diff --git a/LanguageMaster.xml b/LanguageMaster.xml index a8b7ca047..6632e120c 100644 --- a/LanguageMaster.xml +++ b/LanguageMaster.xml @@ -227,7 +227,11 @@ Note: Do check free disk space. File name ending TS settings... Remove line-breaks + Delete lines Try to use source encoding + Delete first lines + Delete last lines + Delete lines containing "Language" in output file name Matroska (.mkv) "Language" in output file name: {0} Two letter language code @@ -2106,6 +2110,9 @@ can edit in same subtitle file (collaboration) List view and text box List view Text box + Use syntax coloring + Html color + ASSA color Update Focus set video position Toggle dock/undock of video controls @@ -2117,6 +2124,8 @@ can edit in same subtitle file (collaboration) Set start, auto duration and go to next Set end, next start and go to next Key down=set start, Key up=set end and go to next + Set start and set end of previous (minus min gap) + Set start and set end of previous and go to next (minus min gap) Move selected lines 100 ms forward Move selected lines 100 ms back Move start {0} ms back @@ -2151,6 +2160,7 @@ can edit in same subtitle file (collaboration) Insert new subtitle at key-down, set end time at key-up Merge dialog (insert dashes) Go to next line + Go to next line and set cursor at end Go to previous line Go to current line start Go to current line end @@ -2274,6 +2284,7 @@ can edit in same subtitle file (collaboration) Move last word from first line down (current subtitle) Selection to lowercase Selection to uppercase + Toggle casing of selection (propercase/uppercase/lowercase) Selection to Ruby (Japanese) Toggle auto duration Auto break text diff --git a/src/SubtitleEdit.sln b/SubtitleEdit.sln similarity index 69% rename from src/SubtitleEdit.sln rename to SubtitleEdit.sln index 0fe045426..101c02e65 100644 --- a/src/SubtitleEdit.sln +++ b/SubtitleEdit.sln @@ -1,73 +1,68 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29728.190 -MinimumVisualStudioVersion = 14.0.23107.0 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubtitleEdit", "SubtitleEdit.csproj", "{511A5B59-1C35-4719-8536-23B19AF9B21A}" - ProjectSection(ProjectDependencies) = postProject - {DBD4656C-5F40-4067-A70B-C4460DE20F77} = {DBD4656C-5F40-4067-A70B-C4460DE20F77} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateAssemblyInfo", "UpdateAssemblyInfo\UpdateAssemblyInfo.csproj", "{DBD4656C-5F40-4067-A70B-C4460DE20F77}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateLanguageFiles", "UpdateLanguageFiles\UpdateLanguageFiles.csproj", "{36BCA2A7-EE6B-45FD-AF90-D3F76A84DA76}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateResourceScript", "UpdateResourceScript\UpdateResourceScript.csproj", "{2CB9698C-F0A8-42FF-8938-DE047292D5FE}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibSE", "..\libse\LibSE.csproj", "{3E3CB28F-3A7B-430F-9EB3-0D6C1E53B753}" - ProjectSection(ProjectDependencies) = postProject - {DBD4656C-5F40-4067-A70B-C4460DE20F77} = {DBD4656C-5F40-4067-A70B-C4460DE20F77} - {36BCA2A7-EE6B-45FD-AF90-D3F76A84DA76} = {36BCA2A7-EE6B-45FD-AF90-D3F76A84DA76} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Win32Resources", "Win32Resources\Win32Resources.vcxproj", "{905ACC84-B353-4313-BFE5-CCF460B959AF}" - ProjectSection(ProjectDependencies) = postProject - {511A5B59-1C35-4719-8536-23B19AF9B21A} = {511A5B59-1C35-4719-8536-23B19AF9B21A} - {2CB9698C-F0A8-42FF-8938-DE047292D5FE} = {2CB9698C-F0A8-42FF-8938-DE047292D5FE} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {511A5B59-1C35-4719-8536-23B19AF9B21A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {511A5B59-1C35-4719-8536-23B19AF9B21A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {511A5B59-1C35-4719-8536-23B19AF9B21A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {511A5B59-1C35-4719-8536-23B19AF9B21A}.Release|Any CPU.Build.0 = Release|Any CPU - {7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}.Release|Any CPU.Build.0 = Release|Any CPU - {DBD4656C-5F40-4067-A70B-C4460DE20F77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DBD4656C-5F40-4067-A70B-C4460DE20F77}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DBD4656C-5F40-4067-A70B-C4460DE20F77}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DBD4656C-5F40-4067-A70B-C4460DE20F77}.Release|Any CPU.Build.0 = Release|Any CPU - {36BCA2A7-EE6B-45FD-AF90-D3F76A84DA76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {36BCA2A7-EE6B-45FD-AF90-D3F76A84DA76}.Debug|Any CPU.Build.0 = Debug|Any CPU - {36BCA2A7-EE6B-45FD-AF90-D3F76A84DA76}.Release|Any CPU.ActiveCfg = Release|Any CPU - {36BCA2A7-EE6B-45FD-AF90-D3F76A84DA76}.Release|Any CPU.Build.0 = Release|Any CPU - {2CB9698C-F0A8-42FF-8938-DE047292D5FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2CB9698C-F0A8-42FF-8938-DE047292D5FE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2CB9698C-F0A8-42FF-8938-DE047292D5FE}.Release|Any CPU.Build.0 = Release|Any CPU - {3E3CB28F-3A7B-430F-9EB3-0D6C1E53B753}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3E3CB28F-3A7B-430F-9EB3-0D6C1E53B753}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3E3CB28F-3A7B-430F-9EB3-0D6C1E53B753}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3E3CB28F-3A7B-430F-9EB3-0D6C1E53B753}.Release|Any CPU.Build.0 = Release|Any CPU - {905ACC84-B353-4313-BFE5-CCF460B959AF}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {905ACC84-B353-4313-BFE5-CCF460B959AF}.Release|Any CPU.ActiveCfg = Release|Win32 - {905ACC84-B353-4313-BFE5-CCF460B959AF}.Release|Any CPU.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E12BDE22-B6A4-4AB6-AF96-F3C0F89C15EC} - EndGlobalSection - GlobalSection(TestCaseManagementSettings) = postSolution - CategoryFile = SubtitleEdit.vsmdi - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29728.190 +MinimumVisualStudioVersion = 14.0.23107.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "src\Test\Test.csproj", "{7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateAssemblyInfo", "src\UpdateAssemblyInfo\UpdateAssemblyInfo.csproj", "{DBD4656C-5F40-4067-A70B-C4460DE20F77}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateLanguageFiles", "src\UpdateLanguageFiles\UpdateLanguageFiles.csproj", "{36BCA2A7-EE6B-45FD-AF90-D3F76A84DA76}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateResourceScript", "src\UpdateResourceScript\UpdateResourceScript.csproj", "{2CB9698C-F0A8-42FF-8938-DE047292D5FE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Win32Resources", "src\Win32Resources\Win32Resources.vcxproj", "{905ACC84-B353-4313-BFE5-CCF460B959AF}" + ProjectSection(ProjectDependencies) = postProject + {511A5B59-1C35-4719-8536-23B19AF9B21A} = {511A5B59-1C35-4719-8536-23B19AF9B21A} + {2CB9698C-F0A8-42FF-8938-DE047292D5FE} = {2CB9698C-F0A8-42FF-8938-DE047292D5FE} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B1BB9DD1-0EE8-4D43-AAAB-C39D0CC882A9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibSE", "src\libse\LibSE.csproj", "{D6F64CD3-C3EA-4B36-B575-9B3B8A3CA13F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubtitleEdit", "src\ui\SubtitleEdit.csproj", "{511A5B59-1C35-4719-8536-23B19AF9B21A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7BE5B8E8-9469-4C7C-89D7-E8C884DEFC0E}.Release|Any CPU.Build.0 = Release|Any CPU + {DBD4656C-5F40-4067-A70B-C4460DE20F77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DBD4656C-5F40-4067-A70B-C4460DE20F77}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DBD4656C-5F40-4067-A70B-C4460DE20F77}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DBD4656C-5F40-4067-A70B-C4460DE20F77}.Release|Any CPU.Build.0 = Release|Any CPU + {36BCA2A7-EE6B-45FD-AF90-D3F76A84DA76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {36BCA2A7-EE6B-45FD-AF90-D3F76A84DA76}.Debug|Any CPU.Build.0 = Debug|Any CPU + {36BCA2A7-EE6B-45FD-AF90-D3F76A84DA76}.Release|Any CPU.ActiveCfg = Release|Any CPU + {36BCA2A7-EE6B-45FD-AF90-D3F76A84DA76}.Release|Any CPU.Build.0 = Release|Any CPU + {2CB9698C-F0A8-42FF-8938-DE047292D5FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CB9698C-F0A8-42FF-8938-DE047292D5FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CB9698C-F0A8-42FF-8938-DE047292D5FE}.Release|Any CPU.Build.0 = Release|Any CPU + {905ACC84-B353-4313-BFE5-CCF460B959AF}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {905ACC84-B353-4313-BFE5-CCF460B959AF}.Release|Any CPU.ActiveCfg = Release|Win32 + {905ACC84-B353-4313-BFE5-CCF460B959AF}.Release|Any CPU.Build.0 = Release|Win32 + {D6F64CD3-C3EA-4B36-B575-9B3B8A3CA13F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6F64CD3-C3EA-4B36-B575-9B3B8A3CA13F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6F64CD3-C3EA-4B36-B575-9B3B8A3CA13F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6F64CD3-C3EA-4B36-B575-9B3B8A3CA13F}.Release|Any CPU.Build.0 = Release|Any CPU + {511A5B59-1C35-4719-8536-23B19AF9B21A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {511A5B59-1C35-4719-8536-23B19AF9B21A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {511A5B59-1C35-4719-8536-23B19AF9B21A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {511A5B59-1C35-4719-8536-23B19AF9B21A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E12BDE22-B6A4-4AB6-AF96-F3C0F89C15EC} + EndGlobalSection + GlobalSection(TestCaseManagementSettings) = postSolution + CategoryFile = SubtitleEdit.vsmdi + EndGlobalSection +EndGlobal diff --git a/SubtitleEdit.sln.DotSettings b/SubtitleEdit.sln.DotSettings new file mode 100644 index 000000000..dd009cf93 --- /dev/null +++ b/SubtitleEdit.sln.DotSettings @@ -0,0 +1,24 @@ + + ExplicitlyExcluded + ExplicitlyExcluded + ExplicitlyExcluded + ExplicitlyExcluded + ExplicitlyExcluded + ExplicitlyExcluded + True + NEVER + False + False + True + False + SSA + True + True + True + True + True + True + True + True + True + True \ No newline at end of file diff --git a/build.bat b/build.bat index 1740cf75f..05e4f9a0f 100644 --- a/build.bat +++ b/build.bat @@ -81,7 +81,6 @@ TITLE %BUILDTYPE%ing Subtitle Edit - Release^|Any CPU... ECHO. ECHO %BUILDTYPE%ing Subtitle Edit - Release^|Any CPU... DEL /F /Q SubtitleEdit-*-Setup.exe SubtitleEdit-*.zip 2>NUL -PUSHD "src" ECHO. ECHO Visual Studio installation path: "%VSINSTALLDIR%" IF EXIST "%VSINSTALLDIR%MSBuild\15.0\Bin\MSBuild.exe" ( @@ -93,16 +92,24 @@ IF EXIST "%VSINSTALLDIR%MSBuild\Current\Bin\MSBuild.exe" ( ECHO Cannot find Visual Studio 2017. GOTO EndWithError )) + "%MSBUILD%" SubtitleEdit.sln /r /t:%BUILDTYPE% /p:Configuration=Release /p:Platform="Any CPU"^ /maxcpucount /consoleloggerparameters:DisableMPLogging;Summary;Verbosity=minimal IF %ERRORLEVEL% NEQ 0 GOTO EndWithError IF /I "%BUILDTYPE%" == "Clean" GOTO EndSuccessful +dir +PUSHD "src/ui" +dir ECHO. ECHO Merging assemblies with ILRepack... FOR /D %%A IN (packages\ILRepack.*) DO (SET "ILREPACKDIR=%%A") ECHO. +dir +echo ILREPACKDIR +echo %ILREPACKDIR% +echo ILREPACKDIR done "%ILREPACKDIR%\tools\ILRepack.exe" /parallel /internalize /targetplatform:v4 /out:"bin\Release\SubtitleEdit.exe" "bin\Release\SubtitleEdit.exe"^ "bin\Release\libse.dll" "bin\Release\zlib.net.dll" "bin\Release\NHunspell.dll" "bin\Release\UtfUnknown.dll" "DLLs\Interop.QuartzTypeLib.dll" IF %ERRORLEVEL% NEQ 0 GOTO EndWithError @@ -166,7 +173,7 @@ EXIT /B TITLE Creating ZIP archive with 7-Zip... ECHO. ECHO Creating ZIP archive with 7-Zip... -PUSHD "src\bin\Release" +PUSHD "src\ui\bin\Release" IF EXIST "temp_zip" RD /S /Q "temp_zip" IF NOT EXIST "temp_zip" MD "temp_zip" IF NOT EXIST "temp_zip\Languages" MD "temp_zip\Languages" @@ -174,14 +181,14 @@ IF NOT EXIST "temp_zip\Dictionaries" MD "temp_zip\Dictionaries" IF NOT EXIST "temp_zip\Ocr" MD "temp_zip\Ocr" ECHO. -COPY /Y /V "..\..\..\LICENSE.txt" "temp_zip\" -COPY /Y /V "..\..\..\Changelog.txt" "temp_zip\" +COPY /Y /V "..\..\..\..\LICENSE.txt" "temp_zip\" +COPY /Y /V "..\..\..\..\Changelog.txt" "temp_zip\" COPY /Y /V "Hunspellx86.dll" "temp_zip\" COPY /Y /V "Hunspellx64.dll" "temp_zip\" COPY /Y /V "SubtitleEdit.exe" "temp_zip\" COPY /Y /V "Languages\*.xml" "temp_zip\Languages\" -COPY /Y /V "..\..\..\Dictionaries\*.*" "temp_zip\Dictionaries\" -COPY /Y /V "..\..\..\Ocr\*.*" "temp_zip\Ocr\" +COPY /Y /V "..\..\..\..\Dictionaries\*.*" "temp_zip\Dictionaries\" +COPY /Y /V "..\..\..\..\Ocr\*.*" "temp_zip\Ocr\" PUSHD "temp_zip" START "" /B /WAIT "%SEVENZIP%" a -tzip -mx=9 "SubtitleEdit-%VERSION%.zip" * >NUL @@ -189,7 +196,7 @@ IF %ERRORLEVEL% NEQ 0 GOTO EndWithError ECHO. ECHO ZIP archive created successfully! -MOVE /Y "SubtitleEdit-%VERSION%.zip" "..\..\..\.." >NUL +MOVE /Y "SubtitleEdit-%VERSION%.zip" "..\..\..\..\.." >NUL POPD IF EXIST "temp_zip" RD /S /Q "temp_zip" POPD @@ -198,7 +205,7 @@ EXIT /B :SubGetVersion -FOR /F delims^=^"^ tokens^=2 %%A IN ('FINDSTR /R /C:"AssemblyVersion" "src\Properties\AssemblyInfo.cs.template"') DO ( +FOR /F delims^=^"^ tokens^=2 %%A IN ('FINDSTR /R /C:"AssemblyVersion" "src\ui\Properties\AssemblyInfo.cs.template"') DO ( REM 3.4.1.[REVNO] SET "VERSION=%%A" ) diff --git a/build_helpers.bat b/build_helpers.bat index 12c9a4651..06ed164cb 100644 --- a/build_helpers.bat +++ b/build_helpers.bat @@ -20,7 +20,7 @@ IF NOT EXIST "%ToolPath%" ( GOTO END ) -"%ToolPath%" "src\Win32Resources\Resources.rc.template" "src\bin\%ConfigurationName%\SubtitleEdit.exe" +"%ToolPath%" "src\Win32Resources\Resources.rc.template" "src\ui\bin\%ConfigurationName%\SubtitleEdit.exe" IF %ERRORLEVEL% NEQ 0 ( ECHO ERROR: Something went wrong when generating the resource script... @@ -35,7 +35,7 @@ IF NOT EXIST "%ToolPath%" ( GOTO END ) -"%ToolPath%" "LanguageMaster.xml" "libse\LanguageDeserializer.cs" +"%ToolPath%" "LanguageMaster.xml" "src\libse\LanguageDeserializer.cs" IF %ERRORLEVEL% NEQ 0 ( ECHO ERROR: Something went wrong when generating the language files... @@ -50,7 +50,7 @@ IF NOT EXIST "%ToolPath%" ( GOTO END ) -"%ToolPath%" "src\Properties\AssemblyInfo.cs.template" "libse\Properties\AssemblyInfo.cs.template" +"%ToolPath%" "src\ui\Properties\AssemblyInfo.cs.template" "src\libse\Properties\AssemblyInfo.cs.template" IF %ERRORLEVEL% NEQ 0 ( ECHO ERROR: Something went wrong when generating the revision number... diff --git a/coverity.bat b/coverity.bat deleted file mode 100644 index dfddfa2fc..000000000 --- a/coverity.bat +++ /dev/null @@ -1,73 +0,0 @@ -@ECHO OFF - -SETLOCAL - -PUSHD %~dp0 - -IF NOT DEFINED COVDIR SET "COVDIR=H:\progs\thirdparty\cov-analysis-win64" -IF DEFINED COVDIR IF NOT EXIST "%COVDIR%" ( - ECHO. - ECHO ERROR: Coverity not found in "%COVDIR%" - GOTO End -) - - -CALL "%VS140COMNTOOLS%\vsvars32.bat" -IF %ERRORLEVEL% NEQ 0 ( - ECHO vsvars32.bat call failed. - GOTO End -) - - -:Cleanup -IF EXIST "cov-int" RD /q /s "cov-int" -IF EXIST "SubtitleEdit.lzma" DEL "SubtitleEdit.lzma" -IF EXIST "SubtitleEdit.tar" DEL "SubtitleEdit.tar" -IF EXIST "SubtitleEdit.tgz" DEL "SubtitleEdit.tgz" - - -:Main -SET MSBUILD_SWITCHES=/nologo /t:Rebuild /p:Configuration=Release /p:Platform="Any CPU"^ - /maxcpucount /consoleloggerparameters:DisableMPLogging;Summary;Verbosity=minimal - -"%COVDIR%\bin\cov-build.exe" --dir cov-int MSBuild.exe src\SubtitleEdit.sln %MSBUILD_SWITCHES% - - -:tar -tar --version 1>&2 2>NUL || (ECHO. & ECHO ERROR: tar not found & GOTO SevenZip) -tar caf "SubtitleEdit.lzma" "cov-int" -GOTO End - - -:SevenZip -CALL :SubDetectSevenzipPath - -rem Coverity is totally bogus with lzma... -rem And since I cannot replicate the arguments with 7-Zip, just use tar/gzip. -IF EXIST "%SEVENZIP%" ( - "%SEVENZIP%" a -ttar "SubtitleEdit.tar" "cov-int" - "%SEVENZIP%" a -tgzip "SubtitleEdit.tgz" "SubtitleEdit.tar" - IF EXIST "SubtitleEdit.tar" DEL "SubtitleEdit.tar" - GOTO End -) - - -:SubDetectSevenzipPath -FOR %%G IN (7z.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G") -IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B) - -FOR %%G IN (7za.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G") -IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B) - -FOR /F "tokens=2*" %%A IN ( - 'REG QUERY "HKLM\SOFTWARE\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ" ^|^| - REG QUERY "HKLM\SOFTWARE\Wow6432Node\7-Zip" /v "Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "SEVENZIP=%%B\7z.exe" -EXIT /B - - -:End -POPD -ECHO. & ECHO Press any key to close this window... -PAUSE >NUL -ENDLOCAL -EXIT /B diff --git a/installer/Subtitle_Edit_installer.iss b/installer/Subtitle_Edit_installer.iss index 80312784e..18cb1dcf0 100644 --- a/installer/Subtitle_Edit_installer.iss +++ b/installer/Subtitle_Edit_installer.iss @@ -44,7 +44,7 @@ #define VerBuild #define VerRevision -#define bindir "..\src\bin\Release" +#define bindir "..\src\ui\bin\Release" #ifnexist bindir + "\SubtitleEdit.exe" #error Compile Subtitle Edit first @@ -92,7 +92,7 @@ VersionInfoVersion={#app_ver_full} MinVersion=5.6 LicenseFile=..\LICENSE.txt InfoAfterFile=..\Changelog.txt -SetupIconFile=..\src\Icons\SE.ico +SetupIconFile=..\src\ui\Icons\SE.ico WizardImageFile=Icons\WizardImageFile.bmp WizardSmallImageFile=Icons\WizardSmallImageFile.bmp OutputDir=. diff --git a/src/packages.config b/packages.config similarity index 100% rename from src/packages.config rename to packages.config diff --git a/run_tabspace.bat b/run_tabspace.bat deleted file mode 100644 index a39cfc067..000000000 --- a/run_tabspace.bat +++ /dev/null @@ -1,10 +0,0 @@ -@ECHO OFF -SETLOCAL - -PUSHD %~dp0 - -tabspace /ext:bat;c;cc;cpp;cs;cxx;h;hpp;hxx;iss;xml /exclude:*\*.designer.cs - -POPD -ENDLOCAL -EXIT /B diff --git a/src/Forms/ChooseAudioTrack.resx b/src/Forms/ChooseAudioTrack.resx deleted file mode 100644 index 29dcb1b3a..000000000 --- a/src/Forms/ChooseAudioTrack.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/Forms/ChooseStyle.resx b/src/Forms/ChooseStyle.resx deleted file mode 100644 index 29dcb1b3a..000000000 --- a/src/Forms/ChooseStyle.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/Forms/ColumnPaste.resx b/src/Forms/ColumnPaste.resx deleted file mode 100644 index 29dcb1b3a..000000000 --- a/src/Forms/ColumnPaste.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/Forms/DoNotBreakAfterListEdit.resx b/src/Forms/DoNotBreakAfterListEdit.resx deleted file mode 100644 index 29dcb1b3a..000000000 --- a/src/Forms/DoNotBreakAfterListEdit.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/Forms/DurationsBridgeGaps.resx b/src/Forms/DurationsBridgeGaps.resx deleted file mode 100644 index 29dcb1b3a..000000000 --- a/src/Forms/DurationsBridgeGaps.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/Forms/DvdSubRipChooseLanguage.resx b/src/Forms/DvdSubRipChooseLanguage.resx deleted file mode 100644 index 29dcb1b3a..000000000 --- a/src/Forms/DvdSubRipChooseLanguage.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/Forms/FcpProperties.resx b/src/Forms/FcpProperties.resx deleted file mode 100644 index 29dcb1b3a..000000000 --- a/src/Forms/FcpProperties.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/Forms/GoogleOrMicrosoftTranslate.resx b/src/Forms/GoogleOrMicrosoftTranslate.resx deleted file mode 100644 index 29dcb1b3a..000000000 --- a/src/Forms/GoogleOrMicrosoftTranslate.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/Forms/Interjections.resx b/src/Forms/Interjections.resx deleted file mode 100644 index 29dcb1b3a..000000000 --- a/src/Forms/Interjections.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/Forms/MeasurementConverter.resx b/src/Forms/MeasurementConverter.resx deleted file mode 100644 index 29dcb1b3a..000000000 --- a/src/Forms/MeasurementConverter.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/Test/Test.csproj b/src/Test/Test.csproj index 2eccdc8a6..2a08429ec 100644 --- a/src/Test/Test.csproj +++ b/src/Test/Test.csproj @@ -92,16 +92,6 @@ - - - {3e3cb28f-3a7b-430f-9eb3-0d6c1e53b753} - LibSE - - - {511A5B59-1C35-4719-8536-23B19AF9B21A} - SubtitleEdit - - @@ -164,7 +154,16 @@ - + + + {d6f64cd3-c3ea-4b36-b575-9b3b8a3ca13f} + LibSE + + + {511a5b59-1c35-4719-8536-23b19af9b21a} + SubtitleEdit + + > 072058 - //Meine Mutter und meine Schwester, - - //-->> 072169 - - //-->> 072172 - //die in Zürich lebt, und ich, - - //-->> 072247 - const string paragraphWriteFormat = "-->> {0}{3}{2}{3}-->> {1}{3}{3}"; - - var sb = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - string text = Utilities.RemoveSsaTags(p.Text); - int noOfLines = Utilities.GetNumberOfLines(text); - if (noOfLines > 2) - { - text = Utilities.AutoBreakLine(text); - } - else if (noOfLines == 1) - { - text += Environment.NewLine; - } - - sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), text, Environment.NewLine)); - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - var paragraph = new Paragraph(); - var expecting = ExpectingLine.TimeStart; - _errorCount = 0; - - subtitle.Paragraphs.Clear(); - foreach (string line in lines) - { - if (line.StartsWith("-->> ", StringComparison.Ordinal)) - { - string timePart = line.Substring(4).Trim(); - if (timePart.Length > 0) - { - try - { - var tc = DecodeTimeCode(timePart); - if (expecting == ExpectingLine.TimeStart) - { - paragraph = new Paragraph { StartTime = tc }; - expecting = ExpectingLine.Text; - } - else if (expecting == ExpectingLine.TimeEndOrText) - { - paragraph.EndTime = tc; - subtitle.Paragraphs.Add(paragraph); - paragraph = new Paragraph(); - expecting = ExpectingLine.TimeStart; - } - } - catch - { - _errorCount++; - expecting = ExpectingLine.TimeStart; - } - } - } - else - { - if (expecting == ExpectingLine.Text || expecting == ExpectingLine.TimeEndOrText) - { - if (line.Length > 0) - { - string text = line.Replace("|", Environment.NewLine); - if (string.IsNullOrEmpty(paragraph.Text)) - { - paragraph.Text = text.Trim(); - } - else - { - paragraph.Text += Environment.NewLine + text; - } - - if (paragraph.Text.Length > 2000) - { - _errorCount += 100; - return; - } - } - expecting = ExpectingLine.TimeEndOrText; - } - else if (expecting == ExpectingLine.TimeStart && !string.IsNullOrWhiteSpace(line)) - { - int ms = (int)paragraph.EndTime.TotalMilliseconds; - paragraph = new Paragraph { StartTime = { TotalMilliseconds = ms }, Text = line.Trim() }; - expecting = ExpectingLine.TimeEndOrText; - } - } - } - subtitle.Renumber(); - } - - private static string EncodeTimeCode(TimeCode time) - { - int frames = MillisecondsToFrames(time.TotalMilliseconds) + 1; - return frames.ToString(CultureInfo.InvariantCulture); - } - - private static TimeCode DecodeTimeCode(string timePart) - { - int milliseconds = (int)Math.Round(TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate * int.Parse(timePart)); - return new TimeCode(milliseconds); - } - - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class AQTitle : SubtitleFormat + { + private enum ExpectingLine + { + TimeStart, + Text, + TimeEndOrText, + } + + public override string Extension => ".aqt"; + + public override string Name => "AQTitle"; + + public override bool IsTimeBased => false; + + public override string ToText(Subtitle subtitle, string title) + { + //-->> 072058 + //Meine Mutter und meine Schwester, + + //-->> 072169 + + //-->> 072172 + //die in Zürich lebt, und ich, + + //-->> 072247 + const string paragraphWriteFormat = "-->> {0}{3}{2}{3}-->> {1}{3}{3}"; + + var sb = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + string text = Utilities.RemoveSsaTags(p.Text); + int noOfLines = Utilities.GetNumberOfLines(text); + if (noOfLines > 2) + { + text = Utilities.AutoBreakLine(text); + } + else if (noOfLines == 1) + { + text += Environment.NewLine; + } + + sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), text, Environment.NewLine)); + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + var paragraph = new Paragraph(); + var expecting = ExpectingLine.TimeStart; + _errorCount = 0; + + subtitle.Paragraphs.Clear(); + foreach (string line in lines) + { + if (line.StartsWith("-->> ", StringComparison.Ordinal)) + { + string timePart = line.Substring(4).Trim(); + if (timePart.Length > 0) + { + try + { + var tc = DecodeTimeCode(timePart); + if (expecting == ExpectingLine.TimeStart) + { + paragraph = new Paragraph { StartTime = tc }; + expecting = ExpectingLine.Text; + } + else if (expecting == ExpectingLine.TimeEndOrText) + { + paragraph.EndTime = tc; + subtitle.Paragraphs.Add(paragraph); + paragraph = new Paragraph(); + expecting = ExpectingLine.TimeStart; + } + } + catch + { + _errorCount++; + expecting = ExpectingLine.TimeStart; + } + } + } + else + { + if (expecting == ExpectingLine.Text || expecting == ExpectingLine.TimeEndOrText) + { + if (line.Length > 0) + { + string text = line.Replace("|", Environment.NewLine); + if (string.IsNullOrEmpty(paragraph.Text)) + { + paragraph.Text = text.Trim(); + } + else + { + paragraph.Text += Environment.NewLine + text; + } + + if (paragraph.Text.Length > 2000) + { + _errorCount += 100; + return; + } + } + expecting = ExpectingLine.TimeEndOrText; + } + else if (expecting == ExpectingLine.TimeStart && !string.IsNullOrWhiteSpace(line)) + { + int ms = (int)paragraph.EndTime.TotalMilliseconds; + paragraph = new Paragraph { StartTime = { TotalMilliseconds = ms }, Text = line.Trim() }; + expecting = ExpectingLine.TimeEndOrText; + } + } + } + subtitle.Renumber(); + } + + private static string EncodeTimeCode(TimeCode time) + { + int frames = MillisecondsToFrames(time.TotalMilliseconds) + 1; + return frames.ToString(CultureInfo.InvariantCulture); + } + + private static TimeCode DecodeTimeCode(string timePart) + { + int milliseconds = (int)Math.Round(TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate * int.Parse(timePart)); + return new TimeCode(milliseconds); + } + + } +} diff --git a/libse/SubtitleFormats/AbcIViewer.cs b/src/libse/SubtitleFormats/AbcIViewer.cs similarity index 97% rename from libse/SubtitleFormats/AbcIViewer.cs rename to src/libse/SubtitleFormats/AbcIViewer.cs index ad8192616..230b47c38 100644 --- a/libse/SubtitleFormats/AbcIViewer.cs +++ b/src/libse/SubtitleFormats/AbcIViewer.cs @@ -1,120 +1,120 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class AbcIViewer : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "ABC iView"; - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - ""; - - var xml = new XmlDocument { XmlResolver = null }; - xml.LoadXml(xmlStructure); - XmlNode reel = xml.DocumentElement.SelectSingleNode("reel"); - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("title"); - - XmlAttribute start = xml.CreateAttribute("start"); - start.InnerText = ToTimeCode(p.StartTime.TotalMilliseconds); - paragraph.Attributes.Append(start); - - XmlAttribute end = xml.CreateAttribute("end"); - end.InnerText = ToTimeCode(p.EndTime.TotalMilliseconds); - paragraph.Attributes.Append(end); - - paragraph.InnerText = HtmlUtil.RemoveHtmlTags(p.Text.Replace(Environment.NewLine, "|"), true); - - reel.AppendChild(paragraph); - } - - return ToUtf8XmlString(xml); - } - - private static string ToTimeCode(double totalMilliseconds) - { - var ts = TimeSpan.FromMilliseconds(totalMilliseconds); - return $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}:{ts.Milliseconds:00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - bool allTwoCifferMs = true; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - - string xmlString = sb.ToString(); - if (!xmlString.Contains(" ".xml"; + + public override string Name => "ABC iView"; + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + ""; + + var xml = new XmlDocument { XmlResolver = null }; + xml.LoadXml(xmlStructure); + XmlNode reel = xml.DocumentElement.SelectSingleNode("reel"); + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("title"); + + XmlAttribute start = xml.CreateAttribute("start"); + start.InnerText = ToTimeCode(p.StartTime.TotalMilliseconds); + paragraph.Attributes.Append(start); + + XmlAttribute end = xml.CreateAttribute("end"); + end.InnerText = ToTimeCode(p.EndTime.TotalMilliseconds); + paragraph.Attributes.Append(end); + + paragraph.InnerText = HtmlUtil.RemoveHtmlTags(p.Text.Replace(Environment.NewLine, "|"), true); + + reel.AppendChild(paragraph); + } + + return ToUtf8XmlString(xml); + } + + private static string ToTimeCode(double totalMilliseconds) + { + var ts = TimeSpan.FromMilliseconds(totalMilliseconds); + return $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}:{ts.Milliseconds:00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + bool allTwoCifferMs = true; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + + string xmlString = sb.ToString(); + if (!xmlString.Contains(" ".xml"; - - public override string Name => "Adobe After Effects ft-MarkerExporter"; - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = @" - - - 1 - - - - - -".Replace("'", "\""); - - var xml = new XmlDocument { XmlResolver = null }; - xml.LoadXml(xmlStructure); - const string innerXml = "", @"{\i}"); - text = text.Replace("", @"{\u1}"); - text = text.Replace("", @"{\u0}"); - text = text.Replace("", @"{\u}"); - text = text.Replace("", @"{\b1}"); - text = text.Replace("", @"{\b0}"); - text = text.Replace("", @"{\b}"); - int count = 0; - while (text.Contains("', start); - if (end > 0) - { - string fontTag = text.Substring(start + 5, end - (start + 4)); - text = text.Remove(start, end - start + 1); - int indexOfEndFont = text.IndexOf("", start, StringComparison.Ordinal); - if (indexOfEndFont > 0) - { - text = text.Remove(indexOfEndFont, 7); - if (indexOfEndFont < text.Length) - { - if (fontTag.Contains(" size=")) - { - text = text.Insert(indexOfEndFont, "{\\fs}"); - } - if (fontTag.Contains(" face=")) - { - text = text.Insert(indexOfEndFont, "{\\fn}"); - } - if (fontTag.Contains(" color=")) - { - text = text.Insert(indexOfEndFont, "{\\c}"); - } - } - } - - fontTag = FormatTag(ref text, start, fontTag, "face=\"", "fn", "}"); - fontTag = FormatTag(ref text, start, fontTag, "face='", "fn", "}"); - fontTag = FormatTag(ref text, start, fontTag, "face=", "fn", "}"); - - fontTag = FormatTag(ref text, start, fontTag, "size=\"", "fs", "}"); - fontTag = FormatTag(ref text, start, fontTag, "size='", "fs", "}"); - fontTag = FormatTag(ref text, start, fontTag, "size=", "fs", "}"); - - fontTag = FormatTag(ref text, start, fontTag, "color=\"", "c&H", "&}"); - fontTag = FormatTag(ref text, start, fontTag, "color='", "c&H", "&}"); - FormatTag(ref text, start, fontTag, "color=", "c&H", "&}"); - } - count++; - } - text = text.Replace("{\\c}", "@___@@").Replace("}{", string.Empty).Replace("@___@@", "{\\c}").Replace("{\\c}{\\c&", "{\\c&"); - while (text.EndsWith("{\\c}", StringComparison.Ordinal)) - { - text = text.Remove(text.Length - 4); - } - while (text.Contains("\\fs\\fs", StringComparison.Ordinal)) - { - text = text.Replace("\\fs\\fs", "\\fs"); - } - while (text.Contains("\\fn\\fn", StringComparison.Ordinal)) - { - text = text.Replace("\\fn\\fn", "\\fn"); - } - while (text.Contains("\\c\\c&H", StringComparison.Ordinal)) - { - text = text.Replace("\\c\\c&H", "\\c&H"); - } - return text; - } - - private static string FormatTag(ref string text, int start, string fontTag, string tag, string ssaTagName, string endSsaTag) - { - if (fontTag.Contains(tag)) - { - int fontStart = fontTag.IndexOf(tag, StringComparison.Ordinal); - - int fontEnd = fontTag.IndexOfAny(new[] { '"', '\'' }, fontStart + tag.Length); - if (fontEnd < 0) - { - fontEnd = fontTag.IndexOfAny(new[] { ' ', '>' }, fontStart + tag.Length); - } - - if (fontEnd > 0) - { - string subTag = fontTag.Substring(fontStart + tag.Length, fontEnd - (fontStart + tag.Length)); - if (tag.Contains("color")) - { - Color c; - try - { - c = ColorTranslator.FromHtml(subTag); - } - catch - { - c = Color.White; - } - subTag = (c.B.ToString("X2") + c.G.ToString("X2") + c.R.ToString("X2")).ToLowerInvariant(); // use bbggrr - } - fontTag = fontTag.Remove(fontStart, fontEnd - fontStart + 1); - if (start < text.Length) - { - text = text.Insert(start, @"{\" + ssaTagName + subTag + endSsaTag); - } - } - } - return fontTag; - } - - public static string GetFormattedText(string input) - { - var text = input.Replace("\\N", Environment.NewLine).Replace("\\n", Environment.NewLine); - - var tooComplex = ContainsUnsupportedTags(text); - - if (!tooComplex) - { - for (int i = 0; i < 10; i++) // just look ten times... - { - bool italic; - if (text.Contains(@"{\fn")) - { - int start = text.IndexOf(@"{\fn", StringComparison.Ordinal); - int end = text.IndexOf('}', start); - if (end > 0 && !text.Substring(start).StartsWith("{\\fn}", StringComparison.Ordinal)) - { - string fontName = text.Substring(start + 4, end - (start + 4)); - string extraTags = string.Empty; - CheckAndAddSubTags(ref fontName, ref extraTags, out var unknownTags, out italic); - text = text.Remove(start, end - start + 1); - if (italic) - { - text = text.Insert(start, "" + unknownTags + ""); - } - else - { - text = text.Insert(start, "" + unknownTags); - } - - int indexOfEndTag = text.IndexOf("{\\fn}", start, StringComparison.Ordinal); - if (indexOfEndTag > 0) - { - text = text.Remove(indexOfEndTag, "{\\fn}".Length).Insert(indexOfEndTag, ""); - } - else - { - int indexOfNextTag1 = text.IndexOf("{\\fn", start, StringComparison.Ordinal); - int indexOfNextTag2 = text.IndexOf("{\\c}", start, StringComparison.Ordinal); - if (indexOfNextTag1 > 0) - { - text = text.Insert(indexOfNextTag1, ""); - } - else if (indexOfNextTag2 > 0 && text.IndexOf("{\\", start, StringComparison.Ordinal) >= indexOfNextTag2) - { - text = text.Insert(indexOfNextTag2, ""); - } - else - { - text += ""; - } - } - } - } - - if (text.Contains(@"{\fs")) - { - int start = text.IndexOf(@"{\fs", StringComparison.Ordinal); - int end = text.IndexOf('}', start); - if (end > 0 && !text.Substring(start).StartsWith("{\\fs}", StringComparison.Ordinal)) - { - string fontSize = text.Substring(start + 4, end - (start + 4)); - string extraTags = string.Empty; - CheckAndAddSubTags(ref fontSize, ref extraTags, out var unknownTags, out italic); - if (float.TryParse(fontSize, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _)) - { - text = text.Remove(start, end - start + 1); - if (italic) - { - text = text.Insert(start, "" + unknownTags + ""); - } - else - { - text = text.Insert(start, "" + unknownTags); - } - - int indexOfEndTag = text.IndexOf("{\\fs}", start, StringComparison.Ordinal); - if (indexOfEndTag > 0) - { - text = text.Remove(indexOfEndTag, "{\\fs}".Length).Insert(indexOfEndTag, ""); - } - else - { - int indexOfNextTag1 = text.IndexOf("{\\fs", start, StringComparison.Ordinal); - int indexOfNextTag2 = text.IndexOf("{\\c}", start, StringComparison.Ordinal); - if (indexOfNextTag1 > 0) - { - text = text.Insert(indexOfNextTag1, ""); - } - else if (indexOfNextTag2 > 0 && text.IndexOf("{\\", start, StringComparison.Ordinal) >= indexOfNextTag2) - { - text = text.Insert(indexOfNextTag2, ""); - } - else - { - text += ""; - } - } - } - } - } - - if (text.Contains(@"{\c")) - { - int start = text.IndexOf(@"{\c", StringComparison.Ordinal); - int end = text.IndexOf('}', start); - if (end > 0 && !text.Substring(start).StartsWith("{\\c}", StringComparison.Ordinal) && !text.Substring(start).StartsWith("{\\clip", StringComparison.Ordinal)) - { - string color = text.Substring(start + 4, end - (start + 4)); - string extraTags = string.Empty; - CheckAndAddSubTags(ref color, ref extraTags, out var unknownTags, out italic); - - color = color.RemoveChar('&').TrimStart('H'); - color = color.PadLeft(6, '0'); - - // switch to rrggbb from bbggrr - color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2); - color = color.ToLowerInvariant(); - - text = text.Remove(start, end - start + 1); - if (italic) - { - text = text.Insert(start, "" + unknownTags + ""); - } - else - { - text = text.Insert(start, "" + unknownTags); - } - - int indexOfEndTag = text.IndexOf("{\\c}", start, StringComparison.Ordinal); - int indexOfNextColorTag = text.IndexOf("{\\c&", start, StringComparison.Ordinal); - if (indexOfNextColorTag > 0 && (indexOfNextColorTag < indexOfEndTag || indexOfEndTag == -1)) - { - text = text.Insert(indexOfNextColorTag, ""); - } - else if (indexOfEndTag > 0) - { - text = text.Remove(indexOfEndTag, "{\\c}".Length).Insert(indexOfEndTag, ""); - } - else - { - text += ""; - } - } - } - - if (text.Contains(@"{\1c")) // "1" specifices primary color - { - int start = text.IndexOf(@"{\1c", StringComparison.Ordinal); - int end = text.IndexOf('}', start); - if (end > 0 && !text.Substring(start).StartsWith("{\\1c}", StringComparison.Ordinal)) - { - string color = text.Substring(start + 5, end - (start + 5)); - string extraTags = string.Empty; - CheckAndAddSubTags(ref color, ref extraTags, out var unknownTags, out italic); - - color = color.RemoveChar('&').TrimStart('H'); - color = color.PadLeft(6, '0'); - - // switch to rrggbb from bbggrr - color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2); - color = color.ToLowerInvariant(); - - text = text.Remove(start, end - start + 1); - if (italic) - { - text = text.Insert(start, "" + unknownTags + ""); - } - else - { - text = text.Insert(start, "" + unknownTags); - } - - text += ""; - } - } - } - } - - text = text.Replace(@"{\i1}", ""); - text = text.Replace(@"{\i0}", ""); - text = text.Replace(@"{\i}", ""); - if (Utilities.CountTagInText(text, "") > Utilities.CountTagInText(text, "")) - { - text += ""; - } - - text = text.Replace(@"{\u1}", ""); - text = text.Replace(@"{\u0}", ""); - text = text.Replace(@"{\u}", ""); - if (Utilities.CountTagInText(text, "") > Utilities.CountTagInText(text, "")) - { - text += ""; - } - - text = text.Replace(@"{\b1}", ""); - text = text.Replace(@"{\b0}", ""); - text = text.Replace(@"{\b}", ""); - if (Utilities.CountTagInText(text, "") > Utilities.CountTagInText(text, "")) - { - text += ""; - } - - return text; - } - - private static bool ContainsUnsupportedTags(string text) - { - if (string.IsNullOrEmpty(text) || !text.Contains("{\\", StringComparison.OrdinalIgnoreCase)) - { - return false; - } - - var unsupportedTags = new List - { - "\\alpha", - "\\be0", - "\\be1", - "\\bord", - "\\blur", - "\\clip", - "\\fad", - "\\fa", - "\\fade", - "\\fscx", - "\\fscy", - "\\fr", - "\\iclip", - "\\k", - "\\K", - "\\kf", - "\\ko", - "\\move", - "\\org", - "\\p", - "\\pos", - "\\s0", - "\\s1", - "\\t(", - "\\xbord", - "\\ybord", - "\\xshad", - "\\yshad" - }; - - foreach (var unsupportedTag in unsupportedTags) - { - if (text.Contains(unsupportedTag, StringComparison.Ordinal)) - { - return true; - } - } - - return false; - } - - private static void CheckAndAddSubTags(ref string tagName, ref string extraTags, out string unknownTags, out bool italic) - { - italic = false; - unknownTags = string.Empty; - int indexOfSPlit = tagName.IndexOf('\\'); - if (indexOfSPlit > 0) - { - string rest = tagName.Substring(indexOfSPlit).TrimStart('\\'); - tagName = tagName.Remove(indexOfSPlit); - - for (int i = 0; i < 10; i++) - { - if (rest.StartsWith("fs", StringComparison.Ordinal) && rest.Length > 2) - { - indexOfSPlit = rest.IndexOf('\\'); - string fontSize = rest; - if (indexOfSPlit > 0) - { - fontSize = rest.Substring(0, indexOfSPlit); - rest = rest.Substring(indexOfSPlit).TrimStart('\\'); - } - else - { - rest = string.Empty; - } - extraTags += " size=\"" + fontSize.Substring(2) + "\""; - } - else if (rest.StartsWith("fn", StringComparison.Ordinal) && rest.Length > 2) - { - indexOfSPlit = rest.IndexOf('\\'); - string fontName = rest; - if (indexOfSPlit > 0) - { - fontName = rest.Substring(0, indexOfSPlit); - rest = rest.Substring(indexOfSPlit).TrimStart('\\'); - } - else - { - rest = string.Empty; - } - extraTags += " face=\"" + fontName.Substring(2) + "\""; - } - else if (rest.StartsWith('c') && rest.Length > 2) - { - indexOfSPlit = rest.IndexOf('\\'); - string fontColor = rest; - if (indexOfSPlit > 0) - { - fontColor = rest.Substring(0, indexOfSPlit); - rest = rest.Substring(indexOfSPlit).TrimStart('\\'); - } - else - { - rest = string.Empty; - } - - string color = fontColor.Substring(2); - color = color.RemoveChar('&').TrimStart('H'); - color = color.PadLeft(6, '0'); - // switch to rrggbb from bbggrr - color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2); - color = color.ToLowerInvariant(); - - extraTags += " color=\"" + color + "\""; - } - else if (rest.StartsWith("i1", StringComparison.Ordinal) && rest.Length > 1) - { - indexOfSPlit = rest.IndexOf('\\'); - italic = true; - if (indexOfSPlit > 0) - { - rest = rest.Substring(indexOfSPlit).TrimStart('\\'); - } - else - { - rest = string.Empty; - } - } - else if (rest.Length > 0 && rest.Contains("\\")) - { - indexOfSPlit = rest.IndexOf('\\'); - var unknowntag = rest.Substring(0, indexOfSPlit); - unknownTags += "\\" + unknowntag; - rest = rest.Substring(indexOfSPlit).TrimStart('\\'); - } - else if (!string.IsNullOrEmpty(rest)) - { - unknownTags += "\\" + rest; - rest = string.Empty; - } - } - } - if (!string.IsNullOrEmpty(unknownTags)) - { - unknownTags = "{" + unknownTags + "}"; - } - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - Errors = null; - bool eventsStarted = false; - bool fontsStarted = false; - bool graphicsStarted = false; - subtitle.Paragraphs.Clear(); - - // Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text - int indexLayer = 0; - int indexStart = 1; - int indexEnd = 2; - int indexStyle = 3; - int indexActor = -1; // convert "Actor" to "Nam" (if no "Name") - int indexName = 4; - int indexMarginL = 5; - int indexMarginR = 6; - int indexMarginV = 7; - int indexEffect = 8; - int indexText = 9; - var errors = new StringBuilder(); - int lineNumber = 0; - - var header = new StringBuilder(); - var footer = new StringBuilder(); - foreach (string line in lines) - { - lineNumber++; - if (!eventsStarted && !fontsStarted && !graphicsStarted && - !line.Trim().Equals("[fonts]", StringComparison.InvariantCultureIgnoreCase) && - !line.Trim().Equals("[graphics]", StringComparison.InvariantCultureIgnoreCase)) - { - header.AppendLine(line); - } - - if (string.IsNullOrWhiteSpace(line) || line.TrimStart().StartsWith(';')) - { - // skip empty and comment lines - } - else if (line.TrimStart().StartsWith("dialog:", StringComparison.OrdinalIgnoreCase) || line.TrimStart().StartsWith("dialogue:", StringComparison.OrdinalIgnoreCase)) // fix faulty font tags... - { - eventsStarted = true; - fontsStarted = false; - graphicsStarted = false; - } - - if (line.Trim().Equals("[events]", StringComparison.OrdinalIgnoreCase)) - { - if (header.ToString().IndexOf(Environment.NewLine + "[events]", StringComparison.OrdinalIgnoreCase) < 0) - { - var h = header.ToString().TrimEnd(); - header.Clear(); - header.AppendLine(h); - header.AppendLine(); - header.AppendLine("[Events]"); - } - eventsStarted = true; - fontsStarted = false; - graphicsStarted = false; - } - else if (line.Trim().Equals("[fonts]", StringComparison.OrdinalIgnoreCase)) - { - eventsStarted = false; - fontsStarted = true; - graphicsStarted = false; - footer.AppendLine(); - footer.AppendLine("[Fonts]"); - } - else if (line.Trim().Equals("[graphics]", StringComparison.OrdinalIgnoreCase)) - { - eventsStarted = false; - fontsStarted = false; - graphicsStarted = true; - footer.AppendLine(); - footer.AppendLine("[Graphics]"); - } - else if (line.Trim().Equals("[Aegisub Extradata]", StringComparison.OrdinalIgnoreCase)) - { - eventsStarted = false; - fontsStarted = false; - graphicsStarted = true; - footer.AppendLine(); - footer.AppendLine("[Aegisub Extradata]"); - } - else if (fontsStarted) - { - footer.AppendLine(line); - } - else if (graphicsStarted) - { - footer.AppendLine(line); - } - else if (eventsStarted) - { - string s = line.Trim().ToLowerInvariant(); - if (line.Length > 10 && s.StartsWith("format:", StringComparison.Ordinal)) - { - indexLayer = -1; - indexStart = -1; - indexEnd = -1; - indexStyle = -1; - indexActor = -1; - indexName = -1; - indexMarginL = -1; - indexMarginR = -1; - indexMarginV = -1; - indexEffect = -1; - indexText = -1; - - var format = s.Substring(8).Split(','); - for (int i = 0; i < format.Length; i++) - { - var formatTrimmed = format[i].Trim(); - if (formatTrimmed.Equals("start", StringComparison.Ordinal)) - { - indexStart = i; - } - else if (formatTrimmed.Equals("end", StringComparison.Ordinal)) - { - indexEnd = i; - } - else if (formatTrimmed.Equals("text", StringComparison.Ordinal)) - { - indexText = i; - } - else if (formatTrimmed.Equals("style", StringComparison.Ordinal)) - { - indexStyle = i; - } - else if (formatTrimmed.Equals("actor", StringComparison.Ordinal)) - { - indexActor = i; - } - else if (formatTrimmed.Equals("name", StringComparison.Ordinal)) - { - indexName = i; - } - else if (formatTrimmed.Equals("marginl", StringComparison.Ordinal)) - { - indexMarginL = i; - } - else if (formatTrimmed.Equals("marginr", StringComparison.Ordinal)) - { - indexMarginR = i; - } - else if (formatTrimmed.Equals("marginv", StringComparison.Ordinal)) - { - indexMarginV = i; - } - else if (formatTrimmed.Equals("effect", StringComparison.Ordinal)) - { - indexEffect = i; - } - else if (formatTrimmed.Equals("layer", StringComparison.Ordinal)) - { - indexLayer = i; - } - } - } - else if (!string.IsNullOrEmpty(s)) - { - var text = string.Empty; - var start = string.Empty; - var end = string.Empty; - var style = string.Empty; - var actor = string.Empty; - var marginL = string.Empty; - var marginR = string.Empty; - var marginV = string.Empty; - var effect = string.Empty; - var layer = 0; - - string[] splittedLine; - if (s.StartsWith("dialog:", StringComparison.Ordinal)) - { - splittedLine = line.Remove(0, 7).Split(','); - } - else if (s.StartsWith("dialogue:", StringComparison.Ordinal)) - { - splittedLine = line.Remove(0, 9).Split(','); - } - else - { - splittedLine = line.Split(','); - } - - for (int i = 0; i < splittedLine.Length; i++) - { - if (i == indexStart) - { - start = splittedLine[i].Trim(); - } - else if (i == indexEnd) - { - end = splittedLine[i].Trim(); - } - else if (i == indexStyle) - { - style = splittedLine[i].Trim(); - } - else if (i == indexActor && indexName == -1) - { - actor = splittedLine[i].Trim(); - } - else if (i == indexName) - { - actor = splittedLine[i].Trim(); - } - else if (i == indexMarginL) - { - marginL = splittedLine[i].Trim(); - } - else if (i == indexMarginR) - { - marginR = splittedLine[i].Trim(); - } - else if (i == indexMarginV) - { - marginV = splittedLine[i].Trim(); - } - else if (i == indexEffect) - { - effect = splittedLine[i].Trim(); - } - else if (i == indexLayer) - { - int.TryParse(splittedLine[i].Replace("Comment:", string.Empty).Trim(), out layer); - } - else if (i == indexText) - { - text = splittedLine[i]; - } - else if (i > indexText) - { - text += "," + splittedLine[i]; - } - } - - try - { - var p = new Paragraph - { - StartTime = GetTimeCodeFromString(start), - EndTime = GetTimeCodeFromString(end), - Text = GetFormattedText(text) - }; - - if (!string.IsNullOrEmpty(style)) - { - p.Extra = style; - } - - if (!string.IsNullOrEmpty(actor)) - { - p.Actor = actor; - } - - if (!string.IsNullOrEmpty(marginL)) - { - p.MarginL = marginL; - } - - if (!string.IsNullOrEmpty(marginR)) - { - p.MarginR = marginR; - } - - if (!string.IsNullOrEmpty(marginV)) - { - p.MarginV = marginV; - } - - if (!string.IsNullOrEmpty(effect)) - { - p.Effect = effect; - } - - p.Layer = layer; - p.IsComment = s.StartsWith("comment:", StringComparison.Ordinal); - subtitle.Paragraphs.Add(p); - } - catch - { - _errorCount++; - if (errors.Length < 2000) - { - errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXErrorReadingTimeCodeFromSourceLineY, lineNumber, line)); - } - else if (subtitle.Paragraphs.Count == 0) - { - break; - } - } - } - } - } - if (header.Length > 0) - { - subtitle.Header = header.ToString(); - } - - if (footer.Length > 0) - { - subtitle.Footer = footer.ToString().Trim(); - } - - subtitle.Renumber(); - Errors = errors.ToString(); - } - - private static TimeCode GetTimeCodeFromString(string time) - { - // h:mm:ss.cc - string[] timeCode = time.Split(':', '.'); - return new TimeCode(int.Parse(timeCode[0]), - int.Parse(timeCode[1]), - int.Parse(timeCode[2]), - int.Parse(timeCode[3]) * 10); - } - - public override void RemoveNativeFormatting(Subtitle subtitle, SubtitleFormat newFormat) - { - if (newFormat != null && newFormat.Name == SubStationAlpha.NameOfFormat) - { - foreach (var p in subtitle.Paragraphs) - { - string s = p.Text; - - if (s.Contains('{') && s.Contains('}')) - { - var p1Index = s.IndexOf("\\p1", StringComparison.Ordinal); - var p0Index = s.IndexOf("{\\p0}", StringComparison.Ordinal); - if (p1Index > 0 && (p0Index > p1Index || p0Index == -1)) - { - var startTagIndex = s.Substring(0, p1Index).LastIndexOf('{'); - if (startTagIndex >= 0) - { - if (p0Index > p1Index) - { - s = s.Remove(startTagIndex, p0Index - startTagIndex + "{\\p0}".Length); - } - else - { - s = s.Remove(startTagIndex); - } - } - } - - var karaokeStart = s.IndexOf("{Kara Effector", StringComparison.Ordinal); - if (karaokeStart >= 0) - { - int l = s.IndexOf('}', karaokeStart + 1); - if (l < karaokeStart) - { - break; - } - - s = s.Remove(karaokeStart, l - karaokeStart + 1); - } - - s = s.Replace(@"\u0", string.Empty); - s = s.Replace(@"\u1", string.Empty); - s = s.Replace(@"\s0", string.Empty); - s = s.Replace(@"\s1", string.Empty); - s = s.Replace(@"\be0", string.Empty); - s = s.Replace(@"\be1", string.Empty); - - s = RemoveTag(s, "shad"); - s = RemoveTag(s, "fsc"); - s = RemoveTag(s, "fsp"); - s = RemoveTag(s, "fr"); - - s = RemoveTag(s, "t("); - s = RemoveTag(s, "move("); - s = RemoveTag(s, "Position("); - s = RemoveTag(s, "org("); - s = RemoveTag(s, "fade("); - s = RemoveTag(s, "fad("); - s = RemoveTag(s, "clip("); - s = RemoveTag(s, "iclip("); - s = RemoveTag(s, "pbo("); - s = RemoveTag(s, "bord"); - s = RemoveTag(s, "pos"); - - // TODO: Alignment tags - - s = s.Replace("{}", string.Empty); - - p.Text = s; - } - } - } - else - { - foreach (var p in subtitle.Paragraphs) - { - var noTags = Utilities.RemoveSsaTags(p.Text).Trim(); - if (noTags.Length == 0) - { - p.Text = string.Empty; - continue; - } - - p.Text = p.Text.Replace("\\n", Environment.NewLine); // Soft line break - p.Text = p.Text.Replace("\\N", Environment.NewLine); // Hard line break - p.Text = p.Text.Replace("\\h", " "); // Hard space - - if (noTags.StartsWith("m ", StringComparison.Ordinal)) - { - var test = noTags.Remove(0, 2) - .RemoveChar('0') - .RemoveChar('1') - .RemoveChar('2') - .RemoveChar('3') - .RemoveChar('4') - .RemoveChar('5') - .RemoveChar('6') - .RemoveChar('7') - .RemoveChar('8') - .RemoveChar('9') - .RemoveChar('-') - .RemoveChar('l') - .RemoveChar('m') - .RemoveChar(' ') - .RemoveChar('.'); - if (test.Length == 0) - { - p.Text = string.Empty; - continue; - } - } - - int indexOfBegin = p.Text.IndexOf('{'); - string pre = string.Empty; - while (indexOfBegin >= 0 && p.Text.IndexOf('}') > indexOfBegin) - { - string s = p.Text.Substring(indexOfBegin); - if (s.StartsWith("{\\an1}", StringComparison.Ordinal) || - s.StartsWith("{\\an2}", StringComparison.Ordinal) || - s.StartsWith("{\\an3}", StringComparison.Ordinal) || - s.StartsWith("{\\an4}", StringComparison.Ordinal) || - s.StartsWith("{\\an5}", StringComparison.Ordinal) || - s.StartsWith("{\\an6}", StringComparison.Ordinal) || - s.StartsWith("{\\an7}", StringComparison.Ordinal) || - s.StartsWith("{\\an8}", StringComparison.Ordinal) || - s.StartsWith("{\\an9}", StringComparison.Ordinal)) - { - pre = s.Substring(0, 6); - } - else if (s.StartsWith("{\\an1\\", StringComparison.Ordinal) || - s.StartsWith("{\\an2\\", StringComparison.Ordinal) || - s.StartsWith("{\\an3\\", StringComparison.Ordinal) || - s.StartsWith("{\\an4\\", StringComparison.Ordinal) || - s.StartsWith("{\\an5\\", StringComparison.Ordinal) || - s.StartsWith("{\\an6\\", StringComparison.Ordinal) || - s.StartsWith("{\\an7\\", StringComparison.Ordinal) || - s.StartsWith("{\\an8\\", StringComparison.Ordinal) || - s.StartsWith("{\\an9\\", StringComparison.Ordinal)) - { - pre = s.Substring(0, 5) + "}"; - } - int indexOfEnd = p.Text.IndexOf('}'); - p.Text = p.Text.Remove(indexOfBegin, indexOfEnd - indexOfBegin + 1); - - indexOfBegin = p.Text.IndexOf('{'); - } - p.Text = pre + p.Text; - } - } - } - - private static string RemoveTag(string s, string tag) - { - int indexOfTag = s.IndexOf(@"\" + tag, StringComparison.Ordinal); - if (indexOfTag > 0) - { - var endIndex1 = s.IndexOf('\\', indexOfTag + 1); - var endIndex2 = s.IndexOf('}', indexOfTag + 1); - endIndex1 = Math.Min(endIndex1, endIndex2); - if (endIndex1 > 0) - { - return s.Remove(indexOfTag, endIndex1 - indexOfTag); - } - } - return s; - } - - /// - /// BGR color like this: &HBBGGRR& (where BB, GG, and RR are hex values in uppercase) - /// - /// Input string - /// Default color - /// Input string as color, or default color if problems - public static Color GetSsaColor(string f, Color defaultColor) - { - //Red = &H0000FF& - //Green = &H00FF00& - //Blue = &HFF0000& - //White = &HFFFFFF& - //Black = &H000000& - string s = f.Trim().Trim('&'); - - if (s.StartsWith('h') && s.Length < 7) - { - while (s.Length < 7) - { - s = s.Insert(1, "0"); - } - } - - if (s.StartsWith('h') && s.Length == 7) - { - s = s.Substring(1); - string hexColor = "#" + s.Substring(4, 2) + s.Substring(2, 2) + s.Substring(0, 2); - try - { - return ColorTranslator.FromHtml(hexColor); - } - catch - { - return defaultColor; - } - } - if (s.StartsWith('h') && s.Length == 9) - { - if (int.TryParse(s.Substring(1, 2), NumberStyles.HexNumber, null, out var alpha)) - { - alpha = 255 - alpha; // ASS stores alpha in reverse (0=full itentity and 255=fully transparent) - } - else - { - alpha = 255; // full color - } - s = s.Substring(3); - string hexColor = "#" + s.Substring(4, 2) + s.Substring(2, 2) + s.Substring(0, 2); - try - { - var c = ColorTranslator.FromHtml(hexColor); - return Color.FromArgb(alpha, c); - } - catch - { - return defaultColor; - } - } - - if (int.TryParse(f, out var number)) - { - var temp = Color.FromArgb(number); - return Color.FromArgb(255, temp.B, temp.G, temp.R); - } - return defaultColor; - } - - public static string GetSsaColorString(Color c) - { - return $"&H{255 - c.A:X2}{c.B:X2}{c.G:X2}{c.R:X2}"; // ASS stores alpha in reverse (0=full itentity and 255=fully transparent) - } - - public static string CheckForErrors(string header) - { - if (string.IsNullOrEmpty(header)) - { - return string.Empty; - } - - var sb = new StringBuilder(); - - int styleCount = -1; - - int nameIndex = -1; - int fontNameIndex = -1; - int fontsizeIndex = -1; - int primaryColourIndex = -1; - int secondaryColourIndex = -1; - int outlineColourIndex = -1; - int backColourIndex = -1; - int boldIndex = -1; - int italicIndex = -1; - int underlineIndex = -1; - int outlineIndex = -1; - int shadowIndex = -1; - int alignmentIndex = -1; - int marginLIndex = -1; - int marginRIndex = -1; - int marginVIndex = -1; - int borderStyleIndex = -1; - - foreach (string line in header.SplitToLines()) - { - string s = line.Trim().ToLowerInvariant(); - if (s.StartsWith("format:", StringComparison.Ordinal)) - { - if (line.Length > 10) - { - var format = line.Substring(8).ToLowerInvariant().Split(','); - styleCount = format.Length; - for (int i = 0; i < format.Length; i++) - { - string f = format[i].Trim(); - if (f == "name") - { - nameIndex = i; - } - else if (f == "fontname") - { - fontNameIndex = i; - } - else if (f == "fontsize") - { - fontsizeIndex = i; - } - else if (f == "primarycolour") - { - primaryColourIndex = i; - } - else if (f == "secondarycolour") - { - secondaryColourIndex = i; - } - else if (f == "outlinecolour") - { - outlineColourIndex = i; - } - else if (f == "backcolour") - { - backColourIndex = i; - } - else if (f == "bold") - { - boldIndex = i; - } - else if (f == "italic") - { - italicIndex = i; - } - else if (f == "underline") - { - underlineIndex = i; - } - else if (f == "outline") - { - outlineIndex = i; - } - else if (f == "shadow") - { - shadowIndex = i; - } - else if (f == "alignment") - { - alignmentIndex = i; - } - else if (f == "marginl") - { - marginLIndex = i; - } - else if (f == "marginr") - { - marginRIndex = i; - } - else if (f == "marginv") - { - marginVIndex = i; - } - else if (f == "borderstyle") - { - borderStyleIndex = i; - } - } - } - } - else if (s.RemoveChar(' ').StartsWith("style:", StringComparison.Ordinal)) - { - if (line.Length > 10) - { - string rawLine = line; - var format = line.Substring(6).Split(','); - - if (format.Length != styleCount) - { - sb.AppendLine("Number of expected Style elements do not match number of Format elements: " + rawLine); - sb.AppendLine(); - } - else - { - var dummyColor = Color.FromArgb(9, 14, 16, 26); - for (int i = 0; i < format.Length; i++) - { - string f = format[i].Trim().ToLowerInvariant(); - if (i == nameIndex) - { - if (f.Length == 0) - { - sb.AppendLine("'Name' is empty: " + rawLine); - sb.AppendLine(); - } - } - else if (i == fontNameIndex) - { - if (f.Length == 0) - { - sb.AppendLine("'Fontname' is empty: " + rawLine); - sb.AppendLine(); - } - } - else if (i == fontsizeIndex) - { - if (!float.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _) || f.StartsWith('-')) - { - sb.AppendLine("'Fontsize' incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == primaryColourIndex) - { - if (GetSsaColor(f, dummyColor) == dummyColor || f == "&h") - { - sb.AppendLine("'PrimaryColour' incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == secondaryColourIndex) - { - if (GetSsaColor(f, dummyColor) == dummyColor) - { - sb.AppendLine("'SecondaryColour' incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == outlineColourIndex) - { - if (GetSsaColor(f, dummyColor) == dummyColor) - { - sb.AppendLine("'OutlineColour' incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == backColourIndex) - { - if (GetSsaColor(f, dummyColor) == dummyColor) - { - sb.AppendLine("'BackColour' incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == boldIndex) - { - if (Utilities.AllLetters.Contains(f)) - { - sb.AppendLine("'Bold' incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == italicIndex) - { - if (Utilities.AllLetters.Contains(f)) - { - sb.AppendLine("'Italic' incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == underlineIndex) - { - if (Utilities.AllLetters.Contains(f)) - { - sb.AppendLine("'Underline' incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == outlineIndex) - { - if (!float.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _) || f.StartsWith('-')) - { - sb.AppendLine("'Outline' (width) incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == shadowIndex) - { - if (!float.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _) || f.StartsWith('-')) - { - sb.AppendLine("'Shadow' (width) incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == alignmentIndex) - { - if (!"101123456789 ".Contains(f)) - { - sb.AppendLine("'Alignment' incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == marginLIndex) - { - if (!int.TryParse(f, out _) || f.StartsWith('-')) - { - sb.AppendLine("'MarginL' incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == marginRIndex) - { - if (!int.TryParse(f, out _) || f.StartsWith('-')) - { - sb.AppendLine("'MarginR' incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == marginVIndex) - { - if (!int.TryParse(f, out _) || f.StartsWith('-')) - { - sb.AppendLine("'MarginV' incorrect: " + rawLine); - sb.AppendLine(); - } - } - else if (i == borderStyleIndex) - { - if (f.Length != 0 && !"123".Contains(f)) - { - sb.AppendLine("'BorderStyle' incorrect: " + rawLine); - sb.AppendLine(); - } - } - } - } - } - } - } - return sb.ToString(); - } - - /// - /// Add new style to ASS header - /// - /// Header with new style - public static string AddSsaStyle(SsaStyle style, string inputHeader) - { - var header = inputHeader; - if (string.IsNullOrEmpty(header)) - { - header = DefaultHeader; - } - - var sb = new StringBuilder(); - bool stylesStarted = false; - bool styleAdded = false; - string styleFormat = "Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding"; - foreach (string line in header.SplitToLines()) - { - if (line.Equals("[V4+ Styles]", StringComparison.OrdinalIgnoreCase) || line.Equals("[V4 Styles]", StringComparison.OrdinalIgnoreCase)) - { - stylesStarted = true; - } - - if (line.StartsWith("format:", StringComparison.OrdinalIgnoreCase)) - { - styleFormat = line; - } - - if (!line.StartsWith("Style: " + style.Name + ",", StringComparison.Ordinal)) // overwrite existing style - { - sb.AppendLine(line); - } - - if (!styleAdded && stylesStarted && line.TrimStart().StartsWith("style:", StringComparison.OrdinalIgnoreCase)) - { - sb.AppendLine(style.ToRawAss(styleFormat)); - styleAdded = true; - } - } - return sb.ToString(); - } - - public static SsaStyle GetSsaStyle(string styleName, string header) - { - var style = new SsaStyle { Name = styleName }; - - int nameIndex = -1; - int fontNameIndex = -1; - int fontsizeIndex = -1; - int primaryColourIndex = -1; - int secondaryColourIndex = -1; - int tertiaryColourIndex = -1; - int outlineColourIndex = -1; - int backColourIndex = -1; - int boldIndex = -1; - int italicIndex = -1; - int underlineIndex = -1; - int outlineIndex = -1; - int shadowIndex = -1; - int alignmentIndex = -1; - int marginLIndex = -1; - int marginRIndex = -1; - int marginVIndex = -1; - int borderStyleIndex = -1; - - if (header == null) - { - header = DefaultHeader; - } - - foreach (string line in header.SplitToLines()) - { - string s = line.Trim().ToLowerInvariant(); - if (s.StartsWith("format:", StringComparison.Ordinal)) - { - if (line.Length > 10) - { - var format = line.ToLowerInvariant().Substring(8).Split(','); - for (int i = 0; i < format.Length; i++) - { - string f = format[i].Trim().ToLowerInvariant(); - if (f == "name") - { - nameIndex = i; - } - else if (f == "fontname") - { - fontNameIndex = i; - } - else if (f == "fontsize") - { - fontsizeIndex = i; - } - else if (f == "primarycolour") - { - primaryColourIndex = i; - } - else if (f == "secondarycolour") - { - secondaryColourIndex = i; - } - else if (f == "tertiarycolour") - { - tertiaryColourIndex = i; - } - else if (f == "outlinecolour") - { - outlineColourIndex = i; - } - else if (f == "backcolour") - { - backColourIndex = i; - } - else if (f == "bold") - { - boldIndex = i; - } - else if (f == "italic") - { - italicIndex = i; - } - else if (f == "underline") - { - underlineIndex = i; - } - else if (f == "outline") - { - outlineIndex = i; - } - else if (f == "shadow") - { - shadowIndex = i; - } - else if (f == "alignment") - { - alignmentIndex = i; - } - else if (f == "marginl") - { - marginLIndex = i; - } - else if (f == "marginr") - { - marginRIndex = i; - } - else if (f == "marginv") - { - marginVIndex = i; - } - else if (f == "borderstyle") - { - borderStyleIndex = i; - } - } - } - } - else if (s.RemoveChar(' ').StartsWith("style:", StringComparison.Ordinal)) - { - if (line.Length > 10) - { - style.RawLine = line; - var format = line.Substring(6).Split(','); - for (int i = 0; i < format.Length; i++) - { - string f = format[i].Trim().ToLowerInvariant(); - if (i == nameIndex) - { - style.Name = format[i].Trim(); - } - else if (i == fontNameIndex) - { - style.FontName = f; - } - else if (i == fontsizeIndex) - { - if (float.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var fOut)) - { - style.FontSize = fOut; - } - } - else if (i == primaryColourIndex) - { - style.Primary = GetSsaColor(f, Color.White); - } - else if (i == secondaryColourIndex) - { - style.Secondary = GetSsaColor(f, Color.Yellow); - } - else if (i == tertiaryColourIndex) - { - style.Tertiary = GetSsaColor(f, Color.Yellow); - } - else if (i == outlineColourIndex) - { - style.Outline = GetSsaColor(f, Color.Black); - } - else if (i == backColourIndex) - { - style.Background = GetSsaColor(f, Color.Black); - } - else if (i == boldIndex) - { - style.Bold = f == "-1" || f == "1"; - } - else if (i == italicIndex) - { - style.Italic = f == "-1" || f == "1"; - } - else if (i == underlineIndex) - { - style.Underline = f == "-1" || f == "1"; - } - else if (i == outlineIndex) - { - if (decimal.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var number)) - { - style.OutlineWidth = number; - } - } - else if (i == shadowIndex) - { - if (decimal.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var number)) - { - style.ShadowWidth = number; - } - } - else if (i == alignmentIndex) - { - style.Alignment = f; - } - else if (i == marginLIndex) - { - if (int.TryParse(f, out var number)) - { - style.MarginLeft = number; - } - } - else if (i == marginRIndex) - { - if (int.TryParse(f, out var number)) - { - style.MarginRight = number; - } - } - else if (i == marginVIndex) - { - if (int.TryParse(f, out var number)) - { - style.MarginVertical = number; - } - } - else if (i == borderStyleIndex) - { - style.BorderStyle = f; - } - } - } - if (styleName != null && style.Name != null && (styleName.Equals(style.Name, StringComparison.OrdinalIgnoreCase) || - styleName.Equals("*Default", StringComparison.OrdinalIgnoreCase) && - style.Name.Equals("Default", StringComparison.OrdinalIgnoreCase))) - { - style.LoadedFromHeader = true; - return style; - } - } - } - return new SsaStyle { Name = styleName }; - } - - public override bool HasStyleSupport => true; - } +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class AdvancedSubStationAlpha : SubtitleFormat + { + public string Errors { get; private set; } + + public static string DefaultStyle + { + get + { + var borderStyle = "1"; // 1=normal, 3=opaque box + if (Configuration.Settings.SubtitleSettings.SsaOpaqueBox) + { + borderStyle = "3"; + } + + var boldStyle = "0"; // 0=regular + if (Configuration.Settings.SubtitleSettings.SsaFontBold) + { + boldStyle = "-1"; + } + + var ssa = Configuration.Settings.SubtitleSettings; + return "Style: Default," + ssa.SsaFontName + "," + + ssa.SsaFontSize.ToString(CultureInfo.InvariantCulture) + "," + + GetSsaColorString(Color.FromArgb(ssa.SsaFontColorArgb)) + "," + + "&H0300FFFF,&H00000000,&H02000000," + boldStyle + ",0,0,0,100,100,0,0," + borderStyle + "," + ssa.SsaOutline.ToString(CultureInfo.InvariantCulture) + "," + + Configuration.Settings.SubtitleSettings.SsaShadow.ToString(CultureInfo.InvariantCulture) + ",2," + ssa.SsaMarginLeft + "," + ssa.SsaMarginRight + "," + ssa.SsaMarginTopBottom + ",1"; + } + } + + public static string DefaultHeader + { + get + { + var format = new AdvancedSubStationAlpha(); + var sub = new Subtitle(); + string text = format.ToText(sub, string.Empty); + var lines = text.SplitToLines(); + format.LoadSubtitle(sub, lines, string.Empty); + return sub.Header; + } + } + + public override string Extension => ".ass"; + + public const string NameOfFormat = "Advanced Sub Station Alpha"; + + public override string Name => NameOfFormat; + + public override bool IsMine(List lines, string fileName) + { + var subtitle = new Subtitle(); + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + string all = sb.ToString(); + if (!string.IsNullOrEmpty(fileName) && fileName.EndsWith(".ass", StringComparison.OrdinalIgnoreCase) && !all.Contains("[V4 Styles]")) + { + } + else if (!all.Contains("dialog:", StringComparison.OrdinalIgnoreCase) && !all.Contains("dialogue:", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + else if (!all.Contains("[V4+ Styles]") && new SubStationAlpha().IsMine(lines, fileName)) + { + return false; + } + + LoadSubtitle(subtitle, lines, fileName); + Errors = null; + if (subtitle.Paragraphs.Count > _errorCount) + { + if (!string.IsNullOrEmpty(subtitle.Header)) + { + subtitle.Header = subtitle.Header.Replace("[V4 Styles]", "[V4+ Styles]"); + } + + return true; + } + return false; + } + + public const string HeaderNoStyles = @"[Script Info] +; This is an Advanced Sub Station Alpha v4+ script. +Title: {0} +ScriptType: v4.00+ +Collisions: Normal +PlayDepth: 0 + +[V4+ Styles] +Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding +{1} + +[Events] +Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"; + + public override string ToText(Subtitle subtitle, string title) + { + bool fromTtml = false; + string header = @"[Script Info] +; This is an Advanced Sub Station Alpha v4+ script. +Title: {0} +ScriptType: v4.00+ +Collisions: Normal +PlayDepth: 0 + +[V4+ Styles] +Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding +" + DefaultStyle + @" + +[Events] +Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"; + + const string timeCodeFormat = "{0}:{1:00}:{2:00}.{3:00}"; // h:mm:ss.cc + const string paragraphWriteFormat = "Dialogue: {9},{0},{1},{3},{4},{5},{6},{7},{8},{2}"; + const string commentWriteFormat = "Comment: {9},{0},{1},{3},{4},{5},{6},{7},{8},{2}"; + + var sb = new StringBuilder(); + bool isValidAssHeader = !string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.Contains("[V4+ Styles]"); + var styles = new List(); + if (isValidAssHeader) + { + sb.AppendLine(subtitle.Header.Trim()); + sb.AppendLine("Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"); + styles = GetStylesFromHeader(subtitle.Header); + } + else if (!string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.Contains("[V4 Styles]")) + { + LoadStylesFromSubstationAlpha(subtitle, title, header, HeaderNoStyles, sb); + } + else if (subtitle.Header != null && subtitle.Header.Contains("http://www.w3.org/ns/ttml")) + { + LoadStylesFromTimedText10(subtitle, title, header, HeaderNoStyles, sb); + fromTtml = true; + isValidAssHeader = !string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.Contains("[V4+ Styles]"); + if (isValidAssHeader) + { + styles = GetStylesFromHeader(subtitle.Header); + } + } + else if (subtitle.Header != null && subtitle.Header.Contains("http://www.w3.org/2006/10/ttaf1")) + { + LoadStylesFromTimedTextTimedDraft2006Oct(subtitle, title, header, HeaderNoStyles, sb); + fromTtml = true; + isValidAssHeader = !string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.Contains("[V4+ Styles]"); + if (isValidAssHeader) + { + styles = GetStylesFromHeader(subtitle.Header); + } + } + else + { + sb.AppendLine(string.Format(header, title)); + } + foreach (var p in subtitle.Paragraphs) + { + string start = string.Format(timeCodeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10); + string end = string.Format(timeCodeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10); + string style = "Default"; + if (!string.IsNullOrEmpty(p.Extra) && isValidAssHeader && styles.Contains(p.Extra)) + { + style = p.Extra; + } + + if (fromTtml && !string.IsNullOrEmpty(p.Style) && isValidAssHeader && styles.Contains(p.Style)) + { + style = p.Style; + } + + string actor = ""; + if (!string.IsNullOrEmpty(p.Actor)) + { + actor = p.Actor; + } + + string marginL = "0"; + if (!string.IsNullOrEmpty(p.MarginL) && Utilities.IsInteger(p.MarginL)) + { + marginL = p.MarginL; + } + + string marginR = "0"; + if (!string.IsNullOrEmpty(p.MarginR) && Utilities.IsInteger(p.MarginR)) + { + marginR = p.MarginR; + } + + string marginV = "0"; + if (!string.IsNullOrEmpty(p.MarginV) && Utilities.IsInteger(p.MarginV)) + { + marginV = p.MarginV; + } + + string effect = ""; + if (!string.IsNullOrEmpty(p.Effect)) + { + effect = p.Effect; + } + + if (p.IsComment) + { + sb.AppendLine(string.Format(commentWriteFormat, start, end, FormatText(p), style, actor, marginL, marginR, marginV, effect, p.Layer)); + } + else + { + sb.AppendLine(string.Format(paragraphWriteFormat, start, end, FormatText(p), style, actor, marginL, marginR, marginV, effect, p.Layer)); + } + } + + if (!string.IsNullOrEmpty(subtitle.Footer) && + (subtitle.Footer.Contains("[Fonts]" + Environment.NewLine) || subtitle.Footer.Contains("[Graphics]" + Environment.NewLine) || subtitle.Footer.Contains("[Aegisub Extradata]" + Environment.NewLine))) + { + sb.AppendLine(); + sb.AppendLine(subtitle.Footer); + } + return sb.ToString().Trim() + Environment.NewLine; + } + + public static string GetHeaderAndStylesFromSubStationAlpha(string header) + { + var scriptInfo = string.Empty; + if (header != null && + header.Contains("[Script Info]") && + header.Contains("ScriptType: v4.00") && + !header.Contains("ScriptType: v4.00+")) + { + var sb = new StringBuilder(); + var scriptInfoOn = false; + foreach (var line in header.SplitToLines()) + { + if (line.RemoveChar(' ').Contains("Styles]", StringComparison.OrdinalIgnoreCase)) + { + break; + } + + if (line.Equals("[Script Info]", StringComparison.OrdinalIgnoreCase)) + { + scriptInfoOn = true; + } + + if (scriptInfoOn) + { + if (line.StartsWith("ScriptType:", StringComparison.OrdinalIgnoreCase)) + { + sb.AppendLine("ScriptType: v4.00+"); + } + else if (line.Equals("; This is a Sub Station Alpha v4 script.", StringComparison.OrdinalIgnoreCase)) + { + sb.AppendLine("; This is an Advanced Sub Station Alpha v4+ script."); + } + else + { + sb.AppendLine(line); + } + } + } + scriptInfo = sb.ToString(); + } + + var style = GetStyle(header); + + if (string.IsNullOrEmpty(scriptInfo) || string.IsNullOrEmpty(style)) + { + return DefaultHeader; + } + + return string.Format($@"{scriptInfo.Trim() + Environment.NewLine} +[V4+ Styles] +Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding +{style.Trim() + Environment.NewLine} +[Events]"); + } + + private static void LoadStylesFromSubstationAlpha(Subtitle subtitle, string title, string header, string headerNoStyles, StringBuilder sb) + { + try + { + var ttStyles = GetStyle(subtitle.Header); + if (!string.IsNullOrEmpty(ttStyles)) + { + sb.AppendLine(string.Format(headerNoStyles, title, ttStyles)); + subtitle.Header = sb.ToString(); + } + else + { + sb.AppendLine(string.Format(header, title)); + } + } + catch + { + sb.AppendLine(string.Format(header, title)); + } + } + + private static string GetStyle(string header) + { + var ttStyles = new StringBuilder(); + + // Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding + const string styleFormat = "Style: {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},0,100,100,0,0,{10},{11},{12},{13},{14},{15},{16},1"; + foreach (var styleName in GetStylesFromHeader(header)) + { + try + { + var ssaStyle = GetSsaStyle(styleName, header); + + string bold = "0"; + if (ssaStyle.Bold) + { + bold = "-1"; + } + + string italic = "0"; + if (ssaStyle.Italic) + { + italic = "-1"; + } + + string underline = "0"; + if (ssaStyle.Underline) + { + underline = "-1"; + } + + string newAlignment = "2"; + switch (ssaStyle.Alignment) + { + case "1": + newAlignment = "1"; + break; + case "3": + newAlignment = "3"; + break; + case "9": + newAlignment = "4"; + break; + case "10": + newAlignment = "5"; + break; + case "11": + newAlignment = "6"; + break; + case "5": + newAlignment = "7"; + break; + case "6": + newAlignment = "8"; + break; + case "7": + newAlignment = "9"; + break; + } + + ttStyles.AppendLine(string.Format(styleFormat, ssaStyle.Name, ssaStyle.FontName, ssaStyle.FontSize, GetSsaColorString(ssaStyle.Primary), GetSsaColorString(ssaStyle.Secondary), + GetSsaColorString(ssaStyle.Outline), GetSsaColorString(ssaStyle.Background), bold, italic, underline, ssaStyle.BorderStyle, ssaStyle.OutlineWidth.ToString(CultureInfo.InvariantCulture), ssaStyle.ShadowWidth.ToString(CultureInfo.InvariantCulture), + newAlignment, ssaStyle.MarginLeft, ssaStyle.MarginRight, ssaStyle.MarginVertical)); + } + catch + { + // ignored + } + } + + return ttStyles.ToString(); + } + + public static void LoadStylesFromTimedText10(Subtitle subtitle, string title, string header, string headerNoStyles, StringBuilder sb) + { + foreach (Paragraph p in subtitle.Paragraphs) + { + p.Effect = null; + } + + try + { + var lines = subtitle.Header.SplitToLines(); + var tt = new TimedText10(); + var sub = new Subtitle(); + tt.LoadSubtitle(sub, lines, string.Empty); + + var xml = new XmlDocument(); + xml.LoadXml(subtitle.Header); + var nsmgr = new XmlNamespaceManager(xml.NameTable); + nsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml"); + XmlNode head = xml.DocumentElement.SelectSingleNode("ttml:head", nsmgr); + int styleCount = 0; + var ttStyles = new StringBuilder(); + var styleNames = new List(); + foreach (XmlNode node in head.SelectNodes("//ttml:style", nsmgr)) + { + string name = null; + if (node.Attributes["xml:id"] != null) + { + name = node.Attributes["xml:id"].Value; + } + else if (node.Attributes["id"] != null) + { + name = node.Attributes["id"].Value; + } + + if (name != null) + { + styleCount++; + + string fontFamily = "Arial"; + if (node.Attributes["tts:fontFamily"]?.Value != null) + { + fontFamily = node.Attributes["tts:fontFamily"].Value; + if (fontFamily.Contains(",")) + { + fontFamily = fontFamily.Split(',')[0]; + } + } + + string fontWeight = "normal"; + if (node.Attributes["tts:fontWeight"] != null) + { + fontWeight = node.Attributes["tts:fontWeight"].Value; + } + + string fontStyle = "normal"; + if (node.Attributes["tts:fontStyle"] != null) + { + fontStyle = node.Attributes["tts:fontStyle"].Value; + } + + string color = "#ffffff"; + if (node.Attributes["tts:color"] != null) + { + color = node.Attributes["tts:color"].Value.Trim(); + } + + Color c = Color.White; + try + { + if (color.StartsWith("rgb(", StringComparison.Ordinal)) + { + string[] arr = color.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); + } + else + { + c = ColorTranslator.FromHtml(color); + } + } + catch + { + // ignored + } + + string fontSize = "20"; + if (node.Attributes["tts:fontSize"] != null) + { + fontSize = node.Attributes["tts:fontSize"].Value.Replace("px", string.Empty).Replace("em", string.Empty); + } + + if (!float.TryParse(fontSize, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var fSize)) + { + fSize = 20; + } + + string italic = "0"; + if (fontStyle == "italic") + { + italic = "-1"; + } + + string bold = "0"; + if (fontWeight == "bold") + { + bold = "-1"; + } + + const string styleFormat = "Style: {0},{1},{2},{3},&H0300FFFF,&H00000000,&H02000000,{4},{5},0,0,100,100,0,0,1,2,2,2,10,10,10,1"; + ttStyles.AppendLine(string.Format(styleFormat, name, fontFamily, fSize, GetSsaColorString(c), bold, italic)); + styleNames.Add(name); + } + } + + if (styleCount > 0) + { + if (!styleNames.Contains("Default") && !styleNames.Contains("default") && subtitle.Paragraphs.Any(pa => string.IsNullOrEmpty(pa.Extra))) + { + ttStyles = new StringBuilder(DefaultStyle + Environment.NewLine + ttStyles); + foreach (var paragraph in subtitle.Paragraphs) + { + if (string.IsNullOrEmpty(paragraph.Extra)) + { + paragraph.Extra = "Default"; + } + } + } + sb.AppendLine(string.Format(headerNoStyles, title, ttStyles)); + subtitle.Header = sb.ToString(); + } + else + { + sb.AppendLine(string.Format(header, title)); + } + + // Set correct style on paragraphs + foreach (Paragraph p in subtitle.Paragraphs) + { + if (p.Extra != null && p.Extra.Contains('/')) + { + p.Extra = p.Extra.Split('/')[0].Trim(); + } + } + } + catch + { + sb.AppendLine(string.Format(header, title)); + } + } + + public static void LoadStylesFromTimedTextTimedDraft2006Oct(Subtitle subtitle, string title, string header, string headerNoStyles, StringBuilder sb) + { + foreach (Paragraph p in subtitle.Paragraphs) + { + p.Effect = null; + } + + try + { + var lines = subtitle.Header.SplitToLines(); + var sb2 = new StringBuilder(); + lines.ForEach(line => sb2.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + xml.LoadXml(sb2.ToString().Replace(" & ", " & ").Replace("Q&A", "Q&A").RemoveControlCharactersButWhiteSpace().Trim()); + subtitle.Header = xml.OuterXml; + var nsmgr = new XmlNamespaceManager(xml.NameTable); + nsmgr.AddNamespace("ttaf1", xml.DocumentElement.NamespaceURI); + int styleCount = 0; + var ttStyles = new StringBuilder(); + var styleNames = new List(); + foreach (XmlNode node in xml.DocumentElement.SelectNodes("//ttaf1:style", nsmgr)) + { + string name = null; + if (node.Attributes["xml:id"] != null) + { + name = node.Attributes["xml:id"].Value; + } + else if (node.Attributes["id"] != null) + { + name = node.Attributes["id"].Value; + } + + if (name != null) + { + styleCount++; + + string fontFamily = "Arial"; + if (node.Attributes["tts:fontFamily"]?.Value != null) + { + fontFamily = node.Attributes["tts:fontFamily"].Value; + if (fontFamily.Contains(",")) + { + fontFamily = fontFamily.Split(',')[0]; + } + } + + string fontWeight = "normal"; + if (node.Attributes["tts:fontWeight"] != null) + { + fontWeight = node.Attributes["tts:fontWeight"].Value; + } + + string fontStyle = "normal"; + if (node.Attributes["tts:fontStyle"] != null) + { + fontStyle = node.Attributes["tts:fontStyle"].Value; + } + + string color = "#ffffff"; + if (node.Attributes["tts:color"] != null) + { + color = node.Attributes["tts:color"].Value.Trim(); + } + + Color c = Color.White; + try + { + if (color.StartsWith("rgb(", StringComparison.Ordinal)) + { + string[] arr = color.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); + } + else + { + c = ColorTranslator.FromHtml(color); + } + } + catch + { + // ignored + } + + string fontSize = "20"; + if (node.Attributes["tts:fontSize"] != null) + { + fontSize = node.Attributes["tts:fontSize"].Value.Replace("px", string.Empty).Replace("em", string.Empty); + } + + if (!float.TryParse(fontSize, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var fSize)) + { + fSize = 20; + } + + string italic = "0"; + if (fontStyle == "italic") + { + italic = "-1"; + } + + string bold = "0"; + if (fontWeight == "bold") + { + bold = "-1"; + } + + const string styleFormat = "Style: {0},{1},{2},{3},&H0300FFFF,&H00000000,&H02000000,{4},{5},0,0,100,100,0,0,1,2,2,2,10,10,10,1"; + ttStyles.AppendLine(string.Format(styleFormat, name, fontFamily, fSize, GetSsaColorString(c), bold, italic)); + styleNames.Add(name); + } + } + + if (styleCount > 0) + { + if (!styleNames.Contains("Default") && !styleNames.Contains("default") && subtitle.Paragraphs.Any(pa => string.IsNullOrEmpty(pa.Extra))) + { + ttStyles = new StringBuilder(DefaultStyle + Environment.NewLine + ttStyles); + foreach (var paragraph in subtitle.Paragraphs) + { + if (string.IsNullOrEmpty(paragraph.Extra)) + { + paragraph.Extra = "Default"; + } + } + } + sb.AppendLine(string.Format(headerNoStyles, title, ttStyles)); + subtitle.Header = sb.ToString(); + } + else + { + sb.AppendLine(string.Format(header, title)); + } + + // Set correct style on paragraphs + foreach (Paragraph p in subtitle.Paragraphs) + { + if (p.Extra != null && p.Extra.Contains('/')) + { + p.Extra = p.Extra.Split('/')[0].Trim(); + } + } + } + catch + { + sb.AppendLine(string.Format(header, title)); + } + } + + public static List GetStylesFromHeader(string headerLines) + { + var list = new List(); + + if (headerLines == null) + { + headerLines = DefaultStyle; + } + + if (headerLines.Contains("http://www.w3.org/ns/ttml")) + { + var subtitle = new Subtitle { Header = headerLines }; + LoadStylesFromTimedText10(subtitle, string.Empty, headerLines, HeaderNoStyles, new StringBuilder()); + headerLines = subtitle.Header; + } + + foreach (string line in headerLines.SplitToLines()) + { + if (line.StartsWith("style:", StringComparison.OrdinalIgnoreCase)) + { + int end = line.IndexOf(','); + if (end > 0) + { + list.Add(line.Substring(6, end - 6).Trim()); + } + } + } + return list; + } + + public static string FormatText(Paragraph p) + { + string text = p.Text.Replace(Environment.NewLine, "\\N"); + + if (!text.Contains('<')) + { + return text; + } + + text = text.Replace("", @"{\i1}"); + text = text.Replace("", @"{\i0}"); + text = text.Replace("", @"{\i}"); + text = text.Replace("", @"{\u1}"); + text = text.Replace("", @"{\u0}"); + text = text.Replace("", @"{\u}"); + text = text.Replace("", @"{\b1}"); + text = text.Replace("", @"{\b0}"); + text = text.Replace("", @"{\b}"); + int count = 0; + while (text.Contains("', start); + if (end > 0) + { + string fontTag = text.Substring(start + 5, end - (start + 4)); + text = text.Remove(start, end - start + 1); + int indexOfEndFont = text.IndexOf("", start, StringComparison.Ordinal); + if (indexOfEndFont > 0) + { + text = text.Remove(indexOfEndFont, 7); + if (indexOfEndFont < text.Length) + { + if (fontTag.Contains(" size=")) + { + text = text.Insert(indexOfEndFont, "{\\fs}"); + } + if (fontTag.Contains(" face=")) + { + text = text.Insert(indexOfEndFont, "{\\fn}"); + } + if (fontTag.Contains(" color=")) + { + text = text.Insert(indexOfEndFont, "{\\c}"); + } + } + } + + fontTag = FormatTag(ref text, start, fontTag, "face=\"", "fn", "}"); + fontTag = FormatTag(ref text, start, fontTag, "face='", "fn", "}"); + fontTag = FormatTag(ref text, start, fontTag, "face=", "fn", "}"); + + fontTag = FormatTag(ref text, start, fontTag, "size=\"", "fs", "}"); + fontTag = FormatTag(ref text, start, fontTag, "size='", "fs", "}"); + fontTag = FormatTag(ref text, start, fontTag, "size=", "fs", "}"); + + fontTag = FormatTag(ref text, start, fontTag, "color=\"", "c&H", "&}"); + fontTag = FormatTag(ref text, start, fontTag, "color='", "c&H", "&}"); + FormatTag(ref text, start, fontTag, "color=", "c&H", "&}"); + } + count++; + } + text = text.Replace("{\\c}", "@___@@").Replace("}{", string.Empty).Replace("@___@@", "{\\c}").Replace("{\\c}{\\c&", "{\\c&"); + while (text.EndsWith("{\\c}", StringComparison.Ordinal)) + { + text = text.Remove(text.Length - 4); + } + while (text.Contains("\\fs\\fs", StringComparison.Ordinal)) + { + text = text.Replace("\\fs\\fs", "\\fs"); + } + while (text.Contains("\\fn\\fn", StringComparison.Ordinal)) + { + text = text.Replace("\\fn\\fn", "\\fn"); + } + while (text.Contains("\\c\\c&H", StringComparison.Ordinal)) + { + text = text.Replace("\\c\\c&H", "\\c&H"); + } + return text; + } + + private static string FormatTag(ref string text, int start, string fontTag, string tag, string ssaTagName, string endSsaTag) + { + if (fontTag.Contains(tag)) + { + int fontStart = fontTag.IndexOf(tag, StringComparison.Ordinal); + + int fontEnd = fontTag.IndexOfAny(new[] { '"', '\'' }, fontStart + tag.Length); + if (fontEnd < 0) + { + fontEnd = fontTag.IndexOfAny(new[] { ' ', '>' }, fontStart + tag.Length); + } + + if (fontEnd > 0) + { + string subTag = fontTag.Substring(fontStart + tag.Length, fontEnd - (fontStart + tag.Length)); + if (tag.Contains("color")) + { + Color c; + try + { + c = ColorTranslator.FromHtml(subTag); + } + catch + { + c = Color.White; + } + subTag = (c.B.ToString("X2") + c.G.ToString("X2") + c.R.ToString("X2")).ToLowerInvariant(); // use bbggrr + } + fontTag = fontTag.Remove(fontStart, fontEnd - fontStart + 1); + if (start < text.Length) + { + text = text.Insert(start, @"{\" + ssaTagName + subTag + endSsaTag); + } + } + } + return fontTag; + } + + public static string GetFormattedText(string input) + { + var text = input.Replace("\\N", Environment.NewLine).Replace("\\n", Environment.NewLine); + + var tooComplex = ContainsUnsupportedTags(text); + + if (!tooComplex) + { + for (int i = 0; i < 10; i++) // just look ten times... + { + bool italic; + if (text.Contains(@"{\fn")) + { + int start = text.IndexOf(@"{\fn", StringComparison.Ordinal); + int end = text.IndexOf('}', start); + if (end > 0 && !text.Substring(start).StartsWith("{\\fn}", StringComparison.Ordinal)) + { + string fontName = text.Substring(start + 4, end - (start + 4)); + string extraTags = string.Empty; + CheckAndAddSubTags(ref fontName, ref extraTags, out var unknownTags, out italic); + text = text.Remove(start, end - start + 1); + if (italic) + { + text = text.Insert(start, "" + unknownTags + ""); + } + else + { + text = text.Insert(start, "" + unknownTags); + } + + int indexOfEndTag = text.IndexOf("{\\fn}", start, StringComparison.Ordinal); + if (indexOfEndTag > 0) + { + text = text.Remove(indexOfEndTag, "{\\fn}".Length).Insert(indexOfEndTag, ""); + } + else + { + int indexOfNextTag1 = text.IndexOf("{\\fn", start, StringComparison.Ordinal); + int indexOfNextTag2 = text.IndexOf("{\\c}", start, StringComparison.Ordinal); + if (indexOfNextTag1 > 0) + { + text = text.Insert(indexOfNextTag1, ""); + } + else if (indexOfNextTag2 > 0 && text.IndexOf("{\\", start, StringComparison.Ordinal) >= indexOfNextTag2) + { + text = text.Insert(indexOfNextTag2, ""); + } + else + { + text += ""; + } + } + } + } + + if (text.Contains(@"{\fs")) + { + int start = text.IndexOf(@"{\fs", StringComparison.Ordinal); + int end = text.IndexOf('}', start); + if (end > 0 && !text.Substring(start).StartsWith("{\\fs}", StringComparison.Ordinal)) + { + string fontSize = text.Substring(start + 4, end - (start + 4)); + string extraTags = string.Empty; + CheckAndAddSubTags(ref fontSize, ref extraTags, out var unknownTags, out italic); + if (float.TryParse(fontSize, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _)) + { + text = text.Remove(start, end - start + 1); + if (italic) + { + text = text.Insert(start, "" + unknownTags + ""); + } + else + { + text = text.Insert(start, "" + unknownTags); + } + + int indexOfEndTag = text.IndexOf("{\\fs}", start, StringComparison.Ordinal); + if (indexOfEndTag > 0) + { + text = text.Remove(indexOfEndTag, "{\\fs}".Length).Insert(indexOfEndTag, ""); + } + else + { + int indexOfNextTag1 = text.IndexOf("{\\fs", start, StringComparison.Ordinal); + int indexOfNextTag2 = text.IndexOf("{\\c}", start, StringComparison.Ordinal); + if (indexOfNextTag1 > 0) + { + text = text.Insert(indexOfNextTag1, ""); + } + else if (indexOfNextTag2 > 0 && text.IndexOf("{\\", start, StringComparison.Ordinal) >= indexOfNextTag2) + { + text = text.Insert(indexOfNextTag2, ""); + } + else + { + text += ""; + } + } + } + } + } + + if (text.Contains(@"{\c")) + { + int start = text.IndexOf(@"{\c", StringComparison.Ordinal); + int end = text.IndexOf('}', start); + if (end > 0 && !text.Substring(start).StartsWith("{\\c}", StringComparison.Ordinal) && !text.Substring(start).StartsWith("{\\clip", StringComparison.Ordinal)) + { + string color = text.Substring(start + 4, end - (start + 4)); + string extraTags = string.Empty; + CheckAndAddSubTags(ref color, ref extraTags, out var unknownTags, out italic); + + color = color.RemoveChar('&').TrimStart('H'); + color = color.PadLeft(6, '0'); + + // switch to rrggbb from bbggrr + color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2); + color = color.ToLowerInvariant(); + + text = text.Remove(start, end - start + 1); + if (italic) + { + text = text.Insert(start, "" + unknownTags + ""); + } + else + { + text = text.Insert(start, "" + unknownTags); + } + + int indexOfEndTag = text.IndexOf("{\\c}", start, StringComparison.Ordinal); + int indexOfNextColorTag = text.IndexOf("{\\c&", start, StringComparison.Ordinal); + if (indexOfNextColorTag > 0 && (indexOfNextColorTag < indexOfEndTag || indexOfEndTag == -1)) + { + text = text.Insert(indexOfNextColorTag, ""); + } + else if (indexOfEndTag > 0) + { + text = text.Remove(indexOfEndTag, "{\\c}".Length).Insert(indexOfEndTag, ""); + } + else + { + text += ""; + } + } + } + + if (text.Contains(@"{\1c")) // "1" specifices primary color + { + int start = text.IndexOf(@"{\1c", StringComparison.Ordinal); + int end = text.IndexOf('}', start); + if (end > 0 && !text.Substring(start).StartsWith("{\\1c}", StringComparison.Ordinal)) + { + string color = text.Substring(start + 5, end - (start + 5)); + string extraTags = string.Empty; + CheckAndAddSubTags(ref color, ref extraTags, out var unknownTags, out italic); + + color = color.RemoveChar('&').TrimStart('H'); + color = color.PadLeft(6, '0'); + + // switch to rrggbb from bbggrr + color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2); + color = color.ToLowerInvariant(); + + text = text.Remove(start, end - start + 1); + if (italic) + { + text = text.Insert(start, "" + unknownTags + ""); + } + else + { + text = text.Insert(start, "" + unknownTags); + } + + text += ""; + } + } + } + } + + text = text.Replace(@"{\i1}", ""); + text = text.Replace(@"{\i0}", ""); + text = text.Replace(@"{\i}", ""); + if (Utilities.CountTagInText(text, "") > Utilities.CountTagInText(text, "")) + { + text += ""; + } + + text = text.Replace(@"{\u1}", ""); + text = text.Replace(@"{\u0}", ""); + text = text.Replace(@"{\u}", ""); + if (Utilities.CountTagInText(text, "") > Utilities.CountTagInText(text, "")) + { + text += ""; + } + + text = text.Replace(@"{\b1}", ""); + text = text.Replace(@"{\b0}", ""); + text = text.Replace(@"{\b}", ""); + if (Utilities.CountTagInText(text, "") > Utilities.CountTagInText(text, "")) + { + text += ""; + } + + return text; + } + + private static bool ContainsUnsupportedTags(string text) + { + if (string.IsNullOrEmpty(text) || !text.Contains("{\\", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + var unsupportedTags = new List + { + "\\alpha", + "\\be0", + "\\be1", + "\\bord", + "\\blur", + "\\clip", + "\\fad", + "\\fa", + "\\fade", + "\\fscx", + "\\fscy", + "\\fr", + "\\iclip", + "\\k", + "\\K", + "\\kf", + "\\ko", + "\\move", + "\\org", + "\\p", + "\\pos", + "\\s0", + "\\s1", + "\\t(", + "\\xbord", + "\\ybord", + "\\xshad", + "\\yshad" + }; + + foreach (var unsupportedTag in unsupportedTags) + { + if (text.Contains(unsupportedTag, StringComparison.Ordinal)) + { + return true; + } + } + + return false; + } + + private static void CheckAndAddSubTags(ref string tagName, ref string extraTags, out string unknownTags, out bool italic) + { + italic = false; + unknownTags = string.Empty; + int indexOfSPlit = tagName.IndexOf('\\'); + if (indexOfSPlit > 0) + { + string rest = tagName.Substring(indexOfSPlit).TrimStart('\\'); + tagName = tagName.Remove(indexOfSPlit); + + for (int i = 0; i < 10; i++) + { + if (rest.StartsWith("fs", StringComparison.Ordinal) && rest.Length > 2) + { + indexOfSPlit = rest.IndexOf('\\'); + string fontSize = rest; + if (indexOfSPlit > 0) + { + fontSize = rest.Substring(0, indexOfSPlit); + rest = rest.Substring(indexOfSPlit).TrimStart('\\'); + } + else + { + rest = string.Empty; + } + extraTags += " size=\"" + fontSize.Substring(2) + "\""; + } + else if (rest.StartsWith("fn", StringComparison.Ordinal) && rest.Length > 2) + { + indexOfSPlit = rest.IndexOf('\\'); + string fontName = rest; + if (indexOfSPlit > 0) + { + fontName = rest.Substring(0, indexOfSPlit); + rest = rest.Substring(indexOfSPlit).TrimStart('\\'); + } + else + { + rest = string.Empty; + } + extraTags += " face=\"" + fontName.Substring(2) + "\""; + } + else if (rest.StartsWith('c') && rest.Length > 2) + { + indexOfSPlit = rest.IndexOf('\\'); + string fontColor = rest; + if (indexOfSPlit > 0) + { + fontColor = rest.Substring(0, indexOfSPlit); + rest = rest.Substring(indexOfSPlit).TrimStart('\\'); + } + else + { + rest = string.Empty; + } + + string color = fontColor.Substring(2); + color = color.RemoveChar('&').TrimStart('H'); + color = color.PadLeft(6, '0'); + // switch to rrggbb from bbggrr + color = "#" + color.Remove(color.Length - 6) + color.Substring(color.Length - 2, 2) + color.Substring(color.Length - 4, 2) + color.Substring(color.Length - 6, 2); + color = color.ToLowerInvariant(); + + extraTags += " color=\"" + color + "\""; + } + else if (rest.StartsWith("i1", StringComparison.Ordinal) && rest.Length > 1) + { + indexOfSPlit = rest.IndexOf('\\'); + italic = true; + if (indexOfSPlit > 0) + { + rest = rest.Substring(indexOfSPlit).TrimStart('\\'); + } + else + { + rest = string.Empty; + } + } + else if (rest.Length > 0 && rest.Contains("\\")) + { + indexOfSPlit = rest.IndexOf('\\'); + var unknowntag = rest.Substring(0, indexOfSPlit); + unknownTags += "\\" + unknowntag; + rest = rest.Substring(indexOfSPlit).TrimStart('\\'); + } + else if (!string.IsNullOrEmpty(rest)) + { + unknownTags += "\\" + rest; + rest = string.Empty; + } + } + } + if (!string.IsNullOrEmpty(unknownTags)) + { + unknownTags = "{" + unknownTags + "}"; + } + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + Errors = null; + bool eventsStarted = false; + bool fontsStarted = false; + bool graphicsStarted = false; + subtitle.Paragraphs.Clear(); + + // Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text + int indexLayer = 0; + int indexStart = 1; + int indexEnd = 2; + int indexStyle = 3; + int indexActor = -1; // convert "Actor" to "Nam" (if no "Name") + int indexName = 4; + int indexMarginL = 5; + int indexMarginR = 6; + int indexMarginV = 7; + int indexEffect = 8; + int indexText = 9; + var errors = new StringBuilder(); + int lineNumber = 0; + + var header = new StringBuilder(); + var footer = new StringBuilder(); + foreach (string line in lines) + { + lineNumber++; + if (!eventsStarted && !fontsStarted && !graphicsStarted && + !line.Trim().Equals("[fonts]", StringComparison.InvariantCultureIgnoreCase) && + !line.Trim().Equals("[graphics]", StringComparison.InvariantCultureIgnoreCase)) + { + header.AppendLine(line); + } + + if (string.IsNullOrWhiteSpace(line) || line.TrimStart().StartsWith(';')) + { + // skip empty and comment lines + } + else if (line.TrimStart().StartsWith("dialog:", StringComparison.OrdinalIgnoreCase) || line.TrimStart().StartsWith("dialogue:", StringComparison.OrdinalIgnoreCase)) // fix faulty font tags... + { + eventsStarted = true; + fontsStarted = false; + graphicsStarted = false; + } + + if (line.Trim().Equals("[events]", StringComparison.OrdinalIgnoreCase)) + { + if (header.ToString().IndexOf(Environment.NewLine + "[events]", StringComparison.OrdinalIgnoreCase) < 0) + { + var h = header.ToString().TrimEnd(); + header.Clear(); + header.AppendLine(h); + header.AppendLine(); + header.AppendLine("[Events]"); + } + eventsStarted = true; + fontsStarted = false; + graphicsStarted = false; + } + else if (line.Trim().Equals("[fonts]", StringComparison.OrdinalIgnoreCase)) + { + eventsStarted = false; + fontsStarted = true; + graphicsStarted = false; + footer.AppendLine(); + footer.AppendLine("[Fonts]"); + } + else if (line.Trim().Equals("[graphics]", StringComparison.OrdinalIgnoreCase)) + { + eventsStarted = false; + fontsStarted = false; + graphicsStarted = true; + footer.AppendLine(); + footer.AppendLine("[Graphics]"); + } + else if (line.Trim().Equals("[Aegisub Extradata]", StringComparison.OrdinalIgnoreCase)) + { + eventsStarted = false; + fontsStarted = false; + graphicsStarted = true; + footer.AppendLine(); + footer.AppendLine("[Aegisub Extradata]"); + } + else if (fontsStarted) + { + footer.AppendLine(line); + } + else if (graphicsStarted) + { + footer.AppendLine(line); + } + else if (eventsStarted) + { + string s = line.Trim().ToLowerInvariant(); + if (line.Length > 10 && s.StartsWith("format:", StringComparison.Ordinal)) + { + indexLayer = -1; + indexStart = -1; + indexEnd = -1; + indexStyle = -1; + indexActor = -1; + indexName = -1; + indexMarginL = -1; + indexMarginR = -1; + indexMarginV = -1; + indexEffect = -1; + indexText = -1; + + var format = s.Substring(8).Split(','); + for (int i = 0; i < format.Length; i++) + { + var formatTrimmed = format[i].Trim(); + if (formatTrimmed.Equals("start", StringComparison.Ordinal)) + { + indexStart = i; + } + else if (formatTrimmed.Equals("end", StringComparison.Ordinal)) + { + indexEnd = i; + } + else if (formatTrimmed.Equals("text", StringComparison.Ordinal)) + { + indexText = i; + } + else if (formatTrimmed.Equals("style", StringComparison.Ordinal)) + { + indexStyle = i; + } + else if (formatTrimmed.Equals("actor", StringComparison.Ordinal)) + { + indexActor = i; + } + else if (formatTrimmed.Equals("name", StringComparison.Ordinal)) + { + indexName = i; + } + else if (formatTrimmed.Equals("marginl", StringComparison.Ordinal)) + { + indexMarginL = i; + } + else if (formatTrimmed.Equals("marginr", StringComparison.Ordinal)) + { + indexMarginR = i; + } + else if (formatTrimmed.Equals("marginv", StringComparison.Ordinal)) + { + indexMarginV = i; + } + else if (formatTrimmed.Equals("effect", StringComparison.Ordinal)) + { + indexEffect = i; + } + else if (formatTrimmed.Equals("layer", StringComparison.Ordinal)) + { + indexLayer = i; + } + } + } + else if (!string.IsNullOrEmpty(s)) + { + var text = string.Empty; + var start = string.Empty; + var end = string.Empty; + var style = string.Empty; + var actor = string.Empty; + var marginL = string.Empty; + var marginR = string.Empty; + var marginV = string.Empty; + var effect = string.Empty; + var layer = 0; + + string[] splittedLine; + if (s.StartsWith("dialog:", StringComparison.Ordinal)) + { + splittedLine = line.Remove(0, 7).Split(','); + } + else if (s.StartsWith("dialogue:", StringComparison.Ordinal)) + { + splittedLine = line.Remove(0, 9).Split(','); + } + else + { + splittedLine = line.Split(','); + } + + for (int i = 0; i < splittedLine.Length; i++) + { + if (i == indexStart) + { + start = splittedLine[i].Trim(); + } + else if (i == indexEnd) + { + end = splittedLine[i].Trim(); + } + else if (i == indexStyle) + { + style = splittedLine[i].Trim(); + } + else if (i == indexActor && indexName == -1) + { + actor = splittedLine[i].Trim(); + } + else if (i == indexName) + { + actor = splittedLine[i].Trim(); + } + else if (i == indexMarginL) + { + marginL = splittedLine[i].Trim(); + } + else if (i == indexMarginR) + { + marginR = splittedLine[i].Trim(); + } + else if (i == indexMarginV) + { + marginV = splittedLine[i].Trim(); + } + else if (i == indexEffect) + { + effect = splittedLine[i].Trim(); + } + else if (i == indexLayer) + { + int.TryParse(splittedLine[i].Replace("Comment:", string.Empty).Trim(), out layer); + } + else if (i == indexText) + { + text = splittedLine[i]; + } + else if (i > indexText) + { + text += "," + splittedLine[i]; + } + } + + try + { + var p = new Paragraph + { + StartTime = GetTimeCodeFromString(start), + EndTime = GetTimeCodeFromString(end), + Text = GetFormattedText(text) + }; + + if (!string.IsNullOrEmpty(style)) + { + p.Extra = style; + } + + if (!string.IsNullOrEmpty(actor)) + { + p.Actor = actor; + } + + if (!string.IsNullOrEmpty(marginL)) + { + p.MarginL = marginL; + } + + if (!string.IsNullOrEmpty(marginR)) + { + p.MarginR = marginR; + } + + if (!string.IsNullOrEmpty(marginV)) + { + p.MarginV = marginV; + } + + if (!string.IsNullOrEmpty(effect)) + { + p.Effect = effect; + } + + p.Layer = layer; + p.IsComment = s.StartsWith("comment:", StringComparison.Ordinal); + subtitle.Paragraphs.Add(p); + } + catch + { + _errorCount++; + if (errors.Length < 2000) + { + errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXErrorReadingTimeCodeFromSourceLineY, lineNumber, line)); + } + else if (subtitle.Paragraphs.Count == 0) + { + break; + } + } + } + } + } + if (header.Length > 0) + { + subtitle.Header = header.ToString(); + } + + if (footer.Length > 0) + { + subtitle.Footer = footer.ToString().Trim(); + } + + subtitle.Renumber(); + Errors = errors.ToString(); + } + + private static TimeCode GetTimeCodeFromString(string time) + { + // h:mm:ss.cc + string[] timeCode = time.Split(':', '.'); + return new TimeCode(int.Parse(timeCode[0]), + int.Parse(timeCode[1]), + int.Parse(timeCode[2]), + int.Parse(timeCode[3]) * 10); + } + + public override void RemoveNativeFormatting(Subtitle subtitle, SubtitleFormat newFormat) + { + if (newFormat != null && newFormat.Name == SubStationAlpha.NameOfFormat) + { + foreach (var p in subtitle.Paragraphs) + { + string s = p.Text; + + if (s.Contains('{') && s.Contains('}')) + { + var p1Index = s.IndexOf("\\p1", StringComparison.Ordinal); + var p0Index = s.IndexOf("{\\p0}", StringComparison.Ordinal); + if (p1Index > 0 && (p0Index > p1Index || p0Index == -1)) + { + var startTagIndex = s.Substring(0, p1Index).LastIndexOf('{'); + if (startTagIndex >= 0) + { + if (p0Index > p1Index) + { + s = s.Remove(startTagIndex, p0Index - startTagIndex + "{\\p0}".Length); + } + else + { + s = s.Remove(startTagIndex); + } + } + } + + var karaokeStart = s.IndexOf("{Kara Effector", StringComparison.Ordinal); + if (karaokeStart >= 0) + { + int l = s.IndexOf('}', karaokeStart + 1); + if (l < karaokeStart) + { + break; + } + + s = s.Remove(karaokeStart, l - karaokeStart + 1); + } + + s = s.Replace(@"\u0", string.Empty); + s = s.Replace(@"\u1", string.Empty); + s = s.Replace(@"\s0", string.Empty); + s = s.Replace(@"\s1", string.Empty); + s = s.Replace(@"\be0", string.Empty); + s = s.Replace(@"\be1", string.Empty); + + s = RemoveTag(s, "shad"); + s = RemoveTag(s, "fsc"); + s = RemoveTag(s, "fsp"); + s = RemoveTag(s, "fr"); + + s = RemoveTag(s, "t("); + s = RemoveTag(s, "move("); + s = RemoveTag(s, "Position("); + s = RemoveTag(s, "org("); + s = RemoveTag(s, "fade("); + s = RemoveTag(s, "fad("); + s = RemoveTag(s, "clip("); + s = RemoveTag(s, "iclip("); + s = RemoveTag(s, "pbo("); + s = RemoveTag(s, "bord"); + s = RemoveTag(s, "pos"); + + // TODO: Alignment tags + + s = s.Replace("{}", string.Empty); + + p.Text = s; + } + } + } + else + { + foreach (var p in subtitle.Paragraphs) + { + var noTags = Utilities.RemoveSsaTags(p.Text).Trim(); + if (noTags.Length == 0) + { + p.Text = string.Empty; + continue; + } + + p.Text = p.Text.Replace("\\n", Environment.NewLine); // Soft line break + p.Text = p.Text.Replace("\\N", Environment.NewLine); // Hard line break + p.Text = p.Text.Replace("\\h", " "); // Hard space + + if (noTags.StartsWith("m ", StringComparison.Ordinal)) + { + var test = noTags.Remove(0, 2) + .RemoveChar('0') + .RemoveChar('1') + .RemoveChar('2') + .RemoveChar('3') + .RemoveChar('4') + .RemoveChar('5') + .RemoveChar('6') + .RemoveChar('7') + .RemoveChar('8') + .RemoveChar('9') + .RemoveChar('-') + .RemoveChar('l') + .RemoveChar('m') + .RemoveChar(' ') + .RemoveChar('.'); + if (test.Length == 0) + { + p.Text = string.Empty; + continue; + } + } + + int indexOfBegin = p.Text.IndexOf('{'); + string pre = string.Empty; + while (indexOfBegin >= 0 && p.Text.IndexOf('}') > indexOfBegin) + { + string s = p.Text.Substring(indexOfBegin); + if (s.StartsWith("{\\an1}", StringComparison.Ordinal) || + s.StartsWith("{\\an2}", StringComparison.Ordinal) || + s.StartsWith("{\\an3}", StringComparison.Ordinal) || + s.StartsWith("{\\an4}", StringComparison.Ordinal) || + s.StartsWith("{\\an5}", StringComparison.Ordinal) || + s.StartsWith("{\\an6}", StringComparison.Ordinal) || + s.StartsWith("{\\an7}", StringComparison.Ordinal) || + s.StartsWith("{\\an8}", StringComparison.Ordinal) || + s.StartsWith("{\\an9}", StringComparison.Ordinal)) + { + pre = s.Substring(0, 6); + } + else if (s.StartsWith("{\\an1\\", StringComparison.Ordinal) || + s.StartsWith("{\\an2\\", StringComparison.Ordinal) || + s.StartsWith("{\\an3\\", StringComparison.Ordinal) || + s.StartsWith("{\\an4\\", StringComparison.Ordinal) || + s.StartsWith("{\\an5\\", StringComparison.Ordinal) || + s.StartsWith("{\\an6\\", StringComparison.Ordinal) || + s.StartsWith("{\\an7\\", StringComparison.Ordinal) || + s.StartsWith("{\\an8\\", StringComparison.Ordinal) || + s.StartsWith("{\\an9\\", StringComparison.Ordinal)) + { + pre = s.Substring(0, 5) + "}"; + } + int indexOfEnd = p.Text.IndexOf('}'); + p.Text = p.Text.Remove(indexOfBegin, indexOfEnd - indexOfBegin + 1); + + indexOfBegin = p.Text.IndexOf('{'); + } + p.Text = pre + p.Text; + } + } + } + + private static string RemoveTag(string s, string tag) + { + int indexOfTag = s.IndexOf(@"\" + tag, StringComparison.Ordinal); + if (indexOfTag > 0) + { + var endIndex1 = s.IndexOf('\\', indexOfTag + 1); + var endIndex2 = s.IndexOf('}', indexOfTag + 1); + endIndex1 = Math.Min(endIndex1, endIndex2); + if (endIndex1 > 0) + { + return s.Remove(indexOfTag, endIndex1 - indexOfTag); + } + } + return s; + } + + /// + /// BGR color like this: &HBBGGRR& (where BB, GG, and RR are hex values in uppercase) + /// + /// Input string + /// Default color + /// Input string as color, or default color if problems + public static Color GetSsaColor(string f, Color defaultColor) + { + //Red = &H0000FF& + //Green = &H00FF00& + //Blue = &HFF0000& + //White = &HFFFFFF& + //Black = &H000000& + string s = f.Trim().Trim('&'); + + if (s.StartsWith('h') && s.Length < 7) + { + while (s.Length < 7) + { + s = s.Insert(1, "0"); + } + } + + if (s.StartsWith('h') && s.Length == 7) + { + s = s.Substring(1); + string hexColor = "#" + s.Substring(4, 2) + s.Substring(2, 2) + s.Substring(0, 2); + try + { + return ColorTranslator.FromHtml(hexColor); + } + catch + { + return defaultColor; + } + } + if (s.StartsWith('h') && s.Length == 9) + { + if (int.TryParse(s.Substring(1, 2), NumberStyles.HexNumber, null, out var alpha)) + { + alpha = 255 - alpha; // ASS stores alpha in reverse (0=full itentity and 255=fully transparent) + } + else + { + alpha = 255; // full color + } + s = s.Substring(3); + string hexColor = "#" + s.Substring(4, 2) + s.Substring(2, 2) + s.Substring(0, 2); + try + { + var c = ColorTranslator.FromHtml(hexColor); + return Color.FromArgb(alpha, c); + } + catch + { + return defaultColor; + } + } + + if (int.TryParse(f, out var number)) + { + var temp = Color.FromArgb(number); + return Color.FromArgb(255, temp.B, temp.G, temp.R); + } + return defaultColor; + } + + public static string GetSsaColorString(Color c) + { + return $"&H{255 - c.A:X2}{c.B:X2}{c.G:X2}{c.R:X2}"; // ASS stores alpha in reverse (0=full itentity and 255=fully transparent) + } + + public static string CheckForErrors(string header) + { + if (string.IsNullOrEmpty(header)) + { + return string.Empty; + } + + var sb = new StringBuilder(); + + int styleCount = -1; + + int nameIndex = -1; + int fontNameIndex = -1; + int fontsizeIndex = -1; + int primaryColourIndex = -1; + int secondaryColourIndex = -1; + int outlineColourIndex = -1; + int backColourIndex = -1; + int boldIndex = -1; + int italicIndex = -1; + int underlineIndex = -1; + int outlineIndex = -1; + int shadowIndex = -1; + int alignmentIndex = -1; + int marginLIndex = -1; + int marginRIndex = -1; + int marginVIndex = -1; + int borderStyleIndex = -1; + + foreach (string line in header.SplitToLines()) + { + string s = line.Trim().ToLowerInvariant(); + if (s.StartsWith("format:", StringComparison.Ordinal)) + { + if (line.Length > 10) + { + var format = line.Substring(8).ToLowerInvariant().Split(','); + styleCount = format.Length; + for (int i = 0; i < format.Length; i++) + { + string f = format[i].Trim(); + if (f == "name") + { + nameIndex = i; + } + else if (f == "fontname") + { + fontNameIndex = i; + } + else if (f == "fontsize") + { + fontsizeIndex = i; + } + else if (f == "primarycolour") + { + primaryColourIndex = i; + } + else if (f == "secondarycolour") + { + secondaryColourIndex = i; + } + else if (f == "outlinecolour") + { + outlineColourIndex = i; + } + else if (f == "backcolour") + { + backColourIndex = i; + } + else if (f == "bold") + { + boldIndex = i; + } + else if (f == "italic") + { + italicIndex = i; + } + else if (f == "underline") + { + underlineIndex = i; + } + else if (f == "outline") + { + outlineIndex = i; + } + else if (f == "shadow") + { + shadowIndex = i; + } + else if (f == "alignment") + { + alignmentIndex = i; + } + else if (f == "marginl") + { + marginLIndex = i; + } + else if (f == "marginr") + { + marginRIndex = i; + } + else if (f == "marginv") + { + marginVIndex = i; + } + else if (f == "borderstyle") + { + borderStyleIndex = i; + } + } + } + } + else if (s.RemoveChar(' ').StartsWith("style:", StringComparison.Ordinal)) + { + if (line.Length > 10) + { + string rawLine = line; + var format = line.Substring(6).Split(','); + + if (format.Length != styleCount) + { + sb.AppendLine("Number of expected Style elements do not match number of Format elements: " + rawLine); + sb.AppendLine(); + } + else + { + var dummyColor = Color.FromArgb(9, 14, 16, 26); + for (int i = 0; i < format.Length; i++) + { + string f = format[i].Trim().ToLowerInvariant(); + if (i == nameIndex) + { + if (f.Length == 0) + { + sb.AppendLine("'Name' is empty: " + rawLine); + sb.AppendLine(); + } + } + else if (i == fontNameIndex) + { + if (f.Length == 0) + { + sb.AppendLine("'Fontname' is empty: " + rawLine); + sb.AppendLine(); + } + } + else if (i == fontsizeIndex) + { + if (!float.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _) || f.StartsWith('-')) + { + sb.AppendLine("'Fontsize' incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == primaryColourIndex) + { + if (GetSsaColor(f, dummyColor) == dummyColor || f == "&h") + { + sb.AppendLine("'PrimaryColour' incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == secondaryColourIndex) + { + if (GetSsaColor(f, dummyColor) == dummyColor) + { + sb.AppendLine("'SecondaryColour' incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == outlineColourIndex) + { + if (GetSsaColor(f, dummyColor) == dummyColor) + { + sb.AppendLine("'OutlineColour' incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == backColourIndex) + { + if (GetSsaColor(f, dummyColor) == dummyColor) + { + sb.AppendLine("'BackColour' incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == boldIndex) + { + if (Utilities.AllLetters.Contains(f)) + { + sb.AppendLine("'Bold' incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == italicIndex) + { + if (Utilities.AllLetters.Contains(f)) + { + sb.AppendLine("'Italic' incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == underlineIndex) + { + if (Utilities.AllLetters.Contains(f)) + { + sb.AppendLine("'Underline' incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == outlineIndex) + { + if (!float.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _) || f.StartsWith('-')) + { + sb.AppendLine("'Outline' (width) incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == shadowIndex) + { + if (!float.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out _) || f.StartsWith('-')) + { + sb.AppendLine("'Shadow' (width) incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == alignmentIndex) + { + if (!"101123456789 ".Contains(f)) + { + sb.AppendLine("'Alignment' incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == marginLIndex) + { + if (!int.TryParse(f, out _) || f.StartsWith('-')) + { + sb.AppendLine("'MarginL' incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == marginRIndex) + { + if (!int.TryParse(f, out _) || f.StartsWith('-')) + { + sb.AppendLine("'MarginR' incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == marginVIndex) + { + if (!int.TryParse(f, out _) || f.StartsWith('-')) + { + sb.AppendLine("'MarginV' incorrect: " + rawLine); + sb.AppendLine(); + } + } + else if (i == borderStyleIndex) + { + if (f.Length != 0 && !"123".Contains(f)) + { + sb.AppendLine("'BorderStyle' incorrect: " + rawLine); + sb.AppendLine(); + } + } + } + } + } + } + } + return sb.ToString(); + } + + /// + /// Add new style to ASS header + /// + /// Header with new style + public static string AddSsaStyle(SsaStyle style, string inputHeader) + { + var header = inputHeader; + if (string.IsNullOrEmpty(header)) + { + header = DefaultHeader; + } + + var sb = new StringBuilder(); + bool stylesStarted = false; + bool styleAdded = false; + string styleFormat = "Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding"; + foreach (string line in header.SplitToLines()) + { + if (line.Equals("[V4+ Styles]", StringComparison.OrdinalIgnoreCase) || line.Equals("[V4 Styles]", StringComparison.OrdinalIgnoreCase)) + { + stylesStarted = true; + } + + if (line.StartsWith("format:", StringComparison.OrdinalIgnoreCase)) + { + styleFormat = line; + } + + if (!line.StartsWith("Style: " + style.Name + ",", StringComparison.Ordinal)) // overwrite existing style + { + sb.AppendLine(line); + } + + if (!styleAdded && stylesStarted && line.TrimStart().StartsWith("style:", StringComparison.OrdinalIgnoreCase)) + { + sb.AppendLine(style.ToRawAss(styleFormat)); + styleAdded = true; + } + } + return sb.ToString(); + } + + public static SsaStyle GetSsaStyle(string styleName, string header) + { + var style = new SsaStyle { Name = styleName }; + + int nameIndex = -1; + int fontNameIndex = -1; + int fontsizeIndex = -1; + int primaryColourIndex = -1; + int secondaryColourIndex = -1; + int tertiaryColourIndex = -1; + int outlineColourIndex = -1; + int backColourIndex = -1; + int boldIndex = -1; + int italicIndex = -1; + int underlineIndex = -1; + int outlineIndex = -1; + int shadowIndex = -1; + int alignmentIndex = -1; + int marginLIndex = -1; + int marginRIndex = -1; + int marginVIndex = -1; + int borderStyleIndex = -1; + + if (header == null) + { + header = DefaultHeader; + } + + foreach (string line in header.SplitToLines()) + { + string s = line.Trim().ToLowerInvariant(); + if (s.StartsWith("format:", StringComparison.Ordinal)) + { + if (line.Length > 10) + { + var format = line.ToLowerInvariant().Substring(8).Split(','); + for (int i = 0; i < format.Length; i++) + { + string f = format[i].Trim().ToLowerInvariant(); + if (f == "name") + { + nameIndex = i; + } + else if (f == "fontname") + { + fontNameIndex = i; + } + else if (f == "fontsize") + { + fontsizeIndex = i; + } + else if (f == "primarycolour") + { + primaryColourIndex = i; + } + else if (f == "secondarycolour") + { + secondaryColourIndex = i; + } + else if (f == "tertiarycolour") + { + tertiaryColourIndex = i; + } + else if (f == "outlinecolour") + { + outlineColourIndex = i; + } + else if (f == "backcolour") + { + backColourIndex = i; + } + else if (f == "bold") + { + boldIndex = i; + } + else if (f == "italic") + { + italicIndex = i; + } + else if (f == "underline") + { + underlineIndex = i; + } + else if (f == "outline") + { + outlineIndex = i; + } + else if (f == "shadow") + { + shadowIndex = i; + } + else if (f == "alignment") + { + alignmentIndex = i; + } + else if (f == "marginl") + { + marginLIndex = i; + } + else if (f == "marginr") + { + marginRIndex = i; + } + else if (f == "marginv") + { + marginVIndex = i; + } + else if (f == "borderstyle") + { + borderStyleIndex = i; + } + } + } + } + else if (s.RemoveChar(' ').StartsWith("style:", StringComparison.Ordinal)) + { + if (line.Length > 10) + { + style.RawLine = line; + var format = line.Substring(6).Split(','); + for (int i = 0; i < format.Length; i++) + { + string f = format[i].Trim().ToLowerInvariant(); + if (i == nameIndex) + { + style.Name = format[i].Trim(); + } + else if (i == fontNameIndex) + { + style.FontName = f; + } + else if (i == fontsizeIndex) + { + if (float.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var fOut)) + { + style.FontSize = fOut; + } + } + else if (i == primaryColourIndex) + { + style.Primary = GetSsaColor(f, Color.White); + } + else if (i == secondaryColourIndex) + { + style.Secondary = GetSsaColor(f, Color.Yellow); + } + else if (i == tertiaryColourIndex) + { + style.Tertiary = GetSsaColor(f, Color.Yellow); + } + else if (i == outlineColourIndex) + { + style.Outline = GetSsaColor(f, Color.Black); + } + else if (i == backColourIndex) + { + style.Background = GetSsaColor(f, Color.Black); + } + else if (i == boldIndex) + { + style.Bold = f == "-1" || f == "1"; + } + else if (i == italicIndex) + { + style.Italic = f == "-1" || f == "1"; + } + else if (i == underlineIndex) + { + style.Underline = f == "-1" || f == "1"; + } + else if (i == outlineIndex) + { + if (decimal.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var number)) + { + style.OutlineWidth = number; + } + } + else if (i == shadowIndex) + { + if (decimal.TryParse(f, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var number)) + { + style.ShadowWidth = number; + } + } + else if (i == alignmentIndex) + { + style.Alignment = f; + } + else if (i == marginLIndex) + { + if (int.TryParse(f, out var number)) + { + style.MarginLeft = number; + } + } + else if (i == marginRIndex) + { + if (int.TryParse(f, out var number)) + { + style.MarginRight = number; + } + } + else if (i == marginVIndex) + { + if (int.TryParse(f, out var number)) + { + style.MarginVertical = number; + } + } + else if (i == borderStyleIndex) + { + style.BorderStyle = f; + } + } + } + if (styleName != null && style.Name != null && (styleName.Equals(style.Name, StringComparison.OrdinalIgnoreCase) || + styleName.Equals("*Default", StringComparison.OrdinalIgnoreCase) && + style.Name.Equals("Default", StringComparison.OrdinalIgnoreCase))) + { + style.LoadedFromHeader = true; + return style; + } + } + } + return new SsaStyle { Name = styleName }; + } + + public override bool HasStyleSupport => true; + } } \ No newline at end of file diff --git a/libse/SubtitleFormats/AribB24Decoder.cs b/src/libse/SubtitleFormats/AribB24Decoder.cs similarity index 100% rename from libse/SubtitleFormats/AribB24Decoder.cs rename to src/libse/SubtitleFormats/AribB24Decoder.cs diff --git a/libse/SubtitleFormats/AribB36.cs b/src/libse/SubtitleFormats/AribB36.cs similarity index 100% rename from libse/SubtitleFormats/AribB36.cs rename to src/libse/SubtitleFormats/AribB36.cs diff --git a/libse/SubtitleFormats/AvidCaption.cs b/src/libse/SubtitleFormats/AvidCaption.cs similarity index 97% rename from libse/SubtitleFormats/AvidCaption.cs rename to src/libse/SubtitleFormats/AvidCaption.cs index 24478613d..877f74463 100644 --- a/libse/SubtitleFormats/AvidCaption.cs +++ b/src/libse/SubtitleFormats/AvidCaption.cs @@ -1,127 +1,127 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class AvidCaption : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d \d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "Avid Caption"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - sb.AppendLine("@ This file written with the Avid Caption plugin, version 1"); - sb.AppendLine(); - sb.AppendLine(""); - const string writeFormat = "{0} {1}{2}{3}{2}"; - foreach (Paragraph p in subtitle.Paragraphs) - { - sb.AppendLine(string.Format(writeFormat, p.StartTime.ToHHMMSSFF(), EncodeEndTimeCode(p.EndTime), Environment.NewLine, HtmlUtil.RemoveHtmlTags(p.Text, true))); - //00:50:34:22 00:50:39:13 - //Ich muss dafür sorgen, - //dass die Epsteins weiterleben - } - sb.AppendLine(""); - return sb.ToString(); - } - - private static string EncodeEndTimeCode(TimeCode time) - { - //00:50:39:13 (last is frame) - - //Bugfix for Avid - On 23.976 FPS and 24 FPS projects, when the End time of a subtitle ends in 02, 07, 12, 17, 22, 27 frames, the subtitle won't import. - if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 23.976) < 0.01 || - Math.Abs(Configuration.Settings.General.CurrentFrameRate - 24) < 0.01) - { - var frames = MillisecondsToFramesMaxFrameRate(time.Milliseconds); - if (frames == 2 || frames == 7 || frames == 12 || frames == 17 || frames == 22 || frames == 27) - { - frames--; - } - - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{frames:00}"; - } - else - { - return time.ToHHMMSSFF(); - } - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - //00:03:15:22 00:03:23:10 This is line one. - //This is line two. - Paragraph p = null; - subtitle.Paragraphs.Clear(); - _errorCount = 0; - bool beginFound = false; - bool endFound = false; - foreach (string line in lines) - { - string tline = line.Trim(); - if (tline.Equals("", StringComparison.OrdinalIgnoreCase)) - { - beginFound = true; - } - else if (tline.Equals("", StringComparison.OrdinalIgnoreCase)) - { - endFound = true; - break; - } - - if (line.IndexOf(':') == 2 && RegexTimeCodes.IsMatch(line)) - { - string temp = line.Substring(0, RegexTimeCodes.Match(line).Length); - string start = temp.Substring(0, 11); - string end = temp.Substring(12, 11); - - string[] startParts = start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); - string[] endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); - if (startParts.Length == 4 && endParts.Length == 4) - { - p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty); - subtitle.Paragraphs.Add(p); - } - } - else if (tline.Length == 0 || tline[0] == '@') - { - // skip these lines - } - else if (tline.Length > 0 && p != null) - { - if (string.IsNullOrEmpty(p.Text)) - { - p.Text = line; - } - else - { - if (Utilities.IsInteger(line)) - { - _errorCount++; - } - p.Text = p.Text.TrimEnd() + Environment.NewLine + line; - } - } - } - if (!beginFound) - { - _errorCount++; - } - - if (!endFound) - { - _errorCount++; - } - - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class AvidCaption : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d \d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "Avid Caption"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + sb.AppendLine("@ This file written with the Avid Caption plugin, version 1"); + sb.AppendLine(); + sb.AppendLine(""); + const string writeFormat = "{0} {1}{2}{3}{2}"; + foreach (Paragraph p in subtitle.Paragraphs) + { + sb.AppendLine(string.Format(writeFormat, p.StartTime.ToHHMMSSFF(), EncodeEndTimeCode(p.EndTime), Environment.NewLine, HtmlUtil.RemoveHtmlTags(p.Text, true))); + //00:50:34:22 00:50:39:13 + //Ich muss dafür sorgen, + //dass die Epsteins weiterleben + } + sb.AppendLine(""); + return sb.ToString(); + } + + private static string EncodeEndTimeCode(TimeCode time) + { + //00:50:39:13 (last is frame) + + //Bugfix for Avid - On 23.976 FPS and 24 FPS projects, when the End time of a subtitle ends in 02, 07, 12, 17, 22, 27 frames, the subtitle won't import. + if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 23.976) < 0.01 || + Math.Abs(Configuration.Settings.General.CurrentFrameRate - 24) < 0.01) + { + var frames = MillisecondsToFramesMaxFrameRate(time.Milliseconds); + if (frames == 2 || frames == 7 || frames == 12 || frames == 17 || frames == 22 || frames == 27) + { + frames--; + } + + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{frames:00}"; + } + else + { + return time.ToHHMMSSFF(); + } + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + //00:03:15:22 00:03:23:10 This is line one. + //This is line two. + Paragraph p = null; + subtitle.Paragraphs.Clear(); + _errorCount = 0; + bool beginFound = false; + bool endFound = false; + foreach (string line in lines) + { + string tline = line.Trim(); + if (tline.Equals("", StringComparison.OrdinalIgnoreCase)) + { + beginFound = true; + } + else if (tline.Equals("", StringComparison.OrdinalIgnoreCase)) + { + endFound = true; + break; + } + + if (line.IndexOf(':') == 2 && RegexTimeCodes.IsMatch(line)) + { + string temp = line.Substring(0, RegexTimeCodes.Match(line).Length); + string start = temp.Substring(0, 11); + string end = temp.Substring(12, 11); + + string[] startParts = start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); + string[] endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); + if (startParts.Length == 4 && endParts.Length == 4) + { + p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty); + subtitle.Paragraphs.Add(p); + } + } + else if (tline.Length == 0 || tline[0] == '@') + { + // skip these lines + } + else if (tline.Length > 0 && p != null) + { + if (string.IsNullOrEmpty(p.Text)) + { + p.Text = line; + } + else + { + if (Utilities.IsInteger(line)) + { + _errorCount++; + } + p.Text = p.Text.TrimEnd() + Environment.NewLine + line; + } + } + } + if (!beginFound) + { + _errorCount++; + } + + if (!endFound) + { + _errorCount++; + } + + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/AvidDvd.cs b/src/libse/SubtitleFormats/AvidDvd.cs similarity index 97% rename from libse/SubtitleFormats/AvidDvd.cs rename to src/libse/SubtitleFormats/AvidDvd.cs index b053c51f5..87e455d48 100644 --- a/libse/SubtitleFormats/AvidDvd.cs +++ b/src/libse/SubtitleFormats/AvidDvd.cs @@ -1,155 +1,155 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class AvidDvd : SubtitleFormat - { - //25 10:03:20:23 10:03:23:05 some text - //I see, on my way.|New line also. - // - //26 10:03:31:18 10:03:34:00 even more text - //Panessa, why didn't they give them - //an escape route ? - - private static readonly Regex RegexTimeCode = new Regex(@"^\d+\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t.+$", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "Avid DVD"; - - public override bool IsMine(List lines, string fileName) - { - if (fileName != null) - { - if (fileName.EndsWith(".dost", StringComparison.OrdinalIgnoreCase)) - { - return false; - } - - if (fileName.EndsWith(".sst", StringComparison.OrdinalIgnoreCase) && new SonicScenaristBitmaps().IsMine(lines, fileName)) - { - return false; - } - } - - return base.IsMine(lines, fileName); - } - - private static string MakeTimeCode(TimeCode tc) - { - return tc.ToHHMMSSFF(); - } - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - int count = 1; - bool italic = false; - for (int i = 0; i < subtitle.Paragraphs.Count; i++) - { - Paragraph p = subtitle.Paragraphs[i]; - string text = p.Text; - if (text.StartsWith('{') && text.Length > 6 && text[6] == '}') - { - text = text.Remove(0, 6); - } - - if (text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal)) - { - if (!italic) - { - italic = true; - sb.AppendLine("$Italic = TRUE"); - } - } - else if (italic) - { - italic = false; - sb.AppendLine("$Italic = FALSE"); - } - - text = HtmlUtil.RemoveHtmlTags(text, true); - sb.AppendLine($"{count}\t{MakeTimeCode(p.StartTime)}\t{MakeTimeCode(p.EndTime)}\t{text.Replace(Environment.NewLine, "|")}"); - sb.AppendLine(); - count++; - } - - return sb.ToString(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - Paragraph p = null; - var sb = new StringBuilder(); - bool italic = false; - foreach (string line in lines) - { - string s = line.TrimEnd(); - if (RegexTimeCode.IsMatch(s)) - { - try - { - if (p != null) - { - p.Text = sb.ToString().Replace("|", Environment.NewLine).Trim(); - subtitle.Paragraphs.Add(p); - } - sb.Clear(); - string[] arr = s.Split('\t'); - if (arr.Length >= 3) - { - string text = s.Remove(0, arr[0].Length + arr[1].Length + arr[2].Length + 2).Trim(); - - if (string.IsNullOrWhiteSpace(text.Replace("0", string.Empty).Replace("1", string.Empty).Replace("2", string.Empty).Replace("3", string.Empty).Replace("4", string.Empty).Replace("5", string.Empty). - Replace("6", string.Empty).Replace("7", string.Empty).Replace("8", string.Empty).Replace("9", string.Empty).RemoveChar('.').RemoveChar(':').RemoveChar(','))) - { - _errorCount++; - } - - if (italic) - { - text = "" + text + ""; - } - - sb.AppendLine(text); - char[] splitChars = { ',', '.', ':' }; - p = new Paragraph(DecodeTimeCodeFrames(arr[1], splitChars), DecodeTimeCodeFrames(arr[2], splitChars), string.Empty); - } - } - catch - { - _errorCount++; - p = null; - } - } - else if (s.StartsWith('$')) - { - if (s.RemoveChar(' ').Equals("$italic=true", StringComparison.OrdinalIgnoreCase)) - { - italic = true; - } - else if (s.RemoveChar(' ').Equals("$italic=false", StringComparison.OrdinalIgnoreCase)) - { - italic = false; - } - } - else if (!string.IsNullOrWhiteSpace(s)) - { - sb.AppendLine(s); - } - } - if (p != null) - { - p.Text = sb.ToString().Replace("|", Environment.NewLine).Trim(); - subtitle.Paragraphs.Add(p); - } - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class AvidDvd : SubtitleFormat + { + //25 10:03:20:23 10:03:23:05 some text + //I see, on my way.|New line also. + // + //26 10:03:31:18 10:03:34:00 even more text + //Panessa, why didn't they give them + //an escape route ? + + private static readonly Regex RegexTimeCode = new Regex(@"^\d+\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t.+$", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "Avid DVD"; + + public override bool IsMine(List lines, string fileName) + { + if (fileName != null) + { + if (fileName.EndsWith(".dost", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + if (fileName.EndsWith(".sst", StringComparison.OrdinalIgnoreCase) && new SonicScenaristBitmaps().IsMine(lines, fileName)) + { + return false; + } + } + + return base.IsMine(lines, fileName); + } + + private static string MakeTimeCode(TimeCode tc) + { + return tc.ToHHMMSSFF(); + } + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + int count = 1; + bool italic = false; + for (int i = 0; i < subtitle.Paragraphs.Count; i++) + { + Paragraph p = subtitle.Paragraphs[i]; + string text = p.Text; + if (text.StartsWith('{') && text.Length > 6 && text[6] == '}') + { + text = text.Remove(0, 6); + } + + if (text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal)) + { + if (!italic) + { + italic = true; + sb.AppendLine("$Italic = TRUE"); + } + } + else if (italic) + { + italic = false; + sb.AppendLine("$Italic = FALSE"); + } + + text = HtmlUtil.RemoveHtmlTags(text, true); + sb.AppendLine($"{count}\t{MakeTimeCode(p.StartTime)}\t{MakeTimeCode(p.EndTime)}\t{text.Replace(Environment.NewLine, "|")}"); + sb.AppendLine(); + count++; + } + + return sb.ToString(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + Paragraph p = null; + var sb = new StringBuilder(); + bool italic = false; + foreach (string line in lines) + { + string s = line.TrimEnd(); + if (RegexTimeCode.IsMatch(s)) + { + try + { + if (p != null) + { + p.Text = sb.ToString().Replace("|", Environment.NewLine).Trim(); + subtitle.Paragraphs.Add(p); + } + sb.Clear(); + string[] arr = s.Split('\t'); + if (arr.Length >= 3) + { + string text = s.Remove(0, arr[0].Length + arr[1].Length + arr[2].Length + 2).Trim(); + + if (string.IsNullOrWhiteSpace(text.Replace("0", string.Empty).Replace("1", string.Empty).Replace("2", string.Empty).Replace("3", string.Empty).Replace("4", string.Empty).Replace("5", string.Empty). + Replace("6", string.Empty).Replace("7", string.Empty).Replace("8", string.Empty).Replace("9", string.Empty).RemoveChar('.').RemoveChar(':').RemoveChar(','))) + { + _errorCount++; + } + + if (italic) + { + text = "" + text + ""; + } + + sb.AppendLine(text); + char[] splitChars = { ',', '.', ':' }; + p = new Paragraph(DecodeTimeCodeFrames(arr[1], splitChars), DecodeTimeCodeFrames(arr[2], splitChars), string.Empty); + } + } + catch + { + _errorCount++; + p = null; + } + } + else if (s.StartsWith('$')) + { + if (s.RemoveChar(' ').Equals("$italic=true", StringComparison.OrdinalIgnoreCase)) + { + italic = true; + } + else if (s.RemoveChar(' ').Equals("$italic=false", StringComparison.OrdinalIgnoreCase)) + { + italic = false; + } + } + else if (!string.IsNullOrWhiteSpace(s)) + { + sb.AppendLine(s); + } + } + if (p != null) + { + p.Text = sb.ToString().Replace("|", Environment.NewLine).Trim(); + subtitle.Paragraphs.Add(p); + } + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/AvidStl.cs b/src/libse/SubtitleFormats/AvidStl.cs similarity index 97% rename from libse/SubtitleFormats/AvidStl.cs rename to src/libse/SubtitleFormats/AvidStl.cs index db141dea9..5f97022d5 100644 --- a/libse/SubtitleFormats/AvidStl.cs +++ b/src/libse/SubtitleFormats/AvidStl.cs @@ -1,194 +1,194 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class AvidStl : SubtitleFormat - { - private const int TextLength = 112; - - private static Paragraph ReadSubtitleBlock(byte[] buffer, int index) - { - index += 5; - var p = new Paragraph { StartTime = ReadTimeCode(buffer, ref index), EndTime = ReadTimeCode(buffer, ref index) }; - index += 3; - for (int i = index; i < index + TextLength; i++) - { - if (buffer[i] == 0x8f || buffer[i] == 0) - { - buffer[i] = 32; - } - else if (buffer[i] == 0x8a) - { - buffer[i] = 0xa; - } - } - p.Text = Encoding.GetEncoding(1252).GetString(buffer, index, TextLength).Trim(); - p.Text = p.Text.Replace("\n", Environment.NewLine); - return p; - } - - private static TimeCode ReadTimeCode(byte[] buffer, ref int index) - { - int hours = buffer[index]; - int minutes = buffer[index + 1]; - int seconds = buffer[index + 2]; - int milliseconds = FramesToMillisecondsMax999(buffer[index + 3]); - index += 4; - return new TimeCode(hours, minutes, seconds, milliseconds); - } - - public static void WriteSubtitleBlock(FileStream fs, Paragraph p, int number) - { - fs.WriteByte(0); - fs.WriteByte((byte)(number % 256)); // number - low byte - fs.WriteByte((byte)(number / 256)); // number - high byte - fs.WriteByte(0xff); - fs.WriteByte(0); - WriteTimeCode(fs, p.StartTime); - WriteTimeCode(fs, p.EndTime); - fs.WriteByte(1); - fs.WriteByte(2); - fs.WriteByte(0); - var buffer = Encoding.GetEncoding(1252).GetBytes(p.Text.Replace(Environment.NewLine, "Š")); - if (buffer.Length <= 128) - { - fs.Write(buffer, 0, buffer.Length); - for (int i = buffer.Length; i < TextLength; i++) - { - fs.WriteByte(0x8f); - } - } - else - { - for (int i = 0; i < TextLength; i++) - { - fs.WriteByte(buffer[i]); - } - } - } - - private static void WriteTimeCode(FileStream fs, TimeCode tc) - { - fs.WriteByte((byte)(tc.Hours)); - fs.WriteByte((byte)(tc.Minutes)); - fs.WriteByte((byte)(tc.Seconds)); - fs.WriteByte((byte)(MillisecondsToFramesMaxFrameRate(tc.Milliseconds))); - } - - public override string Extension => ".stl"; - - public const string NameOfFormat = "Avid STL"; - - public override string Name => NameOfFormat; - - public static void Save(string fileName, Subtitle subtitle) - { - using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) - { - byte[] buffer = { 0x38, 0x35, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x30, 0x30, 0x30, 0x39 }; - fs.Write(buffer, 0, buffer.Length); - for (int i = 0; i < 0xde; i++) - { - fs.WriteByte(0); - } - - string numberOfLines = subtitle.Paragraphs.Count.ToString("D5"); - - buffer = Encoding.ASCII.GetBytes(numberOfLines + numberOfLines + "001"); - fs.Write(buffer, 0, buffer.Length); - for (int i = 0; i < 0x15; i++) - { - fs.WriteByte(0); - } - - buffer = Encoding.ASCII.GetBytes("11"); - fs.Write(buffer, 0, buffer.Length); - while (fs.Length < 1024) - { - fs.WriteByte(0); - } - - int subtitleNumber = 0; - foreach (Paragraph p in subtitle.Paragraphs) - { - WriteSubtitleBlock(fs, p, subtitleNumber); - subtitleNumber++; - } - } - } - - public override bool IsMine(List lines, string fileName) - { - if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) - { - try - { - var fi = new FileInfo(fileName); - if (fi.Length > 1150 && fi.Length < 1024000) // not too small or too big - { - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - if (buffer[0] == 0x38 && - buffer[1] == 0x35 && - buffer[2] == 0x30 && - buffer[1024] == 0 && - buffer[1025] == 0 && - buffer[1026] == 0 && - buffer[1027] == 0xff) - { - return true; - } - - if (fileName.EndsWith(".stl", StringComparison.OrdinalIgnoreCase) && - buffer.Length > 1283 && - buffer[1024] == 0 && - buffer[1025] == 1 && - buffer[1026] == 0 && - buffer[1027] == 0xff && - buffer[1152] == 0 && - buffer[1153] == 2 && - buffer[1154] == 0 && - buffer[1155] == 0xff && - buffer[1280] == 0 && - buffer[1281] == 3 && - buffer[1282] == 0 && - buffer[1283] == 0xff) - { - return true; - } - } - } - catch - { - return false; - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - return "Not supported!"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - subtitle.Paragraphs.Clear(); - subtitle.Header = null; - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - - int index = 1024; - while (index <= buffer.Length - 128) - { - Paragraph p = ReadSubtitleBlock(buffer, index); - subtitle.Paragraphs.Add(p); - index += 128; - } - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class AvidStl : SubtitleFormat + { + private const int TextLength = 112; + + private static Paragraph ReadSubtitleBlock(byte[] buffer, int index) + { + index += 5; + var p = new Paragraph { StartTime = ReadTimeCode(buffer, ref index), EndTime = ReadTimeCode(buffer, ref index) }; + index += 3; + for (int i = index; i < index + TextLength; i++) + { + if (buffer[i] == 0x8f || buffer[i] == 0) + { + buffer[i] = 32; + } + else if (buffer[i] == 0x8a) + { + buffer[i] = 0xa; + } + } + p.Text = Encoding.GetEncoding(1252).GetString(buffer, index, TextLength).Trim(); + p.Text = p.Text.Replace("\n", Environment.NewLine); + return p; + } + + private static TimeCode ReadTimeCode(byte[] buffer, ref int index) + { + int hours = buffer[index]; + int minutes = buffer[index + 1]; + int seconds = buffer[index + 2]; + int milliseconds = FramesToMillisecondsMax999(buffer[index + 3]); + index += 4; + return new TimeCode(hours, minutes, seconds, milliseconds); + } + + public static void WriteSubtitleBlock(FileStream fs, Paragraph p, int number) + { + fs.WriteByte(0); + fs.WriteByte((byte)(number % 256)); // number - low byte + fs.WriteByte((byte)(number / 256)); // number - high byte + fs.WriteByte(0xff); + fs.WriteByte(0); + WriteTimeCode(fs, p.StartTime); + WriteTimeCode(fs, p.EndTime); + fs.WriteByte(1); + fs.WriteByte(2); + fs.WriteByte(0); + var buffer = Encoding.GetEncoding(1252).GetBytes(p.Text.Replace(Environment.NewLine, "Š")); + if (buffer.Length <= 128) + { + fs.Write(buffer, 0, buffer.Length); + for (int i = buffer.Length; i < TextLength; i++) + { + fs.WriteByte(0x8f); + } + } + else + { + for (int i = 0; i < TextLength; i++) + { + fs.WriteByte(buffer[i]); + } + } + } + + private static void WriteTimeCode(FileStream fs, TimeCode tc) + { + fs.WriteByte((byte)(tc.Hours)); + fs.WriteByte((byte)(tc.Minutes)); + fs.WriteByte((byte)(tc.Seconds)); + fs.WriteByte((byte)(MillisecondsToFramesMaxFrameRate(tc.Milliseconds))); + } + + public override string Extension => ".stl"; + + public const string NameOfFormat = "Avid STL"; + + public override string Name => NameOfFormat; + + public static void Save(string fileName, Subtitle subtitle) + { + using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) + { + byte[] buffer = { 0x38, 0x35, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x30, 0x30, 0x30, 0x39 }; + fs.Write(buffer, 0, buffer.Length); + for (int i = 0; i < 0xde; i++) + { + fs.WriteByte(0); + } + + string numberOfLines = subtitle.Paragraphs.Count.ToString("D5"); + + buffer = Encoding.ASCII.GetBytes(numberOfLines + numberOfLines + "001"); + fs.Write(buffer, 0, buffer.Length); + for (int i = 0; i < 0x15; i++) + { + fs.WriteByte(0); + } + + buffer = Encoding.ASCII.GetBytes("11"); + fs.Write(buffer, 0, buffer.Length); + while (fs.Length < 1024) + { + fs.WriteByte(0); + } + + int subtitleNumber = 0; + foreach (Paragraph p in subtitle.Paragraphs) + { + WriteSubtitleBlock(fs, p, subtitleNumber); + subtitleNumber++; + } + } + } + + public override bool IsMine(List lines, string fileName) + { + if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) + { + try + { + var fi = new FileInfo(fileName); + if (fi.Length > 1150 && fi.Length < 1024000) // not too small or too big + { + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + if (buffer[0] == 0x38 && + buffer[1] == 0x35 && + buffer[2] == 0x30 && + buffer[1024] == 0 && + buffer[1025] == 0 && + buffer[1026] == 0 && + buffer[1027] == 0xff) + { + return true; + } + + if (fileName.EndsWith(".stl", StringComparison.OrdinalIgnoreCase) && + buffer.Length > 1283 && + buffer[1024] == 0 && + buffer[1025] == 1 && + buffer[1026] == 0 && + buffer[1027] == 0xff && + buffer[1152] == 0 && + buffer[1153] == 2 && + buffer[1154] == 0 && + buffer[1155] == 0xff && + buffer[1280] == 0 && + buffer[1281] == 3 && + buffer[1282] == 0 && + buffer[1283] == 0xff) + { + return true; + } + } + } + catch + { + return false; + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + return "Not supported!"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + subtitle.Paragraphs.Clear(); + subtitle.Header = null; + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + + int index = 1024; + while (index <= buffer.Length - 128) + { + Paragraph p = ReadSubtitleBlock(buffer, index); + subtitle.Paragraphs.Add(p); + index += 128; + } + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/AwsTranscribeJson.cs b/src/libse/SubtitleFormats/AwsTranscribeJson.cs similarity index 100% rename from libse/SubtitleFormats/AwsTranscribeJson.cs rename to src/libse/SubtitleFormats/AwsTranscribeJson.cs diff --git a/libse/SubtitleFormats/Ayato.cs b/src/libse/SubtitleFormats/Ayato.cs similarity index 97% rename from libse/SubtitleFormats/Ayato.cs rename to src/libse/SubtitleFormats/Ayato.cs index 7c972c637..4563d19ff 100644 --- a/libse/SubtitleFormats/Ayato.cs +++ b/src/libse/SubtitleFormats/Ayato.cs @@ -1,366 +1,366 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Ayato : SubtitleFormat - { - public override string Extension => ".aya"; - - public override string Name => "Ayato"; - - public override bool IsMine(List lines, string fileName) - { - if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) - { - var fi = new FileInfo(fileName); - if (fi.Length >= 3000 && fi.Length < 1024000) // not too small or too big - { - if (!fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) - { - return false; - } - - return base.IsMine(lines, fileName); - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - throw new NotImplementedException(); - } - - public void Save(string fileName, string videoFileName, Subtitle subtitle) - { - using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) - { - // header - var header = new byte[2713]; - header[00] = 0x05; - header[01] = 0x30; - header[02] = 0x32; - header[03] = 0x2E; - header[04] = 0x30; - header[05] = 0x33; - header[06] = 0x05; - header[07] = 0x41; - header[08] = 0x79; - header[09] = 0x61; - header[10] = 0x74; - header[11] = 0x6F; - header[12] = 0x02; - header[77] = 0x01; - header[81] = 0x01; - header[608] = 0x3b; - header[609] = 0x32; - header[613] = 0x58; - header[614] = 0x02; - header[615] = 0xE8; - header[616] = 0x03; - header[617] = 0xE8; - header[618] = 0x03; - header[619] = 0xE8; - header[620] = 0x03; - header[621] = 0xE8; - header[622] = 0x03; - header[639] = 0x02; - - header[682] = (byte)(subtitle.Paragraphs.Count & 0xff); - header[683] = (byte)((subtitle.Paragraphs.Count >> 8) & 0xff); - - header[686] = 0x09; - header[687] = 0x04; - - header[751] = 0x08; - - header[760] = 0x01; - header[761] = 0x0a; - - header[830] = 0x58; - header[831] = 0x48; - - header[2048] = 0x99; - header[2049] = 0x02; - - header[2050] = (byte)(subtitle.Paragraphs.Count & 0xff); - header[2051] = (byte)((subtitle.Paragraphs.Count >> 8) & 0xff); - - header[2069] = 0x17; - header[2071] = 0x17; - header[2073] = 0x02; - header[2075] = 0x27; - header[2077] = 0x0c; - header[2079] = 0x04; - - header[2082] = 0x01; - header[2085] = 0x01; - - // Microsoft Sans Serif - header[2088] = 0x4d; - header[2089] = 0x69; - header[2090] = 0x63; - header[2091] = 0x72; - header[2092] = 0x6f; - header[2093] = 0x73; - header[2094] = 0x6f; - header[2095] = 0x66; - header[2096] = 0x74; - header[2097] = 0x20; - header[2098] = 0x53; - header[2099] = 0x61; - header[2100] = 0x6e; - header[2101] = 0x73; - header[2102] = 0x20; - header[2103] = 0x53; - header[2104] = 0x65; - header[2105] = 0x72; - header[2106] = 0x69; - header[2107] = 0x66; - - header[2120] = 0x1f; - header[2123] = 0x01; - header[2124] = 0x02; - - header[2128] = 0xff; - header[2136] = 0x02; - header[2176] = 0x01; - header[2193] = 0x02; - header[2194] = 0x02; - - header[2197] = 0x0C; - header[2198] = 0x14; - header[2199] = 0x0C; - header[2200] = 0x01; - header[2201] = 0xe8; - header[2202] = 0x03; - header[2203] = 0xe8; - header[2204] = 0x03; - header[2205] = 0xe8; - header[2206] = 0x03; - header[2207] = 0xe8; - header[2208] = 0x03; - - header[2225] = 0x13; - header[2226] = 0x08; - header[2227] = 0xdf; - header[2228] = 0x07; - header[2229] = 0x13; - header[2230] = 0x08; - header[2231] = 0xdf; - header[2232] = 0x07; - - fs.Write(header, 0, header.Length); - - // paragraphs - var sub = new Subtitle(subtitle); - int number = 1; - foreach (Paragraph p in sub.Paragraphs) - { - WriteParagraph(fs, p, number); - number++; - } - } - } - - private static void WriteParagraph(Stream stream, Paragraph paragraph, int number) - { - // subtitle number - stream.WriteByte((byte)(number & 0xff)); - stream.WriteByte((byte)((number >> 8) & 0xff)); - - stream.WriteByte(0); - stream.WriteByte(0); - WriteFrames(stream, paragraph.StartTime); - stream.WriteByte(0); - WriteFrames(stream, paragraph.EndTime); - stream.WriteByte(0); - - stream.WriteByte(0x17); - stream.WriteByte(0); - stream.WriteByte(2); - stream.WriteByte(0); - - WriteText(stream, paragraph.Text); - } - - private static void WriteFrames(Stream stream, TimeCode timeCode) - { - var frames = (uint)Math.Round((double)MillisecondsToFrames(timeCode.TotalMilliseconds)); - stream.WriteByte((byte)(frames & 0xff)); - stream.WriteByte((byte)((frames >> 8) & 0xff)); - stream.WriteByte((byte)((frames >> 16) & 0xff)); - } - - private static void WriteText(Stream stream, string text) - { - var bytes = MakeBytes(text); - - stream.WriteByte((byte)(bytes.Length + 1)); // text length - - for (int i = 0; i < 55; i++) // 55 bytes zero padding - { - stream.WriteByte(0); - } - - stream.WriteByte(7); - stream.Write(bytes, 0, bytes.Length); - } - - private static byte[] MakeBytes(string text) - { - var bytesList = new List(); - int count = 0; - foreach (var line in HtmlUtil.RemoveHtmlTags(text, true).SplitToLines()) - { - if (count > 0) - { - bytesList.Add(0x1f); - bytesList.Add(0x7); - } - bytesList.AddRange(Encoding.UTF8.GetBytes(line)); - count++; - } - return bytesList.ToArray(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - const int startPosition = 0xa99; - const int textPosition = 72; - - _errorCount = 0; - subtitle.Paragraphs.Clear(); - subtitle.Header = null; - var buffer = FileUtil.ReadAllBytesShared(fileName); - int index = startPosition; - if (buffer[index] != 1) - { - return; - } - - while (index + textPosition < buffer.Length) - { - int textLength = buffer[index + 16]; - if (textLength > 0 && index + textPosition + textLength < buffer.Length) - { - string text = GetText(index + textPosition, textLength, buffer); - if (!string.IsNullOrWhiteSpace(text)) - { - int startFrames = GetFrames(index + 4, buffer); - int endFrames = GetFrames(index + 8, buffer); - subtitle.Paragraphs.Add(new Paragraph(text, FramesToMilliseconds(startFrames), FramesToMilliseconds(endFrames))); - } - } - index += textPosition + textLength; - } - subtitle.Renumber(); - } - - private static string GetText(int index, int length, byte[] buffer) - { - if (length < 1) - { - return string.Empty; - } - - int offset = 0; - if (buffer[index] == 7) - { - offset = 1; - } - else if (buffer[index + 1] == 7) - { - offset = 2; - } - else if (buffer[index + 2] == 7) - { - offset = 3; - } - - if (buffer[index + offset] < 32) - { - offset++; - } - - if (length - offset < 1) - { - return string.Empty; - } - - var sb = new StringBuilder(); - var textBytes = new List(); - int i = index + offset; - int max = i + length - offset; - while (i < max) - { - if (i + 3 < max && buffer[i] < 32 && buffer[i + 1] < 32 && buffer[i + 2] < 32 && buffer[i + 3] == 7) - { - AddToLine(textBytes, sb); - sb.AppendLine(); - if (i + 4 < max && buffer[i + 4] < 32) - { - i++; - } - i += 3; - } - else if (i + 2 < max && buffer[i] < 32 && buffer[i + 1] < 32 && buffer[i + 2] == 7) - { - AddToLine(textBytes, sb); - sb.AppendLine(); - if (i + 3 < max && buffer[i + 3] < 32) - { - i++; - } - i += 2; - } - else if (i + 1 < max && buffer[i] < 32 && buffer[i + 1] == 7) - { - AddToLine(textBytes, sb); - sb.AppendLine(); - if (i + 2 < max && buffer[i + 2] < 32) - { - i++; - } - i++; - } - else if (buffer[i] == 7) - { - AddToLine(textBytes, sb); - sb.AppendLine(); - if (i + 1 < max && buffer[i + 1] < 32) - { - i++; - } - } - else - { - textBytes.Add(buffer[i]); - } - i++; - } - AddToLine(textBytes, sb); - return sb.ToString(); - } - - private static void AddToLine(List textBytes, StringBuilder sb) - { - if (textBytes.Count > 0) - { - var lineBuffer = textBytes.ToArray(); - sb.Append(Encoding.UTF8.GetString(lineBuffer, 0, lineBuffer.Length)); - textBytes.Clear(); - } - } - - private static int GetFrames(int index, byte[] buffer) - { - return (buffer[index + 2] << 16) + (buffer[index + 1] << 8) + buffer[index]; - } - - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Ayato : SubtitleFormat + { + public override string Extension => ".aya"; + + public override string Name => "Ayato"; + + public override bool IsMine(List lines, string fileName) + { + if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) + { + var fi = new FileInfo(fileName); + if (fi.Length >= 3000 && fi.Length < 1024000) // not too small or too big + { + if (!fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + return base.IsMine(lines, fileName); + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + throw new NotImplementedException(); + } + + public void Save(string fileName, string videoFileName, Subtitle subtitle) + { + using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) + { + // header + var header = new byte[2713]; + header[00] = 0x05; + header[01] = 0x30; + header[02] = 0x32; + header[03] = 0x2E; + header[04] = 0x30; + header[05] = 0x33; + header[06] = 0x05; + header[07] = 0x41; + header[08] = 0x79; + header[09] = 0x61; + header[10] = 0x74; + header[11] = 0x6F; + header[12] = 0x02; + header[77] = 0x01; + header[81] = 0x01; + header[608] = 0x3b; + header[609] = 0x32; + header[613] = 0x58; + header[614] = 0x02; + header[615] = 0xE8; + header[616] = 0x03; + header[617] = 0xE8; + header[618] = 0x03; + header[619] = 0xE8; + header[620] = 0x03; + header[621] = 0xE8; + header[622] = 0x03; + header[639] = 0x02; + + header[682] = (byte)(subtitle.Paragraphs.Count & 0xff); + header[683] = (byte)((subtitle.Paragraphs.Count >> 8) & 0xff); + + header[686] = 0x09; + header[687] = 0x04; + + header[751] = 0x08; + + header[760] = 0x01; + header[761] = 0x0a; + + header[830] = 0x58; + header[831] = 0x48; + + header[2048] = 0x99; + header[2049] = 0x02; + + header[2050] = (byte)(subtitle.Paragraphs.Count & 0xff); + header[2051] = (byte)((subtitle.Paragraphs.Count >> 8) & 0xff); + + header[2069] = 0x17; + header[2071] = 0x17; + header[2073] = 0x02; + header[2075] = 0x27; + header[2077] = 0x0c; + header[2079] = 0x04; + + header[2082] = 0x01; + header[2085] = 0x01; + + // Microsoft Sans Serif + header[2088] = 0x4d; + header[2089] = 0x69; + header[2090] = 0x63; + header[2091] = 0x72; + header[2092] = 0x6f; + header[2093] = 0x73; + header[2094] = 0x6f; + header[2095] = 0x66; + header[2096] = 0x74; + header[2097] = 0x20; + header[2098] = 0x53; + header[2099] = 0x61; + header[2100] = 0x6e; + header[2101] = 0x73; + header[2102] = 0x20; + header[2103] = 0x53; + header[2104] = 0x65; + header[2105] = 0x72; + header[2106] = 0x69; + header[2107] = 0x66; + + header[2120] = 0x1f; + header[2123] = 0x01; + header[2124] = 0x02; + + header[2128] = 0xff; + header[2136] = 0x02; + header[2176] = 0x01; + header[2193] = 0x02; + header[2194] = 0x02; + + header[2197] = 0x0C; + header[2198] = 0x14; + header[2199] = 0x0C; + header[2200] = 0x01; + header[2201] = 0xe8; + header[2202] = 0x03; + header[2203] = 0xe8; + header[2204] = 0x03; + header[2205] = 0xe8; + header[2206] = 0x03; + header[2207] = 0xe8; + header[2208] = 0x03; + + header[2225] = 0x13; + header[2226] = 0x08; + header[2227] = 0xdf; + header[2228] = 0x07; + header[2229] = 0x13; + header[2230] = 0x08; + header[2231] = 0xdf; + header[2232] = 0x07; + + fs.Write(header, 0, header.Length); + + // paragraphs + var sub = new Subtitle(subtitle); + int number = 1; + foreach (Paragraph p in sub.Paragraphs) + { + WriteParagraph(fs, p, number); + number++; + } + } + } + + private static void WriteParagraph(Stream stream, Paragraph paragraph, int number) + { + // subtitle number + stream.WriteByte((byte)(number & 0xff)); + stream.WriteByte((byte)((number >> 8) & 0xff)); + + stream.WriteByte(0); + stream.WriteByte(0); + WriteFrames(stream, paragraph.StartTime); + stream.WriteByte(0); + WriteFrames(stream, paragraph.EndTime); + stream.WriteByte(0); + + stream.WriteByte(0x17); + stream.WriteByte(0); + stream.WriteByte(2); + stream.WriteByte(0); + + WriteText(stream, paragraph.Text); + } + + private static void WriteFrames(Stream stream, TimeCode timeCode) + { + var frames = (uint)Math.Round((double)MillisecondsToFrames(timeCode.TotalMilliseconds)); + stream.WriteByte((byte)(frames & 0xff)); + stream.WriteByte((byte)((frames >> 8) & 0xff)); + stream.WriteByte((byte)((frames >> 16) & 0xff)); + } + + private static void WriteText(Stream stream, string text) + { + var bytes = MakeBytes(text); + + stream.WriteByte((byte)(bytes.Length + 1)); // text length + + for (int i = 0; i < 55; i++) // 55 bytes zero padding + { + stream.WriteByte(0); + } + + stream.WriteByte(7); + stream.Write(bytes, 0, bytes.Length); + } + + private static byte[] MakeBytes(string text) + { + var bytesList = new List(); + int count = 0; + foreach (var line in HtmlUtil.RemoveHtmlTags(text, true).SplitToLines()) + { + if (count > 0) + { + bytesList.Add(0x1f); + bytesList.Add(0x7); + } + bytesList.AddRange(Encoding.UTF8.GetBytes(line)); + count++; + } + return bytesList.ToArray(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + const int startPosition = 0xa99; + const int textPosition = 72; + + _errorCount = 0; + subtitle.Paragraphs.Clear(); + subtitle.Header = null; + var buffer = FileUtil.ReadAllBytesShared(fileName); + int index = startPosition; + if (buffer[index] != 1) + { + return; + } + + while (index + textPosition < buffer.Length) + { + int textLength = buffer[index + 16]; + if (textLength > 0 && index + textPosition + textLength < buffer.Length) + { + string text = GetText(index + textPosition, textLength, buffer); + if (!string.IsNullOrWhiteSpace(text)) + { + int startFrames = GetFrames(index + 4, buffer); + int endFrames = GetFrames(index + 8, buffer); + subtitle.Paragraphs.Add(new Paragraph(text, FramesToMilliseconds(startFrames), FramesToMilliseconds(endFrames))); + } + } + index += textPosition + textLength; + } + subtitle.Renumber(); + } + + private static string GetText(int index, int length, byte[] buffer) + { + if (length < 1) + { + return string.Empty; + } + + int offset = 0; + if (buffer[index] == 7) + { + offset = 1; + } + else if (buffer[index + 1] == 7) + { + offset = 2; + } + else if (buffer[index + 2] == 7) + { + offset = 3; + } + + if (buffer[index + offset] < 32) + { + offset++; + } + + if (length - offset < 1) + { + return string.Empty; + } + + var sb = new StringBuilder(); + var textBytes = new List(); + int i = index + offset; + int max = i + length - offset; + while (i < max) + { + if (i + 3 < max && buffer[i] < 32 && buffer[i + 1] < 32 && buffer[i + 2] < 32 && buffer[i + 3] == 7) + { + AddToLine(textBytes, sb); + sb.AppendLine(); + if (i + 4 < max && buffer[i + 4] < 32) + { + i++; + } + i += 3; + } + else if (i + 2 < max && buffer[i] < 32 && buffer[i + 1] < 32 && buffer[i + 2] == 7) + { + AddToLine(textBytes, sb); + sb.AppendLine(); + if (i + 3 < max && buffer[i + 3] < 32) + { + i++; + } + i += 2; + } + else if (i + 1 < max && buffer[i] < 32 && buffer[i + 1] == 7) + { + AddToLine(textBytes, sb); + sb.AppendLine(); + if (i + 2 < max && buffer[i + 2] < 32) + { + i++; + } + i++; + } + else if (buffer[i] == 7) + { + AddToLine(textBytes, sb); + sb.AppendLine(); + if (i + 1 < max && buffer[i + 1] < 32) + { + i++; + } + } + else + { + textBytes.Add(buffer[i]); + } + i++; + } + AddToLine(textBytes, sb); + return sb.ToString(); + } + + private static void AddToLine(List textBytes, StringBuilder sb) + { + if (textBytes.Count > 0) + { + var lineBuffer = textBytes.ToArray(); + sb.Append(Encoding.UTF8.GetString(lineBuffer, 0, lineBuffer.Length)); + textBytes.Clear(); + } + } + + private static int GetFrames(int index, byte[] buffer) + { + return (buffer[index + 2] << 16) + (buffer[index + 1] << 8) + buffer[index]; + } + + } +} diff --git a/libse/SubtitleFormats/BdnXml.cs b/src/libse/SubtitleFormats/BdnXml.cs similarity index 97% rename from libse/SubtitleFormats/BdnXml.cs rename to src/libse/SubtitleFormats/BdnXml.cs index 3bb7fdc17..5b6d1ccc9 100644 --- a/libse/SubtitleFormats/BdnXml.cs +++ b/src/libse/SubtitleFormats/BdnXml.cs @@ -1,112 +1,112 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class BdnXml : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "BDN Xml"; - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - ""; - - var xml = new XmlDocument { XmlResolver = null }; - xml.LoadXml(xmlStructure); - - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("Paragraph"); - - XmlNode number = xml.CreateElement("Number"); - number.InnerText = p.Number.ToString(CultureInfo.InvariantCulture); - paragraph.AppendChild(number); - - XmlNode start = xml.CreateElement("StartMilliseconds"); - start.InnerText = p.StartTime.TotalMilliseconds.ToString(CultureInfo.InvariantCulture); - paragraph.AppendChild(start); - - XmlNode end = xml.CreateElement("EndMilliseconds"); - end.InnerText = p.EndTime.TotalMilliseconds.ToString(CultureInfo.InvariantCulture); - paragraph.AppendChild(end); - - XmlNode text = xml.CreateElement("Text"); - text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text, true); - paragraph.AppendChild(text); - - xml.DocumentElement.AppendChild(paragraph); - } - string textUtf8; - using (var ms = new MemoryStream()) - { - var writer = new XmlTextWriter(ms, Encoding.UTF8) { Formatting = Formatting.Indented }; - xml.Save(writer); - textUtf8 = Encoding.UTF8.GetString(ms.ToArray()); - } - return textUtf8.Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - - string xmlString = sb.ToString(); - if (!xmlString.Contains(" ".xml"; + + public override string Name => "BDN Xml"; + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + ""; + + var xml = new XmlDocument { XmlResolver = null }; + xml.LoadXml(xmlStructure); + + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("Paragraph"); + + XmlNode number = xml.CreateElement("Number"); + number.InnerText = p.Number.ToString(CultureInfo.InvariantCulture); + paragraph.AppendChild(number); + + XmlNode start = xml.CreateElement("StartMilliseconds"); + start.InnerText = p.StartTime.TotalMilliseconds.ToString(CultureInfo.InvariantCulture); + paragraph.AppendChild(start); + + XmlNode end = xml.CreateElement("EndMilliseconds"); + end.InnerText = p.EndTime.TotalMilliseconds.ToString(CultureInfo.InvariantCulture); + paragraph.AppendChild(end); + + XmlNode text = xml.CreateElement("Text"); + text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text, true); + paragraph.AppendChild(text); + + xml.DocumentElement.AppendChild(paragraph); + } + string textUtf8; + using (var ms = new MemoryStream()) + { + var writer = new XmlTextWriter(ms, Encoding.UTF8) { Formatting = Formatting.Indented }; + xml.Save(writer); + textUtf8 = Encoding.UTF8.GetString(ms.ToArray()); + } + return textUtf8.Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + + string xmlString = sb.ToString(); + if (!xmlString.Contains(" ".stp"; - - public override string Name => "Belle Nuit Subtitler"; - - public override string ToText(Subtitle subtitle, string title) - { - const string paragraphWriteFormat = "/tc {0} {1}{2}{3}{2}"; - - var sb = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), Environment.NewLine, EncodeText(p.Text))); - } - - var doc = new XmlDocument { XmlResolver = null }; - doc.LoadXml("" + Environment.NewLine + @" - document - - creator - SICT - type - STLI - version - 1.4 - applicationversion - Belle Nuit Subtitler 1.7.8 - creationdate - 2012-03-13 16:30:32 - modificationdate - 2012-03-13 16:30:32 - - mainleft - 40 - maintop - 48 - mainwidth - 825 - mainheight - 886 - styledt - - exportdt - - previewdt - - moviedt - - exportformat - TIFF - style - - font - Geneva - size - 26 - spacing - 1 - leading - 7 - bold - - italic - - underline - - vertical - 486 - halin - 1 - valign - 2 - standard - PAL - height - 576 - width - 720 - widthreal - 768 - antialiasing - 4 - left - 40 - right - 680 - wrapmethod - 2 - interlaced - - textcolor - #FBFFF2 - textalpha - 1 - textsoft - 0 - bordercolor - #F0F10 - borderalpha - 1 - bordersoft - 0 - borderwidth - 6 - rectcolor - #0 - rectalpha - 0 - rectsoft - 0 - rectform - 1 - shadowcolor - #7F7F7F - shadowalpha - 0 - shadowsoft - 0 - shadowx - 2 - shadowy - 2 - framerate - 25 - - folderpath - - prefix - - moviepath - - movieoffset - 00:00:00:00 - moviesyncoption - - pagesetup - - titlelist -"); - XmlNode node = doc.CreateElement("string"); - node.InnerText = sb.ToString().Trim() + Environment.NewLine + Environment.NewLine; - doc.DocumentElement.AppendChild(node); - - return ToUtf8XmlString(doc).Replace("\r\n", "\n"); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var sb = new StringBuilder(); - foreach (var line in lines) - { - sb.AppendLine(line); - } - var doc = new XmlDocument { XmlResolver = null }; - try - { - doc.LoadXml(sb.ToString()); - if (doc.DocumentElement == null || doc.DocumentElement.Name != "xmldict" || doc.DocumentElement.SelectSingleNode("string") == null) - { - return; - } - } - catch (Exception) - { - _errorCount = 1; - return; - } - - string text = null; - string keyName = string.Empty; - foreach (XmlNode node in doc.DocumentElement.ChildNodes) - { - if (node.Name == "key") - { - keyName = node.InnerText; - } - else if (node.Name == "string" && keyName == "titlelist") - { - text = node.InnerText; - break; - } - } - if (text == null) - { - return; - } - - subtitle.Paragraphs.Clear(); - Paragraph paragraph = null; - sb.Clear(); - foreach (string line in text.Split(Utilities.NewLineChars)) - { - if (RegexTimeCode.IsMatch(line)) - { - string[] parts = line.Substring(4, 11).Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); - if (parts.Length == 4) - { - try - { - if (paragraph != null && !string.IsNullOrWhiteSpace(sb.ToString())) - { - paragraph.Text = DecodeText(sb); - } - - var start = DecodeTimeCodeFramesFourParts(parts); - parts = line.Substring(16, 11).Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); - var end = DecodeTimeCodeFramesFourParts(parts); - paragraph = new Paragraph { StartTime = start, EndTime = end }; - subtitle.Paragraphs.Add(paragraph); - sb.Clear(); - } - catch - { - _errorCount++; - } - } - } - else if (RegexFileNum.IsMatch(line)) - { - continue; // skip Belle-Nuit's numbering lines ("/file 0001") - } - else if (paragraph != null) - { - sb.AppendLine(line); - } - else - { - _errorCount++; - } - } - if (paragraph != null && !string.IsNullOrWhiteSpace(sb.ToString())) - { - paragraph.Text = DecodeText(sb); - } - subtitle.Renumber(); - } - - private static string EncodeText(string s) - { - s = HtmlUtil.RemoveOpenCloseTags(s, HtmlUtil.TagBold, HtmlUtil.TagUnderline, HtmlUtil.TagFont); - if (s.StartsWith("{\\an3}", StringComparison.Ordinal) || s.StartsWith("{\\an6}", StringComparison.Ordinal)) - { - s = "/STYLE RIGHT" + Environment.NewLine + s.Remove(0, 6).Trim(); - } - - if (s.StartsWith("{\\an1}", StringComparison.Ordinal) || s.StartsWith("{\\an4}", StringComparison.Ordinal)) - { - s = "/STYLE LEFT" + Environment.NewLine + s.Remove(0, 6).Trim(); - } - - if (s.StartsWith("{\\an7}", StringComparison.Ordinal) || s.StartsWith("{\\an8}", StringComparison.Ordinal) || s.StartsWith("{\\an9}", StringComparison.Ordinal)) - { - s = "/STYLE VERTICAL(-25)" + Environment.NewLine + s.Remove(0, 6).Trim(); - } - - if (s.StartsWith("{\\an2}", StringComparison.Ordinal) || s.StartsWith("{\\an5}", StringComparison.Ordinal)) - { - s = s.Remove(0, 6).Trim(); - } - - return s; - } - - private static string DecodeText(StringBuilder sb) - { - var s = sb.ToString().Trim(); - s = s.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine).Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); - if (s.StartsWith("/STYLE RIGHT" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an3}" + s.Remove(0, 12).Trim(); - } - - if (s.StartsWith("/STYLE LEFT" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an1}" + s.Remove(0, 11).Trim(); - } - - if (s.StartsWith("/STYLE TOP" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an8}" + s.Remove(0, 10).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-25)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an8}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-24)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an8}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-23)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an8}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-22)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an8}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-21)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an8}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-20)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an8}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-19)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an8}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-18)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an5}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-17)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an5}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-16)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an5}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-15)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an5}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-14)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an5}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-13)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an5}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-12)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an5}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-11)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an5}" + s.Remove(0, 20).Trim(); - } - - if (s.StartsWith("/STYLE VERTICAL(-10)" + Environment.NewLine, StringComparison.Ordinal)) - { - s = "{\\an5}" + s.Remove(0, 20).Trim(); - } - - s = HtmlUtil.FixInvalidItalicTags(s); - return s; - } - - private static string EncodeTimeCode(TimeCode time) - { - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class BelleNuitSubtitler : SubtitleFormat + { + ///tc 00:00:35:09 00:00:38:05 + private static readonly Regex RegexTimeCode = new Regex(@"^\/tc \d\d:\d\d:\d\d:\d\d \d\d:\d\d:\d\d:\d\d", RegexOptions.Compiled); + private static readonly Regex RegexFileNum = new Regex(@"^\/file\s+\d+$", RegexOptions.Compiled); + + public override string Extension => ".stp"; + + public override string Name => "Belle Nuit Subtitler"; + + public override string ToText(Subtitle subtitle, string title) + { + const string paragraphWriteFormat = "/tc {0} {1}{2}{3}{2}"; + + var sb = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), Environment.NewLine, EncodeText(p.Text))); + } + + var doc = new XmlDocument { XmlResolver = null }; + doc.LoadXml("" + Environment.NewLine + @" + document + + creator + SICT + type + STLI + version + 1.4 + applicationversion + Belle Nuit Subtitler 1.7.8 + creationdate + 2012-03-13 16:30:32 + modificationdate + 2012-03-13 16:30:32 + + mainleft + 40 + maintop + 48 + mainwidth + 825 + mainheight + 886 + styledt + + exportdt + + previewdt + + moviedt + + exportformat + TIFF + style + + font + Geneva + size + 26 + spacing + 1 + leading + 7 + bold + + italic + + underline + + vertical + 486 + halin + 1 + valign + 2 + standard + PAL + height + 576 + width + 720 + widthreal + 768 + antialiasing + 4 + left + 40 + right + 680 + wrapmethod + 2 + interlaced + + textcolor + #FBFFF2 + textalpha + 1 + textsoft + 0 + bordercolor + #F0F10 + borderalpha + 1 + bordersoft + 0 + borderwidth + 6 + rectcolor + #0 + rectalpha + 0 + rectsoft + 0 + rectform + 1 + shadowcolor + #7F7F7F + shadowalpha + 0 + shadowsoft + 0 + shadowx + 2 + shadowy + 2 + framerate + 25 + + folderpath + + prefix + + moviepath + + movieoffset + 00:00:00:00 + moviesyncoption + + pagesetup + + titlelist +"); + XmlNode node = doc.CreateElement("string"); + node.InnerText = sb.ToString().Trim() + Environment.NewLine + Environment.NewLine; + doc.DocumentElement.AppendChild(node); + + return ToUtf8XmlString(doc).Replace("\r\n", "\n"); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var sb = new StringBuilder(); + foreach (var line in lines) + { + sb.AppendLine(line); + } + var doc = new XmlDocument { XmlResolver = null }; + try + { + doc.LoadXml(sb.ToString()); + if (doc.DocumentElement == null || doc.DocumentElement.Name != "xmldict" || doc.DocumentElement.SelectSingleNode("string") == null) + { + return; + } + } + catch (Exception) + { + _errorCount = 1; + return; + } + + string text = null; + string keyName = string.Empty; + foreach (XmlNode node in doc.DocumentElement.ChildNodes) + { + if (node.Name == "key") + { + keyName = node.InnerText; + } + else if (node.Name == "string" && keyName == "titlelist") + { + text = node.InnerText; + break; + } + } + if (text == null) + { + return; + } + + subtitle.Paragraphs.Clear(); + Paragraph paragraph = null; + sb.Clear(); + foreach (string line in text.Split(Utilities.NewLineChars)) + { + if (RegexTimeCode.IsMatch(line)) + { + string[] parts = line.Substring(4, 11).Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); + if (parts.Length == 4) + { + try + { + if (paragraph != null && !string.IsNullOrWhiteSpace(sb.ToString())) + { + paragraph.Text = DecodeText(sb); + } + + var start = DecodeTimeCodeFramesFourParts(parts); + parts = line.Substring(16, 11).Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); + var end = DecodeTimeCodeFramesFourParts(parts); + paragraph = new Paragraph { StartTime = start, EndTime = end }; + subtitle.Paragraphs.Add(paragraph); + sb.Clear(); + } + catch + { + _errorCount++; + } + } + } + else if (RegexFileNum.IsMatch(line)) + { + continue; // skip Belle-Nuit's numbering lines ("/file 0001") + } + else if (paragraph != null) + { + sb.AppendLine(line); + } + else + { + _errorCount++; + } + } + if (paragraph != null && !string.IsNullOrWhiteSpace(sb.ToString())) + { + paragraph.Text = DecodeText(sb); + } + subtitle.Renumber(); + } + + private static string EncodeText(string s) + { + s = HtmlUtil.RemoveOpenCloseTags(s, HtmlUtil.TagBold, HtmlUtil.TagUnderline, HtmlUtil.TagFont); + if (s.StartsWith("{\\an3}", StringComparison.Ordinal) || s.StartsWith("{\\an6}", StringComparison.Ordinal)) + { + s = "/STYLE RIGHT" + Environment.NewLine + s.Remove(0, 6).Trim(); + } + + if (s.StartsWith("{\\an1}", StringComparison.Ordinal) || s.StartsWith("{\\an4}", StringComparison.Ordinal)) + { + s = "/STYLE LEFT" + Environment.NewLine + s.Remove(0, 6).Trim(); + } + + if (s.StartsWith("{\\an7}", StringComparison.Ordinal) || s.StartsWith("{\\an8}", StringComparison.Ordinal) || s.StartsWith("{\\an9}", StringComparison.Ordinal)) + { + s = "/STYLE VERTICAL(-25)" + Environment.NewLine + s.Remove(0, 6).Trim(); + } + + if (s.StartsWith("{\\an2}", StringComparison.Ordinal) || s.StartsWith("{\\an5}", StringComparison.Ordinal)) + { + s = s.Remove(0, 6).Trim(); + } + + return s; + } + + private static string DecodeText(StringBuilder sb) + { + var s = sb.ToString().Trim(); + s = s.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine).Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); + if (s.StartsWith("/STYLE RIGHT" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an3}" + s.Remove(0, 12).Trim(); + } + + if (s.StartsWith("/STYLE LEFT" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an1}" + s.Remove(0, 11).Trim(); + } + + if (s.StartsWith("/STYLE TOP" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an8}" + s.Remove(0, 10).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-25)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an8}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-24)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an8}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-23)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an8}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-22)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an8}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-21)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an8}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-20)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an8}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-19)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an8}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-18)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an5}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-17)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an5}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-16)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an5}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-15)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an5}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-14)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an5}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-13)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an5}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-12)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an5}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-11)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an5}" + s.Remove(0, 20).Trim(); + } + + if (s.StartsWith("/STYLE VERTICAL(-10)" + Environment.NewLine, StringComparison.Ordinal)) + { + s = "{\\an5}" + s.Remove(0, 20).Trim(); + } + + s = HtmlUtil.FixInvalidItalicTags(s); + return s; + } + + private static string EncodeTimeCode(TimeCode time) + { + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + } +} diff --git a/libse/SubtitleFormats/Bilibili.cs b/src/libse/SubtitleFormats/Bilibili.cs similarity index 100% rename from libse/SubtitleFormats/Bilibili.cs rename to src/libse/SubtitleFormats/Bilibili.cs diff --git a/libse/SubtitleFormats/CapMakerPlus.cs b/src/libse/SubtitleFormats/CapMakerPlus.cs similarity index 98% rename from libse/SubtitleFormats/CapMakerPlus.cs rename to src/libse/SubtitleFormats/CapMakerPlus.cs index aaa0123b8..c501c7653 100644 --- a/libse/SubtitleFormats/CapMakerPlus.cs +++ b/src/libse/SubtitleFormats/CapMakerPlus.cs @@ -1,277 +1,277 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class CapMakerPlus : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); - - public override string Extension => ".cap"; - - public const string NameOfFormat = "CapMaker Plus"; - - public override string Name => NameOfFormat; - - public static void Save(string fileName, Subtitle subtitle) - { - Paragraph p; - int gridDataCount = subtitle.Paragraphs.Count; - for (int i = 0; i < subtitle.Paragraphs.Count; i++) - { - p = subtitle.Paragraphs[i]; - Paragraph next = subtitle.GetParagraphOrDefault(i + 1); - if (next != null && next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds > 100) - { - gridDataCount++; - } - } - - var buffer = new byte[] { 0x2B, 0x27, 0xF, 0x3C, 0x43, 0x61, 0x70, 0x4D, 0x61, 0x6B, 0x65, 0x72, 0x20, 0x50, 0x6C, 0x75, 0x73, 0x3E, 0x3, 0x2, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x21, 0, 0, 0, 0, 0, 0, 0, 0x7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x5, 0, 0, 0, 0x5, 0, 0, 0, 0x5, 0, 0, 0, 0x5, 0, 0, 0, 0x1, 0, 0, 0, 0x5E, 0x1, 0, 0, 0x1E, 0, 0, 0, 0x20, 0, 0, 0, 0x2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x7D, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x42, 0, 0, 0, 0x30, 0, 0, 0, 0x42, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0x20, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x2, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0x10, 0x10, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0xFF, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0x40, 0x40, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0xFF, 0, 0, 0, 0x1, 0, 0, 0, 0x2, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0x1, 0, 0x9, 0, 0x43, 0x47, 0x72, 0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x3, 0x2, 0x25, 0, 0, 0, 0, 0, 0, 0, 0x9, 0x4C, 0x61, 0x6E, 0x67, 0x75, 0x61, 0x67, 0x65, 0x31, 0x1, 0, 0xFF, 0, 0x1, 0, 0, 0, 0, 0, 0, 0x80, 0xBF, 0, 0, 0, 0xC0, 0x2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x9, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x2E, 0x63, 0x61, 0x70, 0x9, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x2E, 0x63, 0x61, 0x70, 0x1F, 0x44, 0x3A, 0x5C, 0x43, 0x70, 0x63, 0x57, 0x69, 0x6E, 0x5C, 0x37, 0x30, 0x30, 0x5C, 0x53, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x73, 0x5C, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x2E, 0x74, 0x78, 0x74, 0x3C, 0, 0, 0, 0x5, 0x41, 0x72, 0x69, 0x61, 0x6C, 0, 0, 0, 0x40, 0xE0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3C, 0, 0, 0, 0xB, 0x43, 0x6F, 0x75, 0x72, 0x69, 0x65, 0x72, 0x20, 0x4E, 0x65, 0x77, 0, 0, 0, 0x40, 0xB4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0xF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFB, 0xFF, 0x4, 0, 0xC, 0, 0, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0x1, 0, 0, 0xF0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x14, 0, 0, 0, 0xA, 0, 0, 0, 0x14, 0, 0, 0, 0xA, 0, 0, 0, 0, 0, 0, 0x9, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x2E, 0x63, 0x61, 0x70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0 }; - buffer[1400] = (byte)(gridDataCount % 256); // paragraphs - low byte - buffer[1401] = (byte)(gridDataCount / 256); // paragraphs - high byte - - using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) - { - fs.Write(buffer, 0, buffer.Length); - - p = null; - for (int i = 0; i < subtitle.Paragraphs.Count; i++) - { - p = subtitle.Paragraphs[i]; - Paragraph next = subtitle.GetParagraphOrDefault(i + 1); - - WriteTime(fs, p.StartTime); - - buffer = new byte[] { - // styles 00 00 80 BF 00 00 00 C0 02 00 01 00 - 0, - 0, - 0x80, //horizontal align, 0x80BF= center, 0x0000=left, 0x00c0=right - 0xBF, - 0, - 0, - 0, - 0xC0, // vertical Position: C0=bottom, 0=top - 2, //justification, 1=left, 2=center - 0, - 1, //1=normal font, 3=italic - 0 - }; - - string text = p.Text; - if (text.StartsWith("{\\a6}", StringComparison.Ordinal)) - { - text = p.Text.Remove(0, 5); - buffer[7] = 0; // align top - } - else if (text.StartsWith("{\\a1}", StringComparison.Ordinal)) - { - text = p.Text.Remove(0, 5); - buffer[2] = 0; // align left - buffer[3] = 0; // align left - } - else if (text.StartsWith("{\\a3}", StringComparison.Ordinal)) - { - text = p.Text.Remove(0, 5); - buffer[2] = 0; // align right - buffer[3] = 0xc0; // align right - } - else if (text.StartsWith("{\\a5}", StringComparison.Ordinal)) - { - text = p.Text.Remove(0, 5); - buffer[7] = 0; // align top - buffer[2] = 0; // align left - buffer[3] = 0; // align left - } - else if (text.StartsWith("{\\a7}", StringComparison.Ordinal)) - { - text = p.Text.Remove(0, 5); - buffer[7] = 0; // align top - buffer[2] = 0; // align right - buffer[3] = 0xc0; // align right - } - - if (text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal)) - { - buffer[10] = 3; - } - - fs.Write(buffer, 0, buffer.Length); - - text = HtmlUtil.RemoveHtmlTags(text); - if (text.Length > 118) - { - text = text.Substring(0, 118); - } - - fs.WriteByte((byte)(text.Length)); - buffer = Encoding.GetEncoding(1252).GetBytes(text); - fs.Write(buffer, 0, buffer.Length); - - for (int j = 0; j < 74; j++) - { - fs.WriteByte(0); - } - - if (next != null && next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds > 100) - { - // write empty end - WriteTime(fs, p.EndTime); - buffer = new byte[] { 0, 0, 0, 0xC0, 0, 0, 0, 0, 0x01, 0, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - fs.Write(buffer, 0, buffer.Length); - } - } - if (p != null) - { - WriteTime(fs, p.EndTime); - buffer = new byte[] { 0, 0, 0x80, 0xBF, 0, 0, 0, 0xC0, 0x02, 0, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0x40, 0x40, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x01, 0, 0, 0, 0xFF, 0, 0, 0, 0x01, 0, 0, 0, 0x02, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - fs.Write(buffer, 0, buffer.Length); - } - } - } - - private static void WriteTime(FileStream fs, TimeCode timeCode) - { - fs.WriteByte(0xb); - byte[] buffer = Encoding.ASCII.GetBytes(timeCode.ToHHMMSSFF()); - fs.Write(buffer, 0, buffer.Length); - } - - public override bool IsMine(List lines, string fileName) - { - if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) - { - var fi = new FileInfo(fileName); - if (fi.Length >= 640 && fi.Length < 1024000) // not too small or too big - { - if (fileName.EndsWith(".cap", StringComparison.OrdinalIgnoreCase)) - { - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - if (buffer[0] == 0x2b) // "+" - { - return true; - } - } - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - return "Not supported!"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - subtitle.Paragraphs.Clear(); - subtitle.Header = null; - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - - int i = 128; - Paragraph last = null; - while (i < buffer.Length - 20) - { - if (buffer[i] == 0x0b) - { - string timeCode = Encoding.ASCII.GetString(buffer, i + 1, 11); - if (timeCode != "00:00:00:00" && RegexTimeCodes.IsMatch(timeCode)) - { - var p = new Paragraph { StartTime = DecodeTimeCodeFramesFourParts(timeCode.Split(':')) }; - bool italic = buffer[i + 22] == 3; // 3=italic, 1=normal - int textStart = i + 25; // text starts 25 chars after time code - int textLength = 0; - while (textStart + textLength < buffer.Length && buffer[textStart + textLength] != 0) - { - textLength++; - } - if (textLength > 0) - { - p.Text = Encoding.GetEncoding(1252).GetString(buffer, textStart, textLength); - int rtIndex = p.Text.IndexOf("{\\rtf1", StringComparison.Ordinal); - if (rtIndex >= 0 && rtIndex < 10) - { - p.Text = p.Text.Substring(rtIndex).FromRtf(); - } - else if (italic) - { - p.Text = "" + p.Text + ""; - } - } - else - { - p.Text = string.Empty; - } - last = p; - subtitle.Paragraphs.Add(p); - } - } - i++; - } - if (last != null) - { - last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(last.Text); - } - - for (i = 0; i < subtitle.Paragraphs.Count - 1; i++) - { - subtitle.Paragraphs[i].EndTime.TotalMilliseconds = subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds; - } - for (i = subtitle.Paragraphs.Count - 1; i >= 0; i--) - { - if (string.IsNullOrEmpty(subtitle.Paragraphs[i].Text)) - { - subtitle.Paragraphs.RemoveAt(i); - } - } - - var deletes = new List(); - for (i = 0; i < subtitle.Paragraphs.Count - 1; i++) - { - if (subtitle.Paragraphs[i].StartTime.TotalMilliseconds == subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds) - { - subtitle.Paragraphs[i].Text += Environment.NewLine + subtitle.Paragraphs[i + 1].Text; - subtitle.Paragraphs[i].EndTime = subtitle.Paragraphs[i + 1].EndTime; - deletes.Add(i + 1); - } - } - subtitle.RemoveParagraphsByIndices(deletes); - - for (i = 0; i < subtitle.Paragraphs.Count - 1; i++) - { - if (subtitle.Paragraphs[i].StartTime.TotalMilliseconds == subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds) - { - } - else if (subtitle.Paragraphs[i].EndTime.TotalMilliseconds == subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds) - { - subtitle.Paragraphs[i].EndTime.TotalMilliseconds = subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds - 1; - } - } - subtitle.Renumber(); - - // adjust all times - if (buffer.Length > 1364) - { - try - { - string adjust = Encoding.GetEncoding(1252).GetString(buffer, 1354, 11); // 00:59:59:28 - TimeCode tc = DecodeTimeCodeFramesFourParts(adjust.Split(':')); - if (tc.TotalMilliseconds > 0) - { - subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-tc.TotalMilliseconds)); - } - } - catch - { - // ignored - } - } - } - - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class CapMakerPlus : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); + + public override string Extension => ".cap"; + + public const string NameOfFormat = "CapMaker Plus"; + + public override string Name => NameOfFormat; + + public static void Save(string fileName, Subtitle subtitle) + { + Paragraph p; + int gridDataCount = subtitle.Paragraphs.Count; + for (int i = 0; i < subtitle.Paragraphs.Count; i++) + { + p = subtitle.Paragraphs[i]; + Paragraph next = subtitle.GetParagraphOrDefault(i + 1); + if (next != null && next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds > 100) + { + gridDataCount++; + } + } + + var buffer = new byte[] { 0x2B, 0x27, 0xF, 0x3C, 0x43, 0x61, 0x70, 0x4D, 0x61, 0x6B, 0x65, 0x72, 0x20, 0x50, 0x6C, 0x75, 0x73, 0x3E, 0x3, 0x2, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x21, 0, 0, 0, 0, 0, 0, 0, 0x7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x5, 0, 0, 0, 0x5, 0, 0, 0, 0x5, 0, 0, 0, 0x5, 0, 0, 0, 0x1, 0, 0, 0, 0x5E, 0x1, 0, 0, 0x1E, 0, 0, 0, 0x20, 0, 0, 0, 0x2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x7D, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x42, 0, 0, 0, 0x30, 0, 0, 0, 0x42, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0x20, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x2, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0x10, 0x10, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0xFF, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0x40, 0x40, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x1, 0, 0, 0, 0xFF, 0, 0, 0, 0x1, 0, 0, 0, 0x2, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0x1, 0, 0x9, 0, 0x43, 0x47, 0x72, 0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x3, 0x2, 0x25, 0, 0, 0, 0, 0, 0, 0, 0x9, 0x4C, 0x61, 0x6E, 0x67, 0x75, 0x61, 0x67, 0x65, 0x31, 0x1, 0, 0xFF, 0, 0x1, 0, 0, 0, 0, 0, 0, 0x80, 0xBF, 0, 0, 0, 0xC0, 0x2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x9, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x2E, 0x63, 0x61, 0x70, 0x9, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x2E, 0x63, 0x61, 0x70, 0x1F, 0x44, 0x3A, 0x5C, 0x43, 0x70, 0x63, 0x57, 0x69, 0x6E, 0x5C, 0x37, 0x30, 0x30, 0x5C, 0x53, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x73, 0x5C, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x2E, 0x74, 0x78, 0x74, 0x3C, 0, 0, 0, 0x5, 0x41, 0x72, 0x69, 0x61, 0x6C, 0, 0, 0, 0x40, 0xE0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3C, 0, 0, 0, 0xB, 0x43, 0x6F, 0x75, 0x72, 0x69, 0x65, 0x72, 0x20, 0x4E, 0x65, 0x77, 0, 0, 0, 0x40, 0xB4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0xF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFB, 0xFF, 0x4, 0, 0xC, 0, 0, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0x1E, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0x1, 0, 0, 0xF0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0, 0, 0, 0, 0, 0, 0, 0x14, 0, 0, 0, 0xA, 0, 0, 0, 0x14, 0, 0, 0, 0xA, 0, 0, 0, 0, 0, 0, 0x9, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x2E, 0x63, 0x61, 0x70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xB, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0, 0, 0, 0 }; + buffer[1400] = (byte)(gridDataCount % 256); // paragraphs - low byte + buffer[1401] = (byte)(gridDataCount / 256); // paragraphs - high byte + + using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) + { + fs.Write(buffer, 0, buffer.Length); + + p = null; + for (int i = 0; i < subtitle.Paragraphs.Count; i++) + { + p = subtitle.Paragraphs[i]; + Paragraph next = subtitle.GetParagraphOrDefault(i + 1); + + WriteTime(fs, p.StartTime); + + buffer = new byte[] { + // styles 00 00 80 BF 00 00 00 C0 02 00 01 00 + 0, + 0, + 0x80, //horizontal align, 0x80BF= center, 0x0000=left, 0x00c0=right + 0xBF, + 0, + 0, + 0, + 0xC0, // vertical Position: C0=bottom, 0=top + 2, //justification, 1=left, 2=center + 0, + 1, //1=normal font, 3=italic + 0 + }; + + string text = p.Text; + if (text.StartsWith("{\\a6}", StringComparison.Ordinal)) + { + text = p.Text.Remove(0, 5); + buffer[7] = 0; // align top + } + else if (text.StartsWith("{\\a1}", StringComparison.Ordinal)) + { + text = p.Text.Remove(0, 5); + buffer[2] = 0; // align left + buffer[3] = 0; // align left + } + else if (text.StartsWith("{\\a3}", StringComparison.Ordinal)) + { + text = p.Text.Remove(0, 5); + buffer[2] = 0; // align right + buffer[3] = 0xc0; // align right + } + else if (text.StartsWith("{\\a5}", StringComparison.Ordinal)) + { + text = p.Text.Remove(0, 5); + buffer[7] = 0; // align top + buffer[2] = 0; // align left + buffer[3] = 0; // align left + } + else if (text.StartsWith("{\\a7}", StringComparison.Ordinal)) + { + text = p.Text.Remove(0, 5); + buffer[7] = 0; // align top + buffer[2] = 0; // align right + buffer[3] = 0xc0; // align right + } + + if (text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal)) + { + buffer[10] = 3; + } + + fs.Write(buffer, 0, buffer.Length); + + text = HtmlUtil.RemoveHtmlTags(text); + if (text.Length > 118) + { + text = text.Substring(0, 118); + } + + fs.WriteByte((byte)(text.Length)); + buffer = Encoding.GetEncoding(1252).GetBytes(text); + fs.Write(buffer, 0, buffer.Length); + + for (int j = 0; j < 74; j++) + { + fs.WriteByte(0); + } + + if (next != null && next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds > 100) + { + // write empty end + WriteTime(fs, p.EndTime); + buffer = new byte[] { 0, 0, 0, 0xC0, 0, 0, 0, 0, 0x01, 0, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + fs.Write(buffer, 0, buffer.Length); + } + } + if (p != null) + { + WriteTime(fs, p.EndTime); + buffer = new byte[] { 0, 0, 0x80, 0xBF, 0, 0, 0, 0xC0, 0x02, 0, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0x40, 0x40, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0x80, 0x80, 0x80, 0, 0x01, 0, 0, 0, 0xFF, 0, 0, 0, 0x01, 0, 0, 0, 0x02, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x48, 0, 0, 0, 0x30, 0, 0, 0, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + fs.Write(buffer, 0, buffer.Length); + } + } + } + + private static void WriteTime(FileStream fs, TimeCode timeCode) + { + fs.WriteByte(0xb); + byte[] buffer = Encoding.ASCII.GetBytes(timeCode.ToHHMMSSFF()); + fs.Write(buffer, 0, buffer.Length); + } + + public override bool IsMine(List lines, string fileName) + { + if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) + { + var fi = new FileInfo(fileName); + if (fi.Length >= 640 && fi.Length < 1024000) // not too small or too big + { + if (fileName.EndsWith(".cap", StringComparison.OrdinalIgnoreCase)) + { + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + if (buffer[0] == 0x2b) // "+" + { + return true; + } + } + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + return "Not supported!"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + subtitle.Paragraphs.Clear(); + subtitle.Header = null; + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + + int i = 128; + Paragraph last = null; + while (i < buffer.Length - 20) + { + if (buffer[i] == 0x0b) + { + string timeCode = Encoding.ASCII.GetString(buffer, i + 1, 11); + if (timeCode != "00:00:00:00" && RegexTimeCodes.IsMatch(timeCode)) + { + var p = new Paragraph { StartTime = DecodeTimeCodeFramesFourParts(timeCode.Split(':')) }; + bool italic = buffer[i + 22] == 3; // 3=italic, 1=normal + int textStart = i + 25; // text starts 25 chars after time code + int textLength = 0; + while (textStart + textLength < buffer.Length && buffer[textStart + textLength] != 0) + { + textLength++; + } + if (textLength > 0) + { + p.Text = Encoding.GetEncoding(1252).GetString(buffer, textStart, textLength); + int rtIndex = p.Text.IndexOf("{\\rtf1", StringComparison.Ordinal); + if (rtIndex >= 0 && rtIndex < 10) + { + p.Text = p.Text.Substring(rtIndex).FromRtf(); + } + else if (italic) + { + p.Text = "" + p.Text + ""; + } + } + else + { + p.Text = string.Empty; + } + last = p; + subtitle.Paragraphs.Add(p); + } + } + i++; + } + if (last != null) + { + last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(last.Text); + } + + for (i = 0; i < subtitle.Paragraphs.Count - 1; i++) + { + subtitle.Paragraphs[i].EndTime.TotalMilliseconds = subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds; + } + for (i = subtitle.Paragraphs.Count - 1; i >= 0; i--) + { + if (string.IsNullOrEmpty(subtitle.Paragraphs[i].Text)) + { + subtitle.Paragraphs.RemoveAt(i); + } + } + + var deletes = new List(); + for (i = 0; i < subtitle.Paragraphs.Count - 1; i++) + { + if (subtitle.Paragraphs[i].StartTime.TotalMilliseconds == subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds) + { + subtitle.Paragraphs[i].Text += Environment.NewLine + subtitle.Paragraphs[i + 1].Text; + subtitle.Paragraphs[i].EndTime = subtitle.Paragraphs[i + 1].EndTime; + deletes.Add(i + 1); + } + } + subtitle.RemoveParagraphsByIndices(deletes); + + for (i = 0; i < subtitle.Paragraphs.Count - 1; i++) + { + if (subtitle.Paragraphs[i].StartTime.TotalMilliseconds == subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds) + { + } + else if (subtitle.Paragraphs[i].EndTime.TotalMilliseconds == subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds) + { + subtitle.Paragraphs[i].EndTime.TotalMilliseconds = subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds - 1; + } + } + subtitle.Renumber(); + + // adjust all times + if (buffer.Length > 1364) + { + try + { + string adjust = Encoding.GetEncoding(1252).GetString(buffer, 1354, 11); // 00:59:59:28 + TimeCode tc = DecodeTimeCodeFramesFourParts(adjust.Split(':')); + if (tc.TotalMilliseconds > 0) + { + subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-tc.TotalMilliseconds)); + } + } + catch + { + // ignored + } + } + } + + } +} diff --git a/libse/SubtitleFormats/Cappella.cs b/src/libse/SubtitleFormats/Cappella.cs similarity index 100% rename from libse/SubtitleFormats/Cappella.cs rename to src/libse/SubtitleFormats/Cappella.cs diff --git a/libse/SubtitleFormats/CaptionAssistant.cs b/src/libse/SubtitleFormats/CaptionAssistant.cs similarity index 97% rename from libse/SubtitleFormats/CaptionAssistant.cs rename to src/libse/SubtitleFormats/CaptionAssistant.cs index ad33004a1..47dc9c78a 100644 --- a/libse/SubtitleFormats/CaptionAssistant.cs +++ b/src/libse/SubtitleFormats/CaptionAssistant.cs @@ -1,156 +1,156 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class CaptionAssistant : SubtitleFormat - { - public override string Extension => ".cac"; - - public override string Name => "Caption Assistant"; - - private static string ToTimeCode(TimeCode time) - { - return time.ToHHMMSSFF(); - } - - private static TimeCode DecodeTimeCode(string s) - { - var parts = s.Split(new[] { ':', ';' }, StringSplitOptions.RemoveEmptyEntries); - var hour = int.Parse(parts[0]); - var minutes = int.Parse(parts[1]); - var seconds = int.Parse(parts[2]); - var frames = int.Parse(parts[3]); - - int milliseconds = (int)Math.Round(((TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate) * frames)); - if (milliseconds > 999) - { - milliseconds = 999; - } - - return new TimeCode(hour, minutes, seconds, milliseconds); - } - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - xml.XmlResolver = null; - var cd = xml.DocumentElement.SelectSingleNode("CaptionData"); - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("CaptionDetail"); - - XmlAttribute start = xml.CreateAttribute("PositionIn"); - start.InnerText = ToTimeCode(p.StartTime); - paragraph.Attributes.Append(start); - - XmlAttribute end = xml.CreateAttribute("PositionOut"); - end.InnerText = ToTimeCode(p.EndTime); - paragraph.Attributes.Append(end); - - XmlAttribute text = xml.CreateAttribute("CaptionText"); - text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text, true); - paragraph.Attributes.Append(text); - - XmlAttribute align = xml.CreateAttribute("Align"); - if (p.Text.StartsWith("{\\an1}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an7}", StringComparison.Ordinal)) - { - align.InnerText = "Left"; - } - else if (p.Text.StartsWith("{\\an3}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an6}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an9}", StringComparison.Ordinal)) - { - align.InnerText = "Right"; - } - else - { - align.InnerText = "Center"; - } - - paragraph.Attributes.Append(align); - - XmlAttribute captionType = xml.CreateAttribute("CaptionType"); - captionType.InnerText = "608CC1"; - paragraph.Attributes.Append(captionType); - - cd.AppendChild(paragraph); - } - - return ToUtf8XmlString(xml); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - - string allText = sb.ToString(); - if (!allText.Contains("") || !allText.Contains("")) - { - return; - } - - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(allText); - } - catch (Exception exception) - { - System.Diagnostics.Debug.WriteLine(exception.Message); - _errorCount = 1; - return; - } - - if (xml.DocumentElement == null) - { - _errorCount = 1; - return; - } - - foreach (XmlNode node in xml.DocumentElement.SelectNodes("CaptionData/CaptionDetail")) - { - try - { - if (node.Attributes != null) - { - string text = node.Attributes.GetNamedItem("CaptionText").InnerText.Trim(); - - if (node.Attributes.GetNamedItem("Align") != null) - { - string align = node.Attributes.GetNamedItem("Align").InnerText.Trim(); - if (align.Equals("left", StringComparison.OrdinalIgnoreCase)) - { - text = "{\\an1}" + text; - } - else if (align.Equals("right", StringComparison.OrdinalIgnoreCase)) - { - text = "{\\an3}" + text; - } - } - - string start = node.Attributes.GetNamedItem("PositionIn").InnerText; - string end = node.Attributes.GetNamedItem("PositionOut").InnerText; - subtitle.Paragraphs.Add(new Paragraph(DecodeTimeCode(start), DecodeTimeCode(end), text)); - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - } - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class CaptionAssistant : SubtitleFormat + { + public override string Extension => ".cac"; + + public override string Name => "Caption Assistant"; + + private static string ToTimeCode(TimeCode time) + { + return time.ToHHMMSSFF(); + } + + private static TimeCode DecodeTimeCode(string s) + { + var parts = s.Split(new[] { ':', ';' }, StringSplitOptions.RemoveEmptyEntries); + var hour = int.Parse(parts[0]); + var minutes = int.Parse(parts[1]); + var seconds = int.Parse(parts[2]); + var frames = int.Parse(parts[3]); + + int milliseconds = (int)Math.Round(((TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate) * frames)); + if (milliseconds > 999) + { + milliseconds = 999; + } + + return new TimeCode(hour, minutes, seconds, milliseconds); + } + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + xml.XmlResolver = null; + var cd = xml.DocumentElement.SelectSingleNode("CaptionData"); + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("CaptionDetail"); + + XmlAttribute start = xml.CreateAttribute("PositionIn"); + start.InnerText = ToTimeCode(p.StartTime); + paragraph.Attributes.Append(start); + + XmlAttribute end = xml.CreateAttribute("PositionOut"); + end.InnerText = ToTimeCode(p.EndTime); + paragraph.Attributes.Append(end); + + XmlAttribute text = xml.CreateAttribute("CaptionText"); + text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text, true); + paragraph.Attributes.Append(text); + + XmlAttribute align = xml.CreateAttribute("Align"); + if (p.Text.StartsWith("{\\an1}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an7}", StringComparison.Ordinal)) + { + align.InnerText = "Left"; + } + else if (p.Text.StartsWith("{\\an3}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an6}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an9}", StringComparison.Ordinal)) + { + align.InnerText = "Right"; + } + else + { + align.InnerText = "Center"; + } + + paragraph.Attributes.Append(align); + + XmlAttribute captionType = xml.CreateAttribute("CaptionType"); + captionType.InnerText = "608CC1"; + paragraph.Attributes.Append(captionType); + + cd.AppendChild(paragraph); + } + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + + string allText = sb.ToString(); + if (!allText.Contains("") || !allText.Contains("")) + { + return; + } + + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(allText); + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception.Message); + _errorCount = 1; + return; + } + + if (xml.DocumentElement == null) + { + _errorCount = 1; + return; + } + + foreach (XmlNode node in xml.DocumentElement.SelectNodes("CaptionData/CaptionDetail")) + { + try + { + if (node.Attributes != null) + { + string text = node.Attributes.GetNamedItem("CaptionText").InnerText.Trim(); + + if (node.Attributes.GetNamedItem("Align") != null) + { + string align = node.Attributes.GetNamedItem("Align").InnerText.Trim(); + if (align.Equals("left", StringComparison.OrdinalIgnoreCase)) + { + text = "{\\an1}" + text; + } + else if (align.Equals("right", StringComparison.OrdinalIgnoreCase)) + { + text = "{\\an3}" + text; + } + } + + string start = node.Attributes.GetNamedItem("PositionIn").InnerText; + string end = node.Attributes.GetNamedItem("PositionOut").InnerText; + subtitle.Paragraphs.Add(new Paragraph(DecodeTimeCode(start), DecodeTimeCode(end), text)); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/Captionate.cs b/src/libse/SubtitleFormats/Captionate.cs similarity index 97% rename from libse/SubtitleFormats/Captionate.cs rename to src/libse/SubtitleFormats/Captionate.cs index 319fece29..970e69ba3 100644 --- a/libse/SubtitleFormats/Captionate.cs +++ b/src/libse/SubtitleFormats/Captionate.cs @@ -1,165 +1,165 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Captionate : SubtitleFormat - { - public override string Extension => ".xml"; - - public const string NameOfFormat = "Captionate"; - - public override string Name => NameOfFormat; - - public override string ToText(Subtitle subtitle, string title) - { - const string xmlStructure = @" -hh:mm:ss:ff/30 -namesareprefixed - - - -Default - - -140 - - - - - - -"; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - Paragraph last = null; - foreach (Paragraph p in subtitle.Paragraphs) - { - if (last != null) - { - if (last.EndTime.TotalMilliseconds + 500 < p.StartTime.TotalMilliseconds) - { - var blank = new Paragraph { StartTime = { TotalMilliseconds = last.EndTime.TotalMilliseconds } }; - AddParagraph(xml, blank); - } - } - - AddParagraph(xml, p); - last = p; - } - - return ToUtf8XmlString(xml, true); - } - - private static void AddParagraph(XmlDocument xml, Paragraph p) - { - XmlNode paragraph = xml.CreateElement("caption"); - - XmlAttribute start = xml.CreateAttribute("time"); - start.InnerText = EncodeTime(p.StartTime); - paragraph.Attributes.Append(start); - - if (!string.IsNullOrWhiteSpace(p.Text)) - { - XmlNode tracks = xml.CreateElement("tracks"); - paragraph.AppendChild(tracks); - - XmlNode track0 = xml.CreateElement("track0"); - track0.InnerText = HtmlUtil.RemoveHtmlTags(p.Text, true); - track0.InnerXml = track0.InnerXml.Replace(Environment.NewLine, "
"); - tracks.AppendChild(track0); - } - xml.DocumentElement.SelectSingleNode("captions").AppendChild(paragraph); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - string xmlString; - - if (lines == null && fileName != null) - { - xmlString = File.ReadAllText(fileName); - } - else if (lines != null) - { - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - xmlString = sb.ToString(); - } - else - { - return; - } - - if (!xmlString.Contains("") || !xmlString.Contains("")) - { - return; - } - - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(xmlString); - } - catch - { - _errorCount = 1; - return; - } - - Paragraph p = null; - foreach (XmlNode node in xml.DocumentElement.SelectNodes("captions/caption")) - { - try - { - if (node.Attributes["time"] != null) - { - string start = node.Attributes["time"].InnerText; - double startMilliseconds = DecodeTimeToMilliseconds(start); - if (p != null) - { - p.EndTime.TotalMilliseconds = startMilliseconds - 1; - } - - if (node.SelectSingleNode("tracks/track0") != null) - { - string text = node.SelectSingleNode("tracks/track0").InnerText; - text = HtmlUtil.RemoveHtmlTags(text); - text = text.Replace("
", Environment.NewLine).Replace("
", Environment.NewLine).Replace("
", Environment.NewLine); - p = new Paragraph(text, startMilliseconds, startMilliseconds + 3000); - if (!string.IsNullOrWhiteSpace(text)) - { - subtitle.Paragraphs.Add(p); - } - } - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - } - subtitle.Renumber(); - } - - private static double DecodeTimeToMilliseconds(string time) - { - string[] parts = time.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); - return new TimeSpan(0, int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), (int)(int.Parse(parts[3]) * 10.0)).TotalMilliseconds; - } - - private static string EncodeTime(TimeCode time) - { - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{time.Milliseconds / 10.0:00}"; - } - - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Captionate : SubtitleFormat + { + public override string Extension => ".xml"; + + public const string NameOfFormat = "Captionate"; + + public override string Name => NameOfFormat; + + public override string ToText(Subtitle subtitle, string title) + { + const string xmlStructure = @" +hh:mm:ss:ff/30 +namesareprefixed + + + +Default + + +140 + + + + + + +"; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + Paragraph last = null; + foreach (Paragraph p in subtitle.Paragraphs) + { + if (last != null) + { + if (last.EndTime.TotalMilliseconds + 500 < p.StartTime.TotalMilliseconds) + { + var blank = new Paragraph { StartTime = { TotalMilliseconds = last.EndTime.TotalMilliseconds } }; + AddParagraph(xml, blank); + } + } + + AddParagraph(xml, p); + last = p; + } + + return ToUtf8XmlString(xml, true); + } + + private static void AddParagraph(XmlDocument xml, Paragraph p) + { + XmlNode paragraph = xml.CreateElement("caption"); + + XmlAttribute start = xml.CreateAttribute("time"); + start.InnerText = EncodeTime(p.StartTime); + paragraph.Attributes.Append(start); + + if (!string.IsNullOrWhiteSpace(p.Text)) + { + XmlNode tracks = xml.CreateElement("tracks"); + paragraph.AppendChild(tracks); + + XmlNode track0 = xml.CreateElement("track0"); + track0.InnerText = HtmlUtil.RemoveHtmlTags(p.Text, true); + track0.InnerXml = track0.InnerXml.Replace(Environment.NewLine, "
"); + tracks.AppendChild(track0); + } + xml.DocumentElement.SelectSingleNode("captions").AppendChild(paragraph); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + string xmlString; + + if (lines == null && fileName != null) + { + xmlString = File.ReadAllText(fileName); + } + else if (lines != null) + { + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + xmlString = sb.ToString(); + } + else + { + return; + } + + if (!xmlString.Contains("") || !xmlString.Contains("")) + { + return; + } + + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(xmlString); + } + catch + { + _errorCount = 1; + return; + } + + Paragraph p = null; + foreach (XmlNode node in xml.DocumentElement.SelectNodes("captions/caption")) + { + try + { + if (node.Attributes["time"] != null) + { + string start = node.Attributes["time"].InnerText; + double startMilliseconds = DecodeTimeToMilliseconds(start); + if (p != null) + { + p.EndTime.TotalMilliseconds = startMilliseconds - 1; + } + + if (node.SelectSingleNode("tracks/track0") != null) + { + string text = node.SelectSingleNode("tracks/track0").InnerText; + text = HtmlUtil.RemoveHtmlTags(text); + text = text.Replace("
", Environment.NewLine).Replace("
", Environment.NewLine).Replace("
", Environment.NewLine); + p = new Paragraph(text, startMilliseconds, startMilliseconds + 3000); + if (!string.IsNullOrWhiteSpace(text)) + { + subtitle.Paragraphs.Add(p); + } + } + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + subtitle.Renumber(); + } + + private static double DecodeTimeToMilliseconds(string time) + { + string[] parts = time.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); + return new TimeSpan(0, int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), (int)(int.Parse(parts[3]) * 10.0)).TotalMilliseconds; + } + + private static string EncodeTime(TimeCode time) + { + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{time.Milliseconds / 10.0:00}"; + } + + } +} diff --git a/libse/SubtitleFormats/CaptionateMs.cs b/src/libse/SubtitleFormats/CaptionateMs.cs similarity index 97% rename from libse/SubtitleFormats/CaptionateMs.cs rename to src/libse/SubtitleFormats/CaptionateMs.cs index a57982704..300978750 100644 --- a/libse/SubtitleFormats/CaptionateMs.cs +++ b/src/libse/SubtitleFormats/CaptionateMs.cs @@ -1,145 +1,145 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class CaptionateMs : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "Captionate MS"; - - public override string ToText(Subtitle subtitle, string title) - { - const string xmlStructure = @" -ms -namesareprefixed - - - -Default - - -140 - - - - - - -"; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - Paragraph last = null; - foreach (Paragraph p in subtitle.Paragraphs) - { - if (last != null) - { - if (last.EndTime.TotalMilliseconds + 500 < p.StartTime.TotalMilliseconds) - { - var blank = new Paragraph { StartTime = { TotalMilliseconds = last.EndTime.TotalMilliseconds } }; - AddParagraph(xml, blank); - } - } - - AddParagraph(xml, p); - last = p; - } - - return ToUtf8XmlString(xml, true); - } - - private static void AddParagraph(XmlDocument xml, Paragraph p) - { - XmlNode paragraph = xml.CreateElement("caption"); - - XmlAttribute start = xml.CreateAttribute("time"); - start.InnerText = EncodeTime(p.StartTime); - paragraph.Attributes.Append(start); - - if (!string.IsNullOrWhiteSpace(p.Text)) - { - XmlNode tracks = xml.CreateElement("tracks"); - paragraph.AppendChild(tracks); - - XmlNode track0 = xml.CreateElement("track0"); - track0.InnerText = HtmlUtil.RemoveHtmlTags(p.Text, true); - track0.InnerXml = track0.InnerXml.Replace(Environment.NewLine, "
"); - tracks.AppendChild(track0); - } - xml.DocumentElement.SelectSingleNode("captions").AppendChild(paragraph); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - - string xmlString = sb.ToString(); - if (!xmlString.Contains("") || !xmlString.Contains("")) - { - return; - } - - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(xmlString); - } - catch - { - _errorCount = 1; - return; - } - - Paragraph p = null; - foreach (XmlNode node in xml.DocumentElement.SelectNodes("captions/caption")) - { - try - { - if (node.Attributes["time"] != null) - { - string start = node.Attributes["time"].InnerText; - double startMilliseconds = double.Parse(start); - if (p != null) - { - p.EndTime.TotalMilliseconds = startMilliseconds - 1; - } - - if (node.SelectSingleNode("tracks/track0") != null) - { - string text = node.SelectSingleNode("tracks/track0").InnerText; - text = HtmlUtil.RemoveHtmlTags(text); - text = text.Replace("
", Environment.NewLine).Replace("
", Environment.NewLine).Replace("
", Environment.NewLine); - p = new Paragraph(text, startMilliseconds, startMilliseconds + 3000); - if (!string.IsNullOrWhiteSpace(text)) - { - subtitle.Paragraphs.Add(p); - } - } - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - } - subtitle.Renumber(); - } - - private static string EncodeTime(TimeCode time) - { - return time.TotalMilliseconds.ToString(CultureInfo.InvariantCulture); - } - - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class CaptionateMs : SubtitleFormat + { + public override string Extension => ".xml"; + + public override string Name => "Captionate MS"; + + public override string ToText(Subtitle subtitle, string title) + { + const string xmlStructure = @" +ms +namesareprefixed + + + +Default + + +140 + + + + + + +"; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + Paragraph last = null; + foreach (Paragraph p in subtitle.Paragraphs) + { + if (last != null) + { + if (last.EndTime.TotalMilliseconds + 500 < p.StartTime.TotalMilliseconds) + { + var blank = new Paragraph { StartTime = { TotalMilliseconds = last.EndTime.TotalMilliseconds } }; + AddParagraph(xml, blank); + } + } + + AddParagraph(xml, p); + last = p; + } + + return ToUtf8XmlString(xml, true); + } + + private static void AddParagraph(XmlDocument xml, Paragraph p) + { + XmlNode paragraph = xml.CreateElement("caption"); + + XmlAttribute start = xml.CreateAttribute("time"); + start.InnerText = EncodeTime(p.StartTime); + paragraph.Attributes.Append(start); + + if (!string.IsNullOrWhiteSpace(p.Text)) + { + XmlNode tracks = xml.CreateElement("tracks"); + paragraph.AppendChild(tracks); + + XmlNode track0 = xml.CreateElement("track0"); + track0.InnerText = HtmlUtil.RemoveHtmlTags(p.Text, true); + track0.InnerXml = track0.InnerXml.Replace(Environment.NewLine, "
"); + tracks.AppendChild(track0); + } + xml.DocumentElement.SelectSingleNode("captions").AppendChild(paragraph); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + + string xmlString = sb.ToString(); + if (!xmlString.Contains("") || !xmlString.Contains("")) + { + return; + } + + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(xmlString); + } + catch + { + _errorCount = 1; + return; + } + + Paragraph p = null; + foreach (XmlNode node in xml.DocumentElement.SelectNodes("captions/caption")) + { + try + { + if (node.Attributes["time"] != null) + { + string start = node.Attributes["time"].InnerText; + double startMilliseconds = double.Parse(start); + if (p != null) + { + p.EndTime.TotalMilliseconds = startMilliseconds - 1; + } + + if (node.SelectSingleNode("tracks/track0") != null) + { + string text = node.SelectSingleNode("tracks/track0").InnerText; + text = HtmlUtil.RemoveHtmlTags(text); + text = text.Replace("
", Environment.NewLine).Replace("
", Environment.NewLine).Replace("
", Environment.NewLine); + p = new Paragraph(text, startMilliseconds, startMilliseconds + 3000); + if (!string.IsNullOrWhiteSpace(text)) + { + subtitle.Paragraphs.Add(p); + } + } + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + subtitle.Renumber(); + } + + private static string EncodeTime(TimeCode time) + { + return time.TotalMilliseconds.ToString(CultureInfo.InvariantCulture); + } + + } +} diff --git a/libse/SubtitleFormats/CaptionsInc.cs b/src/libse/SubtitleFormats/CaptionsInc.cs similarity index 97% rename from libse/SubtitleFormats/CaptionsInc.cs rename to src/libse/SubtitleFormats/CaptionsInc.cs index 2a5ec45d7..c852662ff 100644 --- a/libse/SubtitleFormats/CaptionsInc.cs +++ b/src/libse/SubtitleFormats/CaptionsInc.cs @@ -1,264 +1,264 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class CaptionsInc : SubtitleFormat - { - public override string Extension => ".cin"; - - public override string Name => "Caption Inc"; - - public static void Save(string fileName, Subtitle subtitle) - { - using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) - { - string name = Path.GetFileNameWithoutExtension(fileName); - byte[] buffer = Encoding.ASCII.GetBytes(name); - for (int i = 0; i < buffer.Length && i < 8; i++) - { - fs.WriteByte(buffer[i]); - } - - while (fs.Length < 8) - { - fs.WriteByte(0x20); - } - - WriteTime(fs, subtitle.Paragraphs[0].StartTime, false); // first start time - WriteTime(fs, subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime, false); // last end time - - buffer = Encoding.ASCII.GetBytes("Generic Unknown Unknown \"\" Unknown Unknown Unknown".PadRight(230, ' ')); - fs.Write(buffer, 0, buffer.Length); - - // paragraphs - foreach (Paragraph p in subtitle.Paragraphs) - { - buffer = new byte[] { 0x0D, 0x0A, 0xFE }; // header - fs.Write(buffer, 0, buffer.Length); - - // styles - var text = new List { 0x14, 0x20, 0x14, 0x2E, 0x14, 0x54, 0x17 }; - int noOfLines = Utilities.GetNumberOfLines(p.Text); - text.Add(noOfLines == 1 ? (byte)0x22 : (byte)0x21); - - var lines = p.Text.Split(Utilities.NewLineChars, StringSplitOptions.None); - foreach (string line in lines) - { - foreach (char ch in line) - { - text.Add(Encoding.GetEncoding(1252).GetBytes(new[] { ch })[0]); - } - text.Add(0x14); - text.Add(0x74); - } - - // codes+text length - buffer = Encoding.ASCII.GetBytes($"{text.Count:000}"); - fs.Write(buffer, 0, buffer.Length); - - WriteTime(fs, p.StartTime, true); - - // write codes + text - foreach (byte b in text) - { - fs.WriteByte(b); - } - - buffer = new byte[] { 0x14, 0x2F, 0x0D, 0x0A, 0xFE, 0x30, 0x30, 0x32, 0x30 }; - fs.Write(buffer, 0, buffer.Length); - WriteTime(fs, p.EndTime, true); - } - } - } - - private static void WriteTime(FileStream fs, TimeCode timeCode, bool addEndBytes) - { - var time = timeCode.ToHHMMSSFF(); - var buffer = Encoding.ASCII.GetBytes(time); - fs.Write(buffer, 0, buffer.Length); - if (addEndBytes) - { - fs.WriteByte(0xd); - fs.WriteByte(0xa); - } - } - - public override bool IsMine(List lines, string fileName) - { - if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) - { - if (!fileName.EndsWith(".cin", StringComparison.OrdinalIgnoreCase)) - { - return false; - } - - return base.IsMine(lines, fileName); - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - return "Not supported!"; - } - - private static TimeCode DecodeTimestamp(string timeCode) - { - try - { - return new TimeCode(int.Parse(timeCode.Substring(0, 2)), int.Parse(timeCode.Substring(2, 2)), int.Parse(timeCode.Substring(4, 2)), FramesToMillisecondsMax999(int.Parse(timeCode.Substring(6, 2)))); - } - catch (Exception exception) - { - System.Diagnostics.Debug.WriteLine(exception.Message); - return new TimeCode(); - } - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - subtitle.Paragraphs.Clear(); - subtitle.Header = null; - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - - int i = 256; - Paragraph last = null; - while (i < buffer.Length - 20) - { - var p = new Paragraph(); - - while (buffer[i] != 0xfe && i < buffer.Length - 20) - { - i++; - } - if (buffer[i] == 0xfe) - { - i += 4; - string startTime = Encoding.ASCII.GetString(buffer, i, 8); - i += 8; - if (Utilities.IsInteger(startTime)) - { - p.StartTime = DecodeTimestamp(startTime); - } - } - - bool startFound = false; - bool textEnd = false; - while (!startFound && !textEnd && i < buffer.Length - 20) - { - bool skip = false; - if (buffer[i] == 0x0d) - { - i++; - } - else if (buffer[i] == 0x0a) - { - skip = true; - } - else if (buffer[i] == 0x14 && buffer[i + 1] == 0x2c) // text end - { - textEnd = true; - } - else if (buffer[i] <= 0x20) // text start - { - i++; - } - else - { - startFound = true; - } - - if (!skip) - { - i++; - } - } - i++; - - if (!textEnd) - { - i -= 2; - var sb = new StringBuilder(); - while (!textEnd && i < buffer.Length - 20) - { - if (buffer[i] == 0x14 && buffer[i + 1] == 0x2c) // text end - { - textEnd = true; - } - else if (buffer[i] == 0xd && buffer[i + 1] == 0xa) // text end - { - textEnd = true; - } - else if (buffer[i] <= 0x17) - { - if (!sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal)) - { - sb.Append(Environment.NewLine); - } - - i++; - } - else - { - sb.Append(Encoding.GetEncoding(1252).GetString(buffer, i, 1)); - } - - i++; - } - i++; - if (sb.Length > 0) - { - string text = sb.ToString().Trim(); - p.Text = text; - subtitle.Paragraphs.Add(p); - last = p; - } - } - - if (buffer[i] == 0xFE) - { - string endTime = Encoding.ASCII.GetString(buffer, i + 4, 8); - if (Utilities.IsInteger(endTime)) - { - p.EndTime = DecodeTimestamp(endTime); - } - while (i < buffer.Length && buffer[i] != 0xa) - { - i++; - } - - i++; - } - else - { - while (i < buffer.Length && buffer[i] != 0xa) - { - i++; - } - - i++; - - if (buffer[i] == 0xfe) - { - string endTime = Encoding.ASCII.GetString(buffer, i + 4, 8); - if (Utilities.IsInteger(endTime)) - { - p.EndTime = DecodeTimestamp(endTime); - } - } - } - } - if (last != null && last.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) - { - last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(last.Text); - } - - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class CaptionsInc : SubtitleFormat + { + public override string Extension => ".cin"; + + public override string Name => "Caption Inc"; + + public static void Save(string fileName, Subtitle subtitle) + { + using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) + { + string name = Path.GetFileNameWithoutExtension(fileName); + byte[] buffer = Encoding.ASCII.GetBytes(name); + for (int i = 0; i < buffer.Length && i < 8; i++) + { + fs.WriteByte(buffer[i]); + } + + while (fs.Length < 8) + { + fs.WriteByte(0x20); + } + + WriteTime(fs, subtitle.Paragraphs[0].StartTime, false); // first start time + WriteTime(fs, subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime, false); // last end time + + buffer = Encoding.ASCII.GetBytes("Generic Unknown Unknown \"\" Unknown Unknown Unknown".PadRight(230, ' ')); + fs.Write(buffer, 0, buffer.Length); + + // paragraphs + foreach (Paragraph p in subtitle.Paragraphs) + { + buffer = new byte[] { 0x0D, 0x0A, 0xFE }; // header + fs.Write(buffer, 0, buffer.Length); + + // styles + var text = new List { 0x14, 0x20, 0x14, 0x2E, 0x14, 0x54, 0x17 }; + int noOfLines = Utilities.GetNumberOfLines(p.Text); + text.Add(noOfLines == 1 ? (byte)0x22 : (byte)0x21); + + var lines = p.Text.Split(Utilities.NewLineChars, StringSplitOptions.None); + foreach (string line in lines) + { + foreach (char ch in line) + { + text.Add(Encoding.GetEncoding(1252).GetBytes(new[] { ch })[0]); + } + text.Add(0x14); + text.Add(0x74); + } + + // codes+text length + buffer = Encoding.ASCII.GetBytes($"{text.Count:000}"); + fs.Write(buffer, 0, buffer.Length); + + WriteTime(fs, p.StartTime, true); + + // write codes + text + foreach (byte b in text) + { + fs.WriteByte(b); + } + + buffer = new byte[] { 0x14, 0x2F, 0x0D, 0x0A, 0xFE, 0x30, 0x30, 0x32, 0x30 }; + fs.Write(buffer, 0, buffer.Length); + WriteTime(fs, p.EndTime, true); + } + } + } + + private static void WriteTime(FileStream fs, TimeCode timeCode, bool addEndBytes) + { + var time = timeCode.ToHHMMSSFF(); + var buffer = Encoding.ASCII.GetBytes(time); + fs.Write(buffer, 0, buffer.Length); + if (addEndBytes) + { + fs.WriteByte(0xd); + fs.WriteByte(0xa); + } + } + + public override bool IsMine(List lines, string fileName) + { + if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) + { + if (!fileName.EndsWith(".cin", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + return base.IsMine(lines, fileName); + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + return "Not supported!"; + } + + private static TimeCode DecodeTimestamp(string timeCode) + { + try + { + return new TimeCode(int.Parse(timeCode.Substring(0, 2)), int.Parse(timeCode.Substring(2, 2)), int.Parse(timeCode.Substring(4, 2)), FramesToMillisecondsMax999(int.Parse(timeCode.Substring(6, 2)))); + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception.Message); + return new TimeCode(); + } + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + subtitle.Paragraphs.Clear(); + subtitle.Header = null; + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + + int i = 256; + Paragraph last = null; + while (i < buffer.Length - 20) + { + var p = new Paragraph(); + + while (buffer[i] != 0xfe && i < buffer.Length - 20) + { + i++; + } + if (buffer[i] == 0xfe) + { + i += 4; + string startTime = Encoding.ASCII.GetString(buffer, i, 8); + i += 8; + if (Utilities.IsInteger(startTime)) + { + p.StartTime = DecodeTimestamp(startTime); + } + } + + bool startFound = false; + bool textEnd = false; + while (!startFound && !textEnd && i < buffer.Length - 20) + { + bool skip = false; + if (buffer[i] == 0x0d) + { + i++; + } + else if (buffer[i] == 0x0a) + { + skip = true; + } + else if (buffer[i] == 0x14 && buffer[i + 1] == 0x2c) // text end + { + textEnd = true; + } + else if (buffer[i] <= 0x20) // text start + { + i++; + } + else + { + startFound = true; + } + + if (!skip) + { + i++; + } + } + i++; + + if (!textEnd) + { + i -= 2; + var sb = new StringBuilder(); + while (!textEnd && i < buffer.Length - 20) + { + if (buffer[i] == 0x14 && buffer[i + 1] == 0x2c) // text end + { + textEnd = true; + } + else if (buffer[i] == 0xd && buffer[i + 1] == 0xa) // text end + { + textEnd = true; + } + else if (buffer[i] <= 0x17) + { + if (!sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal)) + { + sb.Append(Environment.NewLine); + } + + i++; + } + else + { + sb.Append(Encoding.GetEncoding(1252).GetString(buffer, i, 1)); + } + + i++; + } + i++; + if (sb.Length > 0) + { + string text = sb.ToString().Trim(); + p.Text = text; + subtitle.Paragraphs.Add(p); + last = p; + } + } + + if (buffer[i] == 0xFE) + { + string endTime = Encoding.ASCII.GetString(buffer, i + 4, 8); + if (Utilities.IsInteger(endTime)) + { + p.EndTime = DecodeTimestamp(endTime); + } + while (i < buffer.Length && buffer[i] != 0xa) + { + i++; + } + + i++; + } + else + { + while (i < buffer.Length && buffer[i] != 0xa) + { + i++; + } + + i++; + + if (buffer[i] == 0xfe) + { + string endTime = Encoding.ASCII.GetString(buffer, i + 4, 8); + if (Utilities.IsInteger(endTime)) + { + p.EndTime = DecodeTimestamp(endTime); + } + } + } + } + if (last != null && last.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) + { + last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(last.Text); + } + + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/CaraokeXml.cs b/src/libse/SubtitleFormats/CaraokeXml.cs similarity index 97% rename from libse/SubtitleFormats/CaraokeXml.cs rename to src/libse/SubtitleFormats/CaraokeXml.cs index 3ecc28bce..714799d71 100644 --- a/libse/SubtitleFormats/CaraokeXml.cs +++ b/src/libse/SubtitleFormats/CaraokeXml.cs @@ -1,96 +1,96 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class CaraokeXml : SubtitleFormat - { - public override string Extension => ".crk"; - - public override string Name => "Caraoke Xml"; - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - var paragraph = xml.DocumentElement.SelectSingleNode("paragraph"); - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode item = xml.CreateElement("item"); - - var start = xml.CreateAttribute("tc1"); - start.InnerText = p.StartTime.TotalMilliseconds.ToString(System.Globalization.CultureInfo.InvariantCulture); - item.Attributes.Append(start); - - var end = xml.CreateAttribute("tc2"); - end.InnerText = p.EndTime.TotalMilliseconds.ToString(System.Globalization.CultureInfo.InvariantCulture); - item.Attributes.Append(end); - - var attr = xml.CreateAttribute("attr"); - attr.InnerText = string.Empty; - item.Attributes.Append(attr); - - item.InnerText = p.Text; - - paragraph.AppendChild(item); - } - - return ToUtf8XmlString(xml); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - - string xmlAsText = sb.ToString(); - - if (!xmlAsText.Contains(" ".crk"; + + public override string Name => "Caraoke Xml"; + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + var paragraph = xml.DocumentElement.SelectSingleNode("paragraph"); + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode item = xml.CreateElement("item"); + + var start = xml.CreateAttribute("tc1"); + start.InnerText = p.StartTime.TotalMilliseconds.ToString(System.Globalization.CultureInfo.InvariantCulture); + item.Attributes.Append(start); + + var end = xml.CreateAttribute("tc2"); + end.InnerText = p.EndTime.TotalMilliseconds.ToString(System.Globalization.CultureInfo.InvariantCulture); + item.Attributes.Append(end); + + var attr = xml.CreateAttribute("attr"); + attr.InnerText = string.Empty; + item.Attributes.Append(attr); + + item.InnerText = p.Text; + + paragraph.AppendChild(item); + } + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + + string xmlAsText = sb.ToString(); + + if (!xmlAsText.Contains(" ArabicDictionary = new Dictionary - { - { 0x58, "م" }, - { 0x41, "ا" }, - { 0x4e, "ص" }, - { 0x42, "ب" }, - { 0x46, "ح" }, - { 0x57, "ل" }, - { 0x47, "خ" }, - { 0x5d, "ي" }, - { 0x4a, "ر" }, - { 0x2c, "،" }, - { 0x59, "ن" }, - { 0x5a, "و" }, - { 0x43, "ت" }, - { 0x1d, "-" }, - { 0x49, "ذ" }, - { 0x45, "ج" }, - { 0x5b, "ه" }, - { 0x56, "ك" }, - { 0x21, "؟" }, - { 0x4c, "س" }, - { 0x52, "ع" }, - { 0x5c, "ة" }, - { 0x5e, "ى" }, - { 0x61, "أ" }, - { 0x48, "د" }, - { 0x4d, "ش" }, - { 0x60, "ء" }, - { 0x68, "ﻷ" }, - { 0x54, "ف" }, - { 0x55, "ق" }, - { 0x22, "!" }, - { 0x67, "ﻻ" }, - { 0x66, "ؤ" }, - { 0x64, "آ" }, - { 0x50, "ط" }, - { 0x6a, "ﻵ" }, - { 0x4f, "ض" }, - { 0x6b, "ﺋ" }, - { 0x44, "ث" }, - { 0x51, "ظ" }, - { 0x53, "غ" }, - { 0x4b, "ز" }, - { 0x23, "\"" }, - { 0x6c, "ـ" }, - }; - - private static readonly List HebrewCodes = new List - { - 0x40, // א - 0x41, // ב - 0x42, // ג - 0x43, // ד - 0x44, // ה - 0x45, // ו - 0x46, // ז - 0x47, // ח - 0x49, // י - 0x4c, // ל - 0x4d, // ם - 0x4e, // מ - 0x4f, // ן - 0x50, // נ - 0x51, // ס - 0x52, // ע - 0x54, // פ - 0x56, // צ - 0x57, // ק - 0x58, // ר - 0x59, // ש - 0x5A, // ת - 0x4b, // כ - 0x4a, // ך - 0x48, // ט - 0x53, // ף - 0x55, // ץ - - 0xB1, // "a" - 0xB2, // "b" - 0xB3, // "c" - 0xB4, // "d" - 0xB5, // "e" - 0xB6, // "f" - 0xB7, // "g" - 0xB8, // "h" - 0xB9, // "i" - 0xBA, // "j" - 0xBB, // "k" - 0xBC, // "l" - 0xBD, // "m" - 0xBE, // "n" - 0xBF, // "o" - 0xC0, // "p" - 0xC1, // "q" - 0xC2, // "r" - 0xC3, // "s" - 0xC4, // "t" - 0xC5, // "u" - 0xC6, // "v" - 0xC7, // "w" - 0xC8, // "x" - 0xC9, // "y" - 0xCA, // "z" - - 0x91, // "A" - 0xDB, // "B" -- weird - 0x93, // "C" - 0xDC, // "D" -- weird - 0x95, // "E" - 0x96, // "F" - 0x97, // "G" - 0xAB, // "H" -- weird - 0x99, // "I" - 0x9A, // "J" - 0x9B, // "K" - 0x9C, // "L" - 0xDD, // "M" - 0xDE, // "N" - 0x9F, // "O" - 0xA0, // "P" - 0xA1, // "Q" - 0xA2, // "R" - 0xA3, // "S" - 0xA4, // "T" - 0xA5, // "U" - 0xA6, // "V" - 0xA7, // "W" - 0xA8, // "X" - weird - 0xA9, // "Y" - 0xAA, // "Z" - weird - }; - - private static readonly List HebrewLetters = new List - { - "א", - "ב", - "ג", - "ד", - "ה", - "ו", - "ז", - "ח", - "י", - "ל", - "ם", - "מ", - "ן", - "נ", - "ס", - "ע", - "פ", - "צ", - "ק", - "ר", - "ש", - "ת", - "כ", - "ך", - "ט", - "ף", - "ץ", - - "a", // 0xB1 - "b", // 0xB2 - "c", // 0xB3 - "d", // 0xB4 - "e", // 0xB5 - "f", // 0xB6 - "g", // 0xB7 - "h", // 0xB8 - "i", // 0xB9 - "j", // 0xBA - "k", // 0xBB - "l", // 0xBC - "m", // 0xBD - "n", // 0xBE - "o", // 0xBF - "p", // 0xC0 - "q", // 0xC1 - "r", // 0xC2 - "s", // 0xC3 - "t", // 0xC4 - "u", // 0xC5 - "v", // 0xC6 - "w", // 0xC7 - "x", // 0xC8 - "y", // 0xC9 - "z", // 0xCA - - "A", // 0x91, - "B", // 0xDB, - "C", // 0x93, - "D", // 0xDC, - "E", // 0x95, - "F", // 0x96, - "G", // 0x97, - "H", // 0xAB, - "I", // 0x99, - "J", // 0x9A, - "K", // 0x9B, - "L", // 0x9C, - "M", // 0xDD, - "N", // 0xDE, - "O", // 0x9F, - "P", // 0xA0, - "Q", // 0xA1, - "R", // 0xA2, - "S", // 0xA3, - "T", // 0xA4, - "U", // 0xA5, - "V", // 0xA6, - "W", // 0xA7, - "X", // 0xA8, - "Y", // 0xA9, - "Z", // 0xAA, - }; - - private static readonly List RussianCodes = new List - { - 0x42, // Б - 0x45, // Е - 0x5A, // З - 0x56, // В - 0x49, // И - 0x4E, // Н - 0x58, // Ы - 0x51, // Я - 0x56, // V - 0x53, // С - 0x72, // р - 0x69, // и - 0x71, // я - 0x6E, // н - 0x74, // т - 0x5C, // Э - 0x77, // ю - 0x46, // Ф - 0x5E, // Ч - 0x44, // Д - 0x62, // б - 0x73, // с - 0x75, // у - 0x64, // д - 0x60, // ж - 0x6A, // й - 0x6C, // л - 0x47, // Г - 0x78, // ы - 0x7A, // з - 0x7E, // ч - 0x6D, // м - 0x67, // г - 0x79, // ь - 0x70, // п - 0x76, // в - 0x55, // У - 0x7D, // щ - 0x66, // ф - 0x7C, // э - 0x7B, // ш - 0x50, // П - 0x52, // П - 0x68, // П - }; - - private static readonly List RussianLetters = new List - { - "Б", - "Е", - "З", - "В", - "И", - "Н", - "Ы", - "Я", - "V", - "С", - "р", - "и", - "я", - "н", - "т", - "Э", - "ю", - "Ф", - "Ч", - "Д", - "б", - "с", - "у", - "д", - "ж", - "й", - "л", - "Г", - "ы", - "з", - "ч", - "м", - "г", - "ь", - "п", - "в", - "У", - "щ", - "ф", - "э", - "ш", - "П", - "Р", - "х", - }; - - public override string Extension => ".890"; - - public const string NameOfFormat = "Cavena 890"; - - public override string Name => NameOfFormat; - - public override bool IsTimeBased => false; - - private int _languageIdLine1 = LanguageIdEnglish; - private int _languageIdLine2 = LanguageIdEnglish; - - public bool Save(string fileName, Subtitle subtitle, bool batchMode = false) - { - using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) - { - return Save(fileName, fs, subtitle, batchMode); - } - } - - public bool Save(string fileName, Stream stream, Subtitle subtitle, bool batchMode) - { - int russianCount = 0; - char[] logoGrams = { '的', '是', '啊', '吧', '好', '吧', '亲', '爱', '的', '早', '上' }; - char[] russianChars = { 'я', 'д', 'й', 'л', 'щ', 'ж', 'ц', 'ф', 'ы' }; - foreach (Paragraph p in subtitle.Paragraphs) - { - if (p.Text.Contains(logoGrams)) - { - _languageIdLine1 = LanguageIdChineseSimplified; - _languageIdLine2 = LanguageIdChineseSimplified; - break; - } - if (p.Text.Contains(russianChars)) - { - russianCount++; - if (russianCount > 10) - { - _languageIdLine1 = LanguageIdRussian; - _languageIdLine2 = LanguageIdRussian; // or 0x09? - break; - } - } - } - - if (Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId > 0) - { - _languageIdLine1 = Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId; - _languageIdLine2 = Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId; - } - else - { - var language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); - switch (language) - { - case "he": - _languageIdLine1 = LanguageIdHebrew; - _languageIdLine2 = LanguageIdHebrew; // or 0x09 - break; - case "ru": - _languageIdLine1 = LanguageIdRussian; - _languageIdLine2 = LanguageIdRussian; // or 0x09? - break; - case "zh": - _languageIdLine1 = LanguageIdChineseSimplified; - _languageIdLine2 = LanguageIdChineseSimplified; - break; - case "da": - _languageIdLine1 = LanguageIdDanish; - _languageIdLine2 = LanguageIdDanish; - break; - } - } - - // prompt??? - //if (Configuration.Settings.SubtitleSettings.CurrentCavena890LanguageIdLine1 >= 0) - // _languageIdLine1 = Configuration.Settings.SubtitleSettings.CurrentCavena890LanguageIdLine1; - //if (Configuration.Settings.SubtitleSettings.CurrentCavena890LanguageIdLine2 >= 0) - // _languageIdLine2 = Configuration.Settings.SubtitleSettings.CurrentCavena890LanguageIdLine2; - - // write file header (some fields are known, some are not...) - - stream.WriteByte(0); // ? - stream.WriteByte(0); // ? - - // tape number (20 bytes) - for (int i = 0; i < 20; i++) - { - stream.WriteByte(0); - } - - // ? - for (int i = 0; i < 18; i++) - { - stream.WriteByte(0); - } - - // translated programme title (28 bytes) - string title = Path.GetFileNameWithoutExtension(fileName) ?? string.Empty; - if (title.Length > 28) - { - title = title.Substring(0, 28); - } - - if (!string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena89Title) && Configuration.Settings.SubtitleSettings.CurrentCavena89Title.Length <= 28) - { - title = Configuration.Settings.SubtitleSettings.CurrentCavena89Title; - } - - var buffer = Encoding.ASCII.GetBytes(title); - stream.Write(buffer, 0, buffer.Length); - for (int i = 0; i < 28 - buffer.Length; i++) - { - stream.WriteByte(0); - } - - // translator (28 bytes) - if (!string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena890Translator) && Configuration.Settings.SubtitleSettings.CurrentCavena890Translator.Length <= 28) - { - buffer = Encoding.ASCII.GetBytes(Configuration.Settings.SubtitleSettings.CurrentCavena890Translator); - stream.Write(buffer, 0, buffer.Length); - for (int i = 0; i < 28 - buffer.Length; i++) - { - stream.WriteByte(0); - } - } - else - { - for (int i = 0; i < 28; i++) - { - stream.WriteByte(0); - } - } - - // ? - for (int i = 0; i < 9; i++) - { - stream.WriteByte(0); - } - - // translated episode title (11 bytes) - for (int i = 0; i < 11; i++) - { - stream.WriteByte(0); - } - - // ? - for (int i = 0; i < 18; i++) - { - stream.WriteByte(0); - } - - // ? + language codes - buffer = new byte[] { 0xA0, 0x05, 0x04, 0x03, 0x06, 0x06, 0x08, 0x90, 0x00, 0x00, 0x00, 0x00, (byte)_languageIdLine1, (byte)_languageIdLine2 }; - stream.Write(buffer, 0, buffer.Length); - - // comments (24 bytes) - buffer = Encoding.ASCII.GetBytes(""); - if (!string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena89Comment) && Configuration.Settings.SubtitleSettings.CurrentCavena89Comment.Length <= 24) - { - buffer = Encoding.ASCII.GetBytes(Configuration.Settings.SubtitleSettings.CurrentCavena89Comment); - } - - stream.Write(buffer, 0, buffer.Length); - for (int i = 0; i < 24 - buffer.Length; i++) - { - stream.WriteByte(0); - } - - // ?? - buffer = new byte[] { 0x08, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00 }; - stream.Write(buffer, 0, buffer.Length); - - // number of subtitles - stream.WriteByte((byte)(subtitle.Paragraphs.Count % 256)); - stream.WriteByte((byte)(subtitle.Paragraphs.Count / 256)); - - // write font - prefix with binary zeroes - buffer = GetFontBytesFromLanguageId(_languageIdLine1); // also TBX308VFONTL.V for english... - for (int i = 0; i < 14 - buffer.Length; i++) - { - stream.WriteByte(0); - } - - stream.Write(buffer, 0, buffer.Length); - - // ? - for (int i = 0; i < 13; i++) - { - stream.WriteByte(0); - } - - // number of subtitles again - stream.WriteByte((byte)(subtitle.Paragraphs.Count % 256)); - stream.WriteByte((byte)(subtitle.Paragraphs.Count / 256)); - - - // number of subtitles again again - stream.WriteByte((byte)(subtitle.Paragraphs.Count % 256)); - stream.WriteByte((byte)(subtitle.Paragraphs.Count / 256)); - - // ? - for (int i = 0; i < 6; i++) - { - stream.WriteByte(0); - } - - // original programme title (28 chars) - if (!string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle) && Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle.Length <= 28) - { - buffer = Encoding.ASCII.GetBytes(Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle); - stream.Write(buffer, 0, buffer.Length); - for (int i = 0; i < 28 - buffer.Length; i++) - { - stream.WriteByte(0); - } - } - else - { - for (int i = 0; i < 28; i++) - { - stream.WriteByte(0); - } - } - - // write font (use same font id from line 1) - buffer = GetFontBytesFromLanguageId(_languageIdLine1); - stream.Write(buffer, 0, buffer.Length); - - // ? - stream.WriteByte(0x3d); - stream.WriteByte(0x8d); - - // start of message time - string startOfMessage = "10:00:00:00"; - if (Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage != null && - Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage.Length == startOfMessage.Length) - { - startOfMessage = Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage; - } - - buffer = Encoding.ASCII.GetBytes(startOfMessage); - stream.Write(buffer, 0, buffer.Length); - - buffer = new byte[] - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x54, 0x44 - }; - stream.Write(buffer, 0, buffer.Length); - - for (int i = 0; i < 92; i++) - { - stream.WriteByte(0); - } - - // paragraphs - int number = 16; - foreach (Paragraph p in subtitle.Paragraphs) - { - // number - stream.WriteByte((byte)(number / 256)); - stream.WriteByte((byte)(number % 256)); - - WriteTime(stream, p.StartTime); - WriteTime(stream, p.EndTime); - - if (p.Text.StartsWith("{\\an1}")) - { - stream.WriteByte(0x50); // left - } - else if (p.Text.StartsWith("{\\an3}")) - { - stream.WriteByte(0x52); // left - } - else - { - stream.WriteByte(0x54); // center - } - - buffer = new byte[] { 0, 0, 0, 0, 0, 0, 0 }; // 0x16 }; -- the last two bytes might be something with vertical alignment... - stream.Write(buffer, 0, buffer.Length); - - bool hasBox = Utilities.RemoveSsaTags(p.Text).StartsWith(""); - var text = p.Text.Replace("", string.Empty).Replace("", string.Empty); - text = HtmlUtil.RemoveOpenCloseTags(Utilities.RemoveSsaTags(text), HtmlUtil.TagBold, HtmlUtil.TagFont, HtmlUtil.TagBold); - WriteText(stream, text, p == subtitle.Paragraphs[subtitle.Paragraphs.Count - 1], _languageIdLine1, hasBox); - - number += 16; - } - return true; - } - - private static byte[] GetFontBytesFromLanguageId(int languageId) - { - var buffer = Encoding.ASCII.GetBytes("HLV23N.V"); - if (languageId == LanguageIdChineseTraditional || languageId == LanguageIdChineseSimplified) - { - buffer = Encoding.ASCII.GetBytes("CCKM44.V"); - } - else if (languageId == LanguageIdArabic) - { - buffer = Encoding.ASCII.GetBytes("ARA19N.V"); - } - else if (languageId == LanguageIdRussian) - { - buffer = Encoding.ASCII.GetBytes("KYRIL4.V"); - } - else if (languageId == LanguageIdHebrew) - { - buffer = Encoding.ASCII.GetBytes("HEBNOA.V"); - } - else if (languageId == LanguageIdDanish) - { - buffer = Encoding.ASCII.GetBytes("VFONTL.V"); - } - - return buffer; - } - - private static void WriteText(Stream fs, string text, bool isLast, int languageIdLine, bool useBox) - { - var lines = text.SplitToLines(); - if (lines.Count > 2) - { - lines = Utilities.AutoBreakLine(text).SplitToLines(); - } - - string line1 = string.Empty; - string line2; - if (lines.Count > 1) - { - line1 = lines[0]; - line2 = lines[1]; - } - else - { - line2 = lines[0]; - } - - var buffer = GetTextAsBytes(line1, languageIdLine); - fs.Write(buffer, 0, buffer.Length); - - buffer = new byte[] { 00, 00, 00, 00, 00, 00 }; - if (useBox) - { - buffer[3] = 0xa0; - } - - fs.Write(buffer, 0, buffer.Length); - - buffer = GetTextAsBytes(line2, languageIdLine); - fs.Write(buffer, 0, buffer.Length); - - buffer = new byte[] { 00, 00, 00, 00 }; - if (!isLast) - { - fs.Write(buffer, 0, buffer.Length); - } - } - - private static byte[] GetTextAsBytes(string text, int languageId) - { - var buffer = new byte[51]; - int skipCount = 0; - for (int i = 0; i < buffer.Length; i++) - { - buffer[i] = 0x7F; - } - - if (languageId == LanguageIdChineseTraditional || languageId == LanguageIdChineseSimplified) - { - for (int i = 0; i < buffer.Length; i++) - { - buffer[i] = 0; - } - } - else if (languageId == LanguageIdHebrew) - { - text = Utilities.ReverseNumbers(text); - if (!Configuration.Settings.General.RightToLeftMode) - { - text = Utilities.ReverseStartAndEndingForRightToLeft(text); - } - } - - var encoding = Encoding.Default; - int index = 0; - - if (languageId == LanguageIdHebrew) - { - text = ReverseAnsi(text); - } - - for (int i = 0; i < text.Length; i++) - { - var current = text[i]; - if (skipCount > 0) - { - skipCount--; - } - else if (languageId == LanguageIdHebrew) - { - int letterIndex = HebrewLetters.IndexOf(current.ToString(CultureInfo.InvariantCulture)); - if (letterIndex >= 0) - { - buffer[index] = (byte)HebrewCodes[letterIndex]; - } - else if (i + 3 < text.Length && text.Substring(i, 3) == "") - { - buffer[index] = 0x88; - skipCount = 2; - } - else if (i + 4 <= text.Length && text.Substring(i, 4) == "") - { - buffer[index] = 0x98; - skipCount = 2; - } - else - { - buffer[index] = encoding.GetBytes(new[] { current })[0]; - } - index++; - } - else if (languageId == LanguageIdChineseTraditional || languageId == LanguageIdChineseSimplified) - { - encoding = Encoding.GetEncoding(1201); - if (index < 49) - { - if (i + 3 < text.Length && text.Substring(i, 3) == "") - { - buffer[index] = 0x88; - skipCount = 2; - } - else if (i + 4 <= text.Length && text.Substring(i, 4) == "") - { - buffer[index] = 0x98; - skipCount = 3; - } - else - { - buffer[index] = encoding.GetBytes(new[] { current })[0]; - index++; - } - } - } - else - { - if (index < 50) - { - if (current == 'æ') - { - buffer[index] = 0x1B; - } - else if (current == 'ø') - { - buffer[index] = 0x1C; - } - else if (current == 'å') - { - buffer[index] = 0x1D; - } - else if (current == 'Æ') - { - buffer[index] = 0x5B; - } - else if (current == 'Ø') - { - buffer[index] = 0x5C; - } - else if (current == 'Å') - { - buffer[index] = 0x5D; - } - - // ăĂ şŞ ţŢ (romanian) - else if (current == 'ă') - { - AddTwo(buffer, ref index, 0x89, 0x61); - } - else if (current == 'Ă') - { - AddTwo(buffer, ref index, 0x89, 0x41); - } - else if (current == 'ş') - { - AddTwo(buffer, ref index, 0x87, 0x73); - } - else if (current == 'Ş') - { - AddTwo(buffer, ref index, 0x87, 0x53); - } - else if (current == 'ţ') - { - AddTwo(buffer, ref index, 0x87, 0x74); - } - else if (current == 'Ţ') - { - AddTwo(buffer, ref index, 0x87, 0x54); - } - - // Next mapping of diacritics is reverse engineered, - // and currently only maps characters from latin alphabets according to https://en.wikipedia.org/wiki/Latin_alphabets - - // capitals with accent grave - else if (current == 'À') - { - AddTwo(buffer, ref index, 0x81, 0x41); - } - else if (current == 'È') - { - AddTwo(buffer, ref index, 0x81, 0x45); - } - else if (current == 'Ì') - { - AddTwo(buffer, ref index, 0x81, 0x49); - } - else if (current == 'Ò') - { - AddTwo(buffer, ref index, 0x81, 0x4F); - } - else if (current == 'Ù') - { - AddTwo(buffer, ref index, 0x81, 0x55); - } - else if (current == 'Ẁ') - { - AddTwo(buffer, ref index, 0x81, 0x57); - } - - // lowercase with accent grave - else if (current == 'à') - { - AddTwo(buffer, ref index, 0x81, 0x61); - } - else if (current == 'è') - { - AddTwo(buffer, ref index, 0x81, 0x65); - } - else if (current == 'ì') - { - AddTwo(buffer, ref index, 0x81, 0x69); - } - else if (current == 'ò') - { - AddTwo(buffer, ref index, 0x81, 0x6F); - } - else if (current == 'ù') - { - AddTwo(buffer, ref index, 0x81, 0x75); - } - else if (current == 'ẁ') - { - AddTwo(buffer, ref index, 0x81, 0x75); - } - - // capitals with accent aigu - else if (current == 'Á') - { - AddTwo(buffer, ref index, 0x82, 0x41); - } - else if (current == 'Ć') - { - AddTwo(buffer, ref index, 0x82, 0x43); - } - else if (current == 'É') - { - AddTwo(buffer, ref index, 0x82, 0x45); - } - else if (current == 'Í') - { - AddTwo(buffer, ref index, 0x82, 0x49); - } - else if (current == 'Ĺ') - { - AddTwo(buffer, ref index, 0x82, 0x4C); - } - else if (current == 'Ń') - { - AddTwo(buffer, ref index, 0x82, 0x4E); - } - else if (current == 'Ó') - { - AddTwo(buffer, ref index, 0x82, 0x4F); - } - else if (current == 'Ŕ') - { - AddTwo(buffer, ref index, 0x82, 0x52); - } - else if (current == 'Ś') - { - AddTwo(buffer, ref index, 0x82, 0x53); - } - else if (current == 'Ú') - { - AddTwo(buffer, ref index, 0x82, 0x55); - } - else if (current == 'Ẃ') - { - AddTwo(buffer, ref index, 0x82, 0x57); - } - else if (current == 'Ý') - { - AddTwo(buffer, ref index, 0x82, 0x59); - } - else if (current == 'Ź') - { - AddTwo(buffer, ref index, 0x82, 0x5A); - } - - // lowercase with accent aigu - else if (current == 'á') - { - AddTwo(buffer, ref index, 0x82, 0x61); - } - else if (current == 'ć') - { - AddTwo(buffer, ref index, 0x82, 0x63); - } - else if (current == 'é') - { - AddTwo(buffer, ref index, 0x82, 0x65); - } - else if (current == 'í') - { - AddTwo(buffer, ref index, 0x82, 0x69); - } - else if (current == 'ĺ') - { - AddTwo(buffer, ref index, 0x82, 0x6C); - } - else if (current == 'ń') - { - AddTwo(buffer, ref index, 0x82, 0x6E); - } - else if (current == 'ó') - { - AddTwo(buffer, ref index, 0x82, 0x6F); - } - else if (current == 'ŕ') - { - AddTwo(buffer, ref index, 0x82, 0x72); - } - else if (current == 'ś') - { - AddTwo(buffer, ref index, 0x82, 0x73); - } - else if (current == 'ú') - { - AddTwo(buffer, ref index, 0x82, 0x75); - } - else if (current == 'ẃ') - { - AddTwo(buffer, ref index, 0x82, 0x77); - } - else if (current == 'ý') - { - AddTwo(buffer, ref index, 0x82, 0x79); - } - else if (current == 'ź') - { - AddTwo(buffer, ref index, 0x82, 0x7A); - } - - // capitals with accent circonflexe - else if (current == 'Â') - { - AddTwo(buffer, ref index, 0x83, 0x41); - } - else if (current == 'Ĉ') - { - AddTwo(buffer, ref index, 0x83, 0x43); - } - else if (current == 'Ê') - { - AddTwo(buffer, ref index, 0x83, 0x45); - } - else if (current == 'Ĝ') - { - AddTwo(buffer, ref index, 0x83, 0x47); - } - else if (current == 'Ĥ') - { - AddTwo(buffer, ref index, 0x83, 0x48); - } - else if (current == 'Î') - { - AddTwo(buffer, ref index, 0x83, 0x49); - } - else if (current == 'Ĵ') - { - AddTwo(buffer, ref index, 0x83, 0x4A); - } - else if (current == 'Ô') - { - AddTwo(buffer, ref index, 0x83, 0x4F); - } - else if (current == 'Ŝ') - { - AddTwo(buffer, ref index, 0x83, 0x53); - } - else if (current == 'Û') - { - AddTwo(buffer, ref index, 0x83, 0x55); - } - else if (current == 'Ŵ') - { - AddTwo(buffer, ref index, 0x83, 0x57); - } - else if (current == 'Ŷ') - { - AddTwo(buffer, ref index, 0x83, 0x59); - } - - // lowercase with accent circonflexe - else if (current == 'â') - { - AddTwo(buffer, ref index, 0x83, 0x61); - } - else if (current == 'ĉ') - { - AddTwo(buffer, ref index, 0x83, 0x63); - } - else if (current == 'ê') - { - AddTwo(buffer, ref index, 0x83, 0x65); - } - else if (current == 'ĝ') - { - AddTwo(buffer, ref index, 0x83, 0x67); - } - else if (current == 'ĥ') - { - AddTwo(buffer, ref index, 0x83, 0x68); - } - else if (current == 'î') - { - AddTwo(buffer, ref index, 0x83, 0x69); - } - else if (current == 'ĵ') - { - AddTwo(buffer, ref index, 0x83, 0x6A); - } - else if (current == 'ô') - { - AddTwo(buffer, ref index, 0x83, 0x6F); - } - else if (current == 'ŝ') - { - AddTwo(buffer, ref index, 0x83, 0x73); - } - else if (current == 'û') - { - AddTwo(buffer, ref index, 0x83, 0x75); - } - else if (current == 'ŵ') - { - AddTwo(buffer, ref index, 0x83, 0x77); - } - else if (current == 'ŷ') - { - AddTwo(buffer, ref index, 0x83, 0x79); - } - - // capitals with caron - else if (current == 'Ǎ') - { - AddTwo(buffer, ref index, 0x84, 0x41); - } - else if (current == 'Č') - { - AddTwo(buffer, ref index, 0x84, 0x43); - } - else if (current == 'Ď') - { - AddTwo(buffer, ref index, 0x84, 0x44); - } - else if (current == 'Ě') - { - AddTwo(buffer, ref index, 0x84, 0x45); - } - else if (current == 'Ǧ') - { - AddTwo(buffer, ref index, 0x84, 0x47); - } - else if (current == 'Ǐ') - { - AddTwo(buffer, ref index, 0x84, 0x49); - } - else if (current == 'Ľ') - { - AddTwo(buffer, ref index, 0x84, 0x4C); - } - else if (current == 'Ň') - { - AddTwo(buffer, ref index, 0x84, 0x4E); - } - else if (current == 'Ř') - { - AddTwo(buffer, ref index, 0x84, 0x52); - } - else if (current == 'Š') - { - AddTwo(buffer, ref index, 0x84, 0x53); - } - else if (current == 'Ť') - { - AddTwo(buffer, ref index, 0x84, 0x54); - } - else if (current == 'Ž') - { - AddTwo(buffer, ref index, 0x84, 0x5A); - } - - // lowercase with caron - else if (current == 'ǎ') - { - AddTwo(buffer, ref index, 0x84, 0x61); - } - else if (current == 'č') - { - AddTwo(buffer, ref index, 0x84, 0x63); - } - else if (current == 'ď') - { - AddTwo(buffer, ref index, 0x84, 0x64); - } - else if (current == 'ě') - { - AddTwo(buffer, ref index, 0x84, 0x65); - } - else if (current == 'ǧ') - { - AddTwo(buffer, ref index, 0x84, 0x67); - } - else if (current == 'ǐ') - { - AddTwo(buffer, ref index, 0x84, 0x69); - } - else if (current == 'ľ') - { - AddTwo(buffer, ref index, 0x84, 0x6C); - } - else if (current == 'ň') - { - AddTwo(buffer, ref index, 0x84, 0x6E); - } - else if (current == 'ř') - { - AddTwo(buffer, ref index, 0x84, 0x72); - } - else if (current == 'š') - { - AddTwo(buffer, ref index, 0x84, 0x73); - } - else if (current == 'ť') - { - AddTwo(buffer, ref index, 0x84, 0x74); - } - else if (current == 'ž') - { - AddTwo(buffer, ref index, 0x84, 0x7A); - } - - // capitals with tilde - else if (current == 'Ã') - { - AddTwo(buffer, ref index, 0x85, 0x41); - } - else if (current == 'Ĩ') - { - AddTwo(buffer, ref index, 0x85, 0x49); - } - else if (current == 'Ñ') - { - AddTwo(buffer, ref index, 0x85, 0x4E); - } - else if (current == 'Õ') - { - AddTwo(buffer, ref index, 0x85, 0x4F); - } - else if (current == 'Ũ') - { - AddTwo(buffer, ref index, 0x85, 0x55); - } - - // lowercase with tilde - else if (current == 'ã') - { - AddTwo(buffer, ref index, 0x85, 0x61); - } - else if (current == 'ĩ') - { - AddTwo(buffer, ref index, 0x85, 0x69); - } - else if (current == 'ñ') - { - AddTwo(buffer, ref index, 0x85, 0x6E); - } - else if (current == 'õ') - { - AddTwo(buffer, ref index, 0x85, 0x6F); - } - else if (current == 'ũ') - { - AddTwo(buffer, ref index, 0x85, 0x75); - } - - // capitals with trema - else if (current == 'Ä') - { - AddTwo(buffer, ref index, 0x86, 0x41); - } - else if (current == 'Ë') - { - AddTwo(buffer, ref index, 0x86, 0x45); - } - else if (current == 'Ï') - { - AddTwo(buffer, ref index, 0x86, 0x49); - } - else if (current == 'Ö') - { - AddTwo(buffer, ref index, 0x86, 0x4F); - } - else if (current == 'Ü') - { - AddTwo(buffer, ref index, 0x86, 0x55); - } - else if (current == 'Ẅ') - { - AddTwo(buffer, ref index, 0x86, 0x57); - } - else if (current == 'Ÿ') - { - AddTwo(buffer, ref index, 0x86, 0x59); - } - - // lowercase with trema - else if (current == 'ä') - { - AddTwo(buffer, ref index, 0x86, 0x61); - } - else if (current == 'ë') - { - AddTwo(buffer, ref index, 0x86, 0x65); - } - else if (current == 'ï') - { - AddTwo(buffer, ref index, 0x86, 0x69); - } - else if (current == 'ö') - { - AddTwo(buffer, ref index, 0x86, 0x6F); - } - else if (current == 'ü') - { - AddTwo(buffer, ref index, 0x86, 0x75); - } - else if (current == 'ẅ') - { - AddTwo(buffer, ref index, 0x86, 0x77); - } - else if (current == 'ÿ') - { - AddTwo(buffer, ref index, 0x86, 0x79); - } - else if (i + 3 < text.Length && text.Substring(i, 3) == "") - { - buffer[index] = 0x88; - skipCount = 2; - } - else if (i + 4 <= text.Length && text.Substring(i, 4) == "") - { - buffer[index] = 0x98; - skipCount = 3; - } - else - { - buffer[index] = encoding.GetBytes(new[] { current })[0]; - } - index++; - } - } - } - - return buffer; - } - - private static string ReverseAnsi(string text) - { - var sb = new StringBuilder(); - var ansi = new StringBuilder(); - foreach (var ch in text) - { - if (ch > 255) - { - if (ansi.Length > 0) - { - sb.Append(Utilities.ReverseString(ansi.ToString())); - ansi.Clear(); - } - sb.Append(ch); - } - else - { - ansi.Append(ch); - } - } - if (ansi.Length > 0) - { - sb.Append(Utilities.ReverseString(ansi.ToString())); - } - - return sb.ToString(); - } - - private static void AddTwo(byte[] buffer, ref int index, byte b1, byte b2) - { - buffer[index] = b1; - index++; - buffer[index] = b2; - } - - private static void WriteTime(Stream fs, TimeCode timeCode) - { - double totalMilliseconds = timeCode.TotalMilliseconds; - int frames = (int)Math.Round(totalMilliseconds / (TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate)); - fs.WriteByte((byte)(frames / 256 / 256)); - fs.WriteByte((byte)(frames / 256)); - fs.WriteByte((byte)(frames % 256)); - } - - public override bool IsMine(List lines, string fileName) - { - if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) - { - var fi = new FileInfo(fileName); - if (fi.Length >= 512 && fi.Length < 1024000) // not too small or too big - { - if (!fileName.EndsWith(".890", StringComparison.Ordinal)) - { - return false; - } - - return base.IsMine(lines, fileName); - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - return "Not supported!"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - const int textLength = 51; - - subtitle.Paragraphs.Clear(); - subtitle.Header = null; - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - - _languageIdLine1 = buffer[146]; - if (_languageIdLine1 == 0) - { - _languageIdLine1 = LanguageIdEnglish; - } - - Configuration.Settings.SubtitleSettings.CurrentCavena890LanguageIdLine1 = _languageIdLine1; - - _languageIdLine2 = buffer[147]; - if (_languageIdLine2 == 0) - { - _languageIdLine2 = LanguageIdEnglish; - } - - Configuration.Settings.SubtitleSettings.CurrentCavena890LanguageIdLine2 = _languageIdLine2; - - var fontNameLine1 = Encoding.ASCII.GetString(buffer, 187, 6); - var fontNameLine2 = Encoding.ASCII.GetString(buffer, 246, 6); - - // Hebrew - if (_languageIdLine1 == LanguageIdHebrew || fontNameLine1 == "HEBNOA" || fontNameLine2 == "HEBNOA") - { - _languageIdLine1 = LanguageIdHebrew; - _languageIdLine2 = LanguageIdHebrew; - } - - // Arabic - if (_languageIdLine2 == LanguageIdArabic || fontNameLine1 == "ARABIC") - { - _languageIdLine1 = LanguageIdArabic; - _languageIdLine2 = LanguageIdArabic; - } - - // Russian - else if (_languageIdLine1 == LanguageIdRussian || fontNameLine1.StartsWith("KYRIL", StringComparison.Ordinal) || fontNameLine2.StartsWith("KYRIL", StringComparison.Ordinal)) - { - _languageIdLine1 = LanguageIdRussian; - _languageIdLine2 = LanguageIdRussian; - } - - // Chinese - else if (_languageIdLine1 == LanguageIdChineseSimplified) - { - _languageIdLine1 = LanguageIdChineseSimplified; - _languageIdLine2 = LanguageIdChineseSimplified; - } - else if (_languageIdLine1 == LanguageIdChineseTraditional || fontNameLine1 == "CCKM44" || fontNameLine2 == "CCKM44") - { - _languageIdLine1 = LanguageIdChineseTraditional; - _languageIdLine2 = LanguageIdChineseTraditional; - } - - int i = 455; - int lastNumber = -1; - while (i < buffer.Length - 20) - { - int start = i - textLength; - - int number = buffer[start - 16] * 256 + buffer[start - 15]; - - var p = new Paragraph(); - double startFrame = buffer[start - 14] * 256 * 256 + buffer[start - 13] * 256 + buffer[start - 12]; - double endFrame = buffer[start - 11] * 256 * 256 + buffer[start - 10] * 256 + buffer[start - 9]; - - byte boxType = buffer[start + textLength + 3]; - - string line1 = FixText(buffer, start, textLength, _languageIdLine1); - string line2 = FixText(buffer, start + textLength + 6, textLength, _languageIdLine2); - - if (lastNumber == number) - { - p = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1]; - string temp = (line1.TrimEnd() + Environment.NewLine + line2).TrimEnd(); - if (temp.Length > 0) - { - p.Text = temp; - } - } - else - { - subtitle.Paragraphs.Add(p); - p.StartTime.TotalMilliseconds = (TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate) * startFrame; - p.EndTime.TotalMilliseconds = (TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate) * endFrame; - p.Text = (line1.TrimEnd() + Environment.NewLine + line2).TrimEnd(); - } - if (boxType >= 0xa0 && boxType <= 0xa9 && !string.IsNullOrEmpty(p.Text)) // box - { - if (p.Text.StartsWith("{\\") && p.Text.Contains("}")) - { - p.Text = p.Text.Insert(p.Text.IndexOf('}', 3) + 1, "") + ""; - } - else - { - p.Text = "" + p.Text + ""; - } - } - - lastNumber = number; - - i += 128; - } - - subtitle.Renumber(); - } - - private static string FixText(byte[] buffer, int start, int textLength, int languageId) - { - string text; - - if (languageId == LanguageIdRussian) - { - var encoding = Encoding.GetEncoding(1252); - var sb = new StringBuilder(); - for (int i = 0; i < textLength; i++) - { - int b = buffer[start + i]; - int idx = RussianCodes.IndexOf(b); - if (idx >= 0) - { - sb.Append(RussianLetters[idx]); - } - else - { - sb.Append(encoding.GetString(buffer, start + i, 1)); - } - } - - text = sb.ToString(); - - text = text.Replace(encoding.GetString(new byte[] { 0x7F }), string.Empty); // Used to fill empty space upto 51 bytes - text = text.Replace(encoding.GetString(new byte[] { 0xBE }), string.Empty); // Unknown? - text = FixColors(text); - - if (text.Contains("")) - { - text = text.Replace("", ""); - } - - if (text.Contains("") && !text.Contains("")) - { - text += ""; - } - } - else if (languageId == LanguageIdHebrew) // (_language == "HEBNOA") - { - var encoding = Encoding.GetEncoding(1252); - var sb = new StringBuilder(); - for (int i = 0; i < textLength; i++) - { - int b = buffer[start + i]; - int idx = HebrewCodes.IndexOf(b); - if (idx >= 0) - { - sb.Append(HebrewLetters[idx]); - } - else - { - sb.Append(encoding.GetString(buffer, start + i, 1)); - } - } - - text = sb.ToString(); - - text = text.Replace(encoding.GetString(new byte[] { 0x7F }), string.Empty); // Used to fill empty space upto 51 bytes - text = text.Replace(encoding.GetString(new byte[] { 0xBE }), string.Empty); // Unknown? - text = FixColors(text); - - text = ReverseAnsi(text); - text = Utilities.ReverseStartAndEndingForRightToLeft(text); - } - else if (languageId == LanguageIdArabic) - { - var encoding = Encoding.GetEncoding(1252); - var sb = new StringBuilder(); - for (int i = 0; i < textLength; i++) - { - int b = buffer[start + i]; - if (ArabicDictionary.TryGetValue(b, out var v)) - { - sb.Append(v); - } - else if (b != 0x7F) // filler (decimal 127) - { - sb.Append(encoding.GetString(buffer, start + i, 1)); - } - } - - text = sb.ToString(); - text = text.Replace(encoding.GetString(new byte[] { 0xBE }), string.Empty); // Unknown? - text = FixColors(text).Trim(); - } - else if (languageId == LanguageIdChineseTraditional || languageId == LanguageIdChineseSimplified) // (_language == "CCKM44" || _language == "TVB000") - { - int index = start; - - while (textLength >= 1 && index + textLength < buffer.Length && (buffer[index + textLength - 1] == 0)) - { - textLength--; - } - - if (textLength > 0) - { - text = Encoding.GetEncoding(1201).GetString(buffer, index, textLength).Replace("\0", string.Empty); - } - else - { - text = string.Empty; - } - - var encoding = Encoding.Default; // which encoding?? Encoding.GetEncoding("ISO-8859-5") - text = text.Replace(encoding.GetString(new byte[] { 0x7F }), string.Empty); // Used to fill empty space upto 51 bytes - text = text.Replace(encoding.GetString(new byte[] { 0xBE }), string.Empty); // Unknown? - text = FixColors(text); - text = text.Replace(encoding.GetString(new byte[] { 0x88 }), ""); - text = text.Replace(encoding.GetString(new byte[] { 0x98 }), ""); - - if (text.Contains("")) - { - text = text.Replace("", ""); - } - - if (text.Contains("") && !text.Contains("")) - { - text += ""; - } - } - else - { - var encoding = Encoding.GetEncoding(1252); - text = encoding.GetString(buffer, start, textLength).Replace("\0", string.Empty); - - text = text.Replace(encoding.GetString(new byte[] { 0x7F }), string.Empty); // Used to fill empty space upto 51 bytes - text = text.Replace(encoding.GetString(new byte[] { 0xBE }), string.Empty); // Unknown? - text = FixColors(text); - - text = text.Replace(encoding.GetString(new byte[] { 0x1B }), "æ"); - text = text.Replace(encoding.GetString(new byte[] { 0x1C }), "ø"); - text = text.Replace(encoding.GetString(new byte[] { 0x1D }), "å"); - text = text.Replace(encoding.GetString(new byte[] { 0x1E }), "Æ"); - text = text.Replace(encoding.GetString(new byte[] { 0x1F }), "Ø"); - - text = text.Replace(encoding.GetString(new byte[] { 0x5B }), "Æ"); - text = text.Replace(encoding.GetString(new byte[] { 0x5C }), "Ø"); - text = text.Replace(encoding.GetString(new byte[] { 0x5D }), "Å"); - - // capitals with accent grave - text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x41 }), "À"); - text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x45 }), "È"); - text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x49 }), "Ì"); - text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x4f }), "Ò"); - text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x55 }), "Ù"); - - // lowercase with accent grave - text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x61 }), "à"); - text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x65 }), "è"); - text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x69 }), "ì"); - text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x6F }), "ò"); - text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x75 }), "ù"); - - // capitals with accent aigu - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x41 }), "Á"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x43 }), "Ć"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x45 }), "É"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x49 }), "Í"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x4C }), "Ĺ"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x4E }), "Ń"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x4F }), "Ó"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x52 }), "Ŕ"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x53 }), "Ś"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x55 }), "Ú"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x57 }), "Ẃ"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x59 }), "Ý"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x5A }), "Ź"); - - // lowercase with accent aigu - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x61 }), "á"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x63 }), "ć"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x65 }), "é"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x69 }), "í"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x6C }), "ĺ"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x6E }), "ń"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x6F }), "ó"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x72 }), "ŕ"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x73 }), "ś"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x75 }), "ú"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x77 }), "ẃ"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x79 }), "ý"); - text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x7A }), "ź"); - - // capitals with accent circonflexe - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x41 }), "Â"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x43 }), "Ĉ"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x45 }), "Ê"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x47 }), "Ĝ"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x48 }), "Ĥ"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x49 }), "Î"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x4A }), "Ĵ"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x4F }), "Ô"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x53 }), "Ŝ"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x55 }), "Û"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x57 }), "Ŵ"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x59 }), "Ŷ"); - - // lowercase with accent circonflexe - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x61 }), "â"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x63 }), "ĉ"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x65 }), "ê"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x67 }), "ĝ"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x68 }), "ĥ"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x69 }), "î"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x6A }), "ĵ"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x6F }), "ô"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x73 }), "ŝ"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x75 }), "û"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x77 }), "ŵ"); - text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x79 }), "ŷ"); - - // capitals with caron - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x41 }), "Ǎ"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x43 }), "Č"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x44 }), "Ď"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x45 }), "Ě"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x47 }), "Ǧ"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x49 }), "Ǐ"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x4C }), "Ľ"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x4E }), "Ň"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x52 }), "Ř"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x53 }), "Š"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x54 }), "Ť"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x5A }), "Ž"); - - // lowercase with caron - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x61 }), "ǎ"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x63 }), "č"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x64 }), "ď"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x65 }), "ě"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x67 }), "ǧ"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x69 }), "ǐ"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x6C }), "ľ"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x6E }), "ň"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x72 }), "ř"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x73 }), "š"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x74 }), "ť"); - text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x7A }), "ž"); - - // capitals with tilde - text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x41 }), "Ã"); - text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x49 }), "Ĩ"); - text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x4E }), "Ñ"); - text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x4F }), "Õ"); - text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x55 }), "Ũ"); - - // lowercase with tilde - text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x61 }), "ã"); - text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x69 }), "ĩ"); - text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x6E }), "ñ"); - text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x6F }), "õ"); - text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x75 }), "ũ"); - - // capitals with trema - text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x41 }), "Ä"); - text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x45 }), "Ë"); - text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x49 }), "Ï"); - text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x4F }), "Ö"); - text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x55 }), "Ü"); - text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x59 }), "Ÿ"); - - // lowercase with trema - text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x61 }), "ä"); - text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x65 }), "ë"); - text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x69 }), "ï"); - text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x6F }), "ö"); - text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x75 }), "ü"); - text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x79 }), "ÿ"); - - // with ring - text = text.Replace(encoding.GetString(new byte[] { 0x8C, 0x61 }), "å"); - text = text.Replace(encoding.GetString(new byte[] { 0x8C, 0x41 }), "Å"); - - text = text.Replace(encoding.GetString(new byte[] { 0x88 }), ""); - text = text.Replace(encoding.GetString(new byte[] { 0x98 }), ""); - - // ăĂ şŞ ţŢ (romanian) - text = text.Replace(encoding.GetString(new byte[] { 0x89, 0x61 }), "ă"); - text = text.Replace(encoding.GetString(new byte[] { 0x89, 0x41 }), "Ă"); - text = text.Replace(encoding.GetString(new byte[] { 0x87, 0x73 }), "ş"); - text = text.Replace(encoding.GetString(new byte[] { 0x87, 0x53 }), "Ş"); - text = text.Replace(encoding.GetString(new byte[] { 0x87, 0x74 }), "ţ"); - text = text.Replace(encoding.GetString(new byte[] { 0x87, 0x54 }), "Ţ"); - - if (text.Contains("")) - { - text = text.Replace("", ""); - } - - if (text.Contains("") && !text.Contains("")) - { - text += ""; - } - } - return text; - } - - private static string FixColors(string text) - { - Encoding encoding = Encoding.GetEncoding(1252); - bool fontColorOn = false; - var sb = new StringBuilder(); - for (int i = 0; i < text.Length; i++) - { - var s = text.Substring(i, 1); - if (s == encoding.GetString(new byte[] { 0xf1 })) - { - if (fontColorOn) - { - sb.Append("
"); // white - } - sb.Append(""); // red - fontColorOn = true; - } - else if (s == encoding.GetString(new byte[] { 0xf2 })) - { - if (fontColorOn) - { - sb.Append(""); // white - } - sb.Append(""); // green - fontColorOn = true; - } - else if (s == encoding.GetString(new byte[] { 0xf3 })) - { - if (fontColorOn) - { - sb.Append(""); // white - } - sb.Append(""); // yellow - fontColorOn = true; - } - else if (s == encoding.GetString(new byte[] { 0xf4 })) - { - if (fontColorOn) - { - sb.Append(""); // white - } - sb.Append(""); // purple - fontColorOn = true; - } - else if (s == encoding.GetString(new byte[] { 0xf5 })) - { - if (fontColorOn) - { - sb.Append(""); // white - } - sb.Append(""); // magenta - fontColorOn = true; - } - else if (s == encoding.GetString(new byte[] { 0xf6 })) - { - if (fontColorOn) - { - sb.Append(""); // white - } - sb.Append(""); // cyan - fontColorOn = true; - } - else if (s == encoding.GetString(new byte[] { 0xf7 })) - { - if (fontColorOn) - { - sb.Append(""); // white - fontColorOn = false; - } - } - else if (s == encoding.GetString(new byte[] { 0xf8 })) - { - sb.Append(""); // orange - fontColorOn = true; - } - else - { - sb.Append(s); - } - } - if (fontColorOn) - { - sb.Append(""); // white - } - return sb.ToString(); - } - - } -} +using Nikse.SubtitleEdit.Core.Interfaces; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Cavena890 : SubtitleFormat, IBinaryPersistableSubtitle + { + public const int LanguageIdDanish = 0x07; + public const int LanguageIdEnglish = 0x09; + public const int LanguageIdRussian = 0x56; + public const int LanguageIdArabic = 0x80; + public const int LanguageIdHebrew = 0x8f; + public const int LanguageIdChineseTraditional = 0x90; + public const int LanguageIdChineseSimplified = 0x91; + public const int LanguageIdRomanian = 0x22; + + private static readonly Dictionary ArabicDictionary = new Dictionary + { + { 0x58, "م" }, + { 0x41, "ا" }, + { 0x4e, "ص" }, + { 0x42, "ب" }, + { 0x46, "ح" }, + { 0x57, "ل" }, + { 0x47, "خ" }, + { 0x5d, "ي" }, + { 0x4a, "ر" }, + { 0x2c, "،" }, + { 0x59, "ن" }, + { 0x5a, "و" }, + { 0x43, "ت" }, + { 0x1d, "-" }, + { 0x49, "ذ" }, + { 0x45, "ج" }, + { 0x5b, "ه" }, + { 0x56, "ك" }, + { 0x21, "؟" }, + { 0x4c, "س" }, + { 0x52, "ع" }, + { 0x5c, "ة" }, + { 0x5e, "ى" }, + { 0x61, "أ" }, + { 0x48, "د" }, + { 0x4d, "ش" }, + { 0x60, "ء" }, + { 0x68, "ﻷ" }, + { 0x54, "ف" }, + { 0x55, "ق" }, + { 0x22, "!" }, + { 0x67, "ﻻ" }, + { 0x66, "ؤ" }, + { 0x64, "آ" }, + { 0x50, "ط" }, + { 0x6a, "ﻵ" }, + { 0x4f, "ض" }, + { 0x6b, "ﺋ" }, + { 0x44, "ث" }, + { 0x51, "ظ" }, + { 0x53, "غ" }, + { 0x4b, "ز" }, + { 0x23, "\"" }, + { 0x6c, "ـ" }, + }; + + private static readonly List HebrewCodes = new List + { + 0x40, // א + 0x41, // ב + 0x42, // ג + 0x43, // ד + 0x44, // ה + 0x45, // ו + 0x46, // ז + 0x47, // ח + 0x49, // י + 0x4c, // ל + 0x4d, // ם + 0x4e, // מ + 0x4f, // ן + 0x50, // נ + 0x51, // ס + 0x52, // ע + 0x54, // פ + 0x56, // צ + 0x57, // ק + 0x58, // ר + 0x59, // ש + 0x5A, // ת + 0x4b, // כ + 0x4a, // ך + 0x48, // ט + 0x53, // ף + 0x55, // ץ + + 0xB1, // "a" + 0xB2, // "b" + 0xB3, // "c" + 0xB4, // "d" + 0xB5, // "e" + 0xB6, // "f" + 0xB7, // "g" + 0xB8, // "h" + 0xB9, // "i" + 0xBA, // "j" + 0xBB, // "k" + 0xBC, // "l" + 0xBD, // "m" + 0xBE, // "n" + 0xBF, // "o" + 0xC0, // "p" + 0xC1, // "q" + 0xC2, // "r" + 0xC3, // "s" + 0xC4, // "t" + 0xC5, // "u" + 0xC6, // "v" + 0xC7, // "w" + 0xC8, // "x" + 0xC9, // "y" + 0xCA, // "z" + + 0x91, // "A" + 0xDB, // "B" -- weird + 0x93, // "C" + 0xDC, // "D" -- weird + 0x95, // "E" + 0x96, // "F" + 0x97, // "G" + 0xAB, // "H" -- weird + 0x99, // "I" + 0x9A, // "J" + 0x9B, // "K" + 0x9C, // "L" + 0xDD, // "M" + 0xDE, // "N" + 0x9F, // "O" + 0xA0, // "P" + 0xA1, // "Q" + 0xA2, // "R" + 0xA3, // "S" + 0xA4, // "T" + 0xA5, // "U" + 0xA6, // "V" + 0xA7, // "W" + 0xA8, // "X" - weird + 0xA9, // "Y" + 0xAA, // "Z" - weird + }; + + private static readonly List HebrewLetters = new List + { + "א", + "ב", + "ג", + "ד", + "ה", + "ו", + "ז", + "ח", + "י", + "ל", + "ם", + "מ", + "ן", + "נ", + "ס", + "ע", + "פ", + "צ", + "ק", + "ר", + "ש", + "ת", + "כ", + "ך", + "ט", + "ף", + "ץ", + + "a", // 0xB1 + "b", // 0xB2 + "c", // 0xB3 + "d", // 0xB4 + "e", // 0xB5 + "f", // 0xB6 + "g", // 0xB7 + "h", // 0xB8 + "i", // 0xB9 + "j", // 0xBA + "k", // 0xBB + "l", // 0xBC + "m", // 0xBD + "n", // 0xBE + "o", // 0xBF + "p", // 0xC0 + "q", // 0xC1 + "r", // 0xC2 + "s", // 0xC3 + "t", // 0xC4 + "u", // 0xC5 + "v", // 0xC6 + "w", // 0xC7 + "x", // 0xC8 + "y", // 0xC9 + "z", // 0xCA + + "A", // 0x91, + "B", // 0xDB, + "C", // 0x93, + "D", // 0xDC, + "E", // 0x95, + "F", // 0x96, + "G", // 0x97, + "H", // 0xAB, + "I", // 0x99, + "J", // 0x9A, + "K", // 0x9B, + "L", // 0x9C, + "M", // 0xDD, + "N", // 0xDE, + "O", // 0x9F, + "P", // 0xA0, + "Q", // 0xA1, + "R", // 0xA2, + "S", // 0xA3, + "T", // 0xA4, + "U", // 0xA5, + "V", // 0xA6, + "W", // 0xA7, + "X", // 0xA8, + "Y", // 0xA9, + "Z", // 0xAA, + }; + + private static readonly List RussianCodes = new List + { + 0x42, // Б + 0x45, // Е + 0x5A, // З + 0x56, // В + 0x49, // И + 0x4E, // Н + 0x58, // Ы + 0x51, // Я + 0x56, // V + 0x53, // С + 0x72, // р + 0x69, // и + 0x71, // я + 0x6E, // н + 0x74, // т + 0x5C, // Э + 0x77, // ю + 0x46, // Ф + 0x5E, // Ч + 0x44, // Д + 0x62, // б + 0x73, // с + 0x75, // у + 0x64, // д + 0x60, // ж + 0x6A, // й + 0x6C, // л + 0x47, // Г + 0x78, // ы + 0x7A, // з + 0x7E, // ч + 0x6D, // м + 0x67, // г + 0x79, // ь + 0x70, // п + 0x76, // в + 0x55, // У + 0x7D, // щ + 0x66, // ф + 0x7C, // э + 0x7B, // ш + 0x50, // П + 0x52, // П + 0x68, // П + }; + + private static readonly List RussianLetters = new List + { + "Б", + "Е", + "З", + "В", + "И", + "Н", + "Ы", + "Я", + "V", + "С", + "р", + "и", + "я", + "н", + "т", + "Э", + "ю", + "Ф", + "Ч", + "Д", + "б", + "с", + "у", + "д", + "ж", + "й", + "л", + "Г", + "ы", + "з", + "ч", + "м", + "г", + "ь", + "п", + "в", + "У", + "щ", + "ф", + "э", + "ш", + "П", + "Р", + "х", + }; + + public override string Extension => ".890"; + + public const string NameOfFormat = "Cavena 890"; + + public override string Name => NameOfFormat; + + public override bool IsTimeBased => false; + + private int _languageIdLine1 = LanguageIdEnglish; + private int _languageIdLine2 = LanguageIdEnglish; + + public bool Save(string fileName, Subtitle subtitle, bool batchMode = false) + { + using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) + { + return Save(fileName, fs, subtitle, batchMode); + } + } + + public bool Save(string fileName, Stream stream, Subtitle subtitle, bool batchMode) + { + int russianCount = 0; + char[] logoGrams = { '的', '是', '啊', '吧', '好', '吧', '亲', '爱', '的', '早', '上' }; + char[] russianChars = { 'я', 'д', 'й', 'л', 'щ', 'ж', 'ц', 'ф', 'ы' }; + foreach (Paragraph p in subtitle.Paragraphs) + { + if (p.Text.Contains(logoGrams)) + { + _languageIdLine1 = LanguageIdChineseSimplified; + _languageIdLine2 = LanguageIdChineseSimplified; + break; + } + if (p.Text.Contains(russianChars)) + { + russianCount++; + if (russianCount > 10) + { + _languageIdLine1 = LanguageIdRussian; + _languageIdLine2 = LanguageIdRussian; // or 0x09? + break; + } + } + } + + if (Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId > 0) + { + _languageIdLine1 = Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId; + _languageIdLine2 = Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId; + } + else + { + var language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); + switch (language) + { + case "he": + _languageIdLine1 = LanguageIdHebrew; + _languageIdLine2 = LanguageIdHebrew; // or 0x09 + break; + case "ru": + _languageIdLine1 = LanguageIdRussian; + _languageIdLine2 = LanguageIdRussian; // or 0x09? + break; + case "zh": + _languageIdLine1 = LanguageIdChineseSimplified; + _languageIdLine2 = LanguageIdChineseSimplified; + break; + case "da": + _languageIdLine1 = LanguageIdDanish; + _languageIdLine2 = LanguageIdDanish; + break; + } + } + + // prompt??? + //if (Configuration.Settings.SubtitleSettings.CurrentCavena890LanguageIdLine1 >= 0) + // _languageIdLine1 = Configuration.Settings.SubtitleSettings.CurrentCavena890LanguageIdLine1; + //if (Configuration.Settings.SubtitleSettings.CurrentCavena890LanguageIdLine2 >= 0) + // _languageIdLine2 = Configuration.Settings.SubtitleSettings.CurrentCavena890LanguageIdLine2; + + // write file header (some fields are known, some are not...) + + stream.WriteByte(0); // ? + stream.WriteByte(0); // ? + + // tape number (20 bytes) + for (int i = 0; i < 20; i++) + { + stream.WriteByte(0); + } + + // ? + for (int i = 0; i < 18; i++) + { + stream.WriteByte(0); + } + + // translated programme title (28 bytes) + string title = Path.GetFileNameWithoutExtension(fileName) ?? string.Empty; + if (title.Length > 28) + { + title = title.Substring(0, 28); + } + + if (!string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena89Title) && Configuration.Settings.SubtitleSettings.CurrentCavena89Title.Length <= 28) + { + title = Configuration.Settings.SubtitleSettings.CurrentCavena89Title; + } + + var buffer = Encoding.ASCII.GetBytes(title); + stream.Write(buffer, 0, buffer.Length); + for (int i = 0; i < 28 - buffer.Length; i++) + { + stream.WriteByte(0); + } + + // translator (28 bytes) + if (!string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena890Translator) && Configuration.Settings.SubtitleSettings.CurrentCavena890Translator.Length <= 28) + { + buffer = Encoding.ASCII.GetBytes(Configuration.Settings.SubtitleSettings.CurrentCavena890Translator); + stream.Write(buffer, 0, buffer.Length); + for (int i = 0; i < 28 - buffer.Length; i++) + { + stream.WriteByte(0); + } + } + else + { + for (int i = 0; i < 28; i++) + { + stream.WriteByte(0); + } + } + + // ? + for (int i = 0; i < 9; i++) + { + stream.WriteByte(0); + } + + // translated episode title (11 bytes) + for (int i = 0; i < 11; i++) + { + stream.WriteByte(0); + } + + // ? + for (int i = 0; i < 18; i++) + { + stream.WriteByte(0); + } + + // ? + language codes + buffer = new byte[] { 0xA0, 0x05, 0x04, 0x03, 0x06, 0x06, 0x08, 0x90, 0x00, 0x00, 0x00, 0x00, (byte)_languageIdLine1, (byte)_languageIdLine2 }; + stream.Write(buffer, 0, buffer.Length); + + // comments (24 bytes) + buffer = Encoding.ASCII.GetBytes(""); + if (!string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena89Comment) && Configuration.Settings.SubtitleSettings.CurrentCavena89Comment.Length <= 24) + { + buffer = Encoding.ASCII.GetBytes(Configuration.Settings.SubtitleSettings.CurrentCavena89Comment); + } + + stream.Write(buffer, 0, buffer.Length); + for (int i = 0; i < 24 - buffer.Length; i++) + { + stream.WriteByte(0); + } + + // ?? + buffer = new byte[] { 0x08, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00 }; + stream.Write(buffer, 0, buffer.Length); + + // number of subtitles + stream.WriteByte((byte)(subtitle.Paragraphs.Count % 256)); + stream.WriteByte((byte)(subtitle.Paragraphs.Count / 256)); + + // write font - prefix with binary zeroes + buffer = GetFontBytesFromLanguageId(_languageIdLine1); // also TBX308VFONTL.V for english... + for (int i = 0; i < 14 - buffer.Length; i++) + { + stream.WriteByte(0); + } + + stream.Write(buffer, 0, buffer.Length); + + // ? + for (int i = 0; i < 13; i++) + { + stream.WriteByte(0); + } + + // number of subtitles again + stream.WriteByte((byte)(subtitle.Paragraphs.Count % 256)); + stream.WriteByte((byte)(subtitle.Paragraphs.Count / 256)); + + + // number of subtitles again again + stream.WriteByte((byte)(subtitle.Paragraphs.Count % 256)); + stream.WriteByte((byte)(subtitle.Paragraphs.Count / 256)); + + // ? + for (int i = 0; i < 6; i++) + { + stream.WriteByte(0); + } + + // original programme title (28 chars) + if (!string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle) && Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle.Length <= 28) + { + buffer = Encoding.ASCII.GetBytes(Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle); + stream.Write(buffer, 0, buffer.Length); + for (int i = 0; i < 28 - buffer.Length; i++) + { + stream.WriteByte(0); + } + } + else + { + for (int i = 0; i < 28; i++) + { + stream.WriteByte(0); + } + } + + // write font (use same font id from line 1) + buffer = GetFontBytesFromLanguageId(_languageIdLine1); + stream.Write(buffer, 0, buffer.Length); + + // ? + stream.WriteByte(0x3d); + stream.WriteByte(0x8d); + + // start of message time + string startOfMessage = "10:00:00:00"; + if (Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage != null && + Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage.Length == startOfMessage.Length) + { + startOfMessage = Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage; + } + + buffer = Encoding.ASCII.GetBytes(startOfMessage); + stream.Write(buffer, 0, buffer.Length); + + buffer = new byte[] + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x54, 0x44 + }; + stream.Write(buffer, 0, buffer.Length); + + for (int i = 0; i < 92; i++) + { + stream.WriteByte(0); + } + + // paragraphs + int number = 16; + foreach (Paragraph p in subtitle.Paragraphs) + { + // number + stream.WriteByte((byte)(number / 256)); + stream.WriteByte((byte)(number % 256)); + + WriteTime(stream, p.StartTime); + WriteTime(stream, p.EndTime); + + if (p.Text.StartsWith("{\\an1}")) + { + stream.WriteByte(0x50); // left + } + else if (p.Text.StartsWith("{\\an3}")) + { + stream.WriteByte(0x52); // left + } + else + { + stream.WriteByte(0x54); // center + } + + buffer = new byte[] { 0, 0, 0, 0, 0, 0, 0 }; // 0x16 }; -- the last two bytes might be something with vertical alignment... + stream.Write(buffer, 0, buffer.Length); + + bool hasBox = Utilities.RemoveSsaTags(p.Text).StartsWith(""); + var text = p.Text.Replace("", string.Empty).Replace("", string.Empty); + text = HtmlUtil.RemoveOpenCloseTags(Utilities.RemoveSsaTags(text), HtmlUtil.TagBold, HtmlUtil.TagFont, HtmlUtil.TagBold); + WriteText(stream, text, p == subtitle.Paragraphs[subtitle.Paragraphs.Count - 1], _languageIdLine1, hasBox); + + number += 16; + } + return true; + } + + private static byte[] GetFontBytesFromLanguageId(int languageId) + { + var buffer = Encoding.ASCII.GetBytes("HLV23N.V"); + if (languageId == LanguageIdChineseTraditional || languageId == LanguageIdChineseSimplified) + { + buffer = Encoding.ASCII.GetBytes("CCKM44.V"); + } + else if (languageId == LanguageIdArabic) + { + buffer = Encoding.ASCII.GetBytes("ARA19N.V"); + } + else if (languageId == LanguageIdRussian) + { + buffer = Encoding.ASCII.GetBytes("KYRIL4.V"); + } + else if (languageId == LanguageIdHebrew) + { + buffer = Encoding.ASCII.GetBytes("HEBNOA.V"); + } + else if (languageId == LanguageIdDanish) + { + buffer = Encoding.ASCII.GetBytes("VFONTL.V"); + } + + return buffer; + } + + private static void WriteText(Stream fs, string text, bool isLast, int languageIdLine, bool useBox) + { + var lines = text.SplitToLines(); + if (lines.Count > 2) + { + lines = Utilities.AutoBreakLine(text).SplitToLines(); + } + + string line1 = string.Empty; + string line2; + if (lines.Count > 1) + { + line1 = lines[0]; + line2 = lines[1]; + } + else + { + line2 = lines[0]; + } + + var buffer = GetTextAsBytes(line1, languageIdLine); + fs.Write(buffer, 0, buffer.Length); + + buffer = new byte[] { 00, 00, 00, 00, 00, 00 }; + if (useBox) + { + buffer[3] = 0xa0; + } + + fs.Write(buffer, 0, buffer.Length); + + buffer = GetTextAsBytes(line2, languageIdLine); + fs.Write(buffer, 0, buffer.Length); + + buffer = new byte[] { 00, 00, 00, 00 }; + if (!isLast) + { + fs.Write(buffer, 0, buffer.Length); + } + } + + private static byte[] GetTextAsBytes(string text, int languageId) + { + var buffer = new byte[51]; + int skipCount = 0; + for (int i = 0; i < buffer.Length; i++) + { + buffer[i] = 0x7F; + } + + if (languageId == LanguageIdChineseTraditional || languageId == LanguageIdChineseSimplified) + { + for (int i = 0; i < buffer.Length; i++) + { + buffer[i] = 0; + } + } + else if (languageId == LanguageIdHebrew) + { + text = Utilities.ReverseNumbers(text); + if (!Configuration.Settings.General.RightToLeftMode) + { + text = Utilities.ReverseStartAndEndingForRightToLeft(text); + } + } + + var encoding = Encoding.Default; + int index = 0; + + if (languageId == LanguageIdHebrew) + { + text = ReverseAnsi(text); + } + + for (int i = 0; i < text.Length; i++) + { + var current = text[i]; + if (skipCount > 0) + { + skipCount--; + } + else if (languageId == LanguageIdHebrew) + { + int letterIndex = HebrewLetters.IndexOf(current.ToString(CultureInfo.InvariantCulture)); + if (letterIndex >= 0) + { + buffer[index] = (byte)HebrewCodes[letterIndex]; + } + else if (i + 3 < text.Length && text.Substring(i, 3) == "") + { + buffer[index] = 0x88; + skipCount = 2; + } + else if (i + 4 <= text.Length && text.Substring(i, 4) == "") + { + buffer[index] = 0x98; + skipCount = 2; + } + else + { + buffer[index] = encoding.GetBytes(new[] { current })[0]; + } + index++; + } + else if (languageId == LanguageIdChineseTraditional || languageId == LanguageIdChineseSimplified) + { + encoding = Encoding.GetEncoding(1201); + if (index < 49) + { + if (i + 3 < text.Length && text.Substring(i, 3) == "") + { + buffer[index] = 0x88; + skipCount = 2; + } + else if (i + 4 <= text.Length && text.Substring(i, 4) == "") + { + buffer[index] = 0x98; + skipCount = 3; + } + else + { + buffer[index] = encoding.GetBytes(new[] { current })[0]; + index++; + } + } + } + else + { + if (index < 50) + { + if (current == 'æ') + { + buffer[index] = 0x1B; + } + else if (current == 'ø') + { + buffer[index] = 0x1C; + } + else if (current == 'å') + { + buffer[index] = 0x1D; + } + else if (current == 'Æ') + { + buffer[index] = 0x5B; + } + else if (current == 'Ø') + { + buffer[index] = 0x5C; + } + else if (current == 'Å') + { + buffer[index] = 0x5D; + } + + // ăĂ şŞ ţŢ (romanian) + else if (current == 'ă') + { + AddTwo(buffer, ref index, 0x89, 0x61); + } + else if (current == 'Ă') + { + AddTwo(buffer, ref index, 0x89, 0x41); + } + else if (current == 'ş') + { + AddTwo(buffer, ref index, 0x87, 0x73); + } + else if (current == 'Ş') + { + AddTwo(buffer, ref index, 0x87, 0x53); + } + else if (current == 'ţ') + { + AddTwo(buffer, ref index, 0x87, 0x74); + } + else if (current == 'Ţ') + { + AddTwo(buffer, ref index, 0x87, 0x54); + } + + // Next mapping of diacritics is reverse engineered, + // and currently only maps characters from latin alphabets according to https://en.wikipedia.org/wiki/Latin_alphabets + + // capitals with accent grave + else if (current == 'À') + { + AddTwo(buffer, ref index, 0x81, 0x41); + } + else if (current == 'È') + { + AddTwo(buffer, ref index, 0x81, 0x45); + } + else if (current == 'Ì') + { + AddTwo(buffer, ref index, 0x81, 0x49); + } + else if (current == 'Ò') + { + AddTwo(buffer, ref index, 0x81, 0x4F); + } + else if (current == 'Ù') + { + AddTwo(buffer, ref index, 0x81, 0x55); + } + else if (current == 'Ẁ') + { + AddTwo(buffer, ref index, 0x81, 0x57); + } + + // lowercase with accent grave + else if (current == 'à') + { + AddTwo(buffer, ref index, 0x81, 0x61); + } + else if (current == 'è') + { + AddTwo(buffer, ref index, 0x81, 0x65); + } + else if (current == 'ì') + { + AddTwo(buffer, ref index, 0x81, 0x69); + } + else if (current == 'ò') + { + AddTwo(buffer, ref index, 0x81, 0x6F); + } + else if (current == 'ù') + { + AddTwo(buffer, ref index, 0x81, 0x75); + } + else if (current == 'ẁ') + { + AddTwo(buffer, ref index, 0x81, 0x75); + } + + // capitals with accent aigu + else if (current == 'Á') + { + AddTwo(buffer, ref index, 0x82, 0x41); + } + else if (current == 'Ć') + { + AddTwo(buffer, ref index, 0x82, 0x43); + } + else if (current == 'É') + { + AddTwo(buffer, ref index, 0x82, 0x45); + } + else if (current == 'Í') + { + AddTwo(buffer, ref index, 0x82, 0x49); + } + else if (current == 'Ĺ') + { + AddTwo(buffer, ref index, 0x82, 0x4C); + } + else if (current == 'Ń') + { + AddTwo(buffer, ref index, 0x82, 0x4E); + } + else if (current == 'Ó') + { + AddTwo(buffer, ref index, 0x82, 0x4F); + } + else if (current == 'Ŕ') + { + AddTwo(buffer, ref index, 0x82, 0x52); + } + else if (current == 'Ś') + { + AddTwo(buffer, ref index, 0x82, 0x53); + } + else if (current == 'Ú') + { + AddTwo(buffer, ref index, 0x82, 0x55); + } + else if (current == 'Ẃ') + { + AddTwo(buffer, ref index, 0x82, 0x57); + } + else if (current == 'Ý') + { + AddTwo(buffer, ref index, 0x82, 0x59); + } + else if (current == 'Ź') + { + AddTwo(buffer, ref index, 0x82, 0x5A); + } + + // lowercase with accent aigu + else if (current == 'á') + { + AddTwo(buffer, ref index, 0x82, 0x61); + } + else if (current == 'ć') + { + AddTwo(buffer, ref index, 0x82, 0x63); + } + else if (current == 'é') + { + AddTwo(buffer, ref index, 0x82, 0x65); + } + else if (current == 'í') + { + AddTwo(buffer, ref index, 0x82, 0x69); + } + else if (current == 'ĺ') + { + AddTwo(buffer, ref index, 0x82, 0x6C); + } + else if (current == 'ń') + { + AddTwo(buffer, ref index, 0x82, 0x6E); + } + else if (current == 'ó') + { + AddTwo(buffer, ref index, 0x82, 0x6F); + } + else if (current == 'ŕ') + { + AddTwo(buffer, ref index, 0x82, 0x72); + } + else if (current == 'ś') + { + AddTwo(buffer, ref index, 0x82, 0x73); + } + else if (current == 'ú') + { + AddTwo(buffer, ref index, 0x82, 0x75); + } + else if (current == 'ẃ') + { + AddTwo(buffer, ref index, 0x82, 0x77); + } + else if (current == 'ý') + { + AddTwo(buffer, ref index, 0x82, 0x79); + } + else if (current == 'ź') + { + AddTwo(buffer, ref index, 0x82, 0x7A); + } + + // capitals with accent circonflexe + else if (current == 'Â') + { + AddTwo(buffer, ref index, 0x83, 0x41); + } + else if (current == 'Ĉ') + { + AddTwo(buffer, ref index, 0x83, 0x43); + } + else if (current == 'Ê') + { + AddTwo(buffer, ref index, 0x83, 0x45); + } + else if (current == 'Ĝ') + { + AddTwo(buffer, ref index, 0x83, 0x47); + } + else if (current == 'Ĥ') + { + AddTwo(buffer, ref index, 0x83, 0x48); + } + else if (current == 'Î') + { + AddTwo(buffer, ref index, 0x83, 0x49); + } + else if (current == 'Ĵ') + { + AddTwo(buffer, ref index, 0x83, 0x4A); + } + else if (current == 'Ô') + { + AddTwo(buffer, ref index, 0x83, 0x4F); + } + else if (current == 'Ŝ') + { + AddTwo(buffer, ref index, 0x83, 0x53); + } + else if (current == 'Û') + { + AddTwo(buffer, ref index, 0x83, 0x55); + } + else if (current == 'Ŵ') + { + AddTwo(buffer, ref index, 0x83, 0x57); + } + else if (current == 'Ŷ') + { + AddTwo(buffer, ref index, 0x83, 0x59); + } + + // lowercase with accent circonflexe + else if (current == 'â') + { + AddTwo(buffer, ref index, 0x83, 0x61); + } + else if (current == 'ĉ') + { + AddTwo(buffer, ref index, 0x83, 0x63); + } + else if (current == 'ê') + { + AddTwo(buffer, ref index, 0x83, 0x65); + } + else if (current == 'ĝ') + { + AddTwo(buffer, ref index, 0x83, 0x67); + } + else if (current == 'ĥ') + { + AddTwo(buffer, ref index, 0x83, 0x68); + } + else if (current == 'î') + { + AddTwo(buffer, ref index, 0x83, 0x69); + } + else if (current == 'ĵ') + { + AddTwo(buffer, ref index, 0x83, 0x6A); + } + else if (current == 'ô') + { + AddTwo(buffer, ref index, 0x83, 0x6F); + } + else if (current == 'ŝ') + { + AddTwo(buffer, ref index, 0x83, 0x73); + } + else if (current == 'û') + { + AddTwo(buffer, ref index, 0x83, 0x75); + } + else if (current == 'ŵ') + { + AddTwo(buffer, ref index, 0x83, 0x77); + } + else if (current == 'ŷ') + { + AddTwo(buffer, ref index, 0x83, 0x79); + } + + // capitals with caron + else if (current == 'Ǎ') + { + AddTwo(buffer, ref index, 0x84, 0x41); + } + else if (current == 'Č') + { + AddTwo(buffer, ref index, 0x84, 0x43); + } + else if (current == 'Ď') + { + AddTwo(buffer, ref index, 0x84, 0x44); + } + else if (current == 'Ě') + { + AddTwo(buffer, ref index, 0x84, 0x45); + } + else if (current == 'Ǧ') + { + AddTwo(buffer, ref index, 0x84, 0x47); + } + else if (current == 'Ǐ') + { + AddTwo(buffer, ref index, 0x84, 0x49); + } + else if (current == 'Ľ') + { + AddTwo(buffer, ref index, 0x84, 0x4C); + } + else if (current == 'Ň') + { + AddTwo(buffer, ref index, 0x84, 0x4E); + } + else if (current == 'Ř') + { + AddTwo(buffer, ref index, 0x84, 0x52); + } + else if (current == 'Š') + { + AddTwo(buffer, ref index, 0x84, 0x53); + } + else if (current == 'Ť') + { + AddTwo(buffer, ref index, 0x84, 0x54); + } + else if (current == 'Ž') + { + AddTwo(buffer, ref index, 0x84, 0x5A); + } + + // lowercase with caron + else if (current == 'ǎ') + { + AddTwo(buffer, ref index, 0x84, 0x61); + } + else if (current == 'č') + { + AddTwo(buffer, ref index, 0x84, 0x63); + } + else if (current == 'ď') + { + AddTwo(buffer, ref index, 0x84, 0x64); + } + else if (current == 'ě') + { + AddTwo(buffer, ref index, 0x84, 0x65); + } + else if (current == 'ǧ') + { + AddTwo(buffer, ref index, 0x84, 0x67); + } + else if (current == 'ǐ') + { + AddTwo(buffer, ref index, 0x84, 0x69); + } + else if (current == 'ľ') + { + AddTwo(buffer, ref index, 0x84, 0x6C); + } + else if (current == 'ň') + { + AddTwo(buffer, ref index, 0x84, 0x6E); + } + else if (current == 'ř') + { + AddTwo(buffer, ref index, 0x84, 0x72); + } + else if (current == 'š') + { + AddTwo(buffer, ref index, 0x84, 0x73); + } + else if (current == 'ť') + { + AddTwo(buffer, ref index, 0x84, 0x74); + } + else if (current == 'ž') + { + AddTwo(buffer, ref index, 0x84, 0x7A); + } + + // capitals with tilde + else if (current == 'Ã') + { + AddTwo(buffer, ref index, 0x85, 0x41); + } + else if (current == 'Ĩ') + { + AddTwo(buffer, ref index, 0x85, 0x49); + } + else if (current == 'Ñ') + { + AddTwo(buffer, ref index, 0x85, 0x4E); + } + else if (current == 'Õ') + { + AddTwo(buffer, ref index, 0x85, 0x4F); + } + else if (current == 'Ũ') + { + AddTwo(buffer, ref index, 0x85, 0x55); + } + + // lowercase with tilde + else if (current == 'ã') + { + AddTwo(buffer, ref index, 0x85, 0x61); + } + else if (current == 'ĩ') + { + AddTwo(buffer, ref index, 0x85, 0x69); + } + else if (current == 'ñ') + { + AddTwo(buffer, ref index, 0x85, 0x6E); + } + else if (current == 'õ') + { + AddTwo(buffer, ref index, 0x85, 0x6F); + } + else if (current == 'ũ') + { + AddTwo(buffer, ref index, 0x85, 0x75); + } + + // capitals with trema + else if (current == 'Ä') + { + AddTwo(buffer, ref index, 0x86, 0x41); + } + else if (current == 'Ë') + { + AddTwo(buffer, ref index, 0x86, 0x45); + } + else if (current == 'Ï') + { + AddTwo(buffer, ref index, 0x86, 0x49); + } + else if (current == 'Ö') + { + AddTwo(buffer, ref index, 0x86, 0x4F); + } + else if (current == 'Ü') + { + AddTwo(buffer, ref index, 0x86, 0x55); + } + else if (current == 'Ẅ') + { + AddTwo(buffer, ref index, 0x86, 0x57); + } + else if (current == 'Ÿ') + { + AddTwo(buffer, ref index, 0x86, 0x59); + } + + // lowercase with trema + else if (current == 'ä') + { + AddTwo(buffer, ref index, 0x86, 0x61); + } + else if (current == 'ë') + { + AddTwo(buffer, ref index, 0x86, 0x65); + } + else if (current == 'ï') + { + AddTwo(buffer, ref index, 0x86, 0x69); + } + else if (current == 'ö') + { + AddTwo(buffer, ref index, 0x86, 0x6F); + } + else if (current == 'ü') + { + AddTwo(buffer, ref index, 0x86, 0x75); + } + else if (current == 'ẅ') + { + AddTwo(buffer, ref index, 0x86, 0x77); + } + else if (current == 'ÿ') + { + AddTwo(buffer, ref index, 0x86, 0x79); + } + else if (i + 3 < text.Length && text.Substring(i, 3) == "") + { + buffer[index] = 0x88; + skipCount = 2; + } + else if (i + 4 <= text.Length && text.Substring(i, 4) == "") + { + buffer[index] = 0x98; + skipCount = 3; + } + else + { + buffer[index] = encoding.GetBytes(new[] { current })[0]; + } + index++; + } + } + } + + return buffer; + } + + private static string ReverseAnsi(string text) + { + var sb = new StringBuilder(); + var ansi = new StringBuilder(); + foreach (var ch in text) + { + if (ch > 255) + { + if (ansi.Length > 0) + { + sb.Append(Utilities.ReverseString(ansi.ToString())); + ansi.Clear(); + } + sb.Append(ch); + } + else + { + ansi.Append(ch); + } + } + if (ansi.Length > 0) + { + sb.Append(Utilities.ReverseString(ansi.ToString())); + } + + return sb.ToString(); + } + + private static void AddTwo(byte[] buffer, ref int index, byte b1, byte b2) + { + buffer[index] = b1; + index++; + buffer[index] = b2; + } + + private static void WriteTime(Stream fs, TimeCode timeCode) + { + double totalMilliseconds = timeCode.TotalMilliseconds; + int frames = (int)Math.Round(totalMilliseconds / (TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate)); + fs.WriteByte((byte)(frames / 256 / 256)); + fs.WriteByte((byte)(frames / 256)); + fs.WriteByte((byte)(frames % 256)); + } + + public override bool IsMine(List lines, string fileName) + { + if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) + { + var fi = new FileInfo(fileName); + if (fi.Length >= 512 && fi.Length < 1024000) // not too small or too big + { + if (!fileName.EndsWith(".890", StringComparison.Ordinal)) + { + return false; + } + + return base.IsMine(lines, fileName); + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + return "Not supported!"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + const int textLength = 51; + + subtitle.Paragraphs.Clear(); + subtitle.Header = null; + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + + _languageIdLine1 = buffer[146]; + if (_languageIdLine1 == 0) + { + _languageIdLine1 = LanguageIdEnglish; + } + + Configuration.Settings.SubtitleSettings.CurrentCavena890LanguageIdLine1 = _languageIdLine1; + + _languageIdLine2 = buffer[147]; + if (_languageIdLine2 == 0) + { + _languageIdLine2 = LanguageIdEnglish; + } + + Configuration.Settings.SubtitleSettings.CurrentCavena890LanguageIdLine2 = _languageIdLine2; + + var fontNameLine1 = Encoding.ASCII.GetString(buffer, 187, 6); + var fontNameLine2 = Encoding.ASCII.GetString(buffer, 246, 6); + + // Hebrew + if (_languageIdLine1 == LanguageIdHebrew || fontNameLine1 == "HEBNOA" || fontNameLine2 == "HEBNOA") + { + _languageIdLine1 = LanguageIdHebrew; + _languageIdLine2 = LanguageIdHebrew; + } + + // Arabic + if (_languageIdLine2 == LanguageIdArabic || fontNameLine1 == "ARABIC") + { + _languageIdLine1 = LanguageIdArabic; + _languageIdLine2 = LanguageIdArabic; + } + + // Russian + else if (_languageIdLine1 == LanguageIdRussian || fontNameLine1.StartsWith("KYRIL", StringComparison.Ordinal) || fontNameLine2.StartsWith("KYRIL", StringComparison.Ordinal)) + { + _languageIdLine1 = LanguageIdRussian; + _languageIdLine2 = LanguageIdRussian; + } + + // Chinese + else if (_languageIdLine1 == LanguageIdChineseSimplified) + { + _languageIdLine1 = LanguageIdChineseSimplified; + _languageIdLine2 = LanguageIdChineseSimplified; + } + else if (_languageIdLine1 == LanguageIdChineseTraditional || fontNameLine1 == "CCKM44" || fontNameLine2 == "CCKM44") + { + _languageIdLine1 = LanguageIdChineseTraditional; + _languageIdLine2 = LanguageIdChineseTraditional; + } + + int i = 455; + int lastNumber = -1; + while (i < buffer.Length - 20) + { + int start = i - textLength; + + int number = buffer[start - 16] * 256 + buffer[start - 15]; + + var p = new Paragraph(); + double startFrame = buffer[start - 14] * 256 * 256 + buffer[start - 13] * 256 + buffer[start - 12]; + double endFrame = buffer[start - 11] * 256 * 256 + buffer[start - 10] * 256 + buffer[start - 9]; + + byte boxType = buffer[start + textLength + 3]; + + string line1 = FixText(buffer, start, textLength, _languageIdLine1); + string line2 = FixText(buffer, start + textLength + 6, textLength, _languageIdLine2); + + if (lastNumber == number) + { + p = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1]; + string temp = (line1.TrimEnd() + Environment.NewLine + line2).TrimEnd(); + if (temp.Length > 0) + { + p.Text = temp; + } + } + else + { + subtitle.Paragraphs.Add(p); + p.StartTime.TotalMilliseconds = (TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate) * startFrame; + p.EndTime.TotalMilliseconds = (TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate) * endFrame; + p.Text = (line1.TrimEnd() + Environment.NewLine + line2).TrimEnd(); + } + if (boxType >= 0xa0 && boxType <= 0xa9 && !string.IsNullOrEmpty(p.Text)) // box + { + if (p.Text.StartsWith("{\\") && p.Text.Contains("}")) + { + p.Text = p.Text.Insert(p.Text.IndexOf('}', 3) + 1, "") + ""; + } + else + { + p.Text = "" + p.Text + ""; + } + } + + lastNumber = number; + + i += 128; + } + + subtitle.Renumber(); + } + + private static string FixText(byte[] buffer, int start, int textLength, int languageId) + { + string text; + + if (languageId == LanguageIdRussian) + { + var encoding = Encoding.GetEncoding(1252); + var sb = new StringBuilder(); + for (int i = 0; i < textLength; i++) + { + int b = buffer[start + i]; + int idx = RussianCodes.IndexOf(b); + if (idx >= 0) + { + sb.Append(RussianLetters[idx]); + } + else + { + sb.Append(encoding.GetString(buffer, start + i, 1)); + } + } + + text = sb.ToString(); + + text = text.Replace(encoding.GetString(new byte[] { 0x7F }), string.Empty); // Used to fill empty space upto 51 bytes + text = text.Replace(encoding.GetString(new byte[] { 0xBE }), string.Empty); // Unknown? + text = FixColors(text); + + if (text.Contains("")) + { + text = text.Replace("", ""); + } + + if (text.Contains("") && !text.Contains("")) + { + text += ""; + } + } + else if (languageId == LanguageIdHebrew) // (_language == "HEBNOA") + { + var encoding = Encoding.GetEncoding(1252); + var sb = new StringBuilder(); + for (int i = 0; i < textLength; i++) + { + int b = buffer[start + i]; + int idx = HebrewCodes.IndexOf(b); + if (idx >= 0) + { + sb.Append(HebrewLetters[idx]); + } + else + { + sb.Append(encoding.GetString(buffer, start + i, 1)); + } + } + + text = sb.ToString(); + + text = text.Replace(encoding.GetString(new byte[] { 0x7F }), string.Empty); // Used to fill empty space upto 51 bytes + text = text.Replace(encoding.GetString(new byte[] { 0xBE }), string.Empty); // Unknown? + text = FixColors(text); + + text = ReverseAnsi(text); + text = Utilities.ReverseStartAndEndingForRightToLeft(text); + } + else if (languageId == LanguageIdArabic) + { + var encoding = Encoding.GetEncoding(1252); + var sb = new StringBuilder(); + for (int i = 0; i < textLength; i++) + { + int b = buffer[start + i]; + if (ArabicDictionary.TryGetValue(b, out var v)) + { + sb.Append(v); + } + else if (b != 0x7F) // filler (decimal 127) + { + sb.Append(encoding.GetString(buffer, start + i, 1)); + } + } + + text = sb.ToString(); + text = text.Replace(encoding.GetString(new byte[] { 0xBE }), string.Empty); // Unknown? + text = FixColors(text).Trim(); + } + else if (languageId == LanguageIdChineseTraditional || languageId == LanguageIdChineseSimplified) // (_language == "CCKM44" || _language == "TVB000") + { + int index = start; + + while (textLength >= 1 && index + textLength < buffer.Length && (buffer[index + textLength - 1] == 0)) + { + textLength--; + } + + if (textLength > 0) + { + text = Encoding.GetEncoding(1201).GetString(buffer, index, textLength).Replace("\0", string.Empty); + } + else + { + text = string.Empty; + } + + var encoding = Encoding.Default; // which encoding?? Encoding.GetEncoding("ISO-8859-5") + text = text.Replace(encoding.GetString(new byte[] { 0x7F }), string.Empty); // Used to fill empty space upto 51 bytes + text = text.Replace(encoding.GetString(new byte[] { 0xBE }), string.Empty); // Unknown? + text = FixColors(text); + text = text.Replace(encoding.GetString(new byte[] { 0x88 }), ""); + text = text.Replace(encoding.GetString(new byte[] { 0x98 }), ""); + + if (text.Contains("")) + { + text = text.Replace("", ""); + } + + if (text.Contains("") && !text.Contains("")) + { + text += ""; + } + } + else + { + var encoding = Encoding.GetEncoding(1252); + text = encoding.GetString(buffer, start, textLength).Replace("\0", string.Empty); + + text = text.Replace(encoding.GetString(new byte[] { 0x7F }), string.Empty); // Used to fill empty space upto 51 bytes + text = text.Replace(encoding.GetString(new byte[] { 0xBE }), string.Empty); // Unknown? + text = FixColors(text); + + text = text.Replace(encoding.GetString(new byte[] { 0x1B }), "æ"); + text = text.Replace(encoding.GetString(new byte[] { 0x1C }), "ø"); + text = text.Replace(encoding.GetString(new byte[] { 0x1D }), "å"); + text = text.Replace(encoding.GetString(new byte[] { 0x1E }), "Æ"); + text = text.Replace(encoding.GetString(new byte[] { 0x1F }), "Ø"); + + text = text.Replace(encoding.GetString(new byte[] { 0x5B }), "Æ"); + text = text.Replace(encoding.GetString(new byte[] { 0x5C }), "Ø"); + text = text.Replace(encoding.GetString(new byte[] { 0x5D }), "Å"); + + // capitals with accent grave + text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x41 }), "À"); + text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x45 }), "È"); + text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x49 }), "Ì"); + text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x4f }), "Ò"); + text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x55 }), "Ù"); + + // lowercase with accent grave + text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x61 }), "à"); + text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x65 }), "è"); + text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x69 }), "ì"); + text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x6F }), "ò"); + text = text.Replace(encoding.GetString(new byte[] { 0x81, 0x75 }), "ù"); + + // capitals with accent aigu + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x41 }), "Á"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x43 }), "Ć"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x45 }), "É"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x49 }), "Í"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x4C }), "Ĺ"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x4E }), "Ń"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x4F }), "Ó"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x52 }), "Ŕ"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x53 }), "Ś"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x55 }), "Ú"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x57 }), "Ẃ"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x59 }), "Ý"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x5A }), "Ź"); + + // lowercase with accent aigu + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x61 }), "á"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x63 }), "ć"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x65 }), "é"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x69 }), "í"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x6C }), "ĺ"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x6E }), "ń"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x6F }), "ó"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x72 }), "ŕ"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x73 }), "ś"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x75 }), "ú"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x77 }), "ẃ"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x79 }), "ý"); + text = text.Replace(encoding.GetString(new byte[] { 0x82, 0x7A }), "ź"); + + // capitals with accent circonflexe + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x41 }), "Â"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x43 }), "Ĉ"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x45 }), "Ê"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x47 }), "Ĝ"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x48 }), "Ĥ"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x49 }), "Î"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x4A }), "Ĵ"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x4F }), "Ô"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x53 }), "Ŝ"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x55 }), "Û"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x57 }), "Ŵ"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x59 }), "Ŷ"); + + // lowercase with accent circonflexe + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x61 }), "â"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x63 }), "ĉ"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x65 }), "ê"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x67 }), "ĝ"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x68 }), "ĥ"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x69 }), "î"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x6A }), "ĵ"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x6F }), "ô"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x73 }), "ŝ"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x75 }), "û"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x77 }), "ŵ"); + text = text.Replace(encoding.GetString(new byte[] { 0x83, 0x79 }), "ŷ"); + + // capitals with caron + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x41 }), "Ǎ"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x43 }), "Č"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x44 }), "Ď"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x45 }), "Ě"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x47 }), "Ǧ"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x49 }), "Ǐ"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x4C }), "Ľ"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x4E }), "Ň"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x52 }), "Ř"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x53 }), "Š"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x54 }), "Ť"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x5A }), "Ž"); + + // lowercase with caron + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x61 }), "ǎ"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x63 }), "č"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x64 }), "ď"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x65 }), "ě"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x67 }), "ǧ"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x69 }), "ǐ"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x6C }), "ľ"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x6E }), "ň"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x72 }), "ř"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x73 }), "š"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x74 }), "ť"); + text = text.Replace(encoding.GetString(new byte[] { 0x84, 0x7A }), "ž"); + + // capitals with tilde + text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x41 }), "Ã"); + text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x49 }), "Ĩ"); + text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x4E }), "Ñ"); + text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x4F }), "Õ"); + text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x55 }), "Ũ"); + + // lowercase with tilde + text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x61 }), "ã"); + text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x69 }), "ĩ"); + text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x6E }), "ñ"); + text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x6F }), "õ"); + text = text.Replace(encoding.GetString(new byte[] { 0x85, 0x75 }), "ũ"); + + // capitals with trema + text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x41 }), "Ä"); + text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x45 }), "Ë"); + text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x49 }), "Ï"); + text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x4F }), "Ö"); + text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x55 }), "Ü"); + text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x59 }), "Ÿ"); + + // lowercase with trema + text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x61 }), "ä"); + text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x65 }), "ë"); + text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x69 }), "ï"); + text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x6F }), "ö"); + text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x75 }), "ü"); + text = text.Replace(encoding.GetString(new byte[] { 0x86, 0x79 }), "ÿ"); + + // with ring + text = text.Replace(encoding.GetString(new byte[] { 0x8C, 0x61 }), "å"); + text = text.Replace(encoding.GetString(new byte[] { 0x8C, 0x41 }), "Å"); + + text = text.Replace(encoding.GetString(new byte[] { 0x88 }), ""); + text = text.Replace(encoding.GetString(new byte[] { 0x98 }), ""); + + // ăĂ şŞ ţŢ (romanian) + text = text.Replace(encoding.GetString(new byte[] { 0x89, 0x61 }), "ă"); + text = text.Replace(encoding.GetString(new byte[] { 0x89, 0x41 }), "Ă"); + text = text.Replace(encoding.GetString(new byte[] { 0x87, 0x73 }), "ş"); + text = text.Replace(encoding.GetString(new byte[] { 0x87, 0x53 }), "Ş"); + text = text.Replace(encoding.GetString(new byte[] { 0x87, 0x74 }), "ţ"); + text = text.Replace(encoding.GetString(new byte[] { 0x87, 0x54 }), "Ţ"); + + if (text.Contains("")) + { + text = text.Replace("", ""); + } + + if (text.Contains("") && !text.Contains("")) + { + text += ""; + } + } + return text; + } + + private static string FixColors(string text) + { + Encoding encoding = Encoding.GetEncoding(1252); + bool fontColorOn = false; + var sb = new StringBuilder(); + for (int i = 0; i < text.Length; i++) + { + var s = text.Substring(i, 1); + if (s == encoding.GetString(new byte[] { 0xf1 })) + { + if (fontColorOn) + { + sb.Append(""); // white + } + sb.Append(""); // red + fontColorOn = true; + } + else if (s == encoding.GetString(new byte[] { 0xf2 })) + { + if (fontColorOn) + { + sb.Append(""); // white + } + sb.Append(""); // green + fontColorOn = true; + } + else if (s == encoding.GetString(new byte[] { 0xf3 })) + { + if (fontColorOn) + { + sb.Append(""); // white + } + sb.Append(""); // yellow + fontColorOn = true; + } + else if (s == encoding.GetString(new byte[] { 0xf4 })) + { + if (fontColorOn) + { + sb.Append(""); // white + } + sb.Append(""); // purple + fontColorOn = true; + } + else if (s == encoding.GetString(new byte[] { 0xf5 })) + { + if (fontColorOn) + { + sb.Append(""); // white + } + sb.Append(""); // magenta + fontColorOn = true; + } + else if (s == encoding.GetString(new byte[] { 0xf6 })) + { + if (fontColorOn) + { + sb.Append(""); // white + } + sb.Append(""); // cyan + fontColorOn = true; + } + else if (s == encoding.GetString(new byte[] { 0xf7 })) + { + if (fontColorOn) + { + sb.Append(""); // white + fontColorOn = false; + } + } + else if (s == encoding.GetString(new byte[] { 0xf8 })) + { + sb.Append(""); // orange + fontColorOn = true; + } + else + { + sb.Append(s); + } + } + if (fontColorOn) + { + sb.Append(""); // white + } + return sb.ToString(); + } + + } +} diff --git a/libse/SubtitleFormats/CheetahCaption.cs b/src/libse/SubtitleFormats/CheetahCaption.cs similarity index 97% rename from libse/SubtitleFormats/CheetahCaption.cs rename to src/libse/SubtitleFormats/CheetahCaption.cs index 642f4e5ac..03c334d3f 100644 --- a/libse/SubtitleFormats/CheetahCaption.cs +++ b/src/libse/SubtitleFormats/CheetahCaption.cs @@ -1,367 +1,367 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class CheetahCaption : SubtitleFormat - { - private static readonly Dictionary DicCodeLatin = new Dictionary - { - [0x81] = '♪', - [0x82] = 'á', - [0x83] = 'é', - [0x84] = 'í', - [0x85] = 'ó', - [0x86] = 'ú', - [0x87] = 'â', - [0x88] = 'ê', - [0x89] = 'î', - [0x8A] = 'ô', - [0x8B] = 'û', - [0x8C] = 'à', - [0x8D] = 'è', - [0x8E] = 'Ñ', - [0x8F] = 'ñ', - [0x90] = 'ç', - [0x91] = '¢', - [0x92] = '£', - [0x93] = '¿', - [0x94] = '½', - [0x95] = '®', - }; - - public override string Extension => ".cap"; - - public const string NameOfFormat = "Cheetah Caption"; - - public override string Name => NameOfFormat; - - public static void Save(string fileName, Subtitle subtitle) - { - using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) - { - byte[] buffer = { 0xEA, 0x22, 1, 0 }; // header - fs.Write(buffer, 0, buffer.Length); - - int numberOfLines = subtitle.Paragraphs.Count; - fs.WriteByte((byte)(numberOfLines % 256)); // paragraphs - low byte - fs.WriteByte((byte)(numberOfLines / 256)); // paragraphs - high byte - - buffer = new byte[] { 9, 0xA8, 0xAF, 0x4F }; // ? - fs.Write(buffer, 0, buffer.Length); - - for (int i = 0; i < 118; i++) - { - fs.WriteByte(0); - } - - var dictionaryLatinCode = DicCodeLatin.ToLookup(pair => pair.Value, pair => pair.Key); - - // paragraphs - for (int index = 0; index < subtitle.Paragraphs.Count; index++) - { - var p = subtitle.Paragraphs[index]; - var next = subtitle.GetParagraphOrDefault(index + 1); - string text = p.Text; - - var bufferShort = new byte[] - { - 0, - 0, - 3, // justification, 1=left, 2=right, 3=center - 0xE, //horizontal position, 1=top, F=bottom - 0x10 //horizontal position, 3=left, 0x10=center, 0x19=right - }; - - //styles + ? - buffer = new byte[] - { - 0x12, - 1, - 0, - 0, - 0, - 0, - 3, // justification, 1=left, 2=right, 3=center - 0xF, //horizontal position, 1=top, F=bottom - 0x10 //horizontal position, 3=left, 0x10=center, 0x19=right - }; - - //Normal : 12 01 00 00 00 00 03 0F 10 - //Right-top : 12 01 00 00 00 00 03 01 1C - //Top : 12 01 00 00 00 00 03 01 10 - //Left-top : 12 01 00 00 00 00 03 01 05 - //Left : 12 01 00 00 00 00 03 0F 0A - //Right : 12 01 00 00 00 00 03 0F 1E - //Left : 12 03 00 00 00 00 03 0F 07 - - if (text.StartsWith("{\\an7}", StringComparison.Ordinal) || text.StartsWith("{\\an8}", StringComparison.Ordinal) || text.StartsWith("{\\an9}", StringComparison.Ordinal)) - { - buffer[7] = 1; // align top (vertical) - bufferShort[3] = 1; // align top (vertical) - } - else if (text.StartsWith("{\\an4}", StringComparison.Ordinal) || text.StartsWith("{\\an5}", StringComparison.Ordinal) || text.StartsWith("{\\an6}", StringComparison.Ordinal)) - { - buffer[7] = 8; // center (vertical) - bufferShort[3] = 8; // align top (vertical) - } - - if (text.StartsWith("{\\an7}", StringComparison.Ordinal) || text.StartsWith("{\\an4}", StringComparison.Ordinal) || text.StartsWith("{\\an1}", StringComparison.Ordinal)) - { - buffer[8] = 2; // align left (horizontal) - bufferShort[4] = 2; // align left (horizontal) - } - else if (text.StartsWith("{\\an9}", StringComparison.Ordinal) || text.StartsWith("{\\an6}", StringComparison.Ordinal) || text.StartsWith("{\\an3}", StringComparison.Ordinal)) - { - buffer[8] = 0x1e; // align right (vertical) - bufferShort[4] = 0x1e; // align right (vertical) - } - - int startTag = text.IndexOf('}'); - if (text.StartsWith("{\\", StringComparison.Ordinal) && startTag > 0 && startTag < 10) - { - text = text.Remove(0, startTag + 1); - } - - var textBytes = new List(); - var italic = p.Text.StartsWith("", StringComparison.Ordinal) && p.Text.EndsWith("", StringComparison.Ordinal); - text = HtmlUtil.RemoveHtmlTags(text); - int j = 0; - if (italic) - { - textBytes.Add(0xd0); - } - - var encoding = Encoding.GetEncoding(1252); - while (j < text.Length) - { - if (text.Substring(j).StartsWith(Environment.NewLine, StringComparison.Ordinal)) - { - j += Environment.NewLine.Length; - textBytes.Add(0); - textBytes.Add(0); - textBytes.Add(0); - textBytes.Add(0); - if (italic) - { - textBytes.Add(0xd0); - } - } - else - { - if (dictionaryLatinCode.Contains(text[j])) - { - textBytes.AddRange(dictionaryLatinCode[text[j]]); - } - else - { - textBytes.Add(encoding.GetBytes(new[] { text[j] })[0]); - } - - j++; - } - } - - int length = textBytes.Count + 20; - long end = fs.Position + length; - if (Configuration.Settings.SubtitleSettings.CheetahCaptionAlwayWriteEndTime || next == null || next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds >= 1500) - { - fs.WriteByte((byte)length); - - fs.WriteByte(p.Text.Trim().Contains(Environment.NewLine) ? (byte)0x62 : (byte)0x61); - - WriteTime(fs, p.StartTime); - WriteTime(fs, p.EndTime); - fs.Write(buffer, 0, buffer.Length); // styles - } - else - { - length = textBytes.Count + 20 - (buffer.Length - bufferShort.Length); - end = fs.Position + length; - fs.WriteByte((byte)length); - - fs.WriteByte(p.Text.Trim().Contains(Environment.NewLine) ? (byte)0x42 : (byte)0x41); - - WriteTime(fs, p.StartTime); - fs.WriteByte(2); - fs.WriteByte(1); - fs.WriteByte(0); - fs.WriteByte(0); - fs.Write(bufferShort, 0, bufferShort.Length); // styles - } - - foreach (byte b in textBytes) // text - { - fs.WriteByte(b); - } - - while (end > fs.Position) - { - fs.WriteByte(0); - } - } - } - } - - private static void WriteTime(Stream fs, TimeCode timeCode) - { - fs.WriteByte((byte)timeCode.Hours); - fs.WriteByte((byte)timeCode.Minutes); - fs.WriteByte((byte)timeCode.Seconds); - fs.WriteByte((byte)MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds)); - } - - public override bool IsMine(List lines, string fileName) - { - if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) - { - var fi = new FileInfo(fileName); - if (fi.Length >= 200 && fi.Length < 1024000) // not too small or too big - { - if (fileName.EndsWith(".cap", StringComparison.OrdinalIgnoreCase)) - { - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - for (int i = 0; i < buffer.Length - 20; i++) - { - if (buffer[i + 0] == 0xEA && - buffer[i + 1] == 0x22 && - buffer[i + 2] <= 3) - { - return true; - } - } - } - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) => "Not supported!"; - - private static TimeCode DecodeTimestamp(byte[] buffer, int index) - { - return new TimeCode(buffer[index], buffer[index + 1], buffer[index + 2], FramesToMillisecondsMax999(buffer[index + 3])); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - subtitle.Paragraphs.Clear(); - subtitle.Header = null; - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - - int i = 128; - Paragraph last = null; - var sb = new StringBuilder(); - while (i < buffer.Length - 16) - { - var p = new Paragraph(); - int length = buffer[i]; - - int usedBytes = 20; - - p.StartTime = DecodeTimestamp(buffer, i + 2); - p.EndTime = DecodeTimestamp(buffer, i + 6); - if (p.EndTime.Hours == 2 && p.EndTime.Minutes == 1 && p.EndTime.Seconds == 0 && p.EndTime.Milliseconds == 0 && - (p.Duration.TotalMilliseconds < 0 || p.Duration.TotalMilliseconds > 5000)) - { - usedBytes = 20 - 4; - } - - int textLength = length - usedBytes; - int start = usedBytes - 1; - for (int j = 0; j < 4; j++) - { - if (buffer[i + start - 1] > 0x10) - { - start--; - textLength++; - } - } - - if (textLength > 0 && buffer.Length >= i + textLength) - { - if (last != null && last.EndTime.TotalMilliseconds > p.StartTime.TotalMilliseconds) - { - last.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - - sb.Clear(); - int j = 0; - bool italics = false; - var encoding = Encoding.GetEncoding(1252); - while (j < textLength) - { - int index = i + start + j; - if (buffer[index] == 0) - { - if (italics) - { - sb.Append(""); - } - - italics = false; - if (!sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal)) - { - sb.AppendLine(); - } - } - else if (DicCodeLatin.ContainsKey(buffer[index])) - { - sb.Append(DicCodeLatin[buffer[index]]); - } - else if (buffer[index] >= 0xC0 || buffer[index] <= 0x14) // codes/styles? - { - if (buffer[index] == 0xd0) // italics - { - italics = true; - sb.Append(""); - } - } - else - { - sb.Append(encoding.GetString(buffer, index, 1)); - } - j++; - } - if (italics) - { - sb.Append(""); - } - - p.Text = sb.ToString().Trim(); - p.Text = p.Text.Replace("" + Environment.NewLine + "", Environment.NewLine); - - subtitle.Paragraphs.Add(p); - last = p; - } - if (length == 0) - { - length++; - } - - i += length; - } - if (last != null && (last.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds || last.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)) - { - last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(last.Text); - } - - for (var index = 0; index < subtitle.Paragraphs.Count - 1; index++) - { - var current = subtitle.Paragraphs[index]; - var next = subtitle.Paragraphs[index + 1]; - if (current.EndTime.Hours == 2 && current.EndTime.Minutes == 1 && current.EndTime.Seconds == 0 && current.EndTime.Milliseconds == 0 && - (current.Duration.TotalMilliseconds < 0 || current.Duration.TotalMilliseconds > 5000)) - { - current.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - - subtitle.Renumber(); - } - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class CheetahCaption : SubtitleFormat + { + private static readonly Dictionary DicCodeLatin = new Dictionary + { + [0x81] = '♪', + [0x82] = 'á', + [0x83] = 'é', + [0x84] = 'í', + [0x85] = 'ó', + [0x86] = 'ú', + [0x87] = 'â', + [0x88] = 'ê', + [0x89] = 'î', + [0x8A] = 'ô', + [0x8B] = 'û', + [0x8C] = 'à', + [0x8D] = 'è', + [0x8E] = 'Ñ', + [0x8F] = 'ñ', + [0x90] = 'ç', + [0x91] = '¢', + [0x92] = '£', + [0x93] = '¿', + [0x94] = '½', + [0x95] = '®', + }; + + public override string Extension => ".cap"; + + public const string NameOfFormat = "Cheetah Caption"; + + public override string Name => NameOfFormat; + + public static void Save(string fileName, Subtitle subtitle) + { + using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) + { + byte[] buffer = { 0xEA, 0x22, 1, 0 }; // header + fs.Write(buffer, 0, buffer.Length); + + int numberOfLines = subtitle.Paragraphs.Count; + fs.WriteByte((byte)(numberOfLines % 256)); // paragraphs - low byte + fs.WriteByte((byte)(numberOfLines / 256)); // paragraphs - high byte + + buffer = new byte[] { 9, 0xA8, 0xAF, 0x4F }; // ? + fs.Write(buffer, 0, buffer.Length); + + for (int i = 0; i < 118; i++) + { + fs.WriteByte(0); + } + + var dictionaryLatinCode = DicCodeLatin.ToLookup(pair => pair.Value, pair => pair.Key); + + // paragraphs + for (int index = 0; index < subtitle.Paragraphs.Count; index++) + { + var p = subtitle.Paragraphs[index]; + var next = subtitle.GetParagraphOrDefault(index + 1); + string text = p.Text; + + var bufferShort = new byte[] + { + 0, + 0, + 3, // justification, 1=left, 2=right, 3=center + 0xE, //horizontal position, 1=top, F=bottom + 0x10 //horizontal position, 3=left, 0x10=center, 0x19=right + }; + + //styles + ? + buffer = new byte[] + { + 0x12, + 1, + 0, + 0, + 0, + 0, + 3, // justification, 1=left, 2=right, 3=center + 0xF, //horizontal position, 1=top, F=bottom + 0x10 //horizontal position, 3=left, 0x10=center, 0x19=right + }; + + //Normal : 12 01 00 00 00 00 03 0F 10 + //Right-top : 12 01 00 00 00 00 03 01 1C + //Top : 12 01 00 00 00 00 03 01 10 + //Left-top : 12 01 00 00 00 00 03 01 05 + //Left : 12 01 00 00 00 00 03 0F 0A + //Right : 12 01 00 00 00 00 03 0F 1E + //Left : 12 03 00 00 00 00 03 0F 07 + + if (text.StartsWith("{\\an7}", StringComparison.Ordinal) || text.StartsWith("{\\an8}", StringComparison.Ordinal) || text.StartsWith("{\\an9}", StringComparison.Ordinal)) + { + buffer[7] = 1; // align top (vertical) + bufferShort[3] = 1; // align top (vertical) + } + else if (text.StartsWith("{\\an4}", StringComparison.Ordinal) || text.StartsWith("{\\an5}", StringComparison.Ordinal) || text.StartsWith("{\\an6}", StringComparison.Ordinal)) + { + buffer[7] = 8; // center (vertical) + bufferShort[3] = 8; // align top (vertical) + } + + if (text.StartsWith("{\\an7}", StringComparison.Ordinal) || text.StartsWith("{\\an4}", StringComparison.Ordinal) || text.StartsWith("{\\an1}", StringComparison.Ordinal)) + { + buffer[8] = 2; // align left (horizontal) + bufferShort[4] = 2; // align left (horizontal) + } + else if (text.StartsWith("{\\an9}", StringComparison.Ordinal) || text.StartsWith("{\\an6}", StringComparison.Ordinal) || text.StartsWith("{\\an3}", StringComparison.Ordinal)) + { + buffer[8] = 0x1e; // align right (vertical) + bufferShort[4] = 0x1e; // align right (vertical) + } + + int startTag = text.IndexOf('}'); + if (text.StartsWith("{\\", StringComparison.Ordinal) && startTag > 0 && startTag < 10) + { + text = text.Remove(0, startTag + 1); + } + + var textBytes = new List(); + var italic = p.Text.StartsWith("", StringComparison.Ordinal) && p.Text.EndsWith("", StringComparison.Ordinal); + text = HtmlUtil.RemoveHtmlTags(text); + int j = 0; + if (italic) + { + textBytes.Add(0xd0); + } + + var encoding = Encoding.GetEncoding(1252); + while (j < text.Length) + { + if (text.Substring(j).StartsWith(Environment.NewLine, StringComparison.Ordinal)) + { + j += Environment.NewLine.Length; + textBytes.Add(0); + textBytes.Add(0); + textBytes.Add(0); + textBytes.Add(0); + if (italic) + { + textBytes.Add(0xd0); + } + } + else + { + if (dictionaryLatinCode.Contains(text[j])) + { + textBytes.AddRange(dictionaryLatinCode[text[j]]); + } + else + { + textBytes.Add(encoding.GetBytes(new[] { text[j] })[0]); + } + + j++; + } + } + + int length = textBytes.Count + 20; + long end = fs.Position + length; + if (Configuration.Settings.SubtitleSettings.CheetahCaptionAlwayWriteEndTime || next == null || next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds >= 1500) + { + fs.WriteByte((byte)length); + + fs.WriteByte(p.Text.Trim().Contains(Environment.NewLine) ? (byte)0x62 : (byte)0x61); + + WriteTime(fs, p.StartTime); + WriteTime(fs, p.EndTime); + fs.Write(buffer, 0, buffer.Length); // styles + } + else + { + length = textBytes.Count + 20 - (buffer.Length - bufferShort.Length); + end = fs.Position + length; + fs.WriteByte((byte)length); + + fs.WriteByte(p.Text.Trim().Contains(Environment.NewLine) ? (byte)0x42 : (byte)0x41); + + WriteTime(fs, p.StartTime); + fs.WriteByte(2); + fs.WriteByte(1); + fs.WriteByte(0); + fs.WriteByte(0); + fs.Write(bufferShort, 0, bufferShort.Length); // styles + } + + foreach (byte b in textBytes) // text + { + fs.WriteByte(b); + } + + while (end > fs.Position) + { + fs.WriteByte(0); + } + } + } + } + + private static void WriteTime(Stream fs, TimeCode timeCode) + { + fs.WriteByte((byte)timeCode.Hours); + fs.WriteByte((byte)timeCode.Minutes); + fs.WriteByte((byte)timeCode.Seconds); + fs.WriteByte((byte)MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds)); + } + + public override bool IsMine(List lines, string fileName) + { + if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) + { + var fi = new FileInfo(fileName); + if (fi.Length >= 200 && fi.Length < 1024000) // not too small or too big + { + if (fileName.EndsWith(".cap", StringComparison.OrdinalIgnoreCase)) + { + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + for (int i = 0; i < buffer.Length - 20; i++) + { + if (buffer[i + 0] == 0xEA && + buffer[i + 1] == 0x22 && + buffer[i + 2] <= 3) + { + return true; + } + } + } + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) => "Not supported!"; + + private static TimeCode DecodeTimestamp(byte[] buffer, int index) + { + return new TimeCode(buffer[index], buffer[index + 1], buffer[index + 2], FramesToMillisecondsMax999(buffer[index + 3])); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + subtitle.Paragraphs.Clear(); + subtitle.Header = null; + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + + int i = 128; + Paragraph last = null; + var sb = new StringBuilder(); + while (i < buffer.Length - 16) + { + var p = new Paragraph(); + int length = buffer[i]; + + int usedBytes = 20; + + p.StartTime = DecodeTimestamp(buffer, i + 2); + p.EndTime = DecodeTimestamp(buffer, i + 6); + if (p.EndTime.Hours == 2 && p.EndTime.Minutes == 1 && p.EndTime.Seconds == 0 && p.EndTime.Milliseconds == 0 && + (p.Duration.TotalMilliseconds < 0 || p.Duration.TotalMilliseconds > 5000)) + { + usedBytes = 20 - 4; + } + + int textLength = length - usedBytes; + int start = usedBytes - 1; + for (int j = 0; j < 4; j++) + { + if (buffer[i + start - 1] > 0x10) + { + start--; + textLength++; + } + } + + if (textLength > 0 && buffer.Length >= i + textLength) + { + if (last != null && last.EndTime.TotalMilliseconds > p.StartTime.TotalMilliseconds) + { + last.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + + sb.Clear(); + int j = 0; + bool italics = false; + var encoding = Encoding.GetEncoding(1252); + while (j < textLength) + { + int index = i + start + j; + if (buffer[index] == 0) + { + if (italics) + { + sb.Append(""); + } + + italics = false; + if (!sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal)) + { + sb.AppendLine(); + } + } + else if (DicCodeLatin.ContainsKey(buffer[index])) + { + sb.Append(DicCodeLatin[buffer[index]]); + } + else if (buffer[index] >= 0xC0 || buffer[index] <= 0x14) // codes/styles? + { + if (buffer[index] == 0xd0) // italics + { + italics = true; + sb.Append(""); + } + } + else + { + sb.Append(encoding.GetString(buffer, index, 1)); + } + j++; + } + if (italics) + { + sb.Append(""); + } + + p.Text = sb.ToString().Trim(); + p.Text = p.Text.Replace("" + Environment.NewLine + "", Environment.NewLine); + + subtitle.Paragraphs.Add(p); + last = p; + } + if (length == 0) + { + length++; + } + + i += length; + } + if (last != null && (last.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds || last.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)) + { + last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(last.Text); + } + + for (var index = 0; index < subtitle.Paragraphs.Count - 1; index++) + { + var current = subtitle.Paragraphs[index]; + var next = subtitle.Paragraphs[index + 1]; + if (current.EndTime.Hours == 2 && current.EndTime.Minutes == 1 && current.EndTime.Seconds == 0 && current.EndTime.Milliseconds == 0 && + (current.Duration.TotalMilliseconds < 0 || current.Duration.TotalMilliseconds > 5000)) + { + current.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + + subtitle.Renumber(); + } + } +} diff --git a/libse/SubtitleFormats/CheetahCaptionOld.cs b/src/libse/SubtitleFormats/CheetahCaptionOld.cs similarity index 97% rename from libse/SubtitleFormats/CheetahCaptionOld.cs rename to src/libse/SubtitleFormats/CheetahCaptionOld.cs index 3c4a3467a..7152e9bc7 100644 --- a/libse/SubtitleFormats/CheetahCaptionOld.cs +++ b/src/libse/SubtitleFormats/CheetahCaptionOld.cs @@ -1,99 +1,99 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class CheetahCaptionOld : SubtitleFormat - { - - public override string Extension => ".cap"; - - public const string NameOfFormat = "Cheetah Caption Old"; - - public override string Name => NameOfFormat; - - public static void Save(string fileName, Subtitle subtitle) - { - } - - public override bool IsMine(List lines, string fileName) - { - if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) - { - var fi = new FileInfo(fileName); - if (fi.Length >= 200 && fi.Length < 1024000) // not too small or too big - { - if (fileName.EndsWith(".cap", StringComparison.OrdinalIgnoreCase)) - { - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - if (buffer[0] == 0xEA && buffer[1] == 0x10) - { - var subtitle = new Subtitle(); - LoadSubtitle(subtitle, lines, fileName); - return subtitle.Paragraphs.Count > _errorCount || _errorCount > 25; - } - } - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - return "Not supported!"; - } - - private static TimeCode DecodeTimestamp(byte[] buffer, int index) - { - return new TimeCode(buffer[index], buffer[index + 1], buffer[index + 2], FramesToMillisecondsMax999(buffer[index + 3])); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - subtitle.Paragraphs.Clear(); - subtitle.Header = null; - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - int i = 0x80; - var sb = new StringBuilder(); - while (i < buffer.Length - 0xb1) - { - if (buffer[i] > 30) - { - _errorCount++; - } - sb.AppendLine(Encoding.ASCII.GetString(buffer, i + 0x1a, 38).Replace("\0", string.Empty)); - sb.Append(Encoding.ASCII.GetString(buffer, i + 0x40, 38).Replace("\0", string.Empty)); - var p = new Paragraph(DecodeTimestamp(buffer, i), DecodeTimestamp(buffer, i + 4), sb.ToString().Trim()); - subtitle.Paragraphs.Add(p); - sb.Clear(); - i += 0xb2; - } - for (int index = 0; index < subtitle.Paragraphs.Count; index++) - { - var paragraph = subtitle.Paragraphs[index]; - var next = subtitle.GetParagraphOrDefault(index + 1); - if (paragraph.Duration.TotalSeconds > 100) - { - _errorCount++; - } - if (Math.Abs(paragraph.EndTime.TotalMilliseconds) < 0.1 || paragraph.Duration.TotalMilliseconds < 0.1) - { - if (next != null) - { - paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - if (next == null || paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) - { - paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text); - } - } - } - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class CheetahCaptionOld : SubtitleFormat + { + + public override string Extension => ".cap"; + + public const string NameOfFormat = "Cheetah Caption Old"; + + public override string Name => NameOfFormat; + + public static void Save(string fileName, Subtitle subtitle) + { + } + + public override bool IsMine(List lines, string fileName) + { + if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) + { + var fi = new FileInfo(fileName); + if (fi.Length >= 200 && fi.Length < 1024000) // not too small or too big + { + if (fileName.EndsWith(".cap", StringComparison.OrdinalIgnoreCase)) + { + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + if (buffer[0] == 0xEA && buffer[1] == 0x10) + { + var subtitle = new Subtitle(); + LoadSubtitle(subtitle, lines, fileName); + return subtitle.Paragraphs.Count > _errorCount || _errorCount > 25; + } + } + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + return "Not supported!"; + } + + private static TimeCode DecodeTimestamp(byte[] buffer, int index) + { + return new TimeCode(buffer[index], buffer[index + 1], buffer[index + 2], FramesToMillisecondsMax999(buffer[index + 3])); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + subtitle.Paragraphs.Clear(); + subtitle.Header = null; + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + int i = 0x80; + var sb = new StringBuilder(); + while (i < buffer.Length - 0xb1) + { + if (buffer[i] > 30) + { + _errorCount++; + } + sb.AppendLine(Encoding.ASCII.GetString(buffer, i + 0x1a, 38).Replace("\0", string.Empty)); + sb.Append(Encoding.ASCII.GetString(buffer, i + 0x40, 38).Replace("\0", string.Empty)); + var p = new Paragraph(DecodeTimestamp(buffer, i), DecodeTimestamp(buffer, i + 4), sb.ToString().Trim()); + subtitle.Paragraphs.Add(p); + sb.Clear(); + i += 0xb2; + } + for (int index = 0; index < subtitle.Paragraphs.Count; index++) + { + var paragraph = subtitle.Paragraphs[index]; + var next = subtitle.GetParagraphOrDefault(index + 1); + if (paragraph.Duration.TotalSeconds > 100) + { + _errorCount++; + } + if (Math.Abs(paragraph.EndTime.TotalMilliseconds) < 0.1 || paragraph.Duration.TotalMilliseconds < 0.1) + { + if (next != null) + { + paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + if (next == null || paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) + { + paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text); + } + } + } + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/Chk.cs b/src/libse/SubtitleFormats/Chk.cs similarity index 97% rename from libse/SubtitleFormats/Chk.cs rename to src/libse/SubtitleFormats/Chk.cs index 881cb5514..b2f2dd765 100644 --- a/libse/SubtitleFormats/Chk.cs +++ b/src/libse/SubtitleFormats/Chk.cs @@ -1,313 +1,313 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - /// .CHK subtitle file format - 128 bytes blocks, first byte in block is id (01==text) - /// - public class Chk : SubtitleFormat - { - private readonly Encoding _codePage = Encoding.GetEncoding(850); - // private string _languageId = "DEN"; // English - - public override string Extension => ".chk"; - - public const string NameOfFormat = "CHK"; - - public override string Name => NameOfFormat; - - public override bool IsMine(List lines, string fileName) - { - if (fileName.EndsWith(".chk", StringComparison.OrdinalIgnoreCase)) - { - var buffer = FileUtil.ReadAllBytesShared(fileName); - return buffer.Length > 0 && buffer[0] == 0x1d; - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - return "Not implemented!"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - var buffer = FileUtil.ReadAllBytesShared(fileName); - int index = 256; - _errorCount = 0; - subtitle.Paragraphs.Clear(); - while (index < buffer.Length) - { - Paragraph p = ReadParagraph(buffer, index); - if (p != null) - { - subtitle.Paragraphs.Add(p); - } - - index += 128; - } - - if (subtitle.Paragraphs.Count > 1) - { - if (string.IsNullOrWhiteSpace(subtitle.Paragraphs[0].Text)) - { - subtitle.Paragraphs.RemoveAt(0); - } - - if (string.IsNullOrWhiteSpace(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].Text)) - { - subtitle.Paragraphs.RemoveAt(subtitle.Paragraphs.Count - 1); - } - } - - subtitle.Renumber(); - } - - private Queue _timeCodeQueue = new Queue(); - - private Paragraph ReadParagraph(byte[] buffer, int index) - { - if (buffer[index] == 1 && _timeCodeQueue.Count > 0) // text - { - var sb = new StringBuilder(); - int skipCount = 0; - int textLength = buffer[index + 2] - 11; - int start = index + 13; - - for (int i = 0; i <= textLength; i++) - { - if (skipCount > 0) - { - skipCount--; - } - else if (buffer[index + 13 + i] == 0xFE) - { - sb.Append(GetText(buffer, start, index + i + 13)); - start = index + 13 + i + 3; - skipCount = 2; - sb.AppendLine(); - } - else if (buffer[index + 13 + i] == 0) - { - sb.Append(GetText(buffer, start, index + i + 13)); - break; - } - if (i == textLength) - { - sb.Append(GetText(buffer, start, index + i + 13 + 1)); - } - } - - Paragraph p; - if (_timeCodeQueue.Count > 0) - { - p = _timeCodeQueue.Dequeue(); - } - else - { - p = new Paragraph(); - } - - p.Number = buffer[index + 3] * 256 + buffer[index + 4]; // Subtitle number - p.Text = sb.ToString(); - //if (p.Number == 0 && p.Text.StartsWith("LANG:", StringComparison.Ordinal) && p.Text.Length > 8) - //{ - // _languageId = p.Text.Substring(5, 3); - //} - return p; - } - - if (buffer[index] == 0x0a && _timeCodeQueue.Count > 0) - { - // ? - } - else if (buffer[index] == 0x09 && _timeCodeQueue.Count > 0) - { - // ? - } - else // time codes - { - var newTimeCodes = new List(); - for (int i = 0; i < 15; i++) - { - int start = index + 2 + (i * 8); - int totalFrameNumber = (buffer[start + 3] << 16) + (buffer[start + 5] << 8) + buffer[start + 4]; - int durationInFrames = buffer[start + 6]; - var p = new Paragraph(string.Empty, FramesToMilliseconds(totalFrameNumber), FramesToMilliseconds(totalFrameNumber + durationInFrames)); - newTimeCodes.Add(p); - } - - if (_timeCodeQueue.Count != 15 || IsSequential(newTimeCodes)) - { - _timeCodeQueue = new Queue(newTimeCodes); - } - } - return null; - } - - private static bool IsSequential(List newTimeCodes) - { - var lastMs = 0.0; - foreach (var p in newTimeCodes) - { - if (p.StartTime.TotalMilliseconds < lastMs) - { - return false; - } - lastMs = p.StartTime.TotalMilliseconds; - } - return true; - } - - private string GetText(byte[] buffer, int start, int end) - { - string text = string.Empty; - if (buffer[start] == 0x1f && buffer[start + 1] == 0x57 && buffer[start + 2] == 0x31 && buffer[start + 3] == 0x36) // W16 - { - if (end - start > 4) - { - text = Encoding.GetEncoding(950).GetString(buffer, start + 4, end - start - 4); - } - } - else - { - if (end - start > 0) - { - text = _codePage.GetString(buffer, start, end - start); - } - } - if (text.Length > 4 && text[0] == 0x1f && text[1] == 'R' && text[4] == '.' && CharUtils.IsDigit(text[2]) && CharUtils.IsDigit(text[3])) - { - text = text.Remove(0, 5); - } - - // special language codes... - text = text.Replace("ÔA", "Á"); - text = text.Replace("ÔE", "É"); - text = text.Replace("ÔI", "Í"); - text = text.Replace("ÓN", "Ñ"); - text = text.Replace("ÔO", "Ó"); - text = text.Replace("ÔU", "Ú"); - text = text.Replace("Ôa", "á"); - text = text.Replace("Ôe", "é"); - text = text.Replace("Ôi", "í"); - text = text.Replace("Ón", "ñ"); - text = text.Replace("Ôo", "ó"); - text = text.Replace("Ôu", "ú"); - - text = text.Replace("ÒA", "À"); - text = text.Replace("ÒE", "È"); - text = text.Replace("ÒU", "Ù"); - text = text.Replace("Òa", "à"); - text = text.Replace("Òe", "è"); - text = text.Replace("Òu", "ù"); - - text = text.Replace("ÕU", "Ü"); - text = text.Replace("ÕA", "Ä"); - text = text.Replace("ÕO", "Ö"); - text = text.Replace("Õu", "ü"); - text = text.Replace("Õa", "ä"); - text = text.Replace("Õo", "ö"); - - text = text.Replace("õa", "â"); - text = text.Replace("õe", "ê"); - text = text.Replace("õi", "î"); - text = text.Replace("õu", "û"); - text = text.Replace("õA", "Â"); - text = text.Replace("õE", "Ê"); - text = text.Replace("õI", "Î"); - text = text.Replace("õU", "Û"); - - return ApplyFont(text); - } - - private static string ApplyFont(string text) - { - var sb = new StringBuilder(); - string post = string.Empty; - int i = 0; - while (i < text.Length) - { - if (text[i] == 01 && i < text.Length - 4 && text[i + 1] == 0x1D && text[i + 2] == 07) - { - if (post != string.Empty) - { - sb.Append(""); - } - - sb.Append(""); - post = ""; - i += 2; - } - else if (text[i] == 01 && i < text.Length - 4 && text[i + 1] == 06) - { - if (post != string.Empty) - { - sb.Append(""); - } - - sb.Append(""); - post = ""; - i++; - } - else if (text[i] == 2) - { - if (post != string.Empty) - { - sb.Append(""); - } - - sb.Append(""); - post = ""; - } - else if (text[i] == 3) - { - if (post != string.Empty) - { - sb.Append(""); - } - - sb.Append(""); - post = ""; - } - else if (text[i] == 6) - { - if (post != string.Empty) - { - sb.Append(""); - } - - sb.Append(""); - post = ""; - } - else if (text[i] == 7) - { - if (post != string.Empty) - { - sb.Append(""); - } - - sb.Append(""); - post = ""; - } - else - { - sb.Append(text[i]); - } - i++; - } - - text = sb + post; - if (string.IsNullOrWhiteSpace(HtmlUtil.RemoveHtmlTags(text))) - { - return string.Empty; - } - - return text; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + /// + /// .CHK subtitle file format - 128 bytes blocks, first byte in block is id (01==text) + /// + public class Chk : SubtitleFormat + { + private readonly Encoding _codePage = Encoding.GetEncoding(850); + // private string _languageId = "DEN"; // English + + public override string Extension => ".chk"; + + public const string NameOfFormat = "CHK"; + + public override string Name => NameOfFormat; + + public override bool IsMine(List lines, string fileName) + { + if (fileName.EndsWith(".chk", StringComparison.OrdinalIgnoreCase)) + { + var buffer = FileUtil.ReadAllBytesShared(fileName); + return buffer.Length > 0 && buffer[0] == 0x1d; + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + return "Not implemented!"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + var buffer = FileUtil.ReadAllBytesShared(fileName); + int index = 256; + _errorCount = 0; + subtitle.Paragraphs.Clear(); + while (index < buffer.Length) + { + Paragraph p = ReadParagraph(buffer, index); + if (p != null) + { + subtitle.Paragraphs.Add(p); + } + + index += 128; + } + + if (subtitle.Paragraphs.Count > 1) + { + if (string.IsNullOrWhiteSpace(subtitle.Paragraphs[0].Text)) + { + subtitle.Paragraphs.RemoveAt(0); + } + + if (string.IsNullOrWhiteSpace(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].Text)) + { + subtitle.Paragraphs.RemoveAt(subtitle.Paragraphs.Count - 1); + } + } + + subtitle.Renumber(); + } + + private Queue _timeCodeQueue = new Queue(); + + private Paragraph ReadParagraph(byte[] buffer, int index) + { + if (buffer[index] == 1 && _timeCodeQueue.Count > 0) // text + { + var sb = new StringBuilder(); + int skipCount = 0; + int textLength = buffer[index + 2] - 11; + int start = index + 13; + + for (int i = 0; i <= textLength; i++) + { + if (skipCount > 0) + { + skipCount--; + } + else if (buffer[index + 13 + i] == 0xFE) + { + sb.Append(GetText(buffer, start, index + i + 13)); + start = index + 13 + i + 3; + skipCount = 2; + sb.AppendLine(); + } + else if (buffer[index + 13 + i] == 0) + { + sb.Append(GetText(buffer, start, index + i + 13)); + break; + } + if (i == textLength) + { + sb.Append(GetText(buffer, start, index + i + 13 + 1)); + } + } + + Paragraph p; + if (_timeCodeQueue.Count > 0) + { + p = _timeCodeQueue.Dequeue(); + } + else + { + p = new Paragraph(); + } + + p.Number = buffer[index + 3] * 256 + buffer[index + 4]; // Subtitle number + p.Text = sb.ToString(); + //if (p.Number == 0 && p.Text.StartsWith("LANG:", StringComparison.Ordinal) && p.Text.Length > 8) + //{ + // _languageId = p.Text.Substring(5, 3); + //} + return p; + } + + if (buffer[index] == 0x0a && _timeCodeQueue.Count > 0) + { + // ? + } + else if (buffer[index] == 0x09 && _timeCodeQueue.Count > 0) + { + // ? + } + else // time codes + { + var newTimeCodes = new List(); + for (int i = 0; i < 15; i++) + { + int start = index + 2 + (i * 8); + int totalFrameNumber = (buffer[start + 3] << 16) + (buffer[start + 5] << 8) + buffer[start + 4]; + int durationInFrames = buffer[start + 6]; + var p = new Paragraph(string.Empty, FramesToMilliseconds(totalFrameNumber), FramesToMilliseconds(totalFrameNumber + durationInFrames)); + newTimeCodes.Add(p); + } + + if (_timeCodeQueue.Count != 15 || IsSequential(newTimeCodes)) + { + _timeCodeQueue = new Queue(newTimeCodes); + } + } + return null; + } + + private static bool IsSequential(List newTimeCodes) + { + var lastMs = 0.0; + foreach (var p in newTimeCodes) + { + if (p.StartTime.TotalMilliseconds < lastMs) + { + return false; + } + lastMs = p.StartTime.TotalMilliseconds; + } + return true; + } + + private string GetText(byte[] buffer, int start, int end) + { + string text = string.Empty; + if (buffer[start] == 0x1f && buffer[start + 1] == 0x57 && buffer[start + 2] == 0x31 && buffer[start + 3] == 0x36) // W16 + { + if (end - start > 4) + { + text = Encoding.GetEncoding(950).GetString(buffer, start + 4, end - start - 4); + } + } + else + { + if (end - start > 0) + { + text = _codePage.GetString(buffer, start, end - start); + } + } + if (text.Length > 4 && text[0] == 0x1f && text[1] == 'R' && text[4] == '.' && CharUtils.IsDigit(text[2]) && CharUtils.IsDigit(text[3])) + { + text = text.Remove(0, 5); + } + + // special language codes... + text = text.Replace("ÔA", "Á"); + text = text.Replace("ÔE", "É"); + text = text.Replace("ÔI", "Í"); + text = text.Replace("ÓN", "Ñ"); + text = text.Replace("ÔO", "Ó"); + text = text.Replace("ÔU", "Ú"); + text = text.Replace("Ôa", "á"); + text = text.Replace("Ôe", "é"); + text = text.Replace("Ôi", "í"); + text = text.Replace("Ón", "ñ"); + text = text.Replace("Ôo", "ó"); + text = text.Replace("Ôu", "ú"); + + text = text.Replace("ÒA", "À"); + text = text.Replace("ÒE", "È"); + text = text.Replace("ÒU", "Ù"); + text = text.Replace("Òa", "à"); + text = text.Replace("Òe", "è"); + text = text.Replace("Òu", "ù"); + + text = text.Replace("ÕU", "Ü"); + text = text.Replace("ÕA", "Ä"); + text = text.Replace("ÕO", "Ö"); + text = text.Replace("Õu", "ü"); + text = text.Replace("Õa", "ä"); + text = text.Replace("Õo", "ö"); + + text = text.Replace("õa", "â"); + text = text.Replace("õe", "ê"); + text = text.Replace("õi", "î"); + text = text.Replace("õu", "û"); + text = text.Replace("õA", "Â"); + text = text.Replace("õE", "Ê"); + text = text.Replace("õI", "Î"); + text = text.Replace("õU", "Û"); + + return ApplyFont(text); + } + + private static string ApplyFont(string text) + { + var sb = new StringBuilder(); + string post = string.Empty; + int i = 0; + while (i < text.Length) + { + if (text[i] == 01 && i < text.Length - 4 && text[i + 1] == 0x1D && text[i + 2] == 07) + { + if (post != string.Empty) + { + sb.Append(""); + } + + sb.Append(""); + post = ""; + i += 2; + } + else if (text[i] == 01 && i < text.Length - 4 && text[i + 1] == 06) + { + if (post != string.Empty) + { + sb.Append(""); + } + + sb.Append(""); + post = ""; + i++; + } + else if (text[i] == 2) + { + if (post != string.Empty) + { + sb.Append(""); + } + + sb.Append(""); + post = ""; + } + else if (text[i] == 3) + { + if (post != string.Empty) + { + sb.Append(""); + } + + sb.Append(""); + post = ""; + } + else if (text[i] == 6) + { + if (post != string.Empty) + { + sb.Append(""); + } + + sb.Append(""); + post = ""; + } + else if (text[i] == 7) + { + if (post != string.Empty) + { + sb.Append(""); + } + + sb.Append(""); + post = ""; + } + else + { + sb.Append(text[i]); + } + i++; + } + + text = sb + post; + if (string.IsNullOrWhiteSpace(HtmlUtil.RemoveHtmlTags(text))) + { + return string.Empty; + } + + return text; + } + } +} diff --git a/libse/SubtitleFormats/Cmaft.cs b/src/libse/SubtitleFormats/Cmaft.cs similarity index 100% rename from libse/SubtitleFormats/Cmaft.cs rename to src/libse/SubtitleFormats/Cmaft.cs diff --git a/libse/SubtitleFormats/Csv.cs b/src/libse/SubtitleFormats/Csv.cs similarity index 97% rename from libse/SubtitleFormats/Csv.cs rename to src/libse/SubtitleFormats/Csv.cs index 7c4c747d5..4172c32cf 100644 --- a/libse/SubtitleFormats/Csv.cs +++ b/src/libse/SubtitleFormats/Csv.cs @@ -1,96 +1,96 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Csv : SubtitleFormat - { - private const string Separator = ";"; - private static readonly Regex CsvLine = new Regex(@"^""?\d+""?" + Separator + @"""?\d+""?" + Separator + @"""?\d+""?" + Separator + @"""?[^""]*""?$", RegexOptions.Compiled); - - public override string Extension => ".csv"; - - public override string Name => "Csv"; - - public override bool IsMine(List lines, string fileName) - { - int fine = 0; - int failed = 0; - foreach (string line in lines) - { - if (CsvLine.IsMatch(line)) - { - fine++; - } - else - { - failed++; - } - } - return fine > failed; - } - - public override string ToText(Subtitle subtitle, string title) - { - const string format = "{1}{0}{2}{0}{3}{0}\"{4}\""; - var sb = new StringBuilder(); - sb.AppendLine(string.Format(format, Separator, "Number", "Start time in milliseconds", "End time in milliseconds", "Text")); - foreach (Paragraph p in subtitle.Paragraphs) - { - sb.AppendLine(string.Format(format, Separator, p.Number, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds, p.Text.Replace(Environment.NewLine, "\n"))); - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - bool continuation = false; - Paragraph p = null; - foreach (string line in lines) - { - if (CsvLine.IsMatch(line)) - { - string[] parts = line.Split(Separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - if (parts.Length == 4) - { - try - { - int start = Convert.ToInt32(Utilities.FixQuotes(parts[1])); - int end = Convert.ToInt32(Utilities.FixQuotes(parts[2])); - string text = Utilities.FixQuotes(parts[3]); - p = new Paragraph(text, start, end); - subtitle.Paragraphs.Add(p); - continuation = parts[3].StartsWith('"') && !parts[3].EndsWith('"'); - } - catch - { - _errorCount++; - } - } - } - else - { - if (continuation) - { - if (p.Text.Length < 300) - { - p.Text = (p.Text + Environment.NewLine + line.TrimEnd('"')).Trim(); - } - - continuation = !line.TrimEnd().EndsWith('"'); - } - else - { - _errorCount++; - } - } - } - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Csv : SubtitleFormat + { + private const string Separator = ";"; + private static readonly Regex CsvLine = new Regex(@"^""?\d+""?" + Separator + @"""?\d+""?" + Separator + @"""?\d+""?" + Separator + @"""?[^""]*""?$", RegexOptions.Compiled); + + public override string Extension => ".csv"; + + public override string Name => "Csv"; + + public override bool IsMine(List lines, string fileName) + { + int fine = 0; + int failed = 0; + foreach (string line in lines) + { + if (CsvLine.IsMatch(line)) + { + fine++; + } + else + { + failed++; + } + } + return fine > failed; + } + + public override string ToText(Subtitle subtitle, string title) + { + const string format = "{1}{0}{2}{0}{3}{0}\"{4}\""; + var sb = new StringBuilder(); + sb.AppendLine(string.Format(format, Separator, "Number", "Start time in milliseconds", "End time in milliseconds", "Text")); + foreach (Paragraph p in subtitle.Paragraphs) + { + sb.AppendLine(string.Format(format, Separator, p.Number, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds, p.Text.Replace(Environment.NewLine, "\n"))); + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + bool continuation = false; + Paragraph p = null; + foreach (string line in lines) + { + if (CsvLine.IsMatch(line)) + { + string[] parts = line.Split(Separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + if (parts.Length == 4) + { + try + { + int start = Convert.ToInt32(Utilities.FixQuotes(parts[1])); + int end = Convert.ToInt32(Utilities.FixQuotes(parts[2])); + string text = Utilities.FixQuotes(parts[3]); + p = new Paragraph(text, start, end); + subtitle.Paragraphs.Add(p); + continuation = parts[3].StartsWith('"') && !parts[3].EndsWith('"'); + } + catch + { + _errorCount++; + } + } + } + else + { + if (continuation) + { + if (p.Text.Length < 300) + { + p.Text = (p.Text + Environment.NewLine + line.TrimEnd('"')).Trim(); + } + + continuation = !line.TrimEnd().EndsWith('"'); + } + else + { + _errorCount++; + } + } + } + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/Csv2.cs b/src/libse/SubtitleFormats/Csv2.cs similarity index 97% rename from libse/SubtitleFormats/Csv2.cs rename to src/libse/SubtitleFormats/Csv2.cs index 8e4fde18a..1c5a41e02 100644 --- a/libse/SubtitleFormats/Csv2.cs +++ b/src/libse/SubtitleFormats/Csv2.cs @@ -1,129 +1,129 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Csv2 : SubtitleFormat - { - private const string Separator = ","; - - //1,01:00:10:03,01:00:15:25,I thought I should let my sister-in-law know. - private static readonly Regex CsvLine = new Regex(@"^\d+" + Separator + @"\d\d:\d\d:\d\d:\d\d" + Separator + @"\d\d:\d\d:\d\d:\d\d" + Separator, RegexOptions.Compiled); - - public override string Extension => ".csv"; - - public override string Name => "Csv2"; - - public override bool IsMine(List lines, string fileName) - { - int fine = 0; - int failed = 0; - bool continuation = false; - foreach (string line in lines) - { - Match m = CsvLine.Match(line); - if (m.Success) - { - fine++; - string s = line.Remove(0, m.Length); - continuation = s.StartsWith('"'); - } - else if (!string.IsNullOrWhiteSpace(line)) - { - if (continuation) - { - continuation = false; - } - else - { - failed++; - } - } - } - return fine > failed; - } - - public override string ToText(Subtitle subtitle, string title) - { - const string format = "{1}{0}{2}{0}{3}{0}\"{4}\""; - var sb = new StringBuilder(); - sb.AppendLine(string.Format(format, Separator, "Number", "Start time (hh:mm:ss:ff)", "End time (hh:mm:ss:ff)", "Text")); - foreach (Paragraph p in subtitle.Paragraphs) - { - sb.AppendLine(string.Format(format, Separator, p.Number, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), p.Text.Replace(Environment.NewLine, "\n"))); - } - return sb.ToString().Trim(); - } - - private static string EncodeTimeCode(TimeCode time) - { - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - bool continuation = false; - Paragraph p = null; - foreach (string line in lines) - { - Match m = CsvLine.Match(line); - if (m.Success) - { - string[] parts = line.Substring(0, m.Length).Split(Separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - if (parts.Length == 3) - { - try - { - var start = DecodeTimeCode(parts[1]); - var end = DecodeTimeCode(parts[2]); - string text = line.Remove(0, m.Length); - continuation = text.StartsWith('"') && !text.EndsWith('"'); - text = text.Trim('"'); - p = new Paragraph(start, end, text); - subtitle.Paragraphs.Add(p); - } - catch - { - _errorCount++; - } - } - } - else if (!string.IsNullOrWhiteSpace(line)) - { - if (continuation) - { - if (p != null && p.Text.Length < 300) - { - p.Text = (p.Text + Environment.NewLine + line.TrimEnd('"')).Trim(); - } - - continuation = !line.TrimEnd().EndsWith('"'); - } - else - { - _errorCount++; - } - } - } - subtitle.Renumber(); - } - - private static TimeCode DecodeTimeCode(string part) - { - string[] parts = part.Split(new[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries); - - //00:00:07:12 - string hour = parts[0]; - string minutes = parts[1]; - string seconds = parts[2]; - string frames = parts[3]; - - return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames))); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Csv2 : SubtitleFormat + { + private const string Separator = ","; + + //1,01:00:10:03,01:00:15:25,I thought I should let my sister-in-law know. + private static readonly Regex CsvLine = new Regex(@"^\d+" + Separator + @"\d\d:\d\d:\d\d:\d\d" + Separator + @"\d\d:\d\d:\d\d:\d\d" + Separator, RegexOptions.Compiled); + + public override string Extension => ".csv"; + + public override string Name => "Csv2"; + + public override bool IsMine(List lines, string fileName) + { + int fine = 0; + int failed = 0; + bool continuation = false; + foreach (string line in lines) + { + Match m = CsvLine.Match(line); + if (m.Success) + { + fine++; + string s = line.Remove(0, m.Length); + continuation = s.StartsWith('"'); + } + else if (!string.IsNullOrWhiteSpace(line)) + { + if (continuation) + { + continuation = false; + } + else + { + failed++; + } + } + } + return fine > failed; + } + + public override string ToText(Subtitle subtitle, string title) + { + const string format = "{1}{0}{2}{0}{3}{0}\"{4}\""; + var sb = new StringBuilder(); + sb.AppendLine(string.Format(format, Separator, "Number", "Start time (hh:mm:ss:ff)", "End time (hh:mm:ss:ff)", "Text")); + foreach (Paragraph p in subtitle.Paragraphs) + { + sb.AppendLine(string.Format(format, Separator, p.Number, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), p.Text.Replace(Environment.NewLine, "\n"))); + } + return sb.ToString().Trim(); + } + + private static string EncodeTimeCode(TimeCode time) + { + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + bool continuation = false; + Paragraph p = null; + foreach (string line in lines) + { + Match m = CsvLine.Match(line); + if (m.Success) + { + string[] parts = line.Substring(0, m.Length).Split(Separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + if (parts.Length == 3) + { + try + { + var start = DecodeTimeCode(parts[1]); + var end = DecodeTimeCode(parts[2]); + string text = line.Remove(0, m.Length); + continuation = text.StartsWith('"') && !text.EndsWith('"'); + text = text.Trim('"'); + p = new Paragraph(start, end, text); + subtitle.Paragraphs.Add(p); + } + catch + { + _errorCount++; + } + } + } + else if (!string.IsNullOrWhiteSpace(line)) + { + if (continuation) + { + if (p != null && p.Text.Length < 300) + { + p.Text = (p.Text + Environment.NewLine + line.TrimEnd('"')).Trim(); + } + + continuation = !line.TrimEnd().EndsWith('"'); + } + else + { + _errorCount++; + } + } + } + subtitle.Renumber(); + } + + private static TimeCode DecodeTimeCode(string part) + { + string[] parts = part.Split(new[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries); + + //00:00:07:12 + string hour = parts[0]; + string minutes = parts[1]; + string seconds = parts[2]; + string frames = parts[3]; + + return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), FramesToMillisecondsMax999(int.Parse(frames))); + } + + } +} diff --git a/libse/SubtitleFormats/Csv3.cs b/src/libse/SubtitleFormats/Csv3.cs similarity index 97% rename from libse/SubtitleFormats/Csv3.cs rename to src/libse/SubtitleFormats/Csv3.cs index 643e01d20..c538809b1 100644 --- a/libse/SubtitleFormats/Csv3.cs +++ b/src/libse/SubtitleFormats/Csv3.cs @@ -1,195 +1,195 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Csv3 : SubtitleFormat - { - private const string Separator = ","; - - //01:00:10:03,01:00:15:25,"I thought I should let my sister-in-law know.", "" - private static readonly Regex CsvLine = new Regex(@"^\d\d:\d\d:\d\d:\d\d" + Separator + @"\d\d:\d\d:\d\d:\d\d" + Separator, RegexOptions.Compiled); - - public override string Extension => ".csv"; - - public override string Name => "Csv3"; - - public override bool IsMine(List lines, string fileName) - { - int fine = 0; - int failed = 0; - bool continuation = false; - foreach (string line in lines) - { - if (line.StartsWith("$FontName", StringComparison.Ordinal) || line.StartsWith("$ColorIndex1", StringComparison.Ordinal)) - { - return false; - } - - Match m = null; - if (line.Length > 8 && line[2] == ':') - { - m = CsvLine.Match(line); - } - - if (m != null && m.Success) - { - fine++; - string s = line.Remove(0, m.Length); - continuation = s.StartsWith('"'); - } - else if (!string.IsNullOrWhiteSpace(line)) - { - if (continuation) - { - continuation = false; - } - else - { - failed++; - } - } - } - if (failed > 20) - { - return false; - } - - return fine > failed; - } - - public override string ToText(Subtitle subtitle, string title) - { - const string format = "{1}{0}{2}{0}\"{3}\"{0}\"{4}\""; - var sb = new StringBuilder(); - sb.AppendLine(string.Format(format, Separator, "Start time (hh:mm:ss:ff)", "End time (hh:mm:ss:ff)", "Line 1", "Line 2")); - foreach (Paragraph p in subtitle.Paragraphs) - { - var arr = p.Text.Trim().SplitToLines(); - if (arr.Count > 3) - { - string s = Utilities.AutoBreakLine(p.Text); - arr = s.Trim().SplitToLines(); - } - string line1 = string.Empty; - string line2 = string.Empty; - line1 = arr[0]; - if (arr.Count > 1) - { - line2 = arr[1]; - } - - line1 = line1.Replace("\"", "\"\""); - line2 = line2.Replace("\"", "\"\""); - sb.AppendLine(string.Format(format, Separator, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), line1, line2)); - } - return sb.ToString().Trim(); - } - - private static string EncodeTimeCode(TimeCode time) - { - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - char[] splitChars = { '.', ':' }; - foreach (string line in lines) - { - Match m = CsvLine.Match(line); - if (m.Success) - { - string[] parts = line.Substring(0, m.Length).Split(Separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - if (parts.Length == 2) - { - try - { - var start = DecodeTimeCodeFrames(parts[0], splitChars); - var end = DecodeTimeCodeFrames(parts[1], splitChars); - string text = ReadText(line.Remove(0, m.Length)); - var p = new Paragraph(start, end, text); - subtitle.Paragraphs.Add(p); - } - catch - { - _errorCount++; - } - } - } - else if (!string.IsNullOrWhiteSpace(line)) - { - _errorCount++; - } - } - subtitle.Renumber(); - } - - private static string ReadText(string csv) - { - if (string.IsNullOrEmpty(csv)) - { - return string.Empty; - } - - csv = csv.Replace("\"\"", "\""); - - var sb = new StringBuilder(); - csv = csv.Trim(); - if (csv.StartsWith('"')) - { - csv = csv.Remove(0, 1); - } - - if (csv.EndsWith('"')) - { - csv = csv.Remove(csv.Length - 1, 1); - } - - bool isBreak = false; - for (int i = 0; i < csv.Length; i++) - { - var s = csv[i]; - if (s == '"' && csv.Substring(i).StartsWith("\"\"", StringComparison.Ordinal)) - { - sb.Append('"'); - } - else if (s == '"') - { - if (isBreak) - { - isBreak = false; - } - else if (i == 0 || i == csv.Length - 1 || sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal)) - { - sb.Append('"'); - } - else - { - isBreak = true; - } - } - else - { - if (isBreak && s == ' ') - { - } - else if (isBreak && s == ',') - { - sb.Append(Environment.NewLine); - } - else - { - isBreak = false; - sb.Append(s); - } - } - } - return sb.ToString().Trim(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Csv3 : SubtitleFormat + { + private const string Separator = ","; + + //01:00:10:03,01:00:15:25,"I thought I should let my sister-in-law know.", "" + private static readonly Regex CsvLine = new Regex(@"^\d\d:\d\d:\d\d:\d\d" + Separator + @"\d\d:\d\d:\d\d:\d\d" + Separator, RegexOptions.Compiled); + + public override string Extension => ".csv"; + + public override string Name => "Csv3"; + + public override bool IsMine(List lines, string fileName) + { + int fine = 0; + int failed = 0; + bool continuation = false; + foreach (string line in lines) + { + if (line.StartsWith("$FontName", StringComparison.Ordinal) || line.StartsWith("$ColorIndex1", StringComparison.Ordinal)) + { + return false; + } + + Match m = null; + if (line.Length > 8 && line[2] == ':') + { + m = CsvLine.Match(line); + } + + if (m != null && m.Success) + { + fine++; + string s = line.Remove(0, m.Length); + continuation = s.StartsWith('"'); + } + else if (!string.IsNullOrWhiteSpace(line)) + { + if (continuation) + { + continuation = false; + } + else + { + failed++; + } + } + } + if (failed > 20) + { + return false; + } + + return fine > failed; + } + + public override string ToText(Subtitle subtitle, string title) + { + const string format = "{1}{0}{2}{0}\"{3}\"{0}\"{4}\""; + var sb = new StringBuilder(); + sb.AppendLine(string.Format(format, Separator, "Start time (hh:mm:ss:ff)", "End time (hh:mm:ss:ff)", "Line 1", "Line 2")); + foreach (Paragraph p in subtitle.Paragraphs) + { + var arr = p.Text.Trim().SplitToLines(); + if (arr.Count > 3) + { + string s = Utilities.AutoBreakLine(p.Text); + arr = s.Trim().SplitToLines(); + } + string line1 = string.Empty; + string line2 = string.Empty; + line1 = arr[0]; + if (arr.Count > 1) + { + line2 = arr[1]; + } + + line1 = line1.Replace("\"", "\"\""); + line2 = line2.Replace("\"", "\"\""); + sb.AppendLine(string.Format(format, Separator, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), line1, line2)); + } + return sb.ToString().Trim(); + } + + private static string EncodeTimeCode(TimeCode time) + { + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + char[] splitChars = { '.', ':' }; + foreach (string line in lines) + { + Match m = CsvLine.Match(line); + if (m.Success) + { + string[] parts = line.Substring(0, m.Length).Split(Separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + if (parts.Length == 2) + { + try + { + var start = DecodeTimeCodeFrames(parts[0], splitChars); + var end = DecodeTimeCodeFrames(parts[1], splitChars); + string text = ReadText(line.Remove(0, m.Length)); + var p = new Paragraph(start, end, text); + subtitle.Paragraphs.Add(p); + } + catch + { + _errorCount++; + } + } + } + else if (!string.IsNullOrWhiteSpace(line)) + { + _errorCount++; + } + } + subtitle.Renumber(); + } + + private static string ReadText(string csv) + { + if (string.IsNullOrEmpty(csv)) + { + return string.Empty; + } + + csv = csv.Replace("\"\"", "\""); + + var sb = new StringBuilder(); + csv = csv.Trim(); + if (csv.StartsWith('"')) + { + csv = csv.Remove(0, 1); + } + + if (csv.EndsWith('"')) + { + csv = csv.Remove(csv.Length - 1, 1); + } + + bool isBreak = false; + for (int i = 0; i < csv.Length; i++) + { + var s = csv[i]; + if (s == '"' && csv.Substring(i).StartsWith("\"\"", StringComparison.Ordinal)) + { + sb.Append('"'); + } + else if (s == '"') + { + if (isBreak) + { + isBreak = false; + } + else if (i == 0 || i == csv.Length - 1 || sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal)) + { + sb.Append('"'); + } + else + { + isBreak = true; + } + } + else + { + if (isBreak && s == ' ') + { + } + else if (isBreak && s == ',') + { + sb.Append(Environment.NewLine); + } + else + { + isBreak = false; + sb.Append(s); + } + } + } + return sb.ToString().Trim(); + } + + } +} diff --git a/libse/SubtitleFormats/Csv4.cs b/src/libse/SubtitleFormats/Csv4.cs similarity index 100% rename from libse/SubtitleFormats/Csv4.cs rename to src/libse/SubtitleFormats/Csv4.cs diff --git a/libse/SubtitleFormats/Csv5.cs b/src/libse/SubtitleFormats/Csv5.cs similarity index 100% rename from libse/SubtitleFormats/Csv5.cs rename to src/libse/SubtitleFormats/Csv5.cs diff --git a/libse/SubtitleFormats/CsvNuendo.cs b/src/libse/SubtitleFormats/CsvNuendo.cs similarity index 100% rename from libse/SubtitleFormats/CsvNuendo.cs rename to src/libse/SubtitleFormats/CsvNuendo.cs diff --git a/libse/SubtitleFormats/DCinemaInterop.cs b/src/libse/SubtitleFormats/DCinemaInterop.cs similarity index 100% rename from libse/SubtitleFormats/DCinemaInterop.cs rename to src/libse/SubtitleFormats/DCinemaInterop.cs diff --git a/libse/SubtitleFormats/DCinemaSmpte2007.cs b/src/libse/SubtitleFormats/DCinemaSmpte2007.cs similarity index 97% rename from libse/SubtitleFormats/DCinemaSmpte2007.cs rename to src/libse/SubtitleFormats/DCinemaSmpte2007.cs index f085621ac..31f4940ef 100644 --- a/libse/SubtitleFormats/DCinemaSmpte2007.cs +++ b/src/libse/SubtitleFormats/DCinemaSmpte2007.cs @@ -1,841 +1,841 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Text; -using System.Xml; -using System.Xml.Schema; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class DCinemaSmpte2007 : SubtitleFormat - { - // - // - // urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e - // 2001, A Space Odissey - // This is a subtitle file - // 2012-06-26T12:33:59.000-00:00 - // 1 - // fr - // 25 1 - // 25 - // 00:00:00:00 - // urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391 - // - // - // Hallo - // - // - - public string Errors { get; private set; } - - private double _frameRate = 24; - - public int Version { get; set; } - - public override string Extension => ".xml"; - - public override string Name => "D-Cinema SMPTE 2007"; - - public override bool IsMine(List lines, string fileName) - { - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - string xmlAsString = sb.ToString().Trim(); - if (xmlAsString.Contains("http://www.smpte-ra.org/schemas/428-7/2010/DCST") || - xmlAsString.Contains("http://www.smpte-ra.org/schemas/428-7/2014/DCST")) - { - return false; - } - - if (xmlAsString.Contains(" 0; - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - return false; - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - Errors = null; - var ss = Configuration.Settings.SubtitleSettings; - - if (!string.IsNullOrEmpty(ss.CurrentDCinemaEditRate)) - { - string[] temp = ss.CurrentDCinemaEditRate.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - double d1, d2; - if (temp.Length == 2 && double.TryParse(temp[0], out d1) && double.TryParse(temp[1], out d2)) - { - _frameRate = d1 / d2; - } - } - - string xmlStructure = - "" + Environment.NewLine + - " urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e" + Environment.NewLine + - " " + Environment.NewLine + - " This is a subtitle file" + Environment.NewLine + - " 2012-06-26T12:33:59.000-00:00" + Environment.NewLine + - " 1" + Environment.NewLine + - " en" + Environment.NewLine + - " 25 1" + Environment.NewLine + - " 25" + Environment.NewLine + - " 00:00:00:00 " + Environment.NewLine + - " urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - xml.PreserveWhitespace = true; - var nsmgr = new XmlNamespaceManager(xml.NameTable); - nsmgr.AddNamespace("dcst", xml.DocumentElement.NamespaceURI); - - if (string.IsNullOrEmpty(ss.CurrentDCinemaMovieTitle)) - { - ss.CurrentDCinemaMovieTitle = title; - } - - if (ss.CurrentDCinemaFontSize == 0 || string.IsNullOrEmpty(ss.CurrentDCinemaFontEffect)) - { - Configuration.Settings.SubtitleSettings.InitializeDCinameSettings(true); - } - - xml.DocumentElement.SelectSingleNode("dcst:ContentTitleText", nsmgr).InnerText = ss.CurrentDCinemaMovieTitle; - if (string.IsNullOrEmpty(ss.CurrentDCinemaSubtitleId) || !ss.CurrentDCinemaSubtitleId.StartsWith("urn:uuid:")) - { - ss.CurrentDCinemaSubtitleId = "urn:uuid:" + Guid.NewGuid(); - } - - xml.DocumentElement.SelectSingleNode("dcst:Id", nsmgr).InnerText = ss.CurrentDCinemaSubtitleId; - xml.DocumentElement.SelectSingleNode("dcst:ReelNumber", nsmgr).InnerText = ss.CurrentDCinemaReelNumber; - xml.DocumentElement.SelectSingleNode("dcst:IssueDate", nsmgr).InnerText = ss.CurrentDCinemaIssueDate; - if (string.IsNullOrEmpty(ss.CurrentDCinemaLanguage)) - { - ss.CurrentDCinemaLanguage = "en"; - } - - xml.DocumentElement.SelectSingleNode("dcst:Language", nsmgr).InnerText = ss.CurrentDCinemaLanguage; - if (ss.CurrentDCinemaEditRate == null && ss.CurrentDCinemaTimeCodeRate == null) - { - if (Configuration.Settings.General.CurrentFrameRate == 24) - { - ss.CurrentDCinemaEditRate = "24 1"; - ss.CurrentDCinemaTimeCodeRate = "24"; - } - else - { - ss.CurrentDCinemaEditRate = "25 1"; - ss.CurrentDCinemaTimeCodeRate = "25"; - } - } - xml.DocumentElement.SelectSingleNode("dcst:EditRate", nsmgr).InnerText = ss.CurrentDCinemaEditRate; - xml.DocumentElement.SelectSingleNode("dcst:TimeCodeRate", nsmgr).InnerText = ss.CurrentDCinemaTimeCodeRate; - if (string.IsNullOrEmpty(ss.CurrentDCinemaStartTime)) - { - ss.CurrentDCinemaStartTime = "00:00:00:00"; - } - - xml.DocumentElement.SelectSingleNode("dcst:StartTime", nsmgr).InnerText = ss.CurrentDCinemaStartTime; - xml.DocumentElement.SelectSingleNode("dcst:LoadFont", nsmgr).InnerText = ss.CurrentDCinemaFontUri; - int fontSize = ss.CurrentDCinemaFontSize; - string loadedFontId = "Font1"; - if (!string.IsNullOrEmpty(ss.CurrentDCinemaFontId)) - { - loadedFontId = ss.CurrentDCinemaFontId; - } - - xml.DocumentElement.SelectSingleNode("dcst:LoadFont", nsmgr).Attributes["ID"].Value = loadedFontId; - xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Size"].Value = fontSize.ToString(); - xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Color"].Value = "FF" + Utilities.ColorToHex(ss.CurrentDCinemaFontColor).TrimStart('#').ToUpperInvariant(); - xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["ID"].Value = loadedFontId; - xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Effect"].Value = ss.CurrentDCinemaFontEffect; - xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["EffectColor"].Value = "FF" + Utilities.ColorToHex(ss.CurrentDCinemaFontEffectColor).TrimStart('#').ToUpperInvariant(); - - XmlNode mainListFont = xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr); - int no = 0; - foreach (Paragraph p in subtitle.Paragraphs) - { - if (p.Text != null) - { - XmlNode subNode = xml.CreateElement("dcst:Subtitle", "dcst"); - - XmlAttribute id = xml.CreateAttribute("SpotNumber"); - id.InnerText = (no + 1).ToString(); - subNode.Attributes.Append(id); - - XmlAttribute fadeUpTime = xml.CreateAttribute("FadeUpTime"); - fadeUpTime.InnerText = "00:00:00:00"; - subNode.Attributes.Append(fadeUpTime); - - XmlAttribute fadeDownTime = xml.CreateAttribute("FadeDownTime"); - fadeDownTime.InnerText = "00:00:00:00"; - subNode.Attributes.Append(fadeDownTime); - - XmlAttribute start = xml.CreateAttribute("TimeIn"); - start.InnerText = ConvertToTimeString(p.StartTime); - subNode.Attributes.Append(start); - - XmlAttribute end = xml.CreateAttribute("TimeOut"); - end.InnerText = ConvertToTimeString(p.EndTime); - subNode.Attributes.Append(end); - - bool alignLeft = p.Text.StartsWith("{\\a1}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a5}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a9}", StringComparison.Ordinal) || // sub station alpha - p.Text.StartsWith("{\\an1}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an7}", StringComparison.Ordinal); // advanced sub station alpha - - bool alignRight = p.Text.StartsWith("{\\a3}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a7}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a11}", StringComparison.Ordinal) || // sub station alpha - p.Text.StartsWith("{\\an3}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an6}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); // advanced sub station alpha - - bool alignVTop = p.Text.StartsWith("{\\a5}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a6}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a7}", StringComparison.Ordinal) || // sub station alpha - p.Text.StartsWith("{\\an7}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an8}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); // advanced sub station alpha - - bool alignVCenter = p.Text.StartsWith("{\\a9}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a10}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a11}", StringComparison.Ordinal) || // sub station alpha - p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an5}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an6}", StringComparison.Ordinal); // advanced sub station alpha - - string text = Utilities.RemoveSsaTags(p.Text); - - var lines = text.SplitToLines(); - int vPos = 1 + lines.Count * 7; - int vPosFactor = (int)Math.Round(fontSize / 7.4); - if (alignVTop) - { - vPos = Configuration.Settings.SubtitleSettings.DCinemaBottomMargin; // Bottom margin is normally 8 - } - else if (alignVCenter) - { - vPos = (int)Math.Round((lines.Count * vPosFactor * -1) / 2.0); - } - else - { - vPos = lines.Count * vPosFactor - vPosFactor + Configuration.Settings.SubtitleSettings.DCinemaBottomMargin; // Bottom margin is normally 8 - } - - bool isItalic = false; - int fontNo = 0; - Stack fontColors = new Stack(); - foreach (string line in lines) - { - XmlNode textNode = xml.CreateElement("dcst:Text", "dcst"); - - XmlAttribute vPosition = xml.CreateAttribute("Vposition"); - vPosition.InnerText = vPos.ToString(); - textNode.Attributes.Append(vPosition); - - XmlAttribute vAlign = xml.CreateAttribute("Valign"); - if (alignVTop) - { - vAlign.InnerText = "top"; - } - else if (alignVCenter) - { - vAlign.InnerText = "center"; - } - else - { - vAlign.InnerText = "bottom"; - } - - textNode.Attributes.Append(vAlign); textNode.Attributes.Append(vAlign); - - XmlAttribute hAlign = xml.CreateAttribute("Halign"); - if (alignLeft) - { - hAlign.InnerText = "left"; - } - else if (alignRight) - { - hAlign.InnerText = "right"; - } - else - { - hAlign.InnerText = "center"; - } - - textNode.Attributes.Append(hAlign); - - XmlAttribute direction = xml.CreateAttribute("Direction"); - direction.InnerText = "ltr"; - textNode.Attributes.Append(direction); - - int i = 0; - var txt = new StringBuilder(); - var html = new StringBuilder(); - XmlNode nodeTemp = xml.CreateElement("temp"); - while (i < line.Length) - { - if (!isItalic && line.Substring(i).StartsWith("")) - { - if (txt.Length > 0) - { - nodeTemp.InnerText = txt.ToString(); - html.Append(nodeTemp.InnerXml); - txt.Clear(); - } - isItalic = true; - i += 2; - } - else if (isItalic && line.Substring(i).StartsWith("")) - { - if (txt.Length > 0) - { - XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); - - XmlAttribute italic = xml.CreateAttribute("Italic"); - italic.InnerText = "yes"; - fontNode.Attributes.Append(italic); - - if (line.Length > i + 5 && line.Substring(i + 4).StartsWith("")) - { - XmlAttribute fontColor = xml.CreateAttribute("Color"); - fontColor.InnerText = fontColors.Pop(); - fontNode.Attributes.Append(fontColor); - fontNo--; - i += 7; - } - - fontNode.InnerText = HtmlUtil.RemoveHtmlTags(txt.ToString()); - html.Append(fontNode.OuterXml); - txt.Clear(); - } - isItalic = false; - i += 3; - } - else if (line.Substring(i).StartsWith("")) - { - if (txt.Length > 0) - { - XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); - - XmlAttribute fontColor = xml.CreateAttribute("Color"); - fontColor.InnerText = fontColors.Pop(); - fontNode.Attributes.Append(fontColor); - - if (line.Length > i + 9 && line.Substring(i + 7).StartsWith("")) - { - XmlAttribute italic = xml.CreateAttribute("Italic"); - italic.InnerText = "yes"; - fontNode.Attributes.Append(italic); - isItalic = false; - i += 4; - } - - fontNode.InnerText = HtmlUtil.RemoveHtmlTags(txt.ToString()); - html.Append(fontNode.OuterXml); - txt.Clear(); - } - fontNo--; - i += 6; - } - else - { - txt.Append(line[i]); - } - i++; - } - - if (fontNo > 0) - { - if (txt.Length > 0) - { - XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); - - XmlAttribute fontColor = xml.CreateAttribute("Color"); - fontColor.InnerText = fontColors.Peek(); - fontNode.Attributes.Append(fontColor); - - if (isItalic) - { - XmlAttribute italic = xml.CreateAttribute("Italic"); - italic.InnerText = "yes"; - fontNode.Attributes.Append(italic); - } - - fontNode.InnerText = HtmlUtil.RemoveHtmlTags(txt.ToString()); - html.Append(fontNode.OuterXml); - } - else if (html.Length > 0 && html.ToString().StartsWith("" + html.ToString().Replace("dcst:Font", "Font") + ""); - XmlNode fontNode = xml.CreateElement("dcst:Font"); - fontNode.InnerXml = temp.DocumentElement.SelectSingleNode("Font").InnerXml; - foreach (XmlAttribute a in temp.DocumentElement.SelectSingleNode("Font").Attributes) - { - XmlAttribute newA = xml.CreateAttribute(a.Name); - newA.InnerText = a.InnerText; - fontNode.Attributes.Append(newA); - } - - XmlAttribute fontColor = xml.CreateAttribute("Color"); - fontColor.InnerText = fontColors.Peek(); - fontNode.Attributes.Append(fontColor); - - html.Clear(); - html.Append(fontNode.OuterXml); - } - } - else if (isItalic) - { - if (txt.Length > 0) - { - XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); - - XmlAttribute italic = xml.CreateAttribute("Italic"); - italic.InnerText = "yes"; - fontNode.Attributes.Append(italic); - - fontNode.InnerText = HtmlUtil.RemoveHtmlTags(line); - html.Append(fontNode.OuterXml); - } - } - else - { - if (txt.Length > 0) - { - nodeTemp.InnerText = txt.ToString(); - html.Append(nodeTemp.InnerXml); - } - } - textNode.InnerXml = html.ToString(); - - subNode.AppendChild(textNode); - if (alignVTop) - { - vPos += vPosFactor; - } - else - { - vPos -= vPosFactor; - } - } - if (subNode.InnerXml.Length == 0) - { // Empty text is just one space - XmlNode textNode = xml.CreateElement("dcst:Text", "dcst"); - textNode.InnerXml = " "; - subNode.AppendChild(textNode); - - XmlAttribute vPosition = xml.CreateAttribute("Vposition"); - vPosition.InnerText = vPos.ToString(); - textNode.Attributes.Append(vPosition); - - XmlAttribute vAlign = xml.CreateAttribute("Valign"); - vAlign.InnerText = "bottom"; - textNode.Attributes.Append(vAlign); - } - mainListFont.AppendChild(subNode); - no++; - } - } - string result = ToUtf8XmlString(xml).Replace("encoding=\"utf-8\"", "encoding=\"UTF-8\"").Replace(" xmlns:dcst=\"dcst\"", string.Empty); - - const string res = "Nikse.SubtitleEdit.Resources.SMPTE-428-7-2007-DCST.xsd.gz"; - System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); - Stream strm = asm.GetManifestResourceStream(res); - if (strm != null) - { - try - { - var xmld = new XmlDocument(); - var rdr = new StreamReader(strm); - var zip = new GZipStream(rdr.BaseStream, CompressionMode.Decompress); - xmld.LoadXml(result); - using (var xr = XmlReader.Create(zip)) - { - xmld.Schemas.Add(null, xr); - xmld.Validate(ValidationCallBack); - } - } - catch (Exception exception) - { - Errors = "Error validating xml via SMPTE - 428 - 7 - 2007 - DCST.xsd: " + exception.Message; - } - } - return DCinemaSmpte2010.FixDcsTextSameLine(result); - } - - private void ValidationCallBack(object sender, ValidationEventArgs e) - { - throw new Exception(e.Message); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - var xml = new XmlDocument { XmlResolver = null }; - xml.LoadXml(sb.ToString().Replace(" 0 && lastVPosition.Length > 0) - { - pText.AppendLine(); - } - - lastVPosition = vPosition; - } - } - - bool alignLeft = false; - bool alignRight = false; - bool alignVTop = false; - bool alignVCenter = false; - if (innerNode.Attributes["Halign"] != null) - { - string hAlign = innerNode.Attributes["Halign"].InnerText; - if (hAlign == "left") - { - alignLeft = true; - } - else if (hAlign == "right") - { - alignRight = true; - } - } - - if (innerNode.Attributes["Valign"] != null) - { - string hAlign = innerNode.Attributes["Valign"].InnerText; - if (hAlign == "top") - { - alignVTop = true; - } - else if (hAlign == "center") - { - alignVCenter = true; - } - } - - if (alignLeft || alignRight || alignVCenter || alignVTop) - { - if (!pText.ToString().StartsWith("{\\an")) - { - string pre = string.Empty; - if (alignVTop) - { - if (alignLeft) - { - pre = "{\\an7}"; - } - else if (alignRight) - { - pre = "{\\an9}"; - } - else - { - pre = "{\\an8}"; - } - } - else if (alignVCenter) - { - if (alignLeft) - { - pre = "{\\an4}"; - } - else if (alignRight) - { - pre = "{\\an6}"; - } - else - { - pre = "{\\an5}"; - } - } - else - { - if (alignLeft) - { - pre = "{\\an1}"; - } - else if (alignRight) - { - pre = "{\\an3}"; - } - } - - string temp = pre + pText; - pText.Clear(); - pText.Append(temp); - } - } - - if (innerNode.ChildNodes.Count == 0) - { - pText.Append(innerNode.InnerText); - } - else - { - foreach (XmlNode innerInnerNode in innerNode) - { - if (innerInnerNode.Name == "Font" && innerInnerNode.Attributes["Italic"] != null && - innerInnerNode.Attributes["Italic"].InnerText.Equals("yes", StringComparison.OrdinalIgnoreCase)) - { - if (innerInnerNode.Attributes["Color"] != null) - { - pText.Append("" + innerInnerNode.InnerText + ""); - } - else - { - pText.Append("" + innerInnerNode.InnerText + ""); - } - } - else if (innerInnerNode.Name == "Font" && innerInnerNode.Attributes["Color"] != null) - { - if (innerInnerNode.Attributes["Italic"] != null && innerInnerNode.Attributes["Italic"].InnerText.Equals("yes", StringComparison.OrdinalIgnoreCase)) - { - pText.Append("" + innerInnerNode.InnerText + ""); - } - else - { - pText.Append("" + innerInnerNode.InnerText + ""); - } - } - else - { - pText.Append(innerInnerNode.InnerText); - } - } - } - } - else - { - pText.Append(innerNode.InnerText); - } - } - string start = node.Attributes["TimeIn"].InnerText; - string end = node.Attributes["TimeOut"].InnerText; - - if (node.ParentNode.Name == "Font" && node.ParentNode.Attributes["Italic"] != null && node.ParentNode.Attributes["Italic"].InnerText.Equals("yes", StringComparison.OrdinalIgnoreCase) && - !pText.ToString().Contains("")) - { - string text = pText.ToString(); - if (text.StartsWith("{\\an") && text.Length > 6) - { - text = text.Insert(6, "") + ""; - } - else - { - text = "" + text + ""; - } - pText = new StringBuilder(text); - } - - subtitle.Paragraphs.Add(new Paragraph(GetTimeCode(start), GetTimeCode(end), pText.ToString())); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - } - - if (subtitle.Paragraphs.Count > 0) - { - subtitle.Header = xml.OuterXml; // save id/language/font for later use - } - - subtitle.Renumber(); - } - - private static string GetColorStringFromDCinema(string p) - { - string s = p.ToLowerInvariant().Trim(); - if (s.Replace("#", string.Empty). - Replace("0", string.Empty). - Replace("1", string.Empty). - Replace("2", string.Empty). - Replace("3", string.Empty). - Replace("4", string.Empty). - Replace("5", string.Empty). - Replace("6", string.Empty). - Replace("7", string.Empty). - Replace("8", string.Empty). - Replace("9", string.Empty). - Replace("a", string.Empty). - Replace("b", string.Empty). - Replace("c", string.Empty). - Replace("d", string.Empty). - Replace("e", string.Empty). - Replace("f", string.Empty).Length == 0) - { - if (s.StartsWith('#')) - { - return s; - } - return "#" + s; - } - return p; - } - - private TimeCode GetTimeCode(string s) - { - var parts = s.Split(':', '.', ','); - - int milliseconds = (int)Math.Round(int.Parse(parts[3]) * (TimeCode.BaseUnit / _frameRate)); - if (milliseconds > 999) - { - milliseconds = 999; - } - - return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), milliseconds); - } - - private string ConvertToTimeString(TimeCode time) - { - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{DCinemaSmpte2010.MsToFramesMaxFrameRate(time.Milliseconds, _frameRate):00}"; - } - - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Text; +using System.Xml; +using System.Xml.Schema; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class DCinemaSmpte2007 : SubtitleFormat + { + // + // + // urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e + // 2001, A Space Odissey + // This is a subtitle file + // 2012-06-26T12:33:59.000-00:00 + // 1 + // fr + // 25 1 + // 25 + // 00:00:00:00 + // urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391 + // + // + // Hallo + // + // + + public string Errors { get; private set; } + + private double _frameRate = 24; + + public int Version { get; set; } + + public override string Extension => ".xml"; + + public override string Name => "D-Cinema SMPTE 2007"; + + public override bool IsMine(List lines, string fileName) + { + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + string xmlAsString = sb.ToString().Trim(); + if (xmlAsString.Contains("http://www.smpte-ra.org/schemas/428-7/2010/DCST") || + xmlAsString.Contains("http://www.smpte-ra.org/schemas/428-7/2014/DCST")) + { + return false; + } + + if (xmlAsString.Contains(" 0; + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + return false; + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + Errors = null; + var ss = Configuration.Settings.SubtitleSettings; + + if (!string.IsNullOrEmpty(ss.CurrentDCinemaEditRate)) + { + string[] temp = ss.CurrentDCinemaEditRate.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + double d1, d2; + if (temp.Length == 2 && double.TryParse(temp[0], out d1) && double.TryParse(temp[1], out d2)) + { + _frameRate = d1 / d2; + } + } + + string xmlStructure = + "" + Environment.NewLine + + " urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e" + Environment.NewLine + + " " + Environment.NewLine + + " This is a subtitle file" + Environment.NewLine + + " 2012-06-26T12:33:59.000-00:00" + Environment.NewLine + + " 1" + Environment.NewLine + + " en" + Environment.NewLine + + " 25 1" + Environment.NewLine + + " 25" + Environment.NewLine + + " 00:00:00:00 " + Environment.NewLine + + " urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + xml.PreserveWhitespace = true; + var nsmgr = new XmlNamespaceManager(xml.NameTable); + nsmgr.AddNamespace("dcst", xml.DocumentElement.NamespaceURI); + + if (string.IsNullOrEmpty(ss.CurrentDCinemaMovieTitle)) + { + ss.CurrentDCinemaMovieTitle = title; + } + + if (ss.CurrentDCinemaFontSize == 0 || string.IsNullOrEmpty(ss.CurrentDCinemaFontEffect)) + { + Configuration.Settings.SubtitleSettings.InitializeDCinameSettings(true); + } + + xml.DocumentElement.SelectSingleNode("dcst:ContentTitleText", nsmgr).InnerText = ss.CurrentDCinemaMovieTitle; + if (string.IsNullOrEmpty(ss.CurrentDCinemaSubtitleId) || !ss.CurrentDCinemaSubtitleId.StartsWith("urn:uuid:")) + { + ss.CurrentDCinemaSubtitleId = "urn:uuid:" + Guid.NewGuid(); + } + + xml.DocumentElement.SelectSingleNode("dcst:Id", nsmgr).InnerText = ss.CurrentDCinemaSubtitleId; + xml.DocumentElement.SelectSingleNode("dcst:ReelNumber", nsmgr).InnerText = ss.CurrentDCinemaReelNumber; + xml.DocumentElement.SelectSingleNode("dcst:IssueDate", nsmgr).InnerText = ss.CurrentDCinemaIssueDate; + if (string.IsNullOrEmpty(ss.CurrentDCinemaLanguage)) + { + ss.CurrentDCinemaLanguage = "en"; + } + + xml.DocumentElement.SelectSingleNode("dcst:Language", nsmgr).InnerText = ss.CurrentDCinemaLanguage; + if (ss.CurrentDCinemaEditRate == null && ss.CurrentDCinemaTimeCodeRate == null) + { + if (Configuration.Settings.General.CurrentFrameRate == 24) + { + ss.CurrentDCinemaEditRate = "24 1"; + ss.CurrentDCinemaTimeCodeRate = "24"; + } + else + { + ss.CurrentDCinemaEditRate = "25 1"; + ss.CurrentDCinemaTimeCodeRate = "25"; + } + } + xml.DocumentElement.SelectSingleNode("dcst:EditRate", nsmgr).InnerText = ss.CurrentDCinemaEditRate; + xml.DocumentElement.SelectSingleNode("dcst:TimeCodeRate", nsmgr).InnerText = ss.CurrentDCinemaTimeCodeRate; + if (string.IsNullOrEmpty(ss.CurrentDCinemaStartTime)) + { + ss.CurrentDCinemaStartTime = "00:00:00:00"; + } + + xml.DocumentElement.SelectSingleNode("dcst:StartTime", nsmgr).InnerText = ss.CurrentDCinemaStartTime; + xml.DocumentElement.SelectSingleNode("dcst:LoadFont", nsmgr).InnerText = ss.CurrentDCinemaFontUri; + int fontSize = ss.CurrentDCinemaFontSize; + string loadedFontId = "Font1"; + if (!string.IsNullOrEmpty(ss.CurrentDCinemaFontId)) + { + loadedFontId = ss.CurrentDCinemaFontId; + } + + xml.DocumentElement.SelectSingleNode("dcst:LoadFont", nsmgr).Attributes["ID"].Value = loadedFontId; + xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Size"].Value = fontSize.ToString(); + xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Color"].Value = "FF" + Utilities.ColorToHex(ss.CurrentDCinemaFontColor).TrimStart('#').ToUpperInvariant(); + xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["ID"].Value = loadedFontId; + xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Effect"].Value = ss.CurrentDCinemaFontEffect; + xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["EffectColor"].Value = "FF" + Utilities.ColorToHex(ss.CurrentDCinemaFontEffectColor).TrimStart('#').ToUpperInvariant(); + + XmlNode mainListFont = xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr); + int no = 0; + foreach (Paragraph p in subtitle.Paragraphs) + { + if (p.Text != null) + { + XmlNode subNode = xml.CreateElement("dcst:Subtitle", "dcst"); + + XmlAttribute id = xml.CreateAttribute("SpotNumber"); + id.InnerText = (no + 1).ToString(); + subNode.Attributes.Append(id); + + XmlAttribute fadeUpTime = xml.CreateAttribute("FadeUpTime"); + fadeUpTime.InnerText = "00:00:00:00"; + subNode.Attributes.Append(fadeUpTime); + + XmlAttribute fadeDownTime = xml.CreateAttribute("FadeDownTime"); + fadeDownTime.InnerText = "00:00:00:00"; + subNode.Attributes.Append(fadeDownTime); + + XmlAttribute start = xml.CreateAttribute("TimeIn"); + start.InnerText = ConvertToTimeString(p.StartTime); + subNode.Attributes.Append(start); + + XmlAttribute end = xml.CreateAttribute("TimeOut"); + end.InnerText = ConvertToTimeString(p.EndTime); + subNode.Attributes.Append(end); + + bool alignLeft = p.Text.StartsWith("{\\a1}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a5}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a9}", StringComparison.Ordinal) || // sub station alpha + p.Text.StartsWith("{\\an1}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an7}", StringComparison.Ordinal); // advanced sub station alpha + + bool alignRight = p.Text.StartsWith("{\\a3}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a7}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a11}", StringComparison.Ordinal) || // sub station alpha + p.Text.StartsWith("{\\an3}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an6}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); // advanced sub station alpha + + bool alignVTop = p.Text.StartsWith("{\\a5}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a6}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a7}", StringComparison.Ordinal) || // sub station alpha + p.Text.StartsWith("{\\an7}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an8}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); // advanced sub station alpha + + bool alignVCenter = p.Text.StartsWith("{\\a9}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a10}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a11}", StringComparison.Ordinal) || // sub station alpha + p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an5}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an6}", StringComparison.Ordinal); // advanced sub station alpha + + string text = Utilities.RemoveSsaTags(p.Text); + + var lines = text.SplitToLines(); + int vPos = 1 + lines.Count * 7; + int vPosFactor = (int)Math.Round(fontSize / 7.4); + if (alignVTop) + { + vPos = Configuration.Settings.SubtitleSettings.DCinemaBottomMargin; // Bottom margin is normally 8 + } + else if (alignVCenter) + { + vPos = (int)Math.Round((lines.Count * vPosFactor * -1) / 2.0); + } + else + { + vPos = lines.Count * vPosFactor - vPosFactor + Configuration.Settings.SubtitleSettings.DCinemaBottomMargin; // Bottom margin is normally 8 + } + + bool isItalic = false; + int fontNo = 0; + Stack fontColors = new Stack(); + foreach (string line in lines) + { + XmlNode textNode = xml.CreateElement("dcst:Text", "dcst"); + + XmlAttribute vPosition = xml.CreateAttribute("Vposition"); + vPosition.InnerText = vPos.ToString(); + textNode.Attributes.Append(vPosition); + + XmlAttribute vAlign = xml.CreateAttribute("Valign"); + if (alignVTop) + { + vAlign.InnerText = "top"; + } + else if (alignVCenter) + { + vAlign.InnerText = "center"; + } + else + { + vAlign.InnerText = "bottom"; + } + + textNode.Attributes.Append(vAlign); textNode.Attributes.Append(vAlign); + + XmlAttribute hAlign = xml.CreateAttribute("Halign"); + if (alignLeft) + { + hAlign.InnerText = "left"; + } + else if (alignRight) + { + hAlign.InnerText = "right"; + } + else + { + hAlign.InnerText = "center"; + } + + textNode.Attributes.Append(hAlign); + + XmlAttribute direction = xml.CreateAttribute("Direction"); + direction.InnerText = "ltr"; + textNode.Attributes.Append(direction); + + int i = 0; + var txt = new StringBuilder(); + var html = new StringBuilder(); + XmlNode nodeTemp = xml.CreateElement("temp"); + while (i < line.Length) + { + if (!isItalic && line.Substring(i).StartsWith("")) + { + if (txt.Length > 0) + { + nodeTemp.InnerText = txt.ToString(); + html.Append(nodeTemp.InnerXml); + txt.Clear(); + } + isItalic = true; + i += 2; + } + else if (isItalic && line.Substring(i).StartsWith("")) + { + if (txt.Length > 0) + { + XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); + + XmlAttribute italic = xml.CreateAttribute("Italic"); + italic.InnerText = "yes"; + fontNode.Attributes.Append(italic); + + if (line.Length > i + 5 && line.Substring(i + 4).StartsWith("")) + { + XmlAttribute fontColor = xml.CreateAttribute("Color"); + fontColor.InnerText = fontColors.Pop(); + fontNode.Attributes.Append(fontColor); + fontNo--; + i += 7; + } + + fontNode.InnerText = HtmlUtil.RemoveHtmlTags(txt.ToString()); + html.Append(fontNode.OuterXml); + txt.Clear(); + } + isItalic = false; + i += 3; + } + else if (line.Substring(i).StartsWith("")) + { + if (txt.Length > 0) + { + XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); + + XmlAttribute fontColor = xml.CreateAttribute("Color"); + fontColor.InnerText = fontColors.Pop(); + fontNode.Attributes.Append(fontColor); + + if (line.Length > i + 9 && line.Substring(i + 7).StartsWith("")) + { + XmlAttribute italic = xml.CreateAttribute("Italic"); + italic.InnerText = "yes"; + fontNode.Attributes.Append(italic); + isItalic = false; + i += 4; + } + + fontNode.InnerText = HtmlUtil.RemoveHtmlTags(txt.ToString()); + html.Append(fontNode.OuterXml); + txt.Clear(); + } + fontNo--; + i += 6; + } + else + { + txt.Append(line[i]); + } + i++; + } + + if (fontNo > 0) + { + if (txt.Length > 0) + { + XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); + + XmlAttribute fontColor = xml.CreateAttribute("Color"); + fontColor.InnerText = fontColors.Peek(); + fontNode.Attributes.Append(fontColor); + + if (isItalic) + { + XmlAttribute italic = xml.CreateAttribute("Italic"); + italic.InnerText = "yes"; + fontNode.Attributes.Append(italic); + } + + fontNode.InnerText = HtmlUtil.RemoveHtmlTags(txt.ToString()); + html.Append(fontNode.OuterXml); + } + else if (html.Length > 0 && html.ToString().StartsWith("" + html.ToString().Replace("dcst:Font", "Font") + ""); + XmlNode fontNode = xml.CreateElement("dcst:Font"); + fontNode.InnerXml = temp.DocumentElement.SelectSingleNode("Font").InnerXml; + foreach (XmlAttribute a in temp.DocumentElement.SelectSingleNode("Font").Attributes) + { + XmlAttribute newA = xml.CreateAttribute(a.Name); + newA.InnerText = a.InnerText; + fontNode.Attributes.Append(newA); + } + + XmlAttribute fontColor = xml.CreateAttribute("Color"); + fontColor.InnerText = fontColors.Peek(); + fontNode.Attributes.Append(fontColor); + + html.Clear(); + html.Append(fontNode.OuterXml); + } + } + else if (isItalic) + { + if (txt.Length > 0) + { + XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); + + XmlAttribute italic = xml.CreateAttribute("Italic"); + italic.InnerText = "yes"; + fontNode.Attributes.Append(italic); + + fontNode.InnerText = HtmlUtil.RemoveHtmlTags(line); + html.Append(fontNode.OuterXml); + } + } + else + { + if (txt.Length > 0) + { + nodeTemp.InnerText = txt.ToString(); + html.Append(nodeTemp.InnerXml); + } + } + textNode.InnerXml = html.ToString(); + + subNode.AppendChild(textNode); + if (alignVTop) + { + vPos += vPosFactor; + } + else + { + vPos -= vPosFactor; + } + } + if (subNode.InnerXml.Length == 0) + { // Empty text is just one space + XmlNode textNode = xml.CreateElement("dcst:Text", "dcst"); + textNode.InnerXml = " "; + subNode.AppendChild(textNode); + + XmlAttribute vPosition = xml.CreateAttribute("Vposition"); + vPosition.InnerText = vPos.ToString(); + textNode.Attributes.Append(vPosition); + + XmlAttribute vAlign = xml.CreateAttribute("Valign"); + vAlign.InnerText = "bottom"; + textNode.Attributes.Append(vAlign); + } + mainListFont.AppendChild(subNode); + no++; + } + } + string result = ToUtf8XmlString(xml).Replace("encoding=\"utf-8\"", "encoding=\"UTF-8\"").Replace(" xmlns:dcst=\"dcst\"", string.Empty); + + const string res = "Nikse.SubtitleEdit.Resources.SMPTE-428-7-2007-DCST.xsd.gz"; + System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); + Stream strm = asm.GetManifestResourceStream(res); + if (strm != null) + { + try + { + var xmld = new XmlDocument(); + var rdr = new StreamReader(strm); + var zip = new GZipStream(rdr.BaseStream, CompressionMode.Decompress); + xmld.LoadXml(result); + using (var xr = XmlReader.Create(zip)) + { + xmld.Schemas.Add(null, xr); + xmld.Validate(ValidationCallBack); + } + } + catch (Exception exception) + { + Errors = "Error validating xml via SMPTE - 428 - 7 - 2007 - DCST.xsd: " + exception.Message; + } + } + return DCinemaSmpte2010.FixDcsTextSameLine(result); + } + + private void ValidationCallBack(object sender, ValidationEventArgs e) + { + throw new Exception(e.Message); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + xml.LoadXml(sb.ToString().Replace(" 0 && lastVPosition.Length > 0) + { + pText.AppendLine(); + } + + lastVPosition = vPosition; + } + } + + bool alignLeft = false; + bool alignRight = false; + bool alignVTop = false; + bool alignVCenter = false; + if (innerNode.Attributes["Halign"] != null) + { + string hAlign = innerNode.Attributes["Halign"].InnerText; + if (hAlign == "left") + { + alignLeft = true; + } + else if (hAlign == "right") + { + alignRight = true; + } + } + + if (innerNode.Attributes["Valign"] != null) + { + string hAlign = innerNode.Attributes["Valign"].InnerText; + if (hAlign == "top") + { + alignVTop = true; + } + else if (hAlign == "center") + { + alignVCenter = true; + } + } + + if (alignLeft || alignRight || alignVCenter || alignVTop) + { + if (!pText.ToString().StartsWith("{\\an")) + { + string pre = string.Empty; + if (alignVTop) + { + if (alignLeft) + { + pre = "{\\an7}"; + } + else if (alignRight) + { + pre = "{\\an9}"; + } + else + { + pre = "{\\an8}"; + } + } + else if (alignVCenter) + { + if (alignLeft) + { + pre = "{\\an4}"; + } + else if (alignRight) + { + pre = "{\\an6}"; + } + else + { + pre = "{\\an5}"; + } + } + else + { + if (alignLeft) + { + pre = "{\\an1}"; + } + else if (alignRight) + { + pre = "{\\an3}"; + } + } + + string temp = pre + pText; + pText.Clear(); + pText.Append(temp); + } + } + + if (innerNode.ChildNodes.Count == 0) + { + pText.Append(innerNode.InnerText); + } + else + { + foreach (XmlNode innerInnerNode in innerNode) + { + if (innerInnerNode.Name == "Font" && innerInnerNode.Attributes["Italic"] != null && + innerInnerNode.Attributes["Italic"].InnerText.Equals("yes", StringComparison.OrdinalIgnoreCase)) + { + if (innerInnerNode.Attributes["Color"] != null) + { + pText.Append("" + innerInnerNode.InnerText + ""); + } + else + { + pText.Append("" + innerInnerNode.InnerText + ""); + } + } + else if (innerInnerNode.Name == "Font" && innerInnerNode.Attributes["Color"] != null) + { + if (innerInnerNode.Attributes["Italic"] != null && innerInnerNode.Attributes["Italic"].InnerText.Equals("yes", StringComparison.OrdinalIgnoreCase)) + { + pText.Append("" + innerInnerNode.InnerText + ""); + } + else + { + pText.Append("" + innerInnerNode.InnerText + ""); + } + } + else + { + pText.Append(innerInnerNode.InnerText); + } + } + } + } + else + { + pText.Append(innerNode.InnerText); + } + } + string start = node.Attributes["TimeIn"].InnerText; + string end = node.Attributes["TimeOut"].InnerText; + + if (node.ParentNode.Name == "Font" && node.ParentNode.Attributes["Italic"] != null && node.ParentNode.Attributes["Italic"].InnerText.Equals("yes", StringComparison.OrdinalIgnoreCase) && + !pText.ToString().Contains("")) + { + string text = pText.ToString(); + if (text.StartsWith("{\\an") && text.Length > 6) + { + text = text.Insert(6, "") + ""; + } + else + { + text = "" + text + ""; + } + pText = new StringBuilder(text); + } + + subtitle.Paragraphs.Add(new Paragraph(GetTimeCode(start), GetTimeCode(end), pText.ToString())); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + + if (subtitle.Paragraphs.Count > 0) + { + subtitle.Header = xml.OuterXml; // save id/language/font for later use + } + + subtitle.Renumber(); + } + + private static string GetColorStringFromDCinema(string p) + { + string s = p.ToLowerInvariant().Trim(); + if (s.Replace("#", string.Empty). + Replace("0", string.Empty). + Replace("1", string.Empty). + Replace("2", string.Empty). + Replace("3", string.Empty). + Replace("4", string.Empty). + Replace("5", string.Empty). + Replace("6", string.Empty). + Replace("7", string.Empty). + Replace("8", string.Empty). + Replace("9", string.Empty). + Replace("a", string.Empty). + Replace("b", string.Empty). + Replace("c", string.Empty). + Replace("d", string.Empty). + Replace("e", string.Empty). + Replace("f", string.Empty).Length == 0) + { + if (s.StartsWith('#')) + { + return s; + } + return "#" + s; + } + return p; + } + + private TimeCode GetTimeCode(string s) + { + var parts = s.Split(':', '.', ','); + + int milliseconds = (int)Math.Round(int.Parse(parts[3]) * (TimeCode.BaseUnit / _frameRate)); + if (milliseconds > 999) + { + milliseconds = 999; + } + + return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), milliseconds); + } + + private string ConvertToTimeString(TimeCode time) + { + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{DCinemaSmpte2010.MsToFramesMaxFrameRate(time.Milliseconds, _frameRate):00}"; + } + + } +} diff --git a/libse/SubtitleFormats/DCinemaSmpte2010.cs b/src/libse/SubtitleFormats/DCinemaSmpte2010.cs similarity index 98% rename from libse/SubtitleFormats/DCinemaSmpte2010.cs rename to src/libse/SubtitleFormats/DCinemaSmpte2010.cs index 129429e3f..f72c8e305 100644 --- a/libse/SubtitleFormats/DCinemaSmpte2010.cs +++ b/src/libse/SubtitleFormats/DCinemaSmpte2010.cs @@ -1,854 +1,854 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Text; -using System.Xml; -using System.Xml.Schema; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class DCinemaSmpte2010 : SubtitleFormat - { - // - // - // urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e - // 2001, A Space Odissey - // This is a subtitle file - // 2012-06-26T12:33:59.000-00:00 - // 1 - // fr - // 25 1 - // 25 - // 00:00:00:00 - // urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391 - // - // - // Hallo - // - // - - public string Errors { get; private set; } - - private double _frameRate = 24; - - public int Version { get; set; } - - public override string Extension => ".xml"; - - public override string Name => "D-Cinema SMPTE 2010"; - - public override bool IsMine(List lines, string fileName) - { - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - string xmlAsString = sb.ToString().Trim(); - - if (xmlAsString.Contains("http://www.smpte-ra.org/schemas/428-7/2007/DCST") || - xmlAsString.Contains("http://www.smpte-ra.org/schemas/428-7/2014/DCST")) - { - return false; - } - - if (xmlAsString.Contains(" 0; - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - return false; - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - Errors = null; - var ss = Configuration.Settings.SubtitleSettings; - - if (!string.IsNullOrEmpty(ss.CurrentDCinemaEditRate)) - { - string[] temp = ss.CurrentDCinemaEditRate.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - double d1, d2; - if (temp.Length == 2 && double.TryParse(temp[0], out d1) && double.TryParse(temp[1], out d2)) - { - _frameRate = d1 / d2; - } - } - - string xmlStructure = - "" + Environment.NewLine + - " urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e" + Environment.NewLine + - " " + Environment.NewLine + - " This is a subtitle file" + Environment.NewLine + - " 2012-06-26T12:33:59.000-00:00" + Environment.NewLine + - " 1" + Environment.NewLine + - " en" + Environment.NewLine + - " 25 1" + Environment.NewLine + - " 25" + Environment.NewLine + - " 00:00:00:00 " + Environment.NewLine + - " urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - xml.PreserveWhitespace = true; - var nsmgr = new XmlNamespaceManager(xml.NameTable); - nsmgr.AddNamespace("dcst", xml.DocumentElement.NamespaceURI); - - if (string.IsNullOrEmpty(ss.CurrentDCinemaMovieTitle)) - { - ss.CurrentDCinemaMovieTitle = title; - } - - if (ss.CurrentDCinemaFontSize == 0 || string.IsNullOrEmpty(ss.CurrentDCinemaFontEffect)) - { - Configuration.Settings.SubtitleSettings.InitializeDCinameSettings(true); - } - - xml.DocumentElement.SelectSingleNode("dcst:ContentTitleText", nsmgr).InnerText = ss.CurrentDCinemaMovieTitle; - if (string.IsNullOrEmpty(ss.CurrentDCinemaSubtitleId) || !ss.CurrentDCinemaSubtitleId.StartsWith("urn:uuid:")) - { - ss.CurrentDCinemaSubtitleId = "urn:uuid:" + Guid.NewGuid(); - } - - xml.DocumentElement.SelectSingleNode("dcst:Id", nsmgr).InnerText = ss.CurrentDCinemaSubtitleId; - xml.DocumentElement.SelectSingleNode("dcst:ReelNumber", nsmgr).InnerText = ss.CurrentDCinemaReelNumber; - xml.DocumentElement.SelectSingleNode("dcst:IssueDate", nsmgr).InnerText = ss.CurrentDCinemaIssueDate; - if (string.IsNullOrEmpty(ss.CurrentDCinemaLanguage)) - { - ss.CurrentDCinemaLanguage = "en"; - } - - xml.DocumentElement.SelectSingleNode("dcst:Language", nsmgr).InnerText = ss.CurrentDCinemaLanguage; - if (ss.CurrentDCinemaEditRate == null && ss.CurrentDCinemaTimeCodeRate == null) - { - if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 24) < 0.01) - { - ss.CurrentDCinemaEditRate = "24 1"; - ss.CurrentDCinemaTimeCodeRate = "24"; - } - else - { - ss.CurrentDCinemaEditRate = "25 1"; - ss.CurrentDCinemaTimeCodeRate = "25"; - } - } - xml.DocumentElement.SelectSingleNode("dcst:EditRate", nsmgr).InnerText = ss.CurrentDCinemaEditRate; - xml.DocumentElement.SelectSingleNode("dcst:TimeCodeRate", nsmgr).InnerText = ss.CurrentDCinemaTimeCodeRate; - if (string.IsNullOrEmpty(ss.CurrentDCinemaStartTime)) - { - ss.CurrentDCinemaStartTime = "00:00:00:00"; - } - - xml.DocumentElement.SelectSingleNode("dcst:StartTime", nsmgr).InnerText = ss.CurrentDCinemaStartTime; - xml.DocumentElement.SelectSingleNode("dcst:LoadFont", nsmgr).InnerText = ss.CurrentDCinemaFontUri; - int fontSize = ss.CurrentDCinemaFontSize; - string loadedFontId = "Font1"; - if (!string.IsNullOrEmpty(ss.CurrentDCinemaFontId)) - { - loadedFontId = ss.CurrentDCinemaFontId; - } - - xml.DocumentElement.SelectSingleNode("dcst:LoadFont", nsmgr).Attributes["ID"].Value = loadedFontId; - xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Size"].Value = fontSize.ToString(); - xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Color"].Value = "FF" + Utilities.ColorToHex(ss.CurrentDCinemaFontColor).TrimStart('#').ToUpperInvariant(); - xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["ID"].Value = loadedFontId; - xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Effect"].Value = ss.CurrentDCinemaFontEffect; - xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["EffectColor"].Value = "FF" + Utilities.ColorToHex(ss.CurrentDCinemaFontEffectColor).TrimStart('#').ToUpperInvariant(); - - XmlNode mainListFont = xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr); - int no = 0; - foreach (Paragraph p in subtitle.Paragraphs) - { - if (p.Text != null) - { - XmlNode subNode = xml.CreateElement("dcst:Subtitle", "dcst"); - - XmlAttribute id = xml.CreateAttribute("SpotNumber"); - id.InnerText = (no + 1).ToString(); - subNode.Attributes.Append(id); - - XmlAttribute fadeUpTime = xml.CreateAttribute("FadeUpTime"); - fadeUpTime.InnerText = new TimeCode(FramesToMilliseconds(Configuration.Settings.SubtitleSettings.DCinemaFadeUpTime)).ToHHMMSSFF(); - subNode.Attributes.Append(fadeUpTime); - - XmlAttribute fadeDownTime = xml.CreateAttribute("FadeDownTime"); - fadeDownTime.InnerText = new TimeCode(FramesToMilliseconds(Configuration.Settings.SubtitleSettings.DCinemaFadeDownTime)).ToHHMMSSFF(); - subNode.Attributes.Append(fadeDownTime); - - XmlAttribute start = xml.CreateAttribute("TimeIn"); - start.InnerText = ConvertToTimeString(p.StartTime); - subNode.Attributes.Append(start); - - XmlAttribute end = xml.CreateAttribute("TimeOut"); - end.InnerText = ConvertToTimeString(p.EndTime); - subNode.Attributes.Append(end); - - bool alignLeft = p.Text.StartsWith("{\\a1}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a5}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a9}", StringComparison.Ordinal) || // sub station alpha - p.Text.StartsWith("{\\an1}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an7}", StringComparison.Ordinal); // advanced sub station alpha - - bool alignRight = p.Text.StartsWith("{\\a3}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a7}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a11}", StringComparison.Ordinal) || // sub station alpha - p.Text.StartsWith("{\\an3}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an6}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); // advanced sub station alpha - - bool alignVTop = p.Text.StartsWith("{\\a5}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a6}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a7}", StringComparison.Ordinal) || // sub station alpha - p.Text.StartsWith("{\\an7}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an8}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); // advanced sub station alpha - - bool alignVCenter = p.Text.StartsWith("{\\a9}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a10}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a11}", StringComparison.Ordinal) || // sub station alpha - p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an5}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an6}", StringComparison.Ordinal); // advanced sub station alpha - - string text = Utilities.RemoveSsaTags(p.Text); - - var lines = text.SplitToLines(); - int vPos = 1 + lines.Count * 7; - int vPosFactor = (int)Math.Round(fontSize / 7.4); - if (alignVTop) - { - vPos = Configuration.Settings.SubtitleSettings.DCinemaBottomMargin; // Bottom margin is normally 8 - } - else if (alignVCenter) - { - vPos = (int)Math.Round((lines.Count * vPosFactor * -1) / 2.0); - } - else - { - vPos = (lines.Count * vPosFactor) - vPosFactor + Configuration.Settings.SubtitleSettings.DCinemaBottomMargin; // Bottom margin is normally 8 - } - - bool isItalic = false; - int fontNo = 0; - Stack fontColors = new Stack(); - foreach (string line in lines) - { - XmlNode textNode = xml.CreateElement("dcst:Text", "dcst"); - - XmlAttribute vPosition = xml.CreateAttribute("Vposition"); - vPosition.InnerText = vPos.ToString(); - textNode.Attributes.Append(vPosition); - - XmlAttribute vAlign = xml.CreateAttribute("Valign"); - if (alignVTop) - { - vAlign.InnerText = "top"; - } - else if (alignVCenter) - { - vAlign.InnerText = "center"; - } - else - { - vAlign.InnerText = "bottom"; - } - - textNode.Attributes.Append(vAlign); textNode.Attributes.Append(vAlign); - - XmlAttribute hAlign = xml.CreateAttribute("Halign"); - if (alignLeft) - { - hAlign.InnerText = "left"; - } - else if (alignRight) - { - hAlign.InnerText = "right"; - } - else - { - hAlign.InnerText = "center"; - } - - textNode.Attributes.Append(hAlign); - - XmlAttribute direction = xml.CreateAttribute("Direction"); - direction.InnerText = "ltr"; - textNode.Attributes.Append(direction); - - int i = 0; - var txt = new StringBuilder(); - var html = new StringBuilder(); - XmlNode nodeTemp = xml.CreateElement("temp"); - while (i < line.Length) - { - if (!isItalic && line.Substring(i).StartsWith("", StringComparison.Ordinal)) - { - if (txt.Length > 0) - { - nodeTemp.InnerText = txt.ToString(); - html.Append(nodeTemp.InnerXml); - txt.Clear(); - } - isItalic = true; - i += 2; - } - else if (isItalic && line.Substring(i).StartsWith("", StringComparison.Ordinal)) - { - if (txt.Length > 0) - { - XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); - - XmlAttribute italic = xml.CreateAttribute("Italic"); - italic.InnerText = "yes"; - fontNode.Attributes.Append(italic); - - if (line.Length > i + 5 && line.Substring(i + 4).StartsWith("", StringComparison.Ordinal)) - { - XmlAttribute fontColor = xml.CreateAttribute("Color"); - fontColor.InnerText = fontColors.Pop(); - fontNode.Attributes.Append(fontColor); - fontNo--; - i += 7; - } - - fontNode.InnerText = HtmlUtil.RemoveHtmlTags(txt.ToString()); - html.Append(fontNode.OuterXml); - txt.Clear(); - } - isItalic = false; - i += 3; - } - else if (line.Substring(i).StartsWith("", StringComparison.Ordinal)) - { - if (txt.Length > 0) - { - XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); - - XmlAttribute fontColor = xml.CreateAttribute("Color"); - fontColor.InnerText = fontColors.Pop(); - fontNode.Attributes.Append(fontColor); - - if (line.Length > i + 9 && line.Substring(i + 7).StartsWith("", StringComparison.Ordinal)) - { - XmlAttribute italic = xml.CreateAttribute("Italic"); - italic.InnerText = "yes"; - fontNode.Attributes.Append(italic); - isItalic = false; - i += 4; - } - - fontNode.InnerText = HtmlUtil.RemoveHtmlTags(txt.ToString()); - html.Append(fontNode.OuterXml); - txt.Clear(); - } - fontNo--; - i += 6; - } - else - { - txt.Append(line[i]); - } - i++; - } - - if (fontNo > 0) - { - if (txt.Length > 0) - { - XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); - - XmlAttribute fontColor = xml.CreateAttribute("Color"); - fontColor.InnerText = fontColors.Peek(); - fontNode.Attributes.Append(fontColor); - - if (isItalic) - { - XmlAttribute italic = xml.CreateAttribute("Italic"); - italic.InnerText = "yes"; - fontNode.Attributes.Append(italic); - } - - fontNode.InnerText = HtmlUtil.RemoveHtmlTags(txt.ToString()); - html.Append(fontNode.OuterXml); - } - else if (html.Length > 0 && html.ToString().StartsWith("" + html.ToString().Replace("dcst:Font", "Font") + ""); - XmlNode fontNode = xml.CreateElement("dcst:Font"); - fontNode.InnerXml = temp.DocumentElement.SelectSingleNode("Font").InnerXml; - foreach (XmlAttribute a in temp.DocumentElement.SelectSingleNode("Font").Attributes) - { - XmlAttribute newA = xml.CreateAttribute(a.Name); - newA.InnerText = a.InnerText; - fontNode.Attributes.Append(newA); - } - - XmlAttribute fontColor = xml.CreateAttribute("Color"); - fontColor.InnerText = fontColors.Peek(); - fontNode.Attributes.Append(fontColor); - - html.Clear(); - html.Append(fontNode.OuterXml); - } - } - else if (isItalic) - { - if (txt.Length > 0) - { - XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); - - XmlAttribute italic = xml.CreateAttribute("Italic"); - italic.InnerText = "yes"; - fontNode.Attributes.Append(italic); - - fontNode.InnerText = HtmlUtil.RemoveHtmlTags(line); - html.Append(fontNode.OuterXml); - } - } - else - { - if (txt.Length > 0) - { - nodeTemp.InnerText = txt.ToString(); - html.Append(nodeTemp.InnerXml); - } - } - textNode.InnerXml = html.ToString(); - - subNode.AppendChild(textNode); - if (alignVTop) - { - vPos += vPosFactor; - } - else - { - vPos -= vPosFactor; - } - } - if (subNode.InnerXml.Length == 0) - { // Empty text is just one space - XmlNode textNode = xml.CreateElement("dcst:Text", "dcst"); - textNode.InnerXml = " "; - subNode.AppendChild(textNode); - - XmlAttribute vPosition = xml.CreateAttribute("Vposition"); - vPosition.InnerText = vPos.ToString(); - textNode.Attributes.Append(vPosition); - - XmlAttribute vAlign = xml.CreateAttribute("Valign"); - vAlign.InnerText = "bottom"; - textNode.Attributes.Append(vAlign); - } - mainListFont.AppendChild(subNode); - no++; - } - } - string result = ToUtf8XmlString(xml).Replace("encoding=\"utf-8\"", "encoding=\"UTF-8\"").Replace(" xmlns:dcst=\"dcst\"", string.Empty); - - const string res = "Nikse.SubtitleEdit.Resources.SMPTE-428-7-2010-DCST.xsd.gz"; - System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); - Stream strm = asm.GetManifestResourceStream(res); - if (strm != null) - { - try - { - var xmld = new XmlDocument(); - var rdr = new StreamReader(strm); - var zip = new GZipStream(rdr.BaseStream, CompressionMode.Decompress); - xmld.LoadXml(result); - using (var xr = XmlReader.Create(zip)) - { - xmld.Schemas.Add(null, xr); - xmld.Validate(ValidationCallBack); - } - } - catch (Exception exception) - { - Errors = "Error validating xml via SMPTE-428-7-2010-DCST.xsd: " + exception.Message; - } - } - return FixDcsTextSameLine(result); - } - - /// - /// All space characters present inside the content of a Text element shall be rendered - /// - internal static string FixDcsTextSameLine(string xml) - { - int index = xml.IndexOf(" 0 && endIndex > 0) - { - endIndex = xml.IndexOf("", index, StringComparison.Ordinal); - if (endIndex > 0) - { - var part = xml.Substring(index, endIndex - index); - if (part.Contains(Environment.NewLine)) - { - part = part.Replace(Environment.NewLine, " "); - while (part.Contains(" ")) - { - part = part.Replace(" ", " "); - } - part = part.Replace("> <", "><"); - } - xml = xml.Remove(index, endIndex - index).Insert(index, part); - index = xml.IndexOf(" lines, string fileName) - { - _errorCount = 0; - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - var xml = new XmlDocument { XmlResolver = null }; - xml.LoadXml(sb.ToString().Replace(" 0 && lastVPosition.Length > 0) - { - pText.AppendLine(); - } - - lastVPosition = vPosition; - } - } - - bool alignLeft = false; - bool alignRight = false; - bool alignVTop = false; - bool alignVCenter = false; - if (innerNode.Attributes["Halign"] != null) - { - string hAlign = innerNode.Attributes["Halign"].InnerText; - if (hAlign == "left") - { - alignLeft = true; - } - else if (hAlign == "right") - { - alignRight = true; - } - } - - if (innerNode.Attributes["Valign"] != null) - { - string hAlign = innerNode.Attributes["Valign"].InnerText; - if (hAlign == "top") - { - alignVTop = true; - } - else if (hAlign == "center") - { - alignVCenter = true; - } - } - - if (alignLeft || alignRight || alignVCenter || alignVTop) - { - if (!pText.ToString().StartsWith("{\\an", StringComparison.Ordinal)) - { - string pre = string.Empty; - if (alignVTop) - { - if (alignLeft) - { - pre = "{\\an7}"; - } - else if (alignRight) - { - pre = "{\\an9}"; - } - else - { - pre = "{\\an8}"; - } - } - else if (alignVCenter) - { - if (alignLeft) - { - pre = "{\\an4}"; - } - else if (alignRight) - { - pre = "{\\an6}"; - } - else - { - pre = "{\\an5}"; - } - } - else - { - if (alignLeft) - { - pre = "{\\an1}"; - } - else if (alignRight) - { - pre = "{\\an3}"; - } - } - - string temp = pre + pText; - pText.Clear(); - pText.Append(temp); - } - } - - if (innerNode.ChildNodes.Count == 0) - { - pText.Append(innerNode.InnerText); - } - else - { - foreach (XmlNode innerInnerNode in innerNode) - { - if (innerInnerNode.Name == "Font" && innerInnerNode.Attributes["Italic"] != null && - innerInnerNode.Attributes["Italic"].InnerText.Equals("yes", StringComparison.OrdinalIgnoreCase)) - { - if (innerInnerNode.Attributes["Color"] != null) - { - pText.Append("" + innerInnerNode.InnerText + ""); - } - else - { - pText.Append("" + innerInnerNode.InnerText + ""); - } - } - else if (innerInnerNode.Name == "Font" && innerInnerNode.Attributes["Color"] != null) - { - if (innerInnerNode.Attributes["Italic"] != null && innerInnerNode.Attributes["Italic"].InnerText.Equals("yes", StringComparison.OrdinalIgnoreCase)) - { - pText.Append("" + innerInnerNode.InnerText + ""); - } - else - { - pText.Append("" + innerInnerNode.InnerText + ""); - } - } - else - { - pText.Append(innerInnerNode.InnerText); - } - } - } - } - else - { - pText.Append(innerNode.InnerText); - } - } - string start = node.Attributes["TimeIn"].InnerText; - string end = node.Attributes["TimeOut"].InnerText; - - if (node.ParentNode.Name == "Font" && node.ParentNode.Attributes["Italic"] != null && node.ParentNode.Attributes["Italic"].InnerText.Equals("yes", StringComparison.OrdinalIgnoreCase) && - !pText.ToString().Contains("")) - { - string text = pText.ToString(); - if (text.StartsWith("{\\an", StringComparison.Ordinal) && text.Length > 6) - { - text = text.Insert(6, "") + ""; - } - else - { - text = "" + text + ""; - } - - pText = new StringBuilder(text); - } - - subtitle.Paragraphs.Add(new Paragraph(GetTimeCode(start), GetTimeCode(end), pText.ToString())); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - } - - if (subtitle.Paragraphs.Count > 0) - { - subtitle.Header = xml.OuterXml; // save id/language/font for later use - } - - subtitle.Renumber(); - } - - private TimeCode GetTimeCode(string s) - { - var parts = s.Split(new[] { ':', '.', ',' }); - - int milliseconds = (int)Math.Round(int.Parse(parts[3]) * (TimeCode.BaseUnit / _frameRate)); - if (milliseconds > 999) - { - milliseconds = 999; - } - - return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), milliseconds); - } - - public static int MsToFramesMaxFrameRate(double milliseconds, double frameRate) - { - int frames = (int)Math.Round(milliseconds / (TimeCode.BaseUnit / frameRate)); - if (frames >= Configuration.Settings.General.CurrentFrameRate) - { - frames = (int)(frameRate - 0.01); - } - - return frames; - } - - private string ConvertToTimeString(TimeCode time) - { - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MsToFramesMaxFrameRate(time.Milliseconds, _frameRate):00}"; - } - - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Text; +using System.Xml; +using System.Xml.Schema; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class DCinemaSmpte2010 : SubtitleFormat + { + // + // + // urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e + // 2001, A Space Odissey + // This is a subtitle file + // 2012-06-26T12:33:59.000-00:00 + // 1 + // fr + // 25 1 + // 25 + // 00:00:00:00 + // urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391 + // + // + // Hallo + // + // + + public string Errors { get; private set; } + + private double _frameRate = 24; + + public int Version { get; set; } + + public override string Extension => ".xml"; + + public override string Name => "D-Cinema SMPTE 2010"; + + public override bool IsMine(List lines, string fileName) + { + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + string xmlAsString = sb.ToString().Trim(); + + if (xmlAsString.Contains("http://www.smpte-ra.org/schemas/428-7/2007/DCST") || + xmlAsString.Contains("http://www.smpte-ra.org/schemas/428-7/2014/DCST")) + { + return false; + } + + if (xmlAsString.Contains(" 0; + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + return false; + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + Errors = null; + var ss = Configuration.Settings.SubtitleSettings; + + if (!string.IsNullOrEmpty(ss.CurrentDCinemaEditRate)) + { + string[] temp = ss.CurrentDCinemaEditRate.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + double d1, d2; + if (temp.Length == 2 && double.TryParse(temp[0], out d1) && double.TryParse(temp[1], out d2)) + { + _frameRate = d1 / d2; + } + } + + string xmlStructure = + "" + Environment.NewLine + + " urn:uuid:7be835a3-cfb4-43d0-bb4b-f0b4c95e962e" + Environment.NewLine + + " " + Environment.NewLine + + " This is a subtitle file" + Environment.NewLine + + " 2012-06-26T12:33:59.000-00:00" + Environment.NewLine + + " 1" + Environment.NewLine + + " en" + Environment.NewLine + + " 25 1" + Environment.NewLine + + " 25" + Environment.NewLine + + " 00:00:00:00 " + Environment.NewLine + + " urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + xml.PreserveWhitespace = true; + var nsmgr = new XmlNamespaceManager(xml.NameTable); + nsmgr.AddNamespace("dcst", xml.DocumentElement.NamespaceURI); + + if (string.IsNullOrEmpty(ss.CurrentDCinemaMovieTitle)) + { + ss.CurrentDCinemaMovieTitle = title; + } + + if (ss.CurrentDCinemaFontSize == 0 || string.IsNullOrEmpty(ss.CurrentDCinemaFontEffect)) + { + Configuration.Settings.SubtitleSettings.InitializeDCinameSettings(true); + } + + xml.DocumentElement.SelectSingleNode("dcst:ContentTitleText", nsmgr).InnerText = ss.CurrentDCinemaMovieTitle; + if (string.IsNullOrEmpty(ss.CurrentDCinemaSubtitleId) || !ss.CurrentDCinemaSubtitleId.StartsWith("urn:uuid:")) + { + ss.CurrentDCinemaSubtitleId = "urn:uuid:" + Guid.NewGuid(); + } + + xml.DocumentElement.SelectSingleNode("dcst:Id", nsmgr).InnerText = ss.CurrentDCinemaSubtitleId; + xml.DocumentElement.SelectSingleNode("dcst:ReelNumber", nsmgr).InnerText = ss.CurrentDCinemaReelNumber; + xml.DocumentElement.SelectSingleNode("dcst:IssueDate", nsmgr).InnerText = ss.CurrentDCinemaIssueDate; + if (string.IsNullOrEmpty(ss.CurrentDCinemaLanguage)) + { + ss.CurrentDCinemaLanguage = "en"; + } + + xml.DocumentElement.SelectSingleNode("dcst:Language", nsmgr).InnerText = ss.CurrentDCinemaLanguage; + if (ss.CurrentDCinemaEditRate == null && ss.CurrentDCinemaTimeCodeRate == null) + { + if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 24) < 0.01) + { + ss.CurrentDCinemaEditRate = "24 1"; + ss.CurrentDCinemaTimeCodeRate = "24"; + } + else + { + ss.CurrentDCinemaEditRate = "25 1"; + ss.CurrentDCinemaTimeCodeRate = "25"; + } + } + xml.DocumentElement.SelectSingleNode("dcst:EditRate", nsmgr).InnerText = ss.CurrentDCinemaEditRate; + xml.DocumentElement.SelectSingleNode("dcst:TimeCodeRate", nsmgr).InnerText = ss.CurrentDCinemaTimeCodeRate; + if (string.IsNullOrEmpty(ss.CurrentDCinemaStartTime)) + { + ss.CurrentDCinemaStartTime = "00:00:00:00"; + } + + xml.DocumentElement.SelectSingleNode("dcst:StartTime", nsmgr).InnerText = ss.CurrentDCinemaStartTime; + xml.DocumentElement.SelectSingleNode("dcst:LoadFont", nsmgr).InnerText = ss.CurrentDCinemaFontUri; + int fontSize = ss.CurrentDCinemaFontSize; + string loadedFontId = "Font1"; + if (!string.IsNullOrEmpty(ss.CurrentDCinemaFontId)) + { + loadedFontId = ss.CurrentDCinemaFontId; + } + + xml.DocumentElement.SelectSingleNode("dcst:LoadFont", nsmgr).Attributes["ID"].Value = loadedFontId; + xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Size"].Value = fontSize.ToString(); + xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Color"].Value = "FF" + Utilities.ColorToHex(ss.CurrentDCinemaFontColor).TrimStart('#').ToUpperInvariant(); + xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["ID"].Value = loadedFontId; + xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["Effect"].Value = ss.CurrentDCinemaFontEffect; + xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr).Attributes["EffectColor"].Value = "FF" + Utilities.ColorToHex(ss.CurrentDCinemaFontEffectColor).TrimStart('#').ToUpperInvariant(); + + XmlNode mainListFont = xml.DocumentElement.SelectSingleNode("dcst:SubtitleList/dcst:Font", nsmgr); + int no = 0; + foreach (Paragraph p in subtitle.Paragraphs) + { + if (p.Text != null) + { + XmlNode subNode = xml.CreateElement("dcst:Subtitle", "dcst"); + + XmlAttribute id = xml.CreateAttribute("SpotNumber"); + id.InnerText = (no + 1).ToString(); + subNode.Attributes.Append(id); + + XmlAttribute fadeUpTime = xml.CreateAttribute("FadeUpTime"); + fadeUpTime.InnerText = new TimeCode(FramesToMilliseconds(Configuration.Settings.SubtitleSettings.DCinemaFadeUpTime)).ToHHMMSSFF(); + subNode.Attributes.Append(fadeUpTime); + + XmlAttribute fadeDownTime = xml.CreateAttribute("FadeDownTime"); + fadeDownTime.InnerText = new TimeCode(FramesToMilliseconds(Configuration.Settings.SubtitleSettings.DCinemaFadeDownTime)).ToHHMMSSFF(); + subNode.Attributes.Append(fadeDownTime); + + XmlAttribute start = xml.CreateAttribute("TimeIn"); + start.InnerText = ConvertToTimeString(p.StartTime); + subNode.Attributes.Append(start); + + XmlAttribute end = xml.CreateAttribute("TimeOut"); + end.InnerText = ConvertToTimeString(p.EndTime); + subNode.Attributes.Append(end); + + bool alignLeft = p.Text.StartsWith("{\\a1}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a5}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a9}", StringComparison.Ordinal) || // sub station alpha + p.Text.StartsWith("{\\an1}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an7}", StringComparison.Ordinal); // advanced sub station alpha + + bool alignRight = p.Text.StartsWith("{\\a3}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a7}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a11}", StringComparison.Ordinal) || // sub station alpha + p.Text.StartsWith("{\\an3}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an6}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); // advanced sub station alpha + + bool alignVTop = p.Text.StartsWith("{\\a5}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a6}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a7}", StringComparison.Ordinal) || // sub station alpha + p.Text.StartsWith("{\\an7}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an8}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); // advanced sub station alpha + + bool alignVCenter = p.Text.StartsWith("{\\a9}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a10}", StringComparison.Ordinal) || p.Text.StartsWith("{\\a11}", StringComparison.Ordinal) || // sub station alpha + p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an5}", StringComparison.Ordinal) || p.Text.StartsWith("{\\an6}", StringComparison.Ordinal); // advanced sub station alpha + + string text = Utilities.RemoveSsaTags(p.Text); + + var lines = text.SplitToLines(); + int vPos = 1 + lines.Count * 7; + int vPosFactor = (int)Math.Round(fontSize / 7.4); + if (alignVTop) + { + vPos = Configuration.Settings.SubtitleSettings.DCinemaBottomMargin; // Bottom margin is normally 8 + } + else if (alignVCenter) + { + vPos = (int)Math.Round((lines.Count * vPosFactor * -1) / 2.0); + } + else + { + vPos = (lines.Count * vPosFactor) - vPosFactor + Configuration.Settings.SubtitleSettings.DCinemaBottomMargin; // Bottom margin is normally 8 + } + + bool isItalic = false; + int fontNo = 0; + Stack fontColors = new Stack(); + foreach (string line in lines) + { + XmlNode textNode = xml.CreateElement("dcst:Text", "dcst"); + + XmlAttribute vPosition = xml.CreateAttribute("Vposition"); + vPosition.InnerText = vPos.ToString(); + textNode.Attributes.Append(vPosition); + + XmlAttribute vAlign = xml.CreateAttribute("Valign"); + if (alignVTop) + { + vAlign.InnerText = "top"; + } + else if (alignVCenter) + { + vAlign.InnerText = "center"; + } + else + { + vAlign.InnerText = "bottom"; + } + + textNode.Attributes.Append(vAlign); textNode.Attributes.Append(vAlign); + + XmlAttribute hAlign = xml.CreateAttribute("Halign"); + if (alignLeft) + { + hAlign.InnerText = "left"; + } + else if (alignRight) + { + hAlign.InnerText = "right"; + } + else + { + hAlign.InnerText = "center"; + } + + textNode.Attributes.Append(hAlign); + + XmlAttribute direction = xml.CreateAttribute("Direction"); + direction.InnerText = "ltr"; + textNode.Attributes.Append(direction); + + int i = 0; + var txt = new StringBuilder(); + var html = new StringBuilder(); + XmlNode nodeTemp = xml.CreateElement("temp"); + while (i < line.Length) + { + if (!isItalic && line.Substring(i).StartsWith("", StringComparison.Ordinal)) + { + if (txt.Length > 0) + { + nodeTemp.InnerText = txt.ToString(); + html.Append(nodeTemp.InnerXml); + txt.Clear(); + } + isItalic = true; + i += 2; + } + else if (isItalic && line.Substring(i).StartsWith("", StringComparison.Ordinal)) + { + if (txt.Length > 0) + { + XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); + + XmlAttribute italic = xml.CreateAttribute("Italic"); + italic.InnerText = "yes"; + fontNode.Attributes.Append(italic); + + if (line.Length > i + 5 && line.Substring(i + 4).StartsWith("", StringComparison.Ordinal)) + { + XmlAttribute fontColor = xml.CreateAttribute("Color"); + fontColor.InnerText = fontColors.Pop(); + fontNode.Attributes.Append(fontColor); + fontNo--; + i += 7; + } + + fontNode.InnerText = HtmlUtil.RemoveHtmlTags(txt.ToString()); + html.Append(fontNode.OuterXml); + txt.Clear(); + } + isItalic = false; + i += 3; + } + else if (line.Substring(i).StartsWith("", StringComparison.Ordinal)) + { + if (txt.Length > 0) + { + XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); + + XmlAttribute fontColor = xml.CreateAttribute("Color"); + fontColor.InnerText = fontColors.Pop(); + fontNode.Attributes.Append(fontColor); + + if (line.Length > i + 9 && line.Substring(i + 7).StartsWith("", StringComparison.Ordinal)) + { + XmlAttribute italic = xml.CreateAttribute("Italic"); + italic.InnerText = "yes"; + fontNode.Attributes.Append(italic); + isItalic = false; + i += 4; + } + + fontNode.InnerText = HtmlUtil.RemoveHtmlTags(txt.ToString()); + html.Append(fontNode.OuterXml); + txt.Clear(); + } + fontNo--; + i += 6; + } + else + { + txt.Append(line[i]); + } + i++; + } + + if (fontNo > 0) + { + if (txt.Length > 0) + { + XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); + + XmlAttribute fontColor = xml.CreateAttribute("Color"); + fontColor.InnerText = fontColors.Peek(); + fontNode.Attributes.Append(fontColor); + + if (isItalic) + { + XmlAttribute italic = xml.CreateAttribute("Italic"); + italic.InnerText = "yes"; + fontNode.Attributes.Append(italic); + } + + fontNode.InnerText = HtmlUtil.RemoveHtmlTags(txt.ToString()); + html.Append(fontNode.OuterXml); + } + else if (html.Length > 0 && html.ToString().StartsWith("" + html.ToString().Replace("dcst:Font", "Font") + ""); + XmlNode fontNode = xml.CreateElement("dcst:Font"); + fontNode.InnerXml = temp.DocumentElement.SelectSingleNode("Font").InnerXml; + foreach (XmlAttribute a in temp.DocumentElement.SelectSingleNode("Font").Attributes) + { + XmlAttribute newA = xml.CreateAttribute(a.Name); + newA.InnerText = a.InnerText; + fontNode.Attributes.Append(newA); + } + + XmlAttribute fontColor = xml.CreateAttribute("Color"); + fontColor.InnerText = fontColors.Peek(); + fontNode.Attributes.Append(fontColor); + + html.Clear(); + html.Append(fontNode.OuterXml); + } + } + else if (isItalic) + { + if (txt.Length > 0) + { + XmlNode fontNode = xml.CreateElement("dcst:Font", "dcst"); + + XmlAttribute italic = xml.CreateAttribute("Italic"); + italic.InnerText = "yes"; + fontNode.Attributes.Append(italic); + + fontNode.InnerText = HtmlUtil.RemoveHtmlTags(line); + html.Append(fontNode.OuterXml); + } + } + else + { + if (txt.Length > 0) + { + nodeTemp.InnerText = txt.ToString(); + html.Append(nodeTemp.InnerXml); + } + } + textNode.InnerXml = html.ToString(); + + subNode.AppendChild(textNode); + if (alignVTop) + { + vPos += vPosFactor; + } + else + { + vPos -= vPosFactor; + } + } + if (subNode.InnerXml.Length == 0) + { // Empty text is just one space + XmlNode textNode = xml.CreateElement("dcst:Text", "dcst"); + textNode.InnerXml = " "; + subNode.AppendChild(textNode); + + XmlAttribute vPosition = xml.CreateAttribute("Vposition"); + vPosition.InnerText = vPos.ToString(); + textNode.Attributes.Append(vPosition); + + XmlAttribute vAlign = xml.CreateAttribute("Valign"); + vAlign.InnerText = "bottom"; + textNode.Attributes.Append(vAlign); + } + mainListFont.AppendChild(subNode); + no++; + } + } + string result = ToUtf8XmlString(xml).Replace("encoding=\"utf-8\"", "encoding=\"UTF-8\"").Replace(" xmlns:dcst=\"dcst\"", string.Empty); + + const string res = "Nikse.SubtitleEdit.Resources.SMPTE-428-7-2010-DCST.xsd.gz"; + System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); + Stream strm = asm.GetManifestResourceStream(res); + if (strm != null) + { + try + { + var xmld = new XmlDocument(); + var rdr = new StreamReader(strm); + var zip = new GZipStream(rdr.BaseStream, CompressionMode.Decompress); + xmld.LoadXml(result); + using (var xr = XmlReader.Create(zip)) + { + xmld.Schemas.Add(null, xr); + xmld.Validate(ValidationCallBack); + } + } + catch (Exception exception) + { + Errors = "Error validating xml via SMPTE-428-7-2010-DCST.xsd: " + exception.Message; + } + } + return FixDcsTextSameLine(result); + } + + /// + /// All space characters present inside the content of a Text element shall be rendered + /// + internal static string FixDcsTextSameLine(string xml) + { + int index = xml.IndexOf(" 0 && endIndex > 0) + { + endIndex = xml.IndexOf("", index, StringComparison.Ordinal); + if (endIndex > 0) + { + var part = xml.Substring(index, endIndex - index); + if (part.Contains(Environment.NewLine)) + { + part = part.Replace(Environment.NewLine, " "); + while (part.Contains(" ")) + { + part = part.Replace(" ", " "); + } + part = part.Replace("> <", "><"); + } + xml = xml.Remove(index, endIndex - index).Insert(index, part); + index = xml.IndexOf(" lines, string fileName) + { + _errorCount = 0; + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + xml.LoadXml(sb.ToString().Replace(" 0 && lastVPosition.Length > 0) + { + pText.AppendLine(); + } + + lastVPosition = vPosition; + } + } + + bool alignLeft = false; + bool alignRight = false; + bool alignVTop = false; + bool alignVCenter = false; + if (innerNode.Attributes["Halign"] != null) + { + string hAlign = innerNode.Attributes["Halign"].InnerText; + if (hAlign == "left") + { + alignLeft = true; + } + else if (hAlign == "right") + { + alignRight = true; + } + } + + if (innerNode.Attributes["Valign"] != null) + { + string hAlign = innerNode.Attributes["Valign"].InnerText; + if (hAlign == "top") + { + alignVTop = true; + } + else if (hAlign == "center") + { + alignVCenter = true; + } + } + + if (alignLeft || alignRight || alignVCenter || alignVTop) + { + if (!pText.ToString().StartsWith("{\\an", StringComparison.Ordinal)) + { + string pre = string.Empty; + if (alignVTop) + { + if (alignLeft) + { + pre = "{\\an7}"; + } + else if (alignRight) + { + pre = "{\\an9}"; + } + else + { + pre = "{\\an8}"; + } + } + else if (alignVCenter) + { + if (alignLeft) + { + pre = "{\\an4}"; + } + else if (alignRight) + { + pre = "{\\an6}"; + } + else + { + pre = "{\\an5}"; + } + } + else + { + if (alignLeft) + { + pre = "{\\an1}"; + } + else if (alignRight) + { + pre = "{\\an3}"; + } + } + + string temp = pre + pText; + pText.Clear(); + pText.Append(temp); + } + } + + if (innerNode.ChildNodes.Count == 0) + { + pText.Append(innerNode.InnerText); + } + else + { + foreach (XmlNode innerInnerNode in innerNode) + { + if (innerInnerNode.Name == "Font" && innerInnerNode.Attributes["Italic"] != null && + innerInnerNode.Attributes["Italic"].InnerText.Equals("yes", StringComparison.OrdinalIgnoreCase)) + { + if (innerInnerNode.Attributes["Color"] != null) + { + pText.Append("" + innerInnerNode.InnerText + ""); + } + else + { + pText.Append("" + innerInnerNode.InnerText + ""); + } + } + else if (innerInnerNode.Name == "Font" && innerInnerNode.Attributes["Color"] != null) + { + if (innerInnerNode.Attributes["Italic"] != null && innerInnerNode.Attributes["Italic"].InnerText.Equals("yes", StringComparison.OrdinalIgnoreCase)) + { + pText.Append("" + innerInnerNode.InnerText + ""); + } + else + { + pText.Append("" + innerInnerNode.InnerText + ""); + } + } + else + { + pText.Append(innerInnerNode.InnerText); + } + } + } + } + else + { + pText.Append(innerNode.InnerText); + } + } + string start = node.Attributes["TimeIn"].InnerText; + string end = node.Attributes["TimeOut"].InnerText; + + if (node.ParentNode.Name == "Font" && node.ParentNode.Attributes["Italic"] != null && node.ParentNode.Attributes["Italic"].InnerText.Equals("yes", StringComparison.OrdinalIgnoreCase) && + !pText.ToString().Contains("")) + { + string text = pText.ToString(); + if (text.StartsWith("{\\an", StringComparison.Ordinal) && text.Length > 6) + { + text = text.Insert(6, "") + ""; + } + else + { + text = "" + text + ""; + } + + pText = new StringBuilder(text); + } + + subtitle.Paragraphs.Add(new Paragraph(GetTimeCode(start), GetTimeCode(end), pText.ToString())); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + + if (subtitle.Paragraphs.Count > 0) + { + subtitle.Header = xml.OuterXml; // save id/language/font for later use + } + + subtitle.Renumber(); + } + + private TimeCode GetTimeCode(string s) + { + var parts = s.Split(new[] { ':', '.', ',' }); + + int milliseconds = (int)Math.Round(int.Parse(parts[3]) * (TimeCode.BaseUnit / _frameRate)); + if (milliseconds > 999) + { + milliseconds = 999; + } + + return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), milliseconds); + } + + public static int MsToFramesMaxFrameRate(double milliseconds, double frameRate) + { + int frames = (int)Math.Round(milliseconds / (TimeCode.BaseUnit / frameRate)); + if (frames >= Configuration.Settings.General.CurrentFrameRate) + { + frames = (int)(frameRate - 0.01); + } + + return frames; + } + + private string ConvertToTimeString(TimeCode time) + { + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MsToFramesMaxFrameRate(time.Milliseconds, _frameRate):00}"; + } + + } +} diff --git a/libse/SubtitleFormats/DCinemaSmpte2014.cs b/src/libse/SubtitleFormats/DCinemaSmpte2014.cs similarity index 100% rename from libse/SubtitleFormats/DCinemaSmpte2014.cs rename to src/libse/SubtitleFormats/DCinemaSmpte2014.cs diff --git a/libse/SubtitleFormats/DigiBeta.cs b/src/libse/SubtitleFormats/DigiBeta.cs similarity index 97% rename from libse/SubtitleFormats/DigiBeta.cs rename to src/libse/SubtitleFormats/DigiBeta.cs index a422891f6..81202a2be 100644 --- a/libse/SubtitleFormats/DigiBeta.cs +++ b/src/libse/SubtitleFormats/DigiBeta.cs @@ -1,72 +1,72 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class DigiBeta : SubtitleFormat - { - private static readonly Regex RegexTimeCode = new Regex(@"^\d\d \d\d \d\d \d\d\t\d\d \d\d \d\d \d\d\t", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "DigiBeta"; - - public override string ToText(Subtitle subtitle, string title) - { - //10 01 37 23 10 01 42 01 Makkhi (newline is TAB) - const string paragraphWriteFormat = "{0}\t{1}\t{2}"; - - var sb = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), p.Text.Replace(Environment.NewLine, "\t"))); - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - subtitle.Paragraphs.Clear(); - foreach (string line in lines) - { - if (RegexTimeCode.IsMatch(line) && line.Length > 24) - { - string[] parts = line.Substring(0, 11).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - if (parts.Length == 4) - { - try - { - var start = DecodeTimeCodeFramesFourParts(parts); - parts = line.Substring(12, 11).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - var end = DecodeTimeCodeFramesFourParts(parts); - var paragraph = new Paragraph - { - StartTime = start, - EndTime = end, - Text = line.Substring(24).Trim().Replace("\t", Environment.NewLine) - }; - - subtitle.Paragraphs.Add(paragraph); - } - catch - { - _errorCount++; - } - } - } - } - subtitle.Renumber(); - } - - private static string EncodeTimeCode(TimeCode time) - { - return $"{time.Hours:00} {time.Minutes:00} {time.Seconds:00} {MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class DigiBeta : SubtitleFormat + { + private static readonly Regex RegexTimeCode = new Regex(@"^\d\d \d\d \d\d \d\d\t\d\d \d\d \d\d \d\d\t", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "DigiBeta"; + + public override string ToText(Subtitle subtitle, string title) + { + //10 01 37 23 10 01 42 01 Makkhi (newline is TAB) + const string paragraphWriteFormat = "{0}\t{1}\t{2}"; + + var sb = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), p.Text.Replace(Environment.NewLine, "\t"))); + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + subtitle.Paragraphs.Clear(); + foreach (string line in lines) + { + if (RegexTimeCode.IsMatch(line) && line.Length > 24) + { + string[] parts = line.Substring(0, 11).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + if (parts.Length == 4) + { + try + { + var start = DecodeTimeCodeFramesFourParts(parts); + parts = line.Substring(12, 11).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + var end = DecodeTimeCodeFramesFourParts(parts); + var paragraph = new Paragraph + { + StartTime = start, + EndTime = end, + Text = line.Substring(24).Trim().Replace("\t", Environment.NewLine) + }; + + subtitle.Paragraphs.Add(paragraph); + } + catch + { + _errorCount++; + } + } + } + } + subtitle.Renumber(); + } + + private static string EncodeTimeCode(TimeCode time) + { + return $"{time.Hours:00} {time.Minutes:00} {time.Seconds:00} {MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + } +} diff --git a/libse/SubtitleFormats/DlDd.cs b/src/libse/SubtitleFormats/DlDd.cs similarity index 100% rename from libse/SubtitleFormats/DlDd.cs rename to src/libse/SubtitleFormats/DlDd.cs diff --git a/libse/SubtitleFormats/Dost.cs b/src/libse/SubtitleFormats/Dost.cs similarity index 97% rename from libse/SubtitleFormats/Dost.cs rename to src/libse/SubtitleFormats/Dost.cs index 9c3db4bbb..1028918d9 100644 --- a/libse/SubtitleFormats/Dost.cs +++ b/src/libse/SubtitleFormats/Dost.cs @@ -1,104 +1,104 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Dost : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d\d\d\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t", RegexOptions.Compiled); - - public override string Extension => ".dost"; - - public override string Name => "DOST"; - - public override bool IsMine(List lines, string fileName) - { - var sb = new StringBuilder(); - foreach (string line in lines) - { - sb.AppendLine(line); - } - - if (!sb.ToString().Contains(Environment.NewLine + "NO\tINTIME")) - { - return false; - } - - if (!sb.ToString().Contains("$FORMAT")) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - return "Not implemented"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - //0001 01:25:59:21 01:26:00:20 0 0 BK02-total_0001.png 0 0 - Paragraph p = null; - subtitle.Paragraphs.Clear(); - _errorCount = 0; - foreach (string line in lines) - { - string s = line; - if (RegexTimeCodes.IsMatch(s)) - { - var temp = s.Split('\t'); - if (temp.Length > 7) - { - string start = temp[1]; - string end = temp[2]; - string text = temp[5]; - try - { - p = new Paragraph(DecodeTimeCodeFramesFourParts(start.Split(':')), DecodeTimeCodeFramesFourParts(end.Split(':')), text); - subtitle.Paragraphs.Add(p); - } - catch (Exception exception) - { - _errorCount++; - System.Diagnostics.Debug.WriteLine(exception.Message); - } - } - } - else if (line.StartsWith("$DROP=", StringComparison.Ordinal)) - { - s = s.Remove(0, "$DROP=".Length); - int frameRate; - if (int.TryParse(s, out frameRate)) - { - double f = frameRate / TimeCode.BaseUnit; - if (f > 10 && f < 500) - { - Configuration.Settings.General.CurrentFrameRate = f; - } - - if (BatchSourceFrameRate.HasValue) - { - Configuration.Settings.General.CurrentFrameRate = BatchSourceFrameRate.Value; - } - } - } - else if (string.IsNullOrWhiteSpace(line) || line.StartsWith('$')) - { - // skip empty lines or lines starting with $ - } - else if (!string.IsNullOrWhiteSpace(line) && p != null) - { - _errorCount++; - } - } - - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Dost : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d\d\d\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t", RegexOptions.Compiled); + + public override string Extension => ".dost"; + + public override string Name => "DOST"; + + public override bool IsMine(List lines, string fileName) + { + var sb = new StringBuilder(); + foreach (string line in lines) + { + sb.AppendLine(line); + } + + if (!sb.ToString().Contains(Environment.NewLine + "NO\tINTIME")) + { + return false; + } + + if (!sb.ToString().Contains("$FORMAT")) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + return "Not implemented"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + //0001 01:25:59:21 01:26:00:20 0 0 BK02-total_0001.png 0 0 + Paragraph p = null; + subtitle.Paragraphs.Clear(); + _errorCount = 0; + foreach (string line in lines) + { + string s = line; + if (RegexTimeCodes.IsMatch(s)) + { + var temp = s.Split('\t'); + if (temp.Length > 7) + { + string start = temp[1]; + string end = temp[2]; + string text = temp[5]; + try + { + p = new Paragraph(DecodeTimeCodeFramesFourParts(start.Split(':')), DecodeTimeCodeFramesFourParts(end.Split(':')), text); + subtitle.Paragraphs.Add(p); + } + catch (Exception exception) + { + _errorCount++; + System.Diagnostics.Debug.WriteLine(exception.Message); + } + } + } + else if (line.StartsWith("$DROP=", StringComparison.Ordinal)) + { + s = s.Remove(0, "$DROP=".Length); + int frameRate; + if (int.TryParse(s, out frameRate)) + { + double f = frameRate / TimeCode.BaseUnit; + if (f > 10 && f < 500) + { + Configuration.Settings.General.CurrentFrameRate = f; + } + + if (BatchSourceFrameRate.HasValue) + { + Configuration.Settings.General.CurrentFrameRate = BatchSourceFrameRate.Value; + } + } + } + else if (string.IsNullOrWhiteSpace(line) || line.StartsWith('$')) + { + // skip empty lines or lines starting with $ + } + else if (!string.IsNullOrWhiteSpace(line) && p != null) + { + _errorCount++; + } + } + + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/DvSubtitle.cs b/src/libse/SubtitleFormats/DvSubtitle.cs similarity index 100% rename from libse/SubtitleFormats/DvSubtitle.cs rename to src/libse/SubtitleFormats/DvSubtitle.cs diff --git a/libse/SubtitleFormats/DvdStudioPro.cs b/src/libse/SubtitleFormats/DvdStudioPro.cs similarity index 97% rename from libse/SubtitleFormats/DvdStudioPro.cs rename to src/libse/SubtitleFormats/DvdStudioPro.cs index 3031aa419..943725f1b 100644 --- a/libse/SubtitleFormats/DvdStudioPro.cs +++ b/src/libse/SubtitleFormats/DvdStudioPro.cs @@ -1,327 +1,327 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class DvdStudioPro : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d+:\d+:\d+[:;]\d+\t,\t\d+:\d+:\d+[:;]\d+\t,\t.*$", RegexOptions.Compiled); - - public override string Extension => ".STL"; - - public override string Name => "DVD Studio Pro"; - - public override string ToText(Subtitle subtitle, string title) - { - const string paragraphWriteFormat = "{0}\t,\t{1}\t,\t{2}\r\n"; - const string timeFormat = "{0:00}:{1:00}:{2:00}:{3:00}"; - var header = Configuration.Settings.SubtitleSettings.DvdStudioProHeader.TrimEnd() + Environment.NewLine; - - var lastVerticalAlign = "$VertAlign = Bottom"; - var lastHorizontalcalAlign = "$HorzAlign = Center"; - var sb = new StringBuilder(); - sb.AppendLine(header); - foreach (Paragraph p in subtitle.Paragraphs) - { - string startTime = string.Format(timeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds)); - string endTime = string.Format(timeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds)); - sb = ToTextAlignment(p, sb, ref lastVerticalAlign, ref lastHorizontalcalAlign); - sb.AppendFormat(paragraphWriteFormat, startTime, endTime, EncodeStyles(p.Text)); - } - return sb.ToString().Trim(); - } - - internal static StringBuilder ToTextAlignment(Paragraph p, StringBuilder sb, ref string lastVerticalAlign, ref string lastHorizontalAlign) - { - string verticalAlign; - string horizontalAlign; - bool verticalTopAlign = p.Text.StartsWith("{\\an7}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an8}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); - bool verticalCenterAlign = p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an5}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an6}", StringComparison.Ordinal); - if (verticalTopAlign) - { - verticalAlign = "$VertAlign = Top"; - } - else if (verticalCenterAlign) - { - verticalAlign = "$VertAlign = Center"; - } - else - { - verticalAlign = "$VertAlign = Bottom"; - } - - if (lastVerticalAlign != verticalAlign) - { - sb.AppendLine(verticalAlign); - } - - bool horizontalLeftAlign = p.Text.StartsWith("{\\an1}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an7}", StringComparison.Ordinal); - bool horizontalRightAlign = p.Text.StartsWith("{\\an3}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an6}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); - if (horizontalLeftAlign) - { - horizontalAlign = "$HorzAlign = Left"; - } - else if (horizontalRightAlign) - { - horizontalAlign = "$HorzAlign = Right"; - } - else - { - horizontalAlign = "$HorzAlign = Center"; - } - - if (lastHorizontalAlign != horizontalAlign) - { - sb.AppendLine(horizontalAlign); - } - - lastVerticalAlign = verticalAlign; - lastHorizontalAlign = horizontalAlign; - return sb; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - int number = 0; - var verticalAlign = "$VertAlign=Bottom"; - var horizontalAlign = "$HorzAlign=Center"; - bool italicOn = false; - bool boldOn = false; - bool underlineOn = false; - - foreach (string line in lines) - { - if (!string.IsNullOrWhiteSpace(line) && line[0] != '$') - { - if (RegexTimeCodes.Match(line).Success) - { - string[] threePart = line.Split(new[] { "\t,\t" }, StringSplitOptions.None); - var p = new Paragraph(); - if (threePart.Length == 3 && - GetTimeCode(p.StartTime, threePart[0]) && - GetTimeCode(p.EndTime, threePart[1])) - { - number++; - p.Number = number; - p.Text = threePart[2].TrimEnd().Replace(" | ", Environment.NewLine).Replace("|", Environment.NewLine); - p.Text = DecodeStyles(p.Text); - if (italicOn && !p.Text.Contains("")) - { - p.Text = "" + p.Text + ""; - } - if (boldOn && !p.Text.Contains("")) - { - p.Text = "" + p.Text + ""; - } - if (underlineOn && !p.Text.Contains("")) - { - p.Text = "" + p.Text + ""; - } - p.Text = GetAlignment(verticalAlign, horizontalAlign) + p.Text; - subtitle.Paragraphs.Add(p); - } - } - else - { - _errorCount++; - } - } - else if (line != null && line.TrimStart().StartsWith("$VertAlign", StringComparison.OrdinalIgnoreCase)) - { - verticalAlign = line.RemoveChar(' ').RemoveChar('\t'); - } - else if (line != null && line.TrimStart().StartsWith("$HorzAlign", StringComparison.OrdinalIgnoreCase)) - { - horizontalAlign = line.RemoveChar(' ').RemoveChar('\t'); - } - else if (line.Replace(" ", string.Empty).Equals("$Italic=True", StringComparison.OrdinalIgnoreCase)) - { - italicOn = true; - } - else if (line.Replace(" ", string.Empty).Trim().Equals("$Italic=False", StringComparison.OrdinalIgnoreCase)) - { - italicOn = false; - } - else if (line.Replace(" ", string.Empty).Equals("$Bold=True", StringComparison.OrdinalIgnoreCase)) - { - boldOn = true; - } - else if (line.Replace(" ", string.Empty).Trim().Equals("$Bold=False", StringComparison.OrdinalIgnoreCase)) - { - boldOn = false; - } - else if (line.Replace(" ", string.Empty).Equals("$Underlined=True", StringComparison.OrdinalIgnoreCase)) - { - underlineOn = true; - } - else if (line.Replace(" ", string.Empty).Trim().Equals("$Underlined=False", StringComparison.OrdinalIgnoreCase)) - { - underlineOn = false; - } - } - } - - internal static string GetAlignment(string verticalAlign, string horizontalAlign) - { - if (verticalAlign.Equals("$VertAlign=Top", StringComparison.OrdinalIgnoreCase)) - { - if (horizontalAlign.Equals("$HorzAlign=Left", StringComparison.OrdinalIgnoreCase)) - { - return "{\\an7}"; - } - - if (horizontalAlign.Equals("$HorzAlign=Right", StringComparison.OrdinalIgnoreCase)) - { - return "{\\an9}"; - } - - return "{\\an8}"; - } - - if (verticalAlign.Equals("$VertAlign=Center", StringComparison.OrdinalIgnoreCase)) - { - if (horizontalAlign.Equals("$HorzAlign=Left", StringComparison.OrdinalIgnoreCase)) - { - return "{\\an4}"; - } - - if (horizontalAlign.Equals("$HorzAlign=Right", StringComparison.OrdinalIgnoreCase)) - { - return "{\\an6}"; - } - - return "{\\an5}"; - } - - if (horizontalAlign.Equals("$HorzAlign=Left", StringComparison.OrdinalIgnoreCase)) - { - return "{\\an1}"; - } - - if (horizontalAlign.Equals("$HorzAlign=Right", StringComparison.OrdinalIgnoreCase)) - { - return "{\\an3}"; - } - - return string.Empty; - } - - internal static string DecodeStyles(string text) - { - var sb = new StringBuilder(); - bool italicOn = false; - bool boldOn = false; - bool skipNext = false; - for (int i = 0; i < text.Length; i++) - { - if (skipNext) - { - skipNext = false; - } - else - { - if (text.Substring(i).StartsWith("^I", StringComparison.Ordinal)) - { - sb.Append(!italicOn ? "" : ""); - italicOn = !italicOn; - skipNext = true; - } - else if (text.Substring(i).StartsWith("^B", StringComparison.Ordinal)) - { - sb.Append(!boldOn ? "" : ""); - boldOn = !boldOn; - skipNext = true; - } - else - { - sb.Append(text[i]); - } - } - } - return sb.ToString(); - } - - internal static string EncodeStyles(string input) - { - var text = Utilities.RemoveSsaTags(input); - text = text.Replace("", "").Replace("", ""); - bool allItalic = text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(text, "") == 1; - bool allBold = text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(text, "") == 1; - bool allUnderline = text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(text, "") == 1; - bool allUnderlineBoldItalic = text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(text, "") == 1; - bool allBoldItalic = text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(text, "") == 1 && Utilities.CountTagInText(text, "") == 1; - - text = text.Replace("", "^I"); - text = text.Replace("", "^I"); - text = text.Replace("", "^I"); - text = text.Replace("", "^I"); - - text = text.Replace("", "^B"); - text = text.Replace("", "^B"); - text = text.Replace("", "^B"); - text = text.Replace("", "^B"); - - text = text.Replace("", "^U"); - text = text.Replace("", "^U"); - text = text.Replace("", "^U"); - text = text.Replace("", "^U"); - - if (allUnderlineBoldItalic) - { - return text.Replace(Environment.NewLine, "^U^B^I|^I^B^U"); - } - - if (allBoldItalic) - { - return text.Replace(Environment.NewLine, "^U^B^I|^I^B^U"); - } - - if (allItalic) - { - return text.Replace(Environment.NewLine, "^I|^I"); - } - - if (allBold) - { - return text.Replace(Environment.NewLine, "^B|^B"); - } - - if (allUnderline) - { - return text.Replace(Environment.NewLine, "^U|^U"); - } - - return text.Replace(Environment.NewLine, "|"); - } - - internal static bool GetTimeCode(TimeCode timeCode, string timeString) - { - try - { - var timeParts = timeString.Split(':', ';'); - timeCode.Hours = int.Parse(timeParts[0]); - timeCode.Minutes = int.Parse(timeParts[1]); - timeCode.Seconds = int.Parse(timeParts[2]); - timeCode.Milliseconds = FramesToMillisecondsMax999(int.Parse(timeParts[3])); - return true; - } - catch - { - return false; - } - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class DvdStudioPro : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d+:\d+:\d+[:;]\d+\t,\t\d+:\d+:\d+[:;]\d+\t,\t.*$", RegexOptions.Compiled); + + public override string Extension => ".STL"; + + public override string Name => "DVD Studio Pro"; + + public override string ToText(Subtitle subtitle, string title) + { + const string paragraphWriteFormat = "{0}\t,\t{1}\t,\t{2}\r\n"; + const string timeFormat = "{0:00}:{1:00}:{2:00}:{3:00}"; + var header = Configuration.Settings.SubtitleSettings.DvdStudioProHeader.TrimEnd() + Environment.NewLine; + + var lastVerticalAlign = "$VertAlign = Bottom"; + var lastHorizontalcalAlign = "$HorzAlign = Center"; + var sb = new StringBuilder(); + sb.AppendLine(header); + foreach (Paragraph p in subtitle.Paragraphs) + { + string startTime = string.Format(timeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds)); + string endTime = string.Format(timeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds)); + sb = ToTextAlignment(p, sb, ref lastVerticalAlign, ref lastHorizontalcalAlign); + sb.AppendFormat(paragraphWriteFormat, startTime, endTime, EncodeStyles(p.Text)); + } + return sb.ToString().Trim(); + } + + internal static StringBuilder ToTextAlignment(Paragraph p, StringBuilder sb, ref string lastVerticalAlign, ref string lastHorizontalAlign) + { + string verticalAlign; + string horizontalAlign; + bool verticalTopAlign = p.Text.StartsWith("{\\an7}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an8}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); + bool verticalCenterAlign = p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an5}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an6}", StringComparison.Ordinal); + if (verticalTopAlign) + { + verticalAlign = "$VertAlign = Top"; + } + else if (verticalCenterAlign) + { + verticalAlign = "$VertAlign = Center"; + } + else + { + verticalAlign = "$VertAlign = Bottom"; + } + + if (lastVerticalAlign != verticalAlign) + { + sb.AppendLine(verticalAlign); + } + + bool horizontalLeftAlign = p.Text.StartsWith("{\\an1}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an7}", StringComparison.Ordinal); + bool horizontalRightAlign = p.Text.StartsWith("{\\an3}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an6}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); + if (horizontalLeftAlign) + { + horizontalAlign = "$HorzAlign = Left"; + } + else if (horizontalRightAlign) + { + horizontalAlign = "$HorzAlign = Right"; + } + else + { + horizontalAlign = "$HorzAlign = Center"; + } + + if (lastHorizontalAlign != horizontalAlign) + { + sb.AppendLine(horizontalAlign); + } + + lastVerticalAlign = verticalAlign; + lastHorizontalAlign = horizontalAlign; + return sb; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + int number = 0; + var verticalAlign = "$VertAlign=Bottom"; + var horizontalAlign = "$HorzAlign=Center"; + bool italicOn = false; + bool boldOn = false; + bool underlineOn = false; + + foreach (string line in lines) + { + if (!string.IsNullOrWhiteSpace(line) && line[0] != '$') + { + if (RegexTimeCodes.Match(line).Success) + { + string[] threePart = line.Split(new[] { "\t,\t" }, StringSplitOptions.None); + var p = new Paragraph(); + if (threePart.Length == 3 && + GetTimeCode(p.StartTime, threePart[0]) && + GetTimeCode(p.EndTime, threePart[1])) + { + number++; + p.Number = number; + p.Text = threePart[2].TrimEnd().Replace(" | ", Environment.NewLine).Replace("|", Environment.NewLine); + p.Text = DecodeStyles(p.Text); + if (italicOn && !p.Text.Contains("")) + { + p.Text = "" + p.Text + ""; + } + if (boldOn && !p.Text.Contains("")) + { + p.Text = "" + p.Text + ""; + } + if (underlineOn && !p.Text.Contains("")) + { + p.Text = "" + p.Text + ""; + } + p.Text = GetAlignment(verticalAlign, horizontalAlign) + p.Text; + subtitle.Paragraphs.Add(p); + } + } + else + { + _errorCount++; + } + } + else if (line != null && line.TrimStart().StartsWith("$VertAlign", StringComparison.OrdinalIgnoreCase)) + { + verticalAlign = line.RemoveChar(' ').RemoveChar('\t'); + } + else if (line != null && line.TrimStart().StartsWith("$HorzAlign", StringComparison.OrdinalIgnoreCase)) + { + horizontalAlign = line.RemoveChar(' ').RemoveChar('\t'); + } + else if (line.Replace(" ", string.Empty).Equals("$Italic=True", StringComparison.OrdinalIgnoreCase)) + { + italicOn = true; + } + else if (line.Replace(" ", string.Empty).Trim().Equals("$Italic=False", StringComparison.OrdinalIgnoreCase)) + { + italicOn = false; + } + else if (line.Replace(" ", string.Empty).Equals("$Bold=True", StringComparison.OrdinalIgnoreCase)) + { + boldOn = true; + } + else if (line.Replace(" ", string.Empty).Trim().Equals("$Bold=False", StringComparison.OrdinalIgnoreCase)) + { + boldOn = false; + } + else if (line.Replace(" ", string.Empty).Equals("$Underlined=True", StringComparison.OrdinalIgnoreCase)) + { + underlineOn = true; + } + else if (line.Replace(" ", string.Empty).Trim().Equals("$Underlined=False", StringComparison.OrdinalIgnoreCase)) + { + underlineOn = false; + } + } + } + + internal static string GetAlignment(string verticalAlign, string horizontalAlign) + { + if (verticalAlign.Equals("$VertAlign=Top", StringComparison.OrdinalIgnoreCase)) + { + if (horizontalAlign.Equals("$HorzAlign=Left", StringComparison.OrdinalIgnoreCase)) + { + return "{\\an7}"; + } + + if (horizontalAlign.Equals("$HorzAlign=Right", StringComparison.OrdinalIgnoreCase)) + { + return "{\\an9}"; + } + + return "{\\an8}"; + } + + if (verticalAlign.Equals("$VertAlign=Center", StringComparison.OrdinalIgnoreCase)) + { + if (horizontalAlign.Equals("$HorzAlign=Left", StringComparison.OrdinalIgnoreCase)) + { + return "{\\an4}"; + } + + if (horizontalAlign.Equals("$HorzAlign=Right", StringComparison.OrdinalIgnoreCase)) + { + return "{\\an6}"; + } + + return "{\\an5}"; + } + + if (horizontalAlign.Equals("$HorzAlign=Left", StringComparison.OrdinalIgnoreCase)) + { + return "{\\an1}"; + } + + if (horizontalAlign.Equals("$HorzAlign=Right", StringComparison.OrdinalIgnoreCase)) + { + return "{\\an3}"; + } + + return string.Empty; + } + + internal static string DecodeStyles(string text) + { + var sb = new StringBuilder(); + bool italicOn = false; + bool boldOn = false; + bool skipNext = false; + for (int i = 0; i < text.Length; i++) + { + if (skipNext) + { + skipNext = false; + } + else + { + if (text.Substring(i).StartsWith("^I", StringComparison.Ordinal)) + { + sb.Append(!italicOn ? "" : ""); + italicOn = !italicOn; + skipNext = true; + } + else if (text.Substring(i).StartsWith("^B", StringComparison.Ordinal)) + { + sb.Append(!boldOn ? "" : ""); + boldOn = !boldOn; + skipNext = true; + } + else + { + sb.Append(text[i]); + } + } + } + return sb.ToString(); + } + + internal static string EncodeStyles(string input) + { + var text = Utilities.RemoveSsaTags(input); + text = text.Replace("", "").Replace("", ""); + bool allItalic = text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(text, "") == 1; + bool allBold = text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(text, "") == 1; + bool allUnderline = text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(text, "") == 1; + bool allUnderlineBoldItalic = text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(text, "") == 1; + bool allBoldItalic = text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(text, "") == 1 && Utilities.CountTagInText(text, "") == 1; + + text = text.Replace("", "^I"); + text = text.Replace("", "^I"); + text = text.Replace("", "^I"); + text = text.Replace("", "^I"); + + text = text.Replace("", "^B"); + text = text.Replace("", "^B"); + text = text.Replace("", "^B"); + text = text.Replace("", "^B"); + + text = text.Replace("", "^U"); + text = text.Replace("", "^U"); + text = text.Replace("", "^U"); + text = text.Replace("", "^U"); + + if (allUnderlineBoldItalic) + { + return text.Replace(Environment.NewLine, "^U^B^I|^I^B^U"); + } + + if (allBoldItalic) + { + return text.Replace(Environment.NewLine, "^U^B^I|^I^B^U"); + } + + if (allItalic) + { + return text.Replace(Environment.NewLine, "^I|^I"); + } + + if (allBold) + { + return text.Replace(Environment.NewLine, "^B|^B"); + } + + if (allUnderline) + { + return text.Replace(Environment.NewLine, "^U|^U"); + } + + return text.Replace(Environment.NewLine, "|"); + } + + internal static bool GetTimeCode(TimeCode timeCode, string timeString) + { + try + { + var timeParts = timeString.Split(':', ';'); + timeCode.Hours = int.Parse(timeParts[0]); + timeCode.Minutes = int.Parse(timeParts[1]); + timeCode.Seconds = int.Parse(timeParts[2]); + timeCode.Milliseconds = FramesToMillisecondsMax999(int.Parse(timeParts[3])); + return true; + } + catch + { + return false; + } + } + + } +} diff --git a/libse/SubtitleFormats/DvdStudioProSpace.cs b/src/libse/SubtitleFormats/DvdStudioProSpace.cs similarity index 97% rename from libse/SubtitleFormats/DvdStudioProSpace.cs rename to src/libse/SubtitleFormats/DvdStudioProSpace.cs index 62404bc8b..8730d7002 100644 --- a/libse/SubtitleFormats/DvdStudioProSpace.cs +++ b/src/libse/SubtitleFormats/DvdStudioProSpace.cs @@ -1,126 +1,126 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class DvdStudioProSpace : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d+:\d+:\d+[:;]\d+ , \d+:\d+:\d+[:;]\d+ , .*$", RegexOptions.Compiled); - - public override string Extension => ".STL"; - - public override string Name => "DVD Studio Pro with space"; - - - public override string ToText(Subtitle subtitle, string title) - { - const string paragraphWriteFormat = "{0} , {1} , {2}\r\n"; - const string timeFormat = "{0:00}:{1:00}:{2:00}:{3:00}"; - var header = Configuration.Settings.SubtitleSettings.DvdStudioProHeader.TrimEnd() + Environment.NewLine; - - var lastVerticalAlign = "$VertAlign = Bottom"; - var lastHorizontalcalAlign = "$HorzAlign = Center"; - var sb = new StringBuilder(); - sb.AppendLine(header); - foreach (Paragraph p in subtitle.Paragraphs) - { - string startTime = string.Format(timeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds)); - string endTime = string.Format(timeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds)); - DvdStudioPro.ToTextAlignment(p, sb, ref lastVerticalAlign, ref lastHorizontalcalAlign); - sb.AppendFormat(paragraphWriteFormat, startTime, endTime, DvdStudioPro.EncodeStyles(p.Text)); - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - int number = 0; - var verticalAlign = "$VertAlign=Bottom"; - var horizontalAlign = "$HorzAlign=Center"; - bool italicOn = false; - bool boldOn = false; - bool underlineOn = false; - foreach (string line in lines) - { - if (!string.IsNullOrWhiteSpace(line) && line[0] != '$' && !line.StartsWith("//", StringComparison.Ordinal)) - { - if (RegexTimeCodes.Match(line).Success) - { - string[] toPart = line.Substring(0, 25).Split(new[] { " ," }, StringSplitOptions.None); - Paragraph p = new Paragraph(); - if (toPart.Length == 2 && - DvdStudioPro.GetTimeCode(p.StartTime, toPart[0]) && - DvdStudioPro.GetTimeCode(p.EndTime, toPart[1])) - { - number++; - p.Number = number; - string text = line.Substring(27).Trim(); - p.Text = text.Replace(" | ", Environment.NewLine).Replace("|", Environment.NewLine); - p.Text = DvdStudioPro.DecodeStyles(p.Text); - if (p.Text.Trim().StartsWith("<>")) - { - _errorCount++; - } - - if (italicOn && !p.Text.Contains("")) - { - p.Text = "" + p.Text + ""; - } - if (boldOn && !p.Text.Contains("")) - { - p.Text = "" + p.Text + ""; - } - if (underlineOn && !p.Text.Contains("")) - { - p.Text = "" + p.Text + ""; - } - p.Text = DvdStudioPro.GetAlignment(verticalAlign, horizontalAlign) + p.Text; - subtitle.Paragraphs.Add(p); - } - } - else - { - _errorCount++; - } - } - else if (line != null && line.TrimStart().StartsWith("$VertAlign", StringComparison.OrdinalIgnoreCase)) - { - verticalAlign = line.RemoveChar(' ').RemoveChar('\t'); - } - else if (line != null && line.TrimStart().StartsWith("$HorzAlign", StringComparison.OrdinalIgnoreCase)) - { - horizontalAlign = line.RemoveChar(' ').RemoveChar('\t'); - } - else if (line.Replace(" ", string.Empty).Equals("$Italic=True", StringComparison.OrdinalIgnoreCase)) - { - italicOn = true; - } - else if (line.Replace(" ", string.Empty).Trim().Equals("$Italic=False", StringComparison.OrdinalIgnoreCase)) - { - italicOn = false; - } - else if (line.Replace(" ", string.Empty).Equals("$Bold=True", StringComparison.OrdinalIgnoreCase)) - { - boldOn = true; - } - else if (line.Replace(" ", string.Empty).Trim().Equals("$Bold=False", StringComparison.OrdinalIgnoreCase)) - { - boldOn = false; - } - else if (line.Replace(" ", string.Empty).Equals("$Underlined=True", StringComparison.OrdinalIgnoreCase)) - { - underlineOn = true; - } - else if (line.Replace(" ", string.Empty).Trim().Equals("$Underlined=False", StringComparison.OrdinalIgnoreCase)) - { - underlineOn = false; - } - } - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class DvdStudioProSpace : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d+:\d+:\d+[:;]\d+ , \d+:\d+:\d+[:;]\d+ , .*$", RegexOptions.Compiled); + + public override string Extension => ".STL"; + + public override string Name => "DVD Studio Pro with space"; + + + public override string ToText(Subtitle subtitle, string title) + { + const string paragraphWriteFormat = "{0} , {1} , {2}\r\n"; + const string timeFormat = "{0:00}:{1:00}:{2:00}:{3:00}"; + var header = Configuration.Settings.SubtitleSettings.DvdStudioProHeader.TrimEnd() + Environment.NewLine; + + var lastVerticalAlign = "$VertAlign = Bottom"; + var lastHorizontalcalAlign = "$HorzAlign = Center"; + var sb = new StringBuilder(); + sb.AppendLine(header); + foreach (Paragraph p in subtitle.Paragraphs) + { + string startTime = string.Format(timeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds)); + string endTime = string.Format(timeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds)); + DvdStudioPro.ToTextAlignment(p, sb, ref lastVerticalAlign, ref lastHorizontalcalAlign); + sb.AppendFormat(paragraphWriteFormat, startTime, endTime, DvdStudioPro.EncodeStyles(p.Text)); + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + int number = 0; + var verticalAlign = "$VertAlign=Bottom"; + var horizontalAlign = "$HorzAlign=Center"; + bool italicOn = false; + bool boldOn = false; + bool underlineOn = false; + foreach (string line in lines) + { + if (!string.IsNullOrWhiteSpace(line) && line[0] != '$' && !line.StartsWith("//", StringComparison.Ordinal)) + { + if (RegexTimeCodes.Match(line).Success) + { + string[] toPart = line.Substring(0, 25).Split(new[] { " ," }, StringSplitOptions.None); + Paragraph p = new Paragraph(); + if (toPart.Length == 2 && + DvdStudioPro.GetTimeCode(p.StartTime, toPart[0]) && + DvdStudioPro.GetTimeCode(p.EndTime, toPart[1])) + { + number++; + p.Number = number; + string text = line.Substring(27).Trim(); + p.Text = text.Replace(" | ", Environment.NewLine).Replace("|", Environment.NewLine); + p.Text = DvdStudioPro.DecodeStyles(p.Text); + if (p.Text.Trim().StartsWith("<>")) + { + _errorCount++; + } + + if (italicOn && !p.Text.Contains("")) + { + p.Text = "" + p.Text + ""; + } + if (boldOn && !p.Text.Contains("")) + { + p.Text = "" + p.Text + ""; + } + if (underlineOn && !p.Text.Contains("")) + { + p.Text = "" + p.Text + ""; + } + p.Text = DvdStudioPro.GetAlignment(verticalAlign, horizontalAlign) + p.Text; + subtitle.Paragraphs.Add(p); + } + } + else + { + _errorCount++; + } + } + else if (line != null && line.TrimStart().StartsWith("$VertAlign", StringComparison.OrdinalIgnoreCase)) + { + verticalAlign = line.RemoveChar(' ').RemoveChar('\t'); + } + else if (line != null && line.TrimStart().StartsWith("$HorzAlign", StringComparison.OrdinalIgnoreCase)) + { + horizontalAlign = line.RemoveChar(' ').RemoveChar('\t'); + } + else if (line.Replace(" ", string.Empty).Equals("$Italic=True", StringComparison.OrdinalIgnoreCase)) + { + italicOn = true; + } + else if (line.Replace(" ", string.Empty).Trim().Equals("$Italic=False", StringComparison.OrdinalIgnoreCase)) + { + italicOn = false; + } + else if (line.Replace(" ", string.Empty).Equals("$Bold=True", StringComparison.OrdinalIgnoreCase)) + { + boldOn = true; + } + else if (line.Replace(" ", string.Empty).Trim().Equals("$Bold=False", StringComparison.OrdinalIgnoreCase)) + { + boldOn = false; + } + else if (line.Replace(" ", string.Empty).Equals("$Underlined=True", StringComparison.OrdinalIgnoreCase)) + { + underlineOn = true; + } + else if (line.Replace(" ", string.Empty).Trim().Equals("$Underlined=False", StringComparison.OrdinalIgnoreCase)) + { + underlineOn = false; + } + } + } + + } +} diff --git a/libse/SubtitleFormats/DvdStudioProSpaceGraphic.cs b/src/libse/SubtitleFormats/DvdStudioProSpaceGraphic.cs similarity index 100% rename from libse/SubtitleFormats/DvdStudioProSpaceGraphic.cs rename to src/libse/SubtitleFormats/DvdStudioProSpaceGraphic.cs diff --git a/libse/SubtitleFormats/DvdStudioProSpaceOne.cs b/src/libse/SubtitleFormats/DvdStudioProSpaceOne.cs similarity index 97% rename from libse/SubtitleFormats/DvdStudioProSpaceOne.cs rename to src/libse/SubtitleFormats/DvdStudioProSpaceOne.cs index 96082b4c7..42b17b1f7 100644 --- a/libse/SubtitleFormats/DvdStudioProSpaceOne.cs +++ b/src/libse/SubtitleFormats/DvdStudioProSpaceOne.cs @@ -1,125 +1,125 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class DvdStudioProSpaceOne : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d+:\d+:\d+:\d+,\d+:\d+:\d+:\d+, .*$", RegexOptions.Compiled); - - public override string Extension => ".STL"; - - public override string Name => "DVD Studio Pro with one space"; - - public override string ToText(Subtitle subtitle, string title) - { - const string paragraphWriteFormat = "{0},{1}, {2}\r\n"; - const string timeFormat = "{0:00}:{1:00}:{2:00}:{3:00}"; - var header = Configuration.Settings.SubtitleSettings.DvdStudioProHeader.TrimEnd() + Environment.NewLine; - - var lastVerticalAlign = "$VertAlign = Bottom"; - var lastHorizontalcalAlign = "$HorzAlign = Center"; - var sb = new StringBuilder(); - sb.AppendLine(header); - foreach (Paragraph p in subtitle.Paragraphs) - { - string startTime = string.Format(timeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds)); - string endTime = string.Format(timeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds)); - DvdStudioPro.ToTextAlignment(p, sb, ref lastVerticalAlign, ref lastHorizontalcalAlign); - sb.AppendFormat(paragraphWriteFormat, startTime, endTime, DvdStudioPro.EncodeStyles(p.Text)); - } - return sb.ToString().Trim(); - } - - public static byte GetFrameFromMilliseconds(int milliseconds, double frameRate) - { - return (byte)Math.Round(milliseconds / (TimeCode.BaseUnit / frameRate)); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - int number = 0; - var verticalAlign = "$VertAlign=Bottom"; - var horizontalAlign = "$HorzAlign=Center"; - bool italicOn = false; - bool boldOn = false; - bool underlineOn = false; - foreach (string line in lines) - { - if (!string.IsNullOrWhiteSpace(line) && line[0] != '$' && !line.StartsWith("//", StringComparison.Ordinal)) - { - if (RegexTimeCodes.Match(line).Success) - { - string[] toPart = line.Substring(0, 24).Trim(',').Split(','); - var p = new Paragraph(); - if (toPart.Length == 2 && - DvdStudioPro.GetTimeCode(p.StartTime, toPart[0]) && - DvdStudioPro.GetTimeCode(p.EndTime, toPart[1])) - { - number++; - p.Number = number; - string text = line.Substring(25).Trim(); - p.Text = text.Replace(" | ", Environment.NewLine).Replace("|", Environment.NewLine); - p.Text = DvdStudioPro.DecodeStyles(p.Text); - if (italicOn && !p.Text.Contains("")) - { - p.Text = "" + p.Text + ""; - } - if (boldOn && !p.Text.Contains("")) - { - p.Text = "" + p.Text + ""; - } - if (underlineOn && !p.Text.Contains("")) - { - p.Text = "" + p.Text + ""; - } - p.Text = DvdStudioPro.GetAlignment(verticalAlign, horizontalAlign) + p.Text; - subtitle.Paragraphs.Add(p); - } - } - else - { - _errorCount++; - } - } - else if (line != null && line.TrimStart().StartsWith("$VertAlign", StringComparison.OrdinalIgnoreCase)) - { - verticalAlign = line.RemoveChar(' ').RemoveChar('\t'); - } - else if (line != null && line.TrimStart().StartsWith("$HorzAlign", StringComparison.OrdinalIgnoreCase)) - { - horizontalAlign = line.RemoveChar(' ').RemoveChar('\t'); - } - else if (line.Replace(" ", string.Empty).Equals("$Italic=True", StringComparison.OrdinalIgnoreCase)) - { - italicOn = true; - } - else if (line.Replace(" ", string.Empty).Trim().Equals("$Italic=False", StringComparison.OrdinalIgnoreCase)) - { - italicOn = false; - } - else if (line.Replace(" ", string.Empty).Equals("$Bold=True", StringComparison.OrdinalIgnoreCase)) - { - boldOn = true; - } - else if (line.Replace(" ", string.Empty).Trim().Equals("$Bold=False", StringComparison.OrdinalIgnoreCase)) - { - boldOn = false; - } - else if (line.Replace(" ", string.Empty).Equals("$Underlined=True", StringComparison.OrdinalIgnoreCase)) - { - underlineOn = true; - } - else if (line.Replace(" ", string.Empty).Trim().Equals("$Underlined=False", StringComparison.OrdinalIgnoreCase)) - { - underlineOn = false; - } - } - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class DvdStudioProSpaceOne : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d+:\d+:\d+:\d+,\d+:\d+:\d+:\d+, .*$", RegexOptions.Compiled); + + public override string Extension => ".STL"; + + public override string Name => "DVD Studio Pro with one space"; + + public override string ToText(Subtitle subtitle, string title) + { + const string paragraphWriteFormat = "{0},{1}, {2}\r\n"; + const string timeFormat = "{0:00}:{1:00}:{2:00}:{3:00}"; + var header = Configuration.Settings.SubtitleSettings.DvdStudioProHeader.TrimEnd() + Environment.NewLine; + + var lastVerticalAlign = "$VertAlign = Bottom"; + var lastHorizontalcalAlign = "$HorzAlign = Center"; + var sb = new StringBuilder(); + sb.AppendLine(header); + foreach (Paragraph p in subtitle.Paragraphs) + { + string startTime = string.Format(timeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds)); + string endTime = string.Format(timeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds)); + DvdStudioPro.ToTextAlignment(p, sb, ref lastVerticalAlign, ref lastHorizontalcalAlign); + sb.AppendFormat(paragraphWriteFormat, startTime, endTime, DvdStudioPro.EncodeStyles(p.Text)); + } + return sb.ToString().Trim(); + } + + public static byte GetFrameFromMilliseconds(int milliseconds, double frameRate) + { + return (byte)Math.Round(milliseconds / (TimeCode.BaseUnit / frameRate)); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + int number = 0; + var verticalAlign = "$VertAlign=Bottom"; + var horizontalAlign = "$HorzAlign=Center"; + bool italicOn = false; + bool boldOn = false; + bool underlineOn = false; + foreach (string line in lines) + { + if (!string.IsNullOrWhiteSpace(line) && line[0] != '$' && !line.StartsWith("//", StringComparison.Ordinal)) + { + if (RegexTimeCodes.Match(line).Success) + { + string[] toPart = line.Substring(0, 24).Trim(',').Split(','); + var p = new Paragraph(); + if (toPart.Length == 2 && + DvdStudioPro.GetTimeCode(p.StartTime, toPart[0]) && + DvdStudioPro.GetTimeCode(p.EndTime, toPart[1])) + { + number++; + p.Number = number; + string text = line.Substring(25).Trim(); + p.Text = text.Replace(" | ", Environment.NewLine).Replace("|", Environment.NewLine); + p.Text = DvdStudioPro.DecodeStyles(p.Text); + if (italicOn && !p.Text.Contains("")) + { + p.Text = "" + p.Text + ""; + } + if (boldOn && !p.Text.Contains("")) + { + p.Text = "" + p.Text + ""; + } + if (underlineOn && !p.Text.Contains("")) + { + p.Text = "" + p.Text + ""; + } + p.Text = DvdStudioPro.GetAlignment(verticalAlign, horizontalAlign) + p.Text; + subtitle.Paragraphs.Add(p); + } + } + else + { + _errorCount++; + } + } + else if (line != null && line.TrimStart().StartsWith("$VertAlign", StringComparison.OrdinalIgnoreCase)) + { + verticalAlign = line.RemoveChar(' ').RemoveChar('\t'); + } + else if (line != null && line.TrimStart().StartsWith("$HorzAlign", StringComparison.OrdinalIgnoreCase)) + { + horizontalAlign = line.RemoveChar(' ').RemoveChar('\t'); + } + else if (line.Replace(" ", string.Empty).Equals("$Italic=True", StringComparison.OrdinalIgnoreCase)) + { + italicOn = true; + } + else if (line.Replace(" ", string.Empty).Trim().Equals("$Italic=False", StringComparison.OrdinalIgnoreCase)) + { + italicOn = false; + } + else if (line.Replace(" ", string.Empty).Equals("$Bold=True", StringComparison.OrdinalIgnoreCase)) + { + boldOn = true; + } + else if (line.Replace(" ", string.Empty).Trim().Equals("$Bold=False", StringComparison.OrdinalIgnoreCase)) + { + boldOn = false; + } + else if (line.Replace(" ", string.Empty).Equals("$Underlined=True", StringComparison.OrdinalIgnoreCase)) + { + underlineOn = true; + } + else if (line.Replace(" ", string.Empty).Trim().Equals("$Underlined=False", StringComparison.OrdinalIgnoreCase)) + { + underlineOn = false; + } + } + } + + } +} diff --git a/libse/SubtitleFormats/DvdStudioProSpaceOneSemicolon.cs b/src/libse/SubtitleFormats/DvdStudioProSpaceOneSemicolon.cs similarity index 100% rename from libse/SubtitleFormats/DvdStudioProSpaceOneSemicolon.cs rename to src/libse/SubtitleFormats/DvdStudioProSpaceOneSemicolon.cs diff --git a/libse/SubtitleFormats/DvdSubtitle.cs b/src/libse/SubtitleFormats/DvdSubtitle.cs similarity index 97% rename from libse/SubtitleFormats/DvdSubtitle.cs rename to src/libse/SubtitleFormats/DvdSubtitle.cs index 9d3f6bece..eb7580029 100644 --- a/libse/SubtitleFormats/DvdSubtitle.cs +++ b/src/libse/SubtitleFormats/DvdSubtitle.cs @@ -1,139 +1,139 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class DvdSubtitle : SubtitleFormat - { - - private static readonly Regex RegexTimeCodes = new Regex(@"^\{T \d+:\d+:\d+:\d+$", RegexOptions.Compiled); - - public override string Extension => ".sub"; - - public override string Name => "DVDSubtitle"; - - public override string ToText(Subtitle subtitle, string title) - { - const string paragraphWriteFormat = "T {0}\r\n{1}\r\n"; - const string timeFormat = "{0:00}:{1:00}:{2:00}:{3:00}"; - const string header = @"{HEAD -DISCID= -DVDTITLE= -CODEPAGE=1250 -FORMAT=ASCII -LANG= -TITLE=1 -ORIGINAL=ORIGINAL -AUTHOR= -WEB= -INFO= -LICENSE= -}"; - - var sb = new StringBuilder(); - sb.AppendLine(header); - foreach (var p in subtitle.Paragraphs) - { - int milliseconds = p.StartTime.Milliseconds / 10; - string time = string.Format(timeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, milliseconds); - sb.AppendLine("{" + string.Format(paragraphWriteFormat, time, p.Text) + "}"); - - milliseconds = p.EndTime.Milliseconds / 10; - time = string.Format(timeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, milliseconds); - sb.AppendLine("{" + string.Format(paragraphWriteFormat, time, string.Empty) + "}"); - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - //{T 00:03:14:27 - //Some text - //} - _errorCount = 0; - bool textOn = false; - string text = string.Empty; - var start = new TimeCode(); - var end = new TimeCode(); - foreach (string line in lines) - { - if (textOn) - { - if (line.Trim() == "}") - { - var p = new Paragraph - { - Text = text, - StartTime = new TimeCode(start.TotalMilliseconds), - EndTime = new TimeCode(end.TotalMilliseconds) - }; - - subtitle.Paragraphs.Add(p); - - text = string.Empty; - start = new TimeCode(); - end = new TimeCode(); - textOn = false; - } - else - { - if (text.Length == 0) - { - text = line; - } - else - { - text += Environment.NewLine + line; - } - } - } - else - { - if (RegexTimeCodes.Match(line).Success) - { - try - { - textOn = true; - string[] arr = line.Substring(3).Trim().Split(':'); - if (arr.Length == 4) - { - int hours = int.Parse(arr[0]); - int minutes = int.Parse(arr[1]); - int seconds = int.Parse(arr[2]); - int milliseconds = int.Parse(arr[3]); - if (arr[3].Length == 2) - { - milliseconds *= 10; - } - - start = new TimeCode(hours, minutes, seconds, milliseconds); - } - } - catch - { - textOn = false; - _errorCount++; - } - } - } - } - - int index = 1; - foreach (var p in subtitle.Paragraphs) - { - var next = subtitle.GetParagraphOrDefault(index); - if (next != null) - { - p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds; - } - index++; - } - - subtitle.RemoveEmptyLines(); - subtitle.Renumber(); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class DvdSubtitle : SubtitleFormat + { + + private static readonly Regex RegexTimeCodes = new Regex(@"^\{T \d+:\d+:\d+:\d+$", RegexOptions.Compiled); + + public override string Extension => ".sub"; + + public override string Name => "DVDSubtitle"; + + public override string ToText(Subtitle subtitle, string title) + { + const string paragraphWriteFormat = "T {0}\r\n{1}\r\n"; + const string timeFormat = "{0:00}:{1:00}:{2:00}:{3:00}"; + const string header = @"{HEAD +DISCID= +DVDTITLE= +CODEPAGE=1250 +FORMAT=ASCII +LANG= +TITLE=1 +ORIGINAL=ORIGINAL +AUTHOR= +WEB= +INFO= +LICENSE= +}"; + + var sb = new StringBuilder(); + sb.AppendLine(header); + foreach (var p in subtitle.Paragraphs) + { + int milliseconds = p.StartTime.Milliseconds / 10; + string time = string.Format(timeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, milliseconds); + sb.AppendLine("{" + string.Format(paragraphWriteFormat, time, p.Text) + "}"); + + milliseconds = p.EndTime.Milliseconds / 10; + time = string.Format(timeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, milliseconds); + sb.AppendLine("{" + string.Format(paragraphWriteFormat, time, string.Empty) + "}"); + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + //{T 00:03:14:27 + //Some text + //} + _errorCount = 0; + bool textOn = false; + string text = string.Empty; + var start = new TimeCode(); + var end = new TimeCode(); + foreach (string line in lines) + { + if (textOn) + { + if (line.Trim() == "}") + { + var p = new Paragraph + { + Text = text, + StartTime = new TimeCode(start.TotalMilliseconds), + EndTime = new TimeCode(end.TotalMilliseconds) + }; + + subtitle.Paragraphs.Add(p); + + text = string.Empty; + start = new TimeCode(); + end = new TimeCode(); + textOn = false; + } + else + { + if (text.Length == 0) + { + text = line; + } + else + { + text += Environment.NewLine + line; + } + } + } + else + { + if (RegexTimeCodes.Match(line).Success) + { + try + { + textOn = true; + string[] arr = line.Substring(3).Trim().Split(':'); + if (arr.Length == 4) + { + int hours = int.Parse(arr[0]); + int minutes = int.Parse(arr[1]); + int seconds = int.Parse(arr[2]); + int milliseconds = int.Parse(arr[3]); + if (arr[3].Length == 2) + { + milliseconds *= 10; + } + + start = new TimeCode(hours, minutes, seconds, milliseconds); + } + } + catch + { + textOn = false; + _errorCount++; + } + } + } + } + + int index = 1; + foreach (var p in subtitle.Paragraphs) + { + var next = subtitle.GetParagraphOrDefault(index); + if (next != null) + { + p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds; + } + index++; + } + + subtitle.RemoveEmptyLines(); + subtitle.Renumber(); + } + } +} diff --git a/libse/SubtitleFormats/DvdSubtitleSystem.cs b/src/libse/SubtitleFormats/DvdSubtitleSystem.cs similarity index 97% rename from libse/SubtitleFormats/DvdSubtitleSystem.cs rename to src/libse/SubtitleFormats/DvdSubtitleSystem.cs index 1230edf9b..bb67209d0 100644 --- a/libse/SubtitleFormats/DvdSubtitleSystem.cs +++ b/src/libse/SubtitleFormats/DvdSubtitleSystem.cs @@ -1,87 +1,87 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class DvdSubtitleSystem : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d \d\d:\d\d:\d\d:\d\d ", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "DVD Subtitle System"; - - public override bool IsMine(List lines, string fileName) - { - var sb = new StringBuilder(); - foreach (string line in lines) - { - sb.AppendLine(line); - } - - if (sb.ToString().Contains("#INPOINT OUTPOINT PATH")) - { - return false; // Pinnacle Impression - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - //00:03:15:22 00:03:23:10 This is line one. - //This is line two. - sb.AppendLine($"{EncodeTimeCode(p.StartTime)} {EncodeTimeCode(p.EndTime)} {HtmlUtil.RemoveHtmlTags(p.Text.Replace(Environment.NewLine, "//"), true)}"); - } - return sb.ToString(); - } - - private static string EncodeTimeCode(TimeCode time) - { - //00:03:15:22 (last is ms div 10) - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - //00:03:15:22 00:03:23:10 This is line one. - //This is line two. - subtitle.Paragraphs.Clear(); - _errorCount = 0; - foreach (string line in lines) - { - // line must contain atleast 24 characters (time-code)... - if (line.Length < 24) - { - _errorCount += 10; - continue; - } - - Match match = RegexTimeCodes.Match(line); - - if (match.Success) - { - string temp = line.Substring(0, match.Length); - string start = temp.Substring(0, 11); - string end = temp.Substring(12, 11); - - string[] startParts = start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); - string[] endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); - string text = line.Substring(match.Length).Trim(); - text = text.Replace("//", Environment.NewLine); - var p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text); - subtitle.Paragraphs.Add(p); - } - } - - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class DvdSubtitleSystem : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d \d\d:\d\d:\d\d:\d\d ", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "DVD Subtitle System"; + + public override bool IsMine(List lines, string fileName) + { + var sb = new StringBuilder(); + foreach (string line in lines) + { + sb.AppendLine(line); + } + + if (sb.ToString().Contains("#INPOINT OUTPOINT PATH")) + { + return false; // Pinnacle Impression + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + //00:03:15:22 00:03:23:10 This is line one. + //This is line two. + sb.AppendLine($"{EncodeTimeCode(p.StartTime)} {EncodeTimeCode(p.EndTime)} {HtmlUtil.RemoveHtmlTags(p.Text.Replace(Environment.NewLine, "//"), true)}"); + } + return sb.ToString(); + } + + private static string EncodeTimeCode(TimeCode time) + { + //00:03:15:22 (last is ms div 10) + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + //00:03:15:22 00:03:23:10 This is line one. + //This is line two. + subtitle.Paragraphs.Clear(); + _errorCount = 0; + foreach (string line in lines) + { + // line must contain atleast 24 characters (time-code)... + if (line.Length < 24) + { + _errorCount += 10; + continue; + } + + Match match = RegexTimeCodes.Match(line); + + if (match.Success) + { + string temp = line.Substring(0, match.Length); + string start = temp.Substring(0, 11); + string end = temp.Substring(12, 11); + + string[] startParts = start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); + string[] endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); + string text = line.Substring(match.Length).Trim(); + text = text.Replace("//", Environment.NewLine); + var p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text); + subtitle.Paragraphs.Add(p); + } + } + + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/ELRStudioClosedCaption.cs b/src/libse/SubtitleFormats/ELRStudioClosedCaption.cs similarity index 97% rename from libse/SubtitleFormats/ELRStudioClosedCaption.cs rename to src/libse/SubtitleFormats/ELRStudioClosedCaption.cs index f355cb2a4..ef1a7faf6 100644 --- a/libse/SubtitleFormats/ELRStudioClosedCaption.cs +++ b/src/libse/SubtitleFormats/ELRStudioClosedCaption.cs @@ -1,144 +1,144 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class ELRStudioClosedCaption : SubtitleFormat - { - public override string Extension => ".elr"; - - public override string Name => "ELRStudio Closed Caption"; - - public static void Save(string fileName) - { - using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) - { - //... - } - } - - public override bool IsMine(List lines, string fileName) - { - if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) - { - var fi = new FileInfo(fileName); - if (fi.Length >= 640 && fi.Length < 1024000) // not too small or too big - { - if (fileName.EndsWith(".elr", StringComparison.OrdinalIgnoreCase)) - { - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - byte[] compareBuffer = { 0x05, 0x01, 0x0D, 0x15, 0x11, 0x00, 0xA9, 0x00, 0x45, 0x00, 0x6C, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x20, 0x00, 0x53, 0x00, 0x74, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6F, 0x00 }; - - for (int i = 6; i < compareBuffer.Length; i++) - { - if (buffer[i] != compareBuffer[i]) - { - return false; - } - } - - var sub = new Subtitle(); - LoadSubtitle(sub, lines, fileName); - return sub.Paragraphs.Count > 0; - } - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - return "Not supported!"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - subtitle.Paragraphs.Clear(); - subtitle.Header = null; - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - - int i = 128; - while (i < buffer.Length - 40) - { - try - { - if ((buffer[i] == 0xc4 || buffer[i] == 0x5d) && buffer[i + 1] == 9 && buffer[i + 2] == 0 && buffer[i + 3] == 0x10) // start time (hopefully) - { - var p = new Paragraph { StartTime = GetTimeCode(buffer, i + 4) }; - i += 7; - - // seek to endtime - while (i < buffer.Length - 10 && !((buffer[i] == 0xc4 || buffer[i] == 0x5d) && buffer[i + 1] == 9 && buffer[i + 2] == 0 && buffer[i + 3] == 0x10)) - { - i++; - } - if (buffer[i] == 0xc4 && buffer[i + 1] == 9 && buffer[i + 2] == 0 && buffer[i + 3] == 0x10) - { - p.EndTime = GetTimeCode(buffer, i + 4); - i += 7; - } - if (Math.Abs(p.EndTime.TotalMilliseconds) < 0.001) - { - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 2000; - } - - // seek to text - var sb = new StringBuilder(); - int min = 4; - while (min > 0 || i < buffer.Length - 10 && !((buffer[i] == 0xc4 || buffer[i] == 0x5d) && buffer[i + 1] == 9 && buffer[i + 2] == 0 && buffer[i + 3] == 0x10)) - { - min--; - if (buffer[i] == 9 && buffer[i + 1] == 0 && buffer[i + 2] == 0x44) - { - var length = buffer[i - 1]; - i += 12; - for (int j = i; j < i + length * 4; j += 4) - { - sb.Append(Encoding.GetEncoding(1252).GetString(buffer, j, 1)); - } - sb.AppendLine(); - } - else - { - i++; - } - } - p.Text = (p.Text + " " + sb).Trim(); - subtitle.Paragraphs.Add(p); - } - else - { - i++; - } - } - catch - { - i += 5; - } - } - subtitle.Renumber(); - } - - private static TimeCode GetTimeCode(byte[] buffer, int idx) - { - try - { - const string format = "X4"; - int frames = int.Parse(buffer[idx].ToString(format)); - int seconds = int.Parse(buffer[idx + 1].ToString(format)); - int minutes = int.Parse(buffer[idx + 2].ToString(format)); - int hours = int.Parse(buffer[idx + 3].ToString(format)); - return new TimeCode(hours, minutes, seconds, FramesToMillisecondsMax999(frames)); - } - catch - { - return new TimeCode(); - } - } - - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class ELRStudioClosedCaption : SubtitleFormat + { + public override string Extension => ".elr"; + + public override string Name => "ELRStudio Closed Caption"; + + public static void Save(string fileName) + { + using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) + { + //... + } + } + + public override bool IsMine(List lines, string fileName) + { + if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) + { + var fi = new FileInfo(fileName); + if (fi.Length >= 640 && fi.Length < 1024000) // not too small or too big + { + if (fileName.EndsWith(".elr", StringComparison.OrdinalIgnoreCase)) + { + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + byte[] compareBuffer = { 0x05, 0x01, 0x0D, 0x15, 0x11, 0x00, 0xA9, 0x00, 0x45, 0x00, 0x6C, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x20, 0x00, 0x53, 0x00, 0x74, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6F, 0x00 }; + + for (int i = 6; i < compareBuffer.Length; i++) + { + if (buffer[i] != compareBuffer[i]) + { + return false; + } + } + + var sub = new Subtitle(); + LoadSubtitle(sub, lines, fileName); + return sub.Paragraphs.Count > 0; + } + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + return "Not supported!"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + subtitle.Paragraphs.Clear(); + subtitle.Header = null; + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + + int i = 128; + while (i < buffer.Length - 40) + { + try + { + if ((buffer[i] == 0xc4 || buffer[i] == 0x5d) && buffer[i + 1] == 9 && buffer[i + 2] == 0 && buffer[i + 3] == 0x10) // start time (hopefully) + { + var p = new Paragraph { StartTime = GetTimeCode(buffer, i + 4) }; + i += 7; + + // seek to endtime + while (i < buffer.Length - 10 && !((buffer[i] == 0xc4 || buffer[i] == 0x5d) && buffer[i + 1] == 9 && buffer[i + 2] == 0 && buffer[i + 3] == 0x10)) + { + i++; + } + if (buffer[i] == 0xc4 && buffer[i + 1] == 9 && buffer[i + 2] == 0 && buffer[i + 3] == 0x10) + { + p.EndTime = GetTimeCode(buffer, i + 4); + i += 7; + } + if (Math.Abs(p.EndTime.TotalMilliseconds) < 0.001) + { + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 2000; + } + + // seek to text + var sb = new StringBuilder(); + int min = 4; + while (min > 0 || i < buffer.Length - 10 && !((buffer[i] == 0xc4 || buffer[i] == 0x5d) && buffer[i + 1] == 9 && buffer[i + 2] == 0 && buffer[i + 3] == 0x10)) + { + min--; + if (buffer[i] == 9 && buffer[i + 1] == 0 && buffer[i + 2] == 0x44) + { + var length = buffer[i - 1]; + i += 12; + for (int j = i; j < i + length * 4; j += 4) + { + sb.Append(Encoding.GetEncoding(1252).GetString(buffer, j, 1)); + } + sb.AppendLine(); + } + else + { + i++; + } + } + p.Text = (p.Text + " " + sb).Trim(); + subtitle.Paragraphs.Add(p); + } + else + { + i++; + } + } + catch + { + i += 5; + } + } + subtitle.Renumber(); + } + + private static TimeCode GetTimeCode(byte[] buffer, int idx) + { + try + { + const string format = "X4"; + int frames = int.Parse(buffer[idx].ToString(format)); + int seconds = int.Parse(buffer[idx + 1].ToString(format)); + int minutes = int.Parse(buffer[idx + 2].ToString(format)); + int hours = int.Parse(buffer[idx + 3].ToString(format)); + return new TimeCode(hours, minutes, seconds, FramesToMillisecondsMax999(frames)); + } + catch + { + return new TimeCode(); + } + } + + } +} diff --git a/libse/SubtitleFormats/ESubXf.cs b/src/libse/SubtitleFormats/ESubXf.cs similarity index 100% rename from libse/SubtitleFormats/ESubXf.cs rename to src/libse/SubtitleFormats/ESubXf.cs diff --git a/libse/SubtitleFormats/EZTSubtitlesProject.cs b/src/libse/SubtitleFormats/EZTSubtitlesProject.cs similarity index 100% rename from libse/SubtitleFormats/EZTSubtitlesProject.cs rename to src/libse/SubtitleFormats/EZTSubtitlesProject.cs diff --git a/libse/SubtitleFormats/Ebu.cs b/src/libse/SubtitleFormats/Ebu.cs similarity index 97% rename from libse/SubtitleFormats/Ebu.cs rename to src/libse/SubtitleFormats/Ebu.cs index 4c04a40fd..9c827671d 100644 --- a/libse/SubtitleFormats/Ebu.cs +++ b/src/libse/SubtitleFormats/Ebu.cs @@ -1,1785 +1,1785 @@ -using Nikse.SubtitleEdit.Core.Interfaces; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - /// EBU Subtitling data exchange format - /// - public class Ebu : SubtitleFormat, IBinaryPersistableSubtitle - { - private static readonly Regex FontTagsNoSpace1 = new Regex("[a-zA-z.!?][a-zA-Z-]", RegexOptions.Compiled); - private static readonly Regex FontTagsNoSpace2 = new Regex("[a-zA-z.!?][a-zA-Z-]", RegexOptions.Compiled); - - private static readonly Regex FontTagsStartSpace = new Regex("^ ", RegexOptions.Compiled); // " " - private static readonly Regex FontTagsNewLineSpace = new Regex("[\r\n]+ ", RegexOptions.Compiled); // "\r\n " - - private const string LanguageCodeChinese = "75"; - - public interface IEbuUiHelper - { - void Initialize(EbuGeneralSubtitleInformation header, byte justificationCode, string fileName, Subtitle subtitle); - bool ShowDialogOk(); - byte JustificationCode { get; set; } - } - - public static IEbuUiHelper EbuUiHelper { get; set; } - - private static readonly Regex RegExprColor = new Regex(@"^[a-f0-9]{6}$", RegexOptions.Compiled); - - public List VerticalPositions = new List(); - public List JustificationCodes = new List(); - - public EbuGeneralSubtitleInformation Header; - - /// - /// GSI block (1024 bytes) - /// - public class EbuGeneralSubtitleInformation - { - public string CodePageNumber { get; set; } // 0..2 - public string DiskFormatCode { get; set; } // 3..10 - public double FrameRateFromSaveDialog { get; set; } - public string DisplayStandardCode { get; set; } // 11 - public string CharacterCodeTableNumber { get; set; } // 12..13 - public string LanguageCode { get; set; } // 14..15 - public string OriginalProgrammeTitle { get; set; } // 16..47 - public string OriginalEpisodeTitle { get; set; } - public string TranslatedProgrammeTitle { get; set; } - public string TranslatedEpisodeTitle { get; set; } - public string TranslatorsName { get; set; } - public string TranslatorsContactDetails { get; set; } - public string SubtitleListReferenceCode { get; set; } - public string CreationDate { get; set; } - public string RevisionDate { get; set; } - public string RevisionNumber { get; set; } - public string TotalNumberOfTextAndTimingInformationBlocks { get; set; } - public string TotalNumberOfSubtitles { get; set; } - public string TotalNumberOfSubtitleGroups { get; set; } - public string MaximumNumberOfDisplayableCharactersInAnyTextRow { get; set; } - public string MaximumNumberOfDisplayableRows { get; set; } - public string TimeCodeStatus { get; set; } - public string TimeCodeStartOfProgramme { get; set; } - public string TimeCodeFirstInCue { get; set; } - public string TotalNumberOfDisks { get; set; } - public string DiskSequenceNumber { get; set; } - public string CountryOfOrigin { get; set; } - public string Publisher { get; set; } - public string EditorsName { get; set; } - public string EditorsContactDetails { get; set; } - public string SpareBytes { get; set; } - public string UserDefinedArea { get; set; } - - public double FrameRate - { - get - { - if (FrameRateFromSaveDialog > 20) - { - return FrameRateFromSaveDialog; - } - - if (DiskFormatCode.StartsWith("STL23", StringComparison.Ordinal)) - { - return 23.0; - } - - if (DiskFormatCode.StartsWith("STL24", StringComparison.Ordinal)) - { - return 24.0; - } - - if (DiskFormatCode.StartsWith("STL25", StringComparison.Ordinal)) - { - return 25.0; - } - - if (DiskFormatCode.StartsWith("STL29", StringComparison.Ordinal)) - { - return 29.0; - } - - if (DiskFormatCode.StartsWith("STL35", StringComparison.Ordinal)) - { - return 35.0; - } - - if (DiskFormatCode.StartsWith("STL48", StringComparison.Ordinal)) - { - return 48.0; - } - - if (DiskFormatCode.StartsWith("STL50", StringComparison.Ordinal)) - { - return 50.0; - } - - if (DiskFormatCode.StartsWith("STL60", StringComparison.Ordinal)) - { - return 60.0; - } - - return 30.0; // should be DiskFormatcode STL30.01 - } - } - - public EbuGeneralSubtitleInformation() - { - CodePageNumber = "437"; - DiskFormatCode = "STL25.01"; - DisplayStandardCode = "0"; // 0=Open subtitling - CharacterCodeTableNumber = "00"; - LanguageCode = "0A"; - OriginalProgrammeTitle = "No Title "; - OriginalEpisodeTitle = " "; - TranslatedProgrammeTitle = string.Empty.PadLeft(32, ' '); - TranslatedEpisodeTitle = string.Empty.PadLeft(32, ' '); - TranslatorsName = string.Empty.PadLeft(32, ' '); - TranslatorsContactDetails = string.Empty.PadLeft(32, ' '); - SubtitleListReferenceCode = "0 "; - CreationDate = "101021"; - RevisionDate = "101021"; - RevisionNumber = "01"; - TotalNumberOfTextAndTimingInformationBlocks = "00725"; - TotalNumberOfSubtitles = "00725"; - TotalNumberOfSubtitleGroups = "001"; - MaximumNumberOfDisplayableCharactersInAnyTextRow = "40"; - MaximumNumberOfDisplayableRows = "23"; - TimeCodeStatus = "1"; - TimeCodeStartOfProgramme = "00000000"; - TimeCodeFirstInCue = "00000001"; - TotalNumberOfDisks = "1"; - DiskSequenceNumber = "1"; - CountryOfOrigin = "USA"; - Publisher = string.Empty.PadLeft(32, ' '); - EditorsName = string.Empty.PadLeft(32, ' '); - EditorsContactDetails = string.Empty.PadLeft(32, ' '); - SpareBytes = string.Empty.PadLeft(75, ' '); - UserDefinedArea = string.Empty.PadLeft(576, ' '); - } - - public override string ToString() - { - var result = CodePageNumber + - DiskFormatCode + - DisplayStandardCode + - CharacterCodeTableNumber + - LanguageCode + - OriginalProgrammeTitle + - OriginalEpisodeTitle + - TranslatedProgrammeTitle + - TranslatedEpisodeTitle + - TranslatorsName + - TranslatorsContactDetails + - SubtitleListReferenceCode + - CreationDate + - RevisionDate + - RevisionNumber + - TotalNumberOfTextAndTimingInformationBlocks + - TotalNumberOfSubtitles + - TotalNumberOfSubtitleGroups + - MaximumNumberOfDisplayableCharactersInAnyTextRow + - MaximumNumberOfDisplayableRows + - TimeCodeStatus + - TimeCodeStartOfProgramme + - TimeCodeFirstInCue + - TotalNumberOfDisks + - DiskSequenceNumber + - CountryOfOrigin + - Publisher + - EditorsName + - EditorsContactDetails + - SpareBytes + - UserDefinedArea; - - if (result.Length == 1024) - { - return result; - } - - return "Length must be 1024 but is " + result.Length; - } - } - - /// - /// TTI block 128 bytes - /// - private class EbuTextTimingInformation - { - public byte SubtitleGroupNumber { get; set; } - public ushort SubtitleNumber { get; set; } - public byte ExtensionBlockNumber { get; set; } - public byte CumulativeStatus { get; set; } - public int TimeCodeInHours { get; set; } - public int TimeCodeInMinutes { get; set; } - public int TimeCodeInSeconds { get; set; } - public int TimeCodeInMilliseconds { get; set; } - public int TimeCodeOutHours { get; set; } - public int TimeCodeOutMinutes { get; set; } - public int TimeCodeOutSeconds { get; set; } - public int TimeCodeOutMilliseconds { get; set; } - public byte VerticalPosition { get; set; } - public byte JustificationCode { get; set; } - public byte CommentFlag { get; set; } - public string TextField { get; set; } - - public EbuTextTimingInformation() - { - SubtitleGroupNumber = 0; - ExtensionBlockNumber = 255; - CumulativeStatus = 0; - VerticalPosition = 0x16; - JustificationCode = 2; - CommentFlag = 0; - } - - public byte[] GetBytes(EbuGeneralSubtitleInformation header) - { - var buffer = new byte[128]; // Text and Timing Information (TTI) block consists of 128 bytes - - buffer[0] = SubtitleGroupNumber; - var temp = BitConverter.GetBytes(SubtitleNumber); - buffer[1] = temp[0]; - buffer[2] = temp[1]; - buffer[3] = ExtensionBlockNumber; - buffer[4] = CumulativeStatus; - - buffer[5] = (byte)TimeCodeInHours; - buffer[6] = (byte)TimeCodeInMinutes; - var frames = GetFrameFromMilliseconds(TimeCodeInMilliseconds, header.FrameRate, out var extraSeconds); - buffer[7] = (byte)(TimeCodeInSeconds + extraSeconds); - buffer[8] = frames; - - buffer[9] = (byte)TimeCodeOutHours; - buffer[10] = (byte)TimeCodeOutMinutes; - frames = GetFrameFromMilliseconds(TimeCodeOutMilliseconds, header.FrameRate, out extraSeconds); - buffer[11] = (byte)(TimeCodeOutSeconds + extraSeconds); - buffer[12] = frames; - - buffer[13] = VerticalPosition; - buffer[14] = JustificationCode; - buffer[15] = CommentFlag; - - var encoding = GetEncoding(header.CodePageNumber); - if (header.LanguageCode == LanguageCodeChinese) - { - var lines = HtmlUtil.RemoveHtmlTags(TextField, true).SplitToLines(); - var byteList = new List(); - encoding = Encoding.GetEncoding(1200); // 16-bit Unicode - for (var i = 0; i < lines.Count; i++) - { - var l = lines[i]; - if (i > 0) - { // new line - byteList.Add(0); - byteList.Add(138); - } - byteList.AddRange(encoding.GetBytes(l).ToArray()); - } - - for (var i = 0; i < 112; i++) - { - if (i < byteList.Count) - { - buffer[16 + i] = byteList[i]; - } - else - { - buffer[16 + i] = 0x8f; - } - } - - return buffer; - } - - if (header.CharacterCodeTableNumber == "00") - { - encoding = Encoding.GetEncoding(20269); - // 0xC1—0xCF combines characters - http://en.wikipedia.org/wiki/ISO/IEC_6937 - - var sbTwoChar = new StringBuilder(); - bool skipNext = false; - for (var index = 0; index < TextField.Length; index++) - { - var ch = TextField[index]; - if (skipNext) - { - skipNext = false; - } - else if (ch == 'ı' && TextField.Substring(index).StartsWith("ı̂")) // extended unicode char - rewritten as simple 'î' - looks the same as "î" but it's not...) - { - sbTwoChar.Append(encoding.GetString(new byte[] { 0xc3, 0x69 })); // Ãi - simple î - skipNext = true; - } - else if ("ÀÈÌÒÙàèìòù".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc1 }), "ÀÈÌÒÙàèìòù", "AEIOUaeiou")); - } - else if ("ÁĆÉÍĹŃÓŔŚÚÝŹáćéģíĺńóŕśúýź".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc2 }), "ÁĆÉÍĹŃÓŔŚÚÝŹáćéģíĺńóŕśúýź", "ACEILNORSUYZacegilnorsuyz")); - } - else if ("ÂĈÊĜĤÎĴÔŜÛŴŶâĉêĝĥĵôŝûŵŷîı̂".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc3 }), "ÂĈÊĜĤÎĴÔŜÛŴŶâĉêĝĥîĵôŝûŵŷ", "ACEGHIJOSUWYaceghijosuwy")); - } - else if ("ÃĨÑÕŨãĩñõũ".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc4 }), "ÃĨÑÕŨãĩñõũ", "AINOUainou")); - } - else if ("ĀĒĪŌŪāēīōū".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc5 }), "ĀĒĪŌŪāēīōū", "AEIOUaeiou")); - } - else if ("ĂĞŬăğŭ".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc6 }), "ĂĞŬăğŭ", "AGUagu")); - } - else if ("ĊĖĠİŻċėġıż".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc7 }), "ĊĖĠİŻċėġıż", "CEGIZcegiz")); - } - else if ("ÄËÏÖÜŸäëïöüÿ".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc8 }), "ÄËÏÖÜŸäëïöüÿ", "AEIOUYaeiouy")); - } - else if ("ÅŮåů".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xca }), "ÅŮåů", "AUau")); - } - else if ("ÇĢĶĻŅŖŞŢçķļņŗşţ".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xcb }), "ÇĢĶĻŅŖŞŢçķļņŗşţ", "CGKLNRSTcklnrst")); - } - else if ("ŐŰőű".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xcd }), "ŐŰőű", "OUou")); - } - else if ("ĄĘĮŲąęįų".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xce }), "ĄĘĮŲąęįų", "AEIUaeiu")); - } - else if ("ČĎĚĽŇŘŠŤŽčďěľňřšťž".Contains(ch)) - { - sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xcf }), "ČĎĚĽŇŘŠŤŽčďěľňřšťž", "CDELNRSTZcdelnrstz")); - } - else - { - sbTwoChar.Append(ch); - } - } - - TextField = sbTwoChar.ToString(); - } - else if (header.CharacterCodeTableNumber == "01") // Latin/Cyrillic alphabet - from ISO 8859/5-1988 - { - encoding = Encoding.GetEncoding("ISO-8859-5"); - } - else if (header.CharacterCodeTableNumber == "02") // Latin/Arabic alphabet - from ISO 8859/6-1987 - { - encoding = Encoding.GetEncoding("ISO-8859-6"); - } - else if (header.CharacterCodeTableNumber == "03") // Latin/Greek alphabet - from ISO 8859/7-1987 - { - encoding = Encoding.GetEncoding("ISO-8859-7"); // or ISO-8859-1 ? - } - else if (header.CharacterCodeTableNumber == "04") // Latin/Hebrew alphabet - from ISO 8859/8-1988 - { - encoding = Encoding.GetEncoding("ISO-8859-8"); - } - - // italic/underline - var italicsOn = encoding.GetString(new byte[] { 0x80 }); - var italicsOff = encoding.GetString(new byte[] { 0x81 }); - var underlineOn = encoding.GetString(new byte[] { 0x82 }); - var underlineOff = encoding.GetString(new byte[] { 0x83 }); - var boxingOn = encoding.GetString(new byte[] { 0x84 }); - var boxingOff = encoding.GetString(new byte[] { 0x85 }); - - TextField = FixItalics(TextField); - - TextField = TextField.Replace("", italicsOn); - TextField = TextField.Replace("", italicsOn); - TextField = TextField.Replace("", italicsOff); - TextField = TextField.Replace("", italicsOff); - TextField = TextField.Replace("", underlineOn); - TextField = TextField.Replace("", underlineOn); - TextField = TextField.Replace("", underlineOff); - TextField = TextField.Replace("", underlineOff); - TextField = TextField.Replace("", boxingOn); - TextField = TextField.Replace("", boxingOn); - TextField = TextField.Replace("", boxingOff); - TextField = TextField.Replace("", boxingOff); - if (header.CharacterCodeTableNumber == "00") - { - TextField = TextField.Replace("©", encoding.GetString(new byte[] { 0xd3 })); - TextField = TextField.Replace("™", encoding.GetString(new byte[] { 0xd4 })); - TextField = TextField.Replace("♪", encoding.GetString(new byte[] { 0xd5 })); - } - - TextField = EncodeText(TextField, encoding, header.DisplayStandardCode); - TextField = HtmlUtil.RemoveHtmlTags(TextField, true); - - if (header.DisplayStandardCode != "0") // 0=Open subtitling - { - if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox && Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight) - { - TextField = encoding.GetString(new byte[] { 0x0d, 0x0b, 0x0b }) + TextField; // d=double height, b=start box - } - else if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox) - { - TextField = encoding.GetString(new byte[] { 0x0b, 0x0b }) + TextField; // b=start box - } - else if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight) - { - TextField = encoding.GetString(new byte[] { 0x0d }) + TextField; // d=double height - } - } - - // convert text to bytes - var bytes = encoding.GetBytes(TextField); - - // some fixes for bytes - if (bytes.Length == TextField.Length) - { - for (var i = 0; i < bytes.Length; i++) - { - if (TextField[i] == '#') - { - bytes[i] = 0x23; - } - else if (TextField[i] == 'Đ') - { - bytes[i] = 0xe2; - } - else if (TextField[i] == '–') // em dash - { - bytes[i] = 0xd0; - } - } - } - - for (var i = 0; i < 112; i++) - { - if (i < bytes.Length) - { - buffer[16 + i] = bytes[i]; - } - else - { - buffer[16 + i] = 0x8f; - } - } - return buffer; - } - - private static string FixItalics(string text) - { - var italicOn = false; - var sb = new StringBuilder(); - foreach (var line in HtmlUtil.FixInvalidItalicTags(text).SplitToLines()) - { - var s = line; - if (italicOn && !s.TrimStart().StartsWith("", StringComparison.Ordinal)) - { - s = "" + s; - } - - var endTagIndex = s.LastIndexOf("", StringComparison.Ordinal); - if (s.LastIndexOf("", StringComparison.Ordinal) > endTagIndex) - { - italicOn = true; - } - else if (endTagIndex >= 0) - { - italicOn = false; - } - - if (italicOn) - { - sb.AppendLine(s + ""); - } - else - { - sb.AppendLine(s); - } - } - - return sb.ToString().TrimEnd(); - } - - private static string EncodeText(string text, Encoding encoding, string displayStandardCode) - { - // newline - var newline = encoding.GetString(new byte[] { 0x8a, 0x8a }); - if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox && Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight) - { - newline = encoding.GetString(new byte[] { 0x0a, 0x0a, 0x8a, 0x8a, 0x0d, 0x0b, 0x0b }); // 0a==end box, 0d==double height, 0b==start box - } - else if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox) - { - newline = "\u000a\u000a" + - string.Empty.PadLeft(Configuration.Settings.SubtitleSettings.EbuStlNewLineRows, '\u008a') + - encoding.GetString(new byte[] { 0x0b, 0x0b }); // 0a==end box, 0b==start box - } - else if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight) - { - newline = encoding.GetString(new byte[] { 0x8a, 0x8a, 0x0d, 0x0d }); // 0d==double height - } - - if (displayStandardCode == "0") // 0=Open subtitling - { - newline = encoding.GetString(new byte[] { 0x8A }); //8Ah=CR/LF - } - - var lastColor = string.Empty; - var sb = new StringBuilder(); - var list = text.SplitToLines(); - for (var index = 0; index < list.Count; index++) - { - if (index > 0) - { - sb.Append(newline); - if (displayStandardCode != "0" && !string.IsNullOrEmpty(lastColor)) - { - sb.Append(lastColor); - } - } - - var line = list[index]; - var i = 0; - while (i < line.Length) - { - var newStart = line.Substring(i); - if (newStart.StartsWith("', i); - if (end > 0) - { - if (displayStandardCode != "0") - { - lastColor = GetColor(encoding, line, i); - sb.Append(lastColor); - } - - i = end + 1; - } - } - else if (newStart == "") - { - i += "".Length; - lastColor = string.Empty; - } - else if (newStart.StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - if (displayStandardCode != "0") - { - sb.Append(encoding.GetString(new byte[] { 0x07 })); // white - } - - i += "".Length; - } - else - { - sb.Append(line.Substring(i, 1)); - i++; - } - } - } - - if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox && displayStandardCode != "0") - { - sb.Append(encoding.GetString(new byte[] { 0x0a, 0x0a })); //a=end box - } - - return sb.ToString(); - } - - private static string GetColor(Encoding encoding, string line, int i) - { - var end = line.IndexOf('>', i); - if (end > 0) - { - string f = line.Substring(i, end - i); - if (f.Contains(" color=", StringComparison.OrdinalIgnoreCase)) - { - var colorStart = f.IndexOf(" color=", StringComparison.OrdinalIgnoreCase); - if (line.IndexOf('"', colorStart + " color=".Length + 1) > 0) - { - var colorEnd = f.IndexOf('"', colorStart + " color=".Length + 1); - if (colorStart > 1) - { - string color = f.Substring(colorStart + 7, colorEnd - (colorStart + 7)); - color = color.Trim('\''); - color = color.Trim('\"'); - color = color.Trim('#'); - return GetNearestEbuColorCode(color, encoding); - } - } - } - } - return string.Empty; - } - - private static string GetNearestEbuColorCode(string color, Encoding encoding) - { - color = color.ToLowerInvariant(); - if (color == "black" || color == "000000") - { - return encoding.GetString(new byte[] { 0x00 }); // black - } - - if (color == "red" || color == "ff0000") - { - return encoding.GetString(new byte[] { 0x01 }); // red - } - - if (color == "green" || color == "00ff00") - { - return encoding.GetString(new byte[] { 0x02 }); // green - } - - if (color == "yellow" || color == "ffff00") - { - return encoding.GetString(new byte[] { 0x03 }); // yellow - } - - if (color == "blue" || color == "0000ff") - { - return encoding.GetString(new byte[] { 0x04 }); // blue - } - - if (color == "magenta" || color == "ff00ff") - { - return encoding.GetString(new byte[] { 0x05 }); // magenta - } - - if (color == "cyan" || color == "00ffff") - { - return encoding.GetString(new byte[] { 0x06 }); // cyan - } - - if (color == "white" || color == "ffffff") - { - return encoding.GetString(new byte[] { 0x07 }); // white - } - - if (color.Length == 6) - { - if (RegExprColor.IsMatch(color)) - { - const int maxDiff = 130; - int r = int.Parse(color.Substring(0, 2), NumberStyles.HexNumber); - int g = int.Parse(color.Substring(2, 2), NumberStyles.HexNumber); - int b = int.Parse(color.Substring(4, 2), NumberStyles.HexNumber); - if (r < maxDiff && g < maxDiff && b < maxDiff) - { - return encoding.GetString(new byte[] { 0x00 }); // black - } - - if (r > 255 - maxDiff && g < maxDiff && b < maxDiff) - { - return encoding.GetString(new byte[] { 0x01 }); // red - } - - if (r < maxDiff && g > 255 - maxDiff && b < maxDiff) - { - return encoding.GetString(new byte[] { 0x02 }); // green - } - - if (r > 255 - maxDiff && g > 255 - maxDiff && b < maxDiff) - { - return encoding.GetString(new byte[] { 0x03 }); // yellow - } - - if (r < maxDiff && g < maxDiff && b > 255 - maxDiff) - { - return encoding.GetString(new byte[] { 0x04 }); // blue - } - - if (r > 255 - maxDiff && g < maxDiff && b > 255 - maxDiff) - { - return encoding.GetString(new byte[] { 0x05 }); // magenta - } - - if (r < maxDiff && g > 255 - maxDiff && b > 255 - maxDiff) - { - return encoding.GetString(new byte[] { 0x06 }); // cyan - } - - if (r > 255 - maxDiff && g > 255 - maxDiff && b > 255 - maxDiff) - { - return encoding.GetString(new byte[] { 0x07 }); // white - } - } - } - return string.Empty; - } - - private static string ReplaceSpecialCharactersWithTwoByteEncoding(char ch, string specialCharacter, string originalCharacters, string newCharacters) - { - if (originalCharacters.Length != newCharacters.Length) - { - throw new ArgumentException("originalCharacters and newCharacters must have equal length"); - } - - for (var i = 0; i < newCharacters.Length; i++) - { - if (originalCharacters[i] == ch) - { - return specialCharacter + newCharacters[i]; - } - } - return ch.ToString(); - } - - public static byte GetFrameFromMilliseconds(int milliseconds, double frameRate, out byte extraSeconds) - { - extraSeconds = 0; - var fr = Math.Round(milliseconds / (TimeCode.BaseUnit / frameRate)); - if (fr >= frameRate) - { - fr = 0; - extraSeconds = 1; - } - - return (byte)fr; - } - } - - public override string Extension => ".stl"; - - public const string NameOfFormat = "EBU STL"; - - public override string Name => NameOfFormat; - - public bool Save(string fileName, Subtitle subtitle) - { - return Save(fileName, subtitle, false); - } - - public bool Save(string fileName, Subtitle subtitle, bool batchMode, EbuGeneralSubtitleInformation header = null) - { - using (var ms = new MemoryStream()) - { - var ok = Save(fileName, ms, subtitle, batchMode, header); - if (ok) - { - ms.Position = 0; - using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) - { - ms.CopyTo(fs); - } - } - return ok; - } - } - - public bool Save(string fileName, Stream stream, Subtitle subtitle, bool batchMode, EbuGeneralSubtitleInformation header) - { - if (header == null) - { - header = new EbuGeneralSubtitleInformation { LanguageCode = AutoDetectLanguageCode(subtitle) }; - } - - if (EbuUiHelper == null) - { - return false; - } - - if (subtitle.Header != null && subtitle.Header.Length == 1024 && (subtitle.Header.Contains("STL24") || subtitle.Header.Contains("STL25") || subtitle.Header.Contains("STL29") || subtitle.Header.Contains("STL30"))) - { - header = ReadHeader(GetEncoding(subtitle.Header.Substring(0, 3)).GetBytes(subtitle.Header)); - EbuUiHelper.Initialize(header, EbuUiHelper.JustificationCode, null, subtitle); - } - else - { - EbuUiHelper.Initialize(header, EbuUiHelper.JustificationCode, fileName, subtitle); - } - - if (!batchMode && !EbuUiHelper.ShowDialogOk()) - { - return false; - } - - header.TotalNumberOfSubtitles = subtitle.Paragraphs.Count.ToString("D5"); // seems to be 1 higher than actual number of subtitles - header.TotalNumberOfTextAndTimingInformationBlocks = header.TotalNumberOfSubtitles; - - var today = $"{DateTime.Now:yyMMdd}"; - if (today.Length == 6) - { - header.CreationDate = today; - header.RevisionDate = today; - } - - var firstParagraph = subtitle.GetParagraphOrDefault(0); - if (firstParagraph != null) - { - var tc = firstParagraph.StartTime; - var frames = EbuTextTimingInformation.GetFrameFromMilliseconds(tc.Milliseconds, header.FrameRate, out var extraSeconds); - var firstTimeCode = $"{tc.Hours:00}{tc.Minutes:00}{tc.Seconds + extraSeconds:00}{frames:00}"; - if (firstTimeCode.Length == 8) - { - header.TimeCodeFirstInCue = firstTimeCode; - } - } - - var buffer = GetEncoding(header.CodePageNumber).GetBytes(header.ToString()); - stream.Write(buffer, 0, buffer.Length); - - var subtitleNumber = 0; - foreach (var p in subtitle.Paragraphs) - { - var tti = new EbuTextTimingInformation(); - - if (!int.TryParse(header.MaximumNumberOfDisplayableRows, out var rows)) - { - rows = 23; - } - - if (header.DisplayStandardCode == "1" || header.DisplayStandardCode == "2") // teletext - { - rows = 23; - } - else if (header.DisplayStandardCode == "0" && header.MaximumNumberOfDisplayableRows == "02") // open subtitling - { - rows = 15; - } - - var text = p.Text.Trim(Utilities.NewLineChars); - if (text.StartsWith("{\\an7}", StringComparison.Ordinal) || text.StartsWith("{\\an8}", StringComparison.Ordinal) || text.StartsWith("{\\an9}", StringComparison.Ordinal)) - { - tti.VerticalPosition = (byte)Configuration.Settings.SubtitleSettings.EbuStlMarginTop; // top (vertical) - if (header.DisplayStandardCode == "1" || header.DisplayStandardCode == "2") // teletext - { - tti.VerticalPosition++; - } - } - else if (text.StartsWith("{\\an4}", StringComparison.Ordinal) || text.StartsWith("{\\an5}", StringComparison.Ordinal) || text.StartsWith("{\\an6}", StringComparison.Ordinal)) - { - tti.VerticalPosition = (byte)(rows / 2); // middle (vertical) - } - else - { - var numberOfLineBreaks = Math.Max(0, Utilities.GetNumberOfLines(text) - 1); - var startRow = rows - Configuration.Settings.SubtitleSettings.EbuStlMarginBottom - - numberOfLineBreaks * Configuration.Settings.SubtitleSettings.EbuStlNewLineRows; - if (startRow < 0) - { - startRow = 0; - } - - tti.VerticalPosition = (byte)startRow; // bottom (vertical) - } - - tti.JustificationCode = EbuUiHelper.JustificationCode; // use default justification - if (text.StartsWith("{\\an1}", StringComparison.Ordinal) || text.StartsWith("{\\an4}", StringComparison.Ordinal) || text.StartsWith("{\\an7}", StringComparison.Ordinal)) - { - tti.JustificationCode = 1; // 01h=left-justified text - } - else if (text.StartsWith("{\\an3}", StringComparison.Ordinal) || text.StartsWith("{\\an6}", StringComparison.Ordinal) || text.StartsWith("{\\an9}", StringComparison.Ordinal)) - { - tti.JustificationCode = 3; // 03h=right-justified - } - else if (text.StartsWith("{\\an2}", StringComparison.Ordinal) || text.StartsWith("{\\an5}", StringComparison.Ordinal) || text.StartsWith("{\\an8}", StringComparison.Ordinal)) - { - tti.JustificationCode = 2; // 02h=centred text - } - - // replace some unsupported characters - text = text.Replace("„", "\""); // lower quote - text = text.Replace("‚", "’"); // lower apostrophe - text = text.Replace("♫", "♪"); // only music single note supported - text = text.Replace("…", "..."); // fix Unicode ellipsis - - tti.SubtitleNumber = (ushort)subtitleNumber; - tti.TextField = text; - int startTag = tti.TextField.IndexOf('}'); - if (tti.TextField.StartsWith("{\\", StringComparison.Ordinal) && startTag > 0 && startTag < 10) - { - tti.TextField = tti.TextField.Remove(0, startTag + 1); - } - - if (!p.StartTime.IsMaxTime) - { - tti.TimeCodeInHours = p.StartTime.Hours; - tti.TimeCodeInMinutes = p.StartTime.Minutes; - tti.TimeCodeInSeconds = p.StartTime.Seconds; - tti.TimeCodeInMilliseconds = p.StartTime.Milliseconds; - } - - if (!p.EndTime.IsMaxTime) - { - tti.TimeCodeOutHours = p.EndTime.Hours; - tti.TimeCodeOutMinutes = p.EndTime.Minutes; - tti.TimeCodeOutSeconds = p.EndTime.Seconds; - tti.TimeCodeOutMilliseconds = p.EndTime.Milliseconds; - } - - buffer = tti.GetBytes(header); - stream.Write(buffer, 0, buffer.Length); - subtitleNumber++; - } - return true; - } - - private static string AutoDetectLanguageCode(Subtitle subtitle) - { - if (subtitle == null || subtitle.Paragraphs.Count == 0) - { - return "00"; // Unknown/not applicable - } - - var languageCode = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(subtitle); - switch (languageCode) - { - case "sq": return "01"; // Albanian - case "br": return "02"; // Breton - case "ca": return "03"; // Catalan - case "hr": return "04"; // Croatian - case "cy": return "05"; // Welsh - case "cs": return "06"; // Czech - case "da": return "07"; // Danish - case "de": return "08"; // German - case "en": return "09"; // English - case "es": return "0A"; // Spanish - case "eo": return "0B"; // Esperanto - case "et": return "0C"; // Estonian - case "eu": return "0D"; // Basque - case "fo": return "0E"; // Faroese - case "fr": return "0F"; // French - case "fy": return "10"; // Frisian - case "ga": return "11"; // Irish - case "gd": return "12"; // Gaelic - case "gl": return "13"; // Galician - case "is": return "14"; // Icelandic - case "it": return "15"; // Italian - case "Lappish": return "16"; // Lappish - case "la": return "17"; // Latin - case "lv": return "18"; // Latvian": - case "lb": return "19"; // Luxembourgi - case "lt": return "1A"; // Lithuanian - case "hu": return "1B"; // Hungarian - case "mt": return "1C"; // Maltese - case "nl": return "1D"; // Dutch - case "nb": return "1E"; // Norwegian - case "oc": return "1F"; // Occitan - case "pl": return "20"; // Polish - case "pt": return "21"; // Portuguese - case "ro": return "22"; // Romanian - case "rm": return "23"; // Romansh - case "sr": return "24"; // Serbian - case "sk": return "25"; // Slovak - case "sl": return "26"; // Slovenian - case "fi": return "27"; // Finnish - case "sv": return "28"; // Swedish - case "tr": return "29"; // Turkish - case "Flemish": return "2A"; // Flemish - case "Wallon": return "2B"; // Wallon - } - - return "09"; // English - default - } - - public override bool IsMine(List lines, string fileName) - { - if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) - { - var fi = new FileInfo(fileName); - if (fi.Length >= 1024 + 128 && fi.Length < 2048000) // not too small or too big - { - try - { - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - EbuGeneralSubtitleInformation header = ReadHeader(buffer); - if (header.DiskFormatCode.StartsWith("STL23", StringComparison.Ordinal) || - header.DiskFormatCode.StartsWith("STL24", StringComparison.Ordinal) || - header.DiskFormatCode.StartsWith("STL25", StringComparison.Ordinal) || - header.DiskFormatCode.StartsWith("STL29", StringComparison.Ordinal) || - header.DiskFormatCode.StartsWith("STL30", StringComparison.Ordinal) || - header.DiskFormatCode.StartsWith("STL35", StringComparison.Ordinal) || - header.DiskFormatCode.StartsWith("STL48", StringComparison.Ordinal) || - header.DiskFormatCode.StartsWith("STL50", StringComparison.Ordinal) || - header.DiskFormatCode.StartsWith("STL60", StringComparison.Ordinal) || - "012 ".Contains(header.DisplayStandardCode) && "437|850|860|863|865".Contains(header.CodePageNumber)) - { - return Utilities.IsInteger(header.CodePageNumber) || fileName.EndsWith(".stl", StringComparison.OrdinalIgnoreCase); - } - } - catch - { - return false; - } - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - return "Not supported!"; - } - - public void LoadSubtitle(Subtitle subtitle, byte[] buffer) - { - subtitle.Paragraphs.Clear(); - subtitle.Header = null; - var header = ReadHeader(buffer); - subtitle.Header = Encoding.UTF8.GetString(buffer); - Paragraph last = null; - byte lastExtensionBlockNumber = 0xff; - JustificationCodes = new List(); - VerticalPositions = new List(); - Configuration.Settings.General.CurrentFrameRate = header.FrameRate; - foreach (var tti in ReadTextAndTiming(buffer, header)) - { - if (tti.ExtensionBlockNumber != 0xfe) // FEh : Reserved for User Data - { - var p = new Paragraph - { - Text = tti.TextField, - StartTime = new TimeCode(tti.TimeCodeInHours, tti.TimeCodeInMinutes, tti.TimeCodeInSeconds, tti.TimeCodeInMilliseconds), - EndTime = new TimeCode(tti.TimeCodeOutHours, tti.TimeCodeOutMinutes, tti.TimeCodeOutSeconds, tti.TimeCodeOutMilliseconds), - MarginV = tti.VerticalPosition.ToString(CultureInfo.InvariantCulture) - }; - - if (Math.Abs(p.StartTime.TotalMilliseconds) < 0.01 && Math.Abs(p.EndTime.TotalMilliseconds) < 0.01) - { - p.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - p.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - } - - if (lastExtensionBlockNumber != 0xff && last != null) - { - last.Text += p.Text; // merge text - } - else - { - subtitle.Paragraphs.Add(p); - last = p; - } - - p.Text = HtmlUtil.FixInvalidItalicTags(p.Text); - lastExtensionBlockNumber = tti.ExtensionBlockNumber; - } - } - subtitle.Renumber(); - Header = header; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - LoadSubtitle(subtitle, FileUtil.ReadAllBytesShared(fileName)); - } - - public static EbuGeneralSubtitleInformation ReadHeader(byte[] buffer) - { - var enc = GetEncoding(Encoding.ASCII.GetString(buffer, 0, 3)); - var header = new EbuGeneralSubtitleInformation - { - CodePageNumber = enc.GetString(buffer, 0, 3), - DiskFormatCode = enc.GetString(buffer, 3, 8), - DisplayStandardCode = enc.GetString(buffer, 11, 1), - CharacterCodeTableNumber = enc.GetString(buffer, 12, 2), - LanguageCode = enc.GetString(buffer, 14, 2), - OriginalProgrammeTitle = enc.GetString(buffer, 16, 32), - OriginalEpisodeTitle = enc.GetString(buffer, 48, 32), - TranslatedProgrammeTitle = enc.GetString(buffer, 80, 32), - TranslatedEpisodeTitle = enc.GetString(buffer, 112, 32), - TranslatorsName = enc.GetString(buffer, 144, 32), - TranslatorsContactDetails = enc.GetString(buffer, 176, 32), - SubtitleListReferenceCode = enc.GetString(buffer, 208, 16), - CreationDate = enc.GetString(buffer, 224, 6), - RevisionDate = enc.GetString(buffer, 230, 6), - RevisionNumber = enc.GetString(buffer, 236, 2), - TotalNumberOfTextAndTimingInformationBlocks = enc.GetString(buffer, 238, 5), - TotalNumberOfSubtitles = enc.GetString(buffer, 243, 5), - TotalNumberOfSubtitleGroups = enc.GetString(buffer, 248, 3), - MaximumNumberOfDisplayableCharactersInAnyTextRow = enc.GetString(buffer, 251, 2), - MaximumNumberOfDisplayableRows = enc.GetString(buffer, 253, 2), - TimeCodeStatus = enc.GetString(buffer, 255, 1), - TimeCodeStartOfProgramme = enc.GetString(buffer, 256, 8), - CountryOfOrigin = enc.GetString(buffer, 274, 3), - SpareBytes = enc.GetString(buffer, 373, 75), - UserDefinedArea = enc.GetString(buffer, 448, 576) - }; - return header; - } - - private static Encoding GetEncoding(string codePageNumber) - { - try - { - return Encoding.GetEncoding(int.TryParse(codePageNumber, out int cp) ? cp : 437); - } - catch (NotSupportedException) - { - return Encoding.GetEncoding(437); - } - } - - /// - /// Get text with regard code page from header - /// - /// Skip next character - /// EBU header - /// data buffer - /// index to current byte in buffer - /// Character at index - private static string GetCharacter(out bool skipNext, EbuGeneralSubtitleInformation header, byte[] buffer, int index) - { - skipNext = false; - - if (header.LanguageCode == LanguageCodeChinese) - { - skipNext = true; - return Encoding.GetEncoding(1200).GetString(buffer, index, 2); // 16-bit Unicode - } - - if (header.CharacterCodeTableNumber == "00") - { - var b = buffer[index]; - if (b == 0xd3) - { - return "©"; - } - - if (b == 0xd4) - { - return "™"; - } - - if (b == 0xd5) - { - return "♪"; - } - - //note that 0xC1—0xCF combines characters - http://en.wikipedia.org/wiki/ISO/IEC_6937 - var encoding = Encoding.GetEncoding(20269); - if (index + 2 > buffer.Length) - { - return string.Empty; - } - - var next = encoding.GetString(buffer, index + 1, 1); - switch (b) - { - case 0xc1: // Grave - skipNext = @"AEIOUaeiou".Contains(next); - switch (next) - { - case "A": return "À"; - case "E": return "È"; - case "I": return "Ì"; - case "O": return "Ò"; - case "U": return "Ù"; - case "a": return "à"; - case "e": return "è"; - case "i": return "ì"; - case "o": return "ò"; - case "u": return "ù"; - } - return string.Empty; - case 0xc2: // Acute - skipNext = @"ACEILNORSUYZacegilnorsuyz".Contains(next); - switch (next) - { - case "A": return "Á"; - case "C": return "Ć"; - case "E": return "É"; - case "I": return "Í"; - case "L": return "Ĺ"; - case "N": return "Ń"; - case "O": return "Ó"; - case "R": return "Ŕ"; - case "S": return "Ś"; - case "U": return "Ú"; - case "Y": return "Ý"; - case "Z": return "Ź"; - case "a": return "á"; - case "c": return "ć"; - case "e": return "é"; - case "g": return "ģ"; - case "i": return "í"; - case "l": return "ĺ"; - case "n": return "ń"; - case "o": return "ó"; - case "r": return "ŕ"; - case "s": return "ś"; - case "u": return "ú"; - case "y": return "ý"; - case "z": return "ź"; - } - return string.Empty; - case 0xc3: // Circumflex - skipNext = @"ACEGHIJOSUWYaceghjosuwyıi".Contains(next); - switch (next) - { - case "A": return "Â"; - case "C": return "Ĉ"; - case "E": return "Ê"; - case "G": return "Ĝ"; - case "H": return "Ĥ"; - case "I": return "Î"; - case "J": return "Ĵ"; - case "O": return "Ô"; - case "S": return "Ŝ"; - case "U": return "Û"; - case "W": return "Ŵ"; - case "Y": return "Ŷ"; - case "a": return "â"; - case "c": return "ĉ"; - case "e": return "ê"; - case "g": return "ĝ"; - case "h": return "ĥ"; - case "j": return "ĵ"; - case "o": return "ô"; - case "s": return "ŝ"; - case "u": return "û"; - case "w": return "ŵ"; - case "y": return "ŷ"; - case "ı": return "ı̂"; - case "i": return "î"; - } - return string.Empty; - case 0xc4: // Tilde - skipNext = @"AINOUainou".Contains(next); - switch (next) - { - case "A": return "Ã"; - case "I": return "Ĩ"; - case "N": return "Ñ"; - case "O": return "Õ"; - case "U": return "Ũ"; - case "a": return "ã"; - case "i": return "ĩ"; - case "n": return "ñ"; - case "o": return "õ"; - case "u": return "ũ"; - } - return string.Empty; - case 0xc5: // Macron - skipNext = @"AEIOUaeiou".Contains(next); - switch (next) - { - case "A": return "Ā"; - case "E": return "Ē"; - case "I": return "Ī"; - case "O": return "Ō"; - case "U": return "Ū"; - case "a": return "ā"; - case "e": return "ē"; - case "i": return "ī"; - case "o": return "ō"; - case "u": return "ū"; - } - return string.Empty; - case 0xc6: // Breve - skipNext = @"AGUagu".Contains(next); - switch (next) - { - case "A": return "Ă"; - case "G": return "Ğ"; - case "U": return "Ŭ"; - case "a": return "ă"; - case "g": return "ğ"; - case "u": return "ŭ"; - } - return string.Empty; - case 0xc7: // Dot - skipNext = @"CEGIZcegiz".Contains(next); - switch (next) - { - case "C": return "Ċ"; - case "E": return "Ė"; - case "G": return "Ġ"; - case "I": return "İ"; - case "Z": return "Ż"; - case "c": return "ċ"; - case "e": return "ė"; - case "g": return "ġ"; - case "i": return "ı"; - case "z": return "ż"; - } - return string.Empty; - case 0xc8: // Umlaut or diæresis - skipNext = @"AEIOUYaeiouy".Contains(next); - switch (next) - { - case "A": return "Ä"; - case "E": return "Ë"; - case "I": return "Ï"; - case "O": return "Ö"; - case "U": return "Ü"; - case "Y": return "Ÿ"; - case "a": return "ä"; - case "e": return "ë"; - case "i": return "ï"; - case "o": return "ö"; - case "u": return "ü"; - case "y": return "ÿ"; - } - return string.Empty; - case 0xca: // Ring - skipNext = @"AUau".Contains(next); - switch (next) - { - case "A": return "Å"; - case "U": return "Ů"; - case "a": return "å"; - case "u": return "ů"; - } - return string.Empty; - case 0xcb: // Cedilla - skipNext = @"CGKLNRSTcklnrst".Contains(next); - switch (next) - { - case "C": return "Ç"; - case "G": return "Ģ"; - case "K": return "Ķ"; - case "L": return "Ļ"; - case "N": return "Ņ"; - case "R": return "Ŗ"; - case "S": return "Ş"; - case "T": return "Ţ"; - case "c": return "ç"; - case "k": return "ķ"; - case "l": return "ļ"; - case "n": return "ņ"; - case "r": return "ŗ"; - case "s": return "ş"; - case "t": return "ţ"; - } - return string.Empty; - case 0xcd: // DoubleAcute - skipNext = @"OUou".Contains(next); - switch (next) - { - case "O": return "Ő"; - case "U": return "Ű"; - case "o": return "ő"; - case "u": return "ű"; - } - return string.Empty; - case 0xce: // Ogonek - skipNext = @"AEIUaeiu".Contains(next); - switch (next) - { - case "A": return "Ą"; - case "E": return "Ę"; - case "I": return "Į"; - case "U": return "Ų"; - case "a": return "ą"; - case "e": return "ę"; - case "i": return "į"; - case "u": return "ų"; - } - return string.Empty; - case 0xcf: // Caron - skipNext = @"CDELNRSTZcdelnrstz".Contains(next); - switch (next) - { - case "C": return "Č"; - case "D": return "Ď"; - case "E": return "Ě"; - case "L": return "Ľ"; - case "N": return "Ň"; - case "R": return "Ř"; - case "S": return "Š"; - case "T": return "Ť"; - case "Z": return "Ž"; - case "c": return "č"; - case "d": return "ď"; - case "e": return "ě"; - case "l": return "ľ"; - case "n": return "ň"; - case "r": return "ř"; - case "s": return "š"; - case "t": return "ť"; - case "z": return "ž"; - } - return string.Empty; - default: - return encoding.GetString(buffer, index, 1); - } - } - - if (header.CharacterCodeTableNumber == "01") // Latin/Cyrillic alphabet - from ISO 8859/5-1988 - { - return Encoding.GetEncoding("ISO-8859-5").GetString(buffer, index, 1); - } - - if (header.CharacterCodeTableNumber == "02") // Latin/Arabic alphabet - from ISO 8859/6-1987 - { - return Encoding.GetEncoding("ISO-8859-6").GetString(buffer, index, 1); - } - - if (header.CharacterCodeTableNumber == "03") // Latin/Greek alphabet - from ISO 8859/7-1987 - { - return Encoding.GetEncoding("ISO-8859-7").GetString(buffer, index, 1); // or ISO-8859-1 ? - } - - if (header.CharacterCodeTableNumber == "04") // Latin/Hebrew alphabet - from ISO 8859/8-1988 - { - return Encoding.GetEncoding("ISO-8859-8").GetString(buffer, index, 1); - } - - return string.Empty; - } - - /// - /// Read Text and Timing Information (TTI) block. - /// Each Text and Timing Information (TTI) block consists of 128 bytes. - /// - private IEnumerable ReadTextAndTiming(byte[] buffer, EbuGeneralSubtitleInformation header) - { - const int startOfTextAndTimingBlock = 1024; - const int ttiSize = 128; - const byte italicsOn = 0x80; - const byte italicsOff = 0x81; - const byte underlineOn = 0x82; - const byte underlineOff = 0x83; - const byte boxingOn = 0x84; - const byte boxingOff = 0x85; - - var list = new List(); - int index = startOfTextAndTimingBlock; - while (index + ttiSize <= buffer.Length) - { - var tti = new EbuTextTimingInformation - { - SubtitleGroupNumber = buffer[index], - SubtitleNumber = (ushort)(buffer[index + 2] * 256 + buffer[index + 1]), - ExtensionBlockNumber = buffer[index + 3], - CumulativeStatus = buffer[index + 4], - TimeCodeInHours = buffer[index + 5 + 0], - TimeCodeInMinutes = buffer[index + 5 + 1], - TimeCodeInSeconds = buffer[index + 5 + 2], - TimeCodeInMilliseconds = FramesToMillisecondsMax999(buffer[index + 5 + 3]), - TimeCodeOutHours = buffer[index + 9 + 0], - TimeCodeOutMinutes = buffer[index + 9 + 1], - TimeCodeOutSeconds = buffer[index + 9 + 2], - TimeCodeOutMilliseconds = FramesToMillisecondsMax999(buffer[index + 9 + 3]), - VerticalPosition = buffer[index + 13], - JustificationCode = buffer[index + 14], - CommentFlag = buffer[index + 15] - }; - VerticalPositions.Add(tti.VerticalPosition); - JustificationCodes.Add(tti.JustificationCode); - - // Text block - // - has a fixed length of 112 byte - // - 8Ah = new line - // - unused space = 8Fh - int i = index + 16; // text block start at 17th byte (index 16) - var open = header.DisplayStandardCode != "1" && header.DisplayStandardCode != "2"; - var closed = header.DisplayStandardCode != "0"; - int max = i + 112; - var sb = new StringBuilder(); - while (i < max) - { - var b = buffer[i]; - if (b <= 0x1f) // Closed - Teletext control codes - { - if (closed) - { - var tag = GetColorOrTag(b); - if (!string.IsNullOrEmpty(tag)) - { - sb.Append(tag); - } - } - } - else if (b >= 0x20 && b <= 0x7f) // Both - Character codes - { - var ch = GetCharacter(out var skipNext, header, buffer, i); - sb.Append(ch); - if (skipNext) - { - i++; - } - } - else if (b >= 0x80 && b <= 0x85) // Open - italic/underline/boxing - { - if (open) - { - if (b == italicsOn && header.LanguageCode != LanguageCodeChinese) - { - sb.Append(""); - } - else if (b == italicsOff && header.LanguageCode != LanguageCodeChinese) - { - sb.Append(""); - } - else if (b == underlineOn && header.LanguageCode != LanguageCodeChinese) - { - sb.Append(""); - } - else if (b == underlineOff && header.LanguageCode != LanguageCodeChinese) - { - sb.Append(""); - } - else if (b == boxingOn && header.LanguageCode != LanguageCodeChinese) - { - sb.Append(""); - } - else if (b == boxingOff && header.LanguageCode != LanguageCodeChinese) - { - sb.Append(""); - } - } - } - else if (b >= 0x86 && b <= 0x89) // Both - Reserved for future use - { - } - else if (b == 0x8a) // Both - CR/LF - { - sb.AppendLine(); - } - else if (b >= 0x8b && b <= 0x8e) // Both - Reserved for future use - { - } - else if (b == 0x8f) // Both - unused space - { - } - else if (b >= 0x90 && b <= 0x9f) // Both - Reserved for future use - { - } - else if (b >= 0xa1 && b <= 0xff) // Both - Character codes - { - var ch = GetCharacter(out var skipNext, header, buffer, i); - sb.Append(ch); - if (skipNext) - { - i++; - } - } - i++; - } - tti.TextField = FixSpacesAndTags(sb.ToString()); - - if (!int.TryParse(header.MaximumNumberOfDisplayableRows, out var rows)) - { - rows = 23; - } - - if (tti.VerticalPosition < 3) - { - if (tti.JustificationCode == 1) // left - { - tti.TextField = "{\\an7}" + tti.TextField; - } - else if (tti.JustificationCode == 3) // right - { - tti.TextField = "{\\an9}" + tti.TextField; - } - else - { - tti.TextField = "{\\an8}" + tti.TextField; - } - } - else if (tti.VerticalPosition <= rows / 2 + 1) - { - if (tti.JustificationCode == 1) // left - { - tti.TextField = "{\\an4}" + tti.TextField; - } - else if (tti.JustificationCode == 3) // right - { - tti.TextField = "{\\an6}" + tti.TextField; - } - else - { - tti.TextField = "{\\an5}" + tti.TextField; - } - } - else - { - if (tti.JustificationCode == 1) // left - { - tti.TextField = "{\\an1}" + tti.TextField; - } - else if (tti.JustificationCode == 3) // right - { - tti.TextField = "{\\an3}" + tti.TextField; - } - } - index += ttiSize; - list.Add(tti); - } - return list; - } - - private static string GetColorOrTag(byte b) - { - switch (b) - { - case 0x00: - return ""; - case 0x01: - return ""; - case 0x02: - return ""; - case 0x03: - return ""; - case 0x04: - return ""; - case 0x05: - return ""; - case 0x06: - return ""; - case 0x07: - return ""; - //case 0x0a: - // return ""; - //case 0x0b: - // return ""; - } - return null; - } - - private static string FixSpacesAndTags(string text) - { - text = text.Trim(); - while (text.Contains(" ")) - { - text = text.Replace(" ", " "); - } - - var match = FontTagsNoSpace1.Match(text); - while (match.Success) - { - text = text.Remove(match.Index, match.Length).Insert(match.Index, match.Value.Replace(" ", string.Empty).Contains("", string.Empty); - } - - while (text.Contains(Environment.NewLine + Environment.NewLine)) - { - text = text.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); - } - - var lines = text.SplitToLines(); - - // fix multi font tags, e.g. a color in the middle of a line - for (var index = 0; index < lines.Count; index++) - { - var whiteTag = ""; - var line = lines[index]; - var changed = false; - var count = Utilities.CountTagInText(line, " 1) - { - count = 0; - var endTags = 0; - var idx = line.IndexOf(" 0) - { - count++; - var start = line.Substring(idx); - if (count == 1 && start.StartsWith(whiteTag)) - { - line = line.Remove(idx, whiteTag.Length); - idx--; - changed = true; - lines[index] = line; - } - else if (count > 1 && start.StartsWith(whiteTag)) - { - line = line.Remove(idx, whiteTag.Length).Insert(idx, ""); - changed = true; - lines[index] = line; - endTags++; - count--; - } - else if (count > 1 && count > endTags + 1 && !start.StartsWith(whiteTag)) - { - line = line.Insert(idx, ""); - changed = true; - lines[index] = line; - idx += "".Length; - endTags++; - } - idx = line.IndexOf(" 0) - { - sb.Append(s); - if (count == 1 && !s.Contains("")) - { - sb.Append(""); - } - - sb.AppendLine(); - } - } - - text = sb.ToString().TrimEnd(); - - while (text.Contains(Environment.NewLine + " ")) - { - text = text.Replace(Environment.NewLine + " ", Environment.NewLine); - } - - // remove starting white spaces - match = FontTagsStartSpace.Match(text); - while (match.Success) - { - text = text.Remove(match.Index + match.Length - 1, 1); - match = FontTagsStartSpace.Match(text); - } - - // remove starting white spaces on 2+ line - match = FontTagsNewLineSpace.Match(text); - while (match.Success) - { - text = text.Remove(match.Index + match.Length - 1, 1); - match = FontTagsNewLineSpace.Match(text); - } - - text = text.Replace(" ", " "); - - text = HtmlUtil.FixInvalidItalicTags(text); - - return text; - } - - public override bool IsTextBased => false; - - public bool Save(string fileName, Stream stream, Subtitle subtitle, bool batchMode) - { - return Save(fileName, stream, subtitle, batchMode, null); - } - } -} +using Nikse.SubtitleEdit.Core.Interfaces; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + /// + /// EBU Subtitling data exchange format + /// + public class Ebu : SubtitleFormat, IBinaryPersistableSubtitle + { + private static readonly Regex FontTagsNoSpace1 = new Regex("[a-zA-z.!?][a-zA-Z-]", RegexOptions.Compiled); + private static readonly Regex FontTagsNoSpace2 = new Regex("[a-zA-z.!?][a-zA-Z-]", RegexOptions.Compiled); + + private static readonly Regex FontTagsStartSpace = new Regex("^ ", RegexOptions.Compiled); // " " + private static readonly Regex FontTagsNewLineSpace = new Regex("[\r\n]+ ", RegexOptions.Compiled); // "\r\n " + + private const string LanguageCodeChinese = "75"; + + public interface IEbuUiHelper + { + void Initialize(EbuGeneralSubtitleInformation header, byte justificationCode, string fileName, Subtitle subtitle); + bool ShowDialogOk(); + byte JustificationCode { get; set; } + } + + public static IEbuUiHelper EbuUiHelper { get; set; } + + private static readonly Regex RegExprColor = new Regex(@"^[a-f0-9]{6}$", RegexOptions.Compiled); + + public List VerticalPositions = new List(); + public List JustificationCodes = new List(); + + public EbuGeneralSubtitleInformation Header; + + /// + /// GSI block (1024 bytes) + /// + public class EbuGeneralSubtitleInformation + { + public string CodePageNumber { get; set; } // 0..2 + public string DiskFormatCode { get; set; } // 3..10 + public double FrameRateFromSaveDialog { get; set; } + public string DisplayStandardCode { get; set; } // 11 + public string CharacterCodeTableNumber { get; set; } // 12..13 + public string LanguageCode { get; set; } // 14..15 + public string OriginalProgrammeTitle { get; set; } // 16..47 + public string OriginalEpisodeTitle { get; set; } + public string TranslatedProgrammeTitle { get; set; } + public string TranslatedEpisodeTitle { get; set; } + public string TranslatorsName { get; set; } + public string TranslatorsContactDetails { get; set; } + public string SubtitleListReferenceCode { get; set; } + public string CreationDate { get; set; } + public string RevisionDate { get; set; } + public string RevisionNumber { get; set; } + public string TotalNumberOfTextAndTimingInformationBlocks { get; set; } + public string TotalNumberOfSubtitles { get; set; } + public string TotalNumberOfSubtitleGroups { get; set; } + public string MaximumNumberOfDisplayableCharactersInAnyTextRow { get; set; } + public string MaximumNumberOfDisplayableRows { get; set; } + public string TimeCodeStatus { get; set; } + public string TimeCodeStartOfProgramme { get; set; } + public string TimeCodeFirstInCue { get; set; } + public string TotalNumberOfDisks { get; set; } + public string DiskSequenceNumber { get; set; } + public string CountryOfOrigin { get; set; } + public string Publisher { get; set; } + public string EditorsName { get; set; } + public string EditorsContactDetails { get; set; } + public string SpareBytes { get; set; } + public string UserDefinedArea { get; set; } + + public double FrameRate + { + get + { + if (FrameRateFromSaveDialog > 20) + { + return FrameRateFromSaveDialog; + } + + if (DiskFormatCode.StartsWith("STL23", StringComparison.Ordinal)) + { + return 23.0; + } + + if (DiskFormatCode.StartsWith("STL24", StringComparison.Ordinal)) + { + return 24.0; + } + + if (DiskFormatCode.StartsWith("STL25", StringComparison.Ordinal)) + { + return 25.0; + } + + if (DiskFormatCode.StartsWith("STL29", StringComparison.Ordinal)) + { + return 29.0; + } + + if (DiskFormatCode.StartsWith("STL35", StringComparison.Ordinal)) + { + return 35.0; + } + + if (DiskFormatCode.StartsWith("STL48", StringComparison.Ordinal)) + { + return 48.0; + } + + if (DiskFormatCode.StartsWith("STL50", StringComparison.Ordinal)) + { + return 50.0; + } + + if (DiskFormatCode.StartsWith("STL60", StringComparison.Ordinal)) + { + return 60.0; + } + + return 30.0; // should be DiskFormatcode STL30.01 + } + } + + public EbuGeneralSubtitleInformation() + { + CodePageNumber = "437"; + DiskFormatCode = "STL25.01"; + DisplayStandardCode = "0"; // 0=Open subtitling + CharacterCodeTableNumber = "00"; + LanguageCode = "0A"; + OriginalProgrammeTitle = "No Title "; + OriginalEpisodeTitle = " "; + TranslatedProgrammeTitle = string.Empty.PadLeft(32, ' '); + TranslatedEpisodeTitle = string.Empty.PadLeft(32, ' '); + TranslatorsName = string.Empty.PadLeft(32, ' '); + TranslatorsContactDetails = string.Empty.PadLeft(32, ' '); + SubtitleListReferenceCode = "0 "; + CreationDate = "101021"; + RevisionDate = "101021"; + RevisionNumber = "01"; + TotalNumberOfTextAndTimingInformationBlocks = "00725"; + TotalNumberOfSubtitles = "00725"; + TotalNumberOfSubtitleGroups = "001"; + MaximumNumberOfDisplayableCharactersInAnyTextRow = "40"; + MaximumNumberOfDisplayableRows = "23"; + TimeCodeStatus = "1"; + TimeCodeStartOfProgramme = "00000000"; + TimeCodeFirstInCue = "00000001"; + TotalNumberOfDisks = "1"; + DiskSequenceNumber = "1"; + CountryOfOrigin = "USA"; + Publisher = string.Empty.PadLeft(32, ' '); + EditorsName = string.Empty.PadLeft(32, ' '); + EditorsContactDetails = string.Empty.PadLeft(32, ' '); + SpareBytes = string.Empty.PadLeft(75, ' '); + UserDefinedArea = string.Empty.PadLeft(576, ' '); + } + + public override string ToString() + { + var result = CodePageNumber + + DiskFormatCode + + DisplayStandardCode + + CharacterCodeTableNumber + + LanguageCode + + OriginalProgrammeTitle + + OriginalEpisodeTitle + + TranslatedProgrammeTitle + + TranslatedEpisodeTitle + + TranslatorsName + + TranslatorsContactDetails + + SubtitleListReferenceCode + + CreationDate + + RevisionDate + + RevisionNumber + + TotalNumberOfTextAndTimingInformationBlocks + + TotalNumberOfSubtitles + + TotalNumberOfSubtitleGroups + + MaximumNumberOfDisplayableCharactersInAnyTextRow + + MaximumNumberOfDisplayableRows + + TimeCodeStatus + + TimeCodeStartOfProgramme + + TimeCodeFirstInCue + + TotalNumberOfDisks + + DiskSequenceNumber + + CountryOfOrigin + + Publisher + + EditorsName + + EditorsContactDetails + + SpareBytes + + UserDefinedArea; + + if (result.Length == 1024) + { + return result; + } + + return "Length must be 1024 but is " + result.Length; + } + } + + /// + /// TTI block 128 bytes + /// + private class EbuTextTimingInformation + { + public byte SubtitleGroupNumber { get; set; } + public ushort SubtitleNumber { get; set; } + public byte ExtensionBlockNumber { get; set; } + public byte CumulativeStatus { get; set; } + public int TimeCodeInHours { get; set; } + public int TimeCodeInMinutes { get; set; } + public int TimeCodeInSeconds { get; set; } + public int TimeCodeInMilliseconds { get; set; } + public int TimeCodeOutHours { get; set; } + public int TimeCodeOutMinutes { get; set; } + public int TimeCodeOutSeconds { get; set; } + public int TimeCodeOutMilliseconds { get; set; } + public byte VerticalPosition { get; set; } + public byte JustificationCode { get; set; } + public byte CommentFlag { get; set; } + public string TextField { get; set; } + + public EbuTextTimingInformation() + { + SubtitleGroupNumber = 0; + ExtensionBlockNumber = 255; + CumulativeStatus = 0; + VerticalPosition = 0x16; + JustificationCode = 2; + CommentFlag = 0; + } + + public byte[] GetBytes(EbuGeneralSubtitleInformation header) + { + var buffer = new byte[128]; // Text and Timing Information (TTI) block consists of 128 bytes + + buffer[0] = SubtitleGroupNumber; + var temp = BitConverter.GetBytes(SubtitleNumber); + buffer[1] = temp[0]; + buffer[2] = temp[1]; + buffer[3] = ExtensionBlockNumber; + buffer[4] = CumulativeStatus; + + buffer[5] = (byte)TimeCodeInHours; + buffer[6] = (byte)TimeCodeInMinutes; + var frames = GetFrameFromMilliseconds(TimeCodeInMilliseconds, header.FrameRate, out var extraSeconds); + buffer[7] = (byte)(TimeCodeInSeconds + extraSeconds); + buffer[8] = frames; + + buffer[9] = (byte)TimeCodeOutHours; + buffer[10] = (byte)TimeCodeOutMinutes; + frames = GetFrameFromMilliseconds(TimeCodeOutMilliseconds, header.FrameRate, out extraSeconds); + buffer[11] = (byte)(TimeCodeOutSeconds + extraSeconds); + buffer[12] = frames; + + buffer[13] = VerticalPosition; + buffer[14] = JustificationCode; + buffer[15] = CommentFlag; + + var encoding = GetEncoding(header.CodePageNumber); + if (header.LanguageCode == LanguageCodeChinese) + { + var lines = HtmlUtil.RemoveHtmlTags(TextField, true).SplitToLines(); + var byteList = new List(); + encoding = Encoding.GetEncoding(1200); // 16-bit Unicode + for (var i = 0; i < lines.Count; i++) + { + var l = lines[i]; + if (i > 0) + { // new line + byteList.Add(0); + byteList.Add(138); + } + byteList.AddRange(encoding.GetBytes(l).ToArray()); + } + + for (var i = 0; i < 112; i++) + { + if (i < byteList.Count) + { + buffer[16 + i] = byteList[i]; + } + else + { + buffer[16 + i] = 0x8f; + } + } + + return buffer; + } + + if (header.CharacterCodeTableNumber == "00") + { + encoding = Encoding.GetEncoding(20269); + // 0xC1—0xCF combines characters - http://en.wikipedia.org/wiki/ISO/IEC_6937 + + var sbTwoChar = new StringBuilder(); + bool skipNext = false; + for (var index = 0; index < TextField.Length; index++) + { + var ch = TextField[index]; + if (skipNext) + { + skipNext = false; + } + else if (ch == 'ı' && TextField.Substring(index).StartsWith("ı̂")) // extended unicode char - rewritten as simple 'î' - looks the same as "î" but it's not...) + { + sbTwoChar.Append(encoding.GetString(new byte[] { 0xc3, 0x69 })); // Ãi - simple î + skipNext = true; + } + else if ("ÀÈÌÒÙàèìòù".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc1 }), "ÀÈÌÒÙàèìòù", "AEIOUaeiou")); + } + else if ("ÁĆÉÍĹŃÓŔŚÚÝŹáćéģíĺńóŕśúýź".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc2 }), "ÁĆÉÍĹŃÓŔŚÚÝŹáćéģíĺńóŕśúýź", "ACEILNORSUYZacegilnorsuyz")); + } + else if ("ÂĈÊĜĤÎĴÔŜÛŴŶâĉêĝĥĵôŝûŵŷîı̂".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc3 }), "ÂĈÊĜĤÎĴÔŜÛŴŶâĉêĝĥîĵôŝûŵŷ", "ACEGHIJOSUWYaceghijosuwy")); + } + else if ("ÃĨÑÕŨãĩñõũ".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc4 }), "ÃĨÑÕŨãĩñõũ", "AINOUainou")); + } + else if ("ĀĒĪŌŪāēīōū".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc5 }), "ĀĒĪŌŪāēīōū", "AEIOUaeiou")); + } + else if ("ĂĞŬăğŭ".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc6 }), "ĂĞŬăğŭ", "AGUagu")); + } + else if ("ĊĖĠİŻċėġıż".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc7 }), "ĊĖĠİŻċėġıż", "CEGIZcegiz")); + } + else if ("ÄËÏÖÜŸäëïöüÿ".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xc8 }), "ÄËÏÖÜŸäëïöüÿ", "AEIOUYaeiouy")); + } + else if ("ÅŮåů".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xca }), "ÅŮåů", "AUau")); + } + else if ("ÇĢĶĻŅŖŞŢçķļņŗşţ".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xcb }), "ÇĢĶĻŅŖŞŢçķļņŗşţ", "CGKLNRSTcklnrst")); + } + else if ("ŐŰőű".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xcd }), "ŐŰőű", "OUou")); + } + else if ("ĄĘĮŲąęįų".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xce }), "ĄĘĮŲąęįų", "AEIUaeiu")); + } + else if ("ČĎĚĽŇŘŠŤŽčďěľňřšťž".Contains(ch)) + { + sbTwoChar.Append(ReplaceSpecialCharactersWithTwoByteEncoding(ch, encoding.GetString(new byte[] { 0xcf }), "ČĎĚĽŇŘŠŤŽčďěľňřšťž", "CDELNRSTZcdelnrstz")); + } + else + { + sbTwoChar.Append(ch); + } + } + + TextField = sbTwoChar.ToString(); + } + else if (header.CharacterCodeTableNumber == "01") // Latin/Cyrillic alphabet - from ISO 8859/5-1988 + { + encoding = Encoding.GetEncoding("ISO-8859-5"); + } + else if (header.CharacterCodeTableNumber == "02") // Latin/Arabic alphabet - from ISO 8859/6-1987 + { + encoding = Encoding.GetEncoding("ISO-8859-6"); + } + else if (header.CharacterCodeTableNumber == "03") // Latin/Greek alphabet - from ISO 8859/7-1987 + { + encoding = Encoding.GetEncoding("ISO-8859-7"); // or ISO-8859-1 ? + } + else if (header.CharacterCodeTableNumber == "04") // Latin/Hebrew alphabet - from ISO 8859/8-1988 + { + encoding = Encoding.GetEncoding("ISO-8859-8"); + } + + // italic/underline + var italicsOn = encoding.GetString(new byte[] { 0x80 }); + var italicsOff = encoding.GetString(new byte[] { 0x81 }); + var underlineOn = encoding.GetString(new byte[] { 0x82 }); + var underlineOff = encoding.GetString(new byte[] { 0x83 }); + var boxingOn = encoding.GetString(new byte[] { 0x84 }); + var boxingOff = encoding.GetString(new byte[] { 0x85 }); + + TextField = FixItalics(TextField); + + TextField = TextField.Replace("", italicsOn); + TextField = TextField.Replace("", italicsOn); + TextField = TextField.Replace("", italicsOff); + TextField = TextField.Replace("", italicsOff); + TextField = TextField.Replace("", underlineOn); + TextField = TextField.Replace("", underlineOn); + TextField = TextField.Replace("", underlineOff); + TextField = TextField.Replace("", underlineOff); + TextField = TextField.Replace("", boxingOn); + TextField = TextField.Replace("", boxingOn); + TextField = TextField.Replace("", boxingOff); + TextField = TextField.Replace("", boxingOff); + if (header.CharacterCodeTableNumber == "00") + { + TextField = TextField.Replace("©", encoding.GetString(new byte[] { 0xd3 })); + TextField = TextField.Replace("™", encoding.GetString(new byte[] { 0xd4 })); + TextField = TextField.Replace("♪", encoding.GetString(new byte[] { 0xd5 })); + } + + TextField = EncodeText(TextField, encoding, header.DisplayStandardCode); + TextField = HtmlUtil.RemoveHtmlTags(TextField, true); + + if (header.DisplayStandardCode != "0") // 0=Open subtitling + { + if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox && Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight) + { + TextField = encoding.GetString(new byte[] { 0x0d, 0x0b, 0x0b }) + TextField; // d=double height, b=start box + } + else if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox) + { + TextField = encoding.GetString(new byte[] { 0x0b, 0x0b }) + TextField; // b=start box + } + else if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight) + { + TextField = encoding.GetString(new byte[] { 0x0d }) + TextField; // d=double height + } + } + + // convert text to bytes + var bytes = encoding.GetBytes(TextField); + + // some fixes for bytes + if (bytes.Length == TextField.Length) + { + for (var i = 0; i < bytes.Length; i++) + { + if (TextField[i] == '#') + { + bytes[i] = 0x23; + } + else if (TextField[i] == 'Đ') + { + bytes[i] = 0xe2; + } + else if (TextField[i] == '–') // em dash + { + bytes[i] = 0xd0; + } + } + } + + for (var i = 0; i < 112; i++) + { + if (i < bytes.Length) + { + buffer[16 + i] = bytes[i]; + } + else + { + buffer[16 + i] = 0x8f; + } + } + return buffer; + } + + private static string FixItalics(string text) + { + var italicOn = false; + var sb = new StringBuilder(); + foreach (var line in HtmlUtil.FixInvalidItalicTags(text).SplitToLines()) + { + var s = line; + if (italicOn && !s.TrimStart().StartsWith("", StringComparison.Ordinal)) + { + s = "" + s; + } + + var endTagIndex = s.LastIndexOf("", StringComparison.Ordinal); + if (s.LastIndexOf("", StringComparison.Ordinal) > endTagIndex) + { + italicOn = true; + } + else if (endTagIndex >= 0) + { + italicOn = false; + } + + if (italicOn) + { + sb.AppendLine(s + ""); + } + else + { + sb.AppendLine(s); + } + } + + return sb.ToString().TrimEnd(); + } + + private static string EncodeText(string text, Encoding encoding, string displayStandardCode) + { + // newline + var newline = encoding.GetString(new byte[] { 0x8a, 0x8a }); + if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox && Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight) + { + newline = encoding.GetString(new byte[] { 0x0a, 0x0a, 0x8a, 0x8a, 0x0d, 0x0b, 0x0b }); // 0a==end box, 0d==double height, 0b==start box + } + else if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox) + { + newline = "\u000a\u000a" + + string.Empty.PadLeft(Configuration.Settings.SubtitleSettings.EbuStlNewLineRows, '\u008a') + + encoding.GetString(new byte[] { 0x0b, 0x0b }); // 0a==end box, 0b==start box + } + else if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight) + { + newline = encoding.GetString(new byte[] { 0x8a, 0x8a, 0x0d, 0x0d }); // 0d==double height + } + + if (displayStandardCode == "0") // 0=Open subtitling + { + newline = encoding.GetString(new byte[] { 0x8A }); //8Ah=CR/LF + } + + var lastColor = string.Empty; + var sb = new StringBuilder(); + var list = text.SplitToLines(); + for (var index = 0; index < list.Count; index++) + { + if (index > 0) + { + sb.Append(newline); + if (displayStandardCode != "0" && !string.IsNullOrEmpty(lastColor)) + { + sb.Append(lastColor); + } + } + + var line = list[index]; + var i = 0; + while (i < line.Length) + { + var newStart = line.Substring(i); + if (newStart.StartsWith("', i); + if (end > 0) + { + if (displayStandardCode != "0") + { + lastColor = GetColor(encoding, line, i); + sb.Append(lastColor); + } + + i = end + 1; + } + } + else if (newStart == "") + { + i += "".Length; + lastColor = string.Empty; + } + else if (newStart.StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + if (displayStandardCode != "0") + { + sb.Append(encoding.GetString(new byte[] { 0x07 })); // white + } + + i += "".Length; + } + else + { + sb.Append(line.Substring(i, 1)); + i++; + } + } + } + + if (Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox && displayStandardCode != "0") + { + sb.Append(encoding.GetString(new byte[] { 0x0a, 0x0a })); //a=end box + } + + return sb.ToString(); + } + + private static string GetColor(Encoding encoding, string line, int i) + { + var end = line.IndexOf('>', i); + if (end > 0) + { + string f = line.Substring(i, end - i); + if (f.Contains(" color=", StringComparison.OrdinalIgnoreCase)) + { + var colorStart = f.IndexOf(" color=", StringComparison.OrdinalIgnoreCase); + if (line.IndexOf('"', colorStart + " color=".Length + 1) > 0) + { + var colorEnd = f.IndexOf('"', colorStart + " color=".Length + 1); + if (colorStart > 1) + { + string color = f.Substring(colorStart + 7, colorEnd - (colorStart + 7)); + color = color.Trim('\''); + color = color.Trim('\"'); + color = color.Trim('#'); + return GetNearestEbuColorCode(color, encoding); + } + } + } + } + return string.Empty; + } + + private static string GetNearestEbuColorCode(string color, Encoding encoding) + { + color = color.ToLowerInvariant(); + if (color == "black" || color == "000000") + { + return encoding.GetString(new byte[] { 0x00 }); // black + } + + if (color == "red" || color == "ff0000") + { + return encoding.GetString(new byte[] { 0x01 }); // red + } + + if (color == "green" || color == "00ff00") + { + return encoding.GetString(new byte[] { 0x02 }); // green + } + + if (color == "yellow" || color == "ffff00") + { + return encoding.GetString(new byte[] { 0x03 }); // yellow + } + + if (color == "blue" || color == "0000ff") + { + return encoding.GetString(new byte[] { 0x04 }); // blue + } + + if (color == "magenta" || color == "ff00ff") + { + return encoding.GetString(new byte[] { 0x05 }); // magenta + } + + if (color == "cyan" || color == "00ffff") + { + return encoding.GetString(new byte[] { 0x06 }); // cyan + } + + if (color == "white" || color == "ffffff") + { + return encoding.GetString(new byte[] { 0x07 }); // white + } + + if (color.Length == 6) + { + if (RegExprColor.IsMatch(color)) + { + const int maxDiff = 130; + int r = int.Parse(color.Substring(0, 2), NumberStyles.HexNumber); + int g = int.Parse(color.Substring(2, 2), NumberStyles.HexNumber); + int b = int.Parse(color.Substring(4, 2), NumberStyles.HexNumber); + if (r < maxDiff && g < maxDiff && b < maxDiff) + { + return encoding.GetString(new byte[] { 0x00 }); // black + } + + if (r > 255 - maxDiff && g < maxDiff && b < maxDiff) + { + return encoding.GetString(new byte[] { 0x01 }); // red + } + + if (r < maxDiff && g > 255 - maxDiff && b < maxDiff) + { + return encoding.GetString(new byte[] { 0x02 }); // green + } + + if (r > 255 - maxDiff && g > 255 - maxDiff && b < maxDiff) + { + return encoding.GetString(new byte[] { 0x03 }); // yellow + } + + if (r < maxDiff && g < maxDiff && b > 255 - maxDiff) + { + return encoding.GetString(new byte[] { 0x04 }); // blue + } + + if (r > 255 - maxDiff && g < maxDiff && b > 255 - maxDiff) + { + return encoding.GetString(new byte[] { 0x05 }); // magenta + } + + if (r < maxDiff && g > 255 - maxDiff && b > 255 - maxDiff) + { + return encoding.GetString(new byte[] { 0x06 }); // cyan + } + + if (r > 255 - maxDiff && g > 255 - maxDiff && b > 255 - maxDiff) + { + return encoding.GetString(new byte[] { 0x07 }); // white + } + } + } + return string.Empty; + } + + private static string ReplaceSpecialCharactersWithTwoByteEncoding(char ch, string specialCharacter, string originalCharacters, string newCharacters) + { + if (originalCharacters.Length != newCharacters.Length) + { + throw new ArgumentException("originalCharacters and newCharacters must have equal length"); + } + + for (var i = 0; i < newCharacters.Length; i++) + { + if (originalCharacters[i] == ch) + { + return specialCharacter + newCharacters[i]; + } + } + return ch.ToString(); + } + + public static byte GetFrameFromMilliseconds(int milliseconds, double frameRate, out byte extraSeconds) + { + extraSeconds = 0; + var fr = Math.Round(milliseconds / (TimeCode.BaseUnit / frameRate)); + if (fr >= frameRate) + { + fr = 0; + extraSeconds = 1; + } + + return (byte)fr; + } + } + + public override string Extension => ".stl"; + + public const string NameOfFormat = "EBU STL"; + + public override string Name => NameOfFormat; + + public bool Save(string fileName, Subtitle subtitle) + { + return Save(fileName, subtitle, false); + } + + public bool Save(string fileName, Subtitle subtitle, bool batchMode, EbuGeneralSubtitleInformation header = null) + { + using (var ms = new MemoryStream()) + { + var ok = Save(fileName, ms, subtitle, batchMode, header); + if (ok) + { + ms.Position = 0; + using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) + { + ms.CopyTo(fs); + } + } + return ok; + } + } + + public bool Save(string fileName, Stream stream, Subtitle subtitle, bool batchMode, EbuGeneralSubtitleInformation header) + { + if (header == null) + { + header = new EbuGeneralSubtitleInformation { LanguageCode = AutoDetectLanguageCode(subtitle) }; + } + + if (EbuUiHelper == null) + { + return false; + } + + if (subtitle.Header != null && subtitle.Header.Length == 1024 && (subtitle.Header.Contains("STL24") || subtitle.Header.Contains("STL25") || subtitle.Header.Contains("STL29") || subtitle.Header.Contains("STL30"))) + { + header = ReadHeader(GetEncoding(subtitle.Header.Substring(0, 3)).GetBytes(subtitle.Header)); + EbuUiHelper.Initialize(header, EbuUiHelper.JustificationCode, null, subtitle); + } + else + { + EbuUiHelper.Initialize(header, EbuUiHelper.JustificationCode, fileName, subtitle); + } + + if (!batchMode && !EbuUiHelper.ShowDialogOk()) + { + return false; + } + + header.TotalNumberOfSubtitles = subtitle.Paragraphs.Count.ToString("D5"); // seems to be 1 higher than actual number of subtitles + header.TotalNumberOfTextAndTimingInformationBlocks = header.TotalNumberOfSubtitles; + + var today = $"{DateTime.Now:yyMMdd}"; + if (today.Length == 6) + { + header.CreationDate = today; + header.RevisionDate = today; + } + + var firstParagraph = subtitle.GetParagraphOrDefault(0); + if (firstParagraph != null) + { + var tc = firstParagraph.StartTime; + var frames = EbuTextTimingInformation.GetFrameFromMilliseconds(tc.Milliseconds, header.FrameRate, out var extraSeconds); + var firstTimeCode = $"{tc.Hours:00}{tc.Minutes:00}{tc.Seconds + extraSeconds:00}{frames:00}"; + if (firstTimeCode.Length == 8) + { + header.TimeCodeFirstInCue = firstTimeCode; + } + } + + var buffer = GetEncoding(header.CodePageNumber).GetBytes(header.ToString()); + stream.Write(buffer, 0, buffer.Length); + + var subtitleNumber = 0; + foreach (var p in subtitle.Paragraphs) + { + var tti = new EbuTextTimingInformation(); + + if (!int.TryParse(header.MaximumNumberOfDisplayableRows, out var rows)) + { + rows = 23; + } + + if (header.DisplayStandardCode == "1" || header.DisplayStandardCode == "2") // teletext + { + rows = 23; + } + else if (header.DisplayStandardCode == "0" && header.MaximumNumberOfDisplayableRows == "02") // open subtitling + { + rows = 15; + } + + var text = p.Text.Trim(Utilities.NewLineChars); + if (text.StartsWith("{\\an7}", StringComparison.Ordinal) || text.StartsWith("{\\an8}", StringComparison.Ordinal) || text.StartsWith("{\\an9}", StringComparison.Ordinal)) + { + tti.VerticalPosition = (byte)Configuration.Settings.SubtitleSettings.EbuStlMarginTop; // top (vertical) + if (header.DisplayStandardCode == "1" || header.DisplayStandardCode == "2") // teletext + { + tti.VerticalPosition++; + } + } + else if (text.StartsWith("{\\an4}", StringComparison.Ordinal) || text.StartsWith("{\\an5}", StringComparison.Ordinal) || text.StartsWith("{\\an6}", StringComparison.Ordinal)) + { + tti.VerticalPosition = (byte)(rows / 2); // middle (vertical) + } + else + { + var numberOfLineBreaks = Math.Max(0, Utilities.GetNumberOfLines(text) - 1); + var startRow = rows - Configuration.Settings.SubtitleSettings.EbuStlMarginBottom - + numberOfLineBreaks * Configuration.Settings.SubtitleSettings.EbuStlNewLineRows; + if (startRow < 0) + { + startRow = 0; + } + + tti.VerticalPosition = (byte)startRow; // bottom (vertical) + } + + tti.JustificationCode = EbuUiHelper.JustificationCode; // use default justification + if (text.StartsWith("{\\an1}", StringComparison.Ordinal) || text.StartsWith("{\\an4}", StringComparison.Ordinal) || text.StartsWith("{\\an7}", StringComparison.Ordinal)) + { + tti.JustificationCode = 1; // 01h=left-justified text + } + else if (text.StartsWith("{\\an3}", StringComparison.Ordinal) || text.StartsWith("{\\an6}", StringComparison.Ordinal) || text.StartsWith("{\\an9}", StringComparison.Ordinal)) + { + tti.JustificationCode = 3; // 03h=right-justified + } + else if (text.StartsWith("{\\an2}", StringComparison.Ordinal) || text.StartsWith("{\\an5}", StringComparison.Ordinal) || text.StartsWith("{\\an8}", StringComparison.Ordinal)) + { + tti.JustificationCode = 2; // 02h=centred text + } + + // replace some unsupported characters + text = text.Replace("„", "\""); // lower quote + text = text.Replace("‚", "’"); // lower apostrophe + text = text.Replace("♫", "♪"); // only music single note supported + text = text.Replace("…", "..."); // fix Unicode ellipsis + + tti.SubtitleNumber = (ushort)subtitleNumber; + tti.TextField = text; + int startTag = tti.TextField.IndexOf('}'); + if (tti.TextField.StartsWith("{\\", StringComparison.Ordinal) && startTag > 0 && startTag < 10) + { + tti.TextField = tti.TextField.Remove(0, startTag + 1); + } + + if (!p.StartTime.IsMaxTime) + { + tti.TimeCodeInHours = p.StartTime.Hours; + tti.TimeCodeInMinutes = p.StartTime.Minutes; + tti.TimeCodeInSeconds = p.StartTime.Seconds; + tti.TimeCodeInMilliseconds = p.StartTime.Milliseconds; + } + + if (!p.EndTime.IsMaxTime) + { + tti.TimeCodeOutHours = p.EndTime.Hours; + tti.TimeCodeOutMinutes = p.EndTime.Minutes; + tti.TimeCodeOutSeconds = p.EndTime.Seconds; + tti.TimeCodeOutMilliseconds = p.EndTime.Milliseconds; + } + + buffer = tti.GetBytes(header); + stream.Write(buffer, 0, buffer.Length); + subtitleNumber++; + } + return true; + } + + private static string AutoDetectLanguageCode(Subtitle subtitle) + { + if (subtitle == null || subtitle.Paragraphs.Count == 0) + { + return "00"; // Unknown/not applicable + } + + var languageCode = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(subtitle); + switch (languageCode) + { + case "sq": return "01"; // Albanian + case "br": return "02"; // Breton + case "ca": return "03"; // Catalan + case "hr": return "04"; // Croatian + case "cy": return "05"; // Welsh + case "cs": return "06"; // Czech + case "da": return "07"; // Danish + case "de": return "08"; // German + case "en": return "09"; // English + case "es": return "0A"; // Spanish + case "eo": return "0B"; // Esperanto + case "et": return "0C"; // Estonian + case "eu": return "0D"; // Basque + case "fo": return "0E"; // Faroese + case "fr": return "0F"; // French + case "fy": return "10"; // Frisian + case "ga": return "11"; // Irish + case "gd": return "12"; // Gaelic + case "gl": return "13"; // Galician + case "is": return "14"; // Icelandic + case "it": return "15"; // Italian + case "Lappish": return "16"; // Lappish + case "la": return "17"; // Latin + case "lv": return "18"; // Latvian": + case "lb": return "19"; // Luxembourgi + case "lt": return "1A"; // Lithuanian + case "hu": return "1B"; // Hungarian + case "mt": return "1C"; // Maltese + case "nl": return "1D"; // Dutch + case "nb": return "1E"; // Norwegian + case "oc": return "1F"; // Occitan + case "pl": return "20"; // Polish + case "pt": return "21"; // Portuguese + case "ro": return "22"; // Romanian + case "rm": return "23"; // Romansh + case "sr": return "24"; // Serbian + case "sk": return "25"; // Slovak + case "sl": return "26"; // Slovenian + case "fi": return "27"; // Finnish + case "sv": return "28"; // Swedish + case "tr": return "29"; // Turkish + case "Flemish": return "2A"; // Flemish + case "Wallon": return "2B"; // Wallon + } + + return "09"; // English - default + } + + public override bool IsMine(List lines, string fileName) + { + if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) + { + var fi = new FileInfo(fileName); + if (fi.Length >= 1024 + 128 && fi.Length < 2048000) // not too small or too big + { + try + { + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + EbuGeneralSubtitleInformation header = ReadHeader(buffer); + if (header.DiskFormatCode.StartsWith("STL23", StringComparison.Ordinal) || + header.DiskFormatCode.StartsWith("STL24", StringComparison.Ordinal) || + header.DiskFormatCode.StartsWith("STL25", StringComparison.Ordinal) || + header.DiskFormatCode.StartsWith("STL29", StringComparison.Ordinal) || + header.DiskFormatCode.StartsWith("STL30", StringComparison.Ordinal) || + header.DiskFormatCode.StartsWith("STL35", StringComparison.Ordinal) || + header.DiskFormatCode.StartsWith("STL48", StringComparison.Ordinal) || + header.DiskFormatCode.StartsWith("STL50", StringComparison.Ordinal) || + header.DiskFormatCode.StartsWith("STL60", StringComparison.Ordinal) || + "012 ".Contains(header.DisplayStandardCode) && "437|850|860|863|865".Contains(header.CodePageNumber)) + { + return Utilities.IsInteger(header.CodePageNumber) || fileName.EndsWith(".stl", StringComparison.OrdinalIgnoreCase); + } + } + catch + { + return false; + } + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + return "Not supported!"; + } + + public void LoadSubtitle(Subtitle subtitle, byte[] buffer) + { + subtitle.Paragraphs.Clear(); + subtitle.Header = null; + var header = ReadHeader(buffer); + subtitle.Header = Encoding.UTF8.GetString(buffer); + Paragraph last = null; + byte lastExtensionBlockNumber = 0xff; + JustificationCodes = new List(); + VerticalPositions = new List(); + Configuration.Settings.General.CurrentFrameRate = header.FrameRate; + foreach (var tti in ReadTextAndTiming(buffer, header)) + { + if (tti.ExtensionBlockNumber != 0xfe) // FEh : Reserved for User Data + { + var p = new Paragraph + { + Text = tti.TextField, + StartTime = new TimeCode(tti.TimeCodeInHours, tti.TimeCodeInMinutes, tti.TimeCodeInSeconds, tti.TimeCodeInMilliseconds), + EndTime = new TimeCode(tti.TimeCodeOutHours, tti.TimeCodeOutMinutes, tti.TimeCodeOutSeconds, tti.TimeCodeOutMilliseconds), + MarginV = tti.VerticalPosition.ToString(CultureInfo.InvariantCulture) + }; + + if (Math.Abs(p.StartTime.TotalMilliseconds) < 0.01 && Math.Abs(p.EndTime.TotalMilliseconds) < 0.01) + { + p.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + p.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + } + + if (lastExtensionBlockNumber != 0xff && last != null) + { + last.Text += p.Text; // merge text + } + else + { + subtitle.Paragraphs.Add(p); + last = p; + } + + p.Text = HtmlUtil.FixInvalidItalicTags(p.Text); + lastExtensionBlockNumber = tti.ExtensionBlockNumber; + } + } + subtitle.Renumber(); + Header = header; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + LoadSubtitle(subtitle, FileUtil.ReadAllBytesShared(fileName)); + } + + public static EbuGeneralSubtitleInformation ReadHeader(byte[] buffer) + { + var enc = GetEncoding(Encoding.ASCII.GetString(buffer, 0, 3)); + var header = new EbuGeneralSubtitleInformation + { + CodePageNumber = enc.GetString(buffer, 0, 3), + DiskFormatCode = enc.GetString(buffer, 3, 8), + DisplayStandardCode = enc.GetString(buffer, 11, 1), + CharacterCodeTableNumber = enc.GetString(buffer, 12, 2), + LanguageCode = enc.GetString(buffer, 14, 2), + OriginalProgrammeTitle = enc.GetString(buffer, 16, 32), + OriginalEpisodeTitle = enc.GetString(buffer, 48, 32), + TranslatedProgrammeTitle = enc.GetString(buffer, 80, 32), + TranslatedEpisodeTitle = enc.GetString(buffer, 112, 32), + TranslatorsName = enc.GetString(buffer, 144, 32), + TranslatorsContactDetails = enc.GetString(buffer, 176, 32), + SubtitleListReferenceCode = enc.GetString(buffer, 208, 16), + CreationDate = enc.GetString(buffer, 224, 6), + RevisionDate = enc.GetString(buffer, 230, 6), + RevisionNumber = enc.GetString(buffer, 236, 2), + TotalNumberOfTextAndTimingInformationBlocks = enc.GetString(buffer, 238, 5), + TotalNumberOfSubtitles = enc.GetString(buffer, 243, 5), + TotalNumberOfSubtitleGroups = enc.GetString(buffer, 248, 3), + MaximumNumberOfDisplayableCharactersInAnyTextRow = enc.GetString(buffer, 251, 2), + MaximumNumberOfDisplayableRows = enc.GetString(buffer, 253, 2), + TimeCodeStatus = enc.GetString(buffer, 255, 1), + TimeCodeStartOfProgramme = enc.GetString(buffer, 256, 8), + CountryOfOrigin = enc.GetString(buffer, 274, 3), + SpareBytes = enc.GetString(buffer, 373, 75), + UserDefinedArea = enc.GetString(buffer, 448, 576) + }; + return header; + } + + private static Encoding GetEncoding(string codePageNumber) + { + try + { + return Encoding.GetEncoding(int.TryParse(codePageNumber, out int cp) ? cp : 437); + } + catch (NotSupportedException) + { + return Encoding.GetEncoding(437); + } + } + + /// + /// Get text with regard code page from header + /// + /// Skip next character + /// EBU header + /// data buffer + /// index to current byte in buffer + /// Character at index + private static string GetCharacter(out bool skipNext, EbuGeneralSubtitleInformation header, byte[] buffer, int index) + { + skipNext = false; + + if (header.LanguageCode == LanguageCodeChinese) + { + skipNext = true; + return Encoding.GetEncoding(1200).GetString(buffer, index, 2); // 16-bit Unicode + } + + if (header.CharacterCodeTableNumber == "00") + { + var b = buffer[index]; + if (b == 0xd3) + { + return "©"; + } + + if (b == 0xd4) + { + return "™"; + } + + if (b == 0xd5) + { + return "♪"; + } + + //note that 0xC1—0xCF combines characters - http://en.wikipedia.org/wiki/ISO/IEC_6937 + var encoding = Encoding.GetEncoding(20269); + if (index + 2 > buffer.Length) + { + return string.Empty; + } + + var next = encoding.GetString(buffer, index + 1, 1); + switch (b) + { + case 0xc1: // Grave + skipNext = @"AEIOUaeiou".Contains(next); + switch (next) + { + case "A": return "À"; + case "E": return "È"; + case "I": return "Ì"; + case "O": return "Ò"; + case "U": return "Ù"; + case "a": return "à"; + case "e": return "è"; + case "i": return "ì"; + case "o": return "ò"; + case "u": return "ù"; + } + return string.Empty; + case 0xc2: // Acute + skipNext = @"ACEILNORSUYZacegilnorsuyz".Contains(next); + switch (next) + { + case "A": return "Á"; + case "C": return "Ć"; + case "E": return "É"; + case "I": return "Í"; + case "L": return "Ĺ"; + case "N": return "Ń"; + case "O": return "Ó"; + case "R": return "Ŕ"; + case "S": return "Ś"; + case "U": return "Ú"; + case "Y": return "Ý"; + case "Z": return "Ź"; + case "a": return "á"; + case "c": return "ć"; + case "e": return "é"; + case "g": return "ģ"; + case "i": return "í"; + case "l": return "ĺ"; + case "n": return "ń"; + case "o": return "ó"; + case "r": return "ŕ"; + case "s": return "ś"; + case "u": return "ú"; + case "y": return "ý"; + case "z": return "ź"; + } + return string.Empty; + case 0xc3: // Circumflex + skipNext = @"ACEGHIJOSUWYaceghjosuwyıi".Contains(next); + switch (next) + { + case "A": return "Â"; + case "C": return "Ĉ"; + case "E": return "Ê"; + case "G": return "Ĝ"; + case "H": return "Ĥ"; + case "I": return "Î"; + case "J": return "Ĵ"; + case "O": return "Ô"; + case "S": return "Ŝ"; + case "U": return "Û"; + case "W": return "Ŵ"; + case "Y": return "Ŷ"; + case "a": return "â"; + case "c": return "ĉ"; + case "e": return "ê"; + case "g": return "ĝ"; + case "h": return "ĥ"; + case "j": return "ĵ"; + case "o": return "ô"; + case "s": return "ŝ"; + case "u": return "û"; + case "w": return "ŵ"; + case "y": return "ŷ"; + case "ı": return "ı̂"; + case "i": return "î"; + } + return string.Empty; + case 0xc4: // Tilde + skipNext = @"AINOUainou".Contains(next); + switch (next) + { + case "A": return "Ã"; + case "I": return "Ĩ"; + case "N": return "Ñ"; + case "O": return "Õ"; + case "U": return "Ũ"; + case "a": return "ã"; + case "i": return "ĩ"; + case "n": return "ñ"; + case "o": return "õ"; + case "u": return "ũ"; + } + return string.Empty; + case 0xc5: // Macron + skipNext = @"AEIOUaeiou".Contains(next); + switch (next) + { + case "A": return "Ā"; + case "E": return "Ē"; + case "I": return "Ī"; + case "O": return "Ō"; + case "U": return "Ū"; + case "a": return "ā"; + case "e": return "ē"; + case "i": return "ī"; + case "o": return "ō"; + case "u": return "ū"; + } + return string.Empty; + case 0xc6: // Breve + skipNext = @"AGUagu".Contains(next); + switch (next) + { + case "A": return "Ă"; + case "G": return "Ğ"; + case "U": return "Ŭ"; + case "a": return "ă"; + case "g": return "ğ"; + case "u": return "ŭ"; + } + return string.Empty; + case 0xc7: // Dot + skipNext = @"CEGIZcegiz".Contains(next); + switch (next) + { + case "C": return "Ċ"; + case "E": return "Ė"; + case "G": return "Ġ"; + case "I": return "İ"; + case "Z": return "Ż"; + case "c": return "ċ"; + case "e": return "ė"; + case "g": return "ġ"; + case "i": return "ı"; + case "z": return "ż"; + } + return string.Empty; + case 0xc8: // Umlaut or diæresis + skipNext = @"AEIOUYaeiouy".Contains(next); + switch (next) + { + case "A": return "Ä"; + case "E": return "Ë"; + case "I": return "Ï"; + case "O": return "Ö"; + case "U": return "Ü"; + case "Y": return "Ÿ"; + case "a": return "ä"; + case "e": return "ë"; + case "i": return "ï"; + case "o": return "ö"; + case "u": return "ü"; + case "y": return "ÿ"; + } + return string.Empty; + case 0xca: // Ring + skipNext = @"AUau".Contains(next); + switch (next) + { + case "A": return "Å"; + case "U": return "Ů"; + case "a": return "å"; + case "u": return "ů"; + } + return string.Empty; + case 0xcb: // Cedilla + skipNext = @"CGKLNRSTcklnrst".Contains(next); + switch (next) + { + case "C": return "Ç"; + case "G": return "Ģ"; + case "K": return "Ķ"; + case "L": return "Ļ"; + case "N": return "Ņ"; + case "R": return "Ŗ"; + case "S": return "Ş"; + case "T": return "Ţ"; + case "c": return "ç"; + case "k": return "ķ"; + case "l": return "ļ"; + case "n": return "ņ"; + case "r": return "ŗ"; + case "s": return "ş"; + case "t": return "ţ"; + } + return string.Empty; + case 0xcd: // DoubleAcute + skipNext = @"OUou".Contains(next); + switch (next) + { + case "O": return "Ő"; + case "U": return "Ű"; + case "o": return "ő"; + case "u": return "ű"; + } + return string.Empty; + case 0xce: // Ogonek + skipNext = @"AEIUaeiu".Contains(next); + switch (next) + { + case "A": return "Ą"; + case "E": return "Ę"; + case "I": return "Į"; + case "U": return "Ų"; + case "a": return "ą"; + case "e": return "ę"; + case "i": return "į"; + case "u": return "ų"; + } + return string.Empty; + case 0xcf: // Caron + skipNext = @"CDELNRSTZcdelnrstz".Contains(next); + switch (next) + { + case "C": return "Č"; + case "D": return "Ď"; + case "E": return "Ě"; + case "L": return "Ľ"; + case "N": return "Ň"; + case "R": return "Ř"; + case "S": return "Š"; + case "T": return "Ť"; + case "Z": return "Ž"; + case "c": return "č"; + case "d": return "ď"; + case "e": return "ě"; + case "l": return "ľ"; + case "n": return "ň"; + case "r": return "ř"; + case "s": return "š"; + case "t": return "ť"; + case "z": return "ž"; + } + return string.Empty; + default: + return encoding.GetString(buffer, index, 1); + } + } + + if (header.CharacterCodeTableNumber == "01") // Latin/Cyrillic alphabet - from ISO 8859/5-1988 + { + return Encoding.GetEncoding("ISO-8859-5").GetString(buffer, index, 1); + } + + if (header.CharacterCodeTableNumber == "02") // Latin/Arabic alphabet - from ISO 8859/6-1987 + { + return Encoding.GetEncoding("ISO-8859-6").GetString(buffer, index, 1); + } + + if (header.CharacterCodeTableNumber == "03") // Latin/Greek alphabet - from ISO 8859/7-1987 + { + return Encoding.GetEncoding("ISO-8859-7").GetString(buffer, index, 1); // or ISO-8859-1 ? + } + + if (header.CharacterCodeTableNumber == "04") // Latin/Hebrew alphabet - from ISO 8859/8-1988 + { + return Encoding.GetEncoding("ISO-8859-8").GetString(buffer, index, 1); + } + + return string.Empty; + } + + /// + /// Read Text and Timing Information (TTI) block. + /// Each Text and Timing Information (TTI) block consists of 128 bytes. + /// + private IEnumerable ReadTextAndTiming(byte[] buffer, EbuGeneralSubtitleInformation header) + { + const int startOfTextAndTimingBlock = 1024; + const int ttiSize = 128; + const byte italicsOn = 0x80; + const byte italicsOff = 0x81; + const byte underlineOn = 0x82; + const byte underlineOff = 0x83; + const byte boxingOn = 0x84; + const byte boxingOff = 0x85; + + var list = new List(); + int index = startOfTextAndTimingBlock; + while (index + ttiSize <= buffer.Length) + { + var tti = new EbuTextTimingInformation + { + SubtitleGroupNumber = buffer[index], + SubtitleNumber = (ushort)(buffer[index + 2] * 256 + buffer[index + 1]), + ExtensionBlockNumber = buffer[index + 3], + CumulativeStatus = buffer[index + 4], + TimeCodeInHours = buffer[index + 5 + 0], + TimeCodeInMinutes = buffer[index + 5 + 1], + TimeCodeInSeconds = buffer[index + 5 + 2], + TimeCodeInMilliseconds = FramesToMillisecondsMax999(buffer[index + 5 + 3]), + TimeCodeOutHours = buffer[index + 9 + 0], + TimeCodeOutMinutes = buffer[index + 9 + 1], + TimeCodeOutSeconds = buffer[index + 9 + 2], + TimeCodeOutMilliseconds = FramesToMillisecondsMax999(buffer[index + 9 + 3]), + VerticalPosition = buffer[index + 13], + JustificationCode = buffer[index + 14], + CommentFlag = buffer[index + 15] + }; + VerticalPositions.Add(tti.VerticalPosition); + JustificationCodes.Add(tti.JustificationCode); + + // Text block + // - has a fixed length of 112 byte + // - 8Ah = new line + // - unused space = 8Fh + int i = index + 16; // text block start at 17th byte (index 16) + var open = header.DisplayStandardCode != "1" && header.DisplayStandardCode != "2"; + var closed = header.DisplayStandardCode != "0"; + int max = i + 112; + var sb = new StringBuilder(); + while (i < max) + { + var b = buffer[i]; + if (b <= 0x1f) // Closed - Teletext control codes + { + if (closed) + { + var tag = GetColorOrTag(b); + if (!string.IsNullOrEmpty(tag)) + { + sb.Append(tag); + } + } + } + else if (b >= 0x20 && b <= 0x7f) // Both - Character codes + { + var ch = GetCharacter(out var skipNext, header, buffer, i); + sb.Append(ch); + if (skipNext) + { + i++; + } + } + else if (b >= 0x80 && b <= 0x85) // Open - italic/underline/boxing + { + if (open) + { + if (b == italicsOn && header.LanguageCode != LanguageCodeChinese) + { + sb.Append(""); + } + else if (b == italicsOff && header.LanguageCode != LanguageCodeChinese) + { + sb.Append(""); + } + else if (b == underlineOn && header.LanguageCode != LanguageCodeChinese) + { + sb.Append(""); + } + else if (b == underlineOff && header.LanguageCode != LanguageCodeChinese) + { + sb.Append(""); + } + else if (b == boxingOn && header.LanguageCode != LanguageCodeChinese) + { + sb.Append(""); + } + else if (b == boxingOff && header.LanguageCode != LanguageCodeChinese) + { + sb.Append(""); + } + } + } + else if (b >= 0x86 && b <= 0x89) // Both - Reserved for future use + { + } + else if (b == 0x8a) // Both - CR/LF + { + sb.AppendLine(); + } + else if (b >= 0x8b && b <= 0x8e) // Both - Reserved for future use + { + } + else if (b == 0x8f) // Both - unused space + { + } + else if (b >= 0x90 && b <= 0x9f) // Both - Reserved for future use + { + } + else if (b >= 0xa1 && b <= 0xff) // Both - Character codes + { + var ch = GetCharacter(out var skipNext, header, buffer, i); + sb.Append(ch); + if (skipNext) + { + i++; + } + } + i++; + } + tti.TextField = FixSpacesAndTags(sb.ToString()); + + if (!int.TryParse(header.MaximumNumberOfDisplayableRows, out var rows)) + { + rows = 23; + } + + if (tti.VerticalPosition < 3) + { + if (tti.JustificationCode == 1) // left + { + tti.TextField = "{\\an7}" + tti.TextField; + } + else if (tti.JustificationCode == 3) // right + { + tti.TextField = "{\\an9}" + tti.TextField; + } + else + { + tti.TextField = "{\\an8}" + tti.TextField; + } + } + else if (tti.VerticalPosition <= rows / 2 + 1) + { + if (tti.JustificationCode == 1) // left + { + tti.TextField = "{\\an4}" + tti.TextField; + } + else if (tti.JustificationCode == 3) // right + { + tti.TextField = "{\\an6}" + tti.TextField; + } + else + { + tti.TextField = "{\\an5}" + tti.TextField; + } + } + else + { + if (tti.JustificationCode == 1) // left + { + tti.TextField = "{\\an1}" + tti.TextField; + } + else if (tti.JustificationCode == 3) // right + { + tti.TextField = "{\\an3}" + tti.TextField; + } + } + index += ttiSize; + list.Add(tti); + } + return list; + } + + private static string GetColorOrTag(byte b) + { + switch (b) + { + case 0x00: + return ""; + case 0x01: + return ""; + case 0x02: + return ""; + case 0x03: + return ""; + case 0x04: + return ""; + case 0x05: + return ""; + case 0x06: + return ""; + case 0x07: + return ""; + //case 0x0a: + // return ""; + //case 0x0b: + // return ""; + } + return null; + } + + private static string FixSpacesAndTags(string text) + { + text = text.Trim(); + while (text.Contains(" ")) + { + text = text.Replace(" ", " "); + } + + var match = FontTagsNoSpace1.Match(text); + while (match.Success) + { + text = text.Remove(match.Index, match.Length).Insert(match.Index, match.Value.Replace(" ", string.Empty).Contains("", string.Empty); + } + + while (text.Contains(Environment.NewLine + Environment.NewLine)) + { + text = text.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); + } + + var lines = text.SplitToLines(); + + // fix multi font tags, e.g. a color in the middle of a line + for (var index = 0; index < lines.Count; index++) + { + var whiteTag = ""; + var line = lines[index]; + var changed = false; + var count = Utilities.CountTagInText(line, " 1) + { + count = 0; + var endTags = 0; + var idx = line.IndexOf(" 0) + { + count++; + var start = line.Substring(idx); + if (count == 1 && start.StartsWith(whiteTag)) + { + line = line.Remove(idx, whiteTag.Length); + idx--; + changed = true; + lines[index] = line; + } + else if (count > 1 && start.StartsWith(whiteTag)) + { + line = line.Remove(idx, whiteTag.Length).Insert(idx, ""); + changed = true; + lines[index] = line; + endTags++; + count--; + } + else if (count > 1 && count > endTags + 1 && !start.StartsWith(whiteTag)) + { + line = line.Insert(idx, ""); + changed = true; + lines[index] = line; + idx += "".Length; + endTags++; + } + idx = line.IndexOf(" 0) + { + sb.Append(s); + if (count == 1 && !s.Contains("")) + { + sb.Append(""); + } + + sb.AppendLine(); + } + } + + text = sb.ToString().TrimEnd(); + + while (text.Contains(Environment.NewLine + " ")) + { + text = text.Replace(Environment.NewLine + " ", Environment.NewLine); + } + + // remove starting white spaces + match = FontTagsStartSpace.Match(text); + while (match.Success) + { + text = text.Remove(match.Index + match.Length - 1, 1); + match = FontTagsStartSpace.Match(text); + } + + // remove starting white spaces on 2+ line + match = FontTagsNewLineSpace.Match(text); + while (match.Success) + { + text = text.Remove(match.Index + match.Length - 1, 1); + match = FontTagsNewLineSpace.Match(text); + } + + text = text.Replace(" ", " "); + + text = HtmlUtil.FixInvalidItalicTags(text); + + return text; + } + + public override bool IsTextBased => false; + + public bool Save(string fileName, Stream stream, Subtitle subtitle, bool batchMode) + { + return Save(fileName, stream, subtitle, batchMode, null); + } + } +} diff --git a/libse/SubtitleFormats/Edl.cs b/src/libse/SubtitleFormats/Edl.cs similarity index 97% rename from libse/SubtitleFormats/Edl.cs rename to src/libse/SubtitleFormats/Edl.cs index 2bd17831a..4f70b7711 100644 --- a/libse/SubtitleFormats/Edl.cs +++ b/src/libse/SubtitleFormats/Edl.cs @@ -1,142 +1,142 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Edl : SubtitleFormat - { - private static readonly Regex Regex = new Regex(@"^\d+\s+[A-Z]{2}\s+[A-Z]\s+[A-Z]\s+\d\d:\d\d:\d\d:\d\d\s+\d\d:\d\d:\d\d:\d\d\s+\d\d:\d\d:\d\d:\d\d\s+\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); - private const string TextPrefix = "* FROM CLIP NAME: "; - - public override string Extension => ".edl"; - - public override string Name => "EDL"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - sb.AppendLine("TITLE: " + title); - if (Configuration.Settings.General.CurrentFrameRate % 1.0 > 0.01) - { - sb.AppendLine("FCM: NON-DROP FRAME"); - } - else - { - sb.AppendLine("FCM: DROP FRAME"); - } - - sb.AppendLine(); - const string writeFormat = "{0:000000} {1} {2} {3} {4} {5} {6} {7}"; - for (int index = 0; index < subtitle.Paragraphs.Count; index++) - { - int no = index + 1; - var p = subtitle.Paragraphs[index]; - if (index == 0 && p.StartTime.TotalSeconds > 1) - { - var start = new TimeCode(p.StartTime.TotalMilliseconds - 1000.0); - var end = new TimeCode(p.StartTime.TotalMilliseconds - 1); - sb.AppendLine(string.Format(writeFormat, no, "BL", "V", "C", EncodeTimeCode(start), EncodeTimeCode(end), EncodeTimeCode(start), EncodeTimeCode(end))); - sb.AppendLine(); - } - var text = HtmlUtil.RemoveHtmlTags(p.Text, true); - sb.AppendLine(string.Format(writeFormat, no, "AX", "V", "C", EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime))); - sb.AppendLine(TextPrefix + text); - sb.AppendLine(); - var next = subtitle.GetParagraphOrDefault(no); - if (next != null && next.StartTime.TotalMilliseconds > p.EndTime.TotalMilliseconds + 100) - { - var start = new TimeCode(p.EndTime.TotalMilliseconds + 1); - var end = new TimeCode(start.TotalMilliseconds + 1000); - if (end.TotalMilliseconds >= next.StartTime.TotalMilliseconds) - { - end = new TimeCode(next.StartTime.TotalMilliseconds - 1); - } - sb.AppendLine(string.Format(writeFormat, no, "BL", "V", "C", EncodeTimeCode(start), EncodeTimeCode(end), EncodeTimeCode(start), EncodeTimeCode(end))); - sb.AppendLine(); - } - } - return sb.ToString().Trim() + Environment.NewLine; - } - - private static string EncodeTimeCode(TimeCode timeCode) - { - return $"{timeCode.Hours:00}:{timeCode.Minutes:00}:{timeCode.Seconds:00}:{MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds):00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { //002 AX V C 01:00:01:15 01:00:04:18 00:00:01:15 00:00:04:18 - //000002 AX V C 01:00:04:00 01:00:05:00 00:00:02:05 00:00:03:05 - _errorCount = 0; - Paragraph lastParagraph = null; - int count = 0; - var splitChar = new[] { ' ' }; - foreach (string line in lines) - { - bool isTimeCode = false; - if (line.Length > 0) - { - bool success = false; - if (line.Length > 65 && line.Length < 85 && line.IndexOf(':') > 20) - { - var match = Regex.Match(line); - if (match.Success) - { - isTimeCode = true; - if (lastParagraph != null && Math.Abs(lastParagraph.StartTime.TotalMilliseconds + 1) > 0.001) - { - subtitle.Paragraphs.Add(lastParagraph); - } - - var arr = line.Split(splitChar, StringSplitOptions.RemoveEmptyEntries); - try - { - if (arr.Length == 8 && arr[1] != "BL") - { - var start = DecodeTimeCodeFrames(arr[6], SplitCharColon); - var end = DecodeTimeCodeFrames(arr[7], SplitCharColon); - lastParagraph = new Paragraph(start, end, string.Empty); - success = true; - } - else - { - lastParagraph = new Paragraph(string.Empty, -1, -1); - } - } - catch - { - _errorCount++; - } - } - } - if (!isTimeCode && !string.IsNullOrWhiteSpace(line) && lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) - { - lastParagraph.Text = (lastParagraph.Text + Environment.NewLine + line).Trim(); - success = true; - } - if (!success && count > 9) - { - _errorCount++; - } - } - count++; - } - if (lastParagraph != null) - { - subtitle.Paragraphs.Add(lastParagraph); - } - foreach (var paragraph in subtitle.Paragraphs) - { - if (paragraph.Text.StartsWith(TextPrefix, StringComparison.Ordinal)) - { - paragraph.Text = paragraph.Text.Remove(0, TextPrefix.Length).TrimStart(); - } - } - - subtitle.Renumber(); - } - - } +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Edl : SubtitleFormat + { + private static readonly Regex Regex = new Regex(@"^\d+\s+[A-Z]{2}\s+[A-Z]\s+[A-Z]\s+\d\d:\d\d:\d\d:\d\d\s+\d\d:\d\d:\d\d:\d\d\s+\d\d:\d\d:\d\d:\d\d\s+\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); + private const string TextPrefix = "* FROM CLIP NAME: "; + + public override string Extension => ".edl"; + + public override string Name => "EDL"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + sb.AppendLine("TITLE: " + title); + if (Configuration.Settings.General.CurrentFrameRate % 1.0 > 0.01) + { + sb.AppendLine("FCM: NON-DROP FRAME"); + } + else + { + sb.AppendLine("FCM: DROP FRAME"); + } + + sb.AppendLine(); + const string writeFormat = "{0:000000} {1} {2} {3} {4} {5} {6} {7}"; + for (int index = 0; index < subtitle.Paragraphs.Count; index++) + { + int no = index + 1; + var p = subtitle.Paragraphs[index]; + if (index == 0 && p.StartTime.TotalSeconds > 1) + { + var start = new TimeCode(p.StartTime.TotalMilliseconds - 1000.0); + var end = new TimeCode(p.StartTime.TotalMilliseconds - 1); + sb.AppendLine(string.Format(writeFormat, no, "BL", "V", "C", EncodeTimeCode(start), EncodeTimeCode(end), EncodeTimeCode(start), EncodeTimeCode(end))); + sb.AppendLine(); + } + var text = HtmlUtil.RemoveHtmlTags(p.Text, true); + sb.AppendLine(string.Format(writeFormat, no, "AX", "V", "C", EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime))); + sb.AppendLine(TextPrefix + text); + sb.AppendLine(); + var next = subtitle.GetParagraphOrDefault(no); + if (next != null && next.StartTime.TotalMilliseconds > p.EndTime.TotalMilliseconds + 100) + { + var start = new TimeCode(p.EndTime.TotalMilliseconds + 1); + var end = new TimeCode(start.TotalMilliseconds + 1000); + if (end.TotalMilliseconds >= next.StartTime.TotalMilliseconds) + { + end = new TimeCode(next.StartTime.TotalMilliseconds - 1); + } + sb.AppendLine(string.Format(writeFormat, no, "BL", "V", "C", EncodeTimeCode(start), EncodeTimeCode(end), EncodeTimeCode(start), EncodeTimeCode(end))); + sb.AppendLine(); + } + } + return sb.ToString().Trim() + Environment.NewLine; + } + + private static string EncodeTimeCode(TimeCode timeCode) + { + return $"{timeCode.Hours:00}:{timeCode.Minutes:00}:{timeCode.Seconds:00}:{MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds):00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { //002 AX V C 01:00:01:15 01:00:04:18 00:00:01:15 00:00:04:18 + //000002 AX V C 01:00:04:00 01:00:05:00 00:00:02:05 00:00:03:05 + _errorCount = 0; + Paragraph lastParagraph = null; + int count = 0; + var splitChar = new[] { ' ' }; + foreach (string line in lines) + { + bool isTimeCode = false; + if (line.Length > 0) + { + bool success = false; + if (line.Length > 65 && line.Length < 85 && line.IndexOf(':') > 20) + { + var match = Regex.Match(line); + if (match.Success) + { + isTimeCode = true; + if (lastParagraph != null && Math.Abs(lastParagraph.StartTime.TotalMilliseconds + 1) > 0.001) + { + subtitle.Paragraphs.Add(lastParagraph); + } + + var arr = line.Split(splitChar, StringSplitOptions.RemoveEmptyEntries); + try + { + if (arr.Length == 8 && arr[1] != "BL") + { + var start = DecodeTimeCodeFrames(arr[6], SplitCharColon); + var end = DecodeTimeCodeFrames(arr[7], SplitCharColon); + lastParagraph = new Paragraph(start, end, string.Empty); + success = true; + } + else + { + lastParagraph = new Paragraph(string.Empty, -1, -1); + } + } + catch + { + _errorCount++; + } + } + } + if (!isTimeCode && !string.IsNullOrWhiteSpace(line) && lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) + { + lastParagraph.Text = (lastParagraph.Text + Environment.NewLine + line).Trim(); + success = true; + } + if (!success && count > 9) + { + _errorCount++; + } + } + count++; + } + if (lastParagraph != null) + { + subtitle.Paragraphs.Add(lastParagraph); + } + foreach (var paragraph in subtitle.Paragraphs) + { + if (paragraph.Text.StartsWith(TextPrefix, StringComparison.Ordinal)) + { + paragraph.Text = paragraph.Text.Remove(0, TextPrefix.Length).TrimStart(); + } + } + + subtitle.Renumber(); + } + + } } \ No newline at end of file diff --git a/libse/SubtitleFormats/Eeg708.cs b/src/libse/SubtitleFormats/Eeg708.cs similarity index 97% rename from libse/SubtitleFormats/Eeg708.cs rename to src/libse/SubtitleFormats/Eeg708.cs index 9ba402f77..c6fbeaa2b 100644 --- a/libse/SubtitleFormats/Eeg708.cs +++ b/src/libse/SubtitleFormats/Eeg708.cs @@ -1,105 +1,105 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Eeg708 : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "EEG 708"; - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("Caption"); - XmlAttribute start = xml.CreateAttribute("timecode"); - start.InnerText = EncodeTimeCode(p.StartTime); - paragraph.Attributes.Append(start); - XmlNode text = xml.CreateElement("Text"); - text.InnerText = p.Text; - paragraph.AppendChild(text); - xml.DocumentElement.AppendChild(paragraph); - - paragraph = xml.CreateElement("Caption"); - start = xml.CreateAttribute("timecode"); - start.InnerText = EncodeTimeCode(p.EndTime); - paragraph.Attributes.Append(start); - xml.DocumentElement.AppendChild(paragraph); - } - - return ToUtf8XmlString(xml); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - - string allText = sb.ToString(); - if (!allText.Contains("", Environment.NewLine).Replace("
", Environment.NewLine); - TimeCode startTime = DecodeTimeCodeFramesFourParts(start.Split(':')); - lastParagraph = new Paragraph(s, startTime.TotalMilliseconds, startTime.TotalMilliseconds + 3000); - subtitle.Paragraphs.Add(lastParagraph); - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - } - subtitle.Renumber(); - } - - private static string EncodeTimeCode(TimeCode time) - { - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Eeg708 : SubtitleFormat + { + public override string Extension => ".xml"; + + public override string Name => "EEG 708"; + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("Caption"); + XmlAttribute start = xml.CreateAttribute("timecode"); + start.InnerText = EncodeTimeCode(p.StartTime); + paragraph.Attributes.Append(start); + XmlNode text = xml.CreateElement("Text"); + text.InnerText = p.Text; + paragraph.AppendChild(text); + xml.DocumentElement.AppendChild(paragraph); + + paragraph = xml.CreateElement("Caption"); + start = xml.CreateAttribute("timecode"); + start.InnerText = EncodeTimeCode(p.EndTime); + paragraph.Attributes.Append(start); + xml.DocumentElement.AppendChild(paragraph); + } + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + + string allText = sb.ToString(); + if (!allText.Contains("", Environment.NewLine).Replace("
", Environment.NewLine); + TimeCode startTime = DecodeTimeCodeFramesFourParts(start.Split(':')); + lastParagraph = new Paragraph(s, startTime.TotalMilliseconds, startTime.TotalMilliseconds + 3000); + subtitle.Paragraphs.Add(lastParagraph); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + subtitle.Renumber(); + } + + private static string EncodeTimeCode(TimeCode time) + { + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + } +} diff --git a/libse/SubtitleFormats/ElrPrint.cs b/src/libse/SubtitleFormats/ElrPrint.cs similarity index 100% rename from libse/SubtitleFormats/ElrPrint.cs rename to src/libse/SubtitleFormats/ElrPrint.cs diff --git a/libse/SubtitleFormats/F4Rtf.cs b/src/libse/SubtitleFormats/F4Rtf.cs similarity index 96% rename from libse/SubtitleFormats/F4Rtf.cs rename to src/libse/SubtitleFormats/F4Rtf.cs index 14791a08d..0ef584711 100644 --- a/libse/SubtitleFormats/F4Rtf.cs +++ b/src/libse/SubtitleFormats/F4Rtf.cs @@ -1,48 +1,48 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class F4Rtf : F4Text - { - public override string Extension => ".rtf"; - - public override string Name => "F4 Rich Text Format"; - - public override bool IsMine(List lines, string fileName) - { - if (fileName != null && !fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - return ToF4Text(subtitle).ToRtf(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var sb = new StringBuilder(); - foreach (string line in lines) - { - sb.AppendLine(line); - } - - string rtf = sb.ToString().Trim(); - if (!rtf.StartsWith("{\\rtf", StringComparison.Ordinal)) - { - return; - } - - LoadF4TextSubtitle(subtitle, rtf.FromRtf()); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class F4Rtf : F4Text + { + public override string Extension => ".rtf"; + + public override string Name => "F4 Rich Text Format"; + + public override bool IsMine(List lines, string fileName) + { + if (fileName != null && !fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + return ToF4Text(subtitle).ToRtf(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var sb = new StringBuilder(); + foreach (string line in lines) + { + sb.AppendLine(line); + } + + string rtf = sb.ToString().Trim(); + if (!rtf.StartsWith("{\\rtf", StringComparison.Ordinal)) + { + return; + } + + LoadF4TextSubtitle(subtitle, rtf.FromRtf()); + } + + } +} diff --git a/libse/SubtitleFormats/F4Text.cs b/src/libse/SubtitleFormats/F4Text.cs similarity index 97% rename from libse/SubtitleFormats/F4Text.cs rename to src/libse/SubtitleFormats/F4Text.cs index e09f54fa8..30287ca53 100644 --- a/libse/SubtitleFormats/F4Text.cs +++ b/src/libse/SubtitleFormats/F4Text.cs @@ -1,156 +1,156 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - /// #00:00:06-8# - /// http://www.audiotranskription.de - /// - public class F4Text : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d-\d$", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "F4 Text"; - - public override bool IsMine(List lines, string fileName) - { - if (fileName != null && !fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public static string ToF4Text(Subtitle subtitle) - { - var sb = new StringBuilder(); - const string writeFormat = "{0}{1}"; - foreach (Paragraph p in subtitle.Paragraphs) - { - sb.AppendFormat(writeFormat, HtmlUtil.RemoveHtmlTags(p.Text, true), EncodeTimeCode(p.EndTime)); - } - return sb.ToString().Trim(); - } - - public override string ToText(Subtitle subtitle, string title) - { - return ToF4Text(subtitle); - } - - private static string EncodeTimeCode(TimeCode time) - { - return $" #{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}-{Math.Round(time.Milliseconds / 100.0, 0):0}# "; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var sb = new StringBuilder(); - foreach (string line in lines) - { - sb.AppendLine(line); - } - - string text = sb.ToString(); - if (text.Contains("{\\rtf") || text.Contains("")) - { - return; - } - - LoadF4TextSubtitle(subtitle, text); - } - - protected void LoadF4TextSubtitle(Subtitle subtitle, string text) - { - Paragraph p = null; - subtitle.Paragraphs.Clear(); - var arr = text.Trim().Split(new[] { '#' }, StringSplitOptions.RemoveEmptyEntries); - var currentText = new StringBuilder(); - foreach (string line in arr) - { - if (RegexTimeCodes.IsMatch(line)) - { - if (p == null) - { - p = new Paragraph(); - if (currentText.Length > 0) - { - p.Text = currentText.ToString().Trim().Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); - p.Text = p.Text.Trim('\n', '\r'); - subtitle.Paragraphs.Add(p); - p = new Paragraph(); - } - } - if (Math.Abs(p.StartTime.TotalMilliseconds) < 0.01 || currentText.Length == 0) - { - p.StartTime = DecodeTimeCode(line.Split(new[] { ':', '-' }, StringSplitOptions.RemoveEmptyEntries)); - } - else - { - p.EndTime = DecodeTimeCode(line.Split(new[] { ':', '-' }, StringSplitOptions.RemoveEmptyEntries)); - p.Text = currentText.ToString().Trim().Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); - p.Text = p.Text.Trim('\n', '\r').Trim(); - subtitle.Paragraphs.Add(p); - p = null; - currentText.Clear(); - } - } - else - { - if (p == null && subtitle.Paragraphs.Count > 0) - { - p = new Paragraph { StartTime = { TotalMilliseconds = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds } }; - } - currentText.AppendLine(line.Trim()); - } - } - if (currentText.Length > 0 && subtitle.Paragraphs.Count > 0 && currentText.Length < 1000) - { - if (p == null) - { - p = new Paragraph(); - } - - p.Text = currentText.ToString().Trim().Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); - p.Text = p.Text.Trim('\n', '\r').Trim(); - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 3000; - subtitle.Paragraphs.Add(p); - } - subtitle.Renumber(); - } - - private TimeCode DecodeTimeCode(string[] parts) - { - var tc = new TimeCode(); - try - { - int hour = int.Parse(parts[0]); - int minutes = int.Parse(parts[1]); - int seconds = int.Parse(parts[2]); - int millisecond = int.Parse(parts[3]); - - int milliseconds = (int)Math.Round(millisecond * 100.0); - if (milliseconds > 999) - { - milliseconds = 999; - } - - tc = new TimeCode(hour, minutes, seconds, milliseconds); - } - catch (Exception exception) - { - System.Diagnostics.Debug.WriteLine(exception.Message); - _errorCount++; - } - return tc; - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + /// + /// #00:00:06-8# + /// http://www.audiotranskription.de + /// + public class F4Text : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d-\d$", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "F4 Text"; + + public override bool IsMine(List lines, string fileName) + { + if (fileName != null && !fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public static string ToF4Text(Subtitle subtitle) + { + var sb = new StringBuilder(); + const string writeFormat = "{0}{1}"; + foreach (Paragraph p in subtitle.Paragraphs) + { + sb.AppendFormat(writeFormat, HtmlUtil.RemoveHtmlTags(p.Text, true), EncodeTimeCode(p.EndTime)); + } + return sb.ToString().Trim(); + } + + public override string ToText(Subtitle subtitle, string title) + { + return ToF4Text(subtitle); + } + + private static string EncodeTimeCode(TimeCode time) + { + return $" #{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}-{Math.Round(time.Milliseconds / 100.0, 0):0}# "; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var sb = new StringBuilder(); + foreach (string line in lines) + { + sb.AppendLine(line); + } + + string text = sb.ToString(); + if (text.Contains("{\\rtf") || text.Contains("")) + { + return; + } + + LoadF4TextSubtitle(subtitle, text); + } + + protected void LoadF4TextSubtitle(Subtitle subtitle, string text) + { + Paragraph p = null; + subtitle.Paragraphs.Clear(); + var arr = text.Trim().Split(new[] { '#' }, StringSplitOptions.RemoveEmptyEntries); + var currentText = new StringBuilder(); + foreach (string line in arr) + { + if (RegexTimeCodes.IsMatch(line)) + { + if (p == null) + { + p = new Paragraph(); + if (currentText.Length > 0) + { + p.Text = currentText.ToString().Trim().Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); + p.Text = p.Text.Trim('\n', '\r'); + subtitle.Paragraphs.Add(p); + p = new Paragraph(); + } + } + if (Math.Abs(p.StartTime.TotalMilliseconds) < 0.01 || currentText.Length == 0) + { + p.StartTime = DecodeTimeCode(line.Split(new[] { ':', '-' }, StringSplitOptions.RemoveEmptyEntries)); + } + else + { + p.EndTime = DecodeTimeCode(line.Split(new[] { ':', '-' }, StringSplitOptions.RemoveEmptyEntries)); + p.Text = currentText.ToString().Trim().Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); + p.Text = p.Text.Trim('\n', '\r').Trim(); + subtitle.Paragraphs.Add(p); + p = null; + currentText.Clear(); + } + } + else + { + if (p == null && subtitle.Paragraphs.Count > 0) + { + p = new Paragraph { StartTime = { TotalMilliseconds = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds } }; + } + currentText.AppendLine(line.Trim()); + } + } + if (currentText.Length > 0 && subtitle.Paragraphs.Count > 0 && currentText.Length < 1000) + { + if (p == null) + { + p = new Paragraph(); + } + + p.Text = currentText.ToString().Trim().Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); + p.Text = p.Text.Trim('\n', '\r').Trim(); + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 3000; + subtitle.Paragraphs.Add(p); + } + subtitle.Renumber(); + } + + private TimeCode DecodeTimeCode(string[] parts) + { + var tc = new TimeCode(); + try + { + int hour = int.Parse(parts[0]); + int minutes = int.Parse(parts[1]); + int seconds = int.Parse(parts[2]); + int millisecond = int.Parse(parts[3]); + + int milliseconds = (int)Math.Round(millisecond * 100.0); + if (milliseconds > 999) + { + milliseconds = 999; + } + + tc = new TimeCode(hour, minutes, seconds, milliseconds); + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception.Message); + _errorCount++; + } + return tc; + } + + } +} diff --git a/libse/SubtitleFormats/F4Xml.cs b/src/libse/SubtitleFormats/F4Xml.cs similarity index 96% rename from libse/SubtitleFormats/F4Xml.cs rename to src/libse/SubtitleFormats/F4Xml.cs index 6f712dd9f..c8b4c460a 100644 --- a/libse/SubtitleFormats/F4Xml.cs +++ b/src/libse/SubtitleFormats/F4Xml.cs @@ -1,74 +1,74 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class F4Xml : F4Text - { - public override string Extension => ".xml"; - - public override string Name => "F4 Xml"; - - public override bool IsMine(List lines, string fileName) - { - if (fileName != null && !fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - var xml = new XmlDocument(); - var template = @" - - - - -".Replace("'", "\""); - xml.LoadXml(template); - xml.DocumentElement.SelectSingleNode("content").Attributes["content"].Value = ToF4Text(subtitle); - - return ToUtf8XmlString(xml); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var sb = new StringBuilder(); - foreach (string line in lines) - { - sb.AppendLine(line); - } - - string xml = sb.ToString(); - if (!xml.Contains(" ".xml"; + + public override string Name => "F4 Xml"; + + public override bool IsMine(List lines, string fileName) + { + if (fileName != null && !fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + var xml = new XmlDocument(); + var template = @" + + + + +".Replace("'", "\""); + xml.LoadXml(template); + xml.DocumentElement.SelectSingleNode("content").Attributes["content"].Value = ToF4Text(subtitle); + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var sb = new StringBuilder(); + foreach (string line in lines) + { + sb.AppendLine(line); + } + + string xml = sb.ToString(); + if (!xml.Contains(" ".xml"; - - public override string Name => "FLVCoreCuePoints"; - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("CuePoint"); - - XmlNode startTime = xml.CreateElement("Time"); - startTime.InnerText = p.StartTime.TotalMilliseconds.ToString(); - paragraph.AppendChild(startTime); - - XmlNode paragraphType = xml.CreateElement("Type"); - paragraphType.InnerText = "event"; - paragraph.AppendChild(paragraphType); - - XmlNode name = xml.CreateElement("Name"); - name.InnerText = p.Text; - paragraph.AppendChild(name); - - XmlNode parameters = xml.CreateElement("Parameters"); - - XmlNode parameter = xml.CreateElement("Parameter"); - name = xml.CreateElement("Name"); - name.InnerText = "source"; - XmlNode value = xml.CreateElement("Value"); - value.InnerText = "transcription"; - parameter.AppendChild(name); - parameter.AppendChild(value); - parameters.AppendChild(parameter); - - parameter = xml.CreateElement("Parameter"); - name = xml.CreateElement("Name"); - name.InnerText = "duration"; - value = xml.CreateElement("Value"); - value.InnerText = p.Duration.TotalMilliseconds.ToString(); - parameter.AppendChild(name); - parameter.AppendChild(value); - parameters.AppendChild(parameter); - - parameter = xml.CreateElement("Parameter"); - name = xml.CreateElement("Name"); - name.InnerText = "confidence"; - value = xml.CreateElement("Value"); - value.InnerText = "50"; - parameter.AppendChild(name); - parameter.AppendChild(value); - parameters.AppendChild(parameter); - - paragraph.AppendChild(parameters); - - xml.DocumentElement.AppendChild(paragraph); - } - - return ToUtf8XmlString(xml); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - - string allText = sb.ToString(); - if (!allText.Contains(" next.StartTime.TotalMilliseconds) - { - p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class FLVCoreCuePoints : SubtitleFormat + { + public override string Extension => ".xml"; + + public override string Name => "FLVCoreCuePoints"; + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("CuePoint"); + + XmlNode startTime = xml.CreateElement("Time"); + startTime.InnerText = p.StartTime.TotalMilliseconds.ToString(); + paragraph.AppendChild(startTime); + + XmlNode paragraphType = xml.CreateElement("Type"); + paragraphType.InnerText = "event"; + paragraph.AppendChild(paragraphType); + + XmlNode name = xml.CreateElement("Name"); + name.InnerText = p.Text; + paragraph.AppendChild(name); + + XmlNode parameters = xml.CreateElement("Parameters"); + + XmlNode parameter = xml.CreateElement("Parameter"); + name = xml.CreateElement("Name"); + name.InnerText = "source"; + XmlNode value = xml.CreateElement("Value"); + value.InnerText = "transcription"; + parameter.AppendChild(name); + parameter.AppendChild(value); + parameters.AppendChild(parameter); + + parameter = xml.CreateElement("Parameter"); + name = xml.CreateElement("Name"); + name.InnerText = "duration"; + value = xml.CreateElement("Value"); + value.InnerText = p.Duration.TotalMilliseconds.ToString(); + parameter.AppendChild(name); + parameter.AppendChild(value); + parameters.AppendChild(parameter); + + parameter = xml.CreateElement("Parameter"); + name = xml.CreateElement("Name"); + name.InnerText = "confidence"; + value = xml.CreateElement("Value"); + value.InnerText = "50"; + parameter.AppendChild(name); + parameter.AppendChild(value); + parameters.AppendChild(parameter); + + paragraph.AppendChild(parameters); + + xml.DocumentElement.AppendChild(paragraph); + } + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + + string allText = sb.ToString(); + if (!allText.Contains(" next.StartTime.TotalMilliseconds) + { + p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/FabSubtitler.cs b/src/libse/SubtitleFormats/FabSubtitler.cs similarity index 97% rename from libse/SubtitleFormats/FabSubtitler.cs rename to src/libse/SubtitleFormats/FabSubtitler.cs index 8a939e7aa..e9094e524 100644 --- a/libse/SubtitleFormats/FabSubtitler.cs +++ b/src/libse/SubtitleFormats/FabSubtitler.cs @@ -1,80 +1,80 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class FabSubtitler : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d \d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "FAB Subtitler"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - const string writeFormat = "{0} {1}{2}{3}{2}"; - foreach (Paragraph p in subtitle.Paragraphs) - { - //00:50:34:22 00:50:39:13 - //Ich muss dafür sorgen, - //dass die Epsteins weiterleben - sb.AppendLine(string.Format(writeFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), Environment.NewLine, HtmlUtil.RemoveHtmlTags(p.Text))); - } - return sb.ToString(); - } - - private static string EncodeTimeCode(TimeCode time) - { - //00:50:39:13 (last is frame) - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - //00:03:15:22 00:03:23:10 This is line one. - //This is line two. - Paragraph p = null; - subtitle.Paragraphs.Clear(); - _errorCount = 0; - foreach (string line in lines) - { - if (RegexTimeCodes.IsMatch(line)) - { - string temp = line.Substring(0, RegexTimeCodes.Match(line).Length); - string start = temp.Substring(0, 11); - string end = temp.Substring(13, 11); - - string[] startParts = start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); - string[] endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); - if (startParts.Length == 4 && endParts.Length == 4) - { - p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty); - subtitle.Paragraphs.Add(p); - } - } - else if (string.IsNullOrWhiteSpace(line)) - { - // skip these lines - } - else if (p != null) - { - if (string.IsNullOrEmpty(p.Text)) - { - p.Text = line; - } - else - { - p.Text = p.Text + Environment.NewLine + line; - } - } - } - - subtitle.Renumber(); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class FabSubtitler : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d \d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "FAB Subtitler"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + const string writeFormat = "{0} {1}{2}{3}{2}"; + foreach (Paragraph p in subtitle.Paragraphs) + { + //00:50:34:22 00:50:39:13 + //Ich muss dafür sorgen, + //dass die Epsteins weiterleben + sb.AppendLine(string.Format(writeFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), Environment.NewLine, HtmlUtil.RemoveHtmlTags(p.Text))); + } + return sb.ToString(); + } + + private static string EncodeTimeCode(TimeCode time) + { + //00:50:39:13 (last is frame) + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + //00:03:15:22 00:03:23:10 This is line one. + //This is line two. + Paragraph p = null; + subtitle.Paragraphs.Clear(); + _errorCount = 0; + foreach (string line in lines) + { + if (RegexTimeCodes.IsMatch(line)) + { + string temp = line.Substring(0, RegexTimeCodes.Match(line).Length); + string start = temp.Substring(0, 11); + string end = temp.Substring(13, 11); + + string[] startParts = start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); + string[] endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); + if (startParts.Length == 4 && endParts.Length == 4) + { + p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty); + subtitle.Paragraphs.Add(p); + } + } + else if (string.IsNullOrWhiteSpace(line)) + { + // skip these lines + } + else if (p != null) + { + if (string.IsNullOrEmpty(p.Text)) + { + p.Text = line; + } + else + { + p.Text = p.Text + Environment.NewLine + line; + } + } + } + + subtitle.Renumber(); + } + } +} diff --git a/libse/SubtitleFormats/FilmEditXml.cs b/src/libse/SubtitleFormats/FilmEditXml.cs similarity index 97% rename from libse/SubtitleFormats/FilmEditXml.cs rename to src/libse/SubtitleFormats/FilmEditXml.cs index 35355e786..88eeb8d1b 100644 --- a/libse/SubtitleFormats/FilmEditXml.cs +++ b/src/libse/SubtitleFormats/FilmEditXml.cs @@ -1,155 +1,155 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class FilmEditXml : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "Film Edit xml"; - - public override bool IsMine(List lines, string fileName) - { - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - string xmlAsString = sb.ToString().Trim(); - if (xmlAsString.Contains("") && xmlAsString.Contains("")) - { - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(xmlAsString); - var paragraphs = xml.DocumentElement.SelectNodes("subtitle"); - return paragraphs != null && paragraphs.Count > 0 && xml.DocumentElement.Name == "filmeditxml"; - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - "Arial" + Environment.NewLine + - "22" + Environment.NewLine + - "720" + Environment.NewLine + - "576" + Environment.NewLine + - "586" + Environment.NewLine + - "330" + Environment.NewLine + - "1420" + Environment.NewLine + - "25" + Environment.NewLine + - "False" + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - XmlNode div = xml.DocumentElement; - int no = 0; - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("subtitle"); - string text = HtmlUtil.RemoveHtmlTags(p.Text); - - XmlNode num = xml.CreateElement("num"); - num.InnerText = no.ToString(); - paragraph.AppendChild(num); - - XmlNode dur = xml.CreateElement("dur"); - dur.InnerText = EncodeDuration(p.Duration); - paragraph.AppendChild(dur); - - XmlNode textNode = xml.CreateElement("text"); - textNode.InnerText = text.Replace(Environment.NewLine, "\\N"); - paragraph.AppendChild(textNode); - - XmlNode timeIn = xml.CreateElement("in"); - timeIn.InnerText = EncodeTimeCode(p.StartTime); - paragraph.AppendChild(timeIn); - - XmlNode timeOut = xml.CreateElement("out"); - timeOut.InnerText = EncodeTimeCode(p.EndTime); - paragraph.AppendChild(timeOut); - - XmlNode align = xml.CreateElement("align"); - align.InnerText = "C"; - paragraph.AppendChild(align); - - XmlNode posx = xml.CreateElement("posx"); - posx.InnerText = "0"; - paragraph.AppendChild(posx); - - XmlNode post = xml.CreateElement("posy"); - post.InnerText = "308"; - paragraph.AppendChild(post); - - XmlNode memo = xml.CreateElement("memo"); - paragraph.AppendChild(memo); - - div.AppendChild(paragraph); - no++; - } - - return ToUtf8XmlString(xml); - } - - private static string EncodeDuration(TimeCode timeCode) - { - return $"{timeCode.Seconds:00}:{MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds):00}"; - } - - private static string EncodeTimeCode(TimeCode timeCode) - { - return $"{timeCode.Hours:00}:{timeCode.Minutes:00}:{timeCode.Seconds:00}:{MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds):00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - var xml = new XmlDocument { XmlResolver = null }; - xml.LoadXml(sb.ToString().Trim()); - foreach (XmlNode node in xml.DocumentElement.SelectNodes("subtitle")) - { - try - { - var p = new Paragraph(); - foreach (XmlNode innerNode in node.ChildNodes) - { - switch (innerNode.Name) - { - case "text": - p.Text = innerNode.InnerText.Replace("\\N", Environment.NewLine); - break; - case "in": - p.StartTime = DecodeTimeCodeFrames(innerNode.InnerText, SplitCharColon); - break; - case "out": - p.EndTime = DecodeTimeCodeFrames(innerNode.InnerText, SplitCharColon); - break; - } - } - if (p.StartTime.TotalSeconds >= 0 && p.EndTime.TotalMilliseconds > 0 && !string.IsNullOrEmpty(p.Text)) - { - subtitle.Paragraphs.Add(p); - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - } - subtitle.Renumber(); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class FilmEditXml : SubtitleFormat + { + public override string Extension => ".xml"; + + public override string Name => "Film Edit xml"; + + public override bool IsMine(List lines, string fileName) + { + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + string xmlAsString = sb.ToString().Trim(); + if (xmlAsString.Contains("") && xmlAsString.Contains("")) + { + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(xmlAsString); + var paragraphs = xml.DocumentElement.SelectNodes("subtitle"); + return paragraphs != null && paragraphs.Count > 0 && xml.DocumentElement.Name == "filmeditxml"; + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + "Arial" + Environment.NewLine + + "22" + Environment.NewLine + + "720" + Environment.NewLine + + "576" + Environment.NewLine + + "586" + Environment.NewLine + + "330" + Environment.NewLine + + "1420" + Environment.NewLine + + "25" + Environment.NewLine + + "False" + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + XmlNode div = xml.DocumentElement; + int no = 0; + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("subtitle"); + string text = HtmlUtil.RemoveHtmlTags(p.Text); + + XmlNode num = xml.CreateElement("num"); + num.InnerText = no.ToString(); + paragraph.AppendChild(num); + + XmlNode dur = xml.CreateElement("dur"); + dur.InnerText = EncodeDuration(p.Duration); + paragraph.AppendChild(dur); + + XmlNode textNode = xml.CreateElement("text"); + textNode.InnerText = text.Replace(Environment.NewLine, "\\N"); + paragraph.AppendChild(textNode); + + XmlNode timeIn = xml.CreateElement("in"); + timeIn.InnerText = EncodeTimeCode(p.StartTime); + paragraph.AppendChild(timeIn); + + XmlNode timeOut = xml.CreateElement("out"); + timeOut.InnerText = EncodeTimeCode(p.EndTime); + paragraph.AppendChild(timeOut); + + XmlNode align = xml.CreateElement("align"); + align.InnerText = "C"; + paragraph.AppendChild(align); + + XmlNode posx = xml.CreateElement("posx"); + posx.InnerText = "0"; + paragraph.AppendChild(posx); + + XmlNode post = xml.CreateElement("posy"); + post.InnerText = "308"; + paragraph.AppendChild(post); + + XmlNode memo = xml.CreateElement("memo"); + paragraph.AppendChild(memo); + + div.AppendChild(paragraph); + no++; + } + + return ToUtf8XmlString(xml); + } + + private static string EncodeDuration(TimeCode timeCode) + { + return $"{timeCode.Seconds:00}:{MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds):00}"; + } + + private static string EncodeTimeCode(TimeCode timeCode) + { + return $"{timeCode.Hours:00}:{timeCode.Minutes:00}:{timeCode.Seconds:00}:{MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds):00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + xml.LoadXml(sb.ToString().Trim()); + foreach (XmlNode node in xml.DocumentElement.SelectNodes("subtitle")) + { + try + { + var p = new Paragraph(); + foreach (XmlNode innerNode in node.ChildNodes) + { + switch (innerNode.Name) + { + case "text": + p.Text = innerNode.InnerText.Replace("\\N", Environment.NewLine); + break; + case "in": + p.StartTime = DecodeTimeCodeFrames(innerNode.InnerText, SplitCharColon); + break; + case "out": + p.EndTime = DecodeTimeCodeFrames(innerNode.InnerText, SplitCharColon); + break; + } + } + if (p.StartTime.TotalSeconds >= 0 && p.EndTime.TotalMilliseconds > 0 && !string.IsNullOrEmpty(p.Text)) + { + subtitle.Paragraphs.Add(p); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + subtitle.Renumber(); + } + } +} diff --git a/libse/SubtitleFormats/FinalCutProImage.cs b/src/libse/SubtitleFormats/FinalCutProImage.cs similarity index 97% rename from libse/SubtitleFormats/FinalCutProImage.cs rename to src/libse/SubtitleFormats/FinalCutProImage.cs index c36999fae..3715e825c 100644 --- a/libse/SubtitleFormats/FinalCutProImage.cs +++ b/src/libse/SubtitleFormats/FinalCutProImage.cs @@ -1,107 +1,107 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class FinalCutProImage : SubtitleFormat - { - public double FrameRate { get; set; } - - public override string Extension => ".xml"; - - public override string Name => "Final Cut Pro Image"; - - public override string ToText(Subtitle subtitle, string title) - { - throw new NotImplementedException(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - FrameRate = Configuration.Settings.General.CurrentFrameRate; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(sb.ToString().Trim()); - - if (xml.DocumentElement.SelectSingleNode("sequence/rate") != null && xml.DocumentElement.SelectSingleNode("sequence/rate/timebase") != null) - { - try - { - var frameRate = double.Parse(xml.DocumentElement.SelectSingleNode("sequence/rate/timebase").InnerText); - if (frameRate > 10 && frameRate < 2000) - { - Configuration.Settings.General.CurrentFrameRate = frameRate; - } - } - catch - { - // ignored - } - } - - - foreach (XmlNode node in xml.DocumentElement.SelectNodes("sequence/media/video/track/clipitem")) - { - try - { - XmlNode fileNode = node.SelectSingleNode("file"); - if (fileNode != null) - { - XmlNode fileNameNode = fileNode.SelectSingleNode("name"); - XmlNode pathurlNode = fileNode.SelectSingleNode("pathurl"); - if (fileNameNode != null) - { - var p = new Paragraph(); - p.Text = fileNameNode.InnerText; - if (pathurlNode != null) - { - p.Extra = pathurlNode.InnerText; - } - - XmlNode inNode = node.SelectSingleNode("in"); - XmlNode startNode = node.SelectSingleNode("start"); - if (startNode != null) - { - p.StartTime.TotalMilliseconds = FramesToMilliseconds(Convert.ToInt32(startNode.InnerText)); - } - else if (inNode != null) - { - p.StartTime.TotalMilliseconds = FramesToMilliseconds(Convert.ToInt32(inNode.InnerText)); - } - XmlNode outNode = node.SelectSingleNode("out"); - XmlNode endNode = node.SelectSingleNode("end"); - if (endNode != null) - { - p.EndTime.TotalMilliseconds = FramesToMilliseconds(Convert.ToInt32(endNode.InnerText)); - } - else if (outNode != null) - { - p.EndTime.TotalMilliseconds = FramesToMilliseconds(Convert.ToInt32(outNode.InnerText)); - } - subtitle.Paragraphs.Add(p); - } - } - } - catch - { - _errorCount++; - } - } - subtitle.Renumber(); - } - catch - { - _errorCount = 1; - } - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class FinalCutProImage : SubtitleFormat + { + public double FrameRate { get; set; } + + public override string Extension => ".xml"; + + public override string Name => "Final Cut Pro Image"; + + public override string ToText(Subtitle subtitle, string title) + { + throw new NotImplementedException(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + FrameRate = Configuration.Settings.General.CurrentFrameRate; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(sb.ToString().Trim()); + + if (xml.DocumentElement.SelectSingleNode("sequence/rate") != null && xml.DocumentElement.SelectSingleNode("sequence/rate/timebase") != null) + { + try + { + var frameRate = double.Parse(xml.DocumentElement.SelectSingleNode("sequence/rate/timebase").InnerText); + if (frameRate > 10 && frameRate < 2000) + { + Configuration.Settings.General.CurrentFrameRate = frameRate; + } + } + catch + { + // ignored + } + } + + + foreach (XmlNode node in xml.DocumentElement.SelectNodes("sequence/media/video/track/clipitem")) + { + try + { + XmlNode fileNode = node.SelectSingleNode("file"); + if (fileNode != null) + { + XmlNode fileNameNode = fileNode.SelectSingleNode("name"); + XmlNode pathurlNode = fileNode.SelectSingleNode("pathurl"); + if (fileNameNode != null) + { + var p = new Paragraph(); + p.Text = fileNameNode.InnerText; + if (pathurlNode != null) + { + p.Extra = pathurlNode.InnerText; + } + + XmlNode inNode = node.SelectSingleNode("in"); + XmlNode startNode = node.SelectSingleNode("start"); + if (startNode != null) + { + p.StartTime.TotalMilliseconds = FramesToMilliseconds(Convert.ToInt32(startNode.InnerText)); + } + else if (inNode != null) + { + p.StartTime.TotalMilliseconds = FramesToMilliseconds(Convert.ToInt32(inNode.InnerText)); + } + XmlNode outNode = node.SelectSingleNode("out"); + XmlNode endNode = node.SelectSingleNode("end"); + if (endNode != null) + { + p.EndTime.TotalMilliseconds = FramesToMilliseconds(Convert.ToInt32(endNode.InnerText)); + } + else if (outNode != null) + { + p.EndTime.TotalMilliseconds = FramesToMilliseconds(Convert.ToInt32(outNode.InnerText)); + } + subtitle.Paragraphs.Add(p); + } + } + } + catch + { + _errorCount++; + } + } + subtitle.Renumber(); + } + catch + { + _errorCount = 1; + } + } + + } +} diff --git a/libse/SubtitleFormats/FinalCutProTest2Xml.cs b/src/libse/SubtitleFormats/FinalCutProTest2Xml.cs similarity index 98% rename from libse/SubtitleFormats/FinalCutProTest2Xml.cs rename to src/libse/SubtitleFormats/FinalCutProTest2Xml.cs index 8c2b6b99a..4659da414 100644 --- a/libse/SubtitleFormats/FinalCutProTest2Xml.cs +++ b/src/libse/SubtitleFormats/FinalCutProTest2Xml.cs @@ -1,313 +1,313 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - // - Mom, when you were my age what did you want to do? - public class FinalCutProTest2Xml : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "Final Cut Pro Test2 Xml"; - - public static string GetFrameRateAsString() - { - if (Configuration.Settings.General.CurrentFrameRate < 24) - { - return "24"; // ntsc 23.976 - } - - if (Configuration.Settings.General.CurrentFrameRate < 25) - { - return "24"; - } - - if (Configuration.Settings.General.CurrentFrameRate < 29) - { - return "25"; - } - - if (Configuration.Settings.General.CurrentFrameRate < 30) - { - return "30"; // ntsc 29.97 - } - - if (Configuration.Settings.General.CurrentFrameRate < 40) - { - return "30"; - } - - if (Configuration.Settings.General.CurrentFrameRate < 60) - { - return "60"; // ntsc 59.94 - } - - return "60"; - } - - public static string GetNtsc() - { - if (Configuration.Settings.General.CurrentFrameRate < 24) - { - return "TRUE"; // ntsc 23.976 - } - - if (Configuration.Settings.General.CurrentFrameRate < 25) - { - return "FALSE"; - } - - return "TRUE"; - } - - public override string ToText(Subtitle subtitle, string title) - { - int duration = 0; - if (subtitle.Paragraphs.Count > 0) - { - duration = (int)Math.Round(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalSeconds * Configuration.Settings.General.CurrentFrameRate); - } - - string seString = "Subtitle Edit at " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - " " + Environment.NewLine + - " EC466A7D-8B45-4682-9978-D15D630C882Eadd" + seString + "" + duration + ">" + GetNtsc() + @"" + GetFrameRateAsString() + @"" + GetNtsc() + @"" + GetFrameRateAsString() + @"01:00:00:0090000sourceNDF-1-1"; - - const string xmlTrackStructure = "Text3000FALSE251375148615041615FALSEblackFALSETextTextTextgeneratorvideostrTextA finales de los años sesenta, una joven pareja, Guy y Rosemary, fontnameFontLucida GrandefontsizeSize01000[FONTSIZE]fontstyleStyle14Plain1Bold2Italic3Bold/Italic41fontalignAlignment13Left1Center2Right32fontcolorFont Color255255255255originOrigin00fonttrackTracking-2002001leadingLeading-1001000aspectAspect0.151autokernAuto KerningTRUEsubpixelUse SubpixelTRUEBasic MotionbasicmotionmotionvideoscaleScale01000100rotationRotation-864086400centerCenter0.004709580.396648centerOffsetAnchor Point00video3506ED18-CB4D-41B8-A760-4D42356E4F321E6E96FD-94F6-4975-BDFE-7B360E909111"; - - if (string.IsNullOrEmpty(title)) - { - title = "Subtitle Edit subtitle"; - } - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - xml.DocumentElement.SelectSingleNode("sequence").Attributes["id"].Value = title; - xml.DocumentElement.SelectSingleNode("sequence/name").InnerText = title; - xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = Guid.NewGuid().ToString().ToUpperInvariant(); - if (!string.IsNullOrEmpty(subtitle.Header)) - { - var header = new XmlDocument(); - try - { - header.LoadXml(subtitle.Header); - var node = header.DocumentElement.SelectSingleNode("sequence/uuid"); - if (node != null) - { - xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = node.InnerText; - } - } - catch - { - } - } - - XmlNode trackNode = xml.DocumentElement.SelectSingleNode("sequence/media/video/track[2]"); - - const string newLine = "_____@___"; - int number = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode generatorItem = xml.CreateElement("generatoritem"); - string fontStyle = "1"; //1==plain - var s = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont).Trim(); - if ((s.StartsWith("") && s.EndsWith("")) || (s.StartsWith("") && s.EndsWith(""))) - { - fontStyle = "4"; //4==bold/italic - } - else if (s.StartsWith("") && s.EndsWith("")) - { - fontStyle = "3"; //3==italic - } - - generatorItem.InnerXml = xmlTrackStructure.Replace("[NUMBER]", number.ToString()).Replace("[FONTSTYLE]", fontStyle).Replace("[FONTSIZE]", Configuration.Settings.SubtitleSettings.FcpFontSize.ToString(CultureInfo.InvariantCulture)); - - double frameRate = Configuration.Settings.General.CurrentFrameRate; - XmlNode start = generatorItem.SelectSingleNode("generatoritem/start"); - start.InnerText = ((int)Math.Round(p.StartTime.TotalSeconds * frameRate)).ToString(); - - XmlNode end = generatorItem.SelectSingleNode("generatoritem/end"); - end.InnerText = ((int)Math.Round(p.EndTime.TotalSeconds * frameRate)).ToString(); - - XmlNode text = generatorItem.SelectSingleNode("generatoritem/effect/parameter[parameterid='str']/value"); - text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); - text.InnerXml = text.InnerXml.Replace(Environment.NewLine, newLine); - - trackNode.AppendChild(generatorItem.SelectSingleNode("generatoritem")); - number++; - } - - string xmlAsText = ToUtf8XmlString(xml); - xmlAsText = xmlAsText.Replace("xmeml[]", "xmeml"); - xmlAsText = xmlAsText.Replace(newLine, " "); - return xmlAsText; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var frameRate = Configuration.Settings.General.CurrentFrameRate; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(sb.ToString().Trim()); - - var header = new XmlDocument { XmlResolver = null }; - header.LoadXml(sb.ToString()); - if (header.SelectSingleNode("sequence/media/video/track") != null) - { - header.RemoveChild(header.SelectSingleNode("sequence/media/video/track")); - } - - subtitle.Header = header.OuterXml; - - if (xml.DocumentElement.SelectSingleNode("sequence/rate") != null && xml.DocumentElement.SelectSingleNode("sequence/rate/timebase") != null) - { - try - { - frameRate = double.Parse(xml.DocumentElement.SelectSingleNode("sequence/rate/timebase").InnerText); - } - catch - { - frameRate = Configuration.Settings.General.CurrentFrameRate; - } - } - - foreach (XmlNode node in xml.SelectNodes("//video/track")) - { - try - { - foreach (XmlNode generatorItemNode in node.SelectNodes("generatoritem")) - { - XmlNode rate = generatorItemNode.SelectSingleNode("rate"); - XmlNode timebase = rate?.SelectSingleNode("timebase"); - if (timebase != null) - { - frameRate = double.Parse(timebase.InnerText); - } - - double startFrame = 0; - double endFrame = 0; - XmlNode startNode = generatorItemNode.SelectSingleNode("start"); - if (startNode != null) - { - startFrame = double.Parse(startNode.InnerText); - } - - XmlNode endNode = generatorItemNode.SelectSingleNode("end"); - if (endNode != null) - { - endFrame = double.Parse(endNode.InnerText); - } - - string text = string.Empty; - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='str']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - if (valueNode != null) - { - text += valueNode.InnerText; - } - } - - bool italic = false; - bool bold = false; - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='style']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - var valueEntries = parameterNode.SelectNodes("valuelist/valueentry"); - if (valueNode != null) - { - int no; - if (int.TryParse(valueNode.InnerText, out no)) - { - no--; - if (no < valueEntries.Count) - { - var styleNameNode = valueEntries[no].SelectSingleNode("name"); - if (styleNameNode != null) - { - string styleName = styleNameNode.InnerText.ToLowerInvariant().Trim(); - italic = styleName == "italic" || styleName == "bold/italic"; - bold = styleName == "bold" || styleName == "bold/italic"; - } - } - } - } - } - if (!bold && !italic) - { - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='fontstyle']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - var valueEntries = parameterNode.SelectNodes("valuelist/valueentry"); - if (valueNode != null) - { - int no; - if (int.TryParse(valueNode.InnerText, out no)) - { - no--; - if (no < valueEntries.Count) - { - var styleNameNode = valueEntries[no].SelectSingleNode("name"); - if (styleNameNode != null) - { - string styleName = styleNameNode.InnerText.ToLowerInvariant().Trim(); - italic = styleName == "italic" || styleName == "bold/italic"; - bold = styleName == "bold" || styleName == "bold/italic"; - } - } - } - } - } - } - - if (text.Length > 0) - { - if (!text.Contains(Environment.NewLine)) - { - text = text.Replace("\r", Environment.NewLine); - } - - if (bold) - { - text = "" + text + ""; - } - - if (italic) - { - text = "" + text + ""; - } - - subtitle.Paragraphs.Add(new Paragraph(text, Convert.ToDouble((startFrame / frameRate) * 1000), Convert.ToDouble((endFrame / frameRate) * 1000))); - } - } - } - catch - { - _errorCount++; - } - } - subtitle.Renumber(); - } - catch - { - _errorCount = 1; - return; - } - Configuration.Settings.General.CurrentFrameRate = frameRate; - } - - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + // - Mom, when you were my age what did you want to do? + public class FinalCutProTest2Xml : SubtitleFormat + { + public override string Extension => ".xml"; + + public override string Name => "Final Cut Pro Test2 Xml"; + + public static string GetFrameRateAsString() + { + if (Configuration.Settings.General.CurrentFrameRate < 24) + { + return "24"; // ntsc 23.976 + } + + if (Configuration.Settings.General.CurrentFrameRate < 25) + { + return "24"; + } + + if (Configuration.Settings.General.CurrentFrameRate < 29) + { + return "25"; + } + + if (Configuration.Settings.General.CurrentFrameRate < 30) + { + return "30"; // ntsc 29.97 + } + + if (Configuration.Settings.General.CurrentFrameRate < 40) + { + return "30"; + } + + if (Configuration.Settings.General.CurrentFrameRate < 60) + { + return "60"; // ntsc 59.94 + } + + return "60"; + } + + public static string GetNtsc() + { + if (Configuration.Settings.General.CurrentFrameRate < 24) + { + return "TRUE"; // ntsc 23.976 + } + + if (Configuration.Settings.General.CurrentFrameRate < 25) + { + return "FALSE"; + } + + return "TRUE"; + } + + public override string ToText(Subtitle subtitle, string title) + { + int duration = 0; + if (subtitle.Paragraphs.Count > 0) + { + duration = (int)Math.Round(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalSeconds * Configuration.Settings.General.CurrentFrameRate); + } + + string seString = "Subtitle Edit at " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + " " + Environment.NewLine + + " EC466A7D-8B45-4682-9978-D15D630C882Eadd" + seString + "" + duration + ">" + GetNtsc() + @"" + GetFrameRateAsString() + @"" + GetNtsc() + @"" + GetFrameRateAsString() + @"01:00:00:0090000sourceNDF-1-1"; + + const string xmlTrackStructure = "Text3000FALSE251375148615041615FALSEblackFALSETextTextTextgeneratorvideostrTextA finales de los años sesenta, una joven pareja, Guy y Rosemary, fontnameFontLucida GrandefontsizeSize01000[FONTSIZE]fontstyleStyle14Plain1Bold2Italic3Bold/Italic41fontalignAlignment13Left1Center2Right32fontcolorFont Color255255255255originOrigin00fonttrackTracking-2002001leadingLeading-1001000aspectAspect0.151autokernAuto KerningTRUEsubpixelUse SubpixelTRUEBasic MotionbasicmotionmotionvideoscaleScale01000100rotationRotation-864086400centerCenter0.004709580.396648centerOffsetAnchor Point00video3506ED18-CB4D-41B8-A760-4D42356E4F321E6E96FD-94F6-4975-BDFE-7B360E909111"; + + if (string.IsNullOrEmpty(title)) + { + title = "Subtitle Edit subtitle"; + } + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + xml.DocumentElement.SelectSingleNode("sequence").Attributes["id"].Value = title; + xml.DocumentElement.SelectSingleNode("sequence/name").InnerText = title; + xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = Guid.NewGuid().ToString().ToUpperInvariant(); + if (!string.IsNullOrEmpty(subtitle.Header)) + { + var header = new XmlDocument(); + try + { + header.LoadXml(subtitle.Header); + var node = header.DocumentElement.SelectSingleNode("sequence/uuid"); + if (node != null) + { + xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = node.InnerText; + } + } + catch + { + } + } + + XmlNode trackNode = xml.DocumentElement.SelectSingleNode("sequence/media/video/track[2]"); + + const string newLine = "_____@___"; + int number = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode generatorItem = xml.CreateElement("generatoritem"); + string fontStyle = "1"; //1==plain + var s = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont).Trim(); + if ((s.StartsWith("") && s.EndsWith("")) || (s.StartsWith("") && s.EndsWith(""))) + { + fontStyle = "4"; //4==bold/italic + } + else if (s.StartsWith("") && s.EndsWith("")) + { + fontStyle = "3"; //3==italic + } + + generatorItem.InnerXml = xmlTrackStructure.Replace("[NUMBER]", number.ToString()).Replace("[FONTSTYLE]", fontStyle).Replace("[FONTSIZE]", Configuration.Settings.SubtitleSettings.FcpFontSize.ToString(CultureInfo.InvariantCulture)); + + double frameRate = Configuration.Settings.General.CurrentFrameRate; + XmlNode start = generatorItem.SelectSingleNode("generatoritem/start"); + start.InnerText = ((int)Math.Round(p.StartTime.TotalSeconds * frameRate)).ToString(); + + XmlNode end = generatorItem.SelectSingleNode("generatoritem/end"); + end.InnerText = ((int)Math.Round(p.EndTime.TotalSeconds * frameRate)).ToString(); + + XmlNode text = generatorItem.SelectSingleNode("generatoritem/effect/parameter[parameterid='str']/value"); + text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); + text.InnerXml = text.InnerXml.Replace(Environment.NewLine, newLine); + + trackNode.AppendChild(generatorItem.SelectSingleNode("generatoritem")); + number++; + } + + string xmlAsText = ToUtf8XmlString(xml); + xmlAsText = xmlAsText.Replace("xmeml[]", "xmeml"); + xmlAsText = xmlAsText.Replace(newLine, " "); + return xmlAsText; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var frameRate = Configuration.Settings.General.CurrentFrameRate; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(sb.ToString().Trim()); + + var header = new XmlDocument { XmlResolver = null }; + header.LoadXml(sb.ToString()); + if (header.SelectSingleNode("sequence/media/video/track") != null) + { + header.RemoveChild(header.SelectSingleNode("sequence/media/video/track")); + } + + subtitle.Header = header.OuterXml; + + if (xml.DocumentElement.SelectSingleNode("sequence/rate") != null && xml.DocumentElement.SelectSingleNode("sequence/rate/timebase") != null) + { + try + { + frameRate = double.Parse(xml.DocumentElement.SelectSingleNode("sequence/rate/timebase").InnerText); + } + catch + { + frameRate = Configuration.Settings.General.CurrentFrameRate; + } + } + + foreach (XmlNode node in xml.SelectNodes("//video/track")) + { + try + { + foreach (XmlNode generatorItemNode in node.SelectNodes("generatoritem")) + { + XmlNode rate = generatorItemNode.SelectSingleNode("rate"); + XmlNode timebase = rate?.SelectSingleNode("timebase"); + if (timebase != null) + { + frameRate = double.Parse(timebase.InnerText); + } + + double startFrame = 0; + double endFrame = 0; + XmlNode startNode = generatorItemNode.SelectSingleNode("start"); + if (startNode != null) + { + startFrame = double.Parse(startNode.InnerText); + } + + XmlNode endNode = generatorItemNode.SelectSingleNode("end"); + if (endNode != null) + { + endFrame = double.Parse(endNode.InnerText); + } + + string text = string.Empty; + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='str']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + if (valueNode != null) + { + text += valueNode.InnerText; + } + } + + bool italic = false; + bool bold = false; + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='style']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + var valueEntries = parameterNode.SelectNodes("valuelist/valueentry"); + if (valueNode != null) + { + int no; + if (int.TryParse(valueNode.InnerText, out no)) + { + no--; + if (no < valueEntries.Count) + { + var styleNameNode = valueEntries[no].SelectSingleNode("name"); + if (styleNameNode != null) + { + string styleName = styleNameNode.InnerText.ToLowerInvariant().Trim(); + italic = styleName == "italic" || styleName == "bold/italic"; + bold = styleName == "bold" || styleName == "bold/italic"; + } + } + } + } + } + if (!bold && !italic) + { + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='fontstyle']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + var valueEntries = parameterNode.SelectNodes("valuelist/valueentry"); + if (valueNode != null) + { + int no; + if (int.TryParse(valueNode.InnerText, out no)) + { + no--; + if (no < valueEntries.Count) + { + var styleNameNode = valueEntries[no].SelectSingleNode("name"); + if (styleNameNode != null) + { + string styleName = styleNameNode.InnerText.ToLowerInvariant().Trim(); + italic = styleName == "italic" || styleName == "bold/italic"; + bold = styleName == "bold" || styleName == "bold/italic"; + } + } + } + } + } + } + + if (text.Length > 0) + { + if (!text.Contains(Environment.NewLine)) + { + text = text.Replace("\r", Environment.NewLine); + } + + if (bold) + { + text = "" + text + ""; + } + + if (italic) + { + text = "" + text + ""; + } + + subtitle.Paragraphs.Add(new Paragraph(text, Convert.ToDouble((startFrame / frameRate) * 1000), Convert.ToDouble((endFrame / frameRate) * 1000))); + } + } + } + catch + { + _errorCount++; + } + } + subtitle.Renumber(); + } + catch + { + _errorCount = 1; + return; + } + Configuration.Settings.General.CurrentFrameRate = frameRate; + } + + } +} diff --git a/libse/SubtitleFormats/FinalCutProTextXml.cs b/src/libse/SubtitleFormats/FinalCutProTextXml.cs similarity index 97% rename from libse/SubtitleFormats/FinalCutProTextXml.cs rename to src/libse/SubtitleFormats/FinalCutProTextXml.cs index 1c710a023..bd6fd67e9 100644 --- a/libse/SubtitleFormats/FinalCutProTextXml.cs +++ b/src/libse/SubtitleFormats/FinalCutProTextXml.cs @@ -1,398 +1,398 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - // - Mom, when you were my age what did you want to do? - public class FinalCutProTestXml : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "Final Cut Pro Test Xml"; - - public static string GetFrameRateAsString() - { - if (Configuration.Settings.General.CurrentFrameRate < 24) - { - return "24"; // ntsc 23.976 - } - - if (Configuration.Settings.General.CurrentFrameRate < 25) - { - return "24"; - } - - if (Configuration.Settings.General.CurrentFrameRate < 29) - { - return "25"; - } - - if (Configuration.Settings.General.CurrentFrameRate < 30) - { - return "30"; // ntsc 29.97 - } - - if (Configuration.Settings.General.CurrentFrameRate < 40) - { - return "30"; - } - - if (Configuration.Settings.General.CurrentFrameRate < 60) - { - return "60"; // ntsc 59.94 - } - - return "60"; - } - - public static string GetNtsc() - { - if (Configuration.Settings.General.CurrentFrameRate < 24) - { - return "TRUE"; // ntsc 23.976 - } - - if (Configuration.Settings.General.CurrentFrameRate < 25) - { - return "FALSE"; - } - - return "TRUE"; - //if (Configuration.Settings.General.CurrentFrameRate < 29) - // return "FALSE"; - //if (Configuration.Settings.General.CurrentFrameRate < 29) - // return "FALSE"; - //if (Configuration.Settings.General.CurrentFrameRate < 30) - // return "TRUE"; // ntsc 29.97 - //if (Configuration.Settings.General.CurrentFrameRate < 40) - // return "TRUE"; - //if (Configuration.Settings.General.CurrentFrameRate < 40) - // return "TRUE"; - //if (Configuration.Settings.General.CurrentFrameRate < 60) - // return "TRUE"; // ntsc 59.94 - //return "FALSE"; - } - - public override string ToText(Subtitle subtitle, string title) - { - int duration = 0; - if (subtitle.Paragraphs.Count > 0) - { - duration = (int)Math.Round(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalSeconds * Configuration.Settings.General.CurrentFrameRate); - } - - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - @" 5B3B0C07-9A9D-42AA-872C-C953923F97D8 - add - X - " + duration + @" - - " + GetNtsc() + @" - " + GetFrameRateAsString() + @" - - - - " + GetNtsc() + @" - " + GetFrameRateAsString() + @" - - 00:00:00:00 - 0 - source - NDF - - 0 - " + duration + @" - - - - -"; - - if (string.IsNullOrEmpty(title)) - { - title = "Subtitle Edit subtitle"; - } - - string xmlTrackStructure = "Text0" + GetNtsc() + @"" + GetFrameRateAsString() + @"046TextTextTextgeneratorvideostrText[TEXT]fontnameFontArialfontsizeSize0100032fontstyleStyle14Plain1Bold2Italic3Bold/Italic1[FONTSTYLE]fontalignAlignment13Left1Center2Right32fontcolorFont Color1255255255originOrigin00.233854"; - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - xml.DocumentElement.SelectSingleNode("sequence").Attributes["id"].Value = title; - xml.DocumentElement.SelectSingleNode("sequence/name").InnerText = title; - - xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = Guid.NewGuid().ToString().ToUpperInvariant(); - if (!string.IsNullOrEmpty(subtitle.Header)) - { - var header = new XmlDocument(); - try - { - header.LoadXml(subtitle.Header); - var node = header.DocumentElement.SelectSingleNode("sequence/uuid"); - if (node != null) - { - xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = node.InnerText; - } - } - catch - { - } - } - - XmlNode trackNode = xml.DocumentElement.SelectSingleNode("sequence/media/video/track"); - - const string newLine = "_____@___"; - int number = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode generatorItem = xml.CreateElement("generatoritem"); - string fontStyle = "1"; //1==plain - var s = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont).Trim(); - if ((s.StartsWith("") && s.EndsWith("")) || (s.StartsWith("") && s.EndsWith(""))) - { - fontStyle = "4"; //4==bold/italic - } - else if (s.StartsWith("") && s.EndsWith("")) - { - fontStyle = "3"; //3==italic - } - - generatorItem.InnerXml = xmlTrackStructure.Replace("[NUMBER]", number.ToString()).Replace("[FONTSTYLE]", fontStyle); - - double frameRate = Configuration.Settings.General.CurrentFrameRate; - XmlNode start = generatorItem.SelectSingleNode("generatoritem/start"); - start.InnerText = ((int)Math.Round(p.StartTime.TotalSeconds * frameRate)).ToString(); - - XmlNode end = generatorItem.SelectSingleNode("generatoritem/end"); - end.InnerText = ((int)Math.Round(p.EndTime.TotalSeconds * frameRate)).ToString(); - - XmlNode text = generatorItem.SelectSingleNode("generatoritem/effect/parameter[parameterid='str']/value"); - text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); - text.InnerXml = text.InnerXml.Replace(Environment.NewLine, newLine); - - trackNode.AppendChild(generatorItem.SelectSingleNode("generatoritem")); - number++; - } - - string xmlAsText = ToUtf8XmlString(xml); - xmlAsText = xmlAsText.Replace("xmeml[]", "xmeml"); - xmlAsText = xmlAsText.Replace(newLine, " "); - return xmlAsText; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var frameRate = Configuration.Settings.General.CurrentFrameRate; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(sb.ToString().Trim()); - - var header = new XmlDocument { XmlResolver = null }; - header.LoadXml(sb.ToString()); - if (header.SelectSingleNode("sequence/media/video/track") != null) - { - header.RemoveChild(header.SelectSingleNode("sequence/media/video/track")); - } - - subtitle.Header = header.OuterXml; - - if (xml.DocumentElement.SelectSingleNode("sequence/rate") != null && xml.DocumentElement.SelectSingleNode("sequence/rate/timebase") != null) - { - try - { - frameRate = double.Parse(xml.DocumentElement.SelectSingleNode("sequence/rate/timebase").InnerText); - } - catch - { - frameRate = Configuration.Settings.General.CurrentFrameRate; - } - } - - foreach (XmlNode node in xml.SelectNodes("//media/video/track")) - { - try - { - foreach (XmlNode generatorItemNode in node.SelectNodes("generatoritem")) - { - XmlNode rate = generatorItemNode.SelectSingleNode("rate"); - if (rate != null) - { - XmlNode timebase = rate.SelectSingleNode("timebase"); - if (timebase != null) - { - frameRate = double.Parse(timebase.InnerText); - } - } - - double startFrame = 0; - double endFrame = 0; - XmlNode startNode = generatorItemNode.SelectSingleNode("start"); - if (startNode != null) - { - startFrame = double.Parse(startNode.InnerText); - } - - XmlNode endNode = generatorItemNode.SelectSingleNode("end"); - if (endNode != null) - { - endFrame = double.Parse(endNode.InnerText); - } - - string text = string.Empty; - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='str']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - if (valueNode != null) - { - text += valueNode.InnerText; - } - } - - bool italic = false; - bool bold = false; - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='style']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - var valueEntries = parameterNode.SelectNodes("valuelist/valueentry"); - if (valueNode != null) - { - int no; - if (int.TryParse(valueNode.InnerText, out no)) - { - no--; - if (no < valueEntries.Count) - { - var styleNameNode = valueEntries[no].SelectSingleNode("name"); - if (styleNameNode != null) - { - string styleName = styleNameNode.InnerText.ToLowerInvariant().Trim(); - italic = styleName == "italic" || styleName == "bold/italic"; - bold = styleName == "bold" || styleName == "bold/italic"; - } - } - } - } - } - if (!bold && !italic) - { - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='fontstyle']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - var valueEntries = parameterNode.SelectNodes("valuelist/valueentry"); - if (valueNode != null) - { - int no; - if (int.TryParse(valueNode.InnerText, out no)) - { - no--; - if (no < valueEntries.Count) - { - var styleNameNode = valueEntries[no].SelectSingleNode("name"); - if (styleNameNode != null) - { - string styleName = styleNameNode.InnerText.ToLowerInvariant().Trim(); - italic = styleName == "italic" || styleName == "bold/italic"; - bold = styleName == "bold" || styleName == "bold/italic"; - } - } - } - } - } - } - - if (text.Length > 0) - { - if (!text.Contains(Environment.NewLine)) - { - text = text.Replace("\r", Environment.NewLine); - } - - if (bold) - { - text = "" + text + ""; - } - - if (italic) - { - text = "" + text + ""; - } - - subtitle.Paragraphs.Add(new Paragraph(text, Convert.ToDouble((startFrame / frameRate) * 1000), Convert.ToDouble((endFrame / frameRate) * 1000))); - } - } - } - catch - { - _errorCount++; - } - } - subtitle.Renumber(); - } - catch - { - _errorCount = 1; - return; - } - Configuration.Settings.General.CurrentFrameRate = frameRate; - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + // - Mom, when you were my age what did you want to do? + public class FinalCutProTestXml : SubtitleFormat + { + public override string Extension => ".xml"; + + public override string Name => "Final Cut Pro Test Xml"; + + public static string GetFrameRateAsString() + { + if (Configuration.Settings.General.CurrentFrameRate < 24) + { + return "24"; // ntsc 23.976 + } + + if (Configuration.Settings.General.CurrentFrameRate < 25) + { + return "24"; + } + + if (Configuration.Settings.General.CurrentFrameRate < 29) + { + return "25"; + } + + if (Configuration.Settings.General.CurrentFrameRate < 30) + { + return "30"; // ntsc 29.97 + } + + if (Configuration.Settings.General.CurrentFrameRate < 40) + { + return "30"; + } + + if (Configuration.Settings.General.CurrentFrameRate < 60) + { + return "60"; // ntsc 59.94 + } + + return "60"; + } + + public static string GetNtsc() + { + if (Configuration.Settings.General.CurrentFrameRate < 24) + { + return "TRUE"; // ntsc 23.976 + } + + if (Configuration.Settings.General.CurrentFrameRate < 25) + { + return "FALSE"; + } + + return "TRUE"; + //if (Configuration.Settings.General.CurrentFrameRate < 29) + // return "FALSE"; + //if (Configuration.Settings.General.CurrentFrameRate < 29) + // return "FALSE"; + //if (Configuration.Settings.General.CurrentFrameRate < 30) + // return "TRUE"; // ntsc 29.97 + //if (Configuration.Settings.General.CurrentFrameRate < 40) + // return "TRUE"; + //if (Configuration.Settings.General.CurrentFrameRate < 40) + // return "TRUE"; + //if (Configuration.Settings.General.CurrentFrameRate < 60) + // return "TRUE"; // ntsc 59.94 + //return "FALSE"; + } + + public override string ToText(Subtitle subtitle, string title) + { + int duration = 0; + if (subtitle.Paragraphs.Count > 0) + { + duration = (int)Math.Round(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalSeconds * Configuration.Settings.General.CurrentFrameRate); + } + + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + @" 5B3B0C07-9A9D-42AA-872C-C953923F97D8 + add + X + " + duration + @" + + " + GetNtsc() + @" + " + GetFrameRateAsString() + @" + + + + " + GetNtsc() + @" + " + GetFrameRateAsString() + @" + + 00:00:00:00 + 0 + source + NDF + + 0 + " + duration + @" + + + + +"; + + if (string.IsNullOrEmpty(title)) + { + title = "Subtitle Edit subtitle"; + } + + string xmlTrackStructure = "Text0" + GetNtsc() + @"" + GetFrameRateAsString() + @"046TextTextTextgeneratorvideostrText[TEXT]fontnameFontArialfontsizeSize0100032fontstyleStyle14Plain1Bold2Italic3Bold/Italic1[FONTSTYLE]fontalignAlignment13Left1Center2Right32fontcolorFont Color1255255255originOrigin00.233854"; + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + xml.DocumentElement.SelectSingleNode("sequence").Attributes["id"].Value = title; + xml.DocumentElement.SelectSingleNode("sequence/name").InnerText = title; + + xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = Guid.NewGuid().ToString().ToUpperInvariant(); + if (!string.IsNullOrEmpty(subtitle.Header)) + { + var header = new XmlDocument(); + try + { + header.LoadXml(subtitle.Header); + var node = header.DocumentElement.SelectSingleNode("sequence/uuid"); + if (node != null) + { + xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = node.InnerText; + } + } + catch + { + } + } + + XmlNode trackNode = xml.DocumentElement.SelectSingleNode("sequence/media/video/track"); + + const string newLine = "_____@___"; + int number = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode generatorItem = xml.CreateElement("generatoritem"); + string fontStyle = "1"; //1==plain + var s = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont).Trim(); + if ((s.StartsWith("") && s.EndsWith("")) || (s.StartsWith("") && s.EndsWith(""))) + { + fontStyle = "4"; //4==bold/italic + } + else if (s.StartsWith("") && s.EndsWith("")) + { + fontStyle = "3"; //3==italic + } + + generatorItem.InnerXml = xmlTrackStructure.Replace("[NUMBER]", number.ToString()).Replace("[FONTSTYLE]", fontStyle); + + double frameRate = Configuration.Settings.General.CurrentFrameRate; + XmlNode start = generatorItem.SelectSingleNode("generatoritem/start"); + start.InnerText = ((int)Math.Round(p.StartTime.TotalSeconds * frameRate)).ToString(); + + XmlNode end = generatorItem.SelectSingleNode("generatoritem/end"); + end.InnerText = ((int)Math.Round(p.EndTime.TotalSeconds * frameRate)).ToString(); + + XmlNode text = generatorItem.SelectSingleNode("generatoritem/effect/parameter[parameterid='str']/value"); + text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); + text.InnerXml = text.InnerXml.Replace(Environment.NewLine, newLine); + + trackNode.AppendChild(generatorItem.SelectSingleNode("generatoritem")); + number++; + } + + string xmlAsText = ToUtf8XmlString(xml); + xmlAsText = xmlAsText.Replace("xmeml[]", "xmeml"); + xmlAsText = xmlAsText.Replace(newLine, " "); + return xmlAsText; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var frameRate = Configuration.Settings.General.CurrentFrameRate; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(sb.ToString().Trim()); + + var header = new XmlDocument { XmlResolver = null }; + header.LoadXml(sb.ToString()); + if (header.SelectSingleNode("sequence/media/video/track") != null) + { + header.RemoveChild(header.SelectSingleNode("sequence/media/video/track")); + } + + subtitle.Header = header.OuterXml; + + if (xml.DocumentElement.SelectSingleNode("sequence/rate") != null && xml.DocumentElement.SelectSingleNode("sequence/rate/timebase") != null) + { + try + { + frameRate = double.Parse(xml.DocumentElement.SelectSingleNode("sequence/rate/timebase").InnerText); + } + catch + { + frameRate = Configuration.Settings.General.CurrentFrameRate; + } + } + + foreach (XmlNode node in xml.SelectNodes("//media/video/track")) + { + try + { + foreach (XmlNode generatorItemNode in node.SelectNodes("generatoritem")) + { + XmlNode rate = generatorItemNode.SelectSingleNode("rate"); + if (rate != null) + { + XmlNode timebase = rate.SelectSingleNode("timebase"); + if (timebase != null) + { + frameRate = double.Parse(timebase.InnerText); + } + } + + double startFrame = 0; + double endFrame = 0; + XmlNode startNode = generatorItemNode.SelectSingleNode("start"); + if (startNode != null) + { + startFrame = double.Parse(startNode.InnerText); + } + + XmlNode endNode = generatorItemNode.SelectSingleNode("end"); + if (endNode != null) + { + endFrame = double.Parse(endNode.InnerText); + } + + string text = string.Empty; + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='str']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + if (valueNode != null) + { + text += valueNode.InnerText; + } + } + + bool italic = false; + bool bold = false; + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='style']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + var valueEntries = parameterNode.SelectNodes("valuelist/valueentry"); + if (valueNode != null) + { + int no; + if (int.TryParse(valueNode.InnerText, out no)) + { + no--; + if (no < valueEntries.Count) + { + var styleNameNode = valueEntries[no].SelectSingleNode("name"); + if (styleNameNode != null) + { + string styleName = styleNameNode.InnerText.ToLowerInvariant().Trim(); + italic = styleName == "italic" || styleName == "bold/italic"; + bold = styleName == "bold" || styleName == "bold/italic"; + } + } + } + } + } + if (!bold && !italic) + { + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='fontstyle']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + var valueEntries = parameterNode.SelectNodes("valuelist/valueentry"); + if (valueNode != null) + { + int no; + if (int.TryParse(valueNode.InnerText, out no)) + { + no--; + if (no < valueEntries.Count) + { + var styleNameNode = valueEntries[no].SelectSingleNode("name"); + if (styleNameNode != null) + { + string styleName = styleNameNode.InnerText.ToLowerInvariant().Trim(); + italic = styleName == "italic" || styleName == "bold/italic"; + bold = styleName == "bold" || styleName == "bold/italic"; + } + } + } + } + } + } + + if (text.Length > 0) + { + if (!text.Contains(Environment.NewLine)) + { + text = text.Replace("\r", Environment.NewLine); + } + + if (bold) + { + text = "" + text + ""; + } + + if (italic) + { + text = "" + text + ""; + } + + subtitle.Paragraphs.Add(new Paragraph(text, Convert.ToDouble((startFrame / frameRate) * 1000), Convert.ToDouble((endFrame / frameRate) * 1000))); + } + } + } + catch + { + _errorCount++; + } + } + subtitle.Renumber(); + } + catch + { + _errorCount = 1; + return; + } + Configuration.Settings.General.CurrentFrameRate = frameRate; + } + + } +} diff --git a/libse/SubtitleFormats/FinalCutProXCM.cs b/src/libse/SubtitleFormats/FinalCutProXCM.cs similarity index 97% rename from libse/SubtitleFormats/FinalCutProXCM.cs rename to src/libse/SubtitleFormats/FinalCutProXCM.cs index e10bb7e68..d19551e02 100644 --- a/libse/SubtitleFormats/FinalCutProXCM.cs +++ b/src/libse/SubtitleFormats/FinalCutProXCM.cs @@ -1,142 +1,142 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class FinalCutProXCM : SubtitleFormat - { - public double FrameRate { get; set; } - - public override string Extension => ".fcpxml"; - - public override string Name => "Final Cut Pro X Chapter Marker"; - - public override string ToText(Subtitle subtitle, string title) - { - if (Configuration.Settings.General.CurrentFrameRate > 26) - { - FrameRate = 30; - } - else - { - FrameRate = 25; - } - - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - Environment.NewLine + - "" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - XmlNode videoNode = xml.DocumentElement.SelectSingleNode("project/sequence/spine/clip"); - - int number = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode chapterMarker = xml.CreateElement("chapter-marker"); - - var attr = xml.CreateAttribute("duration"); - attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s"; - chapterMarker.Attributes.Append(attr); - - attr = xml.CreateAttribute("start"); - attr.Value = Convert.ToInt64(p.StartTime.TotalSeconds * 2400000) + "/2400000s"; - chapterMarker.Attributes.Append(attr); - - attr = xml.CreateAttribute("value"); - attr.Value = p.Text.Replace(Environment.NewLine, Convert.ToChar(8232).ToString()); - chapterMarker.Attributes.Append(attr); - - attr = xml.CreateAttribute("posterOffset"); - attr.Value = "11/24s"; - chapterMarker.Attributes.Append(attr); - - videoNode.AppendChild(chapterMarker); - number++; - } - - string xmlAsText = ToUtf8XmlString(xml); - xmlAsText = xmlAsText.Replace("fcpxml[]", "fcpxml"); - xmlAsText = xmlAsText.Replace("fcpxml []", "fcpxml"); - return xmlAsText; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - FrameRate = Configuration.Settings.General.CurrentFrameRate; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - var xml = new XmlDocument { XmlResolver = null }; - xml.PreserveWhitespace = true; - try - { - xml.LoadXml(sb.ToString().Trim()); - - foreach (XmlNode node in xml.SelectNodes("fcpxml/project/sequence/spine/clip/chapter-marker")) - { - try - { - var p = new Paragraph(); - p.Text = node.Attributes["value"].InnerText; - p.Text = p.Text.Replace(Convert.ToChar(8232).ToString(), Environment.NewLine); - p.StartTime = DecodeTime(node.Attributes["start"]); - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + DecodeTime(node.Attributes["duration"]).TotalMilliseconds; - subtitle.Paragraphs.Add(p); - } - catch - { - _errorCount++; - } - } - subtitle.Renumber(); - } - catch - { - _errorCount = 1; - } - } - - private static TimeCode DecodeTime(XmlAttribute duration) - { - // 220220/60000s - if (duration != null) - { - var arr = duration.Value.TrimEnd('s').Split('/'); - if (arr.Length == 2) - { - return TimeCode.FromSeconds(long.Parse(arr[0]) / double.Parse(arr[1])); - } - else if (arr.Length == 1) - { - return TimeCode.FromSeconds(float.Parse(arr[0])); - } - } - return new TimeCode(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class FinalCutProXCM : SubtitleFormat + { + public double FrameRate { get; set; } + + public override string Extension => ".fcpxml"; + + public override string Name => "Final Cut Pro X Chapter Marker"; + + public override string ToText(Subtitle subtitle, string title) + { + if (Configuration.Settings.General.CurrentFrameRate > 26) + { + FrameRate = 30; + } + else + { + FrameRate = 25; + } + + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + Environment.NewLine + + "" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + XmlNode videoNode = xml.DocumentElement.SelectSingleNode("project/sequence/spine/clip"); + + int number = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode chapterMarker = xml.CreateElement("chapter-marker"); + + var attr = xml.CreateAttribute("duration"); + attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s"; + chapterMarker.Attributes.Append(attr); + + attr = xml.CreateAttribute("start"); + attr.Value = Convert.ToInt64(p.StartTime.TotalSeconds * 2400000) + "/2400000s"; + chapterMarker.Attributes.Append(attr); + + attr = xml.CreateAttribute("value"); + attr.Value = p.Text.Replace(Environment.NewLine, Convert.ToChar(8232).ToString()); + chapterMarker.Attributes.Append(attr); + + attr = xml.CreateAttribute("posterOffset"); + attr.Value = "11/24s"; + chapterMarker.Attributes.Append(attr); + + videoNode.AppendChild(chapterMarker); + number++; + } + + string xmlAsText = ToUtf8XmlString(xml); + xmlAsText = xmlAsText.Replace("fcpxml[]", "fcpxml"); + xmlAsText = xmlAsText.Replace("fcpxml []", "fcpxml"); + return xmlAsText; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + FrameRate = Configuration.Settings.General.CurrentFrameRate; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + xml.PreserveWhitespace = true; + try + { + xml.LoadXml(sb.ToString().Trim()); + + foreach (XmlNode node in xml.SelectNodes("fcpxml/project/sequence/spine/clip/chapter-marker")) + { + try + { + var p = new Paragraph(); + p.Text = node.Attributes["value"].InnerText; + p.Text = p.Text.Replace(Convert.ToChar(8232).ToString(), Environment.NewLine); + p.StartTime = DecodeTime(node.Attributes["start"]); + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + DecodeTime(node.Attributes["duration"]).TotalMilliseconds; + subtitle.Paragraphs.Add(p); + } + catch + { + _errorCount++; + } + } + subtitle.Renumber(); + } + catch + { + _errorCount = 1; + } + } + + private static TimeCode DecodeTime(XmlAttribute duration) + { + // 220220/60000s + if (duration != null) + { + var arr = duration.Value.TrimEnd('s').Split('/'); + if (arr.Length == 2) + { + return TimeCode.FromSeconds(long.Parse(arr[0]) / double.Parse(arr[1])); + } + else if (arr.Length == 1) + { + return TimeCode.FromSeconds(float.Parse(arr[0])); + } + } + return new TimeCode(); + } + + } +} diff --git a/libse/SubtitleFormats/FinalCutProXXml.cs b/src/libse/SubtitleFormats/FinalCutProXXml.cs similarity index 97% rename from libse/SubtitleFormats/FinalCutProXXml.cs rename to src/libse/SubtitleFormats/FinalCutProXXml.cs index be339edc7..c2a53b3f2 100644 --- a/libse/SubtitleFormats/FinalCutProXXml.cs +++ b/src/libse/SubtitleFormats/FinalCutProXXml.cs @@ -1,176 +1,176 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class FinalCutProXXml : SubtitleFormat - { - public double FrameRate { get; set; } - - public override string Extension => ".fcpxml"; - - public override string Name => "Final Cut Pro X Xml"; - - public override string ToText(Subtitle subtitle, string title) - { - if (Configuration.Settings.General.CurrentFrameRate > 26) - { - FrameRate = 30; - } - else - { - FrameRate = 25; - } - - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - Environment.NewLine + - "" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - // - // - // - // - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - ""; - - string xmlClipStructure = - " " + Environment.NewLine + - " <adjust-transform position=\"0.267518 -32.3158\"/>" + Environment.NewLine + - " <text></text>" + Environment.NewLine + - " "; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - XmlNode videoNode = xml.DocumentElement.SelectSingleNode("project/sequence/spine"); - - int number = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode clip = xml.CreateElement("clip"); - clip.InnerXml = xmlClipStructure; - var attr = xml.CreateAttribute("name"); - attr.Value = title; - clip.Attributes.Append(attr); - - attr = xml.CreateAttribute("duration"); - //attr.Value = "9529520/2400000s"; - attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s"; - clip.Attributes.Append(attr); - - attr = xml.CreateAttribute("start"); - //attr.Value = "1201200/2400000s"; - attr.Value = Convert.ToInt64(p.StartTime.TotalSeconds * 2400000) + "/2400000s"; - clip.Attributes.Append(attr); - - attr = xml.CreateAttribute("audioStart"); - attr.Value = "0s"; - clip.Attributes.Append(attr); - - attr = xml.CreateAttribute("audioDuration"); - attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s"; - clip.Attributes.Append(attr); - - attr = xml.CreateAttribute("tcFormat"); - attr.Value = "NDF"; - clip.Attributes.Append(attr); - - XmlNode titleNode = clip.SelectSingleNode("title"); - titleNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s"; - titleNode.Attributes["name"].Value = HtmlUtil.RemoveHtmlTags(p.Text); - titleNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds * 60000) + "/60000s"; - titleNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s"; - - XmlNode text = clip.SelectSingleNode("title/text"); - text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); - - videoNode.AppendChild(clip); - number++; - } - - string xmlAsText = ToUtf8XmlString(xml); - xmlAsText = xmlAsText.Replace("fcpxml[]", "fcpxml"); - xmlAsText = xmlAsText.Replace("fcpxml []", "fcpxml"); - return xmlAsText; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - FrameRate = Configuration.Settings.General.CurrentFrameRate; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(sb.ToString().Trim()); - - foreach (XmlNode node in xml.SelectNodes("fcpxml/project/sequence/spine/clip")) - { - try - { - foreach (XmlNode title in node.SelectNodes("title")) - { - var role = title.Attributes["role"]; - if (role != null && role.InnerText == "Subtitles") - { - var textNode = title.SelectSingleNode("text"); - if (textNode != null && !string.IsNullOrEmpty(textNode.InnerText)) - { - string text = textNode.InnerText; - Paragraph p = new Paragraph(); - p.Text = text.Trim(); - p.StartTime = DecodeTime(title.Attributes["offset"]); - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + DecodeTime(title.Attributes["duration"]).TotalMilliseconds; - subtitle.Paragraphs.Add(p); - } - } - } - } - catch - { - _errorCount++; - } - } - subtitle.Renumber(); - } - catch - { - _errorCount = 1; - } - } - - private static TimeCode DecodeTime(XmlAttribute duration) - { - // 220220/60000s - if (duration != null) - { - var arr = duration.Value.TrimEnd('s').Split('/'); - if (arr.Length == 2) - { - return TimeCode.FromSeconds(long.Parse(arr[0]) / double.Parse(arr[1])); - } - else if (arr.Length == 1) - { - return TimeCode.FromSeconds(float.Parse(arr[0])); - } - } - return new TimeCode(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class FinalCutProXXml : SubtitleFormat + { + public double FrameRate { get; set; } + + public override string Extension => ".fcpxml"; + + public override string Name => "Final Cut Pro X Xml"; + + public override string ToText(Subtitle subtitle, string title) + { + if (Configuration.Settings.General.CurrentFrameRate > 26) + { + FrameRate = 30; + } + else + { + FrameRate = 25; + } + + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + Environment.NewLine + + "" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + // + // + // + // + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + ""; + + string xmlClipStructure = + " " + Environment.NewLine + + " <adjust-transform position=\"0.267518 -32.3158\"/>" + Environment.NewLine + + " <text></text>" + Environment.NewLine + + " "; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + XmlNode videoNode = xml.DocumentElement.SelectSingleNode("project/sequence/spine"); + + int number = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode clip = xml.CreateElement("clip"); + clip.InnerXml = xmlClipStructure; + var attr = xml.CreateAttribute("name"); + attr.Value = title; + clip.Attributes.Append(attr); + + attr = xml.CreateAttribute("duration"); + //attr.Value = "9529520/2400000s"; + attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s"; + clip.Attributes.Append(attr); + + attr = xml.CreateAttribute("start"); + //attr.Value = "1201200/2400000s"; + attr.Value = Convert.ToInt64(p.StartTime.TotalSeconds * 2400000) + "/2400000s"; + clip.Attributes.Append(attr); + + attr = xml.CreateAttribute("audioStart"); + attr.Value = "0s"; + clip.Attributes.Append(attr); + + attr = xml.CreateAttribute("audioDuration"); + attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s"; + clip.Attributes.Append(attr); + + attr = xml.CreateAttribute("tcFormat"); + attr.Value = "NDF"; + clip.Attributes.Append(attr); + + XmlNode titleNode = clip.SelectSingleNode("title"); + titleNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s"; + titleNode.Attributes["name"].Value = HtmlUtil.RemoveHtmlTags(p.Text); + titleNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds * 60000) + "/60000s"; + titleNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s"; + + XmlNode text = clip.SelectSingleNode("title/text"); + text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); + + videoNode.AppendChild(clip); + number++; + } + + string xmlAsText = ToUtf8XmlString(xml); + xmlAsText = xmlAsText.Replace("fcpxml[]", "fcpxml"); + xmlAsText = xmlAsText.Replace("fcpxml []", "fcpxml"); + return xmlAsText; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + FrameRate = Configuration.Settings.General.CurrentFrameRate; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(sb.ToString().Trim()); + + foreach (XmlNode node in xml.SelectNodes("fcpxml/project/sequence/spine/clip")) + { + try + { + foreach (XmlNode title in node.SelectNodes("title")) + { + var role = title.Attributes["role"]; + if (role != null && role.InnerText == "Subtitles") + { + var textNode = title.SelectSingleNode("text"); + if (textNode != null && !string.IsNullOrEmpty(textNode.InnerText)) + { + string text = textNode.InnerText; + Paragraph p = new Paragraph(); + p.Text = text.Trim(); + p.StartTime = DecodeTime(title.Attributes["offset"]); + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + DecodeTime(title.Attributes["duration"]).TotalMilliseconds; + subtitle.Paragraphs.Add(p); + } + } + } + } + catch + { + _errorCount++; + } + } + subtitle.Renumber(); + } + catch + { + _errorCount = 1; + } + } + + private static TimeCode DecodeTime(XmlAttribute duration) + { + // 220220/60000s + if (duration != null) + { + var arr = duration.Value.TrimEnd('s').Split('/'); + if (arr.Length == 2) + { + return TimeCode.FromSeconds(long.Parse(arr[0]) / double.Parse(arr[1])); + } + else if (arr.Length == 1) + { + return TimeCode.FromSeconds(float.Parse(arr[0])); + } + } + return new TimeCode(); + } + + } +} diff --git a/libse/SubtitleFormats/FinalCutProXml.cs b/src/libse/SubtitleFormats/FinalCutProXml.cs similarity index 97% rename from libse/SubtitleFormats/FinalCutProXml.cs rename to src/libse/SubtitleFormats/FinalCutProXml.cs index 0b2332574..d8dcd9b1f 100644 --- a/libse/SubtitleFormats/FinalCutProXml.cs +++ b/src/libse/SubtitleFormats/FinalCutProXml.cs @@ -1,657 +1,657 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - // - Mom, when you were my age what did you want to do? - public class FinalCutProXml : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "Final Cut Pro Xml"; - - public static string GetFrameRateAsString() - { - if (Configuration.Settings.General.CurrentFrameRate < 24) - { - return "24"; // ntsc 23.976 - } - - if (Configuration.Settings.General.CurrentFrameRate < 25) - { - return "24"; - } - - if (Configuration.Settings.General.CurrentFrameRate < 29) - { - return "25"; - } - - if (Configuration.Settings.General.CurrentFrameRate < 30) - { - return "30"; // ntsc 29.97 - } - - if (Configuration.Settings.General.CurrentFrameRate < 40) - { - return "30"; - } - - if (Configuration.Settings.General.CurrentFrameRate < 60) - { - return "60"; // ntsc 59.94 - } - - return "60"; - } - - public static string GetNtsc() - { - if (Configuration.Settings.General.CurrentFrameRate < 24) - { - return "TRUE"; // ntsc 23.976 - } - - if (Configuration.Settings.General.CurrentFrameRate < 25) - { - return "FALSE"; - } - - return "TRUE"; - } - - public override string ToText(Subtitle subtitle, string title) - { - int duration = 0; - if (subtitle.Paragraphs.Count > 0) - { - duration = (int)Math.Round(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalSeconds * Configuration.Settings.General.CurrentFrameRate); - } - - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - @" 5B3B0C07-9A9D-42AA-872C-C953923F97D8 - add - X - " + duration + @" - - " + GetNtsc() + @" - " + GetFrameRateAsString() + @" - - - - " + GetNtsc() + @" - " + GetFrameRateAsString() + @" - - 00:00:00:00 - 0 - source - NDF - - 0 - " + duration + @" - - - - -"; - - string xmlTrackStructure = - @" - Outline Text - 3000 - - " + GetNtsc() + @" - " + GetFrameRateAsString() + @" - - 1380 - 1474 - 8228 - 8322 - TRUE - FALSE - black - Outline Text1 - - Outline Text - Outline Text - Text - generator - video - - part1 - Text Settings - - - - str - Text - [TEXT] - - - font - Font - [FONTNAME] - - - style - Style - 1 - 4 - - - Plain - 1 - - - Bold - 2 - - - Italic - 3 - - - Bold/Italic - 4 - - - [FONTSTYLE] - - - align - Alignment - 1 - 3 - - - Left - 1 - - - Center - 2 - - - Right - 3 - - - 2 - - - size - Size - 0 - 200 - [FONTSIZE] - - - track - Tracking - 0 - 100 - 1 - - - lead - Leading - -100 - 100 - 0 - - - aspect - Aspect - 0 - 4 - 1 - - - linewidth - Line Width - 0 - 200 - 20 - - - linesoft - Line Softness - 0 - 100 - 5 - - - textopacity - Text Opacity - 0 - 100 - 100 - - - center - Center - - 0.00833333 - 0.390741 - - - - textcolor - Text Color - - 255 - 255 - 255 - 255 - - - - supertext - Text Graphic - - - linecolor - Line Color - - 255 - 0 - 0 - 0 - - - - part2 - Background Settings - - - - xscale - Horizontal Size - 0 - 200 - 0 - - - yscale - Vertical Size - 0 - 200 - 0 - - - xoffset - Horizontal Offset - -100 - 100 - 0 - - - yoffset - Vertical Offset - -100 - 100 - 0 - - - backcolor - Back Color - - 255 - 255 - 255 - 255 - - - - superback - Back Graphic - - - crop - Crop - FALSE - - - autokern - Auto Kerning - TRUE - - - - video - - "; - - if (string.IsNullOrEmpty(title)) - { - title = "Subtitle Edit subtitle"; - } - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - xml.DocumentElement.SelectSingleNode("sequence").Attributes["id"].Value = title; - xml.DocumentElement.SelectSingleNode("sequence/name").InnerText = title; - xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = Guid.NewGuid().ToString().ToUpperInvariant(); - if (!string.IsNullOrEmpty(subtitle.Header)) - { - var header = new XmlDocument(); - try - { - header.LoadXml(subtitle.Header); - var node = header.DocumentElement.SelectSingleNode("sequence/uuid"); - if (node != null) - { - xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = node.InnerText; - } - } - catch - { - // ignored - } - } - - XmlNode trackNode = xml.DocumentElement.SelectSingleNode("sequence/media/video/track"); - - const string newLine = "_____@___"; - int number = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode generatorItem = xml.CreateElement("generatoritem"); - string fontStyle = "1"; //1==plain - var s = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont).Trim(); - if ((s.StartsWith("") && s.EndsWith("")) || (s.StartsWith("") && s.EndsWith(""))) - { - fontStyle = "4"; //4==bold/italic - } - else if (s.StartsWith("") && s.EndsWith("")) - { - fontStyle = "3"; //3==italic - } - - generatorItem.InnerXml = xmlTrackStructure.Replace("[NUMBER]", number.ToString()).Replace("[FONTSTYLE]", fontStyle). - Replace("[FONTSIZE]", Configuration.Settings.SubtitleSettings.FcpFontSize.ToString(CultureInfo.InvariantCulture)). - Replace("[FONTNAME]", Configuration.Settings.SubtitleSettings.FcpFontName). - Replace("[NUMBER]", number.ToString(CultureInfo.InvariantCulture)); - - double frameRate = Configuration.Settings.General.CurrentFrameRate; - XmlNode start = generatorItem.SelectSingleNode("generatoritem/start"); - start.InnerText = ((int)Math.Round(p.StartTime.TotalSeconds * frameRate)).ToString(); - - XmlNode end = generatorItem.SelectSingleNode("generatoritem/end"); - end.InnerText = ((int)Math.Round(p.EndTime.TotalSeconds * frameRate)).ToString(); - - XmlNode text = generatorItem.SelectSingleNode("generatoritem/effect/parameter[parameterid='str']/value"); - text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); - text.InnerXml = text.InnerXml.Replace(Environment.NewLine, newLine); - - trackNode.AppendChild(generatorItem.SelectSingleNode("generatoritem")); - number++; - } - - string xmlAsText = ToUtf8XmlString(xml); - xmlAsText = xmlAsText.Replace("xmeml[]", "xmeml"); - xmlAsText = xmlAsText.Replace(newLine, " "); - return xmlAsText; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var frameRate = Configuration.Settings.General.CurrentFrameRate; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(sb.ToString().Trim()); - var header = new XmlDocument { XmlResolver = null }; - header.LoadXml(sb.ToString()); - if (header.SelectSingleNode("sequence/media/video/track") != null) - { - header.RemoveChild(header.SelectSingleNode("sequence/media/video/track")); - } - - subtitle.Header = header.OuterXml; - - if (xml.DocumentElement.SelectSingleNode("sequence/rate") != null && xml.DocumentElement.SelectSingleNode("sequence/rate/timebase") != null) - { - try - { - frameRate = double.Parse(xml.DocumentElement.SelectSingleNode("sequence/rate/timebase").InnerText); - } - catch - { - frameRate = Configuration.Settings.General.CurrentFrameRate; - } - } - - foreach (XmlNode node in xml.SelectNodes("//video/track")) - { - try - { - foreach (XmlNode generatorItemNode in node.SelectNodes("generatoritem")) - { - XmlNode rate = generatorItemNode.SelectSingleNode("rate"); - if (rate != null) - { - XmlNode timebase = rate.SelectSingleNode("timebase"); - if (timebase != null) - { - frameRate = double.Parse(timebase.InnerText); - } - } - - double startFrame = 0; - double endFrame = 0; - XmlNode startNode = generatorItemNode.SelectSingleNode("start"); - if (startNode != null) - { - startFrame = double.Parse(startNode.InnerText); - } - - XmlNode endNode = generatorItemNode.SelectSingleNode("end"); - if (endNode != null) - { - endFrame = double.Parse(endNode.InnerText); - } - - string text = string.Empty; - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='str']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - if (valueNode != null) - { - text += valueNode.InnerText; - } - } - if (text.Length == 0) - { - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='str1']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - if (valueNode != null) - { - text += valueNode.InnerText; - } - } - } - if (text.Length == 0) - { - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='str2']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - if (valueNode != null) - { - text += valueNode.InnerText; - } - } - } - if (text.Length == 0) - { - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='sourcetext']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - if (valueNode != null) - { - text += valueNode.InnerText; - } - } - } - if (text.Length == 0) - { - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='text']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - if (valueNode != null) - { - text += valueNode.InnerText; - } - } - } - - bool italic = false; - bool bold = false; - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='style']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - var valueEntries = parameterNode.SelectNodes("valuelist/valueentry"); - if (valueNode != null) - { - int no; - if (int.TryParse(valueNode.InnerText, out no)) - { - no--; - if (no < valueEntries.Count) - { - var styleNameNode = valueEntries[no].SelectSingleNode("name"); - if (styleNameNode != null) - { - string styleName = styleNameNode.InnerText.ToLowerInvariant().Trim(); - italic = styleName == "italic" || styleName == "bold/italic"; - bold = styleName == "bold" || styleName == "bold/italic"; - } - } - } - } - } - if (!bold && !italic) - { - foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='fontstyle']")) - { - XmlNode valueNode = parameterNode.SelectSingleNode("value"); - var valueEntries = parameterNode.SelectNodes("valuelist/valueentry"); - if (valueNode != null) - { - int no; - if (int.TryParse(valueNode.InnerText, out no)) - { - no--; - if (no < valueEntries.Count) - { - var styleNameNode = valueEntries[no].SelectSingleNode("name"); - if (styleNameNode != null) - { - string styleName = styleNameNode.InnerText.ToLowerInvariant().Trim(); - italic = styleName == "italic" || styleName == "bold/italic"; - bold = styleName == "bold" || styleName == "bold/italic"; - } - } - } - } - } - } - - if (text.Length > 0) - { - if (!text.Contains(Environment.NewLine)) - { - text = text.Replace("\r", Environment.NewLine); - } - - if (bold) - { - text = "" + text + ""; - } - - if (italic) - { - text = "" + text + ""; - } - - subtitle.Paragraphs.Add(new Paragraph(text, Convert.ToDouble((startFrame / frameRate) * 1000), Convert.ToDouble((endFrame / frameRate) * 1000))); - } - } - } - catch - { - _errorCount++; - } - } - subtitle.Renumber(); - } - catch - { - _errorCount = 1; - return; - } - Configuration.Settings.General.CurrentFrameRate = frameRate; - } - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + // - Mom, when you were my age what did you want to do? + public class FinalCutProXml : SubtitleFormat + { + public override string Extension => ".xml"; + + public override string Name => "Final Cut Pro Xml"; + + public static string GetFrameRateAsString() + { + if (Configuration.Settings.General.CurrentFrameRate < 24) + { + return "24"; // ntsc 23.976 + } + + if (Configuration.Settings.General.CurrentFrameRate < 25) + { + return "24"; + } + + if (Configuration.Settings.General.CurrentFrameRate < 29) + { + return "25"; + } + + if (Configuration.Settings.General.CurrentFrameRate < 30) + { + return "30"; // ntsc 29.97 + } + + if (Configuration.Settings.General.CurrentFrameRate < 40) + { + return "30"; + } + + if (Configuration.Settings.General.CurrentFrameRate < 60) + { + return "60"; // ntsc 59.94 + } + + return "60"; + } + + public static string GetNtsc() + { + if (Configuration.Settings.General.CurrentFrameRate < 24) + { + return "TRUE"; // ntsc 23.976 + } + + if (Configuration.Settings.General.CurrentFrameRate < 25) + { + return "FALSE"; + } + + return "TRUE"; + } + + public override string ToText(Subtitle subtitle, string title) + { + int duration = 0; + if (subtitle.Paragraphs.Count > 0) + { + duration = (int)Math.Round(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalSeconds * Configuration.Settings.General.CurrentFrameRate); + } + + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + @" 5B3B0C07-9A9D-42AA-872C-C953923F97D8 + add + X + " + duration + @" + + " + GetNtsc() + @" + " + GetFrameRateAsString() + @" + + + + " + GetNtsc() + @" + " + GetFrameRateAsString() + @" + + 00:00:00:00 + 0 + source + NDF + + 0 + " + duration + @" + + + + +"; + + string xmlTrackStructure = + @" + Outline Text + 3000 + + " + GetNtsc() + @" + " + GetFrameRateAsString() + @" + + 1380 + 1474 + 8228 + 8322 + TRUE + FALSE + black + Outline Text1 + + Outline Text + Outline Text + Text + generator + video + + part1 + Text Settings + + + + str + Text + [TEXT] + + + font + Font + [FONTNAME] + + + style + Style + 1 + 4 + + + Plain + 1 + + + Bold + 2 + + + Italic + 3 + + + Bold/Italic + 4 + + + [FONTSTYLE] + + + align + Alignment + 1 + 3 + + + Left + 1 + + + Center + 2 + + + Right + 3 + + + 2 + + + size + Size + 0 + 200 + [FONTSIZE] + + + track + Tracking + 0 + 100 + 1 + + + lead + Leading + -100 + 100 + 0 + + + aspect + Aspect + 0 + 4 + 1 + + + linewidth + Line Width + 0 + 200 + 20 + + + linesoft + Line Softness + 0 + 100 + 5 + + + textopacity + Text Opacity + 0 + 100 + 100 + + + center + Center + + 0.00833333 + 0.390741 + + + + textcolor + Text Color + + 255 + 255 + 255 + 255 + + + + supertext + Text Graphic + + + linecolor + Line Color + + 255 + 0 + 0 + 0 + + + + part2 + Background Settings + + + + xscale + Horizontal Size + 0 + 200 + 0 + + + yscale + Vertical Size + 0 + 200 + 0 + + + xoffset + Horizontal Offset + -100 + 100 + 0 + + + yoffset + Vertical Offset + -100 + 100 + 0 + + + backcolor + Back Color + + 255 + 255 + 255 + 255 + + + + superback + Back Graphic + + + crop + Crop + FALSE + + + autokern + Auto Kerning + TRUE + + + + video + + "; + + if (string.IsNullOrEmpty(title)) + { + title = "Subtitle Edit subtitle"; + } + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + xml.DocumentElement.SelectSingleNode("sequence").Attributes["id"].Value = title; + xml.DocumentElement.SelectSingleNode("sequence/name").InnerText = title; + xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = Guid.NewGuid().ToString().ToUpperInvariant(); + if (!string.IsNullOrEmpty(subtitle.Header)) + { + var header = new XmlDocument(); + try + { + header.LoadXml(subtitle.Header); + var node = header.DocumentElement.SelectSingleNode("sequence/uuid"); + if (node != null) + { + xml.DocumentElement.SelectSingleNode("sequence/uuid").InnerText = node.InnerText; + } + } + catch + { + // ignored + } + } + + XmlNode trackNode = xml.DocumentElement.SelectSingleNode("sequence/media/video/track"); + + const string newLine = "_____@___"; + int number = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode generatorItem = xml.CreateElement("generatoritem"); + string fontStyle = "1"; //1==plain + var s = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont).Trim(); + if ((s.StartsWith("") && s.EndsWith("")) || (s.StartsWith("") && s.EndsWith(""))) + { + fontStyle = "4"; //4==bold/italic + } + else if (s.StartsWith("") && s.EndsWith("")) + { + fontStyle = "3"; //3==italic + } + + generatorItem.InnerXml = xmlTrackStructure.Replace("[NUMBER]", number.ToString()).Replace("[FONTSTYLE]", fontStyle). + Replace("[FONTSIZE]", Configuration.Settings.SubtitleSettings.FcpFontSize.ToString(CultureInfo.InvariantCulture)). + Replace("[FONTNAME]", Configuration.Settings.SubtitleSettings.FcpFontName). + Replace("[NUMBER]", number.ToString(CultureInfo.InvariantCulture)); + + double frameRate = Configuration.Settings.General.CurrentFrameRate; + XmlNode start = generatorItem.SelectSingleNode("generatoritem/start"); + start.InnerText = ((int)Math.Round(p.StartTime.TotalSeconds * frameRate)).ToString(); + + XmlNode end = generatorItem.SelectSingleNode("generatoritem/end"); + end.InnerText = ((int)Math.Round(p.EndTime.TotalSeconds * frameRate)).ToString(); + + XmlNode text = generatorItem.SelectSingleNode("generatoritem/effect/parameter[parameterid='str']/value"); + text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); + text.InnerXml = text.InnerXml.Replace(Environment.NewLine, newLine); + + trackNode.AppendChild(generatorItem.SelectSingleNode("generatoritem")); + number++; + } + + string xmlAsText = ToUtf8XmlString(xml); + xmlAsText = xmlAsText.Replace("xmeml[]", "xmeml"); + xmlAsText = xmlAsText.Replace(newLine, " "); + return xmlAsText; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var frameRate = Configuration.Settings.General.CurrentFrameRate; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(sb.ToString().Trim()); + var header = new XmlDocument { XmlResolver = null }; + header.LoadXml(sb.ToString()); + if (header.SelectSingleNode("sequence/media/video/track") != null) + { + header.RemoveChild(header.SelectSingleNode("sequence/media/video/track")); + } + + subtitle.Header = header.OuterXml; + + if (xml.DocumentElement.SelectSingleNode("sequence/rate") != null && xml.DocumentElement.SelectSingleNode("sequence/rate/timebase") != null) + { + try + { + frameRate = double.Parse(xml.DocumentElement.SelectSingleNode("sequence/rate/timebase").InnerText); + } + catch + { + frameRate = Configuration.Settings.General.CurrentFrameRate; + } + } + + foreach (XmlNode node in xml.SelectNodes("//video/track")) + { + try + { + foreach (XmlNode generatorItemNode in node.SelectNodes("generatoritem")) + { + XmlNode rate = generatorItemNode.SelectSingleNode("rate"); + if (rate != null) + { + XmlNode timebase = rate.SelectSingleNode("timebase"); + if (timebase != null) + { + frameRate = double.Parse(timebase.InnerText); + } + } + + double startFrame = 0; + double endFrame = 0; + XmlNode startNode = generatorItemNode.SelectSingleNode("start"); + if (startNode != null) + { + startFrame = double.Parse(startNode.InnerText); + } + + XmlNode endNode = generatorItemNode.SelectSingleNode("end"); + if (endNode != null) + { + endFrame = double.Parse(endNode.InnerText); + } + + string text = string.Empty; + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='str']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + if (valueNode != null) + { + text += valueNode.InnerText; + } + } + if (text.Length == 0) + { + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='str1']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + if (valueNode != null) + { + text += valueNode.InnerText; + } + } + } + if (text.Length == 0) + { + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='str2']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + if (valueNode != null) + { + text += valueNode.InnerText; + } + } + } + if (text.Length == 0) + { + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='sourcetext']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + if (valueNode != null) + { + text += valueNode.InnerText; + } + } + } + if (text.Length == 0) + { + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='text']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + if (valueNode != null) + { + text += valueNode.InnerText; + } + } + } + + bool italic = false; + bool bold = false; + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='style']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + var valueEntries = parameterNode.SelectNodes("valuelist/valueentry"); + if (valueNode != null) + { + int no; + if (int.TryParse(valueNode.InnerText, out no)) + { + no--; + if (no < valueEntries.Count) + { + var styleNameNode = valueEntries[no].SelectSingleNode("name"); + if (styleNameNode != null) + { + string styleName = styleNameNode.InnerText.ToLowerInvariant().Trim(); + italic = styleName == "italic" || styleName == "bold/italic"; + bold = styleName == "bold" || styleName == "bold/italic"; + } + } + } + } + } + if (!bold && !italic) + { + foreach (XmlNode parameterNode in generatorItemNode.SelectNodes("effect/parameter[parameterid='fontstyle']")) + { + XmlNode valueNode = parameterNode.SelectSingleNode("value"); + var valueEntries = parameterNode.SelectNodes("valuelist/valueentry"); + if (valueNode != null) + { + int no; + if (int.TryParse(valueNode.InnerText, out no)) + { + no--; + if (no < valueEntries.Count) + { + var styleNameNode = valueEntries[no].SelectSingleNode("name"); + if (styleNameNode != null) + { + string styleName = styleNameNode.InnerText.ToLowerInvariant().Trim(); + italic = styleName == "italic" || styleName == "bold/italic"; + bold = styleName == "bold" || styleName == "bold/italic"; + } + } + } + } + } + } + + if (text.Length > 0) + { + if (!text.Contains(Environment.NewLine)) + { + text = text.Replace("\r", Environment.NewLine); + } + + if (bold) + { + text = "" + text + ""; + } + + if (italic) + { + text = "" + text + ""; + } + + subtitle.Paragraphs.Add(new Paragraph(text, Convert.ToDouble((startFrame / frameRate) * 1000), Convert.ToDouble((endFrame / frameRate) * 1000))); + } + } + } + catch + { + _errorCount++; + } + } + subtitle.Renumber(); + } + catch + { + _errorCount = 1; + return; + } + Configuration.Settings.General.CurrentFrameRate = frameRate; + } + } +} diff --git a/libse/SubtitleFormats/FinalCutProXml13.cs b/src/libse/SubtitleFormats/FinalCutProXml13.cs similarity index 97% rename from libse/SubtitleFormats/FinalCutProXml13.cs rename to src/libse/SubtitleFormats/FinalCutProXml13.cs index f148c15a1..888af8a17 100644 --- a/libse/SubtitleFormats/FinalCutProXml13.cs +++ b/src/libse/SubtitleFormats/FinalCutProXml13.cs @@ -1,200 +1,200 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class FinalCutProXml13 : SubtitleFormat - { - public double FrameRate { get; set; } - - public override string Extension => ".fcpxml"; - - public override string Name => "Final Cut Pro Xml 1.3"; - - public override string ToText(Subtitle subtitle, string title) - { - if (Configuration.Settings.General.CurrentFrameRate > 26) - { - FrameRate = 30; - } - else - { - FrameRate = 25; - } - - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - Environment.NewLine + - "" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - ""; - - string xmlClipStructure = - " "; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - XmlNode videoNode = xml.DocumentElement.SelectSingleNode("project/sequence/spine"); - - int number = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode clip = xml.CreateElement("clip"); - clip.InnerXml = xmlClipStructure; - var attr = xml.CreateAttribute("name"); - attr.Value = title; - clip.Attributes.Append(attr); - - attr = xml.CreateAttribute("duration"); - attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s"; - clip.Attributes.Append(attr); - - attr = xml.CreateAttribute("start"); - attr.Value = Convert.ToInt64(p.StartTime.TotalSeconds * 2400000) + "/2400000s"; - clip.Attributes.Append(attr); - - attr = xml.CreateAttribute("audioStart"); - attr.Value = "0s"; - clip.Attributes.Append(attr); - - attr = xml.CreateAttribute("audioDuration"); - attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s"; - clip.Attributes.Append(attr); - - attr = xml.CreateAttribute("tcFormat"); - attr.Value = "NDF"; - clip.Attributes.Append(attr); - - XmlNode titleNode = clip.SelectSingleNode("video"); - titleNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s"; - titleNode.Attributes["name"].Value = HtmlUtil.RemoveHtmlTags(p.Text); - titleNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds * 60000) + "/60000s"; - titleNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s"; - - XmlNode param = clip.SelectSingleNode("video/param"); - param.Attributes["value"].InnerText = HtmlUtil.RemoveHtmlTags(p.Text); - - videoNode.AppendChild(clip); - number++; - } - - string xmlAsText = ToUtf8XmlString(xml); - xmlAsText = xmlAsText.Replace("fcpxml[]", "fcpxml"); - xmlAsText = xmlAsText.Replace("fcpxml []", "fcpxml"); - return xmlAsText; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - FrameRate = Configuration.Settings.General.CurrentFrameRate; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - string x = sb.ToString(); - if (!x.Contains(" 0) - { - var prev = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1]; - if (prev.Text == p.Text && prev.StartTime.TotalMilliseconds == p.StartTime.TotalMilliseconds) - { - add = false; - } - } - if (add) - { - subtitle.Paragraphs.Add(p); - } - } - catch - { - _errorCount++; - } - } - } - subtitle.Renumber(); - } - catch (Exception exception) - { - System.Diagnostics.Debug.WriteLine(exception.Message); - _errorCount = 1; - } - } - - private static TimeCode DecodeTime(XmlAttribute duration) - { - // 220220/60000s - if (duration != null) - { - var arr = duration.Value.TrimEnd('s').Split('/'); - if (arr.Length == 2) - { - return TimeCode.FromSeconds(long.Parse(arr[0]) / double.Parse(arr[1])); - } - else if (arr.Length == 1) - { - return TimeCode.FromSeconds(float.Parse(arr[0])); - } - } - return new TimeCode(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class FinalCutProXml13 : SubtitleFormat + { + public double FrameRate { get; set; } + + public override string Extension => ".fcpxml"; + + public override string Name => "Final Cut Pro Xml 1.3"; + + public override string ToText(Subtitle subtitle, string title) + { + if (Configuration.Settings.General.CurrentFrameRate > 26) + { + FrameRate = 30; + } + else + { + FrameRate = 25; + } + + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + Environment.NewLine + + "" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + ""; + + string xmlClipStructure = + " "; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + XmlNode videoNode = xml.DocumentElement.SelectSingleNode("project/sequence/spine"); + + int number = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode clip = xml.CreateElement("clip"); + clip.InnerXml = xmlClipStructure; + var attr = xml.CreateAttribute("name"); + attr.Value = title; + clip.Attributes.Append(attr); + + attr = xml.CreateAttribute("duration"); + attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s"; + clip.Attributes.Append(attr); + + attr = xml.CreateAttribute("start"); + attr.Value = Convert.ToInt64(p.StartTime.TotalSeconds * 2400000) + "/2400000s"; + clip.Attributes.Append(attr); + + attr = xml.CreateAttribute("audioStart"); + attr.Value = "0s"; + clip.Attributes.Append(attr); + + attr = xml.CreateAttribute("audioDuration"); + attr.Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s"; + clip.Attributes.Append(attr); + + attr = xml.CreateAttribute("tcFormat"); + attr.Value = "NDF"; + clip.Attributes.Append(attr); + + XmlNode titleNode = clip.SelectSingleNode("video"); + titleNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s"; + titleNode.Attributes["name"].Value = HtmlUtil.RemoveHtmlTags(p.Text); + titleNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds * 60000) + "/60000s"; + titleNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s"; + + XmlNode param = clip.SelectSingleNode("video/param"); + param.Attributes["value"].InnerText = HtmlUtil.RemoveHtmlTags(p.Text); + + videoNode.AppendChild(clip); + number++; + } + + string xmlAsText = ToUtf8XmlString(xml); + xmlAsText = xmlAsText.Replace("fcpxml[]", "fcpxml"); + xmlAsText = xmlAsText.Replace("fcpxml []", "fcpxml"); + return xmlAsText; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + FrameRate = Configuration.Settings.General.CurrentFrameRate; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + string x = sb.ToString(); + if (!x.Contains(" 0) + { + var prev = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1]; + if (prev.Text == p.Text && prev.StartTime.TotalMilliseconds == p.StartTime.TotalMilliseconds) + { + add = false; + } + } + if (add) + { + subtitle.Paragraphs.Add(p); + } + } + catch + { + _errorCount++; + } + } + } + subtitle.Renumber(); + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception.Message); + _errorCount = 1; + } + } + + private static TimeCode DecodeTime(XmlAttribute duration) + { + // 220220/60000s + if (duration != null) + { + var arr = duration.Value.TrimEnd('s').Split('/'); + if (arr.Length == 2) + { + return TimeCode.FromSeconds(long.Parse(arr[0]) / double.Parse(arr[1])); + } + else if (arr.Length == 1) + { + return TimeCode.FromSeconds(float.Parse(arr[0])); + } + } + return new TimeCode(); + } + + } +} diff --git a/libse/SubtitleFormats/FinalCutProXml14.cs b/src/libse/SubtitleFormats/FinalCutProXml14.cs similarity index 98% rename from libse/SubtitleFormats/FinalCutProXml14.cs rename to src/libse/SubtitleFormats/FinalCutProXml14.cs index c2b507cc7..4d233d805 100644 --- a/libse/SubtitleFormats/FinalCutProXml14.cs +++ b/src/libse/SubtitleFormats/FinalCutProXml14.cs @@ -1,188 +1,188 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class FinalCutProXml14 : SubtitleFormat - { - public double FrameRate { get; set; } - - public override string Extension => ".fcpxml"; - - public override string Name => "Final Cut Pro Xml 1.4"; - - public override string ToText(Subtitle subtitle, string title) - { - if (Configuration.Settings.General.CurrentFrameRate > 26) - { - FrameRate = 30; - } - else - { - FrameRate = 25; - } - - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - Environment.NewLine + - "" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " Apple ProRes 422 Proxy" + Environment.NewLine + - " Linear PCM" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + // From here down I am unsure how it should be - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - ""; - - string xmlClipStructure = - " "; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - XmlNode videoNode = xml.DocumentElement.SelectSingleNode("//project/sequence/spine/clip"); - int number = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode video = xml.CreateElement("video"); - video.InnerXml = xmlClipStructure; - - XmlNode generatorNode = video.SelectSingleNode("video"); - generatorNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 2400000) + "/2400000s"; - generatorNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s"; - generatorNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 2400000) + "/2400000s"; - - XmlNode param = video.SelectSingleNode("video/param"); - param.Attributes["value"].InnerText = HtmlUtil.RemoveHtmlTags(p.Text); - - videoNode.AppendChild(generatorNode); - number++; - } - - string xmlAsText = ToUtf8XmlString(xml); - xmlAsText = xmlAsText.Replace("fcpxml[]", "fcpxml"); - xmlAsText = xmlAsText.Replace("fcpxml []", "fcpxml"); - return xmlAsText; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - FrameRate = Configuration.Settings.General.CurrentFrameRate; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - string x = sb.ToString(); - if (!x.Contains("") && !x.Contains("")) - { - return; - } - - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(x.Trim()); - - foreach (XmlNode node in xml.SelectNodes("//project/sequence/spine/clip/video/param[@name='Text']")) - { - try - { - string text = node.Attributes["value"].InnerText; - Paragraph p = new Paragraph(); - p.Text = text.Trim(); - p.StartTime = DecodeTime(node.ParentNode.Attributes["offset"]); - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + DecodeTime(node.ParentNode.Attributes["duration"]).TotalMilliseconds; - subtitle.Paragraphs.Add(p); - } - catch - { - _errorCount++; - } - } - - if (subtitle.Paragraphs.Count == 0) - { - foreach (XmlNode node in xml.SelectNodes("//project/sequence/spine/clip/video/title/text")) - { - try - { - string text = node.ParentNode.InnerText; - Paragraph p = new Paragraph(); - p.Text = text.Trim(); - p.StartTime = DecodeTime(node.ParentNode.Attributes["offset"]); - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + DecodeTime(node.ParentNode.Attributes["duration"]).TotalMilliseconds; - bool add = true; - if (subtitle.Paragraphs.Count > 0) - { - var prev = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1]; - if (prev.Text == p.Text && Math.Abs(prev.StartTime.TotalMilliseconds - p.StartTime.TotalMilliseconds) < 0.01) - { - add = false; - } - } - if (add) - { - subtitle.Paragraphs.Add(p); - } - } - catch - { - _errorCount++; - } - } - } - subtitle.Renumber(); - } - catch - { - _errorCount = 1; - } - } - - private static TimeCode DecodeTime(XmlAttribute duration) - { - // 220220/60000s - if (duration != null) - { - var arr = duration.Value.TrimEnd('s').Split('/'); - if (arr.Length == 2) - { - return TimeCode.FromSeconds(long.Parse(arr[0]) / double.Parse(arr[1])); - } - else if (arr.Length == 1) - { - return TimeCode.FromSeconds(float.Parse(arr[0])); - } - } - return new TimeCode(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class FinalCutProXml14 : SubtitleFormat + { + public double FrameRate { get; set; } + + public override string Extension => ".fcpxml"; + + public override string Name => "Final Cut Pro Xml 1.4"; + + public override string ToText(Subtitle subtitle, string title) + { + if (Configuration.Settings.General.CurrentFrameRate > 26) + { + FrameRate = 30; + } + else + { + FrameRate = 25; + } + + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + Environment.NewLine + + "" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " Apple ProRes 422 Proxy" + Environment.NewLine + + " Linear PCM" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + // From here down I am unsure how it should be + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + ""; + + string xmlClipStructure = + " "; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + XmlNode videoNode = xml.DocumentElement.SelectSingleNode("//project/sequence/spine/clip"); + int number = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode video = xml.CreateElement("video"); + video.InnerXml = xmlClipStructure; + + XmlNode generatorNode = video.SelectSingleNode("video"); + generatorNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 2400000) + "/2400000s"; + generatorNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds * 2400000) + "/2400000s"; + generatorNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 2400000) + "/2400000s"; + + XmlNode param = video.SelectSingleNode("video/param"); + param.Attributes["value"].InnerText = HtmlUtil.RemoveHtmlTags(p.Text); + + videoNode.AppendChild(generatorNode); + number++; + } + + string xmlAsText = ToUtf8XmlString(xml); + xmlAsText = xmlAsText.Replace("fcpxml[]", "fcpxml"); + xmlAsText = xmlAsText.Replace("fcpxml []", "fcpxml"); + return xmlAsText; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + FrameRate = Configuration.Settings.General.CurrentFrameRate; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + string x = sb.ToString(); + if (!x.Contains("") && !x.Contains("")) + { + return; + } + + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(x.Trim()); + + foreach (XmlNode node in xml.SelectNodes("//project/sequence/spine/clip/video/param[@name='Text']")) + { + try + { + string text = node.Attributes["value"].InnerText; + Paragraph p = new Paragraph(); + p.Text = text.Trim(); + p.StartTime = DecodeTime(node.ParentNode.Attributes["offset"]); + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + DecodeTime(node.ParentNode.Attributes["duration"]).TotalMilliseconds; + subtitle.Paragraphs.Add(p); + } + catch + { + _errorCount++; + } + } + + if (subtitle.Paragraphs.Count == 0) + { + foreach (XmlNode node in xml.SelectNodes("//project/sequence/spine/clip/video/title/text")) + { + try + { + string text = node.ParentNode.InnerText; + Paragraph p = new Paragraph(); + p.Text = text.Trim(); + p.StartTime = DecodeTime(node.ParentNode.Attributes["offset"]); + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + DecodeTime(node.ParentNode.Attributes["duration"]).TotalMilliseconds; + bool add = true; + if (subtitle.Paragraphs.Count > 0) + { + var prev = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1]; + if (prev.Text == p.Text && Math.Abs(prev.StartTime.TotalMilliseconds - p.StartTime.TotalMilliseconds) < 0.01) + { + add = false; + } + } + if (add) + { + subtitle.Paragraphs.Add(p); + } + } + catch + { + _errorCount++; + } + } + } + subtitle.Renumber(); + } + catch + { + _errorCount = 1; + } + } + + private static TimeCode DecodeTime(XmlAttribute duration) + { + // 220220/60000s + if (duration != null) + { + var arr = duration.Value.TrimEnd('s').Split('/'); + if (arr.Length == 2) + { + return TimeCode.FromSeconds(long.Parse(arr[0]) / double.Parse(arr[1])); + } + else if (arr.Length == 1) + { + return TimeCode.FromSeconds(float.Parse(arr[0])); + } + } + return new TimeCode(); + } + + } +} diff --git a/libse/SubtitleFormats/FinalCutProXml14Text.cs b/src/libse/SubtitleFormats/FinalCutProXml14Text.cs similarity index 97% rename from libse/SubtitleFormats/FinalCutProXml14Text.cs rename to src/libse/SubtitleFormats/FinalCutProXml14Text.cs index 4bd5a3fb3..73f89b5dc 100644 --- a/libse/SubtitleFormats/FinalCutProXml14Text.cs +++ b/src/libse/SubtitleFormats/FinalCutProXml14Text.cs @@ -1,209 +1,209 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class FinalCutProXml14Text : SubtitleFormat - { - public double FrameRate { get; set; } - - public override string Extension => ".fcpxml"; - - public override string Name => "Final Cut Pro Xml 1.4 Text"; - - public override string ToText(Subtitle subtitle, string title) - { - if (Configuration.Settings.General.CurrentFrameRate > 26) - { - FrameRate = 30; - } - else - { - FrameRate = 25; - } - - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - Environment.NewLine + - "" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - ""; - - string xmlClipStructure = - "" + Environment.NewLine + - " <param name=\"Position\" key=\"9999/999166631/999166633/1/100/101\" value=\"-1.67499 -470.934\"/>" + Environment.NewLine + - " <text>" + Environment.NewLine + - " <text-style ref=\"ts[NUMBER]\">THE NOISEMAKER</text-style>" + Environment.NewLine + - " </text>" + Environment.NewLine + - " <text-style-def id=\"ts[NUMBER]\">" + Environment.NewLine + - " <text-style font=\"Lucida Grande\" fontSize=\"36\" fontFace=\"Regular\" fontColor=\"0.793266 0.793391 0.793221 1\" baseline=\"29\" shadowColor=\"0 0 0 1\" shadowOffset=\"5 315\" alignment=\"center\"/>" + Environment.NewLine + - " </text-style-def>" + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - XmlNode videoNode = xml.DocumentElement.SelectSingleNode("//project/sequence/spine/gap"); - int number = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode video = xml.CreateElement("video"); - var trimmedTitle = new StringBuilder(); - foreach (var ch in HtmlUtil.RemoveHtmlTags(p.Text, true)) - { - if (CharUtils.IsEnglishAlphabet(ch) || char.IsDigit(ch)) - { - trimmedTitle.Append(ch); - } - } - string temp = xmlClipStructure.Replace("[NUMBER]", number.ToString(CultureInfo.InvariantCulture)).Replace("[TITLEID]", trimmedTitle.ToString()); - video.InnerXml = temp; - - XmlNode generatorNode = video.SelectSingleNode("title"); - if (IsNearleWholeNumber(p.StartTime.TotalSeconds)) - { - generatorNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds) + "s"; - } - else - { - generatorNode.Attributes["offset"].Value = FinalCutProXml15.GetFrameTime(p.StartTime); - } - - if (IsNearleWholeNumber(p.Duration.TotalSeconds)) - { - generatorNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds) + "s"; - } - else - { - generatorNode.Attributes["duration"].Value = FinalCutProXml15.GetFrameTime(p.Duration); - } - - if (IsNearleWholeNumber(p.StartTime.TotalSeconds)) - { - generatorNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds) + "s"; - } - else - { - generatorNode.Attributes["start"].Value = FinalCutProXml15.GetFrameTime(p.StartTime); - } - - XmlNode param = video.SelectSingleNode("title/text/text-style"); - param.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); - - videoNode.AppendChild(generatorNode); - number++; - } - - string xmlAsText = ToUtf8XmlString(xml); - xmlAsText = xmlAsText.Replace("fcpxml[]", "fcpxml"); - xmlAsText = xmlAsText.Replace("fcpxml []", "fcpxml"); - return xmlAsText; - } - - private static bool IsNearleWholeNumber(double number) - { - double rest = number - Convert.ToInt64(number); - return rest < 0.001; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - FrameRate = Configuration.Settings.General.CurrentFrameRate; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - string x = sb.ToString(); - if (!x.Contains("")) - { - return; - } - - var xml = new XmlDocument(); - try - { - xml.LoadXml(x.Trim()); - - if (subtitle.Paragraphs.Count == 0) - { - var textNodes = xml.SelectNodes("//project/sequence/spine/title/text"); - if (textNodes.Count == 0) - { - textNodes = xml.SelectNodes("//project/sequence/spine/gap/title/text"); - } - foreach (XmlNode node in textNodes) - { - try - { - string text = node.ParentNode.InnerText; - var p = new Paragraph(); - p.Text = text.Trim(); - p.StartTime = DecodeTime(node.ParentNode.Attributes["offset"]); - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + DecodeTime(node.ParentNode.Attributes["duration"]).TotalMilliseconds; - bool add = true; - if (subtitle.Paragraphs.Count > 0) - { - var prev = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1]; - if (prev.Text == p.Text && prev.StartTime.TotalMilliseconds == p.StartTime.TotalMilliseconds) - { - add = false; - } - } - if (add) - { - subtitle.Paragraphs.Add(p); - } - } - catch - { - _errorCount++; - } - } - } - subtitle.Renumber(); - } - catch - { - _errorCount = 1; - } - } - - private static TimeCode DecodeTime(XmlAttribute duration) - { - // 220220/60000s - if (duration != null) - { - var arr = duration.Value.TrimEnd('s').Split('/'); - if (arr.Length == 2) - { - return TimeCode.FromSeconds(long.Parse(arr[0]) / double.Parse(arr[1])); - } - if (arr.Length == 1) - { - return TimeCode.FromSeconds(float.Parse(arr[0])); - } - } - return new TimeCode(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class FinalCutProXml14Text : SubtitleFormat + { + public double FrameRate { get; set; } + + public override string Extension => ".fcpxml"; + + public override string Name => "Final Cut Pro Xml 1.4 Text"; + + public override string ToText(Subtitle subtitle, string title) + { + if (Configuration.Settings.General.CurrentFrameRate > 26) + { + FrameRate = 30; + } + else + { + FrameRate = 25; + } + + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + Environment.NewLine + + "" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + ""; + + string xmlClipStructure = + "" + Environment.NewLine + + " <param name=\"Position\" key=\"9999/999166631/999166633/1/100/101\" value=\"-1.67499 -470.934\"/>" + Environment.NewLine + + " <text>" + Environment.NewLine + + " <text-style ref=\"ts[NUMBER]\">THE NOISEMAKER</text-style>" + Environment.NewLine + + " </text>" + Environment.NewLine + + " <text-style-def id=\"ts[NUMBER]\">" + Environment.NewLine + + " <text-style font=\"Lucida Grande\" fontSize=\"36\" fontFace=\"Regular\" fontColor=\"0.793266 0.793391 0.793221 1\" baseline=\"29\" shadowColor=\"0 0 0 1\" shadowOffset=\"5 315\" alignment=\"center\"/>" + Environment.NewLine + + " </text-style-def>" + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + XmlNode videoNode = xml.DocumentElement.SelectSingleNode("//project/sequence/spine/gap"); + int number = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode video = xml.CreateElement("video"); + var trimmedTitle = new StringBuilder(); + foreach (var ch in HtmlUtil.RemoveHtmlTags(p.Text, true)) + { + if (CharUtils.IsEnglishAlphabet(ch) || char.IsDigit(ch)) + { + trimmedTitle.Append(ch); + } + } + string temp = xmlClipStructure.Replace("[NUMBER]", number.ToString(CultureInfo.InvariantCulture)).Replace("[TITLEID]", trimmedTitle.ToString()); + video.InnerXml = temp; + + XmlNode generatorNode = video.SelectSingleNode("title"); + if (IsNearleWholeNumber(p.StartTime.TotalSeconds)) + { + generatorNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds) + "s"; + } + else + { + generatorNode.Attributes["offset"].Value = FinalCutProXml15.GetFrameTime(p.StartTime); + } + + if (IsNearleWholeNumber(p.Duration.TotalSeconds)) + { + generatorNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds) + "s"; + } + else + { + generatorNode.Attributes["duration"].Value = FinalCutProXml15.GetFrameTime(p.Duration); + } + + if (IsNearleWholeNumber(p.StartTime.TotalSeconds)) + { + generatorNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds) + "s"; + } + else + { + generatorNode.Attributes["start"].Value = FinalCutProXml15.GetFrameTime(p.StartTime); + } + + XmlNode param = video.SelectSingleNode("title/text/text-style"); + param.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); + + videoNode.AppendChild(generatorNode); + number++; + } + + string xmlAsText = ToUtf8XmlString(xml); + xmlAsText = xmlAsText.Replace("fcpxml[]", "fcpxml"); + xmlAsText = xmlAsText.Replace("fcpxml []", "fcpxml"); + return xmlAsText; + } + + private static bool IsNearleWholeNumber(double number) + { + double rest = number - Convert.ToInt64(number); + return rest < 0.001; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + FrameRate = Configuration.Settings.General.CurrentFrameRate; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + string x = sb.ToString(); + if (!x.Contains("")) + { + return; + } + + var xml = new XmlDocument(); + try + { + xml.LoadXml(x.Trim()); + + if (subtitle.Paragraphs.Count == 0) + { + var textNodes = xml.SelectNodes("//project/sequence/spine/title/text"); + if (textNodes.Count == 0) + { + textNodes = xml.SelectNodes("//project/sequence/spine/gap/title/text"); + } + foreach (XmlNode node in textNodes) + { + try + { + string text = node.ParentNode.InnerText; + var p = new Paragraph(); + p.Text = text.Trim(); + p.StartTime = DecodeTime(node.ParentNode.Attributes["offset"]); + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + DecodeTime(node.ParentNode.Attributes["duration"]).TotalMilliseconds; + bool add = true; + if (subtitle.Paragraphs.Count > 0) + { + var prev = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1]; + if (prev.Text == p.Text && prev.StartTime.TotalMilliseconds == p.StartTime.TotalMilliseconds) + { + add = false; + } + } + if (add) + { + subtitle.Paragraphs.Add(p); + } + } + catch + { + _errorCount++; + } + } + } + subtitle.Renumber(); + } + catch + { + _errorCount = 1; + } + } + + private static TimeCode DecodeTime(XmlAttribute duration) + { + // 220220/60000s + if (duration != null) + { + var arr = duration.Value.TrimEnd('s').Split('/'); + if (arr.Length == 2) + { + return TimeCode.FromSeconds(long.Parse(arr[0]) / double.Parse(arr[1])); + } + if (arr.Length == 1) + { + return TimeCode.FromSeconds(float.Parse(arr[0])); + } + } + return new TimeCode(); + } + + } +} diff --git a/libse/SubtitleFormats/FinalCutProXml15.cs b/src/libse/SubtitleFormats/FinalCutProXml15.cs similarity index 100% rename from libse/SubtitleFormats/FinalCutProXml15.cs rename to src/libse/SubtitleFormats/FinalCutProXml15.cs diff --git a/libse/SubtitleFormats/FinalCutProXml16.cs b/src/libse/SubtitleFormats/FinalCutProXml16.cs similarity index 100% rename from libse/SubtitleFormats/FinalCutProXml16.cs rename to src/libse/SubtitleFormats/FinalCutProXml16.cs diff --git a/libse/SubtitleFormats/FinalCutProXml17.cs b/src/libse/SubtitleFormats/FinalCutProXml17.cs similarity index 100% rename from libse/SubtitleFormats/FinalCutProXml17.cs rename to src/libse/SubtitleFormats/FinalCutProXml17.cs diff --git a/libse/SubtitleFormats/FinalCutProXml18.cs b/src/libse/SubtitleFormats/FinalCutProXml18.cs similarity index 100% rename from libse/SubtitleFormats/FinalCutProXml18.cs rename to src/libse/SubtitleFormats/FinalCutProXml18.cs diff --git a/libse/SubtitleFormats/FinalCutProXmlGap.cs b/src/libse/SubtitleFormats/FinalCutProXmlGap.cs similarity index 98% rename from libse/SubtitleFormats/FinalCutProXmlGap.cs rename to src/libse/SubtitleFormats/FinalCutProXmlGap.cs index 8f53f125c..9372fd441 100644 --- a/libse/SubtitleFormats/FinalCutProXmlGap.cs +++ b/src/libse/SubtitleFormats/FinalCutProXmlGap.cs @@ -1,149 +1,149 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class FinalCutProXmlGap : SubtitleFormat - { - public double FrameRate { get; set; } - - public override string Extension => ".fcpxml"; - - public override string Name => "Final Cut Xml Gap"; - - public override string ToText(Subtitle subtitle, string title) - { - if (Configuration.Settings.General.CurrentFrameRate > 26) - { - FrameRate = 30; - } - else - { - FrameRate = 25; - } - - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - Environment.NewLine + - "" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - // - // - // - // - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - ""; - - string xmlClipStructure = - " " + Environment.NewLine + - " <adjust-transform position=\"0.267518 -32.3158\"/>" + Environment.NewLine + - " <text></text>" + Environment.NewLine + - " "; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - XmlNode videoNode = xml.DocumentElement.SelectSingleNode("project/sequence/spine/gap"); - - int number = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode titleNode = xml.CreateElement("holder"); - titleNode.InnerXml = xmlClipStructure; - titleNode = titleNode.SelectSingleNode("title"); - titleNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s"; - titleNode.Attributes["name"].Value = HtmlUtil.RemoveHtmlTags(p.Text); - titleNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds * 60000) + "/60000s"; - titleNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s"; - titleNode.SelectSingleNode("text").InnerText = HtmlUtil.RemoveHtmlTags(p.Text); - videoNode.AppendChild(titleNode); - number++; - } - - string xmlAsText = ToUtf8XmlString(xml); - xmlAsText = xmlAsText.Replace("fcpxml[]", "fcpxml"); - xmlAsText = xmlAsText.Replace("fcpxml []", "fcpxml"); - return xmlAsText; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - FrameRate = Configuration.Settings.General.CurrentFrameRate; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(sb.ToString().Trim()); - - foreach (XmlNode node in xml.SelectNodes("fcpxml/project/sequence/spine/gap")) - { - try - { - foreach (XmlNode title in node.SelectNodes("title")) - { - var textNodes = title.SelectNodes("text"); - if (textNodes != null && textNodes.Count > 0) - { - var p = new Paragraph(); - p.StartTime = DecodeTime(title.Attributes["offset"]); - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + DecodeTime(title.Attributes["duration"]).TotalMilliseconds; - var text = new StringBuilder(); - foreach (XmlNode textNode in textNodes) - { - text.AppendLine(textNode.InnerText); - } - p.Text = text.ToString().Trim(); - subtitle.Paragraphs.Add(p); - } - } - } - catch - { - _errorCount++; - } - } - subtitle.Renumber(); - } - catch - { - _errorCount = 1; - } - } - - private static TimeCode DecodeTime(XmlAttribute duration) - { - // 220220/60000s - if (duration != null) - { - var arr = duration.Value.TrimEnd('s').Split('/'); - if (arr.Length == 2) - { - return TimeCode.FromSeconds(long.Parse(arr[0]) / double.Parse(arr[1])); - } - - if (arr.Length == 1) - { - return TimeCode.FromSeconds(float.Parse(arr[0])); - } - } - return new TimeCode(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class FinalCutProXmlGap : SubtitleFormat + { + public double FrameRate { get; set; } + + public override string Extension => ".fcpxml"; + + public override string Name => "Final Cut Xml Gap"; + + public override string ToText(Subtitle subtitle, string title) + { + if (Configuration.Settings.General.CurrentFrameRate > 26) + { + FrameRate = 30; + } + else + { + FrameRate = 25; + } + + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + Environment.NewLine + + "" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + // + // + // + // + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + ""; + + string xmlClipStructure = + " " + Environment.NewLine + + " <adjust-transform position=\"0.267518 -32.3158\"/>" + Environment.NewLine + + " <text></text>" + Environment.NewLine + + " "; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + XmlNode videoNode = xml.DocumentElement.SelectSingleNode("project/sequence/spine/gap"); + + int number = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode titleNode = xml.CreateElement("holder"); + titleNode.InnerXml = xmlClipStructure; + titleNode = titleNode.SelectSingleNode("title"); + titleNode.Attributes["offset"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s"; + titleNode.Attributes["name"].Value = HtmlUtil.RemoveHtmlTags(p.Text); + titleNode.Attributes["duration"].Value = Convert.ToInt64(p.Duration.TotalSeconds * 60000) + "/60000s"; + titleNode.Attributes["start"].Value = Convert.ToInt64(p.StartTime.TotalSeconds * 60000) + "/60000s"; + titleNode.SelectSingleNode("text").InnerText = HtmlUtil.RemoveHtmlTags(p.Text); + videoNode.AppendChild(titleNode); + number++; + } + + string xmlAsText = ToUtf8XmlString(xml); + xmlAsText = xmlAsText.Replace("fcpxml[]", "fcpxml"); + xmlAsText = xmlAsText.Replace("fcpxml []", "fcpxml"); + return xmlAsText; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + FrameRate = Configuration.Settings.General.CurrentFrameRate; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(sb.ToString().Trim()); + + foreach (XmlNode node in xml.SelectNodes("fcpxml/project/sequence/spine/gap")) + { + try + { + foreach (XmlNode title in node.SelectNodes("title")) + { + var textNodes = title.SelectNodes("text"); + if (textNodes != null && textNodes.Count > 0) + { + var p = new Paragraph(); + p.StartTime = DecodeTime(title.Attributes["offset"]); + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + DecodeTime(title.Attributes["duration"]).TotalMilliseconds; + var text = new StringBuilder(); + foreach (XmlNode textNode in textNodes) + { + text.AppendLine(textNode.InnerText); + } + p.Text = text.ToString().Trim(); + subtitle.Paragraphs.Add(p); + } + } + } + catch + { + _errorCount++; + } + } + subtitle.Renumber(); + } + catch + { + _errorCount = 1; + } + } + + private static TimeCode DecodeTime(XmlAttribute duration) + { + // 220220/60000s + if (duration != null) + { + var arr = duration.Value.TrimEnd('s').Split('/'); + if (arr.Length == 2) + { + return TimeCode.FromSeconds(long.Parse(arr[0]) / double.Parse(arr[1])); + } + + if (arr.Length == 1) + { + return TimeCode.FromSeconds(float.Parse(arr[0])); + } + } + return new TimeCode(); + } + + } +} diff --git a/libse/SubtitleFormats/FinalDraftTemplate2.cs b/src/libse/SubtitleFormats/FinalDraftTemplate2.cs similarity index 100% rename from libse/SubtitleFormats/FinalDraftTemplate2.cs rename to src/libse/SubtitleFormats/FinalDraftTemplate2.cs diff --git a/libse/SubtitleFormats/FlashXml.cs b/src/libse/SubtitleFormats/FlashXml.cs similarity index 97% rename from libse/SubtitleFormats/FlashXml.cs rename to src/libse/SubtitleFormats/FlashXml.cs index 96f1a02e9..d0dc7ae84 100644 --- a/libse/SubtitleFormats/FlashXml.cs +++ b/src/libse/SubtitleFormats/FlashXml.cs @@ -1,176 +1,176 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - - // - // - //
- //

This is fully skinnable through XML
using external images for each button]]>

- //

You can put in any order or enable/disable
the control buttons]]>

- //

Test below some of the customizable
properties this player has]]>

- //

Many other properties related to fonts, sizes, colors
and list properties are in style.css file]]>

- //
- //
- public class FlashXml : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "Flash Xml"; - - public override bool IsMine(List lines, string fileName) - { - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - string xmlAsString = sb.ToString().Trim(); - if ((xmlAsString.Contains("") || xmlAsString.Contains(""))) - { - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(xmlAsString); - var paragraphs = xml.DocumentElement.SelectNodes("div/p"); - return paragraphs != null && paragraphs.Count > 0 && xml.DocumentElement.Name == "tt"; - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - } - } - return false; - } - - private static string ConvertToTimeString(TimeCode time) - { - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}.{time.Milliseconds:00}"; - } - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - "
" + Environment.NewLine + - "
" + Environment.NewLine + - "
"; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - XmlNode div = xml.DocumentElement.SelectSingleNode("div"); - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("p"); - string text = HtmlUtil.RemoveHtmlTags(p.Text, true); - - paragraph.InnerText = text; - paragraph.InnerXml = "" + paragraph.InnerXml.Replace(Environment.NewLine, "
") + "]]>"; - - XmlAttribute start = xml.CreateAttribute("begin"); - start.InnerText = ConvertToTimeString(p.StartTime); - paragraph.Attributes.Append(start); - - XmlAttribute end = xml.CreateAttribute("end"); - end.InnerText = ConvertToTimeString(p.EndTime); - paragraph.Attributes.Append(end); - - div.AppendChild(paragraph); - } - - return ToUtf8XmlString(xml); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - double startSeconds = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - var xml = new XmlDocument { XmlResolver = null }; - xml.LoadXml(sb.ToString().Trim()); - - var pText = new StringBuilder(); - foreach (XmlNode node in xml.DocumentElement.SelectNodes("div/p")) - { - try - { - foreach (XmlNode innerNode in node.ChildNodes) - { - if (innerNode.Name == "br") - { - pText.AppendLine(); - } - else - { - pText.Append(innerNode.InnerText.Trim()); - } - } - - var start = string.Empty; - if (node.Attributes["begin"] != null) - { - start = node.Attributes["begin"].InnerText; - } - - var end = string.Empty; - if (node.Attributes["end"] != null) - { - end = node.Attributes["end"].InnerText; - } - - var dur = string.Empty; - if (node.Attributes["dur"] != null) - { - dur = node.Attributes["dur"].InnerText; - } - - TimeCode startCode = TimeCode.FromSeconds(startSeconds); - if (start.Length > 0) - { - startCode = GetTimeCode(start); - } - - TimeCode endCode; - if (end.Length > 0) - { - endCode = GetTimeCode(end); - } - else if (dur.Length > 0) - { - endCode = new TimeCode(GetTimeCode(dur).TotalMilliseconds + startCode.TotalMilliseconds); - } - else - { - endCode = new TimeCode(startCode.TotalMilliseconds + 3000); - } - startSeconds = endCode.TotalSeconds; - - subtitle.Paragraphs.Add(new Paragraph(startCode, endCode, pText.ToString().Replace("", string.Empty).Replace("", string.Empty))); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - pText.Clear(); - } - subtitle.Renumber(); - } - - private static TimeCode GetTimeCode(string s) - { - if (s.EndsWith('s')) - { - s = s.TrimEnd('s'); - return TimeCode.FromSeconds(double.Parse(s)); - } - var parts = s.Split(new[] { ':', '.', ',' }); - return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + + // + // + //
+ //

This is fully skinnable through XML
using external images for each button]]>

+ //

You can put in any order or enable/disable
the control buttons]]>

+ //

Test below some of the customizable
properties this player has]]>

+ //

Many other properties related to fonts, sizes, colors
and list properties are in style.css file]]>

+ //
+ //
+ public class FlashXml : SubtitleFormat + { + public override string Extension => ".xml"; + + public override string Name => "Flash Xml"; + + public override bool IsMine(List lines, string fileName) + { + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + string xmlAsString = sb.ToString().Trim(); + if ((xmlAsString.Contains("") || xmlAsString.Contains(""))) + { + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(xmlAsString); + var paragraphs = xml.DocumentElement.SelectNodes("div/p"); + return paragraphs != null && paragraphs.Count > 0 && xml.DocumentElement.Name == "tt"; + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + } + } + return false; + } + + private static string ConvertToTimeString(TimeCode time) + { + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}.{time.Milliseconds:00}"; + } + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + "
" + Environment.NewLine + + "
" + Environment.NewLine + + "
"; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + XmlNode div = xml.DocumentElement.SelectSingleNode("div"); + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("p"); + string text = HtmlUtil.RemoveHtmlTags(p.Text, true); + + paragraph.InnerText = text; + paragraph.InnerXml = "" + paragraph.InnerXml.Replace(Environment.NewLine, "
") + "]]>"; + + XmlAttribute start = xml.CreateAttribute("begin"); + start.InnerText = ConvertToTimeString(p.StartTime); + paragraph.Attributes.Append(start); + + XmlAttribute end = xml.CreateAttribute("end"); + end.InnerText = ConvertToTimeString(p.EndTime); + paragraph.Attributes.Append(end); + + div.AppendChild(paragraph); + } + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + double startSeconds = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + xml.LoadXml(sb.ToString().Trim()); + + var pText = new StringBuilder(); + foreach (XmlNode node in xml.DocumentElement.SelectNodes("div/p")) + { + try + { + foreach (XmlNode innerNode in node.ChildNodes) + { + if (innerNode.Name == "br") + { + pText.AppendLine(); + } + else + { + pText.Append(innerNode.InnerText.Trim()); + } + } + + var start = string.Empty; + if (node.Attributes["begin"] != null) + { + start = node.Attributes["begin"].InnerText; + } + + var end = string.Empty; + if (node.Attributes["end"] != null) + { + end = node.Attributes["end"].InnerText; + } + + var dur = string.Empty; + if (node.Attributes["dur"] != null) + { + dur = node.Attributes["dur"].InnerText; + } + + TimeCode startCode = TimeCode.FromSeconds(startSeconds); + if (start.Length > 0) + { + startCode = GetTimeCode(start); + } + + TimeCode endCode; + if (end.Length > 0) + { + endCode = GetTimeCode(end); + } + else if (dur.Length > 0) + { + endCode = new TimeCode(GetTimeCode(dur).TotalMilliseconds + startCode.TotalMilliseconds); + } + else + { + endCode = new TimeCode(startCode.TotalMilliseconds + 3000); + } + startSeconds = endCode.TotalSeconds; + + subtitle.Paragraphs.Add(new Paragraph(startCode, endCode, pText.ToString().Replace("", string.Empty).Replace("", string.Empty))); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + pText.Clear(); + } + subtitle.Renumber(); + } + + private static TimeCode GetTimeCode(string s) + { + if (s.EndsWith('s')) + { + s = s.TrimEnd('s'); + return TimeCode.FromSeconds(double.Parse(s)); + } + var parts = s.Split(new[] { ':', '.', ',' }); + return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])); + } + + } +} diff --git a/libse/SubtitleFormats/Footage.cs b/src/libse/SubtitleFormats/Footage.cs similarity index 97% rename from libse/SubtitleFormats/Footage.cs rename to src/libse/SubtitleFormats/Footage.cs index a9ca7167a..3cf651803 100644 --- a/libse/SubtitleFormats/Footage.cs +++ b/src/libse/SubtitleFormats/Footage.cs @@ -1,170 +1,170 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Footage : SubtitleFormat - { - private static readonly Regex RegexTimeCode = new Regex(@"^\s*\d+,\d\d$", RegexOptions.Compiled); - - private enum ExpectingLine - { - Number, - TimeStart, - TimeEnd, - Text - } - - public override string Extension => ".txt"; - - public override string Name => "Footage"; - - public override bool IsMine(List lines, string fileName) - { - var asc = new TimeLineFootageAscii(); - if (fileName != null && asc.IsMine(null, fileName)) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - //1. - // 66,13 - // 70,00 - //#Tā nu es sapazinos - //#И так я познакомился - - //2. - // 71,14 - // 78,10 - //#ar dakteri Henriju Gūsu. - //#с доктором Генри Гусом. - - const string paragraphWriteFormat = "{4}.{3}{0}{3}{1}{3}{2}{3}"; - var sb = new StringBuilder(); - int count = 0; - foreach (Paragraph p in subtitle.Paragraphs) - { - count++; - string text = HtmlUtil.RemoveHtmlTags(p.Text); - if (p.Text.StartsWith("", StringComparison.Ordinal) && p.Text.EndsWith("", StringComparison.Ordinal)) - { - text = "#" + text; - } - - sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), text, Environment.NewLine, count)); - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - Paragraph paragraph = null; - ExpectingLine expecting = ExpectingLine.Number; - _errorCount = 0; - - subtitle.Paragraphs.Clear(); - char[] splitChar = { ',' }; - foreach (string line in lines) - { - if (line.EndsWith('.') && Utilities.IsInteger(line.TrimEnd('.'))) - { - if (!string.IsNullOrEmpty(paragraph?.Text)) - { - subtitle.Paragraphs.Add(paragraph); - } - - paragraph = new Paragraph(); - expecting = ExpectingLine.TimeStart; - } - else if (paragraph != null && expecting == ExpectingLine.TimeStart && RegexTimeCode.IsMatch(line)) - { - string[] parts = line.Split(splitChar, StringSplitOptions.RemoveEmptyEntries); - if (parts.Length == 2) - { - try - { - var tc = DecodeTimeCode(parts); - paragraph.StartTime = tc; - expecting = ExpectingLine.TimeEnd; - } - catch - { - _errorCount++; - expecting = ExpectingLine.Number; - } - } - } - else if (paragraph != null && expecting == ExpectingLine.TimeEnd && RegexTimeCode.IsMatch(line)) - { - string[] parts = line.Split(splitChar, StringSplitOptions.RemoveEmptyEntries); - if (parts.Length == 2) - { - try - { - var tc = DecodeTimeCode(parts); - paragraph.EndTime = tc; - expecting = ExpectingLine.Text; - } - catch - { - _errorCount++; - expecting = ExpectingLine.Number; - } - } - } - else - { - if (paragraph != null && expecting == ExpectingLine.Text) - { - if (line.Length > 0) - { - string s = line.Trim(); - if (s.StartsWith('#')) - { - s = "" + s.Remove(0, 1) + ""; - } - - paragraph.Text = (paragraph.Text + Environment.NewLine + s).Trim(); - paragraph.Text = paragraph.Text.Replace("
" + Environment.NewLine + "", Environment.NewLine); - if (paragraph.Text.Length > 2000) - { - _errorCount += 100; - return; - } - } - } - } - } - if (paragraph != null && !string.IsNullOrEmpty(paragraph.Text)) - { - subtitle.Paragraphs.Add(paragraph); - } - - subtitle.Renumber(); - } - - private static string EncodeTimeCode(TimeCode time) - { - int frames = MillisecondsToFrames(time.TotalMilliseconds); - int footage = frames / 16; - int rest = (int)Math.Round(frames % 16.0 / 16.0 * 24.0); - return $"{footage:00},{rest:00}".PadLeft(8); - } - - private static TimeCode DecodeTimeCode(string[] parts) - { - int frames16 = int.Parse(parts[0]); - int frames = int.Parse(parts[1]); - return new TimeCode(FramesToMilliseconds(16 * frames16 + (frames * 16.0 / 24.0))); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Footage : SubtitleFormat + { + private static readonly Regex RegexTimeCode = new Regex(@"^\s*\d+,\d\d$", RegexOptions.Compiled); + + private enum ExpectingLine + { + Number, + TimeStart, + TimeEnd, + Text + } + + public override string Extension => ".txt"; + + public override string Name => "Footage"; + + public override bool IsMine(List lines, string fileName) + { + var asc = new TimeLineFootageAscii(); + if (fileName != null && asc.IsMine(null, fileName)) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + //1. + // 66,13 + // 70,00 + //#Tā nu es sapazinos + //#И так я познакомился + + //2. + // 71,14 + // 78,10 + //#ar dakteri Henriju Gūsu. + //#с доктором Генри Гусом. + + const string paragraphWriteFormat = "{4}.{3}{0}{3}{1}{3}{2}{3}"; + var sb = new StringBuilder(); + int count = 0; + foreach (Paragraph p in subtitle.Paragraphs) + { + count++; + string text = HtmlUtil.RemoveHtmlTags(p.Text); + if (p.Text.StartsWith("", StringComparison.Ordinal) && p.Text.EndsWith("", StringComparison.Ordinal)) + { + text = "#" + text; + } + + sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), text, Environment.NewLine, count)); + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + Paragraph paragraph = null; + ExpectingLine expecting = ExpectingLine.Number; + _errorCount = 0; + + subtitle.Paragraphs.Clear(); + char[] splitChar = { ',' }; + foreach (string line in lines) + { + if (line.EndsWith('.') && Utilities.IsInteger(line.TrimEnd('.'))) + { + if (!string.IsNullOrEmpty(paragraph?.Text)) + { + subtitle.Paragraphs.Add(paragraph); + } + + paragraph = new Paragraph(); + expecting = ExpectingLine.TimeStart; + } + else if (paragraph != null && expecting == ExpectingLine.TimeStart && RegexTimeCode.IsMatch(line)) + { + string[] parts = line.Split(splitChar, StringSplitOptions.RemoveEmptyEntries); + if (parts.Length == 2) + { + try + { + var tc = DecodeTimeCode(parts); + paragraph.StartTime = tc; + expecting = ExpectingLine.TimeEnd; + } + catch + { + _errorCount++; + expecting = ExpectingLine.Number; + } + } + } + else if (paragraph != null && expecting == ExpectingLine.TimeEnd && RegexTimeCode.IsMatch(line)) + { + string[] parts = line.Split(splitChar, StringSplitOptions.RemoveEmptyEntries); + if (parts.Length == 2) + { + try + { + var tc = DecodeTimeCode(parts); + paragraph.EndTime = tc; + expecting = ExpectingLine.Text; + } + catch + { + _errorCount++; + expecting = ExpectingLine.Number; + } + } + } + else + { + if (paragraph != null && expecting == ExpectingLine.Text) + { + if (line.Length > 0) + { + string s = line.Trim(); + if (s.StartsWith('#')) + { + s = "" + s.Remove(0, 1) + ""; + } + + paragraph.Text = (paragraph.Text + Environment.NewLine + s).Trim(); + paragraph.Text = paragraph.Text.Replace("" + Environment.NewLine + "", Environment.NewLine); + if (paragraph.Text.Length > 2000) + { + _errorCount += 100; + return; + } + } + } + } + } + if (paragraph != null && !string.IsNullOrEmpty(paragraph.Text)) + { + subtitle.Paragraphs.Add(paragraph); + } + + subtitle.Renumber(); + } + + private static string EncodeTimeCode(TimeCode time) + { + int frames = MillisecondsToFrames(time.TotalMilliseconds); + int footage = frames / 16; + int rest = (int)Math.Round(frames % 16.0 / 16.0 * 24.0); + return $"{footage:00},{rest:00}".PadLeft(8); + } + + private static TimeCode DecodeTimeCode(string[] parts) + { + int frames16 = int.Parse(parts[0]); + int frames = int.Parse(parts[1]); + return new TimeCode(FramesToMilliseconds(16 * frames16 + (frames * 16.0 / 24.0))); + } + + } +} diff --git a/libse/SubtitleFormats/GooglePlayJson.cs b/src/libse/SubtitleFormats/GooglePlayJson.cs similarity index 100% rename from libse/SubtitleFormats/GooglePlayJson.cs rename to src/libse/SubtitleFormats/GooglePlayJson.cs diff --git a/libse/SubtitleFormats/GpacTtxt.cs b/src/libse/SubtitleFormats/GpacTtxt.cs similarity index 97% rename from libse/SubtitleFormats/GpacTtxt.cs rename to src/libse/SubtitleFormats/GpacTtxt.cs index 65da69587..3e3dd2b9f 100644 --- a/libse/SubtitleFormats/GpacTtxt.cs +++ b/src/libse/SubtitleFormats/GpacTtxt.cs @@ -1,120 +1,120 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class GpacTtxt : SubtitleFormat - { - public override string Extension => ".ttxt"; - - public override string Name => "GPAC TTXT"; - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - ""; - - string xmlTrackStructure = - "" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " 00:03:57:16" + Environment.NewLine + - ""; - - var xml = new XmlDocument { XmlResolver = null }; - xml.LoadXml(xmlStructure); - // TODO: Set variables... - XmlNode trackNode = xml.DocumentElement.SelectSingleNode("TrackList/Track/StItemList"); - - int number = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - // starttime + text - XmlNode stItem = xml.CreateElement("StItem"); - stItem.InnerXml = xmlTrackStructure; - - XmlAttribute memo = xml.CreateAttribute("Memo"); - memo.InnerText = string.Empty; - stItem.Attributes.Append(memo); - - XmlAttribute tc = xml.CreateAttribute("TC"); - tc.InnerText = ((int)Math.Round(p.StartTime.TotalMilliseconds)).ToString(); - stItem.Attributes.Append(tc); - - XmlAttribute row = xml.CreateAttribute("Row"); - row.InnerText = number.ToString(); - stItem.Attributes.Append(row); - - XmlNodeList list = stItem.SelectNodes("StTextList/StText"); - list[0].InnerText = p.Text; - list[2].InnerText = p.StartTime.ToHHMMSSFF(); - trackNode.AppendChild(stItem); - number++; - - // endtime - stItem = xml.CreateElement("StItem"); - stItem.InnerXml = xmlTrackStructure; - - memo = xml.CreateAttribute("Memo"); - memo.InnerText = string.Empty; - stItem.Attributes.Append(memo); - - tc = xml.CreateAttribute("TC"); - tc.InnerText = ((int)Math.Round(p.EndTime.TotalMilliseconds)).ToString(); - stItem.Attributes.Append(tc); - - row = xml.CreateAttribute("Row"); - row.InnerText = number.ToString(); - stItem.Attributes.Append(row); - - list = stItem.SelectNodes("StTextList/StText"); - list[0].InnerText = string.Empty; - list[2].InnerText = p.EndTime.ToString(); - trackNode.AppendChild(stItem); - number++; - } - - return ToUtf8XmlString(xml); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - if (!sb.ToString().Contains(" 1) - { - text = (list[0].InnerText + Environment.NewLine + list[1].InnerText).Trim(); - } - else if (list.Count == 1) - { - text = list[0].InnerText.Trim(); - } - - p.Text = text; - subtitle.Paragraphs.Add(p); - } - catch - { - _errorCount++; - } - } - subtitle.Renumber(); - } - catch - { - _errorCount = 1; - return; - } - - int i = 0; - foreach (Paragraph p in subtitle.Paragraphs) - { - i++; - var next = subtitle.GetParagraphOrDefault(i); - if (next != null) - { - p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds; - } - } - subtitle.RemoveEmptyLines(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class IssXml : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); //00:02:56:02 + + public override string Extension => ".ats"; + + public override string Name => "ATS ISS"; + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + ""; + + string xmlTrackStructure = + "" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " 00:03:57:16" + Environment.NewLine + + ""; + + var xml = new XmlDocument { XmlResolver = null }; + xml.LoadXml(xmlStructure); + // TODO: Set variables... + XmlNode trackNode = xml.DocumentElement.SelectSingleNode("TrackList/Track/StItemList"); + + int number = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + // starttime + text + XmlNode stItem = xml.CreateElement("StItem"); + stItem.InnerXml = xmlTrackStructure; + + XmlAttribute memo = xml.CreateAttribute("Memo"); + memo.InnerText = string.Empty; + stItem.Attributes.Append(memo); + + XmlAttribute tc = xml.CreateAttribute("TC"); + tc.InnerText = ((int)Math.Round(p.StartTime.TotalMilliseconds)).ToString(); + stItem.Attributes.Append(tc); + + XmlAttribute row = xml.CreateAttribute("Row"); + row.InnerText = number.ToString(); + stItem.Attributes.Append(row); + + XmlNodeList list = stItem.SelectNodes("StTextList/StText"); + list[0].InnerText = p.Text; + list[2].InnerText = p.StartTime.ToHHMMSSFF(); + trackNode.AppendChild(stItem); + number++; + + // endtime + stItem = xml.CreateElement("StItem"); + stItem.InnerXml = xmlTrackStructure; + + memo = xml.CreateAttribute("Memo"); + memo.InnerText = string.Empty; + stItem.Attributes.Append(memo); + + tc = xml.CreateAttribute("TC"); + tc.InnerText = ((int)Math.Round(p.EndTime.TotalMilliseconds)).ToString(); + stItem.Attributes.Append(tc); + + row = xml.CreateAttribute("Row"); + row.InnerText = number.ToString(); + stItem.Attributes.Append(row); + + list = stItem.SelectNodes("StTextList/StText"); + list[0].InnerText = string.Empty; + list[2].InnerText = p.EndTime.ToString(); + trackNode.AppendChild(stItem); + number++; + } + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + if (!sb.ToString().Contains(" 1) + { + text = (list[0].InnerText + Environment.NewLine + list[1].InnerText).Trim(); + } + else if (list.Count == 1) + { + text = list[0].InnerText.Trim(); + } + + p.Text = text; + subtitle.Paragraphs.Add(p); + } + catch + { + _errorCount++; + } + } + subtitle.Renumber(); + } + catch + { + _errorCount = 1; + return; + } + + int i = 0; + foreach (Paragraph p in subtitle.Paragraphs) + { + i++; + var next = subtitle.GetParagraphOrDefault(i); + if (next != null) + { + p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds; + } + } + subtitle.RemoveEmptyLines(); + } + + } +} diff --git a/libse/SubtitleFormats/ItunesTimedText.cs b/src/libse/SubtitleFormats/ItunesTimedText.cs similarity index 97% rename from libse/SubtitleFormats/ItunesTimedText.cs rename to src/libse/SubtitleFormats/ItunesTimedText.cs index 020307e21..3496ad4bc 100644 --- a/libse/SubtitleFormats/ItunesTimedText.cs +++ b/src/libse/SubtitleFormats/ItunesTimedText.cs @@ -1,377 +1,377 @@ -using System; -using System.Collections.Generic; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - /// Crappy format... should always be saved as UTF-8 without BOM (hacked Main.cs) and
tags should be oldstyle
- ///
- public class ItunesTimedText : TimedText10 - { - public override string Extension => ".itt"; - - public new const string NameOfFormat = "iTunes Timed Text"; - - public override string Name => NameOfFormat; - - public override bool IsMine(List lines, string fileName) - { - if (fileName != null && !fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) - { - return false; - } - - if (new NetflixTimedText().IsMine(lines, fileName)) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - XmlNode styleHead = null; - bool convertedFromSubStationAlpha = false; - if (subtitle.Header != null) - { - try - { - var x = new XmlDocument(); - x.LoadXml(subtitle.Header); - var xnsmgr = new XmlNamespaceManager(x.NameTable); - xnsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml"); - styleHead = x.DocumentElement.SelectSingleNode("ttml:head", xnsmgr); - } - catch - { - styleHead = null; - } - if (styleHead == null && (subtitle.Header.Contains("[V4+ Styles]") || subtitle.Header.Contains("[V4 Styles]"))) - { - var x = new XmlDocument(); - x.LoadXml(new ItunesTimedText().ToText(new Subtitle(), "tt")); // load default xml - var xnsmgr = new XmlNamespaceManager(x.NameTable); - xnsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml"); - styleHead = x.DocumentElement.SelectSingleNode("ttml:head", xnsmgr); - styleHead.SelectSingleNode("ttml:styling", xnsmgr).RemoveAll(); - foreach (string styleName in AdvancedSubStationAlpha.GetStylesFromHeader(subtitle.Header)) - { - try - { - var ssaStyle = AdvancedSubStationAlpha.GetSsaStyle(styleName, subtitle.Header); - - string fontStyle = "normal"; - if (ssaStyle.Italic) - { - fontStyle = "italic"; - } - - string fontWeight = "normal"; - if (ssaStyle.Bold) - { - fontWeight = "bold"; - } - - AddStyleToXml(x, styleHead, xnsmgr, ssaStyle.Name, ssaStyle.FontName, fontWeight, fontStyle, Utilities.ColorToHex(ssaStyle.Primary), ssaStyle.FontSize.ToString()); - convertedFromSubStationAlpha = true; - - } - catch - { - // ignored - } - } - subtitle.Header = x.OuterXml; // save new xml with styles in header - } - } - - var xml = new XmlDocument { XmlResolver = null }; - var nsmgr = new XmlNamespaceManager(xml.NameTable); - nsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml"); - nsmgr.AddNamespace("ttp", "http://www.w3.org/ns/10/ttml#parameter"); - nsmgr.AddNamespace("tts", "http://www.w3.org/ns/ttml#styling"); - nsmgr.AddNamespace("ttm", "http://www.w3.org/ns/10/ttml#metadata"); - - string frameRate = ((int)Math.Round(Configuration.Settings.General.CurrentFrameRate)).ToString(); - string frameRateMultiplier = "999 1000"; - if (Configuration.Settings.General.CurrentFrameRate % 1.0 < 0.01) - { - frameRateMultiplier = "1 1"; - } - string dropMode = "nonDrop"; - if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 29.97) < 0.01) - { - dropMode = "dropNTSC"; - } - - const string language = "en-US"; - string xmlStructure = "" + Environment.NewLine + - "" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " - - -<-- Open play menu, choose Captions and Subtiles, On if available --> -<-- Open tools menu, Security, Show local captions when present -->"; - - bool useExtra = false; - if (!string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.StartsWith(" - -_TITLE_ - - Metrics {time:ms;} - Spec {MSFT:1.0;} - -" + subtitle.Header.Trim() + @" - - -<-- Open play menu, choose Captions and Subtiles, On if available --> -<-- Open tools menu, Security, Show local captions when present -->"; - } - - // Example text (start numbers are milliseconds) - //

Let's go! - //


- - string paragraphWriteFormat = @"

{2}" + Environment.NewLine + - @"

 "; - string paragraphWriteFormatOpen = @"

{1}"; - if (Name == new SamiModern().Name) - { - paragraphWriteFormat = "

{2}

" + Environment.NewLine + - "

 

"; - paragraphWriteFormatOpen = "

{1}

"; - } - else if (Name == new SamiYouTube().Name) - { - paragraphWriteFormat = "

{2}

" + Environment.NewLine + - "

"; - paragraphWriteFormatOpen = "

{1}

"; - } - - int count = 1; - var sb = new StringBuilder(); - sb.AppendLine(header.Replace("_TITLE_", title).Replace("_LANGUAGE-STYLE_", languageStyle)); - var totalLine = new StringBuilder(); - var partialLine = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - Paragraph next = subtitle.GetParagraphOrDefault(count); - string text = p.Text; - - if (text.Contains('<') && text.Contains('>')) - { - bool tagOn = false; - for (int i = 0; i < text.Length; i++) - { - string t = text.Substring(i); - if (t.StartsWith('<') && - (t.StartsWith("') && tagOn) - { - tagOn = false; - totalLine.Append('>'); - } - else if (!tagOn) - { - partialLine.Append(text[i]); - } - else - { - totalLine.Append(text[i]); - } - } - - totalLine.Append(EncodeText(partialLine.ToString())); - text = totalLine.ToString(); - totalLine.Clear(); - partialLine.Clear(); - } - else - { - text = EncodeText(text); - } - - if (Name == new SamiModern().Name) - { - text = text.Replace(Environment.NewLine, "
"); - } - else - { - text = text.Replace(Environment.NewLine, "
"); - } - - string currentClass = languageTag; - if (useExtra && !string.IsNullOrEmpty(p.Extra)) - { - currentClass = p.Extra; - } - - var startMs = (long)(Math.Round(p.StartTime.TotalMilliseconds)); - var endMs = (long)(Math.Round(p.EndTime.TotalMilliseconds)); - if (next != null && Math.Abs(((long)Math.Round(next.StartTime.TotalMilliseconds)) - endMs) < 1) - { - sb.AppendLine(string.Format(paragraphWriteFormatOpen, startMs, text, currentClass)); - } - else - { - sb.AppendLine(string.Format(paragraphWriteFormat, startMs, endMs, text, currentClass)); - } - - count++; - } - sb.AppendLine(""); - sb.AppendLine(""); - return sb.ToString().Trim(); - } - - private static string EncodeText(string text) - { - switch (Configuration.Settings.SubtitleSettings.SamiHtmlEncodeMode) - { - case 1: - return WebUtility.HtmlEncode(text); - case 2: - return HtmlUtil.EncodeNamed(text); - case 3: - return HtmlUtil.EncodeNumeric(text); - } - return text; - } - - public static List GetStylesFromHeader(string header) - { - var list = new List(); - if (!string.IsNullOrEmpty(header) && header.StartsWith(" 2) - { - string name = s.Substring(1, s.IndexOf(' ') - 1); - list.Add(name); - } - } - } - else - { - list.Add("ENUSCC"); - } - return list; - } - - public static List GetStylesFromSubtitle(Subtitle subtitle) - { - string language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); - var ci = CultureInfo.GetCultureInfo(language); - language = CultureInfo.CreateSpecificCulture(ci.Name).Name; - string languageTag = $"{language.Replace("-", string.Empty).ToUpperInvariant()}CC"; - return new List { languageTag }; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var sb = new StringBuilder(); - foreach (string l in lines) - { - sb.AppendLine(l.Replace(" 0) - { - int styleEnd = allInputLower.IndexOf("", StringComparison.Ordinal); - if (styleEnd > 0) - { - subtitle.Header = allInput.Substring(styleStart, styleEnd - styleStart + 8); - } - } - - const string syncTag = "= 0) - { - string millisecondsAsString = string.Empty; - while (index < allInput.Length && expectedChars.Contains(allInput[index])) - { - if (allInput[index] != '"' && allInput[index] != '\'') - { - millisecondsAsString += allInput[index]; - } - - index++; - } - - while (index < allInput.Length && allInput[index] != '>') - { - index++; - } - - if (index < allInput.Length && allInput[index] == '>') - { - index++; - } - - int syncEndPos = allInputLower.IndexOf(syncTag, index, StringComparison.Ordinal); - if (hasEncryptedTags) - { - int syncEndPosEnc = allInputLower.IndexOf(syncTagEnc, index, StringComparison.Ordinal); - if (syncStartPosEnc >= 0 && syncStartPosEnc < syncStartPos || syncEndPos == -1) - { - syncEndPos = syncEndPosEnc; - } - } - - string text; - if (syncEndPos >= 0) - { - text = allInput.Substring(index, syncEndPos - index); - } - else - { - text = allInput.Substring(index); - } - - string textToLower = text.ToLowerInvariant(); - if (textToLower.Contains(" class=")) - { - var className = new StringBuilder(); - int startClass = textToLower.IndexOf(" class=", StringComparison.Ordinal); - int indexClass = startClass + 7; - while (indexClass < textToLower.Length && (Utilities.LowercaseLettersWithNumbers + @"'""").Contains(textToLower[indexClass])) - { - className.Append(text[indexClass]); - indexClass++; - } - p.Extra = className.ToString().Trim(' ', '\'', '"'); - } - - if (text.Contains("ID=\"Source\"") || text.Contains("ID=Source")) - { - int sourceIndex = text.IndexOf("ID=\"Source\"", StringComparison.Ordinal); - if (sourceIndex < 0) - { - sourceIndex = text.IndexOf("ID=Source", StringComparison.Ordinal); - } - - int st = sourceIndex - 1; - while (st > 0 && text.Substring(st, 2).ToUpperInvariant() != " 0) - { - text = text.Substring(0, st) + text.Substring(sourceIndex); - } - int et = st; - while (et < text.Length - 5 && text.Substring(et, 3).ToUpperInvariant() != "

" && text.Substring(et, 4).ToUpperInvariant() != "

") - { - et++; - } - text = text.Substring(0, st) + text.Substring(et); - } - text = text.Replace(Environment.NewLine, " "); - text = text.Replace(" ", " "); - - text = text.TrimEnd(); - text = Regex.Replace(text, @"
", Environment.NewLine, RegexOptions.IgnoreCase); - - while (text.Contains(" ")) - { - text = text.Replace(" ", " "); - } - - text = text.Replace("", string.Empty).Replace("", string.Empty).TrimEnd(); - text = text.Replace("", string.Empty).Replace("", string.Empty).TrimEnd(); - - int endSyncPos = text.ToUpperInvariant().IndexOf("
", StringComparison.OrdinalIgnoreCase); - if (text.IndexOf('>') > 0 && (text.IndexOf('>') < endSyncPos || endSyncPos == -1)) - { - text = text.Remove(0, text.IndexOf('>') + 1); - } - - text = text.TrimEnd(); - - if (text.EndsWith("
", StringComparison.OrdinalIgnoreCase)) - { - text = text.Substring(0, text.Length - 7).TrimEnd(); - } - - if (text.EndsWith("

", StringComparison.Ordinal) || text.EndsWith("

", StringComparison.OrdinalIgnoreCase)) - { - text = text.Substring(0, text.Length - 4).TrimEnd(); - } - - text = RemoveDiv(text).Trim(); - text = text.Replace(" ", " ").Replace("&NBSP;", " "); - text = text.Replace("

", string.Empty).Replace("", string.Empty).Replace("", string.Empty); - if (string.IsNullOrWhiteSpace(text)) - { - text = string.Empty; - } - - if (text.Contains("")) - { - text += ""; - } - - if (text.StartsWith("") && !text.Contains("")) - { - text += "
"; - } - - if (text.Contains('<') && text.Contains('>')) - { - var total = new StringBuilder(); - var partial = new StringBuilder(); - bool tagOn = false; - for (int i = 0; i < text.Length && i < 999; i++) - { - string tmp = text.Substring(i); - if (tmp.StartsWith('<') && - (tmp.StartsWith("') && tagOn) - { - tagOn = false; - total.Append('>'); - } - else if (!tagOn) - { - partial.Append(text[i]); - } - else - { - total.Append(text[i]); - } - } - total.Append(WebUtility.HtmlDecode(partial.ToString())); - text = total.ToString(); - } - else - { - text = WebUtility.HtmlDecode(text); - } - - var cleanText = text.FixExtraSpaces(); - cleanText = cleanText.Trim(); - - if (!string.IsNullOrEmpty(p.Text) && !string.IsNullOrEmpty(millisecondsAsString)) - { - p.EndTime = new TimeCode(long.Parse(millisecondsAsString)); - subtitle.Paragraphs.Add(p); - p = new Paragraph(); - } - - p.Text = cleanText; - long l; - if (long.TryParse(millisecondsAsString, out l)) - { - p.StartTime = new TimeCode(l); - } - - if (syncEndPos <= 0) - { - syncStartPos = -1; - } - else - { - syncStartPos = allInputLower.IndexOf(syncTag, syncEndPos, StringComparison.Ordinal); - index = syncStartPos + syncTag.Length; - - if (hasEncryptedTags) - { - syncStartPosEnc = allInputLower.IndexOf(syncTagEnc, syncEndPos, StringComparison.Ordinal); - if (syncStartPosEnc >= 0 && syncStartPosEnc < syncStartPos || syncStartPos == -1) - { - syncStartPos = syncStartPosEnc; - index = syncStartPosEnc + syncTagEnc.Length; - } - } - } - } - if (!string.IsNullOrEmpty(p.Text) && !subtitle.Paragraphs.Contains(p)) - { - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text); - subtitle.Paragraphs.Add(p); - } - subtitle.Renumber(); - - if (subtitle.Paragraphs.Count > 0 && - (subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].Text.ToUpperInvariant().Trim() == "" || - subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].Text.ToUpperInvariant().Trim() == "")) - { - subtitle.Paragraphs.RemoveAt(subtitle.Paragraphs.Count - 1); - } - - foreach (Paragraph p2 in subtitle.Paragraphs) - { - p2.Text = p2.Text.Replace('\u00A0', ' '); // non-breaking space to normal space - } - } - - private string RemoveDiv(string text) - { - int indexOfDiv = text.IndexOf("
", StringComparison.Ordinal); - } - - int maxLoop = 10; - while (indexOfDiv > 0 && maxLoop >= 0) - { - int indexOfStartEnd = text.IndexOf(">", indexOfDiv + 1, StringComparison.Ordinal); - if (indexOfStartEnd > 0) - { - text = text.Remove(indexOfDiv, indexOfStartEnd - indexOfDiv + 1); - text = text.Replace("
", string.Empty); - - indexOfDiv = text.IndexOf("
", StringComparison.Ordinal); - } - } - maxLoop--; - } - return text; - } - - public override bool HasStyleSupport => true; - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Net; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Sami : SubtitleFormat + { + public override string Extension => ".smi"; + + public override string Name => "SAMI"; + + public override bool IsMine(List lines, string fileName) + { + var sb = new StringBuilder(); + foreach (string l in lines) + { + sb.AppendLine(l); + } + + if (Name == "SAMI" && sb.ToString().Contains("")) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + var language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); + var ci = CultureInfo.GetCultureInfo(language); + language = CultureInfo.CreateSpecificCulture(ci.Name).Name; + string languageTag = $"{language.Replace("-", string.Empty).ToUpperInvariant()}CC"; + string languageName = ci.EnglishName; + string languageStyle = $".{languageTag} [ name: {languageName}; lang: {language.Replace("_", "-")} ; SAMIType: CC ; ]"; + languageStyle = languageStyle.Replace("[", "{").Replace("]", "}"); + + string header = +@" + +_TITLE_ + + Metrics {time:ms;} + Spec {MSFT:1.0;} + + + + +<-- Open play menu, choose Captions and Subtiles, On if available --> +<-- Open tools menu, Security, Show local captions when present -->"; + + bool useExtra = false; + if (!string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.StartsWith(" + +_TITLE_ + + Metrics {time:ms;} + Spec {MSFT:1.0;} + +" + subtitle.Header.Trim() + @" + + +<-- Open play menu, choose Captions and Subtiles, On if available --> +<-- Open tools menu, Security, Show local captions when present -->"; + } + + // Example text (start numbers are milliseconds) + //

Let's go! + //


+ + string paragraphWriteFormat = @"

{2}" + Environment.NewLine + + @"

 "; + string paragraphWriteFormatOpen = @"

{1}"; + if (Name == new SamiModern().Name) + { + paragraphWriteFormat = "

{2}

" + Environment.NewLine + + "

 

"; + paragraphWriteFormatOpen = "

{1}

"; + } + else if (Name == new SamiYouTube().Name) + { + paragraphWriteFormat = "

{2}

" + Environment.NewLine + + "

"; + paragraphWriteFormatOpen = "

{1}

"; + } + + int count = 1; + var sb = new StringBuilder(); + sb.AppendLine(header.Replace("_TITLE_", title).Replace("_LANGUAGE-STYLE_", languageStyle)); + var totalLine = new StringBuilder(); + var partialLine = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + Paragraph next = subtitle.GetParagraphOrDefault(count); + string text = p.Text; + + if (text.Contains('<') && text.Contains('>')) + { + bool tagOn = false; + for (int i = 0; i < text.Length; i++) + { + string t = text.Substring(i); + if (t.StartsWith('<') && + (t.StartsWith("') && tagOn) + { + tagOn = false; + totalLine.Append('>'); + } + else if (!tagOn) + { + partialLine.Append(text[i]); + } + else + { + totalLine.Append(text[i]); + } + } + + totalLine.Append(EncodeText(partialLine.ToString())); + text = totalLine.ToString(); + totalLine.Clear(); + partialLine.Clear(); + } + else + { + text = EncodeText(text); + } + + if (Name == new SamiModern().Name) + { + text = text.Replace(Environment.NewLine, "
"); + } + else + { + text = text.Replace(Environment.NewLine, "
"); + } + + string currentClass = languageTag; + if (useExtra && !string.IsNullOrEmpty(p.Extra)) + { + currentClass = p.Extra; + } + + var startMs = (long)(Math.Round(p.StartTime.TotalMilliseconds)); + var endMs = (long)(Math.Round(p.EndTime.TotalMilliseconds)); + if (next != null && Math.Abs(((long)Math.Round(next.StartTime.TotalMilliseconds)) - endMs) < 1) + { + sb.AppendLine(string.Format(paragraphWriteFormatOpen, startMs, text, currentClass)); + } + else + { + sb.AppendLine(string.Format(paragraphWriteFormat, startMs, endMs, text, currentClass)); + } + + count++; + } + sb.AppendLine(""); + sb.AppendLine("
"); + return sb.ToString().Trim(); + } + + private static string EncodeText(string text) + { + switch (Configuration.Settings.SubtitleSettings.SamiHtmlEncodeMode) + { + case 1: + return WebUtility.HtmlEncode(text); + case 2: + return HtmlUtil.EncodeNamed(text); + case 3: + return HtmlUtil.EncodeNumeric(text); + } + return text; + } + + public static List GetStylesFromHeader(string header) + { + var list = new List(); + if (!string.IsNullOrEmpty(header) && header.StartsWith(" 2) + { + string name = s.Substring(1, s.IndexOf(' ') - 1); + list.Add(name); + } + } + } + else + { + list.Add("ENUSCC"); + } + return list; + } + + public static List GetStylesFromSubtitle(Subtitle subtitle) + { + string language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); + var ci = CultureInfo.GetCultureInfo(language); + language = CultureInfo.CreateSpecificCulture(ci.Name).Name; + string languageTag = $"{language.Replace("-", string.Empty).ToUpperInvariant()}CC"; + return new List { languageTag }; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var sb = new StringBuilder(); + foreach (string l in lines) + { + sb.AppendLine(l.Replace(" 0) + { + int styleEnd = allInputLower.IndexOf("", StringComparison.Ordinal); + if (styleEnd > 0) + { + subtitle.Header = allInput.Substring(styleStart, styleEnd - styleStart + 8); + } + } + + const string syncTag = "= 0) + { + string millisecondsAsString = string.Empty; + while (index < allInput.Length && expectedChars.Contains(allInput[index])) + { + if (allInput[index] != '"' && allInput[index] != '\'') + { + millisecondsAsString += allInput[index]; + } + + index++; + } + + while (index < allInput.Length && allInput[index] != '>') + { + index++; + } + + if (index < allInput.Length && allInput[index] == '>') + { + index++; + } + + int syncEndPos = allInputLower.IndexOf(syncTag, index, StringComparison.Ordinal); + if (hasEncryptedTags) + { + int syncEndPosEnc = allInputLower.IndexOf(syncTagEnc, index, StringComparison.Ordinal); + if (syncStartPosEnc >= 0 && syncStartPosEnc < syncStartPos || syncEndPos == -1) + { + syncEndPos = syncEndPosEnc; + } + } + + string text; + if (syncEndPos >= 0) + { + text = allInput.Substring(index, syncEndPos - index); + } + else + { + text = allInput.Substring(index); + } + + string textToLower = text.ToLowerInvariant(); + if (textToLower.Contains(" class=")) + { + var className = new StringBuilder(); + int startClass = textToLower.IndexOf(" class=", StringComparison.Ordinal); + int indexClass = startClass + 7; + while (indexClass < textToLower.Length && (Utilities.LowercaseLettersWithNumbers + @"'""").Contains(textToLower[indexClass])) + { + className.Append(text[indexClass]); + indexClass++; + } + p.Extra = className.ToString().Trim(' ', '\'', '"'); + } + + if (text.Contains("ID=\"Source\"") || text.Contains("ID=Source")) + { + int sourceIndex = text.IndexOf("ID=\"Source\"", StringComparison.Ordinal); + if (sourceIndex < 0) + { + sourceIndex = text.IndexOf("ID=Source", StringComparison.Ordinal); + } + + int st = sourceIndex - 1; + while (st > 0 && text.Substring(st, 2).ToUpperInvariant() != " 0) + { + text = text.Substring(0, st) + text.Substring(sourceIndex); + } + int et = st; + while (et < text.Length - 5 && text.Substring(et, 3).ToUpperInvariant() != "

" && text.Substring(et, 4).ToUpperInvariant() != "

") + { + et++; + } + text = text.Substring(0, st) + text.Substring(et); + } + text = text.Replace(Environment.NewLine, " "); + text = text.Replace(" ", " "); + + text = text.TrimEnd(); + text = Regex.Replace(text, @"
", Environment.NewLine, RegexOptions.IgnoreCase); + + while (text.Contains(" ")) + { + text = text.Replace(" ", " "); + } + + text = text.Replace("", string.Empty).Replace("", string.Empty).TrimEnd(); + text = text.Replace("", string.Empty).Replace("", string.Empty).TrimEnd(); + + int endSyncPos = text.ToUpperInvariant().IndexOf("
", StringComparison.OrdinalIgnoreCase); + if (text.IndexOf('>') > 0 && (text.IndexOf('>') < endSyncPos || endSyncPos == -1)) + { + text = text.Remove(0, text.IndexOf('>') + 1); + } + + text = text.TrimEnd(); + + if (text.EndsWith("
", StringComparison.OrdinalIgnoreCase)) + { + text = text.Substring(0, text.Length - 7).TrimEnd(); + } + + if (text.EndsWith("

", StringComparison.Ordinal) || text.EndsWith("

", StringComparison.OrdinalIgnoreCase)) + { + text = text.Substring(0, text.Length - 4).TrimEnd(); + } + + text = RemoveDiv(text).Trim(); + text = text.Replace(" ", " ").Replace("&NBSP;", " "); + text = text.Replace("

", string.Empty).Replace("", string.Empty).Replace("", string.Empty); + if (string.IsNullOrWhiteSpace(text)) + { + text = string.Empty; + } + + if (text.Contains("")) + { + text += ""; + } + + if (text.StartsWith("") && !text.Contains("")) + { + text += "
"; + } + + if (text.Contains('<') && text.Contains('>')) + { + var total = new StringBuilder(); + var partial = new StringBuilder(); + bool tagOn = false; + for (int i = 0; i < text.Length && i < 999; i++) + { + string tmp = text.Substring(i); + if (tmp.StartsWith('<') && + (tmp.StartsWith("') && tagOn) + { + tagOn = false; + total.Append('>'); + } + else if (!tagOn) + { + partial.Append(text[i]); + } + else + { + total.Append(text[i]); + } + } + total.Append(WebUtility.HtmlDecode(partial.ToString())); + text = total.ToString(); + } + else + { + text = WebUtility.HtmlDecode(text); + } + + var cleanText = text.FixExtraSpaces(); + cleanText = cleanText.Trim(); + + if (!string.IsNullOrEmpty(p.Text) && !string.IsNullOrEmpty(millisecondsAsString)) + { + p.EndTime = new TimeCode(long.Parse(millisecondsAsString)); + subtitle.Paragraphs.Add(p); + p = new Paragraph(); + } + + p.Text = cleanText; + long l; + if (long.TryParse(millisecondsAsString, out l)) + { + p.StartTime = new TimeCode(l); + } + + if (syncEndPos <= 0) + { + syncStartPos = -1; + } + else + { + syncStartPos = allInputLower.IndexOf(syncTag, syncEndPos, StringComparison.Ordinal); + index = syncStartPos + syncTag.Length; + + if (hasEncryptedTags) + { + syncStartPosEnc = allInputLower.IndexOf(syncTagEnc, syncEndPos, StringComparison.Ordinal); + if (syncStartPosEnc >= 0 && syncStartPosEnc < syncStartPos || syncStartPos == -1) + { + syncStartPos = syncStartPosEnc; + index = syncStartPosEnc + syncTagEnc.Length; + } + } + } + } + if (!string.IsNullOrEmpty(p.Text) && !subtitle.Paragraphs.Contains(p)) + { + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text); + subtitle.Paragraphs.Add(p); + } + subtitle.Renumber(); + + if (subtitle.Paragraphs.Count > 0 && + (subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].Text.ToUpperInvariant().Trim() == "" || + subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].Text.ToUpperInvariant().Trim() == "")) + { + subtitle.Paragraphs.RemoveAt(subtitle.Paragraphs.Count - 1); + } + + foreach (Paragraph p2 in subtitle.Paragraphs) + { + p2.Text = p2.Text.Replace('\u00A0', ' '); // non-breaking space to normal space + } + } + + private string RemoveDiv(string text) + { + int indexOfDiv = text.IndexOf("
", StringComparison.Ordinal); + } + + int maxLoop = 10; + while (indexOfDiv > 0 && maxLoop >= 0) + { + int indexOfStartEnd = text.IndexOf(">", indexOfDiv + 1, StringComparison.Ordinal); + if (indexOfStartEnd > 0) + { + text = text.Remove(indexOfDiv, indexOfStartEnd - indexOfDiv + 1); + text = text.Replace("
", string.Empty); + + indexOfDiv = text.IndexOf("
", StringComparison.Ordinal); + } + } + maxLoop--; + } + return text; + } + + public override bool HasStyleSupport => true; + } +} diff --git a/libse/SubtitleFormats/SamiAvDicPlayer.cs b/src/libse/SubtitleFormats/SamiAvDicPlayer.cs similarity index 100% rename from libse/SubtitleFormats/SamiAvDicPlayer.cs rename to src/libse/SubtitleFormats/SamiAvDicPlayer.cs diff --git a/libse/SubtitleFormats/SamiModern.cs b/src/libse/SubtitleFormats/SamiModern.cs similarity index 95% rename from libse/SubtitleFormats/SamiModern.cs rename to src/libse/SubtitleFormats/SamiModern.cs index 0a1b28127..1fbac0739 100644 --- a/libse/SubtitleFormats/SamiModern.cs +++ b/src/libse/SubtitleFormats/SamiModern.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SamiModern : Sami - { - public override string Name => "SAMI modern"; - } -} +using System.Collections.Generic; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SamiModern : Sami + { + public override string Name => "SAMI modern"; + } +} diff --git a/libse/SubtitleFormats/SamiYouTube.cs b/src/libse/SubtitleFormats/SamiYouTube.cs similarity index 95% rename from libse/SubtitleFormats/SamiYouTube.cs rename to src/libse/SubtitleFormats/SamiYouTube.cs index 0624c5585..f2bc14af9 100644 --- a/libse/SubtitleFormats/SamiYouTube.cs +++ b/src/libse/SubtitleFormats/SamiYouTube.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SamiYouTube : Sami - { - public override string Name => "SAMI YouTube"; - } -} +using System.Collections.Generic; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SamiYouTube : Sami + { + public override string Name => "SAMI YouTube"; + } +} diff --git a/libse/SubtitleFormats/SatBoxPng.cs b/src/libse/SubtitleFormats/SatBoxPng.cs similarity index 97% rename from libse/SubtitleFormats/SatBoxPng.cs rename to src/libse/SubtitleFormats/SatBoxPng.cs index 428a5b1ec..4490296ec 100644 --- a/libse/SubtitleFormats/SatBoxPng.cs +++ b/src/libse/SubtitleFormats/SatBoxPng.cs @@ -1,94 +1,94 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - /// http://forum.videohelp.com/threads/365786-Converting-Subtitles-%28XML-PNG%29-to-idx-sub - /// - public class SatBoxPng : SubtitleFormat - { - public override string Extension => ".txt"; - - public override string Name => "SatBox png"; - - public override string ToText(Subtitle subtitle, string title) - { - return "Not implemented"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - // - Paragraph p = null; - subtitle.Paragraphs.Clear(); - _errorCount = 0; - if (string.IsNullOrEmpty(fileName)) - { - return; - } - - string path = Path.GetDirectoryName(fileName); - foreach (string line in lines) - { - if (line.Contains(" s=\"") && line.Contains(" e=\"") && line.Contains(" i=\"") && line.Contains(".png") && (line.Contains("= 0 && File.Exists(Path.Combine(path, text.Remove(0, indexOfSlash + 1)))) - { - text = Path.Combine(path, text.Remove(0, indexOfSlash + 1)); - } - } - p = new Paragraph(DecodeTimeCode(start), DecodeTimeCode(end), text); - subtitle.Paragraphs.Add(p); - } - catch (Exception exception) - { - _errorCount++; - System.Diagnostics.Debug.WriteLine(exception.Message); - } - } - else if (!string.IsNullOrWhiteSpace(line) && p != null) - { - _errorCount++; - } - } - subtitle.Renumber(); - } - - private static string GetTagValue(string tag, string line) - { - var start = line.IndexOf(tag + "=\"", StringComparison.Ordinal); - if (start > 0 && line.Length > start + 4) - { - int end = line.IndexOf('"', start + 3); - if (end > 0 && line.Length > end + 3) - { - string value = line.Substring(start + 3, end - start - 3); - return value; - } - } - return string.Empty; - } - - private static TimeCode DecodeTimeCode(string s) - { - return TimeCode.FromSeconds(double.Parse(s, CultureInfo.InvariantCulture)); - } - - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + /// + /// http://forum.videohelp.com/threads/365786-Converting-Subtitles-%28XML-PNG%29-to-idx-sub + /// + public class SatBoxPng : SubtitleFormat + { + public override string Extension => ".txt"; + + public override string Name => "SatBox png"; + + public override string ToText(Subtitle subtitle, string title) + { + return "Not implemented"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + // + Paragraph p = null; + subtitle.Paragraphs.Clear(); + _errorCount = 0; + if (string.IsNullOrEmpty(fileName)) + { + return; + } + + string path = Path.GetDirectoryName(fileName); + foreach (string line in lines) + { + if (line.Contains(" s=\"") && line.Contains(" e=\"") && line.Contains(" i=\"") && line.Contains(".png") && (line.Contains("= 0 && File.Exists(Path.Combine(path, text.Remove(0, indexOfSlash + 1)))) + { + text = Path.Combine(path, text.Remove(0, indexOfSlash + 1)); + } + } + p = new Paragraph(DecodeTimeCode(start), DecodeTimeCode(end), text); + subtitle.Paragraphs.Add(p); + } + catch (Exception exception) + { + _errorCount++; + System.Diagnostics.Debug.WriteLine(exception.Message); + } + } + else if (!string.IsNullOrWhiteSpace(line) && p != null) + { + _errorCount++; + } + } + subtitle.Renumber(); + } + + private static string GetTagValue(string tag, string line) + { + var start = line.IndexOf(tag + "=\"", StringComparison.Ordinal); + if (start > 0 && line.Length > start + 4) + { + int end = line.IndexOf('"', start + 3); + if (end > 0 && line.Length > end + 3) + { + string value = line.Substring(start + 3, end - start - 3); + return value; + } + } + return string.Empty; + } + + private static TimeCode DecodeTimeCode(string s) + { + return TimeCode.FromSeconds(double.Parse(s, CultureInfo.InvariantCulture)); + } + + } +} diff --git a/libse/SubtitleFormats/Scenarist.cs b/src/libse/SubtitleFormats/Scenarist.cs similarity index 97% rename from libse/SubtitleFormats/Scenarist.cs rename to src/libse/SubtitleFormats/Scenarist.cs index 0137e7b13..14a2df55c 100644 --- a/libse/SubtitleFormats/Scenarist.cs +++ b/src/libse/SubtitleFormats/Scenarist.cs @@ -1,95 +1,95 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Scenarist : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d\d\d\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public const string NameOfFormat = "Scenarist"; - - public override string Name => NameOfFormat; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - int index = 0; - foreach (var p in subtitle.Paragraphs) - { - //0003 00:00:28:16 00:00:31:04 Jeg vil lære jer frygten for HERREN." (newline is \t) - sb.AppendLine($"{index + 1:0000}\t{EncodeTimeCode(p.StartTime)}\t{EncodeTimeCode(p.EndTime)}\t{HtmlUtil.RemoveHtmlTags(p.Text).Replace(Environment.NewLine, "\t")}"); - index++; - } - return sb.ToString(); - } - - private static string EncodeTimeCode(TimeCode time) - { - //00:03:15:22 (last is frame) - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - //00:03:15:22 00:03:23:10 This is line one. - //This is line two. - Paragraph p = null; - subtitle.Paragraphs.Clear(); - _errorCount = 0; - foreach (var line in lines) - { - if (RegexTimeCodes.IsMatch(line)) - { - var temp = line.Substring(0, RegexTimeCodes.Match(line).Length); - var start = temp.Substring(5, 11); - var end = temp.Substring(12 + 5, 11); - - var startParts = start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); - var endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); - if (startParts.Length == 4 && endParts.Length == 4) - { - var text = line.Remove(0, RegexTimeCodes.Match(line).Length - 1).Trim(); - if (!text.Contains(Environment.NewLine)) - { - text = text.Replace("\t", Environment.NewLine); - } - - p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text); - subtitle.Paragraphs.Add(p); - } - } - else if (string.IsNullOrWhiteSpace(line)) - { - // skip these lines - } - else if (p != null) - { - _errorCount++; - } - } - - for (var index = 0; index < subtitle.Paragraphs.Count - 1; index++) - { - var current = subtitle.Paragraphs[index]; - var next = subtitle.Paragraphs[index + 1]; - if (Math.Abs(current.EndTime.TotalMilliseconds - next.StartTime.TotalMilliseconds) < 0.01) - { - if (current.EndTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines > - current.StartTime.TotalMilliseconds) - { - current.EndTime.TotalMilliseconds -= Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Scenarist : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d\d\d\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public const string NameOfFormat = "Scenarist"; + + public override string Name => NameOfFormat; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + int index = 0; + foreach (var p in subtitle.Paragraphs) + { + //0003 00:00:28:16 00:00:31:04 Jeg vil lære jer frygten for HERREN." (newline is \t) + sb.AppendLine($"{index + 1:0000}\t{EncodeTimeCode(p.StartTime)}\t{EncodeTimeCode(p.EndTime)}\t{HtmlUtil.RemoveHtmlTags(p.Text).Replace(Environment.NewLine, "\t")}"); + index++; + } + return sb.ToString(); + } + + private static string EncodeTimeCode(TimeCode time) + { + //00:03:15:22 (last is frame) + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + //00:03:15:22 00:03:23:10 This is line one. + //This is line two. + Paragraph p = null; + subtitle.Paragraphs.Clear(); + _errorCount = 0; + foreach (var line in lines) + { + if (RegexTimeCodes.IsMatch(line)) + { + var temp = line.Substring(0, RegexTimeCodes.Match(line).Length); + var start = temp.Substring(5, 11); + var end = temp.Substring(12 + 5, 11); + + var startParts = start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); + var endParts = end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); + if (startParts.Length == 4 && endParts.Length == 4) + { + var text = line.Remove(0, RegexTimeCodes.Match(line).Length - 1).Trim(); + if (!text.Contains(Environment.NewLine)) + { + text = text.Replace("\t", Environment.NewLine); + } + + p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), text); + subtitle.Paragraphs.Add(p); + } + } + else if (string.IsNullOrWhiteSpace(line)) + { + // skip these lines + } + else if (p != null) + { + _errorCount++; + } + } + + for (var index = 0; index < subtitle.Paragraphs.Count - 1; index++) + { + var current = subtitle.Paragraphs[index]; + var next = subtitle.Paragraphs[index + 1]; + if (Math.Abs(current.EndTime.TotalMilliseconds - next.StartTime.TotalMilliseconds) < 0.01) + { + if (current.EndTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines > + current.StartTime.TotalMilliseconds) + { + current.EndTime.TotalMilliseconds -= Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/ScenaristClosedCaptions.cs b/src/libse/SubtitleFormats/ScenaristClosedCaptions.cs similarity index 97% rename from libse/SubtitleFormats/ScenaristClosedCaptions.cs rename to src/libse/SubtitleFormats/ScenaristClosedCaptions.cs index abaf2fa73..e393dc870 100644 --- a/libse/SubtitleFormats/ScenaristClosedCaptions.cs +++ b/src/libse/SubtitleFormats/ScenaristClosedCaptions.cs @@ -1,1204 +1,1204 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - - /// - /// http://www.theneitherworld.com/mcpoodle/SCC_TOOLS/DOCS/SCC_FORMAT.HTML - /// § 15.119 47 CFR Ch. I (10–1–10 Edition) (pdf) - /// Maximum four lines + max 32 characters on each line - /// - public class ScenaristClosedCaptions : SubtitleFormat - { - //00:01:00:29 9420 9420 94ae 94ae 94d0 94d0 4920 f761 7320 ... semi colon (instead of colon) before frame number is used to indicate drop frame - private const string TimeCodeRegEx = @"^\d+:\d\d:\d\d[:,]\d\d\t"; - private static readonly Regex Regex = new Regex(TimeCodeRegEx, RegexOptions.Compiled); - protected virtual Regex RegexTimeCodes => Regex; - protected bool DropFrame; - - private static readonly List> LetterDictionary = new List> - { - new KeyValuePair("20", " " ), - new KeyValuePair("a1", "!" ), - new KeyValuePair("a2", "\""), - new KeyValuePair("23", "#" ), - new KeyValuePair("a4", "$" ), - new KeyValuePair("25", "%" ), - new KeyValuePair("26", "&" ), - new KeyValuePair("a7", "'" ), - new KeyValuePair("a8", "(" ), - new KeyValuePair("29", ")" ), - new KeyValuePair("2a", "á" ), - new KeyValuePair("ab", "+" ), - new KeyValuePair("2c", "," ), - new KeyValuePair("ad", "-" ), - new KeyValuePair("ae", "." ), - new KeyValuePair("2f", "/" ), - new KeyValuePair("b0", "0" ), - new KeyValuePair("31", "1" ), - new KeyValuePair("32", "2" ), - new KeyValuePair("b3", "3" ), - new KeyValuePair("34", "4" ), - new KeyValuePair("b5", "5" ), - new KeyValuePair("b6", "6" ), - new KeyValuePair("37", "7" ), - new KeyValuePair("38", "8" ), - new KeyValuePair("b9", "9" ), - new KeyValuePair("ba", ":" ), - new KeyValuePair("3b", ";" ), - new KeyValuePair("bc", "<" ), - new KeyValuePair("3d", "=" ), - new KeyValuePair("3e", ">" ), - new KeyValuePair("bf", "?" ), - new KeyValuePair("40", "@" ), - new KeyValuePair("c1", "A" ), - new KeyValuePair("c2", "B" ), - new KeyValuePair("43", "C" ), - new KeyValuePair("c4", "D" ), - new KeyValuePair("45", "E" ), - new KeyValuePair("46", "F" ), - new KeyValuePair("c7", "G" ), - new KeyValuePair("c8", "H" ), - new KeyValuePair("49", "I" ), - new KeyValuePair("4a", "J" ), - new KeyValuePair("cb", "K" ), - new KeyValuePair("4c", "L" ), - new KeyValuePair("cd", "M" ), - new KeyValuePair("ce", "N" ), - new KeyValuePair("4f", "O" ), - new KeyValuePair("d0", "P" ), - new KeyValuePair("51", "Q" ), - new KeyValuePair("52", "R" ), - new KeyValuePair("d3", "S" ), - new KeyValuePair("54", "T" ), - new KeyValuePair("d5", "U" ), - new KeyValuePair("d6", "V" ), - new KeyValuePair("57", "W" ), - new KeyValuePair("58", "X" ), - new KeyValuePair("d9", "Y" ), - new KeyValuePair("da", "Z" ), - new KeyValuePair("5b", "[" ), - new KeyValuePair("dc", "é" ), - new KeyValuePair("5d", "]" ), - new KeyValuePair("5e", "í" ), - new KeyValuePair("df", "ó" ), - new KeyValuePair("e0", "ú" ), - new KeyValuePair("61", "a" ), - new KeyValuePair("62", "b" ), - new KeyValuePair("e3", "c" ), - new KeyValuePair("64", "d" ), - new KeyValuePair("e5", "e" ), - new KeyValuePair("e6", "f" ), - new KeyValuePair("67", "g" ), - new KeyValuePair("68", "h" ), - new KeyValuePair("e9", "i" ), - new KeyValuePair("ea", "j" ), - new KeyValuePair("6b", "k" ), - new KeyValuePair("ec", "l" ), - new KeyValuePair("6d", "m" ), - new KeyValuePair("ef", "o" ), - new KeyValuePair("70", "p" ), - new KeyValuePair("f1", "q" ), - new KeyValuePair("f2", "r" ), - new KeyValuePair("73", "s" ), - new KeyValuePair("f4", "t" ), - new KeyValuePair("75", "u" ), - new KeyValuePair("76", "v" ), - new KeyValuePair("f7", "w" ), - new KeyValuePair("f8", "x" ), - new KeyValuePair("fb", "ç" ), - new KeyValuePair("79", "y" ), - new KeyValuePair("7a", "z" ), - new KeyValuePair("7c", "" ), - new KeyValuePair("fd", "Ñ" ), - new KeyValuePair("fe", "ñ" ), - new KeyValuePair("7f", "■" ), - new KeyValuePair("7b", "ç" ), - new KeyValuePair("63", "c" ), - new KeyValuePair("65", "e" ), - new KeyValuePair("66", "f" ), - new KeyValuePair("69", "i" ), - new KeyValuePair("6a", "j" ), - new KeyValuePair("6c", "l" ), - new KeyValuePair("6e", "n" ), - new KeyValuePair("6f", "o" ), - new KeyValuePair("71", "q" ), - new KeyValuePair("72", "r" ), - new KeyValuePair("74", "t" ), - new KeyValuePair("77", "w" ), - new KeyValuePair("78", "x" ), - new KeyValuePair("91b0", "" ), - new KeyValuePair("91b3", "" ), - new KeyValuePair("91b5", "" ), - new KeyValuePair("91b6", "£" ), - new KeyValuePair("9137", "♪" ), - new KeyValuePair("9138", "à" ), - new KeyValuePair("91b9", "" ), - new KeyValuePair("91ba", "è" ), - new KeyValuePair("913b", "â" ), - new KeyValuePair("91bc", "ê" ), - new KeyValuePair("913d", "î" ), - new KeyValuePair("913e", "ô" ), - new KeyValuePair("91bf", "û" ), - new KeyValuePair("9220", "Á" ), - new KeyValuePair("92a1", "É" ), - new KeyValuePair("92a2", "Ó" ), - new KeyValuePair("9223", "Ú" ), - new KeyValuePair("92a4", "Ü" ), - new KeyValuePair("9225", "ü" ), - new KeyValuePair("9226", "'" ), - new KeyValuePair("92a7", "i" ), - new KeyValuePair("92a8", "*" ), - new KeyValuePair("9229", "'" ), - new KeyValuePair("922a", "-" ), - new KeyValuePair("92ab", "" ), - new KeyValuePair("922c", "" ), - new KeyValuePair("92ad", "\""), - new KeyValuePair("92ae", "\""), - new KeyValuePair("922f", "" ), - new KeyValuePair("92b0", "À" ), - new KeyValuePair("9231", "Â" ), - new KeyValuePair("9232", "Ç" ), - new KeyValuePair("92b3", "È" ), - new KeyValuePair("9234", "Ê" ), - new KeyValuePair("92b5", "Ë" ), - new KeyValuePair("92b6", "ë" ), - new KeyValuePair("9237", "Î" ), - new KeyValuePair("9238", "Ï" ), - new KeyValuePair("92b9", "ï" ), - new KeyValuePair("923b", "Ù" ), - new KeyValuePair("923d", "Û" ), - new KeyValuePair("923e", "" ), - new KeyValuePair("92bf", "" ), - new KeyValuePair("1320", "Ã" ), - new KeyValuePair("c1 1320", "Ã" ), - new KeyValuePair("c180 1320", "Ã" ), - new KeyValuePair("13a1", "ã" ), - new KeyValuePair("80 13a1", "ã" ), - new KeyValuePair("6180 13a1", "ã" ), - new KeyValuePair("13a2", "Í" ), - new KeyValuePair("49 13a2", "Í" ), - new KeyValuePair("4980 13a2", "Í" ), - new KeyValuePair("1323", "Ì" ), - new KeyValuePair("49 1323", "Ì" ), - new KeyValuePair("4980 1323", "Ì" ), - new KeyValuePair("13a4", "ì" ), - new KeyValuePair("e9 13a4", "ì" ), - new KeyValuePair("e980 13a4", "ì" ), - new KeyValuePair("1325", "Ò" ), - new KeyValuePair("4f 1325", "Ò" ), - new KeyValuePair("4f80 1325", "Ò" ), - new KeyValuePair("1326", "ò" ), - new KeyValuePair("ef 1326", "ò" ), - new KeyValuePair("ef80 1326", "ò" ), - new KeyValuePair("13a7", "Õ" ), - new KeyValuePair("4f 13a7", "Õ" ), - new KeyValuePair("4f80 13a7", "Õ" ), - new KeyValuePair("13a8", "õ" ), - new KeyValuePair("ef 13a8", "õ" ), - new KeyValuePair("ef80 13a8", "õ" ), - new KeyValuePair("1329", "{" ), - new KeyValuePair("132a", "}" ), - new KeyValuePair("13ab", "\\"), - new KeyValuePair("132c", "^" ), - new KeyValuePair("13ad", "_" ), - new KeyValuePair("13ae", "|" ), - new KeyValuePair("132f", "~" ), - new KeyValuePair("13b0", "Ä" ), - new KeyValuePair("c180 13b0", "Ä" ), - new KeyValuePair("1331", "ä" ), - new KeyValuePair("6180 1331", "ä" ), - new KeyValuePair("1332", "Ö" ), - new KeyValuePair("4f80 1332", "Ö" ), - new KeyValuePair("13b3", "ö" ), - new KeyValuePair("ef80 13b3", "ö" ), - new KeyValuePair("1334", "" ), - new KeyValuePair("13b5", "" ), - new KeyValuePair("13b6", "" ), - new KeyValuePair("1337", "|" ), - new KeyValuePair("1338", "Å" ), - new KeyValuePair("13b9", "å" ), - new KeyValuePair("4f80 13ba 13ba", "Ø" ), - new KeyValuePair("133b", "ø" ), - new KeyValuePair("133d", "" ), - new KeyValuePair("133e", "" ), - new KeyValuePair("13bf", "" ), - new KeyValuePair("9420", "" ), //9420=RCL, Resume Caption Loading - new KeyValuePair("94ae", "" ), //94ae=Clear Buffer - new KeyValuePair("942c", "" ), //942c=Clear Caption - new KeyValuePair("8080", "" ), //8080=Wait One Frame - new KeyValuePair("942f", "" ), //942f=Display Caption - new KeyValuePair("9440", "" ), //9440=? first sub? - new KeyValuePair("9452", "" ), //? - new KeyValuePair("9454", "" ), //? - new KeyValuePair("9470", "" ), //9470=? - new KeyValuePair("94d0", "" ), //94d0=? - new KeyValuePair("94d6", "" ), //94d6=? - new KeyValuePair("94f2", "" ), - new KeyValuePair("94f4", "" ), - new KeyValuePair("9723", " " ), // ? - new KeyValuePair("97a1", " " ), // ? - new KeyValuePair("97a2", " " ), // ? - new KeyValuePair("1370", "" ), //1370=? - new KeyValuePair("13e0", "" ), //13e0=? - new KeyValuePair("13f2", "" ), //13f2=? - new KeyValuePair("136e", "" ), //136e=? - new KeyValuePair("94ce", "" ), //94ce=? - new KeyValuePair("2c2f", "" ), //? - new KeyValuePair("1130", "®" ), - new KeyValuePair("1131", "°" ), - new KeyValuePair("1132", "½" ), - new KeyValuePair("1133", "¿" ), - new KeyValuePair("1134", "TM"), - new KeyValuePair("1135", "¢" ), - new KeyValuePair("1136", "£" ), - new KeyValuePair("1137", "♪" ), - new KeyValuePair("1138", "à" ), - new KeyValuePair("113a", "è" ), - new KeyValuePair("113b", "â" ), - new KeyValuePair("113c", "ê" ), - new KeyValuePair("113d", "î" ), - new KeyValuePair("113e", "ô" ), - new KeyValuePair("113f", "û" ), - new KeyValuePair("9130", "®" ), - new KeyValuePair("9131", "°" ), - new KeyValuePair("9132", "½" ), - new KeyValuePair("9133", "¿" ), - new KeyValuePair("9134", "TM"), - new KeyValuePair("9135", "¢" ), - new KeyValuePair("9136", "£" ), - new KeyValuePair("913a", "è" ), - new KeyValuePair("913c", "ê" ), - new KeyValuePair("913f", "û" ), - new KeyValuePair("a180 92a7 92a7", "¡" ), - new KeyValuePair("92a7 92a7", "¡" ), - new KeyValuePair("91b3 91b3", "¿" ), - - new KeyValuePair("6180 9138 9138", "à"), //61=a - new KeyValuePair("9138 9138", "à"), - - new KeyValuePair("6180 913b 913b", "â"), - new KeyValuePair("913b 913b", "â"), - - new KeyValuePair("6180 1331 1331", "ä"), - new KeyValuePair("1331 1331", "ä"), - - new KeyValuePair("e580 91ba 91ba", "è"), - new KeyValuePair("6180 91ba 91ba", "è"), - new KeyValuePair("91ba 91ba", "è"), - - new KeyValuePair("e580 91bc 91bc", "ê"), - new KeyValuePair("6180 91bc 91bc", "ê"), - new KeyValuePair("91bc 91bc", "ê"), - - - new KeyValuePair("e580 92b6 92b6", "ë"), //e5=e (+65?) - new KeyValuePair("6580 92b6 92b6", "ë"), - new KeyValuePair("92b6 92b6", "ë"), - - new KeyValuePair("e980 13a4 13a4", "ì"), //e9 = i - new KeyValuePair("13a4 13a4", "ì"), - - new KeyValuePair("e980 913d 913d", "î"), - new KeyValuePair("913d 913d", "î"), - - new KeyValuePair("e980 92b9 92b9", "ï"), - new KeyValuePair("92b9 92b9", "ï"), - - new KeyValuePair("1326 1326", "ò"), //o=ef or 6f - new KeyValuePair("ef80 1326 1326", "ò"), - new KeyValuePair("6f80 1326 1326", "ò"), - - new KeyValuePair("913e 913e", "ô"), - new KeyValuePair("ef80 913e 913e", "ô"), - new KeyValuePair("6f80 913e 913e", "ô"), - - new KeyValuePair("13b3 13b3", "ö"), - new KeyValuePair("ef80 13b3 13b3", "ö"), - new KeyValuePair("6f80 13b3 13b3", "ö"), - - new KeyValuePair("7580 13b3 13b3", "ù"), //u=75 - - new KeyValuePair("7580 92bc 92bc", "ù"), - new KeyValuePair("92bc 92bc", "ù"), - - new KeyValuePair("7580 91bf 91bf", "û"), - new KeyValuePair("91bf 91bf", "û"), - - new KeyValuePair("7580 9225 9225", "ü"), - new KeyValuePair("9225 9225", "ü"), - - new KeyValuePair("4380 9232 9232", "Ç"), //43=C - new KeyValuePair("9232 9232", "Ç"), - - new KeyValuePair("c180 1338 1338", "Å"), //c1=A - new KeyValuePair("1338 1338", "Å"), - - new KeyValuePair("c180 92b0 92b0", "À"), - new KeyValuePair("92b0 92b0", "À"), - - new KeyValuePair("c180 9220 9220", "Á"), - new KeyValuePair("9220 9220", "Á"), - - new KeyValuePair("c180 9231 9231", "Â"), - new KeyValuePair("9231 9231", "Â"), - - new KeyValuePair("c180 1320 1320", "Ã"), - new KeyValuePair("1320 1320", "Ã"), - - new KeyValuePair("c180 13b0 13b0", "Ä"), - new KeyValuePair("13b0 13b0", "Ä"), - - new KeyValuePair("4580 92b3 92b3", "È"), - new KeyValuePair("92b3 92b3", "È"), - - new KeyValuePair("4580 92a1 92a1", "É"), - new KeyValuePair("92a1 92a1", "É"), - - new KeyValuePair("4580 9234 9234", "Ê"), - new KeyValuePair("9234 9234", "Ê"), - - new KeyValuePair("4580 92b5 92b5", "Ë"), - new KeyValuePair("92b5 92b5", "Ë"), - - new KeyValuePair("4980 1323 1323", "Ì"), - new KeyValuePair("1323 1323", "Ì"), - - new KeyValuePair("4980 13a2 13a2", "Í"), - new KeyValuePair("13a2 13a2", "Í"), - - new KeyValuePair("4980 9237 9237", "Î"), - new KeyValuePair("9237 9237", "Î"), - - new KeyValuePair("4980 9238 9238", "Ï"), - new KeyValuePair("9238 9238", "Ï"), - - new KeyValuePair("4f80 92a2 92a2", "Ó"), //4f=O - new KeyValuePair("92a2 92a2", "Ó"), - - new KeyValuePair("4f80 1325 1325", "Ò"), - new KeyValuePair("1325 1325", "Ò"), - - new KeyValuePair("4f80 92ba 92ba", "Ô"), - new KeyValuePair("92ba 92ba", "Ô"), - - new KeyValuePair("4f80 13a7 13a7", "Õ"), - new KeyValuePair("13a7 13a7", "Õ"), - - new KeyValuePair("4f80 1332 1332", "Ö"), - new KeyValuePair("1332 1332", "Ö"), - - new KeyValuePair("d580 9223 9223", "Ú"), - new KeyValuePair("923d 923d", "Û"), - - new KeyValuePair("d580 923b 923b", "Ù"), - new KeyValuePair("9223 9223", "Ú"), - - new KeyValuePair("d580 92a4 92a4", "Ü"), - new KeyValuePair("92a4 92a4", "Ü"), - - new KeyValuePair("d580 923d 923d", "Û"), - }; - - private static readonly Dictionary LettersCodeLookup = LetterDictionary.ToDictionary(p => p.Key, p => p.Value); - - public override string Extension => ".scc"; - - public override string Name => "Scenarist Closed Captions"; - - private static string FixMax4LinesAndMax32CharsPerLine(string text, string language) - { - // fix attempt 1 - var lines = text.Trim().SplitToLines(); - if (IsAllOkay(lines)) - { - return text; - } - - // fix attempt 2 - text = Utilities.AutoBreakLine(text, 1, 4, language); - lines = text.Trim().SplitToLines(); - if (IsAllOkay(lines)) - { - return text; - } - - // fix attempt 3 - text = AutoBreakLineMax4Lines(text, 32); - lines = text.Trim().SplitToLines(); - if (IsAllOkay(lines)) - { - return text; - } - - var sb = new StringBuilder(); - int count = 0; - foreach (var line in lines) - { - if (count < 4) - { - sb.AppendLine(line.Length > 32 ? line.Substring(0, 32) : line); - } - count++; - } - return sb.ToString().Trim(); - } - - private static bool IsAllOkay(List lines) - { - return lines.Count <= 4 && lines.All(line => line.Length <= 32); - } - - private static int GetLastIndexOfSpace(string s, int endCount) - { - var end = Math.Min(endCount, s.Length - 1); - while (end > 0) - { - if (s[end] == ' ') - { - return end; - } - - end--; - } - return -1; - } - - private static string AutoBreakLineMax4Lines(string text, int maxLength) - { - string s = text.Replace(Environment.NewLine, " "); - s = s.Replace(" ", " "); - var sb = new StringBuilder(); - int i = GetLastIndexOfSpace(s, maxLength); - if (i > 0) - { - sb.AppendLine(s.Substring(0, i)); - s = s.Remove(0, i).Trim(); - i = s.Length <= maxLength ? s.Length : GetLastIndexOfSpace(s, maxLength); - - if (i > 0) - { - sb.AppendLine(s.Substring(0, i)); - s = s.Remove(0, i).Trim(); - i = s.Length <= maxLength ? s.Length : GetLastIndexOfSpace(s, maxLength); - - if (i > 0) - { - sb.AppendLine(s.Substring(0, i)); - s = s.Remove(0, i).Trim(); - i = s.Length <= maxLength ? s.Length : GetLastIndexOfSpace(s, maxLength); - - if (i > 0) - { - sb.AppendLine(s.Substring(0, i)); - } - else - { - sb.Append(s); - } - } - else - { - sb.Append(s); - } - } - return sb.ToString().Trim(); - } - return text; - } - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - sb.AppendLine("Scenarist_SCC V1.0"); - sb.AppendLine(); - string language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); - for (int i = 0; i < subtitle.Paragraphs.Count; i++) - { - var p = subtitle.Paragraphs[i]; - sb.AppendLine($"{ToTimeCode(p.StartTime.TotalMilliseconds)}\t94ae 94ae 9420 9420 {ToSccText(p.Text, language)} 942f 942f"); - sb.AppendLine(); - - var next = subtitle.GetParagraphOrDefault(i + 1); - if (next == null || Math.Abs(next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds) > 100) - { - sb.AppendLine($"{ToTimeCode(p.EndTime.TotalMilliseconds)}\t942c 942c"); - sb.AppendLine(); - } - } - return sb.ToString(); - } - - private static string ToSccText(string text, string language) - { - text = FixMax4LinesAndMax32CharsPerLine(text, language); - var topAlign = text.StartsWith("{\\an7}", StringComparison.Ordinal) || - text.StartsWith("{\\an8}", StringComparison.Ordinal) || - text.StartsWith("{\\an9}", StringComparison.Ordinal); - - var leftAlign = text.StartsWith("{\\an7}", StringComparison.Ordinal) || - text.StartsWith("{\\an4}", StringComparison.Ordinal) || - text.StartsWith("{\\an1}", StringComparison.Ordinal); - - var rightAlign = text.StartsWith("{\\an9}", StringComparison.Ordinal) || - text.StartsWith("{\\an6}", StringComparison.Ordinal) || - text.StartsWith("{\\an3}", StringComparison.Ordinal); - - var verticalCenter = text.StartsWith("{\\an4}", StringComparison.Ordinal) || - text.StartsWith("{\\an5}", StringComparison.Ordinal) || - text.StartsWith("{\\an6}", StringComparison.Ordinal); - - text = Utilities.RemoveSsaTags(text); - var lines = text.Trim().SplitToLines(); - int italic = 0; - var sb = new StringBuilder(); - int count = 1; - foreach (var line in lines) - { - text = line.Trim(); - if (count > 0) - { - sb.Append(' '); - } - - var centerCodes = GetCenterCodes(text, count, lines.Count, topAlign, leftAlign, rightAlign, verticalCenter); - sb.Append(centerCodes); - count++; - int i = 0; - string code = string.Empty; - if (italic > 0) - { - sb.Append("91ae 91ae "); // italic - } - - while (i < text.Length) - { - string s = text.Substring(i, 1); - string codeFromLetter = GetCodeFromLetter(s); - string newCode; - if (text.Substring(i).StartsWith("", StringComparison.Ordinal)) - { - newCode = "91ae"; - i += 2; - italic++; - } - else if (text.Substring(i).StartsWith("", StringComparison.Ordinal) && italic > 0) - { - newCode = "9120"; - i += 3; - italic--; - } - else if (text[i] == '’') - { - if (code.Length == 4) - { - sb.Append(code + " "); - code = string.Empty; - } - - if (code.Length == 0) - { - code = "80"; - } - - if (code.Length == 2) - { - code += "a7"; - sb.Append(code + " "); - } - - code = "9229"; - newCode = ""; - } - else if (codeFromLetter == null) - { - newCode = GetCodeFromLetter(" "); - } - else - { - newCode = codeFromLetter; - } - - if (code.Length == 2 && newCode.Length == 4) - { - code += "80"; - } - - if (code.Length == 4) - { - sb.Append(code + " "); - if (code.StartsWith('9') || code.StartsWith('8')) // control codes must be double - { - sb.Append(code + " "); - } - - code = string.Empty; - } - - if (code.Length == 2 && newCode.Length == 2) - { - code += newCode; - newCode = string.Empty; - } - - if (newCode.Length == 4 && code.Length == 0) - { - code = newCode; - } - else if (newCode.Length == 2 && code.Length == 0) - { - code = newCode; - } - else if (newCode.Length > 4) - { - if (code.Length == 2) - { - code += "80"; - sb.Append(code + " "); - if (code.StartsWith('9') || code.StartsWith('8')) // control codes must be double - { - sb.Append(code + " "); - } - - code = string.Empty; - } - else if (code.Length == 4) - { - sb.Append(code + " "); - if (code.StartsWith('9') || code.StartsWith('8')) // control codes must be double - { - sb.Append(code + " "); - } - - code = string.Empty; - } - - sb.Append(newCode.TrimEnd() + " "); - } - - i++; - } - - if (code.Length == 2) - { - code += "80"; - } - - if (code.Length == 4) - { - sb.Append(code); - } - } - - return sb.ToString().Trim(); - } - - private static string GetCodeFromLetter(string letter) - { - var code = LetterDictionary.FirstOrDefault(x => x.Value == letter); - if (code.Equals(new KeyValuePair())) - { - return null; - } - - return code.Key; - } - - private static string GetLetterFromCode(string hexCode) - { - return LettersCodeLookup.TryGetValue(hexCode, out var letter) ? letter : null; - } - - public static string GetCenterCodes(string text, int lineNumber, int totalLines, bool topAlign, bool leftAlign, bool rightAlign, bool verticalCenter) - { - var row = 14 - (totalLines - lineNumber); - if (topAlign) - { - row = lineNumber; - } - else if (verticalCenter) - { - row = 6 - totalLines / 2 + lineNumber; - } - var rowCodes = new List { "91", "91", "92", "92", "15", "15", "16", "16", "97", "97", "10", "13", "13", "94", "94" }; - var rowCode = rowCodes[row]; - - var left = (32 - text.Length) / 2; - if (leftAlign) - { - left = 0; - } - else if (rightAlign) - { - left = 32 - text.Length; - } - int columnRest = left % 4; - int column = left - columnRest; - - List columnCodes; - switch (column) - { - case 0: - columnCodes = new List { "d0", "70", "d0", "70", "d0", "70", "d0", "70", "d0", "70", "d0", "d0", "70", "d0", "70" }; - break; - case 4: - columnCodes = new List { "52", "f2", "52", "f2", "52", "f2", "52", "f2", "52", "f2", "52", "52", "f2", "52", "f2" }; - break; - case 8: - columnCodes = new List { "54", "f4", "54", "f4", "54", "f4", "54", "f4", "54", "f4", "54", "54", "f4", "54", "f4" }; - break; - case 12: - columnCodes = new List { "d6", "76", "d6", "76", "d6", "76", "d6", "76", "d6", "76", "d6", "d6", "76", "d6", "76" }; - break; - case 16: - columnCodes = new List { "58", "f8", "58", "f8", "58", "f8", "58", "f8", "58", "f8", "58", "58", "f8", "58", "f8" }; - break; - case 20: - columnCodes = new List { "da", "7a", "da", "7a", "da", "7a", "da", "7a", "da", "7a", "da", "da", "7a", "da", "7a" }; - break; - case 24: - columnCodes = new List { "dc", "7c", "dc", "7c", "dc", "7c", "dc", "7c", "dc", "7c", "dc", "dc", "7c", "dc", "7c" }; - break; - default: // 28 - columnCodes = new List { "5e", "fe", "5e", "fe", "5e", "fe", "5e", "fe", "5e", "fe", "5e", "5e", "fe", "5e", "fe" }; - break; - } - var code = rowCode + columnCodes[row]; - - if (columnRest == 1) - { - return code + " " + code + " 97a1 97a1 "; - } - - if (columnRest == 2) - { - return code + " " + code + " 97a2 97a2 "; - } - - if (columnRest == 3) - { - return $"{code} {code} 9723 9723 "; - } - - return $"{code} {code} "; - } - - private string ToTimeCode(double totalMilliseconds) - { - var ts = TimeSpan.FromMilliseconds(totalMilliseconds); - if (DropFrame) - { - return $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00};{MillisecondsToFramesMaxFrameRate(ts.Milliseconds):00}"; - } - - return $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}:{MillisecondsToFramesMaxFrameRate(ts.Milliseconds):00}"; - } - - private static Dictionary _styleLookup; - public static SccPositionAndStyle GetColorAndPosition(string code) - { - if (_styleLookup == null) - { - _styleLookup = SccPositionAndStyleTable.SccPositionAndStyles.ToDictionary(p => p.Code, p => p); - } - - return _styleLookup.TryGetValue(code, out var style) ? style : null; - } - - public static string GetCodeFromPositionAndColor(int x, int y, FontStyle fontStyle, Color color) - { - var match = SccPositionAndStyleTable.SccPositionAndStyles.FirstOrDefault(p => p.X == x && p.Y == y && p.Style == fontStyle && p.ForeColor == color); - return match == null ? string.Empty : match.Code; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - Paragraph p = null; - foreach (string line in lines) - { - var s = line.Trim(); - var match = RegexTimeCodes.Match(s); - if (match.Success) - { - var startTime = ParseTimeCode(s.Substring(0, match.Length - 1)); - var text = GetSccText(s.Substring(match.Index), ref _errorCount); - - if (text == "942c 942c" || text == "942c") - { - if (p != null) - { - p.EndTime.TotalMilliseconds = startTime.TotalMilliseconds; - } - } - else - { - p = new Paragraph(startTime, new TimeCode(startTime.TotalMilliseconds), text); - subtitle.Paragraphs.Add(p); - } - } - } - for (int i = subtitle.Paragraphs.Count - 2; i >= 0; i--) - { - p = subtitle.GetParagraphOrDefault(i); - var next = subtitle.GetParagraphOrDefault(i + 1); - if (p != null && next != null && Math.Abs(p.EndTime.TotalMilliseconds - p.StartTime.TotalMilliseconds) < 0.001) - { - p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds; - } - - if (next != null && string.IsNullOrEmpty(next.Text)) - { - subtitle.Paragraphs.Remove(next); - } - } - - p = subtitle.GetParagraphOrDefault(0); - if (p != null && string.IsNullOrEmpty(p.Text)) - { - subtitle.Paragraphs.Remove(p); - } - - for (var index = 0; index < subtitle.Paragraphs.Count - 1; index++) - { - var current = subtitle.Paragraphs[index]; - var next = subtitle.Paragraphs[index + 1]; - if (Math.Abs(current.EndTime.TotalMilliseconds - next.StartTime.TotalMilliseconds) < 0.01) - { - if (current.EndTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines > - current.StartTime.TotalMilliseconds) - { - current.EndTime.TotalMilliseconds -= Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - - subtitle.Renumber(); - } - - public static string GetSccText(string s, ref int errorCount) - { - int y = 0; - int x = -1; - string[] parts = s.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); - var sb = new StringBuilder(); - bool first = true; - bool italicOn = false; - bool fontOn = false; - int k = 0; - var alignment = string.Empty; - - while (k < parts.Length) - { - string part = parts[k]; - if (part.Length == 4) - { - if (part != "94ae" && part != "9420" && part != "94ad" && part != "9426" && part != "946e" && part != "91ce" && part != "13ce" && part != "9425" && part != "9429") - { - - // skewed apostrophe "’" - if (part == "9229" && k < parts.Length - 1 && parts[k + 1] == "9229" && sb.EndsWith('\'')) - { - sb.Remove(sb.Length - 1, 1); - sb.Append("’"); - k += 2; - continue; - } - - // 3 codes - if (k < parts.Length - 2) - { - var letter = GetLetterFromCode(part + " " + parts[k + 1] + " " + parts[k + 2]); - if (letter != null) - { - sb.Append(letter); - k += 3; - continue; - } - } - - // two codes - if (k < parts.Length - 1) - { - var letter = GetLetterFromCode(part + " " + parts[k + 1]); - if (letter != null) - { - sb.Append(letter); - k += 2; - continue; - } - } - - if (part[0] == '9' || part[0] == '8') - { - if (k + 1 < parts.Length && parts[k + 1] == part) - { - k++; - } - } - - var cp = GetColorAndPosition(part); - if (cp != null) - { - if (!string.IsNullOrWhiteSpace(sb.ToString()) && cp.Y > 0 && y >= 0 && cp.Y > y && !sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal)) - { - sb.AppendLine(); - } - - if (cp.Y > 0) - { - y = cp.Y; - } - - x = cp.X; - - if (y < 4) - { - alignment = "{\\an8}"; - } - - if (y >= 7 && y <= 9) - { - alignment = "{\\an5}"; - } - - if (cp.ForeColor == Color.Green) - { - if (fontOn) - { - sb.Append(""); - } - sb.Append(""); - fontOn = true; - } - else if (cp.ForeColor == Color.Blue) - { - if (fontOn) - { - sb.Append(""); - } - sb.Append(""); - fontOn = true; - } - else if (cp.ForeColor == Color.Cyan) - { - if (fontOn) - { - sb.Append(""); - } - sb.Append(""); - fontOn = true; - } - else if (cp.ForeColor == Color.Red) - { - if (fontOn) - { - sb.Append(""); - } - sb.Append(""); - fontOn = true; - } - else if (cp.ForeColor == Color.Yellow) - { - if (fontOn) - { - sb.Append(""); - } - sb.Append(""); - fontOn = true; - } - else if (cp.ForeColor == Color.Magenta) - { - if (fontOn) - { - sb.Append(""); - } - sb.Append(""); - fontOn = true; - } - else if (cp.ForeColor == Color.White && fontOn) - { - sb.Append(""); - sb.Append(""); - fontOn = false; - } - else if (cp.ForeColor == Color.Black && fontOn) - { - sb.Append(""); - fontOn = false; - } - - if ((cp.Style & FontStyle.Italic) == FontStyle.Italic && !italicOn) - { - sb.Append(""); - italicOn = true; - } - else if (cp.Style == FontStyle.Regular && italicOn) - { - sb.Append(""); - italicOn = false; - } - } - else - { - switch (part) - { - case "9440": - case "94e0": - if (!sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal)) - { - sb.AppendLine(); - } - - break; - case "2c75": - case "2cf2": - case "2c6f": - case "2c6e": - case "2c6d": - case "2c6c": - case "2c6b": - case "2c6a": - case "2c69": - case "2c68": - case "2c67": - case "2c66": - case "2c65": - case "2c64": - case "2c63": - case "2c62": - case "2c61": - sb.Append(GetLetterFromCode(part.Substring(2, 2))); - break; - case "2c52": - case "2c94": - break; - default: - var result = GetLetterFromCode(part); - if (result == null) - { - sb.Append(GetLetterFromCode(part.Substring(0, 2))); - var secondPart = part.Substring(2, 2) + "80"; - - // 3 codes - if (k < parts.Length - 2) - { - var letter = GetLetterFromCode(secondPart + " " + parts[k + 1] + " " + parts[k + 2]); - if (letter != null) - { - sb.Append(letter); - k += 3; - continue; - } - } - - // two codes - if (k < parts.Length - 1) - { - var letter = GetLetterFromCode(secondPart + " " + parts[k + 1]); - if (letter != null) - { - sb.Append(letter); - k += 2; - continue; - } - } - - sb.Append(GetLetterFromCode(part.Substring(2, 2))); - } - else - { - sb.Append(result); - } - break; - } - } - } - } - else if (part.Length > 0) - { - if (!first) - { - errorCount++; - } - } - first = false; - k++; - } - - var leftAlign = false; - var rightAlign = false; - if (x >= 0) - { - var text = sb.ToString().Trim().SplitToLines().LastOrDefault(); - text = HtmlUtil.RemoveHtmlTags(text); - if (text != null && !string.IsNullOrEmpty(text)) - { - if (text.Length < 28) - { - if (x < 3) - { - leftAlign = true; - } - else if (x + text.Length > 30) - { - rightAlign = true; - } - } - } - } - - if (alignment == "{\\an8}" && leftAlign) - { - alignment = "{\\an7}"; - } - else if (alignment == "{\\an8}" && rightAlign) - { - alignment = "{\\an9}"; - } - else if (alignment == "{\\an5}" && leftAlign) - { - alignment = "{\\an4}"; - } - else if (alignment == "{\\an5}" && rightAlign) - { - alignment = "{\\an6}"; - } - else if (string.IsNullOrEmpty(alignment) && leftAlign) - { - alignment = "{\\an1}"; - } - else if (string.IsNullOrEmpty(alignment) && rightAlign) - { - alignment = "{\\an3}"; - } - - var res = sb.ToString().Replace("", string.Empty).Replace("", string.Empty); - if (fontOn) - { - res += ""; - } - - res = res.Replace(Environment.NewLine + "", "" + Environment.NewLine); - res = res.Replace(" ", " ").Replace(" ", " ").Replace(Environment.NewLine + " ", Environment.NewLine).Trim(); - if (res.Contains("") && !res.Contains("")) - { - res += ""; - } - - return alignment + HtmlUtil.FixInvalidItalicTags(res); - } - - private static TimeCode ParseTimeCode(string start) - { - var arr = start.Split(new[] { ':', ';', ',' }, StringSplitOptions.RemoveEmptyEntries); - return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), FramesToMillisecondsMax999(int.Parse(arr[3]))); - } - } -} +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + + /// + /// http://www.theneitherworld.com/mcpoodle/SCC_TOOLS/DOCS/SCC_FORMAT.HTML + /// § 15.119 47 CFR Ch. I (10–1–10 Edition) (pdf) + /// Maximum four lines + max 32 characters on each line + /// + public class ScenaristClosedCaptions : SubtitleFormat + { + //00:01:00:29 9420 9420 94ae 94ae 94d0 94d0 4920 f761 7320 ... semi colon (instead of colon) before frame number is used to indicate drop frame + private const string TimeCodeRegEx = @"^\d+:\d\d:\d\d[:,]\d\d\t"; + private static readonly Regex Regex = new Regex(TimeCodeRegEx, RegexOptions.Compiled); + protected virtual Regex RegexTimeCodes => Regex; + protected bool DropFrame; + + private static readonly List> LetterDictionary = new List> + { + new KeyValuePair("20", " " ), + new KeyValuePair("a1", "!" ), + new KeyValuePair("a2", "\""), + new KeyValuePair("23", "#" ), + new KeyValuePair("a4", "$" ), + new KeyValuePair("25", "%" ), + new KeyValuePair("26", "&" ), + new KeyValuePair("a7", "'" ), + new KeyValuePair("a8", "(" ), + new KeyValuePair("29", ")" ), + new KeyValuePair("2a", "á" ), + new KeyValuePair("ab", "+" ), + new KeyValuePair("2c", "," ), + new KeyValuePair("ad", "-" ), + new KeyValuePair("ae", "." ), + new KeyValuePair("2f", "/" ), + new KeyValuePair("b0", "0" ), + new KeyValuePair("31", "1" ), + new KeyValuePair("32", "2" ), + new KeyValuePair("b3", "3" ), + new KeyValuePair("34", "4" ), + new KeyValuePair("b5", "5" ), + new KeyValuePair("b6", "6" ), + new KeyValuePair("37", "7" ), + new KeyValuePair("38", "8" ), + new KeyValuePair("b9", "9" ), + new KeyValuePair("ba", ":" ), + new KeyValuePair("3b", ";" ), + new KeyValuePair("bc", "<" ), + new KeyValuePair("3d", "=" ), + new KeyValuePair("3e", ">" ), + new KeyValuePair("bf", "?" ), + new KeyValuePair("40", "@" ), + new KeyValuePair("c1", "A" ), + new KeyValuePair("c2", "B" ), + new KeyValuePair("43", "C" ), + new KeyValuePair("c4", "D" ), + new KeyValuePair("45", "E" ), + new KeyValuePair("46", "F" ), + new KeyValuePair("c7", "G" ), + new KeyValuePair("c8", "H" ), + new KeyValuePair("49", "I" ), + new KeyValuePair("4a", "J" ), + new KeyValuePair("cb", "K" ), + new KeyValuePair("4c", "L" ), + new KeyValuePair("cd", "M" ), + new KeyValuePair("ce", "N" ), + new KeyValuePair("4f", "O" ), + new KeyValuePair("d0", "P" ), + new KeyValuePair("51", "Q" ), + new KeyValuePair("52", "R" ), + new KeyValuePair("d3", "S" ), + new KeyValuePair("54", "T" ), + new KeyValuePair("d5", "U" ), + new KeyValuePair("d6", "V" ), + new KeyValuePair("57", "W" ), + new KeyValuePair("58", "X" ), + new KeyValuePair("d9", "Y" ), + new KeyValuePair("da", "Z" ), + new KeyValuePair("5b", "[" ), + new KeyValuePair("dc", "é" ), + new KeyValuePair("5d", "]" ), + new KeyValuePair("5e", "í" ), + new KeyValuePair("df", "ó" ), + new KeyValuePair("e0", "ú" ), + new KeyValuePair("61", "a" ), + new KeyValuePair("62", "b" ), + new KeyValuePair("e3", "c" ), + new KeyValuePair("64", "d" ), + new KeyValuePair("e5", "e" ), + new KeyValuePair("e6", "f" ), + new KeyValuePair("67", "g" ), + new KeyValuePair("68", "h" ), + new KeyValuePair("e9", "i" ), + new KeyValuePair("ea", "j" ), + new KeyValuePair("6b", "k" ), + new KeyValuePair("ec", "l" ), + new KeyValuePair("6d", "m" ), + new KeyValuePair("ef", "o" ), + new KeyValuePair("70", "p" ), + new KeyValuePair("f1", "q" ), + new KeyValuePair("f2", "r" ), + new KeyValuePair("73", "s" ), + new KeyValuePair("f4", "t" ), + new KeyValuePair("75", "u" ), + new KeyValuePair("76", "v" ), + new KeyValuePair("f7", "w" ), + new KeyValuePair("f8", "x" ), + new KeyValuePair("fb", "ç" ), + new KeyValuePair("79", "y" ), + new KeyValuePair("7a", "z" ), + new KeyValuePair("7c", "" ), + new KeyValuePair("fd", "Ñ" ), + new KeyValuePair("fe", "ñ" ), + new KeyValuePair("7f", "■" ), + new KeyValuePair("7b", "ç" ), + new KeyValuePair("63", "c" ), + new KeyValuePair("65", "e" ), + new KeyValuePair("66", "f" ), + new KeyValuePair("69", "i" ), + new KeyValuePair("6a", "j" ), + new KeyValuePair("6c", "l" ), + new KeyValuePair("6e", "n" ), + new KeyValuePair("6f", "o" ), + new KeyValuePair("71", "q" ), + new KeyValuePair("72", "r" ), + new KeyValuePair("74", "t" ), + new KeyValuePair("77", "w" ), + new KeyValuePair("78", "x" ), + new KeyValuePair("91b0", "" ), + new KeyValuePair("91b3", "" ), + new KeyValuePair("91b5", "" ), + new KeyValuePair("91b6", "£" ), + new KeyValuePair("9137", "♪" ), + new KeyValuePair("9138", "à" ), + new KeyValuePair("91b9", "" ), + new KeyValuePair("91ba", "è" ), + new KeyValuePair("913b", "â" ), + new KeyValuePair("91bc", "ê" ), + new KeyValuePair("913d", "î" ), + new KeyValuePair("913e", "ô" ), + new KeyValuePair("91bf", "û" ), + new KeyValuePair("9220", "Á" ), + new KeyValuePair("92a1", "É" ), + new KeyValuePair("92a2", "Ó" ), + new KeyValuePair("9223", "Ú" ), + new KeyValuePair("92a4", "Ü" ), + new KeyValuePair("9225", "ü" ), + new KeyValuePair("9226", "'" ), + new KeyValuePair("92a7", "i" ), + new KeyValuePair("92a8", "*" ), + new KeyValuePair("9229", "'" ), + new KeyValuePair("922a", "-" ), + new KeyValuePair("92ab", "" ), + new KeyValuePair("922c", "" ), + new KeyValuePair("92ad", "\""), + new KeyValuePair("92ae", "\""), + new KeyValuePair("922f", "" ), + new KeyValuePair("92b0", "À" ), + new KeyValuePair("9231", "Â" ), + new KeyValuePair("9232", "Ç" ), + new KeyValuePair("92b3", "È" ), + new KeyValuePair("9234", "Ê" ), + new KeyValuePair("92b5", "Ë" ), + new KeyValuePair("92b6", "ë" ), + new KeyValuePair("9237", "Î" ), + new KeyValuePair("9238", "Ï" ), + new KeyValuePair("92b9", "ï" ), + new KeyValuePair("923b", "Ù" ), + new KeyValuePair("923d", "Û" ), + new KeyValuePair("923e", "" ), + new KeyValuePair("92bf", "" ), + new KeyValuePair("1320", "Ã" ), + new KeyValuePair("c1 1320", "Ã" ), + new KeyValuePair("c180 1320", "Ã" ), + new KeyValuePair("13a1", "ã" ), + new KeyValuePair("80 13a1", "ã" ), + new KeyValuePair("6180 13a1", "ã" ), + new KeyValuePair("13a2", "Í" ), + new KeyValuePair("49 13a2", "Í" ), + new KeyValuePair("4980 13a2", "Í" ), + new KeyValuePair("1323", "Ì" ), + new KeyValuePair("49 1323", "Ì" ), + new KeyValuePair("4980 1323", "Ì" ), + new KeyValuePair("13a4", "ì" ), + new KeyValuePair("e9 13a4", "ì" ), + new KeyValuePair("e980 13a4", "ì" ), + new KeyValuePair("1325", "Ò" ), + new KeyValuePair("4f 1325", "Ò" ), + new KeyValuePair("4f80 1325", "Ò" ), + new KeyValuePair("1326", "ò" ), + new KeyValuePair("ef 1326", "ò" ), + new KeyValuePair("ef80 1326", "ò" ), + new KeyValuePair("13a7", "Õ" ), + new KeyValuePair("4f 13a7", "Õ" ), + new KeyValuePair("4f80 13a7", "Õ" ), + new KeyValuePair("13a8", "õ" ), + new KeyValuePair("ef 13a8", "õ" ), + new KeyValuePair("ef80 13a8", "õ" ), + new KeyValuePair("1329", "{" ), + new KeyValuePair("132a", "}" ), + new KeyValuePair("13ab", "\\"), + new KeyValuePair("132c", "^" ), + new KeyValuePair("13ad", "_" ), + new KeyValuePair("13ae", "|" ), + new KeyValuePair("132f", "~" ), + new KeyValuePair("13b0", "Ä" ), + new KeyValuePair("c180 13b0", "Ä" ), + new KeyValuePair("1331", "ä" ), + new KeyValuePair("6180 1331", "ä" ), + new KeyValuePair("1332", "Ö" ), + new KeyValuePair("4f80 1332", "Ö" ), + new KeyValuePair("13b3", "ö" ), + new KeyValuePair("ef80 13b3", "ö" ), + new KeyValuePair("1334", "" ), + new KeyValuePair("13b5", "" ), + new KeyValuePair("13b6", "" ), + new KeyValuePair("1337", "|" ), + new KeyValuePair("1338", "Å" ), + new KeyValuePair("13b9", "å" ), + new KeyValuePair("4f80 13ba 13ba", "Ø" ), + new KeyValuePair("133b", "ø" ), + new KeyValuePair("133d", "" ), + new KeyValuePair("133e", "" ), + new KeyValuePair("13bf", "" ), + new KeyValuePair("9420", "" ), //9420=RCL, Resume Caption Loading + new KeyValuePair("94ae", "" ), //94ae=Clear Buffer + new KeyValuePair("942c", "" ), //942c=Clear Caption + new KeyValuePair("8080", "" ), //8080=Wait One Frame + new KeyValuePair("942f", "" ), //942f=Display Caption + new KeyValuePair("9440", "" ), //9440=? first sub? + new KeyValuePair("9452", "" ), //? + new KeyValuePair("9454", "" ), //? + new KeyValuePair("9470", "" ), //9470=? + new KeyValuePair("94d0", "" ), //94d0=? + new KeyValuePair("94d6", "" ), //94d6=? + new KeyValuePair("94f2", "" ), + new KeyValuePair("94f4", "" ), + new KeyValuePair("9723", " " ), // ? + new KeyValuePair("97a1", " " ), // ? + new KeyValuePair("97a2", " " ), // ? + new KeyValuePair("1370", "" ), //1370=? + new KeyValuePair("13e0", "" ), //13e0=? + new KeyValuePair("13f2", "" ), //13f2=? + new KeyValuePair("136e", "" ), //136e=? + new KeyValuePair("94ce", "" ), //94ce=? + new KeyValuePair("2c2f", "" ), //? + new KeyValuePair("1130", "®" ), + new KeyValuePair("1131", "°" ), + new KeyValuePair("1132", "½" ), + new KeyValuePair("1133", "¿" ), + new KeyValuePair("1134", "TM"), + new KeyValuePair("1135", "¢" ), + new KeyValuePair("1136", "£" ), + new KeyValuePair("1137", "♪" ), + new KeyValuePair("1138", "à" ), + new KeyValuePair("113a", "è" ), + new KeyValuePair("113b", "â" ), + new KeyValuePair("113c", "ê" ), + new KeyValuePair("113d", "î" ), + new KeyValuePair("113e", "ô" ), + new KeyValuePair("113f", "û" ), + new KeyValuePair("9130", "®" ), + new KeyValuePair("9131", "°" ), + new KeyValuePair("9132", "½" ), + new KeyValuePair("9133", "¿" ), + new KeyValuePair("9134", "TM"), + new KeyValuePair("9135", "¢" ), + new KeyValuePair("9136", "£" ), + new KeyValuePair("913a", "è" ), + new KeyValuePair("913c", "ê" ), + new KeyValuePair("913f", "û" ), + new KeyValuePair("a180 92a7 92a7", "¡" ), + new KeyValuePair("92a7 92a7", "¡" ), + new KeyValuePair("91b3 91b3", "¿" ), + + new KeyValuePair("6180 9138 9138", "à"), //61=a + new KeyValuePair("9138 9138", "à"), + + new KeyValuePair("6180 913b 913b", "â"), + new KeyValuePair("913b 913b", "â"), + + new KeyValuePair("6180 1331 1331", "ä"), + new KeyValuePair("1331 1331", "ä"), + + new KeyValuePair("e580 91ba 91ba", "è"), + new KeyValuePair("6180 91ba 91ba", "è"), + new KeyValuePair("91ba 91ba", "è"), + + new KeyValuePair("e580 91bc 91bc", "ê"), + new KeyValuePair("6180 91bc 91bc", "ê"), + new KeyValuePair("91bc 91bc", "ê"), + + + new KeyValuePair("e580 92b6 92b6", "ë"), //e5=e (+65?) + new KeyValuePair("6580 92b6 92b6", "ë"), + new KeyValuePair("92b6 92b6", "ë"), + + new KeyValuePair("e980 13a4 13a4", "ì"), //e9 = i + new KeyValuePair("13a4 13a4", "ì"), + + new KeyValuePair("e980 913d 913d", "î"), + new KeyValuePair("913d 913d", "î"), + + new KeyValuePair("e980 92b9 92b9", "ï"), + new KeyValuePair("92b9 92b9", "ï"), + + new KeyValuePair("1326 1326", "ò"), //o=ef or 6f + new KeyValuePair("ef80 1326 1326", "ò"), + new KeyValuePair("6f80 1326 1326", "ò"), + + new KeyValuePair("913e 913e", "ô"), + new KeyValuePair("ef80 913e 913e", "ô"), + new KeyValuePair("6f80 913e 913e", "ô"), + + new KeyValuePair("13b3 13b3", "ö"), + new KeyValuePair("ef80 13b3 13b3", "ö"), + new KeyValuePair("6f80 13b3 13b3", "ö"), + + new KeyValuePair("7580 13b3 13b3", "ù"), //u=75 + + new KeyValuePair("7580 92bc 92bc", "ù"), + new KeyValuePair("92bc 92bc", "ù"), + + new KeyValuePair("7580 91bf 91bf", "û"), + new KeyValuePair("91bf 91bf", "û"), + + new KeyValuePair("7580 9225 9225", "ü"), + new KeyValuePair("9225 9225", "ü"), + + new KeyValuePair("4380 9232 9232", "Ç"), //43=C + new KeyValuePair("9232 9232", "Ç"), + + new KeyValuePair("c180 1338 1338", "Å"), //c1=A + new KeyValuePair("1338 1338", "Å"), + + new KeyValuePair("c180 92b0 92b0", "À"), + new KeyValuePair("92b0 92b0", "À"), + + new KeyValuePair("c180 9220 9220", "Á"), + new KeyValuePair("9220 9220", "Á"), + + new KeyValuePair("c180 9231 9231", "Â"), + new KeyValuePair("9231 9231", "Â"), + + new KeyValuePair("c180 1320 1320", "Ã"), + new KeyValuePair("1320 1320", "Ã"), + + new KeyValuePair("c180 13b0 13b0", "Ä"), + new KeyValuePair("13b0 13b0", "Ä"), + + new KeyValuePair("4580 92b3 92b3", "È"), + new KeyValuePair("92b3 92b3", "È"), + + new KeyValuePair("4580 92a1 92a1", "É"), + new KeyValuePair("92a1 92a1", "É"), + + new KeyValuePair("4580 9234 9234", "Ê"), + new KeyValuePair("9234 9234", "Ê"), + + new KeyValuePair("4580 92b5 92b5", "Ë"), + new KeyValuePair("92b5 92b5", "Ë"), + + new KeyValuePair("4980 1323 1323", "Ì"), + new KeyValuePair("1323 1323", "Ì"), + + new KeyValuePair("4980 13a2 13a2", "Í"), + new KeyValuePair("13a2 13a2", "Í"), + + new KeyValuePair("4980 9237 9237", "Î"), + new KeyValuePair("9237 9237", "Î"), + + new KeyValuePair("4980 9238 9238", "Ï"), + new KeyValuePair("9238 9238", "Ï"), + + new KeyValuePair("4f80 92a2 92a2", "Ó"), //4f=O + new KeyValuePair("92a2 92a2", "Ó"), + + new KeyValuePair("4f80 1325 1325", "Ò"), + new KeyValuePair("1325 1325", "Ò"), + + new KeyValuePair("4f80 92ba 92ba", "Ô"), + new KeyValuePair("92ba 92ba", "Ô"), + + new KeyValuePair("4f80 13a7 13a7", "Õ"), + new KeyValuePair("13a7 13a7", "Õ"), + + new KeyValuePair("4f80 1332 1332", "Ö"), + new KeyValuePair("1332 1332", "Ö"), + + new KeyValuePair("d580 9223 9223", "Ú"), + new KeyValuePair("923d 923d", "Û"), + + new KeyValuePair("d580 923b 923b", "Ù"), + new KeyValuePair("9223 9223", "Ú"), + + new KeyValuePair("d580 92a4 92a4", "Ü"), + new KeyValuePair("92a4 92a4", "Ü"), + + new KeyValuePair("d580 923d 923d", "Û"), + }; + + private static readonly Dictionary LettersCodeLookup = LetterDictionary.ToDictionary(p => p.Key, p => p.Value); + + public override string Extension => ".scc"; + + public override string Name => "Scenarist Closed Captions"; + + private static string FixMax4LinesAndMax32CharsPerLine(string text, string language) + { + // fix attempt 1 + var lines = text.Trim().SplitToLines(); + if (IsAllOkay(lines)) + { + return text; + } + + // fix attempt 2 + text = Utilities.AutoBreakLine(text, 1, 4, language); + lines = text.Trim().SplitToLines(); + if (IsAllOkay(lines)) + { + return text; + } + + // fix attempt 3 + text = AutoBreakLineMax4Lines(text, 32); + lines = text.Trim().SplitToLines(); + if (IsAllOkay(lines)) + { + return text; + } + + var sb = new StringBuilder(); + int count = 0; + foreach (var line in lines) + { + if (count < 4) + { + sb.AppendLine(line.Length > 32 ? line.Substring(0, 32) : line); + } + count++; + } + return sb.ToString().Trim(); + } + + private static bool IsAllOkay(List lines) + { + return lines.Count <= 4 && lines.All(line => line.Length <= 32); + } + + private static int GetLastIndexOfSpace(string s, int endCount) + { + var end = Math.Min(endCount, s.Length - 1); + while (end > 0) + { + if (s[end] == ' ') + { + return end; + } + + end--; + } + return -1; + } + + private static string AutoBreakLineMax4Lines(string text, int maxLength) + { + string s = text.Replace(Environment.NewLine, " "); + s = s.Replace(" ", " "); + var sb = new StringBuilder(); + int i = GetLastIndexOfSpace(s, maxLength); + if (i > 0) + { + sb.AppendLine(s.Substring(0, i)); + s = s.Remove(0, i).Trim(); + i = s.Length <= maxLength ? s.Length : GetLastIndexOfSpace(s, maxLength); + + if (i > 0) + { + sb.AppendLine(s.Substring(0, i)); + s = s.Remove(0, i).Trim(); + i = s.Length <= maxLength ? s.Length : GetLastIndexOfSpace(s, maxLength); + + if (i > 0) + { + sb.AppendLine(s.Substring(0, i)); + s = s.Remove(0, i).Trim(); + i = s.Length <= maxLength ? s.Length : GetLastIndexOfSpace(s, maxLength); + + if (i > 0) + { + sb.AppendLine(s.Substring(0, i)); + } + else + { + sb.Append(s); + } + } + else + { + sb.Append(s); + } + } + return sb.ToString().Trim(); + } + return text; + } + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + sb.AppendLine("Scenarist_SCC V1.0"); + sb.AppendLine(); + string language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); + for (int i = 0; i < subtitle.Paragraphs.Count; i++) + { + var p = subtitle.Paragraphs[i]; + sb.AppendLine($"{ToTimeCode(p.StartTime.TotalMilliseconds)}\t94ae 94ae 9420 9420 {ToSccText(p.Text, language)} 942f 942f"); + sb.AppendLine(); + + var next = subtitle.GetParagraphOrDefault(i + 1); + if (next == null || Math.Abs(next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds) > 100) + { + sb.AppendLine($"{ToTimeCode(p.EndTime.TotalMilliseconds)}\t942c 942c"); + sb.AppendLine(); + } + } + return sb.ToString(); + } + + private static string ToSccText(string text, string language) + { + text = FixMax4LinesAndMax32CharsPerLine(text, language); + var topAlign = text.StartsWith("{\\an7}", StringComparison.Ordinal) || + text.StartsWith("{\\an8}", StringComparison.Ordinal) || + text.StartsWith("{\\an9}", StringComparison.Ordinal); + + var leftAlign = text.StartsWith("{\\an7}", StringComparison.Ordinal) || + text.StartsWith("{\\an4}", StringComparison.Ordinal) || + text.StartsWith("{\\an1}", StringComparison.Ordinal); + + var rightAlign = text.StartsWith("{\\an9}", StringComparison.Ordinal) || + text.StartsWith("{\\an6}", StringComparison.Ordinal) || + text.StartsWith("{\\an3}", StringComparison.Ordinal); + + var verticalCenter = text.StartsWith("{\\an4}", StringComparison.Ordinal) || + text.StartsWith("{\\an5}", StringComparison.Ordinal) || + text.StartsWith("{\\an6}", StringComparison.Ordinal); + + text = Utilities.RemoveSsaTags(text); + var lines = text.Trim().SplitToLines(); + int italic = 0; + var sb = new StringBuilder(); + int count = 1; + foreach (var line in lines) + { + text = line.Trim(); + if (count > 0) + { + sb.Append(' '); + } + + var centerCodes = GetCenterCodes(text, count, lines.Count, topAlign, leftAlign, rightAlign, verticalCenter); + sb.Append(centerCodes); + count++; + int i = 0; + string code = string.Empty; + if (italic > 0) + { + sb.Append("91ae 91ae "); // italic + } + + while (i < text.Length) + { + string s = text.Substring(i, 1); + string codeFromLetter = GetCodeFromLetter(s); + string newCode; + if (text.Substring(i).StartsWith("", StringComparison.Ordinal)) + { + newCode = "91ae"; + i += 2; + italic++; + } + else if (text.Substring(i).StartsWith("", StringComparison.Ordinal) && italic > 0) + { + newCode = "9120"; + i += 3; + italic--; + } + else if (text[i] == '’') + { + if (code.Length == 4) + { + sb.Append(code + " "); + code = string.Empty; + } + + if (code.Length == 0) + { + code = "80"; + } + + if (code.Length == 2) + { + code += "a7"; + sb.Append(code + " "); + } + + code = "9229"; + newCode = ""; + } + else if (codeFromLetter == null) + { + newCode = GetCodeFromLetter(" "); + } + else + { + newCode = codeFromLetter; + } + + if (code.Length == 2 && newCode.Length == 4) + { + code += "80"; + } + + if (code.Length == 4) + { + sb.Append(code + " "); + if (code.StartsWith('9') || code.StartsWith('8')) // control codes must be double + { + sb.Append(code + " "); + } + + code = string.Empty; + } + + if (code.Length == 2 && newCode.Length == 2) + { + code += newCode; + newCode = string.Empty; + } + + if (newCode.Length == 4 && code.Length == 0) + { + code = newCode; + } + else if (newCode.Length == 2 && code.Length == 0) + { + code = newCode; + } + else if (newCode.Length > 4) + { + if (code.Length == 2) + { + code += "80"; + sb.Append(code + " "); + if (code.StartsWith('9') || code.StartsWith('8')) // control codes must be double + { + sb.Append(code + " "); + } + + code = string.Empty; + } + else if (code.Length == 4) + { + sb.Append(code + " "); + if (code.StartsWith('9') || code.StartsWith('8')) // control codes must be double + { + sb.Append(code + " "); + } + + code = string.Empty; + } + + sb.Append(newCode.TrimEnd() + " "); + } + + i++; + } + + if (code.Length == 2) + { + code += "80"; + } + + if (code.Length == 4) + { + sb.Append(code); + } + } + + return sb.ToString().Trim(); + } + + private static string GetCodeFromLetter(string letter) + { + var code = LetterDictionary.FirstOrDefault(x => x.Value == letter); + if (code.Equals(new KeyValuePair())) + { + return null; + } + + return code.Key; + } + + private static string GetLetterFromCode(string hexCode) + { + return LettersCodeLookup.TryGetValue(hexCode, out var letter) ? letter : null; + } + + public static string GetCenterCodes(string text, int lineNumber, int totalLines, bool topAlign, bool leftAlign, bool rightAlign, bool verticalCenter) + { + var row = 14 - (totalLines - lineNumber); + if (topAlign) + { + row = lineNumber; + } + else if (verticalCenter) + { + row = 6 - totalLines / 2 + lineNumber; + } + var rowCodes = new List { "91", "91", "92", "92", "15", "15", "16", "16", "97", "97", "10", "13", "13", "94", "94" }; + var rowCode = rowCodes[row]; + + var left = (32 - text.Length) / 2; + if (leftAlign) + { + left = 0; + } + else if (rightAlign) + { + left = 32 - text.Length; + } + int columnRest = left % 4; + int column = left - columnRest; + + List columnCodes; + switch (column) + { + case 0: + columnCodes = new List { "d0", "70", "d0", "70", "d0", "70", "d0", "70", "d0", "70", "d0", "d0", "70", "d0", "70" }; + break; + case 4: + columnCodes = new List { "52", "f2", "52", "f2", "52", "f2", "52", "f2", "52", "f2", "52", "52", "f2", "52", "f2" }; + break; + case 8: + columnCodes = new List { "54", "f4", "54", "f4", "54", "f4", "54", "f4", "54", "f4", "54", "54", "f4", "54", "f4" }; + break; + case 12: + columnCodes = new List { "d6", "76", "d6", "76", "d6", "76", "d6", "76", "d6", "76", "d6", "d6", "76", "d6", "76" }; + break; + case 16: + columnCodes = new List { "58", "f8", "58", "f8", "58", "f8", "58", "f8", "58", "f8", "58", "58", "f8", "58", "f8" }; + break; + case 20: + columnCodes = new List { "da", "7a", "da", "7a", "da", "7a", "da", "7a", "da", "7a", "da", "da", "7a", "da", "7a" }; + break; + case 24: + columnCodes = new List { "dc", "7c", "dc", "7c", "dc", "7c", "dc", "7c", "dc", "7c", "dc", "dc", "7c", "dc", "7c" }; + break; + default: // 28 + columnCodes = new List { "5e", "fe", "5e", "fe", "5e", "fe", "5e", "fe", "5e", "fe", "5e", "5e", "fe", "5e", "fe" }; + break; + } + var code = rowCode + columnCodes[row]; + + if (columnRest == 1) + { + return code + " " + code + " 97a1 97a1 "; + } + + if (columnRest == 2) + { + return code + " " + code + " 97a2 97a2 "; + } + + if (columnRest == 3) + { + return $"{code} {code} 9723 9723 "; + } + + return $"{code} {code} "; + } + + private string ToTimeCode(double totalMilliseconds) + { + var ts = TimeSpan.FromMilliseconds(totalMilliseconds); + if (DropFrame) + { + return $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00};{MillisecondsToFramesMaxFrameRate(ts.Milliseconds):00}"; + } + + return $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}:{MillisecondsToFramesMaxFrameRate(ts.Milliseconds):00}"; + } + + private static Dictionary _styleLookup; + public static SccPositionAndStyle GetColorAndPosition(string code) + { + if (_styleLookup == null) + { + _styleLookup = SccPositionAndStyleTable.SccPositionAndStyles.ToDictionary(p => p.Code, p => p); + } + + return _styleLookup.TryGetValue(code, out var style) ? style : null; + } + + public static string GetCodeFromPositionAndColor(int x, int y, FontStyle fontStyle, Color color) + { + var match = SccPositionAndStyleTable.SccPositionAndStyles.FirstOrDefault(p => p.X == x && p.Y == y && p.Style == fontStyle && p.ForeColor == color); + return match == null ? string.Empty : match.Code; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + Paragraph p = null; + foreach (string line in lines) + { + var s = line.Trim(); + var match = RegexTimeCodes.Match(s); + if (match.Success) + { + var startTime = ParseTimeCode(s.Substring(0, match.Length - 1)); + var text = GetSccText(s.Substring(match.Index), ref _errorCount); + + if (text == "942c 942c" || text == "942c") + { + if (p != null) + { + p.EndTime.TotalMilliseconds = startTime.TotalMilliseconds; + } + } + else + { + p = new Paragraph(startTime, new TimeCode(startTime.TotalMilliseconds), text); + subtitle.Paragraphs.Add(p); + } + } + } + for (int i = subtitle.Paragraphs.Count - 2; i >= 0; i--) + { + p = subtitle.GetParagraphOrDefault(i); + var next = subtitle.GetParagraphOrDefault(i + 1); + if (p != null && next != null && Math.Abs(p.EndTime.TotalMilliseconds - p.StartTime.TotalMilliseconds) < 0.001) + { + p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds; + } + + if (next != null && string.IsNullOrEmpty(next.Text)) + { + subtitle.Paragraphs.Remove(next); + } + } + + p = subtitle.GetParagraphOrDefault(0); + if (p != null && string.IsNullOrEmpty(p.Text)) + { + subtitle.Paragraphs.Remove(p); + } + + for (var index = 0; index < subtitle.Paragraphs.Count - 1; index++) + { + var current = subtitle.Paragraphs[index]; + var next = subtitle.Paragraphs[index + 1]; + if (Math.Abs(current.EndTime.TotalMilliseconds - next.StartTime.TotalMilliseconds) < 0.01) + { + if (current.EndTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines > + current.StartTime.TotalMilliseconds) + { + current.EndTime.TotalMilliseconds -= Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + + subtitle.Renumber(); + } + + public static string GetSccText(string s, ref int errorCount) + { + int y = 0; + int x = -1; + string[] parts = s.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); + var sb = new StringBuilder(); + bool first = true; + bool italicOn = false; + bool fontOn = false; + int k = 0; + var alignment = string.Empty; + + while (k < parts.Length) + { + string part = parts[k]; + if (part.Length == 4) + { + if (part != "94ae" && part != "9420" && part != "94ad" && part != "9426" && part != "946e" && part != "91ce" && part != "13ce" && part != "9425" && part != "9429") + { + + // skewed apostrophe "’" + if (part == "9229" && k < parts.Length - 1 && parts[k + 1] == "9229" && sb.EndsWith('\'')) + { + sb.Remove(sb.Length - 1, 1); + sb.Append("’"); + k += 2; + continue; + } + + // 3 codes + if (k < parts.Length - 2) + { + var letter = GetLetterFromCode(part + " " + parts[k + 1] + " " + parts[k + 2]); + if (letter != null) + { + sb.Append(letter); + k += 3; + continue; + } + } + + // two codes + if (k < parts.Length - 1) + { + var letter = GetLetterFromCode(part + " " + parts[k + 1]); + if (letter != null) + { + sb.Append(letter); + k += 2; + continue; + } + } + + if (part[0] == '9' || part[0] == '8') + { + if (k + 1 < parts.Length && parts[k + 1] == part) + { + k++; + } + } + + var cp = GetColorAndPosition(part); + if (cp != null) + { + if (!string.IsNullOrWhiteSpace(sb.ToString()) && cp.Y > 0 && y >= 0 && cp.Y > y && !sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal)) + { + sb.AppendLine(); + } + + if (cp.Y > 0) + { + y = cp.Y; + } + + x = cp.X; + + if (y < 4) + { + alignment = "{\\an8}"; + } + + if (y >= 7 && y <= 9) + { + alignment = "{\\an5}"; + } + + if (cp.ForeColor == Color.Green) + { + if (fontOn) + { + sb.Append(""); + } + sb.Append(""); + fontOn = true; + } + else if (cp.ForeColor == Color.Blue) + { + if (fontOn) + { + sb.Append(""); + } + sb.Append(""); + fontOn = true; + } + else if (cp.ForeColor == Color.Cyan) + { + if (fontOn) + { + sb.Append(""); + } + sb.Append(""); + fontOn = true; + } + else if (cp.ForeColor == Color.Red) + { + if (fontOn) + { + sb.Append(""); + } + sb.Append(""); + fontOn = true; + } + else if (cp.ForeColor == Color.Yellow) + { + if (fontOn) + { + sb.Append(""); + } + sb.Append(""); + fontOn = true; + } + else if (cp.ForeColor == Color.Magenta) + { + if (fontOn) + { + sb.Append(""); + } + sb.Append(""); + fontOn = true; + } + else if (cp.ForeColor == Color.White && fontOn) + { + sb.Append(""); + sb.Append(""); + fontOn = false; + } + else if (cp.ForeColor == Color.Black && fontOn) + { + sb.Append(""); + fontOn = false; + } + + if ((cp.Style & FontStyle.Italic) == FontStyle.Italic && !italicOn) + { + sb.Append(""); + italicOn = true; + } + else if (cp.Style == FontStyle.Regular && italicOn) + { + sb.Append(""); + italicOn = false; + } + } + else + { + switch (part) + { + case "9440": + case "94e0": + if (!sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal)) + { + sb.AppendLine(); + } + + break; + case "2c75": + case "2cf2": + case "2c6f": + case "2c6e": + case "2c6d": + case "2c6c": + case "2c6b": + case "2c6a": + case "2c69": + case "2c68": + case "2c67": + case "2c66": + case "2c65": + case "2c64": + case "2c63": + case "2c62": + case "2c61": + sb.Append(GetLetterFromCode(part.Substring(2, 2))); + break; + case "2c52": + case "2c94": + break; + default: + var result = GetLetterFromCode(part); + if (result == null) + { + sb.Append(GetLetterFromCode(part.Substring(0, 2))); + var secondPart = part.Substring(2, 2) + "80"; + + // 3 codes + if (k < parts.Length - 2) + { + var letter = GetLetterFromCode(secondPart + " " + parts[k + 1] + " " + parts[k + 2]); + if (letter != null) + { + sb.Append(letter); + k += 3; + continue; + } + } + + // two codes + if (k < parts.Length - 1) + { + var letter = GetLetterFromCode(secondPart + " " + parts[k + 1]); + if (letter != null) + { + sb.Append(letter); + k += 2; + continue; + } + } + + sb.Append(GetLetterFromCode(part.Substring(2, 2))); + } + else + { + sb.Append(result); + } + break; + } + } + } + } + else if (part.Length > 0) + { + if (!first) + { + errorCount++; + } + } + first = false; + k++; + } + + var leftAlign = false; + var rightAlign = false; + if (x >= 0) + { + var text = sb.ToString().Trim().SplitToLines().LastOrDefault(); + text = HtmlUtil.RemoveHtmlTags(text); + if (text != null && !string.IsNullOrEmpty(text)) + { + if (text.Length < 28) + { + if (x < 3) + { + leftAlign = true; + } + else if (x + text.Length > 30) + { + rightAlign = true; + } + } + } + } + + if (alignment == "{\\an8}" && leftAlign) + { + alignment = "{\\an7}"; + } + else if (alignment == "{\\an8}" && rightAlign) + { + alignment = "{\\an9}"; + } + else if (alignment == "{\\an5}" && leftAlign) + { + alignment = "{\\an4}"; + } + else if (alignment == "{\\an5}" && rightAlign) + { + alignment = "{\\an6}"; + } + else if (string.IsNullOrEmpty(alignment) && leftAlign) + { + alignment = "{\\an1}"; + } + else if (string.IsNullOrEmpty(alignment) && rightAlign) + { + alignment = "{\\an3}"; + } + + var res = sb.ToString().Replace("", string.Empty).Replace("", string.Empty); + if (fontOn) + { + res += ""; + } + + res = res.Replace(Environment.NewLine + "", "" + Environment.NewLine); + res = res.Replace(" ", " ").Replace(" ", " ").Replace(Environment.NewLine + " ", Environment.NewLine).Trim(); + if (res.Contains("") && !res.Contains("")) + { + res += ""; + } + + return alignment + HtmlUtil.FixInvalidItalicTags(res); + } + + private static TimeCode ParseTimeCode(string start) + { + var arr = start.Split(new[] { ':', ';', ',' }, StringSplitOptions.RemoveEmptyEntries); + return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), FramesToMillisecondsMax999(int.Parse(arr[3]))); + } + } +} diff --git a/libse/SubtitleFormats/ScenaristClosedCaptionsDropFrame.cs b/src/libse/SubtitleFormats/ScenaristClosedCaptionsDropFrame.cs similarity index 97% rename from libse/SubtitleFormats/ScenaristClosedCaptionsDropFrame.cs rename to src/libse/SubtitleFormats/ScenaristClosedCaptionsDropFrame.cs index 4066616f3..25e03a7fd 100644 --- a/libse/SubtitleFormats/ScenaristClosedCaptionsDropFrame.cs +++ b/src/libse/SubtitleFormats/ScenaristClosedCaptionsDropFrame.cs @@ -1,18 +1,18 @@ -using System.Text.RegularExpressions; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class ScenaristClosedCaptionsDropFrame : ScenaristClosedCaptions - { - //00:01:00:29 9420 9420 94ae 94ae 94d0 94d0 4920 f761 7320 ... semi colon (instead of colon) before frame number is used to indicate drop frame - private const string TimeCodeRegEx = @"^\d+:\d\d:\d\d[;,]\d\d\t"; - private static readonly Regex Regex = new Regex(TimeCodeRegEx, RegexOptions.Compiled); - protected override Regex RegexTimeCodes => Regex; - public override string Name => "Scenarist Closed Captions Drop Frame"; - - public ScenaristClosedCaptionsDropFrame() - { - DropFrame = true; - } - } -} +using System.Text.RegularExpressions; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class ScenaristClosedCaptionsDropFrame : ScenaristClosedCaptions + { + //00:01:00:29 9420 9420 94ae 94ae 94d0 94d0 4920 f761 7320 ... semi colon (instead of colon) before frame number is used to indicate drop frame + private const string TimeCodeRegEx = @"^\d+:\d\d:\d\d[;,]\d\d\t"; + private static readonly Regex Regex = new Regex(TimeCodeRegEx, RegexOptions.Compiled); + protected override Regex RegexTimeCodes => Regex; + public override string Name => "Scenarist Closed Captions Drop Frame"; + + public ScenaristClosedCaptionsDropFrame() + { + DropFrame = true; + } + } +} diff --git a/libse/SubtitleFormats/SeImageHtmlIndex.cs b/src/libse/SubtitleFormats/SeImageHtmlIndex.cs similarity index 97% rename from libse/SubtitleFormats/SeImageHtmlIndex.cs rename to src/libse/SubtitleFormats/SeImageHtmlIndex.cs index 99e684588..9ac3b830d 100644 --- a/libse/SubtitleFormats/SeImageHtmlIndex.cs +++ b/src/libse/SubtitleFormats/SeImageHtmlIndex.cs @@ -1,87 +1,87 @@ -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - /// Export from Subtitle Edit OCR window - /// - public class SeImageHtmlIndex : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^#\d+:\d+", RegexOptions.Compiled); - - public override string Extension => ".html"; - - public override string Name => "SE image HTML index"; - - public override bool IsMine(List lines, string fileName) - { - if (fileName != null && !fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - throw new NotImplementedException(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - foreach (string line in lines) - { - if (line.Contains(".png") && RegexTimeCodes.IsMatch(line)) - { - int idx = line.IndexOf(" 0) - { - try - { - var s = line.Replace(">", ">").Substring(0, idx); - s = s.Remove(0, s.IndexOf(':') + 1); - var arr = s.Split(new[] { '-', '>' }, StringSplitOptions.RemoveEmptyEntries); - var p = new Paragraph { StartTime = DecodeTimeCode(arr[0]), EndTime = DecodeTimeCode(arr[1]) }; - int start = line.IndexOf("', ',', '.' }, StringSplitOptions.RemoveEmptyEntries); - int milliseconds = int.Parse(parts[parts.Length - 1]); - int seconds = int.Parse(parts[parts.Length - 2]); - int minutes = 0; - if (parts.Length > 2) - { - minutes = int.Parse(parts[parts.Length - 3]); - } - - int hour = 0; - if (parts.Length > 3) - { - hour = int.Parse(parts[parts.Length - 4]); - } - - return new TimeCode(hour, minutes, seconds, milliseconds); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + /// + /// Export from Subtitle Edit OCR window + /// + public class SeImageHtmlIndex : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^#\d+:\d+", RegexOptions.Compiled); + + public override string Extension => ".html"; + + public override string Name => "SE image HTML index"; + + public override bool IsMine(List lines, string fileName) + { + if (fileName != null && !fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + throw new NotImplementedException(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + foreach (string line in lines) + { + if (line.Contains(".png") && RegexTimeCodes.IsMatch(line)) + { + int idx = line.IndexOf(" 0) + { + try + { + var s = line.Replace(">", ">").Substring(0, idx); + s = s.Remove(0, s.IndexOf(':') + 1); + var arr = s.Split(new[] { '-', '>' }, StringSplitOptions.RemoveEmptyEntries); + var p = new Paragraph { StartTime = DecodeTimeCode(arr[0]), EndTime = DecodeTimeCode(arr[1]) }; + int start = line.IndexOf("', ',', '.' }, StringSplitOptions.RemoveEmptyEntries); + int milliseconds = int.Parse(parts[parts.Length - 1]); + int seconds = int.Parse(parts[parts.Length - 2]); + int minutes = 0; + if (parts.Length > 2) + { + minutes = int.Parse(parts[parts.Length - 3]); + } + + int hour = 0; + if (parts.Length > 3) + { + hour = int.Parse(parts[parts.Length - 4]); + } + + return new TimeCode(hour, minutes, seconds, milliseconds); + } + + } +} diff --git a/libse/SubtitleFormats/SmilTimesheetData.cs b/src/libse/SubtitleFormats/SmilTimesheetData.cs similarity index 97% rename from libse/SubtitleFormats/SmilTimesheetData.cs rename to src/libse/SubtitleFormats/SmilTimesheetData.cs index df39e4fd7..dcb50f2f4 100644 --- a/libse/SubtitleFormats/SmilTimesheetData.cs +++ b/src/libse/SubtitleFormats/SmilTimesheetData.cs @@ -1,236 +1,236 @@ -using System; -using System.Collections.Generic; -using System.Net; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - /// http://wam.inrialpes.fr/timesheets/annotations/video.html - /// - public class SmilTimesheetData : SubtitleFormat - { - public override string Extension => ".html"; - - public override string Name => "SMIL Timesheet"; - - public override bool IsMine(List lines, string fileName) - { - var sb = new StringBuilder(); - foreach (string l in lines) - { - sb.AppendLine(l); - } - - if (!sb.ToString().Contains(" data-begin")) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - string header = -@" - -" + Environment.NewLine + -"\t" + Environment.NewLine + -"\tSMIL Timesheet" + @" - -" + Environment.NewLine + -"\t
" + Environment.NewLine + -"\t\t" + Environment.NewLine; - - const string paragraphWriteFormatOpen = "\t\t

\r\n{1}\r\n

"; - const string paragraphWriteFormat = "\t\t

\r\n{2}\r\n

"; - int count = 1; - var sb = new StringBuilder(); - sb.AppendLine(header.Replace("_TITLE_", title)); - foreach (Paragraph p in subtitle.Paragraphs) - { - Paragraph next = subtitle.GetParagraphOrDefault(count); - string text = p.Text; - if (next != null && Math.Abs(next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds) < 100) - { - sb.AppendLine(string.Format(paragraphWriteFormatOpen, EncodeTime(p.StartTime), text)); - } - else - { - sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTime(p.StartTime), EncodeTime(p.EndTime), text)); - } - - count++; - } - sb.AppendLine("\t
"); - sb.AppendLine(""); - sb.AppendLine(""); - return sb.ToString().Trim(); - } - - private static string EncodeTime(TimeCode time) - { - //3:15:22 - if (time.Hours > 0) - { - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}.{time.Milliseconds / 10:00}"; - } - - if (time.Minutes > 9) - { - return $"{time.Minutes:00}:{time.Seconds:00}.{time.Milliseconds / 10:00}"; - } - - return $"{time.Minutes}:{time.Seconds:00}.{time.Milliseconds / 10:00}"; - } - - private static TimeCode DecodeTimeCode(string[] s) - { - if (s.Length == 3) - { - return new TimeCode(0, int.Parse(s[0]), int.Parse(s[1]), int.Parse(s[2]) * 10); - } - - return new TimeCode(int.Parse(s[0]), int.Parse(s[1]), int.Parse(s[2]), int.Parse(s[3]) * 10); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var sb = new StringBuilder(); - foreach (string l in lines) - { - sb.AppendLine(l); - } - - string allInput = sb.ToString(); - string allInputLower = allInput.ToLowerInvariant(); - const string syncTag = "

= 0) - { - var syncEndPos = allInputLower.IndexOf("

", index, StringComparison.Ordinal); - if (syncEndPos > 0) - { - string s = allInput.Substring(syncStartPos + 2, syncEndPos - syncStartPos - 2); - int indexOfBegin = s.IndexOf(" data-begin=", StringComparison.Ordinal); - int indexOfAttributesEnd = s.IndexOf('>'); - if (indexOfBegin >= 0 && indexOfAttributesEnd > indexOfBegin) - { - string text = s.Substring(indexOfAttributesEnd + 1).Trim(); - text = text.Replace("
", Environment.NewLine); - text = text.Replace("
", Environment.NewLine); - text = text.Replace("
", Environment.NewLine); - text = text.Replace("\t", " "); - while (text.Contains(" ")) - { - text = text.Replace(" ", " "); - } - - while (text.Contains(Environment.NewLine + " ")) - { - text = text.Replace(Environment.NewLine + " ", Environment.NewLine); - } - - while (text.Contains(Environment.NewLine + Environment.NewLine)) - { - text = text.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); - } - - string begin = s.Substring(indexOfBegin + " data-begin=".Length); - tcBegin.Clear(); - for (int i = 0; i <= 10; i++) - { - if (begin.Length > i && @"0123456789:.".Contains(begin[i])) - { - tcBegin.Append(begin[i]); - } - } - - tcEnd.Clear(); - var indexOfEnd = s.IndexOf(" data-end=", StringComparison.Ordinal); - if (indexOfEnd >= 0) - { - string end = s.Substring(indexOfEnd + " data-end=".Length); - for (int i = 0; i <= 10; i++) - { - if (end.Length > i && @"0123456789:.".Contains(end[i])) - { - tcEnd.Append(end[i]); - } - } - } - - var arr = tcBegin.ToString().Split(splitChars, StringSplitOptions.RemoveEmptyEntries); - if (arr.Length == 3 || arr.Length == 4) - { - var p = new Paragraph { Text = text }; - try - { - p.StartTime = DecodeTimeCode(arr); - if (tcEnd.Length > 0) - { - arr = tcEnd.ToString().Split(splitChars, StringSplitOptions.RemoveEmptyEntries); - p.EndTime = DecodeTimeCode(arr); - } - subtitle.Paragraphs.Add(p); - } - catch - { - _errorCount++; - } - } - } - } - if (syncEndPos <= 0) - { - syncStartPos = -1; - } - else - { - syncStartPos = allInputLower.IndexOf(syncTag, syncEndPos, StringComparison.Ordinal); - index = syncStartPos + syncTag.Length; - } - } - - index = 1; - foreach (Paragraph paragraph in subtitle.Paragraphs) - { - Paragraph next = subtitle.GetParagraphOrDefault(index); - if (next != null) - { - paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1; - } - else if (paragraph.EndTime.TotalMilliseconds < 50) - { - paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text); - } - if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) - { - paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text); - } - index++; - } - - foreach (Paragraph p2 in subtitle.Paragraphs) - { - p2.Text = WebUtility.HtmlDecode(p2.Text); - } - - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Net; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + /// + /// http://wam.inrialpes.fr/timesheets/annotations/video.html + /// + public class SmilTimesheetData : SubtitleFormat + { + public override string Extension => ".html"; + + public override string Name => "SMIL Timesheet"; + + public override bool IsMine(List lines, string fileName) + { + var sb = new StringBuilder(); + foreach (string l in lines) + { + sb.AppendLine(l); + } + + if (!sb.ToString().Contains(" data-begin")) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + string header = +@" + +" + Environment.NewLine + +"\t" + Environment.NewLine + +"\tSMIL Timesheet" + @" + +" + Environment.NewLine + +"\t
" + Environment.NewLine + +"\t\t" + Environment.NewLine; + + const string paragraphWriteFormatOpen = "\t\t

\r\n{1}\r\n

"; + const string paragraphWriteFormat = "\t\t

\r\n{2}\r\n

"; + int count = 1; + var sb = new StringBuilder(); + sb.AppendLine(header.Replace("_TITLE_", title)); + foreach (Paragraph p in subtitle.Paragraphs) + { + Paragraph next = subtitle.GetParagraphOrDefault(count); + string text = p.Text; + if (next != null && Math.Abs(next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds) < 100) + { + sb.AppendLine(string.Format(paragraphWriteFormatOpen, EncodeTime(p.StartTime), text)); + } + else + { + sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTime(p.StartTime), EncodeTime(p.EndTime), text)); + } + + count++; + } + sb.AppendLine("\t
"); + sb.AppendLine(""); + sb.AppendLine(""); + return sb.ToString().Trim(); + } + + private static string EncodeTime(TimeCode time) + { + //3:15:22 + if (time.Hours > 0) + { + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}.{time.Milliseconds / 10:00}"; + } + + if (time.Minutes > 9) + { + return $"{time.Minutes:00}:{time.Seconds:00}.{time.Milliseconds / 10:00}"; + } + + return $"{time.Minutes}:{time.Seconds:00}.{time.Milliseconds / 10:00}"; + } + + private static TimeCode DecodeTimeCode(string[] s) + { + if (s.Length == 3) + { + return new TimeCode(0, int.Parse(s[0]), int.Parse(s[1]), int.Parse(s[2]) * 10); + } + + return new TimeCode(int.Parse(s[0]), int.Parse(s[1]), int.Parse(s[2]), int.Parse(s[3]) * 10); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var sb = new StringBuilder(); + foreach (string l in lines) + { + sb.AppendLine(l); + } + + string allInput = sb.ToString(); + string allInputLower = allInput.ToLowerInvariant(); + const string syncTag = "

= 0) + { + var syncEndPos = allInputLower.IndexOf("

", index, StringComparison.Ordinal); + if (syncEndPos > 0) + { + string s = allInput.Substring(syncStartPos + 2, syncEndPos - syncStartPos - 2); + int indexOfBegin = s.IndexOf(" data-begin=", StringComparison.Ordinal); + int indexOfAttributesEnd = s.IndexOf('>'); + if (indexOfBegin >= 0 && indexOfAttributesEnd > indexOfBegin) + { + string text = s.Substring(indexOfAttributesEnd + 1).Trim(); + text = text.Replace("
", Environment.NewLine); + text = text.Replace("
", Environment.NewLine); + text = text.Replace("
", Environment.NewLine); + text = text.Replace("\t", " "); + while (text.Contains(" ")) + { + text = text.Replace(" ", " "); + } + + while (text.Contains(Environment.NewLine + " ")) + { + text = text.Replace(Environment.NewLine + " ", Environment.NewLine); + } + + while (text.Contains(Environment.NewLine + Environment.NewLine)) + { + text = text.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); + } + + string begin = s.Substring(indexOfBegin + " data-begin=".Length); + tcBegin.Clear(); + for (int i = 0; i <= 10; i++) + { + if (begin.Length > i && @"0123456789:.".Contains(begin[i])) + { + tcBegin.Append(begin[i]); + } + } + + tcEnd.Clear(); + var indexOfEnd = s.IndexOf(" data-end=", StringComparison.Ordinal); + if (indexOfEnd >= 0) + { + string end = s.Substring(indexOfEnd + " data-end=".Length); + for (int i = 0; i <= 10; i++) + { + if (end.Length > i && @"0123456789:.".Contains(end[i])) + { + tcEnd.Append(end[i]); + } + } + } + + var arr = tcBegin.ToString().Split(splitChars, StringSplitOptions.RemoveEmptyEntries); + if (arr.Length == 3 || arr.Length == 4) + { + var p = new Paragraph { Text = text }; + try + { + p.StartTime = DecodeTimeCode(arr); + if (tcEnd.Length > 0) + { + arr = tcEnd.ToString().Split(splitChars, StringSplitOptions.RemoveEmptyEntries); + p.EndTime = DecodeTimeCode(arr); + } + subtitle.Paragraphs.Add(p); + } + catch + { + _errorCount++; + } + } + } + } + if (syncEndPos <= 0) + { + syncStartPos = -1; + } + else + { + syncStartPos = allInputLower.IndexOf(syncTag, syncEndPos, StringComparison.Ordinal); + index = syncStartPos + syncTag.Length; + } + } + + index = 1; + foreach (Paragraph paragraph in subtitle.Paragraphs) + { + Paragraph next = subtitle.GetParagraphOrDefault(index); + if (next != null) + { + paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1; + } + else if (paragraph.EndTime.TotalMilliseconds < 50) + { + paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text); + } + if (paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) + { + paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(paragraph.Text); + } + index++; + } + + foreach (Paragraph p2 in subtitle.Paragraphs) + { + p2.Text = WebUtility.HtmlDecode(p2.Text); + } + + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/SmpteTt2052.cs b/src/libse/SubtitleFormats/SmpteTt2052.cs similarity index 100% rename from libse/SubtitleFormats/SmpteTt2052.cs rename to src/libse/SubtitleFormats/SmpteTt2052.cs diff --git a/libse/SubtitleFormats/SoftNiColonSub.cs b/src/libse/SubtitleFormats/SoftNiColonSub.cs similarity index 97% rename from libse/SubtitleFormats/SoftNiColonSub.cs rename to src/libse/SubtitleFormats/SoftNiColonSub.cs index 14ca011ea..4a49a15de 100644 --- a/libse/SubtitleFormats/SoftNiColonSub.cs +++ b/src/libse/SubtitleFormats/SoftNiColonSub.cs @@ -1,229 +1,229 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - /// SoftNi - http://www.softni.com/ - /// - public class SoftNicolonSub : SubtitleFormat - { - private static readonly Regex regexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d\\\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); - - public override string Extension => ".sub"; - - public override string Name => "SoftNi colon sub"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - var lineSb = new StringBuilder(); - sb.AppendLine("*PART 1*"); - sb.AppendLine("00:00:00:00\\00:00:00:00"); - foreach (Paragraph p in subtitle.Paragraphs) - { - string text = p.Text; - bool positionTop = false; - - // If text starts with {\an8}, subtitle appears at the top - if (text.StartsWith("{\\an8}", StringComparison.Ordinal)) - { - positionTop = true; - // Remove the tag {\an8}. - text = text.Remove(0, 6); - } - - // Split lines (split a subtitle into its lines) - var lines = text.SplitToLines(); - int count = 0; - lineSb.Clear(); - bool nextLineInItalics = false; - foreach (string line in lines) - { - // Append line break in every line except the first one - if (count > 0) - { - lineSb.Append(Environment.NewLine); - } - - var tempLine = line; - - // This line should be in italics (it was detected in previous line) - if (nextLineInItalics) - { - tempLine = "" + tempLine; - nextLineInItalics = false; - } - - if (tempLine.StartsWith("", StringComparison.Ordinal) && tempLine.EndsWith("", StringComparison.Ordinal)) - { - // Whole line is in italics - // Remove from the beginning - tempLine = tempLine.Remove(0, 3); - // Remove from the end - tempLine = tempLine.Remove(tempLine.Length - 4, 4); - // Add new italics tag at the beginning - tempLine = "[" + tempLine; - } - else if (tempLine.StartsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(tempLine, "") > Utilities.CountTagInText(tempLine, "")) - { - // Line starts with but italics are not closed. So the next line should be in italics - nextLineInItalics = true; - } - lineSb.Append(tempLine); - count++; - - text = lineSb.ToString(); - // Replace remaining italics tags - text = text.Replace("", @"["); - text = text.Replace("", @"]"); - text = HtmlUtil.RemoveHtmlTags(text); - } - - // Add top-position SoftNI marker "}" at the beginning of first line. - if (positionTop) - { - text = "}" + text; - } - - sb.AppendLine($"{text}{Environment.NewLine}{p.StartTime.ToHHMMSSPeriodFF().Replace(".", ":")}\\{p.EndTime.ToHHMMSSPeriodFF().Replace(".", ":")}"); - } - sb.AppendLine(@"*END*"); - sb.AppendLine(@"...........\..........."); - sb.AppendLine(@"*CODE*"); - sb.AppendLine(@"0000000000000000"); - sb.AppendLine(@"*CAST*"); - sb.AppendLine(@"*GENERATOR*"); - sb.AppendLine(@"*FONTS*"); - sb.AppendLine(@"*READ*"); - sb.AppendLine(@"0,300 15,000 130,000 100,000 25,000"); - sb.AppendLine(@"*TIMING*"); - sb.AppendLine(@"1 25 0"); - sb.AppendLine(@"*TIMED BACKUP NAME*"); - sb.AppendLine(@"C:\"); - sb.AppendLine(@"*FORMAT SAMPLE ÅåÉéÌìÕõÛûÿ*"); - sb.AppendLine(@"*READ ADVANCED*"); - sb.AppendLine(@"< > 1 1 0,300"); - sb.AppendLine(@"*MARKERS*"); - return sb.ToString(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - DoLoadSubtitle(subtitle, lines); - } - - private void DoLoadSubtitle(Subtitle subtitle, List lines) - { - //—Peter. - //—Estoy de licencia. - //01:48:50.07\01:48:52.01 - var sb = new StringBuilder(); - var lineSb = new StringBuilder(); - Paragraph p = null; - subtitle.Paragraphs.Clear(); - char[] splitChars = { ':', '.' }; - foreach (string line in lines) - { - string s = line.Trim(); - if (regexTimeCodes.IsMatch(s)) - { - // Start and end time separated by "\" - var temp = s.Split('\\'); - if (temp.Length > 1) - { - string start = temp[0]; - string end = temp[1]; - - string[] startParts = start.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); - string[] endParts = end.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); - if (startParts.Length == 4 && endParts.Length == 4) - { - try - { - p = new Paragraph - { - StartTime = DecodeTimeCodeFramesFourParts(startParts), - EndTime = DecodeTimeCodeFramesFourParts(endParts) - }; - string text = sb.ToString().Trim(); - - bool positionTop = false; - // If text starts with "}", subtitle appears at the top - if (text.StartsWith('}')) - { - positionTop = true; - // Remove the tag "}" - text = text.Remove(0, 1); - } - // Replace tags - text = text.Replace("[", @""); - text = text.Replace("]", @""); - - // Split subtitle lines (one subtitle has one or more lines) - var subtitleLines = text.SplitToLines(); - int count = 0; - lineSb.Clear(); - foreach (string subtitleLine in subtitleLines) - { - // Append line break in every line except the first one - if (count > 0) - { - lineSb.Append(Environment.NewLine); - } - - var tempLine = subtitleLine; - // Close italics in every line (if next line is in italics, SoftNI will use "[" at the beginning) - if (Utilities.CountTagInText(tempLine, "") > Utilities.CountTagInText(tempLine, "")) - { - tempLine = tempLine + ""; - } - - lineSb.Append(tempLine); - count++; - } - text = lineSb.ToString(); - - // Replace "line break" with just a line break (SubRip does not need to close italics and open them again in the next line). - text = text.Replace("" + Environment.NewLine + "", Environment.NewLine); - - // Subtitle appears at the top (add tag) - if (positionTop) - { - text = "{\\an8}" + text; - } - - p.Text = text; - if (text.Length > 0) - { - subtitle.Paragraphs.Add(p); - } - - sb.Clear(); - } - catch (Exception exception) - { - _errorCount++; - System.Diagnostics.Debug.WriteLine(exception.Message); - } - } - } - } - else if (string.IsNullOrWhiteSpace(line) || line.StartsWith('*')) - { - // skip empty lines or start - } - else if (p != null) - { - sb.AppendLine(line); - } - } - - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + /// + /// SoftNi - http://www.softni.com/ + /// + public class SoftNicolonSub : SubtitleFormat + { + private static readonly Regex regexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d\\\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); + + public override string Extension => ".sub"; + + public override string Name => "SoftNi colon sub"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + var lineSb = new StringBuilder(); + sb.AppendLine("*PART 1*"); + sb.AppendLine("00:00:00:00\\00:00:00:00"); + foreach (Paragraph p in subtitle.Paragraphs) + { + string text = p.Text; + bool positionTop = false; + + // If text starts with {\an8}, subtitle appears at the top + if (text.StartsWith("{\\an8}", StringComparison.Ordinal)) + { + positionTop = true; + // Remove the tag {\an8}. + text = text.Remove(0, 6); + } + + // Split lines (split a subtitle into its lines) + var lines = text.SplitToLines(); + int count = 0; + lineSb.Clear(); + bool nextLineInItalics = false; + foreach (string line in lines) + { + // Append line break in every line except the first one + if (count > 0) + { + lineSb.Append(Environment.NewLine); + } + + var tempLine = line; + + // This line should be in italics (it was detected in previous line) + if (nextLineInItalics) + { + tempLine = "" + tempLine; + nextLineInItalics = false; + } + + if (tempLine.StartsWith("", StringComparison.Ordinal) && tempLine.EndsWith("", StringComparison.Ordinal)) + { + // Whole line is in italics + // Remove from the beginning + tempLine = tempLine.Remove(0, 3); + // Remove from the end + tempLine = tempLine.Remove(tempLine.Length - 4, 4); + // Add new italics tag at the beginning + tempLine = "[" + tempLine; + } + else if (tempLine.StartsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(tempLine, "") > Utilities.CountTagInText(tempLine, "")) + { + // Line starts with but italics are not closed. So the next line should be in italics + nextLineInItalics = true; + } + lineSb.Append(tempLine); + count++; + + text = lineSb.ToString(); + // Replace remaining italics tags + text = text.Replace("", @"["); + text = text.Replace("", @"]"); + text = HtmlUtil.RemoveHtmlTags(text); + } + + // Add top-position SoftNI marker "}" at the beginning of first line. + if (positionTop) + { + text = "}" + text; + } + + sb.AppendLine($"{text}{Environment.NewLine}{p.StartTime.ToHHMMSSPeriodFF().Replace(".", ":")}\\{p.EndTime.ToHHMMSSPeriodFF().Replace(".", ":")}"); + } + sb.AppendLine(@"*END*"); + sb.AppendLine(@"...........\..........."); + sb.AppendLine(@"*CODE*"); + sb.AppendLine(@"0000000000000000"); + sb.AppendLine(@"*CAST*"); + sb.AppendLine(@"*GENERATOR*"); + sb.AppendLine(@"*FONTS*"); + sb.AppendLine(@"*READ*"); + sb.AppendLine(@"0,300 15,000 130,000 100,000 25,000"); + sb.AppendLine(@"*TIMING*"); + sb.AppendLine(@"1 25 0"); + sb.AppendLine(@"*TIMED BACKUP NAME*"); + sb.AppendLine(@"C:\"); + sb.AppendLine(@"*FORMAT SAMPLE ÅåÉéÌìÕõÛûÿ*"); + sb.AppendLine(@"*READ ADVANCED*"); + sb.AppendLine(@"< > 1 1 0,300"); + sb.AppendLine(@"*MARKERS*"); + return sb.ToString(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + DoLoadSubtitle(subtitle, lines); + } + + private void DoLoadSubtitle(Subtitle subtitle, List lines) + { + //—Peter. + //—Estoy de licencia. + //01:48:50.07\01:48:52.01 + var sb = new StringBuilder(); + var lineSb = new StringBuilder(); + Paragraph p = null; + subtitle.Paragraphs.Clear(); + char[] splitChars = { ':', '.' }; + foreach (string line in lines) + { + string s = line.Trim(); + if (regexTimeCodes.IsMatch(s)) + { + // Start and end time separated by "\" + var temp = s.Split('\\'); + if (temp.Length > 1) + { + string start = temp[0]; + string end = temp[1]; + + string[] startParts = start.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); + string[] endParts = end.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); + if (startParts.Length == 4 && endParts.Length == 4) + { + try + { + p = new Paragraph + { + StartTime = DecodeTimeCodeFramesFourParts(startParts), + EndTime = DecodeTimeCodeFramesFourParts(endParts) + }; + string text = sb.ToString().Trim(); + + bool positionTop = false; + // If text starts with "}", subtitle appears at the top + if (text.StartsWith('}')) + { + positionTop = true; + // Remove the tag "}" + text = text.Remove(0, 1); + } + // Replace tags + text = text.Replace("[", @""); + text = text.Replace("]", @""); + + // Split subtitle lines (one subtitle has one or more lines) + var subtitleLines = text.SplitToLines(); + int count = 0; + lineSb.Clear(); + foreach (string subtitleLine in subtitleLines) + { + // Append line break in every line except the first one + if (count > 0) + { + lineSb.Append(Environment.NewLine); + } + + var tempLine = subtitleLine; + // Close italics in every line (if next line is in italics, SoftNI will use "[" at the beginning) + if (Utilities.CountTagInText(tempLine, "") > Utilities.CountTagInText(tempLine, "")) + { + tempLine = tempLine + ""; + } + + lineSb.Append(tempLine); + count++; + } + text = lineSb.ToString(); + + // Replace "line break" with just a line break (SubRip does not need to close italics and open them again in the next line). + text = text.Replace("" + Environment.NewLine + "", Environment.NewLine); + + // Subtitle appears at the top (add tag) + if (positionTop) + { + text = "{\\an8}" + text; + } + + p.Text = text; + if (text.Length > 0) + { + subtitle.Paragraphs.Add(p); + } + + sb.Clear(); + } + catch (Exception exception) + { + _errorCount++; + System.Diagnostics.Debug.WriteLine(exception.Message); + } + } + } + } + else if (string.IsNullOrWhiteSpace(line) || line.StartsWith('*')) + { + // skip empty lines or start + } + else if (p != null) + { + sb.AppendLine(line); + } + } + + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/SoftNiSub.cs b/src/libse/SubtitleFormats/SoftNiSub.cs similarity index 97% rename from libse/SubtitleFormats/SoftNiSub.cs rename to src/libse/SubtitleFormats/SoftNiSub.cs index d34c8b378..aad4b14e6 100644 --- a/libse/SubtitleFormats/SoftNiSub.cs +++ b/src/libse/SubtitleFormats/SoftNiSub.cs @@ -1,228 +1,228 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - /// SoftNi - http://www.softni.com/ - /// - public class SoftNiSub : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d\.\d\d\\\d\d:\d\d:\d\d\.\d\d$", RegexOptions.Compiled); - - public override string Extension => ".sub"; - - public override string Name => "SoftNi sub"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - var lineSb = new StringBuilder(); - sb.AppendLine("*PART 1*"); - sb.AppendLine("00:00:00.00\\00:00:00.00"); - const string writeFormat = "{0}{1}{2}\\{3}"; - foreach (Paragraph p in subtitle.Paragraphs) - { - string text = p.Text; - bool positionTop = false; - - // If text starts with {\an8}, subtitle appears at the top - if (text.StartsWith("{\\an8}", StringComparison.Ordinal)) - { - positionTop = true; - // Remove the tag {\an8}. - text = text.Remove(0, 6); - } - - // Split lines (split a subtitle into its lines) - var lines = text.SplitToLines(); - int count = 0; - lineSb.Clear(); - bool nextLineInItalics = false; - foreach (string line in lines) - { - // Append line break in every line except the first one - if (count > 0) - { - lineSb.Append(Environment.NewLine); - } - - var tempLine = line; - - // This line should be in italics (it was detected in previous line) - if (nextLineInItalics) - { - tempLine = "" + tempLine; - nextLineInItalics = false; - } - - if (tempLine.StartsWith("", StringComparison.Ordinal) && tempLine.EndsWith("", StringComparison.Ordinal)) - { - // Whole line is in italics - // Remove from the beginning - tempLine = tempLine.Remove(0, 3); - // Remove from the end - tempLine = tempLine.Remove(tempLine.Length - 4, 4); - // Add new italics tag at the beginning - tempLine = "[" + tempLine; - } - else if (tempLine.StartsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(tempLine, "") > Utilities.CountTagInText(tempLine, "")) - { - // Line starts with but italics are not closed. So the next line should be in italics - nextLineInItalics = true; - } - lineSb.Append(tempLine); - count++; - - text = lineSb.ToString(); - // Replace remaining italics tags - text = text.Replace("", @"["); - text = text.Replace("", @"]"); - text = HtmlUtil.RemoveHtmlTags(text); - } - - // Add top-position SoftNI marker "}" at the beginning of first line. - if (positionTop) - { - text = "}" + text; - } - - sb.AppendLine(string.Format(writeFormat, text, Environment.NewLine, p.StartTime.ToHHMMSSPeriodFF(), p.EndTime.ToHHMMSSPeriodFF())); - } - sb.AppendLine(@"*END*"); - sb.AppendLine(@"...........\..........."); - sb.AppendLine(@"*CODE*"); - sb.AppendLine(@"0000000000000000"); - sb.AppendLine(@"*CAST*"); - sb.AppendLine(@"*GENERATOR*"); - sb.AppendLine(@"*FONTS*"); - sb.AppendLine(@"*READ*"); - sb.AppendLine(@"0,300 15,000 130,000 100,000 25,000"); - sb.AppendLine(@"*TIMING*"); - sb.AppendLine(@"1 25 0"); - sb.AppendLine(@"*TIMED BACKUP NAME*"); - sb.AppendLine(@"C:\"); - sb.AppendLine(@"*FORMAT SAMPLE ÅåÉéÌìÕõÛûÿ*"); - sb.AppendLine(@"*READ ADVANCED*"); - sb.AppendLine(@"< > 1 1 0,300"); - sb.AppendLine(@"*MARKERS*"); - return sb.ToString(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - DoLoadSubtitle(subtitle, lines); - } - - private void DoLoadSubtitle(Subtitle subtitle, List lines) - { - //—Peter. - //—Estoy de licencia. - //01:48:50.07\01:48:52.01 - var sb = new StringBuilder(); - var lineSb = new StringBuilder(); - Paragraph p = null; - subtitle.Paragraphs.Clear(); - char[] splitChars = { ':', '.' }; - foreach (string line in lines) - { - string s = line.Trim(); - if (RegexTimeCodes.IsMatch(s)) - { - // Start and end time separated by "\" - var temp = s.Split('\\'); - if (temp.Length > 1) - { - string start = temp[0]; - string end = temp[1]; - - string[] startParts = start.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); - string[] endParts = end.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); - if (startParts.Length == 4 && endParts.Length == 4) - { - try - { - p = new Paragraph(); - p.StartTime = DecodeTimeCodeFramesFourParts(startParts); - p.EndTime = DecodeTimeCodeFramesFourParts(endParts); - string text = sb.ToString().Trim(); - - bool positionTop = false; - // If text starts with "}", subtitle appears at the top - if (text.StartsWith('}')) - { - positionTop = true; - // Remove the tag "{" - text = text.Remove(0, 1); - } - // Replace tags - text = text.Replace("[", @""); - text = text.Replace("]", @""); - - // Split subtitle lines (one subtitle has one or more lines) - var subtitleLines = text.SplitToLines(); - int count = 0; - lineSb.Clear(); - foreach (string subtitleLine in subtitleLines) - { - // Append line break in every line except the first one - if (count > 0) - { - lineSb.Append(Environment.NewLine); - } - - var tempLine = subtitleLine; - // Close italics in every line (if next line is in italics, SoftNI will use "[" at the beginning) - if (Utilities.CountTagInText(tempLine, "") > Utilities.CountTagInText(tempLine, "")) - { - tempLine = tempLine + ""; - } - - lineSb.Append(tempLine); - count++; - } - text = lineSb.ToString(); - - // Replace "line break" with just a line break (SubRip does not need to close italics and open them again in the next line). - text = text.Replace("" + Environment.NewLine + "", Environment.NewLine); - - // Subtitle appears at the top (add tag) - if (positionTop) - { - text = "{\\an8}" + text; - } - - p.Text = text; - if (text.Length > 0) - { - subtitle.Paragraphs.Add(p); - } - - sb.Clear(); - } - catch (Exception exception) - { - _errorCount++; - System.Diagnostics.Debug.WriteLine(exception.Message); - } - } - } - } - else if (string.IsNullOrWhiteSpace(line) || line.StartsWith('*')) - { - // skip empty lines - } - else if (p != null) - { - sb.AppendLine(line); - } - } - - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + /// + /// SoftNi - http://www.softni.com/ + /// + public class SoftNiSub : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d\.\d\d\\\d\d:\d\d:\d\d\.\d\d$", RegexOptions.Compiled); + + public override string Extension => ".sub"; + + public override string Name => "SoftNi sub"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + var lineSb = new StringBuilder(); + sb.AppendLine("*PART 1*"); + sb.AppendLine("00:00:00.00\\00:00:00.00"); + const string writeFormat = "{0}{1}{2}\\{3}"; + foreach (Paragraph p in subtitle.Paragraphs) + { + string text = p.Text; + bool positionTop = false; + + // If text starts with {\an8}, subtitle appears at the top + if (text.StartsWith("{\\an8}", StringComparison.Ordinal)) + { + positionTop = true; + // Remove the tag {\an8}. + text = text.Remove(0, 6); + } + + // Split lines (split a subtitle into its lines) + var lines = text.SplitToLines(); + int count = 0; + lineSb.Clear(); + bool nextLineInItalics = false; + foreach (string line in lines) + { + // Append line break in every line except the first one + if (count > 0) + { + lineSb.Append(Environment.NewLine); + } + + var tempLine = line; + + // This line should be in italics (it was detected in previous line) + if (nextLineInItalics) + { + tempLine = "" + tempLine; + nextLineInItalics = false; + } + + if (tempLine.StartsWith("", StringComparison.Ordinal) && tempLine.EndsWith("", StringComparison.Ordinal)) + { + // Whole line is in italics + // Remove from the beginning + tempLine = tempLine.Remove(0, 3); + // Remove from the end + tempLine = tempLine.Remove(tempLine.Length - 4, 4); + // Add new italics tag at the beginning + tempLine = "[" + tempLine; + } + else if (tempLine.StartsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(tempLine, "") > Utilities.CountTagInText(tempLine, "")) + { + // Line starts with but italics are not closed. So the next line should be in italics + nextLineInItalics = true; + } + lineSb.Append(tempLine); + count++; + + text = lineSb.ToString(); + // Replace remaining italics tags + text = text.Replace("", @"["); + text = text.Replace("", @"]"); + text = HtmlUtil.RemoveHtmlTags(text); + } + + // Add top-position SoftNI marker "}" at the beginning of first line. + if (positionTop) + { + text = "}" + text; + } + + sb.AppendLine(string.Format(writeFormat, text, Environment.NewLine, p.StartTime.ToHHMMSSPeriodFF(), p.EndTime.ToHHMMSSPeriodFF())); + } + sb.AppendLine(@"*END*"); + sb.AppendLine(@"...........\..........."); + sb.AppendLine(@"*CODE*"); + sb.AppendLine(@"0000000000000000"); + sb.AppendLine(@"*CAST*"); + sb.AppendLine(@"*GENERATOR*"); + sb.AppendLine(@"*FONTS*"); + sb.AppendLine(@"*READ*"); + sb.AppendLine(@"0,300 15,000 130,000 100,000 25,000"); + sb.AppendLine(@"*TIMING*"); + sb.AppendLine(@"1 25 0"); + sb.AppendLine(@"*TIMED BACKUP NAME*"); + sb.AppendLine(@"C:\"); + sb.AppendLine(@"*FORMAT SAMPLE ÅåÉéÌìÕõÛûÿ*"); + sb.AppendLine(@"*READ ADVANCED*"); + sb.AppendLine(@"< > 1 1 0,300"); + sb.AppendLine(@"*MARKERS*"); + return sb.ToString(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + DoLoadSubtitle(subtitle, lines); + } + + private void DoLoadSubtitle(Subtitle subtitle, List lines) + { + //—Peter. + //—Estoy de licencia. + //01:48:50.07\01:48:52.01 + var sb = new StringBuilder(); + var lineSb = new StringBuilder(); + Paragraph p = null; + subtitle.Paragraphs.Clear(); + char[] splitChars = { ':', '.' }; + foreach (string line in lines) + { + string s = line.Trim(); + if (RegexTimeCodes.IsMatch(s)) + { + // Start and end time separated by "\" + var temp = s.Split('\\'); + if (temp.Length > 1) + { + string start = temp[0]; + string end = temp[1]; + + string[] startParts = start.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); + string[] endParts = end.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); + if (startParts.Length == 4 && endParts.Length == 4) + { + try + { + p = new Paragraph(); + p.StartTime = DecodeTimeCodeFramesFourParts(startParts); + p.EndTime = DecodeTimeCodeFramesFourParts(endParts); + string text = sb.ToString().Trim(); + + bool positionTop = false; + // If text starts with "}", subtitle appears at the top + if (text.StartsWith('}')) + { + positionTop = true; + // Remove the tag "{" + text = text.Remove(0, 1); + } + // Replace tags + text = text.Replace("[", @""); + text = text.Replace("]", @""); + + // Split subtitle lines (one subtitle has one or more lines) + var subtitleLines = text.SplitToLines(); + int count = 0; + lineSb.Clear(); + foreach (string subtitleLine in subtitleLines) + { + // Append line break in every line except the first one + if (count > 0) + { + lineSb.Append(Environment.NewLine); + } + + var tempLine = subtitleLine; + // Close italics in every line (if next line is in italics, SoftNI will use "[" at the beginning) + if (Utilities.CountTagInText(tempLine, "") > Utilities.CountTagInText(tempLine, "")) + { + tempLine = tempLine + ""; + } + + lineSb.Append(tempLine); + count++; + } + text = lineSb.ToString(); + + // Replace "line break" with just a line break (SubRip does not need to close italics and open them again in the next line). + text = text.Replace("" + Environment.NewLine + "", Environment.NewLine); + + // Subtitle appears at the top (add tag) + if (positionTop) + { + text = "{\\an8}" + text; + } + + p.Text = text; + if (text.Length > 0) + { + subtitle.Paragraphs.Add(p); + } + + sb.Clear(); + } + catch (Exception exception) + { + _errorCount++; + System.Diagnostics.Debug.WriteLine(exception.Message); + } + } + } + } + else if (string.IsNullOrWhiteSpace(line) || line.StartsWith('*')) + { + // skip empty lines + } + else if (p != null) + { + sb.AppendLine(line); + } + } + + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/Son.cs b/src/libse/SubtitleFormats/Son.cs similarity index 97% rename from libse/SubtitleFormats/Son.cs rename to src/libse/SubtitleFormats/Son.cs index de02f58b7..2869c2dbf 100644 --- a/libse/SubtitleFormats/Son.cs +++ b/src/libse/SubtitleFormats/Son.cs @@ -1,68 +1,68 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Son : SubtitleFormat - { - public override string Extension => ".son"; - - public override string Name => "SON"; - - public override string ToText(Subtitle subtitle, string title) - { - const string writeFormat = "{0:0000}\t{1}\t{2}\t{3}"; - var sb = new StringBuilder(); - int index = 0; - foreach (Paragraph p in subtitle.Paragraphs) - { - index++; - sb.AppendLine(string.Format(writeFormat, index, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), HtmlUtil.RemoveHtmlTags(p.Text).Replace(Environment.NewLine, "\t"))); - } - return sb.ToString(); - } - - private static string EncodeTimeCode(TimeCode time) - { - //00:03:15:22 (last is frame) - return time.ToHHMMSSFF(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - //0001 00:00:19:13 00:00:22:10 a_0001.tif - var regexTimeCodes = new Regex(@"^\d\d\d\d\t+(\d\d:\d\d:\d\d:\d\d)\t(\d\d:\d\d:\d\d:\d\d)\t.+\.(?:tif|tiff|png|bmp|TIF|TIFF|PNG|BMP)", RegexOptions.Compiled); - Paragraph p = null; - subtitle.Paragraphs.Clear(); - _errorCount = 0; - int index = 0; - foreach (string line in lines) - { - var match = regexTimeCodes.Match(line); - if (match.Success) - { - var start = DecodeTimeCodeFramesFourParts(match.Groups[1].Value.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries)); - var end = DecodeTimeCodeFramesFourParts(match.Groups[2].Value.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries)); - var lastTabIndex = line.LastIndexOf('\t'); - var text = line.Substring(lastTabIndex + 1).Trim(); - p = new Paragraph(start, end, text); - subtitle.Paragraphs.Add(p); - } - else if (index < 10 || string.IsNullOrWhiteSpace(line) || line[0] == '#' || line.StartsWith("Display_Area", StringComparison.Ordinal) || line.StartsWith("Color", StringComparison.Ordinal)) - { - // skip these lines - } - else if (p != null) - { - _errorCount++; - } - index++; - } - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Son : SubtitleFormat + { + public override string Extension => ".son"; + + public override string Name => "SON"; + + public override string ToText(Subtitle subtitle, string title) + { + const string writeFormat = "{0:0000}\t{1}\t{2}\t{3}"; + var sb = new StringBuilder(); + int index = 0; + foreach (Paragraph p in subtitle.Paragraphs) + { + index++; + sb.AppendLine(string.Format(writeFormat, index, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), HtmlUtil.RemoveHtmlTags(p.Text).Replace(Environment.NewLine, "\t"))); + } + return sb.ToString(); + } + + private static string EncodeTimeCode(TimeCode time) + { + //00:03:15:22 (last is frame) + return time.ToHHMMSSFF(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + //0001 00:00:19:13 00:00:22:10 a_0001.tif + var regexTimeCodes = new Regex(@"^\d\d\d\d\t+(\d\d:\d\d:\d\d:\d\d)\t(\d\d:\d\d:\d\d:\d\d)\t.+\.(?:tif|tiff|png|bmp|TIF|TIFF|PNG|BMP)", RegexOptions.Compiled); + Paragraph p = null; + subtitle.Paragraphs.Clear(); + _errorCount = 0; + int index = 0; + foreach (string line in lines) + { + var match = regexTimeCodes.Match(line); + if (match.Success) + { + var start = DecodeTimeCodeFramesFourParts(match.Groups[1].Value.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries)); + var end = DecodeTimeCodeFramesFourParts(match.Groups[2].Value.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries)); + var lastTabIndex = line.LastIndexOf('\t'); + var text = line.Substring(lastTabIndex + 1).Trim(); + p = new Paragraph(start, end, text); + subtitle.Paragraphs.Add(p); + } + else if (index < 10 || string.IsNullOrWhiteSpace(line) || line[0] == '#' || line.StartsWith("Display_Area", StringComparison.Ordinal) || line.StartsWith("Color", StringComparison.Ordinal)) + { + // skip these lines + } + else if (p != null) + { + _errorCount++; + } + index++; + } + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/SonicScenaristBitmaps.cs b/src/libse/SubtitleFormats/SonicScenaristBitmaps.cs similarity index 97% rename from libse/SubtitleFormats/SonicScenaristBitmaps.cs rename to src/libse/SubtitleFormats/SonicScenaristBitmaps.cs index 353673489..111f59b1e 100644 --- a/libse/SubtitleFormats/SonicScenaristBitmaps.cs +++ b/src/libse/SubtitleFormats/SonicScenaristBitmaps.cs @@ -1,93 +1,93 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SonicScenaristBitmaps : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d{1,4}\s+\d\d:\d\d:\d\d:\d\d\s+\d\d:\d\d:\d\d:\d\d\s+.+\.(tif|tiff|png|bmp|TIF|TIFF|PNG|BMP)", RegexOptions.Compiled); - - public override string Extension => ".sst"; - - public override string Name => "Sonic Scenarist Bitmaps"; - - public override bool IsMine(List lines, string fileName) - { - var extension = System.IO.Path.GetExtension(fileName); - if (extension != null && extension.ToLowerInvariant() != ".sst") - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - int index = 0; - const string writeFormat = "{0:0000} {1} {2} {3}"; - foreach (Paragraph p in subtitle.Paragraphs) - { - //0001 00:49:26:22 00:49:27:13 t01_v001c001_22_0001.bmp - sb.AppendLine(string.Format(writeFormat, index + 1, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), HtmlUtil.RemoveHtmlTags(p.Text).Replace(Environment.NewLine, "\t"))); - index++; - } - return sb.ToString(); - } - - private static string EncodeTimeCode(TimeCode time) - { - //00:03:15:22 (last is frame) - return time.ToHHMMSSFF(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - //00:03:15:22 00:03:23:10 This is line one. - //This is line two. - Paragraph p = null; - subtitle.Paragraphs.Clear(); - _errorCount = 0; - int index = 0; - char[] splitChar = { ' ' }; - var sb = new StringBuilder(); - foreach (string line in lines) - { - if (RegexTimeCodes.IsMatch(line)) - { - string temp = line.Substring(0, RegexTimeCodes.Match(line).Length).Replace("\t", " "); - - string[] parts = temp.Split(splitChar, StringSplitOptions.RemoveEmptyEntries); - - if (parts.Length > 3) - { - sb.Clear(); - for (int i = 3; i < parts.Length; i++) - { - sb.Append(parts[i] + " "); - } - - string text = sb.ToString().Trim(); - p = new Paragraph(DecodeTimeCodeFramesFourParts(parts[1].Split(SplitCharColon)), DecodeTimeCodeFramesFourParts(parts[2].Split(SplitCharColon)), text); - subtitle.Paragraphs.Add(p); - } - } - else if (string.IsNullOrWhiteSpace(line) || line.StartsWith("Display_Area", StringComparison.Ordinal) || line.StartsWith('#') || line.StartsWith("Color", StringComparison.Ordinal) || index < 10) - { - // skip these lines - } - else if (p != null) - { - _errorCount++; - } - index++; - } - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SonicScenaristBitmaps : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d{1,4}\s+\d\d:\d\d:\d\d:\d\d\s+\d\d:\d\d:\d\d:\d\d\s+.+\.(tif|tiff|png|bmp|TIF|TIFF|PNG|BMP)", RegexOptions.Compiled); + + public override string Extension => ".sst"; + + public override string Name => "Sonic Scenarist Bitmaps"; + + public override bool IsMine(List lines, string fileName) + { + var extension = System.IO.Path.GetExtension(fileName); + if (extension != null && extension.ToLowerInvariant() != ".sst") + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + int index = 0; + const string writeFormat = "{0:0000} {1} {2} {3}"; + foreach (Paragraph p in subtitle.Paragraphs) + { + //0001 00:49:26:22 00:49:27:13 t01_v001c001_22_0001.bmp + sb.AppendLine(string.Format(writeFormat, index + 1, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), HtmlUtil.RemoveHtmlTags(p.Text).Replace(Environment.NewLine, "\t"))); + index++; + } + return sb.ToString(); + } + + private static string EncodeTimeCode(TimeCode time) + { + //00:03:15:22 (last is frame) + return time.ToHHMMSSFF(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + //00:03:15:22 00:03:23:10 This is line one. + //This is line two. + Paragraph p = null; + subtitle.Paragraphs.Clear(); + _errorCount = 0; + int index = 0; + char[] splitChar = { ' ' }; + var sb = new StringBuilder(); + foreach (string line in lines) + { + if (RegexTimeCodes.IsMatch(line)) + { + string temp = line.Substring(0, RegexTimeCodes.Match(line).Length).Replace("\t", " "); + + string[] parts = temp.Split(splitChar, StringSplitOptions.RemoveEmptyEntries); + + if (parts.Length > 3) + { + sb.Clear(); + for (int i = 3; i < parts.Length; i++) + { + sb.Append(parts[i] + " "); + } + + string text = sb.ToString().Trim(); + p = new Paragraph(DecodeTimeCodeFramesFourParts(parts[1].Split(SplitCharColon)), DecodeTimeCodeFramesFourParts(parts[2].Split(SplitCharColon)), text); + subtitle.Paragraphs.Add(p); + } + } + else if (string.IsNullOrWhiteSpace(line) || line.StartsWith("Display_Area", StringComparison.Ordinal) || line.StartsWith('#') || line.StartsWith("Color", StringComparison.Ordinal) || index < 10) + { + // skip these lines + } + else if (p != null) + { + _errorCount++; + } + index++; + } + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/SonyDVDArchitect.cs b/src/libse/SubtitleFormats/SonyDVDArchitect.cs similarity index 97% rename from libse/SubtitleFormats/SonyDVDArchitect.cs rename to src/libse/SubtitleFormats/SonyDVDArchitect.cs index 5f3582260..275aaf93d 100644 --- a/libse/SubtitleFormats/SonyDVDArchitect.cs +++ b/src/libse/SubtitleFormats/SonyDVDArchitect.cs @@ -1,95 +1,95 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SonyDVDArchitect : SubtitleFormat - { - private static readonly Regex Regex = new Regex(@"^\d\d:\d\d:\d\d:\d\d[ ]+-[ ]+\d\d:\d\d:\d\d:\d\d", RegexOptions.Compiled); - - public override string Extension => ".sub"; - - public override string Name => "Sony DVDArchitect"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - const string writeFormat = "{0:00}:{1:00}:{2:00}:{3:00} - {4:00}:{5:00}:{6:00}:{7:00} \t{8}"; - foreach (Paragraph p in subtitle.Paragraphs) - { - var text = HtmlUtil.RemoveHtmlTags(p.Text, true); - text = text.Replace(Environment.NewLine, "\r"); - sb.AppendLine(string.Format(writeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10, - p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10, - text)); - } - return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - // 00:04:10:92 - 00:04:13:32 Raise Yourself To Help Mankind - // 00:04:27:92 - 00:04:30:92 الجهة المتولية للمسئولية الاجتماعية لشركتنا. - - _errorCount = 0; - Paragraph lastParagraph = null; - foreach (string line in lines) - { - if (string.IsNullOrWhiteSpace(line)) - { - continue; - } - - bool success = false; - - Match match = null; - if (line.Length > 26 && line[2] == ':') - { - match = Regex.Match(line); - } - - if (match != null && match.Success) - { - string s = line.Substring(0, match.Length); - s = s.Replace(" - ", ":"); - s = s.RemoveChar(' '); - string[] parts = s.Split(':'); - if (parts.Length == 8) - { - int hours = int.Parse(parts[0]); - int minutes = int.Parse(parts[1]); - int seconds = int.Parse(parts[2]); - int milliseconds = int.Parse(parts[3]) * 10; - var start = new TimeCode(hours, minutes, seconds, milliseconds); - - hours = int.Parse(parts[4]); - minutes = int.Parse(parts[5]); - seconds = int.Parse(parts[6]); - milliseconds = int.Parse(parts[7]) * 10; - var end = new TimeCode(hours, minutes, seconds, milliseconds); - - string text = line.Substring(match.Length).TrimStart(); - text = text.Replace("|", Environment.NewLine); - - lastParagraph = new Paragraph(start, end, text); - subtitle.Paragraphs.Add(lastParagraph); - success = true; - } - } - else if (lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) - { - lastParagraph.Text += Environment.NewLine + line.Trim(); - success = true; - } - if (!success) - { - _errorCount++; - } - } - subtitle.Renumber(); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SonyDVDArchitect : SubtitleFormat + { + private static readonly Regex Regex = new Regex(@"^\d\d:\d\d:\d\d:\d\d[ ]+-[ ]+\d\d:\d\d:\d\d:\d\d", RegexOptions.Compiled); + + public override string Extension => ".sub"; + + public override string Name => "Sony DVDArchitect"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + const string writeFormat = "{0:00}:{1:00}:{2:00}:{3:00} - {4:00}:{5:00}:{6:00}:{7:00} \t{8}"; + foreach (Paragraph p in subtitle.Paragraphs) + { + var text = HtmlUtil.RemoveHtmlTags(p.Text, true); + text = text.Replace(Environment.NewLine, "\r"); + sb.AppendLine(string.Format(writeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10, + p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10, + text)); + } + return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + // 00:04:10:92 - 00:04:13:32 Raise Yourself To Help Mankind + // 00:04:27:92 - 00:04:30:92 الجهة المتولية للمسئولية الاجتماعية لشركتنا. + + _errorCount = 0; + Paragraph lastParagraph = null; + foreach (string line in lines) + { + if (string.IsNullOrWhiteSpace(line)) + { + continue; + } + + bool success = false; + + Match match = null; + if (line.Length > 26 && line[2] == ':') + { + match = Regex.Match(line); + } + + if (match != null && match.Success) + { + string s = line.Substring(0, match.Length); + s = s.Replace(" - ", ":"); + s = s.RemoveChar(' '); + string[] parts = s.Split(':'); + if (parts.Length == 8) + { + int hours = int.Parse(parts[0]); + int minutes = int.Parse(parts[1]); + int seconds = int.Parse(parts[2]); + int milliseconds = int.Parse(parts[3]) * 10; + var start = new TimeCode(hours, minutes, seconds, milliseconds); + + hours = int.Parse(parts[4]); + minutes = int.Parse(parts[5]); + seconds = int.Parse(parts[6]); + milliseconds = int.Parse(parts[7]) * 10; + var end = new TimeCode(hours, minutes, seconds, milliseconds); + + string text = line.Substring(match.Length).TrimStart(); + text = text.Replace("|", Environment.NewLine); + + lastParagraph = new Paragraph(start, end, text); + subtitle.Paragraphs.Add(lastParagraph); + success = true; + } + } + else if (lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) + { + lastParagraph.Text += Environment.NewLine + line.Trim(); + success = true; + } + if (!success) + { + _errorCount++; + } + } + subtitle.Renumber(); + } + } +} diff --git a/libse/SubtitleFormats/SonyDVDArchitectExplicitDuration.cs b/src/libse/SubtitleFormats/SonyDVDArchitectExplicitDuration.cs similarity index 97% rename from libse/SubtitleFormats/SonyDVDArchitectExplicitDuration.cs rename to src/libse/SubtitleFormats/SonyDVDArchitectExplicitDuration.cs index 33b66f69d..013ff912e 100644 --- a/libse/SubtitleFormats/SonyDVDArchitectExplicitDuration.cs +++ b/src/libse/SubtitleFormats/SonyDVDArchitectExplicitDuration.cs @@ -1,99 +1,99 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SonyDVDArchitectExplicitDuration : SubtitleFormat - { - private static readonly Regex Regex = new Regex(@"^\d\d:\d\d:\d\d\.\d\d\d[ \t]+\d\d:\d\d:\d\d\.\d\d\d[ \t]+\d\d:\d\d:\d\d\.\d\d\d[ \t]+", RegexOptions.Compiled); - - public override string Extension => ".sub"; - - public override string Name => "Sony DVDArchitect Explicit duration"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - const string writeFormat = "{0:00}:{1:00}:{2:00}.{3:000}\t{4:00}:{5:00}:{6:00}.{7:000}\t{8:00}:{9:00}:{10:00}.{11:000}\t{12}"; - foreach (Paragraph p in subtitle.Paragraphs) - { - string text = HtmlUtil.RemoveHtmlTags(p.Text); - text = text.Replace(Environment.NewLine, "\r"); - sb.AppendLine(string.Format(writeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds, - p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds, - p.Duration.Hours, p.Duration.Minutes, p.Duration.Seconds, p.Duration.Milliseconds, - text)); - } - return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { //00:02:10.354 00:02:13.047 00:00:02.693 Her er endnu en tekstfil fra DVD-Architect.Med 2 linier. - //00:02:14.018 00:02:19.018 00:00:05.000 - Prøvetekst 2- Linie 2 - //newline = \r (0D) - - _errorCount = 0; - Paragraph lastParagraph = null; - foreach (string line in lines) - { - if (string.IsNullOrWhiteSpace(line)) - { - continue; - } - - string s = line; - bool success = false; - bool isTimeCode = false; - - if (s.Length > 26 && s.IndexOf(':') == 2) - { - var match = Regex.Match(s); - if (match.Success) - { - isTimeCode = true; - s = s.Substring(0, match.Length); - s = s.Replace('\t', ':'); - s = s.Replace('.', ':'); - s = s.RemoveChar(' '); - s = s.Trim().TrimEnd(':').TrimEnd(); - string[] parts = s.Split(':'); - if (parts.Length == 12) - { - int hours = int.Parse(parts[0]); - int minutes = int.Parse(parts[1]); - int seconds = int.Parse(parts[2]); - int milliseconds = int.Parse(parts[3]); - var start = new TimeCode(hours, minutes, seconds, milliseconds); - - hours = int.Parse(parts[4]); - minutes = int.Parse(parts[5]); - seconds = int.Parse(parts[6]); - milliseconds = int.Parse(parts[7]); - var end = new TimeCode(hours, minutes, seconds, milliseconds); - - string text = line.Substring(match.Length).TrimStart(); - text = text.Replace("|", Environment.NewLine); - - lastParagraph = new Paragraph(start, end, text); - subtitle.Paragraphs.Add(lastParagraph); - success = true; - } - } - } - if (!isTimeCode && lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) - { - lastParagraph.Text += Environment.NewLine + line.Trim(); - success = true; - } - if (!success) - { - _errorCount++; - } - } - subtitle.Renumber(); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SonyDVDArchitectExplicitDuration : SubtitleFormat + { + private static readonly Regex Regex = new Regex(@"^\d\d:\d\d:\d\d\.\d\d\d[ \t]+\d\d:\d\d:\d\d\.\d\d\d[ \t]+\d\d:\d\d:\d\d\.\d\d\d[ \t]+", RegexOptions.Compiled); + + public override string Extension => ".sub"; + + public override string Name => "Sony DVDArchitect Explicit duration"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + const string writeFormat = "{0:00}:{1:00}:{2:00}.{3:000}\t{4:00}:{5:00}:{6:00}.{7:000}\t{8:00}:{9:00}:{10:00}.{11:000}\t{12}"; + foreach (Paragraph p in subtitle.Paragraphs) + { + string text = HtmlUtil.RemoveHtmlTags(p.Text); + text = text.Replace(Environment.NewLine, "\r"); + sb.AppendLine(string.Format(writeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds, + p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds, + p.Duration.Hours, p.Duration.Minutes, p.Duration.Seconds, p.Duration.Milliseconds, + text)); + } + return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { //00:02:10.354 00:02:13.047 00:00:02.693 Her er endnu en tekstfil fra DVD-Architect.Med 2 linier. + //00:02:14.018 00:02:19.018 00:00:05.000 - Prøvetekst 2- Linie 2 + //newline = \r (0D) + + _errorCount = 0; + Paragraph lastParagraph = null; + foreach (string line in lines) + { + if (string.IsNullOrWhiteSpace(line)) + { + continue; + } + + string s = line; + bool success = false; + bool isTimeCode = false; + + if (s.Length > 26 && s.IndexOf(':') == 2) + { + var match = Regex.Match(s); + if (match.Success) + { + isTimeCode = true; + s = s.Substring(0, match.Length); + s = s.Replace('\t', ':'); + s = s.Replace('.', ':'); + s = s.RemoveChar(' '); + s = s.Trim().TrimEnd(':').TrimEnd(); + string[] parts = s.Split(':'); + if (parts.Length == 12) + { + int hours = int.Parse(parts[0]); + int minutes = int.Parse(parts[1]); + int seconds = int.Parse(parts[2]); + int milliseconds = int.Parse(parts[3]); + var start = new TimeCode(hours, minutes, seconds, milliseconds); + + hours = int.Parse(parts[4]); + minutes = int.Parse(parts[5]); + seconds = int.Parse(parts[6]); + milliseconds = int.Parse(parts[7]); + var end = new TimeCode(hours, minutes, seconds, milliseconds); + + string text = line.Substring(match.Length).TrimStart(); + text = text.Replace("|", Environment.NewLine); + + lastParagraph = new Paragraph(start, end, text); + subtitle.Paragraphs.Add(lastParagraph); + success = true; + } + } + } + if (!isTimeCode && lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) + { + lastParagraph.Text += Environment.NewLine + line.Trim(); + success = true; + } + if (!success) + { + _errorCount++; + } + } + subtitle.Renumber(); + } + } +} diff --git a/libse/SubtitleFormats/SonyDVDArchitectLineAndDuration.cs b/src/libse/SubtitleFormats/SonyDVDArchitectLineAndDuration.cs similarity index 97% rename from libse/SubtitleFormats/SonyDVDArchitectLineAndDuration.cs rename to src/libse/SubtitleFormats/SonyDVDArchitectLineAndDuration.cs index b8fed4a56..4f1cea498 100644 --- a/libse/SubtitleFormats/SonyDVDArchitectLineAndDuration.cs +++ b/src/libse/SubtitleFormats/SonyDVDArchitectLineAndDuration.cs @@ -1,110 +1,110 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SonyDVDArchitectLineAndDuration : SubtitleFormat - { - private static readonly Regex Regex = new Regex(@"^\d+\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "Sony DVDArchitect line/duration"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - sb.AppendLine("Title: " + title); - sb.AppendLine("Translator: No Author"); - sb.AppendLine("Date: " + DateTime.Now.ToString("dd-MM-yyyy").Replace("-", ".")); // 25.08.2011 - double milliseconds = 0; - if (subtitle.Paragraphs.Count > 0) - { - milliseconds = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds; - } - - var tc = new TimeCode(milliseconds); - sb.AppendLine(string.Format("Duration: {0:00}:{1:00}:{2:00}:{3:00}", tc.Hours, tc.Minutes, tc.Seconds, MillisecondsToFramesMaxFrameRate(tc.Milliseconds))); // 01:20:49:12 - sb.AppendLine("Program start: 00:00:00:00"); - sb.AppendLine("Title count: " + subtitle.Paragraphs.Count); - sb.AppendLine(); - sb.AppendLine("#\tIn\tOut\tDuration"); - sb.AppendLine(); - int count = 0; - const string writeFormat = "{13}\t{0:00}:{1:00}:{2:00}:{3:00}\t{4:00}:{5:00}:{6:00}:{7:00}\t{8:00}:{9:00}:{10:00}:{11:00}\r\n{12}"; - foreach (Paragraph p in subtitle.Paragraphs) - { - count++; - var text = HtmlUtil.RemoveHtmlTags(p.Text, true); - - // to avoid rounding errors in duration - var startFrame = MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds); - var endFrame = MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds); - var durationCalc = new Paragraph( - new TimeCode(p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, FramesToMillisecondsMax999(startFrame)), - new TimeCode(p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, FramesToMillisecondsMax999(endFrame)), - string.Empty); - - sb.AppendLine(string.Format(writeFormat + Environment.NewLine, - p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, startFrame, - p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, endFrame, - durationCalc.Duration.Hours, durationCalc.Duration.Minutes, durationCalc.Duration.Seconds, MillisecondsToFramesMaxFrameRate(durationCalc.Duration.Milliseconds), - text, count)); - } - return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { //22 00:04:19:12 00:04:21:09 00:00:01:21 - _errorCount = 0; - Paragraph lastParagraph = null; - int count = 0; - foreach (string line in lines) - { - bool isTimeCode = false; - if (line.Length > 0) - { - bool success = false; - if (line.Length > 31 && line.IndexOf(':') > 1) - { - var match = Regex.Match(line); - if (match.Success) - { - isTimeCode = true; - if (lastParagraph != null) - { - subtitle.Paragraphs.Add(lastParagraph); - } - - var arr = line.Split('\t'); - TimeCode start = DecodeTimeCodeFrames(arr[1], SplitCharColon); - TimeCode end = DecodeTimeCodeFrames(arr[2], SplitCharColon); - lastParagraph = new Paragraph(start, end, string.Empty); - success = true; - } - } - if (!isTimeCode && !string.IsNullOrWhiteSpace(line) && lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) - { - lastParagraph.Text = (lastParagraph.Text + Environment.NewLine + line).Trim(); - success = true; - } - if (!success && count > 9) - { - _errorCount++; - } - } - count++; - } - if (lastParagraph != null) - { - subtitle.Paragraphs.Add(lastParagraph); - } - - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SonyDVDArchitectLineAndDuration : SubtitleFormat + { + private static readonly Regex Regex = new Regex(@"^\d+\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "Sony DVDArchitect line/duration"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + sb.AppendLine("Title: " + title); + sb.AppendLine("Translator: No Author"); + sb.AppendLine("Date: " + DateTime.Now.ToString("dd-MM-yyyy").Replace("-", ".")); // 25.08.2011 + double milliseconds = 0; + if (subtitle.Paragraphs.Count > 0) + { + milliseconds = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds; + } + + var tc = new TimeCode(milliseconds); + sb.AppendLine(string.Format("Duration: {0:00}:{1:00}:{2:00}:{3:00}", tc.Hours, tc.Minutes, tc.Seconds, MillisecondsToFramesMaxFrameRate(tc.Milliseconds))); // 01:20:49:12 + sb.AppendLine("Program start: 00:00:00:00"); + sb.AppendLine("Title count: " + subtitle.Paragraphs.Count); + sb.AppendLine(); + sb.AppendLine("#\tIn\tOut\tDuration"); + sb.AppendLine(); + int count = 0; + const string writeFormat = "{13}\t{0:00}:{1:00}:{2:00}:{3:00}\t{4:00}:{5:00}:{6:00}:{7:00}\t{8:00}:{9:00}:{10:00}:{11:00}\r\n{12}"; + foreach (Paragraph p in subtitle.Paragraphs) + { + count++; + var text = HtmlUtil.RemoveHtmlTags(p.Text, true); + + // to avoid rounding errors in duration + var startFrame = MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds); + var endFrame = MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds); + var durationCalc = new Paragraph( + new TimeCode(p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, FramesToMillisecondsMax999(startFrame)), + new TimeCode(p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, FramesToMillisecondsMax999(endFrame)), + string.Empty); + + sb.AppendLine(string.Format(writeFormat + Environment.NewLine, + p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, startFrame, + p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, endFrame, + durationCalc.Duration.Hours, durationCalc.Duration.Minutes, durationCalc.Duration.Seconds, MillisecondsToFramesMaxFrameRate(durationCalc.Duration.Milliseconds), + text, count)); + } + return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { //22 00:04:19:12 00:04:21:09 00:00:01:21 + _errorCount = 0; + Paragraph lastParagraph = null; + int count = 0; + foreach (string line in lines) + { + bool isTimeCode = false; + if (line.Length > 0) + { + bool success = false; + if (line.Length > 31 && line.IndexOf(':') > 1) + { + var match = Regex.Match(line); + if (match.Success) + { + isTimeCode = true; + if (lastParagraph != null) + { + subtitle.Paragraphs.Add(lastParagraph); + } + + var arr = line.Split('\t'); + TimeCode start = DecodeTimeCodeFrames(arr[1], SplitCharColon); + TimeCode end = DecodeTimeCodeFrames(arr[2], SplitCharColon); + lastParagraph = new Paragraph(start, end, string.Empty); + success = true; + } + } + if (!isTimeCode && !string.IsNullOrWhiteSpace(line) && lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) + { + lastParagraph.Text = (lastParagraph.Text + Environment.NewLine + line).Trim(); + success = true; + } + if (!success && count > 9) + { + _errorCount++; + } + } + count++; + } + if (lastParagraph != null) + { + subtitle.Paragraphs.Add(lastParagraph); + } + + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/SonyDVDArchitectLineDurationLength.cs b/src/libse/SubtitleFormats/SonyDVDArchitectLineDurationLength.cs similarity index 97% rename from libse/SubtitleFormats/SonyDVDArchitectLineDurationLength.cs rename to src/libse/SubtitleFormats/SonyDVDArchitectLineDurationLength.cs index c0bf27c0b..a303aa0ff 100644 --- a/libse/SubtitleFormats/SonyDVDArchitectLineDurationLength.cs +++ b/src/libse/SubtitleFormats/SonyDVDArchitectLineDurationLength.cs @@ -1,110 +1,110 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SonyDVDArchitectLineDurationLength : SubtitleFormat - { - private static readonly Regex Regex = new Regex(@"^\d+\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t\d+$", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "Sony DVDArchitect line/dur/length"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - sb.AppendLine("Title: " + title); - sb.AppendLine("Translator: No Author"); - sb.AppendLine("Date: " + DateTime.Now.ToString("dd-MM-yyyy").Replace("-", ".")); // 25.08.2011 - double milliseconds = 0; - if (subtitle.Paragraphs.Count > 0) - { - milliseconds = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds; - } - - var tc = new TimeCode(milliseconds); - sb.AppendLine(string.Format("Duration: {0:00}:{1:00}:{2:00}:{3:00}", tc.Hours, tc.Minutes, tc.Seconds, MillisecondsToFramesMaxFrameRate(tc.Milliseconds))); // 01:20:49:12 - sb.AppendLine("Program start: 00:00:00:00"); - sb.AppendLine("Title count: " + subtitle.Paragraphs.Count); - sb.AppendLine(); - sb.AppendLine("#\tIn\tOut\tDuration\tLength"); - sb.AppendLine(); - int count = 0; - const string writeFormat = "{14}\t{0:00}:{1:00}:{2:00}:{3:00}\t{4:00}:{5:00}:{6:00}:{7:00}\t{8:00}:{9:00}:{10:00}:{11:00}\t{12}\r\n{13}"; - foreach (Paragraph p in subtitle.Paragraphs) - { - count++; - var text = HtmlUtil.RemoveHtmlTags(p.Text, true); - - // to avoid rounding errors in duration - var startFrame = MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds); - var endFrame = MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds); - var durationCalc = new Paragraph( - new TimeCode(p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, FramesToMillisecondsMax999(startFrame)), - new TimeCode(p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, FramesToMillisecondsMax999(endFrame)), - string.Empty); - - sb.AppendLine(string.Format(writeFormat + Environment.NewLine, - p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, startFrame, - p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, endFrame, - durationCalc.Duration.Hours, durationCalc.Duration.Minutes, durationCalc.Duration.Seconds, MillisecondsToFramesMaxFrameRate(durationCalc.Duration.Milliseconds), - text.Length, text, count)); - } - return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { //22 00:04:19:12 00:04:21:09 00:00:01:21 14 - _errorCount = 0; - Paragraph lastParagraph = null; - int count = 0; - foreach (string line in lines) - { - bool isTimeCode = false; - if (line.Length > 0) - { - bool success = false; - if (line.Length > 33 && line.IndexOf(':') > 1) - { - var match = Regex.Match(line); - if (match.Success) - { - isTimeCode = true; - if (lastParagraph != null) - { - subtitle.Paragraphs.Add(lastParagraph); - } - - var arr = line.Split('\t'); - TimeCode start = DecodeTimeCodeFrames(arr[1], SplitCharColon); - TimeCode end = DecodeTimeCodeFrames(arr[2], SplitCharColon); - lastParagraph = new Paragraph(start, end, string.Empty); - success = true; - } - } - if (!isTimeCode && !string.IsNullOrWhiteSpace(line) && lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) - { - lastParagraph.Text = (lastParagraph.Text + Environment.NewLine + line).Trim(); - success = true; - } - if (!success && count > 9) - { - _errorCount++; - } - } - count++; - } - if (lastParagraph != null) - { - subtitle.Paragraphs.Add(lastParagraph); - } - - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SonyDVDArchitectLineDurationLength : SubtitleFormat + { + private static readonly Regex Regex = new Regex(@"^\d+\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t\d\d:\d\d:\d\d:\d\d\t\d+$", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "Sony DVDArchitect line/dur/length"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + sb.AppendLine("Title: " + title); + sb.AppendLine("Translator: No Author"); + sb.AppendLine("Date: " + DateTime.Now.ToString("dd-MM-yyyy").Replace("-", ".")); // 25.08.2011 + double milliseconds = 0; + if (subtitle.Paragraphs.Count > 0) + { + milliseconds = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds; + } + + var tc = new TimeCode(milliseconds); + sb.AppendLine(string.Format("Duration: {0:00}:{1:00}:{2:00}:{3:00}", tc.Hours, tc.Minutes, tc.Seconds, MillisecondsToFramesMaxFrameRate(tc.Milliseconds))); // 01:20:49:12 + sb.AppendLine("Program start: 00:00:00:00"); + sb.AppendLine("Title count: " + subtitle.Paragraphs.Count); + sb.AppendLine(); + sb.AppendLine("#\tIn\tOut\tDuration\tLength"); + sb.AppendLine(); + int count = 0; + const string writeFormat = "{14}\t{0:00}:{1:00}:{2:00}:{3:00}\t{4:00}:{5:00}:{6:00}:{7:00}\t{8:00}:{9:00}:{10:00}:{11:00}\t{12}\r\n{13}"; + foreach (Paragraph p in subtitle.Paragraphs) + { + count++; + var text = HtmlUtil.RemoveHtmlTags(p.Text, true); + + // to avoid rounding errors in duration + var startFrame = MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds); + var endFrame = MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds); + var durationCalc = new Paragraph( + new TimeCode(p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, FramesToMillisecondsMax999(startFrame)), + new TimeCode(p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, FramesToMillisecondsMax999(endFrame)), + string.Empty); + + sb.AppendLine(string.Format(writeFormat + Environment.NewLine, + p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, startFrame, + p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, endFrame, + durationCalc.Duration.Hours, durationCalc.Duration.Minutes, durationCalc.Duration.Seconds, MillisecondsToFramesMaxFrameRate(durationCalc.Duration.Milliseconds), + text.Length, text, count)); + } + return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { //22 00:04:19:12 00:04:21:09 00:00:01:21 14 + _errorCount = 0; + Paragraph lastParagraph = null; + int count = 0; + foreach (string line in lines) + { + bool isTimeCode = false; + if (line.Length > 0) + { + bool success = false; + if (line.Length > 33 && line.IndexOf(':') > 1) + { + var match = Regex.Match(line); + if (match.Success) + { + isTimeCode = true; + if (lastParagraph != null) + { + subtitle.Paragraphs.Add(lastParagraph); + } + + var arr = line.Split('\t'); + TimeCode start = DecodeTimeCodeFrames(arr[1], SplitCharColon); + TimeCode end = DecodeTimeCodeFrames(arr[2], SplitCharColon); + lastParagraph = new Paragraph(start, end, string.Empty); + success = true; + } + } + if (!isTimeCode && !string.IsNullOrWhiteSpace(line) && lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) + { + lastParagraph.Text = (lastParagraph.Text + Environment.NewLine + line).Trim(); + success = true; + } + if (!success && count > 9) + { + _errorCount++; + } + } + count++; + } + if (lastParagraph != null) + { + subtitle.Paragraphs.Add(lastParagraph); + } + + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/SonyDVDArchitectTabs.cs b/src/libse/SubtitleFormats/SonyDVDArchitectTabs.cs similarity index 97% rename from libse/SubtitleFormats/SonyDVDArchitectTabs.cs rename to src/libse/SubtitleFormats/SonyDVDArchitectTabs.cs index e0506d9c2..a33afec78 100644 --- a/libse/SubtitleFormats/SonyDVDArchitectTabs.cs +++ b/src/libse/SubtitleFormats/SonyDVDArchitectTabs.cs @@ -1,95 +1,95 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SonyDVDArchitectTabs : SubtitleFormat - { - private static readonly Regex Regex = new Regex(@"^\d\d:\d\d:\d\d:\d\d[ \t]+\d\d:\d\d:\d\d:\d\d[ \t]+", RegexOptions.Compiled); - - public override string Extension => ".sub"; - - public override string Name => "Sony DVDArchitect Tabs"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - const string writeFormat = "{0:00}:{1:00}:{2:00}:{3:00}\t{4:00}:{5:00}:{6:00}:{7:00}\t{8}"; - foreach (Paragraph p in subtitle.Paragraphs) - { - string text = HtmlUtil.RemoveHtmlTags(p.Text); - text = text.Replace(Environment.NewLine, "\r"); - sb.AppendLine(string.Format(writeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10, - p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10, - text)); - } - return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { //00:02:09:34 00:02:13:07 - Hvad mener du så om konkurrencen?- Jo, det er helt fint. - //00:02:14:02 00:02:16:41 - Var det den rigtige der vandt?- Ja, bestemt. - //newline = \r (0D) - - _errorCount = 0; - Paragraph lastParagraph = null; - foreach (string line in lines) - { - if (string.IsNullOrWhiteSpace(line)) - { - continue; - } - - bool success = false; - bool isTimeCode = false; - if (line.Length > 26 && line.IndexOf(':') == 2) - { - var match = Regex.Match(line); - if (match.Success) - { - isTimeCode = true; - string s = line.Substring(0, match.Length); - s = s.Replace('\t', ':'); - s = s.RemoveChar(' '); - s = s.Trim().TrimEnd(':').TrimEnd(); - string[] parts = s.Split(':'); - if (parts.Length == 8) - { - int hours = int.Parse(parts[0]); - int minutes = int.Parse(parts[1]); - int seconds = int.Parse(parts[2]); - int milliseconds = int.Parse(parts[3]) * 10; - var start = new TimeCode(hours, minutes, seconds, milliseconds); - - hours = int.Parse(parts[4]); - minutes = int.Parse(parts[5]); - seconds = int.Parse(parts[6]); - milliseconds = int.Parse(parts[7]) * 10; - var end = new TimeCode(hours, minutes, seconds, milliseconds); - - string text = line.Substring(match.Length).TrimStart(); - text = text.Replace("|", Environment.NewLine); - - lastParagraph = new Paragraph(start, end, text); - subtitle.Paragraphs.Add(lastParagraph); - success = true; - } - } - } - if (!isTimeCode && lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) - { - lastParagraph.Text += Environment.NewLine + line.Trim(); - success = true; - } - if (!success) - { - _errorCount++; - } - } - subtitle.Renumber(); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SonyDVDArchitectTabs : SubtitleFormat + { + private static readonly Regex Regex = new Regex(@"^\d\d:\d\d:\d\d:\d\d[ \t]+\d\d:\d\d:\d\d:\d\d[ \t]+", RegexOptions.Compiled); + + public override string Extension => ".sub"; + + public override string Name => "Sony DVDArchitect Tabs"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + const string writeFormat = "{0:00}:{1:00}:{2:00}:{3:00}\t{4:00}:{5:00}:{6:00}:{7:00}\t{8}"; + foreach (Paragraph p in subtitle.Paragraphs) + { + string text = HtmlUtil.RemoveHtmlTags(p.Text); + text = text.Replace(Environment.NewLine, "\r"); + sb.AppendLine(string.Format(writeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10, + p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10, + text)); + } + return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { //00:02:09:34 00:02:13:07 - Hvad mener du så om konkurrencen?- Jo, det er helt fint. + //00:02:14:02 00:02:16:41 - Var det den rigtige der vandt?- Ja, bestemt. + //newline = \r (0D) + + _errorCount = 0; + Paragraph lastParagraph = null; + foreach (string line in lines) + { + if (string.IsNullOrWhiteSpace(line)) + { + continue; + } + + bool success = false; + bool isTimeCode = false; + if (line.Length > 26 && line.IndexOf(':') == 2) + { + var match = Regex.Match(line); + if (match.Success) + { + isTimeCode = true; + string s = line.Substring(0, match.Length); + s = s.Replace('\t', ':'); + s = s.RemoveChar(' '); + s = s.Trim().TrimEnd(':').TrimEnd(); + string[] parts = s.Split(':'); + if (parts.Length == 8) + { + int hours = int.Parse(parts[0]); + int minutes = int.Parse(parts[1]); + int seconds = int.Parse(parts[2]); + int milliseconds = int.Parse(parts[3]) * 10; + var start = new TimeCode(hours, minutes, seconds, milliseconds); + + hours = int.Parse(parts[4]); + minutes = int.Parse(parts[5]); + seconds = int.Parse(parts[6]); + milliseconds = int.Parse(parts[7]) * 10; + var end = new TimeCode(hours, minutes, seconds, milliseconds); + + string text = line.Substring(match.Length).TrimStart(); + text = text.Replace("|", Environment.NewLine); + + lastParagraph = new Paragraph(start, end, text); + subtitle.Paragraphs.Add(lastParagraph); + success = true; + } + } + } + if (!isTimeCode && lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) + { + lastParagraph.Text += Environment.NewLine + line.Trim(); + success = true; + } + if (!success) + { + _errorCount++; + } + } + subtitle.Renumber(); + } + } +} diff --git a/libse/SubtitleFormats/SonyDVDArchitectWithLineNumbers.cs b/src/libse/SubtitleFormats/SonyDVDArchitectWithLineNumbers.cs similarity index 97% rename from libse/SubtitleFormats/SonyDVDArchitectWithLineNumbers.cs rename to src/libse/SubtitleFormats/SonyDVDArchitectWithLineNumbers.cs index 8b9d9ed6a..e9e5da856 100644 --- a/libse/SubtitleFormats/SonyDVDArchitectWithLineNumbers.cs +++ b/src/libse/SubtitleFormats/SonyDVDArchitectWithLineNumbers.cs @@ -1,127 +1,127 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SonyDVDArchitectWithLineNumbers : SubtitleFormat - { - private static readonly Regex RegexTimeCode = new Regex(@"^\d\d\d\d \d\d:\d\d:\d\d:\d\d \d\d:\d\d:\d\d:\d\d", RegexOptions.Compiled); - private static readonly Regex Regex1DigitMilliseconds = new Regex(@"^\d\d\d\d \d\d\d:\d\d:\d\d:\d \d\d\d:\d\d:\d\d:\d", RegexOptions.Compiled); - - public override string Extension => ".sub"; - - public override string Name => "Sony DVDArchitect w. line#"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - string text = HtmlUtil.RemoveHtmlTags(p.Text); - text = text.Replace(Environment.NewLine, "\r"); - sb.AppendLine(string.Format("{9:0000} {0:00}:{1:00}:{2:00}:{3:00} {4:00}:{5:00}:{6:00}:{7:00} \t{8}" + Environment.NewLine, - p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10, - p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10, - text, p.Number)); - } - return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { // 00:04:10:92 - 00:04:13:32 Raise Yourself To Help Mankind - // 00:04:27:92 - 00:04:30:92 الجهة المتولية للمسئولية الاجتماعية لشركتنا. - - _errorCount = 0; - Paragraph lastParagraph = null; - foreach (string line in lines) - { - if (string.IsNullOrWhiteSpace(line)) - { - continue; - } - - bool success = false; - if (line.IndexOf(':') > 0) - { - string s = line; - var match = RegexTimeCode.Match(s); - var match1DigitMilliseconds = Regex1DigitMilliseconds.Match(s); - if (s.Length > 31 && match.Success) - { - s = s.Substring(5, match.Length - 5).TrimStart(); - s = s.Replace(" ", ":"); - s = s.RemoveChar(' '); - string[] parts = s.Split(':'); - if (parts.Length == 8) - { - int hours = int.Parse(parts[0]); - int minutes = int.Parse(parts[1]); - int seconds = int.Parse(parts[2]); - int milliseconds = int.Parse(parts[3]) * 10; - var start = new TimeCode(hours, minutes, seconds, milliseconds); - - hours = int.Parse(parts[4]); - minutes = int.Parse(parts[5]); - seconds = int.Parse(parts[6]); - milliseconds = int.Parse(parts[7]) * 10; - var end = new TimeCode(hours, minutes, seconds, milliseconds); - - string text = line.Replace("\0", string.Empty).Substring(match.Length).TrimStart(); - text = text.Replace("|", Environment.NewLine); - - lastParagraph = new Paragraph(start, end, text); - subtitle.Paragraphs.Add(lastParagraph); - success = true; - } - } - else if (s.Length > 29 && match1DigitMilliseconds.Success) - { - s = s.Substring(5, match1DigitMilliseconds.Length - 5).TrimStart(); - s = s.Replace(" ", ":"); - s = s.RemoveChar(' '); - string[] parts = s.Split(':'); - if (parts.Length == 8) - { - int hours = int.Parse(parts[0]); - int minutes = int.Parse(parts[1]); - int seconds = int.Parse(parts[2]); - int milliseconds = int.Parse(parts[3]) * 10; - var start = new TimeCode(hours, minutes, seconds, milliseconds); - - hours = int.Parse(parts[4]); - minutes = int.Parse(parts[5]); - seconds = int.Parse(parts[6]); - milliseconds = int.Parse(parts[7]) * 10; - var end = new TimeCode(hours, minutes, seconds, milliseconds); - - string text = line.Replace("\0", string.Empty).Substring(match1DigitMilliseconds.Length).TrimStart(); - text = text.Replace("|", Environment.NewLine); - - lastParagraph = new Paragraph(start, end, text); - subtitle.Paragraphs.Add(lastParagraph); - success = true; - } - } - else if (lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) - { - lastParagraph.Text += Environment.NewLine + line.Trim(); - success = true; - } - } - else if (lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) - { - lastParagraph.Text += Environment.NewLine + line.Trim(); - success = true; - } - if (!success) - { - _errorCount++; - } - } - subtitle.Renumber(); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SonyDVDArchitectWithLineNumbers : SubtitleFormat + { + private static readonly Regex RegexTimeCode = new Regex(@"^\d\d\d\d \d\d:\d\d:\d\d:\d\d \d\d:\d\d:\d\d:\d\d", RegexOptions.Compiled); + private static readonly Regex Regex1DigitMilliseconds = new Regex(@"^\d\d\d\d \d\d\d:\d\d:\d\d:\d \d\d\d:\d\d:\d\d:\d", RegexOptions.Compiled); + + public override string Extension => ".sub"; + + public override string Name => "Sony DVDArchitect w. line#"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + string text = HtmlUtil.RemoveHtmlTags(p.Text); + text = text.Replace(Environment.NewLine, "\r"); + sb.AppendLine(string.Format("{9:0000} {0:00}:{1:00}:{2:00}:{3:00} {4:00}:{5:00}:{6:00}:{7:00} \t{8}" + Environment.NewLine, + p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10, + p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10, + text, p.Number)); + } + return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine + Environment.NewLine; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { // 00:04:10:92 - 00:04:13:32 Raise Yourself To Help Mankind + // 00:04:27:92 - 00:04:30:92 الجهة المتولية للمسئولية الاجتماعية لشركتنا. + + _errorCount = 0; + Paragraph lastParagraph = null; + foreach (string line in lines) + { + if (string.IsNullOrWhiteSpace(line)) + { + continue; + } + + bool success = false; + if (line.IndexOf(':') > 0) + { + string s = line; + var match = RegexTimeCode.Match(s); + var match1DigitMilliseconds = Regex1DigitMilliseconds.Match(s); + if (s.Length > 31 && match.Success) + { + s = s.Substring(5, match.Length - 5).TrimStart(); + s = s.Replace(" ", ":"); + s = s.RemoveChar(' '); + string[] parts = s.Split(':'); + if (parts.Length == 8) + { + int hours = int.Parse(parts[0]); + int minutes = int.Parse(parts[1]); + int seconds = int.Parse(parts[2]); + int milliseconds = int.Parse(parts[3]) * 10; + var start = new TimeCode(hours, minutes, seconds, milliseconds); + + hours = int.Parse(parts[4]); + minutes = int.Parse(parts[5]); + seconds = int.Parse(parts[6]); + milliseconds = int.Parse(parts[7]) * 10; + var end = new TimeCode(hours, minutes, seconds, milliseconds); + + string text = line.Replace("\0", string.Empty).Substring(match.Length).TrimStart(); + text = text.Replace("|", Environment.NewLine); + + lastParagraph = new Paragraph(start, end, text); + subtitle.Paragraphs.Add(lastParagraph); + success = true; + } + } + else if (s.Length > 29 && match1DigitMilliseconds.Success) + { + s = s.Substring(5, match1DigitMilliseconds.Length - 5).TrimStart(); + s = s.Replace(" ", ":"); + s = s.RemoveChar(' '); + string[] parts = s.Split(':'); + if (parts.Length == 8) + { + int hours = int.Parse(parts[0]); + int minutes = int.Parse(parts[1]); + int seconds = int.Parse(parts[2]); + int milliseconds = int.Parse(parts[3]) * 10; + var start = new TimeCode(hours, minutes, seconds, milliseconds); + + hours = int.Parse(parts[4]); + minutes = int.Parse(parts[5]); + seconds = int.Parse(parts[6]); + milliseconds = int.Parse(parts[7]) * 10; + var end = new TimeCode(hours, minutes, seconds, milliseconds); + + string text = line.Replace("\0", string.Empty).Substring(match1DigitMilliseconds.Length).TrimStart(); + text = text.Replace("|", Environment.NewLine); + + lastParagraph = new Paragraph(start, end, text); + subtitle.Paragraphs.Add(lastParagraph); + success = true; + } + } + else if (lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) + { + lastParagraph.Text += Environment.NewLine + line.Trim(); + success = true; + } + } + else if (lastParagraph != null && Utilities.GetNumberOfLines(lastParagraph.Text) < 5) + { + lastParagraph.Text += Environment.NewLine + line.Trim(); + success = true; + } + if (!success) + { + _errorCount++; + } + } + subtitle.Renumber(); + } + } +} diff --git a/libse/SubtitleFormats/Speechmatics.cs b/src/libse/SubtitleFormats/Speechmatics.cs similarity index 100% rename from libse/SubtitleFormats/Speechmatics.cs rename to src/libse/SubtitleFormats/Speechmatics.cs diff --git a/libse/SubtitleFormats/Spruce.cs b/src/libse/SubtitleFormats/Spruce.cs similarity index 97% rename from libse/SubtitleFormats/Spruce.cs rename to src/libse/SubtitleFormats/Spruce.cs index 902179e16..5c8aa6b5a 100644 --- a/libse/SubtitleFormats/Spruce.cs +++ b/src/libse/SubtitleFormats/Spruce.cs @@ -1,215 +1,215 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Spruce : SubtitleFormat - { - private const string Italic = "^I"; - private const string Bold = "^B"; - private const string Underline = "^U"; - - private static readonly Regex RegexTimeCodes1 = new Regex(@"^\d\d:\d\d:\d\d:\d\d,\d\d:\d\d:\d\d:\d\d,.+", RegexOptions.Compiled); - private static readonly Regex RegexTimeCodes2 = new Regex(@"^\d\d:\d\d:\d\d:\d\d,\d\d:\d\d:\d\d:\d\d,", RegexOptions.Compiled); // Matches time-only. - - public override string Extension => ".stl"; - - public override string Name => "Spruce Subtitle File"; - - public override string ToText(Subtitle subtitle, string title) - { - const string header = @"//Font select and font size -$FontName = Arial -$FontSize = 30 - -//Character attributes (global) -$Bold = FALSE -$UnderLined = FALSE -$Italic = FALSE - -//Position Control -$HorzAlign = Center -$VertAlign = Bottom -$XOffset = 0 -$YOffset = 0 - -//Contrast Control -$TextContrast = 15 -$Outline1Contrast = 8 -$Outline2Contrast = 15 -$BackgroundContrast = 0 - -//Effects Control -$ForceDisplay = FALSE -$FadeIn = 0 -$FadeOut = 0 - -//Other Controls -$TapeOffset = FALSE -//$SetFilePathToken = <<:>> - -//Colors -$ColorIndex1 = 0 -$ColorIndex2 = 1 -$ColorIndex3 = 2 -$ColorIndex4 = 3 - -//Subtitles"; - - var lastVerticalAlign = "$VertAlign = Bottom"; - var lastHorizontalcalAlign = "$HorzAlign = Center"; - var sb = new StringBuilder(); - sb.AppendLine(header); - foreach (Paragraph p in subtitle.Paragraphs) - { - DvdStudioPro.ToTextAlignment(p, sb, ref lastVerticalAlign, ref lastHorizontalcalAlign); - sb.AppendLine($"{EncodeTimeCode(p.StartTime)},{EncodeTimeCode(p.EndTime)},{EncodeText(p.Text)}"); - } - return sb.ToString(); - } - - private static string EncodeText(string input) - { - var text = HtmlUtil.FixUpperTags(input); - bool allItalic = text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(text, "") == 1; - text = text.Replace("", Bold); - text = text.Replace("", Bold); - text = text.Replace("", Italic); - text = text.Replace("", Italic); - text = text.Replace("", Underline); - text = text.Replace("", Underline); - text = HtmlUtil.RemoveHtmlTags(text, true); - if (allItalic) - { - return text.Replace(Environment.NewLine, "^I|^I"); - } - - return text.Replace(Environment.NewLine, "|"); - } - - private static string EncodeTimeCode(TimeCode time) - { - //00:01:54:19 - int frames = MillisecondsToFramesMaxFrameRate(time.Milliseconds); - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{frames:00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - //00:01:54:19,00:01:56:17,We should be thankful|they accepted our offer. - _errorCount = 0; - subtitle.Paragraphs.Clear(); - - // Copy reference of static compiled regex (RegexTimeCodes1). - Regex timeCodeRegex = RegexTimeCodes1; - if (fileName != null && fileName.EndsWith(".stl", StringComparison.OrdinalIgnoreCase)) // allow empty text if extension is ".stl"... - { - timeCodeRegex = RegexTimeCodes2; - } - - var verticalAlign = "$VertAlign=Bottom"; - var horizontalAlign = "$HorzAlign=Center"; - foreach (string line in lines) - { - if (line.IndexOf(':') == 2 && timeCodeRegex.IsMatch(line)) - { - string start = line.Substring(0, 11); - string end = line.Substring(12, 11); - - try - { - var text = DecodeText(line.Substring(24)); - text = DvdStudioPro.GetAlignment(verticalAlign, horizontalAlign) + text; - Paragraph p = new Paragraph(DecodeTimeCode(start), DecodeTimeCode(end), text); - subtitle.Paragraphs.Add(p); - } - catch - { - _errorCount++; - } - } - else if (line.TrimStart().StartsWith("$VertAlign", StringComparison.OrdinalIgnoreCase)) - { - verticalAlign = line.RemoveChar(' ').RemoveChar('\t'); - } - else if (line.TrimStart().StartsWith("$HorzAlign", StringComparison.OrdinalIgnoreCase)) - { - horizontalAlign = line.RemoveChar(' ').RemoveChar('\t'); - } - else if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("//", StringComparison.Ordinal) && !line.StartsWith('$')) - { - _errorCount++; - } - } - subtitle.Renumber(); - } - - private static TimeCode DecodeTimeCode(string time) - { - //00:01:54:19 - string hour = time.Substring(0, 2); - string minutes = time.Substring(3, 2); - string seconds = time.Substring(6, 2); - string frames = time.Substring(9, 2); - - int milliseconds = FramesToMillisecondsMax999(int.Parse(frames)); - return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), milliseconds); - } - - private static string DecodeText(string input) - { - var text = input.Replace("|", Environment.NewLine); - - //^IBrillstein^I - if (text.Contains(Bold)) - { - text = DecoderTextExtension(text, Bold, ""); - } - if (text.Contains(Italic)) - { - text = DecoderTextExtension(text, Italic, ""); - } - if (text.Contains(Underline)) - { - text = DecoderTextExtension(text, Underline, ""); - } - - return text; - } - - private static string DecoderTextExtension(string input, string spruceTag, string htmlOpenTag) - { - var htmlCloseTag = htmlOpenTag.Insert(1, "/"); - var text = input; - var idx = text.IndexOf(spruceTag, StringComparison.Ordinal); - var c = Utilities.CountTagInText(text, spruceTag); - if (c == 1) - { - var l = idx + spruceTag.Length; - if (l < text.Length) - { - text = text.Replace(spruceTag, htmlOpenTag) + htmlCloseTag; - } - else if (l == text.Length) // Brillstein^I - { - text = text.Remove(text.Length - Italic.Length); - } - } - else if (c > 1) - { - var isOpen = true; - while (idx >= 0) - { - var htmlTag = isOpen ? htmlOpenTag : htmlCloseTag; - text = text.Remove(idx, spruceTag.Length).Insert(idx, htmlTag); - isOpen = !isOpen; - idx = text.IndexOf(spruceTag, idx + htmlTag.Length, StringComparison.Ordinal); - } - } - return text; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Spruce : SubtitleFormat + { + private const string Italic = "^I"; + private const string Bold = "^B"; + private const string Underline = "^U"; + + private static readonly Regex RegexTimeCodes1 = new Regex(@"^\d\d:\d\d:\d\d:\d\d,\d\d:\d\d:\d\d:\d\d,.+", RegexOptions.Compiled); + private static readonly Regex RegexTimeCodes2 = new Regex(@"^\d\d:\d\d:\d\d:\d\d,\d\d:\d\d:\d\d:\d\d,", RegexOptions.Compiled); // Matches time-only. + + public override string Extension => ".stl"; + + public override string Name => "Spruce Subtitle File"; + + public override string ToText(Subtitle subtitle, string title) + { + const string header = @"//Font select and font size +$FontName = Arial +$FontSize = 30 + +//Character attributes (global) +$Bold = FALSE +$UnderLined = FALSE +$Italic = FALSE + +//Position Control +$HorzAlign = Center +$VertAlign = Bottom +$XOffset = 0 +$YOffset = 0 + +//Contrast Control +$TextContrast = 15 +$Outline1Contrast = 8 +$Outline2Contrast = 15 +$BackgroundContrast = 0 + +//Effects Control +$ForceDisplay = FALSE +$FadeIn = 0 +$FadeOut = 0 + +//Other Controls +$TapeOffset = FALSE +//$SetFilePathToken = <<:>> + +//Colors +$ColorIndex1 = 0 +$ColorIndex2 = 1 +$ColorIndex3 = 2 +$ColorIndex4 = 3 + +//Subtitles"; + + var lastVerticalAlign = "$VertAlign = Bottom"; + var lastHorizontalcalAlign = "$HorzAlign = Center"; + var sb = new StringBuilder(); + sb.AppendLine(header); + foreach (Paragraph p in subtitle.Paragraphs) + { + DvdStudioPro.ToTextAlignment(p, sb, ref lastVerticalAlign, ref lastHorizontalcalAlign); + sb.AppendLine($"{EncodeTimeCode(p.StartTime)},{EncodeTimeCode(p.EndTime)},{EncodeText(p.Text)}"); + } + return sb.ToString(); + } + + private static string EncodeText(string input) + { + var text = HtmlUtil.FixUpperTags(input); + bool allItalic = text.StartsWith("", StringComparison.Ordinal) && text.EndsWith("", StringComparison.Ordinal) && Utilities.CountTagInText(text, "") == 1; + text = text.Replace("", Bold); + text = text.Replace("", Bold); + text = text.Replace("", Italic); + text = text.Replace("", Italic); + text = text.Replace("", Underline); + text = text.Replace("", Underline); + text = HtmlUtil.RemoveHtmlTags(text, true); + if (allItalic) + { + return text.Replace(Environment.NewLine, "^I|^I"); + } + + return text.Replace(Environment.NewLine, "|"); + } + + private static string EncodeTimeCode(TimeCode time) + { + //00:01:54:19 + int frames = MillisecondsToFramesMaxFrameRate(time.Milliseconds); + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{frames:00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + //00:01:54:19,00:01:56:17,We should be thankful|they accepted our offer. + _errorCount = 0; + subtitle.Paragraphs.Clear(); + + // Copy reference of static compiled regex (RegexTimeCodes1). + Regex timeCodeRegex = RegexTimeCodes1; + if (fileName != null && fileName.EndsWith(".stl", StringComparison.OrdinalIgnoreCase)) // allow empty text if extension is ".stl"... + { + timeCodeRegex = RegexTimeCodes2; + } + + var verticalAlign = "$VertAlign=Bottom"; + var horizontalAlign = "$HorzAlign=Center"; + foreach (string line in lines) + { + if (line.IndexOf(':') == 2 && timeCodeRegex.IsMatch(line)) + { + string start = line.Substring(0, 11); + string end = line.Substring(12, 11); + + try + { + var text = DecodeText(line.Substring(24)); + text = DvdStudioPro.GetAlignment(verticalAlign, horizontalAlign) + text; + Paragraph p = new Paragraph(DecodeTimeCode(start), DecodeTimeCode(end), text); + subtitle.Paragraphs.Add(p); + } + catch + { + _errorCount++; + } + } + else if (line.TrimStart().StartsWith("$VertAlign", StringComparison.OrdinalIgnoreCase)) + { + verticalAlign = line.RemoveChar(' ').RemoveChar('\t'); + } + else if (line.TrimStart().StartsWith("$HorzAlign", StringComparison.OrdinalIgnoreCase)) + { + horizontalAlign = line.RemoveChar(' ').RemoveChar('\t'); + } + else if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("//", StringComparison.Ordinal) && !line.StartsWith('$')) + { + _errorCount++; + } + } + subtitle.Renumber(); + } + + private static TimeCode DecodeTimeCode(string time) + { + //00:01:54:19 + string hour = time.Substring(0, 2); + string minutes = time.Substring(3, 2); + string seconds = time.Substring(6, 2); + string frames = time.Substring(9, 2); + + int milliseconds = FramesToMillisecondsMax999(int.Parse(frames)); + return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), milliseconds); + } + + private static string DecodeText(string input) + { + var text = input.Replace("|", Environment.NewLine); + + //^IBrillstein^I + if (text.Contains(Bold)) + { + text = DecoderTextExtension(text, Bold, ""); + } + if (text.Contains(Italic)) + { + text = DecoderTextExtension(text, Italic, ""); + } + if (text.Contains(Underline)) + { + text = DecoderTextExtension(text, Underline, ""); + } + + return text; + } + + private static string DecoderTextExtension(string input, string spruceTag, string htmlOpenTag) + { + var htmlCloseTag = htmlOpenTag.Insert(1, "/"); + var text = input; + var idx = text.IndexOf(spruceTag, StringComparison.Ordinal); + var c = Utilities.CountTagInText(text, spruceTag); + if (c == 1) + { + var l = idx + spruceTag.Length; + if (l < text.Length) + { + text = text.Replace(spruceTag, htmlOpenTag) + htmlCloseTag; + } + else if (l == text.Length) // Brillstein^I + { + text = text.Remove(text.Length - Italic.Length); + } + } + else if (c > 1) + { + var isOpen = true; + while (idx >= 0) + { + var htmlTag = isOpen ? htmlOpenTag : htmlCloseTag; + text = text.Remove(idx, spruceTag.Length).Insert(idx, htmlTag); + isOpen = !isOpen; + idx = text.IndexOf(spruceTag, idx + htmlTag.Length, StringComparison.Ordinal); + } + } + return text; + } + } +} diff --git a/libse/SubtitleFormats/SpruceWithSpace.cs b/src/libse/SubtitleFormats/SpruceWithSpace.cs similarity index 97% rename from libse/SubtitleFormats/SpruceWithSpace.cs rename to src/libse/SubtitleFormats/SpruceWithSpace.cs index 8571246b2..98ab7bbc8 100644 --- a/libse/SubtitleFormats/SpruceWithSpace.cs +++ b/src/libse/SubtitleFormats/SpruceWithSpace.cs @@ -1,196 +1,196 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SpruceWithSpace : SubtitleFormat - { - - private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d, \d\d:\d\d:\d\d:\d\d,.+", RegexOptions.Compiled); - - public override string Extension => ".stl"; - - public override string Name => "Spruce Subtitle With Space"; - - public override string ToText(Subtitle subtitle, string title) - { - const string header = @"$FontName = Arial -$FontSize = 34 -$HorzAlign = Left -$VertAlign = Bottom -$XOffset = 0 -$YOffset = 0 -$Bold = FALSE -$UnderLined = FALSE -$Italic = FALSE -$TextContrast = 15 -$Outline1Contrast = 15 -$Outline2Contrast = 15 -$BackgroundContrast = 0 -$ForceDisplay = FALSE -$FadeIn = 0 -$FadeOut = 0 -$TapeOffset = FALSE - -\\Colour 0 = Black -\\Colour 1 = Red -\\Colour 2 = Green -\\Colour 3 = Yellow -\\Colour 4 = Blue -\\Colour 5 = Magenta -\\Colour 6 = Cyan -\\Colour 7 = White -"; - - var lastVerticalAlign = "$VertAlign = Bottom"; - var lastHorizontalcalAlign = "$HorzAlign = Center"; - var sb = new StringBuilder(); - sb.AppendLine(header); - foreach (Paragraph p in subtitle.Paragraphs) - { - sb = ToTextAlignment(p, sb, ref lastVerticalAlign, ref lastHorizontalcalAlign); - sb.AppendLine($"{EncodeTimeCode(p.StartTime)}, {EncodeTimeCode(p.EndTime)}, {EncodeText(p.Text)}"); - } - return sb.ToString(); - } - - private static StringBuilder ToTextAlignment(Paragraph p, StringBuilder sb, ref string lastVerticalAlign, ref string lastHorizontalAlign) - { - string verticalAlign; - string horizontalAlign; - bool verticalTopAlign = p.Text.StartsWith("{\\an7}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an8}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); - bool verticalCenterAlign = p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an5}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an6}", StringComparison.Ordinal); - if (verticalTopAlign) - { - verticalAlign = "$VertAlign = Top"; - } - else if (verticalCenterAlign) - { - verticalAlign = "$VertAlign = Center"; - } - else - { - verticalAlign = "$VertAlign = Bottom"; - } - - if (lastVerticalAlign != verticalAlign) - { - sb.AppendLine(verticalAlign); - } - - bool horizontalLeftAlign = p.Text.StartsWith("{\\an1}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an7}", StringComparison.Ordinal); - bool horizontalRightAlign = p.Text.StartsWith("{\\an3}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an6}", StringComparison.Ordinal) || - p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); - if (horizontalLeftAlign) - { - horizontalAlign = "$HorzAlign = Left"; - } - else if (horizontalRightAlign) - { - horizontalAlign = "$HorzAlign = Right"; - } - else - { - horizontalAlign = "$HorzAlign = Center"; - } - - sb.AppendLine(horizontalAlign); - - lastVerticalAlign = verticalAlign; - lastHorizontalAlign = horizontalAlign; - return sb; - } - - private static string EncodeText(string input) - { - var text = input.Replace("", "^B") - .Replace("", string.Empty) - .Replace("", "^I") - .Replace("", string.Empty) - .Replace("", "^U") - .Replace("", string.Empty); - return HtmlUtil.RemoveHtmlTags(text, true).Replace(Environment.NewLine, "|"); - } - - private static string EncodeTimeCode(TimeCode time) - { - //00:01:54:19 - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - //00:01:54:19,00:01:56:17,We should be thankful|they accepted our offer. - _errorCount = 0; - var verticalAlign = "$VertAlign=Bottom"; - var horizontalAlign = "$HorzAlign=Center"; - subtitle.Paragraphs.Clear(); - foreach (string line in lines) - { - if (line.IndexOf(':') == 2 && RegexTimeCodes.IsMatch(line)) - { - string start = line.Substring(0, 11); - string end = line.Substring(13, 11); - - try - { - var text = DecodeText(line.Substring(25).Trim()); - text = DvdStudioPro.GetAlignment(verticalAlign, horizontalAlign) + text; - var startTime = DecodeTimeCodeFramesFourParts(start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries)); - var endTime = DecodeTimeCodeFramesFourParts(end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries)); - var p = new Paragraph(startTime, endTime, text); - subtitle.Paragraphs.Add(p); - } - catch - { - _errorCount++; - } - } - else if (line.TrimStart().StartsWith("$VertAlign", StringComparison.OrdinalIgnoreCase)) - { - verticalAlign = line.RemoveChar(' ').RemoveChar('\t'); - } - else if (line.TrimStart().StartsWith("$HorzAlign", StringComparison.OrdinalIgnoreCase)) - { - horizontalAlign = line.RemoveChar(' ').RemoveChar('\t'); - } - else if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("//", StringComparison.Ordinal) && !line.StartsWith('$')) - { - _errorCount++; - } - } - subtitle.Renumber(); - } - - private static string DecodeText(string text) - { // TODO: Improve end tags - text = text.Replace("|", Environment.NewLine); - if (text.Contains("^B")) - { - text = text.Replace("^B", "") + ""; - } - - if (text.Contains("^I")) - { - text = text.Replace("^I", "") + ""; - } - - if (text.Contains("^U")) - { - text = text.Replace("^U", "") + ""; - } - - return text; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SpruceWithSpace : SubtitleFormat + { + + private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d:\d\d, \d\d:\d\d:\d\d:\d\d,.+", RegexOptions.Compiled); + + public override string Extension => ".stl"; + + public override string Name => "Spruce Subtitle With Space"; + + public override string ToText(Subtitle subtitle, string title) + { + const string header = @"$FontName = Arial +$FontSize = 34 +$HorzAlign = Left +$VertAlign = Bottom +$XOffset = 0 +$YOffset = 0 +$Bold = FALSE +$UnderLined = FALSE +$Italic = FALSE +$TextContrast = 15 +$Outline1Contrast = 15 +$Outline2Contrast = 15 +$BackgroundContrast = 0 +$ForceDisplay = FALSE +$FadeIn = 0 +$FadeOut = 0 +$TapeOffset = FALSE + +\\Colour 0 = Black +\\Colour 1 = Red +\\Colour 2 = Green +\\Colour 3 = Yellow +\\Colour 4 = Blue +\\Colour 5 = Magenta +\\Colour 6 = Cyan +\\Colour 7 = White +"; + + var lastVerticalAlign = "$VertAlign = Bottom"; + var lastHorizontalcalAlign = "$HorzAlign = Center"; + var sb = new StringBuilder(); + sb.AppendLine(header); + foreach (Paragraph p in subtitle.Paragraphs) + { + sb = ToTextAlignment(p, sb, ref lastVerticalAlign, ref lastHorizontalcalAlign); + sb.AppendLine($"{EncodeTimeCode(p.StartTime)}, {EncodeTimeCode(p.EndTime)}, {EncodeText(p.Text)}"); + } + return sb.ToString(); + } + + private static StringBuilder ToTextAlignment(Paragraph p, StringBuilder sb, ref string lastVerticalAlign, ref string lastHorizontalAlign) + { + string verticalAlign; + string horizontalAlign; + bool verticalTopAlign = p.Text.StartsWith("{\\an7}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an8}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); + bool verticalCenterAlign = p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an5}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an6}", StringComparison.Ordinal); + if (verticalTopAlign) + { + verticalAlign = "$VertAlign = Top"; + } + else if (verticalCenterAlign) + { + verticalAlign = "$VertAlign = Center"; + } + else + { + verticalAlign = "$VertAlign = Bottom"; + } + + if (lastVerticalAlign != verticalAlign) + { + sb.AppendLine(verticalAlign); + } + + bool horizontalLeftAlign = p.Text.StartsWith("{\\an1}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an4}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an7}", StringComparison.Ordinal); + bool horizontalRightAlign = p.Text.StartsWith("{\\an3}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an6}", StringComparison.Ordinal) || + p.Text.StartsWith("{\\an9}", StringComparison.Ordinal); + if (horizontalLeftAlign) + { + horizontalAlign = "$HorzAlign = Left"; + } + else if (horizontalRightAlign) + { + horizontalAlign = "$HorzAlign = Right"; + } + else + { + horizontalAlign = "$HorzAlign = Center"; + } + + sb.AppendLine(horizontalAlign); + + lastVerticalAlign = verticalAlign; + lastHorizontalAlign = horizontalAlign; + return sb; + } + + private static string EncodeText(string input) + { + var text = input.Replace("", "^B") + .Replace("", string.Empty) + .Replace("", "^I") + .Replace("", string.Empty) + .Replace("", "^U") + .Replace("", string.Empty); + return HtmlUtil.RemoveHtmlTags(text, true).Replace(Environment.NewLine, "|"); + } + + private static string EncodeTimeCode(TimeCode time) + { + //00:01:54:19 + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + //00:01:54:19,00:01:56:17,We should be thankful|they accepted our offer. + _errorCount = 0; + var verticalAlign = "$VertAlign=Bottom"; + var horizontalAlign = "$HorzAlign=Center"; + subtitle.Paragraphs.Clear(); + foreach (string line in lines) + { + if (line.IndexOf(':') == 2 && RegexTimeCodes.IsMatch(line)) + { + string start = line.Substring(0, 11); + string end = line.Substring(13, 11); + + try + { + var text = DecodeText(line.Substring(25).Trim()); + text = DvdStudioPro.GetAlignment(verticalAlign, horizontalAlign) + text; + var startTime = DecodeTimeCodeFramesFourParts(start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries)); + var endTime = DecodeTimeCodeFramesFourParts(end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries)); + var p = new Paragraph(startTime, endTime, text); + subtitle.Paragraphs.Add(p); + } + catch + { + _errorCount++; + } + } + else if (line.TrimStart().StartsWith("$VertAlign", StringComparison.OrdinalIgnoreCase)) + { + verticalAlign = line.RemoveChar(' ').RemoveChar('\t'); + } + else if (line.TrimStart().StartsWith("$HorzAlign", StringComparison.OrdinalIgnoreCase)) + { + horizontalAlign = line.RemoveChar(' ').RemoveChar('\t'); + } + else if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("//", StringComparison.Ordinal) && !line.StartsWith('$')) + { + _errorCount++; + } + } + subtitle.Renumber(); + } + + private static string DecodeText(string text) + { // TODO: Improve end tags + text = text.Replace("|", Environment.NewLine); + if (text.Contains("^B")) + { + text = text.Replace("^B", "") + ""; + } + + if (text.Contains("^I")) + { + text = text.Replace("^I", "") + ""; + } + + if (text.Contains("^U")) + { + text = text.Replace("^U", "") + ""; + } + + return text; + } + } +} diff --git a/libse/SubtitleFormats/Spt.cs b/src/libse/SubtitleFormats/Spt.cs similarity index 96% rename from libse/SubtitleFormats/Spt.cs rename to src/libse/SubtitleFormats/Spt.cs index 5cb479ba3..6060f791e 100644 --- a/libse/SubtitleFormats/Spt.cs +++ b/src/libse/SubtitleFormats/Spt.cs @@ -1,177 +1,177 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Spt : SubtitleFormat - { - public override string Extension => ".spt"; - - public const string NameOfFormat = "spt"; - - public override string Name => NameOfFormat; - - public static void Save(string fileName, Subtitle subtitle) - { - var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write); - - // header - fs.WriteByte(1); - for (int i = 1; i < 23; i++) - { - fs.WriteByte(0); - } - - fs.WriteByte(0x60); - - // paragraphs - foreach (Paragraph p in subtitle.Paragraphs) - { - WriteParagraph(p); - } - - // footer - fs.WriteByte(0xff); - for (int i = 0; i < 11; i++) - { - fs.WriteByte(0); - } - - fs.WriteByte(0x11); - byte[] footerBuffer = Encoding.ASCII.GetBytes("dummy end of file"); - fs.Write(footerBuffer, 0, footerBuffer.Length); - - fs.Close(); - } - - private static void WriteParagraph(Paragraph p) - { - WriteTimeCode(); - WriteTimeCode(); - - string text = p.Text; - if (Utilities.GetNumberOfLines(text) > 2) - { - text = Utilities.AutoBreakLine(p.Text); - } - - var lines = text.SplitToLines(); - int textLengthFirstLine = 0; - int textLengthSecondLine = 0; - if (lines.Count > 0) - { - textLengthFirstLine = lines[0].Length; - if (lines.Count > 1) - { - textLengthSecondLine = lines[1].Length; - } - } - } - - private static void WriteTimeCode() - { - // write 8 bytes time code - } - - public override bool IsMine(List lines, string fileName) - { - if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) - { - try - { - FileInfo fi = new FileInfo(fileName); - if (fi.Length > 100 && fi.Length < 1024000) // not too small or too big - { - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - - if (buffer[00] > 10 && - buffer[01] == 0 && - fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - } - } - catch - { - return false; - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - return "Not supported!"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - subtitle.Paragraphs.Clear(); - byte[] buffer = FileUtil.ReadAllBytesShared(fileName); - - int index = buffer[0]; // go to first subtitle paragraph - while (index < buffer.Length) - { - Paragraph p = GetSptParagraph(ref index, buffer); - if (p != null) - { - subtitle.Paragraphs.Add(p); - } - } - subtitle.Renumber(); - } - - private Paragraph GetSptParagraph(ref int index, byte[] buffer) - { - if (index + 16 + 20 + 4 >= buffer.Length) - { - index = index + 16 + 20 + 4; - return null; - } - - int textLengthFirstLine = buffer[index + 16 + 20]; - int textLengthSecondLine = buffer[index + 16 + 20 + 4]; - var allItalic = buffer[index + 16 + 4] == 1; - - if (textLengthFirstLine == 0 && textLengthSecondLine == 0) - { - index += 16 + 20 + 16; - _errorCount++; - return null; - } - - try - { - var p = new Paragraph - { - StartTime = Sptx.GetTimeCode(Encoding.Default.GetString(buffer, index, 8)), - EndTime = Sptx.GetTimeCode(Encoding.Default.GetString(buffer, index + 8, 8)), - Text = Sptx.FixItalics(Encoding.Default.GetString(buffer, index + 16 + 20 + 16, textLengthFirstLine)) - }; - - if (textLengthSecondLine > 0) - { - p.Text += Environment.NewLine + Encoding.Default.GetString(buffer, index + 16 + 20 + 16 + textLengthFirstLine, textLengthSecondLine); - } - - if (allItalic) - { - p.Text = "" + p.Text.Trim() + ""; - } - - index += 16 + 20 + 16 + textLengthFirstLine + textLengthSecondLine; - return p; - } - catch - { - index += 16 + 20 + 16 + textLengthFirstLine + textLengthSecondLine; - _errorCount++; - return null; - } - } - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Spt : SubtitleFormat + { + public override string Extension => ".spt"; + + public const string NameOfFormat = "spt"; + + public override string Name => NameOfFormat; + + public static void Save(string fileName, Subtitle subtitle) + { + var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write); + + // header + fs.WriteByte(1); + for (int i = 1; i < 23; i++) + { + fs.WriteByte(0); + } + + fs.WriteByte(0x60); + + // paragraphs + foreach (Paragraph p in subtitle.Paragraphs) + { + WriteParagraph(p); + } + + // footer + fs.WriteByte(0xff); + for (int i = 0; i < 11; i++) + { + fs.WriteByte(0); + } + + fs.WriteByte(0x11); + byte[] footerBuffer = Encoding.ASCII.GetBytes("dummy end of file"); + fs.Write(footerBuffer, 0, footerBuffer.Length); + + fs.Close(); + } + + private static void WriteParagraph(Paragraph p) + { + WriteTimeCode(); + WriteTimeCode(); + + string text = p.Text; + if (Utilities.GetNumberOfLines(text) > 2) + { + text = Utilities.AutoBreakLine(p.Text); + } + + var lines = text.SplitToLines(); + int textLengthFirstLine = 0; + int textLengthSecondLine = 0; + if (lines.Count > 0) + { + textLengthFirstLine = lines[0].Length; + if (lines.Count > 1) + { + textLengthSecondLine = lines[1].Length; + } + } + } + + private static void WriteTimeCode() + { + // write 8 bytes time code + } + + public override bool IsMine(List lines, string fileName) + { + if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) + { + try + { + FileInfo fi = new FileInfo(fileName); + if (fi.Length > 100 && fi.Length < 1024000) // not too small or too big + { + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + + if (buffer[00] > 10 && + buffer[01] == 0 && + fileName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + } + catch + { + return false; + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + return "Not supported!"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + subtitle.Paragraphs.Clear(); + byte[] buffer = FileUtil.ReadAllBytesShared(fileName); + + int index = buffer[0]; // go to first subtitle paragraph + while (index < buffer.Length) + { + Paragraph p = GetSptParagraph(ref index, buffer); + if (p != null) + { + subtitle.Paragraphs.Add(p); + } + } + subtitle.Renumber(); + } + + private Paragraph GetSptParagraph(ref int index, byte[] buffer) + { + if (index + 16 + 20 + 4 >= buffer.Length) + { + index = index + 16 + 20 + 4; + return null; + } + + int textLengthFirstLine = buffer[index + 16 + 20]; + int textLengthSecondLine = buffer[index + 16 + 20 + 4]; + var allItalic = buffer[index + 16 + 4] == 1; + + if (textLengthFirstLine == 0 && textLengthSecondLine == 0) + { + index += 16 + 20 + 16; + _errorCount++; + return null; + } + + try + { + var p = new Paragraph + { + StartTime = Sptx.GetTimeCode(Encoding.Default.GetString(buffer, index, 8)), + EndTime = Sptx.GetTimeCode(Encoding.Default.GetString(buffer, index + 8, 8)), + Text = Sptx.FixItalics(Encoding.Default.GetString(buffer, index + 16 + 20 + 16, textLengthFirstLine)) + }; + + if (textLengthSecondLine > 0) + { + p.Text += Environment.NewLine + Encoding.Default.GetString(buffer, index + 16 + 20 + 16 + textLengthFirstLine, textLengthSecondLine); + } + + if (allItalic) + { + p.Text = "" + p.Text.Trim() + ""; + } + + index += 16 + 20 + 16 + textLengthFirstLine + textLengthSecondLine; + return p; + } + catch + { + index += 16 + 20 + 16 + textLengthFirstLine + textLengthSecondLine; + _errorCount++; + return null; + } + } + } +} diff --git a/libse/SubtitleFormats/Sptx.cs b/src/libse/SubtitleFormats/Sptx.cs similarity index 100% rename from libse/SubtitleFormats/Sptx.cs rename to src/libse/SubtitleFormats/Sptx.cs diff --git a/libse/SubtitleFormats/SpuImage.cs b/src/libse/SubtitleFormats/SpuImage.cs similarity index 100% rename from libse/SubtitleFormats/SpuImage.cs rename to src/libse/SubtitleFormats/SpuImage.cs diff --git a/libse/SubtitleFormats/StructuredTitles.cs b/src/libse/SubtitleFormats/StructuredTitles.cs similarity index 97% rename from libse/SubtitleFormats/StructuredTitles.cs rename to src/libse/SubtitleFormats/StructuredTitles.cs index d60eb8d0f..c9ffc05da 100644 --- a/libse/SubtitleFormats/StructuredTitles.cs +++ b/src/libse/SubtitleFormats/StructuredTitles.cs @@ -1,191 +1,191 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class StructuredTitles : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d\d\d[ a-z]: \d\d:\d\d:\d\d:\d\d,\d\d:\d\d:\d\d:\d\d,\d{1,2}", RegexOptions.Compiled); - private static readonly Regex RegexSomeCodes = new Regex(@"^\d\d \d\d \d\d", RegexOptions.Compiled); - private static readonly Regex RegexText = new Regex(@"^[A-Z]\d[A-Z]\d\d ", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "Structured titles"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - sb.AppendLine("Structured titles"); - int index = 0; - - //0001 : 01:07:25:08,01:07:29:00,10 - //80 80 80 - //C1Y00 Niemand zal je helpen ontsnappen. - //C1Y00 - Een agent heeft me geholpen. - foreach (var p in subtitle.Paragraphs) - { - // 1=first line, 11=bottom line, 10=bottom of two lines subtitle - string verticalAlignment; - if (p.Text.StartsWith("{\\an8}", StringComparison.Ordinal)) - { - verticalAlignment = "1"; // one line - } - else - { - verticalAlignment = (12 - Utilities.GetNumberOfLines(p.Text)).ToString(CultureInfo.InvariantCulture); - } - - sb.AppendLine($"{index + 1:0000} : {EncodeTimeCode(p.StartTime)},{EncodeTimeCode(p.EndTime)},{verticalAlignment}"); - sb.AppendLine("80 80 80"); - var italic = Utilities.RemoveSsaTags(p.Text).StartsWith("", StringComparison.OrdinalIgnoreCase) && - p.Text.EndsWith("", StringComparison.OrdinalIgnoreCase); - var pre = string.Empty; - var post = string.Empty; - if (italic) - { - pre = "<"; - post = ">"; - } - var lines = HtmlUtil.RemoveHtmlTags(p.Text, true).SplitToLines(); - for (int i = 0; i < lines.Count; i++) - { - string line = lines[i]; - sb.AppendLine(GetPositionCode(i, p.Extra) + " " + pre + line.Trim() + post); - } - sb.AppendLine(); - index++; - } - return sb.ToString(); - } - - private static string GetPositionCode(int lineNumber, string extra) - { - if (!string.IsNullOrWhiteSpace(extra)) - { - var arr = extra.Split(':'); - if (lineNumber < arr.Length && arr[lineNumber].Length == 5) - { - return arr[lineNumber]; - } - } - return "C1Y00"; - } - - private static string EncodeTimeCode(TimeCode time) - { - //00:03:15:22 (last is frame) - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - //0001 : 01:07:25:08,01:07:29:00,10 - _errorCount = 0; - Paragraph p = null; - subtitle.Paragraphs.Clear(); - foreach (string line in lines) - { - if (line.IndexOf(':') == 5 && RegexTimeCodes.IsMatch(line)) - { - if (p != null) - { - subtitle.Paragraphs.Add(p); - } - - string start = line.Substring(7, 11); - string end = line.Substring(19, 11); - - string[] startParts = start.Split(SplitCharColon); - string[] endParts = end.Split(SplitCharColon); - if (startParts.Length == 4 && endParts.Length == 4) - { - p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty); - if (line.EndsWith(",1", StringComparison.Ordinal) || line.EndsWith(",2", StringComparison.Ordinal)) - { - p.Text = "{\\an8}"; - } - } - } - else if (p != null && RegexText.IsMatch(line)) - { - if (string.IsNullOrEmpty(p.Text)) - { - p.Extra = line.Substring(0, 5); - p.Text = line.Substring(5).Trim(); - } - else if (p.Text == "{\\an8}") - { - p.Extra = line.Substring(0, 5); - p.Text += line.Substring(5).Trim(); - } - else - { - p.Extra += ":" + line.Substring(0, 5); - p.Text += Environment.NewLine + line.Substring(5).Trim(); - } - } - else if (string.IsNullOrWhiteSpace(line) || line.Length < 10 && RegexSomeCodes.IsMatch(line)) - { - // skip these lines - } - else if (p != null) - { - if (p.Text != null && Utilities.GetNumberOfLines(p.Text) > 3) - { - _errorCount++; - } - else - { - if (!line.TrimEnd().EndsWith(": --:--:--:--,--:--:--:--,-1", StringComparison.Ordinal)) - { - if (string.IsNullOrEmpty(p.Text)) - { - p.Text = line.Trim(); - } - else - { - p.Text += Environment.NewLine + line.Trim(); - } - } - } - } - } - if (!string.IsNullOrEmpty(p?.Text)) - { - subtitle.Paragraphs.Add(p); - } - - FixItalics(subtitle); - - subtitle.Renumber(); - } - - private static void FixItalics(Subtitle subtitle) - { - foreach (var p in subtitle.Paragraphs) - { - if (p.Text.Contains('<') && p.Text.Contains('>')) - { - var sb = new StringBuilder(); - foreach (var line in p.Text.SplitToLines()) - { - if (line.StartsWith('<') && line.EndsWith('>')) - { - sb.AppendLine("" + line.TrimStart('<').TrimEnd('>') + ""); - } - else - { - sb.AppendLine(line); - } - } - p.Text = HtmlUtil.FixInvalidItalicTags(sb.ToString().TrimEnd()); - } - } - } - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class StructuredTitles : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d\d\d[ a-z]: \d\d:\d\d:\d\d:\d\d,\d\d:\d\d:\d\d:\d\d,\d{1,2}", RegexOptions.Compiled); + private static readonly Regex RegexSomeCodes = new Regex(@"^\d\d \d\d \d\d", RegexOptions.Compiled); + private static readonly Regex RegexText = new Regex(@"^[A-Z]\d[A-Z]\d\d ", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "Structured titles"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + sb.AppendLine("Structured titles"); + int index = 0; + + //0001 : 01:07:25:08,01:07:29:00,10 + //80 80 80 + //C1Y00 Niemand zal je helpen ontsnappen. + //C1Y00 - Een agent heeft me geholpen. + foreach (var p in subtitle.Paragraphs) + { + // 1=first line, 11=bottom line, 10=bottom of two lines subtitle + string verticalAlignment; + if (p.Text.StartsWith("{\\an8}", StringComparison.Ordinal)) + { + verticalAlignment = "1"; // one line + } + else + { + verticalAlignment = (12 - Utilities.GetNumberOfLines(p.Text)).ToString(CultureInfo.InvariantCulture); + } + + sb.AppendLine($"{index + 1:0000} : {EncodeTimeCode(p.StartTime)},{EncodeTimeCode(p.EndTime)},{verticalAlignment}"); + sb.AppendLine("80 80 80"); + var italic = Utilities.RemoveSsaTags(p.Text).StartsWith("", StringComparison.OrdinalIgnoreCase) && + p.Text.EndsWith("", StringComparison.OrdinalIgnoreCase); + var pre = string.Empty; + var post = string.Empty; + if (italic) + { + pre = "<"; + post = ">"; + } + var lines = HtmlUtil.RemoveHtmlTags(p.Text, true).SplitToLines(); + for (int i = 0; i < lines.Count; i++) + { + string line = lines[i]; + sb.AppendLine(GetPositionCode(i, p.Extra) + " " + pre + line.Trim() + post); + } + sb.AppendLine(); + index++; + } + return sb.ToString(); + } + + private static string GetPositionCode(int lineNumber, string extra) + { + if (!string.IsNullOrWhiteSpace(extra)) + { + var arr = extra.Split(':'); + if (lineNumber < arr.Length && arr[lineNumber].Length == 5) + { + return arr[lineNumber]; + } + } + return "C1Y00"; + } + + private static string EncodeTimeCode(TimeCode time) + { + //00:03:15:22 (last is frame) + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + //0001 : 01:07:25:08,01:07:29:00,10 + _errorCount = 0; + Paragraph p = null; + subtitle.Paragraphs.Clear(); + foreach (string line in lines) + { + if (line.IndexOf(':') == 5 && RegexTimeCodes.IsMatch(line)) + { + if (p != null) + { + subtitle.Paragraphs.Add(p); + } + + string start = line.Substring(7, 11); + string end = line.Substring(19, 11); + + string[] startParts = start.Split(SplitCharColon); + string[] endParts = end.Split(SplitCharColon); + if (startParts.Length == 4 && endParts.Length == 4) + { + p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty); + if (line.EndsWith(",1", StringComparison.Ordinal) || line.EndsWith(",2", StringComparison.Ordinal)) + { + p.Text = "{\\an8}"; + } + } + } + else if (p != null && RegexText.IsMatch(line)) + { + if (string.IsNullOrEmpty(p.Text)) + { + p.Extra = line.Substring(0, 5); + p.Text = line.Substring(5).Trim(); + } + else if (p.Text == "{\\an8}") + { + p.Extra = line.Substring(0, 5); + p.Text += line.Substring(5).Trim(); + } + else + { + p.Extra += ":" + line.Substring(0, 5); + p.Text += Environment.NewLine + line.Substring(5).Trim(); + } + } + else if (string.IsNullOrWhiteSpace(line) || line.Length < 10 && RegexSomeCodes.IsMatch(line)) + { + // skip these lines + } + else if (p != null) + { + if (p.Text != null && Utilities.GetNumberOfLines(p.Text) > 3) + { + _errorCount++; + } + else + { + if (!line.TrimEnd().EndsWith(": --:--:--:--,--:--:--:--,-1", StringComparison.Ordinal)) + { + if (string.IsNullOrEmpty(p.Text)) + { + p.Text = line.Trim(); + } + else + { + p.Text += Environment.NewLine + line.Trim(); + } + } + } + } + } + if (!string.IsNullOrEmpty(p?.Text)) + { + subtitle.Paragraphs.Add(p); + } + + FixItalics(subtitle); + + subtitle.Renumber(); + } + + private static void FixItalics(Subtitle subtitle) + { + foreach (var p in subtitle.Paragraphs) + { + if (p.Text.Contains('<') && p.Text.Contains('>')) + { + var sb = new StringBuilder(); + foreach (var line in p.Text.SplitToLines()) + { + if (line.StartsWith('<') && line.EndsWith('>')) + { + sb.AppendLine("" + line.TrimStart('<').TrimEnd('>') + ""); + } + else + { + sb.AppendLine(line); + } + } + p.Text = HtmlUtil.FixInvalidItalicTags(sb.ToString().TrimEnd()); + } + } + } + } +} diff --git a/libse/SubtitleFormats/SubRip.cs b/src/libse/SubtitleFormats/SubRip.cs similarity index 97% rename from libse/SubtitleFormats/SubRip.cs rename to src/libse/SubtitleFormats/SubRip.cs index e4f34a913..ec8b412fc 100644 --- a/libse/SubtitleFormats/SubRip.cs +++ b/src/libse/SubtitleFormats/SubRip.cs @@ -1,500 +1,500 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SubRip : SubtitleFormat - { - public string Errors { get; private set; } - private StringBuilder _errors; - private int _lineNumber; - private bool _isMsFrames; - private bool _isWsrt; - - private enum ExpectingLine - { - Number, - TimeCodes, - Text - } - - private Paragraph _paragraph; - private Paragraph _lastParagraph; - private ExpectingLine _expecting = ExpectingLine.Number; - - public override string Extension => ".srt"; - - public const string NameOfFormat = "SubRip"; - - public override string Name => NameOfFormat; - - public override List AlternateExtensions => new List { ".wsrt" }; - - public override bool IsMine(List lines, string fileName) - { - if (lines.Count > 0 && lines[0].StartsWith("WEBVTT", StringComparison.OrdinalIgnoreCase)) - { - return false; - } - - var subtitle = new Subtitle(); - LoadSubtitle(subtitle, lines, fileName); - Errors = null; - return subtitle.Paragraphs.Count > _errorCount; - } - - public override string ToText(Subtitle subtitle, string title) - { - const string paragraphWriteFormat = "{0}{4}{1} --> {2}{4}{3}{4}{4}"; - - var sb = new StringBuilder(); - foreach (var p in subtitle.Paragraphs) - { - sb.AppendFormat(paragraphWriteFormat, p.Number, p.StartTime, p.EndTime, p.Text, Environment.NewLine); - } - return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - bool doRenumber = false; - _errors = new StringBuilder(); - _lineNumber = 0; - _isMsFrames = true; - _isWsrt = fileName != null && fileName.EndsWith(".wsrt", StringComparison.OrdinalIgnoreCase); - _paragraph = new Paragraph(); - _expecting = ExpectingLine.Number; - _errorCount = 0; - - subtitle.Paragraphs.Clear(); - for (int i = 0; i < lines.Count; i++) - { - _lineNumber++; - string line = lines[i].TrimEnd(); - line = line.Trim('\u007F'); // 127=delete ascii - - string next = string.Empty; - if (i + 1 < lines.Count) - { - next = lines[i + 1]; - } - - string nextNext = string.Empty; - if (i + 2 < lines.Count) - { - nextNext = lines[i + 2]; - } - - string nextNextNext = string.Empty; - if (i + 3 < lines.Count) - { - nextNextNext = lines[i + 3]; - } - - // A new line is missing between two paragraphs or no line number (buggy file) - if (_expecting == ExpectingLine.Text && i + 1 < lines.Count && !string.IsNullOrEmpty(_paragraph?.Text) && - Utilities.IsInteger(line) && TryReadTimeCodesLine(line.Trim(), null, false)) - { - if (!string.IsNullOrEmpty(_paragraph.Text)) - { - subtitle.Paragraphs.Add(_paragraph); - _lastParagraph = _paragraph; - _paragraph = new Paragraph(); - } - _expecting = ExpectingLine.Number; - } - if (_expecting == ExpectingLine.Number && TryReadTimeCodesLine(line.Trim(), null, false)) - { - _expecting = ExpectingLine.TimeCodes; - doRenumber = true; - } - else if (!string.IsNullOrEmpty(_paragraph?.Text) && _expecting == ExpectingLine.Text && TryReadTimeCodesLine(line.Trim(), null, false)) - { - subtitle.Paragraphs.Add(_paragraph); - _lastParagraph = _paragraph; - _paragraph = new Paragraph(); - _expecting = ExpectingLine.TimeCodes; - doRenumber = true; - } - - ReadLine(subtitle, line, next, nextNext, nextNextNext); - } - - if (_paragraph?.IsDefault == false) - { - subtitle.Paragraphs.Add(_paragraph); - } - - if (doRenumber) - { - subtitle.Renumber(); - } - - foreach (var p in subtitle.Paragraphs) - { - if (_isMsFrames) - { - p.StartTime.Milliseconds = FramesToMillisecondsMax999(p.StartTime.Milliseconds); - p.EndTime.Milliseconds = FramesToMillisecondsMax999(p.EndTime.Milliseconds); - } - p.Text = p.Text.TrimEnd(); - } - Errors = _errors.ToString(); - } - - private void ReadLine(Subtitle subtitle, string line, string next, string nextNext, string nextNextNext) - { - switch (_expecting) - { - case ExpectingLine.Number: - if (int.TryParse(line, out var number)) - { - _paragraph.Number = number; - _expecting = ExpectingLine.TimeCodes; - } - else if (!string.IsNullOrWhiteSpace(line)) - { - if (_lastParagraph != null && nextNext != null && (_lastParagraph.Number + 1).ToString(CultureInfo.InvariantCulture) == nextNext) - { - _lastParagraph.Text = (_lastParagraph.Text + Environment.NewLine + line.Trim()).Trim(); - } - else - { - if (_errors.Length < 2000) - { - _errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXExpectedNumberFromSourceLineY, _lineNumber, line)); - } - - _errorCount++; - } - } - break; - case ExpectingLine.TimeCodes: - if (TryReadTimeCodesLine(line, _paragraph, true)) - { - _paragraph.Text = string.Empty; - _expecting = ExpectingLine.Text; - } - else if (!string.IsNullOrWhiteSpace(line)) - { - if (_errors.Length < 2000) - { - _errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXErrorReadingTimeCodeFromSourceLineY, _lineNumber, line)); - } - - _errorCount++; - _expecting = ExpectingLine.Number; // lets go to next paragraph - } - break; - case ExpectingLine.Text: - if (Utilities.IsInteger(line) && (TryReadTimeCodesLine(next, null, false) || string.IsNullOrEmpty(next) && TryReadTimeCodesLine(nextNext, null, false))) - { - // line is integer and time code follows - could loose a number from text... - subtitle.Paragraphs.Add(_paragraph); - _lastParagraph = _paragraph; - _paragraph = new Paragraph(); - _expecting = ExpectingLine.Number; - if (int.TryParse(line, out var n)) - { - _paragraph.Number = n; - } - if (_errors.Length < 2000 && line.Trim() != GetLastNumber(_paragraph)) - { - _errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXExpectedEmptyLine, _lineNumber, line)); - } - } - else if (TryReadTimeCodesLine(line, null, false)) - { - if (_paragraph != null && _paragraph.EndTime.TotalMilliseconds > 0 || - _paragraph != null && !string.IsNullOrEmpty(_paragraph.Text)) - { - subtitle.Paragraphs.Add(_paragraph); - _lastParagraph = _paragraph; - } - _paragraph = new Paragraph(); - TryReadTimeCodesLine(line, _paragraph, false); - _expecting = ExpectingLine.Text; - } - else if (!string.IsNullOrWhiteSpace(line) || IsText(next) || IsText(nextNext) || nextNextNext == GetLastNumber(_paragraph)) - { - if (_isWsrt && !string.IsNullOrEmpty(line)) - { - for (int i = 30; i < 40; i++) - { - line = line.Replace("<" + i + ">", ""); - line = line.Replace("", ""); - } - } - - if (_paragraph.Text.Length > 0) - { - _paragraph.Text += Environment.NewLine; - } - - _paragraph.Text += RemoveBadChars(line).TrimEnd(); - } - else if (string.IsNullOrEmpty(line) && string.IsNullOrEmpty(_paragraph.Text)) - { - _paragraph.Text = string.Empty; - if (!string.IsNullOrEmpty(next) && (Utilities.IsInteger(next) || TryReadTimeCodesLine(next, null, false))) - { - subtitle.Paragraphs.Add(_paragraph); - _lastParagraph = _paragraph; - _paragraph = new Paragraph(); - _expecting = ExpectingLine.Number; - } - } - else if (string.IsNullOrEmpty(line) && string.IsNullOrEmpty(next)) - { - _paragraph.Text += Environment.NewLine + RemoveBadChars(line).TrimEnd(); - } - else - { - subtitle.Paragraphs.Add(_paragraph); - _lastParagraph = _paragraph; - _paragraph = new Paragraph(); - _expecting = ExpectingLine.Number; - } - break; - } - } - - private static string GetLastNumber(Paragraph p) - { - if (p == null) - { - return "1"; - } - return (p.Number + 1).ToString(CultureInfo.InvariantCulture); - } - - private bool IsText(string text) - { - return !(string.IsNullOrWhiteSpace(text) || Utilities.IsInteger(text) || TryReadTimeCodesLine(text.Trim(), null, false)); - } - - private static string RemoveBadChars(string line) - { - return line.Replace('\0', ' '); - } - - private bool TryReadTimeCodesLine(string input, Paragraph paragraph, bool validate) - { - var s = input.TrimStart('-', ' '); - if (s.Length < 10 || !char.IsDigit(s[0])) - { - return false; - } - - const string defaultSeparator = " --> "; - // Fix some badly formatted separator sequences - anything can happen if you manually edit ;) - var line = input.Replace('،', ',') - .Replace('', ',') - .Replace('¡', ',') - .Replace(" -> ", defaultSeparator) - .Replace(" - > ", defaultSeparator) - .Replace(" ->> ", defaultSeparator) - .Replace(" -- > ", defaultSeparator) - .Replace(" - -> ", defaultSeparator) - .Replace(" -->> ", defaultSeparator) - .Replace(" ---> ", defaultSeparator) - .Replace(": ", ":").Trim(); - - // Removed stuff after time codes - like subtitle position - // - example of position info: 00:02:26,407 --> 00:02:31,356 X1:100 X2:100 Y1:100 Y2:100 - if (line.Length > 30) - { - if (line[29] == ' ') - { - line = line.Substring(0, 29); - } - else if (line[28] == ' ') - { - line = line.Substring(0, 28); - } - else if (line[27] == ' ') - { - line = line.Substring(0, 27); - } - } - - // removes all extra spaces - line = line.RemoveChar(' ').Replace("-->", defaultSeparator).Trim(); - - // Fix a few more cases of wrong time codes, seen this: 00.00.02,000 --> 00.00.04,000 - line = line.Replace('.', ':'); - if (line.Length >= 29 && (line[8] == ':' || line[8] == ';')) - { - line = line.Substring(0, 8) + ',' + line.Substring(8 + 1); - } - - if (line.Length >= 29 && line.Length <= 30 && (line[25] == ':' || line[25] == ';')) - { - line = line.Substring(0, 25) + ',' + line.Substring(25 + 1); - } - - // allow missing hours as some (buggy) websites generate these time codes: 04:48,460 --> 04:52,364 - if (line.Length == 23 && line[2] == ':' && line[5] == ',' && line[9] == ' ' && line[12] == '>' && line[13] == ' ' && line[16] == ':' && line[19] == ',') - { - line = "00:" + line.Insert(14, "00:"); - } - - if (IsValidTimeCode(line)) - { - string[] parts = line.Replace("-->", ":").RemoveChar(' ').Split(':', ','); - try - { - int startHours = int.Parse(parts[0]); - int startMinutes = int.Parse(parts[1]); - int startSeconds = int.Parse(parts[2]); - int startMilliseconds = int.Parse(parts[3]); - int endHours = int.Parse(parts[4]); - int endMinutes = int.Parse(parts[5]); - int endSeconds = int.Parse(parts[6]); - int endMilliseconds = int.Parse(parts[7]); - - if (validate && _errors.Length < 2000 && - (startHours > 99 || startMinutes > 99 || startSeconds > 99 || startMilliseconds > 999 || - endHours > 99 || endMinutes > 99 || endSeconds > 99 || endMilliseconds > 999)) - { - _errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXErrorReadingTimeCodeFromSourceLineY, _lineNumber, line)); - } - - if (_isMsFrames && (parts[3].Length != 2 || startMilliseconds > 30 || parts[7].Length != 2 || endMilliseconds > 30)) - { - _isMsFrames = false; - } - - if (paragraph != null) - { - paragraph.StartTime = new TimeCode(startHours, startMinutes, startSeconds, startMilliseconds); - if (parts[0].StartsWith('-') && paragraph.StartTime.TotalMilliseconds > 0) - { - paragraph.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds * -1; - } - - paragraph.EndTime = new TimeCode(endHours, endMinutes, endSeconds, endMilliseconds); - if (parts[4].StartsWith('-') && paragraph.EndTime.TotalMilliseconds > 0) - { - paragraph.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds * -1; - } - } - return true; - } - catch - { - return false; - } - } - return false; - } - - /// - /// Optimized validation of time codes - /// Old Regex was: - /// - ^-?\d+:-?\d+:-?\d+[:,]-?\d+\s*-->\s*-?\d+:-?\d+:-?\d+[:,]-?\d+$ - /// - ^\d+:\d+:\d+,\d+\s*-->\s*\d+:\d+:\d+,\d+$ - /// True if valid srt time code - /// - private static bool IsValidTimeCode(string line) - { - int step = 0; - var max = line.Length; - for (int i = 0; i < max; i++) - { - var ch = line[i]; - if (char.IsWhiteSpace(ch)) - { - continue; - } - - if (step == 0 || step == 2 || step == 4 || step == 9 || step == 11) // start numbers - { - if (ch == '-' || char.IsDigit(ch)) - { - step++; - } - else - { - return false; - } - } - else if (step == 1 || step == 3 || step == 10 || step == 12) // number - { - if (char.IsDigit(ch)) - { - // ok - } - else if (ch == ':') - { - step++; - } - else - { - return false; - } - } - else if (step == 5 || step == 13) // seconds - { - if (char.IsDigit(ch)) - { - // ok - } - else if (ch == ',' || ch == ':') - { - step++; - } - else - { - return false; - } - } - else if (step == 6 || step == 14) // milliseconds - { - if (char.IsDigit(ch)) - { - // ok - } - else if (ch == '-') - { - step++; - } - else - { - return false; - } - } - else if (step == 7) // separator char 2 - { - if (ch == '-') - { - step++; - } - else - { - return false; - } - } - else if (step == 8) // separator char 3 - { - if (ch == '>') - { - step++; - } - else - { - return false; - } - } - else if (step > 14) - { - return false; - } - } - return true; - } - } +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SubRip : SubtitleFormat + { + public string Errors { get; private set; } + private StringBuilder _errors; + private int _lineNumber; + private bool _isMsFrames; + private bool _isWsrt; + + private enum ExpectingLine + { + Number, + TimeCodes, + Text + } + + private Paragraph _paragraph; + private Paragraph _lastParagraph; + private ExpectingLine _expecting = ExpectingLine.Number; + + public override string Extension => ".srt"; + + public const string NameOfFormat = "SubRip"; + + public override string Name => NameOfFormat; + + public override List AlternateExtensions => new List { ".wsrt" }; + + public override bool IsMine(List lines, string fileName) + { + if (lines.Count > 0 && lines[0].StartsWith("WEBVTT", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + var subtitle = new Subtitle(); + LoadSubtitle(subtitle, lines, fileName); + Errors = null; + return subtitle.Paragraphs.Count > _errorCount; + } + + public override string ToText(Subtitle subtitle, string title) + { + const string paragraphWriteFormat = "{0}{4}{1} --> {2}{4}{3}{4}{4}"; + + var sb = new StringBuilder(); + foreach (var p in subtitle.Paragraphs) + { + sb.AppendFormat(paragraphWriteFormat, p.Number, p.StartTime, p.EndTime, p.Text, Environment.NewLine); + } + return sb.ToString().Trim() + Environment.NewLine + Environment.NewLine; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + bool doRenumber = false; + _errors = new StringBuilder(); + _lineNumber = 0; + _isMsFrames = true; + _isWsrt = fileName != null && fileName.EndsWith(".wsrt", StringComparison.OrdinalIgnoreCase); + _paragraph = new Paragraph(); + _expecting = ExpectingLine.Number; + _errorCount = 0; + + subtitle.Paragraphs.Clear(); + for (int i = 0; i < lines.Count; i++) + { + _lineNumber++; + string line = lines[i].TrimEnd(); + line = line.Trim('\u007F'); // 127=delete ascii + + string next = string.Empty; + if (i + 1 < lines.Count) + { + next = lines[i + 1]; + } + + string nextNext = string.Empty; + if (i + 2 < lines.Count) + { + nextNext = lines[i + 2]; + } + + string nextNextNext = string.Empty; + if (i + 3 < lines.Count) + { + nextNextNext = lines[i + 3]; + } + + // A new line is missing between two paragraphs or no line number (buggy file) + if (_expecting == ExpectingLine.Text && i + 1 < lines.Count && !string.IsNullOrEmpty(_paragraph?.Text) && + Utilities.IsInteger(line) && TryReadTimeCodesLine(line.Trim(), null, false)) + { + if (!string.IsNullOrEmpty(_paragraph.Text)) + { + subtitle.Paragraphs.Add(_paragraph); + _lastParagraph = _paragraph; + _paragraph = new Paragraph(); + } + _expecting = ExpectingLine.Number; + } + if (_expecting == ExpectingLine.Number && TryReadTimeCodesLine(line.Trim(), null, false)) + { + _expecting = ExpectingLine.TimeCodes; + doRenumber = true; + } + else if (!string.IsNullOrEmpty(_paragraph?.Text) && _expecting == ExpectingLine.Text && TryReadTimeCodesLine(line.Trim(), null, false)) + { + subtitle.Paragraphs.Add(_paragraph); + _lastParagraph = _paragraph; + _paragraph = new Paragraph(); + _expecting = ExpectingLine.TimeCodes; + doRenumber = true; + } + + ReadLine(subtitle, line, next, nextNext, nextNextNext); + } + + if (_paragraph?.IsDefault == false) + { + subtitle.Paragraphs.Add(_paragraph); + } + + if (doRenumber) + { + subtitle.Renumber(); + } + + foreach (var p in subtitle.Paragraphs) + { + if (_isMsFrames) + { + p.StartTime.Milliseconds = FramesToMillisecondsMax999(p.StartTime.Milliseconds); + p.EndTime.Milliseconds = FramesToMillisecondsMax999(p.EndTime.Milliseconds); + } + p.Text = p.Text.TrimEnd(); + } + Errors = _errors.ToString(); + } + + private void ReadLine(Subtitle subtitle, string line, string next, string nextNext, string nextNextNext) + { + switch (_expecting) + { + case ExpectingLine.Number: + if (int.TryParse(line, out var number)) + { + _paragraph.Number = number; + _expecting = ExpectingLine.TimeCodes; + } + else if (!string.IsNullOrWhiteSpace(line)) + { + if (_lastParagraph != null && nextNext != null && (_lastParagraph.Number + 1).ToString(CultureInfo.InvariantCulture) == nextNext) + { + _lastParagraph.Text = (_lastParagraph.Text + Environment.NewLine + line.Trim()).Trim(); + } + else + { + if (_errors.Length < 2000) + { + _errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXExpectedNumberFromSourceLineY, _lineNumber, line)); + } + + _errorCount++; + } + } + break; + case ExpectingLine.TimeCodes: + if (TryReadTimeCodesLine(line, _paragraph, true)) + { + _paragraph.Text = string.Empty; + _expecting = ExpectingLine.Text; + } + else if (!string.IsNullOrWhiteSpace(line)) + { + if (_errors.Length < 2000) + { + _errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXErrorReadingTimeCodeFromSourceLineY, _lineNumber, line)); + } + + _errorCount++; + _expecting = ExpectingLine.Number; // lets go to next paragraph + } + break; + case ExpectingLine.Text: + if (Utilities.IsInteger(line) && (TryReadTimeCodesLine(next, null, false) || string.IsNullOrEmpty(next) && TryReadTimeCodesLine(nextNext, null, false))) + { + // line is integer and time code follows - could loose a number from text... + subtitle.Paragraphs.Add(_paragraph); + _lastParagraph = _paragraph; + _paragraph = new Paragraph(); + _expecting = ExpectingLine.Number; + if (int.TryParse(line, out var n)) + { + _paragraph.Number = n; + } + if (_errors.Length < 2000 && line.Trim() != GetLastNumber(_paragraph)) + { + _errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXExpectedEmptyLine, _lineNumber, line)); + } + } + else if (TryReadTimeCodesLine(line, null, false)) + { + if (_paragraph != null && _paragraph.EndTime.TotalMilliseconds > 0 || + _paragraph != null && !string.IsNullOrEmpty(_paragraph.Text)) + { + subtitle.Paragraphs.Add(_paragraph); + _lastParagraph = _paragraph; + } + _paragraph = new Paragraph(); + TryReadTimeCodesLine(line, _paragraph, false); + _expecting = ExpectingLine.Text; + } + else if (!string.IsNullOrWhiteSpace(line) || IsText(next) || IsText(nextNext) || nextNextNext == GetLastNumber(_paragraph)) + { + if (_isWsrt && !string.IsNullOrEmpty(line)) + { + for (int i = 30; i < 40; i++) + { + line = line.Replace("<" + i + ">", ""); + line = line.Replace("", ""); + } + } + + if (_paragraph.Text.Length > 0) + { + _paragraph.Text += Environment.NewLine; + } + + _paragraph.Text += RemoveBadChars(line).TrimEnd(); + } + else if (string.IsNullOrEmpty(line) && string.IsNullOrEmpty(_paragraph.Text)) + { + _paragraph.Text = string.Empty; + if (!string.IsNullOrEmpty(next) && (Utilities.IsInteger(next) || TryReadTimeCodesLine(next, null, false))) + { + subtitle.Paragraphs.Add(_paragraph); + _lastParagraph = _paragraph; + _paragraph = new Paragraph(); + _expecting = ExpectingLine.Number; + } + } + else if (string.IsNullOrEmpty(line) && string.IsNullOrEmpty(next)) + { + _paragraph.Text += Environment.NewLine + RemoveBadChars(line).TrimEnd(); + } + else + { + subtitle.Paragraphs.Add(_paragraph); + _lastParagraph = _paragraph; + _paragraph = new Paragraph(); + _expecting = ExpectingLine.Number; + } + break; + } + } + + private static string GetLastNumber(Paragraph p) + { + if (p == null) + { + return "1"; + } + return (p.Number + 1).ToString(CultureInfo.InvariantCulture); + } + + private bool IsText(string text) + { + return !(string.IsNullOrWhiteSpace(text) || Utilities.IsInteger(text) || TryReadTimeCodesLine(text.Trim(), null, false)); + } + + private static string RemoveBadChars(string line) + { + return line.Replace('\0', ' '); + } + + private bool TryReadTimeCodesLine(string input, Paragraph paragraph, bool validate) + { + var s = input.TrimStart('-', ' '); + if (s.Length < 10 || !char.IsDigit(s[0])) + { + return false; + } + + const string defaultSeparator = " --> "; + // Fix some badly formatted separator sequences - anything can happen if you manually edit ;) + var line = input.Replace('،', ',') + .Replace('', ',') + .Replace('¡', ',') + .Replace(" -> ", defaultSeparator) + .Replace(" - > ", defaultSeparator) + .Replace(" ->> ", defaultSeparator) + .Replace(" -- > ", defaultSeparator) + .Replace(" - -> ", defaultSeparator) + .Replace(" -->> ", defaultSeparator) + .Replace(" ---> ", defaultSeparator) + .Replace(": ", ":").Trim(); + + // Removed stuff after time codes - like subtitle position + // - example of position info: 00:02:26,407 --> 00:02:31,356 X1:100 X2:100 Y1:100 Y2:100 + if (line.Length > 30) + { + if (line[29] == ' ') + { + line = line.Substring(0, 29); + } + else if (line[28] == ' ') + { + line = line.Substring(0, 28); + } + else if (line[27] == ' ') + { + line = line.Substring(0, 27); + } + } + + // removes all extra spaces + line = line.RemoveChar(' ').Replace("-->", defaultSeparator).Trim(); + + // Fix a few more cases of wrong time codes, seen this: 00.00.02,000 --> 00.00.04,000 + line = line.Replace('.', ':'); + if (line.Length >= 29 && (line[8] == ':' || line[8] == ';')) + { + line = line.Substring(0, 8) + ',' + line.Substring(8 + 1); + } + + if (line.Length >= 29 && line.Length <= 30 && (line[25] == ':' || line[25] == ';')) + { + line = line.Substring(0, 25) + ',' + line.Substring(25 + 1); + } + + // allow missing hours as some (buggy) websites generate these time codes: 04:48,460 --> 04:52,364 + if (line.Length == 23 && line[2] == ':' && line[5] == ',' && line[9] == ' ' && line[12] == '>' && line[13] == ' ' && line[16] == ':' && line[19] == ',') + { + line = "00:" + line.Insert(14, "00:"); + } + + if (IsValidTimeCode(line)) + { + string[] parts = line.Replace("-->", ":").RemoveChar(' ').Split(':', ','); + try + { + int startHours = int.Parse(parts[0]); + int startMinutes = int.Parse(parts[1]); + int startSeconds = int.Parse(parts[2]); + int startMilliseconds = int.Parse(parts[3]); + int endHours = int.Parse(parts[4]); + int endMinutes = int.Parse(parts[5]); + int endSeconds = int.Parse(parts[6]); + int endMilliseconds = int.Parse(parts[7]); + + if (validate && _errors.Length < 2000 && + (startHours > 99 || startMinutes > 99 || startSeconds > 99 || startMilliseconds > 999 || + endHours > 99 || endMinutes > 99 || endSeconds > 99 || endMilliseconds > 999)) + { + _errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXErrorReadingTimeCodeFromSourceLineY, _lineNumber, line)); + } + + if (_isMsFrames && (parts[3].Length != 2 || startMilliseconds > 30 || parts[7].Length != 2 || endMilliseconds > 30)) + { + _isMsFrames = false; + } + + if (paragraph != null) + { + paragraph.StartTime = new TimeCode(startHours, startMinutes, startSeconds, startMilliseconds); + if (parts[0].StartsWith('-') && paragraph.StartTime.TotalMilliseconds > 0) + { + paragraph.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds * -1; + } + + paragraph.EndTime = new TimeCode(endHours, endMinutes, endSeconds, endMilliseconds); + if (parts[4].StartsWith('-') && paragraph.EndTime.TotalMilliseconds > 0) + { + paragraph.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds * -1; + } + } + return true; + } + catch + { + return false; + } + } + return false; + } + + /// + /// Optimized validation of time codes + /// Old Regex was: + /// - ^-?\d+:-?\d+:-?\d+[:,]-?\d+\s*-->\s*-?\d+:-?\d+:-?\d+[:,]-?\d+$ + /// - ^\d+:\d+:\d+,\d+\s*-->\s*\d+:\d+:\d+,\d+$ + /// True if valid srt time code + /// + private static bool IsValidTimeCode(string line) + { + int step = 0; + var max = line.Length; + for (int i = 0; i < max; i++) + { + var ch = line[i]; + if (char.IsWhiteSpace(ch)) + { + continue; + } + + if (step == 0 || step == 2 || step == 4 || step == 9 || step == 11) // start numbers + { + if (ch == '-' || char.IsDigit(ch)) + { + step++; + } + else + { + return false; + } + } + else if (step == 1 || step == 3 || step == 10 || step == 12) // number + { + if (char.IsDigit(ch)) + { + // ok + } + else if (ch == ':') + { + step++; + } + else + { + return false; + } + } + else if (step == 5 || step == 13) // seconds + { + if (char.IsDigit(ch)) + { + // ok + } + else if (ch == ',' || ch == ':') + { + step++; + } + else + { + return false; + } + } + else if (step == 6 || step == 14) // milliseconds + { + if (char.IsDigit(ch)) + { + // ok + } + else if (ch == '-') + { + step++; + } + else + { + return false; + } + } + else if (step == 7) // separator char 2 + { + if (ch == '-') + { + step++; + } + else + { + return false; + } + } + else if (step == 8) // separator char 3 + { + if (ch == '>') + { + step++; + } + else + { + return false; + } + } + else if (step > 14) + { + return false; + } + } + return true; + } + } } \ No newline at end of file diff --git a/libse/SubtitleFormats/SubStationAlpha.cs b/src/libse/SubtitleFormats/SubStationAlpha.cs similarity index 97% rename from libse/SubtitleFormats/SubStationAlpha.cs rename to src/libse/SubtitleFormats/SubStationAlpha.cs index ec8b1c2b7..5801cdbc7 100644 --- a/libse/SubtitleFormats/SubStationAlpha.cs +++ b/src/libse/SubtitleFormats/SubStationAlpha.cs @@ -1,738 +1,738 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SubStationAlpha : SubtitleFormat - { - public string Errors { get; private set; } - - public override string Extension => ".ssa"; - - public const string NameOfFormat = "Sub Station Alpha"; - - public override string Name => NameOfFormat; - - public override bool IsMine(List lines, string fileName) - { - var subtitle = new Subtitle(); - LoadSubtitle(subtitle, lines, fileName); - Errors = null; - return subtitle.Paragraphs.Count > _errorCount; - } - - const string HeaderNoStyles = - @"[Script Info] -; This is a Sub Station Alpha v4 script. -Title: {0} -ScriptType: v4.00 -Collisions: Normal -PlayDepth: 0 - -[V4 Styles] -Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding -{1} - -[Events] -Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"; - - public override string ToText(Subtitle subtitle, string title) - { - const string header = -@"[Script Info] -; This is a Sub Station Alpha v4 script. -Title: {0} -ScriptType: v4.00 -Collisions: Normal -PlayDepth: 0 - -[V4 Styles] -Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding -Style: Default,{1},{2},{3},65535,65535,-2147483640,{9},0,1,{4},{5},2,{6},{7},{8},0,1 - -[Events] -Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"; - - - - const string timeCodeFormat = "{0}:{1:00}:{2:00}.{3:00}"; // h:mm:ss.cc - const string paragraphWriteFormat = "Dialogue: Marked={4},{0},{1},{3},{5},{6},{7},{8},{9},{2}"; - const string commentWriteFormat = "Comment: Marked={4},{0},{1},{3},{5},{6},{7},{8},{9},{2}"; - - var sb = new StringBuilder(); - Color fontColor = Color.FromArgb(Configuration.Settings.SubtitleSettings.SsaFontColorArgb); - bool isValidAssHeader = !string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.Contains("[V4 Styles]"); - var styles = new List(); - if (isValidAssHeader) - { - sb.AppendLine(subtitle.Header.Trim()); - const string formatLine = "Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"; - if (!subtitle.Header.Contains(formatLine)) - { - sb.AppendLine(formatLine); - } - - styles = AdvancedSubStationAlpha.GetStylesFromHeader(subtitle.Header); - } - else if (!string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.Contains("[V4+ Styles]")) - { - LoadStylesFromAdvancedSubstationAlpha(subtitle, title, subtitle.Header, HeaderNoStyles, sb); - isValidAssHeader = true; - styles = AdvancedSubStationAlpha.GetStylesFromHeader(subtitle.Header); - } - else if (subtitle.Header != null && subtitle.Header.Contains("http://www.w3.org/ns/ttml")) - { - LoadStylesFromTimedText10(subtitle, title, header, HeaderNoStyles, sb); - } - else - { - var ssa = Configuration.Settings.SubtitleSettings; - string boldStyle = "0"; // 0=regular - if (ssa.SsaFontBold) - { - boldStyle = "-1"; // -1 = true, 0 is false - } - - sb.AppendLine(string.Format(header, - title, - ssa.SsaFontName, - (int)ssa.SsaFontSize, - ColorTranslator.ToWin32(fontColor), - ssa.SsaOutline, - ssa.SsaShadow, - ssa.SsaMarginLeft, - ssa.SsaMarginRight, - ssa.SsaMarginTopBottom, - boldStyle - )); - } - foreach (Paragraph p in subtitle.Paragraphs) - { - string start = string.Format(timeCodeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10); - string end = string.Format(timeCodeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10); - string style = "Default"; - - string actor = "NTP"; - if (!string.IsNullOrEmpty(p.Actor)) - { - actor = p.Actor; - } - - string marginL = "0000"; - if (!string.IsNullOrEmpty(p.MarginL) && Utilities.IsInteger(p.MarginL)) - { - marginL = p.MarginL.PadLeft(4, '0'); - } - - string marginR = "0000"; - if (!string.IsNullOrEmpty(p.MarginR) && Utilities.IsInteger(p.MarginR)) - { - marginR = p.MarginR.PadLeft(4, '0'); - } - - string marginV = "0000"; - if (!string.IsNullOrEmpty(p.MarginV) && Utilities.IsInteger(p.MarginV)) - { - marginV = p.MarginV.PadLeft(4, '0'); - } - - string effect = ""; - if (!string.IsNullOrEmpty(p.Effect)) - { - effect = p.Effect; - } - - if (!string.IsNullOrEmpty(p.Extra) && isValidAssHeader && styles.Contains(p.Extra)) - { - style = p.Extra; - } - - if (style == "Default") - { - style = "*Default"; - } - - if (p.IsComment) - { - sb.AppendLine(string.Format(commentWriteFormat, start, end, AdvancedSubStationAlpha.FormatText(p), style, p.Layer, actor, marginL, marginR, marginV, effect)); - } - else - { - sb.AppendLine(string.Format(paragraphWriteFormat, start, end, AdvancedSubStationAlpha.FormatText(p), style, p.Layer, actor, marginL, marginR, marginV, effect)); - } - } - return sb.ToString().Trim() + Environment.NewLine; - } - - private static void LoadStylesFromAdvancedSubstationAlpha(Subtitle subtitle, string title, string header, string headerNoStyles, StringBuilder sb) - { - try - { - var style = GetStyle(subtitle.Header); - if (!string.IsNullOrEmpty(style)) - { - sb.AppendLine(string.Format(headerNoStyles, title, style)); - subtitle.Header = sb.ToString(); - } - else - { - sb.AppendLine(string.Format(header, title)); - } - } - catch - { - sb.AppendLine(string.Format(header, title)); - } - } - - private static string GetStyle(string header) - { - var ttStyles = new StringBuilder(); - foreach (string styleName in AdvancedSubStationAlpha.GetStylesFromHeader(header)) - { - try - { - var ssaStyle = AdvancedSubStationAlpha.GetSsaStyle(styleName, header); - - string bold = "0"; - if (ssaStyle.Bold) - { - bold = "-1"; - } - - string italic = "0"; - if (ssaStyle.Italic) - { - italic = "-1"; - } - - string newAlignment = "2"; - switch (ssaStyle.Alignment) - { - case "1": - newAlignment = "1"; - break; - case "3": - newAlignment = "3"; - break; - case "4": - newAlignment = "9"; - break; - case "5": - newAlignment = "10"; - break; - case "6": - newAlignment = "11"; - break; - case "7": - newAlignment = "5"; - break; - case "8": - newAlignment = "6"; - break; - case "9": - newAlignment = "7"; - break; - } - - //Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding - const string styleFormat = "Style: {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},0,1"; - // N FN FS PC SC TC BC Bo It BS O Sh Ali ML MR MV A Encoding - - ttStyles.AppendLine(string.Format(styleFormat, ssaStyle.Name, ssaStyle.FontName, ssaStyle.FontSize, ssaStyle.Primary.ToArgb(), ssaStyle.Secondary.ToArgb(), - ssaStyle.Outline.ToArgb(), ssaStyle.Background.ToArgb(), bold, italic, ssaStyle.BorderStyle, ssaStyle.OutlineWidth.ToString(CultureInfo.InvariantCulture), ssaStyle.ShadowWidth.ToString(CultureInfo.InvariantCulture), - newAlignment, ssaStyle.MarginLeft, ssaStyle.MarginRight, ssaStyle.MarginVertical)); - } - catch - { - // ignored - } - } - - return ttStyles.ToString(); - } - - private static void LoadStylesFromTimedText10(Subtitle subtitle, string title, string header, string headerNoStyles, StringBuilder sb) - { - try - { - var lines = subtitle.Header.SplitToLines(); - var tt = new TimedText10(); - var sub = new Subtitle(); - tt.LoadSubtitle(sub, lines, string.Empty); - - var xml = new XmlDocument(); - xml.LoadXml(subtitle.Header); - var nsmgr = new XmlNamespaceManager(xml.NameTable); - nsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml"); - XmlNode head = xml.DocumentElement.SelectSingleNode("ttml:head", nsmgr); - int stylexmlCount = 0; - var ttStyles = new StringBuilder(); - foreach (XmlNode node in head.SelectNodes("//ttml:style", nsmgr)) - { - string name = null; - if (node.Attributes["xml:id"] != null) - { - name = node.Attributes["xml:id"].Value; - } - else if (node.Attributes["id"] != null) - { - name = node.Attributes["id"].Value; - } - - if (name != null) - { - stylexmlCount++; - - string fontFamily = "Arial"; - if (node.Attributes["tts:fontFamily"] != null) - { - fontFamily = node.Attributes["tts:fontFamily"].Value; - } - - string fontWeight = "normal"; - if (node.Attributes["tts:fontWeight"] != null) - { - fontWeight = node.Attributes["tts:fontWeight"].Value; - } - - string fontStyle = "normal"; - if (node.Attributes["tts:fontStyle"] != null) - { - fontStyle = node.Attributes["tts:fontStyle"].Value; - } - - string color = "#ffffff"; - if (node.Attributes["tts:color"] != null) - { - color = node.Attributes["tts:color"].Value.Trim(); - } - - Color c; - try - { - if (color.StartsWith("rgb(", StringComparison.Ordinal)) - { - string[] arr = color.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); - } - else - { - c = ColorTranslator.FromHtml(color); - } - } - catch - { - c = Color.White; - } - - string fontSize = "20"; - if (node.Attributes["tts:fontSize"] != null) - { - fontSize = node.Attributes["tts:fontSize"].Value.Replace("px", string.Empty).Replace("em", string.Empty); - } - - if (!int.TryParse(fontSize, out var fSize)) - { - fSize = 20; - } - - const string styleFormat = "Style: {0},{1},{2},{3},65535,65535,-2147483640,-1,0,1,3,0,2,10,10,10,0,1"; - - ttStyles.AppendLine(string.Format(styleFormat, name, fontFamily, fSize, c.ToArgb())); - } - } - - if (stylexmlCount > 0) - { - sb.AppendLine(string.Format(headerNoStyles, title, ttStyles)); - subtitle.Header = sb.ToString(); - } - else - { - sb.AppendLine(string.Format(header, title)); - } - } - catch - { - sb.AppendLine(string.Format(header, title)); - } - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - Errors = null; - bool eventsStarted = false; - subtitle.Paragraphs.Clear(); - // "Marked", " Start", " End", " Style", " Name", " MarginL", " MarginR", " MarginV", " Effect", " Text" - int indexLayer = 0; - int indexStart = 1; - int indexEnd = 2; - int indexStyle = 3; - const int indexName = 4; - int indexMarginL = 5; - int indexMarginR = 6; - int indexMarginV = 7; - int indexEffect = 8; - int indexText = 9; - var errors = new StringBuilder(); - int lineNumber = 0; - - var header = new StringBuilder(); - for (int i1 = 0; i1 < lines.Count; i1++) - { - string line = lines[i1]; - lineNumber++; - if (!eventsStarted) - { - header.AppendLine(line); - } - - if (!string.IsNullOrEmpty(line) && line.TrimStart().StartsWith(';')) - { - // skip comment lines - } - else if (line.Trim().Equals("[events]", StringComparison.OrdinalIgnoreCase)) - { - eventsStarted = true; - } - else if (eventsStarted && !string.IsNullOrWhiteSpace(line)) - { - string s = line.Trim().ToLowerInvariant(); - if (line.Length > 10 && s.StartsWith("format:", StringComparison.Ordinal)) - { - var format = s.Substring(8).Split(','); - for (int i = 0; i < format.Length; i++) - { - var formatTrimmed = format[i].Trim(); - if (formatTrimmed.Equals("layer", StringComparison.Ordinal)) - { - indexLayer = i; - } - else if (formatTrimmed.Equals("start", StringComparison.Ordinal)) - { - indexStart = i; - } - else if (formatTrimmed.Equals("end", StringComparison.Ordinal)) - { - indexEnd = i; - } - else if (formatTrimmed.Equals("text", StringComparison.Ordinal)) - { - indexText = i; - } - else if (formatTrimmed.Equals("effect", StringComparison.Ordinal)) - { - indexEffect = i; - } - else if (formatTrimmed.Equals("style", StringComparison.Ordinal)) - { - indexStyle = i; - } - else if (formatTrimmed.Equals("marginl", StringComparison.Ordinal)) - { - indexMarginL = i; - } - else if (formatTrimmed.Equals("marginr", StringComparison.Ordinal)) - { - indexMarginR = i; - } - else if (formatTrimmed.Equals("marginv", StringComparison.Ordinal)) - { - indexMarginV = i; - } - } - } - else if (!string.IsNullOrEmpty(s)) - { - var text = string.Empty; - var start = string.Empty; - var end = string.Empty; - var style = string.Empty; - var marginL = string.Empty; - var marginR = string.Empty; - var marginV = string.Empty; - var layer = 0; - var effect = string.Empty; - var name = string.Empty; - - string[] splittedLine; - if (s.StartsWith("dialog:", StringComparison.Ordinal)) - { - splittedLine = line.Remove(0, 7).Split(','); - } - else if (s.StartsWith("dialogue:", StringComparison.Ordinal)) - { - splittedLine = line.Remove(0, 9).Split(','); - } - else - { - splittedLine = line.Split(','); - } - - for (int i = 0; i < splittedLine.Length; i++) - { - if (i == indexStart) - { - start = splittedLine[i].Trim(); - } - else if (i == indexEnd) - { - end = splittedLine[i].Trim(); - } - else if (i == indexLayer) - { - int.TryParse(splittedLine[i], out layer); - } - else if (i == indexEffect) - { - effect = splittedLine[i]; - } - else if (i == indexText) - { - text = splittedLine[i]; - } - else if (i == indexStyle) - { - style = splittedLine[i]; - } - else if (i == indexMarginL) - { - marginL = splittedLine[i].Trim(); - } - else if (i == indexMarginR) - { - marginR = splittedLine[i].Trim(); - } - else if (i == indexMarginV) - { - marginV = splittedLine[i].Trim(); - } - else if (i == indexName) - { - name = splittedLine[i]; - } - else if (i > indexText) - { - text += "," + splittedLine[i]; - } - } - - try - { - var p = new Paragraph - { - StartTime = GetTimeCodeFromString(start), - EndTime = GetTimeCodeFromString(end), - Text = AdvancedSubStationAlpha.GetFormattedText(text) - }; - - if (!string.IsNullOrEmpty(style)) - { - p.Extra = style; - } - - if (!string.IsNullOrEmpty(marginL)) - { - p.MarginL = marginL; - } - - if (!string.IsNullOrEmpty(marginR)) - { - p.MarginR = marginR; - } - - if (!string.IsNullOrEmpty(marginV)) - { - p.MarginV = marginV; - } - - if (!string.IsNullOrEmpty(effect)) - { - p.Effect = effect; - } - - p.Layer = layer; - if (!string.IsNullOrEmpty(name)) - { - p.Actor = name; - } - - p.IsComment = s.StartsWith("comment:", StringComparison.Ordinal); - subtitle.Paragraphs.Add(p); - } - catch - { - _errorCount++; - if (errors.Length < 2000) - { - errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXErrorReadingTimeCodeFromSourceLineY, lineNumber, line)); - } - else if (subtitle.Paragraphs.Count == 0) - { - break; - } - } - } - } - } - if (header.Length > 0) - { - subtitle.Header = header.ToString(); - } - - subtitle.Renumber(); - Errors = errors.ToString(); - } - - private static TimeCode GetTimeCodeFromString(string time) - { - // h:mm:ss.cc - string[] timeCode = time.Split(':', '.'); - return new TimeCode(int.Parse(timeCode[0]), - int.Parse(timeCode[1]), - int.Parse(timeCode[2]), - int.Parse(timeCode[3]) * 10); - } - - public override void RemoveNativeFormatting(Subtitle subtitle, SubtitleFormat newFormat) - { - if (newFormat != null && newFormat.Name == AdvancedSubStationAlpha.NameOfFormat) - { - // do we need any conversion? - } - else - { - foreach (Paragraph p in subtitle.Paragraphs) - { - int indexOfBegin = p.Text.IndexOf('{'); - string pre = string.Empty; - while (indexOfBegin >= 0 && p.Text.IndexOf('}') > indexOfBegin) - { - string s = p.Text.Substring(indexOfBegin); - if (s.StartsWith("{\\an1}", StringComparison.Ordinal) || - s.StartsWith("{\\an2}", StringComparison.Ordinal) || - s.StartsWith("{\\an3}", StringComparison.Ordinal) || - s.StartsWith("{\\an4}", StringComparison.Ordinal) || - s.StartsWith("{\\an5}", StringComparison.Ordinal) || - s.StartsWith("{\\an6}", StringComparison.Ordinal) || - s.StartsWith("{\\an7}", StringComparison.Ordinal) || - s.StartsWith("{\\an8}", StringComparison.Ordinal) || - s.StartsWith("{\\an9}", StringComparison.Ordinal)) - { - pre = s.Substring(0, 6); - } - else if (s.StartsWith("{\\an1\\", StringComparison.Ordinal) || - s.StartsWith("{\\an2\\", StringComparison.Ordinal) || - s.StartsWith("{\\an3\\", StringComparison.Ordinal) || - s.StartsWith("{\\an4\\", StringComparison.Ordinal) || - s.StartsWith("{\\an5\\", StringComparison.Ordinal) || - s.StartsWith("{\\an6\\", StringComparison.Ordinal) || - s.StartsWith("{\\an7\\", StringComparison.Ordinal) || - s.StartsWith("{\\an8\\", StringComparison.Ordinal) || - s.StartsWith("{\\an9\\", StringComparison.Ordinal)) - { - pre = s.Substring(0, 5) + "}"; - } - else if (s.StartsWith("{\\a1}", StringComparison.Ordinal) || s.StartsWith("{\\a1\\", StringComparison.Ordinal) || - s.StartsWith("{\\a3}", StringComparison.Ordinal) || s.StartsWith("{\\a3\\", StringComparison.Ordinal)) - { - pre = s.Substring(0, 4) + "}"; - } - else if (s.StartsWith("{\\a9}", StringComparison.Ordinal) || s.StartsWith("{\\a9\\", StringComparison.Ordinal)) - { - pre = "{\\an4}"; - } - else if (s.StartsWith("{\\a10}", StringComparison.Ordinal) || s.StartsWith("{\\a10\\", StringComparison.Ordinal)) - { - pre = "{\\an5}"; - } - else if (s.StartsWith("{\\a11}", StringComparison.Ordinal) || s.StartsWith("{\\a11\\", StringComparison.Ordinal)) - { - pre = "{\\an6}"; - } - else if (s.StartsWith("{\\a5}", StringComparison.Ordinal) || s.StartsWith("{\\a5\\", StringComparison.Ordinal)) - { - pre = "{\\an7}"; - } - else if (s.StartsWith("{\\a6}", StringComparison.Ordinal) || s.StartsWith("{\\a6\\", StringComparison.Ordinal)) - { - pre = "{\\an8}"; - } - else if (s.StartsWith("{\\a7}", StringComparison.Ordinal) || s.StartsWith("{\\a7\\", StringComparison.Ordinal)) - { - pre = "{\\an9}"; - } - int indexOfEnd = p.Text.IndexOf('}'); - p.Text = p.Text.Remove(indexOfBegin, (indexOfEnd - indexOfBegin) + 1); - - indexOfBegin = p.Text.IndexOf('{'); - } - p.Text = pre + p.Text; - } - } - } - - public override bool HasStyleSupport => true; - - public static string GetHeaderAndStylesFromAdvancedSubStationAlpha(string header, string title) - { - var scriptInfo = string.Empty; - if (header != null && header.Contains("[Script Info]") && header.Contains("ScriptType: v4.00+")) - { - var sb = new StringBuilder(); - var scriptInfoOn = false; - foreach (var line in header.SplitToLines()) - { - if (line.RemoveChar(' ').Contains("Styles]", StringComparison.OrdinalIgnoreCase)) - { - break; - } - - if (line.Equals("[Script Info]", StringComparison.OrdinalIgnoreCase)) - { - scriptInfoOn = true; - } - - if (scriptInfoOn) - { - if (line.StartsWith("ScriptType:", StringComparison.OrdinalIgnoreCase)) - { - sb.AppendLine("ScriptType: v4.00"); - } - else if (line.Equals("; This is an Advanced Sub Station Alpha v4+ script.", StringComparison.OrdinalIgnoreCase)) - { - sb.AppendLine("; This is a Sub Station Alpha v4 script."); - } - else - { - sb.AppendLine(line); - } - } - } - scriptInfo = sb.ToString(); - } - - var style = GetStyle(header); - - if (string.IsNullOrEmpty(scriptInfo) || string.IsNullOrEmpty(style)) - { - var s = new Subtitle { Paragraphs = { new Paragraph("test", 0, 1000) } }; - new SubStationAlpha().ToText(s, string.Empty); - return s.Header; - } - - return string.Format($@"{scriptInfo.Trim() + Environment.NewLine} -[V4 Styles] -Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding -{style.Trim() + Environment.NewLine} -[Events]"); - } - } -} +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SubStationAlpha : SubtitleFormat + { + public string Errors { get; private set; } + + public override string Extension => ".ssa"; + + public const string NameOfFormat = "Sub Station Alpha"; + + public override string Name => NameOfFormat; + + public override bool IsMine(List lines, string fileName) + { + var subtitle = new Subtitle(); + LoadSubtitle(subtitle, lines, fileName); + Errors = null; + return subtitle.Paragraphs.Count > _errorCount; + } + + const string HeaderNoStyles = + @"[Script Info] +; This is a Sub Station Alpha v4 script. +Title: {0} +ScriptType: v4.00 +Collisions: Normal +PlayDepth: 0 + +[V4 Styles] +Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding +{1} + +[Events] +Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"; + + public override string ToText(Subtitle subtitle, string title) + { + const string header = +@"[Script Info] +; This is a Sub Station Alpha v4 script. +Title: {0} +ScriptType: v4.00 +Collisions: Normal +PlayDepth: 0 + +[V4 Styles] +Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding +Style: Default,{1},{2},{3},65535,65535,-2147483640,{9},0,1,{4},{5},2,{6},{7},{8},0,1 + +[Events] +Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"; + + + + const string timeCodeFormat = "{0}:{1:00}:{2:00}.{3:00}"; // h:mm:ss.cc + const string paragraphWriteFormat = "Dialogue: Marked={4},{0},{1},{3},{5},{6},{7},{8},{9},{2}"; + const string commentWriteFormat = "Comment: Marked={4},{0},{1},{3},{5},{6},{7},{8},{9},{2}"; + + var sb = new StringBuilder(); + Color fontColor = Color.FromArgb(Configuration.Settings.SubtitleSettings.SsaFontColorArgb); + bool isValidAssHeader = !string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.Contains("[V4 Styles]"); + var styles = new List(); + if (isValidAssHeader) + { + sb.AppendLine(subtitle.Header.Trim()); + const string formatLine = "Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"; + if (!subtitle.Header.Contains(formatLine)) + { + sb.AppendLine(formatLine); + } + + styles = AdvancedSubStationAlpha.GetStylesFromHeader(subtitle.Header); + } + else if (!string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.Contains("[V4+ Styles]")) + { + LoadStylesFromAdvancedSubstationAlpha(subtitle, title, subtitle.Header, HeaderNoStyles, sb); + isValidAssHeader = true; + styles = AdvancedSubStationAlpha.GetStylesFromHeader(subtitle.Header); + } + else if (subtitle.Header != null && subtitle.Header.Contains("http://www.w3.org/ns/ttml")) + { + LoadStylesFromTimedText10(subtitle, title, header, HeaderNoStyles, sb); + } + else + { + var ssa = Configuration.Settings.SubtitleSettings; + string boldStyle = "0"; // 0=regular + if (ssa.SsaFontBold) + { + boldStyle = "-1"; // -1 = true, 0 is false + } + + sb.AppendLine(string.Format(header, + title, + ssa.SsaFontName, + (int)ssa.SsaFontSize, + ColorTranslator.ToWin32(fontColor), + ssa.SsaOutline, + ssa.SsaShadow, + ssa.SsaMarginLeft, + ssa.SsaMarginRight, + ssa.SsaMarginTopBottom, + boldStyle + )); + } + foreach (Paragraph p in subtitle.Paragraphs) + { + string start = string.Format(timeCodeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10); + string end = string.Format(timeCodeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10); + string style = "Default"; + + string actor = "NTP"; + if (!string.IsNullOrEmpty(p.Actor)) + { + actor = p.Actor; + } + + string marginL = "0000"; + if (!string.IsNullOrEmpty(p.MarginL) && Utilities.IsInteger(p.MarginL)) + { + marginL = p.MarginL.PadLeft(4, '0'); + } + + string marginR = "0000"; + if (!string.IsNullOrEmpty(p.MarginR) && Utilities.IsInteger(p.MarginR)) + { + marginR = p.MarginR.PadLeft(4, '0'); + } + + string marginV = "0000"; + if (!string.IsNullOrEmpty(p.MarginV) && Utilities.IsInteger(p.MarginV)) + { + marginV = p.MarginV.PadLeft(4, '0'); + } + + string effect = ""; + if (!string.IsNullOrEmpty(p.Effect)) + { + effect = p.Effect; + } + + if (!string.IsNullOrEmpty(p.Extra) && isValidAssHeader && styles.Contains(p.Extra)) + { + style = p.Extra; + } + + if (style == "Default") + { + style = "*Default"; + } + + if (p.IsComment) + { + sb.AppendLine(string.Format(commentWriteFormat, start, end, AdvancedSubStationAlpha.FormatText(p), style, p.Layer, actor, marginL, marginR, marginV, effect)); + } + else + { + sb.AppendLine(string.Format(paragraphWriteFormat, start, end, AdvancedSubStationAlpha.FormatText(p), style, p.Layer, actor, marginL, marginR, marginV, effect)); + } + } + return sb.ToString().Trim() + Environment.NewLine; + } + + private static void LoadStylesFromAdvancedSubstationAlpha(Subtitle subtitle, string title, string header, string headerNoStyles, StringBuilder sb) + { + try + { + var style = GetStyle(subtitle.Header); + if (!string.IsNullOrEmpty(style)) + { + sb.AppendLine(string.Format(headerNoStyles, title, style)); + subtitle.Header = sb.ToString(); + } + else + { + sb.AppendLine(string.Format(header, title)); + } + } + catch + { + sb.AppendLine(string.Format(header, title)); + } + } + + private static string GetStyle(string header) + { + var ttStyles = new StringBuilder(); + foreach (string styleName in AdvancedSubStationAlpha.GetStylesFromHeader(header)) + { + try + { + var ssaStyle = AdvancedSubStationAlpha.GetSsaStyle(styleName, header); + + string bold = "0"; + if (ssaStyle.Bold) + { + bold = "-1"; + } + + string italic = "0"; + if (ssaStyle.Italic) + { + italic = "-1"; + } + + string newAlignment = "2"; + switch (ssaStyle.Alignment) + { + case "1": + newAlignment = "1"; + break; + case "3": + newAlignment = "3"; + break; + case "4": + newAlignment = "9"; + break; + case "5": + newAlignment = "10"; + break; + case "6": + newAlignment = "11"; + break; + case "7": + newAlignment = "5"; + break; + case "8": + newAlignment = "6"; + break; + case "9": + newAlignment = "7"; + break; + } + + //Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding + const string styleFormat = "Style: {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},0,1"; + // N FN FS PC SC TC BC Bo It BS O Sh Ali ML MR MV A Encoding + + ttStyles.AppendLine(string.Format(styleFormat, ssaStyle.Name, ssaStyle.FontName, ssaStyle.FontSize, ssaStyle.Primary.ToArgb(), ssaStyle.Secondary.ToArgb(), + ssaStyle.Outline.ToArgb(), ssaStyle.Background.ToArgb(), bold, italic, ssaStyle.BorderStyle, ssaStyle.OutlineWidth.ToString(CultureInfo.InvariantCulture), ssaStyle.ShadowWidth.ToString(CultureInfo.InvariantCulture), + newAlignment, ssaStyle.MarginLeft, ssaStyle.MarginRight, ssaStyle.MarginVertical)); + } + catch + { + // ignored + } + } + + return ttStyles.ToString(); + } + + private static void LoadStylesFromTimedText10(Subtitle subtitle, string title, string header, string headerNoStyles, StringBuilder sb) + { + try + { + var lines = subtitle.Header.SplitToLines(); + var tt = new TimedText10(); + var sub = new Subtitle(); + tt.LoadSubtitle(sub, lines, string.Empty); + + var xml = new XmlDocument(); + xml.LoadXml(subtitle.Header); + var nsmgr = new XmlNamespaceManager(xml.NameTable); + nsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml"); + XmlNode head = xml.DocumentElement.SelectSingleNode("ttml:head", nsmgr); + int stylexmlCount = 0; + var ttStyles = new StringBuilder(); + foreach (XmlNode node in head.SelectNodes("//ttml:style", nsmgr)) + { + string name = null; + if (node.Attributes["xml:id"] != null) + { + name = node.Attributes["xml:id"].Value; + } + else if (node.Attributes["id"] != null) + { + name = node.Attributes["id"].Value; + } + + if (name != null) + { + stylexmlCount++; + + string fontFamily = "Arial"; + if (node.Attributes["tts:fontFamily"] != null) + { + fontFamily = node.Attributes["tts:fontFamily"].Value; + } + + string fontWeight = "normal"; + if (node.Attributes["tts:fontWeight"] != null) + { + fontWeight = node.Attributes["tts:fontWeight"].Value; + } + + string fontStyle = "normal"; + if (node.Attributes["tts:fontStyle"] != null) + { + fontStyle = node.Attributes["tts:fontStyle"].Value; + } + + string color = "#ffffff"; + if (node.Attributes["tts:color"] != null) + { + color = node.Attributes["tts:color"].Value.Trim(); + } + + Color c; + try + { + if (color.StartsWith("rgb(", StringComparison.Ordinal)) + { + string[] arr = color.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); + } + else + { + c = ColorTranslator.FromHtml(color); + } + } + catch + { + c = Color.White; + } + + string fontSize = "20"; + if (node.Attributes["tts:fontSize"] != null) + { + fontSize = node.Attributes["tts:fontSize"].Value.Replace("px", string.Empty).Replace("em", string.Empty); + } + + if (!int.TryParse(fontSize, out var fSize)) + { + fSize = 20; + } + + const string styleFormat = "Style: {0},{1},{2},{3},65535,65535,-2147483640,-1,0,1,3,0,2,10,10,10,0,1"; + + ttStyles.AppendLine(string.Format(styleFormat, name, fontFamily, fSize, c.ToArgb())); + } + } + + if (stylexmlCount > 0) + { + sb.AppendLine(string.Format(headerNoStyles, title, ttStyles)); + subtitle.Header = sb.ToString(); + } + else + { + sb.AppendLine(string.Format(header, title)); + } + } + catch + { + sb.AppendLine(string.Format(header, title)); + } + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + Errors = null; + bool eventsStarted = false; + subtitle.Paragraphs.Clear(); + // "Marked", " Start", " End", " Style", " Name", " MarginL", " MarginR", " MarginV", " Effect", " Text" + int indexLayer = 0; + int indexStart = 1; + int indexEnd = 2; + int indexStyle = 3; + const int indexName = 4; + int indexMarginL = 5; + int indexMarginR = 6; + int indexMarginV = 7; + int indexEffect = 8; + int indexText = 9; + var errors = new StringBuilder(); + int lineNumber = 0; + + var header = new StringBuilder(); + for (int i1 = 0; i1 < lines.Count; i1++) + { + string line = lines[i1]; + lineNumber++; + if (!eventsStarted) + { + header.AppendLine(line); + } + + if (!string.IsNullOrEmpty(line) && line.TrimStart().StartsWith(';')) + { + // skip comment lines + } + else if (line.Trim().Equals("[events]", StringComparison.OrdinalIgnoreCase)) + { + eventsStarted = true; + } + else if (eventsStarted && !string.IsNullOrWhiteSpace(line)) + { + string s = line.Trim().ToLowerInvariant(); + if (line.Length > 10 && s.StartsWith("format:", StringComparison.Ordinal)) + { + var format = s.Substring(8).Split(','); + for (int i = 0; i < format.Length; i++) + { + var formatTrimmed = format[i].Trim(); + if (formatTrimmed.Equals("layer", StringComparison.Ordinal)) + { + indexLayer = i; + } + else if (formatTrimmed.Equals("start", StringComparison.Ordinal)) + { + indexStart = i; + } + else if (formatTrimmed.Equals("end", StringComparison.Ordinal)) + { + indexEnd = i; + } + else if (formatTrimmed.Equals("text", StringComparison.Ordinal)) + { + indexText = i; + } + else if (formatTrimmed.Equals("effect", StringComparison.Ordinal)) + { + indexEffect = i; + } + else if (formatTrimmed.Equals("style", StringComparison.Ordinal)) + { + indexStyle = i; + } + else if (formatTrimmed.Equals("marginl", StringComparison.Ordinal)) + { + indexMarginL = i; + } + else if (formatTrimmed.Equals("marginr", StringComparison.Ordinal)) + { + indexMarginR = i; + } + else if (formatTrimmed.Equals("marginv", StringComparison.Ordinal)) + { + indexMarginV = i; + } + } + } + else if (!string.IsNullOrEmpty(s)) + { + var text = string.Empty; + var start = string.Empty; + var end = string.Empty; + var style = string.Empty; + var marginL = string.Empty; + var marginR = string.Empty; + var marginV = string.Empty; + var layer = 0; + var effect = string.Empty; + var name = string.Empty; + + string[] splittedLine; + if (s.StartsWith("dialog:", StringComparison.Ordinal)) + { + splittedLine = line.Remove(0, 7).Split(','); + } + else if (s.StartsWith("dialogue:", StringComparison.Ordinal)) + { + splittedLine = line.Remove(0, 9).Split(','); + } + else + { + splittedLine = line.Split(','); + } + + for (int i = 0; i < splittedLine.Length; i++) + { + if (i == indexStart) + { + start = splittedLine[i].Trim(); + } + else if (i == indexEnd) + { + end = splittedLine[i].Trim(); + } + else if (i == indexLayer) + { + int.TryParse(splittedLine[i], out layer); + } + else if (i == indexEffect) + { + effect = splittedLine[i]; + } + else if (i == indexText) + { + text = splittedLine[i]; + } + else if (i == indexStyle) + { + style = splittedLine[i]; + } + else if (i == indexMarginL) + { + marginL = splittedLine[i].Trim(); + } + else if (i == indexMarginR) + { + marginR = splittedLine[i].Trim(); + } + else if (i == indexMarginV) + { + marginV = splittedLine[i].Trim(); + } + else if (i == indexName) + { + name = splittedLine[i]; + } + else if (i > indexText) + { + text += "," + splittedLine[i]; + } + } + + try + { + var p = new Paragraph + { + StartTime = GetTimeCodeFromString(start), + EndTime = GetTimeCodeFromString(end), + Text = AdvancedSubStationAlpha.GetFormattedText(text) + }; + + if (!string.IsNullOrEmpty(style)) + { + p.Extra = style; + } + + if (!string.IsNullOrEmpty(marginL)) + { + p.MarginL = marginL; + } + + if (!string.IsNullOrEmpty(marginR)) + { + p.MarginR = marginR; + } + + if (!string.IsNullOrEmpty(marginV)) + { + p.MarginV = marginV; + } + + if (!string.IsNullOrEmpty(effect)) + { + p.Effect = effect; + } + + p.Layer = layer; + if (!string.IsNullOrEmpty(name)) + { + p.Actor = name; + } + + p.IsComment = s.StartsWith("comment:", StringComparison.Ordinal); + subtitle.Paragraphs.Add(p); + } + catch + { + _errorCount++; + if (errors.Length < 2000) + { + errors.AppendLine(string.Format(Configuration.Settings.Language.Main.LineNumberXErrorReadingTimeCodeFromSourceLineY, lineNumber, line)); + } + else if (subtitle.Paragraphs.Count == 0) + { + break; + } + } + } + } + } + if (header.Length > 0) + { + subtitle.Header = header.ToString(); + } + + subtitle.Renumber(); + Errors = errors.ToString(); + } + + private static TimeCode GetTimeCodeFromString(string time) + { + // h:mm:ss.cc + string[] timeCode = time.Split(':', '.'); + return new TimeCode(int.Parse(timeCode[0]), + int.Parse(timeCode[1]), + int.Parse(timeCode[2]), + int.Parse(timeCode[3]) * 10); + } + + public override void RemoveNativeFormatting(Subtitle subtitle, SubtitleFormat newFormat) + { + if (newFormat != null && newFormat.Name == AdvancedSubStationAlpha.NameOfFormat) + { + // do we need any conversion? + } + else + { + foreach (Paragraph p in subtitle.Paragraphs) + { + int indexOfBegin = p.Text.IndexOf('{'); + string pre = string.Empty; + while (indexOfBegin >= 0 && p.Text.IndexOf('}') > indexOfBegin) + { + string s = p.Text.Substring(indexOfBegin); + if (s.StartsWith("{\\an1}", StringComparison.Ordinal) || + s.StartsWith("{\\an2}", StringComparison.Ordinal) || + s.StartsWith("{\\an3}", StringComparison.Ordinal) || + s.StartsWith("{\\an4}", StringComparison.Ordinal) || + s.StartsWith("{\\an5}", StringComparison.Ordinal) || + s.StartsWith("{\\an6}", StringComparison.Ordinal) || + s.StartsWith("{\\an7}", StringComparison.Ordinal) || + s.StartsWith("{\\an8}", StringComparison.Ordinal) || + s.StartsWith("{\\an9}", StringComparison.Ordinal)) + { + pre = s.Substring(0, 6); + } + else if (s.StartsWith("{\\an1\\", StringComparison.Ordinal) || + s.StartsWith("{\\an2\\", StringComparison.Ordinal) || + s.StartsWith("{\\an3\\", StringComparison.Ordinal) || + s.StartsWith("{\\an4\\", StringComparison.Ordinal) || + s.StartsWith("{\\an5\\", StringComparison.Ordinal) || + s.StartsWith("{\\an6\\", StringComparison.Ordinal) || + s.StartsWith("{\\an7\\", StringComparison.Ordinal) || + s.StartsWith("{\\an8\\", StringComparison.Ordinal) || + s.StartsWith("{\\an9\\", StringComparison.Ordinal)) + { + pre = s.Substring(0, 5) + "}"; + } + else if (s.StartsWith("{\\a1}", StringComparison.Ordinal) || s.StartsWith("{\\a1\\", StringComparison.Ordinal) || + s.StartsWith("{\\a3}", StringComparison.Ordinal) || s.StartsWith("{\\a3\\", StringComparison.Ordinal)) + { + pre = s.Substring(0, 4) + "}"; + } + else if (s.StartsWith("{\\a9}", StringComparison.Ordinal) || s.StartsWith("{\\a9\\", StringComparison.Ordinal)) + { + pre = "{\\an4}"; + } + else if (s.StartsWith("{\\a10}", StringComparison.Ordinal) || s.StartsWith("{\\a10\\", StringComparison.Ordinal)) + { + pre = "{\\an5}"; + } + else if (s.StartsWith("{\\a11}", StringComparison.Ordinal) || s.StartsWith("{\\a11\\", StringComparison.Ordinal)) + { + pre = "{\\an6}"; + } + else if (s.StartsWith("{\\a5}", StringComparison.Ordinal) || s.StartsWith("{\\a5\\", StringComparison.Ordinal)) + { + pre = "{\\an7}"; + } + else if (s.StartsWith("{\\a6}", StringComparison.Ordinal) || s.StartsWith("{\\a6\\", StringComparison.Ordinal)) + { + pre = "{\\an8}"; + } + else if (s.StartsWith("{\\a7}", StringComparison.Ordinal) || s.StartsWith("{\\a7\\", StringComparison.Ordinal)) + { + pre = "{\\an9}"; + } + int indexOfEnd = p.Text.IndexOf('}'); + p.Text = p.Text.Remove(indexOfBegin, (indexOfEnd - indexOfBegin) + 1); + + indexOfBegin = p.Text.IndexOf('{'); + } + p.Text = pre + p.Text; + } + } + } + + public override bool HasStyleSupport => true; + + public static string GetHeaderAndStylesFromAdvancedSubStationAlpha(string header, string title) + { + var scriptInfo = string.Empty; + if (header != null && header.Contains("[Script Info]") && header.Contains("ScriptType: v4.00+")) + { + var sb = new StringBuilder(); + var scriptInfoOn = false; + foreach (var line in header.SplitToLines()) + { + if (line.RemoveChar(' ').Contains("Styles]", StringComparison.OrdinalIgnoreCase)) + { + break; + } + + if (line.Equals("[Script Info]", StringComparison.OrdinalIgnoreCase)) + { + scriptInfoOn = true; + } + + if (scriptInfoOn) + { + if (line.StartsWith("ScriptType:", StringComparison.OrdinalIgnoreCase)) + { + sb.AppendLine("ScriptType: v4.00"); + } + else if (line.Equals("; This is an Advanced Sub Station Alpha v4+ script.", StringComparison.OrdinalIgnoreCase)) + { + sb.AppendLine("; This is a Sub Station Alpha v4 script."); + } + else + { + sb.AppendLine(line); + } + } + } + scriptInfo = sb.ToString(); + } + + var style = GetStyle(header); + + if (string.IsNullOrEmpty(scriptInfo) || string.IsNullOrEmpty(style)) + { + var s = new Subtitle { Paragraphs = { new Paragraph("test", 0, 1000) } }; + new SubStationAlpha().ToText(s, string.Empty); + return s.Header; + } + + return string.Format($@"{scriptInfo.Trim() + Environment.NewLine} +[V4 Styles] +Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding +{style.Trim() + Environment.NewLine} +[Events]"); + } + } +} diff --git a/libse/SubtitleFormats/SubUrbia.cs b/src/libse/SubtitleFormats/SubUrbia.cs similarity index 100% rename from libse/SubtitleFormats/SubUrbia.cs rename to src/libse/SubtitleFormats/SubUrbia.cs diff --git a/libse/SubtitleFormats/SubViewer10.cs b/src/libse/SubtitleFormats/SubViewer10.cs similarity index 97% rename from libse/SubtitleFormats/SubViewer10.cs rename to src/libse/SubtitleFormats/SubViewer10.cs index 7461dcb56..11dff345d 100644 --- a/libse/SubtitleFormats/SubViewer10.cs +++ b/src/libse/SubtitleFormats/SubViewer10.cs @@ -1,126 +1,126 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SubViewer10 : SubtitleFormat - { - private static readonly Regex RegexTimeCode = new Regex(@"^\[\d\d:\d\d:\d\d\]$", RegexOptions.Compiled); - - private enum ExpectingLine - { - TimeStart, - Text, - TimeEnd, - } - - public override string Extension => ".sub"; - - public override string Name => "SubViewer 1.0"; - - public override string ToText(Subtitle subtitle, string title) - { - //[00:02:14] - //Yes a new line|Line number 2 - //[00:02:15] - string paragraphWriteFormat = "[{0:00}:{1:00}:{2:00}]" + Environment.NewLine + - "{3}" + Environment.NewLine + - "[{4:00}:{5:00}:{6:00}]"; - const string header = @"[TITLE] -{0} -[AUTHOR] -[SOURCE] -[PRG] -[FILEPATH] -[DELAY] -0 -[CD TRACK] -0 -[BEGIN] -******** START SCRIPT ******** -"; - const string footer = @"[end] -******** END SCRIPT ******** -"; - var sb = new StringBuilder(); - sb.AppendFormat(header, title); - foreach (Paragraph p in subtitle.Paragraphs) - { - string text = HtmlUtil.RemoveHtmlTags(p.Text.Replace(Environment.NewLine, "|")); - - sb.AppendLine(string.Format(paragraphWriteFormat, - p.StartTime.Hours, - p.StartTime.Minutes, - p.StartTime.Seconds, - text, - p.EndTime.Hours, - p.EndTime.Minutes, - p.EndTime.Seconds)); - sb.AppendLine(); - } - sb.Append(footer); - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - var paragraph = new Paragraph(); - ExpectingLine expecting = ExpectingLine.TimeStart; - _errorCount = 0; - - subtitle.Paragraphs.Clear(); - char[] splitChars = { ':', ']', '[', ' ' }; - foreach (string line in lines) - { - if (line.StartsWith('[') && RegexTimeCode.IsMatch(line)) - { - string[] parts = line.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); - if (parts.Length == 3) - { - try - { - int startHours = int.Parse(parts[0]); - int startMinutes = int.Parse(parts[1]); - int startSeconds = int.Parse(parts[2]); - var tc = new TimeCode(startHours, startMinutes, startSeconds, 0); - if (expecting == ExpectingLine.TimeStart) - { - paragraph = new Paragraph(); - paragraph.StartTime = tc; - expecting = ExpectingLine.Text; - } - else if (expecting == ExpectingLine.TimeEnd) - { - paragraph.EndTime = tc; - expecting = ExpectingLine.TimeStart; - subtitle.Paragraphs.Add(paragraph); - paragraph = new Paragraph(); - } - } - catch - { - _errorCount++; - expecting = ExpectingLine.TimeStart; - } - } - } - else - { - if (expecting == ExpectingLine.Text) - { - if (line.Length > 0) - { - string text = line.Replace("|", Environment.NewLine); - paragraph.Text = text; - expecting = ExpectingLine.TimeEnd; - } - } - } - } - subtitle.Renumber(); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SubViewer10 : SubtitleFormat + { + private static readonly Regex RegexTimeCode = new Regex(@"^\[\d\d:\d\d:\d\d\]$", RegexOptions.Compiled); + + private enum ExpectingLine + { + TimeStart, + Text, + TimeEnd, + } + + public override string Extension => ".sub"; + + public override string Name => "SubViewer 1.0"; + + public override string ToText(Subtitle subtitle, string title) + { + //[00:02:14] + //Yes a new line|Line number 2 + //[00:02:15] + string paragraphWriteFormat = "[{0:00}:{1:00}:{2:00}]" + Environment.NewLine + + "{3}" + Environment.NewLine + + "[{4:00}:{5:00}:{6:00}]"; + const string header = @"[TITLE] +{0} +[AUTHOR] +[SOURCE] +[PRG] +[FILEPATH] +[DELAY] +0 +[CD TRACK] +0 +[BEGIN] +******** START SCRIPT ******** +"; + const string footer = @"[end] +******** END SCRIPT ******** +"; + var sb = new StringBuilder(); + sb.AppendFormat(header, title); + foreach (Paragraph p in subtitle.Paragraphs) + { + string text = HtmlUtil.RemoveHtmlTags(p.Text.Replace(Environment.NewLine, "|")); + + sb.AppendLine(string.Format(paragraphWriteFormat, + p.StartTime.Hours, + p.StartTime.Minutes, + p.StartTime.Seconds, + text, + p.EndTime.Hours, + p.EndTime.Minutes, + p.EndTime.Seconds)); + sb.AppendLine(); + } + sb.Append(footer); + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + var paragraph = new Paragraph(); + ExpectingLine expecting = ExpectingLine.TimeStart; + _errorCount = 0; + + subtitle.Paragraphs.Clear(); + char[] splitChars = { ':', ']', '[', ' ' }; + foreach (string line in lines) + { + if (line.StartsWith('[') && RegexTimeCode.IsMatch(line)) + { + string[] parts = line.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); + if (parts.Length == 3) + { + try + { + int startHours = int.Parse(parts[0]); + int startMinutes = int.Parse(parts[1]); + int startSeconds = int.Parse(parts[2]); + var tc = new TimeCode(startHours, startMinutes, startSeconds, 0); + if (expecting == ExpectingLine.TimeStart) + { + paragraph = new Paragraph(); + paragraph.StartTime = tc; + expecting = ExpectingLine.Text; + } + else if (expecting == ExpectingLine.TimeEnd) + { + paragraph.EndTime = tc; + expecting = ExpectingLine.TimeStart; + subtitle.Paragraphs.Add(paragraph); + paragraph = new Paragraph(); + } + } + catch + { + _errorCount++; + expecting = ExpectingLine.TimeStart; + } + } + } + else + { + if (expecting == ExpectingLine.Text) + { + if (line.Length > 0) + { + string text = line.Replace("|", Environment.NewLine); + paragraph.Text = text; + expecting = ExpectingLine.TimeEnd; + } + } + } + } + subtitle.Renumber(); + } + } +} diff --git a/libse/SubtitleFormats/SubViewer20.cs b/src/libse/SubtitleFormats/SubViewer20.cs similarity index 97% rename from libse/SubtitleFormats/SubViewer20.cs rename to src/libse/SubtitleFormats/SubViewer20.cs index afcba3845..766007213 100644 --- a/libse/SubtitleFormats/SubViewer20.cs +++ b/src/libse/SubtitleFormats/SubViewer20.cs @@ -1,161 +1,161 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SubViewer20 : SubtitleFormat - { - private enum ExpectingLine - { - TimeCodes, - Text - } - - private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d.\d+,\d\d:\d\d:\d\d.\d+$", RegexOptions.Compiled); - - public override string Extension => ".sub"; - - public override string Name => "SubViewer 2.0"; - - public override bool IsMine(List lines, string fileName) - { - var sbv = new YouTubeSbv(); - if (sbv.IsMine(lines, fileName) && !string.Join(string.Empty, lines.ToArray()).Contains("[br]")) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - const string paragraphWriteFormat = "{0:00}:{1:00}:{2:00}.{3:00},{4:00}:{5:00}:{6:00}.{7:00}{8}{9}"; - const string header = @"[INFORMATION] -[TITLE]{0} -[AUTHOR] -[SOURCE] -[PRG] -[FILEPATH] -[DELAY]0 -[CD TRACK]0 -[COMMENT] -[END INFORMATION] -[SUBTITLE] -[COLF]&H000000,[STYLE]bd,[SIZE]25,[FONT]Arial -"; - //00:00:06.61,00:00:13.75 - //text1[br]text2 - var sb = new StringBuilder(); - if (subtitle.Header != null && subtitle.Header.Contains("[INFORMATION]")) - { - sb.AppendLine(subtitle.Header); - } - else - { - sb.AppendFormat(header, title); - } - foreach (Paragraph p in subtitle.Paragraphs) - { - string text = p.Text.Replace(Environment.NewLine, "[br]"); - text = text.Replace("", "{\\i1}"); - text = text.Replace("", "{\\i0}"); - text = text.Replace("", "{\\b1}"); - text = text.Replace("", "{\\b0}"); - text = text.Replace("", "{\\u1}"); - text = text.Replace("", "{\\u0}"); - - sb.AppendLine(string.Format(paragraphWriteFormat, - p.StartTime.Hours, - p.StartTime.Minutes, - p.StartTime.Seconds, - RoundTo2Cifres(p.StartTime.Milliseconds), - p.EndTime.Hours, - p.EndTime.Minutes, - p.EndTime.Seconds, - RoundTo2Cifres(p.EndTime.Milliseconds), - Environment.NewLine, - text)); - sb.AppendLine(); - } - return sb.ToString().Trim(); - } - - private static int RoundTo2Cifres(int milliseconds) - { - return (int)Math.Round(milliseconds / 10.0); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - var paragraph = new Paragraph(); - var expecting = ExpectingLine.TimeCodes; - _errorCount = 0; - char[] splitChars = { ':', ',', '.' }; - subtitle.Paragraphs.Clear(); - var header = new StringBuilder(); - foreach (string line in lines) - { - if (subtitle.Paragraphs.Count == 0 && expecting == ExpectingLine.TimeCodes && line.StartsWith("[", StringComparison.Ordinal)) - { - header.AppendLine(line); - } - else if (line.Length > 20 && char.IsDigit(line[0]) && RegexTimeCodes.IsMatch(line)) - { - var parts = line.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); - if (parts.Length == 8) - { - try - { - paragraph.StartTime = DecodeTimeCode(parts, 0); - paragraph.EndTime = DecodeTimeCode(parts, 4); - expecting = ExpectingLine.Text; - } - catch - { - _errorCount++; - expecting = ExpectingLine.TimeCodes; - } - } - } - else if (expecting == ExpectingLine.Text && line.Length > 0) - { - string text = line.Replace("[br]", Environment.NewLine); - if (text.Contains("{\\", StringComparison.Ordinal)) - { - text = text.Replace("{\\i1}", ""); - text = text.Replace("{\\i0}", ""); - text = text.Replace("{\\i}", ""); - text = text.Replace("{\\b1}", ""); - text = text.Replace("{\\b0}", ""); - text = text.Replace("{\\b}", ""); - text = text.Replace("{\\u1}", ""); - text = text.Replace("{\\u0}", ""); - text = text.Replace("{\\u}", ""); - } - paragraph.Text = text; - subtitle.Paragraphs.Add(paragraph); - paragraph = new Paragraph(); - expecting = ExpectingLine.TimeCodes; - } - } - subtitle.Renumber(); - if (header.ToString().Contains("[INFORMATION]")) - { - subtitle.Header = header.ToString().TrimEnd(); - } - } - - public static TimeCode DecodeTimeCode(string[] encodedTimeCode, int index) - { - // Hours, Minutes, Seconds, Milliseconds / 10. - return new TimeCode(int.Parse(encodedTimeCode[index]), - int.Parse(encodedTimeCode[index + 1]), - int.Parse(encodedTimeCode[index + 2]), - int.Parse(encodedTimeCode[index + 3]) * 10); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SubViewer20 : SubtitleFormat + { + private enum ExpectingLine + { + TimeCodes, + Text + } + + private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d.\d+,\d\d:\d\d:\d\d.\d+$", RegexOptions.Compiled); + + public override string Extension => ".sub"; + + public override string Name => "SubViewer 2.0"; + + public override bool IsMine(List lines, string fileName) + { + var sbv = new YouTubeSbv(); + if (sbv.IsMine(lines, fileName) && !string.Join(string.Empty, lines.ToArray()).Contains("[br]")) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + const string paragraphWriteFormat = "{0:00}:{1:00}:{2:00}.{3:00},{4:00}:{5:00}:{6:00}.{7:00}{8}{9}"; + const string header = @"[INFORMATION] +[TITLE]{0} +[AUTHOR] +[SOURCE] +[PRG] +[FILEPATH] +[DELAY]0 +[CD TRACK]0 +[COMMENT] +[END INFORMATION] +[SUBTITLE] +[COLF]&H000000,[STYLE]bd,[SIZE]25,[FONT]Arial +"; + //00:00:06.61,00:00:13.75 + //text1[br]text2 + var sb = new StringBuilder(); + if (subtitle.Header != null && subtitle.Header.Contains("[INFORMATION]")) + { + sb.AppendLine(subtitle.Header); + } + else + { + sb.AppendFormat(header, title); + } + foreach (Paragraph p in subtitle.Paragraphs) + { + string text = p.Text.Replace(Environment.NewLine, "[br]"); + text = text.Replace("", "{\\i1}"); + text = text.Replace("", "{\\i0}"); + text = text.Replace("", "{\\b1}"); + text = text.Replace("", "{\\b0}"); + text = text.Replace("", "{\\u1}"); + text = text.Replace("", "{\\u0}"); + + sb.AppendLine(string.Format(paragraphWriteFormat, + p.StartTime.Hours, + p.StartTime.Minutes, + p.StartTime.Seconds, + RoundTo2Cifres(p.StartTime.Milliseconds), + p.EndTime.Hours, + p.EndTime.Minutes, + p.EndTime.Seconds, + RoundTo2Cifres(p.EndTime.Milliseconds), + Environment.NewLine, + text)); + sb.AppendLine(); + } + return sb.ToString().Trim(); + } + + private static int RoundTo2Cifres(int milliseconds) + { + return (int)Math.Round(milliseconds / 10.0); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + var paragraph = new Paragraph(); + var expecting = ExpectingLine.TimeCodes; + _errorCount = 0; + char[] splitChars = { ':', ',', '.' }; + subtitle.Paragraphs.Clear(); + var header = new StringBuilder(); + foreach (string line in lines) + { + if (subtitle.Paragraphs.Count == 0 && expecting == ExpectingLine.TimeCodes && line.StartsWith("[", StringComparison.Ordinal)) + { + header.AppendLine(line); + } + else if (line.Length > 20 && char.IsDigit(line[0]) && RegexTimeCodes.IsMatch(line)) + { + var parts = line.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); + if (parts.Length == 8) + { + try + { + paragraph.StartTime = DecodeTimeCode(parts, 0); + paragraph.EndTime = DecodeTimeCode(parts, 4); + expecting = ExpectingLine.Text; + } + catch + { + _errorCount++; + expecting = ExpectingLine.TimeCodes; + } + } + } + else if (expecting == ExpectingLine.Text && line.Length > 0) + { + string text = line.Replace("[br]", Environment.NewLine); + if (text.Contains("{\\", StringComparison.Ordinal)) + { + text = text.Replace("{\\i1}", ""); + text = text.Replace("{\\i0}", ""); + text = text.Replace("{\\i}", ""); + text = text.Replace("{\\b1}", ""); + text = text.Replace("{\\b0}", ""); + text = text.Replace("{\\b}", ""); + text = text.Replace("{\\u1}", ""); + text = text.Replace("{\\u0}", ""); + text = text.Replace("{\\u}", ""); + } + paragraph.Text = text; + subtitle.Paragraphs.Add(paragraph); + paragraph = new Paragraph(); + expecting = ExpectingLine.TimeCodes; + } + } + subtitle.Renumber(); + if (header.ToString().Contains("[INFORMATION]")) + { + subtitle.Header = header.ToString().TrimEnd(); + } + } + + public static TimeCode DecodeTimeCode(string[] encodedTimeCode, int index) + { + // Hours, Minutes, Seconds, Milliseconds / 10. + return new TimeCode(int.Parse(encodedTimeCode[index]), + int.Parse(encodedTimeCode[index + 1]), + int.Parse(encodedTimeCode[index + 2]), + int.Parse(encodedTimeCode[index + 3]) * 10); + } + } +} diff --git a/libse/SubtitleFormats/SubtitleEditorProject.cs b/src/libse/SubtitleFormats/SubtitleEditorProject.cs similarity index 97% rename from libse/SubtitleFormats/SubtitleEditorProject.cs rename to src/libse/SubtitleFormats/SubtitleEditorProject.cs index 803f18859..619f366fc 100644 --- a/libse/SubtitleFormats/SubtitleEditorProject.cs +++ b/src/libse/SubtitleFormats/SubtitleEditorProject.cs @@ -1,158 +1,158 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SubtitleEditorProject : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "Subtitle Editor Project"; - - public override bool IsMine(List lines, string fileName) - { - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - string xmlAsString = sb.ToString().Trim(); - if (xmlAsString.Contains(" 0; - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - return false; - } - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - // - XmlNode div = xml.DocumentElement.SelectSingleNode("subtitles"); - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("subtitle"); - - XmlAttribute duration = xml.CreateAttribute("duration"); - duration.InnerText = ((int)Math.Round(p.Duration.TotalMilliseconds)).ToString(CultureInfo.InvariantCulture); - paragraph.Attributes.Append(duration); - - XmlAttribute effect = xml.CreateAttribute("effect"); - effect.InnerText = string.Empty; - paragraph.Attributes.Append(effect); - - XmlAttribute end = xml.CreateAttribute("end"); - end.InnerText = ((int)Math.Round(p.EndTime.TotalMilliseconds)).ToString(CultureInfo.InvariantCulture); - paragraph.Attributes.Append(end); - - XmlAttribute layer = xml.CreateAttribute("layer"); - layer.InnerText = "0"; - paragraph.Attributes.Append(layer); - - XmlAttribute marginL = xml.CreateAttribute("margin-l"); - marginL.InnerText = "0"; - paragraph.Attributes.Append(marginL); - - XmlAttribute marginR = xml.CreateAttribute("margin-r"); - marginR.InnerText = "0"; - paragraph.Attributes.Append(marginR); - - XmlAttribute marginV = xml.CreateAttribute("margin-v"); - marginV.InnerText = "0"; - paragraph.Attributes.Append(marginV); - - XmlAttribute name = xml.CreateAttribute("name"); - name.InnerText = string.Empty; - paragraph.Attributes.Append(name); - - XmlAttribute note = xml.CreateAttribute("note"); - note.InnerText = string.Empty; - paragraph.Attributes.Append(note); - - XmlAttribute path = xml.CreateAttribute("path"); - path.InnerText = "0"; - paragraph.Attributes.Append(path); - - XmlAttribute start = xml.CreateAttribute("start"); - start.InnerText = ((int)Math.Round(p.StartTime.TotalMilliseconds)).ToString(CultureInfo.InvariantCulture); - paragraph.Attributes.Append(start); - - XmlAttribute style = xml.CreateAttribute("style"); - style.InnerText = "Default"; - paragraph.Attributes.Append(style); - - string text = HtmlUtil.RemoveHtmlTags(p.Text); - XmlAttribute textNode = xml.CreateAttribute("text"); - textNode.InnerText = text; - paragraph.Attributes.Append(textNode); - - XmlAttribute translation = xml.CreateAttribute("translation"); - translation.InnerText = string.Empty; - paragraph.Attributes.Append(translation); - - div.AppendChild(paragraph); - } - - return ToUtf8XmlString(xml); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - var xml = new XmlDocument { XmlResolver = null }; - xml.LoadXml(sb.ToString().Trim()); - - XmlNode div = xml.DocumentElement.SelectSingleNode("subtitles"); - foreach (XmlNode node in div.ChildNodes) - { - try - { - // - var p = new Paragraph { StartTime = { TotalMilliseconds = int.Parse(node.Attributes["start"].Value) } }; - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + int.Parse(node.Attributes["duration"].Value); - p.Text = node.Attributes["text"].Value; - - subtitle.Paragraphs.Add(p); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - } - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SubtitleEditorProject : SubtitleFormat + { + public override string Extension => ".xml"; + + public override string Name => "Subtitle Editor Project"; + + public override bool IsMine(List lines, string fileName) + { + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + string xmlAsString = sb.ToString().Trim(); + if (xmlAsString.Contains(" 0; + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + return false; + } + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + // + XmlNode div = xml.DocumentElement.SelectSingleNode("subtitles"); + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("subtitle"); + + XmlAttribute duration = xml.CreateAttribute("duration"); + duration.InnerText = ((int)Math.Round(p.Duration.TotalMilliseconds)).ToString(CultureInfo.InvariantCulture); + paragraph.Attributes.Append(duration); + + XmlAttribute effect = xml.CreateAttribute("effect"); + effect.InnerText = string.Empty; + paragraph.Attributes.Append(effect); + + XmlAttribute end = xml.CreateAttribute("end"); + end.InnerText = ((int)Math.Round(p.EndTime.TotalMilliseconds)).ToString(CultureInfo.InvariantCulture); + paragraph.Attributes.Append(end); + + XmlAttribute layer = xml.CreateAttribute("layer"); + layer.InnerText = "0"; + paragraph.Attributes.Append(layer); + + XmlAttribute marginL = xml.CreateAttribute("margin-l"); + marginL.InnerText = "0"; + paragraph.Attributes.Append(marginL); + + XmlAttribute marginR = xml.CreateAttribute("margin-r"); + marginR.InnerText = "0"; + paragraph.Attributes.Append(marginR); + + XmlAttribute marginV = xml.CreateAttribute("margin-v"); + marginV.InnerText = "0"; + paragraph.Attributes.Append(marginV); + + XmlAttribute name = xml.CreateAttribute("name"); + name.InnerText = string.Empty; + paragraph.Attributes.Append(name); + + XmlAttribute note = xml.CreateAttribute("note"); + note.InnerText = string.Empty; + paragraph.Attributes.Append(note); + + XmlAttribute path = xml.CreateAttribute("path"); + path.InnerText = "0"; + paragraph.Attributes.Append(path); + + XmlAttribute start = xml.CreateAttribute("start"); + start.InnerText = ((int)Math.Round(p.StartTime.TotalMilliseconds)).ToString(CultureInfo.InvariantCulture); + paragraph.Attributes.Append(start); + + XmlAttribute style = xml.CreateAttribute("style"); + style.InnerText = "Default"; + paragraph.Attributes.Append(style); + + string text = HtmlUtil.RemoveHtmlTags(p.Text); + XmlAttribute textNode = xml.CreateAttribute("text"); + textNode.InnerText = text; + paragraph.Attributes.Append(textNode); + + XmlAttribute translation = xml.CreateAttribute("translation"); + translation.InnerText = string.Empty; + paragraph.Attributes.Append(translation); + + div.AppendChild(paragraph); + } + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + var xml = new XmlDocument { XmlResolver = null }; + xml.LoadXml(sb.ToString().Trim()); + + XmlNode div = xml.DocumentElement.SelectSingleNode("subtitles"); + foreach (XmlNode node in div.ChildNodes) + { + try + { + // + var p = new Paragraph { StartTime = { TotalMilliseconds = int.Parse(node.Attributes["start"].Value) } }; + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + int.Parse(node.Attributes["duration"].Value); + p.Text = node.Attributes["text"].Value; + + subtitle.Paragraphs.Add(p); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/SubtitleFormat.cs b/src/libse/SubtitleFormats/SubtitleFormat.cs similarity index 97% rename from libse/SubtitleFormats/SubtitleFormat.cs rename to src/libse/SubtitleFormats/SubtitleFormat.cs index 1eb25b1f6..2d0035207 100644 --- a/libse/SubtitleFormats/SubtitleFormat.cs +++ b/src/libse/SubtitleFormats/SubtitleFormat.cs @@ -1,661 +1,661 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; -using Nikse.SubtitleEdit.Core.Interfaces; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public abstract class SubtitleFormat - { - private static IList _allSubtitleFormats; - - protected static readonly char[] SplitCharColon = { ':' }; - - /// - /// Text formats supported by Subtitle Edit - /// - public static IEnumerable AllSubtitleFormats - { - get - { - if (_allSubtitleFormats != null) - { - return _allSubtitleFormats; - } - - _allSubtitleFormats = new List - { - new SubRip(), - new AbcIViewer(), - new AdobeAfterEffectsFTME(), - new AdobeEncore(), - new AdobeEncoreLineTabNewLine(), - new AdobeEncoreTabs(), - new AdobeEncoreWithLineNumbers(), - new AdobeEncoreWithLineNumbersNtsc(), - new AdvancedSubStationAlpha(), - new AQTitle(), - new AvidCaption(), - new AvidDvd(), - new AwsTranscribeJson(), - new BelleNuitSubtitler(), - new Bilibili(), - new Cappella(), - new CaptionAssistant(), - new Captionate(), - new CaptionateMs(), - new CaraokeXml(), - new Csv(), - new Csv2(), - new Csv3(), - new Csv4(), - new Csv5(), - new CsvNuendo(), - new DCinemaInterop(), - new DCinemaSmpte2007(), - new DCinemaSmpte2010(), - new DCinemaSmpte2014(), - new DigiBeta(), - new DvdStudioPro(), - new DvdStudioProSpaceOne(), - new DvdStudioProSpaceOneSemicolon(), - new DvdStudioProSpace(), - new DvdSubtitle(), - new DvdSubtitleSystem(), - new DvSubtitle(), - new Ebu(), - new Edl(), - new Eeg708(), - new ElrPrint(), - new ESubXf(), - new F4Text(), - new EZTSubtitlesProject(), - new F4Rtf(), - new F4Xml(), - new FabSubtitler(), - new FilmEditXml(), - new FinalCutProXml(), - new FinalCutProXXml(), - new FinalCutProXmlGap(), - new FinalCutProXCM(), - new FinalCutProXml13(), - new FinalCutProXml14(), - new FinalCutProXml14Text(), - new FinalCutProXml15(), - new FinalCutProXml16(), - new FinalCutProXml17(), - new FinalCutProXml18(), - new FinalCutProTestXml(), - new FinalCutProTest2Xml(), - new FlashXml(), - new FLVCoreCuePoints(), - new Footage(), - new GooglePlayJson(), - new GpacTtxt(), - new Gremots(), - new HollyStarJson(), - new ImageLogicAutocaption(), - new InqScribe(), - new IssXml(), - new ItunesTimedText(), - new JacoSub(), - new JsonTed(), - new Json(), - new JsonType2(), - new JsonType3(), - new JsonType4(), - new JsonType5(), - new JsonType6(), - new JsonType7(), - new JsonType8(), - new JsonType8b(), - new JsonType9(), - new JsonType10(), - new JsonType11(), - new JsonType12(), - new JsonType13(), - new JsonType14(), - new JsonType15(), - new JsonType16(), - new JsonType17(), - new JsonType18(), - new KanopyHtml(), - new LambdaCap(), - new Lrc(), - new MacSub(), - new MediaTransData(), - new MicroDvd(), - new MidwayInscriberCGX(), - new MPlayer2(), - new MsOfficeWorkbook(), - new NciTimedRollUpCaptions(), - new NetflixImsc11Japanese(), - new NetflixTimedText(), - new OgmChapters(), - new OpenDvt(), - new Oresme(), - new OresmeDocXDocument(), - new OtterAi(), - new Pe2(), - new PhoenixSubtitle(), - new PinnacleImpression(), - new PListCaption(), - new ProjectionSubtitleList(), - new QubeMasterImport(), - new QuickTimeText(), - new RealTime(), - new RhozetHarmonic(), - new Rtf1(), - new Rtf2(), - new Sami(), - new SamiAvDicPlayer(), - new SamiModern(), - new SamiYouTube(), - new Scenarist(), - new ScenaristClosedCaptions(), - new ScenaristClosedCaptionsDropFrame(), - new SmilTimesheetData(), - new SmpteTt2052(), - new SoftNiSub(), - new SoftNicolonSub(), - new SonyDVDArchitect(), - new SonyDVDArchitectExplicitDuration(), - new SonyDVDArchitectLineAndDuration(), - new SonyDVDArchitectLineDurationLength(), - new SonyDVDArchitectTabs(), - new SonyDVDArchitectWithLineNumbers(), - new Speechmatics(), - new Spruce(), - new SpruceWithSpace(), - new StructuredTitles(), - new SubStationAlpha(), - new SubtitleEditorProject(), - new SubUrbia(), - new SubViewer10(), - new SubViewer20(), - new SwiftInterchange2(), - new SwiftText(), - new SwiftTextLineNumber(), - new SwiftTextLineNOAndDur(), - new Tek(), - new TimeXml(), - new TimeXml2(), - new TimedText10(), - new TimedText200604(), - new TimedText200604CData(), - new TimedText200604Ooyala(), - new TimedText(), - new TitleExchangePro(), - new Titra(), - new TmpegEncText(), - new TmpegEncAW5(), - new TmpegEncXml(), - new TMPlayer(), - new TranscriberXml(), - new Tmx14(), - new TurboTitler(), - new TwentyThreeJson(), - new TwentyThreeJsonEmbed(), - new TwentyThreeJsonEmbedWebSrt(), - new UniversalSubtitleFormat(), - new UTSubtitleXml(), - new Utx(), - new UtxFrames(), - new UleadSubtitleFormat(), - new VocapiaSplit(), - new WebVTT(), - new WebVTTFileWithLineNumber(), - new Xif(), - new Xmp(), - new YouTubeAnnotations(), - new YouTubeSbv(), - new YouTubeTranscript(), - new YouTubeTranscriptOneLine(), - new ZeroG(), - // new Idx(), - new UnknownSubtitle1(), - new UnknownSubtitle2(), - new UnknownSubtitle3(), - new UnknownSubtitle4(), - new UnknownSubtitle5(), - new UnknownSubtitle6(), - new UnknownSubtitle7(), - new UnknownSubtitle8(), - new UnknownSubtitle9(), - new UnknownSubtitle10(), - new UnknownSubtitle11(), - new UnknownSubtitle12(), - new UnknownSubtitle13(), - new UnknownSubtitle14(), - new UnknownSubtitle15(), - new UnknownSubtitle16(), - new UnknownSubtitle17(), - new UnknownSubtitle18(), - new UnknownSubtitle19(), - new UnknownSubtitle20(), - new UnknownSubtitle21(), - new UnknownSubtitle22(), - new UnknownSubtitle23(), - new UnknownSubtitle24(), - new UnknownSubtitle25(), - new UnknownSubtitle26(), - new UnknownSubtitle27(), - new UnknownSubtitle28(), - new UnknownSubtitle29(), - new UnknownSubtitle30(), - new UnknownSubtitle31(), - new UnknownSubtitle32(), - new UnknownSubtitle33(), - new UnknownSubtitle34(), - new UnknownSubtitle35(), - new UnknownSubtitle36(), - new UnknownSubtitle37(), - new UnknownSubtitle38(), - new UnknownSubtitle39(), - new UnknownSubtitle40(), - new UnknownSubtitle41(), - new UnknownSubtitle42(), - new UnknownSubtitle43(), - new UnknownSubtitle44(), - new UnknownSubtitle45(), - new UnknownSubtitle46(), - new UnknownSubtitle47(), - new UnknownSubtitle48(), - new UnknownSubtitle49(), - new UnknownSubtitle50(), - new UnknownSubtitle51(), - new UnknownSubtitle52(), - new UnknownSubtitle53(), - new UnknownSubtitle54(), - new UnknownSubtitle55(), - new UnknownSubtitle56(), - new UnknownSubtitle57(), - new UnknownSubtitle58(), - new UnknownSubtitle59(), - new UnknownSubtitle60(), - new UnknownSubtitle61(), - new UnknownSubtitle62(), - new UnknownSubtitle63(), - new UnknownSubtitle64(), - new UnknownSubtitle65(), - new UnknownSubtitle66(), - new UnknownSubtitle67(), - new UnknownSubtitle68(), - new UnknownSubtitle69(), - new UnknownSubtitle70(), - new UnknownSubtitle71(), - new UnknownSubtitle72(), - new UnknownSubtitle73(), - new UnknownSubtitle74(), - new UnknownSubtitle75(), - new UnknownSubtitle76(), - new UnknownSubtitle77(), - new UnknownSubtitle78(), - new UnknownSubtitle79(), - new UnknownSubtitle80(), - new UnknownSubtitle81(), - new UnknownSubtitle82(), - new UnknownSubtitle83(), - new UnknownSubtitle84(), - new UnknownSubtitle85(), - new UnknownSubtitle86(), - new UnknownSubtitle87(), - new UnknownSubtitle88(), - new UnknownSubtitle89(), - new UnknownSubtitle90(), - new UnknownSubtitle91(), - new UnknownSubtitle92(), - new UnknownSubtitle93(), - new UnknownSubtitle94(), - new UnknownSubtitle95(), - new UnknownSubtitle96(), - new UnknownSubtitle97(), - new UnknownSubtitle98(), - new UnknownSubtitle99(), - new UnknownSubtitle100(), - new UnknownSubtitle101(), - }; - - string path = Configuration.PluginsDirectory; - if (Directory.Exists(path)) - { - foreach (string pluginFileName in Directory.EnumerateFiles(path, "*.DLL")) - { - try - { - var assembly = System.Reflection.Assembly.Load(FileUtil.ReadAllBytesShared(pluginFileName)); - foreach (var exportedType in assembly.GetExportedTypes()) - { - try - { - object pluginObject = Activator.CreateInstance(exportedType); - if (pluginObject is SubtitleFormat po) - { - _allSubtitleFormats.Insert(1, po); - } - } - catch - { - // ignored - } - } - } - catch - { - // ignored - } - } - } - - return _allSubtitleFormats; - } - } - - protected int _errorCount; - - public abstract string Extension - { - get; - } - - public abstract string Name - { - get; - } - - public virtual bool IsTimeBased => true; - - public bool IsFrameBased => !IsTimeBased; - - public string FriendlyName => $"{Name} ({Extension})"; - - public int ErrorCount => _errorCount; - - public virtual bool IsMine(List lines, string fileName) - { - var subtitle = new Subtitle(); - var oldFrameRate = Configuration.Settings.General.CurrentFrameRate; - LoadSubtitle(subtitle, lines, fileName); - Configuration.Settings.General.CurrentFrameRate = oldFrameRate; - return subtitle.Paragraphs.Count > _errorCount; - } - - public abstract string ToText(Subtitle subtitle, string title); - - public abstract void LoadSubtitle(Subtitle subtitle, List lines, string fileName); - - public bool IsVobSubIndexFile => Extension.Equals(".idx", StringComparison.Ordinal); - - public virtual void RemoveNativeFormatting(Subtitle subtitle, SubtitleFormat newFormat) - { - } - - public virtual List AlternateExtensions => new List(); - - public static int MillisecondsToFrames(double milliseconds) - { - return MillisecondsToFrames(milliseconds, Configuration.Settings.General.CurrentFrameRate); - } - - public static int MillisecondsToFrames(double milliseconds, double frameRate) - { - return (int)Math.Round(milliseconds / (TimeCode.BaseUnit / GetFrameForCalculation(frameRate))); - } - - public static double GetFrameForCalculation(double frameRate) - { - if (Math.Abs(frameRate - 23.976) < 0.01) - { - return 24000.0 / 1001.0; - } - if (Math.Abs(frameRate - 29.97) < 0.01) - { - return 30000.0 / 1001.0; - } - if (Math.Abs(frameRate - 59.94) < 0.01) - { - return 60000.0 / 1001.0; - } - - return frameRate; - } - - public static int MillisecondsToFramesMaxFrameRate(double milliseconds) - { - int frames = (int)Math.Round(milliseconds / (TimeCode.BaseUnit / GetFrameForCalculation(Configuration.Settings.General.CurrentFrameRate))); - if (frames >= Configuration.Settings.General.CurrentFrameRate) - { - frames = (int)(Configuration.Settings.General.CurrentFrameRate - 0.01); - } - - return frames; - } - - public static int FramesToMilliseconds(double frames) - { - return (int)Math.Round(frames * (TimeCode.BaseUnit / GetFrameForCalculation(Configuration.Settings.General.CurrentFrameRate))); - } - - public static int FramesToMillisecondsMax999(double frames) - { - int ms = (int)Math.Round(frames * (TimeCode.BaseUnit / GetFrameForCalculation(Configuration.Settings.General.CurrentFrameRate))); - return Math.Min(ms, 999); - } - - public virtual bool HasStyleSupport => false; - - public bool BatchMode { get; set; } - public double? BatchSourceFrameRate { get; set; } - - public static string ToUtf8XmlString(XmlDocument xml, bool omitXmlDeclaration = false) - { - var settings = new XmlWriterSettings - { - Indent = true, - OmitXmlDeclaration = omitXmlDeclaration, - }; - var result = new StringBuilder(); - - using (var xmlWriter = XmlWriter.Create(result, settings)) - { - xml.Save(xmlWriter); - } - - return result.ToString().Replace(" encoding=\"utf-16\"", " encoding=\"utf-8\"").Trim(); - } - - public virtual bool IsTextBased => true; - - protected static TimeCode DecodeTimeCodeFramesTwoParts(string[] tokens) - { - if (tokens == null) - { - return new TimeCode(); - } - - if (tokens.Length != 2) - { - throw new InvalidOperationException(); - } - - return new TimeCode(0, 0, int.Parse(tokens[0]), FramesToMillisecondsMax999(int.Parse(tokens[1]))); - } - - protected static TimeCode DecodeTimeCodeFramesFourParts(string[] tokens) - { - if (tokens == null) - { - return new TimeCode(); - } - - if (tokens.Length != 4) - { - throw new InvalidOperationException(); - } - - return new TimeCode(int.Parse(tokens[0]), int.Parse(tokens[1]), int.Parse(tokens[2]), FramesToMillisecondsMax999(int.Parse(tokens[3]))); - } - - protected static TimeCode DecodeTimeCodeMsFourParts(string[] tokens) - { - if (tokens == null) - { - return new TimeCode(); - } - - if (tokens.Length != 4) - { - throw new InvalidOperationException(); - } - - return new TimeCode(int.Parse(tokens[0]), int.Parse(tokens[1]), int.Parse(tokens[2]), int.Parse(tokens[3])); - } - - protected static TimeCode DecodeTimeCodeFrames(string timestamp, char[] splitChars) - { - return DecodeTimeCodeFramesFourParts(timestamp.Split(splitChars, StringSplitOptions.RemoveEmptyEntries)); - } - - /// - /// Load subtitle type of 'formats' from file. - /// - /// List of possible formats - /// Name of subtitle file - /// Subtitle to load file into - /// The format of the file, null of not format match found - public static SubtitleFormat LoadSubtitleFromFile(SubtitleFormat[] formats, string fileName, Subtitle subtitle) - { - if (formats == null || formats.Length == 0 || string.IsNullOrEmpty(fileName)) - { - return null; - } - - var list = new List(File.ReadAllLines(fileName, LanguageAutoDetect.GetEncodingFromFile(fileName))); - foreach (var subtitleFormat in formats) - { - if (subtitleFormat.IsMine(list, fileName)) - { - subtitleFormat.LoadSubtitle(subtitle, list, fileName); - return subtitleFormat; - } - } - return null; - } - - /// - /// Load subtitle from a list of lines and a file name (the last can be null). - /// - /// Text lines from subtitle file - /// Optional file name - /// Subtitle, null if format not recognized - public static Subtitle LoadSubtitleFromLines(List lines, string fileName) - { - if (lines == null || lines.Count == 0) - { - return null; - } - - var subtitle = new Subtitle(); - foreach (var subtitleFormat in AllSubtitleFormats) - { - if (subtitleFormat.IsMine(lines, fileName)) - { - subtitleFormat.LoadSubtitle(subtitle, lines, fileName); - return subtitle; - } - } - - return null; - } - - public static SubtitleFormat[] GetBinaryFormats(bool batchMode) - { - return new SubtitleFormat[] - { - new Ebu { BatchMode = batchMode }, - new Pac { BatchMode = batchMode }, - new PacUnicode(), - new Cavena890 { BatchMode = batchMode }, - new Spt(), - new CheetahCaption(), - new CheetahCaptionOld(), - new TSB4(), - new Chk(), - new Ayato(), - new CapMakerPlus(), - new Ultech130(), - new NciCaption(), - new AvidStl(), - new WinCaps32(), - new IsmtDfxp(), - new Cavena890(), - new Spt(), - new Sptx(), - new IaiSub(), - new ELRStudioClosedCaption(), - new CaptionsInc(), - new TimeLineMvt(), - new Cmaft(), - new Pns(), - new PlayCaptionsFreeEditor(), - }; - } - - public static SubtitleFormat[] GetTextOtherFormats() - { - return new SubtitleFormat[] - { - new DlDd(), - new Ted20(), - new Captionate(), - new TimeLineAscii(), - new TimeLineFootageAscii(), - new TimedTextImage(), - new FinalCutProImage(), - new SpuImage(), - new Dost(), - new SeImageHtmlIndex(), - new BdnXml(), - new Wsb(), - new JsonTypeOnlyLoad1(), - new TranscriptiveJson(), - new KaraokeCdgCreatorText(), - new VidIcelandic(), - }; - } - - public static SubtitleFormat FromName(string formatName, SubtitleFormat defaultFormat) - { - string trimmedFormatName = formatName.Trim(); - foreach (var format in AllSubtitleFormats) - { - if (format.Name.Trim().Equals(trimmedFormatName, StringComparison.OrdinalIgnoreCase) || - format.FriendlyName.Trim().Equals(trimmedFormatName, StringComparison.OrdinalIgnoreCase)) - { - return format; - } - } - - return defaultFormat; - } - - public static SubtitleFormat BinaryPersistableFromName(string formatName, bool batchMode) - { - string trimmedFormatName = formatName.Trim(); - foreach (var format in GetBinaryFormats(batchMode)) - { - if (format is IBinaryPersistableSubtitle && - format.Name.Trim().Equals(trimmedFormatName, StringComparison.OrdinalIgnoreCase) || - format.FriendlyName.Trim().Equals(trimmedFormatName, StringComparison.OrdinalIgnoreCase)) - { - return format; - } - } - - return null; - } - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Core.Interfaces; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public abstract class SubtitleFormat + { + private static IList _allSubtitleFormats; + + protected static readonly char[] SplitCharColon = { ':' }; + + /// + /// Text formats supported by Subtitle Edit + /// + public static IEnumerable AllSubtitleFormats + { + get + { + if (_allSubtitleFormats != null) + { + return _allSubtitleFormats; + } + + _allSubtitleFormats = new List + { + new SubRip(), + new AbcIViewer(), + new AdobeAfterEffectsFTME(), + new AdobeEncore(), + new AdobeEncoreLineTabNewLine(), + new AdobeEncoreTabs(), + new AdobeEncoreWithLineNumbers(), + new AdobeEncoreWithLineNumbersNtsc(), + new AdvancedSubStationAlpha(), + new AQTitle(), + new AvidCaption(), + new AvidDvd(), + new AwsTranscribeJson(), + new BelleNuitSubtitler(), + new Bilibili(), + new Cappella(), + new CaptionAssistant(), + new Captionate(), + new CaptionateMs(), + new CaraokeXml(), + new Csv(), + new Csv2(), + new Csv3(), + new Csv4(), + new Csv5(), + new CsvNuendo(), + new DCinemaInterop(), + new DCinemaSmpte2007(), + new DCinemaSmpte2010(), + new DCinemaSmpte2014(), + new DigiBeta(), + new DvdStudioPro(), + new DvdStudioProSpaceOne(), + new DvdStudioProSpaceOneSemicolon(), + new DvdStudioProSpace(), + new DvdSubtitle(), + new DvdSubtitleSystem(), + new DvSubtitle(), + new Ebu(), + new Edl(), + new Eeg708(), + new ElrPrint(), + new ESubXf(), + new F4Text(), + new EZTSubtitlesProject(), + new F4Rtf(), + new F4Xml(), + new FabSubtitler(), + new FilmEditXml(), + new FinalCutProXml(), + new FinalCutProXXml(), + new FinalCutProXmlGap(), + new FinalCutProXCM(), + new FinalCutProXml13(), + new FinalCutProXml14(), + new FinalCutProXml14Text(), + new FinalCutProXml15(), + new FinalCutProXml16(), + new FinalCutProXml17(), + new FinalCutProXml18(), + new FinalCutProTestXml(), + new FinalCutProTest2Xml(), + new FlashXml(), + new FLVCoreCuePoints(), + new Footage(), + new GooglePlayJson(), + new GpacTtxt(), + new Gremots(), + new HollyStarJson(), + new ImageLogicAutocaption(), + new InqScribe(), + new IssXml(), + new ItunesTimedText(), + new JacoSub(), + new JsonTed(), + new Json(), + new JsonType2(), + new JsonType3(), + new JsonType4(), + new JsonType5(), + new JsonType6(), + new JsonType7(), + new JsonType8(), + new JsonType8b(), + new JsonType9(), + new JsonType10(), + new JsonType11(), + new JsonType12(), + new JsonType13(), + new JsonType14(), + new JsonType15(), + new JsonType16(), + new JsonType17(), + new JsonType18(), + new KanopyHtml(), + new LambdaCap(), + new Lrc(), + new MacSub(), + new MediaTransData(), + new MicroDvd(), + new MidwayInscriberCGX(), + new MPlayer2(), + new MsOfficeWorkbook(), + new NciTimedRollUpCaptions(), + new NetflixImsc11Japanese(), + new NetflixTimedText(), + new OgmChapters(), + new OpenDvt(), + new Oresme(), + new OresmeDocXDocument(), + new OtterAi(), + new Pe2(), + new PhoenixSubtitle(), + new PinnacleImpression(), + new PListCaption(), + new ProjectionSubtitleList(), + new QubeMasterImport(), + new QuickTimeText(), + new RealTime(), + new RhozetHarmonic(), + new Rtf1(), + new Rtf2(), + new Sami(), + new SamiAvDicPlayer(), + new SamiModern(), + new SamiYouTube(), + new Scenarist(), + new ScenaristClosedCaptions(), + new ScenaristClosedCaptionsDropFrame(), + new SmilTimesheetData(), + new SmpteTt2052(), + new SoftNiSub(), + new SoftNicolonSub(), + new SonyDVDArchitect(), + new SonyDVDArchitectExplicitDuration(), + new SonyDVDArchitectLineAndDuration(), + new SonyDVDArchitectLineDurationLength(), + new SonyDVDArchitectTabs(), + new SonyDVDArchitectWithLineNumbers(), + new Speechmatics(), + new Spruce(), + new SpruceWithSpace(), + new StructuredTitles(), + new SubStationAlpha(), + new SubtitleEditorProject(), + new SubUrbia(), + new SubViewer10(), + new SubViewer20(), + new SwiftInterchange2(), + new SwiftText(), + new SwiftTextLineNumber(), + new SwiftTextLineNOAndDur(), + new Tek(), + new TimeXml(), + new TimeXml2(), + new TimedText10(), + new TimedText200604(), + new TimedText200604CData(), + new TimedText200604Ooyala(), + new TimedText(), + new TitleExchangePro(), + new Titra(), + new TmpegEncText(), + new TmpegEncAW5(), + new TmpegEncXml(), + new TMPlayer(), + new TranscriberXml(), + new Tmx14(), + new TurboTitler(), + new TwentyThreeJson(), + new TwentyThreeJsonEmbed(), + new TwentyThreeJsonEmbedWebSrt(), + new UniversalSubtitleFormat(), + new UTSubtitleXml(), + new Utx(), + new UtxFrames(), + new UleadSubtitleFormat(), + new VocapiaSplit(), + new WebVTT(), + new WebVTTFileWithLineNumber(), + new Xif(), + new Xmp(), + new YouTubeAnnotations(), + new YouTubeSbv(), + new YouTubeTranscript(), + new YouTubeTranscriptOneLine(), + new ZeroG(), + // new Idx(), + new UnknownSubtitle1(), + new UnknownSubtitle2(), + new UnknownSubtitle3(), + new UnknownSubtitle4(), + new UnknownSubtitle5(), + new UnknownSubtitle6(), + new UnknownSubtitle7(), + new UnknownSubtitle8(), + new UnknownSubtitle9(), + new UnknownSubtitle10(), + new UnknownSubtitle11(), + new UnknownSubtitle12(), + new UnknownSubtitle13(), + new UnknownSubtitle14(), + new UnknownSubtitle15(), + new UnknownSubtitle16(), + new UnknownSubtitle17(), + new UnknownSubtitle18(), + new UnknownSubtitle19(), + new UnknownSubtitle20(), + new UnknownSubtitle21(), + new UnknownSubtitle22(), + new UnknownSubtitle23(), + new UnknownSubtitle24(), + new UnknownSubtitle25(), + new UnknownSubtitle26(), + new UnknownSubtitle27(), + new UnknownSubtitle28(), + new UnknownSubtitle29(), + new UnknownSubtitle30(), + new UnknownSubtitle31(), + new UnknownSubtitle32(), + new UnknownSubtitle33(), + new UnknownSubtitle34(), + new UnknownSubtitle35(), + new UnknownSubtitle36(), + new UnknownSubtitle37(), + new UnknownSubtitle38(), + new UnknownSubtitle39(), + new UnknownSubtitle40(), + new UnknownSubtitle41(), + new UnknownSubtitle42(), + new UnknownSubtitle43(), + new UnknownSubtitle44(), + new UnknownSubtitle45(), + new UnknownSubtitle46(), + new UnknownSubtitle47(), + new UnknownSubtitle48(), + new UnknownSubtitle49(), + new UnknownSubtitle50(), + new UnknownSubtitle51(), + new UnknownSubtitle52(), + new UnknownSubtitle53(), + new UnknownSubtitle54(), + new UnknownSubtitle55(), + new UnknownSubtitle56(), + new UnknownSubtitle57(), + new UnknownSubtitle58(), + new UnknownSubtitle59(), + new UnknownSubtitle60(), + new UnknownSubtitle61(), + new UnknownSubtitle62(), + new UnknownSubtitle63(), + new UnknownSubtitle64(), + new UnknownSubtitle65(), + new UnknownSubtitle66(), + new UnknownSubtitle67(), + new UnknownSubtitle68(), + new UnknownSubtitle69(), + new UnknownSubtitle70(), + new UnknownSubtitle71(), + new UnknownSubtitle72(), + new UnknownSubtitle73(), + new UnknownSubtitle74(), + new UnknownSubtitle75(), + new UnknownSubtitle76(), + new UnknownSubtitle77(), + new UnknownSubtitle78(), + new UnknownSubtitle79(), + new UnknownSubtitle80(), + new UnknownSubtitle81(), + new UnknownSubtitle82(), + new UnknownSubtitle83(), + new UnknownSubtitle84(), + new UnknownSubtitle85(), + new UnknownSubtitle86(), + new UnknownSubtitle87(), + new UnknownSubtitle88(), + new UnknownSubtitle89(), + new UnknownSubtitle90(), + new UnknownSubtitle91(), + new UnknownSubtitle92(), + new UnknownSubtitle93(), + new UnknownSubtitle94(), + new UnknownSubtitle95(), + new UnknownSubtitle96(), + new UnknownSubtitle97(), + new UnknownSubtitle98(), + new UnknownSubtitle99(), + new UnknownSubtitle100(), + new UnknownSubtitle101(), + }; + + string path = Configuration.PluginsDirectory; + if (Directory.Exists(path)) + { + foreach (string pluginFileName in Directory.EnumerateFiles(path, "*.DLL")) + { + try + { + var assembly = System.Reflection.Assembly.Load(FileUtil.ReadAllBytesShared(pluginFileName)); + foreach (var exportedType in assembly.GetExportedTypes()) + { + try + { + object pluginObject = Activator.CreateInstance(exportedType); + if (pluginObject is SubtitleFormat po) + { + _allSubtitleFormats.Insert(1, po); + } + } + catch + { + // ignored + } + } + } + catch + { + // ignored + } + } + } + + return _allSubtitleFormats; + } + } + + protected int _errorCount; + + public abstract string Extension + { + get; + } + + public abstract string Name + { + get; + } + + public virtual bool IsTimeBased => true; + + public bool IsFrameBased => !IsTimeBased; + + public string FriendlyName => $"{Name} ({Extension})"; + + public int ErrorCount => _errorCount; + + public virtual bool IsMine(List lines, string fileName) + { + var subtitle = new Subtitle(); + var oldFrameRate = Configuration.Settings.General.CurrentFrameRate; + LoadSubtitle(subtitle, lines, fileName); + Configuration.Settings.General.CurrentFrameRate = oldFrameRate; + return subtitle.Paragraphs.Count > _errorCount; + } + + public abstract string ToText(Subtitle subtitle, string title); + + public abstract void LoadSubtitle(Subtitle subtitle, List lines, string fileName); + + public bool IsVobSubIndexFile => Extension.Equals(".idx", StringComparison.Ordinal); + + public virtual void RemoveNativeFormatting(Subtitle subtitle, SubtitleFormat newFormat) + { + } + + public virtual List AlternateExtensions => new List(); + + public static int MillisecondsToFrames(double milliseconds) + { + return MillisecondsToFrames(milliseconds, Configuration.Settings.General.CurrentFrameRate); + } + + public static int MillisecondsToFrames(double milliseconds, double frameRate) + { + return (int)Math.Round(milliseconds / (TimeCode.BaseUnit / GetFrameForCalculation(frameRate))); + } + + public static double GetFrameForCalculation(double frameRate) + { + if (Math.Abs(frameRate - 23.976) < 0.01) + { + return 24000.0 / 1001.0; + } + if (Math.Abs(frameRate - 29.97) < 0.01) + { + return 30000.0 / 1001.0; + } + if (Math.Abs(frameRate - 59.94) < 0.01) + { + return 60000.0 / 1001.0; + } + + return frameRate; + } + + public static int MillisecondsToFramesMaxFrameRate(double milliseconds) + { + int frames = (int)Math.Round(milliseconds / (TimeCode.BaseUnit / GetFrameForCalculation(Configuration.Settings.General.CurrentFrameRate))); + if (frames >= Configuration.Settings.General.CurrentFrameRate) + { + frames = (int)(Configuration.Settings.General.CurrentFrameRate - 0.01); + } + + return frames; + } + + public static int FramesToMilliseconds(double frames) + { + return (int)Math.Round(frames * (TimeCode.BaseUnit / GetFrameForCalculation(Configuration.Settings.General.CurrentFrameRate))); + } + + public static int FramesToMillisecondsMax999(double frames) + { + int ms = (int)Math.Round(frames * (TimeCode.BaseUnit / GetFrameForCalculation(Configuration.Settings.General.CurrentFrameRate))); + return Math.Min(ms, 999); + } + + public virtual bool HasStyleSupport => false; + + public bool BatchMode { get; set; } + public double? BatchSourceFrameRate { get; set; } + + public static string ToUtf8XmlString(XmlDocument xml, bool omitXmlDeclaration = false) + { + var settings = new XmlWriterSettings + { + Indent = true, + OmitXmlDeclaration = omitXmlDeclaration, + }; + var result = new StringBuilder(); + + using (var xmlWriter = XmlWriter.Create(result, settings)) + { + xml.Save(xmlWriter); + } + + return result.ToString().Replace(" encoding=\"utf-16\"", " encoding=\"utf-8\"").Trim(); + } + + public virtual bool IsTextBased => true; + + protected static TimeCode DecodeTimeCodeFramesTwoParts(string[] tokens) + { + if (tokens == null) + { + return new TimeCode(); + } + + if (tokens.Length != 2) + { + throw new InvalidOperationException(); + } + + return new TimeCode(0, 0, int.Parse(tokens[0]), FramesToMillisecondsMax999(int.Parse(tokens[1]))); + } + + protected static TimeCode DecodeTimeCodeFramesFourParts(string[] tokens) + { + if (tokens == null) + { + return new TimeCode(); + } + + if (tokens.Length != 4) + { + throw new InvalidOperationException(); + } + + return new TimeCode(int.Parse(tokens[0]), int.Parse(tokens[1]), int.Parse(tokens[2]), FramesToMillisecondsMax999(int.Parse(tokens[3]))); + } + + protected static TimeCode DecodeTimeCodeMsFourParts(string[] tokens) + { + if (tokens == null) + { + return new TimeCode(); + } + + if (tokens.Length != 4) + { + throw new InvalidOperationException(); + } + + return new TimeCode(int.Parse(tokens[0]), int.Parse(tokens[1]), int.Parse(tokens[2]), int.Parse(tokens[3])); + } + + protected static TimeCode DecodeTimeCodeFrames(string timestamp, char[] splitChars) + { + return DecodeTimeCodeFramesFourParts(timestamp.Split(splitChars, StringSplitOptions.RemoveEmptyEntries)); + } + + /// + /// Load subtitle type of 'formats' from file. + /// + /// List of possible formats + /// Name of subtitle file + /// Subtitle to load file into + /// The format of the file, null of not format match found + public static SubtitleFormat LoadSubtitleFromFile(SubtitleFormat[] formats, string fileName, Subtitle subtitle) + { + if (formats == null || formats.Length == 0 || string.IsNullOrEmpty(fileName)) + { + return null; + } + + var list = new List(File.ReadAllLines(fileName, LanguageAutoDetect.GetEncodingFromFile(fileName))); + foreach (var subtitleFormat in formats) + { + if (subtitleFormat.IsMine(list, fileName)) + { + subtitleFormat.LoadSubtitle(subtitle, list, fileName); + return subtitleFormat; + } + } + return null; + } + + /// + /// Load subtitle from a list of lines and a file name (the last can be null). + /// + /// Text lines from subtitle file + /// Optional file name + /// Subtitle, null if format not recognized + public static Subtitle LoadSubtitleFromLines(List lines, string fileName) + { + if (lines == null || lines.Count == 0) + { + return null; + } + + var subtitle = new Subtitle(); + foreach (var subtitleFormat in AllSubtitleFormats) + { + if (subtitleFormat.IsMine(lines, fileName)) + { + subtitleFormat.LoadSubtitle(subtitle, lines, fileName); + return subtitle; + } + } + + return null; + } + + public static SubtitleFormat[] GetBinaryFormats(bool batchMode) + { + return new SubtitleFormat[] + { + new Ebu { BatchMode = batchMode }, + new Pac { BatchMode = batchMode }, + new PacUnicode(), + new Cavena890 { BatchMode = batchMode }, + new Spt(), + new CheetahCaption(), + new CheetahCaptionOld(), + new TSB4(), + new Chk(), + new Ayato(), + new CapMakerPlus(), + new Ultech130(), + new NciCaption(), + new AvidStl(), + new WinCaps32(), + new IsmtDfxp(), + new Cavena890(), + new Spt(), + new Sptx(), + new IaiSub(), + new ELRStudioClosedCaption(), + new CaptionsInc(), + new TimeLineMvt(), + new Cmaft(), + new Pns(), + new PlayCaptionsFreeEditor(), + }; + } + + public static SubtitleFormat[] GetTextOtherFormats() + { + return new SubtitleFormat[] + { + new DlDd(), + new Ted20(), + new Captionate(), + new TimeLineAscii(), + new TimeLineFootageAscii(), + new TimedTextImage(), + new FinalCutProImage(), + new SpuImage(), + new Dost(), + new SeImageHtmlIndex(), + new BdnXml(), + new Wsb(), + new JsonTypeOnlyLoad1(), + new TranscriptiveJson(), + new KaraokeCdgCreatorText(), + new VidIcelandic(), + }; + } + + public static SubtitleFormat FromName(string formatName, SubtitleFormat defaultFormat) + { + string trimmedFormatName = formatName.Trim(); + foreach (var format in AllSubtitleFormats) + { + if (format.Name.Trim().Equals(trimmedFormatName, StringComparison.OrdinalIgnoreCase) || + format.FriendlyName.Trim().Equals(trimmedFormatName, StringComparison.OrdinalIgnoreCase)) + { + return format; + } + } + + return defaultFormat; + } + + public static SubtitleFormat BinaryPersistableFromName(string formatName, bool batchMode) + { + string trimmedFormatName = formatName.Trim(); + foreach (var format in GetBinaryFormats(batchMode)) + { + if (format is IBinaryPersistableSubtitle && + format.Name.Trim().Equals(trimmedFormatName, StringComparison.OrdinalIgnoreCase) || + format.FriendlyName.Trim().Equals(trimmedFormatName, StringComparison.OrdinalIgnoreCase)) + { + return format; + } + } + + return null; + } + } +} diff --git a/libse/SubtitleFormats/SwiftInterchange2.cs b/src/libse/SubtitleFormats/SwiftInterchange2.cs similarity index 97% rename from libse/SubtitleFormats/SwiftInterchange2.cs rename to src/libse/SubtitleFormats/SwiftInterchange2.cs index 9e97cb61e..0fbd19f7e 100644 --- a/libse/SubtitleFormats/SwiftInterchange2.cs +++ b/src/libse/SubtitleFormats/SwiftInterchange2.cs @@ -1,226 +1,226 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SwiftInterchange2 : SubtitleFormat - { - private const string ItalicPrefix = ""; - private string _fileName; - - public override string Extension => ".sif"; - - public override string Name => "Swift Interchange File V2"; - - public override bool IsMine(List lines, string fileName) - { - if (lines.Count > 0 && lines[0] != null && lines[0].StartsWith("{\\rtf1")) - { - return false; - } - - _fileName = fileName; - return base.IsMine(lines, fileName); - } - - private static string GetOriginatingSwift(Subtitle subtitle) - { - string lang = "English (USA)"; - string languageCode = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); - if (languageCode == "nl") - { - lang = "Dutch (Netherlands)"; - } - else if (languageCode == "de") - { - lang = "German (German)"; - } - return "Open 25 " + lang; - // examples: - // Line21 30 DROP English (USA) - // Open 25 German (German) - // Open 25 Dutch (Netherlands) - //TODO: Frame rate - } - - private string GetVideoFileName(string title) - { - string fileNameNoExt = null; - if (_fileName != null) - { - fileNameNoExt = _fileName.Substring(0, _fileName.Length - Path.GetExtension(_fileName).Length); - } - foreach (var ext in Utilities.VideoFileExtensions) - { - if (!string.IsNullOrEmpty(fileNameNoExt) && File.Exists(Path.Combine(fileNameNoExt, ext))) - { - return Path.Combine(fileNameNoExt, ext); - } - if (!string.IsNullOrEmpty(title) && File.Exists(Path.Combine(title, ext))) - { - return Path.Combine(title, ext); - } - } - if (string.IsNullOrEmpty(title)) - { - return "Unknown.mpg"; - } - return title + ".mpg"; - } - - public override string ToText(Subtitle subtitle, string title) - { - string date = $"{DateTime.Now.Day:00}/{DateTime.Now.Month:00}/{DateTime.Now.Year}"; - const string header = @"# SWIFT INTERCHANGE FILE V2 -# DO NOT EDIT LINES BEGINNING WITH '#' SIGN -# Originating Swift: [ORIGINATING_SWIFT] -# VIDEO CLIP : [VIDEO_FILE] -# BROADCAST DATE : [DATE] -# REVISION DATE : [DATE] -# CREATION DATE : [DATE] -# COUNTRY OF ORIGIN : ENG -# EPISODE NUMBER : 0 -# DEADLINE DATE : [DATE] -# AUTO TX : false -# CURRENT STYLE : None -# STYLE DATE : None -# STYLE Time : None"; - var sb = new StringBuilder(); - var videoFileName = GetVideoFileName(title); - sb.AppendLine(header.Replace("[DATE]", date).Replace("[VIDEO_FILE]", videoFileName).Replace("[ORIGINATING_SWIFT]", GetOriginatingSwift(subtitle))); - sb.AppendLine(); - sb.AppendLine(); - const string paragraphWriteFormat = @"# SUBTITLE {3} -# TIMEIN {0} -# DURATION {1} AUTO -# TIMEOUT {2} -# START ROW BOTTOM -# ALIGN CENTRE JUSTIFY CENTER"; - int count = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - string startTime = $"{p.StartTime.Hours:00}:{p.StartTime.Minutes:00}:{p.StartTime.Seconds:00}:{MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds):00}"; - string endTime = $"{p.EndTime.Hours:00}:{p.EndTime.Minutes:00}:{p.EndTime.Seconds:00}:{MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds):00}"; - string duration = $"{p.Duration.Seconds:00}:{MillisecondsToFramesMaxFrameRate(p.Duration.Milliseconds):00}"; - sb.AppendLine(string.Format(paragraphWriteFormat, startTime, duration, endTime, count)); - string text = HtmlUtil.RemoveHtmlTags(p.Text); - if (p.Text.StartsWith("", StringComparison.Ordinal) && p.Text.EndsWith("", StringComparison.Ordinal)) - { - text = ItalicPrefix + text; - } - var arr = text.SplitToLines(); - for (int rowNo = 0; rowNo < arr.Count; rowNo++) - { - if (rowNo == arr.Count - 1) - { - sb.AppendLine("# ROW " + rowNo); - } - else - { - sb.AppendLine("# ROW " + rowNo + " RETURN"); - } - sb.AppendLine(arr[rowNo]); - } - sb.AppendLine(); - count++; - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - Paragraph p = null; - foreach (string line in lines) - { - if (line.StartsWith("# SUBTITLE", StringComparison.Ordinal)) - { - if (p != null) - { - subtitle.Paragraphs.Add(p); - } - - p = new Paragraph(); - } - else if (p != null && line.StartsWith("# TIMEIN", StringComparison.Ordinal)) - { - string timeCode = line.Remove(0, 8).Trim(); - if (timeCode != "--:--:--:--" && !GetTimeCode(p.StartTime, timeCode)) - { - _errorCount++; - } - } - else if (p != null && line.StartsWith("# DURATION", StringComparison.Ordinal)) - { - // # DURATION 01:17 AUTO - string timeCode = line.Remove(0, 10).Replace("AUTO", string.Empty).Trim(); - if (timeCode != "--:--") - { - var arr = timeCode.Split(':', ' '); - if (arr.Length > 1) - { - if (int.TryParse(arr[0], out var sec) && int.TryParse(arr[1], out var frame)) - { - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + FramesToMillisecondsMax999(frame); - p.EndTime.TotalSeconds += sec; - } - } - } - } - else if (p != null && line.StartsWith("# TIMEOUT", StringComparison.Ordinal)) - { - string timeCode = line.Remove(0, 9).Trim(); - if (timeCode != "--:--:--:--" && !GetTimeCode(p.EndTime, timeCode)) - { - _errorCount++; - } - } - else if (p != null && !line.StartsWith('#')) - { - if (p.Text.Length > 500) - { - _errorCount += 10; - return; - } - p.Text = (p.Text + Environment.NewLine + line).Trim(); - } - } - if (p != null) - { - subtitle.Paragraphs.Add(p); - } - - subtitle.RemoveEmptyLines(); - subtitle.Renumber(); - - foreach (var paragraph in subtitle.Paragraphs) - { - if (paragraph.Text.StartsWith(ItalicPrefix, StringComparison.Ordinal)) - { - paragraph.Text = "" + paragraph.Text.Remove(0, ItalicPrefix.Length).TrimStart() + ""; - } - } - } - - private static bool GetTimeCode(TimeCode timeCode, string timeString) - { - try - { - string[] timeParts = timeString.Split(':', '.'); - timeCode.Hours = int.Parse(timeParts[0]); - timeCode.Minutes = int.Parse(timeParts[1]); - timeCode.Seconds = int.Parse(timeParts[2]); - timeCode.Milliseconds = FramesToMillisecondsMax999(int.Parse(timeParts[3])); - return true; - } - catch - { - return false; - } - } - - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SwiftInterchange2 : SubtitleFormat + { + private const string ItalicPrefix = ""; + private string _fileName; + + public override string Extension => ".sif"; + + public override string Name => "Swift Interchange File V2"; + + public override bool IsMine(List lines, string fileName) + { + if (lines.Count > 0 && lines[0] != null && lines[0].StartsWith("{\\rtf1")) + { + return false; + } + + _fileName = fileName; + return base.IsMine(lines, fileName); + } + + private static string GetOriginatingSwift(Subtitle subtitle) + { + string lang = "English (USA)"; + string languageCode = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); + if (languageCode == "nl") + { + lang = "Dutch (Netherlands)"; + } + else if (languageCode == "de") + { + lang = "German (German)"; + } + return "Open 25 " + lang; + // examples: + // Line21 30 DROP English (USA) + // Open 25 German (German) + // Open 25 Dutch (Netherlands) + //TODO: Frame rate + } + + private string GetVideoFileName(string title) + { + string fileNameNoExt = null; + if (_fileName != null) + { + fileNameNoExt = _fileName.Substring(0, _fileName.Length - Path.GetExtension(_fileName).Length); + } + foreach (var ext in Utilities.VideoFileExtensions) + { + if (!string.IsNullOrEmpty(fileNameNoExt) && File.Exists(Path.Combine(fileNameNoExt, ext))) + { + return Path.Combine(fileNameNoExt, ext); + } + if (!string.IsNullOrEmpty(title) && File.Exists(Path.Combine(title, ext))) + { + return Path.Combine(title, ext); + } + } + if (string.IsNullOrEmpty(title)) + { + return "Unknown.mpg"; + } + return title + ".mpg"; + } + + public override string ToText(Subtitle subtitle, string title) + { + string date = $"{DateTime.Now.Day:00}/{DateTime.Now.Month:00}/{DateTime.Now.Year}"; + const string header = @"# SWIFT INTERCHANGE FILE V2 +# DO NOT EDIT LINES BEGINNING WITH '#' SIGN +# Originating Swift: [ORIGINATING_SWIFT] +# VIDEO CLIP : [VIDEO_FILE] +# BROADCAST DATE : [DATE] +# REVISION DATE : [DATE] +# CREATION DATE : [DATE] +# COUNTRY OF ORIGIN : ENG +# EPISODE NUMBER : 0 +# DEADLINE DATE : [DATE] +# AUTO TX : false +# CURRENT STYLE : None +# STYLE DATE : None +# STYLE Time : None"; + var sb = new StringBuilder(); + var videoFileName = GetVideoFileName(title); + sb.AppendLine(header.Replace("[DATE]", date).Replace("[VIDEO_FILE]", videoFileName).Replace("[ORIGINATING_SWIFT]", GetOriginatingSwift(subtitle))); + sb.AppendLine(); + sb.AppendLine(); + const string paragraphWriteFormat = @"# SUBTITLE {3} +# TIMEIN {0} +# DURATION {1} AUTO +# TIMEOUT {2} +# START ROW BOTTOM +# ALIGN CENTRE JUSTIFY CENTER"; + int count = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + string startTime = $"{p.StartTime.Hours:00}:{p.StartTime.Minutes:00}:{p.StartTime.Seconds:00}:{MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds):00}"; + string endTime = $"{p.EndTime.Hours:00}:{p.EndTime.Minutes:00}:{p.EndTime.Seconds:00}:{MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds):00}"; + string duration = $"{p.Duration.Seconds:00}:{MillisecondsToFramesMaxFrameRate(p.Duration.Milliseconds):00}"; + sb.AppendLine(string.Format(paragraphWriteFormat, startTime, duration, endTime, count)); + string text = HtmlUtil.RemoveHtmlTags(p.Text); + if (p.Text.StartsWith("", StringComparison.Ordinal) && p.Text.EndsWith("", StringComparison.Ordinal)) + { + text = ItalicPrefix + text; + } + var arr = text.SplitToLines(); + for (int rowNo = 0; rowNo < arr.Count; rowNo++) + { + if (rowNo == arr.Count - 1) + { + sb.AppendLine("# ROW " + rowNo); + } + else + { + sb.AppendLine("# ROW " + rowNo + " RETURN"); + } + sb.AppendLine(arr[rowNo]); + } + sb.AppendLine(); + count++; + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + Paragraph p = null; + foreach (string line in lines) + { + if (line.StartsWith("# SUBTITLE", StringComparison.Ordinal)) + { + if (p != null) + { + subtitle.Paragraphs.Add(p); + } + + p = new Paragraph(); + } + else if (p != null && line.StartsWith("# TIMEIN", StringComparison.Ordinal)) + { + string timeCode = line.Remove(0, 8).Trim(); + if (timeCode != "--:--:--:--" && !GetTimeCode(p.StartTime, timeCode)) + { + _errorCount++; + } + } + else if (p != null && line.StartsWith("# DURATION", StringComparison.Ordinal)) + { + // # DURATION 01:17 AUTO + string timeCode = line.Remove(0, 10).Replace("AUTO", string.Empty).Trim(); + if (timeCode != "--:--") + { + var arr = timeCode.Split(':', ' '); + if (arr.Length > 1) + { + if (int.TryParse(arr[0], out var sec) && int.TryParse(arr[1], out var frame)) + { + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + FramesToMillisecondsMax999(frame); + p.EndTime.TotalSeconds += sec; + } + } + } + } + else if (p != null && line.StartsWith("# TIMEOUT", StringComparison.Ordinal)) + { + string timeCode = line.Remove(0, 9).Trim(); + if (timeCode != "--:--:--:--" && !GetTimeCode(p.EndTime, timeCode)) + { + _errorCount++; + } + } + else if (p != null && !line.StartsWith('#')) + { + if (p.Text.Length > 500) + { + _errorCount += 10; + return; + } + p.Text = (p.Text + Environment.NewLine + line).Trim(); + } + } + if (p != null) + { + subtitle.Paragraphs.Add(p); + } + + subtitle.RemoveEmptyLines(); + subtitle.Renumber(); + + foreach (var paragraph in subtitle.Paragraphs) + { + if (paragraph.Text.StartsWith(ItalicPrefix, StringComparison.Ordinal)) + { + paragraph.Text = "" + paragraph.Text.Remove(0, ItalicPrefix.Length).TrimStart() + ""; + } + } + } + + private static bool GetTimeCode(TimeCode timeCode, string timeString) + { + try + { + string[] timeParts = timeString.Split(':', '.'); + timeCode.Hours = int.Parse(timeParts[0]); + timeCode.Minutes = int.Parse(timeParts[1]); + timeCode.Seconds = int.Parse(timeParts[2]); + timeCode.Milliseconds = FramesToMillisecondsMax999(int.Parse(timeParts[3])); + return true; + } + catch + { + return false; + } + } + + } +} diff --git a/libse/SubtitleFormats/SwiftText.cs b/src/libse/SubtitleFormats/SwiftText.cs similarity index 97% rename from libse/SubtitleFormats/SwiftText.cs rename to src/libse/SubtitleFormats/SwiftText.cs index 36986935f..4f914cbc2 100644 --- a/libse/SubtitleFormats/SwiftText.cs +++ b/src/libse/SubtitleFormats/SwiftText.cs @@ -1,198 +1,198 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SwiftText : SubtitleFormat - { - private enum ExpectingLine - { - TimeCodes, - Text - } - - private Paragraph _paragraph; - private StringBuilder _text = new StringBuilder(); - private ExpectingLine _expecting = ExpectingLine.TimeCodes; - - private static readonly Regex RegexTimeCodes = new Regex(@"^TIMEIN:\s*[0123456789-]+:[0123456789-]+:[0123456789-]+:[0123456789-]+\s*DURATION:\s*[0123456789-]+:[0123456789-]+\s*TIMEOUT:\s*[0123456789-]+:[0123456789-]+:[0123456789-]+:[0123456789-]+$", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "Swift text"; - - public override bool IsMine(List lines, string fileName) - { - if (lines == null || lines.Count > 2 && !string.IsNullOrEmpty(lines[0]) && lines[0].Contains("{QTtext}")) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - //TIMEIN: 01:00:01:09 DURATION: 01:20 TIMEOUT: --:--:--:-- - //Broadcasting - //from an undisclosed location... - - //TIMEIN: 01:00:04:12 DURATION: 04:25 TIMEOUT: 01:00:09:07 - - const string paragraphWriteFormat = "TIMEIN: {0}\tDURATION: {1}\tTIMEOUT: {2}\r\n{3}\r\n"; - - var sb = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - // to avoid rounding errors in duration - var startFrame = MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds); - var endFrame = MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds); - var durationCalc = new Paragraph( - new TimeCode(p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, FramesToMillisecondsMax999(startFrame)), - new TimeCode(p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, FramesToMillisecondsMax999(endFrame)), - string.Empty); - - string startTime = $"{p.StartTime.Hours:00}:{p.StartTime.Minutes:00}:{p.StartTime.Seconds:00}:{startFrame:00}"; - string timeOut = $"{p.EndTime.Hours:00}:{p.EndTime.Minutes:00}:{p.EndTime.Seconds:00}:{endFrame:00}"; - string timeDuration = $"{durationCalc.Duration.Seconds:00}:{MillisecondsToFramesMaxFrameRate(durationCalc.Duration.Milliseconds):00}"; - sb.AppendLine(string.Format(paragraphWriteFormat, startTime, timeDuration, timeOut, p.Text)); - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _paragraph = new Paragraph(); - _expecting = ExpectingLine.TimeCodes; - _errorCount = 0; - - subtitle.Paragraphs.Clear(); - foreach (string line in lines) - { - ReadLine(subtitle, line); - if (_text.Length > 1000) - { - return; - } - } - if (_text != null && _text.ToString().TrimStart().Length > 0) - { - _paragraph.Text = _text.ToString().Trim(); - subtitle.Paragraphs.Add(_paragraph); - } - - subtitle.Renumber(); - } - - private void ReadLine(Subtitle subtitle, string line) - { - switch (_expecting) - { - case ExpectingLine.TimeCodes: - if (TryReadTimeCodesLine(line, _paragraph)) - { - _text = new StringBuilder(); - _expecting = ExpectingLine.Text; - } - else if (!string.IsNullOrWhiteSpace(line)) - { - _errorCount++; - _expecting = ExpectingLine.Text; // lets go to next paragraph - } - break; - case ExpectingLine.Text: - if (!string.IsNullOrWhiteSpace(line)) - { - _text.AppendLine(line.TrimEnd()); - } - else if (_paragraph != null && _paragraph.EndTime.TotalMilliseconds > 0) - { - _paragraph.Text = _text.ToString().Trim(); - subtitle.Paragraphs.Add(_paragraph); - _paragraph = new Paragraph(); - _expecting = ExpectingLine.TimeCodes; - } - else - { - _errorCount++; - } - break; - } - } - - private static bool TryReadTimeCodesLine(string line, Paragraph paragraph) - { - line = line.Trim(); - if (line.StartsWith("TIMEIN:", StringComparison.Ordinal) && RegexTimeCodes.IsMatch(line)) - { - //TIMEIN: 01:00:04:12 DURATION: 04:25 TIMEOUT: 01:00:09:07 - string s = line.Replace("TIMEIN:", string.Empty).Replace("DURATION", string.Empty).Replace("TIMEOUT", string.Empty).RemoveChar(' ').Replace("\t", string.Empty); - string[] parts = s.Split(':'); - try - { - int startHours = int.Parse(parts[0]); - int startMinutes = int.Parse(parts[1]); - int startSeconds = int.Parse(parts[2]); - int startMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[3])); - - int durationSeconds = 0; - if (parts[4] != "-") - { - durationSeconds = int.Parse(parts[4]); - } - - int durationMilliseconds = 0; - if (parts[5] != "--") - { - durationMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[5])); - } - - int endHours = 0; - if (parts[6] != "--") - { - endHours = int.Parse(parts[6]); - } - - int endMinutes = 0; - if (parts[7] != "--") - { - endMinutes = int.Parse(parts[7]); - } - - int endSeconds = 0; - if (parts[8] != "--") - { - endSeconds = int.Parse(parts[8]); - } - - int endMilliseconds = 0; - if (parts[9] != "--") - { - endMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[9])); - } - - paragraph.StartTime = new TimeCode(startHours, startMinutes, startSeconds, startMilliseconds); - - if (durationSeconds > 0 || durationMilliseconds > 0) - { - paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + (durationSeconds * 1000 + durationMilliseconds); - } - else - { - paragraph.EndTime = new TimeCode(endHours, endMinutes, endSeconds, endMilliseconds); - } - - return true; - } - catch - { - return false; - } - } - return false; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SwiftText : SubtitleFormat + { + private enum ExpectingLine + { + TimeCodes, + Text + } + + private Paragraph _paragraph; + private StringBuilder _text = new StringBuilder(); + private ExpectingLine _expecting = ExpectingLine.TimeCodes; + + private static readonly Regex RegexTimeCodes = new Regex(@"^TIMEIN:\s*[0123456789-]+:[0123456789-]+:[0123456789-]+:[0123456789-]+\s*DURATION:\s*[0123456789-]+:[0123456789-]+\s*TIMEOUT:\s*[0123456789-]+:[0123456789-]+:[0123456789-]+:[0123456789-]+$", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "Swift text"; + + public override bool IsMine(List lines, string fileName) + { + if (lines == null || lines.Count > 2 && !string.IsNullOrEmpty(lines[0]) && lines[0].Contains("{QTtext}")) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + //TIMEIN: 01:00:01:09 DURATION: 01:20 TIMEOUT: --:--:--:-- + //Broadcasting + //from an undisclosed location... + + //TIMEIN: 01:00:04:12 DURATION: 04:25 TIMEOUT: 01:00:09:07 + + const string paragraphWriteFormat = "TIMEIN: {0}\tDURATION: {1}\tTIMEOUT: {2}\r\n{3}\r\n"; + + var sb = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + // to avoid rounding errors in duration + var startFrame = MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds); + var endFrame = MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds); + var durationCalc = new Paragraph( + new TimeCode(p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, FramesToMillisecondsMax999(startFrame)), + new TimeCode(p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, FramesToMillisecondsMax999(endFrame)), + string.Empty); + + string startTime = $"{p.StartTime.Hours:00}:{p.StartTime.Minutes:00}:{p.StartTime.Seconds:00}:{startFrame:00}"; + string timeOut = $"{p.EndTime.Hours:00}:{p.EndTime.Minutes:00}:{p.EndTime.Seconds:00}:{endFrame:00}"; + string timeDuration = $"{durationCalc.Duration.Seconds:00}:{MillisecondsToFramesMaxFrameRate(durationCalc.Duration.Milliseconds):00}"; + sb.AppendLine(string.Format(paragraphWriteFormat, startTime, timeDuration, timeOut, p.Text)); + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _paragraph = new Paragraph(); + _expecting = ExpectingLine.TimeCodes; + _errorCount = 0; + + subtitle.Paragraphs.Clear(); + foreach (string line in lines) + { + ReadLine(subtitle, line); + if (_text.Length > 1000) + { + return; + } + } + if (_text != null && _text.ToString().TrimStart().Length > 0) + { + _paragraph.Text = _text.ToString().Trim(); + subtitle.Paragraphs.Add(_paragraph); + } + + subtitle.Renumber(); + } + + private void ReadLine(Subtitle subtitle, string line) + { + switch (_expecting) + { + case ExpectingLine.TimeCodes: + if (TryReadTimeCodesLine(line, _paragraph)) + { + _text = new StringBuilder(); + _expecting = ExpectingLine.Text; + } + else if (!string.IsNullOrWhiteSpace(line)) + { + _errorCount++; + _expecting = ExpectingLine.Text; // lets go to next paragraph + } + break; + case ExpectingLine.Text: + if (!string.IsNullOrWhiteSpace(line)) + { + _text.AppendLine(line.TrimEnd()); + } + else if (_paragraph != null && _paragraph.EndTime.TotalMilliseconds > 0) + { + _paragraph.Text = _text.ToString().Trim(); + subtitle.Paragraphs.Add(_paragraph); + _paragraph = new Paragraph(); + _expecting = ExpectingLine.TimeCodes; + } + else + { + _errorCount++; + } + break; + } + } + + private static bool TryReadTimeCodesLine(string line, Paragraph paragraph) + { + line = line.Trim(); + if (line.StartsWith("TIMEIN:", StringComparison.Ordinal) && RegexTimeCodes.IsMatch(line)) + { + //TIMEIN: 01:00:04:12 DURATION: 04:25 TIMEOUT: 01:00:09:07 + string s = line.Replace("TIMEIN:", string.Empty).Replace("DURATION", string.Empty).Replace("TIMEOUT", string.Empty).RemoveChar(' ').Replace("\t", string.Empty); + string[] parts = s.Split(':'); + try + { + int startHours = int.Parse(parts[0]); + int startMinutes = int.Parse(parts[1]); + int startSeconds = int.Parse(parts[2]); + int startMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[3])); + + int durationSeconds = 0; + if (parts[4] != "-") + { + durationSeconds = int.Parse(parts[4]); + } + + int durationMilliseconds = 0; + if (parts[5] != "--") + { + durationMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[5])); + } + + int endHours = 0; + if (parts[6] != "--") + { + endHours = int.Parse(parts[6]); + } + + int endMinutes = 0; + if (parts[7] != "--") + { + endMinutes = int.Parse(parts[7]); + } + + int endSeconds = 0; + if (parts[8] != "--") + { + endSeconds = int.Parse(parts[8]); + } + + int endMilliseconds = 0; + if (parts[9] != "--") + { + endMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[9])); + } + + paragraph.StartTime = new TimeCode(startHours, startMinutes, startSeconds, startMilliseconds); + + if (durationSeconds > 0 || durationMilliseconds > 0) + { + paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + (durationSeconds * 1000 + durationMilliseconds); + } + else + { + paragraph.EndTime = new TimeCode(endHours, endMinutes, endSeconds, endMilliseconds); + } + + return true; + } + catch + { + return false; + } + } + return false; + } + } +} diff --git a/libse/SubtitleFormats/SwiftTextLineNoAndDur.cs b/src/libse/SubtitleFormats/SwiftTextLineNoAndDur.cs similarity index 97% rename from libse/SubtitleFormats/SwiftTextLineNoAndDur.cs rename to src/libse/SubtitleFormats/SwiftTextLineNoAndDur.cs index 47c406a5d..3cc099b16 100644 --- a/libse/SubtitleFormats/SwiftTextLineNoAndDur.cs +++ b/src/libse/SubtitleFormats/SwiftTextLineNoAndDur.cs @@ -1,185 +1,185 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SwiftTextLineNOAndDur : SubtitleFormat - { - private enum ExpectingLine - { - TimeCodes, - Text - } - - private Paragraph _paragraph; - private StringBuilder _text = new StringBuilder(); - private ExpectingLine _expecting = ExpectingLine.TimeCodes; - - private static readonly Regex RegexTimeCodes = new Regex(@"^SUBTITLE: \d+\s+TIMEIN:\s*[0123456789-]+:[0123456789-]+:[0123456789-]+:[0123456789-]+\s*DURATION:\s*[0123456789-]+:[0123456789-]+\s+TIMEOUT:\s*[0123456789-]+:[0123456789-]+:[0123456789-]+:[0123456789-]+$", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "Swift text line# +dur"; - - public override bool IsMine(List lines, string fileName) - { - if (lines != null && lines.Count > 2 && !string.IsNullOrEmpty(lines[0]) && lines[0].Contains("{QTtext}")) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - //SUBTITLE: 1 TIMEIN: 00:00:07:01 DURATION: 03:11 TIMEOUT: 00:00:10:12 - //Voor de oorlog - - //SUBTITLE: 2 TIMEIN: 00:00:10:16 DURATION: 01:08 TIMEOUT: 00:00:11:24 - //Ik ben Marie Pinhas. Ik ben geboren - //in Thessaloniki in Griekenland, - - //SUBTITLE: 3 TIMEIN: 00:00:12:12 DURATION: 02:10 TIMEOUT: 00:00:14:22 - //op 6 maart '31, - //in een heel oude Griekse familie. - - const string paragraphWriteFormat = "SUBTITLE: {1}\tTIMEIN: {0}\tDURATION: {4}\tTIMEOUT: {2}\r\n{3}\r\n"; - - var sb = new StringBuilder(); - int count = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - // to avoid rounding errors in duration - var startFrame = MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds); - var endFrame = MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds); - var durationCalc = new Paragraph( - new TimeCode(p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, FramesToMillisecondsMax999(startFrame)), - new TimeCode(p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, FramesToMillisecondsMax999(endFrame)), - string.Empty); - - string startTime = $"{p.StartTime.Hours:00}:{p.StartTime.Minutes:00}:{p.StartTime.Seconds:00}:{startFrame:00}"; - string timeOut = $"{p.EndTime.Hours:00}:{p.EndTime.Minutes:00}:{p.EndTime.Seconds:00}:{endFrame:00}"; - string timeDuration = $"{durationCalc.Duration.Seconds:00}:{MillisecondsToFramesMaxFrameRate(durationCalc.Duration.Milliseconds):00}"; - sb.AppendLine(string.Format(paragraphWriteFormat, startTime, count, timeOut, p.Text, timeDuration)); - count++; - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _paragraph = new Paragraph(); - _expecting = ExpectingLine.TimeCodes; - _errorCount = 0; - - subtitle.Paragraphs.Clear(); - foreach (string line in lines) - { - ReadLine(subtitle, line); - if (_text.Length > 1000) - { - return; - } - } - if (_text != null && _text.ToString().TrimStart().Length > 0) - { - _paragraph.Text = _text.ToString().Trim(); - subtitle.Paragraphs.Add(_paragraph); - } - - subtitle.Renumber(); - } - - private void ReadLine(Subtitle subtitle, string line) - { - switch (_expecting) - { - case ExpectingLine.TimeCodes: - if (TryReadTimeCodesLine(line, _paragraph)) - { - _text = new StringBuilder(); - _expecting = ExpectingLine.Text; - } - else if (!string.IsNullOrWhiteSpace(line)) - { - _errorCount++; - _expecting = ExpectingLine.Text; // lets go to next paragraph - } - break; - case ExpectingLine.Text: - if (!string.IsNullOrWhiteSpace(line)) - { - _text.AppendLine(line.TrimEnd()); - } - else if (_paragraph != null && _paragraph.EndTime.TotalMilliseconds > 0) - { - _paragraph.Text = _text.ToString().Trim(); - subtitle.Paragraphs.Add(_paragraph); - _paragraph = new Paragraph(); - _expecting = ExpectingLine.TimeCodes; - } - else - { - _errorCount++; - } - break; - } - } - - private static bool TryReadTimeCodesLine(string line, Paragraph paragraph) - { - line = line.Trim(); - if (line.Length > 20 && line.StartsWith("SUBTITLE:", StringComparison.Ordinal) && RegexTimeCodes.IsMatch(line)) - { - //SUBTITLE: 1 TIMEIN: 00:00:07:01 DURATION: 03:11 TIMEOUT: 00:00:10:12 - string s = line.Replace("SUBTITLE:", string.Empty).Replace("TIMEIN", string.Empty).Replace("DURATION", string.Empty).Replace("TIMEOUT", string.Empty).RemoveChar(' ').Replace("\t", string.Empty); - string[] parts = s.Split(':'); - try - { - int startHours = int.Parse(parts[1]); - int startMinutes = int.Parse(parts[2]); - int startSeconds = int.Parse(parts[3]); - int startMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[4])); - - int endHours = 0; - if (parts[5 + 2] != "--") - { - endHours = int.Parse(parts[5 + 2]); - } - - int endMinutes = 0; - if (parts[6 + 2] != "--") - { - endMinutes = int.Parse(parts[6 + 2]); - } - - int endSeconds = 0; - if (parts[7 + 2] != "--") - { - endSeconds = int.Parse(parts[7 + 2]); - } - - int endMilliseconds = 0; - if (parts[8 + 2] != "--") - { - endMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[8 + 2])); - } - - paragraph.StartTime = new TimeCode(startHours, startMinutes, startSeconds, startMilliseconds); - paragraph.EndTime = new TimeCode(endHours, endMinutes, endSeconds, endMilliseconds); - return true; - } - catch - { - return false; - } - } - return false; - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SwiftTextLineNOAndDur : SubtitleFormat + { + private enum ExpectingLine + { + TimeCodes, + Text + } + + private Paragraph _paragraph; + private StringBuilder _text = new StringBuilder(); + private ExpectingLine _expecting = ExpectingLine.TimeCodes; + + private static readonly Regex RegexTimeCodes = new Regex(@"^SUBTITLE: \d+\s+TIMEIN:\s*[0123456789-]+:[0123456789-]+:[0123456789-]+:[0123456789-]+\s*DURATION:\s*[0123456789-]+:[0123456789-]+\s+TIMEOUT:\s*[0123456789-]+:[0123456789-]+:[0123456789-]+:[0123456789-]+$", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "Swift text line# +dur"; + + public override bool IsMine(List lines, string fileName) + { + if (lines != null && lines.Count > 2 && !string.IsNullOrEmpty(lines[0]) && lines[0].Contains("{QTtext}")) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + //SUBTITLE: 1 TIMEIN: 00:00:07:01 DURATION: 03:11 TIMEOUT: 00:00:10:12 + //Voor de oorlog + + //SUBTITLE: 2 TIMEIN: 00:00:10:16 DURATION: 01:08 TIMEOUT: 00:00:11:24 + //Ik ben Marie Pinhas. Ik ben geboren + //in Thessaloniki in Griekenland, + + //SUBTITLE: 3 TIMEIN: 00:00:12:12 DURATION: 02:10 TIMEOUT: 00:00:14:22 + //op 6 maart '31, + //in een heel oude Griekse familie. + + const string paragraphWriteFormat = "SUBTITLE: {1}\tTIMEIN: {0}\tDURATION: {4}\tTIMEOUT: {2}\r\n{3}\r\n"; + + var sb = new StringBuilder(); + int count = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + // to avoid rounding errors in duration + var startFrame = MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds); + var endFrame = MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds); + var durationCalc = new Paragraph( + new TimeCode(p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, FramesToMillisecondsMax999(startFrame)), + new TimeCode(p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, FramesToMillisecondsMax999(endFrame)), + string.Empty); + + string startTime = $"{p.StartTime.Hours:00}:{p.StartTime.Minutes:00}:{p.StartTime.Seconds:00}:{startFrame:00}"; + string timeOut = $"{p.EndTime.Hours:00}:{p.EndTime.Minutes:00}:{p.EndTime.Seconds:00}:{endFrame:00}"; + string timeDuration = $"{durationCalc.Duration.Seconds:00}:{MillisecondsToFramesMaxFrameRate(durationCalc.Duration.Milliseconds):00}"; + sb.AppendLine(string.Format(paragraphWriteFormat, startTime, count, timeOut, p.Text, timeDuration)); + count++; + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _paragraph = new Paragraph(); + _expecting = ExpectingLine.TimeCodes; + _errorCount = 0; + + subtitle.Paragraphs.Clear(); + foreach (string line in lines) + { + ReadLine(subtitle, line); + if (_text.Length > 1000) + { + return; + } + } + if (_text != null && _text.ToString().TrimStart().Length > 0) + { + _paragraph.Text = _text.ToString().Trim(); + subtitle.Paragraphs.Add(_paragraph); + } + + subtitle.Renumber(); + } + + private void ReadLine(Subtitle subtitle, string line) + { + switch (_expecting) + { + case ExpectingLine.TimeCodes: + if (TryReadTimeCodesLine(line, _paragraph)) + { + _text = new StringBuilder(); + _expecting = ExpectingLine.Text; + } + else if (!string.IsNullOrWhiteSpace(line)) + { + _errorCount++; + _expecting = ExpectingLine.Text; // lets go to next paragraph + } + break; + case ExpectingLine.Text: + if (!string.IsNullOrWhiteSpace(line)) + { + _text.AppendLine(line.TrimEnd()); + } + else if (_paragraph != null && _paragraph.EndTime.TotalMilliseconds > 0) + { + _paragraph.Text = _text.ToString().Trim(); + subtitle.Paragraphs.Add(_paragraph); + _paragraph = new Paragraph(); + _expecting = ExpectingLine.TimeCodes; + } + else + { + _errorCount++; + } + break; + } + } + + private static bool TryReadTimeCodesLine(string line, Paragraph paragraph) + { + line = line.Trim(); + if (line.Length > 20 && line.StartsWith("SUBTITLE:", StringComparison.Ordinal) && RegexTimeCodes.IsMatch(line)) + { + //SUBTITLE: 1 TIMEIN: 00:00:07:01 DURATION: 03:11 TIMEOUT: 00:00:10:12 + string s = line.Replace("SUBTITLE:", string.Empty).Replace("TIMEIN", string.Empty).Replace("DURATION", string.Empty).Replace("TIMEOUT", string.Empty).RemoveChar(' ').Replace("\t", string.Empty); + string[] parts = s.Split(':'); + try + { + int startHours = int.Parse(parts[1]); + int startMinutes = int.Parse(parts[2]); + int startSeconds = int.Parse(parts[3]); + int startMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[4])); + + int endHours = 0; + if (parts[5 + 2] != "--") + { + endHours = int.Parse(parts[5 + 2]); + } + + int endMinutes = 0; + if (parts[6 + 2] != "--") + { + endMinutes = int.Parse(parts[6 + 2]); + } + + int endSeconds = 0; + if (parts[7 + 2] != "--") + { + endSeconds = int.Parse(parts[7 + 2]); + } + + int endMilliseconds = 0; + if (parts[8 + 2] != "--") + { + endMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[8 + 2])); + } + + paragraph.StartTime = new TimeCode(startHours, startMinutes, startSeconds, startMilliseconds); + paragraph.EndTime = new TimeCode(endHours, endMinutes, endSeconds, endMilliseconds); + return true; + } + catch + { + return false; + } + } + return false; + } + + } +} diff --git a/libse/SubtitleFormats/SwiftTextLineNumber.cs b/src/libse/SubtitleFormats/SwiftTextLineNumber.cs similarity index 97% rename from libse/SubtitleFormats/SwiftTextLineNumber.cs rename to src/libse/SubtitleFormats/SwiftTextLineNumber.cs index c42e97df1..1f3b93206 100644 --- a/libse/SubtitleFormats/SwiftTextLineNumber.cs +++ b/src/libse/SubtitleFormats/SwiftTextLineNumber.cs @@ -1,175 +1,175 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class SwiftTextLineNumber : SubtitleFormat - { - private enum ExpectingLine - { - TimeCodes, - Text - } - - private Paragraph _paragraph; - private StringBuilder _text = new StringBuilder(); - private ExpectingLine _expecting = ExpectingLine.TimeCodes; - - private static readonly Regex RegexTimeCodes = new Regex(@"^SUBTITLE: \d+\s+TIMEIN:\s*[0123456789-]+:[0123456789-]+:[0123456789-]+:[0123456789-]+\s*TIMEOUT:\s*[0123456789-]+:[0123456789-]+:[0123456789-]+:[0123456789-]+$", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "Swift text line#"; - - public override bool IsMine(List lines, string fileName) - { - if (lines == null || lines.Count > 2 && !string.IsNullOrEmpty(lines[0]) && lines[0].Contains("{QTtext}")) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - public override string ToText(Subtitle subtitle, string title) - { - //SUBTITLE: 1 TIMEIN: 00:00:00:00 TIMEOUT: 00:00:04:00 - //Voor de oorlog - - //SUBTITLE: 2 TIMEIN: 00:00:05:12 TIMEOUT: 00:00:10:02 - //Ik ben Marie Pinhas. Ik ben geboren - //in Thessaloniki in Griekenland, - - //SUBTITLE: 3 TIMEIN: 00:00:10:06 TIMEOUT: 00:00:15:17 - //op 6 maart '31, - //in een heel oude Griekse familie. - - const string paragraphWriteFormat = "SUBTITLE: {1}\tTIMEIN: {0}\tTIMEOUT: {2}\r\n{3}\r\n"; - - var sb = new StringBuilder(); - int count = 1; - foreach (var p in subtitle.Paragraphs) - { - string startTime = $"{p.StartTime.Hours:00}:{p.StartTime.Minutes:00}:{p.StartTime.Seconds:00}:{MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds):00}"; - string timeOut = $"{p.EndTime.Hours:00}:{p.EndTime.Minutes:00}:{p.EndTime.Seconds:00}:{MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds):00}"; - sb.AppendLine(string.Format(paragraphWriteFormat, startTime, count, timeOut, p.Text)); - count++; - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _paragraph = new Paragraph(); - _expecting = ExpectingLine.TimeCodes; - _errorCount = 0; - - subtitle.Paragraphs.Clear(); - foreach (string line in lines) - { - ReadLine(subtitle, line); - if (_text.Length > 1000) - { - return; - } - } - if (_text != null && _text.ToString().TrimStart().Length > 0) - { - _paragraph.Text = _text.ToString().Trim(); - subtitle.Paragraphs.Add(_paragraph); - } - - subtitle.Renumber(); - } - - private void ReadLine(Subtitle subtitle, string line) - { - switch (_expecting) - { - case ExpectingLine.TimeCodes: - if (TryReadTimeCodesLine(line, _paragraph)) - { - _text = new StringBuilder(); - _expecting = ExpectingLine.Text; - } - else if (!string.IsNullOrWhiteSpace(line)) - { - _errorCount++; - _expecting = ExpectingLine.Text; // lets go to next paragraph - } - break; - case ExpectingLine.Text: - if (!string.IsNullOrWhiteSpace(line)) - { - _text.AppendLine(line.TrimEnd()); - } - else if (_paragraph != null && _paragraph.EndTime.TotalMilliseconds > 0) - { - _paragraph.Text = _text.ToString().Trim(); - subtitle.Paragraphs.Add(_paragraph); - _paragraph = new Paragraph(); - _expecting = ExpectingLine.TimeCodes; - } - else - { - _errorCount++; - } - break; - } - } - - private static bool TryReadTimeCodesLine(string line, Paragraph paragraph) - { - line = line.Trim(); - if (line.Length > 20 && line.StartsWith("SUBTITLE:", StringComparison.Ordinal) && RegexTimeCodes.IsMatch(line)) - { - //SUBTITLE: 59 TIMEIN: 00:04:28:06 TIMEOUT: 00:04:32:12 - string s = line.Replace("SUBTITLE:", string.Empty).Replace("TIMEIN", string.Empty).Replace("TIMEOUT", string.Empty).RemoveChar(' ').Replace("\t", string.Empty); - string[] parts = s.Split(':'); - try - { - int startHours = int.Parse(parts[1]); - int startMinutes = int.Parse(parts[2]); - int startSeconds = int.Parse(parts[3]); - int startMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[4])); - - int endHours = 0; - if (parts[5] != "--") - { - endHours = int.Parse(parts[5]); - } - - int endMinutes = 0; - if (parts[6] != "--") - { - endMinutes = int.Parse(parts[6]); - } - - int endSeconds = 0; - if (parts[7] != "--") - { - endSeconds = int.Parse(parts[7]); - } - - int endMilliseconds = 0; - if (parts[8] != "--") - { - endMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[8])); - } - - paragraph.StartTime = new TimeCode(startHours, startMinutes, startSeconds, startMilliseconds); - paragraph.EndTime = new TimeCode(endHours, endMinutes, endSeconds, endMilliseconds); - return true; - } - catch - { - return false; - } - } - return false; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class SwiftTextLineNumber : SubtitleFormat + { + private enum ExpectingLine + { + TimeCodes, + Text + } + + private Paragraph _paragraph; + private StringBuilder _text = new StringBuilder(); + private ExpectingLine _expecting = ExpectingLine.TimeCodes; + + private static readonly Regex RegexTimeCodes = new Regex(@"^SUBTITLE: \d+\s+TIMEIN:\s*[0123456789-]+:[0123456789-]+:[0123456789-]+:[0123456789-]+\s*TIMEOUT:\s*[0123456789-]+:[0123456789-]+:[0123456789-]+:[0123456789-]+$", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "Swift text line#"; + + public override bool IsMine(List lines, string fileName) + { + if (lines == null || lines.Count > 2 && !string.IsNullOrEmpty(lines[0]) && lines[0].Contains("{QTtext}")) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + public override string ToText(Subtitle subtitle, string title) + { + //SUBTITLE: 1 TIMEIN: 00:00:00:00 TIMEOUT: 00:00:04:00 + //Voor de oorlog + + //SUBTITLE: 2 TIMEIN: 00:00:05:12 TIMEOUT: 00:00:10:02 + //Ik ben Marie Pinhas. Ik ben geboren + //in Thessaloniki in Griekenland, + + //SUBTITLE: 3 TIMEIN: 00:00:10:06 TIMEOUT: 00:00:15:17 + //op 6 maart '31, + //in een heel oude Griekse familie. + + const string paragraphWriteFormat = "SUBTITLE: {1}\tTIMEIN: {0}\tTIMEOUT: {2}\r\n{3}\r\n"; + + var sb = new StringBuilder(); + int count = 1; + foreach (var p in subtitle.Paragraphs) + { + string startTime = $"{p.StartTime.Hours:00}:{p.StartTime.Minutes:00}:{p.StartTime.Seconds:00}:{MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds):00}"; + string timeOut = $"{p.EndTime.Hours:00}:{p.EndTime.Minutes:00}:{p.EndTime.Seconds:00}:{MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds):00}"; + sb.AppendLine(string.Format(paragraphWriteFormat, startTime, count, timeOut, p.Text)); + count++; + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _paragraph = new Paragraph(); + _expecting = ExpectingLine.TimeCodes; + _errorCount = 0; + + subtitle.Paragraphs.Clear(); + foreach (string line in lines) + { + ReadLine(subtitle, line); + if (_text.Length > 1000) + { + return; + } + } + if (_text != null && _text.ToString().TrimStart().Length > 0) + { + _paragraph.Text = _text.ToString().Trim(); + subtitle.Paragraphs.Add(_paragraph); + } + + subtitle.Renumber(); + } + + private void ReadLine(Subtitle subtitle, string line) + { + switch (_expecting) + { + case ExpectingLine.TimeCodes: + if (TryReadTimeCodesLine(line, _paragraph)) + { + _text = new StringBuilder(); + _expecting = ExpectingLine.Text; + } + else if (!string.IsNullOrWhiteSpace(line)) + { + _errorCount++; + _expecting = ExpectingLine.Text; // lets go to next paragraph + } + break; + case ExpectingLine.Text: + if (!string.IsNullOrWhiteSpace(line)) + { + _text.AppendLine(line.TrimEnd()); + } + else if (_paragraph != null && _paragraph.EndTime.TotalMilliseconds > 0) + { + _paragraph.Text = _text.ToString().Trim(); + subtitle.Paragraphs.Add(_paragraph); + _paragraph = new Paragraph(); + _expecting = ExpectingLine.TimeCodes; + } + else + { + _errorCount++; + } + break; + } + } + + private static bool TryReadTimeCodesLine(string line, Paragraph paragraph) + { + line = line.Trim(); + if (line.Length > 20 && line.StartsWith("SUBTITLE:", StringComparison.Ordinal) && RegexTimeCodes.IsMatch(line)) + { + //SUBTITLE: 59 TIMEIN: 00:04:28:06 TIMEOUT: 00:04:32:12 + string s = line.Replace("SUBTITLE:", string.Empty).Replace("TIMEIN", string.Empty).Replace("TIMEOUT", string.Empty).RemoveChar(' ').Replace("\t", string.Empty); + string[] parts = s.Split(':'); + try + { + int startHours = int.Parse(parts[1]); + int startMinutes = int.Parse(parts[2]); + int startSeconds = int.Parse(parts[3]); + int startMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[4])); + + int endHours = 0; + if (parts[5] != "--") + { + endHours = int.Parse(parts[5]); + } + + int endMinutes = 0; + if (parts[6] != "--") + { + endMinutes = int.Parse(parts[6]); + } + + int endSeconds = 0; + if (parts[7] != "--") + { + endSeconds = int.Parse(parts[7]); + } + + int endMilliseconds = 0; + if (parts[8] != "--") + { + endMilliseconds = FramesToMillisecondsMax999(int.Parse(parts[8])); + } + + paragraph.StartTime = new TimeCode(startHours, startMinutes, startSeconds, startMilliseconds); + paragraph.EndTime = new TimeCode(endHours, endMinutes, endSeconds, endMilliseconds); + return true; + } + catch + { + return false; + } + } + return false; + } + } +} diff --git a/libse/SubtitleFormats/TMPlayer.cs b/src/libse/SubtitleFormats/TMPlayer.cs similarity index 97% rename from libse/SubtitleFormats/TMPlayer.cs rename to src/libse/SubtitleFormats/TMPlayer.cs index 92740a29b..19896e214 100644 --- a/libse/SubtitleFormats/TMPlayer.cs +++ b/src/libse/SubtitleFormats/TMPlayer.cs @@ -1,132 +1,132 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class TMPlayer : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d+:\d\d:\d\d[: ].*$", RegexOptions.Compiled); // accept a " " instead of the last ":" too - - public override string Extension => ".txt"; - - public override string Name => "TMPlayer"; - - public override bool IsMine(List lines, string fileName) - { - var subtitle = new Subtitle(); - LoadSubtitle(subtitle, lines, fileName); - - if (subtitle.Paragraphs.Count > 4) - { - bool allStartWithNumber = true; - foreach (Paragraph p in subtitle.Paragraphs) - { - if (p.Text.Length > 1 && !Utilities.IsInteger(p.Text.Substring(0, 2))) - { - allStartWithNumber = false; - break; - } - } - if (allStartWithNumber) - { - return false; - } - } - if (subtitle.Paragraphs.Count > _errorCount) - { - if (new UnknownSubtitle33().IsMine(lines, fileName) || new UnknownSubtitle36().IsMine(lines, fileName)) - { - return false; - } - - return true; - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - string text = HtmlUtil.RemoveHtmlTags(p.Text); - text = text.Replace(Environment.NewLine, "|"); - sb.AppendLine($"{p.StartTime.Hours:00}:{p.StartTime.Minutes:00}:{p.StartTime.Seconds:00}:{text}"); - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { // 0:02:36:You've returned to the village|after 2 years, Shekhar. - // 00:00:50:America has made my fortune. - _errorCount = 0; - foreach (string line in lines) - { - bool success = false; - if (line.IndexOf(':') > 0 && RegexTimeCodes.Match(line).Success) - { - try - { - string s = line; - if (line.Length > 9 && line[8] == ' ') - { - s = line.Substring(0, 8) + ":" + line.Substring(9); - } - - string[] parts = s.Split(':'); - if (parts.Length > 3) - { - int hours = int.Parse(parts[0]); - int minutes = int.Parse(parts[1]); - int seconds = int.Parse(parts[2]); - string text = string.Empty; - for (int i = 3; i < parts.Length; i++) - { - if (text.Length == 0) - { - text = parts[i]; - } - else - { - text += ":" + parts[i]; - } - } - text = text.Replace("|", Environment.NewLine); - var start = new TimeCode(hours, minutes, seconds, 0); - double duration = Utilities.GetOptimalDisplayMilliseconds(text); - var end = new TimeCode(start.TotalMilliseconds + duration); - - var p = new Paragraph(start, end, text); - subtitle.Paragraphs.Add(p); - success = true; - } - } - catch - { - _errorCount++; - } - } - if (!success) - { - _errorCount++; - } - } - - int index = 0; - foreach (Paragraph p in subtitle.Paragraphs) - { - Paragraph next = subtitle.GetParagraphOrDefault(index + 1); - if (next != null && next.StartTime.TotalMilliseconds <= p.EndTime.TotalMilliseconds) - { - p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1; - } - - index++; - p.Number = index; - } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class TMPlayer : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d+:\d\d:\d\d[: ].*$", RegexOptions.Compiled); // accept a " " instead of the last ":" too + + public override string Extension => ".txt"; + + public override string Name => "TMPlayer"; + + public override bool IsMine(List lines, string fileName) + { + var subtitle = new Subtitle(); + LoadSubtitle(subtitle, lines, fileName); + + if (subtitle.Paragraphs.Count > 4) + { + bool allStartWithNumber = true; + foreach (Paragraph p in subtitle.Paragraphs) + { + if (p.Text.Length > 1 && !Utilities.IsInteger(p.Text.Substring(0, 2))) + { + allStartWithNumber = false; + break; + } + } + if (allStartWithNumber) + { + return false; + } + } + if (subtitle.Paragraphs.Count > _errorCount) + { + if (new UnknownSubtitle33().IsMine(lines, fileName) || new UnknownSubtitle36().IsMine(lines, fileName)) + { + return false; + } + + return true; + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + string text = HtmlUtil.RemoveHtmlTags(p.Text); + text = text.Replace(Environment.NewLine, "|"); + sb.AppendLine($"{p.StartTime.Hours:00}:{p.StartTime.Minutes:00}:{p.StartTime.Seconds:00}:{text}"); + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { // 0:02:36:You've returned to the village|after 2 years, Shekhar. + // 00:00:50:America has made my fortune. + _errorCount = 0; + foreach (string line in lines) + { + bool success = false; + if (line.IndexOf(':') > 0 && RegexTimeCodes.Match(line).Success) + { + try + { + string s = line; + if (line.Length > 9 && line[8] == ' ') + { + s = line.Substring(0, 8) + ":" + line.Substring(9); + } + + string[] parts = s.Split(':'); + if (parts.Length > 3) + { + int hours = int.Parse(parts[0]); + int minutes = int.Parse(parts[1]); + int seconds = int.Parse(parts[2]); + string text = string.Empty; + for (int i = 3; i < parts.Length; i++) + { + if (text.Length == 0) + { + text = parts[i]; + } + else + { + text += ":" + parts[i]; + } + } + text = text.Replace("|", Environment.NewLine); + var start = new TimeCode(hours, minutes, seconds, 0); + double duration = Utilities.GetOptimalDisplayMilliseconds(text); + var end = new TimeCode(start.TotalMilliseconds + duration); + + var p = new Paragraph(start, end, text); + subtitle.Paragraphs.Add(p); + success = true; + } + } + catch + { + _errorCount++; + } + } + if (!success) + { + _errorCount++; + } + } + + int index = 0; + foreach (Paragraph p in subtitle.Paragraphs) + { + Paragraph next = subtitle.GetParagraphOrDefault(index + 1); + if (next != null && next.StartTime.TotalMilliseconds <= p.EndTime.TotalMilliseconds) + { + p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1; + } + + index++; + p.Number = index; + } + } + } +} diff --git a/libse/SubtitleFormats/TSB4.cs b/src/libse/SubtitleFormats/TSB4.cs similarity index 97% rename from libse/SubtitleFormats/TSB4.cs rename to src/libse/SubtitleFormats/TSB4.cs index a6864fd5d..07e8e6f95 100644 --- a/libse/SubtitleFormats/TSB4.cs +++ b/src/libse/SubtitleFormats/TSB4.cs @@ -1,151 +1,151 @@ -using System.Collections.Generic; -using System.Text; -using System; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - /// SubtitleNext - /// - public class TSB4 : SubtitleFormat - { - public override string Extension => ".sub"; - - public override string Name => "TSB4"; - - public override string ToText(Subtitle subtitle, string title) - { - return "Not supported!"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var spaceMode = true; - subtitle.Paragraphs.Clear(); - if (string.IsNullOrEmpty(fileName)) - { - return; - } - byte[] array; - try - { - array = FileUtil.ReadAllBytesShared(fileName); - } - catch - { - _errorCount++; - return; - } - if (array.Length < 100 || array[0] != 84 || array[1] != 83 || array[2] != 66 || array[3] != 52) - { - return; - } - - int codePage = 0; // use default code page if not found - - for (int i = 0; i < array.Length - 20; i++) - { - if (array[i] == 67 && array[i + 1] == 80 && array[i + 2] == 65 && array[i + 3] == 71 && array[i + 4] == 4 && array[i + 5] == 0 && array[i + 6] == 0 && array[i + 7] == 0) // CPAG - { - codePage = array[i + 8] + array[i + 9] * 256; - i += 12; - } - if (array[i] == 84 && array[i + 1] == 73 && array[i + 2] == 84 && array[i + 3] == 76 && array[i + 8] == 84 && array[i + 9] == 73 && array[i + 10] == 77 && array[i + 11] == 69) // TITL + TIME - { - if (array[i + 5] != 32) - { - spaceMode = false; - } - - int endOfText = array[i + 4]; - if (!spaceMode) - { - endOfText += array[i + 5] * 256; - } - - int start = array[i + 16] + array[i + 17] * 256; - if (array[i + 18] != 32 || !spaceMode) - { - start += array[i + 18] * 256 * 256; - } - - int end = array[i + 20] + array[i + 21] * 256; - if (array[i + 22] != 32 || !spaceMode) - { - end += array[i + 22] * 256 * 256; - } - - int textStart = i; - while (textStart <= i + endOfText + 4 && !(array[textStart] == 0x4C && array[textStart + 1] == 0x49 && array[textStart + 2] == 0x4E && array[textStart + 3] == 0x45)) // LINE - { - textStart++; - } - int length = array[textStart + 4]; - if (array[textStart + 5] != 32 || !spaceMode) - { - length += array[textStart + 5] * 256; - } - - textStart += 8; - - string text = string.Empty; - if (textStart + length > array.Length) - { - if (textStart < array.Length) - { - text = Encoding.GetEncoding(codePage).GetString(array, textStart, array.Length - textStart); - } - } - else - { - text = Encoding.GetEncoding(codePage).GetString(array, textStart, length); - } - text = FixItalicsAndBinaryZero(text); - text = string.Join(Environment.NewLine, text.SplitToLines()); //conform to CRLF - text = text.Replace(" " + Environment.NewLine, Environment.NewLine).Trim(); - var item = new Paragraph(text, FramesToMilliseconds(start), FramesToMilliseconds(end)); - subtitle.Paragraphs.Add(item); - i += endOfText + 5; - } - } - subtitle.RemoveEmptyLines(); - subtitle.Renumber(); - } - - private static string FixItalicsAndBinaryZero(string text) - { - var sb = new StringBuilder(text.Length + 5); - var italicOn = false; - for (int i = 0; i < text.Length; i++) - { - var ch = text[i]; - switch (ch) - { - case '\u007f': - sb.Append(italicOn ? "
" : ""); - italicOn = !italicOn; - break; - case '\r': - case '\n': - if (italicOn) - { - sb.Append(""); - italicOn = false; - } - sb.Append(ch); - break; - case '\0': - sb.Append(" "); - break; - default: - sb.Append(ch); - break; - } - } - return sb.ToString().Trim(); - } - - } -} +using System.Collections.Generic; +using System.Text; +using System; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + /// + /// SubtitleNext + /// + public class TSB4 : SubtitleFormat + { + public override string Extension => ".sub"; + + public override string Name => "TSB4"; + + public override string ToText(Subtitle subtitle, string title) + { + return "Not supported!"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var spaceMode = true; + subtitle.Paragraphs.Clear(); + if (string.IsNullOrEmpty(fileName)) + { + return; + } + byte[] array; + try + { + array = FileUtil.ReadAllBytesShared(fileName); + } + catch + { + _errorCount++; + return; + } + if (array.Length < 100 || array[0] != 84 || array[1] != 83 || array[2] != 66 || array[3] != 52) + { + return; + } + + int codePage = 0; // use default code page if not found + + for (int i = 0; i < array.Length - 20; i++) + { + if (array[i] == 67 && array[i + 1] == 80 && array[i + 2] == 65 && array[i + 3] == 71 && array[i + 4] == 4 && array[i + 5] == 0 && array[i + 6] == 0 && array[i + 7] == 0) // CPAG + { + codePage = array[i + 8] + array[i + 9] * 256; + i += 12; + } + if (array[i] == 84 && array[i + 1] == 73 && array[i + 2] == 84 && array[i + 3] == 76 && array[i + 8] == 84 && array[i + 9] == 73 && array[i + 10] == 77 && array[i + 11] == 69) // TITL + TIME + { + if (array[i + 5] != 32) + { + spaceMode = false; + } + + int endOfText = array[i + 4]; + if (!spaceMode) + { + endOfText += array[i + 5] * 256; + } + + int start = array[i + 16] + array[i + 17] * 256; + if (array[i + 18] != 32 || !spaceMode) + { + start += array[i + 18] * 256 * 256; + } + + int end = array[i + 20] + array[i + 21] * 256; + if (array[i + 22] != 32 || !spaceMode) + { + end += array[i + 22] * 256 * 256; + } + + int textStart = i; + while (textStart <= i + endOfText + 4 && !(array[textStart] == 0x4C && array[textStart + 1] == 0x49 && array[textStart + 2] == 0x4E && array[textStart + 3] == 0x45)) // LINE + { + textStart++; + } + int length = array[textStart + 4]; + if (array[textStart + 5] != 32 || !spaceMode) + { + length += array[textStart + 5] * 256; + } + + textStart += 8; + + string text = string.Empty; + if (textStart + length > array.Length) + { + if (textStart < array.Length) + { + text = Encoding.GetEncoding(codePage).GetString(array, textStart, array.Length - textStart); + } + } + else + { + text = Encoding.GetEncoding(codePage).GetString(array, textStart, length); + } + text = FixItalicsAndBinaryZero(text); + text = string.Join(Environment.NewLine, text.SplitToLines()); //conform to CRLF + text = text.Replace(" " + Environment.NewLine, Environment.NewLine).Trim(); + var item = new Paragraph(text, FramesToMilliseconds(start), FramesToMilliseconds(end)); + subtitle.Paragraphs.Add(item); + i += endOfText + 5; + } + } + subtitle.RemoveEmptyLines(); + subtitle.Renumber(); + } + + private static string FixItalicsAndBinaryZero(string text) + { + var sb = new StringBuilder(text.Length + 5); + var italicOn = false; + for (int i = 0; i < text.Length; i++) + { + var ch = text[i]; + switch (ch) + { + case '\u007f': + sb.Append(italicOn ? "
" : ""); + italicOn = !italicOn; + break; + case '\r': + case '\n': + if (italicOn) + { + sb.Append(""); + italicOn = false; + } + sb.Append(ch); + break; + case '\0': + sb.Append(" "); + break; + default: + sb.Append(ch); + break; + } + } + return sb.ToString().Trim(); + } + + } +} diff --git a/libse/SubtitleFormats/Ted20.cs b/src/libse/SubtitleFormats/Ted20.cs similarity index 100% rename from libse/SubtitleFormats/Ted20.cs rename to src/libse/SubtitleFormats/Ted20.cs diff --git a/libse/SubtitleFormats/Tek.cs b/src/libse/SubtitleFormats/Tek.cs similarity index 97% rename from libse/SubtitleFormats/Tek.cs rename to src/libse/SubtitleFormats/Tek.cs index 04dbf8882..39aedce44 100644 --- a/libse/SubtitleFormats/Tek.cs +++ b/src/libse/SubtitleFormats/Tek.cs @@ -1,107 +1,107 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class Tek : SubtitleFormat - { - private static readonly Regex RegexTimeCode = new Regex(@"^\d+ \d+ \d \d \d$", RegexOptions.Compiled); - - public override string Extension => ".tek"; - - public override string Name => "TEK"; - - public override bool IsTimeBased => false; - - public override string ToText(Subtitle subtitle, string title) - { - //1. - //8.03 - //10.06 - //- Labai aèiû. - //- Jûs rimtai? - - //2. - //16.00 - //19.06 - //Kaip reikalai ðunø grobimo versle? - - const string paragraphWriteFormat = "{0} {1} 1 1 0\r\n{2}"; - var sb = new StringBuilder(); - sb.AppendLine(@"ý Smart Titl Editor / Smart Titler (A)(C)1992-2001. Dragutin Nikolic -ý Serial No: XXXXXXXXXXXXXX -ý Korisnik: Prava i Prevodi - prevodioci -ý -ý KONFIGURACIONI PODACI -ý Dozvoljeno slova u redu: 30 -ý Vremenska korekcija: 1.0000000000E+00 -ý Radjeno vremenskih korekcija: TRUE -ý Slovni raspored ASCIR -ý -ý Kraj info blocka."); - sb.AppendLine(); - foreach (Paragraph p in subtitle.Paragraphs) - { - var text = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont); - sb.AppendLine(string.Format(paragraphWriteFormat, MillisecondsToFrames(p.StartTime.TotalMilliseconds), MillisecondsToFrames(p.EndTime.TotalMilliseconds), text)); - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - Paragraph paragraph = null; - _errorCount = 0; - - subtitle.Paragraphs.Clear(); - foreach (string line in lines) - { - string s = line.Trim(); - if (RegexTimeCode.IsMatch(s)) - { - if (paragraph != null) - { - subtitle.Paragraphs.Add(paragraph); - } - - paragraph = new Paragraph(); - string[] parts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - if (parts.Length == 5) - { - try - { - paragraph.StartTime.TotalMilliseconds = FramesToMilliseconds(int.Parse(parts[0])); - paragraph.EndTime.TotalMilliseconds = FramesToMilliseconds(int.Parse(parts[1])); - } - catch - { - _errorCount++; - } - } - } - else if (paragraph != null && s.Length > 0) - { - paragraph.Text = (paragraph.Text + Environment.NewLine + s).Trim(); - if (paragraph.Text.Length > 2000) - { - _errorCount += 100; - return; - } - } - else if (s.Length > 0 && !s.StartsWith('ý')) - { - _errorCount++; - } - } - if (paragraph != null) - { - subtitle.Paragraphs.Add(paragraph); - } - - subtitle.Renumber(); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class Tek : SubtitleFormat + { + private static readonly Regex RegexTimeCode = new Regex(@"^\d+ \d+ \d \d \d$", RegexOptions.Compiled); + + public override string Extension => ".tek"; + + public override string Name => "TEK"; + + public override bool IsTimeBased => false; + + public override string ToText(Subtitle subtitle, string title) + { + //1. + //8.03 + //10.06 + //- Labai aèiû. + //- Jûs rimtai? + + //2. + //16.00 + //19.06 + //Kaip reikalai ðunø grobimo versle? + + const string paragraphWriteFormat = "{0} {1} 1 1 0\r\n{2}"; + var sb = new StringBuilder(); + sb.AppendLine(@"ý Smart Titl Editor / Smart Titler (A)(C)1992-2001. Dragutin Nikolic +ý Serial No: XXXXXXXXXXXXXX +ý Korisnik: Prava i Prevodi - prevodioci +ý +ý KONFIGURACIONI PODACI +ý Dozvoljeno slova u redu: 30 +ý Vremenska korekcija: 1.0000000000E+00 +ý Radjeno vremenskih korekcija: TRUE +ý Slovni raspored ASCIR +ý +ý Kraj info blocka."); + sb.AppendLine(); + foreach (Paragraph p in subtitle.Paragraphs) + { + var text = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont); + sb.AppendLine(string.Format(paragraphWriteFormat, MillisecondsToFrames(p.StartTime.TotalMilliseconds), MillisecondsToFrames(p.EndTime.TotalMilliseconds), text)); + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + Paragraph paragraph = null; + _errorCount = 0; + + subtitle.Paragraphs.Clear(); + foreach (string line in lines) + { + string s = line.Trim(); + if (RegexTimeCode.IsMatch(s)) + { + if (paragraph != null) + { + subtitle.Paragraphs.Add(paragraph); + } + + paragraph = new Paragraph(); + string[] parts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + if (parts.Length == 5) + { + try + { + paragraph.StartTime.TotalMilliseconds = FramesToMilliseconds(int.Parse(parts[0])); + paragraph.EndTime.TotalMilliseconds = FramesToMilliseconds(int.Parse(parts[1])); + } + catch + { + _errorCount++; + } + } + } + else if (paragraph != null && s.Length > 0) + { + paragraph.Text = (paragraph.Text + Environment.NewLine + s).Trim(); + if (paragraph.Text.Length > 2000) + { + _errorCount += 100; + return; + } + } + else if (s.Length > 0 && !s.StartsWith('ý')) + { + _errorCount++; + } + } + if (paragraph != null) + { + subtitle.Paragraphs.Add(paragraph); + } + + subtitle.Renumber(); + } + } +} diff --git a/libse/SubtitleFormats/TextST.cs b/src/libse/SubtitleFormats/TextST.cs similarity index 97% rename from libse/SubtitleFormats/TextST.cs rename to src/libse/SubtitleFormats/TextST.cs index 69864a6ed..dce658ae7 100644 --- a/libse/SubtitleFormats/TextST.cs +++ b/src/libse/SubtitleFormats/TextST.cs @@ -1,1189 +1,1189 @@ -using Nikse.SubtitleEdit.Core.BluRaySup; -using Nikse.SubtitleEdit.Core.ContainerFormats.TransportStream; -using Nikse.SubtitleEdit.Core.VobSub; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public static class StreamExtensions - { - - public static void WritePts(this Stream stream, ulong pts) - { - //TODO: check max - var buffer = BitConverter.GetBytes(pts); - if (BitConverter.IsLittleEndian) - { - stream.WriteByte(buffer[4]); - stream.WriteByte(buffer[3]); - stream.WriteByte(buffer[2]); - stream.WriteByte(buffer[1]); - stream.WriteByte(buffer[0]); - } - else - { - stream.WriteByte(buffer[buffer.Length - 1]); - stream.WriteByte(buffer[buffer.Length - 2]); - stream.WriteByte(buffer[buffer.Length - 3]); - stream.WriteByte(buffer[buffer.Length - 4]); - stream.WriteByte(buffer[buffer.Length - 5]); - } - } - - public static void WriteWord(this Stream stream, int value) - { - //TODO: check max - stream.WriteByte((byte)(value / 256)); - stream.WriteByte((byte)(value % 256)); - } - - public static void WriteWord(this Stream stream, int value, int firstBitValue) - { - //TODO: check max - var firstByte = (byte)(value / 256); - if (firstBitValue == 1) - { - firstByte = (byte)(firstByte | 0b10000000); - } - - stream.WriteByte(firstByte); - stream.WriteByte((byte)(value % 256)); - } - - public static void WriteByte(this Stream stream, int value, int firstBitValue) - { - //TODO: check max - var firstByte = (byte)(value); - if (firstBitValue == 1) - { - firstByte = (byte)(firstByte | 0b10000000); - } - - stream.WriteByte(firstByte); - } - } - - public class TextST : SubtitleFormat - { - public class Palette - { - public int PaletteEntryId { get; set; } - public int Y { get; set; } - public int Cr { get; set; } - public int Cb { get; set; } - public int T { get; set; } - - public Color Color - { - get - { - var arr = BluRaySupPalette.YCbCr2Rgb(Y, Cb, Cr, false); - return Color.FromArgb(T, arr[0], arr[1], arr[2]); - } - } - } - - public class RegionStyle - { - public RegionStyle() - { - } - - public RegionStyle(RegionStyle regionStyle) - { - RegionStyleId = regionStyle.RegionStyleId; - RegionHorizontalPosition = regionStyle.RegionHorizontalPosition; - RegionVerticalPosition = regionStyle.RegionVerticalPosition; - RegionWidth = regionStyle.RegionWidth; - RegionHeight = regionStyle.RegionHeight; - RegionBgPaletteEntryIdRef = regionStyle.RegionBgPaletteEntryIdRef; - TextBoxHorizontalPosition = regionStyle.TextBoxHorizontalPosition; - TextBoxVerticalPosition = regionStyle.TextBoxVerticalPosition; - TextBoxWidth = regionStyle.TextBoxWidth; - TextBoxHeight = regionStyle.TextBoxHeight; - TextFlow = regionStyle.TextFlow; - TextHorizontalAlignment = regionStyle.TextHorizontalAlignment; - TextVerticalAlignment = regionStyle.TextVerticalAlignment; - LineSpace = regionStyle.LineSpace; - FontIdRef = regionStyle.FontIdRef; - FontStyle = regionStyle.FontStyle; - FontSize = regionStyle.FontSize; - FontPaletteEntryIdRef = regionStyle.FontPaletteEntryIdRef; - FontOutlinePaletteEntryIdRef = regionStyle.FontOutlinePaletteEntryIdRef; - FontOutlineThickness = regionStyle.FontOutlineThickness; - } - - public int RegionStyleId { get; set; } - public int RegionHorizontalPosition { get; set; } - public int RegionVerticalPosition { get; set; } - public int RegionWidth { get; set; } - public int RegionHeight { get; set; } - public int RegionBgPaletteEntryIdRef { get; set; } - public int TextBoxHorizontalPosition { get; set; } - public int TextBoxVerticalPosition { get; set; } - public int TextBoxWidth { get; set; } - public int TextBoxHeight { get; set; } - public int TextFlow { get; set; } - public int TextHorizontalAlignment { get; set; } - public int TextVerticalAlignment { get; set; } - public int LineSpace { get; set; } - public int FontIdRef { get; set; } - public int FontStyle { get; set; } - public int FontSize { get; set; } - public int FontPaletteEntryIdRef { get; set; } - public int FontOutlinePaletteEntryIdRef { get; set; } - public int FontOutlineThickness { get; set; } - } - - public class UserStyle - { - public int UserStyleId { get; set; } - public int RegionHorizontalPositionDirection { get; set; } - public int RegionHorizontalPositionDelta { get; set; } - public int RegionVerticalPositionDirection { get; set; } - public int RegionVerticalPositionDelta { get; set; } - public int FontSizeIncDec { get; set; } - public int FontSizeDelta { get; set; } - public int TextBoxHorizontalPositionDirection { get; set; } - public int TextBoxHorizontalPositionDelta { get; set; } - public int TextBoxVerticalPositionDirection { get; set; } - public int TextBoxVerticalPositionDelta { get; set; } - public int TextBoxWidthIncDec { get; set; } - public int TextBoxWidthDelta { get; set; } - public int TextBoxHeightIncDec { get; set; } - public int TextBoxHeightDelta { get; set; } - public int LineSpaceIncDec { get; set; } - public int LineSpaceDelta { get; set; } - } - - public class DialogStyleSegment - { - public bool PlayerStyleFlag { get; set; } - public int NumberOfRegionStyles { get; set; } - public int NumberOfUserStyles { get; set; } - public List RegionStyles { get; set; } - public List UserStyles { get; set; } - public List Palettes { get; set; } - public int NumberOfDialogPresentationSegments { get; set; } - - public DialogStyleSegment() - { - PlayerStyleFlag = true; - RegionStyles = new List(); - UserStyles = new List(); - Palettes = new List(); - } - - public DialogStyleSegment(byte[] buffer) - { - PlayerStyleFlag = (buffer[9] & 0b10000000) > 0; - NumberOfRegionStyles = buffer[11]; - NumberOfUserStyles = buffer[12]; - - int idx = 13; - RegionStyles = new List(NumberOfRegionStyles); - for (int i = 0; i < NumberOfRegionStyles; i++) - { - var rs = new RegionStyle - { - RegionStyleId = buffer[idx], - RegionHorizontalPosition = (buffer[idx + 1] << 8) + buffer[idx + 2], - RegionVerticalPosition = (buffer[idx + 3] << 8) + buffer[idx + 4], - RegionWidth = (buffer[idx + 5] << 8) + buffer[idx + 6], - RegionHeight = (buffer[idx + 7] << 8) + buffer[idx + 8], - RegionBgPaletteEntryIdRef = buffer[idx + 9], - TextBoxHorizontalPosition = (buffer[idx + 11] << 8) + buffer[idx + 12], - TextBoxVerticalPosition = (buffer[idx + 13] << 8) + buffer[idx + 14], - TextBoxWidth = (buffer[idx + 15] << 8) + buffer[idx + 16], - TextBoxHeight = (buffer[idx + 17] << 8) + buffer[idx + 18], - TextFlow = buffer[idx + 19], - TextHorizontalAlignment = buffer[idx + 20], - TextVerticalAlignment = buffer[idx + 21], - LineSpace = buffer[idx + 22], - FontIdRef = buffer[idx + 23], - FontStyle = buffer[idx + 24], - FontSize = buffer[idx + 25], - FontPaletteEntryIdRef = buffer[idx + 26], - FontOutlinePaletteEntryIdRef = buffer[idx + 27], - FontOutlineThickness = buffer[idx + 28] - }; - RegionStyles.Add(rs); - idx += 29; - } - - UserStyles = new List(); - for (int j = 0; j < NumberOfUserStyles; j++) - { - var us = new UserStyle - { - UserStyleId = buffer[idx], - RegionHorizontalPositionDirection = buffer[idx + 1] >> 7, - RegionHorizontalPositionDelta = ((buffer[idx + 1] & 0b01111111) << 8) + buffer[idx + 2], - RegionVerticalPositionDirection = buffer[idx + 3] >> 7, - RegionVerticalPositionDelta = ((buffer[idx + 3] & 0b01111111) << 8) + buffer[idx + 4], - FontSizeIncDec = buffer[idx + 5] >> 7, - FontSizeDelta = (buffer[idx + 5] & 0b01111111), - TextBoxHorizontalPositionDirection = buffer[idx + 6] >> 7, - TextBoxHorizontalPositionDelta = ((buffer[idx + 6] & 0b01111111) << 8) + buffer[idx + 7], - TextBoxVerticalPositionDirection = buffer[idx + 8] >> 7, - TextBoxVerticalPositionDelta = ((buffer[idx + 8] & 0b01111111) << 8) + buffer[idx + 9], - TextBoxWidthIncDec = buffer[idx + 10] >> 7, - TextBoxWidthDelta = ((buffer[idx + 10] & 0b01111111) << 8) + buffer[idx + 11], - TextBoxHeightIncDec = buffer[idx + 12] >> 7, - TextBoxHeightDelta = ((buffer[idx + 12] & 0b01111111) << 8) + buffer[idx + 13], - LineSpaceIncDec = buffer[idx + 14] >> 7, - LineSpaceDelta = (buffer[idx + 14] & 0b01111111) - }; - UserStyles.Add(us); - idx += 15; - } - - int numberOfPalettees = ((buffer[idx] << 8) + buffer[idx + 1]) / 5; - Palettes = new List(numberOfPalettees); - idx += 2; - for (int i = 0; i < numberOfPalettees; i++) - { - var palette = new Palette - { - PaletteEntryId = buffer[idx], - Y = buffer[idx + 1], - Cr = buffer[idx + 2], - Cb = buffer[idx + 3], - T = buffer[idx + 4] - }; - Palettes.Add(palette); - idx += 5; - } - NumberOfDialogPresentationSegments = (buffer[idx] << 8) + buffer[idx + 1]; - } - - public void WriteToStream(Stream stream, int numberOfSubtitles) - { - NumberOfRegionStyles = RegionStyles.Count; - NumberOfUserStyles = UserStyles.Count; - - byte[] regionStyle = MakeRegionStyle(); - stream.Write(new byte[] { 0, 0, 1, 0xbf }, 0, 4); // MPEG-2 Private stream 2 - var size = regionStyle.Length + 5; - stream.WriteWord(size); - stream.WriteByte(SegmentTypeDialogStyle); // 0x81 - stream.WriteWord(size - 3); - stream.Write(regionStyle, 0, regionStyle.Length); - stream.WriteWord(numberOfSubtitles); - } - - private byte[] MakeRegionStyle() - { - using (var ms = new MemoryStream()) - { - if (PlayerStyleFlag) - { - ms.WriteByte(0b10000000); - } - else - { - ms.WriteByte(0); - } - - ms.WriteByte(0); // reserved? - ms.WriteByte((byte)NumberOfRegionStyles); - ms.WriteByte((byte)NumberOfUserStyles); - - foreach (var regionStyle in RegionStyles) - { - AddRegionStyle(ms, regionStyle); - } - - foreach (var userStyle in UserStyles) - { - AddUserStyle(ms, userStyle); - } - - ms.WriteWord(Palettes.Count * 5); - foreach (var palette in Palettes) - { - ms.WriteByte((byte)palette.PaletteEntryId); - ms.WriteByte((byte)palette.Y); - ms.WriteByte((byte)palette.Cb); - ms.WriteByte((byte)palette.Cr); - ms.WriteByte((byte)palette.T); - } - - return ms.ToArray(); - } - } - - private void AddUserStyle(Stream stream, UserStyle userStyle) - { - stream.WriteByte((byte)userStyle.UserStyleId); - stream.WriteWord(userStyle.RegionHorizontalPositionDelta, userStyle.RegionHorizontalPositionDirection); - stream.WriteWord(userStyle.RegionVerticalPositionDelta, userStyle.RegionVerticalPositionDirection); - stream.WriteByte(userStyle.FontSizeDelta, userStyle.FontSizeIncDec); - stream.WriteWord(userStyle.TextBoxHorizontalPositionDelta, userStyle.TextBoxHorizontalPositionDirection); - stream.WriteWord(userStyle.TextBoxVerticalPositionDelta, userStyle.TextBoxVerticalPositionDirection); - stream.WriteWord(userStyle.TextBoxWidthDelta, userStyle.TextBoxWidthIncDec); - stream.WriteWord(userStyle.TextBoxHeightDelta, userStyle.TextBoxHeightIncDec); - stream.WriteByte(userStyle.LineSpaceDelta, userStyle.LineSpaceIncDec); - } - - private static void AddRegionStyle(Stream stream, RegionStyle regionStyle) - { - stream.WriteByte((byte)regionStyle.RegionStyleId); - stream.WriteWord(regionStyle.RegionHorizontalPosition); - stream.WriteWord(regionStyle.RegionVerticalPosition); - stream.WriteWord(regionStyle.RegionWidth); - stream.WriteWord(regionStyle.RegionHeight); - stream.WriteByte((byte)regionStyle.RegionBgPaletteEntryIdRef); - stream.WriteByte(0); // reserved - stream.WriteWord(regionStyle.TextBoxHorizontalPosition); - stream.WriteWord(regionStyle.TextBoxVerticalPosition); - stream.WriteWord(regionStyle.TextBoxWidth); - stream.WriteWord(regionStyle.TextBoxHeight); - stream.WriteByte((byte)regionStyle.TextFlow); - stream.WriteByte((byte)regionStyle.TextHorizontalAlignment); - stream.WriteByte((byte)regionStyle.TextVerticalAlignment); - stream.WriteByte((byte)regionStyle.LineSpace); - stream.WriteByte((byte)regionStyle.FontIdRef); - stream.WriteByte((byte)regionStyle.FontStyle); - stream.WriteByte((byte)regionStyle.FontSize); - stream.WriteByte((byte)regionStyle.FontPaletteEntryIdRef); - stream.WriteByte((byte)regionStyle.FontOutlinePaletteEntryIdRef); - stream.WriteByte((byte)regionStyle.FontOutlineThickness); - } - - public static DialogStyleSegment DefaultDialogStyleSegment - { - get - { - var dss = new DialogStyleSegment(); - - dss.RegionStyles.Add(new RegionStyle - { - RegionStyleId = 0, - RegionHorizontalPosition = 100, - RegionVerticalPosition = 880, - RegionWidth = 1720, - RegionHeight = 200, - RegionBgPaletteEntryIdRef = 2, - TextBoxHorizontalPosition = 0, - TextBoxVerticalPosition = 880, - TextBoxWidth = 1719, - TextBoxHeight = 130, - TextFlow = 1, - TextHorizontalAlignment = 2, - TextVerticalAlignment = 1, - LineSpace = 70, - FontIdRef = 0, - FontStyle = 4, - FontSize = 45, - FontPaletteEntryIdRef = 3, - FontOutlinePaletteEntryIdRef = 1, - FontOutlineThickness = 2, - }); - dss.NumberOfRegionStyles = dss.RegionStyles.Count; - - dss.Palettes.Add(new Palette - { - PaletteEntryId = 0, - Y = 235, - Cr = 128, - Cb = 128, - T = 0 - }); - dss.Palettes.Add(new Palette - { - PaletteEntryId = 1, - Y = 16, - Cr = 128, - Cb = 128, - T = 255 - }); - dss.Palettes.Add(new Palette - { - PaletteEntryId = 2, - Y = 235, - Cr = 128, - Cb = 128, - T = 0 - }); - dss.Palettes.Add(new Palette - { - PaletteEntryId = 3, - Y = 235, - Cr = 128, - Cb = 128, - T = 255 - }); - dss.Palettes.Add(new Palette - { - PaletteEntryId = 254, - Y = 16, - Cr = 128, - Cb = 128, - T = 0 - }); - return dss; - } - } - } - - public abstract class SubtitleRegionContent - { - public int EscapeCode { get; set; } - public int DataType { get; set; } - public int DataLength { get; set; } - public string Name { get; set; } - public abstract void WriteExtraToStream(Stream stream); - } - - public class SubtitleRegionContentText : SubtitleRegionContent - { - private string _text; - - public string Text - { - get { return _text; } - set - { - DataLength = Encoding.UTF8.GetBytes(value).Length; - _text = value; - } - } - - public SubtitleRegionContentText() - { - EscapeCode = 27; - DataType = 1; - Name = "Text"; - } - - public override void WriteExtraToStream(Stream stream) - { - var buffer = Encoding.UTF8.GetBytes(Text); - stream.Write(buffer, 0, buffer.Length); - } - } - - public class SubtitleRegionContentChangeFontSet : SubtitleRegionContent - { - public int FontId { get; set; } - - public SubtitleRegionContentChangeFontSet() - { - EscapeCode = 27; - DataType = 2; - DataLength = 1; - Name = "Font set"; - } - - public override void WriteExtraToStream(Stream stream) - { - stream.WriteByte((byte)FontId); - } - } - - public class SubtitleRegionContentChangeFontStyle : SubtitleRegionContent - { - public int FontStyle { get; set; } - public int FontOutlinePaletteId { get; set; } - public int FontOutlineThickness { get; set; } - - public SubtitleRegionContentChangeFontStyle() - { - EscapeCode = 27; - DataType = 3; - DataLength = 3; - Name = "Font style"; - } - - public override void WriteExtraToStream(Stream stream) - { - stream.WriteByte((byte)FontStyle); - stream.WriteByte((byte)FontOutlinePaletteId); - stream.WriteByte((byte)FontOutlineThickness); - } - } - - public class SubtitleRegionContentChangeFontSize : SubtitleRegionContent - { - public int FontSize { get; set; } - - public SubtitleRegionContentChangeFontSize() - { - EscapeCode = 27; - DataType = 4; - DataLength = 1; - Name = "Font size"; - } - public override void WriteExtraToStream(Stream stream) - { - stream.WriteByte((byte)FontSize); - } - } - - public class SubtitleRegionContentChangeFontColor : SubtitleRegionContent - { - public int FontPaletteId { get; set; } - - public SubtitleRegionContentChangeFontColor() - { - EscapeCode = 27; - DataType = 5; - DataLength = 1; - Name = "Font color"; - } - public override void WriteExtraToStream(Stream stream) - { - stream.WriteByte((byte)FontPaletteId); - } - } - - public class SubtitleRegionContentLineBreak : SubtitleRegionContent - { - public SubtitleRegionContentLineBreak() - { - EscapeCode = 27; - DataType = 0x0a; - Name = "Line break"; - } - public override void WriteExtraToStream(Stream stream) - { - } - } - - public class SubtitleRegionContentEndOfInlineStyle : SubtitleRegionContent - { - public SubtitleRegionContentEndOfInlineStyle() - { - EscapeCode = 27; - DataType = 0x0b; - Name = "End of inline style"; - } - public override void WriteExtraToStream(Stream stream) - { - } - } - - public class SubtitleRegion - { - public bool ContinuousPresentation { get; set; } - public bool Forced { get; set; } - public int RegionStyleId { get; set; } - public List Texts { get; set; } - public List Content { get; set; } - } - - public class DialogPresentationSegment - { - public int Length { get; set; } - public UInt64 StartPts { get; set; } - public UInt64 EndPts { get; set; } - public bool PaletteUpdate { get; set; } - public List PaletteUpdates { get; set; } - public List Regions { get; set; } - - public DialogPresentationSegment(Paragraph paragraph, RegionStyle regionStyle) - { - StartPts = (ulong)Math.Round(paragraph.StartTime.TotalMilliseconds * 90.0); - EndPts = (ulong)Math.Round(paragraph.EndTime.TotalMilliseconds * 90.0); - PaletteUpdates = new List(); - Regions = new List - { - new SubtitleRegion - { - ContinuousPresentation = false, - Forced = false, - RegionStyleId = regionStyle.RegionStyleId, - Texts = new List(), - Content = new List() - } - }; - - var content = Regions[0].Content; - var lines = paragraph.Text.SplitToLines(); - var sb = new StringBuilder(); - bool italic = false; - bool bold = false; - for (int lineNumber = 0; lineNumber < lines.Count; lineNumber++) - { - string line = lines[lineNumber]; - if (lineNumber > 0) - { - if (italic || bold) - { - content.Add(new SubtitleRegionContentEndOfInlineStyle()); - } - content.Add(new SubtitleRegionContentLineBreak()); - if (italic && bold) - { - content.Add(new SubtitleRegionContentChangeFontStyle - { - FontStyle = 3, // bold and italic - FontOutlinePaletteId = regionStyle.FontOutlinePaletteEntryIdRef, - FontOutlineThickness = regionStyle.FontOutlineThickness - }); - } - else if (italic) - { - content.Add(new SubtitleRegionContentChangeFontStyle - { - FontStyle = 2, // italic - FontOutlinePaletteId = regionStyle.FontOutlinePaletteEntryIdRef, - FontOutlineThickness = regionStyle.FontOutlineThickness - }); - } - else if (bold) - { - content.Add(new SubtitleRegionContentChangeFontStyle - { - FontStyle = 1, // bold - FontOutlinePaletteId = regionStyle.FontOutlinePaletteEntryIdRef, - FontOutlineThickness = regionStyle.FontOutlineThickness - }); - } - } - int i = 0; - while (i < line.Length) - { - string s = line.Substring(i); - if (s.StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - italic = true; - if (content.Count > 0 && content[content.Count - 1] is SubtitleRegionContentChangeFontStyle) - { - content.RemoveAt(content.Count - 1); // Remove last style tag (italic/bold will be combined) - } - content.Add(new SubtitleRegionContentChangeFontStyle - { - FontStyle = bold ? 3 : 2, // italic - FontOutlinePaletteId = regionStyle.FontOutlinePaletteEntryIdRef, - FontOutlineThickness = regionStyle.FontOutlineThickness - }); - i += 3; - } - else if (s.StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - italic = false; - AddText(sb, content); - if (content.Count > 0 && content[content.Count - 1] is SubtitleRegionContentEndOfInlineStyle) - { - content.RemoveAt(content.Count - 1); // Remove last to avoid duplicated - } - content.Add(new SubtitleRegionContentEndOfInlineStyle()); - i += 4; - } - else if (s.StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - bold = true; - if (content.Count > 0 && content[content.Count - 1] is SubtitleRegionContentChangeFontStyle) - { - content.RemoveAt(content.Count - 1); // Remove last style tag (italic/bold will be combined) - } - content.Add(new SubtitleRegionContentChangeFontStyle - { - FontStyle = italic ? 3 : 1, // bold - FontOutlinePaletteId = regionStyle.FontOutlinePaletteEntryIdRef, - FontOutlineThickness = regionStyle.FontOutlineThickness - }); - i += 3; - } - else if (s.StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - bold = false; - AddText(sb, content); - if (content.Count > 0 && content[content.Count - 1] is SubtitleRegionContentEndOfInlineStyle) - { - content.RemoveAt(content.Count - 1); // Remove last to avoid duplicated - } - content.Add(new SubtitleRegionContentEndOfInlineStyle()); - i += 4; - } - else - { - i++; - sb.Append(s.Substring(0, 1)); - } - } - AddText(sb, content); - } - if (content.Count > 0 && content[content.Count - 1] is SubtitleRegionContentEndOfInlineStyle) - { - content.RemoveAt(content.Count - 1); // last 'end-of-inline-style' not needed - } - } - - private static void AddText(StringBuilder sb, List content) - { - if (sb.Length > 0) - { - string text = HtmlUtil.RemoveHtmlTags(sb.ToString(), true); - content.Add(new SubtitleRegionContentText - { - Text = text, - DataLength = Encoding.UTF8.GetBytes(text).Length - }); - sb.Clear(); - } - } - - public DialogPresentationSegment(byte[] buffer, int index) - { - int idx = index; - StartPts = buffer[idx + 13]; - StartPts += (ulong)buffer[idx + 12] << 8; - StartPts += (ulong)buffer[idx + 11] << 16; - StartPts += (ulong)buffer[idx + 10] << 24; - StartPts += (ulong)(buffer[idx + 9] & 0b00000001) << 32; - - EndPts = buffer[idx + 18]; - EndPts += (ulong)buffer[idx + 17] << 8; - EndPts += (ulong)buffer[idx + 16] << 16; - EndPts += (ulong)buffer[idx + 15] << 24; - EndPts += (ulong)(buffer[idx + 14] & 0b00000001) << 32; - - PaletteUpdate = (buffer[idx + 19] & 0b10000000) > 0; - idx += 20; - PaletteUpdates = new List(); - if (PaletteUpdate) - { - int numberOfPaletteEntries = buffer[idx + 21] + (buffer[idx + 20] << 8); - for (int i = 0; i < numberOfPaletteEntries; i++) - { - PaletteUpdates.Add(new Palette - { - PaletteEntryId = buffer[idx++], - Y = buffer[idx++], - Cr = buffer[idx++], - Cb = buffer[idx++], - T = buffer[idx++] - }); - } - } - - int numberOfRegions = buffer[idx++]; - Regions = new List(numberOfRegions); - for (int i = 0; i < numberOfRegions; i++) - { - var region = new SubtitleRegion { ContinuousPresentation = (buffer[idx] & 0b10000000) > 0, Forced = (buffer[idx] & 0b01000000) > 0 }; - idx++; - region.RegionStyleId = buffer[idx++]; - int regionSubtitleLength = buffer[idx + 1] + (buffer[idx] << 8); - idx += 2; - int processedLength = 0; - region.Texts = new List(); - region.Content = new List(); - string endStyle = string.Empty; - while (processedLength < regionSubtitleLength) - { - byte escapeCode = buffer[idx++]; - byte dataType = buffer[idx++]; - byte dataLength = buffer[idx++]; - processedLength += 3; - if (dataType == 0x01) // Text - { - string text = Encoding.UTF8.GetString(buffer, idx, dataLength); - region.Texts.Add(text); - region.Content.Add(new SubtitleRegionContentText - { - EscapeCode = escapeCode, - DataType = dataType, - DataLength = dataLength, - Text = text - }); - } - else if (dataType == 0x02) // Change a font set - { - region.Content.Add(new SubtitleRegionContentChangeFontSet - { - EscapeCode = escapeCode, - DataType = dataType, - DataLength = dataLength, - FontId = buffer[idx] - }); - } - else if (dataType == 0x03) // Change a font style - { - var fontStyle = buffer[idx]; - var fontOutlinePaletteId = buffer[idx + 1]; - var fontOutlineThickness = buffer[idx + 2]; - switch (fontStyle) - { - case 1: - region.Texts.Add(""); - endStyle = ""; - break; - case 2: - region.Texts.Add(""); - endStyle = ""; - break; - case 3: - region.Texts.Add(""); - endStyle = ""; - break; - case 5: - region.Texts.Add(""); - endStyle = ""; - break; - case 6: - region.Texts.Add(""); - endStyle = ""; - break; - case 7: - region.Texts.Add(""); - endStyle = ""; - break; - } - region.Content.Add(new SubtitleRegionContentChangeFontStyle - { - EscapeCode = escapeCode, - DataType = dataType, - DataLength = dataLength, - FontStyle = fontStyle, - FontOutlinePaletteId = fontOutlinePaletteId, - FontOutlineThickness = fontOutlineThickness - }); - } - else if (dataType == 0x04) // Change a font size - { - region.Content.Add(new SubtitleRegionContentChangeFontSize - { - EscapeCode = escapeCode, - DataType = dataType, - DataLength = dataLength, - FontSize = buffer[idx] - }); - } - else if (dataType == 0x05) // Change a font color - { - region.Content.Add(new SubtitleRegionContentChangeFontColor - { - EscapeCode = escapeCode, - DataType = dataType, - DataLength = dataLength, - FontPaletteId = buffer[idx] - }); - } - else if (dataType == 0x0A) // Line break - { - region.Texts.Add(Environment.NewLine); - region.Content.Add(new SubtitleRegionContentLineBreak - { - EscapeCode = escapeCode, - DataType = dataType, - DataLength = dataLength, - }); - } - else if (dataType == 0x0B) // End of inline style - { - if (!string.IsNullOrEmpty(endStyle)) - { - region.Texts.Add(endStyle); - endStyle = string.Empty; - } - region.Content.Add(new SubtitleRegionContentEndOfInlineStyle - { - EscapeCode = escapeCode, - DataType = dataType, - DataLength = dataLength, - }); - } - processedLength += dataLength; - idx += dataLength; - } - if (!string.IsNullOrEmpty(endStyle)) - { - region.Texts.Add(endStyle); - } - Regions.Add(region); - } - } - - public string Text - { - get - { - var sb = new StringBuilder(); - foreach (var region in Regions) - { - foreach (string text in region.Texts) - { - sb.Append(text); - } - } - return sb.ToString(); - } - } - - public ulong StartPtsMilliseconds => (ulong)Math.Round((StartPts) / 90.0); - - public ulong EndPtsMilliseconds => (ulong)Math.Round((EndPts) / 90.0); - - public void WriteToStream(Stream stream) - { - byte[] regionSubtitle = MakeSubtitleRegions(); - stream.Write(new byte[] { 0, 0, 1, 0xbf }, 0, 4); // MPEG-2 Private stream 2 - int size = regionSubtitle.Length + 15; - stream.WriteWord(size); - stream.WriteByte(SegmentTypeDialogPresentation); // 0x82 - stream.WriteWord(size - 3); - stream.WritePts(StartPts); - stream.WritePts(EndPts); - if (PaletteUpdate) - { - stream.WriteWord(PaletteUpdates.Count); - foreach (var palette in PaletteUpdates) - { - stream.WriteByte((byte)palette.PaletteEntryId); - stream.WriteByte((byte)palette.Y); - stream.WriteByte((byte)palette.Cb); - stream.WriteByte((byte)palette.Cr); - stream.WriteByte((byte)palette.T); - } - } - else - { - stream.WriteByte(0); // 1 bit = palette update (0=no update), next 7 bits reserved - } - stream.WriteByte((byte)Regions.Count); // number of regions - - stream.Write(regionSubtitle, 0, regionSubtitle.Length); - } - - private byte[] MakeSubtitleRegions() - { - using (var ms = new MemoryStream()) - { - foreach (var subtitleRegion in Regions) - { - byte flags = 0; - if (subtitleRegion.ContinuousPresentation) - { - flags = (byte)(flags | 0b10000000); - } - - if (subtitleRegion.Forced) - { - flags = (byte)(flags | 0b01000000); - } - - ms.WriteByte(flags); // first byte=continuous_present_flag, second byte=force, next 6 bits reserved - - ms.WriteByte((byte)subtitleRegion.RegionStyleId); - var contentBuffer = MakeSubtitleRegionContent(subtitleRegion); - ms.WriteWord(contentBuffer.Length); // set region subtitle size field - ms.Write(contentBuffer, 0, contentBuffer.Length); - } - return ms.ToArray(); - } - } - - private static byte[] MakeSubtitleRegionContent(SubtitleRegion subtitleRegion) - { - using (var ms = new MemoryStream()) - { - foreach (var content in subtitleRegion.Content) - { - ms.WriteByte((byte)content.EscapeCode); // escape code (0x1b / 27) - ms.WriteByte((byte)content.DataType); - ms.WriteByte((byte)content.DataLength); - content.WriteExtraToStream(ms); - } - return ms.ToArray(); - } - } - } - - public DialogStyleSegment StyleSegment; - public List PresentationSegments; - - private const int TextSubtitleStreamPid = 0x1800; - private const byte SegmentTypeDialogStyle = 0x81; - private const byte SegmentTypeDialogPresentation = 0x82; - - public override string Extension => ".m2ts"; - - public override string Name => "Blu-ray TextST"; - - public override bool IsMine(List lines, string fileName) - { - if (string.IsNullOrEmpty(fileName)) - { - return false; - } - - if (fileName.EndsWith(".m2ts", StringComparison.OrdinalIgnoreCase) && FileUtil.IsM2TransportStream(fileName) || - fileName.EndsWith(".textst", StringComparison.OrdinalIgnoreCase) && FileUtil.IsMpeg2PrivateStream2(fileName)) - { - return base.IsMine(lines, fileName); - } - return false; - } - - public override string ToText(Subtitle subtitle, string title) - { - throw new NotImplementedException(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - if (FileUtil.IsMpeg2PrivateStream2(fileName)) - { - using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - LoadSubtitleFromMpeg2PesPackets(subtitle, fs); - } - } - else - { - using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - LoadSubtitleFromM2Ts(subtitle, fs); - } - } - subtitle.Renumber(); - } - - private void LoadSubtitleFromMpeg2PesPackets(Subtitle subtitle, Stream stream) - { - long position = 0; - stream.Position = 0; - stream.Seek(position, SeekOrigin.Begin); - long streamLength = stream.Length; - var buffer = new byte[512]; - PresentationSegments = new List(); - while (position < streamLength) - { - stream.Seek(position, SeekOrigin.Begin); - int bytesRead = stream.Read(buffer, 0, buffer.Length); - if (bytesRead < 20) - { - break; - } - - int size = (buffer[4] << 8) + buffer[5] + 6; - position += size; - - if (bytesRead > 10 && VobSubParser.IsPrivateStream2(buffer, 0)) - { - if (buffer[6] == SegmentTypeDialogPresentation) - { - var dps = new DialogPresentationSegment(buffer, 0); - PresentationSegments.Add(dps); - subtitle.Paragraphs.Add(new Paragraph(dps.Text.Trim(), dps.StartPtsMilliseconds, dps.EndPtsMilliseconds)); - } - else if (buffer[6] == SegmentTypeDialogStyle) - { - StyleSegment = new DialogStyleSegment(buffer); - } - } - } - } - - private void LoadSubtitleFromM2Ts(Subtitle subtitle, Stream ms) - { - var subtitlePackets = new List(); - const int packetLength = 188; - bool isM2TransportStream = DetectFormat(ms); - var packetBuffer = new byte[packetLength]; - var m2TsTimeCodeBuffer = new byte[4]; - long position = 0; - ms.Position = 0; - - // check for Topfield .rec file - ms.Seek(position, SeekOrigin.Begin); - ms.Read(m2TsTimeCodeBuffer, 0, 3); - if (m2TsTimeCodeBuffer[0] == 0x54 && m2TsTimeCodeBuffer[1] == 0x46 && m2TsTimeCodeBuffer[2] == 0x72) - { - position = 3760; - } - - long transportStreamLength = ms.Length; - ms.Seek(position, SeekOrigin.Begin); - while (position < transportStreamLength) - { - if (isM2TransportStream) - { - var m2TsHeaderBytesRead = ms.Read(m2TsTimeCodeBuffer, 0, m2TsTimeCodeBuffer.Length); - if (m2TsHeaderBytesRead < m2TsTimeCodeBuffer.Length) - { - break; // incomplete m2ts header - } - position += m2TsTimeCodeBuffer.Length; - } - - var packetBytesRead = ms.Read(packetBuffer, 0, packetLength); - if (packetBytesRead < packetLength) - { - break; // incomplete packet - } - - byte syncByte = packetBuffer[0]; - if (syncByte == Packet.SynchronizationByte) - { - var packet = new Packet(packetBuffer); - if (packet.PacketId == TextSubtitleStreamPid) - { - subtitlePackets.Add(packet); - } - position += packetLength; - } - else - { - if (isM2TransportStream) - { - position -= m2TsTimeCodeBuffer.Length; - } - position++; - ms.Seek(position, SeekOrigin.Begin); - } - } - - //TODO: merge ts packets - - PresentationSegments = new List(); - foreach (var item in subtitlePackets) - { - if (item.Payload != null && item.Payload.Length > 10 && VobSubParser.IsPrivateStream2(item.Payload, 0)) - { - if (item.Payload[6] == SegmentTypeDialogPresentation) - { - var dps = new DialogPresentationSegment(item.Payload, 0); - PresentationSegments.Add(dps); - subtitle.Paragraphs.Add(new Paragraph(dps.Text.Trim(), dps.StartPtsMilliseconds, dps.EndPtsMilliseconds)); - } - else if (item.Payload[6] == SegmentTypeDialogStyle) - { - StyleSegment = new DialogStyleSegment(item.Payload); - } - } - } - - subtitle.Renumber(); - } - - private static bool DetectFormat(Stream ms) - { - if (ms.Length > 192 + 192 + 5) - { - ms.Seek(0, SeekOrigin.Begin); - var buffer = new byte[192 + 192 + 5]; - ms.Read(buffer, 0, buffer.Length); - if (buffer[0] == Packet.SynchronizationByte && buffer[188] == Packet.SynchronizationByte) - { - return false; - } - - if (buffer[4] == Packet.SynchronizationByte && buffer[192 + 4] == Packet.SynchronizationByte && buffer[192 + 192 + 4] == Packet.SynchronizationByte) - { - return true; - } - } - return false; - } - } -} +using Nikse.SubtitleEdit.Core.BluRaySup; +using Nikse.SubtitleEdit.Core.ContainerFormats.TransportStream; +using Nikse.SubtitleEdit.Core.VobSub; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public static class StreamExtensions + { + + public static void WritePts(this Stream stream, ulong pts) + { + //TODO: check max + var buffer = BitConverter.GetBytes(pts); + if (BitConverter.IsLittleEndian) + { + stream.WriteByte(buffer[4]); + stream.WriteByte(buffer[3]); + stream.WriteByte(buffer[2]); + stream.WriteByte(buffer[1]); + stream.WriteByte(buffer[0]); + } + else + { + stream.WriteByte(buffer[buffer.Length - 1]); + stream.WriteByte(buffer[buffer.Length - 2]); + stream.WriteByte(buffer[buffer.Length - 3]); + stream.WriteByte(buffer[buffer.Length - 4]); + stream.WriteByte(buffer[buffer.Length - 5]); + } + } + + public static void WriteWord(this Stream stream, int value) + { + //TODO: check max + stream.WriteByte((byte)(value / 256)); + stream.WriteByte((byte)(value % 256)); + } + + public static void WriteWord(this Stream stream, int value, int firstBitValue) + { + //TODO: check max + var firstByte = (byte)(value / 256); + if (firstBitValue == 1) + { + firstByte = (byte)(firstByte | 0b10000000); + } + + stream.WriteByte(firstByte); + stream.WriteByte((byte)(value % 256)); + } + + public static void WriteByte(this Stream stream, int value, int firstBitValue) + { + //TODO: check max + var firstByte = (byte)(value); + if (firstBitValue == 1) + { + firstByte = (byte)(firstByte | 0b10000000); + } + + stream.WriteByte(firstByte); + } + } + + public class TextST : SubtitleFormat + { + public class Palette + { + public int PaletteEntryId { get; set; } + public int Y { get; set; } + public int Cr { get; set; } + public int Cb { get; set; } + public int T { get; set; } + + public Color Color + { + get + { + var arr = BluRaySupPalette.YCbCr2Rgb(Y, Cb, Cr, false); + return Color.FromArgb(T, arr[0], arr[1], arr[2]); + } + } + } + + public class RegionStyle + { + public RegionStyle() + { + } + + public RegionStyle(RegionStyle regionStyle) + { + RegionStyleId = regionStyle.RegionStyleId; + RegionHorizontalPosition = regionStyle.RegionHorizontalPosition; + RegionVerticalPosition = regionStyle.RegionVerticalPosition; + RegionWidth = regionStyle.RegionWidth; + RegionHeight = regionStyle.RegionHeight; + RegionBgPaletteEntryIdRef = regionStyle.RegionBgPaletteEntryIdRef; + TextBoxHorizontalPosition = regionStyle.TextBoxHorizontalPosition; + TextBoxVerticalPosition = regionStyle.TextBoxVerticalPosition; + TextBoxWidth = regionStyle.TextBoxWidth; + TextBoxHeight = regionStyle.TextBoxHeight; + TextFlow = regionStyle.TextFlow; + TextHorizontalAlignment = regionStyle.TextHorizontalAlignment; + TextVerticalAlignment = regionStyle.TextVerticalAlignment; + LineSpace = regionStyle.LineSpace; + FontIdRef = regionStyle.FontIdRef; + FontStyle = regionStyle.FontStyle; + FontSize = regionStyle.FontSize; + FontPaletteEntryIdRef = regionStyle.FontPaletteEntryIdRef; + FontOutlinePaletteEntryIdRef = regionStyle.FontOutlinePaletteEntryIdRef; + FontOutlineThickness = regionStyle.FontOutlineThickness; + } + + public int RegionStyleId { get; set; } + public int RegionHorizontalPosition { get; set; } + public int RegionVerticalPosition { get; set; } + public int RegionWidth { get; set; } + public int RegionHeight { get; set; } + public int RegionBgPaletteEntryIdRef { get; set; } + public int TextBoxHorizontalPosition { get; set; } + public int TextBoxVerticalPosition { get; set; } + public int TextBoxWidth { get; set; } + public int TextBoxHeight { get; set; } + public int TextFlow { get; set; } + public int TextHorizontalAlignment { get; set; } + public int TextVerticalAlignment { get; set; } + public int LineSpace { get; set; } + public int FontIdRef { get; set; } + public int FontStyle { get; set; } + public int FontSize { get; set; } + public int FontPaletteEntryIdRef { get; set; } + public int FontOutlinePaletteEntryIdRef { get; set; } + public int FontOutlineThickness { get; set; } + } + + public class UserStyle + { + public int UserStyleId { get; set; } + public int RegionHorizontalPositionDirection { get; set; } + public int RegionHorizontalPositionDelta { get; set; } + public int RegionVerticalPositionDirection { get; set; } + public int RegionVerticalPositionDelta { get; set; } + public int FontSizeIncDec { get; set; } + public int FontSizeDelta { get; set; } + public int TextBoxHorizontalPositionDirection { get; set; } + public int TextBoxHorizontalPositionDelta { get; set; } + public int TextBoxVerticalPositionDirection { get; set; } + public int TextBoxVerticalPositionDelta { get; set; } + public int TextBoxWidthIncDec { get; set; } + public int TextBoxWidthDelta { get; set; } + public int TextBoxHeightIncDec { get; set; } + public int TextBoxHeightDelta { get; set; } + public int LineSpaceIncDec { get; set; } + public int LineSpaceDelta { get; set; } + } + + public class DialogStyleSegment + { + public bool PlayerStyleFlag { get; set; } + public int NumberOfRegionStyles { get; set; } + public int NumberOfUserStyles { get; set; } + public List RegionStyles { get; set; } + public List UserStyles { get; set; } + public List Palettes { get; set; } + public int NumberOfDialogPresentationSegments { get; set; } + + public DialogStyleSegment() + { + PlayerStyleFlag = true; + RegionStyles = new List(); + UserStyles = new List(); + Palettes = new List(); + } + + public DialogStyleSegment(byte[] buffer) + { + PlayerStyleFlag = (buffer[9] & 0b10000000) > 0; + NumberOfRegionStyles = buffer[11]; + NumberOfUserStyles = buffer[12]; + + int idx = 13; + RegionStyles = new List(NumberOfRegionStyles); + for (int i = 0; i < NumberOfRegionStyles; i++) + { + var rs = new RegionStyle + { + RegionStyleId = buffer[idx], + RegionHorizontalPosition = (buffer[idx + 1] << 8) + buffer[idx + 2], + RegionVerticalPosition = (buffer[idx + 3] << 8) + buffer[idx + 4], + RegionWidth = (buffer[idx + 5] << 8) + buffer[idx + 6], + RegionHeight = (buffer[idx + 7] << 8) + buffer[idx + 8], + RegionBgPaletteEntryIdRef = buffer[idx + 9], + TextBoxHorizontalPosition = (buffer[idx + 11] << 8) + buffer[idx + 12], + TextBoxVerticalPosition = (buffer[idx + 13] << 8) + buffer[idx + 14], + TextBoxWidth = (buffer[idx + 15] << 8) + buffer[idx + 16], + TextBoxHeight = (buffer[idx + 17] << 8) + buffer[idx + 18], + TextFlow = buffer[idx + 19], + TextHorizontalAlignment = buffer[idx + 20], + TextVerticalAlignment = buffer[idx + 21], + LineSpace = buffer[idx + 22], + FontIdRef = buffer[idx + 23], + FontStyle = buffer[idx + 24], + FontSize = buffer[idx + 25], + FontPaletteEntryIdRef = buffer[idx + 26], + FontOutlinePaletteEntryIdRef = buffer[idx + 27], + FontOutlineThickness = buffer[idx + 28] + }; + RegionStyles.Add(rs); + idx += 29; + } + + UserStyles = new List(); + for (int j = 0; j < NumberOfUserStyles; j++) + { + var us = new UserStyle + { + UserStyleId = buffer[idx], + RegionHorizontalPositionDirection = buffer[idx + 1] >> 7, + RegionHorizontalPositionDelta = ((buffer[idx + 1] & 0b01111111) << 8) + buffer[idx + 2], + RegionVerticalPositionDirection = buffer[idx + 3] >> 7, + RegionVerticalPositionDelta = ((buffer[idx + 3] & 0b01111111) << 8) + buffer[idx + 4], + FontSizeIncDec = buffer[idx + 5] >> 7, + FontSizeDelta = (buffer[idx + 5] & 0b01111111), + TextBoxHorizontalPositionDirection = buffer[idx + 6] >> 7, + TextBoxHorizontalPositionDelta = ((buffer[idx + 6] & 0b01111111) << 8) + buffer[idx + 7], + TextBoxVerticalPositionDirection = buffer[idx + 8] >> 7, + TextBoxVerticalPositionDelta = ((buffer[idx + 8] & 0b01111111) << 8) + buffer[idx + 9], + TextBoxWidthIncDec = buffer[idx + 10] >> 7, + TextBoxWidthDelta = ((buffer[idx + 10] & 0b01111111) << 8) + buffer[idx + 11], + TextBoxHeightIncDec = buffer[idx + 12] >> 7, + TextBoxHeightDelta = ((buffer[idx + 12] & 0b01111111) << 8) + buffer[idx + 13], + LineSpaceIncDec = buffer[idx + 14] >> 7, + LineSpaceDelta = (buffer[idx + 14] & 0b01111111) + }; + UserStyles.Add(us); + idx += 15; + } + + int numberOfPalettees = ((buffer[idx] << 8) + buffer[idx + 1]) / 5; + Palettes = new List(numberOfPalettees); + idx += 2; + for (int i = 0; i < numberOfPalettees; i++) + { + var palette = new Palette + { + PaletteEntryId = buffer[idx], + Y = buffer[idx + 1], + Cr = buffer[idx + 2], + Cb = buffer[idx + 3], + T = buffer[idx + 4] + }; + Palettes.Add(palette); + idx += 5; + } + NumberOfDialogPresentationSegments = (buffer[idx] << 8) + buffer[idx + 1]; + } + + public void WriteToStream(Stream stream, int numberOfSubtitles) + { + NumberOfRegionStyles = RegionStyles.Count; + NumberOfUserStyles = UserStyles.Count; + + byte[] regionStyle = MakeRegionStyle(); + stream.Write(new byte[] { 0, 0, 1, 0xbf }, 0, 4); // MPEG-2 Private stream 2 + var size = regionStyle.Length + 5; + stream.WriteWord(size); + stream.WriteByte(SegmentTypeDialogStyle); // 0x81 + stream.WriteWord(size - 3); + stream.Write(regionStyle, 0, regionStyle.Length); + stream.WriteWord(numberOfSubtitles); + } + + private byte[] MakeRegionStyle() + { + using (var ms = new MemoryStream()) + { + if (PlayerStyleFlag) + { + ms.WriteByte(0b10000000); + } + else + { + ms.WriteByte(0); + } + + ms.WriteByte(0); // reserved? + ms.WriteByte((byte)NumberOfRegionStyles); + ms.WriteByte((byte)NumberOfUserStyles); + + foreach (var regionStyle in RegionStyles) + { + AddRegionStyle(ms, regionStyle); + } + + foreach (var userStyle in UserStyles) + { + AddUserStyle(ms, userStyle); + } + + ms.WriteWord(Palettes.Count * 5); + foreach (var palette in Palettes) + { + ms.WriteByte((byte)palette.PaletteEntryId); + ms.WriteByte((byte)palette.Y); + ms.WriteByte((byte)palette.Cb); + ms.WriteByte((byte)palette.Cr); + ms.WriteByte((byte)palette.T); + } + + return ms.ToArray(); + } + } + + private void AddUserStyle(Stream stream, UserStyle userStyle) + { + stream.WriteByte((byte)userStyle.UserStyleId); + stream.WriteWord(userStyle.RegionHorizontalPositionDelta, userStyle.RegionHorizontalPositionDirection); + stream.WriteWord(userStyle.RegionVerticalPositionDelta, userStyle.RegionVerticalPositionDirection); + stream.WriteByte(userStyle.FontSizeDelta, userStyle.FontSizeIncDec); + stream.WriteWord(userStyle.TextBoxHorizontalPositionDelta, userStyle.TextBoxHorizontalPositionDirection); + stream.WriteWord(userStyle.TextBoxVerticalPositionDelta, userStyle.TextBoxVerticalPositionDirection); + stream.WriteWord(userStyle.TextBoxWidthDelta, userStyle.TextBoxWidthIncDec); + stream.WriteWord(userStyle.TextBoxHeightDelta, userStyle.TextBoxHeightIncDec); + stream.WriteByte(userStyle.LineSpaceDelta, userStyle.LineSpaceIncDec); + } + + private static void AddRegionStyle(Stream stream, RegionStyle regionStyle) + { + stream.WriteByte((byte)regionStyle.RegionStyleId); + stream.WriteWord(regionStyle.RegionHorizontalPosition); + stream.WriteWord(regionStyle.RegionVerticalPosition); + stream.WriteWord(regionStyle.RegionWidth); + stream.WriteWord(regionStyle.RegionHeight); + stream.WriteByte((byte)regionStyle.RegionBgPaletteEntryIdRef); + stream.WriteByte(0); // reserved + stream.WriteWord(regionStyle.TextBoxHorizontalPosition); + stream.WriteWord(regionStyle.TextBoxVerticalPosition); + stream.WriteWord(regionStyle.TextBoxWidth); + stream.WriteWord(regionStyle.TextBoxHeight); + stream.WriteByte((byte)regionStyle.TextFlow); + stream.WriteByte((byte)regionStyle.TextHorizontalAlignment); + stream.WriteByte((byte)regionStyle.TextVerticalAlignment); + stream.WriteByte((byte)regionStyle.LineSpace); + stream.WriteByte((byte)regionStyle.FontIdRef); + stream.WriteByte((byte)regionStyle.FontStyle); + stream.WriteByte((byte)regionStyle.FontSize); + stream.WriteByte((byte)regionStyle.FontPaletteEntryIdRef); + stream.WriteByte((byte)regionStyle.FontOutlinePaletteEntryIdRef); + stream.WriteByte((byte)regionStyle.FontOutlineThickness); + } + + public static DialogStyleSegment DefaultDialogStyleSegment + { + get + { + var dss = new DialogStyleSegment(); + + dss.RegionStyles.Add(new RegionStyle + { + RegionStyleId = 0, + RegionHorizontalPosition = 100, + RegionVerticalPosition = 880, + RegionWidth = 1720, + RegionHeight = 200, + RegionBgPaletteEntryIdRef = 2, + TextBoxHorizontalPosition = 0, + TextBoxVerticalPosition = 880, + TextBoxWidth = 1719, + TextBoxHeight = 130, + TextFlow = 1, + TextHorizontalAlignment = 2, + TextVerticalAlignment = 1, + LineSpace = 70, + FontIdRef = 0, + FontStyle = 4, + FontSize = 45, + FontPaletteEntryIdRef = 3, + FontOutlinePaletteEntryIdRef = 1, + FontOutlineThickness = 2, + }); + dss.NumberOfRegionStyles = dss.RegionStyles.Count; + + dss.Palettes.Add(new Palette + { + PaletteEntryId = 0, + Y = 235, + Cr = 128, + Cb = 128, + T = 0 + }); + dss.Palettes.Add(new Palette + { + PaletteEntryId = 1, + Y = 16, + Cr = 128, + Cb = 128, + T = 255 + }); + dss.Palettes.Add(new Palette + { + PaletteEntryId = 2, + Y = 235, + Cr = 128, + Cb = 128, + T = 0 + }); + dss.Palettes.Add(new Palette + { + PaletteEntryId = 3, + Y = 235, + Cr = 128, + Cb = 128, + T = 255 + }); + dss.Palettes.Add(new Palette + { + PaletteEntryId = 254, + Y = 16, + Cr = 128, + Cb = 128, + T = 0 + }); + return dss; + } + } + } + + public abstract class SubtitleRegionContent + { + public int EscapeCode { get; set; } + public int DataType { get; set; } + public int DataLength { get; set; } + public string Name { get; set; } + public abstract void WriteExtraToStream(Stream stream); + } + + public class SubtitleRegionContentText : SubtitleRegionContent + { + private string _text; + + public string Text + { + get { return _text; } + set + { + DataLength = Encoding.UTF8.GetBytes(value).Length; + _text = value; + } + } + + public SubtitleRegionContentText() + { + EscapeCode = 27; + DataType = 1; + Name = "Text"; + } + + public override void WriteExtraToStream(Stream stream) + { + var buffer = Encoding.UTF8.GetBytes(Text); + stream.Write(buffer, 0, buffer.Length); + } + } + + public class SubtitleRegionContentChangeFontSet : SubtitleRegionContent + { + public int FontId { get; set; } + + public SubtitleRegionContentChangeFontSet() + { + EscapeCode = 27; + DataType = 2; + DataLength = 1; + Name = "Font set"; + } + + public override void WriteExtraToStream(Stream stream) + { + stream.WriteByte((byte)FontId); + } + } + + public class SubtitleRegionContentChangeFontStyle : SubtitleRegionContent + { + public int FontStyle { get; set; } + public int FontOutlinePaletteId { get; set; } + public int FontOutlineThickness { get; set; } + + public SubtitleRegionContentChangeFontStyle() + { + EscapeCode = 27; + DataType = 3; + DataLength = 3; + Name = "Font style"; + } + + public override void WriteExtraToStream(Stream stream) + { + stream.WriteByte((byte)FontStyle); + stream.WriteByte((byte)FontOutlinePaletteId); + stream.WriteByte((byte)FontOutlineThickness); + } + } + + public class SubtitleRegionContentChangeFontSize : SubtitleRegionContent + { + public int FontSize { get; set; } + + public SubtitleRegionContentChangeFontSize() + { + EscapeCode = 27; + DataType = 4; + DataLength = 1; + Name = "Font size"; + } + public override void WriteExtraToStream(Stream stream) + { + stream.WriteByte((byte)FontSize); + } + } + + public class SubtitleRegionContentChangeFontColor : SubtitleRegionContent + { + public int FontPaletteId { get; set; } + + public SubtitleRegionContentChangeFontColor() + { + EscapeCode = 27; + DataType = 5; + DataLength = 1; + Name = "Font color"; + } + public override void WriteExtraToStream(Stream stream) + { + stream.WriteByte((byte)FontPaletteId); + } + } + + public class SubtitleRegionContentLineBreak : SubtitleRegionContent + { + public SubtitleRegionContentLineBreak() + { + EscapeCode = 27; + DataType = 0x0a; + Name = "Line break"; + } + public override void WriteExtraToStream(Stream stream) + { + } + } + + public class SubtitleRegionContentEndOfInlineStyle : SubtitleRegionContent + { + public SubtitleRegionContentEndOfInlineStyle() + { + EscapeCode = 27; + DataType = 0x0b; + Name = "End of inline style"; + } + public override void WriteExtraToStream(Stream stream) + { + } + } + + public class SubtitleRegion + { + public bool ContinuousPresentation { get; set; } + public bool Forced { get; set; } + public int RegionStyleId { get; set; } + public List Texts { get; set; } + public List Content { get; set; } + } + + public class DialogPresentationSegment + { + public int Length { get; set; } + public UInt64 StartPts { get; set; } + public UInt64 EndPts { get; set; } + public bool PaletteUpdate { get; set; } + public List PaletteUpdates { get; set; } + public List Regions { get; set; } + + public DialogPresentationSegment(Paragraph paragraph, RegionStyle regionStyle) + { + StartPts = (ulong)Math.Round(paragraph.StartTime.TotalMilliseconds * 90.0); + EndPts = (ulong)Math.Round(paragraph.EndTime.TotalMilliseconds * 90.0); + PaletteUpdates = new List(); + Regions = new List + { + new SubtitleRegion + { + ContinuousPresentation = false, + Forced = false, + RegionStyleId = regionStyle.RegionStyleId, + Texts = new List(), + Content = new List() + } + }; + + var content = Regions[0].Content; + var lines = paragraph.Text.SplitToLines(); + var sb = new StringBuilder(); + bool italic = false; + bool bold = false; + for (int lineNumber = 0; lineNumber < lines.Count; lineNumber++) + { + string line = lines[lineNumber]; + if (lineNumber > 0) + { + if (italic || bold) + { + content.Add(new SubtitleRegionContentEndOfInlineStyle()); + } + content.Add(new SubtitleRegionContentLineBreak()); + if (italic && bold) + { + content.Add(new SubtitleRegionContentChangeFontStyle + { + FontStyle = 3, // bold and italic + FontOutlinePaletteId = regionStyle.FontOutlinePaletteEntryIdRef, + FontOutlineThickness = regionStyle.FontOutlineThickness + }); + } + else if (italic) + { + content.Add(new SubtitleRegionContentChangeFontStyle + { + FontStyle = 2, // italic + FontOutlinePaletteId = regionStyle.FontOutlinePaletteEntryIdRef, + FontOutlineThickness = regionStyle.FontOutlineThickness + }); + } + else if (bold) + { + content.Add(new SubtitleRegionContentChangeFontStyle + { + FontStyle = 1, // bold + FontOutlinePaletteId = regionStyle.FontOutlinePaletteEntryIdRef, + FontOutlineThickness = regionStyle.FontOutlineThickness + }); + } + } + int i = 0; + while (i < line.Length) + { + string s = line.Substring(i); + if (s.StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + italic = true; + if (content.Count > 0 && content[content.Count - 1] is SubtitleRegionContentChangeFontStyle) + { + content.RemoveAt(content.Count - 1); // Remove last style tag (italic/bold will be combined) + } + content.Add(new SubtitleRegionContentChangeFontStyle + { + FontStyle = bold ? 3 : 2, // italic + FontOutlinePaletteId = regionStyle.FontOutlinePaletteEntryIdRef, + FontOutlineThickness = regionStyle.FontOutlineThickness + }); + i += 3; + } + else if (s.StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + italic = false; + AddText(sb, content); + if (content.Count > 0 && content[content.Count - 1] is SubtitleRegionContentEndOfInlineStyle) + { + content.RemoveAt(content.Count - 1); // Remove last to avoid duplicated + } + content.Add(new SubtitleRegionContentEndOfInlineStyle()); + i += 4; + } + else if (s.StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + bold = true; + if (content.Count > 0 && content[content.Count - 1] is SubtitleRegionContentChangeFontStyle) + { + content.RemoveAt(content.Count - 1); // Remove last style tag (italic/bold will be combined) + } + content.Add(new SubtitleRegionContentChangeFontStyle + { + FontStyle = italic ? 3 : 1, // bold + FontOutlinePaletteId = regionStyle.FontOutlinePaletteEntryIdRef, + FontOutlineThickness = regionStyle.FontOutlineThickness + }); + i += 3; + } + else if (s.StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + bold = false; + AddText(sb, content); + if (content.Count > 0 && content[content.Count - 1] is SubtitleRegionContentEndOfInlineStyle) + { + content.RemoveAt(content.Count - 1); // Remove last to avoid duplicated + } + content.Add(new SubtitleRegionContentEndOfInlineStyle()); + i += 4; + } + else + { + i++; + sb.Append(s.Substring(0, 1)); + } + } + AddText(sb, content); + } + if (content.Count > 0 && content[content.Count - 1] is SubtitleRegionContentEndOfInlineStyle) + { + content.RemoveAt(content.Count - 1); // last 'end-of-inline-style' not needed + } + } + + private static void AddText(StringBuilder sb, List content) + { + if (sb.Length > 0) + { + string text = HtmlUtil.RemoveHtmlTags(sb.ToString(), true); + content.Add(new SubtitleRegionContentText + { + Text = text, + DataLength = Encoding.UTF8.GetBytes(text).Length + }); + sb.Clear(); + } + } + + public DialogPresentationSegment(byte[] buffer, int index) + { + int idx = index; + StartPts = buffer[idx + 13]; + StartPts += (ulong)buffer[idx + 12] << 8; + StartPts += (ulong)buffer[idx + 11] << 16; + StartPts += (ulong)buffer[idx + 10] << 24; + StartPts += (ulong)(buffer[idx + 9] & 0b00000001) << 32; + + EndPts = buffer[idx + 18]; + EndPts += (ulong)buffer[idx + 17] << 8; + EndPts += (ulong)buffer[idx + 16] << 16; + EndPts += (ulong)buffer[idx + 15] << 24; + EndPts += (ulong)(buffer[idx + 14] & 0b00000001) << 32; + + PaletteUpdate = (buffer[idx + 19] & 0b10000000) > 0; + idx += 20; + PaletteUpdates = new List(); + if (PaletteUpdate) + { + int numberOfPaletteEntries = buffer[idx + 21] + (buffer[idx + 20] << 8); + for (int i = 0; i < numberOfPaletteEntries; i++) + { + PaletteUpdates.Add(new Palette + { + PaletteEntryId = buffer[idx++], + Y = buffer[idx++], + Cr = buffer[idx++], + Cb = buffer[idx++], + T = buffer[idx++] + }); + } + } + + int numberOfRegions = buffer[idx++]; + Regions = new List(numberOfRegions); + for (int i = 0; i < numberOfRegions; i++) + { + var region = new SubtitleRegion { ContinuousPresentation = (buffer[idx] & 0b10000000) > 0, Forced = (buffer[idx] & 0b01000000) > 0 }; + idx++; + region.RegionStyleId = buffer[idx++]; + int regionSubtitleLength = buffer[idx + 1] + (buffer[idx] << 8); + idx += 2; + int processedLength = 0; + region.Texts = new List(); + region.Content = new List(); + string endStyle = string.Empty; + while (processedLength < regionSubtitleLength) + { + byte escapeCode = buffer[idx++]; + byte dataType = buffer[idx++]; + byte dataLength = buffer[idx++]; + processedLength += 3; + if (dataType == 0x01) // Text + { + string text = Encoding.UTF8.GetString(buffer, idx, dataLength); + region.Texts.Add(text); + region.Content.Add(new SubtitleRegionContentText + { + EscapeCode = escapeCode, + DataType = dataType, + DataLength = dataLength, + Text = text + }); + } + else if (dataType == 0x02) // Change a font set + { + region.Content.Add(new SubtitleRegionContentChangeFontSet + { + EscapeCode = escapeCode, + DataType = dataType, + DataLength = dataLength, + FontId = buffer[idx] + }); + } + else if (dataType == 0x03) // Change a font style + { + var fontStyle = buffer[idx]; + var fontOutlinePaletteId = buffer[idx + 1]; + var fontOutlineThickness = buffer[idx + 2]; + switch (fontStyle) + { + case 1: + region.Texts.Add(""); + endStyle = ""; + break; + case 2: + region.Texts.Add(""); + endStyle = ""; + break; + case 3: + region.Texts.Add(""); + endStyle = ""; + break; + case 5: + region.Texts.Add(""); + endStyle = ""; + break; + case 6: + region.Texts.Add(""); + endStyle = ""; + break; + case 7: + region.Texts.Add(""); + endStyle = ""; + break; + } + region.Content.Add(new SubtitleRegionContentChangeFontStyle + { + EscapeCode = escapeCode, + DataType = dataType, + DataLength = dataLength, + FontStyle = fontStyle, + FontOutlinePaletteId = fontOutlinePaletteId, + FontOutlineThickness = fontOutlineThickness + }); + } + else if (dataType == 0x04) // Change a font size + { + region.Content.Add(new SubtitleRegionContentChangeFontSize + { + EscapeCode = escapeCode, + DataType = dataType, + DataLength = dataLength, + FontSize = buffer[idx] + }); + } + else if (dataType == 0x05) // Change a font color + { + region.Content.Add(new SubtitleRegionContentChangeFontColor + { + EscapeCode = escapeCode, + DataType = dataType, + DataLength = dataLength, + FontPaletteId = buffer[idx] + }); + } + else if (dataType == 0x0A) // Line break + { + region.Texts.Add(Environment.NewLine); + region.Content.Add(new SubtitleRegionContentLineBreak + { + EscapeCode = escapeCode, + DataType = dataType, + DataLength = dataLength, + }); + } + else if (dataType == 0x0B) // End of inline style + { + if (!string.IsNullOrEmpty(endStyle)) + { + region.Texts.Add(endStyle); + endStyle = string.Empty; + } + region.Content.Add(new SubtitleRegionContentEndOfInlineStyle + { + EscapeCode = escapeCode, + DataType = dataType, + DataLength = dataLength, + }); + } + processedLength += dataLength; + idx += dataLength; + } + if (!string.IsNullOrEmpty(endStyle)) + { + region.Texts.Add(endStyle); + } + Regions.Add(region); + } + } + + public string Text + { + get + { + var sb = new StringBuilder(); + foreach (var region in Regions) + { + foreach (string text in region.Texts) + { + sb.Append(text); + } + } + return sb.ToString(); + } + } + + public ulong StartPtsMilliseconds => (ulong)Math.Round((StartPts) / 90.0); + + public ulong EndPtsMilliseconds => (ulong)Math.Round((EndPts) / 90.0); + + public void WriteToStream(Stream stream) + { + byte[] regionSubtitle = MakeSubtitleRegions(); + stream.Write(new byte[] { 0, 0, 1, 0xbf }, 0, 4); // MPEG-2 Private stream 2 + int size = regionSubtitle.Length + 15; + stream.WriteWord(size); + stream.WriteByte(SegmentTypeDialogPresentation); // 0x82 + stream.WriteWord(size - 3); + stream.WritePts(StartPts); + stream.WritePts(EndPts); + if (PaletteUpdate) + { + stream.WriteWord(PaletteUpdates.Count); + foreach (var palette in PaletteUpdates) + { + stream.WriteByte((byte)palette.PaletteEntryId); + stream.WriteByte((byte)palette.Y); + stream.WriteByte((byte)palette.Cb); + stream.WriteByte((byte)palette.Cr); + stream.WriteByte((byte)palette.T); + } + } + else + { + stream.WriteByte(0); // 1 bit = palette update (0=no update), next 7 bits reserved + } + stream.WriteByte((byte)Regions.Count); // number of regions + + stream.Write(regionSubtitle, 0, regionSubtitle.Length); + } + + private byte[] MakeSubtitleRegions() + { + using (var ms = new MemoryStream()) + { + foreach (var subtitleRegion in Regions) + { + byte flags = 0; + if (subtitleRegion.ContinuousPresentation) + { + flags = (byte)(flags | 0b10000000); + } + + if (subtitleRegion.Forced) + { + flags = (byte)(flags | 0b01000000); + } + + ms.WriteByte(flags); // first byte=continuous_present_flag, second byte=force, next 6 bits reserved + + ms.WriteByte((byte)subtitleRegion.RegionStyleId); + var contentBuffer = MakeSubtitleRegionContent(subtitleRegion); + ms.WriteWord(contentBuffer.Length); // set region subtitle size field + ms.Write(contentBuffer, 0, contentBuffer.Length); + } + return ms.ToArray(); + } + } + + private static byte[] MakeSubtitleRegionContent(SubtitleRegion subtitleRegion) + { + using (var ms = new MemoryStream()) + { + foreach (var content in subtitleRegion.Content) + { + ms.WriteByte((byte)content.EscapeCode); // escape code (0x1b / 27) + ms.WriteByte((byte)content.DataType); + ms.WriteByte((byte)content.DataLength); + content.WriteExtraToStream(ms); + } + return ms.ToArray(); + } + } + } + + public DialogStyleSegment StyleSegment; + public List PresentationSegments; + + private const int TextSubtitleStreamPid = 0x1800; + private const byte SegmentTypeDialogStyle = 0x81; + private const byte SegmentTypeDialogPresentation = 0x82; + + public override string Extension => ".m2ts"; + + public override string Name => "Blu-ray TextST"; + + public override bool IsMine(List lines, string fileName) + { + if (string.IsNullOrEmpty(fileName)) + { + return false; + } + + if (fileName.EndsWith(".m2ts", StringComparison.OrdinalIgnoreCase) && FileUtil.IsM2TransportStream(fileName) || + fileName.EndsWith(".textst", StringComparison.OrdinalIgnoreCase) && FileUtil.IsMpeg2PrivateStream2(fileName)) + { + return base.IsMine(lines, fileName); + } + return false; + } + + public override string ToText(Subtitle subtitle, string title) + { + throw new NotImplementedException(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + if (FileUtil.IsMpeg2PrivateStream2(fileName)) + { + using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + LoadSubtitleFromMpeg2PesPackets(subtitle, fs); + } + } + else + { + using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + LoadSubtitleFromM2Ts(subtitle, fs); + } + } + subtitle.Renumber(); + } + + private void LoadSubtitleFromMpeg2PesPackets(Subtitle subtitle, Stream stream) + { + long position = 0; + stream.Position = 0; + stream.Seek(position, SeekOrigin.Begin); + long streamLength = stream.Length; + var buffer = new byte[512]; + PresentationSegments = new List(); + while (position < streamLength) + { + stream.Seek(position, SeekOrigin.Begin); + int bytesRead = stream.Read(buffer, 0, buffer.Length); + if (bytesRead < 20) + { + break; + } + + int size = (buffer[4] << 8) + buffer[5] + 6; + position += size; + + if (bytesRead > 10 && VobSubParser.IsPrivateStream2(buffer, 0)) + { + if (buffer[6] == SegmentTypeDialogPresentation) + { + var dps = new DialogPresentationSegment(buffer, 0); + PresentationSegments.Add(dps); + subtitle.Paragraphs.Add(new Paragraph(dps.Text.Trim(), dps.StartPtsMilliseconds, dps.EndPtsMilliseconds)); + } + else if (buffer[6] == SegmentTypeDialogStyle) + { + StyleSegment = new DialogStyleSegment(buffer); + } + } + } + } + + private void LoadSubtitleFromM2Ts(Subtitle subtitle, Stream ms) + { + var subtitlePackets = new List(); + const int packetLength = 188; + bool isM2TransportStream = DetectFormat(ms); + var packetBuffer = new byte[packetLength]; + var m2TsTimeCodeBuffer = new byte[4]; + long position = 0; + ms.Position = 0; + + // check for Topfield .rec file + ms.Seek(position, SeekOrigin.Begin); + ms.Read(m2TsTimeCodeBuffer, 0, 3); + if (m2TsTimeCodeBuffer[0] == 0x54 && m2TsTimeCodeBuffer[1] == 0x46 && m2TsTimeCodeBuffer[2] == 0x72) + { + position = 3760; + } + + long transportStreamLength = ms.Length; + ms.Seek(position, SeekOrigin.Begin); + while (position < transportStreamLength) + { + if (isM2TransportStream) + { + var m2TsHeaderBytesRead = ms.Read(m2TsTimeCodeBuffer, 0, m2TsTimeCodeBuffer.Length); + if (m2TsHeaderBytesRead < m2TsTimeCodeBuffer.Length) + { + break; // incomplete m2ts header + } + position += m2TsTimeCodeBuffer.Length; + } + + var packetBytesRead = ms.Read(packetBuffer, 0, packetLength); + if (packetBytesRead < packetLength) + { + break; // incomplete packet + } + + byte syncByte = packetBuffer[0]; + if (syncByte == Packet.SynchronizationByte) + { + var packet = new Packet(packetBuffer); + if (packet.PacketId == TextSubtitleStreamPid) + { + subtitlePackets.Add(packet); + } + position += packetLength; + } + else + { + if (isM2TransportStream) + { + position -= m2TsTimeCodeBuffer.Length; + } + position++; + ms.Seek(position, SeekOrigin.Begin); + } + } + + //TODO: merge ts packets + + PresentationSegments = new List(); + foreach (var item in subtitlePackets) + { + if (item.Payload != null && item.Payload.Length > 10 && VobSubParser.IsPrivateStream2(item.Payload, 0)) + { + if (item.Payload[6] == SegmentTypeDialogPresentation) + { + var dps = new DialogPresentationSegment(item.Payload, 0); + PresentationSegments.Add(dps); + subtitle.Paragraphs.Add(new Paragraph(dps.Text.Trim(), dps.StartPtsMilliseconds, dps.EndPtsMilliseconds)); + } + else if (item.Payload[6] == SegmentTypeDialogStyle) + { + StyleSegment = new DialogStyleSegment(item.Payload); + } + } + } + + subtitle.Renumber(); + } + + private static bool DetectFormat(Stream ms) + { + if (ms.Length > 192 + 192 + 5) + { + ms.Seek(0, SeekOrigin.Begin); + var buffer = new byte[192 + 192 + 5]; + ms.Read(buffer, 0, buffer.Length); + if (buffer[0] == Packet.SynchronizationByte && buffer[188] == Packet.SynchronizationByte) + { + return false; + } + + if (buffer[4] == Packet.SynchronizationByte && buffer[192 + 4] == Packet.SynchronizationByte && buffer[192 + 192 + 4] == Packet.SynchronizationByte) + { + return true; + } + } + return false; + } + } +} diff --git a/libse/SubtitleFormats/TimeCodesOnly1.cs b/src/libse/SubtitleFormats/TimeCodesOnly1.cs similarity index 100% rename from libse/SubtitleFormats/TimeCodesOnly1.cs rename to src/libse/SubtitleFormats/TimeCodesOnly1.cs diff --git a/libse/SubtitleFormats/TimeCodesOnly2.cs b/src/libse/SubtitleFormats/TimeCodesOnly2.cs similarity index 100% rename from libse/SubtitleFormats/TimeCodesOnly2.cs rename to src/libse/SubtitleFormats/TimeCodesOnly2.cs diff --git a/libse/SubtitleFormats/TimeXml.cs b/src/libse/SubtitleFormats/TimeXml.cs similarity index 97% rename from libse/SubtitleFormats/TimeXml.cs rename to src/libse/SubtitleFormats/TimeXml.cs index a95232d8c..81c0c66d3 100644 --- a/libse/SubtitleFormats/TimeXml.cs +++ b/src/libse/SubtitleFormats/TimeXml.cs @@ -1,95 +1,95 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class TimeXml : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "Xml"; - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("Paragraph"); - - XmlNode number = xml.CreateElement("Number"); - number.InnerText = p.Number.ToString(CultureInfo.InvariantCulture); - paragraph.AppendChild(number); - - XmlNode start = xml.CreateElement("StartMilliseconds"); - start.InnerText = ((long)(Math.Round(p.StartTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture); - paragraph.AppendChild(start); - - XmlNode end = xml.CreateElement("EndMilliseconds"); - end.InnerText = ((long)(Math.Round(p.EndTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture); - paragraph.AppendChild(end); - - XmlNode text = xml.CreateElement("Text"); - text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); - paragraph.AppendChild(text); - - xml.DocumentElement.AppendChild(paragraph); - } - - return ToUtf8XmlString(xml); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - - string xmlString = sb.ToString(); - if (!xmlString.Contains("") || !xmlString.Contains("")) - { - return; - } - - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(xmlString); - } - catch - { - _errorCount = 1; - return; - } - - foreach (XmlNode node in xml.DocumentElement.SelectNodes("Paragraph")) - { - try - { - string start = node.SelectSingleNode("StartMilliseconds").InnerText; - string end = node.SelectSingleNode("EndMilliseconds").InnerText; - string text = node.SelectSingleNode("Text").InnerText; - - subtitle.Paragraphs.Add(new Paragraph(text, Convert.ToDouble(start, CultureInfo.InvariantCulture), Convert.ToDouble(end, CultureInfo.InvariantCulture))); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - } - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class TimeXml : SubtitleFormat + { + public override string Extension => ".xml"; + + public override string Name => "Xml"; + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("Paragraph"); + + XmlNode number = xml.CreateElement("Number"); + number.InnerText = p.Number.ToString(CultureInfo.InvariantCulture); + paragraph.AppendChild(number); + + XmlNode start = xml.CreateElement("StartMilliseconds"); + start.InnerText = ((long)(Math.Round(p.StartTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture); + paragraph.AppendChild(start); + + XmlNode end = xml.CreateElement("EndMilliseconds"); + end.InnerText = ((long)(Math.Round(p.EndTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture); + paragraph.AppendChild(end); + + XmlNode text = xml.CreateElement("Text"); + text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); + paragraph.AppendChild(text); + + xml.DocumentElement.AppendChild(paragraph); + } + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + + string xmlString = sb.ToString(); + if (!xmlString.Contains("") || !xmlString.Contains("")) + { + return; + } + + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(xmlString); + } + catch + { + _errorCount = 1; + return; + } + + foreach (XmlNode node in xml.DocumentElement.SelectNodes("Paragraph")) + { + try + { + string start = node.SelectSingleNode("StartMilliseconds").InnerText; + string end = node.SelectSingleNode("EndMilliseconds").InnerText; + string text = node.SelectSingleNode("Text").InnerText; + + subtitle.Paragraphs.Add(new Paragraph(text, Convert.ToDouble(start, CultureInfo.InvariantCulture), Convert.ToDouble(end, CultureInfo.InvariantCulture))); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/TimeXml2.cs b/src/libse/SubtitleFormats/TimeXml2.cs similarity index 97% rename from libse/SubtitleFormats/TimeXml2.cs rename to src/libse/SubtitleFormats/TimeXml2.cs index 9d7e71b0c..47117107e 100644 --- a/libse/SubtitleFormats/TimeXml2.cs +++ b/src/libse/SubtitleFormats/TimeXml2.cs @@ -1,109 +1,109 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class TimeXml2 : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "Xml 2"; - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("Subtitle"); - - XmlNode number = xml.CreateElement("Number"); - number.InnerText = p.Number.ToString(CultureInfo.InvariantCulture); - paragraph.AppendChild(number); - - XmlNode start = xml.CreateElement("Start"); - start.InnerText = p.StartTime.ToString(); - paragraph.AppendChild(start); - - XmlNode end = xml.CreateElement("End"); - end.InnerText = p.EndTime.ToString(); - paragraph.AppendChild(end); - - XmlNode duration = xml.CreateElement("Duration"); - duration.InnerText = p.Duration.ToShortString(); - paragraph.AppendChild(duration); - - XmlNode text = xml.CreateElement("Text"); - text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); - paragraph.AppendChild(text); - - xml.DocumentElement.AppendChild(paragraph); - } - - return ToUtf8XmlString(xml); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - - var xmlString = sb.ToString(); - if (!xmlString.Contains("") || !xmlString.Contains("") || !xmlString.Contains("")) - { - return; - } - - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(xmlString); - } - catch - { - _errorCount = 1; - return; - } - - foreach (XmlNode node in xml.DocumentElement.SelectNodes("Subtitle")) - { - try - { - TimeCode startTimeCode = DecodeTimeCode(node.SelectSingleNode("Start").InnerText); - TimeCode endTimeCode = DecodeTimeCode(node.SelectSingleNode("End").InnerText); - string text = node.SelectSingleNode("Text").InnerText; - subtitle.Paragraphs.Add(new Paragraph(startTimeCode, endTimeCode, text)); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - } - subtitle.Renumber(); - } - - private static TimeCode DecodeTimeCode(string p) - { - var parts = p.Split(new[] { ';', '.', ':', ',' }); - - string hour = parts[0]; - string minutes = parts[1]; - string seconds = parts[2]; - string ms = parts[3]; - - return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), (int.Parse(ms))); - } - - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class TimeXml2 : SubtitleFormat + { + public override string Extension => ".xml"; + + public override string Name => "Xml 2"; + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("Subtitle"); + + XmlNode number = xml.CreateElement("Number"); + number.InnerText = p.Number.ToString(CultureInfo.InvariantCulture); + paragraph.AppendChild(number); + + XmlNode start = xml.CreateElement("Start"); + start.InnerText = p.StartTime.ToString(); + paragraph.AppendChild(start); + + XmlNode end = xml.CreateElement("End"); + end.InnerText = p.EndTime.ToString(); + paragraph.AppendChild(end); + + XmlNode duration = xml.CreateElement("Duration"); + duration.InnerText = p.Duration.ToShortString(); + paragraph.AppendChild(duration); + + XmlNode text = xml.CreateElement("Text"); + text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text); + paragraph.AppendChild(text); + + xml.DocumentElement.AppendChild(paragraph); + } + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + + var xmlString = sb.ToString(); + if (!xmlString.Contains("") || !xmlString.Contains("") || !xmlString.Contains("")) + { + return; + } + + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(xmlString); + } + catch + { + _errorCount = 1; + return; + } + + foreach (XmlNode node in xml.DocumentElement.SelectNodes("Subtitle")) + { + try + { + TimeCode startTimeCode = DecodeTimeCode(node.SelectSingleNode("Start").InnerText); + TimeCode endTimeCode = DecodeTimeCode(node.SelectSingleNode("End").InnerText); + string text = node.SelectSingleNode("Text").InnerText; + subtitle.Paragraphs.Add(new Paragraph(startTimeCode, endTimeCode, text)); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + subtitle.Renumber(); + } + + private static TimeCode DecodeTimeCode(string p) + { + var parts = p.Split(new[] { ';', '.', ':', ',' }); + + string hour = parts[0]; + string minutes = parts[1]; + string seconds = parts[2]; + string ms = parts[3]; + + return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), (int.Parse(ms))); + } + + } +} diff --git a/libse/SubtitleFormats/TimedText.cs b/src/libse/SubtitleFormats/TimedText.cs similarity index 98% rename from libse/SubtitleFormats/TimedText.cs rename to src/libse/SubtitleFormats/TimedText.cs index 2023a7436..b797b51de 100644 --- a/libse/SubtitleFormats/TimedText.cs +++ b/src/libse/SubtitleFormats/TimedText.cs @@ -1,404 +1,404 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class TimedText : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "Timed Text draft 2006-10"; - - public override bool IsMine(List lines, string fileName) - { - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - string xmlAsString = sb.ToString().RemoveControlCharactersButWhiteSpace().Trim(); - - if (xmlAsString.Contains("xmlns:tts=\"http://www.w3.org/2006/04")) - { - return false; - } - - if (xmlAsString.Contains("http://www.w3.org/") && - xmlAsString.Contains("/ttaf1")) - { - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(xmlAsString.Replace(" & ", " & ").Replace("Q&A", "Q&A")); - - var nsmgr = new XmlNamespaceManager(xml.NameTable); - nsmgr.AddNamespace("ttaf1", xml.DocumentElement.NamespaceURI); - var div = xml.DocumentElement.SelectSingleNode("//ttaf1:body", nsmgr).SelectSingleNode("ttaf1:div", nsmgr); - if (div == null) - { - div = xml.DocumentElement.SelectSingleNode("//ttaf1:body", nsmgr).FirstChild; - } - - int numberOfParagraphs = div.ChildNodes.Count; - return numberOfParagraphs > 0; - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - return false; - } - } - return false; - } - - private static string ConvertToTimeString(TimeCode time) - { - if (Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormatSource == "hh:mm:ss.ms-two-digits") - { - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}.{(int)Math.Round(time.Milliseconds / 10.0):0}"; - } - - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}.{time.Milliseconds:000}"; - } - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - "" + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " " + Environment.NewLine + - " - - - - -"; - xmlStructure = xmlStructure.Replace("[DATE]", DateTime.Now.ToString("yyyy-MM-dd")); - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - xml.DocumentElement.SelectSingleNode("metadata/title").InnerText = title; - var subtitlesNode = xml.DocumentElement.SelectSingleNode("subtitles"); - - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("subtitle"); - - XmlAttribute start = xml.CreateAttribute("start"); - start.InnerText = p.StartTime.ToString().Replace(",", "."); - paragraph.Attributes.Prepend(start); - - XmlAttribute stop = xml.CreateAttribute("stop"); - stop.InnerText = p.EndTime.ToString().Replace(",", "."); - paragraph.Attributes.Append(stop); - - XmlNode text = xml.CreateElement("text"); - bool first = true; - foreach (string line in HtmlUtil.RemoveHtmlTags(p.Text, true).SplitToLines()) - { - if (!first) - { - XmlNode br = xml.CreateElement("br"); - text.AppendChild(br); - } - first = false; - var t = xml.CreateTextNode(string.Empty); - t.InnerText = line; - text.AppendChild(t); - } - paragraph.AppendChild(text); - - XmlAttribute style = xml.CreateAttribute("style"); - style.InnerText = "Default"; - text.Attributes.Append(style); - - subtitlesNode.AppendChild(paragraph); - } - - return ToUtf8XmlString(xml); - } - - private static TimeCode DecodeTimeCode(string code) - { - string[] parts = code.Split(new[] { ':', '.', ',' }, StringSplitOptions.RemoveEmptyEntries); - - if (parts.Length == 1) - { - return new TimeCode(0, 0, int.Parse(code), 0); // seconds only - } - if (parts.Length == 2) - { - return new TimeCode(0, 0, int.Parse(parts[0]), int.Parse(parts[1])); // seconds + ms - } - - //00:00:07:120 - string hour = parts[0]; - string minutes = parts[1]; - string seconds = parts[2]; - string ms = parts[3]; - return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), int.Parse(ms)); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - - string xmlString = sb.ToString(); - if (!xmlString.Contains("")) - { - return; - } - - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(xmlString); - } - catch - { - _errorCount = 1; - return; - } - - foreach (XmlNode node in xml.DocumentElement.SelectNodes("subtitles/subtitle")) - { - try - { - string start = node.Attributes["start"].InnerText; - string stop = node.Attributes["stop"].InnerText; - - var text = new StringBuilder(); - foreach (XmlNode innerNode in node.SelectSingleNode("text").ChildNodes) - { - switch (innerNode.Name.Replace("tt:", string.Empty)) - { - case "br": - text.AppendLine(); - break; - default: - text.Append(innerNode.InnerText); - break; - } - } - - subtitle.Paragraphs.Add(new Paragraph(DecodeTimeCode(start), DecodeTimeCode(stop), text.ToString().Trim())); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - } - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class UniversalSubtitleFormat : SubtitleFormat + { + public override string Extension => ".usf"; + + public override string Name => "Universal Subtitle Format"; + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + @" + Universal Subtitle Format + + SubtitleEdit + nikse.dk@gmail.com + https://www.nikse.dk/ + " + Environment.NewLine + +" English" + Environment.NewLine + +@" [DATE] + This is a USF file + + + " + Environment.NewLine + + " + + + + +"; + xmlStructure = xmlStructure.Replace("[DATE]", DateTime.Now.ToString("yyyy-MM-dd")); + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + xml.DocumentElement.SelectSingleNode("metadata/title").InnerText = title; + var subtitlesNode = xml.DocumentElement.SelectSingleNode("subtitles"); + + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("subtitle"); + + XmlAttribute start = xml.CreateAttribute("start"); + start.InnerText = p.StartTime.ToString().Replace(",", "."); + paragraph.Attributes.Prepend(start); + + XmlAttribute stop = xml.CreateAttribute("stop"); + stop.InnerText = p.EndTime.ToString().Replace(",", "."); + paragraph.Attributes.Append(stop); + + XmlNode text = xml.CreateElement("text"); + bool first = true; + foreach (string line in HtmlUtil.RemoveHtmlTags(p.Text, true).SplitToLines()) + { + if (!first) + { + XmlNode br = xml.CreateElement("br"); + text.AppendChild(br); + } + first = false; + var t = xml.CreateTextNode(string.Empty); + t.InnerText = line; + text.AppendChild(t); + } + paragraph.AppendChild(text); + + XmlAttribute style = xml.CreateAttribute("style"); + style.InnerText = "Default"; + text.Attributes.Append(style); + + subtitlesNode.AppendChild(paragraph); + } + + return ToUtf8XmlString(xml); + } + + private static TimeCode DecodeTimeCode(string code) + { + string[] parts = code.Split(new[] { ':', '.', ',' }, StringSplitOptions.RemoveEmptyEntries); + + if (parts.Length == 1) + { + return new TimeCode(0, 0, int.Parse(code), 0); // seconds only + } + if (parts.Length == 2) + { + return new TimeCode(0, 0, int.Parse(parts[0]), int.Parse(parts[1])); // seconds + ms + } + + //00:00:07:120 + string hour = parts[0]; + string minutes = parts[1]; + string seconds = parts[2]; + string ms = parts[3]; + return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), int.Parse(ms)); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + + string xmlString = sb.ToString(); + if (!xmlString.Contains("")) + { + return; + } + + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(xmlString); + } + catch + { + _errorCount = 1; + return; + } + + foreach (XmlNode node in xml.DocumentElement.SelectNodes("subtitles/subtitle")) + { + try + { + string start = node.Attributes["start"].InnerText; + string stop = node.Attributes["stop"].InnerText; + + var text = new StringBuilder(); + foreach (XmlNode innerNode in node.SelectSingleNode("text").ChildNodes) + { + switch (innerNode.Name.Replace("tt:", string.Empty)) + { + case "br": + text.AppendLine(); + break; + default: + text.Append(innerNode.InnerText); + break; + } + } + + subtitle.Paragraphs.Add(new Paragraph(DecodeTimeCode(start), DecodeTimeCode(stop), text.ToString().Trim())); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/UnknownSubtitle1.cs b/src/libse/SubtitleFormats/UnknownSubtitle1.cs similarity index 97% rename from libse/SubtitleFormats/UnknownSubtitle1.cs rename to src/libse/SubtitleFormats/UnknownSubtitle1.cs index 8092e9278..574f12f6f 100644 --- a/libse/SubtitleFormats/UnknownSubtitle1.cs +++ b/src/libse/SubtitleFormats/UnknownSubtitle1.cs @@ -1,112 +1,112 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class UnknownSubtitle1 : SubtitleFormat - { - //0:01 – 0:11 - private static readonly Regex RegexTimeCodes = new Regex(@"^\d+:\d\d – \d+:\d\d ", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "Unknown 1"; - - public override string ToText(Subtitle subtitle, string title) - { - //0:01 – 0:11 "My vengeance needs blood!" -Marquis De Sade - //[Laughter, thunder] - //0:17 – 0:19 - On this 5th day of December - - //0:19 – 0:22 in the year of our Lord 1648, - - - const string paragraphWriteFormat = "{0} – {1} {2}"; - - var sb = new StringBuilder(); - const string format = "{0:0}:{1:00}"; - foreach (Paragraph p in subtitle.Paragraphs) - { - int seconds = p.StartTime.Seconds; - if (p.StartTime.Milliseconds >= 500) - { - seconds++; - } - - string startTime = string.Format(format, p.StartTime.Minutes + p.StartTime.Hours * 60, seconds); - - seconds = p.EndTime.Seconds; - if (p.EndTime.Milliseconds >= 500) - { - seconds++; - } - - string timeOut = string.Format(format, p.EndTime.Minutes + p.EndTime.Hours * 60, seconds); - - sb.AppendLine(string.Format(paragraphWriteFormat, startTime, timeOut, p.Text)); - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - Paragraph p = null; - _errorCount = 0; - - subtitle.Paragraphs.Clear(); - var sb = new StringBuilder(); - char[] splitChars = { '–', ' ' }; - foreach (string line in lines) - { - Match match; - if (line.Length > 11 && (match = RegexTimeCodes.Match(line)).Success) - { - if (p != null) - { - p.Text = (p.Text + Environment.NewLine + sb).Trim(); - } - - var parts = line.Substring(0, match.Length).Split(splitChars, StringSplitOptions.RemoveEmptyEntries); - try - { - p = new Paragraph { StartTime = DecodeTimeCode(parts[0]), EndTime = DecodeTimeCode(parts[1]) }; - p.Text = line.Substring(match.Length).Trim(); - subtitle.Paragraphs.Add(p); - sb.Clear(); - } - catch - { - p = null; - _errorCount++; - } - } - else if (p == null) - { - _errorCount++; - } - else - { - sb.AppendLine(line); - } - if (_errorCount > 20) - { - return; - } - } - if (p != null) - { - p.Text = (p.Text + Environment.NewLine + sb).Trim(); - } - - subtitle.Renumber(); - } - - private static TimeCode DecodeTimeCode(string code) - { - //68:20 (minutes:seconds) - var parts = code.Trim().Split(':'); - return new TimeCode(0, int.Parse(parts[0]), int.Parse(parts[1]), 0); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class UnknownSubtitle1 : SubtitleFormat + { + //0:01 – 0:11 + private static readonly Regex RegexTimeCodes = new Regex(@"^\d+:\d\d – \d+:\d\d ", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "Unknown 1"; + + public override string ToText(Subtitle subtitle, string title) + { + //0:01 – 0:11 "My vengeance needs blood!" -Marquis De Sade + //[Laughter, thunder] + //0:17 – 0:19 - On this 5th day of December - + //0:19 – 0:22 in the year of our Lord 1648, - + + const string paragraphWriteFormat = "{0} – {1} {2}"; + + var sb = new StringBuilder(); + const string format = "{0:0}:{1:00}"; + foreach (Paragraph p in subtitle.Paragraphs) + { + int seconds = p.StartTime.Seconds; + if (p.StartTime.Milliseconds >= 500) + { + seconds++; + } + + string startTime = string.Format(format, p.StartTime.Minutes + p.StartTime.Hours * 60, seconds); + + seconds = p.EndTime.Seconds; + if (p.EndTime.Milliseconds >= 500) + { + seconds++; + } + + string timeOut = string.Format(format, p.EndTime.Minutes + p.EndTime.Hours * 60, seconds); + + sb.AppendLine(string.Format(paragraphWriteFormat, startTime, timeOut, p.Text)); + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + Paragraph p = null; + _errorCount = 0; + + subtitle.Paragraphs.Clear(); + var sb = new StringBuilder(); + char[] splitChars = { '–', ' ' }; + foreach (string line in lines) + { + Match match; + if (line.Length > 11 && (match = RegexTimeCodes.Match(line)).Success) + { + if (p != null) + { + p.Text = (p.Text + Environment.NewLine + sb).Trim(); + } + + var parts = line.Substring(0, match.Length).Split(splitChars, StringSplitOptions.RemoveEmptyEntries); + try + { + p = new Paragraph { StartTime = DecodeTimeCode(parts[0]), EndTime = DecodeTimeCode(parts[1]) }; + p.Text = line.Substring(match.Length).Trim(); + subtitle.Paragraphs.Add(p); + sb.Clear(); + } + catch + { + p = null; + _errorCount++; + } + } + else if (p == null) + { + _errorCount++; + } + else + { + sb.AppendLine(line); + } + if (_errorCount > 20) + { + return; + } + } + if (p != null) + { + p.Text = (p.Text + Environment.NewLine + sb).Trim(); + } + + subtitle.Renumber(); + } + + private static TimeCode DecodeTimeCode(string code) + { + //68:20 (minutes:seconds) + var parts = code.Trim().Split(':'); + return new TimeCode(0, int.Parse(parts[0]), int.Parse(parts[1]), 0); + } + } +} diff --git a/libse/SubtitleFormats/UnknownSubtitle10.cs b/src/libse/SubtitleFormats/UnknownSubtitle10.cs similarity index 97% rename from libse/SubtitleFormats/UnknownSubtitle10.cs rename to src/libse/SubtitleFormats/UnknownSubtitle10.cs index 4acb05a69..dfa2f6cf9 100644 --- a/libse/SubtitleFormats/UnknownSubtitle10.cs +++ b/src/libse/SubtitleFormats/UnknownSubtitle10.cs @@ -1,120 +1,120 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class UnknownSubtitle10 : SubtitleFormat - { - public override string Extension => ".txt"; - - public override string Name => "Unknown 10"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - sb.Append("{\"language_code\":\"en\",\"subtitles\":["); - int i = 0; - foreach (Paragraph p in subtitle.Paragraphs) - { - if (i > 0) - { - sb.Append(','); - } - - sb.Append('{'); - sb.AppendFormat("\"content\":\"{0}\",\"start_time\":{1},\"end_time\":{2}", p.Text.Replace(Environment.NewLine, "
"), ((long)(Math.Round(p.StartTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture), ((long)(Math.Round(p.EndTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture)); - sb.Append('}'); - i++; - } - sb.Append("]}"); - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - var temp = new StringBuilder(); - foreach (string l in lines) - { - temp.Append(l); - } - - string all = temp.ToString(); - if (!all.Contains("{\"content\":\"")) - { - return; - } - - var arr = all.Replace("\n", string.Empty).Replace("{\"content\":\"", "\n").Split('\n'); - - _errorCount = 0; - subtitle.Paragraphs.Clear(); - - // {"content":"La ce se gandeste Oh Ha Ni a noastra
de la inceputul dimineti?","start_time":314071,"end_time":317833}, - for (int i = 0; i < arr.Length; i++) - { - string line = arr[i].Trim(); - - int indexStartTime = line.IndexOf("\"start_time\":", StringComparison.Ordinal); - int indexEndTime = line.IndexOf("\"end_time\":", StringComparison.Ordinal); - if (indexStartTime > 0 && indexEndTime > 0) - { - int indexEndText = indexStartTime; - if (indexStartTime > indexEndTime) - { - indexEndText = indexEndTime; - } - - string text = line.Substring(0, indexEndText - 1).Trim().TrimEnd('\"'); - text = text.Replace("
", Environment.NewLine).Replace("
", Environment.NewLine); - text = text.Replace("
", Environment.NewLine).Replace("
", Environment.NewLine); - text = text.Replace(Environment.NewLine + " ", Environment.NewLine); - text = text.Replace(Environment.NewLine + " ", Environment.NewLine); - text = text.Replace(Environment.NewLine + " ", Environment.NewLine); - text = text.Replace(" " + Environment.NewLine, Environment.NewLine); - text = text.Replace(" " + Environment.NewLine, Environment.NewLine); - text = text.Replace(" " + Environment.NewLine, Environment.NewLine); - try - { - string start = line.Substring(indexStartTime); - string end = line.Substring(indexEndTime); - var paragraph = new Paragraph - { - Text = text, - StartTime = { TotalMilliseconds = GetMilliseconds(start) }, - EndTime = { TotalMilliseconds = GetMilliseconds(end) } - }; - subtitle.Paragraphs.Add(paragraph); - } - catch (Exception exception) - { - System.Diagnostics.Debug.WriteLine(exception.Message); - _errorCount++; - } - } - } - subtitle.Renumber(); - } - - private static double GetMilliseconds(string start) - { - while (start.Length > 1 && !start.StartsWith(':')) - { - start = start.Remove(0, 1); - } - - start = start.Trim().Trim(':').Trim('"').Trim(); - - int i = 0; - while (i < start.Length && char.IsDigit(start[i])) - { - i++; - } - - return int.Parse(start.Substring(0, i)); - } - - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class UnknownSubtitle10 : SubtitleFormat + { + public override string Extension => ".txt"; + + public override string Name => "Unknown 10"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + sb.Append("{\"language_code\":\"en\",\"subtitles\":["); + int i = 0; + foreach (Paragraph p in subtitle.Paragraphs) + { + if (i > 0) + { + sb.Append(','); + } + + sb.Append('{'); + sb.AppendFormat("\"content\":\"{0}\",\"start_time\":{1},\"end_time\":{2}", p.Text.Replace(Environment.NewLine, "
"), ((long)(Math.Round(p.StartTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture), ((long)(Math.Round(p.EndTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture)); + sb.Append('}'); + i++; + } + sb.Append("]}"); + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + var temp = new StringBuilder(); + foreach (string l in lines) + { + temp.Append(l); + } + + string all = temp.ToString(); + if (!all.Contains("{\"content\":\"")) + { + return; + } + + var arr = all.Replace("\n", string.Empty).Replace("{\"content\":\"", "\n").Split('\n'); + + _errorCount = 0; + subtitle.Paragraphs.Clear(); + + // {"content":"La ce se gandeste Oh Ha Ni a noastra
de la inceputul dimineti?","start_time":314071,"end_time":317833}, + for (int i = 0; i < arr.Length; i++) + { + string line = arr[i].Trim(); + + int indexStartTime = line.IndexOf("\"start_time\":", StringComparison.Ordinal); + int indexEndTime = line.IndexOf("\"end_time\":", StringComparison.Ordinal); + if (indexStartTime > 0 && indexEndTime > 0) + { + int indexEndText = indexStartTime; + if (indexStartTime > indexEndTime) + { + indexEndText = indexEndTime; + } + + string text = line.Substring(0, indexEndText - 1).Trim().TrimEnd('\"'); + text = text.Replace("
", Environment.NewLine).Replace("
", Environment.NewLine); + text = text.Replace("
", Environment.NewLine).Replace("
", Environment.NewLine); + text = text.Replace(Environment.NewLine + " ", Environment.NewLine); + text = text.Replace(Environment.NewLine + " ", Environment.NewLine); + text = text.Replace(Environment.NewLine + " ", Environment.NewLine); + text = text.Replace(" " + Environment.NewLine, Environment.NewLine); + text = text.Replace(" " + Environment.NewLine, Environment.NewLine); + text = text.Replace(" " + Environment.NewLine, Environment.NewLine); + try + { + string start = line.Substring(indexStartTime); + string end = line.Substring(indexEndTime); + var paragraph = new Paragraph + { + Text = text, + StartTime = { TotalMilliseconds = GetMilliseconds(start) }, + EndTime = { TotalMilliseconds = GetMilliseconds(end) } + }; + subtitle.Paragraphs.Add(paragraph); + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception.Message); + _errorCount++; + } + } + } + subtitle.Renumber(); + } + + private static double GetMilliseconds(string start) + { + while (start.Length > 1 && !start.StartsWith(':')) + { + start = start.Remove(0, 1); + } + + start = start.Trim().Trim(':').Trim('"').Trim(); + + int i = 0; + while (i < start.Length && char.IsDigit(start[i])) + { + i++; + } + + return int.Parse(start.Substring(0, i)); + } + + } +} diff --git a/libse/SubtitleFormats/UnknownSubtitle100.cs b/src/libse/SubtitleFormats/UnknownSubtitle100.cs similarity index 100% rename from libse/SubtitleFormats/UnknownSubtitle100.cs rename to src/libse/SubtitleFormats/UnknownSubtitle100.cs diff --git a/libse/SubtitleFormats/UnknownSubtitle101.cs b/src/libse/SubtitleFormats/UnknownSubtitle101.cs similarity index 100% rename from libse/SubtitleFormats/UnknownSubtitle101.cs rename to src/libse/SubtitleFormats/UnknownSubtitle101.cs diff --git a/libse/SubtitleFormats/UnknownSubtitle11.cs b/src/libse/SubtitleFormats/UnknownSubtitle11.cs similarity index 97% rename from libse/SubtitleFormats/UnknownSubtitle11.cs rename to src/libse/SubtitleFormats/UnknownSubtitle11.cs index 6adaaa110..818de403f 100644 --- a/libse/SubtitleFormats/UnknownSubtitle11.cs +++ b/src/libse/SubtitleFormats/UnknownSubtitle11.cs @@ -1,284 +1,284 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - /// MicroDVD with time codes...? - /// - public class UnknownSubtitle11 : SubtitleFormat - { - private static readonly Regex RegexMicroDvdLine = new Regex(@"^\{-?\d+:\d+:\d+}\{-?\d+:\d+:\d+}.*$", RegexOptions.Compiled); - - public override string Extension => ".sub"; - - public override string Name => "Unknown 11"; - - public override bool IsMine(List lines, string fileName) - { - var trimmedLines = new List(); - int errors = 0; - foreach (string line in lines) - { - if (line.Contains('{')) - { - string s = RemoveIllegalSpacesAndFixEmptyCodes(line); - if (RegexMicroDvdLine.IsMatch(s)) - { - trimmedLines.Add(s); - } - else - { - errors++; - } - } - else - { - errors++; - } - } - - return trimmedLines.Count > errors; - } - - private static string RemoveIllegalSpacesAndFixEmptyCodes(string line) - { - int index = line.IndexOf('}'); - if (index >= 0 && index < line.Length) - { - index = line.IndexOf('}', index + 1); - if (index >= 0 && index + 1 < line.Length) - { - var indexOfBrackets = line.IndexOf("{}", StringComparison.Ordinal); - if (indexOfBrackets >= 0 && indexOfBrackets < index) - { - line = line.Insert(indexOfBrackets + 1, "0"); // set empty time codes to zero - index++; - } - - while (line.Contains(' ') && line.IndexOf(' ') < index) - { - line = line.Remove(line.IndexOf(' '), 1); - index--; - } - } - } - return line; - } - - private static string MakeTimeCode(TimeCode tc) - { - return string.Format("{0}:{1:00}:{2:00}", tc.Hours, tc.Minutes, tc.Seconds); - } - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - sb.Append('{'); - sb.Append(MakeTimeCode(p.StartTime)); - sb.Append("}{"); - sb.Append(MakeTimeCode(p.EndTime)); - sb.Append('}'); - - //{y:b} is italics for single line - //{Y:b} is italics for both lines - - var parts = p.Text.SplitToLines(); - int count = 0; - bool italicOn = false; - bool boldOn = false; - bool underlineOn = false; - var lineSb = new StringBuilder(); - foreach (string line in parts) - { - if (count > 0) - { - lineSb.Append('|'); - } - - if (line.StartsWith("") || italicOn) - { - italicOn = true; - boldOn = false; - underlineOn = false; - lineSb.Append("{y:i}"); // italic single line - } - else if (line.StartsWith("") || boldOn) - { - italicOn = false; - boldOn = true; - underlineOn = false; - lineSb.Append("{y:b}"); // bold single line - } - else if (line.StartsWith("") || underlineOn) - { - italicOn = false; - boldOn = false; - underlineOn = true; - lineSb.Append("{y:u}"); // underline single line - } - - if (line.Contains("")) - { - italicOn = false; - } - - if (line.Contains("")) - { - boldOn = false; - } - - if (line.Contains("")) - { - underlineOn = false; - } - - lineSb.Append(HtmlUtil.RemoveHtmlTags(line)); - count++; - } - string text = lineSb.ToString(); - int noOfLines = Utilities.CountTagInText(text, '|') + 1; - if (noOfLines > 1 && Utilities.CountTagInText(text, "{y:i}") == noOfLines) - { - text = "{Y:i}" + text.Replace("{y:i}", string.Empty); - } - else if (noOfLines > 1 && Utilities.CountTagInText(text, "{y:b}") == noOfLines) - { - text = "{Y:b}" + text.Replace("{y:b}", string.Empty); - } - else if (noOfLines > 1 && Utilities.CountTagInText(text, "{y:u}") == noOfLines) - { - text = "{Y:u}" + text.Replace("{y:u}", string.Empty); - } - - sb.AppendLine(HtmlUtil.RemoveHtmlTags(text)); - } - return sb.ToString().Trim(); - } - - private static TimeCode DecodeTimeCode(string timeCode) - { - string[] arr = timeCode.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); - return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), 0); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - foreach (string line in lines) - { - string s = RemoveIllegalSpacesAndFixEmptyCodes(line); - if (RegexMicroDvdLine.IsMatch(s)) - { - try - { - int textIndex = GetTextStartIndex(s); - if (textIndex < s.Length) - { - string text = s.Substring(textIndex); - string temp = s.Substring(0, textIndex - 1); - string[] frames = temp.Replace("}{", ";").Replace("{", string.Empty).Replace("}", string.Empty).Split(';'); - - TimeCode startTime = DecodeTimeCode(frames[0]); - TimeCode endTime = DecodeTimeCode(frames[1]); - - string post = string.Empty; - string[] parts = text.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); - int count = 0; - var lineSb = new StringBuilder(); - foreach (string s2 in parts) - { - if (count > 0) - { - lineSb.AppendLine(); - } - - s = s2.Trim(); - if (s.StartsWith("{Y:i}")) - { - s = "" + s.Replace("{Y:i}", string.Empty); - post += ""; - } - else if (s.StartsWith("{Y:b}")) - { - s = "" + s.Replace("{Y:b}", string.Empty); - post += ""; - } - else if (s.StartsWith("{Y:u}")) - { - s = "" + s.Replace("{Y:u}", string.Empty); - post += ""; - } - else if (s.StartsWith("{y:i}")) - { - s = "" + s.Replace("{y:i}", string.Empty) + ""; - } - else if (s.StartsWith("{y:b}")) - { - s = "" + s.Replace("{y:b}", string.Empty) + ""; - } - else if (s.StartsWith("{y:u}")) - { - s = "" + s.Replace("{y:u}", string.Empty) + ""; - } - s = s.Replace("{Y:i}", string.Empty).Replace("{y:i}", string.Empty); - s = s.Replace("{Y:b}", string.Empty).Replace("{y:b}", string.Empty); - s = s.Replace("{Y:u}", string.Empty).Replace("{y:u}", string.Empty); - lineSb.Append(s); - count++; - } - text = lineSb + post; - subtitle.Paragraphs.Add(new Paragraph(startTime, endTime, text)); - } - } - catch - { - _errorCount++; - } - } - else - { - _errorCount++; - } - } - - int i = 0; - foreach (Paragraph p in subtitle.Paragraphs) - { - Paragraph previous = subtitle.GetParagraphOrDefault(i - 1); - if (p.StartTime.TotalMilliseconds == 0 && previous != null) - { - p.StartTime.TotalMilliseconds = previous.EndTime.TotalMilliseconds + 1; - } - if (p.EndTime.TotalMilliseconds == 0) - { - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds; - } - i++; - } - - subtitle.Renumber(); - } - - private static int GetTextStartIndex(string line) - { - int i = 0; - int tagCount = 0; - while (i < line.Length && tagCount < 4) - { - if (line[i] == '{' || line[i] == '}') - { - tagCount++; - } - i++; - } - return i; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + /// + /// MicroDVD with time codes...? + /// + public class UnknownSubtitle11 : SubtitleFormat + { + private static readonly Regex RegexMicroDvdLine = new Regex(@"^\{-?\d+:\d+:\d+}\{-?\d+:\d+:\d+}.*$", RegexOptions.Compiled); + + public override string Extension => ".sub"; + + public override string Name => "Unknown 11"; + + public override bool IsMine(List lines, string fileName) + { + var trimmedLines = new List(); + int errors = 0; + foreach (string line in lines) + { + if (line.Contains('{')) + { + string s = RemoveIllegalSpacesAndFixEmptyCodes(line); + if (RegexMicroDvdLine.IsMatch(s)) + { + trimmedLines.Add(s); + } + else + { + errors++; + } + } + else + { + errors++; + } + } + + return trimmedLines.Count > errors; + } + + private static string RemoveIllegalSpacesAndFixEmptyCodes(string line) + { + int index = line.IndexOf('}'); + if (index >= 0 && index < line.Length) + { + index = line.IndexOf('}', index + 1); + if (index >= 0 && index + 1 < line.Length) + { + var indexOfBrackets = line.IndexOf("{}", StringComparison.Ordinal); + if (indexOfBrackets >= 0 && indexOfBrackets < index) + { + line = line.Insert(indexOfBrackets + 1, "0"); // set empty time codes to zero + index++; + } + + while (line.Contains(' ') && line.IndexOf(' ') < index) + { + line = line.Remove(line.IndexOf(' '), 1); + index--; + } + } + } + return line; + } + + private static string MakeTimeCode(TimeCode tc) + { + return string.Format("{0}:{1:00}:{2:00}", tc.Hours, tc.Minutes, tc.Seconds); + } + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + sb.Append('{'); + sb.Append(MakeTimeCode(p.StartTime)); + sb.Append("}{"); + sb.Append(MakeTimeCode(p.EndTime)); + sb.Append('}'); + + //{y:b} is italics for single line + //{Y:b} is italics for both lines + + var parts = p.Text.SplitToLines(); + int count = 0; + bool italicOn = false; + bool boldOn = false; + bool underlineOn = false; + var lineSb = new StringBuilder(); + foreach (string line in parts) + { + if (count > 0) + { + lineSb.Append('|'); + } + + if (line.StartsWith("") || italicOn) + { + italicOn = true; + boldOn = false; + underlineOn = false; + lineSb.Append("{y:i}"); // italic single line + } + else if (line.StartsWith("") || boldOn) + { + italicOn = false; + boldOn = true; + underlineOn = false; + lineSb.Append("{y:b}"); // bold single line + } + else if (line.StartsWith("") || underlineOn) + { + italicOn = false; + boldOn = false; + underlineOn = true; + lineSb.Append("{y:u}"); // underline single line + } + + if (line.Contains("")) + { + italicOn = false; + } + + if (line.Contains("")) + { + boldOn = false; + } + + if (line.Contains("")) + { + underlineOn = false; + } + + lineSb.Append(HtmlUtil.RemoveHtmlTags(line)); + count++; + } + string text = lineSb.ToString(); + int noOfLines = Utilities.CountTagInText(text, '|') + 1; + if (noOfLines > 1 && Utilities.CountTagInText(text, "{y:i}") == noOfLines) + { + text = "{Y:i}" + text.Replace("{y:i}", string.Empty); + } + else if (noOfLines > 1 && Utilities.CountTagInText(text, "{y:b}") == noOfLines) + { + text = "{Y:b}" + text.Replace("{y:b}", string.Empty); + } + else if (noOfLines > 1 && Utilities.CountTagInText(text, "{y:u}") == noOfLines) + { + text = "{Y:u}" + text.Replace("{y:u}", string.Empty); + } + + sb.AppendLine(HtmlUtil.RemoveHtmlTags(text)); + } + return sb.ToString().Trim(); + } + + private static TimeCode DecodeTimeCode(string timeCode) + { + string[] arr = timeCode.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); + return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), 0); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + foreach (string line in lines) + { + string s = RemoveIllegalSpacesAndFixEmptyCodes(line); + if (RegexMicroDvdLine.IsMatch(s)) + { + try + { + int textIndex = GetTextStartIndex(s); + if (textIndex < s.Length) + { + string text = s.Substring(textIndex); + string temp = s.Substring(0, textIndex - 1); + string[] frames = temp.Replace("}{", ";").Replace("{", string.Empty).Replace("}", string.Empty).Split(';'); + + TimeCode startTime = DecodeTimeCode(frames[0]); + TimeCode endTime = DecodeTimeCode(frames[1]); + + string post = string.Empty; + string[] parts = text.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + int count = 0; + var lineSb = new StringBuilder(); + foreach (string s2 in parts) + { + if (count > 0) + { + lineSb.AppendLine(); + } + + s = s2.Trim(); + if (s.StartsWith("{Y:i}")) + { + s = "" + s.Replace("{Y:i}", string.Empty); + post += ""; + } + else if (s.StartsWith("{Y:b}")) + { + s = "" + s.Replace("{Y:b}", string.Empty); + post += ""; + } + else if (s.StartsWith("{Y:u}")) + { + s = "" + s.Replace("{Y:u}", string.Empty); + post += ""; + } + else if (s.StartsWith("{y:i}")) + { + s = "" + s.Replace("{y:i}", string.Empty) + ""; + } + else if (s.StartsWith("{y:b}")) + { + s = "" + s.Replace("{y:b}", string.Empty) + ""; + } + else if (s.StartsWith("{y:u}")) + { + s = "" + s.Replace("{y:u}", string.Empty) + ""; + } + s = s.Replace("{Y:i}", string.Empty).Replace("{y:i}", string.Empty); + s = s.Replace("{Y:b}", string.Empty).Replace("{y:b}", string.Empty); + s = s.Replace("{Y:u}", string.Empty).Replace("{y:u}", string.Empty); + lineSb.Append(s); + count++; + } + text = lineSb + post; + subtitle.Paragraphs.Add(new Paragraph(startTime, endTime, text)); + } + } + catch + { + _errorCount++; + } + } + else + { + _errorCount++; + } + } + + int i = 0; + foreach (Paragraph p in subtitle.Paragraphs) + { + Paragraph previous = subtitle.GetParagraphOrDefault(i - 1); + if (p.StartTime.TotalMilliseconds == 0 && previous != null) + { + p.StartTime.TotalMilliseconds = previous.EndTime.TotalMilliseconds + 1; + } + if (p.EndTime.TotalMilliseconds == 0) + { + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds; + } + i++; + } + + subtitle.Renumber(); + } + + private static int GetTextStartIndex(string line) + { + int i = 0; + int tagCount = 0; + while (i < line.Length && tagCount < 4) + { + if (line[i] == '{' || line[i] == '}') + { + tagCount++; + } + i++; + } + return i; + } + } +} diff --git a/libse/SubtitleFormats/UnknownSubtitle12.cs b/src/libse/SubtitleFormats/UnknownSubtitle12.cs similarity index 96% rename from libse/SubtitleFormats/UnknownSubtitle12.cs rename to src/libse/SubtitleFormats/UnknownSubtitle12.cs index 7931d8e65..305be1444 100644 --- a/libse/SubtitleFormats/UnknownSubtitle12.cs +++ b/src/libse/SubtitleFormats/UnknownSubtitle12.cs @@ -1,91 +1,91 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - ///4.01 5.12 - ///Dit is de dag. - /// - public class UnknownSubtitle12 : SubtitleFormat - { - private static readonly Regex RegexTimeCode = new Regex(@"^\d+\.\d\d\t\t\d+\.\d\d\t*$", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "Unknown 12"; - - private static string MakeTimeCode(TimeCode tc) - { - return string.Format(CultureInfo.InvariantCulture, "{0:0.00}", tc.TotalSeconds); - } - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - sb.Append(MakeTimeCode(p.StartTime)); - sb.Append("\t\t"); - sb.Append(MakeTimeCode(p.EndTime)); - sb.Append("\t\t\n"); - sb.Append(p.Text.Replace(Environment.NewLine, "\n") + "\n\n"); - } - return sb.ToString().Trim(); - } - - private static TimeCode DecodeTimeCode(string timeCode) - { - return TimeCode.FromSeconds(double.Parse(timeCode.Trim())); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - Paragraph p = null; - var text = new StringBuilder(); - foreach (string line in lines) - { - string s = line.Trim(); - if (RegexTimeCode.IsMatch(s)) - { - try - { - if (p != null) - { - p.Text = text.ToString().Trim(); - subtitle.Paragraphs.Add(p); - } - string[] arr = s.Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); - text.Clear(); - p = new Paragraph(DecodeTimeCode(arr[0]), DecodeTimeCode(arr[1]), ""); - } - catch - { - _errorCount++; - p = null; - } - } - else if (p != null) - { - text.AppendLine(s); - } - else - { - _errorCount++; - } - } - if (p != null && text.Length > 0) - { - p.Text = text.ToString().Trim(); - subtitle.Paragraphs.Add(p); - } - subtitle.Renumber(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + /// + ///4.01 5.12 + ///Dit is de dag. + /// + public class UnknownSubtitle12 : SubtitleFormat + { + private static readonly Regex RegexTimeCode = new Regex(@"^\d+\.\d\d\t\t\d+\.\d\d\t*$", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "Unknown 12"; + + private static string MakeTimeCode(TimeCode tc) + { + return string.Format(CultureInfo.InvariantCulture, "{0:0.00}", tc.TotalSeconds); + } + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + sb.Append(MakeTimeCode(p.StartTime)); + sb.Append("\t\t"); + sb.Append(MakeTimeCode(p.EndTime)); + sb.Append("\t\t\n"); + sb.Append(p.Text.Replace(Environment.NewLine, "\n") + "\n\n"); + } + return sb.ToString().Trim(); + } + + private static TimeCode DecodeTimeCode(string timeCode) + { + return TimeCode.FromSeconds(double.Parse(timeCode.Trim())); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + Paragraph p = null; + var text = new StringBuilder(); + foreach (string line in lines) + { + string s = line.Trim(); + if (RegexTimeCode.IsMatch(s)) + { + try + { + if (p != null) + { + p.Text = text.ToString().Trim(); + subtitle.Paragraphs.Add(p); + } + string[] arr = s.Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); + text.Clear(); + p = new Paragraph(DecodeTimeCode(arr[0]), DecodeTimeCode(arr[1]), ""); + } + catch + { + _errorCount++; + p = null; + } + } + else if (p != null) + { + text.AppendLine(s); + } + else + { + _errorCount++; + } + } + if (p != null && text.Length > 0) + { + p.Text = text.ToString().Trim(); + subtitle.Paragraphs.Add(p); + } + subtitle.Renumber(); + } + + } +} diff --git a/libse/SubtitleFormats/UnknownSubtitle13.cs b/src/libse/SubtitleFormats/UnknownSubtitle13.cs similarity index 97% rename from libse/SubtitleFormats/UnknownSubtitle13.cs rename to src/libse/SubtitleFormats/UnknownSubtitle13.cs index 3a29077dd..b8c24599c 100644 --- a/libse/SubtitleFormats/UnknownSubtitle13.cs +++ b/src/libse/SubtitleFormats/UnknownSubtitle13.cs @@ -1,120 +1,120 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class UnknownSubtitle13 : SubtitleFormat - { - public override string Extension => ".xml"; - - public override string Name => "Unknown 13"; - - public override string ToText(Subtitle subtitle, string title) - { - string xmlStructure = - "" + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - int id = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("entry"); - - XmlAttribute duration = xml.CreateAttribute("timeOut"); - duration.InnerText = p.EndTime.ToString(); - paragraph.Attributes.Append(duration); - - XmlAttribute start = xml.CreateAttribute("timeIn"); - start.InnerText = p.StartTime.ToString(); - paragraph.Attributes.Append(start); - - XmlAttribute idAttr = xml.CreateAttribute("id"); - idAttr.InnerText = id.ToString(CultureInfo.InvariantCulture); - paragraph.Attributes.Append(idAttr); - - paragraph.InnerText = " lines, string fileName) - { - _errorCount = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - - string allText = sb.ToString(); - if (!allText.Contains("") || !allText.Contains("timeIn=")) - { - return; - } - - var xml = new XmlDocument { XmlResolver = null }; - try - { - xml.LoadXml(allText); - } - catch (Exception exception) - { - System.Diagnostics.Debug.WriteLine(exception.Message); - _errorCount = 1; - return; - } - - foreach (XmlNode node in xml.DocumentElement.SelectNodes("entry")) - { - try - { - string start = node.Attributes["timeIn"].InnerText; - string end = node.Attributes["timeOut"].InnerText; - string text = node.InnerText; - if (text.StartsWith("![CDATA[", StringComparison.Ordinal)) - { - text = text.Remove(0, 8); - } - - if (text.StartsWith(" ".xml"; + + public override string Name => "Unknown 13"; + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + int id = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("entry"); + + XmlAttribute duration = xml.CreateAttribute("timeOut"); + duration.InnerText = p.EndTime.ToString(); + paragraph.Attributes.Append(duration); + + XmlAttribute start = xml.CreateAttribute("timeIn"); + start.InnerText = p.StartTime.ToString(); + paragraph.Attributes.Append(start); + + XmlAttribute idAttr = xml.CreateAttribute("id"); + idAttr.InnerText = id.ToString(CultureInfo.InvariantCulture); + paragraph.Attributes.Append(idAttr); + + paragraph.InnerText = " lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + + string allText = sb.ToString(); + if (!allText.Contains("") || !allText.Contains("timeIn=")) + { + return; + } + + var xml = new XmlDocument { XmlResolver = null }; + try + { + xml.LoadXml(allText); + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception.Message); + _errorCount = 1; + return; + } + + foreach (XmlNode node in xml.DocumentElement.SelectNodes("entry")) + { + try + { + string start = node.Attributes["timeIn"].InnerText; + string end = node.Attributes["timeOut"].InnerText; + string text = node.InnerText; + if (text.StartsWith("![CDATA[", StringComparison.Ordinal)) + { + text = text.Remove(0, 8); + } + + if (text.StartsWith(" ".xml"; - - public override string Name => "Unknown 14"; - - public override string ToText(Subtitle subtitle, string title) - { - // - // XYZ PRESENTS - // - - string xmlStructure = - "" + Environment.NewLine + - ""; - - var xml = new XmlDocument(); - xml.LoadXml(xmlStructure); - - foreach (Paragraph p in subtitle.Paragraphs) - { - XmlNode paragraph = xml.CreateElement("Phrase"); - - XmlAttribute start = xml.CreateAttribute("TimeStart"); - start.InnerText = ((long)(Math.Round(p.StartTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture); - paragraph.Attributes.Append(start); - - XmlAttribute end = xml.CreateAttribute("TimeEnd"); - end.InnerText = ((long)(Math.Round(p.EndTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture); - paragraph.Attributes.Append(end); - - XmlNode text = xml.CreateElement("Text"); - text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text).Replace(Environment.NewLine, "\\n"); - paragraph.AppendChild(text); - - xml.DocumentElement.AppendChild(paragraph); - } - - return ToUtf8XmlString(xml); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - - var sb = new StringBuilder(); - lines.ForEach(line => sb.AppendLine(line)); - - string allText = sb.ToString(); - if (!allText.Contains(" ".xml"; + + public override string Name => "Unknown 14"; + + public override string ToText(Subtitle subtitle, string title) + { + // + // XYZ PRESENTS + // + + string xmlStructure = + "" + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + foreach (Paragraph p in subtitle.Paragraphs) + { + XmlNode paragraph = xml.CreateElement("Phrase"); + + XmlAttribute start = xml.CreateAttribute("TimeStart"); + start.InnerText = ((long)(Math.Round(p.StartTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture); + paragraph.Attributes.Append(start); + + XmlAttribute end = xml.CreateAttribute("TimeEnd"); + end.InnerText = ((long)(Math.Round(p.EndTime.TotalMilliseconds))).ToString(CultureInfo.InvariantCulture); + paragraph.Attributes.Append(end); + + XmlNode text = xml.CreateElement("Text"); + text.InnerText = HtmlUtil.RemoveHtmlTags(p.Text).Replace(Environment.NewLine, "\\n"); + paragraph.AppendChild(text); + + xml.DocumentElement.AppendChild(paragraph); + } + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + + string allText = sb.ToString(); + if (!allText.Contains(" ".xml"; - - public override string Name => "Unknown 15"; - - private static string ToTimeCode(TimeCode tc) - { - int last = (int)Math.Round(tc.Milliseconds / 10.0D + 0.5D); - return tc.ToString().Substring(0, 8) + ":" + string.Format("{0:0#}", last); - } - - private static TimeCode DecodeTimeCode(string s) - { - var parts = s.Split(new[] { ';', ':' }, StringSplitOptions.RemoveEmptyEntries); - return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3]) * 100); - } - - public override string ToText(Subtitle subtitle, string title) - { - // - //
")) - { - return; - } - - var xml = new XmlDocument { XmlResolver = null }; - try - { - string xmlText = sb.ToString(); - xml.LoadXml(xmlText); - var styles = new List { "speech" }; - - if (_promptForStyles) - { - var stylesWithCount = new Dictionary(); - foreach (XmlNode node in xml.SelectNodes("//annotation")) - { - try - { - if (node.Attributes["style"] != null && node.Attributes["style"].Value != null) - { - string style = node.Attributes["style"].Value; - - XmlNode textNode = node.SelectSingleNode("TEXT"); - XmlNodeList regions = node.SelectNodes("segment/movingRegion/anchoredRegion"); - - if (regions.Count != 2) - { - regions = node.SelectNodes("segment/movingRegion/rectRegion"); - } - - if (textNode != null && regions.Count == 2) - { - if (stylesWithCount.ContainsKey(style)) - { - stylesWithCount[style]++; - } - else - { - stylesWithCount.Add(style, 1); - } - } - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - } - } - if (stylesWithCount.Count > 1 && GetYouTubeAnnotationStyles != null) - { - styles = GetYouTubeAnnotationStyles.GetYouTubeAnnotationStyles(stylesWithCount); - } - else - { - styles.Clear(); - foreach (var k in stylesWithCount.Keys) - { - styles.Add(k); - } - } - } - else - { - styles.Add("popup"); - styles.Add("anchored"); - } - - foreach (XmlNode node in xml.SelectNodes("//annotation")) - { - try - { - if (node.Attributes["style"] != null && styles.Contains(node.Attributes["style"].Value)) - { - XmlNode textNode = node.SelectSingleNode("TEXT"); - XmlNodeList regions = node.SelectNodes("segment/movingRegion/anchoredRegion"); - - if (regions.Count != 2) - { - regions = node.SelectNodes("segment/movingRegion/rectRegion"); - } - - if (textNode != null && regions.Count == 2) - { - string startTime = regions[0].Attributes["t"].Value; - string endTime = regions[1].Attributes["t"].Value; - var p = new Paragraph(); - p.StartTime = DecodeTimeCode(startTime); - p.EndTime = DecodeTimeCode(endTime); - p.Text = textNode.InnerText; - subtitle.Paragraphs.Add(p); - } - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount++; - } - } - subtitle.Sort(SubtitleSortCriteria.StartTime); // force order by start time - subtitle.Renumber(); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - _errorCount = 1; - } - } - - private static TimeCode DecodeTimeCode(string time) - { - var arr = time.Split(new[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries); - if (arr.Length == 3) - { - return new TimeCode(0, int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); - } - - return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3])); - } - - private static string EncodeTime(TimeCode timeCode) - { - //0:01:08.0 - return $"{timeCode.Hours}:{timeCode.Minutes:00}:{timeCode.Seconds:00}.{timeCode.Milliseconds}"; - } - } -} +using Nikse.SubtitleEdit.Core.Enums; +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class YouTubeAnnotations : SubtitleFormat + { + public interface IGetYouTubeAnnotationStyles + { + List GetYouTubeAnnotationStyles(Dictionary stylesWithCount); + } + + public static IGetYouTubeAnnotationStyles GetYouTubeAnnotationStyles { get; set; } + + private bool _promptForStyles = true; + + public override string Extension => ".xml"; + + public static readonly string NameOfFormat = "YouTube Annotations"; + + public override string Name => NameOfFormat; + + public override bool IsMine(List lines, string fileName) + { + var subtitle = new Subtitle(); + _promptForStyles = false; + LoadSubtitle(subtitle, lines, fileName); + _promptForStyles = true; + return subtitle.Paragraphs.Count > 0; + } + + public override string ToText(Subtitle subtitle, string title) + { + string xmlStructure = + "" + Environment.NewLine + + "" + Environment.NewLine + + " " + Environment.NewLine + + " " + Environment.NewLine + + ""; + + var xml = new XmlDocument(); + xml.LoadXml(xmlStructure); + + XmlNode annotations = xml.DocumentElement.SelectSingleNode("annotations"); + + int count = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + // + // BUT now something inside is BROKEN! + // + // + // + // + // + // + // + + XmlNode annotation = xml.CreateElement("annotation"); + + XmlAttribute att = xml.CreateAttribute("id"); + att.InnerText = "annotation_" + count; + annotation.Attributes.Append(att); + + att = xml.CreateAttribute("author"); + att.InnerText = "Subtitle Edit"; + annotation.Attributes.Append(att); + + att = xml.CreateAttribute("type"); + att.InnerText = "text"; + annotation.Attributes.Append(att); + + att = xml.CreateAttribute("style"); + att.InnerText = "speech"; + annotation.Attributes.Append(att); + + XmlNode text = xml.CreateElement("TEXT"); + text.InnerText = p.Text; + annotation.AppendChild(text); + + XmlNode segment = xml.CreateElement("segment"); + annotation.AppendChild(segment); + + XmlNode movingRegion = xml.CreateElement("movingRegion"); + segment.AppendChild(movingRegion); + + att = xml.CreateAttribute("type"); + att.InnerText = "anchored"; + movingRegion.Attributes.Append(att); + + XmlNode anchoredRegion = xml.CreateElement("anchoredRegion"); + movingRegion.AppendChild(anchoredRegion); + att = xml.CreateAttribute("t"); + att.InnerText = EncodeTime(p.StartTime); + anchoredRegion.Attributes.Append(att); + att = xml.CreateAttribute("d"); + att.InnerText = "0"; + anchoredRegion.Attributes.Append(att); + + anchoredRegion = xml.CreateElement("anchoredRegion"); + movingRegion.AppendChild(anchoredRegion); + att = xml.CreateAttribute("t"); + att.InnerText = EncodeTime(p.EndTime); + anchoredRegion.Attributes.Append(att); + att = xml.CreateAttribute("d"); + att.InnerText = "0"; + anchoredRegion.Attributes.Append(att); + + annotations.AppendChild(annotation); + count++; + } + + return ToUtf8XmlString(xml); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + + var sb = new StringBuilder(); + lines.ForEach(line => sb.AppendLine(line)); + if (!sb.ToString().Contains("") || !sb.ToString().Contains("
")) + { + return; + } + + var xml = new XmlDocument { XmlResolver = null }; + try + { + string xmlText = sb.ToString(); + xml.LoadXml(xmlText); + var styles = new List { "speech" }; + + if (_promptForStyles) + { + var stylesWithCount = new Dictionary(); + foreach (XmlNode node in xml.SelectNodes("//annotation")) + { + try + { + if (node.Attributes["style"] != null && node.Attributes["style"].Value != null) + { + string style = node.Attributes["style"].Value; + + XmlNode textNode = node.SelectSingleNode("TEXT"); + XmlNodeList regions = node.SelectNodes("segment/movingRegion/anchoredRegion"); + + if (regions.Count != 2) + { + regions = node.SelectNodes("segment/movingRegion/rectRegion"); + } + + if (textNode != null && regions.Count == 2) + { + if (stylesWithCount.ContainsKey(style)) + { + stylesWithCount[style]++; + } + else + { + stylesWithCount.Add(style, 1); + } + } + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + } + } + if (stylesWithCount.Count > 1 && GetYouTubeAnnotationStyles != null) + { + styles = GetYouTubeAnnotationStyles.GetYouTubeAnnotationStyles(stylesWithCount); + } + else + { + styles.Clear(); + foreach (var k in stylesWithCount.Keys) + { + styles.Add(k); + } + } + } + else + { + styles.Add("popup"); + styles.Add("anchored"); + } + + foreach (XmlNode node in xml.SelectNodes("//annotation")) + { + try + { + if (node.Attributes["style"] != null && styles.Contains(node.Attributes["style"].Value)) + { + XmlNode textNode = node.SelectSingleNode("TEXT"); + XmlNodeList regions = node.SelectNodes("segment/movingRegion/anchoredRegion"); + + if (regions.Count != 2) + { + regions = node.SelectNodes("segment/movingRegion/rectRegion"); + } + + if (textNode != null && regions.Count == 2) + { + string startTime = regions[0].Attributes["t"].Value; + string endTime = regions[1].Attributes["t"].Value; + var p = new Paragraph(); + p.StartTime = DecodeTimeCode(startTime); + p.EndTime = DecodeTimeCode(endTime); + p.Text = textNode.InnerText; + subtitle.Paragraphs.Add(p); + } + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount++; + } + } + subtitle.Sort(SubtitleSortCriteria.StartTime); // force order by start time + subtitle.Renumber(); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex.Message); + _errorCount = 1; + } + } + + private static TimeCode DecodeTimeCode(string time) + { + var arr = time.Split(new[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries); + if (arr.Length == 3) + { + return new TimeCode(0, int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); + } + + return new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3])); + } + + private static string EncodeTime(TimeCode timeCode) + { + //0:01:08.0 + return $"{timeCode.Hours}:{timeCode.Minutes:00}:{timeCode.Seconds:00}.{timeCode.Milliseconds}"; + } + } +} diff --git a/libse/SubtitleFormats/YouTubeSbv.cs b/src/libse/SubtitleFormats/YouTubeSbv.cs similarity index 97% rename from libse/SubtitleFormats/YouTubeSbv.cs rename to src/libse/SubtitleFormats/YouTubeSbv.cs index 85bf3b839..dc8fee3fe 100644 --- a/libse/SubtitleFormats/YouTubeSbv.cs +++ b/src/libse/SubtitleFormats/YouTubeSbv.cs @@ -1,179 +1,179 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - /// - /// YouTube "SubViewer" format... I think YouTube tried to add "SubViewer 2.0" support but instread they created their own format... nice ;) - /// - public class YouTubeSbv : SubtitleFormat - { - private enum ExpectingLine - { - TimeCodes, - Text - } - - private Paragraph _paragraph; - private ExpectingLine _expecting = ExpectingLine.TimeCodes; - private static readonly Regex RegexTimeCodes = new Regex(@"^-?\d+:-?\d+:-?\d+[:,.]-?\d+,\d+:-?\d+:-?\d+[:,.]-?\d+$", RegexOptions.Compiled); - - public override string Extension => ".sbv"; - - public override string Name => "YouTube sbv"; - - public override string ToText(Subtitle subtitle, string title) - { - const string paragraphWriteFormat = "{0},{1}\r\n{2}\r\n\r\n"; - - var sb = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - sb.AppendFormat(paragraphWriteFormat, FormatTime(p.StartTime), FormatTime(p.EndTime), p.Text); - } - return sb.ToString().Trim(); - } - - private static string FormatTime(TimeCode timeCode) - { - return $"{timeCode.Hours}:{timeCode.Minutes:00}:{timeCode.Seconds:00}.{timeCode.Milliseconds:000}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - //0:00:07.500,0:00:13.500 - //In den Bergen über Musanze in Ruanda feiert die Trustbank (Kreditnehmer-Gruppe) "Trususanze" ihren Erfolg. - - //0:00:14.000,0:00:17.000 - //Indem sie ihre Zukunft einander anvertraut haben, haben sie sich - - _paragraph = new Paragraph(); - _expecting = ExpectingLine.TimeCodes; - _errorCount = 0; - - subtitle.Paragraphs.Clear(); - for (int i = 0; i < lines.Count; i++) - { - string line = lines[i].TrimEnd(); - string next = string.Empty; - if (i + 1 < lines.Count) - { - next = lines[i + 1]; - } - - // A new line is missing between two paragraphs (buggy srt file) - if (_expecting == ExpectingLine.Text && i + 1 < lines.Count && - _paragraph != null && !string.IsNullOrEmpty(_paragraph.Text) && - RegexTimeCodes.IsMatch(lines[i])) - { - ReadLine(subtitle, string.Empty, string.Empty); - } - - ReadLine(subtitle, line, next); - } - if (_paragraph != null && !string.IsNullOrWhiteSpace(_paragraph.Text)) - { - subtitle.Paragraphs.Add(_paragraph); - } - - foreach (Paragraph p in subtitle.Paragraphs) - { - p.Text = p.Text.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); - } - - subtitle.Renumber(); - } - - private void ReadLine(Subtitle subtitle, string line, string next) - { - switch (_expecting) - { - case ExpectingLine.TimeCodes: - if (TryReadTimeCodesLine(line, _paragraph)) - { - _paragraph.Text = string.Empty; - _expecting = ExpectingLine.Text; - } - else if (!string.IsNullOrWhiteSpace(line)) - { - _errorCount++; - } - break; - case ExpectingLine.Text: - if (!string.IsNullOrWhiteSpace(line)) - { - if (_paragraph.Text.Length > 0) - { - _paragraph.Text += Environment.NewLine; - } - - _paragraph.Text += RemoveBadChars(line).TrimEnd(); - } - else if (IsText(next)) - { - if (_paragraph.Text.Length > 0) - { - _paragraph.Text += Environment.NewLine; - } - - _paragraph.Text += RemoveBadChars(line).TrimEnd(); - } - else - { - subtitle.Paragraphs.Add(_paragraph); - _paragraph = new Paragraph(); - _expecting = ExpectingLine.TimeCodes; - } - break; - } - } - - private static bool IsText(string text) - { - if (string.IsNullOrWhiteSpace(text) || Utilities.IsInteger(text) || RegexTimeCodes.IsMatch(text)) - { - return false; - } - - return true; - } - - private static string RemoveBadChars(string line) - { - return line.Replace('\0', ' '); - } - - private static bool TryReadTimeCodesLine(string inputLine, Paragraph paragraph) - { - var line = inputLine.Replace('.', ':').Replace('،', ',').Replace('¡', ':'); - - if (RegexTimeCodes.IsMatch(line)) - { - line = line.Replace(',', ':'); - string[] parts = line.RemoveChar(' ').Split(':', ','); - try - { - int startHours = int.Parse(parts[0]); - int startMinutes = int.Parse(parts[1]); - int startSeconds = int.Parse(parts[2]); - int startMilliseconds = int.Parse(parts[3]); - int endHours = int.Parse(parts[4]); - int endMinutes = int.Parse(parts[5]); - int endSeconds = int.Parse(parts[6]); - int endMilliseconds = int.Parse(parts[7]); - paragraph.StartTime = new TimeCode(startHours, startMinutes, startSeconds, startMilliseconds); - paragraph.EndTime = new TimeCode(endHours, endMinutes, endSeconds, endMilliseconds); - return true; - } - catch - { - return false; - } - } - return false; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + /// + /// YouTube "SubViewer" format... I think YouTube tried to add "SubViewer 2.0" support but instread they created their own format... nice ;) + /// + public class YouTubeSbv : SubtitleFormat + { + private enum ExpectingLine + { + TimeCodes, + Text + } + + private Paragraph _paragraph; + private ExpectingLine _expecting = ExpectingLine.TimeCodes; + private static readonly Regex RegexTimeCodes = new Regex(@"^-?\d+:-?\d+:-?\d+[:,.]-?\d+,\d+:-?\d+:-?\d+[:,.]-?\d+$", RegexOptions.Compiled); + + public override string Extension => ".sbv"; + + public override string Name => "YouTube sbv"; + + public override string ToText(Subtitle subtitle, string title) + { + const string paragraphWriteFormat = "{0},{1}\r\n{2}\r\n\r\n"; + + var sb = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + sb.AppendFormat(paragraphWriteFormat, FormatTime(p.StartTime), FormatTime(p.EndTime), p.Text); + } + return sb.ToString().Trim(); + } + + private static string FormatTime(TimeCode timeCode) + { + return $"{timeCode.Hours}:{timeCode.Minutes:00}:{timeCode.Seconds:00}.{timeCode.Milliseconds:000}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + //0:00:07.500,0:00:13.500 + //In den Bergen über Musanze in Ruanda feiert die Trustbank (Kreditnehmer-Gruppe) "Trususanze" ihren Erfolg. + + //0:00:14.000,0:00:17.000 + //Indem sie ihre Zukunft einander anvertraut haben, haben sie sich + + _paragraph = new Paragraph(); + _expecting = ExpectingLine.TimeCodes; + _errorCount = 0; + + subtitle.Paragraphs.Clear(); + for (int i = 0; i < lines.Count; i++) + { + string line = lines[i].TrimEnd(); + string next = string.Empty; + if (i + 1 < lines.Count) + { + next = lines[i + 1]; + } + + // A new line is missing between two paragraphs (buggy srt file) + if (_expecting == ExpectingLine.Text && i + 1 < lines.Count && + _paragraph != null && !string.IsNullOrEmpty(_paragraph.Text) && + RegexTimeCodes.IsMatch(lines[i])) + { + ReadLine(subtitle, string.Empty, string.Empty); + } + + ReadLine(subtitle, line, next); + } + if (_paragraph != null && !string.IsNullOrWhiteSpace(_paragraph.Text)) + { + subtitle.Paragraphs.Add(_paragraph); + } + + foreach (Paragraph p in subtitle.Paragraphs) + { + p.Text = p.Text.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); + } + + subtitle.Renumber(); + } + + private void ReadLine(Subtitle subtitle, string line, string next) + { + switch (_expecting) + { + case ExpectingLine.TimeCodes: + if (TryReadTimeCodesLine(line, _paragraph)) + { + _paragraph.Text = string.Empty; + _expecting = ExpectingLine.Text; + } + else if (!string.IsNullOrWhiteSpace(line)) + { + _errorCount++; + } + break; + case ExpectingLine.Text: + if (!string.IsNullOrWhiteSpace(line)) + { + if (_paragraph.Text.Length > 0) + { + _paragraph.Text += Environment.NewLine; + } + + _paragraph.Text += RemoveBadChars(line).TrimEnd(); + } + else if (IsText(next)) + { + if (_paragraph.Text.Length > 0) + { + _paragraph.Text += Environment.NewLine; + } + + _paragraph.Text += RemoveBadChars(line).TrimEnd(); + } + else + { + subtitle.Paragraphs.Add(_paragraph); + _paragraph = new Paragraph(); + _expecting = ExpectingLine.TimeCodes; + } + break; + } + } + + private static bool IsText(string text) + { + if (string.IsNullOrWhiteSpace(text) || Utilities.IsInteger(text) || RegexTimeCodes.IsMatch(text)) + { + return false; + } + + return true; + } + + private static string RemoveBadChars(string line) + { + return line.Replace('\0', ' '); + } + + private static bool TryReadTimeCodesLine(string inputLine, Paragraph paragraph) + { + var line = inputLine.Replace('.', ':').Replace('،', ',').Replace('¡', ':'); + + if (RegexTimeCodes.IsMatch(line)) + { + line = line.Replace(',', ':'); + string[] parts = line.RemoveChar(' ').Split(':', ','); + try + { + int startHours = int.Parse(parts[0]); + int startMinutes = int.Parse(parts[1]); + int startSeconds = int.Parse(parts[2]); + int startMilliseconds = int.Parse(parts[3]); + int endHours = int.Parse(parts[4]); + int endMinutes = int.Parse(parts[5]); + int endSeconds = int.Parse(parts[6]); + int endMilliseconds = int.Parse(parts[7]); + paragraph.StartTime = new TimeCode(startHours, startMinutes, startSeconds, startMilliseconds); + paragraph.EndTime = new TimeCode(endHours, endMinutes, endSeconds, endMilliseconds); + return true; + } + catch + { + return false; + } + } + return false; + } + } +} diff --git a/libse/SubtitleFormats/YouTubeTranscript.cs b/src/libse/SubtitleFormats/YouTubeTranscript.cs similarity index 97% rename from libse/SubtitleFormats/YouTubeTranscript.cs rename to src/libse/SubtitleFormats/YouTubeTranscript.cs index 364936438..0ca65ff2e 100644 --- a/libse/SubtitleFormats/YouTubeTranscript.cs +++ b/src/libse/SubtitleFormats/YouTubeTranscript.cs @@ -1,96 +1,96 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class YouTubeTranscript : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d{1,3}:\d\d$", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "YouTube Transcript"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - sb.AppendLine(string.Format("{0}" + Environment.NewLine + "{1}", EncodeTimeCode(p.StartTime), HtmlUtil.RemoveHtmlTags(p.Text.Replace(Environment.NewLine, " ")))); - } - return sb.ToString(); - } - - public override bool IsMine(List lines, string fileName) - { - if (new UnknownSubtitle88().IsMine(lines, fileName)) - { - return false; - } - - return base.IsMine(lines, fileName); - } - - private static string EncodeTimeCode(TimeCode time) - { - return $"{time.Hours * 60 + time.Minutes}:{time.Seconds:00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - Paragraph p = null; - subtitle.Paragraphs.Clear(); - foreach (string line in lines) - { - var s = line.TrimEnd(); - if (RegexTimeCodes.IsMatch(s)) - { - p = new Paragraph(DecodeTimeCode(s), new TimeCode(), string.Empty); - subtitle.Paragraphs.Add(p); - } - else if (string.IsNullOrWhiteSpace(s)) - { - // skip these lines - } - else if (p != null) - { - if (string.IsNullOrEmpty(p.Text)) - { - p.Text = s; - } - else - { - p.Text = p.Text + Environment.NewLine + s; - } - - if (p.Text.Length > 800) - { - _errorCount++; - return; - } - } - } - foreach (Paragraph p2 in subtitle.Paragraphs) - { - p2.Text = Utilities.AutoBreakLine(p2.Text); - } - subtitle.RecalculateDisplayTimes(Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds, null, Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds); - subtitle.Renumber(); - } - - private static TimeCode DecodeTimeCode(string s) - { - string[] parts = s.Split(':'); - - var minutes = int.Parse(parts[0]); - var seconds = int.Parse(parts[1]); - - return new TimeCode(0, minutes, seconds, 0); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class YouTubeTranscript : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d{1,3}:\d\d$", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "YouTube Transcript"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + sb.AppendLine(string.Format("{0}" + Environment.NewLine + "{1}", EncodeTimeCode(p.StartTime), HtmlUtil.RemoveHtmlTags(p.Text.Replace(Environment.NewLine, " ")))); + } + return sb.ToString(); + } + + public override bool IsMine(List lines, string fileName) + { + if (new UnknownSubtitle88().IsMine(lines, fileName)) + { + return false; + } + + return base.IsMine(lines, fileName); + } + + private static string EncodeTimeCode(TimeCode time) + { + return $"{time.Hours * 60 + time.Minutes}:{time.Seconds:00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + Paragraph p = null; + subtitle.Paragraphs.Clear(); + foreach (string line in lines) + { + var s = line.TrimEnd(); + if (RegexTimeCodes.IsMatch(s)) + { + p = new Paragraph(DecodeTimeCode(s), new TimeCode(), string.Empty); + subtitle.Paragraphs.Add(p); + } + else if (string.IsNullOrWhiteSpace(s)) + { + // skip these lines + } + else if (p != null) + { + if (string.IsNullOrEmpty(p.Text)) + { + p.Text = s; + } + else + { + p.Text = p.Text + Environment.NewLine + s; + } + + if (p.Text.Length > 800) + { + _errorCount++; + return; + } + } + } + foreach (Paragraph p2 in subtitle.Paragraphs) + { + p2.Text = Utilities.AutoBreakLine(p2.Text); + } + subtitle.RecalculateDisplayTimes(Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds, null, Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds); + subtitle.Renumber(); + } + + private static TimeCode DecodeTimeCode(string s) + { + string[] parts = s.Split(':'); + + var minutes = int.Parse(parts[0]); + var seconds = int.Parse(parts[1]); + + return new TimeCode(0, minutes, seconds, 0); + } + + } +} diff --git a/libse/SubtitleFormats/YouTubeTranscriptOneLine.cs b/src/libse/SubtitleFormats/YouTubeTranscriptOneLine.cs similarity index 97% rename from libse/SubtitleFormats/YouTubeTranscriptOneLine.cs rename to src/libse/SubtitleFormats/YouTubeTranscriptOneLine.cs index 2ed4a315f..dc672ee32 100644 --- a/libse/SubtitleFormats/YouTubeTranscriptOneLine.cs +++ b/src/libse/SubtitleFormats/YouTubeTranscriptOneLine.cs @@ -1,76 +1,76 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class YouTubeTranscriptOneLine : SubtitleFormat - { - private static readonly Regex RegexTimeCodes = new Regex(@"^\d{1,3}:\d\d.+$", RegexOptions.Compiled); - - public override string Extension => ".txt"; - - public override string Name => "YouTube Transcript one line"; - - public override string ToText(Subtitle subtitle, string title) - { - var sb = new StringBuilder(); - const string writeFormat = "{0}{1}"; - foreach (Paragraph p in subtitle.Paragraphs) - { - sb.AppendLine(string.Format(writeFormat, EncodeTimeCode(p.StartTime), HtmlUtil.RemoveHtmlTags(p.Text.Replace(Environment.NewLine, " ")))); - } - return sb.ToString(); - } - - private static string EncodeTimeCode(TimeCode time) - { - return $"{time.Hours * 60 + time.Minutes}:{time.Seconds:00}"; - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - subtitle.Paragraphs.Clear(); - char[] trimChars = { '–', '.', ';', ':' }; - foreach (string line in lines) - { - if (RegexTimeCodes.IsMatch(line)) - { - int splitter = line.IndexOf(':') + 3; - string text = line.Remove(0, splitter); - var p = new Paragraph(DecodeTimeCode(line.Substring(0, splitter)), new TimeCode(), text); - subtitle.Paragraphs.Add(p); - text = text.Trim().Trim(trimChars).Trim(); - if (text.Length > 0 && char.IsDigit(text[0])) - { - _errorCount++; - } - } - else - { - _errorCount += 2; - } - } - foreach (Paragraph p2 in subtitle.Paragraphs) - { - p2.Text = Utilities.AutoBreakLine(p2.Text); - } - subtitle.RecalculateDisplayTimes(Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds, null, Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds); - subtitle.Renumber(); - } - - private static TimeCode DecodeTimeCode(string s) - { - string[] parts = s.Split(':'); - - string minutes = parts[0]; - string seconds = parts[1]; - - return new TimeCode(0, int.Parse(minutes), int.Parse(seconds), 0); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class YouTubeTranscriptOneLine : SubtitleFormat + { + private static readonly Regex RegexTimeCodes = new Regex(@"^\d{1,3}:\d\d.+$", RegexOptions.Compiled); + + public override string Extension => ".txt"; + + public override string Name => "YouTube Transcript one line"; + + public override string ToText(Subtitle subtitle, string title) + { + var sb = new StringBuilder(); + const string writeFormat = "{0}{1}"; + foreach (Paragraph p in subtitle.Paragraphs) + { + sb.AppendLine(string.Format(writeFormat, EncodeTimeCode(p.StartTime), HtmlUtil.RemoveHtmlTags(p.Text.Replace(Environment.NewLine, " ")))); + } + return sb.ToString(); + } + + private static string EncodeTimeCode(TimeCode time) + { + return $"{time.Hours * 60 + time.Minutes}:{time.Seconds:00}"; + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + subtitle.Paragraphs.Clear(); + char[] trimChars = { '–', '.', ';', ':' }; + foreach (string line in lines) + { + if (RegexTimeCodes.IsMatch(line)) + { + int splitter = line.IndexOf(':') + 3; + string text = line.Remove(0, splitter); + var p = new Paragraph(DecodeTimeCode(line.Substring(0, splitter)), new TimeCode(), text); + subtitle.Paragraphs.Add(p); + text = text.Trim().Trim(trimChars).Trim(); + if (text.Length > 0 && char.IsDigit(text[0])) + { + _errorCount++; + } + } + else + { + _errorCount += 2; + } + } + foreach (Paragraph p2 in subtitle.Paragraphs) + { + p2.Text = Utilities.AutoBreakLine(p2.Text); + } + subtitle.RecalculateDisplayTimes(Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds, null, Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds); + subtitle.Renumber(); + } + + private static TimeCode DecodeTimeCode(string s) + { + string[] parts = s.Split(':'); + + string minutes = parts[0]; + string seconds = parts[1]; + + return new TimeCode(0, int.Parse(minutes), int.Parse(seconds), 0); + } + + } +} diff --git a/libse/SubtitleFormats/ZeroG.cs b/src/libse/SubtitleFormats/ZeroG.cs similarity index 97% rename from libse/SubtitleFormats/ZeroG.cs rename to src/libse/SubtitleFormats/ZeroG.cs index 0771182b5..db327292d 100644 --- a/libse/SubtitleFormats/ZeroG.cs +++ b/src/libse/SubtitleFormats/ZeroG.cs @@ -1,83 +1,83 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Core.SubtitleFormats -{ - public class ZeroG : SubtitleFormat - { - //E 1 0:50:05.42 0:50:10.06 Default NTP - private static readonly Regex RegexTimeCodes = new Regex(@"^E 1 \d:\d\d:\d\d.\d\d \d:\d\d:\d\d.\d\d Default NTP ", RegexOptions.Compiled); - - public override string Extension => ".zeg"; - - public override string Name => "Zero G"; - - public override string ToText(Subtitle subtitle, string title) - { - //% Zero G 1.0 - - //E 1 0:50:20.22 0:50:21.38 Default NTP Die Frage ist: - //E 1 0:50:21.54 0:50:25.86 Default NTP Wieso habe ich überlebt? - //E 1 0:50:27.30 0:50:30.78 Default NTP Was habe ich richtig gemacht? \n Ich weiß es nicht. - const string paragraphWriteFormat = "E 1 {0} {1} Default NTP {2}"; - - var sb = new StringBuilder(); - sb.AppendLine("% Zero G 1.0"); - sb.AppendLine(); - foreach (Paragraph p in subtitle.Paragraphs) - { - string text = p.Text.Replace(Environment.NewLine, " \\n "); - sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), text)); - } - return sb.ToString().Trim(); - } - - public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) - { - _errorCount = 0; - subtitle.Paragraphs.Clear(); - foreach (string line in lines) - { - var s = line.Trim(); - if (s.Length > 35 && RegexTimeCodes.IsMatch(s)) - { - try - { - string timePart = s.Substring(4, 10).TrimEnd(); - var start = DecodeTimeCode(timePart); - timePart = s.Substring(15, 10).Trim(); - var end = DecodeTimeCode(timePart); - var paragraph = new Paragraph { StartTime = start, EndTime = end }; - paragraph.Text = s.Substring(38).Replace(" \\n ", Environment.NewLine).Replace("\\n", Environment.NewLine); - subtitle.Paragraphs.Add(paragraph); - } - catch - { - _errorCount++; - } - } - } - subtitle.Renumber(); - } - - private static string EncodeTimeCode(TimeCode time) - { - //0:50:05.42 - return string.Format("{0:0}:{1:00}:{2:00}.{3:00}", time.Hours, time.Minutes, time.Seconds, time.Milliseconds / 10); - } - - private static TimeCode DecodeTimeCode(string timePart) - { - string[] parts = timePart.Split(new[] { ':', '.' }, StringSplitOptions.RemoveEmptyEntries); - int hours = int.Parse(parts[0]); - int minutes = int.Parse(parts[1]); - int seconds = int.Parse(parts[2]); - int milliseconds = int.Parse(parts[3]) * 10; - return new TimeCode(hours, minutes, seconds, milliseconds); - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Core.SubtitleFormats +{ + public class ZeroG : SubtitleFormat + { + //E 1 0:50:05.42 0:50:10.06 Default NTP + private static readonly Regex RegexTimeCodes = new Regex(@"^E 1 \d:\d\d:\d\d.\d\d \d:\d\d:\d\d.\d\d Default NTP ", RegexOptions.Compiled); + + public override string Extension => ".zeg"; + + public override string Name => "Zero G"; + + public override string ToText(Subtitle subtitle, string title) + { + //% Zero G 1.0 + + //E 1 0:50:20.22 0:50:21.38 Default NTP Die Frage ist: + //E 1 0:50:21.54 0:50:25.86 Default NTP Wieso habe ich überlebt? + //E 1 0:50:27.30 0:50:30.78 Default NTP Was habe ich richtig gemacht? \n Ich weiß es nicht. + const string paragraphWriteFormat = "E 1 {0} {1} Default NTP {2}"; + + var sb = new StringBuilder(); + sb.AppendLine("% Zero G 1.0"); + sb.AppendLine(); + foreach (Paragraph p in subtitle.Paragraphs) + { + string text = p.Text.Replace(Environment.NewLine, " \\n "); + sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), text)); + } + return sb.ToString().Trim(); + } + + public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) + { + _errorCount = 0; + subtitle.Paragraphs.Clear(); + foreach (string line in lines) + { + var s = line.Trim(); + if (s.Length > 35 && RegexTimeCodes.IsMatch(s)) + { + try + { + string timePart = s.Substring(4, 10).TrimEnd(); + var start = DecodeTimeCode(timePart); + timePart = s.Substring(15, 10).Trim(); + var end = DecodeTimeCode(timePart); + var paragraph = new Paragraph { StartTime = start, EndTime = end }; + paragraph.Text = s.Substring(38).Replace(" \\n ", Environment.NewLine).Replace("\\n", Environment.NewLine); + subtitle.Paragraphs.Add(paragraph); + } + catch + { + _errorCount++; + } + } + } + subtitle.Renumber(); + } + + private static string EncodeTimeCode(TimeCode time) + { + //0:50:05.42 + return string.Format("{0:0}:{1:00}:{2:00}.{3:00}", time.Hours, time.Minutes, time.Seconds, time.Milliseconds / 10); + } + + private static TimeCode DecodeTimeCode(string timePart) + { + string[] parts = timePart.Split(new[] { ':', '.' }, StringSplitOptions.RemoveEmptyEntries); + int hours = int.Parse(parts[0]); + int minutes = int.Parse(parts[1]); + int seconds = int.Parse(parts[2]); + int milliseconds = int.Parse(parts[3]) * 10; + return new TimeCode(hours, minutes, seconds, milliseconds); + } + + } +} diff --git a/libse/Translate/Formatting.cs b/src/libse/Translate/Formatting.cs similarity index 100% rename from libse/Translate/Formatting.cs rename to src/libse/Translate/Formatting.cs diff --git a/libse/Translate/GoogleTranslator1.cs b/src/libse/Translate/GoogleTranslator1.cs similarity index 100% rename from libse/Translate/GoogleTranslator1.cs rename to src/libse/Translate/GoogleTranslator1.cs diff --git a/libse/Translate/GoogleTranslator2.cs b/src/libse/Translate/GoogleTranslator2.cs similarity index 100% rename from libse/Translate/GoogleTranslator2.cs rename to src/libse/Translate/GoogleTranslator2.cs diff --git a/libse/Translate/GoogleTranslator3.cs b/src/libse/Translate/GoogleTranslator3.cs similarity index 100% rename from libse/Translate/GoogleTranslator3.cs rename to src/libse/Translate/GoogleTranslator3.cs diff --git a/libse/Translate/ITranslator.cs b/src/libse/Translate/ITranslator.cs similarity index 100% rename from libse/Translate/ITranslator.cs rename to src/libse/Translate/ITranslator.cs diff --git a/libse/Translate/MicrosoftTranslator.cs b/src/libse/Translate/MicrosoftTranslator.cs similarity index 100% rename from libse/Translate/MicrosoftTranslator.cs rename to src/libse/Translate/MicrosoftTranslator.cs diff --git a/libse/Translate/TranslationHelper.cs b/src/libse/Translate/TranslationHelper.cs similarity index 100% rename from libse/Translate/TranslationHelper.cs rename to src/libse/Translate/TranslationHelper.cs diff --git a/libse/Translate/TranslationPair.cs b/src/libse/Translate/TranslationPair.cs similarity index 100% rename from libse/Translate/TranslationPair.cs rename to src/libse/Translate/TranslationPair.cs diff --git a/libse/VobSub/Helper.cs b/src/libse/VobSub/Helper.cs similarity index 100% rename from libse/VobSub/Helper.cs rename to src/libse/VobSub/Helper.cs diff --git a/libse/VobSub/Idx.cs b/src/libse/VobSub/Idx.cs similarity index 100% rename from libse/VobSub/Idx.cs rename to src/libse/VobSub/Idx.cs diff --git a/libse/VobSub/IdxParagraph.cs b/src/libse/VobSub/IdxParagraph.cs similarity index 100% rename from libse/VobSub/IdxParagraph.cs rename to src/libse/VobSub/IdxParagraph.cs diff --git a/libse/VobSub/Mpeg2Header.cs b/src/libse/VobSub/Mpeg2Header.cs similarity index 100% rename from libse/VobSub/Mpeg2Header.cs rename to src/libse/VobSub/Mpeg2Header.cs diff --git a/libse/VobSub/PacketizedElementaryStream.cs b/src/libse/VobSub/PacketizedElementaryStream.cs similarity index 100% rename from libse/VobSub/PacketizedElementaryStream.cs rename to src/libse/VobSub/PacketizedElementaryStream.cs diff --git a/libse/VobSub/SpHeader.cs b/src/libse/VobSub/SpHeader.cs similarity index 100% rename from libse/VobSub/SpHeader.cs rename to src/libse/VobSub/SpHeader.cs diff --git a/libse/VobSub/SubPicture.cs b/src/libse/VobSub/SubPicture.cs similarity index 100% rename from libse/VobSub/SubPicture.cs rename to src/libse/VobSub/SubPicture.cs diff --git a/libse/VobSub/VobSubMergedPack.cs b/src/libse/VobSub/VobSubMergedPack.cs similarity index 100% rename from libse/VobSub/VobSubMergedPack.cs rename to src/libse/VobSub/VobSubMergedPack.cs diff --git a/libse/VobSub/VobSubPack.cs b/src/libse/VobSub/VobSubPack.cs similarity index 100% rename from libse/VobSub/VobSubPack.cs rename to src/libse/VobSub/VobSubPack.cs diff --git a/libse/VobSub/VobSubParser.cs b/src/libse/VobSub/VobSubParser.cs similarity index 100% rename from libse/VobSub/VobSubParser.cs rename to src/libse/VobSub/VobSubParser.cs diff --git a/libse/VobSub/VobSubWriter.cs b/src/libse/VobSub/VobSubWriter.cs similarity index 100% rename from libse/VobSub/VobSubWriter.cs rename to src/libse/VobSub/VobSubWriter.cs diff --git a/src/Controls/AudioVisualizer.Designer.cs b/src/ui/Controls/AudioVisualizer.Designer.cs similarity index 97% rename from src/Controls/AudioVisualizer.Designer.cs rename to src/ui/Controls/AudioVisualizer.Designer.cs index a2d7c6c03..3faed18bc 100644 --- a/src/Controls/AudioVisualizer.Designer.cs +++ b/src/ui/Controls/AudioVisualizer.Designer.cs @@ -1,56 +1,56 @@ -namespace Nikse.SubtitleEdit.Controls -{ - sealed partial class AudioVisualizer - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.SuspendLayout(); - // - // Waveform - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.Black; - this.Name = "Waveform"; - this.Size = new System.Drawing.Size(682, 355); - this.Paint += new System.Windows.Forms.PaintEventHandler(this.WaveformPaint); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.WaveformKeyDown); - this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.WaveformMouseClick); - this.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.WaveformMouseDoubleClick); - this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.WaveformMouseDown); - this.MouseEnter += new System.EventHandler(this.WaveformMouseEnter); - this.MouseLeave += new System.EventHandler(this.WaveformMouseLeave); - this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.WaveformMouseMove); - this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.WaveformMouseUp); - this.ResumeLayout(false); - - } - - #endregion - - } -} +namespace Nikse.SubtitleEdit.Controls +{ + sealed partial class AudioVisualizer + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // Waveform + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Black; + this.Name = "Waveform"; + this.Size = new System.Drawing.Size(682, 355); + this.Paint += new System.Windows.Forms.PaintEventHandler(this.WaveformPaint); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.WaveformKeyDown); + this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.WaveformMouseClick); + this.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.WaveformMouseDoubleClick); + this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.WaveformMouseDown); + this.MouseEnter += new System.EventHandler(this.WaveformMouseEnter); + this.MouseLeave += new System.EventHandler(this.WaveformMouseLeave); + this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.WaveformMouseMove); + this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.WaveformMouseUp); + this.ResumeLayout(false); + + } + + #endregion + + } +} diff --git a/src/Controls/AudioVisualizer.cs b/src/ui/Controls/AudioVisualizer.cs similarity index 97% rename from src/Controls/AudioVisualizer.cs rename to src/ui/Controls/AudioVisualizer.cs index 1e31aa167..5a57cd1af 100644 --- a/src/Controls/AudioVisualizer.cs +++ b/src/ui/Controls/AudioVisualizer.cs @@ -1,2581 +1,2581 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Globalization; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Controls -{ - public sealed partial class AudioVisualizer : UserControl - { - public enum MouseDownParagraphType - { - None, - Start, - Whole, - End - } - - public class MinMax - { - public double Min { get; set; } - public double Max { get; set; } - public double Avg { get; set; } - } - - public class ParagraphEventArgs : EventArgs - { - public Paragraph Paragraph { get; } - public double Seconds { get; } - public Paragraph BeforeParagraph { get; set; } - public MouseDownParagraphType MouseDownParagraphType { get; set; } - public bool MovePreviousOrNext { get; set; } - public double AdjustMs { get; set; } - public ParagraphEventArgs(Paragraph p) - { - Paragraph = p; - } - public ParagraphEventArgs(double seconds, Paragraph p) - { - Seconds = seconds; - Paragraph = p; - } - public ParagraphEventArgs(double seconds, Paragraph p, Paragraph b) - { - Seconds = seconds; - Paragraph = p; - BeforeParagraph = b; - } - public ParagraphEventArgs(double seconds, Paragraph p, Paragraph b, MouseDownParagraphType mouseDownParagraphType) - { - Seconds = seconds; - Paragraph = p; - BeforeParagraph = b; - MouseDownParagraphType = mouseDownParagraphType; - } - public ParagraphEventArgs(double seconds, Paragraph p, Paragraph b, MouseDownParagraphType mouseDownParagraphType, bool movePreviousOrNext) - { - Seconds = seconds; - Paragraph = p; - BeforeParagraph = b; - MouseDownParagraphType = mouseDownParagraphType; - MovePreviousOrNext = movePreviousOrNext; - } - } - - public int ClosenessForBorderSelection { get; set; } = 15; - private const int MinimumSelectionMilliseconds = 100; - - private long _buttonDownTimeTicks; - private long _lastMouseWheelScroll = -1; - private int _mouseMoveLastX = -1; - private int _mouseMoveStartX = -1; - private double _moveWholeStartDifferenceMilliseconds = -1; - private int _mouseMoveEndX = -1; - private bool _mouseDown; - private Paragraph _oldParagraph; - private Paragraph _mouseDownParagraph; - private MouseDownParagraphType _mouseDownParagraphType = MouseDownParagraphType.Start; - private readonly List _displayableParagraphs; - private readonly List _allSelectedParagraphs; - private Paragraph _prevParagraph; - private Paragraph _nextParagraph; - private bool _firstMove = true; - private double _currentVideoPositionSeconds = -1; - private WavePeakData _wavePeaks; - private Subtitle _subtitle; - private bool _noClear; - private double _gapAtStart = -1; - - private SpectrogramData _spectrogram; - private const int SpectrogramDisplayHeight = 128; - - public delegate void ParagraphEventHandler(object sender, ParagraphEventArgs e); - public event ParagraphEventHandler OnNewSelectionRightClicked; - public event ParagraphEventHandler OnParagraphRightClicked; - public event ParagraphEventHandler OnNonParagraphRightClicked; - public event ParagraphEventHandler OnPositionSelected; - - public event ParagraphEventHandler OnTimeChanged; - public event ParagraphEventHandler OnTimeChangedAndOffsetRest; - - public event ParagraphEventHandler OnSingleClick; - public event ParagraphEventHandler OnDoubleClickNonParagraph; - public event EventHandler OnPause; - public event EventHandler OnZoomedChanged; - public event EventHandler InsertAtVideoPosition; - public event EventHandler PasteAtVideoPosition; - - private double _wholeParagraphMinMilliseconds; - private double _wholeParagraphMaxMilliseconds = double.MaxValue; - public Keys InsertAtVideoPositionShortcut { get; set; } - public Keys Move100MsLeft { get; set; } - public Keys Move100MsRight { get; set; } - public Keys MoveOneSecondLeft { get; set; } - public Keys MoveOneSecondRight { get; set; } - public bool MouseWheelScrollUpIsForward { get; set; } = true; - - public const double ZoomMinimum = 0.1; - public const double ZoomMaximum = 2.5; - private double _zoomFactor = 1.0; // 1.0=no zoom - - public const int SceneChangeSnapPixels = 8; - - public double ZoomFactor - { - get => _zoomFactor; - set - { - if (value < ZoomMinimum) - { - value = ZoomMinimum; - } - - if (value > ZoomMaximum) - { - value = ZoomMaximum; - } - - value = Math.Round(value, 2); // round to prevent accumulated rounding errors - if (Math.Abs(_zoomFactor - value) > 0.01) - { - _zoomFactor = value; - Invalidate(); - } - } - } - - public const double VerticalZoomMinimum = 1.0; - public const double VerticalZoomMaximum = 20.0; - private double _verticalZoomFactor = 1.0; // 1.0=no zoom - - public double VerticalZoomFactor - { - get => _verticalZoomFactor; - set - { - if (value < VerticalZoomMinimum) - { - value = VerticalZoomMinimum; - } - - if (value > VerticalZoomMaximum) - { - value = VerticalZoomMaximum; - } - - value = Math.Round(value, 2); // round to prevent accumulated rounding errors - if (Math.Abs(_verticalZoomFactor - value) > 0.01) - { - _verticalZoomFactor = value; - Invalidate(); - } - } - } - - private List _sceneChanges = new List(); - - /// - /// Scene changes (seconds) - /// - public List SceneChanges - { - get => _sceneChanges; - set - { - _sceneChanges = value; - Invalidate(); - } - } - - private List _chapters = new List(); - - public List Chapters - { - get => _chapters; - set - { - _chapters = value; - Invalidate(); - } - } - - public bool IsSpectrogramAvailable => _spectrogram != null && _spectrogram.Images.Count > 0; - - private bool _showSpectrogram; - - public bool ShowSpectrogram - { - get => _showSpectrogram; - set - { - if (_showSpectrogram != value) - { - _showSpectrogram = value; - Invalidate(); - } - } - } - - public bool AllowOverlap { get; set; } - - private bool _showWaveform; - - public bool ShowWaveform - { - get => _showWaveform; - set - { - if (_showWaveform != value) - { - _showWaveform = value; - Invalidate(); - } - } - } - - private double _startPositionSeconds; - - public double StartPositionSeconds - { - get => _startPositionSeconds; - set - { - if (_wavePeaks != null) - { - double endPositionSeconds = value + ((double)Width / _wavePeaks.SampleRate) / _zoomFactor; - if (endPositionSeconds > _wavePeaks.LengthInSeconds) - { - value -= endPositionSeconds - _wavePeaks.LengthInSeconds; - } - } - if (value < 0) - { - value = 0; - } - - if (Math.Abs(_startPositionSeconds - value) > 0.01) - { - _startPositionSeconds = value; - Invalidate(); - } - } - } - - public Paragraph NewSelectionParagraph { get; set; } - public Paragraph SelectedParagraph { get; private set; } - public Paragraph RightClickedParagraph { get; private set; } - public double RightClickedSeconds { get; private set; } - - public string WaveformNotLoadedText { get; set; } - public Color BackgroundColor { get; set; } - public Color Color { get; set; } - public Color SelectedColor { get; set; } - public Color ParagraphColor { get; set; } - public Color TextColor { get; set; } - public Color CursorColor { get; set; } - public Color ChaptersColor { get; set; } - public float TextSize { get; set; } - public bool TextBold { get; set; } - public Color GridColor { get; set; } - public bool ShowGridLines { get; set; } - public bool AllowNewSelection { get; set; } - - public bool Locked { get; set; } - - public double EndPositionSeconds - { - get - { - if (_wavePeaks == null) - { - return 0; - } - - return RelativeXPositionToSeconds(Width); - } - } - - public WavePeakData WavePeaks - { - get => _wavePeaks; - set - { - _zoomFactor = 1.0; - SelectedParagraph = null; - _buttonDownTimeTicks = 0; - _mouseMoveLastX = -1; - _mouseMoveStartX = -1; - _moveWholeStartDifferenceMilliseconds = -1; - _mouseMoveEndX = -1; - _mouseDown = false; - _mouseDownParagraph = null; - _mouseDownParagraphType = MouseDownParagraphType.Start; - _currentVideoPositionSeconds = -1; - _subtitle = new Subtitle(); - _noClear = false; - _wavePeaks = value; - } - } - - public void SetSpectrogram(SpectrogramData spectrogramData) - { - InitializeSpectrogram(spectrogramData); - } - - public void ClearSelection() - { - _mouseDown = false; - _mouseDownParagraph = null; - _mouseMoveStartX = -1; - _mouseMoveEndX = -1; - Invalidate(); - } - - public AudioVisualizer() - { - AutoScaleMode = AutoScaleMode.Dpi; - Font = UiUtil.GetDefaultFont(); - InitializeComponent(); - UiUtil.FixFonts(this); - - _displayableParagraphs = new List(); - _allSelectedParagraphs = new List(); - - SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); - WaveformNotLoadedText = "Click to add waveform/spectrogram"; - MouseWheel += WaveformMouseWheel; - - BackgroundColor = Color.Black; - Color = Color.GreenYellow; - SelectedColor = Color.Red; - ParagraphColor = Color.LimeGreen; - TextColor = Color.Gray; - TextSize = 9; - TextBold = true; - GridColor = Color.FromArgb(255, 20, 20, 18); - ShowGridLines = true; - AllowNewSelection = true; - ShowSpectrogram = true; - ShowWaveform = true; - InsertAtVideoPositionShortcut = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainWaveformInsertAtCurrentPosition); - } - - protected override bool IsInputKey(Keys keyData) - { - Keys key = keyData & Keys.KeyCode; - - switch (key) - { - case Keys.Up: - case Keys.Down: - case Keys.Right: - case Keys.Left: - return true; - - default: - return base.IsInputKey(keyData); - } - } - - private void LoadParagraphs(Subtitle subtitle, int primarySelectedIndex, ListView.SelectedIndexCollection selectedIndexes) - { - _subtitle.Paragraphs.Clear(); - _displayableParagraphs.Clear(); - SelectedParagraph = null; - _allSelectedParagraphs.Clear(); - - if (_wavePeaks == null) - { - return; - } - - const double additionalSeconds = 15.0; // Helps when scrolling - double startThresholdMilliseconds = (_startPositionSeconds - additionalSeconds) * TimeCode.BaseUnit; - double endThresholdMilliseconds = (EndPositionSeconds + additionalSeconds) * TimeCode.BaseUnit; - - for (int i = 0; i < subtitle.Paragraphs.Count; i++) - { - var p = subtitle.Paragraphs[i]; - - if (p.StartTime.IsMaxTime) - { - continue; - } - - _subtitle.Paragraphs.Add(p); - - if (p.EndTime.TotalMilliseconds >= startThresholdMilliseconds && p.StartTime.TotalMilliseconds <= endThresholdMilliseconds) - { - _displayableParagraphs.Add(p); - } - } - - var primaryParagraph = subtitle.GetParagraphOrDefault(primarySelectedIndex); - if (primaryParagraph != null && !primaryParagraph.StartTime.IsMaxTime) - { - SelectedParagraph = primaryParagraph; - _allSelectedParagraphs.Add(primaryParagraph); - } - foreach (int index in selectedIndexes) - { - var p = subtitle.GetParagraphOrDefault(index); - if (p != null && !p.StartTime.IsMaxTime) - { - _allSelectedParagraphs.Add(p); - } - } - } - - public void SetPosition(double startPositionSeconds, Subtitle subtitle, double currentVideoPositionSeconds, int subtitleIndex, ListView.SelectedIndexCollection selectedIndexes) - { - if (TimeSpan.FromTicks(DateTime.UtcNow.Ticks - _lastMouseWheelScroll).TotalSeconds > 0.25) - { // don't set start position when scrolling with mouse wheel as it will make a bad (jumping back) forward scrolling - StartPositionSeconds = startPositionSeconds; - } - _currentVideoPositionSeconds = currentVideoPositionSeconds; - LoadParagraphs(subtitle, subtitleIndex, selectedIndexes); - Invalidate(); - } - - private class IsSelectedHelper - { - private readonly SelectionRange[] _ranges; - private int _lastPosition = int.MaxValue; - private SelectionRange _nextSelection; - - public IsSelectedHelper(List paragraphs, int sampleRate) - { - var count = paragraphs.Count; - _ranges = new SelectionRange[count]; - for (int index = 0; index < count; index++) - { - var p = paragraphs[index]; - int start = (int)Math.Round(p.StartTime.TotalSeconds * sampleRate); - int end = (int)Math.Round(p.EndTime.TotalSeconds * sampleRate); - _ranges[index] = new SelectionRange(start, end); - } - } - - public bool IsSelected(int position) - { - if (position < _lastPosition || position > _nextSelection.End) - { - FindNextSelection(position); - } - - _lastPosition = position; - - return position >= _nextSelection.Start && position <= _nextSelection.End; - } - - private void FindNextSelection(int position) - { - _nextSelection = new SelectionRange(int.MaxValue, int.MaxValue); - for (int index = 0; index < _ranges.Length; index++) - { - var range = _ranges[index]; - if (range.End >= position && (range.Start < _nextSelection.Start || range.Start == _nextSelection.Start && range.End > _nextSelection.End)) - { - _nextSelection = range; - } - } - } - - private struct SelectionRange - { - public readonly int Start; - public readonly int End; - - public SelectionRange(int start, int end) - { - Start = start; - End = end; - } - } - } - - //private Stopwatch _sw; - //private readonly List _ticks = new List(); - internal void WaveformPaint(object sender, PaintEventArgs e) - { - //_sw = Stopwatch.StartNew(); - Graphics graphics = e.Graphics; - if (_wavePeaks != null) - { - bool showSpectrogram = _showSpectrogram && IsSpectrogramAvailable; - bool showSpectrogramOnly = showSpectrogram && !_showWaveform; - int waveformHeight = Height - (showSpectrogram ? SpectrogramDisplayHeight : 0); - - // background - graphics.Clear(BackgroundColor); - - // grid lines - if (ShowGridLines && !showSpectrogramOnly) - { - DrawGridLines(graphics, waveformHeight); - } - - // spectrogram - if (showSpectrogram) - { - DrawSpectrogram(graphics); - } - - // waveform - if (_showWaveform) - { - using (var penNormal = new Pen(Color)) - using (var penSelected = new Pen(SelectedColor)) // selected paragraph - { - var isSelectedHelper = new IsSelectedHelper(_allSelectedParagraphs, _wavePeaks.SampleRate); - int baseHeight = (int)(_wavePeaks.HighestPeak / _verticalZoomFactor); - int halfWaveformHeight = waveformHeight / 2; - Func calculateY = value => - { - var offset = (value / baseHeight) * halfWaveformHeight; - if (offset > halfWaveformHeight) - { - offset = halfWaveformHeight; - } - - if (offset < -halfWaveformHeight) - { - offset = -halfWaveformHeight; - } - - return (float)(halfWaveformHeight - offset); - }; - var div = _wavePeaks.SampleRate * _zoomFactor; - for (int x = 0; x < Width; x++) - { - var pos = (_startPositionSeconds + x / div) * _wavePeaks.SampleRate; - int pos0 = (int)pos; - int pos1 = pos0; - pos1++; - if (pos1 >= _wavePeaks.Peaks.Count) - { - break; - } - - var pos1Weight = pos - pos0; - var pos0Weight = 1F - pos1Weight; - var peak0 = _wavePeaks.Peaks[pos0]; - var peak1 = _wavePeaks.Peaks[pos1]; - var max = peak0.Max * pos0Weight + peak1.Max * pos1Weight; - var min = peak0.Min * pos0Weight + peak1.Min * pos1Weight; - var yMax = calculateY(max); - var yMin = Math.Max(calculateY(min), yMax + 0.1F); - var pen = isSelectedHelper.IsSelected(pos0) ? penSelected : penNormal; - graphics.DrawLine(pen, x, yMax, x, yMin); - } - } - } - - // time line - if (!showSpectrogramOnly) - { - DrawTimeLine(graphics, waveformHeight); - } - - int currentPositionPos = SecondsToXPosition(_currentVideoPositionSeconds - _startPositionSeconds); - bool currentPosDone = false; - - // paragraphs - var startPositionMilliseconds = _startPositionSeconds * 1000.0; - var endPositionMilliseconds = RelativeXPositionToSeconds(Width) * 1000.0; - var paragraphStartList = new List(); - var paragraphEndList = new List(); - foreach (Paragraph p in _displayableParagraphs) - { - if (p.EndTime.TotalMilliseconds >= startPositionMilliseconds && p.StartTime.TotalMilliseconds <= endPositionMilliseconds) - { - paragraphStartList.Add(SecondsToXPosition(p.StartTime.TotalSeconds - _startPositionSeconds)); - paragraphEndList.Add(SecondsToXPosition(p.EndTime.TotalSeconds - _startPositionSeconds)); - DrawParagraph(p, graphics); - } - } - - // scene changes - if (_sceneChanges != null) - { - try - { - int index = 0; - while (index < _sceneChanges.Count) - { - int pos; - try - { - double time = _sceneChanges[index++]; - pos = SecondsToXPosition(time - _startPositionSeconds); - } - catch - { - pos = -1; - } - if (pos > 0 && pos < Width) - { - if (currentPositionPos == pos) - { // scene change and current pos are the same - draw 2 pixels + current pos dotted - currentPosDone = true; - using (var p = new Pen(Color.AntiqueWhite, 2)) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - - using (var p = new Pen(CursorColor, 2) { DashStyle = DashStyle.Dash }) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - } - else if (paragraphStartList.Contains(pos)) - { // scene change and start pos are the same - draw 2 pixels + current pos dotted - using (var p = new Pen(Color.AntiqueWhite, 2)) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - - using (var p = new Pen(Color.FromArgb(175, 0, 100, 0), 2) { DashStyle = DashStyle.Dash }) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - } - else if (paragraphEndList.Contains(pos)) - { // scene change and end pos are the same - draw 2 pixels + current pos dotted - using (var p = new Pen(Color.AntiqueWhite, 2)) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - - using (var p = new Pen(Color.FromArgb(175, 110, 10, 10), 2) { DashStyle = DashStyle.Dash }) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - } - else - { - using (var p = new Pen(Color.AntiqueWhite)) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - } - } - } - } - catch (Exception) - { - // ignored - } - } - - // chapters - if (_chapters != null) - { - try - { - int index = 0; - while (index < _chapters.Count) - { - int pos; - try - { - double time = _chapters[index].StartTime; - pos = SecondsToXPosition(time - _startPositionSeconds); - } - catch - { - pos = -1; - } - if (pos >= 0 && pos < Width) - { - // draw chapter text - using (var font = new Font(Configuration.Settings.General.SubtitleFontName, TextSize, TextBold ? FontStyle.Bold : FontStyle.Regular)) - using (var brush = new SolidBrush(Color.White)) - { - var name = string.Empty; - var x = pos + 3; - var y = index + 1 < _chapters.Count && _chapters[index].StartTime == _chapters[index + 1].StartTime ? Height / 2 - font.Height - 12 : Height / 2 - 12; - using (var chpaterTextBackBrush = new SolidBrush(ChaptersColor)) - { - name = _chapters[index].Nested ? "+ " + _chapters[index].Name : _chapters[index].Name; - var textSize = graphics.MeasureString(name, font); - graphics.FillRectangle(chpaterTextBackBrush, x, y, textSize.Width + 2, textSize.Height); - } - - x += 2; - graphics.DrawString(name, font, brush, new PointF(x, y)); - } - - // draw chapter line - if (currentPositionPos == pos) - { // chapter and current pos are the same - draw 2 pixels + current pos dotted - currentPosDone = true; - using (var p = new Pen(ChaptersColor, 2)) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - - using (var p = new Pen(CursorColor, 2) { DashStyle = DashStyle.Dash }) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - } - else if (paragraphStartList.Contains(pos)) - { // chapter and start pos are the same - draw 2 pixels + current pos dotted - using (var p = new Pen(ChaptersColor, 2)) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - - using (var p = new Pen(Color.FromArgb(175, 0, 100, 0), 2) { DashStyle = DashStyle.Dash }) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - } - else if (paragraphEndList.Contains(pos)) - { // chapter and end pos are the same - draw 2 pixels + current pos dotted - using (var p = new Pen(ChaptersColor, 2)) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - - using (var p = new Pen(Color.FromArgb(175, 110, 10, 10), 2) { DashStyle = DashStyle.Dash }) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - } - else - { - using (var p = new Pen(ChaptersColor)) - { - graphics.DrawLine(p, pos, 0, pos, Height); - } - } - } - - index++; - } - } - catch (Exception) - { - // ignore - } - } - - // current video position - if (_currentVideoPositionSeconds > 0 && !currentPosDone && currentPositionPos > 0 && currentPositionPos < Width) - { - using (var p = new Pen(CursorColor)) - { - graphics.DrawLine(p, currentPositionPos, 0, currentPositionPos, Height); - } - } - - // current selection - if (NewSelectionParagraph != null) - { - int currentRegionLeft = SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - _startPositionSeconds); - int currentRegionRight = SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - _startPositionSeconds); - int currentRegionWidth = currentRegionRight - currentRegionLeft; - if (currentRegionRight >= 0 && currentRegionLeft <= Width) - { - using (var brush = new SolidBrush(Color.FromArgb(128, 255, 255, 255))) - { - graphics.FillRectangle(brush, currentRegionLeft, 0, currentRegionWidth, graphics.VisibleClipBounds.Height); - } - - if (currentRegionWidth > 40) - { - using (var brush = new SolidBrush(CursorColor)) - { - graphics.DrawString($"{(double)currentRegionWidth / _wavePeaks.SampleRate / _zoomFactor:0.###} {Configuration.Settings.Language.Waveform.Seconds}", Font, brush, new PointF(currentRegionLeft + 3, Height - 32)); - } - } - } - } - } - else - { - graphics.Clear(BackgroundColor); - - if (ShowGridLines) - { - DrawGridLines(graphics, Height); - } - - using (var textBrush = new SolidBrush(TextColor)) - using (var textFont = new Font(Font.FontFamily, 8)) - { - if (Width > 90) - { - graphics.DrawString(WaveformNotLoadedText, textFont, textBrush, new PointF(Width / 2.0f - 65, Height / 2.0f - 10)); - } - else - { - using (var stringFormat = new StringFormat(StringFormatFlags.DirectionVertical)) - { - graphics.DrawString(WaveformNotLoadedText, textFont, textBrush, new PointF(1, 10), stringFormat); - } - } - } - } - if (Focused) - { - using (var p = new Pen(SelectedColor)) - { - graphics.DrawRectangle(p, new Rectangle(0, 0, Width - 1, Height - 1)); - } - } - //_sw.Stop(); - //_ticks.Add(_sw.ElapsedMilliseconds); - //e.Graphics.DrawString("X = " + _ticks.Average().ToString(), Font, new SolidBrush(Color.Cyan), 100, 130); - } - - private void DrawGridLines(Graphics graphics, int imageHeight) - { - if (_wavePeaks == null) - { - using (var pen = new Pen(new SolidBrush(GridColor))) - { - for (int i = 0; i < Width; i += 10) - { - graphics.DrawLine(pen, i, 0, i, imageHeight); - graphics.DrawLine(pen, 0, i, Width, i); - } - } - } - else - { - double seconds = Math.Ceiling(_startPositionSeconds) - _startPositionSeconds - 1; - int xPosition = SecondsToXPosition(seconds); - int yPosition = 0; - double yCounter = 0; - double interval = _zoomFactor >= 0.4 ? - 0.1 : // a pixel is 0.1 second - 1.0; // a pixel is 1.0 second - using (var pen = new Pen(GridColor)) - { - while (xPosition < Width) - { - graphics.DrawLine(pen, xPosition, 0, xPosition, imageHeight); - - seconds += interval; - xPosition = SecondsToXPosition(seconds); - } - - while (yPosition < Height) - { - graphics.DrawLine(pen, 0, yPosition, Width, yPosition); - - yCounter += interval; - yPosition = Convert.ToInt32(yCounter * _wavePeaks.SampleRate * _zoomFactor); - } - } - } - } - - private void DrawTimeLine(Graphics graphics, int imageHeight) - { - double seconds = Math.Ceiling(_startPositionSeconds) - _startPositionSeconds; - int position = SecondsToXPosition(seconds); - using (var pen = new Pen(TextColor)) - using (var textBrush = new SolidBrush(TextColor)) - using (var textFont = new Font(Font.FontFamily, 7)) - { - while (position < Width) - { - var n = _zoomFactor * _wavePeaks.SampleRate; - if (n > 38 || (int)Math.Round(_startPositionSeconds + seconds) % 5 == 0) - { - graphics.DrawLine(pen, position, imageHeight, position, imageHeight - 10); - graphics.DrawString(GetDisplayTime(_startPositionSeconds + seconds), textFont, textBrush, new PointF(position + 2, imageHeight - 13)); - } - - seconds += 0.5; - position = SecondsToXPosition(seconds); - - if (n > 64) - { - graphics.DrawLine(pen, position, imageHeight, position, imageHeight - 5); - } - - seconds += 0.5; - position = SecondsToXPosition(seconds); - } - } - } - - private static string GetDisplayTime(double seconds) - { - var ts = TimeSpan.FromSeconds(seconds + Configuration.Settings.General.CurrentVideoOffsetInMs / TimeCode.BaseUnit); - if (ts.Minutes == 0 && ts.Hours == 0) - { - return ts.Seconds.ToString(CultureInfo.InvariantCulture); - } - - if (ts.Hours == 0) - { - return $"{ts.Minutes:00}:{ts.Seconds:00}"; - } - - return $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}"; - } - - private void DrawParagraph(Paragraph paragraph, Graphics graphics) - { - int currentRegionLeft = SecondsToXPosition(paragraph.StartTime.TotalSeconds - _startPositionSeconds); - int currentRegionRight = SecondsToXPosition(paragraph.EndTime.TotalSeconds - _startPositionSeconds); - int currentRegionWidth = currentRegionRight - currentRegionLeft; - - // background - using (var brush = new SolidBrush(Color.FromArgb(42, 255, 255, 255))) - { - graphics.FillRectangle(brush, currentRegionLeft, 0, currentRegionWidth, graphics.VisibleClipBounds.Height); - } - - // left edge - using (var pen = new Pen(new SolidBrush(Color.FromArgb(175, 0, 100, 0))) { DashStyle = DashStyle.Solid, Width = 2 }) - { - graphics.DrawLine(pen, currentRegionLeft, 0, currentRegionLeft, graphics.VisibleClipBounds.Height); - } - - // right edge - using (var pen = new Pen(new SolidBrush(Color.FromArgb(175, 110, 10, 10))) { DashStyle = DashStyle.Dash, Width = 2 }) - { - graphics.DrawLine(pen, currentRegionRight - 1, 0, currentRegionRight - 1, graphics.VisibleClipBounds.Height); - } - - using (var font = new Font(Configuration.Settings.General.SubtitleFontName, TextSize, TextBold ? FontStyle.Bold : FontStyle.Regular)) - using (var textBrush = new SolidBrush(TextColor)) - using (var outlineBrush = new SolidBrush(Color.Black)) - { - Action drawStringOutlined = (text, x, y) => - { - // poor mans outline + text - graphics.DrawString(text, font, outlineBrush, new PointF(x, y - 1)); - graphics.DrawString(text, font, outlineBrush, new PointF(x, y + 1)); - graphics.DrawString(text, font, outlineBrush, new PointF(x - 1, y)); - graphics.DrawString(text, font, outlineBrush, new PointF(x + 1, y)); - graphics.DrawString(text, font, textBrush, new PointF(x, y)); - }; - - const int padding = 3; - double n = _zoomFactor * _wavePeaks.SampleRate; - - // bookmark text - if (paragraph.Bookmark != null) - { - var x = currentRegionLeft + padding; - var y = Height / 2 + (int)graphics.MeasureString("xx", font).Height / 2 + 2; - - using (var bookmarkBackBrush = new SolidBrush(Color.FromArgb(255, 250, 205))) - { - var textSize = graphics.MeasureString(paragraph.Bookmark, font); - if (textSize.Width < 1) - { - textSize = new SizeF(-2, 18); // empty bookmark text - } - - graphics.FillRectangle(bookmarkBackBrush, x, y, textSize.Width + 20, textSize.Height + 10); - } - - x += 2; - graphics.FillPolygon(textBrush, new[] - { - new Point(x, y + 2), - new Point(x + 14, y + 2), - new Point(x + 14, y + 22 + 2), - new Point(x + 7, y + 14 + 2), - new Point(x, y + 22 + 2), - new Point(x, y + 2), - }); - x += 16; - graphics.DrawString(paragraph.Bookmark, font, textBrush, new PointF(x, y)); - } - - // paragraph text - if (n > 80) - { - string text = HtmlUtil.RemoveHtmlTags(paragraph.Text, true); - if (Configuration.Settings.VideoControls.WaveformUnwrapText) - { - text = text.Replace(Environment.NewLine, " "); - } - - DrawParagraphText(graphics, text, font, currentRegionWidth, padding, drawStringOutlined, currentRegionLeft); - } - - // paragraph number - if (n > 25) - { - string text = "#" + paragraph.Number + " " + paragraph.Duration.ToShortDisplayString(); - if (n <= 51 || graphics.MeasureString(text, font).Width >= currentRegionWidth - padding - 1) - { - text = "#" + paragraph.Number; - } - else if (n > 99) - { - if (Configuration.Settings.VideoControls.WaveformHideWpmCpsLabels) - { - if (Configuration.Settings.VideoControls.WaveformDrawWpm) - { - text = $"{paragraph.WordsPerMinute:0.00}" + Environment.NewLine + text; - } - - if (Configuration.Settings.VideoControls.WaveformDrawCps) - { - text = $"{Utilities.GetCharactersPerSecond(paragraph):0.00}" + Environment.NewLine + text; - } - } - else - { - if (Configuration.Settings.VideoControls.WaveformDrawWpm) - { - text = string.Format(Configuration.Settings.Language.Waveform.WordsMinX, paragraph.WordsPerMinute) + Environment.NewLine + text; - } - - if (Configuration.Settings.VideoControls.WaveformDrawCps) - { - text = string.Format(Configuration.Settings.Language.Waveform.CharsSecX, Utilities.GetCharactersPerSecond(paragraph)) + Environment.NewLine + text; - } - } - } - drawStringOutlined(text, currentRegionLeft + padding, Height - 14 - (int)graphics.MeasureString(text, font).Height); - } - } - } - - private void DrawParagraphText(Graphics graphics, string text, Font font, int currentRegionWidth, int padding, Action drawStringOutlined, int currentRegionLeft) - { - if (Configuration.Settings.General.RightToLeftMode && LanguageAutoDetect.CouldBeRightToLeftLanguage(new Subtitle(_displayableParagraphs))) - { - text = Utilities.ReverseStartAndEndingForRightToLeft(text); - } - - if (text.Length > 500) - { - text = text.Substring(0, 500); // don't now allow very long texts as they can make SE unresponsive - see https://github.com/SubtitleEdit/subtitleedit/issues/2536 - } - - int y = padding; - var max = currentRegionWidth - padding - 1; - foreach (var line in text.SplitToLines()) - { - text = line; - int removeLength = 1; - var measureResult = graphics.MeasureString(text, font); - while (text.Length > removeLength && graphics.MeasureString(text, font).Width > max) - { - text = text.Remove(text.Length - removeLength).TrimEnd() + "…"; - if (text.Length > 200) - { - removeLength = 21; - } - else if (text.Length > 100) - { - removeLength = 11; - } - else - { - removeLength = 2; - } - - measureResult = graphics.MeasureString(text, font); - } - drawStringOutlined(text, currentRegionLeft + padding, y); - y += (int)Math.Round(measureResult.Height, MidpointRounding.AwayFromZero); - } - - } - - private double RelativeXPositionToSeconds(int x) - { - return _startPositionSeconds + (double)x / _wavePeaks.SampleRate / _zoomFactor; - } - - private int SecondsToXPosition(double seconds) - { - return (int)Math.Round(seconds * _wavePeaks.SampleRate * _zoomFactor); - } - - private int SecondsToSampleIndex(double seconds) - { - return (int)Math.Round(seconds * _wavePeaks.SampleRate); - } - - private double SampleIndexToSeconds(int index) - { - return (double)index / _wavePeaks.SampleRate; - } - - private void WaveformMouseDown(object sender, MouseEventArgs e) - { - if (_wavePeaks == null) - { - return; - } - - Paragraph oldMouseDownParagraph = null; - _mouseDownParagraphType = MouseDownParagraphType.None; - _gapAtStart = -1; - _firstMove = true; - if (e.Button == MouseButtons.Left) - { - _buttonDownTimeTicks = DateTime.UtcNow.Ticks; - - Cursor = Cursors.VSplit; - double seconds = RelativeXPositionToSeconds(e.X); - var milliseconds = (int)(seconds * TimeCode.BaseUnit); - - if (SetParagraphBorderHit(milliseconds, NewSelectionParagraph)) - { - if (_mouseDownParagraph != null) - { - oldMouseDownParagraph = new Paragraph(_mouseDownParagraph); - } - - if (_mouseDownParagraphType == MouseDownParagraphType.Start) - { - if (_mouseDownParagraph != null) - { - _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds; - OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); - } - - NewSelectionParagraph.StartTime.TotalMilliseconds = milliseconds; - _mouseMoveStartX = e.X; - _mouseMoveEndX = SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - _startPositionSeconds); - } - else - { - if (_mouseDownParagraph != null) - { - _mouseDownParagraph.EndTime.TotalMilliseconds = milliseconds; - OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); - } - - NewSelectionParagraph.EndTime.TotalMilliseconds = milliseconds; - _mouseMoveStartX = SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - _startPositionSeconds); - _mouseMoveEndX = e.X; - } - SetMinMaxViaSeconds(seconds); - } - else if (SetParagraphBorderHit(milliseconds, SelectedParagraph) || SetParagraphBorderHit(milliseconds, _displayableParagraphs)) - { - NewSelectionParagraph = null; - if (_mouseDownParagraph != null) - { - oldMouseDownParagraph = new Paragraph(_mouseDownParagraph); - int curIdx = _subtitle.Paragraphs.IndexOf(_mouseDownParagraph); - if (_mouseDownParagraphType == MouseDownParagraphType.Start) - { - if (curIdx > 0) - { - var prev = _subtitle.Paragraphs[curIdx - 1]; - if (prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines < milliseconds) - { - _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds; - OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); - } - } - else - { - _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds; - OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); - } - } - else - { - if (curIdx < _subtitle.Paragraphs.Count - 1) - { - var next = _subtitle.Paragraphs[curIdx + 1]; - if (milliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines < next.StartTime.TotalMilliseconds) - { - _mouseDownParagraph.EndTime.TotalMilliseconds = milliseconds; - OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); - } - } - else - { - _mouseDownParagraph.EndTime.TotalMilliseconds = milliseconds; - OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); - } - } - } - SetMinAndMax(); - } - else - { - Paragraph p = GetParagraphAtMilliseconds(milliseconds); - if (p != null) - { - _oldParagraph = new Paragraph(p); - _mouseDownParagraph = p; - oldMouseDownParagraph = new Paragraph(_mouseDownParagraph); - _mouseDownParagraphType = MouseDownParagraphType.Whole; - _moveWholeStartDifferenceMilliseconds = (RelativeXPositionToSeconds(e.X) * TimeCode.BaseUnit) - p.StartTime.TotalMilliseconds; - Cursor = Cursors.Hand; - SetMinAndMax(); - } - else if (!AllowNewSelection) - { - Cursor = Cursors.Default; - } - if (p == null) - { - SetMinMaxViaSeconds(seconds); - } - - NewSelectionParagraph = null; - _mouseMoveStartX = e.X; - _mouseMoveEndX = e.X; - } - if (_mouseDownParagraphType == MouseDownParagraphType.Start) - { - if (_subtitle != null && _mouseDownParagraph != null) - { - int curIdx = _subtitle.Paragraphs.IndexOf(_mouseDownParagraph); - if (curIdx > 0 && oldMouseDownParagraph != null) - { - _gapAtStart = oldMouseDownParagraph.StartTime.TotalMilliseconds - _subtitle.Paragraphs[curIdx - 1].EndTime.TotalMilliseconds; - } - } - } - else if (_mouseDownParagraphType == MouseDownParagraphType.End) - { - if (_subtitle != null && _mouseDownParagraph != null) - { - int curIdx = _subtitle.Paragraphs.IndexOf(_mouseDownParagraph); - if (curIdx >= 0 && curIdx < _subtitle.Paragraphs.Count - 1 && oldMouseDownParagraph != null) - { - _gapAtStart = _subtitle.Paragraphs[curIdx + 1].StartTime.TotalMilliseconds - oldMouseDownParagraph.EndTime.TotalMilliseconds; - } - } - } - _mouseDown = true; - } - else - { - if (e.Button == MouseButtons.Right) - { - double seconds = RelativeXPositionToSeconds(e.X); - var milliseconds = (int)(seconds * TimeCode.BaseUnit); - - if (OnNewSelectionRightClicked != null && NewSelectionParagraph != null) - { - OnNewSelectionRightClicked.Invoke(this, new ParagraphEventArgs(NewSelectionParagraph)); - RightClickedParagraph = null; - _noClear = true; - } - else - { - Paragraph p = GetParagraphAtMilliseconds(milliseconds); - RightClickedParagraph = p; - RightClickedSeconds = seconds; - if (p != null) - { - if (OnParagraphRightClicked != null) - { - NewSelectionParagraph = null; - OnParagraphRightClicked.Invoke(this, new ParagraphEventArgs(seconds, p)); - } - } - else - { - OnNonParagraphRightClicked?.Invoke(this, new ParagraphEventArgs(seconds, null)); - } - } - } - Cursor = Cursors.Default; - } - } - - private void SetMinMaxViaSeconds(double seconds) - { - _wholeParagraphMinMilliseconds = 0; - _wholeParagraphMaxMilliseconds = double.MaxValue; - if (_subtitle != null) - { - Paragraph prev = null; - Paragraph next = null; - var paragraphs = _subtitle.Paragraphs.OrderBy(p => p.StartTime.TotalMilliseconds).ToList(); - for (int i = 0; i < paragraphs.Count; i++) - { - var p2 = paragraphs[i]; - if (p2.StartTime.TotalSeconds < seconds) - { - prev = p2; - } - else if (p2.EndTime.TotalSeconds > seconds) - { - next = p2; - break; - } - } - if (prev != null) - { - _wholeParagraphMinMilliseconds = prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - - if (next != null) - { - _wholeParagraphMaxMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - - private void SetMinAndMax() - { - _wholeParagraphMinMilliseconds = 0; - _wholeParagraphMaxMilliseconds = double.MaxValue; - if (_subtitle != null && _mouseDownParagraph != null) - { - var paragraphs = _subtitle.Paragraphs.OrderBy(p => p.StartTime.TotalMilliseconds).ToList(); - int curIdx = paragraphs.IndexOf(_mouseDownParagraph); - if (curIdx >= 0) - { - if (curIdx > 0) - { - _wholeParagraphMinMilliseconds = paragraphs[curIdx - 1].EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - if (curIdx < _subtitle.Paragraphs.Count - 1) - { - _wholeParagraphMaxMilliseconds = paragraphs[curIdx + 1].StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - } - - private void SetMinAndMaxMoveStart() - { - _wholeParagraphMinMilliseconds = 0; - _wholeParagraphMaxMilliseconds = double.MaxValue; - if (_subtitle != null && _mouseDownParagraph != null) - { - var paragraphs = _subtitle.Paragraphs.OrderBy(p => p.StartTime.TotalMilliseconds).ToList(); - int curIdx = paragraphs.IndexOf(_mouseDownParagraph); - if (curIdx >= 0) - { - var gap = Math.Abs(paragraphs[curIdx - 1].EndTime.TotalMilliseconds - paragraphs[curIdx].StartTime.TotalMilliseconds); - _wholeParagraphMinMilliseconds = paragraphs[curIdx - 1].StartTime.TotalMilliseconds + gap + 200; - } - } - } - - private void SetMinAndMaxMoveEnd() - { - _wholeParagraphMinMilliseconds = 0; - _wholeParagraphMaxMilliseconds = double.MaxValue; - if (_subtitle != null && _mouseDownParagraph != null) - { - var paragraphs = _subtitle.Paragraphs.OrderBy(p => p.StartTime.TotalMilliseconds).ToList(); - int curIdx = paragraphs.IndexOf(_mouseDownParagraph); - if (curIdx >= 0) - { - if (curIdx < _subtitle.Paragraphs.Count - 1) - { - var gap = Math.Abs(paragraphs[curIdx].EndTime.TotalMilliseconds - paragraphs[curIdx + 1].StartTime.TotalMilliseconds); - _wholeParagraphMaxMilliseconds = paragraphs[curIdx + 1].EndTime.TotalMilliseconds - gap - 200; - } - } - } - } - - private bool SetParagraphBorderHit(int milliseconds, List paragraphs) - { - foreach (var p in paragraphs) - { - bool hit = SetParagraphBorderHit(milliseconds, p); - if (hit) - { - return true; - } - } - return false; - } - - private Paragraph GetParagraphAtMilliseconds(int milliseconds) - { - Paragraph p = null; - if (IsParagraphHit(milliseconds, SelectedParagraph)) - { - p = SelectedParagraph; - } - - if (p == null) - { - foreach (var pNext in _displayableParagraphs) - { - if (IsParagraphHit(milliseconds, pNext)) - { - p = pNext; - break; - } - } - } - - return p; - } - - private bool SetParagraphBorderHit(int milliseconds, Paragraph paragraph) - { - if (paragraph == null) - { - return false; - } - - if (IsParagraphBorderStartHit(milliseconds, paragraph.StartTime.TotalMilliseconds)) - { - _oldParagraph = new Paragraph(paragraph); - _mouseDownParagraph = paragraph; - _mouseDownParagraphType = MouseDownParagraphType.Start; - return true; - } - if (IsParagraphBorderEndHit(milliseconds, paragraph.EndTime.TotalMilliseconds)) - { - _oldParagraph = new Paragraph(paragraph); - _mouseDownParagraph = paragraph; - _mouseDownParagraphType = MouseDownParagraphType.End; - return true; - } - return false; - } - - private bool PreventOverlap - { - get - { - if (ModifierKeys == Keys.Shift) - { - return AllowOverlap; - } - - return !AllowOverlap; - } - } - - private bool AllowMovePrevOrNext => _gapAtStart >= 0 && _gapAtStart < 500 && ModifierKeys == Keys.Alt; - - private void WaveformMouseMove(object sender, MouseEventArgs e) - { - if (_wavePeaks == null) - { - return; - } - - int oldMouseMoveLastX = _mouseMoveLastX; - if (e.X < 0 && _startPositionSeconds > 0.1 && _mouseDown) - { - if (e.X < _mouseMoveLastX) - { - StartPositionSeconds -= 0.1; - if (_mouseDownParagraph == null) - { - _mouseMoveEndX = 0; - _mouseMoveStartX += (int)(_wavePeaks.SampleRate * 0.1); - OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_startPositionSeconds, null)); - } - } - _mouseMoveLastX = e.X; - Invalidate(); - return; - } - if (e.X > Width && _startPositionSeconds + 0.1 < _wavePeaks.LengthInSeconds && _mouseDown) - { - StartPositionSeconds += 0.1; - if (_mouseDownParagraph == null) - { - _mouseMoveEndX = Width; - _mouseMoveStartX -= (int)(_wavePeaks.SampleRate * 0.1); - OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_startPositionSeconds, null)); - } - _mouseMoveLastX = e.X; - Invalidate(); - return; - } - _mouseMoveLastX = e.X; - - if (e.X < 0 || e.X > Width) - { - return; - } - - if (e.Button == MouseButtons.None) - { - double seconds = RelativeXPositionToSeconds(e.X); - var milliseconds = (int)(seconds * TimeCode.BaseUnit); - - if (IsParagraphBorderHit(milliseconds, NewSelectionParagraph)) - { - Cursor = Cursors.VSplit; - } - else if (IsParagraphBorderHit(milliseconds, SelectedParagraph) || - IsParagraphBorderHit(milliseconds, _displayableParagraphs)) - { - Cursor = Cursors.VSplit; - } - else - { - Cursor = Cursors.Default; - } - } - else if (e.Button == MouseButtons.Left) - { - if (oldMouseMoveLastX == e.X) - { - return; // no horizontal movement - } - - if (_mouseDown) - { - if (_mouseDownParagraph != null) - { - double seconds = RelativeXPositionToSeconds(e.X); - var milliseconds = (int)(seconds * TimeCode.BaseUnit); - var subtitleIndex = _subtitle.GetIndex(_mouseDownParagraph); - _prevParagraph = _subtitle.GetParagraphOrDefault(subtitleIndex - 1); - _nextParagraph = _subtitle.GetParagraphOrDefault(subtitleIndex + 1); - - if (_firstMove && Math.Abs(oldMouseMoveLastX - e.X) < Configuration.Settings.General.MinimumMillisecondsBetweenLines && GetParagraphAtMilliseconds(milliseconds) == null) - { - if (_mouseDownParagraphType == MouseDownParagraphType.Start && _prevParagraph != null && Math.Abs(_mouseDownParagraph.StartTime.TotalMilliseconds - _prevParagraph.EndTime.TotalMilliseconds) <= ClosenessForBorderSelection + 15) - { - return; // do not decide which paragraph to move yet - } - - if (_mouseDownParagraphType == MouseDownParagraphType.End && _nextParagraph != null && Math.Abs(_mouseDownParagraph.EndTime.TotalMilliseconds - _nextParagraph.StartTime.TotalMilliseconds) <= ClosenessForBorderSelection + 15) - { - return; // do not decide which paragraph to move yet - } - } - - if (ModifierKeys != Keys.Alt) - { - // decide which paragraph to move - if (_firstMove && e.X > oldMouseMoveLastX && _nextParagraph != null && _mouseDownParagraphType == MouseDownParagraphType.End) - { - if (milliseconds >= _nextParagraph.StartTime.TotalMilliseconds && milliseconds < _nextParagraph.EndTime.TotalMilliseconds) - { - _mouseDownParagraph = _nextParagraph; - _mouseDownParagraphType = MouseDownParagraphType.Start; - } - } - else if (_firstMove && e.X < oldMouseMoveLastX && _prevParagraph != null && _mouseDownParagraphType == MouseDownParagraphType.Start) - { - if (milliseconds <= _prevParagraph.EndTime.TotalMilliseconds && milliseconds > _prevParagraph.StartTime.TotalMilliseconds) - { - _mouseDownParagraph = _prevParagraph; - _mouseDownParagraphType = MouseDownParagraphType.End; - } - } - } - _firstMove = false; - - if (_mouseDownParagraphType == MouseDownParagraphType.Start) - { - if (_mouseDownParagraph.EndTime.TotalMilliseconds - milliseconds > MinimumSelectionMilliseconds) - { - if (AllowMovePrevOrNext) - { - SetMinAndMaxMoveStart(); - } - else - { - SetMinAndMax(); - } - - _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds; - - if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && ModifierKeys != Keys.Shift) - { - double nearestSceneChange = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs((x * 1000) - milliseconds) < Math.Abs((y * 1000) - milliseconds) ? x : y) : -9999; - if (Math.Abs(e.X - SecondsToXPosition(nearestSceneChange - _startPositionSeconds)) < SceneChangeSnapPixels) - { - _mouseDownParagraph.StartTime.TotalMilliseconds = nearestSceneChange * 1000; - } - } - - if (PreventOverlap && _mouseDownParagraph.StartTime.TotalMilliseconds <= _wholeParagraphMinMilliseconds) - { - _mouseDownParagraph.StartTime.TotalMilliseconds = _wholeParagraphMinMilliseconds + 1; - } - - if (NewSelectionParagraph != null) - { - NewSelectionParagraph.StartTime.TotalMilliseconds = milliseconds; - - if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && ModifierKeys != Keys.Shift) - { - double nearestSceneChange = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs((x * 1000) - milliseconds) < Math.Abs((y * 1000) - milliseconds) ? x : y) : -9999; - if (Math.Abs(e.X - SecondsToXPosition(nearestSceneChange - _startPositionSeconds)) < SceneChangeSnapPixels) - { - NewSelectionParagraph.StartTime.TotalMilliseconds = nearestSceneChange * 1000; - } - } - - if (PreventOverlap && NewSelectionParagraph.StartTime.TotalMilliseconds <= _wholeParagraphMinMilliseconds) - { - NewSelectionParagraph.StartTime.TotalMilliseconds = _wholeParagraphMinMilliseconds + 1; - } - - _mouseMoveStartX = e.X; - } - else - { - OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); - Refresh(); - return; - } - } - } - else if (_mouseDownParagraphType == MouseDownParagraphType.End) - { - if (milliseconds - _mouseDownParagraph.StartTime.TotalMilliseconds > MinimumSelectionMilliseconds) - { - if (AllowMovePrevOrNext) - { - SetMinAndMaxMoveEnd(); - } - else - { - SetMinAndMax(); - } - - _mouseDownParagraph.EndTime.TotalMilliseconds = milliseconds; - - if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && ModifierKeys != Keys.Shift) - { - double nearestSceneChange = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs((x * 1000) - milliseconds) < Math.Abs((y * 1000) - milliseconds) ? x : y) : -9999; - if (Math.Abs(e.X - SecondsToXPosition(nearestSceneChange - _startPositionSeconds)) < SceneChangeSnapPixels) - { - _mouseDownParagraph.EndTime.TotalMilliseconds = nearestSceneChange * 1000; - } - } - - if (PreventOverlap && _mouseDownParagraph.EndTime.TotalMilliseconds >= _wholeParagraphMaxMilliseconds) - { - _mouseDownParagraph.EndTime.TotalMilliseconds = _wholeParagraphMaxMilliseconds - 1; - } - - if (NewSelectionParagraph != null) - { - NewSelectionParagraph.EndTime.TotalMilliseconds = milliseconds; - - if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && ModifierKeys != Keys.Shift) - { - double nearestSceneChange = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs((x * 1000) - milliseconds) < Math.Abs((y * 1000) - milliseconds) ? x : y) : -9999; - if (Math.Abs(e.X - SecondsToXPosition(nearestSceneChange - _startPositionSeconds)) < SceneChangeSnapPixels) - { - NewSelectionParagraph.EndTime.TotalMilliseconds = nearestSceneChange * 1000; - } - } - - if (PreventOverlap && NewSelectionParagraph.EndTime.TotalMilliseconds >= _wholeParagraphMaxMilliseconds) - { - NewSelectionParagraph.EndTime.TotalMilliseconds = _wholeParagraphMaxMilliseconds - 1; - } - - _mouseMoveEndX = e.X; - } - else - { - OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); - Refresh(); - return; - } - } - } - else if (_mouseDownParagraphType == MouseDownParagraphType.Whole) - { - double durationMilliseconds = _mouseDownParagraph.Duration.TotalMilliseconds; - - var oldStart = _mouseDownParagraph.StartTime.TotalMilliseconds; - _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds - _moveWholeStartDifferenceMilliseconds; - _mouseDownParagraph.EndTime.TotalMilliseconds = _mouseDownParagraph.StartTime.TotalMilliseconds + durationMilliseconds; - - if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && ModifierKeys != Keys.Shift) - { - double nearestSceneChangeInFront = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs((x * 1000) - _mouseDownParagraph.StartTime.TotalMilliseconds) < Math.Abs((y * 1000) - _mouseDownParagraph.StartTime.TotalMilliseconds) ? x : y) : -9999; - double nearestSceneChangeInBack = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs((x * 1000) - _mouseDownParagraph.EndTime.TotalMilliseconds) < Math.Abs((y * 1000) - _mouseDownParagraph.EndTime.TotalMilliseconds) ? x : y) : -9999; - - if (Math.Abs(SecondsToXPosition(_mouseDownParagraph.StartTime.TotalSeconds - _startPositionSeconds) - SecondsToXPosition(nearestSceneChangeInFront - _startPositionSeconds)) < SceneChangeSnapPixels) - { - _mouseDownParagraph.StartTime.TotalMilliseconds = nearestSceneChangeInFront * 1000; - _mouseDownParagraph.EndTime.TotalMilliseconds = (nearestSceneChangeInFront * 1000) + durationMilliseconds; - } - else if (Math.Abs(SecondsToXPosition(_mouseDownParagraph.EndTime.TotalSeconds - _startPositionSeconds) - SecondsToXPosition(nearestSceneChangeInBack - _startPositionSeconds)) < SceneChangeSnapPixels) - { - _mouseDownParagraph.EndTime.TotalMilliseconds = nearestSceneChangeInBack * 1000; - _mouseDownParagraph.StartTime.TotalMilliseconds = (nearestSceneChangeInBack * 1000) - durationMilliseconds; - } - } - - if (PreventOverlap && _mouseDownParagraph.EndTime.TotalMilliseconds >= _wholeParagraphMaxMilliseconds) - { - _mouseDownParagraph.EndTime.TotalMilliseconds = _wholeParagraphMaxMilliseconds - 1; - _mouseDownParagraph.StartTime.TotalMilliseconds = _mouseDownParagraph.EndTime.TotalMilliseconds - durationMilliseconds; - } - else if (PreventOverlap && _mouseDownParagraph.StartTime.TotalMilliseconds <= _wholeParagraphMinMilliseconds) - { - _mouseDownParagraph.StartTime.TotalMilliseconds = _wholeParagraphMinMilliseconds + 1; - _mouseDownParagraph.EndTime.TotalMilliseconds = _mouseDownParagraph.StartTime.TotalMilliseconds + durationMilliseconds; - } - - if (PreventOverlap && - (_mouseDownParagraph.StartTime.TotalMilliseconds <= _wholeParagraphMinMilliseconds || - _mouseDownParagraph.EndTime.TotalMilliseconds >= _wholeParagraphMaxMilliseconds)) - { - _mouseDownParagraph.StartTime.TotalMilliseconds = oldStart; - _mouseDownParagraph.EndTime.TotalMilliseconds = oldStart + durationMilliseconds; - return; - } - - OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType) { AdjustMs = _mouseDownParagraph.StartTime.TotalMilliseconds - oldStart }); - } - } - else - { - _mouseMoveEndX = e.X; - if (NewSelectionParagraph == null && Math.Abs(_mouseMoveEndX - _mouseMoveStartX) > 2) - { - if (AllowNewSelection) - { - NewSelectionParagraph = new Paragraph(); - } - } - - if (NewSelectionParagraph != null) - { - int start = Math.Min(_mouseMoveStartX, _mouseMoveEndX); - int end = Math.Max(_mouseMoveStartX, _mouseMoveEndX); - - var startTotalSeconds = RelativeXPositionToSeconds(start); - var endTotalSeconds = RelativeXPositionToSeconds(end); - - NewSelectionParagraph.StartTime.TotalSeconds = startTotalSeconds; - NewSelectionParagraph.EndTime.TotalSeconds = endTotalSeconds; - - if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && ModifierKeys != Keys.Shift) - { - double nearestSceneChangeInFront = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs(x - startTotalSeconds) < Math.Abs(y - startTotalSeconds) ? x : y) : -9999; - double nearestSceneChangeInBack = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs(x - endTotalSeconds) < Math.Abs(y - endTotalSeconds) ? x : y) : -9999; - - if (Math.Abs(SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - _startPositionSeconds) - SecondsToXPosition(nearestSceneChangeInFront - _startPositionSeconds)) < SceneChangeSnapPixels) - { - NewSelectionParagraph.StartTime.TotalMilliseconds = nearestSceneChangeInFront * 1000; - Invalidate(); - } - if (Math.Abs(SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - _startPositionSeconds) - SecondsToXPosition(nearestSceneChangeInBack - _startPositionSeconds)) < SceneChangeSnapPixels) - { - NewSelectionParagraph.EndTime.TotalMilliseconds = nearestSceneChangeInBack * 1000; - Invalidate(); - } - } - - if (PreventOverlap && endTotalSeconds * TimeCode.BaseUnit >= _wholeParagraphMaxMilliseconds) - { - NewSelectionParagraph.EndTime.TotalMilliseconds = _wholeParagraphMaxMilliseconds - 1; - Invalidate(); - } - if (PreventOverlap && startTotalSeconds * TimeCode.BaseUnit <= _wholeParagraphMinMilliseconds) - { - NewSelectionParagraph.StartTime.TotalMilliseconds = _wholeParagraphMinMilliseconds + 1; - Invalidate(); - } - } - } - Invalidate(); - } - } - } - - private bool IsParagraphBorderHit(int milliseconds, List paragraphs) - { - foreach (Paragraph p in paragraphs) - { - bool hit = IsParagraphBorderHit(milliseconds, p); - if (hit) - { - return true; - } - } - return false; - } - - private bool IsParagraphBorderHit(int milliseconds, Paragraph paragraph) - { - if (paragraph == null) - { - return false; - } - - return IsParagraphBorderStartHit(milliseconds, paragraph.StartTime.TotalMilliseconds) || - IsParagraphBorderEndHit(milliseconds, paragraph.EndTime.TotalMilliseconds); - } - - private bool IsParagraphBorderStartHit(double milliseconds, double startMs) - { - return Math.Abs(milliseconds - (startMs - 5)) - 10 <= ClosenessForBorderSelection; - } - - private bool IsParagraphBorderEndHit(double milliseconds, double endMs) - { - return Math.Abs(milliseconds - (endMs - 22)) - 7 <= ClosenessForBorderSelection; - } - - private void WaveformMouseUp(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Left) - { - if (_mouseDown) - { - if (_mouseDownParagraph != null) - { - _mouseDownParagraph = null; - } - else - { - _mouseMoveEndX = e.X; - } - _mouseDown = false; - } - } - Cursor = Cursors.Default; - } - - private void WaveformMouseLeave(object sender, EventArgs e) - { - Cursor = Cursors.Default; - _mouseDown = false; - Invalidate(); - } - - private void WaveformMouseEnter(object sender, EventArgs e) - { - if (_wavePeaks == null) - { - return; - } - - if (_noClear) - { - _noClear = false; - } - else - { - Cursor = Cursors.Default; - _mouseDown = false; - _mouseDownParagraph = null; - _mouseMoveStartX = -1; - _mouseMoveEndX = -1; - Invalidate(); - } - - if (NewSelectionParagraph != null) - { - _mouseMoveStartX = SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - _startPositionSeconds); - _mouseMoveEndX = SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - _startPositionSeconds); - } - } - - private void WaveformMouseDoubleClick(object sender, MouseEventArgs e) - { - if (_wavePeaks == null) - { - return; - } - - _mouseDown = false; - _mouseDownParagraph = null; - _mouseMoveStartX = -1; - _mouseMoveEndX = -1; - - if (e.Button == MouseButtons.Left) - { - OnPause?.Invoke(sender, null); - double seconds = RelativeXPositionToSeconds(e.X); - var milliseconds = (int)(seconds * TimeCode.BaseUnit); - - Paragraph p = GetParagraphAtMilliseconds(milliseconds); - if (p != null) - { - seconds = p.StartTime.TotalSeconds; - double endSeconds = p.EndTime.TotalSeconds; - if (seconds < _startPositionSeconds) - { - _startPositionSeconds = (p.StartTime.TotalSeconds) + 0.1; // move earlier - show whole selected paragraph - } - else if (endSeconds > EndPositionSeconds) - { - double newStartPos = _startPositionSeconds + (endSeconds - EndPositionSeconds); // move later, so whole selected paragraph is visible - if (newStartPos < seconds) // but only if visible screen is wide enough - { - _startPositionSeconds = newStartPos; - } - } - } - - OnDoubleClickNonParagraph?.Invoke(this, new ParagraphEventArgs(seconds, p)); - } - } - - private static bool IsParagraphHit(int milliseconds, Paragraph paragraph) - { - if (paragraph == null) - { - return false; - } - - return milliseconds >= paragraph.StartTime.TotalMilliseconds && milliseconds <= paragraph.EndTime.TotalMilliseconds; - } - - private void WaveformMouseClick(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Left && OnSingleClick != null) - { - int diff = Math.Abs(_mouseMoveStartX - e.X); - if (_mouseMoveStartX == -1 || _mouseMoveEndX == -1 || diff < 10 && TimeSpan.FromTicks(DateTime.UtcNow.Ticks - _buttonDownTimeTicks).TotalSeconds < 0.25) - { - if (ModifierKeys == Keys.Shift && SelectedParagraph != null) - { - double seconds = RelativeXPositionToSeconds(e.X); - var milliseconds = (int)(seconds * TimeCode.BaseUnit); - if (_mouseDownParagraphType == MouseDownParagraphType.None || _mouseDownParagraphType == MouseDownParagraphType.Whole) - { - if (seconds < SelectedParagraph.EndTime.TotalSeconds) - { - _oldParagraph = new Paragraph(SelectedParagraph); - _mouseDownParagraph = SelectedParagraph; - _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds; - OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph)); - } - } - return; - } - if (ModifierKeys == Keys.Control && SelectedParagraph != null) - { - double seconds = RelativeXPositionToSeconds(e.X); - var milliseconds = (int)(seconds * TimeCode.BaseUnit); - if (_mouseDownParagraphType == MouseDownParagraphType.None || _mouseDownParagraphType == MouseDownParagraphType.Whole) - { - if (seconds > SelectedParagraph.StartTime.TotalSeconds) - { - _oldParagraph = new Paragraph(SelectedParagraph); - _mouseDownParagraph = SelectedParagraph; - _mouseDownParagraph.EndTime.TotalMilliseconds = milliseconds; - OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph)); - } - } - return; - } - if (ModifierKeys == (Keys.Control | Keys.Shift) && SelectedParagraph != null) - { - double seconds = RelativeXPositionToSeconds(e.X); - if (_mouseDownParagraphType == MouseDownParagraphType.None || _mouseDownParagraphType == MouseDownParagraphType.Whole) - { - _oldParagraph = new Paragraph(SelectedParagraph); - _mouseDownParagraph = SelectedParagraph; - OnTimeChangedAndOffsetRest?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph)); - } - return; - } - if (ModifierKeys == Keys.Alt && SelectedParagraph != null) - { - double seconds = RelativeXPositionToSeconds(e.X); - var milliseconds = (int)(seconds * TimeCode.BaseUnit); - if (_mouseDownParagraphType == MouseDownParagraphType.None || _mouseDownParagraphType == MouseDownParagraphType.Whole) - { - _oldParagraph = new Paragraph(SelectedParagraph); - _mouseDownParagraph = SelectedParagraph; - double durationMilliseconds = _mouseDownParagraph.Duration.TotalMilliseconds; - _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds; - _mouseDownParagraph.EndTime.TotalMilliseconds = _mouseDownParagraph.StartTime.TotalMilliseconds + durationMilliseconds; - OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph)); - } - return; - } - - if (_mouseDownParagraphType == MouseDownParagraphType.None || _mouseDownParagraphType == MouseDownParagraphType.Whole) - { - double seconds = RelativeXPositionToSeconds(e.X); - var milliseconds = (int)(seconds * TimeCode.BaseUnit); - Paragraph p = GetParagraphAtMilliseconds(milliseconds); - OnSingleClick.Invoke(this, new ParagraphEventArgs(RelativeXPositionToSeconds(e.X), p)); - } - } - } - } - - private void WaveformKeyDown(object sender, KeyEventArgs e) - { - if (_wavePeaks == null) - { - return; - } - - if (e.Modifiers == Keys.None && e.KeyCode == Keys.Add) - { - ZoomIn(); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Subtract) - { - ZoomOut(); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D0) - { - ZoomFactor = 1.0; - OnZoomedChanged?.Invoke(this, null); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Z) - { - if (_startPositionSeconds > 0.1) - { - StartPositionSeconds -= 0.1; - OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_startPositionSeconds, null)); - Invalidate(); - e.SuppressKeyPress = true; - } - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.X) - { - if (_startPositionSeconds + 0.1 < _wavePeaks.LengthInSeconds) - { - StartPositionSeconds += 0.1; - OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_startPositionSeconds, null)); - Invalidate(); - e.SuppressKeyPress = true; - } - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.C) - { - Locked = !Locked; - Invalidate(); - e.SuppressKeyPress = true; - } - else if (e.KeyData == InsertAtVideoPositionShortcut) - { - if (InsertAtVideoPosition != null) - { - InsertAtVideoPosition.Invoke(this, null); - e.SuppressKeyPress = true; - } - } - else if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control) //Ctrl+v = Paste from clipboard - { - if (PasteAtVideoPosition != null) - { - PasteAtVideoPosition.Invoke(this, null); - e.SuppressKeyPress = true; - } - } - else if (e.KeyData == Move100MsLeft) - { - var pos = Math.Max(0, _currentVideoPositionSeconds - 0.1); - OnPositionSelected?.Invoke(this, new ParagraphEventArgs(pos, null)); - Invalidate(); - e.SuppressKeyPress = true; - } - else if (e.KeyData == Move100MsRight) - { - var pos = _currentVideoPositionSeconds + 0.1; - OnPositionSelected?.Invoke(this, new ParagraphEventArgs(pos, null)); - Invalidate(); - e.SuppressKeyPress = true; - } - else if (e.KeyData == MoveOneSecondLeft) - { - var pos = Math.Max(0, _currentVideoPositionSeconds - 1); - OnPositionSelected?.Invoke(this, new ParagraphEventArgs(pos, null)); - Invalidate(); - e.SuppressKeyPress = true; - } - else if (e.KeyData == MoveOneSecondRight) - { - var pos = _currentVideoPositionSeconds + 1; - OnPositionSelected?.Invoke(this, new ParagraphEventArgs(pos, null)); - Invalidate(); - e.SuppressKeyPress = true; - } - } - - public void ZoomIn() - { - ZoomFactor += 0.1; - OnZoomedChanged?.Invoke(this, null); - } - - public void ZoomOut() - { - ZoomFactor -= 0.1; - OnZoomedChanged?.Invoke(this, null); - } - - private void VerticalZoomIn() - { - VerticalZoomFactor *= 1.1; - } - - private void VerticalZoomOut() - { - VerticalZoomFactor /= 1.1; - } - - private void WaveformMouseWheel(object sender, MouseEventArgs e) - { - // The scroll wheel could work in theory without the waveform loaded (it would be - // just like dragging the slider, which does work without the waveform), but the - // code below doesn't support it, so bail out until someone feels like fixing it. - if (_wavePeaks == null) - { - return; - } - - if (ModifierKeys == Keys.Control) - { - if (e.Delta > 0) - { - ZoomIn(); - } - else - { - ZoomOut(); - } - - return; - } - - if (ModifierKeys == (Keys.Control | Keys.Shift)) - { - if (e.Delta > 0) - { - VerticalZoomIn(); - } - else - { - VerticalZoomOut(); - } - - return; - } - - int delta = e.Delta; - if (!MouseWheelScrollUpIsForward) - { - delta = delta * -1; - } - - if (Locked) - { - OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_currentVideoPositionSeconds + (delta / 256.0), null)); - } - else - { - StartPositionSeconds += delta / 256.0; - _lastMouseWheelScroll = DateTime.UtcNow.Ticks; - if (_currentVideoPositionSeconds < _startPositionSeconds || _currentVideoPositionSeconds >= EndPositionSeconds) - { - OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_startPositionSeconds, null)); - } - } - Invalidate(); - } - - ///////////////////////////////////////////////// - - private void InitializeSpectrogram(SpectrogramData spectrogram) - { - if (_spectrogram != null) - { - _spectrogram.Dispose(); - _spectrogram = null; - Invalidate(); - } - - if (spectrogram == null) - { - return; - } - - if (spectrogram.IsLoaded) - { - InitializeSpectrogramInternal(spectrogram); - } - else - { - Task.Factory.StartNew(() => - { - spectrogram.Load(); - BeginInvoke((Action)(() => - { - InitializeSpectrogramInternal(spectrogram); - })); - }); - } - } - - private void InitializeSpectrogramInternal(SpectrogramData spectrogram) - { - if (_spectrogram != null) - { - return; - } - - _spectrogram = spectrogram; - Invalidate(); - } - - private void DrawSpectrogram(Graphics graphics) - { - int width = (int)Math.Round((EndPositionSeconds - _startPositionSeconds) / _spectrogram.SampleDuration); - using (var bmpCombined = new Bitmap(width, _spectrogram.FftSize / 2)) - using (var gfxCombined = Graphics.FromImage(bmpCombined)) - { - int left = (int)Math.Round(_startPositionSeconds / _spectrogram.SampleDuration); - int offset = 0; - int imageIndex = left / _spectrogram.ImageWidth; - while (offset < width && imageIndex < _spectrogram.Images.Count) - { - int x = (left + offset) % _spectrogram.ImageWidth; - int w = Math.Min(_spectrogram.ImageWidth - x, width - offset); - gfxCombined.DrawImage(_spectrogram.Images[imageIndex], offset, 0, new Rectangle(x, 0, w, bmpCombined.Height), GraphicsUnit.Pixel); - offset += w; - imageIndex++; - } - int displayHeight = _showWaveform ? SpectrogramDisplayHeight : Height; - graphics.DrawImage(bmpCombined, new Rectangle(0, Height - displayHeight, Width, displayHeight)); - } - } - - private double GetAverageVolumeForNextMilliseconds(int sampleIndex, int milliseconds) - { - // length cannot be less than 9 - int length = Math.Max(SecondsToSampleIndex(milliseconds / TimeCode.BaseUnit), 9); - int max = Math.Min(sampleIndex + length, _wavePeaks.Peaks.Count); - int from = Math.Max(sampleIndex, 1); - - if (from >= max) - { - return 0; - } - - double v = 0; - for (int i = from; i < max; i++) - { - v += _wavePeaks.Peaks[i].Abs; - } - - return v / (max - from); - } - - internal void GenerateTimeCodes(Subtitle subtitle, double startFromSeconds, int blockSizeMilliseconds, int minimumVolumePercent, int maximumVolumePercent, int defaultMilliseconds) - { - int begin = SecondsToSampleIndex(startFromSeconds); - - double average = 0; - for (int k = begin; k < _wavePeaks.Peaks.Count; k++) - { - average += _wavePeaks.Peaks[k].Abs; - } - - average /= _wavePeaks.Peaks.Count - begin; - - var maxThreshold = (int)(_wavePeaks.HighestPeak * (maximumVolumePercent / 100.0)); - var silenceThreshold = (int)(average * (minimumVolumePercent / 100.0)); - - int length50Ms = SecondsToSampleIndex(0.050); - double secondsPerParagraph = defaultMilliseconds / TimeCode.BaseUnit; - int minBetween = SecondsToSampleIndex(Configuration.Settings.General.MinimumMillisecondsBetweenLines / TimeCode.BaseUnit); - bool subtitleOn = false; - int i = begin; - while (i < _wavePeaks.Peaks.Count) - { - if (subtitleOn) - { - var currentLengthInSeconds = SampleIndexToSeconds(i - begin); - if (currentLengthInSeconds > 1.0) - { - subtitleOn = EndParagraphDueToLowVolume(subtitle, blockSizeMilliseconds, silenceThreshold, begin, true, i); - if (!subtitleOn) - { - begin = i + minBetween; - i = begin; - } - } - if (subtitleOn && currentLengthInSeconds >= secondsPerParagraph) - { - for (int j = 0; j < 20; j++) - { - subtitleOn = EndParagraphDueToLowVolume(subtitle, blockSizeMilliseconds, silenceThreshold, begin, true, i + (j * length50Ms)); - if (!subtitleOn) - { - i += (j * length50Ms); - begin = i + minBetween; - i = begin; - break; - } - } - - if (subtitleOn) // force break - { - var p = new Paragraph(string.Empty, SampleIndexToSeconds(begin) * TimeCode.BaseUnit, SampleIndexToSeconds(i) * TimeCode.BaseUnit); - subtitle.Paragraphs.Add(p); - begin = i + minBetween; - i = begin; - } - } - } - else - { - double avgVol = GetAverageVolumeForNextMilliseconds(i, blockSizeMilliseconds); - if (avgVol > silenceThreshold && avgVol < maxThreshold) - { - subtitleOn = true; - begin = i; - } - } - i++; - } - - subtitle.Renumber(); - } - - private bool EndParagraphDueToLowVolume(Subtitle subtitle, int blockSizeMilliseconds, double silenceThreshold, int begin, bool subtitleOn, int i) - { - double avgVol = GetAverageVolumeForNextMilliseconds(i, blockSizeMilliseconds); - if (avgVol < silenceThreshold) - { - var p = new Paragraph(string.Empty, SampleIndexToSeconds(begin) * TimeCode.BaseUnit, SampleIndexToSeconds(i) * TimeCode.BaseUnit); - subtitle.Paragraphs.Add(p); - subtitleOn = false; - } - return subtitleOn; - } - - private MinMax GetMinAndMax(int startIndex, int endIndex) - { - int minPeak = int.MaxValue; - int maxPeak = int.MinValue; - double total = 0; - for (int i = startIndex; i < endIndex; i++) - { - var v = _wavePeaks.Peaks[i].Abs; - total += v; - if (v < minPeak) - { - minPeak = v; - } - if (v > maxPeak) - { - maxPeak = v; - } - } - - return new MinMax { Min = minPeak, Max = maxPeak, Avg = total / (endIndex - startIndex) }; - } - - public double FindDataBelowThreshold(double thresholdPercent, double durationInSeconds) - { - int begin = SecondsToSampleIndex(_currentVideoPositionSeconds + 1); - int length = SecondsToSampleIndex(durationInSeconds); - var threshold = thresholdPercent / 100.0 * _wavePeaks.HighestPeak; - - int hitCount = 0; - for (int i = Math.Max(0, begin); i < _wavePeaks.Peaks.Count; i++) - { - if (_wavePeaks.Peaks[i].Abs <= threshold) - { - hitCount++; - } - else - { - hitCount = 0; - } - - if (hitCount > length) - { - double seconds = SampleIndexToSeconds(i - (length / 2)); - if (seconds >= 0) - { - StartPositionSeconds = seconds; - if (_startPositionSeconds > 1) - { - StartPositionSeconds -= 1; - } - - OnSingleClick?.Invoke(this, new ParagraphEventArgs(seconds, null)); - Invalidate(); - } - return seconds; - } - } - return -1; - } - - /// video position in seconds, -1 if not found - public double FindDataBelowThresholdBack(double thresholdPercent, double durationInSeconds) - { - int begin = SecondsToSampleIndex(_currentVideoPositionSeconds - 1); - int length = SecondsToSampleIndex(durationInSeconds); - var threshold = thresholdPercent / 100.0 * _wavePeaks.HighestPeak; - int hitCount = 0; - for (int i = begin; i > 0; i--) - { - if (i > 0 && i < _wavePeaks.Peaks.Count && _wavePeaks.Peaks[i].Abs <= threshold) - { - hitCount++; - if (hitCount > length) - { - double seconds = SampleIndexToSeconds(i + length / 2); - if (seconds >= 0) - { - StartPositionSeconds = seconds; - if (_startPositionSeconds > 1) - { - StartPositionSeconds -= 1; - } - else - { - StartPositionSeconds = 0; - } - - OnSingleClick?.Invoke(this, new ParagraphEventArgs(seconds, null)); - Invalidate(); - } - return seconds; - } - } - else - { - hitCount = 0; - } - } - return -1; - } - - /// - /// Seeks silence in volume - /// - /// video position in seconds, -1 if not found - public double FindDataBelowThresholdBackForStart(double thresholdPercent, double durationInSeconds, double startSeconds) - { - var min = Math.Max(0, SecondsToSampleIndex(startSeconds - 1)); - var maxShort = Math.Min(_wavePeaks.Peaks.Count, SecondsToSampleIndex(startSeconds + durationInSeconds + 0.01)); - var max = Math.Min(_wavePeaks.Peaks.Count, SecondsToSampleIndex(startSeconds + durationInSeconds + 0.8)); - int length = SecondsToSampleIndex(durationInSeconds); - var threshold = thresholdPercent / 100.0 * _wavePeaks.HighestPeak; - - var minMax = GetMinAndMax(min, max); - const int lowPeakDifference = 4_000; - if (minMax.Max - minMax.Min < lowPeakDifference) - { - return -1; // all audio about the same - } - - // look for start silence in the beginning of subtitle - min = SecondsToSampleIndex(startSeconds); - var hitCount = 0; - int index; - for (index = min; index < max; index++) - { - if (index > 0 && index < _wavePeaks.Peaks.Count && _wavePeaks.Peaks[index].Abs <= threshold) - { - hitCount++; - } - else - { - minMax = GetMinAndMax(min, index); - var currentMinMax = GetMinAndMax(SecondsToSampleIndex(startSeconds), SecondsToSampleIndex(startSeconds + 0.8)); - if (currentMinMax.Avg > minMax.Avg + 300 || currentMinMax.Avg < 1000 && minMax.Avg < 1000 && Math.Abs(currentMinMax.Avg - minMax.Avg) < 500) - { - break; - } - hitCount = length / 2; - } - } - if (hitCount > length) - { - minMax = GetMinAndMax(min, index); - var currentMinMax = GetMinAndMax(SecondsToSampleIndex(startSeconds), SecondsToSampleIndex(startSeconds + 0.8)); - if (currentMinMax.Avg > minMax.Avg + 300 || currentMinMax.Avg < 1000 && minMax.Avg < 1000 && Math.Abs(currentMinMax.Avg - minMax.Avg) < 500) - { - return Math.Max(0, SampleIndexToSeconds(index - 1) - 0.01); - } - } - - // move start left? - min = SecondsToSampleIndex(startSeconds - 1); - hitCount = 0; - for (index = maxShort; index > min; index--) - { - if (index > 0 && index < _wavePeaks.Peaks.Count && _wavePeaks.Peaks[index].Abs <= threshold) - { - hitCount++; - if (hitCount > length) - { - return Math.Max(0, SampleIndexToSeconds(index + length) - 0.01); - } - } - else - { - hitCount = 0; - } - } - return -1; - } - - public double FindLowPercentage(double startSeconds, double endSeconds) - { - var min = Math.Max(0, SecondsToSampleIndex(startSeconds)); - var max = Math.Min(_wavePeaks.Peaks.Count, SecondsToSampleIndex(endSeconds)); - var minMax = GetMinAndMax(min, max); - var threshold = minMax.Min * 100.0 / _wavePeaks.HighestPeak; - return threshold; - } - - public double FindHighPercentage(double startSeconds, double endSeconds) - { - var min = Math.Max(0, SecondsToSampleIndex(startSeconds)); - var max = Math.Min(_wavePeaks.Peaks.Count, SecondsToSampleIndex(endSeconds)); - var minMax = GetMinAndMax(min, max); - var threshold = minMax.Max * 100.0 / _wavePeaks.HighestPeak; - return threshold; - } - - public int GetSceneChangeIndex(double seconds) - { - if (SceneChanges == null) - { - return -1; - } - try - { - for (int index = 0; index < SceneChanges.Count; index++) - { - var sceneChange = SceneChanges[index]; - if (Math.Abs(sceneChange - seconds) < 0.04) - { - return index; - } - } - } - catch - { - // ignored - } - - return -1; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Globalization; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Controls +{ + public sealed partial class AudioVisualizer : UserControl + { + public enum MouseDownParagraphType + { + None, + Start, + Whole, + End + } + + public class MinMax + { + public double Min { get; set; } + public double Max { get; set; } + public double Avg { get; set; } + } + + public class ParagraphEventArgs : EventArgs + { + public Paragraph Paragraph { get; } + public double Seconds { get; } + public Paragraph BeforeParagraph { get; set; } + public MouseDownParagraphType MouseDownParagraphType { get; set; } + public bool MovePreviousOrNext { get; set; } + public double AdjustMs { get; set; } + public ParagraphEventArgs(Paragraph p) + { + Paragraph = p; + } + public ParagraphEventArgs(double seconds, Paragraph p) + { + Seconds = seconds; + Paragraph = p; + } + public ParagraphEventArgs(double seconds, Paragraph p, Paragraph b) + { + Seconds = seconds; + Paragraph = p; + BeforeParagraph = b; + } + public ParagraphEventArgs(double seconds, Paragraph p, Paragraph b, MouseDownParagraphType mouseDownParagraphType) + { + Seconds = seconds; + Paragraph = p; + BeforeParagraph = b; + MouseDownParagraphType = mouseDownParagraphType; + } + public ParagraphEventArgs(double seconds, Paragraph p, Paragraph b, MouseDownParagraphType mouseDownParagraphType, bool movePreviousOrNext) + { + Seconds = seconds; + Paragraph = p; + BeforeParagraph = b; + MouseDownParagraphType = mouseDownParagraphType; + MovePreviousOrNext = movePreviousOrNext; + } + } + + public int ClosenessForBorderSelection { get; set; } = 15; + private const int MinimumSelectionMilliseconds = 100; + + private long _buttonDownTimeTicks; + private long _lastMouseWheelScroll = -1; + private int _mouseMoveLastX = -1; + private int _mouseMoveStartX = -1; + private double _moveWholeStartDifferenceMilliseconds = -1; + private int _mouseMoveEndX = -1; + private bool _mouseDown; + private Paragraph _oldParagraph; + private Paragraph _mouseDownParagraph; + private MouseDownParagraphType _mouseDownParagraphType = MouseDownParagraphType.Start; + private readonly List _displayableParagraphs; + private readonly List _allSelectedParagraphs; + private Paragraph _prevParagraph; + private Paragraph _nextParagraph; + private bool _firstMove = true; + private double _currentVideoPositionSeconds = -1; + private WavePeakData _wavePeaks; + private Subtitle _subtitle; + private bool _noClear; + private double _gapAtStart = -1; + + private SpectrogramData _spectrogram; + private const int SpectrogramDisplayHeight = 128; + + public delegate void ParagraphEventHandler(object sender, ParagraphEventArgs e); + public event ParagraphEventHandler OnNewSelectionRightClicked; + public event ParagraphEventHandler OnParagraphRightClicked; + public event ParagraphEventHandler OnNonParagraphRightClicked; + public event ParagraphEventHandler OnPositionSelected; + + public event ParagraphEventHandler OnTimeChanged; + public event ParagraphEventHandler OnTimeChangedAndOffsetRest; + + public event ParagraphEventHandler OnSingleClick; + public event ParagraphEventHandler OnDoubleClickNonParagraph; + public event EventHandler OnPause; + public event EventHandler OnZoomedChanged; + public event EventHandler InsertAtVideoPosition; + public event EventHandler PasteAtVideoPosition; + + private double _wholeParagraphMinMilliseconds; + private double _wholeParagraphMaxMilliseconds = double.MaxValue; + public Keys InsertAtVideoPositionShortcut { get; set; } + public Keys Move100MsLeft { get; set; } + public Keys Move100MsRight { get; set; } + public Keys MoveOneSecondLeft { get; set; } + public Keys MoveOneSecondRight { get; set; } + public bool MouseWheelScrollUpIsForward { get; set; } = true; + + public const double ZoomMinimum = 0.1; + public const double ZoomMaximum = 2.5; + private double _zoomFactor = 1.0; // 1.0=no zoom + + public const int SceneChangeSnapPixels = 8; + + public double ZoomFactor + { + get => _zoomFactor; + set + { + if (value < ZoomMinimum) + { + value = ZoomMinimum; + } + + if (value > ZoomMaximum) + { + value = ZoomMaximum; + } + + value = Math.Round(value, 2); // round to prevent accumulated rounding errors + if (Math.Abs(_zoomFactor - value) > 0.01) + { + _zoomFactor = value; + Invalidate(); + } + } + } + + public const double VerticalZoomMinimum = 1.0; + public const double VerticalZoomMaximum = 20.0; + private double _verticalZoomFactor = 1.0; // 1.0=no zoom + + public double VerticalZoomFactor + { + get => _verticalZoomFactor; + set + { + if (value < VerticalZoomMinimum) + { + value = VerticalZoomMinimum; + } + + if (value > VerticalZoomMaximum) + { + value = VerticalZoomMaximum; + } + + value = Math.Round(value, 2); // round to prevent accumulated rounding errors + if (Math.Abs(_verticalZoomFactor - value) > 0.01) + { + _verticalZoomFactor = value; + Invalidate(); + } + } + } + + private List _sceneChanges = new List(); + + /// + /// Scene changes (seconds) + /// + public List SceneChanges + { + get => _sceneChanges; + set + { + _sceneChanges = value; + Invalidate(); + } + } + + private List _chapters = new List(); + + public List Chapters + { + get => _chapters; + set + { + _chapters = value; + Invalidate(); + } + } + + public bool IsSpectrogramAvailable => _spectrogram != null && _spectrogram.Images.Count > 0; + + private bool _showSpectrogram; + + public bool ShowSpectrogram + { + get => _showSpectrogram; + set + { + if (_showSpectrogram != value) + { + _showSpectrogram = value; + Invalidate(); + } + } + } + + public bool AllowOverlap { get; set; } + + private bool _showWaveform; + + public bool ShowWaveform + { + get => _showWaveform; + set + { + if (_showWaveform != value) + { + _showWaveform = value; + Invalidate(); + } + } + } + + private double _startPositionSeconds; + + public double StartPositionSeconds + { + get => _startPositionSeconds; + set + { + if (_wavePeaks != null) + { + double endPositionSeconds = value + ((double)Width / _wavePeaks.SampleRate) / _zoomFactor; + if (endPositionSeconds > _wavePeaks.LengthInSeconds) + { + value -= endPositionSeconds - _wavePeaks.LengthInSeconds; + } + } + if (value < 0) + { + value = 0; + } + + if (Math.Abs(_startPositionSeconds - value) > 0.01) + { + _startPositionSeconds = value; + Invalidate(); + } + } + } + + public Paragraph NewSelectionParagraph { get; set; } + public Paragraph SelectedParagraph { get; private set; } + public Paragraph RightClickedParagraph { get; private set; } + public double RightClickedSeconds { get; private set; } + + public string WaveformNotLoadedText { get; set; } + public Color BackgroundColor { get; set; } + public Color Color { get; set; } + public Color SelectedColor { get; set; } + public Color ParagraphColor { get; set; } + public Color TextColor { get; set; } + public Color CursorColor { get; set; } + public Color ChaptersColor { get; set; } + public float TextSize { get; set; } + public bool TextBold { get; set; } + public Color GridColor { get; set; } + public bool ShowGridLines { get; set; } + public bool AllowNewSelection { get; set; } + + public bool Locked { get; set; } + + public double EndPositionSeconds + { + get + { + if (_wavePeaks == null) + { + return 0; + } + + return RelativeXPositionToSeconds(Width); + } + } + + public WavePeakData WavePeaks + { + get => _wavePeaks; + set + { + _zoomFactor = 1.0; + SelectedParagraph = null; + _buttonDownTimeTicks = 0; + _mouseMoveLastX = -1; + _mouseMoveStartX = -1; + _moveWholeStartDifferenceMilliseconds = -1; + _mouseMoveEndX = -1; + _mouseDown = false; + _mouseDownParagraph = null; + _mouseDownParagraphType = MouseDownParagraphType.Start; + _currentVideoPositionSeconds = -1; + _subtitle = new Subtitle(); + _noClear = false; + _wavePeaks = value; + } + } + + public void SetSpectrogram(SpectrogramData spectrogramData) + { + InitializeSpectrogram(spectrogramData); + } + + public void ClearSelection() + { + _mouseDown = false; + _mouseDownParagraph = null; + _mouseMoveStartX = -1; + _mouseMoveEndX = -1; + Invalidate(); + } + + public AudioVisualizer() + { + AutoScaleMode = AutoScaleMode.Dpi; + Font = UiUtil.GetDefaultFont(); + InitializeComponent(); + UiUtil.FixFonts(this); + + _displayableParagraphs = new List(); + _allSelectedParagraphs = new List(); + + SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); + WaveformNotLoadedText = "Click to add waveform/spectrogram"; + MouseWheel += WaveformMouseWheel; + + BackgroundColor = Color.Black; + Color = Color.GreenYellow; + SelectedColor = Color.Red; + ParagraphColor = Color.LimeGreen; + TextColor = Color.Gray; + TextSize = 9; + TextBold = true; + GridColor = Color.FromArgb(255, 20, 20, 18); + ShowGridLines = true; + AllowNewSelection = true; + ShowSpectrogram = true; + ShowWaveform = true; + InsertAtVideoPositionShortcut = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainWaveformInsertAtCurrentPosition); + } + + protected override bool IsInputKey(Keys keyData) + { + Keys key = keyData & Keys.KeyCode; + + switch (key) + { + case Keys.Up: + case Keys.Down: + case Keys.Right: + case Keys.Left: + return true; + + default: + return base.IsInputKey(keyData); + } + } + + private void LoadParagraphs(Subtitle subtitle, int primarySelectedIndex, ListView.SelectedIndexCollection selectedIndexes) + { + _subtitle.Paragraphs.Clear(); + _displayableParagraphs.Clear(); + SelectedParagraph = null; + _allSelectedParagraphs.Clear(); + + if (_wavePeaks == null) + { + return; + } + + const double additionalSeconds = 15.0; // Helps when scrolling + double startThresholdMilliseconds = (_startPositionSeconds - additionalSeconds) * TimeCode.BaseUnit; + double endThresholdMilliseconds = (EndPositionSeconds + additionalSeconds) * TimeCode.BaseUnit; + + for (int i = 0; i < subtitle.Paragraphs.Count; i++) + { + var p = subtitle.Paragraphs[i]; + + if (p.StartTime.IsMaxTime) + { + continue; + } + + _subtitle.Paragraphs.Add(p); + + if (p.EndTime.TotalMilliseconds >= startThresholdMilliseconds && p.StartTime.TotalMilliseconds <= endThresholdMilliseconds) + { + _displayableParagraphs.Add(p); + } + } + + var primaryParagraph = subtitle.GetParagraphOrDefault(primarySelectedIndex); + if (primaryParagraph != null && !primaryParagraph.StartTime.IsMaxTime) + { + SelectedParagraph = primaryParagraph; + _allSelectedParagraphs.Add(primaryParagraph); + } + foreach (int index in selectedIndexes) + { + var p = subtitle.GetParagraphOrDefault(index); + if (p != null && !p.StartTime.IsMaxTime) + { + _allSelectedParagraphs.Add(p); + } + } + } + + public void SetPosition(double startPositionSeconds, Subtitle subtitle, double currentVideoPositionSeconds, int subtitleIndex, ListView.SelectedIndexCollection selectedIndexes) + { + if (TimeSpan.FromTicks(DateTime.UtcNow.Ticks - _lastMouseWheelScroll).TotalSeconds > 0.25) + { // don't set start position when scrolling with mouse wheel as it will make a bad (jumping back) forward scrolling + StartPositionSeconds = startPositionSeconds; + } + _currentVideoPositionSeconds = currentVideoPositionSeconds; + LoadParagraphs(subtitle, subtitleIndex, selectedIndexes); + Invalidate(); + } + + private class IsSelectedHelper + { + private readonly SelectionRange[] _ranges; + private int _lastPosition = int.MaxValue; + private SelectionRange _nextSelection; + + public IsSelectedHelper(List paragraphs, int sampleRate) + { + var count = paragraphs.Count; + _ranges = new SelectionRange[count]; + for (int index = 0; index < count; index++) + { + var p = paragraphs[index]; + int start = (int)Math.Round(p.StartTime.TotalSeconds * sampleRate); + int end = (int)Math.Round(p.EndTime.TotalSeconds * sampleRate); + _ranges[index] = new SelectionRange(start, end); + } + } + + public bool IsSelected(int position) + { + if (position < _lastPosition || position > _nextSelection.End) + { + FindNextSelection(position); + } + + _lastPosition = position; + + return position >= _nextSelection.Start && position <= _nextSelection.End; + } + + private void FindNextSelection(int position) + { + _nextSelection = new SelectionRange(int.MaxValue, int.MaxValue); + for (int index = 0; index < _ranges.Length; index++) + { + var range = _ranges[index]; + if (range.End >= position && (range.Start < _nextSelection.Start || range.Start == _nextSelection.Start && range.End > _nextSelection.End)) + { + _nextSelection = range; + } + } + } + + private struct SelectionRange + { + public readonly int Start; + public readonly int End; + + public SelectionRange(int start, int end) + { + Start = start; + End = end; + } + } + } + + //private Stopwatch _sw; + //private readonly List _ticks = new List(); + internal void WaveformPaint(object sender, PaintEventArgs e) + { + //_sw = Stopwatch.StartNew(); + Graphics graphics = e.Graphics; + if (_wavePeaks != null) + { + bool showSpectrogram = _showSpectrogram && IsSpectrogramAvailable; + bool showSpectrogramOnly = showSpectrogram && !_showWaveform; + int waveformHeight = Height - (showSpectrogram ? SpectrogramDisplayHeight : 0); + + // background + graphics.Clear(BackgroundColor); + + // grid lines + if (ShowGridLines && !showSpectrogramOnly) + { + DrawGridLines(graphics, waveformHeight); + } + + // spectrogram + if (showSpectrogram) + { + DrawSpectrogram(graphics); + } + + // waveform + if (_showWaveform) + { + using (var penNormal = new Pen(Color)) + using (var penSelected = new Pen(SelectedColor)) // selected paragraph + { + var isSelectedHelper = new IsSelectedHelper(_allSelectedParagraphs, _wavePeaks.SampleRate); + int baseHeight = (int)(_wavePeaks.HighestPeak / _verticalZoomFactor); + int halfWaveformHeight = waveformHeight / 2; + Func calculateY = value => + { + var offset = (value / baseHeight) * halfWaveformHeight; + if (offset > halfWaveformHeight) + { + offset = halfWaveformHeight; + } + + if (offset < -halfWaveformHeight) + { + offset = -halfWaveformHeight; + } + + return (float)(halfWaveformHeight - offset); + }; + var div = _wavePeaks.SampleRate * _zoomFactor; + for (int x = 0; x < Width; x++) + { + var pos = (_startPositionSeconds + x / div) * _wavePeaks.SampleRate; + int pos0 = (int)pos; + int pos1 = pos0; + pos1++; + if (pos1 >= _wavePeaks.Peaks.Count) + { + break; + } + + var pos1Weight = pos - pos0; + var pos0Weight = 1F - pos1Weight; + var peak0 = _wavePeaks.Peaks[pos0]; + var peak1 = _wavePeaks.Peaks[pos1]; + var max = peak0.Max * pos0Weight + peak1.Max * pos1Weight; + var min = peak0.Min * pos0Weight + peak1.Min * pos1Weight; + var yMax = calculateY(max); + var yMin = Math.Max(calculateY(min), yMax + 0.1F); + var pen = isSelectedHelper.IsSelected(pos0) ? penSelected : penNormal; + graphics.DrawLine(pen, x, yMax, x, yMin); + } + } + } + + // time line + if (!showSpectrogramOnly) + { + DrawTimeLine(graphics, waveformHeight); + } + + int currentPositionPos = SecondsToXPosition(_currentVideoPositionSeconds - _startPositionSeconds); + bool currentPosDone = false; + + // paragraphs + var startPositionMilliseconds = _startPositionSeconds * 1000.0; + var endPositionMilliseconds = RelativeXPositionToSeconds(Width) * 1000.0; + var paragraphStartList = new List(); + var paragraphEndList = new List(); + foreach (Paragraph p in _displayableParagraphs) + { + if (p.EndTime.TotalMilliseconds >= startPositionMilliseconds && p.StartTime.TotalMilliseconds <= endPositionMilliseconds) + { + paragraphStartList.Add(SecondsToXPosition(p.StartTime.TotalSeconds - _startPositionSeconds)); + paragraphEndList.Add(SecondsToXPosition(p.EndTime.TotalSeconds - _startPositionSeconds)); + DrawParagraph(p, graphics); + } + } + + // scene changes + if (_sceneChanges != null) + { + try + { + int index = 0; + while (index < _sceneChanges.Count) + { + int pos; + try + { + double time = _sceneChanges[index++]; + pos = SecondsToXPosition(time - _startPositionSeconds); + } + catch + { + pos = -1; + } + if (pos > 0 && pos < Width) + { + if (currentPositionPos == pos) + { // scene change and current pos are the same - draw 2 pixels + current pos dotted + currentPosDone = true; + using (var p = new Pen(Color.AntiqueWhite, 2)) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + + using (var p = new Pen(CursorColor, 2) { DashStyle = DashStyle.Dash }) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + } + else if (paragraphStartList.Contains(pos)) + { // scene change and start pos are the same - draw 2 pixels + current pos dotted + using (var p = new Pen(Color.AntiqueWhite, 2)) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + + using (var p = new Pen(Color.FromArgb(175, 0, 100, 0), 2) { DashStyle = DashStyle.Dash }) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + } + else if (paragraphEndList.Contains(pos)) + { // scene change and end pos are the same - draw 2 pixels + current pos dotted + using (var p = new Pen(Color.AntiqueWhite, 2)) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + + using (var p = new Pen(Color.FromArgb(175, 110, 10, 10), 2) { DashStyle = DashStyle.Dash }) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + } + else + { + using (var p = new Pen(Color.AntiqueWhite)) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + } + } + } + } + catch (Exception) + { + // ignored + } + } + + // chapters + if (_chapters != null) + { + try + { + int index = 0; + while (index < _chapters.Count) + { + int pos; + try + { + double time = _chapters[index].StartTime; + pos = SecondsToXPosition(time - _startPositionSeconds); + } + catch + { + pos = -1; + } + if (pos >= 0 && pos < Width) + { + // draw chapter text + using (var font = new Font(Configuration.Settings.General.SubtitleFontName, TextSize, TextBold ? FontStyle.Bold : FontStyle.Regular)) + using (var brush = new SolidBrush(Color.White)) + { + var name = string.Empty; + var x = pos + 3; + var y = index + 1 < _chapters.Count && _chapters[index].StartTime == _chapters[index + 1].StartTime ? Height / 2 - font.Height - 12 : Height / 2 - 12; + using (var chpaterTextBackBrush = new SolidBrush(ChaptersColor)) + { + name = _chapters[index].Nested ? "+ " + _chapters[index].Name : _chapters[index].Name; + var textSize = graphics.MeasureString(name, font); + graphics.FillRectangle(chpaterTextBackBrush, x, y, textSize.Width + 2, textSize.Height); + } + + x += 2; + graphics.DrawString(name, font, brush, new PointF(x, y)); + } + + // draw chapter line + if (currentPositionPos == pos) + { // chapter and current pos are the same - draw 2 pixels + current pos dotted + currentPosDone = true; + using (var p = new Pen(ChaptersColor, 2)) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + + using (var p = new Pen(CursorColor, 2) { DashStyle = DashStyle.Dash }) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + } + else if (paragraphStartList.Contains(pos)) + { // chapter and start pos are the same - draw 2 pixels + current pos dotted + using (var p = new Pen(ChaptersColor, 2)) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + + using (var p = new Pen(Color.FromArgb(175, 0, 100, 0), 2) { DashStyle = DashStyle.Dash }) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + } + else if (paragraphEndList.Contains(pos)) + { // chapter and end pos are the same - draw 2 pixels + current pos dotted + using (var p = new Pen(ChaptersColor, 2)) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + + using (var p = new Pen(Color.FromArgb(175, 110, 10, 10), 2) { DashStyle = DashStyle.Dash }) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + } + else + { + using (var p = new Pen(ChaptersColor)) + { + graphics.DrawLine(p, pos, 0, pos, Height); + } + } + } + + index++; + } + } + catch (Exception) + { + // ignore + } + } + + // current video position + if (_currentVideoPositionSeconds > 0 && !currentPosDone && currentPositionPos > 0 && currentPositionPos < Width) + { + using (var p = new Pen(CursorColor)) + { + graphics.DrawLine(p, currentPositionPos, 0, currentPositionPos, Height); + } + } + + // current selection + if (NewSelectionParagraph != null) + { + int currentRegionLeft = SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - _startPositionSeconds); + int currentRegionRight = SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - _startPositionSeconds); + int currentRegionWidth = currentRegionRight - currentRegionLeft; + if (currentRegionRight >= 0 && currentRegionLeft <= Width) + { + using (var brush = new SolidBrush(Color.FromArgb(128, 255, 255, 255))) + { + graphics.FillRectangle(brush, currentRegionLeft, 0, currentRegionWidth, graphics.VisibleClipBounds.Height); + } + + if (currentRegionWidth > 40) + { + using (var brush = new SolidBrush(CursorColor)) + { + graphics.DrawString($"{(double)currentRegionWidth / _wavePeaks.SampleRate / _zoomFactor:0.###} {Configuration.Settings.Language.Waveform.Seconds}", Font, brush, new PointF(currentRegionLeft + 3, Height - 32)); + } + } + } + } + } + else + { + graphics.Clear(BackgroundColor); + + if (ShowGridLines) + { + DrawGridLines(graphics, Height); + } + + using (var textBrush = new SolidBrush(TextColor)) + using (var textFont = new Font(Font.FontFamily, 8)) + { + if (Width > 90) + { + graphics.DrawString(WaveformNotLoadedText, textFont, textBrush, new PointF(Width / 2.0f - 65, Height / 2.0f - 10)); + } + else + { + using (var stringFormat = new StringFormat(StringFormatFlags.DirectionVertical)) + { + graphics.DrawString(WaveformNotLoadedText, textFont, textBrush, new PointF(1, 10), stringFormat); + } + } + } + } + if (Focused) + { + using (var p = new Pen(SelectedColor)) + { + graphics.DrawRectangle(p, new Rectangle(0, 0, Width - 1, Height - 1)); + } + } + //_sw.Stop(); + //_ticks.Add(_sw.ElapsedMilliseconds); + //e.Graphics.DrawString("X = " + _ticks.Average().ToString(), Font, new SolidBrush(Color.Cyan), 100, 130); + } + + private void DrawGridLines(Graphics graphics, int imageHeight) + { + if (_wavePeaks == null) + { + using (var pen = new Pen(new SolidBrush(GridColor))) + { + for (int i = 0; i < Width; i += 10) + { + graphics.DrawLine(pen, i, 0, i, imageHeight); + graphics.DrawLine(pen, 0, i, Width, i); + } + } + } + else + { + double seconds = Math.Ceiling(_startPositionSeconds) - _startPositionSeconds - 1; + int xPosition = SecondsToXPosition(seconds); + int yPosition = 0; + double yCounter = 0; + double interval = _zoomFactor >= 0.4 ? + 0.1 : // a pixel is 0.1 second + 1.0; // a pixel is 1.0 second + using (var pen = new Pen(GridColor)) + { + while (xPosition < Width) + { + graphics.DrawLine(pen, xPosition, 0, xPosition, imageHeight); + + seconds += interval; + xPosition = SecondsToXPosition(seconds); + } + + while (yPosition < Height) + { + graphics.DrawLine(pen, 0, yPosition, Width, yPosition); + + yCounter += interval; + yPosition = Convert.ToInt32(yCounter * _wavePeaks.SampleRate * _zoomFactor); + } + } + } + } + + private void DrawTimeLine(Graphics graphics, int imageHeight) + { + double seconds = Math.Ceiling(_startPositionSeconds) - _startPositionSeconds; + int position = SecondsToXPosition(seconds); + using (var pen = new Pen(TextColor)) + using (var textBrush = new SolidBrush(TextColor)) + using (var textFont = new Font(Font.FontFamily, 7)) + { + while (position < Width) + { + var n = _zoomFactor * _wavePeaks.SampleRate; + if (n > 38 || (int)Math.Round(_startPositionSeconds + seconds) % 5 == 0) + { + graphics.DrawLine(pen, position, imageHeight, position, imageHeight - 10); + graphics.DrawString(GetDisplayTime(_startPositionSeconds + seconds), textFont, textBrush, new PointF(position + 2, imageHeight - 13)); + } + + seconds += 0.5; + position = SecondsToXPosition(seconds); + + if (n > 64) + { + graphics.DrawLine(pen, position, imageHeight, position, imageHeight - 5); + } + + seconds += 0.5; + position = SecondsToXPosition(seconds); + } + } + } + + private static string GetDisplayTime(double seconds) + { + var ts = TimeSpan.FromSeconds(seconds + Configuration.Settings.General.CurrentVideoOffsetInMs / TimeCode.BaseUnit); + if (ts.Minutes == 0 && ts.Hours == 0) + { + return ts.Seconds.ToString(CultureInfo.InvariantCulture); + } + + if (ts.Hours == 0) + { + return $"{ts.Minutes:00}:{ts.Seconds:00}"; + } + + return $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}"; + } + + private void DrawParagraph(Paragraph paragraph, Graphics graphics) + { + int currentRegionLeft = SecondsToXPosition(paragraph.StartTime.TotalSeconds - _startPositionSeconds); + int currentRegionRight = SecondsToXPosition(paragraph.EndTime.TotalSeconds - _startPositionSeconds); + int currentRegionWidth = currentRegionRight - currentRegionLeft; + + // background + using (var brush = new SolidBrush(Color.FromArgb(42, 255, 255, 255))) + { + graphics.FillRectangle(brush, currentRegionLeft, 0, currentRegionWidth, graphics.VisibleClipBounds.Height); + } + + // left edge + using (var pen = new Pen(new SolidBrush(Color.FromArgb(175, 0, 100, 0))) { DashStyle = DashStyle.Solid, Width = 2 }) + { + graphics.DrawLine(pen, currentRegionLeft, 0, currentRegionLeft, graphics.VisibleClipBounds.Height); + } + + // right edge + using (var pen = new Pen(new SolidBrush(Color.FromArgb(175, 110, 10, 10))) { DashStyle = DashStyle.Dash, Width = 2 }) + { + graphics.DrawLine(pen, currentRegionRight - 1, 0, currentRegionRight - 1, graphics.VisibleClipBounds.Height); + } + + using (var font = new Font(Configuration.Settings.General.SubtitleFontName, TextSize, TextBold ? FontStyle.Bold : FontStyle.Regular)) + using (var textBrush = new SolidBrush(TextColor)) + using (var outlineBrush = new SolidBrush(Color.Black)) + { + Action drawStringOutlined = (text, x, y) => + { + // poor mans outline + text + graphics.DrawString(text, font, outlineBrush, new PointF(x, y - 1)); + graphics.DrawString(text, font, outlineBrush, new PointF(x, y + 1)); + graphics.DrawString(text, font, outlineBrush, new PointF(x - 1, y)); + graphics.DrawString(text, font, outlineBrush, new PointF(x + 1, y)); + graphics.DrawString(text, font, textBrush, new PointF(x, y)); + }; + + const int padding = 3; + double n = _zoomFactor * _wavePeaks.SampleRate; + + // bookmark text + if (paragraph.Bookmark != null) + { + var x = currentRegionLeft + padding; + var y = Height / 2 + (int)graphics.MeasureString("xx", font).Height / 2 + 2; + + using (var bookmarkBackBrush = new SolidBrush(Color.FromArgb(255, 250, 205))) + { + var textSize = graphics.MeasureString(paragraph.Bookmark, font); + if (textSize.Width < 1) + { + textSize = new SizeF(-2, 18); // empty bookmark text + } + + graphics.FillRectangle(bookmarkBackBrush, x, y, textSize.Width + 20, textSize.Height + 10); + } + + x += 2; + graphics.FillPolygon(textBrush, new[] + { + new Point(x, y + 2), + new Point(x + 14, y + 2), + new Point(x + 14, y + 22 + 2), + new Point(x + 7, y + 14 + 2), + new Point(x, y + 22 + 2), + new Point(x, y + 2), + }); + x += 16; + graphics.DrawString(paragraph.Bookmark, font, textBrush, new PointF(x, y)); + } + + // paragraph text + if (n > 80) + { + string text = HtmlUtil.RemoveHtmlTags(paragraph.Text, true); + if (Configuration.Settings.VideoControls.WaveformUnwrapText) + { + text = text.Replace(Environment.NewLine, " "); + } + + DrawParagraphText(graphics, text, font, currentRegionWidth, padding, drawStringOutlined, currentRegionLeft); + } + + // paragraph number + if (n > 25) + { + string text = "#" + paragraph.Number + " " + paragraph.Duration.ToShortDisplayString(); + if (n <= 51 || graphics.MeasureString(text, font).Width >= currentRegionWidth - padding - 1) + { + text = "#" + paragraph.Number; + } + else if (n > 99) + { + if (Configuration.Settings.VideoControls.WaveformHideWpmCpsLabels) + { + if (Configuration.Settings.VideoControls.WaveformDrawWpm) + { + text = $"{paragraph.WordsPerMinute:0.00}" + Environment.NewLine + text; + } + + if (Configuration.Settings.VideoControls.WaveformDrawCps) + { + text = $"{Utilities.GetCharactersPerSecond(paragraph):0.00}" + Environment.NewLine + text; + } + } + else + { + if (Configuration.Settings.VideoControls.WaveformDrawWpm) + { + text = string.Format(Configuration.Settings.Language.Waveform.WordsMinX, paragraph.WordsPerMinute) + Environment.NewLine + text; + } + + if (Configuration.Settings.VideoControls.WaveformDrawCps) + { + text = string.Format(Configuration.Settings.Language.Waveform.CharsSecX, Utilities.GetCharactersPerSecond(paragraph)) + Environment.NewLine + text; + } + } + } + drawStringOutlined(text, currentRegionLeft + padding, Height - 14 - (int)graphics.MeasureString(text, font).Height); + } + } + } + + private void DrawParagraphText(Graphics graphics, string text, Font font, int currentRegionWidth, int padding, Action drawStringOutlined, int currentRegionLeft) + { + if (Configuration.Settings.General.RightToLeftMode && LanguageAutoDetect.CouldBeRightToLeftLanguage(new Subtitle(_displayableParagraphs))) + { + text = Utilities.ReverseStartAndEndingForRightToLeft(text); + } + + if (text.Length > 500) + { + text = text.Substring(0, 500); // don't now allow very long texts as they can make SE unresponsive - see https://github.com/SubtitleEdit/subtitleedit/issues/2536 + } + + int y = padding; + var max = currentRegionWidth - padding - 1; + foreach (var line in text.SplitToLines()) + { + text = line; + int removeLength = 1; + var measureResult = graphics.MeasureString(text, font); + while (text.Length > removeLength && graphics.MeasureString(text, font).Width > max) + { + text = text.Remove(text.Length - removeLength).TrimEnd() + "…"; + if (text.Length > 200) + { + removeLength = 21; + } + else if (text.Length > 100) + { + removeLength = 11; + } + else + { + removeLength = 2; + } + + measureResult = graphics.MeasureString(text, font); + } + drawStringOutlined(text, currentRegionLeft + padding, y); + y += (int)Math.Round(measureResult.Height, MidpointRounding.AwayFromZero); + } + + } + + private double RelativeXPositionToSeconds(int x) + { + return _startPositionSeconds + (double)x / _wavePeaks.SampleRate / _zoomFactor; + } + + private int SecondsToXPosition(double seconds) + { + return (int)Math.Round(seconds * _wavePeaks.SampleRate * _zoomFactor); + } + + private int SecondsToSampleIndex(double seconds) + { + return (int)Math.Round(seconds * _wavePeaks.SampleRate); + } + + private double SampleIndexToSeconds(int index) + { + return (double)index / _wavePeaks.SampleRate; + } + + private void WaveformMouseDown(object sender, MouseEventArgs e) + { + if (_wavePeaks == null) + { + return; + } + + Paragraph oldMouseDownParagraph = null; + _mouseDownParagraphType = MouseDownParagraphType.None; + _gapAtStart = -1; + _firstMove = true; + if (e.Button == MouseButtons.Left) + { + _buttonDownTimeTicks = DateTime.UtcNow.Ticks; + + Cursor = Cursors.VSplit; + double seconds = RelativeXPositionToSeconds(e.X); + var milliseconds = (int)(seconds * TimeCode.BaseUnit); + + if (SetParagraphBorderHit(milliseconds, NewSelectionParagraph)) + { + if (_mouseDownParagraph != null) + { + oldMouseDownParagraph = new Paragraph(_mouseDownParagraph); + } + + if (_mouseDownParagraphType == MouseDownParagraphType.Start) + { + if (_mouseDownParagraph != null) + { + _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds; + OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); + } + + NewSelectionParagraph.StartTime.TotalMilliseconds = milliseconds; + _mouseMoveStartX = e.X; + _mouseMoveEndX = SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - _startPositionSeconds); + } + else + { + if (_mouseDownParagraph != null) + { + _mouseDownParagraph.EndTime.TotalMilliseconds = milliseconds; + OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); + } + + NewSelectionParagraph.EndTime.TotalMilliseconds = milliseconds; + _mouseMoveStartX = SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - _startPositionSeconds); + _mouseMoveEndX = e.X; + } + SetMinMaxViaSeconds(seconds); + } + else if (SetParagraphBorderHit(milliseconds, SelectedParagraph) || SetParagraphBorderHit(milliseconds, _displayableParagraphs)) + { + NewSelectionParagraph = null; + if (_mouseDownParagraph != null) + { + oldMouseDownParagraph = new Paragraph(_mouseDownParagraph); + int curIdx = _subtitle.Paragraphs.IndexOf(_mouseDownParagraph); + if (_mouseDownParagraphType == MouseDownParagraphType.Start) + { + if (curIdx > 0) + { + var prev = _subtitle.Paragraphs[curIdx - 1]; + if (prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines < milliseconds) + { + _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds; + OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); + } + } + else + { + _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds; + OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); + } + } + else + { + if (curIdx < _subtitle.Paragraphs.Count - 1) + { + var next = _subtitle.Paragraphs[curIdx + 1]; + if (milliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines < next.StartTime.TotalMilliseconds) + { + _mouseDownParagraph.EndTime.TotalMilliseconds = milliseconds; + OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); + } + } + else + { + _mouseDownParagraph.EndTime.TotalMilliseconds = milliseconds; + OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); + } + } + } + SetMinAndMax(); + } + else + { + Paragraph p = GetParagraphAtMilliseconds(milliseconds); + if (p != null) + { + _oldParagraph = new Paragraph(p); + _mouseDownParagraph = p; + oldMouseDownParagraph = new Paragraph(_mouseDownParagraph); + _mouseDownParagraphType = MouseDownParagraphType.Whole; + _moveWholeStartDifferenceMilliseconds = (RelativeXPositionToSeconds(e.X) * TimeCode.BaseUnit) - p.StartTime.TotalMilliseconds; + Cursor = Cursors.Hand; + SetMinAndMax(); + } + else if (!AllowNewSelection) + { + Cursor = Cursors.Default; + } + if (p == null) + { + SetMinMaxViaSeconds(seconds); + } + + NewSelectionParagraph = null; + _mouseMoveStartX = e.X; + _mouseMoveEndX = e.X; + } + if (_mouseDownParagraphType == MouseDownParagraphType.Start) + { + if (_subtitle != null && _mouseDownParagraph != null) + { + int curIdx = _subtitle.Paragraphs.IndexOf(_mouseDownParagraph); + if (curIdx > 0 && oldMouseDownParagraph != null) + { + _gapAtStart = oldMouseDownParagraph.StartTime.TotalMilliseconds - _subtitle.Paragraphs[curIdx - 1].EndTime.TotalMilliseconds; + } + } + } + else if (_mouseDownParagraphType == MouseDownParagraphType.End) + { + if (_subtitle != null && _mouseDownParagraph != null) + { + int curIdx = _subtitle.Paragraphs.IndexOf(_mouseDownParagraph); + if (curIdx >= 0 && curIdx < _subtitle.Paragraphs.Count - 1 && oldMouseDownParagraph != null) + { + _gapAtStart = _subtitle.Paragraphs[curIdx + 1].StartTime.TotalMilliseconds - oldMouseDownParagraph.EndTime.TotalMilliseconds; + } + } + } + _mouseDown = true; + } + else + { + if (e.Button == MouseButtons.Right) + { + double seconds = RelativeXPositionToSeconds(e.X); + var milliseconds = (int)(seconds * TimeCode.BaseUnit); + + if (OnNewSelectionRightClicked != null && NewSelectionParagraph != null) + { + OnNewSelectionRightClicked.Invoke(this, new ParagraphEventArgs(NewSelectionParagraph)); + RightClickedParagraph = null; + _noClear = true; + } + else + { + Paragraph p = GetParagraphAtMilliseconds(milliseconds); + RightClickedParagraph = p; + RightClickedSeconds = seconds; + if (p != null) + { + if (OnParagraphRightClicked != null) + { + NewSelectionParagraph = null; + OnParagraphRightClicked.Invoke(this, new ParagraphEventArgs(seconds, p)); + } + } + else + { + OnNonParagraphRightClicked?.Invoke(this, new ParagraphEventArgs(seconds, null)); + } + } + } + Cursor = Cursors.Default; + } + } + + private void SetMinMaxViaSeconds(double seconds) + { + _wholeParagraphMinMilliseconds = 0; + _wholeParagraphMaxMilliseconds = double.MaxValue; + if (_subtitle != null) + { + Paragraph prev = null; + Paragraph next = null; + var paragraphs = _subtitle.Paragraphs.OrderBy(p => p.StartTime.TotalMilliseconds).ToList(); + for (int i = 0; i < paragraphs.Count; i++) + { + var p2 = paragraphs[i]; + if (p2.StartTime.TotalSeconds < seconds) + { + prev = p2; + } + else if (p2.EndTime.TotalSeconds > seconds) + { + next = p2; + break; + } + } + if (prev != null) + { + _wholeParagraphMinMilliseconds = prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + + if (next != null) + { + _wholeParagraphMaxMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + + private void SetMinAndMax() + { + _wholeParagraphMinMilliseconds = 0; + _wholeParagraphMaxMilliseconds = double.MaxValue; + if (_subtitle != null && _mouseDownParagraph != null) + { + var paragraphs = _subtitle.Paragraphs.OrderBy(p => p.StartTime.TotalMilliseconds).ToList(); + int curIdx = paragraphs.IndexOf(_mouseDownParagraph); + if (curIdx >= 0) + { + if (curIdx > 0) + { + _wholeParagraphMinMilliseconds = paragraphs[curIdx - 1].EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + if (curIdx < _subtitle.Paragraphs.Count - 1) + { + _wholeParagraphMaxMilliseconds = paragraphs[curIdx + 1].StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + } + + private void SetMinAndMaxMoveStart() + { + _wholeParagraphMinMilliseconds = 0; + _wholeParagraphMaxMilliseconds = double.MaxValue; + if (_subtitle != null && _mouseDownParagraph != null) + { + var paragraphs = _subtitle.Paragraphs.OrderBy(p => p.StartTime.TotalMilliseconds).ToList(); + int curIdx = paragraphs.IndexOf(_mouseDownParagraph); + if (curIdx >= 0) + { + var gap = Math.Abs(paragraphs[curIdx - 1].EndTime.TotalMilliseconds - paragraphs[curIdx].StartTime.TotalMilliseconds); + _wholeParagraphMinMilliseconds = paragraphs[curIdx - 1].StartTime.TotalMilliseconds + gap + 200; + } + } + } + + private void SetMinAndMaxMoveEnd() + { + _wholeParagraphMinMilliseconds = 0; + _wholeParagraphMaxMilliseconds = double.MaxValue; + if (_subtitle != null && _mouseDownParagraph != null) + { + var paragraphs = _subtitle.Paragraphs.OrderBy(p => p.StartTime.TotalMilliseconds).ToList(); + int curIdx = paragraphs.IndexOf(_mouseDownParagraph); + if (curIdx >= 0) + { + if (curIdx < _subtitle.Paragraphs.Count - 1) + { + var gap = Math.Abs(paragraphs[curIdx].EndTime.TotalMilliseconds - paragraphs[curIdx + 1].StartTime.TotalMilliseconds); + _wholeParagraphMaxMilliseconds = paragraphs[curIdx + 1].EndTime.TotalMilliseconds - gap - 200; + } + } + } + } + + private bool SetParagraphBorderHit(int milliseconds, List paragraphs) + { + foreach (var p in paragraphs) + { + bool hit = SetParagraphBorderHit(milliseconds, p); + if (hit) + { + return true; + } + } + return false; + } + + private Paragraph GetParagraphAtMilliseconds(int milliseconds) + { + Paragraph p = null; + if (IsParagraphHit(milliseconds, SelectedParagraph)) + { + p = SelectedParagraph; + } + + if (p == null) + { + foreach (var pNext in _displayableParagraphs) + { + if (IsParagraphHit(milliseconds, pNext)) + { + p = pNext; + break; + } + } + } + + return p; + } + + private bool SetParagraphBorderHit(int milliseconds, Paragraph paragraph) + { + if (paragraph == null) + { + return false; + } + + if (IsParagraphBorderStartHit(milliseconds, paragraph.StartTime.TotalMilliseconds)) + { + _oldParagraph = new Paragraph(paragraph); + _mouseDownParagraph = paragraph; + _mouseDownParagraphType = MouseDownParagraphType.Start; + return true; + } + if (IsParagraphBorderEndHit(milliseconds, paragraph.EndTime.TotalMilliseconds)) + { + _oldParagraph = new Paragraph(paragraph); + _mouseDownParagraph = paragraph; + _mouseDownParagraphType = MouseDownParagraphType.End; + return true; + } + return false; + } + + private bool PreventOverlap + { + get + { + if (ModifierKeys == Keys.Shift) + { + return AllowOverlap; + } + + return !AllowOverlap; + } + } + + private bool AllowMovePrevOrNext => _gapAtStart >= 0 && _gapAtStart < 500 && ModifierKeys == Keys.Alt; + + private void WaveformMouseMove(object sender, MouseEventArgs e) + { + if (_wavePeaks == null) + { + return; + } + + int oldMouseMoveLastX = _mouseMoveLastX; + if (e.X < 0 && _startPositionSeconds > 0.1 && _mouseDown) + { + if (e.X < _mouseMoveLastX) + { + StartPositionSeconds -= 0.1; + if (_mouseDownParagraph == null) + { + _mouseMoveEndX = 0; + _mouseMoveStartX += (int)(_wavePeaks.SampleRate * 0.1); + OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_startPositionSeconds, null)); + } + } + _mouseMoveLastX = e.X; + Invalidate(); + return; + } + if (e.X > Width && _startPositionSeconds + 0.1 < _wavePeaks.LengthInSeconds && _mouseDown) + { + StartPositionSeconds += 0.1; + if (_mouseDownParagraph == null) + { + _mouseMoveEndX = Width; + _mouseMoveStartX -= (int)(_wavePeaks.SampleRate * 0.1); + OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_startPositionSeconds, null)); + } + _mouseMoveLastX = e.X; + Invalidate(); + return; + } + _mouseMoveLastX = e.X; + + if (e.X < 0 || e.X > Width) + { + return; + } + + if (e.Button == MouseButtons.None) + { + double seconds = RelativeXPositionToSeconds(e.X); + var milliseconds = (int)(seconds * TimeCode.BaseUnit); + + if (IsParagraphBorderHit(milliseconds, NewSelectionParagraph)) + { + Cursor = Cursors.VSplit; + } + else if (IsParagraphBorderHit(milliseconds, SelectedParagraph) || + IsParagraphBorderHit(milliseconds, _displayableParagraphs)) + { + Cursor = Cursors.VSplit; + } + else + { + Cursor = Cursors.Default; + } + } + else if (e.Button == MouseButtons.Left) + { + if (oldMouseMoveLastX == e.X) + { + return; // no horizontal movement + } + + if (_mouseDown) + { + if (_mouseDownParagraph != null) + { + double seconds = RelativeXPositionToSeconds(e.X); + var milliseconds = (int)(seconds * TimeCode.BaseUnit); + var subtitleIndex = _subtitle.GetIndex(_mouseDownParagraph); + _prevParagraph = _subtitle.GetParagraphOrDefault(subtitleIndex - 1); + _nextParagraph = _subtitle.GetParagraphOrDefault(subtitleIndex + 1); + + if (_firstMove && Math.Abs(oldMouseMoveLastX - e.X) < Configuration.Settings.General.MinimumMillisecondsBetweenLines && GetParagraphAtMilliseconds(milliseconds) == null) + { + if (_mouseDownParagraphType == MouseDownParagraphType.Start && _prevParagraph != null && Math.Abs(_mouseDownParagraph.StartTime.TotalMilliseconds - _prevParagraph.EndTime.TotalMilliseconds) <= ClosenessForBorderSelection + 15) + { + return; // do not decide which paragraph to move yet + } + + if (_mouseDownParagraphType == MouseDownParagraphType.End && _nextParagraph != null && Math.Abs(_mouseDownParagraph.EndTime.TotalMilliseconds - _nextParagraph.StartTime.TotalMilliseconds) <= ClosenessForBorderSelection + 15) + { + return; // do not decide which paragraph to move yet + } + } + + if (ModifierKeys != Keys.Alt) + { + // decide which paragraph to move + if (_firstMove && e.X > oldMouseMoveLastX && _nextParagraph != null && _mouseDownParagraphType == MouseDownParagraphType.End) + { + if (milliseconds >= _nextParagraph.StartTime.TotalMilliseconds && milliseconds < _nextParagraph.EndTime.TotalMilliseconds) + { + _mouseDownParagraph = _nextParagraph; + _mouseDownParagraphType = MouseDownParagraphType.Start; + } + } + else if (_firstMove && e.X < oldMouseMoveLastX && _prevParagraph != null && _mouseDownParagraphType == MouseDownParagraphType.Start) + { + if (milliseconds <= _prevParagraph.EndTime.TotalMilliseconds && milliseconds > _prevParagraph.StartTime.TotalMilliseconds) + { + _mouseDownParagraph = _prevParagraph; + _mouseDownParagraphType = MouseDownParagraphType.End; + } + } + } + _firstMove = false; + + if (_mouseDownParagraphType == MouseDownParagraphType.Start) + { + if (_mouseDownParagraph.EndTime.TotalMilliseconds - milliseconds > MinimumSelectionMilliseconds) + { + if (AllowMovePrevOrNext) + { + SetMinAndMaxMoveStart(); + } + else + { + SetMinAndMax(); + } + + _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds; + + if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && ModifierKeys != Keys.Shift) + { + double nearestSceneChange = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs((x * 1000) - milliseconds) < Math.Abs((y * 1000) - milliseconds) ? x : y) : -9999; + if (Math.Abs(e.X - SecondsToXPosition(nearestSceneChange - _startPositionSeconds)) < SceneChangeSnapPixels) + { + _mouseDownParagraph.StartTime.TotalMilliseconds = nearestSceneChange * 1000; + } + } + + if (PreventOverlap && _mouseDownParagraph.StartTime.TotalMilliseconds <= _wholeParagraphMinMilliseconds) + { + _mouseDownParagraph.StartTime.TotalMilliseconds = _wholeParagraphMinMilliseconds + 1; + } + + if (NewSelectionParagraph != null) + { + NewSelectionParagraph.StartTime.TotalMilliseconds = milliseconds; + + if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && ModifierKeys != Keys.Shift) + { + double nearestSceneChange = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs((x * 1000) - milliseconds) < Math.Abs((y * 1000) - milliseconds) ? x : y) : -9999; + if (Math.Abs(e.X - SecondsToXPosition(nearestSceneChange - _startPositionSeconds)) < SceneChangeSnapPixels) + { + NewSelectionParagraph.StartTime.TotalMilliseconds = nearestSceneChange * 1000; + } + } + + if (PreventOverlap && NewSelectionParagraph.StartTime.TotalMilliseconds <= _wholeParagraphMinMilliseconds) + { + NewSelectionParagraph.StartTime.TotalMilliseconds = _wholeParagraphMinMilliseconds + 1; + } + + _mouseMoveStartX = e.X; + } + else + { + OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); + Refresh(); + return; + } + } + } + else if (_mouseDownParagraphType == MouseDownParagraphType.End) + { + if (milliseconds - _mouseDownParagraph.StartTime.TotalMilliseconds > MinimumSelectionMilliseconds) + { + if (AllowMovePrevOrNext) + { + SetMinAndMaxMoveEnd(); + } + else + { + SetMinAndMax(); + } + + _mouseDownParagraph.EndTime.TotalMilliseconds = milliseconds; + + if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && ModifierKeys != Keys.Shift) + { + double nearestSceneChange = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs((x * 1000) - milliseconds) < Math.Abs((y * 1000) - milliseconds) ? x : y) : -9999; + if (Math.Abs(e.X - SecondsToXPosition(nearestSceneChange - _startPositionSeconds)) < SceneChangeSnapPixels) + { + _mouseDownParagraph.EndTime.TotalMilliseconds = nearestSceneChange * 1000; + } + } + + if (PreventOverlap && _mouseDownParagraph.EndTime.TotalMilliseconds >= _wholeParagraphMaxMilliseconds) + { + _mouseDownParagraph.EndTime.TotalMilliseconds = _wholeParagraphMaxMilliseconds - 1; + } + + if (NewSelectionParagraph != null) + { + NewSelectionParagraph.EndTime.TotalMilliseconds = milliseconds; + + if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && ModifierKeys != Keys.Shift) + { + double nearestSceneChange = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs((x * 1000) - milliseconds) < Math.Abs((y * 1000) - milliseconds) ? x : y) : -9999; + if (Math.Abs(e.X - SecondsToXPosition(nearestSceneChange - _startPositionSeconds)) < SceneChangeSnapPixels) + { + NewSelectionParagraph.EndTime.TotalMilliseconds = nearestSceneChange * 1000; + } + } + + if (PreventOverlap && NewSelectionParagraph.EndTime.TotalMilliseconds >= _wholeParagraphMaxMilliseconds) + { + NewSelectionParagraph.EndTime.TotalMilliseconds = _wholeParagraphMaxMilliseconds - 1; + } + + _mouseMoveEndX = e.X; + } + else + { + OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); + Refresh(); + return; + } + } + } + else if (_mouseDownParagraphType == MouseDownParagraphType.Whole) + { + double durationMilliseconds = _mouseDownParagraph.Duration.TotalMilliseconds; + + var oldStart = _mouseDownParagraph.StartTime.TotalMilliseconds; + _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds - _moveWholeStartDifferenceMilliseconds; + _mouseDownParagraph.EndTime.TotalMilliseconds = _mouseDownParagraph.StartTime.TotalMilliseconds + durationMilliseconds; + + if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && ModifierKeys != Keys.Shift) + { + double nearestSceneChangeInFront = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs((x * 1000) - _mouseDownParagraph.StartTime.TotalMilliseconds) < Math.Abs((y * 1000) - _mouseDownParagraph.StartTime.TotalMilliseconds) ? x : y) : -9999; + double nearestSceneChangeInBack = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs((x * 1000) - _mouseDownParagraph.EndTime.TotalMilliseconds) < Math.Abs((y * 1000) - _mouseDownParagraph.EndTime.TotalMilliseconds) ? x : y) : -9999; + + if (Math.Abs(SecondsToXPosition(_mouseDownParagraph.StartTime.TotalSeconds - _startPositionSeconds) - SecondsToXPosition(nearestSceneChangeInFront - _startPositionSeconds)) < SceneChangeSnapPixels) + { + _mouseDownParagraph.StartTime.TotalMilliseconds = nearestSceneChangeInFront * 1000; + _mouseDownParagraph.EndTime.TotalMilliseconds = (nearestSceneChangeInFront * 1000) + durationMilliseconds; + } + else if (Math.Abs(SecondsToXPosition(_mouseDownParagraph.EndTime.TotalSeconds - _startPositionSeconds) - SecondsToXPosition(nearestSceneChangeInBack - _startPositionSeconds)) < SceneChangeSnapPixels) + { + _mouseDownParagraph.EndTime.TotalMilliseconds = nearestSceneChangeInBack * 1000; + _mouseDownParagraph.StartTime.TotalMilliseconds = (nearestSceneChangeInBack * 1000) - durationMilliseconds; + } + } + + if (PreventOverlap && _mouseDownParagraph.EndTime.TotalMilliseconds >= _wholeParagraphMaxMilliseconds) + { + _mouseDownParagraph.EndTime.TotalMilliseconds = _wholeParagraphMaxMilliseconds - 1; + _mouseDownParagraph.StartTime.TotalMilliseconds = _mouseDownParagraph.EndTime.TotalMilliseconds - durationMilliseconds; + } + else if (PreventOverlap && _mouseDownParagraph.StartTime.TotalMilliseconds <= _wholeParagraphMinMilliseconds) + { + _mouseDownParagraph.StartTime.TotalMilliseconds = _wholeParagraphMinMilliseconds + 1; + _mouseDownParagraph.EndTime.TotalMilliseconds = _mouseDownParagraph.StartTime.TotalMilliseconds + durationMilliseconds; + } + + if (PreventOverlap && + (_mouseDownParagraph.StartTime.TotalMilliseconds <= _wholeParagraphMinMilliseconds || + _mouseDownParagraph.EndTime.TotalMilliseconds >= _wholeParagraphMaxMilliseconds)) + { + _mouseDownParagraph.StartTime.TotalMilliseconds = oldStart; + _mouseDownParagraph.EndTime.TotalMilliseconds = oldStart + durationMilliseconds; + return; + } + + OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType) { AdjustMs = _mouseDownParagraph.StartTime.TotalMilliseconds - oldStart }); + } + } + else + { + _mouseMoveEndX = e.X; + if (NewSelectionParagraph == null && Math.Abs(_mouseMoveEndX - _mouseMoveStartX) > 2) + { + if (AllowNewSelection) + { + NewSelectionParagraph = new Paragraph(); + } + } + + if (NewSelectionParagraph != null) + { + int start = Math.Min(_mouseMoveStartX, _mouseMoveEndX); + int end = Math.Max(_mouseMoveStartX, _mouseMoveEndX); + + var startTotalSeconds = RelativeXPositionToSeconds(start); + var endTotalSeconds = RelativeXPositionToSeconds(end); + + NewSelectionParagraph.StartTime.TotalSeconds = startTotalSeconds; + NewSelectionParagraph.EndTime.TotalSeconds = endTotalSeconds; + + if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && ModifierKeys != Keys.Shift) + { + double nearestSceneChangeInFront = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs(x - startTotalSeconds) < Math.Abs(y - startTotalSeconds) ? x : y) : -9999; + double nearestSceneChangeInBack = _sceneChanges.Count > 0 ? _sceneChanges.Aggregate((x, y) => Math.Abs(x - endTotalSeconds) < Math.Abs(y - endTotalSeconds) ? x : y) : -9999; + + if (Math.Abs(SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - _startPositionSeconds) - SecondsToXPosition(nearestSceneChangeInFront - _startPositionSeconds)) < SceneChangeSnapPixels) + { + NewSelectionParagraph.StartTime.TotalMilliseconds = nearestSceneChangeInFront * 1000; + Invalidate(); + } + if (Math.Abs(SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - _startPositionSeconds) - SecondsToXPosition(nearestSceneChangeInBack - _startPositionSeconds)) < SceneChangeSnapPixels) + { + NewSelectionParagraph.EndTime.TotalMilliseconds = nearestSceneChangeInBack * 1000; + Invalidate(); + } + } + + if (PreventOverlap && endTotalSeconds * TimeCode.BaseUnit >= _wholeParagraphMaxMilliseconds) + { + NewSelectionParagraph.EndTime.TotalMilliseconds = _wholeParagraphMaxMilliseconds - 1; + Invalidate(); + } + if (PreventOverlap && startTotalSeconds * TimeCode.BaseUnit <= _wholeParagraphMinMilliseconds) + { + NewSelectionParagraph.StartTime.TotalMilliseconds = _wholeParagraphMinMilliseconds + 1; + Invalidate(); + } + } + } + Invalidate(); + } + } + } + + private bool IsParagraphBorderHit(int milliseconds, List paragraphs) + { + foreach (Paragraph p in paragraphs) + { + bool hit = IsParagraphBorderHit(milliseconds, p); + if (hit) + { + return true; + } + } + return false; + } + + private bool IsParagraphBorderHit(int milliseconds, Paragraph paragraph) + { + if (paragraph == null) + { + return false; + } + + return IsParagraphBorderStartHit(milliseconds, paragraph.StartTime.TotalMilliseconds) || + IsParagraphBorderEndHit(milliseconds, paragraph.EndTime.TotalMilliseconds); + } + + private bool IsParagraphBorderStartHit(double milliseconds, double startMs) + { + return Math.Abs(milliseconds - (startMs - 5)) - 10 <= ClosenessForBorderSelection; + } + + private bool IsParagraphBorderEndHit(double milliseconds, double endMs) + { + return Math.Abs(milliseconds - (endMs - 22)) - 7 <= ClosenessForBorderSelection; + } + + private void WaveformMouseUp(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (_mouseDown) + { + if (_mouseDownParagraph != null) + { + _mouseDownParagraph = null; + } + else + { + _mouseMoveEndX = e.X; + } + _mouseDown = false; + } + } + Cursor = Cursors.Default; + } + + private void WaveformMouseLeave(object sender, EventArgs e) + { + Cursor = Cursors.Default; + _mouseDown = false; + Invalidate(); + } + + private void WaveformMouseEnter(object sender, EventArgs e) + { + if (_wavePeaks == null) + { + return; + } + + if (_noClear) + { + _noClear = false; + } + else + { + Cursor = Cursors.Default; + _mouseDown = false; + _mouseDownParagraph = null; + _mouseMoveStartX = -1; + _mouseMoveEndX = -1; + Invalidate(); + } + + if (NewSelectionParagraph != null) + { + _mouseMoveStartX = SecondsToXPosition(NewSelectionParagraph.StartTime.TotalSeconds - _startPositionSeconds); + _mouseMoveEndX = SecondsToXPosition(NewSelectionParagraph.EndTime.TotalSeconds - _startPositionSeconds); + } + } + + private void WaveformMouseDoubleClick(object sender, MouseEventArgs e) + { + if (_wavePeaks == null) + { + return; + } + + _mouseDown = false; + _mouseDownParagraph = null; + _mouseMoveStartX = -1; + _mouseMoveEndX = -1; + + if (e.Button == MouseButtons.Left) + { + OnPause?.Invoke(sender, null); + double seconds = RelativeXPositionToSeconds(e.X); + var milliseconds = (int)(seconds * TimeCode.BaseUnit); + + Paragraph p = GetParagraphAtMilliseconds(milliseconds); + if (p != null) + { + seconds = p.StartTime.TotalSeconds; + double endSeconds = p.EndTime.TotalSeconds; + if (seconds < _startPositionSeconds) + { + _startPositionSeconds = (p.StartTime.TotalSeconds) + 0.1; // move earlier - show whole selected paragraph + } + else if (endSeconds > EndPositionSeconds) + { + double newStartPos = _startPositionSeconds + (endSeconds - EndPositionSeconds); // move later, so whole selected paragraph is visible + if (newStartPos < seconds) // but only if visible screen is wide enough + { + _startPositionSeconds = newStartPos; + } + } + } + + OnDoubleClickNonParagraph?.Invoke(this, new ParagraphEventArgs(seconds, p)); + } + } + + private static bool IsParagraphHit(int milliseconds, Paragraph paragraph) + { + if (paragraph == null) + { + return false; + } + + return milliseconds >= paragraph.StartTime.TotalMilliseconds && milliseconds <= paragraph.EndTime.TotalMilliseconds; + } + + private void WaveformMouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left && OnSingleClick != null) + { + int diff = Math.Abs(_mouseMoveStartX - e.X); + if (_mouseMoveStartX == -1 || _mouseMoveEndX == -1 || diff < 10 && TimeSpan.FromTicks(DateTime.UtcNow.Ticks - _buttonDownTimeTicks).TotalSeconds < 0.25) + { + if (ModifierKeys == Keys.Shift && SelectedParagraph != null) + { + double seconds = RelativeXPositionToSeconds(e.X); + var milliseconds = (int)(seconds * TimeCode.BaseUnit); + if (_mouseDownParagraphType == MouseDownParagraphType.None || _mouseDownParagraphType == MouseDownParagraphType.Whole) + { + if (seconds < SelectedParagraph.EndTime.TotalSeconds) + { + _oldParagraph = new Paragraph(SelectedParagraph); + _mouseDownParagraph = SelectedParagraph; + _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds; + OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph)); + } + } + return; + } + if (ModifierKeys == Keys.Control && SelectedParagraph != null) + { + double seconds = RelativeXPositionToSeconds(e.X); + var milliseconds = (int)(seconds * TimeCode.BaseUnit); + if (_mouseDownParagraphType == MouseDownParagraphType.None || _mouseDownParagraphType == MouseDownParagraphType.Whole) + { + if (seconds > SelectedParagraph.StartTime.TotalSeconds) + { + _oldParagraph = new Paragraph(SelectedParagraph); + _mouseDownParagraph = SelectedParagraph; + _mouseDownParagraph.EndTime.TotalMilliseconds = milliseconds; + OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph)); + } + } + return; + } + if (ModifierKeys == (Keys.Control | Keys.Shift) && SelectedParagraph != null) + { + double seconds = RelativeXPositionToSeconds(e.X); + if (_mouseDownParagraphType == MouseDownParagraphType.None || _mouseDownParagraphType == MouseDownParagraphType.Whole) + { + _oldParagraph = new Paragraph(SelectedParagraph); + _mouseDownParagraph = SelectedParagraph; + OnTimeChangedAndOffsetRest?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph)); + } + return; + } + if (ModifierKeys == Keys.Alt && SelectedParagraph != null) + { + double seconds = RelativeXPositionToSeconds(e.X); + var milliseconds = (int)(seconds * TimeCode.BaseUnit); + if (_mouseDownParagraphType == MouseDownParagraphType.None || _mouseDownParagraphType == MouseDownParagraphType.Whole) + { + _oldParagraph = new Paragraph(SelectedParagraph); + _mouseDownParagraph = SelectedParagraph; + double durationMilliseconds = _mouseDownParagraph.Duration.TotalMilliseconds; + _mouseDownParagraph.StartTime.TotalMilliseconds = milliseconds; + _mouseDownParagraph.EndTime.TotalMilliseconds = _mouseDownParagraph.StartTime.TotalMilliseconds + durationMilliseconds; + OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph)); + } + return; + } + + if (_mouseDownParagraphType == MouseDownParagraphType.None || _mouseDownParagraphType == MouseDownParagraphType.Whole) + { + double seconds = RelativeXPositionToSeconds(e.X); + var milliseconds = (int)(seconds * TimeCode.BaseUnit); + Paragraph p = GetParagraphAtMilliseconds(milliseconds); + OnSingleClick.Invoke(this, new ParagraphEventArgs(RelativeXPositionToSeconds(e.X), p)); + } + } + } + } + + private void WaveformKeyDown(object sender, KeyEventArgs e) + { + if (_wavePeaks == null) + { + return; + } + + if (e.Modifiers == Keys.None && e.KeyCode == Keys.Add) + { + ZoomIn(); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Subtract) + { + ZoomOut(); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D0) + { + ZoomFactor = 1.0; + OnZoomedChanged?.Invoke(this, null); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Z) + { + if (_startPositionSeconds > 0.1) + { + StartPositionSeconds -= 0.1; + OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_startPositionSeconds, null)); + Invalidate(); + e.SuppressKeyPress = true; + } + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.X) + { + if (_startPositionSeconds + 0.1 < _wavePeaks.LengthInSeconds) + { + StartPositionSeconds += 0.1; + OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_startPositionSeconds, null)); + Invalidate(); + e.SuppressKeyPress = true; + } + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.C) + { + Locked = !Locked; + Invalidate(); + e.SuppressKeyPress = true; + } + else if (e.KeyData == InsertAtVideoPositionShortcut) + { + if (InsertAtVideoPosition != null) + { + InsertAtVideoPosition.Invoke(this, null); + e.SuppressKeyPress = true; + } + } + else if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control) //Ctrl+v = Paste from clipboard + { + if (PasteAtVideoPosition != null) + { + PasteAtVideoPosition.Invoke(this, null); + e.SuppressKeyPress = true; + } + } + else if (e.KeyData == Move100MsLeft) + { + var pos = Math.Max(0, _currentVideoPositionSeconds - 0.1); + OnPositionSelected?.Invoke(this, new ParagraphEventArgs(pos, null)); + Invalidate(); + e.SuppressKeyPress = true; + } + else if (e.KeyData == Move100MsRight) + { + var pos = _currentVideoPositionSeconds + 0.1; + OnPositionSelected?.Invoke(this, new ParagraphEventArgs(pos, null)); + Invalidate(); + e.SuppressKeyPress = true; + } + else if (e.KeyData == MoveOneSecondLeft) + { + var pos = Math.Max(0, _currentVideoPositionSeconds - 1); + OnPositionSelected?.Invoke(this, new ParagraphEventArgs(pos, null)); + Invalidate(); + e.SuppressKeyPress = true; + } + else if (e.KeyData == MoveOneSecondRight) + { + var pos = _currentVideoPositionSeconds + 1; + OnPositionSelected?.Invoke(this, new ParagraphEventArgs(pos, null)); + Invalidate(); + e.SuppressKeyPress = true; + } + } + + public void ZoomIn() + { + ZoomFactor += 0.1; + OnZoomedChanged?.Invoke(this, null); + } + + public void ZoomOut() + { + ZoomFactor -= 0.1; + OnZoomedChanged?.Invoke(this, null); + } + + private void VerticalZoomIn() + { + VerticalZoomFactor *= 1.1; + } + + private void VerticalZoomOut() + { + VerticalZoomFactor /= 1.1; + } + + private void WaveformMouseWheel(object sender, MouseEventArgs e) + { + // The scroll wheel could work in theory without the waveform loaded (it would be + // just like dragging the slider, which does work without the waveform), but the + // code below doesn't support it, so bail out until someone feels like fixing it. + if (_wavePeaks == null) + { + return; + } + + if (ModifierKeys == Keys.Control) + { + if (e.Delta > 0) + { + ZoomIn(); + } + else + { + ZoomOut(); + } + + return; + } + + if (ModifierKeys == (Keys.Control | Keys.Shift)) + { + if (e.Delta > 0) + { + VerticalZoomIn(); + } + else + { + VerticalZoomOut(); + } + + return; + } + + int delta = e.Delta; + if (!MouseWheelScrollUpIsForward) + { + delta = delta * -1; + } + + if (Locked) + { + OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_currentVideoPositionSeconds + (delta / 256.0), null)); + } + else + { + StartPositionSeconds += delta / 256.0; + _lastMouseWheelScroll = DateTime.UtcNow.Ticks; + if (_currentVideoPositionSeconds < _startPositionSeconds || _currentVideoPositionSeconds >= EndPositionSeconds) + { + OnPositionSelected?.Invoke(this, new ParagraphEventArgs(_startPositionSeconds, null)); + } + } + Invalidate(); + } + + ///////////////////////////////////////////////// + + private void InitializeSpectrogram(SpectrogramData spectrogram) + { + if (_spectrogram != null) + { + _spectrogram.Dispose(); + _spectrogram = null; + Invalidate(); + } + + if (spectrogram == null) + { + return; + } + + if (spectrogram.IsLoaded) + { + InitializeSpectrogramInternal(spectrogram); + } + else + { + Task.Factory.StartNew(() => + { + spectrogram.Load(); + BeginInvoke((Action)(() => + { + InitializeSpectrogramInternal(spectrogram); + })); + }); + } + } + + private void InitializeSpectrogramInternal(SpectrogramData spectrogram) + { + if (_spectrogram != null) + { + return; + } + + _spectrogram = spectrogram; + Invalidate(); + } + + private void DrawSpectrogram(Graphics graphics) + { + int width = (int)Math.Round((EndPositionSeconds - _startPositionSeconds) / _spectrogram.SampleDuration); + using (var bmpCombined = new Bitmap(width, _spectrogram.FftSize / 2)) + using (var gfxCombined = Graphics.FromImage(bmpCombined)) + { + int left = (int)Math.Round(_startPositionSeconds / _spectrogram.SampleDuration); + int offset = 0; + int imageIndex = left / _spectrogram.ImageWidth; + while (offset < width && imageIndex < _spectrogram.Images.Count) + { + int x = (left + offset) % _spectrogram.ImageWidth; + int w = Math.Min(_spectrogram.ImageWidth - x, width - offset); + gfxCombined.DrawImage(_spectrogram.Images[imageIndex], offset, 0, new Rectangle(x, 0, w, bmpCombined.Height), GraphicsUnit.Pixel); + offset += w; + imageIndex++; + } + int displayHeight = _showWaveform ? SpectrogramDisplayHeight : Height; + graphics.DrawImage(bmpCombined, new Rectangle(0, Height - displayHeight, Width, displayHeight)); + } + } + + private double GetAverageVolumeForNextMilliseconds(int sampleIndex, int milliseconds) + { + // length cannot be less than 9 + int length = Math.Max(SecondsToSampleIndex(milliseconds / TimeCode.BaseUnit), 9); + int max = Math.Min(sampleIndex + length, _wavePeaks.Peaks.Count); + int from = Math.Max(sampleIndex, 1); + + if (from >= max) + { + return 0; + } + + double v = 0; + for (int i = from; i < max; i++) + { + v += _wavePeaks.Peaks[i].Abs; + } + + return v / (max - from); + } + + internal void GenerateTimeCodes(Subtitle subtitle, double startFromSeconds, int blockSizeMilliseconds, int minimumVolumePercent, int maximumVolumePercent, int defaultMilliseconds) + { + int begin = SecondsToSampleIndex(startFromSeconds); + + double average = 0; + for (int k = begin; k < _wavePeaks.Peaks.Count; k++) + { + average += _wavePeaks.Peaks[k].Abs; + } + + average /= _wavePeaks.Peaks.Count - begin; + + var maxThreshold = (int)(_wavePeaks.HighestPeak * (maximumVolumePercent / 100.0)); + var silenceThreshold = (int)(average * (minimumVolumePercent / 100.0)); + + int length50Ms = SecondsToSampleIndex(0.050); + double secondsPerParagraph = defaultMilliseconds / TimeCode.BaseUnit; + int minBetween = SecondsToSampleIndex(Configuration.Settings.General.MinimumMillisecondsBetweenLines / TimeCode.BaseUnit); + bool subtitleOn = false; + int i = begin; + while (i < _wavePeaks.Peaks.Count) + { + if (subtitleOn) + { + var currentLengthInSeconds = SampleIndexToSeconds(i - begin); + if (currentLengthInSeconds > 1.0) + { + subtitleOn = EndParagraphDueToLowVolume(subtitle, blockSizeMilliseconds, silenceThreshold, begin, true, i); + if (!subtitleOn) + { + begin = i + minBetween; + i = begin; + } + } + if (subtitleOn && currentLengthInSeconds >= secondsPerParagraph) + { + for (int j = 0; j < 20; j++) + { + subtitleOn = EndParagraphDueToLowVolume(subtitle, blockSizeMilliseconds, silenceThreshold, begin, true, i + (j * length50Ms)); + if (!subtitleOn) + { + i += (j * length50Ms); + begin = i + minBetween; + i = begin; + break; + } + } + + if (subtitleOn) // force break + { + var p = new Paragraph(string.Empty, SampleIndexToSeconds(begin) * TimeCode.BaseUnit, SampleIndexToSeconds(i) * TimeCode.BaseUnit); + subtitle.Paragraphs.Add(p); + begin = i + minBetween; + i = begin; + } + } + } + else + { + double avgVol = GetAverageVolumeForNextMilliseconds(i, blockSizeMilliseconds); + if (avgVol > silenceThreshold && avgVol < maxThreshold) + { + subtitleOn = true; + begin = i; + } + } + i++; + } + + subtitle.Renumber(); + } + + private bool EndParagraphDueToLowVolume(Subtitle subtitle, int blockSizeMilliseconds, double silenceThreshold, int begin, bool subtitleOn, int i) + { + double avgVol = GetAverageVolumeForNextMilliseconds(i, blockSizeMilliseconds); + if (avgVol < silenceThreshold) + { + var p = new Paragraph(string.Empty, SampleIndexToSeconds(begin) * TimeCode.BaseUnit, SampleIndexToSeconds(i) * TimeCode.BaseUnit); + subtitle.Paragraphs.Add(p); + subtitleOn = false; + } + return subtitleOn; + } + + private MinMax GetMinAndMax(int startIndex, int endIndex) + { + int minPeak = int.MaxValue; + int maxPeak = int.MinValue; + double total = 0; + for (int i = startIndex; i < endIndex; i++) + { + var v = _wavePeaks.Peaks[i].Abs; + total += v; + if (v < minPeak) + { + minPeak = v; + } + if (v > maxPeak) + { + maxPeak = v; + } + } + + return new MinMax { Min = minPeak, Max = maxPeak, Avg = total / (endIndex - startIndex) }; + } + + public double FindDataBelowThreshold(double thresholdPercent, double durationInSeconds) + { + int begin = SecondsToSampleIndex(_currentVideoPositionSeconds + 1); + int length = SecondsToSampleIndex(durationInSeconds); + var threshold = thresholdPercent / 100.0 * _wavePeaks.HighestPeak; + + int hitCount = 0; + for (int i = Math.Max(0, begin); i < _wavePeaks.Peaks.Count; i++) + { + if (_wavePeaks.Peaks[i].Abs <= threshold) + { + hitCount++; + } + else + { + hitCount = 0; + } + + if (hitCount > length) + { + double seconds = SampleIndexToSeconds(i - (length / 2)); + if (seconds >= 0) + { + StartPositionSeconds = seconds; + if (_startPositionSeconds > 1) + { + StartPositionSeconds -= 1; + } + + OnSingleClick?.Invoke(this, new ParagraphEventArgs(seconds, null)); + Invalidate(); + } + return seconds; + } + } + return -1; + } + + /// video position in seconds, -1 if not found + public double FindDataBelowThresholdBack(double thresholdPercent, double durationInSeconds) + { + int begin = SecondsToSampleIndex(_currentVideoPositionSeconds - 1); + int length = SecondsToSampleIndex(durationInSeconds); + var threshold = thresholdPercent / 100.0 * _wavePeaks.HighestPeak; + int hitCount = 0; + for (int i = begin; i > 0; i--) + { + if (i > 0 && i < _wavePeaks.Peaks.Count && _wavePeaks.Peaks[i].Abs <= threshold) + { + hitCount++; + if (hitCount > length) + { + double seconds = SampleIndexToSeconds(i + length / 2); + if (seconds >= 0) + { + StartPositionSeconds = seconds; + if (_startPositionSeconds > 1) + { + StartPositionSeconds -= 1; + } + else + { + StartPositionSeconds = 0; + } + + OnSingleClick?.Invoke(this, new ParagraphEventArgs(seconds, null)); + Invalidate(); + } + return seconds; + } + } + else + { + hitCount = 0; + } + } + return -1; + } + + /// + /// Seeks silence in volume + /// + /// video position in seconds, -1 if not found + public double FindDataBelowThresholdBackForStart(double thresholdPercent, double durationInSeconds, double startSeconds) + { + var min = Math.Max(0, SecondsToSampleIndex(startSeconds - 1)); + var maxShort = Math.Min(_wavePeaks.Peaks.Count, SecondsToSampleIndex(startSeconds + durationInSeconds + 0.01)); + var max = Math.Min(_wavePeaks.Peaks.Count, SecondsToSampleIndex(startSeconds + durationInSeconds + 0.8)); + int length = SecondsToSampleIndex(durationInSeconds); + var threshold = thresholdPercent / 100.0 * _wavePeaks.HighestPeak; + + var minMax = GetMinAndMax(min, max); + const int lowPeakDifference = 4_000; + if (minMax.Max - minMax.Min < lowPeakDifference) + { + return -1; // all audio about the same + } + + // look for start silence in the beginning of subtitle + min = SecondsToSampleIndex(startSeconds); + var hitCount = 0; + int index; + for (index = min; index < max; index++) + { + if (index > 0 && index < _wavePeaks.Peaks.Count && _wavePeaks.Peaks[index].Abs <= threshold) + { + hitCount++; + } + else + { + minMax = GetMinAndMax(min, index); + var currentMinMax = GetMinAndMax(SecondsToSampleIndex(startSeconds), SecondsToSampleIndex(startSeconds + 0.8)); + if (currentMinMax.Avg > minMax.Avg + 300 || currentMinMax.Avg < 1000 && minMax.Avg < 1000 && Math.Abs(currentMinMax.Avg - minMax.Avg) < 500) + { + break; + } + hitCount = length / 2; + } + } + if (hitCount > length) + { + minMax = GetMinAndMax(min, index); + var currentMinMax = GetMinAndMax(SecondsToSampleIndex(startSeconds), SecondsToSampleIndex(startSeconds + 0.8)); + if (currentMinMax.Avg > minMax.Avg + 300 || currentMinMax.Avg < 1000 && minMax.Avg < 1000 && Math.Abs(currentMinMax.Avg - minMax.Avg) < 500) + { + return Math.Max(0, SampleIndexToSeconds(index - 1) - 0.01); + } + } + + // move start left? + min = SecondsToSampleIndex(startSeconds - 1); + hitCount = 0; + for (index = maxShort; index > min; index--) + { + if (index > 0 && index < _wavePeaks.Peaks.Count && _wavePeaks.Peaks[index].Abs <= threshold) + { + hitCount++; + if (hitCount > length) + { + return Math.Max(0, SampleIndexToSeconds(index + length) - 0.01); + } + } + else + { + hitCount = 0; + } + } + return -1; + } + + public double FindLowPercentage(double startSeconds, double endSeconds) + { + var min = Math.Max(0, SecondsToSampleIndex(startSeconds)); + var max = Math.Min(_wavePeaks.Peaks.Count, SecondsToSampleIndex(endSeconds)); + var minMax = GetMinAndMax(min, max); + var threshold = minMax.Min * 100.0 / _wavePeaks.HighestPeak; + return threshold; + } + + public double FindHighPercentage(double startSeconds, double endSeconds) + { + var min = Math.Max(0, SecondsToSampleIndex(startSeconds)); + var max = Math.Min(_wavePeaks.Peaks.Count, SecondsToSampleIndex(endSeconds)); + var minMax = GetMinAndMax(min, max); + var threshold = minMax.Max * 100.0 / _wavePeaks.HighestPeak; + return threshold; + } + + public int GetSceneChangeIndex(double seconds) + { + if (SceneChanges == null) + { + return -1; + } + try + { + for (int index = 0; index < SceneChanges.Count; index++) + { + var sceneChange = SceneChanges[index]; + if (Math.Abs(sceneChange - seconds) < 0.04) + { + return index; + } + } + } + catch + { + // ignored + } + + return -1; + } + + } +} diff --git a/src/Controls/AudioVisualizer.resx b/src/ui/Controls/AudioVisualizer.resx similarity index 97% rename from src/Controls/AudioVisualizer.resx rename to src/ui/Controls/AudioVisualizer.resx index 4f24d55cd..8b2ff64a1 100644 --- a/src/Controls/AudioVisualizer.resx +++ b/src/ui/Controls/AudioVisualizer.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Controls/SETextBox.cs b/src/ui/Controls/SETextBox.cs similarity index 97% rename from src/Controls/SETextBox.cs rename to src/ui/Controls/SETextBox.cs index 4271cf83b..fc30a424b 100644 --- a/src/Controls/SETextBox.cs +++ b/src/ui/Controls/SETextBox.cs @@ -1,1090 +1,1090 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Drawing; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Controls -{ - /// - /// TextBox with drag and drop. - /// - public sealed class SETextBox : Panel - { - public new event EventHandler TextChanged; - public new event KeyEventHandler KeyDown; - public new event MouseEventHandler MouseClick; - public new event EventHandler Enter; - public new event KeyEventHandler KeyUp; - public new event EventHandler Leave; - public new event MouseEventHandler MouseMove; - - private string _dragText = string.Empty; - private int _dragStartFrom; - private long _dragStartTicks; - private bool _dragRemoveOld; - private bool _dragFromThis; - private long _gotFocusTicks; - private bool _checkRtfChange = true; - private RichTextBox _richTextBoxTemp; - private RichTextBox _uiTextBox; - private TextBox _textBox; - private int _mouseMoveSelectionLength; - - public SETextBox() - { - Initialize(Configuration.Settings.General.SubtitleTextBoxSyntaxColor); - } - - public void Initialize(bool useSyntaxColoring) - { - ContextMenuStrip oldContextMenuStrip = null; - var oldEnabled = true; - if (_textBox != null) - { - oldContextMenuStrip = _textBox.ContextMenuStrip; - oldEnabled = _textBox.Enabled; - } - else if (_uiTextBox != null) - { - oldContextMenuStrip = _uiTextBox.ContextMenuStrip; - oldEnabled = _uiTextBox.Enabled; - } - - BorderStyle = BorderStyle.None; - Padding = new Padding(1); - BackColor = SystemColors.WindowFrame; - - Controls.Clear(); - _textBox?.Dispose(); - _richTextBoxTemp?.Dispose(); - _uiTextBox?.Dispose(); - if (useSyntaxColoring) - { - _textBox = null; - _richTextBoxTemp = new RichTextBox(); - _uiTextBox = new RichTextBox { BorderStyle = BorderStyle.None, Multiline = true }; - InitializeBackingControl(_uiTextBox); - - // avoid selection when centered and clicking to the left - _uiTextBox.MouseDown += (sender, args) => - { - var charIndex = _uiTextBox.GetCharIndexFromPosition(args.Location); - if (Configuration.Settings.General.CenterSubtitleInTextBox && - _mouseMoveSelectionLength == 0 && - (charIndex == 0 || charIndex >= 0 && _uiTextBox.Text[charIndex - 1] == '\n')) - { - _uiTextBox.SelectionLength = 0; - } - }; - _uiTextBox.MouseMove += (sender, args) => - { - _mouseMoveSelectionLength = _uiTextBox.SelectionLength; - }; - _uiTextBox.KeyDown += (sender, args) => - { - // fix annoying "beeps" when moving cursor position - if ((args.KeyData == Keys.Left || args.KeyData == Keys.PageUp) && _uiTextBox.SelectionStart == 0) - { - args.SuppressKeyPress = true; - } - else if (args.KeyData == Keys.Up && _uiTextBox.SelectionStart <= _uiTextBox.Text.IndexOf('\n')) - { - args.SuppressKeyPress = true; - } - else if (args.KeyData == Keys.Home && (_uiTextBox.SelectionStart == 0 || _uiTextBox.SelectionStart > 0 && _uiTextBox.Text[_uiTextBox.SelectionStart - 1] == '\n')) - { - args.SuppressKeyPress = true; - } - else if (args.KeyData == (Keys.Home | Keys.Control) && _uiTextBox.SelectionStart == 0) - { - args.SuppressKeyPress = true; - } - else if (args.KeyData == Keys.End && (_uiTextBox.SelectionStart >= _uiTextBox.Text.Length || _uiTextBox.SelectionStart + 1 < _uiTextBox.Text.Length && _uiTextBox.Text[_uiTextBox.SelectionStart] == '\n')) - { - args.SuppressKeyPress = true; - } - else if (args.KeyData == (Keys.End | Keys.Control) && _uiTextBox.SelectionStart >= _uiTextBox.Text.Length) - { - args.SuppressKeyPress = true; - } - else if (args.KeyData == Keys.Right && _uiTextBox.SelectionStart >= _uiTextBox.Text.Length) - { - args.SuppressKeyPress = true; - } - else if (args.KeyData == Keys.Down && _uiTextBox.SelectionStart >= _uiTextBox.Text.Length) - { - args.SuppressKeyPress = true; - } - else if (args.KeyData == Keys.PageDown && _uiTextBox.SelectionStart >= _uiTextBox.Text.Length) - { - args.SuppressKeyPress = true; - } - }; - } - else - { - _textBox = new TextBox { BorderStyle = BorderStyle.None, Multiline = true }; - InitializeBackingControl(_textBox); - } - - UpdateFontAndColors(); - if (oldContextMenuStrip != null) - { - ContextMenuStrip = oldContextMenuStrip; - } - - Enabled = oldEnabled; - } - - private void InitializeBackingControl(Control textBox) - { - textBox.AllowDrop = true; - textBox.DragEnter += SETextBox_DragEnter; - textBox.DragDrop += SETextBox_DragDrop; - textBox.GotFocus += (sender, args) => { _gotFocusTicks = DateTime.UtcNow.Ticks; }; - textBox.MouseDown += SETextBox_MouseDown; - textBox.MouseUp += SETextBox_MouseUp; - textBox.TextChanged += TextChangedHighlight; - Controls.Add(textBox); - textBox.Dock = DockStyle.Fill; - textBox.Enter += (sender, args) => { BackColor = SystemColors.Highlight; }; - textBox.Leave += (sender, args) => { BackColor = SystemColors.WindowFrame; }; - textBox.TextChanged += (sender, args) => { TextChanged?.Invoke(sender, args); }; - textBox.KeyDown += (sender, args) => { KeyDown?.Invoke(sender, args); }; - textBox.MouseClick += (sender, args) => { MouseClick?.Invoke(sender, args); }; - textBox.Enter += (sender, args) => { Enter?.Invoke(sender, args); }; - textBox.KeyUp += (sender, args) => { KeyUp?.Invoke(sender, args); }; - textBox.Leave += (sender, args) => { Leave?.Invoke(sender, args); }; - textBox.MouseMove += (sender, args) => { MouseMove?.Invoke(sender, args); }; - } - - private void UpdateFontAndColors() - { - UpdateFontAndColors(_uiTextBox); - UpdateFontAndColors(_richTextBoxTemp); - UpdateFontAndColors(_textBox); - } - - public void UpdateFontAndColors(Control textBox) - { - if (textBox == null) - { - return; - } - - var gs = Configuration.Settings.General; - if (string.IsNullOrEmpty(gs.SubtitleFontName)) - { - gs.SubtitleFontName = Font.Name; - } - - try - { - textBox.Font = gs.SubtitleTextBoxFontBold ? new Font(gs.SubtitleFontName, gs.SubtitleTextBoxFontSize, FontStyle.Bold) : new Font(gs.SubtitleFontName, gs.SubtitleTextBoxFontSize); - textBox.ForeColor = gs.SubtitleFontColor; - textBox.BackColor = gs.SubtitleBackgroundColor; - } - catch - { - // ignore - } - } - - private bool _fixedArabicComma; - public override string Text - { - get - { - if (_textBox != null) - { - return _textBox.Text; - } - - if (_uiTextBox == null) - { - return string.Empty; - } - - var s = _uiTextBox.Text; - if (_fixedArabicComma) - { - s = s.Replace("\u202A", string.Empty); - } - - return string.Join(Environment.NewLine, s.SplitToLines()); - } - set - { - if (_textBox != null) - { - _textBox.Text = value; - return; - } - - if (_uiTextBox == null) - { - return; - } - - _fixedArabicComma = false; - var s = value; - if (!Configuration.Settings.General.RightToLeftMode && !s.Contains('\u202A')) - { - string textNoTags = HtmlUtil.RemoveHtmlTags(s, true); - if (textNoTags.EndsWith('،')) - { - s = s.Replace("،", "\u202A،"); - } - else if (textNoTags.StartsWith('،')) - { - s = s.Replace("،", "،\u202A"); - } - - _fixedArabicComma = true; - } - - _uiTextBox.Text = string.Join("\n", s.SplitToLines()); - } - } - - public int SelectionStart - { - get - { - if (_textBox == null && _uiTextBox == null) - { - return 0; - } - - return _textBox?.SelectionStart ?? _uiTextBox.SelectionStart; - } - set - { - if (_textBox != null) - { - _textBox.SelectionStart = value; - } - else if (_uiTextBox != null) - { - _uiTextBox.SelectionStart = value; - } - } - } - - public int SelectionLength - { - get - { - if (_textBox == null && _uiTextBox == null) - { - return 0; - } - - return _textBox?.SelectionLength ?? _uiTextBox.SelectionLength; - } - set - { - if (_textBox != null) - { - _textBox.SelectionLength = value; - } - else if (_uiTextBox != null) - { - _uiTextBox.SelectionLength = value; - } - } - } - - public bool HideSelection - { - get - { - if (_textBox == null && _uiTextBox == null) - { - return false; - } - - return _textBox?.HideSelection ?? _uiTextBox.HideSelection; - } - set - { - if (_textBox != null) - { - _textBox.HideSelection = value; - } - else if (_uiTextBox != null) - { - _uiTextBox.HideSelection = value; - } - } - } - - public string SelectedText - { - get - { - if (_textBox == null && _uiTextBox == null) - { - return string.Empty; - } - - return _textBox?.SelectedText ?? _uiTextBox.SelectedText; - } - set - { - if (_textBox != null) - { - _textBox.SelectedText = value; - } - else if (_uiTextBox != null) - { - _uiTextBox.SelectedText = value; - } - } - } - - public bool Multiline - { - get - { - if (_textBox == null && _uiTextBox == null) - { - return false; - } - - return _textBox?.Multiline ?? _uiTextBox.Multiline; - } - set - { - if (_textBox != null) - { - _textBox.Multiline = value; - } - else if (_uiTextBox != null) - { - _uiTextBox.Multiline = value; - } - } - } - - public new bool Enabled - { - get - { - if (_textBox == null && _uiTextBox == null) - { - return true; - } - - return _textBox?.Enabled ?? _uiTextBox.Enabled; - } - set - { - if (_textBox != null) - { - _textBox.Enabled = value; - } - else if (_uiTextBox != null) - { - _uiTextBox.Enabled = value; - } - } - } - - public RichTextBoxScrollBars ScrollBars - { - get - { - if (_textBox == null && _uiTextBox == null) - { - return RichTextBoxScrollBars.None; - } - - if (_textBox != null) - { - if (_textBox.ScrollBars == System.Windows.Forms.ScrollBars.Both) - { - return RichTextBoxScrollBars.Both; - } - - if (_textBox.ScrollBars == System.Windows.Forms.ScrollBars.Horizontal) - { - return RichTextBoxScrollBars.Horizontal; - } - - if (_textBox.ScrollBars == System.Windows.Forms.ScrollBars.Vertical) - { - return RichTextBoxScrollBars.Vertical; - } - - return RichTextBoxScrollBars.None; - } - - return _uiTextBox.ScrollBars; - } - set - { - if (_textBox != null) - { - if (value == RichTextBoxScrollBars.Both || value == RichTextBoxScrollBars.ForcedBoth) - { - _textBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; - } - else if (value == RichTextBoxScrollBars.Horizontal || value == RichTextBoxScrollBars.ForcedHorizontal) - { - _textBox.ScrollBars = System.Windows.Forms.ScrollBars.Horizontal; - } - else if (value == RichTextBoxScrollBars.Vertical || value == RichTextBoxScrollBars.ForcedVertical) - { - _textBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - } - - _textBox.ScrollBars = System.Windows.Forms.ScrollBars.None; - } - else if (_uiTextBox != null) - { - _uiTextBox.ScrollBars = value; - } - } - } - - public override ContextMenuStrip ContextMenuStrip - { - get - { - if (_textBox == null && _uiTextBox == null) - { - return null; - } - - return _textBox?.ContextMenuStrip ?? _uiTextBox.ContextMenuStrip; - } - set - { - if (_textBox != null) - { - _textBox.ContextMenuStrip = value; - return; - } - - if (_uiTextBox != null) - { - _uiTextBox.ContextMenuStrip = value; - } - } - } - - public int GetCharIndexFromPosition(Point pt) - { - if (_textBox != null) - { - return _textBox.GetCharIndexFromPosition(pt); - } - - if (_uiTextBox != null) - { - return _uiTextBox.GetCharIndexFromPosition(pt); - } - - return 0; - } - - public void SelectAll() - { - if (_textBox != null) - { - _textBox.SelectAll(); - } - else - { - _uiTextBox?.SelectAll(); - } - } - - public void Clear() - { - if (_textBox != null) - { - _textBox.Clear(); - } - else - { - _uiTextBox?.Clear(); - } - } - - public void Undo() - { - if (_textBox != null) - { - _textBox.Undo(); - } - else - { - _uiTextBox?.Undo(); - } - } - - public void ClearUndo() - { - if (_textBox != null) - { - _textBox.ClearUndo(); - } - else - { - _uiTextBox?.ClearUndo(); - } - } - - public void Copy() - { - if (_textBox != null) - { - _textBox.Copy(); - } - else - { - _uiTextBox?.Copy(); - } - } - - public void Cut() - { - if (_textBox != null) - { - _textBox.Cut(); - } - else - { - _uiTextBox?.Cut(); - } - } - - public void Paste() - { - if (_textBox != null) - { - _textBox.Paste(); - } - else - { - _uiTextBox?.Paste(); - } - } - - public override bool Focused - { - get - { - if (_textBox == null && _uiTextBox == null) - { - return false; - } - - return _textBox?.Focused ?? _uiTextBox.Focused; - } - } - - public new void Focus() - { - if (_textBox != null) - { - _textBox.Focus(); - } - else - { - _uiTextBox?.Focus(); - } - } - - private void SETextBox_MouseUp(object sender, MouseEventArgs e) - { - _dragRemoveOld = false; - _dragFromThis = false; - } - - private void SETextBox_MouseDown(object sender, MouseEventArgs e) - { - if (MouseButtons == MouseButtons.Left && !string.IsNullOrEmpty(_dragText)) - { - var pt = new Point(e.X, e.Y); - int index = GetCharIndexFromPosition(pt); - if (index >= _dragStartFrom && index <= _dragStartFrom + _dragText.Length) - { - // re-make selection - SelectionStart = _dragStartFrom; - SelectionLength = _dragText.Length; - - try - { - var dataObject = new DataObject(); - dataObject.SetText(_dragText, TextDataFormat.UnicodeText); - dataObject.SetText(_dragText, TextDataFormat.Text); - - _dragFromThis = true; - if (ModifierKeys == Keys.Control) - { - _dragRemoveOld = false; - DoDragDrop(dataObject, DragDropEffects.Copy); - } - else if (ModifierKeys == Keys.None) - { - _dragRemoveOld = true; - DoDragDrop(dataObject, DragDropEffects.Move); - } - } - catch - { - // ignored - } - } - } - } - - private void SETextBox_DragDrop(object sender, DragEventArgs e) - { - var pt = PointToClient(new Point(e.X, e.Y)); - int index = GetCharIndexFromPosition(pt); - - string newText; - if (e.Data.GetDataPresent(DataFormats.UnicodeText)) - { - newText = (string)e.Data.GetData(DataFormats.UnicodeText); - } - else - { - newText = (string)e.Data.GetData(DataFormats.Text); - } - - if (string.IsNullOrWhiteSpace(Text)) - { - Text = newText; - } - else - { - bool justAppend = index == Text.Length - 1 && index > 0; - const string expectedChars = ":;]<.!?؟"; - if (_dragFromThis) - { - _dragFromThis = false; - long milliseconds = (DateTime.UtcNow.Ticks - _dragStartTicks) / 10000; - if (milliseconds < 400) - { - SelectionLength = 0; - if (justAppend) - { - index++; - } - - SelectionStart = index; - return; // too fast - nobody can drag and drop this fast - } - - if (index >= _dragStartFrom && index <= _dragStartFrom + _dragText.Length) - { - return; // don't drop same text at same position - } - - if (_dragRemoveOld) - { - _dragRemoveOld = false; - Text = Text.Remove(_dragStartFrom, _dragText.Length); - - // fix spaces - if (_dragStartFrom == 0 && Text.Length > 0 && Text[0] == ' ') - { - Text = Text.Remove(0, 1); - index--; - } - else if (_dragStartFrom > 1 && Text.Length > _dragStartFrom + 1 && Text[_dragStartFrom] == ' ' && Text[_dragStartFrom - 1] == ' ') - { - Text = Text.Remove(_dragStartFrom, 1); - if (_dragStartFrom < index) - { - index--; - } - } - else if (_dragStartFrom > 0 && Text.Length > _dragStartFrom + 1 && Text[_dragStartFrom] == ' ' && expectedChars.Contains(Text[_dragStartFrom + 1])) - { - Text = Text.Remove(_dragStartFrom, 1); - if (_dragStartFrom < index) - { - index--; - } - } - - // fix index - if (index > _dragStartFrom) - { - index -= _dragText.Length; - } - - if (index < 0) - { - index = 0; - } - } - } - if (justAppend) - { - index = Text.Length; - Text += newText; - } - else - { - Text = Text.Insert(index, newText); - } - - // fix start spaces - int endIndex = index + newText.Length; - if (index > 0 && !newText.StartsWith(' ') && Text[index - 1] != ' ') - { - Text = Text.Insert(index, " "); - endIndex++; - } - else if (index > 0 && newText.StartsWith(' ') && Text[index - 1] == ' ') - { - Text = Text.Remove(index, 1); - endIndex--; - } - - // fix end spaces - if (endIndex < Text.Length && !newText.EndsWith(' ') && Text[endIndex] != ' ') - { - bool lastWord = expectedChars.Contains(Text[endIndex]); - if (!lastWord) - { - Text = Text.Insert(endIndex, " "); - } - } - else if (endIndex < Text.Length && newText.EndsWith(' ') && Text[endIndex] == ' ') - { - Text = Text.Remove(endIndex, 1); - } - - SelectionStart = index + 1; - UiUtil.SelectWordAtCaret(this); - } - - _dragRemoveOld = false; - _dragFromThis = false; - } - - private void SETextBox_DragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.Text) || e.Data.GetDataPresent(DataFormats.UnicodeText)) - { - e.Effect = ModifierKeys == Keys.Control ? DragDropEffects.Copy : DragDropEffects.Move; - } - else - { - e.Effect = DragDropEffects.None; - } - } - - private const int WM_LBUTTONDOWN = 0x0201; - protected override void WndProc(ref Message m) - { - if (m.Msg == WM_LBUTTONDOWN) - { - long milliseconds = (DateTime.UtcNow.Ticks - _gotFocusTicks) / 10000; - if (milliseconds > 10) - { - _dragText = SelectedText; - _dragStartFrom = SelectionStart; - _dragStartTicks = DateTime.UtcNow.Ticks; - } - } - base.WndProc(ref m); - } - - public void HighlightHtmlText() - { - if (Configuration.Settings.General.RightToLeftMode) - { - if (RightToLeft != RightToLeft.Yes) - { - RightToLeft = RightToLeft.Yes; - } - } - else - { - if (RightToLeft != RightToLeft.No) - { - RightToLeft = RightToLeft.No; - } - } - - if (_textBox != null) - { - if (Configuration.Settings.General.CenterSubtitleInTextBox && - _textBox.TextAlign != HorizontalAlignment.Center) - { - _textBox.TextAlign = HorizontalAlignment.Center; - } - - return; - } - - _richTextBoxTemp.RightToLeft = RightToLeft; - - - var text = _uiTextBox.Text; - if (string.IsNullOrWhiteSpace(text) || text.Length > 1000) - { - if (Configuration.Settings.General.CenterSubtitleInTextBox) - { - SuspendLayout(); - _richTextBoxTemp.Text = text; - _richTextBoxTemp.SelectAll(); - _richTextBoxTemp.SelectionAlignment = HorizontalAlignment.Center; - - // fix cursor to start in middle (and not left) - _richTextBoxTemp.Rtf = _richTextBoxTemp.Rtf.Replace("\\pard\\par", "\\par"); - - ResumeLayout(false); - _uiTextBox.Rtf = _richTextBoxTemp.Rtf; - } - - return; - } - - _richTextBoxTemp.SuspendLayout(); - _richTextBoxTemp.Clear(); - _richTextBoxTemp.Text = text; - _richTextBoxTemp.SelectAll(); - _richTextBoxTemp.SelectionFont = _richTextBoxTemp.Font; - _richTextBoxTemp.SelectionColor = _richTextBoxTemp.ForeColor; - - bool htmlTagOn = false; - bool htmlTagFontOn = false; - int htmlTagStart = -1; - bool assaTagOn = false; - bool assaPrimaryColorTagOn = false; - bool assaSecondaryColorTagOn = false; - bool assaBorderColorTagOn = false; - bool assaShadowColorTagOn = false; - var assaTagStart = -1; - int tagOn = -1; - var textLength = text.Length; - int i = 0; - - while (i < textLength) - { - var ch = text[i]; - if (assaTagOn) - { - if (ch == '}' && tagOn >= 0) - { - assaTagOn = false; - _richTextBoxTemp.SelectionStart = assaTagStart; - _richTextBoxTemp.SelectionLength = i - assaTagStart + 1; - _richTextBoxTemp.SelectionColor = Configuration.Settings.General.SubtitleTextBoxAssColor; - if (assaTagStart >= 0) - { - if (assaPrimaryColorTagOn) - { - string colorTag = text.IndexOf("\\c", assaTagStart, StringComparison.OrdinalIgnoreCase) != -1 ? "\\c" : "\\1c"; - - SetAssaColor(text, assaTagStart, colorTag); - assaPrimaryColorTagOn = false; - } - - if (assaSecondaryColorTagOn) - { - SetAssaColor(text, assaTagStart, "\\2c"); - assaSecondaryColorTagOn = false; - } - - if (assaBorderColorTagOn) - { - SetAssaColor(text, assaTagStart, "\\3c"); - assaBorderColorTagOn = false; - } - - if (assaShadowColorTagOn) - { - SetAssaColor(text, assaTagStart, "\\4c"); - assaShadowColorTagOn = false; - } - } - - assaTagStart = -1; - } - } - else if (htmlTagOn) - { - if (ch == '>' && tagOn >= 0) - { - htmlTagOn = false; - _richTextBoxTemp.SelectionStart = htmlTagStart; - _richTextBoxTemp.SelectionLength = i - htmlTagStart + 1; - _richTextBoxTemp.SelectionColor = Configuration.Settings.General.SubtitleTextBoxHtmlColor; - if (htmlTagFontOn && htmlTagStart >= 0) - { - SetHtmlColor(text, htmlTagStart); - htmlTagFontOn = false; - } - htmlTagStart = -1; - } - } - else if (ch == '{' && i < textLength - 1 && text[i + 1] == '\\' && text.IndexOf('}', i) > 0) - { - var s = text.Substring(i); - assaTagOn = true; - tagOn = i; - assaTagStart = i; - assaPrimaryColorTagOn = s.Contains("\\c", StringComparison.OrdinalIgnoreCase) || s.Contains("\\1c", StringComparison.OrdinalIgnoreCase); - assaSecondaryColorTagOn = s.Contains("\\2c", StringComparison.OrdinalIgnoreCase); - assaBorderColorTagOn = s.Contains("\\3c", StringComparison.OrdinalIgnoreCase); - assaShadowColorTagOn = s.Contains("\\4c", StringComparison.OrdinalIgnoreCase); - } - else if (ch == '<') - { - var s = text.Substring(i); - if (s.StartsWith("", StringComparison.OrdinalIgnoreCase) || - s.StartsWith("", StringComparison.OrdinalIgnoreCase) || - s.StartsWith("", StringComparison.OrdinalIgnoreCase) || - s.StartsWith("", StringComparison.OrdinalIgnoreCase) || - s.StartsWith("", StringComparison.OrdinalIgnoreCase) || - s.StartsWith("", StringComparison.OrdinalIgnoreCase) || - s.StartsWith("", StringComparison.OrdinalIgnoreCase) || - s.StartsWith("", StringComparison.OrdinalIgnoreCase) || - s.StartsWith("", StringComparison.OrdinalIgnoreCase) || - (s.StartsWith("", i, StringComparison.OrdinalIgnoreCase) > 0)) - { - htmlTagOn = true; - htmlTagStart = i; - htmlTagFontOn = s.StartsWith(" 0) - { - var color = text.Substring(colorStart, colorEnd - colorStart); - try - { - Color c; - if (color.StartsWith("rgb(", StringComparison.Ordinal)) - { - string[] arr = color.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); - } - else - { - c = ColorTranslator.FromHtml(color); - } - - SetForeColorAndChangeBackColorIfClose(colorStart, colorEnd, c); - } - catch - { - // ignored - } - } - } - } - - private void SetForeColorAndChangeBackColorIfClose(int colorStart, int colorEnd, Color c) - { - _richTextBoxTemp.SelectionStart = colorStart; - _richTextBoxTemp.SelectionLength = colorEnd - colorStart; - _richTextBoxTemp.SelectionColor = c; - - var diff = Math.Abs(c.R - BackColor.R) + Math.Abs(c.G - BackColor.G) + Math.Abs(c.B - BackColor.B); - if (diff < 60) - { - _richTextBoxTemp.SelectionBackColor = Color.FromArgb(byte.MaxValue - c.R, byte.MaxValue - c.G, byte.MaxValue - c.B, byte.MaxValue - c.R); - } - } - - private void TextChangedHighlight(object sender, EventArgs e) - { - if (_checkRtfChange) - { - _checkRtfChange = false; - HighlightHtmlText(); - _checkRtfChange = true; - } - } - - private void SetAssaColor(string text, int assaTagStart, string colorTag) - { - int colorStart = text.IndexOf(colorTag, assaTagStart, StringComparison.OrdinalIgnoreCase); - if (colorStart > 0) - { - colorStart += colorTag.Length; - if (text[colorStart] == '&') - { - colorStart++; - } - - int colorEnd = text.IndexOf('&', colorStart + 1); - if (colorEnd > 0) - { - var color = text.Substring(colorStart, colorEnd - colorStart); - try - { - if (color.Length == 7) - { - var rgbColor = string.Concat("#", color[5], color[6], color[3], color[4], color[1], color[2]); - var c = ColorTranslator.FromHtml(rgbColor); - SetForeColorAndChangeBackColorIfClose(colorStart, colorEnd, c); - } - } - catch - { - // ignored - } - } - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Drawing; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Controls +{ + /// + /// TextBox with drag and drop. + /// + public sealed class SETextBox : Panel + { + public new event EventHandler TextChanged; + public new event KeyEventHandler KeyDown; + public new event MouseEventHandler MouseClick; + public new event EventHandler Enter; + public new event KeyEventHandler KeyUp; + public new event EventHandler Leave; + public new event MouseEventHandler MouseMove; + + private string _dragText = string.Empty; + private int _dragStartFrom; + private long _dragStartTicks; + private bool _dragRemoveOld; + private bool _dragFromThis; + private long _gotFocusTicks; + private bool _checkRtfChange = true; + private RichTextBox _richTextBoxTemp; + private RichTextBox _uiTextBox; + private TextBox _textBox; + private int _mouseMoveSelectionLength; + + public SETextBox() + { + Initialize(Configuration.Settings.General.SubtitleTextBoxSyntaxColor); + } + + public void Initialize(bool useSyntaxColoring) + { + ContextMenuStrip oldContextMenuStrip = null; + var oldEnabled = true; + if (_textBox != null) + { + oldContextMenuStrip = _textBox.ContextMenuStrip; + oldEnabled = _textBox.Enabled; + } + else if (_uiTextBox != null) + { + oldContextMenuStrip = _uiTextBox.ContextMenuStrip; + oldEnabled = _uiTextBox.Enabled; + } + + BorderStyle = BorderStyle.None; + Padding = new Padding(1); + BackColor = SystemColors.WindowFrame; + + Controls.Clear(); + _textBox?.Dispose(); + _richTextBoxTemp?.Dispose(); + _uiTextBox?.Dispose(); + if (useSyntaxColoring) + { + _textBox = null; + _richTextBoxTemp = new RichTextBox(); + _uiTextBox = new RichTextBox { BorderStyle = BorderStyle.None, Multiline = true }; + InitializeBackingControl(_uiTextBox); + + // avoid selection when centered and clicking to the left + _uiTextBox.MouseDown += (sender, args) => + { + var charIndex = _uiTextBox.GetCharIndexFromPosition(args.Location); + if (Configuration.Settings.General.CenterSubtitleInTextBox && + _mouseMoveSelectionLength == 0 && + (charIndex == 0 || charIndex >= 0 && _uiTextBox.Text[charIndex - 1] == '\n')) + { + _uiTextBox.SelectionLength = 0; + } + }; + _uiTextBox.MouseMove += (sender, args) => + { + _mouseMoveSelectionLength = _uiTextBox.SelectionLength; + }; + _uiTextBox.KeyDown += (sender, args) => + { + // fix annoying "beeps" when moving cursor position + if ((args.KeyData == Keys.Left || args.KeyData == Keys.PageUp) && _uiTextBox.SelectionStart == 0) + { + args.SuppressKeyPress = true; + } + else if (args.KeyData == Keys.Up && _uiTextBox.SelectionStart <= _uiTextBox.Text.IndexOf('\n')) + { + args.SuppressKeyPress = true; + } + else if (args.KeyData == Keys.Home && (_uiTextBox.SelectionStart == 0 || _uiTextBox.SelectionStart > 0 && _uiTextBox.Text[_uiTextBox.SelectionStart - 1] == '\n')) + { + args.SuppressKeyPress = true; + } + else if (args.KeyData == (Keys.Home | Keys.Control) && _uiTextBox.SelectionStart == 0) + { + args.SuppressKeyPress = true; + } + else if (args.KeyData == Keys.End && (_uiTextBox.SelectionStart >= _uiTextBox.Text.Length || _uiTextBox.SelectionStart + 1 < _uiTextBox.Text.Length && _uiTextBox.Text[_uiTextBox.SelectionStart] == '\n')) + { + args.SuppressKeyPress = true; + } + else if (args.KeyData == (Keys.End | Keys.Control) && _uiTextBox.SelectionStart >= _uiTextBox.Text.Length) + { + args.SuppressKeyPress = true; + } + else if (args.KeyData == Keys.Right && _uiTextBox.SelectionStart >= _uiTextBox.Text.Length) + { + args.SuppressKeyPress = true; + } + else if (args.KeyData == Keys.Down && _uiTextBox.SelectionStart >= _uiTextBox.Text.Length) + { + args.SuppressKeyPress = true; + } + else if (args.KeyData == Keys.PageDown && _uiTextBox.SelectionStart >= _uiTextBox.Text.Length) + { + args.SuppressKeyPress = true; + } + }; + } + else + { + _textBox = new TextBox { BorderStyle = BorderStyle.None, Multiline = true }; + InitializeBackingControl(_textBox); + } + + UpdateFontAndColors(); + if (oldContextMenuStrip != null) + { + ContextMenuStrip = oldContextMenuStrip; + } + + Enabled = oldEnabled; + } + + private void InitializeBackingControl(Control textBox) + { + textBox.AllowDrop = true; + textBox.DragEnter += SETextBox_DragEnter; + textBox.DragDrop += SETextBox_DragDrop; + textBox.GotFocus += (sender, args) => { _gotFocusTicks = DateTime.UtcNow.Ticks; }; + textBox.MouseDown += SETextBox_MouseDown; + textBox.MouseUp += SETextBox_MouseUp; + textBox.TextChanged += TextChangedHighlight; + Controls.Add(textBox); + textBox.Dock = DockStyle.Fill; + textBox.Enter += (sender, args) => { BackColor = SystemColors.Highlight; }; + textBox.Leave += (sender, args) => { BackColor = SystemColors.WindowFrame; }; + textBox.TextChanged += (sender, args) => { TextChanged?.Invoke(sender, args); }; + textBox.KeyDown += (sender, args) => { KeyDown?.Invoke(sender, args); }; + textBox.MouseClick += (sender, args) => { MouseClick?.Invoke(sender, args); }; + textBox.Enter += (sender, args) => { Enter?.Invoke(sender, args); }; + textBox.KeyUp += (sender, args) => { KeyUp?.Invoke(sender, args); }; + textBox.Leave += (sender, args) => { Leave?.Invoke(sender, args); }; + textBox.MouseMove += (sender, args) => { MouseMove?.Invoke(sender, args); }; + } + + private void UpdateFontAndColors() + { + UpdateFontAndColors(_uiTextBox); + UpdateFontAndColors(_richTextBoxTemp); + UpdateFontAndColors(_textBox); + } + + public void UpdateFontAndColors(Control textBox) + { + if (textBox == null) + { + return; + } + + var gs = Configuration.Settings.General; + if (string.IsNullOrEmpty(gs.SubtitleFontName)) + { + gs.SubtitleFontName = Font.Name; + } + + try + { + textBox.Font = gs.SubtitleTextBoxFontBold ? new Font(gs.SubtitleFontName, gs.SubtitleTextBoxFontSize, FontStyle.Bold) : new Font(gs.SubtitleFontName, gs.SubtitleTextBoxFontSize); + textBox.ForeColor = gs.SubtitleFontColor; + textBox.BackColor = gs.SubtitleBackgroundColor; + } + catch + { + // ignore + } + } + + private bool _fixedArabicComma; + public override string Text + { + get + { + if (_textBox != null) + { + return _textBox.Text; + } + + if (_uiTextBox == null) + { + return string.Empty; + } + + var s = _uiTextBox.Text; + if (_fixedArabicComma) + { + s = s.Replace("\u202A", string.Empty); + } + + return string.Join(Environment.NewLine, s.SplitToLines()); + } + set + { + if (_textBox != null) + { + _textBox.Text = value; + return; + } + + if (_uiTextBox == null) + { + return; + } + + _fixedArabicComma = false; + var s = value; + if (!Configuration.Settings.General.RightToLeftMode && !s.Contains('\u202A')) + { + string textNoTags = HtmlUtil.RemoveHtmlTags(s, true); + if (textNoTags.EndsWith('،')) + { + s = s.Replace("،", "\u202A،"); + } + else if (textNoTags.StartsWith('،')) + { + s = s.Replace("،", "،\u202A"); + } + + _fixedArabicComma = true; + } + + _uiTextBox.Text = string.Join("\n", s.SplitToLines()); + } + } + + public int SelectionStart + { + get + { + if (_textBox == null && _uiTextBox == null) + { + return 0; + } + + return _textBox?.SelectionStart ?? _uiTextBox.SelectionStart; + } + set + { + if (_textBox != null) + { + _textBox.SelectionStart = value; + } + else if (_uiTextBox != null) + { + _uiTextBox.SelectionStart = value; + } + } + } + + public int SelectionLength + { + get + { + if (_textBox == null && _uiTextBox == null) + { + return 0; + } + + return _textBox?.SelectionLength ?? _uiTextBox.SelectionLength; + } + set + { + if (_textBox != null) + { + _textBox.SelectionLength = value; + } + else if (_uiTextBox != null) + { + _uiTextBox.SelectionLength = value; + } + } + } + + public bool HideSelection + { + get + { + if (_textBox == null && _uiTextBox == null) + { + return false; + } + + return _textBox?.HideSelection ?? _uiTextBox.HideSelection; + } + set + { + if (_textBox != null) + { + _textBox.HideSelection = value; + } + else if (_uiTextBox != null) + { + _uiTextBox.HideSelection = value; + } + } + } + + public string SelectedText + { + get + { + if (_textBox == null && _uiTextBox == null) + { + return string.Empty; + } + + return _textBox?.SelectedText ?? _uiTextBox.SelectedText; + } + set + { + if (_textBox != null) + { + _textBox.SelectedText = value; + } + else if (_uiTextBox != null) + { + _uiTextBox.SelectedText = value; + } + } + } + + public bool Multiline + { + get + { + if (_textBox == null && _uiTextBox == null) + { + return false; + } + + return _textBox?.Multiline ?? _uiTextBox.Multiline; + } + set + { + if (_textBox != null) + { + _textBox.Multiline = value; + } + else if (_uiTextBox != null) + { + _uiTextBox.Multiline = value; + } + } + } + + public new bool Enabled + { + get + { + if (_textBox == null && _uiTextBox == null) + { + return true; + } + + return _textBox?.Enabled ?? _uiTextBox.Enabled; + } + set + { + if (_textBox != null) + { + _textBox.Enabled = value; + } + else if (_uiTextBox != null) + { + _uiTextBox.Enabled = value; + } + } + } + + public RichTextBoxScrollBars ScrollBars + { + get + { + if (_textBox == null && _uiTextBox == null) + { + return RichTextBoxScrollBars.None; + } + + if (_textBox != null) + { + if (_textBox.ScrollBars == System.Windows.Forms.ScrollBars.Both) + { + return RichTextBoxScrollBars.Both; + } + + if (_textBox.ScrollBars == System.Windows.Forms.ScrollBars.Horizontal) + { + return RichTextBoxScrollBars.Horizontal; + } + + if (_textBox.ScrollBars == System.Windows.Forms.ScrollBars.Vertical) + { + return RichTextBoxScrollBars.Vertical; + } + + return RichTextBoxScrollBars.None; + } + + return _uiTextBox.ScrollBars; + } + set + { + if (_textBox != null) + { + if (value == RichTextBoxScrollBars.Both || value == RichTextBoxScrollBars.ForcedBoth) + { + _textBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; + } + else if (value == RichTextBoxScrollBars.Horizontal || value == RichTextBoxScrollBars.ForcedHorizontal) + { + _textBox.ScrollBars = System.Windows.Forms.ScrollBars.Horizontal; + } + else if (value == RichTextBoxScrollBars.Vertical || value == RichTextBoxScrollBars.ForcedVertical) + { + _textBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + } + + _textBox.ScrollBars = System.Windows.Forms.ScrollBars.None; + } + else if (_uiTextBox != null) + { + _uiTextBox.ScrollBars = value; + } + } + } + + public override ContextMenuStrip ContextMenuStrip + { + get + { + if (_textBox == null && _uiTextBox == null) + { + return null; + } + + return _textBox?.ContextMenuStrip ?? _uiTextBox.ContextMenuStrip; + } + set + { + if (_textBox != null) + { + _textBox.ContextMenuStrip = value; + return; + } + + if (_uiTextBox != null) + { + _uiTextBox.ContextMenuStrip = value; + } + } + } + + public int GetCharIndexFromPosition(Point pt) + { + if (_textBox != null) + { + return _textBox.GetCharIndexFromPosition(pt); + } + + if (_uiTextBox != null) + { + return _uiTextBox.GetCharIndexFromPosition(pt); + } + + return 0; + } + + public void SelectAll() + { + if (_textBox != null) + { + _textBox.SelectAll(); + } + else + { + _uiTextBox?.SelectAll(); + } + } + + public void Clear() + { + if (_textBox != null) + { + _textBox.Clear(); + } + else + { + _uiTextBox?.Clear(); + } + } + + public void Undo() + { + if (_textBox != null) + { + _textBox.Undo(); + } + else + { + _uiTextBox?.Undo(); + } + } + + public void ClearUndo() + { + if (_textBox != null) + { + _textBox.ClearUndo(); + } + else + { + _uiTextBox?.ClearUndo(); + } + } + + public void Copy() + { + if (_textBox != null) + { + _textBox.Copy(); + } + else + { + _uiTextBox?.Copy(); + } + } + + public void Cut() + { + if (_textBox != null) + { + _textBox.Cut(); + } + else + { + _uiTextBox?.Cut(); + } + } + + public void Paste() + { + if (_textBox != null) + { + _textBox.Paste(); + } + else + { + _uiTextBox?.Paste(); + } + } + + public override bool Focused + { + get + { + if (_textBox == null && _uiTextBox == null) + { + return false; + } + + return _textBox?.Focused ?? _uiTextBox.Focused; + } + } + + public new void Focus() + { + if (_textBox != null) + { + _textBox.Focus(); + } + else + { + _uiTextBox?.Focus(); + } + } + + private void SETextBox_MouseUp(object sender, MouseEventArgs e) + { + _dragRemoveOld = false; + _dragFromThis = false; + } + + private void SETextBox_MouseDown(object sender, MouseEventArgs e) + { + if (MouseButtons == MouseButtons.Left && !string.IsNullOrEmpty(_dragText)) + { + var pt = new Point(e.X, e.Y); + int index = GetCharIndexFromPosition(pt); + if (index >= _dragStartFrom && index <= _dragStartFrom + _dragText.Length) + { + // re-make selection + SelectionStart = _dragStartFrom; + SelectionLength = _dragText.Length; + + try + { + var dataObject = new DataObject(); + dataObject.SetText(_dragText, TextDataFormat.UnicodeText); + dataObject.SetText(_dragText, TextDataFormat.Text); + + _dragFromThis = true; + if (ModifierKeys == Keys.Control) + { + _dragRemoveOld = false; + DoDragDrop(dataObject, DragDropEffects.Copy); + } + else if (ModifierKeys == Keys.None) + { + _dragRemoveOld = true; + DoDragDrop(dataObject, DragDropEffects.Move); + } + } + catch + { + // ignored + } + } + } + } + + private void SETextBox_DragDrop(object sender, DragEventArgs e) + { + var pt = PointToClient(new Point(e.X, e.Y)); + int index = GetCharIndexFromPosition(pt); + + string newText; + if (e.Data.GetDataPresent(DataFormats.UnicodeText)) + { + newText = (string)e.Data.GetData(DataFormats.UnicodeText); + } + else + { + newText = (string)e.Data.GetData(DataFormats.Text); + } + + if (string.IsNullOrWhiteSpace(Text)) + { + Text = newText; + } + else + { + bool justAppend = index == Text.Length - 1 && index > 0; + const string expectedChars = ":;]<.!?؟"; + if (_dragFromThis) + { + _dragFromThis = false; + long milliseconds = (DateTime.UtcNow.Ticks - _dragStartTicks) / 10000; + if (milliseconds < 400) + { + SelectionLength = 0; + if (justAppend) + { + index++; + } + + SelectionStart = index; + return; // too fast - nobody can drag and drop this fast + } + + if (index >= _dragStartFrom && index <= _dragStartFrom + _dragText.Length) + { + return; // don't drop same text at same position + } + + if (_dragRemoveOld) + { + _dragRemoveOld = false; + Text = Text.Remove(_dragStartFrom, _dragText.Length); + + // fix spaces + if (_dragStartFrom == 0 && Text.Length > 0 && Text[0] == ' ') + { + Text = Text.Remove(0, 1); + index--; + } + else if (_dragStartFrom > 1 && Text.Length > _dragStartFrom + 1 && Text[_dragStartFrom] == ' ' && Text[_dragStartFrom - 1] == ' ') + { + Text = Text.Remove(_dragStartFrom, 1); + if (_dragStartFrom < index) + { + index--; + } + } + else if (_dragStartFrom > 0 && Text.Length > _dragStartFrom + 1 && Text[_dragStartFrom] == ' ' && expectedChars.Contains(Text[_dragStartFrom + 1])) + { + Text = Text.Remove(_dragStartFrom, 1); + if (_dragStartFrom < index) + { + index--; + } + } + + // fix index + if (index > _dragStartFrom) + { + index -= _dragText.Length; + } + + if (index < 0) + { + index = 0; + } + } + } + if (justAppend) + { + index = Text.Length; + Text += newText; + } + else + { + Text = Text.Insert(index, newText); + } + + // fix start spaces + int endIndex = index + newText.Length; + if (index > 0 && !newText.StartsWith(' ') && Text[index - 1] != ' ') + { + Text = Text.Insert(index, " "); + endIndex++; + } + else if (index > 0 && newText.StartsWith(' ') && Text[index - 1] == ' ') + { + Text = Text.Remove(index, 1); + endIndex--; + } + + // fix end spaces + if (endIndex < Text.Length && !newText.EndsWith(' ') && Text[endIndex] != ' ') + { + bool lastWord = expectedChars.Contains(Text[endIndex]); + if (!lastWord) + { + Text = Text.Insert(endIndex, " "); + } + } + else if (endIndex < Text.Length && newText.EndsWith(' ') && Text[endIndex] == ' ') + { + Text = Text.Remove(endIndex, 1); + } + + SelectionStart = index + 1; + UiUtil.SelectWordAtCaret(this); + } + + _dragRemoveOld = false; + _dragFromThis = false; + } + + private void SETextBox_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.Text) || e.Data.GetDataPresent(DataFormats.UnicodeText)) + { + e.Effect = ModifierKeys == Keys.Control ? DragDropEffects.Copy : DragDropEffects.Move; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private const int WM_LBUTTONDOWN = 0x0201; + protected override void WndProc(ref Message m) + { + if (m.Msg == WM_LBUTTONDOWN) + { + long milliseconds = (DateTime.UtcNow.Ticks - _gotFocusTicks) / 10000; + if (milliseconds > 10) + { + _dragText = SelectedText; + _dragStartFrom = SelectionStart; + _dragStartTicks = DateTime.UtcNow.Ticks; + } + } + base.WndProc(ref m); + } + + public void HighlightHtmlText() + { + if (Configuration.Settings.General.RightToLeftMode) + { + if (RightToLeft != RightToLeft.Yes) + { + RightToLeft = RightToLeft.Yes; + } + } + else + { + if (RightToLeft != RightToLeft.No) + { + RightToLeft = RightToLeft.No; + } + } + + if (_textBox != null) + { + if (Configuration.Settings.General.CenterSubtitleInTextBox && + _textBox.TextAlign != HorizontalAlignment.Center) + { + _textBox.TextAlign = HorizontalAlignment.Center; + } + + return; + } + + _richTextBoxTemp.RightToLeft = RightToLeft; + + + var text = _uiTextBox.Text; + if (string.IsNullOrWhiteSpace(text) || text.Length > 1000) + { + if (Configuration.Settings.General.CenterSubtitleInTextBox) + { + SuspendLayout(); + _richTextBoxTemp.Text = text; + _richTextBoxTemp.SelectAll(); + _richTextBoxTemp.SelectionAlignment = HorizontalAlignment.Center; + + // fix cursor to start in middle (and not left) + _richTextBoxTemp.Rtf = _richTextBoxTemp.Rtf.Replace("\\pard\\par", "\\par"); + + ResumeLayout(false); + _uiTextBox.Rtf = _richTextBoxTemp.Rtf; + } + + return; + } + + _richTextBoxTemp.SuspendLayout(); + _richTextBoxTemp.Clear(); + _richTextBoxTemp.Text = text; + _richTextBoxTemp.SelectAll(); + _richTextBoxTemp.SelectionFont = _richTextBoxTemp.Font; + _richTextBoxTemp.SelectionColor = _richTextBoxTemp.ForeColor; + + bool htmlTagOn = false; + bool htmlTagFontOn = false; + int htmlTagStart = -1; + bool assaTagOn = false; + bool assaPrimaryColorTagOn = false; + bool assaSecondaryColorTagOn = false; + bool assaBorderColorTagOn = false; + bool assaShadowColorTagOn = false; + var assaTagStart = -1; + int tagOn = -1; + var textLength = text.Length; + int i = 0; + + while (i < textLength) + { + var ch = text[i]; + if (assaTagOn) + { + if (ch == '}' && tagOn >= 0) + { + assaTagOn = false; + _richTextBoxTemp.SelectionStart = assaTagStart; + _richTextBoxTemp.SelectionLength = i - assaTagStart + 1; + _richTextBoxTemp.SelectionColor = Configuration.Settings.General.SubtitleTextBoxAssColor; + if (assaTagStart >= 0) + { + if (assaPrimaryColorTagOn) + { + string colorTag = text.IndexOf("\\c", assaTagStart, StringComparison.OrdinalIgnoreCase) != -1 ? "\\c" : "\\1c"; + + SetAssaColor(text, assaTagStart, colorTag); + assaPrimaryColorTagOn = false; + } + + if (assaSecondaryColorTagOn) + { + SetAssaColor(text, assaTagStart, "\\2c"); + assaSecondaryColorTagOn = false; + } + + if (assaBorderColorTagOn) + { + SetAssaColor(text, assaTagStart, "\\3c"); + assaBorderColorTagOn = false; + } + + if (assaShadowColorTagOn) + { + SetAssaColor(text, assaTagStart, "\\4c"); + assaShadowColorTagOn = false; + } + } + + assaTagStart = -1; + } + } + else if (htmlTagOn) + { + if (ch == '>' && tagOn >= 0) + { + htmlTagOn = false; + _richTextBoxTemp.SelectionStart = htmlTagStart; + _richTextBoxTemp.SelectionLength = i - htmlTagStart + 1; + _richTextBoxTemp.SelectionColor = Configuration.Settings.General.SubtitleTextBoxHtmlColor; + if (htmlTagFontOn && htmlTagStart >= 0) + { + SetHtmlColor(text, htmlTagStart); + htmlTagFontOn = false; + } + htmlTagStart = -1; + } + } + else if (ch == '{' && i < textLength - 1 && text[i + 1] == '\\' && text.IndexOf('}', i) > 0) + { + var s = text.Substring(i); + assaTagOn = true; + tagOn = i; + assaTagStart = i; + assaPrimaryColorTagOn = s.Contains("\\c", StringComparison.OrdinalIgnoreCase) || s.Contains("\\1c", StringComparison.OrdinalIgnoreCase); + assaSecondaryColorTagOn = s.Contains("\\2c", StringComparison.OrdinalIgnoreCase); + assaBorderColorTagOn = s.Contains("\\3c", StringComparison.OrdinalIgnoreCase); + assaShadowColorTagOn = s.Contains("\\4c", StringComparison.OrdinalIgnoreCase); + } + else if (ch == '<') + { + var s = text.Substring(i); + if (s.StartsWith("", StringComparison.OrdinalIgnoreCase) || + s.StartsWith("", StringComparison.OrdinalIgnoreCase) || + s.StartsWith("", StringComparison.OrdinalIgnoreCase) || + s.StartsWith("", StringComparison.OrdinalIgnoreCase) || + s.StartsWith("", StringComparison.OrdinalIgnoreCase) || + s.StartsWith("", StringComparison.OrdinalIgnoreCase) || + s.StartsWith("", StringComparison.OrdinalIgnoreCase) || + s.StartsWith("", StringComparison.OrdinalIgnoreCase) || + s.StartsWith("", StringComparison.OrdinalIgnoreCase) || + (s.StartsWith("", i, StringComparison.OrdinalIgnoreCase) > 0)) + { + htmlTagOn = true; + htmlTagStart = i; + htmlTagFontOn = s.StartsWith(" 0) + { + var color = text.Substring(colorStart, colorEnd - colorStart); + try + { + Color c; + if (color.StartsWith("rgb(", StringComparison.Ordinal)) + { + string[] arr = color.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); + } + else + { + c = ColorTranslator.FromHtml(color); + } + + SetForeColorAndChangeBackColorIfClose(colorStart, colorEnd, c); + } + catch + { + // ignored + } + } + } + } + + private void SetForeColorAndChangeBackColorIfClose(int colorStart, int colorEnd, Color c) + { + _richTextBoxTemp.SelectionStart = colorStart; + _richTextBoxTemp.SelectionLength = colorEnd - colorStart; + _richTextBoxTemp.SelectionColor = c; + + var diff = Math.Abs(c.R - BackColor.R) + Math.Abs(c.G - BackColor.G) + Math.Abs(c.B - BackColor.B); + if (diff < 60) + { + _richTextBoxTemp.SelectionBackColor = Color.FromArgb(byte.MaxValue - c.R, byte.MaxValue - c.G, byte.MaxValue - c.B, byte.MaxValue - c.R); + } + } + + private void TextChangedHighlight(object sender, EventArgs e) + { + if (_checkRtfChange) + { + _checkRtfChange = false; + HighlightHtmlText(); + _checkRtfChange = true; + } + } + + private void SetAssaColor(string text, int assaTagStart, string colorTag) + { + int colorStart = text.IndexOf(colorTag, assaTagStart, StringComparison.OrdinalIgnoreCase); + if (colorStart > 0) + { + colorStart += colorTag.Length; + if (text[colorStart] == '&') + { + colorStart++; + } + + int colorEnd = text.IndexOf('&', colorStart + 1); + if (colorEnd > 0) + { + var color = text.Substring(colorStart, colorEnd - colorStart); + try + { + if (color.Length == 7) + { + var rgbColor = string.Concat("#", color[5], color[6], color[3], color[4], color[1], color[2]); + var c = ColorTranslator.FromHtml(rgbColor); + SetForeColorAndChangeBackColorIfClose(colorStart, colorEnd, c); + } + } + catch + { + // ignored + } + } + } + } + } +} diff --git a/src/Controls/SubtitleListView.cs b/src/ui/Controls/SubtitleListView.cs similarity index 97% rename from src/Controls/SubtitleListView.cs rename to src/ui/Controls/SubtitleListView.cs index 7e881ae46..6d9a3d58d 100644 --- a/src/Controls/SubtitleListView.cs +++ b/src/ui/Controls/SubtitleListView.cs @@ -1,2077 +1,2077 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Controls -{ - public sealed class SubtitleListView : ListView - { - public enum SubtitleColumn - { - Number, - Start, - End, - Duration, - CharactersPerSeconds, - WordsPerMinute, - Gap, - Actor, - Region, - Text, - TextAlternate, - Extra, - Network - } - - private List SubtitleColumns { get; } - - public int GetColumnIndex(SubtitleColumn column) - { - return SubtitleColumns.IndexOf(column); - } - - public int ColumnIndexNumber { get; private set; } - public int ColumnIndexStart { get; private set; } - public int ColumnIndexEnd { get; private set; } - public int ColumnIndexDuration { get; private set; } - public int ColumnIndexWpm { get; private set; } - public int ColumnIndexCps { get; private set; } - public int ColumnIndexGap { get; private set; } - public int ColumnIndexActor { get; private set; } - public int ColumnIndexRegion { get; private set; } - public int ColumnIndexText { get; private set; } - public int ColumnIndexTextAlternate { get; private set; } - public int ColumnIndexExtra { get; private set; } - public int ColumnIndexNetwork { get; private set; } - - public bool IsAlternateTextColumnVisible => ColumnIndexTextAlternate >= 0; - private string _lineSeparatorString = " || "; - - private Font _subtitleFont = new Font("Tahoma", 8.25F); - - private string _subtitleFontName = "Tahoma"; - - public override bool RightToLeftLayout - { - get => base.RightToLeftLayout; - set - { - var hzAlignment = value ? HorizontalAlignment.Left : HorizontalAlignment.Right; - if (ColumnIndexCps >= 0) - { - Columns[ColumnIndexCps].TextAlign = hzAlignment; - } - - if (ColumnIndexWpm >= 0) - { - Columns[ColumnIndexWpm].TextAlign = hzAlignment; - } - - base.RightToLeftLayout = value; - } - } - - public string SubtitleFontName - { - get => _subtitleFontName; - set - { - _subtitleFontName = value; - _subtitleFont = new Font(_subtitleFontName, SubtitleFontSize, GetFontStyle()); - } - } - - private bool _subtitleFontBold; - - public bool SubtitleFontBold - { - get { return _subtitleFontBold; } - set - { - _subtitleFontBold = value; - _subtitleFont = new Font(_subtitleFontName, SubtitleFontSize, GetFontStyle()); - } - } - - private int _subtitleFontSize = 8; - - public int SubtitleFontSize - { - get => _subtitleFontSize; - set - { - _subtitleFontSize = value; - _subtitleFont = new Font(_subtitleFontName, SubtitleFontSize, GetFontStyle()); - } - } - - public bool UseSyntaxColoring { get; set; } - private Settings _settings; - private bool _saveColumnWidthChanges; - - public int FirstVisibleIndex { get; set; } = -1; - - public void InitializeLanguage(LanguageStructure.General general, Settings settings) - { - int idx = GetColumnIndex(SubtitleColumn.Number); - if (idx >= 0) - { - Columns[idx].Text = general.NumberSymbol; - } - - idx = GetColumnIndex(SubtitleColumn.Start); - if (idx >= 0) - { - Columns[idx].Text = general.StartTime; - } - - idx = GetColumnIndex(SubtitleColumn.End); - if (idx >= 0) - { - Columns[idx].Text = general.EndTime; - } - - idx = GetColumnIndex(SubtitleColumn.Duration); - if (idx >= 0) - { - Columns[idx].Text = general.Duration; - } - - idx = GetColumnIndex(SubtitleColumn.CharactersPerSeconds); - if (idx >= 0) - { - Columns[idx].Text = general.CharsPerSec; - } - - idx = GetColumnIndex(SubtitleColumn.WordsPerMinute); - if (idx >= 0) - { - Columns[idx].Text = general.WordsPerMin; - } - - idx = GetColumnIndex(SubtitleColumn.Gap); - if (idx >= 0) - { - Columns[idx].Text = general.Gap; - } - - idx = GetColumnIndex(SubtitleColumn.Actor); - if (idx >= 0) - { - Columns[idx].Text = general.Actor; - } - - idx = GetColumnIndex(SubtitleColumn.Region); - if (idx >= 0) - { - Columns[idx].Text = general.Region; - } - - idx = GetColumnIndex(SubtitleColumn.Text); - if (idx >= 0) - { - Columns[idx].Text = general.Text; - } - - if (settings.General.ListViewLineSeparatorString != null) - { - _lineSeparatorString = settings.General.ListViewLineSeparatorString; - } - - if (!string.IsNullOrEmpty(settings.General.SubtitleFontName)) - { - _subtitleFontName = settings.General.SubtitleFontName; - } - - SubtitleFontBold = settings.General.SubtitleListViewFontBold; - if (settings.General.SubtitleListViewFontSize > 6 && settings.General.SubtitleListViewFontSize < 72) - { - SubtitleFontSize = settings.General.SubtitleListViewFontSize; - } - - ForeColor = settings.General.SubtitleFontColor; - BackColor = settings.General.SubtitleBackgroundColor; - _settings = settings; - } - - public void InitializeTimestampColumnWidths(Control parentForm) - { - if (_settings != null && _settings.General.ListViewColumnsRememberSize && _settings.General.ListViewNumberWidth > 1 && - _settings.General.ListViewStartWidth > 1 && _settings.General.ListViewEndWidth > 1 && _settings.General.ListViewDurationWidth > 1) - { - int idx = GetColumnIndex(SubtitleColumn.Number); - if (idx >= 0) - { - Columns[idx].Width = Configuration.Settings.General.ListViewNumberWidth; - } - - idx = GetColumnIndex(SubtitleColumn.Start); - if (idx >= 0) - { - Columns[idx].Width = _settings.General.ListViewStartWidth; - } - - idx = GetColumnIndex(SubtitleColumn.End); - if (idx >= 0) - { - Columns[idx].Width = _settings.General.ListViewEndWidth; - } - - idx = GetColumnIndex(SubtitleColumn.Duration); - if (idx >= 0) - { - Columns[idx].Width = _settings.General.ListViewDurationWidth; - } - - idx = GetColumnIndex(SubtitleColumn.CharactersPerSeconds); - if (idx >= 0) - { - Columns[idx].Width = _settings.General.ListViewCpsWidth; - } - - idx = GetColumnIndex(SubtitleColumn.WordsPerMinute); - if (idx >= 0) - { - Columns[idx].Width = _settings.General.ListViewWpmWidth; - } - - idx = GetColumnIndex(SubtitleColumn.Gap); - if (idx >= 0) - { - Columns[idx].Width = _settings.General.ListViewGapWidth; - } - - idx = GetColumnIndex(SubtitleColumn.Actor); - if (idx >= 0) - { - Columns[idx].Width = _settings.General.ListViewActorWidth; - } - - idx = GetColumnIndex(SubtitleColumn.Region); - if (idx >= 0) - { - Columns[idx].Width = _settings.General.ListViewRegionWidth; - } - - idx = GetColumnIndex(SubtitleColumn.Text); - if (idx >= 0) - { - Columns[idx].Width = _settings.General.ListViewTextWidth; - } - - _saveColumnWidthChanges = true; - } - else if (parentForm != null) - { - using (var graphics = parentForm.CreateGraphics()) - { - var timestampSizeF = graphics.MeasureString(new TimeCode(0, 0, 33, 527).ToDisplayString(), Font); - var timestampWidth = (int)(timestampSizeF.Width + 0.5) + 11; - - var idx = GetColumnIndex(SubtitleColumn.Start); - if (idx >= 0) - { - Columns[idx].Width = timestampWidth; - } - - idx = GetColumnIndex(SubtitleColumn.End); - if (idx >= 0) - { - Columns[idx].Width = timestampWidth; - } - - idx = GetColumnIndex(SubtitleColumn.Duration); - if (idx >= 0) - { - Columns[idx].Width = (int)(timestampWidth * 0.8); - } - } - } - - SubtitleListViewLastColumnFill(this, null); - } - - public SubtitleListView() - { - DoubleBuffered = true; - UseSyntaxColoring = true; - Font = new Font("Tahoma", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - AllowColumnReorder = true; - HeaderStyle = ColumnHeaderStyle.Nonclickable; - - ColumnIndexNumber = -1; - ColumnIndexStart = -1; - ColumnIndexEnd = -1; - ColumnIndexDuration = -1; - ColumnIndexWpm = -1; - ColumnIndexCps = -1; - ColumnIndexGap = -1; - ColumnIndexActor = -1; - ColumnIndexRegion = -1; - ColumnIndexText = -1; - ColumnIndexTextAlternate = -1; - ColumnIndexExtra = -1; - ColumnIndexNetwork = -1; - - SubtitleColumns = new List - { - SubtitleColumn.Number, - SubtitleColumn.Start, - SubtitleColumn.End, - SubtitleColumn.Duration, - SubtitleColumn.Text - }; - UpdateColumnIndexes(); - - foreach (var c in SubtitleColumns) - { - switch (c) - { - case SubtitleColumn.Number: - Columns.Add(new ColumnHeader { Width = 50 }); - break; - case SubtitleColumn.Start: - Columns.Add(new ColumnHeader { Width = 80 }); - break; - case SubtitleColumn.End: - Columns.Add(new ColumnHeader { Width = 80 }); - break; - case SubtitleColumn.Duration: - Columns.Add(new ColumnHeader { Width = 55 }); - break; - case SubtitleColumn.CharactersPerSeconds: - Columns.Add(new ColumnHeader { Width = 60 }); - break; - case SubtitleColumn.WordsPerMinute: - Columns.Add(new ColumnHeader { Width = 65 }); - break; - case SubtitleColumn.Gap: - Columns.Add(new ColumnHeader { Width = 60 }); - break; - case SubtitleColumn.Actor: - Columns.Add(new ColumnHeader { Width = 80 }); - break; - case SubtitleColumn.Region: - Columns.Add(new ColumnHeader { Width = 60 }); - break; - case SubtitleColumn.Text: - Columns.Add(new ColumnHeader { Width = 300 }); - break; - } - } - - if (Configuration.Settings != null && !Configuration.Settings.Tools.ListViewShowColumnEndTime) - { - HideColumn(SubtitleColumn.End); - } - - if (Configuration.Settings != null && !Configuration.Settings.Tools.ListViewShowColumnDuration) - { - HideColumn(SubtitleColumn.Duration); - } - - if (Configuration.Settings != null && Configuration.Settings.Tools.ListViewShowColumnCharsPerSec) - { - ShowCharsSecColumn(Configuration.Settings.Language.General.CharsPerSec); - } - - if (Configuration.Settings != null && Configuration.Settings.Tools.ListViewShowColumnWordsPerMin) - { - ShowWordsMinColumn(Configuration.Settings.Language.General.WordsPerMin); - } - - if (Configuration.Settings != null && Configuration.Settings.Tools.ListViewShowColumnGap) - { - ShowGapColumn(Configuration.Settings.Language.General.Gap); - } - - SubtitleListViewLastColumnFill(this, null); - - FullRowSelect = true; - View = View.Details; - Resize += SubtitleListViewLastColumnFill; - GridLines = true; - ColumnWidthChanged += SubtitleListViewColumnWidthChanged; - OwnerDraw = true; - DrawItem += SubtitleListView_DrawItem; - DrawSubItem += SubtitleListView_DrawSubItem; - DrawColumnHeader += SubtitleListView_DrawColumnHeader; - } - - private void UpdateColumnIndexes() - { - ColumnIndexNumber = GetColumnIndex(SubtitleColumn.Number); - ColumnIndexStart = GetColumnIndex(SubtitleColumn.Start); - ColumnIndexEnd = GetColumnIndex(SubtitleColumn.End); - ColumnIndexDuration = GetColumnIndex(SubtitleColumn.Duration); - ColumnIndexCps = GetColumnIndex(SubtitleColumn.CharactersPerSeconds); - ColumnIndexWpm = GetColumnIndex(SubtitleColumn.WordsPerMinute); - ColumnIndexGap = GetColumnIndex(SubtitleColumn.Gap); - ColumnIndexActor = GetColumnIndex(SubtitleColumn.Actor); - ColumnIndexRegion = GetColumnIndex(SubtitleColumn.Region); - ColumnIndexText = GetColumnIndex(SubtitleColumn.Text); - ColumnIndexTextAlternate = GetColumnIndex(SubtitleColumn.TextAlternate); - ColumnIndexExtra = GetColumnIndex(SubtitleColumn.Extra); - ColumnIndexNetwork = GetColumnIndex(SubtitleColumn.Network); - } - - private void SubtitleListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) - { - e.DrawDefault = true; - } - - private void SubtitleListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) - { - Color backgroundColor = Items[e.ItemIndex].SubItems[e.ColumnIndex].BackColor; - if (Focused && backgroundColor == BackColor || RightToLeftLayout) - { - e.DrawDefault = true; - return; - } - - using (var sf = new StringFormat()) - { - switch (e.Header.TextAlign) - { - case HorizontalAlignment.Center: - sf.Alignment = StringAlignment.Center; - break; - case HorizontalAlignment.Right: - sf.Alignment = StringAlignment.Far; - break; - } - - if (e.Item.Selected) - { - - Rectangle rect = e.Bounds; - if (Configuration.Settings != null) - { - backgroundColor = backgroundColor == BackColor ? Configuration.Settings.Tools.ListViewUnfocusedSelectedColor : GetCustomColor(backgroundColor); - var sb = new SolidBrush(backgroundColor); - e.Graphics.FillRectangle(sb, rect); - } - else - { - e.Graphics.FillRectangle(Brushes.LightBlue, rect); - } - - int addX = 0; - - if (e.ColumnIndex == 0 && StateImageList?.Images.Count > 0) - { - addX = 18; - } - - if (e.ColumnIndex == 0 && e.Item.StateImageIndex >= 0 && StateImageList?.Images.Count > e.Item.StateImageIndex) - { - e.Graphics.DrawImage(StateImageList.Images[e.Item.StateImageIndex], new Rectangle(rect.X + 4, rect.Y + 2, 16, 16)); - } - - if (Columns[e.ColumnIndex].TextAlign == HorizontalAlignment.Right) - { - var stringWidth = (int)e.Graphics.MeasureString(e.Item.SubItems[e.ColumnIndex].Text, _subtitleFont).Width; - TextRenderer.DrawText(e.Graphics, e.Item.SubItems[e.ColumnIndex].Text, _subtitleFont, new Point(e.Bounds.Right - stringWidth - 7, e.Bounds.Top + 2), e.Item.ForeColor, TextFormatFlags.NoPrefix); - } - else - { - TextRenderer.DrawText(e.Graphics, e.Item.SubItems[e.ColumnIndex].Text, _subtitleFont, new Point(e.Bounds.Left + 3 + addX, e.Bounds.Top + 2), e.Item.ForeColor, TextFormatFlags.NoPrefix); - } - } - else - { - e.DrawDefault = true; - } - } - } - - private static Color GetCustomColor(Color color) - { - int r = Math.Max(color.R - 39, 0); - int g = Math.Max(color.G - 39, 0); - int b = Math.Max(color.B - 39, 0); - return Color.FromArgb(color.A, r, g, b); - } - - private void SubtitleListView_DrawItem(object sender, DrawListViewItemEventArgs e) - { - if (!Focused && (e.State & ListViewItemStates.Selected) != 0) - { - if (e.Item.Focused) - { - e.DrawFocusRectangle(); - } - } - else - { - e.DrawDefault = true; - } - } - - private void SubtitleListViewColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e) - { - if (_settings != null && _saveColumnWidthChanges) - { - if (e.ColumnIndex == ColumnIndexNumber) - { - Configuration.Settings.General.ListViewNumberWidth = Columns[ColumnIndexNumber].Width; - } - else if (e.ColumnIndex == ColumnIndexStart) - { - Configuration.Settings.General.ListViewStartWidth = Columns[ColumnIndexStart].Width; - } - else if (e.ColumnIndex == ColumnIndexEnd) - { - Configuration.Settings.General.ListViewEndWidth = Columns[ColumnIndexEnd].Width; - } - else if (e.ColumnIndex == ColumnIndexDuration) - { - Configuration.Settings.General.ListViewDurationWidth = Columns[ColumnIndexDuration].Width; - } - else if (e.ColumnIndex == ColumnIndexCps) - { - Configuration.Settings.General.ListViewCpsWidth = Columns[ColumnIndexCps].Width; - } - else if (e.ColumnIndex == ColumnIndexWpm) - { - Configuration.Settings.General.ListViewWpmWidth = Columns[ColumnIndexWpm].Width; - } - else if (e.ColumnIndex == ColumnIndexGap) - { - Configuration.Settings.General.ListViewGapWidth = Columns[ColumnIndexGap].Width; - } - else if (e.ColumnIndex == ColumnIndexActor) - { - Configuration.Settings.General.ListViewActorWidth = Columns[ColumnIndexActor].Width; - } - else if (e.ColumnIndex == ColumnIndexRegion) - { - Configuration.Settings.General.ListViewRegionWidth = Columns[ColumnIndexRegion].Width; - } - if (e.ColumnIndex == ColumnIndexText) - { - Configuration.Settings.General.ListViewTextWidth = Columns[ColumnIndexText].Width; - } - } - } - - public void AutoSizeColumns() - { - var numberIdx = GetColumnIndex(SubtitleColumn.Number); - if (numberIdx >= 0) - { - Columns[numberIdx].Width = 50; - Columns[numberIdx].Width = 50; - } - - var startIdx = GetColumnIndex(SubtitleColumn.Start); - var endIdx = GetColumnIndex(SubtitleColumn.End); - var durationIdx = GetColumnIndex(SubtitleColumn.Duration); - int timeStampWidth; - try - { - using (var graphics = CreateGraphics()) - { - var timestampSizeF = graphics.MeasureString(new TimeCode(0, 0, 33, 527).ToDisplayString(), Font); - timeStampWidth = (int)(timestampSizeF.Width + 0.5) + 11; - } - } - catch - { - timeStampWidth = 65; - } - if (startIdx >= 0) - { - Columns[startIdx].Width = timeStampWidth; - } - if (endIdx >= 0) - { - Columns[endIdx].Width = timeStampWidth; - } - if (durationIdx >= 0) - { - Columns[durationIdx].Width = (int)(timeStampWidth * 0.8); - } - - var cpsIdx = GetColumnIndex(SubtitleColumn.CharactersPerSeconds); - if (cpsIdx >= 0) - { - Columns[cpsIdx].Width = 60; - Columns[cpsIdx].Width = 60; - } - - var wpmIdx = GetColumnIndex(SubtitleColumn.WordsPerMinute); - if (wpmIdx >= 0) - { - Columns[wpmIdx].Width = 65; - Columns[wpmIdx].Width = 65; - } - - var gapIdx = GetColumnIndex(SubtitleColumn.Gap); - if (gapIdx >= 0) - { - Columns[gapIdx].Width = 60; - Columns[gapIdx].Width = 60; - } - - var actorIdx = GetColumnIndex(SubtitleColumn.Actor); - if (actorIdx >= 0) - { - Columns[actorIdx].Width = 80; - Columns[actorIdx].Width = 80; - } - - var regionIdx = GetColumnIndex(SubtitleColumn.Region); - if (regionIdx >= 0) - { - Columns[regionIdx].Width = 60; - Columns[regionIdx].Width = 60; - } - - int w = 0; - for (int index = 0; index < SubtitleColumns.Count; index++) - { - var column = SubtitleColumns[index]; - int cw = Columns[index].Width; - if (column != SubtitleColumn.Text && column != SubtitleColumn.TextAlternate) - { - w += cw; - } - } - int lengthAvailable = Width - w; - if (ColumnIndexTextAlternate >= 0) - { - lengthAvailable = lengthAvailable / 2; - Columns[ColumnIndexTextAlternate].Width = lengthAvailable; - Columns[ColumnIndexTextAlternate].Width = lengthAvailable; - Columns[ColumnIndexTextAlternate].Width = lengthAvailable; - } - Columns[ColumnIndexText].Width = lengthAvailable; - Columns[ColumnIndexText].Width = lengthAvailable; - Columns[ColumnIndexText].Width = lengthAvailable; - SubtitleListViewLastColumnFill(this, null); - } - - public void AutoSizeAllColumns(Form parentForm) - { - InitializeTimestampColumnWidths(parentForm); - - var numberIdx = GetColumnIndex(SubtitleColumn.Number); - if (numberIdx >= 0) - { - if (_settings != null && _settings.General.ListViewColumnsRememberSize && _settings.General.ListViewNumberWidth > 1) - { - Columns[numberIdx].Width = _settings.General.ListViewNumberWidth; - } - else - { - Columns[numberIdx].Width = 50; - } - } - - var startIdx = GetColumnIndex(SubtitleColumn.Start); - var endIdx = GetColumnIndex(SubtitleColumn.End); - int timeStampWidth; - try - { - using (var graphics = CreateGraphics()) - { - var timestampSizeF = graphics.MeasureString(new TimeCode(0, 0, 33, 527).ToDisplayString(), Font); - timeStampWidth = (int)(timestampSizeF.Width + 0.5) + 11; - } - } - catch - { - timeStampWidth = 65; - } - if (startIdx >= 0) - { - if (_settings != null && _settings.General.ListViewColumnsRememberSize && _settings.General.ListViewStartWidth > 1) - { - Columns[startIdx].Width = _settings.General.ListViewStartWidth; - } - else - { - Columns[startIdx].Width = timeStampWidth; - } - } - if (endIdx >= 0) - { - if (_settings != null && _settings.General.ListViewColumnsRememberSize && _settings.General.ListViewEndWidth > 1) - { - Columns[endIdx].Width = _settings.General.ListViewEndWidth; - } - else - { - Columns[endIdx].Width = timeStampWidth; - } - } - - int w = 0; - for (int index = 0; index < SubtitleColumns.Count; index++) - { - var column = SubtitleColumns[index]; - int cw = Columns[index].Width; - if (cw < 10 || column == SubtitleColumn.Extra || column == SubtitleColumn.Network) - { - cw = 55; - if (column == SubtitleColumn.CharactersPerSeconds) - { - cw = 65; - } - else if (column == SubtitleColumn.WordsPerMinute) - { - cw = 70; - } - else if (column == SubtitleColumn.Gap) - { - cw = 60; - } - else if (column == SubtitleColumn.Actor) - { - cw = 70; - } - else if (column == SubtitleColumn.Region) - { - cw = 60; - } - else if (column != SubtitleColumn.Number) - { - cw = 120; - } - - Columns[index].Width = cw; - Columns[index].Width = cw; - Columns[index].Width = cw; - } - if (column != SubtitleColumn.Text && column != SubtitleColumn.TextAlternate) - { - w += cw; - } - } - - int lengthAvailable = Width - w; - if (ColumnIndexTextAlternate >= 0 && Columns.Count > ColumnIndexTextAlternate) - { - lengthAvailable = lengthAvailable / 2; - Columns[ColumnIndexTextAlternate].Width = lengthAvailable; - Columns[ColumnIndexTextAlternate].Width = lengthAvailable; - Columns[ColumnIndexTextAlternate].Width = lengthAvailable; - } - Columns[ColumnIndexText].Width = lengthAvailable; - Columns[ColumnIndexText].Width = lengthAvailable; - Columns[ColumnIndexText].Width = lengthAvailable; - SubtitleListViewLastColumnFill(this, null); - } - - public void ShowEndColumn(string title) - { - if (GetColumnIndex(SubtitleColumn.End) == -1) - { - var ch = new ColumnHeader { Text = title, TextAlign = RightToLeftLayout ? HorizontalAlignment.Right : HorizontalAlignment.Left }; - if (ColumnIndexStart >= 0) - { - SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.End); - Columns.Insert(ColumnIndexStart + 1, ch); - } - else if (ColumnIndexNumber >= 0) - { - SubtitleColumns.Insert(ColumnIndexNumber + 1, SubtitleColumn.End); - Columns.Insert(ColumnIndexStart + 1, ch); - } - else - { - SubtitleColumns.Add(SubtitleColumn.End); - Columns.Insert(0, ch); - } - UpdateColumnIndexes(); - - try - { - using (var graphics = Parent.CreateGraphics()) - { - var timestampSizeF = graphics.MeasureString(new TimeCode(0, 0, 33, 527).ToDisplayString(), Font); - var timestampWidth = (int)(timestampSizeF.Width + 0.5) + 11; - Columns[ColumnIndexEnd].Width = timestampWidth; - } - } - catch - { - Columns[ColumnIndexEnd].Width = 65; - } - - AutoSizeAllColumns(null); - } - } - - public void ShowDurationColumn(string title) - { - if (GetColumnIndex(SubtitleColumn.Duration) == -1) - { - var ch = new ColumnHeader { Text = title, TextAlign = RightToLeftLayout ? HorizontalAlignment.Right : HorizontalAlignment.Left }; - if (ColumnIndexEnd >= 0) - { - SubtitleColumns.Insert(ColumnIndexEnd + 1, SubtitleColumn.Duration); - Columns.Insert(ColumnIndexEnd + 1, ch); - } - else if (ColumnIndexStart >= 0) - { - SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.Duration); - Columns.Insert(ColumnIndexStart + 1, ch); - } - else if (ColumnIndexNumber >= 0) - { - SubtitleColumns.Insert(ColumnIndexNumber + 1, SubtitleColumn.Duration); - Columns.Insert(ColumnIndexStart + 1, ch); - } - else - { - SubtitleColumns.Add(SubtitleColumn.Duration); - Columns.Insert(0, ch); - } - UpdateColumnIndexes(); - - try - { - using (var graphics = Parent.CreateGraphics()) - { - var timestampSizeF = graphics.MeasureString(new TimeCode(0, 0, 33, 527).ToDisplayString(), Font); - var timestampWidth = (int)(timestampSizeF.Width + 0.5) + 11; - Columns[ColumnIndexDuration].Width = (int)(timestampWidth * 0.8); - } - } - catch - { - Columns[ColumnIndexDuration].Width = 55; - } - - AutoSizeAllColumns(null); - } - } - - public void ShowAlternateTextColumn(string title) - { - if (GetColumnIndex(SubtitleColumn.TextAlternate) == -1) - { - if (ColumnIndexText >= 0) - { - SubtitleColumns.Insert(ColumnIndexText + 1, SubtitleColumn.TextAlternate); - Columns.Insert(ColumnIndexText + 1, new ColumnHeader { Text = title }); - } - else - { - SubtitleColumns.Add(SubtitleColumn.TextAlternate); - Columns.Add(new ColumnHeader { Text = title }); - } - UpdateColumnIndexes(); - Columns[ColumnIndexTextAlternate].Width = 300; - Columns[ColumnIndexTextAlternate].Width = 300; - Columns[ColumnIndexTextAlternate].Width = 300; - AutoSizeAllColumns(null); - } - else - { - Columns[ColumnIndexTextAlternate].Text = title; - } - } - - public void ShowExtraColumn(string title) - { - if (GetColumnIndex(SubtitleColumn.Extra) == -1) - { - if (ColumnIndexNetwork >= 0) - { - SubtitleColumns.Insert(ColumnIndexNetwork, SubtitleColumn.Extra); - Columns.Insert(ColumnIndexNetwork, new ColumnHeader { Text = title, Width = 120 }); - } - else - { - SubtitleColumns.Add(SubtitleColumn.Extra); - Columns.Add(new ColumnHeader { Text = title, Width = 120 }); - } - UpdateColumnIndexes(); - Columns[ColumnIndexExtra].Width = 120; - Columns[ColumnIndexExtra].Width = 120; - Columns[ColumnIndexExtra].Width = 120; - AutoSizeAllColumns(null); - } - else - { - Columns[ColumnIndexExtra].Text = title; - } - } - - public void ShowNetworkColumn(string title) - { - if (GetColumnIndex(SubtitleColumn.Network) == -1) - { - SubtitleColumns.Add(SubtitleColumn.Network); - Columns.Add(new ColumnHeader { Text = title, Width = 120 }); - UpdateColumnIndexes(); - AutoSizeAllColumns(null); - } - } - - public void ShowCharsSecColumn(string title) - { - if (GetColumnIndex(SubtitleColumn.CharactersPerSeconds) == -1) - { - var ch = new ColumnHeader { Text = title, TextAlign = RightToLeftLayout ? HorizontalAlignment.Left : HorizontalAlignment.Right }; - if (ColumnIndexDuration >= 0) - { - SubtitleColumns.Insert(ColumnIndexDuration + 1, SubtitleColumn.CharactersPerSeconds); - Columns.Insert(ColumnIndexDuration + 1, ch); - } - else if (ColumnIndexEnd >= 0) - { - SubtitleColumns.Insert(ColumnIndexEnd + 1, SubtitleColumn.CharactersPerSeconds); - Columns.Insert(ColumnIndexEnd + 1, ch); - } - else if (ColumnIndexStart >= 0) - { - SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.CharactersPerSeconds); - Columns.Insert(ColumnIndexStart + 1, ch); - } - else - { - SubtitleColumns.Add(SubtitleColumn.CharactersPerSeconds); - Columns.Add(ch); - } - UpdateColumnIndexes(); - Columns[ColumnIndexCps].Width = 65; - Columns[ColumnIndexCps].Width = 65; - AutoSizeAllColumns(null); - } - } - - public void ShowWordsMinColumn(string title) - { - if (GetColumnIndex(SubtitleColumn.WordsPerMinute) == -1) - { - var ch = new ColumnHeader { Text = title, TextAlign = RightToLeftLayout ? HorizontalAlignment.Left : HorizontalAlignment.Right }; - if (ColumnIndexCps >= 0) - { - SubtitleColumns.Insert(ColumnIndexCps + 1, SubtitleColumn.WordsPerMinute); - Columns.Insert(ColumnIndexCps + 1, ch); - } - else if (ColumnIndexDuration >= 0) - { - SubtitleColumns.Insert(ColumnIndexDuration + 1, SubtitleColumn.WordsPerMinute); - Columns.Insert(ColumnIndexDuration + 1, ch); - } - else if (ColumnIndexEnd >= 0) - { - SubtitleColumns.Insert(ColumnIndexEnd + 1, SubtitleColumn.WordsPerMinute); - Columns.Insert(ColumnIndexEnd + 1, ch); - } - else if (ColumnIndexStart >= 0) - { - SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.WordsPerMinute); - Columns.Insert(ColumnIndexStart + 1, ch); - } - else - { - SubtitleColumns.Add(SubtitleColumn.WordsPerMinute); - Columns.Add(ch); - } - UpdateColumnIndexes(); - Columns[ColumnIndexWpm].Width = 70; - Columns[ColumnIndexWpm].Width = 70; - AutoSizeAllColumns(null); - } - } - - public void ShowGapColumn(string title) - { - if (GetColumnIndex(SubtitleColumn.Gap) == -1) - { - var ch = new ColumnHeader { Text = title }; - if (ColumnIndexWpm >= 0) - { - SubtitleColumns.Insert(ColumnIndexWpm + 1, SubtitleColumn.Gap); - Columns.Insert(ColumnIndexWpm + 1, ch); - } - else if (ColumnIndexCps >= 0) - { - SubtitleColumns.Insert(ColumnIndexCps + 1, SubtitleColumn.Gap); - Columns.Insert(ColumnIndexCps + 1, ch); - } - else if (ColumnIndexDuration >= 0) - { - SubtitleColumns.Insert(ColumnIndexDuration + 1, SubtitleColumn.Gap); - Columns.Insert(ColumnIndexDuration + 1, ch); - } - else if (ColumnIndexEnd >= 0) - { - SubtitleColumns.Insert(ColumnIndexEnd + 1, SubtitleColumn.Gap); - Columns.Insert(ColumnIndexEnd + 1, ch); - } - else if (ColumnIndexStart >= 0) - { - SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.Gap); - Columns.Insert(ColumnIndexStart + 1, ch); - } - else - { - SubtitleColumns.Add(SubtitleColumn.Gap); - Columns.Add(ch); - } - UpdateColumnIndexes(); - Columns[ColumnIndexGap].Width = 80; - Columns[ColumnIndexGap].Width = 80; - AutoSizeAllColumns(null); - } - } - - public void ShowActorColumn(string title) - { - if (GetColumnIndex(SubtitleColumn.Actor) == -1) - { - var ch = new ColumnHeader { Text = title }; - if (ColumnIndexGap >= 0) - { - SubtitleColumns.Insert(ColumnIndexGap + 1, SubtitleColumn.Actor); - Columns.Insert(ColumnIndexGap + 1, ch); - } - else if (ColumnIndexWpm >= 0) - { - SubtitleColumns.Insert(ColumnIndexWpm + 1, SubtitleColumn.Actor); - Columns.Insert(ColumnIndexWpm + 1, ch); - } - else if (ColumnIndexCps >= 0) - { - SubtitleColumns.Insert(ColumnIndexCps + 1, SubtitleColumn.Actor); - Columns.Insert(ColumnIndexCps + 1, ch); - } - else if (ColumnIndexDuration >= 0) - { - SubtitleColumns.Insert(ColumnIndexDuration + 1, SubtitleColumn.Actor); - Columns.Insert(ColumnIndexDuration + 1, ch); - } - else if (ColumnIndexEnd >= 0) - { - SubtitleColumns.Insert(ColumnIndexEnd + 1, SubtitleColumn.Actor); - Columns.Insert(ColumnIndexEnd + 1, ch); - } - else if (ColumnIndexStart >= 0) - { - SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.Actor); - Columns.Insert(ColumnIndexStart + 1, ch); - } - else - { - SubtitleColumns.Add(SubtitleColumn.Actor); - Columns.Add(ch); - } - UpdateColumnIndexes(); - Columns[ColumnIndexActor].Width = 80; - Columns[ColumnIndexActor].Width = 80; - AutoSizeAllColumns(null); - } - else - { - Columns[GetColumnIndex(SubtitleColumn.Actor)].Text = title; - } - } - - public void ShowRegionColumn(string title) - { - if (GetColumnIndex(SubtitleColumn.Region) == -1) - { - var ch = new ColumnHeader { Text = title }; - if (ColumnIndexActor >= 0) - { - SubtitleColumns.Insert(ColumnIndexActor + 1, SubtitleColumn.Region); - Columns.Insert(ColumnIndexActor + 1, ch); - } - else if (ColumnIndexGap >= 0) - { - SubtitleColumns.Insert(ColumnIndexGap + 1, SubtitleColumn.Region); - Columns.Insert(ColumnIndexGap + 1, ch); - } - else if (ColumnIndexWpm >= 0) - { - SubtitleColumns.Insert(ColumnIndexWpm + 1, SubtitleColumn.Region); - Columns.Insert(ColumnIndexWpm + 1, ch); - } - else if (ColumnIndexCps >= 0) - { - SubtitleColumns.Insert(ColumnIndexCps + 1, SubtitleColumn.Region); - Columns.Insert(ColumnIndexCps + 1, ch); - } - else if (ColumnIndexDuration >= 0) - { - SubtitleColumns.Insert(ColumnIndexDuration + 1, SubtitleColumn.Region); - Columns.Insert(ColumnIndexDuration + 1, ch); - } - else if (ColumnIndexEnd >= 0) - { - SubtitleColumns.Insert(ColumnIndexEnd + 1, SubtitleColumn.Region); - Columns.Insert(ColumnIndexEnd + 1, ch); - } - else if (ColumnIndexStart >= 0) - { - SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.Region); - Columns.Insert(ColumnIndexStart + 1, ch); - } - else - { - SubtitleColumns.Add(SubtitleColumn.Region); - Columns.Add(ch); - } - UpdateColumnIndexes(); - Columns[ColumnIndexRegion].Width = 80; - Columns[ColumnIndexRegion].Width = 80; - AutoSizeAllColumns(null); - } - } - - public void HideColumn(SubtitleColumn column) - { - var idx = GetColumnIndex(column); - if (idx >= 0) - { - SubtitleColumns.RemoveAt(idx); - UpdateColumnIndexes(); - Columns.RemoveAt(idx); - AutoSizeAllColumns(null); - } - } - - public void SubtitleListViewLastColumnFill(object sender, EventArgs e) - { - int width = 0; - for (int i = 0; i < Columns.Count - 1; i++) - { - width += Columns[i].Width; - } - if (Columns.Count > 0) - { - Columns[Columns.Count - 1].Width = Width - (width + 25); - } - } - - public void SaveFirstVisibleIndex() - { - if (TopItem != null) - { - FirstVisibleIndex = Items.Count > 0 ? TopItem.Index : -1; - } - } - - private void RestoreFirstVisibleIndex() - { - if (IsValidIndex(FirstVisibleIndex)) - { - if (FirstVisibleIndex + 1 < Items.Count) - { - FirstVisibleIndex++; - } - - Items[Items.Count - 1].EnsureVisible(); - Items[FirstVisibleIndex].EnsureVisible(); - } - } - - internal void Fill(Subtitle subtitle, Subtitle subtitleAlternate = null) - { - if (subtitleAlternate == null || subtitleAlternate.Paragraphs.Count == 0) - { - Fill(subtitle.Paragraphs); - } - else - { - Fill(subtitle.Paragraphs, subtitleAlternate.Paragraphs); - } - } - - internal void Fill(List paragraphs) - { - SaveFirstVisibleIndex(); - BeginUpdate(); - Items.Clear(); - var x = ListViewItemSorter; - ListViewItemSorter = null; - var font = new Font(_subtitleFontName, SubtitleFontSize, GetFontStyle()); - var items = new ListViewItem[paragraphs.Count]; - for (var index = 0; index < paragraphs.Count; index++) - { - var paragraph = paragraphs[index]; - Paragraph next = null; - if (index + 1 < paragraphs.Count) - { - next = paragraphs[index + 1]; - } - items[index] = MakeListViewItem(paragraph, next, null, font); - } - - Items.AddRange(items); - - if (UseSyntaxColoring && _settings != null) - { - for (var index = 0; index < paragraphs.Count; index++) - { - var paragraph = paragraphs[index]; - var item = items[index]; - SyntaxColorListViewItem(paragraphs, index, paragraph, item); - } - } - - ListViewItemSorter = x; - EndUpdate(); - - if (FirstVisibleIndex == 0) - { - FirstVisibleIndex = -1; - } - } - - internal void Fill(List paragraphs, List paragraphsAlternate) - { - SaveFirstVisibleIndex(); - BeginUpdate(); - Items.Clear(); - var x = ListViewItemSorter; - ListViewItemSorter = null; - var items = new ListViewItem[paragraphs.Count]; - var font = new Font(_subtitleFontName, SubtitleFontSize, GetFontStyle()); - for (var index = 0; index < paragraphs.Count; index++) - { - var paragraph = paragraphs[index]; - Paragraph alternate = Utilities.GetOriginalParagraph(index, paragraph, paragraphsAlternate); - Paragraph next = null; - if (index + 1 < paragraphs.Count) - { - next = paragraphs[index + 1]; - } - items[index] = MakeListViewItem(paragraph, next, alternate, font); - } - - Items.AddRange(items); - - if (UseSyntaxColoring && _settings != null) - { - for (var index = 0; index < paragraphs.Count; index++) - { - var paragraph = paragraphs[index]; - var item = items[index]; - SyntaxColorListViewItem(paragraphs, index, paragraph, item); - } - } - - ListViewItemSorter = x; - EndUpdate(); - - if (FirstVisibleIndex == 0) - { - FirstVisibleIndex = -1; - } - } - - public void SyntaxColorAllLines(Subtitle subtitle) - { - if (UseSyntaxColoring && _settings != null) - { - for (int index = 0; index < subtitle.Paragraphs.Count; index++) - { - var paragraph = subtitle.Paragraphs[index]; - SyntaxColorListViewItem(subtitle.Paragraphs, index, paragraph, Items[index]); - } - } - } - - public void SyntaxColorLine(List paragraphs, int i, Paragraph paragraph) - { - if (UseSyntaxColoring && _settings != null && IsValidIndex(i)) - { - var item = Items[i]; - SyntaxColorListViewItem(paragraphs, i, paragraph, item); - } - } - - private void SyntaxColorListViewItem(List paragraphs, int i, Paragraph paragraph, ListViewItem item) - { - if (item.UseItemStyleForSubItems) - { - item.UseItemStyleForSubItems = false; - item.SubItems[ColumnIndexDuration].BackColor = BackColor; - } - if (ColumnIndexCps >= 0) - { - item.SubItems[ColumnIndexCps].BackColor = BackColor; - } - if (ColumnIndexWpm >= 0) - { - item.SubItems[ColumnIndexWpm].BackColor = paragraph.WordsPerMinute > Configuration.Settings.General.SubtitleMaximumWordsPerMinute ? Configuration.Settings.Tools.ListViewSyntaxErrorColor : BackColor; - } - if (ColumnIndexDuration >= 0) - { - item.SubItems[ColumnIndexDuration].BackColor = BackColor; - } - - if (_settings.Tools.ListViewSyntaxColorDurationSmall) - { - double charactersPerSecond = Utilities.GetCharactersPerSecond(paragraph); - if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds) - { - if (ColumnIndexCps >= 0) - { - item.SubItems[ColumnIndexCps].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - } - else if (ColumnIndexDuration >= 0) - { - item.SubItems[ColumnIndexDuration].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - } - } - if (paragraph.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds && ColumnIndexDuration >= 0) - { - item.SubItems[ColumnIndexDuration].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - } - } - if (_settings.Tools.ListViewSyntaxColorDurationBig && - paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds && - ColumnIndexDuration >= 0) - { - item.SubItems[ColumnIndexDuration].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - } - - if (_settings.Tools.ListViewSyntaxColorOverlap && i > 0 && i < paragraphs.Count && ColumnIndexEnd >= 0) - { - Paragraph prev = paragraphs[i - 1]; - if (paragraph.StartTime.TotalMilliseconds < prev.EndTime.TotalMilliseconds && !prev.EndTime.IsMaxTime) - { - Items[i - 1].SubItems[ColumnIndexEnd].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - item.SubItems[ColumnIndexStart].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - } - else - { - Items[i - 1].SubItems[ColumnIndexEnd].BackColor = BackColor; - item.SubItems[ColumnIndexStart].BackColor = BackColor; - } - } - - if (_settings.Tools.ListViewSyntaxColorGap && i >= 0 && i < paragraphs.Count - 1 && ColumnIndexGap >= 0) - { - Paragraph next = paragraphs[i + 1]; - if (next.StartTime.TotalMilliseconds - paragraph.EndTime.TotalMilliseconds < Configuration.Settings.General.MinimumMillisecondsBetweenLines) - { - item.SubItems[ColumnIndexGap].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - } - else - { - item.SubItems[ColumnIndexGap].BackColor = BackColor; - } - } - - if (ColumnIndexTextAlternate >= 0 && item.SubItems.Count >= ColumnIndexTextAlternate) - { - item.SubItems[ColumnIndexTextAlternate].BackColor = BackColor; - } - - if (ColumnIndexText >= item.SubItems.Count) - { - return; - } - - if (_settings.Tools.ListViewSyntaxColorLongLines) - { - string s = HtmlUtil.RemoveHtmlTags(paragraph.Text, true); - foreach (string line in s.SplitToLines()) - { - if (line.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength) - { - item.SubItems[ColumnIndexText].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - return; - } - } - int noOfLines = paragraph.NumberOfLines; - if (s.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) <= Configuration.Settings.General.SubtitleLineMaximumLength * noOfLines) - { - if (noOfLines > Configuration.Settings.General.MaxNumberOfLines && _settings.Tools.ListViewSyntaxMoreThanXLines) - { - item.SubItems[ColumnIndexText].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - } - else - { - item.SubItems[ColumnIndexText].BackColor = BackColor; - } - } - else - { - item.SubItems[ColumnIndexText].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - } - } - if (_settings.Tools.ListViewSyntaxColorWideLines) - { - string s = HtmlUtil.RemoveHtmlTags(paragraph.Text, true); - foreach (string line in s.SplitToLines()) - { - if (TextWidth.CalcPixelWidth(line) > Configuration.Settings.General.SubtitleLineMaximumPixelWidth) - { - item.SubItems[ColumnIndexText].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - return; - } - } - } - if (_settings.Tools.ListViewSyntaxMoreThanXLines && - item.SubItems[ColumnIndexText].BackColor != Configuration.Settings.Tools.ListViewSyntaxErrorColor) - { - if (paragraph.NumberOfLines > Configuration.Settings.General.MaxNumberOfLines) - { - item.SubItems[ColumnIndexText].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - } - } - } - - private string GetDisplayTime(TimeCode timeCode) - { - if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) - { - return new TimeCode(timeCode.TotalMilliseconds + Configuration.Settings.General.CurrentVideoOffsetInMs).ToDisplayString(); - } - - return timeCode.ToDisplayString(); - } - - private ListViewItem MakeListViewItem(Paragraph paragraph, Paragraph next, Paragraph paragraphAlternate, Font font) - { - var item = new ListViewItem(paragraph.Number.ToString(CultureInfo.InvariantCulture)) { Tag = paragraph, UseItemStyleForSubItems = false }; - foreach (var column in SubtitleColumns) - { - switch (column) - { - case SubtitleColumn.Start: - item.SubItems.Add(GetDisplayTime(paragraph.StartTime)); - break; - case SubtitleColumn.End: - item.SubItems.Add(GetDisplayTime(paragraph.EndTime)); - break; - case SubtitleColumn.Duration: - item.SubItems.Add(paragraph.Duration.ToShortDisplayString()); - break; - case SubtitleColumn.CharactersPerSeconds: - item.SubItems.Add($"{Utilities.GetCharactersPerSecond(paragraph):0.00}"); - break; - case SubtitleColumn.WordsPerMinute: - item.SubItems.Add($"{paragraph.WordsPerMinute:0.00}"); - break; - case SubtitleColumn.Gap: - item.SubItems.Add(GetGap(paragraph, next)); - break; - case SubtitleColumn.Actor: - item.SubItems.Add(paragraph.Actor); - break; - case SubtitleColumn.Region: - item.SubItems.Add(paragraph.Region); - break; - case SubtitleColumn.Text: - item.SubItems.Add(paragraph.Text.Replace(Environment.NewLine, _lineSeparatorString)); - break; - case SubtitleColumn.TextAlternate: - var text = paragraphAlternate != null ? paragraphAlternate.Text : string.Empty; - item.SubItems.Add(text.Replace(Environment.NewLine, _lineSeparatorString)); - break; - case SubtitleColumn.Extra: - item.SubItems.Add(paragraph.Extra); - break; - case SubtitleColumn.Network: - item.SubItems.Add(string.Empty); - break; - } - } - - item.StateImageIndex = paragraph.Bookmark != null ? 0 : -1; - item.Font = font; - return item; - } - - public void SelectNone() - { - for (var i = Items.Count - 1; i >= 0; i--) - { - Items[i].Selected = false; - } - } - - public void SelectIndexAndEnsureVisibleFaster(int index) - { - var topItem = TopItem; - if (!IsValidIndex(index) || topItem == null) - { - return; - } - - BeginUpdate(); - foreach (var selectedIndex in GetSelectedIndices()) - { - Items[selectedIndex].Selected = false; - } - - var selectedItem = Items[index]; - selectedItem.Selected = true; - selectedItem.Focused = true; - - var topIndex = topItem.Index; - var numberOfVisibleItems = (Height - 30) / GetItemRect(0).Height; - int bottomIndex = topIndex + numberOfVisibleItems; - if (index >= bottomIndex) - { - Items[Math.Min(Items.Count - 1, index + numberOfVisibleItems / 2)].EnsureVisible(); - } - else if (index < topIndex) - { - Items[Math.Max(0, index - numberOfVisibleItems / 2)].EnsureVisible(); - } - EndUpdate(); - } - - public void SelectIndexAndEnsureVisible(int index, bool focus) - { - if (!IsValidIndex(index)) - { - return; - } - - if (TopItem == null) - { - EnsureVisible(index); - if (focus) - { - Items[index].Focused = true; - } - return; - } - - int bottomIndex = TopItem.Index + (Height - 25) / 16; - int itemsBeforeAfterCount = (bottomIndex - TopItem.Index) / 2 - 1; - if (itemsBeforeAfterCount < 0) - { - itemsBeforeAfterCount = 1; - } - - int beforeIndex = index - itemsBeforeAfterCount; - if (beforeIndex < 0) - { - beforeIndex = 0; - } - - int afterIndex = index + itemsBeforeAfterCount; - if (afterIndex >= Items.Count) - { - afterIndex = Items.Count - 1; - } - - SelectNone(); - if (TopItem.Index <= beforeIndex && bottomIndex > afterIndex) - { - Items[index].Selected = true; - Items[index].EnsureVisible(); - if (focus) - { - Items[index].Focused = true; - } - EnsureVisible(index); - return; - } - - Items[beforeIndex].EnsureVisible(); - EnsureVisible(beforeIndex); - Items[afterIndex].EnsureVisible(); - EnsureVisible(afterIndex); - Items[index].Selected = true; - Items[index].EnsureVisible(); - if (focus) - { - Items[index].Focused = true; - } - EnsureVisible(index); - } - - public void SelectIndexAndEnsureVisible(int index) - { - SelectIndexAndEnsureVisible(index, false); - } - - public void SelectIndexAndEnsureVisible(Paragraph p) - { - SelectNone(); - if (p == null) - { - return; - } - - for (int index = 0; index < Items.Count; index++) - { - ListViewItem item = Items[index]; - if (item.Tag as Paragraph == p || - item.Text == p.Number.ToString(CultureInfo.InvariantCulture) && - (ColumnIndexStart < 0 || item.SubItems[ColumnIndexStart].Text == GetDisplayTime(p.StartTime)) && - (ColumnIndexEnd < 0 || item.SubItems[ColumnIndexEnd].Text == GetDisplayTime(p.EndTime)) && - item.SubItems[ColumnIndexText].Text == p.Text) - { - RestoreFirstVisibleIndex(); - item.Selected = true; - item.EnsureVisible(); - return; - } - } - } - - public Paragraph GetSelectedParagraph(Subtitle subtitle) - { - if (subtitle != null && SelectedItems.Count > 0) - { - return subtitle.GetParagraphOrDefault(SelectedItems[0].Index); - } - - return null; - } - - public string GetText(int index) - { - if (IsValidIndex(index)) - { - return Items[index].SubItems[ColumnIndexText].Text.Replace(_lineSeparatorString, Environment.NewLine); - } - - return null; - } - - public string GetTextAlternate(int index) - { - if (IsValidIndex(index) && ColumnIndexTextAlternate >= 0) - { - return Items[index].SubItems[ColumnIndexTextAlternate].Text.Replace(_lineSeparatorString, Environment.NewLine); - } - - return null; - } - - public void SetText(int index, string text) - { - if (IsValidIndex(index)) - { - ListViewItem item = Items[index]; - if (ColumnIndexText >= 0) - { - item.SubItems[ColumnIndexText].Text = text.Replace(Environment.NewLine, _lineSeparatorString); - } - - if (item.Tag is Paragraph paragraph) - { - UpdateCpsAndWpm(item, paragraph); - } - } - } - - public void SetTimeAndText(int index, Paragraph paragraph, Paragraph next) - { - if (IsValidIndex(index)) - { - ListViewItem item = Items[index]; - if (ColumnIndexStart >= 0) - { - item.SubItems[ColumnIndexStart].Text = GetDisplayTime(paragraph.StartTime); - } - - if (ColumnIndexEnd >= 0) - { - item.SubItems[ColumnIndexEnd].Text = GetDisplayTime(paragraph.EndTime); - } - - if (ColumnIndexDuration >= 0) - { - item.SubItems[ColumnIndexDuration].Text = paragraph.Duration.ToShortDisplayString(); - } - - if (ColumnIndexGap >= 0) - { - item.SubItems[ColumnIndexGap].Text = GetGap(paragraph, next); - } - - if (ColumnIndexActor >= 0) - { - item.SubItems[ColumnIndexActor].Text = paragraph.Actor; - } - - if (ColumnIndexRegion >= 0) - { - item.SubItems[ColumnIndexRegion].Text = paragraph.Region; - } - - if (ColumnIndexText >= 0) - { - item.SubItems[ColumnIndexText].Text = paragraph.Text.Replace(Environment.NewLine, _lineSeparatorString); - } - - UpdateCpsAndWpm(item, paragraph); - } - } - - private void UpdateCpsAndWpm(ListViewItem item, Paragraph paragraph) - { - if (ColumnIndexCps >= 0) - { - item.SubItems[ColumnIndexCps].Text = $"{Utilities.GetCharactersPerSecond(paragraph):0.00}"; - } - if (ColumnIndexWpm >= 0) - { - item.SubItems[ColumnIndexWpm].Text = $"{paragraph.WordsPerMinute:0.00}"; - } - } - - public void SetExtraText(int index, string text, Color color) - { - if (IsValidIndex(index)) - { - if (GetColumnIndex(SubtitleColumn.Extra) == -1) - { - ShowExtraColumn(string.Empty); - } - while (ColumnIndexExtra >= Items[index].SubItems.Count) - { - Items[index].SubItems.Add(string.Empty); - } - - if (ColumnIndexExtra >= 0) - { - Items[index].SubItems[ColumnIndexExtra].Text = text; - Items[index].UseItemStyleForSubItems = false; - Items[index].SubItems[ColumnIndexExtra].BackColor = BackColor; - Items[index].SubItems[ColumnIndexExtra].ForeColor = color; - } - } - } - - public void SetNetworkText(int index, string text, Color color) - { - if (IsValidIndex(index)) - { - if (GetColumnIndex(SubtitleColumn.Network) == -1) - { - ShowNetworkColumn(string.Empty); - } - while (ColumnIndexNetwork >= Items[index].SubItems.Count) - { - Items[index].SubItems.Add(string.Empty); - } - - if (ColumnIndexNetwork >= 0) - { - Items[index].SubItems[ColumnIndexNetwork].Text = text; - Items[index].UseItemStyleForSubItems = false; - Items[index].SubItems[ColumnIndexNetwork].BackColor = Color.AntiqueWhite; - Items[index].SubItems[ColumnIndexNetwork].ForeColor = color; - } - } - } - - public void SetAlternateText(int index, string text) - { - if (IsValidIndex(index) && Columns.Count >= ColumnIndexTextAlternate + 1) - { - if (GetColumnIndex(SubtitleColumn.TextAlternate) == -1) - { - ShowAlternateTextColumn(string.Empty); - } - while (ColumnIndexTextAlternate >= Items[index].SubItems.Count) - { - Items[index].SubItems.Add(string.Empty); - } - - if (ColumnIndexTextAlternate >= 0) - { - Items[index].SubItems[ColumnIndexTextAlternate].Text = text.Replace(Environment.NewLine, _lineSeparatorString); - Items[index].UseItemStyleForSubItems = false; - Items[index].SubItems[ColumnIndexTextAlternate].BackColor = BackColor; - } - } - } - - public void SetDuration(int index, Paragraph paragraph, Paragraph next) - { - if (IsValidIndex(index)) - { - ListViewItem item = Items[index]; - if (ColumnIndexEnd >= 0) - { - item.SubItems[ColumnIndexEnd].Text = GetDisplayTime(paragraph.EndTime); - } - - if (ColumnIndexDuration >= 0) - { - item.SubItems[ColumnIndexDuration].Text = paragraph.Duration.ToShortDisplayString(); - } - - if (ColumnIndexGap >= 0) - { - item.SubItems[ColumnIndexGap].Text = GetGap(paragraph, next); - } - - UpdateCpsAndWpm(item, paragraph); - } - } - - public void SetNumber(int index, string number) - { - if (IsValidIndex(index) && ColumnIndexNumber >= 0) - { - Items[index].SubItems[ColumnIndexNumber].Text = number; - } - } - - public void UpdateFrames(Subtitle subtitle) - { - if (Configuration.Settings?.General.UseTimeFormatHHMMSSFF == true) - { - BeginUpdate(); - for (int i = 0; i < subtitle.Paragraphs.Count; i++) - { - if (IsValidIndex(i)) - { - Paragraph p = subtitle.Paragraphs[i]; - ListViewItem item = Items[i]; - if (ColumnIndexStart >= 0) - { - item.SubItems[ColumnIndexStart].Text = GetDisplayTime(p.StartTime); - } - - if (ColumnIndexEnd >= 0) - { - item.SubItems[ColumnIndexEnd].Text = GetDisplayTime(p.EndTime); - } - - if (ColumnIndexDuration >= 0) - { - item.SubItems[ColumnIndexDuration].Text = p.Duration.ToShortDisplayString(); - } - } - } - EndUpdate(); - } - } - - public void SetStartTimeAndDuration(int index, Paragraph paragraph, Paragraph next, Paragraph prev) - { - if (IsValidIndex(index)) - { - ListViewItem item = Items[index]; - if (ColumnIndexStart >= 0) - { - item.SubItems[ColumnIndexStart].Text = GetDisplayTime(paragraph.StartTime); - } - - if (ColumnIndexEnd >= 0) - { - item.SubItems[ColumnIndexEnd].Text = GetDisplayTime(paragraph.EndTime); - } - - if (ColumnIndexDuration >= 0) - { - item.SubItems[ColumnIndexDuration].Text = paragraph.Duration.ToShortDisplayString(); - } - - if (ColumnIndexGap >= 0) - { - item.SubItems[ColumnIndexGap].Text = GetGap(paragraph, next); - } - - UpdateCpsAndWpm(item, paragraph); - } - SetGap(index - 1, prev, paragraph); - } - - private void SetGap(int index, Paragraph paragraph, Paragraph next) - { - if (IsValidIndex(index)) - { - ListViewItem item = Items[index]; - if (ColumnIndexGap >= 0) - { - item.SubItems[ColumnIndexGap].Text = GetGap(paragraph, next); - } - } - } - - private string GetGap(Paragraph paragraph, Paragraph next) - { - if (next == null || paragraph == null || next.StartTime.IsMaxTime || paragraph.EndTime.IsMaxTime) - { - return string.Empty; - } - - return new TimeCode(next.StartTime.TotalMilliseconds - paragraph.EndTime.TotalMilliseconds).ToShortDisplayString(); - } - - public void SetBackgroundColor(int index, Color color, int columnNumber) - { - if (IsValidIndex(index)) - { - ListViewItem item = Items[index]; - if (item.UseItemStyleForSubItems) - { - item.UseItemStyleForSubItems = false; - } - - if (columnNumber >= 0 && columnNumber < item.SubItems.Count) - { - item.SubItems[columnNumber].BackColor = color; - } - } - } - - public void SetBackgroundColor(int index, Color color) - { - if (IsValidIndex(index)) - { - ListViewItem item = Items[index]; - item.BackColor = color; - if (ColumnIndexStart >= 0) - { - Items[index].SubItems[ColumnIndexStart].BackColor = color; - } - - if (ColumnIndexEnd >= 0) - { - Items[index].SubItems[ColumnIndexEnd].BackColor = color; - } - - if (ColumnIndexDuration >= 0) - { - Items[index].SubItems[ColumnIndexDuration].BackColor = color; - } - - if (ColumnIndexCps >= 0) - { - Items[index].SubItems[ColumnIndexCps].BackColor = color; - } - - if (ColumnIndexWpm >= 0) - { - Items[index].SubItems[ColumnIndexWpm].BackColor = color; - } - - if (ColumnIndexGap >= 0) - { - Items[index].SubItems[ColumnIndexGap].BackColor = color; - } - - if (ColumnIndexText >= 0) - { - Items[index].SubItems[ColumnIndexText].BackColor = color; - } - - if (ColumnIndexTextAlternate >= 0) - { - Items[index].SubItems[ColumnIndexTextAlternate].BackColor = color; - } - } - } - - public Color GetBackgroundColor(int index) - { - if (IsValidIndex(index)) - { - ListViewItem item = Items[index]; - return item.BackColor; - } - return DefaultBackColor; - } - - /// - /// Removes all text and set background color - /// - /// - /// - public void ColorOut(int index, Color color) - { - if (IsValidIndex(index)) - { - ListViewItem item = Items[index]; - item.Text = string.Empty; - if (ColumnIndexStart >= 0) - { - item.SubItems[ColumnIndexStart].Text = string.Empty; - } - - if (ColumnIndexEnd >= 0) - { - item.SubItems[ColumnIndexEnd].Text = string.Empty; - } - - if (ColumnIndexDuration >= 0) - { - item.SubItems[ColumnIndexDuration].Text = string.Empty; - } - - if (ColumnIndexText >= 0) - { - item.SubItems[ColumnIndexText].Text = string.Empty; - } - - if (ColumnIndexGap >= 0) - { - item.SubItems[ColumnIndexGap].Text = string.Empty; - } - - SetBackgroundColor(index, color); - } - } - - public void HideNonVobSubColumns() - { - var numberIdx = GetColumnIndex(SubtitleColumn.Number); - if (numberIdx >= 0) - { - Columns[numberIdx].Width = 0; - } - - HideColumn(SubtitleColumn.End); - HideColumn(SubtitleColumn.Duration); - HideColumn(SubtitleColumn.CharactersPerSeconds); - HideColumn(SubtitleColumn.WordsPerMinute); - } - - public void SetCustomResize(EventHandler handler) - { - if (handler == null) - { - return; - } - - Resize -= SubtitleListViewLastColumnFill; - Resize += handler; - } - - private bool IsValidIndex(int index) - { - return index >= 0 && index < Items.Count; - } - - private FontStyle GetFontStyle() => SubtitleFontBold ? FontStyle.Bold : FontStyle.Regular; - - public void ShowState(int index, Paragraph paragraph) - { - if (IsValidIndex(index)) - { - Items[index].StateImageIndex = paragraph.Bookmark != null ? 0 : -1; - } - } - - /// - /// Get SelectedIndices as array for faster performance. - /// - /// SelectedIndices as int array - public int[] GetSelectedIndices() - { - var selectedIndices = new int[SelectedIndices.Count]; - SelectedIndices.CopyTo(selectedIndices, 0); - return selectedIndices; - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Controls +{ + public sealed class SubtitleListView : ListView + { + public enum SubtitleColumn + { + Number, + Start, + End, + Duration, + CharactersPerSeconds, + WordsPerMinute, + Gap, + Actor, + Region, + Text, + TextAlternate, + Extra, + Network + } + + private List SubtitleColumns { get; } + + public int GetColumnIndex(SubtitleColumn column) + { + return SubtitleColumns.IndexOf(column); + } + + public int ColumnIndexNumber { get; private set; } + public int ColumnIndexStart { get; private set; } + public int ColumnIndexEnd { get; private set; } + public int ColumnIndexDuration { get; private set; } + public int ColumnIndexWpm { get; private set; } + public int ColumnIndexCps { get; private set; } + public int ColumnIndexGap { get; private set; } + public int ColumnIndexActor { get; private set; } + public int ColumnIndexRegion { get; private set; } + public int ColumnIndexText { get; private set; } + public int ColumnIndexTextAlternate { get; private set; } + public int ColumnIndexExtra { get; private set; } + public int ColumnIndexNetwork { get; private set; } + + public bool IsAlternateTextColumnVisible => ColumnIndexTextAlternate >= 0; + private string _lineSeparatorString = " || "; + + private Font _subtitleFont = new Font("Tahoma", 8.25F); + + private string _subtitleFontName = "Tahoma"; + + public override bool RightToLeftLayout + { + get => base.RightToLeftLayout; + set + { + var hzAlignment = value ? HorizontalAlignment.Left : HorizontalAlignment.Right; + if (ColumnIndexCps >= 0) + { + Columns[ColumnIndexCps].TextAlign = hzAlignment; + } + + if (ColumnIndexWpm >= 0) + { + Columns[ColumnIndexWpm].TextAlign = hzAlignment; + } + + base.RightToLeftLayout = value; + } + } + + public string SubtitleFontName + { + get => _subtitleFontName; + set + { + _subtitleFontName = value; + _subtitleFont = new Font(_subtitleFontName, SubtitleFontSize, GetFontStyle()); + } + } + + private bool _subtitleFontBold; + + public bool SubtitleFontBold + { + get { return _subtitleFontBold; } + set + { + _subtitleFontBold = value; + _subtitleFont = new Font(_subtitleFontName, SubtitleFontSize, GetFontStyle()); + } + } + + private int _subtitleFontSize = 8; + + public int SubtitleFontSize + { + get => _subtitleFontSize; + set + { + _subtitleFontSize = value; + _subtitleFont = new Font(_subtitleFontName, SubtitleFontSize, GetFontStyle()); + } + } + + public bool UseSyntaxColoring { get; set; } + private Settings _settings; + private bool _saveColumnWidthChanges; + + public int FirstVisibleIndex { get; set; } = -1; + + public void InitializeLanguage(LanguageStructure.General general, Settings settings) + { + int idx = GetColumnIndex(SubtitleColumn.Number); + if (idx >= 0) + { + Columns[idx].Text = general.NumberSymbol; + } + + idx = GetColumnIndex(SubtitleColumn.Start); + if (idx >= 0) + { + Columns[idx].Text = general.StartTime; + } + + idx = GetColumnIndex(SubtitleColumn.End); + if (idx >= 0) + { + Columns[idx].Text = general.EndTime; + } + + idx = GetColumnIndex(SubtitleColumn.Duration); + if (idx >= 0) + { + Columns[idx].Text = general.Duration; + } + + idx = GetColumnIndex(SubtitleColumn.CharactersPerSeconds); + if (idx >= 0) + { + Columns[idx].Text = general.CharsPerSec; + } + + idx = GetColumnIndex(SubtitleColumn.WordsPerMinute); + if (idx >= 0) + { + Columns[idx].Text = general.WordsPerMin; + } + + idx = GetColumnIndex(SubtitleColumn.Gap); + if (idx >= 0) + { + Columns[idx].Text = general.Gap; + } + + idx = GetColumnIndex(SubtitleColumn.Actor); + if (idx >= 0) + { + Columns[idx].Text = general.Actor; + } + + idx = GetColumnIndex(SubtitleColumn.Region); + if (idx >= 0) + { + Columns[idx].Text = general.Region; + } + + idx = GetColumnIndex(SubtitleColumn.Text); + if (idx >= 0) + { + Columns[idx].Text = general.Text; + } + + if (settings.General.ListViewLineSeparatorString != null) + { + _lineSeparatorString = settings.General.ListViewLineSeparatorString; + } + + if (!string.IsNullOrEmpty(settings.General.SubtitleFontName)) + { + _subtitleFontName = settings.General.SubtitleFontName; + } + + SubtitleFontBold = settings.General.SubtitleListViewFontBold; + if (settings.General.SubtitleListViewFontSize > 6 && settings.General.SubtitleListViewFontSize < 72) + { + SubtitleFontSize = settings.General.SubtitleListViewFontSize; + } + + ForeColor = settings.General.SubtitleFontColor; + BackColor = settings.General.SubtitleBackgroundColor; + _settings = settings; + } + + public void InitializeTimestampColumnWidths(Control parentForm) + { + if (_settings != null && _settings.General.ListViewColumnsRememberSize && _settings.General.ListViewNumberWidth > 1 && + _settings.General.ListViewStartWidth > 1 && _settings.General.ListViewEndWidth > 1 && _settings.General.ListViewDurationWidth > 1) + { + int idx = GetColumnIndex(SubtitleColumn.Number); + if (idx >= 0) + { + Columns[idx].Width = Configuration.Settings.General.ListViewNumberWidth; + } + + idx = GetColumnIndex(SubtitleColumn.Start); + if (idx >= 0) + { + Columns[idx].Width = _settings.General.ListViewStartWidth; + } + + idx = GetColumnIndex(SubtitleColumn.End); + if (idx >= 0) + { + Columns[idx].Width = _settings.General.ListViewEndWidth; + } + + idx = GetColumnIndex(SubtitleColumn.Duration); + if (idx >= 0) + { + Columns[idx].Width = _settings.General.ListViewDurationWidth; + } + + idx = GetColumnIndex(SubtitleColumn.CharactersPerSeconds); + if (idx >= 0) + { + Columns[idx].Width = _settings.General.ListViewCpsWidth; + } + + idx = GetColumnIndex(SubtitleColumn.WordsPerMinute); + if (idx >= 0) + { + Columns[idx].Width = _settings.General.ListViewWpmWidth; + } + + idx = GetColumnIndex(SubtitleColumn.Gap); + if (idx >= 0) + { + Columns[idx].Width = _settings.General.ListViewGapWidth; + } + + idx = GetColumnIndex(SubtitleColumn.Actor); + if (idx >= 0) + { + Columns[idx].Width = _settings.General.ListViewActorWidth; + } + + idx = GetColumnIndex(SubtitleColumn.Region); + if (idx >= 0) + { + Columns[idx].Width = _settings.General.ListViewRegionWidth; + } + + idx = GetColumnIndex(SubtitleColumn.Text); + if (idx >= 0) + { + Columns[idx].Width = _settings.General.ListViewTextWidth; + } + + _saveColumnWidthChanges = true; + } + else if (parentForm != null) + { + using (var graphics = parentForm.CreateGraphics()) + { + var timestampSizeF = graphics.MeasureString(new TimeCode(0, 0, 33, 527).ToDisplayString(), Font); + var timestampWidth = (int)(timestampSizeF.Width + 0.5) + 11; + + var idx = GetColumnIndex(SubtitleColumn.Start); + if (idx >= 0) + { + Columns[idx].Width = timestampWidth; + } + + idx = GetColumnIndex(SubtitleColumn.End); + if (idx >= 0) + { + Columns[idx].Width = timestampWidth; + } + + idx = GetColumnIndex(SubtitleColumn.Duration); + if (idx >= 0) + { + Columns[idx].Width = (int)(timestampWidth * 0.8); + } + } + } + + SubtitleListViewLastColumnFill(this, null); + } + + public SubtitleListView() + { + DoubleBuffered = true; + UseSyntaxColoring = true; + Font = new Font("Tahoma", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + AllowColumnReorder = true; + HeaderStyle = ColumnHeaderStyle.Nonclickable; + + ColumnIndexNumber = -1; + ColumnIndexStart = -1; + ColumnIndexEnd = -1; + ColumnIndexDuration = -1; + ColumnIndexWpm = -1; + ColumnIndexCps = -1; + ColumnIndexGap = -1; + ColumnIndexActor = -1; + ColumnIndexRegion = -1; + ColumnIndexText = -1; + ColumnIndexTextAlternate = -1; + ColumnIndexExtra = -1; + ColumnIndexNetwork = -1; + + SubtitleColumns = new List + { + SubtitleColumn.Number, + SubtitleColumn.Start, + SubtitleColumn.End, + SubtitleColumn.Duration, + SubtitleColumn.Text + }; + UpdateColumnIndexes(); + + foreach (var c in SubtitleColumns) + { + switch (c) + { + case SubtitleColumn.Number: + Columns.Add(new ColumnHeader { Width = 50 }); + break; + case SubtitleColumn.Start: + Columns.Add(new ColumnHeader { Width = 80 }); + break; + case SubtitleColumn.End: + Columns.Add(new ColumnHeader { Width = 80 }); + break; + case SubtitleColumn.Duration: + Columns.Add(new ColumnHeader { Width = 55 }); + break; + case SubtitleColumn.CharactersPerSeconds: + Columns.Add(new ColumnHeader { Width = 60 }); + break; + case SubtitleColumn.WordsPerMinute: + Columns.Add(new ColumnHeader { Width = 65 }); + break; + case SubtitleColumn.Gap: + Columns.Add(new ColumnHeader { Width = 60 }); + break; + case SubtitleColumn.Actor: + Columns.Add(new ColumnHeader { Width = 80 }); + break; + case SubtitleColumn.Region: + Columns.Add(new ColumnHeader { Width = 60 }); + break; + case SubtitleColumn.Text: + Columns.Add(new ColumnHeader { Width = 300 }); + break; + } + } + + if (Configuration.Settings != null && !Configuration.Settings.Tools.ListViewShowColumnEndTime) + { + HideColumn(SubtitleColumn.End); + } + + if (Configuration.Settings != null && !Configuration.Settings.Tools.ListViewShowColumnDuration) + { + HideColumn(SubtitleColumn.Duration); + } + + if (Configuration.Settings != null && Configuration.Settings.Tools.ListViewShowColumnCharsPerSec) + { + ShowCharsSecColumn(Configuration.Settings.Language.General.CharsPerSec); + } + + if (Configuration.Settings != null && Configuration.Settings.Tools.ListViewShowColumnWordsPerMin) + { + ShowWordsMinColumn(Configuration.Settings.Language.General.WordsPerMin); + } + + if (Configuration.Settings != null && Configuration.Settings.Tools.ListViewShowColumnGap) + { + ShowGapColumn(Configuration.Settings.Language.General.Gap); + } + + SubtitleListViewLastColumnFill(this, null); + + FullRowSelect = true; + View = View.Details; + Resize += SubtitleListViewLastColumnFill; + GridLines = true; + ColumnWidthChanged += SubtitleListViewColumnWidthChanged; + OwnerDraw = true; + DrawItem += SubtitleListView_DrawItem; + DrawSubItem += SubtitleListView_DrawSubItem; + DrawColumnHeader += SubtitleListView_DrawColumnHeader; + } + + private void UpdateColumnIndexes() + { + ColumnIndexNumber = GetColumnIndex(SubtitleColumn.Number); + ColumnIndexStart = GetColumnIndex(SubtitleColumn.Start); + ColumnIndexEnd = GetColumnIndex(SubtitleColumn.End); + ColumnIndexDuration = GetColumnIndex(SubtitleColumn.Duration); + ColumnIndexCps = GetColumnIndex(SubtitleColumn.CharactersPerSeconds); + ColumnIndexWpm = GetColumnIndex(SubtitleColumn.WordsPerMinute); + ColumnIndexGap = GetColumnIndex(SubtitleColumn.Gap); + ColumnIndexActor = GetColumnIndex(SubtitleColumn.Actor); + ColumnIndexRegion = GetColumnIndex(SubtitleColumn.Region); + ColumnIndexText = GetColumnIndex(SubtitleColumn.Text); + ColumnIndexTextAlternate = GetColumnIndex(SubtitleColumn.TextAlternate); + ColumnIndexExtra = GetColumnIndex(SubtitleColumn.Extra); + ColumnIndexNetwork = GetColumnIndex(SubtitleColumn.Network); + } + + private void SubtitleListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) + { + e.DrawDefault = true; + } + + private void SubtitleListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) + { + Color backgroundColor = Items[e.ItemIndex].SubItems[e.ColumnIndex].BackColor; + if (Focused && backgroundColor == BackColor || RightToLeftLayout) + { + e.DrawDefault = true; + return; + } + + using (var sf = new StringFormat()) + { + switch (e.Header.TextAlign) + { + case HorizontalAlignment.Center: + sf.Alignment = StringAlignment.Center; + break; + case HorizontalAlignment.Right: + sf.Alignment = StringAlignment.Far; + break; + } + + if (e.Item.Selected) + { + + Rectangle rect = e.Bounds; + if (Configuration.Settings != null) + { + backgroundColor = backgroundColor == BackColor ? Configuration.Settings.Tools.ListViewUnfocusedSelectedColor : GetCustomColor(backgroundColor); + var sb = new SolidBrush(backgroundColor); + e.Graphics.FillRectangle(sb, rect); + } + else + { + e.Graphics.FillRectangle(Brushes.LightBlue, rect); + } + + int addX = 0; + + if (e.ColumnIndex == 0 && StateImageList?.Images.Count > 0) + { + addX = 18; + } + + if (e.ColumnIndex == 0 && e.Item.StateImageIndex >= 0 && StateImageList?.Images.Count > e.Item.StateImageIndex) + { + e.Graphics.DrawImage(StateImageList.Images[e.Item.StateImageIndex], new Rectangle(rect.X + 4, rect.Y + 2, 16, 16)); + } + + if (Columns[e.ColumnIndex].TextAlign == HorizontalAlignment.Right) + { + var stringWidth = (int)e.Graphics.MeasureString(e.Item.SubItems[e.ColumnIndex].Text, _subtitleFont).Width; + TextRenderer.DrawText(e.Graphics, e.Item.SubItems[e.ColumnIndex].Text, _subtitleFont, new Point(e.Bounds.Right - stringWidth - 7, e.Bounds.Top + 2), e.Item.ForeColor, TextFormatFlags.NoPrefix); + } + else + { + TextRenderer.DrawText(e.Graphics, e.Item.SubItems[e.ColumnIndex].Text, _subtitleFont, new Point(e.Bounds.Left + 3 + addX, e.Bounds.Top + 2), e.Item.ForeColor, TextFormatFlags.NoPrefix); + } + } + else + { + e.DrawDefault = true; + } + } + } + + private static Color GetCustomColor(Color color) + { + int r = Math.Max(color.R - 39, 0); + int g = Math.Max(color.G - 39, 0); + int b = Math.Max(color.B - 39, 0); + return Color.FromArgb(color.A, r, g, b); + } + + private void SubtitleListView_DrawItem(object sender, DrawListViewItemEventArgs e) + { + if (!Focused && (e.State & ListViewItemStates.Selected) != 0) + { + if (e.Item.Focused) + { + e.DrawFocusRectangle(); + } + } + else + { + e.DrawDefault = true; + } + } + + private void SubtitleListViewColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e) + { + if (_settings != null && _saveColumnWidthChanges) + { + if (e.ColumnIndex == ColumnIndexNumber) + { + Configuration.Settings.General.ListViewNumberWidth = Columns[ColumnIndexNumber].Width; + } + else if (e.ColumnIndex == ColumnIndexStart) + { + Configuration.Settings.General.ListViewStartWidth = Columns[ColumnIndexStart].Width; + } + else if (e.ColumnIndex == ColumnIndexEnd) + { + Configuration.Settings.General.ListViewEndWidth = Columns[ColumnIndexEnd].Width; + } + else if (e.ColumnIndex == ColumnIndexDuration) + { + Configuration.Settings.General.ListViewDurationWidth = Columns[ColumnIndexDuration].Width; + } + else if (e.ColumnIndex == ColumnIndexCps) + { + Configuration.Settings.General.ListViewCpsWidth = Columns[ColumnIndexCps].Width; + } + else if (e.ColumnIndex == ColumnIndexWpm) + { + Configuration.Settings.General.ListViewWpmWidth = Columns[ColumnIndexWpm].Width; + } + else if (e.ColumnIndex == ColumnIndexGap) + { + Configuration.Settings.General.ListViewGapWidth = Columns[ColumnIndexGap].Width; + } + else if (e.ColumnIndex == ColumnIndexActor) + { + Configuration.Settings.General.ListViewActorWidth = Columns[ColumnIndexActor].Width; + } + else if (e.ColumnIndex == ColumnIndexRegion) + { + Configuration.Settings.General.ListViewRegionWidth = Columns[ColumnIndexRegion].Width; + } + if (e.ColumnIndex == ColumnIndexText) + { + Configuration.Settings.General.ListViewTextWidth = Columns[ColumnIndexText].Width; + } + } + } + + public void AutoSizeColumns() + { + var numberIdx = GetColumnIndex(SubtitleColumn.Number); + if (numberIdx >= 0) + { + Columns[numberIdx].Width = 50; + Columns[numberIdx].Width = 50; + } + + var startIdx = GetColumnIndex(SubtitleColumn.Start); + var endIdx = GetColumnIndex(SubtitleColumn.End); + var durationIdx = GetColumnIndex(SubtitleColumn.Duration); + int timeStampWidth; + try + { + using (var graphics = CreateGraphics()) + { + var timestampSizeF = graphics.MeasureString(new TimeCode(0, 0, 33, 527).ToDisplayString(), Font); + timeStampWidth = (int)(timestampSizeF.Width + 0.5) + 11; + } + } + catch + { + timeStampWidth = 65; + } + if (startIdx >= 0) + { + Columns[startIdx].Width = timeStampWidth; + } + if (endIdx >= 0) + { + Columns[endIdx].Width = timeStampWidth; + } + if (durationIdx >= 0) + { + Columns[durationIdx].Width = (int)(timeStampWidth * 0.8); + } + + var cpsIdx = GetColumnIndex(SubtitleColumn.CharactersPerSeconds); + if (cpsIdx >= 0) + { + Columns[cpsIdx].Width = 60; + Columns[cpsIdx].Width = 60; + } + + var wpmIdx = GetColumnIndex(SubtitleColumn.WordsPerMinute); + if (wpmIdx >= 0) + { + Columns[wpmIdx].Width = 65; + Columns[wpmIdx].Width = 65; + } + + var gapIdx = GetColumnIndex(SubtitleColumn.Gap); + if (gapIdx >= 0) + { + Columns[gapIdx].Width = 60; + Columns[gapIdx].Width = 60; + } + + var actorIdx = GetColumnIndex(SubtitleColumn.Actor); + if (actorIdx >= 0) + { + Columns[actorIdx].Width = 80; + Columns[actorIdx].Width = 80; + } + + var regionIdx = GetColumnIndex(SubtitleColumn.Region); + if (regionIdx >= 0) + { + Columns[regionIdx].Width = 60; + Columns[regionIdx].Width = 60; + } + + int w = 0; + for (int index = 0; index < SubtitleColumns.Count; index++) + { + var column = SubtitleColumns[index]; + int cw = Columns[index].Width; + if (column != SubtitleColumn.Text && column != SubtitleColumn.TextAlternate) + { + w += cw; + } + } + int lengthAvailable = Width - w; + if (ColumnIndexTextAlternate >= 0) + { + lengthAvailable = lengthAvailable / 2; + Columns[ColumnIndexTextAlternate].Width = lengthAvailable; + Columns[ColumnIndexTextAlternate].Width = lengthAvailable; + Columns[ColumnIndexTextAlternate].Width = lengthAvailable; + } + Columns[ColumnIndexText].Width = lengthAvailable; + Columns[ColumnIndexText].Width = lengthAvailable; + Columns[ColumnIndexText].Width = lengthAvailable; + SubtitleListViewLastColumnFill(this, null); + } + + public void AutoSizeAllColumns(Form parentForm) + { + InitializeTimestampColumnWidths(parentForm); + + var numberIdx = GetColumnIndex(SubtitleColumn.Number); + if (numberIdx >= 0) + { + if (_settings != null && _settings.General.ListViewColumnsRememberSize && _settings.General.ListViewNumberWidth > 1) + { + Columns[numberIdx].Width = _settings.General.ListViewNumberWidth; + } + else + { + Columns[numberIdx].Width = 50; + } + } + + var startIdx = GetColumnIndex(SubtitleColumn.Start); + var endIdx = GetColumnIndex(SubtitleColumn.End); + int timeStampWidth; + try + { + using (var graphics = CreateGraphics()) + { + var timestampSizeF = graphics.MeasureString(new TimeCode(0, 0, 33, 527).ToDisplayString(), Font); + timeStampWidth = (int)(timestampSizeF.Width + 0.5) + 11; + } + } + catch + { + timeStampWidth = 65; + } + if (startIdx >= 0) + { + if (_settings != null && _settings.General.ListViewColumnsRememberSize && _settings.General.ListViewStartWidth > 1) + { + Columns[startIdx].Width = _settings.General.ListViewStartWidth; + } + else + { + Columns[startIdx].Width = timeStampWidth; + } + } + if (endIdx >= 0) + { + if (_settings != null && _settings.General.ListViewColumnsRememberSize && _settings.General.ListViewEndWidth > 1) + { + Columns[endIdx].Width = _settings.General.ListViewEndWidth; + } + else + { + Columns[endIdx].Width = timeStampWidth; + } + } + + int w = 0; + for (int index = 0; index < SubtitleColumns.Count; index++) + { + var column = SubtitleColumns[index]; + int cw = Columns[index].Width; + if (cw < 10 || column == SubtitleColumn.Extra || column == SubtitleColumn.Network) + { + cw = 55; + if (column == SubtitleColumn.CharactersPerSeconds) + { + cw = 65; + } + else if (column == SubtitleColumn.WordsPerMinute) + { + cw = 70; + } + else if (column == SubtitleColumn.Gap) + { + cw = 60; + } + else if (column == SubtitleColumn.Actor) + { + cw = 70; + } + else if (column == SubtitleColumn.Region) + { + cw = 60; + } + else if (column != SubtitleColumn.Number) + { + cw = 120; + } + + Columns[index].Width = cw; + Columns[index].Width = cw; + Columns[index].Width = cw; + } + if (column != SubtitleColumn.Text && column != SubtitleColumn.TextAlternate) + { + w += cw; + } + } + + int lengthAvailable = Width - w; + if (ColumnIndexTextAlternate >= 0 && Columns.Count > ColumnIndexTextAlternate) + { + lengthAvailable = lengthAvailable / 2; + Columns[ColumnIndexTextAlternate].Width = lengthAvailable; + Columns[ColumnIndexTextAlternate].Width = lengthAvailable; + Columns[ColumnIndexTextAlternate].Width = lengthAvailable; + } + Columns[ColumnIndexText].Width = lengthAvailable; + Columns[ColumnIndexText].Width = lengthAvailable; + Columns[ColumnIndexText].Width = lengthAvailable; + SubtitleListViewLastColumnFill(this, null); + } + + public void ShowEndColumn(string title) + { + if (GetColumnIndex(SubtitleColumn.End) == -1) + { + var ch = new ColumnHeader { Text = title, TextAlign = RightToLeftLayout ? HorizontalAlignment.Right : HorizontalAlignment.Left }; + if (ColumnIndexStart >= 0) + { + SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.End); + Columns.Insert(ColumnIndexStart + 1, ch); + } + else if (ColumnIndexNumber >= 0) + { + SubtitleColumns.Insert(ColumnIndexNumber + 1, SubtitleColumn.End); + Columns.Insert(ColumnIndexStart + 1, ch); + } + else + { + SubtitleColumns.Add(SubtitleColumn.End); + Columns.Insert(0, ch); + } + UpdateColumnIndexes(); + + try + { + using (var graphics = Parent.CreateGraphics()) + { + var timestampSizeF = graphics.MeasureString(new TimeCode(0, 0, 33, 527).ToDisplayString(), Font); + var timestampWidth = (int)(timestampSizeF.Width + 0.5) + 11; + Columns[ColumnIndexEnd].Width = timestampWidth; + } + } + catch + { + Columns[ColumnIndexEnd].Width = 65; + } + + AutoSizeAllColumns(null); + } + } + + public void ShowDurationColumn(string title) + { + if (GetColumnIndex(SubtitleColumn.Duration) == -1) + { + var ch = new ColumnHeader { Text = title, TextAlign = RightToLeftLayout ? HorizontalAlignment.Right : HorizontalAlignment.Left }; + if (ColumnIndexEnd >= 0) + { + SubtitleColumns.Insert(ColumnIndexEnd + 1, SubtitleColumn.Duration); + Columns.Insert(ColumnIndexEnd + 1, ch); + } + else if (ColumnIndexStart >= 0) + { + SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.Duration); + Columns.Insert(ColumnIndexStart + 1, ch); + } + else if (ColumnIndexNumber >= 0) + { + SubtitleColumns.Insert(ColumnIndexNumber + 1, SubtitleColumn.Duration); + Columns.Insert(ColumnIndexStart + 1, ch); + } + else + { + SubtitleColumns.Add(SubtitleColumn.Duration); + Columns.Insert(0, ch); + } + UpdateColumnIndexes(); + + try + { + using (var graphics = Parent.CreateGraphics()) + { + var timestampSizeF = graphics.MeasureString(new TimeCode(0, 0, 33, 527).ToDisplayString(), Font); + var timestampWidth = (int)(timestampSizeF.Width + 0.5) + 11; + Columns[ColumnIndexDuration].Width = (int)(timestampWidth * 0.8); + } + } + catch + { + Columns[ColumnIndexDuration].Width = 55; + } + + AutoSizeAllColumns(null); + } + } + + public void ShowAlternateTextColumn(string title) + { + if (GetColumnIndex(SubtitleColumn.TextAlternate) == -1) + { + if (ColumnIndexText >= 0) + { + SubtitleColumns.Insert(ColumnIndexText + 1, SubtitleColumn.TextAlternate); + Columns.Insert(ColumnIndexText + 1, new ColumnHeader { Text = title }); + } + else + { + SubtitleColumns.Add(SubtitleColumn.TextAlternate); + Columns.Add(new ColumnHeader { Text = title }); + } + UpdateColumnIndexes(); + Columns[ColumnIndexTextAlternate].Width = 300; + Columns[ColumnIndexTextAlternate].Width = 300; + Columns[ColumnIndexTextAlternate].Width = 300; + AutoSizeAllColumns(null); + } + else + { + Columns[ColumnIndexTextAlternate].Text = title; + } + } + + public void ShowExtraColumn(string title) + { + if (GetColumnIndex(SubtitleColumn.Extra) == -1) + { + if (ColumnIndexNetwork >= 0) + { + SubtitleColumns.Insert(ColumnIndexNetwork, SubtitleColumn.Extra); + Columns.Insert(ColumnIndexNetwork, new ColumnHeader { Text = title, Width = 120 }); + } + else + { + SubtitleColumns.Add(SubtitleColumn.Extra); + Columns.Add(new ColumnHeader { Text = title, Width = 120 }); + } + UpdateColumnIndexes(); + Columns[ColumnIndexExtra].Width = 120; + Columns[ColumnIndexExtra].Width = 120; + Columns[ColumnIndexExtra].Width = 120; + AutoSizeAllColumns(null); + } + else + { + Columns[ColumnIndexExtra].Text = title; + } + } + + public void ShowNetworkColumn(string title) + { + if (GetColumnIndex(SubtitleColumn.Network) == -1) + { + SubtitleColumns.Add(SubtitleColumn.Network); + Columns.Add(new ColumnHeader { Text = title, Width = 120 }); + UpdateColumnIndexes(); + AutoSizeAllColumns(null); + } + } + + public void ShowCharsSecColumn(string title) + { + if (GetColumnIndex(SubtitleColumn.CharactersPerSeconds) == -1) + { + var ch = new ColumnHeader { Text = title, TextAlign = RightToLeftLayout ? HorizontalAlignment.Left : HorizontalAlignment.Right }; + if (ColumnIndexDuration >= 0) + { + SubtitleColumns.Insert(ColumnIndexDuration + 1, SubtitleColumn.CharactersPerSeconds); + Columns.Insert(ColumnIndexDuration + 1, ch); + } + else if (ColumnIndexEnd >= 0) + { + SubtitleColumns.Insert(ColumnIndexEnd + 1, SubtitleColumn.CharactersPerSeconds); + Columns.Insert(ColumnIndexEnd + 1, ch); + } + else if (ColumnIndexStart >= 0) + { + SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.CharactersPerSeconds); + Columns.Insert(ColumnIndexStart + 1, ch); + } + else + { + SubtitleColumns.Add(SubtitleColumn.CharactersPerSeconds); + Columns.Add(ch); + } + UpdateColumnIndexes(); + Columns[ColumnIndexCps].Width = 65; + Columns[ColumnIndexCps].Width = 65; + AutoSizeAllColumns(null); + } + } + + public void ShowWordsMinColumn(string title) + { + if (GetColumnIndex(SubtitleColumn.WordsPerMinute) == -1) + { + var ch = new ColumnHeader { Text = title, TextAlign = RightToLeftLayout ? HorizontalAlignment.Left : HorizontalAlignment.Right }; + if (ColumnIndexCps >= 0) + { + SubtitleColumns.Insert(ColumnIndexCps + 1, SubtitleColumn.WordsPerMinute); + Columns.Insert(ColumnIndexCps + 1, ch); + } + else if (ColumnIndexDuration >= 0) + { + SubtitleColumns.Insert(ColumnIndexDuration + 1, SubtitleColumn.WordsPerMinute); + Columns.Insert(ColumnIndexDuration + 1, ch); + } + else if (ColumnIndexEnd >= 0) + { + SubtitleColumns.Insert(ColumnIndexEnd + 1, SubtitleColumn.WordsPerMinute); + Columns.Insert(ColumnIndexEnd + 1, ch); + } + else if (ColumnIndexStart >= 0) + { + SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.WordsPerMinute); + Columns.Insert(ColumnIndexStart + 1, ch); + } + else + { + SubtitleColumns.Add(SubtitleColumn.WordsPerMinute); + Columns.Add(ch); + } + UpdateColumnIndexes(); + Columns[ColumnIndexWpm].Width = 70; + Columns[ColumnIndexWpm].Width = 70; + AutoSizeAllColumns(null); + } + } + + public void ShowGapColumn(string title) + { + if (GetColumnIndex(SubtitleColumn.Gap) == -1) + { + var ch = new ColumnHeader { Text = title }; + if (ColumnIndexWpm >= 0) + { + SubtitleColumns.Insert(ColumnIndexWpm + 1, SubtitleColumn.Gap); + Columns.Insert(ColumnIndexWpm + 1, ch); + } + else if (ColumnIndexCps >= 0) + { + SubtitleColumns.Insert(ColumnIndexCps + 1, SubtitleColumn.Gap); + Columns.Insert(ColumnIndexCps + 1, ch); + } + else if (ColumnIndexDuration >= 0) + { + SubtitleColumns.Insert(ColumnIndexDuration + 1, SubtitleColumn.Gap); + Columns.Insert(ColumnIndexDuration + 1, ch); + } + else if (ColumnIndexEnd >= 0) + { + SubtitleColumns.Insert(ColumnIndexEnd + 1, SubtitleColumn.Gap); + Columns.Insert(ColumnIndexEnd + 1, ch); + } + else if (ColumnIndexStart >= 0) + { + SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.Gap); + Columns.Insert(ColumnIndexStart + 1, ch); + } + else + { + SubtitleColumns.Add(SubtitleColumn.Gap); + Columns.Add(ch); + } + UpdateColumnIndexes(); + Columns[ColumnIndexGap].Width = 80; + Columns[ColumnIndexGap].Width = 80; + AutoSizeAllColumns(null); + } + } + + public void ShowActorColumn(string title) + { + if (GetColumnIndex(SubtitleColumn.Actor) == -1) + { + var ch = new ColumnHeader { Text = title }; + if (ColumnIndexGap >= 0) + { + SubtitleColumns.Insert(ColumnIndexGap + 1, SubtitleColumn.Actor); + Columns.Insert(ColumnIndexGap + 1, ch); + } + else if (ColumnIndexWpm >= 0) + { + SubtitleColumns.Insert(ColumnIndexWpm + 1, SubtitleColumn.Actor); + Columns.Insert(ColumnIndexWpm + 1, ch); + } + else if (ColumnIndexCps >= 0) + { + SubtitleColumns.Insert(ColumnIndexCps + 1, SubtitleColumn.Actor); + Columns.Insert(ColumnIndexCps + 1, ch); + } + else if (ColumnIndexDuration >= 0) + { + SubtitleColumns.Insert(ColumnIndexDuration + 1, SubtitleColumn.Actor); + Columns.Insert(ColumnIndexDuration + 1, ch); + } + else if (ColumnIndexEnd >= 0) + { + SubtitleColumns.Insert(ColumnIndexEnd + 1, SubtitleColumn.Actor); + Columns.Insert(ColumnIndexEnd + 1, ch); + } + else if (ColumnIndexStart >= 0) + { + SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.Actor); + Columns.Insert(ColumnIndexStart + 1, ch); + } + else + { + SubtitleColumns.Add(SubtitleColumn.Actor); + Columns.Add(ch); + } + UpdateColumnIndexes(); + Columns[ColumnIndexActor].Width = 80; + Columns[ColumnIndexActor].Width = 80; + AutoSizeAllColumns(null); + } + else + { + Columns[GetColumnIndex(SubtitleColumn.Actor)].Text = title; + } + } + + public void ShowRegionColumn(string title) + { + if (GetColumnIndex(SubtitleColumn.Region) == -1) + { + var ch = new ColumnHeader { Text = title }; + if (ColumnIndexActor >= 0) + { + SubtitleColumns.Insert(ColumnIndexActor + 1, SubtitleColumn.Region); + Columns.Insert(ColumnIndexActor + 1, ch); + } + else if (ColumnIndexGap >= 0) + { + SubtitleColumns.Insert(ColumnIndexGap + 1, SubtitleColumn.Region); + Columns.Insert(ColumnIndexGap + 1, ch); + } + else if (ColumnIndexWpm >= 0) + { + SubtitleColumns.Insert(ColumnIndexWpm + 1, SubtitleColumn.Region); + Columns.Insert(ColumnIndexWpm + 1, ch); + } + else if (ColumnIndexCps >= 0) + { + SubtitleColumns.Insert(ColumnIndexCps + 1, SubtitleColumn.Region); + Columns.Insert(ColumnIndexCps + 1, ch); + } + else if (ColumnIndexDuration >= 0) + { + SubtitleColumns.Insert(ColumnIndexDuration + 1, SubtitleColumn.Region); + Columns.Insert(ColumnIndexDuration + 1, ch); + } + else if (ColumnIndexEnd >= 0) + { + SubtitleColumns.Insert(ColumnIndexEnd + 1, SubtitleColumn.Region); + Columns.Insert(ColumnIndexEnd + 1, ch); + } + else if (ColumnIndexStart >= 0) + { + SubtitleColumns.Insert(ColumnIndexStart + 1, SubtitleColumn.Region); + Columns.Insert(ColumnIndexStart + 1, ch); + } + else + { + SubtitleColumns.Add(SubtitleColumn.Region); + Columns.Add(ch); + } + UpdateColumnIndexes(); + Columns[ColumnIndexRegion].Width = 80; + Columns[ColumnIndexRegion].Width = 80; + AutoSizeAllColumns(null); + } + } + + public void HideColumn(SubtitleColumn column) + { + var idx = GetColumnIndex(column); + if (idx >= 0) + { + SubtitleColumns.RemoveAt(idx); + UpdateColumnIndexes(); + Columns.RemoveAt(idx); + AutoSizeAllColumns(null); + } + } + + public void SubtitleListViewLastColumnFill(object sender, EventArgs e) + { + int width = 0; + for (int i = 0; i < Columns.Count - 1; i++) + { + width += Columns[i].Width; + } + if (Columns.Count > 0) + { + Columns[Columns.Count - 1].Width = Width - (width + 25); + } + } + + public void SaveFirstVisibleIndex() + { + if (TopItem != null) + { + FirstVisibleIndex = Items.Count > 0 ? TopItem.Index : -1; + } + } + + private void RestoreFirstVisibleIndex() + { + if (IsValidIndex(FirstVisibleIndex)) + { + if (FirstVisibleIndex + 1 < Items.Count) + { + FirstVisibleIndex++; + } + + Items[Items.Count - 1].EnsureVisible(); + Items[FirstVisibleIndex].EnsureVisible(); + } + } + + internal void Fill(Subtitle subtitle, Subtitle subtitleAlternate = null) + { + if (subtitleAlternate == null || subtitleAlternate.Paragraphs.Count == 0) + { + Fill(subtitle.Paragraphs); + } + else + { + Fill(subtitle.Paragraphs, subtitleAlternate.Paragraphs); + } + } + + internal void Fill(List paragraphs) + { + SaveFirstVisibleIndex(); + BeginUpdate(); + Items.Clear(); + var x = ListViewItemSorter; + ListViewItemSorter = null; + var font = new Font(_subtitleFontName, SubtitleFontSize, GetFontStyle()); + var items = new ListViewItem[paragraphs.Count]; + for (var index = 0; index < paragraphs.Count; index++) + { + var paragraph = paragraphs[index]; + Paragraph next = null; + if (index + 1 < paragraphs.Count) + { + next = paragraphs[index + 1]; + } + items[index] = MakeListViewItem(paragraph, next, null, font); + } + + Items.AddRange(items); + + if (UseSyntaxColoring && _settings != null) + { + for (var index = 0; index < paragraphs.Count; index++) + { + var paragraph = paragraphs[index]; + var item = items[index]; + SyntaxColorListViewItem(paragraphs, index, paragraph, item); + } + } + + ListViewItemSorter = x; + EndUpdate(); + + if (FirstVisibleIndex == 0) + { + FirstVisibleIndex = -1; + } + } + + internal void Fill(List paragraphs, List paragraphsAlternate) + { + SaveFirstVisibleIndex(); + BeginUpdate(); + Items.Clear(); + var x = ListViewItemSorter; + ListViewItemSorter = null; + var items = new ListViewItem[paragraphs.Count]; + var font = new Font(_subtitleFontName, SubtitleFontSize, GetFontStyle()); + for (var index = 0; index < paragraphs.Count; index++) + { + var paragraph = paragraphs[index]; + Paragraph alternate = Utilities.GetOriginalParagraph(index, paragraph, paragraphsAlternate); + Paragraph next = null; + if (index + 1 < paragraphs.Count) + { + next = paragraphs[index + 1]; + } + items[index] = MakeListViewItem(paragraph, next, alternate, font); + } + + Items.AddRange(items); + + if (UseSyntaxColoring && _settings != null) + { + for (var index = 0; index < paragraphs.Count; index++) + { + var paragraph = paragraphs[index]; + var item = items[index]; + SyntaxColorListViewItem(paragraphs, index, paragraph, item); + } + } + + ListViewItemSorter = x; + EndUpdate(); + + if (FirstVisibleIndex == 0) + { + FirstVisibleIndex = -1; + } + } + + public void SyntaxColorAllLines(Subtitle subtitle) + { + if (UseSyntaxColoring && _settings != null) + { + for (int index = 0; index < subtitle.Paragraphs.Count; index++) + { + var paragraph = subtitle.Paragraphs[index]; + SyntaxColorListViewItem(subtitle.Paragraphs, index, paragraph, Items[index]); + } + } + } + + public void SyntaxColorLine(List paragraphs, int i, Paragraph paragraph) + { + if (UseSyntaxColoring && _settings != null && IsValidIndex(i)) + { + var item = Items[i]; + SyntaxColorListViewItem(paragraphs, i, paragraph, item); + } + } + + private void SyntaxColorListViewItem(List paragraphs, int i, Paragraph paragraph, ListViewItem item) + { + if (item.UseItemStyleForSubItems) + { + item.UseItemStyleForSubItems = false; + item.SubItems[ColumnIndexDuration].BackColor = BackColor; + } + if (ColumnIndexCps >= 0) + { + item.SubItems[ColumnIndexCps].BackColor = BackColor; + } + if (ColumnIndexWpm >= 0) + { + item.SubItems[ColumnIndexWpm].BackColor = paragraph.WordsPerMinute > Configuration.Settings.General.SubtitleMaximumWordsPerMinute ? Configuration.Settings.Tools.ListViewSyntaxErrorColor : BackColor; + } + if (ColumnIndexDuration >= 0) + { + item.SubItems[ColumnIndexDuration].BackColor = BackColor; + } + + if (_settings.Tools.ListViewSyntaxColorDurationSmall) + { + double charactersPerSecond = Utilities.GetCharactersPerSecond(paragraph); + if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds) + { + if (ColumnIndexCps >= 0) + { + item.SubItems[ColumnIndexCps].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + } + else if (ColumnIndexDuration >= 0) + { + item.SubItems[ColumnIndexDuration].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + } + } + if (paragraph.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds && ColumnIndexDuration >= 0) + { + item.SubItems[ColumnIndexDuration].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + } + } + if (_settings.Tools.ListViewSyntaxColorDurationBig && + paragraph.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds && + ColumnIndexDuration >= 0) + { + item.SubItems[ColumnIndexDuration].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + } + + if (_settings.Tools.ListViewSyntaxColorOverlap && i > 0 && i < paragraphs.Count && ColumnIndexEnd >= 0) + { + Paragraph prev = paragraphs[i - 1]; + if (paragraph.StartTime.TotalMilliseconds < prev.EndTime.TotalMilliseconds && !prev.EndTime.IsMaxTime) + { + Items[i - 1].SubItems[ColumnIndexEnd].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + item.SubItems[ColumnIndexStart].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + } + else + { + Items[i - 1].SubItems[ColumnIndexEnd].BackColor = BackColor; + item.SubItems[ColumnIndexStart].BackColor = BackColor; + } + } + + if (_settings.Tools.ListViewSyntaxColorGap && i >= 0 && i < paragraphs.Count - 1 && ColumnIndexGap >= 0) + { + Paragraph next = paragraphs[i + 1]; + if (next.StartTime.TotalMilliseconds - paragraph.EndTime.TotalMilliseconds < Configuration.Settings.General.MinimumMillisecondsBetweenLines) + { + item.SubItems[ColumnIndexGap].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + } + else + { + item.SubItems[ColumnIndexGap].BackColor = BackColor; + } + } + + if (ColumnIndexTextAlternate >= 0 && item.SubItems.Count >= ColumnIndexTextAlternate) + { + item.SubItems[ColumnIndexTextAlternate].BackColor = BackColor; + } + + if (ColumnIndexText >= item.SubItems.Count) + { + return; + } + + if (_settings.Tools.ListViewSyntaxColorLongLines) + { + string s = HtmlUtil.RemoveHtmlTags(paragraph.Text, true); + foreach (string line in s.SplitToLines()) + { + if (line.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength) + { + item.SubItems[ColumnIndexText].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + return; + } + } + int noOfLines = paragraph.NumberOfLines; + if (s.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) <= Configuration.Settings.General.SubtitleLineMaximumLength * noOfLines) + { + if (noOfLines > Configuration.Settings.General.MaxNumberOfLines && _settings.Tools.ListViewSyntaxMoreThanXLines) + { + item.SubItems[ColumnIndexText].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + } + else + { + item.SubItems[ColumnIndexText].BackColor = BackColor; + } + } + else + { + item.SubItems[ColumnIndexText].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + } + } + if (_settings.Tools.ListViewSyntaxColorWideLines) + { + string s = HtmlUtil.RemoveHtmlTags(paragraph.Text, true); + foreach (string line in s.SplitToLines()) + { + if (TextWidth.CalcPixelWidth(line) > Configuration.Settings.General.SubtitleLineMaximumPixelWidth) + { + item.SubItems[ColumnIndexText].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + return; + } + } + } + if (_settings.Tools.ListViewSyntaxMoreThanXLines && + item.SubItems[ColumnIndexText].BackColor != Configuration.Settings.Tools.ListViewSyntaxErrorColor) + { + if (paragraph.NumberOfLines > Configuration.Settings.General.MaxNumberOfLines) + { + item.SubItems[ColumnIndexText].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + } + } + } + + private string GetDisplayTime(TimeCode timeCode) + { + if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) + { + return new TimeCode(timeCode.TotalMilliseconds + Configuration.Settings.General.CurrentVideoOffsetInMs).ToDisplayString(); + } + + return timeCode.ToDisplayString(); + } + + private ListViewItem MakeListViewItem(Paragraph paragraph, Paragraph next, Paragraph paragraphAlternate, Font font) + { + var item = new ListViewItem(paragraph.Number.ToString(CultureInfo.InvariantCulture)) { Tag = paragraph, UseItemStyleForSubItems = false }; + foreach (var column in SubtitleColumns) + { + switch (column) + { + case SubtitleColumn.Start: + item.SubItems.Add(GetDisplayTime(paragraph.StartTime)); + break; + case SubtitleColumn.End: + item.SubItems.Add(GetDisplayTime(paragraph.EndTime)); + break; + case SubtitleColumn.Duration: + item.SubItems.Add(paragraph.Duration.ToShortDisplayString()); + break; + case SubtitleColumn.CharactersPerSeconds: + item.SubItems.Add($"{Utilities.GetCharactersPerSecond(paragraph):0.00}"); + break; + case SubtitleColumn.WordsPerMinute: + item.SubItems.Add($"{paragraph.WordsPerMinute:0.00}"); + break; + case SubtitleColumn.Gap: + item.SubItems.Add(GetGap(paragraph, next)); + break; + case SubtitleColumn.Actor: + item.SubItems.Add(paragraph.Actor); + break; + case SubtitleColumn.Region: + item.SubItems.Add(paragraph.Region); + break; + case SubtitleColumn.Text: + item.SubItems.Add(paragraph.Text.Replace(Environment.NewLine, _lineSeparatorString)); + break; + case SubtitleColumn.TextAlternate: + var text = paragraphAlternate != null ? paragraphAlternate.Text : string.Empty; + item.SubItems.Add(text.Replace(Environment.NewLine, _lineSeparatorString)); + break; + case SubtitleColumn.Extra: + item.SubItems.Add(paragraph.Extra); + break; + case SubtitleColumn.Network: + item.SubItems.Add(string.Empty); + break; + } + } + + item.StateImageIndex = paragraph.Bookmark != null ? 0 : -1; + item.Font = font; + return item; + } + + public void SelectNone() + { + for (var i = Items.Count - 1; i >= 0; i--) + { + Items[i].Selected = false; + } + } + + public void SelectIndexAndEnsureVisibleFaster(int index) + { + var topItem = TopItem; + if (!IsValidIndex(index) || topItem == null) + { + return; + } + + BeginUpdate(); + foreach (var selectedIndex in GetSelectedIndices()) + { + Items[selectedIndex].Selected = false; + } + + var selectedItem = Items[index]; + selectedItem.Selected = true; + selectedItem.Focused = true; + + var topIndex = topItem.Index; + var numberOfVisibleItems = (Height - 30) / GetItemRect(0).Height; + int bottomIndex = topIndex + numberOfVisibleItems; + if (index >= bottomIndex) + { + Items[Math.Min(Items.Count - 1, index + numberOfVisibleItems / 2)].EnsureVisible(); + } + else if (index < topIndex) + { + Items[Math.Max(0, index - numberOfVisibleItems / 2)].EnsureVisible(); + } + EndUpdate(); + } + + public void SelectIndexAndEnsureVisible(int index, bool focus) + { + if (!IsValidIndex(index)) + { + return; + } + + if (TopItem == null) + { + EnsureVisible(index); + if (focus) + { + Items[index].Focused = true; + } + return; + } + + int bottomIndex = TopItem.Index + (Height - 25) / 16; + int itemsBeforeAfterCount = (bottomIndex - TopItem.Index) / 2 - 1; + if (itemsBeforeAfterCount < 0) + { + itemsBeforeAfterCount = 1; + } + + int beforeIndex = index - itemsBeforeAfterCount; + if (beforeIndex < 0) + { + beforeIndex = 0; + } + + int afterIndex = index + itemsBeforeAfterCount; + if (afterIndex >= Items.Count) + { + afterIndex = Items.Count - 1; + } + + SelectNone(); + if (TopItem.Index <= beforeIndex && bottomIndex > afterIndex) + { + Items[index].Selected = true; + Items[index].EnsureVisible(); + if (focus) + { + Items[index].Focused = true; + } + EnsureVisible(index); + return; + } + + Items[beforeIndex].EnsureVisible(); + EnsureVisible(beforeIndex); + Items[afterIndex].EnsureVisible(); + EnsureVisible(afterIndex); + Items[index].Selected = true; + Items[index].EnsureVisible(); + if (focus) + { + Items[index].Focused = true; + } + EnsureVisible(index); + } + + public void SelectIndexAndEnsureVisible(int index) + { + SelectIndexAndEnsureVisible(index, false); + } + + public void SelectIndexAndEnsureVisible(Paragraph p) + { + SelectNone(); + if (p == null) + { + return; + } + + for (int index = 0; index < Items.Count; index++) + { + ListViewItem item = Items[index]; + if (item.Tag as Paragraph == p || + item.Text == p.Number.ToString(CultureInfo.InvariantCulture) && + (ColumnIndexStart < 0 || item.SubItems[ColumnIndexStart].Text == GetDisplayTime(p.StartTime)) && + (ColumnIndexEnd < 0 || item.SubItems[ColumnIndexEnd].Text == GetDisplayTime(p.EndTime)) && + item.SubItems[ColumnIndexText].Text == p.Text) + { + RestoreFirstVisibleIndex(); + item.Selected = true; + item.EnsureVisible(); + return; + } + } + } + + public Paragraph GetSelectedParagraph(Subtitle subtitle) + { + if (subtitle != null && SelectedItems.Count > 0) + { + return subtitle.GetParagraphOrDefault(SelectedItems[0].Index); + } + + return null; + } + + public string GetText(int index) + { + if (IsValidIndex(index)) + { + return Items[index].SubItems[ColumnIndexText].Text.Replace(_lineSeparatorString, Environment.NewLine); + } + + return null; + } + + public string GetTextAlternate(int index) + { + if (IsValidIndex(index) && ColumnIndexTextAlternate >= 0) + { + return Items[index].SubItems[ColumnIndexTextAlternate].Text.Replace(_lineSeparatorString, Environment.NewLine); + } + + return null; + } + + public void SetText(int index, string text) + { + if (IsValidIndex(index)) + { + ListViewItem item = Items[index]; + if (ColumnIndexText >= 0) + { + item.SubItems[ColumnIndexText].Text = text.Replace(Environment.NewLine, _lineSeparatorString); + } + + if (item.Tag is Paragraph paragraph) + { + UpdateCpsAndWpm(item, paragraph); + } + } + } + + public void SetTimeAndText(int index, Paragraph paragraph, Paragraph next) + { + if (IsValidIndex(index)) + { + ListViewItem item = Items[index]; + if (ColumnIndexStart >= 0) + { + item.SubItems[ColumnIndexStart].Text = GetDisplayTime(paragraph.StartTime); + } + + if (ColumnIndexEnd >= 0) + { + item.SubItems[ColumnIndexEnd].Text = GetDisplayTime(paragraph.EndTime); + } + + if (ColumnIndexDuration >= 0) + { + item.SubItems[ColumnIndexDuration].Text = paragraph.Duration.ToShortDisplayString(); + } + + if (ColumnIndexGap >= 0) + { + item.SubItems[ColumnIndexGap].Text = GetGap(paragraph, next); + } + + if (ColumnIndexActor >= 0) + { + item.SubItems[ColumnIndexActor].Text = paragraph.Actor; + } + + if (ColumnIndexRegion >= 0) + { + item.SubItems[ColumnIndexRegion].Text = paragraph.Region; + } + + if (ColumnIndexText >= 0) + { + item.SubItems[ColumnIndexText].Text = paragraph.Text.Replace(Environment.NewLine, _lineSeparatorString); + } + + UpdateCpsAndWpm(item, paragraph); + } + } + + private void UpdateCpsAndWpm(ListViewItem item, Paragraph paragraph) + { + if (ColumnIndexCps >= 0) + { + item.SubItems[ColumnIndexCps].Text = $"{Utilities.GetCharactersPerSecond(paragraph):0.00}"; + } + if (ColumnIndexWpm >= 0) + { + item.SubItems[ColumnIndexWpm].Text = $"{paragraph.WordsPerMinute:0.00}"; + } + } + + public void SetExtraText(int index, string text, Color color) + { + if (IsValidIndex(index)) + { + if (GetColumnIndex(SubtitleColumn.Extra) == -1) + { + ShowExtraColumn(string.Empty); + } + while (ColumnIndexExtra >= Items[index].SubItems.Count) + { + Items[index].SubItems.Add(string.Empty); + } + + if (ColumnIndexExtra >= 0) + { + Items[index].SubItems[ColumnIndexExtra].Text = text; + Items[index].UseItemStyleForSubItems = false; + Items[index].SubItems[ColumnIndexExtra].BackColor = BackColor; + Items[index].SubItems[ColumnIndexExtra].ForeColor = color; + } + } + } + + public void SetNetworkText(int index, string text, Color color) + { + if (IsValidIndex(index)) + { + if (GetColumnIndex(SubtitleColumn.Network) == -1) + { + ShowNetworkColumn(string.Empty); + } + while (ColumnIndexNetwork >= Items[index].SubItems.Count) + { + Items[index].SubItems.Add(string.Empty); + } + + if (ColumnIndexNetwork >= 0) + { + Items[index].SubItems[ColumnIndexNetwork].Text = text; + Items[index].UseItemStyleForSubItems = false; + Items[index].SubItems[ColumnIndexNetwork].BackColor = Color.AntiqueWhite; + Items[index].SubItems[ColumnIndexNetwork].ForeColor = color; + } + } + } + + public void SetAlternateText(int index, string text) + { + if (IsValidIndex(index) && Columns.Count >= ColumnIndexTextAlternate + 1) + { + if (GetColumnIndex(SubtitleColumn.TextAlternate) == -1) + { + ShowAlternateTextColumn(string.Empty); + } + while (ColumnIndexTextAlternate >= Items[index].SubItems.Count) + { + Items[index].SubItems.Add(string.Empty); + } + + if (ColumnIndexTextAlternate >= 0) + { + Items[index].SubItems[ColumnIndexTextAlternate].Text = text.Replace(Environment.NewLine, _lineSeparatorString); + Items[index].UseItemStyleForSubItems = false; + Items[index].SubItems[ColumnIndexTextAlternate].BackColor = BackColor; + } + } + } + + public void SetDuration(int index, Paragraph paragraph, Paragraph next) + { + if (IsValidIndex(index)) + { + ListViewItem item = Items[index]; + if (ColumnIndexEnd >= 0) + { + item.SubItems[ColumnIndexEnd].Text = GetDisplayTime(paragraph.EndTime); + } + + if (ColumnIndexDuration >= 0) + { + item.SubItems[ColumnIndexDuration].Text = paragraph.Duration.ToShortDisplayString(); + } + + if (ColumnIndexGap >= 0) + { + item.SubItems[ColumnIndexGap].Text = GetGap(paragraph, next); + } + + UpdateCpsAndWpm(item, paragraph); + } + } + + public void SetNumber(int index, string number) + { + if (IsValidIndex(index) && ColumnIndexNumber >= 0) + { + Items[index].SubItems[ColumnIndexNumber].Text = number; + } + } + + public void UpdateFrames(Subtitle subtitle) + { + if (Configuration.Settings?.General.UseTimeFormatHHMMSSFF == true) + { + BeginUpdate(); + for (int i = 0; i < subtitle.Paragraphs.Count; i++) + { + if (IsValidIndex(i)) + { + Paragraph p = subtitle.Paragraphs[i]; + ListViewItem item = Items[i]; + if (ColumnIndexStart >= 0) + { + item.SubItems[ColumnIndexStart].Text = GetDisplayTime(p.StartTime); + } + + if (ColumnIndexEnd >= 0) + { + item.SubItems[ColumnIndexEnd].Text = GetDisplayTime(p.EndTime); + } + + if (ColumnIndexDuration >= 0) + { + item.SubItems[ColumnIndexDuration].Text = p.Duration.ToShortDisplayString(); + } + } + } + EndUpdate(); + } + } + + public void SetStartTimeAndDuration(int index, Paragraph paragraph, Paragraph next, Paragraph prev) + { + if (IsValidIndex(index)) + { + ListViewItem item = Items[index]; + if (ColumnIndexStart >= 0) + { + item.SubItems[ColumnIndexStart].Text = GetDisplayTime(paragraph.StartTime); + } + + if (ColumnIndexEnd >= 0) + { + item.SubItems[ColumnIndexEnd].Text = GetDisplayTime(paragraph.EndTime); + } + + if (ColumnIndexDuration >= 0) + { + item.SubItems[ColumnIndexDuration].Text = paragraph.Duration.ToShortDisplayString(); + } + + if (ColumnIndexGap >= 0) + { + item.SubItems[ColumnIndexGap].Text = GetGap(paragraph, next); + } + + UpdateCpsAndWpm(item, paragraph); + } + SetGap(index - 1, prev, paragraph); + } + + private void SetGap(int index, Paragraph paragraph, Paragraph next) + { + if (IsValidIndex(index)) + { + ListViewItem item = Items[index]; + if (ColumnIndexGap >= 0) + { + item.SubItems[ColumnIndexGap].Text = GetGap(paragraph, next); + } + } + } + + private string GetGap(Paragraph paragraph, Paragraph next) + { + if (next == null || paragraph == null || next.StartTime.IsMaxTime || paragraph.EndTime.IsMaxTime) + { + return string.Empty; + } + + return new TimeCode(next.StartTime.TotalMilliseconds - paragraph.EndTime.TotalMilliseconds).ToShortDisplayString(); + } + + public void SetBackgroundColor(int index, Color color, int columnNumber) + { + if (IsValidIndex(index)) + { + ListViewItem item = Items[index]; + if (item.UseItemStyleForSubItems) + { + item.UseItemStyleForSubItems = false; + } + + if (columnNumber >= 0 && columnNumber < item.SubItems.Count) + { + item.SubItems[columnNumber].BackColor = color; + } + } + } + + public void SetBackgroundColor(int index, Color color) + { + if (IsValidIndex(index)) + { + ListViewItem item = Items[index]; + item.BackColor = color; + if (ColumnIndexStart >= 0) + { + Items[index].SubItems[ColumnIndexStart].BackColor = color; + } + + if (ColumnIndexEnd >= 0) + { + Items[index].SubItems[ColumnIndexEnd].BackColor = color; + } + + if (ColumnIndexDuration >= 0) + { + Items[index].SubItems[ColumnIndexDuration].BackColor = color; + } + + if (ColumnIndexCps >= 0) + { + Items[index].SubItems[ColumnIndexCps].BackColor = color; + } + + if (ColumnIndexWpm >= 0) + { + Items[index].SubItems[ColumnIndexWpm].BackColor = color; + } + + if (ColumnIndexGap >= 0) + { + Items[index].SubItems[ColumnIndexGap].BackColor = color; + } + + if (ColumnIndexText >= 0) + { + Items[index].SubItems[ColumnIndexText].BackColor = color; + } + + if (ColumnIndexTextAlternate >= 0) + { + Items[index].SubItems[ColumnIndexTextAlternate].BackColor = color; + } + } + } + + public Color GetBackgroundColor(int index) + { + if (IsValidIndex(index)) + { + ListViewItem item = Items[index]; + return item.BackColor; + } + return DefaultBackColor; + } + + /// + /// Removes all text and set background color + /// + /// + /// + public void ColorOut(int index, Color color) + { + if (IsValidIndex(index)) + { + ListViewItem item = Items[index]; + item.Text = string.Empty; + if (ColumnIndexStart >= 0) + { + item.SubItems[ColumnIndexStart].Text = string.Empty; + } + + if (ColumnIndexEnd >= 0) + { + item.SubItems[ColumnIndexEnd].Text = string.Empty; + } + + if (ColumnIndexDuration >= 0) + { + item.SubItems[ColumnIndexDuration].Text = string.Empty; + } + + if (ColumnIndexText >= 0) + { + item.SubItems[ColumnIndexText].Text = string.Empty; + } + + if (ColumnIndexGap >= 0) + { + item.SubItems[ColumnIndexGap].Text = string.Empty; + } + + SetBackgroundColor(index, color); + } + } + + public void HideNonVobSubColumns() + { + var numberIdx = GetColumnIndex(SubtitleColumn.Number); + if (numberIdx >= 0) + { + Columns[numberIdx].Width = 0; + } + + HideColumn(SubtitleColumn.End); + HideColumn(SubtitleColumn.Duration); + HideColumn(SubtitleColumn.CharactersPerSeconds); + HideColumn(SubtitleColumn.WordsPerMinute); + } + + public void SetCustomResize(EventHandler handler) + { + if (handler == null) + { + return; + } + + Resize -= SubtitleListViewLastColumnFill; + Resize += handler; + } + + private bool IsValidIndex(int index) + { + return index >= 0 && index < Items.Count; + } + + private FontStyle GetFontStyle() => SubtitleFontBold ? FontStyle.Bold : FontStyle.Regular; + + public void ShowState(int index, Paragraph paragraph) + { + if (IsValidIndex(index)) + { + Items[index].StateImageIndex = paragraph.Bookmark != null ? 0 : -1; + } + } + + /// + /// Get SelectedIndices as array for faster performance. + /// + /// SelectedIndices as int array + public int[] GetSelectedIndices() + { + var selectedIndices = new int[SelectedIndices.Count]; + SelectedIndices.CopyTo(selectedIndices, 0); + return selectedIndices; + } + } +} diff --git a/src/Controls/TimeUpDown.Designer.cs b/src/ui/Controls/TimeUpDown.Designer.cs similarity index 97% rename from src/Controls/TimeUpDown.Designer.cs rename to src/ui/Controls/TimeUpDown.Designer.cs index feb28a472..7bb16d1b9 100644 --- a/src/Controls/TimeUpDown.Designer.cs +++ b/src/ui/Controls/TimeUpDown.Designer.cs @@ -1,78 +1,78 @@ -namespace Nikse.SubtitleEdit.Controls -{ - sealed partial class TimeUpDown - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.maskedTextBox1 = new System.Windows.Forms.MaskedTextBox(); - this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); - this.SuspendLayout(); - // - // maskedTextBox1 - // - this.maskedTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.maskedTextBox1.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite; - this.maskedTextBox1.Location = new System.Drawing.Point(4, 3); - this.maskedTextBox1.Mask = "00:00:00.000"; - this.maskedTextBox1.Name = "maskedTextBox1"; - this.maskedTextBox1.Size = new System.Drawing.Size(71, 13); - this.maskedTextBox1.TabIndex = 21; - this.maskedTextBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MaskedTextBox1KeyDown); - this.maskedTextBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.maskedTextBox1_MouseDown); - // - // numericUpDown1 - // - this.numericUpDown1.Location = new System.Drawing.Point(2, 1); - this.numericUpDown1.Name = "numericUpDown1"; - this.numericUpDown1.Size = new System.Drawing.Size(91, 20); - this.numericUpDown1.TabIndex = 20; - this.numericUpDown1.TabStop = false; - // - // TimeUpDown - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.AutoSize = true; - this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.Controls.Add(this.maskedTextBox1); - this.Controls.Add(this.numericUpDown1); - this.Name = "TimeUpDown"; - this.Size = new System.Drawing.Size(96, 24); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.MaskedTextBox maskedTextBox1; - private System.Windows.Forms.NumericUpDown numericUpDown1; - - } -} +namespace Nikse.SubtitleEdit.Controls +{ + sealed partial class TimeUpDown + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.maskedTextBox1 = new System.Windows.Forms.MaskedTextBox(); + this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); + this.SuspendLayout(); + // + // maskedTextBox1 + // + this.maskedTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.maskedTextBox1.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite; + this.maskedTextBox1.Location = new System.Drawing.Point(4, 3); + this.maskedTextBox1.Mask = "00:00:00.000"; + this.maskedTextBox1.Name = "maskedTextBox1"; + this.maskedTextBox1.Size = new System.Drawing.Size(71, 13); + this.maskedTextBox1.TabIndex = 21; + this.maskedTextBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MaskedTextBox1KeyDown); + this.maskedTextBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.maskedTextBox1_MouseDown); + // + // numericUpDown1 + // + this.numericUpDown1.Location = new System.Drawing.Point(2, 1); + this.numericUpDown1.Name = "numericUpDown1"; + this.numericUpDown1.Size = new System.Drawing.Size(91, 20); + this.numericUpDown1.TabIndex = 20; + this.numericUpDown1.TabStop = false; + // + // TimeUpDown + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.Controls.Add(this.maskedTextBox1); + this.Controls.Add(this.numericUpDown1); + this.Name = "TimeUpDown"; + this.Size = new System.Drawing.Size(96, 24); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.MaskedTextBox maskedTextBox1; + private System.Windows.Forms.NumericUpDown numericUpDown1; + + } +} diff --git a/src/Controls/TimeUpDown.cs b/src/ui/Controls/TimeUpDown.cs similarity index 97% rename from src/Controls/TimeUpDown.cs rename to src/ui/Controls/TimeUpDown.cs index bd54c7495..ea9704325 100644 --- a/src/Controls/TimeUpDown.cs +++ b/src/ui/Controls/TimeUpDown.cs @@ -1,343 +1,343 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Globalization; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Controls -{ - public sealed partial class TimeUpDown : UserControl - { - public enum TimeMode - { - HHMMSSMS, - HHMMSSFF - } - - private readonly bool _designMode = LicenseManager.UsageMode == LicenseUsageMode.Designtime; - - private const int NumericUpDownValue = 50; - - public EventHandler TimeCodeChanged; - - private bool _forceHHMMSSFF; - - public bool UseVideoOffset { get; set; } - - private static readonly char[] SplitChars = GetSplitChars(); - - private bool _dirty; - double _initialTotalMilliseconds; - - internal void ForceHHMMSSFF() - { - _forceHHMMSSFF = true; - maskedTextBox1.Mask = "00:00:00:00"; - } - - public TimeMode Mode - { - get - { - if (_forceHHMMSSFF || Configuration.Settings?.General.UseTimeFormatHHMMSSFF == true) - { - return TimeMode.HHMMSSFF; - } - - return TimeMode.HHMMSSMS; - } - } - - public void SetAutoWidth() - { - int width; - using (var g = Graphics.FromHwnd(IntPtr.Zero)) - { - var widthOfUpDown = 25; - if (Configuration.IsRunningOnLinux) - { - widthOfUpDown += 20; - } - var actualWidth = g.MeasureString("00:00:00:000", Font).Width; - width = (int)Math.Round(actualWidth + widthOfUpDown); - } - var diff = Width - width; - maskedTextBox1.Width -= diff; - numericUpDown1.Width -= diff; - } - - private static char[] GetSplitChars() - { - var splitChars = new List { ':', ',', '.' }; - string cultureSeparator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; - if (cultureSeparator.Length == 1) - { - var ch = Convert.ToChar(cultureSeparator); - if (!splitChars.Contains(ch)) - { - splitChars.Add(ch); - } - } - return splitChars.ToArray(); - } - - public TimeUpDown() - { - Font = UiUtil.GetDefaultFont(); - InitializeComponent(); - UiUtil.FixFonts(this); - numericUpDown1.ValueChanged += NumericUpDownValueChanged; - numericUpDown1.Value = NumericUpDownValue; - maskedTextBox1.InsertKeyMode = InsertKeyMode.Overwrite; - } - - private void NumericUpDownValueChanged(object sender, EventArgs e) - { - _dirty = true; - double? milliseconds = GetTotalMilliseconds(); - if (milliseconds.HasValue) - { - if (milliseconds.Value >= TimeCode.MaxTimeTotalMilliseconds - 0.1) - { - milliseconds = 0; - } - - if (Mode == TimeMode.HHMMSSMS) - { - if (numericUpDown1.Value > NumericUpDownValue) - { - SetTotalMilliseconds(milliseconds.Value + 100); - } - else if (numericUpDown1.Value < NumericUpDownValue) - { - SetTotalMilliseconds(milliseconds.Value - 100); - } - } - else - { - if (numericUpDown1.Value > NumericUpDownValue) - { - SetTotalMilliseconds(milliseconds.Value + Core.SubtitleFormats.SubtitleFormat.FramesToMilliseconds(1)); - } - else if (numericUpDown1.Value < NumericUpDownValue) - { - SetTotalMilliseconds(milliseconds.Value - Core.SubtitleFormats.SubtitleFormat.FramesToMilliseconds(1)); - } - } - TimeCodeChanged?.Invoke(this, e); - } - numericUpDown1.Value = NumericUpDownValue; - } - - public MaskedTextBox MaskedTextBox => maskedTextBox1; - - public void SetTotalMilliseconds(double milliseconds) - { - _dirty = false; - _initialTotalMilliseconds = milliseconds; - if (UseVideoOffset) - { - milliseconds += Configuration.Settings.General.CurrentVideoOffsetInMs; - } - if (Mode == TimeMode.HHMMSSMS) - { - maskedTextBox1.Mask = GetMask(milliseconds); - maskedTextBox1.Text = new TimeCode(milliseconds).ToString(); - } - else - { - var tc = new TimeCode(milliseconds); - maskedTextBox1.Mask = GetMaskFrames(milliseconds); - maskedTextBox1.Text = tc.ToString().Substring(0, 9) + $"{Core.SubtitleFormats.SubtitleFormat.MillisecondsToFrames(tc.Milliseconds):00}"; - } - _dirty = false; - } - - public double? GetTotalMilliseconds() - { - return _dirty ? TimeCode?.TotalMilliseconds : _initialTotalMilliseconds; - } - - public TimeCode TimeCode - { - get - { - if (_designMode) - { - return new TimeCode(); - } - - if (string.IsNullOrWhiteSpace(maskedTextBox1.Text.RemoveChar('.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, string.Empty).RemoveChar(',').RemoveChar(':'))) - { - return new TimeCode(TimeCode.MaxTimeTotalMilliseconds); - } - - if (!_dirty) - { - return new TimeCode(_initialTotalMilliseconds); - } - - string startTime = maskedTextBox1.Text; - bool isNegative = startTime.StartsWith('-'); - startTime = startTime.TrimStart('-').Replace(' ', '0'); - if (Mode == TimeMode.HHMMSSMS) - { - if (startTime.EndsWith(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, StringComparison.Ordinal)) - { - startTime += "000"; - } - - var times = startTime.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries); - - if (times.Length == 4) - { - int.TryParse(times[0], out var hours); - - int.TryParse(times[1], out var minutes); - if (minutes > 59) - { - minutes = 59; - } - - int.TryParse(times[2], out var seconds); - if (seconds > 59) - { - seconds = 59; - } - - int.TryParse(times[3].PadRight(3, '0'), out var milliseconds); - var tc = new TimeCode(hours, minutes, seconds, milliseconds); - - if (UseVideoOffset) - { - tc.TotalMilliseconds -= Configuration.Settings.General.CurrentVideoOffsetInMs; - } - - if (isNegative) - { - tc.TotalMilliseconds *= -1; - } - - return tc; - } - } - else - { - if (startTime.EndsWith(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, StringComparison.Ordinal) || startTime.EndsWith(':')) - { - startTime += "00"; - } - - string[] times = startTime.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries); - - if (times.Length == 4) - { - int.TryParse(times[0], out var hours); - - int.TryParse(times[1], out var minutes); - - int.TryParse(times[2], out var seconds); - - if (int.TryParse(times[3], out var milliseconds)) - { - milliseconds = Core.SubtitleFormats.SubtitleFormat.FramesToMillisecondsMax999(milliseconds); - } - - var tc = new TimeCode(hours, minutes, seconds, milliseconds); - - if (UseVideoOffset) - { - tc.TotalMilliseconds -= Configuration.Settings.General.CurrentVideoOffsetInMs; - } - - if (isNegative) - { - tc.TotalMilliseconds *= -1; - } - - return tc; - } - } - return null; - } - set - { - if (_designMode) - { - return; - } - - if (value != null) - { - _dirty = false; - _initialTotalMilliseconds = value.TotalMilliseconds; - } - - if (value == null || value.TotalMilliseconds >= TimeCode.MaxTimeTotalMilliseconds - 0.1) - { - maskedTextBox1.Text = string.Empty; - return; - } - - var v = new TimeCode(value.TotalMilliseconds); - if (UseVideoOffset) - { - v.TotalMilliseconds += Configuration.Settings.General.CurrentVideoOffsetInMs; - } - - if (Mode == TimeMode.HHMMSSMS) - { - maskedTextBox1.Mask = GetMask(v.TotalMilliseconds); - maskedTextBox1.Text = v.ToString(); - } - else - { - maskedTextBox1.Mask = GetMaskFrames(v.TotalMilliseconds); - maskedTextBox1.Text = v.ToHHMMSSFF(); - } - } - } - - private void MaskedTextBox1KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyData == Keys.Up) - { - numericUpDown1.UpButton(); - e.SuppressKeyPress = true; - } - else if (e.KeyData == Keys.Down) - { - numericUpDown1.DownButton(); - e.SuppressKeyPress = true; - } - else if (e.KeyData == Keys.Enter) - { - TimeCodeChanged?.Invoke(this, e); - e.SuppressKeyPress = true; - } - else if (e.KeyData != (Keys.Tab | Keys.Shift) && - e.KeyData != Keys.Tab && - e.KeyData != Keys.Left && - e.KeyData != Keys.Right) - { - _dirty = true; - } - } - - private static string GetMask(double val) => val >= 0 ? "00:00:00.000" : "-00:00:00.000"; - - private static string GetMaskFrames(double val) => val >= 0 ? "00:00:00:00" : "-00:00:00:00"; - - private void maskedTextBox1_MouseDown(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Right) - { - _dirty = true; - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Globalization; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Controls +{ + public sealed partial class TimeUpDown : UserControl + { + public enum TimeMode + { + HHMMSSMS, + HHMMSSFF + } + + private readonly bool _designMode = LicenseManager.UsageMode == LicenseUsageMode.Designtime; + + private const int NumericUpDownValue = 50; + + public EventHandler TimeCodeChanged; + + private bool _forceHHMMSSFF; + + public bool UseVideoOffset { get; set; } + + private static readonly char[] SplitChars = GetSplitChars(); + + private bool _dirty; + double _initialTotalMilliseconds; + + internal void ForceHHMMSSFF() + { + _forceHHMMSSFF = true; + maskedTextBox1.Mask = "00:00:00:00"; + } + + public TimeMode Mode + { + get + { + if (_forceHHMMSSFF || Configuration.Settings?.General.UseTimeFormatHHMMSSFF == true) + { + return TimeMode.HHMMSSFF; + } + + return TimeMode.HHMMSSMS; + } + } + + public void SetAutoWidth() + { + int width; + using (var g = Graphics.FromHwnd(IntPtr.Zero)) + { + var widthOfUpDown = 25; + if (Configuration.IsRunningOnLinux) + { + widthOfUpDown += 20; + } + var actualWidth = g.MeasureString("00:00:00:000", Font).Width; + width = (int)Math.Round(actualWidth + widthOfUpDown); + } + var diff = Width - width; + maskedTextBox1.Width -= diff; + numericUpDown1.Width -= diff; + } + + private static char[] GetSplitChars() + { + var splitChars = new List { ':', ',', '.' }; + string cultureSeparator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; + if (cultureSeparator.Length == 1) + { + var ch = Convert.ToChar(cultureSeparator); + if (!splitChars.Contains(ch)) + { + splitChars.Add(ch); + } + } + return splitChars.ToArray(); + } + + public TimeUpDown() + { + Font = UiUtil.GetDefaultFont(); + InitializeComponent(); + UiUtil.FixFonts(this); + numericUpDown1.ValueChanged += NumericUpDownValueChanged; + numericUpDown1.Value = NumericUpDownValue; + maskedTextBox1.InsertKeyMode = InsertKeyMode.Overwrite; + } + + private void NumericUpDownValueChanged(object sender, EventArgs e) + { + _dirty = true; + double? milliseconds = GetTotalMilliseconds(); + if (milliseconds.HasValue) + { + if (milliseconds.Value >= TimeCode.MaxTimeTotalMilliseconds - 0.1) + { + milliseconds = 0; + } + + if (Mode == TimeMode.HHMMSSMS) + { + if (numericUpDown1.Value > NumericUpDownValue) + { + SetTotalMilliseconds(milliseconds.Value + 100); + } + else if (numericUpDown1.Value < NumericUpDownValue) + { + SetTotalMilliseconds(milliseconds.Value - 100); + } + } + else + { + if (numericUpDown1.Value > NumericUpDownValue) + { + SetTotalMilliseconds(milliseconds.Value + Core.SubtitleFormats.SubtitleFormat.FramesToMilliseconds(1)); + } + else if (numericUpDown1.Value < NumericUpDownValue) + { + SetTotalMilliseconds(milliseconds.Value - Core.SubtitleFormats.SubtitleFormat.FramesToMilliseconds(1)); + } + } + TimeCodeChanged?.Invoke(this, e); + } + numericUpDown1.Value = NumericUpDownValue; + } + + public MaskedTextBox MaskedTextBox => maskedTextBox1; + + public void SetTotalMilliseconds(double milliseconds) + { + _dirty = false; + _initialTotalMilliseconds = milliseconds; + if (UseVideoOffset) + { + milliseconds += Configuration.Settings.General.CurrentVideoOffsetInMs; + } + if (Mode == TimeMode.HHMMSSMS) + { + maskedTextBox1.Mask = GetMask(milliseconds); + maskedTextBox1.Text = new TimeCode(milliseconds).ToString(); + } + else + { + var tc = new TimeCode(milliseconds); + maskedTextBox1.Mask = GetMaskFrames(milliseconds); + maskedTextBox1.Text = tc.ToString().Substring(0, 9) + $"{Core.SubtitleFormats.SubtitleFormat.MillisecondsToFrames(tc.Milliseconds):00}"; + } + _dirty = false; + } + + public double? GetTotalMilliseconds() + { + return _dirty ? TimeCode?.TotalMilliseconds : _initialTotalMilliseconds; + } + + public TimeCode TimeCode + { + get + { + if (_designMode) + { + return new TimeCode(); + } + + if (string.IsNullOrWhiteSpace(maskedTextBox1.Text.RemoveChar('.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, string.Empty).RemoveChar(',').RemoveChar(':'))) + { + return new TimeCode(TimeCode.MaxTimeTotalMilliseconds); + } + + if (!_dirty) + { + return new TimeCode(_initialTotalMilliseconds); + } + + string startTime = maskedTextBox1.Text; + bool isNegative = startTime.StartsWith('-'); + startTime = startTime.TrimStart('-').Replace(' ', '0'); + if (Mode == TimeMode.HHMMSSMS) + { + if (startTime.EndsWith(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, StringComparison.Ordinal)) + { + startTime += "000"; + } + + var times = startTime.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries); + + if (times.Length == 4) + { + int.TryParse(times[0], out var hours); + + int.TryParse(times[1], out var minutes); + if (minutes > 59) + { + minutes = 59; + } + + int.TryParse(times[2], out var seconds); + if (seconds > 59) + { + seconds = 59; + } + + int.TryParse(times[3].PadRight(3, '0'), out var milliseconds); + var tc = new TimeCode(hours, minutes, seconds, milliseconds); + + if (UseVideoOffset) + { + tc.TotalMilliseconds -= Configuration.Settings.General.CurrentVideoOffsetInMs; + } + + if (isNegative) + { + tc.TotalMilliseconds *= -1; + } + + return tc; + } + } + else + { + if (startTime.EndsWith(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, StringComparison.Ordinal) || startTime.EndsWith(':')) + { + startTime += "00"; + } + + string[] times = startTime.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries); + + if (times.Length == 4) + { + int.TryParse(times[0], out var hours); + + int.TryParse(times[1], out var minutes); + + int.TryParse(times[2], out var seconds); + + if (int.TryParse(times[3], out var milliseconds)) + { + milliseconds = Core.SubtitleFormats.SubtitleFormat.FramesToMillisecondsMax999(milliseconds); + } + + var tc = new TimeCode(hours, minutes, seconds, milliseconds); + + if (UseVideoOffset) + { + tc.TotalMilliseconds -= Configuration.Settings.General.CurrentVideoOffsetInMs; + } + + if (isNegative) + { + tc.TotalMilliseconds *= -1; + } + + return tc; + } + } + return null; + } + set + { + if (_designMode) + { + return; + } + + if (value != null) + { + _dirty = false; + _initialTotalMilliseconds = value.TotalMilliseconds; + } + + if (value == null || value.TotalMilliseconds >= TimeCode.MaxTimeTotalMilliseconds - 0.1) + { + maskedTextBox1.Text = string.Empty; + return; + } + + var v = new TimeCode(value.TotalMilliseconds); + if (UseVideoOffset) + { + v.TotalMilliseconds += Configuration.Settings.General.CurrentVideoOffsetInMs; + } + + if (Mode == TimeMode.HHMMSSMS) + { + maskedTextBox1.Mask = GetMask(v.TotalMilliseconds); + maskedTextBox1.Text = v.ToString(); + } + else + { + maskedTextBox1.Mask = GetMaskFrames(v.TotalMilliseconds); + maskedTextBox1.Text = v.ToHHMMSSFF(); + } + } + } + + private void MaskedTextBox1KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyData == Keys.Up) + { + numericUpDown1.UpButton(); + e.SuppressKeyPress = true; + } + else if (e.KeyData == Keys.Down) + { + numericUpDown1.DownButton(); + e.SuppressKeyPress = true; + } + else if (e.KeyData == Keys.Enter) + { + TimeCodeChanged?.Invoke(this, e); + e.SuppressKeyPress = true; + } + else if (e.KeyData != (Keys.Tab | Keys.Shift) && + e.KeyData != Keys.Tab && + e.KeyData != Keys.Left && + e.KeyData != Keys.Right) + { + _dirty = true; + } + } + + private static string GetMask(double val) => val >= 0 ? "00:00:00.000" : "-00:00:00.000"; + + private static string GetMaskFrames(double val) => val >= 0 ? "00:00:00:00" : "-00:00:00:00"; + + private void maskedTextBox1_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + _dirty = true; + } + } + } +} diff --git a/src/Forms/Ocr/VobSubOcrNewFolder.resx b/src/ui/Controls/TimeUpDown.resx similarity index 100% rename from src/Forms/Ocr/VobSubOcrNewFolder.resx rename to src/ui/Controls/TimeUpDown.resx diff --git a/src/Controls/VideoPlayerContainer.cs b/src/ui/Controls/VideoPlayerContainer.cs similarity index 97% rename from src/Controls/VideoPlayerContainer.cs rename to src/ui/Controls/VideoPlayerContainer.cs index ddc734c8f..007bca1ed 100644 --- a/src/Controls/VideoPlayerContainer.cs +++ b/src/ui/Controls/VideoPlayerContainer.cs @@ -1,2111 +1,2111 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; -using Nikse.SubtitleEdit.Logic.VideoPlayers; -using System; -using System.Drawing; -using System.IO; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System.Collections.Generic; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Controls -{ - public sealed class VideoPlayerContainer : Panel - { - public class RichTextBoxViewOnly : RichTextBox - { - public RichTextBoxViewOnly() - { - ReadOnly = true; - BorderStyle = BorderStyle.None; - TabStop = false; - SetStyle(ControlStyles.Selectable, false); - SetStyle(ControlStyles.UserMouse, true); - MouseEnter += delegate { Cursor = Cursors.Default; }; - ScrollBars = RichTextBoxScrollBars.None; - Margin = new Padding(0); - } - - protected override void WndProc(ref Message m) - { - if (m.Msg == 0x204) - { - return; // WM_RBUTTONDOWN - } - - if (m.Msg == 0x205) - { - return; // WM_RBUTTONUP - } - - base.WndProc(ref m); - } - } - - public event EventHandler OnButtonClicked; - public event EventHandler OnEmptyPlayerClicked; - public Panel PanelPlayer { get; private set; } - private Panel _panelSubtitle; - private string _subtitleText = string.Empty; - private VideoPlayer _videoPlayer; - - public float FontSizeFactor { get; set; } - - public VideoPlayer VideoPlayer - { - get => _videoPlayer; - set - { - _videoPlayer = value; - if (_videoPlayer != null) - { - SetPlayerName(_videoPlayer.PlayerName); - } - - if (_videoPlayer is LibMpvDynamic && Configuration.Settings.General.MpvHandlesPreviewText) - { - _subtitlesHeight = 0; - } - else - { - _subtitlesHeight = 57; - } - DeleteTempMpvFileName(); - VideoPlayerContainerResize(this, null); - } - } - - public RichTextBoxViewOnly TextBox { get; private set; } - - public int VideoWidth { get; set; } - public int VideoHeight { get; set; } - - private bool _isMuted; - private double? _muteOldVolume; - private readonly System.ComponentModel.ComponentResourceManager _resources; - private int _controlsHeight = 47; - private const int OriginalSubtitlesHeight = 57; - private int _subtitlesHeight = OriginalSubtitlesHeight; - private readonly Color _backgroundColor = Color.FromArgb(18, 18, 18); - private Panel _panelControls; - - private PictureBox _pictureBoxBackground; - private PictureBox _pictureBoxReverse; - private PictureBox _pictureBoxReverseOver; - private PictureBox _pictureBoxReverseDown; - private PictureBox _pictureBoxFastForward; - private PictureBox _pictureBoxFastForwardOver; - private PictureBox _pictureBoxFastForwardDown; - private PictureBox _pictureBoxPlay; - private PictureBox _pictureBoxPlayOver; - private PictureBox _pictureBoxPlayDown; - private readonly PictureBox _pictureBoxPause = new PictureBox(); - private readonly PictureBox _pictureBoxPauseOver = new PictureBox(); - private readonly PictureBox _pictureBoxPauseDown = new PictureBox(); - private readonly PictureBox _pictureBoxStop = new PictureBox(); - private readonly PictureBox _pictureBoxStopOver = new PictureBox(); - private readonly PictureBox _pictureBoxStopDown = new PictureBox(); - private readonly PictureBox _pictureBoxFullscreen = new PictureBox(); - private readonly PictureBox _pictureBoxFullscreenOver = new PictureBox(); - private readonly PictureBox _pictureBoxFullscreenDown = new PictureBox(); - private readonly PictureBox _pictureBoxMute = new PictureBox(); - private readonly PictureBox _pictureBoxMuteOver = new PictureBox(); - private readonly PictureBox _pictureBoxMuteDown = new PictureBox(); - private readonly PictureBox _pictureBoxProgressbarBackground = new PictureBox(); - private readonly PictureBox _pictureBoxProgressBar = new PictureBox(); - private readonly PictureBox _pictureBoxVolumeBarBackground = new PictureBox(); - private readonly PictureBox _pictureBoxVolumeBar = new PictureBox(); - private readonly Label _labelTimeCode = new Label(); - private readonly Label _labelVideoPlayerName = new Label(); - private readonly Label _labelVolume = new Label(); - private readonly ToolTip _currentPositionToolTip = new ToolTip(); - private List _chapters; - - public List Chapters - { - get => _chapters; - set - { - _chapters = value; - Invalidate(true); - } - } - - public RightToLeft TextRightToLeft - { - get => TextBox.RightToLeft; - set - { - TextBox.RightToLeft = value; - TextBox.SelectAll(); - TextBox.SelectionAlignment = HorizontalAlignment.Center; - } - } - - public bool ShowStopButton - { - get => _pictureBoxStop.Visible || _pictureBoxStopOver.Visible || _pictureBoxStopDown.Visible; - set - { - if (value) - { - _pictureBoxStop.Visible = true; - _pictureBoxStop.BringToFront(); - } - else - { - HideAllStopImages(); - } - } - } - - public bool ShowMuteButton - { - get => _pictureBoxMute.Visible || _pictureBoxMuteOver.Visible || _pictureBoxMuteDown.Visible; - set - { - if (value) - { - _pictureBoxMute.Visible = true; - _pictureBoxMute.BringToFront(); - } - else - { - HideAllMuteImages(); - } - } - } - - public bool ShowFullscreenButton - { - get => _pictureBoxFullscreen.Visible || _pictureBoxFullscreenOver.Visible || _pictureBoxFullscreenDown.Visible; - set - { - if (value) - { - _pictureBoxFullscreen.Visible = true; - _pictureBoxFullscreen.BringToFront(); - } - else - { - HideAllFullscreenImages(); - } - } - } - - public VideoPlayerContainer() - { - _chapters = new List(); - SmpteMode = false; - FontSizeFactor = 1.0F; - BorderStyle = BorderStyle.None; - _resources = new System.ComponentModel.ComponentResourceManager(typeof(VideoPlayerContainer)); - _labelVolume.Text = Configuration.Settings.General.VideoPlayerDefaultVolume + "%"; - BackColor = _backgroundColor; - Controls.Add(MakePlayerPanel()); - Controls.Add(MakeSubtitlesPanel()); - Controls.Add(MakeControlsPanel()); - _panelControls.BringToFront(); - _pictureBoxProgressBar.Width = 0; - - ShowAllControls(); - if (Configuration.IsRunningOnLinux) - { - System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(1500), () => - { - if (string.IsNullOrEmpty(_labelVideoPlayerName.Text)) - { - _labelVideoPlayerName.Text = "..."; - } - FontSizeFactor = 1.0F; - SetSubtitleFont(); - _labelTimeCode.Text = $"{new TimeCode().ToDisplayString()} / ?"; - ShowAllControls(); - VideoPlayerContainerResize(this, null); - ShowAllControls(); - Invalidate(); - Refresh(); - }); - } - - VideoPlayerContainerResize(this, null); - Resize += VideoPlayerContainerResize; - PanelPlayer.MouseDown += PanelPlayerMouseDown; - - PictureBoxFastForwardMouseEnter(null, null); - PictureBoxFastForwardOverMouseLeave(null, null); - } - - private void ShowAllControls() - { - HideAllPlayImages(); - HideAllPauseImages(); - _pictureBoxPlay.Visible = true; - _pictureBoxPlay.BringToFront(); - - HideAllStopImages(); - _pictureBoxStop.Visible = true; - _pictureBoxStop.BringToFront(); - - HideAllStopImages(); - _pictureBoxStop.Visible = true; - _pictureBoxStop.BringToFront(); - - HideAllFullscreenImages(); - _pictureBoxFullscreen.Visible = true; - _pictureBoxFullscreen.BringToFront(); - - HideAllMuteImages(); - _pictureBoxMute.Visible = true; - _pictureBoxMute.BringToFront(); - - HideAllReverseImages(); - _pictureBoxReverse.Visible = true; - _pictureBoxReverse.BringToFront(); - - HideAllFastForwardImages(); - _pictureBoxFastForward.Visible = true; - _pictureBoxFastForward.BringToFront(); - - _pictureBoxProgressbarBackground.Visible = true; - _pictureBoxProgressbarBackground.BringToFront(); - _pictureBoxProgressBar.Visible = true; - _pictureBoxProgressBar.BringToFront(); - - _labelTimeCode.Visible = true; - _labelTimeCode.BringToFront(); - } - - public void EnableMouseWheelStep() - { - AddMouseWheelEvent(this); - } - - public void SetPlayerName(string s) - { - _labelVideoPlayerName.Text = s; - _labelVideoPlayerName.Left = Width - _labelVideoPlayerName.Width - 3; - } - - public void UpdatePlayerName() - { - if (_videoPlayer != null) - { - SetPlayerName(_videoPlayer.PlayerName); - } - } - - public void ResetTimeLabel() - { - _labelTimeCode.Text = string.Empty; - } - - private void AddMouseWheelEvent(Control control) - { - control.MouseWheel += ControlMouseWheel; - foreach (Control ctrl in control.Controls) - { - AddMouseWheelEvent(ctrl); - } - } - - private void ControlMouseWheel(object sender, MouseEventArgs e) - { - int delta = e.Delta; - double newPosition = CurrentPosition - delta / 256.0; - if (newPosition < 0) - { - newPosition = 0; - } - else if (newPosition > Duration) - { - newPosition = Duration; - } - - CurrentPosition = newPosition; - } - - private Control MakeSubtitlesPanel() - { - _panelSubtitle = new Panel { BackColor = _backgroundColor, Left = 0, Top = 0, Height = _subtitlesHeight + 1 }; - TextBox = new RichTextBoxViewOnly(); - _panelSubtitle.Controls.Add(TextBox); - TextBox.BackColor = _backgroundColor; - TextBox.ForeColor = Color.White; - TextBox.Dock = DockStyle.Fill; - SetSubtitleFont(); - TextBox.MouseClick += SubtitleTextBoxMouseClick; - return _panelSubtitle; - } - - public void SetSubtitleFont() - { - var gs = Configuration.Settings.General; - if (string.IsNullOrEmpty(gs.SubtitleFontName)) - { - gs.SubtitleFontName = "Tahoma"; - } - - if (gs.VideoPlayerPreviewFontBold) - { - TextBox.Font = new Font(gs.SubtitleFontName, gs.VideoPlayerPreviewFontSize * FontSizeFactor, FontStyle.Bold); - } - else - { - TextBox.Font = new Font(gs.SubtitleFontName, gs.VideoPlayerPreviewFontSize * FontSizeFactor, FontStyle.Regular); - } - - SubtitleText = _subtitleText; - } - - private void SubtitleTextBoxMouseClick(object sender, MouseEventArgs e) - { - TogglePlayPause(); - } - - public Paragraph LastParagraph { get; set; } - - public void SetSubtitleText(string text, Paragraph p, Subtitle subtitle) - { - var mpv = VideoPlayer as LibMpvDynamic; - LastParagraph = p; - if (mpv != null && Configuration.Settings.General.MpvHandlesPreviewText) - { - if (_subtitlesHeight > 0) - { - _subtitlesHeight = 0; - VideoPlayerContainerResize(null, null); - } - _subtitleText = text; - RefreshMpv(mpv, subtitle); - if (TextBox.Text.Length > 0) - { - TextBox.Text = string.Empty; - } - } - else - { - if (!string.IsNullOrEmpty(_mpvTextFileName) || _subtitlesHeight == 0) - { - mpv?.RemoveSubtitle(); - _subtitlesHeight = 57; - VideoPlayerContainerResize(null, null); - DeleteTempMpvFileName(); - } - SubtitleText = text; - } - } - - private Subtitle _subtitlePrev; - private string _mpvTextOld = string.Empty; - private string _mpvTextFileName; - private int _retryCount = 3; - private void RefreshMpv(LibMpvDynamic mpv, Subtitle subtitle) - { - if (subtitle == null) - { - return; - } - - try - { - var format = new AdvancedSubStationAlpha(); - string text; - - if (subtitle.Header != null && subtitle.Header.Contains("lang=\"ja\"", StringComparison.Ordinal) && subtitle.Header.Contains("bouten-", StringComparison.Ordinal)) - { - text = NetflixImsc11JapaneseToAss.Convert(subtitle, 1280, 720); - } - else - { - if (subtitle.Header == null || !subtitle.Header.Contains("[V4+ Styles]")) - { - var oldSub = subtitle; - subtitle = new Subtitle(subtitle); - if (TextBox.RightToLeft == RightToLeft.Yes && LanguageAutoDetect.CouldBeRightToLeftLanguage(subtitle)) - { - for (var index = 0; index < subtitle.Paragraphs.Count; index++) - { - var paragraph = subtitle.Paragraphs[index]; - if (LanguageAutoDetect.ContainsRightToLeftLetter(paragraph.Text)) - { - paragraph.Text = Utilities.FixRtlViaUnicodeChars(paragraph.Text); - } - } - } - - var oldFontSize = Configuration.Settings.SubtitleSettings.SsaFontSize; - var oldFontBold = Configuration.Settings.SubtitleSettings.SsaFontBold; - Configuration.Settings.SubtitleSettings.SsaFontSize = Configuration.Settings.General.VideoPlayerPreviewFontSize; - Configuration.Settings.SubtitleSettings.SsaFontBold = Configuration.Settings.General.VideoPlayerPreviewFontBold; - subtitle.Header = AdvancedSubStationAlpha.DefaultHeader; - Configuration.Settings.SubtitleSettings.SsaFontSize = oldFontSize; - Configuration.Settings.SubtitleSettings.SsaFontBold = oldFontBold; - - if (oldSub.Header != null && oldSub.Header.Length > 20 && oldSub.Header.Substring(3, 3) == "STL") - { - subtitle.Header = subtitle.Header.Replace("Style: Default,", "Style: Box,arial,20,&H00FFFFFF,&H0300FFFF,&H00000000,&H02000000,0,0,0,0,100,100,0,0,3,2,0,2,10,10,10,1" + - Environment.NewLine + "Style: Default,"); - for (var index = 0; index < subtitle.Paragraphs.Count; index++) - { - var p = subtitle.Paragraphs[index]; - if (p.Text.Contains("")) - { - p.Extra = "Box"; - p.Text = p.Text.Replace("", string.Empty).Replace("", string.Empty); - } - } - } - } - text = subtitle.ToText(format); - } - - - if (text != _mpvTextOld || _mpvTextFileName == null || _retryCount > 0) - { - if (_retryCount >= 0 || string.IsNullOrEmpty(_mpvTextFileName) || _subtitlePrev == null || _subtitlePrev.FileName != subtitle.FileName || !_mpvTextFileName.EndsWith(format.Extension, StringComparison.Ordinal)) - { - mpv.RemoveSubtitle(); - DeleteTempMpvFileName(); - _mpvTextFileName = FileUtil.GetTempFileName(format.Extension); - File.WriteAllText(_mpvTextFileName, text); - mpv.LoadSubtitle(_mpvTextFileName); - _retryCount--; - } - else - { - File.WriteAllText(_mpvTextFileName, text); - mpv.ReloadSubtitle(); - } - _mpvTextOld = text; - } - _subtitlePrev = subtitle; - } - catch - { - // ignored - } - } - - private void DeleteTempMpvFileName() - { - try - { - if (File.Exists(_mpvTextFileName)) - { - File.Delete(_mpvTextFileName); - _mpvTextFileName = null; - } - } - catch - { - // ignored - } - } - - public string SubtitleText - { - get => _subtitleText; - set - { - _subtitleText = value; - - bool alignLeft = _subtitleText.StartsWith("{\\a1}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\a5}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\a9}", StringComparison.Ordinal) || // sub station alpha - _subtitleText.StartsWith("{\\an1}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\an4}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\an7}", StringComparison.Ordinal); // advanced sub station alpha - - bool alignRight = _subtitleText.StartsWith("{\\a3}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\a7}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\a11}", StringComparison.Ordinal) || // sub station alpha - _subtitleText.StartsWith("{\\an3}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\an6}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\an9}", StringComparison.Ordinal); // advanced sub station alpha - - // remove styles for display text (except italic) - string text = Utilities.RemoveSsaTags(_subtitleText); - text = text.Replace("", string.Empty); - text = text.Replace("", string.Empty); - text = text.Replace("", string.Empty); - - // display italic - var sb = new StringBuilder(); - int i = 0; - bool isItalic = false; - bool isBold = false; - bool isUnderline = false; - bool isFontColor = false; - int fontColorBegin = 0; - TextBox.Text = string.Empty; - int letterCount = 0; - var fontColorLookups = new System.Collections.Generic.Dictionary(); - var styleLookups = new System.Collections.Generic.Dictionary(text.Length); - for (int j = 0; j < text.Length; j++) - { - styleLookups.Add(j, Configuration.Settings.General.VideoPlayerPreviewFontBold ? FontStyle.Bold : FontStyle.Regular); - } - - Color fontColor = Color.White; - while (i < text.Length) - { - if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - TextBox.AppendText(sb.ToString()); - sb.Clear(); - isItalic = true; - i += 2; - } - else if (isItalic && text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - TextBox.AppendText(sb.ToString()); - sb.Clear(); - isItalic = false; - i += 3; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - if (!Configuration.Settings.General.VideoPlayerPreviewFontBold) - { - TextBox.AppendText(sb.ToString()); - sb.Clear(); - isBold = true; - } - i += 2; - } - else if (isBold && text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - if (!Configuration.Settings.General.VideoPlayerPreviewFontBold) - { - TextBox.AppendText(sb.ToString()); - sb.Clear(); - isBold = false; - } - i += 3; - } - else if (Configuration.Settings.General.VideoPlayerPreviewFontBold && text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - i += 3; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - TextBox.AppendText(sb.ToString()); - sb.Clear(); - isUnderline = true; - i += 2; - } - else if (isUnderline && text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - TextBox.AppendText(sb.ToString()); - sb.Clear(); - isUnderline = false; - i += 3; - } - else if (text.Substring(i).StartsWith("'); - if (end > 0) - { - string f = s.Substring(0, end); - int colorStart = f.IndexOf(" color=", StringComparison.OrdinalIgnoreCase); - - if (colorStart > 0) - { - int colorEnd = colorStart + " color=".Length + 1; - if (colorEnd < f.Length) - { - colorEnd = f.IndexOf('"', colorEnd); - if (colorEnd > 0 || colorEnd == -1) - { - if (colorEnd == -1) - { - s = f.Substring(colorStart); - } - else - { - s = f.Substring(colorStart, colorEnd - colorStart); - } - - s = s.Remove(0, " color=".Length); - s = s.Trim('"'); - s = s.Trim('\''); - try - { - fontColor = ColorTranslator.FromHtml(s); - fontFound = true; - } - catch - { - fontFound = false; - if (s.Length > 0) - { - try - { - fontColor = ColorTranslator.FromHtml("#" + s); - fontFound = true; - } - catch - { - fontFound = false; - } - } - } - } - } - } - i += end; - } - if (fontFound) - { - TextBox.AppendText(sb.ToString()); - sb.Clear(); - isFontColor = true; - fontColorBegin = letterCount; - } - } - else if (isFontColor && text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - fontColorLookups.Add(new Point(fontColorBegin, TextBox.Text.Length + sb.ToString().Length - fontColorBegin), fontColor); - TextBox.AppendText(sb.ToString()); - sb.Clear(); - isFontColor = false; - i += 6; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - i += 6; - } - else if (text[i] == '\n') // RichTextBox only count NewLine as one character! - { - sb.Append(text[i]); - } - else if (text[i] == '\r') - { - // skip carriage return (0xd / 13) - } - else - { - var idx = TextBox.TextLength + sb.Length; - if (isBold) - { - styleLookups[idx] |= FontStyle.Bold; - } - - if (isItalic) - { - styleLookups[idx] |= FontStyle.Italic; - } - - if (isUnderline) - { - styleLookups[idx] |= FontStyle.Underline; - } - - sb.Append(text[i]); - letterCount++; - } - i++; - } - TextBox.Text += sb.ToString(); - TextBox.SelectAll(); - - if (alignLeft) - { - TextBox.SelectionAlignment = HorizontalAlignment.Left; - } - else if (alignRight) - { - TextBox.SelectionAlignment = HorizontalAlignment.Right; - } - else - { - TextBox.SelectionAlignment = HorizontalAlignment.Center; - } - - TextBox.DeselectAll(); - - Font currentFont = TextBox.SelectionFont; - for (int k = 0; k < TextBox.TextLength; k++) - { - TextBox.SelectionStart = k; - TextBox.SelectionLength = 1; - TextBox.SelectionFont = new Font(currentFont.FontFamily, currentFont.Size, styleLookups[k]); - TextBox.DeselectAll(); - } - - foreach (var entry in fontColorLookups) - { - TextBox.SelectionStart = entry.Key.X; - TextBox.SelectionLength = entry.Key.Y; - TextBox.SelectionColor = entry.Value; - TextBox.DeselectAll(); - } - } - } - - private void PanelPlayerMouseDown(object sender, MouseEventArgs e) - { - if (VideoPlayer == null) - { - OnEmptyPlayerClicked?.Invoke(sender, e); - } - - TogglePlayPause(); - } - - public void InitializeVolume(double defaultVolume) - { - int maxVolume = _pictureBoxVolumeBarBackground.Width - 18; - _pictureBoxVolumeBar.Width = (int)(maxVolume * defaultVolume / 100.0); - } - - private Control MakePlayerPanel() - { - PanelPlayer = new Panel { BackColor = _backgroundColor, Left = 0, Top = 0 }; - return PanelPlayer; - } - - public void HideControls(bool hideCursor) - { - if (_panelControls.Visible) - { - _panelSubtitle.Height += _controlsHeight; - _panelControls.Visible = false; - } - if (hideCursor) - { - HideCursor(); - } - } - - public void ShowControls() - { - if (!_panelControls.Visible) - { - _panelControls.Visible = true; - _panelControls.BringToFront(); - _panelSubtitle.Height -= _controlsHeight; - } - ShowCursor(); - } - - public void HideCursor() - { - if (_cursorStatus < 0) - { - return; - } - - _cursorStatus--; - if (VideoPlayer != null) - { - var mpv = VideoPlayer as LibMpvDynamic; - mpv?.HideCursor(); - } - Cursor.Hide(); - } - - private int _cursorStatus; - - public void ShowCursor() - { - if (_cursorStatus >= 0) - { - return; - } - - _cursorStatus++; - if (VideoPlayer != null) - { - var mpv = VideoPlayer as LibMpvDynamic; - mpv?.ShowCursor(); - } - Cursor.Show(); - } - - private Control MakeControlsPanel() - { - _panelControls = new Panel { Left = 0, Height = _controlsHeight }; - - _pictureBoxBackground = new PictureBox - { - Image = (Image)_resources.GetObject("pictureBoxBar.Image"), - Location = new Point(0, 0), - Name = "_pictureBoxBackground", - Size = new Size(200, 45), - SizeMode = PictureBoxSizeMode.StretchImage, - TabStop = false - }; - _panelControls.Controls.Add(_pictureBoxBackground); - - _pictureBoxPlay = new PictureBox - { - Image = (Image)_resources.GetObject("pictureBoxPlay.Image"), - Location = new Point(22, 126 - 113), - Name = "_pictureBoxPlay", - Size = new Size(29, 29), - SizeMode = PictureBoxSizeMode.AutoSize, - TabStop = false - }; - _pictureBoxPlay.MouseEnter += PictureBoxPlayMouseEnter; - _panelControls.Controls.Add(_pictureBoxPlay); - - _pictureBoxPlayDown = new PictureBox - { - Image = (Image)_resources.GetObject("pictureBoxPlayDown.Image"), - Location = new Point(22, 127 - 113), - Name = "_pictureBoxPlayDown", - Size = new Size(29, 29), - SizeMode = PictureBoxSizeMode.AutoSize, - TabStop = false - }; - _panelControls.Controls.Add(_pictureBoxPlayDown); - - _pictureBoxPlayOver = new PictureBox - { - Image = (Image)_resources.GetObject("pictureBoxPlayOver.Image"), - Location = new Point(23, 126 - 113), - Name = "_pictureBoxPlayOver", - Size = new Size(29, 29), - SizeMode = PictureBoxSizeMode.AutoSize, - TabStop = false - }; - _pictureBoxPlayOver.MouseLeave += PictureBoxPlayOverMouseLeave; - _pictureBoxPlayOver.MouseDown += PictureBoxPlayOverMouseDown; - _pictureBoxPlayOver.MouseUp += PictureBoxPlayOverMouseUp; - _panelControls.Controls.Add(_pictureBoxPlayOver); - - _pictureBoxPause.Image = (Image)_resources.GetObject("pictureBoxPause.Image"); - _pictureBoxPause.Location = new Point(23, 126 - 113); - _pictureBoxPause.Name = "_pictureBoxPause"; - _pictureBoxPause.Size = new Size(29, 29); - _pictureBoxPause.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxPause.TabStop = false; - _pictureBoxPause.MouseEnter += PictureBoxPauseMouseEnter; - _panelControls.Controls.Add(_pictureBoxPause); - - _pictureBoxPauseDown.Image = (Image)_resources.GetObject("pictureBoxPauseDown.Image"); - _pictureBoxPauseDown.Location = new Point(22, 127 - 113); - _pictureBoxPauseDown.Name = "_pictureBoxPauseDown"; - _pictureBoxPauseDown.Size = new Size(29, 29); - _pictureBoxPauseDown.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxPauseDown.TabStop = false; - _panelControls.Controls.Add(_pictureBoxPauseDown); - - _pictureBoxPauseOver.Image = (Image)_resources.GetObject("pictureBoxPauseOver.Image"); - _pictureBoxPauseOver.Location = new Point(22, 127 - 113); - _pictureBoxPauseOver.Name = "_pictureBoxPauseOver"; - _pictureBoxPauseOver.Size = new Size(29, 29); - _pictureBoxPauseOver.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxPauseOver.TabStop = false; - _pictureBoxPauseOver.MouseLeave += PictureBoxPauseOverMouseLeave; - _pictureBoxPauseOver.MouseDown += PictureBoxPauseOverMouseDown; - _pictureBoxPauseOver.MouseUp += PictureBoxPauseOverMouseUp; - _panelControls.Controls.Add(_pictureBoxPauseOver); - - _pictureBoxStop.Image = (Image)_resources.GetObject("pictureBoxStop.Image"); - _pictureBoxStop.Location = new Point(52, 130 - 113); - _pictureBoxStop.Name = "_pictureBoxStop"; - _pictureBoxStop.Size = new Size(20, 20); - _pictureBoxStop.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxStop.TabStop = false; - _pictureBoxStop.MouseEnter += PictureBoxStopMouseEnter; - _panelControls.Controls.Add(_pictureBoxStop); - - _pictureBoxStopDown.Image = (Image)_resources.GetObject("pictureBoxStopDown.Image"); - _pictureBoxStopDown.Location = new Point(52, 130 - 113); - _pictureBoxStopDown.Name = "_pictureBoxStopDown"; - _pictureBoxStopDown.Size = new Size(20, 20); - _pictureBoxStopDown.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxStopDown.TabStop = false; - _panelControls.Controls.Add(_pictureBoxStopDown); - - _pictureBoxStopOver.Image = (Image)_resources.GetObject("pictureBoxStopOver.Image"); - _pictureBoxStopOver.Location = new Point(52, 130 - 113); - _pictureBoxStopOver.Name = "_pictureBoxStopOver"; - _pictureBoxStopOver.Size = new Size(20, 20); - _pictureBoxStopOver.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxStopOver.TabStop = false; - _pictureBoxStopOver.MouseLeave += PictureBoxStopOverMouseLeave; - _pictureBoxStopOver.MouseDown += PictureBoxStopOverMouseDown; - _pictureBoxStopOver.MouseUp += PictureBoxStopOverMouseUp; - _panelControls.Controls.Add(_pictureBoxStopOver); - - _pictureBoxFullscreen.Image = (Image)_resources.GetObject("pictureBoxFS.Image"); - _pictureBoxFullscreen.Location = new Point(95, 130 - 113); - _pictureBoxFullscreen.Name = "_pictureBoxFullscreen"; - _pictureBoxFullscreen.Size = new Size(20, 20); - _pictureBoxFullscreen.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxFullscreen.TabStop = false; - _pictureBoxFullscreen.MouseEnter += PictureBoxFullscreenMouseEnter; - _panelControls.Controls.Add(_pictureBoxFullscreen); - - _pictureBoxFullscreenDown.Image = (Image)_resources.GetObject("pictureBoxFSDown.Image"); - _pictureBoxFullscreenDown.Location = new Point(95, 130 - 113); - _pictureBoxFullscreenDown.Name = "_pictureBoxFullscreenDown"; - _pictureBoxFullscreenDown.Size = new Size(20, 20); - _pictureBoxFullscreenDown.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxFullscreenDown.TabStop = false; - _panelControls.Controls.Add(_pictureBoxFullscreenDown); - - _pictureBoxFullscreenOver.Image = (Image)_resources.GetObject("pictureBoxFSOver.Image"); - _pictureBoxFullscreenOver.Location = new Point(95, 130 - 113); - _pictureBoxFullscreenOver.Name = "_pictureBoxFullscreenOver"; - _pictureBoxFullscreenOver.Size = new Size(20, 20); - _pictureBoxFullscreenOver.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxFullscreenOver.TabStop = false; - _pictureBoxFullscreenOver.MouseLeave += PictureBoxFullscreenOverMouseLeave; - _pictureBoxFullscreenOver.MouseDown += PictureBoxFullscreenOverMouseDown; - _pictureBoxFullscreenOver.MouseUp += PictureBoxFullscreenOverMouseUp; - _panelControls.Controls.Add(_pictureBoxFullscreenOver); - - _pictureBoxProgressbarBackground.Anchor = AnchorStyles.Top | AnchorStyles.Left; - _pictureBoxProgressbarBackground.BackColor = Color.Transparent; - _pictureBoxProgressbarBackground.Image = (Image)_resources.GetObject("pictureBoxProgressbarBackground.Image"); - _pictureBoxProgressbarBackground.Location = new Point(43, 114 - 113); - _pictureBoxProgressbarBackground.Margin = new Padding(0); - _pictureBoxProgressbarBackground.Name = "_pictureBoxProgressbarBackground"; - _pictureBoxProgressbarBackground.Size = new Size(531, 12); - _pictureBoxProgressbarBackground.SizeMode = PictureBoxSizeMode.StretchImage; - _pictureBoxProgressbarBackground.TabStop = false; - _pictureBoxProgressbarBackground.Paint += PictureBoxProgressbarBackgroundPaint; - _pictureBoxProgressbarBackground.MouseDown += PictureBoxProgressbarBackgroundMouseDown; - _pictureBoxProgressbarBackground.MouseLeave += PictureBoxProgressbarBackgroundMouseLeave; - _pictureBoxProgressbarBackground.MouseMove += PictureBoxProgressbarBackgroundMouseMove; - _panelControls.Controls.Add(_pictureBoxProgressbarBackground); - - _pictureBoxProgressBar.Image = (Image)_resources.GetObject("pictureBoxProgressBar.Image"); - _pictureBoxProgressBar.Location = new Point(47, 118 - 113); - _pictureBoxProgressBar.Name = "_pictureBoxProgressBar"; - _pictureBoxProgressBar.Size = new Size(318, 4); - _pictureBoxProgressBar.SizeMode = PictureBoxSizeMode.StretchImage; - _pictureBoxProgressBar.TabStop = false; - _pictureBoxProgressBar.Paint += PictureBoxProgressBarPaint; - _pictureBoxProgressBar.MouseDown += PictureBoxProgressBarMouseDown; - _pictureBoxProgressBar.MouseLeave += PictureBoxProgressBarMouseLeave; - _pictureBoxProgressBar.MouseMove += PictureBoxProgressBarMouseMove; - _panelControls.Controls.Add(_pictureBoxProgressBar); - _pictureBoxProgressBar.BringToFront(); - - _pictureBoxMute.Image = (Image)_resources.GetObject("pictureBoxMute.Image"); - _pictureBoxMute.Location = new Point(75, 131 - 113); - _pictureBoxMute.Name = "_pictureBoxMute"; - _pictureBoxMute.Size = new Size(19, 19); - _pictureBoxMute.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxMute.TabStop = false; - _pictureBoxMute.MouseEnter += PictureBoxMuteMouseEnter; - _panelControls.Controls.Add(_pictureBoxMute); - - _pictureBoxMuteDown.Image = (Image)_resources.GetObject("pictureBoxMuteDown.Image"); - _pictureBoxMuteDown.Location = new Point(75, 131 - 113); - _pictureBoxMuteDown.Name = "_pictureBoxMuteDown"; - _pictureBoxMuteDown.Size = new Size(19, 19); - _pictureBoxMuteDown.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxMuteDown.TabStop = false; - _pictureBoxMuteDown.Click += PictureBoxMuteDownClick; - _panelControls.Controls.Add(_pictureBoxMuteDown); - - _pictureBoxMuteOver.Image = (Image)_resources.GetObject("pictureBoxMuteOver.Image"); - _pictureBoxMuteOver.Location = new Point(75, 131 - 113); - _pictureBoxMuteOver.Name = "_pictureBoxMuteOver"; - _pictureBoxMuteOver.Size = new Size(19, 19); - _pictureBoxMuteOver.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxMuteOver.TabStop = false; - _pictureBoxMuteOver.MouseLeave += PictureBoxMuteOverMouseLeave; - _pictureBoxMuteOver.MouseDown += PictureBoxMuteOverMouseDown; - _pictureBoxMuteOver.MouseUp += PictureBoxMuteOverMouseUp; - _panelControls.Controls.Add(_pictureBoxMuteOver); - - _pictureBoxVolumeBarBackground.Image = (Image)_resources.GetObject("pictureBoxVolumeBarBackground.Image"); - _pictureBoxVolumeBarBackground.Location = new Point(111, 135 - 113); - _pictureBoxVolumeBarBackground.Name = "_pictureBoxVolumeBarBackground"; - _pictureBoxVolumeBarBackground.Size = new Size(82, 13); - _pictureBoxVolumeBarBackground.SizeMode = PictureBoxSizeMode.AutoSize; - _pictureBoxVolumeBarBackground.TabStop = false; - _pictureBoxVolumeBarBackground.MouseDown += PictureBoxVolumeBarBackgroundMouseDown; - _panelControls.Controls.Add(_pictureBoxVolumeBarBackground); - - _pictureBoxVolumeBar.Image = (Image)_resources.GetObject("pictureBoxVolumeBar.Image"); - _pictureBoxVolumeBar.Location = new Point(120, 139 - 113); - _pictureBoxVolumeBar.Name = "_pictureBoxVolumeBar"; - _pictureBoxVolumeBar.Size = new Size(48, 4); - _pictureBoxVolumeBar.SizeMode = PictureBoxSizeMode.StretchImage; - _pictureBoxVolumeBar.TabStop = false; - _pictureBoxVolumeBar.MouseDown += PictureBoxVolumeBarMouseDown; - _panelControls.Controls.Add(_pictureBoxVolumeBar); - _pictureBoxVolumeBar.BringToFront(); - - _pictureBoxReverse = new PictureBox - { - Image = (Image)_resources.GetObject("pictureBoxReverse.Image"), - Location = new Point(28, 3), - Name = "_pictureBoxReverse", - Size = new Size(16, 8), - SizeMode = PictureBoxSizeMode.AutoSize, - TabStop = false - }; - _panelControls.Controls.Add(_pictureBoxReverse); - _pictureBoxReverse.MouseEnter += PictureBoxReverseMouseEnter; - - _pictureBoxReverseOver = new PictureBox - { - Image = (Image)_resources.GetObject("pictureBoxReverseMouseOver.Image"), - Location = _pictureBoxReverse.Location, - Name = "_pictureBoxReverseOver", - Size = _pictureBoxReverse.Size, - SizeMode = PictureBoxSizeMode.AutoSize, - TabStop = false - }; - _panelControls.Controls.Add(_pictureBoxReverseOver); - _pictureBoxReverseOver.MouseLeave += PictureBoxReverseOverMouseLeave; - _pictureBoxReverseOver.MouseDown += PictureBoxReverseOverMouseDown; - _pictureBoxReverseOver.MouseUp += PictureBoxReverseOverMouseUp; - - _pictureBoxReverseDown = new PictureBox - { - Image = (Image)_resources.GetObject("pictureBoxReverseMouseDown.Image"), - Location = _pictureBoxReverse.Location, - Name = "_pictureBoxReverseOver", - Size = _pictureBoxReverse.Size, - SizeMode = PictureBoxSizeMode.AutoSize, - TabStop = false - }; - _panelControls.Controls.Add(_pictureBoxReverseDown); - - _pictureBoxFastForward = new PictureBox - { - Image = (Image)_resources.GetObject("pictureBoxFastForward.Image"), - Location = new Point(571, 1), - Name = "_pictureBoxFastForward", - Size = new Size(17, 13), - SizeMode = PictureBoxSizeMode.AutoSize, - TabStop = false - }; - _panelControls.Controls.Add(_pictureBoxFastForward); - _pictureBoxFastForward.MouseEnter += PictureBoxFastForwardMouseEnter; - - _pictureBoxFastForwardOver = new PictureBox - { - Image = (Image)_resources.GetObject("pictureBoxFastForwardMouseOver.Image"), - Location = _pictureBoxFastForward.Location, - Name = "_pictureBoxFastForwardOver", - Size = _pictureBoxFastForward.Size, - SizeMode = PictureBoxSizeMode.AutoSize, - TabStop = false - }; - _panelControls.Controls.Add(_pictureBoxFastForwardOver); - _pictureBoxFastForwardOver.MouseLeave += PictureBoxFastForwardOverMouseLeave; - _pictureBoxFastForwardOver.MouseDown += PictureBoxFastForwardOverMouseDown; - _pictureBoxFastForwardOver.MouseUp += PictureBoxFastForwardOverMouseUp; - - _pictureBoxFastForwardDown = new PictureBox - { - Image = (Image)_resources.GetObject("pictureBoxFastForwardMouseDown.Image"), - Location = _pictureBoxFastForward.Location, - Name = "_pictureBoxFastForwardDown", - Size = _pictureBoxFastForward.Size, - SizeMode = PictureBoxSizeMode.AutoSize, - TabStop = false - }; - _panelControls.Controls.Add(_pictureBoxFastForwardDown); - - _labelVolume.Location = new Point(120, 17); - _labelVolume.ForeColor = Color.WhiteSmoke; - _labelVolume.BackColor = Color.FromArgb(67, 75, 93); - _labelVolume.AutoSize = true; - _labelVolume.Font = new Font(_labelTimeCode.Font.FontFamily, 6); - _panelControls.Controls.Add(_labelVolume); - - _labelTimeCode.Location = new Point(280, 28); - _labelTimeCode.ForeColor = Color.WhiteSmoke; - _labelTimeCode.Font = new Font(_labelTimeCode.Font.FontFamily, 8, FontStyle.Bold); - _labelTimeCode.AutoSize = true; - _panelControls.Controls.Add(_labelTimeCode); - - _labelVideoPlayerName.Location = new Point(282, 17); - _labelVideoPlayerName.ForeColor = Color.WhiteSmoke; - _labelVideoPlayerName.BackColor = Color.FromArgb(67, 75, 93); - _labelVideoPlayerName.AutoSize = true; - _labelVideoPlayerName.Font = new Font(_labelTimeCode.Font.FontFamily, 6); - _panelControls.Controls.Add(_labelVideoPlayerName); - - if (Configuration.Settings.General.UseDarkTheme) - { - _labelVolume.ForeColor = Color.Gray; - _labelTimeCode.ForeColor = Color.Gray; - _labelVideoPlayerName.ForeColor = Color.Gray; - } - - - _pictureBoxBackground.SendToBack(); - _pictureBoxFastForwardDown.BringToFront(); - _pictureBoxFastForwardOver.BringToFront(); - _pictureBoxFastForward.BringToFront(); - _pictureBoxPlay.BringToFront(); - - _panelControls.BackColor = _backgroundColor; - _pictureBoxPlayDown.BringToFront(); - _pictureBoxPlayOver.BringToFront(); - _pictureBoxPlay.BringToFront(); - _labelTimeCode.BringToFront(); - _labelVolume.BringToFront(); - return _panelControls; - } - - public void VideoPlayerContainerResize(object sender, EventArgs e) - { - _controlsHeight = _pictureBoxBackground.Height; - PanelPlayer.Height = Height - (_controlsHeight + _subtitlesHeight); - PanelPlayer.Width = Width; - _videoPlayer?.Resize(PanelPlayer.Width, PanelPlayer.Height); - - _panelSubtitle.Top = Height - (_controlsHeight + _subtitlesHeight); - _panelSubtitle.Width = Width; - - _panelControls.Top = Height - _controlsHeight + 2; - _panelControls.Width = Width; - _pictureBoxBackground.Width = Width; - _pictureBoxProgressbarBackground.Width = Width - (_pictureBoxProgressbarBackground.Left * 2); - _pictureBoxFastForward.Left = Width - 48; - _pictureBoxFastForwardDown.Left = _pictureBoxFastForward.Left; - _pictureBoxFastForwardOver.Left = _pictureBoxFastForward.Left; - - ResizeTimeCode(); - - _labelVideoPlayerName.Left = Width - _labelVideoPlayerName.Width - 3; - DeleteTempMpvFileName(); - } - - private void ResizeTimeCode() - { - if (string.IsNullOrEmpty(_labelTimeCode.Text)) - { - var span = TimeCode.FromSeconds(1); - _labelTimeCode.Text = $"{span.ToDisplayString()} / {span.ToDisplayString()}{(SmpteMode ? " SMPTE" : string.Empty)}"; - _labelTimeCode.Left = Width - _labelTimeCode.Width - 9; - if (_labelTimeCode.Top + _labelTimeCode.Height >= _panelControls.Height - 4) - { - _labelTimeCode.Font = new Font(_labelTimeCode.Font.Name, _labelTimeCode.Font.Size - 1); - } - - _labelTimeCode.Text = string.Empty; - } - else - { - _labelTimeCode.Left = Width - _labelTimeCode.Width - 9; - if (_labelTimeCode.Top + _labelTimeCode.Height >= _panelControls.Height - 4) - { - _labelTimeCode.Font = new Font(_labelTimeCode.Font.Name, _labelTimeCode.Font.Size - 1); - } - } - } - - #region PlayPauseButtons - - public void RefreshPlayPauseButtons() - { - if (VideoPlayer != null) - { - if (VideoPlayer.IsPlaying) - { - if (!_pictureBoxPause.Visible && !_pictureBoxPauseDown.Visible && !_pictureBoxPauseOver.Visible) - { - HideAllPauseImages(); - HideAllPlayImages(); - _pictureBoxPause.Visible = true; - _pictureBoxPause.BringToFront(); - } - } - else - { - if (!_pictureBoxPlay.Visible && !_pictureBoxPlayOver.Visible && !_pictureBoxPlayDown.Visible) - { - HideAllPauseImages(); - HideAllPlayImages(); - _pictureBoxPlay.Visible = true; - _pictureBoxPlay.BringToFront(); - } - } - } - } - - private void HideAllPlayImages() - { - _pictureBoxPlayOver.Visible = false; - _pictureBoxPlayDown.Visible = false; - _pictureBoxPlay.Visible = false; - } - - private void PictureBoxPlayMouseEnter(object sender, EventArgs e) - { - if (_pictureBoxPlay.Visible) - { - HideAllPlayImages(); - _pictureBoxPlayOver.Visible = true; - _pictureBoxPlayOver.BringToFront(); - } - } - - private void PictureBoxPlayOverMouseLeave(object sender, EventArgs e) - { - if (_pictureBoxPlayOver.Visible) - { - HideAllPlayImages(); - _pictureBoxPlay.Visible = true; - _pictureBoxPlay.BringToFront(); - } - } - - private void PictureBoxPlayOverMouseDown(object sender, MouseEventArgs e) - { - HideAllPlayImages(); - _pictureBoxPlayDown.Visible = true; - _pictureBoxPlayDown.BringToFront(); - OnButtonClicked?.Invoke(sender, e); - } - - private void PictureBoxPlayOverMouseUp(object sender, MouseEventArgs e) - { - if (IsMouseOverControl((PictureBox)sender, e.Location)) - { - HideAllPlayImages(); - _pictureBoxPause.Visible = true; - _pictureBoxPause.BringToFront(); - Play(); - } - else - { - HideAllPlayImages(); - _pictureBoxPlay.Visible = true; - _pictureBoxPause.BringToFront(); - } - } - - private void HideAllPauseImages() - { - _pictureBoxPauseOver.Visible = false; - _pictureBoxPauseDown.Visible = false; - _pictureBoxPause.Visible = false; - } - - private void PictureBoxPauseMouseEnter(object sender, EventArgs e) - { - if (_pictureBoxPause.Visible) - { - HideAllPauseImages(); - _pictureBoxPauseOver.Visible = true; - _pictureBoxPauseOver.BringToFront(); - } - } - - private void PictureBoxPauseOverMouseLeave(object sender, EventArgs e) - { - if (_pictureBoxPauseOver.Visible) - { - HideAllPauseImages(); - _pictureBoxPause.Visible = true; - _pictureBoxPause.BringToFront(); - } - } - - private void PictureBoxPauseOverMouseDown(object sender, MouseEventArgs e) - { - if (_pictureBoxPauseOver.Visible) - { - HideAllPauseImages(); - _pictureBoxPauseDown.Visible = true; - _pictureBoxPauseDown.BringToFront(); - } - OnButtonClicked?.Invoke(sender, e); - } - - private void PictureBoxPauseOverMouseUp(object sender, MouseEventArgs e) - { - if (IsMouseOverControl((PictureBox)sender, e.Location)) - { - HideAllPauseImages(); - _pictureBoxPlay.Visible = true; - _pictureBoxPlay.BringToFront(); - Pause(); - } - else - { - HideAllPauseImages(); - _pictureBoxPause.Visible = true; - _pictureBoxPause.BringToFront(); - } - } - - #endregion PlayPauseButtons - - #region StopButtons - - private void HideAllStopImages() - { - _pictureBoxStopOver.Visible = false; - _pictureBoxStopDown.Visible = false; - _pictureBoxStop.Visible = false; - } - - private void PictureBoxStopMouseEnter(object sender, EventArgs e) - { - HideAllStopImages(); - _pictureBoxStopOver.Visible = true; - _pictureBoxStopOver.BringToFront(); - } - - private void PictureBoxStopOverMouseLeave(object sender, EventArgs e) - { - if (_pictureBoxStopOver.Visible) - { - HideAllStopImages(); - _pictureBoxStop.Visible = true; - _pictureBoxStop.BringToFront(); - } - } - - private void PictureBoxStopOverMouseDown(object sender, MouseEventArgs e) - { - if (_pictureBoxStopOver.Visible) - { - HideAllStopImages(); - _pictureBoxStopDown.Visible = true; - _pictureBoxStopDown.BringToFront(); - } - OnButtonClicked?.Invoke(sender, e); - } - - private void PictureBoxStopOverMouseUp(object sender, MouseEventArgs e) - { - if (IsMouseOverControl((PictureBox)sender, e.Location)) - { - HideAllStopImages(); - _pictureBoxStop.Visible = true; - _pictureBoxStop.BringToFront(); - Stop(); - } - else - { - HideAllStopImages(); - _pictureBoxStop.Visible = true; - _pictureBoxStop.BringToFront(); - } - } - - #endregion StopButtons - - #region FullscreenButtons - - private void HideAllFullscreenImages() - { - _pictureBoxFullscreenOver.Visible = false; - _pictureBoxFullscreenDown.Visible = false; - _pictureBoxFullscreen.Visible = false; - } - - public void ShowFullScreenControls() - { - _pictureBoxFullscreen.Image = (Image)_resources.GetObject("pictureBoxNoFS.Image"); - _pictureBoxFullscreenDown.Image = (Image)_resources.GetObject("pictureBoxNoFSDown.Image"); - _pictureBoxFullscreenOver.Image = (Image)_resources.GetObject("pictureBoxNoFSOver.Image"); - } - - public void ShowNonFullScreenControls() - { - _pictureBoxFullscreen.Image = (Image)_resources.GetObject("pictureBoxFS.Image"); - _pictureBoxFullscreenDown.Image = (Image)_resources.GetObject("pictureBoxFSDown.Image"); - _pictureBoxFullscreenOver.Image = (Image)_resources.GetObject("pictureBoxFSOver.Image"); - } - - private void PictureBoxFullscreenMouseEnter(object sender, EventArgs e) - { - HideAllFullscreenImages(); - _pictureBoxFullscreenOver.Visible = true; - _pictureBoxFullscreenOver.BringToFront(); - } - - private void PictureBoxFullscreenOverMouseLeave(object sender, EventArgs e) - { - if (_pictureBoxFullscreenOver.Visible) - { - HideAllFullscreenImages(); - _pictureBoxFullscreen.Visible = true; - _pictureBoxFullscreen.BringToFront(); - } - } - - private void PictureBoxFullscreenOverMouseDown(object sender, MouseEventArgs e) - { - HideAllFullscreenImages(); - OnButtonClicked?.Invoke(sender, e); - } - - private void PictureBoxFullscreenOverMouseUp(object sender, MouseEventArgs e) - { - HideAllFullscreenImages(); - _pictureBoxFullscreen.Visible = true; - _pictureBoxFullscreen.BringToFront(); - } - - #endregion FullscreenButtons - - #region Mute buttons - - private void HideAllMuteImages() - { - _pictureBoxMuteOver.Visible = false; - _pictureBoxMuteDown.Visible = false; - _pictureBoxMute.Visible = false; - } - - private void PictureBoxMuteMouseEnter(object sender, EventArgs e) - { - HideAllMuteImages(); - if (Mute) - { - _pictureBoxMuteDown.Visible = true; - _pictureBoxMuteDown.BringToFront(); - } - else - { - _pictureBoxMuteOver.Visible = true; - _pictureBoxMuteOver.BringToFront(); - } - } - - private void PictureBoxMuteOverMouseLeave(object sender, EventArgs e) - { - if (_pictureBoxMuteOver.Visible) - { - HideAllMuteImages(); - _pictureBoxMute.Visible = true; - _pictureBoxMute.BringToFront(); - } - } - - private void PictureBoxMuteOverMouseDown(object sender, MouseEventArgs e) - { - if (_pictureBoxMuteOver.Visible) - { - HideAllMuteImages(); - _pictureBoxMuteDown.Visible = true; - _pictureBoxMuteDown.BringToFront(); - } - OnButtonClicked?.Invoke(sender, e); - } - - private void PictureBoxMuteOverMouseUp(object sender, MouseEventArgs e) - { - if (IsMouseOverControl((PictureBox)sender, e.Location)) - { - HideAllMuteImages(); - _pictureBoxMuteDown.Visible = true; - _pictureBoxMuteDown.BringToFront(); - Mute = true; - } - else - { - HideAllMuteImages(); - _pictureBoxMute.Visible = true; - _pictureBoxMute.BringToFront(); - } - } - - private void PictureBoxMuteDownClick(object sender, EventArgs e) - { - Mute = false; - HideAllMuteImages(); - _pictureBoxMute.Visible = true; - _pictureBoxMute.BringToFront(); - OnButtonClicked?.Invoke(sender, e); - } - - #endregion Mute buttons - - #region Reverse buttons - - private void HideAllReverseImages() - { - _pictureBoxReverseOver.Visible = false; - _pictureBoxReverseDown.Visible = false; - _pictureBoxReverse.Visible = false; - } - - private void PictureBoxReverseMouseEnter(object sender, EventArgs e) - { - HideAllReverseImages(); - _pictureBoxReverseOver.Visible = true; - _pictureBoxReverseOver.BringToFront(); - } - - private void PictureBoxReverseOverMouseLeave(object sender, EventArgs e) - { - HideAllReverseImages(); - _pictureBoxReverse.Visible = true; - _pictureBoxReverse.BringToFront(); - } - - private void PictureBoxReverseOverMouseDown(object sender, MouseEventArgs e) - { - HideAllReverseImages(); - _pictureBoxReverseDown.Visible = true; - _pictureBoxReverseDown.BringToFront(); - if (VideoPlayer != null) - { - var newPosition = CurrentPosition - 3.0; - if (newPosition < 0) - { - newPosition = 0; - } - - CurrentPosition = newPosition; - } - } - - private void PictureBoxReverseOverMouseUp(object sender, MouseEventArgs e) - { - HideAllReverseImages(); - _pictureBoxReverse.Visible = true; - _pictureBoxReverse.BringToFront(); - } - - #endregion Reverse buttons - - #region Fast forward buttons - - private void HideAllFastForwardImages() - { - _pictureBoxFastForwardOver.Visible = false; - _pictureBoxFastForwardDown.Visible = false; - _pictureBoxFastForward.Visible = false; - } - - private void PictureBoxFastForwardMouseEnter(object sender, EventArgs e) - { - HideAllFastForwardImages(); - _pictureBoxFastForwardOver.Visible = true; - _pictureBoxFastForwardOver.BringToFront(); - } - - private void PictureBoxFastForwardOverMouseLeave(object sender, EventArgs e) - { - HideAllFastForwardImages(); - _pictureBoxFastForward.Visible = true; - _pictureBoxFastForward.BringToFront(); - } - - private void PictureBoxFastForwardOverMouseDown(object sender, MouseEventArgs e) - { - HideAllFastForwardImages(); - _pictureBoxFastForwardDown.Visible = true; - _pictureBoxFastForwardDown.BringToFront(); - - if (VideoPlayer != null) - { - var newPosition = CurrentPosition + 3.0; - if (newPosition < 0) - { - newPosition = 0; - } - - CurrentPosition = newPosition; - } - } - - private void PictureBoxFastForwardOverMouseUp(object sender, MouseEventArgs e) - { - HideAllFastForwardImages(); - _pictureBoxFastForward.Visible = true; - _pictureBoxFastForward.BringToFront(); - } - - #endregion Fast forward buttons - - #region Progress bars - - private void SetProgressBarPosition(int mouseX) - { - int max = _pictureBoxProgressbarBackground.Width - 9; - if (mouseX > max) - { - mouseX = max; - } - else if (mouseX < 0) - { - mouseX = 0; - } - - double percent = mouseX * 100.0 / max; - _pictureBoxProgressBar.Width = (int)(max * percent / 100.0); - - CurrentPosition = percent * Duration / 100.0; - } - - private int SecondsToXPosition(double seconds) - { - int max = _pictureBoxProgressbarBackground.Width - 9; - return (int)Math.Round(seconds * max / Duration); - } - - private double CursorVideoPosition(double mouseX) - { - int max = _pictureBoxProgressbarBackground.Width - 9; - if (mouseX > max) - { - mouseX = max; - } - else if (mouseX < 0) - { - mouseX = 0; - } - - double videoPosition = mouseX * Duration / max; - - return videoPosition; - } - - private string CurrentPositionToolTipText(double mouseX) - { - double cursorVideoPosition = CursorVideoPosition(mouseX); - string toolTiptext = TimeCode.FromSeconds(cursorVideoPosition + Configuration.Settings.General.CurrentVideoOffsetInMs / TimeCode.BaseUnit).ToDisplayString(); - - if (_chapters?.Count > 0) - { - toolTiptext += " - "; - - for (int index = 0; index < _chapters.Count; index++) - { - var chapterTime = _chapters[index].StartTime; - var nextChapterTime = index + 1 < _chapters.Count ? _chapters[index + 1].StartTime : Duration; - - if (cursorVideoPosition >= chapterTime && cursorVideoPosition < nextChapterTime) - { - if (_chapters[index].Nested) - { - toolTiptext += "+ "; - } - - toolTiptext += _chapters[index].Name; - break; - } - } - } - - return toolTiptext; - } - - private void DrawChapters(Graphics graphics, int mergin, int startPoint, int endPoint) - { - try - { - int max = _pictureBoxProgressbarBackground.Width - 9; - int index = 0; - while (index < _chapters.Count) - { - int pos; - try - { - double time = _chapters[index++].StartTime; - pos = SecondsToXPosition(time) + mergin; - } - catch - { - pos = -1; - } - if (pos > 0 && pos < max) - { - using (var p = new Pen(Color.LightGray)) - { - graphics.DrawLine(p, pos, startPoint, pos, endPoint); - } - } - } - } - catch (Exception) - { - // ignore - } - } - - private void PictureBoxProgressbarBackgroundMouseDown(object sender, MouseEventArgs e) - { - SetProgressBarPosition(e.X - 4); - OnButtonClicked?.Invoke(sender, e); - } - - private void PictureBoxProgressBarMouseDown(object sender, MouseEventArgs e) - { - SetProgressBarPosition(e.X + 2); - OnButtonClicked?.Invoke(sender, e); - } - - private void PictureBoxProgressbarBackgroundPaint(object sender, PaintEventArgs e) - { - if (_chapters != null) - { - DrawChapters(e.Graphics, 3, _pictureBoxProgressBar.Location.Y, _pictureBoxProgressBar.Location.Y + 3); - } - } - - private void PictureBoxProgressBarPaint(object sender, PaintEventArgs e) - { - if (_chapters != null) - { - DrawChapters(e.Graphics, -1, 1, _pictureBoxProgressBar.Height); - } - } - - private void PictureBoxProgressbarBackgroundMouseMove(object sender, MouseEventArgs e) - { - if (VideoPlayer != null) - { - string toolTiptext = CurrentPositionToolTipText(e.X - 4); - _currentPositionToolTip.Show(toolTiptext, _pictureBoxProgressbarBackground, e.X - 10, e.Y - 25); - } - } - - private void PictureBoxProgressbarBackgroundMouseLeave(object sender, EventArgs e) - { - if (VideoPlayer != null) - { - _currentPositionToolTip.Hide(_pictureBoxProgressbarBackground); - } - } - - private void PictureBoxProgressBarMouseMove(object sender, MouseEventArgs e) - { - if (VideoPlayer != null) - { - string toolTiptext = CurrentPositionToolTipText(e.X + 2); - _currentPositionToolTip.Show(toolTiptext, _pictureBoxProgressBar, e.X - 10, e.Y - 25); - } - } - - private void PictureBoxProgressBarMouseLeave(object sender, EventArgs e) - { - if (VideoPlayer != null) - { - _currentPositionToolTip.Hide(_pictureBoxProgressBar); - } - } - - - /// - /// Use SMPTE time (drop frame mode) - /// See https://blog.frame.io/2017/07/17/timecode-and-frame-rates/ and - /// https://backlothelp.netflix.com/hc/en-us/articles/215131928-How-do-I-know-whether-to-select-SMPTE-or-MEDIA-for-a-timing-reference- - /// - public bool SmpteMode { get; set; } - - public void RefreshProgressBar() - { - if (VideoPlayer == null) - { - _pictureBoxProgressBar.Width = 0; - _labelTimeCode.Text = string.Empty; - } - else - { - int max = _pictureBoxProgressbarBackground.Width - 9; - double percent = (VideoPlayer.CurrentPosition * 100.0) / VideoPlayer.Duration; - _pictureBoxProgressBar.Width = (int)(max * percent / 100.0); - - if (Convert.ToInt64(Duration) == 0) - { - return; - } - - var pos = CurrentPosition; - if (pos > 1000000) - { - pos = 0; - } - - var dur = TimeCode.FromSeconds(Duration + Configuration.Settings.General.CurrentVideoOffsetInMs / TimeCode.BaseUnit); - if (SmpteMode) - { - var span = TimeCode.FromSeconds(pos + 0.017 + Configuration.Settings.General.CurrentVideoOffsetInMs / TimeCode.BaseUnit); - _labelTimeCode.Text = $"{span.ToDisplayString()} / {dur.ToDisplayString()} SMPTE"; - } - else - { - var span = TimeCode.FromSeconds(pos + Configuration.Settings.General.CurrentVideoOffsetInMs / TimeCode.BaseUnit); - _labelTimeCode.Text = $"{span.ToDisplayString()} / {dur.ToDisplayString()}"; - } - ResizeTimeCode(); - - RefreshPlayPauseButtons(); - } - } - - private void SetVolumeBarPosition(int mouseX) - { - int max = _pictureBoxVolumeBarBackground.Width - 18; - if (mouseX > max) - { - mouseX = max; - } - - double percent = (mouseX * 100.0) / max; - _pictureBoxVolumeBar.Width = (int)(max * percent / 100.0); - if (_videoPlayer != null) - { - _videoPlayer.Volume = (int)percent; - } - - _labelVolume.Text = (int)percent + "%"; - Configuration.Settings.General.VideoPlayerDefaultVolume = (int)percent; - } - - private void PictureBoxVolumeBarBackgroundMouseDown(object sender, MouseEventArgs e) - { - SetVolumeBarPosition(e.X - 6); - OnButtonClicked?.Invoke(sender, e); - } - - private void PictureBoxVolumeBarMouseDown(object sender, MouseEventArgs e) - { - SetVolumeBarPosition(e.X + 2); - OnButtonClicked?.Invoke(sender, e); - } - - private void RefreshVolumeBar() - { - if (VideoPlayer == null) - { - _pictureBoxVolumeBar.Width = 0; - } - else - { - int max = _pictureBoxVolumeBarBackground.Width - 18; - _pictureBoxVolumeBar.Width = (int)(max * Volume / 100.0); - } - } - - #endregion Progress bars - - #region VideoPlayer functions - - public void Play() - { - if (VideoPlayer != null) - { - VideoPlayer.Play(); - HideAllPlayImages(); - _pictureBoxPause.Visible = true; - _pictureBoxPause.BringToFront(); - RefreshProgressBar(); - } - OnButtonClicked?.Invoke(null, null); - } - - public void Stop() - { - if (VideoPlayer != null) - { - VideoPlayer.Pause(); - VideoPlayer.CurrentPosition = 0; - HideAllPauseImages(); - _pictureBoxPlay.Visible = true; - _pictureBoxPlay.BringToFront(); - RefreshProgressBar(); - } - OnButtonClicked?.Invoke(null, null); - } - - public void Pause() - { - if (VideoPlayer != null) - { - VideoPlayer.Pause(); - HideAllPauseImages(); - _pictureBoxPlay.Visible = true; - _pictureBoxPlay.BringToFront(); - RefreshProgressBar(); - } - } - - public void TogglePlayPause() - { - if (VideoPlayer != null) - { - if (VideoPlayer.IsPaused) - { - Play(); - } - else - { - Pause(); - } - } - } - - public bool IsPaused => VideoPlayer?.IsPaused == true; - - public double Volume - { - get - { - if (VideoPlayer != null) - { - return VideoPlayer.Volume; - } - - return 0; - } - set - { - if (VideoPlayer != null) - { - if (value > 0) - { - _muteOldVolume = null; - } - - if (value > 100) - { - VideoPlayer.Volume = 100; - } - else if (value < 0) - { - VideoPlayer.Volume = 0; - } - else - { - VideoPlayer.Volume = (int)value; - } - - RefreshVolumeBar(); - } - } - } - - /// - /// Current position in seconds - /// - public double CurrentPosition - { - get - { - if (VideoPlayer != null) - { - if (SmpteMode) - { - return VideoPlayer.CurrentPosition / 1.001; - } - else - { - return VideoPlayer.CurrentPosition; - } - } - return 0; - } - set - { - if (VideoPlayer != null) - { - if (SmpteMode) - { - VideoPlayer.CurrentPosition = value * 1.001; - } - else - { - VideoPlayer.CurrentPosition = value; - } - } - else - { - RefreshProgressBar(); - } - } - } - - /// - /// Total duration in seconds - /// - public double Duration - { - get - { - if (VideoPlayer != null) - { - return VideoPlayer.Duration; - } - - return 0; - } - } - - private bool Mute - { - get - { - if (VideoPlayer != null) - { - return _isMuted; - } - return false; - } - set - { - if (VideoPlayer != null) - { - if (!value && _muteOldVolume != null) - { - Volume = _muteOldVolume.Value; - _labelVolume.Visible = true; - } - else if (value) - { - _muteOldVolume = Volume; - Volume = 0; - _labelVolume.Visible = false; - } - _isMuted = value; - } - } - } - - #endregion VideoPlayer functions - - protected override void Dispose(bool disposing) - { - DeleteTempMpvFileName(); - base.Dispose(disposing); - _retryCount = 3; - SmpteMode = false; - } - - public void PauseAndDisposePlayer() - { - PanelPlayer.Hide(); - Pause(); - SubtitleText = string.Empty; - Chapters = new List(); - var temp = VideoPlayer; - VideoPlayer = null; - Application.DoEvents(); - temp.DisposeVideoPlayer(); - - // to avoid not showing video with libmpv, a new PanelPlayer is made... - PanelPlayer.MouseDown -= PanelPlayerMouseDown; - Controls.Add(MakePlayerPanel()); - PanelPlayer.BringToFront(); - PanelPlayer.MouseDown += PanelPlayerMouseDown; - VideoPlayerContainerResize(this, null); - - DeleteTempMpvFileName(); - _retryCount = 3; - SmpteMode = false; - RefreshProgressBar(); - } - - private bool IsMouseOverControl(Control control, Point cursorLocation) - { - if (control.ClientRectangle.Contains(cursorLocation)) - { - return true; - } - - return false; - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; +using Nikse.SubtitleEdit.Logic.VideoPlayers; +using System; +using System.Drawing; +using System.IO; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System.Collections.Generic; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Controls +{ + public sealed class VideoPlayerContainer : Panel + { + public class RichTextBoxViewOnly : RichTextBox + { + public RichTextBoxViewOnly() + { + ReadOnly = true; + BorderStyle = BorderStyle.None; + TabStop = false; + SetStyle(ControlStyles.Selectable, false); + SetStyle(ControlStyles.UserMouse, true); + MouseEnter += delegate { Cursor = Cursors.Default; }; + ScrollBars = RichTextBoxScrollBars.None; + Margin = new Padding(0); + } + + protected override void WndProc(ref Message m) + { + if (m.Msg == 0x204) + { + return; // WM_RBUTTONDOWN + } + + if (m.Msg == 0x205) + { + return; // WM_RBUTTONUP + } + + base.WndProc(ref m); + } + } + + public event EventHandler OnButtonClicked; + public event EventHandler OnEmptyPlayerClicked; + public Panel PanelPlayer { get; private set; } + private Panel _panelSubtitle; + private string _subtitleText = string.Empty; + private VideoPlayer _videoPlayer; + + public float FontSizeFactor { get; set; } + + public VideoPlayer VideoPlayer + { + get => _videoPlayer; + set + { + _videoPlayer = value; + if (_videoPlayer != null) + { + SetPlayerName(_videoPlayer.PlayerName); + } + + if (_videoPlayer is LibMpvDynamic && Configuration.Settings.General.MpvHandlesPreviewText) + { + _subtitlesHeight = 0; + } + else + { + _subtitlesHeight = 57; + } + DeleteTempMpvFileName(); + VideoPlayerContainerResize(this, null); + } + } + + public RichTextBoxViewOnly TextBox { get; private set; } + + public int VideoWidth { get; set; } + public int VideoHeight { get; set; } + + private bool _isMuted; + private double? _muteOldVolume; + private readonly System.ComponentModel.ComponentResourceManager _resources; + private int _controlsHeight = 47; + private const int OriginalSubtitlesHeight = 57; + private int _subtitlesHeight = OriginalSubtitlesHeight; + private readonly Color _backgroundColor = Color.FromArgb(18, 18, 18); + private Panel _panelControls; + + private PictureBox _pictureBoxBackground; + private PictureBox _pictureBoxReverse; + private PictureBox _pictureBoxReverseOver; + private PictureBox _pictureBoxReverseDown; + private PictureBox _pictureBoxFastForward; + private PictureBox _pictureBoxFastForwardOver; + private PictureBox _pictureBoxFastForwardDown; + private PictureBox _pictureBoxPlay; + private PictureBox _pictureBoxPlayOver; + private PictureBox _pictureBoxPlayDown; + private readonly PictureBox _pictureBoxPause = new PictureBox(); + private readonly PictureBox _pictureBoxPauseOver = new PictureBox(); + private readonly PictureBox _pictureBoxPauseDown = new PictureBox(); + private readonly PictureBox _pictureBoxStop = new PictureBox(); + private readonly PictureBox _pictureBoxStopOver = new PictureBox(); + private readonly PictureBox _pictureBoxStopDown = new PictureBox(); + private readonly PictureBox _pictureBoxFullscreen = new PictureBox(); + private readonly PictureBox _pictureBoxFullscreenOver = new PictureBox(); + private readonly PictureBox _pictureBoxFullscreenDown = new PictureBox(); + private readonly PictureBox _pictureBoxMute = new PictureBox(); + private readonly PictureBox _pictureBoxMuteOver = new PictureBox(); + private readonly PictureBox _pictureBoxMuteDown = new PictureBox(); + private readonly PictureBox _pictureBoxProgressbarBackground = new PictureBox(); + private readonly PictureBox _pictureBoxProgressBar = new PictureBox(); + private readonly PictureBox _pictureBoxVolumeBarBackground = new PictureBox(); + private readonly PictureBox _pictureBoxVolumeBar = new PictureBox(); + private readonly Label _labelTimeCode = new Label(); + private readonly Label _labelVideoPlayerName = new Label(); + private readonly Label _labelVolume = new Label(); + private readonly ToolTip _currentPositionToolTip = new ToolTip(); + private List _chapters; + + public List Chapters + { + get => _chapters; + set + { + _chapters = value; + Invalidate(true); + } + } + + public RightToLeft TextRightToLeft + { + get => TextBox.RightToLeft; + set + { + TextBox.RightToLeft = value; + TextBox.SelectAll(); + TextBox.SelectionAlignment = HorizontalAlignment.Center; + } + } + + public bool ShowStopButton + { + get => _pictureBoxStop.Visible || _pictureBoxStopOver.Visible || _pictureBoxStopDown.Visible; + set + { + if (value) + { + _pictureBoxStop.Visible = true; + _pictureBoxStop.BringToFront(); + } + else + { + HideAllStopImages(); + } + } + } + + public bool ShowMuteButton + { + get => _pictureBoxMute.Visible || _pictureBoxMuteOver.Visible || _pictureBoxMuteDown.Visible; + set + { + if (value) + { + _pictureBoxMute.Visible = true; + _pictureBoxMute.BringToFront(); + } + else + { + HideAllMuteImages(); + } + } + } + + public bool ShowFullscreenButton + { + get => _pictureBoxFullscreen.Visible || _pictureBoxFullscreenOver.Visible || _pictureBoxFullscreenDown.Visible; + set + { + if (value) + { + _pictureBoxFullscreen.Visible = true; + _pictureBoxFullscreen.BringToFront(); + } + else + { + HideAllFullscreenImages(); + } + } + } + + public VideoPlayerContainer() + { + _chapters = new List(); + SmpteMode = false; + FontSizeFactor = 1.0F; + BorderStyle = BorderStyle.None; + _resources = new System.ComponentModel.ComponentResourceManager(typeof(VideoPlayerContainer)); + _labelVolume.Text = Configuration.Settings.General.VideoPlayerDefaultVolume + "%"; + BackColor = _backgroundColor; + Controls.Add(MakePlayerPanel()); + Controls.Add(MakeSubtitlesPanel()); + Controls.Add(MakeControlsPanel()); + _panelControls.BringToFront(); + _pictureBoxProgressBar.Width = 0; + + ShowAllControls(); + if (Configuration.IsRunningOnLinux) + { + System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(1500), () => + { + if (string.IsNullOrEmpty(_labelVideoPlayerName.Text)) + { + _labelVideoPlayerName.Text = "..."; + } + FontSizeFactor = 1.0F; + SetSubtitleFont(); + _labelTimeCode.Text = $"{new TimeCode().ToDisplayString()} / ?"; + ShowAllControls(); + VideoPlayerContainerResize(this, null); + ShowAllControls(); + Invalidate(); + Refresh(); + }); + } + + VideoPlayerContainerResize(this, null); + Resize += VideoPlayerContainerResize; + PanelPlayer.MouseDown += PanelPlayerMouseDown; + + PictureBoxFastForwardMouseEnter(null, null); + PictureBoxFastForwardOverMouseLeave(null, null); + } + + private void ShowAllControls() + { + HideAllPlayImages(); + HideAllPauseImages(); + _pictureBoxPlay.Visible = true; + _pictureBoxPlay.BringToFront(); + + HideAllStopImages(); + _pictureBoxStop.Visible = true; + _pictureBoxStop.BringToFront(); + + HideAllStopImages(); + _pictureBoxStop.Visible = true; + _pictureBoxStop.BringToFront(); + + HideAllFullscreenImages(); + _pictureBoxFullscreen.Visible = true; + _pictureBoxFullscreen.BringToFront(); + + HideAllMuteImages(); + _pictureBoxMute.Visible = true; + _pictureBoxMute.BringToFront(); + + HideAllReverseImages(); + _pictureBoxReverse.Visible = true; + _pictureBoxReverse.BringToFront(); + + HideAllFastForwardImages(); + _pictureBoxFastForward.Visible = true; + _pictureBoxFastForward.BringToFront(); + + _pictureBoxProgressbarBackground.Visible = true; + _pictureBoxProgressbarBackground.BringToFront(); + _pictureBoxProgressBar.Visible = true; + _pictureBoxProgressBar.BringToFront(); + + _labelTimeCode.Visible = true; + _labelTimeCode.BringToFront(); + } + + public void EnableMouseWheelStep() + { + AddMouseWheelEvent(this); + } + + public void SetPlayerName(string s) + { + _labelVideoPlayerName.Text = s; + _labelVideoPlayerName.Left = Width - _labelVideoPlayerName.Width - 3; + } + + public void UpdatePlayerName() + { + if (_videoPlayer != null) + { + SetPlayerName(_videoPlayer.PlayerName); + } + } + + public void ResetTimeLabel() + { + _labelTimeCode.Text = string.Empty; + } + + private void AddMouseWheelEvent(Control control) + { + control.MouseWheel += ControlMouseWheel; + foreach (Control ctrl in control.Controls) + { + AddMouseWheelEvent(ctrl); + } + } + + private void ControlMouseWheel(object sender, MouseEventArgs e) + { + int delta = e.Delta; + double newPosition = CurrentPosition - delta / 256.0; + if (newPosition < 0) + { + newPosition = 0; + } + else if (newPosition > Duration) + { + newPosition = Duration; + } + + CurrentPosition = newPosition; + } + + private Control MakeSubtitlesPanel() + { + _panelSubtitle = new Panel { BackColor = _backgroundColor, Left = 0, Top = 0, Height = _subtitlesHeight + 1 }; + TextBox = new RichTextBoxViewOnly(); + _panelSubtitle.Controls.Add(TextBox); + TextBox.BackColor = _backgroundColor; + TextBox.ForeColor = Color.White; + TextBox.Dock = DockStyle.Fill; + SetSubtitleFont(); + TextBox.MouseClick += SubtitleTextBoxMouseClick; + return _panelSubtitle; + } + + public void SetSubtitleFont() + { + var gs = Configuration.Settings.General; + if (string.IsNullOrEmpty(gs.SubtitleFontName)) + { + gs.SubtitleFontName = "Tahoma"; + } + + if (gs.VideoPlayerPreviewFontBold) + { + TextBox.Font = new Font(gs.SubtitleFontName, gs.VideoPlayerPreviewFontSize * FontSizeFactor, FontStyle.Bold); + } + else + { + TextBox.Font = new Font(gs.SubtitleFontName, gs.VideoPlayerPreviewFontSize * FontSizeFactor, FontStyle.Regular); + } + + SubtitleText = _subtitleText; + } + + private void SubtitleTextBoxMouseClick(object sender, MouseEventArgs e) + { + TogglePlayPause(); + } + + public Paragraph LastParagraph { get; set; } + + public void SetSubtitleText(string text, Paragraph p, Subtitle subtitle) + { + var mpv = VideoPlayer as LibMpvDynamic; + LastParagraph = p; + if (mpv != null && Configuration.Settings.General.MpvHandlesPreviewText) + { + if (_subtitlesHeight > 0) + { + _subtitlesHeight = 0; + VideoPlayerContainerResize(null, null); + } + _subtitleText = text; + RefreshMpv(mpv, subtitle); + if (TextBox.Text.Length > 0) + { + TextBox.Text = string.Empty; + } + } + else + { + if (!string.IsNullOrEmpty(_mpvTextFileName) || _subtitlesHeight == 0) + { + mpv?.RemoveSubtitle(); + _subtitlesHeight = 57; + VideoPlayerContainerResize(null, null); + DeleteTempMpvFileName(); + } + SubtitleText = text; + } + } + + private Subtitle _subtitlePrev; + private string _mpvTextOld = string.Empty; + private string _mpvTextFileName; + private int _retryCount = 3; + private void RefreshMpv(LibMpvDynamic mpv, Subtitle subtitle) + { + if (subtitle == null) + { + return; + } + + try + { + var format = new AdvancedSubStationAlpha(); + string text; + + if (subtitle.Header != null && subtitle.Header.Contains("lang=\"ja\"", StringComparison.Ordinal) && subtitle.Header.Contains("bouten-", StringComparison.Ordinal)) + { + text = NetflixImsc11JapaneseToAss.Convert(subtitle, 1280, 720); + } + else + { + if (subtitle.Header == null || !subtitle.Header.Contains("[V4+ Styles]")) + { + var oldSub = subtitle; + subtitle = new Subtitle(subtitle); + if (TextBox.RightToLeft == RightToLeft.Yes && LanguageAutoDetect.CouldBeRightToLeftLanguage(subtitle)) + { + for (var index = 0; index < subtitle.Paragraphs.Count; index++) + { + var paragraph = subtitle.Paragraphs[index]; + if (LanguageAutoDetect.ContainsRightToLeftLetter(paragraph.Text)) + { + paragraph.Text = Utilities.FixRtlViaUnicodeChars(paragraph.Text); + } + } + } + + var oldFontSize = Configuration.Settings.SubtitleSettings.SsaFontSize; + var oldFontBold = Configuration.Settings.SubtitleSettings.SsaFontBold; + Configuration.Settings.SubtitleSettings.SsaFontSize = Configuration.Settings.General.VideoPlayerPreviewFontSize; + Configuration.Settings.SubtitleSettings.SsaFontBold = Configuration.Settings.General.VideoPlayerPreviewFontBold; + subtitle.Header = AdvancedSubStationAlpha.DefaultHeader; + Configuration.Settings.SubtitleSettings.SsaFontSize = oldFontSize; + Configuration.Settings.SubtitleSettings.SsaFontBold = oldFontBold; + + if (oldSub.Header != null && oldSub.Header.Length > 20 && oldSub.Header.Substring(3, 3) == "STL") + { + subtitle.Header = subtitle.Header.Replace("Style: Default,", "Style: Box,arial,20,&H00FFFFFF,&H0300FFFF,&H00000000,&H02000000,0,0,0,0,100,100,0,0,3,2,0,2,10,10,10,1" + + Environment.NewLine + "Style: Default,"); + for (var index = 0; index < subtitle.Paragraphs.Count; index++) + { + var p = subtitle.Paragraphs[index]; + if (p.Text.Contains("")) + { + p.Extra = "Box"; + p.Text = p.Text.Replace("", string.Empty).Replace("", string.Empty); + } + } + } + } + text = subtitle.ToText(format); + } + + + if (text != _mpvTextOld || _mpvTextFileName == null || _retryCount > 0) + { + if (_retryCount >= 0 || string.IsNullOrEmpty(_mpvTextFileName) || _subtitlePrev == null || _subtitlePrev.FileName != subtitle.FileName || !_mpvTextFileName.EndsWith(format.Extension, StringComparison.Ordinal)) + { + mpv.RemoveSubtitle(); + DeleteTempMpvFileName(); + _mpvTextFileName = FileUtil.GetTempFileName(format.Extension); + File.WriteAllText(_mpvTextFileName, text); + mpv.LoadSubtitle(_mpvTextFileName); + _retryCount--; + } + else + { + File.WriteAllText(_mpvTextFileName, text); + mpv.ReloadSubtitle(); + } + _mpvTextOld = text; + } + _subtitlePrev = subtitle; + } + catch + { + // ignored + } + } + + private void DeleteTempMpvFileName() + { + try + { + if (File.Exists(_mpvTextFileName)) + { + File.Delete(_mpvTextFileName); + _mpvTextFileName = null; + } + } + catch + { + // ignored + } + } + + public string SubtitleText + { + get => _subtitleText; + set + { + _subtitleText = value; + + bool alignLeft = _subtitleText.StartsWith("{\\a1}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\a5}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\a9}", StringComparison.Ordinal) || // sub station alpha + _subtitleText.StartsWith("{\\an1}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\an4}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\an7}", StringComparison.Ordinal); // advanced sub station alpha + + bool alignRight = _subtitleText.StartsWith("{\\a3}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\a7}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\a11}", StringComparison.Ordinal) || // sub station alpha + _subtitleText.StartsWith("{\\an3}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\an6}", StringComparison.Ordinal) || _subtitleText.StartsWith("{\\an9}", StringComparison.Ordinal); // advanced sub station alpha + + // remove styles for display text (except italic) + string text = Utilities.RemoveSsaTags(_subtitleText); + text = text.Replace("", string.Empty); + text = text.Replace("", string.Empty); + text = text.Replace("", string.Empty); + + // display italic + var sb = new StringBuilder(); + int i = 0; + bool isItalic = false; + bool isBold = false; + bool isUnderline = false; + bool isFontColor = false; + int fontColorBegin = 0; + TextBox.Text = string.Empty; + int letterCount = 0; + var fontColorLookups = new System.Collections.Generic.Dictionary(); + var styleLookups = new System.Collections.Generic.Dictionary(text.Length); + for (int j = 0; j < text.Length; j++) + { + styleLookups.Add(j, Configuration.Settings.General.VideoPlayerPreviewFontBold ? FontStyle.Bold : FontStyle.Regular); + } + + Color fontColor = Color.White; + while (i < text.Length) + { + if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + TextBox.AppendText(sb.ToString()); + sb.Clear(); + isItalic = true; + i += 2; + } + else if (isItalic && text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + TextBox.AppendText(sb.ToString()); + sb.Clear(); + isItalic = false; + i += 3; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + if (!Configuration.Settings.General.VideoPlayerPreviewFontBold) + { + TextBox.AppendText(sb.ToString()); + sb.Clear(); + isBold = true; + } + i += 2; + } + else if (isBold && text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + if (!Configuration.Settings.General.VideoPlayerPreviewFontBold) + { + TextBox.AppendText(sb.ToString()); + sb.Clear(); + isBold = false; + } + i += 3; + } + else if (Configuration.Settings.General.VideoPlayerPreviewFontBold && text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + i += 3; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + TextBox.AppendText(sb.ToString()); + sb.Clear(); + isUnderline = true; + i += 2; + } + else if (isUnderline && text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + TextBox.AppendText(sb.ToString()); + sb.Clear(); + isUnderline = false; + i += 3; + } + else if (text.Substring(i).StartsWith("'); + if (end > 0) + { + string f = s.Substring(0, end); + int colorStart = f.IndexOf(" color=", StringComparison.OrdinalIgnoreCase); + + if (colorStart > 0) + { + int colorEnd = colorStart + " color=".Length + 1; + if (colorEnd < f.Length) + { + colorEnd = f.IndexOf('"', colorEnd); + if (colorEnd > 0 || colorEnd == -1) + { + if (colorEnd == -1) + { + s = f.Substring(colorStart); + } + else + { + s = f.Substring(colorStart, colorEnd - colorStart); + } + + s = s.Remove(0, " color=".Length); + s = s.Trim('"'); + s = s.Trim('\''); + try + { + fontColor = ColorTranslator.FromHtml(s); + fontFound = true; + } + catch + { + fontFound = false; + if (s.Length > 0) + { + try + { + fontColor = ColorTranslator.FromHtml("#" + s); + fontFound = true; + } + catch + { + fontFound = false; + } + } + } + } + } + } + i += end; + } + if (fontFound) + { + TextBox.AppendText(sb.ToString()); + sb.Clear(); + isFontColor = true; + fontColorBegin = letterCount; + } + } + else if (isFontColor && text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + fontColorLookups.Add(new Point(fontColorBegin, TextBox.Text.Length + sb.ToString().Length - fontColorBegin), fontColor); + TextBox.AppendText(sb.ToString()); + sb.Clear(); + isFontColor = false; + i += 6; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + i += 6; + } + else if (text[i] == '\n') // RichTextBox only count NewLine as one character! + { + sb.Append(text[i]); + } + else if (text[i] == '\r') + { + // skip carriage return (0xd / 13) + } + else + { + var idx = TextBox.TextLength + sb.Length; + if (isBold) + { + styleLookups[idx] |= FontStyle.Bold; + } + + if (isItalic) + { + styleLookups[idx] |= FontStyle.Italic; + } + + if (isUnderline) + { + styleLookups[idx] |= FontStyle.Underline; + } + + sb.Append(text[i]); + letterCount++; + } + i++; + } + TextBox.Text += sb.ToString(); + TextBox.SelectAll(); + + if (alignLeft) + { + TextBox.SelectionAlignment = HorizontalAlignment.Left; + } + else if (alignRight) + { + TextBox.SelectionAlignment = HorizontalAlignment.Right; + } + else + { + TextBox.SelectionAlignment = HorizontalAlignment.Center; + } + + TextBox.DeselectAll(); + + Font currentFont = TextBox.SelectionFont; + for (int k = 0; k < TextBox.TextLength; k++) + { + TextBox.SelectionStart = k; + TextBox.SelectionLength = 1; + TextBox.SelectionFont = new Font(currentFont.FontFamily, currentFont.Size, styleLookups[k]); + TextBox.DeselectAll(); + } + + foreach (var entry in fontColorLookups) + { + TextBox.SelectionStart = entry.Key.X; + TextBox.SelectionLength = entry.Key.Y; + TextBox.SelectionColor = entry.Value; + TextBox.DeselectAll(); + } + } + } + + private void PanelPlayerMouseDown(object sender, MouseEventArgs e) + { + if (VideoPlayer == null) + { + OnEmptyPlayerClicked?.Invoke(sender, e); + } + + TogglePlayPause(); + } + + public void InitializeVolume(double defaultVolume) + { + int maxVolume = _pictureBoxVolumeBarBackground.Width - 18; + _pictureBoxVolumeBar.Width = (int)(maxVolume * defaultVolume / 100.0); + } + + private Control MakePlayerPanel() + { + PanelPlayer = new Panel { BackColor = _backgroundColor, Left = 0, Top = 0 }; + return PanelPlayer; + } + + public void HideControls(bool hideCursor) + { + if (_panelControls.Visible) + { + _panelSubtitle.Height += _controlsHeight; + _panelControls.Visible = false; + } + if (hideCursor) + { + HideCursor(); + } + } + + public void ShowControls() + { + if (!_panelControls.Visible) + { + _panelControls.Visible = true; + _panelControls.BringToFront(); + _panelSubtitle.Height -= _controlsHeight; + } + ShowCursor(); + } + + public void HideCursor() + { + if (_cursorStatus < 0) + { + return; + } + + _cursorStatus--; + if (VideoPlayer != null) + { + var mpv = VideoPlayer as LibMpvDynamic; + mpv?.HideCursor(); + } + Cursor.Hide(); + } + + private int _cursorStatus; + + public void ShowCursor() + { + if (_cursorStatus >= 0) + { + return; + } + + _cursorStatus++; + if (VideoPlayer != null) + { + var mpv = VideoPlayer as LibMpvDynamic; + mpv?.ShowCursor(); + } + Cursor.Show(); + } + + private Control MakeControlsPanel() + { + _panelControls = new Panel { Left = 0, Height = _controlsHeight }; + + _pictureBoxBackground = new PictureBox + { + Image = (Image)_resources.GetObject("pictureBoxBar.Image"), + Location = new Point(0, 0), + Name = "_pictureBoxBackground", + Size = new Size(200, 45), + SizeMode = PictureBoxSizeMode.StretchImage, + TabStop = false + }; + _panelControls.Controls.Add(_pictureBoxBackground); + + _pictureBoxPlay = new PictureBox + { + Image = (Image)_resources.GetObject("pictureBoxPlay.Image"), + Location = new Point(22, 126 - 113), + Name = "_pictureBoxPlay", + Size = new Size(29, 29), + SizeMode = PictureBoxSizeMode.AutoSize, + TabStop = false + }; + _pictureBoxPlay.MouseEnter += PictureBoxPlayMouseEnter; + _panelControls.Controls.Add(_pictureBoxPlay); + + _pictureBoxPlayDown = new PictureBox + { + Image = (Image)_resources.GetObject("pictureBoxPlayDown.Image"), + Location = new Point(22, 127 - 113), + Name = "_pictureBoxPlayDown", + Size = new Size(29, 29), + SizeMode = PictureBoxSizeMode.AutoSize, + TabStop = false + }; + _panelControls.Controls.Add(_pictureBoxPlayDown); + + _pictureBoxPlayOver = new PictureBox + { + Image = (Image)_resources.GetObject("pictureBoxPlayOver.Image"), + Location = new Point(23, 126 - 113), + Name = "_pictureBoxPlayOver", + Size = new Size(29, 29), + SizeMode = PictureBoxSizeMode.AutoSize, + TabStop = false + }; + _pictureBoxPlayOver.MouseLeave += PictureBoxPlayOverMouseLeave; + _pictureBoxPlayOver.MouseDown += PictureBoxPlayOverMouseDown; + _pictureBoxPlayOver.MouseUp += PictureBoxPlayOverMouseUp; + _panelControls.Controls.Add(_pictureBoxPlayOver); + + _pictureBoxPause.Image = (Image)_resources.GetObject("pictureBoxPause.Image"); + _pictureBoxPause.Location = new Point(23, 126 - 113); + _pictureBoxPause.Name = "_pictureBoxPause"; + _pictureBoxPause.Size = new Size(29, 29); + _pictureBoxPause.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxPause.TabStop = false; + _pictureBoxPause.MouseEnter += PictureBoxPauseMouseEnter; + _panelControls.Controls.Add(_pictureBoxPause); + + _pictureBoxPauseDown.Image = (Image)_resources.GetObject("pictureBoxPauseDown.Image"); + _pictureBoxPauseDown.Location = new Point(22, 127 - 113); + _pictureBoxPauseDown.Name = "_pictureBoxPauseDown"; + _pictureBoxPauseDown.Size = new Size(29, 29); + _pictureBoxPauseDown.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxPauseDown.TabStop = false; + _panelControls.Controls.Add(_pictureBoxPauseDown); + + _pictureBoxPauseOver.Image = (Image)_resources.GetObject("pictureBoxPauseOver.Image"); + _pictureBoxPauseOver.Location = new Point(22, 127 - 113); + _pictureBoxPauseOver.Name = "_pictureBoxPauseOver"; + _pictureBoxPauseOver.Size = new Size(29, 29); + _pictureBoxPauseOver.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxPauseOver.TabStop = false; + _pictureBoxPauseOver.MouseLeave += PictureBoxPauseOverMouseLeave; + _pictureBoxPauseOver.MouseDown += PictureBoxPauseOverMouseDown; + _pictureBoxPauseOver.MouseUp += PictureBoxPauseOverMouseUp; + _panelControls.Controls.Add(_pictureBoxPauseOver); + + _pictureBoxStop.Image = (Image)_resources.GetObject("pictureBoxStop.Image"); + _pictureBoxStop.Location = new Point(52, 130 - 113); + _pictureBoxStop.Name = "_pictureBoxStop"; + _pictureBoxStop.Size = new Size(20, 20); + _pictureBoxStop.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxStop.TabStop = false; + _pictureBoxStop.MouseEnter += PictureBoxStopMouseEnter; + _panelControls.Controls.Add(_pictureBoxStop); + + _pictureBoxStopDown.Image = (Image)_resources.GetObject("pictureBoxStopDown.Image"); + _pictureBoxStopDown.Location = new Point(52, 130 - 113); + _pictureBoxStopDown.Name = "_pictureBoxStopDown"; + _pictureBoxStopDown.Size = new Size(20, 20); + _pictureBoxStopDown.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxStopDown.TabStop = false; + _panelControls.Controls.Add(_pictureBoxStopDown); + + _pictureBoxStopOver.Image = (Image)_resources.GetObject("pictureBoxStopOver.Image"); + _pictureBoxStopOver.Location = new Point(52, 130 - 113); + _pictureBoxStopOver.Name = "_pictureBoxStopOver"; + _pictureBoxStopOver.Size = new Size(20, 20); + _pictureBoxStopOver.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxStopOver.TabStop = false; + _pictureBoxStopOver.MouseLeave += PictureBoxStopOverMouseLeave; + _pictureBoxStopOver.MouseDown += PictureBoxStopOverMouseDown; + _pictureBoxStopOver.MouseUp += PictureBoxStopOverMouseUp; + _panelControls.Controls.Add(_pictureBoxStopOver); + + _pictureBoxFullscreen.Image = (Image)_resources.GetObject("pictureBoxFS.Image"); + _pictureBoxFullscreen.Location = new Point(95, 130 - 113); + _pictureBoxFullscreen.Name = "_pictureBoxFullscreen"; + _pictureBoxFullscreen.Size = new Size(20, 20); + _pictureBoxFullscreen.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxFullscreen.TabStop = false; + _pictureBoxFullscreen.MouseEnter += PictureBoxFullscreenMouseEnter; + _panelControls.Controls.Add(_pictureBoxFullscreen); + + _pictureBoxFullscreenDown.Image = (Image)_resources.GetObject("pictureBoxFSDown.Image"); + _pictureBoxFullscreenDown.Location = new Point(95, 130 - 113); + _pictureBoxFullscreenDown.Name = "_pictureBoxFullscreenDown"; + _pictureBoxFullscreenDown.Size = new Size(20, 20); + _pictureBoxFullscreenDown.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxFullscreenDown.TabStop = false; + _panelControls.Controls.Add(_pictureBoxFullscreenDown); + + _pictureBoxFullscreenOver.Image = (Image)_resources.GetObject("pictureBoxFSOver.Image"); + _pictureBoxFullscreenOver.Location = new Point(95, 130 - 113); + _pictureBoxFullscreenOver.Name = "_pictureBoxFullscreenOver"; + _pictureBoxFullscreenOver.Size = new Size(20, 20); + _pictureBoxFullscreenOver.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxFullscreenOver.TabStop = false; + _pictureBoxFullscreenOver.MouseLeave += PictureBoxFullscreenOverMouseLeave; + _pictureBoxFullscreenOver.MouseDown += PictureBoxFullscreenOverMouseDown; + _pictureBoxFullscreenOver.MouseUp += PictureBoxFullscreenOverMouseUp; + _panelControls.Controls.Add(_pictureBoxFullscreenOver); + + _pictureBoxProgressbarBackground.Anchor = AnchorStyles.Top | AnchorStyles.Left; + _pictureBoxProgressbarBackground.BackColor = Color.Transparent; + _pictureBoxProgressbarBackground.Image = (Image)_resources.GetObject("pictureBoxProgressbarBackground.Image"); + _pictureBoxProgressbarBackground.Location = new Point(43, 114 - 113); + _pictureBoxProgressbarBackground.Margin = new Padding(0); + _pictureBoxProgressbarBackground.Name = "_pictureBoxProgressbarBackground"; + _pictureBoxProgressbarBackground.Size = new Size(531, 12); + _pictureBoxProgressbarBackground.SizeMode = PictureBoxSizeMode.StretchImage; + _pictureBoxProgressbarBackground.TabStop = false; + _pictureBoxProgressbarBackground.Paint += PictureBoxProgressbarBackgroundPaint; + _pictureBoxProgressbarBackground.MouseDown += PictureBoxProgressbarBackgroundMouseDown; + _pictureBoxProgressbarBackground.MouseLeave += PictureBoxProgressbarBackgroundMouseLeave; + _pictureBoxProgressbarBackground.MouseMove += PictureBoxProgressbarBackgroundMouseMove; + _panelControls.Controls.Add(_pictureBoxProgressbarBackground); + + _pictureBoxProgressBar.Image = (Image)_resources.GetObject("pictureBoxProgressBar.Image"); + _pictureBoxProgressBar.Location = new Point(47, 118 - 113); + _pictureBoxProgressBar.Name = "_pictureBoxProgressBar"; + _pictureBoxProgressBar.Size = new Size(318, 4); + _pictureBoxProgressBar.SizeMode = PictureBoxSizeMode.StretchImage; + _pictureBoxProgressBar.TabStop = false; + _pictureBoxProgressBar.Paint += PictureBoxProgressBarPaint; + _pictureBoxProgressBar.MouseDown += PictureBoxProgressBarMouseDown; + _pictureBoxProgressBar.MouseLeave += PictureBoxProgressBarMouseLeave; + _pictureBoxProgressBar.MouseMove += PictureBoxProgressBarMouseMove; + _panelControls.Controls.Add(_pictureBoxProgressBar); + _pictureBoxProgressBar.BringToFront(); + + _pictureBoxMute.Image = (Image)_resources.GetObject("pictureBoxMute.Image"); + _pictureBoxMute.Location = new Point(75, 131 - 113); + _pictureBoxMute.Name = "_pictureBoxMute"; + _pictureBoxMute.Size = new Size(19, 19); + _pictureBoxMute.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxMute.TabStop = false; + _pictureBoxMute.MouseEnter += PictureBoxMuteMouseEnter; + _panelControls.Controls.Add(_pictureBoxMute); + + _pictureBoxMuteDown.Image = (Image)_resources.GetObject("pictureBoxMuteDown.Image"); + _pictureBoxMuteDown.Location = new Point(75, 131 - 113); + _pictureBoxMuteDown.Name = "_pictureBoxMuteDown"; + _pictureBoxMuteDown.Size = new Size(19, 19); + _pictureBoxMuteDown.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxMuteDown.TabStop = false; + _pictureBoxMuteDown.Click += PictureBoxMuteDownClick; + _panelControls.Controls.Add(_pictureBoxMuteDown); + + _pictureBoxMuteOver.Image = (Image)_resources.GetObject("pictureBoxMuteOver.Image"); + _pictureBoxMuteOver.Location = new Point(75, 131 - 113); + _pictureBoxMuteOver.Name = "_pictureBoxMuteOver"; + _pictureBoxMuteOver.Size = new Size(19, 19); + _pictureBoxMuteOver.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxMuteOver.TabStop = false; + _pictureBoxMuteOver.MouseLeave += PictureBoxMuteOverMouseLeave; + _pictureBoxMuteOver.MouseDown += PictureBoxMuteOverMouseDown; + _pictureBoxMuteOver.MouseUp += PictureBoxMuteOverMouseUp; + _panelControls.Controls.Add(_pictureBoxMuteOver); + + _pictureBoxVolumeBarBackground.Image = (Image)_resources.GetObject("pictureBoxVolumeBarBackground.Image"); + _pictureBoxVolumeBarBackground.Location = new Point(111, 135 - 113); + _pictureBoxVolumeBarBackground.Name = "_pictureBoxVolumeBarBackground"; + _pictureBoxVolumeBarBackground.Size = new Size(82, 13); + _pictureBoxVolumeBarBackground.SizeMode = PictureBoxSizeMode.AutoSize; + _pictureBoxVolumeBarBackground.TabStop = false; + _pictureBoxVolumeBarBackground.MouseDown += PictureBoxVolumeBarBackgroundMouseDown; + _panelControls.Controls.Add(_pictureBoxVolumeBarBackground); + + _pictureBoxVolumeBar.Image = (Image)_resources.GetObject("pictureBoxVolumeBar.Image"); + _pictureBoxVolumeBar.Location = new Point(120, 139 - 113); + _pictureBoxVolumeBar.Name = "_pictureBoxVolumeBar"; + _pictureBoxVolumeBar.Size = new Size(48, 4); + _pictureBoxVolumeBar.SizeMode = PictureBoxSizeMode.StretchImage; + _pictureBoxVolumeBar.TabStop = false; + _pictureBoxVolumeBar.MouseDown += PictureBoxVolumeBarMouseDown; + _panelControls.Controls.Add(_pictureBoxVolumeBar); + _pictureBoxVolumeBar.BringToFront(); + + _pictureBoxReverse = new PictureBox + { + Image = (Image)_resources.GetObject("pictureBoxReverse.Image"), + Location = new Point(28, 3), + Name = "_pictureBoxReverse", + Size = new Size(16, 8), + SizeMode = PictureBoxSizeMode.AutoSize, + TabStop = false + }; + _panelControls.Controls.Add(_pictureBoxReverse); + _pictureBoxReverse.MouseEnter += PictureBoxReverseMouseEnter; + + _pictureBoxReverseOver = new PictureBox + { + Image = (Image)_resources.GetObject("pictureBoxReverseMouseOver.Image"), + Location = _pictureBoxReverse.Location, + Name = "_pictureBoxReverseOver", + Size = _pictureBoxReverse.Size, + SizeMode = PictureBoxSizeMode.AutoSize, + TabStop = false + }; + _panelControls.Controls.Add(_pictureBoxReverseOver); + _pictureBoxReverseOver.MouseLeave += PictureBoxReverseOverMouseLeave; + _pictureBoxReverseOver.MouseDown += PictureBoxReverseOverMouseDown; + _pictureBoxReverseOver.MouseUp += PictureBoxReverseOverMouseUp; + + _pictureBoxReverseDown = new PictureBox + { + Image = (Image)_resources.GetObject("pictureBoxReverseMouseDown.Image"), + Location = _pictureBoxReverse.Location, + Name = "_pictureBoxReverseOver", + Size = _pictureBoxReverse.Size, + SizeMode = PictureBoxSizeMode.AutoSize, + TabStop = false + }; + _panelControls.Controls.Add(_pictureBoxReverseDown); + + _pictureBoxFastForward = new PictureBox + { + Image = (Image)_resources.GetObject("pictureBoxFastForward.Image"), + Location = new Point(571, 1), + Name = "_pictureBoxFastForward", + Size = new Size(17, 13), + SizeMode = PictureBoxSizeMode.AutoSize, + TabStop = false + }; + _panelControls.Controls.Add(_pictureBoxFastForward); + _pictureBoxFastForward.MouseEnter += PictureBoxFastForwardMouseEnter; + + _pictureBoxFastForwardOver = new PictureBox + { + Image = (Image)_resources.GetObject("pictureBoxFastForwardMouseOver.Image"), + Location = _pictureBoxFastForward.Location, + Name = "_pictureBoxFastForwardOver", + Size = _pictureBoxFastForward.Size, + SizeMode = PictureBoxSizeMode.AutoSize, + TabStop = false + }; + _panelControls.Controls.Add(_pictureBoxFastForwardOver); + _pictureBoxFastForwardOver.MouseLeave += PictureBoxFastForwardOverMouseLeave; + _pictureBoxFastForwardOver.MouseDown += PictureBoxFastForwardOverMouseDown; + _pictureBoxFastForwardOver.MouseUp += PictureBoxFastForwardOverMouseUp; + + _pictureBoxFastForwardDown = new PictureBox + { + Image = (Image)_resources.GetObject("pictureBoxFastForwardMouseDown.Image"), + Location = _pictureBoxFastForward.Location, + Name = "_pictureBoxFastForwardDown", + Size = _pictureBoxFastForward.Size, + SizeMode = PictureBoxSizeMode.AutoSize, + TabStop = false + }; + _panelControls.Controls.Add(_pictureBoxFastForwardDown); + + _labelVolume.Location = new Point(120, 17); + _labelVolume.ForeColor = Color.WhiteSmoke; + _labelVolume.BackColor = Color.FromArgb(67, 75, 93); + _labelVolume.AutoSize = true; + _labelVolume.Font = new Font(_labelTimeCode.Font.FontFamily, 6); + _panelControls.Controls.Add(_labelVolume); + + _labelTimeCode.Location = new Point(280, 28); + _labelTimeCode.ForeColor = Color.WhiteSmoke; + _labelTimeCode.Font = new Font(_labelTimeCode.Font.FontFamily, 8, FontStyle.Bold); + _labelTimeCode.AutoSize = true; + _panelControls.Controls.Add(_labelTimeCode); + + _labelVideoPlayerName.Location = new Point(282, 17); + _labelVideoPlayerName.ForeColor = Color.WhiteSmoke; + _labelVideoPlayerName.BackColor = Color.FromArgb(67, 75, 93); + _labelVideoPlayerName.AutoSize = true; + _labelVideoPlayerName.Font = new Font(_labelTimeCode.Font.FontFamily, 6); + _panelControls.Controls.Add(_labelVideoPlayerName); + + if (Configuration.Settings.General.UseDarkTheme) + { + _labelVolume.ForeColor = Color.Gray; + _labelTimeCode.ForeColor = Color.Gray; + _labelVideoPlayerName.ForeColor = Color.Gray; + } + + + _pictureBoxBackground.SendToBack(); + _pictureBoxFastForwardDown.BringToFront(); + _pictureBoxFastForwardOver.BringToFront(); + _pictureBoxFastForward.BringToFront(); + _pictureBoxPlay.BringToFront(); + + _panelControls.BackColor = _backgroundColor; + _pictureBoxPlayDown.BringToFront(); + _pictureBoxPlayOver.BringToFront(); + _pictureBoxPlay.BringToFront(); + _labelTimeCode.BringToFront(); + _labelVolume.BringToFront(); + return _panelControls; + } + + public void VideoPlayerContainerResize(object sender, EventArgs e) + { + _controlsHeight = _pictureBoxBackground.Height; + PanelPlayer.Height = Height - (_controlsHeight + _subtitlesHeight); + PanelPlayer.Width = Width; + _videoPlayer?.Resize(PanelPlayer.Width, PanelPlayer.Height); + + _panelSubtitle.Top = Height - (_controlsHeight + _subtitlesHeight); + _panelSubtitle.Width = Width; + + _panelControls.Top = Height - _controlsHeight + 2; + _panelControls.Width = Width; + _pictureBoxBackground.Width = Width; + _pictureBoxProgressbarBackground.Width = Width - (_pictureBoxProgressbarBackground.Left * 2); + _pictureBoxFastForward.Left = Width - 48; + _pictureBoxFastForwardDown.Left = _pictureBoxFastForward.Left; + _pictureBoxFastForwardOver.Left = _pictureBoxFastForward.Left; + + ResizeTimeCode(); + + _labelVideoPlayerName.Left = Width - _labelVideoPlayerName.Width - 3; + DeleteTempMpvFileName(); + } + + private void ResizeTimeCode() + { + if (string.IsNullOrEmpty(_labelTimeCode.Text)) + { + var span = TimeCode.FromSeconds(1); + _labelTimeCode.Text = $"{span.ToDisplayString()} / {span.ToDisplayString()}{(SmpteMode ? " SMPTE" : string.Empty)}"; + _labelTimeCode.Left = Width - _labelTimeCode.Width - 9; + if (_labelTimeCode.Top + _labelTimeCode.Height >= _panelControls.Height - 4) + { + _labelTimeCode.Font = new Font(_labelTimeCode.Font.Name, _labelTimeCode.Font.Size - 1); + } + + _labelTimeCode.Text = string.Empty; + } + else + { + _labelTimeCode.Left = Width - _labelTimeCode.Width - 9; + if (_labelTimeCode.Top + _labelTimeCode.Height >= _panelControls.Height - 4) + { + _labelTimeCode.Font = new Font(_labelTimeCode.Font.Name, _labelTimeCode.Font.Size - 1); + } + } + } + + #region PlayPauseButtons + + public void RefreshPlayPauseButtons() + { + if (VideoPlayer != null) + { + if (VideoPlayer.IsPlaying) + { + if (!_pictureBoxPause.Visible && !_pictureBoxPauseDown.Visible && !_pictureBoxPauseOver.Visible) + { + HideAllPauseImages(); + HideAllPlayImages(); + _pictureBoxPause.Visible = true; + _pictureBoxPause.BringToFront(); + } + } + else + { + if (!_pictureBoxPlay.Visible && !_pictureBoxPlayOver.Visible && !_pictureBoxPlayDown.Visible) + { + HideAllPauseImages(); + HideAllPlayImages(); + _pictureBoxPlay.Visible = true; + _pictureBoxPlay.BringToFront(); + } + } + } + } + + private void HideAllPlayImages() + { + _pictureBoxPlayOver.Visible = false; + _pictureBoxPlayDown.Visible = false; + _pictureBoxPlay.Visible = false; + } + + private void PictureBoxPlayMouseEnter(object sender, EventArgs e) + { + if (_pictureBoxPlay.Visible) + { + HideAllPlayImages(); + _pictureBoxPlayOver.Visible = true; + _pictureBoxPlayOver.BringToFront(); + } + } + + private void PictureBoxPlayOverMouseLeave(object sender, EventArgs e) + { + if (_pictureBoxPlayOver.Visible) + { + HideAllPlayImages(); + _pictureBoxPlay.Visible = true; + _pictureBoxPlay.BringToFront(); + } + } + + private void PictureBoxPlayOverMouseDown(object sender, MouseEventArgs e) + { + HideAllPlayImages(); + _pictureBoxPlayDown.Visible = true; + _pictureBoxPlayDown.BringToFront(); + OnButtonClicked?.Invoke(sender, e); + } + + private void PictureBoxPlayOverMouseUp(object sender, MouseEventArgs e) + { + if (IsMouseOverControl((PictureBox)sender, e.Location)) + { + HideAllPlayImages(); + _pictureBoxPause.Visible = true; + _pictureBoxPause.BringToFront(); + Play(); + } + else + { + HideAllPlayImages(); + _pictureBoxPlay.Visible = true; + _pictureBoxPause.BringToFront(); + } + } + + private void HideAllPauseImages() + { + _pictureBoxPauseOver.Visible = false; + _pictureBoxPauseDown.Visible = false; + _pictureBoxPause.Visible = false; + } + + private void PictureBoxPauseMouseEnter(object sender, EventArgs e) + { + if (_pictureBoxPause.Visible) + { + HideAllPauseImages(); + _pictureBoxPauseOver.Visible = true; + _pictureBoxPauseOver.BringToFront(); + } + } + + private void PictureBoxPauseOverMouseLeave(object sender, EventArgs e) + { + if (_pictureBoxPauseOver.Visible) + { + HideAllPauseImages(); + _pictureBoxPause.Visible = true; + _pictureBoxPause.BringToFront(); + } + } + + private void PictureBoxPauseOverMouseDown(object sender, MouseEventArgs e) + { + if (_pictureBoxPauseOver.Visible) + { + HideAllPauseImages(); + _pictureBoxPauseDown.Visible = true; + _pictureBoxPauseDown.BringToFront(); + } + OnButtonClicked?.Invoke(sender, e); + } + + private void PictureBoxPauseOverMouseUp(object sender, MouseEventArgs e) + { + if (IsMouseOverControl((PictureBox)sender, e.Location)) + { + HideAllPauseImages(); + _pictureBoxPlay.Visible = true; + _pictureBoxPlay.BringToFront(); + Pause(); + } + else + { + HideAllPauseImages(); + _pictureBoxPause.Visible = true; + _pictureBoxPause.BringToFront(); + } + } + + #endregion PlayPauseButtons + + #region StopButtons + + private void HideAllStopImages() + { + _pictureBoxStopOver.Visible = false; + _pictureBoxStopDown.Visible = false; + _pictureBoxStop.Visible = false; + } + + private void PictureBoxStopMouseEnter(object sender, EventArgs e) + { + HideAllStopImages(); + _pictureBoxStopOver.Visible = true; + _pictureBoxStopOver.BringToFront(); + } + + private void PictureBoxStopOverMouseLeave(object sender, EventArgs e) + { + if (_pictureBoxStopOver.Visible) + { + HideAllStopImages(); + _pictureBoxStop.Visible = true; + _pictureBoxStop.BringToFront(); + } + } + + private void PictureBoxStopOverMouseDown(object sender, MouseEventArgs e) + { + if (_pictureBoxStopOver.Visible) + { + HideAllStopImages(); + _pictureBoxStopDown.Visible = true; + _pictureBoxStopDown.BringToFront(); + } + OnButtonClicked?.Invoke(sender, e); + } + + private void PictureBoxStopOverMouseUp(object sender, MouseEventArgs e) + { + if (IsMouseOverControl((PictureBox)sender, e.Location)) + { + HideAllStopImages(); + _pictureBoxStop.Visible = true; + _pictureBoxStop.BringToFront(); + Stop(); + } + else + { + HideAllStopImages(); + _pictureBoxStop.Visible = true; + _pictureBoxStop.BringToFront(); + } + } + + #endregion StopButtons + + #region FullscreenButtons + + private void HideAllFullscreenImages() + { + _pictureBoxFullscreenOver.Visible = false; + _pictureBoxFullscreenDown.Visible = false; + _pictureBoxFullscreen.Visible = false; + } + + public void ShowFullScreenControls() + { + _pictureBoxFullscreen.Image = (Image)_resources.GetObject("pictureBoxNoFS.Image"); + _pictureBoxFullscreenDown.Image = (Image)_resources.GetObject("pictureBoxNoFSDown.Image"); + _pictureBoxFullscreenOver.Image = (Image)_resources.GetObject("pictureBoxNoFSOver.Image"); + } + + public void ShowNonFullScreenControls() + { + _pictureBoxFullscreen.Image = (Image)_resources.GetObject("pictureBoxFS.Image"); + _pictureBoxFullscreenDown.Image = (Image)_resources.GetObject("pictureBoxFSDown.Image"); + _pictureBoxFullscreenOver.Image = (Image)_resources.GetObject("pictureBoxFSOver.Image"); + } + + private void PictureBoxFullscreenMouseEnter(object sender, EventArgs e) + { + HideAllFullscreenImages(); + _pictureBoxFullscreenOver.Visible = true; + _pictureBoxFullscreenOver.BringToFront(); + } + + private void PictureBoxFullscreenOverMouseLeave(object sender, EventArgs e) + { + if (_pictureBoxFullscreenOver.Visible) + { + HideAllFullscreenImages(); + _pictureBoxFullscreen.Visible = true; + _pictureBoxFullscreen.BringToFront(); + } + } + + private void PictureBoxFullscreenOverMouseDown(object sender, MouseEventArgs e) + { + HideAllFullscreenImages(); + OnButtonClicked?.Invoke(sender, e); + } + + private void PictureBoxFullscreenOverMouseUp(object sender, MouseEventArgs e) + { + HideAllFullscreenImages(); + _pictureBoxFullscreen.Visible = true; + _pictureBoxFullscreen.BringToFront(); + } + + #endregion FullscreenButtons + + #region Mute buttons + + private void HideAllMuteImages() + { + _pictureBoxMuteOver.Visible = false; + _pictureBoxMuteDown.Visible = false; + _pictureBoxMute.Visible = false; + } + + private void PictureBoxMuteMouseEnter(object sender, EventArgs e) + { + HideAllMuteImages(); + if (Mute) + { + _pictureBoxMuteDown.Visible = true; + _pictureBoxMuteDown.BringToFront(); + } + else + { + _pictureBoxMuteOver.Visible = true; + _pictureBoxMuteOver.BringToFront(); + } + } + + private void PictureBoxMuteOverMouseLeave(object sender, EventArgs e) + { + if (_pictureBoxMuteOver.Visible) + { + HideAllMuteImages(); + _pictureBoxMute.Visible = true; + _pictureBoxMute.BringToFront(); + } + } + + private void PictureBoxMuteOverMouseDown(object sender, MouseEventArgs e) + { + if (_pictureBoxMuteOver.Visible) + { + HideAllMuteImages(); + _pictureBoxMuteDown.Visible = true; + _pictureBoxMuteDown.BringToFront(); + } + OnButtonClicked?.Invoke(sender, e); + } + + private void PictureBoxMuteOverMouseUp(object sender, MouseEventArgs e) + { + if (IsMouseOverControl((PictureBox)sender, e.Location)) + { + HideAllMuteImages(); + _pictureBoxMuteDown.Visible = true; + _pictureBoxMuteDown.BringToFront(); + Mute = true; + } + else + { + HideAllMuteImages(); + _pictureBoxMute.Visible = true; + _pictureBoxMute.BringToFront(); + } + } + + private void PictureBoxMuteDownClick(object sender, EventArgs e) + { + Mute = false; + HideAllMuteImages(); + _pictureBoxMute.Visible = true; + _pictureBoxMute.BringToFront(); + OnButtonClicked?.Invoke(sender, e); + } + + #endregion Mute buttons + + #region Reverse buttons + + private void HideAllReverseImages() + { + _pictureBoxReverseOver.Visible = false; + _pictureBoxReverseDown.Visible = false; + _pictureBoxReverse.Visible = false; + } + + private void PictureBoxReverseMouseEnter(object sender, EventArgs e) + { + HideAllReverseImages(); + _pictureBoxReverseOver.Visible = true; + _pictureBoxReverseOver.BringToFront(); + } + + private void PictureBoxReverseOverMouseLeave(object sender, EventArgs e) + { + HideAllReverseImages(); + _pictureBoxReverse.Visible = true; + _pictureBoxReverse.BringToFront(); + } + + private void PictureBoxReverseOverMouseDown(object sender, MouseEventArgs e) + { + HideAllReverseImages(); + _pictureBoxReverseDown.Visible = true; + _pictureBoxReverseDown.BringToFront(); + if (VideoPlayer != null) + { + var newPosition = CurrentPosition - 3.0; + if (newPosition < 0) + { + newPosition = 0; + } + + CurrentPosition = newPosition; + } + } + + private void PictureBoxReverseOverMouseUp(object sender, MouseEventArgs e) + { + HideAllReverseImages(); + _pictureBoxReverse.Visible = true; + _pictureBoxReverse.BringToFront(); + } + + #endregion Reverse buttons + + #region Fast forward buttons + + private void HideAllFastForwardImages() + { + _pictureBoxFastForwardOver.Visible = false; + _pictureBoxFastForwardDown.Visible = false; + _pictureBoxFastForward.Visible = false; + } + + private void PictureBoxFastForwardMouseEnter(object sender, EventArgs e) + { + HideAllFastForwardImages(); + _pictureBoxFastForwardOver.Visible = true; + _pictureBoxFastForwardOver.BringToFront(); + } + + private void PictureBoxFastForwardOverMouseLeave(object sender, EventArgs e) + { + HideAllFastForwardImages(); + _pictureBoxFastForward.Visible = true; + _pictureBoxFastForward.BringToFront(); + } + + private void PictureBoxFastForwardOverMouseDown(object sender, MouseEventArgs e) + { + HideAllFastForwardImages(); + _pictureBoxFastForwardDown.Visible = true; + _pictureBoxFastForwardDown.BringToFront(); + + if (VideoPlayer != null) + { + var newPosition = CurrentPosition + 3.0; + if (newPosition < 0) + { + newPosition = 0; + } + + CurrentPosition = newPosition; + } + } + + private void PictureBoxFastForwardOverMouseUp(object sender, MouseEventArgs e) + { + HideAllFastForwardImages(); + _pictureBoxFastForward.Visible = true; + _pictureBoxFastForward.BringToFront(); + } + + #endregion Fast forward buttons + + #region Progress bars + + private void SetProgressBarPosition(int mouseX) + { + int max = _pictureBoxProgressbarBackground.Width - 9; + if (mouseX > max) + { + mouseX = max; + } + else if (mouseX < 0) + { + mouseX = 0; + } + + double percent = mouseX * 100.0 / max; + _pictureBoxProgressBar.Width = (int)(max * percent / 100.0); + + CurrentPosition = percent * Duration / 100.0; + } + + private int SecondsToXPosition(double seconds) + { + int max = _pictureBoxProgressbarBackground.Width - 9; + return (int)Math.Round(seconds * max / Duration); + } + + private double CursorVideoPosition(double mouseX) + { + int max = _pictureBoxProgressbarBackground.Width - 9; + if (mouseX > max) + { + mouseX = max; + } + else if (mouseX < 0) + { + mouseX = 0; + } + + double videoPosition = mouseX * Duration / max; + + return videoPosition; + } + + private string CurrentPositionToolTipText(double mouseX) + { + double cursorVideoPosition = CursorVideoPosition(mouseX); + string toolTiptext = TimeCode.FromSeconds(cursorVideoPosition + Configuration.Settings.General.CurrentVideoOffsetInMs / TimeCode.BaseUnit).ToDisplayString(); + + if (_chapters?.Count > 0) + { + toolTiptext += " - "; + + for (int index = 0; index < _chapters.Count; index++) + { + var chapterTime = _chapters[index].StartTime; + var nextChapterTime = index + 1 < _chapters.Count ? _chapters[index + 1].StartTime : Duration; + + if (cursorVideoPosition >= chapterTime && cursorVideoPosition < nextChapterTime) + { + if (_chapters[index].Nested) + { + toolTiptext += "+ "; + } + + toolTiptext += _chapters[index].Name; + break; + } + } + } + + return toolTiptext; + } + + private void DrawChapters(Graphics graphics, int mergin, int startPoint, int endPoint) + { + try + { + int max = _pictureBoxProgressbarBackground.Width - 9; + int index = 0; + while (index < _chapters.Count) + { + int pos; + try + { + double time = _chapters[index++].StartTime; + pos = SecondsToXPosition(time) + mergin; + } + catch + { + pos = -1; + } + if (pos > 0 && pos < max) + { + using (var p = new Pen(Color.LightGray)) + { + graphics.DrawLine(p, pos, startPoint, pos, endPoint); + } + } + } + } + catch (Exception) + { + // ignore + } + } + + private void PictureBoxProgressbarBackgroundMouseDown(object sender, MouseEventArgs e) + { + SetProgressBarPosition(e.X - 4); + OnButtonClicked?.Invoke(sender, e); + } + + private void PictureBoxProgressBarMouseDown(object sender, MouseEventArgs e) + { + SetProgressBarPosition(e.X + 2); + OnButtonClicked?.Invoke(sender, e); + } + + private void PictureBoxProgressbarBackgroundPaint(object sender, PaintEventArgs e) + { + if (_chapters != null) + { + DrawChapters(e.Graphics, 3, _pictureBoxProgressBar.Location.Y, _pictureBoxProgressBar.Location.Y + 3); + } + } + + private void PictureBoxProgressBarPaint(object sender, PaintEventArgs e) + { + if (_chapters != null) + { + DrawChapters(e.Graphics, -1, 1, _pictureBoxProgressBar.Height); + } + } + + private void PictureBoxProgressbarBackgroundMouseMove(object sender, MouseEventArgs e) + { + if (VideoPlayer != null) + { + string toolTiptext = CurrentPositionToolTipText(e.X - 4); + _currentPositionToolTip.Show(toolTiptext, _pictureBoxProgressbarBackground, e.X - 10, e.Y - 25); + } + } + + private void PictureBoxProgressbarBackgroundMouseLeave(object sender, EventArgs e) + { + if (VideoPlayer != null) + { + _currentPositionToolTip.Hide(_pictureBoxProgressbarBackground); + } + } + + private void PictureBoxProgressBarMouseMove(object sender, MouseEventArgs e) + { + if (VideoPlayer != null) + { + string toolTiptext = CurrentPositionToolTipText(e.X + 2); + _currentPositionToolTip.Show(toolTiptext, _pictureBoxProgressBar, e.X - 10, e.Y - 25); + } + } + + private void PictureBoxProgressBarMouseLeave(object sender, EventArgs e) + { + if (VideoPlayer != null) + { + _currentPositionToolTip.Hide(_pictureBoxProgressBar); + } + } + + + /// + /// Use SMPTE time (drop frame mode) + /// See https://blog.frame.io/2017/07/17/timecode-and-frame-rates/ and + /// https://backlothelp.netflix.com/hc/en-us/articles/215131928-How-do-I-know-whether-to-select-SMPTE-or-MEDIA-for-a-timing-reference- + /// + public bool SmpteMode { get; set; } + + public void RefreshProgressBar() + { + if (VideoPlayer == null) + { + _pictureBoxProgressBar.Width = 0; + _labelTimeCode.Text = string.Empty; + } + else + { + int max = _pictureBoxProgressbarBackground.Width - 9; + double percent = (VideoPlayer.CurrentPosition * 100.0) / VideoPlayer.Duration; + _pictureBoxProgressBar.Width = (int)(max * percent / 100.0); + + if (Convert.ToInt64(Duration) == 0) + { + return; + } + + var pos = CurrentPosition; + if (pos > 1000000) + { + pos = 0; + } + + var dur = TimeCode.FromSeconds(Duration + Configuration.Settings.General.CurrentVideoOffsetInMs / TimeCode.BaseUnit); + if (SmpteMode) + { + var span = TimeCode.FromSeconds(pos + 0.017 + Configuration.Settings.General.CurrentVideoOffsetInMs / TimeCode.BaseUnit); + _labelTimeCode.Text = $"{span.ToDisplayString()} / {dur.ToDisplayString()} SMPTE"; + } + else + { + var span = TimeCode.FromSeconds(pos + Configuration.Settings.General.CurrentVideoOffsetInMs / TimeCode.BaseUnit); + _labelTimeCode.Text = $"{span.ToDisplayString()} / {dur.ToDisplayString()}"; + } + ResizeTimeCode(); + + RefreshPlayPauseButtons(); + } + } + + private void SetVolumeBarPosition(int mouseX) + { + int max = _pictureBoxVolumeBarBackground.Width - 18; + if (mouseX > max) + { + mouseX = max; + } + + double percent = (mouseX * 100.0) / max; + _pictureBoxVolumeBar.Width = (int)(max * percent / 100.0); + if (_videoPlayer != null) + { + _videoPlayer.Volume = (int)percent; + } + + _labelVolume.Text = (int)percent + "%"; + Configuration.Settings.General.VideoPlayerDefaultVolume = (int)percent; + } + + private void PictureBoxVolumeBarBackgroundMouseDown(object sender, MouseEventArgs e) + { + SetVolumeBarPosition(e.X - 6); + OnButtonClicked?.Invoke(sender, e); + } + + private void PictureBoxVolumeBarMouseDown(object sender, MouseEventArgs e) + { + SetVolumeBarPosition(e.X + 2); + OnButtonClicked?.Invoke(sender, e); + } + + private void RefreshVolumeBar() + { + if (VideoPlayer == null) + { + _pictureBoxVolumeBar.Width = 0; + } + else + { + int max = _pictureBoxVolumeBarBackground.Width - 18; + _pictureBoxVolumeBar.Width = (int)(max * Volume / 100.0); + } + } + + #endregion Progress bars + + #region VideoPlayer functions + + public void Play() + { + if (VideoPlayer != null) + { + VideoPlayer.Play(); + HideAllPlayImages(); + _pictureBoxPause.Visible = true; + _pictureBoxPause.BringToFront(); + RefreshProgressBar(); + } + OnButtonClicked?.Invoke(null, null); + } + + public void Stop() + { + if (VideoPlayer != null) + { + VideoPlayer.Pause(); + VideoPlayer.CurrentPosition = 0; + HideAllPauseImages(); + _pictureBoxPlay.Visible = true; + _pictureBoxPlay.BringToFront(); + RefreshProgressBar(); + } + OnButtonClicked?.Invoke(null, null); + } + + public void Pause() + { + if (VideoPlayer != null) + { + VideoPlayer.Pause(); + HideAllPauseImages(); + _pictureBoxPlay.Visible = true; + _pictureBoxPlay.BringToFront(); + RefreshProgressBar(); + } + } + + public void TogglePlayPause() + { + if (VideoPlayer != null) + { + if (VideoPlayer.IsPaused) + { + Play(); + } + else + { + Pause(); + } + } + } + + public bool IsPaused => VideoPlayer?.IsPaused == true; + + public double Volume + { + get + { + if (VideoPlayer != null) + { + return VideoPlayer.Volume; + } + + return 0; + } + set + { + if (VideoPlayer != null) + { + if (value > 0) + { + _muteOldVolume = null; + } + + if (value > 100) + { + VideoPlayer.Volume = 100; + } + else if (value < 0) + { + VideoPlayer.Volume = 0; + } + else + { + VideoPlayer.Volume = (int)value; + } + + RefreshVolumeBar(); + } + } + } + + /// + /// Current position in seconds + /// + public double CurrentPosition + { + get + { + if (VideoPlayer != null) + { + if (SmpteMode) + { + return VideoPlayer.CurrentPosition / 1.001; + } + else + { + return VideoPlayer.CurrentPosition; + } + } + return 0; + } + set + { + if (VideoPlayer != null) + { + if (SmpteMode) + { + VideoPlayer.CurrentPosition = value * 1.001; + } + else + { + VideoPlayer.CurrentPosition = value; + } + } + else + { + RefreshProgressBar(); + } + } + } + + /// + /// Total duration in seconds + /// + public double Duration + { + get + { + if (VideoPlayer != null) + { + return VideoPlayer.Duration; + } + + return 0; + } + } + + private bool Mute + { + get + { + if (VideoPlayer != null) + { + return _isMuted; + } + return false; + } + set + { + if (VideoPlayer != null) + { + if (!value && _muteOldVolume != null) + { + Volume = _muteOldVolume.Value; + _labelVolume.Visible = true; + } + else if (value) + { + _muteOldVolume = Volume; + Volume = 0; + _labelVolume.Visible = false; + } + _isMuted = value; + } + } + } + + #endregion VideoPlayer functions + + protected override void Dispose(bool disposing) + { + DeleteTempMpvFileName(); + base.Dispose(disposing); + _retryCount = 3; + SmpteMode = false; + } + + public void PauseAndDisposePlayer() + { + PanelPlayer.Hide(); + Pause(); + SubtitleText = string.Empty; + Chapters = new List(); + var temp = VideoPlayer; + VideoPlayer = null; + Application.DoEvents(); + temp.DisposeVideoPlayer(); + + // to avoid not showing video with libmpv, a new PanelPlayer is made... + PanelPlayer.MouseDown -= PanelPlayerMouseDown; + Controls.Add(MakePlayerPanel()); + PanelPlayer.BringToFront(); + PanelPlayer.MouseDown += PanelPlayerMouseDown; + VideoPlayerContainerResize(this, null); + + DeleteTempMpvFileName(); + _retryCount = 3; + SmpteMode = false; + RefreshProgressBar(); + } + + private bool IsMouseOverControl(Control control, Point cursorLocation) + { + if (control.ClientRectangle.Contains(cursorLocation)) + { + return true; + } + + return false; + } + } +} diff --git a/src/Controls/VideoPlayerContainer.resx b/src/ui/Controls/VideoPlayerContainer.resx similarity index 98% rename from src/Controls/VideoPlayerContainer.resx rename to src/ui/Controls/VideoPlayerContainer.resx index 001cea71c..56334eb7e 100644 --- a/src/Controls/VideoPlayerContainer.resx +++ b/src/ui/Controls/VideoPlayerContainer.resx @@ -1,615 +1,615 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - iVBORw0KGgoAAAANSUhEUgAABXgAAAAtCAMAAAAjrvPmAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw8OERER - EhISEhITEhIWEhIXERIcERIdFBorFRssJioxJzBMKDFNPENSPURTPUVUPkZVNUBmNkFnQEdXQUlZQkpb - Q0tdRU1eRk5gR09iSFFkSlNmS1RnTVVpTldrT1htUVpvUltwU1xzVl93WmN8XWaAX2mDXmmFYGqFYWuG - dXyadn2bi5KnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6HRMPQAAAalJREFUeF7t1jVu - RVEQRME2MzMze//rczL+S+ioTvLCkUpXrZdfESBAgEBVIB8iQIAAgapAvqZPESBAgEBFIO8iQIAAgapA - 3kSAAAECVYG8igABAgSqAnkRAQIECFQF8iwCBAgQqArkSQQIECBQFcijCBAgQKAqkAcRIECAQFUg9yJA - gACBqkDuRIAAAQJVgdyKAAECBKoCuREBAgQIVAVyLQIECBCoCuRKBAgQIFAVyKUIECBAoCqQCxEgQIBA - VSDnIkCAAIGqQM5EgAABAlWBnIoAAQIEqgI5EQECBAhUBXIoAgQIEKgK5EAECBAgUBXInggQIECgKrD4 - 490XAQIECFQEsi0CBAgQqApEBAgQIFAWWJ6WRIAAAQIVgfwPry8BAgQIdAQMb8fZFQIECCwEDK/HQIAA - gbKA4S2DO0eAAAHD6w0QIECgLGB4y+DOESBAwPB6AwQIECgLGN4yuHMECBDIyoSCAAECBDoCWZtWRYAA - AQIVgWxM6yJAgACBikC2pk0RIECAQEUgu9OOCBAgQKAikOPpSAQIECBQEcjP9C0CBAgQqAj8AYNKjD+4 - WHt6AAAAAElFTkSuQmCC - - - - - ..\Resources\pictureBoxFastForward.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\pictureBoxFastForwardMouseDown.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\pictureBoxFastForwardMouseOver.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\pictureBoxFS.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\pictureBoxFSDown.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\pictureBoxFSOver.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - - iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAMAAABFjsb+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw8OCwsW - DAwRDw8TDQ0UDQ0VDg4UDg4VERESEBATEhISFhcgGxskGxwhHBwjHyAlICAoIyMtICMuICQuJicxJygy - JioxKis2Kyw1LzA6MTI8NDU+NjpGNDtMNjxNNz5OODlBOTpDOT9POj9ROUBPOEBQOEBRO0JSPENSPENT - PERTPURUPURVPkZVPkZWP0ZXREZPQEZXQEhYQUlZQUlaQUlbQkpbQ0tdRExaRUxcRU1eR09dSktUSkxV - SExdSU1eSU1fTlJeU1VdTFBhUFdnUlhmV1lkU1loWWBuX2RxY2ZvYGRzZGd2Yml2ZmhwZ2pycHN7c3V+ - bHGAcnWBcnaDcneGgoWOgISPg4aPgYaUi46Yio+Zio+ajJCZlpmilZmkmJylm56nmZ6onqGqoKOsoKSs - oaWyp6qyqa23sbW9srW+tbnBuLzDvb/Hv8HGvsPLwcPJwMPLw8XKwcbNw8fPw8jPx8zTy9DXz9HVzNHY - zdLZz9Pd0NXd0tfe09jf1Nng19zj3d7i3OHo3eLp4ODk4uPm5ebp6urt6+zu5uvz7/T78PHy8/P09fX2 - 8vX48PX8+vz//f39/v7/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgqUuWQAAARJJREFUKFNjsMIE - DOaYgMEMDExBhIkJhMNgDAL6LvrGxpa+HnpGIB6DIRBoh08M0dFxTuwpctcBchl0dXW1XXsn5alZd0fZ - V3R4aurqMmhrqasWTJrULmvo3dpo19Jmoa3NoKGUkTUBCJRjcp37Cn0mxKtoMGjLdfWDQGhQf2Rav0Nn - tbw2g5hQUzMIRMs0JwU3O+bXCIsxMDDV1oGAk02dV1idRFkmEwMDF3NEbD0QcPslS1WlGtQHMnMxcHGy - MCbU15ey8ynmZItnF/NwAsW4ONlEK+vimPnL/EXTS6TZuEBiXBxsbg22nMwCAeUpImycEDGgSkE2Dg5e - BUlWkBBEjIuTE8jmAJIcIB5EDBVgEwMAxe1P5C1jRZkAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAMAAABFjsb+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFExMVDBIt - DhQuDxk3DRs9FhouHB8mEBs1FxszEBo4ERw6Fx8/GB45DyA8GiIlFCI7GSA3HSI3GiA7HSI5JiwvIic7 - Ji48Dh9CCSBGDyBDDyFEDyJFDyRGCyRMDiZIDCZODyhJDChPDytNBi1dCilRDCpSDy5RDC9YDDNfEiVB - EiZCFyBAFSJHEyZQFjFfBzRmBzhsBzltCzhnDDtqCDxwKDBKLzZLLjVMLzVOITZXLzVQLzVTLjZXLjdc - LzphLztiLztjLzxjMDphMD1kCUB0CUB2DUBxCkh/FUF4OEJYPUdfPkhdPUtiNEd1QkpaRU1dQ09mSU1g - TFlxTFtwV1xsV11vUmB0VmV2WGJzW2R7Wmh6XGp5XGp6YnB/DEyBDVGHEEiGE1mOE1qPEFCQEVmaF2GT - FmGfFmKgG2ymG2ynInatKH2yZXeIZ3mFbnaIa3yJbniKcHeHdXmDeXyGb4CEcYGMcIKOd4iWeYiUeouV - eIqXe4yWmz0ashwMpDAUvDwuvEE0vEM2s1A4slU/q2NIwQUCxwcHwgsIzgAF2QAIwDwy1CEl1Cov3ycu - 1y0x2Cow4AYR4TM54zY/3XVz3Xd26GZryoV1gI2XhIiWhYqXgY+YiI+eg5GahJGfh5adhJafiJaejZGb - jZGfkZSdjpWhiZiljZqgk5qlmJ2qmZ+tkqCmlaCmk6GpmaaumaavnqaunaywroaCq4qGqIyHqI2Ip6+2 - prC0p7G1rrm/sbrFtr7KtMDEtcHFucTHu8TJzZGY0YuT0Zedw8jQyc7VzNDV0NXd0tfe09jf1Nng19zj - 3OHo3eLp7crG8MTD9MbH4+jv6ezw8PX89vf4+vz//vz8/f3+/v7/AAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAc6SIIgAAAV5JREFUKFNj8GPj - E0EGfGx+DGIlu/cig90lYgzRe7Zv2w5CELBt+55ohtgNq1atWrZ6GZCEgA2xDDGr5i2YtfXq+jkLIGDe - qhiG8PmVFdMvXTtSWl29Zse+HWsq54czhJXn5x6+fPlCbNm6g5MmTDq4tiqMIThn566LQBA1d39n79SJ - nQeWBjMEeJ86DQKFS3q6O85d6etfHsDgKXrsOAjMXNg++Wzr2Sltiz0ZzFiPnwCBkKKGxitnauu7is0Y - zDlmLAKJCfhvqmue1lS3MdCcwYKHiXHF8eOH2PkjtrTUtGwOFbJgsOLmZDY9enIlr5amT8HsPC8ubSsG - ax1xSZbI80FyakoKcjLSUuI61gw2urLyshKWKkZuxhrqqorysro2DDZ6yvoGJi5xialJ8e6uhvrKejYM - gr4eCckpaRlZ2VmZ6SnJCR6+ggwMwrZOdvYOjs7Ozo4O9nZOtsIMAJnRonErDmY9AAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAMAAABFjsb+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFERIUCAop - CQ03DR9HDxpZDiJNDyxeEylPGytKHStLHS1MGy1VHS9XFjVfHjBYEi5gHytmETFmEjNqEzVqHTRlHTVm - Ezl2Fj1wFDx6Fj55HT14JzRRITZZKDZTLzlULTteNT9YICpmICtoKj5kLD9lF0F1F0R9HUhzH0p0H016 - NUFdJkNqKkNtKkpwLE53NUdtPU1sO1F+RU1eR1FtTVRsT1huSVlzS1t1TlhwV2B1Fy+BFy+CE0SNE0WO - HkSKGEmJGUyJGU2PIUCJIEGMJEOJJkSIJESPK0qPLl6DOVqCN1abJ1ekKWSNLGeOLGufLWyYMHCdM3ab - KmynLW+jKGmpKGmqKm6pN3ykM3KzRWeMT2WFWmuKRmenS2yoQGi5UG+qVXKsW3mxX32xZm6CaXSJbHeI - aXiLaXiScXiLcXuJcXyQc3yRPIWmPoqrQpGtd4GUdISSdIWffIaTfoeXfIuYfY+bbom3Vo/Ie5TAfZbB - g4uehIubhY2fgZCcgJOfgJSfiZOfgZWgiZGhjZSkiJijjp6omZ+ukqKrk6Wulaeul6GymaGwn6a0m6mx - mquznKy0na61oKi2oK21oqu8obK5orO6p7C+prS6p7W7qLe9rbS9qri+rbi/rLXBr7rBr73DsbfCsL/E - tL7Etb/FtrzIuL/Kiszfjc/djdDektHdlNLbltXenNXdntjfg8LhiMvgotnescDFvsTOvcbQwsnPxMnO - wcfRw8rTxMrTx83Vyc7XyNHVyNHWy9DXydLWytPXy9LbzdLa0tbb0dbe09jfyN700NXg1Nng19zj29/i - 3N7h3N/j3OHo3eLp5Obq5ujr6Ort5+z07O3w7+/x7u/y7/T78PHy8fP09fb38PX89Pb69/j5+Pj5+vz/ - /v7/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYxRxBgAAAW1JREFUKFNjMDIs - q6xAgMoyQyMGw6PXLiODa0cNGZJO7du/f/8eIN63ezeIPJXEkLh14caNs+fM3jh/xqJ5M+dvXLg1kSFh - 0ZSpfYvvzZnQ37vl9slJ/VMWJTDET+9ob79z71BL641ZRaev97ZOj2eI7awrPXTv3pWCkoYL5zLPX6rt - jGWIqd+8/S4QpE3blXprb/HduY0xDF5mV2+CQH7WzZrJNy0uHjP3YnCXPnMWBJoUzrZlnDXZdFjWncGV - 8/ARELA0PZJcfURu5wIuVwYXnqrm40DAkdKjdXCi8fFsPhcGJxFW5u7jx3ewyxgsXSK/ZBu3qBODk5Qg - v/LBI1282rvSVaZt12eTcmJwtpOQFI4+EaWuoVt4YLKOkJidM4Obt62jg6qepo+vR6SnuJq9jbcbg3V5 - RGhYcEB4bl5OoL9fUEhEuRUDU9y69ctWrFy9dsOaVSuXL1u/Lo6JgYGRRUlAQBECBASUWBgZAFBhr6gt - gaHsAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAIAAADZ8fBYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAABeRJREFUSEt9lgtQ - VFUcxg/i4nsXFpZlWXnJW54SD+PhsoiAIA/BIJ+hBhkzko5TjpUzxuBMJlqOUgoNKjIEFI06AVr4oEKz - 8JFIKUqZzfjI8lFOziiy/S7HWRXHdv5z5pzv/32/ezh7711sMma9Ip7xGaZ8bC0W8aD/3v3796RLpbKz - HW5nYyMGBh4MDAw8KyvS84qfqNyi9NyijFlLMvNLpmbMmxRt9vYNMrp5GlzHuxrdGZmjoNPFgxO/Uk9y - RNrMl4cU1qT0ud5+wTqds5d3QHhUYpw5x5S6YEpKISNzFHS6eHDifxoiUrMXWSstZzFXDo8yOel0Pv4h - U6blRya+HpG4Ia2gvnj5lytWdzAyjzBtQKeLByd+UmQfR4mUzEJZqPR8/EPZyGRTJkkQdZ9d6Dl3s/eX - 2xQTOWfc3nCeLh6c+ElJ7kNaVqGYlrlAVmrOIq7vYjCaUuZMjH2vclcviK7Tf+1pudj4eV9tfa8sroTS - 2XUd+qYdP+PET4osBCtNJGfM5xtIyV4YEhHPlSW0tfOaJH6869zmbT0bK7vXfXBKFnMUdC6Gp6H9cnDc - h6TIQoADbWrGfMHBg05IzuOkouPT/OPXY2U7/KXkyypOvFH27bLVRx8vFHQuAJ0d4CdFFgIcaDCFefps - Zny/VJhpRdmWMwdO3OAQmKwo7wLReuh8XXNPQcn+2aUdjMxR0Oni4ShAv7m5h6yEQIOpcOPM2VwqJiEz - akZdy4lblQ19EjrvtfbOrouWwU9F9bG0hV8wyiU61yh55zgbr6i90Nz5J1kIcKCZ015UuEFhk908JoQl - lnJZ/iigBArf+gHQye7fJai68bvogqb11d/IJTrduSuP4SS1dd9VZcuJpXCgKftNTC2QC7/Yd2mX1fQu - 39ANNHf5kYQ5n3b9+JuVGzBjl5WLThcPTmXXNb3v770CQW7RlFog4pJm6l0MPJd8rfKyWNlI+tIjbNDK - 5QSGcOnikWi2AhcCHGgwBcfBLCoua0JoTXnz1SXrTuOOmXvAL6vNOWab9XzZqW1k9aqN7dbzpYsHJ35S - ZCHAgRZrzhLyAfPyjbQb+e6kGYeMkc0q153CsFO41wqPTYeP9t3rt1DllR0icAtcuUSnq3jca+3G15Ii - CwGO8vgFhAqNRu3o5KRWO6OOcm4SY6uEY40SCKgHxC31x81/KYjst3TdfubXb91Fp6t4cOIfWzXSpQkC - HGj2GrVwcHDgOeFBHD5ymd67xcZph7LZwEYR3Qioqe1U36VrFFyUovJWuUSni6I4DTtJkYUABxpMYa/R - hEWZeKXajcmhNyZgr2KN3yOS9wlzE7fXyTPnKXbKEq5corNUPDgDG0mRhQAHGkzlHHwDw3iljnYIVjtv - 98o9rVgz2sULR0Vmy5b6Qx1HjlMQRcHhvLIWuUSnq3hwxu8hRRYCHGgwlXNw1huU153eaKsqCik8q118 - koDq1V7b4u9Xf9TS+tXXFESWjHKJzhIPTvykyEKAA005B61Wq1GPY/OhzyVwQY13lanyHwLDVl1Rr+nz - WbZ7aUXDgrWfuK486LrxV0bmKOh08eDET4osBDjQYCpc8HoXo3zw7EaZuSvz2+4at/5N+Vae9V570G99 - Z0jdpfDdtxmZo6BLA078KlUiWQhwoD3kyi1zLqaUfEedAVPQnLbFP1nSj/fHHrgzed9NRuayHlfw4MTv - pHMhq5zs4GYfcSU6IiaJVwYmuxFRPE7s5e07Fqr4uuWlyw+LuRTp4sGJnxRZK/QJLsdhb6+hzVvZ3dNn - 1FgP2xHT3ZNrZ1ddXNPdv+mGRRZzFHS6eHDiJ0UWgtys5DpaC51bxD8ogl/AyOeTOazRo/WqEaG247LG - uBU5eJUwMkdB53vHgxM/qUHmIxRc/ZBSq7V6Fw/uGH4E483ZvPo8vQKd9eNlMUdBp4sHJ/6nIcJB6zak - tFo3e3sjT7re4B0UPiUuKU/5YR38R4CROQo6XTw48T8NETpj8DPLdaJW70/pXCe6ekbIYm4V/yf7Hwfx - peH+1vvyAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAMAAABhTZc9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw8ODxAP - DxEWEBERERIREhISERITEhIXEhQUERQVExcXEBEcERIdAAA0AAA9CBEkCxY1EhgoFBkqFRssFx8wGyIm - GyMtHSc6Jy00BABGAABPAgRLAgVMBABIBQBOBwdNCQhPAgBRBQBRBQJSAQJbAAhWAA5XChZeGB9dAwdj - Ag5lABViABZuAB9oABpzFhxjFixYHSZfHzRFACVvACN3ACtxADV6GTF0Jy9MIjpJJj9KKDBNKDdLKzlD - KzlEKDlGKjtFKDtGLTtHLD1JMT9MIy1pJS1zMjx3KUNPLUBMJENWJkVYKkZSLUpXLU9dO0BOMkFRNURS - NkZUN05dPkRSPEZVP0ZWOEpZPkhYPk1dK05kKVdsK1d9O0J2NVVmPlJlO2d4QUhYQUpaQ0tdQ0xeRElY - R0xaRU1eRU5gR09iREt5R1FjRVJkQVRqQ1luSFFkSlJlSlNmSVRoS1RpTFdrTVhtTlN9WF5tR2V8V2Bv - XmZzAC2AADWFAT6NAESIAkqUAFGeA1uoCWGoBmSxFnKuHHCyGXm1IVmWKGWfKGWgPnymDXnEQ0+IRFaL - SVSGTFeITFyOU1yFTW6GQHGERXOJR3qPTHKLTXeRTHSeS3uTVmONXWGGWGqVWnecYWWHYmaIYmuNam+P - Y2+SY3OWYXabY3iUbXGQbneVb3qXaHuec3aHcXWSdXqVcH6bcX2gP4CdN4KyFY3VLozIIpnaNJnTJaTm - LqvmKa/tM7HoNrnyRoGWSYOdQYOhQoShQ4WnRoWjRYijR4umQ4itSIegTIihSIyoTJGuT5W0UpWxUpe3 - UZi5VJu8VZ6+aoGbfICafoScaYWmdYWlc46vfIKjfIeofY2jeo2ofpCnR8v6VdT/dub/goefhoqfhYuq - io+iiYymiY2rg5eqjpGphpiwkpetmZ20jKC2lKG0m6K3nqe7nam8oKK3qrLGtLbGtrvCtLvPwcbNwcLR - xsfVzM3Zz9Tb3eLp6u/26/D3+vz/////AAAAAAAAAAAAAAAAAAAAAAAAzAsMkgAAAylJREFUOE9jKASD - goLi0pwgTw8fXx8Pz6Cc0uKCApAwQz4ElOQ4eyQcOXnq1KmTRxI8nHNKwKIMmSCQXxJoNfn03mgvext7 - r+i9pydbBZbkA8UZMoAgs8jZ78R6y7RV9548eXJvVarl+hN+zkWZGRkM6UBQ5BR3Jjrk3osnd86fP3/7 - 0dM7/tFn4pyK0tMZkpOTswP8znhVvXx0bs3qZcuWrV5z7v6Lcq8zfgHZyQxJSSmRVieiq17eXrNs/mwQ - mLdwzfmnldEnrCJTGBITMxwmr498dXvFgoVvX5eVlb1+u3DB8vPPw9dPdshgCEuM8Djp/fD6igUTP/78 - +SD2/s+fH8sWLL961eukRwRDWJJLwp68Z2sXzcr6/PPnU/dHP39+zpq4YMXj3D0JLgwhEY67Y85eWzyr - PxYo+8T1AVA2tm/W4otLY3Y7MoSEWh2LurRyzoQed7DsXaCse0/vnJUXoo5ZMYSF+hw3ujC3191N/xPQ - XvXLP39+0ndz7517wei4D4OEhM8xfkMNeTlFqY8/ftxVW/fjx0cpRSUFDVf+Yz4MDFweBwR4+WTlVFTf - f/t2RXvdt+/vVVWUZPl4BQ54MLByxR0w4JVUUtHSfvP160XdlV+/vtHWUlGS5DU4EMfAyha8K4ZPWVPH - xPjVly/rTJd8+fLK2ERHU5kvZlcwAyuj3ZQuGS296hqz5x8+rDSb++HDc7Oaaj0t6a4pdgyszKIVB811 - qmvr666/ezejYca7d9fr6murdcwPVogysLKyhk/t0qmtb2xuvzC3qbtp7oX25sb6Wp2uqeGsQFkW0YrD - 7TXN3Ru7W9o2bt7Y1gJkNda0H64QZQHpZbaddrS9YePWbdt27Ny5c8e2bVs3NrQfnWbLDNLLysoRPv1o - Z/P2GzdugsCNG9ubO45OD+dghciycoVPO7yhdfONWyBwY3PrhsPTwrmA4gxsYMDpNGnmgQ0bNm3ZsmXT - hg37Z05y4gQJM7BDAJNY/KSZu/fuO7Rv7+7pk+LFmMCiDDxQwM0tFpBXMWnapIq8ADFubogogzAcCAkK - iYiLi4sAaZgYgzUKsLCwQOYDADNYgx+MsDCLAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAMAAABhTZc9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw8ODxAP - DxEWEBERERIREhISERITEhIXEhQUERQVExcXEBEcERIdEhgoFBkqFRssFx8wGyImGyMtHSc6Jy00Jy9M - Jj9KKDBNKzlEKTtFLTtHLD1JMT9MKENOKkNPLUBMKkZSLEdULUpXLU9dMkFRNURSNkZUN05dPUVTPEZV - OEpZPkhYPkxdMldmO1NlO2Z4QEdXQUlZQkpbQ0tdQ0xeRU1eRU5gR09iR1FjRVJkQVhuSFFkSlJlSlNm - SFRnSlRpS1ZrTFdrTVhtRGR5SWZ+AC7SCiTVDi3TADvNATbXBTbfBjzXADrcDTHXDDPdCD7ZES/OFjXP - GT3RAD3gFDvlP3CEAUbSClXUEkTdHlnOHVLVAEDkAEfpAEjqC0voAlr0GkfmFGrYDGr2DHD2FH33Ik3P - JU7KJVvbJFntLGbQJH7WNGnPMWHdOnfCK2TvJXT4Mm3oO3DoTW6FTm6HRXOJRnmOTXKLTHqSQXPSR3fQ - Rn3jGoT+KIrcNZjcJJP7OKjzRoGWR4KcSoWeSImfRoeiRIetR4qnSIimSI2pS46vQo25T5GvTZK1SpG6 - TZS5T5e9bJKrZZW8eJarc5i/QITeRYneTY3fRJrHTZXAQ5LTQpHWRZPVWoHWUZrBT4rkWI3mXZHqTanH - S7nqUbzgZovZbJLGeJnKdJXTf53UfZnYfZjeYYnlY5XlY5TqbJbobZrpd5Tgd5XldZzofp3jeKXrfKDp - fq/vcqX5S8D9Xs3pesD9aeH5cubze+/8hqC5jKTYmazElqzZgKfqh63tjKTmjazpjbLtjbbwkqfnk6jn - lK7rma7ombHum73vorTOp7nZtrvCoLPqorXroLbupbbrpLfvpLrtqbrkq7ztnsf1g/T+ivD/l///qMbz - ptb8tcXjvMnotMTwtMzzs9b3sv//v/L/wcbNz9TbwMvox9HpztboxNX1wdr3zNT1z9j2ztz20djq19z2 - 2d73yuH4w/r/3eLp2eL46u/26/D3+vz/////AAAAAAAAAAAAAAAAAAAAzS/fsQAAAylJREFUOE9jsAUD - Gxt7J0s1eTlFJUU5eTVLJ3sbG5AwgzUEOFpKy+k39cyYPqOnSV9O2tIRLMpgDgLWDqpiof2zp63ZtHXT - mmmz+0PFVB2sgeIMZkBgbi+t3D1r/tV3nz4CwdvL82d1K0vbm5uZMZgCgZ2U7twpZ769e3jjypUrNx6+ - /XhqylxdKTtTUwZjY2MLFeW5Ux59e3jp9MkjR46cOH3xxvuHU+Yqq1gYMxgZmeiIdU959P7a6SOrNmzc - uHHDqiOnrr2+O6VbTMeEwdDQTCJ01rHP105tXvng+pzVc64/WLn56OU3h2eFSpoxGBhqy/bN+3z36NYl - L3/9Olh18Nevl0s2HT37Zl6frDaDppGM/szjj48dWj/nw69f5yv2//r1Yc66rcceHZ6pL8OgoS3ZOPXx - zcOb1la+AurNBsq+qlyw/tDZu1MbJRk0NMU6qx4f27J2AVg2EyRbMX/tlsP3qjrFGAw0FWbk3Nu2tqog - Emjv/vAVQHsjC6oWbLuZM0OBQUREode3IMrbJ9rjxc+fK8KW//z5wiM62D+90LdXgYGBS7bV3cvVMzgm - 7P737yvCl3//cT8sNtjT1cu9VZaBlUuvKTDE0ycmPvz816/Lwpd+/Xo+PD7WxzMksEWPgZVNvSHNLy42 - Pin83PPnyxKXPn9+LjEpPjYuJK1BnYGVUaIk1y0/Pjkl8cCzZ5OzJj57diAxJTk+3y23RIKBlVnQuSMg - vzqlrmbfhQsTaydeuLCvpi6lOj+gw1mQgZWVVas0129HXX1916QJ0xdNnzCpq76+bodfbqkWK1CWRdCl - OTVj944dixcu3Ll758KFi3fs2J2R2uwiyALSyyxR1hGUd/vW7t179u7du2f37lu384LayiSYQXpZWTm0 - yjtSQ3Y9eXIHBJ482RWS2lGuxcEKkWXl0iprzvXL2H7v6Zen97Zn+OU2l2lxAcUZ2MCAU6qovC03KiIh - ISEiKretvEiKEyTMwA4BTEJ6ReVN7a2tre1N5UV6QkxgUQYeKODmFlKxcikuK3axUhHi5oaIMvDDAR8v - n4CwsLAAkIaJMYijAFFRUWQ+AARqaklCCnVoAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAMAAABhTZc9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw4NDw8O - CgoXDg4SDg4WCQwfEA8PEBAPERERERESEhISEhITEhIXExQUFBUVFRUWEBAbERIdExUZFBUYFhcZFRcb - FhccFxgZFxgbFxgfGBkcGRodBQcuBgc1ChEsEhcnFxkjFRoqFRssGx0gHR8jGiAyICEpISMoIyUrIyYs - JCctJCcuJSkvISU0JysyKy84KzA+LTI8LjM9LzU/MDU/BQVAAwdJBglBAw1OBgtQAwVlBAhwDR5nDS5+ - MDVAMTZBMjdCNDlENTtONjxINz1NOD9NLz9zO0FPO0JSPURTPkVWPkZVP0ZWP0ZaP0deL0BuPkZgNEB1 - QEdXQUlZQkpbQ0tcREtdRU1eRk1gRk5gRk9hR09iR1BiSFBjSFFkSlJlSlNmS1RnS1RoTVZpTVZqTlds - T1hsBgiIAAyaABOdABySDhafARSgABmgAB6iBRqhBhygCRaqCBiqACmQDiOYADWYFTWXACimCyiyADup - ADywFyO1GzStIi6eJjqIJzyLKjqKLDuWAEWdAECvAE+2AEm7ClSgHkSiB2O8GWutIkmNMkCNKk26K1q3 - NUykO1qrOVu4NmCaNnevAFTGAFjHAGHIBWnaCnnYEmPPA3flIVLSLWDYSFemRmS2RWO8RWi+SmKxV2mm - V267VHmiZHK6RWbAS2vEUW3EWW/DU3LHVXbJYHfIYX7MbXzJcX3GGYjWD4vvHJjsGpj0JpPQP5XzLqvq - Kqz2MbX3N7v0O8L7XoSme4yxWZrgVrf3bYLNaInScYbDc4HJcoTOeIPHeoXMcY3TepPVRcv9TND+X+b/ - Y9b/Zuv/fPT/kaO8g43Ph5LJgpTUgp7aiZDQjpXTk5nVmqnLkaDXlaPalajdnKPZn6jbhK3oj7LnmLjo - oqbapKzcqa7dqbLAqLPUtrvCtL/YqLzmsbXggNP8ke7/v8bdtsjrwcbNz9Tbxc3hx87rztPj0dfv2Nrw - 2uDn2+Lt3OHo3+Pv2+Dy6u/27PH38/X5+vv9+vz/////AAAAAAAAAAAA6kUEYQAAAxhJREFUOE9jSISD - 5LTUhMjIyITUtGSYGEMCGMTHJ6WE2msoS0tLK2vYh6YkxceDhBniICApRJNf3c7dL8DP3U6dXzMkCSzK - EA0CsfEmfFpegd1zlqxbMqc70EuLzyQ+FijOEAEE0bHa/K6Bc+5/+PYRCD7cmhPoyq8dGx0RwRAOBDFa - Ur4N17+9e/bg3r1795+9+3CtwVdKKyY8nCEsLDTKkN+34dWHZzevXL506dLlKzcfvHva6MtvGBXKEBIS - 5snnXP/03a0r5w4fXLd27cEj5y7ffPW03pnPM4whODhMXd3twqvrFw6ef7Rk0YoVK1avPXTh2qtjburq - YQxBwe58Ln2vblw4tOj9n59X585btnzF6n3Hrr3qc+FzZ/AO1lfxP/b0wqHVC97/+fPn64EJ85YuB0rf - Peqvos/gGaSiX3f34tE1K/tBsn/+vF00ASR98U6dvgqDp4e4fePdY2tWLYPK/vn1aO78lWuO3mm0F2fw - cRd3qr29f9mEnrK3YL1A8OPAhGX7b9c6iTPoafPrpvfU5OfmZb38DQO/SgpqetJ1+RkYGXlZ0gszMvPK - i598B4MfPz4vzMrMKEpn4WXg4jCUsq7OyS2vLH30BQw+7bYtLs/NqbaWMGTgYjPWsKyuKK9qrbz6BgTO - dpVWNleWV1RbahgzcDHq2Mllz6pqndxy9vXr1w8nNrVMmTK5tWpWtpydDtBkEVdRq9kzJk+bevbxw8Vt - HdNnzpw5bfKM2VairiIMXFwMxkZyJVumzZw+aVdn5/qNGzdu2jBz2pYSOSNjBqAsh0SQinnP3k0bN2/e - vHU7EGzbtGlvj6lKkAQHUJaLQcdHyLT31IkdO3YeP3H8+M6dJ071mgr7AG0FyXIxOAQLy5btPXPm9Ekg - OHNmb5mscLADyFKQLAe7Q4gKq1n7nucvXrx4vqfdlFUlxIGdAyjLDQKcjHrRjiJMMhY2NjYWMkyijtF6 - jJxAcQYeCGCWdA1311cTExNV03cPd5VkBosyCEKBAIuCgUdoRHREqIeBAosARJRBCQ4U5eUVVVVVQRRM - DACG9nnjnRgGhwAAAABJRU5ErkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAMAAABhTZc9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw8ODxAP - DxEWEBERERIREhISERITEhIXEhQUERQVExcXEBEcERIdAAA0AAA9CBEkCxY1EhgoFBkqFRssFx8wGyIm - GyMtHSc6Jy00BABGAABOAgRLAgVMBQBJBABNBwdNCQhPAgBQAAdWBQFRAQJbAAxWDRtXEQxSGB9dAwtk - ABRjABVuABhvABxzFhtiFixYHildACZpACN3ATh5HCNhGTF0Jy9MIDdHJj9KKDBNKDdLKzlDKzlEKDlG - KjtFKDtGLTtHLD1JMT9MIy5iJS1zIjprLzt4ND14KUNPLUBMJENWJkVYKkZSLUpXLU9dO0BOMkFRNURS - NkZUN05dPkRSPEZVP0ZWOEpZPkhYPk1dK05kKVdsLl14O0J6NVVmP1NnNlN6O2d4QUhYQUpaQ0tdQ0xe - RElYR0xaRU1eRU5gR09iQ0l6R1FjRVJkQ1luSFFkSlJlSlNmSVRoS1RpTFdrTVhtSlB+WF5tR2V8V2Bv - XmZzAC2AADWFADyDAT6NAEaMAkqUAE+cElOLAFSjB1ygA1uoBWCsB2m3Fnq6HHCyKFGCJVeVLWaaKGWg - PnymCHrLQUqCRFSKTFSCTleJTFyOUViBVlyFTW6GQHGERXOJR3qPTHKLTHqSVmONXWGHVmyUWnWdYWWI - Y2uNbG+ZbXCPY3GVY3iUZ3mdbneVbXuYc3aHcXWScXWedXqVcH6be3+ZaX6hP4CdN4KyG4bFE5DcHprh - LozIIpfYNJnTIZ7jJ6bmKq7tMa/pNLbwN7z0RoGWSYOdQYOhQoShQ4WnRYijRoikR4umQ4itSIagSIig - TIihSIyoTJGuT5W0UpWxUpe3UZi5VJu8VZ6+aoGbfYKbfICcfoWeaYWqeYymR8v6VdT/dub/hImfio+i - iJCmiZaqhpiwkpetjKC2lKC0mqC2nqa8nKm8qK++tbvIwcbNwcPUycvXz9Pb39/o2uDn2+Dr3OHo6u/2 - 7u/z7PH48/P2+vr7+vr9+vz/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAyX1CIwAAAxFJREFUOE9jKASD - goLi0twgTw8fXx8Pz6Dc0uKCApAwQz4ElOQ6eiSeOn/hwoXzpxI9HHNLwKIMWSCQXxJoMePioWgvWytb - r+hDF2dYBJbkA8UZMoEgq8jR79xG8/RVdx8+fHh3VZr5xnN+jkVZmZkMGUBQ5BB3KTrk7pOHd65duXbn - 3pM7/tGX4hyKMjIYUlJScgL8LnlVPb13Ze3qJUuWrF67/t6Tcq9LfgE5KQzJyamRFueiq57eWbtk4cJ5 - 8+YtXLRk7bUnldHnLCJTGZKSMu1mbIx8dm3FoqvPp5VNmjR12rxFK649Dt84wy6TISwpwuO89/17KxdN - ffPjy8Ps7OyySdMWrbhxw+usRwRDWLJT4sG8R+uWzs1+/ePHj7eL3WMnAKVXPog/mOjEEBJhfyDm8o2l - cyfFgmR//Hg1OXbCxLlLbyyLOWDPEBJqcSbqxob5Uya6Q2R/fH06YcKU+cuvR52xYAgL9Tlrfn3BRHcX - Pajsjx+f1rhNXHDd/KwPg4SEzxl+Aw15OUWpV99h4Ju6gokz/xkfBgYujyMCvHySyipKLz6CwefP76fJ - yvLxChzxYGDlijuizwuU1NR6/gEM3l1TU1VRluTVPxLHwMoWvL+LT1lT28jw2RsQeOxqaKiro6nM17U/ - mIGV0WZmn4ymbnWN8eOXL18+TzA0Nq6tqdbRlO6bacPAyixaccxUu7quvv7+i+fzjeubm5sb6+uqtU2P - VYgysLKyhs/q06lraG3rWdDU0t4PBO2tDXXafbPCWYGyLKIVJ7pr2vr7Ozo2b9+5c+fWLVv622q6T1aI - soD0MlvPPt3dvGXXrj179wHB3t07tzR2n55tzQzSy8rKET7ndG/77ps3b4HAzZu723tPzwnnYIXIsnKF - zz7R17n95m0QuLm9s+/E7HAuoDgDGxhwOkyfc3TTpm07duzYtmnTkTnTHThBwgzsEMAkFj99zoFDh48f - PnRgzvR4MSawKAMPFHBziwXkVUyfPb0iL0CMmxsiyiAMB0KCQiLi4uIiQBomxmCJAszMzJD5AKC+iMSu - Me5pAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAIAAADZ8fBYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAABcZJREFUSEt9lgtM - lWUYxz+8sFYmnONRM2JthnePpYYlKIJwLhw4HEESmDtME1FjqNPyljrLDEixcQmHOXUmiKOkNLGcLi9o - G5osFFBAhVKuAqZyUJBz+r297iSSffvv7PV5///f+3zP931Dl5DIRcpzrj7i6utwKN2PO7u6OqWrf3/X - vv1cXVwUu73bbrc/L6uYZsf3UMRCE4pcYo5O1EXETdFHav1DxwZaxhsitaYofllToc4uHpzCj3pyFGN4 - 3DMKjUogM356MAjf+DWmLbvN6UdDsoqkWFOhLg6bHowTf2+IYrC87xTbIXMSvIMiRs4w+S/fYtlxUpdR - Zk69ueCr2x/tali/t5Ff1lSos4sHJ35SZJ9GKfqweVJUuSla0FqslrSCmWnlMam39h9rK7lqu1rTUVFt - c+rilfa9ha3s4sGJnxRZCE6aojPHShkjF2l9DZOi4sN3nvb/7Eb2D63Vfz4Aeuxca/6JlpzCZinWVEBz - TOahZpz4SZGF4KQpgSFWZAhfMCkgnJMl9Mfi+/RIfu+RpuxD9Rl59dv235JKP1BPhToHXKq24ZRoshDg - SKAy0zQ3MDTWL9TKpLgpCSWQc+IOeUAbdtai1TvqnNq0u446ze47dudc2b288wJNFgIcaDCVgOAYXdi8 - cVOD/JZtZl6ph1uKax8SIAaOfMGpmsVbK2KTbizYVi+VkCbOgJ76bSODPl3ZkfRdC1kIY3x10GAKrp8x - enRgmDnz51kpt4ByPgGePrjSymaHw/HA1kXvszbVoDmfN1q3CiVmiTcE59cn20CThQAHWoAxWsxh4oxQ - 3sfA9MuphXePlHfQ8qYDTYk7Gy1rL0quvGrq21dl1+jW/+GkP0EfbmF0tAwBDjTRL3iaN3y6S5dyA+ju - X9txiPc0swnuhSsNTq5cMFBmAn12cpM1TRxPE7TMXUKAA22GIUqZpn+PeYdsL8Aqm12T0wyUzH9yQXd2 - 2Xmqsmuc+Gklt/wxBDjQfGeGC+5YfYQ54+TE+dfZ21jQhhXH5MQGz+hLvft1tt9675EcCx2Q4kYhwIHm - ExCmjNK+zcqUdvzliRWCFVHmOq1C8alS/Gv7+VzgFe587PgPddnpGuF5wa9ixNwq3+UNEOBA8xo9QRk0 - dCgPUZ+cN1B7uf+Um8qEUsW7XECDG12CSnnJmtpsvUWz1bUNDAqu8E8oJQsBDjR3t4GC6zt7oT5p3xDv - Eo3vbWHyqQLaZ+5914hyuOSfUWVNw4bMX9zNh/oEnqUDcXPe5WQhwIGmUqkUlXrQO2FW/SdZI8KKB0y+ - DlFCByyxDf6gPDu/qORK1dOiorXmAGX3pbgmnDICFwIcaO5uboqbuxsfm25lis/qMy96lY348KGALrdp - NnRI7unzv0nlFxYZVuZ4xH1P3WOzDeHBiZ8UWQhwoLkxB3eVymP4yKC4tcbUg6o3L+GQAa+MrnEppWm5 - x8GhxdvyxqzIpzL1mzo0OecRwoMTPymyEOBAE3NQ/3O9a4rRr93OgYxC/5OdADHys74shOizMXda1hnL - 0WvmonZLcTcKOevAJtEsSJGFAEcCBVelFi0Hx280puwZbi7ximlZXGMnKShHr0nNL/uLolOxlQ5Jp4Kf - FFkIoll4ksvFNJiLecVW7mXY9N/HxbV9cdex+YE9oa4DrWrp+vi+w6llrQ7ELh6c+EmRhQDn337lSq3R - cBeh69IxcT7Pd92p7sMOB9rRU7LILh7RaepBUmICGs0TlLNf+W/eZbZF1yl75Ky5xxU5j/i+T7U7pFhT - oS5nihM/KbJOqJzDIKd4l1WawfylMi/dQgt8PCT5stVB11811EmxpiKeUnIeHpz4SZF9GgWXc3rITTXE - 4w0tn42k878FY3KuLqlAijUVScSDE39vCN+b5zNSqz3dVa8hMvwpDIheyoMOW5rE/fLLmgp1dqUNf2+I - Mthj/POkGTZW/cpofoe+/pbnKB8p1s76/2T/BmTsnV5cYwy9AAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAAT4AAAAECAMAAAAgcKN9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFHB4hHR4i - D0HNGEXCWHiYYnm0a4/ubpb/frjthMX/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbZ1u+QAAACZJREFUOE9jYGQY - BRSEAAsH5yggOwQYmJlGAfkhwMDKxj4KyA4BANhiFlbMlRkDAAAAAElFTkSuQmCC - - - - - R0lGODlhdgEMAPcAABweIR0eIigsNDA0PjY7SEZOYE1VaU5Wa09YbVBYbVBZblFZb1FablFab1JbcFFa - cVNcc1Rdc1RddFRddVVedVZfdlZfd1dgd1hieVhielpjfFtlfVtlfl1mf11mgF5ogl9pg15phWBqhWFq - hgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - ACwAAAAAdgEMAAAI/wBDCBxIsKDBgwgTKlzIsKHDhxAjSpxIsaLFixgzarw4oqPHjyBDihxJsqTJkyhT - qlzJsqXLlzBjypxJs6ZMEDhBiNjJs6fPn0CDCh1KtKjRo0iTKl3KtKnTp1CjSp2KNCcIDx0+gLhQoavX - r2DDih1LtqzZs2jTql3Ltq3bt3Djyp1Lty7aCyA+dPCggUMDAQEACB5MuLDhw4gTK17MuLHjx5AjS55M - ubLly5gza24cQEADDhosYBhAYEGC06hTq17NurXr17Bjy55Nu7bt27hz697Nu7fv37IXEBiAwQKEBwUo - TJDAvLnz59CjS59Ovbr169iza9/Ovbv37+DDi7wfT/76BAoFHkBw4EBBBgkR4sufT7++/fv48+vfz7+/ - //8ABijggAQWaOCBCCbInwQZKMBeAww4sMEIVFVo4YUYZqjhhhx26GFRI2zgAAMNIGAiAg2kqOKKLLbo - 4oswxijjjDTWaOONOOao44489ujjj0AGaeOJCBxg5JFIJqnkkkw26eSTUEYp5ZRUVmnllVhmqeWWXHbp - 5ZYGhCnmmGSWaeaZaKap5ppstunmm3DGKeecdNZp55145mlnQAA7 - - - - ..\Resources\pictureBoxReverse.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\pictureBoxReverseMouseDown.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\pictureBoxReverseMouseOver.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - - iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw8OCgoW - DAwRDw8TDQ0VDw8UEBATEhISHyMtJioxMjdJMzhKNDxNOkFRPENSPENTPURTPURUPkZVP0ZWQEdXQUlZ - QkpbQ0tdRU1eRk5gm56nyszQ09jf1Nng3eLp8PX8+vz//v7/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHzqB+wAAAHxJREFUKFONzdkO - gjAQheHDVpBFqVVQcOv7v6SclgmJmRi+u386bXFX4KbAqMCgwFWBCzl7iqxj4kzd7KO5Y6K3i3aded8y - 0R8X9UfUTDgeNW/RhM0DVS9RMRGkD5GGLql4ioL5Z5hN6/Up2zZNnkS52YalEeGL+OaP/cMvDc4aWeQk - 0FYAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFEBESEhIS - ExMVExMWCBc2CRY3Dxo3CBk5CRo7EhYpEhcuFRoqFhssHB8mEBczExs0FRswFhwxFBw2ERw6Eh48GiIl - GyA3HCAyHSM2HSI3GiA7HSI5JiwvJioyIyk7JCo8Ji48Dh5BDh9CDyFECyRMCydODCZOBi1dCylRCi1X - FyBAFSJHEyZQFjFfBzRmBzltCjRgCzhmKS9BLzZLLjVMLzVOLzVQLzVTLjZXLjdcLzphLztiLztjLzxj - MDphMD1kCUB2Ckh/FUF4N0BVO0JRPENUPERTPkVVP0dXOEJYNEd1QUhZQUlaQkpaQ0tdRU1eQk1hQ05h - Q09mRk5gR1NmTFtwUmB0VmV2XGp5XGp6YXB+Y3F/DVGHEEiGE1qPEFCQEVmaF2GTFmKgG2ynInatKH2y - ZHWFZHWGa36Ob4CEb4GNcoONcIKOeouVeIqXe4yWf42Wgo+YhZObh5adhJafiJaekqCmnaOwnaywprG0 - p7G1tMDEtcHFucTH09jf1tre1Nng19zj3eLp8PX8+vz//v7/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARsHXsgAAATlJREFUKFNVy+dX - QQEYgPG3SyGyJTTsvZJxqcwWUbj2Di2zMiqU5v/dB+eWfh+fcx7AMCx8Oi+MYXAeWeGtz+OtROBMfDt+ - mTe+FUM4Mxk9j/48jyYZOMk/Df97ysNxdtgbPNzfzdw/DHrDLByl++1uc/o9M2122/00HKQ6jVbuC5dr - NTopOEjeXF2nPnGp66ubJBzGE9FY4AMXiEUTcdgIWja31l5xa1ubliDADp9Ko7zhKDQqfwcQ6yqTtfwb - l1nMVSsQbEIGm/6709kMoQ0Idi2Hu/T4PvO4xOVo7UBw6KQyCXmRSCKTiItkiUyqcwAB1cuVSoVaY942 - a9QKpVKuRwFBDSqjyesrlC5KBZ/XZFQZUFgQhPzFcqVaq1/Wa9VKuegPCWABETndrt29fY/Hs7+363I7 - RcgPYGp9sy9YtQ4AAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDhAWEhIS - EREWERIUERIaCAopCQ03EiA/JCg2DxpZFSVDFidGEiRIHSlFEihSECtXEixVFClQFixSFC9VEy1cFTFW - FTBeHytmEjBgEjFiEjRrFTdsHzlsFjxzFDx6Hj56ITBMIzJOIzVVLz9cICpmICtoIjdhF0B8OUFVOEBW - OkJXOkJYO0NZPUVbP0hdO0liOlB+Q0tdRU1eRE1fQ01iQ0xjRE1hRk5gR1dxSFlyFy+BFy+CE0WOHkSK - HU6HGU2PGk+NHlCCIUCIIECJIEGMJEOJJkSIJESPK0qPIlWDJluDKF6EN1abJ1ekKGmqK2+rMHasNX2s - M3KzVGaARmenS2yoQGi5UG+qVXKsW3mxX32xZHSHOoSsP4ytQ5KudIWSeIuceY2dbom3Vo/Ie5TAfZbB - hZmkh5qlipqliJ2nk6WulKavl6mwm6S1mKiwmquzn6+3obK5orO6prS6sL/EtL7EiszfjtHfk9Pfl9bf - ntjfg8LhiMvgo9rfscDFxMnOytLWytPX09jfyN701Nng3N7h3ODk3eLp7+/x8PHy8PX8+vz//v7/AAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAasY1UQAAATxJREFUKFNjMDc3 - NzM1QQBTM3NzBiNjg6TUFARITTIwZjA0aO7sQAadzQYMelGtDY3IoKE1ikE3sr6kDhmU1Ecy6ESUFhYV - 5OdBQH5BUWFpBINWeHFWdkZbDwS0ZWRnFYczaITmpKXHQ8V6euLT03JCGTRDMhMSo7thIDoxITOEQdsn - 2MJSvwsG9C0tgn0YODyUFRR522GAV1FB2YOBwU2Ji5u9CQbYubmU3BhYXNUEhXhaYIBHSFDNlYHFSUZE - jA8uyCcmIuPEwOIsLyUtkQvVnishLSXvzMDiYiunLivJLyAsKizALymrLmfrwsDi7mtj72Dn6Onl7eXp - aOdgb+PrzsBknRzk5x8QGBMbFxsTGODvF5RsxcDIFlZdU1ZeUVlVW1VZUV5WUx3GxsDIzMqpKi6uAgHi - 4qqcrMwAl/uGWf27czcAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAAT4AAAAECAMAAAAgcKN9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFHB4hHR4i - D0HNGEXCWHiYYnm0a4/ubpb/frjthMX/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbZ1u+QAAACZJREFUOE9jYGQY - BRSEAAsH5yggOwQYmJlGAfkhwMDKxj4KyA4BANhiFlbMlRkDAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAAFIAAAANCAMAAAANKsmLAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDg0MDw8O - EBAPEREQEREREhISFBQVFRYXFRYYFhcZGBkcGRocIiQpIiQqJSkvJioxKCszLDA5NDpFOUBNO0FPPENS - PUVUPkZVQEdXR09hS1NmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIb5gPgAAAHBJREFUOE/VzjsS - gDAIRdFnFMVPNH6j7n+hFgELW9J4GobmzsOZHWJ2OJQ1/YawJ3FbjbYoKV05N9yacDPLTkyJA/edQc9w - kkKRhMUP3mDwS5AUKBkvuk3oGiWlSVezUe0+SapKo0qKpCv1z3D/kXwApPU2QwRJJE0AAAAASUVORK5C - YII= - - - - - ..\Resources\pictureBoxNoFS.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\pictureBoxNoFSDown.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\pictureBoxNoFSOver.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + iVBORw0KGgoAAAANSUhEUgAABXgAAAAtCAMAAAAjrvPmAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw8OERER + EhISEhITEhIWEhIXERIcERIdFBorFRssJioxJzBMKDFNPENSPURTPUVUPkZVNUBmNkFnQEdXQUlZQkpb + Q0tdRU1eRk5gR09iSFFkSlNmS1RnTVVpTldrT1htUVpvUltwU1xzVl93WmN8XWaAX2mDXmmFYGqFYWuG + dXyadn2bi5KnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6HRMPQAAAalJREFUeF7t1jVu + RVEQRME2MzMze//rczL+S+ioTvLCkUpXrZdfESBAgEBVIB8iQIAAgapAvqZPESBAgEBFIO8iQIAAgapA + 3kSAAAECVYG8igABAgSqAnkRAQIECFQF8iwCBAgQqArkSQQIECBQFcijCBAgQKAqkAcRIECAQFUg9yJA + gACBqkDuRIAAAQJVgdyKAAECBKoCuREBAgQIVAVyLQIECBCoCuRKBAgQIFAVyKUIECBAoCqQCxEgQIBA + VSDnIkCAAIGqQM5EgAABAlWBnIoAAQIEqgI5EQECBAhUBXIoAgQIEKgK5EAECBAgUBXInggQIECgKrD4 + 490XAQIECFQEsi0CBAgQqApEBAgQIFAWWJ6WRIAAAQIVgfwPry8BAgQIdAQMb8fZFQIECCwEDK/HQIAA + gbKA4S2DO0eAAAHD6w0QIECgLGB4y+DOESBAwPB6AwQIECgLGN4yuHMECBDIyoSCAAECBDoCWZtWRYAA + AQIVgWxM6yJAgACBikC2pk0RIECAQEUgu9OOCBAgQKAikOPpSAQIECBQEcjP9C0CBAgQqAj8AYNKjD+4 + WHt6AAAAAElFTkSuQmCC + + + + + ..\Resources\pictureBoxFastForward.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pictureBoxFastForwardMouseDown.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pictureBoxFastForwardMouseOver.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pictureBoxFS.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pictureBoxFSDown.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pictureBoxFSOver.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + + iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAMAAABFjsb+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw8OCwsW + DAwRDw8TDQ0UDQ0VDg4UDg4VERESEBATEhISFhcgGxskGxwhHBwjHyAlICAoIyMtICMuICQuJicxJygy + JioxKis2Kyw1LzA6MTI8NDU+NjpGNDtMNjxNNz5OODlBOTpDOT9POj9ROUBPOEBQOEBRO0JSPENSPENT + PERTPURUPURVPkZVPkZWP0ZXREZPQEZXQEhYQUlZQUlaQUlbQkpbQ0tdRExaRUxcRU1eR09dSktUSkxV + SExdSU1eSU1fTlJeU1VdTFBhUFdnUlhmV1lkU1loWWBuX2RxY2ZvYGRzZGd2Yml2ZmhwZ2pycHN7c3V+ + bHGAcnWBcnaDcneGgoWOgISPg4aPgYaUi46Yio+Zio+ajJCZlpmilZmkmJylm56nmZ6onqGqoKOsoKSs + oaWyp6qyqa23sbW9srW+tbnBuLzDvb/Hv8HGvsPLwcPJwMPLw8XKwcbNw8fPw8jPx8zTy9DXz9HVzNHY + zdLZz9Pd0NXd0tfe09jf1Nng19zj3d7i3OHo3eLp4ODk4uPm5ebp6urt6+zu5uvz7/T78PHy8/P09fX2 + 8vX48PX8+vz//f39/v7/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgqUuWQAAARJJREFUKFNjsMIE + DOaYgMEMDExBhIkJhMNgDAL6LvrGxpa+HnpGIB6DIRBoh08M0dFxTuwpctcBchl0dXW1XXsn5alZd0fZ + V3R4aurqMmhrqasWTJrULmvo3dpo19Jmoa3NoKGUkTUBCJRjcp37Cn0mxKtoMGjLdfWDQGhQf2Rav0Nn + tbw2g5hQUzMIRMs0JwU3O+bXCIsxMDDV1oGAk02dV1idRFkmEwMDF3NEbD0QcPslS1WlGtQHMnMxcHGy + MCbU15ey8ynmZItnF/NwAsW4ONlEK+vimPnL/EXTS6TZuEBiXBxsbg22nMwCAeUpImycEDGgSkE2Dg5e + BUlWkBBEjIuTE8jmAJIcIB5EDBVgEwMAxe1P5C1jRZkAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAMAAABFjsb+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFExMVDBIt + DhQuDxk3DRs9FhouHB8mEBs1FxszEBo4ERw6Fx8/GB45DyA8GiIlFCI7GSA3HSI3GiA7HSI5JiwvIic7 + Ji48Dh9CCSBGDyBDDyFEDyJFDyRGCyRMDiZIDCZODyhJDChPDytNBi1dCilRDCpSDy5RDC9YDDNfEiVB + EiZCFyBAFSJHEyZQFjFfBzRmBzhsBzltCzhnDDtqCDxwKDBKLzZLLjVMLzVOITZXLzVQLzVTLjZXLjdc + LzphLztiLztjLzxjMDphMD1kCUB0CUB2DUBxCkh/FUF4OEJYPUdfPkhdPUtiNEd1QkpaRU1dQ09mSU1g + TFlxTFtwV1xsV11vUmB0VmV2WGJzW2R7Wmh6XGp5XGp6YnB/DEyBDVGHEEiGE1mOE1qPEFCQEVmaF2GT + FmGfFmKgG2ymG2ynInatKH2yZXeIZ3mFbnaIa3yJbniKcHeHdXmDeXyGb4CEcYGMcIKOd4iWeYiUeouV + eIqXe4yWmz0ashwMpDAUvDwuvEE0vEM2s1A4slU/q2NIwQUCxwcHwgsIzgAF2QAIwDwy1CEl1Cov3ycu + 1y0x2Cow4AYR4TM54zY/3XVz3Xd26GZryoV1gI2XhIiWhYqXgY+YiI+eg5GahJGfh5adhJafiJaejZGb + jZGfkZSdjpWhiZiljZqgk5qlmJ2qmZ+tkqCmlaCmk6GpmaaumaavnqaunaywroaCq4qGqIyHqI2Ip6+2 + prC0p7G1rrm/sbrFtr7KtMDEtcHFucTHu8TJzZGY0YuT0Zedw8jQyc7VzNDV0NXd0tfe09jf1Nng19zj + 3OHo3eLp7crG8MTD9MbH4+jv6ezw8PX89vf4+vz//vz8/f3+/v7/AAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAc6SIIgAAAV5JREFUKFNj8GPj + E0EGfGx+DGIlu/cig90lYgzRe7Zv2w5CELBt+55ohtgNq1atWrZ6GZCEgA2xDDGr5i2YtfXq+jkLIGDe + qhiG8PmVFdMvXTtSWl29Zse+HWsq54czhJXn5x6+fPlCbNm6g5MmTDq4tiqMIThn566LQBA1d39n79SJ + nQeWBjMEeJ86DQKFS3q6O85d6etfHsDgKXrsOAjMXNg++Wzr2Sltiz0ZzFiPnwCBkKKGxitnauu7is0Y + zDlmLAKJCfhvqmue1lS3MdCcwYKHiXHF8eOH2PkjtrTUtGwOFbJgsOLmZDY9enIlr5amT8HsPC8ubSsG + ax1xSZbI80FyakoKcjLSUuI61gw2urLyshKWKkZuxhrqqorysro2DDZ6yvoGJi5xialJ8e6uhvrKejYM + gr4eCckpaRlZ2VmZ6SnJCR6+ggwMwrZOdvYOjs7Ozo4O9nZOtsIMAJnRonErDmY9AAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAMAAABFjsb+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFERIUCAop + CQ03DR9HDxpZDiJNDyxeEylPGytKHStLHS1MGy1VHS9XFjVfHjBYEi5gHytmETFmEjNqEzVqHTRlHTVm + Ezl2Fj1wFDx6Fj55HT14JzRRITZZKDZTLzlULTteNT9YICpmICtoKj5kLD9lF0F1F0R9HUhzH0p0H016 + NUFdJkNqKkNtKkpwLE53NUdtPU1sO1F+RU1eR1FtTVRsT1huSVlzS1t1TlhwV2B1Fy+BFy+CE0SNE0WO + HkSKGEmJGUyJGU2PIUCJIEGMJEOJJkSIJESPK0qPLl6DOVqCN1abJ1ekKWSNLGeOLGufLWyYMHCdM3ab + KmynLW+jKGmpKGmqKm6pN3ykM3KzRWeMT2WFWmuKRmenS2yoQGi5UG+qVXKsW3mxX32xZm6CaXSJbHeI + aXiLaXiScXiLcXuJcXyQc3yRPIWmPoqrQpGtd4GUdISSdIWffIaTfoeXfIuYfY+bbom3Vo/Ie5TAfZbB + g4uehIubhY2fgZCcgJOfgJSfiZOfgZWgiZGhjZSkiJijjp6omZ+ukqKrk6Wulaeul6GymaGwn6a0m6mx + mquznKy0na61oKi2oK21oqu8obK5orO6p7C+prS6p7W7qLe9rbS9qri+rbi/rLXBr7rBr73DsbfCsL/E + tL7Etb/FtrzIuL/Kiszfjc/djdDektHdlNLbltXenNXdntjfg8LhiMvgotnescDFvsTOvcbQwsnPxMnO + wcfRw8rTxMrTx83Vyc7XyNHVyNHWy9DXydLWytPXy9LbzdLa0tbb0dbe09jfyN700NXg1Nng19zj29/i + 3N7h3N/j3OHo3eLp5Obq5ujr6Ort5+z07O3w7+/x7u/y7/T78PHy8fP09fb38PX89Pb69/j5+Pj5+vz/ + /v7/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYxRxBgAAAW1JREFUKFNjMDIs + q6xAgMoyQyMGw6PXLiODa0cNGZJO7du/f/8eIN63ezeIPJXEkLh14caNs+fM3jh/xqJ5M+dvXLg1kSFh + 0ZSpfYvvzZnQ37vl9slJ/VMWJTDET+9ob79z71BL641ZRaev97ZOj2eI7awrPXTv3pWCkoYL5zLPX6rt + jGWIqd+8/S4QpE3blXprb/HduY0xDF5mV2+CQH7WzZrJNy0uHjP3YnCXPnMWBJoUzrZlnDXZdFjWncGV + 8/ARELA0PZJcfURu5wIuVwYXnqrm40DAkdKjdXCi8fFsPhcGJxFW5u7jx3ewyxgsXSK/ZBu3qBODk5Qg + v/LBI1282rvSVaZt12eTcmJwtpOQFI4+EaWuoVt4YLKOkJidM4Obt62jg6qepo+vR6SnuJq9jbcbg3V5 + RGhYcEB4bl5OoL9fUEhEuRUDU9y69ctWrFy9dsOaVSuXL1u/Lo6JgYGRRUlAQBECBASUWBgZAFBhr6gt + gaHsAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAIAAADZ8fBYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAABeRJREFUSEt9lgtQ + VFUcxg/i4nsXFpZlWXnJW54SD+PhsoiAIA/BIJ+hBhkzko5TjpUzxuBMJlqOUgoNKjIEFI06AVr4oEKz + 8JFIKUqZzfjI8lFOziiy/S7HWRXHdv5z5pzv/32/ezh7711sMma9Ip7xGaZ8bC0W8aD/3v3796RLpbKz + HW5nYyMGBh4MDAw8KyvS84qfqNyi9NyijFlLMvNLpmbMmxRt9vYNMrp5GlzHuxrdGZmjoNPFgxO/Uk9y + RNrMl4cU1qT0ud5+wTqds5d3QHhUYpw5x5S6YEpKISNzFHS6eHDifxoiUrMXWSstZzFXDo8yOel0Pv4h + U6blRya+HpG4Ia2gvnj5lytWdzAyjzBtQKeLByd+UmQfR4mUzEJZqPR8/EPZyGRTJkkQdZ9d6Dl3s/eX + 2xQTOWfc3nCeLh6c+ElJ7kNaVqGYlrlAVmrOIq7vYjCaUuZMjH2vclcviK7Tf+1pudj4eV9tfa8sroTS + 2XUd+qYdP+PET4osBCtNJGfM5xtIyV4YEhHPlSW0tfOaJH6869zmbT0bK7vXfXBKFnMUdC6Gp6H9cnDc + h6TIQoADbWrGfMHBg05IzuOkouPT/OPXY2U7/KXkyypOvFH27bLVRx8vFHQuAJ0d4CdFFgIcaDCFefps + Zny/VJhpRdmWMwdO3OAQmKwo7wLReuh8XXNPQcn+2aUdjMxR0Oni4ShAv7m5h6yEQIOpcOPM2VwqJiEz + akZdy4lblQ19EjrvtfbOrouWwU9F9bG0hV8wyiU61yh55zgbr6i90Nz5J1kIcKCZ015UuEFhk908JoQl + lnJZ/iigBArf+gHQye7fJai68bvogqb11d/IJTrduSuP4SS1dd9VZcuJpXCgKftNTC2QC7/Yd2mX1fQu + 39ANNHf5kYQ5n3b9+JuVGzBjl5WLThcPTmXXNb3v770CQW7RlFog4pJm6l0MPJd8rfKyWNlI+tIjbNDK + 5QSGcOnikWi2AhcCHGgwBcfBLCoua0JoTXnz1SXrTuOOmXvAL6vNOWab9XzZqW1k9aqN7dbzpYsHJ35S + ZCHAgRZrzhLyAfPyjbQb+e6kGYeMkc0q153CsFO41wqPTYeP9t3rt1DllR0icAtcuUSnq3jca+3G15Ii + CwGO8vgFhAqNRu3o5KRWO6OOcm4SY6uEY40SCKgHxC31x81/KYjst3TdfubXb91Fp6t4cOIfWzXSpQkC + HGj2GrVwcHDgOeFBHD5ymd67xcZph7LZwEYR3Qioqe1U36VrFFyUovJWuUSni6I4DTtJkYUABxpMYa/R + hEWZeKXajcmhNyZgr2KN3yOS9wlzE7fXyTPnKXbKEq5corNUPDgDG0mRhQAHGkzlHHwDw3iljnYIVjtv + 98o9rVgz2sULR0Vmy5b6Qx1HjlMQRcHhvLIWuUSnq3hwxu8hRRYCHGgwlXNw1huU153eaKsqCik8q118 + koDq1V7b4u9Xf9TS+tXXFESWjHKJzhIPTvykyEKAA005B61Wq1GPY/OhzyVwQY13lanyHwLDVl1Rr+nz + WbZ7aUXDgrWfuK486LrxV0bmKOh08eDET4osBDjQYCpc8HoXo3zw7EaZuSvz2+4at/5N+Vae9V570G99 + Z0jdpfDdtxmZo6BLA078KlUiWQhwoD3kyi1zLqaUfEedAVPQnLbFP1nSj/fHHrgzed9NRuayHlfw4MTv + pHMhq5zs4GYfcSU6IiaJVwYmuxFRPE7s5e07Fqr4uuWlyw+LuRTp4sGJnxRZK/QJLsdhb6+hzVvZ3dNn + 1FgP2xHT3ZNrZ1ddXNPdv+mGRRZzFHS6eHDiJ0UWgtys5DpaC51bxD8ogl/AyOeTOazRo/WqEaG247LG + uBU5eJUwMkdB53vHgxM/qUHmIxRc/ZBSq7V6Fw/uGH4E483ZvPo8vQKd9eNlMUdBp4sHJ/6nIcJB6zak + tFo3e3sjT7re4B0UPiUuKU/5YR38R4CROQo6XTw48T8NETpj8DPLdaJW70/pXCe6ekbIYm4V/yf7Hwfx + peH+1vvyAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAMAAABhTZc9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw8ODxAP + DxEWEBERERIREhISERITEhIXEhQUERQVExcXEBEcERIdAAA0AAA9CBEkCxY1EhgoFBkqFRssFx8wGyIm + GyMtHSc6Jy00BABGAABPAgRLAgVMBABIBQBOBwdNCQhPAgBRBQBRBQJSAQJbAAhWAA5XChZeGB9dAwdj + Ag5lABViABZuAB9oABpzFhxjFixYHSZfHzRFACVvACN3ACtxADV6GTF0Jy9MIjpJJj9KKDBNKDdLKzlD + KzlEKDlGKjtFKDtGLTtHLD1JMT9MIy1pJS1zMjx3KUNPLUBMJENWJkVYKkZSLUpXLU9dO0BOMkFRNURS + NkZUN05dPkRSPEZVP0ZWOEpZPkhYPk1dK05kKVdsK1d9O0J2NVVmPlJlO2d4QUhYQUpaQ0tdQ0xeRElY + R0xaRU1eRU5gR09iREt5R1FjRVJkQVRqQ1luSFFkSlJlSlNmSVRoS1RpTFdrTVhtTlN9WF5tR2V8V2Bv + XmZzAC2AADWFAT6NAESIAkqUAFGeA1uoCWGoBmSxFnKuHHCyGXm1IVmWKGWfKGWgPnymDXnEQ0+IRFaL + SVSGTFeITFyOU1yFTW6GQHGERXOJR3qPTHKLTXeRTHSeS3uTVmONXWGGWGqVWnecYWWHYmaIYmuNam+P + Y2+SY3OWYXabY3iUbXGQbneVb3qXaHuec3aHcXWSdXqVcH6bcX2gP4CdN4KyFY3VLozIIpnaNJnTJaTm + LqvmKa/tM7HoNrnyRoGWSYOdQYOhQoShQ4WnRoWjRYijR4umQ4itSIegTIihSIyoTJGuT5W0UpWxUpe3 + UZi5VJu8VZ6+aoGbfICafoScaYWmdYWlc46vfIKjfIeofY2jeo2ofpCnR8v6VdT/dub/goefhoqfhYuq + io+iiYymiY2rg5eqjpGphpiwkpetmZ20jKC2lKG0m6K3nqe7nam8oKK3qrLGtLbGtrvCtLvPwcbNwcLR + xsfVzM3Zz9Tb3eLp6u/26/D3+vz/////AAAAAAAAAAAAAAAAAAAAAAAAzAsMkgAAAylJREFUOE9jKASD + goLi0pwgTw8fXx8Pz6Cc0uKCApAwQz4ElOQ4eyQcOXnq1KmTRxI8nHNKwKIMmSCQXxJoNfn03mgvext7 + r+i9pydbBZbkA8UZMoAgs8jZ78R6y7RV9548eXJvVarl+hN+zkWZGRkM6UBQ5BR3Jjrk3osnd86fP3/7 + 0dM7/tFn4pyK0tMZkpOTswP8znhVvXx0bs3qZcuWrV5z7v6Lcq8zfgHZyQxJSSmRVieiq17eXrNs/mwQ + mLdwzfmnldEnrCJTGBITMxwmr498dXvFgoVvX5eVlb1+u3DB8vPPw9dPdshgCEuM8Djp/fD6igUTP/78 + +SD2/s+fH8sWLL961eukRwRDWJJLwp68Z2sXzcr6/PPnU/dHP39+zpq4YMXj3D0JLgwhEY67Y85eWzyr + PxYo+8T1AVA2tm/W4otLY3Y7MoSEWh2LurRyzoQed7DsXaCse0/vnJUXoo5ZMYSF+hw3ujC3191N/xPQ + XvXLP39+0ndz7517wei4D4OEhM8xfkMNeTlFqY8/ftxVW/fjx0cpRSUFDVf+Yz4MDFweBwR4+WTlVFTf + f/t2RXvdt+/vVVWUZPl4BQ54MLByxR0w4JVUUtHSfvP160XdlV+/vtHWUlGS5DU4EMfAyha8K4ZPWVPH + xPjVly/rTJd8+fLK2ERHU5kvZlcwAyuj3ZQuGS296hqz5x8+rDSb++HDc7Oaaj0t6a4pdgyszKIVB811 + qmvr666/ezejYca7d9fr6murdcwPVogysLKyhk/t0qmtb2xuvzC3qbtp7oX25sb6Wp2uqeGsQFkW0YrD + 7TXN3Ru7W9o2bt7Y1gJkNda0H64QZQHpZbaddrS9YePWbdt27Ny5c8e2bVs3NrQfnWbLDNLLysoRPv1o + Z/P2GzdugsCNG9ubO45OD+dghciycoVPO7yhdfONWyBwY3PrhsPTwrmA4gxsYMDpNGnmgQ0bNm3ZsmXT + hg37Z05y4gQJM7BDAJNY/KSZu/fuO7Rv7+7pk+LFmMCiDDxQwM0tFpBXMWnapIq8ADFubogogzAcCAkK + iYiLi4sAaZgYgzUKsLCwQOYDADNYgx+MsDCLAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAMAAABhTZc9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw8ODxAP + DxEWEBERERIREhISERITEhIXEhQUERQVExcXEBEcERIdEhgoFBkqFRssFx8wGyImGyMtHSc6Jy00Jy9M + Jj9KKDBNKzlEKTtFLTtHLD1JMT9MKENOKkNPLUBMKkZSLEdULUpXLU9dMkFRNURSNkZUN05dPUVTPEZV + OEpZPkhYPkxdMldmO1NlO2Z4QEdXQUlZQkpbQ0tdQ0xeRU1eRU5gR09iR1FjRVJkQVhuSFFkSlJlSlNm + SFRnSlRpS1ZrTFdrTVhtRGR5SWZ+AC7SCiTVDi3TADvNATbXBTbfBjzXADrcDTHXDDPdCD7ZES/OFjXP + GT3RAD3gFDvlP3CEAUbSClXUEkTdHlnOHVLVAEDkAEfpAEjqC0voAlr0GkfmFGrYDGr2DHD2FH33Ik3P + JU7KJVvbJFntLGbQJH7WNGnPMWHdOnfCK2TvJXT4Mm3oO3DoTW6FTm6HRXOJRnmOTXKLTHqSQXPSR3fQ + Rn3jGoT+KIrcNZjcJJP7OKjzRoGWR4KcSoWeSImfRoeiRIetR4qnSIimSI2pS46vQo25T5GvTZK1SpG6 + TZS5T5e9bJKrZZW8eJarc5i/QITeRYneTY3fRJrHTZXAQ5LTQpHWRZPVWoHWUZrBT4rkWI3mXZHqTanH + S7nqUbzgZovZbJLGeJnKdJXTf53UfZnYfZjeYYnlY5XlY5TqbJbobZrpd5Tgd5XldZzofp3jeKXrfKDp + fq/vcqX5S8D9Xs3pesD9aeH5cubze+/8hqC5jKTYmazElqzZgKfqh63tjKTmjazpjbLtjbbwkqfnk6jn + lK7rma7ombHum73vorTOp7nZtrvCoLPqorXroLbupbbrpLfvpLrtqbrkq7ztnsf1g/T+ivD/l///qMbz + ptb8tcXjvMnotMTwtMzzs9b3sv//v/L/wcbNz9TbwMvox9HpztboxNX1wdr3zNT1z9j2ztz20djq19z2 + 2d73yuH4w/r/3eLp2eL46u/26/D3+vz/////AAAAAAAAAAAAAAAAAAAAzS/fsQAAAylJREFUOE9jsAUD + Gxt7J0s1eTlFJUU5eTVLJ3sbG5AwgzUEOFpKy+k39cyYPqOnSV9O2tIRLMpgDgLWDqpiof2zp63ZtHXT + mmmz+0PFVB2sgeIMZkBgbi+t3D1r/tV3nz4CwdvL82d1K0vbm5uZMZgCgZ2U7twpZ769e3jjypUrNx6+ + /XhqylxdKTtTUwZjY2MLFeW5Ux59e3jp9MkjR46cOH3xxvuHU+Yqq1gYMxgZmeiIdU959P7a6SOrNmzc + uHHDqiOnrr2+O6VbTMeEwdDQTCJ01rHP105tXvng+pzVc64/WLn56OU3h2eFSpoxGBhqy/bN+3z36NYl + L3/9Olh18Nevl0s2HT37Zl6frDaDppGM/szjj48dWj/nw69f5yv2//r1Yc66rcceHZ6pL8OgoS3ZOPXx + zcOb1la+AurNBsq+qlyw/tDZu1MbJRk0NMU6qx4f27J2AVg2EyRbMX/tlsP3qjrFGAw0FWbk3Nu2tqog + Emjv/vAVQHsjC6oWbLuZM0OBQUREode3IMrbJ9rjxc+fK8KW//z5wiM62D+90LdXgYGBS7bV3cvVMzgm + 7P737yvCl3//cT8sNtjT1cu9VZaBlUuvKTDE0ycmPvz816/Lwpd+/Xo+PD7WxzMksEWPgZVNvSHNLy42 + Pin83PPnyxKXPn9+LjEpPjYuJK1BnYGVUaIk1y0/Pjkl8cCzZ5OzJj57diAxJTk+3y23RIKBlVnQuSMg + vzqlrmbfhQsTaydeuLCvpi6lOj+gw1mQgZWVVas0129HXX1916QJ0xdNnzCpq76+bodfbqkWK1CWRdCl + OTVj944dixcu3Ll758KFi3fs2J2R2uwiyALSyyxR1hGUd/vW7t179u7du2f37lu384LayiSYQXpZWTm0 + yjtSQ3Y9eXIHBJ482RWS2lGuxcEKkWXl0iprzvXL2H7v6Zen97Zn+OU2l2lxAcUZ2MCAU6qovC03KiIh + ISEiKretvEiKEyTMwA4BTEJ6ReVN7a2tre1N5UV6QkxgUQYeKODmFlKxcikuK3axUhHi5oaIMvDDAR8v + n4CwsLAAkIaJMYijAFFRUWQ+AARqaklCCnVoAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAMAAABhTZc9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw4NDw8O + CgoXDg4SDg4WCQwfEA8PEBAPERERERESEhISEhITEhIXExQUFBUVFRUWEBAbERIdExUZFBUYFhcZFRcb + FhccFxgZFxgbFxgfGBkcGRodBQcuBgc1ChEsEhcnFxkjFRoqFRssGx0gHR8jGiAyICEpISMoIyUrIyYs + JCctJCcuJSkvISU0JysyKy84KzA+LTI8LjM9LzU/MDU/BQVAAwdJBglBAw1OBgtQAwVlBAhwDR5nDS5+ + MDVAMTZBMjdCNDlENTtONjxINz1NOD9NLz9zO0FPO0JSPURTPkVWPkZVP0ZWP0ZaP0deL0BuPkZgNEB1 + QEdXQUlZQkpbQ0tcREtdRU1eRk1gRk5gRk9hR09iR1BiSFBjSFFkSlJlSlNmS1RnS1RoTVZpTVZqTlds + T1hsBgiIAAyaABOdABySDhafARSgABmgAB6iBRqhBhygCRaqCBiqACmQDiOYADWYFTWXACimCyiyADup + ADywFyO1GzStIi6eJjqIJzyLKjqKLDuWAEWdAECvAE+2AEm7ClSgHkSiB2O8GWutIkmNMkCNKk26K1q3 + NUykO1qrOVu4NmCaNnevAFTGAFjHAGHIBWnaCnnYEmPPA3flIVLSLWDYSFemRmS2RWO8RWi+SmKxV2mm + V267VHmiZHK6RWbAS2vEUW3EWW/DU3LHVXbJYHfIYX7MbXzJcX3GGYjWD4vvHJjsGpj0JpPQP5XzLqvq + Kqz2MbX3N7v0O8L7XoSme4yxWZrgVrf3bYLNaInScYbDc4HJcoTOeIPHeoXMcY3TepPVRcv9TND+X+b/ + Y9b/Zuv/fPT/kaO8g43Ph5LJgpTUgp7aiZDQjpXTk5nVmqnLkaDXlaPalajdnKPZn6jbhK3oj7LnmLjo + oqbapKzcqa7dqbLAqLPUtrvCtL/YqLzmsbXggNP8ke7/v8bdtsjrwcbNz9Tbxc3hx87rztPj0dfv2Nrw + 2uDn2+Lt3OHo3+Pv2+Dy6u/27PH38/X5+vv9+vz/////AAAAAAAAAAAA6kUEYQAAAxhJREFUOE9jSISD + 5LTUhMjIyITUtGSYGEMCGMTHJ6WE2msoS0tLK2vYh6YkxceDhBniICApRJNf3c7dL8DP3U6dXzMkCSzK + EA0CsfEmfFpegd1zlqxbMqc70EuLzyQ+FijOEAEE0bHa/K6Bc+5/+PYRCD7cmhPoyq8dGx0RwRAOBDFa + Ur4N17+9e/bg3r1795+9+3CtwVdKKyY8nCEsLDTKkN+34dWHZzevXL506dLlKzcfvHva6MtvGBXKEBIS + 5snnXP/03a0r5w4fXLd27cEj5y7ffPW03pnPM4whODhMXd3twqvrFw6ef7Rk0YoVK1avPXTh2qtjburq + YQxBwe58Ln2vblw4tOj9n59X585btnzF6n3Hrr3qc+FzZ/AO1lfxP/b0wqHVC97/+fPn64EJ85YuB0rf + Peqvos/gGaSiX3f34tE1K/tBsn/+vF00ASR98U6dvgqDp4e4fePdY2tWLYPK/vn1aO78lWuO3mm0F2fw + cRd3qr29f9mEnrK3YL1A8OPAhGX7b9c6iTPoafPrpvfU5OfmZb38DQO/SgpqetJ1+RkYGXlZ0gszMvPK + i598B4MfPz4vzMrMKEpn4WXg4jCUsq7OyS2vLH30BQw+7bYtLs/NqbaWMGTgYjPWsKyuKK9qrbz6BgTO + dpVWNleWV1RbahgzcDHq2Mllz6pqndxy9vXr1w8nNrVMmTK5tWpWtpydDtBkEVdRq9kzJk+bevbxw8Vt + HdNnzpw5bfKM2VairiIMXFwMxkZyJVumzZw+aVdn5/qNGzdu2jBz2pYSOSNjBqAsh0SQinnP3k0bN2/e + vHU7EGzbtGlvj6lKkAQHUJaLQcdHyLT31IkdO3YeP3H8+M6dJ071mgr7AG0FyXIxOAQLy5btPXPm9Ekg + OHNmb5mscLADyFKQLAe7Q4gKq1n7nucvXrx4vqfdlFUlxIGdAyjLDQKcjHrRjiJMMhY2NjYWMkyijtF6 + jJxAcQYeCGCWdA1311cTExNV03cPd5VkBosyCEKBAIuCgUdoRHREqIeBAosARJRBCQ4U5eUVVVVVQRRM + DACG9nnjnRgGhwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAMAAABhTZc9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw8ODxAP + DxEWEBERERIREhISERITEhIXEhQUERQVExcXEBEcERIdAAA0AAA9CBEkCxY1EhgoFBkqFRssFx8wGyIm + GyMtHSc6Jy00BABGAABOAgRLAgVMBQBJBABNBwdNCQhPAgBQAAdWBQFRAQJbAAxWDRtXEQxSGB9dAwtk + ABRjABVuABhvABxzFhtiFixYHildACZpACN3ATh5HCNhGTF0Jy9MIDdHJj9KKDBNKDdLKzlDKzlEKDlG + KjtFKDtGLTtHLD1JMT9MIy5iJS1zIjprLzt4ND14KUNPLUBMJENWJkVYKkZSLUpXLU9dO0BOMkFRNURS + NkZUN05dPkRSPEZVP0ZWOEpZPkhYPk1dK05kKVdsLl14O0J6NVVmP1NnNlN6O2d4QUhYQUpaQ0tdQ0xe + RElYR0xaRU1eRU5gR09iQ0l6R1FjRVJkQ1luSFFkSlJlSlNmSVRoS1RpTFdrTVhtSlB+WF5tR2V8V2Bv + XmZzAC2AADWFADyDAT6NAEaMAkqUAE+cElOLAFSjB1ygA1uoBWCsB2m3Fnq6HHCyKFGCJVeVLWaaKGWg + PnymCHrLQUqCRFSKTFSCTleJTFyOUViBVlyFTW6GQHGERXOJR3qPTHKLTHqSVmONXWGHVmyUWnWdYWWI + Y2uNbG+ZbXCPY3GVY3iUZ3mdbneVbXuYc3aHcXWScXWedXqVcH6be3+ZaX6hP4CdN4KyG4bFE5DcHprh + LozIIpfYNJnTIZ7jJ6bmKq7tMa/pNLbwN7z0RoGWSYOdQYOhQoShQ4WnRYijRoikR4umQ4itSIagSIig + TIihSIyoTJGuT5W0UpWxUpe3UZi5VJu8VZ6+aoGbfYKbfICcfoWeaYWqeYymR8v6VdT/dub/hImfio+i + iJCmiZaqhpiwkpetjKC2lKC0mqC2nqa8nKm8qK++tbvIwcbNwcPUycvXz9Pb39/o2uDn2+Dr3OHo6u/2 + 7u/z7PH48/P2+vr7+vr9+vz/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAyX1CIwAAAxFJREFUOE9jKASD + goLi0twgTw8fXx8Pz6Dc0uKCApAwQz4ElOQ6eiSeOn/hwoXzpxI9HHNLwKIMWSCQXxJoMePioWgvWytb + r+hDF2dYBJbkA8UZMoEgq8jR79xG8/RVdx8+fHh3VZr5xnN+jkVZmZkMGUBQ5BB3KTrk7pOHd65duXbn + 3pM7/tGX4hyKMjIYUlJScgL8LnlVPb13Ze3qJUuWrF67/t6Tcq9LfgE5KQzJyamRFueiq57eWbtk4cJ5 + 8+YtXLRk7bUnldHnLCJTGZKSMu1mbIx8dm3FoqvPp5VNmjR12rxFK649Dt84wy6TISwpwuO89/17KxdN + ffPjy8Ps7OyySdMWrbhxw+usRwRDWLJT4sG8R+uWzs1+/ePHj7eL3WMnAKVXPog/mOjEEBJhfyDm8o2l + cyfFgmR//Hg1OXbCxLlLbyyLOWDPEBJqcSbqxob5Uya6Q2R/fH06YcKU+cuvR52xYAgL9Tlrfn3BRHcX + Pajsjx+f1rhNXHDd/KwPg4SEzxl+Aw15OUWpV99h4Ju6gokz/xkfBgYujyMCvHySyipKLz6CwefP76fJ + yvLxChzxYGDlijuizwuU1NR6/gEM3l1TU1VRluTVPxLHwMoWvL+LT1lT28jw2RsQeOxqaKiro6nM17U/ + mIGV0WZmn4ymbnWN8eOXL18+TzA0Nq6tqdbRlO6bacPAyixaccxUu7quvv7+i+fzjeubm5sb6+uqtU2P + VYgysLKyhs/q06lraG3rWdDU0t4PBO2tDXXafbPCWYGyLKIVJ7pr2vr7Ozo2b9+5c+fWLVv622q6T1aI + soD0MlvPPt3dvGXXrj179wHB3t07tzR2n55tzQzSy8rKET7ndG/77ps3b4HAzZu723tPzwnnYIXIsnKF + zz7R17n95m0QuLm9s+/E7HAuoDgDGxhwOkyfc3TTpm07duzYtmnTkTnTHThBwgzsEMAkFj99zoFDh48f + PnRgzvR4MSawKAMPFHBziwXkVUyfPb0iL0CMmxsiyiAMB0KCQiLi4uIiQBomxmCJAszMzJD5AKC+iMSu + Me5pAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAIAAADZ8fBYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAABcZJREFUSEt9lgtM + lWUYxz+8sFYmnONRM2JthnePpYYlKIJwLhw4HEESmDtME1FjqNPyljrLDEixcQmHOXUmiKOkNLGcLi9o + G5osFFBAhVKuAqZyUJBz+r297iSSffvv7PV5///f+3zP931Dl5DIRcpzrj7i6utwKN2PO7u6OqWrf3/X + vv1cXVwUu73bbrc/L6uYZsf3UMRCE4pcYo5O1EXETdFHav1DxwZaxhsitaYofllToc4uHpzCj3pyFGN4 + 3DMKjUogM356MAjf+DWmLbvN6UdDsoqkWFOhLg6bHowTf2+IYrC87xTbIXMSvIMiRs4w+S/fYtlxUpdR + Zk69ueCr2x/tali/t5Ff1lSos4sHJ35SZJ9GKfqweVJUuSla0FqslrSCmWnlMam39h9rK7lqu1rTUVFt + c+rilfa9ha3s4sGJnxRZCE6aojPHShkjF2l9DZOi4sN3nvb/7Eb2D63Vfz4Aeuxca/6JlpzCZinWVEBz + TOahZpz4SZGF4KQpgSFWZAhfMCkgnJMl9Mfi+/RIfu+RpuxD9Rl59dv235JKP1BPhToHXKq24ZRoshDg + SKAy0zQ3MDTWL9TKpLgpCSWQc+IOeUAbdtai1TvqnNq0u446ze47dudc2b288wJNFgIcaDCVgOAYXdi8 + cVOD/JZtZl6ph1uKax8SIAaOfMGpmsVbK2KTbizYVi+VkCbOgJ76bSODPl3ZkfRdC1kIY3x10GAKrp8x + enRgmDnz51kpt4ByPgGePrjSymaHw/HA1kXvszbVoDmfN1q3CiVmiTcE59cn20CThQAHWoAxWsxh4oxQ + 3sfA9MuphXePlHfQ8qYDTYk7Gy1rL0quvGrq21dl1+jW/+GkP0EfbmF0tAwBDjTRL3iaN3y6S5dyA+ju + X9txiPc0swnuhSsNTq5cMFBmAn12cpM1TRxPE7TMXUKAA22GIUqZpn+PeYdsL8Aqm12T0wyUzH9yQXd2 + 2Xmqsmuc+Gklt/wxBDjQfGeGC+5YfYQ54+TE+dfZ21jQhhXH5MQGz+hLvft1tt9675EcCx2Q4kYhwIHm + ExCmjNK+zcqUdvzliRWCFVHmOq1C8alS/Gv7+VzgFe587PgPddnpGuF5wa9ixNwq3+UNEOBA8xo9QRk0 + dCgPUZ+cN1B7uf+Um8qEUsW7XECDG12CSnnJmtpsvUWz1bUNDAqu8E8oJQsBDjR3t4GC6zt7oT5p3xDv + Eo3vbWHyqQLaZ+5914hyuOSfUWVNw4bMX9zNh/oEnqUDcXPe5WQhwIGmUqkUlXrQO2FW/SdZI8KKB0y+ + DlFCByyxDf6gPDu/qORK1dOiorXmAGX3pbgmnDICFwIcaO5uboqbuxsfm25lis/qMy96lY348KGALrdp + NnRI7unzv0nlFxYZVuZ4xH1P3WOzDeHBiZ8UWQhwoLkxB3eVymP4yKC4tcbUg6o3L+GQAa+MrnEppWm5 + x8GhxdvyxqzIpzL1mzo0OecRwoMTPymyEOBAE3NQ/3O9a4rRr93OgYxC/5OdADHys74shOizMXda1hnL + 0WvmonZLcTcKOevAJtEsSJGFAEcCBVelFi0Hx280puwZbi7ximlZXGMnKShHr0nNL/uLolOxlQ5Jp4Kf + FFkIoll4ksvFNJiLecVW7mXY9N/HxbV9cdex+YE9oa4DrWrp+vi+w6llrQ7ELh6c+EmRhQDn337lSq3R + cBeh69IxcT7Pd92p7sMOB9rRU7LILh7RaepBUmICGs0TlLNf+W/eZbZF1yl75Ky5xxU5j/i+T7U7pFhT + oS5nihM/KbJOqJzDIKd4l1WawfylMi/dQgt8PCT5stVB11811EmxpiKeUnIeHpz4SZF9GgWXc3rITTXE + 4w0tn42k878FY3KuLqlAijUVScSDE39vCN+b5zNSqz3dVa8hMvwpDIheyoMOW5rE/fLLmgp1dqUNf2+I + Mthj/POkGTZW/cpofoe+/pbnKB8p1s76/2T/BmTsnV5cYwy9AAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAAT4AAAAECAMAAAAgcKN9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFHB4hHR4i + D0HNGEXCWHiYYnm0a4/ubpb/frjthMX/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbZ1u+QAAACZJREFUOE9jYGQY + BRSEAAsH5yggOwQYmJlGAfkhwMDKxj4KyA4BANhiFlbMlRkDAAAAAElFTkSuQmCC + + + + + R0lGODlhdgEMAPcAABweIR0eIigsNDA0PjY7SEZOYE1VaU5Wa09YbVBYbVBZblFZb1FablFab1JbcFFa + cVNcc1Rdc1RddFRddVVedVZfdlZfd1dgd1hieVhielpjfFtlfVtlfl1mf11mgF5ogl9pg15phWBqhWFq + hgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + ACwAAAAAdgEMAAAI/wBDCBxIsKDBgwgTKlzIsKHDhxAjSpxIsaLFixgzarw4oqPHjyBDihxJsqTJkyhT + qlzJsqXLlzBjypxJs6ZMEDhBiNjJs6fPn0CDCh1KtKjRo0iTKl3KtKnTp1CjSp2KNCcIDx0+gLhQoavX + r2DDih1LtqzZs2jTql3Ltq3bt3Djyp1Lty7aCyA+dPCggUMDAQEACB5MuLDhw4gTK17MuLHjx5AjS55M + ubLly5gza24cQEADDhosYBhAYEGC06hTq17NurXr17Bjy55Nu7bt27hz697Nu7fv37IXEBiAwQKEBwUo + TJDAvLnz59CjS59Ovbr169iza9/Ovbv37+DDi7wfT/76BAoFHkBw4EBBBgkR4sufT7++/fv48+vfz7+/ + //8ABijggAQWaOCBCCbInwQZKMBeAww4sMEIVFVo4YUYZqjhhhx26GFRI2zgAAMNIGAiAg2kqOKKLLbo + 4oswxijjjDTWaOONOOao44489ujjj0AGaeOJCBxg5JFIJqnkkkw26eSTUEYp5ZRUVmnllVhmqeWWXHbp + 5ZYGhCnmmGSWaeaZaKap5ppstunmm3DGKeecdNZp55145mlnQAA7 + + + + ..\Resources\pictureBoxReverse.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pictureBoxReverseMouseDown.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pictureBoxReverseMouseOver.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + + iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDw8OCgoW + DAwRDw8TDQ0VDw8UEBATEhISHyMtJioxMjdJMzhKNDxNOkFRPENSPENTPURTPURUPkZVP0ZWQEdXQUlZ + QkpbQ0tdRU1eRk5gm56nyszQ09jf1Nng3eLp8PX8+vz//v7/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHzqB+wAAAHxJREFUKFONzdkO + gjAQheHDVpBFqVVQcOv7v6SclgmJmRi+u386bXFX4KbAqMCgwFWBCzl7iqxj4kzd7KO5Y6K3i3aded8y + 0R8X9UfUTDgeNW/RhM0DVS9RMRGkD5GGLql4ioL5Z5hN6/Up2zZNnkS52YalEeGL+OaP/cMvDc4aWeQk + 0FYAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFEBESEhIS + ExMVExMWCBc2CRY3Dxo3CBk5CRo7EhYpEhcuFRoqFhssHB8mEBczExs0FRswFhwxFBw2ERw6Eh48GiIl + GyA3HCAyHSM2HSI3GiA7HSI5JiwvJioyIyk7JCo8Ji48Dh5BDh9CDyFECyRMCydODCZOBi1dCylRCi1X + FyBAFSJHEyZQFjFfBzRmBzltCjRgCzhmKS9BLzZLLjVMLzVOLzVQLzVTLjZXLjdcLzphLztiLztjLzxj + MDphMD1kCUB2Ckh/FUF4N0BVO0JRPENUPERTPkVVP0dXOEJYNEd1QUhZQUlaQkpaQ0tdRU1eQk1hQ05h + Q09mRk5gR1NmTFtwUmB0VmV2XGp5XGp6YXB+Y3F/DVGHEEiGE1qPEFCQEVmaF2GTFmKgG2ynInatKH2y + ZHWFZHWGa36Ob4CEb4GNcoONcIKOeouVeIqXe4yWf42Wgo+YhZObh5adhJafiJaekqCmnaOwnaywprG0 + p7G1tMDEtcHFucTH09jf1tre1Nng19zj3eLp8PX8+vz//v7/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARsHXsgAAATlJREFUKFNVy+dX + QQEYgPG3SyGyJTTsvZJxqcwWUbj2Di2zMiqU5v/dB+eWfh+fcx7AMCx8Oi+MYXAeWeGtz+OtROBMfDt+ + mTe+FUM4Mxk9j/48jyYZOMk/Df97ysNxdtgbPNzfzdw/DHrDLByl++1uc/o9M2122/00HKQ6jVbuC5dr + NTopOEjeXF2nPnGp66ubJBzGE9FY4AMXiEUTcdgIWja31l5xa1ubliDADp9Ko7zhKDQqfwcQ6yqTtfwb + l1nMVSsQbEIGm/6709kMoQ0Idi2Hu/T4PvO4xOVo7UBw6KQyCXmRSCKTiItkiUyqcwAB1cuVSoVaY942 + a9QKpVKuRwFBDSqjyesrlC5KBZ/XZFQZUFgQhPzFcqVaq1/Wa9VKuegPCWABETndrt29fY/Hs7+363I7 + RcgPYGp9sy9YtQ4AAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDhAWEhIS + EREWERIUERIaCAopCQ03EiA/JCg2DxpZFSVDFidGEiRIHSlFEihSECtXEixVFClQFixSFC9VEy1cFTFW + FTBeHytmEjBgEjFiEjRrFTdsHzlsFjxzFDx6Hj56ITBMIzJOIzVVLz9cICpmICtoIjdhF0B8OUFVOEBW + OkJXOkJYO0NZPUVbP0hdO0liOlB+Q0tdRU1eRE1fQ01iQ0xjRE1hRk5gR1dxSFlyFy+BFy+CE0WOHkSK + HU6HGU2PGk+NHlCCIUCIIECJIEGMJEOJJkSIJESPK0qPIlWDJluDKF6EN1abJ1ekKGmqK2+rMHasNX2s + M3KzVGaARmenS2yoQGi5UG+qVXKsW3mxX32xZHSHOoSsP4ytQ5KudIWSeIuceY2dbom3Vo/Ie5TAfZbB + hZmkh5qlipqliJ2nk6WulKavl6mwm6S1mKiwmquzn6+3obK5orO6prS6sL/EtL7EiszfjtHfk9Pfl9bf + ntjfg8LhiMvgo9rfscDFxMnOytLWytPX09jfyN701Nng3N7h3ODk3eLp7+/x8PHy8PX8+vz//v7/AAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAasY1UQAAATxJREFUKFNjMDc3 + NzM1QQBTM3NzBiNjg6TUFARITTIwZjA0aO7sQAadzQYMelGtDY3IoKE1ikE3sr6kDhmU1Ecy6ESUFhYV + 5OdBQH5BUWFpBINWeHFWdkZbDwS0ZWRnFYczaITmpKXHQ8V6euLT03JCGTRDMhMSo7thIDoxITOEQdsn + 2MJSvwsG9C0tgn0YODyUFRR522GAV1FB2YOBwU2Ji5u9CQbYubmU3BhYXNUEhXhaYIBHSFDNlYHFSUZE + jA8uyCcmIuPEwOIsLyUtkQvVnishLSXvzMDiYiunLivJLyAsKizALymrLmfrwsDi7mtj72Dn6Onl7eXp + aOdgb+PrzsBknRzk5x8QGBMbFxsTGODvF5RsxcDIFlZdU1ZeUVlVW1VZUV5WUx3GxsDIzMqpKi6uAgHi + 4qqcrMwAl/uGWf27czcAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAAT4AAAAECAMAAAAgcKN9AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFHB4hHR4i + D0HNGEXCWHiYYnm0a4/ubpb/frjthMX/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbZ1u+QAAACZJREFUOE9jYGQY + BRSEAAsH5yggOwQYmJlGAfkhwMDKxj4KyA4BANhiFlbMlRkDAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAAFIAAAANCAMAAAANKsmLAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAwBQTFRFDg0MDw8O + EBAPEREQEREREhISFBQVFRYXFRYYFhcZGBkcGRocIiQpIiQqJSkvJioxKCszLDA5NDpFOUBNO0FPPENS + PUVUPkZVQEdXR09hS1NmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIb5gPgAAAHBJREFUOE/VzjsS + gDAIRdFnFMVPNH6j7n+hFgELW9J4GobmzsOZHWJ2OJQ1/YawJ3FbjbYoKV05N9yacDPLTkyJA/edQc9w + kkKRhMUP3mDwS5AUKBkvuk3oGiWlSVezUe0+SapKo0qKpCv1z3D/kXwApPU2QwRJJE0AAAAASUVORK5C + YII= + + + + + ..\Resources\pictureBoxNoFS.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pictureBoxNoFSDown.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pictureBoxNoFSOver.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/src/DLLs/Interop.QuartzTypeLib.dll b/src/ui/DLLs/Interop.QuartzTypeLib.dll similarity index 100% rename from src/DLLs/Interop.QuartzTypeLib.dll rename to src/ui/DLLs/Interop.QuartzTypeLib.dll diff --git a/src/DLLs/Voikkox64.dll b/src/ui/DLLs/Voikkox64.dll similarity index 100% rename from src/DLLs/Voikkox64.dll rename to src/ui/DLLs/Voikkox64.dll diff --git a/src/DLLs/Voikkox86.dll b/src/ui/DLLs/Voikkox86.dll similarity index 100% rename from src/DLLs/Voikkox86.dll rename to src/ui/DLLs/Voikkox86.dll diff --git a/src/Forms/About.Designer.cs b/src/ui/Forms/About.Designer.cs similarity index 98% rename from src/Forms/About.Designer.cs rename to src/ui/Forms/About.Designer.cs index 89e6937e2..bb9a61b1d 100644 --- a/src/Forms/About.Designer.cs +++ b/src/ui/Forms/About.Designer.cs @@ -1,157 +1,157 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class About - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(About)); - this.okButton = new System.Windows.Forms.Button(); - this.labelProduct = new System.Windows.Forms.Label(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.richTextBoxAbout1 = new System.Windows.Forms.RichTextBox(); - this.buttonDonate = new System.Windows.Forms.Button(); - this.linkLabelGitBuildHash = new System.Windows.Forms.LinkLabel(); - this.tooltip = new System.Windows.Forms.ToolTip(this.components); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.SuspendLayout(); - // - // okButton - // - this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.okButton.Location = new System.Drawing.Point(381, 337); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(83, 23); - this.okButton.TabIndex = 0; - this.okButton.Text = "&OK"; - this.okButton.Click += new System.EventHandler(this.OkButtonClick); - // - // labelProduct - // - this.labelProduct.AutoSize = true; - this.labelProduct.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelProduct.Location = new System.Drawing.Point(13, 16); - this.labelProduct.Name = "labelProduct"; - this.labelProduct.Size = new System.Drawing.Size(140, 19); - this.labelProduct.TabIndex = 26; - this.labelProduct.Text = "Subtitle Edit 3.2"; - // - // pictureBox1 - // - this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); - this.pictureBox1.Location = new System.Drawing.Point(399, 14); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(70, 64); - this.pictureBox1.TabIndex = 27; - this.pictureBox1.TabStop = false; - // - // richTextBoxAbout1 - // - this.richTextBoxAbout1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.richTextBoxAbout1.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.richTextBoxAbout1.Location = new System.Drawing.Point(16, 43); - this.richTextBoxAbout1.Name = "richTextBoxAbout1"; - this.richTextBoxAbout1.ReadOnly = true; - this.richTextBoxAbout1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None; - this.richTextBoxAbout1.Size = new System.Drawing.Size(448, 266); - this.richTextBoxAbout1.TabIndex = 40; - this.richTextBoxAbout1.TabStop = false; - this.richTextBoxAbout1.Text = "About..."; - this.richTextBoxAbout1.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.RichTextBoxAbout1LinkClicked); - // - // buttonDonate - // - this.buttonDonate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonDonate.AutoSize = true; - this.buttonDonate.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.buttonDonate.FlatAppearance.BorderSize = 0; - this.buttonDonate.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.buttonDonate.ForeColor = System.Drawing.Color.Transparent; - this.buttonDonate.Image = global::Nikse.SubtitleEdit.Properties.Resources.Donate; - this.buttonDonate.Location = new System.Drawing.Point(16, 328); - this.buttonDonate.Name = "buttonDonate"; - this.buttonDonate.Size = new System.Drawing.Size(98, 32); - this.buttonDonate.TabIndex = 42; - this.buttonDonate.UseVisualStyleBackColor = false; - this.buttonDonate.Click += new System.EventHandler(this.buttonDonate_Click); - // - // linkLabelGitBuildHash - // - this.linkLabelGitBuildHash.AutoSize = true; - this.linkLabelGitBuildHash.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.linkLabelGitBuildHash.LinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(102)))), ((int)(((byte)(204))))); - this.linkLabelGitBuildHash.Location = new System.Drawing.Point(148, 15); - this.linkLabelGitBuildHash.Name = "linkLabelGitBuildHash"; - this.linkLabelGitBuildHash.Size = new System.Drawing.Size(90, 20); - this.linkLabelGitBuildHash.TabIndex = 43; - this.linkLabelGitBuildHash.TabStop = true; - this.linkLabelGitBuildHash.Text = "linkLabel1"; - this.linkLabelGitBuildHash.VisitedLinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255))))); - this.linkLabelGitBuildHash.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelGitBuildHash_LinkClicked); - // - // About - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(476, 372); - this.Controls.Add(this.linkLabelGitBuildHash); - this.Controls.Add(this.buttonDonate); - this.Controls.Add(this.okButton); - this.Controls.Add(this.pictureBox1); - this.Controls.Add(this.richTextBoxAbout1); - this.Controls.Add(this.labelProduct); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "About"; - this.Padding = new System.Windows.Forms.Padding(9); - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "About Subtitle Edit"; - this.Shown += new System.EventHandler(this.About_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.About_KeyDown); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button okButton; - private System.Windows.Forms.Label labelProduct; - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.RichTextBox richTextBoxAbout1; - private System.Windows.Forms.Button buttonDonate; - private System.Windows.Forms.LinkLabel linkLabelGitBuildHash; - private System.Windows.Forms.ToolTip tooltip; - - } -} +namespace Nikse.SubtitleEdit.Forms +{ + partial class About + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(About)); + this.okButton = new System.Windows.Forms.Button(); + this.labelProduct = new System.Windows.Forms.Label(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.richTextBoxAbout1 = new System.Windows.Forms.RichTextBox(); + this.buttonDonate = new System.Windows.Forms.Button(); + this.linkLabelGitBuildHash = new System.Windows.Forms.LinkLabel(); + this.tooltip = new System.Windows.Forms.ToolTip(this.components); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // okButton + // + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.okButton.Location = new System.Drawing.Point(381, 337); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(83, 23); + this.okButton.TabIndex = 0; + this.okButton.Text = "&OK"; + this.okButton.Click += new System.EventHandler(this.OkButtonClick); + // + // labelProduct + // + this.labelProduct.AutoSize = true; + this.labelProduct.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelProduct.Location = new System.Drawing.Point(13, 16); + this.labelProduct.Name = "labelProduct"; + this.labelProduct.Size = new System.Drawing.Size(140, 19); + this.labelProduct.TabIndex = 26; + this.labelProduct.Text = "Subtitle Edit 3.2"; + // + // pictureBox1 + // + this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); + this.pictureBox1.Location = new System.Drawing.Point(399, 14); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(70, 64); + this.pictureBox1.TabIndex = 27; + this.pictureBox1.TabStop = false; + // + // richTextBoxAbout1 + // + this.richTextBoxAbout1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.richTextBoxAbout1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.richTextBoxAbout1.Location = new System.Drawing.Point(16, 43); + this.richTextBoxAbout1.Name = "richTextBoxAbout1"; + this.richTextBoxAbout1.ReadOnly = true; + this.richTextBoxAbout1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None; + this.richTextBoxAbout1.Size = new System.Drawing.Size(448, 266); + this.richTextBoxAbout1.TabIndex = 40; + this.richTextBoxAbout1.TabStop = false; + this.richTextBoxAbout1.Text = "About..."; + this.richTextBoxAbout1.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.RichTextBoxAbout1LinkClicked); + // + // buttonDonate + // + this.buttonDonate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonDonate.AutoSize = true; + this.buttonDonate.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.buttonDonate.FlatAppearance.BorderSize = 0; + this.buttonDonate.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.buttonDonate.ForeColor = System.Drawing.Color.Transparent; + this.buttonDonate.Image = global::Nikse.SubtitleEdit.Properties.Resources.Donate; + this.buttonDonate.Location = new System.Drawing.Point(16, 328); + this.buttonDonate.Name = "buttonDonate"; + this.buttonDonate.Size = new System.Drawing.Size(98, 32); + this.buttonDonate.TabIndex = 42; + this.buttonDonate.UseVisualStyleBackColor = false; + this.buttonDonate.Click += new System.EventHandler(this.buttonDonate_Click); + // + // linkLabelGitBuildHash + // + this.linkLabelGitBuildHash.AutoSize = true; + this.linkLabelGitBuildHash.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.linkLabelGitBuildHash.LinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(102)))), ((int)(((byte)(204))))); + this.linkLabelGitBuildHash.Location = new System.Drawing.Point(148, 15); + this.linkLabelGitBuildHash.Name = "linkLabelGitBuildHash"; + this.linkLabelGitBuildHash.Size = new System.Drawing.Size(90, 20); + this.linkLabelGitBuildHash.TabIndex = 43; + this.linkLabelGitBuildHash.TabStop = true; + this.linkLabelGitBuildHash.Text = "linkLabel1"; + this.linkLabelGitBuildHash.VisitedLinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255))))); + this.linkLabelGitBuildHash.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelGitBuildHash_LinkClicked); + // + // About + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(476, 372); + this.Controls.Add(this.linkLabelGitBuildHash); + this.Controls.Add(this.buttonDonate); + this.Controls.Add(this.okButton); + this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.richTextBoxAbout1); + this.Controls.Add(this.labelProduct); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "About"; + this.Padding = new System.Windows.Forms.Padding(9); + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "About Subtitle Edit"; + this.Shown += new System.EventHandler(this.About_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.About_KeyDown); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Label labelProduct; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.RichTextBox richTextBoxAbout1; + private System.Windows.Forms.Button buttonDonate; + private System.Windows.Forms.LinkLabel linkLabelGitBuildHash; + private System.Windows.Forms.ToolTip tooltip; + + } +} diff --git a/src/Forms/About.cs b/src/ui/Forms/About.cs similarity index 97% rename from src/Forms/About.cs rename to src/ui/Forms/About.cs index efc95d041..983b9e531 100644 --- a/src/Forms/About.cs +++ b/src/ui/Forms/About.cs @@ -1,121 +1,121 @@ -using Nikse.SubtitleEdit.Core; -using System; -using System.Diagnostics; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; -using Nikse.SubtitleEdit.Logic; - -namespace Nikse.SubtitleEdit.Forms -{ - partial class About : PositionAndSizeForm - { - private readonly LanguageStructure.About _language = Configuration.Settings.Language.About; - private readonly LanguageStructure.General _languageGeneral = Configuration.Settings.Language.General; - - public About() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - UiUtil.FixLargeFonts(this, okButton); - } - - public void Initialize() - { - Text = _language.Title + " - " + (IntPtr.Size * 8) + "-bit"; - okButton.Text = _languageGeneral.Ok; - string[] versionInfo = Utilities.AssemblyVersion.Split('.'); - string revisionNumber = "0"; - if (versionInfo.Length >= 4) - { - revisionNumber = versionInfo[3]; - } - - if (revisionNumber == "0" || revisionNumber == "1") // don't append build number for rev 0 - and also 1 in case first build goes wrong - { - labelProduct.Text = $"{_languageGeneral.Title} {versionInfo[0]}.{versionInfo[1]}.{versionInfo[2]}"; - linkLabelGitBuildHash.Hide(); - } - else - { - labelProduct.Text = $"{_languageGeneral.Title} {versionInfo[0]}.{versionInfo[1]}.{versionInfo[2]} NEXT, beta"; - linkLabelGitBuildHash.Left = labelProduct.Left + labelProduct.Width; - linkLabelGitBuildHash.Text = revisionNumber; - tooltip.SetToolTip(linkLabelGitBuildHash, GetGitHubHashLink()); - linkLabelGitBuildHash.Font = labelProduct.Font; - } - - string aboutText = _language.AboutText1.TrimEnd() + Environment.NewLine + - Environment.NewLine + - _languageGeneral.TranslatedBy.Trim(); - while (aboutText.Contains("\n ") || aboutText.Contains("\n\t")) - { - aboutText = aboutText.Replace("\n ", "\n"); - aboutText = aboutText.Replace("\n\t", "\n"); - } - richTextBoxAbout1.Text = aboutText; - - SetHeight(); - } - - private void SetHeight() - { - using (var g = CreateGraphics()) - { - double height = g.MeasureString(richTextBoxAbout1.Text, richTextBoxAbout1.Font).Height + 15; - richTextBoxAbout1.Height = (int)height; - Height = richTextBoxAbout1.Top + richTextBoxAbout1.Height + 90; - } - } - - private void OkButtonClick(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void About_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp(null); - e.SuppressKeyPress = true; - } - } - - private void RichTextBoxAbout1LinkClicked(object sender, LinkClickedEventArgs e) - { - UiUtil.OpenURL(e.LinkText); - } - - private void buttonDonate_Click(object sender, EventArgs e) - { - UiUtil.OpenURL("https://www.nikse.dk/Donate"); - } - - private void linkLabelGitBuildHash_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - UiUtil.OpenURL(GetGitHubHashLink()); - } - - private static string GetGitHubHashLink() - { - try - { - return "https://github.com/SubtitleEdit/subtitleedit/commit/" + Utilities.AssemblyDescription.Substring(0, 7); - } - catch - { - return "https://github.com/SubtitleEdit/subtitleedit"; - } - } - - private void About_Shown(object sender, EventArgs e) - { - SetHeight(); - } - } -} +using Nikse.SubtitleEdit.Core; +using System; +using System.Diagnostics; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Logic; + +namespace Nikse.SubtitleEdit.Forms +{ + partial class About : PositionAndSizeForm + { + private readonly LanguageStructure.About _language = Configuration.Settings.Language.About; + private readonly LanguageStructure.General _languageGeneral = Configuration.Settings.Language.General; + + public About() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + UiUtil.FixLargeFonts(this, okButton); + } + + public void Initialize() + { + Text = _language.Title + " - " + (IntPtr.Size * 8) + "-bit"; + okButton.Text = _languageGeneral.Ok; + string[] versionInfo = Utilities.AssemblyVersion.Split('.'); + string revisionNumber = "0"; + if (versionInfo.Length >= 4) + { + revisionNumber = versionInfo[3]; + } + + if (revisionNumber == "0" || revisionNumber == "1") // don't append build number for rev 0 - and also 1 in case first build goes wrong + { + labelProduct.Text = $"{_languageGeneral.Title} {versionInfo[0]}.{versionInfo[1]}.{versionInfo[2]}"; + linkLabelGitBuildHash.Hide(); + } + else + { + labelProduct.Text = $"{_languageGeneral.Title} {versionInfo[0]}.{versionInfo[1]}.{versionInfo[2]} NEXT, beta"; + linkLabelGitBuildHash.Left = labelProduct.Left + labelProduct.Width; + linkLabelGitBuildHash.Text = revisionNumber; + tooltip.SetToolTip(linkLabelGitBuildHash, GetGitHubHashLink()); + linkLabelGitBuildHash.Font = labelProduct.Font; + } + + string aboutText = _language.AboutText1.TrimEnd() + Environment.NewLine + + Environment.NewLine + + _languageGeneral.TranslatedBy.Trim(); + while (aboutText.Contains("\n ") || aboutText.Contains("\n\t")) + { + aboutText = aboutText.Replace("\n ", "\n"); + aboutText = aboutText.Replace("\n\t", "\n"); + } + richTextBoxAbout1.Text = aboutText; + + SetHeight(); + } + + private void SetHeight() + { + using (var g = CreateGraphics()) + { + double height = g.MeasureString(richTextBoxAbout1.Text, richTextBoxAbout1.Font).Height + 15; + richTextBoxAbout1.Height = (int)height; + Height = richTextBoxAbout1.Top + richTextBoxAbout1.Height + 90; + } + } + + private void OkButtonClick(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void About_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp(null); + e.SuppressKeyPress = true; + } + } + + private void RichTextBoxAbout1LinkClicked(object sender, LinkClickedEventArgs e) + { + UiUtil.OpenURL(e.LinkText); + } + + private void buttonDonate_Click(object sender, EventArgs e) + { + UiUtil.OpenURL("https://www.nikse.dk/Donate"); + } + + private void linkLabelGitBuildHash_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + UiUtil.OpenURL(GetGitHubHashLink()); + } + + private static string GetGitHubHashLink() + { + try + { + return "https://github.com/SubtitleEdit/subtitleedit/commit/" + Utilities.AssemblyDescription.Substring(0, 7); + } + catch + { + return "https://github.com/SubtitleEdit/subtitleedit"; + } + } + + private void About_Shown(object sender, EventArgs e) + { + SetHeight(); + } + } +} diff --git a/src/Forms/About.resx b/src/ui/Forms/About.resx similarity index 98% rename from src/Forms/About.resx rename to src/ui/Forms/About.resx index 20f7a2beb..f0de7e340 100644 --- a/src/Forms/About.resx +++ b/src/ui/Forms/About.resx @@ -1,195 +1,195 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAAK/INwWK6QAAAAlwSFlzAAAO - vAAADrwBlbxySQAAABl0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuNUmK/OAAAA72SURBVHhe7drr - j1XVGQZw/xWjBi0aEFAwoGKhBQsGtKgY6TjiSAQJxYiiAQMGlIuoCJgiImJAU8MUtUBEWhuC2uIHq0ZM - FK3VVFNrNWpSo3wwu/u3znnnrLPnzAUYak3YyZN9W3ut93ney1p7n3PKye3kdnI7ufW17d27t1izZk3C - 6tWr0/6BBx7ohvsfWJPQ6n7cq17vwv21fd5m7dq1aV/tL8ZgS9gTxxs3biy2bNlSHDhwoKibf/zbzp2/ - K26//fZi1qxZxdy5c4ubbrqpmDlzZnH9zOsTHCd01K7l5zNv6Ej7Gzoabe07yn3HzI60T9eur0Ob1L68 - 13FDo68M2kDNnjnFggULkn3smjFjRhLp8OHDxy/A/v37iyeffLJ4+umn0x6e+u1Txfbt25LKj23e3MCW - Ohw/Vt6rn2uX2sb9nuCZal/16+l59wNlG9eeeOKJZM/OnTuL5557Ltn58MMPF488simdv/nmm8cugs6E - k/B/993DxRdffFF8881/Er7++ut0/kPjyy+/Sraw6dsj3xXffvdtOkf80UdrYn7yySdHJ8Lbb7+diPP2 - K6+8kjpzrYpDh94qDr1VQ6v7/cWhtw7VoL+Afsv9WyWM3xta9QlsFwV4dHZ29k8EeaPw8D4oLtLg1Vdf - Lfbs2ZM6DOzetbuOXeneicDuPbvqY+0qdu3+fRNyW+CZZ59Je8+99PJLSZzXX3+j2LdvX+JBiDrNnjeN - dEJBx7fcckvKM9fyOvBDQN3Zvm1bsqcVtmyt1YrHt25NdYHNZgJCODZD7N37fM8ivPjii6mAfPDB31IF - 9ZAOY5pxDxyvWr2qWLlyZb+walVteoL8+L6yH1hz331lnyXss2Nt8/Z5fxDnK1bk460o7r33ngTnaoAI - wA2Xdeseai0ApYKgcPeQOoDs3XffXdyxcGGa/tra2orLL7+8uOyyyxKmTp2SzgPTrphW4oriyiuvbMJV - 06cXV101vXZc7hPKa9dcc03C9OlX1/ZXZ9fKY8jbVeFe9OmcfabGm0tbb7t9QRICD9ErSoiiNtRpNzY3 - qUyx8PzyZcuKO++8M82x5t5LL720OO+884pBZw4qzjjjjOKss85KOOeccxLOPffcJowYPiK17wsjR40s - Ro06P+GCCy44Zlx44YXF+PHjkyOsBawJpPBdd91Ven5dsbmcFUSOdKrTbmxUoo75c9OmTenYwuLmm+cW - 7e3tydsGQfjUU09NIEJg0KAzuwQ5++yfdIkCQ4cMTagKBMNGDCuGj6gJFfv+4PzzRyXk19h3ySWXJEeF - CDfeOKuYN29esWzZ8lTcV5QpIsrVuDr12kYA4aKRPc9HyCNP3eGlRxFCcvDZg5tIQpVcblwYWMWY0aNT - 3wMB5EUAe6VFe1t7Soc5c+YkPlIZ8DOz1anXNl53k+fthb2HKclQhIaUXuyJbNV7wjpIjh4zJiE39uKx - F5UYm4weKCD/i0mTE3mkhf7iRYtSBEiFRYsXJyEcWznWqdc2jd1APo6F/oSJE0tv17yekxe6I0YMbyI9 - amQtLBveHZPQIN2a8E/HjyuND4zvB1q3E/pTpk5NoY+DUF+79sHkTHykdErrMrK7LYxCJQ9SybmqykA5 - fvrppzV5ngBIRa7NmHFtmgEYEoSDYEOAi9J5GPzzCROTwAw/WkQfOVxnj5ck02jnjs5U+UVBCGCvOLYU - AEIA+S+UGB5FLwTgbeJ441JRY9UImzY9knJMJLnvmFEhgvwM76g7IP08V8OmdC2mZIjrce7+4sWLUl+t - BPAmqeq/8MK+RDRSOgTomNXRPQUQhr4EQF5t6OzckchrK1VMk0uXLEkimGe9QL322msJ8rEqAM/s3/+n - dP/w4XeLzz//d3q5cfzsszu7yG7d+nha2h48+Oe0mEHIM9YtHeXrcksBSls2bFhfrmVe6L8AjIxqGSmQ - CyANeN81DyPvOPJf0ZPvFkG8znjrCctQ/eln7NiLu1KAEMbQzreGTz/9Z/HZZ/9KwoiuCHXtnGuLiCJN - kPffO5yOtQkBJpcFMFJABHAChyxZsrRJAA7slwAGZvjpp52WBEAUOR7WkaIHUfRqhW90MkrFZaj51jNR - D3Iw1j3hbfkNomP8T8el+13FsTyHyZMnJa9rH5HCCV0ClPenTbsiCbBh/YYkQOeOHWVkHocADEHeLGCQ - CHH3cuIQYQ6/nDYtRQlSvOzZceMa4Tq+PCbAyhUris2bHy3ef/+91FbB6mrTAxRdK1UvNrPnzO66TgCC - +MJkzCRAmQJEHRABhKOwjrzuTQDPqSPxgiUqmgQo0VKAsrjlbXJEuNuzDSmzj2tmFPaFAOvLCEhFsJwJ - BkwAA1PehwqRoNi4j3BVAGAYDxnQsbbgWHgfjQC/aqvN7WxiR44JE3+WptMQwCwgBbzQDagAjhUiHTNW - KshHA+hUe0YwOMj2hrwG9CXA8uXLij/8cV8x9+Y5ifSkMtyrQkyZMrUWAWWdEHVJgIFMAUWQ11VYU8xH - H32UKre9qDA1SRHzNKHiDbJKHJBqJYCxq+SFOSJe030B1uekyZObRLAE1h8BbuiYVazfcIIEYJBOGC4d - DhzYnyp9iGEuN6c7ZzBPRD9VYikFyrezSAHPaM8OqzVk2eKbhBlFxLmHsEjLYQq0DK7VgAGKANW2KkCI - wEDtdO47wsaNv0mCmNMZShSCfPzxP1K9iL4aQtRrQF0AX6C0F0X6YLhoUumtDcwoFk49CQD682GlkQIW - QjuOXwDkIZbBoMgZUJhrq3MwmOjwWs1oC6EPP/x7MojhDRFqAnSlQLmwqUZAfNDw+Y03rQb7EkC0Wek1 - IqCfAsSAvQmAeBBwHJXfOQOEHwMYGUKoF1JBVOg/no8U6E8NsLjxQZQAUQOq5EF/x1wEXYSqAAwIAZDV - GSCRrwHyaTAEMZjlqhC2dlAYc2IMzmtAb7MAmxhNxN4EuFoKNEVAswB4EaibAELZDY16EgAxZCxueDqi - oCpAgKH6qhXLA0kM/VUjoD8C8Cyb7HMB9JEfd0+BfgrQ3n5dWkNr5AHeayWAvJbTCh+SVRGqQhjMM1JA - BOgjEAL0Zx0A+fcDz7KRreycOqX2dToJ0CIFtCVCjwL49ue1ti8BzPGMRUhHvZHXXmSZwnyDUxuCvH6P - VoAAb7PTrGCmMEZTBJwoAXzS4kUeNc15GzNgbwIg+MYbf02pw8AgDyGAT/HI90cA3p83/9cluRfSj576 - lRa5AASpLdaOUQCvsrkAvgBHBCxduiSFvwiIOV6H7uUieE4f6gXk3g8w1hSHhClQf+rExAkTmkgD4lEH - fOcj6jvvvJPI5TVAG+8CIsC4iLYSgDB16rUtBLjttnoRnD8/vYAY3JegECA6FgVAZWHIKJ6hvrdA5+4J - f4Prx/P2hCW00GcgMb/66sv0s7aVpSjL1wLaWlcQyviKqu8B7EAmBAgRXNO3tGOb/pAPAcIxdeq1LQnQ - 1rsAPMtDjDA3u8eLooJxVBURsfdNUL+51xmIDGGQNTuY33kU4mc56aUfq0JtX375pdTWsfue0U+Ev2Vw - RACCnBN9sRknQrrHftFTp17b2mbUBKCSxvNLb0YKhABWgkJx4sQJxaiRjZ+xCMMIZKkPDNHW8zlcE2k8 - nMNrs72FTnyfrCK/75j4ueeNaWzC8L46RTT1QBpEBIigOu3GxtsIhADCORfg7MGDm5bCQR7GjGn+dSf3 - eFUAIEJvmDyp+6tuFUE83ggdEwRRUcLDiqr04vGoA1JKdNRpNzavnE0ClEpde21NgKFDh6Tf++zjx5AT - IUCQOhp4Tp8iQGTwLuLqiVmiKoB9t/y3UaY3AaSASBgxbFgSIE8ByAXoS4Qq8UArgr0BaXvPSiuvzUL+ - yJEjxffff59mFmRdxwn5btNfbIqYBrfeWq8B8+YX6kISYEhDgDwNql+EexKhKkCgLwEQzCHHQahLT6Q5 - LUJf0RT6yPsuoQgKd/c41F5E1Ck3b/LG/C5MCGBvSmMY0iFA/MzdHxF6i4JcgFakg2xOmD1e2BRAhERr - LNyEPnK8LvwVwNr0vLYrqjm5x/8OamxVFgKAgRgj7EMAvxA3C9BzKlTJB+EgnZMNARwjq5rL6chbtplW - LcV5lbdjShT2vjsgJwJ4Xqir/tYAuFgXdJv68k1n5kvV3wN+5lp4x8JkjB87eH7I0HMT4qfw+Al8dIsi - mJMOsuHNmC7VHQR5EVnnvMXonCznIMrDXqsR4en4BAcKnuvE8Iy8Jxwu+mpZ+PLNvOmh3IiICMaPvXhs - Ih3eD2/nXq56NycsdCO6qt7kLST9kMEORHkRWZ4VzvbOXXcfUUCMOBwoKmK1yJk4OO4x7/PNABorLAxl - pPyJuoAMwsjz+LiKd+OPUaZTfYSH5SoP60//rTyKoKmLF3Pwsus8yz7t4/c+RL1E6VOoE5StiBsLXO/T - 8/nGMGSFY6hnoJghEIxfd5Buu669mD17TpdnPSOKPKcohXeDbOQpYkEu8pYI4enwsmjwLLuCtFxGjHNy - GBfpCHvt9FOn1v/NQFFZH3poXfplxTrc9XuW3ZOmx0iTeC9gmPvCUFjmXo08VZnBsWsE0IaRiEYIE414 - 0gPRIEbcHOFl94H3gT1E77Ha97UxXifhUUo+v/f5plzjEXvXeOrgXw4mIlW4F6jma3gV4fCscVuFcyvi - HATE0h8R2V6ncXybDoWVARmxbfv2ZHx4NoeQzcNWuyrB8GhOMBAezJHfs89D3fMQAhC2bvbAbUIXCQYQ - wcC8hBQPIgkKknZCLvdmHsII8GZ4rupNAhvHGARS2PShL31Ki4i4HPrWx4B5vbrJIQY8WBoWBvuTIULh - SYbnVTfaQVxzHyJHc6/qQ19RMI0XZIkbYvOyEA/h3fcc9Lq4GYjNwAxUE/JqL/wcK5j2EZLRznEUpdyr - 4dFWXgXXRVSkjucJFoKKLNe1OeHkY5PrvMOQQOQk74YAhCGIJbRr2iluVfI5YUTcj5SJSImoidTQj2fV - GzNI3bT//SY1CKJOMAQJ5IU2QxkeEcB4xBgfRTAIBeLP2eF9+1gRKqzGqg/9/7shGGR5PSIicj68qZ1I - QNSM8aMg159NVAjlyHXFS+ECRH80njyeDUFkT9i0dHI7uZ2g7ZRT/gtoD4EpsituXQAAAABJRU5ErkJg - gg== - - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAAK/INwWK6QAAAAlwSFlzAAAO + vAAADrwBlbxySQAAABl0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuNUmK/OAAAA72SURBVHhe7drr + j1XVGQZw/xWjBi0aEFAwoGKhBQsGtKgY6TjiSAQJxYiiAQMGlIuoCJgiImJAU8MUtUBEWhuC2uIHq0ZM + FK3VVFNrNWpSo3wwu/u3znnnrLPnzAUYak3YyZN9W3ut93ney1p7n3PKye3kdnI7ufW17d27t1izZk3C + 6tWr0/6BBx7ohvsfWJPQ6n7cq17vwv21fd5m7dq1aV/tL8ZgS9gTxxs3biy2bNlSHDhwoKibf/zbzp2/ + K26//fZi1qxZxdy5c4ubbrqpmDlzZnH9zOsTHCd01K7l5zNv6Ej7Gzoabe07yn3HzI60T9eur0Ob1L68 + 13FDo68M2kDNnjnFggULkn3smjFjRhLp8OHDxy/A/v37iyeffLJ4+umn0x6e+u1Txfbt25LKj23e3MCW + Ohw/Vt6rn2uX2sb9nuCZal/16+l59wNlG9eeeOKJZM/OnTuL5557Ltn58MMPF488simdv/nmm8cugs6E + k/B/993DxRdffFF8881/Er7++ut0/kPjyy+/Sraw6dsj3xXffvdtOkf80UdrYn7yySdHJ8Lbb7+diPP2 + K6+8kjpzrYpDh94qDr1VQ6v7/cWhtw7VoL+Afsv9WyWM3xta9QlsFwV4dHZ29k8EeaPw8D4oLtLg1Vdf + Lfbs2ZM6DOzetbuOXeneicDuPbvqY+0qdu3+fRNyW+CZZ59Je8+99PJLSZzXX3+j2LdvX+JBiDrNnjeN + dEJBx7fcckvKM9fyOvBDQN3Zvm1bsqcVtmyt1YrHt25NdYHNZgJCODZD7N37fM8ivPjii6mAfPDB31IF + 9ZAOY5pxDxyvWr2qWLlyZb+walVteoL8+L6yH1hz331lnyXss2Nt8/Z5fxDnK1bk460o7r33ngTnaoAI + wA2Xdeseai0ApYKgcPeQOoDs3XffXdyxcGGa/tra2orLL7+8uOyyyxKmTp2SzgPTrphW4oriyiuvbMJV + 06cXV101vXZc7hPKa9dcc03C9OlX1/ZXZ9fKY8jbVeFe9OmcfabGm0tbb7t9QRICD9ErSoiiNtRpNzY3 + qUyx8PzyZcuKO++8M82x5t5LL720OO+884pBZw4qzjjjjOKss85KOOeccxLOPffcJowYPiK17wsjR40s + Ro06P+GCCy44Zlx44YXF+PHjkyOsBawJpPBdd91Ven5dsbmcFUSOdKrTbmxUoo75c9OmTenYwuLmm+cW + 7e3tydsGQfjUU09NIEJg0KAzuwQ5++yfdIkCQ4cMTagKBMNGDCuGj6gJFfv+4PzzRyXk19h3ySWXJEeF + CDfeOKuYN29esWzZ8lTcV5QpIsrVuDr12kYA4aKRPc9HyCNP3eGlRxFCcvDZg5tIQpVcblwYWMWY0aNT + 3wMB5EUAe6VFe1t7Soc5c+YkPlIZ8DOz1anXNl53k+fthb2HKclQhIaUXuyJbNV7wjpIjh4zJiE39uKx + F5UYm4weKCD/i0mTE3mkhf7iRYtSBEiFRYsXJyEcWznWqdc2jd1APo6F/oSJE0tv17yekxe6I0YMbyI9 + amQtLBveHZPQIN2a8E/HjyuND4zvB1q3E/pTpk5NoY+DUF+79sHkTHykdErrMrK7LYxCJQ9SybmqykA5 + fvrppzV5ngBIRa7NmHFtmgEYEoSDYEOAi9J5GPzzCROTwAw/WkQfOVxnj5ck02jnjs5U+UVBCGCvOLYU + AEIA+S+UGB5FLwTgbeJ441JRY9UImzY9knJMJLnvmFEhgvwM76g7IP08V8OmdC2mZIjrce7+4sWLUl+t + BPAmqeq/8MK+RDRSOgTomNXRPQUQhr4EQF5t6OzckchrK1VMk0uXLEkimGe9QL322msJ8rEqAM/s3/+n + dP/w4XeLzz//d3q5cfzsszu7yG7d+nha2h48+Oe0mEHIM9YtHeXrcksBSls2bFhfrmVe6L8AjIxqGSmQ + CyANeN81DyPvOPJf0ZPvFkG8znjrCctQ/eln7NiLu1KAEMbQzreGTz/9Z/HZZ/9KwoiuCHXtnGuLiCJN + kPffO5yOtQkBJpcFMFJABHAChyxZsrRJAA7slwAGZvjpp52WBEAUOR7WkaIHUfRqhW90MkrFZaj51jNR + D3Iw1j3hbfkNomP8T8el+13FsTyHyZMnJa9rH5HCCV0ClPenTbsiCbBh/YYkQOeOHWVkHocADEHeLGCQ + CHH3cuIQYQ6/nDYtRQlSvOzZceMa4Tq+PCbAyhUris2bHy3ef/+91FbB6mrTAxRdK1UvNrPnzO66TgCC + +MJkzCRAmQJEHRABhKOwjrzuTQDPqSPxgiUqmgQo0VKAsrjlbXJEuNuzDSmzj2tmFPaFAOvLCEhFsJwJ + BkwAA1PehwqRoNi4j3BVAGAYDxnQsbbgWHgfjQC/aqvN7WxiR44JE3+WptMQwCwgBbzQDagAjhUiHTNW + KshHA+hUe0YwOMj2hrwG9CXA8uXLij/8cV8x9+Y5ifSkMtyrQkyZMrUWAWWdEHVJgIFMAUWQ11VYU8xH + H32UKre9qDA1SRHzNKHiDbJKHJBqJYCxq+SFOSJe030B1uekyZObRLAE1h8BbuiYVazfcIIEYJBOGC4d + DhzYnyp9iGEuN6c7ZzBPRD9VYikFyrezSAHPaM8OqzVk2eKbhBlFxLmHsEjLYQq0DK7VgAGKANW2KkCI + wEDtdO47wsaNv0mCmNMZShSCfPzxP1K9iL4aQtRrQF0AX6C0F0X6YLhoUumtDcwoFk49CQD682GlkQIW + QjuOXwDkIZbBoMgZUJhrq3MwmOjwWs1oC6EPP/x7MojhDRFqAnSlQLmwqUZAfNDw+Y03rQb7EkC0Wek1 + IqCfAsSAvQmAeBBwHJXfOQOEHwMYGUKoF1JBVOg/no8U6E8NsLjxQZQAUQOq5EF/x1wEXYSqAAwIAZDV + GSCRrwHyaTAEMZjlqhC2dlAYc2IMzmtAb7MAmxhNxN4EuFoKNEVAswB4EaibAELZDY16EgAxZCxueDqi + oCpAgKH6qhXLA0kM/VUjoD8C8Cyb7HMB9JEfd0+BfgrQ3n5dWkNr5AHeayWAvJbTCh+SVRGqQhjMM1JA + BOgjEAL0Zx0A+fcDz7KRreycOqX2dToJ0CIFtCVCjwL49ue1ti8BzPGMRUhHvZHXXmSZwnyDUxuCvH6P + VoAAb7PTrGCmMEZTBJwoAXzS4kUeNc15GzNgbwIg+MYbf02pw8AgDyGAT/HI90cA3p83/9cluRfSj576 + lRa5AASpLdaOUQCvsrkAvgBHBCxduiSFvwiIOV6H7uUieE4f6gXk3g8w1hSHhClQf+rExAkTmkgD4lEH + fOcj6jvvvJPI5TVAG+8CIsC4iLYSgDB16rUtBLjttnoRnD8/vYAY3JegECA6FgVAZWHIKJ6hvrdA5+4J + f4Prx/P2hCW00GcgMb/66sv0s7aVpSjL1wLaWlcQyviKqu8B7EAmBAgRXNO3tGOb/pAPAcIxdeq1LQnQ + 1rsAPMtDjDA3u8eLooJxVBURsfdNUL+51xmIDGGQNTuY33kU4mc56aUfq0JtX375pdTWsfue0U+Ev2Vw + RACCnBN9sRknQrrHftFTp17b2mbUBKCSxvNLb0YKhABWgkJx4sQJxaiRjZ+xCMMIZKkPDNHW8zlcE2k8 + nMNrs72FTnyfrCK/75j4ueeNaWzC8L46RTT1QBpEBIigOu3GxtsIhADCORfg7MGDm5bCQR7GjGn+dSf3 + eFUAIEJvmDyp+6tuFUE83ggdEwRRUcLDiqr04vGoA1JKdNRpNzavnE0ClEpde21NgKFDh6Tf++zjx5AT + IUCQOhp4Tp8iQGTwLuLqiVmiKoB9t/y3UaY3AaSASBgxbFgSIE8ByAXoS4Qq8UArgr0BaXvPSiuvzUL+ + yJEjxffff59mFmRdxwn5btNfbIqYBrfeWq8B8+YX6kISYEhDgDwNql+EexKhKkCgLwEQzCHHQahLT6Q5 + LUJf0RT6yPsuoQgKd/c41F5E1Ck3b/LG/C5MCGBvSmMY0iFA/MzdHxF6i4JcgFakg2xOmD1e2BRAhERr + LNyEPnK8LvwVwNr0vLYrqjm5x/8OamxVFgKAgRgj7EMAvxA3C9BzKlTJB+EgnZMNARwjq5rL6chbtplW + LcV5lbdjShT2vjsgJwJ4Xqir/tYAuFgXdJv68k1n5kvV3wN+5lp4x8JkjB87eH7I0HMT4qfw+Al8dIsi + mJMOsuHNmC7VHQR5EVnnvMXonCznIMrDXqsR4en4BAcKnuvE8Iy8Jxwu+mpZ+PLNvOmh3IiICMaPvXhs + Ih3eD2/nXq56NycsdCO6qt7kLST9kMEORHkRWZ4VzvbOXXcfUUCMOBwoKmK1yJk4OO4x7/PNABorLAxl + pPyJuoAMwsjz+LiKd+OPUaZTfYSH5SoP60//rTyKoKmLF3Pwsus8yz7t4/c+RL1E6VOoE5StiBsLXO/T + 8/nGMGSFY6hnoJghEIxfd5Buu669mD17TpdnPSOKPKcohXeDbOQpYkEu8pYI4enwsmjwLLuCtFxGjHNy + GBfpCHvt9FOn1v/NQFFZH3poXfplxTrc9XuW3ZOmx0iTeC9gmPvCUFjmXo08VZnBsWsE0IaRiEYIE414 + 0gPRIEbcHOFl94H3gT1E77Ha97UxXifhUUo+v/f5plzjEXvXeOrgXw4mIlW4F6jma3gV4fCscVuFcyvi + HATE0h8R2V6ncXybDoWVARmxbfv2ZHx4NoeQzcNWuyrB8GhOMBAezJHfs89D3fMQAhC2bvbAbUIXCQYQ + wcC8hBQPIgkKknZCLvdmHsII8GZ4rupNAhvHGARS2PShL31Ki4i4HPrWx4B5vbrJIQY8WBoWBvuTIULh + SYbnVTfaQVxzHyJHc6/qQ19RMI0XZIkbYvOyEA/h3fcc9Lq4GYjNwAxUE/JqL/wcK5j2EZLRznEUpdyr + 4dFWXgXXRVSkjucJFoKKLNe1OeHkY5PrvMOQQOQk74YAhCGIJbRr2iluVfI5YUTcj5SJSImoidTQj2fV + GzNI3bT//SY1CKJOMAQJ5IU2QxkeEcB4xBgfRTAIBeLP2eF9+1gRKqzGqg/9/7shGGR5PSIicj68qZ1I + QNSM8aMg159NVAjlyHXFS+ECRH80njyeDUFkT9i0dHI7uZ2g7ZRT/gtoD4EpsituXQAAAABJRU5ErkJg + gg== + + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/AddToNames.Designer.cs b/src/ui/Forms/AddToNames.Designer.cs similarity index 97% rename from src/Forms/AddToNames.Designer.cs rename to src/ui/Forms/AddToNames.Designer.cs index ffa58ce3c..b6c2364b3 100644 --- a/src/Forms/AddToNames.Designer.cs +++ b/src/ui/Forms/AddToNames.Designer.cs @@ -1,123 +1,123 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class AddToNameList - { - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.textBoxAddName = new System.Windows.Forms.TextBox(); - this.labelDescription = new System.Windows.Forms.Label(); - this.comboBoxDictionaries = new System.Windows.Forms.ComboBox(); - this.labelLanguage = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(100, 127); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 2; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(181, 127); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 3; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // textBoxAddName - // - this.textBoxAddName.Location = new System.Drawing.Point(15, 26); - this.textBoxAddName.Name = "textBoxAddName"; - this.textBoxAddName.Size = new System.Drawing.Size(221, 21); - this.textBoxAddName.TabIndex = 0; - // - // labelDescription - // - this.labelDescription.AutoSize = true; - this.labelDescription.Location = new System.Drawing.Point(12, 8); - this.labelDescription.Name = "labelDescription"; - this.labelDescription.Size = new System.Drawing.Size(196, 13); - this.labelDescription.TabIndex = 14; - this.labelDescription.Text = "Add to names/noise list (case sensitive)"; - // - // comboBoxDictionaries - // - this.comboBoxDictionaries.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxDictionaries.FormattingEnabled = true; - this.comboBoxDictionaries.Location = new System.Drawing.Point(15, 80); - this.comboBoxDictionaries.Name = "comboBoxDictionaries"; - this.comboBoxDictionaries.Size = new System.Drawing.Size(221, 21); - this.comboBoxDictionaries.TabIndex = 1; - // - // labelLanguage - // - this.labelLanguage.AutoSize = true; - this.labelLanguage.Location = new System.Drawing.Point(15, 64); - this.labelLanguage.Name = "labelLanguage"; - this.labelLanguage.Size = new System.Drawing.Size(54, 13); - this.labelLanguage.TabIndex = 18; - this.labelLanguage.Text = "Language"; - // - // AddToNameList - // - this.AcceptButton = this.buttonOK; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(268, 162); - this.Controls.Add(this.comboBoxDictionaries); - this.Controls.Add(this.labelLanguage); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.textBoxAddName); - this.Controls.Add(this.labelDescription); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "AddToNameList"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Add to Names List"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.TextBox textBoxAddName; - private System.Windows.Forms.Label labelDescription; - private System.Windows.Forms.ComboBox comboBoxDictionaries; - private System.Windows.Forms.Label labelLanguage; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class AddToNameList + { + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.textBoxAddName = new System.Windows.Forms.TextBox(); + this.labelDescription = new System.Windows.Forms.Label(); + this.comboBoxDictionaries = new System.Windows.Forms.ComboBox(); + this.labelLanguage = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(100, 127); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 2; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(181, 127); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // textBoxAddName + // + this.textBoxAddName.Location = new System.Drawing.Point(15, 26); + this.textBoxAddName.Name = "textBoxAddName"; + this.textBoxAddName.Size = new System.Drawing.Size(221, 21); + this.textBoxAddName.TabIndex = 0; + // + // labelDescription + // + this.labelDescription.AutoSize = true; + this.labelDescription.Location = new System.Drawing.Point(12, 8); + this.labelDescription.Name = "labelDescription"; + this.labelDescription.Size = new System.Drawing.Size(196, 13); + this.labelDescription.TabIndex = 14; + this.labelDescription.Text = "Add to names/noise list (case sensitive)"; + // + // comboBoxDictionaries + // + this.comboBoxDictionaries.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxDictionaries.FormattingEnabled = true; + this.comboBoxDictionaries.Location = new System.Drawing.Point(15, 80); + this.comboBoxDictionaries.Name = "comboBoxDictionaries"; + this.comboBoxDictionaries.Size = new System.Drawing.Size(221, 21); + this.comboBoxDictionaries.TabIndex = 1; + // + // labelLanguage + // + this.labelLanguage.AutoSize = true; + this.labelLanguage.Location = new System.Drawing.Point(15, 64); + this.labelLanguage.Name = "labelLanguage"; + this.labelLanguage.Size = new System.Drawing.Size(54, 13); + this.labelLanguage.TabIndex = 18; + this.labelLanguage.Text = "Language"; + // + // AddToNameList + // + this.AcceptButton = this.buttonOK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(268, 162); + this.Controls.Add(this.comboBoxDictionaries); + this.Controls.Add(this.labelLanguage); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBoxAddName); + this.Controls.Add(this.labelDescription); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "AddToNameList"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Add to Names List"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.TextBox textBoxAddName; + private System.Windows.Forms.Label labelDescription; + private System.Windows.Forms.ComboBox comboBoxDictionaries; + private System.Windows.Forms.Label labelLanguage; + } } \ No newline at end of file diff --git a/src/Forms/AddToNames.cs b/src/ui/Forms/AddToNames.cs similarity index 97% rename from src/Forms/AddToNames.cs rename to src/ui/Forms/AddToNames.cs index f7af4faae..fafff3f67 100644 --- a/src/Forms/AddToNames.cs +++ b/src/ui/Forms/AddToNames.cs @@ -1,116 +1,116 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Dictionaries; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class AddToNameList : PositionAndSizeForm - { - private Subtitle _subtitle; - - public AddToNameList() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Text = Configuration.Settings.Language.AddToNames.Title; - labelDescription.Text = Configuration.Settings.Language.AddToNames.Description; - labelLanguage.Text = Configuration.Settings.Language.SpellCheck.Language; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - FixLargeFonts(); - } - - public string NewName { get; private set; } - - private void FixLargeFonts() - { - if (labelDescription.Left + labelDescription.Width + 5 > Width) - { - Width = labelDescription.Left + labelDescription.Width + 5; - } - - UiUtil.FixLargeFonts(this, buttonOK); - } - - public void Initialize(Subtitle subtitle, string text) - { - _subtitle = subtitle; - - if (!string.IsNullOrEmpty(text)) - { - textBoxAddName.Text = text.Trim().TrimEnd('.', '!', '?'); - if (textBoxAddName.Text.Length > 1) - { - textBoxAddName.Text = char.ToUpper(textBoxAddName.Text[0]) + textBoxAddName.Text.Substring(1); - } - } - - comboBoxDictionaries.Items.Clear(); - string languageName = LanguageAutoDetect.AutoDetectLanguageName(Configuration.Settings.General.SpellCheckLanguage, _subtitle); - int selIndex = -1; - var dictionaries = Utilities.GetDictionaryLanguagesCultureNeutral(); - for (var index = 0; index < dictionaries.Count; index++) - { - string name = dictionaries[index]; - comboBoxDictionaries.Items.Add(name); - if (selIndex == -1 && languageName.Length > 1 && name.Contains("[" + languageName.Substring(0, 2) + "]")) - { - selIndex = index; - } - } - comboBoxDictionaries.SelectedIndex = selIndex >= 0 ? selIndex : 0; - } - - internal void Initialize(Subtitle subtitle, string hunspellName, string text) - { - _subtitle = subtitle; - - if (!string.IsNullOrEmpty(text)) - { - textBoxAddName.Text = text.Trim().TrimEnd('.', '!', '?'); - if (textBoxAddName.Text.Length > 1) - { - textBoxAddName.Text = char.ToUpper(textBoxAddName.Text[0]) + textBoxAddName.Text.Substring(1); - } - } - - comboBoxDictionaries.Items.Clear(); - foreach (string name in Utilities.GetDictionaryLanguages()) - { - comboBoxDictionaries.Items.Add(name); - if (hunspellName != null && name.Equals(hunspellName, StringComparison.OrdinalIgnoreCase)) - { - comboBoxDictionaries.SelectedIndex = comboBoxDictionaries.Items.Count - 1; - } - } - } - - private void ButtonOkClick(object sender, EventArgs e) - { - if (string.IsNullOrWhiteSpace(textBoxAddName.Text) || comboBoxDictionaries.SelectedIndex < 0) - { - return; - } - - NewName = textBoxAddName.Text.RemoveControlCharacters().Trim(); - string languageName; - try - { - languageName = comboBoxDictionaries.Items[comboBoxDictionaries.SelectedIndex].ToString(); - languageName = languageName.Substring(languageName.LastIndexOf("[", StringComparison.Ordinal)).TrimStart('[').TrimEnd(']'); - } - catch - { - languageName = "en"; - } - - var nameList = new NameList(Configuration.DictionariesDirectory, languageName, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); - DialogResult = nameList.Add(textBoxAddName.Text) ? DialogResult.OK : DialogResult.Cancel; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Dictionaries; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class AddToNameList : PositionAndSizeForm + { + private Subtitle _subtitle; + + public AddToNameList() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Text = Configuration.Settings.Language.AddToNames.Title; + labelDescription.Text = Configuration.Settings.Language.AddToNames.Description; + labelLanguage.Text = Configuration.Settings.Language.SpellCheck.Language; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + FixLargeFonts(); + } + + public string NewName { get; private set; } + + private void FixLargeFonts() + { + if (labelDescription.Left + labelDescription.Width + 5 > Width) + { + Width = labelDescription.Left + labelDescription.Width + 5; + } + + UiUtil.FixLargeFonts(this, buttonOK); + } + + public void Initialize(Subtitle subtitle, string text) + { + _subtitle = subtitle; + + if (!string.IsNullOrEmpty(text)) + { + textBoxAddName.Text = text.Trim().TrimEnd('.', '!', '?'); + if (textBoxAddName.Text.Length > 1) + { + textBoxAddName.Text = char.ToUpper(textBoxAddName.Text[0]) + textBoxAddName.Text.Substring(1); + } + } + + comboBoxDictionaries.Items.Clear(); + string languageName = LanguageAutoDetect.AutoDetectLanguageName(Configuration.Settings.General.SpellCheckLanguage, _subtitle); + int selIndex = -1; + var dictionaries = Utilities.GetDictionaryLanguagesCultureNeutral(); + for (var index = 0; index < dictionaries.Count; index++) + { + string name = dictionaries[index]; + comboBoxDictionaries.Items.Add(name); + if (selIndex == -1 && languageName.Length > 1 && name.Contains("[" + languageName.Substring(0, 2) + "]")) + { + selIndex = index; + } + } + comboBoxDictionaries.SelectedIndex = selIndex >= 0 ? selIndex : 0; + } + + internal void Initialize(Subtitle subtitle, string hunspellName, string text) + { + _subtitle = subtitle; + + if (!string.IsNullOrEmpty(text)) + { + textBoxAddName.Text = text.Trim().TrimEnd('.', '!', '?'); + if (textBoxAddName.Text.Length > 1) + { + textBoxAddName.Text = char.ToUpper(textBoxAddName.Text[0]) + textBoxAddName.Text.Substring(1); + } + } + + comboBoxDictionaries.Items.Clear(); + foreach (string name in Utilities.GetDictionaryLanguages()) + { + comboBoxDictionaries.Items.Add(name); + if (hunspellName != null && name.Equals(hunspellName, StringComparison.OrdinalIgnoreCase)) + { + comboBoxDictionaries.SelectedIndex = comboBoxDictionaries.Items.Count - 1; + } + } + } + + private void ButtonOkClick(object sender, EventArgs e) + { + if (string.IsNullOrWhiteSpace(textBoxAddName.Text) || comboBoxDictionaries.SelectedIndex < 0) + { + return; + } + + NewName = textBoxAddName.Text.RemoveControlCharacters().Trim(); + string languageName; + try + { + languageName = comboBoxDictionaries.Items[comboBoxDictionaries.SelectedIndex].ToString(); + languageName = languageName.Substring(languageName.LastIndexOf("[", StringComparison.Ordinal)).TrimStart('[').TrimEnd(']'); + } + catch + { + languageName = "en"; + } + + var nameList = new NameList(Configuration.DictionariesDirectory, languageName, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); + DialogResult = nameList.Add(textBoxAddName.Text) ? DialogResult.OK : DialogResult.Cancel; + } + + } +} diff --git a/src/Forms/AlignmentPickerJapanese.resx b/src/ui/Forms/AddToNames.resx similarity index 100% rename from src/Forms/AlignmentPickerJapanese.resx rename to src/ui/Forms/AddToNames.resx diff --git a/src/Forms/AddToUserDic.Designer.cs b/src/ui/Forms/AddToUserDic.Designer.cs similarity index 97% rename from src/Forms/AddToUserDic.Designer.cs rename to src/ui/Forms/AddToUserDic.Designer.cs index ecc77e652..83cc4a51f 100644 --- a/src/Forms/AddToUserDic.Designer.cs +++ b/src/ui/Forms/AddToUserDic.Designer.cs @@ -1,133 +1,133 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class AddToUserDic - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.comboBoxDictionaries = new System.Windows.Forms.ComboBox(); - this.labelLanguage = new System.Windows.Forms.Label(); - this.textBoxAddName = new System.Windows.Forms.TextBox(); - this.labelDescription = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(80, 127); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 4; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(161, 127); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // comboBoxDictionaries - // - this.comboBoxDictionaries.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxDictionaries.FormattingEnabled = true; - this.comboBoxDictionaries.Location = new System.Drawing.Point(15, 90); - this.comboBoxDictionaries.Name = "comboBoxDictionaries"; - this.comboBoxDictionaries.Size = new System.Drawing.Size(221, 21); - this.comboBoxDictionaries.TabIndex = 20; - // - // labelLanguage - // - this.labelLanguage.AutoSize = true; - this.labelLanguage.Location = new System.Drawing.Point(12, 74); - this.labelLanguage.Name = "labelLanguage"; - this.labelLanguage.Size = new System.Drawing.Size(55, 13); - this.labelLanguage.TabIndex = 22; - this.labelLanguage.Text = "Language"; - // - // textBoxAddName - // - this.textBoxAddName.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBoxAddName.Location = new System.Drawing.Point(15, 36); - this.textBoxAddName.Name = "textBoxAddName"; - this.textBoxAddName.Size = new System.Drawing.Size(221, 21); - this.textBoxAddName.TabIndex = 19; - // - // labelDescription - // - this.labelDescription.AutoSize = true; - this.labelDescription.Location = new System.Drawing.Point(12, 18); - this.labelDescription.Name = "labelDescription"; - this.labelDescription.Size = new System.Drawing.Size(109, 13); - this.labelDescription.TabIndex = 21; - this.labelDescription.Text = "Add to user dictionary"; - // - // AddToUserDic - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(248, 160); - this.Controls.Add(this.comboBoxDictionaries); - this.Controls.Add(this.labelLanguage); - this.Controls.Add(this.textBoxAddName); - this.Controls.Add(this.labelDescription); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "AddToUserDic"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "AddToUserDic"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.AddToUserDic_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.ComboBox comboBoxDictionaries; - private System.Windows.Forms.Label labelLanguage; - private System.Windows.Forms.TextBox textBoxAddName; - private System.Windows.Forms.Label labelDescription; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class AddToUserDic + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.comboBoxDictionaries = new System.Windows.Forms.ComboBox(); + this.labelLanguage = new System.Windows.Forms.Label(); + this.textBoxAddName = new System.Windows.Forms.TextBox(); + this.labelDescription = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(80, 127); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 4; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(161, 127); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // comboBoxDictionaries + // + this.comboBoxDictionaries.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxDictionaries.FormattingEnabled = true; + this.comboBoxDictionaries.Location = new System.Drawing.Point(15, 90); + this.comboBoxDictionaries.Name = "comboBoxDictionaries"; + this.comboBoxDictionaries.Size = new System.Drawing.Size(221, 21); + this.comboBoxDictionaries.TabIndex = 20; + // + // labelLanguage + // + this.labelLanguage.AutoSize = true; + this.labelLanguage.Location = new System.Drawing.Point(12, 74); + this.labelLanguage.Name = "labelLanguage"; + this.labelLanguage.Size = new System.Drawing.Size(55, 13); + this.labelLanguage.TabIndex = 22; + this.labelLanguage.Text = "Language"; + // + // textBoxAddName + // + this.textBoxAddName.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textBoxAddName.Location = new System.Drawing.Point(15, 36); + this.textBoxAddName.Name = "textBoxAddName"; + this.textBoxAddName.Size = new System.Drawing.Size(221, 21); + this.textBoxAddName.TabIndex = 19; + // + // labelDescription + // + this.labelDescription.AutoSize = true; + this.labelDescription.Location = new System.Drawing.Point(12, 18); + this.labelDescription.Name = "labelDescription"; + this.labelDescription.Size = new System.Drawing.Size(109, 13); + this.labelDescription.TabIndex = 21; + this.labelDescription.Text = "Add to user dictionary"; + // + // AddToUserDic + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(248, 160); + this.Controls.Add(this.comboBoxDictionaries); + this.Controls.Add(this.labelLanguage); + this.Controls.Add(this.textBoxAddName); + this.Controls.Add(this.labelDescription); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "AddToUserDic"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "AddToUserDic"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.AddToUserDic_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.ComboBox comboBoxDictionaries; + private System.Windows.Forms.Label labelLanguage; + private System.Windows.Forms.TextBox textBoxAddName; + private System.Windows.Forms.Label labelDescription; + } } \ No newline at end of file diff --git a/src/Forms/AddToUserDic.cs b/src/ui/Forms/AddToUserDic.cs similarity index 97% rename from src/Forms/AddToUserDic.cs rename to src/ui/Forms/AddToUserDic.cs index 46ac55f86..5d3a19dd0 100644 --- a/src/Forms/AddToUserDic.cs +++ b/src/ui/Forms/AddToUserDic.cs @@ -1,90 +1,90 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class AddToUserDic : Form - { - public AddToUserDic() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Text = Configuration.Settings.Language.AddToUserDictionary.Title; - labelDescription.Text = Configuration.Settings.Language.AddToUserDictionary.Description; - labelLanguage.Text = Configuration.Settings.General.Language; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void AddToUserDic_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void buttonOK_Click(object sender, EventArgs e) - { - NewWord = textBoxAddName.Text.RemoveControlCharacters().Trim().ToLowerInvariant(); - if (NewWord.Length == 0) - { - DialogResult = DialogResult.Cancel; - return; - } - - string language = comboBoxDictionaries.Text; - if (language.IndexOf('[') >= 0) - { - language = language.Substring(language.IndexOf('[')).TrimStart('['); - } - - if (language.IndexOf(']') > 0) - { - language = language.Substring(0, language.IndexOf(']')); - } - - var userWordList = new List(); - - Utilities.LoadUserWordList(userWordList, language); - if (!string.IsNullOrEmpty(language) && NewWord.Length > 0 && !userWordList.Contains(NewWord)) - { - Utilities.AddToUserDictionary(NewWord, language); - DialogResult = DialogResult.OK; - return; - } - DialogResult = DialogResult.Cancel; - } - - internal void Initialize(string hunspellName, string text) - { - if (!string.IsNullOrEmpty(text)) - { - textBoxAddName.Text = text.Trim().TrimEnd('.', '!', '?'); - } - - comboBoxDictionaries.Items.Clear(); - foreach (string name in Utilities.GetDictionaryLanguages()) - { - comboBoxDictionaries.Items.Add(name); - if (hunspellName != null && name.Equals(hunspellName, StringComparison.OrdinalIgnoreCase)) - { - comboBoxDictionaries.SelectedIndex = comboBoxDictionaries.Items.Count - 1; - } - } - } - - public string NewWord { get; private set; } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class AddToUserDic : Form + { + public AddToUserDic() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Text = Configuration.Settings.Language.AddToUserDictionary.Title; + labelDescription.Text = Configuration.Settings.Language.AddToUserDictionary.Description; + labelLanguage.Text = Configuration.Settings.General.Language; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void AddToUserDic_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void buttonOK_Click(object sender, EventArgs e) + { + NewWord = textBoxAddName.Text.RemoveControlCharacters().Trim().ToLowerInvariant(); + if (NewWord.Length == 0) + { + DialogResult = DialogResult.Cancel; + return; + } + + string language = comboBoxDictionaries.Text; + if (language.IndexOf('[') >= 0) + { + language = language.Substring(language.IndexOf('[')).TrimStart('['); + } + + if (language.IndexOf(']') > 0) + { + language = language.Substring(0, language.IndexOf(']')); + } + + var userWordList = new List(); + + Utilities.LoadUserWordList(userWordList, language); + if (!string.IsNullOrEmpty(language) && NewWord.Length > 0 && !userWordList.Contains(NewWord)) + { + Utilities.AddToUserDictionary(NewWord, language); + DialogResult = DialogResult.OK; + return; + } + DialogResult = DialogResult.Cancel; + } + + internal void Initialize(string hunspellName, string text) + { + if (!string.IsNullOrEmpty(text)) + { + textBoxAddName.Text = text.Trim().TrimEnd('.', '!', '?'); + } + + comboBoxDictionaries.Items.Clear(); + foreach (string name in Utilities.GetDictionaryLanguages()) + { + comboBoxDictionaries.Items.Add(name); + if (hunspellName != null && name.Equals(hunspellName, StringComparison.OrdinalIgnoreCase)) + { + comboBoxDictionaries.SelectedIndex = comboBoxDictionaries.Items.Count - 1; + } + } + } + + public string NewWord { get; private set; } + } +} diff --git a/src/Forms/AudioToText.resx b/src/ui/Forms/AddToUserDic.resx similarity index 100% rename from src/Forms/AudioToText.resx rename to src/ui/Forms/AddToUserDic.resx diff --git a/src/Forms/AddWaveform.Designer.cs b/src/ui/Forms/AddWaveform.Designer.cs similarity index 100% rename from src/Forms/AddWaveform.Designer.cs rename to src/ui/Forms/AddWaveform.Designer.cs diff --git a/src/Forms/AddWaveform.cs b/src/ui/Forms/AddWaveform.cs similarity index 97% rename from src/Forms/AddWaveform.cs rename to src/ui/Forms/AddWaveform.cs index 82b7779de..c7ae1d688 100644 --- a/src/Forms/AddWaveform.cs +++ b/src/ui/Forms/AddWaveform.cs @@ -1,491 +1,491 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; -using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; -using Nikse.SubtitleEdit.Logic; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class AddWaveform : Form - { - public int AudioTrackNumber { get; set; } = -1; - public string SourceVideoFileName { get; private set; } - private bool _cancel; - private string _peakWaveFileName; - private string _wavFileName; - private string _spectrogramDirectory; - public WavePeakData Peaks { get; private set; } - public SpectrogramData Spectrogram { get; private set; } - private string _encodeParameters; - private const string RetryEncodeParameters = "acodec=s16l"; - private int _delayInMilliseconds; - private int _numberOfAudioTracks; - - public AddWaveform() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - labelProgress.Text = string.Empty; - buttonCancel.Visible = false; - labelInfo.Text = string.Empty; - UiUtil.FixLargeFonts(this, buttonCancel); - } - - public void Initialize(string videoFile, string peakWaveFileName, string spectrogramDirectory, int audioTrackNumber) - { - _peakWaveFileName = peakWaveFileName; - AudioTrackNumber = audioTrackNumber; - if (AudioTrackNumber < 0) - { - AudioTrackNumber = 0; - } - - Text = Configuration.Settings.Language.AddWaveform.Title; - buttonRipWave.Text = Configuration.Settings.Language.AddWaveform.GenerateWaveformData; - labelPleaseWait.Text = Configuration.Settings.Language.AddWaveform.PleaseWait; - labelVideoFileName.Text = videoFile; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - labelSourcevideoFile.Text = Configuration.Settings.Language.AddWaveform.SourceVideoFile; - _spectrogramDirectory = spectrogramDirectory; - _encodeParameters = Configuration.Settings.General.VlcWaveTranscodeSettings; - } - - public static Process GetCommandLineProcess(string inputVideoFile, int audioTrackNumber, string outWaveFile, string encodeParamters, out string encoderName) - { - encoderName = "VLC"; - string parameters = "\"" + inputVideoFile + "\" -I dummy -vvv --no-random --no-repeat --no-loop --no-sout-video --audio-track-id=" + audioTrackNumber + " --sout=\"#transcode{acodec=s16l,channels=1,ab=128,audio-track-id=" + audioTrackNumber + "}:std{access=file,mux=wav,dst=" + outWaveFile + "}\" vlc://quit"; - string exeFilePath; - if (Configuration.IsRunningOnLinux) - { - exeFilePath = "cvlc"; - parameters = "-vvv --no-random --no-repeat --no-loop --no-sout-video --audio-track-id=" + audioTrackNumber + " --sout '#transcode{" + encodeParamters + ",audio-track-id=" + audioTrackNumber + "}:std{mux=wav,access=file,dst=" + outWaveFile + "}' \"" + inputVideoFile + "\" vlc://quit"; - } - else if (Configuration.IsRunningOnMac) - { - exeFilePath = "VLC.app/Contents/MacOS/VLC"; - } - else // windows - { - exeFilePath = Logic.VideoPlayers.LibVlcDynamic.GetVlcPath("vlc.exe"); - if (!File.Exists(exeFilePath)) - { - if (Configuration.Settings.General.UseFFmpegForWaveExtraction && File.Exists(Configuration.Settings.General.FFmpegLocation)) - { - // We will run FFmpeg - } - else - { - throw new DllNotFoundException("NO_VLC"); - } - } - } - - if (Configuration.Settings.General.UseFFmpegForWaveExtraction && (File.Exists(Configuration.Settings.General.FFmpegLocation)) || !Configuration.IsRunningOnWindows) - { - encoderName = "FFmpeg"; - string audioParameter = string.Empty; - if (audioTrackNumber > 0) - { - audioParameter = $"-map 0:a:{audioTrackNumber}"; - } - - const string fFmpegWaveTranscodeSettings = "-i \"{0}\" -vn -ar 24000 -ac 2 -ab 128 -vol 448 -f wav {2} \"{1}\""; - //-i indicates the input - //-vn means no video ouput - //-ar 44100 indicates the sampling frequency. - //-ab indicates the bit rate (in this example 160kb/s) - //-vol 448 will boot volume... 256 is normal - //-ac 2 means 2 channels - - // "-map 0:a:0" is the first audio stream, "-map 0:a:1" is the second audio stream - - exeFilePath = Configuration.Settings.General.FFmpegLocation; - if (!Configuration.IsRunningOnWindows) - { - exeFilePath = "ffmpeg"; - } - parameters = string.Format(fFmpegWaveTranscodeSettings, inputVideoFile, outWaveFile, audioParameter); - } - return new Process { StartInfo = new ProcessStartInfo(exeFilePath, parameters) { WindowStyle = ProcessWindowStyle.Hidden } }; - } - - private void buttonRipWave_Click(object sender, EventArgs e) - { - buttonRipWave.Enabled = false; - _cancel = false; - SourceVideoFileName = labelVideoFileName.Text; - string targetFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".wav"); - string targetDriveLetter = null; - if (Configuration.IsRunningOnWindows) - { - var root = Path.GetPathRoot(targetFile); - if (root.Length > 1 && root[1] == ':') - { - targetDriveLetter = root.Remove(1); - } - } - - labelPleaseWait.Visible = true; - string encoderName; - Process process; - try - { - process = GetCommandLineProcess(SourceVideoFileName, AudioTrackNumber, targetFile, _encodeParameters, out encoderName); - labelInfo.Text = encoderName; - } - catch (DllNotFoundException) - { - if (MessageBox.Show(Configuration.Settings.Language.AddWaveform.VlcMediaPlayerNotFound + Environment.NewLine + - Environment.NewLine + Configuration.Settings.Language.AddWaveform.GoToVlcMediaPlayerHomePage, - Configuration.Settings.Language.AddWaveform.VlcMediaPlayerNotFoundTitle, - MessageBoxButtons.YesNo) == DialogResult.Yes) - { - UiUtil.OpenURL("http://www.videolan.org/"); - } - buttonRipWave.Enabled = true; - return; - } - - process.Start(); - progressBar1.Style = ProgressBarStyle.Marquee; - progressBar1.Visible = true; - double seconds = 0; - buttonCancel.Visible = true; - try - { - process.PriorityClass = ProcessPriorityClass.Normal; - } - catch - { - // ignored - } - - while (!process.HasExited) - { - Application.DoEvents(); - System.Threading.Thread.Sleep(100); - seconds += 0.1; - if (seconds < 60) - { - labelProgress.Text = string.Format(Configuration.Settings.Language.AddWaveform.ExtractingSeconds, seconds); - } - else - { - labelProgress.Text = string.Format(Configuration.Settings.Language.AddWaveform.ExtractingMinutes, (int)(seconds / 60), (int)(seconds % 60)); - } - - Refresh(); - if (_cancel) - { - process.Kill(); - progressBar1.Visible = false; - labelPleaseWait.Visible = false; - buttonRipWave.Enabled = true; - buttonCancel.Visible = false; - DialogResult = DialogResult.Cancel; - return; - } - - if (targetDriveLetter != null && seconds > 1 && Convert.ToInt32(seconds) % 10 == 0) - { - try - { - var drive = new DriveInfo(targetDriveLetter); - if (drive.IsReady) - { - if (drive.AvailableFreeSpace < 50 * 1000000) // 50 mb - { - labelInfo.ForeColor = Color.Red; - labelInfo.Text = Configuration.Settings.Language.AddWaveform.LowDiskSpace; - } - else if (labelInfo.ForeColor == Color.Red) - { - labelInfo.Text = string.Format(Configuration.Settings.Language.AddWaveform.FreeDiskSpace, Utilities.FormatBytesToDisplayFileSize(drive.AvailableFreeSpace)); - } - } - } - catch - { - // ignored - } - } - } - buttonCancel.Visible = false; - progressBar1.Visible = false; - progressBar1.Style = ProgressBarStyle.Blocks; - process.Dispose(); - - var targetFileInfo = new FileInfo(targetFile); - if (!targetFileInfo.Exists) - { - if (_encodeParameters != RetryEncodeParameters) - { - _encodeParameters = RetryEncodeParameters; - buttonRipWave_Click(null, null); - return; - } - - if (_numberOfAudioTracks == 0 && MessageBox.Show(Configuration.Settings.Language.AddWaveform.NoAudioTracksFoundGenerateEmptyWaveform, Configuration.Settings.Language.General.Title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) - { - MakeEmptyWaveFile(); - DialogResult = DialogResult.OK; - return; - } - - MessageBox.Show(string.Format(Configuration.Settings.Language.AddWaveform.WaveFileNotFound, IntPtr.Size * 8, process.StartInfo.FileName, process.StartInfo.Arguments)); - - labelPleaseWait.Visible = false; - labelProgress.Text = string.Empty; - buttonRipWave.Enabled = true; - return; - } - - if (targetFileInfo.Length <= 200) - { - if (_numberOfAudioTracks == 0 && MessageBox.Show(Configuration.Settings.Language.AddWaveform.NoAudioTracksFoundGenerateEmptyWaveform, Configuration.Settings.Language.General.Title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) - { - MakeEmptyWaveFile(); - DialogResult = DialogResult.OK; - return; - } - - MessageBox.Show(string.Format(Configuration.Settings.Language.AddWaveform.WaveFileMalformed, encoderName, process.StartInfo.FileName, process.StartInfo.Arguments)); - - labelPleaseWait.Visible = false; - labelProgress.Text = string.Empty; - buttonRipWave.Enabled = true; - return; - } - - ReadWaveFile(targetFile, _delayInMilliseconds); - labelProgress.Text = string.Empty; - File.Delete(targetFile); - DialogResult = DialogResult.OK; - } - - private void ReadWaveFile(string targetFile, int delayInMilliseconds) - { - labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingPeakFile; - Refresh(); - - using (var waveFile = new WavePeakGenerator(targetFile)) - { - Peaks = waveFile.GeneratePeaks(delayInMilliseconds, _peakWaveFileName); - - if (Configuration.Settings.VideoControls.GenerateSpectrogram) - { - labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingSpectrogram; - Refresh(); - Spectrogram = waveFile.GenerateSpectrogram(delayInMilliseconds, _spectrogramDirectory); - } - } - - labelPleaseWait.Visible = false; - } - - private void MakeEmptyWaveFile() - { - labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingPeakFile; - Refresh(); - var videoInfo = UiUtil.GetVideoInfo(SourceVideoFileName); - Peaks = WavePeakGenerator.GenerateEmptyPeaks(_peakWaveFileName, (int)videoInfo.TotalMilliseconds / 1000); - labelPleaseWait.Visible = false; - } - - private void AddWaveform_Shown(object sender, EventArgs e) - { - Refresh(); - _numberOfAudioTracks = 0; - var audioTrackNames = new List(); - var mkvAudioTrackNumbers = new Dictionary(); - if (labelVideoFileName.Text.Length > 1 && File.Exists(labelVideoFileName.Text)) - { - if (labelVideoFileName.Text.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase)) - { // Choose for number of audio tracks in matroska files - MatroskaFile matroska = null; - try - { - matroska = new MatroskaFile(labelVideoFileName.Text); - if (matroska.IsValid) - { - foreach (var track in matroska.GetTracks()) - { - if (track.IsAudio) - { - _numberOfAudioTracks++; - if (track.CodecId != null && track.Language != null) - { - audioTrackNames.Add("#" + track.TrackNumber + ": " + track.CodecId.Replace("\0", string.Empty) + " - " + track.Language.Replace("\0", string.Empty)); - } - else - { - audioTrackNames.Add("#" + track.TrackNumber); - } - - mkvAudioTrackNumbers.Add(mkvAudioTrackNumbers.Count, track.TrackNumber); - } - } - } - } - finally - { - matroska?.Dispose(); - } - } - else if (labelVideoFileName.Text.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) || labelVideoFileName.Text.EndsWith(".m4v", StringComparison.OrdinalIgnoreCase)) - { // Choose for number of audio tracks in mp4 files - try - { - var mp4 = new MP4Parser(labelVideoFileName.Text); - var tracks = mp4.GetAudioTracks(); - int i = 0; - foreach (var track in tracks) - { - i++; - if (track.Name != null && track.Mdia != null && track.Mdia.Mdhd != null && track.Mdia.Mdhd.LanguageString != null) - { - audioTrackNames.Add(i + ": " + track.Name + " - " + track.Mdia.Mdhd.LanguageString); - } - else if (track.Name != null) - { - audioTrackNames.Add(i + ": " + track.Name); - } - else - { - audioTrackNames.Add(i.ToString(CultureInfo.InvariantCulture)); - } - } - _numberOfAudioTracks = tracks.Count; - } - catch - { - // ignored - } - } - - // Choose audio track - if (_numberOfAudioTracks > 1) - { - using (var form = new ChooseAudioTrack(audioTrackNames, AudioTrackNumber)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - if (AudioTrackNumber != form.SelectedTrack) - { - AudioTrackNumber = form.SelectedTrack; - - var peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(labelVideoFileName.Text, form.SelectedTrack); - var spectrogramFolder = WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(labelVideoFileName.Text, form.SelectedTrack); - if (File.Exists(peakWaveFileName)) - { - DialogResult = DialogResult.Cancel; - return; - } - - _peakWaveFileName = peakWaveFileName; - _spectrogramDirectory = spectrogramFolder; - } - } - else - { - DialogResult = DialogResult.Cancel; - return; - } - } - } - - // check for delay in matroska files - if (labelVideoFileName.Text.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase)) - { - MatroskaFile matroska = null; - try - { - matroska = new MatroskaFile(labelVideoFileName.Text); - if (matroska.IsValid) - { - _delayInMilliseconds = (int)matroska.GetAudioTrackDelayMilliseconds(mkvAudioTrackNumbers[AudioTrackNumber]); - } - } - catch (Exception exception) - { - SeLogger.Error(exception, $"Error getting delay from mkv: {labelVideoFileName.Text}"); - _delayInMilliseconds = 0; - } - finally - { - matroska?.Dispose(); - } - } - - buttonRipWave_Click(null, null); - } - else if (_wavFileName != null) - { - FixWaveOnly(); - } - } - - private void AddWaveform_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#waveform"); - e.SuppressKeyPress = true; - } - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - _cancel = true; - } - - internal void InitializeViaWaveFile(string fileName, string peakWaveFileName, string spectrogramFolder) - { - _peakWaveFileName = peakWaveFileName; - _wavFileName = fileName; - _spectrogramDirectory = spectrogramFolder; - } - - private void FixWaveOnly() - { - Text = Configuration.Settings.Language.AddWaveform.Title; - buttonRipWave.Text = Configuration.Settings.Language.AddWaveform.GenerateWaveformData; - labelPleaseWait.Text = Configuration.Settings.Language.AddWaveform.PleaseWait; - labelVideoFileName.Text = string.Empty; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - buttonRipWave.Enabled = false; - _cancel = false; - buttonCancel.Visible = false; - progressBar1.Visible = false; - progressBar1.Style = ProgressBarStyle.Blocks; - - labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingPeakFile; - Refresh(); - labelPleaseWait.Visible = false; - try - { - ReadWaveFile(_wavFileName, _delayInMilliseconds); - labelProgress.Text = string.Empty; - DialogResult = DialogResult.OK; - } - catch (Exception exception) - { - MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace); - DialogResult = DialogResult.Cancel; - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; +using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Logic; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class AddWaveform : Form + { + public int AudioTrackNumber { get; set; } = -1; + public string SourceVideoFileName { get; private set; } + private bool _cancel; + private string _peakWaveFileName; + private string _wavFileName; + private string _spectrogramDirectory; + public WavePeakData Peaks { get; private set; } + public SpectrogramData Spectrogram { get; private set; } + private string _encodeParameters; + private const string RetryEncodeParameters = "acodec=s16l"; + private int _delayInMilliseconds; + private int _numberOfAudioTracks; + + public AddWaveform() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + labelProgress.Text = string.Empty; + buttonCancel.Visible = false; + labelInfo.Text = string.Empty; + UiUtil.FixLargeFonts(this, buttonCancel); + } + + public void Initialize(string videoFile, string peakWaveFileName, string spectrogramDirectory, int audioTrackNumber) + { + _peakWaveFileName = peakWaveFileName; + AudioTrackNumber = audioTrackNumber; + if (AudioTrackNumber < 0) + { + AudioTrackNumber = 0; + } + + Text = Configuration.Settings.Language.AddWaveform.Title; + buttonRipWave.Text = Configuration.Settings.Language.AddWaveform.GenerateWaveformData; + labelPleaseWait.Text = Configuration.Settings.Language.AddWaveform.PleaseWait; + labelVideoFileName.Text = videoFile; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + labelSourcevideoFile.Text = Configuration.Settings.Language.AddWaveform.SourceVideoFile; + _spectrogramDirectory = spectrogramDirectory; + _encodeParameters = Configuration.Settings.General.VlcWaveTranscodeSettings; + } + + public static Process GetCommandLineProcess(string inputVideoFile, int audioTrackNumber, string outWaveFile, string encodeParamters, out string encoderName) + { + encoderName = "VLC"; + string parameters = "\"" + inputVideoFile + "\" -I dummy -vvv --no-random --no-repeat --no-loop --no-sout-video --audio-track-id=" + audioTrackNumber + " --sout=\"#transcode{acodec=s16l,channels=1,ab=128,audio-track-id=" + audioTrackNumber + "}:std{access=file,mux=wav,dst=" + outWaveFile + "}\" vlc://quit"; + string exeFilePath; + if (Configuration.IsRunningOnLinux) + { + exeFilePath = "cvlc"; + parameters = "-vvv --no-random --no-repeat --no-loop --no-sout-video --audio-track-id=" + audioTrackNumber + " --sout '#transcode{" + encodeParamters + ",audio-track-id=" + audioTrackNumber + "}:std{mux=wav,access=file,dst=" + outWaveFile + "}' \"" + inputVideoFile + "\" vlc://quit"; + } + else if (Configuration.IsRunningOnMac) + { + exeFilePath = "VLC.app/Contents/MacOS/VLC"; + } + else // windows + { + exeFilePath = Logic.VideoPlayers.LibVlcDynamic.GetVlcPath("vlc.exe"); + if (!File.Exists(exeFilePath)) + { + if (Configuration.Settings.General.UseFFmpegForWaveExtraction && File.Exists(Configuration.Settings.General.FFmpegLocation)) + { + // We will run FFmpeg + } + else + { + throw new DllNotFoundException("NO_VLC"); + } + } + } + + if (Configuration.Settings.General.UseFFmpegForWaveExtraction && (File.Exists(Configuration.Settings.General.FFmpegLocation)) || !Configuration.IsRunningOnWindows) + { + encoderName = "FFmpeg"; + string audioParameter = string.Empty; + if (audioTrackNumber > 0) + { + audioParameter = $"-map 0:a:{audioTrackNumber}"; + } + + const string fFmpegWaveTranscodeSettings = "-i \"{0}\" -vn -ar 24000 -ac 2 -ab 128 -vol 448 -f wav {2} \"{1}\""; + //-i indicates the input + //-vn means no video ouput + //-ar 44100 indicates the sampling frequency. + //-ab indicates the bit rate (in this example 160kb/s) + //-vol 448 will boot volume... 256 is normal + //-ac 2 means 2 channels + + // "-map 0:a:0" is the first audio stream, "-map 0:a:1" is the second audio stream + + exeFilePath = Configuration.Settings.General.FFmpegLocation; + if (!Configuration.IsRunningOnWindows) + { + exeFilePath = "ffmpeg"; + } + parameters = string.Format(fFmpegWaveTranscodeSettings, inputVideoFile, outWaveFile, audioParameter); + } + return new Process { StartInfo = new ProcessStartInfo(exeFilePath, parameters) { WindowStyle = ProcessWindowStyle.Hidden } }; + } + + private void buttonRipWave_Click(object sender, EventArgs e) + { + buttonRipWave.Enabled = false; + _cancel = false; + SourceVideoFileName = labelVideoFileName.Text; + string targetFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".wav"); + string targetDriveLetter = null; + if (Configuration.IsRunningOnWindows) + { + var root = Path.GetPathRoot(targetFile); + if (root.Length > 1 && root[1] == ':') + { + targetDriveLetter = root.Remove(1); + } + } + + labelPleaseWait.Visible = true; + string encoderName; + Process process; + try + { + process = GetCommandLineProcess(SourceVideoFileName, AudioTrackNumber, targetFile, _encodeParameters, out encoderName); + labelInfo.Text = encoderName; + } + catch (DllNotFoundException) + { + if (MessageBox.Show(Configuration.Settings.Language.AddWaveform.VlcMediaPlayerNotFound + Environment.NewLine + + Environment.NewLine + Configuration.Settings.Language.AddWaveform.GoToVlcMediaPlayerHomePage, + Configuration.Settings.Language.AddWaveform.VlcMediaPlayerNotFoundTitle, + MessageBoxButtons.YesNo) == DialogResult.Yes) + { + UiUtil.OpenURL("http://www.videolan.org/"); + } + buttonRipWave.Enabled = true; + return; + } + + process.Start(); + progressBar1.Style = ProgressBarStyle.Marquee; + progressBar1.Visible = true; + double seconds = 0; + buttonCancel.Visible = true; + try + { + process.PriorityClass = ProcessPriorityClass.Normal; + } + catch + { + // ignored + } + + while (!process.HasExited) + { + Application.DoEvents(); + System.Threading.Thread.Sleep(100); + seconds += 0.1; + if (seconds < 60) + { + labelProgress.Text = string.Format(Configuration.Settings.Language.AddWaveform.ExtractingSeconds, seconds); + } + else + { + labelProgress.Text = string.Format(Configuration.Settings.Language.AddWaveform.ExtractingMinutes, (int)(seconds / 60), (int)(seconds % 60)); + } + + Refresh(); + if (_cancel) + { + process.Kill(); + progressBar1.Visible = false; + labelPleaseWait.Visible = false; + buttonRipWave.Enabled = true; + buttonCancel.Visible = false; + DialogResult = DialogResult.Cancel; + return; + } + + if (targetDriveLetter != null && seconds > 1 && Convert.ToInt32(seconds) % 10 == 0) + { + try + { + var drive = new DriveInfo(targetDriveLetter); + if (drive.IsReady) + { + if (drive.AvailableFreeSpace < 50 * 1000000) // 50 mb + { + labelInfo.ForeColor = Color.Red; + labelInfo.Text = Configuration.Settings.Language.AddWaveform.LowDiskSpace; + } + else if (labelInfo.ForeColor == Color.Red) + { + labelInfo.Text = string.Format(Configuration.Settings.Language.AddWaveform.FreeDiskSpace, Utilities.FormatBytesToDisplayFileSize(drive.AvailableFreeSpace)); + } + } + } + catch + { + // ignored + } + } + } + buttonCancel.Visible = false; + progressBar1.Visible = false; + progressBar1.Style = ProgressBarStyle.Blocks; + process.Dispose(); + + var targetFileInfo = new FileInfo(targetFile); + if (!targetFileInfo.Exists) + { + if (_encodeParameters != RetryEncodeParameters) + { + _encodeParameters = RetryEncodeParameters; + buttonRipWave_Click(null, null); + return; + } + + if (_numberOfAudioTracks == 0 && MessageBox.Show(Configuration.Settings.Language.AddWaveform.NoAudioTracksFoundGenerateEmptyWaveform, Configuration.Settings.Language.General.Title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + MakeEmptyWaveFile(); + DialogResult = DialogResult.OK; + return; + } + + MessageBox.Show(string.Format(Configuration.Settings.Language.AddWaveform.WaveFileNotFound, IntPtr.Size * 8, process.StartInfo.FileName, process.StartInfo.Arguments)); + + labelPleaseWait.Visible = false; + labelProgress.Text = string.Empty; + buttonRipWave.Enabled = true; + return; + } + + if (targetFileInfo.Length <= 200) + { + if (_numberOfAudioTracks == 0 && MessageBox.Show(Configuration.Settings.Language.AddWaveform.NoAudioTracksFoundGenerateEmptyWaveform, Configuration.Settings.Language.General.Title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + MakeEmptyWaveFile(); + DialogResult = DialogResult.OK; + return; + } + + MessageBox.Show(string.Format(Configuration.Settings.Language.AddWaveform.WaveFileMalformed, encoderName, process.StartInfo.FileName, process.StartInfo.Arguments)); + + labelPleaseWait.Visible = false; + labelProgress.Text = string.Empty; + buttonRipWave.Enabled = true; + return; + } + + ReadWaveFile(targetFile, _delayInMilliseconds); + labelProgress.Text = string.Empty; + File.Delete(targetFile); + DialogResult = DialogResult.OK; + } + + private void ReadWaveFile(string targetFile, int delayInMilliseconds) + { + labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingPeakFile; + Refresh(); + + using (var waveFile = new WavePeakGenerator(targetFile)) + { + Peaks = waveFile.GeneratePeaks(delayInMilliseconds, _peakWaveFileName); + + if (Configuration.Settings.VideoControls.GenerateSpectrogram) + { + labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingSpectrogram; + Refresh(); + Spectrogram = waveFile.GenerateSpectrogram(delayInMilliseconds, _spectrogramDirectory); + } + } + + labelPleaseWait.Visible = false; + } + + private void MakeEmptyWaveFile() + { + labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingPeakFile; + Refresh(); + var videoInfo = UiUtil.GetVideoInfo(SourceVideoFileName); + Peaks = WavePeakGenerator.GenerateEmptyPeaks(_peakWaveFileName, (int)videoInfo.TotalMilliseconds / 1000); + labelPleaseWait.Visible = false; + } + + private void AddWaveform_Shown(object sender, EventArgs e) + { + Refresh(); + _numberOfAudioTracks = 0; + var audioTrackNames = new List(); + var mkvAudioTrackNumbers = new Dictionary(); + if (labelVideoFileName.Text.Length > 1 && File.Exists(labelVideoFileName.Text)) + { + if (labelVideoFileName.Text.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase)) + { // Choose for number of audio tracks in matroska files + MatroskaFile matroska = null; + try + { + matroska = new MatroskaFile(labelVideoFileName.Text); + if (matroska.IsValid) + { + foreach (var track in matroska.GetTracks()) + { + if (track.IsAudio) + { + _numberOfAudioTracks++; + if (track.CodecId != null && track.Language != null) + { + audioTrackNames.Add("#" + track.TrackNumber + ": " + track.CodecId.Replace("\0", string.Empty) + " - " + track.Language.Replace("\0", string.Empty)); + } + else + { + audioTrackNames.Add("#" + track.TrackNumber); + } + + mkvAudioTrackNumbers.Add(mkvAudioTrackNumbers.Count, track.TrackNumber); + } + } + } + } + finally + { + matroska?.Dispose(); + } + } + else if (labelVideoFileName.Text.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) || labelVideoFileName.Text.EndsWith(".m4v", StringComparison.OrdinalIgnoreCase)) + { // Choose for number of audio tracks in mp4 files + try + { + var mp4 = new MP4Parser(labelVideoFileName.Text); + var tracks = mp4.GetAudioTracks(); + int i = 0; + foreach (var track in tracks) + { + i++; + if (track.Name != null && track.Mdia != null && track.Mdia.Mdhd != null && track.Mdia.Mdhd.LanguageString != null) + { + audioTrackNames.Add(i + ": " + track.Name + " - " + track.Mdia.Mdhd.LanguageString); + } + else if (track.Name != null) + { + audioTrackNames.Add(i + ": " + track.Name); + } + else + { + audioTrackNames.Add(i.ToString(CultureInfo.InvariantCulture)); + } + } + _numberOfAudioTracks = tracks.Count; + } + catch + { + // ignored + } + } + + // Choose audio track + if (_numberOfAudioTracks > 1) + { + using (var form = new ChooseAudioTrack(audioTrackNames, AudioTrackNumber)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + if (AudioTrackNumber != form.SelectedTrack) + { + AudioTrackNumber = form.SelectedTrack; + + var peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(labelVideoFileName.Text, form.SelectedTrack); + var spectrogramFolder = WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(labelVideoFileName.Text, form.SelectedTrack); + if (File.Exists(peakWaveFileName)) + { + DialogResult = DialogResult.Cancel; + return; + } + + _peakWaveFileName = peakWaveFileName; + _spectrogramDirectory = spectrogramFolder; + } + } + else + { + DialogResult = DialogResult.Cancel; + return; + } + } + } + + // check for delay in matroska files + if (labelVideoFileName.Text.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase)) + { + MatroskaFile matroska = null; + try + { + matroska = new MatroskaFile(labelVideoFileName.Text); + if (matroska.IsValid) + { + _delayInMilliseconds = (int)matroska.GetAudioTrackDelayMilliseconds(mkvAudioTrackNumbers[AudioTrackNumber]); + } + } + catch (Exception exception) + { + SeLogger.Error(exception, $"Error getting delay from mkv: {labelVideoFileName.Text}"); + _delayInMilliseconds = 0; + } + finally + { + matroska?.Dispose(); + } + } + + buttonRipWave_Click(null, null); + } + else if (_wavFileName != null) + { + FixWaveOnly(); + } + } + + private void AddWaveform_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#waveform"); + e.SuppressKeyPress = true; + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + _cancel = true; + } + + internal void InitializeViaWaveFile(string fileName, string peakWaveFileName, string spectrogramFolder) + { + _peakWaveFileName = peakWaveFileName; + _wavFileName = fileName; + _spectrogramDirectory = spectrogramFolder; + } + + private void FixWaveOnly() + { + Text = Configuration.Settings.Language.AddWaveform.Title; + buttonRipWave.Text = Configuration.Settings.Language.AddWaveform.GenerateWaveformData; + labelPleaseWait.Text = Configuration.Settings.Language.AddWaveform.PleaseWait; + labelVideoFileName.Text = string.Empty; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + buttonRipWave.Enabled = false; + _cancel = false; + buttonCancel.Visible = false; + progressBar1.Visible = false; + progressBar1.Style = ProgressBarStyle.Blocks; + + labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingPeakFile; + Refresh(); + labelPleaseWait.Visible = false; + try + { + ReadWaveFile(_wavFileName, _delayInMilliseconds); + labelProgress.Text = string.Empty; + DialogResult = DialogResult.OK; + } + catch (Exception exception) + { + MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace); + DialogResult = DialogResult.Cancel; + } + } + + } +} diff --git a/src/Forms/AddWaveform.resx b/src/ui/Forms/AddWaveform.resx similarity index 100% rename from src/Forms/AddWaveform.resx rename to src/ui/Forms/AddWaveform.resx diff --git a/src/Forms/AddWaveformBatch.Designer.cs b/src/ui/Forms/AddWaveformBatch.Designer.cs similarity index 100% rename from src/Forms/AddWaveformBatch.Designer.cs rename to src/ui/Forms/AddWaveformBatch.Designer.cs diff --git a/src/Forms/AddWaveformBatch.cs b/src/ui/Forms/AddWaveformBatch.cs similarity index 100% rename from src/Forms/AddWaveformBatch.cs rename to src/ui/Forms/AddWaveformBatch.cs diff --git a/src/Forms/AddWaveformBatch.resx b/src/ui/Forms/AddWaveformBatch.resx similarity index 100% rename from src/Forms/AddWaveformBatch.resx rename to src/ui/Forms/AddWaveformBatch.resx diff --git a/src/Forms/AdjustDisplayDuration.Designer.cs b/src/ui/Forms/AdjustDisplayDuration.Designer.cs similarity index 98% rename from src/Forms/AdjustDisplayDuration.Designer.cs rename to src/ui/Forms/AdjustDisplayDuration.Designer.cs index f0daddb1a..d42d9d739 100644 --- a/src/Forms/AdjustDisplayDuration.Designer.cs +++ b/src/ui/Forms/AdjustDisplayDuration.Designer.cs @@ -1,399 +1,399 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class AdjustDisplayDuration - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.radioButtonPercent = new System.Windows.Forms.RadioButton(); - this.radioButtonSeconds = new System.Windows.Forms.RadioButton(); - this.groupBoxAdjustVia = new System.Windows.Forms.GroupBox(); - this.radioButtonFixed = new System.Windows.Forms.RadioButton(); - this.radioButtonAutoRecalculate = new System.Windows.Forms.RadioButton(); - this.labelNote = new System.Windows.Forms.Label(); - this.labelAddInPercent = new System.Windows.Forms.Label(); - this.labelAddSeconds = new System.Windows.Forms.Label(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.numericUpDownMaxCharsSec = new System.Windows.Forms.NumericUpDown(); - this.labelMaxCharsPerSecond = new System.Windows.Forms.Label(); - this.numericUpDownSeconds = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownPercent = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownOptimalCharsSec = new System.Windows.Forms.NumericUpDown(); - this.labelOptimalCharsSec = new System.Windows.Forms.Label(); - this.numericUpDownFixedMilliseconds = new System.Windows.Forms.NumericUpDown(); - this.labelMillisecondsFixed = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.checkBoxExtendOnly = new System.Windows.Forms.CheckBox(); - this.groupBoxAdjustVia.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharsSec)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFixedMilliseconds)).BeginInit(); - this.SuspendLayout(); - // - // radioButtonPercent - // - this.radioButtonPercent.AutoSize = true; - this.radioButtonPercent.Location = new System.Drawing.Point(171, 21); - this.radioButtonPercent.Name = "radioButtonPercent"; - this.radioButtonPercent.Size = new System.Drawing.Size(62, 17); - this.radioButtonPercent.TabIndex = 1; - this.radioButtonPercent.Text = "Percent"; - this.radioButtonPercent.UseVisualStyleBackColor = true; - this.radioButtonPercent.CheckedChanged += new System.EventHandler(this.RadioButtonPercentCheckedChanged); - // - // radioButtonSeconds - // - this.radioButtonSeconds.AutoSize = true; - this.radioButtonSeconds.Checked = true; - this.radioButtonSeconds.Location = new System.Drawing.Point(11, 21); - this.radioButtonSeconds.Name = "radioButtonSeconds"; - this.radioButtonSeconds.Size = new System.Drawing.Size(65, 17); - this.radioButtonSeconds.TabIndex = 0; - this.radioButtonSeconds.TabStop = true; - this.radioButtonSeconds.Text = "Seconds"; - this.radioButtonSeconds.UseVisualStyleBackColor = true; - this.radioButtonSeconds.CheckedChanged += new System.EventHandler(this.RadioButtonSecondsCheckedChanged); - // - // groupBoxAdjustVia - // - this.groupBoxAdjustVia.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxAdjustVia.Controls.Add(this.radioButtonFixed); - this.groupBoxAdjustVia.Controls.Add(this.radioButtonAutoRecalculate); - this.groupBoxAdjustVia.Controls.Add(this.radioButtonPercent); - this.groupBoxAdjustVia.Controls.Add(this.radioButtonSeconds); - this.groupBoxAdjustVia.Location = new System.Drawing.Point(13, 13); - this.groupBoxAdjustVia.Name = "groupBoxAdjustVia"; - this.groupBoxAdjustVia.Size = new System.Drawing.Size(599, 47); - this.groupBoxAdjustVia.TabIndex = 0; - this.groupBoxAdjustVia.TabStop = false; - this.groupBoxAdjustVia.Text = "Adjust via"; - // - // radioButtonFixed - // - this.radioButtonFixed.AutoSize = true; - this.radioButtonFixed.Location = new System.Drawing.Point(491, 21); - this.radioButtonFixed.Name = "radioButtonFixed"; - this.radioButtonFixed.Size = new System.Drawing.Size(51, 17); - this.radioButtonFixed.TabIndex = 3; - this.radioButtonFixed.Text = "Fixed"; - this.radioButtonFixed.UseVisualStyleBackColor = true; - this.radioButtonFixed.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); - // - // radioButtonAutoRecalculate - // - this.radioButtonAutoRecalculate.AutoSize = true; - this.radioButtonAutoRecalculate.Location = new System.Drawing.Point(344, 21); - this.radioButtonAutoRecalculate.Name = "radioButtonAutoRecalculate"; - this.radioButtonAutoRecalculate.Size = new System.Drawing.Size(80, 17); - this.radioButtonAutoRecalculate.TabIndex = 2; - this.radioButtonAutoRecalculate.Text = "Recalculate"; - this.radioButtonAutoRecalculate.UseVisualStyleBackColor = true; - this.radioButtonAutoRecalculate.CheckedChanged += new System.EventHandler(this.radioButtonAutoRecalculate_CheckedChanged); - // - // labelNote - // - this.labelNote.AutoSize = true; - this.labelNote.Location = new System.Drawing.Point(10, 211); - this.labelNote.Name = "labelNote"; - this.labelNote.Size = new System.Drawing.Size(279, 13); - this.labelNote.TabIndex = 7; - this.labelNote.Text = "Note: Display time will not overlap start time of next text"; - // - // labelAddInPercent - // - this.labelAddInPercent.AutoSize = true; - this.labelAddInPercent.Location = new System.Drawing.Point(179, 70); - this.labelAddInPercent.Name = "labelAddInPercent"; - this.labelAddInPercent.Size = new System.Drawing.Size(89, 13); - this.labelAddInPercent.TabIndex = 3; - this.labelAddInPercent.Text = "Adjust in percent"; - // - // labelAddSeconds - // - this.labelAddSeconds.AutoSize = true; - this.labelAddSeconds.Location = new System.Drawing.Point(10, 70); - this.labelAddSeconds.Name = "labelAddSeconds"; - this.labelAddSeconds.Size = new System.Drawing.Size(68, 13); - this.labelAddSeconds.TabIndex = 1; - this.labelAddSeconds.Text = "Add seconds"; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(537, 231); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 21; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(456, 231); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 20; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // numericUpDownMaxCharsSec - // - this.numericUpDownMaxCharsSec.DecimalPlaces = 1; - this.numericUpDownMaxCharsSec.Enabled = false; - this.numericUpDownMaxCharsSec.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownMaxCharsSec.Location = new System.Drawing.Point(357, 89); - this.numericUpDownMaxCharsSec.Minimum = new decimal(new int[] { - 4, - 0, - 0, - 0}); - this.numericUpDownMaxCharsSec.Name = "numericUpDownMaxCharsSec"; - this.numericUpDownMaxCharsSec.Size = new System.Drawing.Size(80, 21); - this.numericUpDownMaxCharsSec.TabIndex = 6; - this.numericUpDownMaxCharsSec.Value = new decimal(new int[] { - 24, - 0, - 0, - 0}); - // - // labelMaxCharsPerSecond - // - this.labelMaxCharsPerSecond.AutoSize = true; - this.labelMaxCharsPerSecond.Location = new System.Drawing.Point(354, 70); - this.labelMaxCharsPerSecond.Name = "labelMaxCharsPerSecond"; - this.labelMaxCharsPerSecond.Size = new System.Drawing.Size(80, 13); - this.labelMaxCharsPerSecond.TabIndex = 5; - this.labelMaxCharsPerSecond.Text = "Max. chars/sec"; - // - // numericUpDownSeconds - // - this.numericUpDownSeconds.DecimalPlaces = 3; - this.numericUpDownSeconds.Increment = new decimal(new int[] { - 1, - 0, - 0, - 131072}); - this.numericUpDownSeconds.Location = new System.Drawing.Point(13, 89); - this.numericUpDownSeconds.Maximum = new decimal(new int[] { - 20, - 0, - 0, - 0}); - this.numericUpDownSeconds.Minimum = new decimal(new int[] { - 10, - 0, - 0, - -2147483648}); - this.numericUpDownSeconds.Name = "numericUpDownSeconds"; - this.numericUpDownSeconds.Size = new System.Drawing.Size(80, 21); - this.numericUpDownSeconds.TabIndex = 3; - this.numericUpDownSeconds.Value = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - // - // numericUpDownPercent - // - this.numericUpDownPercent.Location = new System.Drawing.Point(182, 89); - this.numericUpDownPercent.Maximum = new decimal(new int[] { - 150, - 0, - 0, - 0}); - this.numericUpDownPercent.Minimum = new decimal(new int[] { - 75, - 0, - 0, - 0}); - this.numericUpDownPercent.Name = "numericUpDownPercent"; - this.numericUpDownPercent.Size = new System.Drawing.Size(80, 21); - this.numericUpDownPercent.TabIndex = 4; - this.numericUpDownPercent.Value = new decimal(new int[] { - 110, - 0, - 0, - 0}); - // - // numericUpDownOptimalCharsSec - // - this.numericUpDownOptimalCharsSec.DecimalPlaces = 1; - this.numericUpDownOptimalCharsSec.Enabled = false; - this.numericUpDownOptimalCharsSec.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownOptimalCharsSec.Location = new System.Drawing.Point(357, 147); - this.numericUpDownOptimalCharsSec.Minimum = new decimal(new int[] { - 4, - 0, - 0, - 0}); - this.numericUpDownOptimalCharsSec.Name = "numericUpDownOptimalCharsSec"; - this.numericUpDownOptimalCharsSec.Size = new System.Drawing.Size(80, 21); - this.numericUpDownOptimalCharsSec.TabIndex = 7; - this.numericUpDownOptimalCharsSec.Value = new decimal(new int[] { - 17, - 0, - 0, - 0}); - // - // labelOptimalCharsSec - // - this.labelOptimalCharsSec.AutoSize = true; - this.labelOptimalCharsSec.Location = new System.Drawing.Point(354, 128); - this.labelOptimalCharsSec.Name = "labelOptimalCharsSec"; - this.labelOptimalCharsSec.Size = new System.Drawing.Size(92, 13); - this.labelOptimalCharsSec.TabIndex = 10; - this.labelOptimalCharsSec.Text = "Optimal chars/sec"; - // - // numericUpDownFixedMilliseconds - // - this.numericUpDownFixedMilliseconds.Enabled = false; - this.numericUpDownFixedMilliseconds.Location = new System.Drawing.Point(501, 89); - this.numericUpDownFixedMilliseconds.Maximum = new decimal(new int[] { - 20000, - 0, - 0, - 0}); - this.numericUpDownFixedMilliseconds.Name = "numericUpDownFixedMilliseconds"; - this.numericUpDownFixedMilliseconds.Size = new System.Drawing.Size(80, 21); - this.numericUpDownFixedMilliseconds.TabIndex = 9; - this.numericUpDownFixedMilliseconds.Value = new decimal(new int[] { - 3000, - 0, - 0, - 0}); - // - // labelMillisecondsFixed - // - this.labelMillisecondsFixed.AutoSize = true; - this.labelMillisecondsFixed.Location = new System.Drawing.Point(498, 70); - this.labelMillisecondsFixed.Name = "labelMillisecondsFixed"; - this.labelMillisecondsFixed.Size = new System.Drawing.Size(62, 13); - this.labelMillisecondsFixed.TabIndex = 12; - this.labelMillisecondsFixed.Text = "Milliseconds"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(264, 93); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(18, 13); - this.label1.TabIndex = 22; - this.label1.Text = "%"; - // - // checkBoxExtendOnly - // - this.checkBoxExtendOnly.AutoSize = true; - this.checkBoxExtendOnly.Location = new System.Drawing.Point(357, 184); - this.checkBoxExtendOnly.Name = "checkBoxExtendOnly"; - this.checkBoxExtendOnly.Size = new System.Drawing.Size(83, 17); - this.checkBoxExtendOnly.TabIndex = 8; - this.checkBoxExtendOnly.Text = "Extend only"; - this.checkBoxExtendOnly.UseVisualStyleBackColor = true; - // - // AdjustDisplayDuration - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(624, 268); - this.Controls.Add(this.checkBoxExtendOnly); - this.Controls.Add(this.label1); - this.Controls.Add(this.numericUpDownFixedMilliseconds); - this.Controls.Add(this.labelMillisecondsFixed); - this.Controls.Add(this.numericUpDownOptimalCharsSec); - this.Controls.Add(this.labelOptimalCharsSec); - this.Controls.Add(this.numericUpDownPercent); - this.Controls.Add(this.numericUpDownSeconds); - this.Controls.Add(this.numericUpDownMaxCharsSec); - this.Controls.Add(this.labelMaxCharsPerSecond); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.labelAddSeconds); - this.Controls.Add(this.labelAddInPercent); - this.Controls.Add(this.labelNote); - this.Controls.Add(this.groupBoxAdjustVia); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "AdjustDisplayDuration"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Adjust display time"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormAdjustDisplayTime_KeyDown); - this.groupBoxAdjustVia.ResumeLayout(false); - this.groupBoxAdjustVia.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharsSec)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFixedMilliseconds)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.RadioButton radioButtonPercent; - private System.Windows.Forms.RadioButton radioButtonSeconds; - private System.Windows.Forms.GroupBox groupBoxAdjustVia; - private System.Windows.Forms.Label labelNote; - private System.Windows.Forms.Label labelAddInPercent; - private System.Windows.Forms.Label labelAddSeconds; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.RadioButton radioButtonAutoRecalculate; - private System.Windows.Forms.NumericUpDown numericUpDownMaxCharsSec; - private System.Windows.Forms.Label labelMaxCharsPerSecond; - private System.Windows.Forms.NumericUpDown numericUpDownSeconds; - private System.Windows.Forms.NumericUpDown numericUpDownPercent; - private System.Windows.Forms.NumericUpDown numericUpDownOptimalCharsSec; - private System.Windows.Forms.Label labelOptimalCharsSec; - private System.Windows.Forms.RadioButton radioButtonFixed; - private System.Windows.Forms.NumericUpDown numericUpDownFixedMilliseconds; - private System.Windows.Forms.Label labelMillisecondsFixed; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.CheckBox checkBoxExtendOnly; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class AdjustDisplayDuration + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.radioButtonPercent = new System.Windows.Forms.RadioButton(); + this.radioButtonSeconds = new System.Windows.Forms.RadioButton(); + this.groupBoxAdjustVia = new System.Windows.Forms.GroupBox(); + this.radioButtonFixed = new System.Windows.Forms.RadioButton(); + this.radioButtonAutoRecalculate = new System.Windows.Forms.RadioButton(); + this.labelNote = new System.Windows.Forms.Label(); + this.labelAddInPercent = new System.Windows.Forms.Label(); + this.labelAddSeconds = new System.Windows.Forms.Label(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.numericUpDownMaxCharsSec = new System.Windows.Forms.NumericUpDown(); + this.labelMaxCharsPerSecond = new System.Windows.Forms.Label(); + this.numericUpDownSeconds = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownPercent = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownOptimalCharsSec = new System.Windows.Forms.NumericUpDown(); + this.labelOptimalCharsSec = new System.Windows.Forms.Label(); + this.numericUpDownFixedMilliseconds = new System.Windows.Forms.NumericUpDown(); + this.labelMillisecondsFixed = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.checkBoxExtendOnly = new System.Windows.Forms.CheckBox(); + this.groupBoxAdjustVia.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharsSec)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFixedMilliseconds)).BeginInit(); + this.SuspendLayout(); + // + // radioButtonPercent + // + this.radioButtonPercent.AutoSize = true; + this.radioButtonPercent.Location = new System.Drawing.Point(171, 21); + this.radioButtonPercent.Name = "radioButtonPercent"; + this.radioButtonPercent.Size = new System.Drawing.Size(62, 17); + this.radioButtonPercent.TabIndex = 1; + this.radioButtonPercent.Text = "Percent"; + this.radioButtonPercent.UseVisualStyleBackColor = true; + this.radioButtonPercent.CheckedChanged += new System.EventHandler(this.RadioButtonPercentCheckedChanged); + // + // radioButtonSeconds + // + this.radioButtonSeconds.AutoSize = true; + this.radioButtonSeconds.Checked = true; + this.radioButtonSeconds.Location = new System.Drawing.Point(11, 21); + this.radioButtonSeconds.Name = "radioButtonSeconds"; + this.radioButtonSeconds.Size = new System.Drawing.Size(65, 17); + this.radioButtonSeconds.TabIndex = 0; + this.radioButtonSeconds.TabStop = true; + this.radioButtonSeconds.Text = "Seconds"; + this.radioButtonSeconds.UseVisualStyleBackColor = true; + this.radioButtonSeconds.CheckedChanged += new System.EventHandler(this.RadioButtonSecondsCheckedChanged); + // + // groupBoxAdjustVia + // + this.groupBoxAdjustVia.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxAdjustVia.Controls.Add(this.radioButtonFixed); + this.groupBoxAdjustVia.Controls.Add(this.radioButtonAutoRecalculate); + this.groupBoxAdjustVia.Controls.Add(this.radioButtonPercent); + this.groupBoxAdjustVia.Controls.Add(this.radioButtonSeconds); + this.groupBoxAdjustVia.Location = new System.Drawing.Point(13, 13); + this.groupBoxAdjustVia.Name = "groupBoxAdjustVia"; + this.groupBoxAdjustVia.Size = new System.Drawing.Size(599, 47); + this.groupBoxAdjustVia.TabIndex = 0; + this.groupBoxAdjustVia.TabStop = false; + this.groupBoxAdjustVia.Text = "Adjust via"; + // + // radioButtonFixed + // + this.radioButtonFixed.AutoSize = true; + this.radioButtonFixed.Location = new System.Drawing.Point(491, 21); + this.radioButtonFixed.Name = "radioButtonFixed"; + this.radioButtonFixed.Size = new System.Drawing.Size(51, 17); + this.radioButtonFixed.TabIndex = 3; + this.radioButtonFixed.Text = "Fixed"; + this.radioButtonFixed.UseVisualStyleBackColor = true; + this.radioButtonFixed.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); + // + // radioButtonAutoRecalculate + // + this.radioButtonAutoRecalculate.AutoSize = true; + this.radioButtonAutoRecalculate.Location = new System.Drawing.Point(344, 21); + this.radioButtonAutoRecalculate.Name = "radioButtonAutoRecalculate"; + this.radioButtonAutoRecalculate.Size = new System.Drawing.Size(80, 17); + this.radioButtonAutoRecalculate.TabIndex = 2; + this.radioButtonAutoRecalculate.Text = "Recalculate"; + this.radioButtonAutoRecalculate.UseVisualStyleBackColor = true; + this.radioButtonAutoRecalculate.CheckedChanged += new System.EventHandler(this.radioButtonAutoRecalculate_CheckedChanged); + // + // labelNote + // + this.labelNote.AutoSize = true; + this.labelNote.Location = new System.Drawing.Point(10, 211); + this.labelNote.Name = "labelNote"; + this.labelNote.Size = new System.Drawing.Size(279, 13); + this.labelNote.TabIndex = 7; + this.labelNote.Text = "Note: Display time will not overlap start time of next text"; + // + // labelAddInPercent + // + this.labelAddInPercent.AutoSize = true; + this.labelAddInPercent.Location = new System.Drawing.Point(179, 70); + this.labelAddInPercent.Name = "labelAddInPercent"; + this.labelAddInPercent.Size = new System.Drawing.Size(89, 13); + this.labelAddInPercent.TabIndex = 3; + this.labelAddInPercent.Text = "Adjust in percent"; + // + // labelAddSeconds + // + this.labelAddSeconds.AutoSize = true; + this.labelAddSeconds.Location = new System.Drawing.Point(10, 70); + this.labelAddSeconds.Name = "labelAddSeconds"; + this.labelAddSeconds.Size = new System.Drawing.Size(68, 13); + this.labelAddSeconds.TabIndex = 1; + this.labelAddSeconds.Text = "Add seconds"; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(537, 231); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 21; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(456, 231); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 20; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // numericUpDownMaxCharsSec + // + this.numericUpDownMaxCharsSec.DecimalPlaces = 1; + this.numericUpDownMaxCharsSec.Enabled = false; + this.numericUpDownMaxCharsSec.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownMaxCharsSec.Location = new System.Drawing.Point(357, 89); + this.numericUpDownMaxCharsSec.Minimum = new decimal(new int[] { + 4, + 0, + 0, + 0}); + this.numericUpDownMaxCharsSec.Name = "numericUpDownMaxCharsSec"; + this.numericUpDownMaxCharsSec.Size = new System.Drawing.Size(80, 21); + this.numericUpDownMaxCharsSec.TabIndex = 6; + this.numericUpDownMaxCharsSec.Value = new decimal(new int[] { + 24, + 0, + 0, + 0}); + // + // labelMaxCharsPerSecond + // + this.labelMaxCharsPerSecond.AutoSize = true; + this.labelMaxCharsPerSecond.Location = new System.Drawing.Point(354, 70); + this.labelMaxCharsPerSecond.Name = "labelMaxCharsPerSecond"; + this.labelMaxCharsPerSecond.Size = new System.Drawing.Size(80, 13); + this.labelMaxCharsPerSecond.TabIndex = 5; + this.labelMaxCharsPerSecond.Text = "Max. chars/sec"; + // + // numericUpDownSeconds + // + this.numericUpDownSeconds.DecimalPlaces = 3; + this.numericUpDownSeconds.Increment = new decimal(new int[] { + 1, + 0, + 0, + 131072}); + this.numericUpDownSeconds.Location = new System.Drawing.Point(13, 89); + this.numericUpDownSeconds.Maximum = new decimal(new int[] { + 20, + 0, + 0, + 0}); + this.numericUpDownSeconds.Minimum = new decimal(new int[] { + 10, + 0, + 0, + -2147483648}); + this.numericUpDownSeconds.Name = "numericUpDownSeconds"; + this.numericUpDownSeconds.Size = new System.Drawing.Size(80, 21); + this.numericUpDownSeconds.TabIndex = 3; + this.numericUpDownSeconds.Value = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + // + // numericUpDownPercent + // + this.numericUpDownPercent.Location = new System.Drawing.Point(182, 89); + this.numericUpDownPercent.Maximum = new decimal(new int[] { + 150, + 0, + 0, + 0}); + this.numericUpDownPercent.Minimum = new decimal(new int[] { + 75, + 0, + 0, + 0}); + this.numericUpDownPercent.Name = "numericUpDownPercent"; + this.numericUpDownPercent.Size = new System.Drawing.Size(80, 21); + this.numericUpDownPercent.TabIndex = 4; + this.numericUpDownPercent.Value = new decimal(new int[] { + 110, + 0, + 0, + 0}); + // + // numericUpDownOptimalCharsSec + // + this.numericUpDownOptimalCharsSec.DecimalPlaces = 1; + this.numericUpDownOptimalCharsSec.Enabled = false; + this.numericUpDownOptimalCharsSec.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownOptimalCharsSec.Location = new System.Drawing.Point(357, 147); + this.numericUpDownOptimalCharsSec.Minimum = new decimal(new int[] { + 4, + 0, + 0, + 0}); + this.numericUpDownOptimalCharsSec.Name = "numericUpDownOptimalCharsSec"; + this.numericUpDownOptimalCharsSec.Size = new System.Drawing.Size(80, 21); + this.numericUpDownOptimalCharsSec.TabIndex = 7; + this.numericUpDownOptimalCharsSec.Value = new decimal(new int[] { + 17, + 0, + 0, + 0}); + // + // labelOptimalCharsSec + // + this.labelOptimalCharsSec.AutoSize = true; + this.labelOptimalCharsSec.Location = new System.Drawing.Point(354, 128); + this.labelOptimalCharsSec.Name = "labelOptimalCharsSec"; + this.labelOptimalCharsSec.Size = new System.Drawing.Size(92, 13); + this.labelOptimalCharsSec.TabIndex = 10; + this.labelOptimalCharsSec.Text = "Optimal chars/sec"; + // + // numericUpDownFixedMilliseconds + // + this.numericUpDownFixedMilliseconds.Enabled = false; + this.numericUpDownFixedMilliseconds.Location = new System.Drawing.Point(501, 89); + this.numericUpDownFixedMilliseconds.Maximum = new decimal(new int[] { + 20000, + 0, + 0, + 0}); + this.numericUpDownFixedMilliseconds.Name = "numericUpDownFixedMilliseconds"; + this.numericUpDownFixedMilliseconds.Size = new System.Drawing.Size(80, 21); + this.numericUpDownFixedMilliseconds.TabIndex = 9; + this.numericUpDownFixedMilliseconds.Value = new decimal(new int[] { + 3000, + 0, + 0, + 0}); + // + // labelMillisecondsFixed + // + this.labelMillisecondsFixed.AutoSize = true; + this.labelMillisecondsFixed.Location = new System.Drawing.Point(498, 70); + this.labelMillisecondsFixed.Name = "labelMillisecondsFixed"; + this.labelMillisecondsFixed.Size = new System.Drawing.Size(62, 13); + this.labelMillisecondsFixed.TabIndex = 12; + this.labelMillisecondsFixed.Text = "Milliseconds"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(264, 93); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(18, 13); + this.label1.TabIndex = 22; + this.label1.Text = "%"; + // + // checkBoxExtendOnly + // + this.checkBoxExtendOnly.AutoSize = true; + this.checkBoxExtendOnly.Location = new System.Drawing.Point(357, 184); + this.checkBoxExtendOnly.Name = "checkBoxExtendOnly"; + this.checkBoxExtendOnly.Size = new System.Drawing.Size(83, 17); + this.checkBoxExtendOnly.TabIndex = 8; + this.checkBoxExtendOnly.Text = "Extend only"; + this.checkBoxExtendOnly.UseVisualStyleBackColor = true; + // + // AdjustDisplayDuration + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(624, 268); + this.Controls.Add(this.checkBoxExtendOnly); + this.Controls.Add(this.label1); + this.Controls.Add(this.numericUpDownFixedMilliseconds); + this.Controls.Add(this.labelMillisecondsFixed); + this.Controls.Add(this.numericUpDownOptimalCharsSec); + this.Controls.Add(this.labelOptimalCharsSec); + this.Controls.Add(this.numericUpDownPercent); + this.Controls.Add(this.numericUpDownSeconds); + this.Controls.Add(this.numericUpDownMaxCharsSec); + this.Controls.Add(this.labelMaxCharsPerSecond); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.labelAddSeconds); + this.Controls.Add(this.labelAddInPercent); + this.Controls.Add(this.labelNote); + this.Controls.Add(this.groupBoxAdjustVia); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "AdjustDisplayDuration"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Adjust display time"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormAdjustDisplayTime_KeyDown); + this.groupBoxAdjustVia.ResumeLayout(false); + this.groupBoxAdjustVia.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharsSec)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFixedMilliseconds)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.RadioButton radioButtonPercent; + private System.Windows.Forms.RadioButton radioButtonSeconds; + private System.Windows.Forms.GroupBox groupBoxAdjustVia; + private System.Windows.Forms.Label labelNote; + private System.Windows.Forms.Label labelAddInPercent; + private System.Windows.Forms.Label labelAddSeconds; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.RadioButton radioButtonAutoRecalculate; + private System.Windows.Forms.NumericUpDown numericUpDownMaxCharsSec; + private System.Windows.Forms.Label labelMaxCharsPerSecond; + private System.Windows.Forms.NumericUpDown numericUpDownSeconds; + private System.Windows.Forms.NumericUpDown numericUpDownPercent; + private System.Windows.Forms.NumericUpDown numericUpDownOptimalCharsSec; + private System.Windows.Forms.Label labelOptimalCharsSec; + private System.Windows.Forms.RadioButton radioButtonFixed; + private System.Windows.Forms.NumericUpDown numericUpDownFixedMilliseconds; + private System.Windows.Forms.Label labelMillisecondsFixed; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.CheckBox checkBoxExtendOnly; + } } \ No newline at end of file diff --git a/src/Forms/AdjustDisplayDuration.cs b/src/ui/Forms/AdjustDisplayDuration.cs similarity index 97% rename from src/Forms/AdjustDisplayDuration.cs rename to src/ui/Forms/AdjustDisplayDuration.cs index 73f169553..d7a4e4f9d 100644 --- a/src/Forms/AdjustDisplayDuration.cs +++ b/src/ui/Forms/AdjustDisplayDuration.cs @@ -1,198 +1,198 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Globalization; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class AdjustDisplayDuration : PositionAndSizeForm - { - internal const string Sec = "seconds"; - internal const string Per = "percent"; - internal const string Recal = "recalc"; - internal const string Fixed = "fixed"; - - public string AdjustValue - { - get - { - if (radioButtonPercent.Checked) - { - return numericUpDownPercent.Value.ToString(CultureInfo.InvariantCulture); - } - - if (radioButtonAutoRecalculate.Checked) - { - return $"{radioButtonAutoRecalculate.Text}, {labelMaxCharsPerSecond.Text}: {numericUpDownMaxCharsSec.Value}"; - } - - return numericUpDownSeconds.Value.ToString(CultureInfo.InvariantCulture); - } - } - - public bool AdjustUsingPercent => radioButtonPercent.Checked; - - public bool AdjustUsingSeconds => radioButtonSeconds.Checked; - - public bool AdjustUsingRecalc => radioButtonAutoRecalculate.Checked; - - public decimal MaxCharactersPerSecond => numericUpDownMaxCharsSec.Value; - - public decimal OptimalCharactersPerSecond => numericUpDownOptimalCharsSec.Value; - - public int FixedMilliseconds => (int)numericUpDownFixedMilliseconds.Value; - - public bool ExtendOnly => checkBoxExtendOnly.Checked; - - public AdjustDisplayDuration() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Icon = Properties.Resources.SubtitleEditFormIcon; - - numericUpDownSeconds.Enabled = false; - numericUpDownPercent.Enabled = false; - - decimal adjustSeconds = Configuration.Settings.Tools.AdjustDurationSeconds; - if (adjustSeconds >= numericUpDownSeconds.Minimum && adjustSeconds <= numericUpDownSeconds.Maximum) - { - numericUpDownSeconds.Value = adjustSeconds; - } - - int adjustPercent = Configuration.Settings.Tools.AdjustDurationPercent; - if (adjustPercent >= numericUpDownPercent.Minimum && adjustPercent <= numericUpDownPercent.Maximum) - { - numericUpDownPercent.Value = adjustPercent; - } - - numericUpDownOptimalCharsSec.Value = (decimal)Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds; - numericUpDownMaxCharsSec.Value = (decimal)Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds; - - checkBoxExtendOnly.Checked = Configuration.Settings.Tools.AdjustDurationExtendOnly; - - LanguageStructure.AdjustDisplayDuration language = Configuration.Settings.Language.AdjustDisplayDuration; - Text = language.Title; - groupBoxAdjustVia.Text = language.AdjustVia; - radioButtonSeconds.Text = language.Seconds; - radioButtonPercent.Text = language.Percent; - radioButtonAutoRecalculate.Text = language.Recalculate; - labelOptimalCharsSec.Text = Configuration.Settings.Language.Settings.OptimalCharactersPerSecond; - labelMaxCharsPerSecond.Text = Configuration.Settings.Language.Settings.MaximumCharactersPerSecond; - labelAddSeconds.Text = language.AddSeconds; - labelAddInPercent.Text = language.SetAsPercent; - labelNote.Text = language.Note; - radioButtonFixed.Text = language.Fixed; - labelMillisecondsFixed.Text = language.Milliseconds; - checkBoxExtendOnly.Text = language.ExtendOnly; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - FixLargeFonts(); - - switch (Configuration.Settings.Tools.AdjustDurationLast) - { - case Sec: - radioButtonSeconds.Checked = true; - break; - case Per: - radioButtonPercent.Checked = true; - break; - case Recal: - radioButtonAutoRecalculate.Checked = true; - break; - case Fixed: - radioButtonFixed.Checked = true; - break; - } - FixEnabled(); - } - - private void FixLargeFonts() - { - if (labelNote.Left + labelNote.Width + 5 > Width) - { - Width = labelNote.Left + labelNote.Width + 5; - } - - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void FormAdjustDisplayTime_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void RadioButtonPercentCheckedChanged(object sender, EventArgs e) - { - FixEnabled(); - } - - private void FixEnabled() - { - numericUpDownPercent.Enabled = radioButtonPercent.Checked; - numericUpDownSeconds.Enabled = radioButtonSeconds.Checked; - numericUpDownMaxCharsSec.Enabled = radioButtonAutoRecalculate.Checked; - numericUpDownOptimalCharsSec.Enabled = radioButtonAutoRecalculate.Checked; - checkBoxExtendOnly.Enabled = radioButtonAutoRecalculate.Checked; - numericUpDownFixedMilliseconds.Enabled = radioButtonFixed.Checked; - } - - private void RadioButtonSecondsCheckedChanged(object sender, EventArgs e) - { - FixEnabled(); - } - - private void ButtonOkClick(object sender, EventArgs e) - { - Configuration.Settings.Tools.AdjustDurationSeconds = numericUpDownSeconds.Value; - Configuration.Settings.Tools.AdjustDurationPercent = (int)numericUpDownPercent.Value; - Configuration.Settings.Tools.AdjustDurationExtendOnly = checkBoxExtendOnly.Checked; - - if (radioButtonSeconds.Checked) - { - Configuration.Settings.Tools.AdjustDurationLast = Sec; - } - else if (radioButtonPercent.Checked) - { - Configuration.Settings.Tools.AdjustDurationLast = Per; - } - else if (radioButtonAutoRecalculate.Checked) - { - Configuration.Settings.Tools.AdjustDurationLast = Recal; - } - else if (radioButtonFixed.Checked) - { - Configuration.Settings.Tools.AdjustDurationLast = Fixed; - } - - DialogResult = DialogResult.OK; - } - - public void HideRecalculate() - { - if (radioButtonAutoRecalculate.Checked) - { - radioButtonSeconds.Checked = true; - } - - radioButtonAutoRecalculate.Visible = false; - labelMaxCharsPerSecond.Visible = false; - numericUpDownMaxCharsSec.Visible = false; - } - - private void radioButton1_CheckedChanged(object sender, EventArgs e) - { - FixEnabled(); - } - - private void radioButtonAutoRecalculate_CheckedChanged(object sender, EventArgs e) - { - FixEnabled(); - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Globalization; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class AdjustDisplayDuration : PositionAndSizeForm + { + internal const string Sec = "seconds"; + internal const string Per = "percent"; + internal const string Recal = "recalc"; + internal const string Fixed = "fixed"; + + public string AdjustValue + { + get + { + if (radioButtonPercent.Checked) + { + return numericUpDownPercent.Value.ToString(CultureInfo.InvariantCulture); + } + + if (radioButtonAutoRecalculate.Checked) + { + return $"{radioButtonAutoRecalculate.Text}, {labelMaxCharsPerSecond.Text}: {numericUpDownMaxCharsSec.Value}"; + } + + return numericUpDownSeconds.Value.ToString(CultureInfo.InvariantCulture); + } + } + + public bool AdjustUsingPercent => radioButtonPercent.Checked; + + public bool AdjustUsingSeconds => radioButtonSeconds.Checked; + + public bool AdjustUsingRecalc => radioButtonAutoRecalculate.Checked; + + public decimal MaxCharactersPerSecond => numericUpDownMaxCharsSec.Value; + + public decimal OptimalCharactersPerSecond => numericUpDownOptimalCharsSec.Value; + + public int FixedMilliseconds => (int)numericUpDownFixedMilliseconds.Value; + + public bool ExtendOnly => checkBoxExtendOnly.Checked; + + public AdjustDisplayDuration() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Icon = Properties.Resources.SubtitleEditFormIcon; + + numericUpDownSeconds.Enabled = false; + numericUpDownPercent.Enabled = false; + + decimal adjustSeconds = Configuration.Settings.Tools.AdjustDurationSeconds; + if (adjustSeconds >= numericUpDownSeconds.Minimum && adjustSeconds <= numericUpDownSeconds.Maximum) + { + numericUpDownSeconds.Value = adjustSeconds; + } + + int adjustPercent = Configuration.Settings.Tools.AdjustDurationPercent; + if (adjustPercent >= numericUpDownPercent.Minimum && adjustPercent <= numericUpDownPercent.Maximum) + { + numericUpDownPercent.Value = adjustPercent; + } + + numericUpDownOptimalCharsSec.Value = (decimal)Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds; + numericUpDownMaxCharsSec.Value = (decimal)Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds; + + checkBoxExtendOnly.Checked = Configuration.Settings.Tools.AdjustDurationExtendOnly; + + LanguageStructure.AdjustDisplayDuration language = Configuration.Settings.Language.AdjustDisplayDuration; + Text = language.Title; + groupBoxAdjustVia.Text = language.AdjustVia; + radioButtonSeconds.Text = language.Seconds; + radioButtonPercent.Text = language.Percent; + radioButtonAutoRecalculate.Text = language.Recalculate; + labelOptimalCharsSec.Text = Configuration.Settings.Language.Settings.OptimalCharactersPerSecond; + labelMaxCharsPerSecond.Text = Configuration.Settings.Language.Settings.MaximumCharactersPerSecond; + labelAddSeconds.Text = language.AddSeconds; + labelAddInPercent.Text = language.SetAsPercent; + labelNote.Text = language.Note; + radioButtonFixed.Text = language.Fixed; + labelMillisecondsFixed.Text = language.Milliseconds; + checkBoxExtendOnly.Text = language.ExtendOnly; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + FixLargeFonts(); + + switch (Configuration.Settings.Tools.AdjustDurationLast) + { + case Sec: + radioButtonSeconds.Checked = true; + break; + case Per: + radioButtonPercent.Checked = true; + break; + case Recal: + radioButtonAutoRecalculate.Checked = true; + break; + case Fixed: + radioButtonFixed.Checked = true; + break; + } + FixEnabled(); + } + + private void FixLargeFonts() + { + if (labelNote.Left + labelNote.Width + 5 > Width) + { + Width = labelNote.Left + labelNote.Width + 5; + } + + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void FormAdjustDisplayTime_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void RadioButtonPercentCheckedChanged(object sender, EventArgs e) + { + FixEnabled(); + } + + private void FixEnabled() + { + numericUpDownPercent.Enabled = radioButtonPercent.Checked; + numericUpDownSeconds.Enabled = radioButtonSeconds.Checked; + numericUpDownMaxCharsSec.Enabled = radioButtonAutoRecalculate.Checked; + numericUpDownOptimalCharsSec.Enabled = radioButtonAutoRecalculate.Checked; + checkBoxExtendOnly.Enabled = radioButtonAutoRecalculate.Checked; + numericUpDownFixedMilliseconds.Enabled = radioButtonFixed.Checked; + } + + private void RadioButtonSecondsCheckedChanged(object sender, EventArgs e) + { + FixEnabled(); + } + + private void ButtonOkClick(object sender, EventArgs e) + { + Configuration.Settings.Tools.AdjustDurationSeconds = numericUpDownSeconds.Value; + Configuration.Settings.Tools.AdjustDurationPercent = (int)numericUpDownPercent.Value; + Configuration.Settings.Tools.AdjustDurationExtendOnly = checkBoxExtendOnly.Checked; + + if (radioButtonSeconds.Checked) + { + Configuration.Settings.Tools.AdjustDurationLast = Sec; + } + else if (radioButtonPercent.Checked) + { + Configuration.Settings.Tools.AdjustDurationLast = Per; + } + else if (radioButtonAutoRecalculate.Checked) + { + Configuration.Settings.Tools.AdjustDurationLast = Recal; + } + else if (radioButtonFixed.Checked) + { + Configuration.Settings.Tools.AdjustDurationLast = Fixed; + } + + DialogResult = DialogResult.OK; + } + + public void HideRecalculate() + { + if (radioButtonAutoRecalculate.Checked) + { + radioButtonSeconds.Checked = true; + } + + radioButtonAutoRecalculate.Visible = false; + labelMaxCharsPerSecond.Visible = false; + numericUpDownMaxCharsSec.Visible = false; + } + + private void radioButton1_CheckedChanged(object sender, EventArgs e) + { + FixEnabled(); + } + + private void radioButtonAutoRecalculate_CheckedChanged(object sender, EventArgs e) + { + FixEnabled(); + } + } +} diff --git a/src/Forms/AdjustDisplayDuration.resx b/src/ui/Forms/AdjustDisplayDuration.resx similarity index 97% rename from src/Forms/AdjustDisplayDuration.resx rename to src/ui/Forms/AdjustDisplayDuration.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/AdjustDisplayDuration.resx +++ b/src/ui/Forms/AdjustDisplayDuration.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/AlignmentPicker.Designer.cs b/src/ui/Forms/AlignmentPicker.Designer.cs similarity index 97% rename from src/Forms/AlignmentPicker.Designer.cs rename to src/ui/Forms/AlignmentPicker.Designer.cs index 1bd08208b..9e83792ad 100644 --- a/src/Forms/AlignmentPicker.Designer.cs +++ b/src/ui/Forms/AlignmentPicker.Designer.cs @@ -1,178 +1,178 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class AlignmentPicker - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.panel1 = new System.Windows.Forms.Panel(); - this.button9 = new System.Windows.Forms.Button(); - this.button8 = new System.Windows.Forms.Button(); - this.button7 = new System.Windows.Forms.Button(); - this.button6 = new System.Windows.Forms.Button(); - this.button5 = new System.Windows.Forms.Button(); - this.button4 = new System.Windows.Forms.Button(); - this.button3 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.button1 = new System.Windows.Forms.Button(); - this.panel1.SuspendLayout(); - this.SuspendLayout(); - // - // panel1 - // - this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.panel1.Controls.Add(this.button9); - this.panel1.Controls.Add(this.button8); - this.panel1.Controls.Add(this.button7); - this.panel1.Controls.Add(this.button6); - this.panel1.Controls.Add(this.button5); - this.panel1.Controls.Add(this.button4); - this.panel1.Controls.Add(this.button3); - this.panel1.Controls.Add(this.button2); - this.panel1.Controls.Add(this.button1); - this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(309, 106); - this.panel1.TabIndex = 0; - // - // button9 - // - this.button9.Location = new System.Drawing.Point(202, 68); - this.button9.Name = "button9"; - this.button9.Size = new System.Drawing.Size(90, 23); - this.button9.TabIndex = 9; - this.button9.UseVisualStyleBackColor = true; - this.button9.Click += new System.EventHandler(this.button9_Click); - // - // button8 - // - this.button8.Location = new System.Drawing.Point(106, 68); - this.button8.Name = "button8"; - this.button8.Size = new System.Drawing.Size(90, 23); - this.button8.TabIndex = 8; - this.button8.UseVisualStyleBackColor = true; - this.button8.Click += new System.EventHandler(this.button8_Click); - // - // button7 - // - this.button7.Location = new System.Drawing.Point(10, 68); - this.button7.Name = "button7"; - this.button7.Size = new System.Drawing.Size(90, 23); - this.button7.TabIndex = 7; - this.button7.UseVisualStyleBackColor = true; - this.button7.Click += new System.EventHandler(this.button7_Click); - // - // button6 - // - this.button6.Location = new System.Drawing.Point(202, 39); - this.button6.Name = "button6"; - this.button6.Size = new System.Drawing.Size(90, 23); - this.button6.TabIndex = 6; - this.button6.UseVisualStyleBackColor = true; - this.button6.Click += new System.EventHandler(this.button6_Click); - // - // button5 - // - this.button5.Location = new System.Drawing.Point(106, 39); - this.button5.Name = "button5"; - this.button5.Size = new System.Drawing.Size(90, 23); - this.button5.TabIndex = 5; - this.button5.UseVisualStyleBackColor = true; - this.button5.Click += new System.EventHandler(this.button5_Click); - // - // button4 - // - this.button4.Location = new System.Drawing.Point(10, 39); - this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(90, 23); - this.button4.TabIndex = 4; - this.button4.UseVisualStyleBackColor = true; - this.button4.Click += new System.EventHandler(this.button4_Click); - // - // button3 - // - this.button3.Location = new System.Drawing.Point(202, 10); - this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(90, 23); - this.button3.TabIndex = 3; - this.button3.UseVisualStyleBackColor = true; - this.button3.Click += new System.EventHandler(this.button3_Click); - // - // button2 - // - this.button2.Location = new System.Drawing.Point(106, 10); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(90, 23); - this.button2.TabIndex = 2; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // - // button1 - // - this.button1.Location = new System.Drawing.Point(10, 10); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(90, 23); - this.button1.TabIndex = 1; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // AlignmentPicker - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(309, 106); - this.Controls.Add(this.panel1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "AlignmentPicker"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; - this.Text = "Alignment"; - this.Shown += new System.EventHandler(this.AlignmentPicker_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.AlignmentPicker_KeyDown); - this.panel1.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Button button9; - private System.Windows.Forms.Button button8; - private System.Windows.Forms.Button button7; - private System.Windows.Forms.Button button6; - private System.Windows.Forms.Button button5; - private System.Windows.Forms.Button button4; - private System.Windows.Forms.Button button3; - private System.Windows.Forms.Button button2; - private System.Windows.Forms.Button button1; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class AlignmentPicker + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.button9 = new System.Windows.Forms.Button(); + this.button8 = new System.Windows.Forms.Button(); + this.button7 = new System.Windows.Forms.Button(); + this.button6 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.button4 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.panel1.Controls.Add(this.button9); + this.panel1.Controls.Add(this.button8); + this.panel1.Controls.Add(this.button7); + this.panel1.Controls.Add(this.button6); + this.panel1.Controls.Add(this.button5); + this.panel1.Controls.Add(this.button4); + this.panel1.Controls.Add(this.button3); + this.panel1.Controls.Add(this.button2); + this.panel1.Controls.Add(this.button1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(309, 106); + this.panel1.TabIndex = 0; + // + // button9 + // + this.button9.Location = new System.Drawing.Point(202, 68); + this.button9.Name = "button9"; + this.button9.Size = new System.Drawing.Size(90, 23); + this.button9.TabIndex = 9; + this.button9.UseVisualStyleBackColor = true; + this.button9.Click += new System.EventHandler(this.button9_Click); + // + // button8 + // + this.button8.Location = new System.Drawing.Point(106, 68); + this.button8.Name = "button8"; + this.button8.Size = new System.Drawing.Size(90, 23); + this.button8.TabIndex = 8; + this.button8.UseVisualStyleBackColor = true; + this.button8.Click += new System.EventHandler(this.button8_Click); + // + // button7 + // + this.button7.Location = new System.Drawing.Point(10, 68); + this.button7.Name = "button7"; + this.button7.Size = new System.Drawing.Size(90, 23); + this.button7.TabIndex = 7; + this.button7.UseVisualStyleBackColor = true; + this.button7.Click += new System.EventHandler(this.button7_Click); + // + // button6 + // + this.button6.Location = new System.Drawing.Point(202, 39); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(90, 23); + this.button6.TabIndex = 6; + this.button6.UseVisualStyleBackColor = true; + this.button6.Click += new System.EventHandler(this.button6_Click); + // + // button5 + // + this.button5.Location = new System.Drawing.Point(106, 39); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(90, 23); + this.button5.TabIndex = 5; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.button5_Click); + // + // button4 + // + this.button4.Location = new System.Drawing.Point(10, 39); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(90, 23); + this.button4.TabIndex = 4; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.button4_Click); + // + // button3 + // + this.button3.Location = new System.Drawing.Point(202, 10); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(90, 23); + this.button3.TabIndex = 3; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(106, 10); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(90, 23); + this.button2.TabIndex = 2; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(10, 10); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(90, 23); + this.button1.TabIndex = 1; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // AlignmentPicker + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(309, 106); + this.Controls.Add(this.panel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "AlignmentPicker"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.Text = "Alignment"; + this.Shown += new System.EventHandler(this.AlignmentPicker_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.AlignmentPicker_KeyDown); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button button9; + private System.Windows.Forms.Button button8; + private System.Windows.Forms.Button button7; + private System.Windows.Forms.Button button6; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button1; + } } \ No newline at end of file diff --git a/src/Forms/AlignmentPicker.cs b/src/ui/Forms/AlignmentPicker.cs similarity index 96% rename from src/Forms/AlignmentPicker.cs rename to src/ui/Forms/AlignmentPicker.cs index 6062c9a76..bf63cc4f8 100644 --- a/src/Forms/AlignmentPicker.cs +++ b/src/ui/Forms/AlignmentPicker.cs @@ -1,145 +1,145 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Drawing; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class AlignmentPicker : Form - { - public ContentAlignment Alignment { get; private set; } - private readonly string _text; - - public AlignmentPicker(string text) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Text = Configuration.Settings.Language.SubStationAlphaStyles.Alignment; - - button1.Text = Configuration.Settings.Language.SubStationAlphaStyles.TopLeft; - button2.Text = Configuration.Settings.Language.SubStationAlphaStyles.TopCenter; - button3.Text = Configuration.Settings.Language.SubStationAlphaStyles.TopRight; - - button4.Text = Configuration.Settings.Language.SubStationAlphaStyles.MiddleLeft; - button5.Text = Configuration.Settings.Language.SubStationAlphaStyles.MiddleCenter; - button6.Text = Configuration.Settings.Language.SubStationAlphaStyles.MiddleRight; - - button7.Text = Configuration.Settings.Language.SubStationAlphaStyles.BottomLeft; - button8.Text = Configuration.Settings.Language.SubStationAlphaStyles.BottomCenter; - button9.Text = Configuration.Settings.Language.SubStationAlphaStyles.BottomRight; - - UiUtil.FixLargeFonts(this, button1); - _text = text; - } - - public void Done() - { - DialogResult = DialogResult.OK; - } - - private void button1_Click(object sender, EventArgs e) - { - Alignment = ContentAlignment.TopLeft; - Done(); - } - - private void button2_Click(object sender, EventArgs e) - { - Alignment = ContentAlignment.TopCenter; - Done(); - } - - private void button3_Click(object sender, EventArgs e) - { - Alignment = ContentAlignment.TopRight; - Done(); - } - - private void button4_Click(object sender, EventArgs e) - { - Alignment = ContentAlignment.MiddleLeft; - Done(); - } - - private void button5_Click(object sender, EventArgs e) - { - Alignment = ContentAlignment.MiddleCenter; - Done(); - } - - private void button6_Click(object sender, EventArgs e) - { - Alignment = ContentAlignment.MiddleRight; - Done(); - } - - private void button7_Click(object sender, EventArgs e) - { - Alignment = ContentAlignment.BottomLeft; - Done(); - } - - private void button8_Click(object sender, EventArgs e) - { - Alignment = ContentAlignment.BottomCenter; - Done(); - } - - private void button9_Click(object sender, EventArgs e) - { - Alignment = ContentAlignment.BottomRight; - Done(); - } - - private void AlignmentPicker_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void AlignmentPicker_Shown(object sender, EventArgs e) - { - if (_text.StartsWith("{\\an7}", StringComparison.Ordinal)) - { - button1.Focus(); - } - else if (_text.StartsWith("{\\an8}", StringComparison.Ordinal)) - { - button2.Focus(); - } - else if (_text.StartsWith("{\\an9}", StringComparison.Ordinal)) - { - button3.Focus(); - } - else if (_text.StartsWith("{\\an4}", StringComparison.Ordinal)) - { - button4.Focus(); - } - else if (_text.StartsWith("{\\an5}", StringComparison.Ordinal)) - { - button5.Focus(); - } - else if (_text.StartsWith("{\\an6}", StringComparison.Ordinal)) - { - button6.Focus(); - } - else if (_text.StartsWith("{\\an1}", StringComparison.Ordinal)) - { - button7.Focus(); - } - else if (_text.StartsWith("{\\an3}", StringComparison.Ordinal)) - { - button9.Focus(); - } - else - { - button8.Focus(); - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Drawing; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class AlignmentPicker : Form + { + public ContentAlignment Alignment { get; private set; } + private readonly string _text; + + public AlignmentPicker(string text) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Text = Configuration.Settings.Language.SubStationAlphaStyles.Alignment; + + button1.Text = Configuration.Settings.Language.SubStationAlphaStyles.TopLeft; + button2.Text = Configuration.Settings.Language.SubStationAlphaStyles.TopCenter; + button3.Text = Configuration.Settings.Language.SubStationAlphaStyles.TopRight; + + button4.Text = Configuration.Settings.Language.SubStationAlphaStyles.MiddleLeft; + button5.Text = Configuration.Settings.Language.SubStationAlphaStyles.MiddleCenter; + button6.Text = Configuration.Settings.Language.SubStationAlphaStyles.MiddleRight; + + button7.Text = Configuration.Settings.Language.SubStationAlphaStyles.BottomLeft; + button8.Text = Configuration.Settings.Language.SubStationAlphaStyles.BottomCenter; + button9.Text = Configuration.Settings.Language.SubStationAlphaStyles.BottomRight; + + UiUtil.FixLargeFonts(this, button1); + _text = text; + } + + public void Done() + { + DialogResult = DialogResult.OK; + } + + private void button1_Click(object sender, EventArgs e) + { + Alignment = ContentAlignment.TopLeft; + Done(); + } + + private void button2_Click(object sender, EventArgs e) + { + Alignment = ContentAlignment.TopCenter; + Done(); + } + + private void button3_Click(object sender, EventArgs e) + { + Alignment = ContentAlignment.TopRight; + Done(); + } + + private void button4_Click(object sender, EventArgs e) + { + Alignment = ContentAlignment.MiddleLeft; + Done(); + } + + private void button5_Click(object sender, EventArgs e) + { + Alignment = ContentAlignment.MiddleCenter; + Done(); + } + + private void button6_Click(object sender, EventArgs e) + { + Alignment = ContentAlignment.MiddleRight; + Done(); + } + + private void button7_Click(object sender, EventArgs e) + { + Alignment = ContentAlignment.BottomLeft; + Done(); + } + + private void button8_Click(object sender, EventArgs e) + { + Alignment = ContentAlignment.BottomCenter; + Done(); + } + + private void button9_Click(object sender, EventArgs e) + { + Alignment = ContentAlignment.BottomRight; + Done(); + } + + private void AlignmentPicker_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void AlignmentPicker_Shown(object sender, EventArgs e) + { + if (_text.StartsWith("{\\an7}", StringComparison.Ordinal)) + { + button1.Focus(); + } + else if (_text.StartsWith("{\\an8}", StringComparison.Ordinal)) + { + button2.Focus(); + } + else if (_text.StartsWith("{\\an9}", StringComparison.Ordinal)) + { + button3.Focus(); + } + else if (_text.StartsWith("{\\an4}", StringComparison.Ordinal)) + { + button4.Focus(); + } + else if (_text.StartsWith("{\\an5}", StringComparison.Ordinal)) + { + button5.Focus(); + } + else if (_text.StartsWith("{\\an6}", StringComparison.Ordinal)) + { + button6.Focus(); + } + else if (_text.StartsWith("{\\an1}", StringComparison.Ordinal)) + { + button7.Focus(); + } + else if (_text.StartsWith("{\\an3}", StringComparison.Ordinal)) + { + button9.Focus(); + } + else + { + button8.Focus(); + } + } + } +} diff --git a/src/Forms/BatchConvertMkvEnding.resx b/src/ui/Forms/AlignmentPicker.resx similarity index 100% rename from src/Forms/BatchConvertMkvEnding.resx rename to src/ui/Forms/AlignmentPicker.resx diff --git a/src/Forms/AlignmentPickerJapanese.Designer.cs b/src/ui/Forms/AlignmentPickerJapanese.Designer.cs similarity index 100% rename from src/Forms/AlignmentPickerJapanese.Designer.cs rename to src/ui/Forms/AlignmentPickerJapanese.Designer.cs diff --git a/src/Forms/AlignmentPickerJapanese.cs b/src/ui/Forms/AlignmentPickerJapanese.cs similarity index 100% rename from src/Forms/AlignmentPickerJapanese.cs rename to src/ui/Forms/AlignmentPickerJapanese.cs diff --git a/src/Forms/BookmarkAdd.resx b/src/ui/Forms/AlignmentPickerJapanese.resx similarity index 100% rename from src/Forms/BookmarkAdd.resx rename to src/ui/Forms/AlignmentPickerJapanese.resx diff --git a/src/Forms/ApplyDurationLimits.Designer.cs b/src/ui/Forms/ApplyDurationLimits.Designer.cs similarity index 98% rename from src/Forms/ApplyDurationLimits.Designer.cs rename to src/ui/Forms/ApplyDurationLimits.Designer.cs index fc2f40075..3f04f0d9c 100644 --- a/src/Forms/ApplyDurationLimits.Designer.cs +++ b/src/ui/Forms/ApplyDurationLimits.Designer.cs @@ -1,360 +1,360 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ApplyDurationLimits - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.numericUpDownDurationMax = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownDurationMin = new System.Windows.Forms.NumericUpDown(); - this.labelNote = new System.Windows.Forms.Label(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxFixesAvailable = new System.Windows.Forms.GroupBox(); - this.listViewFixes = new System.Windows.Forms.ListView(); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.groupBoxUnfixable = new System.Windows.Forms.GroupBox(); - this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.checkBoxMinDuration = new System.Windows.Forms.CheckBox(); - this.checkBoxMaxDuration = new System.Windows.Forms.CheckBox(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMax)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMin)).BeginInit(); - this.groupBoxFixesAvailable.SuspendLayout(); - this.groupBoxUnfixable.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - this.contextMenuStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // numericUpDownDurationMax - // - this.numericUpDownDurationMax.Location = new System.Drawing.Point(191, 38); - this.numericUpDownDurationMax.Maximum = new decimal(new int[] { - 50000, - 0, - 0, - 0}); - this.numericUpDownDurationMax.Minimum = new decimal(new int[] { - 3000, - 0, - 0, - 0}); - this.numericUpDownDurationMax.Name = "numericUpDownDurationMax"; - this.numericUpDownDurationMax.Size = new System.Drawing.Size(56, 20); - this.numericUpDownDurationMax.TabIndex = 4; - this.numericUpDownDurationMax.Value = new decimal(new int[] { - 50000, - 0, - 0, - 0}); - this.numericUpDownDurationMax.ValueChanged += new System.EventHandler(this.numericUpDownDurationMax_ValueChanged); - this.numericUpDownDurationMax.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDownDurationMax_KeyUp); - this.numericUpDownDurationMax.MouseUp += new System.Windows.Forms.MouseEventHandler(this.numericUpDownDurationMax_MouseUp); - // - // numericUpDownDurationMin - // - this.numericUpDownDurationMin.Location = new System.Drawing.Point(191, 12); - this.numericUpDownDurationMin.Maximum = new decimal(new int[] { - 3000, - 0, - 0, - 0}); - this.numericUpDownDurationMin.Minimum = new decimal(new int[] { - 100, - 0, - 0, - 0}); - this.numericUpDownDurationMin.Name = "numericUpDownDurationMin"; - this.numericUpDownDurationMin.Size = new System.Drawing.Size(56, 20); - this.numericUpDownDurationMin.TabIndex = 2; - this.numericUpDownDurationMin.Value = new decimal(new int[] { - 100, - 0, - 0, - 0}); - this.numericUpDownDurationMin.ValueChanged += new System.EventHandler(this.numericUpDownDurationMin_ValueChanged); - this.numericUpDownDurationMin.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDownDurationMin_KeyUp); - this.numericUpDownDurationMin.MouseUp += new System.Windows.Forms.MouseEventHandler(this.numericUpDownDurationMin_MouseUp); - // - // labelNote - // - this.labelNote.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelNote.AutoSize = true; - this.labelNote.Location = new System.Drawing.Point(19, 542); - this.labelNote.Name = "labelNote"; - this.labelNote.Size = new System.Drawing.Size(265, 13); - this.labelNote.TabIndex = 53; - this.labelNote.Text = "Note: Display time will not overlap start time of next text"; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(874, 538); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 110; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(793, 538); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 100; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // groupBoxFixesAvailable - // - this.groupBoxFixesAvailable.Controls.Add(this.listViewFixes); - this.groupBoxFixesAvailable.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBoxFixesAvailable.Location = new System.Drawing.Point(0, 0); - this.groupBoxFixesAvailable.Name = "groupBoxFixesAvailable"; - this.groupBoxFixesAvailable.Size = new System.Drawing.Size(931, 302); - this.groupBoxFixesAvailable.TabIndex = 5; - this.groupBoxFixesAvailable.TabStop = false; - this.groupBoxFixesAvailable.Text = "Fixes available: {0}"; - // - // listViewFixes - // - this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewFixes.CheckBoxes = true; - this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader4, - this.columnHeader5, - this.columnHeader7, - this.columnHeader8}); - this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; - this.listViewFixes.FullRowSelect = true; - this.listViewFixes.HideSelection = false; - this.listViewFixes.Location = new System.Drawing.Point(6, 23); - this.listViewFixes.Name = "listViewFixes"; - this.listViewFixes.Size = new System.Drawing.Size(919, 273); - this.listViewFixes.TabIndex = 6; - this.listViewFixes.UseCompatibleStateImageBehavior = false; - this.listViewFixes.View = System.Windows.Forms.View.Details; - this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged); - // - // columnHeader4 - // - this.columnHeader4.Text = "Apply"; - this.columnHeader4.Width = 50; - // - // columnHeader5 - // - this.columnHeader5.Text = "Line#"; - this.columnHeader5.Width = 61; - // - // columnHeader7 - // - this.columnHeader7.Text = "Before"; - this.columnHeader7.Width = 390; - // - // columnHeader8 - // - this.columnHeader8.Text = "After"; - this.columnHeader8.Width = 390; - // - // groupBoxUnfixable - // - this.groupBoxUnfixable.Controls.Add(this.subtitleListView1); - this.groupBoxUnfixable.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBoxUnfixable.Location = new System.Drawing.Point(0, 0); - this.groupBoxUnfixable.Name = "groupBoxUnfixable"; - this.groupBoxUnfixable.Size = new System.Drawing.Size(931, 154); - this.groupBoxUnfixable.TabIndex = 51; - this.groupBoxUnfixable.TabStop = false; - this.groupBoxUnfixable.Text = "Unable to fix min duration: {0}"; - // - // subtitleListView1 - // - this.subtitleListView1.AllowColumnReorder = true; - this.subtitleListView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.subtitleListView1.FirstVisibleIndex = -1; - this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.subtitleListView1.FullRowSelect = true; - this.subtitleListView1.GridLines = true; - this.subtitleListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.subtitleListView1.HideSelection = false; - this.subtitleListView1.Location = new System.Drawing.Point(6, 19); - this.subtitleListView1.Name = "subtitleListView1"; - this.subtitleListView1.OwnerDraw = true; - this.subtitleListView1.Size = new System.Drawing.Size(919, 129); - this.subtitleListView1.SubtitleFontBold = false; - this.subtitleListView1.SubtitleFontName = "Tahoma"; - this.subtitleListView1.SubtitleFontSize = 8; - this.subtitleListView1.TabIndex = 52; - this.subtitleListView1.UseCompatibleStateImageBehavior = false; - this.subtitleListView1.UseSyntaxColoring = true; - this.subtitleListView1.View = System.Windows.Forms.View.Details; - // - // splitContainer1 - // - this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.splitContainer1.Location = new System.Drawing.Point(16, 72); - this.splitContainer1.Name = "splitContainer1"; - this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.groupBoxFixesAvailable); - this.splitContainer1.Panel1MinSize = 100; - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.groupBoxUnfixable); - this.splitContainer1.Panel2MinSize = 100; - this.splitContainer1.Size = new System.Drawing.Size(931, 460); - this.splitContainer1.SplitterDistance = 302; - this.splitContainer1.TabIndex = 54; - this.splitContainer1.TabStop = false; - // - // checkBoxMinDuration - // - this.checkBoxMinDuration.AutoSize = true; - this.checkBoxMinDuration.Location = new System.Drawing.Point(16, 13); - this.checkBoxMinDuration.Name = "checkBoxMinDuration"; - this.checkBoxMinDuration.Size = new System.Drawing.Size(149, 17); - this.checkBoxMinDuration.TabIndex = 1; - this.checkBoxMinDuration.Text = "Min. duration, milliseconds"; - this.checkBoxMinDuration.UseVisualStyleBackColor = true; - this.checkBoxMinDuration.CheckedChanged += new System.EventHandler(this.checkBoxMinDuration_CheckedChanged); - // - // checkBoxMaxDuration - // - this.checkBoxMaxDuration.AutoSize = true; - this.checkBoxMaxDuration.Location = new System.Drawing.Point(16, 39); - this.checkBoxMaxDuration.Name = "checkBoxMaxDuration"; - this.checkBoxMaxDuration.Size = new System.Drawing.Size(152, 17); - this.checkBoxMaxDuration.TabIndex = 3; - this.checkBoxMaxDuration.Text = "Max. duration, milliseconds"; - this.checkBoxMaxDuration.UseVisualStyleBackColor = true; - this.checkBoxMaxDuration.CheckedChanged += new System.EventHandler(this.checkBoxMaxDuration_CheckedChanged); - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemSelectAll, - this.toolStripMenuItemInverseSelection}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70); - // - // toolStripMenuItemSelectAll - // - this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; - this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemSelectAll.Text = "Select all"; - this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); - // - // toolStripMenuItemInverseSelection - // - this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; - this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; - this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); - // - // ApplyDurationLimits - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(961, 571); - this.Controls.Add(this.checkBoxMaxDuration); - this.Controls.Add(this.checkBoxMinDuration); - this.Controls.Add(this.splitContainer1); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.labelNote); - this.Controls.Add(this.numericUpDownDurationMax); - this.Controls.Add(this.numericUpDownDurationMin); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(620, 440); - this.Name = "ApplyDurationLimits"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Apply duration limits"; - this.Shown += new System.EventHandler(this.ApplyDurationLimits_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ApplyDurationLimits_KeyDown); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMax)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMin)).EndInit(); - this.groupBoxFixesAvailable.ResumeLayout(false); - this.groupBoxUnfixable.ResumeLayout(false); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); - this.contextMenuStrip1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - private System.Windows.Forms.NumericUpDown numericUpDownDurationMax; - private System.Windows.Forms.NumericUpDown numericUpDownDurationMin; - private System.Windows.Forms.Label labelNote; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.GroupBox groupBoxFixesAvailable; - private System.Windows.Forms.ListView listViewFixes; - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeader7; - private System.Windows.Forms.ColumnHeader columnHeader8; - private System.Windows.Forms.GroupBox groupBoxUnfixable; - private Controls.SubtitleListView subtitleListView1; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.CheckBox checkBoxMinDuration; - private System.Windows.Forms.CheckBox checkBoxMaxDuration; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ApplyDurationLimits + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.numericUpDownDurationMax = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownDurationMin = new System.Windows.Forms.NumericUpDown(); + this.labelNote = new System.Windows.Forms.Label(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxFixesAvailable = new System.Windows.Forms.GroupBox(); + this.listViewFixes = new System.Windows.Forms.ListView(); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.groupBoxUnfixable = new System.Windows.Forms.GroupBox(); + this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.checkBoxMinDuration = new System.Windows.Forms.CheckBox(); + this.checkBoxMaxDuration = new System.Windows.Forms.CheckBox(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMax)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMin)).BeginInit(); + this.groupBoxFixesAvailable.SuspendLayout(); + this.groupBoxUnfixable.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.contextMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // numericUpDownDurationMax + // + this.numericUpDownDurationMax.Location = new System.Drawing.Point(191, 38); + this.numericUpDownDurationMax.Maximum = new decimal(new int[] { + 50000, + 0, + 0, + 0}); + this.numericUpDownDurationMax.Minimum = new decimal(new int[] { + 3000, + 0, + 0, + 0}); + this.numericUpDownDurationMax.Name = "numericUpDownDurationMax"; + this.numericUpDownDurationMax.Size = new System.Drawing.Size(56, 20); + this.numericUpDownDurationMax.TabIndex = 4; + this.numericUpDownDurationMax.Value = new decimal(new int[] { + 50000, + 0, + 0, + 0}); + this.numericUpDownDurationMax.ValueChanged += new System.EventHandler(this.numericUpDownDurationMax_ValueChanged); + this.numericUpDownDurationMax.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDownDurationMax_KeyUp); + this.numericUpDownDurationMax.MouseUp += new System.Windows.Forms.MouseEventHandler(this.numericUpDownDurationMax_MouseUp); + // + // numericUpDownDurationMin + // + this.numericUpDownDurationMin.Location = new System.Drawing.Point(191, 12); + this.numericUpDownDurationMin.Maximum = new decimal(new int[] { + 3000, + 0, + 0, + 0}); + this.numericUpDownDurationMin.Minimum = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numericUpDownDurationMin.Name = "numericUpDownDurationMin"; + this.numericUpDownDurationMin.Size = new System.Drawing.Size(56, 20); + this.numericUpDownDurationMin.TabIndex = 2; + this.numericUpDownDurationMin.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numericUpDownDurationMin.ValueChanged += new System.EventHandler(this.numericUpDownDurationMin_ValueChanged); + this.numericUpDownDurationMin.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDownDurationMin_KeyUp); + this.numericUpDownDurationMin.MouseUp += new System.Windows.Forms.MouseEventHandler(this.numericUpDownDurationMin_MouseUp); + // + // labelNote + // + this.labelNote.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelNote.AutoSize = true; + this.labelNote.Location = new System.Drawing.Point(19, 542); + this.labelNote.Name = "labelNote"; + this.labelNote.Size = new System.Drawing.Size(265, 13); + this.labelNote.TabIndex = 53; + this.labelNote.Text = "Note: Display time will not overlap start time of next text"; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(874, 538); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 110; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(793, 538); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 100; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // groupBoxFixesAvailable + // + this.groupBoxFixesAvailable.Controls.Add(this.listViewFixes); + this.groupBoxFixesAvailable.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBoxFixesAvailable.Location = new System.Drawing.Point(0, 0); + this.groupBoxFixesAvailable.Name = "groupBoxFixesAvailable"; + this.groupBoxFixesAvailable.Size = new System.Drawing.Size(931, 302); + this.groupBoxFixesAvailable.TabIndex = 5; + this.groupBoxFixesAvailable.TabStop = false; + this.groupBoxFixesAvailable.Text = "Fixes available: {0}"; + // + // listViewFixes + // + this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewFixes.CheckBoxes = true; + this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader4, + this.columnHeader5, + this.columnHeader7, + this.columnHeader8}); + this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; + this.listViewFixes.FullRowSelect = true; + this.listViewFixes.HideSelection = false; + this.listViewFixes.Location = new System.Drawing.Point(6, 23); + this.listViewFixes.Name = "listViewFixes"; + this.listViewFixes.Size = new System.Drawing.Size(919, 273); + this.listViewFixes.TabIndex = 6; + this.listViewFixes.UseCompatibleStateImageBehavior = false; + this.listViewFixes.View = System.Windows.Forms.View.Details; + this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged); + // + // columnHeader4 + // + this.columnHeader4.Text = "Apply"; + this.columnHeader4.Width = 50; + // + // columnHeader5 + // + this.columnHeader5.Text = "Line#"; + this.columnHeader5.Width = 61; + // + // columnHeader7 + // + this.columnHeader7.Text = "Before"; + this.columnHeader7.Width = 390; + // + // columnHeader8 + // + this.columnHeader8.Text = "After"; + this.columnHeader8.Width = 390; + // + // groupBoxUnfixable + // + this.groupBoxUnfixable.Controls.Add(this.subtitleListView1); + this.groupBoxUnfixable.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBoxUnfixable.Location = new System.Drawing.Point(0, 0); + this.groupBoxUnfixable.Name = "groupBoxUnfixable"; + this.groupBoxUnfixable.Size = new System.Drawing.Size(931, 154); + this.groupBoxUnfixable.TabIndex = 51; + this.groupBoxUnfixable.TabStop = false; + this.groupBoxUnfixable.Text = "Unable to fix min duration: {0}"; + // + // subtitleListView1 + // + this.subtitleListView1.AllowColumnReorder = true; + this.subtitleListView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.subtitleListView1.FirstVisibleIndex = -1; + this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.subtitleListView1.FullRowSelect = true; + this.subtitleListView1.GridLines = true; + this.subtitleListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.subtitleListView1.HideSelection = false; + this.subtitleListView1.Location = new System.Drawing.Point(6, 19); + this.subtitleListView1.Name = "subtitleListView1"; + this.subtitleListView1.OwnerDraw = true; + this.subtitleListView1.Size = new System.Drawing.Size(919, 129); + this.subtitleListView1.SubtitleFontBold = false; + this.subtitleListView1.SubtitleFontName = "Tahoma"; + this.subtitleListView1.SubtitleFontSize = 8; + this.subtitleListView1.TabIndex = 52; + this.subtitleListView1.UseCompatibleStateImageBehavior = false; + this.subtitleListView1.UseSyntaxColoring = true; + this.subtitleListView1.View = System.Windows.Forms.View.Details; + // + // splitContainer1 + // + this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.splitContainer1.Location = new System.Drawing.Point(16, 72); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.groupBoxFixesAvailable); + this.splitContainer1.Panel1MinSize = 100; + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.groupBoxUnfixable); + this.splitContainer1.Panel2MinSize = 100; + this.splitContainer1.Size = new System.Drawing.Size(931, 460); + this.splitContainer1.SplitterDistance = 302; + this.splitContainer1.TabIndex = 54; + this.splitContainer1.TabStop = false; + // + // checkBoxMinDuration + // + this.checkBoxMinDuration.AutoSize = true; + this.checkBoxMinDuration.Location = new System.Drawing.Point(16, 13); + this.checkBoxMinDuration.Name = "checkBoxMinDuration"; + this.checkBoxMinDuration.Size = new System.Drawing.Size(149, 17); + this.checkBoxMinDuration.TabIndex = 1; + this.checkBoxMinDuration.Text = "Min. duration, milliseconds"; + this.checkBoxMinDuration.UseVisualStyleBackColor = true; + this.checkBoxMinDuration.CheckedChanged += new System.EventHandler(this.checkBoxMinDuration_CheckedChanged); + // + // checkBoxMaxDuration + // + this.checkBoxMaxDuration.AutoSize = true; + this.checkBoxMaxDuration.Location = new System.Drawing.Point(16, 39); + this.checkBoxMaxDuration.Name = "checkBoxMaxDuration"; + this.checkBoxMaxDuration.Size = new System.Drawing.Size(152, 17); + this.checkBoxMaxDuration.TabIndex = 3; + this.checkBoxMaxDuration.Text = "Max. duration, milliseconds"; + this.checkBoxMaxDuration.UseVisualStyleBackColor = true; + this.checkBoxMaxDuration.CheckedChanged += new System.EventHandler(this.checkBoxMaxDuration_CheckedChanged); + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSelectAll, + this.toolStripMenuItemInverseSelection}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70); + // + // toolStripMenuItemSelectAll + // + this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; + this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemSelectAll.Text = "Select all"; + this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); + // + // toolStripMenuItemInverseSelection + // + this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; + this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; + this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); + // + // ApplyDurationLimits + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(961, 571); + this.Controls.Add(this.checkBoxMaxDuration); + this.Controls.Add(this.checkBoxMinDuration); + this.Controls.Add(this.splitContainer1); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.labelNote); + this.Controls.Add(this.numericUpDownDurationMax); + this.Controls.Add(this.numericUpDownDurationMin); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(620, 440); + this.Name = "ApplyDurationLimits"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Apply duration limits"; + this.Shown += new System.EventHandler(this.ApplyDurationLimits_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ApplyDurationLimits_KeyDown); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMax)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMin)).EndInit(); + this.groupBoxFixesAvailable.ResumeLayout(false); + this.groupBoxUnfixable.ResumeLayout(false); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.contextMenuStrip1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.NumericUpDown numericUpDownDurationMax; + private System.Windows.Forms.NumericUpDown numericUpDownDurationMin; + private System.Windows.Forms.Label labelNote; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.GroupBox groupBoxFixesAvailable; + private System.Windows.Forms.ListView listViewFixes; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.ColumnHeader columnHeader8; + private System.Windows.Forms.GroupBox groupBoxUnfixable; + private Controls.SubtitleListView subtitleListView1; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.CheckBox checkBoxMinDuration; + private System.Windows.Forms.CheckBox checkBoxMaxDuration; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; + } } \ No newline at end of file diff --git a/src/Forms/ApplyDurationLimits.cs b/src/ui/Forms/ApplyDurationLimits.cs similarity index 97% rename from src/Forms/ApplyDurationLimits.cs rename to src/ui/Forms/ApplyDurationLimits.cs index 16d8a2c55..258c161a3 100644 --- a/src/Forms/ApplyDurationLimits.cs +++ b/src/ui/Forms/ApplyDurationLimits.cs @@ -1,316 +1,316 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Drawing; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ApplyDurationLimits : PositionAndSizeForm - { - private int _totalFixes; - private int _totalErrors; - private Subtitle _subtitle; - private Subtitle _working; - private bool _onlyListFixes = true; - private readonly Timer _refreshTimer = new Timer(); - private readonly Color _warningColor = Color.FromArgb(255, 253, 145); - private Subtitle _unfixables = new Subtitle(); - - public ApplyDurationLimits() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Text = Configuration.Settings.Language.ApplyDurationLimits.Title; - checkBoxMinDuration.Text = Configuration.Settings.Language.Settings.DurationMinimumMilliseconds; - checkBoxMaxDuration.Text = Configuration.Settings.Language.Settings.DurationMaximumMilliseconds; - checkBoxMinDuration.Checked = Configuration.Settings.Tools.ApplyMinimumDurationLimit; - checkBoxMaxDuration.Checked = Configuration.Settings.Tools.ApplyMaximumDurationLimit; - labelNote.Text = Configuration.Settings.Language.AdjustDisplayDuration.Note; - numericUpDownDurationMin.Value = Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds; - numericUpDownDurationMax.Value = Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds; - toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; - toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - subtitleListView1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - UiUtil.InitializeSubtitleFont(subtitleListView1); - subtitleListView1.AutoSizeAllColumns(this); - listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; - listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; - listViewFixes.Columns[2].Text = Configuration.Settings.Language.General.Before; - listViewFixes.Columns[3].Text = Configuration.Settings.Language.General.After; - numericUpDownDurationMin.Left = checkBoxMinDuration.Left + checkBoxMinDuration.Width + 6; - numericUpDownDurationMax.Left = checkBoxMaxDuration.Left + checkBoxMaxDuration.Width + 6; - if (Math.Abs(numericUpDownDurationMin.Left - numericUpDownDurationMax.Left) < 10) - { - numericUpDownDurationMin.Left = Math.Max(numericUpDownDurationMin.Left, numericUpDownDurationMax.Left); - numericUpDownDurationMax.Left = Math.Max(numericUpDownDurationMin.Left, numericUpDownDurationMax.Left); - } - FixLargeFonts(); - _refreshTimer.Interval = 400; - _refreshTimer.Tick += RefreshTimerTick; - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void RefreshTimerTick(object sender, EventArgs e) - { - _refreshTimer.Stop(); - GeneratePreviewReal(); - } - - private void FixLargeFonts() - { - if (labelNote.Right + 5 > Width) - { - Width = labelNote.Right + 5; - } - - UiUtil.FixLargeFonts(this, buttonOK); - } - - public void Initialize(Subtitle subtitle) - { - _subtitle = subtitle; - GeneratePreview(); - } - - private void GeneratePreview() - { - if (_refreshTimer.Enabled) - { - _refreshTimer.Stop(); - } - _refreshTimer.Start(); - } - - private void GeneratePreviewReal() - { - _totalFixes = 0; - _totalErrors = 0; - _onlyListFixes = true; - - _working = new Subtitle(_subtitle); - listViewFixes.BeginUpdate(); - listViewFixes.Items.Clear(); - if (checkBoxMinDuration.Checked) - { - FixShortDisplayTimes(); - } - if (checkBoxMaxDuration.Checked) - { - FixLongDisplayTimes(); - } - listViewFixes.EndUpdate(); - - groupBoxFixesAvailable.Text = string.Format(Configuration.Settings.Language.ApplyDurationLimits.FixesAvailable, _totalFixes); - groupBoxUnfixable.Text = string.Format(Configuration.Settings.Language.ApplyDurationLimits.UnableToFix, _totalErrors); - } - - private void AddFixToListView(Paragraph p, string before, string after, Color backgroundColor) - { - if (_onlyListFixes) - { - var item = new ListViewItem(string.Empty) { Checked = true, Tag = p, BackColor = backgroundColor }; - item.SubItems.Add(p.Number.ToString()); - item.SubItems.Add(UiUtil.GetListViewTextFromString(before)); - item.SubItems.Add(UiUtil.GetListViewTextFromString(after)); - listViewFixes.Items.Add(item); - } - } - - public bool AllowFix(Paragraph p) - { - if (_onlyListFixes) - { - return true; - } - - string ln = p.Number.ToString(); - foreach (ListViewItem item in listViewFixes.Items) - { - if (item.SubItems[1].Text == ln) - { - return item.Checked; - } - } - return false; - } - - private void FixShortDisplayTimes() - { - _unfixables = new Subtitle(); - double minDisplayTime = (double)numericUpDownDurationMin.Value; - for (int i = 0; i < _working.Paragraphs.Count; i++) - { - Paragraph p = _working.Paragraphs[i]; - double displayTime = p.Duration.TotalMilliseconds; - if (displayTime < minDisplayTime) - { - var next = _working.GetParagraphOrDefault(i + 1); - var wantedEndMs = p.StartTime.TotalMilliseconds + minDisplayTime; - if (next == null || wantedEndMs < next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines && AllowFix(p)) - { - AddFix(p, wantedEndMs, DefaultBackColor); - } - else - { - var nextBestEndMs = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - if (nextBestEndMs > p.EndTime.TotalMilliseconds) - { - AddFix(p, nextBestEndMs, _warningColor); - _unfixables.Paragraphs.Add(new Paragraph(p) { Extra = "Warning" }); - } - else - { - _unfixables.Paragraphs.Add(new Paragraph(p)); - } - _totalErrors++; - } - } - } - subtitleListView1.Fill(_unfixables); - for (int index = 0; index < _unfixables.Paragraphs.Count; index++) - { - var p = _unfixables.Paragraphs[index]; - subtitleListView1.SetBackgroundColor(index, p.Extra == "Warning" ? _warningColor : Configuration.Settings.Tools.ListViewSyntaxErrorColor); - } - } - - private void AddFix(Paragraph p, double endMs, Color backgroundColor) - { - string before = p.StartTime.ToShortString() + " --> " + p.EndTime.ToShortString() + " - " + p.Duration.ToShortString(); - p.EndTime.TotalMilliseconds = endMs; - string after = p.StartTime.ToShortString() + " --> " + p.EndTime.ToShortString() + " - " + p.Duration.ToShortString(); - _totalFixes++; - AddFixToListView(p, before, after, backgroundColor); - } - - public void FixLongDisplayTimes() - { - double maxDisplayTime = (double)numericUpDownDurationMax.Value; - for (int i = 0; i < _working.Paragraphs.Count; i++) - { - Paragraph p = _working.Paragraphs[i]; - double displayTime = p.Duration.TotalMilliseconds; - if (displayTime > maxDisplayTime && AllowFix(p)) - { - AddFix(p, p.StartTime.TotalMilliseconds + maxDisplayTime, DefaultBackColor); - } - } - } - - private void ApplyDurationLimits_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void numericUpDownDurationMin_ValueChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void numericUpDownDurationMax_ValueChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - Configuration.Settings.Tools.ApplyMinimumDurationLimit = checkBoxMinDuration.Checked; - Configuration.Settings.Tools.ApplyMaximumDurationLimit = checkBoxMaxDuration.Checked; - - _onlyListFixes = false; - _working = new Subtitle(_subtitle); - if (checkBoxMinDuration.Checked) - { - FixShortDisplayTimes(); - } - if (checkBoxMaxDuration.Checked) - { - FixLongDisplayTimes(); - } - DialogResult = DialogResult.OK; - } - - public Subtitle FixedSubtitle => _working; - - private void numericUpDownDurationMin_KeyUp(object sender, KeyEventArgs e) - { - GeneratePreview(); - } - - private void numericUpDownDurationMax_KeyUp(object sender, KeyEventArgs e) - { - GeneratePreview(); - } - - private void numericUpDownDurationMin_MouseUp(object sender, MouseEventArgs e) - { - GeneratePreview(); - } - - private void numericUpDownDurationMax_MouseUp(object sender, MouseEventArgs e) - { - GeneratePreview(); - } - - private void ApplyDurationLimits_Shown(object sender, EventArgs e) - { - listViewFixes.Focus(); - } - - private void checkBoxMinDuration_CheckedChanged(object sender, EventArgs e) - { - numericUpDownDurationMin.Enabled = checkBoxMinDuration.Checked; - GeneratePreview(); - - } - - private void checkBoxMaxDuration_CheckedChanged(object sender, EventArgs e) - { - numericUpDownDurationMax.Enabled = checkBoxMaxDuration.Checked; - GeneratePreview(); - } - - private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e) - { - if (listViewFixes.SelectedIndices.Count > 0) - { - int index = listViewFixes.SelectedIndices[0]; - ListViewItem item = listViewFixes.Items[index]; - var number = int.Parse(item.SubItems[1].Text); - foreach (var p in _unfixables.Paragraphs) - { - if (p.Number == number) - { - index = _unfixables.GetIndex(p); - subtitleListView1.SelectIndexAndEnsureVisible(index); - return; - } - } - } - } - - private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = true; - } - } - - private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = !item.Checked; - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Drawing; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ApplyDurationLimits : PositionAndSizeForm + { + private int _totalFixes; + private int _totalErrors; + private Subtitle _subtitle; + private Subtitle _working; + private bool _onlyListFixes = true; + private readonly Timer _refreshTimer = new Timer(); + private readonly Color _warningColor = Color.FromArgb(255, 253, 145); + private Subtitle _unfixables = new Subtitle(); + + public ApplyDurationLimits() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Text = Configuration.Settings.Language.ApplyDurationLimits.Title; + checkBoxMinDuration.Text = Configuration.Settings.Language.Settings.DurationMinimumMilliseconds; + checkBoxMaxDuration.Text = Configuration.Settings.Language.Settings.DurationMaximumMilliseconds; + checkBoxMinDuration.Checked = Configuration.Settings.Tools.ApplyMinimumDurationLimit; + checkBoxMaxDuration.Checked = Configuration.Settings.Tools.ApplyMaximumDurationLimit; + labelNote.Text = Configuration.Settings.Language.AdjustDisplayDuration.Note; + numericUpDownDurationMin.Value = Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds; + numericUpDownDurationMax.Value = Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds; + toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; + toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + subtitleListView1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + UiUtil.InitializeSubtitleFont(subtitleListView1); + subtitleListView1.AutoSizeAllColumns(this); + listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; + listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; + listViewFixes.Columns[2].Text = Configuration.Settings.Language.General.Before; + listViewFixes.Columns[3].Text = Configuration.Settings.Language.General.After; + numericUpDownDurationMin.Left = checkBoxMinDuration.Left + checkBoxMinDuration.Width + 6; + numericUpDownDurationMax.Left = checkBoxMaxDuration.Left + checkBoxMaxDuration.Width + 6; + if (Math.Abs(numericUpDownDurationMin.Left - numericUpDownDurationMax.Left) < 10) + { + numericUpDownDurationMin.Left = Math.Max(numericUpDownDurationMin.Left, numericUpDownDurationMax.Left); + numericUpDownDurationMax.Left = Math.Max(numericUpDownDurationMin.Left, numericUpDownDurationMax.Left); + } + FixLargeFonts(); + _refreshTimer.Interval = 400; + _refreshTimer.Tick += RefreshTimerTick; + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void RefreshTimerTick(object sender, EventArgs e) + { + _refreshTimer.Stop(); + GeneratePreviewReal(); + } + + private void FixLargeFonts() + { + if (labelNote.Right + 5 > Width) + { + Width = labelNote.Right + 5; + } + + UiUtil.FixLargeFonts(this, buttonOK); + } + + public void Initialize(Subtitle subtitle) + { + _subtitle = subtitle; + GeneratePreview(); + } + + private void GeneratePreview() + { + if (_refreshTimer.Enabled) + { + _refreshTimer.Stop(); + } + _refreshTimer.Start(); + } + + private void GeneratePreviewReal() + { + _totalFixes = 0; + _totalErrors = 0; + _onlyListFixes = true; + + _working = new Subtitle(_subtitle); + listViewFixes.BeginUpdate(); + listViewFixes.Items.Clear(); + if (checkBoxMinDuration.Checked) + { + FixShortDisplayTimes(); + } + if (checkBoxMaxDuration.Checked) + { + FixLongDisplayTimes(); + } + listViewFixes.EndUpdate(); + + groupBoxFixesAvailable.Text = string.Format(Configuration.Settings.Language.ApplyDurationLimits.FixesAvailable, _totalFixes); + groupBoxUnfixable.Text = string.Format(Configuration.Settings.Language.ApplyDurationLimits.UnableToFix, _totalErrors); + } + + private void AddFixToListView(Paragraph p, string before, string after, Color backgroundColor) + { + if (_onlyListFixes) + { + var item = new ListViewItem(string.Empty) { Checked = true, Tag = p, BackColor = backgroundColor }; + item.SubItems.Add(p.Number.ToString()); + item.SubItems.Add(UiUtil.GetListViewTextFromString(before)); + item.SubItems.Add(UiUtil.GetListViewTextFromString(after)); + listViewFixes.Items.Add(item); + } + } + + public bool AllowFix(Paragraph p) + { + if (_onlyListFixes) + { + return true; + } + + string ln = p.Number.ToString(); + foreach (ListViewItem item in listViewFixes.Items) + { + if (item.SubItems[1].Text == ln) + { + return item.Checked; + } + } + return false; + } + + private void FixShortDisplayTimes() + { + _unfixables = new Subtitle(); + double minDisplayTime = (double)numericUpDownDurationMin.Value; + for (int i = 0; i < _working.Paragraphs.Count; i++) + { + Paragraph p = _working.Paragraphs[i]; + double displayTime = p.Duration.TotalMilliseconds; + if (displayTime < minDisplayTime) + { + var next = _working.GetParagraphOrDefault(i + 1); + var wantedEndMs = p.StartTime.TotalMilliseconds + minDisplayTime; + if (next == null || wantedEndMs < next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines && AllowFix(p)) + { + AddFix(p, wantedEndMs, DefaultBackColor); + } + else + { + var nextBestEndMs = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + if (nextBestEndMs > p.EndTime.TotalMilliseconds) + { + AddFix(p, nextBestEndMs, _warningColor); + _unfixables.Paragraphs.Add(new Paragraph(p) { Extra = "Warning" }); + } + else + { + _unfixables.Paragraphs.Add(new Paragraph(p)); + } + _totalErrors++; + } + } + } + subtitleListView1.Fill(_unfixables); + for (int index = 0; index < _unfixables.Paragraphs.Count; index++) + { + var p = _unfixables.Paragraphs[index]; + subtitleListView1.SetBackgroundColor(index, p.Extra == "Warning" ? _warningColor : Configuration.Settings.Tools.ListViewSyntaxErrorColor); + } + } + + private void AddFix(Paragraph p, double endMs, Color backgroundColor) + { + string before = p.StartTime.ToShortString() + " --> " + p.EndTime.ToShortString() + " - " + p.Duration.ToShortString(); + p.EndTime.TotalMilliseconds = endMs; + string after = p.StartTime.ToShortString() + " --> " + p.EndTime.ToShortString() + " - " + p.Duration.ToShortString(); + _totalFixes++; + AddFixToListView(p, before, after, backgroundColor); + } + + public void FixLongDisplayTimes() + { + double maxDisplayTime = (double)numericUpDownDurationMax.Value; + for (int i = 0; i < _working.Paragraphs.Count; i++) + { + Paragraph p = _working.Paragraphs[i]; + double displayTime = p.Duration.TotalMilliseconds; + if (displayTime > maxDisplayTime && AllowFix(p)) + { + AddFix(p, p.StartTime.TotalMilliseconds + maxDisplayTime, DefaultBackColor); + } + } + } + + private void ApplyDurationLimits_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void numericUpDownDurationMin_ValueChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void numericUpDownDurationMax_ValueChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + Configuration.Settings.Tools.ApplyMinimumDurationLimit = checkBoxMinDuration.Checked; + Configuration.Settings.Tools.ApplyMaximumDurationLimit = checkBoxMaxDuration.Checked; + + _onlyListFixes = false; + _working = new Subtitle(_subtitle); + if (checkBoxMinDuration.Checked) + { + FixShortDisplayTimes(); + } + if (checkBoxMaxDuration.Checked) + { + FixLongDisplayTimes(); + } + DialogResult = DialogResult.OK; + } + + public Subtitle FixedSubtitle => _working; + + private void numericUpDownDurationMin_KeyUp(object sender, KeyEventArgs e) + { + GeneratePreview(); + } + + private void numericUpDownDurationMax_KeyUp(object sender, KeyEventArgs e) + { + GeneratePreview(); + } + + private void numericUpDownDurationMin_MouseUp(object sender, MouseEventArgs e) + { + GeneratePreview(); + } + + private void numericUpDownDurationMax_MouseUp(object sender, MouseEventArgs e) + { + GeneratePreview(); + } + + private void ApplyDurationLimits_Shown(object sender, EventArgs e) + { + listViewFixes.Focus(); + } + + private void checkBoxMinDuration_CheckedChanged(object sender, EventArgs e) + { + numericUpDownDurationMin.Enabled = checkBoxMinDuration.Checked; + GeneratePreview(); + + } + + private void checkBoxMaxDuration_CheckedChanged(object sender, EventArgs e) + { + numericUpDownDurationMax.Enabled = checkBoxMaxDuration.Checked; + GeneratePreview(); + } + + private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e) + { + if (listViewFixes.SelectedIndices.Count > 0) + { + int index = listViewFixes.SelectedIndices[0]; + ListViewItem item = listViewFixes.Items[index]; + var number = int.Parse(item.SubItems[1].Text); + foreach (var p in _unfixables.Paragraphs) + { + if (p.Number == number) + { + index = _unfixables.GetIndex(p); + subtitleListView1.SelectIndexAndEnsureVisible(index); + return; + } + } + } + } + + private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = true; + } + } + + private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = !item.Checked; + } + } + } +} diff --git a/src/Forms/MergeTextWithSameTimeCodes.resx b/src/ui/Forms/ApplyDurationLimits.resx similarity index 100% rename from src/Forms/MergeTextWithSameTimeCodes.resx rename to src/ui/Forms/ApplyDurationLimits.resx diff --git a/src/Forms/AudioToText.Designer.cs b/src/ui/Forms/AudioToText.Designer.cs similarity index 100% rename from src/Forms/AudioToText.Designer.cs rename to src/ui/Forms/AudioToText.Designer.cs diff --git a/src/Forms/AudioToText.cs b/src/ui/Forms/AudioToText.cs similarity index 100% rename from src/Forms/AudioToText.cs rename to src/ui/Forms/AudioToText.cs diff --git a/src/Forms/BookmarksGoTo.resx b/src/ui/Forms/AudioToText.resx similarity index 100% rename from src/Forms/BookmarksGoTo.resx rename to src/ui/Forms/AudioToText.resx diff --git a/src/Forms/AutoBreakUnbreakLines.Designer.cs b/src/ui/Forms/AutoBreakUnbreakLines.Designer.cs similarity index 98% rename from src/Forms/AutoBreakUnbreakLines.Designer.cs rename to src/ui/Forms/AutoBreakUnbreakLines.Designer.cs index 05f99bd90..d2a2567fe 100644 --- a/src/Forms/AutoBreakUnbreakLines.Designer.cs +++ b/src/ui/Forms/AutoBreakUnbreakLines.Designer.cs @@ -1,210 +1,210 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class AutoBreakUnbreakLines - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.listViewFixes = new System.Windows.Forms.ListView(); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.comboBoxConditions = new System.Windows.Forms.ComboBox(); - this.labelCondition = new System.Windows.Forms.Label(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBoxLinesFound.SuspendLayout(); - this.contextMenuStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // listViewFixes - // - this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewFixes.CheckBoxes = true; - this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader4, - this.columnHeader5, - this.columnHeader7, - this.columnHeader8}); - this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; - this.listViewFixes.FullRowSelect = true; - this.listViewFixes.HideSelection = false; - this.listViewFixes.Location = new System.Drawing.Point(6, 19); - this.listViewFixes.Name = "listViewFixes"; - this.listViewFixes.Size = new System.Drawing.Size(754, 324); - this.listViewFixes.TabIndex = 9; - this.listViewFixes.UseCompatibleStateImageBehavior = false; - this.listViewFixes.View = System.Windows.Forms.View.Details; - this.listViewFixes.Resize += new System.EventHandler(this.listViewFixes_Resize); - // - // columnHeader4 - // - this.columnHeader4.Text = "Apply"; - this.columnHeader4.Width = 45; - // - // columnHeader5 - // - this.columnHeader5.Text = "Line#"; - this.columnHeader5.Width = 61; - // - // columnHeader7 - // - this.columnHeader7.Text = "Before"; - this.columnHeader7.Width = 292; - // - // columnHeader8 - // - this.columnHeader8.Text = "After"; - this.columnHeader8.Width = 292; - // - // groupBoxLinesFound - // - this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxLinesFound.Controls.Add(this.listViewFixes); - this.groupBoxLinesFound.Location = new System.Drawing.Point(2, 70); - this.groupBoxLinesFound.Name = "groupBoxLinesFound"; - this.groupBoxLinesFound.Size = new System.Drawing.Size(766, 349); - this.groupBoxLinesFound.TabIndex = 7; - this.groupBoxLinesFound.TabStop = false; - this.groupBoxLinesFound.Text = "Lines found: {0}"; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(606, 425); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 5; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(687, 425); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 6; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // comboBoxConditions - // - this.comboBoxConditions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxConditions.FormattingEnabled = true; - this.comboBoxConditions.Location = new System.Drawing.Point(12, 30); - this.comboBoxConditions.Name = "comboBoxConditions"; - this.comboBoxConditions.Size = new System.Drawing.Size(150, 21); - this.comboBoxConditions.TabIndex = 8; - // - // labelCondition - // - this.labelCondition.AutoSize = true; - this.labelCondition.Location = new System.Drawing.Point(13, 13); - this.labelCondition.Name = "labelCondition"; - this.labelCondition.Size = new System.Drawing.Size(141, 13); - this.labelCondition.TabIndex = 9; - this.labelCondition.Text = "Only break lines longer than"; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemSelectAll, - this.toolStripMenuItemInverseSelection}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70); - // - // toolStripMenuItemSelectAll - // - this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; - this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemSelectAll.Text = "Select all"; - this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); - // - // toolStripMenuItemInverseSelection - // - this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; - this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; - this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); - // - // AutoBreakUnbreakLines - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(774, 454); - this.Controls.Add(this.labelCondition); - this.Controls.Add(this.comboBoxConditions); - this.Controls.Add(this.groupBoxLinesFound); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(700, 350); - this.Name = "AutoBreakUnbreakLines"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "AutoBreakUnbreakLines"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.AutoBreakUnbreakLinesKeyDown); - this.groupBoxLinesFound.ResumeLayout(false); - this.contextMenuStrip1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ListView listViewFixes; - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeader7; - private System.Windows.Forms.ColumnHeader columnHeader8; - private System.Windows.Forms.GroupBox groupBoxLinesFound; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.ComboBox comboBoxConditions; - private System.Windows.Forms.Label labelCondition; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class AutoBreakUnbreakLines + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.listViewFixes = new System.Windows.Forms.ListView(); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.comboBoxConditions = new System.Windows.Forms.ComboBox(); + this.labelCondition = new System.Windows.Forms.Label(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBoxLinesFound.SuspendLayout(); + this.contextMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // listViewFixes + // + this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewFixes.CheckBoxes = true; + this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader4, + this.columnHeader5, + this.columnHeader7, + this.columnHeader8}); + this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; + this.listViewFixes.FullRowSelect = true; + this.listViewFixes.HideSelection = false; + this.listViewFixes.Location = new System.Drawing.Point(6, 19); + this.listViewFixes.Name = "listViewFixes"; + this.listViewFixes.Size = new System.Drawing.Size(754, 324); + this.listViewFixes.TabIndex = 9; + this.listViewFixes.UseCompatibleStateImageBehavior = false; + this.listViewFixes.View = System.Windows.Forms.View.Details; + this.listViewFixes.Resize += new System.EventHandler(this.listViewFixes_Resize); + // + // columnHeader4 + // + this.columnHeader4.Text = "Apply"; + this.columnHeader4.Width = 45; + // + // columnHeader5 + // + this.columnHeader5.Text = "Line#"; + this.columnHeader5.Width = 61; + // + // columnHeader7 + // + this.columnHeader7.Text = "Before"; + this.columnHeader7.Width = 292; + // + // columnHeader8 + // + this.columnHeader8.Text = "After"; + this.columnHeader8.Width = 292; + // + // groupBoxLinesFound + // + this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxLinesFound.Controls.Add(this.listViewFixes); + this.groupBoxLinesFound.Location = new System.Drawing.Point(2, 70); + this.groupBoxLinesFound.Name = "groupBoxLinesFound"; + this.groupBoxLinesFound.Size = new System.Drawing.Size(766, 349); + this.groupBoxLinesFound.TabIndex = 7; + this.groupBoxLinesFound.TabStop = false; + this.groupBoxLinesFound.Text = "Lines found: {0}"; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(606, 425); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 5; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(687, 425); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // comboBoxConditions + // + this.comboBoxConditions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxConditions.FormattingEnabled = true; + this.comboBoxConditions.Location = new System.Drawing.Point(12, 30); + this.comboBoxConditions.Name = "comboBoxConditions"; + this.comboBoxConditions.Size = new System.Drawing.Size(150, 21); + this.comboBoxConditions.TabIndex = 8; + // + // labelCondition + // + this.labelCondition.AutoSize = true; + this.labelCondition.Location = new System.Drawing.Point(13, 13); + this.labelCondition.Name = "labelCondition"; + this.labelCondition.Size = new System.Drawing.Size(141, 13); + this.labelCondition.TabIndex = 9; + this.labelCondition.Text = "Only break lines longer than"; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSelectAll, + this.toolStripMenuItemInverseSelection}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70); + // + // toolStripMenuItemSelectAll + // + this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; + this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemSelectAll.Text = "Select all"; + this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); + // + // toolStripMenuItemInverseSelection + // + this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; + this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; + this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); + // + // AutoBreakUnbreakLines + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(774, 454); + this.Controls.Add(this.labelCondition); + this.Controls.Add(this.comboBoxConditions); + this.Controls.Add(this.groupBoxLinesFound); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(700, 350); + this.Name = "AutoBreakUnbreakLines"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "AutoBreakUnbreakLines"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.AutoBreakUnbreakLinesKeyDown); + this.groupBoxLinesFound.ResumeLayout(false); + this.contextMenuStrip1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ListView listViewFixes; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.ColumnHeader columnHeader8; + private System.Windows.Forms.GroupBox groupBoxLinesFound; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.ComboBox comboBoxConditions; + private System.Windows.Forms.Label labelCondition; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; + } } \ No newline at end of file diff --git a/src/Forms/AutoBreakUnbreakLines.cs b/src/ui/Forms/AutoBreakUnbreakLines.cs similarity index 97% rename from src/Forms/AutoBreakUnbreakLines.cs rename to src/ui/Forms/AutoBreakUnbreakLines.cs index f8f0b649b..494bed902 100644 --- a/src/Forms/AutoBreakUnbreakLines.cs +++ b/src/ui/Forms/AutoBreakUnbreakLines.cs @@ -1,257 +1,257 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class AutoBreakUnbreakLines : PositionAndSizeForm - { - private List _paragraphs; - private bool _modeAutoBalance; - private HashSet _notAllowedFixes = new HashSet(); - - private Dictionary _fixedText = new Dictionary(); - - private string _language; - - public Dictionary FixedText => _fixedText; - - public AutoBreakUnbreakLines() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - groupBoxLinesFound.Text = string.Empty; - listViewFixes.Columns[2].Width = 290; - listViewFixes.Columns[3].Width = 290; - - listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; - listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; - listViewFixes.Columns[2].Text = Configuration.Settings.Language.General.Before; - listViewFixes.Columns[3].Text = Configuration.Settings.Language.General.After; - toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; - toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - } - - public void Initialize(Subtitle subtitle, bool autoBalance) - { - _language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); - _modeAutoBalance = autoBalance; - _paragraphs = new List(); - - foreach (Paragraph p in subtitle.Paragraphs) - { - _paragraphs.Add(p); - } - - if (autoBalance) - { - labelCondition.Text = Configuration.Settings.Language.AutoBreakUnbreakLines.OnlyBreakLinesLongerThan; - const int start = 10; - const int max = 60; - for (int i = start; i <= max; i++) - { - comboBoxConditions.Items.Add(i.ToString(CultureInfo.InvariantCulture)); - if (i == Configuration.Settings.General.MergeLinesShorterThan - 1) - { - comboBoxConditions.SelectedIndex = comboBoxConditions.Items.Count - 1; - } - } - - if (comboBoxConditions.SelectedIndex < 0) - { - comboBoxConditions.SelectedIndex = 30; - } - - AutoBalance(); - } - else - { - labelCondition.Text = Configuration.Settings.Language.AutoBreakUnbreakLines.OnlyUnbreakLinesLongerThan; - for (int i = 5; i < 51; i++) - { - comboBoxConditions.Items.Add(i.ToString(CultureInfo.InvariantCulture)); - if (i == Configuration.Settings.General.MergeLinesShorterThan - 1) - { - comboBoxConditions.SelectedIndex = comboBoxConditions.Items.Count - 1; - } - } - if (comboBoxConditions.SelectedIndex < 0) - { - comboBoxConditions.SelectedIndex = 5; - } - Unbreak(); - } - comboBoxConditions.SelectedIndexChanged += ComboBoxConditionsSelectedIndexChanged; - } - - public int MinimumLength - { - get - { - return int.Parse(comboBoxConditions.Items[comboBoxConditions.SelectedIndex].ToString()); - } - } - - public int MergeLinesShorterThan - { - get - { - if (Configuration.Settings.General.MergeLinesShorterThan > MinimumLength) - { - return MinimumLength - 1; - } - - return Configuration.Settings.General.MergeLinesShorterThan; - } - } - - private void AutoBalance() - { - listViewFixes.ItemChecked -= listViewFixes_ItemChecked; - _notAllowedFixes = new HashSet(); - _fixedText = new Dictionary(); - int minLength = MinimumLength; - Text = Configuration.Settings.Language.AutoBreakUnbreakLines.TitleAutoBreak; - - - listViewFixes.BeginUpdate(); - listViewFixes.Items.Clear(); - foreach (Paragraph p in _paragraphs) - { - if (HtmlUtil.RemoveHtmlTags(p.Text, true).Length > minLength || p.Text.Contains(Environment.NewLine)) - { - var text = Utilities.AutoBreakLine(p.Text, 5, MergeLinesShorterThan, _language); - if (text != p.Text) - { - AddToListView(p, text); - _fixedText.Add(p.Id, text); - } - } - } - listViewFixes.EndUpdate(); - groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.AutoBreakUnbreakLines.LinesFoundX, listViewFixes.Items.Count); - listViewFixes.ItemChecked += listViewFixes_ItemChecked; - } - - private void Unbreak() - { - listViewFixes.ItemChecked -= listViewFixes_ItemChecked; - _notAllowedFixes = new HashSet(); - _fixedText = new Dictionary(); - int minLength = int.Parse(comboBoxConditions.Items[comboBoxConditions.SelectedIndex].ToString()); - Text = Configuration.Settings.Language.AutoBreakUnbreakLines.TitleUnbreak; - listViewFixes.BeginUpdate(); - listViewFixes.Items.Clear(); - foreach (Paragraph p in _paragraphs) - { - if (p.Text.Contains(Environment.NewLine) && HtmlUtil.RemoveHtmlTags(p.Text, true).Length > minLength) - { - var text = Utilities.UnbreakLine(p.Text); - if (text != p.Text) - { - AddToListView(p, text); - _fixedText.Add(p.Id, text); - } - } - } - listViewFixes.EndUpdate(); - groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.AutoBreakUnbreakLines.LinesFoundX, listViewFixes.Items.Count); - listViewFixes.ItemChecked += listViewFixes_ItemChecked; - } - - private void AutoBreakUnbreakLinesKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void AddToListView(Paragraph p, string newText) - { - var item = new ListViewItem(string.Empty) { Tag = p, Checked = true }; - item.SubItems.Add(p.Number.ToString(CultureInfo.InvariantCulture)); - item.SubItems.Add(UiUtil.GetListViewTextFromString(p.Text)); - item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); - listViewFixes.Items.Add(item); - } - - private void ButtonOkClick(object sender, EventArgs e) - { - for (int i = _paragraphs.Count - 1; i >= 0; i--) - { - var p = _paragraphs[i]; - if (_notAllowedFixes.Contains(p.Id)) - { - _fixedText.Remove(p.Id); - } - } - DialogResult = DialogResult.OK; - } - - private void ComboBoxConditionsSelectedIndexChanged(object sender, EventArgs e) - { - if (_modeAutoBalance) - { - AutoBalance(); - } - else - { - Unbreak(); - } - } - - private void listViewFixes_ItemChecked(object sender, ItemCheckedEventArgs e) - { - if (e.Item == null) - { - return; - } - - var p = e.Item.Tag as Paragraph; - if (p == null) - { - return; - } - - if (e.Item.Checked) - { - _notAllowedFixes.Remove(p.Id); - } - else - { - _notAllowedFixes.Add(p.Id); - } - } - - private void listViewFixes_Resize(object sender, EventArgs e) - { - var newWidth = (listViewFixes.Width - (listViewFixes.Columns[0].Width + listViewFixes.Columns[1].Width)) / 2; - listViewFixes.Columns[3].Width = listViewFixes.Columns[2].Width = newWidth; - } - - private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = true; - } - } - - private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = !item.Checked; - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class AutoBreakUnbreakLines : PositionAndSizeForm + { + private List _paragraphs; + private bool _modeAutoBalance; + private HashSet _notAllowedFixes = new HashSet(); + + private Dictionary _fixedText = new Dictionary(); + + private string _language; + + public Dictionary FixedText => _fixedText; + + public AutoBreakUnbreakLines() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + groupBoxLinesFound.Text = string.Empty; + listViewFixes.Columns[2].Width = 290; + listViewFixes.Columns[3].Width = 290; + + listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; + listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; + listViewFixes.Columns[2].Text = Configuration.Settings.Language.General.Before; + listViewFixes.Columns[3].Text = Configuration.Settings.Language.General.After; + toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; + toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + } + + public void Initialize(Subtitle subtitle, bool autoBalance) + { + _language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); + _modeAutoBalance = autoBalance; + _paragraphs = new List(); + + foreach (Paragraph p in subtitle.Paragraphs) + { + _paragraphs.Add(p); + } + + if (autoBalance) + { + labelCondition.Text = Configuration.Settings.Language.AutoBreakUnbreakLines.OnlyBreakLinesLongerThan; + const int start = 10; + const int max = 60; + for (int i = start; i <= max; i++) + { + comboBoxConditions.Items.Add(i.ToString(CultureInfo.InvariantCulture)); + if (i == Configuration.Settings.General.MergeLinesShorterThan - 1) + { + comboBoxConditions.SelectedIndex = comboBoxConditions.Items.Count - 1; + } + } + + if (comboBoxConditions.SelectedIndex < 0) + { + comboBoxConditions.SelectedIndex = 30; + } + + AutoBalance(); + } + else + { + labelCondition.Text = Configuration.Settings.Language.AutoBreakUnbreakLines.OnlyUnbreakLinesLongerThan; + for (int i = 5; i < 51; i++) + { + comboBoxConditions.Items.Add(i.ToString(CultureInfo.InvariantCulture)); + if (i == Configuration.Settings.General.MergeLinesShorterThan - 1) + { + comboBoxConditions.SelectedIndex = comboBoxConditions.Items.Count - 1; + } + } + if (comboBoxConditions.SelectedIndex < 0) + { + comboBoxConditions.SelectedIndex = 5; + } + Unbreak(); + } + comboBoxConditions.SelectedIndexChanged += ComboBoxConditionsSelectedIndexChanged; + } + + public int MinimumLength + { + get + { + return int.Parse(comboBoxConditions.Items[comboBoxConditions.SelectedIndex].ToString()); + } + } + + public int MergeLinesShorterThan + { + get + { + if (Configuration.Settings.General.MergeLinesShorterThan > MinimumLength) + { + return MinimumLength - 1; + } + + return Configuration.Settings.General.MergeLinesShorterThan; + } + } + + private void AutoBalance() + { + listViewFixes.ItemChecked -= listViewFixes_ItemChecked; + _notAllowedFixes = new HashSet(); + _fixedText = new Dictionary(); + int minLength = MinimumLength; + Text = Configuration.Settings.Language.AutoBreakUnbreakLines.TitleAutoBreak; + + + listViewFixes.BeginUpdate(); + listViewFixes.Items.Clear(); + foreach (Paragraph p in _paragraphs) + { + if (HtmlUtil.RemoveHtmlTags(p.Text, true).Length > minLength || p.Text.Contains(Environment.NewLine)) + { + var text = Utilities.AutoBreakLine(p.Text, 5, MergeLinesShorterThan, _language); + if (text != p.Text) + { + AddToListView(p, text); + _fixedText.Add(p.Id, text); + } + } + } + listViewFixes.EndUpdate(); + groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.AutoBreakUnbreakLines.LinesFoundX, listViewFixes.Items.Count); + listViewFixes.ItemChecked += listViewFixes_ItemChecked; + } + + private void Unbreak() + { + listViewFixes.ItemChecked -= listViewFixes_ItemChecked; + _notAllowedFixes = new HashSet(); + _fixedText = new Dictionary(); + int minLength = int.Parse(comboBoxConditions.Items[comboBoxConditions.SelectedIndex].ToString()); + Text = Configuration.Settings.Language.AutoBreakUnbreakLines.TitleUnbreak; + listViewFixes.BeginUpdate(); + listViewFixes.Items.Clear(); + foreach (Paragraph p in _paragraphs) + { + if (p.Text.Contains(Environment.NewLine) && HtmlUtil.RemoveHtmlTags(p.Text, true).Length > minLength) + { + var text = Utilities.UnbreakLine(p.Text); + if (text != p.Text) + { + AddToListView(p, text); + _fixedText.Add(p.Id, text); + } + } + } + listViewFixes.EndUpdate(); + groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.AutoBreakUnbreakLines.LinesFoundX, listViewFixes.Items.Count); + listViewFixes.ItemChecked += listViewFixes_ItemChecked; + } + + private void AutoBreakUnbreakLinesKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void AddToListView(Paragraph p, string newText) + { + var item = new ListViewItem(string.Empty) { Tag = p, Checked = true }; + item.SubItems.Add(p.Number.ToString(CultureInfo.InvariantCulture)); + item.SubItems.Add(UiUtil.GetListViewTextFromString(p.Text)); + item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); + listViewFixes.Items.Add(item); + } + + private void ButtonOkClick(object sender, EventArgs e) + { + for (int i = _paragraphs.Count - 1; i >= 0; i--) + { + var p = _paragraphs[i]; + if (_notAllowedFixes.Contains(p.Id)) + { + _fixedText.Remove(p.Id); + } + } + DialogResult = DialogResult.OK; + } + + private void ComboBoxConditionsSelectedIndexChanged(object sender, EventArgs e) + { + if (_modeAutoBalance) + { + AutoBalance(); + } + else + { + Unbreak(); + } + } + + private void listViewFixes_ItemChecked(object sender, ItemCheckedEventArgs e) + { + if (e.Item == null) + { + return; + } + + var p = e.Item.Tag as Paragraph; + if (p == null) + { + return; + } + + if (e.Item.Checked) + { + _notAllowedFixes.Remove(p.Id); + } + else + { + _notAllowedFixes.Add(p.Id); + } + } + + private void listViewFixes_Resize(object sender, EventArgs e) + { + var newWidth = (listViewFixes.Width - (listViewFixes.Columns[0].Width + listViewFixes.Columns[1].Width)) / 2; + listViewFixes.Columns[3].Width = listViewFixes.Columns[2].Width = newWidth; + } + + private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = true; + } + } + + private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = !item.Checked; + } + } + } +} diff --git a/src/Forms/Ocr/OCRSpellCheck.resx b/src/ui/Forms/AutoBreakUnbreakLines.resx similarity index 100% rename from src/Forms/Ocr/OCRSpellCheck.resx rename to src/ui/Forms/AutoBreakUnbreakLines.resx diff --git a/src/Forms/BatchConvert.Designer.cs b/src/ui/Forms/BatchConvert.Designer.cs similarity index 98% rename from src/Forms/BatchConvert.Designer.cs rename to src/ui/Forms/BatchConvert.Designer.cs index 237869f53..1989901da 100644 --- a/src/Forms/BatchConvert.Designer.cs +++ b/src/ui/Forms/BatchConvert.Designer.cs @@ -1,1622 +1,1622 @@ -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class BatchConvert - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - TimeCode timeCode1 = new TimeCode(); - this.buttonConvert = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.groupBoxConvertOptions = new System.Windows.Forms.GroupBox(); - this.groupBoxDeleteLines = new System.Windows.Forms.GroupBox(); - this.textBoxDeleteContains = new System.Windows.Forms.TextBox(); - this.labelDeleteLinesContaining = new System.Windows.Forms.Label(); - this.numericUpDownDeleteLast = new System.Windows.Forms.NumericUpDown(); - this.labelDeleteLastLines = new System.Windows.Forms.Label(); - this.numericUpDownDeleteFirst = new System.Windows.Forms.NumericUpDown(); - this.labelDeleteFirstLines = new System.Windows.Forms.Label(); - this.groupBoxRemoveStyle = new System.Windows.Forms.GroupBox(); - this.textBoxRemoveStyle = new System.Windows.Forms.TextBox(); - this.labelStyleName = new System.Windows.Forms.Label(); - this.groupBoxOffsetTimeCodes = new System.Windows.Forms.GroupBox(); - this.radioButtonShowLater = new System.Windows.Forms.RadioButton(); - this.radioButtonShowEarlier = new System.Windows.Forms.RadioButton(); - this.timeUpDownAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.labelHourMinSecMilliSecond = new System.Windows.Forms.Label(); - this.buttonConvertOptionsSettings = new System.Windows.Forms.Button(); - this.listViewConvertOptions = new System.Windows.Forms.ListView(); - this.ActionCheckBox = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.Action = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.contextMenuStripOptions = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.inverseSelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBoxChangeFrameRate = new System.Windows.Forms.GroupBox(); - this.buttonSwapFrameRate = new System.Windows.Forms.Button(); - this.comboBoxFrameRateTo = new System.Windows.Forms.ComboBox(); - this.labelToFrameRate = new System.Windows.Forms.Label(); - this.comboBoxFrameRateFrom = new System.Windows.Forms.ComboBox(); - this.labelFromFrameRate = new System.Windows.Forms.Label(); - this.groupBoxFixRtl = new System.Windows.Forms.GroupBox(); - this.radioButtonReverseStartEnd = new System.Windows.Forms.RadioButton(); - this.radioButtonRemoveUnicode = new System.Windows.Forms.RadioButton(); - this.radioButtonAddUnicode = new System.Windows.Forms.RadioButton(); - this.groupBoxSpeed = new System.Windows.Forms.GroupBox(); - this.radioButtonToDropFrame = new System.Windows.Forms.RadioButton(); - this.radioButtonSpeedFromDropFrame = new System.Windows.Forms.RadioButton(); - this.radioButtonSpeedCustom = new System.Windows.Forms.RadioButton(); - this.numericUpDownPercent = new System.Windows.Forms.NumericUpDown(); - this.labelPercent = new System.Windows.Forms.Label(); - this.groupBoxChangeCasing = new System.Windows.Forms.GroupBox(); - this.radioButtonFixOnlyNames = new System.Windows.Forms.RadioButton(); - this.radioButtonLowercase = new System.Windows.Forms.RadioButton(); - this.radioButtonUppercase = new System.Windows.Forms.RadioButton(); - this.radioButtonNormal = new System.Windows.Forms.RadioButton(); - this.groupBoxMergeShortLines = new System.Windows.Forms.GroupBox(); - this.checkBoxOnlyContinuationLines = new System.Windows.Forms.CheckBox(); - this.numericUpDownMaxCharacters = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownMaxMillisecondsBetweenLines = new System.Windows.Forms.NumericUpDown(); - this.labelMaxMillisecondsBetweenLines = new System.Windows.Forms.Label(); - this.labelMaxCharacters = new System.Windows.Forms.Label(); - this.groupBoxAdjustDuration = new System.Windows.Forms.GroupBox(); - this.comboBoxAdjustDurationVia = new System.Windows.Forms.ComboBox(); - this.labelAdjustDurationVia = new System.Windows.Forms.Label(); - this.panelAdjustDurationFixed = new System.Windows.Forms.Panel(); - this.numericUpDownFixedMilliseconds = new System.Windows.Forms.NumericUpDown(); - this.labelMillisecondsFixed = new System.Windows.Forms.Label(); - this.panelAdjustDurationAddPercent = new System.Windows.Forms.Panel(); - this.label1 = new System.Windows.Forms.Label(); - this.numericUpDownAdjustViaPercent = new System.Windows.Forms.NumericUpDown(); - this.labelAdjustViaPercent = new System.Windows.Forms.Label(); - this.panelAdjustDurationAddSeconds = new System.Windows.Forms.Panel(); - this.numericUpDownSeconds = new System.Windows.Forms.NumericUpDown(); - this.labelAddSeconds = new System.Windows.Forms.Label(); - this.panelAdjustDurationRecalc = new System.Windows.Forms.Panel(); - this.checkBoxExtendOnly = new System.Windows.Forms.CheckBox(); - this.numericUpDownOptimalCharsSec = new System.Windows.Forms.NumericUpDown(); - this.labelOptimalCharsSec = new System.Windows.Forms.Label(); - this.numericUpDownMaxCharsSec = new System.Windows.Forms.NumericUpDown(); - this.labelMaxCharsPerSecond = new System.Windows.Forms.Label(); - this.groupBoxOutput = new System.Windows.Forms.GroupBox(); - this.buttonBrowseEncoding = new System.Windows.Forms.Button(); - this.radioButtonSaveInOutputFolder = new System.Windows.Forms.RadioButton(); - this.buttonTransportStreamSettings = new System.Windows.Forms.Button(); - this.linkLabelOpenOutputFolder = new System.Windows.Forms.LinkLabel(); - this.checkBoxUseStyleFromSource = new System.Windows.Forms.CheckBox(); - this.checkBoxOverwrite = new System.Windows.Forms.CheckBox(); - this.buttonStyles = new System.Windows.Forms.Button(); - this.buttonChooseFolder = new System.Windows.Forms.Button(); - this.comboBoxSubtitleFormats = new System.Windows.Forms.ComboBox(); - this.textBoxOutputFolder = new System.Windows.Forms.TextBox(); - this.labelEncoding = new System.Windows.Forms.Label(); - this.radioButtonSaveInSourceFolder = new System.Windows.Forms.RadioButton(); - this.comboBoxEncoding = new System.Windows.Forms.ComboBox(); - this.labelOutputFormat = new System.Windows.Forms.Label(); - this.groupBoxInput = new System.Windows.Forms.GroupBox(); - this.labelNumberOfFiles = new System.Windows.Forms.Label(); - this.textBoxFilter = new System.Windows.Forms.TextBox(); - this.labelFilter = new System.Windows.Forms.Label(); - this.comboBoxFilter = new System.Windows.Forms.ComboBox(); - this.checkBoxScanFolderRecursive = new System.Windows.Forms.CheckBox(); - this.buttonSearchFolder = new System.Windows.Forms.Button(); - this.buttonInputBrowse = new System.Windows.Forms.Button(); - this.labelChooseInputFiles = new System.Windows.Forms.Label(); - this.listViewInputFiles = new System.Windows.Forms.ListView(); - this.columnHeaderFName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderFormat = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.contextMenuStripFiles = new System.Windows.Forms.ContextMenuStrip(this.components); - this.addFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.openContainingFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.convertMkvSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.progressBar1 = new System.Windows.Forms.ProgressBar(); - this.labelStatus = new System.Windows.Forms.Label(); - this.groupBoxConvertOptions.SuspendLayout(); - this.groupBoxDeleteLines.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDeleteLast)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDeleteFirst)).BeginInit(); - this.groupBoxRemoveStyle.SuspendLayout(); - this.groupBoxOffsetTimeCodes.SuspendLayout(); - this.contextMenuStripOptions.SuspendLayout(); - this.groupBoxChangeFrameRate.SuspendLayout(); - this.groupBoxFixRtl.SuspendLayout(); - this.groupBoxSpeed.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).BeginInit(); - this.groupBoxChangeCasing.SuspendLayout(); - this.groupBoxMergeShortLines.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).BeginInit(); - this.groupBoxAdjustDuration.SuspendLayout(); - this.panelAdjustDurationFixed.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFixedMilliseconds)).BeginInit(); - this.panelAdjustDurationAddPercent.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAdjustViaPercent)).BeginInit(); - this.panelAdjustDurationAddSeconds.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).BeginInit(); - this.panelAdjustDurationRecalc.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharsSec)).BeginInit(); - this.groupBoxOutput.SuspendLayout(); - this.groupBoxInput.SuspendLayout(); - this.contextMenuStripFiles.SuspendLayout(); - this.SuspendLayout(); - // - // buttonConvert - // - this.buttonConvert.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonConvert.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonConvert.Location = new System.Drawing.Point(844, 618); - this.buttonConvert.Name = "buttonConvert"; - this.buttonConvert.Size = new System.Drawing.Size(98, 23); - this.buttonConvert.TabIndex = 2; - this.buttonConvert.Text = "&Convert"; - this.buttonConvert.UseVisualStyleBackColor = true; - this.buttonConvert.Click += new System.EventHandler(this.buttonConvert_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(948, 618); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 3; - this.buttonCancel.Text = "&Done"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // groupBoxConvertOptions - // - this.groupBoxConvertOptions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxConvertOptions.Controls.Add(this.groupBoxDeleteLines); - this.groupBoxConvertOptions.Controls.Add(this.groupBoxRemoveStyle); - this.groupBoxConvertOptions.Controls.Add(this.groupBoxOffsetTimeCodes); - this.groupBoxConvertOptions.Controls.Add(this.buttonConvertOptionsSettings); - this.groupBoxConvertOptions.Controls.Add(this.listViewConvertOptions); - this.groupBoxConvertOptions.Controls.Add(this.groupBoxChangeFrameRate); - this.groupBoxConvertOptions.Controls.Add(this.groupBoxFixRtl); - this.groupBoxConvertOptions.Controls.Add(this.groupBoxSpeed); - this.groupBoxConvertOptions.Controls.Add(this.groupBoxChangeCasing); - this.groupBoxConvertOptions.Controls.Add(this.groupBoxMergeShortLines); - this.groupBoxConvertOptions.Controls.Add(this.groupBoxAdjustDuration); - this.groupBoxConvertOptions.Location = new System.Drawing.Point(422, 19); - this.groupBoxConvertOptions.Name = "groupBoxConvertOptions"; - this.groupBoxConvertOptions.Size = new System.Drawing.Size(583, 275); - this.groupBoxConvertOptions.TabIndex = 11; - this.groupBoxConvertOptions.TabStop = false; - this.groupBoxConvertOptions.Text = "Convert options"; - // - // groupBoxDeleteLines - // - this.groupBoxDeleteLines.Controls.Add(this.textBoxDeleteContains); - this.groupBoxDeleteLines.Controls.Add(this.labelDeleteLinesContaining); - this.groupBoxDeleteLines.Controls.Add(this.numericUpDownDeleteLast); - this.groupBoxDeleteLines.Controls.Add(this.labelDeleteLastLines); - this.groupBoxDeleteLines.Controls.Add(this.numericUpDownDeleteFirst); - this.groupBoxDeleteLines.Controls.Add(this.labelDeleteFirstLines); - this.groupBoxDeleteLines.Location = new System.Drawing.Point(305, 94); - this.groupBoxDeleteLines.Name = "groupBoxDeleteLines"; - this.groupBoxDeleteLines.Size = new System.Drawing.Size(271, 140); - this.groupBoxDeleteLines.TabIndex = 308; - this.groupBoxDeleteLines.TabStop = false; - this.groupBoxDeleteLines.Text = "Delete lines"; - this.groupBoxDeleteLines.Visible = false; - // - // textBoxDeleteContains - // - this.textBoxDeleteContains.Location = new System.Drawing.Point(10, 110); - this.textBoxDeleteContains.Name = "textBoxDeleteContains"; - this.textBoxDeleteContains.Size = new System.Drawing.Size(237, 20); - this.textBoxDeleteContains.TabIndex = 5; - // - // labelDeleteLinesContaining - // - this.labelDeleteLinesContaining.AutoSize = true; - this.labelDeleteLinesContaining.Location = new System.Drawing.Point(9, 89); - this.labelDeleteLinesContaining.Name = "labelDeleteLinesContaining"; - this.labelDeleteLinesContaining.Size = new System.Drawing.Size(114, 13); - this.labelDeleteLinesContaining.TabIndex = 4; - this.labelDeleteLinesContaining.Text = "Delete lines containing"; - // - // numericUpDownDeleteLast - // - this.numericUpDownDeleteLast.Location = new System.Drawing.Point(92, 45); - this.numericUpDownDeleteLast.Name = "numericUpDownDeleteLast"; - this.numericUpDownDeleteLast.Size = new System.Drawing.Size(43, 20); - this.numericUpDownDeleteLast.TabIndex = 3; - // - // labelDeleteLastLines - // - this.labelDeleteLastLines.AutoSize = true; - this.labelDeleteLastLines.Location = new System.Drawing.Point(5, 47); - this.labelDeleteLastLines.Name = "labelDeleteLastLines"; - this.labelDeleteLastLines.Size = new System.Drawing.Size(81, 13); - this.labelDeleteLastLines.TabIndex = 2; - this.labelDeleteLastLines.Text = "Delete last lines"; - // - // numericUpDownDeleteFirst - // - this.numericUpDownDeleteFirst.Location = new System.Drawing.Point(93, 19); - this.numericUpDownDeleteFirst.Name = "numericUpDownDeleteFirst"; - this.numericUpDownDeleteFirst.Size = new System.Drawing.Size(43, 20); - this.numericUpDownDeleteFirst.TabIndex = 1; - // - // labelDeleteFirstLines - // - this.labelDeleteFirstLines.AutoSize = true; - this.labelDeleteFirstLines.Location = new System.Drawing.Point(6, 20); - this.labelDeleteFirstLines.Name = "labelDeleteFirstLines"; - this.labelDeleteFirstLines.Size = new System.Drawing.Size(81, 13); - this.labelDeleteFirstLines.TabIndex = 0; - this.labelDeleteFirstLines.Text = "Delete first lines"; - // - // groupBoxRemoveStyle - // - this.groupBoxRemoveStyle.Controls.Add(this.textBoxRemoveStyle); - this.groupBoxRemoveStyle.Controls.Add(this.labelStyleName); - this.groupBoxRemoveStyle.Location = new System.Drawing.Point(307, 12); - this.groupBoxRemoveStyle.Name = "groupBoxRemoveStyle"; - this.groupBoxRemoveStyle.Size = new System.Drawing.Size(271, 76); - this.groupBoxRemoveStyle.TabIndex = 307; - this.groupBoxRemoveStyle.TabStop = false; - this.groupBoxRemoveStyle.Text = "Remove style/actor"; - this.groupBoxRemoveStyle.Visible = false; - // - // textBoxRemoveStyle - // - this.textBoxRemoveStyle.Location = new System.Drawing.Point(6, 35); - this.textBoxRemoveStyle.Name = "textBoxRemoveStyle"; - this.textBoxRemoveStyle.Size = new System.Drawing.Size(257, 20); - this.textBoxRemoveStyle.TabIndex = 8; - // - // labelStyleName - // - this.labelStyleName.AutoSize = true; - this.labelStyleName.Location = new System.Drawing.Point(6, 20); - this.labelStyleName.Name = "labelStyleName"; - this.labelStyleName.Size = new System.Drawing.Size(59, 13); - this.labelStyleName.TabIndex = 0; - this.labelStyleName.Text = "Style/actor"; - // - // groupBoxOffsetTimeCodes - // - this.groupBoxOffsetTimeCodes.Controls.Add(this.radioButtonShowLater); - this.groupBoxOffsetTimeCodes.Controls.Add(this.radioButtonShowEarlier); - this.groupBoxOffsetTimeCodes.Controls.Add(this.timeUpDownAdjust); - this.groupBoxOffsetTimeCodes.Controls.Add(this.labelHourMinSecMilliSecond); - this.groupBoxOffsetTimeCodes.Location = new System.Drawing.Point(305, 19); - this.groupBoxOffsetTimeCodes.Name = "groupBoxOffsetTimeCodes"; - this.groupBoxOffsetTimeCodes.Size = new System.Drawing.Size(271, 119); - this.groupBoxOffsetTimeCodes.TabIndex = 306; - this.groupBoxOffsetTimeCodes.TabStop = false; - this.groupBoxOffsetTimeCodes.Text = "Offset time codes"; - this.groupBoxOffsetTimeCodes.Visible = false; - // - // radioButtonShowLater - // - this.radioButtonShowLater.AutoSize = true; - this.radioButtonShowLater.Checked = true; - this.radioButtonShowLater.Location = new System.Drawing.Point(9, 89); - this.radioButtonShowLater.Name = "radioButtonShowLater"; - this.radioButtonShowLater.Size = new System.Drawing.Size(75, 17); - this.radioButtonShowLater.TabIndex = 3; - this.radioButtonShowLater.TabStop = true; - this.radioButtonShowLater.Text = "Show later"; - this.radioButtonShowLater.UseVisualStyleBackColor = true; - // - // radioButtonShowEarlier - // - this.radioButtonShowEarlier.AutoSize = true; - this.radioButtonShowEarlier.Location = new System.Drawing.Point(9, 66); - this.radioButtonShowEarlier.Name = "radioButtonShowEarlier"; - this.radioButtonShowEarlier.Size = new System.Drawing.Size(83, 17); - this.radioButtonShowEarlier.TabIndex = 2; - this.radioButtonShowEarlier.Text = "Show earlier"; - this.radioButtonShowEarlier.UseVisualStyleBackColor = true; - // - // timeUpDownAdjust - // - this.timeUpDownAdjust.AutoSize = true; - this.timeUpDownAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownAdjust.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); - this.timeUpDownAdjust.Location = new System.Drawing.Point(7, 37); - this.timeUpDownAdjust.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownAdjust.Name = "timeUpDownAdjust"; - this.timeUpDownAdjust.Size = new System.Drawing.Size(111, 27); - this.timeUpDownAdjust.TabIndex = 1; - timeCode1.Hours = 0; - timeCode1.Milliseconds = 0; - timeCode1.Minutes = 0; - timeCode1.Seconds = 0; - timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode1.TotalMilliseconds = 0D; - timeCode1.TotalSeconds = 0D; - this.timeUpDownAdjust.TimeCode = timeCode1; - this.timeUpDownAdjust.UseVideoOffset = false; - // - // labelHourMinSecMilliSecond - // - this.labelHourMinSecMilliSecond.AutoSize = true; - this.labelHourMinSecMilliSecond.Location = new System.Drawing.Point(6, 20); - this.labelHourMinSecMilliSecond.Name = "labelHourMinSecMilliSecond"; - this.labelHourMinSecMilliSecond.Size = new System.Drawing.Size(90, 13); - this.labelHourMinSecMilliSecond.TabIndex = 0; - this.labelHourMinSecMilliSecond.Text = "Hours:min:sec.ms"; - // - // buttonConvertOptionsSettings - // - this.buttonConvertOptionsSettings.Location = new System.Drawing.Point(305, 144); - this.buttonConvertOptionsSettings.Name = "buttonConvertOptionsSettings"; - this.buttonConvertOptionsSettings.Size = new System.Drawing.Size(116, 23); - this.buttonConvertOptionsSettings.TabIndex = 302; - this.buttonConvertOptionsSettings.Text = "Settings..."; - this.buttonConvertOptionsSettings.UseVisualStyleBackColor = true; - this.buttonConvertOptionsSettings.Visible = false; - this.buttonConvertOptionsSettings.Click += new System.EventHandler(this.ButtonOptionConvertSettings); - // - // listViewConvertOptions - // - this.listViewConvertOptions.CheckBoxes = true; - this.listViewConvertOptions.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.ActionCheckBox, - this.Action}); - this.listViewConvertOptions.ContextMenuStrip = this.contextMenuStripOptions; - this.listViewConvertOptions.FullRowSelect = true; - this.listViewConvertOptions.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; - this.listViewConvertOptions.HideSelection = false; - this.listViewConvertOptions.Location = new System.Drawing.Point(6, 17); - this.listViewConvertOptions.MultiSelect = false; - this.listViewConvertOptions.Name = "listViewConvertOptions"; - this.listViewConvertOptions.Size = new System.Drawing.Size(293, 252); - this.listViewConvertOptions.TabIndex = 301; - this.listViewConvertOptions.UseCompatibleStateImageBehavior = false; - this.listViewConvertOptions.View = System.Windows.Forms.View.Details; - this.listViewConvertOptions.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listViewConvertOptions_ItemChecked); - this.listViewConvertOptions.SelectedIndexChanged += new System.EventHandler(this.listViewConvertOptions_SelectedIndexChanged); - // - // ActionCheckBox - // - this.ActionCheckBox.Width = 30; - // - // Action - // - this.Action.Width = 400; - // - // contextMenuStripOptions - // - this.contextMenuStripOptions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemSelectAll, - this.inverseSelectionToolStripMenuItem}); - this.contextMenuStripOptions.Name = "contextMenuStripOptions"; - this.contextMenuStripOptions.Size = new System.Drawing.Size(162, 48); - // - // toolStripMenuItemSelectAll - // - this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; - this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(161, 22); - this.toolStripMenuItemSelectAll.Text = "Select all"; - this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); - // - // inverseSelectionToolStripMenuItem - // - this.inverseSelectionToolStripMenuItem.Name = "inverseSelectionToolStripMenuItem"; - this.inverseSelectionToolStripMenuItem.Size = new System.Drawing.Size(161, 22); - this.inverseSelectionToolStripMenuItem.Text = "Inverse selection"; - this.inverseSelectionToolStripMenuItem.Click += new System.EventHandler(this.inverseSelectionToolStripMenuItem_Click); - // - // groupBoxChangeFrameRate - // - this.groupBoxChangeFrameRate.Controls.Add(this.buttonSwapFrameRate); - this.groupBoxChangeFrameRate.Controls.Add(this.comboBoxFrameRateTo); - this.groupBoxChangeFrameRate.Controls.Add(this.labelToFrameRate); - this.groupBoxChangeFrameRate.Controls.Add(this.comboBoxFrameRateFrom); - this.groupBoxChangeFrameRate.Controls.Add(this.labelFromFrameRate); - this.groupBoxChangeFrameRate.Location = new System.Drawing.Point(307, 12); - this.groupBoxChangeFrameRate.Name = "groupBoxChangeFrameRate"; - this.groupBoxChangeFrameRate.Size = new System.Drawing.Size(269, 90); - this.groupBoxChangeFrameRate.TabIndex = 305; - this.groupBoxChangeFrameRate.TabStop = false; - this.groupBoxChangeFrameRate.Text = "Change frame rate"; - this.groupBoxChangeFrameRate.Visible = false; - // - // buttonSwapFrameRate - // - this.buttonSwapFrameRate.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.buttonSwapFrameRate.Location = new System.Drawing.Point(207, 28); - this.buttonSwapFrameRate.Name = "buttonSwapFrameRate"; - this.buttonSwapFrameRate.Size = new System.Drawing.Size(27, 28); - this.buttonSwapFrameRate.TabIndex = 9; - this.buttonSwapFrameRate.Text = "<->"; - this.buttonSwapFrameRate.UseVisualStyleBackColor = true; - this.buttonSwapFrameRate.Click += new System.EventHandler(this.buttonSwapFrameRate_Click); - // - // comboBoxFrameRateTo - // - this.comboBoxFrameRateTo.FormattingEnabled = true; - this.comboBoxFrameRateTo.Location = new System.Drawing.Point(130, 46); - this.comboBoxFrameRateTo.Name = "comboBoxFrameRateTo"; - this.comboBoxFrameRateTo.Size = new System.Drawing.Size(71, 21); - this.comboBoxFrameRateTo.TabIndex = 3; - // - // labelToFrameRate - // - this.labelToFrameRate.AutoSize = true; - this.labelToFrameRate.Location = new System.Drawing.Point(6, 50); - this.labelToFrameRate.Name = "labelToFrameRate"; - this.labelToFrameRate.Size = new System.Drawing.Size(70, 13); - this.labelToFrameRate.TabIndex = 2; - this.labelToFrameRate.Text = "To frame rate"; - // - // comboBoxFrameRateFrom - // - this.comboBoxFrameRateFrom.FormattingEnabled = true; - this.comboBoxFrameRateFrom.Location = new System.Drawing.Point(130, 17); - this.comboBoxFrameRateFrom.Name = "comboBoxFrameRateFrom"; - this.comboBoxFrameRateFrom.Size = new System.Drawing.Size(71, 21); - this.comboBoxFrameRateFrom.TabIndex = 1; - // - // labelFromFrameRate - // - this.labelFromFrameRate.AutoSize = true; - this.labelFromFrameRate.Location = new System.Drawing.Point(6, 21); - this.labelFromFrameRate.Name = "labelFromFrameRate"; - this.labelFromFrameRate.Size = new System.Drawing.Size(80, 13); - this.labelFromFrameRate.TabIndex = 0; - this.labelFromFrameRate.Text = "From frame rate"; - // - // groupBoxFixRtl - // - this.groupBoxFixRtl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxFixRtl.Controls.Add(this.radioButtonReverseStartEnd); - this.groupBoxFixRtl.Controls.Add(this.radioButtonRemoveUnicode); - this.groupBoxFixRtl.Controls.Add(this.radioButtonAddUnicode); - this.groupBoxFixRtl.Location = new System.Drawing.Point(305, 17); - this.groupBoxFixRtl.Name = "groupBoxFixRtl"; - this.groupBoxFixRtl.Size = new System.Drawing.Size(271, 115); - this.groupBoxFixRtl.TabIndex = 303; - this.groupBoxFixRtl.TabStop = false; - this.groupBoxFixRtl.Text = "Settings"; - this.groupBoxFixRtl.Visible = false; - // - // radioButtonReverseStartEnd - // - this.radioButtonReverseStartEnd.AutoSize = true; - this.radioButtonReverseStartEnd.Location = new System.Drawing.Point(19, 77); - this.radioButtonReverseStartEnd.Name = "radioButtonReverseStartEnd"; - this.radioButtonReverseStartEnd.Size = new System.Drawing.Size(135, 17); - this.radioButtonReverseStartEnd.TabIndex = 2; - this.radioButtonReverseStartEnd.TabStop = true; - this.radioButtonReverseStartEnd.Text = "Reverse RTL start/end"; - this.radioButtonReverseStartEnd.UseVisualStyleBackColor = true; - // - // radioButtonRemoveUnicode - // - this.radioButtonRemoveUnicode.AutoSize = true; - this.radioButtonRemoveUnicode.Location = new System.Drawing.Point(19, 54); - this.radioButtonRemoveUnicode.Name = "radioButtonRemoveUnicode"; - this.radioButtonRemoveUnicode.Size = new System.Drawing.Size(153, 17); - this.radioButtonRemoveUnicode.TabIndex = 1; - this.radioButtonRemoveUnicode.TabStop = true; - this.radioButtonRemoveUnicode.Text = "Remove RTL unicode tags"; - this.radioButtonRemoveUnicode.UseVisualStyleBackColor = true; - // - // radioButtonAddUnicode - // - this.radioButtonAddUnicode.AutoSize = true; - this.radioButtonAddUnicode.Location = new System.Drawing.Point(19, 31); - this.radioButtonAddUnicode.Name = "radioButtonAddUnicode"; - this.radioButtonAddUnicode.Size = new System.Drawing.Size(145, 17); - this.radioButtonAddUnicode.TabIndex = 0; - this.radioButtonAddUnicode.TabStop = true; - this.radioButtonAddUnicode.Text = "Fix RTL via Unicode tags"; - this.radioButtonAddUnicode.UseVisualStyleBackColor = true; - // - // groupBoxSpeed - // - this.groupBoxSpeed.Controls.Add(this.radioButtonToDropFrame); - this.groupBoxSpeed.Controls.Add(this.radioButtonSpeedFromDropFrame); - this.groupBoxSpeed.Controls.Add(this.radioButtonSpeedCustom); - this.groupBoxSpeed.Controls.Add(this.numericUpDownPercent); - this.groupBoxSpeed.Controls.Add(this.labelPercent); - this.groupBoxSpeed.Location = new System.Drawing.Point(305, 17); - this.groupBoxSpeed.Name = "groupBoxSpeed"; - this.groupBoxSpeed.Size = new System.Drawing.Size(271, 129); - this.groupBoxSpeed.TabIndex = 307; - this.groupBoxSpeed.TabStop = false; - this.groupBoxSpeed.Text = "Change speed"; - this.groupBoxSpeed.Visible = false; - // - // radioButtonToDropFrame - // - this.radioButtonToDropFrame.AutoSize = true; - this.radioButtonToDropFrame.Location = new System.Drawing.Point(6, 91); - this.radioButtonToDropFrame.Name = "radioButtonToDropFrame"; - this.radioButtonToDropFrame.Size = new System.Drawing.Size(91, 17); - this.radioButtonToDropFrame.TabIndex = 3; - this.radioButtonToDropFrame.Text = "To drop frame"; - this.radioButtonToDropFrame.UseVisualStyleBackColor = true; - this.radioButtonToDropFrame.CheckedChanged += new System.EventHandler(this.radioButtonToDropFrame_CheckedChanged); - // - // radioButtonSpeedFromDropFrame - // - this.radioButtonSpeedFromDropFrame.AutoSize = true; - this.radioButtonSpeedFromDropFrame.Location = new System.Drawing.Point(6, 68); - this.radioButtonSpeedFromDropFrame.Name = "radioButtonSpeedFromDropFrame"; - this.radioButtonSpeedFromDropFrame.Size = new System.Drawing.Size(101, 17); - this.radioButtonSpeedFromDropFrame.TabIndex = 2; - this.radioButtonSpeedFromDropFrame.Text = "From drop frame"; - this.radioButtonSpeedFromDropFrame.UseVisualStyleBackColor = true; - this.radioButtonSpeedFromDropFrame.CheckedChanged += new System.EventHandler(this.radioButtonSpeedFromDropFrame_CheckedChanged); - // - // radioButtonSpeedCustom - // - this.radioButtonSpeedCustom.AutoSize = true; - this.radioButtonSpeedCustom.Checked = true; - this.radioButtonSpeedCustom.Location = new System.Drawing.Point(6, 45); - this.radioButtonSpeedCustom.Name = "radioButtonSpeedCustom"; - this.radioButtonSpeedCustom.Size = new System.Drawing.Size(60, 17); - this.radioButtonSpeedCustom.TabIndex = 1; - this.radioButtonSpeedCustom.TabStop = true; - this.radioButtonSpeedCustom.Text = "Custom"; - this.radioButtonSpeedCustom.UseVisualStyleBackColor = true; - this.radioButtonSpeedCustom.CheckedChanged += new System.EventHandler(this.radioButtonSpeedCustom_CheckedChanged); - // - // numericUpDownPercent - // - this.numericUpDownPercent.DecimalPlaces = 5; - this.numericUpDownPercent.Location = new System.Drawing.Point(6, 19); - this.numericUpDownPercent.Maximum = new decimal(new int[] { - 200, - 0, - 0, - 0}); - this.numericUpDownPercent.Minimum = new decimal(new int[] { - 50, - 0, - 0, - 0}); - this.numericUpDownPercent.Name = "numericUpDownPercent"; - this.numericUpDownPercent.Size = new System.Drawing.Size(81, 20); - this.numericUpDownPercent.TabIndex = 0; - this.numericUpDownPercent.Value = new decimal(new int[] { - 100, - 0, - 0, - 0}); - // - // labelPercent - // - this.labelPercent.AutoSize = true; - this.labelPercent.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.labelPercent.Location = new System.Drawing.Point(87, 22); - this.labelPercent.Name = "labelPercent"; - this.labelPercent.Size = new System.Drawing.Size(15, 13); - this.labelPercent.TabIndex = 12; - this.labelPercent.Text = "%"; - // - // groupBoxChangeCasing - // - this.groupBoxChangeCasing.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxChangeCasing.Controls.Add(this.radioButtonFixOnlyNames); - this.groupBoxChangeCasing.Controls.Add(this.radioButtonLowercase); - this.groupBoxChangeCasing.Controls.Add(this.radioButtonUppercase); - this.groupBoxChangeCasing.Controls.Add(this.radioButtonNormal); - this.groupBoxChangeCasing.Location = new System.Drawing.Point(308, 16); - this.groupBoxChangeCasing.Name = "groupBoxChangeCasing"; - this.groupBoxChangeCasing.Size = new System.Drawing.Size(268, 125); - this.groupBoxChangeCasing.TabIndex = 308; - this.groupBoxChangeCasing.TabStop = false; - this.groupBoxChangeCasing.Text = "Change casing to"; - // - // radioButtonFixOnlyNames - // - this.radioButtonFixOnlyNames.AutoSize = true; - this.radioButtonFixOnlyNames.Location = new System.Drawing.Point(11, 43); - this.radioButtonFixOnlyNames.Name = "radioButtonFixOnlyNames"; - this.radioButtonFixOnlyNames.Size = new System.Drawing.Size(263, 17); - this.radioButtonFixOnlyNames.TabIndex = 6; - this.radioButtonFixOnlyNames.Text = "Fix only names casing (via Dictionaries\\names.xml)"; - this.radioButtonFixOnlyNames.UseVisualStyleBackColor = true; - // - // radioButtonLowercase - // - this.radioButtonLowercase.AutoSize = true; - this.radioButtonLowercase.Location = new System.Drawing.Point(11, 89); - this.radioButtonLowercase.Name = "radioButtonLowercase"; - this.radioButtonLowercase.Size = new System.Drawing.Size(86, 17); - this.radioButtonLowercase.TabIndex = 10; - this.radioButtonLowercase.Text = "all lowercase"; - this.radioButtonLowercase.UseVisualStyleBackColor = true; - // - // radioButtonUppercase - // - this.radioButtonUppercase.AutoSize = true; - this.radioButtonUppercase.Location = new System.Drawing.Point(11, 66); - this.radioButtonUppercase.Name = "radioButtonUppercase"; - this.radioButtonUppercase.Size = new System.Drawing.Size(112, 17); - this.radioButtonUppercase.TabIndex = 8; - this.radioButtonUppercase.Text = "ALL UPPERCASE"; - this.radioButtonUppercase.UseVisualStyleBackColor = true; - // - // radioButtonNormal - // - this.radioButtonNormal.AutoSize = true; - this.radioButtonNormal.Checked = true; - this.radioButtonNormal.Location = new System.Drawing.Point(11, 18); - this.radioButtonNormal.Name = "radioButtonNormal"; - this.radioButtonNormal.Size = new System.Drawing.Size(282, 17); - this.radioButtonNormal.TabIndex = 0; - this.radioButtonNormal.TabStop = true; - this.radioButtonNormal.Text = "Normal casing. Sentences begin with uppercase letter."; - this.radioButtonNormal.UseVisualStyleBackColor = true; - // - // groupBoxMergeShortLines - // - this.groupBoxMergeShortLines.Controls.Add(this.checkBoxOnlyContinuationLines); - this.groupBoxMergeShortLines.Controls.Add(this.numericUpDownMaxCharacters); - this.groupBoxMergeShortLines.Controls.Add(this.numericUpDownMaxMillisecondsBetweenLines); - this.groupBoxMergeShortLines.Controls.Add(this.labelMaxMillisecondsBetweenLines); - this.groupBoxMergeShortLines.Controls.Add(this.labelMaxCharacters); - this.groupBoxMergeShortLines.Location = new System.Drawing.Point(308, 23); - this.groupBoxMergeShortLines.Name = "groupBoxMergeShortLines"; - this.groupBoxMergeShortLines.Size = new System.Drawing.Size(268, 149); - this.groupBoxMergeShortLines.TabIndex = 304; - this.groupBoxMergeShortLines.TabStop = false; - this.groupBoxMergeShortLines.Text = "Merge short lines"; - this.groupBoxMergeShortLines.Visible = false; - // - // checkBoxOnlyContinuationLines - // - this.checkBoxOnlyContinuationLines.AutoSize = true; - this.checkBoxOnlyContinuationLines.Checked = true; - this.checkBoxOnlyContinuationLines.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxOnlyContinuationLines.Location = new System.Drawing.Point(16, 127); - this.checkBoxOnlyContinuationLines.Name = "checkBoxOnlyContinuationLines"; - this.checkBoxOnlyContinuationLines.Size = new System.Drawing.Size(164, 17); - this.checkBoxOnlyContinuationLines.TabIndex = 42; - this.checkBoxOnlyContinuationLines.Text = "Only merge continuation lines"; - this.checkBoxOnlyContinuationLines.UseVisualStyleBackColor = true; - // - // numericUpDownMaxCharacters - // - this.numericUpDownMaxCharacters.Location = new System.Drawing.Point(15, 41); - this.numericUpDownMaxCharacters.Maximum = new decimal(new int[] { - 999, - 0, - 0, - 0}); - this.numericUpDownMaxCharacters.Minimum = new decimal(new int[] { - 10, - 0, - 0, - 0}); - this.numericUpDownMaxCharacters.Name = "numericUpDownMaxCharacters"; - this.numericUpDownMaxCharacters.Size = new System.Drawing.Size(64, 20); - this.numericUpDownMaxCharacters.TabIndex = 38; - this.numericUpDownMaxCharacters.Value = new decimal(new int[] { - 65, - 0, - 0, - 0}); - // - // numericUpDownMaxMillisecondsBetweenLines - // - this.numericUpDownMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(15, 90); - this.numericUpDownMaxMillisecondsBetweenLines.Maximum = new decimal(new int[] { - 2000, - 0, - 0, - 0}); - this.numericUpDownMaxMillisecondsBetweenLines.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.numericUpDownMaxMillisecondsBetweenLines.Name = "numericUpDownMaxMillisecondsBetweenLines"; - this.numericUpDownMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(64, 20); - this.numericUpDownMaxMillisecondsBetweenLines.TabIndex = 39; - this.numericUpDownMaxMillisecondsBetweenLines.Value = new decimal(new int[] { - 250, - 0, - 0, - 0}); - // - // labelMaxMillisecondsBetweenLines - // - this.labelMaxMillisecondsBetweenLines.AutoSize = true; - this.labelMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(12, 73); - this.labelMaxMillisecondsBetweenLines.Name = "labelMaxMillisecondsBetweenLines"; - this.labelMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(178, 13); - this.labelMaxMillisecondsBetweenLines.TabIndex = 41; - this.labelMaxMillisecondsBetweenLines.Text = "Maximum milliseconds between lines"; - // - // labelMaxCharacters - // - this.labelMaxCharacters.AutoSize = true; - this.labelMaxCharacters.Location = new System.Drawing.Point(12, 23); - this.labelMaxCharacters.Name = "labelMaxCharacters"; - this.labelMaxCharacters.Size = new System.Drawing.Size(187, 13); - this.labelMaxCharacters.TabIndex = 40; - this.labelMaxCharacters.Text = "Maximum characters in one paragraph"; - // - // groupBoxAdjustDuration - // - this.groupBoxAdjustDuration.Controls.Add(this.comboBoxAdjustDurationVia); - this.groupBoxAdjustDuration.Controls.Add(this.labelAdjustDurationVia); - this.groupBoxAdjustDuration.Controls.Add(this.panelAdjustDurationFixed); - this.groupBoxAdjustDuration.Controls.Add(this.panelAdjustDurationAddPercent); - this.groupBoxAdjustDuration.Controls.Add(this.panelAdjustDurationAddSeconds); - this.groupBoxAdjustDuration.Controls.Add(this.panelAdjustDurationRecalc); - this.groupBoxAdjustDuration.Location = new System.Drawing.Point(305, 16); - this.groupBoxAdjustDuration.Name = "groupBoxAdjustDuration"; - this.groupBoxAdjustDuration.Size = new System.Drawing.Size(271, 251); - this.groupBoxAdjustDuration.TabIndex = 308; - this.groupBoxAdjustDuration.TabStop = false; - this.groupBoxAdjustDuration.Text = "Adjust duration"; - this.groupBoxAdjustDuration.Visible = false; - // - // comboBoxAdjustDurationVia - // - this.comboBoxAdjustDurationVia.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxAdjustDurationVia.FormattingEnabled = true; - this.comboBoxAdjustDurationVia.Location = new System.Drawing.Point(65, 19); - this.comboBoxAdjustDurationVia.Name = "comboBoxAdjustDurationVia"; - this.comboBoxAdjustDurationVia.Size = new System.Drawing.Size(121, 21); - this.comboBoxAdjustDurationVia.TabIndex = 8; - this.comboBoxAdjustDurationVia.SelectedIndexChanged += new System.EventHandler(this.comboBoxAdjustDurationVia_SelectedIndexChanged); - // - // labelAdjustDurationVia - // - this.labelAdjustDurationVia.AutoSize = true; - this.labelAdjustDurationVia.Location = new System.Drawing.Point(8, 22); - this.labelAdjustDurationVia.Name = "labelAdjustDurationVia"; - this.labelAdjustDurationVia.Size = new System.Drawing.Size(51, 13); - this.labelAdjustDurationVia.TabIndex = 7; - this.labelAdjustDurationVia.Text = "AdjustVia"; - // - // panelAdjustDurationFixed - // - this.panelAdjustDurationFixed.Controls.Add(this.numericUpDownFixedMilliseconds); - this.panelAdjustDurationFixed.Controls.Add(this.labelMillisecondsFixed); - this.panelAdjustDurationFixed.Location = new System.Drawing.Point(6, 123); - this.panelAdjustDurationFixed.Name = "panelAdjustDurationFixed"; - this.panelAdjustDurationFixed.Size = new System.Drawing.Size(257, 57); - this.panelAdjustDurationFixed.TabIndex = 15; - // - // numericUpDownFixedMilliseconds - // - this.numericUpDownFixedMilliseconds.Location = new System.Drawing.Point(8, 27); - this.numericUpDownFixedMilliseconds.Maximum = new decimal(new int[] { - 20000, - 0, - 0, - 0}); - this.numericUpDownFixedMilliseconds.Name = "numericUpDownFixedMilliseconds"; - this.numericUpDownFixedMilliseconds.Size = new System.Drawing.Size(80, 20); - this.numericUpDownFixedMilliseconds.TabIndex = 13; - this.numericUpDownFixedMilliseconds.Value = new decimal(new int[] { - 3000, - 0, - 0, - 0}); - // - // labelMillisecondsFixed - // - this.labelMillisecondsFixed.AutoSize = true; - this.labelMillisecondsFixed.Location = new System.Drawing.Point(5, 8); - this.labelMillisecondsFixed.Name = "labelMillisecondsFixed"; - this.labelMillisecondsFixed.Size = new System.Drawing.Size(64, 13); - this.labelMillisecondsFixed.TabIndex = 14; - this.labelMillisecondsFixed.Text = "Milliseconds"; - // - // panelAdjustDurationAddPercent - // - this.panelAdjustDurationAddPercent.Controls.Add(this.label1); - this.panelAdjustDurationAddPercent.Controls.Add(this.numericUpDownAdjustViaPercent); - this.panelAdjustDurationAddPercent.Controls.Add(this.labelAdjustViaPercent); - this.panelAdjustDurationAddPercent.Location = new System.Drawing.Point(7, 79); - this.panelAdjustDurationAddPercent.Name = "panelAdjustDurationAddPercent"; - this.panelAdjustDurationAddPercent.Size = new System.Drawing.Size(257, 63); - this.panelAdjustDurationAddPercent.TabIndex = 14; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(90, 34); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(15, 13); - this.label1.TabIndex = 25; - this.label1.Text = "%"; - // - // numericUpDownAdjustViaPercent - // - this.numericUpDownAdjustViaPercent.Location = new System.Drawing.Point(8, 27); - this.numericUpDownAdjustViaPercent.Maximum = new decimal(new int[] { - 150, - 0, - 0, - 0}); - this.numericUpDownAdjustViaPercent.Minimum = new decimal(new int[] { - 75, - 0, - 0, - 0}); - this.numericUpDownAdjustViaPercent.Name = "numericUpDownAdjustViaPercent"; - this.numericUpDownAdjustViaPercent.Size = new System.Drawing.Size(80, 20); - this.numericUpDownAdjustViaPercent.TabIndex = 24; - this.numericUpDownAdjustViaPercent.Value = new decimal(new int[] { - 110, - 0, - 0, - 0}); - // - // labelAdjustViaPercent - // - this.labelAdjustViaPercent.AutoSize = true; - this.labelAdjustViaPercent.Location = new System.Drawing.Point(5, 8); - this.labelAdjustViaPercent.Name = "labelAdjustViaPercent"; - this.labelAdjustViaPercent.Size = new System.Drawing.Size(86, 13); - this.labelAdjustViaPercent.TabIndex = 23; - this.labelAdjustViaPercent.Text = "Adjust in percent"; - // - // panelAdjustDurationAddSeconds - // - this.panelAdjustDurationAddSeconds.Controls.Add(this.numericUpDownSeconds); - this.panelAdjustDurationAddSeconds.Controls.Add(this.labelAddSeconds); - this.panelAdjustDurationAddSeconds.Location = new System.Drawing.Point(8, 47); - this.panelAdjustDurationAddSeconds.Name = "panelAdjustDurationAddSeconds"; - this.panelAdjustDurationAddSeconds.Size = new System.Drawing.Size(257, 55); - this.panelAdjustDurationAddSeconds.TabIndex = 13; - // - // numericUpDownSeconds - // - this.numericUpDownSeconds.DecimalPlaces = 3; - this.numericUpDownSeconds.Increment = new decimal(new int[] { - 1, - 0, - 0, - 131072}); - this.numericUpDownSeconds.Location = new System.Drawing.Point(8, 27); - this.numericUpDownSeconds.Maximum = new decimal(new int[] { - 20, - 0, - 0, - 0}); - this.numericUpDownSeconds.Minimum = new decimal(new int[] { - 10, - 0, - 0, - -2147483648}); - this.numericUpDownSeconds.Name = "numericUpDownSeconds"; - this.numericUpDownSeconds.Size = new System.Drawing.Size(80, 20); - this.numericUpDownSeconds.TabIndex = 12; - this.numericUpDownSeconds.Value = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - // - // labelAddSeconds - // - this.labelAddSeconds.AutoSize = true; - this.labelAddSeconds.Location = new System.Drawing.Point(5, 8); - this.labelAddSeconds.Name = "labelAddSeconds"; - this.labelAddSeconds.Size = new System.Drawing.Size(69, 13); - this.labelAddSeconds.TabIndex = 11; - this.labelAddSeconds.Text = "Add seconds"; - // - // panelAdjustDurationRecalc - // - this.panelAdjustDurationRecalc.Controls.Add(this.checkBoxExtendOnly); - this.panelAdjustDurationRecalc.Controls.Add(this.numericUpDownOptimalCharsSec); - this.panelAdjustDurationRecalc.Controls.Add(this.labelOptimalCharsSec); - this.panelAdjustDurationRecalc.Controls.Add(this.numericUpDownMaxCharsSec); - this.panelAdjustDurationRecalc.Controls.Add(this.labelMaxCharsPerSecond); - this.panelAdjustDurationRecalc.Location = new System.Drawing.Point(6, 66); - this.panelAdjustDurationRecalc.Name = "panelAdjustDurationRecalc"; - this.panelAdjustDurationRecalc.Size = new System.Drawing.Size(257, 170); - this.panelAdjustDurationRecalc.TabIndex = 16; - // - // checkBoxExtendOnly - // - this.checkBoxExtendOnly.AutoSize = true; - this.checkBoxExtendOnly.Location = new System.Drawing.Point(8, 122); - this.checkBoxExtendOnly.Name = "checkBoxExtendOnly"; - this.checkBoxExtendOnly.Size = new System.Drawing.Size(81, 17); - this.checkBoxExtendOnly.TabIndex = 14; - this.checkBoxExtendOnly.Text = "Extend only"; - this.checkBoxExtendOnly.UseVisualStyleBackColor = true; - // - // numericUpDownOptimalCharsSec - // - this.numericUpDownOptimalCharsSec.DecimalPlaces = 1; - this.numericUpDownOptimalCharsSec.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownOptimalCharsSec.Location = new System.Drawing.Point(8, 85); - this.numericUpDownOptimalCharsSec.Minimum = new decimal(new int[] { - 4, - 0, - 0, - 0}); - this.numericUpDownOptimalCharsSec.Name = "numericUpDownOptimalCharsSec"; - this.numericUpDownOptimalCharsSec.Size = new System.Drawing.Size(80, 20); - this.numericUpDownOptimalCharsSec.TabIndex = 13; - this.numericUpDownOptimalCharsSec.Value = new decimal(new int[] { - 17, - 0, - 0, - 0}); - // - // labelOptimalCharsSec - // - this.labelOptimalCharsSec.AutoSize = true; - this.labelOptimalCharsSec.Location = new System.Drawing.Point(5, 66); - this.labelOptimalCharsSec.Name = "labelOptimalCharsSec"; - this.labelOptimalCharsSec.Size = new System.Drawing.Size(93, 13); - this.labelOptimalCharsSec.TabIndex = 15; - this.labelOptimalCharsSec.Text = "Optimal chars/sec"; - // - // numericUpDownMaxCharsSec - // - this.numericUpDownMaxCharsSec.DecimalPlaces = 1; - this.numericUpDownMaxCharsSec.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownMaxCharsSec.Location = new System.Drawing.Point(8, 27); - this.numericUpDownMaxCharsSec.Minimum = new decimal(new int[] { - 4, - 0, - 0, - 0}); - this.numericUpDownMaxCharsSec.Name = "numericUpDownMaxCharsSec"; - this.numericUpDownMaxCharsSec.Size = new System.Drawing.Size(80, 20); - this.numericUpDownMaxCharsSec.TabIndex = 12; - this.numericUpDownMaxCharsSec.Value = new decimal(new int[] { - 24, - 0, - 0, - 0}); - // - // labelMaxCharsPerSecond - // - this.labelMaxCharsPerSecond.AutoSize = true; - this.labelMaxCharsPerSecond.Location = new System.Drawing.Point(5, 8); - this.labelMaxCharsPerSecond.Name = "labelMaxCharsPerSecond"; - this.labelMaxCharsPerSecond.Size = new System.Drawing.Size(81, 13); - this.labelMaxCharsPerSecond.TabIndex = 11; - this.labelMaxCharsPerSecond.Text = "Max. chars/sec"; - // - // groupBoxOutput - // - this.groupBoxOutput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxOutput.Controls.Add(this.buttonBrowseEncoding); - this.groupBoxOutput.Controls.Add(this.radioButtonSaveInOutputFolder); - this.groupBoxOutput.Controls.Add(this.buttonTransportStreamSettings); - this.groupBoxOutput.Controls.Add(this.linkLabelOpenOutputFolder); - this.groupBoxOutput.Controls.Add(this.checkBoxUseStyleFromSource); - this.groupBoxOutput.Controls.Add(this.checkBoxOverwrite); - this.groupBoxOutput.Controls.Add(this.buttonStyles); - this.groupBoxOutput.Controls.Add(this.buttonChooseFolder); - this.groupBoxOutput.Controls.Add(this.comboBoxSubtitleFormats); - this.groupBoxOutput.Controls.Add(this.textBoxOutputFolder); - this.groupBoxOutput.Controls.Add(this.labelEncoding); - this.groupBoxOutput.Controls.Add(this.radioButtonSaveInSourceFolder); - this.groupBoxOutput.Controls.Add(this.comboBoxEncoding); - this.groupBoxOutput.Controls.Add(this.labelOutputFormat); - this.groupBoxOutput.Controls.Add(this.groupBoxConvertOptions); - this.groupBoxOutput.Location = new System.Drawing.Point(12, 305); - this.groupBoxOutput.Name = "groupBoxOutput"; - this.groupBoxOutput.Size = new System.Drawing.Size(1014, 300); - this.groupBoxOutput.TabIndex = 1; - this.groupBoxOutput.TabStop = false; - this.groupBoxOutput.Text = "Output"; - // - // buttonBrowseEncoding - // - this.buttonBrowseEncoding.Location = new System.Drawing.Point(300, 263); - this.buttonBrowseEncoding.Name = "buttonBrowseEncoding"; - this.buttonBrowseEncoding.Size = new System.Drawing.Size(26, 23); - this.buttonBrowseEncoding.TabIndex = 12; - this.buttonBrowseEncoding.Text = "..."; - this.buttonBrowseEncoding.UseVisualStyleBackColor = true; - this.buttonBrowseEncoding.Click += new System.EventHandler(this.buttonBrowseEncoding_Click); - // - // radioButtonSaveInOutputFolder - // - this.radioButtonSaveInOutputFolder.AutoSize = true; - this.radioButtonSaveInOutputFolder.Location = new System.Drawing.Point(10, 56); - this.radioButtonSaveInOutputFolder.Name = "radioButtonSaveInOutputFolder"; - this.radioButtonSaveInOutputFolder.Size = new System.Drawing.Size(154, 17); - this.radioButtonSaveInOutputFolder.TabIndex = 11; - this.radioButtonSaveInOutputFolder.Text = "Save in output folder below"; - this.radioButtonSaveInOutputFolder.UseVisualStyleBackColor = true; - this.radioButtonSaveInOutputFolder.CheckedChanged += new System.EventHandler(this.radioButtonSaveInOutputFolder_CheckedChanged); - // - // buttonTransportStreamSettings - // - this.buttonTransportStreamSettings.Location = new System.Drawing.Point(300, 236); - this.buttonTransportStreamSettings.Name = "buttonTransportStreamSettings"; - this.buttonTransportStreamSettings.Size = new System.Drawing.Size(116, 23); - this.buttonTransportStreamSettings.TabIndex = 10; - this.buttonTransportStreamSettings.Text = "TS settings..."; - this.buttonTransportStreamSettings.UseVisualStyleBackColor = true; - this.buttonTransportStreamSettings.Visible = false; - this.buttonTransportStreamSettings.Click += new System.EventHandler(this.buttonTransportStreamSettings_Click); - // - // linkLabelOpenOutputFolder - // - this.linkLabelOpenOutputFolder.AutoSize = true; - this.linkLabelOpenOutputFolder.Location = new System.Drawing.Point(357, 81); - this.linkLabelOpenOutputFolder.Name = "linkLabelOpenOutputFolder"; - this.linkLabelOpenOutputFolder.Size = new System.Drawing.Size(42, 13); - this.linkLabelOpenOutputFolder.TabIndex = 9; - this.linkLabelOpenOutputFolder.TabStop = true; - this.linkLabelOpenOutputFolder.Text = "Open..."; - this.linkLabelOpenOutputFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelOpenOutputFolder_LinkClicked); - // - // checkBoxUseStyleFromSource - // - this.checkBoxUseStyleFromSource.AutoSize = true; - this.checkBoxUseStyleFromSource.Location = new System.Drawing.Point(80, 236); - this.checkBoxUseStyleFromSource.Name = "checkBoxUseStyleFromSource"; - this.checkBoxUseStyleFromSource.Size = new System.Drawing.Size(127, 17); - this.checkBoxUseStyleFromSource.TabIndex = 9; - this.checkBoxUseStyleFromSource.Text = "Use style from source"; - this.checkBoxUseStyleFromSource.UseVisualStyleBackColor = true; - this.checkBoxUseStyleFromSource.Visible = false; - // - // checkBoxOverwrite - // - this.checkBoxOverwrite.AutoSize = true; - this.checkBoxOverwrite.Location = new System.Drawing.Point(10, 122); - this.checkBoxOverwrite.Name = "checkBoxOverwrite"; - this.checkBoxOverwrite.Size = new System.Drawing.Size(125, 17); - this.checkBoxOverwrite.TabIndex = 10; - this.checkBoxOverwrite.Text = "Overwrite exiting files"; - this.checkBoxOverwrite.UseVisualStyleBackColor = true; - // - // buttonStyles - // - this.buttonStyles.Location = new System.Drawing.Point(300, 207); - this.buttonStyles.Name = "buttonStyles"; - this.buttonStyles.Size = new System.Drawing.Size(116, 23); - this.buttonStyles.TabIndex = 8; - this.buttonStyles.Text = "Style..."; - this.buttonStyles.UseVisualStyleBackColor = true; - this.buttonStyles.Visible = false; - this.buttonStyles.Click += new System.EventHandler(this.ButtonStylesClick); - // - // buttonChooseFolder - // - this.buttonChooseFolder.Enabled = false; - this.buttonChooseFolder.Location = new System.Drawing.Point(325, 76); - this.buttonChooseFolder.Name = "buttonChooseFolder"; - this.buttonChooseFolder.Size = new System.Drawing.Size(26, 23); - this.buttonChooseFolder.TabIndex = 8; - this.buttonChooseFolder.Text = "..."; - this.buttonChooseFolder.UseVisualStyleBackColor = true; - this.buttonChooseFolder.Click += new System.EventHandler(this.buttonChooseFolder_Click); - // - // comboBoxSubtitleFormats - // - this.comboBoxSubtitleFormats.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSubtitleFormats.FormattingEnabled = true; - this.comboBoxSubtitleFormats.Location = new System.Drawing.Point(80, 209); - this.comboBoxSubtitleFormats.Name = "comboBoxSubtitleFormats"; - this.comboBoxSubtitleFormats.Size = new System.Drawing.Size(214, 21); - this.comboBoxSubtitleFormats.TabIndex = 7; - this.comboBoxSubtitleFormats.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSubtitleFormatsSelectedIndexChanged); - // - // textBoxOutputFolder - // - this.textBoxOutputFolder.Enabled = false; - this.textBoxOutputFolder.Location = new System.Drawing.Point(17, 79); - this.textBoxOutputFolder.Name = "textBoxOutputFolder"; - this.textBoxOutputFolder.Size = new System.Drawing.Size(302, 20); - this.textBoxOutputFolder.TabIndex = 7; - // - // labelEncoding - // - this.labelEncoding.AutoSize = true; - this.labelEncoding.Location = new System.Drawing.Point(10, 267); - this.labelEncoding.Name = "labelEncoding"; - this.labelEncoding.Size = new System.Drawing.Size(52, 13); - this.labelEncoding.TabIndex = 9; - this.labelEncoding.Text = "Encoding"; - // - // radioButtonSaveInSourceFolder - // - this.radioButtonSaveInSourceFolder.AutoSize = true; - this.radioButtonSaveInSourceFolder.Checked = true; - this.radioButtonSaveInSourceFolder.Location = new System.Drawing.Point(10, 27); - this.radioButtonSaveInSourceFolder.Name = "radioButtonSaveInSourceFolder"; - this.radioButtonSaveInSourceFolder.Size = new System.Drawing.Size(141, 17); - this.radioButtonSaveInSourceFolder.TabIndex = 0; - this.radioButtonSaveInSourceFolder.TabStop = true; - this.radioButtonSaveInSourceFolder.Text = "Save in source file folder"; - this.radioButtonSaveInSourceFolder.UseVisualStyleBackColor = true; - this.radioButtonSaveInSourceFolder.CheckedChanged += new System.EventHandler(this.radioButtonSaveInSourceFolder_CheckedChanged); - // - // comboBoxEncoding - // - this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxEncoding.FormattingEnabled = true; - this.comboBoxEncoding.Location = new System.Drawing.Point(80, 264); - this.comboBoxEncoding.Name = "comboBoxEncoding"; - this.comboBoxEncoding.Size = new System.Drawing.Size(214, 21); - this.comboBoxEncoding.TabIndex = 11; - // - // labelOutputFormat - // - this.labelOutputFormat.AutoSize = true; - this.labelOutputFormat.Location = new System.Drawing.Point(10, 212); - this.labelOutputFormat.Name = "labelOutputFormat"; - this.labelOutputFormat.Size = new System.Drawing.Size(39, 13); - this.labelOutputFormat.TabIndex = 6; - this.labelOutputFormat.Text = "Format"; - // - // groupBoxInput - // - this.groupBoxInput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxInput.Controls.Add(this.labelNumberOfFiles); - this.groupBoxInput.Controls.Add(this.textBoxFilter); - this.groupBoxInput.Controls.Add(this.labelFilter); - this.groupBoxInput.Controls.Add(this.comboBoxFilter); - this.groupBoxInput.Controls.Add(this.checkBoxScanFolderRecursive); - this.groupBoxInput.Controls.Add(this.buttonSearchFolder); - this.groupBoxInput.Controls.Add(this.buttonInputBrowse); - this.groupBoxInput.Controls.Add(this.labelChooseInputFiles); - this.groupBoxInput.Controls.Add(this.listViewInputFiles); - this.groupBoxInput.Location = new System.Drawing.Point(12, 12); - this.groupBoxInput.Name = "groupBoxInput"; - this.groupBoxInput.Size = new System.Drawing.Size(1014, 287); - this.groupBoxInput.TabIndex = 0; - this.groupBoxInput.TabStop = false; - this.groupBoxInput.Text = "Input"; - // - // labelNumberOfFiles - // - this.labelNumberOfFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.labelNumberOfFiles.Location = new System.Drawing.Point(872, 258); - this.labelNumberOfFiles.Name = "labelNumberOfFiles"; - this.labelNumberOfFiles.Size = new System.Drawing.Size(100, 16); - this.labelNumberOfFiles.TabIndex = 14; - this.labelNumberOfFiles.Text = "labelNumberOfFiles"; - this.labelNumberOfFiles.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // textBoxFilter - // - this.textBoxFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.textBoxFilter.Location = new System.Drawing.Point(422, 258); - this.textBoxFilter.Name = "textBoxFilter"; - this.textBoxFilter.Size = new System.Drawing.Size(158, 20); - this.textBoxFilter.TabIndex = 13; - // - // labelFilter - // - this.labelFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelFilter.AutoSize = true; - this.labelFilter.Location = new System.Drawing.Point(11, 261); - this.labelFilter.Name = "labelFilter"; - this.labelFilter.Size = new System.Drawing.Size(29, 13); - this.labelFilter.TabIndex = 11; - this.labelFilter.Text = "Filter"; - // - // comboBoxFilter - // - this.comboBoxFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.comboBoxFilter.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxFilter.FormattingEnabled = true; - this.comboBoxFilter.Items.AddRange(new object[] { - "All files", - "SubRip .srt files without BOM header", - "Files with subtitle with more than two lines", - "Files that contains...", - "File name cotains...", - "Mkv language code contains..."}); - this.comboBoxFilter.Location = new System.Drawing.Point(81, 258); - this.comboBoxFilter.Name = "comboBoxFilter"; - this.comboBoxFilter.Size = new System.Drawing.Size(335, 21); - this.comboBoxFilter.TabIndex = 12; - this.comboBoxFilter.SelectedIndexChanged += new System.EventHandler(this.comboBoxFilter_SelectedIndexChanged); - // - // checkBoxScanFolderRecursive - // - this.checkBoxScanFolderRecursive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.checkBoxScanFolderRecursive.AutoSize = true; - this.checkBoxScanFolderRecursive.Checked = true; - this.checkBoxScanFolderRecursive.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxScanFolderRecursive.Location = new System.Drawing.Point(778, 16); - this.checkBoxScanFolderRecursive.Name = "checkBoxScanFolderRecursive"; - this.checkBoxScanFolderRecursive.Size = new System.Drawing.Size(74, 17); - this.checkBoxScanFolderRecursive.TabIndex = 0; - this.checkBoxScanFolderRecursive.Text = "Recursive"; - this.checkBoxScanFolderRecursive.UseVisualStyleBackColor = true; - // - // buttonSearchFolder - // - this.buttonSearchFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSearchFolder.Location = new System.Drawing.Point(858, 12); - this.buttonSearchFolder.Name = "buttonSearchFolder"; - this.buttonSearchFolder.Size = new System.Drawing.Size(116, 23); - this.buttonSearchFolder.TabIndex = 1; - this.buttonSearchFolder.Text = "Search folder..."; - this.buttonSearchFolder.UseVisualStyleBackColor = true; - this.buttonSearchFolder.Click += new System.EventHandler(this.buttonSearchFolder_Click); - // - // buttonInputBrowse - // - this.buttonInputBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonInputBrowse.Location = new System.Drawing.Point(979, 41); - this.buttonInputBrowse.Name = "buttonInputBrowse"; - this.buttonInputBrowse.Size = new System.Drawing.Size(26, 23); - this.buttonInputBrowse.TabIndex = 3; - this.buttonInputBrowse.Text = "..."; - this.buttonInputBrowse.UseVisualStyleBackColor = true; - this.buttonInputBrowse.Click += new System.EventHandler(this.buttonInputBrowse_Click); - // - // labelChooseInputFiles - // - this.labelChooseInputFiles.AutoSize = true; - this.labelChooseInputFiles.Location = new System.Drawing.Point(5, 25); - this.labelChooseInputFiles.Name = "labelChooseInputFiles"; - this.labelChooseInputFiles.Size = new System.Drawing.Size(202, 13); - this.labelChooseInputFiles.TabIndex = 0; - this.labelChooseInputFiles.Text = "Choose input files (browse or drag-n-drop)"; - // - // listViewInputFiles - // - this.listViewInputFiles.AllowDrop = true; - this.listViewInputFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewInputFiles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderFName, - this.columnHeaderSize, - this.columnHeaderFormat, - this.columnHeaderStatus}); - this.listViewInputFiles.ContextMenuStrip = this.contextMenuStripFiles; - this.listViewInputFiles.FullRowSelect = true; - this.listViewInputFiles.HideSelection = false; - this.listViewInputFiles.Location = new System.Drawing.Point(6, 41); - this.listViewInputFiles.Name = "listViewInputFiles"; - this.listViewInputFiles.Size = new System.Drawing.Size(968, 211); - this.listViewInputFiles.TabIndex = 2; - this.listViewInputFiles.UseCompatibleStateImageBehavior = false; - this.listViewInputFiles.View = System.Windows.Forms.View.Details; - this.listViewInputFiles.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewInputFiles_ColumnClick); - this.listViewInputFiles.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewInputFiles_DragDrop); - this.listViewInputFiles.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewInputFiles_DragEnter); - this.listViewInputFiles.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ListViewInputFilesKeyDown); - // - // columnHeaderFName - // - this.columnHeaderFName.Text = "File name"; - this.columnHeaderFName.Width = 500; - // - // columnHeaderSize - // - this.columnHeaderSize.Text = "Size"; - this.columnHeaderSize.Width = 75; - // - // columnHeaderFormat - // - this.columnHeaderFormat.Text = "Format"; - this.columnHeaderFormat.Width = 200; - // - // columnHeaderStatus - // - this.columnHeaderStatus.Text = "Status"; - this.columnHeaderStatus.Width = 124; - // - // contextMenuStripFiles - // - this.contextMenuStripFiles.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.addFilesToolStripMenuItem, - this.toolStripSeparator2, - this.removeToolStripMenuItem, - this.removeAllToolStripMenuItem, - this.openContainingFolderToolStripMenuItem, - this.toolStripSeparator1, - this.convertMkvSettingsToolStripMenuItem}); - this.contextMenuStripFiles.Name = "contextMenuStripStyles"; - this.contextMenuStripFiles.Size = new System.Drawing.Size(400, 126); - this.contextMenuStripFiles.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripFilesOpening); - // - // addFilesToolStripMenuItem - // - this.addFilesToolStripMenuItem.Name = "addFilesToolStripMenuItem"; - this.addFilesToolStripMenuItem.Size = new System.Drawing.Size(399, 22); - this.addFilesToolStripMenuItem.Text = "Add files"; - this.addFilesToolStripMenuItem.Click += new System.EventHandler(this.addFilesToolStripMenuItem_Click); - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(396, 6); - // - // removeToolStripMenuItem - // - this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; - this.removeToolStripMenuItem.Size = new System.Drawing.Size(399, 22); - this.removeToolStripMenuItem.Text = "Remove"; - this.removeToolStripMenuItem.Click += new System.EventHandler(this.RemoveToolStripMenuItemClick); - // - // removeAllToolStripMenuItem - // - this.removeAllToolStripMenuItem.Name = "removeAllToolStripMenuItem"; - this.removeAllToolStripMenuItem.Size = new System.Drawing.Size(399, 22); - this.removeAllToolStripMenuItem.Text = "Remove all"; - this.removeAllToolStripMenuItem.Click += new System.EventHandler(this.RemoveAllToolStripMenuItemClick); - // - // openContainingFolderToolStripMenuItem - // - this.openContainingFolderToolStripMenuItem.Name = "openContainingFolderToolStripMenuItem"; - this.openContainingFolderToolStripMenuItem.Size = new System.Drawing.Size(399, 22); - this.openContainingFolderToolStripMenuItem.Text = "Open containing folder"; - this.openContainingFolderToolStripMenuItem.Click += new System.EventHandler(this.openContainingFolderToolStripMenuItem_Click); - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(396, 6); - // - // convertMkvSettingsToolStripMenuItem - // - this.convertMkvSettingsToolStripMenuItem.Name = "convertMkvSettingsToolStripMenuItem"; - this.convertMkvSettingsToolStripMenuItem.Size = new System.Drawing.Size(399, 22); - this.convertMkvSettingsToolStripMenuItem.Text = "Mkv language in output file name: Three letter language code"; - this.convertMkvSettingsToolStripMenuItem.Click += new System.EventHandler(this.convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem_Click); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // progressBar1 - // - this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.progressBar1.Location = new System.Drawing.Point(15, 627); - this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(820, 10); - this.progressBar1.TabIndex = 8; - // - // labelStatus - // - this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelStatus.AutoSize = true; - this.labelStatus.Location = new System.Drawing.Point(12, 611); - this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(59, 13); - this.labelStatus.TabIndex = 9; - this.labelStatus.Text = "labelStatus"; - // - // BatchConvert - // - this.AllowDrop = true; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1035, 651); - this.Controls.Add(this.labelStatus); - this.Controls.Add(this.progressBar1); - this.Controls.Add(this.groupBoxOutput); - this.Controls.Add(this.groupBoxInput); - this.Controls.Add(this.buttonConvert); - this.Controls.Add(this.buttonCancel); - this.KeyPreview = true; - this.MinimumSize = new System.Drawing.Size(1024, 578); - this.Name = "BatchConvert"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Batch convert"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BatchConvert_FormClosing); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.BatchConvert_KeyDown); - this.groupBoxConvertOptions.ResumeLayout(false); - this.groupBoxDeleteLines.ResumeLayout(false); - this.groupBoxDeleteLines.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDeleteLast)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDeleteFirst)).EndInit(); - this.groupBoxRemoveStyle.ResumeLayout(false); - this.groupBoxRemoveStyle.PerformLayout(); - this.groupBoxOffsetTimeCodes.ResumeLayout(false); - this.groupBoxOffsetTimeCodes.PerformLayout(); - this.contextMenuStripOptions.ResumeLayout(false); - this.groupBoxChangeFrameRate.ResumeLayout(false); - this.groupBoxChangeFrameRate.PerformLayout(); - this.groupBoxFixRtl.ResumeLayout(false); - this.groupBoxFixRtl.PerformLayout(); - this.groupBoxSpeed.ResumeLayout(false); - this.groupBoxSpeed.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).EndInit(); - this.groupBoxChangeCasing.ResumeLayout(false); - this.groupBoxChangeCasing.PerformLayout(); - this.groupBoxMergeShortLines.ResumeLayout(false); - this.groupBoxMergeShortLines.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).EndInit(); - this.groupBoxAdjustDuration.ResumeLayout(false); - this.groupBoxAdjustDuration.PerformLayout(); - this.panelAdjustDurationFixed.ResumeLayout(false); - this.panelAdjustDurationFixed.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFixedMilliseconds)).EndInit(); - this.panelAdjustDurationAddPercent.ResumeLayout(false); - this.panelAdjustDurationAddPercent.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAdjustViaPercent)).EndInit(); - this.panelAdjustDurationAddSeconds.ResumeLayout(false); - this.panelAdjustDurationAddSeconds.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).EndInit(); - this.panelAdjustDurationRecalc.ResumeLayout(false); - this.panelAdjustDurationRecalc.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharsSec)).EndInit(); - this.groupBoxOutput.ResumeLayout(false); - this.groupBoxOutput.PerformLayout(); - this.groupBoxInput.ResumeLayout(false); - this.groupBoxInput.PerformLayout(); - this.contextMenuStripFiles.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonConvert; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.GroupBox groupBoxConvertOptions; - private System.Windows.Forms.GroupBox groupBoxOutput; - private System.Windows.Forms.ComboBox comboBoxSubtitleFormats; - private System.Windows.Forms.Label labelEncoding; - private System.Windows.Forms.ComboBox comboBoxEncoding; - private System.Windows.Forms.Label labelOutputFormat; - private System.Windows.Forms.GroupBox groupBoxInput; - private System.Windows.Forms.Button buttonInputBrowse; - private System.Windows.Forms.Label labelChooseInputFiles; - private System.Windows.Forms.ListView listViewInputFiles; - private System.Windows.Forms.ColumnHeader columnHeaderFName; - private System.Windows.Forms.ColumnHeader columnHeaderSize; - private System.Windows.Forms.ColumnHeader columnHeaderFormat; - private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.ColumnHeader columnHeaderStatus; - private System.Windows.Forms.Button buttonStyles; - private System.Windows.Forms.GroupBox groupBoxOffsetTimeCodes; - private System.Windows.Forms.GroupBox groupBoxChangeFrameRate; - private Controls.TimeUpDown timeUpDownAdjust; - private System.Windows.Forms.Label labelHourMinSecMilliSecond; - private System.Windows.Forms.ComboBox comboBoxFrameRateTo; - private System.Windows.Forms.Label labelToFrameRate; - private System.Windows.Forms.ComboBox comboBoxFrameRateFrom; - private System.Windows.Forms.Label labelFromFrameRate; - private System.Windows.Forms.ContextMenuStrip contextMenuStripFiles; - private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeAllToolStripMenuItem; - private System.Windows.Forms.ProgressBar progressBar1; - private System.Windows.Forms.Label labelStatus; - private System.Windows.Forms.RadioButton radioButtonShowLater; - private System.Windows.Forms.RadioButton radioButtonShowEarlier; - private System.Windows.Forms.Button buttonSearchFolder; - private System.Windows.Forms.CheckBox checkBoxScanFolderRecursive; - private System.Windows.Forms.Label labelFilter; - private System.Windows.Forms.ComboBox comboBoxFilter; - private System.Windows.Forms.TextBox textBoxFilter; - private System.Windows.Forms.GroupBox groupBoxSpeed; - private System.Windows.Forms.NumericUpDown numericUpDownPercent; - private System.Windows.Forms.Label labelPercent; - private System.Windows.Forms.RadioButton radioButtonToDropFrame; - private System.Windows.Forms.RadioButton radioButtonSpeedFromDropFrame; - private System.Windows.Forms.RadioButton radioButtonSpeedCustom; - private System.Windows.Forms.CheckBox checkBoxUseStyleFromSource; - private System.Windows.Forms.Button buttonTransportStreamSettings; - private System.Windows.Forms.RadioButton radioButtonSaveInOutputFolder; - private System.Windows.Forms.LinkLabel linkLabelOpenOutputFolder; - private System.Windows.Forms.CheckBox checkBoxOverwrite; - private System.Windows.Forms.Button buttonChooseFolder; - private System.Windows.Forms.TextBox textBoxOutputFolder; - private System.Windows.Forms.RadioButton radioButtonSaveInSourceFolder; - private System.Windows.Forms.ListView listViewConvertOptions; - private System.Windows.Forms.ColumnHeader ActionCheckBox; - private System.Windows.Forms.ColumnHeader Action; - private System.Windows.Forms.Button buttonConvertOptionsSettings; - private System.Windows.Forms.GroupBox groupBoxFixRtl; - private System.Windows.Forms.RadioButton radioButtonReverseStartEnd; - private System.Windows.Forms.RadioButton radioButtonRemoveUnicode; - private System.Windows.Forms.RadioButton radioButtonAddUnicode; - private System.Windows.Forms.GroupBox groupBoxMergeShortLines; - private System.Windows.Forms.CheckBox checkBoxOnlyContinuationLines; - private System.Windows.Forms.NumericUpDown numericUpDownMaxCharacters; - private System.Windows.Forms.NumericUpDown numericUpDownMaxMillisecondsBetweenLines; - private System.Windows.Forms.Label labelMaxMillisecondsBetweenLines; - private System.Windows.Forms.Label labelMaxCharacters; - private System.Windows.Forms.Button buttonSwapFrameRate; - private System.Windows.Forms.GroupBox groupBoxChangeCasing; - private System.Windows.Forms.RadioButton radioButtonFixOnlyNames; - private System.Windows.Forms.RadioButton radioButtonLowercase; - private System.Windows.Forms.RadioButton radioButtonUppercase; - private System.Windows.Forms.RadioButton radioButtonNormal; - private System.Windows.Forms.ContextMenuStrip contextMenuStripOptions; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; - private System.Windows.Forms.ToolStripMenuItem inverseSelectionToolStripMenuItem; - private System.Windows.Forms.Button buttonBrowseEncoding; - private System.Windows.Forms.Label labelNumberOfFiles; - private System.Windows.Forms.ToolStripMenuItem openContainingFolderToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripMenuItem convertMkvSettingsToolStripMenuItem; - private System.Windows.Forms.GroupBox groupBoxRemoveStyle; - private System.Windows.Forms.TextBox textBoxRemoveStyle; - private System.Windows.Forms.Label labelStyleName; - private System.Windows.Forms.GroupBox groupBoxAdjustDuration; - private System.Windows.Forms.Label labelAdjustDurationVia; - private System.Windows.Forms.ComboBox comboBoxAdjustDurationVia; - private System.Windows.Forms.Panel panelAdjustDurationAddPercent; - private System.Windows.Forms.Panel panelAdjustDurationAddSeconds; - private System.Windows.Forms.NumericUpDown numericUpDownSeconds; - private System.Windows.Forms.Label labelAddSeconds; - private System.Windows.Forms.Panel panelAdjustDurationFixed; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.NumericUpDown numericUpDownAdjustViaPercent; - private System.Windows.Forms.Label labelAdjustViaPercent; - private System.Windows.Forms.NumericUpDown numericUpDownFixedMilliseconds; - private System.Windows.Forms.Label labelMillisecondsFixed; - private System.Windows.Forms.Panel panelAdjustDurationRecalc; - private System.Windows.Forms.CheckBox checkBoxExtendOnly; - private System.Windows.Forms.NumericUpDown numericUpDownOptimalCharsSec; - private System.Windows.Forms.Label labelOptimalCharsSec; - private System.Windows.Forms.NumericUpDown numericUpDownMaxCharsSec; - private System.Windows.Forms.Label labelMaxCharsPerSecond; - private System.Windows.Forms.ToolStripMenuItem addFilesToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.GroupBox groupBoxDeleteLines; - private System.Windows.Forms.TextBox textBoxDeleteContains; - private System.Windows.Forms.Label labelDeleteLinesContaining; - private System.Windows.Forms.NumericUpDown numericUpDownDeleteLast; - private System.Windows.Forms.Label labelDeleteLastLines; - private System.Windows.Forms.NumericUpDown numericUpDownDeleteFirst; - private System.Windows.Forms.Label labelDeleteFirstLines; - } +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class BatchConvert + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + TimeCode timeCode1 = new TimeCode(); + this.buttonConvert = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxConvertOptions = new System.Windows.Forms.GroupBox(); + this.groupBoxDeleteLines = new System.Windows.Forms.GroupBox(); + this.textBoxDeleteContains = new System.Windows.Forms.TextBox(); + this.labelDeleteLinesContaining = new System.Windows.Forms.Label(); + this.numericUpDownDeleteLast = new System.Windows.Forms.NumericUpDown(); + this.labelDeleteLastLines = new System.Windows.Forms.Label(); + this.numericUpDownDeleteFirst = new System.Windows.Forms.NumericUpDown(); + this.labelDeleteFirstLines = new System.Windows.Forms.Label(); + this.groupBoxRemoveStyle = new System.Windows.Forms.GroupBox(); + this.textBoxRemoveStyle = new System.Windows.Forms.TextBox(); + this.labelStyleName = new System.Windows.Forms.Label(); + this.groupBoxOffsetTimeCodes = new System.Windows.Forms.GroupBox(); + this.radioButtonShowLater = new System.Windows.Forms.RadioButton(); + this.radioButtonShowEarlier = new System.Windows.Forms.RadioButton(); + this.timeUpDownAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.labelHourMinSecMilliSecond = new System.Windows.Forms.Label(); + this.buttonConvertOptionsSettings = new System.Windows.Forms.Button(); + this.listViewConvertOptions = new System.Windows.Forms.ListView(); + this.ActionCheckBox = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.Action = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contextMenuStripOptions = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); + this.inverseSelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBoxChangeFrameRate = new System.Windows.Forms.GroupBox(); + this.buttonSwapFrameRate = new System.Windows.Forms.Button(); + this.comboBoxFrameRateTo = new System.Windows.Forms.ComboBox(); + this.labelToFrameRate = new System.Windows.Forms.Label(); + this.comboBoxFrameRateFrom = new System.Windows.Forms.ComboBox(); + this.labelFromFrameRate = new System.Windows.Forms.Label(); + this.groupBoxFixRtl = new System.Windows.Forms.GroupBox(); + this.radioButtonReverseStartEnd = new System.Windows.Forms.RadioButton(); + this.radioButtonRemoveUnicode = new System.Windows.Forms.RadioButton(); + this.radioButtonAddUnicode = new System.Windows.Forms.RadioButton(); + this.groupBoxSpeed = new System.Windows.Forms.GroupBox(); + this.radioButtonToDropFrame = new System.Windows.Forms.RadioButton(); + this.radioButtonSpeedFromDropFrame = new System.Windows.Forms.RadioButton(); + this.radioButtonSpeedCustom = new System.Windows.Forms.RadioButton(); + this.numericUpDownPercent = new System.Windows.Forms.NumericUpDown(); + this.labelPercent = new System.Windows.Forms.Label(); + this.groupBoxChangeCasing = new System.Windows.Forms.GroupBox(); + this.radioButtonFixOnlyNames = new System.Windows.Forms.RadioButton(); + this.radioButtonLowercase = new System.Windows.Forms.RadioButton(); + this.radioButtonUppercase = new System.Windows.Forms.RadioButton(); + this.radioButtonNormal = new System.Windows.Forms.RadioButton(); + this.groupBoxMergeShortLines = new System.Windows.Forms.GroupBox(); + this.checkBoxOnlyContinuationLines = new System.Windows.Forms.CheckBox(); + this.numericUpDownMaxCharacters = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownMaxMillisecondsBetweenLines = new System.Windows.Forms.NumericUpDown(); + this.labelMaxMillisecondsBetweenLines = new System.Windows.Forms.Label(); + this.labelMaxCharacters = new System.Windows.Forms.Label(); + this.groupBoxAdjustDuration = new System.Windows.Forms.GroupBox(); + this.comboBoxAdjustDurationVia = new System.Windows.Forms.ComboBox(); + this.labelAdjustDurationVia = new System.Windows.Forms.Label(); + this.panelAdjustDurationFixed = new System.Windows.Forms.Panel(); + this.numericUpDownFixedMilliseconds = new System.Windows.Forms.NumericUpDown(); + this.labelMillisecondsFixed = new System.Windows.Forms.Label(); + this.panelAdjustDurationAddPercent = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.numericUpDownAdjustViaPercent = new System.Windows.Forms.NumericUpDown(); + this.labelAdjustViaPercent = new System.Windows.Forms.Label(); + this.panelAdjustDurationAddSeconds = new System.Windows.Forms.Panel(); + this.numericUpDownSeconds = new System.Windows.Forms.NumericUpDown(); + this.labelAddSeconds = new System.Windows.Forms.Label(); + this.panelAdjustDurationRecalc = new System.Windows.Forms.Panel(); + this.checkBoxExtendOnly = new System.Windows.Forms.CheckBox(); + this.numericUpDownOptimalCharsSec = new System.Windows.Forms.NumericUpDown(); + this.labelOptimalCharsSec = new System.Windows.Forms.Label(); + this.numericUpDownMaxCharsSec = new System.Windows.Forms.NumericUpDown(); + this.labelMaxCharsPerSecond = new System.Windows.Forms.Label(); + this.groupBoxOutput = new System.Windows.Forms.GroupBox(); + this.buttonBrowseEncoding = new System.Windows.Forms.Button(); + this.radioButtonSaveInOutputFolder = new System.Windows.Forms.RadioButton(); + this.buttonTransportStreamSettings = new System.Windows.Forms.Button(); + this.linkLabelOpenOutputFolder = new System.Windows.Forms.LinkLabel(); + this.checkBoxUseStyleFromSource = new System.Windows.Forms.CheckBox(); + this.checkBoxOverwrite = new System.Windows.Forms.CheckBox(); + this.buttonStyles = new System.Windows.Forms.Button(); + this.buttonChooseFolder = new System.Windows.Forms.Button(); + this.comboBoxSubtitleFormats = new System.Windows.Forms.ComboBox(); + this.textBoxOutputFolder = new System.Windows.Forms.TextBox(); + this.labelEncoding = new System.Windows.Forms.Label(); + this.radioButtonSaveInSourceFolder = new System.Windows.Forms.RadioButton(); + this.comboBoxEncoding = new System.Windows.Forms.ComboBox(); + this.labelOutputFormat = new System.Windows.Forms.Label(); + this.groupBoxInput = new System.Windows.Forms.GroupBox(); + this.labelNumberOfFiles = new System.Windows.Forms.Label(); + this.textBoxFilter = new System.Windows.Forms.TextBox(); + this.labelFilter = new System.Windows.Forms.Label(); + this.comboBoxFilter = new System.Windows.Forms.ComboBox(); + this.checkBoxScanFolderRecursive = new System.Windows.Forms.CheckBox(); + this.buttonSearchFolder = new System.Windows.Forms.Button(); + this.buttonInputBrowse = new System.Windows.Forms.Button(); + this.labelChooseInputFiles = new System.Windows.Forms.Label(); + this.listViewInputFiles = new System.Windows.Forms.ListView(); + this.columnHeaderFName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderFormat = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contextMenuStripFiles = new System.Windows.Forms.ContextMenuStrip(this.components); + this.addFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openContainingFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.convertMkvSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.labelStatus = new System.Windows.Forms.Label(); + this.groupBoxConvertOptions.SuspendLayout(); + this.groupBoxDeleteLines.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDeleteLast)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDeleteFirst)).BeginInit(); + this.groupBoxRemoveStyle.SuspendLayout(); + this.groupBoxOffsetTimeCodes.SuspendLayout(); + this.contextMenuStripOptions.SuspendLayout(); + this.groupBoxChangeFrameRate.SuspendLayout(); + this.groupBoxFixRtl.SuspendLayout(); + this.groupBoxSpeed.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).BeginInit(); + this.groupBoxChangeCasing.SuspendLayout(); + this.groupBoxMergeShortLines.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).BeginInit(); + this.groupBoxAdjustDuration.SuspendLayout(); + this.panelAdjustDurationFixed.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFixedMilliseconds)).BeginInit(); + this.panelAdjustDurationAddPercent.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAdjustViaPercent)).BeginInit(); + this.panelAdjustDurationAddSeconds.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).BeginInit(); + this.panelAdjustDurationRecalc.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharsSec)).BeginInit(); + this.groupBoxOutput.SuspendLayout(); + this.groupBoxInput.SuspendLayout(); + this.contextMenuStripFiles.SuspendLayout(); + this.SuspendLayout(); + // + // buttonConvert + // + this.buttonConvert.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonConvert.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonConvert.Location = new System.Drawing.Point(844, 618); + this.buttonConvert.Name = "buttonConvert"; + this.buttonConvert.Size = new System.Drawing.Size(98, 23); + this.buttonConvert.TabIndex = 2; + this.buttonConvert.Text = "&Convert"; + this.buttonConvert.UseVisualStyleBackColor = true; + this.buttonConvert.Click += new System.EventHandler(this.buttonConvert_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(948, 618); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "&Done"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // groupBoxConvertOptions + // + this.groupBoxConvertOptions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxConvertOptions.Controls.Add(this.groupBoxDeleteLines); + this.groupBoxConvertOptions.Controls.Add(this.groupBoxRemoveStyle); + this.groupBoxConvertOptions.Controls.Add(this.groupBoxOffsetTimeCodes); + this.groupBoxConvertOptions.Controls.Add(this.buttonConvertOptionsSettings); + this.groupBoxConvertOptions.Controls.Add(this.listViewConvertOptions); + this.groupBoxConvertOptions.Controls.Add(this.groupBoxChangeFrameRate); + this.groupBoxConvertOptions.Controls.Add(this.groupBoxFixRtl); + this.groupBoxConvertOptions.Controls.Add(this.groupBoxSpeed); + this.groupBoxConvertOptions.Controls.Add(this.groupBoxChangeCasing); + this.groupBoxConvertOptions.Controls.Add(this.groupBoxMergeShortLines); + this.groupBoxConvertOptions.Controls.Add(this.groupBoxAdjustDuration); + this.groupBoxConvertOptions.Location = new System.Drawing.Point(422, 19); + this.groupBoxConvertOptions.Name = "groupBoxConvertOptions"; + this.groupBoxConvertOptions.Size = new System.Drawing.Size(583, 275); + this.groupBoxConvertOptions.TabIndex = 11; + this.groupBoxConvertOptions.TabStop = false; + this.groupBoxConvertOptions.Text = "Convert options"; + // + // groupBoxDeleteLines + // + this.groupBoxDeleteLines.Controls.Add(this.textBoxDeleteContains); + this.groupBoxDeleteLines.Controls.Add(this.labelDeleteLinesContaining); + this.groupBoxDeleteLines.Controls.Add(this.numericUpDownDeleteLast); + this.groupBoxDeleteLines.Controls.Add(this.labelDeleteLastLines); + this.groupBoxDeleteLines.Controls.Add(this.numericUpDownDeleteFirst); + this.groupBoxDeleteLines.Controls.Add(this.labelDeleteFirstLines); + this.groupBoxDeleteLines.Location = new System.Drawing.Point(305, 94); + this.groupBoxDeleteLines.Name = "groupBoxDeleteLines"; + this.groupBoxDeleteLines.Size = new System.Drawing.Size(271, 140); + this.groupBoxDeleteLines.TabIndex = 308; + this.groupBoxDeleteLines.TabStop = false; + this.groupBoxDeleteLines.Text = "Delete lines"; + this.groupBoxDeleteLines.Visible = false; + // + // textBoxDeleteContains + // + this.textBoxDeleteContains.Location = new System.Drawing.Point(10, 110); + this.textBoxDeleteContains.Name = "textBoxDeleteContains"; + this.textBoxDeleteContains.Size = new System.Drawing.Size(237, 20); + this.textBoxDeleteContains.TabIndex = 5; + // + // labelDeleteLinesContaining + // + this.labelDeleteLinesContaining.AutoSize = true; + this.labelDeleteLinesContaining.Location = new System.Drawing.Point(9, 89); + this.labelDeleteLinesContaining.Name = "labelDeleteLinesContaining"; + this.labelDeleteLinesContaining.Size = new System.Drawing.Size(114, 13); + this.labelDeleteLinesContaining.TabIndex = 4; + this.labelDeleteLinesContaining.Text = "Delete lines containing"; + // + // numericUpDownDeleteLast + // + this.numericUpDownDeleteLast.Location = new System.Drawing.Point(92, 45); + this.numericUpDownDeleteLast.Name = "numericUpDownDeleteLast"; + this.numericUpDownDeleteLast.Size = new System.Drawing.Size(43, 20); + this.numericUpDownDeleteLast.TabIndex = 3; + // + // labelDeleteLastLines + // + this.labelDeleteLastLines.AutoSize = true; + this.labelDeleteLastLines.Location = new System.Drawing.Point(5, 47); + this.labelDeleteLastLines.Name = "labelDeleteLastLines"; + this.labelDeleteLastLines.Size = new System.Drawing.Size(81, 13); + this.labelDeleteLastLines.TabIndex = 2; + this.labelDeleteLastLines.Text = "Delete last lines"; + // + // numericUpDownDeleteFirst + // + this.numericUpDownDeleteFirst.Location = new System.Drawing.Point(93, 19); + this.numericUpDownDeleteFirst.Name = "numericUpDownDeleteFirst"; + this.numericUpDownDeleteFirst.Size = new System.Drawing.Size(43, 20); + this.numericUpDownDeleteFirst.TabIndex = 1; + // + // labelDeleteFirstLines + // + this.labelDeleteFirstLines.AutoSize = true; + this.labelDeleteFirstLines.Location = new System.Drawing.Point(6, 20); + this.labelDeleteFirstLines.Name = "labelDeleteFirstLines"; + this.labelDeleteFirstLines.Size = new System.Drawing.Size(81, 13); + this.labelDeleteFirstLines.TabIndex = 0; + this.labelDeleteFirstLines.Text = "Delete first lines"; + // + // groupBoxRemoveStyle + // + this.groupBoxRemoveStyle.Controls.Add(this.textBoxRemoveStyle); + this.groupBoxRemoveStyle.Controls.Add(this.labelStyleName); + this.groupBoxRemoveStyle.Location = new System.Drawing.Point(307, 12); + this.groupBoxRemoveStyle.Name = "groupBoxRemoveStyle"; + this.groupBoxRemoveStyle.Size = new System.Drawing.Size(271, 76); + this.groupBoxRemoveStyle.TabIndex = 307; + this.groupBoxRemoveStyle.TabStop = false; + this.groupBoxRemoveStyle.Text = "Remove style/actor"; + this.groupBoxRemoveStyle.Visible = false; + // + // textBoxRemoveStyle + // + this.textBoxRemoveStyle.Location = new System.Drawing.Point(6, 35); + this.textBoxRemoveStyle.Name = "textBoxRemoveStyle"; + this.textBoxRemoveStyle.Size = new System.Drawing.Size(257, 20); + this.textBoxRemoveStyle.TabIndex = 8; + // + // labelStyleName + // + this.labelStyleName.AutoSize = true; + this.labelStyleName.Location = new System.Drawing.Point(6, 20); + this.labelStyleName.Name = "labelStyleName"; + this.labelStyleName.Size = new System.Drawing.Size(59, 13); + this.labelStyleName.TabIndex = 0; + this.labelStyleName.Text = "Style/actor"; + // + // groupBoxOffsetTimeCodes + // + this.groupBoxOffsetTimeCodes.Controls.Add(this.radioButtonShowLater); + this.groupBoxOffsetTimeCodes.Controls.Add(this.radioButtonShowEarlier); + this.groupBoxOffsetTimeCodes.Controls.Add(this.timeUpDownAdjust); + this.groupBoxOffsetTimeCodes.Controls.Add(this.labelHourMinSecMilliSecond); + this.groupBoxOffsetTimeCodes.Location = new System.Drawing.Point(305, 19); + this.groupBoxOffsetTimeCodes.Name = "groupBoxOffsetTimeCodes"; + this.groupBoxOffsetTimeCodes.Size = new System.Drawing.Size(271, 119); + this.groupBoxOffsetTimeCodes.TabIndex = 306; + this.groupBoxOffsetTimeCodes.TabStop = false; + this.groupBoxOffsetTimeCodes.Text = "Offset time codes"; + this.groupBoxOffsetTimeCodes.Visible = false; + // + // radioButtonShowLater + // + this.radioButtonShowLater.AutoSize = true; + this.radioButtonShowLater.Checked = true; + this.radioButtonShowLater.Location = new System.Drawing.Point(9, 89); + this.radioButtonShowLater.Name = "radioButtonShowLater"; + this.radioButtonShowLater.Size = new System.Drawing.Size(75, 17); + this.radioButtonShowLater.TabIndex = 3; + this.radioButtonShowLater.TabStop = true; + this.radioButtonShowLater.Text = "Show later"; + this.radioButtonShowLater.UseVisualStyleBackColor = true; + // + // radioButtonShowEarlier + // + this.radioButtonShowEarlier.AutoSize = true; + this.radioButtonShowEarlier.Location = new System.Drawing.Point(9, 66); + this.radioButtonShowEarlier.Name = "radioButtonShowEarlier"; + this.radioButtonShowEarlier.Size = new System.Drawing.Size(83, 17); + this.radioButtonShowEarlier.TabIndex = 2; + this.radioButtonShowEarlier.Text = "Show earlier"; + this.radioButtonShowEarlier.UseVisualStyleBackColor = true; + // + // timeUpDownAdjust + // + this.timeUpDownAdjust.AutoSize = true; + this.timeUpDownAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownAdjust.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + this.timeUpDownAdjust.Location = new System.Drawing.Point(7, 37); + this.timeUpDownAdjust.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownAdjust.Name = "timeUpDownAdjust"; + this.timeUpDownAdjust.Size = new System.Drawing.Size(111, 27); + this.timeUpDownAdjust.TabIndex = 1; + timeCode1.Hours = 0; + timeCode1.Milliseconds = 0; + timeCode1.Minutes = 0; + timeCode1.Seconds = 0; + timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode1.TotalMilliseconds = 0D; + timeCode1.TotalSeconds = 0D; + this.timeUpDownAdjust.TimeCode = timeCode1; + this.timeUpDownAdjust.UseVideoOffset = false; + // + // labelHourMinSecMilliSecond + // + this.labelHourMinSecMilliSecond.AutoSize = true; + this.labelHourMinSecMilliSecond.Location = new System.Drawing.Point(6, 20); + this.labelHourMinSecMilliSecond.Name = "labelHourMinSecMilliSecond"; + this.labelHourMinSecMilliSecond.Size = new System.Drawing.Size(90, 13); + this.labelHourMinSecMilliSecond.TabIndex = 0; + this.labelHourMinSecMilliSecond.Text = "Hours:min:sec.ms"; + // + // buttonConvertOptionsSettings + // + this.buttonConvertOptionsSettings.Location = new System.Drawing.Point(305, 144); + this.buttonConvertOptionsSettings.Name = "buttonConvertOptionsSettings"; + this.buttonConvertOptionsSettings.Size = new System.Drawing.Size(116, 23); + this.buttonConvertOptionsSettings.TabIndex = 302; + this.buttonConvertOptionsSettings.Text = "Settings..."; + this.buttonConvertOptionsSettings.UseVisualStyleBackColor = true; + this.buttonConvertOptionsSettings.Visible = false; + this.buttonConvertOptionsSettings.Click += new System.EventHandler(this.ButtonOptionConvertSettings); + // + // listViewConvertOptions + // + this.listViewConvertOptions.CheckBoxes = true; + this.listViewConvertOptions.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.ActionCheckBox, + this.Action}); + this.listViewConvertOptions.ContextMenuStrip = this.contextMenuStripOptions; + this.listViewConvertOptions.FullRowSelect = true; + this.listViewConvertOptions.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.listViewConvertOptions.HideSelection = false; + this.listViewConvertOptions.Location = new System.Drawing.Point(6, 17); + this.listViewConvertOptions.MultiSelect = false; + this.listViewConvertOptions.Name = "listViewConvertOptions"; + this.listViewConvertOptions.Size = new System.Drawing.Size(293, 252); + this.listViewConvertOptions.TabIndex = 301; + this.listViewConvertOptions.UseCompatibleStateImageBehavior = false; + this.listViewConvertOptions.View = System.Windows.Forms.View.Details; + this.listViewConvertOptions.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listViewConvertOptions_ItemChecked); + this.listViewConvertOptions.SelectedIndexChanged += new System.EventHandler(this.listViewConvertOptions_SelectedIndexChanged); + // + // ActionCheckBox + // + this.ActionCheckBox.Width = 30; + // + // Action + // + this.Action.Width = 400; + // + // contextMenuStripOptions + // + this.contextMenuStripOptions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSelectAll, + this.inverseSelectionToolStripMenuItem}); + this.contextMenuStripOptions.Name = "contextMenuStripOptions"; + this.contextMenuStripOptions.Size = new System.Drawing.Size(162, 48); + // + // toolStripMenuItemSelectAll + // + this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; + this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(161, 22); + this.toolStripMenuItemSelectAll.Text = "Select all"; + this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); + // + // inverseSelectionToolStripMenuItem + // + this.inverseSelectionToolStripMenuItem.Name = "inverseSelectionToolStripMenuItem"; + this.inverseSelectionToolStripMenuItem.Size = new System.Drawing.Size(161, 22); + this.inverseSelectionToolStripMenuItem.Text = "Inverse selection"; + this.inverseSelectionToolStripMenuItem.Click += new System.EventHandler(this.inverseSelectionToolStripMenuItem_Click); + // + // groupBoxChangeFrameRate + // + this.groupBoxChangeFrameRate.Controls.Add(this.buttonSwapFrameRate); + this.groupBoxChangeFrameRate.Controls.Add(this.comboBoxFrameRateTo); + this.groupBoxChangeFrameRate.Controls.Add(this.labelToFrameRate); + this.groupBoxChangeFrameRate.Controls.Add(this.comboBoxFrameRateFrom); + this.groupBoxChangeFrameRate.Controls.Add(this.labelFromFrameRate); + this.groupBoxChangeFrameRate.Location = new System.Drawing.Point(307, 12); + this.groupBoxChangeFrameRate.Name = "groupBoxChangeFrameRate"; + this.groupBoxChangeFrameRate.Size = new System.Drawing.Size(269, 90); + this.groupBoxChangeFrameRate.TabIndex = 305; + this.groupBoxChangeFrameRate.TabStop = false; + this.groupBoxChangeFrameRate.Text = "Change frame rate"; + this.groupBoxChangeFrameRate.Visible = false; + // + // buttonSwapFrameRate + // + this.buttonSwapFrameRate.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.buttonSwapFrameRate.Location = new System.Drawing.Point(207, 28); + this.buttonSwapFrameRate.Name = "buttonSwapFrameRate"; + this.buttonSwapFrameRate.Size = new System.Drawing.Size(27, 28); + this.buttonSwapFrameRate.TabIndex = 9; + this.buttonSwapFrameRate.Text = "<->"; + this.buttonSwapFrameRate.UseVisualStyleBackColor = true; + this.buttonSwapFrameRate.Click += new System.EventHandler(this.buttonSwapFrameRate_Click); + // + // comboBoxFrameRateTo + // + this.comboBoxFrameRateTo.FormattingEnabled = true; + this.comboBoxFrameRateTo.Location = new System.Drawing.Point(130, 46); + this.comboBoxFrameRateTo.Name = "comboBoxFrameRateTo"; + this.comboBoxFrameRateTo.Size = new System.Drawing.Size(71, 21); + this.comboBoxFrameRateTo.TabIndex = 3; + // + // labelToFrameRate + // + this.labelToFrameRate.AutoSize = true; + this.labelToFrameRate.Location = new System.Drawing.Point(6, 50); + this.labelToFrameRate.Name = "labelToFrameRate"; + this.labelToFrameRate.Size = new System.Drawing.Size(70, 13); + this.labelToFrameRate.TabIndex = 2; + this.labelToFrameRate.Text = "To frame rate"; + // + // comboBoxFrameRateFrom + // + this.comboBoxFrameRateFrom.FormattingEnabled = true; + this.comboBoxFrameRateFrom.Location = new System.Drawing.Point(130, 17); + this.comboBoxFrameRateFrom.Name = "comboBoxFrameRateFrom"; + this.comboBoxFrameRateFrom.Size = new System.Drawing.Size(71, 21); + this.comboBoxFrameRateFrom.TabIndex = 1; + // + // labelFromFrameRate + // + this.labelFromFrameRate.AutoSize = true; + this.labelFromFrameRate.Location = new System.Drawing.Point(6, 21); + this.labelFromFrameRate.Name = "labelFromFrameRate"; + this.labelFromFrameRate.Size = new System.Drawing.Size(80, 13); + this.labelFromFrameRate.TabIndex = 0; + this.labelFromFrameRate.Text = "From frame rate"; + // + // groupBoxFixRtl + // + this.groupBoxFixRtl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFixRtl.Controls.Add(this.radioButtonReverseStartEnd); + this.groupBoxFixRtl.Controls.Add(this.radioButtonRemoveUnicode); + this.groupBoxFixRtl.Controls.Add(this.radioButtonAddUnicode); + this.groupBoxFixRtl.Location = new System.Drawing.Point(305, 17); + this.groupBoxFixRtl.Name = "groupBoxFixRtl"; + this.groupBoxFixRtl.Size = new System.Drawing.Size(271, 115); + this.groupBoxFixRtl.TabIndex = 303; + this.groupBoxFixRtl.TabStop = false; + this.groupBoxFixRtl.Text = "Settings"; + this.groupBoxFixRtl.Visible = false; + // + // radioButtonReverseStartEnd + // + this.radioButtonReverseStartEnd.AutoSize = true; + this.radioButtonReverseStartEnd.Location = new System.Drawing.Point(19, 77); + this.radioButtonReverseStartEnd.Name = "radioButtonReverseStartEnd"; + this.radioButtonReverseStartEnd.Size = new System.Drawing.Size(135, 17); + this.radioButtonReverseStartEnd.TabIndex = 2; + this.radioButtonReverseStartEnd.TabStop = true; + this.radioButtonReverseStartEnd.Text = "Reverse RTL start/end"; + this.radioButtonReverseStartEnd.UseVisualStyleBackColor = true; + // + // radioButtonRemoveUnicode + // + this.radioButtonRemoveUnicode.AutoSize = true; + this.radioButtonRemoveUnicode.Location = new System.Drawing.Point(19, 54); + this.radioButtonRemoveUnicode.Name = "radioButtonRemoveUnicode"; + this.radioButtonRemoveUnicode.Size = new System.Drawing.Size(153, 17); + this.radioButtonRemoveUnicode.TabIndex = 1; + this.radioButtonRemoveUnicode.TabStop = true; + this.radioButtonRemoveUnicode.Text = "Remove RTL unicode tags"; + this.radioButtonRemoveUnicode.UseVisualStyleBackColor = true; + // + // radioButtonAddUnicode + // + this.radioButtonAddUnicode.AutoSize = true; + this.radioButtonAddUnicode.Location = new System.Drawing.Point(19, 31); + this.radioButtonAddUnicode.Name = "radioButtonAddUnicode"; + this.radioButtonAddUnicode.Size = new System.Drawing.Size(145, 17); + this.radioButtonAddUnicode.TabIndex = 0; + this.radioButtonAddUnicode.TabStop = true; + this.radioButtonAddUnicode.Text = "Fix RTL via Unicode tags"; + this.radioButtonAddUnicode.UseVisualStyleBackColor = true; + // + // groupBoxSpeed + // + this.groupBoxSpeed.Controls.Add(this.radioButtonToDropFrame); + this.groupBoxSpeed.Controls.Add(this.radioButtonSpeedFromDropFrame); + this.groupBoxSpeed.Controls.Add(this.radioButtonSpeedCustom); + this.groupBoxSpeed.Controls.Add(this.numericUpDownPercent); + this.groupBoxSpeed.Controls.Add(this.labelPercent); + this.groupBoxSpeed.Location = new System.Drawing.Point(305, 17); + this.groupBoxSpeed.Name = "groupBoxSpeed"; + this.groupBoxSpeed.Size = new System.Drawing.Size(271, 129); + this.groupBoxSpeed.TabIndex = 307; + this.groupBoxSpeed.TabStop = false; + this.groupBoxSpeed.Text = "Change speed"; + this.groupBoxSpeed.Visible = false; + // + // radioButtonToDropFrame + // + this.radioButtonToDropFrame.AutoSize = true; + this.radioButtonToDropFrame.Location = new System.Drawing.Point(6, 91); + this.radioButtonToDropFrame.Name = "radioButtonToDropFrame"; + this.radioButtonToDropFrame.Size = new System.Drawing.Size(91, 17); + this.radioButtonToDropFrame.TabIndex = 3; + this.radioButtonToDropFrame.Text = "To drop frame"; + this.radioButtonToDropFrame.UseVisualStyleBackColor = true; + this.radioButtonToDropFrame.CheckedChanged += new System.EventHandler(this.radioButtonToDropFrame_CheckedChanged); + // + // radioButtonSpeedFromDropFrame + // + this.radioButtonSpeedFromDropFrame.AutoSize = true; + this.radioButtonSpeedFromDropFrame.Location = new System.Drawing.Point(6, 68); + this.radioButtonSpeedFromDropFrame.Name = "radioButtonSpeedFromDropFrame"; + this.radioButtonSpeedFromDropFrame.Size = new System.Drawing.Size(101, 17); + this.radioButtonSpeedFromDropFrame.TabIndex = 2; + this.radioButtonSpeedFromDropFrame.Text = "From drop frame"; + this.radioButtonSpeedFromDropFrame.UseVisualStyleBackColor = true; + this.radioButtonSpeedFromDropFrame.CheckedChanged += new System.EventHandler(this.radioButtonSpeedFromDropFrame_CheckedChanged); + // + // radioButtonSpeedCustom + // + this.radioButtonSpeedCustom.AutoSize = true; + this.radioButtonSpeedCustom.Checked = true; + this.radioButtonSpeedCustom.Location = new System.Drawing.Point(6, 45); + this.radioButtonSpeedCustom.Name = "radioButtonSpeedCustom"; + this.radioButtonSpeedCustom.Size = new System.Drawing.Size(60, 17); + this.radioButtonSpeedCustom.TabIndex = 1; + this.radioButtonSpeedCustom.TabStop = true; + this.radioButtonSpeedCustom.Text = "Custom"; + this.radioButtonSpeedCustom.UseVisualStyleBackColor = true; + this.radioButtonSpeedCustom.CheckedChanged += new System.EventHandler(this.radioButtonSpeedCustom_CheckedChanged); + // + // numericUpDownPercent + // + this.numericUpDownPercent.DecimalPlaces = 5; + this.numericUpDownPercent.Location = new System.Drawing.Point(6, 19); + this.numericUpDownPercent.Maximum = new decimal(new int[] { + 200, + 0, + 0, + 0}); + this.numericUpDownPercent.Minimum = new decimal(new int[] { + 50, + 0, + 0, + 0}); + this.numericUpDownPercent.Name = "numericUpDownPercent"; + this.numericUpDownPercent.Size = new System.Drawing.Size(81, 20); + this.numericUpDownPercent.TabIndex = 0; + this.numericUpDownPercent.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // labelPercent + // + this.labelPercent.AutoSize = true; + this.labelPercent.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.labelPercent.Location = new System.Drawing.Point(87, 22); + this.labelPercent.Name = "labelPercent"; + this.labelPercent.Size = new System.Drawing.Size(15, 13); + this.labelPercent.TabIndex = 12; + this.labelPercent.Text = "%"; + // + // groupBoxChangeCasing + // + this.groupBoxChangeCasing.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxChangeCasing.Controls.Add(this.radioButtonFixOnlyNames); + this.groupBoxChangeCasing.Controls.Add(this.radioButtonLowercase); + this.groupBoxChangeCasing.Controls.Add(this.radioButtonUppercase); + this.groupBoxChangeCasing.Controls.Add(this.radioButtonNormal); + this.groupBoxChangeCasing.Location = new System.Drawing.Point(308, 16); + this.groupBoxChangeCasing.Name = "groupBoxChangeCasing"; + this.groupBoxChangeCasing.Size = new System.Drawing.Size(268, 125); + this.groupBoxChangeCasing.TabIndex = 308; + this.groupBoxChangeCasing.TabStop = false; + this.groupBoxChangeCasing.Text = "Change casing to"; + // + // radioButtonFixOnlyNames + // + this.radioButtonFixOnlyNames.AutoSize = true; + this.radioButtonFixOnlyNames.Location = new System.Drawing.Point(11, 43); + this.radioButtonFixOnlyNames.Name = "radioButtonFixOnlyNames"; + this.radioButtonFixOnlyNames.Size = new System.Drawing.Size(263, 17); + this.radioButtonFixOnlyNames.TabIndex = 6; + this.radioButtonFixOnlyNames.Text = "Fix only names casing (via Dictionaries\\names.xml)"; + this.radioButtonFixOnlyNames.UseVisualStyleBackColor = true; + // + // radioButtonLowercase + // + this.radioButtonLowercase.AutoSize = true; + this.radioButtonLowercase.Location = new System.Drawing.Point(11, 89); + this.radioButtonLowercase.Name = "radioButtonLowercase"; + this.radioButtonLowercase.Size = new System.Drawing.Size(86, 17); + this.radioButtonLowercase.TabIndex = 10; + this.radioButtonLowercase.Text = "all lowercase"; + this.radioButtonLowercase.UseVisualStyleBackColor = true; + // + // radioButtonUppercase + // + this.radioButtonUppercase.AutoSize = true; + this.radioButtonUppercase.Location = new System.Drawing.Point(11, 66); + this.radioButtonUppercase.Name = "radioButtonUppercase"; + this.radioButtonUppercase.Size = new System.Drawing.Size(112, 17); + this.radioButtonUppercase.TabIndex = 8; + this.radioButtonUppercase.Text = "ALL UPPERCASE"; + this.radioButtonUppercase.UseVisualStyleBackColor = true; + // + // radioButtonNormal + // + this.radioButtonNormal.AutoSize = true; + this.radioButtonNormal.Checked = true; + this.radioButtonNormal.Location = new System.Drawing.Point(11, 18); + this.radioButtonNormal.Name = "radioButtonNormal"; + this.radioButtonNormal.Size = new System.Drawing.Size(282, 17); + this.radioButtonNormal.TabIndex = 0; + this.radioButtonNormal.TabStop = true; + this.radioButtonNormal.Text = "Normal casing. Sentences begin with uppercase letter."; + this.radioButtonNormal.UseVisualStyleBackColor = true; + // + // groupBoxMergeShortLines + // + this.groupBoxMergeShortLines.Controls.Add(this.checkBoxOnlyContinuationLines); + this.groupBoxMergeShortLines.Controls.Add(this.numericUpDownMaxCharacters); + this.groupBoxMergeShortLines.Controls.Add(this.numericUpDownMaxMillisecondsBetweenLines); + this.groupBoxMergeShortLines.Controls.Add(this.labelMaxMillisecondsBetweenLines); + this.groupBoxMergeShortLines.Controls.Add(this.labelMaxCharacters); + this.groupBoxMergeShortLines.Location = new System.Drawing.Point(308, 23); + this.groupBoxMergeShortLines.Name = "groupBoxMergeShortLines"; + this.groupBoxMergeShortLines.Size = new System.Drawing.Size(268, 149); + this.groupBoxMergeShortLines.TabIndex = 304; + this.groupBoxMergeShortLines.TabStop = false; + this.groupBoxMergeShortLines.Text = "Merge short lines"; + this.groupBoxMergeShortLines.Visible = false; + // + // checkBoxOnlyContinuationLines + // + this.checkBoxOnlyContinuationLines.AutoSize = true; + this.checkBoxOnlyContinuationLines.Checked = true; + this.checkBoxOnlyContinuationLines.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxOnlyContinuationLines.Location = new System.Drawing.Point(16, 127); + this.checkBoxOnlyContinuationLines.Name = "checkBoxOnlyContinuationLines"; + this.checkBoxOnlyContinuationLines.Size = new System.Drawing.Size(164, 17); + this.checkBoxOnlyContinuationLines.TabIndex = 42; + this.checkBoxOnlyContinuationLines.Text = "Only merge continuation lines"; + this.checkBoxOnlyContinuationLines.UseVisualStyleBackColor = true; + // + // numericUpDownMaxCharacters + // + this.numericUpDownMaxCharacters.Location = new System.Drawing.Point(15, 41); + this.numericUpDownMaxCharacters.Maximum = new decimal(new int[] { + 999, + 0, + 0, + 0}); + this.numericUpDownMaxCharacters.Minimum = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDownMaxCharacters.Name = "numericUpDownMaxCharacters"; + this.numericUpDownMaxCharacters.Size = new System.Drawing.Size(64, 20); + this.numericUpDownMaxCharacters.TabIndex = 38; + this.numericUpDownMaxCharacters.Value = new decimal(new int[] { + 65, + 0, + 0, + 0}); + // + // numericUpDownMaxMillisecondsBetweenLines + // + this.numericUpDownMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(15, 90); + this.numericUpDownMaxMillisecondsBetweenLines.Maximum = new decimal(new int[] { + 2000, + 0, + 0, + 0}); + this.numericUpDownMaxMillisecondsBetweenLines.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numericUpDownMaxMillisecondsBetweenLines.Name = "numericUpDownMaxMillisecondsBetweenLines"; + this.numericUpDownMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(64, 20); + this.numericUpDownMaxMillisecondsBetweenLines.TabIndex = 39; + this.numericUpDownMaxMillisecondsBetweenLines.Value = new decimal(new int[] { + 250, + 0, + 0, + 0}); + // + // labelMaxMillisecondsBetweenLines + // + this.labelMaxMillisecondsBetweenLines.AutoSize = true; + this.labelMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(12, 73); + this.labelMaxMillisecondsBetweenLines.Name = "labelMaxMillisecondsBetweenLines"; + this.labelMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(178, 13); + this.labelMaxMillisecondsBetweenLines.TabIndex = 41; + this.labelMaxMillisecondsBetweenLines.Text = "Maximum milliseconds between lines"; + // + // labelMaxCharacters + // + this.labelMaxCharacters.AutoSize = true; + this.labelMaxCharacters.Location = new System.Drawing.Point(12, 23); + this.labelMaxCharacters.Name = "labelMaxCharacters"; + this.labelMaxCharacters.Size = new System.Drawing.Size(187, 13); + this.labelMaxCharacters.TabIndex = 40; + this.labelMaxCharacters.Text = "Maximum characters in one paragraph"; + // + // groupBoxAdjustDuration + // + this.groupBoxAdjustDuration.Controls.Add(this.comboBoxAdjustDurationVia); + this.groupBoxAdjustDuration.Controls.Add(this.labelAdjustDurationVia); + this.groupBoxAdjustDuration.Controls.Add(this.panelAdjustDurationFixed); + this.groupBoxAdjustDuration.Controls.Add(this.panelAdjustDurationAddPercent); + this.groupBoxAdjustDuration.Controls.Add(this.panelAdjustDurationAddSeconds); + this.groupBoxAdjustDuration.Controls.Add(this.panelAdjustDurationRecalc); + this.groupBoxAdjustDuration.Location = new System.Drawing.Point(305, 16); + this.groupBoxAdjustDuration.Name = "groupBoxAdjustDuration"; + this.groupBoxAdjustDuration.Size = new System.Drawing.Size(271, 251); + this.groupBoxAdjustDuration.TabIndex = 308; + this.groupBoxAdjustDuration.TabStop = false; + this.groupBoxAdjustDuration.Text = "Adjust duration"; + this.groupBoxAdjustDuration.Visible = false; + // + // comboBoxAdjustDurationVia + // + this.comboBoxAdjustDurationVia.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxAdjustDurationVia.FormattingEnabled = true; + this.comboBoxAdjustDurationVia.Location = new System.Drawing.Point(65, 19); + this.comboBoxAdjustDurationVia.Name = "comboBoxAdjustDurationVia"; + this.comboBoxAdjustDurationVia.Size = new System.Drawing.Size(121, 21); + this.comboBoxAdjustDurationVia.TabIndex = 8; + this.comboBoxAdjustDurationVia.SelectedIndexChanged += new System.EventHandler(this.comboBoxAdjustDurationVia_SelectedIndexChanged); + // + // labelAdjustDurationVia + // + this.labelAdjustDurationVia.AutoSize = true; + this.labelAdjustDurationVia.Location = new System.Drawing.Point(8, 22); + this.labelAdjustDurationVia.Name = "labelAdjustDurationVia"; + this.labelAdjustDurationVia.Size = new System.Drawing.Size(51, 13); + this.labelAdjustDurationVia.TabIndex = 7; + this.labelAdjustDurationVia.Text = "AdjustVia"; + // + // panelAdjustDurationFixed + // + this.panelAdjustDurationFixed.Controls.Add(this.numericUpDownFixedMilliseconds); + this.panelAdjustDurationFixed.Controls.Add(this.labelMillisecondsFixed); + this.panelAdjustDurationFixed.Location = new System.Drawing.Point(6, 123); + this.panelAdjustDurationFixed.Name = "panelAdjustDurationFixed"; + this.panelAdjustDurationFixed.Size = new System.Drawing.Size(257, 57); + this.panelAdjustDurationFixed.TabIndex = 15; + // + // numericUpDownFixedMilliseconds + // + this.numericUpDownFixedMilliseconds.Location = new System.Drawing.Point(8, 27); + this.numericUpDownFixedMilliseconds.Maximum = new decimal(new int[] { + 20000, + 0, + 0, + 0}); + this.numericUpDownFixedMilliseconds.Name = "numericUpDownFixedMilliseconds"; + this.numericUpDownFixedMilliseconds.Size = new System.Drawing.Size(80, 20); + this.numericUpDownFixedMilliseconds.TabIndex = 13; + this.numericUpDownFixedMilliseconds.Value = new decimal(new int[] { + 3000, + 0, + 0, + 0}); + // + // labelMillisecondsFixed + // + this.labelMillisecondsFixed.AutoSize = true; + this.labelMillisecondsFixed.Location = new System.Drawing.Point(5, 8); + this.labelMillisecondsFixed.Name = "labelMillisecondsFixed"; + this.labelMillisecondsFixed.Size = new System.Drawing.Size(64, 13); + this.labelMillisecondsFixed.TabIndex = 14; + this.labelMillisecondsFixed.Text = "Milliseconds"; + // + // panelAdjustDurationAddPercent + // + this.panelAdjustDurationAddPercent.Controls.Add(this.label1); + this.panelAdjustDurationAddPercent.Controls.Add(this.numericUpDownAdjustViaPercent); + this.panelAdjustDurationAddPercent.Controls.Add(this.labelAdjustViaPercent); + this.panelAdjustDurationAddPercent.Location = new System.Drawing.Point(7, 79); + this.panelAdjustDurationAddPercent.Name = "panelAdjustDurationAddPercent"; + this.panelAdjustDurationAddPercent.Size = new System.Drawing.Size(257, 63); + this.panelAdjustDurationAddPercent.TabIndex = 14; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(90, 34); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(15, 13); + this.label1.TabIndex = 25; + this.label1.Text = "%"; + // + // numericUpDownAdjustViaPercent + // + this.numericUpDownAdjustViaPercent.Location = new System.Drawing.Point(8, 27); + this.numericUpDownAdjustViaPercent.Maximum = new decimal(new int[] { + 150, + 0, + 0, + 0}); + this.numericUpDownAdjustViaPercent.Minimum = new decimal(new int[] { + 75, + 0, + 0, + 0}); + this.numericUpDownAdjustViaPercent.Name = "numericUpDownAdjustViaPercent"; + this.numericUpDownAdjustViaPercent.Size = new System.Drawing.Size(80, 20); + this.numericUpDownAdjustViaPercent.TabIndex = 24; + this.numericUpDownAdjustViaPercent.Value = new decimal(new int[] { + 110, + 0, + 0, + 0}); + // + // labelAdjustViaPercent + // + this.labelAdjustViaPercent.AutoSize = true; + this.labelAdjustViaPercent.Location = new System.Drawing.Point(5, 8); + this.labelAdjustViaPercent.Name = "labelAdjustViaPercent"; + this.labelAdjustViaPercent.Size = new System.Drawing.Size(86, 13); + this.labelAdjustViaPercent.TabIndex = 23; + this.labelAdjustViaPercent.Text = "Adjust in percent"; + // + // panelAdjustDurationAddSeconds + // + this.panelAdjustDurationAddSeconds.Controls.Add(this.numericUpDownSeconds); + this.panelAdjustDurationAddSeconds.Controls.Add(this.labelAddSeconds); + this.panelAdjustDurationAddSeconds.Location = new System.Drawing.Point(8, 47); + this.panelAdjustDurationAddSeconds.Name = "panelAdjustDurationAddSeconds"; + this.panelAdjustDurationAddSeconds.Size = new System.Drawing.Size(257, 55); + this.panelAdjustDurationAddSeconds.TabIndex = 13; + // + // numericUpDownSeconds + // + this.numericUpDownSeconds.DecimalPlaces = 3; + this.numericUpDownSeconds.Increment = new decimal(new int[] { + 1, + 0, + 0, + 131072}); + this.numericUpDownSeconds.Location = new System.Drawing.Point(8, 27); + this.numericUpDownSeconds.Maximum = new decimal(new int[] { + 20, + 0, + 0, + 0}); + this.numericUpDownSeconds.Minimum = new decimal(new int[] { + 10, + 0, + 0, + -2147483648}); + this.numericUpDownSeconds.Name = "numericUpDownSeconds"; + this.numericUpDownSeconds.Size = new System.Drawing.Size(80, 20); + this.numericUpDownSeconds.TabIndex = 12; + this.numericUpDownSeconds.Value = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + // + // labelAddSeconds + // + this.labelAddSeconds.AutoSize = true; + this.labelAddSeconds.Location = new System.Drawing.Point(5, 8); + this.labelAddSeconds.Name = "labelAddSeconds"; + this.labelAddSeconds.Size = new System.Drawing.Size(69, 13); + this.labelAddSeconds.TabIndex = 11; + this.labelAddSeconds.Text = "Add seconds"; + // + // panelAdjustDurationRecalc + // + this.panelAdjustDurationRecalc.Controls.Add(this.checkBoxExtendOnly); + this.panelAdjustDurationRecalc.Controls.Add(this.numericUpDownOptimalCharsSec); + this.panelAdjustDurationRecalc.Controls.Add(this.labelOptimalCharsSec); + this.panelAdjustDurationRecalc.Controls.Add(this.numericUpDownMaxCharsSec); + this.panelAdjustDurationRecalc.Controls.Add(this.labelMaxCharsPerSecond); + this.panelAdjustDurationRecalc.Location = new System.Drawing.Point(6, 66); + this.panelAdjustDurationRecalc.Name = "panelAdjustDurationRecalc"; + this.panelAdjustDurationRecalc.Size = new System.Drawing.Size(257, 170); + this.panelAdjustDurationRecalc.TabIndex = 16; + // + // checkBoxExtendOnly + // + this.checkBoxExtendOnly.AutoSize = true; + this.checkBoxExtendOnly.Location = new System.Drawing.Point(8, 122); + this.checkBoxExtendOnly.Name = "checkBoxExtendOnly"; + this.checkBoxExtendOnly.Size = new System.Drawing.Size(81, 17); + this.checkBoxExtendOnly.TabIndex = 14; + this.checkBoxExtendOnly.Text = "Extend only"; + this.checkBoxExtendOnly.UseVisualStyleBackColor = true; + // + // numericUpDownOptimalCharsSec + // + this.numericUpDownOptimalCharsSec.DecimalPlaces = 1; + this.numericUpDownOptimalCharsSec.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownOptimalCharsSec.Location = new System.Drawing.Point(8, 85); + this.numericUpDownOptimalCharsSec.Minimum = new decimal(new int[] { + 4, + 0, + 0, + 0}); + this.numericUpDownOptimalCharsSec.Name = "numericUpDownOptimalCharsSec"; + this.numericUpDownOptimalCharsSec.Size = new System.Drawing.Size(80, 20); + this.numericUpDownOptimalCharsSec.TabIndex = 13; + this.numericUpDownOptimalCharsSec.Value = new decimal(new int[] { + 17, + 0, + 0, + 0}); + // + // labelOptimalCharsSec + // + this.labelOptimalCharsSec.AutoSize = true; + this.labelOptimalCharsSec.Location = new System.Drawing.Point(5, 66); + this.labelOptimalCharsSec.Name = "labelOptimalCharsSec"; + this.labelOptimalCharsSec.Size = new System.Drawing.Size(93, 13); + this.labelOptimalCharsSec.TabIndex = 15; + this.labelOptimalCharsSec.Text = "Optimal chars/sec"; + // + // numericUpDownMaxCharsSec + // + this.numericUpDownMaxCharsSec.DecimalPlaces = 1; + this.numericUpDownMaxCharsSec.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownMaxCharsSec.Location = new System.Drawing.Point(8, 27); + this.numericUpDownMaxCharsSec.Minimum = new decimal(new int[] { + 4, + 0, + 0, + 0}); + this.numericUpDownMaxCharsSec.Name = "numericUpDownMaxCharsSec"; + this.numericUpDownMaxCharsSec.Size = new System.Drawing.Size(80, 20); + this.numericUpDownMaxCharsSec.TabIndex = 12; + this.numericUpDownMaxCharsSec.Value = new decimal(new int[] { + 24, + 0, + 0, + 0}); + // + // labelMaxCharsPerSecond + // + this.labelMaxCharsPerSecond.AutoSize = true; + this.labelMaxCharsPerSecond.Location = new System.Drawing.Point(5, 8); + this.labelMaxCharsPerSecond.Name = "labelMaxCharsPerSecond"; + this.labelMaxCharsPerSecond.Size = new System.Drawing.Size(81, 13); + this.labelMaxCharsPerSecond.TabIndex = 11; + this.labelMaxCharsPerSecond.Text = "Max. chars/sec"; + // + // groupBoxOutput + // + this.groupBoxOutput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxOutput.Controls.Add(this.buttonBrowseEncoding); + this.groupBoxOutput.Controls.Add(this.radioButtonSaveInOutputFolder); + this.groupBoxOutput.Controls.Add(this.buttonTransportStreamSettings); + this.groupBoxOutput.Controls.Add(this.linkLabelOpenOutputFolder); + this.groupBoxOutput.Controls.Add(this.checkBoxUseStyleFromSource); + this.groupBoxOutput.Controls.Add(this.checkBoxOverwrite); + this.groupBoxOutput.Controls.Add(this.buttonStyles); + this.groupBoxOutput.Controls.Add(this.buttonChooseFolder); + this.groupBoxOutput.Controls.Add(this.comboBoxSubtitleFormats); + this.groupBoxOutput.Controls.Add(this.textBoxOutputFolder); + this.groupBoxOutput.Controls.Add(this.labelEncoding); + this.groupBoxOutput.Controls.Add(this.radioButtonSaveInSourceFolder); + this.groupBoxOutput.Controls.Add(this.comboBoxEncoding); + this.groupBoxOutput.Controls.Add(this.labelOutputFormat); + this.groupBoxOutput.Controls.Add(this.groupBoxConvertOptions); + this.groupBoxOutput.Location = new System.Drawing.Point(12, 305); + this.groupBoxOutput.Name = "groupBoxOutput"; + this.groupBoxOutput.Size = new System.Drawing.Size(1014, 300); + this.groupBoxOutput.TabIndex = 1; + this.groupBoxOutput.TabStop = false; + this.groupBoxOutput.Text = "Output"; + // + // buttonBrowseEncoding + // + this.buttonBrowseEncoding.Location = new System.Drawing.Point(300, 263); + this.buttonBrowseEncoding.Name = "buttonBrowseEncoding"; + this.buttonBrowseEncoding.Size = new System.Drawing.Size(26, 23); + this.buttonBrowseEncoding.TabIndex = 12; + this.buttonBrowseEncoding.Text = "..."; + this.buttonBrowseEncoding.UseVisualStyleBackColor = true; + this.buttonBrowseEncoding.Click += new System.EventHandler(this.buttonBrowseEncoding_Click); + // + // radioButtonSaveInOutputFolder + // + this.radioButtonSaveInOutputFolder.AutoSize = true; + this.radioButtonSaveInOutputFolder.Location = new System.Drawing.Point(10, 56); + this.radioButtonSaveInOutputFolder.Name = "radioButtonSaveInOutputFolder"; + this.radioButtonSaveInOutputFolder.Size = new System.Drawing.Size(154, 17); + this.radioButtonSaveInOutputFolder.TabIndex = 11; + this.radioButtonSaveInOutputFolder.Text = "Save in output folder below"; + this.radioButtonSaveInOutputFolder.UseVisualStyleBackColor = true; + this.radioButtonSaveInOutputFolder.CheckedChanged += new System.EventHandler(this.radioButtonSaveInOutputFolder_CheckedChanged); + // + // buttonTransportStreamSettings + // + this.buttonTransportStreamSettings.Location = new System.Drawing.Point(300, 236); + this.buttonTransportStreamSettings.Name = "buttonTransportStreamSettings"; + this.buttonTransportStreamSettings.Size = new System.Drawing.Size(116, 23); + this.buttonTransportStreamSettings.TabIndex = 10; + this.buttonTransportStreamSettings.Text = "TS settings..."; + this.buttonTransportStreamSettings.UseVisualStyleBackColor = true; + this.buttonTransportStreamSettings.Visible = false; + this.buttonTransportStreamSettings.Click += new System.EventHandler(this.buttonTransportStreamSettings_Click); + // + // linkLabelOpenOutputFolder + // + this.linkLabelOpenOutputFolder.AutoSize = true; + this.linkLabelOpenOutputFolder.Location = new System.Drawing.Point(357, 81); + this.linkLabelOpenOutputFolder.Name = "linkLabelOpenOutputFolder"; + this.linkLabelOpenOutputFolder.Size = new System.Drawing.Size(42, 13); + this.linkLabelOpenOutputFolder.TabIndex = 9; + this.linkLabelOpenOutputFolder.TabStop = true; + this.linkLabelOpenOutputFolder.Text = "Open..."; + this.linkLabelOpenOutputFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelOpenOutputFolder_LinkClicked); + // + // checkBoxUseStyleFromSource + // + this.checkBoxUseStyleFromSource.AutoSize = true; + this.checkBoxUseStyleFromSource.Location = new System.Drawing.Point(80, 236); + this.checkBoxUseStyleFromSource.Name = "checkBoxUseStyleFromSource"; + this.checkBoxUseStyleFromSource.Size = new System.Drawing.Size(127, 17); + this.checkBoxUseStyleFromSource.TabIndex = 9; + this.checkBoxUseStyleFromSource.Text = "Use style from source"; + this.checkBoxUseStyleFromSource.UseVisualStyleBackColor = true; + this.checkBoxUseStyleFromSource.Visible = false; + // + // checkBoxOverwrite + // + this.checkBoxOverwrite.AutoSize = true; + this.checkBoxOverwrite.Location = new System.Drawing.Point(10, 122); + this.checkBoxOverwrite.Name = "checkBoxOverwrite"; + this.checkBoxOverwrite.Size = new System.Drawing.Size(125, 17); + this.checkBoxOverwrite.TabIndex = 10; + this.checkBoxOverwrite.Text = "Overwrite exiting files"; + this.checkBoxOverwrite.UseVisualStyleBackColor = true; + // + // buttonStyles + // + this.buttonStyles.Location = new System.Drawing.Point(300, 207); + this.buttonStyles.Name = "buttonStyles"; + this.buttonStyles.Size = new System.Drawing.Size(116, 23); + this.buttonStyles.TabIndex = 8; + this.buttonStyles.Text = "Style..."; + this.buttonStyles.UseVisualStyleBackColor = true; + this.buttonStyles.Visible = false; + this.buttonStyles.Click += new System.EventHandler(this.ButtonStylesClick); + // + // buttonChooseFolder + // + this.buttonChooseFolder.Enabled = false; + this.buttonChooseFolder.Location = new System.Drawing.Point(325, 76); + this.buttonChooseFolder.Name = "buttonChooseFolder"; + this.buttonChooseFolder.Size = new System.Drawing.Size(26, 23); + this.buttonChooseFolder.TabIndex = 8; + this.buttonChooseFolder.Text = "..."; + this.buttonChooseFolder.UseVisualStyleBackColor = true; + this.buttonChooseFolder.Click += new System.EventHandler(this.buttonChooseFolder_Click); + // + // comboBoxSubtitleFormats + // + this.comboBoxSubtitleFormats.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSubtitleFormats.FormattingEnabled = true; + this.comboBoxSubtitleFormats.Location = new System.Drawing.Point(80, 209); + this.comboBoxSubtitleFormats.Name = "comboBoxSubtitleFormats"; + this.comboBoxSubtitleFormats.Size = new System.Drawing.Size(214, 21); + this.comboBoxSubtitleFormats.TabIndex = 7; + this.comboBoxSubtitleFormats.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSubtitleFormatsSelectedIndexChanged); + // + // textBoxOutputFolder + // + this.textBoxOutputFolder.Enabled = false; + this.textBoxOutputFolder.Location = new System.Drawing.Point(17, 79); + this.textBoxOutputFolder.Name = "textBoxOutputFolder"; + this.textBoxOutputFolder.Size = new System.Drawing.Size(302, 20); + this.textBoxOutputFolder.TabIndex = 7; + // + // labelEncoding + // + this.labelEncoding.AutoSize = true; + this.labelEncoding.Location = new System.Drawing.Point(10, 267); + this.labelEncoding.Name = "labelEncoding"; + this.labelEncoding.Size = new System.Drawing.Size(52, 13); + this.labelEncoding.TabIndex = 9; + this.labelEncoding.Text = "Encoding"; + // + // radioButtonSaveInSourceFolder + // + this.radioButtonSaveInSourceFolder.AutoSize = true; + this.radioButtonSaveInSourceFolder.Checked = true; + this.radioButtonSaveInSourceFolder.Location = new System.Drawing.Point(10, 27); + this.radioButtonSaveInSourceFolder.Name = "radioButtonSaveInSourceFolder"; + this.radioButtonSaveInSourceFolder.Size = new System.Drawing.Size(141, 17); + this.radioButtonSaveInSourceFolder.TabIndex = 0; + this.radioButtonSaveInSourceFolder.TabStop = true; + this.radioButtonSaveInSourceFolder.Text = "Save in source file folder"; + this.radioButtonSaveInSourceFolder.UseVisualStyleBackColor = true; + this.radioButtonSaveInSourceFolder.CheckedChanged += new System.EventHandler(this.radioButtonSaveInSourceFolder_CheckedChanged); + // + // comboBoxEncoding + // + this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxEncoding.FormattingEnabled = true; + this.comboBoxEncoding.Location = new System.Drawing.Point(80, 264); + this.comboBoxEncoding.Name = "comboBoxEncoding"; + this.comboBoxEncoding.Size = new System.Drawing.Size(214, 21); + this.comboBoxEncoding.TabIndex = 11; + // + // labelOutputFormat + // + this.labelOutputFormat.AutoSize = true; + this.labelOutputFormat.Location = new System.Drawing.Point(10, 212); + this.labelOutputFormat.Name = "labelOutputFormat"; + this.labelOutputFormat.Size = new System.Drawing.Size(39, 13); + this.labelOutputFormat.TabIndex = 6; + this.labelOutputFormat.Text = "Format"; + // + // groupBoxInput + // + this.groupBoxInput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxInput.Controls.Add(this.labelNumberOfFiles); + this.groupBoxInput.Controls.Add(this.textBoxFilter); + this.groupBoxInput.Controls.Add(this.labelFilter); + this.groupBoxInput.Controls.Add(this.comboBoxFilter); + this.groupBoxInput.Controls.Add(this.checkBoxScanFolderRecursive); + this.groupBoxInput.Controls.Add(this.buttonSearchFolder); + this.groupBoxInput.Controls.Add(this.buttonInputBrowse); + this.groupBoxInput.Controls.Add(this.labelChooseInputFiles); + this.groupBoxInput.Controls.Add(this.listViewInputFiles); + this.groupBoxInput.Location = new System.Drawing.Point(12, 12); + this.groupBoxInput.Name = "groupBoxInput"; + this.groupBoxInput.Size = new System.Drawing.Size(1014, 287); + this.groupBoxInput.TabIndex = 0; + this.groupBoxInput.TabStop = false; + this.groupBoxInput.Text = "Input"; + // + // labelNumberOfFiles + // + this.labelNumberOfFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.labelNumberOfFiles.Location = new System.Drawing.Point(872, 258); + this.labelNumberOfFiles.Name = "labelNumberOfFiles"; + this.labelNumberOfFiles.Size = new System.Drawing.Size(100, 16); + this.labelNumberOfFiles.TabIndex = 14; + this.labelNumberOfFiles.Text = "labelNumberOfFiles"; + this.labelNumberOfFiles.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // textBoxFilter + // + this.textBoxFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.textBoxFilter.Location = new System.Drawing.Point(422, 258); + this.textBoxFilter.Name = "textBoxFilter"; + this.textBoxFilter.Size = new System.Drawing.Size(158, 20); + this.textBoxFilter.TabIndex = 13; + // + // labelFilter + // + this.labelFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelFilter.AutoSize = true; + this.labelFilter.Location = new System.Drawing.Point(11, 261); + this.labelFilter.Name = "labelFilter"; + this.labelFilter.Size = new System.Drawing.Size(29, 13); + this.labelFilter.TabIndex = 11; + this.labelFilter.Text = "Filter"; + // + // comboBoxFilter + // + this.comboBoxFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.comboBoxFilter.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxFilter.FormattingEnabled = true; + this.comboBoxFilter.Items.AddRange(new object[] { + "All files", + "SubRip .srt files without BOM header", + "Files with subtitle with more than two lines", + "Files that contains...", + "File name cotains...", + "Mkv language code contains..."}); + this.comboBoxFilter.Location = new System.Drawing.Point(81, 258); + this.comboBoxFilter.Name = "comboBoxFilter"; + this.comboBoxFilter.Size = new System.Drawing.Size(335, 21); + this.comboBoxFilter.TabIndex = 12; + this.comboBoxFilter.SelectedIndexChanged += new System.EventHandler(this.comboBoxFilter_SelectedIndexChanged); + // + // checkBoxScanFolderRecursive + // + this.checkBoxScanFolderRecursive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.checkBoxScanFolderRecursive.AutoSize = true; + this.checkBoxScanFolderRecursive.Checked = true; + this.checkBoxScanFolderRecursive.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxScanFolderRecursive.Location = new System.Drawing.Point(778, 16); + this.checkBoxScanFolderRecursive.Name = "checkBoxScanFolderRecursive"; + this.checkBoxScanFolderRecursive.Size = new System.Drawing.Size(74, 17); + this.checkBoxScanFolderRecursive.TabIndex = 0; + this.checkBoxScanFolderRecursive.Text = "Recursive"; + this.checkBoxScanFolderRecursive.UseVisualStyleBackColor = true; + // + // buttonSearchFolder + // + this.buttonSearchFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSearchFolder.Location = new System.Drawing.Point(858, 12); + this.buttonSearchFolder.Name = "buttonSearchFolder"; + this.buttonSearchFolder.Size = new System.Drawing.Size(116, 23); + this.buttonSearchFolder.TabIndex = 1; + this.buttonSearchFolder.Text = "Search folder..."; + this.buttonSearchFolder.UseVisualStyleBackColor = true; + this.buttonSearchFolder.Click += new System.EventHandler(this.buttonSearchFolder_Click); + // + // buttonInputBrowse + // + this.buttonInputBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonInputBrowse.Location = new System.Drawing.Point(979, 41); + this.buttonInputBrowse.Name = "buttonInputBrowse"; + this.buttonInputBrowse.Size = new System.Drawing.Size(26, 23); + this.buttonInputBrowse.TabIndex = 3; + this.buttonInputBrowse.Text = "..."; + this.buttonInputBrowse.UseVisualStyleBackColor = true; + this.buttonInputBrowse.Click += new System.EventHandler(this.buttonInputBrowse_Click); + // + // labelChooseInputFiles + // + this.labelChooseInputFiles.AutoSize = true; + this.labelChooseInputFiles.Location = new System.Drawing.Point(5, 25); + this.labelChooseInputFiles.Name = "labelChooseInputFiles"; + this.labelChooseInputFiles.Size = new System.Drawing.Size(202, 13); + this.labelChooseInputFiles.TabIndex = 0; + this.labelChooseInputFiles.Text = "Choose input files (browse or drag-n-drop)"; + // + // listViewInputFiles + // + this.listViewInputFiles.AllowDrop = true; + this.listViewInputFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewInputFiles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderFName, + this.columnHeaderSize, + this.columnHeaderFormat, + this.columnHeaderStatus}); + this.listViewInputFiles.ContextMenuStrip = this.contextMenuStripFiles; + this.listViewInputFiles.FullRowSelect = true; + this.listViewInputFiles.HideSelection = false; + this.listViewInputFiles.Location = new System.Drawing.Point(6, 41); + this.listViewInputFiles.Name = "listViewInputFiles"; + this.listViewInputFiles.Size = new System.Drawing.Size(968, 211); + this.listViewInputFiles.TabIndex = 2; + this.listViewInputFiles.UseCompatibleStateImageBehavior = false; + this.listViewInputFiles.View = System.Windows.Forms.View.Details; + this.listViewInputFiles.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewInputFiles_ColumnClick); + this.listViewInputFiles.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewInputFiles_DragDrop); + this.listViewInputFiles.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewInputFiles_DragEnter); + this.listViewInputFiles.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ListViewInputFilesKeyDown); + // + // columnHeaderFName + // + this.columnHeaderFName.Text = "File name"; + this.columnHeaderFName.Width = 500; + // + // columnHeaderSize + // + this.columnHeaderSize.Text = "Size"; + this.columnHeaderSize.Width = 75; + // + // columnHeaderFormat + // + this.columnHeaderFormat.Text = "Format"; + this.columnHeaderFormat.Width = 200; + // + // columnHeaderStatus + // + this.columnHeaderStatus.Text = "Status"; + this.columnHeaderStatus.Width = 124; + // + // contextMenuStripFiles + // + this.contextMenuStripFiles.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addFilesToolStripMenuItem, + this.toolStripSeparator2, + this.removeToolStripMenuItem, + this.removeAllToolStripMenuItem, + this.openContainingFolderToolStripMenuItem, + this.toolStripSeparator1, + this.convertMkvSettingsToolStripMenuItem}); + this.contextMenuStripFiles.Name = "contextMenuStripStyles"; + this.contextMenuStripFiles.Size = new System.Drawing.Size(400, 126); + this.contextMenuStripFiles.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripFilesOpening); + // + // addFilesToolStripMenuItem + // + this.addFilesToolStripMenuItem.Name = "addFilesToolStripMenuItem"; + this.addFilesToolStripMenuItem.Size = new System.Drawing.Size(399, 22); + this.addFilesToolStripMenuItem.Text = "Add files"; + this.addFilesToolStripMenuItem.Click += new System.EventHandler(this.addFilesToolStripMenuItem_Click); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(396, 6); + // + // removeToolStripMenuItem + // + this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; + this.removeToolStripMenuItem.Size = new System.Drawing.Size(399, 22); + this.removeToolStripMenuItem.Text = "Remove"; + this.removeToolStripMenuItem.Click += new System.EventHandler(this.RemoveToolStripMenuItemClick); + // + // removeAllToolStripMenuItem + // + this.removeAllToolStripMenuItem.Name = "removeAllToolStripMenuItem"; + this.removeAllToolStripMenuItem.Size = new System.Drawing.Size(399, 22); + this.removeAllToolStripMenuItem.Text = "Remove all"; + this.removeAllToolStripMenuItem.Click += new System.EventHandler(this.RemoveAllToolStripMenuItemClick); + // + // openContainingFolderToolStripMenuItem + // + this.openContainingFolderToolStripMenuItem.Name = "openContainingFolderToolStripMenuItem"; + this.openContainingFolderToolStripMenuItem.Size = new System.Drawing.Size(399, 22); + this.openContainingFolderToolStripMenuItem.Text = "Open containing folder"; + this.openContainingFolderToolStripMenuItem.Click += new System.EventHandler(this.openContainingFolderToolStripMenuItem_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(396, 6); + // + // convertMkvSettingsToolStripMenuItem + // + this.convertMkvSettingsToolStripMenuItem.Name = "convertMkvSettingsToolStripMenuItem"; + this.convertMkvSettingsToolStripMenuItem.Size = new System.Drawing.Size(399, 22); + this.convertMkvSettingsToolStripMenuItem.Text = "Mkv language in output file name: Three letter language code"; + this.convertMkvSettingsToolStripMenuItem.Click += new System.EventHandler(this.convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // progressBar1 + // + this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.progressBar1.Location = new System.Drawing.Point(15, 627); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(820, 10); + this.progressBar1.TabIndex = 8; + // + // labelStatus + // + this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(12, 611); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(59, 13); + this.labelStatus.TabIndex = 9; + this.labelStatus.Text = "labelStatus"; + // + // BatchConvert + // + this.AllowDrop = true; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1035, 651); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.progressBar1); + this.Controls.Add(this.groupBoxOutput); + this.Controls.Add(this.groupBoxInput); + this.Controls.Add(this.buttonConvert); + this.Controls.Add(this.buttonCancel); + this.KeyPreview = true; + this.MinimumSize = new System.Drawing.Size(1024, 578); + this.Name = "BatchConvert"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Batch convert"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BatchConvert_FormClosing); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.BatchConvert_KeyDown); + this.groupBoxConvertOptions.ResumeLayout(false); + this.groupBoxDeleteLines.ResumeLayout(false); + this.groupBoxDeleteLines.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDeleteLast)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDeleteFirst)).EndInit(); + this.groupBoxRemoveStyle.ResumeLayout(false); + this.groupBoxRemoveStyle.PerformLayout(); + this.groupBoxOffsetTimeCodes.ResumeLayout(false); + this.groupBoxOffsetTimeCodes.PerformLayout(); + this.contextMenuStripOptions.ResumeLayout(false); + this.groupBoxChangeFrameRate.ResumeLayout(false); + this.groupBoxChangeFrameRate.PerformLayout(); + this.groupBoxFixRtl.ResumeLayout(false); + this.groupBoxFixRtl.PerformLayout(); + this.groupBoxSpeed.ResumeLayout(false); + this.groupBoxSpeed.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).EndInit(); + this.groupBoxChangeCasing.ResumeLayout(false); + this.groupBoxChangeCasing.PerformLayout(); + this.groupBoxMergeShortLines.ResumeLayout(false); + this.groupBoxMergeShortLines.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).EndInit(); + this.groupBoxAdjustDuration.ResumeLayout(false); + this.groupBoxAdjustDuration.PerformLayout(); + this.panelAdjustDurationFixed.ResumeLayout(false); + this.panelAdjustDurationFixed.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFixedMilliseconds)).EndInit(); + this.panelAdjustDurationAddPercent.ResumeLayout(false); + this.panelAdjustDurationAddPercent.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAdjustViaPercent)).EndInit(); + this.panelAdjustDurationAddSeconds.ResumeLayout(false); + this.panelAdjustDurationAddSeconds.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).EndInit(); + this.panelAdjustDurationRecalc.ResumeLayout(false); + this.panelAdjustDurationRecalc.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharsSec)).EndInit(); + this.groupBoxOutput.ResumeLayout(false); + this.groupBoxOutput.PerformLayout(); + this.groupBoxInput.ResumeLayout(false); + this.groupBoxInput.PerformLayout(); + this.contextMenuStripFiles.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonConvert; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.GroupBox groupBoxConvertOptions; + private System.Windows.Forms.GroupBox groupBoxOutput; + private System.Windows.Forms.ComboBox comboBoxSubtitleFormats; + private System.Windows.Forms.Label labelEncoding; + private System.Windows.Forms.ComboBox comboBoxEncoding; + private System.Windows.Forms.Label labelOutputFormat; + private System.Windows.Forms.GroupBox groupBoxInput; + private System.Windows.Forms.Button buttonInputBrowse; + private System.Windows.Forms.Label labelChooseInputFiles; + private System.Windows.Forms.ListView listViewInputFiles; + private System.Windows.Forms.ColumnHeader columnHeaderFName; + private System.Windows.Forms.ColumnHeader columnHeaderSize; + private System.Windows.Forms.ColumnHeader columnHeaderFormat; + private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.ColumnHeader columnHeaderStatus; + private System.Windows.Forms.Button buttonStyles; + private System.Windows.Forms.GroupBox groupBoxOffsetTimeCodes; + private System.Windows.Forms.GroupBox groupBoxChangeFrameRate; + private Controls.TimeUpDown timeUpDownAdjust; + private System.Windows.Forms.Label labelHourMinSecMilliSecond; + private System.Windows.Forms.ComboBox comboBoxFrameRateTo; + private System.Windows.Forms.Label labelToFrameRate; + private System.Windows.Forms.ComboBox comboBoxFrameRateFrom; + private System.Windows.Forms.Label labelFromFrameRate; + private System.Windows.Forms.ContextMenuStrip contextMenuStripFiles; + private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeAllToolStripMenuItem; + private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.Label labelStatus; + private System.Windows.Forms.RadioButton radioButtonShowLater; + private System.Windows.Forms.RadioButton radioButtonShowEarlier; + private System.Windows.Forms.Button buttonSearchFolder; + private System.Windows.Forms.CheckBox checkBoxScanFolderRecursive; + private System.Windows.Forms.Label labelFilter; + private System.Windows.Forms.ComboBox comboBoxFilter; + private System.Windows.Forms.TextBox textBoxFilter; + private System.Windows.Forms.GroupBox groupBoxSpeed; + private System.Windows.Forms.NumericUpDown numericUpDownPercent; + private System.Windows.Forms.Label labelPercent; + private System.Windows.Forms.RadioButton radioButtonToDropFrame; + private System.Windows.Forms.RadioButton radioButtonSpeedFromDropFrame; + private System.Windows.Forms.RadioButton radioButtonSpeedCustom; + private System.Windows.Forms.CheckBox checkBoxUseStyleFromSource; + private System.Windows.Forms.Button buttonTransportStreamSettings; + private System.Windows.Forms.RadioButton radioButtonSaveInOutputFolder; + private System.Windows.Forms.LinkLabel linkLabelOpenOutputFolder; + private System.Windows.Forms.CheckBox checkBoxOverwrite; + private System.Windows.Forms.Button buttonChooseFolder; + private System.Windows.Forms.TextBox textBoxOutputFolder; + private System.Windows.Forms.RadioButton radioButtonSaveInSourceFolder; + private System.Windows.Forms.ListView listViewConvertOptions; + private System.Windows.Forms.ColumnHeader ActionCheckBox; + private System.Windows.Forms.ColumnHeader Action; + private System.Windows.Forms.Button buttonConvertOptionsSettings; + private System.Windows.Forms.GroupBox groupBoxFixRtl; + private System.Windows.Forms.RadioButton radioButtonReverseStartEnd; + private System.Windows.Forms.RadioButton radioButtonRemoveUnicode; + private System.Windows.Forms.RadioButton radioButtonAddUnicode; + private System.Windows.Forms.GroupBox groupBoxMergeShortLines; + private System.Windows.Forms.CheckBox checkBoxOnlyContinuationLines; + private System.Windows.Forms.NumericUpDown numericUpDownMaxCharacters; + private System.Windows.Forms.NumericUpDown numericUpDownMaxMillisecondsBetweenLines; + private System.Windows.Forms.Label labelMaxMillisecondsBetweenLines; + private System.Windows.Forms.Label labelMaxCharacters; + private System.Windows.Forms.Button buttonSwapFrameRate; + private System.Windows.Forms.GroupBox groupBoxChangeCasing; + private System.Windows.Forms.RadioButton radioButtonFixOnlyNames; + private System.Windows.Forms.RadioButton radioButtonLowercase; + private System.Windows.Forms.RadioButton radioButtonUppercase; + private System.Windows.Forms.RadioButton radioButtonNormal; + private System.Windows.Forms.ContextMenuStrip contextMenuStripOptions; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; + private System.Windows.Forms.ToolStripMenuItem inverseSelectionToolStripMenuItem; + private System.Windows.Forms.Button buttonBrowseEncoding; + private System.Windows.Forms.Label labelNumberOfFiles; + private System.Windows.Forms.ToolStripMenuItem openContainingFolderToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem convertMkvSettingsToolStripMenuItem; + private System.Windows.Forms.GroupBox groupBoxRemoveStyle; + private System.Windows.Forms.TextBox textBoxRemoveStyle; + private System.Windows.Forms.Label labelStyleName; + private System.Windows.Forms.GroupBox groupBoxAdjustDuration; + private System.Windows.Forms.Label labelAdjustDurationVia; + private System.Windows.Forms.ComboBox comboBoxAdjustDurationVia; + private System.Windows.Forms.Panel panelAdjustDurationAddPercent; + private System.Windows.Forms.Panel panelAdjustDurationAddSeconds; + private System.Windows.Forms.NumericUpDown numericUpDownSeconds; + private System.Windows.Forms.Label labelAddSeconds; + private System.Windows.Forms.Panel panelAdjustDurationFixed; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.NumericUpDown numericUpDownAdjustViaPercent; + private System.Windows.Forms.Label labelAdjustViaPercent; + private System.Windows.Forms.NumericUpDown numericUpDownFixedMilliseconds; + private System.Windows.Forms.Label labelMillisecondsFixed; + private System.Windows.Forms.Panel panelAdjustDurationRecalc; + private System.Windows.Forms.CheckBox checkBoxExtendOnly; + private System.Windows.Forms.NumericUpDown numericUpDownOptimalCharsSec; + private System.Windows.Forms.Label labelOptimalCharsSec; + private System.Windows.Forms.NumericUpDown numericUpDownMaxCharsSec; + private System.Windows.Forms.Label labelMaxCharsPerSecond; + private System.Windows.Forms.ToolStripMenuItem addFilesToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.GroupBox groupBoxDeleteLines; + private System.Windows.Forms.TextBox textBoxDeleteContains; + private System.Windows.Forms.Label labelDeleteLinesContaining; + private System.Windows.Forms.NumericUpDown numericUpDownDeleteLast; + private System.Windows.Forms.Label labelDeleteLastLines; + private System.Windows.Forms.NumericUpDown numericUpDownDeleteFirst; + private System.Windows.Forms.Label labelDeleteFirstLines; + } } \ No newline at end of file diff --git a/src/Forms/BatchConvert.cs b/src/ui/Forms/BatchConvert.cs similarity index 97% rename from src/Forms/BatchConvert.cs rename to src/ui/Forms/BatchConvert.cs index dd1668603..f827b078d 100644 --- a/src/Forms/BatchConvert.cs +++ b/src/ui/Forms/BatchConvert.cs @@ -1,2976 +1,2976 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.BluRaySup; -using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; -using Nikse.SubtitleEdit.Core.ContainerFormats.TransportStream; -using Nikse.SubtitleEdit.Core.Forms; -using Nikse.SubtitleEdit.Core.Interfaces; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Core.VobSub; -using Nikse.SubtitleEdit.Forms.Ocr; -using Nikse.SubtitleEdit.Forms.Styles; -using Nikse.SubtitleEdit.Logic; -using Nikse.SubtitleEdit.Logic.CommandLineConvert; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class BatchConvert : PositionAndSizeForm - { - private const string AddUnicode = "ADD_UNICODE"; - private const string RemoveUnicode = "REMOVE_UNICODE"; - private const string ReverseStartEnd = "REVERSE_START_END"; - - public class ThreadDoWorkParameter - { - public bool FixCommonErrors { get; set; } - public bool MultipleReplaceActive { get; set; } - public bool FixRtl { get; set; } - public bool SplitLongLinesActive { get; set; } - public bool AutoBalanceActive { get; set; } - public bool SetMinDisplayTimeBetweenSubtitles { get; set; } - public ListViewItem Item { get; set; } - public Subtitle Subtitle { get; set; } - public SubtitleFormat Format { get; set; } - public TextEncoding Encoding { get; set; } - public string Language { get; set; } - public string Error { get; set; } - public string FileName { get; set; } - public string ToFormat { get; set; } - public SubtitleFormat SourceFormat { get; set; } - public List BinaryParagraphs { get; set; } - public ThreadDoWorkParameter( - bool fixCommonErrors, - bool multipleReplace, - bool fixRtl, - bool splitLongLinesActive, - bool autoBalance, - bool setMinDisplayTimeBetweenSubtitles, - ListViewItem item, - Subtitle subtitle, - SubtitleFormat format, - TextEncoding encoding, - string language, - string fileName, - string toFormat, - SubtitleFormat sourceFormat, - List binaryParagraphs) - { - FixCommonErrors = fixCommonErrors; - MultipleReplaceActive = multipleReplace; - FixRtl = fixRtl; - SplitLongLinesActive = splitLongLinesActive; - AutoBalanceActive = autoBalance; - SetMinDisplayTimeBetweenSubtitles = setMinDisplayTimeBetweenSubtitles; - Item = item; - Subtitle = subtitle; - Format = format; - Encoding = encoding; - Language = language; - FileName = fileName; - ToFormat = toFormat; - SourceFormat = sourceFormat; - BinaryParagraphs = binaryParagraphs; - } - } - - private string _assStyle; - private string _ssaStyle; - private readonly RemoveTextForHI _removeTextForHearingImpaired; - private readonly ChangeCasing _changeCasing = new ChangeCasing(); - private readonly ChangeCasingNames _changeCasingNames = new ChangeCasingNames(); - private bool _converting; - private int _count; - private int _converted; - private int _errors; - private readonly List _allFormats; - private bool _searching; - private bool _abort; - private Ebu.EbuGeneralSubtitleInformation _ebuGeneralInformation; - public static string BluRaySubtitle => "Blu-ray sup"; - public static string VobSubSubtitle => "VobSub"; - public static string DostImageSubtitle => "Dost-image"; - public static string BdnXmlSubtitle => "BDN-XML"; - public static string FcpImageSubtitle => "FCP-image"; - private string _customTextTemplate; - private readonly DurationsBridgeGaps _bridgeGaps; - private const int ConvertMaxFileSize = 1024 * 1024 * 10; // 10 MB - private Dictionary> _bdLookup = new Dictionary>(); - RemoveTextForHISettings _removeTextForHiSettings; - - public BatchConvert(Icon icon) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Icon = (Icon)icon.Clone(); - - progressBar1.Visible = false; - labelStatus.Text = string.Empty; - var l = Configuration.Settings.Language.BatchConvert; - Text = l.Title; - groupBoxInput.Text = l.Input; - labelChooseInputFiles.Text = l.InputDescription; - groupBoxOutput.Text = l.Output; - radioButtonSaveInSourceFolder.Text = l.SaveInSourceFolder; - radioButtonSaveInOutputFolder.Text = l.SaveInOutputFolder; - checkBoxOverwrite.Text = l.OverwriteFiles; - labelOutputFormat.Text = Configuration.Settings.Language.Main.Controls.SubtitleFormat; - labelEncoding.Text = Configuration.Settings.Language.Main.Controls.FileEncoding; - buttonStyles.Text = l.Style; - checkBoxUseStyleFromSource.Text = l.UseStyleFromSource; - groupBoxConvertOptions.Text = l.ConvertOptions; - columnHeaderFName.Text = Configuration.Settings.Language.JoinSubtitles.FileName; - columnHeaderFormat.Text = Configuration.Settings.Language.Main.Controls.SubtitleFormat; - columnHeaderSize.Text = Configuration.Settings.Language.General.Size; - columnHeaderStatus.Text = l.Status; - linkLabelOpenOutputFolder.Text = Configuration.Settings.Language.Main.Menu.File.Open; - buttonSearchFolder.Text = l.ScanFolder; - buttonConvert.Text = l.Convert; - buttonCancel.Text = Configuration.Settings.Language.General.Ok; - checkBoxScanFolderRecursive.Text = l.Recursive; - checkBoxScanFolderRecursive.Left = buttonSearchFolder.Left - checkBoxScanFolderRecursive.Width - 5; - buttonTransportStreamSettings.Text = l.TransportStreamSettingsButton; - groupBoxChangeFrameRate.Text = Configuration.Settings.Language.ChangeFrameRate.Title; - groupBoxOffsetTimeCodes.Text = l.OffsetTimeCodes; - groupBoxSpeed.Text = Configuration.Settings.Language.ChangeSpeedInPercent.TitleShort; - labelFromFrameRate.Text = Configuration.Settings.Language.ChangeFrameRate.FromFrameRate; - labelToFrameRate.Text = Configuration.Settings.Language.ChangeFrameRate.ToFrameRate; - labelHourMinSecMilliSecond.Text = Configuration.Settings.General.UseTimeFormatHHMMSSFF ? Configuration.Settings.Language.General.HourMinutesSecondsFrames : Configuration.Settings.Language.General.HourMinutesSecondsMilliseconds; - openContainingFolderToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.File.OpenContainingFolder; - removeToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.Remove; - removeAllToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.RemoveAll; - groupBoxRemoveStyle.Text = l.RemoveStyleActor; - labelStyleName.Text = $"{Configuration.Settings.Language.General.Style}/{Configuration.Settings.Language.General.Actor}"; - labelDeleteFirstLines.Text = l.DeleteFirstLines; - labelDeleteLastLines.Text = l.DeleteLastLines; - labelDeleteLinesContaining.Text = l.DeleteContaining; - numericUpDownDeleteFirst.Left = labelDeleteFirstLines.Left + labelDeleteFirstLines.Width + 5; - numericUpDownDeleteLast.Left = labelDeleteLastLines.Left + labelDeleteLastLines.Width + 5; - groupBoxAdjustDuration.Text = Configuration.Settings.Language.AdjustDisplayDuration.Title; - - comboBoxFrameRateFrom.Left = labelFromFrameRate.Left + labelFromFrameRate.Width + 3; - comboBoxFrameRateTo.Left = labelToFrameRate.Left + labelToFrameRate.Width + 3; - if (comboBoxFrameRateFrom.Left > comboBoxFrameRateTo.Left) - { - comboBoxFrameRateTo.Left = comboBoxFrameRateFrom.Left; - } - else - { - comboBoxFrameRateFrom.Left = comboBoxFrameRateTo.Left; - } - - buttonSwapFrameRate.Left = comboBoxFrameRateFrom.Left + comboBoxFrameRateFrom.Width + 10; - buttonSwapFrameRate.Top = comboBoxFrameRateFrom.Top + ((comboBoxFrameRateTo.Top + comboBoxFrameRateTo.Height - comboBoxFrameRateFrom.Top) / 2) - (buttonSwapFrameRate.Height / 2) + 1; - - comboBoxSubtitleFormats.Left = labelOutputFormat.Left + labelOutputFormat.Width + 3; - comboBoxEncoding.Left = labelEncoding.Left + labelEncoding.Width + 3; - if (comboBoxSubtitleFormats.Left > comboBoxEncoding.Left) - { - comboBoxEncoding.Left = comboBoxSubtitleFormats.Left; - } - else - { - comboBoxSubtitleFormats.Left = comboBoxEncoding.Left; - } - buttonBrowseEncoding.Left = comboBoxEncoding.Left + comboBoxEncoding.Width + 5; - buttonStyles.Left = comboBoxSubtitleFormats.Left + comboBoxSubtitleFormats.Width + 5; - buttonTransportStreamSettings.Left = buttonStyles.Left; - - timeUpDownAdjust.MaskedTextBox.Text = "000000000"; - - comboBoxFrameRateFrom.Items.Add(23.976); - comboBoxFrameRateFrom.Items.Add(24.0); - comboBoxFrameRateFrom.Items.Add(25.0); - comboBoxFrameRateFrom.Items.Add(29.97); - comboBoxFrameRateFrom.Items.Add(30.0); - - comboBoxFrameRateTo.Items.Add(23.976); - comboBoxFrameRateTo.Items.Add(24.0); - comboBoxFrameRateTo.Items.Add(25.0); - comboBoxFrameRateTo.Items.Add(29.97); - comboBoxFrameRateTo.Items.Add(30.0); - - UiUtil.FixLargeFonts(this, buttonCancel); - - _allFormats = new List { new Pac() }; - var formatNames = new List(); - foreach (var format in SubtitleFormat.AllSubtitleFormats) - { - if (!format.IsVobSubIndexFile) - { - formatNames.Add(format.Name); - _allFormats.Add(format); - } - } - formatNames.Add("PAC"); - formatNames.Add(new Ayato().Name); - formatNames.Add(l.PlainText); - formatNames.Add(BluRaySubtitle); - formatNames.Add(VobSubSubtitle); - formatNames.Add(DostImageSubtitle); - formatNames.Add(BdnXmlSubtitle); - formatNames.Add(FcpImageSubtitle); - formatNames.Add(Configuration.Settings.Language.ExportCustomText.Title); - UiUtil.InitializeSubtitleFormatComboBox(comboBoxSubtitleFormats, formatNames, Configuration.Settings.Tools.BatchConvertFormat); - - UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding); - comboBoxEncoding.Items.Add(new TextEncoding(Encoding.UTF8, l.TryToUseSourceEncoding)); - - if (string.IsNullOrEmpty(Configuration.Settings.Tools.BatchConvertOutputFolder) || !Directory.Exists(Configuration.Settings.Tools.BatchConvertOutputFolder)) - { - textBoxOutputFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); - } - else - { - textBoxOutputFolder.Text = Configuration.Settings.Tools.BatchConvertOutputFolder; - } - - checkBoxOverwrite.Checked = Configuration.Settings.Tools.BatchConvertOverwriteExisting; - buttonConvertOptionsSettings.Text = l.Settings; - radioButtonShowEarlier.Text = Configuration.Settings.Language.ShowEarlierLater.ShowEarlier.RemoveChar('&'); - radioButtonShowLater.Text = Configuration.Settings.Language.ShowEarlierLater.ShowLater.RemoveChar('&'); - radioButtonSpeedCustom.Text = Configuration.Settings.Language.ChangeSpeedInPercent.Custom; - radioButtonSpeedFromDropFrame.Text = Configuration.Settings.Language.ChangeSpeedInPercent.FromDropFrame; - radioButtonToDropFrame.Text = Configuration.Settings.Language.ChangeSpeedInPercent.ToDropFrame; - if (Configuration.Settings.Tools.BatchConvertSaveInSourceFolder) - { - radioButtonSaveInSourceFolder.Checked = true; - } - else - { - radioButtonSaveInOutputFolder.Checked = true; - } - - groupBoxChangeCasing.Text = Configuration.Settings.Language.ChangeCasing.ChangeCasingTo; - radioButtonNormal.Text = Configuration.Settings.Language.ChangeCasing.NormalCasing; - radioButtonFixOnlyNames.Text = Configuration.Settings.Language.ChangeCasing.FixOnlyNamesCasing; - radioButtonUppercase.Text = Configuration.Settings.Language.ChangeCasing.AllUppercase; - radioButtonLowercase.Text = Configuration.Settings.Language.ChangeCasing.AllLowercase; - if (Configuration.Settings.Tools.ChangeCasingChoice == "NamesOnly") - { - radioButtonFixOnlyNames.Checked = true; - } - else if (Configuration.Settings.Tools.ChangeCasingChoice == "Uppercase") - { - radioButtonUppercase.Checked = true; - } - else if (Configuration.Settings.Tools.ChangeCasingChoice == "Lowercase") - { - radioButtonLowercase.Checked = true; - } - - _removeTextForHearingImpaired = new RemoveTextForHI(new RemoveTextForHISettings(new Subtitle())); - _removeTextForHiSettings = _removeTextForHearingImpaired.Settings; - - labelFilter.Text = l.Filter; - comboBoxFilter.Items[0] = Configuration.Settings.Language.General.AllFiles; - comboBoxFilter.Items[1] = l.FilterSrtNoUtf8BOM; - comboBoxFilter.Items[2] = l.FilterMoreThanTwoLines; - comboBoxFilter.Items[3] = l.FilterContains; - comboBoxFilter.Items[4] = l.FilterFileNameContains; - comboBoxFilter.Items[5] = l.MkvLanguageCodeContains; - comboBoxFilter.SelectedIndex = 0; - comboBoxFilter.Left = labelFilter.Left + labelFilter.Width + 4; - textBoxFilter.Left = comboBoxFilter.Left + comboBoxFilter.Width + 4; - - _assStyle = Configuration.Settings.Tools.BatchConvertAssStyles; - _ssaStyle = Configuration.Settings.Tools.BatchConvertSsaStyles; - checkBoxUseStyleFromSource.Checked = Configuration.Settings.Tools.BatchConvertUseStyleFromSource; - _customTextTemplate = Configuration.Settings.Tools.BatchConvertExportCustomTextTemplate; - - comboBoxSubtitleFormats.AutoCompleteSource = AutoCompleteSource.ListItems; - comboBoxSubtitleFormats.AutoCompleteMode = AutoCompleteMode.Append; - - _bridgeGaps = new DurationsBridgeGaps(null); - _bridgeGaps.InitializeSettingsOnly(); - buttonTransportStreamSettings.Visible = false; - - groupBoxFixRtl.Text = Configuration.Settings.Language.BatchConvert.Settings; - radioButtonAddUnicode.Text = Configuration.Settings.Language.BatchConvert.FixRtlAddUnicode; - radioButtonRemoveUnicode.Text = Configuration.Settings.Language.BatchConvert.FixRtlRemoveUnicode; - radioButtonReverseStartEnd.Text = Configuration.Settings.Language.BatchConvert.FixRtlReverseStartEnd; - - - labelAdjustDurationVia.Text = Configuration.Settings.Language.AdjustDisplayDuration.AdjustVia; - comboBoxAdjustDurationVia.Left = labelAdjustDurationVia.Left + labelAdjustDurationVia.Width + 5; - comboBoxAdjustDurationVia.Items.Clear(); - comboBoxAdjustDurationVia.Items.Add(Configuration.Settings.Language.AdjustDisplayDuration.AddSeconds); - comboBoxAdjustDurationVia.Items.Add(Configuration.Settings.Language.AdjustDisplayDuration.Percent); - comboBoxAdjustDurationVia.Items.Add(Configuration.Settings.Language.AdjustDisplayDuration.Recalculate); - comboBoxAdjustDurationVia.Items.Add(Configuration.Settings.Language.AdjustDisplayDuration.Fixed); - switch (Configuration.Settings.Tools.AdjustDurationLast) - { - case AdjustDisplayDuration.Sec: - comboBoxAdjustDurationVia.SelectedIndex = 0; - break; - case AdjustDisplayDuration.Per: - comboBoxAdjustDurationVia.SelectedIndex = 1; - break; - case AdjustDisplayDuration.Recal: - comboBoxAdjustDurationVia.SelectedIndex = 2; - break; - case AdjustDisplayDuration.Fixed: - comboBoxAdjustDurationVia.SelectedIndex = 3; - break; - default: - comboBoxAdjustDurationVia.SelectedIndex = 0; - break; - } - decimal adjustSeconds = Configuration.Settings.Tools.AdjustDurationSeconds; - if (adjustSeconds >= numericUpDownSeconds.Minimum && adjustSeconds <= numericUpDownSeconds.Maximum) - { - numericUpDownSeconds.Value = adjustSeconds; - } - - int adjustPercent = Configuration.Settings.Tools.AdjustDurationPercent; - if (adjustPercent >= numericUpDownAdjustViaPercent.Minimum && adjustPercent <= numericUpDownAdjustViaPercent.Maximum) - { - numericUpDownAdjustViaPercent.Value = adjustPercent; - } - - numericUpDownOptimalCharsSec.Value = (decimal)Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds; - numericUpDownMaxCharsSec.Value = (decimal)Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds; - checkBoxExtendOnly.Checked = Configuration.Settings.Tools.AdjustDurationExtendOnly; - - labelOptimalCharsSec.Text = Configuration.Settings.Language.Settings.OptimalCharactersPerSecond; - labelMaxCharsPerSecond.Text = Configuration.Settings.Language.Settings.MaximumCharactersPerSecond; - labelAddSeconds.Text = Configuration.Settings.Language.AdjustDisplayDuration.AddSeconds; - labelMillisecondsFixed.Text = Configuration.Settings.Language.AdjustDisplayDuration.Milliseconds; - checkBoxExtendOnly.Text = Configuration.Settings.Language.AdjustDisplayDuration.ExtendOnly; - labelAdjustViaPercent.Text = Configuration.Settings.Language.AdjustDisplayDuration.SetAsPercent; - - - - var mode = Configuration.Settings.Tools.BatchConvertFixRtlMode; - if (mode == RemoveUnicode) - { - radioButtonRemoveUnicode.Checked = true; - } - else if (mode == ReverseStartEnd) - { - radioButtonReverseStartEnd.Checked = true; - } - else // fix with unicode char - { - radioButtonAddUnicode.Checked = true; - } - - groupBoxMergeShortLines.Text = Configuration.Settings.Language.MergedShortLines.Title; - labelMaxCharacters.Text = Configuration.Settings.Language.MergedShortLines.MaximumCharacters; - labelMaxMillisecondsBetweenLines.Text = Configuration.Settings.Language.MergedShortLines.MaximumMillisecondsBetween; - checkBoxOnlyContinuationLines.Text = Configuration.Settings.Language.MergedShortLines.OnlyMergeContinuationLines; - if (Configuration.Settings.General.SubtitleLineMaximumLength > numericUpDownMaxCharacters.Maximum) - { - numericUpDownMaxCharacters.Value = numericUpDownMaxCharacters.Maximum; - } - else if (Configuration.Settings.General.SubtitleLineMaximumLength < numericUpDownMaxCharacters.Minimum) - { - numericUpDownMaxCharacters.Value = numericUpDownMaxCharacters.Minimum; - } - else - { - numericUpDownMaxCharacters.Value = Configuration.Settings.General.SubtitleLineMaximumLength; - } - numericUpDownMaxMillisecondsBetweenLines.Value = Configuration.Settings.Tools.MergeShortLinesMaxGap; - checkBoxOnlyContinuationLines.Checked = Configuration.Settings.Tools.MergeShortLinesOnlyContinuous; - - inverseSelectionToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; - toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; - UpdateNumberOfFiles(); - - var fixItems = new List - { - new FixActionItem - { - Text = l.RemoveFormatting, - Checked = Configuration.Settings.Tools.BatchConvertRemoveFormatting, - Action = CommandLineConverter.BatchAction.RemoveFormatting - }, - new FixActionItem - { - Text = l.RemoveStyleActor, - Checked = Configuration.Settings.Tools.BatchConvertRemoveStyle, - Action = CommandLineConverter.BatchAction.RemoveStyle, - Control = groupBoxRemoveStyle - }, - new FixActionItem - { - Text = l.RedoCasing, - Checked = Configuration.Settings.Tools.BatchConvertFixCasing, - Action = CommandLineConverter.BatchAction.RedoCasing, - Control = groupBoxChangeCasing - }, - new FixActionItem - { - Text = l.RemoveTextForHI, - Checked = Configuration.Settings.Tools.BatchConvertRemoveTextForHI, - Action = CommandLineConverter.BatchAction.RemoveTextForHI, - Control = buttonConvertOptionsSettings - }, - new FixActionItem - { - Text = l.BridgeGaps, - Checked = Configuration.Settings.Tools.BatchConvertBridgeGaps, - Action = CommandLineConverter.BatchAction.BridgeGaps, - Control = buttonConvertOptionsSettings - }, - new FixActionItem - { - Text = Configuration.Settings.Language.FixCommonErrors.Title, - Checked = Configuration.Settings.Tools.BatchConvertFixCommonErrors, - Action = CommandLineConverter.BatchAction.FixCommonErrors, - Control = buttonConvertOptionsSettings - }, - new FixActionItem - { - Text = Configuration.Settings.Language.MultipleReplace.Title, - Checked = Configuration.Settings.Tools.BatchConvertMultipleReplace, - Action = CommandLineConverter.BatchAction.MultipleReplace, - Control = buttonConvertOptionsSettings - }, - new FixActionItem - { - Text = l.FixRtl, - Checked = Configuration.Settings.Tools.BatchConvertFixRtl, - Action = CommandLineConverter.BatchAction.FixRtl, - Control = groupBoxFixRtl - }, - new FixActionItem - { - Text = l.SplitLongLines, - Checked = Configuration.Settings.Tools.BatchConvertSplitLongLines, - Action = CommandLineConverter.BatchAction.SplitLongLines - }, - new FixActionItem - { - Text = l.AutoBalance, - Checked = Configuration.Settings.Tools.BatchConvertAutoBalance, - Action = CommandLineConverter.BatchAction.BalanceLines - }, - new FixActionItem - { - Text = Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.Title, - Checked = Configuration.Settings.Tools.BatchConvertSetMinDisplayTimeBetweenSubtitles, - Action = CommandLineConverter.BatchAction.SetMinGap - }, - new FixActionItem - { - Text = Configuration.Settings.Language.MergedShortLines.Title, - Checked = Configuration.Settings.Tools.BatchConvertMergeShortLines, - Action = CommandLineConverter.BatchAction.MergeShortLines, - Control = groupBoxMergeShortLines - }, - new FixActionItem - { - Text = Configuration.Settings.Language.BatchConvert.RemoveLineBreaks, - Checked = Configuration.Settings.Tools.BatchConvertRemoveLineBreaks, - Action = CommandLineConverter.BatchAction.RemoveLineBreaks - }, - new FixActionItem - { - Text = Configuration.Settings.Language.MergeDoubleLines.Title, - Checked = Configuration.Settings.Tools.BatchConvertMergeSameText, - Action = CommandLineConverter.BatchAction.MergeSameTexts - }, - new FixActionItem - { - Text = Configuration.Settings.Language.MergeTextWithSameTimeCodes.Title, - Checked = Configuration.Settings.Tools.BatchConvertMergeSameTimeCodes, - Action = CommandLineConverter.BatchAction.MergeSameTimeCodes - }, - new FixActionItem - { - Text = Configuration.Settings.Language.ChangeFrameRate.Title, - Checked = Configuration.Settings.Tools.BatchConvertChangeFrameRate, - Action = CommandLineConverter.BatchAction.ChangeFrameRate, - Control = groupBoxChangeFrameRate - }, - new FixActionItem - { - Text = l.OffsetTimeCodes, - Checked = Configuration.Settings.Tools.BatchConvertOffsetTimeCodes, - Action = CommandLineConverter.BatchAction.OffsetTimeCodes, - Control = groupBoxOffsetTimeCodes - }, - new FixActionItem - { - Text = Configuration.Settings.Language.ChangeSpeedInPercent.TitleShort, - Checked = Configuration.Settings.Tools.BatchConvertChangeSpeed, - Action = CommandLineConverter.BatchAction.ChangeSpeed, - Control = groupBoxSpeed - }, - new FixActionItem - { - Text = Configuration.Settings.Language.AdjustDisplayDuration.Title, - Checked = Configuration.Settings.Tools.BatchConvertAdjustDisplayDuration, - Action = CommandLineConverter.BatchAction.AdjustDisplayDuration, - Control = groupBoxAdjustDuration - }, - new FixActionItem - { - Text = Configuration.Settings.Language.ApplyDurationLimits.Title, - Checked = Configuration.Settings.Tools.BatchConvertApplyDurationLimits, - Action = CommandLineConverter.BatchAction.ApplyDurationLimits - }, - new FixActionItem - { - Text = l.DeleteLines, - Checked = Configuration.Settings.Tools.BatchConvertDeleteLines, - Action = CommandLineConverter.BatchAction.DeleteLines, - Control = groupBoxDeleteLines - } - - }; - foreach (var fixItem in fixItems) - { - var listViewItem = new ListViewItem { Tag = fixItem }; - listViewItem.SubItems.Add(fixItem.Text); - listViewItem.Checked = fixItem.Checked; - listViewConvertOptions.Items.Add(listViewItem); - } - - listViewConvertOptions_SelectedIndexChanged(null, null); - - if (Configuration.IsRunningOnWindows) - { - buttonSwapFrameRate.Text = "🡙"; - } - else - { - buttonSwapFrameRate.Text = "<->"; - buttonSwapFrameRate.Width = 35; - buttonSwapFrameRate.Font = new Font(Font.FontFamily, Font.Size); - } - - SetMkvLanguageMenuItem(); - } - - private void SetMkvLanguageMenuItem() - { - var styleName = Configuration.Settings.Language.BatchConvert.MkvLanguageStyleThreeLetter; - if (Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle == "2") - { - styleName = Configuration.Settings.Language.BatchConvert.MkvLanguageStyleTwoLetter; - } - else if (Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle == "0") - { - styleName = Configuration.Settings.Language.BatchConvert.MkvLanguageStyleEmpty; - } - - convertMkvSettingsToolStripMenuItem.Text = string.Format(Configuration.Settings.Language.BatchConvert.MkvLanguageInOutputFileNameX, styleName); - } - - public class FixActionItem - { - public string Text { get; set; } - public bool Checked { get; set; } - public CommandLineConverter.BatchAction Action { get; set; } - public Control Control { get; set; } - } - - - private void buttonInputBrowse_Click(object sender, EventArgs e) - { - buttonInputBrowse.Enabled = false; - openFileDialog1.Title = Configuration.Settings.Language.General.OpenSubtitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - openFileDialog1.Multiselect = true; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - try - { - Cursor = Cursors.WaitCursor; - labelStatus.Text = Configuration.Settings.Language.General.PleaseWait; - listViewInputFiles.BeginUpdate(); - foreach (string fileName in openFileDialog1.FileNames) - { - AddInputFile(fileName); - Application.DoEvents(); - } - } - finally - { - listViewInputFiles.EndUpdate(); - Cursor = Cursors.Default; - labelStatus.Text = string.Empty; - } - } - - buttonInputBrowse.Enabled = true; - } - - private void AddInputFile(string fileName) - { - if (comboBoxFilter.SelectedIndex == 4 && textBoxFilter.Text.Length > 0 && !fileName.Contains(textBoxFilter.Text, StringComparison.OrdinalIgnoreCase)) - { - return; - } - try - { - foreach (ListViewItem lvi in listViewInputFiles.Items) - { - if (lvi.Text.Equals(fileName, StringComparison.OrdinalIgnoreCase)) - { - return; - } - } - - var fi = new FileInfo(fileName); - var ext = fi.Extension.ToLowerInvariant(); - var item = new ListViewItem(fileName); - item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); - var isMkv = false; - var mkvPgs = new List(); - var mkvVobSub = new List(); - var mkvSrt = new List(); - var mkvSsa = new List(); - var mkvAss = new List(); - int mkvCount = 0; - var isTs = false; - - SubtitleFormat format = null; - var sub = new Subtitle(); - if (fi.Length < ConvertMaxFileSize) - { - if (!FileUtil.IsBluRaySup(fileName) && !FileUtil.IsVobSub(fileName) && - !((ext == ".mkv" || ext == ".mks") && FileUtil.IsMatroskaFile(fileName))) - { - format = sub.LoadSubtitle(fileName, out _, null); - - if (format == null) - { - foreach (var f in SubtitleFormat.GetBinaryFormats(true)) - { - if (f.IsMine(null, fileName)) - { - f.LoadSubtitle(sub, null, fileName); - format = f; - break; - } - } - } - - if (format == null) - { - var encoding = LanguageAutoDetect.GetEncodingFromFile(fileName); - var lines = FileUtil.ReadAllTextShared(fileName, encoding).SplitToLines(); - foreach (var f in SubtitleFormat.GetTextOtherFormats()) - { - if (f.IsMine(lines, fileName)) - { - f.LoadSubtitle(sub, lines, fileName); - format = f; - break; - } - } - } - } - } - - if (format == null) - { - if (FileUtil.IsBluRaySup(fileName)) - { - item.SubItems.Add("Blu-ray"); - } - else if (FileUtil.IsVobSub(fileName)) - { - item.SubItems.Add("VobSub"); - } - else if (ext == ".mkv" || ext == ".mks") - { - isMkv = true; - using (var matroska = new MatroskaFile(fileName)) - { - if (matroska.IsValid) - { - foreach (var track in matroska.GetTracks(true)) - { - if (track.CodecId.Equals("S_VOBSUB", StringComparison.OrdinalIgnoreCase)) - { - mkvVobSub.Add(MakeMkvTrackInfoString(track)); - } - else if (track.CodecId.Equals("S_HDMV/PGS", StringComparison.OrdinalIgnoreCase)) - { - mkvPgs.Add(MakeMkvTrackInfoString(track)); - } - else if (track.CodecId.Equals("S_TEXT/UTF8", StringComparison.OrdinalIgnoreCase)) - { - mkvSrt.Add(MakeMkvTrackInfoString(track)); - } - else if (track.CodecId.Equals("S_TEXT/SSA", StringComparison.OrdinalIgnoreCase)) - { - mkvSsa.Add(MakeMkvTrackInfoString(track)); - } - else if (track.CodecId.Equals("S_TEXT/ASS", StringComparison.OrdinalIgnoreCase)) - { - mkvAss.Add(MakeMkvTrackInfoString(track)); - } - } - } - } - if (mkvVobSub.Count + mkvPgs.Count + mkvSrt.Count + mkvSsa.Count + mkvAss.Count <= 0) - { - item.SubItems.Add(Configuration.Settings.Language.UnknownSubtitle.Title); - } - } - else if ((ext == ".ts" || ext == ".m2ts" || ext == ".mts" || ext == ".mpg" || ext == ".mpeg") && - (FileUtil.IsTransportStream(fileName) || FileUtil.IsM2TransportStream(fileName))) - { - isTs = true; - } - else - { - item.SubItems.Add(Configuration.Settings.Language.UnknownSubtitle.Title); - } - } - else - { - item.SubItems.Add(format.Name); - } - item.SubItems.Add("-"); - - if (isMkv) - { - if (mkvCount > 0) - { - listViewInputFiles.Items.Add(item); - } - - foreach (var lang in mkvPgs) - { - item = new ListViewItem(fileName); - item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); - listViewInputFiles.Items.Add(item); - item.SubItems.Add("Matroska/PGS - " + lang); - item.SubItems.Add("-"); - } - foreach (var lang in mkvVobSub) - { - item = new ListViewItem(fileName); - item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); - listViewInputFiles.Items.Add(item); - item.SubItems.Add("Matroska/VobSub - " + lang); - item.SubItems.Add("-"); - } - foreach (var lang in mkvSrt) - { - if (comboBoxFilter.SelectedIndex == 5 && textBoxFilter.Text.Length > 0 && !lang.Contains(textBoxFilter.Text, StringComparison.OrdinalIgnoreCase)) - { - continue; - } - item = new ListViewItem(fileName); - item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); - listViewInputFiles.Items.Add(item); - item.SubItems.Add("Matroska/SRT - " + lang); - item.SubItems.Add("-"); - } - foreach (var lang in mkvSsa) - { - item = new ListViewItem(fileName); - item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); - listViewInputFiles.Items.Add(item); - item.SubItems.Add("Matroska/SSA - " + lang); - item.SubItems.Add("-"); - } - foreach (var lang in mkvAss) - { - item = new ListViewItem(fileName); - item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); - listViewInputFiles.Items.Add(item); - item.SubItems.Add("Matroska/ASS - " + lang); - item.SubItems.Add("-"); - } - } - else if (isTs) - { - item = new ListViewItem(fileName); - item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); - listViewInputFiles.Items.Add(item); - item.SubItems.Add("Transport Stream"); - item.SubItems.Add("-"); - } - else - { - listViewInputFiles.Items.Add(item); - } - - if (isTs) - { - buttonTransportStreamSettings.Visible = true; - } - } - catch - { - // ignored - } - UpdateNumberOfFiles(); - } - - private static string MakeMkvTrackInfoString(MatroskaTrackInfo track) - { - return (track.Language ?? "undefined") + (track.IsForced ? " (forced)" : string.Empty) + " #" + track.TrackNumber; - } - - private string GetMkvLanguage(string languageCode) - { - if (Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle == "0") - { - return string.Empty; - } - - if (string.IsNullOrEmpty(languageCode)) - { - return "undefined."; - } - - if (Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle == "2" && - !string.IsNullOrEmpty(Iso639Dash2LanguageCode.GetTwoLetterCodeFromThreeLetterCode(languageCode))) - { - return Iso639Dash2LanguageCode.GetTwoLetterCodeFromThreeLetterCode(languageCode) + "."; - } - - return string.IsNullOrEmpty(languageCode) ? string.Empty : languageCode.TrimEnd('.') + "."; - } - - private void listViewInputFiles_DragEnter(object sender, DragEventArgs e) - { - if (_converting || _searching) - { - e.Effect = DragDropEffects.None; - return; - } - - if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) - { - e.Effect = DragDropEffects.All; - } - } - - private void listViewInputFiles_DragDrop(object sender, DragEventArgs e) - { - if (_converting || _searching) - { - return; - } - - try - { - var fileNames = (string[])e.Data.GetData(DataFormats.FileDrop); - labelStatus.Text = Configuration.Settings.Language.General.PleaseWait; - listViewInputFiles.BeginUpdate(); - foreach (string fileName in fileNames) - { - if (FileUtil.IsDirectory(fileName)) - { - SearchFolder(fileName); - } - else - { - AddInputFile(fileName); - } - } - } - finally - { - labelStatus.Text = string.Empty; - listViewInputFiles.EndUpdate(); - } - } - - private void radioButtonSpeedCustom_CheckedChanged(object sender, EventArgs e) - { - numericUpDownPercent.Enabled = true; - } - - private void radioButtonSpeedFromDropFrame_CheckedChanged(object sender, EventArgs e) - { - numericUpDownPercent.Value = Convert.ToDecimal(099.98887); - numericUpDownPercent.Enabled = false; - } - - private void radioButtonToDropFrame_CheckedChanged(object sender, EventArgs e) - { - numericUpDownPercent.Value = Convert.ToDecimal(100.1001001); - numericUpDownPercent.Enabled = false; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private TextEncoding GetCurrentEncoding(string fileName) - { - bool useEncodingFromFile = comboBoxEncoding.SelectedIndex == comboBoxEncoding.Items.Count - 1; - if (useEncodingFromFile) - { - if (string.IsNullOrEmpty(fileName) || !File.Exists(fileName)) - { - if (Configuration.Settings.General.DefaultEncoding == TextEncoding.Utf8WithoutBom) - { - return new TextEncoding(Encoding.UTF8, TextEncoding.Utf8WithoutBom); - } - return new TextEncoding(Encoding.UTF8, TextEncoding.Utf8WithBom); - } - var enc = LanguageAutoDetect.GetEncodingFromFile(fileName); - return new TextEncoding(enc, null); - } - - return UiUtil.GetTextEncodingComboBoxCurrentEncoding(comboBoxEncoding); - } - - private SubtitleFormat GetCurrentSubtitleFormat() - { - var format = Utilities.GetSubtitleFormatByFriendlyName(comboBoxSubtitleFormats.SelectedItem.ToString()); - return format ?? new SubRip(); - } - - private void buttonConvert_Click(object sender, EventArgs e) - { - if (buttonConvert.Text == Configuration.Settings.Language.General.Cancel) - { - _abort = true; - return; - } - - UpdateChangeCasingSettings(); - UpdateRtlSettings(); - UpdateActionEnabledCache(); - if (listViewInputFiles.Items.Count == 0) - { - MessageBox.Show(Configuration.Settings.Language.BatchConvert.NothingToConvert); - return; - } - if (!checkBoxOverwrite.Checked) - { - if (textBoxOutputFolder.Text.Length < 2) - { - MessageBox.Show(Configuration.Settings.Language.BatchConvert.PleaseChooseOutputFolder); - return; - } - if (!Directory.Exists(textBoxOutputFolder.Text)) - { - try - { - Directory.CreateDirectory(textBoxOutputFolder.Text); - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - return; - } - } - } - _converting = true; - progressBar1.Style = ProgressBarStyle.Blocks; - progressBar1.Maximum = listViewInputFiles.Items.Count; - progressBar1.Value = 0; - progressBar1.Visible = progressBar1.Maximum > 2; - string toFormat = comboBoxSubtitleFormats.Text; - SetControlState(false); - - _count = 0; - _converted = 0; - _errors = 0; - _abort = false; - - var worker1 = SpawnWorker(); - var worker2 = SpawnWorker(); - var worker3 = SpawnWorker(); - - listViewInputFiles.BeginUpdate(); - foreach (ListViewItem item in listViewInputFiles.Items) - { - item.SubItems[3].Text = "-"; - } - - listViewInputFiles.EndUpdate(); - var mkvFileNames = new List(); - Refresh(); - int index = 0; - while (index < listViewInputFiles.Items.Count && !_abort) - { - ListViewItem item = listViewInputFiles.Items[index]; - string fileName = item.Text; - try - { - var binaryParagraphs = new List(); - SubtitleFormat format = null; - var sub = new Subtitle(); - var fi = new FileInfo(fileName); - if (fi.Length < ConvertMaxFileSize && !FileUtil.IsBluRaySup(fileName) && !FileUtil.IsVobSub(fileName)) - { - format = sub.LoadSubtitle(fileName, out _, null); - - if (format == null) - { - foreach (var f in SubtitleFormat.GetBinaryFormats(true)) - { - if (f.IsMine(null, fileName)) - { - f.LoadSubtitle(sub, null, fileName); - format = f; - break; - } - } - } - - if (format == null) - { - var encoding = LanguageAutoDetect.GetEncodingFromFile(fileName); - var lines = FileUtil.ReadAllTextShared(fileName, encoding).SplitToLines(); - foreach (var f in SubtitleFormat.GetTextOtherFormats()) - { - if (f.IsMine(lines, fileName)) - { - f.LoadSubtitle(sub, lines, fileName); - format = f; - break; - } - } - } - - if (format == null) - { - var enc = LanguageAutoDetect.GetEncodingFromFile(fileName); - var s = File.ReadAllText(fileName, enc); - - // check for RTF file - if (fileName.EndsWith(".rtf", StringComparison.OrdinalIgnoreCase) && s.TrimStart().StartsWith("{\\rtf", StringComparison.Ordinal)) - { - using (var rtb = new RichTextBox { Rtf = s }) - { - s = rtb.Text; - } - } - var unknownFormatImporter = new UnknownFormatImporter { UseFrames = true }; - var genericParseSubtitle = unknownFormatImporter.AutoGuessImport(s.SplitToLines()); - if (genericParseSubtitle.Paragraphs.Count > 1) - { - sub = genericParseSubtitle; - format = new SubRip(); - } - } - - if (format != null && format.GetType() == typeof(MicroDvd)) - { - if (sub != null && sub.Paragraphs.Count > 0 && sub.Paragraphs[0].Duration.TotalMilliseconds < 1001) - { - if (sub.Paragraphs[0].Text.StartsWith("29.", StringComparison.Ordinal) || sub.Paragraphs[0].Text.StartsWith("23.", StringComparison.Ordinal) || - sub.Paragraphs[0].Text.StartsWith("29,", StringComparison.Ordinal) || sub.Paragraphs[0].Text.StartsWith("23,", StringComparison.Ordinal) || - sub.Paragraphs[0].Text == "24" || sub.Paragraphs[0].Text == "25" || - sub.Paragraphs[0].Text == "30" || sub.Paragraphs[0].Text == "60") - { - sub.Paragraphs.RemoveAt(0); - } - } - } - } - var bluRaySubtitles = new List(); - bool isVobSub = false; - bool isMatroska = false; - bool isTs = false; - if (format == null && fileName.EndsWith(".sup", StringComparison.OrdinalIgnoreCase) && FileUtil.IsBluRaySup(fileName)) - { - var log = new StringBuilder(); - bluRaySubtitles = BluRaySupParser.ParseBluRaySup(fileName, log); - } - else if (format == null && fileName.EndsWith(".sub", StringComparison.OrdinalIgnoreCase) && FileUtil.IsVobSub(fileName)) - { - isVobSub = true; - } - else if (format == null && (fileName.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase) || fileName.EndsWith(".mks", StringComparison.OrdinalIgnoreCase)) && item.SubItems[2].Text.StartsWith("Matroska", StringComparison.Ordinal)) - { - isMatroska = true; - } - else if (format == null && - (fileName.EndsWith(".ts", StringComparison.OrdinalIgnoreCase) || - fileName.EndsWith(".m2ts", StringComparison.OrdinalIgnoreCase) || - fileName.EndsWith(".mts", StringComparison.OrdinalIgnoreCase) || - fileName.EndsWith(".mpg", StringComparison.OrdinalIgnoreCase) || - fileName.EndsWith(".mpeg", StringComparison.OrdinalIgnoreCase)) && - item.SubItems[2].Text.StartsWith("Transport Stream", StringComparison.Ordinal)) - { - isTs = true; - } - if (format == null && bluRaySubtitles.Count == 0 && !isVobSub && !isMatroska && !isTs) - { - IncrementAndShowProgress(); - } - else - { - if (isMatroska) - { - using (var matroska = new MatroskaFile(fileName)) - { - if (matroska.IsValid) - { - var trackId = item.SubItems[2].Text; - if (trackId.Contains("#")) - { - trackId = trackId.Remove(0, trackId.IndexOf("#", StringComparison.Ordinal) + 1); - } - - foreach (var track in matroska.GetTracks(true)) - { - if (track.CodecId.Equals("S_VOBSUB", StringComparison.OrdinalIgnoreCase)) - { - if (trackId == track.TrackNumber.ToString(CultureInfo.InvariantCulture)) - { - var vobSubs = LoadVobSubFromMatroska(track, matroska, out var idx); - if (vobSubs.Count > 0) - { - item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr; - using (var vobSubOcr = new VobSubOcr()) - { - vobSubOcr.ProgressCallback = progress => - { - item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr + " " + progress; - listViewInputFiles.Refresh(); - }; - vobSubOcr.FileName = Path.GetFileName(fileName); - vobSubOcr.InitializeBatch(vobSubs, idx.Palette, Configuration.Settings.VobSubOcr, fileName, false, track.Language, null); - sub = vobSubOcr.SubtitleFromOcr; - } - } - - fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + GetMkvLanguage(track.Language).Replace("undefined.", string.Empty) + "mkv"; - if (mkvFileNames.Contains(fileName)) - { - fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + GetMkvLanguage(track.Language) + "mkv"; - } - mkvFileNames.Add(fileName); - - break; - } - } - else if (track.CodecId.Equals("S_HDMV/PGS", StringComparison.OrdinalIgnoreCase)) - { - if (trackId == track.TrackNumber.ToString(CultureInfo.InvariantCulture)) - { - bluRaySubtitles = LoadBluRaySupFromMatroska(track, matroska, Handle); - - fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + GetMkvLanguage(track.Language).Replace("undefined.", string.Empty) + "mkv"; - if (mkvFileNames.Contains(fileName)) - { - fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + GetMkvLanguage(track.Language) + "mkv"; - } - mkvFileNames.Add(fileName); - - if ((toFormat == BdnXmlSubtitle || toFormat == BluRaySubtitle || - toFormat == VobSubSubtitle || toFormat == DostImageSubtitle) && - AllowImageToImage()) - { - foreach (var b in bluRaySubtitles) - { - sub.Paragraphs.Add(new Paragraph(b.StartTimeCode, b.EndTimeCode, string.Empty)); - } - if (!_bdLookup.ContainsKey(fileName)) - { - _bdLookup.Add(fileName, bluRaySubtitles); - } - } - else - { - if (bluRaySubtitles.Count > 0) - { - item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr; - using (var vobSubOcr = new VobSubOcr()) - { - vobSubOcr.ProgressCallback = progress => - { - item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr + " " + progress; - listViewInputFiles.Refresh(); - }; - vobSubOcr.FileName = Path.GetFileName(fileName); - vobSubOcr.InitializeBatch(bluRaySubtitles, Configuration.Settings.VobSubOcr, fileName, false, track.Language); - sub = vobSubOcr.SubtitleFromOcr; - } - } - } - break; - } - } - else if (track.CodecId.Equals("S_TEXT/UTF8", StringComparison.OrdinalIgnoreCase) || track.CodecId.Equals("S_TEXT/SSA", StringComparison.OrdinalIgnoreCase) || track.CodecId.Equals("S_TEXT/ASS", StringComparison.OrdinalIgnoreCase)) - { - if (trackId == track.TrackNumber.ToString(CultureInfo.InvariantCulture)) - { - var mkvSub = matroska.GetSubtitle(track.TrackNumber, null); - Utilities.LoadMatroskaTextSubtitle(track, matroska, mkvSub, sub); - fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + GetMkvLanguage(track.Language).Replace("undefined.", string.Empty) + "mkv"; - if (mkvFileNames.Contains(fileName)) - { - fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + GetMkvLanguage(track.Language) + "mkv"; - } - mkvFileNames.Add(fileName); - break; - } - } - } - } - } - } - else if (bluRaySubtitles.Count > 0) - { - if ((toFormat == BdnXmlSubtitle || toFormat == BluRaySubtitle || - toFormat == VobSubSubtitle || toFormat == DostImageSubtitle) && - AllowImageToImage()) - { - foreach (var b in bluRaySubtitles) - { - sub.Paragraphs.Add(new Paragraph(b.StartTimeCode, b.EndTimeCode, string.Empty)); - } - } - else - { - item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr; - using (var vobSubOcr = new VobSubOcr()) - { - vobSubOcr.ProgressCallback = progress => - { - item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr + " " + progress; - listViewInputFiles.Refresh(); - }; - vobSubOcr.FileName = Path.GetFileName(fileName); - vobSubOcr.InitializeBatch(bluRaySubtitles, Configuration.Settings.VobSubOcr, fileName, false); - sub = vobSubOcr.SubtitleFromOcr; - } - } - } - else if (isVobSub) - { - item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr; - using (var vobSubOcr = new VobSubOcr()) - { - vobSubOcr.ProgressCallback = progress => - { - item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr + " " + progress; - listViewInputFiles.Refresh(); - }; - vobSubOcr.InitializeBatch(fileName, Configuration.Settings.VobSubOcr, false, null); - sub = vobSubOcr.SubtitleFromOcr; - } - } - else if (isTs) - { - int tsConvertedCount = 0; - var programMapTableParser = new ProgramMapTableParser(); - programMapTableParser.Parse(fileName); // get languages - var tsParser = new TransportStreamParser(); - tsParser.Parse(fileName, (position, total) => - { - var percent = (int)Math.Round(position * 100.0 / total); - item.SubItems[3].Text = $"Read: {percent}%"; - listViewInputFiles.Refresh(); - }); - - var outputFolder = textBoxOutputFolder.Text; - var overwrite = checkBoxOverwrite.Checked; - if (radioButtonSaveInSourceFolder.Checked) - { - outputFolder = Path.GetDirectoryName(fileName); - } - - var targetEncoding = GetCurrentEncoding(fileName); - - var targetFrameRate = 0.0; - if (double.TryParse(comboBoxFrameRateTo.Text.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var toFrameRate)) - { - targetFrameRate = toFrameRate; - } - - // images - if (!Configuration.Settings.Tools.BatchConvertTsOnlyTeletext) - { - foreach (int id in tsParser.SubtitlePacketIds) - { - void ProgressCallback(string progress) - { - item.SubItems[3].Text = progress; - listViewInputFiles.Refresh(); - } - - if (BluRaySubtitle.RemoveChar(' ').Equals(toFormat.RemoveChar(' '), StringComparison.OrdinalIgnoreCase)) - { - TsToBluRaySup.WriteTrack(fileName, outputFolder, overwrite, 0, null, ProgressCallback, null, programMapTableParser, id, tsParser); - tsConvertedCount++; - } - else if (BdnXmlSubtitle.RemoveChar(' ').Equals(toFormat.RemoveChar(' '), StringComparison.OrdinalIgnoreCase)) - { - TsToBdnXml.WriteTrack(fileName, outputFolder, overwrite, null, ProgressCallback, null, programMapTableParser, id, tsParser); - tsConvertedCount++; - } - else - { - var tsBinaryParagraphs = new List(); - var subtitle = new Subtitle(); - foreach (var transportStreamSubtitle in tsParser.GetDvbSubtitles(id)) - { - tsBinaryParagraphs.Add(transportStreamSubtitle); - subtitle.Paragraphs.Add(new Paragraph(string.Empty, transportStreamSubtitle.StartMilliseconds, transportStreamSubtitle.EndMilliseconds)); - } - - using (var vobSubOcr = new VobSubOcr()) - { - vobSubOcr.ProgressCallback = progress => - { - item.SubItems[3].Text = $"OCR: {progress}"; - listViewInputFiles.Refresh(); - }; - var language = programMapTableParser.GetSubtitleLanguage(id); - language = string.IsNullOrEmpty(language) ? null : language; - vobSubOcr.FileName = Path.GetFileName(fileName); - vobSubOcr.InitializeBatch(tsBinaryParagraphs, Configuration.Settings.VobSubOcr, fileName, false, language, null); - subtitle = vobSubOcr.SubtitleFromOcr; - } - - // apply fixes step 1 - subtitle = ApplyFixesStep1(subtitle, null); - - // apply fixes step 2 - var parameter = new ThreadDoWorkParameter( - IsActionEnabled(CommandLineConverter.BatchAction.FixCommonErrors), - IsActionEnabled(CommandLineConverter.BatchAction.MultipleReplace), - IsActionEnabled(CommandLineConverter.BatchAction.FixRtl), - IsActionEnabled(CommandLineConverter.BatchAction.SplitLongLines), - IsActionEnabled(CommandLineConverter.BatchAction.BalanceLines), - IsActionEnabled(CommandLineConverter.BatchAction.SetMinGap), - item, - subtitle, - GetCurrentSubtitleFormat(), - GetCurrentEncoding(fileName), - Configuration.Settings.Tools.BatchConvertLanguage, - fileName, - toFormat, - format, - binaryParagraphs); - ApplyFixesStep2(parameter, Configuration.Settings.Tools.BatchConvertFixRtlMode); - - var preExt = TsToBluRaySup.GetFileNameEnding(programMapTableParser, id); - int dummy = 0; - CommandLineConverter.BatchConvertSave(toFormat, TimeSpan.Zero, targetEncoding, outputFolder, 0, ref dummy, ref dummy, SubtitleFormat.AllSubtitleFormats.ToList(), fileName, parameter.Subtitle, new SubRip(), null, overwrite, 0, targetFrameRate, null, new List(), null, true, null, null, null, preExt); - tsConvertedCount++; - } - } - } - - // teletext - foreach (var program in tsParser.TeletextSubtitlesLookup) - { - foreach (var kvp in program.Value) - { - var subtitle = new Subtitle(kvp.Value); - var preExt = TsToBluRaySup.GetFileNameEnding(programMapTableParser, kvp.Key); - int dummy = 0; - - // apply fixes step 1 - subtitle = ApplyFixesStep1(subtitle, null); - - // apply fixes step 2 - var parameter = new ThreadDoWorkParameter( - IsActionEnabled(CommandLineConverter.BatchAction.FixCommonErrors), - IsActionEnabled(CommandLineConverter.BatchAction.MultipleReplace), - IsActionEnabled(CommandLineConverter.BatchAction.FixRtl), - IsActionEnabled(CommandLineConverter.BatchAction.SplitLongLines), - IsActionEnabled(CommandLineConverter.BatchAction.BalanceLines), - IsActionEnabled(CommandLineConverter.BatchAction.SetMinGap), - item, - subtitle, - GetCurrentSubtitleFormat(), - GetCurrentEncoding(fileName), - Configuration.Settings.Tools.BatchConvertLanguage, - fileName, - toFormat, - format, - binaryParagraphs); - ApplyFixesStep2(parameter, Configuration.Settings.Tools.BatchConvertFixRtlMode); - - CommandLineConverter.BatchConvertSave(toFormat, TimeSpan.Zero, targetEncoding, outputFolder, 0, ref dummy, ref dummy, SubtitleFormat.AllSubtitleFormats.ToList(), fileName, parameter.Subtitle, new SubRip(), null, overwrite, 0, targetFrameRate, null, new List(), null, true, null, null, null, preExt); - tsConvertedCount++; - } - } - - if (tsConvertedCount > 0) - { - item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Converted; - } - } - - if (comboBoxSubtitleFormats.Text == AdvancedSubStationAlpha.NameOfFormat && _assStyle != null) - { - if (!string.IsNullOrWhiteSpace(_assStyle) && !checkBoxUseStyleFromSource.Checked) - { - sub.Header = _assStyle; - } - } - else if (comboBoxSubtitleFormats.Text == SubStationAlpha.NameOfFormat && _ssaStyle != null) - { - if (!string.IsNullOrWhiteSpace(_ssaStyle) && !checkBoxUseStyleFromSource.Checked) - { - sub.Header = _ssaStyle; - } - } - - bool skip = CheckSkipFilter(fileName, format, sub); - if (skip) - { - item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.FilterSkipped; - } - else - { - sub = ApplyFixesStep1(sub, bluRaySubtitles); - - while (worker1.IsBusy && worker2.IsBusy && worker3.IsBusy) - { - Application.DoEvents(); - System.Threading.Thread.Sleep(100); - } - - var parameter = new ThreadDoWorkParameter( - IsActionEnabled(CommandLineConverter.BatchAction.FixCommonErrors), - IsActionEnabled(CommandLineConverter.BatchAction.MultipleReplace), - IsActionEnabled(CommandLineConverter.BatchAction.FixRtl), - IsActionEnabled(CommandLineConverter.BatchAction.SplitLongLines), - IsActionEnabled(CommandLineConverter.BatchAction.BalanceLines), - IsActionEnabled(CommandLineConverter.BatchAction.SetMinGap), - item, - sub, - GetCurrentSubtitleFormat(), - GetCurrentEncoding(fileName), - Configuration.Settings.Tools.BatchConvertLanguage, - fileName, - toFormat, - format, - binaryParagraphs); - - if (!worker1.IsBusy) - { - worker1.RunWorkerAsync(parameter); - } - else if (!worker2.IsBusy) - { - worker2.RunWorkerAsync(parameter); - } - else if (!worker3.IsBusy) - { - worker3.RunWorkerAsync(parameter); - } - } - } - } - catch (Exception exception) - { - System.Diagnostics.Debug.WriteLine(exception); - IncrementAndShowProgress(); - } - index++; - } - while (worker1.IsBusy || worker2.IsBusy || worker3.IsBusy) - { - try - { - Application.DoEvents(); - } - catch - { - // ignored - } - System.Threading.Thread.Sleep(100); - } - - // dispose workers - worker1.Dispose(); - worker2.Dispose(); - worker3.Dispose(); - - _converting = false; - labelStatus.Text = string.Empty; - progressBar1.Visible = false; - TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); - SetControlState(true); - _bdLookup = new Dictionary>(); - } - - private Subtitle ApplyFixesStep1(Subtitle sub, List bluRaySubtitles) - { - if (IsActionEnabled(CommandLineConverter.BatchAction.BridgeGaps)) - { - Core.Forms.DurationsBridgeGaps.BridgeGaps(sub, _bridgeGaps.MinMsBetweenLines, !_bridgeGaps.PreviousSubtitleTakesAllTime, Configuration.Settings.Tools.BridgeGapMilliseconds, null, null, false); - } - - if (IsActionEnabled(CommandLineConverter.BatchAction.ApplyDurationLimits)) - { - var fixDurationLimits = new FixDurationLimits(Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds, Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds); - sub = fixDurationLimits.Fix(sub); - } - - if (IsActionEnabled(CommandLineConverter.BatchAction.DeleteLines)) - { - DeleteLines(sub); - } - - if (IsActionEnabled(CommandLineConverter.BatchAction.RemoveStyle) && !string.IsNullOrEmpty(textBoxRemoveStyle.Text)) - { - sub.Paragraphs.RemoveAll(p => p.Extra == textBoxRemoveStyle.Text || p.Style == textBoxRemoveStyle.Text); - sub.Renumber(); - } - - if (IsActionEnabled(CommandLineConverter.BatchAction.AdjustDisplayDuration)) - { - var adjustmentType = comboBoxAdjustDurationVia.Text; - if (adjustmentType == Configuration.Settings.Language.AdjustDisplayDuration.Percent) - { - sub.AdjustDisplayTimeUsingPercent((double)numericUpDownAdjustViaPercent.Value, null); - } - else if (adjustmentType == Configuration.Settings.Language.AdjustDisplayDuration.Recalculate) - { - sub.RecalculateDisplayTimes((double)numericUpDownMaxCharsSec.Value, null, (double)numericUpDownOptimalCharsSec.Value, checkBoxExtendOnly.Checked); - } - else if (adjustmentType == Configuration.Settings.Language.AdjustDisplayDuration.Fixed) - { - sub.SetFixedDuration(null, (double)numericUpDownFixedMilliseconds.Value); - } - else - { - sub.AdjustDisplayTimeUsingSeconds((double)numericUpDownSeconds.Value, null); - } - } - - var prev = sub.GetParagraphOrDefault(0); - var first = true; - foreach (var p in sub.Paragraphs) - { - if (IsActionEnabled(CommandLineConverter.BatchAction.RemoveTextForHI)) - { - _removeTextForHearingImpaired.Settings = _removeTextForHiSettings; - p.Text = _removeTextForHearingImpaired.RemoveTextFromHearImpaired(p.Text, sub, sub.Paragraphs.IndexOf(p)); - } - - if (IsActionEnabled(CommandLineConverter.BatchAction.RemoveFormatting)) - { - p.Text = HtmlUtil.RemoveHtmlTags(p.Text, true); - } - - if (!numericUpDownPercent.Value.Equals(100) && IsActionEnabled(CommandLineConverter.BatchAction.ChangeSpeed)) - { - var toSpeedPercentage = Convert.ToDouble(numericUpDownPercent.Value) / 100.0; - p.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds * toSpeedPercentage; - p.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds * toSpeedPercentage; - - if (first) - { - first = false; - } - else - { - if (prev.EndTime.TotalMilliseconds >= p.StartTime.TotalMilliseconds) - { - prev.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds - 1; - } - } - } - - prev = p; - } - - if (bluRaySubtitles == null || bluRaySubtitles.Count == 0) - { - sub.RemoveEmptyLines(); //TODO: only for image export? - } - - if (IsActionEnabled(CommandLineConverter.BatchAction.RedoCasing)) - { - _changeCasing.FixCasing(sub, LanguageAutoDetect.AutoDetectGoogleLanguage(sub)); - _changeCasingNames.Initialize(sub); - _changeCasingNames.FixCasing(); - } - - if (IsActionEnabled(CommandLineConverter.BatchAction.MergeShortLines)) - { - var mergedShortLinesSub = MergeShortLinesUtils.MergeShortLinesInSubtitle(sub, Configuration.Settings.Tools.MergeShortLinesMaxGap, Configuration.Settings.General.SubtitleLineMaximumLength, Configuration.Settings.Tools.MergeShortLinesOnlyContinuous); - if (mergedShortLinesSub.Paragraphs.Count != sub.Paragraphs.Count) - { - sub.Paragraphs.Clear(); - sub.Paragraphs.AddRange(mergedShortLinesSub.Paragraphs); - } - } - - if (IsActionEnabled(CommandLineConverter.BatchAction.RemoveLineBreaks)) - { - foreach (var paragraph in sub.Paragraphs) - { - paragraph.Text = Utilities.UnbreakLine(paragraph.Text); - } - } - - if (IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTexts)) - { - var mergedSameTextsSub = MergeLinesSameTextUtils.MergeLinesWithSameTextInSubtitle(sub, true, 250); - if (mergedSameTextsSub.Paragraphs.Count != sub.Paragraphs.Count) - { - sub.Paragraphs.Clear(); - sub.Paragraphs.AddRange(mergedSameTextsSub.Paragraphs); - } - } - - if (IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTimeCodes)) - { - var mergedSameTimeCodesSub = MergeLinesWithSameTimeCodes.Merge(sub, new List(), out _, true, false, 1000, "en", new List(), new Dictionary(), new Subtitle()); - if (mergedSameTimeCodesSub.Paragraphs.Count != sub.Paragraphs.Count) - { - sub.Paragraphs.Clear(); - sub.Paragraphs.AddRange(mergedSameTimeCodesSub.Paragraphs); - } - } - - if (IsActionEnabled(CommandLineConverter.BatchAction.ChangeFrameRate) && - double.TryParse(comboBoxFrameRateFrom.Text.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var fromFrameRate) && - double.TryParse(comboBoxFrameRateTo.Text.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var toFrameRate)) - { - sub.ChangeFrameRate(fromFrameRate, toFrameRate); - } - - if (IsActionEnabled(CommandLineConverter.BatchAction.OffsetTimeCodes) && timeUpDownAdjust.TimeCode.TotalMilliseconds > 0.00001) - { - var totalMilliseconds = timeUpDownAdjust.TimeCode.TotalMilliseconds; - if (radioButtonShowEarlier.Checked) - { - totalMilliseconds *= -1; - } - - sub.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(totalMilliseconds)); - } - - return sub; - } - - private void DeleteLines(Subtitle sub) - { - var skipFirst = (int)numericUpDownDeleteFirst.Value; - var skipLast = (int)numericUpDownDeleteLast.Value; - var deleteContains = textBoxDeleteContains.Text; - if (skipFirst == 0 && skipLast == 0 && string.IsNullOrWhiteSpace(deleteContains)) - { - return; - } - - var paragraphs = sub.Paragraphs.Skip(skipFirst).ToList(); - paragraphs = paragraphs.Take(paragraphs.Count - skipLast).ToList(); - if (!string.IsNullOrWhiteSpace(deleteContains)) - { - paragraphs = paragraphs.Where(p => !p.Text.Contains(deleteContains)).ToList(); - } - - sub.Paragraphs.Clear(); - sub.Paragraphs.AddRange(paragraphs); - sub.Renumber(); - } - - private void UpdateChangeCasingSettings() - { - if (radioButtonNormal.Checked) - { - Configuration.Settings.Tools.ChangeCasingChoice = "Normal"; - } - else if (radioButtonFixOnlyNames.Checked) - { - Configuration.Settings.Tools.ChangeCasingChoice = "NamesOnly"; - } - else if (radioButtonUppercase.Checked) - { - Configuration.Settings.Tools.ChangeCasingChoice = "Uppercase"; - } - else if (radioButtonLowercase.Checked) - { - Configuration.Settings.Tools.ChangeCasingChoice = "Lowercase"; - } - } - - private Dictionary _actionEnabledCache; - - private void UpdateActionEnabledCache() - { - _actionEnabledCache = new Dictionary(); - foreach (ListViewItem item in listViewConvertOptions.Items) - { - var fixItem = item.Tag as FixActionItem; - _actionEnabledCache.Add(fixItem.Action, item.Checked); - } - } - - private bool IsActionEnabled(CommandLineConverter.BatchAction action) - { - if (_actionEnabledCache != null) - { - return _actionEnabledCache[action]; - } - - foreach (ListViewItem item in listViewConvertOptions.Items) - { - if (item.Tag is FixActionItem fixItem && fixItem.Action == action) - { - return item.Checked; - } - } - return false; - } - - private BackgroundWorker SpawnWorker() - { - var worker = new BackgroundWorker(); - worker.DoWork += DoThreadWork; - worker.RunWorkerCompleted += ThreadWorkerCompleted; - return worker; - } - - /// - /// Text based functions requires text, so no image to image convert - /// - /// - private bool AllowImageToImage() - { - return !IsActionEnabled(CommandLineConverter.BatchAction.BalanceLines) && - !IsActionEnabled(CommandLineConverter.BatchAction.RedoCasing) && - !IsActionEnabled(CommandLineConverter.BatchAction.FixCommonErrors) && - !IsActionEnabled(CommandLineConverter.BatchAction.FixRtl) && - !IsActionEnabled(CommandLineConverter.BatchAction.MultipleReplace) && - !IsActionEnabled(CommandLineConverter.BatchAction.RemoveFormatting) && - !IsActionEnabled(CommandLineConverter.BatchAction.SplitLongLines) && - !IsActionEnabled(CommandLineConverter.BatchAction.RemoveTextForHI) && - !IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTexts) && - !IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTimeCodes) && - !IsActionEnabled(CommandLineConverter.BatchAction.MergeShortLines) && - !IsActionEnabled(CommandLineConverter.BatchAction.RemoveLineBreaks); - } - - internal static List LoadVobSubFromMatroska(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska, out Core.VobSub.Idx idx) - { - var mergedVobSubPacks = new List(); - if (matroskaSubtitleInfo.ContentEncodingType == 1) - { - idx = null; - return mergedVobSubPacks; - } - - var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, null); - idx = new Core.VobSub.Idx(matroskaSubtitleInfo.GetCodecPrivate().SplitToLines()); - foreach (var p in sub) - { - mergedVobSubPacks.Add(new VobSubMergedPack(p.GetData(matroskaSubtitleInfo), TimeSpan.FromMilliseconds(p.Start), 32, null)); - if (mergedVobSubPacks.Count > 0) - { - mergedVobSubPacks[mergedVobSubPacks.Count - 1].EndTime = TimeSpan.FromMilliseconds(p.End); - } - - // fix overlapping (some versions of Handbrake makes overlapping time codes - thx Hawke) - if (mergedVobSubPacks.Count > 1 && mergedVobSubPacks[mergedVobSubPacks.Count - 2].EndTime > mergedVobSubPacks[mergedVobSubPacks.Count - 1].StartTime) - { - mergedVobSubPacks[mergedVobSubPacks.Count - 2].EndTime = TimeSpan.FromMilliseconds(mergedVobSubPacks[mergedVobSubPacks.Count - 1].StartTime.TotalMilliseconds - 1); - } - } - return mergedVobSubPacks; - } - - internal static List LoadBluRaySupFromMatroska(MatroskaTrackInfo track, MatroskaFile matroska, IntPtr handle) - { - if (track.ContentEncodingType == 1) - { - return new List(); - } - - var sub = matroska.GetSubtitle(track.TrackNumber, null); - TaskbarList.SetProgressState(handle, TaskbarButtonProgressFlags.NoProgress); - var subtitles = new List(); - var log = new StringBuilder(); - var clusterStream = new MemoryStream(); - var lastPalettes = new Dictionary>(); - var lastBitmapObjects = new Dictionary>(); - foreach (var p in sub) - { - byte[] buffer = p.GetData(track); - if (buffer != null && buffer.Length > 2) - { - clusterStream.Write(buffer, 0, buffer.Length); - if (ContainsBluRayStartSegment(buffer)) - { - if (subtitles.Count > 0 && subtitles[subtitles.Count - 1].StartTime == subtitles[subtitles.Count - 1].EndTime) - { - subtitles[subtitles.Count - 1].EndTime = (long)((p.Start - 1) * 90.0); - } - clusterStream.Position = 0; - var list = BluRaySupParser.ParseBluRaySup(clusterStream, log, true, lastPalettes, lastBitmapObjects); - foreach (var sup in list) - { - sup.StartTime = (long)((p.Start - 1) * 90.0); - sup.EndTime = (long)((p.End - 1) * 90.0); - subtitles.Add(sup); - - // fix overlapping - if (subtitles.Count > 1 && sub[subtitles.Count - 2].End > sub[subtitles.Count - 1].Start) - { - subtitles[subtitles.Count - 2].EndTime = subtitles[subtitles.Count - 1].StartTime - 1; - } - } - clusterStream = new MemoryStream(); - } - } - else if (subtitles.Count > 0) - { - var lastSub = subtitles[subtitles.Count - 1]; - if (lastSub.StartTime == lastSub.EndTime) - { - lastSub.EndTime = (long)((p.Start - 1) * 90.0); - if (lastSub.EndTime - lastSub.StartTime > 1000000) - { - lastSub.EndTime = lastSub.StartTime; - } - } - } - } - - clusterStream.Dispose(); - return subtitles; - } - - private static bool ContainsBluRayStartSegment(byte[] buffer) - { - const int epochStart = 0x80; - var position = 0; - while (position + 3 <= buffer.Length) - { - var segmentType = buffer[position]; - if (segmentType == epochStart) - { - return true; - } - - int length = BluRaySupParser.BigEndianInt16(buffer, position + 1) + 3; - position += length; - } - return false; - } - - private bool CheckSkipFilter(string fileName, SubtitleFormat format, Subtitle sub) - { - bool skip = false; - if (comboBoxFilter.SelectedIndex == 1) - { - if (format != null && format.GetType() == typeof(SubRip) && FileUtil.HasUtf8Bom(fileName)) - { - skip = true; - } - } - else if (comboBoxFilter.SelectedIndex == 2) - { - skip = true; - foreach (Paragraph p in sub.Paragraphs) - { - if (p.Text != null && Utilities.GetNumberOfLines(p.Text) > 2) - { - skip = false; - break; - } - } - } - else if (comboBoxFilter.SelectedIndex == 3 && !string.IsNullOrWhiteSpace(textBoxFilter.Text)) - { - skip = true; - foreach (Paragraph p in sub.Paragraphs) - { - if (p.Text != null && p.Text.Contains(textBoxFilter.Text, StringComparison.Ordinal)) - { - skip = false; - break; - } - } - } - return skip; - } - - private void IncrementAndShowProgress() - { - if (progressBar1.Value < progressBar1.Maximum) - { - progressBar1.Value++; - } - else - { - progressBar1.Value = progressBar1.Maximum; - } - progressBar1.Refresh(); - - TaskbarList.SetProgressValue(Handle, progressBar1.Value, progressBar1.Maximum); - labelStatus.Text = progressBar1.Value + " / " + progressBar1.Maximum; - if (progressBar1.Value == progressBar1.Maximum) - { - labelStatus.Text = string.Empty; - } - - Application.DoEvents(); - } - - private static void DoThreadWork(object sender, DoWorkEventArgs e) - { - var p = (ThreadDoWorkParameter)e.Argument; - var mode = Configuration.Settings.Tools.BatchConvertFixRtlMode; - - ApplyFixesStep2(p, mode); - - e.Result = p; - } - - private static void ApplyFixesStep2(ThreadDoWorkParameter p, string mode) - { - if (p.FixRtl && mode == RemoveUnicode) - { - for (int i = 0; i < p.Subtitle.Paragraphs.Count; i++) - { - var paragraph = p.Subtitle.Paragraphs[i]; - paragraph.Text = Utilities.RemoveUnicodeControlChars(paragraph.Text); - } - } - - if (p.FixCommonErrors) - { - try - { - using (var fixCommonErrors = new FixCommonErrors { BatchMode = true }) - { - var l = Configuration.Settings.Tools.BatchConvertLanguage; - if (string.IsNullOrEmpty(l)) - { - l = LanguageAutoDetect.AutoDetectGoogleLanguage(p.Subtitle); - } - - for (int i = 0; i < 3; i++) - { - fixCommonErrors.RunBatch(p.Subtitle, p.Format, p.Encoding.Encoding, l); - p.Subtitle = fixCommonErrors.FixedSubtitle; - } - } - } - catch (Exception exception) - { - p.Error = string.Format(Configuration.Settings.Language.BatchConvert.FixCommonErrorsErrorX, exception.Message); - } - } - - if (p.MultipleReplaceActive) - { - try - { - using (var form = new MultipleReplace()) - { - form.RunFromBatch(p.Subtitle); - p.Subtitle = form.FixedSubtitle; - p.Subtitle.RemoveParagraphsByIndices(form.DeleteIndices); - } - } - catch (Exception exception) - { - p.Error = string.Format(Configuration.Settings.Language.BatchConvert.MultipleReplaceErrorX, exception.Message); - } - } - - if (p.SplitLongLinesActive) - { - try - { - p.Subtitle = SplitLongLinesHelper.SplitLongLinesInSubtitle(p.Subtitle, Configuration.Settings.General.SubtitleLineMaximumLength * 2, Configuration.Settings.General.SubtitleLineMaximumLength); - } - catch (Exception exception) - { - p.Error = string.Format(Configuration.Settings.Language.BatchConvert.AutoBalanceErrorX, exception.Message); - } - } - - if (p.AutoBalanceActive) - { - try - { - var l = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(p.Subtitle); - foreach (var paragraph in p.Subtitle.Paragraphs) - { - paragraph.Text = Utilities.AutoBreakLine(paragraph.Text, l ?? p.Language); - } - } - catch (Exception exception) - { - p.Error = string.Format(Configuration.Settings.Language.BatchConvert.AutoBalanceErrorX, exception.Message); - } - } - - if (p.SetMinDisplayTimeBetweenSubtitles) - { - double minimumMillisecondsBetweenLines = Configuration.Settings.General.MinimumMillisecondsBetweenLines; - for (int i = 0; i < p.Subtitle.Paragraphs.Count - 1; i++) - { - var current = p.Subtitle.GetParagraphOrDefault(i); - var next = p.Subtitle.GetParagraphOrDefault(i + 1); - var gapsBetween = next.StartTime.TotalMilliseconds - current.EndTime.TotalMilliseconds; - if (gapsBetween < minimumMillisecondsBetweenLines && current.Duration.TotalMilliseconds > minimumMillisecondsBetweenLines) - { - current.EndTime.TotalMilliseconds -= (minimumMillisecondsBetweenLines - gapsBetween); - } - } - } - - if (p.FixRtl && mode == ReverseStartEnd) - { - for (int i = 0; i < p.Subtitle.Paragraphs.Count; i++) - { - var paragraph = p.Subtitle.Paragraphs[i]; - paragraph.Text = Utilities.ReverseStartAndEndingForRightToLeft(paragraph.Text); - } - } - else if (p.FixRtl && mode == AddUnicode) // fix with unicode char - { - for (int i = 0; i < p.Subtitle.Paragraphs.Count; i++) - { - var paragraph = p.Subtitle.Paragraphs[i]; - paragraph.Text = Utilities.FixRtlViaUnicodeChars(paragraph.Text); - } - } - - // always re-number - p.Subtitle.Renumber(); - } - - private void ThreadWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) - { - CommandLineConverter.BatchConvertProgress progressCallback = null; - var p = (ThreadDoWorkParameter)e.Result; - if (p.Item.Index + 2 < listViewInputFiles.Items.Count) - { - listViewInputFiles.EnsureVisible(p.Item.Index + 2); - } - else - { - listViewInputFiles.EnsureVisible(p.Item.Index); - } - - if (!string.IsNullOrEmpty(p.Error)) - { - p.Item.SubItems[3].Text = p.Error; - } - else - { - if (p.SourceFormat == null) - { - var ext = Path.GetExtension(p.FileName); - if (ext != null && - (ext.Equals(".ts", StringComparison.OrdinalIgnoreCase) || - ext.Equals(".m2ts", StringComparison.OrdinalIgnoreCase) || - ext.Equals(".mts", StringComparison.OrdinalIgnoreCase) || - ext.Equals(".mpg", StringComparison.OrdinalIgnoreCase) || - ext.Equals(".mpeg", StringComparison.OrdinalIgnoreCase)) && - (FileUtil.IsTransportStream(p.FileName) || FileUtil.IsM2TransportStream(p.FileName))) - { - IncrementAndShowProgress(); - return; - } - - p.SourceFormat = new SubRip(); - } - - if (p.ToFormat == Ebu.NameOfFormat) - { - p.Subtitle.Header = _ebuGeneralInformation.ToString(); - } - - var targetFormat = p.ToFormat; - if (targetFormat == Configuration.Settings.Language.ExportCustomText.Title) - { - targetFormat = "CustomText:" + _customTextTemplate; - } - - try - { - var binaryParagraphs = new List(); - if (p.FileName != null && !p.Subtitle.Paragraphs.Any(s => !string.IsNullOrEmpty(s.Text)) && - p.FileName.EndsWith(".sup", StringComparison.OrdinalIgnoreCase) && - FileUtil.IsBluRaySup(p.FileName) && AllowImageToImage()) - { - binaryParagraphs = BluRaySupParser.ParseBluRaySup(p.FileName, new StringBuilder()).Cast().ToList(); - } - else if (p.FileName != null && _bdLookup.ContainsKey(p.FileName)) - { - binaryParagraphs = _bdLookup[p.FileName].Cast().ToList(); - } - var dir = textBoxOutputFolder.Text; - var overwrite = checkBoxOverwrite.Checked; - if (radioButtonSaveInSourceFolder.Checked) - { - dir = Path.GetDirectoryName(p.FileName); - } - var success = CommandLineConverter.BatchConvertSave(targetFormat, TimeSpan.Zero, GetCurrentEncoding(p.FileName), dir, _count, ref _converted, ref _errors, _allFormats, p.FileName, p.Subtitle, p.SourceFormat, binaryParagraphs, overwrite, -1, null, null, null, null, false, progressCallback); - if (success) - { - p.Item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Converted; - } - else - { - p.Item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.NotConverted + " " + p.Item.SubItems[3].Text.Trim('-').Trim(); - } - } - catch (Exception exception) - { - p.Error = $"Save: {exception.InnerException?.Message ?? exception.Message}"; - p.Item.SubItems[3].Text = p.Error; - } - - IncrementAndShowProgress(); - } - } - - private void ComboBoxSubtitleFormatsSelectedIndexChanged(object sender, EventArgs e) - { - checkBoxUseStyleFromSource.Visible = false; - if (comboBoxSubtitleFormats.Text == AdvancedSubStationAlpha.NameOfFormat || comboBoxSubtitleFormats.Text == SubStationAlpha.NameOfFormat) - { - buttonStyles.Text = Configuration.Settings.Language.BatchConvert.Style; - buttonStyles.Visible = true; - comboBoxEncoding.Enabled = true; - buttonBrowseEncoding.Visible = true; - checkBoxUseStyleFromSource.Visible = true; - checkBoxUseStyleFromSource.Left = buttonStyles.Left + buttonStyles.Width - checkBoxUseStyleFromSource.Width; - } - else if (comboBoxSubtitleFormats.Text == Ebu.NameOfFormat) - { - buttonStyles.Text = Configuration.Settings.Language.BatchConvert.Settings; - buttonStyles.Visible = true; - if (_ebuGeneralInformation == null) - { - _ebuGeneralInformation = new Ebu.EbuGeneralSubtitleInformation(); - } - - comboBoxEncoding.Enabled = true; - buttonBrowseEncoding.Visible = true; - } - else if (comboBoxSubtitleFormats.Text == BluRaySubtitle || - comboBoxSubtitleFormats.Text == VobSubSubtitle || - comboBoxSubtitleFormats.Text == DostImageSubtitle || - comboBoxSubtitleFormats.Text == BdnXmlSubtitle || - comboBoxSubtitleFormats.Text == FcpImageSubtitle || - comboBoxSubtitleFormats.Text == Configuration.Settings.Language.ExportCustomText.Title) - { - buttonStyles.Text = Configuration.Settings.Language.BatchConvert.Settings; - buttonStyles.Visible = true; - comboBoxEncoding.Enabled = false; - buttonBrowseEncoding.Visible = false; - } - else if (comboBoxSubtitleFormats.Text == Configuration.Settings.Language.BatchConvert.PlainText) - { - buttonStyles.Text = Configuration.Settings.Language.BatchConvert.Settings; - buttonStyles.Visible = true; - comboBoxEncoding.Enabled = true; - buttonBrowseEncoding.Visible = true; - } - else - { - buttonStyles.Visible = false; - comboBoxEncoding.Enabled = true; - buttonBrowseEncoding.Visible = true; - } - } - - private void ButtonStylesClick(object sender, EventArgs e) - { - if (comboBoxSubtitleFormats.Text == AdvancedSubStationAlpha.NameOfFormat || comboBoxSubtitleFormats.Text == SubStationAlpha.NameOfFormat) - { - ShowAssSsaStyles(); - } - else if (comboBoxSubtitleFormats.Text == Ebu.NameOfFormat) - { - ShowEbuSettings(); - } - else if (comboBoxSubtitleFormats.Text == BluRaySubtitle) - { - ImageExportSettings(ExportPngXml.ExportFormats.BluraySup); - } - else if (comboBoxSubtitleFormats.Text == VobSubSubtitle) - { - ImageExportSettings(ExportPngXml.ExportFormats.VobSub); - } - else if (comboBoxSubtitleFormats.Text == DostImageSubtitle) - { - ImageExportSettings(ExportPngXml.ExportFormats.Dost); - } - else if (comboBoxSubtitleFormats.Text == BdnXmlSubtitle) - { - ImageExportSettings(ExportPngXml.ExportFormats.BdnXml); - } - else if (comboBoxSubtitleFormats.Text == FcpImageSubtitle) - { - ImageExportSettings(ExportPngXml.ExportFormats.Fcp); - } - else if (comboBoxSubtitleFormats.Text == Configuration.Settings.Language.BatchConvert.PlainText) - { - using (var form = new ExportText()) - { - var s = new Subtitle(); - s.Paragraphs.Add(new Paragraph("Test 123." + Environment.NewLine + "Test 456.", 0, 4000)); - s.Paragraphs.Add(new Paragraph("Test 789.", 5000, 9000)); - form.Initialize(s, null); - form.PrepareForBatchSettings(); - form.ShowDialog(this); - } - } - else if (comboBoxSubtitleFormats.Text == Configuration.Settings.Language.ExportCustomText.Title) - { - ShowExportCustomTextSettings(); - } - } - - private void ShowExportCustomTextSettings() - { - var s = new Subtitle(); - s.Paragraphs.Add(new Paragraph("Test 123." + Environment.NewLine + "Test 456.", 0, 4000)); - s.Paragraphs.Add(new Paragraph("Test 777." + Environment.NewLine + "Test 888.", 0, 4000)); - using (var properties = new ExportCustomText(s, null, "Test")) - { - properties.InitializeForBatchConvert(_customTextTemplate); - if (properties.ShowDialog(this) == DialogResult.OK) - { - _customTextTemplate = properties.CurrentFormatName; - } - } - } - - private void ImageExportSettings(string format) - { - using (var properties = new ExportPngXml()) - { - var s = new Subtitle(); - s.Paragraphs.Add(new Paragraph("Test 123." + Environment.NewLine + "Test 456.", 0, 4000)); - properties.Initialize(s, new SubRip(), format, null, null, null); - properties.DisableSaveButtonAndCheckBoxes(); - properties.ShowDialog(this); - } - } - - private void ShowEbuSettings() - { - using (var properties = new EbuSaveOptions()) - { - properties.Initialize(_ebuGeneralInformation, 0, null, null); - properties.ShowDialog(this); - } - } - - private void ShowAssSsaStyles() - { - SubStationAlphaStylesBatchConvert form = null; - try - { - var assa = new AdvancedSubStationAlpha(); - var sub = new Subtitle(); - if (comboBoxSubtitleFormats.Text == assa.Name) - { - if (!string.IsNullOrEmpty(_assStyle)) - { - sub.Header = _assStyle; - } - form = new SubStationAlphaStylesBatchConvert(sub, assa); - if (form.ShowDialog(this) == DialogResult.OK) - { - _assStyle = form.Header; - } - } - else - { - if (!string.IsNullOrEmpty(_ssaStyle)) - { - sub.Header = _ssaStyle; - } - var ssa = new SubStationAlpha(); - if (comboBoxSubtitleFormats.Text == ssa.Name) - { - form = new SubStationAlphaStylesBatchConvert(sub, ssa); - if (form.ShowDialog(this) == DialogResult.OK) - { - _ssaStyle = form.Header; - } - } - } - } - finally - { - form?.Dispose(); - } - } - - private void ContextMenuStripFilesOpening(object sender, CancelEventArgs e) - { - if (_converting) - { - e.Cancel = true; - return; - } - removeToolStripMenuItem.Visible = listViewInputFiles.SelectedItems.Count > 0; - openContainingFolderToolStripMenuItem.Visible = listViewInputFiles.SelectedItems.Count == 1; - removeAllToolStripMenuItem.Visible = listViewInputFiles.Items.Count > 0; - toolStripSeparator1.Visible = listViewInputFiles.Items.Count > 0; - } - - private void RemoveAllToolStripMenuItemClick(object sender, EventArgs e) - { - listViewInputFiles.Items.Clear(); - UpdateNumberOfFiles(); - UpdateTransportStreamSettings(); - } - - private void RemoveSelectedFiles() - { - if (_converting) - { - return; - } - - int first = -1; - for (int i = listViewInputFiles.SelectedIndices.Count - 1; i >= 0; i--) - { - if (first < 0) - { - first = listViewInputFiles.SelectedIndices[i]; - } - listViewInputFiles.Items.RemoveAt(listViewInputFiles.SelectedIndices[i]); - } - - // keep an item selected/focused for improved UX - if (first < listViewInputFiles.Items.Count && listViewInputFiles.Items.Count > 0) - { - listViewInputFiles.Items[first].Selected = true; - listViewInputFiles.FocusedItem = listViewInputFiles.Items[first]; - } - else if (listViewInputFiles.Items.Count > 0) - { - listViewInputFiles.Items[listViewInputFiles.Items.Count - 1].Selected = true; - listViewInputFiles.FocusedItem = listViewInputFiles.Items[listViewInputFiles.Items.Count - 1]; - } - UpdateNumberOfFiles(); - UpdateTransportStreamSettings(); - } - - private void RemoveToolStripMenuItemClick(object sender, EventArgs e) - { - RemoveSelectedFiles(); - } - - private void UpdateTransportStreamSettings() - { - bool hasTransportStream = false; - foreach (ListViewItem lvi in listViewInputFiles.Items) - { - if (lvi.SubItems[2].Text.Equals("Transport Stream", StringComparison.OrdinalIgnoreCase)) - { - hasTransportStream = true; - break; - } - } - - buttonTransportStreamSettings.Visible = hasTransportStream; - } - - private void ListViewInputFilesKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Delete) - { - RemoveSelectedFiles(); - } - else if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) - { - listViewInputFiles.SelectAll(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.D && e.Modifiers == Keys.Control) - { - listViewInputFiles.SelectFirstSelectedItemOnly(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.I && e.Modifiers == (Keys.Control | Keys.Shift)) //InverseSelection - { - listViewInputFiles.InverseSelection(); - e.SuppressKeyPress = true; - } - } - - private void BatchConvert_FormClosing(object sender, FormClosingEventArgs e) - { - if (_converting) - { - e.Cancel = true; - return; - } - if (_searching) - { - _abort = true; - } - - Configuration.Settings.Tools.BatchConvertFixCasing = IsActionEnabled(CommandLineConverter.BatchAction.RedoCasing); - Configuration.Settings.Tools.BatchConvertFixCommonErrors = IsActionEnabled(CommandLineConverter.BatchAction.FixCommonErrors); - Configuration.Settings.Tools.BatchConvertMultipleReplace = IsActionEnabled(CommandLineConverter.BatchAction.MultipleReplace); - Configuration.Settings.Tools.BatchConvertFixRtl = IsActionEnabled(CommandLineConverter.BatchAction.FixRtl); - Configuration.Settings.Tools.BatchConvertSplitLongLines = IsActionEnabled(CommandLineConverter.BatchAction.SplitLongLines); - Configuration.Settings.Tools.BatchConvertAutoBalance = IsActionEnabled(CommandLineConverter.BatchAction.BalanceLines); - Configuration.Settings.Tools.BatchConvertRemoveFormatting = IsActionEnabled(CommandLineConverter.BatchAction.RemoveFormatting); - Configuration.Settings.Tools.BatchConvertBridgeGaps = IsActionEnabled(CommandLineConverter.BatchAction.BridgeGaps); - Configuration.Settings.Tools.BatchConvertRemoveTextForHI = IsActionEnabled(CommandLineConverter.BatchAction.RemoveTextForHI); - Configuration.Settings.Tools.BatchConvertSetMinDisplayTimeBetweenSubtitles = IsActionEnabled(CommandLineConverter.BatchAction.SetMinGap); - Configuration.Settings.Tools.BatchConvertOutputFolder = textBoxOutputFolder.Text; - Configuration.Settings.Tools.BatchConvertOverwriteExisting = checkBoxOverwrite.Checked; - Configuration.Settings.Tools.BatchConvertFormat = comboBoxSubtitleFormats.SelectedItem.ToString(); - Configuration.Settings.Tools.BatchConvertAssStyles = _assStyle; - Configuration.Settings.Tools.BatchConvertSsaStyles = _ssaStyle; - Configuration.Settings.Tools.BatchConvertUseStyleFromSource = checkBoxUseStyleFromSource.Checked; - Configuration.Settings.Tools.BatchConvertExportCustomTextTemplate = _customTextTemplate; - Configuration.Settings.Tools.BatchConvertSaveInSourceFolder = radioButtonSaveInSourceFolder.Checked; - Configuration.Settings.Tools.BatchConvertMergeShortLines = IsActionEnabled(CommandLineConverter.BatchAction.MergeShortLines); - Configuration.Settings.Tools.BatchConvertRemoveLineBreaks = IsActionEnabled(CommandLineConverter.BatchAction.RemoveLineBreaks); - Configuration.Settings.Tools.BatchConvertMergeSameText = IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTexts); - Configuration.Settings.Tools.BatchConvertMergeSameTimeCodes = IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTimeCodes); - Configuration.Settings.Tools.BatchConvertChangeSpeed = IsActionEnabled(CommandLineConverter.BatchAction.ChangeSpeed); - Configuration.Settings.Tools.BatchConvertChangeFrameRate = IsActionEnabled(CommandLineConverter.BatchAction.ChangeFrameRate); - Configuration.Settings.Tools.BatchConvertOffsetTimeCodes = IsActionEnabled(CommandLineConverter.BatchAction.OffsetTimeCodes); - Configuration.Settings.Tools.BatchConvertApplyDurationLimits = IsActionEnabled(CommandLineConverter.BatchAction.ApplyDurationLimits); - Configuration.Settings.Tools.MergeShortLinesMaxGap = (int)numericUpDownMaxMillisecondsBetweenLines.Value; - Configuration.Settings.Tools.MergeShortLinesOnlyContinuous = checkBoxOnlyContinuationLines.Checked; - - UpdateRtlSettings(); - } - - private void UpdateRtlSettings() - { - if (radioButtonRemoveUnicode.Checked) - { - Configuration.Settings.Tools.BatchConvertFixRtlMode = RemoveUnicode; - } - else if (radioButtonReverseStartEnd.Checked) - { - Configuration.Settings.Tools.BatchConvertFixRtlMode = ReverseStartEnd; - } - else - { - Configuration.Settings.Tools.BatchConvertFixRtlMode = AddUnicode; - } - } - - private string _rootFolder; - private void buttonSearchFolder_Click(object sender, EventArgs e) - { - folderBrowserDialog1.ShowNewFolderButton = false; - folderBrowserDialog1.SelectedPath = _rootFolder; - if (folderBrowserDialog1.ShowDialog(this) == DialogResult.OK) - { - listViewInputFiles.BeginUpdate(); - progressBar1.Style = ProgressBarStyle.Marquee; - progressBar1.Visible = true; - SetControlState(false); - labelStatus.Text = string.Empty; - - SearchFolder(folderBrowserDialog1.SelectedPath); - _rootFolder = folderBrowserDialog1.SelectedPath; - - labelStatus.Text = string.Empty; - - SetControlState(true); - listViewInputFiles.EndUpdate(); - } - progressBar1.Value = 0; - progressBar1.Visible = false; - UpdateNumberOfFiles(); - } - - private void SetControlState(bool enabled) - { - labelStatus.Text = string.Empty; - buttonCancel.Enabled = enabled; - groupBoxOutput.Enabled = enabled; - groupBoxConvertOptions.Enabled = enabled; - buttonInputBrowse.Enabled = enabled; - buttonSearchFolder.Enabled = enabled; - checkBoxScanFolderRecursive.Enabled = enabled; - comboBoxFilter.Enabled = enabled; - - if (enabled) - { - buttonConvert.Text = Configuration.Settings.Language.BatchConvert.Convert; - } - else - { - buttonConvert.Text = Configuration.Settings.Language.General.Cancel; - } - } - - private void SearchFolder(string path) - { - _abort = false; - _searching = true; - try - { - if (checkBoxScanFolderRecursive.Checked) - { - ScanFiles(Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories)); - } - else - { - ScanFiles(Directory.EnumerateFiles(path)); - } - } - finally - { - _searching = false; - } - } - - private static readonly HashSet SearchExtBlackList = new HashSet - { - ".png", - ".jpg", - ".jpeg", - ".tif", - ".tiff", - ".gif", - ".bmp", - ".clpi", - ".mpls", - ".wav", - ".mp3", - ".avi", - ".mpeg", - ".mpg", - ".tar", - ".docx", - ".pptx", - ".xlsx", - ".odt", - ".tex", - ".pdf", - ".dll", - ".exe", - ".rar", - ".7z", - ".zip", - ".tar" - }; - - private void ScanFiles(IEnumerable fileNames) - { - foreach (string fileName in fileNames) - { - labelStatus.Text = fileName; - try - { - string ext = Path.GetExtension(fileName).ToLowerInvariant(); - if (!SearchExtBlackList.Contains(ext)) - { - labelStatus.Refresh(); - var fi = new FileInfo(fileName); - if (comboBoxFilter.SelectedIndex == 4 && textBoxFilter.Text.Length > 0 && !fileName.Contains(textBoxFilter.Text, StringComparison.OrdinalIgnoreCase)) - { - // skip - } - else if (ext == ".sub" && FileUtil.IsVobSub(fileName)) - { - AddFromSearch(fileName, fi, "VobSub"); - } - else if (ext == ".sup" && FileUtil.IsBluRaySup(fileName)) - { - AddFromSearch(fileName, fi, "Blu-ray"); - } - else if (ext == ".mkv") - { - // skip for now - } - else if (ext == ".mks") - { - // skip for now - } - else if (ext == ".mp4") - { - // skip for now - } - else - { - if (fi.Length < ConvertMaxFileSize) - { - var sub = new Subtitle(); - var enc = LanguageAutoDetect.GetEncodingFromFile(fileName, true); - var format = sub.LoadSubtitle(fileName, out _, enc, true, null, false); - if (format == null) - { - foreach (var f in SubtitleFormat.GetBinaryFormats(true)) - { - if (f.IsMine(null, fileName)) - { - f.LoadSubtitle(sub, null, fileName); - format = f; - break; - } - } - } - - if (format == null) - { - var lines = FileUtil.ReadAllTextShared(fileName, enc).SplitToLines(); - foreach (var f in SubtitleFormat.GetTextOtherFormats()) - { - if (f.IsMine(lines, fileName)) - { - f.LoadSubtitle(sub, lines, fileName); - format = f; - break; - } - } - } - - if (format != null) - { - AddFromSearch(fileName, fi, format.Name); - } - } - } - progressBar1.Refresh(); - Application.DoEvents(); - if (_abort) - { - progressBar1.Value = 0; - progressBar1.Visible = false; - return; - } - } - } - catch - { - // ignored - } - } - } - - private void AddFromSearch(string fileName, FileInfo fi, string nameOfFormat) - { - var item = new ListViewItem(fileName); - item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); - item.SubItems.Add(nameOfFormat); - item.SubItems.Add("-"); - listViewInputFiles.Items.Add(item); - UpdateNumberOfFiles(); - } - - private void BatchConvert_KeyDown(object sender, KeyEventArgs e) - { - if (_converting || _searching) - { - if (e.KeyCode == Keys.Escape) - { - _abort = true; - e.SuppressKeyPress = true; - } - } - else if (e.KeyCode == Keys.Escape) - { - Close(); - } - else if (e.KeyData == (Keys.Control | Keys.O)) // Open file/s - { - buttonInputBrowse_Click(null, EventArgs.Empty); - } - } - - private void comboBoxFilter_SelectedIndexChanged(object sender, EventArgs e) - { - textBoxFilter.Visible = comboBoxFilter.SelectedIndex == 3 || comboBoxFilter.SelectedIndex == 4 || comboBoxFilter.SelectedIndex == 5; - } - - private void buttonTransportStreamSettings_Click(object sender, EventArgs e) - { - using (var form = new BatchConvertTsSettings()) - { - form.ShowDialog(this); - } - } - - private void radioButtonSaveInSourceFolder_CheckedChanged(object sender, EventArgs e) - { - textBoxOutputFolder.Enabled = false; - buttonChooseFolder.Enabled = false; - } - - private void radioButtonSaveInOutputFolder_CheckedChanged(object sender, EventArgs e) - { - textBoxOutputFolder.Enabled = true; - buttonChooseFolder.Enabled = true; - } - - private void linkLabelOpenOutputFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - if (Directory.Exists(textBoxOutputFolder.Text)) - { - UiUtil.OpenFolder(textBoxOutputFolder.Text); - } - else - { - MessageBox.Show(string.Format(Configuration.Settings.Language.SplitSubtitle.FolderNotFoundX, textBoxOutputFolder.Text)); - } - } - - private void buttonChooseFolder_Click(object sender, EventArgs e) - { - folderBrowserDialog1.ShowNewFolderButton = true; - if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) - { - textBoxOutputFolder.Text = folderBrowserDialog1.SelectedPath; - } - } - - private void listViewConvertOptions_SelectedIndexChanged(object sender, EventArgs e) - { - groupBoxMergeShortLines.Visible = false; - groupBoxChangeFrameRate.Visible = false; - groupBoxSpeed.Visible = false; - groupBoxOffsetTimeCodes.Visible = false; - buttonConvertOptionsSettings.Visible = false; - groupBoxFixRtl.Visible = false; - groupBoxChangeCasing.Visible = false; - groupBoxRemoveStyle.Visible = false; - groupBoxAdjustDuration.Visible = false; - if (listViewConvertOptions.SelectedIndices.Count != 1) - { - return; - } - - var idx = listViewConvertOptions.SelectedIndices[0]; - var fixItem = listViewConvertOptions.Items[idx].Tag as FixActionItem; - if (fixItem?.Control != null) - { - fixItem.Control.Top = listViewConvertOptions.Top; - fixItem.Control.Visible = true; - fixItem.Control.BringToFront(); - if (fixItem.Control is GroupBox groupBox) - { - groupBox.Height = listViewConvertOptions.Height; - } - } - } - - private void ButtonOptionConvertSettings(object sender, EventArgs e) - { - if (listViewConvertOptions.SelectedIndices.Count != 1) - { - return; - } - var idx = listViewConvertOptions.SelectedIndices[0]; - var fixItem = listViewConvertOptions.Items[idx].Tag as FixActionItem; - if (fixItem.Action == CommandLineConverter.BatchAction.RemoveTextForHI) - { - using (var form = new FormRemoveTextForHearImpaired(null, new Subtitle())) - { - form.InitializeSettingsOnly(); - form.ShowDialog(this); - _removeTextForHiSettings = form.GetSettings(new Subtitle()); - } - } - else if (fixItem.Action == CommandLineConverter.BatchAction.FixCommonErrors) - { - using (var form = new FixCommonErrors { BatchMode = true }) - { - form.RunBatchSettings(new Subtitle(), GetCurrentSubtitleFormat(), GetCurrentEncoding(null), Configuration.Settings.Tools.BatchConvertLanguage); - form.ShowDialog(this); - Configuration.Settings.Tools.BatchConvertLanguage = form.Language; - } - } - else if (fixItem.Action == CommandLineConverter.BatchAction.BridgeGaps) - { - _bridgeGaps.ShowDialog(this); - } - else if (fixItem.Action == CommandLineConverter.BatchAction.MultipleReplace) - { - using (var form = new MultipleReplace()) - { - form.Initialize(new Subtitle()); - form.ShowDialog(this); - } - } - } - - private void buttonSwapFrameRate_Click(object sender, EventArgs e) - { - string oldFrameRate = comboBoxFrameRateFrom.Text; - string newFrameRate = comboBoxFrameRateTo.Text; - - comboBoxFrameRateFrom.Text = newFrameRate; - comboBoxFrameRateTo.Text = oldFrameRate; - } - - private void listViewConvertOptions_ItemChecked(object sender, ItemCheckedEventArgs e) - { - var count = listViewConvertOptions.CheckedItems.Count; - if (count > 0) - { - groupBoxConvertOptions.Text = Configuration.Settings.Language.BatchConvert.ConvertOptions + " " + count; - } - else - { - groupBoxConvertOptions.Text = Configuration.Settings.Language.BatchConvert.ConvertOptions; - } - } - - private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewConvertOptions.Items) - { - item.Checked = true; - } - } - - private void inverseSelectionToolStripMenuItem_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewConvertOptions.Items) - { - item.Checked = !item.Checked; - } - } - - private void listViewInputFiles_ColumnClick(object sender, ColumnClickEventArgs e) - { - if (_converting) - { - return; - } - - var sorter = (ListViewSorter)listViewInputFiles.ListViewItemSorter; - if (sorter == null) - { - sorter = new ListViewSorter - { - ColumnNumber = e.Column, - IsNumber = false, - IsDisplayFileSize = e.Column == columnHeaderSize.DisplayIndex - }; - listViewInputFiles.ListViewItemSorter = sorter; - } - - if (e.Column == sorter.ColumnNumber) - { - sorter.Descending = !sorter.Descending; // inverse sort direction - } - else - { - sorter.ColumnNumber = e.Column; - sorter.Descending = false; - sorter.IsNumber = false; - sorter.IsDisplayFileSize = e.Column == columnHeaderSize.DisplayIndex; - } - listViewInputFiles.Sort(); - } - - private void buttonBrowseEncoding_Click(object sender, EventArgs e) - { - openFileDialog1.Title = Configuration.Settings.Language.Main.OpenAnsiSubtitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - using (var chooseEncoding = new ChooseEncoding()) - { - chooseEncoding.Initialize(openFileDialog1.FileName); - if (chooseEncoding.ShowDialog(this) == DialogResult.OK) - { - var encoding = chooseEncoding.GetEncoding(); - for (var i = 0; i < comboBoxEncoding.Items.Count; i++) - { - var item = comboBoxEncoding.Items[i]; - if (item is TextEncoding te) - { - if (te.Encoding.WebName == encoding.WebName) - { - comboBoxEncoding.SelectedIndex = i; - break; - } - } - } - } - } - } - } - - private void UpdateNumberOfFiles() - { - if (listViewInputFiles.Items.Count > 0) - { - labelNumberOfFiles.Text = $"{listViewInputFiles.Items.Count:#,###,##0}"; - } - else - { - labelNumberOfFiles.Text = string.Empty; - } - } - - private void openContainingFolderToolStripMenuItem_Click(object sender, EventArgs e) - { - if (_converting || listViewInputFiles.SelectedIndices.Count != 1) - { - return; - } - - int idx = listViewInputFiles.SelectedIndices[0]; - var fileName = listViewInputFiles.Items[idx].Text; - UiUtil.OpenFolderFromFileName(fileName); - } - - private void convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem_Click(object sender, EventArgs e) - { - using (var form = new BatchConvertMkvEnding { LanguageCodeStyle = Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle }) - { - var result = form.ShowDialog(this); - if (result == DialogResult.OK) - { - Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle = form.LanguageCodeStyle; - SetMkvLanguageMenuItem(); - } - } - } - - private void comboBoxAdjustDurationVia_SelectedIndexChanged(object sender, EventArgs e) - { - panelAdjustDurationAddSeconds.Visible = false; - panelAdjustDurationAddPercent.Visible = false; - panelAdjustDurationFixed.Visible = false; - panelAdjustDurationRecalc.Visible = false; - - var panel = panelAdjustDurationAddSeconds; - if (comboBoxAdjustDurationVia.SelectedIndex == 1) - { - panel = panelAdjustDurationAddPercent; - } - else if (comboBoxAdjustDurationVia.SelectedIndex == 2) - { - panel = panelAdjustDurationRecalc; - } - else if (comboBoxAdjustDurationVia.SelectedIndex == 3) - { - panel = panelAdjustDurationFixed; - } - - panel.Visible = true; - panel.Left = 2; - panel.Top = labelAdjustDurationVia.Top + labelAdjustDurationVia.Height + 9; - } - - private void addFilesToolStripMenuItem_Click(object sender, EventArgs e) - { - buttonInputBrowse_Click(sender, e); - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.BluRaySup; +using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; +using Nikse.SubtitleEdit.Core.ContainerFormats.TransportStream; +using Nikse.SubtitleEdit.Core.Forms; +using Nikse.SubtitleEdit.Core.Interfaces; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Core.VobSub; +using Nikse.SubtitleEdit.Forms.Ocr; +using Nikse.SubtitleEdit.Forms.Styles; +using Nikse.SubtitleEdit.Logic; +using Nikse.SubtitleEdit.Logic.CommandLineConvert; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class BatchConvert : PositionAndSizeForm + { + private const string AddUnicode = "ADD_UNICODE"; + private const string RemoveUnicode = "REMOVE_UNICODE"; + private const string ReverseStartEnd = "REVERSE_START_END"; + + public class ThreadDoWorkParameter + { + public bool FixCommonErrors { get; set; } + public bool MultipleReplaceActive { get; set; } + public bool FixRtl { get; set; } + public bool SplitLongLinesActive { get; set; } + public bool AutoBalanceActive { get; set; } + public bool SetMinDisplayTimeBetweenSubtitles { get; set; } + public ListViewItem Item { get; set; } + public Subtitle Subtitle { get; set; } + public SubtitleFormat Format { get; set; } + public TextEncoding Encoding { get; set; } + public string Language { get; set; } + public string Error { get; set; } + public string FileName { get; set; } + public string ToFormat { get; set; } + public SubtitleFormat SourceFormat { get; set; } + public List BinaryParagraphs { get; set; } + public ThreadDoWorkParameter( + bool fixCommonErrors, + bool multipleReplace, + bool fixRtl, + bool splitLongLinesActive, + bool autoBalance, + bool setMinDisplayTimeBetweenSubtitles, + ListViewItem item, + Subtitle subtitle, + SubtitleFormat format, + TextEncoding encoding, + string language, + string fileName, + string toFormat, + SubtitleFormat sourceFormat, + List binaryParagraphs) + { + FixCommonErrors = fixCommonErrors; + MultipleReplaceActive = multipleReplace; + FixRtl = fixRtl; + SplitLongLinesActive = splitLongLinesActive; + AutoBalanceActive = autoBalance; + SetMinDisplayTimeBetweenSubtitles = setMinDisplayTimeBetweenSubtitles; + Item = item; + Subtitle = subtitle; + Format = format; + Encoding = encoding; + Language = language; + FileName = fileName; + ToFormat = toFormat; + SourceFormat = sourceFormat; + BinaryParagraphs = binaryParagraphs; + } + } + + private string _assStyle; + private string _ssaStyle; + private readonly RemoveTextForHI _removeTextForHearingImpaired; + private readonly ChangeCasing _changeCasing = new ChangeCasing(); + private readonly ChangeCasingNames _changeCasingNames = new ChangeCasingNames(); + private bool _converting; + private int _count; + private int _converted; + private int _errors; + private readonly List _allFormats; + private bool _searching; + private bool _abort; + private Ebu.EbuGeneralSubtitleInformation _ebuGeneralInformation; + public static string BluRaySubtitle => "Blu-ray sup"; + public static string VobSubSubtitle => "VobSub"; + public static string DostImageSubtitle => "Dost-image"; + public static string BdnXmlSubtitle => "BDN-XML"; + public static string FcpImageSubtitle => "FCP-image"; + private string _customTextTemplate; + private readonly DurationsBridgeGaps _bridgeGaps; + private const int ConvertMaxFileSize = 1024 * 1024 * 10; // 10 MB + private Dictionary> _bdLookup = new Dictionary>(); + RemoveTextForHISettings _removeTextForHiSettings; + + public BatchConvert(Icon icon) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Icon = (Icon)icon.Clone(); + + progressBar1.Visible = false; + labelStatus.Text = string.Empty; + var l = Configuration.Settings.Language.BatchConvert; + Text = l.Title; + groupBoxInput.Text = l.Input; + labelChooseInputFiles.Text = l.InputDescription; + groupBoxOutput.Text = l.Output; + radioButtonSaveInSourceFolder.Text = l.SaveInSourceFolder; + radioButtonSaveInOutputFolder.Text = l.SaveInOutputFolder; + checkBoxOverwrite.Text = l.OverwriteFiles; + labelOutputFormat.Text = Configuration.Settings.Language.Main.Controls.SubtitleFormat; + labelEncoding.Text = Configuration.Settings.Language.Main.Controls.FileEncoding; + buttonStyles.Text = l.Style; + checkBoxUseStyleFromSource.Text = l.UseStyleFromSource; + groupBoxConvertOptions.Text = l.ConvertOptions; + columnHeaderFName.Text = Configuration.Settings.Language.JoinSubtitles.FileName; + columnHeaderFormat.Text = Configuration.Settings.Language.Main.Controls.SubtitleFormat; + columnHeaderSize.Text = Configuration.Settings.Language.General.Size; + columnHeaderStatus.Text = l.Status; + linkLabelOpenOutputFolder.Text = Configuration.Settings.Language.Main.Menu.File.Open; + buttonSearchFolder.Text = l.ScanFolder; + buttonConvert.Text = l.Convert; + buttonCancel.Text = Configuration.Settings.Language.General.Ok; + checkBoxScanFolderRecursive.Text = l.Recursive; + checkBoxScanFolderRecursive.Left = buttonSearchFolder.Left - checkBoxScanFolderRecursive.Width - 5; + buttonTransportStreamSettings.Text = l.TransportStreamSettingsButton; + groupBoxChangeFrameRate.Text = Configuration.Settings.Language.ChangeFrameRate.Title; + groupBoxOffsetTimeCodes.Text = l.OffsetTimeCodes; + groupBoxSpeed.Text = Configuration.Settings.Language.ChangeSpeedInPercent.TitleShort; + labelFromFrameRate.Text = Configuration.Settings.Language.ChangeFrameRate.FromFrameRate; + labelToFrameRate.Text = Configuration.Settings.Language.ChangeFrameRate.ToFrameRate; + labelHourMinSecMilliSecond.Text = Configuration.Settings.General.UseTimeFormatHHMMSSFF ? Configuration.Settings.Language.General.HourMinutesSecondsFrames : Configuration.Settings.Language.General.HourMinutesSecondsMilliseconds; + openContainingFolderToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.File.OpenContainingFolder; + removeToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.Remove; + removeAllToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.RemoveAll; + groupBoxRemoveStyle.Text = l.RemoveStyleActor; + labelStyleName.Text = $"{Configuration.Settings.Language.General.Style}/{Configuration.Settings.Language.General.Actor}"; + labelDeleteFirstLines.Text = l.DeleteFirstLines; + labelDeleteLastLines.Text = l.DeleteLastLines; + labelDeleteLinesContaining.Text = l.DeleteContaining; + numericUpDownDeleteFirst.Left = labelDeleteFirstLines.Left + labelDeleteFirstLines.Width + 5; + numericUpDownDeleteLast.Left = labelDeleteLastLines.Left + labelDeleteLastLines.Width + 5; + groupBoxAdjustDuration.Text = Configuration.Settings.Language.AdjustDisplayDuration.Title; + + comboBoxFrameRateFrom.Left = labelFromFrameRate.Left + labelFromFrameRate.Width + 3; + comboBoxFrameRateTo.Left = labelToFrameRate.Left + labelToFrameRate.Width + 3; + if (comboBoxFrameRateFrom.Left > comboBoxFrameRateTo.Left) + { + comboBoxFrameRateTo.Left = comboBoxFrameRateFrom.Left; + } + else + { + comboBoxFrameRateFrom.Left = comboBoxFrameRateTo.Left; + } + + buttonSwapFrameRate.Left = comboBoxFrameRateFrom.Left + comboBoxFrameRateFrom.Width + 10; + buttonSwapFrameRate.Top = comboBoxFrameRateFrom.Top + ((comboBoxFrameRateTo.Top + comboBoxFrameRateTo.Height - comboBoxFrameRateFrom.Top) / 2) - (buttonSwapFrameRate.Height / 2) + 1; + + comboBoxSubtitleFormats.Left = labelOutputFormat.Left + labelOutputFormat.Width + 3; + comboBoxEncoding.Left = labelEncoding.Left + labelEncoding.Width + 3; + if (comboBoxSubtitleFormats.Left > comboBoxEncoding.Left) + { + comboBoxEncoding.Left = comboBoxSubtitleFormats.Left; + } + else + { + comboBoxSubtitleFormats.Left = comboBoxEncoding.Left; + } + buttonBrowseEncoding.Left = comboBoxEncoding.Left + comboBoxEncoding.Width + 5; + buttonStyles.Left = comboBoxSubtitleFormats.Left + comboBoxSubtitleFormats.Width + 5; + buttonTransportStreamSettings.Left = buttonStyles.Left; + + timeUpDownAdjust.MaskedTextBox.Text = "000000000"; + + comboBoxFrameRateFrom.Items.Add(23.976); + comboBoxFrameRateFrom.Items.Add(24.0); + comboBoxFrameRateFrom.Items.Add(25.0); + comboBoxFrameRateFrom.Items.Add(29.97); + comboBoxFrameRateFrom.Items.Add(30.0); + + comboBoxFrameRateTo.Items.Add(23.976); + comboBoxFrameRateTo.Items.Add(24.0); + comboBoxFrameRateTo.Items.Add(25.0); + comboBoxFrameRateTo.Items.Add(29.97); + comboBoxFrameRateTo.Items.Add(30.0); + + UiUtil.FixLargeFonts(this, buttonCancel); + + _allFormats = new List { new Pac() }; + var formatNames = new List(); + foreach (var format in SubtitleFormat.AllSubtitleFormats) + { + if (!format.IsVobSubIndexFile) + { + formatNames.Add(format.Name); + _allFormats.Add(format); + } + } + formatNames.Add("PAC"); + formatNames.Add(new Ayato().Name); + formatNames.Add(l.PlainText); + formatNames.Add(BluRaySubtitle); + formatNames.Add(VobSubSubtitle); + formatNames.Add(DostImageSubtitle); + formatNames.Add(BdnXmlSubtitle); + formatNames.Add(FcpImageSubtitle); + formatNames.Add(Configuration.Settings.Language.ExportCustomText.Title); + UiUtil.InitializeSubtitleFormatComboBox(comboBoxSubtitleFormats, formatNames, Configuration.Settings.Tools.BatchConvertFormat); + + UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding); + comboBoxEncoding.Items.Add(new TextEncoding(Encoding.UTF8, l.TryToUseSourceEncoding)); + + if (string.IsNullOrEmpty(Configuration.Settings.Tools.BatchConvertOutputFolder) || !Directory.Exists(Configuration.Settings.Tools.BatchConvertOutputFolder)) + { + textBoxOutputFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + } + else + { + textBoxOutputFolder.Text = Configuration.Settings.Tools.BatchConvertOutputFolder; + } + + checkBoxOverwrite.Checked = Configuration.Settings.Tools.BatchConvertOverwriteExisting; + buttonConvertOptionsSettings.Text = l.Settings; + radioButtonShowEarlier.Text = Configuration.Settings.Language.ShowEarlierLater.ShowEarlier.RemoveChar('&'); + radioButtonShowLater.Text = Configuration.Settings.Language.ShowEarlierLater.ShowLater.RemoveChar('&'); + radioButtonSpeedCustom.Text = Configuration.Settings.Language.ChangeSpeedInPercent.Custom; + radioButtonSpeedFromDropFrame.Text = Configuration.Settings.Language.ChangeSpeedInPercent.FromDropFrame; + radioButtonToDropFrame.Text = Configuration.Settings.Language.ChangeSpeedInPercent.ToDropFrame; + if (Configuration.Settings.Tools.BatchConvertSaveInSourceFolder) + { + radioButtonSaveInSourceFolder.Checked = true; + } + else + { + radioButtonSaveInOutputFolder.Checked = true; + } + + groupBoxChangeCasing.Text = Configuration.Settings.Language.ChangeCasing.ChangeCasingTo; + radioButtonNormal.Text = Configuration.Settings.Language.ChangeCasing.NormalCasing; + radioButtonFixOnlyNames.Text = Configuration.Settings.Language.ChangeCasing.FixOnlyNamesCasing; + radioButtonUppercase.Text = Configuration.Settings.Language.ChangeCasing.AllUppercase; + radioButtonLowercase.Text = Configuration.Settings.Language.ChangeCasing.AllLowercase; + if (Configuration.Settings.Tools.ChangeCasingChoice == "NamesOnly") + { + radioButtonFixOnlyNames.Checked = true; + } + else if (Configuration.Settings.Tools.ChangeCasingChoice == "Uppercase") + { + radioButtonUppercase.Checked = true; + } + else if (Configuration.Settings.Tools.ChangeCasingChoice == "Lowercase") + { + radioButtonLowercase.Checked = true; + } + + _removeTextForHearingImpaired = new RemoveTextForHI(new RemoveTextForHISettings(new Subtitle())); + _removeTextForHiSettings = _removeTextForHearingImpaired.Settings; + + labelFilter.Text = l.Filter; + comboBoxFilter.Items[0] = Configuration.Settings.Language.General.AllFiles; + comboBoxFilter.Items[1] = l.FilterSrtNoUtf8BOM; + comboBoxFilter.Items[2] = l.FilterMoreThanTwoLines; + comboBoxFilter.Items[3] = l.FilterContains; + comboBoxFilter.Items[4] = l.FilterFileNameContains; + comboBoxFilter.Items[5] = l.MkvLanguageCodeContains; + comboBoxFilter.SelectedIndex = 0; + comboBoxFilter.Left = labelFilter.Left + labelFilter.Width + 4; + textBoxFilter.Left = comboBoxFilter.Left + comboBoxFilter.Width + 4; + + _assStyle = Configuration.Settings.Tools.BatchConvertAssStyles; + _ssaStyle = Configuration.Settings.Tools.BatchConvertSsaStyles; + checkBoxUseStyleFromSource.Checked = Configuration.Settings.Tools.BatchConvertUseStyleFromSource; + _customTextTemplate = Configuration.Settings.Tools.BatchConvertExportCustomTextTemplate; + + comboBoxSubtitleFormats.AutoCompleteSource = AutoCompleteSource.ListItems; + comboBoxSubtitleFormats.AutoCompleteMode = AutoCompleteMode.Append; + + _bridgeGaps = new DurationsBridgeGaps(null); + _bridgeGaps.InitializeSettingsOnly(); + buttonTransportStreamSettings.Visible = false; + + groupBoxFixRtl.Text = Configuration.Settings.Language.BatchConvert.Settings; + radioButtonAddUnicode.Text = Configuration.Settings.Language.BatchConvert.FixRtlAddUnicode; + radioButtonRemoveUnicode.Text = Configuration.Settings.Language.BatchConvert.FixRtlRemoveUnicode; + radioButtonReverseStartEnd.Text = Configuration.Settings.Language.BatchConvert.FixRtlReverseStartEnd; + + + labelAdjustDurationVia.Text = Configuration.Settings.Language.AdjustDisplayDuration.AdjustVia; + comboBoxAdjustDurationVia.Left = labelAdjustDurationVia.Left + labelAdjustDurationVia.Width + 5; + comboBoxAdjustDurationVia.Items.Clear(); + comboBoxAdjustDurationVia.Items.Add(Configuration.Settings.Language.AdjustDisplayDuration.AddSeconds); + comboBoxAdjustDurationVia.Items.Add(Configuration.Settings.Language.AdjustDisplayDuration.Percent); + comboBoxAdjustDurationVia.Items.Add(Configuration.Settings.Language.AdjustDisplayDuration.Recalculate); + comboBoxAdjustDurationVia.Items.Add(Configuration.Settings.Language.AdjustDisplayDuration.Fixed); + switch (Configuration.Settings.Tools.AdjustDurationLast) + { + case AdjustDisplayDuration.Sec: + comboBoxAdjustDurationVia.SelectedIndex = 0; + break; + case AdjustDisplayDuration.Per: + comboBoxAdjustDurationVia.SelectedIndex = 1; + break; + case AdjustDisplayDuration.Recal: + comboBoxAdjustDurationVia.SelectedIndex = 2; + break; + case AdjustDisplayDuration.Fixed: + comboBoxAdjustDurationVia.SelectedIndex = 3; + break; + default: + comboBoxAdjustDurationVia.SelectedIndex = 0; + break; + } + decimal adjustSeconds = Configuration.Settings.Tools.AdjustDurationSeconds; + if (adjustSeconds >= numericUpDownSeconds.Minimum && adjustSeconds <= numericUpDownSeconds.Maximum) + { + numericUpDownSeconds.Value = adjustSeconds; + } + + int adjustPercent = Configuration.Settings.Tools.AdjustDurationPercent; + if (adjustPercent >= numericUpDownAdjustViaPercent.Minimum && adjustPercent <= numericUpDownAdjustViaPercent.Maximum) + { + numericUpDownAdjustViaPercent.Value = adjustPercent; + } + + numericUpDownOptimalCharsSec.Value = (decimal)Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds; + numericUpDownMaxCharsSec.Value = (decimal)Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds; + checkBoxExtendOnly.Checked = Configuration.Settings.Tools.AdjustDurationExtendOnly; + + labelOptimalCharsSec.Text = Configuration.Settings.Language.Settings.OptimalCharactersPerSecond; + labelMaxCharsPerSecond.Text = Configuration.Settings.Language.Settings.MaximumCharactersPerSecond; + labelAddSeconds.Text = Configuration.Settings.Language.AdjustDisplayDuration.AddSeconds; + labelMillisecondsFixed.Text = Configuration.Settings.Language.AdjustDisplayDuration.Milliseconds; + checkBoxExtendOnly.Text = Configuration.Settings.Language.AdjustDisplayDuration.ExtendOnly; + labelAdjustViaPercent.Text = Configuration.Settings.Language.AdjustDisplayDuration.SetAsPercent; + + + + var mode = Configuration.Settings.Tools.BatchConvertFixRtlMode; + if (mode == RemoveUnicode) + { + radioButtonRemoveUnicode.Checked = true; + } + else if (mode == ReverseStartEnd) + { + radioButtonReverseStartEnd.Checked = true; + } + else // fix with unicode char + { + radioButtonAddUnicode.Checked = true; + } + + groupBoxMergeShortLines.Text = Configuration.Settings.Language.MergedShortLines.Title; + labelMaxCharacters.Text = Configuration.Settings.Language.MergedShortLines.MaximumCharacters; + labelMaxMillisecondsBetweenLines.Text = Configuration.Settings.Language.MergedShortLines.MaximumMillisecondsBetween; + checkBoxOnlyContinuationLines.Text = Configuration.Settings.Language.MergedShortLines.OnlyMergeContinuationLines; + if (Configuration.Settings.General.SubtitleLineMaximumLength > numericUpDownMaxCharacters.Maximum) + { + numericUpDownMaxCharacters.Value = numericUpDownMaxCharacters.Maximum; + } + else if (Configuration.Settings.General.SubtitleLineMaximumLength < numericUpDownMaxCharacters.Minimum) + { + numericUpDownMaxCharacters.Value = numericUpDownMaxCharacters.Minimum; + } + else + { + numericUpDownMaxCharacters.Value = Configuration.Settings.General.SubtitleLineMaximumLength; + } + numericUpDownMaxMillisecondsBetweenLines.Value = Configuration.Settings.Tools.MergeShortLinesMaxGap; + checkBoxOnlyContinuationLines.Checked = Configuration.Settings.Tools.MergeShortLinesOnlyContinuous; + + inverseSelectionToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; + toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; + UpdateNumberOfFiles(); + + var fixItems = new List + { + new FixActionItem + { + Text = l.RemoveFormatting, + Checked = Configuration.Settings.Tools.BatchConvertRemoveFormatting, + Action = CommandLineConverter.BatchAction.RemoveFormatting + }, + new FixActionItem + { + Text = l.RemoveStyleActor, + Checked = Configuration.Settings.Tools.BatchConvertRemoveStyle, + Action = CommandLineConverter.BatchAction.RemoveStyle, + Control = groupBoxRemoveStyle + }, + new FixActionItem + { + Text = l.RedoCasing, + Checked = Configuration.Settings.Tools.BatchConvertFixCasing, + Action = CommandLineConverter.BatchAction.RedoCasing, + Control = groupBoxChangeCasing + }, + new FixActionItem + { + Text = l.RemoveTextForHI, + Checked = Configuration.Settings.Tools.BatchConvertRemoveTextForHI, + Action = CommandLineConverter.BatchAction.RemoveTextForHI, + Control = buttonConvertOptionsSettings + }, + new FixActionItem + { + Text = l.BridgeGaps, + Checked = Configuration.Settings.Tools.BatchConvertBridgeGaps, + Action = CommandLineConverter.BatchAction.BridgeGaps, + Control = buttonConvertOptionsSettings + }, + new FixActionItem + { + Text = Configuration.Settings.Language.FixCommonErrors.Title, + Checked = Configuration.Settings.Tools.BatchConvertFixCommonErrors, + Action = CommandLineConverter.BatchAction.FixCommonErrors, + Control = buttonConvertOptionsSettings + }, + new FixActionItem + { + Text = Configuration.Settings.Language.MultipleReplace.Title, + Checked = Configuration.Settings.Tools.BatchConvertMultipleReplace, + Action = CommandLineConverter.BatchAction.MultipleReplace, + Control = buttonConvertOptionsSettings + }, + new FixActionItem + { + Text = l.FixRtl, + Checked = Configuration.Settings.Tools.BatchConvertFixRtl, + Action = CommandLineConverter.BatchAction.FixRtl, + Control = groupBoxFixRtl + }, + new FixActionItem + { + Text = l.SplitLongLines, + Checked = Configuration.Settings.Tools.BatchConvertSplitLongLines, + Action = CommandLineConverter.BatchAction.SplitLongLines + }, + new FixActionItem + { + Text = l.AutoBalance, + Checked = Configuration.Settings.Tools.BatchConvertAutoBalance, + Action = CommandLineConverter.BatchAction.BalanceLines + }, + new FixActionItem + { + Text = Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.Title, + Checked = Configuration.Settings.Tools.BatchConvertSetMinDisplayTimeBetweenSubtitles, + Action = CommandLineConverter.BatchAction.SetMinGap + }, + new FixActionItem + { + Text = Configuration.Settings.Language.MergedShortLines.Title, + Checked = Configuration.Settings.Tools.BatchConvertMergeShortLines, + Action = CommandLineConverter.BatchAction.MergeShortLines, + Control = groupBoxMergeShortLines + }, + new FixActionItem + { + Text = Configuration.Settings.Language.BatchConvert.RemoveLineBreaks, + Checked = Configuration.Settings.Tools.BatchConvertRemoveLineBreaks, + Action = CommandLineConverter.BatchAction.RemoveLineBreaks + }, + new FixActionItem + { + Text = Configuration.Settings.Language.MergeDoubleLines.Title, + Checked = Configuration.Settings.Tools.BatchConvertMergeSameText, + Action = CommandLineConverter.BatchAction.MergeSameTexts + }, + new FixActionItem + { + Text = Configuration.Settings.Language.MergeTextWithSameTimeCodes.Title, + Checked = Configuration.Settings.Tools.BatchConvertMergeSameTimeCodes, + Action = CommandLineConverter.BatchAction.MergeSameTimeCodes + }, + new FixActionItem + { + Text = Configuration.Settings.Language.ChangeFrameRate.Title, + Checked = Configuration.Settings.Tools.BatchConvertChangeFrameRate, + Action = CommandLineConverter.BatchAction.ChangeFrameRate, + Control = groupBoxChangeFrameRate + }, + new FixActionItem + { + Text = l.OffsetTimeCodes, + Checked = Configuration.Settings.Tools.BatchConvertOffsetTimeCodes, + Action = CommandLineConverter.BatchAction.OffsetTimeCodes, + Control = groupBoxOffsetTimeCodes + }, + new FixActionItem + { + Text = Configuration.Settings.Language.ChangeSpeedInPercent.TitleShort, + Checked = Configuration.Settings.Tools.BatchConvertChangeSpeed, + Action = CommandLineConverter.BatchAction.ChangeSpeed, + Control = groupBoxSpeed + }, + new FixActionItem + { + Text = Configuration.Settings.Language.AdjustDisplayDuration.Title, + Checked = Configuration.Settings.Tools.BatchConvertAdjustDisplayDuration, + Action = CommandLineConverter.BatchAction.AdjustDisplayDuration, + Control = groupBoxAdjustDuration + }, + new FixActionItem + { + Text = Configuration.Settings.Language.ApplyDurationLimits.Title, + Checked = Configuration.Settings.Tools.BatchConvertApplyDurationLimits, + Action = CommandLineConverter.BatchAction.ApplyDurationLimits + }, + new FixActionItem + { + Text = l.DeleteLines, + Checked = Configuration.Settings.Tools.BatchConvertDeleteLines, + Action = CommandLineConverter.BatchAction.DeleteLines, + Control = groupBoxDeleteLines + } + + }; + foreach (var fixItem in fixItems) + { + var listViewItem = new ListViewItem { Tag = fixItem }; + listViewItem.SubItems.Add(fixItem.Text); + listViewItem.Checked = fixItem.Checked; + listViewConvertOptions.Items.Add(listViewItem); + } + + listViewConvertOptions_SelectedIndexChanged(null, null); + + if (Configuration.IsRunningOnWindows) + { + buttonSwapFrameRate.Text = "🡙"; + } + else + { + buttonSwapFrameRate.Text = "<->"; + buttonSwapFrameRate.Width = 35; + buttonSwapFrameRate.Font = new Font(Font.FontFamily, Font.Size); + } + + SetMkvLanguageMenuItem(); + } + + private void SetMkvLanguageMenuItem() + { + var styleName = Configuration.Settings.Language.BatchConvert.MkvLanguageStyleThreeLetter; + if (Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle == "2") + { + styleName = Configuration.Settings.Language.BatchConvert.MkvLanguageStyleTwoLetter; + } + else if (Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle == "0") + { + styleName = Configuration.Settings.Language.BatchConvert.MkvLanguageStyleEmpty; + } + + convertMkvSettingsToolStripMenuItem.Text = string.Format(Configuration.Settings.Language.BatchConvert.MkvLanguageInOutputFileNameX, styleName); + } + + public class FixActionItem + { + public string Text { get; set; } + public bool Checked { get; set; } + public CommandLineConverter.BatchAction Action { get; set; } + public Control Control { get; set; } + } + + + private void buttonInputBrowse_Click(object sender, EventArgs e) + { + buttonInputBrowse.Enabled = false; + openFileDialog1.Title = Configuration.Settings.Language.General.OpenSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + openFileDialog1.Multiselect = true; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + try + { + Cursor = Cursors.WaitCursor; + labelStatus.Text = Configuration.Settings.Language.General.PleaseWait; + listViewInputFiles.BeginUpdate(); + foreach (string fileName in openFileDialog1.FileNames) + { + AddInputFile(fileName); + Application.DoEvents(); + } + } + finally + { + listViewInputFiles.EndUpdate(); + Cursor = Cursors.Default; + labelStatus.Text = string.Empty; + } + } + + buttonInputBrowse.Enabled = true; + } + + private void AddInputFile(string fileName) + { + if (comboBoxFilter.SelectedIndex == 4 && textBoxFilter.Text.Length > 0 && !fileName.Contains(textBoxFilter.Text, StringComparison.OrdinalIgnoreCase)) + { + return; + } + try + { + foreach (ListViewItem lvi in listViewInputFiles.Items) + { + if (lvi.Text.Equals(fileName, StringComparison.OrdinalIgnoreCase)) + { + return; + } + } + + var fi = new FileInfo(fileName); + var ext = fi.Extension.ToLowerInvariant(); + var item = new ListViewItem(fileName); + item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); + var isMkv = false; + var mkvPgs = new List(); + var mkvVobSub = new List(); + var mkvSrt = new List(); + var mkvSsa = new List(); + var mkvAss = new List(); + int mkvCount = 0; + var isTs = false; + + SubtitleFormat format = null; + var sub = new Subtitle(); + if (fi.Length < ConvertMaxFileSize) + { + if (!FileUtil.IsBluRaySup(fileName) && !FileUtil.IsVobSub(fileName) && + !((ext == ".mkv" || ext == ".mks") && FileUtil.IsMatroskaFile(fileName))) + { + format = sub.LoadSubtitle(fileName, out _, null); + + if (format == null) + { + foreach (var f in SubtitleFormat.GetBinaryFormats(true)) + { + if (f.IsMine(null, fileName)) + { + f.LoadSubtitle(sub, null, fileName); + format = f; + break; + } + } + } + + if (format == null) + { + var encoding = LanguageAutoDetect.GetEncodingFromFile(fileName); + var lines = FileUtil.ReadAllTextShared(fileName, encoding).SplitToLines(); + foreach (var f in SubtitleFormat.GetTextOtherFormats()) + { + if (f.IsMine(lines, fileName)) + { + f.LoadSubtitle(sub, lines, fileName); + format = f; + break; + } + } + } + } + } + + if (format == null) + { + if (FileUtil.IsBluRaySup(fileName)) + { + item.SubItems.Add("Blu-ray"); + } + else if (FileUtil.IsVobSub(fileName)) + { + item.SubItems.Add("VobSub"); + } + else if (ext == ".mkv" || ext == ".mks") + { + isMkv = true; + using (var matroska = new MatroskaFile(fileName)) + { + if (matroska.IsValid) + { + foreach (var track in matroska.GetTracks(true)) + { + if (track.CodecId.Equals("S_VOBSUB", StringComparison.OrdinalIgnoreCase)) + { + mkvVobSub.Add(MakeMkvTrackInfoString(track)); + } + else if (track.CodecId.Equals("S_HDMV/PGS", StringComparison.OrdinalIgnoreCase)) + { + mkvPgs.Add(MakeMkvTrackInfoString(track)); + } + else if (track.CodecId.Equals("S_TEXT/UTF8", StringComparison.OrdinalIgnoreCase)) + { + mkvSrt.Add(MakeMkvTrackInfoString(track)); + } + else if (track.CodecId.Equals("S_TEXT/SSA", StringComparison.OrdinalIgnoreCase)) + { + mkvSsa.Add(MakeMkvTrackInfoString(track)); + } + else if (track.CodecId.Equals("S_TEXT/ASS", StringComparison.OrdinalIgnoreCase)) + { + mkvAss.Add(MakeMkvTrackInfoString(track)); + } + } + } + } + if (mkvVobSub.Count + mkvPgs.Count + mkvSrt.Count + mkvSsa.Count + mkvAss.Count <= 0) + { + item.SubItems.Add(Configuration.Settings.Language.UnknownSubtitle.Title); + } + } + else if ((ext == ".ts" || ext == ".m2ts" || ext == ".mts" || ext == ".mpg" || ext == ".mpeg") && + (FileUtil.IsTransportStream(fileName) || FileUtil.IsM2TransportStream(fileName))) + { + isTs = true; + } + else + { + item.SubItems.Add(Configuration.Settings.Language.UnknownSubtitle.Title); + } + } + else + { + item.SubItems.Add(format.Name); + } + item.SubItems.Add("-"); + + if (isMkv) + { + if (mkvCount > 0) + { + listViewInputFiles.Items.Add(item); + } + + foreach (var lang in mkvPgs) + { + item = new ListViewItem(fileName); + item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); + listViewInputFiles.Items.Add(item); + item.SubItems.Add("Matroska/PGS - " + lang); + item.SubItems.Add("-"); + } + foreach (var lang in mkvVobSub) + { + item = new ListViewItem(fileName); + item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); + listViewInputFiles.Items.Add(item); + item.SubItems.Add("Matroska/VobSub - " + lang); + item.SubItems.Add("-"); + } + foreach (var lang in mkvSrt) + { + if (comboBoxFilter.SelectedIndex == 5 && textBoxFilter.Text.Length > 0 && !lang.Contains(textBoxFilter.Text, StringComparison.OrdinalIgnoreCase)) + { + continue; + } + item = new ListViewItem(fileName); + item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); + listViewInputFiles.Items.Add(item); + item.SubItems.Add("Matroska/SRT - " + lang); + item.SubItems.Add("-"); + } + foreach (var lang in mkvSsa) + { + item = new ListViewItem(fileName); + item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); + listViewInputFiles.Items.Add(item); + item.SubItems.Add("Matroska/SSA - " + lang); + item.SubItems.Add("-"); + } + foreach (var lang in mkvAss) + { + item = new ListViewItem(fileName); + item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); + listViewInputFiles.Items.Add(item); + item.SubItems.Add("Matroska/ASS - " + lang); + item.SubItems.Add("-"); + } + } + else if (isTs) + { + item = new ListViewItem(fileName); + item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); + listViewInputFiles.Items.Add(item); + item.SubItems.Add("Transport Stream"); + item.SubItems.Add("-"); + } + else + { + listViewInputFiles.Items.Add(item); + } + + if (isTs) + { + buttonTransportStreamSettings.Visible = true; + } + } + catch + { + // ignored + } + UpdateNumberOfFiles(); + } + + private static string MakeMkvTrackInfoString(MatroskaTrackInfo track) + { + return (track.Language ?? "undefined") + (track.IsForced ? " (forced)" : string.Empty) + " #" + track.TrackNumber; + } + + private string GetMkvLanguage(string languageCode) + { + if (Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle == "0") + { + return string.Empty; + } + + if (string.IsNullOrEmpty(languageCode)) + { + return "undefined."; + } + + if (Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle == "2" && + !string.IsNullOrEmpty(Iso639Dash2LanguageCode.GetTwoLetterCodeFromThreeLetterCode(languageCode))) + { + return Iso639Dash2LanguageCode.GetTwoLetterCodeFromThreeLetterCode(languageCode) + "."; + } + + return string.IsNullOrEmpty(languageCode) ? string.Empty : languageCode.TrimEnd('.') + "."; + } + + private void listViewInputFiles_DragEnter(object sender, DragEventArgs e) + { + if (_converting || _searching) + { + e.Effect = DragDropEffects.None; + return; + } + + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.All; + } + } + + private void listViewInputFiles_DragDrop(object sender, DragEventArgs e) + { + if (_converting || _searching) + { + return; + } + + try + { + var fileNames = (string[])e.Data.GetData(DataFormats.FileDrop); + labelStatus.Text = Configuration.Settings.Language.General.PleaseWait; + listViewInputFiles.BeginUpdate(); + foreach (string fileName in fileNames) + { + if (FileUtil.IsDirectory(fileName)) + { + SearchFolder(fileName); + } + else + { + AddInputFile(fileName); + } + } + } + finally + { + labelStatus.Text = string.Empty; + listViewInputFiles.EndUpdate(); + } + } + + private void radioButtonSpeedCustom_CheckedChanged(object sender, EventArgs e) + { + numericUpDownPercent.Enabled = true; + } + + private void radioButtonSpeedFromDropFrame_CheckedChanged(object sender, EventArgs e) + { + numericUpDownPercent.Value = Convert.ToDecimal(099.98887); + numericUpDownPercent.Enabled = false; + } + + private void radioButtonToDropFrame_CheckedChanged(object sender, EventArgs e) + { + numericUpDownPercent.Value = Convert.ToDecimal(100.1001001); + numericUpDownPercent.Enabled = false; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private TextEncoding GetCurrentEncoding(string fileName) + { + bool useEncodingFromFile = comboBoxEncoding.SelectedIndex == comboBoxEncoding.Items.Count - 1; + if (useEncodingFromFile) + { + if (string.IsNullOrEmpty(fileName) || !File.Exists(fileName)) + { + if (Configuration.Settings.General.DefaultEncoding == TextEncoding.Utf8WithoutBom) + { + return new TextEncoding(Encoding.UTF8, TextEncoding.Utf8WithoutBom); + } + return new TextEncoding(Encoding.UTF8, TextEncoding.Utf8WithBom); + } + var enc = LanguageAutoDetect.GetEncodingFromFile(fileName); + return new TextEncoding(enc, null); + } + + return UiUtil.GetTextEncodingComboBoxCurrentEncoding(comboBoxEncoding); + } + + private SubtitleFormat GetCurrentSubtitleFormat() + { + var format = Utilities.GetSubtitleFormatByFriendlyName(comboBoxSubtitleFormats.SelectedItem.ToString()); + return format ?? new SubRip(); + } + + private void buttonConvert_Click(object sender, EventArgs e) + { + if (buttonConvert.Text == Configuration.Settings.Language.General.Cancel) + { + _abort = true; + return; + } + + UpdateChangeCasingSettings(); + UpdateRtlSettings(); + UpdateActionEnabledCache(); + if (listViewInputFiles.Items.Count == 0) + { + MessageBox.Show(Configuration.Settings.Language.BatchConvert.NothingToConvert); + return; + } + if (!checkBoxOverwrite.Checked) + { + if (textBoxOutputFolder.Text.Length < 2) + { + MessageBox.Show(Configuration.Settings.Language.BatchConvert.PleaseChooseOutputFolder); + return; + } + if (!Directory.Exists(textBoxOutputFolder.Text)) + { + try + { + Directory.CreateDirectory(textBoxOutputFolder.Text); + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + return; + } + } + } + _converting = true; + progressBar1.Style = ProgressBarStyle.Blocks; + progressBar1.Maximum = listViewInputFiles.Items.Count; + progressBar1.Value = 0; + progressBar1.Visible = progressBar1.Maximum > 2; + string toFormat = comboBoxSubtitleFormats.Text; + SetControlState(false); + + _count = 0; + _converted = 0; + _errors = 0; + _abort = false; + + var worker1 = SpawnWorker(); + var worker2 = SpawnWorker(); + var worker3 = SpawnWorker(); + + listViewInputFiles.BeginUpdate(); + foreach (ListViewItem item in listViewInputFiles.Items) + { + item.SubItems[3].Text = "-"; + } + + listViewInputFiles.EndUpdate(); + var mkvFileNames = new List(); + Refresh(); + int index = 0; + while (index < listViewInputFiles.Items.Count && !_abort) + { + ListViewItem item = listViewInputFiles.Items[index]; + string fileName = item.Text; + try + { + var binaryParagraphs = new List(); + SubtitleFormat format = null; + var sub = new Subtitle(); + var fi = new FileInfo(fileName); + if (fi.Length < ConvertMaxFileSize && !FileUtil.IsBluRaySup(fileName) && !FileUtil.IsVobSub(fileName)) + { + format = sub.LoadSubtitle(fileName, out _, null); + + if (format == null) + { + foreach (var f in SubtitleFormat.GetBinaryFormats(true)) + { + if (f.IsMine(null, fileName)) + { + f.LoadSubtitle(sub, null, fileName); + format = f; + break; + } + } + } + + if (format == null) + { + var encoding = LanguageAutoDetect.GetEncodingFromFile(fileName); + var lines = FileUtil.ReadAllTextShared(fileName, encoding).SplitToLines(); + foreach (var f in SubtitleFormat.GetTextOtherFormats()) + { + if (f.IsMine(lines, fileName)) + { + f.LoadSubtitle(sub, lines, fileName); + format = f; + break; + } + } + } + + if (format == null) + { + var enc = LanguageAutoDetect.GetEncodingFromFile(fileName); + var s = File.ReadAllText(fileName, enc); + + // check for RTF file + if (fileName.EndsWith(".rtf", StringComparison.OrdinalIgnoreCase) && s.TrimStart().StartsWith("{\\rtf", StringComparison.Ordinal)) + { + using (var rtb = new RichTextBox { Rtf = s }) + { + s = rtb.Text; + } + } + var unknownFormatImporter = new UnknownFormatImporter { UseFrames = true }; + var genericParseSubtitle = unknownFormatImporter.AutoGuessImport(s.SplitToLines()); + if (genericParseSubtitle.Paragraphs.Count > 1) + { + sub = genericParseSubtitle; + format = new SubRip(); + } + } + + if (format != null && format.GetType() == typeof(MicroDvd)) + { + if (sub != null && sub.Paragraphs.Count > 0 && sub.Paragraphs[0].Duration.TotalMilliseconds < 1001) + { + if (sub.Paragraphs[0].Text.StartsWith("29.", StringComparison.Ordinal) || sub.Paragraphs[0].Text.StartsWith("23.", StringComparison.Ordinal) || + sub.Paragraphs[0].Text.StartsWith("29,", StringComparison.Ordinal) || sub.Paragraphs[0].Text.StartsWith("23,", StringComparison.Ordinal) || + sub.Paragraphs[0].Text == "24" || sub.Paragraphs[0].Text == "25" || + sub.Paragraphs[0].Text == "30" || sub.Paragraphs[0].Text == "60") + { + sub.Paragraphs.RemoveAt(0); + } + } + } + } + var bluRaySubtitles = new List(); + bool isVobSub = false; + bool isMatroska = false; + bool isTs = false; + if (format == null && fileName.EndsWith(".sup", StringComparison.OrdinalIgnoreCase) && FileUtil.IsBluRaySup(fileName)) + { + var log = new StringBuilder(); + bluRaySubtitles = BluRaySupParser.ParseBluRaySup(fileName, log); + } + else if (format == null && fileName.EndsWith(".sub", StringComparison.OrdinalIgnoreCase) && FileUtil.IsVobSub(fileName)) + { + isVobSub = true; + } + else if (format == null && (fileName.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase) || fileName.EndsWith(".mks", StringComparison.OrdinalIgnoreCase)) && item.SubItems[2].Text.StartsWith("Matroska", StringComparison.Ordinal)) + { + isMatroska = true; + } + else if (format == null && + (fileName.EndsWith(".ts", StringComparison.OrdinalIgnoreCase) || + fileName.EndsWith(".m2ts", StringComparison.OrdinalIgnoreCase) || + fileName.EndsWith(".mts", StringComparison.OrdinalIgnoreCase) || + fileName.EndsWith(".mpg", StringComparison.OrdinalIgnoreCase) || + fileName.EndsWith(".mpeg", StringComparison.OrdinalIgnoreCase)) && + item.SubItems[2].Text.StartsWith("Transport Stream", StringComparison.Ordinal)) + { + isTs = true; + } + if (format == null && bluRaySubtitles.Count == 0 && !isVobSub && !isMatroska && !isTs) + { + IncrementAndShowProgress(); + } + else + { + if (isMatroska) + { + using (var matroska = new MatroskaFile(fileName)) + { + if (matroska.IsValid) + { + var trackId = item.SubItems[2].Text; + if (trackId.Contains("#")) + { + trackId = trackId.Remove(0, trackId.IndexOf("#", StringComparison.Ordinal) + 1); + } + + foreach (var track in matroska.GetTracks(true)) + { + if (track.CodecId.Equals("S_VOBSUB", StringComparison.OrdinalIgnoreCase)) + { + if (trackId == track.TrackNumber.ToString(CultureInfo.InvariantCulture)) + { + var vobSubs = LoadVobSubFromMatroska(track, matroska, out var idx); + if (vobSubs.Count > 0) + { + item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr; + using (var vobSubOcr = new VobSubOcr()) + { + vobSubOcr.ProgressCallback = progress => + { + item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr + " " + progress; + listViewInputFiles.Refresh(); + }; + vobSubOcr.FileName = Path.GetFileName(fileName); + vobSubOcr.InitializeBatch(vobSubs, idx.Palette, Configuration.Settings.VobSubOcr, fileName, false, track.Language, null); + sub = vobSubOcr.SubtitleFromOcr; + } + } + + fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + GetMkvLanguage(track.Language).Replace("undefined.", string.Empty) + "mkv"; + if (mkvFileNames.Contains(fileName)) + { + fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + GetMkvLanguage(track.Language) + "mkv"; + } + mkvFileNames.Add(fileName); + + break; + } + } + else if (track.CodecId.Equals("S_HDMV/PGS", StringComparison.OrdinalIgnoreCase)) + { + if (trackId == track.TrackNumber.ToString(CultureInfo.InvariantCulture)) + { + bluRaySubtitles = LoadBluRaySupFromMatroska(track, matroska, Handle); + + fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + GetMkvLanguage(track.Language).Replace("undefined.", string.Empty) + "mkv"; + if (mkvFileNames.Contains(fileName)) + { + fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + GetMkvLanguage(track.Language) + "mkv"; + } + mkvFileNames.Add(fileName); + + if ((toFormat == BdnXmlSubtitle || toFormat == BluRaySubtitle || + toFormat == VobSubSubtitle || toFormat == DostImageSubtitle) && + AllowImageToImage()) + { + foreach (var b in bluRaySubtitles) + { + sub.Paragraphs.Add(new Paragraph(b.StartTimeCode, b.EndTimeCode, string.Empty)); + } + if (!_bdLookup.ContainsKey(fileName)) + { + _bdLookup.Add(fileName, bluRaySubtitles); + } + } + else + { + if (bluRaySubtitles.Count > 0) + { + item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr; + using (var vobSubOcr = new VobSubOcr()) + { + vobSubOcr.ProgressCallback = progress => + { + item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr + " " + progress; + listViewInputFiles.Refresh(); + }; + vobSubOcr.FileName = Path.GetFileName(fileName); + vobSubOcr.InitializeBatch(bluRaySubtitles, Configuration.Settings.VobSubOcr, fileName, false, track.Language); + sub = vobSubOcr.SubtitleFromOcr; + } + } + } + break; + } + } + else if (track.CodecId.Equals("S_TEXT/UTF8", StringComparison.OrdinalIgnoreCase) || track.CodecId.Equals("S_TEXT/SSA", StringComparison.OrdinalIgnoreCase) || track.CodecId.Equals("S_TEXT/ASS", StringComparison.OrdinalIgnoreCase)) + { + if (trackId == track.TrackNumber.ToString(CultureInfo.InvariantCulture)) + { + var mkvSub = matroska.GetSubtitle(track.TrackNumber, null); + Utilities.LoadMatroskaTextSubtitle(track, matroska, mkvSub, sub); + fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + "." + GetMkvLanguage(track.Language).Replace("undefined.", string.Empty) + "mkv"; + if (mkvFileNames.Contains(fileName)) + { + fileName = fileName.Substring(0, fileName.LastIndexOf('.')) + ".#" + trackId + "." + GetMkvLanguage(track.Language) + "mkv"; + } + mkvFileNames.Add(fileName); + break; + } + } + } + } + } + } + else if (bluRaySubtitles.Count > 0) + { + if ((toFormat == BdnXmlSubtitle || toFormat == BluRaySubtitle || + toFormat == VobSubSubtitle || toFormat == DostImageSubtitle) && + AllowImageToImage()) + { + foreach (var b in bluRaySubtitles) + { + sub.Paragraphs.Add(new Paragraph(b.StartTimeCode, b.EndTimeCode, string.Empty)); + } + } + else + { + item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr; + using (var vobSubOcr = new VobSubOcr()) + { + vobSubOcr.ProgressCallback = progress => + { + item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr + " " + progress; + listViewInputFiles.Refresh(); + }; + vobSubOcr.FileName = Path.GetFileName(fileName); + vobSubOcr.InitializeBatch(bluRaySubtitles, Configuration.Settings.VobSubOcr, fileName, false); + sub = vobSubOcr.SubtitleFromOcr; + } + } + } + else if (isVobSub) + { + item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr; + using (var vobSubOcr = new VobSubOcr()) + { + vobSubOcr.ProgressCallback = progress => + { + item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Ocr + " " + progress; + listViewInputFiles.Refresh(); + }; + vobSubOcr.InitializeBatch(fileName, Configuration.Settings.VobSubOcr, false, null); + sub = vobSubOcr.SubtitleFromOcr; + } + } + else if (isTs) + { + int tsConvertedCount = 0; + var programMapTableParser = new ProgramMapTableParser(); + programMapTableParser.Parse(fileName); // get languages + var tsParser = new TransportStreamParser(); + tsParser.Parse(fileName, (position, total) => + { + var percent = (int)Math.Round(position * 100.0 / total); + item.SubItems[3].Text = $"Read: {percent}%"; + listViewInputFiles.Refresh(); + }); + + var outputFolder = textBoxOutputFolder.Text; + var overwrite = checkBoxOverwrite.Checked; + if (radioButtonSaveInSourceFolder.Checked) + { + outputFolder = Path.GetDirectoryName(fileName); + } + + var targetEncoding = GetCurrentEncoding(fileName); + + var targetFrameRate = 0.0; + if (double.TryParse(comboBoxFrameRateTo.Text.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var toFrameRate)) + { + targetFrameRate = toFrameRate; + } + + // images + if (!Configuration.Settings.Tools.BatchConvertTsOnlyTeletext) + { + foreach (int id in tsParser.SubtitlePacketIds) + { + void ProgressCallback(string progress) + { + item.SubItems[3].Text = progress; + listViewInputFiles.Refresh(); + } + + if (BluRaySubtitle.RemoveChar(' ').Equals(toFormat.RemoveChar(' '), StringComparison.OrdinalIgnoreCase)) + { + TsToBluRaySup.WriteTrack(fileName, outputFolder, overwrite, 0, null, ProgressCallback, null, programMapTableParser, id, tsParser); + tsConvertedCount++; + } + else if (BdnXmlSubtitle.RemoveChar(' ').Equals(toFormat.RemoveChar(' '), StringComparison.OrdinalIgnoreCase)) + { + TsToBdnXml.WriteTrack(fileName, outputFolder, overwrite, null, ProgressCallback, null, programMapTableParser, id, tsParser); + tsConvertedCount++; + } + else + { + var tsBinaryParagraphs = new List(); + var subtitle = new Subtitle(); + foreach (var transportStreamSubtitle in tsParser.GetDvbSubtitles(id)) + { + tsBinaryParagraphs.Add(transportStreamSubtitle); + subtitle.Paragraphs.Add(new Paragraph(string.Empty, transportStreamSubtitle.StartMilliseconds, transportStreamSubtitle.EndMilliseconds)); + } + + using (var vobSubOcr = new VobSubOcr()) + { + vobSubOcr.ProgressCallback = progress => + { + item.SubItems[3].Text = $"OCR: {progress}"; + listViewInputFiles.Refresh(); + }; + var language = programMapTableParser.GetSubtitleLanguage(id); + language = string.IsNullOrEmpty(language) ? null : language; + vobSubOcr.FileName = Path.GetFileName(fileName); + vobSubOcr.InitializeBatch(tsBinaryParagraphs, Configuration.Settings.VobSubOcr, fileName, false, language, null); + subtitle = vobSubOcr.SubtitleFromOcr; + } + + // apply fixes step 1 + subtitle = ApplyFixesStep1(subtitle, null); + + // apply fixes step 2 + var parameter = new ThreadDoWorkParameter( + IsActionEnabled(CommandLineConverter.BatchAction.FixCommonErrors), + IsActionEnabled(CommandLineConverter.BatchAction.MultipleReplace), + IsActionEnabled(CommandLineConverter.BatchAction.FixRtl), + IsActionEnabled(CommandLineConverter.BatchAction.SplitLongLines), + IsActionEnabled(CommandLineConverter.BatchAction.BalanceLines), + IsActionEnabled(CommandLineConverter.BatchAction.SetMinGap), + item, + subtitle, + GetCurrentSubtitleFormat(), + GetCurrentEncoding(fileName), + Configuration.Settings.Tools.BatchConvertLanguage, + fileName, + toFormat, + format, + binaryParagraphs); + ApplyFixesStep2(parameter, Configuration.Settings.Tools.BatchConvertFixRtlMode); + + var preExt = TsToBluRaySup.GetFileNameEnding(programMapTableParser, id); + int dummy = 0; + CommandLineConverter.BatchConvertSave(toFormat, TimeSpan.Zero, targetEncoding, outputFolder, 0, ref dummy, ref dummy, SubtitleFormat.AllSubtitleFormats.ToList(), fileName, parameter.Subtitle, new SubRip(), null, overwrite, 0, targetFrameRate, null, new List(), null, true, null, null, null, preExt); + tsConvertedCount++; + } + } + } + + // teletext + foreach (var program in tsParser.TeletextSubtitlesLookup) + { + foreach (var kvp in program.Value) + { + var subtitle = new Subtitle(kvp.Value); + var preExt = TsToBluRaySup.GetFileNameEnding(programMapTableParser, kvp.Key); + int dummy = 0; + + // apply fixes step 1 + subtitle = ApplyFixesStep1(subtitle, null); + + // apply fixes step 2 + var parameter = new ThreadDoWorkParameter( + IsActionEnabled(CommandLineConverter.BatchAction.FixCommonErrors), + IsActionEnabled(CommandLineConverter.BatchAction.MultipleReplace), + IsActionEnabled(CommandLineConverter.BatchAction.FixRtl), + IsActionEnabled(CommandLineConverter.BatchAction.SplitLongLines), + IsActionEnabled(CommandLineConverter.BatchAction.BalanceLines), + IsActionEnabled(CommandLineConverter.BatchAction.SetMinGap), + item, + subtitle, + GetCurrentSubtitleFormat(), + GetCurrentEncoding(fileName), + Configuration.Settings.Tools.BatchConvertLanguage, + fileName, + toFormat, + format, + binaryParagraphs); + ApplyFixesStep2(parameter, Configuration.Settings.Tools.BatchConvertFixRtlMode); + + CommandLineConverter.BatchConvertSave(toFormat, TimeSpan.Zero, targetEncoding, outputFolder, 0, ref dummy, ref dummy, SubtitleFormat.AllSubtitleFormats.ToList(), fileName, parameter.Subtitle, new SubRip(), null, overwrite, 0, targetFrameRate, null, new List(), null, true, null, null, null, preExt); + tsConvertedCount++; + } + } + + if (tsConvertedCount > 0) + { + item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Converted; + } + } + + if (comboBoxSubtitleFormats.Text == AdvancedSubStationAlpha.NameOfFormat && _assStyle != null) + { + if (!string.IsNullOrWhiteSpace(_assStyle) && !checkBoxUseStyleFromSource.Checked) + { + sub.Header = _assStyle; + } + } + else if (comboBoxSubtitleFormats.Text == SubStationAlpha.NameOfFormat && _ssaStyle != null) + { + if (!string.IsNullOrWhiteSpace(_ssaStyle) && !checkBoxUseStyleFromSource.Checked) + { + sub.Header = _ssaStyle; + } + } + + bool skip = CheckSkipFilter(fileName, format, sub); + if (skip) + { + item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.FilterSkipped; + } + else + { + sub = ApplyFixesStep1(sub, bluRaySubtitles); + + while (worker1.IsBusy && worker2.IsBusy && worker3.IsBusy) + { + Application.DoEvents(); + System.Threading.Thread.Sleep(100); + } + + var parameter = new ThreadDoWorkParameter( + IsActionEnabled(CommandLineConverter.BatchAction.FixCommonErrors), + IsActionEnabled(CommandLineConverter.BatchAction.MultipleReplace), + IsActionEnabled(CommandLineConverter.BatchAction.FixRtl), + IsActionEnabled(CommandLineConverter.BatchAction.SplitLongLines), + IsActionEnabled(CommandLineConverter.BatchAction.BalanceLines), + IsActionEnabled(CommandLineConverter.BatchAction.SetMinGap), + item, + sub, + GetCurrentSubtitleFormat(), + GetCurrentEncoding(fileName), + Configuration.Settings.Tools.BatchConvertLanguage, + fileName, + toFormat, + format, + binaryParagraphs); + + if (!worker1.IsBusy) + { + worker1.RunWorkerAsync(parameter); + } + else if (!worker2.IsBusy) + { + worker2.RunWorkerAsync(parameter); + } + else if (!worker3.IsBusy) + { + worker3.RunWorkerAsync(parameter); + } + } + } + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception); + IncrementAndShowProgress(); + } + index++; + } + while (worker1.IsBusy || worker2.IsBusy || worker3.IsBusy) + { + try + { + Application.DoEvents(); + } + catch + { + // ignored + } + System.Threading.Thread.Sleep(100); + } + + // dispose workers + worker1.Dispose(); + worker2.Dispose(); + worker3.Dispose(); + + _converting = false; + labelStatus.Text = string.Empty; + progressBar1.Visible = false; + TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); + SetControlState(true); + _bdLookup = new Dictionary>(); + } + + private Subtitle ApplyFixesStep1(Subtitle sub, List bluRaySubtitles) + { + if (IsActionEnabled(CommandLineConverter.BatchAction.BridgeGaps)) + { + Core.Forms.DurationsBridgeGaps.BridgeGaps(sub, _bridgeGaps.MinMsBetweenLines, !_bridgeGaps.PreviousSubtitleTakesAllTime, Configuration.Settings.Tools.BridgeGapMilliseconds, null, null, false); + } + + if (IsActionEnabled(CommandLineConverter.BatchAction.ApplyDurationLimits)) + { + var fixDurationLimits = new FixDurationLimits(Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds, Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds); + sub = fixDurationLimits.Fix(sub); + } + + if (IsActionEnabled(CommandLineConverter.BatchAction.DeleteLines)) + { + DeleteLines(sub); + } + + if (IsActionEnabled(CommandLineConverter.BatchAction.RemoveStyle) && !string.IsNullOrEmpty(textBoxRemoveStyle.Text)) + { + sub.Paragraphs.RemoveAll(p => p.Extra == textBoxRemoveStyle.Text || p.Style == textBoxRemoveStyle.Text); + sub.Renumber(); + } + + if (IsActionEnabled(CommandLineConverter.BatchAction.AdjustDisplayDuration)) + { + var adjustmentType = comboBoxAdjustDurationVia.Text; + if (adjustmentType == Configuration.Settings.Language.AdjustDisplayDuration.Percent) + { + sub.AdjustDisplayTimeUsingPercent((double)numericUpDownAdjustViaPercent.Value, null); + } + else if (adjustmentType == Configuration.Settings.Language.AdjustDisplayDuration.Recalculate) + { + sub.RecalculateDisplayTimes((double)numericUpDownMaxCharsSec.Value, null, (double)numericUpDownOptimalCharsSec.Value, checkBoxExtendOnly.Checked); + } + else if (adjustmentType == Configuration.Settings.Language.AdjustDisplayDuration.Fixed) + { + sub.SetFixedDuration(null, (double)numericUpDownFixedMilliseconds.Value); + } + else + { + sub.AdjustDisplayTimeUsingSeconds((double)numericUpDownSeconds.Value, null); + } + } + + var prev = sub.GetParagraphOrDefault(0); + var first = true; + foreach (var p in sub.Paragraphs) + { + if (IsActionEnabled(CommandLineConverter.BatchAction.RemoveTextForHI)) + { + _removeTextForHearingImpaired.Settings = _removeTextForHiSettings; + p.Text = _removeTextForHearingImpaired.RemoveTextFromHearImpaired(p.Text, sub, sub.Paragraphs.IndexOf(p)); + } + + if (IsActionEnabled(CommandLineConverter.BatchAction.RemoveFormatting)) + { + p.Text = HtmlUtil.RemoveHtmlTags(p.Text, true); + } + + if (!numericUpDownPercent.Value.Equals(100) && IsActionEnabled(CommandLineConverter.BatchAction.ChangeSpeed)) + { + var toSpeedPercentage = Convert.ToDouble(numericUpDownPercent.Value) / 100.0; + p.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds * toSpeedPercentage; + p.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds * toSpeedPercentage; + + if (first) + { + first = false; + } + else + { + if (prev.EndTime.TotalMilliseconds >= p.StartTime.TotalMilliseconds) + { + prev.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds - 1; + } + } + } + + prev = p; + } + + if (bluRaySubtitles == null || bluRaySubtitles.Count == 0) + { + sub.RemoveEmptyLines(); //TODO: only for image export? + } + + if (IsActionEnabled(CommandLineConverter.BatchAction.RedoCasing)) + { + _changeCasing.FixCasing(sub, LanguageAutoDetect.AutoDetectGoogleLanguage(sub)); + _changeCasingNames.Initialize(sub); + _changeCasingNames.FixCasing(); + } + + if (IsActionEnabled(CommandLineConverter.BatchAction.MergeShortLines)) + { + var mergedShortLinesSub = MergeShortLinesUtils.MergeShortLinesInSubtitle(sub, Configuration.Settings.Tools.MergeShortLinesMaxGap, Configuration.Settings.General.SubtitleLineMaximumLength, Configuration.Settings.Tools.MergeShortLinesOnlyContinuous); + if (mergedShortLinesSub.Paragraphs.Count != sub.Paragraphs.Count) + { + sub.Paragraphs.Clear(); + sub.Paragraphs.AddRange(mergedShortLinesSub.Paragraphs); + } + } + + if (IsActionEnabled(CommandLineConverter.BatchAction.RemoveLineBreaks)) + { + foreach (var paragraph in sub.Paragraphs) + { + paragraph.Text = Utilities.UnbreakLine(paragraph.Text); + } + } + + if (IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTexts)) + { + var mergedSameTextsSub = MergeLinesSameTextUtils.MergeLinesWithSameTextInSubtitle(sub, true, 250); + if (mergedSameTextsSub.Paragraphs.Count != sub.Paragraphs.Count) + { + sub.Paragraphs.Clear(); + sub.Paragraphs.AddRange(mergedSameTextsSub.Paragraphs); + } + } + + if (IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTimeCodes)) + { + var mergedSameTimeCodesSub = MergeLinesWithSameTimeCodes.Merge(sub, new List(), out _, true, false, 1000, "en", new List(), new Dictionary(), new Subtitle()); + if (mergedSameTimeCodesSub.Paragraphs.Count != sub.Paragraphs.Count) + { + sub.Paragraphs.Clear(); + sub.Paragraphs.AddRange(mergedSameTimeCodesSub.Paragraphs); + } + } + + if (IsActionEnabled(CommandLineConverter.BatchAction.ChangeFrameRate) && + double.TryParse(comboBoxFrameRateFrom.Text.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var fromFrameRate) && + double.TryParse(comboBoxFrameRateTo.Text.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var toFrameRate)) + { + sub.ChangeFrameRate(fromFrameRate, toFrameRate); + } + + if (IsActionEnabled(CommandLineConverter.BatchAction.OffsetTimeCodes) && timeUpDownAdjust.TimeCode.TotalMilliseconds > 0.00001) + { + var totalMilliseconds = timeUpDownAdjust.TimeCode.TotalMilliseconds; + if (radioButtonShowEarlier.Checked) + { + totalMilliseconds *= -1; + } + + sub.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(totalMilliseconds)); + } + + return sub; + } + + private void DeleteLines(Subtitle sub) + { + var skipFirst = (int)numericUpDownDeleteFirst.Value; + var skipLast = (int)numericUpDownDeleteLast.Value; + var deleteContains = textBoxDeleteContains.Text; + if (skipFirst == 0 && skipLast == 0 && string.IsNullOrWhiteSpace(deleteContains)) + { + return; + } + + var paragraphs = sub.Paragraphs.Skip(skipFirst).ToList(); + paragraphs = paragraphs.Take(paragraphs.Count - skipLast).ToList(); + if (!string.IsNullOrWhiteSpace(deleteContains)) + { + paragraphs = paragraphs.Where(p => !p.Text.Contains(deleteContains)).ToList(); + } + + sub.Paragraphs.Clear(); + sub.Paragraphs.AddRange(paragraphs); + sub.Renumber(); + } + + private void UpdateChangeCasingSettings() + { + if (radioButtonNormal.Checked) + { + Configuration.Settings.Tools.ChangeCasingChoice = "Normal"; + } + else if (radioButtonFixOnlyNames.Checked) + { + Configuration.Settings.Tools.ChangeCasingChoice = "NamesOnly"; + } + else if (radioButtonUppercase.Checked) + { + Configuration.Settings.Tools.ChangeCasingChoice = "Uppercase"; + } + else if (radioButtonLowercase.Checked) + { + Configuration.Settings.Tools.ChangeCasingChoice = "Lowercase"; + } + } + + private Dictionary _actionEnabledCache; + + private void UpdateActionEnabledCache() + { + _actionEnabledCache = new Dictionary(); + foreach (ListViewItem item in listViewConvertOptions.Items) + { + var fixItem = item.Tag as FixActionItem; + _actionEnabledCache.Add(fixItem.Action, item.Checked); + } + } + + private bool IsActionEnabled(CommandLineConverter.BatchAction action) + { + if (_actionEnabledCache != null) + { + return _actionEnabledCache[action]; + } + + foreach (ListViewItem item in listViewConvertOptions.Items) + { + if (item.Tag is FixActionItem fixItem && fixItem.Action == action) + { + return item.Checked; + } + } + return false; + } + + private BackgroundWorker SpawnWorker() + { + var worker = new BackgroundWorker(); + worker.DoWork += DoThreadWork; + worker.RunWorkerCompleted += ThreadWorkerCompleted; + return worker; + } + + /// + /// Text based functions requires text, so no image to image convert + /// + /// + private bool AllowImageToImage() + { + return !IsActionEnabled(CommandLineConverter.BatchAction.BalanceLines) && + !IsActionEnabled(CommandLineConverter.BatchAction.RedoCasing) && + !IsActionEnabled(CommandLineConverter.BatchAction.FixCommonErrors) && + !IsActionEnabled(CommandLineConverter.BatchAction.FixRtl) && + !IsActionEnabled(CommandLineConverter.BatchAction.MultipleReplace) && + !IsActionEnabled(CommandLineConverter.BatchAction.RemoveFormatting) && + !IsActionEnabled(CommandLineConverter.BatchAction.SplitLongLines) && + !IsActionEnabled(CommandLineConverter.BatchAction.RemoveTextForHI) && + !IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTexts) && + !IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTimeCodes) && + !IsActionEnabled(CommandLineConverter.BatchAction.MergeShortLines) && + !IsActionEnabled(CommandLineConverter.BatchAction.RemoveLineBreaks); + } + + internal static List LoadVobSubFromMatroska(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska, out Core.VobSub.Idx idx) + { + var mergedVobSubPacks = new List(); + if (matroskaSubtitleInfo.ContentEncodingType == 1) + { + idx = null; + return mergedVobSubPacks; + } + + var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, null); + idx = new Core.VobSub.Idx(matroskaSubtitleInfo.GetCodecPrivate().SplitToLines()); + foreach (var p in sub) + { + mergedVobSubPacks.Add(new VobSubMergedPack(p.GetData(matroskaSubtitleInfo), TimeSpan.FromMilliseconds(p.Start), 32, null)); + if (mergedVobSubPacks.Count > 0) + { + mergedVobSubPacks[mergedVobSubPacks.Count - 1].EndTime = TimeSpan.FromMilliseconds(p.End); + } + + // fix overlapping (some versions of Handbrake makes overlapping time codes - thx Hawke) + if (mergedVobSubPacks.Count > 1 && mergedVobSubPacks[mergedVobSubPacks.Count - 2].EndTime > mergedVobSubPacks[mergedVobSubPacks.Count - 1].StartTime) + { + mergedVobSubPacks[mergedVobSubPacks.Count - 2].EndTime = TimeSpan.FromMilliseconds(mergedVobSubPacks[mergedVobSubPacks.Count - 1].StartTime.TotalMilliseconds - 1); + } + } + return mergedVobSubPacks; + } + + internal static List LoadBluRaySupFromMatroska(MatroskaTrackInfo track, MatroskaFile matroska, IntPtr handle) + { + if (track.ContentEncodingType == 1) + { + return new List(); + } + + var sub = matroska.GetSubtitle(track.TrackNumber, null); + TaskbarList.SetProgressState(handle, TaskbarButtonProgressFlags.NoProgress); + var subtitles = new List(); + var log = new StringBuilder(); + var clusterStream = new MemoryStream(); + var lastPalettes = new Dictionary>(); + var lastBitmapObjects = new Dictionary>(); + foreach (var p in sub) + { + byte[] buffer = p.GetData(track); + if (buffer != null && buffer.Length > 2) + { + clusterStream.Write(buffer, 0, buffer.Length); + if (ContainsBluRayStartSegment(buffer)) + { + if (subtitles.Count > 0 && subtitles[subtitles.Count - 1].StartTime == subtitles[subtitles.Count - 1].EndTime) + { + subtitles[subtitles.Count - 1].EndTime = (long)((p.Start - 1) * 90.0); + } + clusterStream.Position = 0; + var list = BluRaySupParser.ParseBluRaySup(clusterStream, log, true, lastPalettes, lastBitmapObjects); + foreach (var sup in list) + { + sup.StartTime = (long)((p.Start - 1) * 90.0); + sup.EndTime = (long)((p.End - 1) * 90.0); + subtitles.Add(sup); + + // fix overlapping + if (subtitles.Count > 1 && sub[subtitles.Count - 2].End > sub[subtitles.Count - 1].Start) + { + subtitles[subtitles.Count - 2].EndTime = subtitles[subtitles.Count - 1].StartTime - 1; + } + } + clusterStream = new MemoryStream(); + } + } + else if (subtitles.Count > 0) + { + var lastSub = subtitles[subtitles.Count - 1]; + if (lastSub.StartTime == lastSub.EndTime) + { + lastSub.EndTime = (long)((p.Start - 1) * 90.0); + if (lastSub.EndTime - lastSub.StartTime > 1000000) + { + lastSub.EndTime = lastSub.StartTime; + } + } + } + } + + clusterStream.Dispose(); + return subtitles; + } + + private static bool ContainsBluRayStartSegment(byte[] buffer) + { + const int epochStart = 0x80; + var position = 0; + while (position + 3 <= buffer.Length) + { + var segmentType = buffer[position]; + if (segmentType == epochStart) + { + return true; + } + + int length = BluRaySupParser.BigEndianInt16(buffer, position + 1) + 3; + position += length; + } + return false; + } + + private bool CheckSkipFilter(string fileName, SubtitleFormat format, Subtitle sub) + { + bool skip = false; + if (comboBoxFilter.SelectedIndex == 1) + { + if (format != null && format.GetType() == typeof(SubRip) && FileUtil.HasUtf8Bom(fileName)) + { + skip = true; + } + } + else if (comboBoxFilter.SelectedIndex == 2) + { + skip = true; + foreach (Paragraph p in sub.Paragraphs) + { + if (p.Text != null && Utilities.GetNumberOfLines(p.Text) > 2) + { + skip = false; + break; + } + } + } + else if (comboBoxFilter.SelectedIndex == 3 && !string.IsNullOrWhiteSpace(textBoxFilter.Text)) + { + skip = true; + foreach (Paragraph p in sub.Paragraphs) + { + if (p.Text != null && p.Text.Contains(textBoxFilter.Text, StringComparison.Ordinal)) + { + skip = false; + break; + } + } + } + return skip; + } + + private void IncrementAndShowProgress() + { + if (progressBar1.Value < progressBar1.Maximum) + { + progressBar1.Value++; + } + else + { + progressBar1.Value = progressBar1.Maximum; + } + progressBar1.Refresh(); + + TaskbarList.SetProgressValue(Handle, progressBar1.Value, progressBar1.Maximum); + labelStatus.Text = progressBar1.Value + " / " + progressBar1.Maximum; + if (progressBar1.Value == progressBar1.Maximum) + { + labelStatus.Text = string.Empty; + } + + Application.DoEvents(); + } + + private static void DoThreadWork(object sender, DoWorkEventArgs e) + { + var p = (ThreadDoWorkParameter)e.Argument; + var mode = Configuration.Settings.Tools.BatchConvertFixRtlMode; + + ApplyFixesStep2(p, mode); + + e.Result = p; + } + + private static void ApplyFixesStep2(ThreadDoWorkParameter p, string mode) + { + if (p.FixRtl && mode == RemoveUnicode) + { + for (int i = 0; i < p.Subtitle.Paragraphs.Count; i++) + { + var paragraph = p.Subtitle.Paragraphs[i]; + paragraph.Text = Utilities.RemoveUnicodeControlChars(paragraph.Text); + } + } + + if (p.FixCommonErrors) + { + try + { + using (var fixCommonErrors = new FixCommonErrors { BatchMode = true }) + { + var l = Configuration.Settings.Tools.BatchConvertLanguage; + if (string.IsNullOrEmpty(l)) + { + l = LanguageAutoDetect.AutoDetectGoogleLanguage(p.Subtitle); + } + + for (int i = 0; i < 3; i++) + { + fixCommonErrors.RunBatch(p.Subtitle, p.Format, p.Encoding.Encoding, l); + p.Subtitle = fixCommonErrors.FixedSubtitle; + } + } + } + catch (Exception exception) + { + p.Error = string.Format(Configuration.Settings.Language.BatchConvert.FixCommonErrorsErrorX, exception.Message); + } + } + + if (p.MultipleReplaceActive) + { + try + { + using (var form = new MultipleReplace()) + { + form.RunFromBatch(p.Subtitle); + p.Subtitle = form.FixedSubtitle; + p.Subtitle.RemoveParagraphsByIndices(form.DeleteIndices); + } + } + catch (Exception exception) + { + p.Error = string.Format(Configuration.Settings.Language.BatchConvert.MultipleReplaceErrorX, exception.Message); + } + } + + if (p.SplitLongLinesActive) + { + try + { + p.Subtitle = SplitLongLinesHelper.SplitLongLinesInSubtitle(p.Subtitle, Configuration.Settings.General.SubtitleLineMaximumLength * 2, Configuration.Settings.General.SubtitleLineMaximumLength); + } + catch (Exception exception) + { + p.Error = string.Format(Configuration.Settings.Language.BatchConvert.AutoBalanceErrorX, exception.Message); + } + } + + if (p.AutoBalanceActive) + { + try + { + var l = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(p.Subtitle); + foreach (var paragraph in p.Subtitle.Paragraphs) + { + paragraph.Text = Utilities.AutoBreakLine(paragraph.Text, l ?? p.Language); + } + } + catch (Exception exception) + { + p.Error = string.Format(Configuration.Settings.Language.BatchConvert.AutoBalanceErrorX, exception.Message); + } + } + + if (p.SetMinDisplayTimeBetweenSubtitles) + { + double minimumMillisecondsBetweenLines = Configuration.Settings.General.MinimumMillisecondsBetweenLines; + for (int i = 0; i < p.Subtitle.Paragraphs.Count - 1; i++) + { + var current = p.Subtitle.GetParagraphOrDefault(i); + var next = p.Subtitle.GetParagraphOrDefault(i + 1); + var gapsBetween = next.StartTime.TotalMilliseconds - current.EndTime.TotalMilliseconds; + if (gapsBetween < minimumMillisecondsBetweenLines && current.Duration.TotalMilliseconds > minimumMillisecondsBetweenLines) + { + current.EndTime.TotalMilliseconds -= (minimumMillisecondsBetweenLines - gapsBetween); + } + } + } + + if (p.FixRtl && mode == ReverseStartEnd) + { + for (int i = 0; i < p.Subtitle.Paragraphs.Count; i++) + { + var paragraph = p.Subtitle.Paragraphs[i]; + paragraph.Text = Utilities.ReverseStartAndEndingForRightToLeft(paragraph.Text); + } + } + else if (p.FixRtl && mode == AddUnicode) // fix with unicode char + { + for (int i = 0; i < p.Subtitle.Paragraphs.Count; i++) + { + var paragraph = p.Subtitle.Paragraphs[i]; + paragraph.Text = Utilities.FixRtlViaUnicodeChars(paragraph.Text); + } + } + + // always re-number + p.Subtitle.Renumber(); + } + + private void ThreadWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + { + CommandLineConverter.BatchConvertProgress progressCallback = null; + var p = (ThreadDoWorkParameter)e.Result; + if (p.Item.Index + 2 < listViewInputFiles.Items.Count) + { + listViewInputFiles.EnsureVisible(p.Item.Index + 2); + } + else + { + listViewInputFiles.EnsureVisible(p.Item.Index); + } + + if (!string.IsNullOrEmpty(p.Error)) + { + p.Item.SubItems[3].Text = p.Error; + } + else + { + if (p.SourceFormat == null) + { + var ext = Path.GetExtension(p.FileName); + if (ext != null && + (ext.Equals(".ts", StringComparison.OrdinalIgnoreCase) || + ext.Equals(".m2ts", StringComparison.OrdinalIgnoreCase) || + ext.Equals(".mts", StringComparison.OrdinalIgnoreCase) || + ext.Equals(".mpg", StringComparison.OrdinalIgnoreCase) || + ext.Equals(".mpeg", StringComparison.OrdinalIgnoreCase)) && + (FileUtil.IsTransportStream(p.FileName) || FileUtil.IsM2TransportStream(p.FileName))) + { + IncrementAndShowProgress(); + return; + } + + p.SourceFormat = new SubRip(); + } + + if (p.ToFormat == Ebu.NameOfFormat) + { + p.Subtitle.Header = _ebuGeneralInformation.ToString(); + } + + var targetFormat = p.ToFormat; + if (targetFormat == Configuration.Settings.Language.ExportCustomText.Title) + { + targetFormat = "CustomText:" + _customTextTemplate; + } + + try + { + var binaryParagraphs = new List(); + if (p.FileName != null && !p.Subtitle.Paragraphs.Any(s => !string.IsNullOrEmpty(s.Text)) && + p.FileName.EndsWith(".sup", StringComparison.OrdinalIgnoreCase) && + FileUtil.IsBluRaySup(p.FileName) && AllowImageToImage()) + { + binaryParagraphs = BluRaySupParser.ParseBluRaySup(p.FileName, new StringBuilder()).Cast().ToList(); + } + else if (p.FileName != null && _bdLookup.ContainsKey(p.FileName)) + { + binaryParagraphs = _bdLookup[p.FileName].Cast().ToList(); + } + var dir = textBoxOutputFolder.Text; + var overwrite = checkBoxOverwrite.Checked; + if (radioButtonSaveInSourceFolder.Checked) + { + dir = Path.GetDirectoryName(p.FileName); + } + var success = CommandLineConverter.BatchConvertSave(targetFormat, TimeSpan.Zero, GetCurrentEncoding(p.FileName), dir, _count, ref _converted, ref _errors, _allFormats, p.FileName, p.Subtitle, p.SourceFormat, binaryParagraphs, overwrite, -1, null, null, null, null, false, progressCallback); + if (success) + { + p.Item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.Converted; + } + else + { + p.Item.SubItems[3].Text = Configuration.Settings.Language.BatchConvert.NotConverted + " " + p.Item.SubItems[3].Text.Trim('-').Trim(); + } + } + catch (Exception exception) + { + p.Error = $"Save: {exception.InnerException?.Message ?? exception.Message}"; + p.Item.SubItems[3].Text = p.Error; + } + + IncrementAndShowProgress(); + } + } + + private void ComboBoxSubtitleFormatsSelectedIndexChanged(object sender, EventArgs e) + { + checkBoxUseStyleFromSource.Visible = false; + if (comboBoxSubtitleFormats.Text == AdvancedSubStationAlpha.NameOfFormat || comboBoxSubtitleFormats.Text == SubStationAlpha.NameOfFormat) + { + buttonStyles.Text = Configuration.Settings.Language.BatchConvert.Style; + buttonStyles.Visible = true; + comboBoxEncoding.Enabled = true; + buttonBrowseEncoding.Visible = true; + checkBoxUseStyleFromSource.Visible = true; + checkBoxUseStyleFromSource.Left = buttonStyles.Left + buttonStyles.Width - checkBoxUseStyleFromSource.Width; + } + else if (comboBoxSubtitleFormats.Text == Ebu.NameOfFormat) + { + buttonStyles.Text = Configuration.Settings.Language.BatchConvert.Settings; + buttonStyles.Visible = true; + if (_ebuGeneralInformation == null) + { + _ebuGeneralInformation = new Ebu.EbuGeneralSubtitleInformation(); + } + + comboBoxEncoding.Enabled = true; + buttonBrowseEncoding.Visible = true; + } + else if (comboBoxSubtitleFormats.Text == BluRaySubtitle || + comboBoxSubtitleFormats.Text == VobSubSubtitle || + comboBoxSubtitleFormats.Text == DostImageSubtitle || + comboBoxSubtitleFormats.Text == BdnXmlSubtitle || + comboBoxSubtitleFormats.Text == FcpImageSubtitle || + comboBoxSubtitleFormats.Text == Configuration.Settings.Language.ExportCustomText.Title) + { + buttonStyles.Text = Configuration.Settings.Language.BatchConvert.Settings; + buttonStyles.Visible = true; + comboBoxEncoding.Enabled = false; + buttonBrowseEncoding.Visible = false; + } + else if (comboBoxSubtitleFormats.Text == Configuration.Settings.Language.BatchConvert.PlainText) + { + buttonStyles.Text = Configuration.Settings.Language.BatchConvert.Settings; + buttonStyles.Visible = true; + comboBoxEncoding.Enabled = true; + buttonBrowseEncoding.Visible = true; + } + else + { + buttonStyles.Visible = false; + comboBoxEncoding.Enabled = true; + buttonBrowseEncoding.Visible = true; + } + } + + private void ButtonStylesClick(object sender, EventArgs e) + { + if (comboBoxSubtitleFormats.Text == AdvancedSubStationAlpha.NameOfFormat || comboBoxSubtitleFormats.Text == SubStationAlpha.NameOfFormat) + { + ShowAssSsaStyles(); + } + else if (comboBoxSubtitleFormats.Text == Ebu.NameOfFormat) + { + ShowEbuSettings(); + } + else if (comboBoxSubtitleFormats.Text == BluRaySubtitle) + { + ImageExportSettings(ExportPngXml.ExportFormats.BluraySup); + } + else if (comboBoxSubtitleFormats.Text == VobSubSubtitle) + { + ImageExportSettings(ExportPngXml.ExportFormats.VobSub); + } + else if (comboBoxSubtitleFormats.Text == DostImageSubtitle) + { + ImageExportSettings(ExportPngXml.ExportFormats.Dost); + } + else if (comboBoxSubtitleFormats.Text == BdnXmlSubtitle) + { + ImageExportSettings(ExportPngXml.ExportFormats.BdnXml); + } + else if (comboBoxSubtitleFormats.Text == FcpImageSubtitle) + { + ImageExportSettings(ExportPngXml.ExportFormats.Fcp); + } + else if (comboBoxSubtitleFormats.Text == Configuration.Settings.Language.BatchConvert.PlainText) + { + using (var form = new ExportText()) + { + var s = new Subtitle(); + s.Paragraphs.Add(new Paragraph("Test 123." + Environment.NewLine + "Test 456.", 0, 4000)); + s.Paragraphs.Add(new Paragraph("Test 789.", 5000, 9000)); + form.Initialize(s, null); + form.PrepareForBatchSettings(); + form.ShowDialog(this); + } + } + else if (comboBoxSubtitleFormats.Text == Configuration.Settings.Language.ExportCustomText.Title) + { + ShowExportCustomTextSettings(); + } + } + + private void ShowExportCustomTextSettings() + { + var s = new Subtitle(); + s.Paragraphs.Add(new Paragraph("Test 123." + Environment.NewLine + "Test 456.", 0, 4000)); + s.Paragraphs.Add(new Paragraph("Test 777." + Environment.NewLine + "Test 888.", 0, 4000)); + using (var properties = new ExportCustomText(s, null, "Test")) + { + properties.InitializeForBatchConvert(_customTextTemplate); + if (properties.ShowDialog(this) == DialogResult.OK) + { + _customTextTemplate = properties.CurrentFormatName; + } + } + } + + private void ImageExportSettings(string format) + { + using (var properties = new ExportPngXml()) + { + var s = new Subtitle(); + s.Paragraphs.Add(new Paragraph("Test 123." + Environment.NewLine + "Test 456.", 0, 4000)); + properties.Initialize(s, new SubRip(), format, null, null, null); + properties.DisableSaveButtonAndCheckBoxes(); + properties.ShowDialog(this); + } + } + + private void ShowEbuSettings() + { + using (var properties = new EbuSaveOptions()) + { + properties.Initialize(_ebuGeneralInformation, 0, null, null); + properties.ShowDialog(this); + } + } + + private void ShowAssSsaStyles() + { + SubStationAlphaStylesBatchConvert form = null; + try + { + var assa = new AdvancedSubStationAlpha(); + var sub = new Subtitle(); + if (comboBoxSubtitleFormats.Text == assa.Name) + { + if (!string.IsNullOrEmpty(_assStyle)) + { + sub.Header = _assStyle; + } + form = new SubStationAlphaStylesBatchConvert(sub, assa); + if (form.ShowDialog(this) == DialogResult.OK) + { + _assStyle = form.Header; + } + } + else + { + if (!string.IsNullOrEmpty(_ssaStyle)) + { + sub.Header = _ssaStyle; + } + var ssa = new SubStationAlpha(); + if (comboBoxSubtitleFormats.Text == ssa.Name) + { + form = new SubStationAlphaStylesBatchConvert(sub, ssa); + if (form.ShowDialog(this) == DialogResult.OK) + { + _ssaStyle = form.Header; + } + } + } + } + finally + { + form?.Dispose(); + } + } + + private void ContextMenuStripFilesOpening(object sender, CancelEventArgs e) + { + if (_converting) + { + e.Cancel = true; + return; + } + removeToolStripMenuItem.Visible = listViewInputFiles.SelectedItems.Count > 0; + openContainingFolderToolStripMenuItem.Visible = listViewInputFiles.SelectedItems.Count == 1; + removeAllToolStripMenuItem.Visible = listViewInputFiles.Items.Count > 0; + toolStripSeparator1.Visible = listViewInputFiles.Items.Count > 0; + } + + private void RemoveAllToolStripMenuItemClick(object sender, EventArgs e) + { + listViewInputFiles.Items.Clear(); + UpdateNumberOfFiles(); + UpdateTransportStreamSettings(); + } + + private void RemoveSelectedFiles() + { + if (_converting) + { + return; + } + + int first = -1; + for (int i = listViewInputFiles.SelectedIndices.Count - 1; i >= 0; i--) + { + if (first < 0) + { + first = listViewInputFiles.SelectedIndices[i]; + } + listViewInputFiles.Items.RemoveAt(listViewInputFiles.SelectedIndices[i]); + } + + // keep an item selected/focused for improved UX + if (first < listViewInputFiles.Items.Count && listViewInputFiles.Items.Count > 0) + { + listViewInputFiles.Items[first].Selected = true; + listViewInputFiles.FocusedItem = listViewInputFiles.Items[first]; + } + else if (listViewInputFiles.Items.Count > 0) + { + listViewInputFiles.Items[listViewInputFiles.Items.Count - 1].Selected = true; + listViewInputFiles.FocusedItem = listViewInputFiles.Items[listViewInputFiles.Items.Count - 1]; + } + UpdateNumberOfFiles(); + UpdateTransportStreamSettings(); + } + + private void RemoveToolStripMenuItemClick(object sender, EventArgs e) + { + RemoveSelectedFiles(); + } + + private void UpdateTransportStreamSettings() + { + bool hasTransportStream = false; + foreach (ListViewItem lvi in listViewInputFiles.Items) + { + if (lvi.SubItems[2].Text.Equals("Transport Stream", StringComparison.OrdinalIgnoreCase)) + { + hasTransportStream = true; + break; + } + } + + buttonTransportStreamSettings.Visible = hasTransportStream; + } + + private void ListViewInputFilesKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Delete) + { + RemoveSelectedFiles(); + } + else if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) + { + listViewInputFiles.SelectAll(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.D && e.Modifiers == Keys.Control) + { + listViewInputFiles.SelectFirstSelectedItemOnly(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.I && e.Modifiers == (Keys.Control | Keys.Shift)) //InverseSelection + { + listViewInputFiles.InverseSelection(); + e.SuppressKeyPress = true; + } + } + + private void BatchConvert_FormClosing(object sender, FormClosingEventArgs e) + { + if (_converting) + { + e.Cancel = true; + return; + } + if (_searching) + { + _abort = true; + } + + Configuration.Settings.Tools.BatchConvertFixCasing = IsActionEnabled(CommandLineConverter.BatchAction.RedoCasing); + Configuration.Settings.Tools.BatchConvertFixCommonErrors = IsActionEnabled(CommandLineConverter.BatchAction.FixCommonErrors); + Configuration.Settings.Tools.BatchConvertMultipleReplace = IsActionEnabled(CommandLineConverter.BatchAction.MultipleReplace); + Configuration.Settings.Tools.BatchConvertFixRtl = IsActionEnabled(CommandLineConverter.BatchAction.FixRtl); + Configuration.Settings.Tools.BatchConvertSplitLongLines = IsActionEnabled(CommandLineConverter.BatchAction.SplitLongLines); + Configuration.Settings.Tools.BatchConvertAutoBalance = IsActionEnabled(CommandLineConverter.BatchAction.BalanceLines); + Configuration.Settings.Tools.BatchConvertRemoveFormatting = IsActionEnabled(CommandLineConverter.BatchAction.RemoveFormatting); + Configuration.Settings.Tools.BatchConvertBridgeGaps = IsActionEnabled(CommandLineConverter.BatchAction.BridgeGaps); + Configuration.Settings.Tools.BatchConvertRemoveTextForHI = IsActionEnabled(CommandLineConverter.BatchAction.RemoveTextForHI); + Configuration.Settings.Tools.BatchConvertSetMinDisplayTimeBetweenSubtitles = IsActionEnabled(CommandLineConverter.BatchAction.SetMinGap); + Configuration.Settings.Tools.BatchConvertOutputFolder = textBoxOutputFolder.Text; + Configuration.Settings.Tools.BatchConvertOverwriteExisting = checkBoxOverwrite.Checked; + Configuration.Settings.Tools.BatchConvertFormat = comboBoxSubtitleFormats.SelectedItem.ToString(); + Configuration.Settings.Tools.BatchConvertAssStyles = _assStyle; + Configuration.Settings.Tools.BatchConvertSsaStyles = _ssaStyle; + Configuration.Settings.Tools.BatchConvertUseStyleFromSource = checkBoxUseStyleFromSource.Checked; + Configuration.Settings.Tools.BatchConvertExportCustomTextTemplate = _customTextTemplate; + Configuration.Settings.Tools.BatchConvertSaveInSourceFolder = radioButtonSaveInSourceFolder.Checked; + Configuration.Settings.Tools.BatchConvertMergeShortLines = IsActionEnabled(CommandLineConverter.BatchAction.MergeShortLines); + Configuration.Settings.Tools.BatchConvertRemoveLineBreaks = IsActionEnabled(CommandLineConverter.BatchAction.RemoveLineBreaks); + Configuration.Settings.Tools.BatchConvertMergeSameText = IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTexts); + Configuration.Settings.Tools.BatchConvertMergeSameTimeCodes = IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTimeCodes); + Configuration.Settings.Tools.BatchConvertChangeSpeed = IsActionEnabled(CommandLineConverter.BatchAction.ChangeSpeed); + Configuration.Settings.Tools.BatchConvertChangeFrameRate = IsActionEnabled(CommandLineConverter.BatchAction.ChangeFrameRate); + Configuration.Settings.Tools.BatchConvertOffsetTimeCodes = IsActionEnabled(CommandLineConverter.BatchAction.OffsetTimeCodes); + Configuration.Settings.Tools.BatchConvertApplyDurationLimits = IsActionEnabled(CommandLineConverter.BatchAction.ApplyDurationLimits); + Configuration.Settings.Tools.MergeShortLinesMaxGap = (int)numericUpDownMaxMillisecondsBetweenLines.Value; + Configuration.Settings.Tools.MergeShortLinesOnlyContinuous = checkBoxOnlyContinuationLines.Checked; + + UpdateRtlSettings(); + } + + private void UpdateRtlSettings() + { + if (radioButtonRemoveUnicode.Checked) + { + Configuration.Settings.Tools.BatchConvertFixRtlMode = RemoveUnicode; + } + else if (radioButtonReverseStartEnd.Checked) + { + Configuration.Settings.Tools.BatchConvertFixRtlMode = ReverseStartEnd; + } + else + { + Configuration.Settings.Tools.BatchConvertFixRtlMode = AddUnicode; + } + } + + private string _rootFolder; + private void buttonSearchFolder_Click(object sender, EventArgs e) + { + folderBrowserDialog1.ShowNewFolderButton = false; + folderBrowserDialog1.SelectedPath = _rootFolder; + if (folderBrowserDialog1.ShowDialog(this) == DialogResult.OK) + { + listViewInputFiles.BeginUpdate(); + progressBar1.Style = ProgressBarStyle.Marquee; + progressBar1.Visible = true; + SetControlState(false); + labelStatus.Text = string.Empty; + + SearchFolder(folderBrowserDialog1.SelectedPath); + _rootFolder = folderBrowserDialog1.SelectedPath; + + labelStatus.Text = string.Empty; + + SetControlState(true); + listViewInputFiles.EndUpdate(); + } + progressBar1.Value = 0; + progressBar1.Visible = false; + UpdateNumberOfFiles(); + } + + private void SetControlState(bool enabled) + { + labelStatus.Text = string.Empty; + buttonCancel.Enabled = enabled; + groupBoxOutput.Enabled = enabled; + groupBoxConvertOptions.Enabled = enabled; + buttonInputBrowse.Enabled = enabled; + buttonSearchFolder.Enabled = enabled; + checkBoxScanFolderRecursive.Enabled = enabled; + comboBoxFilter.Enabled = enabled; + + if (enabled) + { + buttonConvert.Text = Configuration.Settings.Language.BatchConvert.Convert; + } + else + { + buttonConvert.Text = Configuration.Settings.Language.General.Cancel; + } + } + + private void SearchFolder(string path) + { + _abort = false; + _searching = true; + try + { + if (checkBoxScanFolderRecursive.Checked) + { + ScanFiles(Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories)); + } + else + { + ScanFiles(Directory.EnumerateFiles(path)); + } + } + finally + { + _searching = false; + } + } + + private static readonly HashSet SearchExtBlackList = new HashSet + { + ".png", + ".jpg", + ".jpeg", + ".tif", + ".tiff", + ".gif", + ".bmp", + ".clpi", + ".mpls", + ".wav", + ".mp3", + ".avi", + ".mpeg", + ".mpg", + ".tar", + ".docx", + ".pptx", + ".xlsx", + ".odt", + ".tex", + ".pdf", + ".dll", + ".exe", + ".rar", + ".7z", + ".zip", + ".tar" + }; + + private void ScanFiles(IEnumerable fileNames) + { + foreach (string fileName in fileNames) + { + labelStatus.Text = fileName; + try + { + string ext = Path.GetExtension(fileName).ToLowerInvariant(); + if (!SearchExtBlackList.Contains(ext)) + { + labelStatus.Refresh(); + var fi = new FileInfo(fileName); + if (comboBoxFilter.SelectedIndex == 4 && textBoxFilter.Text.Length > 0 && !fileName.Contains(textBoxFilter.Text, StringComparison.OrdinalIgnoreCase)) + { + // skip + } + else if (ext == ".sub" && FileUtil.IsVobSub(fileName)) + { + AddFromSearch(fileName, fi, "VobSub"); + } + else if (ext == ".sup" && FileUtil.IsBluRaySup(fileName)) + { + AddFromSearch(fileName, fi, "Blu-ray"); + } + else if (ext == ".mkv") + { + // skip for now + } + else if (ext == ".mks") + { + // skip for now + } + else if (ext == ".mp4") + { + // skip for now + } + else + { + if (fi.Length < ConvertMaxFileSize) + { + var sub = new Subtitle(); + var enc = LanguageAutoDetect.GetEncodingFromFile(fileName, true); + var format = sub.LoadSubtitle(fileName, out _, enc, true, null, false); + if (format == null) + { + foreach (var f in SubtitleFormat.GetBinaryFormats(true)) + { + if (f.IsMine(null, fileName)) + { + f.LoadSubtitle(sub, null, fileName); + format = f; + break; + } + } + } + + if (format == null) + { + var lines = FileUtil.ReadAllTextShared(fileName, enc).SplitToLines(); + foreach (var f in SubtitleFormat.GetTextOtherFormats()) + { + if (f.IsMine(lines, fileName)) + { + f.LoadSubtitle(sub, lines, fileName); + format = f; + break; + } + } + } + + if (format != null) + { + AddFromSearch(fileName, fi, format.Name); + } + } + } + progressBar1.Refresh(); + Application.DoEvents(); + if (_abort) + { + progressBar1.Value = 0; + progressBar1.Visible = false; + return; + } + } + } + catch + { + // ignored + } + } + } + + private void AddFromSearch(string fileName, FileInfo fi, string nameOfFormat) + { + var item = new ListViewItem(fileName); + item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); + item.SubItems.Add(nameOfFormat); + item.SubItems.Add("-"); + listViewInputFiles.Items.Add(item); + UpdateNumberOfFiles(); + } + + private void BatchConvert_KeyDown(object sender, KeyEventArgs e) + { + if (_converting || _searching) + { + if (e.KeyCode == Keys.Escape) + { + _abort = true; + e.SuppressKeyPress = true; + } + } + else if (e.KeyCode == Keys.Escape) + { + Close(); + } + else if (e.KeyData == (Keys.Control | Keys.O)) // Open file/s + { + buttonInputBrowse_Click(null, EventArgs.Empty); + } + } + + private void comboBoxFilter_SelectedIndexChanged(object sender, EventArgs e) + { + textBoxFilter.Visible = comboBoxFilter.SelectedIndex == 3 || comboBoxFilter.SelectedIndex == 4 || comboBoxFilter.SelectedIndex == 5; + } + + private void buttonTransportStreamSettings_Click(object sender, EventArgs e) + { + using (var form = new BatchConvertTsSettings()) + { + form.ShowDialog(this); + } + } + + private void radioButtonSaveInSourceFolder_CheckedChanged(object sender, EventArgs e) + { + textBoxOutputFolder.Enabled = false; + buttonChooseFolder.Enabled = false; + } + + private void radioButtonSaveInOutputFolder_CheckedChanged(object sender, EventArgs e) + { + textBoxOutputFolder.Enabled = true; + buttonChooseFolder.Enabled = true; + } + + private void linkLabelOpenOutputFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + if (Directory.Exists(textBoxOutputFolder.Text)) + { + UiUtil.OpenFolder(textBoxOutputFolder.Text); + } + else + { + MessageBox.Show(string.Format(Configuration.Settings.Language.SplitSubtitle.FolderNotFoundX, textBoxOutputFolder.Text)); + } + } + + private void buttonChooseFolder_Click(object sender, EventArgs e) + { + folderBrowserDialog1.ShowNewFolderButton = true; + if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) + { + textBoxOutputFolder.Text = folderBrowserDialog1.SelectedPath; + } + } + + private void listViewConvertOptions_SelectedIndexChanged(object sender, EventArgs e) + { + groupBoxMergeShortLines.Visible = false; + groupBoxChangeFrameRate.Visible = false; + groupBoxSpeed.Visible = false; + groupBoxOffsetTimeCodes.Visible = false; + buttonConvertOptionsSettings.Visible = false; + groupBoxFixRtl.Visible = false; + groupBoxChangeCasing.Visible = false; + groupBoxRemoveStyle.Visible = false; + groupBoxAdjustDuration.Visible = false; + if (listViewConvertOptions.SelectedIndices.Count != 1) + { + return; + } + + var idx = listViewConvertOptions.SelectedIndices[0]; + var fixItem = listViewConvertOptions.Items[idx].Tag as FixActionItem; + if (fixItem?.Control != null) + { + fixItem.Control.Top = listViewConvertOptions.Top; + fixItem.Control.Visible = true; + fixItem.Control.BringToFront(); + if (fixItem.Control is GroupBox groupBox) + { + groupBox.Height = listViewConvertOptions.Height; + } + } + } + + private void ButtonOptionConvertSettings(object sender, EventArgs e) + { + if (listViewConvertOptions.SelectedIndices.Count != 1) + { + return; + } + var idx = listViewConvertOptions.SelectedIndices[0]; + var fixItem = listViewConvertOptions.Items[idx].Tag as FixActionItem; + if (fixItem.Action == CommandLineConverter.BatchAction.RemoveTextForHI) + { + using (var form = new FormRemoveTextForHearImpaired(null, new Subtitle())) + { + form.InitializeSettingsOnly(); + form.ShowDialog(this); + _removeTextForHiSettings = form.GetSettings(new Subtitle()); + } + } + else if (fixItem.Action == CommandLineConverter.BatchAction.FixCommonErrors) + { + using (var form = new FixCommonErrors { BatchMode = true }) + { + form.RunBatchSettings(new Subtitle(), GetCurrentSubtitleFormat(), GetCurrentEncoding(null), Configuration.Settings.Tools.BatchConvertLanguage); + form.ShowDialog(this); + Configuration.Settings.Tools.BatchConvertLanguage = form.Language; + } + } + else if (fixItem.Action == CommandLineConverter.BatchAction.BridgeGaps) + { + _bridgeGaps.ShowDialog(this); + } + else if (fixItem.Action == CommandLineConverter.BatchAction.MultipleReplace) + { + using (var form = new MultipleReplace()) + { + form.Initialize(new Subtitle()); + form.ShowDialog(this); + } + } + } + + private void buttonSwapFrameRate_Click(object sender, EventArgs e) + { + string oldFrameRate = comboBoxFrameRateFrom.Text; + string newFrameRate = comboBoxFrameRateTo.Text; + + comboBoxFrameRateFrom.Text = newFrameRate; + comboBoxFrameRateTo.Text = oldFrameRate; + } + + private void listViewConvertOptions_ItemChecked(object sender, ItemCheckedEventArgs e) + { + var count = listViewConvertOptions.CheckedItems.Count; + if (count > 0) + { + groupBoxConvertOptions.Text = Configuration.Settings.Language.BatchConvert.ConvertOptions + " " + count; + } + else + { + groupBoxConvertOptions.Text = Configuration.Settings.Language.BatchConvert.ConvertOptions; + } + } + + private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewConvertOptions.Items) + { + item.Checked = true; + } + } + + private void inverseSelectionToolStripMenuItem_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewConvertOptions.Items) + { + item.Checked = !item.Checked; + } + } + + private void listViewInputFiles_ColumnClick(object sender, ColumnClickEventArgs e) + { + if (_converting) + { + return; + } + + var sorter = (ListViewSorter)listViewInputFiles.ListViewItemSorter; + if (sorter == null) + { + sorter = new ListViewSorter + { + ColumnNumber = e.Column, + IsNumber = false, + IsDisplayFileSize = e.Column == columnHeaderSize.DisplayIndex + }; + listViewInputFiles.ListViewItemSorter = sorter; + } + + if (e.Column == sorter.ColumnNumber) + { + sorter.Descending = !sorter.Descending; // inverse sort direction + } + else + { + sorter.ColumnNumber = e.Column; + sorter.Descending = false; + sorter.IsNumber = false; + sorter.IsDisplayFileSize = e.Column == columnHeaderSize.DisplayIndex; + } + listViewInputFiles.Sort(); + } + + private void buttonBrowseEncoding_Click(object sender, EventArgs e) + { + openFileDialog1.Title = Configuration.Settings.Language.Main.OpenAnsiSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + using (var chooseEncoding = new ChooseEncoding()) + { + chooseEncoding.Initialize(openFileDialog1.FileName); + if (chooseEncoding.ShowDialog(this) == DialogResult.OK) + { + var encoding = chooseEncoding.GetEncoding(); + for (var i = 0; i < comboBoxEncoding.Items.Count; i++) + { + var item = comboBoxEncoding.Items[i]; + if (item is TextEncoding te) + { + if (te.Encoding.WebName == encoding.WebName) + { + comboBoxEncoding.SelectedIndex = i; + break; + } + } + } + } + } + } + } + + private void UpdateNumberOfFiles() + { + if (listViewInputFiles.Items.Count > 0) + { + labelNumberOfFiles.Text = $"{listViewInputFiles.Items.Count:#,###,##0}"; + } + else + { + labelNumberOfFiles.Text = string.Empty; + } + } + + private void openContainingFolderToolStripMenuItem_Click(object sender, EventArgs e) + { + if (_converting || listViewInputFiles.SelectedIndices.Count != 1) + { + return; + } + + int idx = listViewInputFiles.SelectedIndices[0]; + var fileName = listViewInputFiles.Items[idx].Text; + UiUtil.OpenFolderFromFileName(fileName); + } + + private void convertMkvThreeLetterLanguageCodesToTwoLettersToolStripMenuItem_Click(object sender, EventArgs e) + { + using (var form = new BatchConvertMkvEnding { LanguageCodeStyle = Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle }) + { + var result = form.ShowDialog(this); + if (result == DialogResult.OK) + { + Configuration.Settings.Tools.BatchConvertMkvLanguageCodeStyle = form.LanguageCodeStyle; + SetMkvLanguageMenuItem(); + } + } + } + + private void comboBoxAdjustDurationVia_SelectedIndexChanged(object sender, EventArgs e) + { + panelAdjustDurationAddSeconds.Visible = false; + panelAdjustDurationAddPercent.Visible = false; + panelAdjustDurationFixed.Visible = false; + panelAdjustDurationRecalc.Visible = false; + + var panel = panelAdjustDurationAddSeconds; + if (comboBoxAdjustDurationVia.SelectedIndex == 1) + { + panel = panelAdjustDurationAddPercent; + } + else if (comboBoxAdjustDurationVia.SelectedIndex == 2) + { + panel = panelAdjustDurationRecalc; + } + else if (comboBoxAdjustDurationVia.SelectedIndex == 3) + { + panel = panelAdjustDurationFixed; + } + + panel.Visible = true; + panel.Left = 2; + panel.Top = labelAdjustDurationVia.Top + labelAdjustDurationVia.Height + 9; + } + + private void addFilesToolStripMenuItem_Click(object sender, EventArgs e) + { + buttonInputBrowse_Click(sender, e); + } + } +} diff --git a/src/Forms/BatchConvert.resx b/src/ui/Forms/BatchConvert.resx similarity index 98% rename from src/Forms/BatchConvert.resx rename to src/ui/Forms/BatchConvert.resx index a1362bcb4..cd4d0f5df 100644 --- a/src/Forms/BatchConvert.resx +++ b/src/ui/Forms/BatchConvert.resx @@ -1,132 +1,132 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 499, 17 - - - 326, 17 - - - 17, 17 - - - 186, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 499, 17 + + + 326, 17 + + + 17, 17 + + + 186, 17 + \ No newline at end of file diff --git a/src/Forms/BatchConvertMkvEnding.Designer.cs b/src/ui/Forms/BatchConvertMkvEnding.Designer.cs similarity index 100% rename from src/Forms/BatchConvertMkvEnding.Designer.cs rename to src/ui/Forms/BatchConvertMkvEnding.Designer.cs diff --git a/src/Forms/BatchConvertMkvEnding.cs b/src/ui/Forms/BatchConvertMkvEnding.cs similarity index 100% rename from src/Forms/BatchConvertMkvEnding.cs rename to src/ui/Forms/BatchConvertMkvEnding.cs diff --git a/src/Forms/ChooseFontName.resx b/src/ui/Forms/BatchConvertMkvEnding.resx similarity index 100% rename from src/Forms/ChooseFontName.resx rename to src/ui/Forms/BatchConvertMkvEnding.resx diff --git a/src/Forms/BatchConvertTsSettings.Designer.cs b/src/ui/Forms/BatchConvertTsSettings.Designer.cs similarity index 100% rename from src/Forms/BatchConvertTsSettings.Designer.cs rename to src/ui/Forms/BatchConvertTsSettings.Designer.cs diff --git a/src/Forms/BatchConvertTsSettings.cs b/src/ui/Forms/BatchConvertTsSettings.cs similarity index 100% rename from src/Forms/BatchConvertTsSettings.cs rename to src/ui/Forms/BatchConvertTsSettings.cs diff --git a/src/Forms/BatchConvertTsSettings.resx b/src/ui/Forms/BatchConvertTsSettings.resx similarity index 100% rename from src/Forms/BatchConvertTsSettings.resx rename to src/ui/Forms/BatchConvertTsSettings.resx diff --git a/src/Forms/Beamer.Designer.cs b/src/ui/Forms/Beamer.Designer.cs similarity index 97% rename from src/Forms/Beamer.Designer.cs rename to src/ui/Forms/Beamer.Designer.cs index 375a0f8ee..5e430ecf6 100644 --- a/src/Forms/Beamer.Designer.cs +++ b/src/ui/Forms/Beamer.Designer.cs @@ -1,363 +1,363 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class Beamer - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.groupBoxImageSettings = new System.Windows.Forms.GroupBox(); - this.comboBoxHAlign = new System.Windows.Forms.ComboBox(); - this.labelHorizontalAlign = new System.Windows.Forms.Label(); - this.labelSubtitleFontSize = new System.Windows.Forms.Label(); - this.comboBoxSubtitleFont = new System.Windows.Forms.ComboBox(); - this.comboBoxSubtitleFontSize = new System.Windows.Forms.ComboBox(); - this.labelSubtitleFont = new System.Windows.Forms.Label(); - this.labelBorderWidth = new System.Windows.Forms.Label(); - this.comboBoxBorderWidth = new System.Windows.Forms.ComboBox(); - this.panelBorderColor = new System.Windows.Forms.Panel(); - this.buttonBorderColor = new System.Windows.Forms.Button(); - this.panelColor = new System.Windows.Forms.Panel(); - this.buttonColor = new System.Windows.Forms.Button(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.buttonStart = new System.Windows.Forms.Button(); - this.colorDialog1 = new System.Windows.Forms.ColorDialog(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.groupBoxImageSettings.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.SuspendLayout(); - // - // groupBoxImageSettings - // - this.groupBoxImageSettings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxImageSettings.Controls.Add(this.comboBoxHAlign); - this.groupBoxImageSettings.Controls.Add(this.labelHorizontalAlign); - this.groupBoxImageSettings.Controls.Add(this.labelSubtitleFontSize); - this.groupBoxImageSettings.Controls.Add(this.comboBoxSubtitleFont); - this.groupBoxImageSettings.Controls.Add(this.comboBoxSubtitleFontSize); - this.groupBoxImageSettings.Controls.Add(this.labelSubtitleFont); - this.groupBoxImageSettings.Controls.Add(this.labelBorderWidth); - this.groupBoxImageSettings.Controls.Add(this.comboBoxBorderWidth); - this.groupBoxImageSettings.Controls.Add(this.panelBorderColor); - this.groupBoxImageSettings.Controls.Add(this.buttonBorderColor); - this.groupBoxImageSettings.Controls.Add(this.panelColor); - this.groupBoxImageSettings.Controls.Add(this.buttonColor); - this.groupBoxImageSettings.Location = new System.Drawing.Point(4, 6); - this.groupBoxImageSettings.Name = "groupBoxImageSettings"; - this.groupBoxImageSettings.Size = new System.Drawing.Size(854, 114); - this.groupBoxImageSettings.TabIndex = 23; - this.groupBoxImageSettings.TabStop = false; - this.groupBoxImageSettings.Text = "Image settings"; - // - // comboBoxHAlign - // - this.comboBoxHAlign.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxHAlign.FormattingEnabled = true; - this.comboBoxHAlign.Items.AddRange(new object[] { - "Left", - "Center", - "Right"}); - this.comboBoxHAlign.Location = new System.Drawing.Point(100, 78); - this.comboBoxHAlign.Name = "comboBoxHAlign"; - this.comboBoxHAlign.Size = new System.Drawing.Size(121, 21); - this.comboBoxHAlign.TabIndex = 25; - this.comboBoxHAlign.SelectedIndexChanged += new System.EventHandler(this.ComboBoxHAlignSelectedIndexChanged); - // - // labelHorizontalAlign - // - this.labelHorizontalAlign.AutoSize = true; - this.labelHorizontalAlign.Location = new System.Drawing.Point(10, 81); - this.labelHorizontalAlign.Name = "labelHorizontalAlign"; - this.labelHorizontalAlign.Size = new System.Drawing.Size(30, 13); - this.labelHorizontalAlign.TabIndex = 24; - this.labelHorizontalAlign.Text = "Align"; - // - // labelSubtitleFontSize - // - this.labelSubtitleFontSize.AutoSize = true; - this.labelSubtitleFontSize.Location = new System.Drawing.Point(10, 54); - this.labelSubtitleFontSize.Name = "labelSubtitleFontSize"; - this.labelSubtitleFontSize.Size = new System.Drawing.Size(84, 13); - this.labelSubtitleFontSize.TabIndex = 20; - this.labelSubtitleFontSize.Text = "Subtitle font size"; - // - // comboBoxSubtitleFont - // - this.comboBoxSubtitleFont.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSubtitleFont.FormattingEnabled = true; - this.comboBoxSubtitleFont.Location = new System.Drawing.Point(100, 24); - this.comboBoxSubtitleFont.Name = "comboBoxSubtitleFont"; - this.comboBoxSubtitleFont.Size = new System.Drawing.Size(121, 21); - this.comboBoxSubtitleFont.TabIndex = 17; - this.comboBoxSubtitleFont.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSubtitleFontSelectedValueChanged); - // - // comboBoxSubtitleFontSize - // - this.comboBoxSubtitleFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSubtitleFontSize.FormattingEnabled = true; - this.comboBoxSubtitleFontSize.Items.AddRange(new object[] { - "10", - "11", - "12", - "13", - "14", - "15", - "16", - "17", - "18", - "19", - "20", - "21", - "22", - "23", - "24", - "25", - "26", - "27", - "28", - "29", - "30", - "31", - "32", - "33", - "34", - "35", - "36", - "37", - "38", - "39", - "40", - "41", - "42", - "43", - "44", - "45", - "46", - "47", - "48", - "49", - "50", - "51", - "52", - "53", - "54", - "55", - "56", - "57", - "58", - "59", - "60", - "61", - "62", - "63", - "64", - "65", - "66", - "67", - "68", - "69", - "70", - "71", - "72", - "73", - "74", - "75", - "76", - "77", - "78", - "79", - "80", - "81", - "82", - "83", - "84", - "85", - "86", - "87", - "88", - "89", - "90", - "91", - "92", - "93", - "94", - "95", - "96", - "97", - "98", - "99", - "100"}); - this.comboBoxSubtitleFontSize.Location = new System.Drawing.Point(100, 51); - this.comboBoxSubtitleFontSize.Name = "comboBoxSubtitleFontSize"; - this.comboBoxSubtitleFontSize.Size = new System.Drawing.Size(121, 21); - this.comboBoxSubtitleFontSize.TabIndex = 18; - this.comboBoxSubtitleFontSize.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSubtitleFontSizeSelectedIndexChanged); - // - // labelSubtitleFont - // - this.labelSubtitleFont.AutoSize = true; - this.labelSubtitleFont.Location = new System.Drawing.Point(10, 27); - this.labelSubtitleFont.Name = "labelSubtitleFont"; - this.labelSubtitleFont.Size = new System.Drawing.Size(63, 13); - this.labelSubtitleFont.TabIndex = 19; - this.labelSubtitleFont.Text = "Subtitle font"; - // - // labelBorderWidth - // - this.labelBorderWidth.Location = new System.Drawing.Point(426, 56); - this.labelBorderWidth.Name = "labelBorderWidth"; - this.labelBorderWidth.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.labelBorderWidth.Size = new System.Drawing.Size(110, 13); - this.labelBorderWidth.TabIndex = 16; - this.labelBorderWidth.Text = "Border width"; - this.labelBorderWidth.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // comboBoxBorderWidth - // - this.comboBoxBorderWidth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxBorderWidth.FormattingEnabled = true; - this.comboBoxBorderWidth.Items.AddRange(new object[] { - "0", - "1", - "2", - "3", - "4", - "5"}); - this.comboBoxBorderWidth.Location = new System.Drawing.Point(537, 51); - this.comboBoxBorderWidth.Name = "comboBoxBorderWidth"; - this.comboBoxBorderWidth.Size = new System.Drawing.Size(121, 21); - this.comboBoxBorderWidth.TabIndex = 15; - this.comboBoxBorderWidth.SelectedIndexChanged += new System.EventHandler(this.ComboBoxBorderWidthSelectedIndexChanged); - // - // panelBorderColor - // - this.panelBorderColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelBorderColor.Location = new System.Drawing.Point(664, 25); - this.panelBorderColor.Name = "panelBorderColor"; - this.panelBorderColor.Size = new System.Drawing.Size(21, 20); - this.panelBorderColor.TabIndex = 14; - this.panelBorderColor.Click += new System.EventHandler(this.ButtonBorderColorClick); - // - // buttonBorderColor - // - this.buttonBorderColor.Location = new System.Drawing.Point(537, 24); - this.buttonBorderColor.Name = "buttonBorderColor"; - this.buttonBorderColor.Size = new System.Drawing.Size(121, 21); - this.buttonBorderColor.TabIndex = 13; - this.buttonBorderColor.Text = "Border color"; - this.buttonBorderColor.UseVisualStyleBackColor = true; - this.buttonBorderColor.Click += new System.EventHandler(this.ButtonBorderColorClick); - // - // panelColor - // - this.panelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelColor.Location = new System.Drawing.Point(403, 25); - this.panelColor.Name = "panelColor"; - this.panelColor.Size = new System.Drawing.Size(21, 20); - this.panelColor.TabIndex = 12; - this.panelColor.Click += new System.EventHandler(this.ButtonColorClick); - // - // buttonColor - // - this.buttonColor.Location = new System.Drawing.Point(276, 24); - this.buttonColor.Name = "buttonColor"; - this.buttonColor.Size = new System.Drawing.Size(121, 21); - this.buttonColor.TabIndex = 11; - this.buttonColor.Text = "Color"; - this.buttonColor.UseVisualStyleBackColor = true; - this.buttonColor.Click += new System.EventHandler(this.ButtonColorClick); - // - // pictureBox1 - // - this.pictureBox1.Location = new System.Drawing.Point(4, 126); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(855, 211); - this.pictureBox1.TabIndex = 22; - this.pictureBox1.TabStop = false; - // - // buttonStart - // - this.buttonStart.Location = new System.Drawing.Point(4, 343); - this.buttonStart.Name = "buttonStart"; - this.buttonStart.Size = new System.Drawing.Size(121, 21); - this.buttonStart.TabIndex = 24; - this.buttonStart.Text = "&Start"; - this.buttonStart.UseVisualStyleBackColor = true; - this.buttonStart.Click += new System.EventHandler(this.ButtonStartClick); - // - // timer1 - // - this.timer1.Interval = 25; - this.timer1.Tick += new System.EventHandler(this.Timer1Tick); - // - // Beamer - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(862, 376); - this.Controls.Add(this.buttonStart); - this.Controls.Add(this.groupBoxImageSettings); - this.Controls.Add(this.pictureBox1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "Beamer"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Beamer"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BeamerFormClosing); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.BeamerKeyDown); - this.groupBoxImageSettings.ResumeLayout(false); - this.groupBoxImageSettings.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxImageSettings; - private System.Windows.Forms.Label labelSubtitleFontSize; - private System.Windows.Forms.ComboBox comboBoxSubtitleFont; - private System.Windows.Forms.ComboBox comboBoxSubtitleFontSize; - private System.Windows.Forms.Label labelSubtitleFont; - private System.Windows.Forms.Label labelBorderWidth; - private System.Windows.Forms.ComboBox comboBoxBorderWidth; - private System.Windows.Forms.Panel panelBorderColor; - private System.Windows.Forms.Button buttonBorderColor; - private System.Windows.Forms.Panel panelColor; - private System.Windows.Forms.Button buttonColor; - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.Button buttonStart; - private System.Windows.Forms.ColorDialog colorDialog1; - private System.Windows.Forms.Timer timer1; - private System.Windows.Forms.ComboBox comboBoxHAlign; - private System.Windows.Forms.Label labelHorizontalAlign; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class Beamer + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.groupBoxImageSettings = new System.Windows.Forms.GroupBox(); + this.comboBoxHAlign = new System.Windows.Forms.ComboBox(); + this.labelHorizontalAlign = new System.Windows.Forms.Label(); + this.labelSubtitleFontSize = new System.Windows.Forms.Label(); + this.comboBoxSubtitleFont = new System.Windows.Forms.ComboBox(); + this.comboBoxSubtitleFontSize = new System.Windows.Forms.ComboBox(); + this.labelSubtitleFont = new System.Windows.Forms.Label(); + this.labelBorderWidth = new System.Windows.Forms.Label(); + this.comboBoxBorderWidth = new System.Windows.Forms.ComboBox(); + this.panelBorderColor = new System.Windows.Forms.Panel(); + this.buttonBorderColor = new System.Windows.Forms.Button(); + this.panelColor = new System.Windows.Forms.Panel(); + this.buttonColor = new System.Windows.Forms.Button(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.buttonStart = new System.Windows.Forms.Button(); + this.colorDialog1 = new System.Windows.Forms.ColorDialog(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.groupBoxImageSettings.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // groupBoxImageSettings + // + this.groupBoxImageSettings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImageSettings.Controls.Add(this.comboBoxHAlign); + this.groupBoxImageSettings.Controls.Add(this.labelHorizontalAlign); + this.groupBoxImageSettings.Controls.Add(this.labelSubtitleFontSize); + this.groupBoxImageSettings.Controls.Add(this.comboBoxSubtitleFont); + this.groupBoxImageSettings.Controls.Add(this.comboBoxSubtitleFontSize); + this.groupBoxImageSettings.Controls.Add(this.labelSubtitleFont); + this.groupBoxImageSettings.Controls.Add(this.labelBorderWidth); + this.groupBoxImageSettings.Controls.Add(this.comboBoxBorderWidth); + this.groupBoxImageSettings.Controls.Add(this.panelBorderColor); + this.groupBoxImageSettings.Controls.Add(this.buttonBorderColor); + this.groupBoxImageSettings.Controls.Add(this.panelColor); + this.groupBoxImageSettings.Controls.Add(this.buttonColor); + this.groupBoxImageSettings.Location = new System.Drawing.Point(4, 6); + this.groupBoxImageSettings.Name = "groupBoxImageSettings"; + this.groupBoxImageSettings.Size = new System.Drawing.Size(854, 114); + this.groupBoxImageSettings.TabIndex = 23; + this.groupBoxImageSettings.TabStop = false; + this.groupBoxImageSettings.Text = "Image settings"; + // + // comboBoxHAlign + // + this.comboBoxHAlign.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxHAlign.FormattingEnabled = true; + this.comboBoxHAlign.Items.AddRange(new object[] { + "Left", + "Center", + "Right"}); + this.comboBoxHAlign.Location = new System.Drawing.Point(100, 78); + this.comboBoxHAlign.Name = "comboBoxHAlign"; + this.comboBoxHAlign.Size = new System.Drawing.Size(121, 21); + this.comboBoxHAlign.TabIndex = 25; + this.comboBoxHAlign.SelectedIndexChanged += new System.EventHandler(this.ComboBoxHAlignSelectedIndexChanged); + // + // labelHorizontalAlign + // + this.labelHorizontalAlign.AutoSize = true; + this.labelHorizontalAlign.Location = new System.Drawing.Point(10, 81); + this.labelHorizontalAlign.Name = "labelHorizontalAlign"; + this.labelHorizontalAlign.Size = new System.Drawing.Size(30, 13); + this.labelHorizontalAlign.TabIndex = 24; + this.labelHorizontalAlign.Text = "Align"; + // + // labelSubtitleFontSize + // + this.labelSubtitleFontSize.AutoSize = true; + this.labelSubtitleFontSize.Location = new System.Drawing.Point(10, 54); + this.labelSubtitleFontSize.Name = "labelSubtitleFontSize"; + this.labelSubtitleFontSize.Size = new System.Drawing.Size(84, 13); + this.labelSubtitleFontSize.TabIndex = 20; + this.labelSubtitleFontSize.Text = "Subtitle font size"; + // + // comboBoxSubtitleFont + // + this.comboBoxSubtitleFont.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSubtitleFont.FormattingEnabled = true; + this.comboBoxSubtitleFont.Location = new System.Drawing.Point(100, 24); + this.comboBoxSubtitleFont.Name = "comboBoxSubtitleFont"; + this.comboBoxSubtitleFont.Size = new System.Drawing.Size(121, 21); + this.comboBoxSubtitleFont.TabIndex = 17; + this.comboBoxSubtitleFont.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSubtitleFontSelectedValueChanged); + // + // comboBoxSubtitleFontSize + // + this.comboBoxSubtitleFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSubtitleFontSize.FormattingEnabled = true; + this.comboBoxSubtitleFontSize.Items.AddRange(new object[] { + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17", + "18", + "19", + "20", + "21", + "22", + "23", + "24", + "25", + "26", + "27", + "28", + "29", + "30", + "31", + "32", + "33", + "34", + "35", + "36", + "37", + "38", + "39", + "40", + "41", + "42", + "43", + "44", + "45", + "46", + "47", + "48", + "49", + "50", + "51", + "52", + "53", + "54", + "55", + "56", + "57", + "58", + "59", + "60", + "61", + "62", + "63", + "64", + "65", + "66", + "67", + "68", + "69", + "70", + "71", + "72", + "73", + "74", + "75", + "76", + "77", + "78", + "79", + "80", + "81", + "82", + "83", + "84", + "85", + "86", + "87", + "88", + "89", + "90", + "91", + "92", + "93", + "94", + "95", + "96", + "97", + "98", + "99", + "100"}); + this.comboBoxSubtitleFontSize.Location = new System.Drawing.Point(100, 51); + this.comboBoxSubtitleFontSize.Name = "comboBoxSubtitleFontSize"; + this.comboBoxSubtitleFontSize.Size = new System.Drawing.Size(121, 21); + this.comboBoxSubtitleFontSize.TabIndex = 18; + this.comboBoxSubtitleFontSize.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSubtitleFontSizeSelectedIndexChanged); + // + // labelSubtitleFont + // + this.labelSubtitleFont.AutoSize = true; + this.labelSubtitleFont.Location = new System.Drawing.Point(10, 27); + this.labelSubtitleFont.Name = "labelSubtitleFont"; + this.labelSubtitleFont.Size = new System.Drawing.Size(63, 13); + this.labelSubtitleFont.TabIndex = 19; + this.labelSubtitleFont.Text = "Subtitle font"; + // + // labelBorderWidth + // + this.labelBorderWidth.Location = new System.Drawing.Point(426, 56); + this.labelBorderWidth.Name = "labelBorderWidth"; + this.labelBorderWidth.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.labelBorderWidth.Size = new System.Drawing.Size(110, 13); + this.labelBorderWidth.TabIndex = 16; + this.labelBorderWidth.Text = "Border width"; + this.labelBorderWidth.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // comboBoxBorderWidth + // + this.comboBoxBorderWidth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxBorderWidth.FormattingEnabled = true; + this.comboBoxBorderWidth.Items.AddRange(new object[] { + "0", + "1", + "2", + "3", + "4", + "5"}); + this.comboBoxBorderWidth.Location = new System.Drawing.Point(537, 51); + this.comboBoxBorderWidth.Name = "comboBoxBorderWidth"; + this.comboBoxBorderWidth.Size = new System.Drawing.Size(121, 21); + this.comboBoxBorderWidth.TabIndex = 15; + this.comboBoxBorderWidth.SelectedIndexChanged += new System.EventHandler(this.ComboBoxBorderWidthSelectedIndexChanged); + // + // panelBorderColor + // + this.panelBorderColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelBorderColor.Location = new System.Drawing.Point(664, 25); + this.panelBorderColor.Name = "panelBorderColor"; + this.panelBorderColor.Size = new System.Drawing.Size(21, 20); + this.panelBorderColor.TabIndex = 14; + this.panelBorderColor.Click += new System.EventHandler(this.ButtonBorderColorClick); + // + // buttonBorderColor + // + this.buttonBorderColor.Location = new System.Drawing.Point(537, 24); + this.buttonBorderColor.Name = "buttonBorderColor"; + this.buttonBorderColor.Size = new System.Drawing.Size(121, 21); + this.buttonBorderColor.TabIndex = 13; + this.buttonBorderColor.Text = "Border color"; + this.buttonBorderColor.UseVisualStyleBackColor = true; + this.buttonBorderColor.Click += new System.EventHandler(this.ButtonBorderColorClick); + // + // panelColor + // + this.panelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelColor.Location = new System.Drawing.Point(403, 25); + this.panelColor.Name = "panelColor"; + this.panelColor.Size = new System.Drawing.Size(21, 20); + this.panelColor.TabIndex = 12; + this.panelColor.Click += new System.EventHandler(this.ButtonColorClick); + // + // buttonColor + // + this.buttonColor.Location = new System.Drawing.Point(276, 24); + this.buttonColor.Name = "buttonColor"; + this.buttonColor.Size = new System.Drawing.Size(121, 21); + this.buttonColor.TabIndex = 11; + this.buttonColor.Text = "Color"; + this.buttonColor.UseVisualStyleBackColor = true; + this.buttonColor.Click += new System.EventHandler(this.ButtonColorClick); + // + // pictureBox1 + // + this.pictureBox1.Location = new System.Drawing.Point(4, 126); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(855, 211); + this.pictureBox1.TabIndex = 22; + this.pictureBox1.TabStop = false; + // + // buttonStart + // + this.buttonStart.Location = new System.Drawing.Point(4, 343); + this.buttonStart.Name = "buttonStart"; + this.buttonStart.Size = new System.Drawing.Size(121, 21); + this.buttonStart.TabIndex = 24; + this.buttonStart.Text = "&Start"; + this.buttonStart.UseVisualStyleBackColor = true; + this.buttonStart.Click += new System.EventHandler(this.ButtonStartClick); + // + // timer1 + // + this.timer1.Interval = 25; + this.timer1.Tick += new System.EventHandler(this.Timer1Tick); + // + // Beamer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(862, 376); + this.Controls.Add(this.buttonStart); + this.Controls.Add(this.groupBoxImageSettings); + this.Controls.Add(this.pictureBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Beamer"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Beamer"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BeamerFormClosing); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.BeamerKeyDown); + this.groupBoxImageSettings.ResumeLayout(false); + this.groupBoxImageSettings.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxImageSettings; + private System.Windows.Forms.Label labelSubtitleFontSize; + private System.Windows.Forms.ComboBox comboBoxSubtitleFont; + private System.Windows.Forms.ComboBox comboBoxSubtitleFontSize; + private System.Windows.Forms.Label labelSubtitleFont; + private System.Windows.Forms.Label labelBorderWidth; + private System.Windows.Forms.ComboBox comboBoxBorderWidth; + private System.Windows.Forms.Panel panelBorderColor; + private System.Windows.Forms.Button buttonBorderColor; + private System.Windows.Forms.Panel panelColor; + private System.Windows.Forms.Button buttonColor; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Button buttonStart; + private System.Windows.Forms.ColorDialog colorDialog1; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.ComboBox comboBoxHAlign; + private System.Windows.Forms.Label labelHorizontalAlign; + } } \ No newline at end of file diff --git a/src/Forms/Beamer.cs b/src/ui/Forms/Beamer.cs similarity index 97% rename from src/Forms/Beamer.cs rename to src/ui/Forms/Beamer.cs index fd768be68..3aeb6bae1 100644 --- a/src/Forms/Beamer.cs +++ b/src/ui/Forms/Beamer.cs @@ -1,767 +1,767 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Text; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class Beamer : Form - { - private readonly Subtitle _subtitle; - private int _index; - private bool _fullscreen; - private Color _subtitleColor; - private string _subtitleFontName; - private float _subtitleFontSize; - private Color _borderColor; - private float _borderWidth; - private readonly bool _isLoading; - private int _marginLeft; - private int _marginBottom = 25; - private int _showIndex = -2; - private double _millisecondsFactor = 1.0; - private readonly Main _main; - private bool _noTimerAction; - private long _videoStartTick; - private readonly Keys _mainGeneralGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle); - - public Beamer(Main main, Subtitle subtitle, int index) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _main = main; - _subtitle = subtitle; - _index = index; - _isLoading = true; - _subtitleColor = Color.White; - _subtitleFontName = "Verdana"; - _subtitleFontSize = 75.0f; - _borderColor = Color.Black; - _borderWidth = 2.0f; - - var language = Configuration.Settings.Language.Beamer; - Text = language.Title; - groupBoxImageSettings.Text = Configuration.Settings.Language.ExportPngXml.ImageSettings; - labelSubtitleFont.Text = Configuration.Settings.Language.ExportPngXml.FontFamily; - labelSubtitleFontSize.Text = Configuration.Settings.Language.ExportPngXml.FontSize; - buttonColor.Text = Configuration.Settings.Language.ExportPngXml.FontColor; - buttonBorderColor.Text = Configuration.Settings.Language.ExportPngXml.BorderColor; - labelBorderWidth.Text = Configuration.Settings.Language.ExportPngXml.BorderWidth; - - _subtitleFontName = Configuration.Settings.SubtitleBeaming.FontName; - _subtitleFontSize = Configuration.Settings.SubtitleBeaming.FontSize; - if (_subtitleFontSize > 100 || _subtitleFontSize < 10) - { - _subtitleFontSize = 60; - } - _subtitleColor = Configuration.Settings.SubtitleBeaming.FontColor; - _borderColor = Configuration.Settings.SubtitleBeaming.BorderColor; - _borderWidth = Configuration.Settings.SubtitleBeaming.BorderWidth; - - panelColor.BackColor = _subtitleColor; - panelBorderColor.BackColor = _borderColor; - - if (Configuration.Settings.SubtitleBeaming.BorderWidth > 0 && Configuration.Settings.SubtitleBeaming.BorderWidth < 5) - { - comboBoxBorderWidth.SelectedIndex = (int)_borderWidth; - } - else - { - comboBoxBorderWidth.SelectedIndex = 2; - } - - comboBoxHAlign.SelectedIndexChanged -= ComboBoxHAlignSelectedIndexChanged; - comboBoxHAlign.SelectedIndex = 1; - comboBoxHAlign.SelectedIndexChanged += ComboBoxHAlignSelectedIndexChanged; - - comboBoxSubtitleFont.SelectedIndexChanged -= ComboBoxSubtitleFontSizeSelectedIndexChanged; - foreach (var x in FontFamily.Families) - { - comboBoxSubtitleFont.Items.Add(x.Name); - if (x.Name.Equals(_subtitleFontName, StringComparison.OrdinalIgnoreCase)) - { - comboBoxSubtitleFont.SelectedIndex = comboBoxSubtitleFont.Items.Count - 1; - } - } - comboBoxSubtitleFont.SelectedIndexChanged += ComboBoxSubtitleFontSizeSelectedIndexChanged; - - comboBoxSubtitleFontSize.SelectedIndex = (_subtitleFontSize >= 10 && _subtitleFontSize <= 100) ? (int)(_subtitleFontSize - 10) : 40; - _isLoading = false; - ShowCurrent(); - } - - private void ButtonColorClick(object sender, EventArgs e) - { - colorDialog1.Color = panelColor.BackColor; - if (colorDialog1.ShowDialog() == DialogResult.OK) - { - panelColor.BackColor = colorDialog1.Color; - ShowCurrent(); - } - } - - private void ButtonBorderColorClick(object sender, EventArgs e) - { - colorDialog1.Color = panelBorderColor.BackColor; - if (colorDialog1.ShowDialog() == DialogResult.OK) - { - panelBorderColor.BackColor = colorDialog1.Color; - ShowCurrent(); - } - } - - private void ComboBoxSubtitleFontSelectedValueChanged(object sender, EventArgs e) - { - ShowCurrent(); - } - - private void ComboBoxSubtitleFontSizeSelectedIndexChanged(object sender, EventArgs e) - { - ShowCurrent(); - } - - private void ComboBoxBorderWidthSelectedIndexChanged(object sender, EventArgs e) - { - ShowCurrent(); - } - - private void ShowCurrent() - { - SetupImageParameters(); - if (_fullscreen) - { - if (_index > 0 && _index < _subtitle.Paragraphs.Count) - { - string text = _subtitle.Paragraphs[_index].Text; - var bmp = GenerateImageFromTextWithStyle(text); - pictureBox1.Image = bmp; - pictureBox1.Height = bmp.Height; - pictureBox1.Width = bmp.Width; - pictureBox1.Left = (Width - bmp.Width) / 2 + _marginLeft; - pictureBox1.Top = Height - (pictureBox1.Height + _marginBottom); - _showIndex = _index; - _main.FocusParagraph(_index); - } - else - { - pictureBox1.Image = null; - } - } - else - { - string text = "Testing 123" + Environment.NewLine + "Subtitle Edit"; - if (_index >= 0 && _index < _subtitle.Paragraphs.Count && _subtitle.Paragraphs[_index].Text.Length > 1) - { - text = _subtitle.Paragraphs[_index].Text; - _main.FocusParagraph(_index); - } - var bmp = GenerateImageFromTextWithStyle(text); - pictureBox1.Top = groupBoxImageSettings.Top + groupBoxImageSettings.Height + 5; - // Alignment direction. - switch (comboBoxHAlign.SelectedIndex) - { - case 0: // Left. - pictureBox1.Left = 5; - break; - case 1: // Center. - pictureBox1.Left = ((groupBoxImageSettings.Width - bmp.Width) / 2); - break; - case 2: // Right. - pictureBox1.Left = groupBoxImageSettings.Width - bmp.Width; - break; - } - pictureBox1.Image = bmp; - pictureBox1.Height = bmp.Height; - pictureBox1.Width = bmp.Width; - _showIndex = -2; - } - } - - private void SetupImageParameters() - { - if (_isLoading) - { - return; - } - - _subtitleColor = panelColor.BackColor; - _borderColor = panelBorderColor.BackColor; - _subtitleFontName = comboBoxSubtitleFont.SelectedItem.ToString(); - _subtitleFontSize = float.Parse(comboBoxSubtitleFontSize.SelectedItem.ToString()); - _borderWidth = float.Parse(comboBoxBorderWidth.SelectedItem.ToString()); - } - - private Bitmap GenerateImageFromTextWithStyle(string text) - { - const bool subtitleFontBold = false; - bool subtitleAlignLeft = comboBoxHAlign.SelectedIndex == 0; - - // remove styles for display text (except italic) - text = Utilities.RemoveSsaTags(text); - text = text.Replace("", string.Empty); - text = text.Replace("", string.Empty); - text = text.Replace("", string.Empty); - text = text.Replace("", string.Empty); - text = text.Replace("", string.Empty); - text = text.Replace("", string.Empty); - text = text.Replace("", string.Empty); - text = text.Replace("", string.Empty); - - Font font; - try - { - font = new Font(_subtitleFontName, _subtitleFontSize, FontStyle.Regular); - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - font = new Font(FontFamily.Families[0].Name, _subtitleFontSize); - } - var bmp = new Bitmap(400, 200); - var g = Graphics.FromImage(bmp); - - SizeF textSize = g.MeasureString("Hj!", font); - var lineHeight = (textSize.Height * 0.64f); - - textSize = g.MeasureString(HtmlUtil.RemoveHtmlTags(text), font); - g.Dispose(); - bmp.Dispose(); - int sizeX = (int)(textSize.Width * 0.8) + 40; - int sizeY = (int)(textSize.Height * 0.8) + 30; - if (sizeX < 1) - { - sizeX = 1; - } - if (sizeY < 1) - { - sizeY = 1; - } - bmp = new Bitmap(sizeX, sizeY); - g = Graphics.FromImage(bmp); - - var lefts = new List(); - foreach (var line in HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagItalic, HtmlUtil.TagFont).SplitToLines()) - { - if (subtitleAlignLeft) - { - lefts.Add(5); - } - else - { - lefts.Add((float)(bmp.Width - g.MeasureString(line, font).Width * 0.8 + 15) / 2); - } - } - - g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; - g.SmoothingMode = SmoothingMode.AntiAlias; - g.CompositingQuality = CompositingQuality.HighQuality; - - var sf = new StringFormat - { - Alignment = StringAlignment.Near, - LineAlignment = StringAlignment.Near - }; - // draw the text to a path - var path = new GraphicsPath(); - - // display italic - var sb = new StringBuilder(); - int i = 0; - bool isItalic = false; - float left = 5; - if (lefts.Count > 0) - { - left = lefts[0]; - } - float top = 5; - bool newLine = false; - int lineNumber = 0; - float leftMargin = left; - int newLinePathPoint = -1; - Color c = _subtitleColor; - var colorStack = new Stack(); - var lastText = new StringBuilder(); - while (i < text.Length) - { - if (text.Substring(i).StartsWith(" 0) - { - TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - if (path.PointCount > 0) - { - PointF[] list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! - for (int k = oldPathPointIndex; k < list.Length; k++) - { - if (list[k].X > addLeft) - { - addLeft = list[k].X; - } - } - } - if (Math.Abs(addLeft) < 0.001) - { - addLeft = left + 2; - } - left = addLeft; - - if (_borderWidth > 0) - { - g.DrawPath(new Pen(_borderColor, _borderWidth), path); - } - - g.FillPath(new SolidBrush(c), path); - path.Reset(); - path = new GraphicsPath(); - sb.Clear(); - - int endIndex = text.Substring(i).IndexOf('>'); - if (endIndex < 0) - { - i += 9999; - } - else - { - string fontContent = text.Substring(i, endIndex); - if (fontContent.Contains(" color=", StringComparison.OrdinalIgnoreCase)) - { - var arr = fontContent.Substring(fontContent.IndexOf(" color=", StringComparison.OrdinalIgnoreCase) + 7).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - if (arr.Length > 0) - { - string fontColor = arr[0].Trim('\'').Trim('"').Trim('\''); - try - { - colorStack.Push(c); // save old color - if (fontColor.StartsWith("rgb(", StringComparison.OrdinalIgnoreCase)) - { - arr = fontColor.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); - } - else - { - c = ColorTranslator.FromHtml(fontColor); - } - } - catch - { - c = _subtitleColor; - } - } - } - i += endIndex; - } - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - if (text.Substring(i).ToLowerInvariant().Replace("", string.Empty).Replace("", string.Empty).Length > 0) - { - if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) - { - string t = sb.ToString(); - sb.Clear(); - sb.Append(' '); - sb.Append(t); - } - - float addLeft = 0; - int oldPathPointIndex = path.PointCount - 1; - if (oldPathPointIndex < 0) - { - oldPathPointIndex = 0; - } - if (sb.Length > 0) - { - TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - if (path.PointCount > 0) - { - PointF[] list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! - for (int k = oldPathPointIndex; k < list.Length; k++) - { - if (list[k].X > addLeft) - { - addLeft = list[k].X; - } - } - } - if (Math.Abs(addLeft) < 0.001) - { - addLeft = left + 2; - } - left = addLeft; - - if (_borderWidth > 0) - { - g.DrawPath(new Pen(_borderColor, _borderWidth), path); - } - g.FillPath(new SolidBrush(c), path); - path.Reset(); - sb.Clear(); - if (colorStack.Count > 0) - { - c = colorStack.Pop(); - } - } - i += 6; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - if (sb.Length > 0) - { - TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - isItalic = true; - i += 2; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) && isItalic) - { - if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) - { - string t = sb.ToString(); - sb.Clear(); - sb.Append(' '); - sb.Append(t); - } - TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - isItalic = false; - i += 3; - } - else if (text.Substring(i).StartsWith(Environment.NewLine, StringComparison.Ordinal)) - { - TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - top += lineHeight; - newLine = true; - i += Environment.NewLine.Length - 1; - lineNumber++; - if (lineNumber < lefts.Count) - { - leftMargin = lefts[lineNumber]; - left = leftMargin; - } - } - else - { - sb.Append(text[i]); - } - i++; - } - if (sb.Length > 0) - { - TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - sf.Dispose(); - - if (_borderWidth > 0) - { - g.DrawPath(new Pen(_borderColor, _borderWidth), path); - } - g.FillPath(new SolidBrush(c), path); - g.Dispose(); - var nbmp = new NikseBitmap(bmp); - nbmp.CropTransparentSidesAndBottom(2, true); - return nbmp.GetBitmap(); - } - - private void Timer1Tick(object sender, EventArgs e) - { - if (_noTimerAction) - { - return; - } - - double positionInMilliseconds = (DateTime.Now.Ticks - _videoStartTick) / 10000.0D; // 10,000 ticks = 1 millisecond - positionInMilliseconds *= _millisecondsFactor; - int index = 0; - foreach (Paragraph p in _subtitle.Paragraphs) - { - if (p.StartTime.TotalMilliseconds <= positionInMilliseconds && - p.EndTime.TotalMilliseconds > positionInMilliseconds) - { - break; - } - index++; - } - if (index == _subtitle.Paragraphs.Count) - { - index = -1; - } - if (index == -1) - { - pictureBox1.Image = null; - } - else if (index != _showIndex) - { - _index = index; - ShowCurrent(); - } - } - - private void ButtonStartClick(object sender, EventArgs e) - { - if (_index >= _subtitle.Paragraphs.Count - 1) - { - _index = -1; - _videoStartTick = DateTime.Now.Ticks; - } - else if (_index >= 0) - { - _videoStartTick = DateTime.Now.Ticks - ((long)(_subtitle.Paragraphs[_index].StartTime.TotalMilliseconds) * 10000); //10,000 ticks = 1 millisecond - } - - groupBoxImageSettings.Hide(); - buttonStart.Hide(); - FormBorderStyle = FormBorderStyle.None; - BackColor = Color.Black; - WindowState = FormWindowState.Maximized; - _fullscreen = true; - pictureBox1.Image = null; - Cursor.Hide(); - _marginBottom = Height - 200; - timer1.Start(); - } - - private void BeamerKeyDown(object sender, KeyEventArgs e) - { - if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Home) - { - _index = 0; - ShowCurrent(); - e.SuppressKeyPress = true; - return; - } - if (e.Modifiers == Keys.Control && e.KeyCode == Keys.End) - { - _index = _subtitle.Paragraphs.Count - 1; - ShowCurrent(); - e.SuppressKeyPress = true; - return; - } - - if (!_fullscreen) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == Keys.Space || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt) || _mainGeneralGoToPrevSubtitle == e.KeyData) - { - if (_index < _subtitle.Paragraphs.Count - 1) - { - _index++; - } - ShowCurrent(); - e.SuppressKeyPress = true; - } - else if (_mainGeneralGoToPrevSubtitle == e.KeyData || (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt)) - { - if (_index > 0) - { - _index--; - } - ShowCurrent(); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.PageDown) - { - if (_index < _subtitle.Paragraphs.Count - 21) - { - _index += 20; - } - else - { - _index = _subtitle.Paragraphs.Count - 1; - } - ShowCurrent(); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.PageUp) - { - if (_index > 20) - { - _index -= 20; - } - else - { - _index = 0; - } - ShowCurrent(); - e.SuppressKeyPress = true; - } - return; - } - - if (e.KeyCode == Keys.Escape) - { - groupBoxImageSettings.Show(); - buttonStart.Show(); - timer1.Stop(); - Cursor.Show(); - FormBorderStyle = FormBorderStyle.FixedDialog; - BackColor = DefaultBackColor; - WindowState = FormWindowState.Normal; - _showIndex = -2; - _fullscreen = false; - ShowCurrent(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.Pause) - { - timer1.Stop(); - timer1.Enabled = false; - } - else if (e.KeyCode == Keys.Space || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)) - { - bool timer1Enabled = timer1.Enabled; - timer1.Enabled = false; - System.Threading.Thread.Sleep(100); - if (_index < _subtitle.Paragraphs.Count - 1) - { - _index++; - } - _videoStartTick = DateTime.Now.Ticks - ((long)(_subtitle.Paragraphs[_index].StartTime.TotalMilliseconds) * 10000); //10,000 ticks = 1 millisecond - - ShowCurrent(); - _noTimerAction = false; - if (timer1Enabled || _fullscreen) - { - timer1.Start(); - } - - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt) - { - bool timer1Enabled = timer1.Enabled; - timer1.Enabled = false; - System.Threading.Thread.Sleep(100); - if (_index > 0) - { - _index--; - } - _videoStartTick = DateTime.Now.Ticks - ((long)(_subtitle.Paragraphs[_index].StartTime.TotalMilliseconds) * 10000); //10,000 ticks = 1 millisecond - ShowCurrent(); - if (timer1Enabled) - { - timer1.Start(); - } - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.PageDown) - { - if (_index < _subtitle.Paragraphs.Count - 21) - { - _index += 20; - } - else - { - _index = _subtitle.Paragraphs.Count - 1; - } - ShowCurrent(); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.PageUp) - { - if (_index > 20) - { - _index -= 20; - } - else - { - _index = 0; - } - ShowCurrent(); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Add) - { - if (comboBoxSubtitleFontSize.SelectedIndex < comboBoxSubtitleFontSize.Items.Count - 1) - { - comboBoxSubtitleFontSize.SelectedIndex = comboBoxSubtitleFontSize.SelectedIndex + 1; - ShowCurrent(); - } - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Subtract) - { - if (comboBoxSubtitleFontSize.SelectedIndex > 0) - { - comboBoxSubtitleFontSize.SelectedIndex = comboBoxSubtitleFontSize.SelectedIndex - 1; - ShowCurrent(); - } - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Add) - { - _millisecondsFactor += 0.001; - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Subtract) - { - _millisecondsFactor -= 0.001; - } - else if (e.KeyCode == Keys.Up) - { - _marginBottom++; - ShowCurrent(); - } - else if (e.KeyCode == Keys.Down) - { - _marginBottom--; - ShowCurrent(); - } - else if (e.KeyCode == Keys.Left) - { - _marginLeft--; - ShowCurrent(); - } - else if (e.KeyCode == Keys.Right) - { - _marginLeft++; - ShowCurrent(); - } - else if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete) - { - timer1.Stop(); - int temp = _index; - _index = -1; - try - { - ShowCurrent(); - } - finally - { - _index = temp; - } - } - } - - private void BeamerFormClosing(object sender, FormClosingEventArgs e) - { - Cursor.Show(); - - // Save user-configurations. - Configuration.Settings.SubtitleBeaming.FontName = _subtitleFontName; - Configuration.Settings.SubtitleBeaming.FontSize = (int)_subtitleFontSize; - Configuration.Settings.SubtitleBeaming.FontColor = _subtitleColor; - Configuration.Settings.SubtitleBeaming.BorderColor = _borderColor; - Configuration.Settings.SubtitleBeaming.BorderWidth = (int)_borderWidth; - } - - private void ComboBoxHAlignSelectedIndexChanged(object sender, EventArgs e) - { - ShowCurrent(); - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Text; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class Beamer : Form + { + private readonly Subtitle _subtitle; + private int _index; + private bool _fullscreen; + private Color _subtitleColor; + private string _subtitleFontName; + private float _subtitleFontSize; + private Color _borderColor; + private float _borderWidth; + private readonly bool _isLoading; + private int _marginLeft; + private int _marginBottom = 25; + private int _showIndex = -2; + private double _millisecondsFactor = 1.0; + private readonly Main _main; + private bool _noTimerAction; + private long _videoStartTick; + private readonly Keys _mainGeneralGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle); + + public Beamer(Main main, Subtitle subtitle, int index) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _main = main; + _subtitle = subtitle; + _index = index; + _isLoading = true; + _subtitleColor = Color.White; + _subtitleFontName = "Verdana"; + _subtitleFontSize = 75.0f; + _borderColor = Color.Black; + _borderWidth = 2.0f; + + var language = Configuration.Settings.Language.Beamer; + Text = language.Title; + groupBoxImageSettings.Text = Configuration.Settings.Language.ExportPngXml.ImageSettings; + labelSubtitleFont.Text = Configuration.Settings.Language.ExportPngXml.FontFamily; + labelSubtitleFontSize.Text = Configuration.Settings.Language.ExportPngXml.FontSize; + buttonColor.Text = Configuration.Settings.Language.ExportPngXml.FontColor; + buttonBorderColor.Text = Configuration.Settings.Language.ExportPngXml.BorderColor; + labelBorderWidth.Text = Configuration.Settings.Language.ExportPngXml.BorderWidth; + + _subtitleFontName = Configuration.Settings.SubtitleBeaming.FontName; + _subtitleFontSize = Configuration.Settings.SubtitleBeaming.FontSize; + if (_subtitleFontSize > 100 || _subtitleFontSize < 10) + { + _subtitleFontSize = 60; + } + _subtitleColor = Configuration.Settings.SubtitleBeaming.FontColor; + _borderColor = Configuration.Settings.SubtitleBeaming.BorderColor; + _borderWidth = Configuration.Settings.SubtitleBeaming.BorderWidth; + + panelColor.BackColor = _subtitleColor; + panelBorderColor.BackColor = _borderColor; + + if (Configuration.Settings.SubtitleBeaming.BorderWidth > 0 && Configuration.Settings.SubtitleBeaming.BorderWidth < 5) + { + comboBoxBorderWidth.SelectedIndex = (int)_borderWidth; + } + else + { + comboBoxBorderWidth.SelectedIndex = 2; + } + + comboBoxHAlign.SelectedIndexChanged -= ComboBoxHAlignSelectedIndexChanged; + comboBoxHAlign.SelectedIndex = 1; + comboBoxHAlign.SelectedIndexChanged += ComboBoxHAlignSelectedIndexChanged; + + comboBoxSubtitleFont.SelectedIndexChanged -= ComboBoxSubtitleFontSizeSelectedIndexChanged; + foreach (var x in FontFamily.Families) + { + comboBoxSubtitleFont.Items.Add(x.Name); + if (x.Name.Equals(_subtitleFontName, StringComparison.OrdinalIgnoreCase)) + { + comboBoxSubtitleFont.SelectedIndex = comboBoxSubtitleFont.Items.Count - 1; + } + } + comboBoxSubtitleFont.SelectedIndexChanged += ComboBoxSubtitleFontSizeSelectedIndexChanged; + + comboBoxSubtitleFontSize.SelectedIndex = (_subtitleFontSize >= 10 && _subtitleFontSize <= 100) ? (int)(_subtitleFontSize - 10) : 40; + _isLoading = false; + ShowCurrent(); + } + + private void ButtonColorClick(object sender, EventArgs e) + { + colorDialog1.Color = panelColor.BackColor; + if (colorDialog1.ShowDialog() == DialogResult.OK) + { + panelColor.BackColor = colorDialog1.Color; + ShowCurrent(); + } + } + + private void ButtonBorderColorClick(object sender, EventArgs e) + { + colorDialog1.Color = panelBorderColor.BackColor; + if (colorDialog1.ShowDialog() == DialogResult.OK) + { + panelBorderColor.BackColor = colorDialog1.Color; + ShowCurrent(); + } + } + + private void ComboBoxSubtitleFontSelectedValueChanged(object sender, EventArgs e) + { + ShowCurrent(); + } + + private void ComboBoxSubtitleFontSizeSelectedIndexChanged(object sender, EventArgs e) + { + ShowCurrent(); + } + + private void ComboBoxBorderWidthSelectedIndexChanged(object sender, EventArgs e) + { + ShowCurrent(); + } + + private void ShowCurrent() + { + SetupImageParameters(); + if (_fullscreen) + { + if (_index > 0 && _index < _subtitle.Paragraphs.Count) + { + string text = _subtitle.Paragraphs[_index].Text; + var bmp = GenerateImageFromTextWithStyle(text); + pictureBox1.Image = bmp; + pictureBox1.Height = bmp.Height; + pictureBox1.Width = bmp.Width; + pictureBox1.Left = (Width - bmp.Width) / 2 + _marginLeft; + pictureBox1.Top = Height - (pictureBox1.Height + _marginBottom); + _showIndex = _index; + _main.FocusParagraph(_index); + } + else + { + pictureBox1.Image = null; + } + } + else + { + string text = "Testing 123" + Environment.NewLine + "Subtitle Edit"; + if (_index >= 0 && _index < _subtitle.Paragraphs.Count && _subtitle.Paragraphs[_index].Text.Length > 1) + { + text = _subtitle.Paragraphs[_index].Text; + _main.FocusParagraph(_index); + } + var bmp = GenerateImageFromTextWithStyle(text); + pictureBox1.Top = groupBoxImageSettings.Top + groupBoxImageSettings.Height + 5; + // Alignment direction. + switch (comboBoxHAlign.SelectedIndex) + { + case 0: // Left. + pictureBox1.Left = 5; + break; + case 1: // Center. + pictureBox1.Left = ((groupBoxImageSettings.Width - bmp.Width) / 2); + break; + case 2: // Right. + pictureBox1.Left = groupBoxImageSettings.Width - bmp.Width; + break; + } + pictureBox1.Image = bmp; + pictureBox1.Height = bmp.Height; + pictureBox1.Width = bmp.Width; + _showIndex = -2; + } + } + + private void SetupImageParameters() + { + if (_isLoading) + { + return; + } + + _subtitleColor = panelColor.BackColor; + _borderColor = panelBorderColor.BackColor; + _subtitleFontName = comboBoxSubtitleFont.SelectedItem.ToString(); + _subtitleFontSize = float.Parse(comboBoxSubtitleFontSize.SelectedItem.ToString()); + _borderWidth = float.Parse(comboBoxBorderWidth.SelectedItem.ToString()); + } + + private Bitmap GenerateImageFromTextWithStyle(string text) + { + const bool subtitleFontBold = false; + bool subtitleAlignLeft = comboBoxHAlign.SelectedIndex == 0; + + // remove styles for display text (except italic) + text = Utilities.RemoveSsaTags(text); + text = text.Replace("", string.Empty); + text = text.Replace("", string.Empty); + text = text.Replace("", string.Empty); + text = text.Replace("", string.Empty); + text = text.Replace("", string.Empty); + text = text.Replace("", string.Empty); + text = text.Replace("", string.Empty); + text = text.Replace("", string.Empty); + + Font font; + try + { + font = new Font(_subtitleFontName, _subtitleFontSize, FontStyle.Regular); + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + font = new Font(FontFamily.Families[0].Name, _subtitleFontSize); + } + var bmp = new Bitmap(400, 200); + var g = Graphics.FromImage(bmp); + + SizeF textSize = g.MeasureString("Hj!", font); + var lineHeight = (textSize.Height * 0.64f); + + textSize = g.MeasureString(HtmlUtil.RemoveHtmlTags(text), font); + g.Dispose(); + bmp.Dispose(); + int sizeX = (int)(textSize.Width * 0.8) + 40; + int sizeY = (int)(textSize.Height * 0.8) + 30; + if (sizeX < 1) + { + sizeX = 1; + } + if (sizeY < 1) + { + sizeY = 1; + } + bmp = new Bitmap(sizeX, sizeY); + g = Graphics.FromImage(bmp); + + var lefts = new List(); + foreach (var line in HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagItalic, HtmlUtil.TagFont).SplitToLines()) + { + if (subtitleAlignLeft) + { + lefts.Add(5); + } + else + { + lefts.Add((float)(bmp.Width - g.MeasureString(line, font).Width * 0.8 + 15) / 2); + } + } + + g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; + g.SmoothingMode = SmoothingMode.AntiAlias; + g.CompositingQuality = CompositingQuality.HighQuality; + + var sf = new StringFormat + { + Alignment = StringAlignment.Near, + LineAlignment = StringAlignment.Near + }; + // draw the text to a path + var path = new GraphicsPath(); + + // display italic + var sb = new StringBuilder(); + int i = 0; + bool isItalic = false; + float left = 5; + if (lefts.Count > 0) + { + left = lefts[0]; + } + float top = 5; + bool newLine = false; + int lineNumber = 0; + float leftMargin = left; + int newLinePathPoint = -1; + Color c = _subtitleColor; + var colorStack = new Stack(); + var lastText = new StringBuilder(); + while (i < text.Length) + { + if (text.Substring(i).StartsWith(" 0) + { + TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + if (path.PointCount > 0) + { + PointF[] list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! + for (int k = oldPathPointIndex; k < list.Length; k++) + { + if (list[k].X > addLeft) + { + addLeft = list[k].X; + } + } + } + if (Math.Abs(addLeft) < 0.001) + { + addLeft = left + 2; + } + left = addLeft; + + if (_borderWidth > 0) + { + g.DrawPath(new Pen(_borderColor, _borderWidth), path); + } + + g.FillPath(new SolidBrush(c), path); + path.Reset(); + path = new GraphicsPath(); + sb.Clear(); + + int endIndex = text.Substring(i).IndexOf('>'); + if (endIndex < 0) + { + i += 9999; + } + else + { + string fontContent = text.Substring(i, endIndex); + if (fontContent.Contains(" color=", StringComparison.OrdinalIgnoreCase)) + { + var arr = fontContent.Substring(fontContent.IndexOf(" color=", StringComparison.OrdinalIgnoreCase) + 7).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + if (arr.Length > 0) + { + string fontColor = arr[0].Trim('\'').Trim('"').Trim('\''); + try + { + colorStack.Push(c); // save old color + if (fontColor.StartsWith("rgb(", StringComparison.OrdinalIgnoreCase)) + { + arr = fontColor.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); + } + else + { + c = ColorTranslator.FromHtml(fontColor); + } + } + catch + { + c = _subtitleColor; + } + } + } + i += endIndex; + } + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + if (text.Substring(i).ToLowerInvariant().Replace("", string.Empty).Replace("", string.Empty).Length > 0) + { + if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) + { + string t = sb.ToString(); + sb.Clear(); + sb.Append(' '); + sb.Append(t); + } + + float addLeft = 0; + int oldPathPointIndex = path.PointCount - 1; + if (oldPathPointIndex < 0) + { + oldPathPointIndex = 0; + } + if (sb.Length > 0) + { + TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + if (path.PointCount > 0) + { + PointF[] list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! + for (int k = oldPathPointIndex; k < list.Length; k++) + { + if (list[k].X > addLeft) + { + addLeft = list[k].X; + } + } + } + if (Math.Abs(addLeft) < 0.001) + { + addLeft = left + 2; + } + left = addLeft; + + if (_borderWidth > 0) + { + g.DrawPath(new Pen(_borderColor, _borderWidth), path); + } + g.FillPath(new SolidBrush(c), path); + path.Reset(); + sb.Clear(); + if (colorStack.Count > 0) + { + c = colorStack.Pop(); + } + } + i += 6; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + if (sb.Length > 0) + { + TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + isItalic = true; + i += 2; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) && isItalic) + { + if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) + { + string t = sb.ToString(); + sb.Clear(); + sb.Append(' '); + sb.Append(t); + } + TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + isItalic = false; + i += 3; + } + else if (text.Substring(i).StartsWith(Environment.NewLine, StringComparison.Ordinal)) + { + TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + top += lineHeight; + newLine = true; + i += Environment.NewLine.Length - 1; + lineNumber++; + if (lineNumber < lefts.Count) + { + leftMargin = lefts[lineNumber]; + left = leftMargin; + } + } + else + { + sb.Append(text[i]); + } + i++; + } + if (sb.Length > 0) + { + TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + sf.Dispose(); + + if (_borderWidth > 0) + { + g.DrawPath(new Pen(_borderColor, _borderWidth), path); + } + g.FillPath(new SolidBrush(c), path); + g.Dispose(); + var nbmp = new NikseBitmap(bmp); + nbmp.CropTransparentSidesAndBottom(2, true); + return nbmp.GetBitmap(); + } + + private void Timer1Tick(object sender, EventArgs e) + { + if (_noTimerAction) + { + return; + } + + double positionInMilliseconds = (DateTime.Now.Ticks - _videoStartTick) / 10000.0D; // 10,000 ticks = 1 millisecond + positionInMilliseconds *= _millisecondsFactor; + int index = 0; + foreach (Paragraph p in _subtitle.Paragraphs) + { + if (p.StartTime.TotalMilliseconds <= positionInMilliseconds && + p.EndTime.TotalMilliseconds > positionInMilliseconds) + { + break; + } + index++; + } + if (index == _subtitle.Paragraphs.Count) + { + index = -1; + } + if (index == -1) + { + pictureBox1.Image = null; + } + else if (index != _showIndex) + { + _index = index; + ShowCurrent(); + } + } + + private void ButtonStartClick(object sender, EventArgs e) + { + if (_index >= _subtitle.Paragraphs.Count - 1) + { + _index = -1; + _videoStartTick = DateTime.Now.Ticks; + } + else if (_index >= 0) + { + _videoStartTick = DateTime.Now.Ticks - ((long)(_subtitle.Paragraphs[_index].StartTime.TotalMilliseconds) * 10000); //10,000 ticks = 1 millisecond + } + + groupBoxImageSettings.Hide(); + buttonStart.Hide(); + FormBorderStyle = FormBorderStyle.None; + BackColor = Color.Black; + WindowState = FormWindowState.Maximized; + _fullscreen = true; + pictureBox1.Image = null; + Cursor.Hide(); + _marginBottom = Height - 200; + timer1.Start(); + } + + private void BeamerKeyDown(object sender, KeyEventArgs e) + { + if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Home) + { + _index = 0; + ShowCurrent(); + e.SuppressKeyPress = true; + return; + } + if (e.Modifiers == Keys.Control && e.KeyCode == Keys.End) + { + _index = _subtitle.Paragraphs.Count - 1; + ShowCurrent(); + e.SuppressKeyPress = true; + return; + } + + if (!_fullscreen) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == Keys.Space || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt) || _mainGeneralGoToPrevSubtitle == e.KeyData) + { + if (_index < _subtitle.Paragraphs.Count - 1) + { + _index++; + } + ShowCurrent(); + e.SuppressKeyPress = true; + } + else if (_mainGeneralGoToPrevSubtitle == e.KeyData || (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt)) + { + if (_index > 0) + { + _index--; + } + ShowCurrent(); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.PageDown) + { + if (_index < _subtitle.Paragraphs.Count - 21) + { + _index += 20; + } + else + { + _index = _subtitle.Paragraphs.Count - 1; + } + ShowCurrent(); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.PageUp) + { + if (_index > 20) + { + _index -= 20; + } + else + { + _index = 0; + } + ShowCurrent(); + e.SuppressKeyPress = true; + } + return; + } + + if (e.KeyCode == Keys.Escape) + { + groupBoxImageSettings.Show(); + buttonStart.Show(); + timer1.Stop(); + Cursor.Show(); + FormBorderStyle = FormBorderStyle.FixedDialog; + BackColor = DefaultBackColor; + WindowState = FormWindowState.Normal; + _showIndex = -2; + _fullscreen = false; + ShowCurrent(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.Pause) + { + timer1.Stop(); + timer1.Enabled = false; + } + else if (e.KeyCode == Keys.Space || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)) + { + bool timer1Enabled = timer1.Enabled; + timer1.Enabled = false; + System.Threading.Thread.Sleep(100); + if (_index < _subtitle.Paragraphs.Count - 1) + { + _index++; + } + _videoStartTick = DateTime.Now.Ticks - ((long)(_subtitle.Paragraphs[_index].StartTime.TotalMilliseconds) * 10000); //10,000 ticks = 1 millisecond + + ShowCurrent(); + _noTimerAction = false; + if (timer1Enabled || _fullscreen) + { + timer1.Start(); + } + + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt) + { + bool timer1Enabled = timer1.Enabled; + timer1.Enabled = false; + System.Threading.Thread.Sleep(100); + if (_index > 0) + { + _index--; + } + _videoStartTick = DateTime.Now.Ticks - ((long)(_subtitle.Paragraphs[_index].StartTime.TotalMilliseconds) * 10000); //10,000 ticks = 1 millisecond + ShowCurrent(); + if (timer1Enabled) + { + timer1.Start(); + } + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.PageDown) + { + if (_index < _subtitle.Paragraphs.Count - 21) + { + _index += 20; + } + else + { + _index = _subtitle.Paragraphs.Count - 1; + } + ShowCurrent(); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.PageUp) + { + if (_index > 20) + { + _index -= 20; + } + else + { + _index = 0; + } + ShowCurrent(); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Add) + { + if (comboBoxSubtitleFontSize.SelectedIndex < comboBoxSubtitleFontSize.Items.Count - 1) + { + comboBoxSubtitleFontSize.SelectedIndex = comboBoxSubtitleFontSize.SelectedIndex + 1; + ShowCurrent(); + } + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Subtract) + { + if (comboBoxSubtitleFontSize.SelectedIndex > 0) + { + comboBoxSubtitleFontSize.SelectedIndex = comboBoxSubtitleFontSize.SelectedIndex - 1; + ShowCurrent(); + } + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Add) + { + _millisecondsFactor += 0.001; + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Subtract) + { + _millisecondsFactor -= 0.001; + } + else if (e.KeyCode == Keys.Up) + { + _marginBottom++; + ShowCurrent(); + } + else if (e.KeyCode == Keys.Down) + { + _marginBottom--; + ShowCurrent(); + } + else if (e.KeyCode == Keys.Left) + { + _marginLeft--; + ShowCurrent(); + } + else if (e.KeyCode == Keys.Right) + { + _marginLeft++; + ShowCurrent(); + } + else if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete) + { + timer1.Stop(); + int temp = _index; + _index = -1; + try + { + ShowCurrent(); + } + finally + { + _index = temp; + } + } + } + + private void BeamerFormClosing(object sender, FormClosingEventArgs e) + { + Cursor.Show(); + + // Save user-configurations. + Configuration.Settings.SubtitleBeaming.FontName = _subtitleFontName; + Configuration.Settings.SubtitleBeaming.FontSize = (int)_subtitleFontSize; + Configuration.Settings.SubtitleBeaming.FontColor = _subtitleColor; + Configuration.Settings.SubtitleBeaming.BorderColor = _borderColor; + Configuration.Settings.SubtitleBeaming.BorderWidth = (int)_borderWidth; + } + + private void ComboBoxHAlignSelectedIndexChanged(object sender, EventArgs e) + { + ShowCurrent(); + } + + } +} diff --git a/src/Forms/Beamer.resx b/src/ui/Forms/Beamer.resx similarity index 97% rename from src/Forms/Beamer.resx rename to src/ui/Forms/Beamer.resx index ea568f77b..21f3cd3ea 100644 --- a/src/Forms/Beamer.resx +++ b/src/ui/Forms/Beamer.resx @@ -1,126 +1,126 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 138, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 138, 17 + \ No newline at end of file diff --git a/src/Forms/BookmarkAdd.Designer.cs b/src/ui/Forms/BookmarkAdd.Designer.cs similarity index 100% rename from src/Forms/BookmarkAdd.Designer.cs rename to src/ui/Forms/BookmarkAdd.Designer.cs diff --git a/src/Forms/BookmarkAdd.cs b/src/ui/Forms/BookmarkAdd.cs similarity index 100% rename from src/Forms/BookmarkAdd.cs rename to src/ui/Forms/BookmarkAdd.cs diff --git a/src/Forms/DialogDoNotShowAgain.resx b/src/ui/Forms/BookmarkAdd.resx similarity index 100% rename from src/Forms/DialogDoNotShowAgain.resx rename to src/ui/Forms/BookmarkAdd.resx diff --git a/src/Forms/BookmarksGoTo.Designer.cs b/src/ui/Forms/BookmarksGoTo.Designer.cs similarity index 100% rename from src/Forms/BookmarksGoTo.Designer.cs rename to src/ui/Forms/BookmarksGoTo.Designer.cs diff --git a/src/Forms/BookmarksGoTo.cs b/src/ui/Forms/BookmarksGoTo.cs similarity index 100% rename from src/Forms/BookmarksGoTo.cs rename to src/ui/Forms/BookmarksGoTo.cs diff --git a/src/Forms/DownloadFfmpeg.resx b/src/ui/Forms/BookmarksGoTo.resx similarity index 100% rename from src/Forms/DownloadFfmpeg.resx rename to src/ui/Forms/BookmarksGoTo.resx diff --git a/src/Forms/Cavena890SaveOptions.Designer.cs b/src/ui/Forms/Cavena890SaveOptions.Designer.cs similarity index 98% rename from src/Forms/Cavena890SaveOptions.Designer.cs rename to src/ui/Forms/Cavena890SaveOptions.Designer.cs index 31ccb519c..f21e330ea 100644 --- a/src/Forms/Cavena890SaveOptions.Designer.cs +++ b/src/ui/Forms/Cavena890SaveOptions.Designer.cs @@ -1,270 +1,270 @@ -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - partial class Cavena890SaveOptions - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - TimeCode timeCode1 = new TimeCode(); - this.labelTimeCodeStartOfProgramme = new System.Windows.Forms.Label(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonImport = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.textBoxComment = new System.Windows.Forms.TextBox(); - this.labelComment = new System.Windows.Forms.Label(); - this.textBoxTranslatedTitle = new System.Windows.Forms.TextBox(); - this.labelTranslatedTitle = new System.Windows.Forms.Label(); - this.textBoxOriginalTitle = new System.Windows.Forms.TextBox(); - this.labelOriginalTitle = new System.Windows.Forms.Label(); - this.textBoxTranslator = new System.Windows.Forms.TextBox(); - this.labelTranslator = new System.Windows.Forms.Label(); - this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.comboBoxLanguage = new System.Windows.Forms.ComboBox(); - this.labelLanguage = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // labelTimeCodeStartOfProgramme - // - this.labelTimeCodeStartOfProgramme.AutoSize = true; - this.labelTimeCodeStartOfProgramme.Location = new System.Drawing.Point(12, 182); - this.labelTimeCodeStartOfProgramme.Name = "labelTimeCodeStartOfProgramme"; - this.labelTimeCodeStartOfProgramme.Size = new System.Drawing.Size(152, 13); - this.labelTimeCodeStartOfProgramme.TabIndex = 10; - this.labelTimeCodeStartOfProgramme.Text = "Time code: Start of programme"; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(250, 262); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 12; - this.buttonOK.Text = "Save"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(331, 262); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 13; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonImport - // - this.buttonImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonImport.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonImport.Location = new System.Drawing.Point(290, 12); - this.buttonImport.Name = "buttonImport"; - this.buttonImport.Size = new System.Drawing.Size(116, 23); - this.buttonImport.TabIndex = 14; - this.buttonImport.Text = "Import..."; - this.buttonImport.UseVisualStyleBackColor = true; - this.buttonImport.Click += new System.EventHandler(this.buttonImport_Click); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // textBoxComment - // - this.textBoxComment.Location = new System.Drawing.Point(185, 119); - this.textBoxComment.MaxLength = 24; - this.textBoxComment.Name = "textBoxComment"; - this.textBoxComment.Size = new System.Drawing.Size(219, 20); - this.textBoxComment.TabIndex = 7; - // - // labelComment - // - this.labelComment.AutoSize = true; - this.labelComment.Location = new System.Drawing.Point(13, 122); - this.labelComment.Name = "labelComment"; - this.labelComment.Size = new System.Drawing.Size(51, 13); - this.labelComment.TabIndex = 6; - this.labelComment.Text = "Comment"; - // - // textBoxTranslatedTitle - // - this.textBoxTranslatedTitle.Location = new System.Drawing.Point(185, 41); - this.textBoxTranslatedTitle.MaxLength = 28; - this.textBoxTranslatedTitle.Name = "textBoxTranslatedTitle"; - this.textBoxTranslatedTitle.Size = new System.Drawing.Size(219, 20); - this.textBoxTranslatedTitle.TabIndex = 1; - // - // labelTranslatedTitle - // - this.labelTranslatedTitle.AutoSize = true; - this.labelTranslatedTitle.Location = new System.Drawing.Point(13, 44); - this.labelTranslatedTitle.Name = "labelTranslatedTitle"; - this.labelTranslatedTitle.Size = new System.Drawing.Size(76, 13); - this.labelTranslatedTitle.TabIndex = 0; - this.labelTranslatedTitle.Text = "Translated title"; - // - // textBoxOriginalTitle - // - this.textBoxOriginalTitle.Location = new System.Drawing.Point(185, 67); - this.textBoxOriginalTitle.MaxLength = 24; - this.textBoxOriginalTitle.Name = "textBoxOriginalTitle"; - this.textBoxOriginalTitle.Size = new System.Drawing.Size(219, 20); - this.textBoxOriginalTitle.TabIndex = 3; - // - // labelOriginalTitle - // - this.labelOriginalTitle.AutoSize = true; - this.labelOriginalTitle.Location = new System.Drawing.Point(13, 70); - this.labelOriginalTitle.Name = "labelOriginalTitle"; - this.labelOriginalTitle.Size = new System.Drawing.Size(61, 13); - this.labelOriginalTitle.TabIndex = 2; - this.labelOriginalTitle.Text = "Original title"; - // - // textBoxTranslator - // - this.textBoxTranslator.Location = new System.Drawing.Point(185, 93); - this.textBoxTranslator.MaxLength = 24; - this.textBoxTranslator.Name = "textBoxTranslator"; - this.textBoxTranslator.Size = new System.Drawing.Size(219, 20); - this.textBoxTranslator.TabIndex = 5; - // - // labelTranslator - // - this.labelTranslator.AutoSize = true; - this.labelTranslator.Location = new System.Drawing.Point(13, 96); - this.labelTranslator.Name = "labelTranslator"; - this.labelTranslator.Size = new System.Drawing.Size(54, 13); - this.labelTranslator.TabIndex = 4; - this.labelTranslator.Text = "Translator"; - // - // timeUpDownStartTime - // - this.timeUpDownStartTime.AutoSize = true; - this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownStartTime.Font = new System.Drawing.Font("Segoe UI", 9F); - this.timeUpDownStartTime.Location = new System.Drawing.Point(183, 177); - this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownStartTime.Name = "timeUpDownStartTime"; - this.timeUpDownStartTime.Size = new System.Drawing.Size(96, 27); - this.timeUpDownStartTime.TabIndex = 11; - timeCode1.Hours = 0; - timeCode1.Milliseconds = 0; - timeCode1.Minutes = 0; - timeCode1.Seconds = 0; - timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode1.TotalMilliseconds = 0D; - timeCode1.TotalSeconds = 0D; - this.timeUpDownStartTime.TimeCode = timeCode1; - this.timeUpDownStartTime.UseVideoOffset = false; - // - // comboBoxLanguage - // - this.comboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxLanguage.FormattingEnabled = true; - this.comboBoxLanguage.Items.AddRange(new object[] { - "Arabic", - "Danish", - "Chinese Simplified", - "Chinese Traditional", - "English", - "Hebrew", - "Russian", - "Romanian"}); - this.comboBoxLanguage.Location = new System.Drawing.Point(185, 149); - this.comboBoxLanguage.Name = "comboBoxLanguage"; - this.comboBoxLanguage.Size = new System.Drawing.Size(219, 21); - this.comboBoxLanguage.TabIndex = 9; - // - // labelLanguage - // - this.labelLanguage.AutoSize = true; - this.labelLanguage.Location = new System.Drawing.Point(16, 152); - this.labelLanguage.Name = "labelLanguage"; - this.labelLanguage.Size = new System.Drawing.Size(55, 13); - this.labelLanguage.TabIndex = 8; - this.labelLanguage.Text = "Language"; - // - // Cavena890SaveOptions - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(418, 297); - this.Controls.Add(this.labelLanguage); - this.Controls.Add(this.comboBoxLanguage); - this.Controls.Add(this.textBoxTranslator); - this.Controls.Add(this.labelTranslator); - this.Controls.Add(this.textBoxOriginalTitle); - this.Controls.Add(this.labelOriginalTitle); - this.Controls.Add(this.textBoxComment); - this.Controls.Add(this.labelComment); - this.Controls.Add(this.textBoxTranslatedTitle); - this.Controls.Add(this.labelTranslatedTitle); - this.Controls.Add(this.buttonImport); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.labelTimeCodeStartOfProgramme); - this.Controls.Add(this.timeUpDownStartTime); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "Cavena890SaveOptions"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Cavena 890 save options"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Cavena890SaveOptions_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelTimeCodeStartOfProgramme; - private Controls.TimeUpDown timeUpDownStartTime; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonImport; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.TextBox textBoxComment; - private System.Windows.Forms.Label labelComment; - private System.Windows.Forms.TextBox textBoxTranslatedTitle; - private System.Windows.Forms.Label labelTranslatedTitle; - private System.Windows.Forms.TextBox textBoxOriginalTitle; - private System.Windows.Forms.Label labelOriginalTitle; - private System.Windows.Forms.TextBox textBoxTranslator; - private System.Windows.Forms.Label labelTranslator; - private System.Windows.Forms.ComboBox comboBoxLanguage; - private System.Windows.Forms.Label labelLanguage; - } +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + partial class Cavena890SaveOptions + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + TimeCode timeCode1 = new TimeCode(); + this.labelTimeCodeStartOfProgramme = new System.Windows.Forms.Label(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonImport = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.textBoxComment = new System.Windows.Forms.TextBox(); + this.labelComment = new System.Windows.Forms.Label(); + this.textBoxTranslatedTitle = new System.Windows.Forms.TextBox(); + this.labelTranslatedTitle = new System.Windows.Forms.Label(); + this.textBoxOriginalTitle = new System.Windows.Forms.TextBox(); + this.labelOriginalTitle = new System.Windows.Forms.Label(); + this.textBoxTranslator = new System.Windows.Forms.TextBox(); + this.labelTranslator = new System.Windows.Forms.Label(); + this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.comboBoxLanguage = new System.Windows.Forms.ComboBox(); + this.labelLanguage = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // labelTimeCodeStartOfProgramme + // + this.labelTimeCodeStartOfProgramme.AutoSize = true; + this.labelTimeCodeStartOfProgramme.Location = new System.Drawing.Point(12, 182); + this.labelTimeCodeStartOfProgramme.Name = "labelTimeCodeStartOfProgramme"; + this.labelTimeCodeStartOfProgramme.Size = new System.Drawing.Size(152, 13); + this.labelTimeCodeStartOfProgramme.TabIndex = 10; + this.labelTimeCodeStartOfProgramme.Text = "Time code: Start of programme"; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(250, 262); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 12; + this.buttonOK.Text = "Save"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(331, 262); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 13; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonImport + // + this.buttonImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonImport.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonImport.Location = new System.Drawing.Point(290, 12); + this.buttonImport.Name = "buttonImport"; + this.buttonImport.Size = new System.Drawing.Size(116, 23); + this.buttonImport.TabIndex = 14; + this.buttonImport.Text = "Import..."; + this.buttonImport.UseVisualStyleBackColor = true; + this.buttonImport.Click += new System.EventHandler(this.buttonImport_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // textBoxComment + // + this.textBoxComment.Location = new System.Drawing.Point(185, 119); + this.textBoxComment.MaxLength = 24; + this.textBoxComment.Name = "textBoxComment"; + this.textBoxComment.Size = new System.Drawing.Size(219, 20); + this.textBoxComment.TabIndex = 7; + // + // labelComment + // + this.labelComment.AutoSize = true; + this.labelComment.Location = new System.Drawing.Point(13, 122); + this.labelComment.Name = "labelComment"; + this.labelComment.Size = new System.Drawing.Size(51, 13); + this.labelComment.TabIndex = 6; + this.labelComment.Text = "Comment"; + // + // textBoxTranslatedTitle + // + this.textBoxTranslatedTitle.Location = new System.Drawing.Point(185, 41); + this.textBoxTranslatedTitle.MaxLength = 28; + this.textBoxTranslatedTitle.Name = "textBoxTranslatedTitle"; + this.textBoxTranslatedTitle.Size = new System.Drawing.Size(219, 20); + this.textBoxTranslatedTitle.TabIndex = 1; + // + // labelTranslatedTitle + // + this.labelTranslatedTitle.AutoSize = true; + this.labelTranslatedTitle.Location = new System.Drawing.Point(13, 44); + this.labelTranslatedTitle.Name = "labelTranslatedTitle"; + this.labelTranslatedTitle.Size = new System.Drawing.Size(76, 13); + this.labelTranslatedTitle.TabIndex = 0; + this.labelTranslatedTitle.Text = "Translated title"; + // + // textBoxOriginalTitle + // + this.textBoxOriginalTitle.Location = new System.Drawing.Point(185, 67); + this.textBoxOriginalTitle.MaxLength = 24; + this.textBoxOriginalTitle.Name = "textBoxOriginalTitle"; + this.textBoxOriginalTitle.Size = new System.Drawing.Size(219, 20); + this.textBoxOriginalTitle.TabIndex = 3; + // + // labelOriginalTitle + // + this.labelOriginalTitle.AutoSize = true; + this.labelOriginalTitle.Location = new System.Drawing.Point(13, 70); + this.labelOriginalTitle.Name = "labelOriginalTitle"; + this.labelOriginalTitle.Size = new System.Drawing.Size(61, 13); + this.labelOriginalTitle.TabIndex = 2; + this.labelOriginalTitle.Text = "Original title"; + // + // textBoxTranslator + // + this.textBoxTranslator.Location = new System.Drawing.Point(185, 93); + this.textBoxTranslator.MaxLength = 24; + this.textBoxTranslator.Name = "textBoxTranslator"; + this.textBoxTranslator.Size = new System.Drawing.Size(219, 20); + this.textBoxTranslator.TabIndex = 5; + // + // labelTranslator + // + this.labelTranslator.AutoSize = true; + this.labelTranslator.Location = new System.Drawing.Point(13, 96); + this.labelTranslator.Name = "labelTranslator"; + this.labelTranslator.Size = new System.Drawing.Size(54, 13); + this.labelTranslator.TabIndex = 4; + this.labelTranslator.Text = "Translator"; + // + // timeUpDownStartTime + // + this.timeUpDownStartTime.AutoSize = true; + this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownStartTime.Font = new System.Drawing.Font("Segoe UI", 9F); + this.timeUpDownStartTime.Location = new System.Drawing.Point(183, 177); + this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownStartTime.Name = "timeUpDownStartTime"; + this.timeUpDownStartTime.Size = new System.Drawing.Size(96, 27); + this.timeUpDownStartTime.TabIndex = 11; + timeCode1.Hours = 0; + timeCode1.Milliseconds = 0; + timeCode1.Minutes = 0; + timeCode1.Seconds = 0; + timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode1.TotalMilliseconds = 0D; + timeCode1.TotalSeconds = 0D; + this.timeUpDownStartTime.TimeCode = timeCode1; + this.timeUpDownStartTime.UseVideoOffset = false; + // + // comboBoxLanguage + // + this.comboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxLanguage.FormattingEnabled = true; + this.comboBoxLanguage.Items.AddRange(new object[] { + "Arabic", + "Danish", + "Chinese Simplified", + "Chinese Traditional", + "English", + "Hebrew", + "Russian", + "Romanian"}); + this.comboBoxLanguage.Location = new System.Drawing.Point(185, 149); + this.comboBoxLanguage.Name = "comboBoxLanguage"; + this.comboBoxLanguage.Size = new System.Drawing.Size(219, 21); + this.comboBoxLanguage.TabIndex = 9; + // + // labelLanguage + // + this.labelLanguage.AutoSize = true; + this.labelLanguage.Location = new System.Drawing.Point(16, 152); + this.labelLanguage.Name = "labelLanguage"; + this.labelLanguage.Size = new System.Drawing.Size(55, 13); + this.labelLanguage.TabIndex = 8; + this.labelLanguage.Text = "Language"; + // + // Cavena890SaveOptions + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(418, 297); + this.Controls.Add(this.labelLanguage); + this.Controls.Add(this.comboBoxLanguage); + this.Controls.Add(this.textBoxTranslator); + this.Controls.Add(this.labelTranslator); + this.Controls.Add(this.textBoxOriginalTitle); + this.Controls.Add(this.labelOriginalTitle); + this.Controls.Add(this.textBoxComment); + this.Controls.Add(this.labelComment); + this.Controls.Add(this.textBoxTranslatedTitle); + this.Controls.Add(this.labelTranslatedTitle); + this.Controls.Add(this.buttonImport); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.labelTimeCodeStartOfProgramme); + this.Controls.Add(this.timeUpDownStartTime); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Cavena890SaveOptions"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Cavena 890 save options"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Cavena890SaveOptions_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelTimeCodeStartOfProgramme; + private Controls.TimeUpDown timeUpDownStartTime; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonImport; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.TextBox textBoxComment; + private System.Windows.Forms.Label labelComment; + private System.Windows.Forms.TextBox textBoxTranslatedTitle; + private System.Windows.Forms.Label labelTranslatedTitle; + private System.Windows.Forms.TextBox textBoxOriginalTitle; + private System.Windows.Forms.Label labelOriginalTitle; + private System.Windows.Forms.TextBox textBoxTranslator; + private System.Windows.Forms.Label labelTranslator; + private System.Windows.Forms.ComboBox comboBoxLanguage; + private System.Windows.Forms.Label labelLanguage; + } } \ No newline at end of file diff --git a/src/Forms/Cavena890SaveOptions.cs b/src/ui/Forms/Cavena890SaveOptions.cs similarity index 98% rename from src/Forms/Cavena890SaveOptions.cs rename to src/ui/Forms/Cavena890SaveOptions.cs index e7496297d..93ed65736 100644 --- a/src/Forms/Cavena890SaveOptions.cs +++ b/src/ui/Forms/Cavena890SaveOptions.cs @@ -1,183 +1,183 @@ -using System; -using System.IO; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Common; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class Cavena890SaveOptions : Form - { - public Cavena890SaveOptions(Subtitle subtitle, string subtitleFileName) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - - timeUpDownStartTime.ForceHHMMSSFF(); - timeUpDownStartTime.TimeCode = new TimeCode(TimeCode.ParseHHMMSSFFToMilliseconds(Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage)); - textBoxTranslatedTitle.Text = Configuration.Settings.SubtitleSettings.CurrentCavena89Title; - textBoxOriginalTitle.Text = Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle; - textBoxTranslator.Text = Configuration.Settings.SubtitleSettings.CurrentCavena890Translator; - textBoxComment.Text = Configuration.Settings.SubtitleSettings.CurrentCavena89Comment; - if (string.IsNullOrWhiteSpace(textBoxComment.Text)) - { - textBoxComment.Text = "Made with Subtitle Edit"; - } - - if (string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena89Title)) - { - string title = Path.GetFileNameWithoutExtension(subtitleFileName) ?? string.Empty; - if (title.Length > 28) - { - title = title.Substring(0, 28); - } - - textBoxTranslatedTitle.Text = title; - } - - var language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); - switch (language) - { - case "he": - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdHebrew; - comboBoxLanguage.SelectedIndex = 5; - break; - case "ru": - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRussian; - comboBoxLanguage.SelectedIndex = 6; - break; - case "ro": - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRomanian; - comboBoxLanguage.SelectedIndex = 7; - break; - case "zh": - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified; - comboBoxLanguage.SelectedIndex = 2; - break; - case "da": - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdDanish; - comboBoxLanguage.SelectedIndex = 1; - break; - default: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdEnglish; - comboBoxLanguage.SelectedIndex = 4; - break; - } - } - - private void Cavena890SaveOptions_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage = timeUpDownStartTime.TimeCode.ToHHMMSSFF(); - Configuration.Settings.SubtitleSettings.CurrentCavena89Title = textBoxTranslatedTitle.Text; - Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle = textBoxOriginalTitle.Text; - Configuration.Settings.SubtitleSettings.CurrentCavena890Translator = textBoxTranslator.Text; - Configuration.Settings.SubtitleSettings.CurrentCavena89Comment = textBoxComment.Text; - - switch (comboBoxLanguage.SelectedIndex) - { - case 0: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdArabic; - break; - case 1: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdDanish; - break; - case 2: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified; - break; - case 3: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseTraditional; - break; - case 5: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdHebrew; - break; - case 6: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRussian; - break; - default: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdEnglish; - break; - } - - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void buttonImport_Click(object sender, EventArgs e) - { - openFileDialog1.Filter = "Cavena 890 (*.890)|*.890"; - openFileDialog1.FileName = string.Empty; - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - var buffer = FileUtil.ReadAllBytesShared(openFileDialog1.FileName); - if (buffer.Length > 270) - { - var s = System.Text.Encoding.ASCII.GetString(buffer, 40, 28); - textBoxTranslatedTitle.Text = s.Replace("\0", string.Empty); - - s = System.Text.Encoding.ASCII.GetString(buffer, 218, 28); - textBoxOriginalTitle.Text = s.Replace("\0", string.Empty); - - s = System.Text.Encoding.ASCII.GetString(buffer, 68, 28); - textBoxTranslator.Text = s.Replace("\0", string.Empty); - - s = System.Text.Encoding.ASCII.GetString(buffer, 148, 24); - textBoxComment.Text = s.Replace("\0", string.Empty); - - s = System.Text.Encoding.ASCII.GetString(buffer, 256, 11); - timeUpDownStartTime.TimeCode = new TimeCode(TimeCode.ParseHHMMSSFFToMilliseconds(s)); - - switch (buffer[146]) - { - case Cavena890.LanguageIdHebrew: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdHebrew; - comboBoxLanguage.SelectedIndex = 5; - break; - case Cavena890.LanguageIdRussian: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRussian; - comboBoxLanguage.SelectedIndex = 6; - break; - case Cavena890.LanguageIdChineseSimplified: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified; - comboBoxLanguage.SelectedIndex = 2; - break; - case Cavena890.LanguageIdChineseTraditional: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified; - comboBoxLanguage.SelectedIndex = 3; - break; - case Cavena890.LanguageIdDanish: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdDanish; - comboBoxLanguage.SelectedIndex = 1; - break; - case Cavena890.LanguageIdRomanian: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRomanian; - comboBoxLanguage.SelectedIndex = 7; - break; - default: - Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdEnglish; - comboBoxLanguage.SelectedIndex = 4; - break; - } - } - } - } - - } -} +using System; +using System.IO; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class Cavena890SaveOptions : Form + { + public Cavena890SaveOptions(Subtitle subtitle, string subtitleFileName) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + + timeUpDownStartTime.ForceHHMMSSFF(); + timeUpDownStartTime.TimeCode = new TimeCode(TimeCode.ParseHHMMSSFFToMilliseconds(Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage)); + textBoxTranslatedTitle.Text = Configuration.Settings.SubtitleSettings.CurrentCavena89Title; + textBoxOriginalTitle.Text = Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle; + textBoxTranslator.Text = Configuration.Settings.SubtitleSettings.CurrentCavena890Translator; + textBoxComment.Text = Configuration.Settings.SubtitleSettings.CurrentCavena89Comment; + if (string.IsNullOrWhiteSpace(textBoxComment.Text)) + { + textBoxComment.Text = "Made with Subtitle Edit"; + } + + if (string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena89Title)) + { + string title = Path.GetFileNameWithoutExtension(subtitleFileName) ?? string.Empty; + if (title.Length > 28) + { + title = title.Substring(0, 28); + } + + textBoxTranslatedTitle.Text = title; + } + + var language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); + switch (language) + { + case "he": + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdHebrew; + comboBoxLanguage.SelectedIndex = 5; + break; + case "ru": + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRussian; + comboBoxLanguage.SelectedIndex = 6; + break; + case "ro": + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRomanian; + comboBoxLanguage.SelectedIndex = 7; + break; + case "zh": + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified; + comboBoxLanguage.SelectedIndex = 2; + break; + case "da": + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdDanish; + comboBoxLanguage.SelectedIndex = 1; + break; + default: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdEnglish; + comboBoxLanguage.SelectedIndex = 4; + break; + } + } + + private void Cavena890SaveOptions_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage = timeUpDownStartTime.TimeCode.ToHHMMSSFF(); + Configuration.Settings.SubtitleSettings.CurrentCavena89Title = textBoxTranslatedTitle.Text; + Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle = textBoxOriginalTitle.Text; + Configuration.Settings.SubtitleSettings.CurrentCavena890Translator = textBoxTranslator.Text; + Configuration.Settings.SubtitleSettings.CurrentCavena89Comment = textBoxComment.Text; + + switch (comboBoxLanguage.SelectedIndex) + { + case 0: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdArabic; + break; + case 1: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdDanish; + break; + case 2: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified; + break; + case 3: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseTraditional; + break; + case 5: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdHebrew; + break; + case 6: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRussian; + break; + default: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdEnglish; + break; + } + + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void buttonImport_Click(object sender, EventArgs e) + { + openFileDialog1.Filter = "Cavena 890 (*.890)|*.890"; + openFileDialog1.FileName = string.Empty; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + var buffer = FileUtil.ReadAllBytesShared(openFileDialog1.FileName); + if (buffer.Length > 270) + { + var s = System.Text.Encoding.ASCII.GetString(buffer, 40, 28); + textBoxTranslatedTitle.Text = s.Replace("\0", string.Empty); + + s = System.Text.Encoding.ASCII.GetString(buffer, 218, 28); + textBoxOriginalTitle.Text = s.Replace("\0", string.Empty); + + s = System.Text.Encoding.ASCII.GetString(buffer, 68, 28); + textBoxTranslator.Text = s.Replace("\0", string.Empty); + + s = System.Text.Encoding.ASCII.GetString(buffer, 148, 24); + textBoxComment.Text = s.Replace("\0", string.Empty); + + s = System.Text.Encoding.ASCII.GetString(buffer, 256, 11); + timeUpDownStartTime.TimeCode = new TimeCode(TimeCode.ParseHHMMSSFFToMilliseconds(s)); + + switch (buffer[146]) + { + case Cavena890.LanguageIdHebrew: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdHebrew; + comboBoxLanguage.SelectedIndex = 5; + break; + case Cavena890.LanguageIdRussian: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRussian; + comboBoxLanguage.SelectedIndex = 6; + break; + case Cavena890.LanguageIdChineseSimplified: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified; + comboBoxLanguage.SelectedIndex = 2; + break; + case Cavena890.LanguageIdChineseTraditional: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified; + comboBoxLanguage.SelectedIndex = 3; + break; + case Cavena890.LanguageIdDanish: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdDanish; + comboBoxLanguage.SelectedIndex = 1; + break; + case Cavena890.LanguageIdRomanian: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRomanian; + comboBoxLanguage.SelectedIndex = 7; + break; + default: + Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdEnglish; + comboBoxLanguage.SelectedIndex = 4; + break; + } + } + } + } + + } +} diff --git a/src/Forms/Cavena890SaveOptions.resx b/src/ui/Forms/Cavena890SaveOptions.resx similarity index 97% rename from src/Forms/Cavena890SaveOptions.resx rename to src/ui/Forms/Cavena890SaveOptions.resx index 3a7d67153..9bad2f599 100644 --- a/src/Forms/Cavena890SaveOptions.resx +++ b/src/ui/Forms/Cavena890SaveOptions.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/ChangeCasing.Designer.cs b/src/ui/Forms/ChangeCasing.Designer.cs similarity index 98% rename from src/Forms/ChangeCasing.Designer.cs rename to src/ui/Forms/ChangeCasing.Designer.cs index 127aecc31..3794d64c3 100644 --- a/src/Forms/ChangeCasing.Designer.cs +++ b/src/ui/Forms/ChangeCasing.Designer.cs @@ -1,190 +1,190 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ChangeCasing - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxChangeCasing = new System.Windows.Forms.GroupBox(); - this.radioButtonFixOnlyNames = new System.Windows.Forms.RadioButton(); - this.checkBoxFixNames = new System.Windows.Forms.CheckBox(); - this.checkBoxOnlyAllUpper = new System.Windows.Forms.CheckBox(); - this.radioButtonLowercase = new System.Windows.Forms.RadioButton(); - this.radioButtonUppercase = new System.Windows.Forms.RadioButton(); - this.radioButtonNormal = new System.Windows.Forms.RadioButton(); - this.groupBoxChangeCasing.SuspendLayout(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(417, 195); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 14; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(336, 195); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 12; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // groupBoxChangeCasing - // - this.groupBoxChangeCasing.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxChangeCasing.Controls.Add(this.radioButtonFixOnlyNames); - this.groupBoxChangeCasing.Controls.Add(this.checkBoxFixNames); - this.groupBoxChangeCasing.Controls.Add(this.checkBoxOnlyAllUpper); - this.groupBoxChangeCasing.Controls.Add(this.radioButtonLowercase); - this.groupBoxChangeCasing.Controls.Add(this.radioButtonUppercase); - this.groupBoxChangeCasing.Controls.Add(this.radioButtonNormal); - this.groupBoxChangeCasing.Location = new System.Drawing.Point(12, 12); - this.groupBoxChangeCasing.Name = "groupBoxChangeCasing"; - this.groupBoxChangeCasing.Size = new System.Drawing.Size(480, 172); - this.groupBoxChangeCasing.TabIndex = 12; - this.groupBoxChangeCasing.TabStop = false; - this.groupBoxChangeCasing.Text = "Change casing to"; - // - // radioButtonFixOnlyNames - // - this.radioButtonFixOnlyNames.AutoSize = true; - this.radioButtonFixOnlyNames.Location = new System.Drawing.Point(11, 88); - this.radioButtonFixOnlyNames.Name = "radioButtonFixOnlyNames"; - this.radioButtonFixOnlyNames.Size = new System.Drawing.Size(267, 17); - this.radioButtonFixOnlyNames.TabIndex = 6; - this.radioButtonFixOnlyNames.Text = "Fix only names casing (via Dictionaries\\names.xml)"; - this.radioButtonFixOnlyNames.UseVisualStyleBackColor = true; - this.radioButtonFixOnlyNames.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); - // - // checkBoxFixNames - // - this.checkBoxFixNames.AutoSize = true; - this.checkBoxFixNames.Checked = true; - this.checkBoxFixNames.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxFixNames.Location = new System.Drawing.Point(23, 39); - this.checkBoxFixNames.Name = "checkBoxFixNames"; - this.checkBoxFixNames.Size = new System.Drawing.Size(245, 17); - this.checkBoxFixNames.TabIndex = 2; - this.checkBoxFixNames.Text = "Fix names casing (via Dictionaries\\names.xml)"; - this.checkBoxFixNames.UseVisualStyleBackColor = true; - // - // checkBoxOnlyAllUpper - // - this.checkBoxOnlyAllUpper.AutoSize = true; - this.checkBoxOnlyAllUpper.Location = new System.Drawing.Point(23, 62); - this.checkBoxOnlyAllUpper.Name = "checkBoxOnlyAllUpper"; - this.checkBoxOnlyAllUpper.Size = new System.Drawing.Size(183, 17); - this.checkBoxOnlyAllUpper.TabIndex = 4; - this.checkBoxOnlyAllUpper.Text = "Only change all upper case lines."; - this.checkBoxOnlyAllUpper.UseVisualStyleBackColor = true; - // - // radioButtonLowercase - // - this.radioButtonLowercase.AutoSize = true; - this.radioButtonLowercase.Location = new System.Drawing.Point(11, 142); - this.radioButtonLowercase.Name = "radioButtonLowercase"; - this.radioButtonLowercase.Size = new System.Drawing.Size(86, 17); - this.radioButtonLowercase.TabIndex = 10; - this.radioButtonLowercase.Text = "all lowercase"; - this.radioButtonLowercase.UseVisualStyleBackColor = true; - this.radioButtonLowercase.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); - // - // radioButtonUppercase - // - this.radioButtonUppercase.AutoSize = true; - this.radioButtonUppercase.Location = new System.Drawing.Point(11, 116); - this.radioButtonUppercase.Name = "radioButtonUppercase"; - this.radioButtonUppercase.Size = new System.Drawing.Size(103, 17); - this.radioButtonUppercase.TabIndex = 8; - this.radioButtonUppercase.Text = "ALL UPPERCASE"; - this.radioButtonUppercase.UseVisualStyleBackColor = true; - this.radioButtonUppercase.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); - // - // radioButtonNormal - // - this.radioButtonNormal.AutoSize = true; - this.radioButtonNormal.Checked = true; - this.radioButtonNormal.Location = new System.Drawing.Point(11, 18); - this.radioButtonNormal.Name = "radioButtonNormal"; - this.radioButtonNormal.Size = new System.Drawing.Size(286, 17); - this.radioButtonNormal.TabIndex = 0; - this.radioButtonNormal.TabStop = true; - this.radioButtonNormal.Text = "Normal casing. Sentences begin with uppercase letter."; - this.radioButtonNormal.UseVisualStyleBackColor = true; - this.radioButtonNormal.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); - // - // ChangeCasing - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(504, 228); - this.Controls.Add(this.groupBoxChangeCasing); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ChangeCasing"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Change casing"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormChangeCasing_KeyDown); - this.groupBoxChangeCasing.ResumeLayout(false); - this.groupBoxChangeCasing.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.GroupBox groupBoxChangeCasing; - private System.Windows.Forms.RadioButton radioButtonUppercase; - private System.Windows.Forms.RadioButton radioButtonNormal; - private System.Windows.Forms.RadioButton radioButtonLowercase; - private System.Windows.Forms.CheckBox checkBoxOnlyAllUpper; - private System.Windows.Forms.CheckBox checkBoxFixNames; - private System.Windows.Forms.RadioButton radioButtonFixOnlyNames; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ChangeCasing + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxChangeCasing = new System.Windows.Forms.GroupBox(); + this.radioButtonFixOnlyNames = new System.Windows.Forms.RadioButton(); + this.checkBoxFixNames = new System.Windows.Forms.CheckBox(); + this.checkBoxOnlyAllUpper = new System.Windows.Forms.CheckBox(); + this.radioButtonLowercase = new System.Windows.Forms.RadioButton(); + this.radioButtonUppercase = new System.Windows.Forms.RadioButton(); + this.radioButtonNormal = new System.Windows.Forms.RadioButton(); + this.groupBoxChangeCasing.SuspendLayout(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(417, 195); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 14; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(336, 195); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 12; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // groupBoxChangeCasing + // + this.groupBoxChangeCasing.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxChangeCasing.Controls.Add(this.radioButtonFixOnlyNames); + this.groupBoxChangeCasing.Controls.Add(this.checkBoxFixNames); + this.groupBoxChangeCasing.Controls.Add(this.checkBoxOnlyAllUpper); + this.groupBoxChangeCasing.Controls.Add(this.radioButtonLowercase); + this.groupBoxChangeCasing.Controls.Add(this.radioButtonUppercase); + this.groupBoxChangeCasing.Controls.Add(this.radioButtonNormal); + this.groupBoxChangeCasing.Location = new System.Drawing.Point(12, 12); + this.groupBoxChangeCasing.Name = "groupBoxChangeCasing"; + this.groupBoxChangeCasing.Size = new System.Drawing.Size(480, 172); + this.groupBoxChangeCasing.TabIndex = 12; + this.groupBoxChangeCasing.TabStop = false; + this.groupBoxChangeCasing.Text = "Change casing to"; + // + // radioButtonFixOnlyNames + // + this.radioButtonFixOnlyNames.AutoSize = true; + this.radioButtonFixOnlyNames.Location = new System.Drawing.Point(11, 88); + this.radioButtonFixOnlyNames.Name = "radioButtonFixOnlyNames"; + this.radioButtonFixOnlyNames.Size = new System.Drawing.Size(267, 17); + this.radioButtonFixOnlyNames.TabIndex = 6; + this.radioButtonFixOnlyNames.Text = "Fix only names casing (via Dictionaries\\names.xml)"; + this.radioButtonFixOnlyNames.UseVisualStyleBackColor = true; + this.radioButtonFixOnlyNames.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); + // + // checkBoxFixNames + // + this.checkBoxFixNames.AutoSize = true; + this.checkBoxFixNames.Checked = true; + this.checkBoxFixNames.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxFixNames.Location = new System.Drawing.Point(23, 39); + this.checkBoxFixNames.Name = "checkBoxFixNames"; + this.checkBoxFixNames.Size = new System.Drawing.Size(245, 17); + this.checkBoxFixNames.TabIndex = 2; + this.checkBoxFixNames.Text = "Fix names casing (via Dictionaries\\names.xml)"; + this.checkBoxFixNames.UseVisualStyleBackColor = true; + // + // checkBoxOnlyAllUpper + // + this.checkBoxOnlyAllUpper.AutoSize = true; + this.checkBoxOnlyAllUpper.Location = new System.Drawing.Point(23, 62); + this.checkBoxOnlyAllUpper.Name = "checkBoxOnlyAllUpper"; + this.checkBoxOnlyAllUpper.Size = new System.Drawing.Size(183, 17); + this.checkBoxOnlyAllUpper.TabIndex = 4; + this.checkBoxOnlyAllUpper.Text = "Only change all upper case lines."; + this.checkBoxOnlyAllUpper.UseVisualStyleBackColor = true; + // + // radioButtonLowercase + // + this.radioButtonLowercase.AutoSize = true; + this.radioButtonLowercase.Location = new System.Drawing.Point(11, 142); + this.radioButtonLowercase.Name = "radioButtonLowercase"; + this.radioButtonLowercase.Size = new System.Drawing.Size(86, 17); + this.radioButtonLowercase.TabIndex = 10; + this.radioButtonLowercase.Text = "all lowercase"; + this.radioButtonLowercase.UseVisualStyleBackColor = true; + this.radioButtonLowercase.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); + // + // radioButtonUppercase + // + this.radioButtonUppercase.AutoSize = true; + this.radioButtonUppercase.Location = new System.Drawing.Point(11, 116); + this.radioButtonUppercase.Name = "radioButtonUppercase"; + this.radioButtonUppercase.Size = new System.Drawing.Size(103, 17); + this.radioButtonUppercase.TabIndex = 8; + this.radioButtonUppercase.Text = "ALL UPPERCASE"; + this.radioButtonUppercase.UseVisualStyleBackColor = true; + this.radioButtonUppercase.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); + // + // radioButtonNormal + // + this.radioButtonNormal.AutoSize = true; + this.radioButtonNormal.Checked = true; + this.radioButtonNormal.Location = new System.Drawing.Point(11, 18); + this.radioButtonNormal.Name = "radioButtonNormal"; + this.radioButtonNormal.Size = new System.Drawing.Size(286, 17); + this.radioButtonNormal.TabIndex = 0; + this.radioButtonNormal.TabStop = true; + this.radioButtonNormal.Text = "Normal casing. Sentences begin with uppercase letter."; + this.radioButtonNormal.UseVisualStyleBackColor = true; + this.radioButtonNormal.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); + // + // ChangeCasing + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(504, 228); + this.Controls.Add(this.groupBoxChangeCasing); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ChangeCasing"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Change casing"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormChangeCasing_KeyDown); + this.groupBoxChangeCasing.ResumeLayout(false); + this.groupBoxChangeCasing.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.GroupBox groupBoxChangeCasing; + private System.Windows.Forms.RadioButton radioButtonUppercase; + private System.Windows.Forms.RadioButton radioButtonNormal; + private System.Windows.Forms.RadioButton radioButtonLowercase; + private System.Windows.Forms.CheckBox checkBoxOnlyAllUpper; + private System.Windows.Forms.CheckBox checkBoxFixNames; + private System.Windows.Forms.RadioButton radioButtonFixOnlyNames; + } } \ No newline at end of file diff --git a/src/Forms/ChangeCasing.cs b/src/ui/Forms/ChangeCasing.cs similarity index 97% rename from src/Forms/ChangeCasing.cs rename to src/ui/Forms/ChangeCasing.cs index e064e7166..b39dbaf47 100644 --- a/src/Forms/ChangeCasing.cs +++ b/src/ui/Forms/ChangeCasing.cs @@ -1,111 +1,111 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ChangeCasing : PositionAndSizeForm - { - public ChangeCasing() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - var language = Configuration.Settings.Language.ChangeCasing; - Text = language.Title; - groupBoxChangeCasing.Text = language.ChangeCasingTo; - radioButtonNormal.Text = language.NormalCasing; - checkBoxFixNames.Text = language.FixNamesCasing; - radioButtonFixOnlyNames.Text = language.FixOnlyNamesCasing; - checkBoxOnlyAllUpper.Text = language.OnlyChangeAllUppercaseLines; - radioButtonUppercase.Text = language.AllUppercase; - radioButtonLowercase.Text = language.AllLowercase; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - FixLargeFonts(); - - if (Configuration.Settings.Tools.ChangeCasingChoice == "NamesOnly") - { - radioButtonFixOnlyNames.Checked = true; - } - else if (Configuration.Settings.Tools.ChangeCasingChoice == "Uppercase") - { - radioButtonUppercase.Checked = true; - } - else if (Configuration.Settings.Tools.ChangeCasingChoice == "Lowercase") - { - radioButtonLowercase.Checked = true; - } - } - - public int LinesChanged { get; private set; } - - public bool ChangeNamesToo => radioButtonFixOnlyNames.Checked || radioButtonNormal.Checked && checkBoxFixNames.Checked; - - public bool OnlyAllUpper => checkBoxOnlyAllUpper.Checked; - - private void FixLargeFonts() - { - if (radioButtonNormal.Left + radioButtonNormal.Width + 40 > Width) - { - Width = radioButtonNormal.Left + radioButtonNormal.Width + 40; - } - - UiUtil.FixLargeFonts(this, buttonOK); - } - - internal void FixCasing(Subtitle subtitle, string language) - { - var fixCasing = new FixCasing(language) - { - FixNormal = radioButtonNormal.Checked, - FixMakeUppercase = radioButtonUppercase.Checked, - FixMakeLowercase = radioButtonLowercase.Checked, - FixNormalOnlyAllUppercase = checkBoxOnlyAllUpper.Checked - }; - fixCasing.Fix(subtitle); - LinesChanged = fixCasing.NoOfLinesChanged; - } - - private void FormChangeCasing_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - if (radioButtonNormal.Checked) - { - Configuration.Settings.Tools.ChangeCasingChoice = "Normal"; - } - else if (radioButtonFixOnlyNames.Checked) - { - Configuration.Settings.Tools.ChangeCasingChoice = "NamesOnly"; - } - else if (radioButtonUppercase.Checked) - { - Configuration.Settings.Tools.ChangeCasingChoice = "Uppercase"; - } - else if (radioButtonLowercase.Checked) - { - Configuration.Settings.Tools.ChangeCasingChoice = "Lowercase"; - } - - DialogResult = DialogResult.OK; - } - - private void RadioButton_CheckedChanged(object sender, EventArgs e) - { - var isNormalCasing = sender == radioButtonNormal; - checkBoxFixNames.Enabled = isNormalCasing; - checkBoxOnlyAllUpper.Enabled = isNormalCasing; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ChangeCasing : PositionAndSizeForm + { + public ChangeCasing() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + var language = Configuration.Settings.Language.ChangeCasing; + Text = language.Title; + groupBoxChangeCasing.Text = language.ChangeCasingTo; + radioButtonNormal.Text = language.NormalCasing; + checkBoxFixNames.Text = language.FixNamesCasing; + radioButtonFixOnlyNames.Text = language.FixOnlyNamesCasing; + checkBoxOnlyAllUpper.Text = language.OnlyChangeAllUppercaseLines; + radioButtonUppercase.Text = language.AllUppercase; + radioButtonLowercase.Text = language.AllLowercase; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + FixLargeFonts(); + + if (Configuration.Settings.Tools.ChangeCasingChoice == "NamesOnly") + { + radioButtonFixOnlyNames.Checked = true; + } + else if (Configuration.Settings.Tools.ChangeCasingChoice == "Uppercase") + { + radioButtonUppercase.Checked = true; + } + else if (Configuration.Settings.Tools.ChangeCasingChoice == "Lowercase") + { + radioButtonLowercase.Checked = true; + } + } + + public int LinesChanged { get; private set; } + + public bool ChangeNamesToo => radioButtonFixOnlyNames.Checked || radioButtonNormal.Checked && checkBoxFixNames.Checked; + + public bool OnlyAllUpper => checkBoxOnlyAllUpper.Checked; + + private void FixLargeFonts() + { + if (radioButtonNormal.Left + radioButtonNormal.Width + 40 > Width) + { + Width = radioButtonNormal.Left + radioButtonNormal.Width + 40; + } + + UiUtil.FixLargeFonts(this, buttonOK); + } + + internal void FixCasing(Subtitle subtitle, string language) + { + var fixCasing = new FixCasing(language) + { + FixNormal = radioButtonNormal.Checked, + FixMakeUppercase = radioButtonUppercase.Checked, + FixMakeLowercase = radioButtonLowercase.Checked, + FixNormalOnlyAllUppercase = checkBoxOnlyAllUpper.Checked + }; + fixCasing.Fix(subtitle); + LinesChanged = fixCasing.NoOfLinesChanged; + } + + private void FormChangeCasing_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + if (radioButtonNormal.Checked) + { + Configuration.Settings.Tools.ChangeCasingChoice = "Normal"; + } + else if (radioButtonFixOnlyNames.Checked) + { + Configuration.Settings.Tools.ChangeCasingChoice = "NamesOnly"; + } + else if (radioButtonUppercase.Checked) + { + Configuration.Settings.Tools.ChangeCasingChoice = "Uppercase"; + } + else if (radioButtonLowercase.Checked) + { + Configuration.Settings.Tools.ChangeCasingChoice = "Lowercase"; + } + + DialogResult = DialogResult.OK; + } + + private void RadioButton_CheckedChanged(object sender, EventArgs e) + { + var isNormalCasing = sender == radioButtonNormal; + checkBoxFixNames.Enabled = isNormalCasing; + checkBoxOnlyAllUpper.Enabled = isNormalCasing; + } + + } +} diff --git a/src/Forms/ChangeCasing.resx b/src/ui/Forms/ChangeCasing.resx similarity index 97% rename from src/Forms/ChangeCasing.resx rename to src/ui/Forms/ChangeCasing.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/ChangeCasing.resx +++ b/src/ui/Forms/ChangeCasing.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/ChangeCasingNames.Designer.cs b/src/ui/Forms/ChangeCasingNames.Designer.cs similarity index 98% rename from src/Forms/ChangeCasingNames.Designer.cs rename to src/ui/Forms/ChangeCasingNames.Designer.cs index 1cc6df850..df3ab04d4 100644 --- a/src/Forms/ChangeCasingNames.Designer.cs +++ b/src/ui/Forms/ChangeCasingNames.Designer.cs @@ -1,352 +1,352 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class ChangeCasingNames - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.groupBoxNames = new System.Windows.Forms.GroupBox(); - this.buttonAddCustomNames = new System.Windows.Forms.Button(); - this.textBoxExtraNames = new System.Windows.Forms.TextBox(); - this.labelExtraNames = new System.Windows.Forms.Label(); - this.buttonInverseSelection = new System.Windows.Forms.Button(); - this.buttonSelectAll = new System.Windows.Forms.Button(); - this.listViewNames = new System.Windows.Forms.ListView(); - this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); - this.listViewFixes = new System.Windows.Forms.ListView(); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); - this.labelXLinesSelected = new System.Windows.Forms.Label(); - this.contextMenuStrip2SelectAll = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItem1SelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem2InverseSelection = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBoxNames.SuspendLayout(); - this.groupBoxLinesFound.SuspendLayout(); - this.contextMenuStrip1.SuspendLayout(); - this.contextMenuStrip2SelectAll.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(591, 602); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 14; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(672, 602); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 15; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // groupBoxNames - // - this.groupBoxNames.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxNames.Controls.Add(this.buttonAddCustomNames); - this.groupBoxNames.Controls.Add(this.textBoxExtraNames); - this.groupBoxNames.Controls.Add(this.labelExtraNames); - this.groupBoxNames.Controls.Add(this.buttonInverseSelection); - this.groupBoxNames.Controls.Add(this.buttonSelectAll); - this.groupBoxNames.Controls.Add(this.listViewNames); - this.groupBoxNames.Location = new System.Drawing.Point(5, 9); - this.groupBoxNames.Name = "groupBoxNames"; - this.groupBoxNames.Size = new System.Drawing.Size(747, 293); - this.groupBoxNames.TabIndex = 12; - this.groupBoxNames.TabStop = false; - this.groupBoxNames.Text = "Names found in subtitle"; - // - // buttonAddCustomNames - // - this.buttonAddCustomNames.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonAddCustomNames.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonAddCustomNames.Location = new System.Drawing.Point(640, 262); - this.buttonAddCustomNames.Name = "buttonAddCustomNames"; - this.buttonAddCustomNames.Size = new System.Drawing.Size(100, 23); - this.buttonAddCustomNames.TabIndex = 11; - this.buttonAddCustomNames.Text = "Add"; - this.buttonAddCustomNames.UseVisualStyleBackColor = true; - this.buttonAddCustomNames.Click += new System.EventHandler(this.buttonAddCustomNames_Click); - // - // textBoxExtraNames - // - this.textBoxExtraNames.Location = new System.Drawing.Point(10, 263); - this.textBoxExtraNames.Name = "textBoxExtraNames"; - this.textBoxExtraNames.Size = new System.Drawing.Size(624, 21); - this.textBoxExtraNames.TabIndex = 10; - // - // labelExtraNames - // - this.labelExtraNames.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelExtraNames.AutoSize = true; - this.labelExtraNames.Location = new System.Drawing.Point(7, 246); - this.labelExtraNames.Name = "labelExtraNames"; - this.labelExtraNames.Size = new System.Drawing.Size(172, 13); - this.labelExtraNames.TabIndex = 17; - this.labelExtraNames.Text = "Extra names (separate by comma)"; - // - // buttonInverseSelection - // - this.buttonInverseSelection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonInverseSelection.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonInverseSelection.Location = new System.Drawing.Point(88, 202); - this.buttonInverseSelection.Name = "buttonInverseSelection"; - this.buttonInverseSelection.Size = new System.Drawing.Size(100, 23); - this.buttonInverseSelection.TabIndex = 9; - this.buttonInverseSelection.Text = "Inverse selection"; - this.buttonInverseSelection.UseVisualStyleBackColor = true; - this.buttonInverseSelection.Click += new System.EventHandler(this.buttonInverseSelection_Click); - // - // buttonSelectAll - // - this.buttonSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonSelectAll.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonSelectAll.Location = new System.Drawing.Point(7, 202); - this.buttonSelectAll.Name = "buttonSelectAll"; - this.buttonSelectAll.Size = new System.Drawing.Size(75, 23); - this.buttonSelectAll.TabIndex = 8; - this.buttonSelectAll.Text = "Select all"; - this.buttonSelectAll.UseVisualStyleBackColor = true; - this.buttonSelectAll.Click += new System.EventHandler(this.buttonSelectAll_Click); - // - // listViewNames - // - this.listViewNames.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewNames.CheckBoxes = true; - this.listViewNames.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.columnHeader2}); - this.listViewNames.ContextMenuStrip = this.contextMenuStrip2SelectAll; - this.listViewNames.FullRowSelect = true; - this.listViewNames.HideSelection = false; - this.listViewNames.Location = new System.Drawing.Point(6, 19); - this.listViewNames.MultiSelect = false; - this.listViewNames.Name = "listViewNames"; - this.listViewNames.Size = new System.Drawing.Size(735, 177); - this.listViewNames.TabIndex = 7; - this.listViewNames.UseCompatibleStateImageBehavior = false; - this.listViewNames.View = System.Windows.Forms.View.Details; - this.listViewNames.SelectedIndexChanged += new System.EventHandler(this.ListViewNamesSelectedIndexChanged); - // - // columnHeader1 - // - this.columnHeader1.Text = "Enabled"; - this.columnHeader1.Width = 70; - // - // columnHeader2 - // - this.columnHeader2.Text = "Name"; - this.columnHeader2.Width = 620; - // - // groupBoxLinesFound - // - this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxLinesFound.Controls.Add(this.listViewFixes); - this.groupBoxLinesFound.Location = new System.Drawing.Point(5, 308); - this.groupBoxLinesFound.Name = "groupBoxLinesFound"; - this.groupBoxLinesFound.Size = new System.Drawing.Size(747, 286); - this.groupBoxLinesFound.TabIndex = 13; - this.groupBoxLinesFound.TabStop = false; - this.groupBoxLinesFound.Text = "Lines found: {0}"; - // - // listViewFixes - // - this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewFixes.CheckBoxes = true; - this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader4, - this.columnHeader5, - this.columnHeader7, - this.columnHeader8}); - this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; - this.listViewFixes.FullRowSelect = true; - this.listViewFixes.HideSelection = false; - this.listViewFixes.Location = new System.Drawing.Point(6, 23); - this.listViewFixes.Name = "listViewFixes"; - this.listViewFixes.Size = new System.Drawing.Size(735, 257); - this.listViewFixes.TabIndex = 9; - this.listViewFixes.UseCompatibleStateImageBehavior = false; - this.listViewFixes.View = System.Windows.Forms.View.Details; - this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged); - // - // columnHeader4 - // - this.columnHeader4.Text = "Apply"; - this.columnHeader4.Width = 45; - // - // columnHeader5 - // - this.columnHeader5.Text = "Line#"; - this.columnHeader5.Width = 61; - // - // columnHeader7 - // - this.columnHeader7.Text = "Before"; - this.columnHeader7.Width = 292; - // - // columnHeader8 - // - this.columnHeader8.Text = "After"; - this.columnHeader8.Width = 292; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemSelectAll, - this.toolStripMenuItemInverseSelection}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(162, 48); - // - // toolStripMenuItemSelectAll - // - this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; - this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(161, 22); - this.toolStripMenuItemSelectAll.Text = "Select all"; - this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); - // - // toolStripMenuItemInverseSelection - // - this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; - this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(161, 22); - this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; - this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); - // - // labelXLinesSelected - // - this.labelXLinesSelected.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelXLinesSelected.AutoSize = true; - this.labelXLinesSelected.Location = new System.Drawing.Point(5, 602); - this.labelXLinesSelected.Name = "labelXLinesSelected"; - this.labelXLinesSelected.Size = new System.Drawing.Size(78, 13); - this.labelXLinesSelected.TabIndex = 16; - this.labelXLinesSelected.Text = "XLinesSelected"; - // - // contextMenuStrip2SelectAll - // - this.contextMenuStrip2SelectAll.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItem1SelectAll, - this.toolStripMenuItem2InverseSelection}); - this.contextMenuStrip2SelectAll.Name = "contextMenuStrip1"; - this.contextMenuStrip2SelectAll.Size = new System.Drawing.Size(181, 70); - // - // toolStripMenuItem1SelectAll - // - this.toolStripMenuItem1SelectAll.Name = "toolStripMenuItem1SelectAll"; - this.toolStripMenuItem1SelectAll.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItem1SelectAll.Text = "Select all"; - this.toolStripMenuItem1SelectAll.Click += new System.EventHandler(this.toolStripMenuItem1SelectAll_Click); - // - // toolStripMenuItem2InverseSelection - // - this.toolStripMenuItem2InverseSelection.Name = "toolStripMenuItem2InverseSelection"; - this.toolStripMenuItem2InverseSelection.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItem2InverseSelection.Text = "Inverse selection"; - this.toolStripMenuItem2InverseSelection.Click += new System.EventHandler(this.toolStripMenuItem2InverseSelection_Click); - // - // ChangeCasingNames - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(757, 632); - this.Controls.Add(this.labelXLinesSelected); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.groupBoxNames); - this.Controls.Add(this.groupBoxLinesFound); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(600, 480); - this.Name = "ChangeCasingNames"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Change casing - Names"; - this.Shown += new System.EventHandler(this.ChangeCasingNames_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChangeCasingNames_KeyDown); - this.groupBoxNames.ResumeLayout(false); - this.groupBoxNames.PerformLayout(); - this.groupBoxLinesFound.ResumeLayout(false); - this.contextMenuStrip1.ResumeLayout(false); - this.contextMenuStrip2SelectAll.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.GroupBox groupBoxNames; - private System.Windows.Forms.ListView listViewNames; - private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.ColumnHeader columnHeader2; - private System.Windows.Forms.GroupBox groupBoxLinesFound; - private System.Windows.Forms.ListView listViewFixes; - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeader7; - private System.Windows.Forms.ColumnHeader columnHeader8; - private System.Windows.Forms.Label labelXLinesSelected; - private System.Windows.Forms.Button buttonInverseSelection; - private System.Windows.Forms.Button buttonSelectAll; - private System.Windows.Forms.Button buttonAddCustomNames; - private System.Windows.Forms.TextBox textBoxExtraNames; - private System.Windows.Forms.Label labelExtraNames; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip2SelectAll; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1SelectAll; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2InverseSelection; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class ChangeCasingNames + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxNames = new System.Windows.Forms.GroupBox(); + this.buttonAddCustomNames = new System.Windows.Forms.Button(); + this.textBoxExtraNames = new System.Windows.Forms.TextBox(); + this.labelExtraNames = new System.Windows.Forms.Label(); + this.buttonInverseSelection = new System.Windows.Forms.Button(); + this.buttonSelectAll = new System.Windows.Forms.Button(); + this.listViewNames = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); + this.listViewFixes = new System.Windows.Forms.ListView(); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); + this.labelXLinesSelected = new System.Windows.Forms.Label(); + this.contextMenuStrip2SelectAll = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItem1SelectAll = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem2InverseSelection = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBoxNames.SuspendLayout(); + this.groupBoxLinesFound.SuspendLayout(); + this.contextMenuStrip1.SuspendLayout(); + this.contextMenuStrip2SelectAll.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(591, 602); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 14; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(672, 602); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 15; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // groupBoxNames + // + this.groupBoxNames.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxNames.Controls.Add(this.buttonAddCustomNames); + this.groupBoxNames.Controls.Add(this.textBoxExtraNames); + this.groupBoxNames.Controls.Add(this.labelExtraNames); + this.groupBoxNames.Controls.Add(this.buttonInverseSelection); + this.groupBoxNames.Controls.Add(this.buttonSelectAll); + this.groupBoxNames.Controls.Add(this.listViewNames); + this.groupBoxNames.Location = new System.Drawing.Point(5, 9); + this.groupBoxNames.Name = "groupBoxNames"; + this.groupBoxNames.Size = new System.Drawing.Size(747, 293); + this.groupBoxNames.TabIndex = 12; + this.groupBoxNames.TabStop = false; + this.groupBoxNames.Text = "Names found in subtitle"; + // + // buttonAddCustomNames + // + this.buttonAddCustomNames.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonAddCustomNames.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonAddCustomNames.Location = new System.Drawing.Point(640, 262); + this.buttonAddCustomNames.Name = "buttonAddCustomNames"; + this.buttonAddCustomNames.Size = new System.Drawing.Size(100, 23); + this.buttonAddCustomNames.TabIndex = 11; + this.buttonAddCustomNames.Text = "Add"; + this.buttonAddCustomNames.UseVisualStyleBackColor = true; + this.buttonAddCustomNames.Click += new System.EventHandler(this.buttonAddCustomNames_Click); + // + // textBoxExtraNames + // + this.textBoxExtraNames.Location = new System.Drawing.Point(10, 263); + this.textBoxExtraNames.Name = "textBoxExtraNames"; + this.textBoxExtraNames.Size = new System.Drawing.Size(624, 21); + this.textBoxExtraNames.TabIndex = 10; + // + // labelExtraNames + // + this.labelExtraNames.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelExtraNames.AutoSize = true; + this.labelExtraNames.Location = new System.Drawing.Point(7, 246); + this.labelExtraNames.Name = "labelExtraNames"; + this.labelExtraNames.Size = new System.Drawing.Size(172, 13); + this.labelExtraNames.TabIndex = 17; + this.labelExtraNames.Text = "Extra names (separate by comma)"; + // + // buttonInverseSelection + // + this.buttonInverseSelection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonInverseSelection.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonInverseSelection.Location = new System.Drawing.Point(88, 202); + this.buttonInverseSelection.Name = "buttonInverseSelection"; + this.buttonInverseSelection.Size = new System.Drawing.Size(100, 23); + this.buttonInverseSelection.TabIndex = 9; + this.buttonInverseSelection.Text = "Inverse selection"; + this.buttonInverseSelection.UseVisualStyleBackColor = true; + this.buttonInverseSelection.Click += new System.EventHandler(this.buttonInverseSelection_Click); + // + // buttonSelectAll + // + this.buttonSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonSelectAll.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonSelectAll.Location = new System.Drawing.Point(7, 202); + this.buttonSelectAll.Name = "buttonSelectAll"; + this.buttonSelectAll.Size = new System.Drawing.Size(75, 23); + this.buttonSelectAll.TabIndex = 8; + this.buttonSelectAll.Text = "Select all"; + this.buttonSelectAll.UseVisualStyleBackColor = true; + this.buttonSelectAll.Click += new System.EventHandler(this.buttonSelectAll_Click); + // + // listViewNames + // + this.listViewNames.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewNames.CheckBoxes = true; + this.listViewNames.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2}); + this.listViewNames.ContextMenuStrip = this.contextMenuStrip2SelectAll; + this.listViewNames.FullRowSelect = true; + this.listViewNames.HideSelection = false; + this.listViewNames.Location = new System.Drawing.Point(6, 19); + this.listViewNames.MultiSelect = false; + this.listViewNames.Name = "listViewNames"; + this.listViewNames.Size = new System.Drawing.Size(735, 177); + this.listViewNames.TabIndex = 7; + this.listViewNames.UseCompatibleStateImageBehavior = false; + this.listViewNames.View = System.Windows.Forms.View.Details; + this.listViewNames.SelectedIndexChanged += new System.EventHandler(this.ListViewNamesSelectedIndexChanged); + // + // columnHeader1 + // + this.columnHeader1.Text = "Enabled"; + this.columnHeader1.Width = 70; + // + // columnHeader2 + // + this.columnHeader2.Text = "Name"; + this.columnHeader2.Width = 620; + // + // groupBoxLinesFound + // + this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxLinesFound.Controls.Add(this.listViewFixes); + this.groupBoxLinesFound.Location = new System.Drawing.Point(5, 308); + this.groupBoxLinesFound.Name = "groupBoxLinesFound"; + this.groupBoxLinesFound.Size = new System.Drawing.Size(747, 286); + this.groupBoxLinesFound.TabIndex = 13; + this.groupBoxLinesFound.TabStop = false; + this.groupBoxLinesFound.Text = "Lines found: {0}"; + // + // listViewFixes + // + this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewFixes.CheckBoxes = true; + this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader4, + this.columnHeader5, + this.columnHeader7, + this.columnHeader8}); + this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; + this.listViewFixes.FullRowSelect = true; + this.listViewFixes.HideSelection = false; + this.listViewFixes.Location = new System.Drawing.Point(6, 23); + this.listViewFixes.Name = "listViewFixes"; + this.listViewFixes.Size = new System.Drawing.Size(735, 257); + this.listViewFixes.TabIndex = 9; + this.listViewFixes.UseCompatibleStateImageBehavior = false; + this.listViewFixes.View = System.Windows.Forms.View.Details; + this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged); + // + // columnHeader4 + // + this.columnHeader4.Text = "Apply"; + this.columnHeader4.Width = 45; + // + // columnHeader5 + // + this.columnHeader5.Text = "Line#"; + this.columnHeader5.Width = 61; + // + // columnHeader7 + // + this.columnHeader7.Text = "Before"; + this.columnHeader7.Width = 292; + // + // columnHeader8 + // + this.columnHeader8.Text = "After"; + this.columnHeader8.Width = 292; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSelectAll, + this.toolStripMenuItemInverseSelection}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(162, 48); + // + // toolStripMenuItemSelectAll + // + this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; + this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(161, 22); + this.toolStripMenuItemSelectAll.Text = "Select all"; + this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); + // + // toolStripMenuItemInverseSelection + // + this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; + this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(161, 22); + this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; + this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); + // + // labelXLinesSelected + // + this.labelXLinesSelected.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelXLinesSelected.AutoSize = true; + this.labelXLinesSelected.Location = new System.Drawing.Point(5, 602); + this.labelXLinesSelected.Name = "labelXLinesSelected"; + this.labelXLinesSelected.Size = new System.Drawing.Size(78, 13); + this.labelXLinesSelected.TabIndex = 16; + this.labelXLinesSelected.Text = "XLinesSelected"; + // + // contextMenuStrip2SelectAll + // + this.contextMenuStrip2SelectAll.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItem1SelectAll, + this.toolStripMenuItem2InverseSelection}); + this.contextMenuStrip2SelectAll.Name = "contextMenuStrip1"; + this.contextMenuStrip2SelectAll.Size = new System.Drawing.Size(181, 70); + // + // toolStripMenuItem1SelectAll + // + this.toolStripMenuItem1SelectAll.Name = "toolStripMenuItem1SelectAll"; + this.toolStripMenuItem1SelectAll.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItem1SelectAll.Text = "Select all"; + this.toolStripMenuItem1SelectAll.Click += new System.EventHandler(this.toolStripMenuItem1SelectAll_Click); + // + // toolStripMenuItem2InverseSelection + // + this.toolStripMenuItem2InverseSelection.Name = "toolStripMenuItem2InverseSelection"; + this.toolStripMenuItem2InverseSelection.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItem2InverseSelection.Text = "Inverse selection"; + this.toolStripMenuItem2InverseSelection.Click += new System.EventHandler(this.toolStripMenuItem2InverseSelection_Click); + // + // ChangeCasingNames + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(757, 632); + this.Controls.Add(this.labelXLinesSelected); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.groupBoxNames); + this.Controls.Add(this.groupBoxLinesFound); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(600, 480); + this.Name = "ChangeCasingNames"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Change casing - Names"; + this.Shown += new System.EventHandler(this.ChangeCasingNames_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChangeCasingNames_KeyDown); + this.groupBoxNames.ResumeLayout(false); + this.groupBoxNames.PerformLayout(); + this.groupBoxLinesFound.ResumeLayout(false); + this.contextMenuStrip1.ResumeLayout(false); + this.contextMenuStrip2SelectAll.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.GroupBox groupBoxNames; + private System.Windows.Forms.ListView listViewNames; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.GroupBox groupBoxLinesFound; + private System.Windows.Forms.ListView listViewFixes; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.ColumnHeader columnHeader8; + private System.Windows.Forms.Label labelXLinesSelected; + private System.Windows.Forms.Button buttonInverseSelection; + private System.Windows.Forms.Button buttonSelectAll; + private System.Windows.Forms.Button buttonAddCustomNames; + private System.Windows.Forms.TextBox textBoxExtraNames; + private System.Windows.Forms.Label labelExtraNames; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip2SelectAll; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1SelectAll; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2InverseSelection; + } } \ No newline at end of file diff --git a/src/Forms/ChangeCasingNames.cs b/src/ui/Forms/ChangeCasingNames.cs similarity index 97% rename from src/Forms/ChangeCasingNames.cs rename to src/ui/Forms/ChangeCasingNames.cs index 12832b5a0..6467b85d4 100644 --- a/src/Forms/ChangeCasingNames.cs +++ b/src/ui/Forms/ChangeCasingNames.cs @@ -1,357 +1,357 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Dictionaries; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ChangeCasingNames : Form - { - private readonly HashSet _usedNames = new HashSet(); - private Subtitle _subtitle; - private const string ExpectedEndChars = " ,.!?:;')]<-\"\r\n"; - private NameList _nameList; - private List _nameListInclMulti; - private string _language; - - public ChangeCasingNames() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - labelXLinesSelected.Text = string.Empty; - Text = Configuration.Settings.Language.ChangeCasingNames.Title; - groupBoxNames.Text = string.Empty; - listViewNames.Columns[0].Text = Configuration.Settings.Language.ChangeCasingNames.Enabled; - listViewNames.Columns[1].Text = Configuration.Settings.Language.ChangeCasingNames.Name; - groupBoxLinesFound.Text = string.Empty; - listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; - listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; - listViewFixes.Columns[2].Text = Configuration.Settings.Language.General.Before; - listViewFixes.Columns[3].Text = Configuration.Settings.Language.General.After; - - buttonSelectAll.Text = Configuration.Settings.Language.FixCommonErrors.SelectAll; - buttonInverseSelection.Text = Configuration.Settings.Language.FixCommonErrors.InverseSelection; - toolStripMenuItem1SelectAll.Text = Configuration.Settings.Language.FixCommonErrors.SelectAll; - toolStripMenuItem2InverseSelection.Text = Configuration.Settings.Language.FixCommonErrors.InverseSelection; - labelExtraNames.Text = Configuration.Settings.Language.ChangeCasingNames.ExtraNames; - buttonAddCustomNames.Text = Configuration.Settings.Language.DvdSubRip.Add; - toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; - toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - listViewFixes.Resize += delegate - { - var width = (listViewFixes.Width - (listViewFixes.Columns[0].Width + listViewFixes.Columns[1].Width)) / 2; - listViewFixes.Columns[2].Width = width; - listViewFixes.Columns[3].Width = width; - }; - UiUtil.FixLargeFonts(this, buttonOK); - } - - public int LinesChanged { get; private set; } - - private void ChangeCasingNames_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void AddToListViewNames(string name) - { - var item = new ListViewItem(string.Empty) { Checked = true }; - item.SubItems.Add(name); - listViewNames.Items.Add(item); - } - - public void Initialize(Subtitle subtitle) - { - _subtitle = subtitle; - - _language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); - if (string.IsNullOrEmpty(_language)) - { - _language = "en_US"; - } - - _nameList = new NameList(Configuration.DictionariesDirectory, _language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); - _nameListInclMulti = _nameList.GetAllNames(); // Will contains both one word names and multi names - - FindAllNames(); - if (_language.StartsWith("en", StringComparison.OrdinalIgnoreCase)) - { - foreach (ListViewItem item in listViewNames.Items) - { - var name = item.SubItems[1].Text; - if (name == "US") - { - item.Checked = false; - } - } - } - - GeneratePreview(); - } - - private void GeneratePreview() - { - Cursor = Cursors.WaitCursor; - listViewFixes.BeginUpdate(); - listViewFixes.Items.Clear(); - foreach (var p in _subtitle.Paragraphs) - { - string text = p.Text; - foreach (ListViewItem item in listViewNames.Items) - { - string name = item.SubItems[1].Text; - - string textNoTags = HtmlUtil.RemoveHtmlTags(text, true); - if (textNoTags != textNoTags.ToUpperInvariant()) - { - if (item.Checked && text != null && text.Contains(name, StringComparison.OrdinalIgnoreCase) && name.Length > 1 && name != name.ToLowerInvariant()) - { - var st = new StrippableText(text); - st.FixCasing(new List { name }, true, false, false, string.Empty); - text = st.MergedString; - } - } - } - if (text != p.Text) - { - AddToPreviewListView(p, text); - } - } - listViewFixes.EndUpdate(); - groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.ChangeCasingNames.LinesFoundX, listViewFixes.Items.Count); - Cursor = Cursors.Default; - } - - private void AddToPreviewListView(Paragraph p, string newText) - { - var item = new ListViewItem(string.Empty) { Tag = p, Checked = true }; - item.SubItems.Add(p.Number.ToString(CultureInfo.InvariantCulture)); - item.SubItems.Add(UiUtil.GetListViewTextFromString(p.Text)); - item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); - listViewFixes.Items.Add(item); - } - - private void AddCustomNames() - { - foreach (var s in textBoxExtraNames.Text.Split(',')) - { - var name = s.Trim(); - if (name.Length > 1 && !_nameListInclMulti.Contains(name)) - { - _nameListInclMulti.Add(name); - } - } - } - - private void FindAllNames() - { - string text = HtmlUtil.RemoveHtmlTags(_subtitle.GetAllTexts()); - string textToLower = text.ToLowerInvariant(); - listViewNames.BeginUpdate(); - foreach (var name in _nameListInclMulti) - { - int startIndex = textToLower.IndexOf(name.ToLowerInvariant(), StringComparison.Ordinal); - if (startIndex >= 0) - { - while (startIndex >= 0 && startIndex < text.Length && - textToLower.Substring(startIndex).Contains(name.ToLowerInvariant()) && name.Length > 1 && name != name.ToLowerInvariant()) - { - bool startOk = startIndex == 0 || "([ --'>\r\n¿¡\"”“„".Contains(text[startIndex - 1]); - if (startOk) - { - int end = startIndex + name.Length; - bool endOk = end <= text.Length; - if (endOk) - { - endOk = end == text.Length || ExpectedEndChars.Contains(text[end]); - } - - if (endOk && text.Substring(startIndex, name.Length) != name) // do not add names where casing already is correct - { - if (!_usedNames.Contains(name)) - { - var isDont = _language.StartsWith("en", StringComparison.OrdinalIgnoreCase) && text.Substring(startIndex).StartsWith("don't", StringComparison.InvariantCultureIgnoreCase); - if (!isDont) - { - _usedNames.Add(name); - AddToListViewNames(name); - break; // break while - } - } - } - } - - startIndex = textToLower.IndexOf(name.ToLowerInvariant(), startIndex + 2, StringComparison.Ordinal); - } - } - } - listViewNames.EndUpdate(); - groupBoxNames.Text = string.Format(Configuration.Settings.Language.ChangeCasingNames.NamesFoundInSubtitleX, listViewNames.Items.Count); - } - - private void ListViewNamesSelectedIndexChanged(object sender, EventArgs e) - { - labelXLinesSelected.Text = string.Empty; - if (listViewNames.SelectedItems.Count != 1) - { - return; - } - - string name = listViewNames.SelectedItems[0].SubItems[1].Text; - listViewFixes.BeginUpdate(); - - foreach (ListViewItem item in listViewFixes.Items) - { - item.Selected = false; - - string text = UiUtil.GetStringFromListViewText(item.SubItems[2].Text); - - string lower = text.ToLowerInvariant(); - if (lower.Contains(name.ToLowerInvariant()) && name.Length > 1 && name != name.ToLowerInvariant()) - { - int start = lower.IndexOf(name.ToLowerInvariant(), StringComparison.Ordinal); - if (start >= 0) - { - bool startOk = start == 0 || lower[start - 1] == ' ' || lower[start - 1] == '-' || lower[start - 1] == '"' || - lower[start - 1] == '\'' || lower[start - 1] == '>' || Environment.NewLine.EndsWith(lower[start - 1]); - - if (startOk) - { - int end = start + name.Length; - bool endOk = end <= lower.Length; - if (endOk) - { - endOk = end == lower.Length || ExpectedEndChars.Contains(lower[end]); - } - - item.Selected = endOk; - } - } - } - } - - listViewFixes.EndUpdate(); - - if (listViewFixes.SelectedItems.Count > 0) - { - listViewFixes.EnsureVisible(listViewFixes.SelectedItems[0].Index); - } - } - - private void ListViewNamesItemChecked(object sender, ItemCheckedEventArgs e) - { - GeneratePreview(); - } - - private void ChangeCasingNames_Shown(object sender, EventArgs e) - { - listViewNames.ItemChecked += ListViewNamesItemChecked; - } - - internal void FixCasing() - { - foreach (ListViewItem item in listViewFixes.Items) - { - if (item.Checked) - { - LinesChanged++; - var p = item.Tag as Paragraph; - if (p != null) - { - p.Text = UiUtil.GetStringFromListViewText(item.SubItems[3].Text); - } - } - } - } - - private void ButtonOkClick(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e) - { - if (listViewFixes.SelectedItems.Count > 1) - { - labelXLinesSelected.Text = string.Format(Configuration.Settings.Language.Main.XLinesSelected, listViewFixes.SelectedItems.Count); - } - else - { - labelXLinesSelected.Text = string.Empty; - } - } - - private void buttonSelectAll_Click(object sender, EventArgs e) - { - DoSelection(true); - } - - private void buttonInverseSelection_Click(object sender, EventArgs e) - { - DoSelection(false); - } - - private void DoSelection(bool selectAll) - { - listViewNames.ItemChecked -= ListViewNamesItemChecked; - listViewNames.BeginUpdate(); - foreach (ListViewItem item in listViewNames.Items) - { - if (selectAll) - { - item.Checked = true; - } - else - { - item.Checked = !item.Checked; - } - } - listViewNames.EndUpdate(); - listViewNames.ItemChecked += ListViewNamesItemChecked; - GeneratePreview(); - } - - private void buttonAddCustomNames_Click(object sender, EventArgs e) - { - AddCustomNames(); - textBoxExtraNames.Text = string.Empty; - FindAllNames(); - } - - private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = true; - } - } - - private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = !item.Checked; - } - } - - private void toolStripMenuItem1SelectAll_Click(object sender, EventArgs e) - { - DoSelection(true); - } - - private void toolStripMenuItem2InverseSelection_Click(object sender, EventArgs e) - { - DoSelection(false); - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Dictionaries; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ChangeCasingNames : Form + { + private readonly HashSet _usedNames = new HashSet(); + private Subtitle _subtitle; + private const string ExpectedEndChars = " ,.!?:;')]<-\"\r\n"; + private NameList _nameList; + private List _nameListInclMulti; + private string _language; + + public ChangeCasingNames() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + labelXLinesSelected.Text = string.Empty; + Text = Configuration.Settings.Language.ChangeCasingNames.Title; + groupBoxNames.Text = string.Empty; + listViewNames.Columns[0].Text = Configuration.Settings.Language.ChangeCasingNames.Enabled; + listViewNames.Columns[1].Text = Configuration.Settings.Language.ChangeCasingNames.Name; + groupBoxLinesFound.Text = string.Empty; + listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; + listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; + listViewFixes.Columns[2].Text = Configuration.Settings.Language.General.Before; + listViewFixes.Columns[3].Text = Configuration.Settings.Language.General.After; + + buttonSelectAll.Text = Configuration.Settings.Language.FixCommonErrors.SelectAll; + buttonInverseSelection.Text = Configuration.Settings.Language.FixCommonErrors.InverseSelection; + toolStripMenuItem1SelectAll.Text = Configuration.Settings.Language.FixCommonErrors.SelectAll; + toolStripMenuItem2InverseSelection.Text = Configuration.Settings.Language.FixCommonErrors.InverseSelection; + labelExtraNames.Text = Configuration.Settings.Language.ChangeCasingNames.ExtraNames; + buttonAddCustomNames.Text = Configuration.Settings.Language.DvdSubRip.Add; + toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; + toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + listViewFixes.Resize += delegate + { + var width = (listViewFixes.Width - (listViewFixes.Columns[0].Width + listViewFixes.Columns[1].Width)) / 2; + listViewFixes.Columns[2].Width = width; + listViewFixes.Columns[3].Width = width; + }; + UiUtil.FixLargeFonts(this, buttonOK); + } + + public int LinesChanged { get; private set; } + + private void ChangeCasingNames_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void AddToListViewNames(string name) + { + var item = new ListViewItem(string.Empty) { Checked = true }; + item.SubItems.Add(name); + listViewNames.Items.Add(item); + } + + public void Initialize(Subtitle subtitle) + { + _subtitle = subtitle; + + _language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); + if (string.IsNullOrEmpty(_language)) + { + _language = "en_US"; + } + + _nameList = new NameList(Configuration.DictionariesDirectory, _language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); + _nameListInclMulti = _nameList.GetAllNames(); // Will contains both one word names and multi names + + FindAllNames(); + if (_language.StartsWith("en", StringComparison.OrdinalIgnoreCase)) + { + foreach (ListViewItem item in listViewNames.Items) + { + var name = item.SubItems[1].Text; + if (name == "US") + { + item.Checked = false; + } + } + } + + GeneratePreview(); + } + + private void GeneratePreview() + { + Cursor = Cursors.WaitCursor; + listViewFixes.BeginUpdate(); + listViewFixes.Items.Clear(); + foreach (var p in _subtitle.Paragraphs) + { + string text = p.Text; + foreach (ListViewItem item in listViewNames.Items) + { + string name = item.SubItems[1].Text; + + string textNoTags = HtmlUtil.RemoveHtmlTags(text, true); + if (textNoTags != textNoTags.ToUpperInvariant()) + { + if (item.Checked && text != null && text.Contains(name, StringComparison.OrdinalIgnoreCase) && name.Length > 1 && name != name.ToLowerInvariant()) + { + var st = new StrippableText(text); + st.FixCasing(new List { name }, true, false, false, string.Empty); + text = st.MergedString; + } + } + } + if (text != p.Text) + { + AddToPreviewListView(p, text); + } + } + listViewFixes.EndUpdate(); + groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.ChangeCasingNames.LinesFoundX, listViewFixes.Items.Count); + Cursor = Cursors.Default; + } + + private void AddToPreviewListView(Paragraph p, string newText) + { + var item = new ListViewItem(string.Empty) { Tag = p, Checked = true }; + item.SubItems.Add(p.Number.ToString(CultureInfo.InvariantCulture)); + item.SubItems.Add(UiUtil.GetListViewTextFromString(p.Text)); + item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); + listViewFixes.Items.Add(item); + } + + private void AddCustomNames() + { + foreach (var s in textBoxExtraNames.Text.Split(',')) + { + var name = s.Trim(); + if (name.Length > 1 && !_nameListInclMulti.Contains(name)) + { + _nameListInclMulti.Add(name); + } + } + } + + private void FindAllNames() + { + string text = HtmlUtil.RemoveHtmlTags(_subtitle.GetAllTexts()); + string textToLower = text.ToLowerInvariant(); + listViewNames.BeginUpdate(); + foreach (var name in _nameListInclMulti) + { + int startIndex = textToLower.IndexOf(name.ToLowerInvariant(), StringComparison.Ordinal); + if (startIndex >= 0) + { + while (startIndex >= 0 && startIndex < text.Length && + textToLower.Substring(startIndex).Contains(name.ToLowerInvariant()) && name.Length > 1 && name != name.ToLowerInvariant()) + { + bool startOk = startIndex == 0 || "([ --'>\r\n¿¡\"”“„".Contains(text[startIndex - 1]); + if (startOk) + { + int end = startIndex + name.Length; + bool endOk = end <= text.Length; + if (endOk) + { + endOk = end == text.Length || ExpectedEndChars.Contains(text[end]); + } + + if (endOk && text.Substring(startIndex, name.Length) != name) // do not add names where casing already is correct + { + if (!_usedNames.Contains(name)) + { + var isDont = _language.StartsWith("en", StringComparison.OrdinalIgnoreCase) && text.Substring(startIndex).StartsWith("don't", StringComparison.InvariantCultureIgnoreCase); + if (!isDont) + { + _usedNames.Add(name); + AddToListViewNames(name); + break; // break while + } + } + } + } + + startIndex = textToLower.IndexOf(name.ToLowerInvariant(), startIndex + 2, StringComparison.Ordinal); + } + } + } + listViewNames.EndUpdate(); + groupBoxNames.Text = string.Format(Configuration.Settings.Language.ChangeCasingNames.NamesFoundInSubtitleX, listViewNames.Items.Count); + } + + private void ListViewNamesSelectedIndexChanged(object sender, EventArgs e) + { + labelXLinesSelected.Text = string.Empty; + if (listViewNames.SelectedItems.Count != 1) + { + return; + } + + string name = listViewNames.SelectedItems[0].SubItems[1].Text; + listViewFixes.BeginUpdate(); + + foreach (ListViewItem item in listViewFixes.Items) + { + item.Selected = false; + + string text = UiUtil.GetStringFromListViewText(item.SubItems[2].Text); + + string lower = text.ToLowerInvariant(); + if (lower.Contains(name.ToLowerInvariant()) && name.Length > 1 && name != name.ToLowerInvariant()) + { + int start = lower.IndexOf(name.ToLowerInvariant(), StringComparison.Ordinal); + if (start >= 0) + { + bool startOk = start == 0 || lower[start - 1] == ' ' || lower[start - 1] == '-' || lower[start - 1] == '"' || + lower[start - 1] == '\'' || lower[start - 1] == '>' || Environment.NewLine.EndsWith(lower[start - 1]); + + if (startOk) + { + int end = start + name.Length; + bool endOk = end <= lower.Length; + if (endOk) + { + endOk = end == lower.Length || ExpectedEndChars.Contains(lower[end]); + } + + item.Selected = endOk; + } + } + } + } + + listViewFixes.EndUpdate(); + + if (listViewFixes.SelectedItems.Count > 0) + { + listViewFixes.EnsureVisible(listViewFixes.SelectedItems[0].Index); + } + } + + private void ListViewNamesItemChecked(object sender, ItemCheckedEventArgs e) + { + GeneratePreview(); + } + + private void ChangeCasingNames_Shown(object sender, EventArgs e) + { + listViewNames.ItemChecked += ListViewNamesItemChecked; + } + + internal void FixCasing() + { + foreach (ListViewItem item in listViewFixes.Items) + { + if (item.Checked) + { + LinesChanged++; + var p = item.Tag as Paragraph; + if (p != null) + { + p.Text = UiUtil.GetStringFromListViewText(item.SubItems[3].Text); + } + } + } + } + + private void ButtonOkClick(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e) + { + if (listViewFixes.SelectedItems.Count > 1) + { + labelXLinesSelected.Text = string.Format(Configuration.Settings.Language.Main.XLinesSelected, listViewFixes.SelectedItems.Count); + } + else + { + labelXLinesSelected.Text = string.Empty; + } + } + + private void buttonSelectAll_Click(object sender, EventArgs e) + { + DoSelection(true); + } + + private void buttonInverseSelection_Click(object sender, EventArgs e) + { + DoSelection(false); + } + + private void DoSelection(bool selectAll) + { + listViewNames.ItemChecked -= ListViewNamesItemChecked; + listViewNames.BeginUpdate(); + foreach (ListViewItem item in listViewNames.Items) + { + if (selectAll) + { + item.Checked = true; + } + else + { + item.Checked = !item.Checked; + } + } + listViewNames.EndUpdate(); + listViewNames.ItemChecked += ListViewNamesItemChecked; + GeneratePreview(); + } + + private void buttonAddCustomNames_Click(object sender, EventArgs e) + { + AddCustomNames(); + textBoxExtraNames.Text = string.Empty; + FindAllNames(); + } + + private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = true; + } + } + + private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = !item.Checked; + } + } + + private void toolStripMenuItem1SelectAll_Click(object sender, EventArgs e) + { + DoSelection(true); + } + + private void toolStripMenuItem2InverseSelection_Click(object sender, EventArgs e) + { + DoSelection(false); + } + } +} diff --git a/src/Forms/ChangeCasingNames.resx b/src/ui/Forms/ChangeCasingNames.resx similarity index 97% rename from src/Forms/ChangeCasingNames.resx rename to src/ui/Forms/ChangeCasingNames.resx index 9292214b5..b52bb6b1c 100644 --- a/src/Forms/ChangeCasingNames.resx +++ b/src/ui/Forms/ChangeCasingNames.resx @@ -1,126 +1,126 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 172, 17 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 172, 17 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/ChangeFrameRate.Designer.cs b/src/ui/Forms/ChangeFrameRate.Designer.cs similarity index 98% rename from src/Forms/ChangeFrameRate.Designer.cs rename to src/ui/Forms/ChangeFrameRate.Designer.cs index b4648679d..3637f2001 100644 --- a/src/Forms/ChangeFrameRate.Designer.cs +++ b/src/ui/Forms/ChangeFrameRate.Designer.cs @@ -1,188 +1,188 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ChangeFrameRate - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.labelInfo = new System.Windows.Forms.Label(); - this.comboBoxFrameRateFrom = new System.Windows.Forms.ComboBox(); - this.labelFromFrameRate = new System.Windows.Forms.Label(); - this.comboBoxFrameRateTo = new System.Windows.Forms.ComboBox(); - this.labelToFrameRate = new System.Windows.Forms.Label(); - this.buttonGetFrameRateFrom = new System.Windows.Forms.Button(); - this.buttonGetFrameRateTo = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.buttonSwap = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(277, 113); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 3; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOK - // - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(194, 113); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 2; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // labelInfo - // - this.labelInfo.AllowDrop = true; - this.labelInfo.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.labelInfo.Location = new System.Drawing.Point(12, 9); - this.labelInfo.Name = "labelInfo"; - this.labelInfo.Size = new System.Drawing.Size(284, 26); - this.labelInfo.TabIndex = 3; - this.labelInfo.Text = "Convert frame rate of subtitle"; - // - // comboBoxFrameRateFrom - // - this.comboBoxFrameRateFrom.FormattingEnabled = true; - this.comboBoxFrameRateFrom.Location = new System.Drawing.Point(148, 45); - this.comboBoxFrameRateFrom.Name = "comboBoxFrameRateFrom"; - this.comboBoxFrameRateFrom.Size = new System.Drawing.Size(121, 21); - this.comboBoxFrameRateFrom.TabIndex = 4; - // - // labelFromFrameRate - // - this.labelFromFrameRate.Location = new System.Drawing.Point(3, 45); - this.labelFromFrameRate.Name = "labelFromFrameRate"; - this.labelFromFrameRate.Size = new System.Drawing.Size(145, 21); - this.labelFromFrameRate.TabIndex = 6; - this.labelFromFrameRate.Text = "From frame rate"; - this.labelFromFrameRate.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // comboBoxFrameRateTo - // - this.comboBoxFrameRateTo.FormattingEnabled = true; - this.comboBoxFrameRateTo.Location = new System.Drawing.Point(148, 74); - this.comboBoxFrameRateTo.Name = "comboBoxFrameRateTo"; - this.comboBoxFrameRateTo.Size = new System.Drawing.Size(121, 21); - this.comboBoxFrameRateTo.TabIndex = 6; - // - // labelToFrameRate - // - this.labelToFrameRate.Location = new System.Drawing.Point(6, 74); - this.labelToFrameRate.Name = "labelToFrameRate"; - this.labelToFrameRate.Size = new System.Drawing.Size(142, 17); - this.labelToFrameRate.TabIndex = 8; - this.labelToFrameRate.Text = "To frame rate"; - this.labelToFrameRate.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // buttonGetFrameRateFrom - // - this.buttonGetFrameRateFrom.Location = new System.Drawing.Point(275, 45); - this.buttonGetFrameRateFrom.Name = "buttonGetFrameRateFrom"; - this.buttonGetFrameRateFrom.Size = new System.Drawing.Size(28, 23); - this.buttonGetFrameRateFrom.TabIndex = 5; - this.buttonGetFrameRateFrom.Text = "..."; - this.buttonGetFrameRateFrom.UseVisualStyleBackColor = true; - this.buttonGetFrameRateFrom.Click += new System.EventHandler(this.ButtonGetFrameRateFromClick); - // - // buttonGetFrameRateTo - // - this.buttonGetFrameRateTo.Location = new System.Drawing.Point(275, 73); - this.buttonGetFrameRateTo.Name = "buttonGetFrameRateTo"; - this.buttonGetFrameRateTo.Size = new System.Drawing.Size(28, 23); - this.buttonGetFrameRateTo.TabIndex = 7; - this.buttonGetFrameRateTo.Text = "..."; - this.buttonGetFrameRateTo.UseVisualStyleBackColor = true; - this.buttonGetFrameRateTo.Click += new System.EventHandler(this.ButtonGetFrameRateToClick); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // buttonSwap - // - this.buttonSwap.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.buttonSwap.Location = new System.Drawing.Point(312, 57); - this.buttonSwap.Name = "buttonSwap"; - this.buttonSwap.Size = new System.Drawing.Size(25, 28); - this.buttonSwap.TabIndex = 8; - this.buttonSwap.Text = "<->"; - this.buttonSwap.UseVisualStyleBackColor = true; - this.buttonSwap.Click += new System.EventHandler(this.buttonSwap_Click); - // - // ChangeFrameRate - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(364, 148); - this.Controls.Add(this.buttonSwap); - this.Controls.Add(this.buttonGetFrameRateTo); - this.Controls.Add(this.buttonGetFrameRateFrom); - this.Controls.Add(this.comboBoxFrameRateTo); - this.Controls.Add(this.labelToFrameRate); - this.Controls.Add(this.comboBoxFrameRateFrom); - this.Controls.Add(this.labelFromFrameRate); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.labelInfo); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ChangeFrameRate"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Change frame rate"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormChangeFrameRate_KeyDown); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Label labelInfo; - private System.Windows.Forms.ComboBox comboBoxFrameRateFrom; - private System.Windows.Forms.Label labelFromFrameRate; - private System.Windows.Forms.ComboBox comboBoxFrameRateTo; - private System.Windows.Forms.Label labelToFrameRate; - private System.Windows.Forms.Button buttonGetFrameRateFrom; - private System.Windows.Forms.Button buttonGetFrameRateTo; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Button buttonSwap; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ChangeFrameRate + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.labelInfo = new System.Windows.Forms.Label(); + this.comboBoxFrameRateFrom = new System.Windows.Forms.ComboBox(); + this.labelFromFrameRate = new System.Windows.Forms.Label(); + this.comboBoxFrameRateTo = new System.Windows.Forms.ComboBox(); + this.labelToFrameRate = new System.Windows.Forms.Label(); + this.buttonGetFrameRateFrom = new System.Windows.Forms.Button(); + this.buttonGetFrameRateTo = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.buttonSwap = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(277, 113); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOK + // + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(194, 113); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 2; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // labelInfo + // + this.labelInfo.AllowDrop = true; + this.labelInfo.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.labelInfo.Location = new System.Drawing.Point(12, 9); + this.labelInfo.Name = "labelInfo"; + this.labelInfo.Size = new System.Drawing.Size(284, 26); + this.labelInfo.TabIndex = 3; + this.labelInfo.Text = "Convert frame rate of subtitle"; + // + // comboBoxFrameRateFrom + // + this.comboBoxFrameRateFrom.FormattingEnabled = true; + this.comboBoxFrameRateFrom.Location = new System.Drawing.Point(148, 45); + this.comboBoxFrameRateFrom.Name = "comboBoxFrameRateFrom"; + this.comboBoxFrameRateFrom.Size = new System.Drawing.Size(121, 21); + this.comboBoxFrameRateFrom.TabIndex = 4; + // + // labelFromFrameRate + // + this.labelFromFrameRate.Location = new System.Drawing.Point(3, 45); + this.labelFromFrameRate.Name = "labelFromFrameRate"; + this.labelFromFrameRate.Size = new System.Drawing.Size(145, 21); + this.labelFromFrameRate.TabIndex = 6; + this.labelFromFrameRate.Text = "From frame rate"; + this.labelFromFrameRate.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // comboBoxFrameRateTo + // + this.comboBoxFrameRateTo.FormattingEnabled = true; + this.comboBoxFrameRateTo.Location = new System.Drawing.Point(148, 74); + this.comboBoxFrameRateTo.Name = "comboBoxFrameRateTo"; + this.comboBoxFrameRateTo.Size = new System.Drawing.Size(121, 21); + this.comboBoxFrameRateTo.TabIndex = 6; + // + // labelToFrameRate + // + this.labelToFrameRate.Location = new System.Drawing.Point(6, 74); + this.labelToFrameRate.Name = "labelToFrameRate"; + this.labelToFrameRate.Size = new System.Drawing.Size(142, 17); + this.labelToFrameRate.TabIndex = 8; + this.labelToFrameRate.Text = "To frame rate"; + this.labelToFrameRate.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // buttonGetFrameRateFrom + // + this.buttonGetFrameRateFrom.Location = new System.Drawing.Point(275, 45); + this.buttonGetFrameRateFrom.Name = "buttonGetFrameRateFrom"; + this.buttonGetFrameRateFrom.Size = new System.Drawing.Size(28, 23); + this.buttonGetFrameRateFrom.TabIndex = 5; + this.buttonGetFrameRateFrom.Text = "..."; + this.buttonGetFrameRateFrom.UseVisualStyleBackColor = true; + this.buttonGetFrameRateFrom.Click += new System.EventHandler(this.ButtonGetFrameRateFromClick); + // + // buttonGetFrameRateTo + // + this.buttonGetFrameRateTo.Location = new System.Drawing.Point(275, 73); + this.buttonGetFrameRateTo.Name = "buttonGetFrameRateTo"; + this.buttonGetFrameRateTo.Size = new System.Drawing.Size(28, 23); + this.buttonGetFrameRateTo.TabIndex = 7; + this.buttonGetFrameRateTo.Text = "..."; + this.buttonGetFrameRateTo.UseVisualStyleBackColor = true; + this.buttonGetFrameRateTo.Click += new System.EventHandler(this.ButtonGetFrameRateToClick); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // buttonSwap + // + this.buttonSwap.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.buttonSwap.Location = new System.Drawing.Point(312, 57); + this.buttonSwap.Name = "buttonSwap"; + this.buttonSwap.Size = new System.Drawing.Size(25, 28); + this.buttonSwap.TabIndex = 8; + this.buttonSwap.Text = "<->"; + this.buttonSwap.UseVisualStyleBackColor = true; + this.buttonSwap.Click += new System.EventHandler(this.buttonSwap_Click); + // + // ChangeFrameRate + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(364, 148); + this.Controls.Add(this.buttonSwap); + this.Controls.Add(this.buttonGetFrameRateTo); + this.Controls.Add(this.buttonGetFrameRateFrom); + this.Controls.Add(this.comboBoxFrameRateTo); + this.Controls.Add(this.labelToFrameRate); + this.Controls.Add(this.comboBoxFrameRateFrom); + this.Controls.Add(this.labelFromFrameRate); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.labelInfo); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ChangeFrameRate"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Change frame rate"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormChangeFrameRate_KeyDown); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Label labelInfo; + private System.Windows.Forms.ComboBox comboBoxFrameRateFrom; + private System.Windows.Forms.Label labelFromFrameRate; + private System.Windows.Forms.ComboBox comboBoxFrameRateTo; + private System.Windows.Forms.Label labelToFrameRate; + private System.Windows.Forms.Button buttonGetFrameRateFrom; + private System.Windows.Forms.Button buttonGetFrameRateTo; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Button buttonSwap; + } } \ No newline at end of file diff --git a/src/Forms/ChangeFrameRate.cs b/src/ui/Forms/ChangeFrameRate.cs similarity index 97% rename from src/Forms/ChangeFrameRate.cs rename to src/ui/Forms/ChangeFrameRate.cs index 6b5c60764..7bb58b2a1 100644 --- a/src/Forms/ChangeFrameRate.cs +++ b/src/ui/Forms/ChangeFrameRate.cs @@ -1,124 +1,124 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Drawing; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ChangeFrameRate : PositionAndSizeForm - { - public ChangeFrameRate() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - InitializeCombobox(comboBoxFrameRateFrom); - InitializeCombobox(comboBoxFrameRateTo); - - var language = Configuration.Settings.Language.ChangeFrameRate; - Text = language.Title; - labelInfo.Text = language.ConvertFrameRateOfSubtitle; - labelFromFrameRate.Text = language.FromFrameRate; - labelToFrameRate.Text = language.ToFrameRate; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - if (Configuration.IsRunningOnWindows) - { - buttonSwap.Text = "🡙"; - } - else - { - buttonSwap.Text = "<->"; - buttonSwap.Width = 35; - buttonSwap.Font = new Font(Font.FontFamily, Font.Size); - } - } - - private void InitializeCombobox(ComboBox comboBox) - { - comboBox.BeginUpdate(); - comboBox.Items.Clear(); - comboBox.Items.Add(23.976); - comboBox.Items.Add(24.0); - comboBox.Items.Add(25.0); - comboBox.Items.Add(29.97); - comboBox.Items.Add(30); - comboBox.EndUpdate(); - } - - private void FormChangeFrameRate_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - public void Initialize(string fromFrameRate) - { - comboBoxFrameRateFrom.Text = fromFrameRate; - } - - private string GetFrameRateFromVideoFile(string oldFrameRate) - { - openFileDialog1.Title = Configuration.Settings.Language.General.OpenVideoFileTitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = Utilities.GetVideoFileFilter(false); - openFileDialog1.FileName = string.Empty; - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - var info = UiUtil.GetVideoInfo(openFileDialog1.FileName); - if (info?.Success == true) - { - return Math.Round(info.FramesPerSecond, 3).ToString(); - } - } - return oldFrameRate; - } - - private void ButtonGetFrameRateFromClick(object sender, EventArgs e) - { - comboBoxFrameRateFrom.Text = GetFrameRateFromVideoFile(comboBoxFrameRateFrom.Text); - } - - private void ButtonGetFrameRateToClick(object sender, EventArgs e) - { - comboBoxFrameRateTo.Text = GetFrameRateFromVideoFile(comboBoxFrameRateTo.Text); - } - - private void ButtonOkClick(object sender, EventArgs e) - { - if (comboBoxFrameRateFrom.Text.Trim() == comboBoxFrameRateTo.Text.Trim()) - { - MessageBox.Show(Configuration.Settings.Language.ChangeFrameRate.FrameRateNotChanged); - return; - } - - if (double.TryParse(comboBoxFrameRateFrom.Text, out _) && double.TryParse(comboBoxFrameRateTo.Text, out _)) - { - DialogResult = DialogResult.OK; - } - else - { - MessageBox.Show(Configuration.Settings.Language.ChangeFrameRate.FrameRateNotCorrect); - } - } - - private void buttonSwap_Click(object sender, EventArgs e) - { - string oldFrameRate = comboBoxFrameRateFrom.Text; - string newFrameRate = comboBoxFrameRateTo.Text; - - comboBoxFrameRateFrom.Text = newFrameRate; - comboBoxFrameRateTo.Text = oldFrameRate; - } - - public double OldFrameRate => double.Parse(comboBoxFrameRateFrom.Text); - - public double NewFrameRate => double.Parse(comboBoxFrameRateTo.Text); - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Drawing; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ChangeFrameRate : PositionAndSizeForm + { + public ChangeFrameRate() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + InitializeCombobox(comboBoxFrameRateFrom); + InitializeCombobox(comboBoxFrameRateTo); + + var language = Configuration.Settings.Language.ChangeFrameRate; + Text = language.Title; + labelInfo.Text = language.ConvertFrameRateOfSubtitle; + labelFromFrameRate.Text = language.FromFrameRate; + labelToFrameRate.Text = language.ToFrameRate; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + if (Configuration.IsRunningOnWindows) + { + buttonSwap.Text = "🡙"; + } + else + { + buttonSwap.Text = "<->"; + buttonSwap.Width = 35; + buttonSwap.Font = new Font(Font.FontFamily, Font.Size); + } + } + + private void InitializeCombobox(ComboBox comboBox) + { + comboBox.BeginUpdate(); + comboBox.Items.Clear(); + comboBox.Items.Add(23.976); + comboBox.Items.Add(24.0); + comboBox.Items.Add(25.0); + comboBox.Items.Add(29.97); + comboBox.Items.Add(30); + comboBox.EndUpdate(); + } + + private void FormChangeFrameRate_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + public void Initialize(string fromFrameRate) + { + comboBoxFrameRateFrom.Text = fromFrameRate; + } + + private string GetFrameRateFromVideoFile(string oldFrameRate) + { + openFileDialog1.Title = Configuration.Settings.Language.General.OpenVideoFileTitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = Utilities.GetVideoFileFilter(false); + openFileDialog1.FileName = string.Empty; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + var info = UiUtil.GetVideoInfo(openFileDialog1.FileName); + if (info?.Success == true) + { + return Math.Round(info.FramesPerSecond, 3).ToString(); + } + } + return oldFrameRate; + } + + private void ButtonGetFrameRateFromClick(object sender, EventArgs e) + { + comboBoxFrameRateFrom.Text = GetFrameRateFromVideoFile(comboBoxFrameRateFrom.Text); + } + + private void ButtonGetFrameRateToClick(object sender, EventArgs e) + { + comboBoxFrameRateTo.Text = GetFrameRateFromVideoFile(comboBoxFrameRateTo.Text); + } + + private void ButtonOkClick(object sender, EventArgs e) + { + if (comboBoxFrameRateFrom.Text.Trim() == comboBoxFrameRateTo.Text.Trim()) + { + MessageBox.Show(Configuration.Settings.Language.ChangeFrameRate.FrameRateNotChanged); + return; + } + + if (double.TryParse(comboBoxFrameRateFrom.Text, out _) && double.TryParse(comboBoxFrameRateTo.Text, out _)) + { + DialogResult = DialogResult.OK; + } + else + { + MessageBox.Show(Configuration.Settings.Language.ChangeFrameRate.FrameRateNotCorrect); + } + } + + private void buttonSwap_Click(object sender, EventArgs e) + { + string oldFrameRate = comboBoxFrameRateFrom.Text; + string newFrameRate = comboBoxFrameRateTo.Text; + + comboBoxFrameRateFrom.Text = newFrameRate; + comboBoxFrameRateTo.Text = oldFrameRate; + } + + public double OldFrameRate => double.Parse(comboBoxFrameRateFrom.Text); + + public double NewFrameRate => double.Parse(comboBoxFrameRateTo.Text); + } +} diff --git a/src/Forms/ChangeFrameRate.resx b/src/ui/Forms/ChangeFrameRate.resx similarity index 97% rename from src/Forms/ChangeFrameRate.resx rename to src/ui/Forms/ChangeFrameRate.resx index beddb180c..8b8d2ee1e 100644 --- a/src/Forms/ChangeFrameRate.resx +++ b/src/ui/Forms/ChangeFrameRate.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/ChangeSpeedInPercent.Designer.cs b/src/ui/Forms/ChangeSpeedInPercent.Designer.cs similarity index 98% rename from src/Forms/ChangeSpeedInPercent.Designer.cs rename to src/ui/Forms/ChangeSpeedInPercent.Designer.cs index 4c657228d..a8ad4fbf6 100644 --- a/src/Forms/ChangeSpeedInPercent.Designer.cs +++ b/src/ui/Forms/ChangeSpeedInPercent.Designer.cs @@ -1,215 +1,215 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class ChangeSpeedInPercent - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.numericUpDownPercent = new System.Windows.Forms.NumericUpDown(); - this.labelPercent = new System.Windows.Forms.Label(); - this.radioButtonSelectedLinesOnly = new System.Windows.Forms.RadioButton(); - this.radioButtonAllLines = new System.Windows.Forms.RadioButton(); - this.groupBoxInfo = new System.Windows.Forms.GroupBox(); - this.radioButtonToDropFrame = new System.Windows.Forms.RadioButton(); - this.radioButtonSpeedFromDropFrame = new System.Windows.Forms.RadioButton(); - this.radioButtonSpeedCustom = new System.Windows.Forms.RadioButton(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).BeginInit(); - this.groupBoxInfo.SuspendLayout(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(295, 158); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(214, 158); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // numericUpDownPercent - // - this.numericUpDownPercent.DecimalPlaces = 5; - this.numericUpDownPercent.Location = new System.Drawing.Point(12, 40); - this.numericUpDownPercent.Maximum = new decimal(new int[] { - 200, - 0, - 0, - 0}); - this.numericUpDownPercent.Minimum = new decimal(new int[] { - 50, - 0, - 0, - 0}); - this.numericUpDownPercent.Name = "numericUpDownPercent"; - this.numericUpDownPercent.Size = new System.Drawing.Size(81, 20); - this.numericUpDownPercent.TabIndex = 0; - this.numericUpDownPercent.Value = new decimal(new int[] { - 100, - 0, - 0, - 0}); - // - // labelPercent - // - this.labelPercent.AutoSize = true; - this.labelPercent.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.labelPercent.Location = new System.Drawing.Point(93, 43); - this.labelPercent.Name = "labelPercent"; - this.labelPercent.Size = new System.Drawing.Size(15, 13); - this.labelPercent.TabIndex = 10; - this.labelPercent.Text = "%"; - // - // radioButtonSelectedLinesOnly - // - this.radioButtonSelectedLinesOnly.AutoSize = true; - this.radioButtonSelectedLinesOnly.Location = new System.Drawing.Point(24, 133); - this.radioButtonSelectedLinesOnly.Name = "radioButtonSelectedLinesOnly"; - this.radioButtonSelectedLinesOnly.Size = new System.Drawing.Size(113, 17); - this.radioButtonSelectedLinesOnly.TabIndex = 2; - this.radioButtonSelectedLinesOnly.TabStop = true; - this.radioButtonSelectedLinesOnly.Text = "Selected lines only"; - this.radioButtonSelectedLinesOnly.UseVisualStyleBackColor = true; - // - // radioButtonAllLines - // - this.radioButtonAllLines.AutoSize = true; - this.radioButtonAllLines.Location = new System.Drawing.Point(24, 110); - this.radioButtonAllLines.Name = "radioButtonAllLines"; - this.radioButtonAllLines.Size = new System.Drawing.Size(60, 17); - this.radioButtonAllLines.TabIndex = 1; - this.radioButtonAllLines.TabStop = true; - this.radioButtonAllLines.Text = "All lines"; - this.radioButtonAllLines.UseVisualStyleBackColor = true; - // - // groupBoxInfo - // - this.groupBoxInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxInfo.Controls.Add(this.numericUpDownPercent); - this.groupBoxInfo.Controls.Add(this.labelPercent); - this.groupBoxInfo.Controls.Add(this.radioButtonToDropFrame); - this.groupBoxInfo.Controls.Add(this.radioButtonSpeedFromDropFrame); - this.groupBoxInfo.Controls.Add(this.radioButtonSpeedCustom); - this.groupBoxInfo.Location = new System.Drawing.Point(12, 12); - this.groupBoxInfo.Name = "groupBoxInfo"; - this.groupBoxInfo.Size = new System.Drawing.Size(358, 92); - this.groupBoxInfo.TabIndex = 0; - this.groupBoxInfo.TabStop = false; - // - // radioButtonToDropFrame - // - this.radioButtonToDropFrame.AutoSize = true; - this.radioButtonToDropFrame.Location = new System.Drawing.Point(141, 63); - this.radioButtonToDropFrame.Name = "radioButtonToDropFrame"; - this.radioButtonToDropFrame.Size = new System.Drawing.Size(91, 17); - this.radioButtonToDropFrame.TabIndex = 3; - this.radioButtonToDropFrame.Text = "To drop frame"; - this.radioButtonToDropFrame.UseVisualStyleBackColor = true; - this.radioButtonToDropFrame.CheckedChanged += new System.EventHandler(this.radioButtonToDropFrame_CheckedChanged); - // - // radioButtonSpeedFromDropFrame - // - this.radioButtonSpeedFromDropFrame.AutoSize = true; - this.radioButtonSpeedFromDropFrame.Location = new System.Drawing.Point(141, 40); - this.radioButtonSpeedFromDropFrame.Name = "radioButtonSpeedFromDropFrame"; - this.radioButtonSpeedFromDropFrame.Size = new System.Drawing.Size(101, 17); - this.radioButtonSpeedFromDropFrame.TabIndex = 2; - this.radioButtonSpeedFromDropFrame.Text = "From drop frame"; - this.radioButtonSpeedFromDropFrame.UseVisualStyleBackColor = true; - this.radioButtonSpeedFromDropFrame.CheckedChanged += new System.EventHandler(this.radioButtonSpeedFromDropFrame_CheckedChanged); - // - // radioButtonSpeedCustom - // - this.radioButtonSpeedCustom.AutoSize = true; - this.radioButtonSpeedCustom.Checked = true; - this.radioButtonSpeedCustom.Location = new System.Drawing.Point(141, 17); - this.radioButtonSpeedCustom.Name = "radioButtonSpeedCustom"; - this.radioButtonSpeedCustom.Size = new System.Drawing.Size(60, 17); - this.radioButtonSpeedCustom.TabIndex = 1; - this.radioButtonSpeedCustom.TabStop = true; - this.radioButtonSpeedCustom.Text = "Custom"; - this.radioButtonSpeedCustom.UseVisualStyleBackColor = true; - this.radioButtonSpeedCustom.CheckedChanged += new System.EventHandler(this.radioButtonSpeedCustom_CheckedChanged); - // - // ChangeSpeedInPercent - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(382, 191); - this.Controls.Add(this.groupBoxInfo); - this.Controls.Add(this.radioButtonSelectedLinesOnly); - this.Controls.Add(this.radioButtonAllLines); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ChangeSpeedInPercent"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "ChangeSpeedInPercent"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChangeSpeedInPercent_KeyDown); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).EndInit(); - this.groupBoxInfo.ResumeLayout(false); - this.groupBoxInfo.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.NumericUpDown numericUpDownPercent; - private System.Windows.Forms.Label labelPercent; - private System.Windows.Forms.RadioButton radioButtonSelectedLinesOnly; - private System.Windows.Forms.RadioButton radioButtonAllLines; - private System.Windows.Forms.GroupBox groupBoxInfo; - private System.Windows.Forms.RadioButton radioButtonToDropFrame; - private System.Windows.Forms.RadioButton radioButtonSpeedFromDropFrame; - private System.Windows.Forms.RadioButton radioButtonSpeedCustom; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class ChangeSpeedInPercent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.numericUpDownPercent = new System.Windows.Forms.NumericUpDown(); + this.labelPercent = new System.Windows.Forms.Label(); + this.radioButtonSelectedLinesOnly = new System.Windows.Forms.RadioButton(); + this.radioButtonAllLines = new System.Windows.Forms.RadioButton(); + this.groupBoxInfo = new System.Windows.Forms.GroupBox(); + this.radioButtonToDropFrame = new System.Windows.Forms.RadioButton(); + this.radioButtonSpeedFromDropFrame = new System.Windows.Forms.RadioButton(); + this.radioButtonSpeedCustom = new System.Windows.Forms.RadioButton(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).BeginInit(); + this.groupBoxInfo.SuspendLayout(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(295, 158); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(214, 158); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // numericUpDownPercent + // + this.numericUpDownPercent.DecimalPlaces = 5; + this.numericUpDownPercent.Location = new System.Drawing.Point(12, 40); + this.numericUpDownPercent.Maximum = new decimal(new int[] { + 200, + 0, + 0, + 0}); + this.numericUpDownPercent.Minimum = new decimal(new int[] { + 50, + 0, + 0, + 0}); + this.numericUpDownPercent.Name = "numericUpDownPercent"; + this.numericUpDownPercent.Size = new System.Drawing.Size(81, 20); + this.numericUpDownPercent.TabIndex = 0; + this.numericUpDownPercent.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // labelPercent + // + this.labelPercent.AutoSize = true; + this.labelPercent.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.labelPercent.Location = new System.Drawing.Point(93, 43); + this.labelPercent.Name = "labelPercent"; + this.labelPercent.Size = new System.Drawing.Size(15, 13); + this.labelPercent.TabIndex = 10; + this.labelPercent.Text = "%"; + // + // radioButtonSelectedLinesOnly + // + this.radioButtonSelectedLinesOnly.AutoSize = true; + this.radioButtonSelectedLinesOnly.Location = new System.Drawing.Point(24, 133); + this.radioButtonSelectedLinesOnly.Name = "radioButtonSelectedLinesOnly"; + this.radioButtonSelectedLinesOnly.Size = new System.Drawing.Size(113, 17); + this.radioButtonSelectedLinesOnly.TabIndex = 2; + this.radioButtonSelectedLinesOnly.TabStop = true; + this.radioButtonSelectedLinesOnly.Text = "Selected lines only"; + this.radioButtonSelectedLinesOnly.UseVisualStyleBackColor = true; + // + // radioButtonAllLines + // + this.radioButtonAllLines.AutoSize = true; + this.radioButtonAllLines.Location = new System.Drawing.Point(24, 110); + this.radioButtonAllLines.Name = "radioButtonAllLines"; + this.radioButtonAllLines.Size = new System.Drawing.Size(60, 17); + this.radioButtonAllLines.TabIndex = 1; + this.radioButtonAllLines.TabStop = true; + this.radioButtonAllLines.Text = "All lines"; + this.radioButtonAllLines.UseVisualStyleBackColor = true; + // + // groupBoxInfo + // + this.groupBoxInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxInfo.Controls.Add(this.numericUpDownPercent); + this.groupBoxInfo.Controls.Add(this.labelPercent); + this.groupBoxInfo.Controls.Add(this.radioButtonToDropFrame); + this.groupBoxInfo.Controls.Add(this.radioButtonSpeedFromDropFrame); + this.groupBoxInfo.Controls.Add(this.radioButtonSpeedCustom); + this.groupBoxInfo.Location = new System.Drawing.Point(12, 12); + this.groupBoxInfo.Name = "groupBoxInfo"; + this.groupBoxInfo.Size = new System.Drawing.Size(358, 92); + this.groupBoxInfo.TabIndex = 0; + this.groupBoxInfo.TabStop = false; + // + // radioButtonToDropFrame + // + this.radioButtonToDropFrame.AutoSize = true; + this.radioButtonToDropFrame.Location = new System.Drawing.Point(141, 63); + this.radioButtonToDropFrame.Name = "radioButtonToDropFrame"; + this.radioButtonToDropFrame.Size = new System.Drawing.Size(91, 17); + this.radioButtonToDropFrame.TabIndex = 3; + this.radioButtonToDropFrame.Text = "To drop frame"; + this.radioButtonToDropFrame.UseVisualStyleBackColor = true; + this.radioButtonToDropFrame.CheckedChanged += new System.EventHandler(this.radioButtonToDropFrame_CheckedChanged); + // + // radioButtonSpeedFromDropFrame + // + this.radioButtonSpeedFromDropFrame.AutoSize = true; + this.radioButtonSpeedFromDropFrame.Location = new System.Drawing.Point(141, 40); + this.radioButtonSpeedFromDropFrame.Name = "radioButtonSpeedFromDropFrame"; + this.radioButtonSpeedFromDropFrame.Size = new System.Drawing.Size(101, 17); + this.radioButtonSpeedFromDropFrame.TabIndex = 2; + this.radioButtonSpeedFromDropFrame.Text = "From drop frame"; + this.radioButtonSpeedFromDropFrame.UseVisualStyleBackColor = true; + this.radioButtonSpeedFromDropFrame.CheckedChanged += new System.EventHandler(this.radioButtonSpeedFromDropFrame_CheckedChanged); + // + // radioButtonSpeedCustom + // + this.radioButtonSpeedCustom.AutoSize = true; + this.radioButtonSpeedCustom.Checked = true; + this.radioButtonSpeedCustom.Location = new System.Drawing.Point(141, 17); + this.radioButtonSpeedCustom.Name = "radioButtonSpeedCustom"; + this.radioButtonSpeedCustom.Size = new System.Drawing.Size(60, 17); + this.radioButtonSpeedCustom.TabIndex = 1; + this.radioButtonSpeedCustom.TabStop = true; + this.radioButtonSpeedCustom.Text = "Custom"; + this.radioButtonSpeedCustom.UseVisualStyleBackColor = true; + this.radioButtonSpeedCustom.CheckedChanged += new System.EventHandler(this.radioButtonSpeedCustom_CheckedChanged); + // + // ChangeSpeedInPercent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(382, 191); + this.Controls.Add(this.groupBoxInfo); + this.Controls.Add(this.radioButtonSelectedLinesOnly); + this.Controls.Add(this.radioButtonAllLines); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ChangeSpeedInPercent"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "ChangeSpeedInPercent"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChangeSpeedInPercent_KeyDown); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPercent)).EndInit(); + this.groupBoxInfo.ResumeLayout(false); + this.groupBoxInfo.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.NumericUpDown numericUpDownPercent; + private System.Windows.Forms.Label labelPercent; + private System.Windows.Forms.RadioButton radioButtonSelectedLinesOnly; + private System.Windows.Forms.RadioButton radioButtonAllLines; + private System.Windows.Forms.GroupBox groupBoxInfo; + private System.Windows.Forms.RadioButton radioButtonToDropFrame; + private System.Windows.Forms.RadioButton radioButtonSpeedFromDropFrame; + private System.Windows.Forms.RadioButton radioButtonSpeedCustom; + } } \ No newline at end of file diff --git a/src/Forms/ChangeSpeedInPercent.cs b/src/ui/Forms/ChangeSpeedInPercent.cs similarity index 97% rename from src/Forms/ChangeSpeedInPercent.cs rename to src/ui/Forms/ChangeSpeedInPercent.cs index 8f289e313..c5ee3f71d 100644 --- a/src/Forms/ChangeSpeedInPercent.cs +++ b/src/ui/Forms/ChangeSpeedInPercent.cs @@ -1,120 +1,120 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ChangeSpeedInPercent : PositionAndSizeForm - { - - public double AdjustFactor { get; private set; } - public bool AdjustAllLines { get; private set; } - - public ChangeSpeedInPercent(int numberOfSelectedLines) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Text = Configuration.Settings.Language.ChangeSpeedInPercent.Title; - groupBoxInfo.Text = Configuration.Settings.Language.ChangeSpeedInPercent.Info; - radioButtonAllLines.Text = Configuration.Settings.Language.ShowEarlierLater.AllLines; - radioButtonSelectedLinesOnly.Text = Configuration.Settings.Language.ShowEarlierLater.SelectedLinesOnly; - radioButtonSpeedCustom.Text = Configuration.Settings.Language.ChangeSpeedInPercent.Custom; - radioButtonSpeedFromDropFrame.Text = Configuration.Settings.Language.ChangeSpeedInPercent.FromDropFrame; - radioButtonToDropFrame.Text = Configuration.Settings.Language.ChangeSpeedInPercent.ToDropFrame; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - - if (string.IsNullOrEmpty(Configuration.Settings.Language.ChangeSpeedInPercent.ToDropFrame)) - { - radioButtonSpeedCustom.Visible = false; - radioButtonSpeedFromDropFrame.Visible = false; - radioButtonToDropFrame.Visible = false; - } - - UiUtil.FixLargeFonts(this, buttonOK); - - if (numberOfSelectedLines > 1) - { - radioButtonSelectedLinesOnly.Checked = true; - } - else - { - radioButtonAllLines.Checked = true; - } - } - - private void ChangeSpeedInPercent_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#sync"); - e.SuppressKeyPress = true; - } - } - - public Subtitle AdjustAllParagraphs(Subtitle subtitle) - { - foreach (Paragraph p in subtitle.Paragraphs) - { - AdjustParagraph(p); - } - - for (int i = 0; i < subtitle.Paragraphs.Count; i++) - { - Paragraph p = subtitle.Paragraphs[i]; - Paragraph next = subtitle.GetParagraphOrDefault(i + 1); - if (next != null) - { - if (p.EndTime.TotalMilliseconds >= next.StartTime.TotalMilliseconds) - { - p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1; - } - } - } - return subtitle; - } - - public void AdjustParagraph(Paragraph p) - { - p.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds * AdjustFactor; - p.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds * AdjustFactor; - } - - private void buttonOK_Click(object sender, EventArgs e) - { - AdjustFactor = Convert.ToDouble(numericUpDownPercent.Value) / 100.0; - AdjustAllLines = radioButtonAllLines.Checked; - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void radioButtonSpeedCustom_CheckedChanged(object sender, EventArgs e) - { - numericUpDownPercent.Enabled = true; - } - - private void radioButtonSpeedFromDropFrame_CheckedChanged(object sender, EventArgs e) - { - numericUpDownPercent.Value = Convert.ToDecimal(099.98887); - numericUpDownPercent.Enabled = false; - } - - private void radioButtonToDropFrame_CheckedChanged(object sender, EventArgs e) - { - numericUpDownPercent.Value = Convert.ToDecimal(100.1001001); - numericUpDownPercent.Enabled = false; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ChangeSpeedInPercent : PositionAndSizeForm + { + + public double AdjustFactor { get; private set; } + public bool AdjustAllLines { get; private set; } + + public ChangeSpeedInPercent(int numberOfSelectedLines) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Text = Configuration.Settings.Language.ChangeSpeedInPercent.Title; + groupBoxInfo.Text = Configuration.Settings.Language.ChangeSpeedInPercent.Info; + radioButtonAllLines.Text = Configuration.Settings.Language.ShowEarlierLater.AllLines; + radioButtonSelectedLinesOnly.Text = Configuration.Settings.Language.ShowEarlierLater.SelectedLinesOnly; + radioButtonSpeedCustom.Text = Configuration.Settings.Language.ChangeSpeedInPercent.Custom; + radioButtonSpeedFromDropFrame.Text = Configuration.Settings.Language.ChangeSpeedInPercent.FromDropFrame; + radioButtonToDropFrame.Text = Configuration.Settings.Language.ChangeSpeedInPercent.ToDropFrame; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + + if (string.IsNullOrEmpty(Configuration.Settings.Language.ChangeSpeedInPercent.ToDropFrame)) + { + radioButtonSpeedCustom.Visible = false; + radioButtonSpeedFromDropFrame.Visible = false; + radioButtonToDropFrame.Visible = false; + } + + UiUtil.FixLargeFonts(this, buttonOK); + + if (numberOfSelectedLines > 1) + { + radioButtonSelectedLinesOnly.Checked = true; + } + else + { + radioButtonAllLines.Checked = true; + } + } + + private void ChangeSpeedInPercent_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#sync"); + e.SuppressKeyPress = true; + } + } + + public Subtitle AdjustAllParagraphs(Subtitle subtitle) + { + foreach (Paragraph p in subtitle.Paragraphs) + { + AdjustParagraph(p); + } + + for (int i = 0; i < subtitle.Paragraphs.Count; i++) + { + Paragraph p = subtitle.Paragraphs[i]; + Paragraph next = subtitle.GetParagraphOrDefault(i + 1); + if (next != null) + { + if (p.EndTime.TotalMilliseconds >= next.StartTime.TotalMilliseconds) + { + p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1; + } + } + } + return subtitle; + } + + public void AdjustParagraph(Paragraph p) + { + p.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds * AdjustFactor; + p.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds * AdjustFactor; + } + + private void buttonOK_Click(object sender, EventArgs e) + { + AdjustFactor = Convert.ToDouble(numericUpDownPercent.Value) / 100.0; + AdjustAllLines = radioButtonAllLines.Checked; + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void radioButtonSpeedCustom_CheckedChanged(object sender, EventArgs e) + { + numericUpDownPercent.Enabled = true; + } + + private void radioButtonSpeedFromDropFrame_CheckedChanged(object sender, EventArgs e) + { + numericUpDownPercent.Value = Convert.ToDecimal(099.98887); + numericUpDownPercent.Enabled = false; + } + + private void radioButtonToDropFrame_CheckedChanged(object sender, EventArgs e) + { + numericUpDownPercent.Value = Convert.ToDecimal(100.1001001); + numericUpDownPercent.Enabled = false; + } + + } +} diff --git a/src/Forms/DvdStudioProProperties.resx b/src/ui/Forms/ChangeSpeedInPercent.resx similarity index 100% rename from src/Forms/DvdStudioProProperties.resx rename to src/ui/Forms/ChangeSpeedInPercent.resx diff --git a/src/Forms/CheckForUpdates.Designer.cs b/src/ui/Forms/CheckForUpdates.Designer.cs similarity index 100% rename from src/Forms/CheckForUpdates.Designer.cs rename to src/ui/Forms/CheckForUpdates.Designer.cs diff --git a/src/Forms/CheckForUpdates.cs b/src/ui/Forms/CheckForUpdates.cs similarity index 100% rename from src/Forms/CheckForUpdates.cs rename to src/ui/Forms/CheckForUpdates.cs diff --git a/src/Forms/CheckForUpdates.resx b/src/ui/Forms/CheckForUpdates.resx similarity index 100% rename from src/Forms/CheckForUpdates.resx rename to src/ui/Forms/CheckForUpdates.resx diff --git a/src/Forms/ChooseAudioTrack.Designer.cs b/src/ui/Forms/ChooseAudioTrack.Designer.cs similarity index 97% rename from src/Forms/ChooseAudioTrack.Designer.cs rename to src/ui/Forms/ChooseAudioTrack.Designer.cs index ededbbe93..03e625fdb 100644 --- a/src/Forms/ChooseAudioTrack.Designer.cs +++ b/src/ui/Forms/ChooseAudioTrack.Designer.cs @@ -1,111 +1,111 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ChooseAudioTrack - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.labelDescr = new System.Windows.Forms.Label(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.listBoxTracks = new System.Windows.Forms.ListBox(); - this.SuspendLayout(); - // - // labelDescr - // - this.labelDescr.AutoSize = true; - this.labelDescr.Location = new System.Drawing.Point(10, 14); - this.labelDescr.Name = "labelDescr"; - this.labelDescr.Size = new System.Drawing.Size(99, 13); - this.labelDescr.TabIndex = 19; - this.labelDescr.Text = "Choose audio track"; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(206, 121); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 18; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(125, 121); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 17; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // listBoxTracks - // - this.listBoxTracks.FormattingEnabled = true; - this.listBoxTracks.Location = new System.Drawing.Point(12, 30); - this.listBoxTracks.Name = "listBoxTracks"; - this.listBoxTracks.Size = new System.Drawing.Size(269, 82); - this.listBoxTracks.TabIndex = 20; - // - // ChooseAudioTrack - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(293, 154); - this.Controls.Add(this.listBoxTracks); - this.Controls.Add(this.labelDescr); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ChooseAudioTrack"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Choose audio track"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChooseAudioTrack_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelDescr; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.ListBox listBoxTracks; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ChooseAudioTrack + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.labelDescr = new System.Windows.Forms.Label(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.listBoxTracks = new System.Windows.Forms.ListBox(); + this.SuspendLayout(); + // + // labelDescr + // + this.labelDescr.AutoSize = true; + this.labelDescr.Location = new System.Drawing.Point(10, 14); + this.labelDescr.Name = "labelDescr"; + this.labelDescr.Size = new System.Drawing.Size(99, 13); + this.labelDescr.TabIndex = 19; + this.labelDescr.Text = "Choose audio track"; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(206, 121); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 18; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(125, 121); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 17; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // listBoxTracks + // + this.listBoxTracks.FormattingEnabled = true; + this.listBoxTracks.Location = new System.Drawing.Point(12, 30); + this.listBoxTracks.Name = "listBoxTracks"; + this.listBoxTracks.Size = new System.Drawing.Size(269, 82); + this.listBoxTracks.TabIndex = 20; + // + // ChooseAudioTrack + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(293, 154); + this.Controls.Add(this.listBoxTracks); + this.Controls.Add(this.labelDescr); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ChooseAudioTrack"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Choose audio track"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChooseAudioTrack_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelDescr; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.ListBox listBoxTracks; + } } \ No newline at end of file diff --git a/src/Forms/ChooseAudioTrack.cs b/src/ui/Forms/ChooseAudioTrack.cs similarity index 96% rename from src/Forms/ChooseAudioTrack.cs rename to src/ui/Forms/ChooseAudioTrack.cs index 1d3e85b80..5fa61c4b5 100644 --- a/src/Forms/ChooseAudioTrack.cs +++ b/src/ui/Forms/ChooseAudioTrack.cs @@ -1,54 +1,54 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ChooseAudioTrack : Form - { - public int SelectedTrack { get; set; } - - public ChooseAudioTrack(List tracks, int selectedTrack) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - foreach (string track in tracks) - { - listBoxTracks.Items.Add(track); - } - listBoxTracks.SelectedIndex = selectedTrack; - - if (listBoxTracks.SelectedIndex == -1 && listBoxTracks.Items.Count > 0) - { - listBoxTracks.SelectedIndex = 0; - } - - Text = Configuration.Settings.Language.ChooseAudioTrack.Title; - labelDescr.Text = Configuration.Settings.Language.ChooseAudioTrack.Title; - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void ChooseAudioTrack_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - SelectedTrack = listBoxTracks.SelectedIndex; - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ChooseAudioTrack : Form + { + public int SelectedTrack { get; set; } + + public ChooseAudioTrack(List tracks, int selectedTrack) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + foreach (string track in tracks) + { + listBoxTracks.Items.Add(track); + } + listBoxTracks.SelectedIndex = selectedTrack; + + if (listBoxTracks.SelectedIndex == -1 && listBoxTracks.Items.Count > 0) + { + listBoxTracks.SelectedIndex = 0; + } + + Text = Configuration.Settings.Language.ChooseAudioTrack.Title; + labelDescr.Text = Configuration.Settings.Language.ChooseAudioTrack.Title; + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void ChooseAudioTrack_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + SelectedTrack = listBoxTracks.SelectedIndex; + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + } +} diff --git a/src/Forms/EbuColorPicker.resx b/src/ui/Forms/ChooseAudioTrack.resx similarity index 100% rename from src/Forms/EbuColorPicker.resx rename to src/ui/Forms/ChooseAudioTrack.resx diff --git a/src/Forms/ChooseEncoding.Designer.cs b/src/ui/Forms/ChooseEncoding.Designer.cs similarity index 98% rename from src/Forms/ChooseEncoding.Designer.cs rename to src/ui/Forms/ChooseEncoding.Designer.cs index 85896cbb4..c19aa0e5b 100644 --- a/src/Forms/ChooseEncoding.Designer.cs +++ b/src/ui/Forms/ChooseEncoding.Designer.cs @@ -1,194 +1,194 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ChooseEncoding - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.listView1 = new System.Windows.Forms.ListView(); - this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.textBoxPreview = new System.Windows.Forms.TextBox(); - this.LabelPreview = new System.Windows.Forms.Label(); - this.buttonSearchClear = new System.Windows.Forms.Button(); - this.labelShortcutsSearch = new System.Windows.Forms.Label(); - this.textBoxSearch = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(542, 473); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 7; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(461, 473); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 6; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // listView1 - // - this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.columnHeader2, - this.columnHeader3}); - this.listView1.FullRowSelect = true; - this.listView1.GridLines = true; - this.listView1.HideSelection = false; - this.listView1.Location = new System.Drawing.Point(12, 41); - this.listView1.MultiSelect = false; - this.listView1.Name = "listView1"; - this.listView1.Size = new System.Drawing.Size(605, 225); - this.listView1.TabIndex = 8; - this.listView1.UseCompatibleStateImageBehavior = false; - this.listView1.View = System.Windows.Forms.View.Details; - this.listView1.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listView1_ColumnClick); - this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged); - // - // columnHeader1 - // - this.columnHeader1.Text = "Codepage"; - this.columnHeader1.Width = 75; - // - // columnHeader2 - // - this.columnHeader2.Text = "Name"; - this.columnHeader2.Width = 124; - // - // columnHeader3 - // - this.columnHeader3.Text = "DisplayName"; - this.columnHeader3.Width = 384; - // - // textBoxPreview - // - this.textBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxPreview.Location = new System.Drawing.Point(13, 301); - this.textBoxPreview.Multiline = true; - this.textBoxPreview.Name = "textBoxPreview"; - this.textBoxPreview.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxPreview.Size = new System.Drawing.Size(604, 156); - this.textBoxPreview.TabIndex = 9; - // - // LabelPreview - // - this.LabelPreview.AutoSize = true; - this.LabelPreview.Location = new System.Drawing.Point(12, 284); - this.LabelPreview.Name = "LabelPreview"; - this.LabelPreview.Size = new System.Drawing.Size(45, 13); - this.LabelPreview.TabIndex = 10; - this.LabelPreview.Text = "Preview"; - // - // buttonSearchClear - // - this.buttonSearchClear.Enabled = false; - this.buttonSearchClear.Location = new System.Drawing.Point(217, 12); - this.buttonSearchClear.Name = "buttonSearchClear"; - this.buttonSearchClear.Size = new System.Drawing.Size(111, 23); - this.buttonSearchClear.TabIndex = 3; - this.buttonSearchClear.Text = "Clear"; - this.buttonSearchClear.UseVisualStyleBackColor = true; - this.buttonSearchClear.Click += new System.EventHandler(this.buttonSearchClear_Click); - // - // labelShortcutsSearch - // - this.labelShortcutsSearch.AutoSize = true; - this.labelShortcutsSearch.Location = new System.Drawing.Point(14, 17); - this.labelShortcutsSearch.Name = "labelShortcutsSearch"; - this.labelShortcutsSearch.Size = new System.Drawing.Size(40, 13); - this.labelShortcutsSearch.TabIndex = 40; - this.labelShortcutsSearch.Text = "Search"; - // - // textBoxSearch - // - this.textBoxSearch.Location = new System.Drawing.Point(60, 14); - this.textBoxSearch.Name = "textBoxSearch"; - this.textBoxSearch.Size = new System.Drawing.Size(151, 21); - this.textBoxSearch.TabIndex = 2; - this.textBoxSearch.TextChanged += new System.EventHandler(this.textBoxSearch_TextChanged); - // - // ChooseEncoding - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(629, 503); - this.Controls.Add(this.buttonSearchClear); - this.Controls.Add(this.labelShortcutsSearch); - this.Controls.Add(this.textBoxSearch); - this.Controls.Add(this.LabelPreview); - this.Controls.Add(this.textBoxPreview); - this.Controls.Add(this.listView1); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(645, 542); - this.Name = "ChooseEncoding"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Choose encoding"; - this.Load += new System.EventHandler(this.ChooseEncoding_Load); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormChooseEncoding_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.ListView listView1; - private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.ColumnHeader columnHeader2; - private System.Windows.Forms.ColumnHeader columnHeader3; - private System.Windows.Forms.TextBox textBoxPreview; - private System.Windows.Forms.Label LabelPreview; - private System.Windows.Forms.Button buttonSearchClear; - private System.Windows.Forms.Label labelShortcutsSearch; - private System.Windows.Forms.TextBox textBoxSearch; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ChooseEncoding + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.listView1 = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.textBoxPreview = new System.Windows.Forms.TextBox(); + this.LabelPreview = new System.Windows.Forms.Label(); + this.buttonSearchClear = new System.Windows.Forms.Button(); + this.labelShortcutsSearch = new System.Windows.Forms.Label(); + this.textBoxSearch = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(542, 473); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 7; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(461, 473); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 6; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // listView1 + // + this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2, + this.columnHeader3}); + this.listView1.FullRowSelect = true; + this.listView1.GridLines = true; + this.listView1.HideSelection = false; + this.listView1.Location = new System.Drawing.Point(12, 41); + this.listView1.MultiSelect = false; + this.listView1.Name = "listView1"; + this.listView1.Size = new System.Drawing.Size(605, 225); + this.listView1.TabIndex = 8; + this.listView1.UseCompatibleStateImageBehavior = false; + this.listView1.View = System.Windows.Forms.View.Details; + this.listView1.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listView1_ColumnClick); + this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged); + // + // columnHeader1 + // + this.columnHeader1.Text = "Codepage"; + this.columnHeader1.Width = 75; + // + // columnHeader2 + // + this.columnHeader2.Text = "Name"; + this.columnHeader2.Width = 124; + // + // columnHeader3 + // + this.columnHeader3.Text = "DisplayName"; + this.columnHeader3.Width = 384; + // + // textBoxPreview + // + this.textBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxPreview.Location = new System.Drawing.Point(13, 301); + this.textBoxPreview.Multiline = true; + this.textBoxPreview.Name = "textBoxPreview"; + this.textBoxPreview.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxPreview.Size = new System.Drawing.Size(604, 156); + this.textBoxPreview.TabIndex = 9; + // + // LabelPreview + // + this.LabelPreview.AutoSize = true; + this.LabelPreview.Location = new System.Drawing.Point(12, 284); + this.LabelPreview.Name = "LabelPreview"; + this.LabelPreview.Size = new System.Drawing.Size(45, 13); + this.LabelPreview.TabIndex = 10; + this.LabelPreview.Text = "Preview"; + // + // buttonSearchClear + // + this.buttonSearchClear.Enabled = false; + this.buttonSearchClear.Location = new System.Drawing.Point(217, 12); + this.buttonSearchClear.Name = "buttonSearchClear"; + this.buttonSearchClear.Size = new System.Drawing.Size(111, 23); + this.buttonSearchClear.TabIndex = 3; + this.buttonSearchClear.Text = "Clear"; + this.buttonSearchClear.UseVisualStyleBackColor = true; + this.buttonSearchClear.Click += new System.EventHandler(this.buttonSearchClear_Click); + // + // labelShortcutsSearch + // + this.labelShortcutsSearch.AutoSize = true; + this.labelShortcutsSearch.Location = new System.Drawing.Point(14, 17); + this.labelShortcutsSearch.Name = "labelShortcutsSearch"; + this.labelShortcutsSearch.Size = new System.Drawing.Size(40, 13); + this.labelShortcutsSearch.TabIndex = 40; + this.labelShortcutsSearch.Text = "Search"; + // + // textBoxSearch + // + this.textBoxSearch.Location = new System.Drawing.Point(60, 14); + this.textBoxSearch.Name = "textBoxSearch"; + this.textBoxSearch.Size = new System.Drawing.Size(151, 21); + this.textBoxSearch.TabIndex = 2; + this.textBoxSearch.TextChanged += new System.EventHandler(this.textBoxSearch_TextChanged); + // + // ChooseEncoding + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(629, 503); + this.Controls.Add(this.buttonSearchClear); + this.Controls.Add(this.labelShortcutsSearch); + this.Controls.Add(this.textBoxSearch); + this.Controls.Add(this.LabelPreview); + this.Controls.Add(this.textBoxPreview); + this.Controls.Add(this.listView1); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(645, 542); + this.Name = "ChooseEncoding"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Choose encoding"; + this.Load += new System.EventHandler(this.ChooseEncoding_Load); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormChooseEncoding_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.ListView listView1; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.ColumnHeader columnHeader3; + private System.Windows.Forms.TextBox textBoxPreview; + private System.Windows.Forms.Label LabelPreview; + private System.Windows.Forms.Button buttonSearchClear; + private System.Windows.Forms.Label labelShortcutsSearch; + private System.Windows.Forms.TextBox textBoxSearch; + } } \ No newline at end of file diff --git a/src/Forms/ChooseEncoding.cs b/src/ui/Forms/ChooseEncoding.cs similarity index 97% rename from src/Forms/ChooseEncoding.cs rename to src/ui/Forms/ChooseEncoding.cs index 3b707a498..e17569f33 100644 --- a/src/Forms/ChooseEncoding.cs +++ b/src/ui/Forms/ChooseEncoding.cs @@ -1,168 +1,168 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.IO; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ChooseEncoding : Form - { - private Encoding _encoding; - private byte[] _fileBuffer; - - public ChooseEncoding() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - LanguageStructure.ChooseEncoding language = Configuration.Settings.Language.ChooseEncoding; - Text = language.Title; - labelShortcutsSearch.Text = Configuration.Settings.Language.General.Search; - buttonSearchClear.Text = Configuration.Settings.Language.DvdSubRip.Clear; - textBoxSearch.Left = labelShortcutsSearch.Left + labelShortcutsSearch.Width + 5; - buttonSearchClear.Left = textBoxSearch.Left + textBoxSearch.Width + 5; - LabelPreview.Text = Configuration.Settings.Language.General.Preview; - listView1.Columns[0].Text = language.CodePage; - listView1.Columns[1].Text = Configuration.Settings.Language.General.Name; - listView1.Columns[2].Text = language.DisplayName; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - } - - public void Initialize(string fileName) - { - try - { - using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - int readCount = (int)Math.Min(100000, fs.Length); - _fileBuffer = new byte[readCount]; - fs.Read(_fileBuffer, 0, readCount); - } - } - catch - { - _fileBuffer = new byte[0]; - } - - Encoding encoding; - if (_fileBuffer.Length > 10 && _fileBuffer[0] == 0xef && _fileBuffer[1] == 0xbb && _fileBuffer[2] == 0xbf) - { - encoding = Encoding.UTF8; - } - else - { - encoding = LanguageAutoDetect.DetectAnsiEncoding(_fileBuffer); - } - - listView1.BeginUpdate(); - foreach (var enc in Configuration.AvailableEncodings) - { - var item = new ListViewItem(new[] { enc.CodePage.ToString(), enc.WebName, enc.EncodingName }); - listView1.Items.Add(item); - if (enc.CodePage == encoding.CodePage) - { - item.Selected = true; - } - } - listView1.ListViewItemSorter = new ListViewSorter { ColumnNumber = 0, IsNumber = true }; - listView1.EndUpdate(); - } - - private void FormChooseEncoding_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - internal Encoding GetEncoding() - { - return _encoding; - } - - private void ButtonOkClick(object sender, EventArgs e) - { - if (listView1.SelectedItems.Count == 0) - { - MessageBox.Show(Configuration.Settings.Language.ChooseEncoding.PleaseSelectAnEncoding); - } - else - { - _encoding = Encoding.GetEncoding(int.Parse(listView1.SelectedItems[0].Text)); - DialogResult = DialogResult.OK; - } - } - - private void listView1_SelectedIndexChanged(object sender, EventArgs e) - { - if (listView1.SelectedItems.Count > 0) - { - Encoding encoding = Encoding.GetEncoding(int.Parse(listView1.SelectedItems[0].Text)); - textBoxPreview.Text = encoding.GetString(_fileBuffer).Replace("\0", " "); - LabelPreview.Text = Configuration.Settings.Language.General.Preview + " - " + encoding.EncodingName; - } - else - { - textBoxPreview.Text = string.Empty; - LabelPreview.Text = string.Empty; - } - } - - private void ChooseEncoding_Load(object sender, EventArgs e) - { - if (listView1.SelectedItems.Count >= 1) - { - listView1.EnsureVisible(listView1.SelectedItems[0].Index); - } - } - - private void listView1_ColumnClick(object sender, ColumnClickEventArgs e) - { - ListViewSorter sorter = (ListViewSorter)listView1.ListViewItemSorter; - - if (e.Column == sorter.ColumnNumber) - { - sorter.Descending = !sorter.Descending; // inverse sort direction - } - else - { - sorter.ColumnNumber = e.Column; - sorter.Descending = false; - sorter.IsNumber = e.Column == 0; // only index 1 is numeric - } - listView1.Sort(); - } - - private void textBoxSearch_TextChanged(object sender, EventArgs e) - { - listView1.BeginUpdate(); - listView1.Items.Clear(); - foreach (var enc in Configuration.AvailableEncodings) - { - if (textBoxSearch.Text.Length < 2 || - enc.CodePage.ToString().Contains(textBoxSearch.Text, StringComparison.OrdinalIgnoreCase) || - enc.WebName.Contains(textBoxSearch.Text, StringComparison.OrdinalIgnoreCase) || - enc.EncodingName.Contains(textBoxSearch.Text, StringComparison.OrdinalIgnoreCase)) - { - var item = new ListViewItem(new[] { enc.CodePage.ToString(), enc.WebName, enc.EncodingName }); - listView1.Items.Add(item); - } - } - listView1.EndUpdate(); - buttonSearchClear.Enabled = textBoxSearch.Text.Length > 0; - listView1_SelectedIndexChanged(null, null); - } - - private void buttonSearchClear_Click(object sender, EventArgs e) - { - textBoxSearch.Text = string.Empty; - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.IO; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ChooseEncoding : Form + { + private Encoding _encoding; + private byte[] _fileBuffer; + + public ChooseEncoding() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + LanguageStructure.ChooseEncoding language = Configuration.Settings.Language.ChooseEncoding; + Text = language.Title; + labelShortcutsSearch.Text = Configuration.Settings.Language.General.Search; + buttonSearchClear.Text = Configuration.Settings.Language.DvdSubRip.Clear; + textBoxSearch.Left = labelShortcutsSearch.Left + labelShortcutsSearch.Width + 5; + buttonSearchClear.Left = textBoxSearch.Left + textBoxSearch.Width + 5; + LabelPreview.Text = Configuration.Settings.Language.General.Preview; + listView1.Columns[0].Text = language.CodePage; + listView1.Columns[1].Text = Configuration.Settings.Language.General.Name; + listView1.Columns[2].Text = language.DisplayName; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + } + + public void Initialize(string fileName) + { + try + { + using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + int readCount = (int)Math.Min(100000, fs.Length); + _fileBuffer = new byte[readCount]; + fs.Read(_fileBuffer, 0, readCount); + } + } + catch + { + _fileBuffer = new byte[0]; + } + + Encoding encoding; + if (_fileBuffer.Length > 10 && _fileBuffer[0] == 0xef && _fileBuffer[1] == 0xbb && _fileBuffer[2] == 0xbf) + { + encoding = Encoding.UTF8; + } + else + { + encoding = LanguageAutoDetect.DetectAnsiEncoding(_fileBuffer); + } + + listView1.BeginUpdate(); + foreach (var enc in Configuration.AvailableEncodings) + { + var item = new ListViewItem(new[] { enc.CodePage.ToString(), enc.WebName, enc.EncodingName }); + listView1.Items.Add(item); + if (enc.CodePage == encoding.CodePage) + { + item.Selected = true; + } + } + listView1.ListViewItemSorter = new ListViewSorter { ColumnNumber = 0, IsNumber = true }; + listView1.EndUpdate(); + } + + private void FormChooseEncoding_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + internal Encoding GetEncoding() + { + return _encoding; + } + + private void ButtonOkClick(object sender, EventArgs e) + { + if (listView1.SelectedItems.Count == 0) + { + MessageBox.Show(Configuration.Settings.Language.ChooseEncoding.PleaseSelectAnEncoding); + } + else + { + _encoding = Encoding.GetEncoding(int.Parse(listView1.SelectedItems[0].Text)); + DialogResult = DialogResult.OK; + } + } + + private void listView1_SelectedIndexChanged(object sender, EventArgs e) + { + if (listView1.SelectedItems.Count > 0) + { + Encoding encoding = Encoding.GetEncoding(int.Parse(listView1.SelectedItems[0].Text)); + textBoxPreview.Text = encoding.GetString(_fileBuffer).Replace("\0", " "); + LabelPreview.Text = Configuration.Settings.Language.General.Preview + " - " + encoding.EncodingName; + } + else + { + textBoxPreview.Text = string.Empty; + LabelPreview.Text = string.Empty; + } + } + + private void ChooseEncoding_Load(object sender, EventArgs e) + { + if (listView1.SelectedItems.Count >= 1) + { + listView1.EnsureVisible(listView1.SelectedItems[0].Index); + } + } + + private void listView1_ColumnClick(object sender, ColumnClickEventArgs e) + { + ListViewSorter sorter = (ListViewSorter)listView1.ListViewItemSorter; + + if (e.Column == sorter.ColumnNumber) + { + sorter.Descending = !sorter.Descending; // inverse sort direction + } + else + { + sorter.ColumnNumber = e.Column; + sorter.Descending = false; + sorter.IsNumber = e.Column == 0; // only index 1 is numeric + } + listView1.Sort(); + } + + private void textBoxSearch_TextChanged(object sender, EventArgs e) + { + listView1.BeginUpdate(); + listView1.Items.Clear(); + foreach (var enc in Configuration.AvailableEncodings) + { + if (textBoxSearch.Text.Length < 2 || + enc.CodePage.ToString().Contains(textBoxSearch.Text, StringComparison.OrdinalIgnoreCase) || + enc.WebName.Contains(textBoxSearch.Text, StringComparison.OrdinalIgnoreCase) || + enc.EncodingName.Contains(textBoxSearch.Text, StringComparison.OrdinalIgnoreCase)) + { + var item = new ListViewItem(new[] { enc.CodePage.ToString(), enc.WebName, enc.EncodingName }); + listView1.Items.Add(item); + } + } + listView1.EndUpdate(); + buttonSearchClear.Enabled = textBoxSearch.Text.Length > 0; + listView1_SelectedIndexChanged(null, null); + } + + private void buttonSearchClear_Click(object sender, EventArgs e) + { + textBoxSearch.Text = string.Empty; + } + } +} diff --git a/src/Forms/ChooseEncoding.resx b/src/ui/Forms/ChooseEncoding.resx similarity index 97% rename from src/Forms/ChooseEncoding.resx rename to src/ui/Forms/ChooseEncoding.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/ChooseEncoding.resx +++ b/src/ui/Forms/ChooseEncoding.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/ChooseFontName.Designer.cs b/src/ui/Forms/ChooseFontName.Designer.cs similarity index 100% rename from src/Forms/ChooseFontName.Designer.cs rename to src/ui/Forms/ChooseFontName.Designer.cs diff --git a/src/Forms/ChooseFontName.cs b/src/ui/Forms/ChooseFontName.cs similarity index 100% rename from src/Forms/ChooseFontName.cs rename to src/ui/Forms/ChooseFontName.cs diff --git a/src/Forms/EbuLanguageCode.resx b/src/ui/Forms/ChooseFontName.resx similarity index 100% rename from src/Forms/EbuLanguageCode.resx rename to src/ui/Forms/ChooseFontName.resx diff --git a/src/Forms/ChooseLanguage.Designer.cs b/src/ui/Forms/ChooseLanguage.Designer.cs similarity index 97% rename from src/Forms/ChooseLanguage.Designer.cs rename to src/ui/Forms/ChooseLanguage.Designer.cs index bfeb9e648..fb7577003 100644 --- a/src/Forms/ChooseLanguage.Designer.cs +++ b/src/ui/Forms/ChooseLanguage.Designer.cs @@ -1,109 +1,109 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ChooseLanguage - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.labelLanguage = new System.Windows.Forms.Label(); - this.comboBoxLanguages = new System.Windows.Forms.ComboBox(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(203, 72); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 2; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOK - // - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(122, 72); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 1; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - // - // labelLanguage - // - this.labelLanguage.AutoSize = true; - this.labelLanguage.Location = new System.Drawing.Point(12, 14); - this.labelLanguage.Name = "labelLanguage"; - this.labelLanguage.Size = new System.Drawing.Size(54, 13); - this.labelLanguage.TabIndex = 15; - this.labelLanguage.Text = "Language"; - // - // comboBoxLanguages - // - this.comboBoxLanguages.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxLanguages.FormattingEnabled = true; - this.comboBoxLanguages.Location = new System.Drawing.Point(12, 31); - this.comboBoxLanguages.Name = "comboBoxLanguages"; - this.comboBoxLanguages.Size = new System.Drawing.Size(266, 21); - this.comboBoxLanguages.TabIndex = 0; - // - // ChooseLanguage - // - this.AcceptButton = this.buttonOK; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(290, 105); - this.Controls.Add(this.labelLanguage); - this.Controls.Add(this.comboBoxLanguages); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ChooseLanguage"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Choose language"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChangeLanguage_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Label labelLanguage; - private System.Windows.Forms.ComboBox comboBoxLanguages; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ChooseLanguage + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.labelLanguage = new System.Windows.Forms.Label(); + this.comboBoxLanguages = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(203, 72); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 2; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOK + // + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(122, 72); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 1; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + // + // labelLanguage + // + this.labelLanguage.AutoSize = true; + this.labelLanguage.Location = new System.Drawing.Point(12, 14); + this.labelLanguage.Name = "labelLanguage"; + this.labelLanguage.Size = new System.Drawing.Size(54, 13); + this.labelLanguage.TabIndex = 15; + this.labelLanguage.Text = "Language"; + // + // comboBoxLanguages + // + this.comboBoxLanguages.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxLanguages.FormattingEnabled = true; + this.comboBoxLanguages.Location = new System.Drawing.Point(12, 31); + this.comboBoxLanguages.Name = "comboBoxLanguages"; + this.comboBoxLanguages.Size = new System.Drawing.Size(266, 21); + this.comboBoxLanguages.TabIndex = 0; + // + // ChooseLanguage + // + this.AcceptButton = this.buttonOK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(290, 105); + this.Controls.Add(this.labelLanguage); + this.Controls.Add(this.comboBoxLanguages); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ChooseLanguage"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Choose language"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChangeLanguage_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Label labelLanguage; + private System.Windows.Forms.ComboBox comboBoxLanguages; + } } \ No newline at end of file diff --git a/src/Forms/ChooseLanguage.cs b/src/ui/Forms/ChooseLanguage.cs similarity index 97% rename from src/Forms/ChooseLanguage.cs rename to src/ui/Forms/ChooseLanguage.cs index ab6788525..5c075127e 100644 --- a/src/Forms/ChooseLanguage.cs +++ b/src/ui/Forms/ChooseLanguage.cs @@ -1,144 +1,144 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Windows.Forms; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ChooseLanguage : PositionAndSizeForm - { - private class TranslationInfo : IEquatable - { - public string CultureName { get; } - - public string DisplayName { get; } - - public TranslationInfo(string cultureName, string displayName) - { - CultureName = cultureName; - try - { - DisplayName = displayName.CapitalizeFirstLetter(CultureInfo.GetCultureInfo(cultureName)); - } - catch - { - DisplayName = displayName.CapitalizeFirstLetter(CultureInfo.InvariantCulture); - } - } - - public bool Equals(TranslationInfo ti) - { - return !ReferenceEquals(ti, null) && CultureName.Equals(ti.CultureName, StringComparison.OrdinalIgnoreCase); - } - - public override bool Equals(object obj) - { - return Equals(obj as TranslationInfo); - } - - public override int GetHashCode() - { - return CultureName.ToUpperInvariant().GetHashCode(); - } - - public override string ToString() - { - return DisplayName; - } - } - - private readonly TranslationInfo _defaultTranslation; - - public string CultureName => !(comboBoxLanguages.SelectedItem is TranslationInfo translation) ? _defaultTranslation.CultureName : translation.CultureName; - - public ChooseLanguage() - { - TranslationInfo currentTranslation; - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - var defaultLanguage = new Language(); - _defaultTranslation = new TranslationInfo(defaultLanguage.General.CultureName, defaultLanguage.Name); - var currentLanguage = Configuration.Settings.Language; - if (currentLanguage == null) - { - currentTranslation = new TranslationInfo(CultureInfo.CurrentUICulture.Name, CultureInfo.CurrentUICulture.NativeName); - Configuration.Settings.Language = defaultLanguage; - } - else - { - currentTranslation = new TranslationInfo(currentLanguage.General.CultureName, currentLanguage.Name); - } - - var translations = new HashSet { _defaultTranslation }; - if (Directory.Exists(Path.Combine(Configuration.BaseDirectory, "Languages"))) - { - var versionInfo = Utilities.AssemblyVersion.Split('.'); - var currentVersion = $"{versionInfo[0]}.{versionInfo[1]}.{versionInfo[2]}"; - var document = new XmlDocument { XmlResolver = null }; - - foreach (var fileName in Directory.GetFiles(Path.Combine(Configuration.BaseDirectory, "Languages"), "*.xml")) - { - document.Load(fileName); - try - { - var version = document.DocumentElement.SelectSingleNode("General/Version").InnerText.Trim(); - if (version == currentVersion) - { - var cultureName = document.DocumentElement.SelectSingleNode("General/CultureName").InnerText.Trim(); - var displayName = document.DocumentElement.Attributes["Name"].Value.Trim(); - if (!string.IsNullOrEmpty(cultureName) && !string.IsNullOrEmpty(displayName)) - { - translations.Add(new TranslationInfo(cultureName, displayName)); - } - } - } - catch - { - // ignored - } - } - } - - int index = -1; - foreach (var translation in translations.OrderBy(ti => ti.DisplayName, StringComparer.CurrentCultureIgnoreCase).ThenBy(ti => ti.CultureName, StringComparer.Ordinal)) - { - int i = comboBoxLanguages.Items.Add(translation); - if (translation.Equals(currentTranslation) || (index < 0 && translation.Equals(_defaultTranslation))) - { - index = i; - } - } - comboBoxLanguages.SelectedIndex = index; - comboBoxLanguages.AutoCompleteSource = AutoCompleteSource.ListItems; - comboBoxLanguages.AutoCompleteMode = AutoCompleteMode.Append; - - Text = Configuration.Settings.Language.ChooseLanguage.Title; - labelLanguage.Text = Configuration.Settings.Language.ChooseLanguage.Language; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void ChangeLanguage_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#translate"); - e.SuppressKeyPress = true; - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ChooseLanguage : PositionAndSizeForm + { + private class TranslationInfo : IEquatable + { + public string CultureName { get; } + + public string DisplayName { get; } + + public TranslationInfo(string cultureName, string displayName) + { + CultureName = cultureName; + try + { + DisplayName = displayName.CapitalizeFirstLetter(CultureInfo.GetCultureInfo(cultureName)); + } + catch + { + DisplayName = displayName.CapitalizeFirstLetter(CultureInfo.InvariantCulture); + } + } + + public bool Equals(TranslationInfo ti) + { + return !ReferenceEquals(ti, null) && CultureName.Equals(ti.CultureName, StringComparison.OrdinalIgnoreCase); + } + + public override bool Equals(object obj) + { + return Equals(obj as TranslationInfo); + } + + public override int GetHashCode() + { + return CultureName.ToUpperInvariant().GetHashCode(); + } + + public override string ToString() + { + return DisplayName; + } + } + + private readonly TranslationInfo _defaultTranslation; + + public string CultureName => !(comboBoxLanguages.SelectedItem is TranslationInfo translation) ? _defaultTranslation.CultureName : translation.CultureName; + + public ChooseLanguage() + { + TranslationInfo currentTranslation; + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + var defaultLanguage = new Language(); + _defaultTranslation = new TranslationInfo(defaultLanguage.General.CultureName, defaultLanguage.Name); + var currentLanguage = Configuration.Settings.Language; + if (currentLanguage == null) + { + currentTranslation = new TranslationInfo(CultureInfo.CurrentUICulture.Name, CultureInfo.CurrentUICulture.NativeName); + Configuration.Settings.Language = defaultLanguage; + } + else + { + currentTranslation = new TranslationInfo(currentLanguage.General.CultureName, currentLanguage.Name); + } + + var translations = new HashSet { _defaultTranslation }; + if (Directory.Exists(Path.Combine(Configuration.BaseDirectory, "Languages"))) + { + var versionInfo = Utilities.AssemblyVersion.Split('.'); + var currentVersion = $"{versionInfo[0]}.{versionInfo[1]}.{versionInfo[2]}"; + var document = new XmlDocument { XmlResolver = null }; + + foreach (var fileName in Directory.GetFiles(Path.Combine(Configuration.BaseDirectory, "Languages"), "*.xml")) + { + document.Load(fileName); + try + { + var version = document.DocumentElement.SelectSingleNode("General/Version").InnerText.Trim(); + if (version == currentVersion) + { + var cultureName = document.DocumentElement.SelectSingleNode("General/CultureName").InnerText.Trim(); + var displayName = document.DocumentElement.Attributes["Name"].Value.Trim(); + if (!string.IsNullOrEmpty(cultureName) && !string.IsNullOrEmpty(displayName)) + { + translations.Add(new TranslationInfo(cultureName, displayName)); + } + } + } + catch + { + // ignored + } + } + } + + int index = -1; + foreach (var translation in translations.OrderBy(ti => ti.DisplayName, StringComparer.CurrentCultureIgnoreCase).ThenBy(ti => ti.CultureName, StringComparer.Ordinal)) + { + int i = comboBoxLanguages.Items.Add(translation); + if (translation.Equals(currentTranslation) || (index < 0 && translation.Equals(_defaultTranslation))) + { + index = i; + } + } + comboBoxLanguages.SelectedIndex = index; + comboBoxLanguages.AutoCompleteSource = AutoCompleteSource.ListItems; + comboBoxLanguages.AutoCompleteMode = AutoCompleteMode.Append; + + Text = Configuration.Settings.Language.ChooseLanguage.Title; + labelLanguage.Text = Configuration.Settings.Language.ChooseLanguage.Language; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void ChangeLanguage_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#translate"); + e.SuppressKeyPress = true; + } + } + + } +} diff --git a/src/Forms/ChooseLanguage.resx b/src/ui/Forms/ChooseLanguage.resx similarity index 97% rename from src/Forms/ChooseLanguage.resx rename to src/ui/Forms/ChooseLanguage.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/ChooseLanguage.resx +++ b/src/ui/Forms/ChooseLanguage.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/ChooseResolution.Designer.cs b/src/ui/Forms/ChooseResolution.Designer.cs similarity index 97% rename from src/Forms/ChooseResolution.Designer.cs rename to src/ui/Forms/ChooseResolution.Designer.cs index 207e0fcb3..215a98d18 100644 --- a/src/Forms/ChooseResolution.Designer.cs +++ b/src/ui/Forms/ChooseResolution.Designer.cs @@ -1,173 +1,173 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ChooseResolution - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.labelVideoResolution = new System.Windows.Forms.Label(); - this.numericUpDownVideoHeight = new System.Windows.Forms.NumericUpDown(); - this.button1 = new System.Windows.Forms.Button(); - this.labelX = new System.Windows.Forms.Label(); - this.numericUpDownVideoWidth = new System.Windows.Forms.NumericUpDown(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoHeight)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoWidth)).BeginInit(); - this.SuspendLayout(); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // labelVideoResolution - // - this.labelVideoResolution.AutoSize = true; - this.labelVideoResolution.Location = new System.Drawing.Point(12, 32); - this.labelVideoResolution.Name = "labelVideoResolution"; - this.labelVideoResolution.Size = new System.Drawing.Size(82, 13); - this.labelVideoResolution.TabIndex = 0; - this.labelVideoResolution.Text = "Video resolution"; - // - // numericUpDownVideoHeight - // - this.numericUpDownVideoHeight.Location = new System.Drawing.Point(205, 29); - this.numericUpDownVideoHeight.Maximum = new decimal(new int[] { - 100000, - 0, - 0, - 0}); - this.numericUpDownVideoHeight.Name = "numericUpDownVideoHeight"; - this.numericUpDownVideoHeight.Size = new System.Drawing.Size(47, 20); - this.numericUpDownVideoHeight.TabIndex = 3; - this.numericUpDownVideoHeight.Value = new decimal(new int[] { - 1080, - 0, - 0, - 0}); - // - // button1 - // - this.button1.Location = new System.Drawing.Point(258, 27); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(27, 23); - this.button1.TabIndex = 4; - this.button1.Text = "..."; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // labelX - // - this.labelX.AutoSize = true; - this.labelX.Location = new System.Drawing.Point(185, 31); - this.labelX.Name = "labelX"; - this.labelX.Size = new System.Drawing.Size(14, 13); - this.labelX.TabIndex = 2; - this.labelX.Text = "X"; - // - // numericUpDownVideoWidth - // - this.numericUpDownVideoWidth.Location = new System.Drawing.Point(132, 29); - this.numericUpDownVideoWidth.Maximum = new decimal(new int[] { - 100000, - 0, - 0, - 0}); - this.numericUpDownVideoWidth.Name = "numericUpDownVideoWidth"; - this.numericUpDownVideoWidth.Size = new System.Drawing.Size(47, 20); - this.numericUpDownVideoWidth.TabIndex = 1; - this.numericUpDownVideoWidth.Value = new decimal(new int[] { - 1920, - 0, - 0, - 0}); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(213, 81); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 6; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(132, 81); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 5; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // ChooseResolution - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(300, 114); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.labelVideoResolution); - this.Controls.Add(this.numericUpDownVideoHeight); - this.Controls.Add(this.button1); - this.Controls.Add(this.labelX); - this.Controls.Add(this.numericUpDownVideoWidth); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ChooseResolution"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Choose video resolution"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChooseResolution_KeyDown); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoHeight)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoWidth)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Label labelVideoResolution; - private System.Windows.Forms.NumericUpDown numericUpDownVideoHeight; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Label labelX; - private System.Windows.Forms.NumericUpDown numericUpDownVideoWidth; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ChooseResolution + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.labelVideoResolution = new System.Windows.Forms.Label(); + this.numericUpDownVideoHeight = new System.Windows.Forms.NumericUpDown(); + this.button1 = new System.Windows.Forms.Button(); + this.labelX = new System.Windows.Forms.Label(); + this.numericUpDownVideoWidth = new System.Windows.Forms.NumericUpDown(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoHeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoWidth)).BeginInit(); + this.SuspendLayout(); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // labelVideoResolution + // + this.labelVideoResolution.AutoSize = true; + this.labelVideoResolution.Location = new System.Drawing.Point(12, 32); + this.labelVideoResolution.Name = "labelVideoResolution"; + this.labelVideoResolution.Size = new System.Drawing.Size(82, 13); + this.labelVideoResolution.TabIndex = 0; + this.labelVideoResolution.Text = "Video resolution"; + // + // numericUpDownVideoHeight + // + this.numericUpDownVideoHeight.Location = new System.Drawing.Point(205, 29); + this.numericUpDownVideoHeight.Maximum = new decimal(new int[] { + 100000, + 0, + 0, + 0}); + this.numericUpDownVideoHeight.Name = "numericUpDownVideoHeight"; + this.numericUpDownVideoHeight.Size = new System.Drawing.Size(47, 20); + this.numericUpDownVideoHeight.TabIndex = 3; + this.numericUpDownVideoHeight.Value = new decimal(new int[] { + 1080, + 0, + 0, + 0}); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(258, 27); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(27, 23); + this.button1.TabIndex = 4; + this.button1.Text = "..."; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // labelX + // + this.labelX.AutoSize = true; + this.labelX.Location = new System.Drawing.Point(185, 31); + this.labelX.Name = "labelX"; + this.labelX.Size = new System.Drawing.Size(14, 13); + this.labelX.TabIndex = 2; + this.labelX.Text = "X"; + // + // numericUpDownVideoWidth + // + this.numericUpDownVideoWidth.Location = new System.Drawing.Point(132, 29); + this.numericUpDownVideoWidth.Maximum = new decimal(new int[] { + 100000, + 0, + 0, + 0}); + this.numericUpDownVideoWidth.Name = "numericUpDownVideoWidth"; + this.numericUpDownVideoWidth.Size = new System.Drawing.Size(47, 20); + this.numericUpDownVideoWidth.TabIndex = 1; + this.numericUpDownVideoWidth.Value = new decimal(new int[] { + 1920, + 0, + 0, + 0}); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(213, 81); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(132, 81); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 5; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // ChooseResolution + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(300, 114); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.labelVideoResolution); + this.Controls.Add(this.numericUpDownVideoHeight); + this.Controls.Add(this.button1); + this.Controls.Add(this.labelX); + this.Controls.Add(this.numericUpDownVideoWidth); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ChooseResolution"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Choose video resolution"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChooseResolution_KeyDown); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoHeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoWidth)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Label labelVideoResolution; + private System.Windows.Forms.NumericUpDown numericUpDownVideoHeight; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label labelX; + private System.Windows.Forms.NumericUpDown numericUpDownVideoWidth; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + } } \ No newline at end of file diff --git a/src/Forms/ChooseResolution.cs b/src/ui/Forms/ChooseResolution.cs similarity index 97% rename from src/Forms/ChooseResolution.cs rename to src/ui/Forms/ChooseResolution.cs index 8cf190928..afcc3995a 100644 --- a/src/Forms/ChooseResolution.cs +++ b/src/ui/Forms/ChooseResolution.cs @@ -1,63 +1,63 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ChooseResolution : Form - { - public int VideoWidth { get; set; } - public int VideoHeight { get; set; } - - public ChooseResolution() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - Text = Configuration.Settings.Language.ExportPngXml.VideoResolution; - labelVideoResolution.Text = Configuration.Settings.Language.ExportPngXml.VideoResolution; - } - - private void button1_Click(object sender, EventArgs e) - { - openFileDialog1.Title = Configuration.Settings.Language.General.OpenVideoFileTitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = Utilities.GetVideoFileFilter(false); - openFileDialog1.FileName = string.Empty; - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - VideoInfo info = UiUtil.GetVideoInfo(openFileDialog1.FileName); - if (info != null && info.Success) - { - numericUpDownVideoWidth.Value = info.Width; - numericUpDownVideoHeight.Value = info.Height; - } - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - VideoWidth = (int)numericUpDownVideoWidth.Value; - VideoHeight = (int)numericUpDownVideoHeight.Value; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void ChooseResolution_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ChooseResolution : Form + { + public int VideoWidth { get; set; } + public int VideoHeight { get; set; } + + public ChooseResolution() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + Text = Configuration.Settings.Language.ExportPngXml.VideoResolution; + labelVideoResolution.Text = Configuration.Settings.Language.ExportPngXml.VideoResolution; + } + + private void button1_Click(object sender, EventArgs e) + { + openFileDialog1.Title = Configuration.Settings.Language.General.OpenVideoFileTitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = Utilities.GetVideoFileFilter(false); + openFileDialog1.FileName = string.Empty; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + VideoInfo info = UiUtil.GetVideoInfo(openFileDialog1.FileName); + if (info != null && info.Success) + { + numericUpDownVideoWidth.Value = info.Width; + numericUpDownVideoHeight.Value = info.Height; + } + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + VideoWidth = (int)numericUpDownVideoWidth.Value; + VideoHeight = (int)numericUpDownVideoHeight.Value; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void ChooseResolution_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + } +} diff --git a/src/Forms/ChooseResolution.resx b/src/ui/Forms/ChooseResolution.resx similarity index 97% rename from src/Forms/ChooseResolution.resx rename to src/ui/Forms/ChooseResolution.resx index 3a7d67153..9bad2f599 100644 --- a/src/Forms/ChooseResolution.resx +++ b/src/ui/Forms/ChooseResolution.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/ChooseStyle.Designer.cs b/src/ui/Forms/ChooseStyle.Designer.cs similarity index 97% rename from src/Forms/ChooseStyle.Designer.cs rename to src/ui/Forms/ChooseStyle.Designer.cs index 2d0c6d80e..594f8b1e8 100644 --- a/src/Forms/ChooseStyle.Designer.cs +++ b/src/ui/Forms/ChooseStyle.Designer.cs @@ -1,167 +1,167 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ChooseStyle - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBoxStyles = new System.Windows.Forms.GroupBox(); - this.listViewStyles = new System.Windows.Forms.ListView(); - this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderFontName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderFontSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderUseCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderPrimaryColor = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderOutline = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxStyles.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxStyles - // - this.groupBoxStyles.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxStyles.Controls.Add(this.listViewStyles); - this.groupBoxStyles.Location = new System.Drawing.Point(12, 12); - this.groupBoxStyles.Name = "groupBoxStyles"; - this.groupBoxStyles.Size = new System.Drawing.Size(700, 424); - this.groupBoxStyles.TabIndex = 1; - this.groupBoxStyles.TabStop = false; - this.groupBoxStyles.Text = "Styles"; - // - // listViewStyles - // - this.listViewStyles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewStyles.CheckBoxes = true; - this.listViewStyles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderName, - this.columnHeaderFontName, - this.columnHeaderFontSize, - this.columnHeaderUseCount, - this.columnHeaderPrimaryColor, - this.columnHeaderOutline}); - this.listViewStyles.FullRowSelect = true; - this.listViewStyles.HideSelection = false; - this.listViewStyles.Location = new System.Drawing.Point(6, 19); - this.listViewStyles.MultiSelect = false; - this.listViewStyles.Name = "listViewStyles"; - this.listViewStyles.Size = new System.Drawing.Size(688, 399); - this.listViewStyles.TabIndex = 0; - this.listViewStyles.UseCompatibleStateImageBehavior = false; - this.listViewStyles.View = System.Windows.Forms.View.Details; - // - // columnHeaderName - // - this.columnHeaderName.Text = "Name"; - this.columnHeaderName.Width = 130; - // - // columnHeaderFontName - // - this.columnHeaderFontName.Text = "Font name"; - this.columnHeaderFontName.Width = 128; - // - // columnHeaderFontSize - // - this.columnHeaderFontSize.Text = "Font size"; - this.columnHeaderFontSize.Width = 85; - // - // columnHeaderUseCount - // - this.columnHeaderUseCount.Text = "Used#"; - this.columnHeaderUseCount.Width = 65; - // - // columnHeaderPrimaryColor - // - this.columnHeaderPrimaryColor.Text = "Primary"; - // - // columnHeaderOutline - // - this.columnHeaderOutline.Text = "Outline"; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(637, 442); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(556, 442); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // ChooseStyle - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(724, 475); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.groupBoxStyles); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ChooseStyle"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Choose style"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChooseStyle_KeyDown); - this.groupBoxStyles.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxStyles; - private System.Windows.Forms.ListView listViewStyles; - private System.Windows.Forms.ColumnHeader columnHeaderName; - private System.Windows.Forms.ColumnHeader columnHeaderFontName; - private System.Windows.Forms.ColumnHeader columnHeaderFontSize; - private System.Windows.Forms.ColumnHeader columnHeaderUseCount; - private System.Windows.Forms.ColumnHeader columnHeaderPrimaryColor; - private System.Windows.Forms.ColumnHeader columnHeaderOutline; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ChooseStyle + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBoxStyles = new System.Windows.Forms.GroupBox(); + this.listViewStyles = new System.Windows.Forms.ListView(); + this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderFontName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderFontSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderUseCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderPrimaryColor = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderOutline = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxStyles.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxStyles + // + this.groupBoxStyles.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxStyles.Controls.Add(this.listViewStyles); + this.groupBoxStyles.Location = new System.Drawing.Point(12, 12); + this.groupBoxStyles.Name = "groupBoxStyles"; + this.groupBoxStyles.Size = new System.Drawing.Size(700, 424); + this.groupBoxStyles.TabIndex = 1; + this.groupBoxStyles.TabStop = false; + this.groupBoxStyles.Text = "Styles"; + // + // listViewStyles + // + this.listViewStyles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewStyles.CheckBoxes = true; + this.listViewStyles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderName, + this.columnHeaderFontName, + this.columnHeaderFontSize, + this.columnHeaderUseCount, + this.columnHeaderPrimaryColor, + this.columnHeaderOutline}); + this.listViewStyles.FullRowSelect = true; + this.listViewStyles.HideSelection = false; + this.listViewStyles.Location = new System.Drawing.Point(6, 19); + this.listViewStyles.MultiSelect = false; + this.listViewStyles.Name = "listViewStyles"; + this.listViewStyles.Size = new System.Drawing.Size(688, 399); + this.listViewStyles.TabIndex = 0; + this.listViewStyles.UseCompatibleStateImageBehavior = false; + this.listViewStyles.View = System.Windows.Forms.View.Details; + // + // columnHeaderName + // + this.columnHeaderName.Text = "Name"; + this.columnHeaderName.Width = 130; + // + // columnHeaderFontName + // + this.columnHeaderFontName.Text = "Font name"; + this.columnHeaderFontName.Width = 128; + // + // columnHeaderFontSize + // + this.columnHeaderFontSize.Text = "Font size"; + this.columnHeaderFontSize.Width = 85; + // + // columnHeaderUseCount + // + this.columnHeaderUseCount.Text = "Used#"; + this.columnHeaderUseCount.Width = 65; + // + // columnHeaderPrimaryColor + // + this.columnHeaderPrimaryColor.Text = "Primary"; + // + // columnHeaderOutline + // + this.columnHeaderOutline.Text = "Outline"; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(637, 442); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(556, 442); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // ChooseStyle + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(724, 475); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.groupBoxStyles); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ChooseStyle"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Choose style"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChooseStyle_KeyDown); + this.groupBoxStyles.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxStyles; + private System.Windows.Forms.ListView listViewStyles; + private System.Windows.Forms.ColumnHeader columnHeaderName; + private System.Windows.Forms.ColumnHeader columnHeaderFontName; + private System.Windows.Forms.ColumnHeader columnHeaderFontSize; + private System.Windows.Forms.ColumnHeader columnHeaderUseCount; + private System.Windows.Forms.ColumnHeader columnHeaderPrimaryColor; + private System.Windows.Forms.ColumnHeader columnHeaderOutline; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + } } \ No newline at end of file diff --git a/src/Forms/ChooseStyle.cs b/src/ui/Forms/ChooseStyle.cs similarity index 97% rename from src/Forms/ChooseStyle.cs rename to src/ui/Forms/ChooseStyle.cs index 3c971720e..6ace18b5c 100644 --- a/src/Forms/ChooseStyle.cs +++ b/src/ui/Forms/ChooseStyle.cs @@ -1,84 +1,84 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Forms.Styles; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ChooseStyle : Form - { - public List SelectedStyleNames { get; set; } - - private readonly Subtitle _subtitle; - private readonly bool _isSubStationAlpha; - - public ChooseStyle(Subtitle subtitle, bool isSubStationAlpha) - { - SelectedStyleNames = new List(); - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _subtitle = subtitle; - _isSubStationAlpha = isSubStationAlpha; - - var l = Configuration.Settings.Language.SubStationAlphaStyles; - Text = l.ChooseStyle; - listViewStyles.Columns[0].Text = l.Name; - listViewStyles.Columns[1].Text = l.FontName; - listViewStyles.Columns[2].Text = l.FontSize; - listViewStyles.Columns[3].Text = l.UseCount; - listViewStyles.Columns[4].Text = l.Primary; - listViewStyles.Columns[5].Text = l.Outline; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - - InitializeListView(); - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void ChooseStyle_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewStyles.Items) - { - if (item.Checked) - { - SelectedStyleNames.Add(item.Text); - } - } - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void InitializeListView() - { - var styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); - listViewStyles.Items.Clear(); - foreach (string style in styles) - { - SsaStyle ssaStyle = AdvancedSubStationAlpha.GetSsaStyle(style, _subtitle.Header); - SubStationAlphaStyles.AddStyle(listViewStyles, ssaStyle, _subtitle, _isSubStationAlpha); - } - if (listViewStyles.Items.Count > 0) - { - listViewStyles.Items[0].Selected = true; - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Forms.Styles; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ChooseStyle : Form + { + public List SelectedStyleNames { get; set; } + + private readonly Subtitle _subtitle; + private readonly bool _isSubStationAlpha; + + public ChooseStyle(Subtitle subtitle, bool isSubStationAlpha) + { + SelectedStyleNames = new List(); + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _subtitle = subtitle; + _isSubStationAlpha = isSubStationAlpha; + + var l = Configuration.Settings.Language.SubStationAlphaStyles; + Text = l.ChooseStyle; + listViewStyles.Columns[0].Text = l.Name; + listViewStyles.Columns[1].Text = l.FontName; + listViewStyles.Columns[2].Text = l.FontSize; + listViewStyles.Columns[3].Text = l.UseCount; + listViewStyles.Columns[4].Text = l.Primary; + listViewStyles.Columns[5].Text = l.Outline; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + + InitializeListView(); + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void ChooseStyle_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewStyles.Items) + { + if (item.Checked) + { + SelectedStyleNames.Add(item.Text); + } + } + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void InitializeListView() + { + var styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); + listViewStyles.Items.Clear(); + foreach (string style in styles) + { + SsaStyle ssaStyle = AdvancedSubStationAlpha.GetSsaStyle(style, _subtitle.Header); + SubStationAlphaStyles.AddStyle(listViewStyles, ssaStyle, _subtitle, _isSubStationAlpha); + } + if (listViewStyles.Items.Count > 0) + { + listViewStyles.Items[0].Selected = true; + } + } + + } +} diff --git a/src/Forms/ExportPngXmlDialogOpenFolder.resx b/src/ui/Forms/ChooseStyle.resx similarity index 100% rename from src/Forms/ExportPngXmlDialogOpenFolder.resx rename to src/ui/Forms/ChooseStyle.resx diff --git a/src/Forms/ColorChooser.cs b/src/ui/Forms/ColorChooser.cs similarity index 100% rename from src/Forms/ColorChooser.cs rename to src/ui/Forms/ColorChooser.cs diff --git a/src/Forms/ColorChooser.resx b/src/ui/Forms/ColorChooser.resx similarity index 100% rename from src/Forms/ColorChooser.resx rename to src/ui/Forms/ColorChooser.resx diff --git a/src/Forms/ColumnPaste.Designer.cs b/src/ui/Forms/ColumnPaste.Designer.cs similarity index 98% rename from src/Forms/ColumnPaste.Designer.cs rename to src/ui/Forms/ColumnPaste.Designer.cs index b5467f607..b84aaf34d 100644 --- a/src/Forms/ColumnPaste.Designer.cs +++ b/src/ui/Forms/ColumnPaste.Designer.cs @@ -1,202 +1,202 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ColumnPaste - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.radioButtonTextOnly = new System.Windows.Forms.RadioButton(); - this.radioButtonTimeCodes = new System.Windows.Forms.RadioButton(); - this.radioButtonOriginalText = new System.Windows.Forms.RadioButton(); - this.radioButtonAll = new System.Windows.Forms.RadioButton(); - this.groupBoxChooseColumn = new System.Windows.Forms.GroupBox(); - this.groupBoxOverwriteOrInsert = new System.Windows.Forms.GroupBox(); - this.radioButtonShiftCellsDown = new System.Windows.Forms.RadioButton(); - this.radioButtonOverwrite = new System.Windows.Forms.RadioButton(); - this.groupBoxChooseColumn.SuspendLayout(); - this.groupBoxOverwriteOrInsert.SuspendLayout(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(378, 136); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(297, 136); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // radioButtonTextOnly - // - this.radioButtonTextOnly.AutoSize = true; - this.radioButtonTextOnly.Checked = true; - this.radioButtonTextOnly.Location = new System.Drawing.Point(6, 65); - this.radioButtonTextOnly.Name = "radioButtonTextOnly"; - this.radioButtonTextOnly.Size = new System.Drawing.Size(68, 17); - this.radioButtonTextOnly.TabIndex = 5; - this.radioButtonTextOnly.TabStop = true; - this.radioButtonTextOnly.Text = "Text only"; - this.radioButtonTextOnly.UseVisualStyleBackColor = true; - // - // radioButtonTimeCodes - // - this.radioButtonTimeCodes.AutoSize = true; - this.radioButtonTimeCodes.Location = new System.Drawing.Point(6, 42); - this.radioButtonTimeCodes.Name = "radioButtonTimeCodes"; - this.radioButtonTimeCodes.Size = new System.Drawing.Size(102, 17); - this.radioButtonTimeCodes.TabIndex = 6; - this.radioButtonTimeCodes.TabStop = true; - this.radioButtonTimeCodes.Text = "Time codes only"; - this.radioButtonTimeCodes.UseVisualStyleBackColor = true; - // - // radioButtonOriginalText - // - this.radioButtonOriginalText.AutoSize = true; - this.radioButtonOriginalText.Location = new System.Drawing.Point(6, 90); - this.radioButtonOriginalText.Name = "radioButtonOriginalText"; - this.radioButtonOriginalText.Size = new System.Drawing.Size(102, 17); - this.radioButtonOriginalText.TabIndex = 7; - this.radioButtonOriginalText.TabStop = true; - this.radioButtonOriginalText.Text = "Original text only"; - this.radioButtonOriginalText.UseVisualStyleBackColor = true; - // - // radioButtonAll - // - this.radioButtonAll.AutoSize = true; - this.radioButtonAll.Location = new System.Drawing.Point(6, 19); - this.radioButtonAll.Name = "radioButtonAll"; - this.radioButtonAll.Size = new System.Drawing.Size(36, 17); - this.radioButtonAll.TabIndex = 8; - this.radioButtonAll.TabStop = true; - this.radioButtonAll.Text = "All"; - this.radioButtonAll.UseVisualStyleBackColor = true; - // - // groupBoxChooseColumn - // - this.groupBoxChooseColumn.Controls.Add(this.radioButtonAll); - this.groupBoxChooseColumn.Controls.Add(this.radioButtonTextOnly); - this.groupBoxChooseColumn.Controls.Add(this.radioButtonTimeCodes); - this.groupBoxChooseColumn.Controls.Add(this.radioButtonOriginalText); - this.groupBoxChooseColumn.Location = new System.Drawing.Point(12, 12); - this.groupBoxChooseColumn.Name = "groupBoxChooseColumn"; - this.groupBoxChooseColumn.Size = new System.Drawing.Size(237, 116); - this.groupBoxChooseColumn.TabIndex = 9; - this.groupBoxChooseColumn.TabStop = false; - this.groupBoxChooseColumn.Text = "Choose column"; - // - // groupBoxOverwriteOrInsert - // - this.groupBoxOverwriteOrInsert.Controls.Add(this.radioButtonShiftCellsDown); - this.groupBoxOverwriteOrInsert.Controls.Add(this.radioButtonOverwrite); - this.groupBoxOverwriteOrInsert.Location = new System.Drawing.Point(255, 12); - this.groupBoxOverwriteOrInsert.Name = "groupBoxOverwriteOrInsert"; - this.groupBoxOverwriteOrInsert.Size = new System.Drawing.Size(200, 116); - this.groupBoxOverwriteOrInsert.TabIndex = 10; - this.groupBoxOverwriteOrInsert.TabStop = false; - this.groupBoxOverwriteOrInsert.Text = "Overwrite/Shift cells down"; - // - // radioButtonShiftCellsDown - // - this.radioButtonShiftCellsDown.AutoSize = true; - this.radioButtonShiftCellsDown.Location = new System.Drawing.Point(6, 42); - this.radioButtonShiftCellsDown.Name = "radioButtonShiftCellsDown"; - this.radioButtonShiftCellsDown.Size = new System.Drawing.Size(99, 17); - this.radioButtonShiftCellsDown.TabIndex = 10; - this.radioButtonShiftCellsDown.TabStop = true; - this.radioButtonShiftCellsDown.Text = "Shift cells down"; - this.radioButtonShiftCellsDown.UseVisualStyleBackColor = true; - // - // radioButtonOverwrite - // - this.radioButtonOverwrite.AutoSize = true; - this.radioButtonOverwrite.Checked = true; - this.radioButtonOverwrite.Location = new System.Drawing.Point(6, 19); - this.radioButtonOverwrite.Name = "radioButtonOverwrite"; - this.radioButtonOverwrite.Size = new System.Drawing.Size(70, 17); - this.radioButtonOverwrite.TabIndex = 9; - this.radioButtonOverwrite.TabStop = true; - this.radioButtonOverwrite.Text = "Overwrite"; - this.radioButtonOverwrite.UseVisualStyleBackColor = true; - // - // ColumnPaste - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(465, 169); - this.Controls.Add(this.groupBoxOverwriteOrInsert); - this.Controls.Add(this.groupBoxChooseColumn); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ColumnPaste"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Column paste"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ColumnPaste_FormClosing); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PasteSpecial_KeyDown); - this.groupBoxChooseColumn.ResumeLayout(false); - this.groupBoxChooseColumn.PerformLayout(); - this.groupBoxOverwriteOrInsert.ResumeLayout(false); - this.groupBoxOverwriteOrInsert.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.RadioButton radioButtonTextOnly; - private System.Windows.Forms.RadioButton radioButtonTimeCodes; - private System.Windows.Forms.RadioButton radioButtonOriginalText; - private System.Windows.Forms.RadioButton radioButtonAll; - private System.Windows.Forms.GroupBox groupBoxChooseColumn; - private System.Windows.Forms.GroupBox groupBoxOverwriteOrInsert; - private System.Windows.Forms.RadioButton radioButtonShiftCellsDown; - private System.Windows.Forms.RadioButton radioButtonOverwrite; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ColumnPaste + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.radioButtonTextOnly = new System.Windows.Forms.RadioButton(); + this.radioButtonTimeCodes = new System.Windows.Forms.RadioButton(); + this.radioButtonOriginalText = new System.Windows.Forms.RadioButton(); + this.radioButtonAll = new System.Windows.Forms.RadioButton(); + this.groupBoxChooseColumn = new System.Windows.Forms.GroupBox(); + this.groupBoxOverwriteOrInsert = new System.Windows.Forms.GroupBox(); + this.radioButtonShiftCellsDown = new System.Windows.Forms.RadioButton(); + this.radioButtonOverwrite = new System.Windows.Forms.RadioButton(); + this.groupBoxChooseColumn.SuspendLayout(); + this.groupBoxOverwriteOrInsert.SuspendLayout(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(378, 136); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(297, 136); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // radioButtonTextOnly + // + this.radioButtonTextOnly.AutoSize = true; + this.radioButtonTextOnly.Checked = true; + this.radioButtonTextOnly.Location = new System.Drawing.Point(6, 65); + this.radioButtonTextOnly.Name = "radioButtonTextOnly"; + this.radioButtonTextOnly.Size = new System.Drawing.Size(68, 17); + this.radioButtonTextOnly.TabIndex = 5; + this.radioButtonTextOnly.TabStop = true; + this.radioButtonTextOnly.Text = "Text only"; + this.radioButtonTextOnly.UseVisualStyleBackColor = true; + // + // radioButtonTimeCodes + // + this.radioButtonTimeCodes.AutoSize = true; + this.radioButtonTimeCodes.Location = new System.Drawing.Point(6, 42); + this.radioButtonTimeCodes.Name = "radioButtonTimeCodes"; + this.radioButtonTimeCodes.Size = new System.Drawing.Size(102, 17); + this.radioButtonTimeCodes.TabIndex = 6; + this.radioButtonTimeCodes.TabStop = true; + this.radioButtonTimeCodes.Text = "Time codes only"; + this.radioButtonTimeCodes.UseVisualStyleBackColor = true; + // + // radioButtonOriginalText + // + this.radioButtonOriginalText.AutoSize = true; + this.radioButtonOriginalText.Location = new System.Drawing.Point(6, 90); + this.radioButtonOriginalText.Name = "radioButtonOriginalText"; + this.radioButtonOriginalText.Size = new System.Drawing.Size(102, 17); + this.radioButtonOriginalText.TabIndex = 7; + this.radioButtonOriginalText.TabStop = true; + this.radioButtonOriginalText.Text = "Original text only"; + this.radioButtonOriginalText.UseVisualStyleBackColor = true; + // + // radioButtonAll + // + this.radioButtonAll.AutoSize = true; + this.radioButtonAll.Location = new System.Drawing.Point(6, 19); + this.radioButtonAll.Name = "radioButtonAll"; + this.radioButtonAll.Size = new System.Drawing.Size(36, 17); + this.radioButtonAll.TabIndex = 8; + this.radioButtonAll.TabStop = true; + this.radioButtonAll.Text = "All"; + this.radioButtonAll.UseVisualStyleBackColor = true; + // + // groupBoxChooseColumn + // + this.groupBoxChooseColumn.Controls.Add(this.radioButtonAll); + this.groupBoxChooseColumn.Controls.Add(this.radioButtonTextOnly); + this.groupBoxChooseColumn.Controls.Add(this.radioButtonTimeCodes); + this.groupBoxChooseColumn.Controls.Add(this.radioButtonOriginalText); + this.groupBoxChooseColumn.Location = new System.Drawing.Point(12, 12); + this.groupBoxChooseColumn.Name = "groupBoxChooseColumn"; + this.groupBoxChooseColumn.Size = new System.Drawing.Size(237, 116); + this.groupBoxChooseColumn.TabIndex = 9; + this.groupBoxChooseColumn.TabStop = false; + this.groupBoxChooseColumn.Text = "Choose column"; + // + // groupBoxOverwriteOrInsert + // + this.groupBoxOverwriteOrInsert.Controls.Add(this.radioButtonShiftCellsDown); + this.groupBoxOverwriteOrInsert.Controls.Add(this.radioButtonOverwrite); + this.groupBoxOverwriteOrInsert.Location = new System.Drawing.Point(255, 12); + this.groupBoxOverwriteOrInsert.Name = "groupBoxOverwriteOrInsert"; + this.groupBoxOverwriteOrInsert.Size = new System.Drawing.Size(200, 116); + this.groupBoxOverwriteOrInsert.TabIndex = 10; + this.groupBoxOverwriteOrInsert.TabStop = false; + this.groupBoxOverwriteOrInsert.Text = "Overwrite/Shift cells down"; + // + // radioButtonShiftCellsDown + // + this.radioButtonShiftCellsDown.AutoSize = true; + this.radioButtonShiftCellsDown.Location = new System.Drawing.Point(6, 42); + this.radioButtonShiftCellsDown.Name = "radioButtonShiftCellsDown"; + this.radioButtonShiftCellsDown.Size = new System.Drawing.Size(99, 17); + this.radioButtonShiftCellsDown.TabIndex = 10; + this.radioButtonShiftCellsDown.TabStop = true; + this.radioButtonShiftCellsDown.Text = "Shift cells down"; + this.radioButtonShiftCellsDown.UseVisualStyleBackColor = true; + // + // radioButtonOverwrite + // + this.radioButtonOverwrite.AutoSize = true; + this.radioButtonOverwrite.Checked = true; + this.radioButtonOverwrite.Location = new System.Drawing.Point(6, 19); + this.radioButtonOverwrite.Name = "radioButtonOverwrite"; + this.radioButtonOverwrite.Size = new System.Drawing.Size(70, 17); + this.radioButtonOverwrite.TabIndex = 9; + this.radioButtonOverwrite.TabStop = true; + this.radioButtonOverwrite.Text = "Overwrite"; + this.radioButtonOverwrite.UseVisualStyleBackColor = true; + // + // ColumnPaste + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(465, 169); + this.Controls.Add(this.groupBoxOverwriteOrInsert); + this.Controls.Add(this.groupBoxChooseColumn); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ColumnPaste"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Column paste"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ColumnPaste_FormClosing); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PasteSpecial_KeyDown); + this.groupBoxChooseColumn.ResumeLayout(false); + this.groupBoxChooseColumn.PerformLayout(); + this.groupBoxOverwriteOrInsert.ResumeLayout(false); + this.groupBoxOverwriteOrInsert.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.RadioButton radioButtonTextOnly; + private System.Windows.Forms.RadioButton radioButtonTimeCodes; + private System.Windows.Forms.RadioButton radioButtonOriginalText; + private System.Windows.Forms.RadioButton radioButtonAll; + private System.Windows.Forms.GroupBox groupBoxChooseColumn; + private System.Windows.Forms.GroupBox groupBoxOverwriteOrInsert; + private System.Windows.Forms.RadioButton radioButtonShiftCellsDown; + private System.Windows.Forms.RadioButton radioButtonOverwrite; + } } \ No newline at end of file diff --git a/src/Forms/ColumnPaste.cs b/src/ui/Forms/ColumnPaste.cs similarity index 97% rename from src/Forms/ColumnPaste.cs rename to src/ui/Forms/ColumnPaste.cs index 7b3ceed03..b46ad32d4 100644 --- a/src/Forms/ColumnPaste.cs +++ b/src/ui/Forms/ColumnPaste.cs @@ -1,120 +1,120 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ColumnPaste : Form - { - public bool PasteAll { get; set; } - public bool PasteTimeCodesOnly { get; set; } - public bool PasteTextOnly { get; set; } - public bool PasteOriginalTextOnly { get; set; } - - public bool PasteOverwrite { get; set; } - - public ColumnPaste(bool isOriginalAvailable, bool onlyText) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - UiUtil.FixLargeFonts(this, buttonOK); - - radioButtonAll.Enabled = !onlyText; - radioButtonTimeCodes.Enabled = !onlyText; - radioButtonOriginalText.Visible = isOriginalAvailable; - - Text = Configuration.Settings.Language.ColumnPaste.Title; - groupBoxChooseColumn.Text = Configuration.Settings.Language.ColumnPaste.ChooseColumn; - groupBoxOverwriteOrInsert.Text = Configuration.Settings.Language.ColumnPaste.OverwriteShiftCellsDown; - radioButtonOverwrite.Text = Configuration.Settings.Language.ColumnPaste.Overwrite; - radioButtonShiftCellsDown.Text = Configuration.Settings.Language.ColumnPaste.ShiftCellsDown; - radioButtonAll.Text = Configuration.Settings.Language.General.All; - radioButtonTimeCodes.Text = Configuration.Settings.Language.ColumnPaste.TimeCodesOnly; - radioButtonTextOnly.Text = Configuration.Settings.Language.ColumnPaste.TextOnly; - radioButtonOriginalText.Text = Configuration.Settings.Language.ColumnPaste.OriginalTextOnly; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - - if (Configuration.Settings.Tools.ColumnPasteColumn == "timecodes") - { - radioButtonTimeCodes.Checked = true; - } - else if (Configuration.Settings.Tools.ColumnPasteColumn == "text") - { - radioButtonTextOnly.Checked = true; - } - else if (isOriginalAvailable && Configuration.Settings.Tools.ColumnPasteColumn == "originaltext") - { - radioButtonOriginalText.Checked = true; - } - else - { - radioButtonAll.Checked = true; - } - - if (onlyText) - { - radioButtonTextOnly.Checked = true; - } - - - if (Configuration.Settings.Tools.ColumnPasteOverwriteMode == "shiftdown") - { - radioButtonShiftCellsDown.Checked = true; - } - else - { - radioButtonOverwrite.Checked = true; - } - } - - private void PasteSpecial_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - PasteAll = radioButtonAll.Checked; - PasteTimeCodesOnly = radioButtonTimeCodes.Checked; - PasteTextOnly = radioButtonTextOnly.Checked; - PasteOriginalTextOnly = radioButtonOriginalText.Checked; - PasteOverwrite = radioButtonOverwrite.Checked; - - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void ColumnPaste_FormClosing(object sender, FormClosingEventArgs e) - { - if (radioButtonTimeCodes.Checked) - { - Configuration.Settings.Tools.ColumnPasteColumn = "timecodes"; - } - else if (radioButtonTextOnly.Checked) - { - Configuration.Settings.Tools.ColumnPasteColumn = "text"; - } - else if (radioButtonOriginalText.Checked) - { - Configuration.Settings.Tools.ColumnPasteColumn = "originaltext"; - } - else - { - Configuration.Settings.Tools.ColumnPasteColumn = "all"; - } - - Configuration.Settings.Tools.ColumnPasteOverwriteMode = radioButtonOverwrite.Checked ? "overwrite" : "shiftdown"; - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ColumnPaste : Form + { + public bool PasteAll { get; set; } + public bool PasteTimeCodesOnly { get; set; } + public bool PasteTextOnly { get; set; } + public bool PasteOriginalTextOnly { get; set; } + + public bool PasteOverwrite { get; set; } + + public ColumnPaste(bool isOriginalAvailable, bool onlyText) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + UiUtil.FixLargeFonts(this, buttonOK); + + radioButtonAll.Enabled = !onlyText; + radioButtonTimeCodes.Enabled = !onlyText; + radioButtonOriginalText.Visible = isOriginalAvailable; + + Text = Configuration.Settings.Language.ColumnPaste.Title; + groupBoxChooseColumn.Text = Configuration.Settings.Language.ColumnPaste.ChooseColumn; + groupBoxOverwriteOrInsert.Text = Configuration.Settings.Language.ColumnPaste.OverwriteShiftCellsDown; + radioButtonOverwrite.Text = Configuration.Settings.Language.ColumnPaste.Overwrite; + radioButtonShiftCellsDown.Text = Configuration.Settings.Language.ColumnPaste.ShiftCellsDown; + radioButtonAll.Text = Configuration.Settings.Language.General.All; + radioButtonTimeCodes.Text = Configuration.Settings.Language.ColumnPaste.TimeCodesOnly; + radioButtonTextOnly.Text = Configuration.Settings.Language.ColumnPaste.TextOnly; + radioButtonOriginalText.Text = Configuration.Settings.Language.ColumnPaste.OriginalTextOnly; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + + if (Configuration.Settings.Tools.ColumnPasteColumn == "timecodes") + { + radioButtonTimeCodes.Checked = true; + } + else if (Configuration.Settings.Tools.ColumnPasteColumn == "text") + { + radioButtonTextOnly.Checked = true; + } + else if (isOriginalAvailable && Configuration.Settings.Tools.ColumnPasteColumn == "originaltext") + { + radioButtonOriginalText.Checked = true; + } + else + { + radioButtonAll.Checked = true; + } + + if (onlyText) + { + radioButtonTextOnly.Checked = true; + } + + + if (Configuration.Settings.Tools.ColumnPasteOverwriteMode == "shiftdown") + { + radioButtonShiftCellsDown.Checked = true; + } + else + { + radioButtonOverwrite.Checked = true; + } + } + + private void PasteSpecial_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + PasteAll = radioButtonAll.Checked; + PasteTimeCodesOnly = radioButtonTimeCodes.Checked; + PasteTextOnly = radioButtonTextOnly.Checked; + PasteOriginalTextOnly = radioButtonOriginalText.Checked; + PasteOverwrite = radioButtonOverwrite.Checked; + + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void ColumnPaste_FormClosing(object sender, FormClosingEventArgs e) + { + if (radioButtonTimeCodes.Checked) + { + Configuration.Settings.Tools.ColumnPasteColumn = "timecodes"; + } + else if (radioButtonTextOnly.Checked) + { + Configuration.Settings.Tools.ColumnPasteColumn = "text"; + } + else if (radioButtonOriginalText.Checked) + { + Configuration.Settings.Tools.ColumnPasteColumn = "originaltext"; + } + else + { + Configuration.Settings.Tools.ColumnPasteColumn = "all"; + } + + Configuration.Settings.Tools.ColumnPasteOverwriteMode = radioButtonOverwrite.Checked ? "overwrite" : "shiftdown"; + } + } +} diff --git a/src/Forms/ExportPngXmlPreview.resx b/src/ui/Forms/ColumnPaste.resx similarity index 100% rename from src/Forms/ExportPngXmlPreview.resx rename to src/ui/Forms/ColumnPaste.resx diff --git a/src/Forms/Compare.Designer.cs b/src/ui/Forms/Compare.Designer.cs similarity index 98% rename from src/Forms/Compare.Designer.cs rename to src/ui/Forms/Compare.Designer.cs index 58d5e0f60..c9922214b 100644 --- a/src/Forms/Compare.Designer.cs +++ b/src/ui/Forms/Compare.Designer.cs @@ -1,392 +1,392 @@ -using Nikse.SubtitleEdit.Controls; - -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class Compare - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.buttonOK = new System.Windows.Forms.Button(); - this.labelSubtitle2 = new System.Windows.Forms.Label(); - this.labelSubtitle1 = new System.Windows.Forms.Label(); - this.buttonOpenSubtitle1 = new System.Windows.Forms.Button(); - this.buttonOpenSubtitle2 = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.buttonNextDifference = new System.Windows.Forms.Button(); - this.buttonPreviousDifference = new System.Windows.Forms.Button(); - this.labelStatus = new System.Windows.Forms.Label(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.richTextBox1 = new System.Windows.Forms.RichTextBox(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.copyTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.richTextBox2 = new System.Windows.Forms.RichTextBox(); - this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.copyTextToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.checkBoxShowOnlyDifferences = new System.Windows.Forms.CheckBox(); - this.checkBoxOnlyListDifferencesInText = new System.Windows.Forms.CheckBox(); - this.checkBoxIgnoreLineBreaks = new System.Windows.Forms.CheckBox(); - this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.subtitleListView2 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.checkBoxIgnoreFormatting = new System.Windows.Forms.CheckBox(); - this.buttonExport = new System.Windows.Forms.Button(); - this.contextMenuStrip1.SuspendLayout(); - this.contextMenuStrip2.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(884, 561); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(84, 23); - this.buttonOK.TabIndex = 22; - this.buttonOK.Text = "&Close"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // labelSubtitle2 - // - this.labelSubtitle2.AutoSize = true; - this.labelSubtitle2.Location = new System.Drawing.Point(491, 36); - this.labelSubtitle2.Name = "labelSubtitle2"; - this.labelSubtitle2.Size = new System.Drawing.Size(30, 13); - this.labelSubtitle2.TabIndex = 3; - this.labelSubtitle2.Text = "sub2"; - this.labelSubtitle2.MouseHover += new System.EventHandler(this.labelSubtitle2_MouseHover); - // - // labelSubtitle1 - // - this.labelSubtitle1.AutoSize = true; - this.labelSubtitle1.Location = new System.Drawing.Point(9, 36); - this.labelSubtitle1.Name = "labelSubtitle1"; - this.labelSubtitle1.Size = new System.Drawing.Size(30, 13); - this.labelSubtitle1.TabIndex = 2; - this.labelSubtitle1.Text = "sub1"; - this.labelSubtitle1.MouseHover += new System.EventHandler(this.labelSubtitle1_MouseHover); - // - // buttonOpenSubtitle1 - // - this.buttonOpenSubtitle1.Location = new System.Drawing.Point(9, 8); - this.buttonOpenSubtitle1.Name = "buttonOpenSubtitle1"; - this.buttonOpenSubtitle1.Size = new System.Drawing.Size(28, 23); - this.buttonOpenSubtitle1.TabIndex = 0; - this.buttonOpenSubtitle1.Text = "..."; - this.buttonOpenSubtitle1.UseVisualStyleBackColor = true; - this.buttonOpenSubtitle1.Click += new System.EventHandler(this.ButtonOpenSubtitle1Click); - // - // buttonOpenSubtitle2 - // - this.buttonOpenSubtitle2.Location = new System.Drawing.Point(491, 8); - this.buttonOpenSubtitle2.Name = "buttonOpenSubtitle2"; - this.buttonOpenSubtitle2.Size = new System.Drawing.Size(28, 23); - this.buttonOpenSubtitle2.TabIndex = 1; - this.buttonOpenSubtitle2.Text = "..."; - this.buttonOpenSubtitle2.UseVisualStyleBackColor = true; - this.buttonOpenSubtitle2.Click += new System.EventHandler(this.ButtonOpenSubtitle2Click); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // buttonNextDifference - // - this.buttonNextDifference.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonNextDifference.Enabled = false; - this.buttonNextDifference.Location = new System.Drawing.Point(168, 549); - this.buttonNextDifference.Name = "buttonNextDifference"; - this.buttonNextDifference.Size = new System.Drawing.Size(156, 23); - this.buttonNextDifference.TabIndex = 9; - this.buttonNextDifference.Text = "&Next difference"; - this.buttonNextDifference.UseVisualStyleBackColor = true; - this.buttonNextDifference.Click += new System.EventHandler(this.ButtonNextDifferenceClick); - // - // buttonPreviousDifference - // - this.buttonPreviousDifference.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonPreviousDifference.Enabled = false; - this.buttonPreviousDifference.Location = new System.Drawing.Point(6, 549); - this.buttonPreviousDifference.Name = "buttonPreviousDifference"; - this.buttonPreviousDifference.Size = new System.Drawing.Size(156, 23); - this.buttonPreviousDifference.TabIndex = 8; - this.buttonPreviousDifference.Text = "&Previous difference"; - this.buttonPreviousDifference.UseVisualStyleBackColor = true; - this.buttonPreviousDifference.Click += new System.EventHandler(this.ButtonPreviousDifferenceClick); - // - // labelStatus - // - this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelStatus.AutoSize = true; - this.labelStatus.Location = new System.Drawing.Point(4, 574); - this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(37, 13); - this.labelStatus.TabIndex = 17; - this.labelStatus.Text = "status"; - // - // timer1 - // - this.timer1.Tick += new System.EventHandler(this.Timer1Tick); - // - // richTextBox1 - // - this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.richTextBox1.BackColor = System.Drawing.SystemColors.Control; - this.richTextBox1.ContextMenuStrip = this.contextMenuStrip1; - this.richTextBox1.Location = new System.Drawing.Point(8, 486); - this.richTextBox1.Name = "richTextBox1"; - this.richTextBox1.ReadOnly = true; - this.richTextBox1.Size = new System.Drawing.Size(476, 43); - this.richTextBox1.TabIndex = 6; - this.richTextBox1.Text = ""; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.copyTextToolStripMenuItem}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(168, 26); - // - // copyTextToolStripMenuItem - // - this.copyTextToolStripMenuItem.Name = "copyTextToolStripMenuItem"; - this.copyTextToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); - this.copyTextToolStripMenuItem.Size = new System.Drawing.Size(167, 22); - this.copyTextToolStripMenuItem.Text = "Copy Text"; - this.copyTextToolStripMenuItem.Click += new System.EventHandler(this.copyTextToolStripMenuItem_Click); - // - // richTextBox2 - // - this.richTextBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.richTextBox2.BackColor = System.Drawing.SystemColors.Control; - this.richTextBox2.ContextMenuStrip = this.contextMenuStrip2; - this.richTextBox2.Location = new System.Drawing.Point(490, 485); - this.richTextBox2.Name = "richTextBox2"; - this.richTextBox2.ReadOnly = true; - this.richTextBox2.Size = new System.Drawing.Size(478, 43); - this.richTextBox2.TabIndex = 7; - this.richTextBox2.Text = ""; - // - // contextMenuStrip2 - // - this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.copyTextToolStripMenuItem1}); - this.contextMenuStrip2.Name = "contextMenuStrip2"; - this.contextMenuStrip2.Size = new System.Drawing.Size(168, 26); - // - // copyTextToolStripMenuItem1 - // - this.copyTextToolStripMenuItem1.Name = "copyTextToolStripMenuItem1"; - this.copyTextToolStripMenuItem1.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); - this.copyTextToolStripMenuItem1.Size = new System.Drawing.Size(167, 22); - this.copyTextToolStripMenuItem1.Text = "Copy Text"; - this.copyTextToolStripMenuItem1.Click += new System.EventHandler(this.copyTextToolStripMenuItem1_Click); - // - // checkBoxShowOnlyDifferences - // - this.checkBoxShowOnlyDifferences.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.checkBoxShowOnlyDifferences.AutoSize = true; - this.checkBoxShowOnlyDifferences.Location = new System.Drawing.Point(330, 534); - this.checkBoxShowOnlyDifferences.Name = "checkBoxShowOnlyDifferences"; - this.checkBoxShowOnlyDifferences.Size = new System.Drawing.Size(132, 17); - this.checkBoxShowOnlyDifferences.TabIndex = 10; - this.checkBoxShowOnlyDifferences.Text = "Show only differences"; - this.checkBoxShowOnlyDifferences.UseVisualStyleBackColor = true; - this.checkBoxShowOnlyDifferences.CheckedChanged += new System.EventHandler(this.checkBoxShowOnlyDifferences_CheckedChanged); - // - // checkBoxOnlyListDifferencesInText - // - this.checkBoxOnlyListDifferencesInText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.checkBoxOnlyListDifferencesInText.AutoSize = true; - this.checkBoxOnlyListDifferencesInText.Checked = true; - this.checkBoxOnlyListDifferencesInText.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxOnlyListDifferencesInText.Location = new System.Drawing.Point(330, 552); - this.checkBoxOnlyListDifferencesInText.Name = "checkBoxOnlyListDifferencesInText"; - this.checkBoxOnlyListDifferencesInText.Size = new System.Drawing.Size(197, 17); - this.checkBoxOnlyListDifferencesInText.TabIndex = 11; - this.checkBoxOnlyListDifferencesInText.Text = "Only look for differences in the text"; - this.checkBoxOnlyListDifferencesInText.UseVisualStyleBackColor = true; - this.checkBoxOnlyListDifferencesInText.CheckedChanged += new System.EventHandler(this.checkBoxOnlyListDifferencesInText_CheckedChanged); - // - // checkBoxIgnoreLineBreaks - // - this.checkBoxIgnoreLineBreaks.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.checkBoxIgnoreLineBreaks.AutoSize = true; - this.checkBoxIgnoreLineBreaks.Location = new System.Drawing.Point(582, 534); - this.checkBoxIgnoreLineBreaks.Name = "checkBoxIgnoreLineBreaks"; - this.checkBoxIgnoreLineBreaks.Size = new System.Drawing.Size(112, 17); - this.checkBoxIgnoreLineBreaks.TabIndex = 12; - this.checkBoxIgnoreLineBreaks.Text = "Ignore line breaks"; - this.checkBoxIgnoreLineBreaks.UseVisualStyleBackColor = true; - this.checkBoxIgnoreLineBreaks.CheckedChanged += new System.EventHandler(this.checkBoxIgnoreLineBreaks_CheckedChanged); - // - // toolTip1 - // - this.toolTip1.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info; - this.toolTip1.ToolTipTitle = "Subtitle name"; - // - // subtitleListView2 - // - this.subtitleListView2.AllowColumnReorder = true; - this.subtitleListView2.AllowDrop = true; - this.subtitleListView2.FirstVisibleIndex = -1; - this.subtitleListView2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.subtitleListView2.FullRowSelect = true; - this.subtitleListView2.GridLines = true; - this.subtitleListView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.subtitleListView2.HideSelection = false; - this.subtitleListView2.Location = new System.Drawing.Point(490, 56); - this.subtitleListView2.Name = "subtitleListView2"; - this.subtitleListView2.OwnerDraw = true; - this.subtitleListView2.Size = new System.Drawing.Size(478, 422); - this.subtitleListView2.SubtitleFontBold = false; - this.subtitleListView2.SubtitleFontName = "Tahoma"; - this.subtitleListView2.SubtitleFontSize = 8; - this.subtitleListView2.TabIndex = 5; - this.subtitleListView2.UseCompatibleStateImageBehavior = false; - this.subtitleListView2.UseSyntaxColoring = true; - this.subtitleListView2.View = System.Windows.Forms.View.Details; - this.subtitleListView2.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView2SelectedIndexChanged); - this.subtitleListView2.DragDrop += new System.Windows.Forms.DragEventHandler(this.subtitleListView2_DragDrop); - this.subtitleListView2.DragEnter += new System.Windows.Forms.DragEventHandler(this.subtitleListView2_DragEnter); - // - // subtitleListView1 - // - this.subtitleListView1.AllowColumnReorder = true; - this.subtitleListView1.AllowDrop = true; - this.subtitleListView1.FirstVisibleIndex = -1; - this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.subtitleListView1.FullRowSelect = true; - this.subtitleListView1.GridLines = true; - this.subtitleListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.subtitleListView1.HideSelection = false; - this.subtitleListView1.Location = new System.Drawing.Point(8, 56); - this.subtitleListView1.Name = "subtitleListView1"; - this.subtitleListView1.OwnerDraw = true; - this.subtitleListView1.Size = new System.Drawing.Size(476, 422); - this.subtitleListView1.SubtitleFontBold = false; - this.subtitleListView1.SubtitleFontName = "Tahoma"; - this.subtitleListView1.SubtitleFontSize = 8; - this.subtitleListView1.TabIndex = 4; - this.subtitleListView1.UseCompatibleStateImageBehavior = false; - this.subtitleListView1.UseSyntaxColoring = true; - this.subtitleListView1.View = System.Windows.Forms.View.Details; - this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView1SelectedIndexChanged); - this.subtitleListView1.DragDrop += new System.Windows.Forms.DragEventHandler(this.subtitleListView1_DragDrop); - this.subtitleListView1.DragEnter += new System.Windows.Forms.DragEventHandler(this.subtitleListView1_DragEnter); - // - // checkBoxIgnoreFormatting - // - this.checkBoxIgnoreFormatting.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.checkBoxIgnoreFormatting.AutoSize = true; - this.checkBoxIgnoreFormatting.Location = new System.Drawing.Point(582, 552); - this.checkBoxIgnoreFormatting.Name = "checkBoxIgnoreFormatting"; - this.checkBoxIgnoreFormatting.Size = new System.Drawing.Size(111, 17); - this.checkBoxIgnoreFormatting.TabIndex = 14; - this.checkBoxIgnoreFormatting.Text = "Ignore formatting"; - this.checkBoxIgnoreFormatting.UseVisualStyleBackColor = true; - this.checkBoxIgnoreFormatting.CheckedChanged += new System.EventHandler(this.checkBoxIgnoreFormatting_CheckedChanged); - // - // buttonExport - // - this.buttonExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonExport.Location = new System.Drawing.Point(774, 561); - this.buttonExport.Name = "buttonExport"; - this.buttonExport.Size = new System.Drawing.Size(104, 23); - this.buttonExport.TabIndex = 20; - this.buttonExport.Text = "Export"; - this.buttonExport.UseVisualStyleBackColor = true; - this.buttonExport.Click += new System.EventHandler(this.buttonExport_Click); - // - // Compare - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(974, 591); - this.Controls.Add(this.buttonExport); - this.Controls.Add(this.checkBoxIgnoreFormatting); - this.Controls.Add(this.checkBoxIgnoreLineBreaks); - this.Controls.Add(this.checkBoxOnlyListDifferencesInText); - this.Controls.Add(this.checkBoxShowOnlyDifferences); - this.Controls.Add(this.richTextBox2); - this.Controls.Add(this.richTextBox1); - this.Controls.Add(this.labelStatus); - this.Controls.Add(this.buttonPreviousDifference); - this.Controls.Add(this.buttonNextDifference); - this.Controls.Add(this.buttonOpenSubtitle2); - this.Controls.Add(this.buttonOpenSubtitle1); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.subtitleListView2); - this.Controls.Add(this.labelSubtitle2); - this.Controls.Add(this.subtitleListView1); - this.Controls.Add(this.labelSubtitle1); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MinimumSize = new System.Drawing.Size(800, 400); - this.Name = "Compare"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Compare subtitles"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Compare_FormClosing); - this.Shown += new System.EventHandler(this.Compare_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Compare_KeyDown); - this.Resize += new System.EventHandler(this.Compare_Resize); - this.contextMenuStrip1.ResumeLayout(false); - this.contextMenuStrip2.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Label labelSubtitle2; - private SubtitleListView subtitleListView2; - private SubtitleListView subtitleListView1; - private System.Windows.Forms.Label labelSubtitle1; - private System.Windows.Forms.Button buttonOpenSubtitle1; - private System.Windows.Forms.Button buttonOpenSubtitle2; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Button buttonNextDifference; - private System.Windows.Forms.Button buttonPreviousDifference; - private System.Windows.Forms.Label labelStatus; - private System.Windows.Forms.Timer timer1; - private System.Windows.Forms.RichTextBox richTextBox1; - private System.Windows.Forms.RichTextBox richTextBox2; - private System.Windows.Forms.CheckBox checkBoxShowOnlyDifferences; - private System.Windows.Forms.CheckBox checkBoxOnlyListDifferencesInText; - private System.Windows.Forms.CheckBox checkBoxIgnoreLineBreaks; - private System.Windows.Forms.ToolTip toolTip1; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem copyTextToolStripMenuItem; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip2; - private System.Windows.Forms.ToolStripMenuItem copyTextToolStripMenuItem1; - private System.Windows.Forms.CheckBox checkBoxIgnoreFormatting; - private System.Windows.Forms.Button buttonExport; - } +using Nikse.SubtitleEdit.Controls; + +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class Compare + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonOK = new System.Windows.Forms.Button(); + this.labelSubtitle2 = new System.Windows.Forms.Label(); + this.labelSubtitle1 = new System.Windows.Forms.Label(); + this.buttonOpenSubtitle1 = new System.Windows.Forms.Button(); + this.buttonOpenSubtitle2 = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.buttonNextDifference = new System.Windows.Forms.Button(); + this.buttonPreviousDifference = new System.Windows.Forms.Button(); + this.labelStatus = new System.Windows.Forms.Label(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.copyTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.richTextBox2 = new System.Windows.Forms.RichTextBox(); + this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.copyTextToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.checkBoxShowOnlyDifferences = new System.Windows.Forms.CheckBox(); + this.checkBoxOnlyListDifferencesInText = new System.Windows.Forms.CheckBox(); + this.checkBoxIgnoreLineBreaks = new System.Windows.Forms.CheckBox(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.subtitleListView2 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.checkBoxIgnoreFormatting = new System.Windows.Forms.CheckBox(); + this.buttonExport = new System.Windows.Forms.Button(); + this.contextMenuStrip1.SuspendLayout(); + this.contextMenuStrip2.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(884, 561); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(84, 23); + this.buttonOK.TabIndex = 22; + this.buttonOK.Text = "&Close"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // labelSubtitle2 + // + this.labelSubtitle2.AutoSize = true; + this.labelSubtitle2.Location = new System.Drawing.Point(491, 36); + this.labelSubtitle2.Name = "labelSubtitle2"; + this.labelSubtitle2.Size = new System.Drawing.Size(30, 13); + this.labelSubtitle2.TabIndex = 3; + this.labelSubtitle2.Text = "sub2"; + this.labelSubtitle2.MouseHover += new System.EventHandler(this.labelSubtitle2_MouseHover); + // + // labelSubtitle1 + // + this.labelSubtitle1.AutoSize = true; + this.labelSubtitle1.Location = new System.Drawing.Point(9, 36); + this.labelSubtitle1.Name = "labelSubtitle1"; + this.labelSubtitle1.Size = new System.Drawing.Size(30, 13); + this.labelSubtitle1.TabIndex = 2; + this.labelSubtitle1.Text = "sub1"; + this.labelSubtitle1.MouseHover += new System.EventHandler(this.labelSubtitle1_MouseHover); + // + // buttonOpenSubtitle1 + // + this.buttonOpenSubtitle1.Location = new System.Drawing.Point(9, 8); + this.buttonOpenSubtitle1.Name = "buttonOpenSubtitle1"; + this.buttonOpenSubtitle1.Size = new System.Drawing.Size(28, 23); + this.buttonOpenSubtitle1.TabIndex = 0; + this.buttonOpenSubtitle1.Text = "..."; + this.buttonOpenSubtitle1.UseVisualStyleBackColor = true; + this.buttonOpenSubtitle1.Click += new System.EventHandler(this.ButtonOpenSubtitle1Click); + // + // buttonOpenSubtitle2 + // + this.buttonOpenSubtitle2.Location = new System.Drawing.Point(491, 8); + this.buttonOpenSubtitle2.Name = "buttonOpenSubtitle2"; + this.buttonOpenSubtitle2.Size = new System.Drawing.Size(28, 23); + this.buttonOpenSubtitle2.TabIndex = 1; + this.buttonOpenSubtitle2.Text = "..."; + this.buttonOpenSubtitle2.UseVisualStyleBackColor = true; + this.buttonOpenSubtitle2.Click += new System.EventHandler(this.ButtonOpenSubtitle2Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // buttonNextDifference + // + this.buttonNextDifference.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonNextDifference.Enabled = false; + this.buttonNextDifference.Location = new System.Drawing.Point(168, 549); + this.buttonNextDifference.Name = "buttonNextDifference"; + this.buttonNextDifference.Size = new System.Drawing.Size(156, 23); + this.buttonNextDifference.TabIndex = 9; + this.buttonNextDifference.Text = "&Next difference"; + this.buttonNextDifference.UseVisualStyleBackColor = true; + this.buttonNextDifference.Click += new System.EventHandler(this.ButtonNextDifferenceClick); + // + // buttonPreviousDifference + // + this.buttonPreviousDifference.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonPreviousDifference.Enabled = false; + this.buttonPreviousDifference.Location = new System.Drawing.Point(6, 549); + this.buttonPreviousDifference.Name = "buttonPreviousDifference"; + this.buttonPreviousDifference.Size = new System.Drawing.Size(156, 23); + this.buttonPreviousDifference.TabIndex = 8; + this.buttonPreviousDifference.Text = "&Previous difference"; + this.buttonPreviousDifference.UseVisualStyleBackColor = true; + this.buttonPreviousDifference.Click += new System.EventHandler(this.ButtonPreviousDifferenceClick); + // + // labelStatus + // + this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(4, 574); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(37, 13); + this.labelStatus.TabIndex = 17; + this.labelStatus.Text = "status"; + // + // timer1 + // + this.timer1.Tick += new System.EventHandler(this.Timer1Tick); + // + // richTextBox1 + // + this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.richTextBox1.BackColor = System.Drawing.SystemColors.Control; + this.richTextBox1.ContextMenuStrip = this.contextMenuStrip1; + this.richTextBox1.Location = new System.Drawing.Point(8, 486); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.ReadOnly = true; + this.richTextBox1.Size = new System.Drawing.Size(476, 43); + this.richTextBox1.TabIndex = 6; + this.richTextBox1.Text = ""; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.copyTextToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(168, 26); + // + // copyTextToolStripMenuItem + // + this.copyTextToolStripMenuItem.Name = "copyTextToolStripMenuItem"; + this.copyTextToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); + this.copyTextToolStripMenuItem.Size = new System.Drawing.Size(167, 22); + this.copyTextToolStripMenuItem.Text = "Copy Text"; + this.copyTextToolStripMenuItem.Click += new System.EventHandler(this.copyTextToolStripMenuItem_Click); + // + // richTextBox2 + // + this.richTextBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.richTextBox2.BackColor = System.Drawing.SystemColors.Control; + this.richTextBox2.ContextMenuStrip = this.contextMenuStrip2; + this.richTextBox2.Location = new System.Drawing.Point(490, 485); + this.richTextBox2.Name = "richTextBox2"; + this.richTextBox2.ReadOnly = true; + this.richTextBox2.Size = new System.Drawing.Size(478, 43); + this.richTextBox2.TabIndex = 7; + this.richTextBox2.Text = ""; + // + // contextMenuStrip2 + // + this.contextMenuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.copyTextToolStripMenuItem1}); + this.contextMenuStrip2.Name = "contextMenuStrip2"; + this.contextMenuStrip2.Size = new System.Drawing.Size(168, 26); + // + // copyTextToolStripMenuItem1 + // + this.copyTextToolStripMenuItem1.Name = "copyTextToolStripMenuItem1"; + this.copyTextToolStripMenuItem1.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); + this.copyTextToolStripMenuItem1.Size = new System.Drawing.Size(167, 22); + this.copyTextToolStripMenuItem1.Text = "Copy Text"; + this.copyTextToolStripMenuItem1.Click += new System.EventHandler(this.copyTextToolStripMenuItem1_Click); + // + // checkBoxShowOnlyDifferences + // + this.checkBoxShowOnlyDifferences.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.checkBoxShowOnlyDifferences.AutoSize = true; + this.checkBoxShowOnlyDifferences.Location = new System.Drawing.Point(330, 534); + this.checkBoxShowOnlyDifferences.Name = "checkBoxShowOnlyDifferences"; + this.checkBoxShowOnlyDifferences.Size = new System.Drawing.Size(132, 17); + this.checkBoxShowOnlyDifferences.TabIndex = 10; + this.checkBoxShowOnlyDifferences.Text = "Show only differences"; + this.checkBoxShowOnlyDifferences.UseVisualStyleBackColor = true; + this.checkBoxShowOnlyDifferences.CheckedChanged += new System.EventHandler(this.checkBoxShowOnlyDifferences_CheckedChanged); + // + // checkBoxOnlyListDifferencesInText + // + this.checkBoxOnlyListDifferencesInText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.checkBoxOnlyListDifferencesInText.AutoSize = true; + this.checkBoxOnlyListDifferencesInText.Checked = true; + this.checkBoxOnlyListDifferencesInText.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxOnlyListDifferencesInText.Location = new System.Drawing.Point(330, 552); + this.checkBoxOnlyListDifferencesInText.Name = "checkBoxOnlyListDifferencesInText"; + this.checkBoxOnlyListDifferencesInText.Size = new System.Drawing.Size(197, 17); + this.checkBoxOnlyListDifferencesInText.TabIndex = 11; + this.checkBoxOnlyListDifferencesInText.Text = "Only look for differences in the text"; + this.checkBoxOnlyListDifferencesInText.UseVisualStyleBackColor = true; + this.checkBoxOnlyListDifferencesInText.CheckedChanged += new System.EventHandler(this.checkBoxOnlyListDifferencesInText_CheckedChanged); + // + // checkBoxIgnoreLineBreaks + // + this.checkBoxIgnoreLineBreaks.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.checkBoxIgnoreLineBreaks.AutoSize = true; + this.checkBoxIgnoreLineBreaks.Location = new System.Drawing.Point(582, 534); + this.checkBoxIgnoreLineBreaks.Name = "checkBoxIgnoreLineBreaks"; + this.checkBoxIgnoreLineBreaks.Size = new System.Drawing.Size(112, 17); + this.checkBoxIgnoreLineBreaks.TabIndex = 12; + this.checkBoxIgnoreLineBreaks.Text = "Ignore line breaks"; + this.checkBoxIgnoreLineBreaks.UseVisualStyleBackColor = true; + this.checkBoxIgnoreLineBreaks.CheckedChanged += new System.EventHandler(this.checkBoxIgnoreLineBreaks_CheckedChanged); + // + // toolTip1 + // + this.toolTip1.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info; + this.toolTip1.ToolTipTitle = "Subtitle name"; + // + // subtitleListView2 + // + this.subtitleListView2.AllowColumnReorder = true; + this.subtitleListView2.AllowDrop = true; + this.subtitleListView2.FirstVisibleIndex = -1; + this.subtitleListView2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.subtitleListView2.FullRowSelect = true; + this.subtitleListView2.GridLines = true; + this.subtitleListView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.subtitleListView2.HideSelection = false; + this.subtitleListView2.Location = new System.Drawing.Point(490, 56); + this.subtitleListView2.Name = "subtitleListView2"; + this.subtitleListView2.OwnerDraw = true; + this.subtitleListView2.Size = new System.Drawing.Size(478, 422); + this.subtitleListView2.SubtitleFontBold = false; + this.subtitleListView2.SubtitleFontName = "Tahoma"; + this.subtitleListView2.SubtitleFontSize = 8; + this.subtitleListView2.TabIndex = 5; + this.subtitleListView2.UseCompatibleStateImageBehavior = false; + this.subtitleListView2.UseSyntaxColoring = true; + this.subtitleListView2.View = System.Windows.Forms.View.Details; + this.subtitleListView2.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView2SelectedIndexChanged); + this.subtitleListView2.DragDrop += new System.Windows.Forms.DragEventHandler(this.subtitleListView2_DragDrop); + this.subtitleListView2.DragEnter += new System.Windows.Forms.DragEventHandler(this.subtitleListView2_DragEnter); + // + // subtitleListView1 + // + this.subtitleListView1.AllowColumnReorder = true; + this.subtitleListView1.AllowDrop = true; + this.subtitleListView1.FirstVisibleIndex = -1; + this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.subtitleListView1.FullRowSelect = true; + this.subtitleListView1.GridLines = true; + this.subtitleListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.subtitleListView1.HideSelection = false; + this.subtitleListView1.Location = new System.Drawing.Point(8, 56); + this.subtitleListView1.Name = "subtitleListView1"; + this.subtitleListView1.OwnerDraw = true; + this.subtitleListView1.Size = new System.Drawing.Size(476, 422); + this.subtitleListView1.SubtitleFontBold = false; + this.subtitleListView1.SubtitleFontName = "Tahoma"; + this.subtitleListView1.SubtitleFontSize = 8; + this.subtitleListView1.TabIndex = 4; + this.subtitleListView1.UseCompatibleStateImageBehavior = false; + this.subtitleListView1.UseSyntaxColoring = true; + this.subtitleListView1.View = System.Windows.Forms.View.Details; + this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView1SelectedIndexChanged); + this.subtitleListView1.DragDrop += new System.Windows.Forms.DragEventHandler(this.subtitleListView1_DragDrop); + this.subtitleListView1.DragEnter += new System.Windows.Forms.DragEventHandler(this.subtitleListView1_DragEnter); + // + // checkBoxIgnoreFormatting + // + this.checkBoxIgnoreFormatting.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.checkBoxIgnoreFormatting.AutoSize = true; + this.checkBoxIgnoreFormatting.Location = new System.Drawing.Point(582, 552); + this.checkBoxIgnoreFormatting.Name = "checkBoxIgnoreFormatting"; + this.checkBoxIgnoreFormatting.Size = new System.Drawing.Size(111, 17); + this.checkBoxIgnoreFormatting.TabIndex = 14; + this.checkBoxIgnoreFormatting.Text = "Ignore formatting"; + this.checkBoxIgnoreFormatting.UseVisualStyleBackColor = true; + this.checkBoxIgnoreFormatting.CheckedChanged += new System.EventHandler(this.checkBoxIgnoreFormatting_CheckedChanged); + // + // buttonExport + // + this.buttonExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonExport.Location = new System.Drawing.Point(774, 561); + this.buttonExport.Name = "buttonExport"; + this.buttonExport.Size = new System.Drawing.Size(104, 23); + this.buttonExport.TabIndex = 20; + this.buttonExport.Text = "Export"; + this.buttonExport.UseVisualStyleBackColor = true; + this.buttonExport.Click += new System.EventHandler(this.buttonExport_Click); + // + // Compare + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(974, 591); + this.Controls.Add(this.buttonExport); + this.Controls.Add(this.checkBoxIgnoreFormatting); + this.Controls.Add(this.checkBoxIgnoreLineBreaks); + this.Controls.Add(this.checkBoxOnlyListDifferencesInText); + this.Controls.Add(this.checkBoxShowOnlyDifferences); + this.Controls.Add(this.richTextBox2); + this.Controls.Add(this.richTextBox1); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.buttonPreviousDifference); + this.Controls.Add(this.buttonNextDifference); + this.Controls.Add(this.buttonOpenSubtitle2); + this.Controls.Add(this.buttonOpenSubtitle1); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.subtitleListView2); + this.Controls.Add(this.labelSubtitle2); + this.Controls.Add(this.subtitleListView1); + this.Controls.Add(this.labelSubtitle1); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MinimumSize = new System.Drawing.Size(800, 400); + this.Name = "Compare"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Compare subtitles"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Compare_FormClosing); + this.Shown += new System.EventHandler(this.Compare_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Compare_KeyDown); + this.Resize += new System.EventHandler(this.Compare_Resize); + this.contextMenuStrip1.ResumeLayout(false); + this.contextMenuStrip2.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Label labelSubtitle2; + private SubtitleListView subtitleListView2; + private SubtitleListView subtitleListView1; + private System.Windows.Forms.Label labelSubtitle1; + private System.Windows.Forms.Button buttonOpenSubtitle1; + private System.Windows.Forms.Button buttonOpenSubtitle2; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Button buttonNextDifference; + private System.Windows.Forms.Button buttonPreviousDifference; + private System.Windows.Forms.Label labelStatus; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.RichTextBox richTextBox2; + private System.Windows.Forms.CheckBox checkBoxShowOnlyDifferences; + private System.Windows.Forms.CheckBox checkBoxOnlyListDifferencesInText; + private System.Windows.Forms.CheckBox checkBoxIgnoreLineBreaks; + private System.Windows.Forms.ToolTip toolTip1; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem copyTextToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip2; + private System.Windows.Forms.ToolStripMenuItem copyTextToolStripMenuItem1; + private System.Windows.Forms.CheckBox checkBoxIgnoreFormatting; + private System.Windows.Forms.Button buttonExport; + } } \ No newline at end of file diff --git a/src/Forms/Compare.cs b/src/ui/Forms/Compare.cs similarity index 97% rename from src/Forms/Compare.cs rename to src/ui/Forms/Compare.cs index 84b6cffa3..a69f0665a 100644 --- a/src/Forms/Compare.cs +++ b/src/ui/Forms/Compare.cs @@ -1,1156 +1,1156 @@ -using Nikse.SubtitleEdit.Controls; -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class Compare : Form - { - private Subtitle _subtitle1; - private Subtitle _subtitle2; - private List _differences; - private readonly Keys _mainGeneralGoToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle); - private readonly Keys _mainGeneralGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle); - private string _language1; - private readonly Color _backDifferenceColor = Color.FromArgb(255, 90, 90); - private readonly Color _foregroundDifferenceColor = Color.FromArgb(225, 0, 0); - private bool _loadingConfig = true; - - public Compare() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - labelSubtitle2.Text = string.Empty; - Text = Configuration.Settings.Language.CompareSubtitles.Title; - buttonPreviousDifference.Text = Configuration.Settings.Language.CompareSubtitles.PreviousDifference; - buttonNextDifference.Text = Configuration.Settings.Language.CompareSubtitles.NextDifference; - checkBoxShowOnlyDifferences.Text = Configuration.Settings.Language.CompareSubtitles.ShowOnlyDifferences; - checkBoxIgnoreLineBreaks.Text = Configuration.Settings.Language.CompareSubtitles.IgnoreLineBreaks; - checkBoxIgnoreFormatting.Text = Configuration.Settings.Language.CompareSubtitles.IgnoreFormatting; - checkBoxOnlyListDifferencesInText.Text = Configuration.Settings.Language.CompareSubtitles.OnlyLookForDifferencesInText; - buttonExport.Text = Configuration.Settings.Language.Statistics.Export; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - copyTextToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.Copy; - copyTextToolStripMenuItem1.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.Copy; - subtitleListView1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - subtitleListView2.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - UiUtil.InitializeSubtitleFont(subtitleListView1); - subtitleListView1.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); - subtitleListView1.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); - UiUtil.InitializeSubtitleFont(subtitleListView2); - subtitleListView2.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); - subtitleListView2.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); - UiUtil.FixLargeFonts(this, buttonOK); - subtitleListView1.UseSyntaxColoring = false; - subtitleListView2.UseSyntaxColoring = false; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - LoadConfigurations(); - buttonExport.Enabled = false; - } - - public void Initialize(Subtitle subtitle1, string subtitleFileName1, string title) - { - Compare_Resize(null, null); - labelStatus.Text = string.Empty; - _subtitle1 = subtitle1; - labelSubtitle1.Text = subtitleFileName1; - if (string.IsNullOrEmpty(subtitleFileName1)) - { - labelSubtitle1.Text = title; - } - - subtitleListView1.Fill(subtitle1); - - if (!string.IsNullOrEmpty(subtitleFileName1)) - { - try - { - openFileDialog1.InitialDirectory = Path.GetDirectoryName(subtitleFileName1); - } - catch - { - // ignored - } - } - subtitleListView1.SelectIndexAndEnsureVisible(0); - _language1 = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle1); - } - - public void Initialize(Subtitle subtitle1, string subtitleFileName1, Subtitle subtitle2, string subtitleFileName2) - { - Compare_Resize(null, null); - labelStatus.Text = string.Empty; - _subtitle1 = subtitle1; - labelSubtitle1.Text = subtitleFileName1; - - _subtitle2 = subtitle2; - labelSubtitle2.Text = subtitleFileName2; - - _language1 = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle1); - CompareSubtitles(); - - if (!string.IsNullOrEmpty(subtitleFileName1) && File.Exists(subtitleFileName1)) - { - openFileDialog1.InitialDirectory = Path.GetDirectoryName(subtitleFileName1); - } - - subtitleListView1.SelectIndexAndEnsureVisible(0); - subtitleListView2.SelectIndexAndEnsureVisible(0); - } - - private void ButtonOpenSubtitle1Click(object sender, EventArgs e) - { - openFileDialog1.FileName = string.Empty; - - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - if (FileUtil.IsVobSub(openFileDialog1.FileName) || FileUtil.IsBluRaySup(openFileDialog1.FileName)) - { - MessageBox.Show(Configuration.Settings.Language.CompareSubtitles.CannotCompareWithImageBasedSubtitles); - return; - } - _subtitle1 = LoadSubtitle(openFileDialog1.FileName); - - subtitleListView1.Fill(_subtitle1); - subtitleListView1.SelectIndexAndEnsureVisible(0); - subtitleListView2.SelectIndexAndEnsureVisible(0); - labelSubtitle1.Text = openFileDialog1.FileName; - _language1 = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle1); - if (_subtitle1.Paragraphs.Count > 0 && _subtitle2?.Paragraphs.Count > 0) - { - CompareSubtitles(); - } - } - } - - private static Subtitle LoadSubtitle(string fileName) - { - var subtitle = new Subtitle(); - var format = subtitle.LoadSubtitle(fileName, out _, null); - if (format == null) - { - foreach (var f in SubtitleFormat.GetBinaryFormats(false)) - { - if (f.IsMine(null, fileName)) - { - f.LoadSubtitle(subtitle, null, fileName); - break; // format found, exit the loop - } - } - } - return subtitle; - } - - private void ButtonOpenSubtitle2Click(object sender, EventArgs e) - { - openFileDialog1.FileName = string.Empty; - - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - if (FileUtil.IsVobSub(openFileDialog1.FileName) || FileUtil.IsBluRaySup(openFileDialog1.FileName)) - { - MessageBox.Show(Configuration.Settings.Language.CompareSubtitles.CannotCompareWithImageBasedSubtitles); - return; - } - - _subtitle2 = LoadSubtitle(openFileDialog1.FileName); - - subtitleListView2.Fill(_subtitle2); - subtitleListView1.SelectIndexAndEnsureVisible(0); - subtitleListView2.SelectIndexAndEnsureVisible(0); - labelSubtitle2.Text = openFileDialog1.FileName; - if (_subtitle2.Paragraphs.Count > 0 && _subtitle1?.Paragraphs.Count > 0) - { - CompareSubtitles(); - } - } - } - - private void CompareSubtitles() - { - if (_loadingConfig || _subtitle2 == null || _subtitle2.Paragraphs.Count == 0) - { - return; - } - buttonExport.Enabled = true; - timer1.Stop(); - var sub1 = new Subtitle(_subtitle1); - var sub2 = new Subtitle(_subtitle2); - - int index = 0; - Paragraph p1 = sub1.GetParagraphOrDefault(index); - Paragraph p2 = sub2.GetParagraphOrDefault(index); - int max = Math.Max(sub1.Paragraphs.Count, sub2.Paragraphs.Count); - while (index < max) - { - if (p1 != null && p2 != null && GetColumnsEqualExceptNumberAndDuration(p1, p2) == 0) - { - for (int i = index + 1; i < max; i++) - { - // Try to find atleast two matching properties - if (GetColumnsEqualExceptNumber(sub1.GetParagraphOrDefault(i), p2) > 1) - { - for (int j = index; j < i; j++) - { - sub2.Paragraphs.Insert(index++, new Paragraph()); - } - break; - } - if (GetColumnsEqualExceptNumber(p1, sub2.GetParagraphOrDefault(i)) > 1) - { - for (int j = index; j < i; j++) - { - sub1.Paragraphs.Insert(index++, new Paragraph()); - } - break; - } - } - } - index++; - p1 = sub1.GetParagraphOrDefault(index); - p2 = sub2.GetParagraphOrDefault(index); - } - - var minSub = sub1.Paragraphs.Count < sub2.Paragraphs.Count ? sub1 : sub2; - for (var idx = minSub.Paragraphs.Count; idx < max; idx++) - { - minSub.Paragraphs.Insert(idx, new Paragraph()); - } - - subtitleListView1.Fill(sub1); - subtitleListView2.Fill(sub2); - - // coloring + differences index list - _differences = new List(); - index = 0; - p1 = sub1.GetParagraphOrDefault(index); - p2 = sub2.GetParagraphOrDefault(index); - int totalWords = 0; - int wordsChanged = 0; - max = Math.Max(sub1.Paragraphs.Count, sub2.Paragraphs.Count); - int min = Math.Min(sub1.Paragraphs.Count, sub2.Paragraphs.Count); - var onlyTextDiff = checkBoxOnlyListDifferencesInText.Checked; - - if (onlyTextDiff) - { - while (index < min) - { - bool addIndexToDifferences = false; - Utilities.GetTotalAndChangedWords(p1.Text, p2.Text, ref totalWords, ref wordsChanged, checkBoxIgnoreLineBreaks.Checked, checkBoxIgnoreFormatting.Checked, ShouldBreakToLetter()); - if (p1.IsDefault) - { - addIndexToDifferences = true; - subtitleListView1.ColorOut(index, Color.Salmon); - } - else if (p2.IsDefault) - { - addIndexToDifferences = true; - subtitleListView2.ColorOut(index, Color.Salmon); - } - else if (FixWhitespace(p1.Text) != FixWhitespace(p2.Text)) - { - addIndexToDifferences = true; - subtitleListView1.SetBackgroundColor(index, Color.LightGreen, subtitleListView1.ColumnIndexText); - subtitleListView2.SetBackgroundColor(index, Color.LightGreen, subtitleListView2.ColumnIndexText); - } - if (addIndexToDifferences) - { - _differences.Add(index); - } - index++; - p1 = sub1.GetParagraphOrDefault(index); - p2 = sub2.GetParagraphOrDefault(index); - } - } - else - { - const double tolerance = 0.1; - while (index < min) - { - Utilities.GetTotalAndChangedWords(p1.Text, p2.Text, ref totalWords, ref wordsChanged, checkBoxIgnoreLineBreaks.Checked, checkBoxIgnoreFormatting.Checked, ShouldBreakToLetter()); - bool addIndexToDifferences = false; - if (p1.IsDefault) - { - addIndexToDifferences = true; - subtitleListView1.ColorOut(index, Color.Salmon); - } - else if (p2.IsDefault) - { - addIndexToDifferences = true; - subtitleListView2.ColorOut(index, Color.Salmon); - } - else - { - int columnsAlike = GetColumnsEqualExceptNumber(p1, p2); - // Not alike paragraphs - if (columnsAlike == 0) - { - addIndexToDifferences = true; - subtitleListView1.SetBackgroundColor(index, Color.LightGreen); - subtitleListView2.SetBackgroundColor(index, Color.LightGreen); - subtitleListView1.SetBackgroundColor(index, subtitleListView1.BackColor, subtitleListView1.ColumnIndexNumber); - subtitleListView2.SetBackgroundColor(index, subtitleListView2.BackColor, subtitleListView2.ColumnIndexNumber); - } - else if (columnsAlike < 4) - { - addIndexToDifferences = true; - // Start time - if (Math.Abs(p1.StartTime.TotalMilliseconds - p2.StartTime.TotalMilliseconds) > tolerance) - { - subtitleListView1.SetBackgroundColor(index, Color.LightGreen, subtitleListView1.ColumnIndexStart); - subtitleListView2.SetBackgroundColor(index, Color.LightGreen, subtitleListView2.ColumnIndexStart); - } - // End time - if (Math.Abs(p1.EndTime.TotalMilliseconds - p2.EndTime.TotalMilliseconds) > tolerance) - { - subtitleListView1.SetBackgroundColor(index, Color.LightGreen, subtitleListView1.ColumnIndexEnd); - subtitleListView2.SetBackgroundColor(index, Color.LightGreen, subtitleListView2.ColumnIndexEnd); - } - // Duration - if (Math.Abs(p1.Duration.TotalMilliseconds - p2.Duration.TotalMilliseconds) > tolerance) - { - subtitleListView1.SetBackgroundColor(index, Color.LightGreen, subtitleListView1.ColumnIndexDuration); - subtitleListView2.SetBackgroundColor(index, Color.LightGreen, subtitleListView2.ColumnIndexDuration); - } - // Text - if (FixWhitespace(p1.Text.Trim()) != FixWhitespace(p2.Text.Trim())) - { - subtitleListView1.SetBackgroundColor(index, Color.LightGreen, subtitleListView1.ColumnIndexText); - subtitleListView2.SetBackgroundColor(index, Color.LightGreen, subtitleListView2.ColumnIndexText); - } - } - // Number - if (p1.Number != p2.Number) - { - addIndexToDifferences = true; - subtitleListView1.SetBackgroundColor(index, Color.FromArgb(255, 200, 100), subtitleListView1.ColumnIndexNumber); - subtitleListView2.SetBackgroundColor(index, Color.FromArgb(255, 200, 100), subtitleListView2.ColumnIndexNumber); - } - } - if (addIndexToDifferences) - { - _differences.Add(index); - } - index++; - p1 = sub1.GetParagraphOrDefault(index); - p2 = sub2.GetParagraphOrDefault(index); - } - } - UpdatePreviousAndNextButtons(); - - if (max > min) // color extra lines as has-difference - { - var listView = subtitleListView1.Items.Count > subtitleListView2.Items.Count ? subtitleListView1 : subtitleListView2; - for (int i = min; i < max; i++) - { - if (!onlyTextDiff) - { - listView.SetBackgroundColor(i, Color.FromArgb(255, 200, 100), listView.ColumnIndexNumber); - listView.SetBackgroundColor(i, Color.LightGreen, listView.ColumnIndexStart); - listView.SetBackgroundColor(i, Color.LightGreen, listView.ColumnIndexEnd); - listView.SetBackgroundColor(i, Color.LightGreen, listView.ColumnIndexDuration); - } - listView.SetBackgroundColor(i, Color.LightGreen, listView.ColumnIndexText); - } - } - - if (_differences.Count >= min) - { - labelStatus.Text = Configuration.Settings.Language.CompareSubtitles.SubtitlesNotAlike; - labelStatus.Font = new Font(labelStatus.Font.FontFamily, labelStatus.Font.Size, FontStyle.Bold); - } - else - { - if (wordsChanged != totalWords && wordsChanged > 0) - { - string formatString = Configuration.Settings.Language.CompareSubtitles.XNumberOfDifferenceAndPercentChanged; - if (ShouldBreakToLetter()) - { - formatString = Configuration.Settings.Language.CompareSubtitles.XNumberOfDifferenceAndPercentLettersChanged; - } - - labelStatus.Text = string.Format(formatString, _differences.Count, wordsChanged * 100.00 / totalWords); - } - else - { - labelStatus.Text = string.Format(Configuration.Settings.Language.CompareSubtitles.XNumberOfDifference, _differences.Count); - } - labelStatus.Font = new Font(labelStatus.Font.FontFamily, labelStatus.Font.Size); - } - - if (checkBoxShowOnlyDifferences.Checked) - { // Remove all lines with no difference - subtitleListView1.BeginUpdate(); - subtitleListView2.BeginUpdate(); - if (_differences.Count < min) - { - for (index = Math.Max(subtitleListView1.Items.Count, subtitleListView2.Items.Count) - 1; index >= 0; index--) - { - if (!_differences.Contains(index)) - { - if (subtitleListView1.Items.Count > index) - { - subtitleListView1.Items.RemoveAt(index); - } - - if (subtitleListView2.Items.Count > index) - { - subtitleListView2.Items.RemoveAt(index); - } - } - } - } - subtitleListView1.EndUpdate(); - subtitleListView2.EndUpdate(); - _differences = new List(); - max = Math.Max(subtitleListView1.Items.Count, subtitleListView2.Items.Count); - for (index = 0; index < max; index++) - { - _differences.Add(index); - } - } - timer1.Start(); - subtitleListView1.FirstVisibleIndex = -1; - subtitleListView1.SelectIndexAndEnsureVisible(0); - } - - private bool ShouldBreakToLetter() => _language1 != null && (_language1 == "ja" || _language1 == "zh"); - - private string FixWhitespace(string p) - { - if (checkBoxIgnoreLineBreaks.Checked) - { - p = p.Replace(Environment.NewLine, " "); - while (p.Contains(" ")) - { - p = p.Replace(" ", " "); - } - } - - if (checkBoxIgnoreFormatting.Checked) - { - p = HtmlUtil.RemoveHtmlTags(p, true); - } - - return p; - } - - private int GetColumnsEqualExceptNumber(Paragraph p1, Paragraph p2) - { - if (p1 == null || p2 == null) - { - return 0; - } - - const double tolerance = 0.1; - - int columnsEqual = 0; - if (Math.Abs(p1.StartTime.TotalMilliseconds - p2.StartTime.TotalMilliseconds) < tolerance) - { - columnsEqual++; - } - - if (Math.Abs(p1.EndTime.TotalMilliseconds - p2.EndTime.TotalMilliseconds) < tolerance) - { - columnsEqual++; - } - - if (Math.Abs(p1.Duration.TotalMilliseconds - p2.Duration.TotalMilliseconds) < tolerance) - { - columnsEqual++; - } - - if (p1.Text.Trim() == p2.Text.Trim() || - checkBoxIgnoreFormatting.Checked && HtmlUtil.RemoveHtmlTags(p1.Text.Trim()) == HtmlUtil.RemoveHtmlTags(p2.Text.Trim())) - { - columnsEqual++; - } - - return columnsEqual; - } - - private int GetColumnsEqualExceptNumberAndDuration(Paragraph p1, Paragraph p2) - { - if (p1 == null || p2 == null) - { - return 0; - } - - const double tolerance = 0.1; - - int columnsEqual = 0; - if (Math.Abs(p1.StartTime.TotalMilliseconds - p2.StartTime.TotalMilliseconds) < tolerance) - { - columnsEqual++; - } - - if (Math.Abs(p1.EndTime.TotalMilliseconds - p2.EndTime.TotalMilliseconds) < tolerance) - { - columnsEqual++; - } - - if (p1.Text.Trim() == p2.Text.Trim() || - checkBoxIgnoreFormatting.Checked && HtmlUtil.RemoveHtmlTags(p1.Text.Trim()) == HtmlUtil.RemoveHtmlTags(p2.Text.Trim())) - { - columnsEqual++; - } - - return columnsEqual; - } - - private void ButtonOkClick(object sender, EventArgs e) - { - Close(); - } - - private void Compare_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - Close(); - } - else if (e.KeyCode == Keys.Enter && buttonNextDifference.Enabled) - { - ButtonNextDifferenceClick(null, null); - } - else if (e.KeyCode == Keys.Right && buttonNextDifference.Enabled) - { - ButtonNextDifferenceClick(null, null); - } - else if (e.KeyCode == Keys.Left && buttonPreviousDifference.Enabled) - { - ButtonPreviousDifferenceClick(null, null); - } - else if (_mainGeneralGoToNextSubtitle == e.KeyData || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)) - { - SubtitleListView lv = subtitleListView1; - if (subtitleListView2.Focused) - { - lv = subtitleListView2; - } - - int selectedIndex = 0; - if (lv.SelectedItems.Count > 0) - { - selectedIndex = lv.SelectedItems[0].Index; - selectedIndex++; - } - lv.SelectIndexAndEnsureVisible(selectedIndex); - } - else if (_mainGeneralGoToPrevSubtitle == e.KeyData || (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt)) - { - SubtitleListView lv = subtitleListView1; - if (subtitleListView2.Focused) - { - lv = subtitleListView2; - } - - int selectedIndex = 0; - if (lv.SelectedItems.Count > 0) - { - selectedIndex = lv.SelectedItems[0].Index; - selectedIndex--; - } - lv.SelectIndexAndEnsureVisible(selectedIndex); - } - } - - private void SubtitleListView1SelectedIndexChanged(object sender, EventArgs e) - { - UpdatePreviousAndNextButtons(); - ShowText(); - } - - private void ShowText() - { - string text1 = string.Empty; - string text2 = string.Empty; - - if (subtitleListView1.SelectedItems.Count == 1) - { - text1 = subtitleListView1.GetText(subtitleListView1.SelectedItems[0].Index); - - if (subtitleListView2.Items.Count > subtitleListView1.SelectedItems[0].Index) - { - text2 = subtitleListView2.GetText(subtitleListView1.SelectedItems[0].Index); - } - } - richTextBox1.Text = text1; - richTextBox2.Text = text2; - - // show diff - if (string.IsNullOrWhiteSpace(text1) || string.IsNullOrWhiteSpace(text2) || text1 == text2) - { - return; - } - - ShowTextDifference(); - } - - private void ShowTextDifference() - { - // from start - int minLength = Math.Min(richTextBox1.Text.Length, richTextBox2.Text.Length); - int startCharactersOk = 0; - for (int i = 0; i < minLength; i++) - { - if (richTextBox1.Text[i] == richTextBox2.Text[i]) - { - startCharactersOk++; - } - else - { - if (richTextBox1.Text.Length > i + 4 && richTextBox2.Text.Length > i + 4 && - richTextBox1.Text[i + 1] == richTextBox2.Text[i + 1] && - richTextBox1.Text[i + 2] == richTextBox2.Text[i + 2] && - richTextBox1.Text[i + 3] == richTextBox2.Text[i + 3] && - richTextBox1.Text[i + 4] == richTextBox2.Text[i + 4]) - { - startCharactersOk++; - - richTextBox1.SelectionStart = i; - richTextBox1.SelectionLength = 1; - richTextBox1.SelectionColor = _foregroundDifferenceColor; - if (" .,".Contains(richTextBox1.SelectedText)) - { - richTextBox1.SelectionBackColor = _backDifferenceColor; - richTextBox1.SelectionColor = DefaultForeColor; - } - - richTextBox2.SelectionStart = i; - richTextBox2.SelectionLength = 1; - richTextBox2.SelectionColor = _foregroundDifferenceColor; - if (" .,".Contains(richTextBox2.SelectedText)) - { - richTextBox2.SelectionBackColor = _backDifferenceColor; - richTextBox2.SelectionColor = DefaultForeColor; - } - } - else - { - break; - } - } - } - - int maxLength = Math.Max(richTextBox1.Text.Length, richTextBox2.Text.Length); - for (int i = startCharactersOk; i < maxLength; i++) - { - if (i < richTextBox1.Text.Length) - { - richTextBox1.SelectionStart = i; - richTextBox1.SelectionLength = 1; - richTextBox1.SelectionColor = _backDifferenceColor; - if (" .,".Contains(richTextBox1.SelectedText)) - { - richTextBox1.SelectionBackColor = _backDifferenceColor; - richTextBox1.SelectionColor = DefaultForeColor; - } - } - if (i < richTextBox2.Text.Length) - { - richTextBox2.SelectionStart = i; - richTextBox2.SelectionLength = 1; - richTextBox2.SelectionColor = _foregroundDifferenceColor; - if (" .,".Contains(richTextBox2.SelectedText)) - { - richTextBox2.SelectionBackColor = _backDifferenceColor; - richTextBox2.SelectionColor = DefaultForeColor; - } - } - } - - // from end - for (int i = 1; i < minLength; i++) - { - if (richTextBox1.Text.Length - i < startCharactersOk || richTextBox2.Text.Length - i < startCharactersOk) - { - break; - } - - if (richTextBox1.Text[richTextBox1.Text.Length - i] == richTextBox2.Text[richTextBox2.Text.Length - i]) - { - richTextBox1.SelectionStart = richTextBox1.Text.Length - i; - richTextBox1.SelectionLength = 1; - richTextBox1.SelectionColor = Color.Black; - richTextBox1.SelectionBackColor = richTextBox1.BackColor; - - richTextBox2.SelectionStart = richTextBox2.Text.Length - i; - richTextBox2.SelectionLength = 1; - richTextBox2.SelectionColor = Color.Black; - richTextBox2.SelectionBackColor = richTextBox1.BackColor; - } - else - { - break; - } - } - - // special situation - equal, but one has more chars - if (richTextBox1.Text.Length > richTextBox2.Text.Length) - { - if (richTextBox1.Text.StartsWith(richTextBox2.Text, StringComparison.Ordinal)) - { - richTextBox1.SelectionStart = richTextBox2.Text.Length; - richTextBox1.SelectionLength = richTextBox1.Text.Length - richTextBox2.Text.Length; - richTextBox1.SelectionBackColor = _backDifferenceColor; - } - } - else if (richTextBox2.Text.Length > richTextBox1.Text.Length) - { - if (richTextBox2.Text.StartsWith(richTextBox1.Text, StringComparison.Ordinal)) - { - richTextBox2.SelectionStart = richTextBox1.Text.Length; - richTextBox2.SelectionLength = richTextBox2.Text.Length - richTextBox1.Text.Length; - richTextBox2.SelectionColor = _foregroundDifferenceColor; - } - } - } - - private void UpdatePreviousAndNextButtons() - { - if (subtitleListView1.Items.Count > 0 && subtitleListView2.Items.Count > 0 && - _differences != null && _differences.Count > 0) - { - if (subtitleListView1.SelectedItems.Count == 0) - { - buttonPreviousDifference.Enabled = false; - buttonNextDifference.Enabled = true; - } - else - { - int index = subtitleListView1.SelectedItems[0].Index; - buttonPreviousDifference.Enabled = _differences[0] < index; - buttonNextDifference.Enabled = _differences[_differences.Count - 1] > index; - } - } - else - { - buttonPreviousDifference.Enabled = false; - buttonNextDifference.Enabled = false; - } - } - - private void SubtitleListView2SelectedIndexChanged(object sender, EventArgs e) - { - UpdatePreviousAndNextButtons(); - } - - private void Compare_Resize(object sender, EventArgs e) - { - subtitleListView1.Width = (Width / 2) - 20; - - subtitleListView2.Left = (Width / 2) - 3; - subtitleListView2.Width = (Width / 2) - 20; - labelSubtitle2.Left = subtitleListView2.Left; - buttonOpenSubtitle2.Left = subtitleListView2.Left; - - subtitleListView1.Height = Height - (subtitleListView1.Top + 140); - subtitleListView2.Height = Height - (subtitleListView2.Top + 140); - - richTextBox1.Width = subtitleListView1.Width; - richTextBox2.Width = subtitleListView2.Width; - richTextBox2.Left = subtitleListView2.Left; - } - - private void ButtonPreviousDifferenceClick(object sender, EventArgs e) - { - if (_differences != null && _differences.Count > 0) - { - if (subtitleListView1.SelectedItems.Count == 0) - { - subtitleListView1.SelectIndexAndEnsureVisible(_differences[0]); - } - else - { - for (int i = subtitleListView1.SelectedItems[0].Index - 1; i >= 0; i--) - { - if (_differences.Contains(i)) - { - subtitleListView1.SelectIndexAndEnsureVisible(i - 2); - subtitleListView1.SelectIndexAndEnsureVisible(i + 2); - subtitleListView1.SelectIndexAndEnsureVisible(i); - break; - } - } - } - } - } - - private void ButtonNextDifferenceClick(object sender, EventArgs e) - { - if (_differences != null && _differences.Count > 0) - { - if (subtitleListView1.SelectedItems.Count == 0) - { - subtitleListView1.SelectIndexAndEnsureVisible(_differences[0]); - } - else - { - for (int i = subtitleListView1.SelectedItems[0].Index + 1; i < subtitleListView1.Items.Count; i++) - { - if (_differences.Contains(i)) - { - subtitleListView1.SelectIndexAndEnsureVisible(i - 2); - subtitleListView1.SelectIndexAndEnsureVisible(i + 2); - subtitleListView1.SelectIndexAndEnsureVisible(i); - subtitleListView1.Focus(); - break; - } - } - } - } - } - - private void Timer1Tick(object sender, EventArgs e) - { - if (subtitleListView1.TopItem == null || subtitleListView2.TopItem == null) - { - return; - } - - char activeListView; - var p = PointToClient(MousePosition); - if (p.X >= subtitleListView1.Left && p.X <= subtitleListView1.Left + subtitleListView1.Width + 2) - { - activeListView = 'L'; - } - else if (p.X >= subtitleListView2.Left && p.X <= subtitleListView2.Left + subtitleListView2.Width + 2) - { - activeListView = 'R'; - } - else - { - return; - } - - if (subtitleListView1.SelectedItems.Count > 0 && activeListView == 'L') - { - if (subtitleListView2.SelectedItems.Count > 0 && - subtitleListView1.SelectedItems[0].Index == subtitleListView2.SelectedItems[0].Index) - { - if (subtitleListView1.TopItem.Index != subtitleListView2.TopItem.Index && - subtitleListView2.Items.Count > subtitleListView1.TopItem.Index) - { - subtitleListView2.TopItem = subtitleListView2.Items[subtitleListView1.TopItem.Index]; - } - - return; - } - subtitleListView2.SelectedIndexChanged -= SubtitleListView2SelectedIndexChanged; - subtitleListView2.SelectIndexAndEnsureVisible(subtitleListView1.SelectedItems[0].Index); - if (subtitleListView1.TopItem.Index != subtitleListView2.TopItem.Index && - subtitleListView2.Items.Count > subtitleListView1.TopItem.Index) - { - subtitleListView2.TopItem = subtitleListView2.Items[subtitleListView1.TopItem.Index]; - } - - subtitleListView2.SelectedIndexChanged += SubtitleListView2SelectedIndexChanged; - } - else if (subtitleListView2.SelectedItems.Count > 0 && activeListView == 'R') - { - if (subtitleListView1.SelectedItems.Count > 0 && - subtitleListView2.SelectedItems[0].Index == subtitleListView1.SelectedItems[0].Index) - { - if (subtitleListView2.TopItem.Index != subtitleListView1.TopItem.Index && - subtitleListView1.Items.Count > subtitleListView2.TopItem.Index) - { - subtitleListView1.TopItem = subtitleListView1.Items[subtitleListView2.TopItem.Index]; - } - - return; - } - subtitleListView1.SelectIndexAndEnsureVisible(subtitleListView2.SelectedItems[0].Index); - if (subtitleListView2.TopItem.Index != subtitleListView1.TopItem.Index && - subtitleListView1.Items.Count > subtitleListView2.TopItem.Index) - { - subtitleListView1.TopItem = subtitleListView1.Items[subtitleListView2.TopItem.Index]; - } - } - } - - private void Compare_FormClosing(object sender, FormClosingEventArgs e) - { - timer1.Stop(); - SaveConfigurations(); - } - - private void checkBoxShowOnlyDifferences_CheckedChanged(object sender, EventArgs e) - { - CompareSubtitles(); - } - - private void checkBoxOnlyListDifferencesInText_CheckedChanged(object sender, EventArgs e) - { - CompareSubtitles(); - } - - private void checkBoxIgnoreLineBreaks_CheckedChanged(object sender, EventArgs e) - { - CompareSubtitles(); - } - - private void labelSubtitle1_MouseHover(object sender, EventArgs e) - { - ShowTip(labelSubtitle1); - } - - private void labelSubtitle2_MouseHover(object sender, EventArgs e) - { - ShowTip(labelSubtitle2); - } - - private void ShowTip(Control control) - { - var text = control.Text; - if (!string.IsNullOrEmpty(text)) - { - try - { - text = Path.GetFileName(text); - } - catch - { - // not a path - } - toolTip1.Show(text, control); - } - } - - private void subtitleListView1_DragEnter(object sender, DragEventArgs e) - { - VerifyDragEnter(e); - } - - private void subtitleListView2_DragEnter(object sender, DragEventArgs e) - { - VerifyDragEnter(e); - } - - private static void VerifyDragEnter(DragEventArgs e) - { - e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; - } - - private void subtitleListView1_DragDrop(object sender, DragEventArgs e) - { - VerifyDragDrop((sender as ListView), e); - } - - private void subtitleListView2_DragDrop(object sender, DragEventArgs e) - { - VerifyDragDrop((sender as ListView), e); - } - - private void VerifyDragDrop(ListView listView, DragEventArgs e) - { - var files = e.Data.GetData(DataFormats.FileDrop) as string[]; - if (files == null) - { - return; - } - if (files.Length > 1) - { - MessageBox.Show(Configuration.Settings.Language.Main.DropOnlyOneFile, - string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - string filePath = files[0]; - if (FileUtil.IsDirectory(filePath)) - { - MessageBox.Show(Configuration.Settings.Language.Main.ErrorDirectoryDropNotAllowed, - string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - - var listExt = new List(); - foreach (var s in UiUtil.SubtitleExtensionFilter.Value.Split(new[] { '*' }, StringSplitOptions.RemoveEmptyEntries)) - { - if (s.EndsWith(';')) - { - listExt.Add(s.Trim(';')); - } - } - if (!listExt.Contains(Path.GetExtension(filePath))) - { - return; - } - - if (FileUtil.IsVobSub(filePath) || FileUtil.IsBluRaySup(filePath)) - { - MessageBox.Show(Configuration.Settings.Language.CompareSubtitles.CannotCompareWithImageBasedSubtitles); - return; - } - - if (listView.Name == "subtitleListView1") - { - _subtitle1 = new Subtitle(); - _subtitle1.LoadSubtitle(filePath, out _, null); - subtitleListView1.Fill(_subtitle1); - subtitleListView1.SelectIndexAndEnsureVisible(0); - subtitleListView2.SelectIndexAndEnsureVisible(0); - labelSubtitle1.Text = filePath; - _language1 = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle1); - if (_subtitle1.Paragraphs.Count > 0) - { - CompareSubtitles(); - } - } - else - { - _subtitle2 = new Subtitle(); - _subtitle2.LoadSubtitle(filePath, out _, null); - subtitleListView2.Fill(_subtitle2); - subtitleListView1.SelectIndexAndEnsureVisible(0); - subtitleListView2.SelectIndexAndEnsureVisible(0); - labelSubtitle2.Text = filePath; - if (_subtitle2.Paragraphs.Count > 0) - { - CompareSubtitles(); - } - } - } - - private void copyTextToolStripMenuItem_Click(object sender, EventArgs e) - { - CopyTextToClipboard(richTextBox1); - } - - private void copyTextToolStripMenuItem1_Click(object sender, EventArgs e) - { - CopyTextToClipboard(richTextBox2); - } - - private static void CopyTextToClipboard(RichTextBox sender) - { - if (string.IsNullOrWhiteSpace(sender.Text)) - { - return; - } - - if (sender.SelectedText.Length > 0) - { - Clipboard.SetText(sender.SelectedText); - return; - } - Clipboard.SetText(sender.Text); - } - - private void LoadConfigurations() - { - var config = Configuration.Settings.Compare; - checkBoxShowOnlyDifferences.Checked = config.ShowOnlyDifferences; - checkBoxOnlyListDifferencesInText.Checked = config.OnlyLookForDifferenceInText; - checkBoxIgnoreLineBreaks.Checked = config.IgnoreLineBreaks; - checkBoxIgnoreFormatting.Checked = config.IgnoreFormatting; - _loadingConfig = false; - } - - private void SaveConfigurations() - { - var config = Configuration.Settings.Compare; - config.ShowOnlyDifferences = checkBoxShowOnlyDifferences.Checked; - config.OnlyLookForDifferenceInText = checkBoxOnlyListDifferencesInText.Checked; - config.IgnoreLineBreaks = checkBoxIgnoreLineBreaks.Checked; - config.IgnoreFormatting = checkBoxIgnoreFormatting.Checked; - } - - private void checkBoxIgnoreFormatting_CheckedChanged(object sender, EventArgs e) - { - CompareSubtitles(); - } - - private void Compare_Shown(object sender, EventArgs e) - { - Activate(); - } - - private void buttonExport_Click(object sender, EventArgs e) - { - using (var saveFile = new SaveFileDialog { Filter = "Html files|*.html" }) - { - if (saveFile.ShowDialog() == DialogResult.OK) - { - string fileName = saveFile.FileName; - var sb = new StringBuilder(); - sb.AppendLine(""); - sb.AppendLine(""); - sb.AppendLine(" "); - sb.AppendLine(" Subtitle Edit compare"); - sb.AppendLine(" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - sb.AppendLine("

Subtitle Edit compare

"); - sb.AppendLine(" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - for (int i = 0; i < subtitleListView1.Items.Count; i++) - { - var itemLeft = subtitleListView1.Items[i].Tag as Paragraph; - var itemRight = subtitleListView2.Items[i].Tag as Paragraph; - if (itemLeft != null && itemRight != null) - { - sb.AppendLine(" "); - sb.AppendLine(" " + GetHtmlText(itemLeft, itemLeft.Number.ToString()) + ""); - sb.AppendLine(" " + GetHtmlText(itemLeft, itemLeft.StartTime.ToShortDisplayString()) + ""); - if (subtitleListView1.ColumnIndexEnd >= 0) - { - sb.AppendLine(" " + GetHtmlText(itemLeft, itemLeft.EndTime.ToShortDisplayString()) + ""); - } - sb.AppendLine(" " + GetHtmlText(itemLeft, itemLeft.Text) + ""); - sb.AppendLine(" "); - sb.AppendLine(" " + GetHtmlText(itemRight, itemRight.Number.ToString()) + ""); - sb.AppendLine(" " + GetHtmlText(itemRight, itemRight.StartTime.ToShortDisplayString()) + ""); - if (subtitleListView2.ColumnIndexEnd >= 0) - { - sb.AppendLine(" " + GetHtmlText(itemRight, itemRight.EndTime.ToShortDisplayString()) + ""); - } - sb.AppendLine(" " + GetHtmlText(itemRight, itemRight.Text) + ""); - sb.AppendLine(" "); - } - } - sb.AppendLine(" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - sb.AppendLine("
" + labelSubtitle1.Text + " " + labelSubtitle2.Text + "
 

" + labelStatus.Text + "
"); - sb.AppendLine(" "); - sb.AppendLine(""); - File.WriteAllText(fileName, sb.ToString()); - } - } - } - - private string GetHtmlText(Paragraph p, string text) - { - if (p.IsDefault) - { - return string.Empty; - } - return HtmlUtil.EncodeNamed(text); - } - - private string GetHtmlBackgroundColor(ListViewItem.ListViewSubItem item) - { - if (item.BackColor == DefaultBackColor) - { - return string.Empty; - } - return " style='background-color:" + ColorTranslator.ToHtml(item.BackColor) + "'"; - } - } -} +using Nikse.SubtitleEdit.Controls; +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class Compare : Form + { + private Subtitle _subtitle1; + private Subtitle _subtitle2; + private List _differences; + private readonly Keys _mainGeneralGoToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle); + private readonly Keys _mainGeneralGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle); + private string _language1; + private readonly Color _backDifferenceColor = Color.FromArgb(255, 90, 90); + private readonly Color _foregroundDifferenceColor = Color.FromArgb(225, 0, 0); + private bool _loadingConfig = true; + + public Compare() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + labelSubtitle2.Text = string.Empty; + Text = Configuration.Settings.Language.CompareSubtitles.Title; + buttonPreviousDifference.Text = Configuration.Settings.Language.CompareSubtitles.PreviousDifference; + buttonNextDifference.Text = Configuration.Settings.Language.CompareSubtitles.NextDifference; + checkBoxShowOnlyDifferences.Text = Configuration.Settings.Language.CompareSubtitles.ShowOnlyDifferences; + checkBoxIgnoreLineBreaks.Text = Configuration.Settings.Language.CompareSubtitles.IgnoreLineBreaks; + checkBoxIgnoreFormatting.Text = Configuration.Settings.Language.CompareSubtitles.IgnoreFormatting; + checkBoxOnlyListDifferencesInText.Text = Configuration.Settings.Language.CompareSubtitles.OnlyLookForDifferencesInText; + buttonExport.Text = Configuration.Settings.Language.Statistics.Export; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + copyTextToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.Copy; + copyTextToolStripMenuItem1.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.Copy; + subtitleListView1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + subtitleListView2.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + UiUtil.InitializeSubtitleFont(subtitleListView1); + subtitleListView1.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); + subtitleListView1.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); + UiUtil.InitializeSubtitleFont(subtitleListView2); + subtitleListView2.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); + subtitleListView2.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); + UiUtil.FixLargeFonts(this, buttonOK); + subtitleListView1.UseSyntaxColoring = false; + subtitleListView2.UseSyntaxColoring = false; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + LoadConfigurations(); + buttonExport.Enabled = false; + } + + public void Initialize(Subtitle subtitle1, string subtitleFileName1, string title) + { + Compare_Resize(null, null); + labelStatus.Text = string.Empty; + _subtitle1 = subtitle1; + labelSubtitle1.Text = subtitleFileName1; + if (string.IsNullOrEmpty(subtitleFileName1)) + { + labelSubtitle1.Text = title; + } + + subtitleListView1.Fill(subtitle1); + + if (!string.IsNullOrEmpty(subtitleFileName1)) + { + try + { + openFileDialog1.InitialDirectory = Path.GetDirectoryName(subtitleFileName1); + } + catch + { + // ignored + } + } + subtitleListView1.SelectIndexAndEnsureVisible(0); + _language1 = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle1); + } + + public void Initialize(Subtitle subtitle1, string subtitleFileName1, Subtitle subtitle2, string subtitleFileName2) + { + Compare_Resize(null, null); + labelStatus.Text = string.Empty; + _subtitle1 = subtitle1; + labelSubtitle1.Text = subtitleFileName1; + + _subtitle2 = subtitle2; + labelSubtitle2.Text = subtitleFileName2; + + _language1 = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle1); + CompareSubtitles(); + + if (!string.IsNullOrEmpty(subtitleFileName1) && File.Exists(subtitleFileName1)) + { + openFileDialog1.InitialDirectory = Path.GetDirectoryName(subtitleFileName1); + } + + subtitleListView1.SelectIndexAndEnsureVisible(0); + subtitleListView2.SelectIndexAndEnsureVisible(0); + } + + private void ButtonOpenSubtitle1Click(object sender, EventArgs e) + { + openFileDialog1.FileName = string.Empty; + + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + if (FileUtil.IsVobSub(openFileDialog1.FileName) || FileUtil.IsBluRaySup(openFileDialog1.FileName)) + { + MessageBox.Show(Configuration.Settings.Language.CompareSubtitles.CannotCompareWithImageBasedSubtitles); + return; + } + _subtitle1 = LoadSubtitle(openFileDialog1.FileName); + + subtitleListView1.Fill(_subtitle1); + subtitleListView1.SelectIndexAndEnsureVisible(0); + subtitleListView2.SelectIndexAndEnsureVisible(0); + labelSubtitle1.Text = openFileDialog1.FileName; + _language1 = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle1); + if (_subtitle1.Paragraphs.Count > 0 && _subtitle2?.Paragraphs.Count > 0) + { + CompareSubtitles(); + } + } + } + + private static Subtitle LoadSubtitle(string fileName) + { + var subtitle = new Subtitle(); + var format = subtitle.LoadSubtitle(fileName, out _, null); + if (format == null) + { + foreach (var f in SubtitleFormat.GetBinaryFormats(false)) + { + if (f.IsMine(null, fileName)) + { + f.LoadSubtitle(subtitle, null, fileName); + break; // format found, exit the loop + } + } + } + return subtitle; + } + + private void ButtonOpenSubtitle2Click(object sender, EventArgs e) + { + openFileDialog1.FileName = string.Empty; + + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + if (FileUtil.IsVobSub(openFileDialog1.FileName) || FileUtil.IsBluRaySup(openFileDialog1.FileName)) + { + MessageBox.Show(Configuration.Settings.Language.CompareSubtitles.CannotCompareWithImageBasedSubtitles); + return; + } + + _subtitle2 = LoadSubtitle(openFileDialog1.FileName); + + subtitleListView2.Fill(_subtitle2); + subtitleListView1.SelectIndexAndEnsureVisible(0); + subtitleListView2.SelectIndexAndEnsureVisible(0); + labelSubtitle2.Text = openFileDialog1.FileName; + if (_subtitle2.Paragraphs.Count > 0 && _subtitle1?.Paragraphs.Count > 0) + { + CompareSubtitles(); + } + } + } + + private void CompareSubtitles() + { + if (_loadingConfig || _subtitle2 == null || _subtitle2.Paragraphs.Count == 0) + { + return; + } + buttonExport.Enabled = true; + timer1.Stop(); + var sub1 = new Subtitle(_subtitle1); + var sub2 = new Subtitle(_subtitle2); + + int index = 0; + Paragraph p1 = sub1.GetParagraphOrDefault(index); + Paragraph p2 = sub2.GetParagraphOrDefault(index); + int max = Math.Max(sub1.Paragraphs.Count, sub2.Paragraphs.Count); + while (index < max) + { + if (p1 != null && p2 != null && GetColumnsEqualExceptNumberAndDuration(p1, p2) == 0) + { + for (int i = index + 1; i < max; i++) + { + // Try to find atleast two matching properties + if (GetColumnsEqualExceptNumber(sub1.GetParagraphOrDefault(i), p2) > 1) + { + for (int j = index; j < i; j++) + { + sub2.Paragraphs.Insert(index++, new Paragraph()); + } + break; + } + if (GetColumnsEqualExceptNumber(p1, sub2.GetParagraphOrDefault(i)) > 1) + { + for (int j = index; j < i; j++) + { + sub1.Paragraphs.Insert(index++, new Paragraph()); + } + break; + } + } + } + index++; + p1 = sub1.GetParagraphOrDefault(index); + p2 = sub2.GetParagraphOrDefault(index); + } + + var minSub = sub1.Paragraphs.Count < sub2.Paragraphs.Count ? sub1 : sub2; + for (var idx = minSub.Paragraphs.Count; idx < max; idx++) + { + minSub.Paragraphs.Insert(idx, new Paragraph()); + } + + subtitleListView1.Fill(sub1); + subtitleListView2.Fill(sub2); + + // coloring + differences index list + _differences = new List(); + index = 0; + p1 = sub1.GetParagraphOrDefault(index); + p2 = sub2.GetParagraphOrDefault(index); + int totalWords = 0; + int wordsChanged = 0; + max = Math.Max(sub1.Paragraphs.Count, sub2.Paragraphs.Count); + int min = Math.Min(sub1.Paragraphs.Count, sub2.Paragraphs.Count); + var onlyTextDiff = checkBoxOnlyListDifferencesInText.Checked; + + if (onlyTextDiff) + { + while (index < min) + { + bool addIndexToDifferences = false; + Utilities.GetTotalAndChangedWords(p1.Text, p2.Text, ref totalWords, ref wordsChanged, checkBoxIgnoreLineBreaks.Checked, checkBoxIgnoreFormatting.Checked, ShouldBreakToLetter()); + if (p1.IsDefault) + { + addIndexToDifferences = true; + subtitleListView1.ColorOut(index, Color.Salmon); + } + else if (p2.IsDefault) + { + addIndexToDifferences = true; + subtitleListView2.ColorOut(index, Color.Salmon); + } + else if (FixWhitespace(p1.Text) != FixWhitespace(p2.Text)) + { + addIndexToDifferences = true; + subtitleListView1.SetBackgroundColor(index, Color.LightGreen, subtitleListView1.ColumnIndexText); + subtitleListView2.SetBackgroundColor(index, Color.LightGreen, subtitleListView2.ColumnIndexText); + } + if (addIndexToDifferences) + { + _differences.Add(index); + } + index++; + p1 = sub1.GetParagraphOrDefault(index); + p2 = sub2.GetParagraphOrDefault(index); + } + } + else + { + const double tolerance = 0.1; + while (index < min) + { + Utilities.GetTotalAndChangedWords(p1.Text, p2.Text, ref totalWords, ref wordsChanged, checkBoxIgnoreLineBreaks.Checked, checkBoxIgnoreFormatting.Checked, ShouldBreakToLetter()); + bool addIndexToDifferences = false; + if (p1.IsDefault) + { + addIndexToDifferences = true; + subtitleListView1.ColorOut(index, Color.Salmon); + } + else if (p2.IsDefault) + { + addIndexToDifferences = true; + subtitleListView2.ColorOut(index, Color.Salmon); + } + else + { + int columnsAlike = GetColumnsEqualExceptNumber(p1, p2); + // Not alike paragraphs + if (columnsAlike == 0) + { + addIndexToDifferences = true; + subtitleListView1.SetBackgroundColor(index, Color.LightGreen); + subtitleListView2.SetBackgroundColor(index, Color.LightGreen); + subtitleListView1.SetBackgroundColor(index, subtitleListView1.BackColor, subtitleListView1.ColumnIndexNumber); + subtitleListView2.SetBackgroundColor(index, subtitleListView2.BackColor, subtitleListView2.ColumnIndexNumber); + } + else if (columnsAlike < 4) + { + addIndexToDifferences = true; + // Start time + if (Math.Abs(p1.StartTime.TotalMilliseconds - p2.StartTime.TotalMilliseconds) > tolerance) + { + subtitleListView1.SetBackgroundColor(index, Color.LightGreen, subtitleListView1.ColumnIndexStart); + subtitleListView2.SetBackgroundColor(index, Color.LightGreen, subtitleListView2.ColumnIndexStart); + } + // End time + if (Math.Abs(p1.EndTime.TotalMilliseconds - p2.EndTime.TotalMilliseconds) > tolerance) + { + subtitleListView1.SetBackgroundColor(index, Color.LightGreen, subtitleListView1.ColumnIndexEnd); + subtitleListView2.SetBackgroundColor(index, Color.LightGreen, subtitleListView2.ColumnIndexEnd); + } + // Duration + if (Math.Abs(p1.Duration.TotalMilliseconds - p2.Duration.TotalMilliseconds) > tolerance) + { + subtitleListView1.SetBackgroundColor(index, Color.LightGreen, subtitleListView1.ColumnIndexDuration); + subtitleListView2.SetBackgroundColor(index, Color.LightGreen, subtitleListView2.ColumnIndexDuration); + } + // Text + if (FixWhitespace(p1.Text.Trim()) != FixWhitespace(p2.Text.Trim())) + { + subtitleListView1.SetBackgroundColor(index, Color.LightGreen, subtitleListView1.ColumnIndexText); + subtitleListView2.SetBackgroundColor(index, Color.LightGreen, subtitleListView2.ColumnIndexText); + } + } + // Number + if (p1.Number != p2.Number) + { + addIndexToDifferences = true; + subtitleListView1.SetBackgroundColor(index, Color.FromArgb(255, 200, 100), subtitleListView1.ColumnIndexNumber); + subtitleListView2.SetBackgroundColor(index, Color.FromArgb(255, 200, 100), subtitleListView2.ColumnIndexNumber); + } + } + if (addIndexToDifferences) + { + _differences.Add(index); + } + index++; + p1 = sub1.GetParagraphOrDefault(index); + p2 = sub2.GetParagraphOrDefault(index); + } + } + UpdatePreviousAndNextButtons(); + + if (max > min) // color extra lines as has-difference + { + var listView = subtitleListView1.Items.Count > subtitleListView2.Items.Count ? subtitleListView1 : subtitleListView2; + for (int i = min; i < max; i++) + { + if (!onlyTextDiff) + { + listView.SetBackgroundColor(i, Color.FromArgb(255, 200, 100), listView.ColumnIndexNumber); + listView.SetBackgroundColor(i, Color.LightGreen, listView.ColumnIndexStart); + listView.SetBackgroundColor(i, Color.LightGreen, listView.ColumnIndexEnd); + listView.SetBackgroundColor(i, Color.LightGreen, listView.ColumnIndexDuration); + } + listView.SetBackgroundColor(i, Color.LightGreen, listView.ColumnIndexText); + } + } + + if (_differences.Count >= min) + { + labelStatus.Text = Configuration.Settings.Language.CompareSubtitles.SubtitlesNotAlike; + labelStatus.Font = new Font(labelStatus.Font.FontFamily, labelStatus.Font.Size, FontStyle.Bold); + } + else + { + if (wordsChanged != totalWords && wordsChanged > 0) + { + string formatString = Configuration.Settings.Language.CompareSubtitles.XNumberOfDifferenceAndPercentChanged; + if (ShouldBreakToLetter()) + { + formatString = Configuration.Settings.Language.CompareSubtitles.XNumberOfDifferenceAndPercentLettersChanged; + } + + labelStatus.Text = string.Format(formatString, _differences.Count, wordsChanged * 100.00 / totalWords); + } + else + { + labelStatus.Text = string.Format(Configuration.Settings.Language.CompareSubtitles.XNumberOfDifference, _differences.Count); + } + labelStatus.Font = new Font(labelStatus.Font.FontFamily, labelStatus.Font.Size); + } + + if (checkBoxShowOnlyDifferences.Checked) + { // Remove all lines with no difference + subtitleListView1.BeginUpdate(); + subtitleListView2.BeginUpdate(); + if (_differences.Count < min) + { + for (index = Math.Max(subtitleListView1.Items.Count, subtitleListView2.Items.Count) - 1; index >= 0; index--) + { + if (!_differences.Contains(index)) + { + if (subtitleListView1.Items.Count > index) + { + subtitleListView1.Items.RemoveAt(index); + } + + if (subtitleListView2.Items.Count > index) + { + subtitleListView2.Items.RemoveAt(index); + } + } + } + } + subtitleListView1.EndUpdate(); + subtitleListView2.EndUpdate(); + _differences = new List(); + max = Math.Max(subtitleListView1.Items.Count, subtitleListView2.Items.Count); + for (index = 0; index < max; index++) + { + _differences.Add(index); + } + } + timer1.Start(); + subtitleListView1.FirstVisibleIndex = -1; + subtitleListView1.SelectIndexAndEnsureVisible(0); + } + + private bool ShouldBreakToLetter() => _language1 != null && (_language1 == "ja" || _language1 == "zh"); + + private string FixWhitespace(string p) + { + if (checkBoxIgnoreLineBreaks.Checked) + { + p = p.Replace(Environment.NewLine, " "); + while (p.Contains(" ")) + { + p = p.Replace(" ", " "); + } + } + + if (checkBoxIgnoreFormatting.Checked) + { + p = HtmlUtil.RemoveHtmlTags(p, true); + } + + return p; + } + + private int GetColumnsEqualExceptNumber(Paragraph p1, Paragraph p2) + { + if (p1 == null || p2 == null) + { + return 0; + } + + const double tolerance = 0.1; + + int columnsEqual = 0; + if (Math.Abs(p1.StartTime.TotalMilliseconds - p2.StartTime.TotalMilliseconds) < tolerance) + { + columnsEqual++; + } + + if (Math.Abs(p1.EndTime.TotalMilliseconds - p2.EndTime.TotalMilliseconds) < tolerance) + { + columnsEqual++; + } + + if (Math.Abs(p1.Duration.TotalMilliseconds - p2.Duration.TotalMilliseconds) < tolerance) + { + columnsEqual++; + } + + if (p1.Text.Trim() == p2.Text.Trim() || + checkBoxIgnoreFormatting.Checked && HtmlUtil.RemoveHtmlTags(p1.Text.Trim()) == HtmlUtil.RemoveHtmlTags(p2.Text.Trim())) + { + columnsEqual++; + } + + return columnsEqual; + } + + private int GetColumnsEqualExceptNumberAndDuration(Paragraph p1, Paragraph p2) + { + if (p1 == null || p2 == null) + { + return 0; + } + + const double tolerance = 0.1; + + int columnsEqual = 0; + if (Math.Abs(p1.StartTime.TotalMilliseconds - p2.StartTime.TotalMilliseconds) < tolerance) + { + columnsEqual++; + } + + if (Math.Abs(p1.EndTime.TotalMilliseconds - p2.EndTime.TotalMilliseconds) < tolerance) + { + columnsEqual++; + } + + if (p1.Text.Trim() == p2.Text.Trim() || + checkBoxIgnoreFormatting.Checked && HtmlUtil.RemoveHtmlTags(p1.Text.Trim()) == HtmlUtil.RemoveHtmlTags(p2.Text.Trim())) + { + columnsEqual++; + } + + return columnsEqual; + } + + private void ButtonOkClick(object sender, EventArgs e) + { + Close(); + } + + private void Compare_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + Close(); + } + else if (e.KeyCode == Keys.Enter && buttonNextDifference.Enabled) + { + ButtonNextDifferenceClick(null, null); + } + else if (e.KeyCode == Keys.Right && buttonNextDifference.Enabled) + { + ButtonNextDifferenceClick(null, null); + } + else if (e.KeyCode == Keys.Left && buttonPreviousDifference.Enabled) + { + ButtonPreviousDifferenceClick(null, null); + } + else if (_mainGeneralGoToNextSubtitle == e.KeyData || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)) + { + SubtitleListView lv = subtitleListView1; + if (subtitleListView2.Focused) + { + lv = subtitleListView2; + } + + int selectedIndex = 0; + if (lv.SelectedItems.Count > 0) + { + selectedIndex = lv.SelectedItems[0].Index; + selectedIndex++; + } + lv.SelectIndexAndEnsureVisible(selectedIndex); + } + else if (_mainGeneralGoToPrevSubtitle == e.KeyData || (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt)) + { + SubtitleListView lv = subtitleListView1; + if (subtitleListView2.Focused) + { + lv = subtitleListView2; + } + + int selectedIndex = 0; + if (lv.SelectedItems.Count > 0) + { + selectedIndex = lv.SelectedItems[0].Index; + selectedIndex--; + } + lv.SelectIndexAndEnsureVisible(selectedIndex); + } + } + + private void SubtitleListView1SelectedIndexChanged(object sender, EventArgs e) + { + UpdatePreviousAndNextButtons(); + ShowText(); + } + + private void ShowText() + { + string text1 = string.Empty; + string text2 = string.Empty; + + if (subtitleListView1.SelectedItems.Count == 1) + { + text1 = subtitleListView1.GetText(subtitleListView1.SelectedItems[0].Index); + + if (subtitleListView2.Items.Count > subtitleListView1.SelectedItems[0].Index) + { + text2 = subtitleListView2.GetText(subtitleListView1.SelectedItems[0].Index); + } + } + richTextBox1.Text = text1; + richTextBox2.Text = text2; + + // show diff + if (string.IsNullOrWhiteSpace(text1) || string.IsNullOrWhiteSpace(text2) || text1 == text2) + { + return; + } + + ShowTextDifference(); + } + + private void ShowTextDifference() + { + // from start + int minLength = Math.Min(richTextBox1.Text.Length, richTextBox2.Text.Length); + int startCharactersOk = 0; + for (int i = 0; i < minLength; i++) + { + if (richTextBox1.Text[i] == richTextBox2.Text[i]) + { + startCharactersOk++; + } + else + { + if (richTextBox1.Text.Length > i + 4 && richTextBox2.Text.Length > i + 4 && + richTextBox1.Text[i + 1] == richTextBox2.Text[i + 1] && + richTextBox1.Text[i + 2] == richTextBox2.Text[i + 2] && + richTextBox1.Text[i + 3] == richTextBox2.Text[i + 3] && + richTextBox1.Text[i + 4] == richTextBox2.Text[i + 4]) + { + startCharactersOk++; + + richTextBox1.SelectionStart = i; + richTextBox1.SelectionLength = 1; + richTextBox1.SelectionColor = _foregroundDifferenceColor; + if (" .,".Contains(richTextBox1.SelectedText)) + { + richTextBox1.SelectionBackColor = _backDifferenceColor; + richTextBox1.SelectionColor = DefaultForeColor; + } + + richTextBox2.SelectionStart = i; + richTextBox2.SelectionLength = 1; + richTextBox2.SelectionColor = _foregroundDifferenceColor; + if (" .,".Contains(richTextBox2.SelectedText)) + { + richTextBox2.SelectionBackColor = _backDifferenceColor; + richTextBox2.SelectionColor = DefaultForeColor; + } + } + else + { + break; + } + } + } + + int maxLength = Math.Max(richTextBox1.Text.Length, richTextBox2.Text.Length); + for (int i = startCharactersOk; i < maxLength; i++) + { + if (i < richTextBox1.Text.Length) + { + richTextBox1.SelectionStart = i; + richTextBox1.SelectionLength = 1; + richTextBox1.SelectionColor = _backDifferenceColor; + if (" .,".Contains(richTextBox1.SelectedText)) + { + richTextBox1.SelectionBackColor = _backDifferenceColor; + richTextBox1.SelectionColor = DefaultForeColor; + } + } + if (i < richTextBox2.Text.Length) + { + richTextBox2.SelectionStart = i; + richTextBox2.SelectionLength = 1; + richTextBox2.SelectionColor = _foregroundDifferenceColor; + if (" .,".Contains(richTextBox2.SelectedText)) + { + richTextBox2.SelectionBackColor = _backDifferenceColor; + richTextBox2.SelectionColor = DefaultForeColor; + } + } + } + + // from end + for (int i = 1; i < minLength; i++) + { + if (richTextBox1.Text.Length - i < startCharactersOk || richTextBox2.Text.Length - i < startCharactersOk) + { + break; + } + + if (richTextBox1.Text[richTextBox1.Text.Length - i] == richTextBox2.Text[richTextBox2.Text.Length - i]) + { + richTextBox1.SelectionStart = richTextBox1.Text.Length - i; + richTextBox1.SelectionLength = 1; + richTextBox1.SelectionColor = Color.Black; + richTextBox1.SelectionBackColor = richTextBox1.BackColor; + + richTextBox2.SelectionStart = richTextBox2.Text.Length - i; + richTextBox2.SelectionLength = 1; + richTextBox2.SelectionColor = Color.Black; + richTextBox2.SelectionBackColor = richTextBox1.BackColor; + } + else + { + break; + } + } + + // special situation - equal, but one has more chars + if (richTextBox1.Text.Length > richTextBox2.Text.Length) + { + if (richTextBox1.Text.StartsWith(richTextBox2.Text, StringComparison.Ordinal)) + { + richTextBox1.SelectionStart = richTextBox2.Text.Length; + richTextBox1.SelectionLength = richTextBox1.Text.Length - richTextBox2.Text.Length; + richTextBox1.SelectionBackColor = _backDifferenceColor; + } + } + else if (richTextBox2.Text.Length > richTextBox1.Text.Length) + { + if (richTextBox2.Text.StartsWith(richTextBox1.Text, StringComparison.Ordinal)) + { + richTextBox2.SelectionStart = richTextBox1.Text.Length; + richTextBox2.SelectionLength = richTextBox2.Text.Length - richTextBox1.Text.Length; + richTextBox2.SelectionColor = _foregroundDifferenceColor; + } + } + } + + private void UpdatePreviousAndNextButtons() + { + if (subtitleListView1.Items.Count > 0 && subtitleListView2.Items.Count > 0 && + _differences != null && _differences.Count > 0) + { + if (subtitleListView1.SelectedItems.Count == 0) + { + buttonPreviousDifference.Enabled = false; + buttonNextDifference.Enabled = true; + } + else + { + int index = subtitleListView1.SelectedItems[0].Index; + buttonPreviousDifference.Enabled = _differences[0] < index; + buttonNextDifference.Enabled = _differences[_differences.Count - 1] > index; + } + } + else + { + buttonPreviousDifference.Enabled = false; + buttonNextDifference.Enabled = false; + } + } + + private void SubtitleListView2SelectedIndexChanged(object sender, EventArgs e) + { + UpdatePreviousAndNextButtons(); + } + + private void Compare_Resize(object sender, EventArgs e) + { + subtitleListView1.Width = (Width / 2) - 20; + + subtitleListView2.Left = (Width / 2) - 3; + subtitleListView2.Width = (Width / 2) - 20; + labelSubtitle2.Left = subtitleListView2.Left; + buttonOpenSubtitle2.Left = subtitleListView2.Left; + + subtitleListView1.Height = Height - (subtitleListView1.Top + 140); + subtitleListView2.Height = Height - (subtitleListView2.Top + 140); + + richTextBox1.Width = subtitleListView1.Width; + richTextBox2.Width = subtitleListView2.Width; + richTextBox2.Left = subtitleListView2.Left; + } + + private void ButtonPreviousDifferenceClick(object sender, EventArgs e) + { + if (_differences != null && _differences.Count > 0) + { + if (subtitleListView1.SelectedItems.Count == 0) + { + subtitleListView1.SelectIndexAndEnsureVisible(_differences[0]); + } + else + { + for (int i = subtitleListView1.SelectedItems[0].Index - 1; i >= 0; i--) + { + if (_differences.Contains(i)) + { + subtitleListView1.SelectIndexAndEnsureVisible(i - 2); + subtitleListView1.SelectIndexAndEnsureVisible(i + 2); + subtitleListView1.SelectIndexAndEnsureVisible(i); + break; + } + } + } + } + } + + private void ButtonNextDifferenceClick(object sender, EventArgs e) + { + if (_differences != null && _differences.Count > 0) + { + if (subtitleListView1.SelectedItems.Count == 0) + { + subtitleListView1.SelectIndexAndEnsureVisible(_differences[0]); + } + else + { + for (int i = subtitleListView1.SelectedItems[0].Index + 1; i < subtitleListView1.Items.Count; i++) + { + if (_differences.Contains(i)) + { + subtitleListView1.SelectIndexAndEnsureVisible(i - 2); + subtitleListView1.SelectIndexAndEnsureVisible(i + 2); + subtitleListView1.SelectIndexAndEnsureVisible(i); + subtitleListView1.Focus(); + break; + } + } + } + } + } + + private void Timer1Tick(object sender, EventArgs e) + { + if (subtitleListView1.TopItem == null || subtitleListView2.TopItem == null) + { + return; + } + + char activeListView; + var p = PointToClient(MousePosition); + if (p.X >= subtitleListView1.Left && p.X <= subtitleListView1.Left + subtitleListView1.Width + 2) + { + activeListView = 'L'; + } + else if (p.X >= subtitleListView2.Left && p.X <= subtitleListView2.Left + subtitleListView2.Width + 2) + { + activeListView = 'R'; + } + else + { + return; + } + + if (subtitleListView1.SelectedItems.Count > 0 && activeListView == 'L') + { + if (subtitleListView2.SelectedItems.Count > 0 && + subtitleListView1.SelectedItems[0].Index == subtitleListView2.SelectedItems[0].Index) + { + if (subtitleListView1.TopItem.Index != subtitleListView2.TopItem.Index && + subtitleListView2.Items.Count > subtitleListView1.TopItem.Index) + { + subtitleListView2.TopItem = subtitleListView2.Items[subtitleListView1.TopItem.Index]; + } + + return; + } + subtitleListView2.SelectedIndexChanged -= SubtitleListView2SelectedIndexChanged; + subtitleListView2.SelectIndexAndEnsureVisible(subtitleListView1.SelectedItems[0].Index); + if (subtitleListView1.TopItem.Index != subtitleListView2.TopItem.Index && + subtitleListView2.Items.Count > subtitleListView1.TopItem.Index) + { + subtitleListView2.TopItem = subtitleListView2.Items[subtitleListView1.TopItem.Index]; + } + + subtitleListView2.SelectedIndexChanged += SubtitleListView2SelectedIndexChanged; + } + else if (subtitleListView2.SelectedItems.Count > 0 && activeListView == 'R') + { + if (subtitleListView1.SelectedItems.Count > 0 && + subtitleListView2.SelectedItems[0].Index == subtitleListView1.SelectedItems[0].Index) + { + if (subtitleListView2.TopItem.Index != subtitleListView1.TopItem.Index && + subtitleListView1.Items.Count > subtitleListView2.TopItem.Index) + { + subtitleListView1.TopItem = subtitleListView1.Items[subtitleListView2.TopItem.Index]; + } + + return; + } + subtitleListView1.SelectIndexAndEnsureVisible(subtitleListView2.SelectedItems[0].Index); + if (subtitleListView2.TopItem.Index != subtitleListView1.TopItem.Index && + subtitleListView1.Items.Count > subtitleListView2.TopItem.Index) + { + subtitleListView1.TopItem = subtitleListView1.Items[subtitleListView2.TopItem.Index]; + } + } + } + + private void Compare_FormClosing(object sender, FormClosingEventArgs e) + { + timer1.Stop(); + SaveConfigurations(); + } + + private void checkBoxShowOnlyDifferences_CheckedChanged(object sender, EventArgs e) + { + CompareSubtitles(); + } + + private void checkBoxOnlyListDifferencesInText_CheckedChanged(object sender, EventArgs e) + { + CompareSubtitles(); + } + + private void checkBoxIgnoreLineBreaks_CheckedChanged(object sender, EventArgs e) + { + CompareSubtitles(); + } + + private void labelSubtitle1_MouseHover(object sender, EventArgs e) + { + ShowTip(labelSubtitle1); + } + + private void labelSubtitle2_MouseHover(object sender, EventArgs e) + { + ShowTip(labelSubtitle2); + } + + private void ShowTip(Control control) + { + var text = control.Text; + if (!string.IsNullOrEmpty(text)) + { + try + { + text = Path.GetFileName(text); + } + catch + { + // not a path + } + toolTip1.Show(text, control); + } + } + + private void subtitleListView1_DragEnter(object sender, DragEventArgs e) + { + VerifyDragEnter(e); + } + + private void subtitleListView2_DragEnter(object sender, DragEventArgs e) + { + VerifyDragEnter(e); + } + + private static void VerifyDragEnter(DragEventArgs e) + { + e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; + } + + private void subtitleListView1_DragDrop(object sender, DragEventArgs e) + { + VerifyDragDrop((sender as ListView), e); + } + + private void subtitleListView2_DragDrop(object sender, DragEventArgs e) + { + VerifyDragDrop((sender as ListView), e); + } + + private void VerifyDragDrop(ListView listView, DragEventArgs e) + { + var files = e.Data.GetData(DataFormats.FileDrop) as string[]; + if (files == null) + { + return; + } + if (files.Length > 1) + { + MessageBox.Show(Configuration.Settings.Language.Main.DropOnlyOneFile, + string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + string filePath = files[0]; + if (FileUtil.IsDirectory(filePath)) + { + MessageBox.Show(Configuration.Settings.Language.Main.ErrorDirectoryDropNotAllowed, + string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + var listExt = new List(); + foreach (var s in UiUtil.SubtitleExtensionFilter.Value.Split(new[] { '*' }, StringSplitOptions.RemoveEmptyEntries)) + { + if (s.EndsWith(';')) + { + listExt.Add(s.Trim(';')); + } + } + if (!listExt.Contains(Path.GetExtension(filePath))) + { + return; + } + + if (FileUtil.IsVobSub(filePath) || FileUtil.IsBluRaySup(filePath)) + { + MessageBox.Show(Configuration.Settings.Language.CompareSubtitles.CannotCompareWithImageBasedSubtitles); + return; + } + + if (listView.Name == "subtitleListView1") + { + _subtitle1 = new Subtitle(); + _subtitle1.LoadSubtitle(filePath, out _, null); + subtitleListView1.Fill(_subtitle1); + subtitleListView1.SelectIndexAndEnsureVisible(0); + subtitleListView2.SelectIndexAndEnsureVisible(0); + labelSubtitle1.Text = filePath; + _language1 = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle1); + if (_subtitle1.Paragraphs.Count > 0) + { + CompareSubtitles(); + } + } + else + { + _subtitle2 = new Subtitle(); + _subtitle2.LoadSubtitle(filePath, out _, null); + subtitleListView2.Fill(_subtitle2); + subtitleListView1.SelectIndexAndEnsureVisible(0); + subtitleListView2.SelectIndexAndEnsureVisible(0); + labelSubtitle2.Text = filePath; + if (_subtitle2.Paragraphs.Count > 0) + { + CompareSubtitles(); + } + } + } + + private void copyTextToolStripMenuItem_Click(object sender, EventArgs e) + { + CopyTextToClipboard(richTextBox1); + } + + private void copyTextToolStripMenuItem1_Click(object sender, EventArgs e) + { + CopyTextToClipboard(richTextBox2); + } + + private static void CopyTextToClipboard(RichTextBox sender) + { + if (string.IsNullOrWhiteSpace(sender.Text)) + { + return; + } + + if (sender.SelectedText.Length > 0) + { + Clipboard.SetText(sender.SelectedText); + return; + } + Clipboard.SetText(sender.Text); + } + + private void LoadConfigurations() + { + var config = Configuration.Settings.Compare; + checkBoxShowOnlyDifferences.Checked = config.ShowOnlyDifferences; + checkBoxOnlyListDifferencesInText.Checked = config.OnlyLookForDifferenceInText; + checkBoxIgnoreLineBreaks.Checked = config.IgnoreLineBreaks; + checkBoxIgnoreFormatting.Checked = config.IgnoreFormatting; + _loadingConfig = false; + } + + private void SaveConfigurations() + { + var config = Configuration.Settings.Compare; + config.ShowOnlyDifferences = checkBoxShowOnlyDifferences.Checked; + config.OnlyLookForDifferenceInText = checkBoxOnlyListDifferencesInText.Checked; + config.IgnoreLineBreaks = checkBoxIgnoreLineBreaks.Checked; + config.IgnoreFormatting = checkBoxIgnoreFormatting.Checked; + } + + private void checkBoxIgnoreFormatting_CheckedChanged(object sender, EventArgs e) + { + CompareSubtitles(); + } + + private void Compare_Shown(object sender, EventArgs e) + { + Activate(); + } + + private void buttonExport_Click(object sender, EventArgs e) + { + using (var saveFile = new SaveFileDialog { Filter = "Html files|*.html" }) + { + if (saveFile.ShowDialog() == DialogResult.OK) + { + string fileName = saveFile.FileName; + var sb = new StringBuilder(); + sb.AppendLine(""); + sb.AppendLine(""); + sb.AppendLine(" "); + sb.AppendLine(" Subtitle Edit compare"); + sb.AppendLine(" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + sb.AppendLine("

Subtitle Edit compare

"); + sb.AppendLine(" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + for (int i = 0; i < subtitleListView1.Items.Count; i++) + { + var itemLeft = subtitleListView1.Items[i].Tag as Paragraph; + var itemRight = subtitleListView2.Items[i].Tag as Paragraph; + if (itemLeft != null && itemRight != null) + { + sb.AppendLine(" "); + sb.AppendLine(" " + GetHtmlText(itemLeft, itemLeft.Number.ToString()) + ""); + sb.AppendLine(" " + GetHtmlText(itemLeft, itemLeft.StartTime.ToShortDisplayString()) + ""); + if (subtitleListView1.ColumnIndexEnd >= 0) + { + sb.AppendLine(" " + GetHtmlText(itemLeft, itemLeft.EndTime.ToShortDisplayString()) + ""); + } + sb.AppendLine(" " + GetHtmlText(itemLeft, itemLeft.Text) + ""); + sb.AppendLine(" "); + sb.AppendLine(" " + GetHtmlText(itemRight, itemRight.Number.ToString()) + ""); + sb.AppendLine(" " + GetHtmlText(itemRight, itemRight.StartTime.ToShortDisplayString()) + ""); + if (subtitleListView2.ColumnIndexEnd >= 0) + { + sb.AppendLine(" " + GetHtmlText(itemRight, itemRight.EndTime.ToShortDisplayString()) + ""); + } + sb.AppendLine(" " + GetHtmlText(itemRight, itemRight.Text) + ""); + sb.AppendLine(" "); + } + } + sb.AppendLine(" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + sb.AppendLine("
" + labelSubtitle1.Text + " " + labelSubtitle2.Text + "
 

" + labelStatus.Text + "
"); + sb.AppendLine(" "); + sb.AppendLine(""); + File.WriteAllText(fileName, sb.ToString()); + } + } + } + + private string GetHtmlText(Paragraph p, string text) + { + if (p.IsDefault) + { + return string.Empty; + } + return HtmlUtil.EncodeNamed(text); + } + + private string GetHtmlBackgroundColor(ListViewItem.ListViewSubItem item) + { + if (item.BackColor == DefaultBackColor) + { + return string.Empty; + } + return " style='background-color:" + ColorTranslator.ToHtml(item.BackColor) + "'"; + } + } +} diff --git a/src/Forms/Compare.resx b/src/ui/Forms/Compare.resx similarity index 98% rename from src/Forms/Compare.resx rename to src/ui/Forms/Compare.resx index 3683cb38d..56ba09b05 100644 --- a/src/Forms/Compare.resx +++ b/src/ui/Forms/Compare.resx @@ -1,135 +1,135 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 147, 17 - - - 331, 17 - - - 486, 17 - - - 234, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 147, 17 + + + 331, 17 + + + 486, 17 + + + 234, 17 + \ No newline at end of file diff --git a/src/Forms/DCinema/DCinemaPropertiesInterop.Designer.cs b/src/ui/Forms/DCinema/DCinemaPropertiesInterop.Designer.cs similarity index 100% rename from src/Forms/DCinema/DCinemaPropertiesInterop.Designer.cs rename to src/ui/Forms/DCinema/DCinemaPropertiesInterop.Designer.cs diff --git a/src/Forms/DCinema/DCinemaPropertiesInterop.cs b/src/ui/Forms/DCinema/DCinemaPropertiesInterop.cs similarity index 100% rename from src/Forms/DCinema/DCinemaPropertiesInterop.cs rename to src/ui/Forms/DCinema/DCinemaPropertiesInterop.cs diff --git a/src/Forms/DCinema/DCinemaPropertiesInterop.resx b/src/ui/Forms/DCinema/DCinemaPropertiesInterop.resx similarity index 100% rename from src/Forms/DCinema/DCinemaPropertiesInterop.resx rename to src/ui/Forms/DCinema/DCinemaPropertiesInterop.resx diff --git a/src/Forms/DCinema/DCinemaPropertiesSmpte.Designer.cs b/src/ui/Forms/DCinema/DCinemaPropertiesSmpte.Designer.cs similarity index 100% rename from src/Forms/DCinema/DCinemaPropertiesSmpte.Designer.cs rename to src/ui/Forms/DCinema/DCinemaPropertiesSmpte.Designer.cs diff --git a/src/Forms/DCinema/DCinemaPropertiesSmpte.cs b/src/ui/Forms/DCinema/DCinemaPropertiesSmpte.cs similarity index 100% rename from src/Forms/DCinema/DCinemaPropertiesSmpte.cs rename to src/ui/Forms/DCinema/DCinemaPropertiesSmpte.cs diff --git a/src/Forms/DCinema/DCinemaPropertiesSmpte.resx b/src/ui/Forms/DCinema/DCinemaPropertiesSmpte.resx similarity index 100% rename from src/Forms/DCinema/DCinemaPropertiesSmpte.resx rename to src/ui/Forms/DCinema/DCinemaPropertiesSmpte.resx diff --git a/src/Forms/DialogDoNotShowAgain.Designer.cs b/src/ui/Forms/DialogDoNotShowAgain.Designer.cs similarity index 100% rename from src/Forms/DialogDoNotShowAgain.Designer.cs rename to src/ui/Forms/DialogDoNotShowAgain.Designer.cs diff --git a/src/Forms/DialogDoNotShowAgain.cs b/src/ui/Forms/DialogDoNotShowAgain.cs similarity index 100% rename from src/Forms/DialogDoNotShowAgain.cs rename to src/ui/Forms/DialogDoNotShowAgain.cs diff --git a/src/Forms/ImportFinalDraft.resx b/src/ui/Forms/DialogDoNotShowAgain.resx similarity index 100% rename from src/Forms/ImportFinalDraft.resx rename to src/ui/Forms/DialogDoNotShowAgain.resx diff --git a/src/Forms/DoNotBreakAfterListEdit.Designer.cs b/src/ui/Forms/DoNotBreakAfterListEdit.Designer.cs similarity index 98% rename from src/Forms/DoNotBreakAfterListEdit.Designer.cs rename to src/ui/Forms/DoNotBreakAfterListEdit.Designer.cs index 0252200b5..29f7a0ab0 100644 --- a/src/Forms/DoNotBreakAfterListEdit.Designer.cs +++ b/src/ui/Forms/DoNotBreakAfterListEdit.Designer.cs @@ -1,214 +1,214 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class DoNotBreakAfterListEdit - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBoxNamesIgonoreLists = new System.Windows.Forms.GroupBox(); - this.radioButtonRegEx = new System.Windows.Forms.RadioButton(); - this.radioButtonText = new System.Windows.Forms.RadioButton(); - this.buttonRemoveNoBreakAfter = new System.Windows.Forms.Button(); - this.listBoxNoBreakAfter = new System.Windows.Forms.ListBox(); - this.textBoxNoBreakAfter = new System.Windows.Forms.TextBox(); - this.buttonAddNoBreakAfter = new System.Windows.Forms.Button(); - this.comboBoxDictionaries = new System.Windows.Forms.ComboBox(); - this.labelLanguage = new System.Windows.Forms.Label(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.groupBoxNamesIgonoreLists.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxNamesIgonoreLists - // - this.groupBoxNamesIgonoreLists.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxNamesIgonoreLists.Controls.Add(this.radioButtonRegEx); - this.groupBoxNamesIgonoreLists.Controls.Add(this.radioButtonText); - this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonRemoveNoBreakAfter); - this.groupBoxNamesIgonoreLists.Controls.Add(this.listBoxNoBreakAfter); - this.groupBoxNamesIgonoreLists.Controls.Add(this.textBoxNoBreakAfter); - this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonAddNoBreakAfter); - this.groupBoxNamesIgonoreLists.Location = new System.Drawing.Point(12, 54); - this.groupBoxNamesIgonoreLists.Name = "groupBoxNamesIgonoreLists"; - this.groupBoxNamesIgonoreLists.Size = new System.Drawing.Size(313, 304); - this.groupBoxNamesIgonoreLists.TabIndex = 2; - this.groupBoxNamesIgonoreLists.TabStop = false; - // - // radioButtonRegEx - // - this.radioButtonRegEx.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.radioButtonRegEx.AutoSize = true; - this.radioButtonRegEx.Location = new System.Drawing.Point(83, 279); - this.radioButtonRegEx.Name = "radioButtonRegEx"; - this.radioButtonRegEx.Size = new System.Drawing.Size(115, 17); - this.radioButtonRegEx.TabIndex = 5; - this.radioButtonRegEx.Text = "Regular expression"; - this.radioButtonRegEx.UseVisualStyleBackColor = true; - this.radioButtonRegEx.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // - // radioButtonText - // - this.radioButtonText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.radioButtonText.AutoSize = true; - this.radioButtonText.Checked = true; - this.radioButtonText.Location = new System.Drawing.Point(6, 279); - this.radioButtonText.Name = "radioButtonText"; - this.radioButtonText.Size = new System.Drawing.Size(46, 17); - this.radioButtonText.TabIndex = 4; - this.radioButtonText.TabStop = true; - this.radioButtonText.Text = "Text"; - this.radioButtonText.UseVisualStyleBackColor = true; - this.radioButtonText.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // - // buttonRemoveNoBreakAfter - // - this.buttonRemoveNoBreakAfter.Location = new System.Drawing.Point(230, 19); - this.buttonRemoveNoBreakAfter.Name = "buttonRemoveNoBreakAfter"; - this.buttonRemoveNoBreakAfter.Size = new System.Drawing.Size(75, 23); - this.buttonRemoveNoBreakAfter.TabIndex = 1; - this.buttonRemoveNoBreakAfter.Text = "Remove"; - this.buttonRemoveNoBreakAfter.UseVisualStyleBackColor = true; - this.buttonRemoveNoBreakAfter.Click += new System.EventHandler(this.buttonRemoveNameEtc_Click); - // - // listBoxNoBreakAfter - // - this.listBoxNoBreakAfter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.listBoxNoBreakAfter.FormattingEnabled = true; - this.listBoxNoBreakAfter.Location = new System.Drawing.Point(6, 19); - this.listBoxNoBreakAfter.Name = "listBoxNoBreakAfter"; - this.listBoxNoBreakAfter.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this.listBoxNoBreakAfter.Size = new System.Drawing.Size(218, 225); - this.listBoxNoBreakAfter.TabIndex = 0; - this.listBoxNoBreakAfter.SelectedIndexChanged += new System.EventHandler(this.listBoxNames_SelectedIndexChanged); - // - // textBoxNoBreakAfter - // - this.textBoxNoBreakAfter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.textBoxNoBreakAfter.Location = new System.Drawing.Point(6, 250); - this.textBoxNoBreakAfter.Name = "textBoxNoBreakAfter"; - this.textBoxNoBreakAfter.Size = new System.Drawing.Size(218, 20); - this.textBoxNoBreakAfter.TabIndex = 2; - this.textBoxNoBreakAfter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxNoBreakAfter_KeyDown); - // - // buttonAddNoBreakAfter - // - this.buttonAddNoBreakAfter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonAddNoBreakAfter.Location = new System.Drawing.Point(230, 248); - this.buttonAddNoBreakAfter.Name = "buttonAddNoBreakAfter"; - this.buttonAddNoBreakAfter.Size = new System.Drawing.Size(75, 23); - this.buttonAddNoBreakAfter.TabIndex = 3; - this.buttonAddNoBreakAfter.Text = "Add"; - this.buttonAddNoBreakAfter.UseVisualStyleBackColor = true; - this.buttonAddNoBreakAfter.Click += new System.EventHandler(this.buttonAddNames_Click); - // - // comboBoxDictionaries - // - this.comboBoxDictionaries.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxDictionaries.FormattingEnabled = true; - this.comboBoxDictionaries.Location = new System.Drawing.Point(12, 27); - this.comboBoxDictionaries.Name = "comboBoxDictionaries"; - this.comboBoxDictionaries.Size = new System.Drawing.Size(224, 21); - this.comboBoxDictionaries.TabIndex = 1; - this.comboBoxDictionaries.SelectedIndexChanged += new System.EventHandler(this.comboBoxDictionaries_SelectedIndexChanged); - // - // labelLanguage - // - this.labelLanguage.AutoSize = true; - this.labelLanguage.Location = new System.Drawing.Point(12, 11); - this.labelLanguage.Name = "labelLanguage"; - this.labelLanguage.Size = new System.Drawing.Size(55, 13); - this.labelLanguage.TabIndex = 0; - this.labelLanguage.Text = "Language"; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(166, 369); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(250, 369); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // DoNotBreakAfterListEdit - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(337, 402); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.comboBoxDictionaries); - this.Controls.Add(this.labelLanguage); - this.Controls.Add(this.groupBoxNamesIgonoreLists); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(350, 340); - this.Name = "DoNotBreakAfterListEdit"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Do not break after list - edit"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DoNotBreakAfterListEdit_KeyDown); - this.groupBoxNamesIgonoreLists.ResumeLayout(false); - this.groupBoxNamesIgonoreLists.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxNamesIgonoreLists; - private System.Windows.Forms.Button buttonRemoveNoBreakAfter; - private System.Windows.Forms.ListBox listBoxNoBreakAfter; - private System.Windows.Forms.TextBox textBoxNoBreakAfter; - private System.Windows.Forms.Button buttonAddNoBreakAfter; - private System.Windows.Forms.ComboBox comboBoxDictionaries; - private System.Windows.Forms.Label labelLanguage; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.RadioButton radioButtonRegEx; - private System.Windows.Forms.RadioButton radioButtonText; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class DoNotBreakAfterListEdit + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBoxNamesIgonoreLists = new System.Windows.Forms.GroupBox(); + this.radioButtonRegEx = new System.Windows.Forms.RadioButton(); + this.radioButtonText = new System.Windows.Forms.RadioButton(); + this.buttonRemoveNoBreakAfter = new System.Windows.Forms.Button(); + this.listBoxNoBreakAfter = new System.Windows.Forms.ListBox(); + this.textBoxNoBreakAfter = new System.Windows.Forms.TextBox(); + this.buttonAddNoBreakAfter = new System.Windows.Forms.Button(); + this.comboBoxDictionaries = new System.Windows.Forms.ComboBox(); + this.labelLanguage = new System.Windows.Forms.Label(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxNamesIgonoreLists.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxNamesIgonoreLists + // + this.groupBoxNamesIgonoreLists.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxNamesIgonoreLists.Controls.Add(this.radioButtonRegEx); + this.groupBoxNamesIgonoreLists.Controls.Add(this.radioButtonText); + this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonRemoveNoBreakAfter); + this.groupBoxNamesIgonoreLists.Controls.Add(this.listBoxNoBreakAfter); + this.groupBoxNamesIgonoreLists.Controls.Add(this.textBoxNoBreakAfter); + this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonAddNoBreakAfter); + this.groupBoxNamesIgonoreLists.Location = new System.Drawing.Point(12, 54); + this.groupBoxNamesIgonoreLists.Name = "groupBoxNamesIgonoreLists"; + this.groupBoxNamesIgonoreLists.Size = new System.Drawing.Size(313, 304); + this.groupBoxNamesIgonoreLists.TabIndex = 2; + this.groupBoxNamesIgonoreLists.TabStop = false; + // + // radioButtonRegEx + // + this.radioButtonRegEx.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.radioButtonRegEx.AutoSize = true; + this.radioButtonRegEx.Location = new System.Drawing.Point(83, 279); + this.radioButtonRegEx.Name = "radioButtonRegEx"; + this.radioButtonRegEx.Size = new System.Drawing.Size(115, 17); + this.radioButtonRegEx.TabIndex = 5; + this.radioButtonRegEx.Text = "Regular expression"; + this.radioButtonRegEx.UseVisualStyleBackColor = true; + this.radioButtonRegEx.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); + // + // radioButtonText + // + this.radioButtonText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.radioButtonText.AutoSize = true; + this.radioButtonText.Checked = true; + this.radioButtonText.Location = new System.Drawing.Point(6, 279); + this.radioButtonText.Name = "radioButtonText"; + this.radioButtonText.Size = new System.Drawing.Size(46, 17); + this.radioButtonText.TabIndex = 4; + this.radioButtonText.TabStop = true; + this.radioButtonText.Text = "Text"; + this.radioButtonText.UseVisualStyleBackColor = true; + this.radioButtonText.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); + // + // buttonRemoveNoBreakAfter + // + this.buttonRemoveNoBreakAfter.Location = new System.Drawing.Point(230, 19); + this.buttonRemoveNoBreakAfter.Name = "buttonRemoveNoBreakAfter"; + this.buttonRemoveNoBreakAfter.Size = new System.Drawing.Size(75, 23); + this.buttonRemoveNoBreakAfter.TabIndex = 1; + this.buttonRemoveNoBreakAfter.Text = "Remove"; + this.buttonRemoveNoBreakAfter.UseVisualStyleBackColor = true; + this.buttonRemoveNoBreakAfter.Click += new System.EventHandler(this.buttonRemoveNameEtc_Click); + // + // listBoxNoBreakAfter + // + this.listBoxNoBreakAfter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.listBoxNoBreakAfter.FormattingEnabled = true; + this.listBoxNoBreakAfter.Location = new System.Drawing.Point(6, 19); + this.listBoxNoBreakAfter.Name = "listBoxNoBreakAfter"; + this.listBoxNoBreakAfter.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.listBoxNoBreakAfter.Size = new System.Drawing.Size(218, 225); + this.listBoxNoBreakAfter.TabIndex = 0; + this.listBoxNoBreakAfter.SelectedIndexChanged += new System.EventHandler(this.listBoxNames_SelectedIndexChanged); + // + // textBoxNoBreakAfter + // + this.textBoxNoBreakAfter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.textBoxNoBreakAfter.Location = new System.Drawing.Point(6, 250); + this.textBoxNoBreakAfter.Name = "textBoxNoBreakAfter"; + this.textBoxNoBreakAfter.Size = new System.Drawing.Size(218, 20); + this.textBoxNoBreakAfter.TabIndex = 2; + this.textBoxNoBreakAfter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxNoBreakAfter_KeyDown); + // + // buttonAddNoBreakAfter + // + this.buttonAddNoBreakAfter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonAddNoBreakAfter.Location = new System.Drawing.Point(230, 248); + this.buttonAddNoBreakAfter.Name = "buttonAddNoBreakAfter"; + this.buttonAddNoBreakAfter.Size = new System.Drawing.Size(75, 23); + this.buttonAddNoBreakAfter.TabIndex = 3; + this.buttonAddNoBreakAfter.Text = "Add"; + this.buttonAddNoBreakAfter.UseVisualStyleBackColor = true; + this.buttonAddNoBreakAfter.Click += new System.EventHandler(this.buttonAddNames_Click); + // + // comboBoxDictionaries + // + this.comboBoxDictionaries.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxDictionaries.FormattingEnabled = true; + this.comboBoxDictionaries.Location = new System.Drawing.Point(12, 27); + this.comboBoxDictionaries.Name = "comboBoxDictionaries"; + this.comboBoxDictionaries.Size = new System.Drawing.Size(224, 21); + this.comboBoxDictionaries.TabIndex = 1; + this.comboBoxDictionaries.SelectedIndexChanged += new System.EventHandler(this.comboBoxDictionaries_SelectedIndexChanged); + // + // labelLanguage + // + this.labelLanguage.AutoSize = true; + this.labelLanguage.Location = new System.Drawing.Point(12, 11); + this.labelLanguage.Name = "labelLanguage"; + this.labelLanguage.Size = new System.Drawing.Size(55, 13); + this.labelLanguage.TabIndex = 0; + this.labelLanguage.Text = "Language"; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(166, 369); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(250, 369); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // DoNotBreakAfterListEdit + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(337, 402); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.comboBoxDictionaries); + this.Controls.Add(this.labelLanguage); + this.Controls.Add(this.groupBoxNamesIgonoreLists); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(350, 340); + this.Name = "DoNotBreakAfterListEdit"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Do not break after list - edit"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DoNotBreakAfterListEdit_KeyDown); + this.groupBoxNamesIgonoreLists.ResumeLayout(false); + this.groupBoxNamesIgonoreLists.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxNamesIgonoreLists; + private System.Windows.Forms.Button buttonRemoveNoBreakAfter; + private System.Windows.Forms.ListBox listBoxNoBreakAfter; + private System.Windows.Forms.TextBox textBoxNoBreakAfter; + private System.Windows.Forms.Button buttonAddNoBreakAfter; + private System.Windows.Forms.ComboBox comboBoxDictionaries; + private System.Windows.Forms.Label labelLanguage; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.RadioButton radioButtonRegEx; + private System.Windows.Forms.RadioButton radioButtonText; + } } \ No newline at end of file diff --git a/src/Forms/DoNotBreakAfterListEdit.cs b/src/ui/Forms/DoNotBreakAfterListEdit.cs similarity index 97% rename from src/Forms/DoNotBreakAfterListEdit.cs rename to src/ui/Forms/DoNotBreakAfterListEdit.cs index 82315fa54..eaef309e6 100644 --- a/src/Forms/DoNotBreakAfterListEdit.cs +++ b/src/ui/Forms/DoNotBreakAfterListEdit.cs @@ -1,246 +1,246 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class DoNotBreakAfterListEdit : Form - { - private readonly List _languages = new List(); - private List _noBreakAfterList = new List(); - - public DoNotBreakAfterListEdit() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.Settings.UseDoNotBreakAfterList; - labelLanguage.Text = Configuration.Settings.Language.ChooseLanguage.Language; - buttonRemoveNoBreakAfter.Text = Configuration.Settings.Language.DvdSubRip.Remove; - buttonAddNoBreakAfter.Text = Configuration.Settings.Language.DvdSubRip.Add; - radioButtonText.Text = Configuration.Settings.Language.General.Text; - radioButtonRegEx.Text = Configuration.Settings.Language.MultipleReplace.RegularExpression; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - - radioButtonRegEx.Left = radioButtonText.Left + radioButtonText.Width + 10; - var idx = 0; - foreach (string fileName in Directory.GetFiles(Configuration.DictionariesDirectory, "*_NoBreakAfterList.xml")) - { - try - { - string s = Path.GetFileName(fileName); - string languageId = s.Substring(0, s.IndexOf('_')); - var ci = CultureInfo.GetCultureInfoByIetfLanguageTag(languageId); - comboBoxDictionaries.Items.Add(ci.EnglishName + " (" + ci.NativeName + ")"); - if ((Configuration.Settings.WordLists.LastLanguage ?? "en-US").StartsWith(languageId, StringComparison.OrdinalIgnoreCase)) - { - idx = _languages.Count; - } - _languages.Add(fileName); - } - catch - { - // ignored - } - } - if (comboBoxDictionaries.Items.Count > 0 && idx < comboBoxDictionaries.Items.Count) - { - comboBoxDictionaries.SelectedIndex = idx; - } - } - - private void DoNotBreakAfterListEdit_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void comboBoxDictionaries_SelectedIndexChanged(object sender, EventArgs e) - { - int idx = comboBoxDictionaries.SelectedIndex; - if (idx >= 0) - { - _noBreakAfterList = new List(); - var doc = new XmlDocument(); - doc.Load(_languages[idx]); - foreach (XmlNode node in doc.DocumentElement.SelectNodes("Item")) - { - if (!string.IsNullOrEmpty(node.InnerText)) - { - if (node.Attributes["RegEx"] != null && node.Attributes["RegEx"].InnerText.Equals("true", StringComparison.OrdinalIgnoreCase)) - { - var r = new Regex(node.InnerText, RegexOptions.Compiled); - _noBreakAfterList.Add(new NoBreakAfterItem(r, node.InnerText)); - } - else - { - _noBreakAfterList.Add(new NoBreakAfterItem(node.InnerText)); - } - } - } - _noBreakAfterList.Sort(); - ShowBreakAfterList(_noBreakAfterList); - } - } - - private void ShowBreakAfterList(List noBreakAfterList) - { - listBoxNoBreakAfter.Items.Clear(); - foreach (var item in noBreakAfterList) - { - if (item.Text != null) - { - listBoxNoBreakAfter.Items.Add(item); - } - } - } - - private void buttonRemoveNameEtc_Click(object sender, EventArgs e) - { - int first = 0; - var list = new List(); - foreach (int i in listBoxNoBreakAfter.SelectedIndices) - { - list.Add(i); - } - - if (list.Count > 0) - { - first = list[0]; - } - - list.Sort(); - for (int i = list.Count - 1; i >= 0; i--) - { - _noBreakAfterList.RemoveAt(list[i]); - } - ShowBreakAfterList(_noBreakAfterList); - if (first >= _noBreakAfterList.Count) - { - first = _noBreakAfterList.Count - 1; - } - - if (first >= 0) - { - listBoxNoBreakAfter.SelectedIndex = first; - } - comboBoxDictionaries.Enabled = false; - } - - private void buttonOK_Click(object sender, EventArgs e) - { - Utilities.ResetNoBreakAfterList(); - int idx = comboBoxDictionaries.SelectedIndex; - if (idx >= 0) - { - var doc = new XmlDocument(); - doc.LoadXml(""); - foreach (NoBreakAfterItem item in _noBreakAfterList) - { - XmlNode node = doc.CreateElement("Item"); - node.InnerText = item.Text; - if (item.Regex != null) - { - XmlAttribute attribute = doc.CreateAttribute("RegEx"); - attribute.InnerText = true.ToString(); - node.Attributes.Append(attribute); - } - doc.DocumentElement.AppendChild(node); - } - doc.Save(_languages[idx]); - } - DialogResult = DialogResult.OK; - } - - private void buttonAddNames_Click(object sender, EventArgs e) - { - if (string.IsNullOrWhiteSpace(textBoxNoBreakAfter.Text)) - { - return; - } - - NoBreakAfterItem item; - if (radioButtonText.Checked) - { - item = new NoBreakAfterItem(textBoxNoBreakAfter.Text); - } - else - { - if (!RegexUtils.IsValidRegex(textBoxNoBreakAfter.Text)) - { - MessageBox.Show(Configuration.Settings.Language.General.RegularExpressionIsNotValid); - return; - } - item = new NoBreakAfterItem(new Regex(textBoxNoBreakAfter.Text), textBoxNoBreakAfter.Text); - } - - foreach (NoBreakAfterItem nbai in _noBreakAfterList) - { - if ((nbai.Regex == null && item.Regex == null || nbai.Regex != null && item.Regex != null) && nbai.Text == item.Text) - { - MessageBox.Show("Text already defined"); - textBoxNoBreakAfter.Focus(); - textBoxNoBreakAfter.SelectAll(); - return; - } - } - _noBreakAfterList.Add(item); - comboBoxDictionaries.Enabled = false; - ShowBreakAfterList(_noBreakAfterList); - for (int i = 0; i < listBoxNoBreakAfter.Items.Count; i++) - { - if (listBoxNoBreakAfter.Items[i].ToString() == item.Text) - { - listBoxNoBreakAfter.SelectedIndex = i; - return; - } - } - textBoxNoBreakAfter.Text = string.Empty; - } - - private void RadioButtonCheckedChanged(object sender, EventArgs e) - { - if (sender == radioButtonRegEx) - { - textBoxNoBreakAfter.ContextMenu = FindReplaceDialogHelper.GetRegExContextMenu(textBoxNoBreakAfter); - } - else - { - textBoxNoBreakAfter.ContextMenuStrip = null; - } - } - - private void listBoxNames_SelectedIndexChanged(object sender, EventArgs e) - { - int idx = listBoxNoBreakAfter.SelectedIndex; - if (idx >= 0 && idx < _noBreakAfterList.Count) - { - NoBreakAfterItem item = _noBreakAfterList[idx]; - textBoxNoBreakAfter.Text = item.Text; - bool isRegEx = item.Regex != null; - radioButtonRegEx.Checked = isRegEx; - radioButtonText.Checked = !isRegEx; - } - } - - private void textBoxNoBreakAfter_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - buttonAddNames_Click(sender, e); - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class DoNotBreakAfterListEdit : Form + { + private readonly List _languages = new List(); + private List _noBreakAfterList = new List(); + + public DoNotBreakAfterListEdit() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.Settings.UseDoNotBreakAfterList; + labelLanguage.Text = Configuration.Settings.Language.ChooseLanguage.Language; + buttonRemoveNoBreakAfter.Text = Configuration.Settings.Language.DvdSubRip.Remove; + buttonAddNoBreakAfter.Text = Configuration.Settings.Language.DvdSubRip.Add; + radioButtonText.Text = Configuration.Settings.Language.General.Text; + radioButtonRegEx.Text = Configuration.Settings.Language.MultipleReplace.RegularExpression; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + + radioButtonRegEx.Left = radioButtonText.Left + radioButtonText.Width + 10; + var idx = 0; + foreach (string fileName in Directory.GetFiles(Configuration.DictionariesDirectory, "*_NoBreakAfterList.xml")) + { + try + { + string s = Path.GetFileName(fileName); + string languageId = s.Substring(0, s.IndexOf('_')); + var ci = CultureInfo.GetCultureInfoByIetfLanguageTag(languageId); + comboBoxDictionaries.Items.Add(ci.EnglishName + " (" + ci.NativeName + ")"); + if ((Configuration.Settings.WordLists.LastLanguage ?? "en-US").StartsWith(languageId, StringComparison.OrdinalIgnoreCase)) + { + idx = _languages.Count; + } + _languages.Add(fileName); + } + catch + { + // ignored + } + } + if (comboBoxDictionaries.Items.Count > 0 && idx < comboBoxDictionaries.Items.Count) + { + comboBoxDictionaries.SelectedIndex = idx; + } + } + + private void DoNotBreakAfterListEdit_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void comboBoxDictionaries_SelectedIndexChanged(object sender, EventArgs e) + { + int idx = comboBoxDictionaries.SelectedIndex; + if (idx >= 0) + { + _noBreakAfterList = new List(); + var doc = new XmlDocument(); + doc.Load(_languages[idx]); + foreach (XmlNode node in doc.DocumentElement.SelectNodes("Item")) + { + if (!string.IsNullOrEmpty(node.InnerText)) + { + if (node.Attributes["RegEx"] != null && node.Attributes["RegEx"].InnerText.Equals("true", StringComparison.OrdinalIgnoreCase)) + { + var r = new Regex(node.InnerText, RegexOptions.Compiled); + _noBreakAfterList.Add(new NoBreakAfterItem(r, node.InnerText)); + } + else + { + _noBreakAfterList.Add(new NoBreakAfterItem(node.InnerText)); + } + } + } + _noBreakAfterList.Sort(); + ShowBreakAfterList(_noBreakAfterList); + } + } + + private void ShowBreakAfterList(List noBreakAfterList) + { + listBoxNoBreakAfter.Items.Clear(); + foreach (var item in noBreakAfterList) + { + if (item.Text != null) + { + listBoxNoBreakAfter.Items.Add(item); + } + } + } + + private void buttonRemoveNameEtc_Click(object sender, EventArgs e) + { + int first = 0; + var list = new List(); + foreach (int i in listBoxNoBreakAfter.SelectedIndices) + { + list.Add(i); + } + + if (list.Count > 0) + { + first = list[0]; + } + + list.Sort(); + for (int i = list.Count - 1; i >= 0; i--) + { + _noBreakAfterList.RemoveAt(list[i]); + } + ShowBreakAfterList(_noBreakAfterList); + if (first >= _noBreakAfterList.Count) + { + first = _noBreakAfterList.Count - 1; + } + + if (first >= 0) + { + listBoxNoBreakAfter.SelectedIndex = first; + } + comboBoxDictionaries.Enabled = false; + } + + private void buttonOK_Click(object sender, EventArgs e) + { + Utilities.ResetNoBreakAfterList(); + int idx = comboBoxDictionaries.SelectedIndex; + if (idx >= 0) + { + var doc = new XmlDocument(); + doc.LoadXml(""); + foreach (NoBreakAfterItem item in _noBreakAfterList) + { + XmlNode node = doc.CreateElement("Item"); + node.InnerText = item.Text; + if (item.Regex != null) + { + XmlAttribute attribute = doc.CreateAttribute("RegEx"); + attribute.InnerText = true.ToString(); + node.Attributes.Append(attribute); + } + doc.DocumentElement.AppendChild(node); + } + doc.Save(_languages[idx]); + } + DialogResult = DialogResult.OK; + } + + private void buttonAddNames_Click(object sender, EventArgs e) + { + if (string.IsNullOrWhiteSpace(textBoxNoBreakAfter.Text)) + { + return; + } + + NoBreakAfterItem item; + if (radioButtonText.Checked) + { + item = new NoBreakAfterItem(textBoxNoBreakAfter.Text); + } + else + { + if (!RegexUtils.IsValidRegex(textBoxNoBreakAfter.Text)) + { + MessageBox.Show(Configuration.Settings.Language.General.RegularExpressionIsNotValid); + return; + } + item = new NoBreakAfterItem(new Regex(textBoxNoBreakAfter.Text), textBoxNoBreakAfter.Text); + } + + foreach (NoBreakAfterItem nbai in _noBreakAfterList) + { + if ((nbai.Regex == null && item.Regex == null || nbai.Regex != null && item.Regex != null) && nbai.Text == item.Text) + { + MessageBox.Show("Text already defined"); + textBoxNoBreakAfter.Focus(); + textBoxNoBreakAfter.SelectAll(); + return; + } + } + _noBreakAfterList.Add(item); + comboBoxDictionaries.Enabled = false; + ShowBreakAfterList(_noBreakAfterList); + for (int i = 0; i < listBoxNoBreakAfter.Items.Count; i++) + { + if (listBoxNoBreakAfter.Items[i].ToString() == item.Text) + { + listBoxNoBreakAfter.SelectedIndex = i; + return; + } + } + textBoxNoBreakAfter.Text = string.Empty; + } + + private void RadioButtonCheckedChanged(object sender, EventArgs e) + { + if (sender == radioButtonRegEx) + { + textBoxNoBreakAfter.ContextMenu = FindReplaceDialogHelper.GetRegExContextMenu(textBoxNoBreakAfter); + } + else + { + textBoxNoBreakAfter.ContextMenuStrip = null; + } + } + + private void listBoxNames_SelectedIndexChanged(object sender, EventArgs e) + { + int idx = listBoxNoBreakAfter.SelectedIndex; + if (idx >= 0 && idx < _noBreakAfterList.Count) + { + NoBreakAfterItem item = _noBreakAfterList[idx]; + textBoxNoBreakAfter.Text = item.Text; + bool isRegEx = item.Regex != null; + radioButtonRegEx.Checked = isRegEx; + radioButtonText.Checked = !isRegEx; + } + } + + private void textBoxNoBreakAfter_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + buttonAddNames_Click(sender, e); + } + } + + } +} diff --git a/src/Forms/MultipleReplaceNewGroup.resx b/src/ui/Forms/DoNotBreakAfterListEdit.resx similarity index 100% rename from src/Forms/MultipleReplaceNewGroup.resx rename to src/ui/Forms/DoNotBreakAfterListEdit.resx diff --git a/src/Forms/DownloadFfmpeg.Designer.cs b/src/ui/Forms/DownloadFfmpeg.Designer.cs similarity index 100% rename from src/Forms/DownloadFfmpeg.Designer.cs rename to src/ui/Forms/DownloadFfmpeg.Designer.cs diff --git a/src/Forms/DownloadFfmpeg.cs b/src/ui/Forms/DownloadFfmpeg.cs similarity index 100% rename from src/Forms/DownloadFfmpeg.cs rename to src/ui/Forms/DownloadFfmpeg.cs diff --git a/src/Forms/NetflixFixErrors.resx b/src/ui/Forms/DownloadFfmpeg.resx similarity index 100% rename from src/Forms/NetflixFixErrors.resx rename to src/ui/Forms/DownloadFfmpeg.resx diff --git a/src/Forms/DurationsBridgeGaps.Designer.cs b/src/ui/Forms/DurationsBridgeGaps.Designer.cs similarity index 98% rename from src/Forms/DurationsBridgeGaps.Designer.cs rename to src/ui/Forms/DurationsBridgeGaps.Designer.cs index 0e16ab72e..593a54900 100644 --- a/src/Forms/DurationsBridgeGaps.Designer.cs +++ b/src/ui/Forms/DurationsBridgeGaps.Designer.cs @@ -1,261 +1,261 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class DurationsBridgeGaps - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.labelMilliseconds = new System.Windows.Forms.Label(); - this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); - this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.numericUpDownMaxMs = new System.Windows.Forms.NumericUpDown(); - this.labelBridgePart1 = new System.Windows.Forms.Label(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.radioButtonProlongEndTime = new System.Windows.Forms.RadioButton(); - this.radioButtonDivideEven = new System.Windows.Forms.RadioButton(); - this.labelMinMsBetweenLines = new System.Windows.Forms.Label(); - this.numericUpDownMinMsBetweenLines = new System.Windows.Forms.NumericUpDown(); - this.groupBoxLinesFound.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMs)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinMsBetweenLines)).BeginInit(); - this.SuspendLayout(); - // - // labelMilliseconds - // - this.labelMilliseconds.AutoSize = true; - this.labelMilliseconds.Location = new System.Drawing.Point(196, 12); - this.labelMilliseconds.Name = "labelMilliseconds"; - this.labelMilliseconds.Size = new System.Drawing.Size(63, 13); - this.labelMilliseconds.TabIndex = 2; - this.labelMilliseconds.Text = "milliseconds"; - // - // groupBoxLinesFound - // - this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxLinesFound.Controls.Add(this.SubtitleListview1); - this.groupBoxLinesFound.Location = new System.Drawing.Point(15, 65); - this.groupBoxLinesFound.Name = "groupBoxLinesFound"; - this.groupBoxLinesFound.Size = new System.Drawing.Size(871, 484); - this.groupBoxLinesFound.TabIndex = 7; - this.groupBoxLinesFound.TabStop = false; - this.groupBoxLinesFound.Text = "Lines that will be bridged"; - // - // SubtitleListview1 - // - this.SubtitleListview1.AllowColumnReorder = true; - this.SubtitleListview1.AllowDrop = true; - this.SubtitleListview1.Dock = System.Windows.Forms.DockStyle.Fill; - this.SubtitleListview1.FirstVisibleIndex = -1; - this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.SubtitleListview1.FullRowSelect = true; - this.SubtitleListview1.GridLines = true; - this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.SubtitleListview1.HideSelection = false; - this.SubtitleListview1.Location = new System.Drawing.Point(3, 16); - this.SubtitleListview1.Name = "SubtitleListview1"; - this.SubtitleListview1.OwnerDraw = true; - this.SubtitleListview1.Size = new System.Drawing.Size(865, 465); - this.SubtitleListview1.SubtitleFontBold = false; - this.SubtitleListview1.SubtitleFontName = "Tahoma"; - this.SubtitleListview1.SubtitleFontSize = 8; - this.SubtitleListview1.TabIndex = 0; - this.SubtitleListview1.UseCompatibleStateImageBehavior = false; - this.SubtitleListview1.UseSyntaxColoring = true; - this.SubtitleListview1.View = System.Windows.Forms.View.Details; - // - // numericUpDownMaxMs - // - this.numericUpDownMaxMs.Increment = new decimal(new int[] { - 25, - 0, - 0, - 0}); - this.numericUpDownMaxMs.Location = new System.Drawing.Point(140, 10); - this.numericUpDownMaxMs.Maximum = new decimal(new int[] { - 2000, - 0, - 0, - 0}); - this.numericUpDownMaxMs.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.numericUpDownMaxMs.Name = "numericUpDownMaxMs"; - this.numericUpDownMaxMs.Size = new System.Drawing.Size(50, 20); - this.numericUpDownMaxMs.TabIndex = 1; - this.numericUpDownMaxMs.Value = new decimal(new int[] { - 100, - 0, - 0, - 0}); - this.numericUpDownMaxMs.ValueChanged += new System.EventHandler(this.numericUpDownMaxMs_ValueChanged); - this.numericUpDownMaxMs.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDownMaxMs_KeyUp); - this.numericUpDownMaxMs.Validated += new System.EventHandler(this.numericUpDownMaxMs_Validated); - // - // labelBridgePart1 - // - this.labelBridgePart1.AutoSize = true; - this.labelBridgePart1.Location = new System.Drawing.Point(12, 12); - this.labelBridgePart1.Name = "labelBridgePart1"; - this.labelBridgePart1.Size = new System.Drawing.Size(122, 13); - this.labelBridgePart1.TabIndex = 0; - this.labelBridgePart1.Text = "Bridge gaps smaller than"; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(730, 555); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 8; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(811, 555); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 9; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // radioButtonProlongEndTime - // - this.radioButtonProlongEndTime.AutoSize = true; - this.radioButtonProlongEndTime.Checked = true; - this.radioButtonProlongEndTime.Location = new System.Drawing.Point(586, 17); - this.radioButtonProlongEndTime.Name = "radioButtonProlongEndTime"; - this.radioButtonProlongEndTime.Size = new System.Drawing.Size(171, 17); - this.radioButtonProlongEndTime.TabIndex = 5; - this.radioButtonProlongEndTime.TabStop = true; - this.radioButtonProlongEndTime.Text = "Previous text takes all gap time"; - this.radioButtonProlongEndTime.UseVisualStyleBackColor = true; - this.radioButtonProlongEndTime.CheckedChanged += new System.EventHandler(this.numericUpDownMaxMs_ValueChanged); - // - // radioButtonDivideEven - // - this.radioButtonDivideEven.AutoSize = true; - this.radioButtonDivideEven.Location = new System.Drawing.Point(586, 40); - this.radioButtonDivideEven.Name = "radioButtonDivideEven"; - this.radioButtonDivideEven.Size = new System.Drawing.Size(125, 17); - this.radioButtonDivideEven.TabIndex = 6; - this.radioButtonDivideEven.Text = "Texts divide gap time"; - this.radioButtonDivideEven.UseVisualStyleBackColor = true; - this.radioButtonDivideEven.CheckedChanged += new System.EventHandler(this.numericUpDownMaxMs_ValueChanged); - // - // labelMinMsBetweenLines - // - this.labelMinMsBetweenLines.AutoSize = true; - this.labelMinMsBetweenLines.Location = new System.Drawing.Point(15, 40); - this.labelMinMsBetweenLines.Name = "labelMinMsBetweenLines"; - this.labelMinMsBetweenLines.Size = new System.Drawing.Size(154, 13); - this.labelMinMsBetweenLines.TabIndex = 3; - this.labelMinMsBetweenLines.Text = "Min. milliseconds between lines"; - // - // numericUpDownMinMsBetweenLines - // - this.numericUpDownMinMsBetweenLines.Increment = new decimal(new int[] { - 5, - 0, - 0, - 0}); - this.numericUpDownMinMsBetweenLines.Location = new System.Drawing.Point(175, 38); - this.numericUpDownMinMsBetweenLines.Maximum = new decimal(new int[] { - 1000, - 0, - 0, - 0}); - this.numericUpDownMinMsBetweenLines.Name = "numericUpDownMinMsBetweenLines"; - this.numericUpDownMinMsBetweenLines.Size = new System.Drawing.Size(50, 20); - this.numericUpDownMinMsBetweenLines.TabIndex = 4; - this.numericUpDownMinMsBetweenLines.Value = new decimal(new int[] { - 40, - 0, - 0, - 0}); - this.numericUpDownMinMsBetweenLines.ValueChanged += new System.EventHandler(this.numericUpDownMinMsBetweenLines_ValueChanged); - this.numericUpDownMinMsBetweenLines.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDownMinMsBetweenLines_KeyUp); - this.numericUpDownMinMsBetweenLines.Validated += new System.EventHandler(this.numericUpDownMinMsBetweenLines_Validated); - // - // DurationsBridgeGaps - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(898, 588); - this.Controls.Add(this.numericUpDownMinMsBetweenLines); - this.Controls.Add(this.labelMinMsBetweenLines); - this.Controls.Add(this.radioButtonDivideEven); - this.Controls.Add(this.radioButtonProlongEndTime); - this.Controls.Add(this.labelMilliseconds); - this.Controls.Add(this.groupBoxLinesFound); - this.Controls.Add(this.numericUpDownMaxMs); - this.Controls.Add(this.labelBridgePart1); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.KeyPreview = true; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(850, 400); - this.Name = "DurationsBridgeGaps"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "DurationsBridgeGaps"; - this.Shown += new System.EventHandler(this.DurationsBridgeGaps_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DurationsBridgeGaps_KeyDown); - this.groupBoxLinesFound.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMs)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinMsBetweenLines)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelMilliseconds; - private System.Windows.Forms.GroupBox groupBoxLinesFound; - private System.Windows.Forms.NumericUpDown numericUpDownMaxMs; - private System.Windows.Forms.Label labelBridgePart1; - private Controls.SubtitleListView SubtitleListview1; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.RadioButton radioButtonProlongEndTime; - private System.Windows.Forms.RadioButton radioButtonDivideEven; - private System.Windows.Forms.Label labelMinMsBetweenLines; - private System.Windows.Forms.NumericUpDown numericUpDownMinMsBetweenLines; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class DurationsBridgeGaps + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.labelMilliseconds = new System.Windows.Forms.Label(); + this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); + this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.numericUpDownMaxMs = new System.Windows.Forms.NumericUpDown(); + this.labelBridgePart1 = new System.Windows.Forms.Label(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.radioButtonProlongEndTime = new System.Windows.Forms.RadioButton(); + this.radioButtonDivideEven = new System.Windows.Forms.RadioButton(); + this.labelMinMsBetweenLines = new System.Windows.Forms.Label(); + this.numericUpDownMinMsBetweenLines = new System.Windows.Forms.NumericUpDown(); + this.groupBoxLinesFound.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMs)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinMsBetweenLines)).BeginInit(); + this.SuspendLayout(); + // + // labelMilliseconds + // + this.labelMilliseconds.AutoSize = true; + this.labelMilliseconds.Location = new System.Drawing.Point(196, 12); + this.labelMilliseconds.Name = "labelMilliseconds"; + this.labelMilliseconds.Size = new System.Drawing.Size(63, 13); + this.labelMilliseconds.TabIndex = 2; + this.labelMilliseconds.Text = "milliseconds"; + // + // groupBoxLinesFound + // + this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxLinesFound.Controls.Add(this.SubtitleListview1); + this.groupBoxLinesFound.Location = new System.Drawing.Point(15, 65); + this.groupBoxLinesFound.Name = "groupBoxLinesFound"; + this.groupBoxLinesFound.Size = new System.Drawing.Size(871, 484); + this.groupBoxLinesFound.TabIndex = 7; + this.groupBoxLinesFound.TabStop = false; + this.groupBoxLinesFound.Text = "Lines that will be bridged"; + // + // SubtitleListview1 + // + this.SubtitleListview1.AllowColumnReorder = true; + this.SubtitleListview1.AllowDrop = true; + this.SubtitleListview1.Dock = System.Windows.Forms.DockStyle.Fill; + this.SubtitleListview1.FirstVisibleIndex = -1; + this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SubtitleListview1.FullRowSelect = true; + this.SubtitleListview1.GridLines = true; + this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.SubtitleListview1.HideSelection = false; + this.SubtitleListview1.Location = new System.Drawing.Point(3, 16); + this.SubtitleListview1.Name = "SubtitleListview1"; + this.SubtitleListview1.OwnerDraw = true; + this.SubtitleListview1.Size = new System.Drawing.Size(865, 465); + this.SubtitleListview1.SubtitleFontBold = false; + this.SubtitleListview1.SubtitleFontName = "Tahoma"; + this.SubtitleListview1.SubtitleFontSize = 8; + this.SubtitleListview1.TabIndex = 0; + this.SubtitleListview1.UseCompatibleStateImageBehavior = false; + this.SubtitleListview1.UseSyntaxColoring = true; + this.SubtitleListview1.View = System.Windows.Forms.View.Details; + // + // numericUpDownMaxMs + // + this.numericUpDownMaxMs.Increment = new decimal(new int[] { + 25, + 0, + 0, + 0}); + this.numericUpDownMaxMs.Location = new System.Drawing.Point(140, 10); + this.numericUpDownMaxMs.Maximum = new decimal(new int[] { + 2000, + 0, + 0, + 0}); + this.numericUpDownMaxMs.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numericUpDownMaxMs.Name = "numericUpDownMaxMs"; + this.numericUpDownMaxMs.Size = new System.Drawing.Size(50, 20); + this.numericUpDownMaxMs.TabIndex = 1; + this.numericUpDownMaxMs.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numericUpDownMaxMs.ValueChanged += new System.EventHandler(this.numericUpDownMaxMs_ValueChanged); + this.numericUpDownMaxMs.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDownMaxMs_KeyUp); + this.numericUpDownMaxMs.Validated += new System.EventHandler(this.numericUpDownMaxMs_Validated); + // + // labelBridgePart1 + // + this.labelBridgePart1.AutoSize = true; + this.labelBridgePart1.Location = new System.Drawing.Point(12, 12); + this.labelBridgePart1.Name = "labelBridgePart1"; + this.labelBridgePart1.Size = new System.Drawing.Size(122, 13); + this.labelBridgePart1.TabIndex = 0; + this.labelBridgePart1.Text = "Bridge gaps smaller than"; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(730, 555); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 8; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(811, 555); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 9; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // radioButtonProlongEndTime + // + this.radioButtonProlongEndTime.AutoSize = true; + this.radioButtonProlongEndTime.Checked = true; + this.radioButtonProlongEndTime.Location = new System.Drawing.Point(586, 17); + this.radioButtonProlongEndTime.Name = "radioButtonProlongEndTime"; + this.radioButtonProlongEndTime.Size = new System.Drawing.Size(171, 17); + this.radioButtonProlongEndTime.TabIndex = 5; + this.radioButtonProlongEndTime.TabStop = true; + this.radioButtonProlongEndTime.Text = "Previous text takes all gap time"; + this.radioButtonProlongEndTime.UseVisualStyleBackColor = true; + this.radioButtonProlongEndTime.CheckedChanged += new System.EventHandler(this.numericUpDownMaxMs_ValueChanged); + // + // radioButtonDivideEven + // + this.radioButtonDivideEven.AutoSize = true; + this.radioButtonDivideEven.Location = new System.Drawing.Point(586, 40); + this.radioButtonDivideEven.Name = "radioButtonDivideEven"; + this.radioButtonDivideEven.Size = new System.Drawing.Size(125, 17); + this.radioButtonDivideEven.TabIndex = 6; + this.radioButtonDivideEven.Text = "Texts divide gap time"; + this.radioButtonDivideEven.UseVisualStyleBackColor = true; + this.radioButtonDivideEven.CheckedChanged += new System.EventHandler(this.numericUpDownMaxMs_ValueChanged); + // + // labelMinMsBetweenLines + // + this.labelMinMsBetweenLines.AutoSize = true; + this.labelMinMsBetweenLines.Location = new System.Drawing.Point(15, 40); + this.labelMinMsBetweenLines.Name = "labelMinMsBetweenLines"; + this.labelMinMsBetweenLines.Size = new System.Drawing.Size(154, 13); + this.labelMinMsBetweenLines.TabIndex = 3; + this.labelMinMsBetweenLines.Text = "Min. milliseconds between lines"; + // + // numericUpDownMinMsBetweenLines + // + this.numericUpDownMinMsBetweenLines.Increment = new decimal(new int[] { + 5, + 0, + 0, + 0}); + this.numericUpDownMinMsBetweenLines.Location = new System.Drawing.Point(175, 38); + this.numericUpDownMinMsBetweenLines.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownMinMsBetweenLines.Name = "numericUpDownMinMsBetweenLines"; + this.numericUpDownMinMsBetweenLines.Size = new System.Drawing.Size(50, 20); + this.numericUpDownMinMsBetweenLines.TabIndex = 4; + this.numericUpDownMinMsBetweenLines.Value = new decimal(new int[] { + 40, + 0, + 0, + 0}); + this.numericUpDownMinMsBetweenLines.ValueChanged += new System.EventHandler(this.numericUpDownMinMsBetweenLines_ValueChanged); + this.numericUpDownMinMsBetweenLines.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDownMinMsBetweenLines_KeyUp); + this.numericUpDownMinMsBetweenLines.Validated += new System.EventHandler(this.numericUpDownMinMsBetweenLines_Validated); + // + // DurationsBridgeGaps + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(898, 588); + this.Controls.Add(this.numericUpDownMinMsBetweenLines); + this.Controls.Add(this.labelMinMsBetweenLines); + this.Controls.Add(this.radioButtonDivideEven); + this.Controls.Add(this.radioButtonProlongEndTime); + this.Controls.Add(this.labelMilliseconds); + this.Controls.Add(this.groupBoxLinesFound); + this.Controls.Add(this.numericUpDownMaxMs); + this.Controls.Add(this.labelBridgePart1); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.KeyPreview = true; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(850, 400); + this.Name = "DurationsBridgeGaps"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "DurationsBridgeGaps"; + this.Shown += new System.EventHandler(this.DurationsBridgeGaps_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DurationsBridgeGaps_KeyDown); + this.groupBoxLinesFound.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMs)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinMsBetweenLines)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelMilliseconds; + private System.Windows.Forms.GroupBox groupBoxLinesFound; + private System.Windows.Forms.NumericUpDown numericUpDownMaxMs; + private System.Windows.Forms.Label labelBridgePart1; + private Controls.SubtitleListView SubtitleListview1; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.RadioButton radioButtonProlongEndTime; + private System.Windows.Forms.RadioButton radioButtonDivideEven; + private System.Windows.Forms.Label labelMinMsBetweenLines; + private System.Windows.Forms.NumericUpDown numericUpDownMinMsBetweenLines; + } } \ No newline at end of file diff --git a/src/Forms/DurationsBridgeGaps.cs b/src/ui/Forms/DurationsBridgeGaps.cs similarity index 97% rename from src/Forms/DurationsBridgeGaps.cs rename to src/ui/Forms/DurationsBridgeGaps.cs index db8c9fac4..899620d8f 100644 --- a/src/Forms/DurationsBridgeGaps.cs +++ b/src/ui/Forms/DurationsBridgeGaps.cs @@ -1,255 +1,255 @@ -using Nikse.SubtitleEdit.Controls; -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; -using Nikse.SubtitleEdit.Core.SubtitleFormats; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class DurationsBridgeGaps : PositionAndSizeForm - { - private readonly Subtitle _subtitle; - private Dictionary _dic; - private readonly Timer _refreshTimer = new Timer(); - public Subtitle FixedSubtitle { get; private set; } - public int FixedCount { get; private set; } - public int MinMsBetweenLines - { - get => (int)numericUpDownMinMsBetweenLines.Value; - set => numericUpDownMinMsBetweenLines.Value = value; - } - - public bool PreviousSubtitleTakesAllTime => radioButtonProlongEndTime.Checked; - - public DurationsBridgeGaps(Subtitle subtitle) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - UiUtil.FixLargeFonts(this, buttonOK); - - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); - SubtitleListview1.SetCustomResize(SubtitleListView1_Resize); - - Text = Configuration.Settings.Language.DurationsBridgeGaps.Title; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.ShowExtraColumn(Configuration.Settings.General.UseTimeFormatHHMMSSFF ? Configuration.Settings.Language.DurationsBridgeGaps.GapToNextFrames : Configuration.Settings.Language.DurationsBridgeGaps.GapToNext); - SubtitleListview1.AutoSizeAllColumns(this); - - labelBridgePart1.Text = Configuration.Settings.Language.DurationsBridgeGaps.BridgeGapsSmallerThanXPart1; - labelMilliseconds.Text = Configuration.Settings.Language.DurationsBridgeGaps.BridgeGapsSmallerThanXPart2; - labelMinMsBetweenLines.Text = Configuration.Settings.Language.DurationsBridgeGaps.MinMillisecondsBetweenLines; - radioButtonProlongEndTime.Text = Configuration.Settings.Language.DurationsBridgeGaps.ProlongEndTime; - radioButtonDivideEven.Text = Configuration.Settings.Language.DurationsBridgeGaps.DivideEven; - groupBoxLinesFound.Text = string.Empty; - - _subtitle = subtitle; - try - { - numericUpDownMaxMs.Value = Configuration.Settings.Tools.BridgeGapMilliseconds; - } - catch - { - numericUpDownMaxMs.Value = 100; - } - if (Configuration.Settings.General.MinimumMillisecondsBetweenLines >= 1 && Configuration.Settings.General.MinimumMillisecondsBetweenLines <= numericUpDownMinMsBetweenLines.Maximum) - { - numericUpDownMinMsBetweenLines.Value = Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - - if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) - { - labelBridgePart1.Text = Configuration.Settings.Language.DurationsBridgeGaps.BridgeGapsSmallerThanXPart1Frames; - labelMilliseconds.Text = Configuration.Settings.Language.DurationsBridgeGaps.BridgeGapsSmallerThanXPart2Frames; - - labelMinMsBetweenLines.Text = Configuration.Settings.Language.DurationsBridgeGaps.MinFramesBetweenLines; - - numericUpDownMaxMs.Value = SubtitleFormat.MillisecondsToFrames((double)numericUpDownMaxMs.Value); - numericUpDownMaxMs.Increment = 1; - numericUpDownMinMsBetweenLines.Value = SubtitleFormat.MillisecondsToFrames((double)numericUpDownMinMsBetweenLines.Value); - numericUpDownMinMsBetweenLines.Increment = 1; - } - - numericUpDownMinMsBetweenLines.Left = labelMinMsBetweenLines.Left + labelMinMsBetweenLines.Width + 4; - numericUpDownMaxMs.Left = labelBridgePart1.Left + labelBridgePart1.Width + 4; - labelMilliseconds.Left = numericUpDownMaxMs.Left + numericUpDownMaxMs.Width + 4; - - if (subtitle != null) - { - _refreshTimer.Interval = 400; - _refreshTimer.Tick += RefreshTimerTick; - GeneratePreview(); - } - } - - private void RefreshTimerTick(object sender, EventArgs e) - { - _refreshTimer.Stop(); - GeneratePreviewReal(); - } - - public sealed override string Text - { - get => base.Text; - set => base.Text = value; - } - - private void buttonOK_Click(object sender, EventArgs e) - { - Configuration.Settings.Tools.BridgeGapMilliseconds = (int)numericUpDownMaxMs.Value; - if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) - { - Configuration.Settings.Tools.BridgeGapMilliseconds = SubtitleFormat.FramesToMilliseconds((double)numericUpDownMaxMs.Value); - } - - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void GeneratePreview() - { - if (_refreshTimer.Enabled) - { - _refreshTimer.Stop(); - } - _refreshTimer.Start(); - } - - private void GeneratePreviewReal() - { - groupBoxLinesFound.Text = string.Empty; - if (_subtitle == null) - { - return; - } - - Cursor = Cursors.WaitCursor; - SubtitleListview1.Items.Clear(); - SubtitleListview1.BeginUpdate(); - FixedSubtitle = new Subtitle(_subtitle); - _dic = new Dictionary(); - var fixedIndexes = new List(FixedSubtitle.Paragraphs.Count); - var minMsBetweenLines = (int)numericUpDownMinMsBetweenLines.Value; - var maxMs = (double)numericUpDownMaxMs.Value; - if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) - { - minMsBetweenLines = SubtitleFormat.FramesToMilliseconds(minMsBetweenLines); - maxMs = SubtitleFormat.FramesToMilliseconds(maxMs); - } - - FixedCount = Core.Forms.DurationsBridgeGaps.BridgeGaps(FixedSubtitle, minMsBetweenLines, radioButtonDivideEven.Checked, maxMs, fixedIndexes, _dic, Configuration.Settings.General.UseTimeFormatHHMMSSFF); - SubtitleListview1.Fill(FixedSubtitle); - for (int i = 0; i < FixedSubtitle.Paragraphs.Count; i++) - { - var cur = FixedSubtitle.Paragraphs[i]; - if (_dic.ContainsKey(cur.Id)) - { - SubtitleListview1.SetExtraText(i, _dic[cur.Id], SubtitleListview1.ForeColor); - } - else - { - var info = string.Empty; - var next = FixedSubtitle.GetParagraphOrDefault(i + 1); - if (next != null) - { - var gap = next.StartTime.TotalMilliseconds - cur.EndTime.TotalMilliseconds; - info = $"{ gap / TimeCode.BaseUnit:0.000}"; - if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) - { - info = $"{ SubtitleFormat.MillisecondsToFrames(gap)}"; - } - } - SubtitleListview1.SetExtraText(i, info, SubtitleListview1.ForeColor); - } - - SubtitleListview1.SetBackgroundColor(i, SubtitleListview1.BackColor); - } - - foreach (var index in fixedIndexes) - { - SubtitleListview1.SetBackgroundColor(index, Color.LightGreen); - } - - SubtitleListview1.EndUpdate(); - groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.DurationsBridgeGaps.GapsBridgedX, FixedCount); - - Cursor = Cursors.Default; - } - - private void numericUpDownMaxMs_ValueChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void numericUpDownMinMsBetweenLines_ValueChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void DurationsBridgeGaps_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void DurationsBridgeGaps_Shown(object sender, EventArgs e) - { - SubtitleListview1.Focus(); - } - - private void numericUpDownMaxMs_Validated(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void numericUpDownMaxMs_KeyUp(object sender, KeyEventArgs e) - { - GeneratePreview(); - } - - private void numericUpDownMinMsBetweenLines_Validated(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void numericUpDownMinMsBetweenLines_KeyUp(object sender, KeyEventArgs e) - { - GeneratePreview(); - } - - private void SubtitleListView1_Resize(object sender, EventArgs e) - { - const int lastColumnWidth = 165; - var columnsCount = SubtitleListview1.Columns.Count - 1; - var width = 0; - for (int i = 0; i < columnsCount - 1; i++) - { - width += SubtitleListview1.Columns[i].Width; - } - SubtitleListview1.Columns[columnsCount - 1].Width = SubtitleListview1.Width - (width + lastColumnWidth); - SubtitleListview1.Columns[columnsCount].Width = -2; - } - - public void InitializeSettingsOnly() - { - groupBoxLinesFound.Enabled = false; - Height = MinimumSize.Height; - MaximizeBox = false; - MinimizeBox = false; - } - } -} +using Nikse.SubtitleEdit.Controls; +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Core.SubtitleFormats; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class DurationsBridgeGaps : PositionAndSizeForm + { + private readonly Subtitle _subtitle; + private Dictionary _dic; + private readonly Timer _refreshTimer = new Timer(); + public Subtitle FixedSubtitle { get; private set; } + public int FixedCount { get; private set; } + public int MinMsBetweenLines + { + get => (int)numericUpDownMinMsBetweenLines.Value; + set => numericUpDownMinMsBetweenLines.Value = value; + } + + public bool PreviousSubtitleTakesAllTime => radioButtonProlongEndTime.Checked; + + public DurationsBridgeGaps(Subtitle subtitle) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + UiUtil.FixLargeFonts(this, buttonOK); + + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); + SubtitleListview1.SetCustomResize(SubtitleListView1_Resize); + + Text = Configuration.Settings.Language.DurationsBridgeGaps.Title; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.ShowExtraColumn(Configuration.Settings.General.UseTimeFormatHHMMSSFF ? Configuration.Settings.Language.DurationsBridgeGaps.GapToNextFrames : Configuration.Settings.Language.DurationsBridgeGaps.GapToNext); + SubtitleListview1.AutoSizeAllColumns(this); + + labelBridgePart1.Text = Configuration.Settings.Language.DurationsBridgeGaps.BridgeGapsSmallerThanXPart1; + labelMilliseconds.Text = Configuration.Settings.Language.DurationsBridgeGaps.BridgeGapsSmallerThanXPart2; + labelMinMsBetweenLines.Text = Configuration.Settings.Language.DurationsBridgeGaps.MinMillisecondsBetweenLines; + radioButtonProlongEndTime.Text = Configuration.Settings.Language.DurationsBridgeGaps.ProlongEndTime; + radioButtonDivideEven.Text = Configuration.Settings.Language.DurationsBridgeGaps.DivideEven; + groupBoxLinesFound.Text = string.Empty; + + _subtitle = subtitle; + try + { + numericUpDownMaxMs.Value = Configuration.Settings.Tools.BridgeGapMilliseconds; + } + catch + { + numericUpDownMaxMs.Value = 100; + } + if (Configuration.Settings.General.MinimumMillisecondsBetweenLines >= 1 && Configuration.Settings.General.MinimumMillisecondsBetweenLines <= numericUpDownMinMsBetweenLines.Maximum) + { + numericUpDownMinMsBetweenLines.Value = Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + + if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) + { + labelBridgePart1.Text = Configuration.Settings.Language.DurationsBridgeGaps.BridgeGapsSmallerThanXPart1Frames; + labelMilliseconds.Text = Configuration.Settings.Language.DurationsBridgeGaps.BridgeGapsSmallerThanXPart2Frames; + + labelMinMsBetweenLines.Text = Configuration.Settings.Language.DurationsBridgeGaps.MinFramesBetweenLines; + + numericUpDownMaxMs.Value = SubtitleFormat.MillisecondsToFrames((double)numericUpDownMaxMs.Value); + numericUpDownMaxMs.Increment = 1; + numericUpDownMinMsBetweenLines.Value = SubtitleFormat.MillisecondsToFrames((double)numericUpDownMinMsBetweenLines.Value); + numericUpDownMinMsBetweenLines.Increment = 1; + } + + numericUpDownMinMsBetweenLines.Left = labelMinMsBetweenLines.Left + labelMinMsBetweenLines.Width + 4; + numericUpDownMaxMs.Left = labelBridgePart1.Left + labelBridgePart1.Width + 4; + labelMilliseconds.Left = numericUpDownMaxMs.Left + numericUpDownMaxMs.Width + 4; + + if (subtitle != null) + { + _refreshTimer.Interval = 400; + _refreshTimer.Tick += RefreshTimerTick; + GeneratePreview(); + } + } + + private void RefreshTimerTick(object sender, EventArgs e) + { + _refreshTimer.Stop(); + GeneratePreviewReal(); + } + + public sealed override string Text + { + get => base.Text; + set => base.Text = value; + } + + private void buttonOK_Click(object sender, EventArgs e) + { + Configuration.Settings.Tools.BridgeGapMilliseconds = (int)numericUpDownMaxMs.Value; + if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) + { + Configuration.Settings.Tools.BridgeGapMilliseconds = SubtitleFormat.FramesToMilliseconds((double)numericUpDownMaxMs.Value); + } + + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void GeneratePreview() + { + if (_refreshTimer.Enabled) + { + _refreshTimer.Stop(); + } + _refreshTimer.Start(); + } + + private void GeneratePreviewReal() + { + groupBoxLinesFound.Text = string.Empty; + if (_subtitle == null) + { + return; + } + + Cursor = Cursors.WaitCursor; + SubtitleListview1.Items.Clear(); + SubtitleListview1.BeginUpdate(); + FixedSubtitle = new Subtitle(_subtitle); + _dic = new Dictionary(); + var fixedIndexes = new List(FixedSubtitle.Paragraphs.Count); + var minMsBetweenLines = (int)numericUpDownMinMsBetweenLines.Value; + var maxMs = (double)numericUpDownMaxMs.Value; + if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) + { + minMsBetweenLines = SubtitleFormat.FramesToMilliseconds(minMsBetweenLines); + maxMs = SubtitleFormat.FramesToMilliseconds(maxMs); + } + + FixedCount = Core.Forms.DurationsBridgeGaps.BridgeGaps(FixedSubtitle, minMsBetweenLines, radioButtonDivideEven.Checked, maxMs, fixedIndexes, _dic, Configuration.Settings.General.UseTimeFormatHHMMSSFF); + SubtitleListview1.Fill(FixedSubtitle); + for (int i = 0; i < FixedSubtitle.Paragraphs.Count; i++) + { + var cur = FixedSubtitle.Paragraphs[i]; + if (_dic.ContainsKey(cur.Id)) + { + SubtitleListview1.SetExtraText(i, _dic[cur.Id], SubtitleListview1.ForeColor); + } + else + { + var info = string.Empty; + var next = FixedSubtitle.GetParagraphOrDefault(i + 1); + if (next != null) + { + var gap = next.StartTime.TotalMilliseconds - cur.EndTime.TotalMilliseconds; + info = $"{ gap / TimeCode.BaseUnit:0.000}"; + if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) + { + info = $"{ SubtitleFormat.MillisecondsToFrames(gap)}"; + } + } + SubtitleListview1.SetExtraText(i, info, SubtitleListview1.ForeColor); + } + + SubtitleListview1.SetBackgroundColor(i, SubtitleListview1.BackColor); + } + + foreach (var index in fixedIndexes) + { + SubtitleListview1.SetBackgroundColor(index, Color.LightGreen); + } + + SubtitleListview1.EndUpdate(); + groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.DurationsBridgeGaps.GapsBridgedX, FixedCount); + + Cursor = Cursors.Default; + } + + private void numericUpDownMaxMs_ValueChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void numericUpDownMinMsBetweenLines_ValueChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void DurationsBridgeGaps_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void DurationsBridgeGaps_Shown(object sender, EventArgs e) + { + SubtitleListview1.Focus(); + } + + private void numericUpDownMaxMs_Validated(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void numericUpDownMaxMs_KeyUp(object sender, KeyEventArgs e) + { + GeneratePreview(); + } + + private void numericUpDownMinMsBetweenLines_Validated(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void numericUpDownMinMsBetweenLines_KeyUp(object sender, KeyEventArgs e) + { + GeneratePreview(); + } + + private void SubtitleListView1_Resize(object sender, EventArgs e) + { + const int lastColumnWidth = 165; + var columnsCount = SubtitleListview1.Columns.Count - 1; + var width = 0; + for (int i = 0; i < columnsCount - 1; i++) + { + width += SubtitleListview1.Columns[i].Width; + } + SubtitleListview1.Columns[columnsCount - 1].Width = SubtitleListview1.Width - (width + lastColumnWidth); + SubtitleListview1.Columns[columnsCount].Width = -2; + } + + public void InitializeSettingsOnly() + { + groupBoxLinesFound.Enabled = false; + Height = MinimumSize.Height; + MaximizeBox = false; + MinimizeBox = false; + } + } +} diff --git a/src/Forms/Networking/NetworkJoin.resx b/src/ui/Forms/DurationsBridgeGaps.resx similarity index 100% rename from src/Forms/Networking/NetworkJoin.resx rename to src/ui/Forms/DurationsBridgeGaps.resx diff --git a/src/Forms/DvdStudioProProperties.Designer.cs b/src/ui/Forms/DvdStudioProProperties.Designer.cs similarity index 100% rename from src/Forms/DvdStudioProProperties.Designer.cs rename to src/ui/Forms/DvdStudioProProperties.Designer.cs diff --git a/src/Forms/DvdStudioProProperties.cs b/src/ui/Forms/DvdStudioProProperties.cs similarity index 100% rename from src/Forms/DvdStudioProProperties.cs rename to src/ui/Forms/DvdStudioProProperties.cs diff --git a/src/Forms/Networking/NetworkLogAndInfo.resx b/src/ui/Forms/DvdStudioProProperties.resx similarity index 100% rename from src/Forms/Networking/NetworkLogAndInfo.resx rename to src/ui/Forms/DvdStudioProProperties.resx diff --git a/src/Forms/DvdSubRip.Designer.cs b/src/ui/Forms/DvdSubRip.Designer.cs similarity index 98% rename from src/Forms/DvdSubRip.Designer.cs rename to src/ui/Forms/DvdSubRip.Designer.cs index 431c1cc3b..a5c3c9ef4 100644 --- a/src/Forms/DvdSubRip.Designer.cs +++ b/src/ui/Forms/DvdSubRip.Designer.cs @@ -1,327 +1,327 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class DvdSubRip - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonOpenIfo = new System.Windows.Forms.Button(); - this.textBoxIfoFileName = new System.Windows.Forms.TextBox(); - this.labelIfoFile = new System.Windows.Forms.Label(); - this.groupBoxDvd = new System.Windows.Forms.GroupBox(); - this.buttonClear = new System.Windows.Forms.Button(); - this.groupBoxLanguages = new System.Windows.Forms.GroupBox(); - this.comboBoxLanguages = new System.Windows.Forms.ComboBox(); - this.groupBoxPalNtsc = new System.Windows.Forms.GroupBox(); - this.radioButtonNtsc = new System.Windows.Forms.RadioButton(); - this.radioButtonPal = new System.Windows.Forms.RadioButton(); - this.ButtonRemoveVob = new System.Windows.Forms.Button(); - this.ButtonMoveVobDown = new System.Windows.Forms.Button(); - this.ButtonMoveVobUp = new System.Windows.Forms.Button(); - this.buttonAddVobFile = new System.Windows.Forms.Button(); - this.labelVobFiles = new System.Windows.Forms.Label(); - this.listBoxVobFiles = new System.Windows.Forms.ListBox(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.progressBarRip = new System.Windows.Forms.ProgressBar(); - this.labelStatus = new System.Windows.Forms.Label(); - this.buttonStartRipping = new System.Windows.Forms.Button(); - this.groupBoxDvd.SuspendLayout(); - this.groupBoxLanguages.SuspendLayout(); - this.groupBoxPalNtsc.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOpenIfo - // - this.buttonOpenIfo.Location = new System.Drawing.Point(447, 32); - this.buttonOpenIfo.Name = "buttonOpenIfo"; - this.buttonOpenIfo.Size = new System.Drawing.Size(29, 23); - this.buttonOpenIfo.TabIndex = 1; - this.buttonOpenIfo.Text = "..."; - this.buttonOpenIfo.UseVisualStyleBackColor = true; - this.buttonOpenIfo.Click += new System.EventHandler(this.ButtonOpenIfoClick); - // - // textBoxIfoFileName - // - this.textBoxIfoFileName.AllowDrop = true; - this.textBoxIfoFileName.Location = new System.Drawing.Point(6, 34); - this.textBoxIfoFileName.Name = "textBoxIfoFileName"; - this.textBoxIfoFileName.ReadOnly = true; - this.textBoxIfoFileName.Size = new System.Drawing.Size(435, 21); - this.textBoxIfoFileName.TabIndex = 0; - this.textBoxIfoFileName.DragDrop += new System.Windows.Forms.DragEventHandler(this.TextBoxIfoFileNameDragDrop); - this.textBoxIfoFileName.DragEnter += new System.Windows.Forms.DragEventHandler(this.TextBoxIfoFileNameDragEnter); - // - // labelIfoFile - // - this.labelIfoFile.AutoSize = true; - this.labelIfoFile.Location = new System.Drawing.Point(6, 17); - this.labelIfoFile.Name = "labelIfoFile"; - this.labelIfoFile.Size = new System.Drawing.Size(42, 13); - this.labelIfoFile.TabIndex = 2; - this.labelIfoFile.Text = "IFO file"; - // - // groupBoxDvd - // - this.groupBoxDvd.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxDvd.Controls.Add(this.buttonClear); - this.groupBoxDvd.Controls.Add(this.groupBoxLanguages); - this.groupBoxDvd.Controls.Add(this.groupBoxPalNtsc); - this.groupBoxDvd.Controls.Add(this.ButtonRemoveVob); - this.groupBoxDvd.Controls.Add(this.ButtonMoveVobDown); - this.groupBoxDvd.Controls.Add(this.ButtonMoveVobUp); - this.groupBoxDvd.Controls.Add(this.buttonAddVobFile); - this.groupBoxDvd.Controls.Add(this.labelVobFiles); - this.groupBoxDvd.Controls.Add(this.listBoxVobFiles); - this.groupBoxDvd.Controls.Add(this.labelIfoFile); - this.groupBoxDvd.Controls.Add(this.buttonOpenIfo); - this.groupBoxDvd.Controls.Add(this.textBoxIfoFileName); - this.groupBoxDvd.Location = new System.Drawing.Point(4, 4); - this.groupBoxDvd.Name = "groupBoxDvd"; - this.groupBoxDvd.Size = new System.Drawing.Size(544, 276); - this.groupBoxDvd.TabIndex = 3; - this.groupBoxDvd.TabStop = false; - this.groupBoxDvd.Text = "DVD files/info"; - // - // buttonClear - // - this.buttonClear.Location = new System.Drawing.Point(446, 133); - this.buttonClear.Name = "buttonClear"; - this.buttonClear.Size = new System.Drawing.Size(92, 23); - this.buttonClear.TabIndex = 9; - this.buttonClear.Text = "Clear"; - this.buttonClear.UseVisualStyleBackColor = true; - this.buttonClear.Click += new System.EventHandler(this.ButtonClearClick); - // - // groupBoxLanguages - // - this.groupBoxLanguages.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxLanguages.Controls.Add(this.comboBoxLanguages); - this.groupBoxLanguages.Location = new System.Drawing.Point(6, 218); - this.groupBoxLanguages.Name = "groupBoxLanguages"; - this.groupBoxLanguages.Size = new System.Drawing.Size(242, 52); - this.groupBoxLanguages.TabIndex = 14; - this.groupBoxLanguages.TabStop = false; - this.groupBoxLanguages.Text = "Languages"; - // - // comboBoxLanguages - // - this.comboBoxLanguages.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxLanguages.FormattingEnabled = true; - this.comboBoxLanguages.Location = new System.Drawing.Point(6, 18); - this.comboBoxLanguages.Name = "comboBoxLanguages"; - this.comboBoxLanguages.Size = new System.Drawing.Size(230, 21); - this.comboBoxLanguages.TabIndex = 14; - // - // groupBoxPalNtsc - // - this.groupBoxPalNtsc.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxPalNtsc.Controls.Add(this.radioButtonNtsc); - this.groupBoxPalNtsc.Controls.Add(this.radioButtonPal); - this.groupBoxPalNtsc.Location = new System.Drawing.Point(254, 218); - this.groupBoxPalNtsc.Name = "groupBoxPalNtsc"; - this.groupBoxPalNtsc.Size = new System.Drawing.Size(284, 52); - this.groupBoxPalNtsc.TabIndex = 20; - this.groupBoxPalNtsc.TabStop = false; - this.groupBoxPalNtsc.Text = "PAL/NTSC"; - // - // radioButtonNtsc - // - this.radioButtonNtsc.AutoSize = true; - this.radioButtonNtsc.Location = new System.Drawing.Point(104, 18); - this.radioButtonNtsc.Name = "radioButtonNtsc"; - this.radioButtonNtsc.Size = new System.Drawing.Size(105, 17); - this.radioButtonNtsc.TabIndex = 1; - this.radioButtonNtsc.TabStop = true; - this.radioButtonNtsc.Text = "NTSC (29.97fps)"; - this.radioButtonNtsc.UseVisualStyleBackColor = true; - // - // radioButtonPal - // - this.radioButtonPal.AutoSize = true; - this.radioButtonPal.Checked = true; - this.radioButtonPal.Location = new System.Drawing.Point(6, 19); - this.radioButtonPal.Name = "radioButtonPal"; - this.radioButtonPal.Size = new System.Drawing.Size(81, 17); - this.radioButtonPal.TabIndex = 0; - this.radioButtonPal.TabStop = true; - this.radioButtonPal.Text = "PAL (25fps)"; - this.radioButtonPal.UseVisualStyleBackColor = true; - // - // ButtonRemoveVob - // - this.ButtonRemoveVob.Location = new System.Drawing.Point(447, 105); - this.ButtonRemoveVob.Name = "ButtonRemoveVob"; - this.ButtonRemoveVob.Size = new System.Drawing.Size(91, 23); - this.ButtonRemoveVob.TabIndex = 8; - this.ButtonRemoveVob.Text = "Remove"; - this.ButtonRemoveVob.UseVisualStyleBackColor = true; - this.ButtonRemoveVob.Click += new System.EventHandler(this.ButtonRemoveVob_Click); - // - // ButtonMoveVobDown - // - this.ButtonMoveVobDown.Location = new System.Drawing.Point(446, 189); - this.ButtonMoveVobDown.Name = "ButtonMoveVobDown"; - this.ButtonMoveVobDown.Size = new System.Drawing.Size(92, 23); - this.ButtonMoveVobDown.TabIndex = 12; - this.ButtonMoveVobDown.Text = "Move down"; - this.ButtonMoveVobDown.UseVisualStyleBackColor = true; - this.ButtonMoveVobDown.Click += new System.EventHandler(this.ButtonMoveVobDown_Click); - // - // ButtonMoveVobUp - // - this.ButtonMoveVobUp.Location = new System.Drawing.Point(447, 161); - this.ButtonMoveVobUp.Name = "ButtonMoveVobUp"; - this.ButtonMoveVobUp.Size = new System.Drawing.Size(91, 23); - this.ButtonMoveVobUp.TabIndex = 10; - this.ButtonMoveVobUp.Text = "Move up"; - this.ButtonMoveVobUp.UseVisualStyleBackColor = true; - this.ButtonMoveVobUp.Click += new System.EventHandler(this.ButtonMoveVobUp_Click); - // - // buttonAddVobFile - // - this.buttonAddVobFile.Location = new System.Drawing.Point(447, 77); - this.buttonAddVobFile.Name = "buttonAddVobFile"; - this.buttonAddVobFile.Size = new System.Drawing.Size(91, 23); - this.buttonAddVobFile.TabIndex = 5; - this.buttonAddVobFile.Text = "Add..."; - this.buttonAddVobFile.UseVisualStyleBackColor = true; - this.buttonAddVobFile.Click += new System.EventHandler(this.ButtonAddVobFileClick); - // - // labelVobFiles - // - this.labelVobFiles.AutoSize = true; - this.labelVobFiles.Location = new System.Drawing.Point(6, 60); - this.labelVobFiles.Name = "labelVobFiles"; - this.labelVobFiles.Size = new System.Drawing.Size(49, 13); - this.labelVobFiles.TabIndex = 4; - this.labelVobFiles.Text = "VOB files"; - // - // listBoxVobFiles - // - this.listBoxVobFiles.AllowDrop = true; - this.listBoxVobFiles.FormattingEnabled = true; - this.listBoxVobFiles.Location = new System.Drawing.Point(6, 77); - this.listBoxVobFiles.Name = "listBoxVobFiles"; - this.listBoxVobFiles.Size = new System.Drawing.Size(435, 134); - this.listBoxVobFiles.TabIndex = 3; - this.listBoxVobFiles.DragDrop += new System.Windows.Forms.DragEventHandler(this.ListBoxVobFilesDragDrop); - this.listBoxVobFiles.DragEnter += new System.Windows.Forms.DragEventHandler(this.ListBoxVobFilesDragEnter); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // progressBarRip - // - this.progressBarRip.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.progressBarRip.Location = new System.Drawing.Point(133, 301); - this.progressBarRip.Name = "progressBarRip"; - this.progressBarRip.Size = new System.Drawing.Size(415, 15); - this.progressBarRip.TabIndex = 4; - this.progressBarRip.Visible = false; - // - // labelStatus - // - this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelStatus.AutoSize = true; - this.labelStatus.Location = new System.Drawing.Point(130, 284); - this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(38, 13); - this.labelStatus.TabIndex = 5; - this.labelStatus.Text = "Status"; - // - // buttonStartRipping - // - this.buttonStartRipping.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonStartRipping.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.buttonStartRipping.Location = new System.Drawing.Point(4, 287); - this.buttonStartRipping.Name = "buttonStartRipping"; - this.buttonStartRipping.Size = new System.Drawing.Size(120, 31); - this.buttonStartRipping.TabIndex = 25; - this.buttonStartRipping.Text = "Start ripping"; - this.buttonStartRipping.UseVisualStyleBackColor = true; - this.buttonStartRipping.Click += new System.EventHandler(this.ButtonStartRippingClick); - // - // DvdSubRip - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(554, 326); - this.Controls.Add(this.progressBarRip); - this.Controls.Add(this.buttonStartRipping); - this.Controls.Add(this.labelStatus); - this.Controls.Add(this.groupBoxDvd); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "DvdSubRip"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Rip subtitles from IFO/VOBs (DVD)"; - this.Shown += new System.EventHandler(this.DvdSubRip_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DvdSubRip_KeyDown); - this.groupBoxDvd.ResumeLayout(false); - this.groupBoxDvd.PerformLayout(); - this.groupBoxLanguages.ResumeLayout(false); - this.groupBoxPalNtsc.ResumeLayout(false); - this.groupBoxPalNtsc.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOpenIfo; - private System.Windows.Forms.TextBox textBoxIfoFileName; - private System.Windows.Forms.Label labelIfoFile; - private System.Windows.Forms.GroupBox groupBoxDvd; - private System.Windows.Forms.ListBox listBoxVobFiles; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Button ButtonRemoveVob; - private System.Windows.Forms.Button ButtonMoveVobDown; - private System.Windows.Forms.Button ButtonMoveVobUp; - private System.Windows.Forms.Button buttonAddVobFile; - private System.Windows.Forms.Label labelVobFiles; - private System.Windows.Forms.ProgressBar progressBarRip; - private System.Windows.Forms.Label labelStatus; - private System.Windows.Forms.Button buttonStartRipping; - private System.Windows.Forms.ComboBox comboBoxLanguages; - private System.Windows.Forms.GroupBox groupBoxLanguages; - private System.Windows.Forms.GroupBox groupBoxPalNtsc; - private System.Windows.Forms.RadioButton radioButtonNtsc; - private System.Windows.Forms.RadioButton radioButtonPal; - private System.Windows.Forms.Button buttonClear; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class DvdSubRip + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonOpenIfo = new System.Windows.Forms.Button(); + this.textBoxIfoFileName = new System.Windows.Forms.TextBox(); + this.labelIfoFile = new System.Windows.Forms.Label(); + this.groupBoxDvd = new System.Windows.Forms.GroupBox(); + this.buttonClear = new System.Windows.Forms.Button(); + this.groupBoxLanguages = new System.Windows.Forms.GroupBox(); + this.comboBoxLanguages = new System.Windows.Forms.ComboBox(); + this.groupBoxPalNtsc = new System.Windows.Forms.GroupBox(); + this.radioButtonNtsc = new System.Windows.Forms.RadioButton(); + this.radioButtonPal = new System.Windows.Forms.RadioButton(); + this.ButtonRemoveVob = new System.Windows.Forms.Button(); + this.ButtonMoveVobDown = new System.Windows.Forms.Button(); + this.ButtonMoveVobUp = new System.Windows.Forms.Button(); + this.buttonAddVobFile = new System.Windows.Forms.Button(); + this.labelVobFiles = new System.Windows.Forms.Label(); + this.listBoxVobFiles = new System.Windows.Forms.ListBox(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.progressBarRip = new System.Windows.Forms.ProgressBar(); + this.labelStatus = new System.Windows.Forms.Label(); + this.buttonStartRipping = new System.Windows.Forms.Button(); + this.groupBoxDvd.SuspendLayout(); + this.groupBoxLanguages.SuspendLayout(); + this.groupBoxPalNtsc.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOpenIfo + // + this.buttonOpenIfo.Location = new System.Drawing.Point(447, 32); + this.buttonOpenIfo.Name = "buttonOpenIfo"; + this.buttonOpenIfo.Size = new System.Drawing.Size(29, 23); + this.buttonOpenIfo.TabIndex = 1; + this.buttonOpenIfo.Text = "..."; + this.buttonOpenIfo.UseVisualStyleBackColor = true; + this.buttonOpenIfo.Click += new System.EventHandler(this.ButtonOpenIfoClick); + // + // textBoxIfoFileName + // + this.textBoxIfoFileName.AllowDrop = true; + this.textBoxIfoFileName.Location = new System.Drawing.Point(6, 34); + this.textBoxIfoFileName.Name = "textBoxIfoFileName"; + this.textBoxIfoFileName.ReadOnly = true; + this.textBoxIfoFileName.Size = new System.Drawing.Size(435, 21); + this.textBoxIfoFileName.TabIndex = 0; + this.textBoxIfoFileName.DragDrop += new System.Windows.Forms.DragEventHandler(this.TextBoxIfoFileNameDragDrop); + this.textBoxIfoFileName.DragEnter += new System.Windows.Forms.DragEventHandler(this.TextBoxIfoFileNameDragEnter); + // + // labelIfoFile + // + this.labelIfoFile.AutoSize = true; + this.labelIfoFile.Location = new System.Drawing.Point(6, 17); + this.labelIfoFile.Name = "labelIfoFile"; + this.labelIfoFile.Size = new System.Drawing.Size(42, 13); + this.labelIfoFile.TabIndex = 2; + this.labelIfoFile.Text = "IFO file"; + // + // groupBoxDvd + // + this.groupBoxDvd.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxDvd.Controls.Add(this.buttonClear); + this.groupBoxDvd.Controls.Add(this.groupBoxLanguages); + this.groupBoxDvd.Controls.Add(this.groupBoxPalNtsc); + this.groupBoxDvd.Controls.Add(this.ButtonRemoveVob); + this.groupBoxDvd.Controls.Add(this.ButtonMoveVobDown); + this.groupBoxDvd.Controls.Add(this.ButtonMoveVobUp); + this.groupBoxDvd.Controls.Add(this.buttonAddVobFile); + this.groupBoxDvd.Controls.Add(this.labelVobFiles); + this.groupBoxDvd.Controls.Add(this.listBoxVobFiles); + this.groupBoxDvd.Controls.Add(this.labelIfoFile); + this.groupBoxDvd.Controls.Add(this.buttonOpenIfo); + this.groupBoxDvd.Controls.Add(this.textBoxIfoFileName); + this.groupBoxDvd.Location = new System.Drawing.Point(4, 4); + this.groupBoxDvd.Name = "groupBoxDvd"; + this.groupBoxDvd.Size = new System.Drawing.Size(544, 276); + this.groupBoxDvd.TabIndex = 3; + this.groupBoxDvd.TabStop = false; + this.groupBoxDvd.Text = "DVD files/info"; + // + // buttonClear + // + this.buttonClear.Location = new System.Drawing.Point(446, 133); + this.buttonClear.Name = "buttonClear"; + this.buttonClear.Size = new System.Drawing.Size(92, 23); + this.buttonClear.TabIndex = 9; + this.buttonClear.Text = "Clear"; + this.buttonClear.UseVisualStyleBackColor = true; + this.buttonClear.Click += new System.EventHandler(this.ButtonClearClick); + // + // groupBoxLanguages + // + this.groupBoxLanguages.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxLanguages.Controls.Add(this.comboBoxLanguages); + this.groupBoxLanguages.Location = new System.Drawing.Point(6, 218); + this.groupBoxLanguages.Name = "groupBoxLanguages"; + this.groupBoxLanguages.Size = new System.Drawing.Size(242, 52); + this.groupBoxLanguages.TabIndex = 14; + this.groupBoxLanguages.TabStop = false; + this.groupBoxLanguages.Text = "Languages"; + // + // comboBoxLanguages + // + this.comboBoxLanguages.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxLanguages.FormattingEnabled = true; + this.comboBoxLanguages.Location = new System.Drawing.Point(6, 18); + this.comboBoxLanguages.Name = "comboBoxLanguages"; + this.comboBoxLanguages.Size = new System.Drawing.Size(230, 21); + this.comboBoxLanguages.TabIndex = 14; + // + // groupBoxPalNtsc + // + this.groupBoxPalNtsc.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxPalNtsc.Controls.Add(this.radioButtonNtsc); + this.groupBoxPalNtsc.Controls.Add(this.radioButtonPal); + this.groupBoxPalNtsc.Location = new System.Drawing.Point(254, 218); + this.groupBoxPalNtsc.Name = "groupBoxPalNtsc"; + this.groupBoxPalNtsc.Size = new System.Drawing.Size(284, 52); + this.groupBoxPalNtsc.TabIndex = 20; + this.groupBoxPalNtsc.TabStop = false; + this.groupBoxPalNtsc.Text = "PAL/NTSC"; + // + // radioButtonNtsc + // + this.radioButtonNtsc.AutoSize = true; + this.radioButtonNtsc.Location = new System.Drawing.Point(104, 18); + this.radioButtonNtsc.Name = "radioButtonNtsc"; + this.radioButtonNtsc.Size = new System.Drawing.Size(105, 17); + this.radioButtonNtsc.TabIndex = 1; + this.radioButtonNtsc.TabStop = true; + this.radioButtonNtsc.Text = "NTSC (29.97fps)"; + this.radioButtonNtsc.UseVisualStyleBackColor = true; + // + // radioButtonPal + // + this.radioButtonPal.AutoSize = true; + this.radioButtonPal.Checked = true; + this.radioButtonPal.Location = new System.Drawing.Point(6, 19); + this.radioButtonPal.Name = "radioButtonPal"; + this.radioButtonPal.Size = new System.Drawing.Size(81, 17); + this.radioButtonPal.TabIndex = 0; + this.radioButtonPal.TabStop = true; + this.radioButtonPal.Text = "PAL (25fps)"; + this.radioButtonPal.UseVisualStyleBackColor = true; + // + // ButtonRemoveVob + // + this.ButtonRemoveVob.Location = new System.Drawing.Point(447, 105); + this.ButtonRemoveVob.Name = "ButtonRemoveVob"; + this.ButtonRemoveVob.Size = new System.Drawing.Size(91, 23); + this.ButtonRemoveVob.TabIndex = 8; + this.ButtonRemoveVob.Text = "Remove"; + this.ButtonRemoveVob.UseVisualStyleBackColor = true; + this.ButtonRemoveVob.Click += new System.EventHandler(this.ButtonRemoveVob_Click); + // + // ButtonMoveVobDown + // + this.ButtonMoveVobDown.Location = new System.Drawing.Point(446, 189); + this.ButtonMoveVobDown.Name = "ButtonMoveVobDown"; + this.ButtonMoveVobDown.Size = new System.Drawing.Size(92, 23); + this.ButtonMoveVobDown.TabIndex = 12; + this.ButtonMoveVobDown.Text = "Move down"; + this.ButtonMoveVobDown.UseVisualStyleBackColor = true; + this.ButtonMoveVobDown.Click += new System.EventHandler(this.ButtonMoveVobDown_Click); + // + // ButtonMoveVobUp + // + this.ButtonMoveVobUp.Location = new System.Drawing.Point(447, 161); + this.ButtonMoveVobUp.Name = "ButtonMoveVobUp"; + this.ButtonMoveVobUp.Size = new System.Drawing.Size(91, 23); + this.ButtonMoveVobUp.TabIndex = 10; + this.ButtonMoveVobUp.Text = "Move up"; + this.ButtonMoveVobUp.UseVisualStyleBackColor = true; + this.ButtonMoveVobUp.Click += new System.EventHandler(this.ButtonMoveVobUp_Click); + // + // buttonAddVobFile + // + this.buttonAddVobFile.Location = new System.Drawing.Point(447, 77); + this.buttonAddVobFile.Name = "buttonAddVobFile"; + this.buttonAddVobFile.Size = new System.Drawing.Size(91, 23); + this.buttonAddVobFile.TabIndex = 5; + this.buttonAddVobFile.Text = "Add..."; + this.buttonAddVobFile.UseVisualStyleBackColor = true; + this.buttonAddVobFile.Click += new System.EventHandler(this.ButtonAddVobFileClick); + // + // labelVobFiles + // + this.labelVobFiles.AutoSize = true; + this.labelVobFiles.Location = new System.Drawing.Point(6, 60); + this.labelVobFiles.Name = "labelVobFiles"; + this.labelVobFiles.Size = new System.Drawing.Size(49, 13); + this.labelVobFiles.TabIndex = 4; + this.labelVobFiles.Text = "VOB files"; + // + // listBoxVobFiles + // + this.listBoxVobFiles.AllowDrop = true; + this.listBoxVobFiles.FormattingEnabled = true; + this.listBoxVobFiles.Location = new System.Drawing.Point(6, 77); + this.listBoxVobFiles.Name = "listBoxVobFiles"; + this.listBoxVobFiles.Size = new System.Drawing.Size(435, 134); + this.listBoxVobFiles.TabIndex = 3; + this.listBoxVobFiles.DragDrop += new System.Windows.Forms.DragEventHandler(this.ListBoxVobFilesDragDrop); + this.listBoxVobFiles.DragEnter += new System.Windows.Forms.DragEventHandler(this.ListBoxVobFilesDragEnter); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // progressBarRip + // + this.progressBarRip.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.progressBarRip.Location = new System.Drawing.Point(133, 301); + this.progressBarRip.Name = "progressBarRip"; + this.progressBarRip.Size = new System.Drawing.Size(415, 15); + this.progressBarRip.TabIndex = 4; + this.progressBarRip.Visible = false; + // + // labelStatus + // + this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(130, 284); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(38, 13); + this.labelStatus.TabIndex = 5; + this.labelStatus.Text = "Status"; + // + // buttonStartRipping + // + this.buttonStartRipping.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonStartRipping.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.buttonStartRipping.Location = new System.Drawing.Point(4, 287); + this.buttonStartRipping.Name = "buttonStartRipping"; + this.buttonStartRipping.Size = new System.Drawing.Size(120, 31); + this.buttonStartRipping.TabIndex = 25; + this.buttonStartRipping.Text = "Start ripping"; + this.buttonStartRipping.UseVisualStyleBackColor = true; + this.buttonStartRipping.Click += new System.EventHandler(this.ButtonStartRippingClick); + // + // DvdSubRip + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(554, 326); + this.Controls.Add(this.progressBarRip); + this.Controls.Add(this.buttonStartRipping); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.groupBoxDvd); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "DvdSubRip"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Rip subtitles from IFO/VOBs (DVD)"; + this.Shown += new System.EventHandler(this.DvdSubRip_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DvdSubRip_KeyDown); + this.groupBoxDvd.ResumeLayout(false); + this.groupBoxDvd.PerformLayout(); + this.groupBoxLanguages.ResumeLayout(false); + this.groupBoxPalNtsc.ResumeLayout(false); + this.groupBoxPalNtsc.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOpenIfo; + private System.Windows.Forms.TextBox textBoxIfoFileName; + private System.Windows.Forms.Label labelIfoFile; + private System.Windows.Forms.GroupBox groupBoxDvd; + private System.Windows.Forms.ListBox listBoxVobFiles; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Button ButtonRemoveVob; + private System.Windows.Forms.Button ButtonMoveVobDown; + private System.Windows.Forms.Button ButtonMoveVobUp; + private System.Windows.Forms.Button buttonAddVobFile; + private System.Windows.Forms.Label labelVobFiles; + private System.Windows.Forms.ProgressBar progressBarRip; + private System.Windows.Forms.Label labelStatus; + private System.Windows.Forms.Button buttonStartRipping; + private System.Windows.Forms.ComboBox comboBoxLanguages; + private System.Windows.Forms.GroupBox groupBoxLanguages; + private System.Windows.Forms.GroupBox groupBoxPalNtsc; + private System.Windows.Forms.RadioButton radioButtonNtsc; + private System.Windows.Forms.RadioButton radioButtonPal; + private System.Windows.Forms.Button buttonClear; + } } \ No newline at end of file diff --git a/src/Forms/DvdSubRip.cs b/src/ui/Forms/DvdSubRip.cs similarity index 97% rename from src/Forms/DvdSubRip.cs rename to src/ui/Forms/DvdSubRip.cs index a44d46e97..dd3dc27d6 100644 --- a/src/Forms/DvdSubRip.cs +++ b/src/ui/Forms/DvdSubRip.cs @@ -1,601 +1,601 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.VobSub; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class DvdSubRip : Form - { - private volatile bool _abort; - public List MergedVobSubPacks; - public List Palette; - public List Languages; - private readonly LanguageStructure.DvdSubRip _language; - private long _lastPresentationTimestamp; - private long _lastVobPresentationTimestamp; - private long _lastNavEndPts; - private long _accumulatedPresentationTimestamp; - private readonly IntPtr _taskbarFormHandle; - private string _initialFileName; - - public string SelectedLanguage - { - get - { - if (comboBoxLanguages.SelectedIndex >= 0) - { - return $"{comboBoxLanguages.Items[comboBoxLanguages.SelectedIndex]} (0x{comboBoxLanguages.SelectedIndex + 32:x})"; - } - - return string.Empty; - } - } - - public DvdSubRip(IntPtr taskbarFormHandle, string initialFileName) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _taskbarFormHandle = taskbarFormHandle; - _initialFileName = initialFileName; - labelStatus.Text = string.Empty; - buttonStartRipping.Enabled = false; - - _language = Configuration.Settings.Language.DvdSubRip; - Text = _language.Title; - groupBoxDvd.Text = _language.DvdGroupTitle; - labelIfoFile.Text = _language.IfoFile; - labelVobFiles.Text = _language.VobFiles; - groupBoxLanguages.Text = _language.Languages; - groupBoxPalNtsc.Text = _language.PalNtsc; - radioButtonPal.Text = _language.Pal; - radioButtonNtsc.Text = _language.Ntsc; - buttonStartRipping.Text = _language.StartRipping; - buttonAddVobFile.Text = _language.Add; - ButtonRemoveVob.Text = _language.Remove; - buttonClear.Text = _language.Clear; - ButtonMoveVobDown.Text = _language.MoveDown; - ButtonMoveVobUp.Text = _language.MoveUp; - - if (System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName == "en") - { - radioButtonNtsc.Checked = true; - } - else - { - radioButtonPal.Checked = true; - } - - UiUtil.FixLargeFonts(this, buttonAddVobFile); - } - - private void ButtonOpenIfoClick(object sender, EventArgs e) - { - openFileDialog1.Multiselect = false; - openFileDialog1.Filter = _language.IfoFiles + "|*.IFO"; - openFileDialog1.FileName = string.Empty; - if (openFileDialog1.ShowDialog() == DialogResult.OK && File.Exists(openFileDialog1.FileName)) - { - OpenIfoFile(openFileDialog1.FileName); - } - } - - private void OpenIfoFile(string fileName) - { - Clear(); - textBoxIfoFileName.Text = fileName; - - // List vob files - string path = Path.GetDirectoryName(fileName); - string onlyFileName = Path.GetFileNameWithoutExtension(fileName); - string searchPattern = onlyFileName.Substring(0, onlyFileName.Length - 1) + "?.VOB"; - listBoxVobFiles.Items.Clear(); - for (int i = 1; i < 30; i++) - { - string vobFileName = searchPattern.Replace("?", i.ToString(CultureInfo.InvariantCulture)); - if (File.Exists(Path.Combine(path, vobFileName))) - { - listBoxVobFiles.Items.Add(Path.Combine(path, vobFileName)); - } - } - - if (listBoxVobFiles.Items.Count == 0) - { - searchPattern = onlyFileName.Substring(0, onlyFileName.Length - 1) + "PGC_01_?.VOB"; - for (int i = 1; i < 30; i++) - { - string vobFileName = searchPattern.Replace("?", i.ToString(CultureInfo.InvariantCulture)); - if (File.Exists(Path.Combine(path, vobFileName))) - { - listBoxVobFiles.Items.Add(Path.Combine(path, vobFileName)); - } - } - } - - using (var ifoParser = new IfoParser(fileName)) - { - if (!string.IsNullOrEmpty(ifoParser.ErrorMessage)) - { - Clear(); - MessageBox.Show(ifoParser.ErrorMessage); - return; - } - - // List info - labelIfoFile.Text = _language.IfoFile + ": " + ifoParser.VideoTitleSetVobs.VideoStream.Resolution; - bool isPal = ifoParser.VideoTitleSetVobs.VideoStream.Standard.Equals("PAL", StringComparison.OrdinalIgnoreCase); - if (isPal) - { - radioButtonPal.Checked = true; - } - else - { - radioButtonNtsc.Checked = true; - } - - // List languages - comboBoxLanguages.Items.Clear(); - foreach (string s in ifoParser.VideoTitleSetVobs.GetAllLanguages()) - { - comboBoxLanguages.Items.Add(s); - } - - if (comboBoxLanguages.Items.Count > 0) - { - comboBoxLanguages.SelectedIndex = 0; - } - - // Save palette (Color LookUp Table) - if (ifoParser.VideoTitleSetProgramChainTable.ProgramChains.Count > 0) - { - Palette = ifoParser.VideoTitleSetProgramChainTable.ProgramChains[0].ColorLookupTable; - } - - ifoParser.Dispose(); - } - buttonStartRipping.Enabled = listBoxVobFiles.Items.Count > 0; - } - - private void ButtonStartRippingClick(object sender, EventArgs e) - { - if (buttonStartRipping.Text == _language.Abort) - { - _abort = true; - buttonStartRipping.Text = _language.StartRipping; - return; - } - _abort = false; - buttonStartRipping.Text = _language.Abort; - _lastPresentationTimestamp = 0; - _lastVobPresentationTimestamp = 0; - _lastNavEndPts = 0; - _accumulatedPresentationTimestamp = 0; - - progressBarRip.Visible = true; - var ms = new MemoryStream(); - int i = 0; - foreach (string vobFileName in listBoxVobFiles.Items) - { - i++; - labelStatus.Text = string.Format(_language.RippingVobFileXofYZ, Path.GetFileName(vobFileName), i, listBoxVobFiles.Items.Count); - Refresh(); - Application.DoEvents(); - - if (!_abort) - { - RipSubtitles(vobFileName, ms, i - 1); // Rip/demux subtitle vob packs - } - } - progressBarRip.Visible = false; - TaskbarList.SetProgressState(_taskbarFormHandle, TaskbarButtonProgressFlags.NoProgress); - buttonStartRipping.Enabled = false; - if (_abort) - { - labelStatus.Text = _language.AbortedByUser; - buttonStartRipping.Text = _language.StartRipping; - buttonStartRipping.Enabled = true; - return; - } - - labelStatus.Text = string.Format(_language.ReadingSubtitleData); - Refresh(); - Application.DoEvents(); - var vobSub = new VobSubParser(radioButtonPal.Checked); - vobSub.Open(ms); - ms.Close(); - labelStatus.Text = string.Empty; - - MergedVobSubPacks = vobSub.MergeVobSubPacks(); // Merge splitted-packs to whole-packs - if (MergedVobSubPacks.Count == 0) - { - MessageBox.Show(Configuration.Settings.Language.Main.NoSubtitlesFound); - buttonStartRipping.Text = _language.StartRipping; - buttonStartRipping.Enabled = true; - return; - } - Languages = new List(); - for (int k = 0; k < comboBoxLanguages.Items.Count; k++) - { - Languages.Add(comboBoxLanguages.Items[k].ToString()); - } - - buttonStartRipping.Text = _language.StartRipping; - buttonStartRipping.Enabled = true; - DialogResult = DialogResult.OK; - } - - /// - /// Opens an existing file for reading, and allow the user to retry if it fails. - /// - /// The file to be opened for reading. - /// A read-only on the specified path. - public static FileStream RetryOpenRead(string path) - { - FileStream fs = null; - while (fs == null) - { - try - { - fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - } - catch (IOException ex) - { - var result = MessageBox.Show(string.Format("An error occured while opening file: {0}", ex.Message), string.Empty, MessageBoxButtons.RetryCancel); - if (result == DialogResult.Cancel) - { - return null; - } - } - } - return fs; - } - - private void RipSubtitles(string vobFileName, MemoryStream stream, int vobNumber) - { - long firstNavStartPts = 0; - - using (var fs = RetryOpenRead(vobFileName)) - { - var buffer = new byte[0x800]; - long position = 0; - progressBarRip.Maximum = 100; - progressBarRip.Value = 0; - int lba = 0; - long length = fs.Length; - while (position < length && !_abort) - { - int bytesRead = 0; - - // Reading and test for IO errors... and allow abort/retry/ignore - var tryAgain = true; - while (tryAgain && position < length) - { - tryAgain = false; - try - { - fs.Seek(position, SeekOrigin.Begin); - bytesRead = fs.Read(buffer, 0, 0x800); - } - catch (IOException exception) - { - var result = MessageBox.Show(string.Format("An error occured while reading file: {0}", exception.Message), "", MessageBoxButtons.AbortRetryIgnore); - if (result == DialogResult.Abort) - { - return; - } - - if (result == DialogResult.Retry) - { - tryAgain = true; - } - - if (result == DialogResult.Ignore) - { - position += 0x800; - tryAgain = true; - } - } - } - - if (VobSubParser.IsMpeg2PackHeader(buffer)) - { - var vsp = new VobSubPack(buffer, null); - if (IsSubtitlePack(buffer)) - { - if (vsp.PacketizedElementaryStream.PresentationTimestamp.HasValue && _accumulatedPresentationTimestamp != 0) - { - UpdatePresentationTimestamp(buffer, _accumulatedPresentationTimestamp, vsp); - } - - stream.Write(buffer, 0, 0x800); - if (bytesRead < 0x800) - { - stream.Write(Encoding.ASCII.GetBytes(new string(' ', 0x800 - bytesRead)), 0, 0x800 - bytesRead); - } - } - else if (IsPrivateStream2(buffer, 0x26)) - { - if (Helper.GetEndian(buffer, 0x0026, 4) == 0x1bf && Helper.GetEndian(buffer, 0x0400, 4) == 0x1bf) - { - uint vobuSPtm = Helper.GetEndian(buffer, 0x0039, 4); - uint vobuEPtm = Helper.GetEndian(buffer, 0x003d, 4); - - _lastPresentationTimestamp = vobuEPtm; - - if (firstNavStartPts == 0) - { - firstNavStartPts = vobuSPtm; - if (vobNumber == 0) - { - _accumulatedPresentationTimestamp = -vobuSPtm; - } - } - if (vobuSPtm + firstNavStartPts + _accumulatedPresentationTimestamp < _lastVobPresentationTimestamp) - { - _accumulatedPresentationTimestamp += _lastNavEndPts - vobuSPtm; - } - else if (_lastNavEndPts > vobuEPtm) - { - _accumulatedPresentationTimestamp += _lastNavEndPts - vobuSPtm; - } - _lastNavEndPts = vobuEPtm; - } - } - } - position += 0x800; - - var progress = (int)((position * 100) / length); - if (progress != progressBarRip.Value) - { - progressBarRip.Value = progress; - TaskbarList.SetProgressValue(_taskbarFormHandle, (vobNumber * 100) + progressBarRip.Value, progressBarRip.Maximum * listBoxVobFiles.Items.Count); - Application.DoEvents(); - } - lba++; - } - } - _lastVobPresentationTimestamp = _lastPresentationTimestamp; - } - - /// - /// Write the 5 PTS bytes to buffer - /// - private static void UpdatePresentationTimestamp(byte[] buffer, long addPresentationTimestamp, VobSubPack vsp) - { - const int presentationTimestampIndex = 23; - long newPts = addPresentationTimestamp + ((long)vsp.PacketizedElementaryStream.PresentationTimestamp.Value); - - var buffer5B = BitConverter.GetBytes((UInt64)newPts); - if (BitConverter.IsLittleEndian) - { - buffer[presentationTimestampIndex + 4] = (byte)(buffer5B[0] << 1 | 0b00000001); // last 7 bits + '1' - buffer[presentationTimestampIndex + 3] = (byte)((buffer5B[0] >> 7) + (buffer5B[1] << 1)); // the next 8 bits (1 from last byte, 7 from next) - buffer[presentationTimestampIndex + 2] = (byte)((buffer5B[1] >> 6 | 0b00000001) + (buffer5B[2] << 2)); // the next 7 bits (1 from 2nd last byte, 6 from 3rd last byte) - buffer[presentationTimestampIndex + 1] = (byte)((buffer5B[2] >> 6) + (buffer5B[3] << 2)); // the next 8 bits (2 from 3rd last byte, 6 from 2rd last byte) - buffer[presentationTimestampIndex] = (byte)((buffer5B[3] >> 6 | 0b00000001) + (buffer5B[4] << 2)); - } - else - { - buffer[presentationTimestampIndex + 4] = (byte)(buffer5B[7] << 1 | 0b00000001); // last 7 bits + '1' - buffer[presentationTimestampIndex + 3] = (byte)((buffer5B[7] >> 7) + (buffer5B[6] << 1)); // the next 8 bits (1 from last byte, 7 from next) - buffer[presentationTimestampIndex + 2] = (byte)((buffer5B[6] >> 6 | 0b00000001) + (buffer5B[5] << 2)); // the next 7 bits (1 from 2nd last byte, 6 from 3rd last byte) - buffer[presentationTimestampIndex + 1] = (byte)((buffer5B[5] >> 6) + (buffer5B[4] << 2)); // the next 8 bits (2 from 3rd last byte, 6 from 2rd last byte) - buffer[presentationTimestampIndex] = (byte)((buffer5B[4] >> 6 | 0b00000001) + (buffer5B[3] << 2)); - } - if (vsp.PacketizedElementaryStream.PresentationTimestampDecodeTimestampFlags == 0b00000010) - { - buffer[presentationTimestampIndex] += 0b00100000; - } - else - { - buffer[presentationTimestampIndex] += 0b00110000; - } - } - - internal static bool IsPrivateStream2(byte[] buffer, int index) - { - return buffer.Length > index + 3 && - buffer[index + 0] == 0 && - buffer[index + 1] == 0 && - buffer[index + 2] == 1 && - buffer[index + 3] == 0xbf; - } - - private static bool IsSubtitlePack(byte[] buffer) - { - const int mpeg2HeaderLength = 14; - if (buffer[0] == 0 && - buffer[1] == 0 && - buffer[2] == 1 && - buffer[3] == 0xba) // 186 - MPEG-2 Pack Header - { - if (buffer[mpeg2HeaderLength + 0] == 0 && - buffer[mpeg2HeaderLength + 1] == 0 && - buffer[mpeg2HeaderLength + 2] == 1 && - buffer[mpeg2HeaderLength + 3] == 0xbd) // 189 - Private stream 1 (non MPEG audio, subpictures) - { - int pesHeaderDataLength = buffer[mpeg2HeaderLength + 8]; - int streamId = buffer[mpeg2HeaderLength + 8 + 1 + pesHeaderDataLength]; - if (streamId >= 0x20 && streamId <= 0x3f) // Subtitle IDs allowed (or x3f to x40?) - { - return true; - } - } - } - return false; - } - - private void ButtonAddVobFileClick(object sender, EventArgs e) - { - openFileDialog1.Filter = _language.VobFiles + "|*.VOB"; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Multiselect = true; - if (openFileDialog1.ShowDialog() == DialogResult.OK && File.Exists(openFileDialog1.FileName)) - { - foreach (var fileName in openFileDialog1.FileNames) - { - listBoxVobFiles.Items.Add(fileName); - } - } - buttonStartRipping.Enabled = listBoxVobFiles.Items.Count > 0; - } - - private void ButtonMoveVobUp_Click(object sender, EventArgs e) - { - if (listBoxVobFiles.SelectedIndex > 0) - { - int index = listBoxVobFiles.SelectedIndex; - string old = listBoxVobFiles.Items[index].ToString(); - listBoxVobFiles.Items.RemoveAt(index); - listBoxVobFiles.Items.Insert(index - 1, old); - listBoxVobFiles.SelectedIndex = index - 1; - } - } - - private void ButtonMoveVobDown_Click(object sender, EventArgs e) - { - if (listBoxVobFiles.SelectedIndex >= 0 && listBoxVobFiles.SelectedIndex < listBoxVobFiles.Items.Count - 1) - { - int index = listBoxVobFiles.SelectedIndex; - string old = listBoxVobFiles.Items[index].ToString(); - listBoxVobFiles.Items.RemoveAt(index); - listBoxVobFiles.Items.Insert(index + 1, old); - listBoxVobFiles.SelectedIndex = index + 1; - } - } - - private void ButtonRemoveVob_Click(object sender, EventArgs e) - { - if (listBoxVobFiles.SelectedIndex >= 0) - { - int index = listBoxVobFiles.SelectedIndex; - listBoxVobFiles.Items.RemoveAt(index); - if (index < listBoxVobFiles.Items.Count) - { - listBoxVobFiles.SelectedIndex = index; - } - else if (index > 0) - { - listBoxVobFiles.SelectedIndex = index - 1; - } - - buttonStartRipping.Enabled = listBoxVobFiles.Items.Count > 0; - - if (listBoxVobFiles.Items.Count == 0) - { - Clear(); - } - } - } - - private void TextBoxIfoFileNameDragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) - { - e.Effect = DragDropEffects.All; - } - } - - private void TextBoxIfoFileNameDragDrop(object sender, DragEventArgs e) - { - var files = (string[])e.Data.GetData(DataFormats.FileDrop); - if (files.Length >= 1) - { - string fileName = files[0]; - - var fi = new FileInfo(fileName); - if (fi.Length < 1024 * 1024 * 2) // max 2 mb - { - if (fi.Extension.ToLowerInvariant() == ".ifo") - { - OpenIfoFile(fileName); - } - } - } - } - - private void ListBoxVobFilesDragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) - { - e.Effect = DragDropEffects.All; - } - } - - private void ListBoxVobFilesDragDrop(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) - { - e.Effect = DragDropEffects.All; - } - - var files = (string[])e.Data.GetData(DataFormats.FileDrop); - foreach (string fileName in files) - { - if (fileName.EndsWith(".vob", StringComparison.InvariantCultureIgnoreCase)) - { - listBoxVobFiles.Items.Add(fileName); - } - } - buttonStartRipping.Enabled = listBoxVobFiles.Items.Count > 0; - } - - private void ButtonClearClick(object sender, EventArgs e) - { - Clear(); - } - - private void Clear() - { - textBoxIfoFileName.Text = string.Empty; - listBoxVobFiles.Items.Clear(); - buttonStartRipping.Enabled = false; - comboBoxLanguages.Items.Clear(); - labelIfoFile.Text = _language.IfoFile; - } - - private void DvdSubRip_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - if (buttonStartRipping.Text == _language.Abort) - { - ButtonStartRippingClick(sender, e); - } - else - { - e.SuppressKeyPress = true; - DialogResult = DialogResult.Cancel; - } - } - } - - private void DvdSubRip_Shown(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(_initialFileName)) - { - return; - } - - if (_initialFileName.EndsWith(".ifo", StringComparison.InvariantCultureIgnoreCase)) - { - OpenIfoFile(_initialFileName); - } - else if (_initialFileName.EndsWith(".vob", StringComparison.InvariantCultureIgnoreCase)) - { - listBoxVobFiles.Items.Add(_initialFileName); - buttonStartRipping.Enabled = true; - } - _initialFileName = null; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.VobSub; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class DvdSubRip : Form + { + private volatile bool _abort; + public List MergedVobSubPacks; + public List Palette; + public List Languages; + private readonly LanguageStructure.DvdSubRip _language; + private long _lastPresentationTimestamp; + private long _lastVobPresentationTimestamp; + private long _lastNavEndPts; + private long _accumulatedPresentationTimestamp; + private readonly IntPtr _taskbarFormHandle; + private string _initialFileName; + + public string SelectedLanguage + { + get + { + if (comboBoxLanguages.SelectedIndex >= 0) + { + return $"{comboBoxLanguages.Items[comboBoxLanguages.SelectedIndex]} (0x{comboBoxLanguages.SelectedIndex + 32:x})"; + } + + return string.Empty; + } + } + + public DvdSubRip(IntPtr taskbarFormHandle, string initialFileName) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _taskbarFormHandle = taskbarFormHandle; + _initialFileName = initialFileName; + labelStatus.Text = string.Empty; + buttonStartRipping.Enabled = false; + + _language = Configuration.Settings.Language.DvdSubRip; + Text = _language.Title; + groupBoxDvd.Text = _language.DvdGroupTitle; + labelIfoFile.Text = _language.IfoFile; + labelVobFiles.Text = _language.VobFiles; + groupBoxLanguages.Text = _language.Languages; + groupBoxPalNtsc.Text = _language.PalNtsc; + radioButtonPal.Text = _language.Pal; + radioButtonNtsc.Text = _language.Ntsc; + buttonStartRipping.Text = _language.StartRipping; + buttonAddVobFile.Text = _language.Add; + ButtonRemoveVob.Text = _language.Remove; + buttonClear.Text = _language.Clear; + ButtonMoveVobDown.Text = _language.MoveDown; + ButtonMoveVobUp.Text = _language.MoveUp; + + if (System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName == "en") + { + radioButtonNtsc.Checked = true; + } + else + { + radioButtonPal.Checked = true; + } + + UiUtil.FixLargeFonts(this, buttonAddVobFile); + } + + private void ButtonOpenIfoClick(object sender, EventArgs e) + { + openFileDialog1.Multiselect = false; + openFileDialog1.Filter = _language.IfoFiles + "|*.IFO"; + openFileDialog1.FileName = string.Empty; + if (openFileDialog1.ShowDialog() == DialogResult.OK && File.Exists(openFileDialog1.FileName)) + { + OpenIfoFile(openFileDialog1.FileName); + } + } + + private void OpenIfoFile(string fileName) + { + Clear(); + textBoxIfoFileName.Text = fileName; + + // List vob files + string path = Path.GetDirectoryName(fileName); + string onlyFileName = Path.GetFileNameWithoutExtension(fileName); + string searchPattern = onlyFileName.Substring(0, onlyFileName.Length - 1) + "?.VOB"; + listBoxVobFiles.Items.Clear(); + for (int i = 1; i < 30; i++) + { + string vobFileName = searchPattern.Replace("?", i.ToString(CultureInfo.InvariantCulture)); + if (File.Exists(Path.Combine(path, vobFileName))) + { + listBoxVobFiles.Items.Add(Path.Combine(path, vobFileName)); + } + } + + if (listBoxVobFiles.Items.Count == 0) + { + searchPattern = onlyFileName.Substring(0, onlyFileName.Length - 1) + "PGC_01_?.VOB"; + for (int i = 1; i < 30; i++) + { + string vobFileName = searchPattern.Replace("?", i.ToString(CultureInfo.InvariantCulture)); + if (File.Exists(Path.Combine(path, vobFileName))) + { + listBoxVobFiles.Items.Add(Path.Combine(path, vobFileName)); + } + } + } + + using (var ifoParser = new IfoParser(fileName)) + { + if (!string.IsNullOrEmpty(ifoParser.ErrorMessage)) + { + Clear(); + MessageBox.Show(ifoParser.ErrorMessage); + return; + } + + // List info + labelIfoFile.Text = _language.IfoFile + ": " + ifoParser.VideoTitleSetVobs.VideoStream.Resolution; + bool isPal = ifoParser.VideoTitleSetVobs.VideoStream.Standard.Equals("PAL", StringComparison.OrdinalIgnoreCase); + if (isPal) + { + radioButtonPal.Checked = true; + } + else + { + radioButtonNtsc.Checked = true; + } + + // List languages + comboBoxLanguages.Items.Clear(); + foreach (string s in ifoParser.VideoTitleSetVobs.GetAllLanguages()) + { + comboBoxLanguages.Items.Add(s); + } + + if (comboBoxLanguages.Items.Count > 0) + { + comboBoxLanguages.SelectedIndex = 0; + } + + // Save palette (Color LookUp Table) + if (ifoParser.VideoTitleSetProgramChainTable.ProgramChains.Count > 0) + { + Palette = ifoParser.VideoTitleSetProgramChainTable.ProgramChains[0].ColorLookupTable; + } + + ifoParser.Dispose(); + } + buttonStartRipping.Enabled = listBoxVobFiles.Items.Count > 0; + } + + private void ButtonStartRippingClick(object sender, EventArgs e) + { + if (buttonStartRipping.Text == _language.Abort) + { + _abort = true; + buttonStartRipping.Text = _language.StartRipping; + return; + } + _abort = false; + buttonStartRipping.Text = _language.Abort; + _lastPresentationTimestamp = 0; + _lastVobPresentationTimestamp = 0; + _lastNavEndPts = 0; + _accumulatedPresentationTimestamp = 0; + + progressBarRip.Visible = true; + var ms = new MemoryStream(); + int i = 0; + foreach (string vobFileName in listBoxVobFiles.Items) + { + i++; + labelStatus.Text = string.Format(_language.RippingVobFileXofYZ, Path.GetFileName(vobFileName), i, listBoxVobFiles.Items.Count); + Refresh(); + Application.DoEvents(); + + if (!_abort) + { + RipSubtitles(vobFileName, ms, i - 1); // Rip/demux subtitle vob packs + } + } + progressBarRip.Visible = false; + TaskbarList.SetProgressState(_taskbarFormHandle, TaskbarButtonProgressFlags.NoProgress); + buttonStartRipping.Enabled = false; + if (_abort) + { + labelStatus.Text = _language.AbortedByUser; + buttonStartRipping.Text = _language.StartRipping; + buttonStartRipping.Enabled = true; + return; + } + + labelStatus.Text = string.Format(_language.ReadingSubtitleData); + Refresh(); + Application.DoEvents(); + var vobSub = new VobSubParser(radioButtonPal.Checked); + vobSub.Open(ms); + ms.Close(); + labelStatus.Text = string.Empty; + + MergedVobSubPacks = vobSub.MergeVobSubPacks(); // Merge splitted-packs to whole-packs + if (MergedVobSubPacks.Count == 0) + { + MessageBox.Show(Configuration.Settings.Language.Main.NoSubtitlesFound); + buttonStartRipping.Text = _language.StartRipping; + buttonStartRipping.Enabled = true; + return; + } + Languages = new List(); + for (int k = 0; k < comboBoxLanguages.Items.Count; k++) + { + Languages.Add(comboBoxLanguages.Items[k].ToString()); + } + + buttonStartRipping.Text = _language.StartRipping; + buttonStartRipping.Enabled = true; + DialogResult = DialogResult.OK; + } + + /// + /// Opens an existing file for reading, and allow the user to retry if it fails. + /// + /// The file to be opened for reading. + /// A read-only on the specified path. + public static FileStream RetryOpenRead(string path) + { + FileStream fs = null; + while (fs == null) + { + try + { + fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + } + catch (IOException ex) + { + var result = MessageBox.Show(string.Format("An error occured while opening file: {0}", ex.Message), string.Empty, MessageBoxButtons.RetryCancel); + if (result == DialogResult.Cancel) + { + return null; + } + } + } + return fs; + } + + private void RipSubtitles(string vobFileName, MemoryStream stream, int vobNumber) + { + long firstNavStartPts = 0; + + using (var fs = RetryOpenRead(vobFileName)) + { + var buffer = new byte[0x800]; + long position = 0; + progressBarRip.Maximum = 100; + progressBarRip.Value = 0; + int lba = 0; + long length = fs.Length; + while (position < length && !_abort) + { + int bytesRead = 0; + + // Reading and test for IO errors... and allow abort/retry/ignore + var tryAgain = true; + while (tryAgain && position < length) + { + tryAgain = false; + try + { + fs.Seek(position, SeekOrigin.Begin); + bytesRead = fs.Read(buffer, 0, 0x800); + } + catch (IOException exception) + { + var result = MessageBox.Show(string.Format("An error occured while reading file: {0}", exception.Message), "", MessageBoxButtons.AbortRetryIgnore); + if (result == DialogResult.Abort) + { + return; + } + + if (result == DialogResult.Retry) + { + tryAgain = true; + } + + if (result == DialogResult.Ignore) + { + position += 0x800; + tryAgain = true; + } + } + } + + if (VobSubParser.IsMpeg2PackHeader(buffer)) + { + var vsp = new VobSubPack(buffer, null); + if (IsSubtitlePack(buffer)) + { + if (vsp.PacketizedElementaryStream.PresentationTimestamp.HasValue && _accumulatedPresentationTimestamp != 0) + { + UpdatePresentationTimestamp(buffer, _accumulatedPresentationTimestamp, vsp); + } + + stream.Write(buffer, 0, 0x800); + if (bytesRead < 0x800) + { + stream.Write(Encoding.ASCII.GetBytes(new string(' ', 0x800 - bytesRead)), 0, 0x800 - bytesRead); + } + } + else if (IsPrivateStream2(buffer, 0x26)) + { + if (Helper.GetEndian(buffer, 0x0026, 4) == 0x1bf && Helper.GetEndian(buffer, 0x0400, 4) == 0x1bf) + { + uint vobuSPtm = Helper.GetEndian(buffer, 0x0039, 4); + uint vobuEPtm = Helper.GetEndian(buffer, 0x003d, 4); + + _lastPresentationTimestamp = vobuEPtm; + + if (firstNavStartPts == 0) + { + firstNavStartPts = vobuSPtm; + if (vobNumber == 0) + { + _accumulatedPresentationTimestamp = -vobuSPtm; + } + } + if (vobuSPtm + firstNavStartPts + _accumulatedPresentationTimestamp < _lastVobPresentationTimestamp) + { + _accumulatedPresentationTimestamp += _lastNavEndPts - vobuSPtm; + } + else if (_lastNavEndPts > vobuEPtm) + { + _accumulatedPresentationTimestamp += _lastNavEndPts - vobuSPtm; + } + _lastNavEndPts = vobuEPtm; + } + } + } + position += 0x800; + + var progress = (int)((position * 100) / length); + if (progress != progressBarRip.Value) + { + progressBarRip.Value = progress; + TaskbarList.SetProgressValue(_taskbarFormHandle, (vobNumber * 100) + progressBarRip.Value, progressBarRip.Maximum * listBoxVobFiles.Items.Count); + Application.DoEvents(); + } + lba++; + } + } + _lastVobPresentationTimestamp = _lastPresentationTimestamp; + } + + /// + /// Write the 5 PTS bytes to buffer + /// + private static void UpdatePresentationTimestamp(byte[] buffer, long addPresentationTimestamp, VobSubPack vsp) + { + const int presentationTimestampIndex = 23; + long newPts = addPresentationTimestamp + ((long)vsp.PacketizedElementaryStream.PresentationTimestamp.Value); + + var buffer5B = BitConverter.GetBytes((UInt64)newPts); + if (BitConverter.IsLittleEndian) + { + buffer[presentationTimestampIndex + 4] = (byte)(buffer5B[0] << 1 | 0b00000001); // last 7 bits + '1' + buffer[presentationTimestampIndex + 3] = (byte)((buffer5B[0] >> 7) + (buffer5B[1] << 1)); // the next 8 bits (1 from last byte, 7 from next) + buffer[presentationTimestampIndex + 2] = (byte)((buffer5B[1] >> 6 | 0b00000001) + (buffer5B[2] << 2)); // the next 7 bits (1 from 2nd last byte, 6 from 3rd last byte) + buffer[presentationTimestampIndex + 1] = (byte)((buffer5B[2] >> 6) + (buffer5B[3] << 2)); // the next 8 bits (2 from 3rd last byte, 6 from 2rd last byte) + buffer[presentationTimestampIndex] = (byte)((buffer5B[3] >> 6 | 0b00000001) + (buffer5B[4] << 2)); + } + else + { + buffer[presentationTimestampIndex + 4] = (byte)(buffer5B[7] << 1 | 0b00000001); // last 7 bits + '1' + buffer[presentationTimestampIndex + 3] = (byte)((buffer5B[7] >> 7) + (buffer5B[6] << 1)); // the next 8 bits (1 from last byte, 7 from next) + buffer[presentationTimestampIndex + 2] = (byte)((buffer5B[6] >> 6 | 0b00000001) + (buffer5B[5] << 2)); // the next 7 bits (1 from 2nd last byte, 6 from 3rd last byte) + buffer[presentationTimestampIndex + 1] = (byte)((buffer5B[5] >> 6) + (buffer5B[4] << 2)); // the next 8 bits (2 from 3rd last byte, 6 from 2rd last byte) + buffer[presentationTimestampIndex] = (byte)((buffer5B[4] >> 6 | 0b00000001) + (buffer5B[3] << 2)); + } + if (vsp.PacketizedElementaryStream.PresentationTimestampDecodeTimestampFlags == 0b00000010) + { + buffer[presentationTimestampIndex] += 0b00100000; + } + else + { + buffer[presentationTimestampIndex] += 0b00110000; + } + } + + internal static bool IsPrivateStream2(byte[] buffer, int index) + { + return buffer.Length > index + 3 && + buffer[index + 0] == 0 && + buffer[index + 1] == 0 && + buffer[index + 2] == 1 && + buffer[index + 3] == 0xbf; + } + + private static bool IsSubtitlePack(byte[] buffer) + { + const int mpeg2HeaderLength = 14; + if (buffer[0] == 0 && + buffer[1] == 0 && + buffer[2] == 1 && + buffer[3] == 0xba) // 186 - MPEG-2 Pack Header + { + if (buffer[mpeg2HeaderLength + 0] == 0 && + buffer[mpeg2HeaderLength + 1] == 0 && + buffer[mpeg2HeaderLength + 2] == 1 && + buffer[mpeg2HeaderLength + 3] == 0xbd) // 189 - Private stream 1 (non MPEG audio, subpictures) + { + int pesHeaderDataLength = buffer[mpeg2HeaderLength + 8]; + int streamId = buffer[mpeg2HeaderLength + 8 + 1 + pesHeaderDataLength]; + if (streamId >= 0x20 && streamId <= 0x3f) // Subtitle IDs allowed (or x3f to x40?) + { + return true; + } + } + } + return false; + } + + private void ButtonAddVobFileClick(object sender, EventArgs e) + { + openFileDialog1.Filter = _language.VobFiles + "|*.VOB"; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Multiselect = true; + if (openFileDialog1.ShowDialog() == DialogResult.OK && File.Exists(openFileDialog1.FileName)) + { + foreach (var fileName in openFileDialog1.FileNames) + { + listBoxVobFiles.Items.Add(fileName); + } + } + buttonStartRipping.Enabled = listBoxVobFiles.Items.Count > 0; + } + + private void ButtonMoveVobUp_Click(object sender, EventArgs e) + { + if (listBoxVobFiles.SelectedIndex > 0) + { + int index = listBoxVobFiles.SelectedIndex; + string old = listBoxVobFiles.Items[index].ToString(); + listBoxVobFiles.Items.RemoveAt(index); + listBoxVobFiles.Items.Insert(index - 1, old); + listBoxVobFiles.SelectedIndex = index - 1; + } + } + + private void ButtonMoveVobDown_Click(object sender, EventArgs e) + { + if (listBoxVobFiles.SelectedIndex >= 0 && listBoxVobFiles.SelectedIndex < listBoxVobFiles.Items.Count - 1) + { + int index = listBoxVobFiles.SelectedIndex; + string old = listBoxVobFiles.Items[index].ToString(); + listBoxVobFiles.Items.RemoveAt(index); + listBoxVobFiles.Items.Insert(index + 1, old); + listBoxVobFiles.SelectedIndex = index + 1; + } + } + + private void ButtonRemoveVob_Click(object sender, EventArgs e) + { + if (listBoxVobFiles.SelectedIndex >= 0) + { + int index = listBoxVobFiles.SelectedIndex; + listBoxVobFiles.Items.RemoveAt(index); + if (index < listBoxVobFiles.Items.Count) + { + listBoxVobFiles.SelectedIndex = index; + } + else if (index > 0) + { + listBoxVobFiles.SelectedIndex = index - 1; + } + + buttonStartRipping.Enabled = listBoxVobFiles.Items.Count > 0; + + if (listBoxVobFiles.Items.Count == 0) + { + Clear(); + } + } + } + + private void TextBoxIfoFileNameDragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.All; + } + } + + private void TextBoxIfoFileNameDragDrop(object sender, DragEventArgs e) + { + var files = (string[])e.Data.GetData(DataFormats.FileDrop); + if (files.Length >= 1) + { + string fileName = files[0]; + + var fi = new FileInfo(fileName); + if (fi.Length < 1024 * 1024 * 2) // max 2 mb + { + if (fi.Extension.ToLowerInvariant() == ".ifo") + { + OpenIfoFile(fileName); + } + } + } + } + + private void ListBoxVobFilesDragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.All; + } + } + + private void ListBoxVobFilesDragDrop(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.All; + } + + var files = (string[])e.Data.GetData(DataFormats.FileDrop); + foreach (string fileName in files) + { + if (fileName.EndsWith(".vob", StringComparison.InvariantCultureIgnoreCase)) + { + listBoxVobFiles.Items.Add(fileName); + } + } + buttonStartRipping.Enabled = listBoxVobFiles.Items.Count > 0; + } + + private void ButtonClearClick(object sender, EventArgs e) + { + Clear(); + } + + private void Clear() + { + textBoxIfoFileName.Text = string.Empty; + listBoxVobFiles.Items.Clear(); + buttonStartRipping.Enabled = false; + comboBoxLanguages.Items.Clear(); + labelIfoFile.Text = _language.IfoFile; + } + + private void DvdSubRip_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + if (buttonStartRipping.Text == _language.Abort) + { + ButtonStartRippingClick(sender, e); + } + else + { + e.SuppressKeyPress = true; + DialogResult = DialogResult.Cancel; + } + } + } + + private void DvdSubRip_Shown(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(_initialFileName)) + { + return; + } + + if (_initialFileName.EndsWith(".ifo", StringComparison.InvariantCultureIgnoreCase)) + { + OpenIfoFile(_initialFileName); + } + else if (_initialFileName.EndsWith(".vob", StringComparison.InvariantCultureIgnoreCase)) + { + listBoxVobFiles.Items.Add(_initialFileName); + buttonStartRipping.Enabled = true; + } + _initialFileName = null; + } + + } +} diff --git a/src/Forms/DvdSubRip.resx b/src/ui/Forms/DvdSubRip.resx similarity index 97% rename from src/Forms/DvdSubRip.resx rename to src/ui/Forms/DvdSubRip.resx index 3a7d67153..9bad2f599 100644 --- a/src/Forms/DvdSubRip.resx +++ b/src/ui/Forms/DvdSubRip.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/DvdSubRipChooseLanguage.Designer.cs b/src/ui/Forms/DvdSubRipChooseLanguage.Designer.cs similarity index 98% rename from src/Forms/DvdSubRipChooseLanguage.Designer.cs rename to src/ui/Forms/DvdSubRipChooseLanguage.Designer.cs index bb9009b3b..ba5183452 100644 --- a/src/Forms/DvdSubRipChooseLanguage.Designer.cs +++ b/src/ui/Forms/DvdSubRipChooseLanguage.Designer.cs @@ -1,176 +1,176 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class DvdSubRipChooseLanguage - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.listBox1 = new System.Windows.Forms.ListBox(); - this.pictureBoxImage = new System.Windows.Forms.PictureBox(); - this.comboBoxLanguages = new System.Windows.Forms.ComboBox(); - this.labelChooseLanguage = new System.Windows.Forms.Label(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxImage = new System.Windows.Forms.GroupBox(); - this.buttonSaveAs = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxImage)).BeginInit(); - this.groupBoxImage.SuspendLayout(); - this.SuspendLayout(); - // - // listBox1 - // - this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.listBox1.FormattingEnabled = true; - this.listBox1.Location = new System.Drawing.Point(5, 57); - this.listBox1.Name = "listBox1"; - this.listBox1.Size = new System.Drawing.Size(298, 212); - this.listBox1.TabIndex = 1; - this.listBox1.SelectedIndexChanged += new System.EventHandler(this.ListBox1SelectedIndexChanged); - // - // pictureBoxImage - // - this.pictureBoxImage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.pictureBoxImage.Location = new System.Drawing.Point(6, 19); - this.pictureBoxImage.Name = "pictureBoxImage"; - this.pictureBoxImage.Size = new System.Drawing.Size(452, 214); - this.pictureBoxImage.TabIndex = 1; - this.pictureBoxImage.TabStop = false; - // - // comboBoxLanguages - // - this.comboBoxLanguages.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxLanguages.FormattingEnabled = true; - this.comboBoxLanguages.Location = new System.Drawing.Point(6, 30); - this.comboBoxLanguages.Name = "comboBoxLanguages"; - this.comboBoxLanguages.Size = new System.Drawing.Size(297, 21); - this.comboBoxLanguages.TabIndex = 0; - this.comboBoxLanguages.SelectedIndexChanged += new System.EventHandler(this.ComboBoxLanguagesSelectedIndexChanged); - // - // labelChooseLanguage - // - this.labelChooseLanguage.AutoSize = true; - this.labelChooseLanguage.Location = new System.Drawing.Point(6, 11); - this.labelChooseLanguage.Name = "labelChooseLanguage"; - this.labelChooseLanguage.Size = new System.Drawing.Size(146, 13); - this.labelChooseLanguage.TabIndex = 3; - this.labelChooseLanguage.Text = "Choose language (stream-id)"; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(692, 281); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(487, 281); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // groupBoxImage - // - this.groupBoxImage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxImage.Controls.Add(this.pictureBoxImage); - this.groupBoxImage.Location = new System.Drawing.Point(309, 30); - this.groupBoxImage.Name = "groupBoxImage"; - this.groupBoxImage.Size = new System.Drawing.Size(464, 239); - this.groupBoxImage.TabIndex = 2; - this.groupBoxImage.TabStop = false; - this.groupBoxImage.Text = "Subtitle image"; - // - // buttonSaveAs - // - this.buttonSaveAs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSaveAs.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonSaveAs.Location = new System.Drawing.Point(568, 281); - this.buttonSaveAs.Name = "buttonSaveAs"; - this.buttonSaveAs.Size = new System.Drawing.Size(118, 23); - this.buttonSaveAs.TabIndex = 4; - this.buttonSaveAs.Text = "Save as..."; - this.buttonSaveAs.UseVisualStyleBackColor = true; - this.buttonSaveAs.Click += new System.EventHandler(this.buttonSaveAs_Click); - // - // DvdSubRipChooseLanguage - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(779, 314); - this.Controls.Add(this.buttonSaveAs); - this.Controls.Add(this.groupBoxImage); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.labelChooseLanguage); - this.Controls.Add(this.comboBoxLanguages); - this.Controls.Add(this.listBox1); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(700, 350); - this.Name = "DvdSubRipChooseLanguage"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Choose language"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DvdSubRipShowSubtitles_KeyDown); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxImage)).EndInit(); - this.groupBoxImage.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ListBox listBox1; - private System.Windows.Forms.PictureBox pictureBoxImage; - private System.Windows.Forms.ComboBox comboBoxLanguages; - private System.Windows.Forms.Label labelChooseLanguage; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.GroupBox groupBoxImage; - private System.Windows.Forms.Button buttonSaveAs; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class DvdSubRipChooseLanguage + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.listBox1 = new System.Windows.Forms.ListBox(); + this.pictureBoxImage = new System.Windows.Forms.PictureBox(); + this.comboBoxLanguages = new System.Windows.Forms.ComboBox(); + this.labelChooseLanguage = new System.Windows.Forms.Label(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxImage = new System.Windows.Forms.GroupBox(); + this.buttonSaveAs = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxImage)).BeginInit(); + this.groupBoxImage.SuspendLayout(); + this.SuspendLayout(); + // + // listBox1 + // + this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.listBox1.FormattingEnabled = true; + this.listBox1.Location = new System.Drawing.Point(5, 57); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(298, 212); + this.listBox1.TabIndex = 1; + this.listBox1.SelectedIndexChanged += new System.EventHandler(this.ListBox1SelectedIndexChanged); + // + // pictureBoxImage + // + this.pictureBoxImage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBoxImage.Location = new System.Drawing.Point(6, 19); + this.pictureBoxImage.Name = "pictureBoxImage"; + this.pictureBoxImage.Size = new System.Drawing.Size(452, 214); + this.pictureBoxImage.TabIndex = 1; + this.pictureBoxImage.TabStop = false; + // + // comboBoxLanguages + // + this.comboBoxLanguages.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxLanguages.FormattingEnabled = true; + this.comboBoxLanguages.Location = new System.Drawing.Point(6, 30); + this.comboBoxLanguages.Name = "comboBoxLanguages"; + this.comboBoxLanguages.Size = new System.Drawing.Size(297, 21); + this.comboBoxLanguages.TabIndex = 0; + this.comboBoxLanguages.SelectedIndexChanged += new System.EventHandler(this.ComboBoxLanguagesSelectedIndexChanged); + // + // labelChooseLanguage + // + this.labelChooseLanguage.AutoSize = true; + this.labelChooseLanguage.Location = new System.Drawing.Point(6, 11); + this.labelChooseLanguage.Name = "labelChooseLanguage"; + this.labelChooseLanguage.Size = new System.Drawing.Size(146, 13); + this.labelChooseLanguage.TabIndex = 3; + this.labelChooseLanguage.Text = "Choose language (stream-id)"; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(692, 281); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(487, 281); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // groupBoxImage + // + this.groupBoxImage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImage.Controls.Add(this.pictureBoxImage); + this.groupBoxImage.Location = new System.Drawing.Point(309, 30); + this.groupBoxImage.Name = "groupBoxImage"; + this.groupBoxImage.Size = new System.Drawing.Size(464, 239); + this.groupBoxImage.TabIndex = 2; + this.groupBoxImage.TabStop = false; + this.groupBoxImage.Text = "Subtitle image"; + // + // buttonSaveAs + // + this.buttonSaveAs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSaveAs.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonSaveAs.Location = new System.Drawing.Point(568, 281); + this.buttonSaveAs.Name = "buttonSaveAs"; + this.buttonSaveAs.Size = new System.Drawing.Size(118, 23); + this.buttonSaveAs.TabIndex = 4; + this.buttonSaveAs.Text = "Save as..."; + this.buttonSaveAs.UseVisualStyleBackColor = true; + this.buttonSaveAs.Click += new System.EventHandler(this.buttonSaveAs_Click); + // + // DvdSubRipChooseLanguage + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(779, 314); + this.Controls.Add(this.buttonSaveAs); + this.Controls.Add(this.groupBoxImage); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.labelChooseLanguage); + this.Controls.Add(this.comboBoxLanguages); + this.Controls.Add(this.listBox1); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(700, 350); + this.Name = "DvdSubRipChooseLanguage"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Choose language"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DvdSubRipShowSubtitles_KeyDown); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxImage)).EndInit(); + this.groupBoxImage.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.PictureBox pictureBoxImage; + private System.Windows.Forms.ComboBox comboBoxLanguages; + private System.Windows.Forms.Label labelChooseLanguage; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.GroupBox groupBoxImage; + private System.Windows.Forms.Button buttonSaveAs; + } } \ No newline at end of file diff --git a/src/Forms/DvdSubRipChooseLanguage.cs b/src/ui/Forms/DvdSubRipChooseLanguage.cs similarity index 97% rename from src/Forms/DvdSubRipChooseLanguage.cs rename to src/ui/Forms/DvdSubRipChooseLanguage.cs index 1b21ebea0..77b418446 100644 --- a/src/Forms/DvdSubRipChooseLanguage.cs +++ b/src/ui/Forms/DvdSubRipChooseLanguage.cs @@ -1,222 +1,222 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.VobSub; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; -using Nikse.SubtitleEdit.Forms.Ocr; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class DvdSubRipChooseLanguage : Form - { - private class SubListBoxItem - { - public string Name { get; } - public VobSubMergedPack SubPack { get; } - public override string ToString() - { - return Name; - } - - public SubListBoxItem(string name, VobSubMergedPack subPack) - { - Name = name; - SubPack = subPack; - } - } - - private List _mergedVobSubPacks; - private List _palette; - private List _languages; - - public List SelectedVobSubMergedPacks { get; private set; } - public string SelectedLanguageString { get; private set; } - - public DvdSubRipChooseLanguage() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Text = Configuration.Settings.Language.DvdSubRipChooseLanguage.Title; - labelChooseLanguage.Text = Configuration.Settings.Language.DvdSubRipChooseLanguage.ChooseLanguageStreamId; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - buttonSaveAs.Text = Configuration.Settings.Language.Main.Menu.File.SaveAs; - groupBoxImage.Text = Configuration.Settings.Language.DvdSubRipChooseLanguage.SubtitleImage; - UiUtil.FixLargeFonts(this, buttonOK); - } - - internal void Initialize(List mergedVobSubPacks, List palette, List languages, string selectedLanguage) - { - _mergedVobSubPacks = mergedVobSubPacks; - _palette = palette; - - var uniqueLanguageStreamIds = new List(); - foreach (var pack in mergedVobSubPacks) - { - if (!uniqueLanguageStreamIds.Contains(pack.StreamId)) - { - uniqueLanguageStreamIds.Add(pack.StreamId); - } - } - - comboBoxLanguages.Items.Clear(); - foreach (string languageName in languages) - { - if (uniqueLanguageStreamIds.Contains(GetLanguageIdFromString(languageName))) // only list languages actually found in vob - { - comboBoxLanguages.Items.Add(languageName); - if (languageName == selectedLanguage) - { - comboBoxLanguages.SelectedIndex = comboBoxLanguages.Items.Count - 1; - } - - uniqueLanguageStreamIds.Remove(GetLanguageIdFromString(languageName)); - } - } - - foreach (var existingLanguageId in uniqueLanguageStreamIds) // subtitle tracks not supplied from IFO - { - // Use U+200E (LEFT-TO-RIGHT MARK) to support right-to-left scripts - comboBoxLanguages.Items.Add(string.Format("{0} \x200E(0x{1:x})", Configuration.Settings.Language.DvdSubRipChooseLanguage.UnknownLanguage, existingLanguageId)); - } - - if (comboBoxLanguages.Items.Count > 0 && comboBoxLanguages.SelectedIndex < 0) - { - comboBoxLanguages.SelectedIndex = 0; - } - - _languages = languages; - } - - private static string ShowInSrtFormat(TimeSpan ts) - { - return $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00},{ts.Milliseconds:000}"; - } - - private void ListBox1SelectedIndexChanged(object sender, EventArgs e) - { - var x = listBox1.Items[listBox1.SelectedIndex] as SubListBoxItem; - - Bitmap bmp = x.SubPack.SubPicture.GetBitmap(_palette, Color.Transparent, Color.Wheat, Color.Black, Color.DarkGray, false); - if (bmp.Width > pictureBoxImage.Width || bmp.Height > pictureBoxImage.Height) - { - float width = bmp.Width; - float height = bmp.Height; - while (width > pictureBoxImage.Width || height > pictureBoxImage.Height) - { - width = width * 95 / 100; - height = height * 95 / 100; - } - - var temp = new Bitmap((int)width, (int)height); - using (var g = Graphics.FromImage(temp)) - { - g.DrawImage(bmp, 0, 0, (int)width, (int)height); - } - - bmp = temp; - } - pictureBoxImage.Image = bmp; - groupBoxImage.Text = string.Format(Configuration.Settings.Language.DvdSubRipChooseLanguage.SubtitleImageXofYAndWidthXHeight, listBox1.SelectedIndex + 1, listBox1.Items.Count, bmp.Width, bmp.Height); - } - - private static int GetLanguageIdFromString(string currentLanguage) - { - currentLanguage = currentLanguage.Substring(currentLanguage.IndexOf("0x", StringComparison.Ordinal) + 2).TrimEnd(')'); - return Convert.ToInt32(currentLanguage, 16); - } - - private void ComboBoxLanguagesSelectedIndexChanged(object sender, EventArgs e) - { - int chosenStreamId = GetLanguageIdFromString(comboBoxLanguages.Items[comboBoxLanguages.SelectedIndex].ToString()); - - listBox1.Items.Clear(); - for (int i = 0; i < _mergedVobSubPacks.Count; i++) - { - var x = _mergedVobSubPacks[i]; - if (x.StreamId == chosenStreamId) - { - string s = $"#{i:000}: Stream-id=0X{x.StreamId:X} - {ShowInSrtFormat(x.StartTime)} --> {ShowInSrtFormat(x.EndTime)}"; - listBox1.Items.Add(new SubListBoxItem(s, x)); - } - } - if (listBox1.Items.Count > 0) - { - listBox1.SelectedIndex = 0; - } - } - - private void ButtonOkClick(object sender, EventArgs e) - { - SelectActive(); - } - - internal void SelectActive() - { - if (_languages != null && comboBoxLanguages.SelectedIndex >= 0 && comboBoxLanguages.SelectedIndex < _languages.Count) - { - SelectedLanguageString = _languages[comboBoxLanguages.SelectedIndex]; - } - else - { - SelectedLanguageString = null; - } - - SelectedVobSubMergedPacks = new List(); - foreach (var x in listBox1.Items) - { - SelectedVobSubMergedPacks.Add((x as SubListBoxItem).SubPack); - } - DialogResult = DialogResult.OK; - } - - private void ButtonCancelClick(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void DvdSubRipShowSubtitles_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - e.SuppressKeyPress = true; - DialogResult = DialogResult.Cancel; - } - } - - private void buttonSaveAs_Click(object sender, EventArgs e) - { - if (_languages != null && comboBoxLanguages.SelectedIndex >= 0 && comboBoxLanguages.SelectedIndex < _languages.Count) - { - SelectedLanguageString = _languages[comboBoxLanguages.SelectedIndex]; - } - else - { - SelectedLanguageString = null; - } - - var subs = new List(); - foreach (var x in listBox1.Items) - { - subs.Add((x as SubListBoxItem).SubPack); - } - - using (var formSubOcr = new VobSubOcr()) - { - formSubOcr.InitializeQuick(subs, _palette, Configuration.Settings.VobSubOcr, SelectedLanguageString); - var subtitle = formSubOcr.ReadyVobSubRip(); - - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.InitializeFromVobSubOcr(subtitle, new Core.SubtitleFormats.SubRip(), ExportPngXml.ExportFormats.VobSub, "DVD", formSubOcr, SelectedLanguageString); - exportBdnXmlPng.ShowDialog(this); - } - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.VobSub; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Forms.Ocr; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class DvdSubRipChooseLanguage : Form + { + private class SubListBoxItem + { + public string Name { get; } + public VobSubMergedPack SubPack { get; } + public override string ToString() + { + return Name; + } + + public SubListBoxItem(string name, VobSubMergedPack subPack) + { + Name = name; + SubPack = subPack; + } + } + + private List _mergedVobSubPacks; + private List _palette; + private List _languages; + + public List SelectedVobSubMergedPacks { get; private set; } + public string SelectedLanguageString { get; private set; } + + public DvdSubRipChooseLanguage() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Text = Configuration.Settings.Language.DvdSubRipChooseLanguage.Title; + labelChooseLanguage.Text = Configuration.Settings.Language.DvdSubRipChooseLanguage.ChooseLanguageStreamId; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + buttonSaveAs.Text = Configuration.Settings.Language.Main.Menu.File.SaveAs; + groupBoxImage.Text = Configuration.Settings.Language.DvdSubRipChooseLanguage.SubtitleImage; + UiUtil.FixLargeFonts(this, buttonOK); + } + + internal void Initialize(List mergedVobSubPacks, List palette, List languages, string selectedLanguage) + { + _mergedVobSubPacks = mergedVobSubPacks; + _palette = palette; + + var uniqueLanguageStreamIds = new List(); + foreach (var pack in mergedVobSubPacks) + { + if (!uniqueLanguageStreamIds.Contains(pack.StreamId)) + { + uniqueLanguageStreamIds.Add(pack.StreamId); + } + } + + comboBoxLanguages.Items.Clear(); + foreach (string languageName in languages) + { + if (uniqueLanguageStreamIds.Contains(GetLanguageIdFromString(languageName))) // only list languages actually found in vob + { + comboBoxLanguages.Items.Add(languageName); + if (languageName == selectedLanguage) + { + comboBoxLanguages.SelectedIndex = comboBoxLanguages.Items.Count - 1; + } + + uniqueLanguageStreamIds.Remove(GetLanguageIdFromString(languageName)); + } + } + + foreach (var existingLanguageId in uniqueLanguageStreamIds) // subtitle tracks not supplied from IFO + { + // Use U+200E (LEFT-TO-RIGHT MARK) to support right-to-left scripts + comboBoxLanguages.Items.Add(string.Format("{0} \x200E(0x{1:x})", Configuration.Settings.Language.DvdSubRipChooseLanguage.UnknownLanguage, existingLanguageId)); + } + + if (comboBoxLanguages.Items.Count > 0 && comboBoxLanguages.SelectedIndex < 0) + { + comboBoxLanguages.SelectedIndex = 0; + } + + _languages = languages; + } + + private static string ShowInSrtFormat(TimeSpan ts) + { + return $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00},{ts.Milliseconds:000}"; + } + + private void ListBox1SelectedIndexChanged(object sender, EventArgs e) + { + var x = listBox1.Items[listBox1.SelectedIndex] as SubListBoxItem; + + Bitmap bmp = x.SubPack.SubPicture.GetBitmap(_palette, Color.Transparent, Color.Wheat, Color.Black, Color.DarkGray, false); + if (bmp.Width > pictureBoxImage.Width || bmp.Height > pictureBoxImage.Height) + { + float width = bmp.Width; + float height = bmp.Height; + while (width > pictureBoxImage.Width || height > pictureBoxImage.Height) + { + width = width * 95 / 100; + height = height * 95 / 100; + } + + var temp = new Bitmap((int)width, (int)height); + using (var g = Graphics.FromImage(temp)) + { + g.DrawImage(bmp, 0, 0, (int)width, (int)height); + } + + bmp = temp; + } + pictureBoxImage.Image = bmp; + groupBoxImage.Text = string.Format(Configuration.Settings.Language.DvdSubRipChooseLanguage.SubtitleImageXofYAndWidthXHeight, listBox1.SelectedIndex + 1, listBox1.Items.Count, bmp.Width, bmp.Height); + } + + private static int GetLanguageIdFromString(string currentLanguage) + { + currentLanguage = currentLanguage.Substring(currentLanguage.IndexOf("0x", StringComparison.Ordinal) + 2).TrimEnd(')'); + return Convert.ToInt32(currentLanguage, 16); + } + + private void ComboBoxLanguagesSelectedIndexChanged(object sender, EventArgs e) + { + int chosenStreamId = GetLanguageIdFromString(comboBoxLanguages.Items[comboBoxLanguages.SelectedIndex].ToString()); + + listBox1.Items.Clear(); + for (int i = 0; i < _mergedVobSubPacks.Count; i++) + { + var x = _mergedVobSubPacks[i]; + if (x.StreamId == chosenStreamId) + { + string s = $"#{i:000}: Stream-id=0X{x.StreamId:X} - {ShowInSrtFormat(x.StartTime)} --> {ShowInSrtFormat(x.EndTime)}"; + listBox1.Items.Add(new SubListBoxItem(s, x)); + } + } + if (listBox1.Items.Count > 0) + { + listBox1.SelectedIndex = 0; + } + } + + private void ButtonOkClick(object sender, EventArgs e) + { + SelectActive(); + } + + internal void SelectActive() + { + if (_languages != null && comboBoxLanguages.SelectedIndex >= 0 && comboBoxLanguages.SelectedIndex < _languages.Count) + { + SelectedLanguageString = _languages[comboBoxLanguages.SelectedIndex]; + } + else + { + SelectedLanguageString = null; + } + + SelectedVobSubMergedPacks = new List(); + foreach (var x in listBox1.Items) + { + SelectedVobSubMergedPacks.Add((x as SubListBoxItem).SubPack); + } + DialogResult = DialogResult.OK; + } + + private void ButtonCancelClick(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void DvdSubRipShowSubtitles_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + e.SuppressKeyPress = true; + DialogResult = DialogResult.Cancel; + } + } + + private void buttonSaveAs_Click(object sender, EventArgs e) + { + if (_languages != null && comboBoxLanguages.SelectedIndex >= 0 && comboBoxLanguages.SelectedIndex < _languages.Count) + { + SelectedLanguageString = _languages[comboBoxLanguages.SelectedIndex]; + } + else + { + SelectedLanguageString = null; + } + + var subs = new List(); + foreach (var x in listBox1.Items) + { + subs.Add((x as SubListBoxItem).SubPack); + } + + using (var formSubOcr = new VobSubOcr()) + { + formSubOcr.InitializeQuick(subs, _palette, Configuration.Settings.VobSubOcr, SelectedLanguageString); + var subtitle = formSubOcr.ReadyVobSubRip(); + + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.InitializeFromVobSubOcr(subtitle, new Core.SubtitleFormats.SubRip(), ExportPngXml.ExportFormats.VobSub, "DVD", formSubOcr, SelectedLanguageString); + exportBdnXmlPng.ShowDialog(this); + } + } + } + + } +} diff --git a/src/Forms/Networking/NetworkStart.resx b/src/ui/Forms/DvdSubRipChooseLanguage.resx similarity index 100% rename from src/Forms/Networking/NetworkStart.resx rename to src/ui/Forms/DvdSubRipChooseLanguage.resx diff --git a/src/Forms/EbuColorPicker.Designer.cs b/src/ui/Forms/EbuColorPicker.Designer.cs similarity index 100% rename from src/Forms/EbuColorPicker.Designer.cs rename to src/ui/Forms/EbuColorPicker.Designer.cs diff --git a/src/Forms/EbuColorPicker.cs b/src/ui/Forms/EbuColorPicker.cs similarity index 100% rename from src/Forms/EbuColorPicker.cs rename to src/ui/Forms/EbuColorPicker.cs diff --git a/src/Forms/Ocr/AddBeterMultiMatch.resx b/src/ui/Forms/EbuColorPicker.resx similarity index 100% rename from src/Forms/Ocr/AddBeterMultiMatch.resx rename to src/ui/Forms/EbuColorPicker.resx diff --git a/src/Forms/EbuLanguageCode.Designer.cs b/src/ui/Forms/EbuLanguageCode.Designer.cs similarity index 100% rename from src/Forms/EbuLanguageCode.Designer.cs rename to src/ui/Forms/EbuLanguageCode.Designer.cs diff --git a/src/Forms/EbuLanguageCode.cs b/src/ui/Forms/EbuLanguageCode.cs similarity index 100% rename from src/Forms/EbuLanguageCode.cs rename to src/ui/Forms/EbuLanguageCode.cs diff --git a/src/Forms/Ocr/AddBetterMultiMatchNOcr.resx b/src/ui/Forms/EbuLanguageCode.resx similarity index 100% rename from src/Forms/Ocr/AddBetterMultiMatchNOcr.resx rename to src/ui/Forms/EbuLanguageCode.resx diff --git a/src/Forms/EbuSaveOptions.Designer.cs b/src/ui/Forms/EbuSaveOptions.Designer.cs similarity index 98% rename from src/Forms/EbuSaveOptions.Designer.cs rename to src/ui/Forms/EbuSaveOptions.Designer.cs index f93b12565..3862b9af0 100644 --- a/src/Forms/EbuSaveOptions.Designer.cs +++ b/src/ui/Forms/EbuSaveOptions.Designer.cs @@ -1,1041 +1,1041 @@ -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - partial class EbuSaveOptions - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - TimeCode timeCode1 = new TimeCode(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.tabControl1 = new System.Windows.Forms.TabControl(); - this.tabPageHeader = new System.Windows.Forms.TabPage(); - this.labelMaxCharsPerRow38ForTeletext = new System.Windows.Forms.Label(); - this.labelLanguageCodeFriendlyName = new System.Windows.Forms.Label(); - this.buttonChooseLanguageCode = new System.Windows.Forms.Button(); - this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.labelDisplayStandardCodeWarning = new System.Windows.Forms.Label(); - this.labelFrameRate = new System.Windows.Forms.Label(); - this.comboBoxFrameRate = new System.Windows.Forms.ComboBox(); - this.labelTimeCodeStartOfProgramme = new System.Windows.Forms.Label(); - this.labelTimeCodeStatus = new System.Windows.Forms.Label(); - this.comboBoxTimeCodeStatus = new System.Windows.Forms.ComboBox(); - this.comboBoxDisplayStandardCode = new System.Windows.Forms.ComboBox(); - this.labelDisplayStandardCode = new System.Windows.Forms.Label(); - this.textBoxCountryOfOrigin = new System.Windows.Forms.TextBox(); - this.labelCountryOfOrigin = new System.Windows.Forms.Label(); - this.textBoxCodePageNumber = new System.Windows.Forms.TextBox(); - this.contextMenuStripCodeTable = new System.Windows.Forms.ContextMenuStrip(this.components); - this.unitedStatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.multilingualToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.portugalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.canadaFrenchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.nordicToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.numericUpDownMaxRows = new System.Windows.Forms.NumericUpDown(); - this.labelMaxNumberOfDisplayableRows = new System.Windows.Forms.Label(); - this.comboBoxDiscFormatCode = new System.Windows.Forms.ComboBox(); - this.labelDiskFormatCode = new System.Windows.Forms.Label(); - this.labelCodePageNumber = new System.Windows.Forms.Label(); - this.textBoxLanguageCode = new System.Windows.Forms.TextBox(); - this.labelLanguageCode = new System.Windows.Forms.Label(); - this.numericUpDownMaxCharacters = new System.Windows.Forms.NumericUpDown(); - this.labelMaxNoOfDisplayableChars = new System.Windows.Forms.Label(); - this.numericUpDownDiskSequenceNumber = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownTotalNumberOfDiscs = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownRevisionNumber = new System.Windows.Forms.NumericUpDown(); - this.labelDiskSequenceNumber = new System.Windows.Forms.Label(); - this.labelTotalNumberOfDisks = new System.Windows.Forms.Label(); - this.labelRevisionNumber = new System.Windows.Forms.Label(); - this.textBoxTranslatorsName = new System.Windows.Forms.TextBox(); - this.labelTranslatorsName = new System.Windows.Forms.Label(); - this.textBoxSubtitleListReferenceCode = new System.Windows.Forms.TextBox(); - this.labelSubtitleListReferenceCode = new System.Windows.Forms.Label(); - this.comboBoxCharacterCodeTable = new System.Windows.Forms.ComboBox(); - this.buttonImport = new System.Windows.Forms.Button(); - this.labelCharacterCodeTable = new System.Windows.Forms.Label(); - this.textBoxTranslatedProgramTitle = new System.Windows.Forms.TextBox(); - this.textBoxTranslatedEpisodeTitle = new System.Windows.Forms.TextBox(); - this.textBoxOriginalEpisodeTitle = new System.Windows.Forms.TextBox(); - this.labelTranslatedEpisodeTitle = new System.Windows.Forms.Label(); - this.labelTranslatedProgramTitle = new System.Windows.Forms.Label(); - this.labelOriginalEpisodeTitle = new System.Windows.Forms.Label(); - this.textBoxOriginalProgramTitle = new System.Windows.Forms.TextBox(); - this.labelOriginalProgramTitle = new System.Windows.Forms.Label(); - this.tabPageTextAndTiming = new System.Windows.Forms.TabPage(); - this.groupBoxVerticalPosition = new System.Windows.Forms.GroupBox(); - this.labelUseBox = new System.Windows.Forms.Label(); - this.numericUpDownNewLineRows = new System.Windows.Forms.NumericUpDown(); - this.labelNewLineRows = new System.Windows.Forms.Label(); - this.labelMarginTop = new System.Windows.Forms.Label(); - this.numericUpDownMarginBottom = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownMarginTop = new System.Windows.Forms.NumericUpDown(); - this.labelMarginBottom = new System.Windows.Forms.Label(); - this.groupBoxTeletext = new System.Windows.Forms.GroupBox(); - this.checkBoxTeletextDoubleHeight = new System.Windows.Forms.CheckBox(); - this.checkBoxTeletextBox = new System.Windows.Forms.CheckBox(); - this.comboBoxJustificationCode = new System.Windows.Forms.ComboBox(); - this.labelJustificationCode = new System.Windows.Forms.Label(); - this.tabPageErrors = new System.Windows.Forms.TabPage(); - this.textBoxErrors = new System.Windows.Forms.TextBox(); - this.labelErrors = new System.Windows.Forms.Label(); - this.tabControl1.SuspendLayout(); - this.tabPageHeader.SuspendLayout(); - this.contextMenuStripCodeTable.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxRows)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDiskSequenceNumber)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTotalNumberOfDiscs)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRevisionNumber)).BeginInit(); - this.tabPageTextAndTiming.SuspendLayout(); - this.groupBoxVerticalPosition.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNewLineRows)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginBottom)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginTop)).BeginInit(); - this.groupBoxTeletext.SuspendLayout(); - this.tabPageErrors.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(607, 510); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 1; - this.buttonOK.Text = "Save"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(688, 510); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 2; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // tabControl1 - // - this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tabControl1.Controls.Add(this.tabPageHeader); - this.tabControl1.Controls.Add(this.tabPageTextAndTiming); - this.tabControl1.Controls.Add(this.tabPageErrors); - this.tabControl1.Location = new System.Drawing.Point(12, 12); - this.tabControl1.Name = "tabControl1"; - this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(758, 487); - this.tabControl1.TabIndex = 0; - // - // tabPageHeader - // - this.tabPageHeader.Controls.Add(this.labelMaxCharsPerRow38ForTeletext); - this.tabPageHeader.Controls.Add(this.labelLanguageCodeFriendlyName); - this.tabPageHeader.Controls.Add(this.buttonChooseLanguageCode); - this.tabPageHeader.Controls.Add(this.timeUpDownStartTime); - this.tabPageHeader.Controls.Add(this.labelDisplayStandardCodeWarning); - this.tabPageHeader.Controls.Add(this.labelFrameRate); - this.tabPageHeader.Controls.Add(this.comboBoxFrameRate); - this.tabPageHeader.Controls.Add(this.labelTimeCodeStartOfProgramme); - this.tabPageHeader.Controls.Add(this.labelTimeCodeStatus); - this.tabPageHeader.Controls.Add(this.comboBoxTimeCodeStatus); - this.tabPageHeader.Controls.Add(this.comboBoxDisplayStandardCode); - this.tabPageHeader.Controls.Add(this.labelDisplayStandardCode); - this.tabPageHeader.Controls.Add(this.textBoxCountryOfOrigin); - this.tabPageHeader.Controls.Add(this.labelCountryOfOrigin); - this.tabPageHeader.Controls.Add(this.textBoxCodePageNumber); - this.tabPageHeader.Controls.Add(this.numericUpDownMaxRows); - this.tabPageHeader.Controls.Add(this.labelMaxNumberOfDisplayableRows); - this.tabPageHeader.Controls.Add(this.comboBoxDiscFormatCode); - this.tabPageHeader.Controls.Add(this.labelDiskFormatCode); - this.tabPageHeader.Controls.Add(this.labelCodePageNumber); - this.tabPageHeader.Controls.Add(this.textBoxLanguageCode); - this.tabPageHeader.Controls.Add(this.labelLanguageCode); - this.tabPageHeader.Controls.Add(this.numericUpDownMaxCharacters); - this.tabPageHeader.Controls.Add(this.labelMaxNoOfDisplayableChars); - this.tabPageHeader.Controls.Add(this.numericUpDownDiskSequenceNumber); - this.tabPageHeader.Controls.Add(this.numericUpDownTotalNumberOfDiscs); - this.tabPageHeader.Controls.Add(this.numericUpDownRevisionNumber); - this.tabPageHeader.Controls.Add(this.labelDiskSequenceNumber); - this.tabPageHeader.Controls.Add(this.labelTotalNumberOfDisks); - this.tabPageHeader.Controls.Add(this.labelRevisionNumber); - this.tabPageHeader.Controls.Add(this.textBoxTranslatorsName); - this.tabPageHeader.Controls.Add(this.labelTranslatorsName); - this.tabPageHeader.Controls.Add(this.textBoxSubtitleListReferenceCode); - this.tabPageHeader.Controls.Add(this.labelSubtitleListReferenceCode); - this.tabPageHeader.Controls.Add(this.comboBoxCharacterCodeTable); - this.tabPageHeader.Controls.Add(this.buttonImport); - this.tabPageHeader.Controls.Add(this.labelCharacterCodeTable); - this.tabPageHeader.Controls.Add(this.textBoxTranslatedProgramTitle); - this.tabPageHeader.Controls.Add(this.textBoxTranslatedEpisodeTitle); - this.tabPageHeader.Controls.Add(this.textBoxOriginalEpisodeTitle); - this.tabPageHeader.Controls.Add(this.labelTranslatedEpisodeTitle); - this.tabPageHeader.Controls.Add(this.labelTranslatedProgramTitle); - this.tabPageHeader.Controls.Add(this.labelOriginalEpisodeTitle); - this.tabPageHeader.Controls.Add(this.textBoxOriginalProgramTitle); - this.tabPageHeader.Controls.Add(this.labelOriginalProgramTitle); - this.tabPageHeader.Location = new System.Drawing.Point(4, 22); - this.tabPageHeader.Name = "tabPageHeader"; - this.tabPageHeader.Padding = new System.Windows.Forms.Padding(3); - this.tabPageHeader.Size = new System.Drawing.Size(750, 461); - this.tabPageHeader.TabIndex = 0; - this.tabPageHeader.Text = "General subtitle information"; - this.tabPageHeader.UseVisualStyleBackColor = true; - // - // labelMaxCharsPerRow38ForTeletext - // - this.labelMaxCharsPerRow38ForTeletext.AutoSize = true; - this.labelMaxCharsPerRow38ForTeletext.ForeColor = System.Drawing.Color.Red; - this.labelMaxCharsPerRow38ForTeletext.Location = new System.Drawing.Point(443, 347); - this.labelMaxCharsPerRow38ForTeletext.Name = "labelMaxCharsPerRow38ForTeletext"; - this.labelMaxCharsPerRow38ForTeletext.Size = new System.Drawing.Size(198, 13); - this.labelMaxCharsPerRow38ForTeletext.TabIndex = 74; - this.labelMaxCharsPerRow38ForTeletext.Text = "Use 38 in \'Max chars per row\' for teletext"; - // - // labelLanguageCodeFriendlyName - // - this.labelLanguageCodeFriendlyName.AutoSize = true; - this.labelLanguageCodeFriendlyName.ForeColor = System.Drawing.SystemColors.GrayText; - this.labelLanguageCodeFriendlyName.Location = new System.Drawing.Point(440, 157); - this.labelLanguageCodeFriendlyName.Name = "labelLanguageCodeFriendlyName"; - this.labelLanguageCodeFriendlyName.Size = new System.Drawing.Size(166, 13); - this.labelLanguageCodeFriendlyName.TabIndex = 73; - this.labelLanguageCodeFriendlyName.Text = "labelLanguageCodeFriendlyName"; - // - // buttonChooseLanguageCode - // - this.buttonChooseLanguageCode.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonChooseLanguageCode.Location = new System.Drawing.Point(405, 153); - this.buttonChooseLanguageCode.Name = "buttonChooseLanguageCode"; - this.buttonChooseLanguageCode.Size = new System.Drawing.Size(31, 21); - this.buttonChooseLanguageCode.TabIndex = 6; - this.buttonChooseLanguageCode.Text = "..."; - this.buttonChooseLanguageCode.UseVisualStyleBackColor = true; - this.buttonChooseLanguageCode.Click += new System.EventHandler(this.buttonChooseLanguageCode_Click); - // - // timeUpDownStartTime - // - this.timeUpDownStartTime.AutoSize = true; - this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownStartTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); - this.timeUpDownStartTime.Location = new System.Drawing.Point(179, 411); - this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownStartTime.Name = "timeUpDownStartTime"; - this.timeUpDownStartTime.Size = new System.Drawing.Size(111, 27); - this.timeUpDownStartTime.TabIndex = 14; - timeCode1.Hours = 0; - timeCode1.Milliseconds = 0; - timeCode1.Minutes = 0; - timeCode1.Seconds = 0; - timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode1.TotalMilliseconds = 0D; - timeCode1.TotalSeconds = 0D; - this.timeUpDownStartTime.TimeCode = timeCode1; - this.timeUpDownStartTime.UseVideoOffset = false; - // - // labelDisplayStandardCodeWarning - // - this.labelDisplayStandardCodeWarning.AutoSize = true; - this.labelDisplayStandardCodeWarning.ForeColor = System.Drawing.Color.Red; - this.labelDisplayStandardCodeWarning.Location = new System.Drawing.Point(406, 102); - this.labelDisplayStandardCodeWarning.Name = "labelDisplayStandardCodeWarning"; - this.labelDisplayStandardCodeWarning.Size = new System.Drawing.Size(146, 13); - this.labelDisplayStandardCodeWarning.TabIndex = 72; - this.labelDisplayStandardCodeWarning.Text = "Use teletext to include colors!"; - // - // labelFrameRate - // - this.labelFrameRate.AutoSize = true; - this.labelFrameRate.Location = new System.Drawing.Point(6, 72); - this.labelFrameRate.Name = "labelFrameRate"; - this.labelFrameRate.Size = new System.Drawing.Size(57, 13); - this.labelFrameRate.TabIndex = 71; - this.labelFrameRate.Text = "Frame rate"; - // - // comboBoxFrameRate - // - this.comboBoxFrameRate.FormattingEnabled = true; - this.comboBoxFrameRate.Location = new System.Drawing.Point(181, 69); - this.comboBoxFrameRate.Name = "comboBoxFrameRate"; - this.comboBoxFrameRate.Size = new System.Drawing.Size(219, 21); - this.comboBoxFrameRate.TabIndex = 2; - // - // labelTimeCodeStartOfProgramme - // - this.labelTimeCodeStartOfProgramme.AutoSize = true; - this.labelTimeCodeStartOfProgramme.Location = new System.Drawing.Point(5, 416); - this.labelTimeCodeStartOfProgramme.Name = "labelTimeCodeStartOfProgramme"; - this.labelTimeCodeStartOfProgramme.Size = new System.Drawing.Size(152, 13); - this.labelTimeCodeStartOfProgramme.TabIndex = 69; - this.labelTimeCodeStartOfProgramme.Text = "Time code: Start of programme"; - // - // labelTimeCodeStatus - // - this.labelTimeCodeStatus.AutoSize = true; - this.labelTimeCodeStatus.Location = new System.Drawing.Point(6, 386); - this.labelTimeCodeStatus.Name = "labelTimeCodeStatus"; - this.labelTimeCodeStatus.Size = new System.Drawing.Size(88, 13); - this.labelTimeCodeStatus.TabIndex = 68; - this.labelTimeCodeStatus.Text = "Time code status"; - // - // comboBoxTimeCodeStatus - // - this.comboBoxTimeCodeStatus.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxTimeCodeStatus.FormattingEnabled = true; - this.comboBoxTimeCodeStatus.Items.AddRange(new object[] { - "Not intended for use", - "Intended for use"}); - this.comboBoxTimeCodeStatus.Location = new System.Drawing.Point(181, 383); - this.comboBoxTimeCodeStatus.Name = "comboBoxTimeCodeStatus"; - this.comboBoxTimeCodeStatus.Size = new System.Drawing.Size(219, 21); - this.comboBoxTimeCodeStatus.TabIndex = 13; - // - // comboBoxDisplayStandardCode - // - this.comboBoxDisplayStandardCode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxDisplayStandardCode.FormattingEnabled = true; - this.comboBoxDisplayStandardCode.Items.AddRange(new object[] { - "0 Open subtitling", - "1 Level-1 teletext", - "2 Level-2 teletext", - "Undefined"}); - this.comboBoxDisplayStandardCode.Location = new System.Drawing.Point(181, 99); - this.comboBoxDisplayStandardCode.Name = "comboBoxDisplayStandardCode"; - this.comboBoxDisplayStandardCode.Size = new System.Drawing.Size(219, 21); - this.comboBoxDisplayStandardCode.TabIndex = 3; - this.comboBoxDisplayStandardCode.SelectedIndexChanged += new System.EventHandler(this.comboBoxDisplayStandardCode_SelectedIndexChanged); - // - // labelDisplayStandardCode - // - this.labelDisplayStandardCode.AutoSize = true; - this.labelDisplayStandardCode.Location = new System.Drawing.Point(6, 102); - this.labelDisplayStandardCode.Name = "labelDisplayStandardCode"; - this.labelDisplayStandardCode.Size = new System.Drawing.Size(112, 13); - this.labelDisplayStandardCode.TabIndex = 65; - this.labelDisplayStandardCode.Text = "Display standard code"; - // - // textBoxCountryOfOrigin - // - this.textBoxCountryOfOrigin.Location = new System.Drawing.Point(181, 340); - this.textBoxCountryOfOrigin.MaxLength = 3; - this.textBoxCountryOfOrigin.Name = "textBoxCountryOfOrigin"; - this.textBoxCountryOfOrigin.Size = new System.Drawing.Size(219, 20); - this.textBoxCountryOfOrigin.TabIndex = 12; - // - // labelCountryOfOrigin - // - this.labelCountryOfOrigin.AutoSize = true; - this.labelCountryOfOrigin.Location = new System.Drawing.Point(6, 343); - this.labelCountryOfOrigin.Name = "labelCountryOfOrigin"; - this.labelCountryOfOrigin.Size = new System.Drawing.Size(83, 13); - this.labelCountryOfOrigin.TabIndex = 63; - this.labelCountryOfOrigin.Text = "Country of origin"; - // - // textBoxCodePageNumber - // - this.textBoxCodePageNumber.ContextMenuStrip = this.contextMenuStripCodeTable; - this.textBoxCodePageNumber.Location = new System.Drawing.Point(181, 12); - this.textBoxCodePageNumber.MaxLength = 3; - this.textBoxCodePageNumber.Name = "textBoxCodePageNumber"; - this.textBoxCodePageNumber.Size = new System.Drawing.Size(219, 20); - this.textBoxCodePageNumber.TabIndex = 0; - // - // contextMenuStripCodeTable - // - this.contextMenuStripCodeTable.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.unitedStatesToolStripMenuItem, - this.multilingualToolStripMenuItem, - this.portugalToolStripMenuItem, - this.canadaFrenchToolStripMenuItem, - this.nordicToolStripMenuItem}); - this.contextMenuStripCodeTable.Name = "contextMenuStripCodeTable"; - this.contextMenuStripCodeTable.Size = new System.Drawing.Size(185, 114); - // - // unitedStatesToolStripMenuItem - // - this.unitedStatesToolStripMenuItem.Name = "unitedStatesToolStripMenuItem"; - this.unitedStatesToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.unitedStatesToolStripMenuItem.Text = "United States (437)"; - this.unitedStatesToolStripMenuItem.Click += new System.EventHandler(this.unitedStatesToolStripMenuItem_Click); - // - // multilingualToolStripMenuItem - // - this.multilingualToolStripMenuItem.Name = "multilingualToolStripMenuItem"; - this.multilingualToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.multilingualToolStripMenuItem.Text = "Multilingual (850)"; - this.multilingualToolStripMenuItem.Click += new System.EventHandler(this.multilingualToolStripMenuItem_Click); - // - // portugalToolStripMenuItem - // - this.portugalToolStripMenuItem.Name = "portugalToolStripMenuItem"; - this.portugalToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.portugalToolStripMenuItem.Text = "Portugal (860)"; - this.portugalToolStripMenuItem.Click += new System.EventHandler(this.portugalToolStripMenuItem_Click); - // - // canadaFrenchToolStripMenuItem - // - this.canadaFrenchToolStripMenuItem.Name = "canadaFrenchToolStripMenuItem"; - this.canadaFrenchToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.canadaFrenchToolStripMenuItem.Text = "Canada-French (863)"; - this.canadaFrenchToolStripMenuItem.Click += new System.EventHandler(this.canadaFrenchToolStripMenuItem_Click); - // - // nordicToolStripMenuItem - // - this.nordicToolStripMenuItem.Name = "nordicToolStripMenuItem"; - this.nordicToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.nordicToolStripMenuItem.Text = "Nordic (865)"; - this.nordicToolStripMenuItem.Click += new System.EventHandler(this.nordicToolStripMenuItem_Click); - // - // numericUpDownMaxRows - // - this.numericUpDownMaxRows.Location = new System.Drawing.Point(613, 251); - this.numericUpDownMaxRows.Maximum = new decimal(new int[] { - 99, - 0, - 0, - 0}); - this.numericUpDownMaxRows.Name = "numericUpDownMaxRows"; - this.numericUpDownMaxRows.Size = new System.Drawing.Size(120, 20); - this.numericUpDownMaxRows.TabIndex = 17; - // - // labelMaxNumberOfDisplayableRows - // - this.labelMaxNumberOfDisplayableRows.AutoSize = true; - this.labelMaxNumberOfDisplayableRows.Location = new System.Drawing.Point(473, 253); - this.labelMaxNumberOfDisplayableRows.Name = "labelMaxNumberOfDisplayableRows"; - this.labelMaxNumberOfDisplayableRows.Size = new System.Drawing.Size(126, 13); - this.labelMaxNumberOfDisplayableRows.TabIndex = 60; - this.labelMaxNumberOfDisplayableRows.Text = "Max# of displayable rows"; - // - // comboBoxDiscFormatCode - // - this.comboBoxDiscFormatCode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxDiscFormatCode.FormattingEnabled = true; - this.comboBoxDiscFormatCode.Items.AddRange(new object[] { - "STL23.01 (non-standard)", - "STL24.01 (non-standard)", - "STL25.01", - "STL29.01 (non-standard)", - "STL30.01"}); - this.comboBoxDiscFormatCode.Location = new System.Drawing.Point(181, 39); - this.comboBoxDiscFormatCode.Name = "comboBoxDiscFormatCode"; - this.comboBoxDiscFormatCode.Size = new System.Drawing.Size(219, 21); - this.comboBoxDiscFormatCode.TabIndex = 1; - this.comboBoxDiscFormatCode.SelectedIndexChanged += new System.EventHandler(this.comboBoxDiscFormatCode_SelectedIndexChanged); - // - // labelDiskFormatCode - // - this.labelDiskFormatCode.AutoSize = true; - this.labelDiskFormatCode.Location = new System.Drawing.Point(6, 42); - this.labelDiskFormatCode.Name = "labelDiskFormatCode"; - this.labelDiskFormatCode.Size = new System.Drawing.Size(87, 13); - this.labelDiskFormatCode.TabIndex = 58; - this.labelDiskFormatCode.Text = "Disk format code"; - // - // labelCodePageNumber - // - this.labelCodePageNumber.AutoSize = true; - this.labelCodePageNumber.Location = new System.Drawing.Point(6, 15); - this.labelCodePageNumber.Name = "labelCodePageNumber"; - this.labelCodePageNumber.Size = new System.Drawing.Size(97, 13); - this.labelCodePageNumber.TabIndex = 56; - this.labelCodePageNumber.Text = "Code page number"; - // - // textBoxLanguageCode - // - this.textBoxLanguageCode.Location = new System.Drawing.Point(181, 154); - this.textBoxLanguageCode.MaxLength = 32; - this.textBoxLanguageCode.Name = "textBoxLanguageCode"; - this.textBoxLanguageCode.Size = new System.Drawing.Size(219, 20); - this.textBoxLanguageCode.TabIndex = 5; - this.textBoxLanguageCode.TextChanged += new System.EventHandler(this.textBoxLanguageCode_TextChanged); - // - // labelLanguageCode - // - this.labelLanguageCode.AutoSize = true; - this.labelLanguageCode.Location = new System.Drawing.Point(6, 157); - this.labelLanguageCode.Name = "labelLanguageCode"; - this.labelLanguageCode.Size = new System.Drawing.Size(82, 13); - this.labelLanguageCode.TabIndex = 54; - this.labelLanguageCode.Text = "Language code"; - // - // numericUpDownMaxCharacters - // - this.numericUpDownMaxCharacters.Location = new System.Drawing.Point(613, 225); - this.numericUpDownMaxCharacters.Maximum = new decimal(new int[] { - 99, - 0, - 0, - 0}); - this.numericUpDownMaxCharacters.Name = "numericUpDownMaxCharacters"; - this.numericUpDownMaxCharacters.Size = new System.Drawing.Size(120, 20); - this.numericUpDownMaxCharacters.TabIndex = 16; - this.numericUpDownMaxCharacters.ValueChanged += new System.EventHandler(this.numericUpDownMaxCharacters_ValueChanged); - // - // labelMaxNoOfDisplayableChars - // - this.labelMaxNoOfDisplayableChars.AutoSize = true; - this.labelMaxNoOfDisplayableChars.Location = new System.Drawing.Point(473, 227); - this.labelMaxNoOfDisplayableChars.Name = "labelMaxNoOfDisplayableChars"; - this.labelMaxNoOfDisplayableChars.Size = new System.Drawing.Size(133, 13); - this.labelMaxNoOfDisplayableChars.TabIndex = 51; - this.labelMaxNoOfDisplayableChars.Text = "Max# of displayable chars "; - // - // numericUpDownDiskSequenceNumber - // - this.numericUpDownDiskSequenceNumber.Location = new System.Drawing.Point(613, 277); - this.numericUpDownDiskSequenceNumber.Maximum = new decimal(new int[] { - 9, - 0, - 0, - 0}); - this.numericUpDownDiskSequenceNumber.Name = "numericUpDownDiskSequenceNumber"; - this.numericUpDownDiskSequenceNumber.Size = new System.Drawing.Size(120, 20); - this.numericUpDownDiskSequenceNumber.TabIndex = 18; - // - // numericUpDownTotalNumberOfDiscs - // - this.numericUpDownTotalNumberOfDiscs.Location = new System.Drawing.Point(613, 303); - this.numericUpDownTotalNumberOfDiscs.Maximum = new decimal(new int[] { - 9, - 0, - 0, - 0}); - this.numericUpDownTotalNumberOfDiscs.Name = "numericUpDownTotalNumberOfDiscs"; - this.numericUpDownTotalNumberOfDiscs.Size = new System.Drawing.Size(120, 20); - this.numericUpDownTotalNumberOfDiscs.TabIndex = 19; - // - // numericUpDownRevisionNumber - // - this.numericUpDownRevisionNumber.Location = new System.Drawing.Point(613, 199); - this.numericUpDownRevisionNumber.Maximum = new decimal(new int[] { - 99, - 0, - 0, - 0}); - this.numericUpDownRevisionNumber.Name = "numericUpDownRevisionNumber"; - this.numericUpDownRevisionNumber.Size = new System.Drawing.Size(120, 20); - this.numericUpDownRevisionNumber.TabIndex = 15; - // - // labelDiskSequenceNumber - // - this.labelDiskSequenceNumber.AutoSize = true; - this.labelDiskSequenceNumber.Location = new System.Drawing.Point(473, 279); - this.labelDiskSequenceNumber.Name = "labelDiskSequenceNumber"; - this.labelDiskSequenceNumber.Size = new System.Drawing.Size(116, 13); - this.labelDiskSequenceNumber.TabIndex = 49; - this.labelDiskSequenceNumber.Text = "Disk sequence number"; - // - // labelTotalNumberOfDisks - // - this.labelTotalNumberOfDisks.AutoSize = true; - this.labelTotalNumberOfDisks.Location = new System.Drawing.Point(473, 305); - this.labelTotalNumberOfDisks.Name = "labelTotalNumberOfDisks"; - this.labelTotalNumberOfDisks.Size = new System.Drawing.Size(108, 13); - this.labelTotalNumberOfDisks.TabIndex = 48; - this.labelTotalNumberOfDisks.Text = "Total number of disks"; - // - // labelRevisionNumber - // - this.labelRevisionNumber.AutoSize = true; - this.labelRevisionNumber.Location = new System.Drawing.Point(473, 201); - this.labelRevisionNumber.Name = "labelRevisionNumber"; - this.labelRevisionNumber.Size = new System.Drawing.Size(86, 13); - this.labelRevisionNumber.TabIndex = 47; - this.labelRevisionNumber.Text = "Revision number"; - // - // textBoxTranslatorsName - // - this.textBoxTranslatorsName.Location = new System.Drawing.Point(181, 284); - this.textBoxTranslatorsName.MaxLength = 32; - this.textBoxTranslatorsName.Name = "textBoxTranslatorsName"; - this.textBoxTranslatorsName.Size = new System.Drawing.Size(219, 20); - this.textBoxTranslatorsName.TabIndex = 10; - // - // labelTranslatorsName - // - this.labelTranslatorsName.AutoSize = true; - this.labelTranslatorsName.Location = new System.Drawing.Point(6, 287); - this.labelTranslatorsName.Name = "labelTranslatorsName"; - this.labelTranslatorsName.Size = new System.Drawing.Size(90, 13); - this.labelTranslatorsName.TabIndex = 45; - this.labelTranslatorsName.Text = "Translator\'s name"; - // - // textBoxSubtitleListReferenceCode - // - this.textBoxSubtitleListReferenceCode.Location = new System.Drawing.Point(181, 314); - this.textBoxSubtitleListReferenceCode.MaxLength = 16; - this.textBoxSubtitleListReferenceCode.Name = "textBoxSubtitleListReferenceCode"; - this.textBoxSubtitleListReferenceCode.Size = new System.Drawing.Size(219, 20); - this.textBoxSubtitleListReferenceCode.TabIndex = 11; - // - // labelSubtitleListReferenceCode - // - this.labelSubtitleListReferenceCode.AutoSize = true; - this.labelSubtitleListReferenceCode.Location = new System.Drawing.Point(6, 317); - this.labelSubtitleListReferenceCode.Name = "labelSubtitleListReferenceCode"; - this.labelSubtitleListReferenceCode.Size = new System.Drawing.Size(132, 13); - this.labelSubtitleListReferenceCode.TabIndex = 43; - this.labelSubtitleListReferenceCode.Text = "Subtitle list reference code"; - // - // comboBoxCharacterCodeTable - // - this.comboBoxCharacterCodeTable.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxCharacterCodeTable.FormattingEnabled = true; - this.comboBoxCharacterCodeTable.Items.AddRange(new object[] { - "Latin", - "Latin/Cyrillic", - "Latin/Arabic", - "Latin/Greek", - "Latin/Hebrew"}); - this.comboBoxCharacterCodeTable.Location = new System.Drawing.Point(181, 126); - this.comboBoxCharacterCodeTable.Name = "comboBoxCharacterCodeTable"; - this.comboBoxCharacterCodeTable.Size = new System.Drawing.Size(219, 21); - this.comboBoxCharacterCodeTable.TabIndex = 4; - // - // buttonImport - // - this.buttonImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonImport.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonImport.Location = new System.Drawing.Point(613, 6); - this.buttonImport.Name = "buttonImport"; - this.buttonImport.Size = new System.Drawing.Size(134, 23); - this.buttonImport.TabIndex = 20; - this.buttonImport.Text = "Import..."; - this.buttonImport.UseVisualStyleBackColor = true; - this.buttonImport.Click += new System.EventHandler(this.buttonImport_Click); - // - // labelCharacterCodeTable - // - this.labelCharacterCodeTable.AutoSize = true; - this.labelCharacterCodeTable.Location = new System.Drawing.Point(6, 129); - this.labelCharacterCodeTable.Name = "labelCharacterCodeTable"; - this.labelCharacterCodeTable.Size = new System.Drawing.Size(106, 13); - this.labelCharacterCodeTable.TabIndex = 40; - this.labelCharacterCodeTable.Text = "Character code table"; - // - // textBoxTranslatedProgramTitle - // - this.textBoxTranslatedProgramTitle.Location = new System.Drawing.Point(181, 232); - this.textBoxTranslatedProgramTitle.MaxLength = 32; - this.textBoxTranslatedProgramTitle.Name = "textBoxTranslatedProgramTitle"; - this.textBoxTranslatedProgramTitle.Size = new System.Drawing.Size(219, 20); - this.textBoxTranslatedProgramTitle.TabIndex = 8; - // - // textBoxTranslatedEpisodeTitle - // - this.textBoxTranslatedEpisodeTitle.Location = new System.Drawing.Point(181, 258); - this.textBoxTranslatedEpisodeTitle.MaxLength = 32; - this.textBoxTranslatedEpisodeTitle.Name = "textBoxTranslatedEpisodeTitle"; - this.textBoxTranslatedEpisodeTitle.Size = new System.Drawing.Size(219, 20); - this.textBoxTranslatedEpisodeTitle.TabIndex = 9; - // - // textBoxOriginalEpisodeTitle - // - this.textBoxOriginalEpisodeTitle.Location = new System.Drawing.Point(181, 206); - this.textBoxOriginalEpisodeTitle.MaxLength = 32; - this.textBoxOriginalEpisodeTitle.Name = "textBoxOriginalEpisodeTitle"; - this.textBoxOriginalEpisodeTitle.Size = new System.Drawing.Size(219, 20); - this.textBoxOriginalEpisodeTitle.TabIndex = 7; - // - // labelTranslatedEpisodeTitle - // - this.labelTranslatedEpisodeTitle.AutoSize = true; - this.labelTranslatedEpisodeTitle.Location = new System.Drawing.Point(6, 261); - this.labelTranslatedEpisodeTitle.Name = "labelTranslatedEpisodeTitle"; - this.labelTranslatedEpisodeTitle.Size = new System.Drawing.Size(116, 13); - this.labelTranslatedEpisodeTitle.TabIndex = 36; - this.labelTranslatedEpisodeTitle.Text = "Translated episode title"; - // - // labelTranslatedProgramTitle - // - this.labelTranslatedProgramTitle.AutoSize = true; - this.labelTranslatedProgramTitle.Location = new System.Drawing.Point(6, 235); - this.labelTranslatedProgramTitle.Name = "labelTranslatedProgramTitle"; - this.labelTranslatedProgramTitle.Size = new System.Drawing.Size(117, 13); - this.labelTranslatedProgramTitle.TabIndex = 35; - this.labelTranslatedProgramTitle.Text = "Translated program title"; - // - // labelOriginalEpisodeTitle - // - this.labelOriginalEpisodeTitle.AutoSize = true; - this.labelOriginalEpisodeTitle.Location = new System.Drawing.Point(6, 209); - this.labelOriginalEpisodeTitle.Name = "labelOriginalEpisodeTitle"; - this.labelOriginalEpisodeTitle.Size = new System.Drawing.Size(101, 13); - this.labelOriginalEpisodeTitle.TabIndex = 34; - this.labelOriginalEpisodeTitle.Text = "Original episode title"; - // - // textBoxOriginalProgramTitle - // - this.textBoxOriginalProgramTitle.Location = new System.Drawing.Point(181, 180); - this.textBoxOriginalProgramTitle.MaxLength = 32; - this.textBoxOriginalProgramTitle.Name = "textBoxOriginalProgramTitle"; - this.textBoxOriginalProgramTitle.Size = new System.Drawing.Size(219, 20); - this.textBoxOriginalProgramTitle.TabIndex = 6; - // - // labelOriginalProgramTitle - // - this.labelOriginalProgramTitle.AutoSize = true; - this.labelOriginalProgramTitle.Location = new System.Drawing.Point(6, 183); - this.labelOriginalProgramTitle.Name = "labelOriginalProgramTitle"; - this.labelOriginalProgramTitle.Size = new System.Drawing.Size(102, 13); - this.labelOriginalProgramTitle.TabIndex = 32; - this.labelOriginalProgramTitle.Text = "Original program title"; - // - // tabPageTextAndTiming - // - this.tabPageTextAndTiming.Controls.Add(this.groupBoxVerticalPosition); - this.tabPageTextAndTiming.Controls.Add(this.groupBoxTeletext); - this.tabPageTextAndTiming.Controls.Add(this.comboBoxJustificationCode); - this.tabPageTextAndTiming.Controls.Add(this.labelJustificationCode); - this.tabPageTextAndTiming.Location = new System.Drawing.Point(4, 22); - this.tabPageTextAndTiming.Name = "tabPageTextAndTiming"; - this.tabPageTextAndTiming.Size = new System.Drawing.Size(750, 461); - this.tabPageTextAndTiming.TabIndex = 2; - this.tabPageTextAndTiming.Text = "Text and timing information"; - this.tabPageTextAndTiming.UseVisualStyleBackColor = true; - // - // groupBoxVerticalPosition - // - this.groupBoxVerticalPosition.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxVerticalPosition.Controls.Add(this.labelUseBox); - this.groupBoxVerticalPosition.Controls.Add(this.numericUpDownNewLineRows); - this.groupBoxVerticalPosition.Controls.Add(this.labelNewLineRows); - this.groupBoxVerticalPosition.Controls.Add(this.labelMarginTop); - this.groupBoxVerticalPosition.Controls.Add(this.numericUpDownMarginBottom); - this.groupBoxVerticalPosition.Controls.Add(this.numericUpDownMarginTop); - this.groupBoxVerticalPosition.Controls.Add(this.labelMarginBottom); - this.groupBoxVerticalPosition.Location = new System.Drawing.Point(9, 49); - this.groupBoxVerticalPosition.Name = "groupBoxVerticalPosition"; - this.groupBoxVerticalPosition.Size = new System.Drawing.Size(727, 201); - this.groupBoxVerticalPosition.TabIndex = 46; - this.groupBoxVerticalPosition.TabStop = false; - this.groupBoxVerticalPosition.Text = "Vertical position"; - // - // labelUseBox - // - this.labelUseBox.AutoSize = true; - this.labelUseBox.ForeColor = System.Drawing.Color.Red; - this.labelUseBox.Location = new System.Drawing.Point(318, 80); - this.labelUseBox.Name = "labelUseBox"; - this.labelUseBox.Size = new System.Drawing.Size(240, 13); - this.labelUseBox.TabIndex = 73; - this.labelUseBox.Text = "Check \'Use box around text\' for only one new-line"; - this.labelUseBox.Visible = false; - // - // numericUpDownNewLineRows - // - this.numericUpDownNewLineRows.Location = new System.Drawing.Point(256, 78); - this.numericUpDownNewLineRows.Maximum = new decimal(new int[] { - 10, - 0, - 0, - 0}); - this.numericUpDownNewLineRows.Name = "numericUpDownNewLineRows"; - this.numericUpDownNewLineRows.Size = new System.Drawing.Size(56, 20); - this.numericUpDownNewLineRows.TabIndex = 54; - this.numericUpDownNewLineRows.Value = new decimal(new int[] { - 2, - 0, - 0, - 0}); - this.numericUpDownNewLineRows.ValueChanged += new System.EventHandler(this.numericUpDownNewLineRows_ValueChanged); - // - // labelNewLineRows - // - this.labelNewLineRows.AutoSize = true; - this.labelNewLineRows.Location = new System.Drawing.Point(13, 80); - this.labelNewLineRows.Name = "labelNewLineRows"; - this.labelNewLineRows.Size = new System.Drawing.Size(179, 13); - this.labelNewLineRows.TabIndex = 53; - this.labelNewLineRows.Text = "Number of rows added by a new line"; - // - // labelMarginTop - // - this.labelMarginTop.AutoSize = true; - this.labelMarginTop.Location = new System.Drawing.Point(13, 28); - this.labelMarginTop.Name = "labelMarginTop"; - this.labelMarginTop.Size = new System.Drawing.Size(174, 13); - this.labelMarginTop.TabIndex = 49; - this.labelMarginTop.Text = "Margin top (for top aligned subtitles)"; - // - // numericUpDownMarginBottom - // - this.numericUpDownMarginBottom.Location = new System.Drawing.Point(256, 52); - this.numericUpDownMarginBottom.Maximum = new decimal(new int[] { - 50, - 0, - 0, - 0}); - this.numericUpDownMarginBottom.Name = "numericUpDownMarginBottom"; - this.numericUpDownMarginBottom.Size = new System.Drawing.Size(56, 20); - this.numericUpDownMarginBottom.TabIndex = 52; - // - // numericUpDownMarginTop - // - this.numericUpDownMarginTop.Location = new System.Drawing.Point(256, 26); - this.numericUpDownMarginTop.Maximum = new decimal(new int[] { - 50, - 0, - 0, - 0}); - this.numericUpDownMarginTop.Name = "numericUpDownMarginTop"; - this.numericUpDownMarginTop.Size = new System.Drawing.Size(56, 20); - this.numericUpDownMarginTop.TabIndex = 48; - // - // labelMarginBottom - // - this.labelMarginBottom.AutoSize = true; - this.labelMarginBottom.Location = new System.Drawing.Point(13, 54); - this.labelMarginBottom.Name = "labelMarginBottom"; - this.labelMarginBottom.Size = new System.Drawing.Size(208, 13); - this.labelMarginBottom.TabIndex = 51; - this.labelMarginBottom.Text = "Margin bottom (for bottom aligned subtitles)"; - // - // groupBoxTeletext - // - this.groupBoxTeletext.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxTeletext.Controls.Add(this.checkBoxTeletextDoubleHeight); - this.groupBoxTeletext.Controls.Add(this.checkBoxTeletextBox); - this.groupBoxTeletext.Location = new System.Drawing.Point(9, 256); - this.groupBoxTeletext.Name = "groupBoxTeletext"; - this.groupBoxTeletext.Size = new System.Drawing.Size(727, 190); - this.groupBoxTeletext.TabIndex = 45; - this.groupBoxTeletext.TabStop = false; - this.groupBoxTeletext.Text = "Teletext"; - // - // checkBoxTeletextDoubleHeight - // - this.checkBoxTeletextDoubleHeight.AutoSize = true; - this.checkBoxTeletextDoubleHeight.Location = new System.Drawing.Point(16, 57); - this.checkBoxTeletextDoubleHeight.Name = "checkBoxTeletextDoubleHeight"; - this.checkBoxTeletextDoubleHeight.Size = new System.Drawing.Size(124, 17); - this.checkBoxTeletextDoubleHeight.TabIndex = 1; - this.checkBoxTeletextDoubleHeight.Text = "Text is double height"; - this.checkBoxTeletextDoubleHeight.UseVisualStyleBackColor = true; - // - // checkBoxTeletextBox - // - this.checkBoxTeletextBox.AutoSize = true; - this.checkBoxTeletextBox.Location = new System.Drawing.Point(16, 34); - this.checkBoxTeletextBox.Name = "checkBoxTeletextBox"; - this.checkBoxTeletextBox.Size = new System.Drawing.Size(121, 17); - this.checkBoxTeletextBox.TabIndex = 0; - this.checkBoxTeletextBox.Text = "Use box around text"; - this.checkBoxTeletextBox.UseVisualStyleBackColor = true; - this.checkBoxTeletextBox.CheckedChanged += new System.EventHandler(this.checkBoxTeletextBox_CheckedChanged); - // - // comboBoxJustificationCode - // - this.comboBoxJustificationCode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxJustificationCode.FormattingEnabled = true; - this.comboBoxJustificationCode.Items.AddRange(new object[] { - "unchanged presentation", - "left-justified text", - "centred text", - "right-justified text"}); - this.comboBoxJustificationCode.Location = new System.Drawing.Point(145, 11); - this.comboBoxJustificationCode.Name = "comboBoxJustificationCode"; - this.comboBoxJustificationCode.Size = new System.Drawing.Size(219, 21); - this.comboBoxJustificationCode.TabIndex = 43; - // - // labelJustificationCode - // - this.labelJustificationCode.AutoSize = true; - this.labelJustificationCode.Location = new System.Drawing.Point(6, 14); - this.labelJustificationCode.Name = "labelJustificationCode"; - this.labelJustificationCode.Size = new System.Drawing.Size(89, 13); - this.labelJustificationCode.TabIndex = 44; - this.labelJustificationCode.Text = "Justification code"; - // - // tabPageErrors - // - this.tabPageErrors.Controls.Add(this.textBoxErrors); - this.tabPageErrors.Controls.Add(this.labelErrors); - this.tabPageErrors.Location = new System.Drawing.Point(4, 22); - this.tabPageErrors.Name = "tabPageErrors"; - this.tabPageErrors.Padding = new System.Windows.Forms.Padding(3); - this.tabPageErrors.Size = new System.Drawing.Size(750, 461); - this.tabPageErrors.TabIndex = 1; - this.tabPageErrors.Text = "Errors"; - this.tabPageErrors.UseVisualStyleBackColor = true; - // - // textBoxErrors - // - this.textBoxErrors.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxErrors.Location = new System.Drawing.Point(6, 26); - this.textBoxErrors.Multiline = true; - this.textBoxErrors.Name = "textBoxErrors"; - this.textBoxErrors.ReadOnly = true; - this.textBoxErrors.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxErrors.Size = new System.Drawing.Size(729, 386); - this.textBoxErrors.TabIndex = 13; - // - // labelErrors - // - this.labelErrors.AutoSize = true; - this.labelErrors.Location = new System.Drawing.Point(3, 10); - this.labelErrors.Name = "labelErrors"; - this.labelErrors.Size = new System.Drawing.Size(34, 13); - this.labelErrors.TabIndex = 12; - this.labelErrors.Text = "Errors"; - // - // EbuSaveOptions - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(775, 542); - this.Controls.Add(this.tabControl1); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.MinimumSize = new System.Drawing.Size(785, 570); - this.Name = "EbuSaveOptions"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "EbuSaveOptions"; - this.tabControl1.ResumeLayout(false); - this.tabPageHeader.ResumeLayout(false); - this.tabPageHeader.PerformLayout(); - this.contextMenuStripCodeTable.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxRows)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDiskSequenceNumber)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTotalNumberOfDiscs)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRevisionNumber)).EndInit(); - this.tabPageTextAndTiming.ResumeLayout(false); - this.tabPageTextAndTiming.PerformLayout(); - this.groupBoxVerticalPosition.ResumeLayout(false); - this.groupBoxVerticalPosition.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNewLineRows)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginBottom)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginTop)).EndInit(); - this.groupBoxTeletext.ResumeLayout(false); - this.groupBoxTeletext.PerformLayout(); - this.tabPageErrors.ResumeLayout(false); - this.tabPageErrors.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.TabControl tabControl1; - private System.Windows.Forms.TabPage tabPageHeader; - private System.Windows.Forms.NumericUpDown numericUpDownDiskSequenceNumber; - private System.Windows.Forms.NumericUpDown numericUpDownTotalNumberOfDiscs; - private System.Windows.Forms.NumericUpDown numericUpDownRevisionNumber; - private System.Windows.Forms.Label labelDiskSequenceNumber; - private System.Windows.Forms.Label labelTotalNumberOfDisks; - private System.Windows.Forms.Label labelRevisionNumber; - private System.Windows.Forms.TextBox textBoxTranslatorsName; - private System.Windows.Forms.Label labelTranslatorsName; - private System.Windows.Forms.TextBox textBoxSubtitleListReferenceCode; - private System.Windows.Forms.Label labelSubtitleListReferenceCode; - private System.Windows.Forms.ComboBox comboBoxCharacterCodeTable; - private System.Windows.Forms.Button buttonImport; - private System.Windows.Forms.Label labelCharacterCodeTable; - private System.Windows.Forms.TextBox textBoxTranslatedProgramTitle; - private System.Windows.Forms.TextBox textBoxTranslatedEpisodeTitle; - private System.Windows.Forms.TextBox textBoxOriginalEpisodeTitle; - private System.Windows.Forms.Label labelTranslatedEpisodeTitle; - private System.Windows.Forms.Label labelTranslatedProgramTitle; - private System.Windows.Forms.Label labelOriginalEpisodeTitle; - private System.Windows.Forms.TextBox textBoxOriginalProgramTitle; - private System.Windows.Forms.Label labelOriginalProgramTitle; - private System.Windows.Forms.TabPage tabPageTextAndTiming; - private System.Windows.Forms.TabPage tabPageErrors; - private System.Windows.Forms.TextBox textBoxErrors; - private System.Windows.Forms.Label labelErrors; - private System.Windows.Forms.ComboBox comboBoxJustificationCode; - private System.Windows.Forms.Label labelJustificationCode; - private System.Windows.Forms.NumericUpDown numericUpDownMaxCharacters; - private System.Windows.Forms.Label labelMaxNoOfDisplayableChars; - private System.Windows.Forms.TextBox textBoxLanguageCode; - private System.Windows.Forms.Label labelLanguageCode; - private System.Windows.Forms.Label labelCodePageNumber; - private System.Windows.Forms.ComboBox comboBoxDiscFormatCode; - private System.Windows.Forms.Label labelDiskFormatCode; - private System.Windows.Forms.NumericUpDown numericUpDownMaxRows; - private System.Windows.Forms.Label labelMaxNumberOfDisplayableRows; - private System.Windows.Forms.TextBox textBoxCodePageNumber; - private System.Windows.Forms.ContextMenuStrip contextMenuStripCodeTable; - private System.Windows.Forms.ToolStripMenuItem unitedStatesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem multilingualToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem portugalToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem canadaFrenchToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem nordicToolStripMenuItem; - private System.Windows.Forms.TextBox textBoxCountryOfOrigin; - private System.Windows.Forms.Label labelCountryOfOrigin; - private System.Windows.Forms.ComboBox comboBoxDisplayStandardCode; - private System.Windows.Forms.Label labelDisplayStandardCode; - private System.Windows.Forms.Label labelTimeCodeStartOfProgramme; - private System.Windows.Forms.Label labelTimeCodeStatus; - private System.Windows.Forms.ComboBox comboBoxTimeCodeStatus; - private Controls.TimeUpDown timeUpDownStartTime; - private System.Windows.Forms.Label labelFrameRate; - private System.Windows.Forms.ComboBox comboBoxFrameRate; - private System.Windows.Forms.GroupBox groupBoxTeletext; - private System.Windows.Forms.CheckBox checkBoxTeletextDoubleHeight; - private System.Windows.Forms.CheckBox checkBoxTeletextBox; - private System.Windows.Forms.GroupBox groupBoxVerticalPosition; - private System.Windows.Forms.Label labelMarginBottom; - private System.Windows.Forms.NumericUpDown numericUpDownMarginTop; - private System.Windows.Forms.Label labelMarginTop; - private System.Windows.Forms.NumericUpDown numericUpDownNewLineRows; - private System.Windows.Forms.Label labelNewLineRows; - private System.Windows.Forms.NumericUpDown numericUpDownMarginBottom; - private System.Windows.Forms.Label labelDisplayStandardCodeWarning; - private System.Windows.Forms.Button buttonChooseLanguageCode; - private System.Windows.Forms.Label labelLanguageCodeFriendlyName; - private System.Windows.Forms.Label labelUseBox; - private System.Windows.Forms.Label labelMaxCharsPerRow38ForTeletext; - } +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + partial class EbuSaveOptions + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + TimeCode timeCode1 = new TimeCode(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPageHeader = new System.Windows.Forms.TabPage(); + this.labelMaxCharsPerRow38ForTeletext = new System.Windows.Forms.Label(); + this.labelLanguageCodeFriendlyName = new System.Windows.Forms.Label(); + this.buttonChooseLanguageCode = new System.Windows.Forms.Button(); + this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.labelDisplayStandardCodeWarning = new System.Windows.Forms.Label(); + this.labelFrameRate = new System.Windows.Forms.Label(); + this.comboBoxFrameRate = new System.Windows.Forms.ComboBox(); + this.labelTimeCodeStartOfProgramme = new System.Windows.Forms.Label(); + this.labelTimeCodeStatus = new System.Windows.Forms.Label(); + this.comboBoxTimeCodeStatus = new System.Windows.Forms.ComboBox(); + this.comboBoxDisplayStandardCode = new System.Windows.Forms.ComboBox(); + this.labelDisplayStandardCode = new System.Windows.Forms.Label(); + this.textBoxCountryOfOrigin = new System.Windows.Forms.TextBox(); + this.labelCountryOfOrigin = new System.Windows.Forms.Label(); + this.textBoxCodePageNumber = new System.Windows.Forms.TextBox(); + this.contextMenuStripCodeTable = new System.Windows.Forms.ContextMenuStrip(this.components); + this.unitedStatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.multilingualToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.portugalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.canadaFrenchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.nordicToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.numericUpDownMaxRows = new System.Windows.Forms.NumericUpDown(); + this.labelMaxNumberOfDisplayableRows = new System.Windows.Forms.Label(); + this.comboBoxDiscFormatCode = new System.Windows.Forms.ComboBox(); + this.labelDiskFormatCode = new System.Windows.Forms.Label(); + this.labelCodePageNumber = new System.Windows.Forms.Label(); + this.textBoxLanguageCode = new System.Windows.Forms.TextBox(); + this.labelLanguageCode = new System.Windows.Forms.Label(); + this.numericUpDownMaxCharacters = new System.Windows.Forms.NumericUpDown(); + this.labelMaxNoOfDisplayableChars = new System.Windows.Forms.Label(); + this.numericUpDownDiskSequenceNumber = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownTotalNumberOfDiscs = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownRevisionNumber = new System.Windows.Forms.NumericUpDown(); + this.labelDiskSequenceNumber = new System.Windows.Forms.Label(); + this.labelTotalNumberOfDisks = new System.Windows.Forms.Label(); + this.labelRevisionNumber = new System.Windows.Forms.Label(); + this.textBoxTranslatorsName = new System.Windows.Forms.TextBox(); + this.labelTranslatorsName = new System.Windows.Forms.Label(); + this.textBoxSubtitleListReferenceCode = new System.Windows.Forms.TextBox(); + this.labelSubtitleListReferenceCode = new System.Windows.Forms.Label(); + this.comboBoxCharacterCodeTable = new System.Windows.Forms.ComboBox(); + this.buttonImport = new System.Windows.Forms.Button(); + this.labelCharacterCodeTable = new System.Windows.Forms.Label(); + this.textBoxTranslatedProgramTitle = new System.Windows.Forms.TextBox(); + this.textBoxTranslatedEpisodeTitle = new System.Windows.Forms.TextBox(); + this.textBoxOriginalEpisodeTitle = new System.Windows.Forms.TextBox(); + this.labelTranslatedEpisodeTitle = new System.Windows.Forms.Label(); + this.labelTranslatedProgramTitle = new System.Windows.Forms.Label(); + this.labelOriginalEpisodeTitle = new System.Windows.Forms.Label(); + this.textBoxOriginalProgramTitle = new System.Windows.Forms.TextBox(); + this.labelOriginalProgramTitle = new System.Windows.Forms.Label(); + this.tabPageTextAndTiming = new System.Windows.Forms.TabPage(); + this.groupBoxVerticalPosition = new System.Windows.Forms.GroupBox(); + this.labelUseBox = new System.Windows.Forms.Label(); + this.numericUpDownNewLineRows = new System.Windows.Forms.NumericUpDown(); + this.labelNewLineRows = new System.Windows.Forms.Label(); + this.labelMarginTop = new System.Windows.Forms.Label(); + this.numericUpDownMarginBottom = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownMarginTop = new System.Windows.Forms.NumericUpDown(); + this.labelMarginBottom = new System.Windows.Forms.Label(); + this.groupBoxTeletext = new System.Windows.Forms.GroupBox(); + this.checkBoxTeletextDoubleHeight = new System.Windows.Forms.CheckBox(); + this.checkBoxTeletextBox = new System.Windows.Forms.CheckBox(); + this.comboBoxJustificationCode = new System.Windows.Forms.ComboBox(); + this.labelJustificationCode = new System.Windows.Forms.Label(); + this.tabPageErrors = new System.Windows.Forms.TabPage(); + this.textBoxErrors = new System.Windows.Forms.TextBox(); + this.labelErrors = new System.Windows.Forms.Label(); + this.tabControl1.SuspendLayout(); + this.tabPageHeader.SuspendLayout(); + this.contextMenuStripCodeTable.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxRows)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDiskSequenceNumber)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTotalNumberOfDiscs)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRevisionNumber)).BeginInit(); + this.tabPageTextAndTiming.SuspendLayout(); + this.groupBoxVerticalPosition.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNewLineRows)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginBottom)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginTop)).BeginInit(); + this.groupBoxTeletext.SuspendLayout(); + this.tabPageErrors.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(607, 510); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 1; + this.buttonOK.Text = "Save"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(688, 510); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 2; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // tabControl1 + // + this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl1.Controls.Add(this.tabPageHeader); + this.tabControl1.Controls.Add(this.tabPageTextAndTiming); + this.tabControl1.Controls.Add(this.tabPageErrors); + this.tabControl1.Location = new System.Drawing.Point(12, 12); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(758, 487); + this.tabControl1.TabIndex = 0; + // + // tabPageHeader + // + this.tabPageHeader.Controls.Add(this.labelMaxCharsPerRow38ForTeletext); + this.tabPageHeader.Controls.Add(this.labelLanguageCodeFriendlyName); + this.tabPageHeader.Controls.Add(this.buttonChooseLanguageCode); + this.tabPageHeader.Controls.Add(this.timeUpDownStartTime); + this.tabPageHeader.Controls.Add(this.labelDisplayStandardCodeWarning); + this.tabPageHeader.Controls.Add(this.labelFrameRate); + this.tabPageHeader.Controls.Add(this.comboBoxFrameRate); + this.tabPageHeader.Controls.Add(this.labelTimeCodeStartOfProgramme); + this.tabPageHeader.Controls.Add(this.labelTimeCodeStatus); + this.tabPageHeader.Controls.Add(this.comboBoxTimeCodeStatus); + this.tabPageHeader.Controls.Add(this.comboBoxDisplayStandardCode); + this.tabPageHeader.Controls.Add(this.labelDisplayStandardCode); + this.tabPageHeader.Controls.Add(this.textBoxCountryOfOrigin); + this.tabPageHeader.Controls.Add(this.labelCountryOfOrigin); + this.tabPageHeader.Controls.Add(this.textBoxCodePageNumber); + this.tabPageHeader.Controls.Add(this.numericUpDownMaxRows); + this.tabPageHeader.Controls.Add(this.labelMaxNumberOfDisplayableRows); + this.tabPageHeader.Controls.Add(this.comboBoxDiscFormatCode); + this.tabPageHeader.Controls.Add(this.labelDiskFormatCode); + this.tabPageHeader.Controls.Add(this.labelCodePageNumber); + this.tabPageHeader.Controls.Add(this.textBoxLanguageCode); + this.tabPageHeader.Controls.Add(this.labelLanguageCode); + this.tabPageHeader.Controls.Add(this.numericUpDownMaxCharacters); + this.tabPageHeader.Controls.Add(this.labelMaxNoOfDisplayableChars); + this.tabPageHeader.Controls.Add(this.numericUpDownDiskSequenceNumber); + this.tabPageHeader.Controls.Add(this.numericUpDownTotalNumberOfDiscs); + this.tabPageHeader.Controls.Add(this.numericUpDownRevisionNumber); + this.tabPageHeader.Controls.Add(this.labelDiskSequenceNumber); + this.tabPageHeader.Controls.Add(this.labelTotalNumberOfDisks); + this.tabPageHeader.Controls.Add(this.labelRevisionNumber); + this.tabPageHeader.Controls.Add(this.textBoxTranslatorsName); + this.tabPageHeader.Controls.Add(this.labelTranslatorsName); + this.tabPageHeader.Controls.Add(this.textBoxSubtitleListReferenceCode); + this.tabPageHeader.Controls.Add(this.labelSubtitleListReferenceCode); + this.tabPageHeader.Controls.Add(this.comboBoxCharacterCodeTable); + this.tabPageHeader.Controls.Add(this.buttonImport); + this.tabPageHeader.Controls.Add(this.labelCharacterCodeTable); + this.tabPageHeader.Controls.Add(this.textBoxTranslatedProgramTitle); + this.tabPageHeader.Controls.Add(this.textBoxTranslatedEpisodeTitle); + this.tabPageHeader.Controls.Add(this.textBoxOriginalEpisodeTitle); + this.tabPageHeader.Controls.Add(this.labelTranslatedEpisodeTitle); + this.tabPageHeader.Controls.Add(this.labelTranslatedProgramTitle); + this.tabPageHeader.Controls.Add(this.labelOriginalEpisodeTitle); + this.tabPageHeader.Controls.Add(this.textBoxOriginalProgramTitle); + this.tabPageHeader.Controls.Add(this.labelOriginalProgramTitle); + this.tabPageHeader.Location = new System.Drawing.Point(4, 22); + this.tabPageHeader.Name = "tabPageHeader"; + this.tabPageHeader.Padding = new System.Windows.Forms.Padding(3); + this.tabPageHeader.Size = new System.Drawing.Size(750, 461); + this.tabPageHeader.TabIndex = 0; + this.tabPageHeader.Text = "General subtitle information"; + this.tabPageHeader.UseVisualStyleBackColor = true; + // + // labelMaxCharsPerRow38ForTeletext + // + this.labelMaxCharsPerRow38ForTeletext.AutoSize = true; + this.labelMaxCharsPerRow38ForTeletext.ForeColor = System.Drawing.Color.Red; + this.labelMaxCharsPerRow38ForTeletext.Location = new System.Drawing.Point(443, 347); + this.labelMaxCharsPerRow38ForTeletext.Name = "labelMaxCharsPerRow38ForTeletext"; + this.labelMaxCharsPerRow38ForTeletext.Size = new System.Drawing.Size(198, 13); + this.labelMaxCharsPerRow38ForTeletext.TabIndex = 74; + this.labelMaxCharsPerRow38ForTeletext.Text = "Use 38 in \'Max chars per row\' for teletext"; + // + // labelLanguageCodeFriendlyName + // + this.labelLanguageCodeFriendlyName.AutoSize = true; + this.labelLanguageCodeFriendlyName.ForeColor = System.Drawing.SystemColors.GrayText; + this.labelLanguageCodeFriendlyName.Location = new System.Drawing.Point(440, 157); + this.labelLanguageCodeFriendlyName.Name = "labelLanguageCodeFriendlyName"; + this.labelLanguageCodeFriendlyName.Size = new System.Drawing.Size(166, 13); + this.labelLanguageCodeFriendlyName.TabIndex = 73; + this.labelLanguageCodeFriendlyName.Text = "labelLanguageCodeFriendlyName"; + // + // buttonChooseLanguageCode + // + this.buttonChooseLanguageCode.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonChooseLanguageCode.Location = new System.Drawing.Point(405, 153); + this.buttonChooseLanguageCode.Name = "buttonChooseLanguageCode"; + this.buttonChooseLanguageCode.Size = new System.Drawing.Size(31, 21); + this.buttonChooseLanguageCode.TabIndex = 6; + this.buttonChooseLanguageCode.Text = "..."; + this.buttonChooseLanguageCode.UseVisualStyleBackColor = true; + this.buttonChooseLanguageCode.Click += new System.EventHandler(this.buttonChooseLanguageCode_Click); + // + // timeUpDownStartTime + // + this.timeUpDownStartTime.AutoSize = true; + this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownStartTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + this.timeUpDownStartTime.Location = new System.Drawing.Point(179, 411); + this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownStartTime.Name = "timeUpDownStartTime"; + this.timeUpDownStartTime.Size = new System.Drawing.Size(111, 27); + this.timeUpDownStartTime.TabIndex = 14; + timeCode1.Hours = 0; + timeCode1.Milliseconds = 0; + timeCode1.Minutes = 0; + timeCode1.Seconds = 0; + timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode1.TotalMilliseconds = 0D; + timeCode1.TotalSeconds = 0D; + this.timeUpDownStartTime.TimeCode = timeCode1; + this.timeUpDownStartTime.UseVideoOffset = false; + // + // labelDisplayStandardCodeWarning + // + this.labelDisplayStandardCodeWarning.AutoSize = true; + this.labelDisplayStandardCodeWarning.ForeColor = System.Drawing.Color.Red; + this.labelDisplayStandardCodeWarning.Location = new System.Drawing.Point(406, 102); + this.labelDisplayStandardCodeWarning.Name = "labelDisplayStandardCodeWarning"; + this.labelDisplayStandardCodeWarning.Size = new System.Drawing.Size(146, 13); + this.labelDisplayStandardCodeWarning.TabIndex = 72; + this.labelDisplayStandardCodeWarning.Text = "Use teletext to include colors!"; + // + // labelFrameRate + // + this.labelFrameRate.AutoSize = true; + this.labelFrameRate.Location = new System.Drawing.Point(6, 72); + this.labelFrameRate.Name = "labelFrameRate"; + this.labelFrameRate.Size = new System.Drawing.Size(57, 13); + this.labelFrameRate.TabIndex = 71; + this.labelFrameRate.Text = "Frame rate"; + // + // comboBoxFrameRate + // + this.comboBoxFrameRate.FormattingEnabled = true; + this.comboBoxFrameRate.Location = new System.Drawing.Point(181, 69); + this.comboBoxFrameRate.Name = "comboBoxFrameRate"; + this.comboBoxFrameRate.Size = new System.Drawing.Size(219, 21); + this.comboBoxFrameRate.TabIndex = 2; + // + // labelTimeCodeStartOfProgramme + // + this.labelTimeCodeStartOfProgramme.AutoSize = true; + this.labelTimeCodeStartOfProgramme.Location = new System.Drawing.Point(5, 416); + this.labelTimeCodeStartOfProgramme.Name = "labelTimeCodeStartOfProgramme"; + this.labelTimeCodeStartOfProgramme.Size = new System.Drawing.Size(152, 13); + this.labelTimeCodeStartOfProgramme.TabIndex = 69; + this.labelTimeCodeStartOfProgramme.Text = "Time code: Start of programme"; + // + // labelTimeCodeStatus + // + this.labelTimeCodeStatus.AutoSize = true; + this.labelTimeCodeStatus.Location = new System.Drawing.Point(6, 386); + this.labelTimeCodeStatus.Name = "labelTimeCodeStatus"; + this.labelTimeCodeStatus.Size = new System.Drawing.Size(88, 13); + this.labelTimeCodeStatus.TabIndex = 68; + this.labelTimeCodeStatus.Text = "Time code status"; + // + // comboBoxTimeCodeStatus + // + this.comboBoxTimeCodeStatus.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxTimeCodeStatus.FormattingEnabled = true; + this.comboBoxTimeCodeStatus.Items.AddRange(new object[] { + "Not intended for use", + "Intended for use"}); + this.comboBoxTimeCodeStatus.Location = new System.Drawing.Point(181, 383); + this.comboBoxTimeCodeStatus.Name = "comboBoxTimeCodeStatus"; + this.comboBoxTimeCodeStatus.Size = new System.Drawing.Size(219, 21); + this.comboBoxTimeCodeStatus.TabIndex = 13; + // + // comboBoxDisplayStandardCode + // + this.comboBoxDisplayStandardCode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxDisplayStandardCode.FormattingEnabled = true; + this.comboBoxDisplayStandardCode.Items.AddRange(new object[] { + "0 Open subtitling", + "1 Level-1 teletext", + "2 Level-2 teletext", + "Undefined"}); + this.comboBoxDisplayStandardCode.Location = new System.Drawing.Point(181, 99); + this.comboBoxDisplayStandardCode.Name = "comboBoxDisplayStandardCode"; + this.comboBoxDisplayStandardCode.Size = new System.Drawing.Size(219, 21); + this.comboBoxDisplayStandardCode.TabIndex = 3; + this.comboBoxDisplayStandardCode.SelectedIndexChanged += new System.EventHandler(this.comboBoxDisplayStandardCode_SelectedIndexChanged); + // + // labelDisplayStandardCode + // + this.labelDisplayStandardCode.AutoSize = true; + this.labelDisplayStandardCode.Location = new System.Drawing.Point(6, 102); + this.labelDisplayStandardCode.Name = "labelDisplayStandardCode"; + this.labelDisplayStandardCode.Size = new System.Drawing.Size(112, 13); + this.labelDisplayStandardCode.TabIndex = 65; + this.labelDisplayStandardCode.Text = "Display standard code"; + // + // textBoxCountryOfOrigin + // + this.textBoxCountryOfOrigin.Location = new System.Drawing.Point(181, 340); + this.textBoxCountryOfOrigin.MaxLength = 3; + this.textBoxCountryOfOrigin.Name = "textBoxCountryOfOrigin"; + this.textBoxCountryOfOrigin.Size = new System.Drawing.Size(219, 20); + this.textBoxCountryOfOrigin.TabIndex = 12; + // + // labelCountryOfOrigin + // + this.labelCountryOfOrigin.AutoSize = true; + this.labelCountryOfOrigin.Location = new System.Drawing.Point(6, 343); + this.labelCountryOfOrigin.Name = "labelCountryOfOrigin"; + this.labelCountryOfOrigin.Size = new System.Drawing.Size(83, 13); + this.labelCountryOfOrigin.TabIndex = 63; + this.labelCountryOfOrigin.Text = "Country of origin"; + // + // textBoxCodePageNumber + // + this.textBoxCodePageNumber.ContextMenuStrip = this.contextMenuStripCodeTable; + this.textBoxCodePageNumber.Location = new System.Drawing.Point(181, 12); + this.textBoxCodePageNumber.MaxLength = 3; + this.textBoxCodePageNumber.Name = "textBoxCodePageNumber"; + this.textBoxCodePageNumber.Size = new System.Drawing.Size(219, 20); + this.textBoxCodePageNumber.TabIndex = 0; + // + // contextMenuStripCodeTable + // + this.contextMenuStripCodeTable.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.unitedStatesToolStripMenuItem, + this.multilingualToolStripMenuItem, + this.portugalToolStripMenuItem, + this.canadaFrenchToolStripMenuItem, + this.nordicToolStripMenuItem}); + this.contextMenuStripCodeTable.Name = "contextMenuStripCodeTable"; + this.contextMenuStripCodeTable.Size = new System.Drawing.Size(185, 114); + // + // unitedStatesToolStripMenuItem + // + this.unitedStatesToolStripMenuItem.Name = "unitedStatesToolStripMenuItem"; + this.unitedStatesToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.unitedStatesToolStripMenuItem.Text = "United States (437)"; + this.unitedStatesToolStripMenuItem.Click += new System.EventHandler(this.unitedStatesToolStripMenuItem_Click); + // + // multilingualToolStripMenuItem + // + this.multilingualToolStripMenuItem.Name = "multilingualToolStripMenuItem"; + this.multilingualToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.multilingualToolStripMenuItem.Text = "Multilingual (850)"; + this.multilingualToolStripMenuItem.Click += new System.EventHandler(this.multilingualToolStripMenuItem_Click); + // + // portugalToolStripMenuItem + // + this.portugalToolStripMenuItem.Name = "portugalToolStripMenuItem"; + this.portugalToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.portugalToolStripMenuItem.Text = "Portugal (860)"; + this.portugalToolStripMenuItem.Click += new System.EventHandler(this.portugalToolStripMenuItem_Click); + // + // canadaFrenchToolStripMenuItem + // + this.canadaFrenchToolStripMenuItem.Name = "canadaFrenchToolStripMenuItem"; + this.canadaFrenchToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.canadaFrenchToolStripMenuItem.Text = "Canada-French (863)"; + this.canadaFrenchToolStripMenuItem.Click += new System.EventHandler(this.canadaFrenchToolStripMenuItem_Click); + // + // nordicToolStripMenuItem + // + this.nordicToolStripMenuItem.Name = "nordicToolStripMenuItem"; + this.nordicToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.nordicToolStripMenuItem.Text = "Nordic (865)"; + this.nordicToolStripMenuItem.Click += new System.EventHandler(this.nordicToolStripMenuItem_Click); + // + // numericUpDownMaxRows + // + this.numericUpDownMaxRows.Location = new System.Drawing.Point(613, 251); + this.numericUpDownMaxRows.Maximum = new decimal(new int[] { + 99, + 0, + 0, + 0}); + this.numericUpDownMaxRows.Name = "numericUpDownMaxRows"; + this.numericUpDownMaxRows.Size = new System.Drawing.Size(120, 20); + this.numericUpDownMaxRows.TabIndex = 17; + // + // labelMaxNumberOfDisplayableRows + // + this.labelMaxNumberOfDisplayableRows.AutoSize = true; + this.labelMaxNumberOfDisplayableRows.Location = new System.Drawing.Point(473, 253); + this.labelMaxNumberOfDisplayableRows.Name = "labelMaxNumberOfDisplayableRows"; + this.labelMaxNumberOfDisplayableRows.Size = new System.Drawing.Size(126, 13); + this.labelMaxNumberOfDisplayableRows.TabIndex = 60; + this.labelMaxNumberOfDisplayableRows.Text = "Max# of displayable rows"; + // + // comboBoxDiscFormatCode + // + this.comboBoxDiscFormatCode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxDiscFormatCode.FormattingEnabled = true; + this.comboBoxDiscFormatCode.Items.AddRange(new object[] { + "STL23.01 (non-standard)", + "STL24.01 (non-standard)", + "STL25.01", + "STL29.01 (non-standard)", + "STL30.01"}); + this.comboBoxDiscFormatCode.Location = new System.Drawing.Point(181, 39); + this.comboBoxDiscFormatCode.Name = "comboBoxDiscFormatCode"; + this.comboBoxDiscFormatCode.Size = new System.Drawing.Size(219, 21); + this.comboBoxDiscFormatCode.TabIndex = 1; + this.comboBoxDiscFormatCode.SelectedIndexChanged += new System.EventHandler(this.comboBoxDiscFormatCode_SelectedIndexChanged); + // + // labelDiskFormatCode + // + this.labelDiskFormatCode.AutoSize = true; + this.labelDiskFormatCode.Location = new System.Drawing.Point(6, 42); + this.labelDiskFormatCode.Name = "labelDiskFormatCode"; + this.labelDiskFormatCode.Size = new System.Drawing.Size(87, 13); + this.labelDiskFormatCode.TabIndex = 58; + this.labelDiskFormatCode.Text = "Disk format code"; + // + // labelCodePageNumber + // + this.labelCodePageNumber.AutoSize = true; + this.labelCodePageNumber.Location = new System.Drawing.Point(6, 15); + this.labelCodePageNumber.Name = "labelCodePageNumber"; + this.labelCodePageNumber.Size = new System.Drawing.Size(97, 13); + this.labelCodePageNumber.TabIndex = 56; + this.labelCodePageNumber.Text = "Code page number"; + // + // textBoxLanguageCode + // + this.textBoxLanguageCode.Location = new System.Drawing.Point(181, 154); + this.textBoxLanguageCode.MaxLength = 32; + this.textBoxLanguageCode.Name = "textBoxLanguageCode"; + this.textBoxLanguageCode.Size = new System.Drawing.Size(219, 20); + this.textBoxLanguageCode.TabIndex = 5; + this.textBoxLanguageCode.TextChanged += new System.EventHandler(this.textBoxLanguageCode_TextChanged); + // + // labelLanguageCode + // + this.labelLanguageCode.AutoSize = true; + this.labelLanguageCode.Location = new System.Drawing.Point(6, 157); + this.labelLanguageCode.Name = "labelLanguageCode"; + this.labelLanguageCode.Size = new System.Drawing.Size(82, 13); + this.labelLanguageCode.TabIndex = 54; + this.labelLanguageCode.Text = "Language code"; + // + // numericUpDownMaxCharacters + // + this.numericUpDownMaxCharacters.Location = new System.Drawing.Point(613, 225); + this.numericUpDownMaxCharacters.Maximum = new decimal(new int[] { + 99, + 0, + 0, + 0}); + this.numericUpDownMaxCharacters.Name = "numericUpDownMaxCharacters"; + this.numericUpDownMaxCharacters.Size = new System.Drawing.Size(120, 20); + this.numericUpDownMaxCharacters.TabIndex = 16; + this.numericUpDownMaxCharacters.ValueChanged += new System.EventHandler(this.numericUpDownMaxCharacters_ValueChanged); + // + // labelMaxNoOfDisplayableChars + // + this.labelMaxNoOfDisplayableChars.AutoSize = true; + this.labelMaxNoOfDisplayableChars.Location = new System.Drawing.Point(473, 227); + this.labelMaxNoOfDisplayableChars.Name = "labelMaxNoOfDisplayableChars"; + this.labelMaxNoOfDisplayableChars.Size = new System.Drawing.Size(133, 13); + this.labelMaxNoOfDisplayableChars.TabIndex = 51; + this.labelMaxNoOfDisplayableChars.Text = "Max# of displayable chars "; + // + // numericUpDownDiskSequenceNumber + // + this.numericUpDownDiskSequenceNumber.Location = new System.Drawing.Point(613, 277); + this.numericUpDownDiskSequenceNumber.Maximum = new decimal(new int[] { + 9, + 0, + 0, + 0}); + this.numericUpDownDiskSequenceNumber.Name = "numericUpDownDiskSequenceNumber"; + this.numericUpDownDiskSequenceNumber.Size = new System.Drawing.Size(120, 20); + this.numericUpDownDiskSequenceNumber.TabIndex = 18; + // + // numericUpDownTotalNumberOfDiscs + // + this.numericUpDownTotalNumberOfDiscs.Location = new System.Drawing.Point(613, 303); + this.numericUpDownTotalNumberOfDiscs.Maximum = new decimal(new int[] { + 9, + 0, + 0, + 0}); + this.numericUpDownTotalNumberOfDiscs.Name = "numericUpDownTotalNumberOfDiscs"; + this.numericUpDownTotalNumberOfDiscs.Size = new System.Drawing.Size(120, 20); + this.numericUpDownTotalNumberOfDiscs.TabIndex = 19; + // + // numericUpDownRevisionNumber + // + this.numericUpDownRevisionNumber.Location = new System.Drawing.Point(613, 199); + this.numericUpDownRevisionNumber.Maximum = new decimal(new int[] { + 99, + 0, + 0, + 0}); + this.numericUpDownRevisionNumber.Name = "numericUpDownRevisionNumber"; + this.numericUpDownRevisionNumber.Size = new System.Drawing.Size(120, 20); + this.numericUpDownRevisionNumber.TabIndex = 15; + // + // labelDiskSequenceNumber + // + this.labelDiskSequenceNumber.AutoSize = true; + this.labelDiskSequenceNumber.Location = new System.Drawing.Point(473, 279); + this.labelDiskSequenceNumber.Name = "labelDiskSequenceNumber"; + this.labelDiskSequenceNumber.Size = new System.Drawing.Size(116, 13); + this.labelDiskSequenceNumber.TabIndex = 49; + this.labelDiskSequenceNumber.Text = "Disk sequence number"; + // + // labelTotalNumberOfDisks + // + this.labelTotalNumberOfDisks.AutoSize = true; + this.labelTotalNumberOfDisks.Location = new System.Drawing.Point(473, 305); + this.labelTotalNumberOfDisks.Name = "labelTotalNumberOfDisks"; + this.labelTotalNumberOfDisks.Size = new System.Drawing.Size(108, 13); + this.labelTotalNumberOfDisks.TabIndex = 48; + this.labelTotalNumberOfDisks.Text = "Total number of disks"; + // + // labelRevisionNumber + // + this.labelRevisionNumber.AutoSize = true; + this.labelRevisionNumber.Location = new System.Drawing.Point(473, 201); + this.labelRevisionNumber.Name = "labelRevisionNumber"; + this.labelRevisionNumber.Size = new System.Drawing.Size(86, 13); + this.labelRevisionNumber.TabIndex = 47; + this.labelRevisionNumber.Text = "Revision number"; + // + // textBoxTranslatorsName + // + this.textBoxTranslatorsName.Location = new System.Drawing.Point(181, 284); + this.textBoxTranslatorsName.MaxLength = 32; + this.textBoxTranslatorsName.Name = "textBoxTranslatorsName"; + this.textBoxTranslatorsName.Size = new System.Drawing.Size(219, 20); + this.textBoxTranslatorsName.TabIndex = 10; + // + // labelTranslatorsName + // + this.labelTranslatorsName.AutoSize = true; + this.labelTranslatorsName.Location = new System.Drawing.Point(6, 287); + this.labelTranslatorsName.Name = "labelTranslatorsName"; + this.labelTranslatorsName.Size = new System.Drawing.Size(90, 13); + this.labelTranslatorsName.TabIndex = 45; + this.labelTranslatorsName.Text = "Translator\'s name"; + // + // textBoxSubtitleListReferenceCode + // + this.textBoxSubtitleListReferenceCode.Location = new System.Drawing.Point(181, 314); + this.textBoxSubtitleListReferenceCode.MaxLength = 16; + this.textBoxSubtitleListReferenceCode.Name = "textBoxSubtitleListReferenceCode"; + this.textBoxSubtitleListReferenceCode.Size = new System.Drawing.Size(219, 20); + this.textBoxSubtitleListReferenceCode.TabIndex = 11; + // + // labelSubtitleListReferenceCode + // + this.labelSubtitleListReferenceCode.AutoSize = true; + this.labelSubtitleListReferenceCode.Location = new System.Drawing.Point(6, 317); + this.labelSubtitleListReferenceCode.Name = "labelSubtitleListReferenceCode"; + this.labelSubtitleListReferenceCode.Size = new System.Drawing.Size(132, 13); + this.labelSubtitleListReferenceCode.TabIndex = 43; + this.labelSubtitleListReferenceCode.Text = "Subtitle list reference code"; + // + // comboBoxCharacterCodeTable + // + this.comboBoxCharacterCodeTable.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxCharacterCodeTable.FormattingEnabled = true; + this.comboBoxCharacterCodeTable.Items.AddRange(new object[] { + "Latin", + "Latin/Cyrillic", + "Latin/Arabic", + "Latin/Greek", + "Latin/Hebrew"}); + this.comboBoxCharacterCodeTable.Location = new System.Drawing.Point(181, 126); + this.comboBoxCharacterCodeTable.Name = "comboBoxCharacterCodeTable"; + this.comboBoxCharacterCodeTable.Size = new System.Drawing.Size(219, 21); + this.comboBoxCharacterCodeTable.TabIndex = 4; + // + // buttonImport + // + this.buttonImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonImport.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonImport.Location = new System.Drawing.Point(613, 6); + this.buttonImport.Name = "buttonImport"; + this.buttonImport.Size = new System.Drawing.Size(134, 23); + this.buttonImport.TabIndex = 20; + this.buttonImport.Text = "Import..."; + this.buttonImport.UseVisualStyleBackColor = true; + this.buttonImport.Click += new System.EventHandler(this.buttonImport_Click); + // + // labelCharacterCodeTable + // + this.labelCharacterCodeTable.AutoSize = true; + this.labelCharacterCodeTable.Location = new System.Drawing.Point(6, 129); + this.labelCharacterCodeTable.Name = "labelCharacterCodeTable"; + this.labelCharacterCodeTable.Size = new System.Drawing.Size(106, 13); + this.labelCharacterCodeTable.TabIndex = 40; + this.labelCharacterCodeTable.Text = "Character code table"; + // + // textBoxTranslatedProgramTitle + // + this.textBoxTranslatedProgramTitle.Location = new System.Drawing.Point(181, 232); + this.textBoxTranslatedProgramTitle.MaxLength = 32; + this.textBoxTranslatedProgramTitle.Name = "textBoxTranslatedProgramTitle"; + this.textBoxTranslatedProgramTitle.Size = new System.Drawing.Size(219, 20); + this.textBoxTranslatedProgramTitle.TabIndex = 8; + // + // textBoxTranslatedEpisodeTitle + // + this.textBoxTranslatedEpisodeTitle.Location = new System.Drawing.Point(181, 258); + this.textBoxTranslatedEpisodeTitle.MaxLength = 32; + this.textBoxTranslatedEpisodeTitle.Name = "textBoxTranslatedEpisodeTitle"; + this.textBoxTranslatedEpisodeTitle.Size = new System.Drawing.Size(219, 20); + this.textBoxTranslatedEpisodeTitle.TabIndex = 9; + // + // textBoxOriginalEpisodeTitle + // + this.textBoxOriginalEpisodeTitle.Location = new System.Drawing.Point(181, 206); + this.textBoxOriginalEpisodeTitle.MaxLength = 32; + this.textBoxOriginalEpisodeTitle.Name = "textBoxOriginalEpisodeTitle"; + this.textBoxOriginalEpisodeTitle.Size = new System.Drawing.Size(219, 20); + this.textBoxOriginalEpisodeTitle.TabIndex = 7; + // + // labelTranslatedEpisodeTitle + // + this.labelTranslatedEpisodeTitle.AutoSize = true; + this.labelTranslatedEpisodeTitle.Location = new System.Drawing.Point(6, 261); + this.labelTranslatedEpisodeTitle.Name = "labelTranslatedEpisodeTitle"; + this.labelTranslatedEpisodeTitle.Size = new System.Drawing.Size(116, 13); + this.labelTranslatedEpisodeTitle.TabIndex = 36; + this.labelTranslatedEpisodeTitle.Text = "Translated episode title"; + // + // labelTranslatedProgramTitle + // + this.labelTranslatedProgramTitle.AutoSize = true; + this.labelTranslatedProgramTitle.Location = new System.Drawing.Point(6, 235); + this.labelTranslatedProgramTitle.Name = "labelTranslatedProgramTitle"; + this.labelTranslatedProgramTitle.Size = new System.Drawing.Size(117, 13); + this.labelTranslatedProgramTitle.TabIndex = 35; + this.labelTranslatedProgramTitle.Text = "Translated program title"; + // + // labelOriginalEpisodeTitle + // + this.labelOriginalEpisodeTitle.AutoSize = true; + this.labelOriginalEpisodeTitle.Location = new System.Drawing.Point(6, 209); + this.labelOriginalEpisodeTitle.Name = "labelOriginalEpisodeTitle"; + this.labelOriginalEpisodeTitle.Size = new System.Drawing.Size(101, 13); + this.labelOriginalEpisodeTitle.TabIndex = 34; + this.labelOriginalEpisodeTitle.Text = "Original episode title"; + // + // textBoxOriginalProgramTitle + // + this.textBoxOriginalProgramTitle.Location = new System.Drawing.Point(181, 180); + this.textBoxOriginalProgramTitle.MaxLength = 32; + this.textBoxOriginalProgramTitle.Name = "textBoxOriginalProgramTitle"; + this.textBoxOriginalProgramTitle.Size = new System.Drawing.Size(219, 20); + this.textBoxOriginalProgramTitle.TabIndex = 6; + // + // labelOriginalProgramTitle + // + this.labelOriginalProgramTitle.AutoSize = true; + this.labelOriginalProgramTitle.Location = new System.Drawing.Point(6, 183); + this.labelOriginalProgramTitle.Name = "labelOriginalProgramTitle"; + this.labelOriginalProgramTitle.Size = new System.Drawing.Size(102, 13); + this.labelOriginalProgramTitle.TabIndex = 32; + this.labelOriginalProgramTitle.Text = "Original program title"; + // + // tabPageTextAndTiming + // + this.tabPageTextAndTiming.Controls.Add(this.groupBoxVerticalPosition); + this.tabPageTextAndTiming.Controls.Add(this.groupBoxTeletext); + this.tabPageTextAndTiming.Controls.Add(this.comboBoxJustificationCode); + this.tabPageTextAndTiming.Controls.Add(this.labelJustificationCode); + this.tabPageTextAndTiming.Location = new System.Drawing.Point(4, 22); + this.tabPageTextAndTiming.Name = "tabPageTextAndTiming"; + this.tabPageTextAndTiming.Size = new System.Drawing.Size(750, 461); + this.tabPageTextAndTiming.TabIndex = 2; + this.tabPageTextAndTiming.Text = "Text and timing information"; + this.tabPageTextAndTiming.UseVisualStyleBackColor = true; + // + // groupBoxVerticalPosition + // + this.groupBoxVerticalPosition.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxVerticalPosition.Controls.Add(this.labelUseBox); + this.groupBoxVerticalPosition.Controls.Add(this.numericUpDownNewLineRows); + this.groupBoxVerticalPosition.Controls.Add(this.labelNewLineRows); + this.groupBoxVerticalPosition.Controls.Add(this.labelMarginTop); + this.groupBoxVerticalPosition.Controls.Add(this.numericUpDownMarginBottom); + this.groupBoxVerticalPosition.Controls.Add(this.numericUpDownMarginTop); + this.groupBoxVerticalPosition.Controls.Add(this.labelMarginBottom); + this.groupBoxVerticalPosition.Location = new System.Drawing.Point(9, 49); + this.groupBoxVerticalPosition.Name = "groupBoxVerticalPosition"; + this.groupBoxVerticalPosition.Size = new System.Drawing.Size(727, 201); + this.groupBoxVerticalPosition.TabIndex = 46; + this.groupBoxVerticalPosition.TabStop = false; + this.groupBoxVerticalPosition.Text = "Vertical position"; + // + // labelUseBox + // + this.labelUseBox.AutoSize = true; + this.labelUseBox.ForeColor = System.Drawing.Color.Red; + this.labelUseBox.Location = new System.Drawing.Point(318, 80); + this.labelUseBox.Name = "labelUseBox"; + this.labelUseBox.Size = new System.Drawing.Size(240, 13); + this.labelUseBox.TabIndex = 73; + this.labelUseBox.Text = "Check \'Use box around text\' for only one new-line"; + this.labelUseBox.Visible = false; + // + // numericUpDownNewLineRows + // + this.numericUpDownNewLineRows.Location = new System.Drawing.Point(256, 78); + this.numericUpDownNewLineRows.Maximum = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDownNewLineRows.Name = "numericUpDownNewLineRows"; + this.numericUpDownNewLineRows.Size = new System.Drawing.Size(56, 20); + this.numericUpDownNewLineRows.TabIndex = 54; + this.numericUpDownNewLineRows.Value = new decimal(new int[] { + 2, + 0, + 0, + 0}); + this.numericUpDownNewLineRows.ValueChanged += new System.EventHandler(this.numericUpDownNewLineRows_ValueChanged); + // + // labelNewLineRows + // + this.labelNewLineRows.AutoSize = true; + this.labelNewLineRows.Location = new System.Drawing.Point(13, 80); + this.labelNewLineRows.Name = "labelNewLineRows"; + this.labelNewLineRows.Size = new System.Drawing.Size(179, 13); + this.labelNewLineRows.TabIndex = 53; + this.labelNewLineRows.Text = "Number of rows added by a new line"; + // + // labelMarginTop + // + this.labelMarginTop.AutoSize = true; + this.labelMarginTop.Location = new System.Drawing.Point(13, 28); + this.labelMarginTop.Name = "labelMarginTop"; + this.labelMarginTop.Size = new System.Drawing.Size(174, 13); + this.labelMarginTop.TabIndex = 49; + this.labelMarginTop.Text = "Margin top (for top aligned subtitles)"; + // + // numericUpDownMarginBottom + // + this.numericUpDownMarginBottom.Location = new System.Drawing.Point(256, 52); + this.numericUpDownMarginBottom.Maximum = new decimal(new int[] { + 50, + 0, + 0, + 0}); + this.numericUpDownMarginBottom.Name = "numericUpDownMarginBottom"; + this.numericUpDownMarginBottom.Size = new System.Drawing.Size(56, 20); + this.numericUpDownMarginBottom.TabIndex = 52; + // + // numericUpDownMarginTop + // + this.numericUpDownMarginTop.Location = new System.Drawing.Point(256, 26); + this.numericUpDownMarginTop.Maximum = new decimal(new int[] { + 50, + 0, + 0, + 0}); + this.numericUpDownMarginTop.Name = "numericUpDownMarginTop"; + this.numericUpDownMarginTop.Size = new System.Drawing.Size(56, 20); + this.numericUpDownMarginTop.TabIndex = 48; + // + // labelMarginBottom + // + this.labelMarginBottom.AutoSize = true; + this.labelMarginBottom.Location = new System.Drawing.Point(13, 54); + this.labelMarginBottom.Name = "labelMarginBottom"; + this.labelMarginBottom.Size = new System.Drawing.Size(208, 13); + this.labelMarginBottom.TabIndex = 51; + this.labelMarginBottom.Text = "Margin bottom (for bottom aligned subtitles)"; + // + // groupBoxTeletext + // + this.groupBoxTeletext.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxTeletext.Controls.Add(this.checkBoxTeletextDoubleHeight); + this.groupBoxTeletext.Controls.Add(this.checkBoxTeletextBox); + this.groupBoxTeletext.Location = new System.Drawing.Point(9, 256); + this.groupBoxTeletext.Name = "groupBoxTeletext"; + this.groupBoxTeletext.Size = new System.Drawing.Size(727, 190); + this.groupBoxTeletext.TabIndex = 45; + this.groupBoxTeletext.TabStop = false; + this.groupBoxTeletext.Text = "Teletext"; + // + // checkBoxTeletextDoubleHeight + // + this.checkBoxTeletextDoubleHeight.AutoSize = true; + this.checkBoxTeletextDoubleHeight.Location = new System.Drawing.Point(16, 57); + this.checkBoxTeletextDoubleHeight.Name = "checkBoxTeletextDoubleHeight"; + this.checkBoxTeletextDoubleHeight.Size = new System.Drawing.Size(124, 17); + this.checkBoxTeletextDoubleHeight.TabIndex = 1; + this.checkBoxTeletextDoubleHeight.Text = "Text is double height"; + this.checkBoxTeletextDoubleHeight.UseVisualStyleBackColor = true; + // + // checkBoxTeletextBox + // + this.checkBoxTeletextBox.AutoSize = true; + this.checkBoxTeletextBox.Location = new System.Drawing.Point(16, 34); + this.checkBoxTeletextBox.Name = "checkBoxTeletextBox"; + this.checkBoxTeletextBox.Size = new System.Drawing.Size(121, 17); + this.checkBoxTeletextBox.TabIndex = 0; + this.checkBoxTeletextBox.Text = "Use box around text"; + this.checkBoxTeletextBox.UseVisualStyleBackColor = true; + this.checkBoxTeletextBox.CheckedChanged += new System.EventHandler(this.checkBoxTeletextBox_CheckedChanged); + // + // comboBoxJustificationCode + // + this.comboBoxJustificationCode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxJustificationCode.FormattingEnabled = true; + this.comboBoxJustificationCode.Items.AddRange(new object[] { + "unchanged presentation", + "left-justified text", + "centred text", + "right-justified text"}); + this.comboBoxJustificationCode.Location = new System.Drawing.Point(145, 11); + this.comboBoxJustificationCode.Name = "comboBoxJustificationCode"; + this.comboBoxJustificationCode.Size = new System.Drawing.Size(219, 21); + this.comboBoxJustificationCode.TabIndex = 43; + // + // labelJustificationCode + // + this.labelJustificationCode.AutoSize = true; + this.labelJustificationCode.Location = new System.Drawing.Point(6, 14); + this.labelJustificationCode.Name = "labelJustificationCode"; + this.labelJustificationCode.Size = new System.Drawing.Size(89, 13); + this.labelJustificationCode.TabIndex = 44; + this.labelJustificationCode.Text = "Justification code"; + // + // tabPageErrors + // + this.tabPageErrors.Controls.Add(this.textBoxErrors); + this.tabPageErrors.Controls.Add(this.labelErrors); + this.tabPageErrors.Location = new System.Drawing.Point(4, 22); + this.tabPageErrors.Name = "tabPageErrors"; + this.tabPageErrors.Padding = new System.Windows.Forms.Padding(3); + this.tabPageErrors.Size = new System.Drawing.Size(750, 461); + this.tabPageErrors.TabIndex = 1; + this.tabPageErrors.Text = "Errors"; + this.tabPageErrors.UseVisualStyleBackColor = true; + // + // textBoxErrors + // + this.textBoxErrors.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxErrors.Location = new System.Drawing.Point(6, 26); + this.textBoxErrors.Multiline = true; + this.textBoxErrors.Name = "textBoxErrors"; + this.textBoxErrors.ReadOnly = true; + this.textBoxErrors.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxErrors.Size = new System.Drawing.Size(729, 386); + this.textBoxErrors.TabIndex = 13; + // + // labelErrors + // + this.labelErrors.AutoSize = true; + this.labelErrors.Location = new System.Drawing.Point(3, 10); + this.labelErrors.Name = "labelErrors"; + this.labelErrors.Size = new System.Drawing.Size(34, 13); + this.labelErrors.TabIndex = 12; + this.labelErrors.Text = "Errors"; + // + // EbuSaveOptions + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(775, 542); + this.Controls.Add(this.tabControl1); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.MinimumSize = new System.Drawing.Size(785, 570); + this.Name = "EbuSaveOptions"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "EbuSaveOptions"; + this.tabControl1.ResumeLayout(false); + this.tabPageHeader.ResumeLayout(false); + this.tabPageHeader.PerformLayout(); + this.contextMenuStripCodeTable.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxRows)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDiskSequenceNumber)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownTotalNumberOfDiscs)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRevisionNumber)).EndInit(); + this.tabPageTextAndTiming.ResumeLayout(false); + this.tabPageTextAndTiming.PerformLayout(); + this.groupBoxVerticalPosition.ResumeLayout(false); + this.groupBoxVerticalPosition.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNewLineRows)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginBottom)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginTop)).EndInit(); + this.groupBoxTeletext.ResumeLayout(false); + this.groupBoxTeletext.PerformLayout(); + this.tabPageErrors.ResumeLayout(false); + this.tabPageErrors.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPageHeader; + private System.Windows.Forms.NumericUpDown numericUpDownDiskSequenceNumber; + private System.Windows.Forms.NumericUpDown numericUpDownTotalNumberOfDiscs; + private System.Windows.Forms.NumericUpDown numericUpDownRevisionNumber; + private System.Windows.Forms.Label labelDiskSequenceNumber; + private System.Windows.Forms.Label labelTotalNumberOfDisks; + private System.Windows.Forms.Label labelRevisionNumber; + private System.Windows.Forms.TextBox textBoxTranslatorsName; + private System.Windows.Forms.Label labelTranslatorsName; + private System.Windows.Forms.TextBox textBoxSubtitleListReferenceCode; + private System.Windows.Forms.Label labelSubtitleListReferenceCode; + private System.Windows.Forms.ComboBox comboBoxCharacterCodeTable; + private System.Windows.Forms.Button buttonImport; + private System.Windows.Forms.Label labelCharacterCodeTable; + private System.Windows.Forms.TextBox textBoxTranslatedProgramTitle; + private System.Windows.Forms.TextBox textBoxTranslatedEpisodeTitle; + private System.Windows.Forms.TextBox textBoxOriginalEpisodeTitle; + private System.Windows.Forms.Label labelTranslatedEpisodeTitle; + private System.Windows.Forms.Label labelTranslatedProgramTitle; + private System.Windows.Forms.Label labelOriginalEpisodeTitle; + private System.Windows.Forms.TextBox textBoxOriginalProgramTitle; + private System.Windows.Forms.Label labelOriginalProgramTitle; + private System.Windows.Forms.TabPage tabPageTextAndTiming; + private System.Windows.Forms.TabPage tabPageErrors; + private System.Windows.Forms.TextBox textBoxErrors; + private System.Windows.Forms.Label labelErrors; + private System.Windows.Forms.ComboBox comboBoxJustificationCode; + private System.Windows.Forms.Label labelJustificationCode; + private System.Windows.Forms.NumericUpDown numericUpDownMaxCharacters; + private System.Windows.Forms.Label labelMaxNoOfDisplayableChars; + private System.Windows.Forms.TextBox textBoxLanguageCode; + private System.Windows.Forms.Label labelLanguageCode; + private System.Windows.Forms.Label labelCodePageNumber; + private System.Windows.Forms.ComboBox comboBoxDiscFormatCode; + private System.Windows.Forms.Label labelDiskFormatCode; + private System.Windows.Forms.NumericUpDown numericUpDownMaxRows; + private System.Windows.Forms.Label labelMaxNumberOfDisplayableRows; + private System.Windows.Forms.TextBox textBoxCodePageNumber; + private System.Windows.Forms.ContextMenuStrip contextMenuStripCodeTable; + private System.Windows.Forms.ToolStripMenuItem unitedStatesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem multilingualToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem portugalToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem canadaFrenchToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem nordicToolStripMenuItem; + private System.Windows.Forms.TextBox textBoxCountryOfOrigin; + private System.Windows.Forms.Label labelCountryOfOrigin; + private System.Windows.Forms.ComboBox comboBoxDisplayStandardCode; + private System.Windows.Forms.Label labelDisplayStandardCode; + private System.Windows.Forms.Label labelTimeCodeStartOfProgramme; + private System.Windows.Forms.Label labelTimeCodeStatus; + private System.Windows.Forms.ComboBox comboBoxTimeCodeStatus; + private Controls.TimeUpDown timeUpDownStartTime; + private System.Windows.Forms.Label labelFrameRate; + private System.Windows.Forms.ComboBox comboBoxFrameRate; + private System.Windows.Forms.GroupBox groupBoxTeletext; + private System.Windows.Forms.CheckBox checkBoxTeletextDoubleHeight; + private System.Windows.Forms.CheckBox checkBoxTeletextBox; + private System.Windows.Forms.GroupBox groupBoxVerticalPosition; + private System.Windows.Forms.Label labelMarginBottom; + private System.Windows.Forms.NumericUpDown numericUpDownMarginTop; + private System.Windows.Forms.Label labelMarginTop; + private System.Windows.Forms.NumericUpDown numericUpDownNewLineRows; + private System.Windows.Forms.Label labelNewLineRows; + private System.Windows.Forms.NumericUpDown numericUpDownMarginBottom; + private System.Windows.Forms.Label labelDisplayStandardCodeWarning; + private System.Windows.Forms.Button buttonChooseLanguageCode; + private System.Windows.Forms.Label labelLanguageCodeFriendlyName; + private System.Windows.Forms.Label labelUseBox; + private System.Windows.Forms.Label labelMaxCharsPerRow38ForTeletext; + } } \ No newline at end of file diff --git a/src/Forms/EbuSaveOptions.cs b/src/ui/Forms/EbuSaveOptions.cs similarity index 97% rename from src/Forms/EbuSaveOptions.cs rename to src/ui/Forms/EbuSaveOptions.cs index a425c3830..838e00582 100644 --- a/src/Forms/EbuSaveOptions.cs +++ b/src/ui/Forms/EbuSaveOptions.cs @@ -1,547 +1,547 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Globalization; -using System.IO; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class EbuSaveOptions : PositionAndSizeForm - { - private Ebu.EbuGeneralSubtitleInformation _header; - private Subtitle _subtitle; - - public byte JustificationCode { get; private set; } - - public EbuSaveOptions() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - var language = Configuration.Settings.Language.EbuSaveOptions; - Text = language.Title; - tabPageHeader.Text = language.GeneralSubtitleInformation; - tabPageTextAndTiming.Text = language.TextAndTimingInformation; - tabPageErrors.Text = language.Errors; - - labelCodePageNumber.Text = language.CodePageNumber; - labelDiskFormatCode.Text = language.DiskFormatCode; - labelDisplayStandardCode.Text = language.DisplayStandardCode; - labelDisplayStandardCodeWarning.Text = string.Empty; - labelMaxCharsPerRow38ForTeletext.Text = string.Empty; - labelCharacterCodeTable.Text = language.CharacterCodeTable; - labelLanguageCode.Text = language.LanguageCode; - labelOriginalProgramTitle.Text = language.OriginalProgramTitle; - labelOriginalEpisodeTitle.Text = language.OriginalEpisodeTitle; - labelTranslatedProgramTitle.Text = language.TranslatedProgramTitle; - labelTranslatedEpisodeTitle.Text = language.TranslatedEpisodeTitle; - labelTranslatorsName.Text = language.TranslatorsName; - labelSubtitleListReferenceCode.Text = language.SubtitleListReferenceCode; - labelCountryOfOrigin.Text = language.CountryOfOrigin; - labelTimeCodeStatus.Text = language.TimeCodeStatus; - labelTimeCodeStartOfProgramme.Text = language.TimeCodeStartOfProgramme; - labelFrameRate.Text = Configuration.Settings.Language.General.FrameRate; - - labelRevisionNumber.Text = language.RevisionNumber; - labelMaxNoOfDisplayableChars.Text = language.MaxNoOfDisplayableChars; - labelMaxNumberOfDisplayableRows.Text = language.MaxNumberOfDisplayableRows; - labelDiskSequenceNumber.Text = language.DiskSequenceNumber; - labelTotalNumberOfDisks.Text = language.TotalNumberOfDisks; - - buttonImport.Text = language.Import; - - labelJustificationCode.Text = language.JustificationCode; - comboBoxJustificationCode.Items.Clear(); - comboBoxJustificationCode.Items.Add(language.TextUnchangedPresentation); - comboBoxJustificationCode.Items.Add(language.TextLeftJustifiedText); - comboBoxJustificationCode.Items.Add(language.TextCenteredText); - comboBoxJustificationCode.Items.Add(language.TextRightJustifiedText); - groupBoxTeletext.Text = language.Teletext; - groupBoxVerticalPosition.Text = language.VerticalPosition; - labelMarginTop.Text = language.MarginTop; - labelMarginBottom.Text = language.MarginBottom; - labelNewLineRows.Text = language.NewLineRows; - int tempW = labelMarginTop.Left + 9 + Math.Max(Math.Max(labelMarginTop.Width, labelMarginBottom.Width), labelNewLineRows.Width); - numericUpDownMarginTop.Left = tempW; - numericUpDownMarginBottom.Left = tempW; - numericUpDownNewLineRows.Left = tempW; - labelUseBox.Left = numericUpDownNewLineRows.Left + numericUpDownNewLineRows.Width + 9; - checkBoxTeletextBox.Text = language.UseBox; - checkBoxTeletextDoubleHeight.Text = language.DoubleHeight; - - labelErrors.Text = language.Errors; - labelUseBox.Text = language.UseBoxForOneNewLine; - - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - - labelLanguageCodeFriendlyName.Text = string.Empty; - timeUpDownStartTime.ForceHHMMSSFF(); - - UiUtil.FixLargeFonts(this, buttonOK); - } - - internal void Initialize(Ebu.EbuGeneralSubtitleInformation header, byte justificationCode, string fileName, Subtitle subtitle) - { - _header = header; - _subtitle = subtitle; - - if (_subtitle == null) - { - tabControl1.TabPages.Remove(tabPageErrors); - } - - FillFromHeader(header); - if (!string.IsNullOrEmpty(fileName)) - { - try - { - FillHeaderFromFile(fileName); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine("EbuOptions unable to read existing file: " + fileName + " - " + ex.Message); - } - string title = Path.GetFileNameWithoutExtension(fileName); - if (title.Length > 32) - { - title = title.Substring(0, 32).Trim(); - } - - textBoxOriginalProgramTitle.Text = title; - } - - comboBoxJustificationCode.SelectedIndex = justificationCode; - numericUpDownMarginTop.Value = Configuration.Settings.SubtitleSettings.EbuStlMarginTop; - numericUpDownMarginBottom.Value = Configuration.Settings.SubtitleSettings.EbuStlMarginBottom; - numericUpDownNewLineRows.Value = Configuration.Settings.SubtitleSettings.EbuStlNewLineRows; - checkBoxTeletextBox.Checked = Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox; - checkBoxTeletextDoubleHeight.Checked = Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight; - - Text = Configuration.Settings.Language.EbuSaveOptions.Title; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - } - - private void CheckErrors(Subtitle subtitle) - { - if (subtitle == null) - { - return; - } - - textBoxErrors.Text = string.Empty; - var sb = new StringBuilder(); - int errorCount = 0; - int i = 1; - foreach (Paragraph p in subtitle.Paragraphs) - { - var arr = p.Text.SplitToLines(); - foreach (string line in arr) - { - string s = HtmlUtil.RemoveHtmlTags(line, true); - if (s.Length > numericUpDownMaxCharacters.Value) - { - sb.AppendLine(string.Format(Configuration.Settings.Language.EbuSaveOptions.MaxLengthError, i, numericUpDownMaxCharacters.Value, s.Length - numericUpDownMaxCharacters.Value, s)); - errorCount++; - } - } - i++; - } - textBoxErrors.Text = sb.ToString(); - tabPageErrors.Text = string.Format(Configuration.Settings.Language.EbuSaveOptions.ErrorsX, errorCount); - } - - private void FillFromHeader(Ebu.EbuGeneralSubtitleInformation header) - { - textBoxCodePageNumber.Text = header.CodePageNumber; - - comboBoxFrameRate.Items.Clear(); - comboBoxFrameRate.Items.Add(23.976); - comboBoxFrameRate.Items.Add(24.0); - comboBoxFrameRate.Items.Add(25.0); - comboBoxFrameRate.Items.Add(29.97); - comboBoxFrameRate.Items.Add(30.0); - - if (header.DiskFormatCode == "STL30.01") - { - comboBoxDiscFormatCode.SelectedIndex = 4; - comboBoxFrameRate.Text = (30).ToString(CultureInfo.CurrentCulture); - } - else if (header.DiskFormatCode == "STL23.01") - { - comboBoxDiscFormatCode.SelectedIndex = 0; - comboBoxFrameRate.Text = (23.976).ToString(CultureInfo.CurrentCulture); - } - else if (header.DiskFormatCode == "STL24.01") - { - comboBoxDiscFormatCode.SelectedIndex = 1; - comboBoxFrameRate.Text = (24).ToString(CultureInfo.CurrentCulture); - } - else if (header.DiskFormatCode == "STL29.01") - { - comboBoxDiscFormatCode.SelectedIndex = 3; - comboBoxFrameRate.Text = (25).ToString(CultureInfo.CurrentCulture); - } - else - { - comboBoxDiscFormatCode.SelectedIndex = 2; - comboBoxFrameRate.Text = (25).ToString(CultureInfo.CurrentCulture); - } - - if (header.FrameRateFromSaveDialog > 20 && header.FrameRateFromSaveDialog < 200) - { - comboBoxFrameRate.Text = header.FrameRateFromSaveDialog.ToString(CultureInfo.CurrentCulture); - } - - if (header.DisplayStandardCode == "0") - { - comboBoxDisplayStandardCode.SelectedIndex = 0; - } - else if (header.DisplayStandardCode == "1") - { - comboBoxDisplayStandardCode.SelectedIndex = 1; - } - else if (header.DisplayStandardCode == "2") - { - comboBoxDisplayStandardCode.SelectedIndex = 2; - } - else - { - comboBoxDisplayStandardCode.SelectedIndex = 3; - } - - comboBoxCharacterCodeTable.SelectedIndex = int.Parse(header.CharacterCodeTableNumber); - textBoxLanguageCode.Text = header.LanguageCode; - textBoxOriginalProgramTitle.Text = header.OriginalProgrammeTitle.TrimEnd(); - textBoxOriginalEpisodeTitle.Text = header.OriginalEpisodeTitle.TrimEnd(); - textBoxTranslatedProgramTitle.Text = header.TranslatedProgrammeTitle.TrimEnd(); - textBoxTranslatedEpisodeTitle.Text = header.TranslatedEpisodeTitle.TrimEnd(); - textBoxTranslatorsName.Text = header.TranslatorsName.TrimEnd(); - textBoxSubtitleListReferenceCode.Text = header.SubtitleListReferenceCode.TrimEnd(); - textBoxCountryOfOrigin.Text = header.CountryOfOrigin; - - comboBoxTimeCodeStatus.SelectedIndex = 1; - if (header.TimeCodeStatus == "0") - { - comboBoxTimeCodeStatus.SelectedIndex = 0; // 1 == intended for use, 0 == not intended for use - } - - try - { - // HHMMSSFF - int hh = int.Parse(header.TimeCodeStartOfProgramme.Substring(0, 2)); - int mm = int.Parse(header.TimeCodeStartOfProgramme.Substring(2, 2)); - int ss = int.Parse(header.TimeCodeStartOfProgramme.Substring(4, 2)); - int ff = int.Parse(header.TimeCodeStartOfProgramme.Substring(6, 2)); - timeUpDownStartTime.TimeCode = new TimeCode(hh, mm, ss, SubtitleFormat.FramesToMillisecondsMax999(ff)); - } - catch (Exception) - { - timeUpDownStartTime.TimeCode = new TimeCode(); - } - - int number; - if (int.TryParse(header.RevisionNumber, out number)) - { - numericUpDownRevisionNumber.Value = number; - } - else - { - numericUpDownRevisionNumber.Value = 1; - } - - if (int.TryParse(header.MaximumNumberOfDisplayableCharactersInAnyTextRow, out number)) - { - numericUpDownMaxCharacters.Value = number; - } - - numericUpDownMaxRows.Value = 23; - if (int.TryParse(header.MaximumNumberOfDisplayableRows, out number)) - { - numericUpDownMaxRows.Value = number; - } - - if (int.TryParse(header.DiskSequenceNumber, out number)) - { - numericUpDownDiskSequenceNumber.Value = number; - } - else - { - numericUpDownDiskSequenceNumber.Value = 1; - } - - if (int.TryParse(header.TotalNumberOfDisks, out number)) - { - numericUpDownTotalNumberOfDiscs.Value = number; - } - else - { - numericUpDownTotalNumberOfDiscs.Value = 1; - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - _header.CodePageNumber = textBoxCodePageNumber.Text; - if (_header.CodePageNumber.Length < 3) - { - _header.CodePageNumber = "865"; - } - - if (comboBoxDiscFormatCode.SelectedIndex == 0) - { - _header.DiskFormatCode = "STL23.01"; - } - else if (comboBoxDiscFormatCode.SelectedIndex == 1) - { - _header.DiskFormatCode = "STL24.01"; - } - else if (comboBoxDiscFormatCode.SelectedIndex == 2) - { - _header.DiskFormatCode = "STL25.01"; - } - else if (comboBoxDiscFormatCode.SelectedIndex == 3) - { - _header.DiskFormatCode = "STL29.01"; - } - else - { - _header.DiskFormatCode = "STL30.01"; - } - - double d; - if (double.TryParse(comboBoxFrameRate.Text.Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), out d) && d > 20 && d < 200) - { - _header.FrameRateFromSaveDialog = d; - } - - if (comboBoxDisplayStandardCode.SelectedIndex == 0) - { - _header.DisplayStandardCode = "0"; - } - else if (comboBoxDisplayStandardCode.SelectedIndex == 1) - { - _header.DisplayStandardCode = "1"; - } - else if (comboBoxDisplayStandardCode.SelectedIndex == 2) - { - _header.DisplayStandardCode = "2"; - } - else - { - _header.DisplayStandardCode = " "; - } - - _header.CharacterCodeTableNumber = "0" + comboBoxCharacterCodeTable.SelectedIndex; - _header.LanguageCode = textBoxLanguageCode.Text; - if (_header.LanguageCode.Length != 2) - { - _header.LanguageCode = "0A"; - } - - _header.OriginalProgrammeTitle = textBoxOriginalProgramTitle.Text.PadRight(32, ' '); - _header.OriginalEpisodeTitle = textBoxOriginalEpisodeTitle.Text.PadRight(32, ' '); - _header.TranslatedProgrammeTitle = textBoxTranslatedProgramTitle.Text.PadRight(32, ' '); - _header.TranslatedEpisodeTitle = textBoxTranslatedEpisodeTitle.Text.PadRight(32, ' '); - _header.TranslatorsName = textBoxTranslatorsName.Text.PadRight(32, ' '); - _header.SubtitleListReferenceCode = textBoxSubtitleListReferenceCode.Text.PadRight(16, ' '); - _header.CountryOfOrigin = textBoxCountryOfOrigin.Text; - if (_header.CountryOfOrigin.Length != 3) - { - _header.CountryOfOrigin = "USA"; - } - - _header.TimeCodeStatus = comboBoxTimeCodeStatus.SelectedIndex.ToString(CultureInfo.InvariantCulture); - _header.TimeCodeStartOfProgramme = timeUpDownStartTime.TimeCode.ToHHMMSSFF().RemoveChar(':'); - - _header.RevisionNumber = numericUpDownRevisionNumber.Value.ToString("00"); - _header.MaximumNumberOfDisplayableCharactersInAnyTextRow = numericUpDownMaxCharacters.Value.ToString("00"); - _header.MaximumNumberOfDisplayableRows = numericUpDownMaxRows.Value.ToString("00"); - _header.DiskSequenceNumber = numericUpDownDiskSequenceNumber.Value.ToString(CultureInfo.InvariantCulture); - _header.TotalNumberOfDisks = numericUpDownTotalNumberOfDiscs.Value.ToString(CultureInfo.InvariantCulture); - - JustificationCode = (byte)comboBoxJustificationCode.SelectedIndex; - Configuration.Settings.SubtitleSettings.EbuStlMarginTop = (int)Math.Round(numericUpDownMarginTop.Value); - Configuration.Settings.SubtitleSettings.EbuStlMarginBottom = (int)Math.Round(numericUpDownMarginBottom.Value); - Configuration.Settings.SubtitleSettings.EbuStlNewLineRows = (int)Math.Round(numericUpDownNewLineRows.Value); - Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox = checkBoxTeletextBox.Checked; - Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight = checkBoxTeletextDoubleHeight.Checked; - - if (_subtitle != null) - { - _subtitle.Header = _header.ToString(); - } - - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void buttonImport_Click(object sender, EventArgs e) - { - openFileDialog1.Filter = "EBU STL files (*.stl)|*.stl"; - openFileDialog1.FileName = string.Empty; - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - FillHeaderFromFile(openFileDialog1.FileName); - } - } - - private void FillHeaderFromFile(string fileName) - { - if (File.Exists(fileName)) - { - var ebu = new Ebu(); - var temp = new Subtitle(); - ebu.LoadSubtitle(temp, null, fileName); - FillFromHeader(ebu.Header); - if (ebu.JustificationCodes.Count > 2 && ebu.JustificationCodes[1] == ebu.JustificationCodes[2]) - { - if (ebu.JustificationCodes[1] >= 0 && ebu.JustificationCodes[1] < 4) - { - comboBoxJustificationCode.SelectedIndex = ebu.JustificationCodes[1]; - } - } - } - } - - private void numericUpDownMaxCharacters_ValueChanged(object sender, EventArgs e) - { - CheckMaxCharsPerRow(); - CheckErrors(_subtitle); - } - - private void unitedStatesToolStripMenuItem_Click(object sender, EventArgs e) - { - textBoxCodePageNumber.Text = "437"; - } - - private void multilingualToolStripMenuItem_Click(object sender, EventArgs e) - { - textBoxCodePageNumber.Text = "850"; - } - - private void portugalToolStripMenuItem_Click(object sender, EventArgs e) - { - textBoxCodePageNumber.Text = "860"; - } - - private void canadaFrenchToolStripMenuItem_Click(object sender, EventArgs e) - { - textBoxCodePageNumber.Text = "863"; - } - - private void nordicToolStripMenuItem_Click(object sender, EventArgs e) - { - textBoxCodePageNumber.Text = "865"; - } - - private void comboBoxDiscFormatCode_SelectedIndexChanged(object sender, EventArgs e) - { - if (comboBoxDiscFormatCode.SelectedIndex == 2) - { - comboBoxFrameRate.Text = (25).ToString(CultureInfo.CurrentCulture); - } - else if (comboBoxDiscFormatCode.SelectedIndex == 4) - { - comboBoxFrameRate.Text = (30).ToString(CultureInfo.CurrentCulture); - } - } - - private void comboBoxDisplayStandardCode_SelectedIndexChanged(object sender, EventArgs e) - { - labelDisplayStandardCodeWarning.Text = string.Empty; - CheckMaxCharsPerRow(); - if (_subtitle == null) - { - return; - } - - var fontColorFound = false; - var alignmentFound = false; - if (comboBoxDisplayStandardCode.SelectedIndex == 0) // open subtitling - { - foreach (var paragraph in _subtitle.Paragraphs) - { - if (!fontColorFound && - paragraph.Text.Contains(" 32) + { + title = title.Substring(0, 32).Trim(); + } + + textBoxOriginalProgramTitle.Text = title; + } + + comboBoxJustificationCode.SelectedIndex = justificationCode; + numericUpDownMarginTop.Value = Configuration.Settings.SubtitleSettings.EbuStlMarginTop; + numericUpDownMarginBottom.Value = Configuration.Settings.SubtitleSettings.EbuStlMarginBottom; + numericUpDownNewLineRows.Value = Configuration.Settings.SubtitleSettings.EbuStlNewLineRows; + checkBoxTeletextBox.Checked = Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox; + checkBoxTeletextDoubleHeight.Checked = Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight; + + Text = Configuration.Settings.Language.EbuSaveOptions.Title; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + } + + private void CheckErrors(Subtitle subtitle) + { + if (subtitle == null) + { + return; + } + + textBoxErrors.Text = string.Empty; + var sb = new StringBuilder(); + int errorCount = 0; + int i = 1; + foreach (Paragraph p in subtitle.Paragraphs) + { + var arr = p.Text.SplitToLines(); + foreach (string line in arr) + { + string s = HtmlUtil.RemoveHtmlTags(line, true); + if (s.Length > numericUpDownMaxCharacters.Value) + { + sb.AppendLine(string.Format(Configuration.Settings.Language.EbuSaveOptions.MaxLengthError, i, numericUpDownMaxCharacters.Value, s.Length - numericUpDownMaxCharacters.Value, s)); + errorCount++; + } + } + i++; + } + textBoxErrors.Text = sb.ToString(); + tabPageErrors.Text = string.Format(Configuration.Settings.Language.EbuSaveOptions.ErrorsX, errorCount); + } + + private void FillFromHeader(Ebu.EbuGeneralSubtitleInformation header) + { + textBoxCodePageNumber.Text = header.CodePageNumber; + + comboBoxFrameRate.Items.Clear(); + comboBoxFrameRate.Items.Add(23.976); + comboBoxFrameRate.Items.Add(24.0); + comboBoxFrameRate.Items.Add(25.0); + comboBoxFrameRate.Items.Add(29.97); + comboBoxFrameRate.Items.Add(30.0); + + if (header.DiskFormatCode == "STL30.01") + { + comboBoxDiscFormatCode.SelectedIndex = 4; + comboBoxFrameRate.Text = (30).ToString(CultureInfo.CurrentCulture); + } + else if (header.DiskFormatCode == "STL23.01") + { + comboBoxDiscFormatCode.SelectedIndex = 0; + comboBoxFrameRate.Text = (23.976).ToString(CultureInfo.CurrentCulture); + } + else if (header.DiskFormatCode == "STL24.01") + { + comboBoxDiscFormatCode.SelectedIndex = 1; + comboBoxFrameRate.Text = (24).ToString(CultureInfo.CurrentCulture); + } + else if (header.DiskFormatCode == "STL29.01") + { + comboBoxDiscFormatCode.SelectedIndex = 3; + comboBoxFrameRate.Text = (25).ToString(CultureInfo.CurrentCulture); + } + else + { + comboBoxDiscFormatCode.SelectedIndex = 2; + comboBoxFrameRate.Text = (25).ToString(CultureInfo.CurrentCulture); + } + + if (header.FrameRateFromSaveDialog > 20 && header.FrameRateFromSaveDialog < 200) + { + comboBoxFrameRate.Text = header.FrameRateFromSaveDialog.ToString(CultureInfo.CurrentCulture); + } + + if (header.DisplayStandardCode == "0") + { + comboBoxDisplayStandardCode.SelectedIndex = 0; + } + else if (header.DisplayStandardCode == "1") + { + comboBoxDisplayStandardCode.SelectedIndex = 1; + } + else if (header.DisplayStandardCode == "2") + { + comboBoxDisplayStandardCode.SelectedIndex = 2; + } + else + { + comboBoxDisplayStandardCode.SelectedIndex = 3; + } + + comboBoxCharacterCodeTable.SelectedIndex = int.Parse(header.CharacterCodeTableNumber); + textBoxLanguageCode.Text = header.LanguageCode; + textBoxOriginalProgramTitle.Text = header.OriginalProgrammeTitle.TrimEnd(); + textBoxOriginalEpisodeTitle.Text = header.OriginalEpisodeTitle.TrimEnd(); + textBoxTranslatedProgramTitle.Text = header.TranslatedProgrammeTitle.TrimEnd(); + textBoxTranslatedEpisodeTitle.Text = header.TranslatedEpisodeTitle.TrimEnd(); + textBoxTranslatorsName.Text = header.TranslatorsName.TrimEnd(); + textBoxSubtitleListReferenceCode.Text = header.SubtitleListReferenceCode.TrimEnd(); + textBoxCountryOfOrigin.Text = header.CountryOfOrigin; + + comboBoxTimeCodeStatus.SelectedIndex = 1; + if (header.TimeCodeStatus == "0") + { + comboBoxTimeCodeStatus.SelectedIndex = 0; // 1 == intended for use, 0 == not intended for use + } + + try + { + // HHMMSSFF + int hh = int.Parse(header.TimeCodeStartOfProgramme.Substring(0, 2)); + int mm = int.Parse(header.TimeCodeStartOfProgramme.Substring(2, 2)); + int ss = int.Parse(header.TimeCodeStartOfProgramme.Substring(4, 2)); + int ff = int.Parse(header.TimeCodeStartOfProgramme.Substring(6, 2)); + timeUpDownStartTime.TimeCode = new TimeCode(hh, mm, ss, SubtitleFormat.FramesToMillisecondsMax999(ff)); + } + catch (Exception) + { + timeUpDownStartTime.TimeCode = new TimeCode(); + } + + int number; + if (int.TryParse(header.RevisionNumber, out number)) + { + numericUpDownRevisionNumber.Value = number; + } + else + { + numericUpDownRevisionNumber.Value = 1; + } + + if (int.TryParse(header.MaximumNumberOfDisplayableCharactersInAnyTextRow, out number)) + { + numericUpDownMaxCharacters.Value = number; + } + + numericUpDownMaxRows.Value = 23; + if (int.TryParse(header.MaximumNumberOfDisplayableRows, out number)) + { + numericUpDownMaxRows.Value = number; + } + + if (int.TryParse(header.DiskSequenceNumber, out number)) + { + numericUpDownDiskSequenceNumber.Value = number; + } + else + { + numericUpDownDiskSequenceNumber.Value = 1; + } + + if (int.TryParse(header.TotalNumberOfDisks, out number)) + { + numericUpDownTotalNumberOfDiscs.Value = number; + } + else + { + numericUpDownTotalNumberOfDiscs.Value = 1; + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + _header.CodePageNumber = textBoxCodePageNumber.Text; + if (_header.CodePageNumber.Length < 3) + { + _header.CodePageNumber = "865"; + } + + if (comboBoxDiscFormatCode.SelectedIndex == 0) + { + _header.DiskFormatCode = "STL23.01"; + } + else if (comboBoxDiscFormatCode.SelectedIndex == 1) + { + _header.DiskFormatCode = "STL24.01"; + } + else if (comboBoxDiscFormatCode.SelectedIndex == 2) + { + _header.DiskFormatCode = "STL25.01"; + } + else if (comboBoxDiscFormatCode.SelectedIndex == 3) + { + _header.DiskFormatCode = "STL29.01"; + } + else + { + _header.DiskFormatCode = "STL30.01"; + } + + double d; + if (double.TryParse(comboBoxFrameRate.Text.Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), out d) && d > 20 && d < 200) + { + _header.FrameRateFromSaveDialog = d; + } + + if (comboBoxDisplayStandardCode.SelectedIndex == 0) + { + _header.DisplayStandardCode = "0"; + } + else if (comboBoxDisplayStandardCode.SelectedIndex == 1) + { + _header.DisplayStandardCode = "1"; + } + else if (comboBoxDisplayStandardCode.SelectedIndex == 2) + { + _header.DisplayStandardCode = "2"; + } + else + { + _header.DisplayStandardCode = " "; + } + + _header.CharacterCodeTableNumber = "0" + comboBoxCharacterCodeTable.SelectedIndex; + _header.LanguageCode = textBoxLanguageCode.Text; + if (_header.LanguageCode.Length != 2) + { + _header.LanguageCode = "0A"; + } + + _header.OriginalProgrammeTitle = textBoxOriginalProgramTitle.Text.PadRight(32, ' '); + _header.OriginalEpisodeTitle = textBoxOriginalEpisodeTitle.Text.PadRight(32, ' '); + _header.TranslatedProgrammeTitle = textBoxTranslatedProgramTitle.Text.PadRight(32, ' '); + _header.TranslatedEpisodeTitle = textBoxTranslatedEpisodeTitle.Text.PadRight(32, ' '); + _header.TranslatorsName = textBoxTranslatorsName.Text.PadRight(32, ' '); + _header.SubtitleListReferenceCode = textBoxSubtitleListReferenceCode.Text.PadRight(16, ' '); + _header.CountryOfOrigin = textBoxCountryOfOrigin.Text; + if (_header.CountryOfOrigin.Length != 3) + { + _header.CountryOfOrigin = "USA"; + } + + _header.TimeCodeStatus = comboBoxTimeCodeStatus.SelectedIndex.ToString(CultureInfo.InvariantCulture); + _header.TimeCodeStartOfProgramme = timeUpDownStartTime.TimeCode.ToHHMMSSFF().RemoveChar(':'); + + _header.RevisionNumber = numericUpDownRevisionNumber.Value.ToString("00"); + _header.MaximumNumberOfDisplayableCharactersInAnyTextRow = numericUpDownMaxCharacters.Value.ToString("00"); + _header.MaximumNumberOfDisplayableRows = numericUpDownMaxRows.Value.ToString("00"); + _header.DiskSequenceNumber = numericUpDownDiskSequenceNumber.Value.ToString(CultureInfo.InvariantCulture); + _header.TotalNumberOfDisks = numericUpDownTotalNumberOfDiscs.Value.ToString(CultureInfo.InvariantCulture); + + JustificationCode = (byte)comboBoxJustificationCode.SelectedIndex; + Configuration.Settings.SubtitleSettings.EbuStlMarginTop = (int)Math.Round(numericUpDownMarginTop.Value); + Configuration.Settings.SubtitleSettings.EbuStlMarginBottom = (int)Math.Round(numericUpDownMarginBottom.Value); + Configuration.Settings.SubtitleSettings.EbuStlNewLineRows = (int)Math.Round(numericUpDownNewLineRows.Value); + Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox = checkBoxTeletextBox.Checked; + Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight = checkBoxTeletextDoubleHeight.Checked; + + if (_subtitle != null) + { + _subtitle.Header = _header.ToString(); + } + + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void buttonImport_Click(object sender, EventArgs e) + { + openFileDialog1.Filter = "EBU STL files (*.stl)|*.stl"; + openFileDialog1.FileName = string.Empty; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + FillHeaderFromFile(openFileDialog1.FileName); + } + } + + private void FillHeaderFromFile(string fileName) + { + if (File.Exists(fileName)) + { + var ebu = new Ebu(); + var temp = new Subtitle(); + ebu.LoadSubtitle(temp, null, fileName); + FillFromHeader(ebu.Header); + if (ebu.JustificationCodes.Count > 2 && ebu.JustificationCodes[1] == ebu.JustificationCodes[2]) + { + if (ebu.JustificationCodes[1] >= 0 && ebu.JustificationCodes[1] < 4) + { + comboBoxJustificationCode.SelectedIndex = ebu.JustificationCodes[1]; + } + } + } + } + + private void numericUpDownMaxCharacters_ValueChanged(object sender, EventArgs e) + { + CheckMaxCharsPerRow(); + CheckErrors(_subtitle); + } + + private void unitedStatesToolStripMenuItem_Click(object sender, EventArgs e) + { + textBoxCodePageNumber.Text = "437"; + } + + private void multilingualToolStripMenuItem_Click(object sender, EventArgs e) + { + textBoxCodePageNumber.Text = "850"; + } + + private void portugalToolStripMenuItem_Click(object sender, EventArgs e) + { + textBoxCodePageNumber.Text = "860"; + } + + private void canadaFrenchToolStripMenuItem_Click(object sender, EventArgs e) + { + textBoxCodePageNumber.Text = "863"; + } + + private void nordicToolStripMenuItem_Click(object sender, EventArgs e) + { + textBoxCodePageNumber.Text = "865"; + } + + private void comboBoxDiscFormatCode_SelectedIndexChanged(object sender, EventArgs e) + { + if (comboBoxDiscFormatCode.SelectedIndex == 2) + { + comboBoxFrameRate.Text = (25).ToString(CultureInfo.CurrentCulture); + } + else if (comboBoxDiscFormatCode.SelectedIndex == 4) + { + comboBoxFrameRate.Text = (30).ToString(CultureInfo.CurrentCulture); + } + } + + private void comboBoxDisplayStandardCode_SelectedIndexChanged(object sender, EventArgs e) + { + labelDisplayStandardCodeWarning.Text = string.Empty; + CheckMaxCharsPerRow(); + if (_subtitle == null) + { + return; + } + + var fontColorFound = false; + var alignmentFound = false; + if (comboBoxDisplayStandardCode.SelectedIndex == 0) // open subtitling + { + foreach (var paragraph in _subtitle.Paragraphs) + { + if (!fontColorFound && + paragraph.Text.Contains(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 157, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 157, 17 + \ No newline at end of file diff --git a/src/Forms/EffectKaraoke.Designer.cs b/src/ui/Forms/EffectKaraoke.Designer.cs similarity index 97% rename from src/Forms/EffectKaraoke.Designer.cs rename to src/ui/Forms/EffectKaraoke.Designer.cs index 65b913a8c..68263144c 100644 --- a/src/Forms/EffectKaraoke.Designer.cs +++ b/src/ui/Forms/EffectKaraoke.Designer.cs @@ -1,232 +1,232 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class EffectKaraoke - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.labelTotalMilliseconds = new System.Windows.Forms.Label(); - this.labelTM = new System.Windows.Forms.Label(); - this.numericUpDownDelay = new System.Windows.Forms.NumericUpDown(); - this.labelColor = new System.Windows.Forms.Label(); - this.labelEndDelay = new System.Windows.Forms.Label(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonChooseColor = new System.Windows.Forms.Button(); - this.panelColor = new System.Windows.Forms.Panel(); - this.labelChooseColor = new System.Windows.Forms.Label(); - this.buttonPreview = new System.Windows.Forms.Button(); - this.colorDialog1 = new System.Windows.Forms.ColorDialog(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.richTextBoxPreview = new System.Windows.Forms.RichTextBox(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDelay)).BeginInit(); - this.SuspendLayout(); - // - // labelTotalMilliseconds - // - this.labelTotalMilliseconds.AutoSize = true; - this.labelTotalMilliseconds.Location = new System.Drawing.Point(169, 52); - this.labelTotalMilliseconds.Name = "labelTotalMilliseconds"; - this.labelTotalMilliseconds.Size = new System.Drawing.Size(108, 13); - this.labelTotalMilliseconds.TabIndex = 49; - this.labelTotalMilliseconds.Text = "labelTotalMilliseconds"; - // - // labelTM - // - this.labelTM.Location = new System.Drawing.Point(3, 52); - this.labelTM.Name = "labelTM"; - this.labelTM.Size = new System.Drawing.Size(163, 13); - this.labelTM.TabIndex = 48; - this.labelTM.Text = "Total milliseconds:"; - this.labelTM.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // numericUpDownDelay - // - this.numericUpDownDelay.DecimalPlaces = 3; - this.numericUpDownDelay.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownDelay.Location = new System.Drawing.Point(169, 72); - this.numericUpDownDelay.Maximum = new decimal(new int[] { - 99999, - 0, - 0, - 0}); - this.numericUpDownDelay.Minimum = new decimal(new int[] { - 99999, - 0, - 0, - -2147483648}); - this.numericUpDownDelay.Name = "numericUpDownDelay"; - this.numericUpDownDelay.Size = new System.Drawing.Size(54, 21); - this.numericUpDownDelay.TabIndex = 47; - // - // labelColor - // - this.labelColor.AutoSize = true; - this.labelColor.Location = new System.Drawing.Point(228, 22); - this.labelColor.Name = "labelColor"; - this.labelColor.Size = new System.Drawing.Size(32, 13); - this.labelColor.TabIndex = 46; - this.labelColor.Text = "Color"; - // - // labelEndDelay - // - this.labelEndDelay.Location = new System.Drawing.Point(3, 76); - this.labelEndDelay.Name = "labelEndDelay"; - this.labelEndDelay.Size = new System.Drawing.Size(163, 17); - this.labelEndDelay.TabIndex = 45; - this.labelEndDelay.Text = "End delay in milliseconds:"; - this.labelEndDelay.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // buttonCancel - // - this.buttonCancel.BackColor = System.Drawing.SystemColors.Control; - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(353, 173); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 44; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = false; - // - // buttonOK - // - this.buttonOK.Location = new System.Drawing.Point(272, 173); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 43; - this.buttonOK.Text = "OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // buttonChooseColor - // - this.buttonChooseColor.Location = new System.Drawing.Point(169, 17); - this.buttonChooseColor.Name = "buttonChooseColor"; - this.buttonChooseColor.Size = new System.Drawing.Size(27, 23); - this.buttonChooseColor.TabIndex = 42; - this.buttonChooseColor.Text = "..."; - this.buttonChooseColor.UseVisualStyleBackColor = true; - this.buttonChooseColor.Click += new System.EventHandler(this.ButtonChooseColorClick); - // - // panelColor - // - this.panelColor.Location = new System.Drawing.Point(202, 19); - this.panelColor.Name = "panelColor"; - this.panelColor.Size = new System.Drawing.Size(20, 20); - this.panelColor.TabIndex = 41; - // - // labelChooseColor - // - this.labelChooseColor.Location = new System.Drawing.Point(0, 22); - this.labelChooseColor.Name = "labelChooseColor"; - this.labelChooseColor.Size = new System.Drawing.Size(166, 13); - this.labelChooseColor.TabIndex = 40; - this.labelChooseColor.Text = "Choose color:"; - this.labelChooseColor.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // buttonPreview - // - this.buttonPreview.Location = new System.Drawing.Point(12, 154); - this.buttonPreview.Name = "buttonPreview"; - this.buttonPreview.Size = new System.Drawing.Size(100, 23); - this.buttonPreview.TabIndex = 39; - this.buttonPreview.Text = "Preview"; - this.buttonPreview.UseVisualStyleBackColor = true; - this.buttonPreview.Click += new System.EventHandler(this.ButtonPreviewClick); - // - // timer1 - // - this.timer1.Tick += new System.EventHandler(this.Timer1Tick); - // - // richTextBoxPreview - // - this.richTextBoxPreview.BackColor = System.Drawing.Color.Black; - this.richTextBoxPreview.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.richTextBoxPreview.DetectUrls = false; - this.richTextBoxPreview.Location = new System.Drawing.Point(13, 99); - this.richTextBoxPreview.Name = "richTextBoxPreview"; - this.richTextBoxPreview.ReadOnly = true; - this.richTextBoxPreview.Size = new System.Drawing.Size(415, 49); - this.richTextBoxPreview.TabIndex = 50; - this.richTextBoxPreview.TabStop = false; - this.richTextBoxPreview.Text = ""; - // - // EffectKaraoke - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(440, 208); - this.Controls.Add(this.richTextBoxPreview); - this.Controls.Add(this.labelTotalMilliseconds); - this.Controls.Add(this.labelTM); - this.Controls.Add(this.numericUpDownDelay); - this.Controls.Add(this.labelColor); - this.Controls.Add(this.labelEndDelay); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonChooseColor); - this.Controls.Add(this.panelColor); - this.Controls.Add(this.labelChooseColor); - this.Controls.Add(this.buttonPreview); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "EffectKaraoke"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Karaoke effect"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormEffectkaraoke_KeyDown); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDelay)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelTotalMilliseconds; - private System.Windows.Forms.Label labelTM; - private System.Windows.Forms.NumericUpDown numericUpDownDelay; - private System.Windows.Forms.Label labelColor; - private System.Windows.Forms.Label labelEndDelay; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonChooseColor; - private System.Windows.Forms.Panel panelColor; - private System.Windows.Forms.Label labelChooseColor; - private System.Windows.Forms.Button buttonPreview; - private System.Windows.Forms.ColorDialog colorDialog1; - private System.Windows.Forms.Timer timer1; - private System.Windows.Forms.RichTextBox richTextBoxPreview; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class EffectKaraoke + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.labelTotalMilliseconds = new System.Windows.Forms.Label(); + this.labelTM = new System.Windows.Forms.Label(); + this.numericUpDownDelay = new System.Windows.Forms.NumericUpDown(); + this.labelColor = new System.Windows.Forms.Label(); + this.labelEndDelay = new System.Windows.Forms.Label(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonChooseColor = new System.Windows.Forms.Button(); + this.panelColor = new System.Windows.Forms.Panel(); + this.labelChooseColor = new System.Windows.Forms.Label(); + this.buttonPreview = new System.Windows.Forms.Button(); + this.colorDialog1 = new System.Windows.Forms.ColorDialog(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.richTextBoxPreview = new System.Windows.Forms.RichTextBox(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDelay)).BeginInit(); + this.SuspendLayout(); + // + // labelTotalMilliseconds + // + this.labelTotalMilliseconds.AutoSize = true; + this.labelTotalMilliseconds.Location = new System.Drawing.Point(169, 52); + this.labelTotalMilliseconds.Name = "labelTotalMilliseconds"; + this.labelTotalMilliseconds.Size = new System.Drawing.Size(108, 13); + this.labelTotalMilliseconds.TabIndex = 49; + this.labelTotalMilliseconds.Text = "labelTotalMilliseconds"; + // + // labelTM + // + this.labelTM.Location = new System.Drawing.Point(3, 52); + this.labelTM.Name = "labelTM"; + this.labelTM.Size = new System.Drawing.Size(163, 13); + this.labelTM.TabIndex = 48; + this.labelTM.Text = "Total milliseconds:"; + this.labelTM.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // numericUpDownDelay + // + this.numericUpDownDelay.DecimalPlaces = 3; + this.numericUpDownDelay.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownDelay.Location = new System.Drawing.Point(169, 72); + this.numericUpDownDelay.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.numericUpDownDelay.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.numericUpDownDelay.Name = "numericUpDownDelay"; + this.numericUpDownDelay.Size = new System.Drawing.Size(54, 21); + this.numericUpDownDelay.TabIndex = 47; + // + // labelColor + // + this.labelColor.AutoSize = true; + this.labelColor.Location = new System.Drawing.Point(228, 22); + this.labelColor.Name = "labelColor"; + this.labelColor.Size = new System.Drawing.Size(32, 13); + this.labelColor.TabIndex = 46; + this.labelColor.Text = "Color"; + // + // labelEndDelay + // + this.labelEndDelay.Location = new System.Drawing.Point(3, 76); + this.labelEndDelay.Name = "labelEndDelay"; + this.labelEndDelay.Size = new System.Drawing.Size(163, 17); + this.labelEndDelay.TabIndex = 45; + this.labelEndDelay.Text = "End delay in milliseconds:"; + this.labelEndDelay.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // buttonCancel + // + this.buttonCancel.BackColor = System.Drawing.SystemColors.Control; + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(353, 173); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 44; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = false; + // + // buttonOK + // + this.buttonOK.Location = new System.Drawing.Point(272, 173); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 43; + this.buttonOK.Text = "OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // buttonChooseColor + // + this.buttonChooseColor.Location = new System.Drawing.Point(169, 17); + this.buttonChooseColor.Name = "buttonChooseColor"; + this.buttonChooseColor.Size = new System.Drawing.Size(27, 23); + this.buttonChooseColor.TabIndex = 42; + this.buttonChooseColor.Text = "..."; + this.buttonChooseColor.UseVisualStyleBackColor = true; + this.buttonChooseColor.Click += new System.EventHandler(this.ButtonChooseColorClick); + // + // panelColor + // + this.panelColor.Location = new System.Drawing.Point(202, 19); + this.panelColor.Name = "panelColor"; + this.panelColor.Size = new System.Drawing.Size(20, 20); + this.panelColor.TabIndex = 41; + // + // labelChooseColor + // + this.labelChooseColor.Location = new System.Drawing.Point(0, 22); + this.labelChooseColor.Name = "labelChooseColor"; + this.labelChooseColor.Size = new System.Drawing.Size(166, 13); + this.labelChooseColor.TabIndex = 40; + this.labelChooseColor.Text = "Choose color:"; + this.labelChooseColor.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // buttonPreview + // + this.buttonPreview.Location = new System.Drawing.Point(12, 154); + this.buttonPreview.Name = "buttonPreview"; + this.buttonPreview.Size = new System.Drawing.Size(100, 23); + this.buttonPreview.TabIndex = 39; + this.buttonPreview.Text = "Preview"; + this.buttonPreview.UseVisualStyleBackColor = true; + this.buttonPreview.Click += new System.EventHandler(this.ButtonPreviewClick); + // + // timer1 + // + this.timer1.Tick += new System.EventHandler(this.Timer1Tick); + // + // richTextBoxPreview + // + this.richTextBoxPreview.BackColor = System.Drawing.Color.Black; + this.richTextBoxPreview.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.richTextBoxPreview.DetectUrls = false; + this.richTextBoxPreview.Location = new System.Drawing.Point(13, 99); + this.richTextBoxPreview.Name = "richTextBoxPreview"; + this.richTextBoxPreview.ReadOnly = true; + this.richTextBoxPreview.Size = new System.Drawing.Size(415, 49); + this.richTextBoxPreview.TabIndex = 50; + this.richTextBoxPreview.TabStop = false; + this.richTextBoxPreview.Text = ""; + // + // EffectKaraoke + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(440, 208); + this.Controls.Add(this.richTextBoxPreview); + this.Controls.Add(this.labelTotalMilliseconds); + this.Controls.Add(this.labelTM); + this.Controls.Add(this.numericUpDownDelay); + this.Controls.Add(this.labelColor); + this.Controls.Add(this.labelEndDelay); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonChooseColor); + this.Controls.Add(this.panelColor); + this.Controls.Add(this.labelChooseColor); + this.Controls.Add(this.buttonPreview); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "EffectKaraoke"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Karaoke effect"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormEffectkaraoke_KeyDown); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDelay)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelTotalMilliseconds; + private System.Windows.Forms.Label labelTM; + private System.Windows.Forms.NumericUpDown numericUpDownDelay; + private System.Windows.Forms.Label labelColor; + private System.Windows.Forms.Label labelEndDelay; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonChooseColor; + private System.Windows.Forms.Panel panelColor; + private System.Windows.Forms.Label labelChooseColor; + private System.Windows.Forms.Button buttonPreview; + private System.Windows.Forms.ColorDialog colorDialog1; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.RichTextBox richTextBoxPreview; + } } \ No newline at end of file diff --git a/src/Forms/EffectKaraoke.cs b/src/ui/Forms/EffectKaraoke.cs similarity index 97% rename from src/Forms/EffectKaraoke.cs rename to src/ui/Forms/EffectKaraoke.cs index 9bef51736..ed2ecb54d 100644 --- a/src/Forms/EffectKaraoke.cs +++ b/src/ui/Forms/EffectKaraoke.cs @@ -1,455 +1,455 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class EffectKaraoke : Form - { - private Paragraph _paragraph; - private List _animation; - private int _timerCount; - - public EffectKaraoke() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.EffectKaraoke.Title; - labelChooseColor.Text = Configuration.Settings.Language.EffectKaraoke.ChooseColor; - labelTM.Text = Configuration.Settings.Language.EffectKaraoke.TotalMilliseconds; - labelEndDelay.Text = Configuration.Settings.Language.EffectKaraoke.EndDelayInMilliseconds; - buttonPreview.Text = Configuration.Settings.Language.General.Preview; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void FormEffectkaraoke_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - internal void Initialize(Paragraph paragraph) - { - _paragraph = new Paragraph(paragraph); - if (_paragraph.Text.Length > 3) - { - _paragraph.Text = HtmlUtil.FixUpperTags(_paragraph.Text); - } - _animation = new List(); - - colorDialog1.Color = Color.Red; - labelColor.Text = Utilities.ColorToHex(colorDialog1.Color); - panelColor.BackColor = colorDialog1.Color; - - AddToPreview(richTextBoxPreview, paragraph.Text); - RefreshPreview(); - labelTotalMilliseconds.Text = $"{paragraph.Duration.TotalMilliseconds / TimeCode.BaseUnit:#,##0.000}"; - numericUpDownDelay.Maximum = (decimal)((paragraph.Duration.TotalMilliseconds - 500) / TimeCode.BaseUnit); - numericUpDownDelay.Minimum = 0; - - numericUpDownDelay.Left = labelEndDelay.Left + labelEndDelay.Width + 5; - } - - internal struct ColorEntry - { - public int Start { get; set; } - public int Length { get; set; } - public Color Color { get; set; } - } - - internal struct FontEntry - { - public int Start { get; set; } - public int Length { get; set; } - public Font Font { get; set; } - } - - private List _colorList; - private List _fontList; - - private void AddToPreview(RichTextBox rtb, string text) - { - richTextBoxPreview.ForeColor = Color.White; - _colorList = new List(); - _fontList = new List(); - - int bold = 0; - int underline = 0; - int italic = 0; - var fontColors = new Stack(); - string currentColor = string.Empty; - - var sb = new StringBuilder(); - int i = 0; - while (i < text.Length) - { - if (text[i] == '<' && IsTagFollowIndex(text, i)) - { - AddTextToRichTextBox(rtb, bold > 0, italic > 0, underline > 0, currentColor, sb.ToString()); - sb.Clear(); - string tag = GetTag(text.Substring(i)); - if (i + 1 < text.Length && text[i + 1] == '/') - { - if (tag == "
" && italic > 0) - { - italic--; - } - else if (tag == "" && bold > 0) - { - bold--; - } - else if (tag == "" && underline > 0) - { - underline--; - } - else if (tag == "") - { - currentColor = fontColors.Count > 0 ? fontColors.Pop() : string.Empty; - } - } - else - { - if (tag == "") - { - italic++; - } - else if (tag == "") - { - bold++; - } - else if (tag == "") - { - underline++; - } - else if (tag.StartsWith(" 0) - { - AddTextToRichTextBox(rtb, bold > 0, italic > 0, underline > 0, currentColor, sb.ToString()); - } - - foreach (var fontEntry in _fontList) - { - rtb.SelectionStart = fontEntry.Start; - rtb.SelectionLength = fontEntry.Length; - rtb.SelectionFont = fontEntry.Font; - rtb.DeselectAll(); - } - - foreach (var colorEntry in _colorList) - { - rtb.SelectionStart = colorEntry.Start; - rtb.SelectionLength = colorEntry.Length; - rtb.SelectionColor = colorEntry.Color; - rtb.DeselectAll(); - } - } - - private void AddTextToRichTextBox(RichTextBox rtb, bool bold, bool italic, bool underline, string color, string text) - { - if (text.Length > 0) - { - int length = rtb.Text.Length; - richTextBoxPreview.Text += text; - _colorList.Add(new ColorEntry { Start = length, Length = text.Length, Color = string.IsNullOrWhiteSpace(color) ? Color.White : ColorTranslator.FromHtml(color) }); - - var fontStyle = new FontStyle(); - if (underline) - { - fontStyle = FontStyle.Underline; - } - - if (italic) - { - fontStyle |= FontStyle.Italic; - } - - if (bold) - { - fontStyle |= FontStyle.Bold; - } - - _fontList.Add(new FontEntry { Start = length, Length = text.Length, Font = new Font(rtb.Font.FontFamily, rtb.Font.Size, fontStyle) }); - } - } - - private static string GetTag(string text) - { - var sb = new StringBuilder(); - for (int i = 0; i < text.Length; i++) - { - sb.Append(text[i]); - if (text[i] == '>') - { - return sb.ToString(); - } - } - return sb.ToString(); - } - - private void ClearPreview() - { - richTextBoxPreview.Text = string.Empty; - } - - private void RefreshPreview() - { - richTextBoxPreview.SelectAll(); - richTextBoxPreview.SelectionAlignment = HorizontalAlignment.Center; - richTextBoxPreview.Refresh(); - } - - private void ButtonChooseColorClick(object sender, EventArgs e) - { - if (colorDialog1.ShowDialog() == DialogResult.OK) - { - labelColor.Text = Utilities.ColorToHex(colorDialog1.Color); - panelColor.BackColor = colorDialog1.Color; - } - } - - private void ButtonPreviewClick(object sender, EventArgs e) - { - MakeAnimation(); - PlayAnimation(); - } - - private void PlayAnimation() - { - _timerCount = (int)_paragraph.StartTime.TotalMilliseconds; - timer1.Start(); - } - - public static double CalculateStepLength(string text, double duration) - { - // Exclude non displayed characters. - int totalNewLineChars = Utilities.CountTagInText(text, '\n') + Utilities.CountTagInText(text, '\r'); - return duration / (HtmlUtil.RemoveHtmlTags(text, true).Length - totalNewLineChars); - } - - public List MakeAnimation(Paragraph paragraph) - { - _paragraph = paragraph; - MakeAnimation(); - return _animation; - } - - private void MakeAnimation() - { - _animation = new List(); - double duration = _paragraph.Duration.TotalMilliseconds - ((double)numericUpDownDelay.Value * TimeCode.BaseUnit); - double stepsLength = CalculateStepLength(_paragraph.Text, duration); - - double startMilliseconds; - double endMilliseconds; - TimeCode start; - TimeCode end; - int index = 0; - string text = string.Empty; - bool tagOn = false; - string tag = string.Empty; - int i = 0; - string startFontTag = string.Format("", Utilities.ColorToHex(panelColor.BackColor)); - const string endFontTag = ""; - string afterCurrentTag = string.Empty; - string beforeEndTag = string.Empty; - string alignment = string.Empty; - - // Preserve SSA tag if present. - if (_paragraph.Text.StartsWith("{\\", StringComparison.Ordinal) && _paragraph.Text.IndexOf('}') > 2) - { - int idx = _paragraph.Text.IndexOf('}'); - alignment = _paragraph.Text.Substring(0, idx + 1); - i = idx; - } - - while (i < _paragraph.Text.Length) - { - var c = _paragraph.Text[i]; - if (tagOn) - { - tag += c; - if (_paragraph.Text[i] == '>') - { - tagOn = false; - if (tag.StartsWith("") - { - afterCurrentTag = ""; - beforeEndTag = ""; - } - else if (tag == "") - { - afterCurrentTag = ""; - beforeEndTag = ""; - } - else if (tag == "") - { - afterCurrentTag = ""; - beforeEndTag = ""; - } - } - } - else if (_paragraph.Text[i] == '<' && IsTagFollowIndex(_paragraph.Text, i)) - { - afterCurrentTag = string.Empty; - tagOn = true; - tag += c; - beforeEndTag = string.Empty; - } - else - { - text += tag + c; - tag = string.Empty; - // Take next char if current is (\r or \n); - while ((_paragraph.Text[i] == '\r' || _paragraph.Text[i] == '\n') && (i + 1 < _paragraph.Text.Length)) - { - text += _paragraph.Text[++i]; - } - string afterText = string.Empty; - if (i + 1 < _paragraph.Text.Length) - { - afterText = _paragraph.Text.Substring(i + 1); - } - - if (afterText.StartsWith(endFontTag, StringComparison.Ordinal) && afterCurrentTag.StartsWith(" if present. - afterText = afterText.Substring(endFontTag.Length); - // Move pointer to end to avoid redundant loop. - i += endFontTag.Length; - afterCurrentTag = string.Empty; - } - string tempText = alignment + startFontTag + text + beforeEndTag + endFontTag + afterCurrentTag + afterText; - tempText = tempText.Replace("", string.Empty); - tempText = tempText.Replace("", string.Empty); - tempText = tempText.Replace("", string.Empty); - - startMilliseconds = index * stepsLength; - startMilliseconds += _paragraph.StartTime.TotalMilliseconds; - endMilliseconds = ((index + 1) * stepsLength) - 1; - endMilliseconds += _paragraph.StartTime.TotalMilliseconds; - start = new TimeCode(startMilliseconds); - end = new TimeCode(endMilliseconds); - _animation.Add(new Paragraph(start, end, tempText)); - index++; - } - i++; - } - // All remaining time should go to the last paragraph. - if (_animation.Count > 0) - { - _animation[_animation.Count - 1].EndTime.TotalMilliseconds = _paragraph.EndTime.TotalMilliseconds; - } - } - - private void Timer1Tick(object sender, EventArgs e) - { - _timerCount += timer1.Interval; - - string s = GetText(_timerCount, _animation); - ClearPreview(); - AddToPreview(richTextBoxPreview, s); - RefreshPreview(); - - if (_timerCount > _paragraph.EndTime.TotalMilliseconds) - { - timer1.Stop(); - System.Threading.Thread.Sleep(200); - ClearPreview(); - AddToPreview(richTextBoxPreview, _paragraph.Text); - } - } - - private static string GetText(int milliseconds, IEnumerable animation) - { - foreach (Paragraph p in animation) - { - if (p.StartTime.TotalMilliseconds <= milliseconds && - p.EndTime.TotalMilliseconds >= milliseconds) - { - return p.Text; - } - } - return string.Empty; - } - - private void ButtonOkClick(object sender, EventArgs e) - { - MakeAnimation(); - DialogResult = DialogResult.OK; - } - - public static bool IsTagFollowIndex(string text, int index) - { - string tag; - // , , , - if (text.Length >= index + 7) - { - tag = text.Substring(index, 7); - if (tag.StartsWith("= index + 3) - { - tag = text.Substring(index, 3); - int idx = 1; - if ((tag[2] == '>' || tag[idx++] == '/') && (tag[idx] == 'i' || tag[idx] == 'I' || tag[idx] == 'b' || tag[idx] == 'B' || tag[idx] == 'u' || tag[idx] == 'U')) - { - return true; - } - } - return false; - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class EffectKaraoke : Form + { + private Paragraph _paragraph; + private List _animation; + private int _timerCount; + + public EffectKaraoke() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.EffectKaraoke.Title; + labelChooseColor.Text = Configuration.Settings.Language.EffectKaraoke.ChooseColor; + labelTM.Text = Configuration.Settings.Language.EffectKaraoke.TotalMilliseconds; + labelEndDelay.Text = Configuration.Settings.Language.EffectKaraoke.EndDelayInMilliseconds; + buttonPreview.Text = Configuration.Settings.Language.General.Preview; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void FormEffectkaraoke_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + internal void Initialize(Paragraph paragraph) + { + _paragraph = new Paragraph(paragraph); + if (_paragraph.Text.Length > 3) + { + _paragraph.Text = HtmlUtil.FixUpperTags(_paragraph.Text); + } + _animation = new List(); + + colorDialog1.Color = Color.Red; + labelColor.Text = Utilities.ColorToHex(colorDialog1.Color); + panelColor.BackColor = colorDialog1.Color; + + AddToPreview(richTextBoxPreview, paragraph.Text); + RefreshPreview(); + labelTotalMilliseconds.Text = $"{paragraph.Duration.TotalMilliseconds / TimeCode.BaseUnit:#,##0.000}"; + numericUpDownDelay.Maximum = (decimal)((paragraph.Duration.TotalMilliseconds - 500) / TimeCode.BaseUnit); + numericUpDownDelay.Minimum = 0; + + numericUpDownDelay.Left = labelEndDelay.Left + labelEndDelay.Width + 5; + } + + internal struct ColorEntry + { + public int Start { get; set; } + public int Length { get; set; } + public Color Color { get; set; } + } + + internal struct FontEntry + { + public int Start { get; set; } + public int Length { get; set; } + public Font Font { get; set; } + } + + private List _colorList; + private List _fontList; + + private void AddToPreview(RichTextBox rtb, string text) + { + richTextBoxPreview.ForeColor = Color.White; + _colorList = new List(); + _fontList = new List(); + + int bold = 0; + int underline = 0; + int italic = 0; + var fontColors = new Stack(); + string currentColor = string.Empty; + + var sb = new StringBuilder(); + int i = 0; + while (i < text.Length) + { + if (text[i] == '<' && IsTagFollowIndex(text, i)) + { + AddTextToRichTextBox(rtb, bold > 0, italic > 0, underline > 0, currentColor, sb.ToString()); + sb.Clear(); + string tag = GetTag(text.Substring(i)); + if (i + 1 < text.Length && text[i + 1] == '/') + { + if (tag == "" && italic > 0) + { + italic--; + } + else if (tag == "" && bold > 0) + { + bold--; + } + else if (tag == "" && underline > 0) + { + underline--; + } + else if (tag == "") + { + currentColor = fontColors.Count > 0 ? fontColors.Pop() : string.Empty; + } + } + else + { + if (tag == "") + { + italic++; + } + else if (tag == "") + { + bold++; + } + else if (tag == "") + { + underline++; + } + else if (tag.StartsWith(" 0) + { + AddTextToRichTextBox(rtb, bold > 0, italic > 0, underline > 0, currentColor, sb.ToString()); + } + + foreach (var fontEntry in _fontList) + { + rtb.SelectionStart = fontEntry.Start; + rtb.SelectionLength = fontEntry.Length; + rtb.SelectionFont = fontEntry.Font; + rtb.DeselectAll(); + } + + foreach (var colorEntry in _colorList) + { + rtb.SelectionStart = colorEntry.Start; + rtb.SelectionLength = colorEntry.Length; + rtb.SelectionColor = colorEntry.Color; + rtb.DeselectAll(); + } + } + + private void AddTextToRichTextBox(RichTextBox rtb, bool bold, bool italic, bool underline, string color, string text) + { + if (text.Length > 0) + { + int length = rtb.Text.Length; + richTextBoxPreview.Text += text; + _colorList.Add(new ColorEntry { Start = length, Length = text.Length, Color = string.IsNullOrWhiteSpace(color) ? Color.White : ColorTranslator.FromHtml(color) }); + + var fontStyle = new FontStyle(); + if (underline) + { + fontStyle = FontStyle.Underline; + } + + if (italic) + { + fontStyle |= FontStyle.Italic; + } + + if (bold) + { + fontStyle |= FontStyle.Bold; + } + + _fontList.Add(new FontEntry { Start = length, Length = text.Length, Font = new Font(rtb.Font.FontFamily, rtb.Font.Size, fontStyle) }); + } + } + + private static string GetTag(string text) + { + var sb = new StringBuilder(); + for (int i = 0; i < text.Length; i++) + { + sb.Append(text[i]); + if (text[i] == '>') + { + return sb.ToString(); + } + } + return sb.ToString(); + } + + private void ClearPreview() + { + richTextBoxPreview.Text = string.Empty; + } + + private void RefreshPreview() + { + richTextBoxPreview.SelectAll(); + richTextBoxPreview.SelectionAlignment = HorizontalAlignment.Center; + richTextBoxPreview.Refresh(); + } + + private void ButtonChooseColorClick(object sender, EventArgs e) + { + if (colorDialog1.ShowDialog() == DialogResult.OK) + { + labelColor.Text = Utilities.ColorToHex(colorDialog1.Color); + panelColor.BackColor = colorDialog1.Color; + } + } + + private void ButtonPreviewClick(object sender, EventArgs e) + { + MakeAnimation(); + PlayAnimation(); + } + + private void PlayAnimation() + { + _timerCount = (int)_paragraph.StartTime.TotalMilliseconds; + timer1.Start(); + } + + public static double CalculateStepLength(string text, double duration) + { + // Exclude non displayed characters. + int totalNewLineChars = Utilities.CountTagInText(text, '\n') + Utilities.CountTagInText(text, '\r'); + return duration / (HtmlUtil.RemoveHtmlTags(text, true).Length - totalNewLineChars); + } + + public List MakeAnimation(Paragraph paragraph) + { + _paragraph = paragraph; + MakeAnimation(); + return _animation; + } + + private void MakeAnimation() + { + _animation = new List(); + double duration = _paragraph.Duration.TotalMilliseconds - ((double)numericUpDownDelay.Value * TimeCode.BaseUnit); + double stepsLength = CalculateStepLength(_paragraph.Text, duration); + + double startMilliseconds; + double endMilliseconds; + TimeCode start; + TimeCode end; + int index = 0; + string text = string.Empty; + bool tagOn = false; + string tag = string.Empty; + int i = 0; + string startFontTag = string.Format("", Utilities.ColorToHex(panelColor.BackColor)); + const string endFontTag = ""; + string afterCurrentTag = string.Empty; + string beforeEndTag = string.Empty; + string alignment = string.Empty; + + // Preserve SSA tag if present. + if (_paragraph.Text.StartsWith("{\\", StringComparison.Ordinal) && _paragraph.Text.IndexOf('}') > 2) + { + int idx = _paragraph.Text.IndexOf('}'); + alignment = _paragraph.Text.Substring(0, idx + 1); + i = idx; + } + + while (i < _paragraph.Text.Length) + { + var c = _paragraph.Text[i]; + if (tagOn) + { + tag += c; + if (_paragraph.Text[i] == '>') + { + tagOn = false; + if (tag.StartsWith("") + { + afterCurrentTag = ""; + beforeEndTag = ""; + } + else if (tag == "") + { + afterCurrentTag = ""; + beforeEndTag = ""; + } + else if (tag == "") + { + afterCurrentTag = ""; + beforeEndTag = ""; + } + } + } + else if (_paragraph.Text[i] == '<' && IsTagFollowIndex(_paragraph.Text, i)) + { + afterCurrentTag = string.Empty; + tagOn = true; + tag += c; + beforeEndTag = string.Empty; + } + else + { + text += tag + c; + tag = string.Empty; + // Take next char if current is (\r or \n); + while ((_paragraph.Text[i] == '\r' || _paragraph.Text[i] == '\n') && (i + 1 < _paragraph.Text.Length)) + { + text += _paragraph.Text[++i]; + } + string afterText = string.Empty; + if (i + 1 < _paragraph.Text.Length) + { + afterText = _paragraph.Text.Substring(i + 1); + } + + if (afterText.StartsWith(endFontTag, StringComparison.Ordinal) && afterCurrentTag.StartsWith(" if present. + afterText = afterText.Substring(endFontTag.Length); + // Move pointer to end to avoid redundant loop. + i += endFontTag.Length; + afterCurrentTag = string.Empty; + } + string tempText = alignment + startFontTag + text + beforeEndTag + endFontTag + afterCurrentTag + afterText; + tempText = tempText.Replace("", string.Empty); + tempText = tempText.Replace("", string.Empty); + tempText = tempText.Replace("", string.Empty); + + startMilliseconds = index * stepsLength; + startMilliseconds += _paragraph.StartTime.TotalMilliseconds; + endMilliseconds = ((index + 1) * stepsLength) - 1; + endMilliseconds += _paragraph.StartTime.TotalMilliseconds; + start = new TimeCode(startMilliseconds); + end = new TimeCode(endMilliseconds); + _animation.Add(new Paragraph(start, end, tempText)); + index++; + } + i++; + } + // All remaining time should go to the last paragraph. + if (_animation.Count > 0) + { + _animation[_animation.Count - 1].EndTime.TotalMilliseconds = _paragraph.EndTime.TotalMilliseconds; + } + } + + private void Timer1Tick(object sender, EventArgs e) + { + _timerCount += timer1.Interval; + + string s = GetText(_timerCount, _animation); + ClearPreview(); + AddToPreview(richTextBoxPreview, s); + RefreshPreview(); + + if (_timerCount > _paragraph.EndTime.TotalMilliseconds) + { + timer1.Stop(); + System.Threading.Thread.Sleep(200); + ClearPreview(); + AddToPreview(richTextBoxPreview, _paragraph.Text); + } + } + + private static string GetText(int milliseconds, IEnumerable animation) + { + foreach (Paragraph p in animation) + { + if (p.StartTime.TotalMilliseconds <= milliseconds && + p.EndTime.TotalMilliseconds >= milliseconds) + { + return p.Text; + } + } + return string.Empty; + } + + private void ButtonOkClick(object sender, EventArgs e) + { + MakeAnimation(); + DialogResult = DialogResult.OK; + } + + public static bool IsTagFollowIndex(string text, int index) + { + string tag; + // , , , + if (text.Length >= index + 7) + { + tag = text.Substring(index, 7); + if (tag.StartsWith("= index + 3) + { + tag = text.Substring(index, 3); + int idx = 1; + if ((tag[2] == '>' || tag[idx++] == '/') && (tag[idx] == 'i' || tag[idx] == 'I' || tag[idx] == 'b' || tag[idx] == 'B' || tag[idx] == 'u' || tag[idx] == 'U')) + { + return true; + } + } + return false; + } + } +} diff --git a/src/Forms/EffectKaraoke.resx b/src/ui/Forms/EffectKaraoke.resx similarity index 97% rename from src/Forms/EffectKaraoke.resx rename to src/ui/Forms/EffectKaraoke.resx index e35a5f29c..296ac3e67 100644 --- a/src/Forms/EffectKaraoke.resx +++ b/src/ui/Forms/EffectKaraoke.resx @@ -1,126 +1,126 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 130, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 130, 17 + \ No newline at end of file diff --git a/src/Forms/EffectTypewriter.Designer.cs b/src/ui/Forms/EffectTypewriter.Designer.cs similarity index 97% rename from src/Forms/EffectTypewriter.Designer.cs rename to src/ui/Forms/EffectTypewriter.Designer.cs index 3e50699f4..3e244a967 100644 --- a/src/Forms/EffectTypewriter.Designer.cs +++ b/src/ui/Forms/EffectTypewriter.Designer.cs @@ -1,182 +1,182 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class EffectTypewriter - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.buttonPreview = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.labelEndDelay = new System.Windows.Forms.Label(); - this.numericUpDownDelay = new System.Windows.Forms.NumericUpDown(); - this.labelTM = new System.Windows.Forms.Label(); - this.labelTotalMilliseconds = new System.Windows.Forms.Label(); - this.richTextBoxPreview = new System.Windows.Forms.RichTextBox(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDelay)).BeginInit(); - this.SuspendLayout(); - // - // buttonPreview - // - this.buttonPreview.Location = new System.Drawing.Point(12, 119); - this.buttonPreview.Name = "buttonPreview"; - this.buttonPreview.Size = new System.Drawing.Size(100, 23); - this.buttonPreview.TabIndex = 26; - this.buttonPreview.Text = "Preview"; - this.buttonPreview.UseVisualStyleBackColor = true; - this.buttonPreview.Click += new System.EventHandler(this.ButtonPreviewClick); - // - // buttonOK - // - this.buttonOK.Location = new System.Drawing.Point(265, 144); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 30; - this.buttonOK.Text = "OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(346, 144); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 31; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // timer1 - // - this.timer1.Tick += new System.EventHandler(this.Timer1Tick); - // - // labelEndDelay - // - this.labelEndDelay.Location = new System.Drawing.Point(5, 45); - this.labelEndDelay.Name = "labelEndDelay"; - this.labelEndDelay.Size = new System.Drawing.Size(161, 19); - this.labelEndDelay.TabIndex = 32; - this.labelEndDelay.Text = "End delay in milliseconds:"; - this.labelEndDelay.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // numericUpDownDelay - // - this.numericUpDownDelay.DecimalPlaces = 3; - this.numericUpDownDelay.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownDelay.Location = new System.Drawing.Point(169, 43); - this.numericUpDownDelay.Maximum = new decimal(new int[] { - 99999, - 0, - 0, - 0}); - this.numericUpDownDelay.Minimum = new decimal(new int[] { - 99999, - 0, - 0, - -2147483648}); - this.numericUpDownDelay.Name = "numericUpDownDelay"; - this.numericUpDownDelay.Size = new System.Drawing.Size(54, 21); - this.numericUpDownDelay.TabIndex = 35; - // - // labelTM - // - this.labelTM.Location = new System.Drawing.Point(2, 23); - this.labelTM.Name = "labelTM"; - this.labelTM.Size = new System.Drawing.Size(164, 13); - this.labelTM.TabIndex = 36; - this.labelTM.Text = "Total milliseconds:"; - this.labelTM.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // labelTotalMilliseconds - // - this.labelTotalMilliseconds.AutoSize = true; - this.labelTotalMilliseconds.Location = new System.Drawing.Point(169, 23); - this.labelTotalMilliseconds.Name = "labelTotalMilliseconds"; - this.labelTotalMilliseconds.Size = new System.Drawing.Size(108, 13); - this.labelTotalMilliseconds.TabIndex = 37; - this.labelTotalMilliseconds.Text = "labelTotalMilliseconds"; - // - // richTextBoxPreview - // - this.richTextBoxPreview.BackColor = System.Drawing.Color.Black; - this.richTextBoxPreview.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.richTextBoxPreview.DetectUrls = false; - this.richTextBoxPreview.Location = new System.Drawing.Point(12, 69); - this.richTextBoxPreview.Name = "richTextBoxPreview"; - this.richTextBoxPreview.ReadOnly = true; - this.richTextBoxPreview.Size = new System.Drawing.Size(409, 44); - this.richTextBoxPreview.TabIndex = 51; - this.richTextBoxPreview.TabStop = false; - this.richTextBoxPreview.Text = ""; - // - // EffectTypewriter - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(433, 179); - this.Controls.Add(this.richTextBoxPreview); - this.Controls.Add(this.labelTotalMilliseconds); - this.Controls.Add(this.labelTM); - this.Controls.Add(this.numericUpDownDelay); - this.Controls.Add(this.labelEndDelay); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonPreview); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "EffectTypewriter"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Typewriter effect"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormEffectTypewriter_KeyDown); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDelay)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonPreview; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Timer timer1; - private System.Windows.Forms.Label labelEndDelay; - private System.Windows.Forms.NumericUpDown numericUpDownDelay; - private System.Windows.Forms.Label labelTM; - private System.Windows.Forms.Label labelTotalMilliseconds; - private System.Windows.Forms.RichTextBox richTextBoxPreview; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class EffectTypewriter + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonPreview = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.labelEndDelay = new System.Windows.Forms.Label(); + this.numericUpDownDelay = new System.Windows.Forms.NumericUpDown(); + this.labelTM = new System.Windows.Forms.Label(); + this.labelTotalMilliseconds = new System.Windows.Forms.Label(); + this.richTextBoxPreview = new System.Windows.Forms.RichTextBox(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDelay)).BeginInit(); + this.SuspendLayout(); + // + // buttonPreview + // + this.buttonPreview.Location = new System.Drawing.Point(12, 119); + this.buttonPreview.Name = "buttonPreview"; + this.buttonPreview.Size = new System.Drawing.Size(100, 23); + this.buttonPreview.TabIndex = 26; + this.buttonPreview.Text = "Preview"; + this.buttonPreview.UseVisualStyleBackColor = true; + this.buttonPreview.Click += new System.EventHandler(this.ButtonPreviewClick); + // + // buttonOK + // + this.buttonOK.Location = new System.Drawing.Point(265, 144); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 30; + this.buttonOK.Text = "OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(346, 144); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 31; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // timer1 + // + this.timer1.Tick += new System.EventHandler(this.Timer1Tick); + // + // labelEndDelay + // + this.labelEndDelay.Location = new System.Drawing.Point(5, 45); + this.labelEndDelay.Name = "labelEndDelay"; + this.labelEndDelay.Size = new System.Drawing.Size(161, 19); + this.labelEndDelay.TabIndex = 32; + this.labelEndDelay.Text = "End delay in milliseconds:"; + this.labelEndDelay.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // numericUpDownDelay + // + this.numericUpDownDelay.DecimalPlaces = 3; + this.numericUpDownDelay.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownDelay.Location = new System.Drawing.Point(169, 43); + this.numericUpDownDelay.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.numericUpDownDelay.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.numericUpDownDelay.Name = "numericUpDownDelay"; + this.numericUpDownDelay.Size = new System.Drawing.Size(54, 21); + this.numericUpDownDelay.TabIndex = 35; + // + // labelTM + // + this.labelTM.Location = new System.Drawing.Point(2, 23); + this.labelTM.Name = "labelTM"; + this.labelTM.Size = new System.Drawing.Size(164, 13); + this.labelTM.TabIndex = 36; + this.labelTM.Text = "Total milliseconds:"; + this.labelTM.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // labelTotalMilliseconds + // + this.labelTotalMilliseconds.AutoSize = true; + this.labelTotalMilliseconds.Location = new System.Drawing.Point(169, 23); + this.labelTotalMilliseconds.Name = "labelTotalMilliseconds"; + this.labelTotalMilliseconds.Size = new System.Drawing.Size(108, 13); + this.labelTotalMilliseconds.TabIndex = 37; + this.labelTotalMilliseconds.Text = "labelTotalMilliseconds"; + // + // richTextBoxPreview + // + this.richTextBoxPreview.BackColor = System.Drawing.Color.Black; + this.richTextBoxPreview.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.richTextBoxPreview.DetectUrls = false; + this.richTextBoxPreview.Location = new System.Drawing.Point(12, 69); + this.richTextBoxPreview.Name = "richTextBoxPreview"; + this.richTextBoxPreview.ReadOnly = true; + this.richTextBoxPreview.Size = new System.Drawing.Size(409, 44); + this.richTextBoxPreview.TabIndex = 51; + this.richTextBoxPreview.TabStop = false; + this.richTextBoxPreview.Text = ""; + // + // EffectTypewriter + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(433, 179); + this.Controls.Add(this.richTextBoxPreview); + this.Controls.Add(this.labelTotalMilliseconds); + this.Controls.Add(this.labelTM); + this.Controls.Add(this.numericUpDownDelay); + this.Controls.Add(this.labelEndDelay); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonPreview); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "EffectTypewriter"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Typewriter effect"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormEffectTypewriter_KeyDown); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDelay)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonPreview; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Label labelEndDelay; + private System.Windows.Forms.NumericUpDown numericUpDownDelay; + private System.Windows.Forms.Label labelTM; + private System.Windows.Forms.Label labelTotalMilliseconds; + private System.Windows.Forms.RichTextBox richTextBoxPreview; + } } \ No newline at end of file diff --git a/src/Forms/EffectTypewriter.cs b/src/ui/Forms/EffectTypewriter.cs similarity index 97% rename from src/Forms/EffectTypewriter.cs rename to src/ui/Forms/EffectTypewriter.cs index 36bb77111..e2865c77d 100644 --- a/src/Forms/EffectTypewriter.cs +++ b/src/ui/Forms/EffectTypewriter.cs @@ -1,408 +1,408 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class EffectTypewriter : Form - { - private Paragraph _paragraph; - private int _timerCount; - - public EffectTypewriter() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.EffectTypewriter.Title; - labelTM.Text = Configuration.Settings.Language.EffectTypewriter.TotalMilliseconds; - labelEndDelay.Text = Configuration.Settings.Language.EffectTypewriter.EndDelayInMilliseconds; - buttonPreview.Text = Configuration.Settings.Language.General.Preview; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - } - - public List TypewriterParagraphs { get; private set; } - - private void FormEffectTypewriter_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - internal void Initialize(Paragraph paragraph) - { - _paragraph = paragraph; - - AddToPreview(richTextBoxPreview, paragraph.Text); - RefreshPreview(); - - labelTotalMilliseconds.Text = $"{paragraph.Duration.TotalMilliseconds / TimeCode.BaseUnit:#,##0.000}"; - numericUpDownDelay.Maximum = (decimal)((paragraph.Duration.TotalMilliseconds - 500) / TimeCode.BaseUnit); - numericUpDownDelay.Minimum = 0; - - numericUpDownDelay.Left = labelEndDelay.Left + labelEndDelay.Width + 5; - } - - private List _colorList; - private List _fontList; - - private void AddToPreview(RichTextBox rtb, string text) - { - richTextBoxPreview.ForeColor = Color.White; - _colorList = new List(); - _fontList = new List(); - - int bold = 0; - int underline = 0; - int italic = 0; - var fontColors = new Stack(); - string currentColor = string.Empty; - - var sb = new StringBuilder(); - int i = 0; - while (i < text.Length) - { - if (text[i] == '<') - { - AddTextToRichTextBox(rtb, bold > 0, italic > 0, underline > 0, currentColor, sb.ToString()); - sb.Clear(); - string tag = GetTag(text.Substring(i).ToLowerInvariant()); - if (i + 1 < text.Length && text[i + 1] == '/') - { - if (tag == "" && italic > 0) - { - italic--; - } - else if (tag == "" && bold > 0) - { - bold--; - } - else if (tag == "" && underline > 0) - { - underline--; - } - else if (tag == "") - { - currentColor = fontColors.Count > 0 ? fontColors.Pop() : string.Empty; - } - } - else - { - if (tag == "") - { - italic++; - } - else if (tag == "") - { - bold++; - } - else if (tag == "") - { - underline++; - } - else if (tag.StartsWith(" 0) - { - AddTextToRichTextBox(rtb, bold > 0, italic > 0, underline > 0, currentColor, sb.ToString()); - } - - foreach (var fontEntry in _fontList) - { - rtb.SelectionStart = fontEntry.Start; - rtb.SelectionLength = fontEntry.Length; - rtb.SelectionFont = fontEntry.Font; - rtb.DeselectAll(); - } - - foreach (var colorEntry in _colorList) - { - rtb.SelectionStart = colorEntry.Start; - rtb.SelectionLength = colorEntry.Length; - rtb.SelectionColor = colorEntry.Color; - rtb.DeselectAll(); - } - } - - private void AddTextToRichTextBox(RichTextBox rtb, bool bold, bool italic, bool underline, string color, string text) - { - if (text.Length > 0) - { - int length = rtb.Text.Length; - richTextBoxPreview.Text += text; - - var c = Color.White; - if (!string.IsNullOrWhiteSpace(color)) - { - try - { - c = ColorTranslator.FromHtml(color); - } - catch - { - try - { - c = ColorTranslator.FromHtml("#" + color.Trim('#', ' ', '"', '\'')); - } - catch - { - c = Color.White; - } - } - } - - _colorList.Add(new EffectKaraoke.ColorEntry { Start = length, Length = text.Length, Color = c }); - - var fontStyle = new FontStyle(); - if (underline) - { - fontStyle |= FontStyle.Underline; - } - - if (italic) - { - fontStyle |= FontStyle.Italic; - } - - if (bold) - { - fontStyle |= FontStyle.Bold; - } - - _fontList.Add(new EffectKaraoke.FontEntry { Start = length, Length = text.Length, Font = new Font(rtb.Font.FontFamily, rtb.Font.Size, fontStyle) }); - } - } - - private static string GetTag(string text) - { - var sb = new StringBuilder(); - for (int i = 0; i < text.Length; i++) - { - sb.Append(text[i]); - if (text[i] == '>') - { - return sb.ToString(); - } - } - return sb.ToString(); - } - - private void ClearPreview() - { - richTextBoxPreview.Text = string.Empty; - } - - private void RefreshPreview() - { - richTextBoxPreview.SelectAll(); - richTextBoxPreview.SelectionAlignment = HorizontalAlignment.Center; - richTextBoxPreview.Refresh(); - } - - private void ButtonPreviewClick(object sender, EventArgs e) - { - MakeAnimation(); - PlayAnimation(); - } - - private void PlayAnimation() - { - _timerCount = (int)_paragraph.StartTime.TotalMilliseconds; - timer1.Start(); - } - - private static double CalculateStepLength(string text, double duration) - { - if (text.StartsWith("{\\", StringComparison.Ordinal) && text.IndexOf('}') > 2) - { - int i = 0; - while (i < text.Length && - text.Substring(i).StartsWith("{\\", StringComparison.Ordinal) && - text.Substring(i).IndexOf('}', i) > 2) - { - int idx = text.IndexOf('}', i); - i = idx + 1; - } - text = text.Remove(0, i); - } - - text = HtmlUtil.RemoveHtmlTags(text); - return duration / text.Length; - } - - public void MakeAnimation() - { - TypewriterParagraphs = new List(); - double duration = _paragraph.Duration.TotalMilliseconds - (double)numericUpDownDelay.Value * TimeCode.BaseUnit; - double stepsLength = CalculateStepLength(_paragraph.Text, duration); - - double startMilliseconds; - double endMilliseconds; - TimeCode start; - TimeCode end; - int index = 0; - string text = string.Empty; - bool tagOn = false; - string tag = string.Empty; - int i = 0; - string beforeEndTag = string.Empty; - string alignment = string.Empty; - while (i < _paragraph.Text.Length) - { - if (i == 0 && _paragraph.Text.StartsWith("{\\", StringComparison.Ordinal) && _paragraph.Text.IndexOf('}') > 2) - { - int j = i; - while (j < _paragraph.Text.Length && - _paragraph.Text.Substring(j).StartsWith("{\\", StringComparison.Ordinal) && - _paragraph.Text.Substring(j).IndexOf('}', j) > 2) - { - int idx = _paragraph.Text.IndexOf('}', j); - i = idx; - j = i + 1; - } - alignment = _paragraph.Text.Substring(0, j); - } - else if (tagOn) - { - tag += _paragraph.Text[i]; - if (_paragraph.Text[i] == '>') - { - tagOn = false; - if (tag.StartsWith("") - { - beforeEndTag = ""; - } - else if (tag == "") - { - beforeEndTag = ""; - } - else if (tag == "") - { - beforeEndTag = ""; - } - } - } - else if (_paragraph.Text[i] == '<') - { - tagOn = true; - tag += _paragraph.Text[i]; - beforeEndTag = string.Empty; - } - else - { - text += tag + _paragraph.Text[i]; - tag = string.Empty; - - startMilliseconds = index * stepsLength; - startMilliseconds += _paragraph.StartTime.TotalMilliseconds; - endMilliseconds = (index + 1) * stepsLength - 1; - endMilliseconds += _paragraph.StartTime.TotalMilliseconds; - start = new TimeCode(startMilliseconds); - end = new TimeCode(endMilliseconds); - TypewriterParagraphs.Add(new Paragraph(start, end, alignment + text + beforeEndTag) { Extra = _paragraph.Extra }); - index++; - } - i++; - } - - if (numericUpDownDelay.Value > 0) - { - startMilliseconds = index * stepsLength; - startMilliseconds += _paragraph.StartTime.TotalMilliseconds; - endMilliseconds = _paragraph.EndTime.TotalMilliseconds; - start = new TimeCode(startMilliseconds); - end = new TimeCode(endMilliseconds); - TypewriterParagraphs.Add(new Paragraph(start, end, _paragraph.Text) { Extra = _paragraph.Extra }); - } - else if (TypewriterParagraphs.Count > 0) - { - TypewriterParagraphs[TypewriterParagraphs.Count - 1].EndTime.TotalMilliseconds = _paragraph.EndTime.TotalMilliseconds; - } - } - - private void Timer1Tick(object sender, EventArgs e) - { - _timerCount += timer1.Interval; - - string s = GetText(_timerCount, TypewriterParagraphs); - ClearPreview(); - AddToPreview(richTextBoxPreview, s); - RefreshPreview(); - - if (_timerCount > _paragraph.EndTime.TotalMilliseconds) - { - timer1.Stop(); - System.Threading.Thread.Sleep(200); - ClearPreview(); - AddToPreview(richTextBoxPreview, _paragraph.Text); - } - } - - private static string GetText(int milliseconds, IEnumerable animation) - { - foreach (Paragraph p in animation) - { - if (p.StartTime.TotalMilliseconds <= milliseconds && - p.EndTime.TotalMilliseconds >= milliseconds) - { - return p.Text; - } - } - return string.Empty; - } - - private void ButtonOkClick(object sender, EventArgs e) - { - MakeAnimation(); - DialogResult = DialogResult.OK; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class EffectTypewriter : Form + { + private Paragraph _paragraph; + private int _timerCount; + + public EffectTypewriter() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.EffectTypewriter.Title; + labelTM.Text = Configuration.Settings.Language.EffectTypewriter.TotalMilliseconds; + labelEndDelay.Text = Configuration.Settings.Language.EffectTypewriter.EndDelayInMilliseconds; + buttonPreview.Text = Configuration.Settings.Language.General.Preview; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + } + + public List TypewriterParagraphs { get; private set; } + + private void FormEffectTypewriter_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + internal void Initialize(Paragraph paragraph) + { + _paragraph = paragraph; + + AddToPreview(richTextBoxPreview, paragraph.Text); + RefreshPreview(); + + labelTotalMilliseconds.Text = $"{paragraph.Duration.TotalMilliseconds / TimeCode.BaseUnit:#,##0.000}"; + numericUpDownDelay.Maximum = (decimal)((paragraph.Duration.TotalMilliseconds - 500) / TimeCode.BaseUnit); + numericUpDownDelay.Minimum = 0; + + numericUpDownDelay.Left = labelEndDelay.Left + labelEndDelay.Width + 5; + } + + private List _colorList; + private List _fontList; + + private void AddToPreview(RichTextBox rtb, string text) + { + richTextBoxPreview.ForeColor = Color.White; + _colorList = new List(); + _fontList = new List(); + + int bold = 0; + int underline = 0; + int italic = 0; + var fontColors = new Stack(); + string currentColor = string.Empty; + + var sb = new StringBuilder(); + int i = 0; + while (i < text.Length) + { + if (text[i] == '<') + { + AddTextToRichTextBox(rtb, bold > 0, italic > 0, underline > 0, currentColor, sb.ToString()); + sb.Clear(); + string tag = GetTag(text.Substring(i).ToLowerInvariant()); + if (i + 1 < text.Length && text[i + 1] == '/') + { + if (tag == "
" && italic > 0) + { + italic--; + } + else if (tag == "" && bold > 0) + { + bold--; + } + else if (tag == "" && underline > 0) + { + underline--; + } + else if (tag == "") + { + currentColor = fontColors.Count > 0 ? fontColors.Pop() : string.Empty; + } + } + else + { + if (tag == "") + { + italic++; + } + else if (tag == "") + { + bold++; + } + else if (tag == "") + { + underline++; + } + else if (tag.StartsWith(" 0) + { + AddTextToRichTextBox(rtb, bold > 0, italic > 0, underline > 0, currentColor, sb.ToString()); + } + + foreach (var fontEntry in _fontList) + { + rtb.SelectionStart = fontEntry.Start; + rtb.SelectionLength = fontEntry.Length; + rtb.SelectionFont = fontEntry.Font; + rtb.DeselectAll(); + } + + foreach (var colorEntry in _colorList) + { + rtb.SelectionStart = colorEntry.Start; + rtb.SelectionLength = colorEntry.Length; + rtb.SelectionColor = colorEntry.Color; + rtb.DeselectAll(); + } + } + + private void AddTextToRichTextBox(RichTextBox rtb, bool bold, bool italic, bool underline, string color, string text) + { + if (text.Length > 0) + { + int length = rtb.Text.Length; + richTextBoxPreview.Text += text; + + var c = Color.White; + if (!string.IsNullOrWhiteSpace(color)) + { + try + { + c = ColorTranslator.FromHtml(color); + } + catch + { + try + { + c = ColorTranslator.FromHtml("#" + color.Trim('#', ' ', '"', '\'')); + } + catch + { + c = Color.White; + } + } + } + + _colorList.Add(new EffectKaraoke.ColorEntry { Start = length, Length = text.Length, Color = c }); + + var fontStyle = new FontStyle(); + if (underline) + { + fontStyle |= FontStyle.Underline; + } + + if (italic) + { + fontStyle |= FontStyle.Italic; + } + + if (bold) + { + fontStyle |= FontStyle.Bold; + } + + _fontList.Add(new EffectKaraoke.FontEntry { Start = length, Length = text.Length, Font = new Font(rtb.Font.FontFamily, rtb.Font.Size, fontStyle) }); + } + } + + private static string GetTag(string text) + { + var sb = new StringBuilder(); + for (int i = 0; i < text.Length; i++) + { + sb.Append(text[i]); + if (text[i] == '>') + { + return sb.ToString(); + } + } + return sb.ToString(); + } + + private void ClearPreview() + { + richTextBoxPreview.Text = string.Empty; + } + + private void RefreshPreview() + { + richTextBoxPreview.SelectAll(); + richTextBoxPreview.SelectionAlignment = HorizontalAlignment.Center; + richTextBoxPreview.Refresh(); + } + + private void ButtonPreviewClick(object sender, EventArgs e) + { + MakeAnimation(); + PlayAnimation(); + } + + private void PlayAnimation() + { + _timerCount = (int)_paragraph.StartTime.TotalMilliseconds; + timer1.Start(); + } + + private static double CalculateStepLength(string text, double duration) + { + if (text.StartsWith("{\\", StringComparison.Ordinal) && text.IndexOf('}') > 2) + { + int i = 0; + while (i < text.Length && + text.Substring(i).StartsWith("{\\", StringComparison.Ordinal) && + text.Substring(i).IndexOf('}', i) > 2) + { + int idx = text.IndexOf('}', i); + i = idx + 1; + } + text = text.Remove(0, i); + } + + text = HtmlUtil.RemoveHtmlTags(text); + return duration / text.Length; + } + + public void MakeAnimation() + { + TypewriterParagraphs = new List(); + double duration = _paragraph.Duration.TotalMilliseconds - (double)numericUpDownDelay.Value * TimeCode.BaseUnit; + double stepsLength = CalculateStepLength(_paragraph.Text, duration); + + double startMilliseconds; + double endMilliseconds; + TimeCode start; + TimeCode end; + int index = 0; + string text = string.Empty; + bool tagOn = false; + string tag = string.Empty; + int i = 0; + string beforeEndTag = string.Empty; + string alignment = string.Empty; + while (i < _paragraph.Text.Length) + { + if (i == 0 && _paragraph.Text.StartsWith("{\\", StringComparison.Ordinal) && _paragraph.Text.IndexOf('}') > 2) + { + int j = i; + while (j < _paragraph.Text.Length && + _paragraph.Text.Substring(j).StartsWith("{\\", StringComparison.Ordinal) && + _paragraph.Text.Substring(j).IndexOf('}', j) > 2) + { + int idx = _paragraph.Text.IndexOf('}', j); + i = idx; + j = i + 1; + } + alignment = _paragraph.Text.Substring(0, j); + } + else if (tagOn) + { + tag += _paragraph.Text[i]; + if (_paragraph.Text[i] == '>') + { + tagOn = false; + if (tag.StartsWith("") + { + beforeEndTag = ""; + } + else if (tag == "") + { + beforeEndTag = ""; + } + else if (tag == "") + { + beforeEndTag = ""; + } + } + } + else if (_paragraph.Text[i] == '<') + { + tagOn = true; + tag += _paragraph.Text[i]; + beforeEndTag = string.Empty; + } + else + { + text += tag + _paragraph.Text[i]; + tag = string.Empty; + + startMilliseconds = index * stepsLength; + startMilliseconds += _paragraph.StartTime.TotalMilliseconds; + endMilliseconds = (index + 1) * stepsLength - 1; + endMilliseconds += _paragraph.StartTime.TotalMilliseconds; + start = new TimeCode(startMilliseconds); + end = new TimeCode(endMilliseconds); + TypewriterParagraphs.Add(new Paragraph(start, end, alignment + text + beforeEndTag) { Extra = _paragraph.Extra }); + index++; + } + i++; + } + + if (numericUpDownDelay.Value > 0) + { + startMilliseconds = index * stepsLength; + startMilliseconds += _paragraph.StartTime.TotalMilliseconds; + endMilliseconds = _paragraph.EndTime.TotalMilliseconds; + start = new TimeCode(startMilliseconds); + end = new TimeCode(endMilliseconds); + TypewriterParagraphs.Add(new Paragraph(start, end, _paragraph.Text) { Extra = _paragraph.Extra }); + } + else if (TypewriterParagraphs.Count > 0) + { + TypewriterParagraphs[TypewriterParagraphs.Count - 1].EndTime.TotalMilliseconds = _paragraph.EndTime.TotalMilliseconds; + } + } + + private void Timer1Tick(object sender, EventArgs e) + { + _timerCount += timer1.Interval; + + string s = GetText(_timerCount, TypewriterParagraphs); + ClearPreview(); + AddToPreview(richTextBoxPreview, s); + RefreshPreview(); + + if (_timerCount > _paragraph.EndTime.TotalMilliseconds) + { + timer1.Stop(); + System.Threading.Thread.Sleep(200); + ClearPreview(); + AddToPreview(richTextBoxPreview, _paragraph.Text); + } + } + + private static string GetText(int milliseconds, IEnumerable animation) + { + foreach (Paragraph p in animation) + { + if (p.StartTime.TotalMilliseconds <= milliseconds && + p.EndTime.TotalMilliseconds >= milliseconds) + { + return p.Text; + } + } + return string.Empty; + } + + private void ButtonOkClick(object sender, EventArgs e) + { + MakeAnimation(); + DialogResult = DialogResult.OK; + } + + } +} diff --git a/src/Forms/EffectTypewriter.resx b/src/ui/Forms/EffectTypewriter.resx similarity index 97% rename from src/Forms/EffectTypewriter.resx rename to src/ui/Forms/EffectTypewriter.resx index 5fce07d17..cde41baac 100644 --- a/src/Forms/EffectTypewriter.resx +++ b/src/ui/Forms/EffectTypewriter.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 130, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 130, 17 + \ No newline at end of file diff --git a/src/Forms/ExportCustomText.Designer.cs b/src/ui/Forms/ExportCustomText.Designer.cs similarity index 98% rename from src/Forms/ExportCustomText.Designer.cs rename to src/ui/Forms/ExportCustomText.Designer.cs index f290d6ace..bd75ae7af 100644 --- a/src/Forms/ExportCustomText.Designer.cs +++ b/src/ui/Forms/ExportCustomText.Designer.cs @@ -1,296 +1,296 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class ExportCustomText - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.listViewTemplates = new System.Windows.Forms.ListView(); - this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); - this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBoxFormats = new System.Windows.Forms.GroupBox(); - this.buttonDelete = new System.Windows.Forms.Button(); - this.buttonEdit = new System.Windows.Forms.Button(); - this.buttonNew = new System.Windows.Forms.Button(); - this.textBoxPreview = new System.Windows.Forms.TextBox(); - this.groupBoxPreview = new System.Windows.Forms.GroupBox(); - this.labelEncoding = new System.Windows.Forms.Label(); - this.comboBoxEncoding = new System.Windows.Forms.ComboBox(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonSave = new System.Windows.Forms.Button(); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.contextMenuStrip1.SuspendLayout(); - this.groupBoxFormats.SuspendLayout(); - this.groupBoxPreview.SuspendLayout(); - this.SuspendLayout(); - // - // listViewTemplates - // - this.listViewTemplates.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewTemplates.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.columnHeader2}); - this.listViewTemplates.ContextMenuStrip = this.contextMenuStrip1; - this.listViewTemplates.FullRowSelect = true; - this.listViewTemplates.HideSelection = false; - this.listViewTemplates.Location = new System.Drawing.Point(6, 23); - this.listViewTemplates.MultiSelect = false; - this.listViewTemplates.Name = "listViewTemplates"; - this.listViewTemplates.Size = new System.Drawing.Size(450, 310); - this.listViewTemplates.TabIndex = 0; - this.listViewTemplates.UseCompatibleStateImageBehavior = false; - this.listViewTemplates.View = System.Windows.Forms.View.Details; - this.listViewTemplates.SelectedIndexChanged += new System.EventHandler(this.listViewTemplates_SelectedIndexChanged); - this.listViewTemplates.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listViewTemplates_MouseDoubleClick); - // - // columnHeader1 - // - this.columnHeader1.Text = "Name"; - this.columnHeader1.Width = 120; - // - // columnHeader2 - // - this.columnHeader2.Text = "Text"; - this.columnHeader2.Width = 326; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.editToolStripMenuItem, - this.deleteToolStripMenuItem, - this.toolStripMenuItem2, - this.newToolStripMenuItem}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(108, 76); - this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); - // - // editToolStripMenuItem - // - this.editToolStripMenuItem.Name = "editToolStripMenuItem"; - this.editToolStripMenuItem.Size = new System.Drawing.Size(107, 22); - this.editToolStripMenuItem.Text = "Edit"; - this.editToolStripMenuItem.Click += new System.EventHandler(this.editToolStripMenuItem_Click); - // - // deleteToolStripMenuItem - // - this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(107, 22); - this.deleteToolStripMenuItem.Text = "Delete"; - this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); - // - // toolStripMenuItem2 - // - this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(104, 6); - // - // newToolStripMenuItem - // - this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.Size = new System.Drawing.Size(107, 22); - this.newToolStripMenuItem.Text = "New"; - this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click); - // - // groupBoxFormats - // - this.groupBoxFormats.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.groupBoxFormats.Controls.Add(this.buttonDelete); - this.groupBoxFormats.Controls.Add(this.buttonEdit); - this.groupBoxFormats.Controls.Add(this.buttonNew); - this.groupBoxFormats.Controls.Add(this.listViewTemplates); - this.groupBoxFormats.Location = new System.Drawing.Point(12, 12); - this.groupBoxFormats.Name = "groupBoxFormats"; - this.groupBoxFormats.Size = new System.Drawing.Size(462, 366); - this.groupBoxFormats.TabIndex = 0; - this.groupBoxFormats.TabStop = false; - this.groupBoxFormats.Text = "Formats"; - // - // buttonDelete - // - this.buttonDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDelete.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonDelete.Location = new System.Drawing.Point(216, 339); - this.buttonDelete.Name = "buttonDelete"; - this.buttonDelete.Size = new System.Drawing.Size(117, 23); - this.buttonDelete.TabIndex = 2; - this.buttonDelete.Text = "Delete"; - this.buttonDelete.UseVisualStyleBackColor = true; - this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click); - // - // buttonEdit - // - this.buttonEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonEdit.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonEdit.Location = new System.Drawing.Point(93, 339); - this.buttonEdit.Name = "buttonEdit"; - this.buttonEdit.Size = new System.Drawing.Size(117, 23); - this.buttonEdit.TabIndex = 1; - this.buttonEdit.Text = "&Edit"; - this.buttonEdit.UseVisualStyleBackColor = true; - this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click); - // - // buttonNew - // - this.buttonNew.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonNew.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonNew.Location = new System.Drawing.Point(339, 339); - this.buttonNew.Name = "buttonNew"; - this.buttonNew.Size = new System.Drawing.Size(117, 23); - this.buttonNew.TabIndex = 3; - this.buttonNew.Text = "&New"; - this.buttonNew.UseVisualStyleBackColor = true; - this.buttonNew.Click += new System.EventHandler(this.buttonNew_Click); - // - // textBoxPreview - // - this.textBoxPreview.Dock = System.Windows.Forms.DockStyle.Fill; - this.textBoxPreview.Location = new System.Drawing.Point(3, 16); - this.textBoxPreview.Multiline = true; - this.textBoxPreview.Name = "textBoxPreview"; - this.textBoxPreview.ReadOnly = true; - this.textBoxPreview.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxPreview.Size = new System.Drawing.Size(445, 346); - this.textBoxPreview.TabIndex = 0; - this.textBoxPreview.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxPreview_KeyDown); - // - // groupBoxPreview - // - this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxPreview.Controls.Add(this.textBoxPreview); - this.groupBoxPreview.Location = new System.Drawing.Point(480, 13); - this.groupBoxPreview.Name = "groupBoxPreview"; - this.groupBoxPreview.Size = new System.Drawing.Size(451, 365); - this.groupBoxPreview.TabIndex = 1; - this.groupBoxPreview.TabStop = false; - this.groupBoxPreview.Text = "Preview"; - // - // labelEncoding - // - this.labelEncoding.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.labelEncoding.AutoSize = true; - this.labelEncoding.Location = new System.Drawing.Point(482, 415); - this.labelEncoding.Name = "labelEncoding"; - this.labelEncoding.Size = new System.Drawing.Size(52, 13); - this.labelEncoding.TabIndex = 2; - this.labelEncoding.Text = "Encoding"; - // - // comboBoxEncoding - // - this.comboBoxEncoding.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxEncoding.FormattingEnabled = true; - this.comboBoxEncoding.Location = new System.Drawing.Point(540, 411); - this.comboBoxEncoding.Name = "comboBoxEncoding"; - this.comboBoxEncoding.Size = new System.Drawing.Size(183, 21); - this.comboBoxEncoding.TabIndex = 3; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(852, 410); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonSave - // - this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSave.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonSave.Location = new System.Drawing.Point(729, 410); - this.buttonSave.Name = "buttonSave"; - this.buttonSave.Size = new System.Drawing.Size(117, 23); - this.buttonSave.TabIndex = 4; - this.buttonSave.Text = "&Save as..."; - this.buttonSave.UseVisualStyleBackColor = true; - this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); - // - // ExportCustomText - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(939, 444); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonSave); - this.Controls.Add(this.labelEncoding); - this.Controls.Add(this.comboBoxEncoding); - this.Controls.Add(this.groupBoxPreview); - this.Controls.Add(this.groupBoxFormats); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(830, 350); - this.Name = "ExportCustomText"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Export custom text format"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExportCustomText_KeyDown); - this.contextMenuStrip1.ResumeLayout(false); - this.groupBoxFormats.ResumeLayout(false); - this.groupBoxPreview.ResumeLayout(false); - this.groupBoxPreview.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ListView listViewTemplates; - private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.ColumnHeader columnHeader2; - private System.Windows.Forms.GroupBox groupBoxFormats; - private System.Windows.Forms.TextBox textBoxPreview; - private System.Windows.Forms.GroupBox groupBoxPreview; - private System.Windows.Forms.Label labelEncoding; - private System.Windows.Forms.ComboBox comboBoxEncoding; - private System.Windows.Forms.Button buttonNew; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonSave; - private System.Windows.Forms.Button buttonEdit; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2; - private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; - private System.Windows.Forms.Button buttonDelete; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class ExportCustomText + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.listViewTemplates = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); + this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBoxFormats = new System.Windows.Forms.GroupBox(); + this.buttonDelete = new System.Windows.Forms.Button(); + this.buttonEdit = new System.Windows.Forms.Button(); + this.buttonNew = new System.Windows.Forms.Button(); + this.textBoxPreview = new System.Windows.Forms.TextBox(); + this.groupBoxPreview = new System.Windows.Forms.GroupBox(); + this.labelEncoding = new System.Windows.Forms.Label(); + this.comboBoxEncoding = new System.Windows.Forms.ComboBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.contextMenuStrip1.SuspendLayout(); + this.groupBoxFormats.SuspendLayout(); + this.groupBoxPreview.SuspendLayout(); + this.SuspendLayout(); + // + // listViewTemplates + // + this.listViewTemplates.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewTemplates.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2}); + this.listViewTemplates.ContextMenuStrip = this.contextMenuStrip1; + this.listViewTemplates.FullRowSelect = true; + this.listViewTemplates.HideSelection = false; + this.listViewTemplates.Location = new System.Drawing.Point(6, 23); + this.listViewTemplates.MultiSelect = false; + this.listViewTemplates.Name = "listViewTemplates"; + this.listViewTemplates.Size = new System.Drawing.Size(450, 310); + this.listViewTemplates.TabIndex = 0; + this.listViewTemplates.UseCompatibleStateImageBehavior = false; + this.listViewTemplates.View = System.Windows.Forms.View.Details; + this.listViewTemplates.SelectedIndexChanged += new System.EventHandler(this.listViewTemplates_SelectedIndexChanged); + this.listViewTemplates.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listViewTemplates_MouseDoubleClick); + // + // columnHeader1 + // + this.columnHeader1.Text = "Name"; + this.columnHeader1.Width = 120; + // + // columnHeader2 + // + this.columnHeader2.Text = "Text"; + this.columnHeader2.Width = 326; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.editToolStripMenuItem, + this.deleteToolStripMenuItem, + this.toolStripMenuItem2, + this.newToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(108, 76); + this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); + // + // editToolStripMenuItem + // + this.editToolStripMenuItem.Name = "editToolStripMenuItem"; + this.editToolStripMenuItem.Size = new System.Drawing.Size(107, 22); + this.editToolStripMenuItem.Text = "Edit"; + this.editToolStripMenuItem.Click += new System.EventHandler(this.editToolStripMenuItem_Click); + // + // deleteToolStripMenuItem + // + this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(107, 22); + this.deleteToolStripMenuItem.Text = "Delete"; + this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); + // + // toolStripMenuItem2 + // + this.toolStripMenuItem2.Name = "toolStripMenuItem2"; + this.toolStripMenuItem2.Size = new System.Drawing.Size(104, 6); + // + // newToolStripMenuItem + // + this.newToolStripMenuItem.Name = "newToolStripMenuItem"; + this.newToolStripMenuItem.Size = new System.Drawing.Size(107, 22); + this.newToolStripMenuItem.Text = "New"; + this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click); + // + // groupBoxFormats + // + this.groupBoxFormats.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.groupBoxFormats.Controls.Add(this.buttonDelete); + this.groupBoxFormats.Controls.Add(this.buttonEdit); + this.groupBoxFormats.Controls.Add(this.buttonNew); + this.groupBoxFormats.Controls.Add(this.listViewTemplates); + this.groupBoxFormats.Location = new System.Drawing.Point(12, 12); + this.groupBoxFormats.Name = "groupBoxFormats"; + this.groupBoxFormats.Size = new System.Drawing.Size(462, 366); + this.groupBoxFormats.TabIndex = 0; + this.groupBoxFormats.TabStop = false; + this.groupBoxFormats.Text = "Formats"; + // + // buttonDelete + // + this.buttonDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDelete.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonDelete.Location = new System.Drawing.Point(216, 339); + this.buttonDelete.Name = "buttonDelete"; + this.buttonDelete.Size = new System.Drawing.Size(117, 23); + this.buttonDelete.TabIndex = 2; + this.buttonDelete.Text = "Delete"; + this.buttonDelete.UseVisualStyleBackColor = true; + this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click); + // + // buttonEdit + // + this.buttonEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonEdit.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonEdit.Location = new System.Drawing.Point(93, 339); + this.buttonEdit.Name = "buttonEdit"; + this.buttonEdit.Size = new System.Drawing.Size(117, 23); + this.buttonEdit.TabIndex = 1; + this.buttonEdit.Text = "&Edit"; + this.buttonEdit.UseVisualStyleBackColor = true; + this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click); + // + // buttonNew + // + this.buttonNew.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonNew.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonNew.Location = new System.Drawing.Point(339, 339); + this.buttonNew.Name = "buttonNew"; + this.buttonNew.Size = new System.Drawing.Size(117, 23); + this.buttonNew.TabIndex = 3; + this.buttonNew.Text = "&New"; + this.buttonNew.UseVisualStyleBackColor = true; + this.buttonNew.Click += new System.EventHandler(this.buttonNew_Click); + // + // textBoxPreview + // + this.textBoxPreview.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBoxPreview.Location = new System.Drawing.Point(3, 16); + this.textBoxPreview.Multiline = true; + this.textBoxPreview.Name = "textBoxPreview"; + this.textBoxPreview.ReadOnly = true; + this.textBoxPreview.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBoxPreview.Size = new System.Drawing.Size(445, 346); + this.textBoxPreview.TabIndex = 0; + this.textBoxPreview.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxPreview_KeyDown); + // + // groupBoxPreview + // + this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxPreview.Controls.Add(this.textBoxPreview); + this.groupBoxPreview.Location = new System.Drawing.Point(480, 13); + this.groupBoxPreview.Name = "groupBoxPreview"; + this.groupBoxPreview.Size = new System.Drawing.Size(451, 365); + this.groupBoxPreview.TabIndex = 1; + this.groupBoxPreview.TabStop = false; + this.groupBoxPreview.Text = "Preview"; + // + // labelEncoding + // + this.labelEncoding.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.labelEncoding.AutoSize = true; + this.labelEncoding.Location = new System.Drawing.Point(482, 415); + this.labelEncoding.Name = "labelEncoding"; + this.labelEncoding.Size = new System.Drawing.Size(52, 13); + this.labelEncoding.TabIndex = 2; + this.labelEncoding.Text = "Encoding"; + // + // comboBoxEncoding + // + this.comboBoxEncoding.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxEncoding.FormattingEnabled = true; + this.comboBoxEncoding.Location = new System.Drawing.Point(540, 411); + this.comboBoxEncoding.Name = "comboBoxEncoding"; + this.comboBoxEncoding.Size = new System.Drawing.Size(183, 21); + this.comboBoxEncoding.TabIndex = 3; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(852, 410); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonSave + // + this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSave.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonSave.Location = new System.Drawing.Point(729, 410); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(117, 23); + this.buttonSave.TabIndex = 4; + this.buttonSave.Text = "&Save as..."; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); + // + // ExportCustomText + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(939, 444); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.labelEncoding); + this.Controls.Add(this.comboBoxEncoding); + this.Controls.Add(this.groupBoxPreview); + this.Controls.Add(this.groupBoxFormats); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(830, 350); + this.Name = "ExportCustomText"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Export custom text format"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExportCustomText_KeyDown); + this.contextMenuStrip1.ResumeLayout(false); + this.groupBoxFormats.ResumeLayout(false); + this.groupBoxPreview.ResumeLayout(false); + this.groupBoxPreview.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ListView listViewTemplates; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.GroupBox groupBoxFormats; + private System.Windows.Forms.TextBox textBoxPreview; + private System.Windows.Forms.GroupBox groupBoxPreview; + private System.Windows.Forms.Label labelEncoding; + private System.Windows.Forms.ComboBox comboBoxEncoding; + private System.Windows.Forms.Button buttonNew; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonSave; + private System.Windows.Forms.Button buttonEdit; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2; + private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; + private System.Windows.Forms.Button buttonDelete; + } } \ No newline at end of file diff --git a/src/Forms/ExportCustomText.cs b/src/ui/Forms/ExportCustomText.cs similarity index 97% rename from src/Forms/ExportCustomText.cs rename to src/ui/Forms/ExportCustomText.cs index 8497c056d..f4d91a7d1 100644 --- a/src/Forms/ExportCustomText.cs +++ b/src/ui/Forms/ExportCustomText.cs @@ -1,391 +1,391 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class ExportCustomText : PositionAndSizeForm - { - private readonly List _templates = new List(); - private readonly Subtitle _subtitle; - private readonly Subtitle _translated; - private readonly string _title; - private bool _batchConvert; - public string LogMessage { get; set; } - public string CurrentFormatName { get; set; } - - public ExportCustomText(Subtitle subtitle, Subtitle original, string title) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - if (original?.Paragraphs == null || original.Paragraphs.Count == 0) - { - _subtitle = subtitle; - } - else - { - _subtitle = original; - _translated = subtitle; - } - _title = title; - - UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding); - - if (string.IsNullOrEmpty(Configuration.Settings.Tools.ExportCustomTemplates)) - { - _templates.Add("SubRipÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]Æ"); - } - else - { - foreach (string template in Configuration.Settings.Tools.ExportCustomTemplates.Split('æ')) - { - _templates.Add(template); - } - } - ShowTemplates(_templates); - - var l = Configuration.Settings.Language.ExportCustomText; - Text = l.Title; - groupBoxFormats.Text = l.Formats; - buttonSave.Text = l.SaveAs; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - groupBoxPreview.Text = Configuration.Settings.Language.General.Preview; - labelEncoding.Text = Configuration.Settings.Language.Main.Controls.FileEncoding; - columnHeader1.Text = Configuration.Settings.Language.General.Name; - columnHeader2.Text = Configuration.Settings.Language.General.Text; - buttonNew.Text = l.New; - buttonEdit.Text = l.Edit; - buttonDelete.Text = l.Delete; - deleteToolStripMenuItem.Text = l.Delete; - editToolStripMenuItem.Text = l.Edit; - newToolStripMenuItem.Text = l.New; - } - - public sealed override string Text - { - get => base.Text; - set => base.Text = value; - } - - private void ShowTemplates(List templates) - { - listViewTemplates.Items.Clear(); - foreach (string s in templates) - { - var arr = s.Split('Æ'); - if (arr.Length == 6) - { - var lvi = new ListViewItem(arr[0]); - lvi.SubItems.Add(arr[2].Replace(Environment.NewLine, "
")); - listViewTemplates.Items.Add(lvi); - } - } - if (listViewTemplates.Items.Count > 0) - { - listViewTemplates.Items[0].Selected = true; - } - } - - private void buttonNew_Click(object sender, EventArgs e) - { - New(); - } - - private bool NameExists(string name) - { - if (string.IsNullOrEmpty(name)) - { - return true; - } - - for (int i = 0; i < _templates.Count; i++) - { - if (_templates[i].StartsWith(name + "Æ", StringComparison.InvariantCulture)) - { - return true; - } - } - return false; - } - - private void New() - { - using (var form = new ExportCustomTextFormat("NewÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]Æ")) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - var arr = form.FormatOk.Split('Æ'); - if (arr.Length == 6) - { - string name = arr[0]; - int i = 1; - while (NameExists(name)) - { - form.FormatOk = form.FormatOk.Remove(0, name.Length); - name = arr[0] + " (" + i + ")"; - form.FormatOk = name + form.FormatOk; - i++; - } - _templates.Add(form.FormatOk); - ShowTemplates(_templates); - listViewTemplates.Items[listViewTemplates.Items.Count - 1].Selected = true; - } - } - } - SaveTemplates(); - } - - private void SaveTemplates() - { - var sb = new StringBuilder(); - foreach (string template in _templates) - { - sb.Append(template + 'æ'); - } - Configuration.Settings.Tools.ExportCustomTemplates = sb.ToString().TrimEnd('æ'); - } - - private void buttonEdit_Click(object sender, EventArgs e) - { - Edit(); - } - - private void Edit() - { - if (listViewTemplates.SelectedItems.Count == 1) - { - int idx = listViewTemplates.SelectedItems[0].Index; - using (var form = new ExportCustomTextFormat(_templates[idx])) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - _templates[idx] = form.FormatOk; - SaveTemplates(); - ShowTemplates(_templates); - if (idx < listViewTemplates.Items.Count) - { - listViewTemplates.Items[idx].Selected = true; - } - } - } - } - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private TextEncoding GetCurrentEncoding() - { - return UiUtil.GetTextEncodingComboBoxCurrentEncoding(comboBoxEncoding); - } - - private void buttonSave_Click(object sender, EventArgs e) - { - if (_batchConvert) - { - if (listViewTemplates.SelectedItems.Count == 1) - { - CurrentFormatName = listViewTemplates.SelectedItems[0].Text; - } - - DialogResult = DialogResult.OK; - return; - } - - saveFileDialog1.Title = Configuration.Settings.Language.ExportCustomText.SaveSubtitleAs; - if (!string.IsNullOrEmpty(_title)) - { - saveFileDialog1.FileName = Path.GetFileNameWithoutExtension(_title) + ".txt"; - } - - saveFileDialog1.Filter = Configuration.Settings.Language.General.AllFiles + "|*.*"; - if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) - { - try - { - FileUtil.WriteAllText(saveFileDialog1.FileName, GenerateText(_subtitle, _translated, _title), GetCurrentEncoding()); - LogMessage = string.Format(Configuration.Settings.Language.ExportCustomText.SubtitleExportedInCustomFormatToX, saveFileDialog1.FileName); - DialogResult = DialogResult.OK; - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - } - } - } - - private string GenerateText(Subtitle subtitle, Subtitle translation, string title) - { - if (listViewTemplates.SelectedItems.Count != 1) - { - return string.Empty; - } - - title = title == null ? string.Empty : Path.GetFileNameWithoutExtension(title); - - try - { - int idx = listViewTemplates.SelectedItems[0].Index; - return GenerateCustomText(subtitle, translation, title, _templates[idx]); - } - catch (Exception exception) - { - return exception.Message; - } - } - - internal static string GenerateCustomText(Subtitle subtitle, Subtitle translation, string title, string templateString) - { - var arr = templateString.Split('Æ'); - var sb = new StringBuilder(); - sb.Append(ExportCustomTextFormat.GetHeaderOrFooter(title, subtitle, arr[1])); - string template = ExportCustomTextFormat.GetParagraphTemplate(arr[2]); - var isXml = arr[1].Contains("", ">") - .Replace("&", "&"); - } - text = ExportCustomTextFormat.GetText(text, arr[4]); - - string translationText = string.Empty; - if (translation?.Paragraphs != null && translation.Paragraphs.Count > 0) - { - var trans = Utilities.GetOriginalParagraph(i, p, translation.Paragraphs); - if (trans != null) - { - translationText = trans.Text; - } - } - string paragraph = ExportCustomTextFormat.GetParagraph(template, start, end, text, translationText, i, p.Actor, p.Duration, arr[3], Utilities.GetCharactersPerSecond(p)); - sb.Append(paragraph); - } - sb.Append(ExportCustomTextFormat.GetHeaderOrFooter(title, subtitle, arr[5])); - return sb.ToString(); - } - - private void listViewTemplates_SelectedIndexChanged(object sender, EventArgs e) - { - textBoxPreview.Text = GenerateText(_subtitle, _translated, _title); - buttonSave.Enabled = listViewTemplates.SelectedItems.Count == 1; - } - - private void deleteToolStripMenuItem_Click(object sender, EventArgs e) - { - Delete(); - } - - private void Delete() - { - if (listViewTemplates.SelectedItems.Count != 1) - { - return; - } - - int idx = listViewTemplates.SelectedItems[0].Index; - for (int i = listViewTemplates.Items.Count - 1; i >= 0; i--) - { - ListViewItem item = listViewTemplates.Items[i]; - if (item.Selected) - { - string name = item.Text; - for (int j = _templates.Count - 1; j > 0; j--) - { - if (_templates[j].StartsWith(name + "Æ", StringComparison.InvariantCultureIgnoreCase)) - { - _templates.RemoveAt(j); - } - } - item.Remove(); - } - } - if (idx >= listViewTemplates.Items.Count) - { - idx--; - } - - if (idx >= 0) - { - listViewTemplates.Items[idx].Selected = true; - } - - SaveTemplates(); - } - - private void ExportCustomText_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void buttonDelete_Click(object sender, EventArgs e) - { - Delete(); - } - - private void editToolStripMenuItem_Click(object sender, EventArgs e) - { - Edit(); - } - - private void newToolStripMenuItem_Click(object sender, EventArgs e) - { - New(); - } - - private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e) - { - bool enableVisibility = listViewTemplates.SelectedItems.Count > 0; - toolStripMenuItem2.Visible = enableVisibility; - editToolStripMenuItem.Visible = enableVisibility; - deleteToolStripMenuItem.Visible = enableVisibility; - } - - private void listViewTemplates_MouseDoubleClick(object sender, MouseEventArgs e) - { - Edit(); - } - - public void InitializeForBatchConvert(string customTextTemplate) - { - _batchConvert = true; - buttonSave.Text = Configuration.Settings.Language.General.Ok; - - for (int index = 0; index < _templates.Count; index++) - { - var item = _templates[index]; - if (item.StartsWith(customTextTemplate + "Æ", StringComparison.Ordinal)) - { - listViewTemplates.Items[index].Selected = true; - } - } - } - - private void textBoxPreview_KeyDown(object sender, KeyEventArgs e) - { - if (e.Control && e.KeyCode == Keys.A) - { - textBoxPreview.SelectAll(); - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class ExportCustomText : PositionAndSizeForm + { + private readonly List _templates = new List(); + private readonly Subtitle _subtitle; + private readonly Subtitle _translated; + private readonly string _title; + private bool _batchConvert; + public string LogMessage { get; set; } + public string CurrentFormatName { get; set; } + + public ExportCustomText(Subtitle subtitle, Subtitle original, string title) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + if (original?.Paragraphs == null || original.Paragraphs.Count == 0) + { + _subtitle = subtitle; + } + else + { + _subtitle = original; + _translated = subtitle; + } + _title = title; + + UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding); + + if (string.IsNullOrEmpty(Configuration.Settings.Tools.ExportCustomTemplates)) + { + _templates.Add("SubRipÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]Æ"); + } + else + { + foreach (string template in Configuration.Settings.Tools.ExportCustomTemplates.Split('æ')) + { + _templates.Add(template); + } + } + ShowTemplates(_templates); + + var l = Configuration.Settings.Language.ExportCustomText; + Text = l.Title; + groupBoxFormats.Text = l.Formats; + buttonSave.Text = l.SaveAs; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + groupBoxPreview.Text = Configuration.Settings.Language.General.Preview; + labelEncoding.Text = Configuration.Settings.Language.Main.Controls.FileEncoding; + columnHeader1.Text = Configuration.Settings.Language.General.Name; + columnHeader2.Text = Configuration.Settings.Language.General.Text; + buttonNew.Text = l.New; + buttonEdit.Text = l.Edit; + buttonDelete.Text = l.Delete; + deleteToolStripMenuItem.Text = l.Delete; + editToolStripMenuItem.Text = l.Edit; + newToolStripMenuItem.Text = l.New; + } + + public sealed override string Text + { + get => base.Text; + set => base.Text = value; + } + + private void ShowTemplates(List templates) + { + listViewTemplates.Items.Clear(); + foreach (string s in templates) + { + var arr = s.Split('Æ'); + if (arr.Length == 6) + { + var lvi = new ListViewItem(arr[0]); + lvi.SubItems.Add(arr[2].Replace(Environment.NewLine, "
")); + listViewTemplates.Items.Add(lvi); + } + } + if (listViewTemplates.Items.Count > 0) + { + listViewTemplates.Items[0].Selected = true; + } + } + + private void buttonNew_Click(object sender, EventArgs e) + { + New(); + } + + private bool NameExists(string name) + { + if (string.IsNullOrEmpty(name)) + { + return true; + } + + for (int i = 0; i < _templates.Count; i++) + { + if (_templates[i].StartsWith(name + "Æ", StringComparison.InvariantCulture)) + { + return true; + } + } + return false; + } + + private void New() + { + using (var form = new ExportCustomTextFormat("NewÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]Æ")) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + var arr = form.FormatOk.Split('Æ'); + if (arr.Length == 6) + { + string name = arr[0]; + int i = 1; + while (NameExists(name)) + { + form.FormatOk = form.FormatOk.Remove(0, name.Length); + name = arr[0] + " (" + i + ")"; + form.FormatOk = name + form.FormatOk; + i++; + } + _templates.Add(form.FormatOk); + ShowTemplates(_templates); + listViewTemplates.Items[listViewTemplates.Items.Count - 1].Selected = true; + } + } + } + SaveTemplates(); + } + + private void SaveTemplates() + { + var sb = new StringBuilder(); + foreach (string template in _templates) + { + sb.Append(template + 'æ'); + } + Configuration.Settings.Tools.ExportCustomTemplates = sb.ToString().TrimEnd('æ'); + } + + private void buttonEdit_Click(object sender, EventArgs e) + { + Edit(); + } + + private void Edit() + { + if (listViewTemplates.SelectedItems.Count == 1) + { + int idx = listViewTemplates.SelectedItems[0].Index; + using (var form = new ExportCustomTextFormat(_templates[idx])) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + _templates[idx] = form.FormatOk; + SaveTemplates(); + ShowTemplates(_templates); + if (idx < listViewTemplates.Items.Count) + { + listViewTemplates.Items[idx].Selected = true; + } + } + } + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private TextEncoding GetCurrentEncoding() + { + return UiUtil.GetTextEncodingComboBoxCurrentEncoding(comboBoxEncoding); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + if (_batchConvert) + { + if (listViewTemplates.SelectedItems.Count == 1) + { + CurrentFormatName = listViewTemplates.SelectedItems[0].Text; + } + + DialogResult = DialogResult.OK; + return; + } + + saveFileDialog1.Title = Configuration.Settings.Language.ExportCustomText.SaveSubtitleAs; + if (!string.IsNullOrEmpty(_title)) + { + saveFileDialog1.FileName = Path.GetFileNameWithoutExtension(_title) + ".txt"; + } + + saveFileDialog1.Filter = Configuration.Settings.Language.General.AllFiles + "|*.*"; + if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) + { + try + { + FileUtil.WriteAllText(saveFileDialog1.FileName, GenerateText(_subtitle, _translated, _title), GetCurrentEncoding()); + LogMessage = string.Format(Configuration.Settings.Language.ExportCustomText.SubtitleExportedInCustomFormatToX, saveFileDialog1.FileName); + DialogResult = DialogResult.OK; + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + } + } + } + + private string GenerateText(Subtitle subtitle, Subtitle translation, string title) + { + if (listViewTemplates.SelectedItems.Count != 1) + { + return string.Empty; + } + + title = title == null ? string.Empty : Path.GetFileNameWithoutExtension(title); + + try + { + int idx = listViewTemplates.SelectedItems[0].Index; + return GenerateCustomText(subtitle, translation, title, _templates[idx]); + } + catch (Exception exception) + { + return exception.Message; + } + } + + internal static string GenerateCustomText(Subtitle subtitle, Subtitle translation, string title, string templateString) + { + var arr = templateString.Split('Æ'); + var sb = new StringBuilder(); + sb.Append(ExportCustomTextFormat.GetHeaderOrFooter(title, subtitle, arr[1])); + string template = ExportCustomTextFormat.GetParagraphTemplate(arr[2]); + var isXml = arr[1].Contains("", ">") + .Replace("&", "&"); + } + text = ExportCustomTextFormat.GetText(text, arr[4]); + + string translationText = string.Empty; + if (translation?.Paragraphs != null && translation.Paragraphs.Count > 0) + { + var trans = Utilities.GetOriginalParagraph(i, p, translation.Paragraphs); + if (trans != null) + { + translationText = trans.Text; + } + } + string paragraph = ExportCustomTextFormat.GetParagraph(template, start, end, text, translationText, i, p.Actor, p.Duration, arr[3], Utilities.GetCharactersPerSecond(p)); + sb.Append(paragraph); + } + sb.Append(ExportCustomTextFormat.GetHeaderOrFooter(title, subtitle, arr[5])); + return sb.ToString(); + } + + private void listViewTemplates_SelectedIndexChanged(object sender, EventArgs e) + { + textBoxPreview.Text = GenerateText(_subtitle, _translated, _title); + buttonSave.Enabled = listViewTemplates.SelectedItems.Count == 1; + } + + private void deleteToolStripMenuItem_Click(object sender, EventArgs e) + { + Delete(); + } + + private void Delete() + { + if (listViewTemplates.SelectedItems.Count != 1) + { + return; + } + + int idx = listViewTemplates.SelectedItems[0].Index; + for (int i = listViewTemplates.Items.Count - 1; i >= 0; i--) + { + ListViewItem item = listViewTemplates.Items[i]; + if (item.Selected) + { + string name = item.Text; + for (int j = _templates.Count - 1; j > 0; j--) + { + if (_templates[j].StartsWith(name + "Æ", StringComparison.InvariantCultureIgnoreCase)) + { + _templates.RemoveAt(j); + } + } + item.Remove(); + } + } + if (idx >= listViewTemplates.Items.Count) + { + idx--; + } + + if (idx >= 0) + { + listViewTemplates.Items[idx].Selected = true; + } + + SaveTemplates(); + } + + private void ExportCustomText_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void buttonDelete_Click(object sender, EventArgs e) + { + Delete(); + } + + private void editToolStripMenuItem_Click(object sender, EventArgs e) + { + Edit(); + } + + private void newToolStripMenuItem_Click(object sender, EventArgs e) + { + New(); + } + + private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e) + { + bool enableVisibility = listViewTemplates.SelectedItems.Count > 0; + toolStripMenuItem2.Visible = enableVisibility; + editToolStripMenuItem.Visible = enableVisibility; + deleteToolStripMenuItem.Visible = enableVisibility; + } + + private void listViewTemplates_MouseDoubleClick(object sender, MouseEventArgs e) + { + Edit(); + } + + public void InitializeForBatchConvert(string customTextTemplate) + { + _batchConvert = true; + buttonSave.Text = Configuration.Settings.Language.General.Ok; + + for (int index = 0; index < _templates.Count; index++) + { + var item = _templates[index]; + if (item.StartsWith(customTextTemplate + "Æ", StringComparison.Ordinal)) + { + listViewTemplates.Items[index].Selected = true; + } + } + } + + private void textBoxPreview_KeyDown(object sender, KeyEventArgs e) + { + if (e.Control && e.KeyCode == Keys.A) + { + textBoxPreview.SelectAll(); + } + } + } +} diff --git a/src/Forms/ExportCustomText.resx b/src/ui/Forms/ExportCustomText.resx similarity index 97% rename from src/Forms/ExportCustomText.resx rename to src/ui/Forms/ExportCustomText.resx index f36ef2556..84c4692cc 100644 --- a/src/Forms/ExportCustomText.resx +++ b/src/ui/Forms/ExportCustomText.resx @@ -1,126 +1,126 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 153, 17 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 153, 17 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/ExportCustomTextFormat.Designer.cs b/src/ui/Forms/ExportCustomTextFormat.Designer.cs similarity index 98% rename from src/Forms/ExportCustomTextFormat.Designer.cs rename to src/ui/Forms/ExportCustomTextFormat.Designer.cs index f6a51a434..dc00d61a2 100644 --- a/src/Forms/ExportCustomTextFormat.Designer.cs +++ b/src/ui/Forms/ExportCustomTextFormat.Designer.cs @@ -1,522 +1,522 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ExportCustomTextFormat - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.groupBoxTemplate = new System.Windows.Forms.GroupBox(); - this.textBoxName = new System.Windows.Forms.TextBox(); - this.labelName = new System.Windows.Forms.Label(); - this.comboBoxNewLine = new System.Windows.Forms.ComboBox(); - this.comboBoxTimeCode = new System.Windows.Forms.ComboBox(); - this.labelNewLine = new System.Windows.Forms.Label(); - this.labelTimeCode = new System.Windows.Forms.Label(); - this.textBoxFooter = new System.Windows.Forms.TextBox(); - this.contextMenuStripFooter = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem(); - this.labelFooter = new System.Windows.Forms.Label(); - this.labelTextLine = new System.Windows.Forms.Label(); - this.textBoxParagraph = new System.Windows.Forms.TextBox(); - this.contextMenuStripParagraph = new System.Windows.Forms.ContextMenuStrip(this.components); - this.insertHHMMSSMSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.insertendToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.insertnumberToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.insertdurationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.textToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.translationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemActor = new System.Windows.Forms.ToolStripMenuItem(); - this.tabToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.textToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.textline2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.labelHeader = new System.Windows.Forms.Label(); - this.textBoxHeader = new System.Windows.Forms.TextBox(); - this.contextMenuStripHeader = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripMenuItem(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxPreview = new System.Windows.Forms.GroupBox(); - this.textBoxPreview = new System.Windows.Forms.TextBox(); - this.cpsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.textlengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.cpsperiodToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBoxTemplate.SuspendLayout(); - this.contextMenuStripFooter.SuspendLayout(); - this.contextMenuStripParagraph.SuspendLayout(); - this.contextMenuStripHeader.SuspendLayout(); - this.groupBoxPreview.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxTemplate - // - this.groupBoxTemplate.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.groupBoxTemplate.Controls.Add(this.textBoxName); - this.groupBoxTemplate.Controls.Add(this.labelName); - this.groupBoxTemplate.Controls.Add(this.comboBoxNewLine); - this.groupBoxTemplate.Controls.Add(this.comboBoxTimeCode); - this.groupBoxTemplate.Controls.Add(this.labelNewLine); - this.groupBoxTemplate.Controls.Add(this.labelTimeCode); - this.groupBoxTemplate.Controls.Add(this.textBoxFooter); - this.groupBoxTemplate.Controls.Add(this.labelFooter); - this.groupBoxTemplate.Controls.Add(this.labelTextLine); - this.groupBoxTemplate.Controls.Add(this.textBoxParagraph); - this.groupBoxTemplate.Controls.Add(this.labelHeader); - this.groupBoxTemplate.Controls.Add(this.textBoxHeader); - this.groupBoxTemplate.Location = new System.Drawing.Point(12, 12); - this.groupBoxTemplate.Name = "groupBoxTemplate"; - this.groupBoxTemplate.Size = new System.Drawing.Size(346, 393); - this.groupBoxTemplate.TabIndex = 0; - this.groupBoxTemplate.TabStop = false; - this.groupBoxTemplate.Text = "Current template"; - // - // textBoxName - // - this.textBoxName.Location = new System.Drawing.Point(49, 30); - this.textBoxName.Name = "textBoxName"; - this.textBoxName.Size = new System.Drawing.Size(291, 20); - this.textBoxName.TabIndex = 1; - // - // labelName - // - this.labelName.AutoSize = true; - this.labelName.Location = new System.Drawing.Point(8, 33); - this.labelName.Name = "labelName"; - this.labelName.Size = new System.Drawing.Size(35, 13); - this.labelName.TabIndex = 0; - this.labelName.Text = "Name"; - // - // comboBoxNewLine - // - this.comboBoxNewLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.comboBoxNewLine.FormattingEnabled = true; - this.comboBoxNewLine.Items.AddRange(new object[] { - "[Do not modify]", - "||", - "[Only newline (hex char 0xd)]"}); - this.comboBoxNewLine.Location = new System.Drawing.Point(241, 266); - this.comboBoxNewLine.Name = "comboBoxNewLine"; - this.comboBoxNewLine.Size = new System.Drawing.Size(99, 21); - this.comboBoxNewLine.TabIndex = 9; - this.comboBoxNewLine.SelectedIndexChanged += new System.EventHandler(this.comboBoxNewLine_SelectedIndexChanged); - this.comboBoxNewLine.TextChanged += new System.EventHandler(this.comboBoxNewLine_TextChanged); - // - // comboBoxTimeCode - // - this.comboBoxTimeCode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.comboBoxTimeCode.FormattingEnabled = true; - this.comboBoxTimeCode.Items.AddRange(new object[] { - "hh:mm:ss,zzz", - "hh:mm:ss.ff", - "h:mm:ss,zzz", - "h:mm:ss,zz", - "ff", - "zzz", - "ss"}); - this.comboBoxTimeCode.Location = new System.Drawing.Point(69, 266); - this.comboBoxTimeCode.Name = "comboBoxTimeCode"; - this.comboBoxTimeCode.Size = new System.Drawing.Size(92, 21); - this.comboBoxTimeCode.TabIndex = 7; - this.comboBoxTimeCode.SelectedIndexChanged += new System.EventHandler(this.comboBoxTimeCode_SelectedIndexChanged); - this.comboBoxTimeCode.TextChanged += new System.EventHandler(this.comboBoxTimeCode_TextChanged); - // - // labelNewLine - // - this.labelNewLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelNewLine.AutoSize = true; - this.labelNewLine.Location = new System.Drawing.Point(185, 267); - this.labelNewLine.Name = "labelNewLine"; - this.labelNewLine.Size = new System.Drawing.Size(48, 13); - this.labelNewLine.TabIndex = 8; - this.labelNewLine.Text = "New line"; - // - // labelTimeCode - // - this.labelTimeCode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelTimeCode.AutoSize = true; - this.labelTimeCode.Location = new System.Drawing.Point(6, 267); - this.labelTimeCode.Name = "labelTimeCode"; - this.labelTimeCode.Size = new System.Drawing.Size(57, 13); - this.labelTimeCode.TabIndex = 6; - this.labelTimeCode.Text = "Time code"; - // - // textBoxFooter - // - this.textBoxFooter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.textBoxFooter.ContextMenuStrip = this.contextMenuStripFooter; - this.textBoxFooter.Location = new System.Drawing.Point(6, 313); - this.textBoxFooter.Multiline = true; - this.textBoxFooter.Name = "textBoxFooter"; - this.textBoxFooter.Size = new System.Drawing.Size(334, 70); - this.textBoxFooter.TabIndex = 11; - this.textBoxFooter.TextChanged += new System.EventHandler(this.TextBoxParagraphTextChanged); - // - // contextMenuStripFooter - // - this.contextMenuStripFooter.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItem3, - this.toolStripMenuItem4, - this.toolStripMenuItem5}); - this.contextMenuStripFooter.Name = "contextMenuStrip1"; - this.contextMenuStripFooter.Size = new System.Drawing.Size(114, 70); - // - // toolStripMenuItem3 - // - this.toolStripMenuItem3.Name = "toolStripMenuItem3"; - this.toolStripMenuItem3.Size = new System.Drawing.Size(113, 22); - this.toolStripMenuItem3.Text = "{title}"; - this.toolStripMenuItem3.Click += new System.EventHandler(this.InsertTagFooter); - // - // toolStripMenuItem4 - // - this.toolStripMenuItem4.Name = "toolStripMenuItem4"; - this.toolStripMenuItem4.Size = new System.Drawing.Size(113, 22); - this.toolStripMenuItem4.Text = "{#lines}"; - this.toolStripMenuItem4.Click += new System.EventHandler(this.InsertTagFooter); - // - // toolStripMenuItem5 - // - this.toolStripMenuItem5.Name = "toolStripMenuItem5"; - this.toolStripMenuItem5.Size = new System.Drawing.Size(113, 22); - this.toolStripMenuItem5.Text = "{tab}"; - this.toolStripMenuItem5.Click += new System.EventHandler(this.InsertTagFooter); - // - // labelFooter - // - this.labelFooter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelFooter.AutoSize = true; - this.labelFooter.Location = new System.Drawing.Point(6, 297); - this.labelFooter.Name = "labelFooter"; - this.labelFooter.Size = new System.Drawing.Size(37, 13); - this.labelFooter.TabIndex = 10; - this.labelFooter.Text = "Footer"; - // - // labelTextLine - // - this.labelTextLine.AutoSize = true; - this.labelTextLine.Location = new System.Drawing.Point(6, 159); - this.labelTextLine.Name = "labelTextLine"; - this.labelTextLine.Size = new System.Drawing.Size(104, 13); - this.labelTextLine.TabIndex = 4; - this.labelTextLine.Text = "Text line (paragraph)"; - // - // textBoxParagraph - // - this.textBoxParagraph.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.textBoxParagraph.ContextMenuStrip = this.contextMenuStripParagraph; - this.textBoxParagraph.Location = new System.Drawing.Point(6, 175); - this.textBoxParagraph.Multiline = true; - this.textBoxParagraph.Name = "textBoxParagraph"; - this.textBoxParagraph.Size = new System.Drawing.Size(334, 85); - this.textBoxParagraph.TabIndex = 5; - this.textBoxParagraph.Text = "{number}\r\n{start} --> {end}\r\n{text}\r\n\r\n"; - this.textBoxParagraph.TextChanged += new System.EventHandler(this.TextBoxParagraphTextChanged); - // - // contextMenuStripParagraph - // - this.contextMenuStripParagraph.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.insertHHMMSSMSToolStripMenuItem, - this.insertendToolStripMenuItem, - this.insertnumberToolStripMenuItem, - this.insertdurationToolStripMenuItem, - this.textToolStripMenuItem, - this.translationToolStripMenuItem, - this.toolStripMenuItemActor, - this.tabToolStripMenuItem, - this.textToolStripMenuItem1, - this.textline2ToolStripMenuItem, - this.cpsperiodToolStripMenuItem, - this.cpsToolStripMenuItem, - this.textlengthToolStripMenuItem}); - this.contextMenuStripParagraph.Name = "contextMenuStrip1"; - this.contextMenuStripParagraph.Size = new System.Drawing.Size(147, 290); - // - // insertHHMMSSMSToolStripMenuItem - // - this.insertHHMMSSMSToolStripMenuItem.Name = "insertHHMMSSMSToolStripMenuItem"; - this.insertHHMMSSMSToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.insertHHMMSSMSToolStripMenuItem.Text = "{start}"; - this.insertHHMMSSMSToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); - // - // insertendToolStripMenuItem - // - this.insertendToolStripMenuItem.Name = "insertendToolStripMenuItem"; - this.insertendToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.insertendToolStripMenuItem.Text = "{end}"; - this.insertendToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); - // - // insertnumberToolStripMenuItem - // - this.insertnumberToolStripMenuItem.Name = "insertnumberToolStripMenuItem"; - this.insertnumberToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.insertnumberToolStripMenuItem.Text = "{number}"; - this.insertnumberToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); - // - // insertdurationToolStripMenuItem - // - this.insertdurationToolStripMenuItem.Name = "insertdurationToolStripMenuItem"; - this.insertdurationToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.insertdurationToolStripMenuItem.Text = "{duration}"; - this.insertdurationToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); - // - // textToolStripMenuItem - // - this.textToolStripMenuItem.Name = "textToolStripMenuItem"; - this.textToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.textToolStripMenuItem.Text = "{text}"; - this.textToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); - // - // translationToolStripMenuItem - // - this.translationToolStripMenuItem.Name = "translationToolStripMenuItem"; - this.translationToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.translationToolStripMenuItem.Text = "{translation}"; - this.translationToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); - // - // toolStripMenuItemActor - // - this.toolStripMenuItemActor.Name = "toolStripMenuItemActor"; - this.toolStripMenuItemActor.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemActor.Text = "{actor}"; - this.toolStripMenuItemActor.Click += new System.EventHandler(this.InsertTag); - // - // tabToolStripMenuItem - // - this.tabToolStripMenuItem.Name = "tabToolStripMenuItem"; - this.tabToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.tabToolStripMenuItem.Text = "{tab}"; - this.tabToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); - // - // textToolStripMenuItem1 - // - this.textToolStripMenuItem1.Name = "textToolStripMenuItem1"; - this.textToolStripMenuItem1.Size = new System.Drawing.Size(180, 22); - this.textToolStripMenuItem1.Text = "{text-line-1}"; - this.textToolStripMenuItem1.Click += new System.EventHandler(this.InsertTag); - // - // textline2ToolStripMenuItem - // - this.textline2ToolStripMenuItem.Name = "textline2ToolStripMenuItem"; - this.textline2ToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.textline2ToolStripMenuItem.Text = "{text-line-2}"; - this.textline2ToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); - // - // labelHeader - // - this.labelHeader.AutoSize = true; - this.labelHeader.Location = new System.Drawing.Point(6, 64); - this.labelHeader.Name = "labelHeader"; - this.labelHeader.Size = new System.Drawing.Size(42, 13); - this.labelHeader.TabIndex = 2; - this.labelHeader.Text = "Header"; - // - // textBoxHeader - // - this.textBoxHeader.ContextMenuStrip = this.contextMenuStripHeader; - this.textBoxHeader.Location = new System.Drawing.Point(6, 80); - this.textBoxHeader.Multiline = true; - this.textBoxHeader.Name = "textBoxHeader"; - this.textBoxHeader.Size = new System.Drawing.Size(334, 64); - this.textBoxHeader.TabIndex = 3; - this.textBoxHeader.TextChanged += new System.EventHandler(this.TextBoxParagraphTextChanged); - // - // contextMenuStripHeader - // - this.contextMenuStripHeader.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItem1, - this.toolStripMenuItem2, - this.toolStripMenuItem7}); - this.contextMenuStripHeader.Name = "contextMenuStrip1"; - this.contextMenuStripHeader.Size = new System.Drawing.Size(114, 70); - // - // toolStripMenuItem1 - // - this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(113, 22); - this.toolStripMenuItem1.Text = "{title}"; - this.toolStripMenuItem1.Click += new System.EventHandler(this.InsertTagHeader); - // - // toolStripMenuItem2 - // - this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(113, 22); - this.toolStripMenuItem2.Text = "{#lines}"; - this.toolStripMenuItem2.Click += new System.EventHandler(this.InsertTagHeader); - // - // toolStripMenuItem7 - // - this.toolStripMenuItem7.Name = "toolStripMenuItem7"; - this.toolStripMenuItem7.Size = new System.Drawing.Size(113, 22); - this.toolStripMenuItem7.Text = "{tab}"; - this.toolStripMenuItem7.Click += new System.EventHandler(this.InsertTagHeader); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(628, 412); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 3; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(547, 412); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 2; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // groupBoxPreview - // - this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxPreview.Controls.Add(this.textBoxPreview); - this.groupBoxPreview.Location = new System.Drawing.Point(364, 12); - this.groupBoxPreview.Name = "groupBoxPreview"; - this.groupBoxPreview.Size = new System.Drawing.Size(346, 393); - this.groupBoxPreview.TabIndex = 1; - this.groupBoxPreview.TabStop = false; - this.groupBoxPreview.Text = "Preview"; - // - // textBoxPreview - // - this.textBoxPreview.Dock = System.Windows.Forms.DockStyle.Fill; - this.textBoxPreview.Location = new System.Drawing.Point(3, 16); - this.textBoxPreview.Multiline = true; - this.textBoxPreview.Name = "textBoxPreview"; - this.textBoxPreview.ReadOnly = true; - this.textBoxPreview.Size = new System.Drawing.Size(340, 374); - this.textBoxPreview.TabIndex = 0; - // - // cpsToolStripMenuItem - // - this.cpsToolStripMenuItem.Name = "cpsToolStripMenuItem"; - this.cpsToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.cpsToolStripMenuItem.Text = "{cps-comma}"; - this.cpsToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); - // - // textlengthToolStripMenuItem - // - this.textlengthToolStripMenuItem.Name = "textlengthToolStripMenuItem"; - this.textlengthToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.textlengthToolStripMenuItem.Text = "{text-length}"; - this.textlengthToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); - // - // cpsperiodToolStripMenuItem - // - this.cpsperiodToolStripMenuItem.Name = "cpsperiodToolStripMenuItem"; - this.cpsperiodToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.cpsperiodToolStripMenuItem.Text = "{cps-period}"; - this.cpsperiodToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); - // - // ExportCustomTextFormat - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(715, 445); - this.Controls.Add(this.groupBoxPreview); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.groupBoxTemplate); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(600, 450); - this.Name = "ExportCustomTextFormat"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Custom text format"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExportCustomTextFormatKeyDown); - this.groupBoxTemplate.ResumeLayout(false); - this.groupBoxTemplate.PerformLayout(); - this.contextMenuStripFooter.ResumeLayout(false); - this.contextMenuStripParagraph.ResumeLayout(false); - this.contextMenuStripHeader.ResumeLayout(false); - this.groupBoxPreview.ResumeLayout(false); - this.groupBoxPreview.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxTemplate; - private System.Windows.Forms.Label labelHeader; - private System.Windows.Forms.TextBox textBoxHeader; - private System.Windows.Forms.Label labelFooter; - private System.Windows.Forms.Label labelTextLine; - private System.Windows.Forms.TextBox textBoxParagraph; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.TextBox textBoxFooter; - private System.Windows.Forms.ContextMenuStrip contextMenuStripParagraph; - private System.Windows.Forms.ToolStripMenuItem insertHHMMSSMSToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem insertendToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem insertnumberToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem insertdurationToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem textToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem tabToolStripMenuItem; - private System.Windows.Forms.ComboBox comboBoxNewLine; - private System.Windows.Forms.ComboBox comboBoxTimeCode; - private System.Windows.Forms.Label labelNewLine; - private System.Windows.Forms.Label labelTimeCode; - private System.Windows.Forms.GroupBox groupBoxPreview; - private System.Windows.Forms.TextBox textBoxPreview; - private System.Windows.Forms.TextBox textBoxName; - private System.Windows.Forms.Label labelName; - private System.Windows.Forms.ToolStripMenuItem translationToolStripMenuItem; - private System.Windows.Forms.ContextMenuStrip contextMenuStripHeader; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem7; - private System.Windows.Forms.ContextMenuStrip contextMenuStripFooter; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemActor; - private System.Windows.Forms.ToolStripMenuItem textToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem textline2ToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem cpsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem textlengthToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem cpsperiodToolStripMenuItem; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ExportCustomTextFormat + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.groupBoxTemplate = new System.Windows.Forms.GroupBox(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.labelName = new System.Windows.Forms.Label(); + this.comboBoxNewLine = new System.Windows.Forms.ComboBox(); + this.comboBoxTimeCode = new System.Windows.Forms.ComboBox(); + this.labelNewLine = new System.Windows.Forms.Label(); + this.labelTimeCode = new System.Windows.Forms.Label(); + this.textBoxFooter = new System.Windows.Forms.TextBox(); + this.contextMenuStripFooter = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem(); + this.labelFooter = new System.Windows.Forms.Label(); + this.labelTextLine = new System.Windows.Forms.Label(); + this.textBoxParagraph = new System.Windows.Forms.TextBox(); + this.contextMenuStripParagraph = new System.Windows.Forms.ContextMenuStrip(this.components); + this.insertHHMMSSMSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.insertendToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.insertnumberToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.insertdurationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.textToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.translationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemActor = new System.Windows.Forms.ToolStripMenuItem(); + this.tabToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.textToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.textline2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.labelHeader = new System.Windows.Forms.Label(); + this.textBoxHeader = new System.Windows.Forms.TextBox(); + this.contextMenuStripHeader = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripMenuItem(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxPreview = new System.Windows.Forms.GroupBox(); + this.textBoxPreview = new System.Windows.Forms.TextBox(); + this.cpsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.textlengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.cpsperiodToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBoxTemplate.SuspendLayout(); + this.contextMenuStripFooter.SuspendLayout(); + this.contextMenuStripParagraph.SuspendLayout(); + this.contextMenuStripHeader.SuspendLayout(); + this.groupBoxPreview.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxTemplate + // + this.groupBoxTemplate.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.groupBoxTemplate.Controls.Add(this.textBoxName); + this.groupBoxTemplate.Controls.Add(this.labelName); + this.groupBoxTemplate.Controls.Add(this.comboBoxNewLine); + this.groupBoxTemplate.Controls.Add(this.comboBoxTimeCode); + this.groupBoxTemplate.Controls.Add(this.labelNewLine); + this.groupBoxTemplate.Controls.Add(this.labelTimeCode); + this.groupBoxTemplate.Controls.Add(this.textBoxFooter); + this.groupBoxTemplate.Controls.Add(this.labelFooter); + this.groupBoxTemplate.Controls.Add(this.labelTextLine); + this.groupBoxTemplate.Controls.Add(this.textBoxParagraph); + this.groupBoxTemplate.Controls.Add(this.labelHeader); + this.groupBoxTemplate.Controls.Add(this.textBoxHeader); + this.groupBoxTemplate.Location = new System.Drawing.Point(12, 12); + this.groupBoxTemplate.Name = "groupBoxTemplate"; + this.groupBoxTemplate.Size = new System.Drawing.Size(346, 393); + this.groupBoxTemplate.TabIndex = 0; + this.groupBoxTemplate.TabStop = false; + this.groupBoxTemplate.Text = "Current template"; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(49, 30); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(291, 20); + this.textBoxName.TabIndex = 1; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(8, 33); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(35, 13); + this.labelName.TabIndex = 0; + this.labelName.Text = "Name"; + // + // comboBoxNewLine + // + this.comboBoxNewLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.comboBoxNewLine.FormattingEnabled = true; + this.comboBoxNewLine.Items.AddRange(new object[] { + "[Do not modify]", + "||", + "[Only newline (hex char 0xd)]"}); + this.comboBoxNewLine.Location = new System.Drawing.Point(241, 266); + this.comboBoxNewLine.Name = "comboBoxNewLine"; + this.comboBoxNewLine.Size = new System.Drawing.Size(99, 21); + this.comboBoxNewLine.TabIndex = 9; + this.comboBoxNewLine.SelectedIndexChanged += new System.EventHandler(this.comboBoxNewLine_SelectedIndexChanged); + this.comboBoxNewLine.TextChanged += new System.EventHandler(this.comboBoxNewLine_TextChanged); + // + // comboBoxTimeCode + // + this.comboBoxTimeCode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.comboBoxTimeCode.FormattingEnabled = true; + this.comboBoxTimeCode.Items.AddRange(new object[] { + "hh:mm:ss,zzz", + "hh:mm:ss.ff", + "h:mm:ss,zzz", + "h:mm:ss,zz", + "ff", + "zzz", + "ss"}); + this.comboBoxTimeCode.Location = new System.Drawing.Point(69, 266); + this.comboBoxTimeCode.Name = "comboBoxTimeCode"; + this.comboBoxTimeCode.Size = new System.Drawing.Size(92, 21); + this.comboBoxTimeCode.TabIndex = 7; + this.comboBoxTimeCode.SelectedIndexChanged += new System.EventHandler(this.comboBoxTimeCode_SelectedIndexChanged); + this.comboBoxTimeCode.TextChanged += new System.EventHandler(this.comboBoxTimeCode_TextChanged); + // + // labelNewLine + // + this.labelNewLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelNewLine.AutoSize = true; + this.labelNewLine.Location = new System.Drawing.Point(185, 267); + this.labelNewLine.Name = "labelNewLine"; + this.labelNewLine.Size = new System.Drawing.Size(48, 13); + this.labelNewLine.TabIndex = 8; + this.labelNewLine.Text = "New line"; + // + // labelTimeCode + // + this.labelTimeCode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelTimeCode.AutoSize = true; + this.labelTimeCode.Location = new System.Drawing.Point(6, 267); + this.labelTimeCode.Name = "labelTimeCode"; + this.labelTimeCode.Size = new System.Drawing.Size(57, 13); + this.labelTimeCode.TabIndex = 6; + this.labelTimeCode.Text = "Time code"; + // + // textBoxFooter + // + this.textBoxFooter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.textBoxFooter.ContextMenuStrip = this.contextMenuStripFooter; + this.textBoxFooter.Location = new System.Drawing.Point(6, 313); + this.textBoxFooter.Multiline = true; + this.textBoxFooter.Name = "textBoxFooter"; + this.textBoxFooter.Size = new System.Drawing.Size(334, 70); + this.textBoxFooter.TabIndex = 11; + this.textBoxFooter.TextChanged += new System.EventHandler(this.TextBoxParagraphTextChanged); + // + // contextMenuStripFooter + // + this.contextMenuStripFooter.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItem3, + this.toolStripMenuItem4, + this.toolStripMenuItem5}); + this.contextMenuStripFooter.Name = "contextMenuStrip1"; + this.contextMenuStripFooter.Size = new System.Drawing.Size(114, 70); + // + // toolStripMenuItem3 + // + this.toolStripMenuItem3.Name = "toolStripMenuItem3"; + this.toolStripMenuItem3.Size = new System.Drawing.Size(113, 22); + this.toolStripMenuItem3.Text = "{title}"; + this.toolStripMenuItem3.Click += new System.EventHandler(this.InsertTagFooter); + // + // toolStripMenuItem4 + // + this.toolStripMenuItem4.Name = "toolStripMenuItem4"; + this.toolStripMenuItem4.Size = new System.Drawing.Size(113, 22); + this.toolStripMenuItem4.Text = "{#lines}"; + this.toolStripMenuItem4.Click += new System.EventHandler(this.InsertTagFooter); + // + // toolStripMenuItem5 + // + this.toolStripMenuItem5.Name = "toolStripMenuItem5"; + this.toolStripMenuItem5.Size = new System.Drawing.Size(113, 22); + this.toolStripMenuItem5.Text = "{tab}"; + this.toolStripMenuItem5.Click += new System.EventHandler(this.InsertTagFooter); + // + // labelFooter + // + this.labelFooter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelFooter.AutoSize = true; + this.labelFooter.Location = new System.Drawing.Point(6, 297); + this.labelFooter.Name = "labelFooter"; + this.labelFooter.Size = new System.Drawing.Size(37, 13); + this.labelFooter.TabIndex = 10; + this.labelFooter.Text = "Footer"; + // + // labelTextLine + // + this.labelTextLine.AutoSize = true; + this.labelTextLine.Location = new System.Drawing.Point(6, 159); + this.labelTextLine.Name = "labelTextLine"; + this.labelTextLine.Size = new System.Drawing.Size(104, 13); + this.labelTextLine.TabIndex = 4; + this.labelTextLine.Text = "Text line (paragraph)"; + // + // textBoxParagraph + // + this.textBoxParagraph.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.textBoxParagraph.ContextMenuStrip = this.contextMenuStripParagraph; + this.textBoxParagraph.Location = new System.Drawing.Point(6, 175); + this.textBoxParagraph.Multiline = true; + this.textBoxParagraph.Name = "textBoxParagraph"; + this.textBoxParagraph.Size = new System.Drawing.Size(334, 85); + this.textBoxParagraph.TabIndex = 5; + this.textBoxParagraph.Text = "{number}\r\n{start} --> {end}\r\n{text}\r\n\r\n"; + this.textBoxParagraph.TextChanged += new System.EventHandler(this.TextBoxParagraphTextChanged); + // + // contextMenuStripParagraph + // + this.contextMenuStripParagraph.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.insertHHMMSSMSToolStripMenuItem, + this.insertendToolStripMenuItem, + this.insertnumberToolStripMenuItem, + this.insertdurationToolStripMenuItem, + this.textToolStripMenuItem, + this.translationToolStripMenuItem, + this.toolStripMenuItemActor, + this.tabToolStripMenuItem, + this.textToolStripMenuItem1, + this.textline2ToolStripMenuItem, + this.cpsperiodToolStripMenuItem, + this.cpsToolStripMenuItem, + this.textlengthToolStripMenuItem}); + this.contextMenuStripParagraph.Name = "contextMenuStrip1"; + this.contextMenuStripParagraph.Size = new System.Drawing.Size(147, 290); + // + // insertHHMMSSMSToolStripMenuItem + // + this.insertHHMMSSMSToolStripMenuItem.Name = "insertHHMMSSMSToolStripMenuItem"; + this.insertHHMMSSMSToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.insertHHMMSSMSToolStripMenuItem.Text = "{start}"; + this.insertHHMMSSMSToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); + // + // insertendToolStripMenuItem + // + this.insertendToolStripMenuItem.Name = "insertendToolStripMenuItem"; + this.insertendToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.insertendToolStripMenuItem.Text = "{end}"; + this.insertendToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); + // + // insertnumberToolStripMenuItem + // + this.insertnumberToolStripMenuItem.Name = "insertnumberToolStripMenuItem"; + this.insertnumberToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.insertnumberToolStripMenuItem.Text = "{number}"; + this.insertnumberToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); + // + // insertdurationToolStripMenuItem + // + this.insertdurationToolStripMenuItem.Name = "insertdurationToolStripMenuItem"; + this.insertdurationToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.insertdurationToolStripMenuItem.Text = "{duration}"; + this.insertdurationToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); + // + // textToolStripMenuItem + // + this.textToolStripMenuItem.Name = "textToolStripMenuItem"; + this.textToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.textToolStripMenuItem.Text = "{text}"; + this.textToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); + // + // translationToolStripMenuItem + // + this.translationToolStripMenuItem.Name = "translationToolStripMenuItem"; + this.translationToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.translationToolStripMenuItem.Text = "{translation}"; + this.translationToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); + // + // toolStripMenuItemActor + // + this.toolStripMenuItemActor.Name = "toolStripMenuItemActor"; + this.toolStripMenuItemActor.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemActor.Text = "{actor}"; + this.toolStripMenuItemActor.Click += new System.EventHandler(this.InsertTag); + // + // tabToolStripMenuItem + // + this.tabToolStripMenuItem.Name = "tabToolStripMenuItem"; + this.tabToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.tabToolStripMenuItem.Text = "{tab}"; + this.tabToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); + // + // textToolStripMenuItem1 + // + this.textToolStripMenuItem1.Name = "textToolStripMenuItem1"; + this.textToolStripMenuItem1.Size = new System.Drawing.Size(180, 22); + this.textToolStripMenuItem1.Text = "{text-line-1}"; + this.textToolStripMenuItem1.Click += new System.EventHandler(this.InsertTag); + // + // textline2ToolStripMenuItem + // + this.textline2ToolStripMenuItem.Name = "textline2ToolStripMenuItem"; + this.textline2ToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.textline2ToolStripMenuItem.Text = "{text-line-2}"; + this.textline2ToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); + // + // labelHeader + // + this.labelHeader.AutoSize = true; + this.labelHeader.Location = new System.Drawing.Point(6, 64); + this.labelHeader.Name = "labelHeader"; + this.labelHeader.Size = new System.Drawing.Size(42, 13); + this.labelHeader.TabIndex = 2; + this.labelHeader.Text = "Header"; + // + // textBoxHeader + // + this.textBoxHeader.ContextMenuStrip = this.contextMenuStripHeader; + this.textBoxHeader.Location = new System.Drawing.Point(6, 80); + this.textBoxHeader.Multiline = true; + this.textBoxHeader.Name = "textBoxHeader"; + this.textBoxHeader.Size = new System.Drawing.Size(334, 64); + this.textBoxHeader.TabIndex = 3; + this.textBoxHeader.TextChanged += new System.EventHandler(this.TextBoxParagraphTextChanged); + // + // contextMenuStripHeader + // + this.contextMenuStripHeader.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItem1, + this.toolStripMenuItem2, + this.toolStripMenuItem7}); + this.contextMenuStripHeader.Name = "contextMenuStrip1"; + this.contextMenuStripHeader.Size = new System.Drawing.Size(114, 70); + // + // toolStripMenuItem1 + // + this.toolStripMenuItem1.Name = "toolStripMenuItem1"; + this.toolStripMenuItem1.Size = new System.Drawing.Size(113, 22); + this.toolStripMenuItem1.Text = "{title}"; + this.toolStripMenuItem1.Click += new System.EventHandler(this.InsertTagHeader); + // + // toolStripMenuItem2 + // + this.toolStripMenuItem2.Name = "toolStripMenuItem2"; + this.toolStripMenuItem2.Size = new System.Drawing.Size(113, 22); + this.toolStripMenuItem2.Text = "{#lines}"; + this.toolStripMenuItem2.Click += new System.EventHandler(this.InsertTagHeader); + // + // toolStripMenuItem7 + // + this.toolStripMenuItem7.Name = "toolStripMenuItem7"; + this.toolStripMenuItem7.Size = new System.Drawing.Size(113, 22); + this.toolStripMenuItem7.Text = "{tab}"; + this.toolStripMenuItem7.Click += new System.EventHandler(this.InsertTagHeader); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(628, 412); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(547, 412); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 2; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // groupBoxPreview + // + this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxPreview.Controls.Add(this.textBoxPreview); + this.groupBoxPreview.Location = new System.Drawing.Point(364, 12); + this.groupBoxPreview.Name = "groupBoxPreview"; + this.groupBoxPreview.Size = new System.Drawing.Size(346, 393); + this.groupBoxPreview.TabIndex = 1; + this.groupBoxPreview.TabStop = false; + this.groupBoxPreview.Text = "Preview"; + // + // textBoxPreview + // + this.textBoxPreview.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBoxPreview.Location = new System.Drawing.Point(3, 16); + this.textBoxPreview.Multiline = true; + this.textBoxPreview.Name = "textBoxPreview"; + this.textBoxPreview.ReadOnly = true; + this.textBoxPreview.Size = new System.Drawing.Size(340, 374); + this.textBoxPreview.TabIndex = 0; + // + // cpsToolStripMenuItem + // + this.cpsToolStripMenuItem.Name = "cpsToolStripMenuItem"; + this.cpsToolStripMenuItem.Size = new System.Drawing.Size(146, 22); + this.cpsToolStripMenuItem.Text = "{cps-comma}"; + this.cpsToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); + // + // textlengthToolStripMenuItem + // + this.textlengthToolStripMenuItem.Name = "textlengthToolStripMenuItem"; + this.textlengthToolStripMenuItem.Size = new System.Drawing.Size(146, 22); + this.textlengthToolStripMenuItem.Text = "{text-length}"; + this.textlengthToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); + // + // cpsperiodToolStripMenuItem + // + this.cpsperiodToolStripMenuItem.Name = "cpsperiodToolStripMenuItem"; + this.cpsperiodToolStripMenuItem.Size = new System.Drawing.Size(146, 22); + this.cpsperiodToolStripMenuItem.Text = "{cps-period}"; + this.cpsperiodToolStripMenuItem.Click += new System.EventHandler(this.InsertTag); + // + // ExportCustomTextFormat + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(715, 445); + this.Controls.Add(this.groupBoxPreview); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.groupBoxTemplate); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(600, 450); + this.Name = "ExportCustomTextFormat"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Custom text format"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExportCustomTextFormatKeyDown); + this.groupBoxTemplate.ResumeLayout(false); + this.groupBoxTemplate.PerformLayout(); + this.contextMenuStripFooter.ResumeLayout(false); + this.contextMenuStripParagraph.ResumeLayout(false); + this.contextMenuStripHeader.ResumeLayout(false); + this.groupBoxPreview.ResumeLayout(false); + this.groupBoxPreview.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxTemplate; + private System.Windows.Forms.Label labelHeader; + private System.Windows.Forms.TextBox textBoxHeader; + private System.Windows.Forms.Label labelFooter; + private System.Windows.Forms.Label labelTextLine; + private System.Windows.Forms.TextBox textBoxParagraph; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.TextBox textBoxFooter; + private System.Windows.Forms.ContextMenuStrip contextMenuStripParagraph; + private System.Windows.Forms.ToolStripMenuItem insertHHMMSSMSToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem insertendToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem insertnumberToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem insertdurationToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem textToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem tabToolStripMenuItem; + private System.Windows.Forms.ComboBox comboBoxNewLine; + private System.Windows.Forms.ComboBox comboBoxTimeCode; + private System.Windows.Forms.Label labelNewLine; + private System.Windows.Forms.Label labelTimeCode; + private System.Windows.Forms.GroupBox groupBoxPreview; + private System.Windows.Forms.TextBox textBoxPreview; + private System.Windows.Forms.TextBox textBoxName; + private System.Windows.Forms.Label labelName; + private System.Windows.Forms.ToolStripMenuItem translationToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip contextMenuStripHeader; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem7; + private System.Windows.Forms.ContextMenuStrip contextMenuStripFooter; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemActor; + private System.Windows.Forms.ToolStripMenuItem textToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem textline2ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem cpsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem textlengthToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem cpsperiodToolStripMenuItem; + } } \ No newline at end of file diff --git a/src/Forms/ExportCustomTextFormat.cs b/src/ui/Forms/ExportCustomTextFormat.cs similarity index 97% rename from src/Forms/ExportCustomTextFormat.cs rename to src/ui/Forms/ExportCustomTextFormat.cs index 48fc4db46..ca3f4521c 100644 --- a/src/Forms/ExportCustomTextFormat.cs +++ b/src/ui/Forms/ExportCustomTextFormat.cs @@ -1,401 +1,401 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Globalization; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ExportCustomTextFormat : Form - { - public const string EnglishDoNotModify = "[Do not modify]"; - public string FormatOk { get; set; } - - public ExportCustomTextFormat(string format) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - var l = Configuration.Settings.Language.ExportCustomTextFormat; - comboBoxNewLine.Items.Clear(); - comboBoxNewLine.Items.Add(l.DoNotModify); - comboBoxNewLine.Items.Add("||"); - comboBoxNewLine.Items.Add(" "); - comboBoxNewLine.Items.Add("{newline}"); - comboBoxNewLine.Items.Add("{tab}"); - comboBoxNewLine.Items.Add("{lf}"); - comboBoxNewLine.Items.Add("{cr}"); - - comboBoxTimeCode.Text = "hh:mm:ss,zzz"; - if (!string.IsNullOrEmpty(format)) - { - var arr = format.Split('Æ'); - if (arr.Length == 6) - { - textBoxName.Text = arr[0]; - textBoxHeader.Text = arr[1]; - if (!comboBoxTimeCode.Items.Contains(arr[3])) - { - comboBoxTimeCode.Items.Add(arr[3]); - } - - comboBoxTimeCode.Text = arr[3]; - textBoxParagraph.Text = arr[2]; - comboBoxNewLine.Text = arr[4].Replace(EnglishDoNotModify, l.DoNotModify); - textBoxFooter.Text = arr[5]; - } - } - GeneratePreview(); - - Text = l.Title; - labelName.Text = Configuration.Settings.Language.General.Name; - groupBoxTemplate.Text = l.Template; - labelTimeCode.Text = l.TimeCode; - labelNewLine.Text = l.NewLine; - labelHeader.Text = l.Header; - labelTextLine.Text = l.TextLine; - labelFooter.Text = l.Footer; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - groupBoxPreview.Text = Configuration.Settings.Language.General.Preview; - } - - private void ExportCustomTextFormatKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void TextBoxParagraphTextChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void GeneratePreview() - { - var subtitle = new Subtitle(); - var p1 = new Paragraph("Line 1a." + Environment.NewLine + "Line 1b.", 1000, 3500) { Actor = "Joe" }; - var start1 = GetTimeCode(p1.StartTime, comboBoxTimeCode.Text); - var end1 = GetTimeCode(p1.EndTime, comboBoxTimeCode.Text); - var p2 = new Paragraph("Line 2a." + Environment.NewLine + "Line 2b.", 1000, 3500) { Actor = "Smith" }; - var start2 = GetTimeCode(p2.StartTime, comboBoxTimeCode.Text); - var end2 = GetTimeCode(p2.EndTime, comboBoxTimeCode.Text); - subtitle.Paragraphs.Add(p1); - subtitle.Paragraphs.Add(p2); - try - { - var newLine = comboBoxNewLine.Text.Replace(Configuration.Settings.Language.ExportCustomTextFormat.DoNotModify, EnglishDoNotModify); - var template = GetParagraphTemplate(textBoxParagraph.Text); - textBoxPreview.Text = GetHeaderOrFooter("Demo", subtitle, textBoxHeader.Text) + - GetParagraph(template, start1, end1, GetText(p1.Text, newLine), GetText("Line 1a." + Environment.NewLine + "Line 1b.", newLine), 0, p1.Actor, p1.Duration, comboBoxTimeCode.Text, Utilities.GetCharactersPerSecond(p1)) + - GetParagraph(template, start2, end2, GetText(p2.Text, newLine), GetText("Line 2a." + Environment.NewLine + "Line 2b.", newLine), 1, p2.Actor, p2.Duration, comboBoxTimeCode.Text, Utilities.GetCharactersPerSecond(p2)) + - GetHeaderOrFooter("Demo", subtitle, textBoxFooter.Text); - } - catch (Exception ex) - { - textBoxPreview.Text = ex.Message; - } - } - - public static string GetParagraphTemplate(string template) - { - var s = template.Replace("{start}", "{0}"); - s = s.Replace("{end}", "{1}"); - s = s.Replace("{text}", "{2}"); - s = s.Replace("{translation}", "{3}"); - s = s.Replace("{number}", "{4}"); - s = s.Replace("{number:", "{4:"); - s = s.Replace("{number-1}", "{5}"); - s = s.Replace("{number-1:", "{5:"); - s = s.Replace("{duration}", "{6}"); - s = s.Replace("{actor}", "{7}"); - s = s.Replace("{text-line-1}", "{8}"); - s = s.Replace("{text-line-2}", "{9}"); - s = s.Replace("{cps-comma}", "{10}"); - s = s.Replace("{cps-period}", "{11}"); - s = s.Replace("{text-length}", "{12}"); - s = s.Replace("{tab}", "\t"); - return s; - } - - public static string GetText(string text, string newLine) - { - if (!string.IsNullOrEmpty(newLine) && newLine != EnglishDoNotModify) - { - newLine = newLine.Replace("{newline}", Environment.NewLine); - newLine = newLine.Replace("{tab}", "\t"); - newLine = newLine.Replace("{lf}", "\n"); - newLine = newLine.Replace("{cr}", "\r"); - return text.Replace(Environment.NewLine, newLine); - } - return text; - } - - public static string GetTimeCode(TimeCode timeCode, string template) - { - var t = template; - var templateTrimmed = t.Trim(); - if (templateTrimmed == "ss") - { - t = t.Replace("ss", $"{timeCode.TotalSeconds:00}"); - } - - if (templateTrimmed == "s") - { - t = t.Replace("s", $"{timeCode.TotalSeconds}"); - } - - if (templateTrimmed == "zzz") - { - t = t.Replace("zzz", $"{timeCode.TotalMilliseconds:000}"); - } - - if (templateTrimmed == "z") - { - t = t.Replace("z", $"{timeCode.TotalMilliseconds}"); - } - - if (templateTrimmed == "ff") - { - t = t.Replace("ff", $"{SubtitleFormat.MillisecondsToFrames(timeCode.TotalMilliseconds)}"); - } - - var totalSeconds = (int)timeCode.TotalSeconds; - if (t.StartsWith("ssssssss", StringComparison.Ordinal)) - { - t = t.Replace("ssssssss", $"{totalSeconds:00000000}"); - } - - if (t.StartsWith("sssssss", StringComparison.Ordinal)) - { - t = t.Replace("sssssss", $"{totalSeconds:0000000}"); - } - - if (t.StartsWith("ssssss", StringComparison.Ordinal)) - { - t = t.Replace("ssssss", $"{totalSeconds:000000}"); - } - - if (t.StartsWith("sssss", StringComparison.Ordinal)) - { - t = t.Replace("sssss", $"{totalSeconds:00000}"); - } - - if (t.StartsWith("ssss", StringComparison.Ordinal)) - { - t = t.Replace("ssss", $"{totalSeconds:0000}"); - } - - if (t.StartsWith("sss", StringComparison.Ordinal)) - { - t = t.Replace("sss", $"{totalSeconds:000}"); - } - - if (t.StartsWith("ss", StringComparison.Ordinal)) - { - t = t.Replace("ss", $"{totalSeconds:00}"); - } - - var totalMilliseconds = (long)timeCode.TotalMilliseconds; - if (t.StartsWith("zzzzzzzz", StringComparison.Ordinal)) - { - t = t.Replace("zzzzzzzz", $"{totalMilliseconds:00000000}"); - } - - if (t.StartsWith("zzzzzzz", StringComparison.Ordinal)) - { - t = t.Replace("zzzzzzz", $"{totalMilliseconds:0000000}"); - } - - if (t.StartsWith("zzzzzz", StringComparison.Ordinal)) - { - t = t.Replace("zzzzzz", $"{totalMilliseconds:000000}"); - } - - if (t.StartsWith("zzzzz", StringComparison.Ordinal)) - { - t = t.Replace("zzzzz", $"{totalMilliseconds:00000}"); - } - - if (t.StartsWith("zzzz", StringComparison.Ordinal)) - { - t = t.Replace("zzzz", $"{totalMilliseconds:0000}"); - } - - if (t.StartsWith("zzz", StringComparison.Ordinal)) - { - t = t.Replace("zzz", $"{totalMilliseconds:000}"); - } - - t = t.Replace("hh", $"{timeCode.Hours:00}"); - t = t.Replace("h", $"{timeCode.Hours}"); - t = t.Replace("mm", $"{timeCode.Minutes:00}"); - t = t.Replace("m", $"{timeCode.Minutes}"); - t = t.Replace("ss", $"{timeCode.Seconds:00}"); - t = t.Replace("s", $"{timeCode.Seconds}"); - t = t.Replace("zzz", $"{timeCode.Milliseconds:000}"); - t = t.Replace("zz", $"{Math.Round(timeCode.Milliseconds / 10.0):00}"); - t = t.Replace("z", $"{Math.Round(timeCode.Milliseconds / 100.0):0}"); - t = t.Replace("ff", $"{SubtitleFormat.MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds):00}"); - t = t.Replace("f", $"{SubtitleFormat.MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds)}"); - return t; - } - - private void InsertTag(object sender, EventArgs e) - { - if (sender is ToolStripItem item) - { - textBoxParagraph.Text = textBoxParagraph.Text.Insert(textBoxParagraph.SelectionStart, item.Text); - } - } - - private void comboBoxTimeCode_SelectedIndexChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void comboBoxNewLine_SelectedIndexChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void comboBoxTimeCode_TextChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void comboBoxNewLine_TextChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - FormatOk = textBoxName.Text + "Æ" + textBoxHeader.Text + "Æ" + textBoxParagraph.Text + "Æ" + comboBoxTimeCode.Text + "Æ" + comboBoxNewLine.Text.Replace(Configuration.Settings.Language.ExportCustomTextFormat.DoNotModify, EnglishDoNotModify) + "Æ" + textBoxFooter.Text; - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void InsertTagHeader(object sender, EventArgs e) - { - if (sender is ToolStripItem item) - { - string s = item.Text; - textBoxHeader.Text = textBoxHeader.Text.Insert(textBoxHeader.SelectionStart, s); - } - } - - private void InsertTagFooter(object sender, EventArgs e) - { - if (sender is ToolStripItem item) - { - string s = item.Text; - textBoxFooter.Text = textBoxFooter.Text.Insert(textBoxFooter.SelectionStart, s); - } - } - - public static string GetHeaderOrFooter(string title, Subtitle subtitle, string template) - { - template = template.Replace("{title}", title); - template = template.Replace("{#lines}", subtitle.Paragraphs.Count.ToString(CultureInfo.InvariantCulture)); - template = template.Replace("{tab}", "\t"); - return template; - } - - internal static string GetParagraph(string template, string start, string end, string text, string translation, int number, string actor, TimeCode duration, string timeCodeTemplate, double cps) - { - string d = duration.ToString(); - if (timeCodeTemplate == "ff" || timeCodeTemplate == "f") - { - d = SubtitleFormat.MillisecondsToFrames(duration.TotalMilliseconds).ToString(CultureInfo.InvariantCulture); - } - - if (timeCodeTemplate == "zzz" || timeCodeTemplate == "zz" || timeCodeTemplate == "z") - { - d = duration.TotalMilliseconds.ToString(CultureInfo.InvariantCulture); - } - - if (timeCodeTemplate == "sss" || timeCodeTemplate == "ss" || timeCodeTemplate == "s") - { - d = duration.Seconds.ToString(CultureInfo.InvariantCulture); - } - else if (timeCodeTemplate.EndsWith("ss.ff", StringComparison.Ordinal)) - { - d = $"{duration.Seconds:00}.{SubtitleFormat.MillisecondsToFramesMaxFrameRate(duration.Milliseconds):00}"; - } - else if (timeCodeTemplate.EndsWith("ss:ff", StringComparison.Ordinal)) - { - d = $"{duration.Seconds:00}:{SubtitleFormat.MillisecondsToFramesMaxFrameRate(duration.Milliseconds):00}"; - } - else if (timeCodeTemplate.EndsWith("ss,ff", StringComparison.Ordinal)) - { - d = $"{duration.Seconds:00},{SubtitleFormat.MillisecondsToFramesMaxFrameRate(duration.Milliseconds):00}"; - } - else if (timeCodeTemplate.EndsWith("ss;ff", StringComparison.Ordinal)) - { - d = $"{duration.Seconds:00};{SubtitleFormat.MillisecondsToFramesMaxFrameRate(duration.Milliseconds):00}"; - } - else if (timeCodeTemplate.EndsWith("ss.zzz", StringComparison.Ordinal)) - { - d = $"{duration.Seconds:00}.{duration.Milliseconds:000}"; - } - else if (timeCodeTemplate.EndsWith("ss:zzz", StringComparison.Ordinal)) - { - d = $"{duration.Seconds:00}:{duration.Milliseconds:000}"; - } - else if (timeCodeTemplate.EndsWith("ss,zzz", StringComparison.Ordinal)) - { - d = $"{duration.Seconds:00},{duration.Milliseconds:000}"; - } - else if (timeCodeTemplate.EndsWith("ss;zzz", StringComparison.Ordinal)) - { - d = $"{duration.Seconds:00};{duration.Milliseconds:000}"; - } - else if (timeCodeTemplate.EndsWith("ss.zz", StringComparison.Ordinal)) - { - d = $"{duration.Seconds:00}.{Math.Round(duration.Milliseconds / 10.0):00}"; - } - else if (timeCodeTemplate.EndsWith("ss:zz", StringComparison.Ordinal)) - { - d = $"{duration.Seconds:00}:{Math.Round(duration.Milliseconds / 10.0):00}"; - } - else if (timeCodeTemplate.EndsWith("ss,zz", StringComparison.Ordinal)) - { - d = $"{duration.Seconds:00},{Math.Round(duration.Milliseconds / 10.0):00}"; - } - else if (timeCodeTemplate.EndsWith("ss;zz", StringComparison.Ordinal)) - { - d = $"{duration.Seconds:00};{Math.Round(duration.Milliseconds / 10.0):00}"; - } - - var lines = text.SplitToLines(); - var line1 = string.Empty; - var line2 = string.Empty; - if (lines.Count > 0) - { - line1 = lines[0]; - } - - if (lines.Count > 1) - { - line2 = lines[1]; - } - - string s = template; - s = s.Replace("{{", "@@@@_@@@{"); - s = s.Replace("}}", "}@@@_@@@@"); - s = string.Format(s, start, end, text, translation, number + 1, number, d, actor, line1, line2, cps.ToString(CultureInfo.InvariantCulture).Replace(".", ","), cps.ToString(CultureInfo.InvariantCulture), text.Length); - s = s.Replace("@@@@_@@@", "{"); - s = s.Replace("@@@_@@@@", "}"); - return s; - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Globalization; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ExportCustomTextFormat : Form + { + public const string EnglishDoNotModify = "[Do not modify]"; + public string FormatOk { get; set; } + + public ExportCustomTextFormat(string format) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + var l = Configuration.Settings.Language.ExportCustomTextFormat; + comboBoxNewLine.Items.Clear(); + comboBoxNewLine.Items.Add(l.DoNotModify); + comboBoxNewLine.Items.Add("||"); + comboBoxNewLine.Items.Add(" "); + comboBoxNewLine.Items.Add("{newline}"); + comboBoxNewLine.Items.Add("{tab}"); + comboBoxNewLine.Items.Add("{lf}"); + comboBoxNewLine.Items.Add("{cr}"); + + comboBoxTimeCode.Text = "hh:mm:ss,zzz"; + if (!string.IsNullOrEmpty(format)) + { + var arr = format.Split('Æ'); + if (arr.Length == 6) + { + textBoxName.Text = arr[0]; + textBoxHeader.Text = arr[1]; + if (!comboBoxTimeCode.Items.Contains(arr[3])) + { + comboBoxTimeCode.Items.Add(arr[3]); + } + + comboBoxTimeCode.Text = arr[3]; + textBoxParagraph.Text = arr[2]; + comboBoxNewLine.Text = arr[4].Replace(EnglishDoNotModify, l.DoNotModify); + textBoxFooter.Text = arr[5]; + } + } + GeneratePreview(); + + Text = l.Title; + labelName.Text = Configuration.Settings.Language.General.Name; + groupBoxTemplate.Text = l.Template; + labelTimeCode.Text = l.TimeCode; + labelNewLine.Text = l.NewLine; + labelHeader.Text = l.Header; + labelTextLine.Text = l.TextLine; + labelFooter.Text = l.Footer; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + groupBoxPreview.Text = Configuration.Settings.Language.General.Preview; + } + + private void ExportCustomTextFormatKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void TextBoxParagraphTextChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void GeneratePreview() + { + var subtitle = new Subtitle(); + var p1 = new Paragraph("Line 1a." + Environment.NewLine + "Line 1b.", 1000, 3500) { Actor = "Joe" }; + var start1 = GetTimeCode(p1.StartTime, comboBoxTimeCode.Text); + var end1 = GetTimeCode(p1.EndTime, comboBoxTimeCode.Text); + var p2 = new Paragraph("Line 2a." + Environment.NewLine + "Line 2b.", 1000, 3500) { Actor = "Smith" }; + var start2 = GetTimeCode(p2.StartTime, comboBoxTimeCode.Text); + var end2 = GetTimeCode(p2.EndTime, comboBoxTimeCode.Text); + subtitle.Paragraphs.Add(p1); + subtitle.Paragraphs.Add(p2); + try + { + var newLine = comboBoxNewLine.Text.Replace(Configuration.Settings.Language.ExportCustomTextFormat.DoNotModify, EnglishDoNotModify); + var template = GetParagraphTemplate(textBoxParagraph.Text); + textBoxPreview.Text = GetHeaderOrFooter("Demo", subtitle, textBoxHeader.Text) + + GetParagraph(template, start1, end1, GetText(p1.Text, newLine), GetText("Line 1a." + Environment.NewLine + "Line 1b.", newLine), 0, p1.Actor, p1.Duration, comboBoxTimeCode.Text, Utilities.GetCharactersPerSecond(p1)) + + GetParagraph(template, start2, end2, GetText(p2.Text, newLine), GetText("Line 2a." + Environment.NewLine + "Line 2b.", newLine), 1, p2.Actor, p2.Duration, comboBoxTimeCode.Text, Utilities.GetCharactersPerSecond(p2)) + + GetHeaderOrFooter("Demo", subtitle, textBoxFooter.Text); + } + catch (Exception ex) + { + textBoxPreview.Text = ex.Message; + } + } + + public static string GetParagraphTemplate(string template) + { + var s = template.Replace("{start}", "{0}"); + s = s.Replace("{end}", "{1}"); + s = s.Replace("{text}", "{2}"); + s = s.Replace("{translation}", "{3}"); + s = s.Replace("{number}", "{4}"); + s = s.Replace("{number:", "{4:"); + s = s.Replace("{number-1}", "{5}"); + s = s.Replace("{number-1:", "{5:"); + s = s.Replace("{duration}", "{6}"); + s = s.Replace("{actor}", "{7}"); + s = s.Replace("{text-line-1}", "{8}"); + s = s.Replace("{text-line-2}", "{9}"); + s = s.Replace("{cps-comma}", "{10}"); + s = s.Replace("{cps-period}", "{11}"); + s = s.Replace("{text-length}", "{12}"); + s = s.Replace("{tab}", "\t"); + return s; + } + + public static string GetText(string text, string newLine) + { + if (!string.IsNullOrEmpty(newLine) && newLine != EnglishDoNotModify) + { + newLine = newLine.Replace("{newline}", Environment.NewLine); + newLine = newLine.Replace("{tab}", "\t"); + newLine = newLine.Replace("{lf}", "\n"); + newLine = newLine.Replace("{cr}", "\r"); + return text.Replace(Environment.NewLine, newLine); + } + return text; + } + + public static string GetTimeCode(TimeCode timeCode, string template) + { + var t = template; + var templateTrimmed = t.Trim(); + if (templateTrimmed == "ss") + { + t = t.Replace("ss", $"{timeCode.TotalSeconds:00}"); + } + + if (templateTrimmed == "s") + { + t = t.Replace("s", $"{timeCode.TotalSeconds}"); + } + + if (templateTrimmed == "zzz") + { + t = t.Replace("zzz", $"{timeCode.TotalMilliseconds:000}"); + } + + if (templateTrimmed == "z") + { + t = t.Replace("z", $"{timeCode.TotalMilliseconds}"); + } + + if (templateTrimmed == "ff") + { + t = t.Replace("ff", $"{SubtitleFormat.MillisecondsToFrames(timeCode.TotalMilliseconds)}"); + } + + var totalSeconds = (int)timeCode.TotalSeconds; + if (t.StartsWith("ssssssss", StringComparison.Ordinal)) + { + t = t.Replace("ssssssss", $"{totalSeconds:00000000}"); + } + + if (t.StartsWith("sssssss", StringComparison.Ordinal)) + { + t = t.Replace("sssssss", $"{totalSeconds:0000000}"); + } + + if (t.StartsWith("ssssss", StringComparison.Ordinal)) + { + t = t.Replace("ssssss", $"{totalSeconds:000000}"); + } + + if (t.StartsWith("sssss", StringComparison.Ordinal)) + { + t = t.Replace("sssss", $"{totalSeconds:00000}"); + } + + if (t.StartsWith("ssss", StringComparison.Ordinal)) + { + t = t.Replace("ssss", $"{totalSeconds:0000}"); + } + + if (t.StartsWith("sss", StringComparison.Ordinal)) + { + t = t.Replace("sss", $"{totalSeconds:000}"); + } + + if (t.StartsWith("ss", StringComparison.Ordinal)) + { + t = t.Replace("ss", $"{totalSeconds:00}"); + } + + var totalMilliseconds = (long)timeCode.TotalMilliseconds; + if (t.StartsWith("zzzzzzzz", StringComparison.Ordinal)) + { + t = t.Replace("zzzzzzzz", $"{totalMilliseconds:00000000}"); + } + + if (t.StartsWith("zzzzzzz", StringComparison.Ordinal)) + { + t = t.Replace("zzzzzzz", $"{totalMilliseconds:0000000}"); + } + + if (t.StartsWith("zzzzzz", StringComparison.Ordinal)) + { + t = t.Replace("zzzzzz", $"{totalMilliseconds:000000}"); + } + + if (t.StartsWith("zzzzz", StringComparison.Ordinal)) + { + t = t.Replace("zzzzz", $"{totalMilliseconds:00000}"); + } + + if (t.StartsWith("zzzz", StringComparison.Ordinal)) + { + t = t.Replace("zzzz", $"{totalMilliseconds:0000}"); + } + + if (t.StartsWith("zzz", StringComparison.Ordinal)) + { + t = t.Replace("zzz", $"{totalMilliseconds:000}"); + } + + t = t.Replace("hh", $"{timeCode.Hours:00}"); + t = t.Replace("h", $"{timeCode.Hours}"); + t = t.Replace("mm", $"{timeCode.Minutes:00}"); + t = t.Replace("m", $"{timeCode.Minutes}"); + t = t.Replace("ss", $"{timeCode.Seconds:00}"); + t = t.Replace("s", $"{timeCode.Seconds}"); + t = t.Replace("zzz", $"{timeCode.Milliseconds:000}"); + t = t.Replace("zz", $"{Math.Round(timeCode.Milliseconds / 10.0):00}"); + t = t.Replace("z", $"{Math.Round(timeCode.Milliseconds / 100.0):0}"); + t = t.Replace("ff", $"{SubtitleFormat.MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds):00}"); + t = t.Replace("f", $"{SubtitleFormat.MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds)}"); + return t; + } + + private void InsertTag(object sender, EventArgs e) + { + if (sender is ToolStripItem item) + { + textBoxParagraph.Text = textBoxParagraph.Text.Insert(textBoxParagraph.SelectionStart, item.Text); + } + } + + private void comboBoxTimeCode_SelectedIndexChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void comboBoxNewLine_SelectedIndexChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void comboBoxTimeCode_TextChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void comboBoxNewLine_TextChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + FormatOk = textBoxName.Text + "Æ" + textBoxHeader.Text + "Æ" + textBoxParagraph.Text + "Æ" + comboBoxTimeCode.Text + "Æ" + comboBoxNewLine.Text.Replace(Configuration.Settings.Language.ExportCustomTextFormat.DoNotModify, EnglishDoNotModify) + "Æ" + textBoxFooter.Text; + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void InsertTagHeader(object sender, EventArgs e) + { + if (sender is ToolStripItem item) + { + string s = item.Text; + textBoxHeader.Text = textBoxHeader.Text.Insert(textBoxHeader.SelectionStart, s); + } + } + + private void InsertTagFooter(object sender, EventArgs e) + { + if (sender is ToolStripItem item) + { + string s = item.Text; + textBoxFooter.Text = textBoxFooter.Text.Insert(textBoxFooter.SelectionStart, s); + } + } + + public static string GetHeaderOrFooter(string title, Subtitle subtitle, string template) + { + template = template.Replace("{title}", title); + template = template.Replace("{#lines}", subtitle.Paragraphs.Count.ToString(CultureInfo.InvariantCulture)); + template = template.Replace("{tab}", "\t"); + return template; + } + + internal static string GetParagraph(string template, string start, string end, string text, string translation, int number, string actor, TimeCode duration, string timeCodeTemplate, double cps) + { + string d = duration.ToString(); + if (timeCodeTemplate == "ff" || timeCodeTemplate == "f") + { + d = SubtitleFormat.MillisecondsToFrames(duration.TotalMilliseconds).ToString(CultureInfo.InvariantCulture); + } + + if (timeCodeTemplate == "zzz" || timeCodeTemplate == "zz" || timeCodeTemplate == "z") + { + d = duration.TotalMilliseconds.ToString(CultureInfo.InvariantCulture); + } + + if (timeCodeTemplate == "sss" || timeCodeTemplate == "ss" || timeCodeTemplate == "s") + { + d = duration.Seconds.ToString(CultureInfo.InvariantCulture); + } + else if (timeCodeTemplate.EndsWith("ss.ff", StringComparison.Ordinal)) + { + d = $"{duration.Seconds:00}.{SubtitleFormat.MillisecondsToFramesMaxFrameRate(duration.Milliseconds):00}"; + } + else if (timeCodeTemplate.EndsWith("ss:ff", StringComparison.Ordinal)) + { + d = $"{duration.Seconds:00}:{SubtitleFormat.MillisecondsToFramesMaxFrameRate(duration.Milliseconds):00}"; + } + else if (timeCodeTemplate.EndsWith("ss,ff", StringComparison.Ordinal)) + { + d = $"{duration.Seconds:00},{SubtitleFormat.MillisecondsToFramesMaxFrameRate(duration.Milliseconds):00}"; + } + else if (timeCodeTemplate.EndsWith("ss;ff", StringComparison.Ordinal)) + { + d = $"{duration.Seconds:00};{SubtitleFormat.MillisecondsToFramesMaxFrameRate(duration.Milliseconds):00}"; + } + else if (timeCodeTemplate.EndsWith("ss.zzz", StringComparison.Ordinal)) + { + d = $"{duration.Seconds:00}.{duration.Milliseconds:000}"; + } + else if (timeCodeTemplate.EndsWith("ss:zzz", StringComparison.Ordinal)) + { + d = $"{duration.Seconds:00}:{duration.Milliseconds:000}"; + } + else if (timeCodeTemplate.EndsWith("ss,zzz", StringComparison.Ordinal)) + { + d = $"{duration.Seconds:00},{duration.Milliseconds:000}"; + } + else if (timeCodeTemplate.EndsWith("ss;zzz", StringComparison.Ordinal)) + { + d = $"{duration.Seconds:00};{duration.Milliseconds:000}"; + } + else if (timeCodeTemplate.EndsWith("ss.zz", StringComparison.Ordinal)) + { + d = $"{duration.Seconds:00}.{Math.Round(duration.Milliseconds / 10.0):00}"; + } + else if (timeCodeTemplate.EndsWith("ss:zz", StringComparison.Ordinal)) + { + d = $"{duration.Seconds:00}:{Math.Round(duration.Milliseconds / 10.0):00}"; + } + else if (timeCodeTemplate.EndsWith("ss,zz", StringComparison.Ordinal)) + { + d = $"{duration.Seconds:00},{Math.Round(duration.Milliseconds / 10.0):00}"; + } + else if (timeCodeTemplate.EndsWith("ss;zz", StringComparison.Ordinal)) + { + d = $"{duration.Seconds:00};{Math.Round(duration.Milliseconds / 10.0):00}"; + } + + var lines = text.SplitToLines(); + var line1 = string.Empty; + var line2 = string.Empty; + if (lines.Count > 0) + { + line1 = lines[0]; + } + + if (lines.Count > 1) + { + line2 = lines[1]; + } + + string s = template; + s = s.Replace("{{", "@@@@_@@@{"); + s = s.Replace("}}", "}@@@_@@@@"); + s = string.Format(s, start, end, text, translation, number + 1, number, d, actor, line1, line2, cps.ToString(CultureInfo.InvariantCulture).Replace(".", ","), cps.ToString(CultureInfo.InvariantCulture), text.Length); + s = s.Replace("@@@@_@@@", "{"); + s = s.Replace("@@@_@@@@", "}"); + return s; + } + } +} diff --git a/src/Forms/ExportCustomTextFormat.resx b/src/ui/Forms/ExportCustomTextFormat.resx similarity index 98% rename from src/Forms/ExportCustomTextFormat.resx rename to src/ui/Forms/ExportCustomTextFormat.resx index 0fb26081b..ae1994e22 100644 --- a/src/Forms/ExportCustomTextFormat.resx +++ b/src/ui/Forms/ExportCustomTextFormat.resx @@ -1,129 +1,129 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 327, 17 - - - 17, 17 - - - 172, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 327, 17 + + + 17, 17 + + + 172, 17 + \ No newline at end of file diff --git a/src/Forms/ExportFcpXmlAdvanced.Designer.cs b/src/ui/Forms/ExportFcpXmlAdvanced.Designer.cs similarity index 100% rename from src/Forms/ExportFcpXmlAdvanced.Designer.cs rename to src/ui/Forms/ExportFcpXmlAdvanced.Designer.cs diff --git a/src/Forms/ExportFcpXmlAdvanced.cs b/src/ui/Forms/ExportFcpXmlAdvanced.cs similarity index 100% rename from src/Forms/ExportFcpXmlAdvanced.cs rename to src/ui/Forms/ExportFcpXmlAdvanced.cs diff --git a/src/Forms/ExportFcpXmlAdvanced.resx b/src/ui/Forms/ExportFcpXmlAdvanced.resx similarity index 100% rename from src/Forms/ExportFcpXmlAdvanced.resx rename to src/ui/Forms/ExportFcpXmlAdvanced.resx diff --git a/src/Forms/ExportPngXml.Designer.cs b/src/ui/Forms/ExportPngXml.Designer.cs similarity index 98% rename from src/Forms/ExportPngXml.Designer.cs rename to src/ui/Forms/ExportPngXml.Designer.cs index f0d3247a8..08a63d31f 100644 --- a/src/Forms/ExportPngXml.Designer.cs +++ b/src/ui/Forms/ExportPngXml.Designer.cs @@ -1,1175 +1,1175 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class ExportPngXml - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.saveImageAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.buttonExport = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); - this.progressBar1 = new System.Windows.Forms.ProgressBar(); - this.groupBoxImageSettings = new System.Windows.Forms.GroupBox(); - this.labelResize = new System.Windows.Forms.Label(); - this.comboBoxResizePercentage = new System.Windows.Forms.ComboBox(); - this.comboBoxBottomMarginUnit = new System.Windows.Forms.ComboBox(); - this.comboBoxLeftRightMarginUnit = new System.Windows.Forms.ComboBox(); - this.labelLineHeightStyle = new System.Windows.Forms.Label(); - this.panelFullFrameBackground = new System.Windows.Forms.Panel(); - this.comboBoxLeftRightMargin = new System.Windows.Forms.ComboBox(); - this.checkBoxFullFrameImage = new System.Windows.Forms.CheckBox(); - this.checkBoxTransAntiAliase = new System.Windows.Forms.CheckBox(); - this.labelLineHeight = new System.Windows.Forms.Label(); - this.numericUpDownLineSpacing = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownShadowTransparency = new System.Windows.Forms.NumericUpDown(); - this.labelShadowTransparency = new System.Windows.Forms.Label(); - this.labelShadowWidth = new System.Windows.Forms.Label(); - this.comboBoxShadowWidth = new System.Windows.Forms.ComboBox(); - this.panelShadowColor = new System.Windows.Forms.Panel(); - this.buttonShadowColor = new System.Windows.Forms.Button(); - this.labelDepth = new System.Windows.Forms.Label(); - this.label3D = new System.Windows.Forms.Label(); - this.comboBox3D = new System.Windows.Forms.ComboBox(); - this.numericUpDownDepth3D = new System.Windows.Forms.NumericUpDown(); - this.buttonCustomResolution = new System.Windows.Forms.Button(); - this.comboBoxBottomMargin = new System.Windows.Forms.ComboBox(); - this.labelBottomMargin = new System.Windows.Forms.Label(); - this.labelFrameRate = new System.Windows.Forms.Label(); - this.comboBoxFrameRate = new System.Windows.Forms.ComboBox(); - this.labelLanguage = new System.Windows.Forms.Label(); - this.comboBoxLanguage = new System.Windows.Forms.ComboBox(); - this.labelImageFormat = new System.Windows.Forms.Label(); - this.comboBoxImageFormat = new System.Windows.Forms.ComboBox(); - this.checkBoxBold = new System.Windows.Forms.CheckBox(); - this.labelResolution = new System.Windows.Forms.Label(); - this.comboBoxResolution = new System.Windows.Forms.ComboBox(); - this.comboBoxHAlign = new System.Windows.Forms.ComboBox(); - this.labelHorizontalAlign = new System.Windows.Forms.Label(); - this.checkBoxSimpleRender = new System.Windows.Forms.CheckBox(); - this.labelSubtitleFontSize = new System.Windows.Forms.Label(); - this.comboBoxSubtitleFont = new System.Windows.Forms.ComboBox(); - this.comboBoxSubtitleFontSize = new System.Windows.Forms.ComboBox(); - this.labelSubtitleFont = new System.Windows.Forms.Label(); - this.labelBorderWidth = new System.Windows.Forms.Label(); - this.comboBoxBorderWidth = new System.Windows.Forms.ComboBox(); - this.panelBorderColor = new System.Windows.Forms.Panel(); - this.buttonBorderColor = new System.Windows.Forms.Button(); - this.panelColor = new System.Windows.Forms.Panel(); - this.buttonColor = new System.Windows.Forms.Button(); - this.checkBoxSkipEmptyFrameAtStart = new System.Windows.Forms.CheckBox(); - this.checkBoxFcpFullPathUrl = new System.Windows.Forms.CheckBox(); - this.labelLeftRightMargin = new System.Windows.Forms.Label(); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.groupBoxExportImage = new System.Windows.Forms.GroupBox(); - this.linkLabelPreview = new System.Windows.Forms.LinkLabel(); - this.panelVlcTemp = new System.Windows.Forms.Panel(); - this.timerPreview = new System.Windows.Forms.Timer(this.components); - this.contextMenuStripListView = new System.Windows.Forms.ContextMenuStrip(this.components); - this.normalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.italicToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boxSingleLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boxMultiLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparatorAdjust = new System.Windows.Forms.ToolStripSeparator(); - this.adjustDisplayTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.adjustTimeCodesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.subtitleListView1 = new System.Windows.Forms.ListView(); - this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.contextMenuStrip1.SuspendLayout(); - this.groupBoxImageSettings.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownLineSpacing)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownShadowTransparency)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDepth3D)).BeginInit(); - this.groupBoxExportImage.SuspendLayout(); - this.contextMenuStripListView.SuspendLayout(); - this.SuspendLayout(); - // - // pictureBox1 - // - this.pictureBox1.ContextMenuStrip = this.contextMenuStrip1; - this.pictureBox1.Location = new System.Drawing.Point(6, 19); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(553, 152); - this.pictureBox1.TabIndex = 1; - this.pictureBox1.TabStop = false; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.saveImageAsToolStripMenuItem}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(158, 26); - // - // saveImageAsToolStripMenuItem - // - this.saveImageAsToolStripMenuItem.Name = "saveImageAsToolStripMenuItem"; - this.saveImageAsToolStripMenuItem.Size = new System.Drawing.Size(157, 22); - this.saveImageAsToolStripMenuItem.Text = "Save image as..."; - this.saveImageAsToolStripMenuItem.Click += new System.EventHandler(this.saveImageAsToolStripMenuItem_Click); - // - // buttonExport - // - this.buttonExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonExport.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonExport.Location = new System.Drawing.Point(768, 597); - this.buttonExport.Name = "buttonExport"; - this.buttonExport.Size = new System.Drawing.Size(126, 23); - this.buttonExport.TabIndex = 6; - this.buttonExport.Text = "Export all lines..."; - this.buttonExport.UseVisualStyleBackColor = true; - this.buttonExport.Click += new System.EventHandler(this.ButtonExportClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(894, 597); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 0; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // progressBar1 - // - this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.progressBar1.Location = new System.Drawing.Point(12, 599); - this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(750, 21); - this.progressBar1.TabIndex = 5; - this.progressBar1.Visible = false; - // - // groupBoxImageSettings - // - this.groupBoxImageSettings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxImageSettings.Controls.Add(this.labelResize); - this.groupBoxImageSettings.Controls.Add(this.comboBoxResizePercentage); - this.groupBoxImageSettings.Controls.Add(this.comboBoxBottomMarginUnit); - this.groupBoxImageSettings.Controls.Add(this.comboBoxLeftRightMarginUnit); - this.groupBoxImageSettings.Controls.Add(this.labelLineHeightStyle); - this.groupBoxImageSettings.Controls.Add(this.panelFullFrameBackground); - this.groupBoxImageSettings.Controls.Add(this.comboBoxLeftRightMargin); - this.groupBoxImageSettings.Controls.Add(this.checkBoxFullFrameImage); - this.groupBoxImageSettings.Controls.Add(this.checkBoxTransAntiAliase); - this.groupBoxImageSettings.Controls.Add(this.labelLineHeight); - this.groupBoxImageSettings.Controls.Add(this.numericUpDownLineSpacing); - this.groupBoxImageSettings.Controls.Add(this.numericUpDownShadowTransparency); - this.groupBoxImageSettings.Controls.Add(this.labelShadowTransparency); - this.groupBoxImageSettings.Controls.Add(this.labelShadowWidth); - this.groupBoxImageSettings.Controls.Add(this.comboBoxShadowWidth); - this.groupBoxImageSettings.Controls.Add(this.panelShadowColor); - this.groupBoxImageSettings.Controls.Add(this.buttonShadowColor); - this.groupBoxImageSettings.Controls.Add(this.labelDepth); - this.groupBoxImageSettings.Controls.Add(this.label3D); - this.groupBoxImageSettings.Controls.Add(this.comboBox3D); - this.groupBoxImageSettings.Controls.Add(this.numericUpDownDepth3D); - this.groupBoxImageSettings.Controls.Add(this.buttonCustomResolution); - this.groupBoxImageSettings.Controls.Add(this.comboBoxBottomMargin); - this.groupBoxImageSettings.Controls.Add(this.labelBottomMargin); - this.groupBoxImageSettings.Controls.Add(this.labelFrameRate); - this.groupBoxImageSettings.Controls.Add(this.comboBoxFrameRate); - this.groupBoxImageSettings.Controls.Add(this.labelLanguage); - this.groupBoxImageSettings.Controls.Add(this.comboBoxLanguage); - this.groupBoxImageSettings.Controls.Add(this.labelImageFormat); - this.groupBoxImageSettings.Controls.Add(this.comboBoxImageFormat); - this.groupBoxImageSettings.Controls.Add(this.checkBoxBold); - this.groupBoxImageSettings.Controls.Add(this.labelResolution); - this.groupBoxImageSettings.Controls.Add(this.comboBoxResolution); - this.groupBoxImageSettings.Controls.Add(this.comboBoxHAlign); - this.groupBoxImageSettings.Controls.Add(this.labelHorizontalAlign); - this.groupBoxImageSettings.Controls.Add(this.checkBoxSimpleRender); - this.groupBoxImageSettings.Controls.Add(this.labelSubtitleFontSize); - this.groupBoxImageSettings.Controls.Add(this.comboBoxSubtitleFont); - this.groupBoxImageSettings.Controls.Add(this.comboBoxSubtitleFontSize); - this.groupBoxImageSettings.Controls.Add(this.labelSubtitleFont); - this.groupBoxImageSettings.Controls.Add(this.labelBorderWidth); - this.groupBoxImageSettings.Controls.Add(this.comboBoxBorderWidth); - this.groupBoxImageSettings.Controls.Add(this.panelBorderColor); - this.groupBoxImageSettings.Controls.Add(this.buttonBorderColor); - this.groupBoxImageSettings.Controls.Add(this.panelColor); - this.groupBoxImageSettings.Controls.Add(this.buttonColor); - this.groupBoxImageSettings.Controls.Add(this.checkBoxSkipEmptyFrameAtStart); - this.groupBoxImageSettings.Controls.Add(this.checkBoxFcpFullPathUrl); - this.groupBoxImageSettings.Controls.Add(this.labelLeftRightMargin); - this.groupBoxImageSettings.Location = new System.Drawing.Point(12, 218); - this.groupBoxImageSettings.Name = "groupBoxImageSettings"; - this.groupBoxImageSettings.Size = new System.Drawing.Size(963, 191); - this.groupBoxImageSettings.TabIndex = 3; - this.groupBoxImageSettings.TabStop = false; - this.groupBoxImageSettings.Text = "Image settings"; - // - // labelResize - // - this.labelResize.AutoSize = true; - this.labelResize.Location = new System.Drawing.Point(263, 8); - this.labelResize.Name = "labelResize"; - this.labelResize.Size = new System.Drawing.Size(39, 13); - this.labelResize.TabIndex = 61; - this.labelResize.Text = "Resize"; - this.labelResize.Visible = false; - // - // comboBoxResizePercentage - // - this.comboBoxResizePercentage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxResizePercentage.FormattingEnabled = true; - this.comboBoxResizePercentage.Location = new System.Drawing.Point(308, 5); - this.comboBoxResizePercentage.Name = "comboBoxResizePercentage"; - this.comboBoxResizePercentage.Size = new System.Drawing.Size(77, 21); - this.comboBoxResizePercentage.TabIndex = 18; - this.comboBoxResizePercentage.Visible = false; - this.comboBoxResizePercentage.SelectedIndexChanged += new System.EventHandler(this.comboBoxResizePercentage_SelectedIndexChanged); - // - // comboBoxBottomMarginUnit - // - this.comboBoxBottomMarginUnit.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxBottomMarginUnit.FormattingEnabled = true; - this.comboBoxBottomMarginUnit.Items.AddRange(new object[] { - "%", - "px"}); - this.comboBoxBottomMarginUnit.Location = new System.Drawing.Point(181, 132); - this.comboBoxBottomMarginUnit.Name = "comboBoxBottomMarginUnit"; - this.comboBoxBottomMarginUnit.Size = new System.Drawing.Size(54, 21); - this.comboBoxBottomMarginUnit.TabIndex = 14; - this.comboBoxBottomMarginUnit.SelectedIndexChanged += new System.EventHandler(this.comboBoxBottomMarginUnit_SelectedIndexChanged); - // - // comboBoxLeftRightMarginUnit - // - this.comboBoxLeftRightMarginUnit.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxLeftRightMarginUnit.FormattingEnabled = true; - this.comboBoxLeftRightMarginUnit.Items.AddRange(new object[] { - "%", - "px"}); - this.comboBoxLeftRightMarginUnit.Location = new System.Drawing.Point(181, 159); - this.comboBoxLeftRightMarginUnit.Name = "comboBoxLeftRightMarginUnit"; - this.comboBoxLeftRightMarginUnit.Size = new System.Drawing.Size(54, 21); - this.comboBoxLeftRightMarginUnit.TabIndex = 17; - this.comboBoxLeftRightMarginUnit.SelectedIndexChanged += new System.EventHandler(this.comboBoxLeftRightMarginUnit_SelectedIndexChanged); - // - // labelLineHeightStyle - // - this.labelLineHeightStyle.AutoSize = true; - this.labelLineHeightStyle.Location = new System.Drawing.Point(799, 153); - this.labelLineHeightStyle.Name = "labelLineHeightStyle"; - this.labelLineHeightStyle.Size = new System.Drawing.Size(103, 13); - this.labelLineHeightStyle.TabIndex = 59; - this.labelLineHeightStyle.Text = "labelLineHeightStyle"; - // - // panelFullFrameBackground - // - this.panelFullFrameBackground.BackColor = System.Drawing.Color.Transparent; - this.panelFullFrameBackground.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelFullFrameBackground.Location = new System.Drawing.Point(677, 104); - this.panelFullFrameBackground.Name = "panelFullFrameBackground"; - this.panelFullFrameBackground.Size = new System.Drawing.Size(21, 20); - this.panelFullFrameBackground.TabIndex = 36; - this.panelFullFrameBackground.Visible = false; - this.panelFullFrameBackground.Click += new System.EventHandler(this.panelFullFrameBackground_Click); - // - // comboBoxLeftRightMargin - // - this.comboBoxLeftRightMargin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxLeftRightMargin.FormattingEnabled = true; - this.comboBoxLeftRightMargin.Location = new System.Drawing.Point(112, 159); - this.comboBoxLeftRightMargin.Name = "comboBoxLeftRightMargin"; - this.comboBoxLeftRightMargin.Size = new System.Drawing.Size(63, 21); - this.comboBoxLeftRightMargin.TabIndex = 16; - this.comboBoxLeftRightMargin.SelectedIndexChanged += new System.EventHandler(this.comboBoxLeftRightMargin_SelectedIndexChanged); - // - // checkBoxFullFrameImage - // - this.checkBoxFullFrameImage.AutoSize = true; - this.checkBoxFullFrameImage.Location = new System.Drawing.Point(543, 104); - this.checkBoxFullFrameImage.Name = "checkBoxFullFrameImage"; - this.checkBoxFullFrameImage.Size = new System.Drawing.Size(102, 17); - this.checkBoxFullFrameImage.TabIndex = 34; - this.checkBoxFullFrameImage.Text = "Full frame image"; - this.checkBoxFullFrameImage.UseVisualStyleBackColor = true; - this.checkBoxFullFrameImage.CheckedChanged += new System.EventHandler(this.checkBoxFullFrameImage_CheckedChanged); - // - // checkBoxTransAntiAliase - // - this.checkBoxTransAntiAliase.AutoSize = true; - this.checkBoxTransAntiAliase.Location = new System.Drawing.Point(287, 92); - this.checkBoxTransAntiAliase.Name = "checkBoxTransAntiAliase"; - this.checkBoxTransAntiAliase.Size = new System.Drawing.Size(162, 17); - this.checkBoxTransAntiAliase.TabIndex = 21; - this.checkBoxTransAntiAliase.Text = "Anti-alising with transparency"; - this.checkBoxTransAntiAliase.UseVisualStyleBackColor = true; - this.checkBoxTransAntiAliase.CheckedChanged += new System.EventHandler(this.checkBoxAntiAlias_CheckedChanged); - // - // labelLineHeight - // - this.labelLineHeight.Location = new System.Drawing.Point(686, 132); - this.labelLineHeight.Name = "labelLineHeight"; - this.labelLineHeight.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.labelLineHeight.Size = new System.Drawing.Size(110, 16); - this.labelLineHeight.TabIndex = 54; - this.labelLineHeight.Text = "Line height"; - this.labelLineHeight.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // numericUpDownLineSpacing - // - this.numericUpDownLineSpacing.Location = new System.Drawing.Point(802, 130); - this.numericUpDownLineSpacing.Maximum = new decimal(new int[] { - 500, - 0, - 0, - 0}); - this.numericUpDownLineSpacing.Name = "numericUpDownLineSpacing"; - this.numericUpDownLineSpacing.Size = new System.Drawing.Size(47, 20); - this.numericUpDownLineSpacing.TabIndex = 44; - this.numericUpDownLineSpacing.Value = new decimal(new int[] { - 10, - 0, - 0, - 0}); - this.numericUpDownLineSpacing.ValueChanged += new System.EventHandler(this.numericUpDownLineSpacing_ValueChanged); - this.numericUpDownLineSpacing.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDownLineSpacing_KeyUp); - // - // numericUpDownShadowTransparency - // - this.numericUpDownShadowTransparency.Location = new System.Drawing.Point(802, 81); - this.numericUpDownShadowTransparency.Maximum = new decimal(new int[] { - 255, - 0, - 0, - 0}); - this.numericUpDownShadowTransparency.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.numericUpDownShadowTransparency.Name = "numericUpDownShadowTransparency"; - this.numericUpDownShadowTransparency.Size = new System.Drawing.Size(47, 20); - this.numericUpDownShadowTransparency.TabIndex = 43; - this.numericUpDownShadowTransparency.Value = new decimal(new int[] { - 200, - 0, - 0, - 0}); - this.numericUpDownShadowTransparency.ValueChanged += new System.EventHandler(this.numericUpDownShadowTransparency_ValueChanged); - // - // labelShadowTransparency - // - this.labelShadowTransparency.Location = new System.Drawing.Point(686, 83); - this.labelShadowTransparency.Name = "labelShadowTransparency"; - this.labelShadowTransparency.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.labelShadowTransparency.Size = new System.Drawing.Size(110, 13); - this.labelShadowTransparency.TabIndex = 39; - this.labelShadowTransparency.Text = "Transparency"; - this.labelShadowTransparency.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // labelShadowWidth - // - this.labelShadowWidth.Location = new System.Drawing.Point(686, 55); - this.labelShadowWidth.Name = "labelShadowWidth"; - this.labelShadowWidth.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.labelShadowWidth.Size = new System.Drawing.Size(110, 13); - this.labelShadowWidth.TabIndex = 35; - this.labelShadowWidth.Text = "Shadow width"; - this.labelShadowWidth.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // comboBoxShadowWidth - // - this.comboBoxShadowWidth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxShadowWidth.FormattingEnabled = true; - this.comboBoxShadowWidth.Items.AddRange(new object[] { - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "10", - "11", - "12", - "13", - "14", - "15"}); - this.comboBoxShadowWidth.Location = new System.Drawing.Point(802, 52); - this.comboBoxShadowWidth.Name = "comboBoxShadowWidth"; - this.comboBoxShadowWidth.Size = new System.Drawing.Size(121, 21); - this.comboBoxShadowWidth.TabIndex = 42; - this.comboBoxShadowWidth.SelectedIndexChanged += new System.EventHandler(this.comboBoxShadowWidth_SelectedIndexChanged); - // - // panelShadowColor - // - this.panelShadowColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelShadowColor.Location = new System.Drawing.Point(929, 26); - this.panelShadowColor.Name = "panelShadowColor"; - this.panelShadowColor.Size = new System.Drawing.Size(21, 20); - this.panelShadowColor.TabIndex = 41; - this.panelShadowColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelShadowColor_MouseClick); - // - // buttonShadowColor - // - this.buttonShadowColor.Location = new System.Drawing.Point(802, 25); - this.buttonShadowColor.Name = "buttonShadowColor"; - this.buttonShadowColor.Size = new System.Drawing.Size(121, 23); - this.buttonShadowColor.TabIndex = 40; - this.buttonShadowColor.Text = "Shadow color"; - this.buttonShadowColor.UseVisualStyleBackColor = true; - this.buttonShadowColor.Click += new System.EventHandler(this.buttonShadowColor_Click); - // - // labelDepth - // - this.labelDepth.Location = new System.Drawing.Point(247, 134); - this.labelDepth.Name = "labelDepth"; - this.labelDepth.Size = new System.Drawing.Size(100, 18); - this.labelDepth.TabIndex = 18; - this.labelDepth.Text = "Depth"; - this.labelDepth.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // label3D - // - this.label3D.AutoSize = true; - this.label3D.Location = new System.Drawing.Point(284, 113); - this.label3D.Name = "label3D"; - this.label3D.Size = new System.Drawing.Size(21, 13); - this.label3D.TabIndex = 16; - this.label3D.Text = "3D"; - // - // comboBox3D - // - this.comboBox3D.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBox3D.FormattingEnabled = true; - this.comboBox3D.Location = new System.Drawing.Point(309, 110); - this.comboBox3D.Name = "comboBox3D"; - this.comboBox3D.Size = new System.Drawing.Size(112, 21); - this.comboBox3D.TabIndex = 22; - this.comboBox3D.SelectedIndexChanged += new System.EventHandler(this.comboBox3D_SelectedIndexChanged); - // - // numericUpDownDepth3D - // - this.numericUpDownDepth3D.Location = new System.Drawing.Point(353, 135); - this.numericUpDownDepth3D.Minimum = new decimal(new int[] { - 100, - 0, - 0, - -2147483648}); - this.numericUpDownDepth3D.Name = "numericUpDownDepth3D"; - this.numericUpDownDepth3D.Size = new System.Drawing.Size(47, 20); - this.numericUpDownDepth3D.TabIndex = 23; - this.numericUpDownDepth3D.ValueChanged += new System.EventHandler(this.numericUpDownDepth3D_ValueChanged); - // - // buttonCustomResolution - // - this.buttonCustomResolution.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCustomResolution.Location = new System.Drawing.Point(238, 78); - this.buttonCustomResolution.Name = "buttonCustomResolution"; - this.buttonCustomResolution.Size = new System.Drawing.Size(24, 21); - this.buttonCustomResolution.TabIndex = 6; - this.buttonCustomResolution.Text = "..."; - this.buttonCustomResolution.UseVisualStyleBackColor = true; - this.buttonCustomResolution.Click += new System.EventHandler(this.buttonCustomResolution_Click); - // - // comboBoxBottomMargin - // - this.comboBoxBottomMargin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxBottomMargin.FormattingEnabled = true; - this.comboBoxBottomMargin.Location = new System.Drawing.Point(112, 132); - this.comboBoxBottomMargin.Name = "comboBoxBottomMargin"; - this.comboBoxBottomMargin.Size = new System.Drawing.Size(63, 21); - this.comboBoxBottomMargin.TabIndex = 10; - this.comboBoxBottomMargin.SelectedIndexChanged += new System.EventHandler(this.comboBoxBottomMargin_SelectedIndexChanged); - // - // labelBottomMargin - // - this.labelBottomMargin.AutoSize = true; - this.labelBottomMargin.Location = new System.Drawing.Point(6, 135); - this.labelBottomMargin.Name = "labelBottomMargin"; - this.labelBottomMargin.Size = new System.Drawing.Size(74, 13); - this.labelBottomMargin.TabIndex = 9; - this.labelBottomMargin.Text = "Bottom margin"; - // - // labelFrameRate - // - this.labelFrameRate.Location = new System.Drawing.Point(427, 137); - this.labelFrameRate.Name = "labelFrameRate"; - this.labelFrameRate.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.labelFrameRate.Size = new System.Drawing.Size(110, 13); - this.labelFrameRate.TabIndex = 34; - this.labelFrameRate.Text = "Frame rate"; - this.labelFrameRate.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.labelFrameRate.Visible = false; - // - // comboBoxFrameRate - // - this.comboBoxFrameRate.FormattingEnabled = true; - this.comboBoxFrameRate.Location = new System.Drawing.Point(543, 134); - this.comboBoxFrameRate.Name = "comboBoxFrameRate"; - this.comboBoxFrameRate.Size = new System.Drawing.Size(128, 21); - this.comboBoxFrameRate.TabIndex = 37; - // - // labelLanguage - // - this.labelLanguage.Location = new System.Drawing.Point(427, 108); - this.labelLanguage.Name = "labelLanguage"; - this.labelLanguage.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.labelLanguage.Size = new System.Drawing.Size(110, 13); - this.labelLanguage.TabIndex = 30; - this.labelLanguage.Text = "Language"; - this.labelLanguage.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.labelLanguage.Visible = false; - // - // comboBoxLanguage - // - this.comboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxLanguage.FormattingEnabled = true; - this.comboBoxLanguage.Items.AddRange(new object[] { - "Bmp", - "Exif", - "Gif", - "Jpg", - "Png", - "Tiff"}); - this.comboBoxLanguage.Location = new System.Drawing.Point(543, 105); - this.comboBoxLanguage.Name = "comboBoxLanguage"; - this.comboBoxLanguage.Size = new System.Drawing.Size(128, 21); - this.comboBoxLanguage.TabIndex = 35; - this.comboBoxLanguage.Visible = false; - // - // labelImageFormat - // - this.labelImageFormat.Location = new System.Drawing.Point(427, 81); - this.labelImageFormat.Name = "labelImageFormat"; - this.labelImageFormat.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.labelImageFormat.Size = new System.Drawing.Size(110, 13); - this.labelImageFormat.TabIndex = 28; - this.labelImageFormat.Text = "Image format"; - this.labelImageFormat.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // comboBoxImageFormat - // - this.comboBoxImageFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxImageFormat.FormattingEnabled = true; - this.comboBoxImageFormat.Items.AddRange(new object[] { - "Bmp", - "Exif", - "Gif", - "Jpg", - "Png", - "Tiff", - "Tga"}); - this.comboBoxImageFormat.Location = new System.Drawing.Point(543, 78); - this.comboBoxImageFormat.Name = "comboBoxImageFormat"; - this.comboBoxImageFormat.Size = new System.Drawing.Size(128, 21); - this.comboBoxImageFormat.TabIndex = 33; - // - // checkBoxBold - // - this.checkBoxBold.AutoSize = true; - this.checkBoxBold.Location = new System.Drawing.Point(287, 50); - this.checkBoxBold.Name = "checkBoxBold"; - this.checkBoxBold.Size = new System.Drawing.Size(47, 17); - this.checkBoxBold.TabIndex = 19; - this.checkBoxBold.Text = "Bold"; - this.checkBoxBold.UseVisualStyleBackColor = true; - this.checkBoxBold.CheckedChanged += new System.EventHandler(this.checkBoxBold_CheckedChanged); - // - // labelResolution - // - this.labelResolution.AutoSize = true; - this.labelResolution.Location = new System.Drawing.Point(6, 81); - this.labelResolution.Name = "labelResolution"; - this.labelResolution.Size = new System.Drawing.Size(51, 13); - this.labelResolution.TabIndex = 4; - this.labelResolution.Text = "Video res"; - // - // comboBoxResolution - // - this.comboBoxResolution.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxResolution.DropDownWidth = 160; - this.comboBoxResolution.FormattingEnabled = true; - this.comboBoxResolution.Items.AddRange(new object[] { - "4K (4096x2160)", - "UHD (3840x2160)", - "2K (2048x1080)", - "DCI 2K Scope (2048x858)", - "DCI 2K Flat (1998x1080)", - "1080p (1920x1080)", - "1440x1080", - "720p (1280x720)", - "960x720", - "480p (848x480)", - "PAL (720x576)", - "NTSC (720x480)", - "640x352", - "640x272"}); - this.comboBoxResolution.Location = new System.Drawing.Point(112, 78); - this.comboBoxResolution.Name = "comboBoxResolution"; - this.comboBoxResolution.Size = new System.Drawing.Size(123, 21); - this.comboBoxResolution.TabIndex = 5; - this.comboBoxResolution.SelectedIndexChanged += new System.EventHandler(this.comboBoxResolution_SelectedIndexChanged); - // - // comboBoxHAlign - // - this.comboBoxHAlign.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxHAlign.DropDownWidth = 200; - this.comboBoxHAlign.FormattingEnabled = true; - this.comboBoxHAlign.Items.AddRange(new object[] { - "Left", - "Center", - "Right", - "Center - Left justify"}); - this.comboBoxHAlign.Location = new System.Drawing.Point(112, 105); - this.comboBoxHAlign.Name = "comboBoxHAlign"; - this.comboBoxHAlign.Size = new System.Drawing.Size(123, 21); - this.comboBoxHAlign.TabIndex = 8; - this.comboBoxHAlign.SelectedIndexChanged += new System.EventHandler(this.comboBoxHAlign_SelectedIndexChanged); - // - // labelHorizontalAlign - // - this.labelHorizontalAlign.AutoSize = true; - this.labelHorizontalAlign.Location = new System.Drawing.Point(6, 108); - this.labelHorizontalAlign.Name = "labelHorizontalAlign"; - this.labelHorizontalAlign.Size = new System.Drawing.Size(30, 13); - this.labelHorizontalAlign.TabIndex = 7; - this.labelHorizontalAlign.Text = "Align"; - // - // checkBoxSimpleRender - // - this.checkBoxSimpleRender.AutoSize = true; - this.checkBoxSimpleRender.Location = new System.Drawing.Point(287, 71); - this.checkBoxSimpleRender.Name = "checkBoxSimpleRender"; - this.checkBoxSimpleRender.Size = new System.Drawing.Size(104, 17); - this.checkBoxSimpleRender.TabIndex = 20; - this.checkBoxSimpleRender.Text = "Simple rendering"; - this.checkBoxSimpleRender.UseVisualStyleBackColor = true; - this.checkBoxSimpleRender.CheckedChanged += new System.EventHandler(this.checkBoxAntiAlias_CheckedChanged); - // - // labelSubtitleFontSize - // - this.labelSubtitleFontSize.AutoSize = true; - this.labelSubtitleFontSize.Location = new System.Drawing.Point(6, 54); - this.labelSubtitleFontSize.Name = "labelSubtitleFontSize"; - this.labelSubtitleFontSize.Size = new System.Drawing.Size(84, 13); - this.labelSubtitleFontSize.TabIndex = 2; - this.labelSubtitleFontSize.Text = "Subtitle font size"; - // - // comboBoxSubtitleFont - // - this.comboBoxSubtitleFont.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSubtitleFont.DropDownWidth = 210; - this.comboBoxSubtitleFont.FormattingEnabled = true; - this.comboBoxSubtitleFont.Location = new System.Drawing.Point(112, 24); - this.comboBoxSubtitleFont.Name = "comboBoxSubtitleFont"; - this.comboBoxSubtitleFont.Size = new System.Drawing.Size(123, 21); - this.comboBoxSubtitleFont.TabIndex = 1; - this.comboBoxSubtitleFont.SelectedIndexChanged += new System.EventHandler(this.comboBoxSubtitleFont_SelectedIndexChanged); - this.comboBoxSubtitleFont.SelectedValueChanged += new System.EventHandler(this.comboBoxSubtitleFont_SelectedValueChanged); - // - // comboBoxSubtitleFontSize - // - this.comboBoxSubtitleFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSubtitleFontSize.FormattingEnabled = true; - this.comboBoxSubtitleFontSize.Items.AddRange(new object[] { - "15", - "16", - "17", - "18", - "19", - "20", - "21", - "22", - "23", - "24", - "25", - "26", - "27", - "28", - "29", - "30", - "31", - "32", - "33", - "34", - "35", - "36", - "37", - "38", - "39", - "40", - "41", - "42", - "43", - "44", - "45", - "46", - "47", - "48", - "49", - "50", - "51", - "52", - "53", - "54", - "55", - "56", - "57", - "58", - "59", - "60", - "61", - "62", - "63", - "64", - "65", - "66", - "67", - "68", - "69", - "70", - "71", - "72", - "73", - "74", - "75", - "76", - "77", - "78", - "79", - "80", - "81", - "82", - "83", - "84", - "85", - "86", - "87", - "88", - "89", - "90", - "91", - "92", - "93", - "94", - "95", - "96", - "97", - "98", - "99", - "100", - "110", - "120", - "130", - "140", - "150", - "160", - "170", - "180", - "190", - "200", - "225", - "250", - "275", - "300", - "325", - "350", - "375", - "400", - "425", - "450", - "475", - "500"}); - this.comboBoxSubtitleFontSize.Location = new System.Drawing.Point(112, 51); - this.comboBoxSubtitleFontSize.Name = "comboBoxSubtitleFontSize"; - this.comboBoxSubtitleFontSize.Size = new System.Drawing.Size(123, 21); - this.comboBoxSubtitleFontSize.TabIndex = 3; - this.comboBoxSubtitleFontSize.SelectedIndexChanged += new System.EventHandler(this.comboBoxSubtitleFontSize_SelectedIndexChanged); - // - // labelSubtitleFont - // - this.labelSubtitleFont.AutoSize = true; - this.labelSubtitleFont.Location = new System.Drawing.Point(6, 29); - this.labelSubtitleFont.Name = "labelSubtitleFont"; - this.labelSubtitleFont.Size = new System.Drawing.Size(63, 13); - this.labelSubtitleFont.TabIndex = 0; - this.labelSubtitleFont.Text = "Subtitle font"; - // - // labelBorderWidth - // - this.labelBorderWidth.Location = new System.Drawing.Point(427, 54); - this.labelBorderWidth.Name = "labelBorderWidth"; - this.labelBorderWidth.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.labelBorderWidth.Size = new System.Drawing.Size(110, 13); - this.labelBorderWidth.TabIndex = 16; - this.labelBorderWidth.Text = "Border width"; - this.labelBorderWidth.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // comboBoxBorderWidth - // - this.comboBoxBorderWidth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxBorderWidth.FormattingEnabled = true; - this.comboBoxBorderWidth.Items.AddRange(new object[] { - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "10", - "11", - "12", - "13", - "14", - "15"}); - this.comboBoxBorderWidth.Location = new System.Drawing.Point(543, 51); - this.comboBoxBorderWidth.Name = "comboBoxBorderWidth"; - this.comboBoxBorderWidth.Size = new System.Drawing.Size(128, 21); - this.comboBoxBorderWidth.TabIndex = 32; - this.comboBoxBorderWidth.SelectedIndexChanged += new System.EventHandler(this.comboBoxBorderWidth_SelectedIndexChanged); - // - // panelBorderColor - // - this.panelBorderColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelBorderColor.Location = new System.Drawing.Point(677, 25); - this.panelBorderColor.Name = "panelBorderColor"; - this.panelBorderColor.Size = new System.Drawing.Size(21, 20); - this.panelBorderColor.TabIndex = 31; - this.panelBorderColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelBorderColor_MouseClick); - // - // buttonBorderColor - // - this.buttonBorderColor.Location = new System.Drawing.Point(543, 24); - this.buttonBorderColor.Name = "buttonBorderColor"; - this.buttonBorderColor.Size = new System.Drawing.Size(128, 23); - this.buttonBorderColor.TabIndex = 30; - this.buttonBorderColor.Text = "Border color"; - this.buttonBorderColor.UseVisualStyleBackColor = true; - this.buttonBorderColor.Click += new System.EventHandler(this.buttonBorderColor_Click); - // - // panelColor - // - this.panelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelColor.Location = new System.Drawing.Point(414, 25); - this.panelColor.Name = "panelColor"; - this.panelColor.Size = new System.Drawing.Size(21, 20); - this.panelColor.TabIndex = 12; - this.panelColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseClick); - // - // buttonColor - // - this.buttonColor.Location = new System.Drawing.Point(287, 24); - this.buttonColor.Name = "buttonColor"; - this.buttonColor.Size = new System.Drawing.Size(121, 23); - this.buttonColor.TabIndex = 18; - this.buttonColor.Text = "Color"; - this.buttonColor.UseVisualStyleBackColor = true; - this.buttonColor.Click += new System.EventHandler(this.buttonColor_Click); - // - // checkBoxSkipEmptyFrameAtStart - // - this.checkBoxSkipEmptyFrameAtStart.AutoSize = true; - this.checkBoxSkipEmptyFrameAtStart.Checked = true; - this.checkBoxSkipEmptyFrameAtStart.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxSkipEmptyFrameAtStart.Location = new System.Drawing.Point(287, 92); - this.checkBoxSkipEmptyFrameAtStart.Name = "checkBoxSkipEmptyFrameAtStart"; - this.checkBoxSkipEmptyFrameAtStart.Size = new System.Drawing.Size(147, 17); - this.checkBoxSkipEmptyFrameAtStart.TabIndex = 15; - this.checkBoxSkipEmptyFrameAtStart.Text = "Skip empty frames at start"; - this.checkBoxSkipEmptyFrameAtStart.UseVisualStyleBackColor = true; - // - // checkBoxFcpFullPathUrl - // - this.checkBoxFcpFullPathUrl.AutoSize = true; - this.checkBoxFcpFullPathUrl.Location = new System.Drawing.Point(6, 161); - this.checkBoxFcpFullPathUrl.Name = "checkBoxFcpFullPathUrl"; - this.checkBoxFcpFullPathUrl.Size = new System.Drawing.Size(182, 17); - this.checkBoxFcpFullPathUrl.TabIndex = 62; - this.checkBoxFcpFullPathUrl.Text = "Use full image path url in FCP xml"; - this.checkBoxFcpFullPathUrl.UseVisualStyleBackColor = true; - // - // labelLeftRightMargin - // - this.labelLeftRightMargin.AutoSize = true; - this.labelLeftRightMargin.Location = new System.Drawing.Point(6, 161); - this.labelLeftRightMargin.Name = "labelLeftRightMargin"; - this.labelLeftRightMargin.Size = new System.Drawing.Size(84, 13); - this.labelLeftRightMargin.TabIndex = 56; - this.labelLeftRightMargin.Text = "Left/right margin"; - // - // groupBoxExportImage - // - this.groupBoxExportImage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxExportImage.Controls.Add(this.linkLabelPreview); - this.groupBoxExportImage.Controls.Add(this.panelVlcTemp); - this.groupBoxExportImage.Controls.Add(this.pictureBox1); - this.groupBoxExportImage.Location = new System.Drawing.Point(13, 415); - this.groupBoxExportImage.Name = "groupBoxExportImage"; - this.groupBoxExportImage.Size = new System.Drawing.Size(962, 178); - this.groupBoxExportImage.TabIndex = 1; - this.groupBoxExportImage.TabStop = false; - // - // linkLabelPreview - // - this.linkLabelPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.linkLabelPreview.AutoSize = true; - this.linkLabelPreview.Location = new System.Drawing.Point(906, 16); - this.linkLabelPreview.Name = "linkLabelPreview"; - this.linkLabelPreview.Size = new System.Drawing.Size(45, 13); - this.linkLabelPreview.TabIndex = 9; - this.linkLabelPreview.TabStop = true; - this.linkLabelPreview.Text = "Preview"; - this.linkLabelPreview.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.linkLabelPreview.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelPreview_LinkClicked); - // - // panelVlcTemp - // - this.panelVlcTemp.Location = new System.Drawing.Point(642, 52); - this.panelVlcTemp.Name = "panelVlcTemp"; - this.panelVlcTemp.Size = new System.Drawing.Size(200, 100); - this.panelVlcTemp.TabIndex = 10; - this.panelVlcTemp.Visible = false; - // - // timerPreview - // - this.timerPreview.Interval = 500; - this.timerPreview.Tick += new System.EventHandler(this.timerPreview_Tick); - // - // contextMenuStripListView - // - this.contextMenuStripListView.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.normalToolStripMenuItem, - this.italicToolStripMenuItem, - this.boxSingleLineToolStripMenuItem, - this.boxMultiLineToolStripMenuItem, - this.toolStripSeparatorAdjust, - this.adjustDisplayTimeToolStripMenuItem, - this.adjustTimeCodesToolStripMenuItem}); - this.contextMenuStripListView.Name = "contextMenuStripListView"; - this.contextMenuStripListView.Size = new System.Drawing.Size(185, 142); - this.contextMenuStripListView.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripListView_Opening); - // - // normalToolStripMenuItem - // - this.normalToolStripMenuItem.Name = "normalToolStripMenuItem"; - this.normalToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.normalToolStripMenuItem.Text = "Normal"; - this.normalToolStripMenuItem.Click += new System.EventHandler(this.normalToolStripMenuItem_Click); - // - // italicToolStripMenuItem - // - this.italicToolStripMenuItem.Name = "italicToolStripMenuItem"; - this.italicToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.italicToolStripMenuItem.Text = "Italic"; - this.italicToolStripMenuItem.Click += new System.EventHandler(this.italicToolStripMenuItem_Click); - // - // boxSingleLineToolStripMenuItem - // - this.boxSingleLineToolStripMenuItem.Name = "boxSingleLineToolStripMenuItem"; - this.boxSingleLineToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.boxSingleLineToolStripMenuItem.Text = "Box - single line"; - this.boxSingleLineToolStripMenuItem.Click += new System.EventHandler(this.boxSingleLineToolStripMenuItem_Click); - // - // boxMultiLineToolStripMenuItem - // - this.boxMultiLineToolStripMenuItem.Name = "boxMultiLineToolStripMenuItem"; - this.boxMultiLineToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.boxMultiLineToolStripMenuItem.Text = "Box - multi line"; - this.boxMultiLineToolStripMenuItem.Click += new System.EventHandler(this.boxMultiLineToolStripMenuItem_Click); - // - // toolStripSeparatorAdjust - // - this.toolStripSeparatorAdjust.Name = "toolStripSeparatorAdjust"; - this.toolStripSeparatorAdjust.Size = new System.Drawing.Size(181, 6); - // - // adjustDisplayTimeToolStripMenuItem - // - this.adjustDisplayTimeToolStripMenuItem.Name = "adjustDisplayTimeToolStripMenuItem"; - this.adjustDisplayTimeToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.adjustDisplayTimeToolStripMenuItem.Text = "Adjust display time..."; - this.adjustDisplayTimeToolStripMenuItem.Click += new System.EventHandler(this.adjustDisplayTimeToolStripMenuItem_Click); - // - // adjustTimeCodesToolStripMenuItem - // - this.adjustTimeCodesToolStripMenuItem.Name = "adjustTimeCodesToolStripMenuItem"; - this.adjustTimeCodesToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.adjustTimeCodesToolStripMenuItem.Text = "Adjust time codes..."; - this.adjustTimeCodesToolStripMenuItem.Click += new System.EventHandler(this.adjustTimeCodesToolStripMenuItem_Click); - // - // subtitleListView1 - // - this.subtitleListView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.subtitleListView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.columnHeader2, - this.columnHeader3, - this.columnHeader4, - this.columnHeader5}); - this.subtitleListView1.ContextMenuStrip = this.contextMenuStripListView; - this.subtitleListView1.FullRowSelect = true; - this.subtitleListView1.GridLines = true; - this.subtitleListView1.HideSelection = false; - this.subtitleListView1.Location = new System.Drawing.Point(13, 13); - this.subtitleListView1.Name = "subtitleListView1"; - this.subtitleListView1.Size = new System.Drawing.Size(962, 199); - this.subtitleListView1.TabIndex = 7; - this.subtitleListView1.UseCompatibleStateImageBehavior = false; - this.subtitleListView1.View = System.Windows.Forms.View.Details; - this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.subtitleListView1_SelectedIndexChanged); - this.subtitleListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.subtitleListView1_KeyDown); - // - // ExportPngXml - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(981, 632); - this.Controls.Add(this.subtitleListView1); - this.Controls.Add(this.groupBoxExportImage); - this.Controls.Add(this.groupBoxImageSettings); - this.Controls.Add(this.progressBar1); - this.Controls.Add(this.buttonExport); - this.Controls.Add(this.buttonCancel); - this.KeyPreview = true; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(890, 667); - this.Name = "ExportPngXml"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "ExportPngXml"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ExportPngXml_FormClosing); - this.Shown += new System.EventHandler(this.ExportPngXml_Shown); - this.ResizeEnd += new System.EventHandler(this.ExportPngXml_ResizeEnd); - this.SizeChanged += new System.EventHandler(this.ExportPngXml_SizeChanged); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExportPngXml_KeyDown); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.contextMenuStrip1.ResumeLayout(false); - this.groupBoxImageSettings.ResumeLayout(false); - this.groupBoxImageSettings.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownLineSpacing)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownShadowTransparency)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDepth3D)).EndInit(); - this.groupBoxExportImage.ResumeLayout(false); - this.groupBoxExportImage.PerformLayout(); - this.contextMenuStripListView.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.Button buttonExport; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; - private System.Windows.Forms.ProgressBar progressBar1; - private System.Windows.Forms.GroupBox groupBoxImageSettings; - private System.Windows.Forms.Label labelBorderWidth; - private System.Windows.Forms.ComboBox comboBoxBorderWidth; - private System.Windows.Forms.Panel panelBorderColor; - private System.Windows.Forms.Button buttonBorderColor; - private System.Windows.Forms.Panel panelColor; - private System.Windows.Forms.Button buttonColor; - private System.Windows.Forms.Label labelSubtitleFontSize; - private System.Windows.Forms.ComboBox comboBoxSubtitleFont; - private System.Windows.Forms.ComboBox comboBoxSubtitleFontSize; - private System.Windows.Forms.Label labelSubtitleFont; - private System.Windows.Forms.CheckBox checkBoxSimpleRender; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; - private System.Windows.Forms.ComboBox comboBoxHAlign; - private System.Windows.Forms.Label labelHorizontalAlign; - private System.Windows.Forms.Label labelResolution; - private System.Windows.Forms.ComboBox comboBoxResolution; - private System.Windows.Forms.CheckBox checkBoxBold; - private System.Windows.Forms.Label labelImageFormat; - private System.Windows.Forms.ComboBox comboBoxImageFormat; - private System.Windows.Forms.Label labelLanguage; - private System.Windows.Forms.ComboBox comboBoxLanguage; - private System.Windows.Forms.Label labelFrameRate; - private System.Windows.Forms.ComboBox comboBoxFrameRate; - private System.Windows.Forms.ComboBox comboBoxBottomMargin; - private System.Windows.Forms.Label labelBottomMargin; - private System.Windows.Forms.CheckBox checkBoxSkipEmptyFrameAtStart; - private System.Windows.Forms.Button buttonCustomResolution; - private System.Windows.Forms.GroupBox groupBoxExportImage; - private System.Windows.Forms.NumericUpDown numericUpDownDepth3D; - private System.Windows.Forms.Label labelDepth; - private System.Windows.Forms.Label label3D; - private System.Windows.Forms.ComboBox comboBox3D; - private System.Windows.Forms.Timer timerPreview; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem saveImageAsToolStripMenuItem; - private System.Windows.Forms.Label labelShadowWidth; - private System.Windows.Forms.ComboBox comboBoxShadowWidth; - private System.Windows.Forms.Panel panelShadowColor; - private System.Windows.Forms.Button buttonShadowColor; - private System.Windows.Forms.NumericUpDown numericUpDownShadowTransparency; - private System.Windows.Forms.Label labelShadowTransparency; - private System.Windows.Forms.Label labelLineHeight; - private System.Windows.Forms.NumericUpDown numericUpDownLineSpacing; - private System.Windows.Forms.CheckBox checkBoxTransAntiAliase; - private System.Windows.Forms.ContextMenuStrip contextMenuStripListView; - private System.Windows.Forms.ToolStripMenuItem boxSingleLineToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem boxMultiLineToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem normalToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem italicToolStripMenuItem; - private System.Windows.Forms.ListView subtitleListView1; - private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.ColumnHeader columnHeader2; - private System.Windows.Forms.ColumnHeader columnHeader3; - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.LinkLabel linkLabelPreview; - private System.Windows.Forms.Panel panelVlcTemp; - private System.Windows.Forms.CheckBox checkBoxFullFrameImage; - private System.Windows.Forms.ComboBox comboBoxLeftRightMargin; - private System.Windows.Forms.Label labelLeftRightMargin; - private System.Windows.Forms.Panel panelFullFrameBackground; - private System.Windows.Forms.Label labelLineHeightStyle; - private System.Windows.Forms.ComboBox comboBoxBottomMarginUnit; - private System.Windows.Forms.ComboBox comboBoxLeftRightMarginUnit; - private System.Windows.Forms.ComboBox comboBoxResizePercentage; - private System.Windows.Forms.Label labelResize; - private System.Windows.Forms.ToolStripMenuItem adjustTimeCodesToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorAdjust; - private System.Windows.Forms.ToolStripMenuItem adjustDisplayTimeToolStripMenuItem; - private System.Windows.Forms.CheckBox checkBoxFcpFullPathUrl; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class ExportPngXml + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.saveImageAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.buttonExport = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.groupBoxImageSettings = new System.Windows.Forms.GroupBox(); + this.labelResize = new System.Windows.Forms.Label(); + this.comboBoxResizePercentage = new System.Windows.Forms.ComboBox(); + this.comboBoxBottomMarginUnit = new System.Windows.Forms.ComboBox(); + this.comboBoxLeftRightMarginUnit = new System.Windows.Forms.ComboBox(); + this.labelLineHeightStyle = new System.Windows.Forms.Label(); + this.panelFullFrameBackground = new System.Windows.Forms.Panel(); + this.comboBoxLeftRightMargin = new System.Windows.Forms.ComboBox(); + this.checkBoxFullFrameImage = new System.Windows.Forms.CheckBox(); + this.checkBoxTransAntiAliase = new System.Windows.Forms.CheckBox(); + this.labelLineHeight = new System.Windows.Forms.Label(); + this.numericUpDownLineSpacing = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownShadowTransparency = new System.Windows.Forms.NumericUpDown(); + this.labelShadowTransparency = new System.Windows.Forms.Label(); + this.labelShadowWidth = new System.Windows.Forms.Label(); + this.comboBoxShadowWidth = new System.Windows.Forms.ComboBox(); + this.panelShadowColor = new System.Windows.Forms.Panel(); + this.buttonShadowColor = new System.Windows.Forms.Button(); + this.labelDepth = new System.Windows.Forms.Label(); + this.label3D = new System.Windows.Forms.Label(); + this.comboBox3D = new System.Windows.Forms.ComboBox(); + this.numericUpDownDepth3D = new System.Windows.Forms.NumericUpDown(); + this.buttonCustomResolution = new System.Windows.Forms.Button(); + this.comboBoxBottomMargin = new System.Windows.Forms.ComboBox(); + this.labelBottomMargin = new System.Windows.Forms.Label(); + this.labelFrameRate = new System.Windows.Forms.Label(); + this.comboBoxFrameRate = new System.Windows.Forms.ComboBox(); + this.labelLanguage = new System.Windows.Forms.Label(); + this.comboBoxLanguage = new System.Windows.Forms.ComboBox(); + this.labelImageFormat = new System.Windows.Forms.Label(); + this.comboBoxImageFormat = new System.Windows.Forms.ComboBox(); + this.checkBoxBold = new System.Windows.Forms.CheckBox(); + this.labelResolution = new System.Windows.Forms.Label(); + this.comboBoxResolution = new System.Windows.Forms.ComboBox(); + this.comboBoxHAlign = new System.Windows.Forms.ComboBox(); + this.labelHorizontalAlign = new System.Windows.Forms.Label(); + this.checkBoxSimpleRender = new System.Windows.Forms.CheckBox(); + this.labelSubtitleFontSize = new System.Windows.Forms.Label(); + this.comboBoxSubtitleFont = new System.Windows.Forms.ComboBox(); + this.comboBoxSubtitleFontSize = new System.Windows.Forms.ComboBox(); + this.labelSubtitleFont = new System.Windows.Forms.Label(); + this.labelBorderWidth = new System.Windows.Forms.Label(); + this.comboBoxBorderWidth = new System.Windows.Forms.ComboBox(); + this.panelBorderColor = new System.Windows.Forms.Panel(); + this.buttonBorderColor = new System.Windows.Forms.Button(); + this.panelColor = new System.Windows.Forms.Panel(); + this.buttonColor = new System.Windows.Forms.Button(); + this.checkBoxSkipEmptyFrameAtStart = new System.Windows.Forms.CheckBox(); + this.checkBoxFcpFullPathUrl = new System.Windows.Forms.CheckBox(); + this.labelLeftRightMargin = new System.Windows.Forms.Label(); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.groupBoxExportImage = new System.Windows.Forms.GroupBox(); + this.linkLabelPreview = new System.Windows.Forms.LinkLabel(); + this.panelVlcTemp = new System.Windows.Forms.Panel(); + this.timerPreview = new System.Windows.Forms.Timer(this.components); + this.contextMenuStripListView = new System.Windows.Forms.ContextMenuStrip(this.components); + this.normalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.italicToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boxSingleLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boxMultiLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparatorAdjust = new System.Windows.Forms.ToolStripSeparator(); + this.adjustDisplayTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.adjustTimeCodesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.subtitleListView1 = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.contextMenuStrip1.SuspendLayout(); + this.groupBoxImageSettings.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownLineSpacing)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownShadowTransparency)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDepth3D)).BeginInit(); + this.groupBoxExportImage.SuspendLayout(); + this.contextMenuStripListView.SuspendLayout(); + this.SuspendLayout(); + // + // pictureBox1 + // + this.pictureBox1.ContextMenuStrip = this.contextMenuStrip1; + this.pictureBox1.Location = new System.Drawing.Point(6, 19); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(553, 152); + this.pictureBox1.TabIndex = 1; + this.pictureBox1.TabStop = false; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.saveImageAsToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(158, 26); + // + // saveImageAsToolStripMenuItem + // + this.saveImageAsToolStripMenuItem.Name = "saveImageAsToolStripMenuItem"; + this.saveImageAsToolStripMenuItem.Size = new System.Drawing.Size(157, 22); + this.saveImageAsToolStripMenuItem.Text = "Save image as..."; + this.saveImageAsToolStripMenuItem.Click += new System.EventHandler(this.saveImageAsToolStripMenuItem_Click); + // + // buttonExport + // + this.buttonExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonExport.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonExport.Location = new System.Drawing.Point(768, 597); + this.buttonExport.Name = "buttonExport"; + this.buttonExport.Size = new System.Drawing.Size(126, 23); + this.buttonExport.TabIndex = 6; + this.buttonExport.Text = "Export all lines..."; + this.buttonExport.UseVisualStyleBackColor = true; + this.buttonExport.Click += new System.EventHandler(this.ButtonExportClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(894, 597); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 0; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // progressBar1 + // + this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.progressBar1.Location = new System.Drawing.Point(12, 599); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(750, 21); + this.progressBar1.TabIndex = 5; + this.progressBar1.Visible = false; + // + // groupBoxImageSettings + // + this.groupBoxImageSettings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImageSettings.Controls.Add(this.labelResize); + this.groupBoxImageSettings.Controls.Add(this.comboBoxResizePercentage); + this.groupBoxImageSettings.Controls.Add(this.comboBoxBottomMarginUnit); + this.groupBoxImageSettings.Controls.Add(this.comboBoxLeftRightMarginUnit); + this.groupBoxImageSettings.Controls.Add(this.labelLineHeightStyle); + this.groupBoxImageSettings.Controls.Add(this.panelFullFrameBackground); + this.groupBoxImageSettings.Controls.Add(this.comboBoxLeftRightMargin); + this.groupBoxImageSettings.Controls.Add(this.checkBoxFullFrameImage); + this.groupBoxImageSettings.Controls.Add(this.checkBoxTransAntiAliase); + this.groupBoxImageSettings.Controls.Add(this.labelLineHeight); + this.groupBoxImageSettings.Controls.Add(this.numericUpDownLineSpacing); + this.groupBoxImageSettings.Controls.Add(this.numericUpDownShadowTransparency); + this.groupBoxImageSettings.Controls.Add(this.labelShadowTransparency); + this.groupBoxImageSettings.Controls.Add(this.labelShadowWidth); + this.groupBoxImageSettings.Controls.Add(this.comboBoxShadowWidth); + this.groupBoxImageSettings.Controls.Add(this.panelShadowColor); + this.groupBoxImageSettings.Controls.Add(this.buttonShadowColor); + this.groupBoxImageSettings.Controls.Add(this.labelDepth); + this.groupBoxImageSettings.Controls.Add(this.label3D); + this.groupBoxImageSettings.Controls.Add(this.comboBox3D); + this.groupBoxImageSettings.Controls.Add(this.numericUpDownDepth3D); + this.groupBoxImageSettings.Controls.Add(this.buttonCustomResolution); + this.groupBoxImageSettings.Controls.Add(this.comboBoxBottomMargin); + this.groupBoxImageSettings.Controls.Add(this.labelBottomMargin); + this.groupBoxImageSettings.Controls.Add(this.labelFrameRate); + this.groupBoxImageSettings.Controls.Add(this.comboBoxFrameRate); + this.groupBoxImageSettings.Controls.Add(this.labelLanguage); + this.groupBoxImageSettings.Controls.Add(this.comboBoxLanguage); + this.groupBoxImageSettings.Controls.Add(this.labelImageFormat); + this.groupBoxImageSettings.Controls.Add(this.comboBoxImageFormat); + this.groupBoxImageSettings.Controls.Add(this.checkBoxBold); + this.groupBoxImageSettings.Controls.Add(this.labelResolution); + this.groupBoxImageSettings.Controls.Add(this.comboBoxResolution); + this.groupBoxImageSettings.Controls.Add(this.comboBoxHAlign); + this.groupBoxImageSettings.Controls.Add(this.labelHorizontalAlign); + this.groupBoxImageSettings.Controls.Add(this.checkBoxSimpleRender); + this.groupBoxImageSettings.Controls.Add(this.labelSubtitleFontSize); + this.groupBoxImageSettings.Controls.Add(this.comboBoxSubtitleFont); + this.groupBoxImageSettings.Controls.Add(this.comboBoxSubtitleFontSize); + this.groupBoxImageSettings.Controls.Add(this.labelSubtitleFont); + this.groupBoxImageSettings.Controls.Add(this.labelBorderWidth); + this.groupBoxImageSettings.Controls.Add(this.comboBoxBorderWidth); + this.groupBoxImageSettings.Controls.Add(this.panelBorderColor); + this.groupBoxImageSettings.Controls.Add(this.buttonBorderColor); + this.groupBoxImageSettings.Controls.Add(this.panelColor); + this.groupBoxImageSettings.Controls.Add(this.buttonColor); + this.groupBoxImageSettings.Controls.Add(this.checkBoxSkipEmptyFrameAtStart); + this.groupBoxImageSettings.Controls.Add(this.checkBoxFcpFullPathUrl); + this.groupBoxImageSettings.Controls.Add(this.labelLeftRightMargin); + this.groupBoxImageSettings.Location = new System.Drawing.Point(12, 218); + this.groupBoxImageSettings.Name = "groupBoxImageSettings"; + this.groupBoxImageSettings.Size = new System.Drawing.Size(963, 191); + this.groupBoxImageSettings.TabIndex = 3; + this.groupBoxImageSettings.TabStop = false; + this.groupBoxImageSettings.Text = "Image settings"; + // + // labelResize + // + this.labelResize.AutoSize = true; + this.labelResize.Location = new System.Drawing.Point(263, 8); + this.labelResize.Name = "labelResize"; + this.labelResize.Size = new System.Drawing.Size(39, 13); + this.labelResize.TabIndex = 61; + this.labelResize.Text = "Resize"; + this.labelResize.Visible = false; + // + // comboBoxResizePercentage + // + this.comboBoxResizePercentage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxResizePercentage.FormattingEnabled = true; + this.comboBoxResizePercentage.Location = new System.Drawing.Point(308, 5); + this.comboBoxResizePercentage.Name = "comboBoxResizePercentage"; + this.comboBoxResizePercentage.Size = new System.Drawing.Size(77, 21); + this.comboBoxResizePercentage.TabIndex = 18; + this.comboBoxResizePercentage.Visible = false; + this.comboBoxResizePercentage.SelectedIndexChanged += new System.EventHandler(this.comboBoxResizePercentage_SelectedIndexChanged); + // + // comboBoxBottomMarginUnit + // + this.comboBoxBottomMarginUnit.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxBottomMarginUnit.FormattingEnabled = true; + this.comboBoxBottomMarginUnit.Items.AddRange(new object[] { + "%", + "px"}); + this.comboBoxBottomMarginUnit.Location = new System.Drawing.Point(181, 132); + this.comboBoxBottomMarginUnit.Name = "comboBoxBottomMarginUnit"; + this.comboBoxBottomMarginUnit.Size = new System.Drawing.Size(54, 21); + this.comboBoxBottomMarginUnit.TabIndex = 14; + this.comboBoxBottomMarginUnit.SelectedIndexChanged += new System.EventHandler(this.comboBoxBottomMarginUnit_SelectedIndexChanged); + // + // comboBoxLeftRightMarginUnit + // + this.comboBoxLeftRightMarginUnit.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxLeftRightMarginUnit.FormattingEnabled = true; + this.comboBoxLeftRightMarginUnit.Items.AddRange(new object[] { + "%", + "px"}); + this.comboBoxLeftRightMarginUnit.Location = new System.Drawing.Point(181, 159); + this.comboBoxLeftRightMarginUnit.Name = "comboBoxLeftRightMarginUnit"; + this.comboBoxLeftRightMarginUnit.Size = new System.Drawing.Size(54, 21); + this.comboBoxLeftRightMarginUnit.TabIndex = 17; + this.comboBoxLeftRightMarginUnit.SelectedIndexChanged += new System.EventHandler(this.comboBoxLeftRightMarginUnit_SelectedIndexChanged); + // + // labelLineHeightStyle + // + this.labelLineHeightStyle.AutoSize = true; + this.labelLineHeightStyle.Location = new System.Drawing.Point(799, 153); + this.labelLineHeightStyle.Name = "labelLineHeightStyle"; + this.labelLineHeightStyle.Size = new System.Drawing.Size(103, 13); + this.labelLineHeightStyle.TabIndex = 59; + this.labelLineHeightStyle.Text = "labelLineHeightStyle"; + // + // panelFullFrameBackground + // + this.panelFullFrameBackground.BackColor = System.Drawing.Color.Transparent; + this.panelFullFrameBackground.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelFullFrameBackground.Location = new System.Drawing.Point(677, 104); + this.panelFullFrameBackground.Name = "panelFullFrameBackground"; + this.panelFullFrameBackground.Size = new System.Drawing.Size(21, 20); + this.panelFullFrameBackground.TabIndex = 36; + this.panelFullFrameBackground.Visible = false; + this.panelFullFrameBackground.Click += new System.EventHandler(this.panelFullFrameBackground_Click); + // + // comboBoxLeftRightMargin + // + this.comboBoxLeftRightMargin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxLeftRightMargin.FormattingEnabled = true; + this.comboBoxLeftRightMargin.Location = new System.Drawing.Point(112, 159); + this.comboBoxLeftRightMargin.Name = "comboBoxLeftRightMargin"; + this.comboBoxLeftRightMargin.Size = new System.Drawing.Size(63, 21); + this.comboBoxLeftRightMargin.TabIndex = 16; + this.comboBoxLeftRightMargin.SelectedIndexChanged += new System.EventHandler(this.comboBoxLeftRightMargin_SelectedIndexChanged); + // + // checkBoxFullFrameImage + // + this.checkBoxFullFrameImage.AutoSize = true; + this.checkBoxFullFrameImage.Location = new System.Drawing.Point(543, 104); + this.checkBoxFullFrameImage.Name = "checkBoxFullFrameImage"; + this.checkBoxFullFrameImage.Size = new System.Drawing.Size(102, 17); + this.checkBoxFullFrameImage.TabIndex = 34; + this.checkBoxFullFrameImage.Text = "Full frame image"; + this.checkBoxFullFrameImage.UseVisualStyleBackColor = true; + this.checkBoxFullFrameImage.CheckedChanged += new System.EventHandler(this.checkBoxFullFrameImage_CheckedChanged); + // + // checkBoxTransAntiAliase + // + this.checkBoxTransAntiAliase.AutoSize = true; + this.checkBoxTransAntiAliase.Location = new System.Drawing.Point(287, 92); + this.checkBoxTransAntiAliase.Name = "checkBoxTransAntiAliase"; + this.checkBoxTransAntiAliase.Size = new System.Drawing.Size(162, 17); + this.checkBoxTransAntiAliase.TabIndex = 21; + this.checkBoxTransAntiAliase.Text = "Anti-alising with transparency"; + this.checkBoxTransAntiAliase.UseVisualStyleBackColor = true; + this.checkBoxTransAntiAliase.CheckedChanged += new System.EventHandler(this.checkBoxAntiAlias_CheckedChanged); + // + // labelLineHeight + // + this.labelLineHeight.Location = new System.Drawing.Point(686, 132); + this.labelLineHeight.Name = "labelLineHeight"; + this.labelLineHeight.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.labelLineHeight.Size = new System.Drawing.Size(110, 16); + this.labelLineHeight.TabIndex = 54; + this.labelLineHeight.Text = "Line height"; + this.labelLineHeight.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // numericUpDownLineSpacing + // + this.numericUpDownLineSpacing.Location = new System.Drawing.Point(802, 130); + this.numericUpDownLineSpacing.Maximum = new decimal(new int[] { + 500, + 0, + 0, + 0}); + this.numericUpDownLineSpacing.Name = "numericUpDownLineSpacing"; + this.numericUpDownLineSpacing.Size = new System.Drawing.Size(47, 20); + this.numericUpDownLineSpacing.TabIndex = 44; + this.numericUpDownLineSpacing.Value = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDownLineSpacing.ValueChanged += new System.EventHandler(this.numericUpDownLineSpacing_ValueChanged); + this.numericUpDownLineSpacing.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDownLineSpacing_KeyUp); + // + // numericUpDownShadowTransparency + // + this.numericUpDownShadowTransparency.Location = new System.Drawing.Point(802, 81); + this.numericUpDownShadowTransparency.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericUpDownShadowTransparency.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numericUpDownShadowTransparency.Name = "numericUpDownShadowTransparency"; + this.numericUpDownShadowTransparency.Size = new System.Drawing.Size(47, 20); + this.numericUpDownShadowTransparency.TabIndex = 43; + this.numericUpDownShadowTransparency.Value = new decimal(new int[] { + 200, + 0, + 0, + 0}); + this.numericUpDownShadowTransparency.ValueChanged += new System.EventHandler(this.numericUpDownShadowTransparency_ValueChanged); + // + // labelShadowTransparency + // + this.labelShadowTransparency.Location = new System.Drawing.Point(686, 83); + this.labelShadowTransparency.Name = "labelShadowTransparency"; + this.labelShadowTransparency.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.labelShadowTransparency.Size = new System.Drawing.Size(110, 13); + this.labelShadowTransparency.TabIndex = 39; + this.labelShadowTransparency.Text = "Transparency"; + this.labelShadowTransparency.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // labelShadowWidth + // + this.labelShadowWidth.Location = new System.Drawing.Point(686, 55); + this.labelShadowWidth.Name = "labelShadowWidth"; + this.labelShadowWidth.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.labelShadowWidth.Size = new System.Drawing.Size(110, 13); + this.labelShadowWidth.TabIndex = 35; + this.labelShadowWidth.Text = "Shadow width"; + this.labelShadowWidth.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // comboBoxShadowWidth + // + this.comboBoxShadowWidth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxShadowWidth.FormattingEnabled = true; + this.comboBoxShadowWidth.Items.AddRange(new object[] { + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15"}); + this.comboBoxShadowWidth.Location = new System.Drawing.Point(802, 52); + this.comboBoxShadowWidth.Name = "comboBoxShadowWidth"; + this.comboBoxShadowWidth.Size = new System.Drawing.Size(121, 21); + this.comboBoxShadowWidth.TabIndex = 42; + this.comboBoxShadowWidth.SelectedIndexChanged += new System.EventHandler(this.comboBoxShadowWidth_SelectedIndexChanged); + // + // panelShadowColor + // + this.panelShadowColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelShadowColor.Location = new System.Drawing.Point(929, 26); + this.panelShadowColor.Name = "panelShadowColor"; + this.panelShadowColor.Size = new System.Drawing.Size(21, 20); + this.panelShadowColor.TabIndex = 41; + this.panelShadowColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelShadowColor_MouseClick); + // + // buttonShadowColor + // + this.buttonShadowColor.Location = new System.Drawing.Point(802, 25); + this.buttonShadowColor.Name = "buttonShadowColor"; + this.buttonShadowColor.Size = new System.Drawing.Size(121, 23); + this.buttonShadowColor.TabIndex = 40; + this.buttonShadowColor.Text = "Shadow color"; + this.buttonShadowColor.UseVisualStyleBackColor = true; + this.buttonShadowColor.Click += new System.EventHandler(this.buttonShadowColor_Click); + // + // labelDepth + // + this.labelDepth.Location = new System.Drawing.Point(247, 134); + this.labelDepth.Name = "labelDepth"; + this.labelDepth.Size = new System.Drawing.Size(100, 18); + this.labelDepth.TabIndex = 18; + this.labelDepth.Text = "Depth"; + this.labelDepth.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // label3D + // + this.label3D.AutoSize = true; + this.label3D.Location = new System.Drawing.Point(284, 113); + this.label3D.Name = "label3D"; + this.label3D.Size = new System.Drawing.Size(21, 13); + this.label3D.TabIndex = 16; + this.label3D.Text = "3D"; + // + // comboBox3D + // + this.comboBox3D.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox3D.FormattingEnabled = true; + this.comboBox3D.Location = new System.Drawing.Point(309, 110); + this.comboBox3D.Name = "comboBox3D"; + this.comboBox3D.Size = new System.Drawing.Size(112, 21); + this.comboBox3D.TabIndex = 22; + this.comboBox3D.SelectedIndexChanged += new System.EventHandler(this.comboBox3D_SelectedIndexChanged); + // + // numericUpDownDepth3D + // + this.numericUpDownDepth3D.Location = new System.Drawing.Point(353, 135); + this.numericUpDownDepth3D.Minimum = new decimal(new int[] { + 100, + 0, + 0, + -2147483648}); + this.numericUpDownDepth3D.Name = "numericUpDownDepth3D"; + this.numericUpDownDepth3D.Size = new System.Drawing.Size(47, 20); + this.numericUpDownDepth3D.TabIndex = 23; + this.numericUpDownDepth3D.ValueChanged += new System.EventHandler(this.numericUpDownDepth3D_ValueChanged); + // + // buttonCustomResolution + // + this.buttonCustomResolution.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCustomResolution.Location = new System.Drawing.Point(238, 78); + this.buttonCustomResolution.Name = "buttonCustomResolution"; + this.buttonCustomResolution.Size = new System.Drawing.Size(24, 21); + this.buttonCustomResolution.TabIndex = 6; + this.buttonCustomResolution.Text = "..."; + this.buttonCustomResolution.UseVisualStyleBackColor = true; + this.buttonCustomResolution.Click += new System.EventHandler(this.buttonCustomResolution_Click); + // + // comboBoxBottomMargin + // + this.comboBoxBottomMargin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxBottomMargin.FormattingEnabled = true; + this.comboBoxBottomMargin.Location = new System.Drawing.Point(112, 132); + this.comboBoxBottomMargin.Name = "comboBoxBottomMargin"; + this.comboBoxBottomMargin.Size = new System.Drawing.Size(63, 21); + this.comboBoxBottomMargin.TabIndex = 10; + this.comboBoxBottomMargin.SelectedIndexChanged += new System.EventHandler(this.comboBoxBottomMargin_SelectedIndexChanged); + // + // labelBottomMargin + // + this.labelBottomMargin.AutoSize = true; + this.labelBottomMargin.Location = new System.Drawing.Point(6, 135); + this.labelBottomMargin.Name = "labelBottomMargin"; + this.labelBottomMargin.Size = new System.Drawing.Size(74, 13); + this.labelBottomMargin.TabIndex = 9; + this.labelBottomMargin.Text = "Bottom margin"; + // + // labelFrameRate + // + this.labelFrameRate.Location = new System.Drawing.Point(427, 137); + this.labelFrameRate.Name = "labelFrameRate"; + this.labelFrameRate.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.labelFrameRate.Size = new System.Drawing.Size(110, 13); + this.labelFrameRate.TabIndex = 34; + this.labelFrameRate.Text = "Frame rate"; + this.labelFrameRate.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.labelFrameRate.Visible = false; + // + // comboBoxFrameRate + // + this.comboBoxFrameRate.FormattingEnabled = true; + this.comboBoxFrameRate.Location = new System.Drawing.Point(543, 134); + this.comboBoxFrameRate.Name = "comboBoxFrameRate"; + this.comboBoxFrameRate.Size = new System.Drawing.Size(128, 21); + this.comboBoxFrameRate.TabIndex = 37; + // + // labelLanguage + // + this.labelLanguage.Location = new System.Drawing.Point(427, 108); + this.labelLanguage.Name = "labelLanguage"; + this.labelLanguage.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.labelLanguage.Size = new System.Drawing.Size(110, 13); + this.labelLanguage.TabIndex = 30; + this.labelLanguage.Text = "Language"; + this.labelLanguage.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.labelLanguage.Visible = false; + // + // comboBoxLanguage + // + this.comboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxLanguage.FormattingEnabled = true; + this.comboBoxLanguage.Items.AddRange(new object[] { + "Bmp", + "Exif", + "Gif", + "Jpg", + "Png", + "Tiff"}); + this.comboBoxLanguage.Location = new System.Drawing.Point(543, 105); + this.comboBoxLanguage.Name = "comboBoxLanguage"; + this.comboBoxLanguage.Size = new System.Drawing.Size(128, 21); + this.comboBoxLanguage.TabIndex = 35; + this.comboBoxLanguage.Visible = false; + // + // labelImageFormat + // + this.labelImageFormat.Location = new System.Drawing.Point(427, 81); + this.labelImageFormat.Name = "labelImageFormat"; + this.labelImageFormat.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.labelImageFormat.Size = new System.Drawing.Size(110, 13); + this.labelImageFormat.TabIndex = 28; + this.labelImageFormat.Text = "Image format"; + this.labelImageFormat.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // comboBoxImageFormat + // + this.comboBoxImageFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxImageFormat.FormattingEnabled = true; + this.comboBoxImageFormat.Items.AddRange(new object[] { + "Bmp", + "Exif", + "Gif", + "Jpg", + "Png", + "Tiff", + "Tga"}); + this.comboBoxImageFormat.Location = new System.Drawing.Point(543, 78); + this.comboBoxImageFormat.Name = "comboBoxImageFormat"; + this.comboBoxImageFormat.Size = new System.Drawing.Size(128, 21); + this.comboBoxImageFormat.TabIndex = 33; + // + // checkBoxBold + // + this.checkBoxBold.AutoSize = true; + this.checkBoxBold.Location = new System.Drawing.Point(287, 50); + this.checkBoxBold.Name = "checkBoxBold"; + this.checkBoxBold.Size = new System.Drawing.Size(47, 17); + this.checkBoxBold.TabIndex = 19; + this.checkBoxBold.Text = "Bold"; + this.checkBoxBold.UseVisualStyleBackColor = true; + this.checkBoxBold.CheckedChanged += new System.EventHandler(this.checkBoxBold_CheckedChanged); + // + // labelResolution + // + this.labelResolution.AutoSize = true; + this.labelResolution.Location = new System.Drawing.Point(6, 81); + this.labelResolution.Name = "labelResolution"; + this.labelResolution.Size = new System.Drawing.Size(51, 13); + this.labelResolution.TabIndex = 4; + this.labelResolution.Text = "Video res"; + // + // comboBoxResolution + // + this.comboBoxResolution.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxResolution.DropDownWidth = 160; + this.comboBoxResolution.FormattingEnabled = true; + this.comboBoxResolution.Items.AddRange(new object[] { + "4K (4096x2160)", + "UHD (3840x2160)", + "2K (2048x1080)", + "DCI 2K Scope (2048x858)", + "DCI 2K Flat (1998x1080)", + "1080p (1920x1080)", + "1440x1080", + "720p (1280x720)", + "960x720", + "480p (848x480)", + "PAL (720x576)", + "NTSC (720x480)", + "640x352", + "640x272"}); + this.comboBoxResolution.Location = new System.Drawing.Point(112, 78); + this.comboBoxResolution.Name = "comboBoxResolution"; + this.comboBoxResolution.Size = new System.Drawing.Size(123, 21); + this.comboBoxResolution.TabIndex = 5; + this.comboBoxResolution.SelectedIndexChanged += new System.EventHandler(this.comboBoxResolution_SelectedIndexChanged); + // + // comboBoxHAlign + // + this.comboBoxHAlign.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxHAlign.DropDownWidth = 200; + this.comboBoxHAlign.FormattingEnabled = true; + this.comboBoxHAlign.Items.AddRange(new object[] { + "Left", + "Center", + "Right", + "Center - Left justify"}); + this.comboBoxHAlign.Location = new System.Drawing.Point(112, 105); + this.comboBoxHAlign.Name = "comboBoxHAlign"; + this.comboBoxHAlign.Size = new System.Drawing.Size(123, 21); + this.comboBoxHAlign.TabIndex = 8; + this.comboBoxHAlign.SelectedIndexChanged += new System.EventHandler(this.comboBoxHAlign_SelectedIndexChanged); + // + // labelHorizontalAlign + // + this.labelHorizontalAlign.AutoSize = true; + this.labelHorizontalAlign.Location = new System.Drawing.Point(6, 108); + this.labelHorizontalAlign.Name = "labelHorizontalAlign"; + this.labelHorizontalAlign.Size = new System.Drawing.Size(30, 13); + this.labelHorizontalAlign.TabIndex = 7; + this.labelHorizontalAlign.Text = "Align"; + // + // checkBoxSimpleRender + // + this.checkBoxSimpleRender.AutoSize = true; + this.checkBoxSimpleRender.Location = new System.Drawing.Point(287, 71); + this.checkBoxSimpleRender.Name = "checkBoxSimpleRender"; + this.checkBoxSimpleRender.Size = new System.Drawing.Size(104, 17); + this.checkBoxSimpleRender.TabIndex = 20; + this.checkBoxSimpleRender.Text = "Simple rendering"; + this.checkBoxSimpleRender.UseVisualStyleBackColor = true; + this.checkBoxSimpleRender.CheckedChanged += new System.EventHandler(this.checkBoxAntiAlias_CheckedChanged); + // + // labelSubtitleFontSize + // + this.labelSubtitleFontSize.AutoSize = true; + this.labelSubtitleFontSize.Location = new System.Drawing.Point(6, 54); + this.labelSubtitleFontSize.Name = "labelSubtitleFontSize"; + this.labelSubtitleFontSize.Size = new System.Drawing.Size(84, 13); + this.labelSubtitleFontSize.TabIndex = 2; + this.labelSubtitleFontSize.Text = "Subtitle font size"; + // + // comboBoxSubtitleFont + // + this.comboBoxSubtitleFont.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSubtitleFont.DropDownWidth = 210; + this.comboBoxSubtitleFont.FormattingEnabled = true; + this.comboBoxSubtitleFont.Location = new System.Drawing.Point(112, 24); + this.comboBoxSubtitleFont.Name = "comboBoxSubtitleFont"; + this.comboBoxSubtitleFont.Size = new System.Drawing.Size(123, 21); + this.comboBoxSubtitleFont.TabIndex = 1; + this.comboBoxSubtitleFont.SelectedIndexChanged += new System.EventHandler(this.comboBoxSubtitleFont_SelectedIndexChanged); + this.comboBoxSubtitleFont.SelectedValueChanged += new System.EventHandler(this.comboBoxSubtitleFont_SelectedValueChanged); + // + // comboBoxSubtitleFontSize + // + this.comboBoxSubtitleFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSubtitleFontSize.FormattingEnabled = true; + this.comboBoxSubtitleFontSize.Items.AddRange(new object[] { + "15", + "16", + "17", + "18", + "19", + "20", + "21", + "22", + "23", + "24", + "25", + "26", + "27", + "28", + "29", + "30", + "31", + "32", + "33", + "34", + "35", + "36", + "37", + "38", + "39", + "40", + "41", + "42", + "43", + "44", + "45", + "46", + "47", + "48", + "49", + "50", + "51", + "52", + "53", + "54", + "55", + "56", + "57", + "58", + "59", + "60", + "61", + "62", + "63", + "64", + "65", + "66", + "67", + "68", + "69", + "70", + "71", + "72", + "73", + "74", + "75", + "76", + "77", + "78", + "79", + "80", + "81", + "82", + "83", + "84", + "85", + "86", + "87", + "88", + "89", + "90", + "91", + "92", + "93", + "94", + "95", + "96", + "97", + "98", + "99", + "100", + "110", + "120", + "130", + "140", + "150", + "160", + "170", + "180", + "190", + "200", + "225", + "250", + "275", + "300", + "325", + "350", + "375", + "400", + "425", + "450", + "475", + "500"}); + this.comboBoxSubtitleFontSize.Location = new System.Drawing.Point(112, 51); + this.comboBoxSubtitleFontSize.Name = "comboBoxSubtitleFontSize"; + this.comboBoxSubtitleFontSize.Size = new System.Drawing.Size(123, 21); + this.comboBoxSubtitleFontSize.TabIndex = 3; + this.comboBoxSubtitleFontSize.SelectedIndexChanged += new System.EventHandler(this.comboBoxSubtitleFontSize_SelectedIndexChanged); + // + // labelSubtitleFont + // + this.labelSubtitleFont.AutoSize = true; + this.labelSubtitleFont.Location = new System.Drawing.Point(6, 29); + this.labelSubtitleFont.Name = "labelSubtitleFont"; + this.labelSubtitleFont.Size = new System.Drawing.Size(63, 13); + this.labelSubtitleFont.TabIndex = 0; + this.labelSubtitleFont.Text = "Subtitle font"; + // + // labelBorderWidth + // + this.labelBorderWidth.Location = new System.Drawing.Point(427, 54); + this.labelBorderWidth.Name = "labelBorderWidth"; + this.labelBorderWidth.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.labelBorderWidth.Size = new System.Drawing.Size(110, 13); + this.labelBorderWidth.TabIndex = 16; + this.labelBorderWidth.Text = "Border width"; + this.labelBorderWidth.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // comboBoxBorderWidth + // + this.comboBoxBorderWidth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxBorderWidth.FormattingEnabled = true; + this.comboBoxBorderWidth.Items.AddRange(new object[] { + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15"}); + this.comboBoxBorderWidth.Location = new System.Drawing.Point(543, 51); + this.comboBoxBorderWidth.Name = "comboBoxBorderWidth"; + this.comboBoxBorderWidth.Size = new System.Drawing.Size(128, 21); + this.comboBoxBorderWidth.TabIndex = 32; + this.comboBoxBorderWidth.SelectedIndexChanged += new System.EventHandler(this.comboBoxBorderWidth_SelectedIndexChanged); + // + // panelBorderColor + // + this.panelBorderColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelBorderColor.Location = new System.Drawing.Point(677, 25); + this.panelBorderColor.Name = "panelBorderColor"; + this.panelBorderColor.Size = new System.Drawing.Size(21, 20); + this.panelBorderColor.TabIndex = 31; + this.panelBorderColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelBorderColor_MouseClick); + // + // buttonBorderColor + // + this.buttonBorderColor.Location = new System.Drawing.Point(543, 24); + this.buttonBorderColor.Name = "buttonBorderColor"; + this.buttonBorderColor.Size = new System.Drawing.Size(128, 23); + this.buttonBorderColor.TabIndex = 30; + this.buttonBorderColor.Text = "Border color"; + this.buttonBorderColor.UseVisualStyleBackColor = true; + this.buttonBorderColor.Click += new System.EventHandler(this.buttonBorderColor_Click); + // + // panelColor + // + this.panelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelColor.Location = new System.Drawing.Point(414, 25); + this.panelColor.Name = "panelColor"; + this.panelColor.Size = new System.Drawing.Size(21, 20); + this.panelColor.TabIndex = 12; + this.panelColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseClick); + // + // buttonColor + // + this.buttonColor.Location = new System.Drawing.Point(287, 24); + this.buttonColor.Name = "buttonColor"; + this.buttonColor.Size = new System.Drawing.Size(121, 23); + this.buttonColor.TabIndex = 18; + this.buttonColor.Text = "Color"; + this.buttonColor.UseVisualStyleBackColor = true; + this.buttonColor.Click += new System.EventHandler(this.buttonColor_Click); + // + // checkBoxSkipEmptyFrameAtStart + // + this.checkBoxSkipEmptyFrameAtStart.AutoSize = true; + this.checkBoxSkipEmptyFrameAtStart.Checked = true; + this.checkBoxSkipEmptyFrameAtStart.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxSkipEmptyFrameAtStart.Location = new System.Drawing.Point(287, 92); + this.checkBoxSkipEmptyFrameAtStart.Name = "checkBoxSkipEmptyFrameAtStart"; + this.checkBoxSkipEmptyFrameAtStart.Size = new System.Drawing.Size(147, 17); + this.checkBoxSkipEmptyFrameAtStart.TabIndex = 15; + this.checkBoxSkipEmptyFrameAtStart.Text = "Skip empty frames at start"; + this.checkBoxSkipEmptyFrameAtStart.UseVisualStyleBackColor = true; + // + // checkBoxFcpFullPathUrl + // + this.checkBoxFcpFullPathUrl.AutoSize = true; + this.checkBoxFcpFullPathUrl.Location = new System.Drawing.Point(6, 161); + this.checkBoxFcpFullPathUrl.Name = "checkBoxFcpFullPathUrl"; + this.checkBoxFcpFullPathUrl.Size = new System.Drawing.Size(182, 17); + this.checkBoxFcpFullPathUrl.TabIndex = 62; + this.checkBoxFcpFullPathUrl.Text = "Use full image path url in FCP xml"; + this.checkBoxFcpFullPathUrl.UseVisualStyleBackColor = true; + // + // labelLeftRightMargin + // + this.labelLeftRightMargin.AutoSize = true; + this.labelLeftRightMargin.Location = new System.Drawing.Point(6, 161); + this.labelLeftRightMargin.Name = "labelLeftRightMargin"; + this.labelLeftRightMargin.Size = new System.Drawing.Size(84, 13); + this.labelLeftRightMargin.TabIndex = 56; + this.labelLeftRightMargin.Text = "Left/right margin"; + // + // groupBoxExportImage + // + this.groupBoxExportImage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxExportImage.Controls.Add(this.linkLabelPreview); + this.groupBoxExportImage.Controls.Add(this.panelVlcTemp); + this.groupBoxExportImage.Controls.Add(this.pictureBox1); + this.groupBoxExportImage.Location = new System.Drawing.Point(13, 415); + this.groupBoxExportImage.Name = "groupBoxExportImage"; + this.groupBoxExportImage.Size = new System.Drawing.Size(962, 178); + this.groupBoxExportImage.TabIndex = 1; + this.groupBoxExportImage.TabStop = false; + // + // linkLabelPreview + // + this.linkLabelPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.linkLabelPreview.AutoSize = true; + this.linkLabelPreview.Location = new System.Drawing.Point(906, 16); + this.linkLabelPreview.Name = "linkLabelPreview"; + this.linkLabelPreview.Size = new System.Drawing.Size(45, 13); + this.linkLabelPreview.TabIndex = 9; + this.linkLabelPreview.TabStop = true; + this.linkLabelPreview.Text = "Preview"; + this.linkLabelPreview.TextAlign = System.Drawing.ContentAlignment.TopRight; + this.linkLabelPreview.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelPreview_LinkClicked); + // + // panelVlcTemp + // + this.panelVlcTemp.Location = new System.Drawing.Point(642, 52); + this.panelVlcTemp.Name = "panelVlcTemp"; + this.panelVlcTemp.Size = new System.Drawing.Size(200, 100); + this.panelVlcTemp.TabIndex = 10; + this.panelVlcTemp.Visible = false; + // + // timerPreview + // + this.timerPreview.Interval = 500; + this.timerPreview.Tick += new System.EventHandler(this.timerPreview_Tick); + // + // contextMenuStripListView + // + this.contextMenuStripListView.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.normalToolStripMenuItem, + this.italicToolStripMenuItem, + this.boxSingleLineToolStripMenuItem, + this.boxMultiLineToolStripMenuItem, + this.toolStripSeparatorAdjust, + this.adjustDisplayTimeToolStripMenuItem, + this.adjustTimeCodesToolStripMenuItem}); + this.contextMenuStripListView.Name = "contextMenuStripListView"; + this.contextMenuStripListView.Size = new System.Drawing.Size(185, 142); + this.contextMenuStripListView.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripListView_Opening); + // + // normalToolStripMenuItem + // + this.normalToolStripMenuItem.Name = "normalToolStripMenuItem"; + this.normalToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.normalToolStripMenuItem.Text = "Normal"; + this.normalToolStripMenuItem.Click += new System.EventHandler(this.normalToolStripMenuItem_Click); + // + // italicToolStripMenuItem + // + this.italicToolStripMenuItem.Name = "italicToolStripMenuItem"; + this.italicToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.italicToolStripMenuItem.Text = "Italic"; + this.italicToolStripMenuItem.Click += new System.EventHandler(this.italicToolStripMenuItem_Click); + // + // boxSingleLineToolStripMenuItem + // + this.boxSingleLineToolStripMenuItem.Name = "boxSingleLineToolStripMenuItem"; + this.boxSingleLineToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.boxSingleLineToolStripMenuItem.Text = "Box - single line"; + this.boxSingleLineToolStripMenuItem.Click += new System.EventHandler(this.boxSingleLineToolStripMenuItem_Click); + // + // boxMultiLineToolStripMenuItem + // + this.boxMultiLineToolStripMenuItem.Name = "boxMultiLineToolStripMenuItem"; + this.boxMultiLineToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.boxMultiLineToolStripMenuItem.Text = "Box - multi line"; + this.boxMultiLineToolStripMenuItem.Click += new System.EventHandler(this.boxMultiLineToolStripMenuItem_Click); + // + // toolStripSeparatorAdjust + // + this.toolStripSeparatorAdjust.Name = "toolStripSeparatorAdjust"; + this.toolStripSeparatorAdjust.Size = new System.Drawing.Size(181, 6); + // + // adjustDisplayTimeToolStripMenuItem + // + this.adjustDisplayTimeToolStripMenuItem.Name = "adjustDisplayTimeToolStripMenuItem"; + this.adjustDisplayTimeToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.adjustDisplayTimeToolStripMenuItem.Text = "Adjust display time..."; + this.adjustDisplayTimeToolStripMenuItem.Click += new System.EventHandler(this.adjustDisplayTimeToolStripMenuItem_Click); + // + // adjustTimeCodesToolStripMenuItem + // + this.adjustTimeCodesToolStripMenuItem.Name = "adjustTimeCodesToolStripMenuItem"; + this.adjustTimeCodesToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.adjustTimeCodesToolStripMenuItem.Text = "Adjust time codes..."; + this.adjustTimeCodesToolStripMenuItem.Click += new System.EventHandler(this.adjustTimeCodesToolStripMenuItem_Click); + // + // subtitleListView1 + // + this.subtitleListView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.subtitleListView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2, + this.columnHeader3, + this.columnHeader4, + this.columnHeader5}); + this.subtitleListView1.ContextMenuStrip = this.contextMenuStripListView; + this.subtitleListView1.FullRowSelect = true; + this.subtitleListView1.GridLines = true; + this.subtitleListView1.HideSelection = false; + this.subtitleListView1.Location = new System.Drawing.Point(13, 13); + this.subtitleListView1.Name = "subtitleListView1"; + this.subtitleListView1.Size = new System.Drawing.Size(962, 199); + this.subtitleListView1.TabIndex = 7; + this.subtitleListView1.UseCompatibleStateImageBehavior = false; + this.subtitleListView1.View = System.Windows.Forms.View.Details; + this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.subtitleListView1_SelectedIndexChanged); + this.subtitleListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.subtitleListView1_KeyDown); + // + // ExportPngXml + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(981, 632); + this.Controls.Add(this.subtitleListView1); + this.Controls.Add(this.groupBoxExportImage); + this.Controls.Add(this.groupBoxImageSettings); + this.Controls.Add(this.progressBar1); + this.Controls.Add(this.buttonExport); + this.Controls.Add(this.buttonCancel); + this.KeyPreview = true; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(890, 667); + this.Name = "ExportPngXml"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "ExportPngXml"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ExportPngXml_FormClosing); + this.Shown += new System.EventHandler(this.ExportPngXml_Shown); + this.ResizeEnd += new System.EventHandler(this.ExportPngXml_ResizeEnd); + this.SizeChanged += new System.EventHandler(this.ExportPngXml_SizeChanged); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExportPngXml_KeyDown); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.contextMenuStrip1.ResumeLayout(false); + this.groupBoxImageSettings.ResumeLayout(false); + this.groupBoxImageSettings.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownLineSpacing)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownShadowTransparency)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDepth3D)).EndInit(); + this.groupBoxExportImage.ResumeLayout(false); + this.groupBoxExportImage.PerformLayout(); + this.contextMenuStripListView.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Button buttonExport; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; + private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.GroupBox groupBoxImageSettings; + private System.Windows.Forms.Label labelBorderWidth; + private System.Windows.Forms.ComboBox comboBoxBorderWidth; + private System.Windows.Forms.Panel panelBorderColor; + private System.Windows.Forms.Button buttonBorderColor; + private System.Windows.Forms.Panel panelColor; + private System.Windows.Forms.Button buttonColor; + private System.Windows.Forms.Label labelSubtitleFontSize; + private System.Windows.Forms.ComboBox comboBoxSubtitleFont; + private System.Windows.Forms.ComboBox comboBoxSubtitleFontSize; + private System.Windows.Forms.Label labelSubtitleFont; + private System.Windows.Forms.CheckBox checkBoxSimpleRender; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.ComboBox comboBoxHAlign; + private System.Windows.Forms.Label labelHorizontalAlign; + private System.Windows.Forms.Label labelResolution; + private System.Windows.Forms.ComboBox comboBoxResolution; + private System.Windows.Forms.CheckBox checkBoxBold; + private System.Windows.Forms.Label labelImageFormat; + private System.Windows.Forms.ComboBox comboBoxImageFormat; + private System.Windows.Forms.Label labelLanguage; + private System.Windows.Forms.ComboBox comboBoxLanguage; + private System.Windows.Forms.Label labelFrameRate; + private System.Windows.Forms.ComboBox comboBoxFrameRate; + private System.Windows.Forms.ComboBox comboBoxBottomMargin; + private System.Windows.Forms.Label labelBottomMargin; + private System.Windows.Forms.CheckBox checkBoxSkipEmptyFrameAtStart; + private System.Windows.Forms.Button buttonCustomResolution; + private System.Windows.Forms.GroupBox groupBoxExportImage; + private System.Windows.Forms.NumericUpDown numericUpDownDepth3D; + private System.Windows.Forms.Label labelDepth; + private System.Windows.Forms.Label label3D; + private System.Windows.Forms.ComboBox comboBox3D; + private System.Windows.Forms.Timer timerPreview; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem saveImageAsToolStripMenuItem; + private System.Windows.Forms.Label labelShadowWidth; + private System.Windows.Forms.ComboBox comboBoxShadowWidth; + private System.Windows.Forms.Panel panelShadowColor; + private System.Windows.Forms.Button buttonShadowColor; + private System.Windows.Forms.NumericUpDown numericUpDownShadowTransparency; + private System.Windows.Forms.Label labelShadowTransparency; + private System.Windows.Forms.Label labelLineHeight; + private System.Windows.Forms.NumericUpDown numericUpDownLineSpacing; + private System.Windows.Forms.CheckBox checkBoxTransAntiAliase; + private System.Windows.Forms.ContextMenuStrip contextMenuStripListView; + private System.Windows.Forms.ToolStripMenuItem boxSingleLineToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem boxMultiLineToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem normalToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem italicToolStripMenuItem; + private System.Windows.Forms.ListView subtitleListView1; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.ColumnHeader columnHeader3; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.LinkLabel linkLabelPreview; + private System.Windows.Forms.Panel panelVlcTemp; + private System.Windows.Forms.CheckBox checkBoxFullFrameImage; + private System.Windows.Forms.ComboBox comboBoxLeftRightMargin; + private System.Windows.Forms.Label labelLeftRightMargin; + private System.Windows.Forms.Panel panelFullFrameBackground; + private System.Windows.Forms.Label labelLineHeightStyle; + private System.Windows.Forms.ComboBox comboBoxBottomMarginUnit; + private System.Windows.Forms.ComboBox comboBoxLeftRightMarginUnit; + private System.Windows.Forms.ComboBox comboBoxResizePercentage; + private System.Windows.Forms.Label labelResize; + private System.Windows.Forms.ToolStripMenuItem adjustTimeCodesToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorAdjust; + private System.Windows.Forms.ToolStripMenuItem adjustDisplayTimeToolStripMenuItem; + private System.Windows.Forms.CheckBox checkBoxFcpFullPathUrl; + } } \ No newline at end of file diff --git a/src/Forms/ExportPngXml.cs b/src/ui/Forms/ExportPngXml.cs similarity index 97% rename from src/Forms/ExportPngXml.cs rename to src/ui/Forms/ExportPngXml.cs index 00872947c..db007e1df 100644 --- a/src/Forms/ExportPngXml.cs +++ b/src/ui/Forms/ExportPngXml.cs @@ -1,5920 +1,5920 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.BluRaySup; -using Nikse.SubtitleEdit.Core.Enums; -using Nikse.SubtitleEdit.Core.Interfaces; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Core.VobSub; -using Nikse.SubtitleEdit.Logic; -using Nikse.SubtitleEdit.Logic.VideoPlayers; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Imaging; -using System.Drawing.Text; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; -using System.Windows.Forms; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ExportPngXml : PositionAndSizeForm - { - internal class ExportFormats - { - internal const string BluraySup = "BLURAYSUP"; - internal const string VobSub = "VOBSUB"; - internal const string Fab = "FAB"; - internal const string Stl = "STL"; - internal const string Fcp = "FCP"; - internal const string Dost = "DOSTIMAGE"; - internal const string DCinemaInterop = "DCINEMA_INTEROP"; - internal const string DCinemaSmpte2014 = "DCINEMA_SMPTE_2014"; - internal const string BdnXml = "BDNXML"; - internal const string Edl = "EDL"; - internal const string EdlClipName = "EDL_CLIPNAME"; - internal const string ImageFrame = "IMAGE/FRAME"; - internal const string Spumux = "SPUMUX"; - } - - internal class MakeBitmapParameter - { - public Bitmap Bitmap { get; set; } - public Paragraph P { get; set; } - public string Type { get; set; } - public Color SubtitleColor { get; set; } - public string SubtitleFontName { get; set; } - public float SubtitleFontSize { get; set; } - public bool SubtitleFontBold { get; set; } - public Color BorderColor { get; set; } - public float BorderWidth { get; set; } - public bool BoxSingleLine { get; set; } - public bool SimpleRendering { get; set; } - public bool AlignLeft { get; set; } - public bool AlignRight { get; set; } - public bool JustifyLeft { get; set; } - public bool JustifyTop { get; set; } - public bool JustifyRight { get; set; } - public byte[] Buffer { get; set; } - public int ScreenWidth { get; set; } - public int ScreenHeight { get; set; } - public string VideoResolution { get; set; } - public int Type3D { get; set; } - public int Depth3D { get; set; } - public double FramesPerSeconds { get; set; } - public int BottomMargin { get; set; } - public int LeftMargin { get; set; } - public int RightMargin { get; set; } - public bool Saved { get; set; } - public ContentAlignment Alignment { get; set; } - public Point? OverridePosition { get; set; } - public Color BackgroundColor { get; set; } - public string SavDialogFileName { get; set; } - public string Error { get; set; } - public string LineJoin { get; set; } - public Color ShadowColor { get; set; } - public float ShadowWidth { get; set; } - public int ShadowAlpha { get; set; } - public Dictionary LineHeight { get; set; } - public bool Forced { get; set; } - public bool FullFrame { get; set; } - public Color FullFrameBackgroundColor { get; set; } - - public MakeBitmapParameter() - { - BackgroundColor = Color.Transparent; - } - } - - private Subtitle _subtitle; - private SubtitleFormat _format; - private static string _formatName; - private Color _subtitleColor; - private string _subtitleFontName = "Verdana"; - private float _subtitleFontSize = 25.0f; - private bool _subtitleFontBold; - private Color _borderColor; - private float _borderWidth = 2.0f; - private bool _isLoading = true; - private string _language = "en"; - private string _exportType = ExportFormats.BdnXml; - private string _fileName; - private string _outputFileName; - private IBinaryParagraphList _vobSubOcr; - private readonly System.Windows.Forms.Timer _previewTimer = new System.Windows.Forms.Timer(); - private string _videoFileName; - private readonly Dictionary _lineHeights; - private static int _boxBorderSize = 8; - - private const string BoxMultiLineText = "BoxMultiLine"; - private const string BoxSingleLineText = "BoxSingleLine"; - - public string GetOutputFileName() - { - return _outputFileName; - } - - public ExportPngXml() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - var toolTip = new ToolTip { ShowAlways = true }; - toolTip.SetToolTip(panelFullFrameBackground, Configuration.Settings.Language.ExportPngXml.ChooseBackgroundColor); - _lineHeights = new Dictionary(); - comboBoxImageFormat.SelectedIndex = 4; - _subtitleColor = Color.FromArgb(byte.MaxValue, Configuration.Settings.Tools.ExportFontColor); - _borderColor = Configuration.Settings.Tools.ExportBorderColor; - _boxBorderSize = Configuration.Settings.Tools.ExportBoxBorderSize; - _previewTimer.Tick += previewTimer_Tick; - _previewTimer.Interval = 100; - labelLineHeightStyle.Text = string.Empty; - } - - private void previewTimer_Tick(object sender, EventArgs e) - { - _previewTimer.Stop(); - GeneratePreview(); - } - - private double FrameRate - { - get - { - if (comboBoxFrameRate.SelectedItem == null) - { - return 25; - } - - string s = comboBoxFrameRate.SelectedItem.ToString(); - s = s.Replace(",", ".").Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, ".").Trim(); - if (double.TryParse(s, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var d)) - { - return d; - } - - return 25; - } - } - - private int MillisecondsToFramesMaxFrameRate(double milliseconds) - { - int frames = (int)Math.Round(milliseconds / (TimeCode.BaseUnit / FrameRate)); - if (frames >= FrameRate) - { - frames = (int)(FrameRate - 0.01); - } - - return frames; - } - - private string ToHHMMSSFF(TimeCode timeCode) - { - return $"{timeCode.Hours:00}:{timeCode.Minutes:00}:{timeCode.Seconds:00}:{MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds):00}"; - } - - private static ContentAlignment GetAlignmentFromParagraph(MakeBitmapParameter p, SubtitleFormat format, Subtitle subtitle) - { - var alignment = ContentAlignment.BottomCenter; - if (p.AlignLeft) - { - alignment = ContentAlignment.BottomLeft; - } - else if (p.AlignRight) - { - alignment = ContentAlignment.BottomRight; - } - - if (format.HasStyleSupport && !string.IsNullOrEmpty(p.P.Extra)) - { - if (format.GetType() == typeof(SubStationAlpha)) - { - var style = AdvancedSubStationAlpha.GetSsaStyle(p.P.Extra, subtitle.Header); - alignment = GetSsaAlignment("{\\a" + style.Alignment + "}", alignment); - } - else if (format.GetType() == typeof(AdvancedSubStationAlpha)) - { - var style = AdvancedSubStationAlpha.GetSsaStyle(p.P.Extra, subtitle.Header); - alignment = GetAssAlignment("{\\an" + style.Alignment + "}", alignment); - } - } - - string text = p.P.Text; - if (format.GetType() == typeof(SubStationAlpha) && text.Length > 5) - { - text = p.P.Text.Substring(0, 6); - alignment = GetSsaAlignment(text, alignment); - } - else if (text.Length > 6) - { - text = p.P.Text.Substring(0, 6); - alignment = GetAssAlignment(text, alignment); - } - return alignment; - } - - private static ContentAlignment GetSsaAlignment(string text, ContentAlignment defaultAlignment) - { - //1: Bottom left - //2: Bottom center - //3: Bottom right - //9: Middle left - //10: Middle center - //11: Middle right - //5: Top left - //6: Top center - //7: Top right - switch (text) - { - case "{\\a1}": - return ContentAlignment.BottomLeft; - case "{\\a2}": - return ContentAlignment.BottomCenter; - case "{\\a3}": - return ContentAlignment.BottomRight; - case "{\\a9}": - return ContentAlignment.MiddleLeft; - case "{\\a10}": - return ContentAlignment.MiddleCenter; - case "{\\a11}": - return ContentAlignment.MiddleRight; - case "{\\a5}": - return ContentAlignment.TopLeft; - case "{\\a6}": - return ContentAlignment.TopCenter; - case "{\\a7}": - return ContentAlignment.TopRight; - } - return defaultAlignment; - } - - private static ContentAlignment GetAssAlignment(string text, ContentAlignment defaultAlignment) - { - //1: Bottom left - //2: Bottom center - //3: Bottom right - //4: Middle left - //5: Middle center - //6: Middle right - //7: Top left - //8: Top center - //9: Top right - switch (text) - { - case "{\\an1}": - return ContentAlignment.BottomLeft; - case "{\\an2}": - return ContentAlignment.BottomCenter; - case "{\\an3}": - return ContentAlignment.BottomRight; - case "{\\an4}": - return ContentAlignment.MiddleLeft; - case "{\\an5}": - return ContentAlignment.MiddleCenter; - case "{\\an6}": - return ContentAlignment.MiddleRight; - case "{\\an7}": - return ContentAlignment.TopLeft; - case "{\\an8}": - return ContentAlignment.TopCenter; - case "{\\an9}": - return ContentAlignment.TopRight; - } - return defaultAlignment; - } - - public static void DoWork(object data) - { - var parameter = (MakeBitmapParameter)data; - - parameter.LineJoin = Configuration.Settings.Tools.ExportPenLineJoin; - parameter.Bitmap = GenerateImageFromTextWithStyle(parameter); - if (parameter.Type == ExportFormats.BluraySup) - { - MakeBluRaySupImage(parameter); - } - } - - internal static void MakeBluRaySupImage(MakeBitmapParameter param) - { - var brSub = new BluRaySupPicture - { - StartTime = (long)param.P.StartTime.TotalMilliseconds, - EndTime = (long)param.P.EndTime.TotalMilliseconds, - Width = param.ScreenWidth, - Height = param.ScreenHeight, - IsForced = param.Forced, - CompositionNumber = param.P.Number * 2 - }; - if (param.FullFrame) - { - var nbmp = new NikseBitmap(param.Bitmap); - nbmp.ReplaceTransparentWith(param.FullFrameBackgroundColor); - using (var bmp = nbmp.GetBitmap()) - { - int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin); - int left = (param.ScreenWidth - param.Bitmap.Width) / 2; - - var b = new NikseBitmap(param.ScreenWidth, param.ScreenHeight); - { - b.Fill(param.FullFrameBackgroundColor); - using (var fullSize = b.GetBitmap()) - { - if (param.Alignment == ContentAlignment.BottomLeft || param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.TopLeft) - { - left = param.LeftMargin; - } - else if (param.Alignment == ContentAlignment.BottomRight || param.Alignment == ContentAlignment.MiddleRight || param.Alignment == ContentAlignment.TopRight) - { - left = param.ScreenWidth - param.Bitmap.Width - param.RightMargin; - } - - if (param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopRight) - { - top = param.BottomMargin; - } - - if (param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.MiddleCenter || param.Alignment == ContentAlignment.MiddleRight) - { - top = param.ScreenHeight - (param.Bitmap.Height / 2); - } - - if (param.OverridePosition != null && - param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.ScreenWidth && - param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.ScreenHeight) - { - left = param.OverridePosition.Value.X; - top = param.OverridePosition.Value.Y; - } - - using (var g = Graphics.FromImage(fullSize)) - { - g.DrawImage(bmp, left, top); - g.Dispose(); - } - param.Buffer = BluRaySupPicture.CreateSupFrame(brSub, fullSize, param.FramesPerSeconds, 0, 0, ContentAlignment.BottomCenter); - } - } - } - } - else - { - if (param.OverridePosition != null && - param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.ScreenWidth && - param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.ScreenHeight) - { - param.LeftMargin = param.OverridePosition.Value.X; - param.BottomMargin = param.ScreenHeight - param.OverridePosition.Value.Y - param.Bitmap.Height; - } - - var margin = (param.Alignment == ContentAlignment.TopRight || - param.Alignment == ContentAlignment.MiddleRight || - param.Alignment == ContentAlignment.BottomRight) - ? param.RightMargin - : param.LeftMargin; - - param.Buffer = BluRaySupPicture.CreateSupFrame(brSub, param.Bitmap, param.FramesPerSeconds, param.BottomMargin, margin, param.Alignment, param.OverridePosition); - } - } - - internal MakeBitmapParameter MakeMakeBitmapParameter(int index, int screenWidth, int screenHeight) - { - var p = _subtitle.GetParagraphOrDefault(index); - var parameter = new MakeBitmapParameter - { - Type = _exportType, - SubtitleColor = _subtitleColor, - SubtitleFontName = _subtitleFontName, - SubtitleFontSize = _subtitleFontSize, - SubtitleFontBold = _subtitleFontBold, - BorderColor = _borderColor, - BorderWidth = _borderWidth, - SimpleRendering = checkBoxSimpleRender.Checked, - AlignLeft = comboBoxHAlign.SelectedIndex == 0, - AlignRight = comboBoxHAlign.SelectedIndex == 2, - JustifyLeft = GetJustifyLeft(p.Text), // center, left justify - JustifyTop = comboBoxHAlign.SelectedIndex == 4, // center, top justify - JustifyRight = comboBoxHAlign.SelectedIndex == 5, // center, right justify - ScreenWidth = screenWidth, - ScreenHeight = screenHeight, - VideoResolution = comboBoxResolution.Text, - Bitmap = null, - FramesPerSeconds = FrameRate, - BottomMargin = GetBottomMarginInPixels(p), - LeftMargin = GetLeftMarginInPixels(p), - RightMargin = GetRightMarginInPixels(p), - Saved = false, - Alignment = ContentAlignment.BottomCenter, - Type3D = comboBox3D.SelectedIndex, - Depth3D = (int)numericUpDownDepth3D.Value, - BackgroundColor = Color.Transparent, - SavDialogFileName = saveFileDialog1.FileName, - ShadowColor = panelShadowColor.BackColor, - ShadowWidth = GetShadowWidth(), - ShadowAlpha = (int)numericUpDownShadowTransparency.Value, - LineHeight = _lineHeights, - FullFrame = checkBoxFullFrameImage.Checked, - FullFrameBackgroundColor = panelFullFrameBackground.BackColor, - }; - if (index < _subtitle.Paragraphs.Count) - { - parameter.P = _subtitle.Paragraphs[index]; - parameter.Alignment = GetAlignmentFromParagraph(parameter, _format, _subtitle); - parameter.OverridePosition = GetAssPoint(parameter.P.Text); - parameter.Forced = subtitleListView1.Items[index].Checked; - - if (_format.HasStyleSupport && !string.IsNullOrEmpty(parameter.P.Extra)) - { - if (_format.GetType() == typeof(SubStationAlpha)) - { - var style = AdvancedSubStationAlpha.GetSsaStyle(parameter.P.Extra, _subtitle.Header); - parameter.SubtitleColor = style.Primary; - parameter.SubtitleFontBold = style.Bold; - parameter.SubtitleFontSize = style.FontSize; - parameter.SubtitleFontName = style.FontName; - parameter.BottomMargin = style.MarginVertical; - if (style.BorderStyle == "3") - { - parameter.BackgroundColor = style.Background; - } - parameter.ShadowColor = style.Outline; - } - else if (_format.GetType() == typeof(AdvancedSubStationAlpha)) - { - var style = AdvancedSubStationAlpha.GetSsaStyle(parameter.P.Extra, _subtitle.Header); - parameter.SubtitleColor = style.Primary; - parameter.SubtitleFontBold = style.Bold; - parameter.SubtitleFontSize = style.FontSize; - parameter.SubtitleFontName = style.FontName; - parameter.BottomMargin = style.MarginVertical; - if (style.BorderStyle == "3") - { - parameter.BackgroundColor = style.Outline; - } - parameter.ShadowAlpha = style.Background.A; - parameter.ShadowColor = style.Background; - } - } - - if (comboBoxBorderWidth.SelectedItem.ToString() == Configuration.Settings.Language.ExportPngXml.BorderStyleBoxForEachLine) - { - parameter.BoxSingleLine = true; - parameter.BackgroundColor = panelBorderColor.BackColor; - parameter.BorderWidth = 0; - } - else if (comboBoxBorderWidth.SelectedItem.ToString() == Configuration.Settings.Language.ExportPngXml.BorderStyleOneBox) - { - parameter.BoxSingleLine = false; - parameter.BackgroundColor = panelBorderColor.BackColor; - parameter.BorderWidth = 0; - } - else - { - _borderWidth = GetBorderWidth(); - } - } - else - { - parameter.P = null; - } - return parameter; - } - - private bool GetJustifyLeft(string text) - { - if (comboBoxHAlign.SelectedIndex == 6 && !string.IsNullOrEmpty(text)) - { - var s = Utilities.RemoveUnneededSpaces(text, _language); - var dialogHelper = new DialogSplitMerge { TwoLetterLanguageCode = _language }; - var lines = s.SplitToLines(); - return dialogHelper.IsDialog(lines) || HasTwoSpeakers(lines); - } - - return comboBoxHAlign.SelectedIndex == 3; - } - - private static bool HasTwoSpeakers(List lines) - { - return lines.Count == 2 && lines[0].HasSentenceEnding() && lines[0].Contains(':') && lines[1].Contains(':'); - } - - private void ButtonExportClick(object sender, EventArgs e) - { - FixStartEndWithSameTimeCode(); - var singleFile = false; - - if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) - { - _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(Configuration.Settings.General.CurrentVideoOffsetInMs)); - } - - var errors = new List(); - buttonExport.Enabled = false; - SetupImageParameters(); - - if (!string.IsNullOrEmpty(_fileName)) - { - saveFileDialog1.FileName = Path.GetFileNameWithoutExtension(_fileName); - } - - if (_exportType == ExportFormats.BluraySup) - { - saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveBluRraySupAs; - saveFileDialog1.DefaultExt = "*.sup"; - saveFileDialog1.AddExtension = true; - saveFileDialog1.Filter = "Blu-Ray sup|*.sup"; - singleFile = true; - } - else if (_exportType == ExportFormats.VobSub) - { - saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveVobSubAs; - saveFileDialog1.DefaultExt = "*.sub"; - saveFileDialog1.AddExtension = true; - saveFileDialog1.Filter = "VobSub|*.sub"; - singleFile = true; - } - else if (_exportType == ExportFormats.Fab) - { - saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveFabImageScriptAs; - saveFileDialog1.DefaultExt = "*.txt"; - saveFileDialog1.AddExtension = true; - saveFileDialog1.Filter = "FAB image scripts|*.txt"; - singleFile = true; - } - else if (_exportType == ExportFormats.Stl) - { - saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveDvdStudioProStlAs; - saveFileDialog1.DefaultExt = "*.txt"; - saveFileDialog1.AddExtension = true; - saveFileDialog1.Filter = "DVD Studio Pro STL|*.stl"; - singleFile = true; - } - else if (_exportType == ExportFormats.Fcp) - { - saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveFcpAs; - saveFileDialog1.DefaultExt = "*.xml"; - saveFileDialog1.AddExtension = true; - saveFileDialog1.Filter = "Xml files|*.xml"; - singleFile = true; - } - else if (_exportType == ExportFormats.Dost) - { - saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveDostAs; - saveFileDialog1.DefaultExt = "*.dost"; - saveFileDialog1.AddExtension = true; - saveFileDialog1.Filter = "Dost files|*.dost"; - singleFile = true; - } - else if (_exportType == ExportFormats.DCinemaInterop) - { - saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveDigitalCinemaInteropAs; - saveFileDialog1.DefaultExt = "*.xml"; - saveFileDialog1.AddExtension = true; - saveFileDialog1.Filter = "Xml files|*.xml"; - singleFile = true; - } - else if (_exportType == ExportFormats.DCinemaSmpte2014) - { - saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveDigitalCinemaSmpte2014; - saveFileDialog1.DefaultExt = "*.xml"; - saveFileDialog1.AddExtension = true; - saveFileDialog1.Filter = "Xml files|*.xml"; - singleFile = true; - } - else if (_exportType == ExportFormats.Edl || _exportType == ExportFormats.EdlClipName) - { - saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SavePremiereEdlAs; - saveFileDialog1.DefaultExt = "*.edl"; - saveFileDialog1.AddExtension = true; - saveFileDialog1.Filter = "EDL files|*.edl"; - singleFile = true; - } - - if (singleFile && saveFileDialog1.ShowDialog(this) == DialogResult.OK || !singleFile && folderBrowserDialog1.ShowDialog(this) == DialogResult.OK) - { - GetResolution(out var width, out var height); - - _outputFileName = singleFile ? saveFileDialog1.FileName : folderBrowserDialog1.SelectedPath; - - FileStream binarySubtitleFile = null; - VobSubWriter vobSubWriter = null; - Paragraph p = null; - if (subtitleListView1.SelectedItems.Count > 0) - { - p = _subtitle.GetParagraphOrDefault(subtitleListView1.SelectedItems[0].Index); - } - - if (_exportType == ExportFormats.BluraySup) - { - binarySubtitleFile = new FileStream(saveFileDialog1.FileName, FileMode.Create); - } - else if (_exportType == ExportFormats.VobSub) - { - vobSubWriter = new VobSubWriter(saveFileDialog1.FileName, width, height, GetBottomMarginInPixels(p), GetLeftMarginInPixels(p), 32, _subtitleColor, _borderColor, !checkBoxTransAntiAliase.Checked, (DvdSubtitleLanguage)comboBoxLanguage.SelectedItem); - } - - progressBar1.Value = 0; - progressBar1.Maximum = _subtitle.Paragraphs.Count - 1; - progressBar1.Visible = true; - _previewTimer.Tick -= previewTimer_Tick; - - int border = GetBottomMarginInPixels(p); - int imagesSavedCount = 0; - var sb = new StringBuilder(); - if (_exportType == ExportFormats.Stl) - { - sb.AppendLine("$SetFilePathToken =" + folderBrowserDialog1.SelectedPath); - sb.AppendLine(); - } - - if (_vobSubOcr != null) - { - int i = 0; - while (i < _subtitle.Paragraphs.Count) - { - var mp = MakeMakeBitmapParameter(i, width, height); - mp.Bitmap = _vobSubOcr.GetSubtitleBitmap(i++); - var exp = GetResizeScale(); - if (Math.Abs(exp - 1) > 0.01) - { - var resizedBitmap = ResizeBitmap(mp.Bitmap, (int)Math.Round(mp.Bitmap.Width * exp), (int)Math.Round(mp.Bitmap.Height * exp)); - mp.Bitmap.Dispose(); - mp.Bitmap = resizedBitmap; - } - if (_exportType == ExportFormats.BluraySup) - { - MakeBluRaySupImage(mp); - } - imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, mp, i); - progressBar1.Refresh(); - Application.DoEvents(); - if (i < progressBar1.Maximum) - { - progressBar1.Value = i; - } - } - } - else - { - var threadEqual = new Thread(DoWork); - var paramEqual = MakeMakeBitmapParameter(0, width, height); - - var threadUnEqual = new Thread(DoWork); - var paramUnEqual = new MakeBitmapParameter(); - if (_subtitle.Paragraphs.Count > 1) - { - MakeMakeBitmapParameter(1, width, height); - } - - threadEqual.Start(paramEqual); - int i = 1; - for (; i < _subtitle.Paragraphs.Count; i++) - { - if (i % 2 == 0) - { - paramEqual = MakeMakeBitmapParameter(i, width, height); - threadEqual = new Thread(DoWork); - threadEqual.Start(paramEqual); - - if (threadUnEqual.ThreadState == ThreadState.Running) - { - threadUnEqual.Join(); - } - - imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, paramUnEqual, i); - if (!string.IsNullOrEmpty(paramUnEqual.Error)) - { - errors.Add(paramUnEqual.Error); - } - } - else - { - paramUnEqual = MakeMakeBitmapParameter(i, width, height); - threadUnEqual = new Thread(DoWork); - threadUnEqual.Start(paramUnEqual); - - if (threadEqual.ThreadState == ThreadState.Running) - { - threadEqual.Join(); - } - - imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, paramEqual, i); - if (!string.IsNullOrEmpty(paramEqual.Error)) - { - errors.Add(paramEqual.Error); - } - } - progressBar1.Refresh(); - Application.DoEvents(); - progressBar1.Value = i; - } - - if (i % 2 == 0) - { - if (threadEqual.ThreadState == ThreadState.Running) - { - threadEqual.Join(); - } - - imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, paramEqual, i); - if (threadUnEqual.ThreadState == ThreadState.Running) - { - threadUnEqual.Join(); - } - - imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, paramUnEqual, i); - } - else - { - if (threadUnEqual.ThreadState == ThreadState.Running) - { - threadUnEqual.Join(); - } - - imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, paramUnEqual, i); - if (threadEqual.ThreadState == ThreadState.Running) - { - threadEqual.Join(); - } - - imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, paramEqual, i); - } - } - - if (errors.Count > 0) - { - var errorSb = new StringBuilder(); - for (int i = 0; i < 20; i++) - { - if (i < errors.Count) - { - errorSb.AppendLine(errors[i]); - } - } - if (errors.Count > 20) - { - errorSb.AppendLine("..."); - } - - MessageBox.Show(string.Format(Configuration.Settings.Language.ExportPngXml.SomeLinesWereTooLongX, errorSb)); - } - - _previewTimer.Tick += previewTimer_Tick; - progressBar1.Visible = false; - if (_exportType == ExportFormats.BluraySup) - { - binarySubtitleFile.Close(); - MessageBox.Show(string.Format(Configuration.Settings.Language.Main.SavedSubtitleX, saveFileDialog1.FileName)); - } - else if (_exportType == ExportFormats.VobSub) - { - vobSubWriter.WriteIdxFile(); - vobSubWriter.Dispose(); - MessageBox.Show(string.Format(Configuration.Settings.Language.Main.SavedSubtitleX, saveFileDialog1.FileName)); - } - else if (_exportType == ExportFormats.Fab) - { - File.WriteAllText(Path.Combine(folderBrowserDialog1.SelectedPath, "Fab_Image_script.txt"), sb.ToString()); - var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, folderBrowserDialog1.SelectedPath); - MessageBoxShowWithFolderName(text, folderBrowserDialog1.SelectedPath); - } - else if (_exportType == ExportFormats.ImageFrame) - { - var empty = new Bitmap(width, height); - imagesSavedCount++; - string numberString = $"{imagesSavedCount:00000}"; - string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant()); - SaveImage(empty, fileName, ImageFormat); - var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, folderBrowserDialog1.SelectedPath); - MessageBoxShowWithFolderName(text, folderBrowserDialog1.SelectedPath); - } - else if (_exportType == ExportFormats.Stl) - { - File.WriteAllText(Path.Combine(folderBrowserDialog1.SelectedPath, "DVD_Studio_Pro_Image_script.stl"), sb.ToString()); - var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, folderBrowserDialog1.SelectedPath); - MessageBoxShowWithFolderName(text, folderBrowserDialog1.SelectedPath); - } - else if (_exportType == ExportFormats.Spumux) - { - string s = "" + Environment.NewLine + - "\t" + Environment.NewLine + - sb + - "\t" + Environment.NewLine + - ""; - File.WriteAllText(Path.Combine(folderBrowserDialog1.SelectedPath, "spu.xml"), s); - var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, folderBrowserDialog1.SelectedPath); - MessageBoxShowWithFolderName(text, folderBrowserDialog1.SelectedPath); - } - else if (_exportType == ExportFormats.Fcp) - { - WriteFcpFile(width, height, sb, saveFileDialog1.FileName); - var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, Path.GetDirectoryName(saveFileDialog1.FileName)); - MessageBoxShowWithFolderName(text, Path.GetDirectoryName(saveFileDialog1.FileName)); - } - else if (_exportType == ExportFormats.Dost) - { - WriteDostFile(saveFileDialog1.FileName, sb.ToString()); - var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, Path.GetDirectoryName(saveFileDialog1.FileName)); - MessageBoxShowWithFolderName(text, Path.GetDirectoryName(saveFileDialog1.FileName)); - } - else if (_exportType == ExportFormats.DCinemaInterop) - { - var doc = new XmlDocument(); - string title = "unknown"; - if (!string.IsNullOrEmpty(_fileName)) - { - title = Path.GetFileNameWithoutExtension(_fileName); - } - - string guid = Guid.NewGuid().ToString().RemoveChar('-').Insert(8, "-").Insert(13, "-").Insert(18, "-").Insert(23, "-"); - doc.LoadXml("" + Environment.NewLine + - "" + Environment.NewLine + - "" + guid + "" + Environment.NewLine + - "" + title + "" + Environment.NewLine + - "1" + Environment.NewLine + - "English" + Environment.NewLine + - sb + - ""); - string fName = saveFileDialog1.FileName; - if (!fName.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)) - { - fName += ".xml"; - } - - File.WriteAllText(fName, SubtitleFormat.ToUtf8XmlString(doc)); - var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, Path.GetDirectoryName(fName)); - MessageBoxShowWithFolderName(text, Path.GetDirectoryName(fName)); - } - else if (_exportType == ExportFormats.DCinemaSmpte2014) - { - var doc = new XmlDocument(); - string title = "unknown"; - if (!string.IsNullOrEmpty(_fileName)) - { - title = Path.GetFileNameWithoutExtension(_fileName); - } - - string guid = Guid.NewGuid().ToString().RemoveChar('-').Insert(8, "-").Insert(13, "-").Insert(18, "-").Insert(23, "-"); - string xml = - "" + Environment.NewLine + - " urn:uuid:" + guid + "" + Environment.NewLine + - " " + Environment.NewLine + - " This is a subtitle file" + Environment.NewLine + - " 2014-01-01T00:00:00.000-00:00" + Environment.NewLine + - " 1" + Environment.NewLine + - " en" + Environment.NewLine + - " 25 1" + Environment.NewLine + - " 25" + Environment.NewLine + - " 00:00:00:00 " + Environment.NewLine + - " urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391" + Environment.NewLine + - " " + Environment.NewLine + - sb + - " " + Environment.NewLine + - ""; - - - doc.LoadXml(xml); - string fName = saveFileDialog1.FileName; - if (!fName.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)) - { - fName += ".xml"; - } - - File.WriteAllText(fName, SubtitleFormat.ToUtf8XmlString(doc)); - var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, Path.GetDirectoryName(fName)); - MessageBoxShowWithFolderName(text, Path.GetDirectoryName(fName)); - } - else if (_exportType == ExportFormats.Edl || _exportType == ExportFormats.EdlClipName) - { - var title = Path.GetFileNameWithoutExtension(saveFileDialog1.FileName); - if (string.IsNullOrEmpty(title)) - { - title = "( no title )"; - } - - string header = "TITLE: " + title + Environment.NewLine + Environment.NewLine; - File.WriteAllText(saveFileDialog1.FileName, header + sb); - var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, Path.GetDirectoryName(saveFileDialog1.FileName)); - MessageBoxShowWithFolderName(text, Path.GetDirectoryName(saveFileDialog1.FileName)); - } - else - { - WriteBdnXmlFile(imagesSavedCount, sb, Path.Combine(folderBrowserDialog1.SelectedPath, "BDN_Index.xml")); - var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, folderBrowserDialog1.SelectedPath); - MessageBoxShowWithFolderName(text, folderBrowserDialog1.SelectedPath); - } - } - buttonExport.Enabled = true; - - if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) - { - _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-Configuration.Settings.General.CurrentVideoOffsetInMs)); - } - } - - private void MessageBoxShowWithFolderName(string text, string folderName) - { - using (var f = new ExportPngXmlDialogOpenFolder(text, folderName)) - { - f.ShowDialog(this); - } - } - - internal void WriteFcpFile(int width, int height, StringBuilder sb, string fileName) - { - string fileNameNoPath = Path.GetFileName(fileName); - string fileNameNoExt = Path.GetFileNameWithoutExtension(fileNameNoPath); - - int duration = 0; - if (_subtitle.Paragraphs.Count > 0) - { - duration = (int)Math.Round(_subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1].EndTime.TotalSeconds * 25.0); - } - - string s = "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - " " + Environment.NewLine + - " add" + Environment.NewLine + - " " + System.Security.SecurityElement.Escape(fileNameNoExt) + @" - " + duration.ToString(CultureInfo.InvariantCulture) + @" - - FALSE - 25 - - - - FALSE - 25 - - 00:00:00:00 - 0 - source - NDF - - 0 - [OUT] - - - - - FALSE - -"; - if (comboBoxFrameRate.Text == "29.97") - { - s = s.Replace("NDF", "DF"); //Non Drop Frame or Drop Frame - s = s.Replace("25", "30"); - s = s.Replace("FALSE", "TRUE"); - } - else if (comboBoxFrameRate.Text == "23.976") - { - s = s.Replace("NDF", "DF"); //Non Drop Frame or Drop Frame - s = s.Replace("25", "24"); - s = s.Replace("FALSE", "TRUE"); - } - else if (comboBoxFrameRate.Text == "59.94") - { - s = s.Replace("NDF", "DF"); //Non Drop Frame or Drop Frame - s = s.Replace("25", "60"); - s = s.Replace("FALSE", "TRUE"); - } - - else - { - s = s.Replace("25", "" + comboBoxFrameRate.Text + ""); - } - - if (_subtitle.Paragraphs.Count > 0) - { - var end = SubtitleFormat.MillisecondsToFrames(_subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds, FrameRate); - end++; - s = s.Replace("[OUT]", end.ToString(CultureInfo.InvariantCulture)); - } - - if (comboBoxLanguage.Text == "NTSC") - { - s = s.Replace("FALSE", "TRUE"); - } - - s = s.Replace("1920", "" + width.ToString(CultureInfo.InvariantCulture) + ""); - s = s.Replace("1080", "" + height.ToString(CultureInfo.InvariantCulture) + ""); - - if (comboBoxImageFormat.Text.Contains("8-bit")) - { - s = s.Replace("32", "8"); - } - - File.WriteAllText(fileName, s); - } - - internal void WriteBdnXmlFile(int imagesSavedCount, StringBuilder sb, string fileName) - { - GetResolution(out var resW, out var resH); - string videoFormat = "1080p"; - if (resW == 1920 && resH == 1080) - { - videoFormat = "1080p"; - } - else if (resW == 1280 && resH == 720) - { - videoFormat = "720p"; - } - else if (resW == 848 && resH == 480) - { - videoFormat = "480p"; - } - else if (resW > 0 && resH > 0) - { - videoFormat = resW + "x" + resH; - } - - var doc = new XmlDocument(); - Paragraph first = _subtitle.Paragraphs[0]; - Paragraph last = _subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1]; - doc.LoadXml("" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - ""); - XmlNode events = doc.DocumentElement.SelectSingleNode("Events"); - doc.PreserveWhitespace = true; - events.InnerXml = sb.ToString(); - File.WriteAllText(fileName, FormatUtf8Xml(doc), Encoding.UTF8); - } - - internal void WriteDostFile(string fileName, string body) - { - string header = @"$FORMAT=480 -$VERSION=1.2 -$ULEAD=TRUE -$DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + - "NO\tINTIME\t\tOUTTIME\t\tXPOS\tYPOS\tFILENAME\tFADEIN\tFADEOUT"; - - string dropValue = "30000"; - if (comboBoxFrameRate.SelectedIndex == -1) - { - var numberAsString = comboBoxFrameRate.Text.Trim().RemoveChar('.').RemoveChar(',').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, string.Empty); - if (numberAsString.Length > 0 && Utilities.IsInteger(numberAsString)) - { - dropValue = numberAsString; - } - } - else if (comboBoxFrameRate.Items[comboBoxFrameRate.SelectedIndex].ToString() == "23.98") - { - dropValue = "23976"; - } - else if (comboBoxFrameRate.Items[comboBoxFrameRate.SelectedIndex].ToString() == "24") - { - dropValue = "24000"; - } - else if (comboBoxFrameRate.Items[comboBoxFrameRate.SelectedIndex].ToString() == "25") - { - dropValue = "25000"; - } - else if (comboBoxFrameRate.Items[comboBoxFrameRate.SelectedIndex].ToString() == "29.97") - { - dropValue = "29970"; - } - else if (comboBoxFrameRate.Items[comboBoxFrameRate.SelectedIndex].ToString() == "30") - { - dropValue = "30000"; - } - else if (comboBoxFrameRate.Items[comboBoxFrameRate.SelectedIndex].ToString() == "59.94") - { - dropValue = "59940"; - } - - header = header.Replace("[DROPVALUE]", dropValue); - comboBoxFrameRate.SelectedIndex = 0; - - File.WriteAllText(fileName, header + Environment.NewLine + body); - } - - private static string FormatUtf8Xml(XmlDocument doc) - { - var sb = new StringBuilder(); - using (var writer = XmlWriter.Create(sb, new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8 })) - { - doc.Save(writer); - } - return sb.ToString().Replace(" encoding=\"utf-16\"", " encoding=\"utf-8\"").Trim(); // "replace hack" due to missing encoding (encoding only works if it's the only parameter...) - } - - private void SaveImage(Bitmap bmp, string fileName, ImageFormat imageFormat) - { - if (Equals(imageFormat, ImageFormat.Icon)) - { - var nikseBitmap = new NikseBitmap(bmp); - nikseBitmap.SaveAsTarga(fileName); - } - else - { - bmp.Save(fileName, imageFormat); - } - } - - private void FixStartEndWithSameTimeCode() - { - for (int i = 0; i < _subtitle.Paragraphs.Count - 1; i++) - { - Paragraph p = _subtitle.Paragraphs[i]; - Paragraph next = _subtitle.Paragraphs[i + 1]; - if (Math.Abs(p.EndTime.TotalMilliseconds - next.StartTime.TotalMilliseconds) < 0.1) - { - p.EndTime.TotalMilliseconds--; - } - } - } - - private void SetResolution(string inputXAndY) - { - if (string.IsNullOrEmpty(inputXAndY)) - { - return; - } - - var xAndY = inputXAndY.ToLowerInvariant(); - - if (_exportType == ExportFormats.Fcp) - { - switch (xAndY) - { - case "720x480": - xAndY = "NTSC-601"; - break; - case "720x576": - xAndY = "PAL-601"; - break; - case "640x480": - xAndY = "square"; - break; - case "1280x720": - xAndY = "DVCPROHD-720P"; - break; - case "960x720": - xAndY = "HD-(960x720)"; - break; - case "1920x1080": - xAndY = "FullHD 1920x1080"; - break; - case "1280x1080": - xAndY = "HD-(1280x1080)"; - break; - case "1440x1080": - xAndY = "HD-(1440x1080)"; - break; - } - } - - if (_exportType == ExportFormats.Fcp || Regex.IsMatch(xAndY, @"\d+x\d+", RegexOptions.IgnoreCase)) - { - for (int i = 0; i < comboBoxResolution.Items.Count; i++) - { - if (comboBoxResolution.Items[i].ToString().Contains(xAndY)) - { - comboBoxResolution.SelectedIndex = i; - return; - } - } - comboBoxResolution.Items[comboBoxResolution.Items.Count - 1] = xAndY; - comboBoxResolution.SelectedIndex = comboBoxResolution.Items.Count - 1; - } - } - - private void GetResolution(out int width, out int height) - { - width = 1920; - height = 1080; - if (comboBoxResolution.SelectedIndex < 0) - { - return; - } - - string text = comboBoxResolution.Text.Trim(); - - if (_exportType == ExportFormats.Fcp) - { - if (text == "NTSC-601") - { - width = 720; - height = 480; - return; - } - - if (text == "PAL-601") - { - width = 720; - height = 576; - return; - } - - if (text == "square") - { - width = 640; - height = 480; - return; - } - - if (text == "DVCPROHD-720P") - { - width = 1280; - height = 720; - return; - } - - if (text == "HD-(960x720)") - { - width = 960; - height = 720; - return; - } - - if (text == "FullHD 1920x1080") - { - width = 1920; - height = 1080; - return; - } - - if (text == "DVCPROHD-1080i60") - { - width = 1920; - height = 1080; - return; - } - - if (text == "HD-(1280x1080)") - { - width = 1280; - height = 1080; - return; - } - - if (text == "DVCPROHD-1080i50") - { - width = 1920; - height = 1080; - return; - } - - if (text == "HD-(1440x1080)") - { - width = 1440; - height = 1080; - return; - } - } - - if (text.Contains('(')) - { - text = text.Remove(0, text.IndexOf('(')).Trim(); - } - - text = text.TrimStart('(').TrimEnd(')').Trim(); - string[] arr = text.Split('x'); - width = int.Parse(arr[0]); - height = int.Parse(arr[1]); - } - - private int WriteParagraph(int width, StringBuilder sb, int border, int height, int imagesSavedCount, VobSubWriter vobSubWriter, FileStream binarySubtitleFile, MakeBitmapParameter param, int i) - { - if (param.Bitmap != null) - { - if (_exportType == ExportFormats.BluraySup) - { - if (!param.Saved) - { - binarySubtitleFile.Write(param.Buffer, 0, param.Buffer.Length); - } - param.Saved = true; - } - else if (_exportType == ExportFormats.VobSub) - { - if (!param.Saved) - { - vobSubWriter.WriteParagraph(param.P, param.Bitmap, param.Alignment); - } - - param.Saved = true; - } - else if (_exportType == ExportFormats.Fab) - { - if (!param.Saved) - { - string numberString = $"IMAGE{i:000}"; - string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant()); - - if (checkBoxFullFrameImage.Checked) - { - var nbmp = new NikseBitmap(param.Bitmap); - nbmp.ReplaceTransparentWith(panelFullFrameBackground.BackColor); - using (var bmp = nbmp.GetBitmap()) - { - imagesSavedCount++; - - //RACE001.TIF 00;00;02;02 00;00;03;15 000 000 720 480 - //RACE002.TIF 00;00;05;18 00;00;09;20 000 000 720 480 - int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin); - int left = (param.ScreenWidth - param.Bitmap.Width) / 2; - - var b = new NikseBitmap(param.ScreenWidth, param.ScreenHeight); - { - b.Fill(panelFullFrameBackground.BackColor); - using (var fullSize = b.GetBitmap()) - { - if (param.Alignment == ContentAlignment.BottomLeft || param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.TopLeft) - { - left = param.LeftMargin; - } - else if (param.Alignment == ContentAlignment.BottomRight || param.Alignment == ContentAlignment.MiddleRight || param.Alignment == ContentAlignment.TopRight) - { - left = param.ScreenWidth - param.Bitmap.Width - param.RightMargin; - } - - if (param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopRight) - { - top = param.BottomMargin; - } - - if (param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.MiddleCenter || param.Alignment == ContentAlignment.MiddleRight) - { - top = (param.ScreenHeight - param.Bitmap.Height) / 2; - } - - if (param.OverridePosition.HasValue && - param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.Bitmap.Width && - param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.Bitmap.Height) - { - left = param.OverridePosition.Value.X; - top = param.OverridePosition.Value.Y; - } - - using (var g = Graphics.FromImage(fullSize)) - { - g.DrawImage(bmp, left, top); - g.Dispose(); - } - SaveImage(fullSize, fileName, ImageFormat); - } - } - left = 0; - top = 0; - sb.AppendLine($"{Path.GetFileName(fileName)} {FormatFabTime(param.P.StartTime, param)} {FormatFabTime(param.P.EndTime, param)} {left} {top} {left + param.ScreenWidth} {top + param.ScreenHeight}"); - } - } - else - { - SaveImage(param.Bitmap, fileName, ImageFormat); - - imagesSavedCount++; - - //RACE001.TIF 00;00;02;02 00;00;03;15 000 000 720 480 - //RACE002.TIF 00;00;05;18 00;00;09;20 000 000 720 480 - int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin); - int left = (param.ScreenWidth - param.Bitmap.Width) / 2; - - if (param.Alignment == ContentAlignment.BottomLeft || param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.TopLeft) - { - left = param.LeftMargin; - } - else if (param.Alignment == ContentAlignment.BottomRight || param.Alignment == ContentAlignment.MiddleRight || param.Alignment == ContentAlignment.TopRight) - { - left = param.ScreenWidth - param.Bitmap.Width - param.RightMargin; - } - - if (param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopRight) - { - top = param.BottomMargin; - } - - if (param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.MiddleCenter || param.Alignment == ContentAlignment.MiddleRight) - { - top = (param.ScreenHeight - param.Bitmap.Height) / 2; - } - - if (param.OverridePosition.HasValue && - param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.Bitmap.Width && - param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.Bitmap.Height) - { - left = param.OverridePosition.Value.X; - top = param.OverridePosition.Value.Y; - } - - sb.AppendLine($"{Path.GetFileName(fileName)} {FormatFabTime(param.P.StartTime, param)} {FormatFabTime(param.P.EndTime, param)} {left} {top} {left + param.Bitmap.Width} {top + param.Bitmap.Height}"); - } - param.Saved = true; - } - } - else if (_exportType == ExportFormats.Stl) - { - if (!param.Saved) - { - string numberString = $"IMAGE{i:000}"; - string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant()); - SaveImage(param.Bitmap, fileName, ImageFormat); - - imagesSavedCount++; - - const string paragraphWriteFormat = "{0} , {1} , {2}\r\n"; - const string timeFormat = "{0:00}:{1:00}:{2:00}:{3:00}"; - - double factor = TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate; - string startTime = string.Format(timeFormat, param.P.StartTime.Hours, param.P.StartTime.Minutes, param.P.StartTime.Seconds, (int)Math.Round(param.P.StartTime.Milliseconds / factor)); - string endTime = string.Format(timeFormat, param.P.EndTime.Hours, param.P.EndTime.Minutes, param.P.EndTime.Seconds, (int)Math.Round(param.P.EndTime.Milliseconds / factor)); - sb.AppendFormat(paragraphWriteFormat, startTime, endTime, fileName); - - param.Saved = true; - } - } - else if (_exportType == ExportFormats.Spumux) - { - if (!param.Saved) - { - string numberString = $"IMAGE{i:000}"; - string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant()); - foreach (var encoder in ImageCodecInfo.GetImageEncoders()) - { - if (encoder.FormatID == ImageFormat.Png.Guid) - { - var parameters = new EncoderParameters { Param = { [0] = new EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 4) } }; - - var nbmp = new NikseBitmap(param.Bitmap); - var b = nbmp.ConvertTo8BitsPerPixel(); - b.Save(fileName, encoder, parameters); - b.Dispose(); - - break; - } - } - imagesSavedCount++; - - const string paragraphWriteFormat = "\t\t"; - const string timeFormat = "{0:00}:{1:00}:{2:00}.{3:00}"; - - double factor = TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate; - string startTime = string.Format(timeFormat, param.P.StartTime.Hours, param.P.StartTime.Minutes, param.P.StartTime.Seconds, (int)Math.Round(param.P.StartTime.Milliseconds / factor)); - string endTime = string.Format(timeFormat, param.P.EndTime.Hours, param.P.EndTime.Minutes, param.P.EndTime.Seconds, (int)Math.Round(param.P.EndTime.Milliseconds / factor)); - int left = (param.ScreenWidth - param.Bitmap.Width) / 2; - if (param.Alignment == ContentAlignment.BottomLeft || param.Alignment == ContentAlignment.TopLeft) - { - left = param.LeftMargin; - } - else if (param.Alignment == ContentAlignment.BottomRight || param.Alignment == ContentAlignment.TopRight) - { - left = param.ScreenWidth - param.Bitmap.Width - param.LeftMargin; - } - int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin); - if (param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopRight) - { - top = param.BottomMargin; - } - sb.AppendLine(string.Format(paragraphWriteFormat, startTime, endTime, fileName, left, top)); - - param.Saved = true; - } - } - else if (_exportType == ExportFormats.Fcp) - { - if (!param.Saved) - { - imagesSavedCount = WriteFcpParagraph(sb, imagesSavedCount, param, i, saveFileDialog1.FileName); - - param.Saved = true; - } - } - else if (_exportType == ExportFormats.Dost) - { - if (!param.Saved) - { - imagesSavedCount = WriteParagraphDost(sb, imagesSavedCount, param, i, saveFileDialog1.FileName); - param.Saved = true; - } - } - else if (_exportType == ExportFormats.ImageFrame) - { - if (!param.Saved) - { - var imageFormat = ImageFormat; - - int lastFrame = imagesSavedCount; - int startFrame = (int)Math.Round(param.P.StartTime.TotalMilliseconds / (TimeCode.BaseUnit / param.FramesPerSeconds)); - var empty = new Bitmap(param.ScreenWidth, param.ScreenHeight); - - if (imagesSavedCount != 0 || !checkBoxSkipEmptyFrameAtStart.Checked) - { - // Save empty picture for each frame up to start frame - for (int k = lastFrame + 1; k < startFrame; k++) - { - string numberString = $"{k:00000}"; - string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant()); - empty.Save(fileName, imageFormat); - imagesSavedCount++; - } - } - - int endFrame = (int)Math.Round(param.P.EndTime.TotalMilliseconds / (TimeCode.BaseUnit / param.FramesPerSeconds)); - var fullSize = new Bitmap(param.ScreenWidth, param.ScreenHeight); - Graphics g = Graphics.FromImage(fullSize); - g.DrawImage(param.Bitmap, (param.ScreenWidth - param.Bitmap.Width) / 2, param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin)); - g.Dispose(); - - if (imagesSavedCount > startFrame) - { - startFrame = imagesSavedCount; // no overlapping - } - - // Save sub picture for each frame in duration - for (int k = startFrame; k <= endFrame; k++) - { - string numberString = $"{k:00000}"; - string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant()); - fullSize.Save(fileName, imageFormat); - imagesSavedCount++; - } - fullSize.Dispose(); - param.Saved = true; - } - } - else if (_exportType == ExportFormats.DCinemaInterop) - { - if (!param.Saved) - { - string numberString = $"{i:0000}"; - string fileName = Path.Combine(Path.GetDirectoryName(saveFileDialog1.FileName), numberString + ".png"); - param.Bitmap.Save(fileName, ImageFormat.Png); - imagesSavedCount++; - param.Saved = true; - - string verticalAlignment = "bottom"; - string horizontalAlignment = "center"; - string vPos = "9.7"; - string hPos = "0"; - - switch (param.Alignment) - { - case ContentAlignment.BottomLeft: - verticalAlignment = "bottom"; - horizontalAlignment = "left"; - hPos = "10"; - break; - case ContentAlignment.BottomRight: - verticalAlignment = "bottom"; - horizontalAlignment = "right"; - hPos = "10"; - break; - case ContentAlignment.MiddleCenter: - verticalAlignment = "center"; - vPos = "0"; - break; - case ContentAlignment.MiddleLeft: - verticalAlignment = "center"; - horizontalAlignment = "left"; - hPos = "10"; - vPos = "0"; - break; - case ContentAlignment.MiddleRight: - verticalAlignment = "center"; - horizontalAlignment = "right"; - hPos = "10"; - vPos = "0"; - break; - case ContentAlignment.TopCenter: - verticalAlignment = "top"; - break; - case ContentAlignment.TopLeft: - verticalAlignment = "top"; - horizontalAlignment = "left"; - hPos = "10"; - break; - case ContentAlignment.TopRight: - verticalAlignment = "top"; - horizontalAlignment = "right"; - hPos = "10"; - break; - } - - sb.AppendLine(""); - if (param.Depth3D == 0) - { - sb.AppendLine("" + numberString + ".png" + ""); - } - else - { - sb.AppendLine("" + numberString + ".png" + ""); - } - - sb.AppendLine(""); - } - } - else if (_exportType == ExportFormats.DCinemaSmpte2014) - { - if (!param.Saved) - { - string numberString = $"{i:0000}"; - string fileName = Path.Combine(Path.GetDirectoryName(saveFileDialog1.FileName), numberString + ".png"); - param.Bitmap.Save(fileName, ImageFormat.Png); - imagesSavedCount++; - param.Saved = true; - - string verticalAlignment = "bottom"; - string horizontalAlignment = "center"; - string vPos = "9.7"; - string hPos = "0"; - - switch (param.Alignment) - { - case ContentAlignment.BottomLeft: - verticalAlignment = "bottom"; - horizontalAlignment = "left"; - hPos = "10"; - break; - case ContentAlignment.BottomRight: - verticalAlignment = "bottom"; - horizontalAlignment = "right"; - hPos = "10"; - break; - case ContentAlignment.MiddleCenter: - verticalAlignment = "center"; - vPos = "0"; - break; - case ContentAlignment.MiddleLeft: - verticalAlignment = "center"; - horizontalAlignment = "left"; - hPos = "10"; - vPos = "0"; - break; - case ContentAlignment.MiddleRight: - verticalAlignment = "center"; - horizontalAlignment = "right"; - hPos = "10"; - vPos = "0"; - break; - case ContentAlignment.TopCenter: - verticalAlignment = "top"; - break; - case ContentAlignment.TopLeft: - verticalAlignment = "top"; - horizontalAlignment = "left"; - hPos = "10"; - break; - case ContentAlignment.TopRight: - verticalAlignment = "top"; - horizontalAlignment = "right"; - hPos = "10"; - break; - } - - sb.AppendLine(""); - if (param.Depth3D == 0) - { - sb.AppendLine("" + numberString + ".png" + ""); - } - else - { - sb.AppendLine("" + numberString + ".png" + ""); - } - - sb.AppendLine(""); - } - } - else if (_exportType == ExportFormats.Edl || _exportType == ExportFormats.EdlClipName) - { - if (!param.Saved) - { - // 001 7M6C7986 V C 14:14:55:21 14:15:16:24 01:00:10:18 01:00:31:21 - var fileName1 = "IMG" + i.ToString(CultureInfo.InvariantCulture).PadLeft(5, '0'); - - var fullSize = new Bitmap(param.ScreenWidth, param.ScreenHeight); - using (var g = Graphics.FromImage(fullSize)) - { - g.DrawImage(param.Bitmap, (param.ScreenWidth - param.Bitmap.Width) / 2, param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin)); - } - var fileName2 = Path.Combine(Path.GetDirectoryName(param.SavDialogFileName), fileName1 + ".PNG"); - fullSize.Save(fileName2, ImageFormat.Png); - fullSize.Dispose(); - - string line = $"{i:000} {fileName1} V C {new TimeCode().ToHHMMSSFF()} {param.P.Duration.ToHHMMSSFF()} {param.P.StartTime.ToHHMMSSFF()} {param.P.EndTime.ToHHMMSSFF()}"; - sb.AppendLine(line); - if (_exportType == ExportFormats.EdlClipName) - { - sb.AppendLine("* FROM CLIP NAME: " + fileName1 + ".PNG"); - } - sb.AppendLine(); - - imagesSavedCount++; - param.Saved = true; - } - } - else // BDNXML - { - if (!param.Saved) - { - imagesSavedCount = WriteBdnXmlParagraph(width, sb, border, height, imagesSavedCount, param, i, folderBrowserDialog1.SelectedPath); - param.Saved = true; - } - } - } - return imagesSavedCount; - } - - internal int WriteFcpParagraph(StringBuilder sb, int imagesSavedCount, MakeBitmapParameter param, int i, string fileName) - { - string numberString = string.Format(Path.GetFileNameWithoutExtension(Path.GetFileName(fileName)) + "{0:0000}", i).RemoveChar(' '); - var fileNameShort = numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant(); - var targetImageFileName = Path.Combine(Path.GetDirectoryName(fileName), fileNameShort); - string fileNameNoPath = Path.GetFileName(fileNameShort); - string fileNameNoExt = Path.GetFileNameWithoutExtension(fileNameNoPath); - string pathUrl = "file://localhost/" + targetImageFileName.Replace("\\", "/").Replace(" ", "%20"); - if (!checkBoxFcpFullPathUrl.Checked) - { - pathUrl = fileNameShort; - } - - string template = " " + Environment.NewLine + -@" " + System.Security.SecurityElement.Escape(fileNameNoPath) + @" - [DURATION] - - [TIMEBASE] - [NTSC] - - [IN] - [OUT] - [START] - [END] - " + param.VideoResolution + @" - TRUE - FALSE - straight - " + System.Security.SecurityElement.Escape(fileNameNoPath) + @"1" + Environment.NewLine + - " " + @" - " + System.Security.SecurityElement.Escape(fileNameNoPath) + @" - " + pathUrl + @" - - [TIMEBASE] - [NTSC] - - [DURATION] - " + param.ScreenWidth + @" - " + param.ScreenHeight + @" - - - - - - video - - none - "; - - var outBitmap = param.Bitmap; - if (checkBoxFullFrameImage.Checked) - { - var nbmp = new NikseBitmap(param.Bitmap); - nbmp.ReplaceTransparentWith(panelFullFrameBackground.BackColor); - using (var bmp = nbmp.GetBitmap()) - { - int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin); - int left = (param.ScreenWidth - param.Bitmap.Width) / 2; - - var b = new NikseBitmap(param.ScreenWidth, param.ScreenHeight); - { - b.Fill(panelFullFrameBackground.BackColor); - outBitmap = b.GetBitmap(); - { - if (param.Alignment == ContentAlignment.BottomLeft || param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.TopLeft) - { - left = param.LeftMargin; - } - else if (param.Alignment == ContentAlignment.BottomRight || param.Alignment == ContentAlignment.MiddleRight || param.Alignment == ContentAlignment.TopRight) - { - left = param.ScreenWidth - param.Bitmap.Width - param.RightMargin; - } - - if (param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopRight) - { - top = param.BottomMargin; - } - - if (param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.MiddleCenter || param.Alignment == ContentAlignment.MiddleRight) - { - top = (param.ScreenHeight - param.Bitmap.Height) / 2; - } - - if (param.OverridePosition.HasValue && - param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.Bitmap.Width && - param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.Bitmap.Height) - { - left = param.OverridePosition.Value.X; - top = param.OverridePosition.Value.Y; - } - - using (var g = Graphics.FromImage(outBitmap)) - { - g.DrawImage(bmp, left, top); - g.Dispose(); - } - } - } - } - } - - - if (comboBoxImageFormat.Text == "8-bit png") - { - foreach (var encoder in ImageCodecInfo.GetImageEncoders()) - { - if (encoder.FormatID == ImageFormat.Png.Guid) - { - var parameters = new EncoderParameters(); - parameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 8); - - var nbmp = new NikseBitmap(outBitmap); - var b = nbmp.ConvertTo8BitsPerPixel(); - b.Save(targetImageFileName, encoder, parameters); - b.Dispose(); - - break; - } - } - } - else - { - SaveImage(outBitmap, targetImageFileName, ImageFormat); - } - imagesSavedCount++; - - int timeBase = 25; - string ntsc = "FALSE"; - if (comboBoxLanguage.SelectedItem.ToString().Equals("NTSC", StringComparison.Ordinal)) - { - ntsc = "TRUE"; - } - - if (Math.Abs(param.FramesPerSeconds - 29.97) < 0.01) - { - timeBase = 30; - ntsc = "TRUE"; - } - else if (Math.Abs(param.FramesPerSeconds - 23.976) < 0.01) - { - timeBase = 24; - ntsc = "TRUE"; - } - else if (Math.Abs(param.FramesPerSeconds - 59.94) < 0.01) - { - timeBase = 60; - ntsc = "TRUE"; - } - - var duration = SubtitleFormat.MillisecondsToFrames(param.P.Duration.TotalMilliseconds, param.FramesPerSeconds); - var start = SubtitleFormat.MillisecondsToFrames(param.P.StartTime.TotalMilliseconds, param.FramesPerSeconds); - var end = SubtitleFormat.MillisecondsToFrames(param.P.EndTime.TotalMilliseconds, param.FramesPerSeconds); - - template = template.Replace("[DURATION]", duration.ToString(CultureInfo.InvariantCulture)); - template = template.Replace("[IN]", start.ToString(CultureInfo.InvariantCulture)); - template = template.Replace("[OUT]", end.ToString(CultureInfo.InvariantCulture)); - template = template.Replace("[START]", start.ToString(CultureInfo.InvariantCulture)); - template = template.Replace("[END]", end.ToString(CultureInfo.InvariantCulture)); - template = template.Replace("[TIMEBASE]", timeBase.ToString(CultureInfo.InvariantCulture)); - template = template.Replace("[NTSC]", ntsc); - sb.AppendLine(template); - return imagesSavedCount; - } - - internal int WriteBdnXmlParagraph(int width, StringBuilder sb, int border, int height, int imagesSavedCount, MakeBitmapParameter param, int i, string path) - { - string numberString = $"{i:0000}"; - string fileName = Path.Combine(path, numberString + ".png"); - - if (comboBoxImageFormat.Text == "Png 8-bit") - { - foreach (var encoder in ImageCodecInfo.GetImageEncoders()) - { - if (encoder.FormatID == ImageFormat.Png.Guid) - { - var parameters = new EncoderParameters(); - parameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 8); - - var nbmp = new NikseBitmap(param.Bitmap); - var b = nbmp.ConvertTo8BitsPerPixel(); - b.Save(fileName, encoder, parameters); - b.Dispose(); - - break; - } - } - } - else - { - param.Bitmap.Save(fileName, ImageFormat.Png); - } - - imagesSavedCount++; - - // - // subtitle_exp_0001.png - // - sb.AppendLine(""); - - int x = (width - param.Bitmap.Width) / 2; - int y = height - (param.Bitmap.Height + param.BottomMargin); - switch (param.Alignment) - { - case ContentAlignment.BottomLeft: - x = border; - y = height - (param.Bitmap.Height + param.BottomMargin); - break; - case ContentAlignment.BottomRight: - x = height - param.Bitmap.Width - border; - y = height - (param.Bitmap.Height + param.BottomMargin); - break; - case ContentAlignment.MiddleCenter: - x = (width - param.Bitmap.Width) / 2; - y = (height - param.Bitmap.Height) / 2; - break; - case ContentAlignment.MiddleLeft: - x = border; - y = (height - param.Bitmap.Height) / 2; - break; - case ContentAlignment.MiddleRight: - x = width - param.Bitmap.Width - border; - y = (height - param.Bitmap.Height) / 2; - break; - case ContentAlignment.TopCenter: - x = (width - param.Bitmap.Width) / 2; - y = border; - break; - case ContentAlignment.TopLeft: - x = border; - y = border; - break; - case ContentAlignment.TopRight: - x = width - param.Bitmap.Width - border; - y = border; - break; - } - - if (param.OverridePosition.HasValue && - param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.Bitmap.Width && - param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.Bitmap.Height) - { - x = param.OverridePosition.Value.X; - y = param.OverridePosition.Value.Y; - } - - sb.AppendLine(" " + numberString + ".png"); - sb.AppendLine(""); - return imagesSavedCount; - } - - internal int WriteParagraphDost(StringBuilder sb, int imagesSavedCount, MakeBitmapParameter param, int i, string fileName) - { - string numberString = string.Format("{0:0000}", i); - fileName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName).Replace(" ", "_")) + "_" + numberString + ".png"; - - foreach (var encoder in ImageCodecInfo.GetImageEncoders()) - { - if (encoder.FormatID == ImageFormat.Png.Guid) - { - var parameters = new EncoderParameters(); - parameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 8); - - var nbmp = new NikseBitmap(param.Bitmap); - var b = nbmp.ConvertTo8BitsPerPixel(); - b.Save(fileName, encoder, parameters); - b.Dispose(); - - break; - } - } - imagesSavedCount++; - - const string paragraphWriteFormat = "{0}\t{1}\t{2}\t{4}\t{5}\t{3}\t0\t0"; - - int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin); - int left = (param.ScreenWidth - param.Bitmap.Width) / 2; - if (param.Alignment == ContentAlignment.BottomLeft || param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.TopLeft) - { - left = param.LeftMargin; - } - else if (param.Alignment == ContentAlignment.BottomRight || param.Alignment == ContentAlignment.MiddleRight || param.Alignment == ContentAlignment.TopRight) - { - left = param.ScreenWidth - param.Bitmap.Width - param.RightMargin; - } - - if (param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopRight) - { - top = param.BottomMargin; - } - - if (param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.MiddleCenter || param.Alignment == ContentAlignment.MiddleRight) - { - top = param.ScreenHeight - (param.Bitmap.Height / 2); - } - - if (param.OverridePosition.HasValue && - param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.Bitmap.Width && - param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.Bitmap.Height) - { - left = param.OverridePosition.Value.X; - top = param.OverridePosition.Value.Y; - } - - string startTime = ToHHMMSSFF(param.P.StartTime); - string endTime = ToHHMMSSFF(param.P.EndTime); - sb.AppendLine(string.Format(paragraphWriteFormat, numberString, startTime, endTime, Path.GetFileName(fileName), left, top)); - return imagesSavedCount; - } - - private ImageFormat ImageFormat - { - get - { - var imageFormat = ImageFormat.Png; - if (comboBoxImageFormat.SelectedIndex == 0) - { - imageFormat = ImageFormat.Bmp; - } - else if (comboBoxImageFormat.SelectedIndex == 1) - { - imageFormat = ImageFormat.Exif; - } - else if (comboBoxImageFormat.SelectedIndex == 2) - { - imageFormat = ImageFormat.Gif; - } - else if (comboBoxImageFormat.SelectedIndex == 3) - { - imageFormat = ImageFormat.Jpeg; - } - else if (comboBoxImageFormat.SelectedIndex == 4) - { - imageFormat = ImageFormat.Png; - } - else if (comboBoxImageFormat.SelectedIndex == 5) - { - imageFormat = ImageFormat.Tiff; - } - - if (string.Compare(comboBoxImageFormat.Text, "tga", StringComparison.OrdinalIgnoreCase) == 0) - { - return ImageFormat.Icon; - } - - return imageFormat; - } - } - - private static string FormatFabTime(TimeCode time, MakeBitmapParameter param) - { - if (param.Bitmap.Width == 720 && param.Bitmap.Height == 480) // NTSC - { - return $"{time.Hours:00};{time.Minutes:00};{time.Seconds:00};{SubtitleFormat.MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - // drop frame - if (Math.Abs(param.FramesPerSeconds - 24 * (999 / 1000)) < 0.01 || - Math.Abs(param.FramesPerSeconds - 29 * (999 / 1000)) < 0.01 || - Math.Abs(param.FramesPerSeconds - 59 * (999 / 1000)) < 0.01) - { - return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{SubtitleFormat.MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - return $"{time.Hours:00};{time.Minutes:00};{time.Seconds:00};{SubtitleFormat.MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; - } - - private void SetupImageParameters() - { - if (subtitleListView1.SelectedItems.Count > 0 && _format.HasStyleSupport) - { - Paragraph p = _subtitle.GetParagraphOrDefault(subtitleListView1.SelectedItems[0].Index); - if (p != null && (_format.GetType() == typeof(AdvancedSubStationAlpha) || _format.GetType() == typeof(SubStationAlpha))) - { - if (!string.IsNullOrEmpty(p.Extra)) - { - comboBoxSubtitleFont.Enabled = false; - comboBoxSubtitleFontSize.Enabled = false; - buttonBorderColor.Enabled = false; - comboBoxHAlign.Enabled = false; - panelBorderColor.Enabled = false; - checkBoxBold.Enabled = false; - buttonColor.Enabled = false; - panelColor.Enabled = false; - comboBoxBorderWidth.Enabled = false; - comboBoxBottomMargin.Enabled = false; - comboBoxBottomMarginUnit.Enabled = false; - comboBoxBottomMarginUnit.SelectedIndex = 1; // px - comboBoxLeftRightMargin.Enabled = false; - comboBoxLeftRightMarginUnit.Enabled = false; - comboBoxLeftRightMarginUnit.SelectedIndex = 1; // px - comboBoxShadowWidth.Enabled = false; - buttonShadowColor.Enabled = false; - panelShadowColor.Enabled = false; - numericUpDownShadowTransparency.Enabled = _format.GetType() != typeof(AdvancedSubStationAlpha); - - SsaStyle style = AdvancedSubStationAlpha.GetSsaStyle(p.Extra, _subtitle.Header); - if (style != null) - { - int i; - for (i = 0; i < comboBoxBottomMargin.Items.Count; i++) - { - if (comboBoxBottomMargin.Items[i].ToString().Equals(style.MarginVertical.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase)) - { - comboBoxBottomMargin.SelectedIndex = i; - break; - } - } - - for (i = 0; i < comboBoxLeftRightMarginUnit.Items.Count; i++) - { - if (comboBoxLeftRightMarginUnit.Items[i].ToString().Equals(style.MarginLeft.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase)) - { - comboBoxLeftRightMarginUnit.SelectedIndex = i; - break; - } - } - - panelColor.BackColor = style.Primary; - panelBorderColor.BackColor = _format.GetType() == typeof(AdvancedSubStationAlpha) ? style.Outline : style.Background; - - for (i = 0; i < comboBoxSubtitleFont.Items.Count; i++) - { - if (comboBoxSubtitleFont.Items[i].ToString().Equals(style.FontName, StringComparison.OrdinalIgnoreCase)) - { - comboBoxSubtitleFont.SelectedIndex = i; - break; - } - } - for (i = 0; i < comboBoxSubtitleFontSize.Items.Count; i++) - { - if (comboBoxSubtitleFontSize.Items[i].ToString().Equals(style.FontSize.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase)) - { - comboBoxSubtitleFontSize.SelectedIndex = i; - break; - } - } - checkBoxBold.Checked = style.Bold; - comboBoxBorderWidth.Items.Clear(); - comboBoxBorderWidth.Items.Add(style.OutlineWidth.ToString(CultureInfo.InvariantCulture)); - comboBoxBorderWidth.SelectedIndex = 0; - - comboBoxShadowWidth.Items.Clear(); - comboBoxShadowWidth.Items.Add(style.ShadowWidth.ToString(CultureInfo.InvariantCulture)); - comboBoxShadowWidth.SelectedIndex = 0; - if (_format.GetType() == typeof(AdvancedSubStationAlpha)) - { - panelShadowColor.BackColor = style.Background; - numericUpDownShadowTransparency.Value = style.Background.A; - } - else - { - panelShadowColor.BackColor = style.Outline; - numericUpDownShadowTransparency.Value = style.Outline.A; - } - } - } - } - } - - _subtitleColor = panelColor.BackColor; - _borderColor = panelBorderColor.BackColor; - _subtitleFontName = comboBoxSubtitleFont.SelectedItem.ToString(); - _subtitleFontSize = float.Parse(comboBoxSubtitleFontSize.SelectedItem.ToString()); - _subtitleFontBold = checkBoxBold.Checked; - - _borderWidth = GetBorderWidth(); - } - - private float GetBorderWidth() - { - if (comboBoxBorderWidth.SelectedItem.ToString() == Configuration.Settings.Language.ExportPngXml.BorderStyleBoxForEachLine || - comboBoxBorderWidth.SelectedItem.ToString() == Configuration.Settings.Language.ExportPngXml.BorderStyleOneBox) - { - return 0; - } - - if (float.TryParse(comboBoxBorderWidth.SelectedItem.ToString(), out var f)) - { - return f; - } - - if (float.TryParse(Utilities.RemoveNonNumbers(comboBoxBorderWidth.SelectedItem.ToString()), out f)) - { - return f; - } - - return 0; - } - - private float GetShadowWidth() - { - if (float.TryParse(comboBoxShadowWidth.SelectedItem.ToString(), out var f)) - { - return f; - } - - if (float.TryParse(Utilities.RemoveNonNumbers(comboBoxShadowWidth.SelectedItem.ToString()), out f)) - { - return f; - } - - return 0; - } - - private static Font GetFont(MakeBitmapParameter parameter, float fontSize) - { - Font font; - try - { - var fontStyle = FontStyle.Regular; - if (parameter.SubtitleFontBold) - { - fontStyle = FontStyle.Bold; - } - - font = new Font(parameter.SubtitleFontName, fontSize, fontStyle); - } - catch (Exception exception) - { - try - { - var fontStyle = FontStyle.Regular; - if (!parameter.SubtitleFontBold) - { - fontStyle = FontStyle.Bold; - } - - font = new Font(parameter.SubtitleFontName, fontSize, fontStyle); - } - catch - { - MessageBox.Show(exception.Message); - - if (FontFamily.Families[0].IsStyleAvailable(FontStyle.Regular)) - { - font = new Font(FontFamily.Families[0].Name, fontSize); - } - else if (FontFamily.Families.Length > 1 && FontFamily.Families[1].IsStyleAvailable(FontStyle.Regular)) - { - font = new Font(FontFamily.Families[1].Name, fontSize); - } - else if (FontFamily.Families.Length > 2 && FontFamily.Families[1].IsStyleAvailable(FontStyle.Regular)) - { - font = new Font(FontFamily.Families[2].Name, fontSize); - } - else - { - font = new Font("Arial", fontSize); - } - } - } - return font; - } - - private double GetResizeScale() - { - if (comboBoxResizePercentage.SelectedItem == null) - { - return 1.0; - } - - var p = int.Parse(comboBoxResizePercentage.SelectedItem.ToString().Replace("%", string.Empty)); - return p / 100.0; - } - - private Bitmap GenerateImageFromTextWithStyle(Paragraph p, out MakeBitmapParameter mbp) - { - mbp = new MakeBitmapParameter { P = p }; - - if (_vobSubOcr != null) - { - var index = _subtitle.GetIndex(p); - if (index >= 0) - { - var b = _vobSubOcr.GetSubtitleBitmap(index); - var exp = GetResizeScale(); - if (Math.Abs(exp - 1) > 0.01) - { - var resizedBitmap = ResizeBitmap(b, (int)Math.Round(b.Width * exp), (int)Math.Round(b.Height * exp)); - b.Dispose(); - return resizedBitmap; - } - return b; - } - - } - - mbp.AlignLeft = comboBoxHAlign.SelectedIndex == 0; - mbp.AlignRight = comboBoxHAlign.SelectedIndex == 2; - mbp.JustifyLeft = GetJustifyLeft(p.Text); - mbp.JustifyTop = comboBoxHAlign.SelectedIndex == 4; - mbp.JustifyRight = comboBoxHAlign.SelectedIndex == 5; - mbp.SimpleRendering = checkBoxSimpleRender.Checked; - mbp.BorderWidth = _borderWidth; - mbp.BorderColor = _borderColor; - mbp.SubtitleFontName = _subtitleFontName; - mbp.SubtitleColor = _subtitleColor; - mbp.SubtitleFontSize = _subtitleFontSize; - mbp.SubtitleFontBold = _subtitleFontBold; - mbp.LineHeight = _lineHeights; - mbp.FullFrame = checkBoxFullFrameImage.Checked; - mbp.FullFrameBackgroundColor = panelFullFrameBackground.BackColor; - mbp.OverridePosition = GetAssPoint(p.Text); - - if (_format.HasStyleSupport && !string.IsNullOrEmpty(p.Extra)) - { - if (_format.GetType() == typeof(SubStationAlpha)) - { - var style = AdvancedSubStationAlpha.GetSsaStyle(p.Extra, _subtitle.Header); - mbp.SubtitleColor = style.Primary; - mbp.SubtitleFontBold = style.Bold; - mbp.SubtitleFontSize = style.FontSize; - mbp.BottomMargin = style.MarginVertical; - if (style.BorderStyle == "3") - { - mbp.BackgroundColor = style.Background; - } - mbp.ShadowColor = style.Outline; - } - else if (_format.GetType() == typeof(AdvancedSubStationAlpha)) - { - var style = AdvancedSubStationAlpha.GetSsaStyle(p.Extra, _subtitle.Header); - mbp.SubtitleColor = style.Primary; - mbp.SubtitleFontBold = style.Bold; - mbp.SubtitleFontSize = style.FontSize; - mbp.BottomMargin = style.MarginVertical; - if (style.BorderStyle == "3") - { - mbp.BackgroundColor = style.Outline; - } - mbp.ShadowAlpha = style.Background.A; - mbp.ShadowColor = style.Background; - } - } - - if (comboBoxBorderWidth.SelectedItem.ToString() == Configuration.Settings.Language.ExportPngXml.BorderStyleBoxForEachLine) - { - _borderWidth = 0; - mbp.BackgroundColor = panelBorderColor.BackColor; - mbp.BoxSingleLine = true; - } - else if (comboBoxBorderWidth.SelectedItem.ToString() == Configuration.Settings.Language.ExportPngXml.BorderStyleOneBox) - { - mbp.BoxSingleLine = false; - _borderWidth = 0; - mbp.BackgroundColor = panelBorderColor.BackColor; - } - - GetResolution(out var width, out var height); - mbp.ScreenWidth = width; - mbp.ScreenHeight = height; - mbp.VideoResolution = comboBoxResolution.Text; - mbp.Type3D = comboBox3D.SelectedIndex; - mbp.Depth3D = (int)numericUpDownDepth3D.Value; - mbp.BottomMargin = GetBottomMarginInPixels(p); - mbp.ShadowWidth = GetShadowWidth(); - mbp.ShadowAlpha = (int)numericUpDownShadowTransparency.Value; - mbp.ShadowColor = panelShadowColor.BackColor; - mbp.LineHeight = _lineHeights; - mbp.Forced = subtitleListView1.Items[_subtitle.GetIndex(p)].Checked; - mbp.LineJoin = Configuration.Settings.Tools.ExportPenLineJoin; - var bmp = GenerateImageFromTextWithStyle(mbp); - if (_exportType == ExportFormats.VobSub || _exportType == ExportFormats.Stl || _exportType == ExportFormats.Spumux) - { - var nbmp = new NikseBitmap(bmp); - nbmp.ConvertToFourColors(Color.Transparent, _subtitleColor, _borderColor, !checkBoxTransAntiAliase.Checked); - - if (_exportType == ExportFormats.Spumux) - { - nbmp.EnsureEvenLines(mbp.BoxSingleLine ? Color.Transparent : mbp.BackgroundColor); - } - - var temp = nbmp.GetBitmap(); - bmp.Dispose(); - return temp; - } - return bmp; - } - - private static int CalcWidthViaDraw(string text, MakeBitmapParameter parameter) - { - var nbmp = GenerateBitmapForCalc(text, parameter); - nbmp.CropTransparentSidesAndBottom(0, true); - return nbmp.Width; - } - - private static NikseBitmap GenerateBitmapForCalc(string text, MakeBitmapParameter parameter) - { - text = text.Trim(); - var path = new GraphicsPath(); - var sb = new StringBuilder(); - int i = 0; - bool isItalic = false; - bool isBold = parameter.SubtitleFontBold; - const float top = 5f; - bool newLine = false; - float left = 1.0f; - float leftMargin = left; - int newLinePathPoint = -1; - Color c = parameter.SubtitleColor; - var colorStack = new Stack(); - var lastText = new StringBuilder(); - var sf = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near }; - var bmp = new Bitmap(parameter.ScreenWidth, 200); - var g = Graphics.FromImage(bmp); - - g.CompositingQuality = CompositingQuality.HighSpeed; - g.SmoothingMode = SmoothingMode.HighSpeed; - g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; - - Font font = GetFont(parameter, parameter.SubtitleFontSize); - var fontStack = new Stack(); - while (i < text.Length) - { - if (text.Substring(i).StartsWith(" 0) - { - lastText.Append(sb); - TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - - addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); - if (path.PointCount == 0) - { - addLeft = left; - } - else if (addLeft < 0.01) - { - addLeft = left + 2; - } - - left = addLeft; - - DrawShadowAndPath(parameter, g, path); - var p2 = new SolidBrush(c); - g.FillPath(p2, path); - p2.Dispose(); - path.Reset(); - path = new GraphicsPath(); - sb.Clear(); - - int endIndex = text.Substring(i).IndexOf('>'); - if (endIndex < 0) - { - i += 9999; - } - else - { - string fontContent = text.Substring(i, endIndex); - if (fontContent.Contains(" color=", StringComparison.OrdinalIgnoreCase)) - { - string[] arr = fontContent.Substring(fontContent.IndexOf(" color=", StringComparison.OrdinalIgnoreCase) + 7).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - if (arr.Length > 0) - { - string fontColor = arr[0].Trim('\'').Trim('"').Trim('\''); - try - { - colorStack.Push(c); // save old color - if (fontColor.StartsWith("rgb(", StringComparison.OrdinalIgnoreCase)) - { - arr = fontColor.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); - } - else - { - c = ColorTranslator.FromHtml(fontColor); - } - } - catch - { - c = parameter.SubtitleColor; - } - } - } - if (fontContent.Contains(" face=", StringComparison.OrdinalIgnoreCase) || fontContent.Contains(" size=", StringComparison.OrdinalIgnoreCase)) - { - float fontSize = parameter.SubtitleFontSize; - string fontFace = parameter.SubtitleFontName; - - string[] arr = fontContent.Substring(fontContent.IndexOf(" face=", StringComparison.OrdinalIgnoreCase) + 6).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - if (arr.Length > 0) - { - fontFace = arr[0].Trim('\'').Trim('"').Trim('\''); - } - - arr = fontContent.Substring(fontContent.IndexOf(" size=", StringComparison.OrdinalIgnoreCase) + 6).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - if (arr.Length > 0) - { - string temp = arr[0].Trim('\'').Trim('"').Trim('\''); - if (float.TryParse(temp, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var f)) - { - fontSize = f; - } - } - - try - { - fontStack.Push(font); // save old cfont - var p = new MakeBitmapParameter { SubtitleFontName = fontFace, SubtitleFontSize = fontSize }; - font = GetFont(p, p.SubtitleFontSize); - } - catch - { - font = fontStack.Pop(); - } - } - i += endIndex; - } - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - if (text.Substring(i).ToLowerInvariant().Replace("", string.Empty).Replace("
", string.Empty).Length > 0) - { - if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) - { - string t = sb.ToString(); - sb.Clear(); - sb.Append(' '); - sb.Append(t); - } - - float addLeft = 0; - int oldPathPointIndex = path.PointCount - 1; - if (oldPathPointIndex < 0) - { - oldPathPointIndex = 0; - } - - if (sb.Length > 0) - { - if (lastText.Length > 0 && left > 2) - { - left -= 1.5f; - } - - lastText.Append(sb); - - TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - - addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); - if (addLeft < 0.01) - { - addLeft = left + 2; - } - - left = addLeft; - - DrawShadowAndPath(parameter, g, path); - g.FillPath(new SolidBrush(c), path); - path.Reset(); - sb = new StringBuilder(); - if (colorStack.Count > 0) - { - c = colorStack.Pop(); - } - - if (left >= 3) - { - left -= 2.5f; - } - } - if (fontStack.Count > 0) - { - font.Dispose(); - font = fontStack.Pop(); - } - i += 6; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - if (sb.Length > 0) - { - lastText.Append(sb); - TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - isItalic = true; - i += 2; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) && isItalic) - { - if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) - { - string t = sb.ToString(); - sb.Clear(); - sb.Append(' '); - sb.Append(t); - } - lastText.Append(sb); - TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - isItalic = false; - i += 3; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - if (sb.Length > 0) - { - lastText.Append(sb); - TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - isBold = true; - i += 2; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) && isBold) - { - if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) - { - string t = sb.ToString(); - sb.Clear(); - sb.Append(' '); - sb.Append(t); - } - lastText.Append(sb); - TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - isBold = false; - i += 3; - } - else - { - sb.Append(text[i]); - } - i++; - } - if (sb.Length > 0) - { - TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - - DrawShadowAndPath(parameter, g, path); - g.FillPath(new SolidBrush(c), path); - g.Dispose(); - - var nbmp = new NikseBitmap(bmp); - bmp.Dispose(); - font.Dispose(); - sf.Dispose(); - return nbmp; - } - - internal static Bitmap GenerateImageFromTextWithStyle(MakeBitmapParameter parameter) - { - Bitmap bmp = null; - if (!parameter.SimpleRendering && parameter.P.Text.Contains(Environment.NewLine) && (parameter.BoxSingleLine || parameter.P.Text.Contains(BoxSingleLineText))) - { - string old = parameter.P.Text; - int oldType3D = parameter.Type3D; - if (parameter.Type3D == 2) // Half-Top/Bottom 3D - { - parameter.Type3D = 0; // fix later - } - var oldBackgroundColor = parameter.BackgroundColor; - if (parameter.P.Text.Contains(BoxSingleLineText)) - { - parameter.P.Text = parameter.P.Text.Replace("<" + BoxSingleLineText + ">", string.Empty).Replace("", string.Empty); - parameter.BackgroundColor = parameter.BorderColor; - } - - var italicOn = false; - var boldOn = false; - var fontTag = string.Empty; - var lineWidts = new List(); - foreach (var line in parameter.P.Text.SplitToLines()) - { - parameter.P.Text = line; - - if (italicOn) - { - parameter.P.Text = "" + parameter.P.Text; - } - italicOn = parameter.P.Text.Contains("", StringComparison.OrdinalIgnoreCase) && !parameter.P.Text.Contains("", StringComparison.OrdinalIgnoreCase); - if (italicOn) - { - parameter.P.Text += ""; - } - - if (boldOn) - { - parameter.P.Text = "" + parameter.P.Text; - } - boldOn = parameter.P.Text.Contains("", StringComparison.OrdinalIgnoreCase) && !parameter.P.Text.Contains("", StringComparison.OrdinalIgnoreCase); - if (boldOn) - { - parameter.P.Text += ""; - } - - parameter.P.Text = fontTag + parameter.P.Text; - if (parameter.P.Text.Contains("", StringComparison.OrdinalIgnoreCase)) - { - int start = parameter.P.Text.LastIndexOf("', start); - fontTag = parameter.P.Text.Substring(start, end - start + 1); - } - - var lineImage = GenerateImageFromTextWithStyleInner(parameter); - lineWidts.Add(lineImage.Width); - if (bmp == null) - { - bmp = lineImage; - } - else - { - int w = Math.Max(bmp.Width, lineImage.Width); - int h = bmp.Height + lineImage.Height; - - int l1; - if (parameter.AlignLeft) - { - l1 = 0; - } - else if (parameter.AlignRight) - { - l1 = w - bmp.Width; - } - else - { - l1 = (int)Math.Round((w - bmp.Width) / 2.0); - - if (parameter.JustifyLeft) - { - l1 = 0; - } - else if (parameter.JustifyRight) - { - l1 = w - lineImage.Width; - } - } - - int l2; - if (parameter.AlignLeft) - { - l2 = 0; - } - else if (parameter.AlignRight) - { - l2 = w - lineImage.Width; - } - else - { - l2 = (int)Math.Round((w - lineImage.Width) / 2.0); - - if (parameter.JustifyLeft) - { - l2 = 0; - } - else if (parameter.JustifyRight) - { - l2 = w - lineImage.Width; - if (parameter.BoxSingleLine) - { - l1 = w - lineWidts[0]; - } - } - } - - var style = GetStyleName(parameter.P); - var lineHeight = 25; - if (parameter.LineHeight.ContainsKey(style)) - { - lineHeight = parameter.LineHeight[style]; - } - else if (parameter.LineHeight.Count > 0) - { - lineHeight = parameter.LineHeight.First().Value; - } - - if (lineHeight > lineImage.Height) - { - h += lineHeight - lineImage.Height; - var largeImage = new Bitmap(w, h); - var g = Graphics.FromImage(largeImage); - g.DrawImageUnscaled(bmp, new Point(l1, 0)); - g.DrawImageUnscaled(lineImage, new Point(l2, bmp.Height + lineHeight - lineImage.Height)); - bmp.Dispose(); - bmp = largeImage; - g.Dispose(); - } - else - { - var largeImage = new Bitmap(w, h); - var g = Graphics.FromImage(largeImage); - g.DrawImageUnscaled(bmp, new Point(l1, 0)); - g.DrawImageUnscaled(lineImage, new Point(l2, bmp.Height)); - bmp.Dispose(); - bmp = largeImage; - g.Dispose(); - } - } - } - parameter.P.Text = old; - parameter.Type3D = oldType3D; - parameter.BackgroundColor = oldBackgroundColor; - - if (parameter.Type3D == 2) // Half-side-by-side 3D - due to per line we need to do this after making lines - { - var newBmp = Make3DTopBottom(parameter, new NikseBitmap(bmp)).GetBitmap(); - bmp?.Dispose(); - bmp = newBmp; - } - } - else - { - var oldBackgroundColor = parameter.BackgroundColor; - string oldText = parameter.P.Text; - if (parameter.P.Text.Contains(BoxMultiLineText) || parameter.P.Text.Contains(BoxSingleLineText)) - { - parameter.P.Text = parameter.P.Text.Replace("<" + BoxMultiLineText + ">", string.Empty).Replace("", string.Empty); - parameter.P.Text = parameter.P.Text.Replace("<" + BoxSingleLineText + ">", string.Empty).Replace("", string.Empty); - parameter.BackgroundColor = parameter.BorderColor; - } - bmp = GenerateImageFromTextWithStyleInner(parameter); - parameter.P.Text = oldText; - parameter.BackgroundColor = oldBackgroundColor; - } - return bmp; - } - - private static readonly Dictionary PaddingDictionary = new Dictionary(); - private static Bitmap GenerateImageFromTextWithStyleInner(MakeBitmapParameter parameter) // for UI - { - string text = parameter.P.Text; - - text = AssToHtmlTagsIfKnow(text); - - text = text.Replace("", ""); - text = text.Replace("", ""); - text = HtmlUtil.FixInvalidItalicTags(text); - - text = text.Replace("", ""); - text = text.Replace("", ""); - - // no support for underline - text = HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagUnderline); - - Font font = null; - Bitmap bmp = null; - try - { - font = GetFont(parameter, parameter.SubtitleFontSize); - SizeF textSize; - using (var bmpTemp = new Bitmap(1, 1)) - using (var g = Graphics.FromImage(bmpTemp)) - { - textSize = g.MeasureString(HtmlUtil.RemoveHtmlTags(text), font); - } - int sizeX = (int)(textSize.Width * 1.8) + 150; - int sizeY = (int)(textSize.Height * 0.9) + 50; - if (sizeX < 1) - { - sizeX = 1; - } - - if (sizeY < 1) - { - sizeY = 1; - } - - if (parameter.BackgroundColor != Color.Transparent) - { - var nbmpTemp = new NikseBitmap(sizeX, sizeY + _boxBorderSize * 2); // make room for box border above+under text - nbmpTemp.Fill(parameter.BackgroundColor); - bmp = nbmpTemp.GetBitmap(); - } - else - { - bmp = new Bitmap(sizeX, sizeY); - } - - var paddingKey = font.Name + font.Size.ToString(CultureInfo.InvariantCulture); - int baseLinePadding; - if (PaddingDictionary.ContainsKey(paddingKey)) - { - baseLinePadding = PaddingDictionary[paddingKey]; - } - else - { - baseLinePadding = (int)Math.Round(TextDraw.MeasureTextHeight(font, "yjK)", parameter.SubtitleFontBold) - TextDraw.MeasureTextHeight(font, "ac", parameter.SubtitleFontBold)); - PaddingDictionary.Add(paddingKey, baseLinePadding); - } - - // align lines with "gjpqy,ýęçÇ/()[]" a bit lower - var lines = text.SplitToLines(); - if (lines.Count > 0) - { - var lastLine = lines[lines.Count - 1]; - if (lastLine.Contains(new[] { 'g', 'j', 'p', 'q', 'y', ',', 'ý', 'ę', 'ç', 'Ç', '/', '(', ')', '[', ']' })) - { - var textNoBelow = lastLine.Replace('g', 'a').Replace('j', 'a').Replace('p', 'a').Replace('q', 'a').Replace('y', 'a').Replace(',', 'a').Replace('ý', 'a').Replace('ę', 'a').Replace('ç', 'a').Replace('Ç', 'a').Replace('/', 'a').Replace('(', 'a').Replace(')', 'a').Replace('[', 'a').Replace(']', 'a'); - baseLinePadding -= (int)Math.Round(TextDraw.MeasureTextHeight(font, lastLine, parameter.SubtitleFontBold) - TextDraw.MeasureTextHeight(font, textNoBelow, parameter.SubtitleFontBold)); - } - else - { - baseLinePadding += 1; - } - if (baseLinePadding < 0) - { - baseLinePadding = 0; - } - } - - if (lines.Count == 1 && parameter.JustifyTop) // align top - { - baseLinePadding += (int)Math.Round(TextDraw.MeasureTextHeight(font, "yjK)", parameter.SubtitleFontBold)); - } - - // TODO: Better baseline - test http://bobpowell.net/formattingtext.aspx - //float baselineOffset=font.SizeInPoints/font.FontFamily.GetEmHeight(font.Style)*font.FontFamily.GetCellAscent(font.Style); - //float baselineOffsetPixels = g.DpiY/72f*baselineOffset; - //baseLinePadding = (int)Math.Round(baselineOffsetPixels); - - var lefts = new List(); - var widths = new List(); - if (text.Contains("", StringComparison.OrdinalIgnoreCase) || text.Contains("", StringComparison.OrdinalIgnoreCase)) - { - bool tempItalicOn = false; - bool tempBoldOn = false; - var tempFontOn = string.Empty; - foreach (string line in text.SplitToLines()) - { - var tempLine = line; - - if (tempItalicOn) - { - tempLine = "" + tempLine; - } - - if (tempBoldOn) - { - tempLine = "" + tempLine; - } - - if (!string.IsNullOrEmpty(tempFontOn)) - { - tempLine = tempFontOn + tempLine; - } - - if (tempLine.LastIndexOf("= 0 && - tempLine.LastIndexOf("", StringComparison.Ordinal) < - tempLine.LastIndexOf("', start); - if (end > 0) - { - tempFontOn = tempLine.Substring(start, end - start + 1); - } - } - else if (tempLine.LastIndexOf("", StringComparison.Ordinal) >= 0) - { - tempFontOn = string.Empty; - } - - if (tempLine.Contains("") && !tempLine.Contains("")) - { - tempItalicOn = true; - } - - if (tempLine.Contains("") && !tempLine.Contains("")) - { - tempBoldOn = true; - } - - int w; - if (text.Contains("")) - { - tempItalicOn = false; - } - - if (line.Contains("")) - { - tempBoldOn = false; - } - } - } - else - { - foreach (var line in HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagItalic, HtmlUtil.TagFont).SplitToLines()) - { - if (parameter.JustifyRight) - { - var w = TextDraw.MeasureTextWidth(font, line, parameter.SubtitleFontBold); - widths.Add(w); - } - - if (parameter.AlignLeft) - { - lefts.Add(5); - } - else if (parameter.AlignRight) - { - lefts.Add(bmp.Width - (TextDraw.MeasureTextWidth(font, line, parameter.SubtitleFontBold) + 15)); - } - else - { - lefts.Add((float)((bmp.Width - TextDraw.MeasureTextWidth(font, line, parameter.SubtitleFontBold) + 15) / 2.0)); - } - } - } - - if (parameter.JustifyLeft) - { - // left justify centered lines - var minX = lefts.Min(p => p); - for (var index = 0; index < lefts.Count; index++) - { - lefts[index] = minX; - } - } - else if (parameter.JustifyRight) - { - // right justify centered lines - var maxX = widths.Max(p => p); - var minX = lefts.Min(p => p); - for (var index = 0; index < lefts.Count; index++) - { - lefts[index] = minX + maxX - widths[index]; - } - } - - var sf = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near }; - - using (var g = Graphics.FromImage(bmp)) - { - g.CompositingQuality = CompositingQuality.HighQuality; - g.InterpolationMode = InterpolationMode.HighQualityBicubic; - g.SmoothingMode = SmoothingMode.HighQuality; - g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; - - if (parameter.SimpleRendering) - { - if (text.StartsWith(" 0) - { - left = lefts[0]; - } - - float top = 5; - if (top < _boxBorderSize && parameter.BackgroundColor != Color.Transparent) - { - top = _boxBorderSize; // make text down so box border will be satisfied - } - - bool newLine = false; - int lineNumber = 0; - float leftMargin = left; - int newLinePathPoint = -1; - Color c = parameter.SubtitleColor; - var colorStack = new Stack(); - var fontStack = new Stack(); - var lastText = new StringBuilder(); - for (var i = 0; i < text.Length; i++) - { - if (text.Substring(i).StartsWith(" 0) - { - lastText.Append(sb); - TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - - addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); - if (path.PointCount == 0) - { - addLeft = left; - } - else if (addLeft < 0.01) - { - addLeft = left + 2; - } - - left = addLeft; - - DrawShadowAndPath(parameter, g, path); - var p2 = new SolidBrush(c); - g.FillPath(p2, path); - p2.Dispose(); - path.Reset(); - path = new GraphicsPath(); - sb = new StringBuilder(); - - int endIndex = text.Substring(i).IndexOf('>'); - if (endIndex < 0) - { - i += 9999; - } - else - { - string fontContent = text.Substring(i, endIndex); - if (fontContent.Contains(" color=", StringComparison.OrdinalIgnoreCase)) - { - string[] arr = fontContent.Substring(fontContent.IndexOf(" color=", StringComparison.OrdinalIgnoreCase) + 7).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - if (arr.Length > 0) - { - string fontColor = arr[0].Trim('\'').Trim('"').Trim('\''); - try - { - colorStack.Push(c); // save old color - if (fontColor.StartsWith("rgb(", StringComparison.OrdinalIgnoreCase)) - { - arr = fontColor.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); - } - else - { - c = ColorTranslator.FromHtml(fontColor); - } - } - catch - { - c = parameter.SubtitleColor; - } - } - } - if (fontContent.Contains(" face=", StringComparison.OrdinalIgnoreCase) || fontContent.Contains(" size=", StringComparison.OrdinalIgnoreCase)) - { - float fontSize = parameter.SubtitleFontSize; - string fontFace = parameter.SubtitleFontName; - - string[] arr = fontContent.Substring(fontContent.IndexOf(" face=", StringComparison.OrdinalIgnoreCase) + 6).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - if (arr.Length > 0) - { - fontFace = arr[0].Trim('\'').Trim('"').Trim('\''); - } - - arr = fontContent.Substring(fontContent.IndexOf(" size=", StringComparison.OrdinalIgnoreCase) + 6).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); - if (arr.Length > 0) - { - string temp = arr[0].Trim('\'').Trim('"').Trim('\''); - if (float.TryParse(temp, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var f)) - { - fontSize = f; - } - } - - try - { - fontStack.Push(font); // save old cfont - var p = new MakeBitmapParameter { SubtitleFontName = fontFace, SubtitleFontSize = fontSize }; - font = GetFont(p, p.SubtitleFontSize); - } - catch - { - font = fontStack.Pop(); - } - } - - - i += endIndex; - } - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - if (text.Substring(i).ToLowerInvariant().Replace("", string.Empty).Replace("", string.Empty).Length > 0) - { - if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) - { - string t = sb.ToString(); - sb.Clear(); - sb.Append(' '); - sb.Append(t); - } - - float addLeft = 0; - int oldPathPointIndex = path.PointCount - 1; - if (oldPathPointIndex < 0) - { - oldPathPointIndex = 0; - } - - if (sb.Length > 0) - { - if (lastText.Length > 0 && left > 2) - { - left -= 1.5f; - } - - lastText.Append(sb); - - TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - - addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); - if (addLeft < 0.01) - { - addLeft = left + 2; - } - - left = addLeft; - - DrawShadowAndPath(parameter, g, path); - g.FillPath(new SolidBrush(c), path); - path.Reset(); - sb.Clear(); - if (colorStack.Count > 0) - { - c = colorStack.Pop(); - } - - if (left >= 3) - { - left -= 2.5f; - } - } - if (fontStack.Count > 0) - { - font.Dispose(); - font = fontStack.Pop(); - } - i += 6; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - if (sb.Length > 0) - { - float addLeft = 0; - int oldPathPointIndex = path.PointCount - 1; - if (oldPathPointIndex < 0) - { - oldPathPointIndex = 0; - } - - lastText.Append(sb); - TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - - addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); - if (addLeft < 0.01) - { - addLeft = left + 2; - } - - left = addLeft; - } - isItalic = true; - i += 2; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) && isItalic) - { - if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) - { - string t = sb.ToString(); - sb.Clear(); - sb.Append(' '); - sb.Append(t); - } - - if (sb.Length > 0) - { - float addLeft = 0; - int oldPathPointIndex = path.PointCount - 1; - if (oldPathPointIndex < 0) - { - oldPathPointIndex = 0; - } - - if (sb.Length > 0) - { - if (lastText.Length > 0 && left > 2) - { - left -= 1.5f; - } - - lastText.Append(sb); - TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - - addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); - if (addLeft < 0.01) - { - addLeft = left + 2; - } - - left = addLeft; - } - - isItalic = false; - i += 3; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) && !isItalic) - { - i += 3; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - if (sb.Length > 0) - { - lastText.Append(sb); - TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - isBold = true; - i += 2; - } - else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) && isBold) - { - if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) - { - string t = sb.ToString(); - sb.Clear(); - sb.Append(' '); - sb.Append(t); - } - - if (sb.Length > 0) - { - float addLeft = 0; - int oldPathPointIndex = path.PointCount - 1; - if (oldPathPointIndex < 0) - { - oldPathPointIndex = 0; - } - - if (sb.Length > 0) - { - if (lastText.Length > 0 && left > 2) - { - left -= 1.5f; - } - - lastText.Append(sb); - TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - - addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); - if (addLeft < 0.01) - { - addLeft = left + 2; - } - - left = addLeft; - } - - isBold = false; - i += 3; - } - else if (text.Substring(i).StartsWith(Environment.NewLine, StringComparison.Ordinal)) - { - lastText.Append(sb); - TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - var style = GetStyleName(parameter.P); - var lineHeight = (int)Math.Round(textSize.Height * 0.64f); - if (parameter.LineHeight.ContainsKey(style)) - { - lineHeight = parameter.LineHeight[style]; - } - - top += lineHeight; - newLine = true; - i += Environment.NewLine.Length - 1; - lineNumber++; - if (lineNumber < lefts.Count) - { - leftMargin = lefts[lineNumber]; - left = leftMargin; - } - } - else - { - sb.Append(text[i]); - } - } - if (sb.Length > 0) - { - TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); - } - - DrawShadowAndPath(parameter, g, path); - g.FillPath(new SolidBrush(c), path); - } - } - sf.Dispose(); - - var nbmp = new NikseBitmap(bmp); - if (parameter.BackgroundColor == Color.Transparent) - { - nbmp.CropTransparentSidesAndBottom(baseLinePadding, true); - nbmp.CropTransparentSidesAndBottom(2, false); - } - else - { - nbmp.CropSidesAndBottom(_boxBorderSize, parameter.BackgroundColor, true); - nbmp.CropTop(_boxBorderSize, parameter.BackgroundColor); - } - - if (nbmp.Width > parameter.ScreenWidth) - { - parameter.Error = "#" + parameter.P.Number.ToString(CultureInfo.InvariantCulture) + ": " + nbmp.Width.ToString(CultureInfo.InvariantCulture) + " > " + parameter.ScreenWidth.ToString(CultureInfo.InvariantCulture); - } - - if (parameter.Type3D == 1) // Half-side-by-side 3D - { - Bitmap singleBmp = nbmp.GetBitmap(); - Bitmap singleHalfBmp = ScaleToHalfWidth(singleBmp); - singleBmp.Dispose(); - var sideBySideBmp = new Bitmap(parameter.ScreenWidth, singleHalfBmp.Height); - int singleWidth = parameter.ScreenWidth / 2; - int singleLeftMargin = (singleWidth - singleHalfBmp.Width) / 2; - - using (Graphics gSideBySide = Graphics.FromImage(sideBySideBmp)) - { - gSideBySide.DrawImage(singleHalfBmp, singleLeftMargin + parameter.Depth3D, 0); - gSideBySide.DrawImage(singleHalfBmp, singleWidth + singleLeftMargin - parameter.Depth3D, 0); - } - nbmp = new NikseBitmap(sideBySideBmp); - if (parameter.BackgroundColor == Color.Transparent) - { - nbmp.CropTransparentSidesAndBottom(2, true); - } - else - { - nbmp.CropSidesAndBottom(_boxBorderSize, parameter.BackgroundColor, true); - } - } - else if (parameter.Type3D == 2) // Half-Top/Bottom 3D - { - nbmp = Make3DTopBottom(parameter, nbmp); - } - return nbmp.GetBitmap(); - } - finally - { - font?.Dispose(); - bmp?.Dispose(); - } - } - - private static float GetLastPositionFromPath(GraphicsPath path, int oldPathPointIndex, float addLeft) - { - if (path.PointCount > 0) - { - var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! - for (int k = oldPathPointIndex + 1; k < list.Length; k++) - { - if (list[k].X > addLeft) - { - addLeft = list[k].X; - } - } - } - return addLeft; - } - - private static Point? GetAssPoint(string s) - { - int k = s.IndexOf("{\\", StringComparison.Ordinal); - while (k >= 0) - { - int l = s.IndexOf('}', k + 1); - if (l < k) - { - break; - } - - var assTags = s.Substring(k + 1, l - k - 1).Split('\\'); - foreach (var assTag in assTags) - { - if (assTag.StartsWith("pos(", StringComparison.Ordinal)) - { - var numbers = assTag.Remove(0, 4).TrimEnd(')').Trim().Split(','); - if (numbers.Length == 2 && Utilities.IsInteger(numbers[0]) && Utilities.IsInteger(numbers[1])) - { - return new Point(int.Parse(numbers[0]), int.Parse(numbers[1])); - } - } - } - k = s.IndexOf("{\\", k + 1, StringComparison.Ordinal); - } - return null; - } - - private static string AssToHtmlTagsIfKnow(string s) - { - int k = s.IndexOf("{\\", StringComparison.Ordinal); - while (k >= 0) - { - int l = s.IndexOf('}', k + 1); - if (l < k) - { - break; - } - - var assTags = s.Substring(k + 1, l - k - 1).Split('\\'); - var sb = new StringBuilder(); - foreach (var assTag in assTags) - { - if (assTag == "i1") - { - sb.Append(""); - } - else if (assTag == "i" || assTag == "i0") - { - sb.Append(""); - } - else if (assTag == "b1" || assTag == "b2" || assTag == "b3" || assTag == "b4") - { - sb.Append(""); - } - else if (assTag == "b" || assTag == "b0") - { - sb.Append(""); - } - } - s = s.Remove(k, l - k + 1); - s = s.Insert(k, sb.ToString()); - k = s.IndexOf("{\\", k, StringComparison.Ordinal); - } - return s; - } - - private static NikseBitmap Make3DTopBottom(MakeBitmapParameter parameter, NikseBitmap nbmp) - { - Bitmap singleBmp = nbmp.GetBitmap(); - Bitmap singleHalfBmp = ScaleToHalfHeight(singleBmp); - singleBmp.Dispose(); - var topBottomBmp = new Bitmap(parameter.ScreenWidth, parameter.ScreenHeight - parameter.BottomMargin); - int singleHeight = parameter.ScreenHeight / 2; - int leftM = (parameter.ScreenWidth / 2) - (singleHalfBmp.Width / 2); - - using (Graphics gTopBottom = Graphics.FromImage(topBottomBmp)) - { - gTopBottom.DrawImage(singleHalfBmp, leftM + parameter.Depth3D, singleHeight - singleHalfBmp.Height - parameter.BottomMargin); - gTopBottom.DrawImage(singleHalfBmp, leftM - parameter.Depth3D, parameter.ScreenHeight - parameter.BottomMargin - singleHalfBmp.Height); - } - nbmp = new NikseBitmap(topBottomBmp); - if (parameter.BackgroundColor == Color.Transparent) - { - nbmp.CropTop(2, Color.Transparent); - nbmp.CropTransparentSidesAndBottom(2, false); - } - else - { - nbmp.CropTop(_boxBorderSize, parameter.BackgroundColor); - nbmp.CropSidesAndBottom(_boxBorderSize, parameter.BackgroundColor, false); - } - return nbmp; - } - - private static void DrawShadowAndPath(MakeBitmapParameter parameter, Graphics g, GraphicsPath path) - { - if (parameter.ShadowWidth > 0) - { - var shadowAlpha = parameter.ShadowAlpha; - if (parameter.ShadowWidth > 1) - { - shadowAlpha = (int)Math.Round(shadowAlpha * 0.8); - } - - var shadowPath = (GraphicsPath)path.Clone(); - for (int k = 0; k < parameter.ShadowWidth; k++) - { - var translateMatrix = new Matrix(); - translateMatrix.Translate(1, 1); - shadowPath.Transform(translateMatrix); - - using (var p1 = new Pen(new SolidBrush(Color.FromArgb(shadowAlpha, parameter.ShadowColor)), parameter.BorderWidth)) - { - SetLineJoin(parameter.LineJoin, p1); - g.DrawPath(p1, shadowPath); - } - } - } - - if (parameter.BorderWidth > 0) - { - var p1 = new Pen(parameter.BorderColor, (float)(parameter.BorderWidth * 1.1)); - SetLineJoin(parameter.LineJoin, p1); - g.DrawPath(p1, path); - p1.Dispose(); - } - } - - private static void SetLineJoin(string lineJoin, Pen pen) - { - if (string.IsNullOrWhiteSpace(lineJoin)) - { - return; - } - - if (string.Compare(lineJoin, "Round", StringComparison.OrdinalIgnoreCase) == 0) - { - pen.LineJoin = LineJoin.Round; - } - else if (string.Compare(lineJoin, "Bevel", StringComparison.OrdinalIgnoreCase) == 0) - { - pen.LineJoin = LineJoin.Bevel; - } - else if (string.Compare(lineJoin, "Miter", StringComparison.OrdinalIgnoreCase) == 0) - { - pen.LineJoin = LineJoin.Miter; - } - else if (string.Compare(lineJoin, "MiterClipped", StringComparison.OrdinalIgnoreCase) == 0) - { - pen.LineJoin = LineJoin.MiterClipped; - } - } - - private static Bitmap ScaleToHalfWidth(Bitmap bmp) - { - int w = bmp.Width / 2; - var newImage = new Bitmap(w, bmp.Height); - using (var gr = Graphics.FromImage(newImage)) - { - gr.SmoothingMode = SmoothingMode.HighQuality; - gr.InterpolationMode = InterpolationMode.HighQualityBicubic; - gr.PixelOffsetMode = PixelOffsetMode.HighQuality; - gr.DrawImage(bmp, new Rectangle(0, 0, w, bmp.Height)); - } - return newImage; - } - - private static Bitmap ScaleToHalfHeight(Bitmap bmp) - { - int h = bmp.Height / 2; - var newImage = new Bitmap(bmp.Width, h); - using (var gr = Graphics.FromImage(newImage)) - { - gr.SmoothingMode = SmoothingMode.HighQuality; - gr.InterpolationMode = InterpolationMode.HighQualityBicubic; - gr.PixelOffsetMode = PixelOffsetMode.HighQuality; - gr.DrawImage(bmp, new Rectangle(0, 0, bmp.Width, h)); - } - return newImage; - } - - private bool _allowCustomBottomMargin; - - internal void Initialize(Subtitle subtitle, SubtitleFormat format, string exportType, string fileName, VideoInfo videoInfo, string videoFileName) - { - checkBoxFullFrameImage.Checked = false; - checkBoxFullFrameImage.Visible = false; - _exportType = exportType; - _fileName = fileName; - _format = format; - _formatName = _format != null ? _format.Name : string.Empty; - if (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat) - { - CalculateHeights(subtitle); - } - _videoFileName = videoFileName; - if (exportType == ExportFormats.BluraySup) - { - Text = "Blu-ray SUP"; - } - else if (exportType == ExportFormats.VobSub) - { - Text = "VobSub (sub/idx)"; - } - else if (exportType == ExportFormats.Fab) - { - Text = "FAB Image Script"; - } - else if (exportType == ExportFormats.ImageFrame) - { - Text = "Image per frame"; - } - else if (exportType == ExportFormats.Stl) - { - Text = "DVD Studio Pro STL"; - } - else if (exportType == ExportFormats.Fcp) - { - Text = "Final Cut Pro"; - } - else if (exportType == ExportFormats.Dost) - { - Text = ExportFormats.Dost; - } - else if (exportType == ExportFormats.Edl) - { - Text = ExportFormats.Edl; - } - else if (_exportType == ExportFormats.EdlClipName) - { - Text = "EDL/CLIPNAME"; - } - else if (exportType == ExportFormats.DCinemaInterop) - { - Text = "DCinema interop/png"; - } - else if (exportType == ExportFormats.DCinemaSmpte2014) - { - Text = "DCinema SMPTE 2014/png"; - } - else if (exportType == ExportFormats.Spumux) - { - Text = ExportFormats.Spumux; - } - else - { - Text = Configuration.Settings.Language.ExportPngXml.Title; - } - - if (_exportType == ExportFormats.VobSub && !string.IsNullOrEmpty(Configuration.Settings.Tools.ExportVobSubFontName)) - { - _subtitleFontName = Configuration.Settings.Tools.ExportVobSubFontName; - } - else if ((_exportType == ExportFormats.BluraySup || _exportType == ExportFormats.Dost) && !string.IsNullOrEmpty(Configuration.Settings.Tools.ExportBluRayFontName)) - { - _subtitleFontName = Configuration.Settings.Tools.ExportBluRayFontName; - } - else if (_exportType == ExportFormats.Fcp && !string.IsNullOrEmpty(Configuration.Settings.Tools.ExportFcpFontName)) - { - _subtitleFontName = Configuration.Settings.Tools.ExportFcpFontName; - } - else if (!string.IsNullOrEmpty(Configuration.Settings.Tools.ExportFontNameOther)) - { - _subtitleFontName = Configuration.Settings.Tools.ExportFontNameOther; - } - - if (_exportType == ExportFormats.VobSub && Configuration.Settings.Tools.ExportVobSubFontSize > 0) - { - _subtitleFontSize = Configuration.Settings.Tools.ExportVobSubFontSize; - } - else if ((_exportType == ExportFormats.BluraySup || _exportType == ExportFormats.Dost) && Configuration.Settings.Tools.ExportBluRayFontSize > 0) - { - _subtitleFontSize = Configuration.Settings.Tools.ExportBluRayFontSize; - } - else if (_exportType == ExportFormats.Fcp && Configuration.Settings.Tools.ExportFcpFontSize > 0) - { - _subtitleFontSize = Configuration.Settings.Tools.ExportFcpFontSize; - } - else if (Configuration.Settings.Tools.ExportLastFontSize > 0) - { - _subtitleFontSize = Configuration.Settings.Tools.ExportLastFontSize; - } - - if (_exportType == ExportFormats.Fcp) - { - comboBoxImageFormat.Items.Add("8-bit png"); - int i = 0; - foreach (string item in comboBoxImageFormat.Items) - { - if (item == Configuration.Settings.Tools.ExportFcpImageType) - { - comboBoxImageFormat.SelectedIndex = i; - break; - } - i++; - } - } - - if (_exportType == ExportFormats.VobSub) - { - comboBoxSubtitleFontSize.SelectedIndex = 7; - int i = 0; - foreach (string item in comboBoxSubtitleFontSize.Items) - { - if (item == Convert.ToInt32(_subtitleFontSize).ToString(CultureInfo.InvariantCulture)) - { - comboBoxSubtitleFontSize.SelectedIndex = i; - break; - } - i++; - } - checkBoxTransAntiAliase.Checked = Configuration.Settings.Tools.ExportVobAntiAliasingWithTransparency; - } - else if (_exportType == ExportFormats.BluraySup || _exportType == ExportFormats.Dost || _exportType == ExportFormats.Fcp) - { - comboBoxSubtitleFontSize.SelectedIndex = 16; - int i = 0; - foreach (string item in comboBoxSubtitleFontSize.Items) - { - if (item == Convert.ToInt32(_subtitleFontSize).ToString(CultureInfo.InvariantCulture)) - { - comboBoxSubtitleFontSize.SelectedIndex = i; - break; - } - i++; - } - } - else - { - comboBoxSubtitleFontSize.SelectedIndex = 16; - int i = 0; - foreach (string item in comboBoxSubtitleFontSize.Items) - { - if (item == Convert.ToInt32(_subtitleFontSize).ToString(CultureInfo.InvariantCulture)) - { - comboBoxSubtitleFontSize.SelectedIndex = i; - break; - } - i++; - } - } - - groupBoxImageSettings.Text = Configuration.Settings.Language.ExportPngXml.ImageSettings; - labelSubtitleFont.Text = Configuration.Settings.Language.ExportPngXml.FontFamily; - labelSubtitleFontSize.Text = Configuration.Settings.Language.ExportPngXml.FontSize; - labelResolution.Text = Configuration.Settings.Language.ExportPngXml.VideoResolution; - buttonColor.Text = Configuration.Settings.Language.ExportPngXml.FontColor; - checkBoxBold.Text = Configuration.Settings.Language.General.Bold; - checkBoxSimpleRender.Text = Configuration.Settings.Language.ExportPngXml.SimpleRendering; - checkBoxTransAntiAliase.Text = Configuration.Settings.Language.ExportPngXml.AntiAliasingWithTransparency; - labelResize.Text = Configuration.Settings.Language.General.Size; - normalToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.RemoveFormattingAll; - italicToolStripMenuItem.Text = Configuration.Settings.Language.General.Italic; - boxSingleLineToolStripMenuItem.Text = Configuration.Settings.Language.ExportPngXml.BoxSingleLine; - boxMultiLineToolStripMenuItem.Text = Configuration.Settings.Language.ExportPngXml.BoxMultiLine; - adjustTimeCodesToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.Synchronization.AdjustAllTimes; - adjustDisplayTimeToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.Tools.AdjustDisplayDuration; - - checkBoxFcpFullPathUrl.Text = Configuration.Settings.Language.ExportPngXml.FcpUseFullPathUrl; - checkBoxFcpFullPathUrl.Visible = exportType == ExportFormats.Fcp; - checkBoxFcpFullPathUrl.Checked = Configuration.Settings.Tools.ExportFcpFullPathUrl; - - - comboBox3D.Items.Clear(); - comboBox3D.Items.Add(Configuration.Settings.Language.General.None); - comboBox3D.Items.Add(Configuration.Settings.Language.ExportPngXml.SideBySide3D); - comboBox3D.Items.Add(Configuration.Settings.Language.ExportPngXml.HalfTopBottom3D); - comboBox3D.SelectedIndex = 0; - - labelDepth.Text = Configuration.Settings.Language.ExportPngXml.Depth; - - numericUpDownDepth3D.Left = labelDepth.Left + labelDepth.Width + 3; - - label3D.Text = Configuration.Settings.Language.ExportPngXml.Text3D; - - comboBox3D.Left = label3D.Left + label3D.Width + 3; - - buttonBorderColor.Text = Configuration.Settings.Language.ExportPngXml.BorderColor; - labelBorderWidth.Text = Configuration.Settings.Language.ExportPngXml.BorderStyle; - labelImageFormat.Text = Configuration.Settings.Language.ExportPngXml.ImageFormat; - checkBoxFullFrameImage.Text = Configuration.Settings.Language.ExportPngXml.FullFrameImage; - - buttonExport.Text = Configuration.Settings.Language.ExportPngXml.ExportAllLines; - buttonCancel.Text = Configuration.Settings.Language.General.Ok; - labelLanguage.Text = Configuration.Settings.Language.ChooseLanguage.Language; - labelFrameRate.Text = Configuration.Settings.Language.General.FrameRate; - labelHorizontalAlign.Text = Configuration.Settings.Language.ExportPngXml.Align; - labelBottomMargin.Text = Configuration.Settings.Language.ExportPngXml.BottomMargin; - labelLeftRightMargin.Text = Configuration.Settings.Language.ExportPngXml.LeftRightMargin; - - comboBoxHAlign.Items.Clear(); - comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.Left); - comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.Center); - comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.Right); - comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.CenterLeftJustify); - comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.CenterTopJustify); - comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.CenterRightJustify); - comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.CenterLeftJustifyDialogs); - - buttonShadowColor.Text = Configuration.Settings.Language.ExportPngXml.ShadowColor; - labelShadowWidth.Text = Configuration.Settings.Language.ExportPngXml.ShadowWidth; - labelShadowTransparency.Text = Configuration.Settings.Language.ExportPngXml.Transparency; - labelLineHeight.Text = Configuration.Settings.Language.ExportPngXml.LineHeight; - - linkLabelPreview.Text = Configuration.Settings.Language.General.Preview; - linkLabelPreview.Left = groupBoxExportImage.Width - linkLabelPreview.Width - 3; - - saveImageAsToolStripMenuItem.Text = Configuration.Settings.Language.ExportPngXml.SaveImageAs; - - SubtitleListView1InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - UiUtil.InitializeSubtitleFont(subtitleListView1); - SubtitleListView1AutoSizeAllColumns(); - - _subtitle = new Subtitle(subtitle); - - panelColor.BackColor = _subtitleColor; - panelBorderColor.BackColor = _borderColor; - InitBorderStyle(); - comboBoxHAlign.SelectedIndex = 1; - comboBoxResolution.SelectedIndex = 3; - - if (Configuration.Settings.Tools.ExportLastShadowTransparency <= numericUpDownShadowTransparency.Maximum && Configuration.Settings.Tools.ExportLastShadowTransparency > 0) - { - numericUpDownShadowTransparency.Value = Configuration.Settings.Tools.ExportLastShadowTransparency; - } - - if ((_exportType == ExportFormats.BluraySup || _exportType == ExportFormats.Dost) && !string.IsNullOrEmpty(Configuration.Settings.Tools.ExportBluRayVideoResolution)) - { - SetResolution(Configuration.Settings.Tools.ExportBluRayVideoResolution); - } - - _language = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(subtitle); - if (exportType == ExportFormats.VobSub) - { - comboBoxBorderWidth.SelectedIndex = 6; - if (_exportType == ExportFormats.VobSub && !string.IsNullOrEmpty(Configuration.Settings.Tools.ExportVobSubVideoResolution)) - { - SetResolution(Configuration.Settings.Tools.ExportVobSubVideoResolution); - } - else - { - comboBoxResolution.SelectedIndex = 8; - } - - labelLanguage.Visible = true; - comboBoxLanguage.Visible = true; - comboBoxLanguage.Items.Clear(); - if (_language == null) - { - _language = Configuration.Settings.Tools.ExportVobSubLanguage; - } - - int index = -1; - foreach (var language in DvdSubtitleLanguage.CompliantLanguages) - { - int i = comboBoxLanguage.Items.Add(language); - if (language.Code == _language || index < 0 && language.Code == "en") - { - index = i; - } - } - comboBoxLanguage.SelectedIndex = index; - } - - bool showImageFormat = exportType == ExportFormats.Fab || exportType == ExportFormats.ImageFrame || exportType == ExportFormats.Stl || exportType == ExportFormats.Fcp || exportType == ExportFormats.BdnXml; - if (exportType == ExportFormats.Fab || exportType == ExportFormats.BluraySup || exportType == ExportFormats.Fcp) - { - checkBoxFullFrameImage.Visible = exportType == ExportFormats.Fab || exportType == ExportFormats.BluraySup || exportType == ExportFormats.Fcp; - } - else - { - checkBoxFullFrameImage.Checked = false; - } - - comboBoxImageFormat.Visible = showImageFormat; - labelImageFormat.Visible = showImageFormat; - labelFrameRate.Visible = exportType == ExportFormats.BdnXml || exportType == ExportFormats.BluraySup || exportType == ExportFormats.Dost || exportType == ExportFormats.ImageFrame; - comboBoxFrameRate.Visible = exportType == ExportFormats.BdnXml || exportType == ExportFormats.BluraySup || exportType == ExportFormats.Dost || exportType == ExportFormats.ImageFrame || exportType == ExportFormats.Fab || exportType == ExportFormats.Fcp; - checkBoxTransAntiAliase.Visible = exportType == ExportFormats.VobSub; - if (exportType == ExportFormats.BdnXml) - { - labelFrameRate.Top = labelLanguage.Top; - comboBoxFrameRate.Top = comboBoxLanguage.Top; - comboBoxFrameRate.Items.Add("23.976"); - comboBoxFrameRate.Items.Add("24"); - comboBoxFrameRate.Items.Add("25"); - comboBoxFrameRate.Items.Add("29.97"); - comboBoxFrameRate.Items.Add("30"); - comboBoxFrameRate.Items.Add("50"); - comboBoxFrameRate.Items.Add("59.94"); - comboBoxFrameRate.Items.Add("60"); - comboBoxFrameRate.SelectedIndex = 2; - - comboBoxImageFormat.Items.Clear(); - comboBoxImageFormat.Items.Add("Png 32-bit"); - comboBoxImageFormat.Items.Add("Png 8-bit"); - if (comboBoxImageFormat.Items[1].ToString() == Configuration.Settings.Tools.ExportBdnXmlImageType) - { - comboBoxImageFormat.SelectedIndex = 1; - } - else - { - comboBoxImageFormat.SelectedIndex = 0; - } - } - else if (exportType == ExportFormats.Dost) - { - labelFrameRate.Top = labelLanguage.Top; - comboBoxFrameRate.Top = comboBoxLanguage.Top; - comboBoxFrameRate.Items.Add("23.98"); - comboBoxFrameRate.Items.Add("24"); - comboBoxFrameRate.Items.Add("25"); - comboBoxFrameRate.Items.Add("29.97"); - comboBoxFrameRate.Items.Add("30"); - comboBoxFrameRate.Items.Add("59.94"); - comboBoxFrameRate.Items.Add("60"); - comboBoxFrameRate.SelectedIndex = 2; - } - else if (exportType == ExportFormats.ImageFrame) - { - labelFrameRate.Top = labelLanguage.Top; - comboBoxFrameRate.Top = comboBoxLanguage.Top; - comboBoxFrameRate.Items.Add("23.976"); - comboBoxFrameRate.Items.Add("24"); - comboBoxFrameRate.Items.Add("25"); - comboBoxFrameRate.Items.Add("29.97"); - comboBoxFrameRate.Items.Add("30"); - comboBoxFrameRate.Items.Add("50"); - comboBoxFrameRate.Items.Add("59.94"); - comboBoxFrameRate.Items.Add("60"); - comboBoxFrameRate.SelectedIndex = 2; - } - else if (exportType == ExportFormats.BluraySup) - { - labelFrameRate.Top = labelLanguage.Top; - comboBoxFrameRate.Top = comboBoxLanguage.Top; - comboBoxFrameRate.Items.Add("23.976"); - comboBoxFrameRate.Items.Add("24"); - comboBoxFrameRate.Items.Add("25"); - comboBoxFrameRate.Items.Add("29.97"); - comboBoxFrameRate.Items.Add("30"); - comboBoxFrameRate.Items.Add("50"); - comboBoxFrameRate.Items.Add("59.94"); - comboBoxFrameRate.Items.Add("60"); - comboBoxFrameRate.SelectedIndex = 1; - comboBoxFrameRate.DropDownStyle = ComboBoxStyle.DropDownList; - - checkBoxFullFrameImage.Top = comboBoxImageFormat.Top + 2; - panelFullFrameBackground.Top = checkBoxFullFrameImage.Top; - } - else if (exportType == ExportFormats.Fab) - { - labelFrameRate.Visible = true; - comboBoxFrameRate.Items.Add("23.976"); - comboBoxFrameRate.Items.Add("24"); - comboBoxFrameRate.Items.Add("25"); - comboBoxFrameRate.Items.Add("29.97"); - comboBoxFrameRate.Items.Add("30"); - comboBoxFrameRate.Items.Add("50"); - comboBoxFrameRate.Items.Add("59.94"); - comboBoxFrameRate.Items.Add("60"); - comboBoxFrameRate.SelectedIndex = 1; - comboBoxFrameRate.DropDownStyle = ComboBoxStyle.DropDownList; - } - else if (exportType == ExportFormats.Fcp) - { - labelFrameRate.Visible = true; - comboBoxFrameRate.Items.Add("23.976"); - comboBoxFrameRate.Items.Add("24"); - comboBoxFrameRate.Items.Add("25"); - comboBoxFrameRate.Items.Add("29.97"); - comboBoxFrameRate.Items.Add("30"); - comboBoxFrameRate.Items.Add("50"); - comboBoxFrameRate.Items.Add("59.94"); - comboBoxFrameRate.Items.Add("60"); - comboBoxFrameRate.SelectedIndex = 2; - comboBoxFrameRate.DropDownStyle = ComboBoxStyle.DropDownList; - - checkBoxFullFrameImage.Top = comboBoxFrameRate.Top + comboBoxFrameRate.Height + 5; - panelFullFrameBackground.Top = checkBoxFullFrameImage.Top; - } - if (comboBoxFrameRate.Items.Count >= 2) - { - SetLastFrameRate(Configuration.Settings.Tools.ExportLastFrameRate); - } - checkBoxFullFrameImage.Checked = Configuration.Settings.Tools.ExportFullFrame; - panelShadowColor.BackColor = Configuration.Settings.Tools.ExportShadowColor; - - comboBoxBottomMarginUnit.SelectedIndex = Configuration.Settings.Tools.ExportBottomMarginUnit == "%" ? 0 : 1; - comboBoxLeftRightMarginUnit.SelectedIndex = Configuration.Settings.Tools.ExportLeftRightMarginUnit == "%" ? 0 : 1; - - _allowCustomBottomMargin = _exportType == ExportFormats.BluraySup || _exportType == ExportFormats.VobSub || _exportType == ExportFormats.ImageFrame || _exportType == ExportFormats.BdnXml || _exportType == ExportFormats.Dost || _exportType == ExportFormats.Fab || _exportType == ExportFormats.Edl || _exportType == ExportFormats.EdlClipName; - if (_allowCustomBottomMargin) - { - comboBoxBottomMarginUnit.Visible = true; - comboBoxBottomMargin.Visible = true; - labelBottomMargin.Visible = true; - - comboBoxLeftRightMarginUnit.Visible = true; - comboBoxLeftRightMargin.Visible = true; - labelLeftRightMargin.Visible = true; - comboBoxBottomMarginUnit_SelectedIndexChanged(null, null); - } - else - { - comboBoxBottomMarginUnit.Visible = false; - comboBoxBottomMargin.Visible = false; - labelBottomMargin.Visible = false; - - comboBoxLeftRightMarginUnit.Visible = false; - comboBoxLeftRightMargin.Visible = false; - labelLeftRightMargin.Visible = false; - } - - checkBoxSkipEmptyFrameAtStart.Visible = exportType == ExportFormats.ImageFrame; - - foreach (var x in FontFamily.Families) - { - if (x.IsStyleAvailable(FontStyle.Regular) || x.IsStyleAvailable(FontStyle.Bold)) - { - comboBoxSubtitleFont.Items.Add(x.Name); - if (x.Name.Equals(_subtitleFontName, StringComparison.OrdinalIgnoreCase)) - { - comboBoxSubtitleFont.SelectedIndex = comboBoxSubtitleFont.Items.Count - 1; - } - } - } - if (comboBoxSubtitleFont.SelectedIndex == -1) - { - comboBoxSubtitleFont.SelectedIndex = 0; // take first font if default font was not found (e.g. linux) - } - - if (videoInfo != null && videoInfo.Height > 0 && videoInfo.Width > 0) - { - comboBoxResolution.Items[comboBoxResolution.Items.Count - 1] = videoInfo.Width + "x" + videoInfo.Height; - comboBoxResolution.SelectedIndex = comboBoxResolution.Items.Count - 1; - } - - if (_lineHeights != null && _lineHeights.Count > 0) - { - numericUpDownLineSpacing.Value = _lineHeights.First().Value; - } - else if (Math.Abs(_subtitleFontSize - Configuration.Settings.Tools.ExportLastFontSize) < 0.01 && Configuration.Settings.Tools.ExportLastLineHeight >= numericUpDownLineSpacing.Minimum && - Configuration.Settings.Tools.ExportLastLineHeight <= numericUpDownLineSpacing.Maximum && Configuration.Settings.Tools.ExportLastLineHeight > 0) - { - numericUpDownLineSpacing.Value = Configuration.Settings.Tools.ExportLastLineHeight; - } - else - { - var lineHeight = (int)Math.Round(GetFontHeight() * 0.64f); - if (lineHeight >= numericUpDownLineSpacing.Minimum && - lineHeight <= numericUpDownLineSpacing.Maximum) - { - numericUpDownLineSpacing.Value = lineHeight; - } - } - - if (Configuration.Settings.Tools.ExportLastBorderWidth >= 0 && Configuration.Settings.Tools.ExportLastBorderWidth < comboBoxBorderWidth.Items.Count) - { - try - { - comboBoxBorderWidth.SelectedIndex = Configuration.Settings.Tools.ExportLastBorderWidth; - } - catch - { - // ignore error - } - } - _borderWidth = GetBorderWidth(); - checkBoxBold.Checked = Configuration.Settings.Tools.ExportLastFontBold; - _subtitleFontBold = Configuration.Settings.Tools.ExportLastFontBold; - - if (Configuration.Settings.Tools.Export3DType >= 0 && Configuration.Settings.Tools.Export3DType < comboBox3D.Items.Count) - { - comboBox3D.SelectedIndex = Configuration.Settings.Tools.Export3DType; - } - - if (Configuration.Settings.Tools.Export3DDepth >= numericUpDownDepth3D.Minimum && Configuration.Settings.Tools.Export3DDepth <= numericUpDownDepth3D.Maximum) - { - numericUpDownDepth3D.Value = Configuration.Settings.Tools.Export3DDepth; - } - - if (Configuration.Settings.Tools.ExportHorizontalAlignment >= 0 && Configuration.Settings.Tools.ExportHorizontalAlignment < comboBoxHAlign.Items.Count) - { - comboBoxHAlign.SelectedIndex = Configuration.Settings.Tools.ExportHorizontalAlignment; - } - - if (exportType == ExportFormats.DCinemaInterop || exportType == ExportFormats.DCinemaSmpte2014) - { - comboBox3D.Visible = false; - numericUpDownDepth3D.Enabled = true; - labelDepth.Enabled = true; - labelDepth.Text = Configuration.Settings.Language.DCinemaProperties.ZPosition; - } - - if (_exportType == ExportFormats.Fcp) - { - comboBoxResolution.Items.Clear(); - comboBoxResolution.Items.Add("NTSC-601"); - comboBoxResolution.Items.Add("PAL-601"); - comboBoxResolution.Items.Add("square"); - comboBoxResolution.Items.Add("DVCPROHD-720P"); - comboBoxResolution.Items.Add("HD-(960x720)"); - comboBoxResolution.Items.Add("DVCPROHD-1080i60"); - comboBoxResolution.Items.Add("HD-(1280x1080)"); - comboBoxResolution.Items.Add("FullHD 1920x1080"); - comboBoxResolution.Items.Add("DVCPROHD-1080i50"); - comboBoxResolution.Items.Add("HD-(1440x1080)"); - comboBoxResolution.SelectedIndex = 7; // FullHD - if (_exportType == ExportFormats.Fcp && !string.IsNullOrEmpty(Configuration.Settings.Tools.ExportFcpVideoResolution)) - { - SetResolution(Configuration.Settings.Tools.ExportFcpVideoResolution); - } - - buttonCustomResolution.Visible = true; // we still allow for custom resolutions - - labelLanguage.Text = "NTSC/PAL"; - comboBoxLanguage.Items.Clear(); - comboBoxLanguage.Items.Add("PAL"); - comboBoxLanguage.Items.Add("NTSC"); - comboBoxLanguage.SelectedIndex = 0; - comboBoxLanguage.Visible = true; - labelLanguage.Visible = true; - if (Configuration.Settings.Tools.ExportFcpPalNtsc == "NTSC") - { - comboBoxLanguage.SelectedIndex = 1; - } - } - - comboBoxShadowWidth.SelectedIndex = 0; - bool shadowVisible = _exportType == ExportFormats.BdnXml || _exportType == ExportFormats.BluraySup || _exportType == ExportFormats.Dost || _exportType == ExportFormats.ImageFrame || _exportType == ExportFormats.Fcp || _exportType == ExportFormats.DCinemaInterop || exportType == ExportFormats.DCinemaSmpte2014 || _exportType == ExportFormats.Edl || _exportType == ExportFormats.EdlClipName; - labelShadowWidth.Visible = shadowVisible; - buttonShadowColor.Visible = shadowVisible; - comboBoxShadowWidth.Visible = shadowVisible; - if (shadowVisible && Configuration.Settings.Tools.ExportBluRayShadow < comboBoxShadowWidth.Items.Count) - { - comboBoxShadowWidth.SelectedIndex = Configuration.Settings.Tools.ExportBluRayShadow; - } - - panelShadowColor.Visible = shadowVisible; - labelShadowTransparency.Visible = shadowVisible; - numericUpDownShadowTransparency.Visible = shadowVisible; - - - if (checkBoxSimpleRender.Enabled) - { - checkBoxSimpleRender.Checked = Configuration.Settings.Tools.ExportVobSubSimpleRendering || _language == "ar"; - } - - if (exportType == ExportFormats.BluraySup || exportType == ExportFormats.VobSub || exportType == ExportFormats.BdnXml) - { - subtitleListView1.CheckBoxes = true; - subtitleListView1.Columns.Insert(0, Configuration.Settings.Language.ExportPngXml.Forced); - SubtitleListView1Fill(_subtitle); - if (_vobSubOcr != null) - { - for (int index = 0; index < _subtitle.Paragraphs.Count; index++) - { - if (_vobSubOcr.GetIsForced(index)) - { - subtitleListView1.Items[index].Checked = true; - } - } - } - - SubtitleListView1SelectIndexAndEnsureVisible(0); - } - else - { - SubtitleListView1Fill(_subtitle); - SubtitleListView1SelectIndexAndEnsureVisible(0); - } - } - - private float GetFontHeight() - { - var mbp = new MakeBitmapParameter - { - SubtitleFontName = _subtitleFontName, - SubtitleFontSize = float.Parse(comboBoxSubtitleFontSize.SelectedItem.ToString()), - SubtitleFontBold = _subtitleFontBold - }; - var fontSize = (float)TextDraw.GetFontSize(mbp.SubtitleFontSize); - using (var font = GetFont(mbp, fontSize)) - using (var bmp = new Bitmap(100, 100)) - using (var g = Graphics.FromImage(bmp)) - { - var textSize = g.MeasureString("Hj!", font); - return textSize.Height; - } - } - - private void CalculateHeights(Subtitle subtitle) - { - foreach (var paragraph in subtitle.Paragraphs) - { - var styleName = paragraph.Extra; - if (!string.IsNullOrEmpty(paragraph.Extra) && !_lineHeights.ContainsKey(styleName)) - { - var style = AdvancedSubStationAlpha.GetSsaStyle(paragraph.Extra, subtitle.Header); - using (var bmp = new Bitmap(100, 100)) - { - using (var g = Graphics.FromImage(bmp)) - { - var mbp = new MakeBitmapParameter - { - SubtitleFontName = style.FontName, - SubtitleFontSize = style.FontSize, - SubtitleFontBold = style.Bold - }; - var fontSize = (float)TextDraw.GetFontSize(mbp.SubtitleFontSize); - Font font = GetFont(mbp, fontSize); - SizeF textSize = g.MeasureString("Hj!", font); - int lineHeight = (int)Math.Round(textSize.Height * 0.64f); - if (fontSize < 30) - { - lineHeight = (int)Math.Round(textSize.Height * 0.69f); - } - - _lineHeights.Add(styleName, lineHeight); - } - } - } - } - } - - private void InitBorderStyle() - { - comboBoxBorderWidth.Items.Clear(); - comboBoxBorderWidth.Items.Add(Configuration.Settings.Language.ExportPngXml.BorderStyleBoxForEachLine); - comboBoxBorderWidth.Items.Add(Configuration.Settings.Language.ExportPngXml.BorderStyleOneBox); - for (int i = 0; i < 16; i++) - { - comboBoxBorderWidth.Items.Add(string.Format(Configuration.Settings.Language.ExportPngXml.BorderStyleNormalWidthX, i)); - } - comboBoxBorderWidth.SelectedIndex = 4; - } - - private void SetLastFrameRate(double lastFrameRate) - { - for (int i = 0; i < comboBoxFrameRate.Items.Count; i++) - { - if (double.TryParse(comboBoxFrameRate.Items[i].ToString().Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var d)) - { - if (Math.Abs(lastFrameRate - d) < 0.01) - { - comboBoxFrameRate.SelectedIndex = i; - return; - } - } - } - } - - internal void SetResolution(Point resolution) - { - comboBoxResolution.Items.Add(resolution.X + "x" + resolution.Y); - comboBoxResolution.SelectedIndex = comboBoxResolution.Items.Count - 1; - } - - internal void InitializeFromVobSubOcr(Subtitle subtitle, SubtitleFormat format, string exportType, string fileName, IBinaryParagraphList vobSubOcr, string languageString) - { - _vobSubOcr = vobSubOcr; - if (_vobSubOcr != null && exportType != ExportFormats.VobSub) - { - comboBoxResizePercentage.Items.Clear(); - for (int i = 50; i < 400; i++) - { - comboBoxResizePercentage.Items.Add(i + "%"); - } - comboBoxResizePercentage.Items.Add("500%"); - comboBoxResizePercentage.SelectedIndex = 50; - comboBoxResizePercentage.Visible = true; - labelResize.Visible = true; - labelResize.Left = buttonColor.Left; - labelResize.Top = buttonColor.Top; - comboBoxResizePercentage.Left = labelResize.Left + labelResize.Width + 5; - comboBoxResizePercentage.Top = labelResize.Top - 4; - } - else - { - comboBoxResizePercentage.Visible = false; - labelResize.Visible = false; - } - - Initialize(subtitle, format, exportType, fileName, null, _videoFileName); - - //set language - if (!string.IsNullOrEmpty(languageString)) - { - if (languageString.Contains('(') && languageString[0] != '(') - { - languageString = languageString.Substring(0, languageString.IndexOf('(') - 1).Trim(); - } - - for (int i = 0; i < comboBoxLanguage.Items.Count; i++) - { - string l = comboBoxLanguage.Items[i].ToString(); - if (l == languageString) - { - comboBoxLanguage.SelectedIndex = i; - break; - } - } - } - - //Disable options not available when exporting existing images - comboBoxSubtitleFont.Enabled = false; - comboBoxSubtitleFontSize.Enabled = false; - - buttonColor.Visible = false; - panelColor.Visible = false; - checkBoxBold.Visible = false; - checkBoxSimpleRender.Visible = false; - comboBox3D.Enabled = false; - numericUpDownDepth3D.Enabled = false; - - buttonBorderColor.Visible = false; - panelBorderColor.Visible = false; - labelBorderWidth.Visible = false; - comboBoxBorderWidth.Visible = false; - - buttonShadowColor.Visible = false; - panelShadowColor.Visible = false; - labelShadowWidth.Visible = false; - comboBoxShadowWidth.Visible = false; - labelShadowTransparency.Visible = false; - numericUpDownShadowTransparency.Visible = false; - labelLineHeight.Visible = false; - numericUpDownLineSpacing.Visible = false; - } - - private void subtitleListView1_SelectedIndexChanged(object sender, EventArgs e) - { - if (_isLoading) - { - return; - } - - _previewTimer.Stop(); - UpdateLineSpacing(); - _previewTimer.Start(); - } - - internal int GetBottomMarginInPixels(Paragraph p) - { - if (!_allowCustomBottomMargin) - { - return 20; - } - - if (!string.IsNullOrEmpty(p?.Extra) && (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat)) - { - var style = AdvancedSubStationAlpha.GetSsaStyle(p.Extra, _subtitle.Header); - return style.MarginVertical; - } - - var s = comboBoxBottomMargin.Text; - if (comboBoxBottomMarginUnit.SelectedIndex == 0) // % - { - GetResolution(out _, out var height); - return (int)Math.Round(int.Parse(s.TrimEnd('%')) / 100.0 * height); - } - - // pixels - return int.Parse(s); - } - - private int GetLeftMarginInPixels(Paragraph p) - { - if (!string.IsNullOrEmpty(p?.Extra) && (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat)) - { - var style = AdvancedSubStationAlpha.GetSsaStyle(p.Extra, _subtitle.Header); - return style.MarginLeft; - } - - var s = comboBoxLeftRightMargin.Text; - if (comboBoxLeftRightMarginUnit.SelectedIndex == 0) // % - { - GetResolution(out var width, out _); - return (int)Math.Round(int.Parse(s) / 100.0 * width); - } - - // pixels - return int.Parse(s); - } - - private int GetRightMarginInPixels(Paragraph p) - { - if (!string.IsNullOrEmpty(p?.Extra) && (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat)) - { - var style = AdvancedSubStationAlpha.GetSsaStyle(p.Extra, _subtitle.Header); - return style.MarginRight; - } - return GetLeftMarginInPixels(p); - } - - - - private void GeneratePreview() - { - SetupImageParameters(); - if (subtitleListView1.SelectedItems.Count > 0) - { - var p = _subtitle.GetParagraphOrDefault(subtitleListView1.SelectedItems[0].Index); - if (p == null) - { - return; - } - var bmp = GenerateImageFromTextWithStyle(p, out var mbp); - if (checkBoxFullFrameImage.Checked) - { - var nbmp = new NikseBitmap(bmp); - nbmp.ReplaceTransparentWith(panelFullFrameBackground.BackColor); - bmp.Dispose(); - bmp = nbmp.GetBitmap(); - } - else - { - groupBoxExportImage.BackColor = DefaultBackColor; - } - pictureBox1.Image = bmp; - - int w = groupBoxExportImage.Width - 4; - pictureBox1.Width = bmp.Width; - pictureBox1.Height = bmp.Height; - pictureBox1.Top = groupBoxExportImage.Height - bmp.Height - GetBottomMarginInPixels(p); - pictureBox1.Left = (w - bmp.Width) / 2; - var alignment = GetAlignmentFromParagraph(mbp, _format, _subtitle); - - // fix alignment from UI - if (comboBoxHAlign.Visible && alignment == ContentAlignment.BottomCenter && _format.GetType() != typeof(AdvancedSubStationAlpha) && _format.GetType() != typeof(SubStationAlpha)) - { - if (comboBoxHAlign.SelectedIndex == 0) - { - alignment = ContentAlignment.BottomLeft; - } - else if (comboBoxHAlign.SelectedIndex == 2) - { - alignment = ContentAlignment.BottomRight; - } - } - - if (comboBoxHAlign.Visible) - { - if (comboBoxLeftRightMargin.Visible) - { - if (alignment == ContentAlignment.BottomLeft || alignment == ContentAlignment.MiddleLeft || alignment == ContentAlignment.TopLeft) - { - pictureBox1.Left = GetLeftMarginInPixels(p); - } - else if (alignment == ContentAlignment.BottomRight || alignment == ContentAlignment.MiddleRight || alignment == ContentAlignment.TopRight) - { - pictureBox1.Left = w - bmp.Width - GetRightMarginInPixels(p); - } - } - - if (alignment == ContentAlignment.MiddleLeft || alignment == ContentAlignment.MiddleCenter || alignment == ContentAlignment.MiddleRight) - { - pictureBox1.Top = (groupBoxExportImage.Height - 4 - bmp.Height) / 2; - } - else if (_allowCustomBottomMargin && alignment == ContentAlignment.TopLeft || alignment == ContentAlignment.TopCenter || alignment == ContentAlignment.TopRight) - { - pictureBox1.Top = GetBottomMarginInPixels(p); - } - } - if (bmp.Width > groupBoxExportImage.Width + 20 || bmp.Height > groupBoxExportImage.Height + 20) - { - pictureBox1.Left = 5; - pictureBox1.Top = 20; - pictureBox1.Width = groupBoxExportImage.Width - 10; - pictureBox1.Height = groupBoxExportImage.Height - 30; - pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; - } - else - { - pictureBox1.SizeMode = PictureBoxSizeMode.Normal; - } - groupBoxExportImage.Text = $"{bmp.Width}x{bmp.Height}"; - if (!string.IsNullOrEmpty(mbp.Error)) - { - groupBoxExportImage.BackColor = Color.Red; - groupBoxExportImage.Text = groupBoxExportImage.Text + " - " + mbp.Error; - } - else - { - if (checkBoxFullFrameImage.Checked) - { - groupBoxExportImage.BackColor = panelFullFrameBackground.BackColor; - } - else - { - groupBoxExportImage.BackColor = groupBoxImageSettings.BackColor; - } - } - } - } - - private void buttonColor_Click(object sender, EventArgs e) - { - bool showAlpha = _exportType == ExportFormats.Fab || _exportType == ExportFormats.BdnXml; - using (var colorChooser = new ColorChooser { Color = panelColor.BackColor, ShowAlpha = showAlpha }) - { - if (colorChooser.ShowDialog() == DialogResult.OK) - { - panelColor.BackColor = colorChooser.Color; - subtitleListView1_SelectedIndexChanged(null, null); - } - } - } - - private void panelColor_MouseClick(object sender, MouseEventArgs e) - { - buttonColor_Click(null, null); - } - - private void buttonBorderColor_Click(object sender, EventArgs e) - { - using (var colorChooser = new ColorChooser { Color = panelBorderColor.BackColor }) - { - if (colorChooser.ShowDialog() == DialogResult.OK) - { - panelBorderColor.BackColor = colorChooser.Color; - subtitleListView1_SelectedIndexChanged(null, null); - } - } - } - - private void panelBorderColor_MouseClick(object sender, MouseEventArgs e) - { - buttonBorderColor_Click(null, null); - } - - private void comboBoxSubtitleFont_SelectedValueChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void comboBoxSubtitleFontSize_SelectedIndexChanged(object sender, EventArgs e) - { - if (_isLoading) - { - return; - } - - if (_formatName != AdvancedSubStationAlpha.NameOfFormat && _formatName != SubStationAlpha.NameOfFormat && - comboBoxSubtitleFontSize.Enabled) - { - var lineHeight = (int)Math.Round(GetFontHeight() * 0.64f); - if (lineHeight >= numericUpDownLineSpacing.Minimum && - lineHeight <= numericUpDownLineSpacing.Maximum) - { - numericUpDownLineSpacing.Value = lineHeight; - } - } - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void UpdateLineSpacing() - { - var style = string.Empty; - if (subtitleListView1.SelectedIndices.Count > 0) - { - style = GetStyleName(_subtitle.Paragraphs[subtitleListView1.SelectedItems[0].Index]); - if (!string.IsNullOrEmpty(style) && _lineHeights.ContainsKey(style)) - { - numericUpDownLineSpacing.Value = _lineHeights[style]; - } - } - labelLineHeightStyle.Text = style; - } - - private void comboBoxBorderWidth_SelectedIndexChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void checkBoxAntiAlias_CheckedChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void ExportPngXml_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#export"); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.G && subtitleListView1.Items.Count > 1) - { - using (var goToLine = new GoToLine()) - { - goToLine.Initialize(1, subtitleListView1.Items.Count); - if (goToLine.ShowDialog(this) == DialogResult.OK) - { - subtitleListView1.Items[goToLine.LineNumber - 1].Selected = true; - subtitleListView1.Items[goToLine.LineNumber - 1].EnsureVisible(); - subtitleListView1.Items[goToLine.LineNumber - 1].Focused = true; - } - } - } - } - - private void ExportPngXml_Shown(object sender, EventArgs e) - { - _isLoading = false; - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void comboBoxHAlign_SelectedIndexChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void checkBoxBold_CheckedChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void buttonCustomResolution_Click(object sender, EventArgs e) - { - using (var cr = new ChooseResolution()) - { - if (cr.ShowDialog(this) == DialogResult.OK) - { - comboBoxResolution.Items[comboBoxResolution.Items.Count - 1] = cr.VideoWidth + "x" + cr.VideoHeight; - comboBoxResolution.SelectedIndex = comboBoxResolution.Items.Count - 1; - } - } - } - - private void ExportPngXml_ResizeEnd(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - subtitleListView1.Columns[subtitleListView1.Columns.Count - 1].Width = -2; - } - - private void comboBoxBottomMargin_SelectedIndexChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void comboBoxResolution_SelectedIndexChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void ExportPngXml_SizeChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - subtitleListView1.Columns[subtitleListView1.Columns.Count - 1].Width = -2; - } - - private void ExportPngXml_FormClosing(object sender, FormClosingEventArgs e) - { - GetResolution(out var width, out var height); - string res = $"{width}x{height}"; - - if (_exportType == ExportFormats.VobSub) - { - Configuration.Settings.Tools.ExportVobSubFontName = _subtitleFontName; - Configuration.Settings.Tools.ExportVobSubFontSize = (int)_subtitleFontSize; - Configuration.Settings.Tools.ExportVobSubVideoResolution = res; - Configuration.Settings.Tools.ExportVobSubLanguage = comboBoxLanguage.Text; - Configuration.Settings.Tools.ExportVobAntiAliasingWithTransparency = checkBoxTransAntiAliase.Checked; - } - else if (_exportType == ExportFormats.BluraySup || _exportType == ExportFormats.Dost) - { - Configuration.Settings.Tools.ExportBluRayFontName = _subtitleFontName; - Configuration.Settings.Tools.ExportBluRayFontSize = (int)_subtitleFontSize; - Configuration.Settings.Tools.ExportBluRayVideoResolution = res; - } - else if (_exportType == ExportFormats.BdnXml || _exportType == ExportFormats.Fcp) - { - Configuration.Settings.Tools.ExportBdnXmlImageType = comboBoxImageFormat.SelectedItem.ToString(); - } - if (_exportType == ExportFormats.Fcp) - { - Configuration.Settings.Tools.ExportFcpFontName = _subtitleFontName; - Configuration.Settings.Tools.ExportFcpFontSize = (int)_subtitleFontSize; - if (comboBoxImageFormat.SelectedItem != null) - { - Configuration.Settings.Tools.ExportFcpImageType = comboBoxImageFormat.SelectedItem.ToString(); - } - - Configuration.Settings.Tools.ExportFcpVideoResolution = res; - Configuration.Settings.Tools.ExportFcpPalNtsc = comboBoxLanguage.SelectedIndex == 0 ? "PAL" : "NTSC"; - } - Configuration.Settings.Tools.ExportFcpFullPathUrl = checkBoxFcpFullPathUrl.Checked; - Configuration.Settings.Tools.ExportLastShadowTransparency = (int)numericUpDownShadowTransparency.Value; - Configuration.Settings.Tools.ExportLastFrameRate = FrameRate; - Configuration.Settings.Tools.ExportFullFrame = checkBoxFullFrameImage.Checked; - Configuration.Settings.Tools.ExportShadowColor = panelShadowColor.BackColor; - Configuration.Settings.Tools.ExportFontColor = _subtitleColor; - Configuration.Settings.Tools.ExportBorderColor = _borderColor; - - if (checkBoxSimpleRender.Enabled) - { - Configuration.Settings.Tools.ExportVobSubSimpleRendering = checkBoxSimpleRender.Checked; - } - - if (_exportType == ExportFormats.BluraySup) - { - if (comboBoxBottomMarginUnit.SelectedIndex == 0) // % - { - Configuration.Settings.Tools.ExportBluRayBottomMarginPercent = comboBoxBottomMargin.SelectedIndex; - } - else // pixels - { - Configuration.Settings.Tools.ExportBluRayBottomMarginPixels = comboBoxBottomMargin.SelectedIndex; - } - } - else if (_allowCustomBottomMargin) - { - if (comboBoxBottomMarginUnit.SelectedIndex == 0) // % - { - Configuration.Settings.Tools.ExportBottomMarginPercent = comboBoxBottomMargin.SelectedIndex; - } - else // pixels - { - Configuration.Settings.Tools.ExportBottomMarginPixels = comboBoxBottomMargin.SelectedIndex; - } - } - - if (comboBoxLeftRightMargin.Visible) - { - if (comboBoxLeftRightMarginUnit.SelectedIndex == 0) // % - { - Configuration.Settings.Tools.ExportLeftRightMarginPercent = comboBoxLeftRightMargin.SelectedIndex; - } - else // pixels - { - Configuration.Settings.Tools.ExportLeftRightMarginPixels = comboBoxLeftRightMargin.SelectedIndex; - } - } - - if (comboBoxBottomMarginUnit.Visible) - { - Configuration.Settings.Tools.ExportBottomMarginUnit = comboBoxBottomMarginUnit.SelectedIndex == 0 ? "%" : "px"; - } - - if (comboBoxLeftRightMarginUnit.Visible) - { - Configuration.Settings.Tools.ExportLeftRightMarginUnit = comboBoxLeftRightMarginUnit.SelectedIndex == 0 ? "%" : "px"; - } - - Configuration.Settings.Tools.ExportHorizontalAlignment = comboBoxHAlign.SelectedIndex; - Configuration.Settings.Tools.Export3DType = comboBox3D.SelectedIndex; - Configuration.Settings.Tools.Export3DDepth = (int)numericUpDownDepth3D.Value; - - if (comboBoxShadowWidth.Visible) - { - Configuration.Settings.Tools.ExportBluRayShadow = comboBoxShadowWidth.SelectedIndex; - } - - Configuration.Settings.Tools.ExportFontNameOther = _subtitleFontName; - Configuration.Settings.Tools.ExportLastFontSize = (int)_subtitleFontSize; - Configuration.Settings.Tools.ExportLastLineHeight = (int)numericUpDownLineSpacing.Value; - Configuration.Settings.Tools.ExportLastBorderWidth = comboBoxBorderWidth.SelectedIndex; - Configuration.Settings.Tools.ExportLastFontBold = checkBoxBold.Checked; - } - - private void numericUpDownDepth3D_ValueChanged(object sender, EventArgs e) - { - if (!timerPreview.Enabled) - { - timerPreview.Start(); - } - } - - private void comboBox3D_SelectedIndexChanged(object sender, EventArgs e) - { - bool enable = comboBox3D.SelectedIndex > 0; - labelDepth.Enabled = enable; - numericUpDownDepth3D.Enabled = enable; - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void timerPreview_Tick(object sender, EventArgs e) - { - timerPreview.Stop(); - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void saveImageAsToolStripMenuItem_Click(object sender, EventArgs e) - { - if (subtitleListView1.SelectedItems.Count != 1) - { - return; - } - - int selectedIndex = subtitleListView1.SelectedItems[0].Index; - - saveFileDialog1.Title = Configuration.Settings.Language.VobSubOcr.SaveSubtitleImageAs; - saveFileDialog1.AddExtension = true; - saveFileDialog1.FileName = "Image" + selectedIndex; - saveFileDialog1.Filter = "PNG image|*.png|BMP image|*.bmp|GIF image|*.gif|TIFF image|*.tiff"; - saveFileDialog1.FilterIndex = 0; - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - var bmp = pictureBox1.Image as Bitmap; - if (bmp == null) - { - MessageBox.Show("No image!"); - return; - } - - try - { - if (saveFileDialog1.FilterIndex == 0) - { - bmp.Save(saveFileDialog1.FileName, ImageFormat.Png); - } - else if (saveFileDialog1.FilterIndex == 1) - { - bmp.Save(saveFileDialog1.FileName); - } - else if (saveFileDialog1.FilterIndex == 2) - { - bmp.Save(saveFileDialog1.FileName, ImageFormat.Gif); - } - else - { - bmp.Save(saveFileDialog1.FileName, ImageFormat.Tiff); - } - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - } - } - } - - private void buttonShadowColor_Click(object sender, EventArgs e) - { - using (var colorChooser = new ColorChooser { Color = panelShadowColor.BackColor }) - { - if (colorChooser.ShowDialog() == DialogResult.OK) - { - panelShadowColor.BackColor = colorChooser.Color; - subtitleListView1_SelectedIndexChanged(null, null); - numericUpDownShadowTransparency.Value = colorChooser.Color.A; - } - } - } - - private void panelShadowColor_MouseClick(object sender, MouseEventArgs e) - { - buttonShadowColor_Click(sender, e); - } - - private void comboBoxShadowWidth_SelectedIndexChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void numericUpDownShadowTransparency_ValueChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void comboBoxSubtitleFont_SelectedIndexChanged(object sender, EventArgs e) - { - if (_isLoading) - { - return; - } - - if (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat) - { - return; - } - - var lineHeight = (int)Math.Round(GetFontHeight() * 0.64f); - if (lineHeight >= numericUpDownLineSpacing.Minimum && - lineHeight <= numericUpDownLineSpacing.Maximum) - { - numericUpDownLineSpacing.ValueChanged -= numericUpDownLineSpacing_ValueChanged; - numericUpDownLineSpacing.Value = lineHeight; - numericUpDownLineSpacing.ValueChanged += numericUpDownLineSpacing_ValueChanged; - } - subtitleListView1_SelectedIndexChanged(null, null); - - // change font - if (!comboBoxSubtitleFont.Enabled) - { - return; - } - try - { - var fontName = comboBoxSubtitleFont.SelectedItem.ToString(); - int columnIndexText = 4; - if (subtitleListView1.CheckBoxes) - { - columnIndexText++; - } - - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - - subtitleListView1.Items[i].SubItems[columnIndexText].Font = new Font(fontName, Font.Size); - } - } - catch - { - // ignore unable to set font errors - } - } - - private void numericUpDownLineSpacing_ValueChanged(object sender, EventArgs e) - { - var value = (int)numericUpDownLineSpacing.Value; - var style = string.Empty; - if (subtitleListView1.SelectedIndices.Count > 0) - { - style = GetStyleName(_subtitle.Paragraphs[subtitleListView1.SelectedItems[0].Index]); - } - - if (_lineHeights.ContainsKey(style)) - { - _lineHeights[style] = value; - } - - if (_formatName != AdvancedSubStationAlpha.NameOfFormat && _formatName != SubStationAlpha.NameOfFormat) - { - _lineHeights.Clear(); - _lineHeights.Add(string.Empty, value); - } - subtitleListView1_SelectedIndexChanged(null, null); - } - - private static string GetStyleName(Paragraph paragraph) - { - if ((_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat) && !string.IsNullOrEmpty(paragraph.Extra)) - { - return paragraph.Extra; - } - return string.Empty; - } - - private void ListViewToggleTag(string tag) - { - if (_subtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0) - { - var indexes = new List(); - foreach (ListViewItem item in subtitleListView1.SelectedItems) - { - indexes.Add(item.Index); - } - - subtitleListView1.BeginUpdate(); - foreach (int i in indexes) - { - if (tag == BoxMultiLineText) - { - _subtitle.Paragraphs[i].Text = _subtitle.Paragraphs[i].Text.Replace("<" + BoxSingleLineText + ">", string.Empty).Replace("", string.Empty); - } - else if (tag == BoxSingleLineText) - { - _subtitle.Paragraphs[i].Text = _subtitle.Paragraphs[i].Text.Replace("<" + BoxMultiLineText + ">", string.Empty).Replace("", string.Empty); - } - - if (_subtitle.Paragraphs[i].Text.Contains("<" + tag + ">")) - { - _subtitle.Paragraphs[i].Text = _subtitle.Paragraphs[i].Text.Replace("<" + tag + ">", string.Empty); - _subtitle.Paragraphs[i].Text = _subtitle.Paragraphs[i].Text.Replace("", string.Empty); - } - else - { - int indexOfEndBracket = _subtitle.Paragraphs[i].Text.IndexOf('}'); - if (_subtitle.Paragraphs[i].Text.StartsWith("{\\", StringComparison.Ordinal) && indexOfEndBracket > 1 && indexOfEndBracket < 6) - { - _subtitle.Paragraphs[i].Text = string.Format("{2}<{0}>{1}", tag, _subtitle.Paragraphs[i].Text.Remove(0, indexOfEndBracket + 1), _subtitle.Paragraphs[i].Text.Substring(0, indexOfEndBracket + 1)); - } - else - { - _subtitle.Paragraphs[i].Text = string.Format("<{0}>{1}", tag, _subtitle.Paragraphs[i].Text); - } - } - SubtitleListView1SetText(i, _subtitle.Paragraphs[i].Text); - } - subtitleListView1.EndUpdate(); - } - } - - private void boxMultiLineToolStripMenuItem_Click(object sender, EventArgs e) - { - ListViewToggleTag(BoxMultiLineText); - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void boxSingleLineToolStripMenuItem_Click(object sender, EventArgs e) - { - ListViewToggleTag(BoxSingleLineText); - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void italicToolStripMenuItem_Click(object sender, EventArgs e) - { - ListViewToggleTag("i"); - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void normalToolStripMenuItem_Click(object sender, EventArgs e) - { - if (_subtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0) - { - bool isSsa = _format.Name == SubStationAlpha.NameOfFormat || - _format.Name == AdvancedSubStationAlpha.NameOfFormat; - - foreach (ListViewItem item in subtitleListView1.SelectedItems) - { - Paragraph p = _subtitle.GetParagraphOrDefault(item.Index); - if (p != null) - { - int indexOfEndBracket = p.Text.IndexOf('}'); - if (p.Text.StartsWith("{\\", StringComparison.Ordinal) && indexOfEndBracket > 1 && indexOfEndBracket < 6) - { - p.Text = p.Text.Remove(0, indexOfEndBracket + 1); - } - - p.Text = HtmlUtil.RemoveHtmlTags(p.Text); - p.Text = p.Text.Replace("<" + BoxSingleLineText + ">", string.Empty).Replace("", string.Empty); - p.Text = p.Text.Replace("<" + BoxMultiLineText + ">", string.Empty).Replace("", string.Empty); - - if (isSsa) - { - p.Text = Utilities.RemoveSsaTags(p.Text); - } - - SubtitleListView1SetText(item.Index, p.Text); - } - } - } - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void subtitleListView1_KeyDown(object sender, KeyEventArgs e) - { - var italicShortCut = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxItalic); - if (e.KeyData == italicShortCut) - { - ListViewToggleTag("i"); - subtitleListView1_SelectedIndexChanged(null, null); - } - else if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) - { - subtitleListView1.SelectAll(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.D && e.Modifiers == Keys.Control) - { - subtitleListView1.SelectFirstSelectedItemOnly(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.I && e.Modifiers == (Keys.Control | Keys.Shift)) - { - subtitleListView1.InverseSelection(); - e.SuppressKeyPress = true; - } - } - - public void SubtitleListView1SelectNone() - { - foreach (ListViewItem item in subtitleListView1.SelectedItems) - { - item.Selected = false; - } - } - - private void SubtitleListView1SelectIndexAndEnsureVisible(int index) - { - if (index < 0 || index >= subtitleListView1.Items.Count || subtitleListView1.Items.Count == 0) - { - return; - } - - if (subtitleListView1.TopItem == null) - { - return; - } - - int bottomIndex = subtitleListView1.TopItem.Index + (Height - 25) / 16; - int itemsBeforeAfterCount = (bottomIndex - subtitleListView1.TopItem.Index) / 2 - 1; - if (itemsBeforeAfterCount < 0) - { - itemsBeforeAfterCount = 1; - } - - int beforeIndex = index - itemsBeforeAfterCount; - if (beforeIndex < 0) - { - beforeIndex = 0; - } - - int afterIndex = index + itemsBeforeAfterCount; - if (afterIndex >= subtitleListView1.Items.Count) - { - afterIndex = subtitleListView1.Items.Count - 1; - } - - SubtitleListView1SelectNone(); - if (subtitleListView1.TopItem.Index <= beforeIndex && bottomIndex > afterIndex) - { - subtitleListView1.Items[index].Selected = true; - subtitleListView1.Items[index].EnsureVisible(); - return; - } - - subtitleListView1.Items[beforeIndex].EnsureVisible(); - subtitleListView1.EnsureVisible(beforeIndex); - subtitleListView1.Items[afterIndex].EnsureVisible(); - subtitleListView1.EnsureVisible(afterIndex); - subtitleListView1.Items[index].Selected = true; - subtitleListView1.Items[index].EnsureVisible(); - } - - private void SubtitleListView1Add(Paragraph paragraph) - { - var item = new ListViewItem(paragraph.Number.ToString(CultureInfo.InvariantCulture)) { Tag = paragraph, UseItemStyleForSubItems = false }; - ListViewItem.ListViewSubItem subItem; - - if (subtitleListView1.CheckBoxes) - { - item.Text = string.Empty; - subItem = new ListViewItem.ListViewSubItem(item, paragraph.Number.ToString(CultureInfo.InvariantCulture)) { Tag = paragraph }; - item.SubItems.Add(subItem); - } - - subItem = new ListViewItem.ListViewSubItem(item, paragraph.StartTime.ToDisplayString()); - item.SubItems.Add(subItem); - - subItem = new ListViewItem.ListViewSubItem(item, paragraph.EndTime.ToDisplayString()); - item.SubItems.Add(subItem); - - subItem = new ListViewItem.ListViewSubItem(item, paragraph.Duration.ToShortDisplayString()); - item.SubItems.Add(subItem); - - subItem = new ListViewItem.ListViewSubItem(item, UiUtil.GetListViewTextFromString(paragraph.Text)); - try - { - if (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat) - { - var style = AdvancedSubStationAlpha.GetSsaStyle(paragraph.Extra, _subtitle.Header); - subItem.Font = new Font(style.FontName, Font.Size); - } - else - { - subItem.Font = new Font(_subtitleFontName, Font.Size); - } - } - catch - { - subItem.Font = new Font(_subtitleFontName, Font.Size, FontStyle.Bold); - } - item.SubItems.Add(subItem); - - if (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat) - { - subItem = new ListViewItem.ListViewSubItem(item, paragraph.Extra); - item.SubItems.Add(subItem); - } - - subtitleListView1.Items.Add(item); - } - - private void SubtitleListView1Fill(Subtitle subtitle) - { - subtitleListView1.BeginUpdate(); - subtitleListView1.Items.Clear(); - foreach (Paragraph paragraph in subtitle.Paragraphs) - { - SubtitleListView1Add(paragraph); - } - subtitleListView1.EndUpdate(); - } - - private void SubtitleListView1AutoSizeAllColumns() - { - int columnIndexNumber = 0; - int columnIndexStart = 1; - int columnIndexEnd = 2; - int columnIndexDuration = 3; - int columnIndexText = 4; - int columnIndexStyle = 5; - - if (subtitleListView1.CheckBoxes) - { - subtitleListView1.Columns[0].Width = 60; - columnIndexNumber++; - columnIndexStart++; - columnIndexEnd++; - columnIndexDuration++; - columnIndexText++; - } - - var settings = Configuration.Settings; - if (settings != null && settings.General.ListViewColumnsRememberSize && settings.General.ListViewNumberWidth > 1) - { - subtitleListView1.Columns[columnIndexNumber].Width = settings.General.ListViewNumberWidth; - } - else - { - subtitleListView1.Columns[columnIndexNumber].Width = 55; - } - - subtitleListView1.Columns[columnIndexStart].Width = 90; - subtitleListView1.Columns[columnIndexEnd].Width = 90; - subtitleListView1.Columns[columnIndexDuration].Width = 60; - if (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat) - { - subtitleListView1.Columns.Add("style", Configuration.Settings.Language.General.Style, 90); - subtitleListView1.Columns[columnIndexText].Width = subtitleListView1.Width - - subtitleListView1.Columns[columnIndexNumber].Width - - subtitleListView1.Columns[columnIndexStart].Width - - subtitleListView1.Columns[columnIndexEnd].Width - - subtitleListView1.Columns[columnIndexDuration].Width - - 175; - subtitleListView1.Columns[columnIndexStyle].Width = -2; - } - else - { - subtitleListView1.Columns[columnIndexText].Width = -2; - } - } - - private void SubtitleListView1InitializeLanguage(LanguageStructure.General general, Core.Common.Settings settings) - { - int columnIndexNumber = 0; - int columnIndexStart = 1; - int columnIndexEnd = 2; - int columnIndexDuration = 3; - int columnIndexText = 4; - - if (subtitleListView1.CheckBoxes) - { - columnIndexNumber++; - columnIndexStart++; - columnIndexEnd++; - columnIndexDuration++; - columnIndexText++; - } - - subtitleListView1.Columns[columnIndexNumber].Text = general.NumberSymbol; - subtitleListView1.Columns[columnIndexStart].Text = general.StartTime; - subtitleListView1.Columns[columnIndexEnd].Text = general.EndTime; - subtitleListView1.Columns[columnIndexDuration].Text = general.Duration; - subtitleListView1.Columns[columnIndexText].Text = general.Text; - subtitleListView1.ForeColor = settings.General.SubtitleFontColor; - subtitleListView1.BackColor = settings.General.SubtitleBackgroundColor; - } - - private void SubtitleListView1SetText(int index, string text) - { - int columnIndexText = 4; - - if (subtitleListView1.CheckBoxes) - { - columnIndexText++; - } - - subtitleListView1.Items[index].SubItems[columnIndexText].Text = UiUtil.GetListViewTextFromString(text); - } - - private void FillPreviewBackground(Bitmap bmp, Graphics g, Paragraph p) - { - try - { - if (!string.IsNullOrWhiteSpace(_videoFileName) && LibVlcDynamic.IsInstalled) - { - using (var vlc = new LibVlcDynamic()) - { - vlc.Initialize(panelVlcTemp, _videoFileName, null, null); - Application.DoEvents(); - vlc.Volume = 0; - vlc.Pause(); - vlc.CurrentPosition = p.StartTime.TotalSeconds; - Application.DoEvents(); - var fileName = FileUtil.GetTempFileName(".bmp"); - vlc.TakeSnapshot(fileName, (uint)bmp.Width, (uint)bmp.Height); - Application.DoEvents(); - Thread.Sleep(200); - using (var tempBmp = new Bitmap(fileName)) - { - g.DrawImageUnscaled(tempBmp, new Point(0, 0)); - } - } - return; - } - } - catch - { - // Was unable to grap screenshot via vlc - } - - // Draw background with generated image - var rect = new Rectangle(0, 0, bmp.Width - 1, bmp.Height - 1); - using (var br = new LinearGradientBrush(rect, Color.Black, Color.Black, 0, false)) - { - var cb = new ColorBlend - { - Positions = new[] { 0, 1 / 6f, 2 / 6f, 3 / 6f, 4 / 6f, 5 / 6f, 1 }, - Colors = new[] { Color.Black, Color.Black, Color.White, Color.Black, Color.Black, Color.White, Color.Black } - }; - br.InterpolationColors = cb; - br.RotateTransform(0); - g.FillRectangle(br, rect); - } - } - - private void linkLabelPreview_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - linkLabelPreview.Enabled = false; - Cursor = Cursors.WaitCursor; - try - { - GetResolution(out var width, out var height); - using (var bmp = new Bitmap(width, height)) - { - using (var g = Graphics.FromImage(bmp)) - { - var p = _subtitle.Paragraphs[subtitleListView1.SelectedItems[0].Index]; - FillPreviewBackground(bmp, g, p); - - var nBmp = new NikseBitmap(pictureBox1.Image as Bitmap); - nBmp.CropSidesAndBottom(100, Color.Transparent, true); - using (var textBmp = nBmp.GetBitmap()) - { - var bp = MakeMakeBitmapParameter(subtitleListView1.SelectedItems[0].Index, width, height); - var alignment = GetAlignmentFromParagraph(bp, _format, _subtitle); - if (comboBoxHAlign.Visible && alignment == ContentAlignment.BottomCenter && _format.GetType() != typeof(AdvancedSubStationAlpha) && _format.GetType() != typeof(SubStationAlpha)) - { - if (comboBoxHAlign.SelectedIndex == 0) - { - alignment = ContentAlignment.BottomLeft; - } - else if (comboBoxHAlign.SelectedIndex == 2) - { - alignment = ContentAlignment.BottomRight; - } - } - - int x = (bmp.Width - textBmp.Width) / 2; - if (alignment == ContentAlignment.BottomLeft || alignment == ContentAlignment.MiddleLeft || alignment == ContentAlignment.TopLeft) - { - x = GetBottomMarginInPixels(p); - } - else if (alignment == ContentAlignment.BottomRight || alignment == ContentAlignment.MiddleRight || alignment == ContentAlignment.TopRight) - { - x = bmp.Width - textBmp.Width - GetBottomMarginInPixels(p); - } - - int y = bmp.Height - textBmp.Height - GetBottomMarginInPixels(p); - if (alignment == ContentAlignment.BottomLeft || alignment == ContentAlignment.MiddleLeft || alignment == ContentAlignment.TopLeft) - { - x = GetBottomMarginInPixels(p); - } - else if (alignment == ContentAlignment.BottomRight || alignment == ContentAlignment.MiddleRight || alignment == ContentAlignment.TopRight) - { - x = bmp.Width - textBmp.Width - GetBottomMarginInPixels(p); - } - - if (alignment == ContentAlignment.MiddleLeft || alignment == ContentAlignment.MiddleCenter || alignment == ContentAlignment.MiddleRight) - { - y = (groupBoxExportImage.Height - 4 - textBmp.Height) / 2; - } - else if (alignment == ContentAlignment.TopLeft || alignment == ContentAlignment.TopCenter || alignment == ContentAlignment.TopRight) - { - y = GetBottomMarginInPixels(p); - } - - g.DrawImageUnscaled(textBmp, new Point(x, y)); - } - } - - using (var form = new ExportPngXmlPreview(bmp)) - { - Cursor = Cursors.Default; - form.ShowDialog(this); - } - } - } - finally - { - Cursor = Cursors.Default; - linkLabelPreview.Enabled = true; - } - } - - private void comboBoxLeftRightMargin_SelectedIndexChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void panelFullFrameBackground_Click(object sender, EventArgs e) - { - using (var colorChooser = new ColorChooser { Color = panelFullFrameBackground.BackColor, Text = Configuration.Settings.Language.ExportPngXml.ChooseBackgroundColor }) - { - if (colorChooser.ShowDialog() == DialogResult.OK) - { - panelFullFrameBackground.BackColor = colorChooser.Color; - subtitleListView1_SelectedIndexChanged(null, null); - } - } - } - - private void checkBoxFullFrameImage_CheckedChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - panelFullFrameBackground.Visible = checkBoxFullFrameImage.Checked; - if (_exportType == ExportFormats.BluraySup || _exportType == ExportFormats.VobSub || _exportType == ExportFormats.ImageFrame || _exportType == ExportFormats.BdnXml || _exportType == ExportFormats.Dost || _exportType == ExportFormats.Fab || _exportType == ExportFormats.Edl || _exportType == ExportFormats.EdlClipName) - { - return; - } - _allowCustomBottomMargin = checkBoxFullFrameImage.Checked; - comboBoxBottomMargin.Visible = checkBoxFullFrameImage.Checked; - labelBottomMargin.Visible = checkBoxFullFrameImage.Checked; - comboBoxBottomMarginUnit.Visible = checkBoxFullFrameImage.Checked; - } - - public void DisableSaveButtonAndCheckBoxes() - { - buttonExport.Visible = false; - subtitleListView1.CheckBoxes = false; - } - - private void comboBoxBottomMarginUnit_SelectedIndexChanged(object sender, EventArgs e) - { - comboBoxBottomMargin.BeginUpdate(); - comboBoxBottomMargin.Items.Clear(); - if (comboBoxBottomMarginUnit.SelectedIndex == 0) - { - for (int i = 0; i <= 95; i++) - { - comboBoxBottomMargin.Items.Add(i); - } - - var exportMarginPercent = _exportType == ExportFormats.BluraySup ? Configuration.Settings.Tools.ExportBluRayBottomMarginPercent : Configuration.Settings.Tools.ExportBottomMarginPercent; - if (exportMarginPercent >= 0 && exportMarginPercent < comboBoxBottomMargin.Items.Count) - { - comboBoxBottomMargin.SelectedIndex = exportMarginPercent; - } - } - else - { - for (int i = 0; i <= 1000; i++) - { - comboBoxBottomMargin.Items.Add(i); - } - - var exportMarginPixels = _exportType == ExportFormats.BluraySup ? Configuration.Settings.Tools.ExportBluRayBottomMarginPixels : Configuration.Settings.Tools.ExportBottomMarginPixels; - if (exportMarginPixels >= 0 && exportMarginPixels < comboBoxBottomMargin.Items.Count) - { - comboBoxBottomMargin.SelectedIndex = exportMarginPixels; - } - } - if (comboBoxBottomMargin.SelectedIndex == -1) - { - comboBoxBottomMargin.SelectedIndex = 0; - } - comboBoxBottomMargin.EndUpdate(); - } - - private void comboBoxLeftRightMarginUnit_SelectedIndexChanged(object sender, EventArgs e) - { - comboBoxLeftRightMargin.BeginUpdate(); - comboBoxLeftRightMargin.Items.Clear(); - if (comboBoxLeftRightMarginUnit.SelectedIndex == 0) - { - for (int i = 0; i < 95; i++) - { - comboBoxLeftRightMargin.Items.Add(i); - } - - if (Configuration.Settings.Tools.ExportLeftRightMarginPercent >= 0 && Configuration.Settings.Tools.ExportLeftRightMarginPercent < comboBoxLeftRightMargin.Items.Count) - { - comboBoxLeftRightMargin.SelectedIndex = Configuration.Settings.Tools.ExportLeftRightMarginPercent; - } - } - else - { - for (int i = 0; i <= 1000; i++) - { - comboBoxLeftRightMargin.Items.Add(i); - } - - if (Configuration.Settings.Tools.ExportLeftRightMarginPixels >= 0 && Configuration.Settings.Tools.ExportLeftRightMarginPixels < comboBoxLeftRightMargin.Items.Count) - { - comboBoxLeftRightMargin.SelectedIndex = Configuration.Settings.Tools.ExportLeftRightMarginPixels; - } - } - if (comboBoxLeftRightMargin.SelectedIndex == -1) - { - comboBoxLeftRightMargin.SelectedIndex = 0; - } - comboBoxLeftRightMargin.EndUpdate(); - } - - private void numericUpDownLineSpacing_KeyUp(object sender, KeyEventArgs e) - { - _previewTimer.Start(); - } - - public static Bitmap ResizeBitmap(Bitmap b, int width, int height) - { - Bitmap newImage = new Bitmap(width, height); - using (var g = Graphics.FromImage(newImage)) - { - g.SmoothingMode = SmoothingMode.HighQuality; - g.InterpolationMode = InterpolationMode.HighQualityBicubic; - g.PixelOffsetMode = PixelOffsetMode.HighQuality; - g.DrawImage(b, new Rectangle(0, 0, width, height)); - } - return newImage; - } - - private void comboBoxResizePercentage_SelectedIndexChanged(object sender, EventArgs e) - { - subtitleListView1_SelectedIndexChanged(null, null); - } - - private void adjustTimeCodesToolStripMenuItem_Click(object sender, EventArgs e) - { - using (var showEarlierOrLater = new ShowEarlierLater()) - { - showEarlierOrLater.Initialize(ShowEarlierOrLater, false); - showEarlierOrLater.ShowDialog(this); - } - } - - public void ShowEarlierOrLater(double adjustMilliseconds, SelectionChoice selection) - { - adjustMilliseconds /= TimeCode.BaseUnit; - subtitleListView1.BeginUpdate(); - int startFrom = 0; - if (selection == SelectionChoice.SelectionAndForward) - { - if (subtitleListView1.SelectedItems.Count > 0) - { - startFrom = subtitleListView1.SelectedItems[0].Index; - } - else - { - startFrom = _subtitle.Paragraphs.Count; - } - } - for (int i = startFrom; i < _subtitle.Paragraphs.Count; i++) - { - switch (selection) - { - case SelectionChoice.SelectionOnly: - if (subtitleListView1.Items[i].Selected) - { - _subtitle.Paragraphs[i].Adjust(1.0, adjustMilliseconds); - ShowTimeInListView(i); - } - break; - case SelectionChoice.AllLines: - case SelectionChoice.SelectionAndForward: - _subtitle.Paragraphs[i].Adjust(1.0, adjustMilliseconds); - ShowTimeInListView(i); - break; - } - } - subtitleListView1.EndUpdate(); - } - - private void ShowTimeInListView(int index) - { - int startIndex = 1; - if (subtitleListView1.CheckBoxes) - { - startIndex++; - } - subtitleListView1.Items[index].SubItems[startIndex].Text = _subtitle.Paragraphs[index].StartTime.ToDisplayString(); - subtitleListView1.Items[index].SubItems[startIndex + 1].Text = _subtitle.Paragraphs[index].EndTime.ToDisplayString(); - subtitleListView1.Items[index].SubItems[startIndex + 2].Text = _subtitle.Paragraphs[index].Duration.ToShortDisplayString(); - } - - private void contextMenuStripListView_Opening(object sender, System.ComponentModel.CancelEventArgs e) - { - bool showImageExportMenuItems = _vobSubOcr != null; - toolStripSeparatorAdjust.Visible = showImageExportMenuItems; - adjustTimeCodesToolStripMenuItem.Visible = showImageExportMenuItems; - adjustDisplayTimeToolStripMenuItem.Visible = showImageExportMenuItems; - } - - private void adjustDisplayTimeToolStripMenuItem_Click(object sender, EventArgs e) - { - using (var adjustDisplayTime = new AdjustDisplayDuration()) - { - adjustDisplayTime.HideRecalculate(); - if (adjustDisplayTime.ShowDialog(this) == DialogResult.OK) - { - if (adjustDisplayTime.AdjustUsingPercent) - { - double percent = double.Parse(adjustDisplayTime.AdjustValue, CultureInfo.InvariantCulture); - _subtitle.AdjustDisplayTimeUsingPercent(percent, null); - } - else if (adjustDisplayTime.AdjustUsingSeconds) - { - double seconds = double.Parse(adjustDisplayTime.AdjustValue, CultureInfo.InvariantCulture); - _subtitle.AdjustDisplayTimeUsingSeconds(seconds, null); - } - else if (adjustDisplayTime.AdjustUsingRecalc) - { - double maxCharSeconds = (double)(adjustDisplayTime.MaxCharactersPerSecond); - _subtitle.RecalculateDisplayTimes(maxCharSeconds, null, (double)adjustDisplayTime.OptimalCharactersPerSecond); - } - else // fixed duration - { - _subtitle.SetFixedDuration(null, adjustDisplayTime.FixedMilliseconds); - } - } - } - subtitleListView1.BeginUpdate(); - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - ShowTimeInListView(i); - } - subtitleListView1.EndUpdate(); - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.BluRaySup; +using Nikse.SubtitleEdit.Core.Enums; +using Nikse.SubtitleEdit.Core.Interfaces; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Core.VobSub; +using Nikse.SubtitleEdit.Logic; +using Nikse.SubtitleEdit.Logic.VideoPlayers; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; +using System.Drawing.Text; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Windows.Forms; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ExportPngXml : PositionAndSizeForm + { + internal class ExportFormats + { + internal const string BluraySup = "BLURAYSUP"; + internal const string VobSub = "VOBSUB"; + internal const string Fab = "FAB"; + internal const string Stl = "STL"; + internal const string Fcp = "FCP"; + internal const string Dost = "DOSTIMAGE"; + internal const string DCinemaInterop = "DCINEMA_INTEROP"; + internal const string DCinemaSmpte2014 = "DCINEMA_SMPTE_2014"; + internal const string BdnXml = "BDNXML"; + internal const string Edl = "EDL"; + internal const string EdlClipName = "EDL_CLIPNAME"; + internal const string ImageFrame = "IMAGE/FRAME"; + internal const string Spumux = "SPUMUX"; + } + + internal class MakeBitmapParameter + { + public Bitmap Bitmap { get; set; } + public Paragraph P { get; set; } + public string Type { get; set; } + public Color SubtitleColor { get; set; } + public string SubtitleFontName { get; set; } + public float SubtitleFontSize { get; set; } + public bool SubtitleFontBold { get; set; } + public Color BorderColor { get; set; } + public float BorderWidth { get; set; } + public bool BoxSingleLine { get; set; } + public bool SimpleRendering { get; set; } + public bool AlignLeft { get; set; } + public bool AlignRight { get; set; } + public bool JustifyLeft { get; set; } + public bool JustifyTop { get; set; } + public bool JustifyRight { get; set; } + public byte[] Buffer { get; set; } + public int ScreenWidth { get; set; } + public int ScreenHeight { get; set; } + public string VideoResolution { get; set; } + public int Type3D { get; set; } + public int Depth3D { get; set; } + public double FramesPerSeconds { get; set; } + public int BottomMargin { get; set; } + public int LeftMargin { get; set; } + public int RightMargin { get; set; } + public bool Saved { get; set; } + public ContentAlignment Alignment { get; set; } + public Point? OverridePosition { get; set; } + public Color BackgroundColor { get; set; } + public string SavDialogFileName { get; set; } + public string Error { get; set; } + public string LineJoin { get; set; } + public Color ShadowColor { get; set; } + public float ShadowWidth { get; set; } + public int ShadowAlpha { get; set; } + public Dictionary LineHeight { get; set; } + public bool Forced { get; set; } + public bool FullFrame { get; set; } + public Color FullFrameBackgroundColor { get; set; } + + public MakeBitmapParameter() + { + BackgroundColor = Color.Transparent; + } + } + + private Subtitle _subtitle; + private SubtitleFormat _format; + private static string _formatName; + private Color _subtitleColor; + private string _subtitleFontName = "Verdana"; + private float _subtitleFontSize = 25.0f; + private bool _subtitleFontBold; + private Color _borderColor; + private float _borderWidth = 2.0f; + private bool _isLoading = true; + private string _language = "en"; + private string _exportType = ExportFormats.BdnXml; + private string _fileName; + private string _outputFileName; + private IBinaryParagraphList _vobSubOcr; + private readonly System.Windows.Forms.Timer _previewTimer = new System.Windows.Forms.Timer(); + private string _videoFileName; + private readonly Dictionary _lineHeights; + private static int _boxBorderSize = 8; + + private const string BoxMultiLineText = "BoxMultiLine"; + private const string BoxSingleLineText = "BoxSingleLine"; + + public string GetOutputFileName() + { + return _outputFileName; + } + + public ExportPngXml() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + var toolTip = new ToolTip { ShowAlways = true }; + toolTip.SetToolTip(panelFullFrameBackground, Configuration.Settings.Language.ExportPngXml.ChooseBackgroundColor); + _lineHeights = new Dictionary(); + comboBoxImageFormat.SelectedIndex = 4; + _subtitleColor = Color.FromArgb(byte.MaxValue, Configuration.Settings.Tools.ExportFontColor); + _borderColor = Configuration.Settings.Tools.ExportBorderColor; + _boxBorderSize = Configuration.Settings.Tools.ExportBoxBorderSize; + _previewTimer.Tick += previewTimer_Tick; + _previewTimer.Interval = 100; + labelLineHeightStyle.Text = string.Empty; + } + + private void previewTimer_Tick(object sender, EventArgs e) + { + _previewTimer.Stop(); + GeneratePreview(); + } + + private double FrameRate + { + get + { + if (comboBoxFrameRate.SelectedItem == null) + { + return 25; + } + + string s = comboBoxFrameRate.SelectedItem.ToString(); + s = s.Replace(",", ".").Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, ".").Trim(); + if (double.TryParse(s, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var d)) + { + return d; + } + + return 25; + } + } + + private int MillisecondsToFramesMaxFrameRate(double milliseconds) + { + int frames = (int)Math.Round(milliseconds / (TimeCode.BaseUnit / FrameRate)); + if (frames >= FrameRate) + { + frames = (int)(FrameRate - 0.01); + } + + return frames; + } + + private string ToHHMMSSFF(TimeCode timeCode) + { + return $"{timeCode.Hours:00}:{timeCode.Minutes:00}:{timeCode.Seconds:00}:{MillisecondsToFramesMaxFrameRate(timeCode.Milliseconds):00}"; + } + + private static ContentAlignment GetAlignmentFromParagraph(MakeBitmapParameter p, SubtitleFormat format, Subtitle subtitle) + { + var alignment = ContentAlignment.BottomCenter; + if (p.AlignLeft) + { + alignment = ContentAlignment.BottomLeft; + } + else if (p.AlignRight) + { + alignment = ContentAlignment.BottomRight; + } + + if (format.HasStyleSupport && !string.IsNullOrEmpty(p.P.Extra)) + { + if (format.GetType() == typeof(SubStationAlpha)) + { + var style = AdvancedSubStationAlpha.GetSsaStyle(p.P.Extra, subtitle.Header); + alignment = GetSsaAlignment("{\\a" + style.Alignment + "}", alignment); + } + else if (format.GetType() == typeof(AdvancedSubStationAlpha)) + { + var style = AdvancedSubStationAlpha.GetSsaStyle(p.P.Extra, subtitle.Header); + alignment = GetAssAlignment("{\\an" + style.Alignment + "}", alignment); + } + } + + string text = p.P.Text; + if (format.GetType() == typeof(SubStationAlpha) && text.Length > 5) + { + text = p.P.Text.Substring(0, 6); + alignment = GetSsaAlignment(text, alignment); + } + else if (text.Length > 6) + { + text = p.P.Text.Substring(0, 6); + alignment = GetAssAlignment(text, alignment); + } + return alignment; + } + + private static ContentAlignment GetSsaAlignment(string text, ContentAlignment defaultAlignment) + { + //1: Bottom left + //2: Bottom center + //3: Bottom right + //9: Middle left + //10: Middle center + //11: Middle right + //5: Top left + //6: Top center + //7: Top right + switch (text) + { + case "{\\a1}": + return ContentAlignment.BottomLeft; + case "{\\a2}": + return ContentAlignment.BottomCenter; + case "{\\a3}": + return ContentAlignment.BottomRight; + case "{\\a9}": + return ContentAlignment.MiddleLeft; + case "{\\a10}": + return ContentAlignment.MiddleCenter; + case "{\\a11}": + return ContentAlignment.MiddleRight; + case "{\\a5}": + return ContentAlignment.TopLeft; + case "{\\a6}": + return ContentAlignment.TopCenter; + case "{\\a7}": + return ContentAlignment.TopRight; + } + return defaultAlignment; + } + + private static ContentAlignment GetAssAlignment(string text, ContentAlignment defaultAlignment) + { + //1: Bottom left + //2: Bottom center + //3: Bottom right + //4: Middle left + //5: Middle center + //6: Middle right + //7: Top left + //8: Top center + //9: Top right + switch (text) + { + case "{\\an1}": + return ContentAlignment.BottomLeft; + case "{\\an2}": + return ContentAlignment.BottomCenter; + case "{\\an3}": + return ContentAlignment.BottomRight; + case "{\\an4}": + return ContentAlignment.MiddleLeft; + case "{\\an5}": + return ContentAlignment.MiddleCenter; + case "{\\an6}": + return ContentAlignment.MiddleRight; + case "{\\an7}": + return ContentAlignment.TopLeft; + case "{\\an8}": + return ContentAlignment.TopCenter; + case "{\\an9}": + return ContentAlignment.TopRight; + } + return defaultAlignment; + } + + public static void DoWork(object data) + { + var parameter = (MakeBitmapParameter)data; + + parameter.LineJoin = Configuration.Settings.Tools.ExportPenLineJoin; + parameter.Bitmap = GenerateImageFromTextWithStyle(parameter); + if (parameter.Type == ExportFormats.BluraySup) + { + MakeBluRaySupImage(parameter); + } + } + + internal static void MakeBluRaySupImage(MakeBitmapParameter param) + { + var brSub = new BluRaySupPicture + { + StartTime = (long)param.P.StartTime.TotalMilliseconds, + EndTime = (long)param.P.EndTime.TotalMilliseconds, + Width = param.ScreenWidth, + Height = param.ScreenHeight, + IsForced = param.Forced, + CompositionNumber = param.P.Number * 2 + }; + if (param.FullFrame) + { + var nbmp = new NikseBitmap(param.Bitmap); + nbmp.ReplaceTransparentWith(param.FullFrameBackgroundColor); + using (var bmp = nbmp.GetBitmap()) + { + int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin); + int left = (param.ScreenWidth - param.Bitmap.Width) / 2; + + var b = new NikseBitmap(param.ScreenWidth, param.ScreenHeight); + { + b.Fill(param.FullFrameBackgroundColor); + using (var fullSize = b.GetBitmap()) + { + if (param.Alignment == ContentAlignment.BottomLeft || param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.TopLeft) + { + left = param.LeftMargin; + } + else if (param.Alignment == ContentAlignment.BottomRight || param.Alignment == ContentAlignment.MiddleRight || param.Alignment == ContentAlignment.TopRight) + { + left = param.ScreenWidth - param.Bitmap.Width - param.RightMargin; + } + + if (param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopRight) + { + top = param.BottomMargin; + } + + if (param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.MiddleCenter || param.Alignment == ContentAlignment.MiddleRight) + { + top = param.ScreenHeight - (param.Bitmap.Height / 2); + } + + if (param.OverridePosition != null && + param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.ScreenWidth && + param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.ScreenHeight) + { + left = param.OverridePosition.Value.X; + top = param.OverridePosition.Value.Y; + } + + using (var g = Graphics.FromImage(fullSize)) + { + g.DrawImage(bmp, left, top); + g.Dispose(); + } + param.Buffer = BluRaySupPicture.CreateSupFrame(brSub, fullSize, param.FramesPerSeconds, 0, 0, ContentAlignment.BottomCenter); + } + } + } + } + else + { + if (param.OverridePosition != null && + param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.ScreenWidth && + param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.ScreenHeight) + { + param.LeftMargin = param.OverridePosition.Value.X; + param.BottomMargin = param.ScreenHeight - param.OverridePosition.Value.Y - param.Bitmap.Height; + } + + var margin = (param.Alignment == ContentAlignment.TopRight || + param.Alignment == ContentAlignment.MiddleRight || + param.Alignment == ContentAlignment.BottomRight) + ? param.RightMargin + : param.LeftMargin; + + param.Buffer = BluRaySupPicture.CreateSupFrame(brSub, param.Bitmap, param.FramesPerSeconds, param.BottomMargin, margin, param.Alignment, param.OverridePosition); + } + } + + internal MakeBitmapParameter MakeMakeBitmapParameter(int index, int screenWidth, int screenHeight) + { + var p = _subtitle.GetParagraphOrDefault(index); + var parameter = new MakeBitmapParameter + { + Type = _exportType, + SubtitleColor = _subtitleColor, + SubtitleFontName = _subtitleFontName, + SubtitleFontSize = _subtitleFontSize, + SubtitleFontBold = _subtitleFontBold, + BorderColor = _borderColor, + BorderWidth = _borderWidth, + SimpleRendering = checkBoxSimpleRender.Checked, + AlignLeft = comboBoxHAlign.SelectedIndex == 0, + AlignRight = comboBoxHAlign.SelectedIndex == 2, + JustifyLeft = GetJustifyLeft(p.Text), // center, left justify + JustifyTop = comboBoxHAlign.SelectedIndex == 4, // center, top justify + JustifyRight = comboBoxHAlign.SelectedIndex == 5, // center, right justify + ScreenWidth = screenWidth, + ScreenHeight = screenHeight, + VideoResolution = comboBoxResolution.Text, + Bitmap = null, + FramesPerSeconds = FrameRate, + BottomMargin = GetBottomMarginInPixels(p), + LeftMargin = GetLeftMarginInPixels(p), + RightMargin = GetRightMarginInPixels(p), + Saved = false, + Alignment = ContentAlignment.BottomCenter, + Type3D = comboBox3D.SelectedIndex, + Depth3D = (int)numericUpDownDepth3D.Value, + BackgroundColor = Color.Transparent, + SavDialogFileName = saveFileDialog1.FileName, + ShadowColor = panelShadowColor.BackColor, + ShadowWidth = GetShadowWidth(), + ShadowAlpha = (int)numericUpDownShadowTransparency.Value, + LineHeight = _lineHeights, + FullFrame = checkBoxFullFrameImage.Checked, + FullFrameBackgroundColor = panelFullFrameBackground.BackColor, + }; + if (index < _subtitle.Paragraphs.Count) + { + parameter.P = _subtitle.Paragraphs[index]; + parameter.Alignment = GetAlignmentFromParagraph(parameter, _format, _subtitle); + parameter.OverridePosition = GetAssPoint(parameter.P.Text); + parameter.Forced = subtitleListView1.Items[index].Checked; + + if (_format.HasStyleSupport && !string.IsNullOrEmpty(parameter.P.Extra)) + { + if (_format.GetType() == typeof(SubStationAlpha)) + { + var style = AdvancedSubStationAlpha.GetSsaStyle(parameter.P.Extra, _subtitle.Header); + parameter.SubtitleColor = style.Primary; + parameter.SubtitleFontBold = style.Bold; + parameter.SubtitleFontSize = style.FontSize; + parameter.SubtitleFontName = style.FontName; + parameter.BottomMargin = style.MarginVertical; + if (style.BorderStyle == "3") + { + parameter.BackgroundColor = style.Background; + } + parameter.ShadowColor = style.Outline; + } + else if (_format.GetType() == typeof(AdvancedSubStationAlpha)) + { + var style = AdvancedSubStationAlpha.GetSsaStyle(parameter.P.Extra, _subtitle.Header); + parameter.SubtitleColor = style.Primary; + parameter.SubtitleFontBold = style.Bold; + parameter.SubtitleFontSize = style.FontSize; + parameter.SubtitleFontName = style.FontName; + parameter.BottomMargin = style.MarginVertical; + if (style.BorderStyle == "3") + { + parameter.BackgroundColor = style.Outline; + } + parameter.ShadowAlpha = style.Background.A; + parameter.ShadowColor = style.Background; + } + } + + if (comboBoxBorderWidth.SelectedItem.ToString() == Configuration.Settings.Language.ExportPngXml.BorderStyleBoxForEachLine) + { + parameter.BoxSingleLine = true; + parameter.BackgroundColor = panelBorderColor.BackColor; + parameter.BorderWidth = 0; + } + else if (comboBoxBorderWidth.SelectedItem.ToString() == Configuration.Settings.Language.ExportPngXml.BorderStyleOneBox) + { + parameter.BoxSingleLine = false; + parameter.BackgroundColor = panelBorderColor.BackColor; + parameter.BorderWidth = 0; + } + else + { + _borderWidth = GetBorderWidth(); + } + } + else + { + parameter.P = null; + } + return parameter; + } + + private bool GetJustifyLeft(string text) + { + if (comboBoxHAlign.SelectedIndex == 6 && !string.IsNullOrEmpty(text)) + { + var s = Utilities.RemoveUnneededSpaces(text, _language); + var dialogHelper = new DialogSplitMerge { TwoLetterLanguageCode = _language }; + var lines = s.SplitToLines(); + return dialogHelper.IsDialog(lines) || HasTwoSpeakers(lines); + } + + return comboBoxHAlign.SelectedIndex == 3; + } + + private static bool HasTwoSpeakers(List lines) + { + return lines.Count == 2 && lines[0].HasSentenceEnding() && lines[0].Contains(':') && lines[1].Contains(':'); + } + + private void ButtonExportClick(object sender, EventArgs e) + { + FixStartEndWithSameTimeCode(); + var singleFile = false; + + if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) + { + _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(Configuration.Settings.General.CurrentVideoOffsetInMs)); + } + + var errors = new List(); + buttonExport.Enabled = false; + SetupImageParameters(); + + if (!string.IsNullOrEmpty(_fileName)) + { + saveFileDialog1.FileName = Path.GetFileNameWithoutExtension(_fileName); + } + + if (_exportType == ExportFormats.BluraySup) + { + saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveBluRraySupAs; + saveFileDialog1.DefaultExt = "*.sup"; + saveFileDialog1.AddExtension = true; + saveFileDialog1.Filter = "Blu-Ray sup|*.sup"; + singleFile = true; + } + else if (_exportType == ExportFormats.VobSub) + { + saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveVobSubAs; + saveFileDialog1.DefaultExt = "*.sub"; + saveFileDialog1.AddExtension = true; + saveFileDialog1.Filter = "VobSub|*.sub"; + singleFile = true; + } + else if (_exportType == ExportFormats.Fab) + { + saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveFabImageScriptAs; + saveFileDialog1.DefaultExt = "*.txt"; + saveFileDialog1.AddExtension = true; + saveFileDialog1.Filter = "FAB image scripts|*.txt"; + singleFile = true; + } + else if (_exportType == ExportFormats.Stl) + { + saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveDvdStudioProStlAs; + saveFileDialog1.DefaultExt = "*.txt"; + saveFileDialog1.AddExtension = true; + saveFileDialog1.Filter = "DVD Studio Pro STL|*.stl"; + singleFile = true; + } + else if (_exportType == ExportFormats.Fcp) + { + saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveFcpAs; + saveFileDialog1.DefaultExt = "*.xml"; + saveFileDialog1.AddExtension = true; + saveFileDialog1.Filter = "Xml files|*.xml"; + singleFile = true; + } + else if (_exportType == ExportFormats.Dost) + { + saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveDostAs; + saveFileDialog1.DefaultExt = "*.dost"; + saveFileDialog1.AddExtension = true; + saveFileDialog1.Filter = "Dost files|*.dost"; + singleFile = true; + } + else if (_exportType == ExportFormats.DCinemaInterop) + { + saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveDigitalCinemaInteropAs; + saveFileDialog1.DefaultExt = "*.xml"; + saveFileDialog1.AddExtension = true; + saveFileDialog1.Filter = "Xml files|*.xml"; + singleFile = true; + } + else if (_exportType == ExportFormats.DCinemaSmpte2014) + { + saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SaveDigitalCinemaSmpte2014; + saveFileDialog1.DefaultExt = "*.xml"; + saveFileDialog1.AddExtension = true; + saveFileDialog1.Filter = "Xml files|*.xml"; + singleFile = true; + } + else if (_exportType == ExportFormats.Edl || _exportType == ExportFormats.EdlClipName) + { + saveFileDialog1.Title = Configuration.Settings.Language.ExportPngXml.SavePremiereEdlAs; + saveFileDialog1.DefaultExt = "*.edl"; + saveFileDialog1.AddExtension = true; + saveFileDialog1.Filter = "EDL files|*.edl"; + singleFile = true; + } + + if (singleFile && saveFileDialog1.ShowDialog(this) == DialogResult.OK || !singleFile && folderBrowserDialog1.ShowDialog(this) == DialogResult.OK) + { + GetResolution(out var width, out var height); + + _outputFileName = singleFile ? saveFileDialog1.FileName : folderBrowserDialog1.SelectedPath; + + FileStream binarySubtitleFile = null; + VobSubWriter vobSubWriter = null; + Paragraph p = null; + if (subtitleListView1.SelectedItems.Count > 0) + { + p = _subtitle.GetParagraphOrDefault(subtitleListView1.SelectedItems[0].Index); + } + + if (_exportType == ExportFormats.BluraySup) + { + binarySubtitleFile = new FileStream(saveFileDialog1.FileName, FileMode.Create); + } + else if (_exportType == ExportFormats.VobSub) + { + vobSubWriter = new VobSubWriter(saveFileDialog1.FileName, width, height, GetBottomMarginInPixels(p), GetLeftMarginInPixels(p), 32, _subtitleColor, _borderColor, !checkBoxTransAntiAliase.Checked, (DvdSubtitleLanguage)comboBoxLanguage.SelectedItem); + } + + progressBar1.Value = 0; + progressBar1.Maximum = _subtitle.Paragraphs.Count - 1; + progressBar1.Visible = true; + _previewTimer.Tick -= previewTimer_Tick; + + int border = GetBottomMarginInPixels(p); + int imagesSavedCount = 0; + var sb = new StringBuilder(); + if (_exportType == ExportFormats.Stl) + { + sb.AppendLine("$SetFilePathToken =" + folderBrowserDialog1.SelectedPath); + sb.AppendLine(); + } + + if (_vobSubOcr != null) + { + int i = 0; + while (i < _subtitle.Paragraphs.Count) + { + var mp = MakeMakeBitmapParameter(i, width, height); + mp.Bitmap = _vobSubOcr.GetSubtitleBitmap(i++); + var exp = GetResizeScale(); + if (Math.Abs(exp - 1) > 0.01) + { + var resizedBitmap = ResizeBitmap(mp.Bitmap, (int)Math.Round(mp.Bitmap.Width * exp), (int)Math.Round(mp.Bitmap.Height * exp)); + mp.Bitmap.Dispose(); + mp.Bitmap = resizedBitmap; + } + if (_exportType == ExportFormats.BluraySup) + { + MakeBluRaySupImage(mp); + } + imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, mp, i); + progressBar1.Refresh(); + Application.DoEvents(); + if (i < progressBar1.Maximum) + { + progressBar1.Value = i; + } + } + } + else + { + var threadEqual = new Thread(DoWork); + var paramEqual = MakeMakeBitmapParameter(0, width, height); + + var threadUnEqual = new Thread(DoWork); + var paramUnEqual = new MakeBitmapParameter(); + if (_subtitle.Paragraphs.Count > 1) + { + MakeMakeBitmapParameter(1, width, height); + } + + threadEqual.Start(paramEqual); + int i = 1; + for (; i < _subtitle.Paragraphs.Count; i++) + { + if (i % 2 == 0) + { + paramEqual = MakeMakeBitmapParameter(i, width, height); + threadEqual = new Thread(DoWork); + threadEqual.Start(paramEqual); + + if (threadUnEqual.ThreadState == ThreadState.Running) + { + threadUnEqual.Join(); + } + + imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, paramUnEqual, i); + if (!string.IsNullOrEmpty(paramUnEqual.Error)) + { + errors.Add(paramUnEqual.Error); + } + } + else + { + paramUnEqual = MakeMakeBitmapParameter(i, width, height); + threadUnEqual = new Thread(DoWork); + threadUnEqual.Start(paramUnEqual); + + if (threadEqual.ThreadState == ThreadState.Running) + { + threadEqual.Join(); + } + + imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, paramEqual, i); + if (!string.IsNullOrEmpty(paramEqual.Error)) + { + errors.Add(paramEqual.Error); + } + } + progressBar1.Refresh(); + Application.DoEvents(); + progressBar1.Value = i; + } + + if (i % 2 == 0) + { + if (threadEqual.ThreadState == ThreadState.Running) + { + threadEqual.Join(); + } + + imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, paramEqual, i); + if (threadUnEqual.ThreadState == ThreadState.Running) + { + threadUnEqual.Join(); + } + + imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, paramUnEqual, i); + } + else + { + if (threadUnEqual.ThreadState == ThreadState.Running) + { + threadUnEqual.Join(); + } + + imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, paramUnEqual, i); + if (threadEqual.ThreadState == ThreadState.Running) + { + threadEqual.Join(); + } + + imagesSavedCount = WriteParagraph(width, sb, border, height, imagesSavedCount, vobSubWriter, binarySubtitleFile, paramEqual, i); + } + } + + if (errors.Count > 0) + { + var errorSb = new StringBuilder(); + for (int i = 0; i < 20; i++) + { + if (i < errors.Count) + { + errorSb.AppendLine(errors[i]); + } + } + if (errors.Count > 20) + { + errorSb.AppendLine("..."); + } + + MessageBox.Show(string.Format(Configuration.Settings.Language.ExportPngXml.SomeLinesWereTooLongX, errorSb)); + } + + _previewTimer.Tick += previewTimer_Tick; + progressBar1.Visible = false; + if (_exportType == ExportFormats.BluraySup) + { + binarySubtitleFile.Close(); + MessageBox.Show(string.Format(Configuration.Settings.Language.Main.SavedSubtitleX, saveFileDialog1.FileName)); + } + else if (_exportType == ExportFormats.VobSub) + { + vobSubWriter.WriteIdxFile(); + vobSubWriter.Dispose(); + MessageBox.Show(string.Format(Configuration.Settings.Language.Main.SavedSubtitleX, saveFileDialog1.FileName)); + } + else if (_exportType == ExportFormats.Fab) + { + File.WriteAllText(Path.Combine(folderBrowserDialog1.SelectedPath, "Fab_Image_script.txt"), sb.ToString()); + var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, folderBrowserDialog1.SelectedPath); + MessageBoxShowWithFolderName(text, folderBrowserDialog1.SelectedPath); + } + else if (_exportType == ExportFormats.ImageFrame) + { + var empty = new Bitmap(width, height); + imagesSavedCount++; + string numberString = $"{imagesSavedCount:00000}"; + string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant()); + SaveImage(empty, fileName, ImageFormat); + var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, folderBrowserDialog1.SelectedPath); + MessageBoxShowWithFolderName(text, folderBrowserDialog1.SelectedPath); + } + else if (_exportType == ExportFormats.Stl) + { + File.WriteAllText(Path.Combine(folderBrowserDialog1.SelectedPath, "DVD_Studio_Pro_Image_script.stl"), sb.ToString()); + var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, folderBrowserDialog1.SelectedPath); + MessageBoxShowWithFolderName(text, folderBrowserDialog1.SelectedPath); + } + else if (_exportType == ExportFormats.Spumux) + { + string s = "" + Environment.NewLine + + "\t" + Environment.NewLine + + sb + + "\t" + Environment.NewLine + + ""; + File.WriteAllText(Path.Combine(folderBrowserDialog1.SelectedPath, "spu.xml"), s); + var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, folderBrowserDialog1.SelectedPath); + MessageBoxShowWithFolderName(text, folderBrowserDialog1.SelectedPath); + } + else if (_exportType == ExportFormats.Fcp) + { + WriteFcpFile(width, height, sb, saveFileDialog1.FileName); + var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, Path.GetDirectoryName(saveFileDialog1.FileName)); + MessageBoxShowWithFolderName(text, Path.GetDirectoryName(saveFileDialog1.FileName)); + } + else if (_exportType == ExportFormats.Dost) + { + WriteDostFile(saveFileDialog1.FileName, sb.ToString()); + var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, Path.GetDirectoryName(saveFileDialog1.FileName)); + MessageBoxShowWithFolderName(text, Path.GetDirectoryName(saveFileDialog1.FileName)); + } + else if (_exportType == ExportFormats.DCinemaInterop) + { + var doc = new XmlDocument(); + string title = "unknown"; + if (!string.IsNullOrEmpty(_fileName)) + { + title = Path.GetFileNameWithoutExtension(_fileName); + } + + string guid = Guid.NewGuid().ToString().RemoveChar('-').Insert(8, "-").Insert(13, "-").Insert(18, "-").Insert(23, "-"); + doc.LoadXml("" + Environment.NewLine + + "" + Environment.NewLine + + "" + guid + "" + Environment.NewLine + + "" + title + "" + Environment.NewLine + + "1" + Environment.NewLine + + "English" + Environment.NewLine + + sb + + ""); + string fName = saveFileDialog1.FileName; + if (!fName.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)) + { + fName += ".xml"; + } + + File.WriteAllText(fName, SubtitleFormat.ToUtf8XmlString(doc)); + var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, Path.GetDirectoryName(fName)); + MessageBoxShowWithFolderName(text, Path.GetDirectoryName(fName)); + } + else if (_exportType == ExportFormats.DCinemaSmpte2014) + { + var doc = new XmlDocument(); + string title = "unknown"; + if (!string.IsNullOrEmpty(_fileName)) + { + title = Path.GetFileNameWithoutExtension(_fileName); + } + + string guid = Guid.NewGuid().ToString().RemoveChar('-').Insert(8, "-").Insert(13, "-").Insert(18, "-").Insert(23, "-"); + string xml = + "" + Environment.NewLine + + " urn:uuid:" + guid + "" + Environment.NewLine + + " " + Environment.NewLine + + " This is a subtitle file" + Environment.NewLine + + " 2014-01-01T00:00:00.000-00:00" + Environment.NewLine + + " 1" + Environment.NewLine + + " en" + Environment.NewLine + + " 25 1" + Environment.NewLine + + " 25" + Environment.NewLine + + " 00:00:00:00 " + Environment.NewLine + + " urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391" + Environment.NewLine + + " " + Environment.NewLine + + sb + + " " + Environment.NewLine + + ""; + + + doc.LoadXml(xml); + string fName = saveFileDialog1.FileName; + if (!fName.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)) + { + fName += ".xml"; + } + + File.WriteAllText(fName, SubtitleFormat.ToUtf8XmlString(doc)); + var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, Path.GetDirectoryName(fName)); + MessageBoxShowWithFolderName(text, Path.GetDirectoryName(fName)); + } + else if (_exportType == ExportFormats.Edl || _exportType == ExportFormats.EdlClipName) + { + var title = Path.GetFileNameWithoutExtension(saveFileDialog1.FileName); + if (string.IsNullOrEmpty(title)) + { + title = "( no title )"; + } + + string header = "TITLE: " + title + Environment.NewLine + Environment.NewLine; + File.WriteAllText(saveFileDialog1.FileName, header + sb); + var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, Path.GetDirectoryName(saveFileDialog1.FileName)); + MessageBoxShowWithFolderName(text, Path.GetDirectoryName(saveFileDialog1.FileName)); + } + else + { + WriteBdnXmlFile(imagesSavedCount, sb, Path.Combine(folderBrowserDialog1.SelectedPath, "BDN_Index.xml")); + var text = string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, folderBrowserDialog1.SelectedPath); + MessageBoxShowWithFolderName(text, folderBrowserDialog1.SelectedPath); + } + } + buttonExport.Enabled = true; + + if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) + { + _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-Configuration.Settings.General.CurrentVideoOffsetInMs)); + } + } + + private void MessageBoxShowWithFolderName(string text, string folderName) + { + using (var f = new ExportPngXmlDialogOpenFolder(text, folderName)) + { + f.ShowDialog(this); + } + } + + internal void WriteFcpFile(int width, int height, StringBuilder sb, string fileName) + { + string fileNameNoPath = Path.GetFileName(fileName); + string fileNameNoExt = Path.GetFileNameWithoutExtension(fileNameNoPath); + + int duration = 0; + if (_subtitle.Paragraphs.Count > 0) + { + duration = (int)Math.Round(_subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1].EndTime.TotalSeconds * 25.0); + } + + string s = "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + " " + Environment.NewLine + + " add" + Environment.NewLine + + " " + System.Security.SecurityElement.Escape(fileNameNoExt) + @" + " + duration.ToString(CultureInfo.InvariantCulture) + @" + + FALSE + 25 + + + + FALSE + 25 + + 00:00:00:00 + 0 + source + NDF + + 0 + [OUT] + + + + + FALSE + +"; + if (comboBoxFrameRate.Text == "29.97") + { + s = s.Replace("NDF", "DF"); //Non Drop Frame or Drop Frame + s = s.Replace("25", "30"); + s = s.Replace("FALSE", "TRUE"); + } + else if (comboBoxFrameRate.Text == "23.976") + { + s = s.Replace("NDF", "DF"); //Non Drop Frame or Drop Frame + s = s.Replace("25", "24"); + s = s.Replace("FALSE", "TRUE"); + } + else if (comboBoxFrameRate.Text == "59.94") + { + s = s.Replace("NDF", "DF"); //Non Drop Frame or Drop Frame + s = s.Replace("25", "60"); + s = s.Replace("FALSE", "TRUE"); + } + + else + { + s = s.Replace("25", "" + comboBoxFrameRate.Text + ""); + } + + if (_subtitle.Paragraphs.Count > 0) + { + var end = SubtitleFormat.MillisecondsToFrames(_subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds, FrameRate); + end++; + s = s.Replace("[OUT]", end.ToString(CultureInfo.InvariantCulture)); + } + + if (comboBoxLanguage.Text == "NTSC") + { + s = s.Replace("FALSE", "TRUE"); + } + + s = s.Replace("1920", "" + width.ToString(CultureInfo.InvariantCulture) + ""); + s = s.Replace("1080", "" + height.ToString(CultureInfo.InvariantCulture) + ""); + + if (comboBoxImageFormat.Text.Contains("8-bit")) + { + s = s.Replace("32", "8"); + } + + File.WriteAllText(fileName, s); + } + + internal void WriteBdnXmlFile(int imagesSavedCount, StringBuilder sb, string fileName) + { + GetResolution(out var resW, out var resH); + string videoFormat = "1080p"; + if (resW == 1920 && resH == 1080) + { + videoFormat = "1080p"; + } + else if (resW == 1280 && resH == 720) + { + videoFormat = "720p"; + } + else if (resW == 848 && resH == 480) + { + videoFormat = "480p"; + } + else if (resW > 0 && resH > 0) + { + videoFormat = resW + "x" + resH; + } + + var doc = new XmlDocument(); + Paragraph first = _subtitle.Paragraphs[0]; + Paragraph last = _subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1]; + doc.LoadXml("" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + ""); + XmlNode events = doc.DocumentElement.SelectSingleNode("Events"); + doc.PreserveWhitespace = true; + events.InnerXml = sb.ToString(); + File.WriteAllText(fileName, FormatUtf8Xml(doc), Encoding.UTF8); + } + + internal void WriteDostFile(string fileName, string body) + { + string header = @"$FORMAT=480 +$VERSION=1.2 +$ULEAD=TRUE +$DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + + "NO\tINTIME\t\tOUTTIME\t\tXPOS\tYPOS\tFILENAME\tFADEIN\tFADEOUT"; + + string dropValue = "30000"; + if (comboBoxFrameRate.SelectedIndex == -1) + { + var numberAsString = comboBoxFrameRate.Text.Trim().RemoveChar('.').RemoveChar(',').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, string.Empty); + if (numberAsString.Length > 0 && Utilities.IsInteger(numberAsString)) + { + dropValue = numberAsString; + } + } + else if (comboBoxFrameRate.Items[comboBoxFrameRate.SelectedIndex].ToString() == "23.98") + { + dropValue = "23976"; + } + else if (comboBoxFrameRate.Items[comboBoxFrameRate.SelectedIndex].ToString() == "24") + { + dropValue = "24000"; + } + else if (comboBoxFrameRate.Items[comboBoxFrameRate.SelectedIndex].ToString() == "25") + { + dropValue = "25000"; + } + else if (comboBoxFrameRate.Items[comboBoxFrameRate.SelectedIndex].ToString() == "29.97") + { + dropValue = "29970"; + } + else if (comboBoxFrameRate.Items[comboBoxFrameRate.SelectedIndex].ToString() == "30") + { + dropValue = "30000"; + } + else if (comboBoxFrameRate.Items[comboBoxFrameRate.SelectedIndex].ToString() == "59.94") + { + dropValue = "59940"; + } + + header = header.Replace("[DROPVALUE]", dropValue); + comboBoxFrameRate.SelectedIndex = 0; + + File.WriteAllText(fileName, header + Environment.NewLine + body); + } + + private static string FormatUtf8Xml(XmlDocument doc) + { + var sb = new StringBuilder(); + using (var writer = XmlWriter.Create(sb, new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8 })) + { + doc.Save(writer); + } + return sb.ToString().Replace(" encoding=\"utf-16\"", " encoding=\"utf-8\"").Trim(); // "replace hack" due to missing encoding (encoding only works if it's the only parameter...) + } + + private void SaveImage(Bitmap bmp, string fileName, ImageFormat imageFormat) + { + if (Equals(imageFormat, ImageFormat.Icon)) + { + var nikseBitmap = new NikseBitmap(bmp); + nikseBitmap.SaveAsTarga(fileName); + } + else + { + bmp.Save(fileName, imageFormat); + } + } + + private void FixStartEndWithSameTimeCode() + { + for (int i = 0; i < _subtitle.Paragraphs.Count - 1; i++) + { + Paragraph p = _subtitle.Paragraphs[i]; + Paragraph next = _subtitle.Paragraphs[i + 1]; + if (Math.Abs(p.EndTime.TotalMilliseconds - next.StartTime.TotalMilliseconds) < 0.1) + { + p.EndTime.TotalMilliseconds--; + } + } + } + + private void SetResolution(string inputXAndY) + { + if (string.IsNullOrEmpty(inputXAndY)) + { + return; + } + + var xAndY = inputXAndY.ToLowerInvariant(); + + if (_exportType == ExportFormats.Fcp) + { + switch (xAndY) + { + case "720x480": + xAndY = "NTSC-601"; + break; + case "720x576": + xAndY = "PAL-601"; + break; + case "640x480": + xAndY = "square"; + break; + case "1280x720": + xAndY = "DVCPROHD-720P"; + break; + case "960x720": + xAndY = "HD-(960x720)"; + break; + case "1920x1080": + xAndY = "FullHD 1920x1080"; + break; + case "1280x1080": + xAndY = "HD-(1280x1080)"; + break; + case "1440x1080": + xAndY = "HD-(1440x1080)"; + break; + } + } + + if (_exportType == ExportFormats.Fcp || Regex.IsMatch(xAndY, @"\d+x\d+", RegexOptions.IgnoreCase)) + { + for (int i = 0; i < comboBoxResolution.Items.Count; i++) + { + if (comboBoxResolution.Items[i].ToString().Contains(xAndY)) + { + comboBoxResolution.SelectedIndex = i; + return; + } + } + comboBoxResolution.Items[comboBoxResolution.Items.Count - 1] = xAndY; + comboBoxResolution.SelectedIndex = comboBoxResolution.Items.Count - 1; + } + } + + private void GetResolution(out int width, out int height) + { + width = 1920; + height = 1080; + if (comboBoxResolution.SelectedIndex < 0) + { + return; + } + + string text = comboBoxResolution.Text.Trim(); + + if (_exportType == ExportFormats.Fcp) + { + if (text == "NTSC-601") + { + width = 720; + height = 480; + return; + } + + if (text == "PAL-601") + { + width = 720; + height = 576; + return; + } + + if (text == "square") + { + width = 640; + height = 480; + return; + } + + if (text == "DVCPROHD-720P") + { + width = 1280; + height = 720; + return; + } + + if (text == "HD-(960x720)") + { + width = 960; + height = 720; + return; + } + + if (text == "FullHD 1920x1080") + { + width = 1920; + height = 1080; + return; + } + + if (text == "DVCPROHD-1080i60") + { + width = 1920; + height = 1080; + return; + } + + if (text == "HD-(1280x1080)") + { + width = 1280; + height = 1080; + return; + } + + if (text == "DVCPROHD-1080i50") + { + width = 1920; + height = 1080; + return; + } + + if (text == "HD-(1440x1080)") + { + width = 1440; + height = 1080; + return; + } + } + + if (text.Contains('(')) + { + text = text.Remove(0, text.IndexOf('(')).Trim(); + } + + text = text.TrimStart('(').TrimEnd(')').Trim(); + string[] arr = text.Split('x'); + width = int.Parse(arr[0]); + height = int.Parse(arr[1]); + } + + private int WriteParagraph(int width, StringBuilder sb, int border, int height, int imagesSavedCount, VobSubWriter vobSubWriter, FileStream binarySubtitleFile, MakeBitmapParameter param, int i) + { + if (param.Bitmap != null) + { + if (_exportType == ExportFormats.BluraySup) + { + if (!param.Saved) + { + binarySubtitleFile.Write(param.Buffer, 0, param.Buffer.Length); + } + param.Saved = true; + } + else if (_exportType == ExportFormats.VobSub) + { + if (!param.Saved) + { + vobSubWriter.WriteParagraph(param.P, param.Bitmap, param.Alignment); + } + + param.Saved = true; + } + else if (_exportType == ExportFormats.Fab) + { + if (!param.Saved) + { + string numberString = $"IMAGE{i:000}"; + string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant()); + + if (checkBoxFullFrameImage.Checked) + { + var nbmp = new NikseBitmap(param.Bitmap); + nbmp.ReplaceTransparentWith(panelFullFrameBackground.BackColor); + using (var bmp = nbmp.GetBitmap()) + { + imagesSavedCount++; + + //RACE001.TIF 00;00;02;02 00;00;03;15 000 000 720 480 + //RACE002.TIF 00;00;05;18 00;00;09;20 000 000 720 480 + int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin); + int left = (param.ScreenWidth - param.Bitmap.Width) / 2; + + var b = new NikseBitmap(param.ScreenWidth, param.ScreenHeight); + { + b.Fill(panelFullFrameBackground.BackColor); + using (var fullSize = b.GetBitmap()) + { + if (param.Alignment == ContentAlignment.BottomLeft || param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.TopLeft) + { + left = param.LeftMargin; + } + else if (param.Alignment == ContentAlignment.BottomRight || param.Alignment == ContentAlignment.MiddleRight || param.Alignment == ContentAlignment.TopRight) + { + left = param.ScreenWidth - param.Bitmap.Width - param.RightMargin; + } + + if (param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopRight) + { + top = param.BottomMargin; + } + + if (param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.MiddleCenter || param.Alignment == ContentAlignment.MiddleRight) + { + top = (param.ScreenHeight - param.Bitmap.Height) / 2; + } + + if (param.OverridePosition.HasValue && + param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.Bitmap.Width && + param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.Bitmap.Height) + { + left = param.OverridePosition.Value.X; + top = param.OverridePosition.Value.Y; + } + + using (var g = Graphics.FromImage(fullSize)) + { + g.DrawImage(bmp, left, top); + g.Dispose(); + } + SaveImage(fullSize, fileName, ImageFormat); + } + } + left = 0; + top = 0; + sb.AppendLine($"{Path.GetFileName(fileName)} {FormatFabTime(param.P.StartTime, param)} {FormatFabTime(param.P.EndTime, param)} {left} {top} {left + param.ScreenWidth} {top + param.ScreenHeight}"); + } + } + else + { + SaveImage(param.Bitmap, fileName, ImageFormat); + + imagesSavedCount++; + + //RACE001.TIF 00;00;02;02 00;00;03;15 000 000 720 480 + //RACE002.TIF 00;00;05;18 00;00;09;20 000 000 720 480 + int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin); + int left = (param.ScreenWidth - param.Bitmap.Width) / 2; + + if (param.Alignment == ContentAlignment.BottomLeft || param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.TopLeft) + { + left = param.LeftMargin; + } + else if (param.Alignment == ContentAlignment.BottomRight || param.Alignment == ContentAlignment.MiddleRight || param.Alignment == ContentAlignment.TopRight) + { + left = param.ScreenWidth - param.Bitmap.Width - param.RightMargin; + } + + if (param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopRight) + { + top = param.BottomMargin; + } + + if (param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.MiddleCenter || param.Alignment == ContentAlignment.MiddleRight) + { + top = (param.ScreenHeight - param.Bitmap.Height) / 2; + } + + if (param.OverridePosition.HasValue && + param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.Bitmap.Width && + param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.Bitmap.Height) + { + left = param.OverridePosition.Value.X; + top = param.OverridePosition.Value.Y; + } + + sb.AppendLine($"{Path.GetFileName(fileName)} {FormatFabTime(param.P.StartTime, param)} {FormatFabTime(param.P.EndTime, param)} {left} {top} {left + param.Bitmap.Width} {top + param.Bitmap.Height}"); + } + param.Saved = true; + } + } + else if (_exportType == ExportFormats.Stl) + { + if (!param.Saved) + { + string numberString = $"IMAGE{i:000}"; + string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant()); + SaveImage(param.Bitmap, fileName, ImageFormat); + + imagesSavedCount++; + + const string paragraphWriteFormat = "{0} , {1} , {2}\r\n"; + const string timeFormat = "{0:00}:{1:00}:{2:00}:{3:00}"; + + double factor = TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate; + string startTime = string.Format(timeFormat, param.P.StartTime.Hours, param.P.StartTime.Minutes, param.P.StartTime.Seconds, (int)Math.Round(param.P.StartTime.Milliseconds / factor)); + string endTime = string.Format(timeFormat, param.P.EndTime.Hours, param.P.EndTime.Minutes, param.P.EndTime.Seconds, (int)Math.Round(param.P.EndTime.Milliseconds / factor)); + sb.AppendFormat(paragraphWriteFormat, startTime, endTime, fileName); + + param.Saved = true; + } + } + else if (_exportType == ExportFormats.Spumux) + { + if (!param.Saved) + { + string numberString = $"IMAGE{i:000}"; + string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant()); + foreach (var encoder in ImageCodecInfo.GetImageEncoders()) + { + if (encoder.FormatID == ImageFormat.Png.Guid) + { + var parameters = new EncoderParameters { Param = { [0] = new EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 4) } }; + + var nbmp = new NikseBitmap(param.Bitmap); + var b = nbmp.ConvertTo8BitsPerPixel(); + b.Save(fileName, encoder, parameters); + b.Dispose(); + + break; + } + } + imagesSavedCount++; + + const string paragraphWriteFormat = "\t\t"; + const string timeFormat = "{0:00}:{1:00}:{2:00}.{3:00}"; + + double factor = TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate; + string startTime = string.Format(timeFormat, param.P.StartTime.Hours, param.P.StartTime.Minutes, param.P.StartTime.Seconds, (int)Math.Round(param.P.StartTime.Milliseconds / factor)); + string endTime = string.Format(timeFormat, param.P.EndTime.Hours, param.P.EndTime.Minutes, param.P.EndTime.Seconds, (int)Math.Round(param.P.EndTime.Milliseconds / factor)); + int left = (param.ScreenWidth - param.Bitmap.Width) / 2; + if (param.Alignment == ContentAlignment.BottomLeft || param.Alignment == ContentAlignment.TopLeft) + { + left = param.LeftMargin; + } + else if (param.Alignment == ContentAlignment.BottomRight || param.Alignment == ContentAlignment.TopRight) + { + left = param.ScreenWidth - param.Bitmap.Width - param.LeftMargin; + } + int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin); + if (param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopRight) + { + top = param.BottomMargin; + } + sb.AppendLine(string.Format(paragraphWriteFormat, startTime, endTime, fileName, left, top)); + + param.Saved = true; + } + } + else if (_exportType == ExportFormats.Fcp) + { + if (!param.Saved) + { + imagesSavedCount = WriteFcpParagraph(sb, imagesSavedCount, param, i, saveFileDialog1.FileName); + + param.Saved = true; + } + } + else if (_exportType == ExportFormats.Dost) + { + if (!param.Saved) + { + imagesSavedCount = WriteParagraphDost(sb, imagesSavedCount, param, i, saveFileDialog1.FileName); + param.Saved = true; + } + } + else if (_exportType == ExportFormats.ImageFrame) + { + if (!param.Saved) + { + var imageFormat = ImageFormat; + + int lastFrame = imagesSavedCount; + int startFrame = (int)Math.Round(param.P.StartTime.TotalMilliseconds / (TimeCode.BaseUnit / param.FramesPerSeconds)); + var empty = new Bitmap(param.ScreenWidth, param.ScreenHeight); + + if (imagesSavedCount != 0 || !checkBoxSkipEmptyFrameAtStart.Checked) + { + // Save empty picture for each frame up to start frame + for (int k = lastFrame + 1; k < startFrame; k++) + { + string numberString = $"{k:00000}"; + string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant()); + empty.Save(fileName, imageFormat); + imagesSavedCount++; + } + } + + int endFrame = (int)Math.Round(param.P.EndTime.TotalMilliseconds / (TimeCode.BaseUnit / param.FramesPerSeconds)); + var fullSize = new Bitmap(param.ScreenWidth, param.ScreenHeight); + Graphics g = Graphics.FromImage(fullSize); + g.DrawImage(param.Bitmap, (param.ScreenWidth - param.Bitmap.Width) / 2, param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin)); + g.Dispose(); + + if (imagesSavedCount > startFrame) + { + startFrame = imagesSavedCount; // no overlapping + } + + // Save sub picture for each frame in duration + for (int k = startFrame; k <= endFrame; k++) + { + string numberString = $"{k:00000}"; + string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant()); + fullSize.Save(fileName, imageFormat); + imagesSavedCount++; + } + fullSize.Dispose(); + param.Saved = true; + } + } + else if (_exportType == ExportFormats.DCinemaInterop) + { + if (!param.Saved) + { + string numberString = $"{i:0000}"; + string fileName = Path.Combine(Path.GetDirectoryName(saveFileDialog1.FileName), numberString + ".png"); + param.Bitmap.Save(fileName, ImageFormat.Png); + imagesSavedCount++; + param.Saved = true; + + string verticalAlignment = "bottom"; + string horizontalAlignment = "center"; + string vPos = "9.7"; + string hPos = "0"; + + switch (param.Alignment) + { + case ContentAlignment.BottomLeft: + verticalAlignment = "bottom"; + horizontalAlignment = "left"; + hPos = "10"; + break; + case ContentAlignment.BottomRight: + verticalAlignment = "bottom"; + horizontalAlignment = "right"; + hPos = "10"; + break; + case ContentAlignment.MiddleCenter: + verticalAlignment = "center"; + vPos = "0"; + break; + case ContentAlignment.MiddleLeft: + verticalAlignment = "center"; + horizontalAlignment = "left"; + hPos = "10"; + vPos = "0"; + break; + case ContentAlignment.MiddleRight: + verticalAlignment = "center"; + horizontalAlignment = "right"; + hPos = "10"; + vPos = "0"; + break; + case ContentAlignment.TopCenter: + verticalAlignment = "top"; + break; + case ContentAlignment.TopLeft: + verticalAlignment = "top"; + horizontalAlignment = "left"; + hPos = "10"; + break; + case ContentAlignment.TopRight: + verticalAlignment = "top"; + horizontalAlignment = "right"; + hPos = "10"; + break; + } + + sb.AppendLine(""); + if (param.Depth3D == 0) + { + sb.AppendLine("" + numberString + ".png" + ""); + } + else + { + sb.AppendLine("" + numberString + ".png" + ""); + } + + sb.AppendLine(""); + } + } + else if (_exportType == ExportFormats.DCinemaSmpte2014) + { + if (!param.Saved) + { + string numberString = $"{i:0000}"; + string fileName = Path.Combine(Path.GetDirectoryName(saveFileDialog1.FileName), numberString + ".png"); + param.Bitmap.Save(fileName, ImageFormat.Png); + imagesSavedCount++; + param.Saved = true; + + string verticalAlignment = "bottom"; + string horizontalAlignment = "center"; + string vPos = "9.7"; + string hPos = "0"; + + switch (param.Alignment) + { + case ContentAlignment.BottomLeft: + verticalAlignment = "bottom"; + horizontalAlignment = "left"; + hPos = "10"; + break; + case ContentAlignment.BottomRight: + verticalAlignment = "bottom"; + horizontalAlignment = "right"; + hPos = "10"; + break; + case ContentAlignment.MiddleCenter: + verticalAlignment = "center"; + vPos = "0"; + break; + case ContentAlignment.MiddleLeft: + verticalAlignment = "center"; + horizontalAlignment = "left"; + hPos = "10"; + vPos = "0"; + break; + case ContentAlignment.MiddleRight: + verticalAlignment = "center"; + horizontalAlignment = "right"; + hPos = "10"; + vPos = "0"; + break; + case ContentAlignment.TopCenter: + verticalAlignment = "top"; + break; + case ContentAlignment.TopLeft: + verticalAlignment = "top"; + horizontalAlignment = "left"; + hPos = "10"; + break; + case ContentAlignment.TopRight: + verticalAlignment = "top"; + horizontalAlignment = "right"; + hPos = "10"; + break; + } + + sb.AppendLine(""); + if (param.Depth3D == 0) + { + sb.AppendLine("" + numberString + ".png" + ""); + } + else + { + sb.AppendLine("" + numberString + ".png" + ""); + } + + sb.AppendLine(""); + } + } + else if (_exportType == ExportFormats.Edl || _exportType == ExportFormats.EdlClipName) + { + if (!param.Saved) + { + // 001 7M6C7986 V C 14:14:55:21 14:15:16:24 01:00:10:18 01:00:31:21 + var fileName1 = "IMG" + i.ToString(CultureInfo.InvariantCulture).PadLeft(5, '0'); + + var fullSize = new Bitmap(param.ScreenWidth, param.ScreenHeight); + using (var g = Graphics.FromImage(fullSize)) + { + g.DrawImage(param.Bitmap, (param.ScreenWidth - param.Bitmap.Width) / 2, param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin)); + } + var fileName2 = Path.Combine(Path.GetDirectoryName(param.SavDialogFileName), fileName1 + ".PNG"); + fullSize.Save(fileName2, ImageFormat.Png); + fullSize.Dispose(); + + string line = $"{i:000} {fileName1} V C {new TimeCode().ToHHMMSSFF()} {param.P.Duration.ToHHMMSSFF()} {param.P.StartTime.ToHHMMSSFF()} {param.P.EndTime.ToHHMMSSFF()}"; + sb.AppendLine(line); + if (_exportType == ExportFormats.EdlClipName) + { + sb.AppendLine("* FROM CLIP NAME: " + fileName1 + ".PNG"); + } + sb.AppendLine(); + + imagesSavedCount++; + param.Saved = true; + } + } + else // BDNXML + { + if (!param.Saved) + { + imagesSavedCount = WriteBdnXmlParagraph(width, sb, border, height, imagesSavedCount, param, i, folderBrowserDialog1.SelectedPath); + param.Saved = true; + } + } + } + return imagesSavedCount; + } + + internal int WriteFcpParagraph(StringBuilder sb, int imagesSavedCount, MakeBitmapParameter param, int i, string fileName) + { + string numberString = string.Format(Path.GetFileNameWithoutExtension(Path.GetFileName(fileName)) + "{0:0000}", i).RemoveChar(' '); + var fileNameShort = numberString + "." + comboBoxImageFormat.Text.ToLowerInvariant(); + var targetImageFileName = Path.Combine(Path.GetDirectoryName(fileName), fileNameShort); + string fileNameNoPath = Path.GetFileName(fileNameShort); + string fileNameNoExt = Path.GetFileNameWithoutExtension(fileNameNoPath); + string pathUrl = "file://localhost/" + targetImageFileName.Replace("\\", "/").Replace(" ", "%20"); + if (!checkBoxFcpFullPathUrl.Checked) + { + pathUrl = fileNameShort; + } + + string template = " " + Environment.NewLine + +@" " + System.Security.SecurityElement.Escape(fileNameNoPath) + @" + [DURATION] + + [TIMEBASE] + [NTSC] + + [IN] + [OUT] + [START] + [END] + " + param.VideoResolution + @" + TRUE + FALSE + straight + " + System.Security.SecurityElement.Escape(fileNameNoPath) + @"1" + Environment.NewLine + + " " + @" + " + System.Security.SecurityElement.Escape(fileNameNoPath) + @" + " + pathUrl + @" + + [TIMEBASE] + [NTSC] + + [DURATION] + " + param.ScreenWidth + @" + " + param.ScreenHeight + @" + + + + + + video + + none + "; + + var outBitmap = param.Bitmap; + if (checkBoxFullFrameImage.Checked) + { + var nbmp = new NikseBitmap(param.Bitmap); + nbmp.ReplaceTransparentWith(panelFullFrameBackground.BackColor); + using (var bmp = nbmp.GetBitmap()) + { + int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin); + int left = (param.ScreenWidth - param.Bitmap.Width) / 2; + + var b = new NikseBitmap(param.ScreenWidth, param.ScreenHeight); + { + b.Fill(panelFullFrameBackground.BackColor); + outBitmap = b.GetBitmap(); + { + if (param.Alignment == ContentAlignment.BottomLeft || param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.TopLeft) + { + left = param.LeftMargin; + } + else if (param.Alignment == ContentAlignment.BottomRight || param.Alignment == ContentAlignment.MiddleRight || param.Alignment == ContentAlignment.TopRight) + { + left = param.ScreenWidth - param.Bitmap.Width - param.RightMargin; + } + + if (param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopRight) + { + top = param.BottomMargin; + } + + if (param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.MiddleCenter || param.Alignment == ContentAlignment.MiddleRight) + { + top = (param.ScreenHeight - param.Bitmap.Height) / 2; + } + + if (param.OverridePosition.HasValue && + param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.Bitmap.Width && + param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.Bitmap.Height) + { + left = param.OverridePosition.Value.X; + top = param.OverridePosition.Value.Y; + } + + using (var g = Graphics.FromImage(outBitmap)) + { + g.DrawImage(bmp, left, top); + g.Dispose(); + } + } + } + } + } + + + if (comboBoxImageFormat.Text == "8-bit png") + { + foreach (var encoder in ImageCodecInfo.GetImageEncoders()) + { + if (encoder.FormatID == ImageFormat.Png.Guid) + { + var parameters = new EncoderParameters(); + parameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 8); + + var nbmp = new NikseBitmap(outBitmap); + var b = nbmp.ConvertTo8BitsPerPixel(); + b.Save(targetImageFileName, encoder, parameters); + b.Dispose(); + + break; + } + } + } + else + { + SaveImage(outBitmap, targetImageFileName, ImageFormat); + } + imagesSavedCount++; + + int timeBase = 25; + string ntsc = "FALSE"; + if (comboBoxLanguage.SelectedItem.ToString().Equals("NTSC", StringComparison.Ordinal)) + { + ntsc = "TRUE"; + } + + if (Math.Abs(param.FramesPerSeconds - 29.97) < 0.01) + { + timeBase = 30; + ntsc = "TRUE"; + } + else if (Math.Abs(param.FramesPerSeconds - 23.976) < 0.01) + { + timeBase = 24; + ntsc = "TRUE"; + } + else if (Math.Abs(param.FramesPerSeconds - 59.94) < 0.01) + { + timeBase = 60; + ntsc = "TRUE"; + } + + var duration = SubtitleFormat.MillisecondsToFrames(param.P.Duration.TotalMilliseconds, param.FramesPerSeconds); + var start = SubtitleFormat.MillisecondsToFrames(param.P.StartTime.TotalMilliseconds, param.FramesPerSeconds); + var end = SubtitleFormat.MillisecondsToFrames(param.P.EndTime.TotalMilliseconds, param.FramesPerSeconds); + + template = template.Replace("[DURATION]", duration.ToString(CultureInfo.InvariantCulture)); + template = template.Replace("[IN]", start.ToString(CultureInfo.InvariantCulture)); + template = template.Replace("[OUT]", end.ToString(CultureInfo.InvariantCulture)); + template = template.Replace("[START]", start.ToString(CultureInfo.InvariantCulture)); + template = template.Replace("[END]", end.ToString(CultureInfo.InvariantCulture)); + template = template.Replace("[TIMEBASE]", timeBase.ToString(CultureInfo.InvariantCulture)); + template = template.Replace("[NTSC]", ntsc); + sb.AppendLine(template); + return imagesSavedCount; + } + + internal int WriteBdnXmlParagraph(int width, StringBuilder sb, int border, int height, int imagesSavedCount, MakeBitmapParameter param, int i, string path) + { + string numberString = $"{i:0000}"; + string fileName = Path.Combine(path, numberString + ".png"); + + if (comboBoxImageFormat.Text == "Png 8-bit") + { + foreach (var encoder in ImageCodecInfo.GetImageEncoders()) + { + if (encoder.FormatID == ImageFormat.Png.Guid) + { + var parameters = new EncoderParameters(); + parameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 8); + + var nbmp = new NikseBitmap(param.Bitmap); + var b = nbmp.ConvertTo8BitsPerPixel(); + b.Save(fileName, encoder, parameters); + b.Dispose(); + + break; + } + } + } + else + { + param.Bitmap.Save(fileName, ImageFormat.Png); + } + + imagesSavedCount++; + + // + // subtitle_exp_0001.png + // + sb.AppendLine(""); + + int x = (width - param.Bitmap.Width) / 2; + int y = height - (param.Bitmap.Height + param.BottomMargin); + switch (param.Alignment) + { + case ContentAlignment.BottomLeft: + x = border; + y = height - (param.Bitmap.Height + param.BottomMargin); + break; + case ContentAlignment.BottomRight: + x = height - param.Bitmap.Width - border; + y = height - (param.Bitmap.Height + param.BottomMargin); + break; + case ContentAlignment.MiddleCenter: + x = (width - param.Bitmap.Width) / 2; + y = (height - param.Bitmap.Height) / 2; + break; + case ContentAlignment.MiddleLeft: + x = border; + y = (height - param.Bitmap.Height) / 2; + break; + case ContentAlignment.MiddleRight: + x = width - param.Bitmap.Width - border; + y = (height - param.Bitmap.Height) / 2; + break; + case ContentAlignment.TopCenter: + x = (width - param.Bitmap.Width) / 2; + y = border; + break; + case ContentAlignment.TopLeft: + x = border; + y = border; + break; + case ContentAlignment.TopRight: + x = width - param.Bitmap.Width - border; + y = border; + break; + } + + if (param.OverridePosition.HasValue && + param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.Bitmap.Width && + param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.Bitmap.Height) + { + x = param.OverridePosition.Value.X; + y = param.OverridePosition.Value.Y; + } + + sb.AppendLine(" " + numberString + ".png"); + sb.AppendLine(""); + return imagesSavedCount; + } + + internal int WriteParagraphDost(StringBuilder sb, int imagesSavedCount, MakeBitmapParameter param, int i, string fileName) + { + string numberString = string.Format("{0:0000}", i); + fileName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName).Replace(" ", "_")) + "_" + numberString + ".png"; + + foreach (var encoder in ImageCodecInfo.GetImageEncoders()) + { + if (encoder.FormatID == ImageFormat.Png.Guid) + { + var parameters = new EncoderParameters(); + parameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 8); + + var nbmp = new NikseBitmap(param.Bitmap); + var b = nbmp.ConvertTo8BitsPerPixel(); + b.Save(fileName, encoder, parameters); + b.Dispose(); + + break; + } + } + imagesSavedCount++; + + const string paragraphWriteFormat = "{0}\t{1}\t{2}\t{4}\t{5}\t{3}\t0\t0"; + + int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin); + int left = (param.ScreenWidth - param.Bitmap.Width) / 2; + if (param.Alignment == ContentAlignment.BottomLeft || param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.TopLeft) + { + left = param.LeftMargin; + } + else if (param.Alignment == ContentAlignment.BottomRight || param.Alignment == ContentAlignment.MiddleRight || param.Alignment == ContentAlignment.TopRight) + { + left = param.ScreenWidth - param.Bitmap.Width - param.RightMargin; + } + + if (param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopRight) + { + top = param.BottomMargin; + } + + if (param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.MiddleCenter || param.Alignment == ContentAlignment.MiddleRight) + { + top = param.ScreenHeight - (param.Bitmap.Height / 2); + } + + if (param.OverridePosition.HasValue && + param.OverridePosition.Value.X >= 0 && param.OverridePosition.Value.X < param.Bitmap.Width && + param.OverridePosition.Value.Y >= 0 && param.OverridePosition.Value.Y < param.Bitmap.Height) + { + left = param.OverridePosition.Value.X; + top = param.OverridePosition.Value.Y; + } + + string startTime = ToHHMMSSFF(param.P.StartTime); + string endTime = ToHHMMSSFF(param.P.EndTime); + sb.AppendLine(string.Format(paragraphWriteFormat, numberString, startTime, endTime, Path.GetFileName(fileName), left, top)); + return imagesSavedCount; + } + + private ImageFormat ImageFormat + { + get + { + var imageFormat = ImageFormat.Png; + if (comboBoxImageFormat.SelectedIndex == 0) + { + imageFormat = ImageFormat.Bmp; + } + else if (comboBoxImageFormat.SelectedIndex == 1) + { + imageFormat = ImageFormat.Exif; + } + else if (comboBoxImageFormat.SelectedIndex == 2) + { + imageFormat = ImageFormat.Gif; + } + else if (comboBoxImageFormat.SelectedIndex == 3) + { + imageFormat = ImageFormat.Jpeg; + } + else if (comboBoxImageFormat.SelectedIndex == 4) + { + imageFormat = ImageFormat.Png; + } + else if (comboBoxImageFormat.SelectedIndex == 5) + { + imageFormat = ImageFormat.Tiff; + } + + if (string.Compare(comboBoxImageFormat.Text, "tga", StringComparison.OrdinalIgnoreCase) == 0) + { + return ImageFormat.Icon; + } + + return imageFormat; + } + } + + private static string FormatFabTime(TimeCode time, MakeBitmapParameter param) + { + if (param.Bitmap.Width == 720 && param.Bitmap.Height == 480) // NTSC + { + return $"{time.Hours:00};{time.Minutes:00};{time.Seconds:00};{SubtitleFormat.MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + // drop frame + if (Math.Abs(param.FramesPerSeconds - 24 * (999 / 1000)) < 0.01 || + Math.Abs(param.FramesPerSeconds - 29 * (999 / 1000)) < 0.01 || + Math.Abs(param.FramesPerSeconds - 59 * (999 / 1000)) < 0.01) + { + return $"{time.Hours:00}:{time.Minutes:00}:{time.Seconds:00}:{SubtitleFormat.MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + return $"{time.Hours:00};{time.Minutes:00};{time.Seconds:00};{SubtitleFormat.MillisecondsToFramesMaxFrameRate(time.Milliseconds):00}"; + } + + private void SetupImageParameters() + { + if (subtitleListView1.SelectedItems.Count > 0 && _format.HasStyleSupport) + { + Paragraph p = _subtitle.GetParagraphOrDefault(subtitleListView1.SelectedItems[0].Index); + if (p != null && (_format.GetType() == typeof(AdvancedSubStationAlpha) || _format.GetType() == typeof(SubStationAlpha))) + { + if (!string.IsNullOrEmpty(p.Extra)) + { + comboBoxSubtitleFont.Enabled = false; + comboBoxSubtitleFontSize.Enabled = false; + buttonBorderColor.Enabled = false; + comboBoxHAlign.Enabled = false; + panelBorderColor.Enabled = false; + checkBoxBold.Enabled = false; + buttonColor.Enabled = false; + panelColor.Enabled = false; + comboBoxBorderWidth.Enabled = false; + comboBoxBottomMargin.Enabled = false; + comboBoxBottomMarginUnit.Enabled = false; + comboBoxBottomMarginUnit.SelectedIndex = 1; // px + comboBoxLeftRightMargin.Enabled = false; + comboBoxLeftRightMarginUnit.Enabled = false; + comboBoxLeftRightMarginUnit.SelectedIndex = 1; // px + comboBoxShadowWidth.Enabled = false; + buttonShadowColor.Enabled = false; + panelShadowColor.Enabled = false; + numericUpDownShadowTransparency.Enabled = _format.GetType() != typeof(AdvancedSubStationAlpha); + + SsaStyle style = AdvancedSubStationAlpha.GetSsaStyle(p.Extra, _subtitle.Header); + if (style != null) + { + int i; + for (i = 0; i < comboBoxBottomMargin.Items.Count; i++) + { + if (comboBoxBottomMargin.Items[i].ToString().Equals(style.MarginVertical.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase)) + { + comboBoxBottomMargin.SelectedIndex = i; + break; + } + } + + for (i = 0; i < comboBoxLeftRightMarginUnit.Items.Count; i++) + { + if (comboBoxLeftRightMarginUnit.Items[i].ToString().Equals(style.MarginLeft.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase)) + { + comboBoxLeftRightMarginUnit.SelectedIndex = i; + break; + } + } + + panelColor.BackColor = style.Primary; + panelBorderColor.BackColor = _format.GetType() == typeof(AdvancedSubStationAlpha) ? style.Outline : style.Background; + + for (i = 0; i < comboBoxSubtitleFont.Items.Count; i++) + { + if (comboBoxSubtitleFont.Items[i].ToString().Equals(style.FontName, StringComparison.OrdinalIgnoreCase)) + { + comboBoxSubtitleFont.SelectedIndex = i; + break; + } + } + for (i = 0; i < comboBoxSubtitleFontSize.Items.Count; i++) + { + if (comboBoxSubtitleFontSize.Items[i].ToString().Equals(style.FontSize.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase)) + { + comboBoxSubtitleFontSize.SelectedIndex = i; + break; + } + } + checkBoxBold.Checked = style.Bold; + comboBoxBorderWidth.Items.Clear(); + comboBoxBorderWidth.Items.Add(style.OutlineWidth.ToString(CultureInfo.InvariantCulture)); + comboBoxBorderWidth.SelectedIndex = 0; + + comboBoxShadowWidth.Items.Clear(); + comboBoxShadowWidth.Items.Add(style.ShadowWidth.ToString(CultureInfo.InvariantCulture)); + comboBoxShadowWidth.SelectedIndex = 0; + if (_format.GetType() == typeof(AdvancedSubStationAlpha)) + { + panelShadowColor.BackColor = style.Background; + numericUpDownShadowTransparency.Value = style.Background.A; + } + else + { + panelShadowColor.BackColor = style.Outline; + numericUpDownShadowTransparency.Value = style.Outline.A; + } + } + } + } + } + + _subtitleColor = panelColor.BackColor; + _borderColor = panelBorderColor.BackColor; + _subtitleFontName = comboBoxSubtitleFont.SelectedItem.ToString(); + _subtitleFontSize = float.Parse(comboBoxSubtitleFontSize.SelectedItem.ToString()); + _subtitleFontBold = checkBoxBold.Checked; + + _borderWidth = GetBorderWidth(); + } + + private float GetBorderWidth() + { + if (comboBoxBorderWidth.SelectedItem.ToString() == Configuration.Settings.Language.ExportPngXml.BorderStyleBoxForEachLine || + comboBoxBorderWidth.SelectedItem.ToString() == Configuration.Settings.Language.ExportPngXml.BorderStyleOneBox) + { + return 0; + } + + if (float.TryParse(comboBoxBorderWidth.SelectedItem.ToString(), out var f)) + { + return f; + } + + if (float.TryParse(Utilities.RemoveNonNumbers(comboBoxBorderWidth.SelectedItem.ToString()), out f)) + { + return f; + } + + return 0; + } + + private float GetShadowWidth() + { + if (float.TryParse(comboBoxShadowWidth.SelectedItem.ToString(), out var f)) + { + return f; + } + + if (float.TryParse(Utilities.RemoveNonNumbers(comboBoxShadowWidth.SelectedItem.ToString()), out f)) + { + return f; + } + + return 0; + } + + private static Font GetFont(MakeBitmapParameter parameter, float fontSize) + { + Font font; + try + { + var fontStyle = FontStyle.Regular; + if (parameter.SubtitleFontBold) + { + fontStyle = FontStyle.Bold; + } + + font = new Font(parameter.SubtitleFontName, fontSize, fontStyle); + } + catch (Exception exception) + { + try + { + var fontStyle = FontStyle.Regular; + if (!parameter.SubtitleFontBold) + { + fontStyle = FontStyle.Bold; + } + + font = new Font(parameter.SubtitleFontName, fontSize, fontStyle); + } + catch + { + MessageBox.Show(exception.Message); + + if (FontFamily.Families[0].IsStyleAvailable(FontStyle.Regular)) + { + font = new Font(FontFamily.Families[0].Name, fontSize); + } + else if (FontFamily.Families.Length > 1 && FontFamily.Families[1].IsStyleAvailable(FontStyle.Regular)) + { + font = new Font(FontFamily.Families[1].Name, fontSize); + } + else if (FontFamily.Families.Length > 2 && FontFamily.Families[1].IsStyleAvailable(FontStyle.Regular)) + { + font = new Font(FontFamily.Families[2].Name, fontSize); + } + else + { + font = new Font("Arial", fontSize); + } + } + } + return font; + } + + private double GetResizeScale() + { + if (comboBoxResizePercentage.SelectedItem == null) + { + return 1.0; + } + + var p = int.Parse(comboBoxResizePercentage.SelectedItem.ToString().Replace("%", string.Empty)); + return p / 100.0; + } + + private Bitmap GenerateImageFromTextWithStyle(Paragraph p, out MakeBitmapParameter mbp) + { + mbp = new MakeBitmapParameter { P = p }; + + if (_vobSubOcr != null) + { + var index = _subtitle.GetIndex(p); + if (index >= 0) + { + var b = _vobSubOcr.GetSubtitleBitmap(index); + var exp = GetResizeScale(); + if (Math.Abs(exp - 1) > 0.01) + { + var resizedBitmap = ResizeBitmap(b, (int)Math.Round(b.Width * exp), (int)Math.Round(b.Height * exp)); + b.Dispose(); + return resizedBitmap; + } + return b; + } + + } + + mbp.AlignLeft = comboBoxHAlign.SelectedIndex == 0; + mbp.AlignRight = comboBoxHAlign.SelectedIndex == 2; + mbp.JustifyLeft = GetJustifyLeft(p.Text); + mbp.JustifyTop = comboBoxHAlign.SelectedIndex == 4; + mbp.JustifyRight = comboBoxHAlign.SelectedIndex == 5; + mbp.SimpleRendering = checkBoxSimpleRender.Checked; + mbp.BorderWidth = _borderWidth; + mbp.BorderColor = _borderColor; + mbp.SubtitleFontName = _subtitleFontName; + mbp.SubtitleColor = _subtitleColor; + mbp.SubtitleFontSize = _subtitleFontSize; + mbp.SubtitleFontBold = _subtitleFontBold; + mbp.LineHeight = _lineHeights; + mbp.FullFrame = checkBoxFullFrameImage.Checked; + mbp.FullFrameBackgroundColor = panelFullFrameBackground.BackColor; + mbp.OverridePosition = GetAssPoint(p.Text); + + if (_format.HasStyleSupport && !string.IsNullOrEmpty(p.Extra)) + { + if (_format.GetType() == typeof(SubStationAlpha)) + { + var style = AdvancedSubStationAlpha.GetSsaStyle(p.Extra, _subtitle.Header); + mbp.SubtitleColor = style.Primary; + mbp.SubtitleFontBold = style.Bold; + mbp.SubtitleFontSize = style.FontSize; + mbp.BottomMargin = style.MarginVertical; + if (style.BorderStyle == "3") + { + mbp.BackgroundColor = style.Background; + } + mbp.ShadowColor = style.Outline; + } + else if (_format.GetType() == typeof(AdvancedSubStationAlpha)) + { + var style = AdvancedSubStationAlpha.GetSsaStyle(p.Extra, _subtitle.Header); + mbp.SubtitleColor = style.Primary; + mbp.SubtitleFontBold = style.Bold; + mbp.SubtitleFontSize = style.FontSize; + mbp.BottomMargin = style.MarginVertical; + if (style.BorderStyle == "3") + { + mbp.BackgroundColor = style.Outline; + } + mbp.ShadowAlpha = style.Background.A; + mbp.ShadowColor = style.Background; + } + } + + if (comboBoxBorderWidth.SelectedItem.ToString() == Configuration.Settings.Language.ExportPngXml.BorderStyleBoxForEachLine) + { + _borderWidth = 0; + mbp.BackgroundColor = panelBorderColor.BackColor; + mbp.BoxSingleLine = true; + } + else if (comboBoxBorderWidth.SelectedItem.ToString() == Configuration.Settings.Language.ExportPngXml.BorderStyleOneBox) + { + mbp.BoxSingleLine = false; + _borderWidth = 0; + mbp.BackgroundColor = panelBorderColor.BackColor; + } + + GetResolution(out var width, out var height); + mbp.ScreenWidth = width; + mbp.ScreenHeight = height; + mbp.VideoResolution = comboBoxResolution.Text; + mbp.Type3D = comboBox3D.SelectedIndex; + mbp.Depth3D = (int)numericUpDownDepth3D.Value; + mbp.BottomMargin = GetBottomMarginInPixels(p); + mbp.ShadowWidth = GetShadowWidth(); + mbp.ShadowAlpha = (int)numericUpDownShadowTransparency.Value; + mbp.ShadowColor = panelShadowColor.BackColor; + mbp.LineHeight = _lineHeights; + mbp.Forced = subtitleListView1.Items[_subtitle.GetIndex(p)].Checked; + mbp.LineJoin = Configuration.Settings.Tools.ExportPenLineJoin; + var bmp = GenerateImageFromTextWithStyle(mbp); + if (_exportType == ExportFormats.VobSub || _exportType == ExportFormats.Stl || _exportType == ExportFormats.Spumux) + { + var nbmp = new NikseBitmap(bmp); + nbmp.ConvertToFourColors(Color.Transparent, _subtitleColor, _borderColor, !checkBoxTransAntiAliase.Checked); + + if (_exportType == ExportFormats.Spumux) + { + nbmp.EnsureEvenLines(mbp.BoxSingleLine ? Color.Transparent : mbp.BackgroundColor); + } + + var temp = nbmp.GetBitmap(); + bmp.Dispose(); + return temp; + } + return bmp; + } + + private static int CalcWidthViaDraw(string text, MakeBitmapParameter parameter) + { + var nbmp = GenerateBitmapForCalc(text, parameter); + nbmp.CropTransparentSidesAndBottom(0, true); + return nbmp.Width; + } + + private static NikseBitmap GenerateBitmapForCalc(string text, MakeBitmapParameter parameter) + { + text = text.Trim(); + var path = new GraphicsPath(); + var sb = new StringBuilder(); + int i = 0; + bool isItalic = false; + bool isBold = parameter.SubtitleFontBold; + const float top = 5f; + bool newLine = false; + float left = 1.0f; + float leftMargin = left; + int newLinePathPoint = -1; + Color c = parameter.SubtitleColor; + var colorStack = new Stack(); + var lastText = new StringBuilder(); + var sf = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near }; + var bmp = new Bitmap(parameter.ScreenWidth, 200); + var g = Graphics.FromImage(bmp); + + g.CompositingQuality = CompositingQuality.HighSpeed; + g.SmoothingMode = SmoothingMode.HighSpeed; + g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; + + Font font = GetFont(parameter, parameter.SubtitleFontSize); + var fontStack = new Stack(); + while (i < text.Length) + { + if (text.Substring(i).StartsWith(" 0) + { + lastText.Append(sb); + TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); + if (path.PointCount == 0) + { + addLeft = left; + } + else if (addLeft < 0.01) + { + addLeft = left + 2; + } + + left = addLeft; + + DrawShadowAndPath(parameter, g, path); + var p2 = new SolidBrush(c); + g.FillPath(p2, path); + p2.Dispose(); + path.Reset(); + path = new GraphicsPath(); + sb.Clear(); + + int endIndex = text.Substring(i).IndexOf('>'); + if (endIndex < 0) + { + i += 9999; + } + else + { + string fontContent = text.Substring(i, endIndex); + if (fontContent.Contains(" color=", StringComparison.OrdinalIgnoreCase)) + { + string[] arr = fontContent.Substring(fontContent.IndexOf(" color=", StringComparison.OrdinalIgnoreCase) + 7).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + if (arr.Length > 0) + { + string fontColor = arr[0].Trim('\'').Trim('"').Trim('\''); + try + { + colorStack.Push(c); // save old color + if (fontColor.StartsWith("rgb(", StringComparison.OrdinalIgnoreCase)) + { + arr = fontColor.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); + } + else + { + c = ColorTranslator.FromHtml(fontColor); + } + } + catch + { + c = parameter.SubtitleColor; + } + } + } + if (fontContent.Contains(" face=", StringComparison.OrdinalIgnoreCase) || fontContent.Contains(" size=", StringComparison.OrdinalIgnoreCase)) + { + float fontSize = parameter.SubtitleFontSize; + string fontFace = parameter.SubtitleFontName; + + string[] arr = fontContent.Substring(fontContent.IndexOf(" face=", StringComparison.OrdinalIgnoreCase) + 6).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + if (arr.Length > 0) + { + fontFace = arr[0].Trim('\'').Trim('"').Trim('\''); + } + + arr = fontContent.Substring(fontContent.IndexOf(" size=", StringComparison.OrdinalIgnoreCase) + 6).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + if (arr.Length > 0) + { + string temp = arr[0].Trim('\'').Trim('"').Trim('\''); + if (float.TryParse(temp, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var f)) + { + fontSize = f; + } + } + + try + { + fontStack.Push(font); // save old cfont + var p = new MakeBitmapParameter { SubtitleFontName = fontFace, SubtitleFontSize = fontSize }; + font = GetFont(p, p.SubtitleFontSize); + } + catch + { + font = fontStack.Pop(); + } + } + i += endIndex; + } + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + if (text.Substring(i).ToLowerInvariant().Replace("", string.Empty).Replace("", string.Empty).Length > 0) + { + if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) + { + string t = sb.ToString(); + sb.Clear(); + sb.Append(' '); + sb.Append(t); + } + + float addLeft = 0; + int oldPathPointIndex = path.PointCount - 1; + if (oldPathPointIndex < 0) + { + oldPathPointIndex = 0; + } + + if (sb.Length > 0) + { + if (lastText.Length > 0 && left > 2) + { + left -= 1.5f; + } + + lastText.Append(sb); + + TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); + if (addLeft < 0.01) + { + addLeft = left + 2; + } + + left = addLeft; + + DrawShadowAndPath(parameter, g, path); + g.FillPath(new SolidBrush(c), path); + path.Reset(); + sb = new StringBuilder(); + if (colorStack.Count > 0) + { + c = colorStack.Pop(); + } + + if (left >= 3) + { + left -= 2.5f; + } + } + if (fontStack.Count > 0) + { + font.Dispose(); + font = fontStack.Pop(); + } + i += 6; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + if (sb.Length > 0) + { + lastText.Append(sb); + TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + isItalic = true; + i += 2; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) && isItalic) + { + if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) + { + string t = sb.ToString(); + sb.Clear(); + sb.Append(' '); + sb.Append(t); + } + lastText.Append(sb); + TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + isItalic = false; + i += 3; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + if (sb.Length > 0) + { + lastText.Append(sb); + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + isBold = true; + i += 2; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) && isBold) + { + if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) + { + string t = sb.ToString(); + sb.Clear(); + sb.Append(' '); + sb.Append(t); + } + lastText.Append(sb); + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + isBold = false; + i += 3; + } + else + { + sb.Append(text[i]); + } + i++; + } + if (sb.Length > 0) + { + TextDraw.DrawText(font, sf, path, sb, isItalic, parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + + DrawShadowAndPath(parameter, g, path); + g.FillPath(new SolidBrush(c), path); + g.Dispose(); + + var nbmp = new NikseBitmap(bmp); + bmp.Dispose(); + font.Dispose(); + sf.Dispose(); + return nbmp; + } + + internal static Bitmap GenerateImageFromTextWithStyle(MakeBitmapParameter parameter) + { + Bitmap bmp = null; + if (!parameter.SimpleRendering && parameter.P.Text.Contains(Environment.NewLine) && (parameter.BoxSingleLine || parameter.P.Text.Contains(BoxSingleLineText))) + { + string old = parameter.P.Text; + int oldType3D = parameter.Type3D; + if (parameter.Type3D == 2) // Half-Top/Bottom 3D + { + parameter.Type3D = 0; // fix later + } + var oldBackgroundColor = parameter.BackgroundColor; + if (parameter.P.Text.Contains(BoxSingleLineText)) + { + parameter.P.Text = parameter.P.Text.Replace("<" + BoxSingleLineText + ">", string.Empty).Replace("", string.Empty); + parameter.BackgroundColor = parameter.BorderColor; + } + + var italicOn = false; + var boldOn = false; + var fontTag = string.Empty; + var lineWidts = new List(); + foreach (var line in parameter.P.Text.SplitToLines()) + { + parameter.P.Text = line; + + if (italicOn) + { + parameter.P.Text = "" + parameter.P.Text; + } + italicOn = parameter.P.Text.Contains("", StringComparison.OrdinalIgnoreCase) && !parameter.P.Text.Contains("", StringComparison.OrdinalIgnoreCase); + if (italicOn) + { + parameter.P.Text += ""; + } + + if (boldOn) + { + parameter.P.Text = "" + parameter.P.Text; + } + boldOn = parameter.P.Text.Contains("", StringComparison.OrdinalIgnoreCase) && !parameter.P.Text.Contains("", StringComparison.OrdinalIgnoreCase); + if (boldOn) + { + parameter.P.Text += ""; + } + + parameter.P.Text = fontTag + parameter.P.Text; + if (parameter.P.Text.Contains("", StringComparison.OrdinalIgnoreCase)) + { + int start = parameter.P.Text.LastIndexOf("', start); + fontTag = parameter.P.Text.Substring(start, end - start + 1); + } + + var lineImage = GenerateImageFromTextWithStyleInner(parameter); + lineWidts.Add(lineImage.Width); + if (bmp == null) + { + bmp = lineImage; + } + else + { + int w = Math.Max(bmp.Width, lineImage.Width); + int h = bmp.Height + lineImage.Height; + + int l1; + if (parameter.AlignLeft) + { + l1 = 0; + } + else if (parameter.AlignRight) + { + l1 = w - bmp.Width; + } + else + { + l1 = (int)Math.Round((w - bmp.Width) / 2.0); + + if (parameter.JustifyLeft) + { + l1 = 0; + } + else if (parameter.JustifyRight) + { + l1 = w - lineImage.Width; + } + } + + int l2; + if (parameter.AlignLeft) + { + l2 = 0; + } + else if (parameter.AlignRight) + { + l2 = w - lineImage.Width; + } + else + { + l2 = (int)Math.Round((w - lineImage.Width) / 2.0); + + if (parameter.JustifyLeft) + { + l2 = 0; + } + else if (parameter.JustifyRight) + { + l2 = w - lineImage.Width; + if (parameter.BoxSingleLine) + { + l1 = w - lineWidts[0]; + } + } + } + + var style = GetStyleName(parameter.P); + var lineHeight = 25; + if (parameter.LineHeight.ContainsKey(style)) + { + lineHeight = parameter.LineHeight[style]; + } + else if (parameter.LineHeight.Count > 0) + { + lineHeight = parameter.LineHeight.First().Value; + } + + if (lineHeight > lineImage.Height) + { + h += lineHeight - lineImage.Height; + var largeImage = new Bitmap(w, h); + var g = Graphics.FromImage(largeImage); + g.DrawImageUnscaled(bmp, new Point(l1, 0)); + g.DrawImageUnscaled(lineImage, new Point(l2, bmp.Height + lineHeight - lineImage.Height)); + bmp.Dispose(); + bmp = largeImage; + g.Dispose(); + } + else + { + var largeImage = new Bitmap(w, h); + var g = Graphics.FromImage(largeImage); + g.DrawImageUnscaled(bmp, new Point(l1, 0)); + g.DrawImageUnscaled(lineImage, new Point(l2, bmp.Height)); + bmp.Dispose(); + bmp = largeImage; + g.Dispose(); + } + } + } + parameter.P.Text = old; + parameter.Type3D = oldType3D; + parameter.BackgroundColor = oldBackgroundColor; + + if (parameter.Type3D == 2) // Half-side-by-side 3D - due to per line we need to do this after making lines + { + var newBmp = Make3DTopBottom(parameter, new NikseBitmap(bmp)).GetBitmap(); + bmp?.Dispose(); + bmp = newBmp; + } + } + else + { + var oldBackgroundColor = parameter.BackgroundColor; + string oldText = parameter.P.Text; + if (parameter.P.Text.Contains(BoxMultiLineText) || parameter.P.Text.Contains(BoxSingleLineText)) + { + parameter.P.Text = parameter.P.Text.Replace("<" + BoxMultiLineText + ">", string.Empty).Replace("", string.Empty); + parameter.P.Text = parameter.P.Text.Replace("<" + BoxSingleLineText + ">", string.Empty).Replace("", string.Empty); + parameter.BackgroundColor = parameter.BorderColor; + } + bmp = GenerateImageFromTextWithStyleInner(parameter); + parameter.P.Text = oldText; + parameter.BackgroundColor = oldBackgroundColor; + } + return bmp; + } + + private static readonly Dictionary PaddingDictionary = new Dictionary(); + private static Bitmap GenerateImageFromTextWithStyleInner(MakeBitmapParameter parameter) // for UI + { + string text = parameter.P.Text; + + text = AssToHtmlTagsIfKnow(text); + + text = text.Replace("", ""); + text = text.Replace("", ""); + text = HtmlUtil.FixInvalidItalicTags(text); + + text = text.Replace("", ""); + text = text.Replace("", ""); + + // no support for underline + text = HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagUnderline); + + Font font = null; + Bitmap bmp = null; + try + { + font = GetFont(parameter, parameter.SubtitleFontSize); + SizeF textSize; + using (var bmpTemp = new Bitmap(1, 1)) + using (var g = Graphics.FromImage(bmpTemp)) + { + textSize = g.MeasureString(HtmlUtil.RemoveHtmlTags(text), font); + } + int sizeX = (int)(textSize.Width * 1.8) + 150; + int sizeY = (int)(textSize.Height * 0.9) + 50; + if (sizeX < 1) + { + sizeX = 1; + } + + if (sizeY < 1) + { + sizeY = 1; + } + + if (parameter.BackgroundColor != Color.Transparent) + { + var nbmpTemp = new NikseBitmap(sizeX, sizeY + _boxBorderSize * 2); // make room for box border above+under text + nbmpTemp.Fill(parameter.BackgroundColor); + bmp = nbmpTemp.GetBitmap(); + } + else + { + bmp = new Bitmap(sizeX, sizeY); + } + + var paddingKey = font.Name + font.Size.ToString(CultureInfo.InvariantCulture); + int baseLinePadding; + if (PaddingDictionary.ContainsKey(paddingKey)) + { + baseLinePadding = PaddingDictionary[paddingKey]; + } + else + { + baseLinePadding = (int)Math.Round(TextDraw.MeasureTextHeight(font, "yjK)", parameter.SubtitleFontBold) - TextDraw.MeasureTextHeight(font, "ac", parameter.SubtitleFontBold)); + PaddingDictionary.Add(paddingKey, baseLinePadding); + } + + // align lines with "gjpqy,ýęçÇ/()[]" a bit lower + var lines = text.SplitToLines(); + if (lines.Count > 0) + { + var lastLine = lines[lines.Count - 1]; + if (lastLine.Contains(new[] { 'g', 'j', 'p', 'q', 'y', ',', 'ý', 'ę', 'ç', 'Ç', '/', '(', ')', '[', ']' })) + { + var textNoBelow = lastLine.Replace('g', 'a').Replace('j', 'a').Replace('p', 'a').Replace('q', 'a').Replace('y', 'a').Replace(',', 'a').Replace('ý', 'a').Replace('ę', 'a').Replace('ç', 'a').Replace('Ç', 'a').Replace('/', 'a').Replace('(', 'a').Replace(')', 'a').Replace('[', 'a').Replace(']', 'a'); + baseLinePadding -= (int)Math.Round(TextDraw.MeasureTextHeight(font, lastLine, parameter.SubtitleFontBold) - TextDraw.MeasureTextHeight(font, textNoBelow, parameter.SubtitleFontBold)); + } + else + { + baseLinePadding += 1; + } + if (baseLinePadding < 0) + { + baseLinePadding = 0; + } + } + + if (lines.Count == 1 && parameter.JustifyTop) // align top + { + baseLinePadding += (int)Math.Round(TextDraw.MeasureTextHeight(font, "yjK)", parameter.SubtitleFontBold)); + } + + // TODO: Better baseline - test http://bobpowell.net/formattingtext.aspx + //float baselineOffset=font.SizeInPoints/font.FontFamily.GetEmHeight(font.Style)*font.FontFamily.GetCellAscent(font.Style); + //float baselineOffsetPixels = g.DpiY/72f*baselineOffset; + //baseLinePadding = (int)Math.Round(baselineOffsetPixels); + + var lefts = new List(); + var widths = new List(); + if (text.Contains("", StringComparison.OrdinalIgnoreCase) || text.Contains("", StringComparison.OrdinalIgnoreCase)) + { + bool tempItalicOn = false; + bool tempBoldOn = false; + var tempFontOn = string.Empty; + foreach (string line in text.SplitToLines()) + { + var tempLine = line; + + if (tempItalicOn) + { + tempLine = "" + tempLine; + } + + if (tempBoldOn) + { + tempLine = "" + tempLine; + } + + if (!string.IsNullOrEmpty(tempFontOn)) + { + tempLine = tempFontOn + tempLine; + } + + if (tempLine.LastIndexOf("= 0 && + tempLine.LastIndexOf("", StringComparison.Ordinal) < + tempLine.LastIndexOf("', start); + if (end > 0) + { + tempFontOn = tempLine.Substring(start, end - start + 1); + } + } + else if (tempLine.LastIndexOf("", StringComparison.Ordinal) >= 0) + { + tempFontOn = string.Empty; + } + + if (tempLine.Contains("") && !tempLine.Contains("")) + { + tempItalicOn = true; + } + + if (tempLine.Contains("") && !tempLine.Contains("")) + { + tempBoldOn = true; + } + + int w; + if (text.Contains("")) + { + tempItalicOn = false; + } + + if (line.Contains("")) + { + tempBoldOn = false; + } + } + } + else + { + foreach (var line in HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagItalic, HtmlUtil.TagFont).SplitToLines()) + { + if (parameter.JustifyRight) + { + var w = TextDraw.MeasureTextWidth(font, line, parameter.SubtitleFontBold); + widths.Add(w); + } + + if (parameter.AlignLeft) + { + lefts.Add(5); + } + else if (parameter.AlignRight) + { + lefts.Add(bmp.Width - (TextDraw.MeasureTextWidth(font, line, parameter.SubtitleFontBold) + 15)); + } + else + { + lefts.Add((float)((bmp.Width - TextDraw.MeasureTextWidth(font, line, parameter.SubtitleFontBold) + 15) / 2.0)); + } + } + } + + if (parameter.JustifyLeft) + { + // left justify centered lines + var minX = lefts.Min(p => p); + for (var index = 0; index < lefts.Count; index++) + { + lefts[index] = minX; + } + } + else if (parameter.JustifyRight) + { + // right justify centered lines + var maxX = widths.Max(p => p); + var minX = lefts.Min(p => p); + for (var index = 0; index < lefts.Count; index++) + { + lefts[index] = minX + maxX - widths[index]; + } + } + + var sf = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near }; + + using (var g = Graphics.FromImage(bmp)) + { + g.CompositingQuality = CompositingQuality.HighQuality; + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + g.SmoothingMode = SmoothingMode.HighQuality; + g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; + + if (parameter.SimpleRendering) + { + if (text.StartsWith(" 0) + { + left = lefts[0]; + } + + float top = 5; + if (top < _boxBorderSize && parameter.BackgroundColor != Color.Transparent) + { + top = _boxBorderSize; // make text down so box border will be satisfied + } + + bool newLine = false; + int lineNumber = 0; + float leftMargin = left; + int newLinePathPoint = -1; + Color c = parameter.SubtitleColor; + var colorStack = new Stack(); + var fontStack = new Stack(); + var lastText = new StringBuilder(); + for (var i = 0; i < text.Length; i++) + { + if (text.Substring(i).StartsWith(" 0) + { + lastText.Append(sb); + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); + if (path.PointCount == 0) + { + addLeft = left; + } + else if (addLeft < 0.01) + { + addLeft = left + 2; + } + + left = addLeft; + + DrawShadowAndPath(parameter, g, path); + var p2 = new SolidBrush(c); + g.FillPath(p2, path); + p2.Dispose(); + path.Reset(); + path = new GraphicsPath(); + sb = new StringBuilder(); + + int endIndex = text.Substring(i).IndexOf('>'); + if (endIndex < 0) + { + i += 9999; + } + else + { + string fontContent = text.Substring(i, endIndex); + if (fontContent.Contains(" color=", StringComparison.OrdinalIgnoreCase)) + { + string[] arr = fontContent.Substring(fontContent.IndexOf(" color=", StringComparison.OrdinalIgnoreCase) + 7).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + if (arr.Length > 0) + { + string fontColor = arr[0].Trim('\'').Trim('"').Trim('\''); + try + { + colorStack.Push(c); // save old color + if (fontColor.StartsWith("rgb(", StringComparison.OrdinalIgnoreCase)) + { + arr = fontColor.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2])); + } + else + { + c = ColorTranslator.FromHtml(fontColor); + } + } + catch + { + c = parameter.SubtitleColor; + } + } + } + if (fontContent.Contains(" face=", StringComparison.OrdinalIgnoreCase) || fontContent.Contains(" size=", StringComparison.OrdinalIgnoreCase)) + { + float fontSize = parameter.SubtitleFontSize; + string fontFace = parameter.SubtitleFontName; + + string[] arr = fontContent.Substring(fontContent.IndexOf(" face=", StringComparison.OrdinalIgnoreCase) + 6).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + if (arr.Length > 0) + { + fontFace = arr[0].Trim('\'').Trim('"').Trim('\''); + } + + arr = fontContent.Substring(fontContent.IndexOf(" size=", StringComparison.OrdinalIgnoreCase) + 6).Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + if (arr.Length > 0) + { + string temp = arr[0].Trim('\'').Trim('"').Trim('\''); + if (float.TryParse(temp, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var f)) + { + fontSize = f; + } + } + + try + { + fontStack.Push(font); // save old cfont + var p = new MakeBitmapParameter { SubtitleFontName = fontFace, SubtitleFontSize = fontSize }; + font = GetFont(p, p.SubtitleFontSize); + } + catch + { + font = fontStack.Pop(); + } + } + + + i += endIndex; + } + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + if (text.Substring(i).ToLowerInvariant().Replace("", string.Empty).Replace("", string.Empty).Length > 0) + { + if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) + { + string t = sb.ToString(); + sb.Clear(); + sb.Append(' '); + sb.Append(t); + } + + float addLeft = 0; + int oldPathPointIndex = path.PointCount - 1; + if (oldPathPointIndex < 0) + { + oldPathPointIndex = 0; + } + + if (sb.Length > 0) + { + if (lastText.Length > 0 && left > 2) + { + left -= 1.5f; + } + + lastText.Append(sb); + + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); + if (addLeft < 0.01) + { + addLeft = left + 2; + } + + left = addLeft; + + DrawShadowAndPath(parameter, g, path); + g.FillPath(new SolidBrush(c), path); + path.Reset(); + sb.Clear(); + if (colorStack.Count > 0) + { + c = colorStack.Pop(); + } + + if (left >= 3) + { + left -= 2.5f; + } + } + if (fontStack.Count > 0) + { + font.Dispose(); + font = fontStack.Pop(); + } + i += 6; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + if (sb.Length > 0) + { + float addLeft = 0; + int oldPathPointIndex = path.PointCount - 1; + if (oldPathPointIndex < 0) + { + oldPathPointIndex = 0; + } + + lastText.Append(sb); + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); + if (addLeft < 0.01) + { + addLeft = left + 2; + } + + left = addLeft; + } + isItalic = true; + i += 2; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) && isItalic) + { + if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) + { + string t = sb.ToString(); + sb.Clear(); + sb.Append(' '); + sb.Append(t); + } + + if (sb.Length > 0) + { + float addLeft = 0; + int oldPathPointIndex = path.PointCount - 1; + if (oldPathPointIndex < 0) + { + oldPathPointIndex = 0; + } + + if (sb.Length > 0) + { + if (lastText.Length > 0 && left > 2) + { + left -= 1.5f; + } + + lastText.Append(sb); + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); + if (addLeft < 0.01) + { + addLeft = left + 2; + } + + left = addLeft; + } + + isItalic = false; + i += 3; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) && !isItalic) + { + i += 3; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + if (sb.Length > 0) + { + lastText.Append(sb); + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + isBold = true; + i += 2; + } + else if (text.Substring(i).StartsWith("", StringComparison.OrdinalIgnoreCase) && isBold) + { + if (lastText.EndsWith(' ') && !sb.StartsWith(' ')) + { + string t = sb.ToString(); + sb.Clear(); + sb.Append(' '); + sb.Append(t); + } + + if (sb.Length > 0) + { + float addLeft = 0; + int oldPathPointIndex = path.PointCount - 1; + if (oldPathPointIndex < 0) + { + oldPathPointIndex = 0; + } + + if (sb.Length > 0) + { + if (lastText.Length > 0 && left > 2) + { + left -= 1.5f; + } + + lastText.Append(sb); + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + + addLeft = GetLastPositionFromPath(path, oldPathPointIndex, addLeft); + if (addLeft < 0.01) + { + addLeft = left + 2; + } + + left = addLeft; + } + + isBold = false; + i += 3; + } + else if (text.Substring(i).StartsWith(Environment.NewLine, StringComparison.Ordinal)) + { + lastText.Append(sb); + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + var style = GetStyleName(parameter.P); + var lineHeight = (int)Math.Round(textSize.Height * 0.64f); + if (parameter.LineHeight.ContainsKey(style)) + { + lineHeight = parameter.LineHeight[style]; + } + + top += lineHeight; + newLine = true; + i += Environment.NewLine.Length - 1; + lineNumber++; + if (lineNumber < lefts.Count) + { + leftMargin = lefts[lineNumber]; + left = leftMargin; + } + } + else + { + sb.Append(text[i]); + } + } + if (sb.Length > 0) + { + TextDraw.DrawText(font, sf, path, sb, isItalic, isBold || parameter.SubtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint); + } + + DrawShadowAndPath(parameter, g, path); + g.FillPath(new SolidBrush(c), path); + } + } + sf.Dispose(); + + var nbmp = new NikseBitmap(bmp); + if (parameter.BackgroundColor == Color.Transparent) + { + nbmp.CropTransparentSidesAndBottom(baseLinePadding, true); + nbmp.CropTransparentSidesAndBottom(2, false); + } + else + { + nbmp.CropSidesAndBottom(_boxBorderSize, parameter.BackgroundColor, true); + nbmp.CropTop(_boxBorderSize, parameter.BackgroundColor); + } + + if (nbmp.Width > parameter.ScreenWidth) + { + parameter.Error = "#" + parameter.P.Number.ToString(CultureInfo.InvariantCulture) + ": " + nbmp.Width.ToString(CultureInfo.InvariantCulture) + " > " + parameter.ScreenWidth.ToString(CultureInfo.InvariantCulture); + } + + if (parameter.Type3D == 1) // Half-side-by-side 3D + { + Bitmap singleBmp = nbmp.GetBitmap(); + Bitmap singleHalfBmp = ScaleToHalfWidth(singleBmp); + singleBmp.Dispose(); + var sideBySideBmp = new Bitmap(parameter.ScreenWidth, singleHalfBmp.Height); + int singleWidth = parameter.ScreenWidth / 2; + int singleLeftMargin = (singleWidth - singleHalfBmp.Width) / 2; + + using (Graphics gSideBySide = Graphics.FromImage(sideBySideBmp)) + { + gSideBySide.DrawImage(singleHalfBmp, singleLeftMargin + parameter.Depth3D, 0); + gSideBySide.DrawImage(singleHalfBmp, singleWidth + singleLeftMargin - parameter.Depth3D, 0); + } + nbmp = new NikseBitmap(sideBySideBmp); + if (parameter.BackgroundColor == Color.Transparent) + { + nbmp.CropTransparentSidesAndBottom(2, true); + } + else + { + nbmp.CropSidesAndBottom(_boxBorderSize, parameter.BackgroundColor, true); + } + } + else if (parameter.Type3D == 2) // Half-Top/Bottom 3D + { + nbmp = Make3DTopBottom(parameter, nbmp); + } + return nbmp.GetBitmap(); + } + finally + { + font?.Dispose(); + bmp?.Dispose(); + } + } + + private static float GetLastPositionFromPath(GraphicsPath path, int oldPathPointIndex, float addLeft) + { + if (path.PointCount > 0) + { + var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!! + for (int k = oldPathPointIndex + 1; k < list.Length; k++) + { + if (list[k].X > addLeft) + { + addLeft = list[k].X; + } + } + } + return addLeft; + } + + private static Point? GetAssPoint(string s) + { + int k = s.IndexOf("{\\", StringComparison.Ordinal); + while (k >= 0) + { + int l = s.IndexOf('}', k + 1); + if (l < k) + { + break; + } + + var assTags = s.Substring(k + 1, l - k - 1).Split('\\'); + foreach (var assTag in assTags) + { + if (assTag.StartsWith("pos(", StringComparison.Ordinal)) + { + var numbers = assTag.Remove(0, 4).TrimEnd(')').Trim().Split(','); + if (numbers.Length == 2 && Utilities.IsInteger(numbers[0]) && Utilities.IsInteger(numbers[1])) + { + return new Point(int.Parse(numbers[0]), int.Parse(numbers[1])); + } + } + } + k = s.IndexOf("{\\", k + 1, StringComparison.Ordinal); + } + return null; + } + + private static string AssToHtmlTagsIfKnow(string s) + { + int k = s.IndexOf("{\\", StringComparison.Ordinal); + while (k >= 0) + { + int l = s.IndexOf('}', k + 1); + if (l < k) + { + break; + } + + var assTags = s.Substring(k + 1, l - k - 1).Split('\\'); + var sb = new StringBuilder(); + foreach (var assTag in assTags) + { + if (assTag == "i1") + { + sb.Append(""); + } + else if (assTag == "i" || assTag == "i0") + { + sb.Append(""); + } + else if (assTag == "b1" || assTag == "b2" || assTag == "b3" || assTag == "b4") + { + sb.Append(""); + } + else if (assTag == "b" || assTag == "b0") + { + sb.Append(""); + } + } + s = s.Remove(k, l - k + 1); + s = s.Insert(k, sb.ToString()); + k = s.IndexOf("{\\", k, StringComparison.Ordinal); + } + return s; + } + + private static NikseBitmap Make3DTopBottom(MakeBitmapParameter parameter, NikseBitmap nbmp) + { + Bitmap singleBmp = nbmp.GetBitmap(); + Bitmap singleHalfBmp = ScaleToHalfHeight(singleBmp); + singleBmp.Dispose(); + var topBottomBmp = new Bitmap(parameter.ScreenWidth, parameter.ScreenHeight - parameter.BottomMargin); + int singleHeight = parameter.ScreenHeight / 2; + int leftM = (parameter.ScreenWidth / 2) - (singleHalfBmp.Width / 2); + + using (Graphics gTopBottom = Graphics.FromImage(topBottomBmp)) + { + gTopBottom.DrawImage(singleHalfBmp, leftM + parameter.Depth3D, singleHeight - singleHalfBmp.Height - parameter.BottomMargin); + gTopBottom.DrawImage(singleHalfBmp, leftM - parameter.Depth3D, parameter.ScreenHeight - parameter.BottomMargin - singleHalfBmp.Height); + } + nbmp = new NikseBitmap(topBottomBmp); + if (parameter.BackgroundColor == Color.Transparent) + { + nbmp.CropTop(2, Color.Transparent); + nbmp.CropTransparentSidesAndBottom(2, false); + } + else + { + nbmp.CropTop(_boxBorderSize, parameter.BackgroundColor); + nbmp.CropSidesAndBottom(_boxBorderSize, parameter.BackgroundColor, false); + } + return nbmp; + } + + private static void DrawShadowAndPath(MakeBitmapParameter parameter, Graphics g, GraphicsPath path) + { + if (parameter.ShadowWidth > 0) + { + var shadowAlpha = parameter.ShadowAlpha; + if (parameter.ShadowWidth > 1) + { + shadowAlpha = (int)Math.Round(shadowAlpha * 0.8); + } + + var shadowPath = (GraphicsPath)path.Clone(); + for (int k = 0; k < parameter.ShadowWidth; k++) + { + var translateMatrix = new Matrix(); + translateMatrix.Translate(1, 1); + shadowPath.Transform(translateMatrix); + + using (var p1 = new Pen(new SolidBrush(Color.FromArgb(shadowAlpha, parameter.ShadowColor)), parameter.BorderWidth)) + { + SetLineJoin(parameter.LineJoin, p1); + g.DrawPath(p1, shadowPath); + } + } + } + + if (parameter.BorderWidth > 0) + { + var p1 = new Pen(parameter.BorderColor, (float)(parameter.BorderWidth * 1.1)); + SetLineJoin(parameter.LineJoin, p1); + g.DrawPath(p1, path); + p1.Dispose(); + } + } + + private static void SetLineJoin(string lineJoin, Pen pen) + { + if (string.IsNullOrWhiteSpace(lineJoin)) + { + return; + } + + if (string.Compare(lineJoin, "Round", StringComparison.OrdinalIgnoreCase) == 0) + { + pen.LineJoin = LineJoin.Round; + } + else if (string.Compare(lineJoin, "Bevel", StringComparison.OrdinalIgnoreCase) == 0) + { + pen.LineJoin = LineJoin.Bevel; + } + else if (string.Compare(lineJoin, "Miter", StringComparison.OrdinalIgnoreCase) == 0) + { + pen.LineJoin = LineJoin.Miter; + } + else if (string.Compare(lineJoin, "MiterClipped", StringComparison.OrdinalIgnoreCase) == 0) + { + pen.LineJoin = LineJoin.MiterClipped; + } + } + + private static Bitmap ScaleToHalfWidth(Bitmap bmp) + { + int w = bmp.Width / 2; + var newImage = new Bitmap(w, bmp.Height); + using (var gr = Graphics.FromImage(newImage)) + { + gr.SmoothingMode = SmoothingMode.HighQuality; + gr.InterpolationMode = InterpolationMode.HighQualityBicubic; + gr.PixelOffsetMode = PixelOffsetMode.HighQuality; + gr.DrawImage(bmp, new Rectangle(0, 0, w, bmp.Height)); + } + return newImage; + } + + private static Bitmap ScaleToHalfHeight(Bitmap bmp) + { + int h = bmp.Height / 2; + var newImage = new Bitmap(bmp.Width, h); + using (var gr = Graphics.FromImage(newImage)) + { + gr.SmoothingMode = SmoothingMode.HighQuality; + gr.InterpolationMode = InterpolationMode.HighQualityBicubic; + gr.PixelOffsetMode = PixelOffsetMode.HighQuality; + gr.DrawImage(bmp, new Rectangle(0, 0, bmp.Width, h)); + } + return newImage; + } + + private bool _allowCustomBottomMargin; + + internal void Initialize(Subtitle subtitle, SubtitleFormat format, string exportType, string fileName, VideoInfo videoInfo, string videoFileName) + { + checkBoxFullFrameImage.Checked = false; + checkBoxFullFrameImage.Visible = false; + _exportType = exportType; + _fileName = fileName; + _format = format; + _formatName = _format != null ? _format.Name : string.Empty; + if (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat) + { + CalculateHeights(subtitle); + } + _videoFileName = videoFileName; + if (exportType == ExportFormats.BluraySup) + { + Text = "Blu-ray SUP"; + } + else if (exportType == ExportFormats.VobSub) + { + Text = "VobSub (sub/idx)"; + } + else if (exportType == ExportFormats.Fab) + { + Text = "FAB Image Script"; + } + else if (exportType == ExportFormats.ImageFrame) + { + Text = "Image per frame"; + } + else if (exportType == ExportFormats.Stl) + { + Text = "DVD Studio Pro STL"; + } + else if (exportType == ExportFormats.Fcp) + { + Text = "Final Cut Pro"; + } + else if (exportType == ExportFormats.Dost) + { + Text = ExportFormats.Dost; + } + else if (exportType == ExportFormats.Edl) + { + Text = ExportFormats.Edl; + } + else if (_exportType == ExportFormats.EdlClipName) + { + Text = "EDL/CLIPNAME"; + } + else if (exportType == ExportFormats.DCinemaInterop) + { + Text = "DCinema interop/png"; + } + else if (exportType == ExportFormats.DCinemaSmpte2014) + { + Text = "DCinema SMPTE 2014/png"; + } + else if (exportType == ExportFormats.Spumux) + { + Text = ExportFormats.Spumux; + } + else + { + Text = Configuration.Settings.Language.ExportPngXml.Title; + } + + if (_exportType == ExportFormats.VobSub && !string.IsNullOrEmpty(Configuration.Settings.Tools.ExportVobSubFontName)) + { + _subtitleFontName = Configuration.Settings.Tools.ExportVobSubFontName; + } + else if ((_exportType == ExportFormats.BluraySup || _exportType == ExportFormats.Dost) && !string.IsNullOrEmpty(Configuration.Settings.Tools.ExportBluRayFontName)) + { + _subtitleFontName = Configuration.Settings.Tools.ExportBluRayFontName; + } + else if (_exportType == ExportFormats.Fcp && !string.IsNullOrEmpty(Configuration.Settings.Tools.ExportFcpFontName)) + { + _subtitleFontName = Configuration.Settings.Tools.ExportFcpFontName; + } + else if (!string.IsNullOrEmpty(Configuration.Settings.Tools.ExportFontNameOther)) + { + _subtitleFontName = Configuration.Settings.Tools.ExportFontNameOther; + } + + if (_exportType == ExportFormats.VobSub && Configuration.Settings.Tools.ExportVobSubFontSize > 0) + { + _subtitleFontSize = Configuration.Settings.Tools.ExportVobSubFontSize; + } + else if ((_exportType == ExportFormats.BluraySup || _exportType == ExportFormats.Dost) && Configuration.Settings.Tools.ExportBluRayFontSize > 0) + { + _subtitleFontSize = Configuration.Settings.Tools.ExportBluRayFontSize; + } + else if (_exportType == ExportFormats.Fcp && Configuration.Settings.Tools.ExportFcpFontSize > 0) + { + _subtitleFontSize = Configuration.Settings.Tools.ExportFcpFontSize; + } + else if (Configuration.Settings.Tools.ExportLastFontSize > 0) + { + _subtitleFontSize = Configuration.Settings.Tools.ExportLastFontSize; + } + + if (_exportType == ExportFormats.Fcp) + { + comboBoxImageFormat.Items.Add("8-bit png"); + int i = 0; + foreach (string item in comboBoxImageFormat.Items) + { + if (item == Configuration.Settings.Tools.ExportFcpImageType) + { + comboBoxImageFormat.SelectedIndex = i; + break; + } + i++; + } + } + + if (_exportType == ExportFormats.VobSub) + { + comboBoxSubtitleFontSize.SelectedIndex = 7; + int i = 0; + foreach (string item in comboBoxSubtitleFontSize.Items) + { + if (item == Convert.ToInt32(_subtitleFontSize).ToString(CultureInfo.InvariantCulture)) + { + comboBoxSubtitleFontSize.SelectedIndex = i; + break; + } + i++; + } + checkBoxTransAntiAliase.Checked = Configuration.Settings.Tools.ExportVobAntiAliasingWithTransparency; + } + else if (_exportType == ExportFormats.BluraySup || _exportType == ExportFormats.Dost || _exportType == ExportFormats.Fcp) + { + comboBoxSubtitleFontSize.SelectedIndex = 16; + int i = 0; + foreach (string item in comboBoxSubtitleFontSize.Items) + { + if (item == Convert.ToInt32(_subtitleFontSize).ToString(CultureInfo.InvariantCulture)) + { + comboBoxSubtitleFontSize.SelectedIndex = i; + break; + } + i++; + } + } + else + { + comboBoxSubtitleFontSize.SelectedIndex = 16; + int i = 0; + foreach (string item in comboBoxSubtitleFontSize.Items) + { + if (item == Convert.ToInt32(_subtitleFontSize).ToString(CultureInfo.InvariantCulture)) + { + comboBoxSubtitleFontSize.SelectedIndex = i; + break; + } + i++; + } + } + + groupBoxImageSettings.Text = Configuration.Settings.Language.ExportPngXml.ImageSettings; + labelSubtitleFont.Text = Configuration.Settings.Language.ExportPngXml.FontFamily; + labelSubtitleFontSize.Text = Configuration.Settings.Language.ExportPngXml.FontSize; + labelResolution.Text = Configuration.Settings.Language.ExportPngXml.VideoResolution; + buttonColor.Text = Configuration.Settings.Language.ExportPngXml.FontColor; + checkBoxBold.Text = Configuration.Settings.Language.General.Bold; + checkBoxSimpleRender.Text = Configuration.Settings.Language.ExportPngXml.SimpleRendering; + checkBoxTransAntiAliase.Text = Configuration.Settings.Language.ExportPngXml.AntiAliasingWithTransparency; + labelResize.Text = Configuration.Settings.Language.General.Size; + normalToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.RemoveFormattingAll; + italicToolStripMenuItem.Text = Configuration.Settings.Language.General.Italic; + boxSingleLineToolStripMenuItem.Text = Configuration.Settings.Language.ExportPngXml.BoxSingleLine; + boxMultiLineToolStripMenuItem.Text = Configuration.Settings.Language.ExportPngXml.BoxMultiLine; + adjustTimeCodesToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.Synchronization.AdjustAllTimes; + adjustDisplayTimeToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.Tools.AdjustDisplayDuration; + + checkBoxFcpFullPathUrl.Text = Configuration.Settings.Language.ExportPngXml.FcpUseFullPathUrl; + checkBoxFcpFullPathUrl.Visible = exportType == ExportFormats.Fcp; + checkBoxFcpFullPathUrl.Checked = Configuration.Settings.Tools.ExportFcpFullPathUrl; + + + comboBox3D.Items.Clear(); + comboBox3D.Items.Add(Configuration.Settings.Language.General.None); + comboBox3D.Items.Add(Configuration.Settings.Language.ExportPngXml.SideBySide3D); + comboBox3D.Items.Add(Configuration.Settings.Language.ExportPngXml.HalfTopBottom3D); + comboBox3D.SelectedIndex = 0; + + labelDepth.Text = Configuration.Settings.Language.ExportPngXml.Depth; + + numericUpDownDepth3D.Left = labelDepth.Left + labelDepth.Width + 3; + + label3D.Text = Configuration.Settings.Language.ExportPngXml.Text3D; + + comboBox3D.Left = label3D.Left + label3D.Width + 3; + + buttonBorderColor.Text = Configuration.Settings.Language.ExportPngXml.BorderColor; + labelBorderWidth.Text = Configuration.Settings.Language.ExportPngXml.BorderStyle; + labelImageFormat.Text = Configuration.Settings.Language.ExportPngXml.ImageFormat; + checkBoxFullFrameImage.Text = Configuration.Settings.Language.ExportPngXml.FullFrameImage; + + buttonExport.Text = Configuration.Settings.Language.ExportPngXml.ExportAllLines; + buttonCancel.Text = Configuration.Settings.Language.General.Ok; + labelLanguage.Text = Configuration.Settings.Language.ChooseLanguage.Language; + labelFrameRate.Text = Configuration.Settings.Language.General.FrameRate; + labelHorizontalAlign.Text = Configuration.Settings.Language.ExportPngXml.Align; + labelBottomMargin.Text = Configuration.Settings.Language.ExportPngXml.BottomMargin; + labelLeftRightMargin.Text = Configuration.Settings.Language.ExportPngXml.LeftRightMargin; + + comboBoxHAlign.Items.Clear(); + comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.Left); + comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.Center); + comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.Right); + comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.CenterLeftJustify); + comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.CenterTopJustify); + comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.CenterRightJustify); + comboBoxHAlign.Items.Add(Configuration.Settings.Language.ExportPngXml.CenterLeftJustifyDialogs); + + buttonShadowColor.Text = Configuration.Settings.Language.ExportPngXml.ShadowColor; + labelShadowWidth.Text = Configuration.Settings.Language.ExportPngXml.ShadowWidth; + labelShadowTransparency.Text = Configuration.Settings.Language.ExportPngXml.Transparency; + labelLineHeight.Text = Configuration.Settings.Language.ExportPngXml.LineHeight; + + linkLabelPreview.Text = Configuration.Settings.Language.General.Preview; + linkLabelPreview.Left = groupBoxExportImage.Width - linkLabelPreview.Width - 3; + + saveImageAsToolStripMenuItem.Text = Configuration.Settings.Language.ExportPngXml.SaveImageAs; + + SubtitleListView1InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + UiUtil.InitializeSubtitleFont(subtitleListView1); + SubtitleListView1AutoSizeAllColumns(); + + _subtitle = new Subtitle(subtitle); + + panelColor.BackColor = _subtitleColor; + panelBorderColor.BackColor = _borderColor; + InitBorderStyle(); + comboBoxHAlign.SelectedIndex = 1; + comboBoxResolution.SelectedIndex = 3; + + if (Configuration.Settings.Tools.ExportLastShadowTransparency <= numericUpDownShadowTransparency.Maximum && Configuration.Settings.Tools.ExportLastShadowTransparency > 0) + { + numericUpDownShadowTransparency.Value = Configuration.Settings.Tools.ExportLastShadowTransparency; + } + + if ((_exportType == ExportFormats.BluraySup || _exportType == ExportFormats.Dost) && !string.IsNullOrEmpty(Configuration.Settings.Tools.ExportBluRayVideoResolution)) + { + SetResolution(Configuration.Settings.Tools.ExportBluRayVideoResolution); + } + + _language = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(subtitle); + if (exportType == ExportFormats.VobSub) + { + comboBoxBorderWidth.SelectedIndex = 6; + if (_exportType == ExportFormats.VobSub && !string.IsNullOrEmpty(Configuration.Settings.Tools.ExportVobSubVideoResolution)) + { + SetResolution(Configuration.Settings.Tools.ExportVobSubVideoResolution); + } + else + { + comboBoxResolution.SelectedIndex = 8; + } + + labelLanguage.Visible = true; + comboBoxLanguage.Visible = true; + comboBoxLanguage.Items.Clear(); + if (_language == null) + { + _language = Configuration.Settings.Tools.ExportVobSubLanguage; + } + + int index = -1; + foreach (var language in DvdSubtitleLanguage.CompliantLanguages) + { + int i = comboBoxLanguage.Items.Add(language); + if (language.Code == _language || index < 0 && language.Code == "en") + { + index = i; + } + } + comboBoxLanguage.SelectedIndex = index; + } + + bool showImageFormat = exportType == ExportFormats.Fab || exportType == ExportFormats.ImageFrame || exportType == ExportFormats.Stl || exportType == ExportFormats.Fcp || exportType == ExportFormats.BdnXml; + if (exportType == ExportFormats.Fab || exportType == ExportFormats.BluraySup || exportType == ExportFormats.Fcp) + { + checkBoxFullFrameImage.Visible = exportType == ExportFormats.Fab || exportType == ExportFormats.BluraySup || exportType == ExportFormats.Fcp; + } + else + { + checkBoxFullFrameImage.Checked = false; + } + + comboBoxImageFormat.Visible = showImageFormat; + labelImageFormat.Visible = showImageFormat; + labelFrameRate.Visible = exportType == ExportFormats.BdnXml || exportType == ExportFormats.BluraySup || exportType == ExportFormats.Dost || exportType == ExportFormats.ImageFrame; + comboBoxFrameRate.Visible = exportType == ExportFormats.BdnXml || exportType == ExportFormats.BluraySup || exportType == ExportFormats.Dost || exportType == ExportFormats.ImageFrame || exportType == ExportFormats.Fab || exportType == ExportFormats.Fcp; + checkBoxTransAntiAliase.Visible = exportType == ExportFormats.VobSub; + if (exportType == ExportFormats.BdnXml) + { + labelFrameRate.Top = labelLanguage.Top; + comboBoxFrameRate.Top = comboBoxLanguage.Top; + comboBoxFrameRate.Items.Add("23.976"); + comboBoxFrameRate.Items.Add("24"); + comboBoxFrameRate.Items.Add("25"); + comboBoxFrameRate.Items.Add("29.97"); + comboBoxFrameRate.Items.Add("30"); + comboBoxFrameRate.Items.Add("50"); + comboBoxFrameRate.Items.Add("59.94"); + comboBoxFrameRate.Items.Add("60"); + comboBoxFrameRate.SelectedIndex = 2; + + comboBoxImageFormat.Items.Clear(); + comboBoxImageFormat.Items.Add("Png 32-bit"); + comboBoxImageFormat.Items.Add("Png 8-bit"); + if (comboBoxImageFormat.Items[1].ToString() == Configuration.Settings.Tools.ExportBdnXmlImageType) + { + comboBoxImageFormat.SelectedIndex = 1; + } + else + { + comboBoxImageFormat.SelectedIndex = 0; + } + } + else if (exportType == ExportFormats.Dost) + { + labelFrameRate.Top = labelLanguage.Top; + comboBoxFrameRate.Top = comboBoxLanguage.Top; + comboBoxFrameRate.Items.Add("23.98"); + comboBoxFrameRate.Items.Add("24"); + comboBoxFrameRate.Items.Add("25"); + comboBoxFrameRate.Items.Add("29.97"); + comboBoxFrameRate.Items.Add("30"); + comboBoxFrameRate.Items.Add("59.94"); + comboBoxFrameRate.Items.Add("60"); + comboBoxFrameRate.SelectedIndex = 2; + } + else if (exportType == ExportFormats.ImageFrame) + { + labelFrameRate.Top = labelLanguage.Top; + comboBoxFrameRate.Top = comboBoxLanguage.Top; + comboBoxFrameRate.Items.Add("23.976"); + comboBoxFrameRate.Items.Add("24"); + comboBoxFrameRate.Items.Add("25"); + comboBoxFrameRate.Items.Add("29.97"); + comboBoxFrameRate.Items.Add("30"); + comboBoxFrameRate.Items.Add("50"); + comboBoxFrameRate.Items.Add("59.94"); + comboBoxFrameRate.Items.Add("60"); + comboBoxFrameRate.SelectedIndex = 2; + } + else if (exportType == ExportFormats.BluraySup) + { + labelFrameRate.Top = labelLanguage.Top; + comboBoxFrameRate.Top = comboBoxLanguage.Top; + comboBoxFrameRate.Items.Add("23.976"); + comboBoxFrameRate.Items.Add("24"); + comboBoxFrameRate.Items.Add("25"); + comboBoxFrameRate.Items.Add("29.97"); + comboBoxFrameRate.Items.Add("30"); + comboBoxFrameRate.Items.Add("50"); + comboBoxFrameRate.Items.Add("59.94"); + comboBoxFrameRate.Items.Add("60"); + comboBoxFrameRate.SelectedIndex = 1; + comboBoxFrameRate.DropDownStyle = ComboBoxStyle.DropDownList; + + checkBoxFullFrameImage.Top = comboBoxImageFormat.Top + 2; + panelFullFrameBackground.Top = checkBoxFullFrameImage.Top; + } + else if (exportType == ExportFormats.Fab) + { + labelFrameRate.Visible = true; + comboBoxFrameRate.Items.Add("23.976"); + comboBoxFrameRate.Items.Add("24"); + comboBoxFrameRate.Items.Add("25"); + comboBoxFrameRate.Items.Add("29.97"); + comboBoxFrameRate.Items.Add("30"); + comboBoxFrameRate.Items.Add("50"); + comboBoxFrameRate.Items.Add("59.94"); + comboBoxFrameRate.Items.Add("60"); + comboBoxFrameRate.SelectedIndex = 1; + comboBoxFrameRate.DropDownStyle = ComboBoxStyle.DropDownList; + } + else if (exportType == ExportFormats.Fcp) + { + labelFrameRate.Visible = true; + comboBoxFrameRate.Items.Add("23.976"); + comboBoxFrameRate.Items.Add("24"); + comboBoxFrameRate.Items.Add("25"); + comboBoxFrameRate.Items.Add("29.97"); + comboBoxFrameRate.Items.Add("30"); + comboBoxFrameRate.Items.Add("50"); + comboBoxFrameRate.Items.Add("59.94"); + comboBoxFrameRate.Items.Add("60"); + comboBoxFrameRate.SelectedIndex = 2; + comboBoxFrameRate.DropDownStyle = ComboBoxStyle.DropDownList; + + checkBoxFullFrameImage.Top = comboBoxFrameRate.Top + comboBoxFrameRate.Height + 5; + panelFullFrameBackground.Top = checkBoxFullFrameImage.Top; + } + if (comboBoxFrameRate.Items.Count >= 2) + { + SetLastFrameRate(Configuration.Settings.Tools.ExportLastFrameRate); + } + checkBoxFullFrameImage.Checked = Configuration.Settings.Tools.ExportFullFrame; + panelShadowColor.BackColor = Configuration.Settings.Tools.ExportShadowColor; + + comboBoxBottomMarginUnit.SelectedIndex = Configuration.Settings.Tools.ExportBottomMarginUnit == "%" ? 0 : 1; + comboBoxLeftRightMarginUnit.SelectedIndex = Configuration.Settings.Tools.ExportLeftRightMarginUnit == "%" ? 0 : 1; + + _allowCustomBottomMargin = _exportType == ExportFormats.BluraySup || _exportType == ExportFormats.VobSub || _exportType == ExportFormats.ImageFrame || _exportType == ExportFormats.BdnXml || _exportType == ExportFormats.Dost || _exportType == ExportFormats.Fab || _exportType == ExportFormats.Edl || _exportType == ExportFormats.EdlClipName; + if (_allowCustomBottomMargin) + { + comboBoxBottomMarginUnit.Visible = true; + comboBoxBottomMargin.Visible = true; + labelBottomMargin.Visible = true; + + comboBoxLeftRightMarginUnit.Visible = true; + comboBoxLeftRightMargin.Visible = true; + labelLeftRightMargin.Visible = true; + comboBoxBottomMarginUnit_SelectedIndexChanged(null, null); + } + else + { + comboBoxBottomMarginUnit.Visible = false; + comboBoxBottomMargin.Visible = false; + labelBottomMargin.Visible = false; + + comboBoxLeftRightMarginUnit.Visible = false; + comboBoxLeftRightMargin.Visible = false; + labelLeftRightMargin.Visible = false; + } + + checkBoxSkipEmptyFrameAtStart.Visible = exportType == ExportFormats.ImageFrame; + + foreach (var x in FontFamily.Families) + { + if (x.IsStyleAvailable(FontStyle.Regular) || x.IsStyleAvailable(FontStyle.Bold)) + { + comboBoxSubtitleFont.Items.Add(x.Name); + if (x.Name.Equals(_subtitleFontName, StringComparison.OrdinalIgnoreCase)) + { + comboBoxSubtitleFont.SelectedIndex = comboBoxSubtitleFont.Items.Count - 1; + } + } + } + if (comboBoxSubtitleFont.SelectedIndex == -1) + { + comboBoxSubtitleFont.SelectedIndex = 0; // take first font if default font was not found (e.g. linux) + } + + if (videoInfo != null && videoInfo.Height > 0 && videoInfo.Width > 0) + { + comboBoxResolution.Items[comboBoxResolution.Items.Count - 1] = videoInfo.Width + "x" + videoInfo.Height; + comboBoxResolution.SelectedIndex = comboBoxResolution.Items.Count - 1; + } + + if (_lineHeights != null && _lineHeights.Count > 0) + { + numericUpDownLineSpacing.Value = _lineHeights.First().Value; + } + else if (Math.Abs(_subtitleFontSize - Configuration.Settings.Tools.ExportLastFontSize) < 0.01 && Configuration.Settings.Tools.ExportLastLineHeight >= numericUpDownLineSpacing.Minimum && + Configuration.Settings.Tools.ExportLastLineHeight <= numericUpDownLineSpacing.Maximum && Configuration.Settings.Tools.ExportLastLineHeight > 0) + { + numericUpDownLineSpacing.Value = Configuration.Settings.Tools.ExportLastLineHeight; + } + else + { + var lineHeight = (int)Math.Round(GetFontHeight() * 0.64f); + if (lineHeight >= numericUpDownLineSpacing.Minimum && + lineHeight <= numericUpDownLineSpacing.Maximum) + { + numericUpDownLineSpacing.Value = lineHeight; + } + } + + if (Configuration.Settings.Tools.ExportLastBorderWidth >= 0 && Configuration.Settings.Tools.ExportLastBorderWidth < comboBoxBorderWidth.Items.Count) + { + try + { + comboBoxBorderWidth.SelectedIndex = Configuration.Settings.Tools.ExportLastBorderWidth; + } + catch + { + // ignore error + } + } + _borderWidth = GetBorderWidth(); + checkBoxBold.Checked = Configuration.Settings.Tools.ExportLastFontBold; + _subtitleFontBold = Configuration.Settings.Tools.ExportLastFontBold; + + if (Configuration.Settings.Tools.Export3DType >= 0 && Configuration.Settings.Tools.Export3DType < comboBox3D.Items.Count) + { + comboBox3D.SelectedIndex = Configuration.Settings.Tools.Export3DType; + } + + if (Configuration.Settings.Tools.Export3DDepth >= numericUpDownDepth3D.Minimum && Configuration.Settings.Tools.Export3DDepth <= numericUpDownDepth3D.Maximum) + { + numericUpDownDepth3D.Value = Configuration.Settings.Tools.Export3DDepth; + } + + if (Configuration.Settings.Tools.ExportHorizontalAlignment >= 0 && Configuration.Settings.Tools.ExportHorizontalAlignment < comboBoxHAlign.Items.Count) + { + comboBoxHAlign.SelectedIndex = Configuration.Settings.Tools.ExportHorizontalAlignment; + } + + if (exportType == ExportFormats.DCinemaInterop || exportType == ExportFormats.DCinemaSmpte2014) + { + comboBox3D.Visible = false; + numericUpDownDepth3D.Enabled = true; + labelDepth.Enabled = true; + labelDepth.Text = Configuration.Settings.Language.DCinemaProperties.ZPosition; + } + + if (_exportType == ExportFormats.Fcp) + { + comboBoxResolution.Items.Clear(); + comboBoxResolution.Items.Add("NTSC-601"); + comboBoxResolution.Items.Add("PAL-601"); + comboBoxResolution.Items.Add("square"); + comboBoxResolution.Items.Add("DVCPROHD-720P"); + comboBoxResolution.Items.Add("HD-(960x720)"); + comboBoxResolution.Items.Add("DVCPROHD-1080i60"); + comboBoxResolution.Items.Add("HD-(1280x1080)"); + comboBoxResolution.Items.Add("FullHD 1920x1080"); + comboBoxResolution.Items.Add("DVCPROHD-1080i50"); + comboBoxResolution.Items.Add("HD-(1440x1080)"); + comboBoxResolution.SelectedIndex = 7; // FullHD + if (_exportType == ExportFormats.Fcp && !string.IsNullOrEmpty(Configuration.Settings.Tools.ExportFcpVideoResolution)) + { + SetResolution(Configuration.Settings.Tools.ExportFcpVideoResolution); + } + + buttonCustomResolution.Visible = true; // we still allow for custom resolutions + + labelLanguage.Text = "NTSC/PAL"; + comboBoxLanguage.Items.Clear(); + comboBoxLanguage.Items.Add("PAL"); + comboBoxLanguage.Items.Add("NTSC"); + comboBoxLanguage.SelectedIndex = 0; + comboBoxLanguage.Visible = true; + labelLanguage.Visible = true; + if (Configuration.Settings.Tools.ExportFcpPalNtsc == "NTSC") + { + comboBoxLanguage.SelectedIndex = 1; + } + } + + comboBoxShadowWidth.SelectedIndex = 0; + bool shadowVisible = _exportType == ExportFormats.BdnXml || _exportType == ExportFormats.BluraySup || _exportType == ExportFormats.Dost || _exportType == ExportFormats.ImageFrame || _exportType == ExportFormats.Fcp || _exportType == ExportFormats.DCinemaInterop || exportType == ExportFormats.DCinemaSmpte2014 || _exportType == ExportFormats.Edl || _exportType == ExportFormats.EdlClipName; + labelShadowWidth.Visible = shadowVisible; + buttonShadowColor.Visible = shadowVisible; + comboBoxShadowWidth.Visible = shadowVisible; + if (shadowVisible && Configuration.Settings.Tools.ExportBluRayShadow < comboBoxShadowWidth.Items.Count) + { + comboBoxShadowWidth.SelectedIndex = Configuration.Settings.Tools.ExportBluRayShadow; + } + + panelShadowColor.Visible = shadowVisible; + labelShadowTransparency.Visible = shadowVisible; + numericUpDownShadowTransparency.Visible = shadowVisible; + + + if (checkBoxSimpleRender.Enabled) + { + checkBoxSimpleRender.Checked = Configuration.Settings.Tools.ExportVobSubSimpleRendering || _language == "ar"; + } + + if (exportType == ExportFormats.BluraySup || exportType == ExportFormats.VobSub || exportType == ExportFormats.BdnXml) + { + subtitleListView1.CheckBoxes = true; + subtitleListView1.Columns.Insert(0, Configuration.Settings.Language.ExportPngXml.Forced); + SubtitleListView1Fill(_subtitle); + if (_vobSubOcr != null) + { + for (int index = 0; index < _subtitle.Paragraphs.Count; index++) + { + if (_vobSubOcr.GetIsForced(index)) + { + subtitleListView1.Items[index].Checked = true; + } + } + } + + SubtitleListView1SelectIndexAndEnsureVisible(0); + } + else + { + SubtitleListView1Fill(_subtitle); + SubtitleListView1SelectIndexAndEnsureVisible(0); + } + } + + private float GetFontHeight() + { + var mbp = new MakeBitmapParameter + { + SubtitleFontName = _subtitleFontName, + SubtitleFontSize = float.Parse(comboBoxSubtitleFontSize.SelectedItem.ToString()), + SubtitleFontBold = _subtitleFontBold + }; + var fontSize = (float)TextDraw.GetFontSize(mbp.SubtitleFontSize); + using (var font = GetFont(mbp, fontSize)) + using (var bmp = new Bitmap(100, 100)) + using (var g = Graphics.FromImage(bmp)) + { + var textSize = g.MeasureString("Hj!", font); + return textSize.Height; + } + } + + private void CalculateHeights(Subtitle subtitle) + { + foreach (var paragraph in subtitle.Paragraphs) + { + var styleName = paragraph.Extra; + if (!string.IsNullOrEmpty(paragraph.Extra) && !_lineHeights.ContainsKey(styleName)) + { + var style = AdvancedSubStationAlpha.GetSsaStyle(paragraph.Extra, subtitle.Header); + using (var bmp = new Bitmap(100, 100)) + { + using (var g = Graphics.FromImage(bmp)) + { + var mbp = new MakeBitmapParameter + { + SubtitleFontName = style.FontName, + SubtitleFontSize = style.FontSize, + SubtitleFontBold = style.Bold + }; + var fontSize = (float)TextDraw.GetFontSize(mbp.SubtitleFontSize); + Font font = GetFont(mbp, fontSize); + SizeF textSize = g.MeasureString("Hj!", font); + int lineHeight = (int)Math.Round(textSize.Height * 0.64f); + if (fontSize < 30) + { + lineHeight = (int)Math.Round(textSize.Height * 0.69f); + } + + _lineHeights.Add(styleName, lineHeight); + } + } + } + } + } + + private void InitBorderStyle() + { + comboBoxBorderWidth.Items.Clear(); + comboBoxBorderWidth.Items.Add(Configuration.Settings.Language.ExportPngXml.BorderStyleBoxForEachLine); + comboBoxBorderWidth.Items.Add(Configuration.Settings.Language.ExportPngXml.BorderStyleOneBox); + for (int i = 0; i < 16; i++) + { + comboBoxBorderWidth.Items.Add(string.Format(Configuration.Settings.Language.ExportPngXml.BorderStyleNormalWidthX, i)); + } + comboBoxBorderWidth.SelectedIndex = 4; + } + + private void SetLastFrameRate(double lastFrameRate) + { + for (int i = 0; i < comboBoxFrameRate.Items.Count; i++) + { + if (double.TryParse(comboBoxFrameRate.Items[i].ToString().Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var d)) + { + if (Math.Abs(lastFrameRate - d) < 0.01) + { + comboBoxFrameRate.SelectedIndex = i; + return; + } + } + } + } + + internal void SetResolution(Point resolution) + { + comboBoxResolution.Items.Add(resolution.X + "x" + resolution.Y); + comboBoxResolution.SelectedIndex = comboBoxResolution.Items.Count - 1; + } + + internal void InitializeFromVobSubOcr(Subtitle subtitle, SubtitleFormat format, string exportType, string fileName, IBinaryParagraphList vobSubOcr, string languageString) + { + _vobSubOcr = vobSubOcr; + if (_vobSubOcr != null && exportType != ExportFormats.VobSub) + { + comboBoxResizePercentage.Items.Clear(); + for (int i = 50; i < 400; i++) + { + comboBoxResizePercentage.Items.Add(i + "%"); + } + comboBoxResizePercentage.Items.Add("500%"); + comboBoxResizePercentage.SelectedIndex = 50; + comboBoxResizePercentage.Visible = true; + labelResize.Visible = true; + labelResize.Left = buttonColor.Left; + labelResize.Top = buttonColor.Top; + comboBoxResizePercentage.Left = labelResize.Left + labelResize.Width + 5; + comboBoxResizePercentage.Top = labelResize.Top - 4; + } + else + { + comboBoxResizePercentage.Visible = false; + labelResize.Visible = false; + } + + Initialize(subtitle, format, exportType, fileName, null, _videoFileName); + + //set language + if (!string.IsNullOrEmpty(languageString)) + { + if (languageString.Contains('(') && languageString[0] != '(') + { + languageString = languageString.Substring(0, languageString.IndexOf('(') - 1).Trim(); + } + + for (int i = 0; i < comboBoxLanguage.Items.Count; i++) + { + string l = comboBoxLanguage.Items[i].ToString(); + if (l == languageString) + { + comboBoxLanguage.SelectedIndex = i; + break; + } + } + } + + //Disable options not available when exporting existing images + comboBoxSubtitleFont.Enabled = false; + comboBoxSubtitleFontSize.Enabled = false; + + buttonColor.Visible = false; + panelColor.Visible = false; + checkBoxBold.Visible = false; + checkBoxSimpleRender.Visible = false; + comboBox3D.Enabled = false; + numericUpDownDepth3D.Enabled = false; + + buttonBorderColor.Visible = false; + panelBorderColor.Visible = false; + labelBorderWidth.Visible = false; + comboBoxBorderWidth.Visible = false; + + buttonShadowColor.Visible = false; + panelShadowColor.Visible = false; + labelShadowWidth.Visible = false; + comboBoxShadowWidth.Visible = false; + labelShadowTransparency.Visible = false; + numericUpDownShadowTransparency.Visible = false; + labelLineHeight.Visible = false; + numericUpDownLineSpacing.Visible = false; + } + + private void subtitleListView1_SelectedIndexChanged(object sender, EventArgs e) + { + if (_isLoading) + { + return; + } + + _previewTimer.Stop(); + UpdateLineSpacing(); + _previewTimer.Start(); + } + + internal int GetBottomMarginInPixels(Paragraph p) + { + if (!_allowCustomBottomMargin) + { + return 20; + } + + if (!string.IsNullOrEmpty(p?.Extra) && (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat)) + { + var style = AdvancedSubStationAlpha.GetSsaStyle(p.Extra, _subtitle.Header); + return style.MarginVertical; + } + + var s = comboBoxBottomMargin.Text; + if (comboBoxBottomMarginUnit.SelectedIndex == 0) // % + { + GetResolution(out _, out var height); + return (int)Math.Round(int.Parse(s.TrimEnd('%')) / 100.0 * height); + } + + // pixels + return int.Parse(s); + } + + private int GetLeftMarginInPixels(Paragraph p) + { + if (!string.IsNullOrEmpty(p?.Extra) && (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat)) + { + var style = AdvancedSubStationAlpha.GetSsaStyle(p.Extra, _subtitle.Header); + return style.MarginLeft; + } + + var s = comboBoxLeftRightMargin.Text; + if (comboBoxLeftRightMarginUnit.SelectedIndex == 0) // % + { + GetResolution(out var width, out _); + return (int)Math.Round(int.Parse(s) / 100.0 * width); + } + + // pixels + return int.Parse(s); + } + + private int GetRightMarginInPixels(Paragraph p) + { + if (!string.IsNullOrEmpty(p?.Extra) && (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat)) + { + var style = AdvancedSubStationAlpha.GetSsaStyle(p.Extra, _subtitle.Header); + return style.MarginRight; + } + return GetLeftMarginInPixels(p); + } + + + + private void GeneratePreview() + { + SetupImageParameters(); + if (subtitleListView1.SelectedItems.Count > 0) + { + var p = _subtitle.GetParagraphOrDefault(subtitleListView1.SelectedItems[0].Index); + if (p == null) + { + return; + } + var bmp = GenerateImageFromTextWithStyle(p, out var mbp); + if (checkBoxFullFrameImage.Checked) + { + var nbmp = new NikseBitmap(bmp); + nbmp.ReplaceTransparentWith(panelFullFrameBackground.BackColor); + bmp.Dispose(); + bmp = nbmp.GetBitmap(); + } + else + { + groupBoxExportImage.BackColor = DefaultBackColor; + } + pictureBox1.Image = bmp; + + int w = groupBoxExportImage.Width - 4; + pictureBox1.Width = bmp.Width; + pictureBox1.Height = bmp.Height; + pictureBox1.Top = groupBoxExportImage.Height - bmp.Height - GetBottomMarginInPixels(p); + pictureBox1.Left = (w - bmp.Width) / 2; + var alignment = GetAlignmentFromParagraph(mbp, _format, _subtitle); + + // fix alignment from UI + if (comboBoxHAlign.Visible && alignment == ContentAlignment.BottomCenter && _format.GetType() != typeof(AdvancedSubStationAlpha) && _format.GetType() != typeof(SubStationAlpha)) + { + if (comboBoxHAlign.SelectedIndex == 0) + { + alignment = ContentAlignment.BottomLeft; + } + else if (comboBoxHAlign.SelectedIndex == 2) + { + alignment = ContentAlignment.BottomRight; + } + } + + if (comboBoxHAlign.Visible) + { + if (comboBoxLeftRightMargin.Visible) + { + if (alignment == ContentAlignment.BottomLeft || alignment == ContentAlignment.MiddleLeft || alignment == ContentAlignment.TopLeft) + { + pictureBox1.Left = GetLeftMarginInPixels(p); + } + else if (alignment == ContentAlignment.BottomRight || alignment == ContentAlignment.MiddleRight || alignment == ContentAlignment.TopRight) + { + pictureBox1.Left = w - bmp.Width - GetRightMarginInPixels(p); + } + } + + if (alignment == ContentAlignment.MiddleLeft || alignment == ContentAlignment.MiddleCenter || alignment == ContentAlignment.MiddleRight) + { + pictureBox1.Top = (groupBoxExportImage.Height - 4 - bmp.Height) / 2; + } + else if (_allowCustomBottomMargin && alignment == ContentAlignment.TopLeft || alignment == ContentAlignment.TopCenter || alignment == ContentAlignment.TopRight) + { + pictureBox1.Top = GetBottomMarginInPixels(p); + } + } + if (bmp.Width > groupBoxExportImage.Width + 20 || bmp.Height > groupBoxExportImage.Height + 20) + { + pictureBox1.Left = 5; + pictureBox1.Top = 20; + pictureBox1.Width = groupBoxExportImage.Width - 10; + pictureBox1.Height = groupBoxExportImage.Height - 30; + pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; + } + else + { + pictureBox1.SizeMode = PictureBoxSizeMode.Normal; + } + groupBoxExportImage.Text = $"{bmp.Width}x{bmp.Height}"; + if (!string.IsNullOrEmpty(mbp.Error)) + { + groupBoxExportImage.BackColor = Color.Red; + groupBoxExportImage.Text = groupBoxExportImage.Text + " - " + mbp.Error; + } + else + { + if (checkBoxFullFrameImage.Checked) + { + groupBoxExportImage.BackColor = panelFullFrameBackground.BackColor; + } + else + { + groupBoxExportImage.BackColor = groupBoxImageSettings.BackColor; + } + } + } + } + + private void buttonColor_Click(object sender, EventArgs e) + { + bool showAlpha = _exportType == ExportFormats.Fab || _exportType == ExportFormats.BdnXml; + using (var colorChooser = new ColorChooser { Color = panelColor.BackColor, ShowAlpha = showAlpha }) + { + if (colorChooser.ShowDialog() == DialogResult.OK) + { + panelColor.BackColor = colorChooser.Color; + subtitleListView1_SelectedIndexChanged(null, null); + } + } + } + + private void panelColor_MouseClick(object sender, MouseEventArgs e) + { + buttonColor_Click(null, null); + } + + private void buttonBorderColor_Click(object sender, EventArgs e) + { + using (var colorChooser = new ColorChooser { Color = panelBorderColor.BackColor }) + { + if (colorChooser.ShowDialog() == DialogResult.OK) + { + panelBorderColor.BackColor = colorChooser.Color; + subtitleListView1_SelectedIndexChanged(null, null); + } + } + } + + private void panelBorderColor_MouseClick(object sender, MouseEventArgs e) + { + buttonBorderColor_Click(null, null); + } + + private void comboBoxSubtitleFont_SelectedValueChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void comboBoxSubtitleFontSize_SelectedIndexChanged(object sender, EventArgs e) + { + if (_isLoading) + { + return; + } + + if (_formatName != AdvancedSubStationAlpha.NameOfFormat && _formatName != SubStationAlpha.NameOfFormat && + comboBoxSubtitleFontSize.Enabled) + { + var lineHeight = (int)Math.Round(GetFontHeight() * 0.64f); + if (lineHeight >= numericUpDownLineSpacing.Minimum && + lineHeight <= numericUpDownLineSpacing.Maximum) + { + numericUpDownLineSpacing.Value = lineHeight; + } + } + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void UpdateLineSpacing() + { + var style = string.Empty; + if (subtitleListView1.SelectedIndices.Count > 0) + { + style = GetStyleName(_subtitle.Paragraphs[subtitleListView1.SelectedItems[0].Index]); + if (!string.IsNullOrEmpty(style) && _lineHeights.ContainsKey(style)) + { + numericUpDownLineSpacing.Value = _lineHeights[style]; + } + } + labelLineHeightStyle.Text = style; + } + + private void comboBoxBorderWidth_SelectedIndexChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void checkBoxAntiAlias_CheckedChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void ExportPngXml_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#export"); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.G && subtitleListView1.Items.Count > 1) + { + using (var goToLine = new GoToLine()) + { + goToLine.Initialize(1, subtitleListView1.Items.Count); + if (goToLine.ShowDialog(this) == DialogResult.OK) + { + subtitleListView1.Items[goToLine.LineNumber - 1].Selected = true; + subtitleListView1.Items[goToLine.LineNumber - 1].EnsureVisible(); + subtitleListView1.Items[goToLine.LineNumber - 1].Focused = true; + } + } + } + } + + private void ExportPngXml_Shown(object sender, EventArgs e) + { + _isLoading = false; + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void comboBoxHAlign_SelectedIndexChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void checkBoxBold_CheckedChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void buttonCustomResolution_Click(object sender, EventArgs e) + { + using (var cr = new ChooseResolution()) + { + if (cr.ShowDialog(this) == DialogResult.OK) + { + comboBoxResolution.Items[comboBoxResolution.Items.Count - 1] = cr.VideoWidth + "x" + cr.VideoHeight; + comboBoxResolution.SelectedIndex = comboBoxResolution.Items.Count - 1; + } + } + } + + private void ExportPngXml_ResizeEnd(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + subtitleListView1.Columns[subtitleListView1.Columns.Count - 1].Width = -2; + } + + private void comboBoxBottomMargin_SelectedIndexChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void comboBoxResolution_SelectedIndexChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void ExportPngXml_SizeChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + subtitleListView1.Columns[subtitleListView1.Columns.Count - 1].Width = -2; + } + + private void ExportPngXml_FormClosing(object sender, FormClosingEventArgs e) + { + GetResolution(out var width, out var height); + string res = $"{width}x{height}"; + + if (_exportType == ExportFormats.VobSub) + { + Configuration.Settings.Tools.ExportVobSubFontName = _subtitleFontName; + Configuration.Settings.Tools.ExportVobSubFontSize = (int)_subtitleFontSize; + Configuration.Settings.Tools.ExportVobSubVideoResolution = res; + Configuration.Settings.Tools.ExportVobSubLanguage = comboBoxLanguage.Text; + Configuration.Settings.Tools.ExportVobAntiAliasingWithTransparency = checkBoxTransAntiAliase.Checked; + } + else if (_exportType == ExportFormats.BluraySup || _exportType == ExportFormats.Dost) + { + Configuration.Settings.Tools.ExportBluRayFontName = _subtitleFontName; + Configuration.Settings.Tools.ExportBluRayFontSize = (int)_subtitleFontSize; + Configuration.Settings.Tools.ExportBluRayVideoResolution = res; + } + else if (_exportType == ExportFormats.BdnXml || _exportType == ExportFormats.Fcp) + { + Configuration.Settings.Tools.ExportBdnXmlImageType = comboBoxImageFormat.SelectedItem.ToString(); + } + if (_exportType == ExportFormats.Fcp) + { + Configuration.Settings.Tools.ExportFcpFontName = _subtitleFontName; + Configuration.Settings.Tools.ExportFcpFontSize = (int)_subtitleFontSize; + if (comboBoxImageFormat.SelectedItem != null) + { + Configuration.Settings.Tools.ExportFcpImageType = comboBoxImageFormat.SelectedItem.ToString(); + } + + Configuration.Settings.Tools.ExportFcpVideoResolution = res; + Configuration.Settings.Tools.ExportFcpPalNtsc = comboBoxLanguage.SelectedIndex == 0 ? "PAL" : "NTSC"; + } + Configuration.Settings.Tools.ExportFcpFullPathUrl = checkBoxFcpFullPathUrl.Checked; + Configuration.Settings.Tools.ExportLastShadowTransparency = (int)numericUpDownShadowTransparency.Value; + Configuration.Settings.Tools.ExportLastFrameRate = FrameRate; + Configuration.Settings.Tools.ExportFullFrame = checkBoxFullFrameImage.Checked; + Configuration.Settings.Tools.ExportShadowColor = panelShadowColor.BackColor; + Configuration.Settings.Tools.ExportFontColor = _subtitleColor; + Configuration.Settings.Tools.ExportBorderColor = _borderColor; + + if (checkBoxSimpleRender.Enabled) + { + Configuration.Settings.Tools.ExportVobSubSimpleRendering = checkBoxSimpleRender.Checked; + } + + if (_exportType == ExportFormats.BluraySup) + { + if (comboBoxBottomMarginUnit.SelectedIndex == 0) // % + { + Configuration.Settings.Tools.ExportBluRayBottomMarginPercent = comboBoxBottomMargin.SelectedIndex; + } + else // pixels + { + Configuration.Settings.Tools.ExportBluRayBottomMarginPixels = comboBoxBottomMargin.SelectedIndex; + } + } + else if (_allowCustomBottomMargin) + { + if (comboBoxBottomMarginUnit.SelectedIndex == 0) // % + { + Configuration.Settings.Tools.ExportBottomMarginPercent = comboBoxBottomMargin.SelectedIndex; + } + else // pixels + { + Configuration.Settings.Tools.ExportBottomMarginPixels = comboBoxBottomMargin.SelectedIndex; + } + } + + if (comboBoxLeftRightMargin.Visible) + { + if (comboBoxLeftRightMarginUnit.SelectedIndex == 0) // % + { + Configuration.Settings.Tools.ExportLeftRightMarginPercent = comboBoxLeftRightMargin.SelectedIndex; + } + else // pixels + { + Configuration.Settings.Tools.ExportLeftRightMarginPixels = comboBoxLeftRightMargin.SelectedIndex; + } + } + + if (comboBoxBottomMarginUnit.Visible) + { + Configuration.Settings.Tools.ExportBottomMarginUnit = comboBoxBottomMarginUnit.SelectedIndex == 0 ? "%" : "px"; + } + + if (comboBoxLeftRightMarginUnit.Visible) + { + Configuration.Settings.Tools.ExportLeftRightMarginUnit = comboBoxLeftRightMarginUnit.SelectedIndex == 0 ? "%" : "px"; + } + + Configuration.Settings.Tools.ExportHorizontalAlignment = comboBoxHAlign.SelectedIndex; + Configuration.Settings.Tools.Export3DType = comboBox3D.SelectedIndex; + Configuration.Settings.Tools.Export3DDepth = (int)numericUpDownDepth3D.Value; + + if (comboBoxShadowWidth.Visible) + { + Configuration.Settings.Tools.ExportBluRayShadow = comboBoxShadowWidth.SelectedIndex; + } + + Configuration.Settings.Tools.ExportFontNameOther = _subtitleFontName; + Configuration.Settings.Tools.ExportLastFontSize = (int)_subtitleFontSize; + Configuration.Settings.Tools.ExportLastLineHeight = (int)numericUpDownLineSpacing.Value; + Configuration.Settings.Tools.ExportLastBorderWidth = comboBoxBorderWidth.SelectedIndex; + Configuration.Settings.Tools.ExportLastFontBold = checkBoxBold.Checked; + } + + private void numericUpDownDepth3D_ValueChanged(object sender, EventArgs e) + { + if (!timerPreview.Enabled) + { + timerPreview.Start(); + } + } + + private void comboBox3D_SelectedIndexChanged(object sender, EventArgs e) + { + bool enable = comboBox3D.SelectedIndex > 0; + labelDepth.Enabled = enable; + numericUpDownDepth3D.Enabled = enable; + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void timerPreview_Tick(object sender, EventArgs e) + { + timerPreview.Stop(); + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void saveImageAsToolStripMenuItem_Click(object sender, EventArgs e) + { + if (subtitleListView1.SelectedItems.Count != 1) + { + return; + } + + int selectedIndex = subtitleListView1.SelectedItems[0].Index; + + saveFileDialog1.Title = Configuration.Settings.Language.VobSubOcr.SaveSubtitleImageAs; + saveFileDialog1.AddExtension = true; + saveFileDialog1.FileName = "Image" + selectedIndex; + saveFileDialog1.Filter = "PNG image|*.png|BMP image|*.bmp|GIF image|*.gif|TIFF image|*.tiff"; + saveFileDialog1.FilterIndex = 0; + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + var bmp = pictureBox1.Image as Bitmap; + if (bmp == null) + { + MessageBox.Show("No image!"); + return; + } + + try + { + if (saveFileDialog1.FilterIndex == 0) + { + bmp.Save(saveFileDialog1.FileName, ImageFormat.Png); + } + else if (saveFileDialog1.FilterIndex == 1) + { + bmp.Save(saveFileDialog1.FileName); + } + else if (saveFileDialog1.FilterIndex == 2) + { + bmp.Save(saveFileDialog1.FileName, ImageFormat.Gif); + } + else + { + bmp.Save(saveFileDialog1.FileName, ImageFormat.Tiff); + } + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + } + } + } + + private void buttonShadowColor_Click(object sender, EventArgs e) + { + using (var colorChooser = new ColorChooser { Color = panelShadowColor.BackColor }) + { + if (colorChooser.ShowDialog() == DialogResult.OK) + { + panelShadowColor.BackColor = colorChooser.Color; + subtitleListView1_SelectedIndexChanged(null, null); + numericUpDownShadowTransparency.Value = colorChooser.Color.A; + } + } + } + + private void panelShadowColor_MouseClick(object sender, MouseEventArgs e) + { + buttonShadowColor_Click(sender, e); + } + + private void comboBoxShadowWidth_SelectedIndexChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void numericUpDownShadowTransparency_ValueChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void comboBoxSubtitleFont_SelectedIndexChanged(object sender, EventArgs e) + { + if (_isLoading) + { + return; + } + + if (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat) + { + return; + } + + var lineHeight = (int)Math.Round(GetFontHeight() * 0.64f); + if (lineHeight >= numericUpDownLineSpacing.Minimum && + lineHeight <= numericUpDownLineSpacing.Maximum) + { + numericUpDownLineSpacing.ValueChanged -= numericUpDownLineSpacing_ValueChanged; + numericUpDownLineSpacing.Value = lineHeight; + numericUpDownLineSpacing.ValueChanged += numericUpDownLineSpacing_ValueChanged; + } + subtitleListView1_SelectedIndexChanged(null, null); + + // change font + if (!comboBoxSubtitleFont.Enabled) + { + return; + } + try + { + var fontName = comboBoxSubtitleFont.SelectedItem.ToString(); + int columnIndexText = 4; + if (subtitleListView1.CheckBoxes) + { + columnIndexText++; + } + + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + + subtitleListView1.Items[i].SubItems[columnIndexText].Font = new Font(fontName, Font.Size); + } + } + catch + { + // ignore unable to set font errors + } + } + + private void numericUpDownLineSpacing_ValueChanged(object sender, EventArgs e) + { + var value = (int)numericUpDownLineSpacing.Value; + var style = string.Empty; + if (subtitleListView1.SelectedIndices.Count > 0) + { + style = GetStyleName(_subtitle.Paragraphs[subtitleListView1.SelectedItems[0].Index]); + } + + if (_lineHeights.ContainsKey(style)) + { + _lineHeights[style] = value; + } + + if (_formatName != AdvancedSubStationAlpha.NameOfFormat && _formatName != SubStationAlpha.NameOfFormat) + { + _lineHeights.Clear(); + _lineHeights.Add(string.Empty, value); + } + subtitleListView1_SelectedIndexChanged(null, null); + } + + private static string GetStyleName(Paragraph paragraph) + { + if ((_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat) && !string.IsNullOrEmpty(paragraph.Extra)) + { + return paragraph.Extra; + } + return string.Empty; + } + + private void ListViewToggleTag(string tag) + { + if (_subtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0) + { + var indexes = new List(); + foreach (ListViewItem item in subtitleListView1.SelectedItems) + { + indexes.Add(item.Index); + } + + subtitleListView1.BeginUpdate(); + foreach (int i in indexes) + { + if (tag == BoxMultiLineText) + { + _subtitle.Paragraphs[i].Text = _subtitle.Paragraphs[i].Text.Replace("<" + BoxSingleLineText + ">", string.Empty).Replace("", string.Empty); + } + else if (tag == BoxSingleLineText) + { + _subtitle.Paragraphs[i].Text = _subtitle.Paragraphs[i].Text.Replace("<" + BoxMultiLineText + ">", string.Empty).Replace("", string.Empty); + } + + if (_subtitle.Paragraphs[i].Text.Contains("<" + tag + ">")) + { + _subtitle.Paragraphs[i].Text = _subtitle.Paragraphs[i].Text.Replace("<" + tag + ">", string.Empty); + _subtitle.Paragraphs[i].Text = _subtitle.Paragraphs[i].Text.Replace("", string.Empty); + } + else + { + int indexOfEndBracket = _subtitle.Paragraphs[i].Text.IndexOf('}'); + if (_subtitle.Paragraphs[i].Text.StartsWith("{\\", StringComparison.Ordinal) && indexOfEndBracket > 1 && indexOfEndBracket < 6) + { + _subtitle.Paragraphs[i].Text = string.Format("{2}<{0}>{1}", tag, _subtitle.Paragraphs[i].Text.Remove(0, indexOfEndBracket + 1), _subtitle.Paragraphs[i].Text.Substring(0, indexOfEndBracket + 1)); + } + else + { + _subtitle.Paragraphs[i].Text = string.Format("<{0}>{1}", tag, _subtitle.Paragraphs[i].Text); + } + } + SubtitleListView1SetText(i, _subtitle.Paragraphs[i].Text); + } + subtitleListView1.EndUpdate(); + } + } + + private void boxMultiLineToolStripMenuItem_Click(object sender, EventArgs e) + { + ListViewToggleTag(BoxMultiLineText); + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void boxSingleLineToolStripMenuItem_Click(object sender, EventArgs e) + { + ListViewToggleTag(BoxSingleLineText); + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void italicToolStripMenuItem_Click(object sender, EventArgs e) + { + ListViewToggleTag("i"); + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void normalToolStripMenuItem_Click(object sender, EventArgs e) + { + if (_subtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0) + { + bool isSsa = _format.Name == SubStationAlpha.NameOfFormat || + _format.Name == AdvancedSubStationAlpha.NameOfFormat; + + foreach (ListViewItem item in subtitleListView1.SelectedItems) + { + Paragraph p = _subtitle.GetParagraphOrDefault(item.Index); + if (p != null) + { + int indexOfEndBracket = p.Text.IndexOf('}'); + if (p.Text.StartsWith("{\\", StringComparison.Ordinal) && indexOfEndBracket > 1 && indexOfEndBracket < 6) + { + p.Text = p.Text.Remove(0, indexOfEndBracket + 1); + } + + p.Text = HtmlUtil.RemoveHtmlTags(p.Text); + p.Text = p.Text.Replace("<" + BoxSingleLineText + ">", string.Empty).Replace("", string.Empty); + p.Text = p.Text.Replace("<" + BoxMultiLineText + ">", string.Empty).Replace("", string.Empty); + + if (isSsa) + { + p.Text = Utilities.RemoveSsaTags(p.Text); + } + + SubtitleListView1SetText(item.Index, p.Text); + } + } + } + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void subtitleListView1_KeyDown(object sender, KeyEventArgs e) + { + var italicShortCut = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxItalic); + if (e.KeyData == italicShortCut) + { + ListViewToggleTag("i"); + subtitleListView1_SelectedIndexChanged(null, null); + } + else if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) + { + subtitleListView1.SelectAll(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.D && e.Modifiers == Keys.Control) + { + subtitleListView1.SelectFirstSelectedItemOnly(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.I && e.Modifiers == (Keys.Control | Keys.Shift)) + { + subtitleListView1.InverseSelection(); + e.SuppressKeyPress = true; + } + } + + public void SubtitleListView1SelectNone() + { + foreach (ListViewItem item in subtitleListView1.SelectedItems) + { + item.Selected = false; + } + } + + private void SubtitleListView1SelectIndexAndEnsureVisible(int index) + { + if (index < 0 || index >= subtitleListView1.Items.Count || subtitleListView1.Items.Count == 0) + { + return; + } + + if (subtitleListView1.TopItem == null) + { + return; + } + + int bottomIndex = subtitleListView1.TopItem.Index + (Height - 25) / 16; + int itemsBeforeAfterCount = (bottomIndex - subtitleListView1.TopItem.Index) / 2 - 1; + if (itemsBeforeAfterCount < 0) + { + itemsBeforeAfterCount = 1; + } + + int beforeIndex = index - itemsBeforeAfterCount; + if (beforeIndex < 0) + { + beforeIndex = 0; + } + + int afterIndex = index + itemsBeforeAfterCount; + if (afterIndex >= subtitleListView1.Items.Count) + { + afterIndex = subtitleListView1.Items.Count - 1; + } + + SubtitleListView1SelectNone(); + if (subtitleListView1.TopItem.Index <= beforeIndex && bottomIndex > afterIndex) + { + subtitleListView1.Items[index].Selected = true; + subtitleListView1.Items[index].EnsureVisible(); + return; + } + + subtitleListView1.Items[beforeIndex].EnsureVisible(); + subtitleListView1.EnsureVisible(beforeIndex); + subtitleListView1.Items[afterIndex].EnsureVisible(); + subtitleListView1.EnsureVisible(afterIndex); + subtitleListView1.Items[index].Selected = true; + subtitleListView1.Items[index].EnsureVisible(); + } + + private void SubtitleListView1Add(Paragraph paragraph) + { + var item = new ListViewItem(paragraph.Number.ToString(CultureInfo.InvariantCulture)) { Tag = paragraph, UseItemStyleForSubItems = false }; + ListViewItem.ListViewSubItem subItem; + + if (subtitleListView1.CheckBoxes) + { + item.Text = string.Empty; + subItem = new ListViewItem.ListViewSubItem(item, paragraph.Number.ToString(CultureInfo.InvariantCulture)) { Tag = paragraph }; + item.SubItems.Add(subItem); + } + + subItem = new ListViewItem.ListViewSubItem(item, paragraph.StartTime.ToDisplayString()); + item.SubItems.Add(subItem); + + subItem = new ListViewItem.ListViewSubItem(item, paragraph.EndTime.ToDisplayString()); + item.SubItems.Add(subItem); + + subItem = new ListViewItem.ListViewSubItem(item, paragraph.Duration.ToShortDisplayString()); + item.SubItems.Add(subItem); + + subItem = new ListViewItem.ListViewSubItem(item, UiUtil.GetListViewTextFromString(paragraph.Text)); + try + { + if (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat) + { + var style = AdvancedSubStationAlpha.GetSsaStyle(paragraph.Extra, _subtitle.Header); + subItem.Font = new Font(style.FontName, Font.Size); + } + else + { + subItem.Font = new Font(_subtitleFontName, Font.Size); + } + } + catch + { + subItem.Font = new Font(_subtitleFontName, Font.Size, FontStyle.Bold); + } + item.SubItems.Add(subItem); + + if (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat) + { + subItem = new ListViewItem.ListViewSubItem(item, paragraph.Extra); + item.SubItems.Add(subItem); + } + + subtitleListView1.Items.Add(item); + } + + private void SubtitleListView1Fill(Subtitle subtitle) + { + subtitleListView1.BeginUpdate(); + subtitleListView1.Items.Clear(); + foreach (Paragraph paragraph in subtitle.Paragraphs) + { + SubtitleListView1Add(paragraph); + } + subtitleListView1.EndUpdate(); + } + + private void SubtitleListView1AutoSizeAllColumns() + { + int columnIndexNumber = 0; + int columnIndexStart = 1; + int columnIndexEnd = 2; + int columnIndexDuration = 3; + int columnIndexText = 4; + int columnIndexStyle = 5; + + if (subtitleListView1.CheckBoxes) + { + subtitleListView1.Columns[0].Width = 60; + columnIndexNumber++; + columnIndexStart++; + columnIndexEnd++; + columnIndexDuration++; + columnIndexText++; + } + + var settings = Configuration.Settings; + if (settings != null && settings.General.ListViewColumnsRememberSize && settings.General.ListViewNumberWidth > 1) + { + subtitleListView1.Columns[columnIndexNumber].Width = settings.General.ListViewNumberWidth; + } + else + { + subtitleListView1.Columns[columnIndexNumber].Width = 55; + } + + subtitleListView1.Columns[columnIndexStart].Width = 90; + subtitleListView1.Columns[columnIndexEnd].Width = 90; + subtitleListView1.Columns[columnIndexDuration].Width = 60; + if (_formatName == AdvancedSubStationAlpha.NameOfFormat || _formatName == SubStationAlpha.NameOfFormat) + { + subtitleListView1.Columns.Add("style", Configuration.Settings.Language.General.Style, 90); + subtitleListView1.Columns[columnIndexText].Width = subtitleListView1.Width - + subtitleListView1.Columns[columnIndexNumber].Width - + subtitleListView1.Columns[columnIndexStart].Width - + subtitleListView1.Columns[columnIndexEnd].Width - + subtitleListView1.Columns[columnIndexDuration].Width - + 175; + subtitleListView1.Columns[columnIndexStyle].Width = -2; + } + else + { + subtitleListView1.Columns[columnIndexText].Width = -2; + } + } + + private void SubtitleListView1InitializeLanguage(LanguageStructure.General general, Core.Common.Settings settings) + { + int columnIndexNumber = 0; + int columnIndexStart = 1; + int columnIndexEnd = 2; + int columnIndexDuration = 3; + int columnIndexText = 4; + + if (subtitleListView1.CheckBoxes) + { + columnIndexNumber++; + columnIndexStart++; + columnIndexEnd++; + columnIndexDuration++; + columnIndexText++; + } + + subtitleListView1.Columns[columnIndexNumber].Text = general.NumberSymbol; + subtitleListView1.Columns[columnIndexStart].Text = general.StartTime; + subtitleListView1.Columns[columnIndexEnd].Text = general.EndTime; + subtitleListView1.Columns[columnIndexDuration].Text = general.Duration; + subtitleListView1.Columns[columnIndexText].Text = general.Text; + subtitleListView1.ForeColor = settings.General.SubtitleFontColor; + subtitleListView1.BackColor = settings.General.SubtitleBackgroundColor; + } + + private void SubtitleListView1SetText(int index, string text) + { + int columnIndexText = 4; + + if (subtitleListView1.CheckBoxes) + { + columnIndexText++; + } + + subtitleListView1.Items[index].SubItems[columnIndexText].Text = UiUtil.GetListViewTextFromString(text); + } + + private void FillPreviewBackground(Bitmap bmp, Graphics g, Paragraph p) + { + try + { + if (!string.IsNullOrWhiteSpace(_videoFileName) && LibVlcDynamic.IsInstalled) + { + using (var vlc = new LibVlcDynamic()) + { + vlc.Initialize(panelVlcTemp, _videoFileName, null, null); + Application.DoEvents(); + vlc.Volume = 0; + vlc.Pause(); + vlc.CurrentPosition = p.StartTime.TotalSeconds; + Application.DoEvents(); + var fileName = FileUtil.GetTempFileName(".bmp"); + vlc.TakeSnapshot(fileName, (uint)bmp.Width, (uint)bmp.Height); + Application.DoEvents(); + Thread.Sleep(200); + using (var tempBmp = new Bitmap(fileName)) + { + g.DrawImageUnscaled(tempBmp, new Point(0, 0)); + } + } + return; + } + } + catch + { + // Was unable to grap screenshot via vlc + } + + // Draw background with generated image + var rect = new Rectangle(0, 0, bmp.Width - 1, bmp.Height - 1); + using (var br = new LinearGradientBrush(rect, Color.Black, Color.Black, 0, false)) + { + var cb = new ColorBlend + { + Positions = new[] { 0, 1 / 6f, 2 / 6f, 3 / 6f, 4 / 6f, 5 / 6f, 1 }, + Colors = new[] { Color.Black, Color.Black, Color.White, Color.Black, Color.Black, Color.White, Color.Black } + }; + br.InterpolationColors = cb; + br.RotateTransform(0); + g.FillRectangle(br, rect); + } + } + + private void linkLabelPreview_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + linkLabelPreview.Enabled = false; + Cursor = Cursors.WaitCursor; + try + { + GetResolution(out var width, out var height); + using (var bmp = new Bitmap(width, height)) + { + using (var g = Graphics.FromImage(bmp)) + { + var p = _subtitle.Paragraphs[subtitleListView1.SelectedItems[0].Index]; + FillPreviewBackground(bmp, g, p); + + var nBmp = new NikseBitmap(pictureBox1.Image as Bitmap); + nBmp.CropSidesAndBottom(100, Color.Transparent, true); + using (var textBmp = nBmp.GetBitmap()) + { + var bp = MakeMakeBitmapParameter(subtitleListView1.SelectedItems[0].Index, width, height); + var alignment = GetAlignmentFromParagraph(bp, _format, _subtitle); + if (comboBoxHAlign.Visible && alignment == ContentAlignment.BottomCenter && _format.GetType() != typeof(AdvancedSubStationAlpha) && _format.GetType() != typeof(SubStationAlpha)) + { + if (comboBoxHAlign.SelectedIndex == 0) + { + alignment = ContentAlignment.BottomLeft; + } + else if (comboBoxHAlign.SelectedIndex == 2) + { + alignment = ContentAlignment.BottomRight; + } + } + + int x = (bmp.Width - textBmp.Width) / 2; + if (alignment == ContentAlignment.BottomLeft || alignment == ContentAlignment.MiddleLeft || alignment == ContentAlignment.TopLeft) + { + x = GetBottomMarginInPixels(p); + } + else if (alignment == ContentAlignment.BottomRight || alignment == ContentAlignment.MiddleRight || alignment == ContentAlignment.TopRight) + { + x = bmp.Width - textBmp.Width - GetBottomMarginInPixels(p); + } + + int y = bmp.Height - textBmp.Height - GetBottomMarginInPixels(p); + if (alignment == ContentAlignment.BottomLeft || alignment == ContentAlignment.MiddleLeft || alignment == ContentAlignment.TopLeft) + { + x = GetBottomMarginInPixels(p); + } + else if (alignment == ContentAlignment.BottomRight || alignment == ContentAlignment.MiddleRight || alignment == ContentAlignment.TopRight) + { + x = bmp.Width - textBmp.Width - GetBottomMarginInPixels(p); + } + + if (alignment == ContentAlignment.MiddleLeft || alignment == ContentAlignment.MiddleCenter || alignment == ContentAlignment.MiddleRight) + { + y = (groupBoxExportImage.Height - 4 - textBmp.Height) / 2; + } + else if (alignment == ContentAlignment.TopLeft || alignment == ContentAlignment.TopCenter || alignment == ContentAlignment.TopRight) + { + y = GetBottomMarginInPixels(p); + } + + g.DrawImageUnscaled(textBmp, new Point(x, y)); + } + } + + using (var form = new ExportPngXmlPreview(bmp)) + { + Cursor = Cursors.Default; + form.ShowDialog(this); + } + } + } + finally + { + Cursor = Cursors.Default; + linkLabelPreview.Enabled = true; + } + } + + private void comboBoxLeftRightMargin_SelectedIndexChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void panelFullFrameBackground_Click(object sender, EventArgs e) + { + using (var colorChooser = new ColorChooser { Color = panelFullFrameBackground.BackColor, Text = Configuration.Settings.Language.ExportPngXml.ChooseBackgroundColor }) + { + if (colorChooser.ShowDialog() == DialogResult.OK) + { + panelFullFrameBackground.BackColor = colorChooser.Color; + subtitleListView1_SelectedIndexChanged(null, null); + } + } + } + + private void checkBoxFullFrameImage_CheckedChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + panelFullFrameBackground.Visible = checkBoxFullFrameImage.Checked; + if (_exportType == ExportFormats.BluraySup || _exportType == ExportFormats.VobSub || _exportType == ExportFormats.ImageFrame || _exportType == ExportFormats.BdnXml || _exportType == ExportFormats.Dost || _exportType == ExportFormats.Fab || _exportType == ExportFormats.Edl || _exportType == ExportFormats.EdlClipName) + { + return; + } + _allowCustomBottomMargin = checkBoxFullFrameImage.Checked; + comboBoxBottomMargin.Visible = checkBoxFullFrameImage.Checked; + labelBottomMargin.Visible = checkBoxFullFrameImage.Checked; + comboBoxBottomMarginUnit.Visible = checkBoxFullFrameImage.Checked; + } + + public void DisableSaveButtonAndCheckBoxes() + { + buttonExport.Visible = false; + subtitleListView1.CheckBoxes = false; + } + + private void comboBoxBottomMarginUnit_SelectedIndexChanged(object sender, EventArgs e) + { + comboBoxBottomMargin.BeginUpdate(); + comboBoxBottomMargin.Items.Clear(); + if (comboBoxBottomMarginUnit.SelectedIndex == 0) + { + for (int i = 0; i <= 95; i++) + { + comboBoxBottomMargin.Items.Add(i); + } + + var exportMarginPercent = _exportType == ExportFormats.BluraySup ? Configuration.Settings.Tools.ExportBluRayBottomMarginPercent : Configuration.Settings.Tools.ExportBottomMarginPercent; + if (exportMarginPercent >= 0 && exportMarginPercent < comboBoxBottomMargin.Items.Count) + { + comboBoxBottomMargin.SelectedIndex = exportMarginPercent; + } + } + else + { + for (int i = 0; i <= 1000; i++) + { + comboBoxBottomMargin.Items.Add(i); + } + + var exportMarginPixels = _exportType == ExportFormats.BluraySup ? Configuration.Settings.Tools.ExportBluRayBottomMarginPixels : Configuration.Settings.Tools.ExportBottomMarginPixels; + if (exportMarginPixels >= 0 && exportMarginPixels < comboBoxBottomMargin.Items.Count) + { + comboBoxBottomMargin.SelectedIndex = exportMarginPixels; + } + } + if (comboBoxBottomMargin.SelectedIndex == -1) + { + comboBoxBottomMargin.SelectedIndex = 0; + } + comboBoxBottomMargin.EndUpdate(); + } + + private void comboBoxLeftRightMarginUnit_SelectedIndexChanged(object sender, EventArgs e) + { + comboBoxLeftRightMargin.BeginUpdate(); + comboBoxLeftRightMargin.Items.Clear(); + if (comboBoxLeftRightMarginUnit.SelectedIndex == 0) + { + for (int i = 0; i < 95; i++) + { + comboBoxLeftRightMargin.Items.Add(i); + } + + if (Configuration.Settings.Tools.ExportLeftRightMarginPercent >= 0 && Configuration.Settings.Tools.ExportLeftRightMarginPercent < comboBoxLeftRightMargin.Items.Count) + { + comboBoxLeftRightMargin.SelectedIndex = Configuration.Settings.Tools.ExportLeftRightMarginPercent; + } + } + else + { + for (int i = 0; i <= 1000; i++) + { + comboBoxLeftRightMargin.Items.Add(i); + } + + if (Configuration.Settings.Tools.ExportLeftRightMarginPixels >= 0 && Configuration.Settings.Tools.ExportLeftRightMarginPixels < comboBoxLeftRightMargin.Items.Count) + { + comboBoxLeftRightMargin.SelectedIndex = Configuration.Settings.Tools.ExportLeftRightMarginPixels; + } + } + if (comboBoxLeftRightMargin.SelectedIndex == -1) + { + comboBoxLeftRightMargin.SelectedIndex = 0; + } + comboBoxLeftRightMargin.EndUpdate(); + } + + private void numericUpDownLineSpacing_KeyUp(object sender, KeyEventArgs e) + { + _previewTimer.Start(); + } + + public static Bitmap ResizeBitmap(Bitmap b, int width, int height) + { + Bitmap newImage = new Bitmap(width, height); + using (var g = Graphics.FromImage(newImage)) + { + g.SmoothingMode = SmoothingMode.HighQuality; + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + g.PixelOffsetMode = PixelOffsetMode.HighQuality; + g.DrawImage(b, new Rectangle(0, 0, width, height)); + } + return newImage; + } + + private void comboBoxResizePercentage_SelectedIndexChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void adjustTimeCodesToolStripMenuItem_Click(object sender, EventArgs e) + { + using (var showEarlierOrLater = new ShowEarlierLater()) + { + showEarlierOrLater.Initialize(ShowEarlierOrLater, false); + showEarlierOrLater.ShowDialog(this); + } + } + + public void ShowEarlierOrLater(double adjustMilliseconds, SelectionChoice selection) + { + adjustMilliseconds /= TimeCode.BaseUnit; + subtitleListView1.BeginUpdate(); + int startFrom = 0; + if (selection == SelectionChoice.SelectionAndForward) + { + if (subtitleListView1.SelectedItems.Count > 0) + { + startFrom = subtitleListView1.SelectedItems[0].Index; + } + else + { + startFrom = _subtitle.Paragraphs.Count; + } + } + for (int i = startFrom; i < _subtitle.Paragraphs.Count; i++) + { + switch (selection) + { + case SelectionChoice.SelectionOnly: + if (subtitleListView1.Items[i].Selected) + { + _subtitle.Paragraphs[i].Adjust(1.0, adjustMilliseconds); + ShowTimeInListView(i); + } + break; + case SelectionChoice.AllLines: + case SelectionChoice.SelectionAndForward: + _subtitle.Paragraphs[i].Adjust(1.0, adjustMilliseconds); + ShowTimeInListView(i); + break; + } + } + subtitleListView1.EndUpdate(); + } + + private void ShowTimeInListView(int index) + { + int startIndex = 1; + if (subtitleListView1.CheckBoxes) + { + startIndex++; + } + subtitleListView1.Items[index].SubItems[startIndex].Text = _subtitle.Paragraphs[index].StartTime.ToDisplayString(); + subtitleListView1.Items[index].SubItems[startIndex + 1].Text = _subtitle.Paragraphs[index].EndTime.ToDisplayString(); + subtitleListView1.Items[index].SubItems[startIndex + 2].Text = _subtitle.Paragraphs[index].Duration.ToShortDisplayString(); + } + + private void contextMenuStripListView_Opening(object sender, System.ComponentModel.CancelEventArgs e) + { + bool showImageExportMenuItems = _vobSubOcr != null; + toolStripSeparatorAdjust.Visible = showImageExportMenuItems; + adjustTimeCodesToolStripMenuItem.Visible = showImageExportMenuItems; + adjustDisplayTimeToolStripMenuItem.Visible = showImageExportMenuItems; + } + + private void adjustDisplayTimeToolStripMenuItem_Click(object sender, EventArgs e) + { + using (var adjustDisplayTime = new AdjustDisplayDuration()) + { + adjustDisplayTime.HideRecalculate(); + if (adjustDisplayTime.ShowDialog(this) == DialogResult.OK) + { + if (adjustDisplayTime.AdjustUsingPercent) + { + double percent = double.Parse(adjustDisplayTime.AdjustValue, CultureInfo.InvariantCulture); + _subtitle.AdjustDisplayTimeUsingPercent(percent, null); + } + else if (adjustDisplayTime.AdjustUsingSeconds) + { + double seconds = double.Parse(adjustDisplayTime.AdjustValue, CultureInfo.InvariantCulture); + _subtitle.AdjustDisplayTimeUsingSeconds(seconds, null); + } + else if (adjustDisplayTime.AdjustUsingRecalc) + { + double maxCharSeconds = (double)(adjustDisplayTime.MaxCharactersPerSecond); + _subtitle.RecalculateDisplayTimes(maxCharSeconds, null, (double)adjustDisplayTime.OptimalCharactersPerSecond); + } + else // fixed duration + { + _subtitle.SetFixedDuration(null, adjustDisplayTime.FixedMilliseconds); + } + } + } + subtitleListView1.BeginUpdate(); + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + ShowTimeInListView(i); + } + subtitleListView1.EndUpdate(); + } + } +} diff --git a/src/Forms/ExportPngXml.resx b/src/ui/Forms/ExportPngXml.resx similarity index 98% rename from src/Forms/ExportPngXml.resx rename to src/ui/Forms/ExportPngXml.resx index 5a84c8588..044fc07f8 100644 --- a/src/Forms/ExportPngXml.resx +++ b/src/ui/Forms/ExportPngXml.resx @@ -1,135 +1,135 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 565, 17 - - - 17, 17 - - - 307, 17 - - - 443, 17 - - - 720, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 565, 17 + + + 17, 17 + + + 307, 17 + + + 443, 17 + + + 720, 17 + \ No newline at end of file diff --git a/src/Forms/ExportPngXmlDialogOpenFolder.Designer.cs b/src/ui/Forms/ExportPngXmlDialogOpenFolder.Designer.cs similarity index 100% rename from src/Forms/ExportPngXmlDialogOpenFolder.Designer.cs rename to src/ui/Forms/ExportPngXmlDialogOpenFolder.Designer.cs diff --git a/src/Forms/ExportPngXmlDialogOpenFolder.cs b/src/ui/Forms/ExportPngXmlDialogOpenFolder.cs similarity index 100% rename from src/Forms/ExportPngXmlDialogOpenFolder.cs rename to src/ui/Forms/ExportPngXmlDialogOpenFolder.cs diff --git a/src/Forms/Ocr/AddToOcrReplaceList.resx b/src/ui/Forms/ExportPngXmlDialogOpenFolder.resx similarity index 100% rename from src/Forms/Ocr/AddToOcrReplaceList.resx rename to src/ui/Forms/ExportPngXmlDialogOpenFolder.resx diff --git a/src/Forms/ExportPngXmlPreview.Designer.cs b/src/ui/Forms/ExportPngXmlPreview.Designer.cs similarity index 100% rename from src/Forms/ExportPngXmlPreview.Designer.cs rename to src/ui/Forms/ExportPngXmlPreview.Designer.cs diff --git a/src/Forms/ExportPngXmlPreview.cs b/src/ui/Forms/ExportPngXmlPreview.cs similarity index 100% rename from src/Forms/ExportPngXmlPreview.cs rename to src/ui/Forms/ExportPngXmlPreview.cs diff --git a/src/Forms/Ocr/BinaryOcrChooseEditDb.resx b/src/ui/Forms/ExportPngXmlPreview.resx similarity index 100% rename from src/Forms/Ocr/BinaryOcrChooseEditDb.resx rename to src/ui/Forms/ExportPngXmlPreview.resx diff --git a/src/Forms/ExportText.Designer.cs b/src/ui/Forms/ExportText.Designer.cs similarity index 98% rename from src/Forms/ExportText.Designer.cs rename to src/ui/Forms/ExportText.Designer.cs index 5034492d7..ef3dd95fc 100644 --- a/src/Forms/ExportText.Designer.cs +++ b/src/ui/Forms/ExportText.Designer.cs @@ -1,411 +1,411 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ExportText - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.textBoxText = new System.Windows.Forms.TextBox(); - this.groupBoxImportOptions = new System.Windows.Forms.GroupBox(); - this.labelEncoding = new System.Windows.Forms.Label(); - this.comboBoxEncoding = new System.Windows.Forms.ComboBox(); - this.checkBoxAddNewlineAfterTimeCodes = new System.Windows.Forms.CheckBox(); - this.checkBoxAddNewlineAfterLineNumber = new System.Windows.Forms.CheckBox(); - this.checkBoxAddNewLine2 = new System.Windows.Forms.CheckBox(); - this.checkBoxAddAfterText = new System.Windows.Forms.CheckBox(); - this.checkBoxShowLineNumbers = new System.Windows.Forms.CheckBox(); - this.groupBoxTimeCodeFormat = new System.Windows.Forms.GroupBox(); - this.comboBoxTimeCodeSeparator = new System.Windows.Forms.ComboBox(); - this.labelTimeCodeSeparator = new System.Windows.Forms.Label(); - this.radioButtonTimeCodeHHMMSSFF = new System.Windows.Forms.RadioButton(); - this.radioButtonTimeCodeMs = new System.Windows.Forms.RadioButton(); - this.radioButtonTimeCodeSrt = new System.Windows.Forms.RadioButton(); - this.groupBoxFormatText = new System.Windows.Forms.GroupBox(); - this.checkBoxRemoveStyling = new System.Windows.Forms.CheckBox(); - this.radioButtonFormatMergeAll = new System.Windows.Forms.RadioButton(); - this.radioButtonFormatNone = new System.Windows.Forms.RadioButton(); - this.radioButtonFormatUnbreak = new System.Windows.Forms.RadioButton(); - this.checkBoxShowTimeCodes = new System.Windows.Forms.CheckBox(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.labelPreview = new System.Windows.Forms.Label(); - this.groupBoxImportOptions.SuspendLayout(); - this.groupBoxTimeCodeFormat.SuspendLayout(); - this.groupBoxFormatText.SuspendLayout(); - this.SuspendLayout(); - // - // textBoxText - // - this.textBoxText.AllowDrop = true; - this.textBoxText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxText.Location = new System.Drawing.Point(12, 40); - this.textBoxText.MaxLength = 0; - this.textBoxText.Multiline = true; - this.textBoxText.Name = "textBoxText"; - this.textBoxText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxText.Size = new System.Drawing.Size(403, 405); - this.textBoxText.TabIndex = 3; - // - // groupBoxImportOptions - // - this.groupBoxImportOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxImportOptions.Controls.Add(this.labelEncoding); - this.groupBoxImportOptions.Controls.Add(this.comboBoxEncoding); - this.groupBoxImportOptions.Controls.Add(this.checkBoxAddNewlineAfterTimeCodes); - this.groupBoxImportOptions.Controls.Add(this.checkBoxAddNewlineAfterLineNumber); - this.groupBoxImportOptions.Controls.Add(this.checkBoxAddNewLine2); - this.groupBoxImportOptions.Controls.Add(this.checkBoxAddAfterText); - this.groupBoxImportOptions.Controls.Add(this.checkBoxShowLineNumbers); - this.groupBoxImportOptions.Controls.Add(this.groupBoxTimeCodeFormat); - this.groupBoxImportOptions.Controls.Add(this.groupBoxFormatText); - this.groupBoxImportOptions.Controls.Add(this.checkBoxShowTimeCodes); - this.groupBoxImportOptions.Location = new System.Drawing.Point(421, 21); - this.groupBoxImportOptions.Name = "groupBoxImportOptions"; - this.groupBoxImportOptions.Size = new System.Drawing.Size(373, 427); - this.groupBoxImportOptions.TabIndex = 0; - this.groupBoxImportOptions.TabStop = false; - this.groupBoxImportOptions.Text = "Export options"; - // - // labelEncoding - // - this.labelEncoding.AutoSize = true; - this.labelEncoding.Location = new System.Drawing.Point(13, 392); - this.labelEncoding.Name = "labelEncoding"; - this.labelEncoding.Size = new System.Drawing.Size(52, 13); - this.labelEncoding.TabIndex = 8; - this.labelEncoding.Text = "Encoding"; - // - // comboBoxEncoding - // - this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxEncoding.FormattingEnabled = true; - this.comboBoxEncoding.Location = new System.Drawing.Point(71, 389); - this.comboBoxEncoding.Name = "comboBoxEncoding"; - this.comboBoxEncoding.Size = new System.Drawing.Size(221, 21); - this.comboBoxEncoding.TabIndex = 9; - // - // checkBoxAddNewlineAfterTimeCodes - // - this.checkBoxAddNewlineAfterTimeCodes.AutoSize = true; - this.checkBoxAddNewlineAfterTimeCodes.Checked = true; - this.checkBoxAddNewlineAfterTimeCodes.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxAddNewlineAfterTimeCodes.Location = new System.Drawing.Point(36, 188); - this.checkBoxAddNewlineAfterTimeCodes.Name = "checkBoxAddNewlineAfterTimeCodes"; - this.checkBoxAddNewlineAfterTimeCodes.Size = new System.Drawing.Size(160, 17); - this.checkBoxAddNewlineAfterTimeCodes.TabIndex = 4; - this.checkBoxAddNewlineAfterTimeCodes.Text = "Add new line after time code"; - this.checkBoxAddNewlineAfterTimeCodes.UseVisualStyleBackColor = true; - this.checkBoxAddNewlineAfterTimeCodes.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // checkBoxAddNewlineAfterLineNumber - // - this.checkBoxAddNewlineAfterLineNumber.AutoSize = true; - this.checkBoxAddNewlineAfterLineNumber.Checked = true; - this.checkBoxAddNewlineAfterLineNumber.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxAddNewlineAfterLineNumber.Location = new System.Drawing.Point(36, 146); - this.checkBoxAddNewlineAfterLineNumber.Name = "checkBoxAddNewlineAfterLineNumber"; - this.checkBoxAddNewlineAfterLineNumber.Size = new System.Drawing.Size(168, 17); - this.checkBoxAddNewlineAfterLineNumber.TabIndex = 2; - this.checkBoxAddNewlineAfterLineNumber.Text = "Add new line after line number"; - this.checkBoxAddNewlineAfterLineNumber.UseVisualStyleBackColor = true; - this.checkBoxAddNewlineAfterLineNumber.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // checkBoxAddNewLine2 - // - this.checkBoxAddNewLine2.AutoSize = true; - this.checkBoxAddNewLine2.Checked = true; - this.checkBoxAddNewLine2.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxAddNewLine2.Location = new System.Drawing.Point(19, 234); - this.checkBoxAddNewLine2.Name = "checkBoxAddNewLine2"; - this.checkBoxAddNewLine2.Size = new System.Drawing.Size(172, 17); - this.checkBoxAddNewLine2.TabIndex = 6; - this.checkBoxAddNewLine2.Text = "Add new line between subtitles"; - this.checkBoxAddNewLine2.UseVisualStyleBackColor = true; - this.checkBoxAddNewLine2.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // checkBoxAddAfterText - // - this.checkBoxAddAfterText.AutoSize = true; - this.checkBoxAddAfterText.Checked = true; - this.checkBoxAddAfterText.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxAddAfterText.Location = new System.Drawing.Point(19, 211); - this.checkBoxAddAfterText.Name = "checkBoxAddAfterText"; - this.checkBoxAddAfterText.Size = new System.Drawing.Size(136, 17); - this.checkBoxAddAfterText.TabIndex = 5; - this.checkBoxAddAfterText.Text = "Add new line after texts"; - this.checkBoxAddAfterText.UseVisualStyleBackColor = true; - this.checkBoxAddAfterText.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // checkBoxShowLineNumbers - // - this.checkBoxShowLineNumbers.AutoSize = true; - this.checkBoxShowLineNumbers.Location = new System.Drawing.Point(19, 127); - this.checkBoxShowLineNumbers.Name = "checkBoxShowLineNumbers"; - this.checkBoxShowLineNumbers.Size = new System.Drawing.Size(115, 17); - this.checkBoxShowLineNumbers.TabIndex = 1; - this.checkBoxShowLineNumbers.Text = "Show line numbers"; - this.checkBoxShowLineNumbers.UseVisualStyleBackColor = true; - this.checkBoxShowLineNumbers.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // groupBoxTimeCodeFormat - // - this.groupBoxTimeCodeFormat.Controls.Add(this.comboBoxTimeCodeSeparator); - this.groupBoxTimeCodeFormat.Controls.Add(this.labelTimeCodeSeparator); - this.groupBoxTimeCodeFormat.Controls.Add(this.radioButtonTimeCodeHHMMSSFF); - this.groupBoxTimeCodeFormat.Controls.Add(this.radioButtonTimeCodeMs); - this.groupBoxTimeCodeFormat.Controls.Add(this.radioButtonTimeCodeSrt); - this.groupBoxTimeCodeFormat.Location = new System.Drawing.Point(6, 264); - this.groupBoxTimeCodeFormat.Name = "groupBoxTimeCodeFormat"; - this.groupBoxTimeCodeFormat.Size = new System.Drawing.Size(326, 119); - this.groupBoxTimeCodeFormat.TabIndex = 7; - this.groupBoxTimeCodeFormat.TabStop = false; - this.groupBoxTimeCodeFormat.Text = "Time code format"; - // - // comboBoxTimeCodeSeparator - // - this.comboBoxTimeCodeSeparator.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxTimeCodeSeparator.FormattingEnabled = true; - this.comboBoxTimeCodeSeparator.Items.AddRange(new object[] { - " --> ", - " - ", - " "}); - this.comboBoxTimeCodeSeparator.Location = new System.Drawing.Point(121, 90); - this.comboBoxTimeCodeSeparator.Name = "comboBoxTimeCodeSeparator"; - this.comboBoxTimeCodeSeparator.Size = new System.Drawing.Size(121, 21); - this.comboBoxTimeCodeSeparator.TabIndex = 4; - this.comboBoxTimeCodeSeparator.SelectedIndexChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // labelTimeCodeSeparator - // - this.labelTimeCodeSeparator.AutoSize = true; - this.labelTimeCodeSeparator.Location = new System.Drawing.Point(13, 93); - this.labelTimeCodeSeparator.Name = "labelTimeCodeSeparator"; - this.labelTimeCodeSeparator.Size = new System.Drawing.Size(104, 13); - this.labelTimeCodeSeparator.TabIndex = 3; - this.labelTimeCodeSeparator.Text = "Time code separator"; - // - // radioButtonTimeCodeHHMMSSFF - // - this.radioButtonTimeCodeHHMMSSFF.AutoSize = true; - this.radioButtonTimeCodeHHMMSSFF.Location = new System.Drawing.Point(16, 65); - this.radioButtonTimeCodeHHMMSSFF.Name = "radioButtonTimeCodeHHMMSSFF"; - this.radioButtonTimeCodeHHMMSSFF.Size = new System.Drawing.Size(226, 17); - this.radioButtonTimeCodeHHMMSSFF.TabIndex = 2; - this.radioButtonTimeCodeHHMMSSFF.Text = "HH:MM:SS:FF (00:00:00:01 - 00:00:02:05)"; - this.radioButtonTimeCodeHHMMSSFF.UseVisualStyleBackColor = true; - this.radioButtonTimeCodeHHMMSSFF.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // radioButtonTimeCodeMs - // - this.radioButtonTimeCodeMs.AutoSize = true; - this.radioButtonTimeCodeMs.Location = new System.Drawing.Point(16, 42); - this.radioButtonTimeCodeMs.Name = "radioButtonTimeCodeMs"; - this.radioButtonTimeCodeMs.Size = new System.Drawing.Size(130, 17); - this.radioButtonTimeCodeMs.TabIndex = 1; - this.radioButtonTimeCodeMs.Text = "Milliseconds (0 - 2100)"; - this.radioButtonTimeCodeMs.UseVisualStyleBackColor = true; - this.radioButtonTimeCodeMs.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // radioButtonTimeCodeSrt - // - this.radioButtonTimeCodeSrt.AutoSize = true; - this.radioButtonTimeCodeSrt.Checked = true; - this.radioButtonTimeCodeSrt.Location = new System.Drawing.Point(16, 19); - this.radioButtonTimeCodeSrt.Name = "radioButtonTimeCodeSrt"; - this.radioButtonTimeCodeSrt.Size = new System.Drawing.Size(191, 17); - this.radioButtonTimeCodeSrt.TabIndex = 0; - this.radioButtonTimeCodeSrt.TabStop = true; - this.radioButtonTimeCodeSrt.Text = "Srt (00:00:00.000 --> 00:00:02.100)"; - this.radioButtonTimeCodeSrt.UseVisualStyleBackColor = true; - this.radioButtonTimeCodeSrt.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // groupBoxFormatText - // - this.groupBoxFormatText.Controls.Add(this.checkBoxRemoveStyling); - this.groupBoxFormatText.Controls.Add(this.radioButtonFormatMergeAll); - this.groupBoxFormatText.Controls.Add(this.radioButtonFormatNone); - this.groupBoxFormatText.Controls.Add(this.radioButtonFormatUnbreak); - this.groupBoxFormatText.Location = new System.Drawing.Point(6, 19); - this.groupBoxFormatText.Name = "groupBoxFormatText"; - this.groupBoxFormatText.Size = new System.Drawing.Size(326, 91); - this.groupBoxFormatText.TabIndex = 0; - this.groupBoxFormatText.TabStop = false; - this.groupBoxFormatText.Text = "Format text"; - // - // checkBoxRemoveStyling - // - this.checkBoxRemoveStyling.AutoSize = true; - this.checkBoxRemoveStyling.Checked = true; - this.checkBoxRemoveStyling.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxRemoveStyling.Location = new System.Drawing.Point(14, 68); - this.checkBoxRemoveStyling.Name = "checkBoxRemoveStyling"; - this.checkBoxRemoveStyling.Size = new System.Drawing.Size(98, 17); - this.checkBoxRemoveStyling.TabIndex = 3; - this.checkBoxRemoveStyling.Text = "Remove styling"; - this.checkBoxRemoveStyling.UseVisualStyleBackColor = true; - this.checkBoxRemoveStyling.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // radioButtonFormatMergeAll - // - this.radioButtonFormatMergeAll.AutoSize = true; - this.radioButtonFormatMergeAll.Location = new System.Drawing.Point(159, 19); - this.radioButtonFormatMergeAll.Name = "radioButtonFormatMergeAll"; - this.radioButtonFormatMergeAll.Size = new System.Drawing.Size(92, 17); - this.radioButtonFormatMergeAll.TabIndex = 1; - this.radioButtonFormatMergeAll.Text = "Merge all lines"; - this.radioButtonFormatMergeAll.UseVisualStyleBackColor = true; - this.radioButtonFormatMergeAll.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // radioButtonFormatNone - // - this.radioButtonFormatNone.AutoSize = true; - this.radioButtonFormatNone.Checked = true; - this.radioButtonFormatNone.Location = new System.Drawing.Point(14, 19); - this.radioButtonFormatNone.Name = "radioButtonFormatNone"; - this.radioButtonFormatNone.Size = new System.Drawing.Size(51, 17); - this.radioButtonFormatNone.TabIndex = 0; - this.radioButtonFormatNone.TabStop = true; - this.radioButtonFormatNone.Text = "None"; - this.radioButtonFormatNone.UseVisualStyleBackColor = true; - this.radioButtonFormatNone.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // radioButtonFormatUnbreak - // - this.radioButtonFormatUnbreak.AutoSize = true; - this.radioButtonFormatUnbreak.Location = new System.Drawing.Point(14, 42); - this.radioButtonFormatUnbreak.Name = "radioButtonFormatUnbreak"; - this.radioButtonFormatUnbreak.Size = new System.Drawing.Size(90, 17); - this.radioButtonFormatUnbreak.TabIndex = 2; - this.radioButtonFormatUnbreak.Text = "Unbreak lines"; - this.radioButtonFormatUnbreak.UseVisualStyleBackColor = true; - this.radioButtonFormatUnbreak.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // checkBoxShowTimeCodes - // - this.checkBoxShowTimeCodes.AutoSize = true; - this.checkBoxShowTimeCodes.Location = new System.Drawing.Point(19, 169); - this.checkBoxShowTimeCodes.Name = "checkBoxShowTimeCodes"; - this.checkBoxShowTimeCodes.Size = new System.Drawing.Size(107, 17); - this.checkBoxShowTimeCodes.TabIndex = 3; - this.checkBoxShowTimeCodes.Text = "Show time codes"; - this.checkBoxShowTimeCodes.UseVisualStyleBackColor = true; - this.checkBoxShowTimeCodes.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(719, 454); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 2; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(581, 454); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(132, 23); - this.buttonOK.TabIndex = 1; - this.buttonOK.Text = "Save as..."; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // labelPreview - // - this.labelPreview.AutoSize = true; - this.labelPreview.Location = new System.Drawing.Point(13, 21); - this.labelPreview.Name = "labelPreview"; - this.labelPreview.Size = new System.Drawing.Size(45, 13); - this.labelPreview.TabIndex = 3; - this.labelPreview.Text = "Preview"; - // - // ExportText - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(806, 487); - this.Controls.Add(this.labelPreview); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.groupBoxImportOptions); - this.Controls.Add(this.textBoxText); - this.KeyPreview = true; - this.MinimumSize = new System.Drawing.Size(800, 520); - this.Name = "ExportText"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Export plain text"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ExportText_FormClosing); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExportText_KeyDown); - this.groupBoxImportOptions.ResumeLayout(false); - this.groupBoxImportOptions.PerformLayout(); - this.groupBoxTimeCodeFormat.ResumeLayout(false); - this.groupBoxTimeCodeFormat.PerformLayout(); - this.groupBoxFormatText.ResumeLayout(false); - this.groupBoxFormatText.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox textBoxText; - private System.Windows.Forms.GroupBox groupBoxImportOptions; - private System.Windows.Forms.CheckBox checkBoxShowLineNumbers; - private System.Windows.Forms.GroupBox groupBoxTimeCodeFormat; - private System.Windows.Forms.RadioButton radioButtonTimeCodeMs; - private System.Windows.Forms.RadioButton radioButtonTimeCodeSrt; - private System.Windows.Forms.GroupBox groupBoxFormatText; - private System.Windows.Forms.RadioButton radioButtonFormatMergeAll; - private System.Windows.Forms.RadioButton radioButtonFormatNone; - private System.Windows.Forms.RadioButton radioButtonFormatUnbreak; - private System.Windows.Forms.CheckBox checkBoxShowTimeCodes; - private System.Windows.Forms.CheckBox checkBoxAddNewLine2; - private System.Windows.Forms.CheckBox checkBoxAddAfterText; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; - private System.Windows.Forms.RadioButton radioButtonTimeCodeHHMMSSFF; - private System.Windows.Forms.CheckBox checkBoxAddNewlineAfterLineNumber; - private System.Windows.Forms.CheckBox checkBoxAddNewlineAfterTimeCodes; - private System.Windows.Forms.ComboBox comboBoxTimeCodeSeparator; - private System.Windows.Forms.Label labelTimeCodeSeparator; - private System.Windows.Forms.Label labelPreview; - private System.Windows.Forms.CheckBox checkBoxRemoveStyling; - private System.Windows.Forms.Label labelEncoding; - private System.Windows.Forms.ComboBox comboBoxEncoding; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ExportText + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBoxText = new System.Windows.Forms.TextBox(); + this.groupBoxImportOptions = new System.Windows.Forms.GroupBox(); + this.labelEncoding = new System.Windows.Forms.Label(); + this.comboBoxEncoding = new System.Windows.Forms.ComboBox(); + this.checkBoxAddNewlineAfterTimeCodes = new System.Windows.Forms.CheckBox(); + this.checkBoxAddNewlineAfterLineNumber = new System.Windows.Forms.CheckBox(); + this.checkBoxAddNewLine2 = new System.Windows.Forms.CheckBox(); + this.checkBoxAddAfterText = new System.Windows.Forms.CheckBox(); + this.checkBoxShowLineNumbers = new System.Windows.Forms.CheckBox(); + this.groupBoxTimeCodeFormat = new System.Windows.Forms.GroupBox(); + this.comboBoxTimeCodeSeparator = new System.Windows.Forms.ComboBox(); + this.labelTimeCodeSeparator = new System.Windows.Forms.Label(); + this.radioButtonTimeCodeHHMMSSFF = new System.Windows.Forms.RadioButton(); + this.radioButtonTimeCodeMs = new System.Windows.Forms.RadioButton(); + this.radioButtonTimeCodeSrt = new System.Windows.Forms.RadioButton(); + this.groupBoxFormatText = new System.Windows.Forms.GroupBox(); + this.checkBoxRemoveStyling = new System.Windows.Forms.CheckBox(); + this.radioButtonFormatMergeAll = new System.Windows.Forms.RadioButton(); + this.radioButtonFormatNone = new System.Windows.Forms.RadioButton(); + this.radioButtonFormatUnbreak = new System.Windows.Forms.RadioButton(); + this.checkBoxShowTimeCodes = new System.Windows.Forms.CheckBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.labelPreview = new System.Windows.Forms.Label(); + this.groupBoxImportOptions.SuspendLayout(); + this.groupBoxTimeCodeFormat.SuspendLayout(); + this.groupBoxFormatText.SuspendLayout(); + this.SuspendLayout(); + // + // textBoxText + // + this.textBoxText.AllowDrop = true; + this.textBoxText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxText.Location = new System.Drawing.Point(12, 40); + this.textBoxText.MaxLength = 0; + this.textBoxText.Multiline = true; + this.textBoxText.Name = "textBoxText"; + this.textBoxText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxText.Size = new System.Drawing.Size(403, 405); + this.textBoxText.TabIndex = 3; + // + // groupBoxImportOptions + // + this.groupBoxImportOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImportOptions.Controls.Add(this.labelEncoding); + this.groupBoxImportOptions.Controls.Add(this.comboBoxEncoding); + this.groupBoxImportOptions.Controls.Add(this.checkBoxAddNewlineAfterTimeCodes); + this.groupBoxImportOptions.Controls.Add(this.checkBoxAddNewlineAfterLineNumber); + this.groupBoxImportOptions.Controls.Add(this.checkBoxAddNewLine2); + this.groupBoxImportOptions.Controls.Add(this.checkBoxAddAfterText); + this.groupBoxImportOptions.Controls.Add(this.checkBoxShowLineNumbers); + this.groupBoxImportOptions.Controls.Add(this.groupBoxTimeCodeFormat); + this.groupBoxImportOptions.Controls.Add(this.groupBoxFormatText); + this.groupBoxImportOptions.Controls.Add(this.checkBoxShowTimeCodes); + this.groupBoxImportOptions.Location = new System.Drawing.Point(421, 21); + this.groupBoxImportOptions.Name = "groupBoxImportOptions"; + this.groupBoxImportOptions.Size = new System.Drawing.Size(373, 427); + this.groupBoxImportOptions.TabIndex = 0; + this.groupBoxImportOptions.TabStop = false; + this.groupBoxImportOptions.Text = "Export options"; + // + // labelEncoding + // + this.labelEncoding.AutoSize = true; + this.labelEncoding.Location = new System.Drawing.Point(13, 392); + this.labelEncoding.Name = "labelEncoding"; + this.labelEncoding.Size = new System.Drawing.Size(52, 13); + this.labelEncoding.TabIndex = 8; + this.labelEncoding.Text = "Encoding"; + // + // comboBoxEncoding + // + this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxEncoding.FormattingEnabled = true; + this.comboBoxEncoding.Location = new System.Drawing.Point(71, 389); + this.comboBoxEncoding.Name = "comboBoxEncoding"; + this.comboBoxEncoding.Size = new System.Drawing.Size(221, 21); + this.comboBoxEncoding.TabIndex = 9; + // + // checkBoxAddNewlineAfterTimeCodes + // + this.checkBoxAddNewlineAfterTimeCodes.AutoSize = true; + this.checkBoxAddNewlineAfterTimeCodes.Checked = true; + this.checkBoxAddNewlineAfterTimeCodes.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxAddNewlineAfterTimeCodes.Location = new System.Drawing.Point(36, 188); + this.checkBoxAddNewlineAfterTimeCodes.Name = "checkBoxAddNewlineAfterTimeCodes"; + this.checkBoxAddNewlineAfterTimeCodes.Size = new System.Drawing.Size(160, 17); + this.checkBoxAddNewlineAfterTimeCodes.TabIndex = 4; + this.checkBoxAddNewlineAfterTimeCodes.Text = "Add new line after time code"; + this.checkBoxAddNewlineAfterTimeCodes.UseVisualStyleBackColor = true; + this.checkBoxAddNewlineAfterTimeCodes.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // checkBoxAddNewlineAfterLineNumber + // + this.checkBoxAddNewlineAfterLineNumber.AutoSize = true; + this.checkBoxAddNewlineAfterLineNumber.Checked = true; + this.checkBoxAddNewlineAfterLineNumber.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxAddNewlineAfterLineNumber.Location = new System.Drawing.Point(36, 146); + this.checkBoxAddNewlineAfterLineNumber.Name = "checkBoxAddNewlineAfterLineNumber"; + this.checkBoxAddNewlineAfterLineNumber.Size = new System.Drawing.Size(168, 17); + this.checkBoxAddNewlineAfterLineNumber.TabIndex = 2; + this.checkBoxAddNewlineAfterLineNumber.Text = "Add new line after line number"; + this.checkBoxAddNewlineAfterLineNumber.UseVisualStyleBackColor = true; + this.checkBoxAddNewlineAfterLineNumber.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // checkBoxAddNewLine2 + // + this.checkBoxAddNewLine2.AutoSize = true; + this.checkBoxAddNewLine2.Checked = true; + this.checkBoxAddNewLine2.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxAddNewLine2.Location = new System.Drawing.Point(19, 234); + this.checkBoxAddNewLine2.Name = "checkBoxAddNewLine2"; + this.checkBoxAddNewLine2.Size = new System.Drawing.Size(172, 17); + this.checkBoxAddNewLine2.TabIndex = 6; + this.checkBoxAddNewLine2.Text = "Add new line between subtitles"; + this.checkBoxAddNewLine2.UseVisualStyleBackColor = true; + this.checkBoxAddNewLine2.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // checkBoxAddAfterText + // + this.checkBoxAddAfterText.AutoSize = true; + this.checkBoxAddAfterText.Checked = true; + this.checkBoxAddAfterText.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxAddAfterText.Location = new System.Drawing.Point(19, 211); + this.checkBoxAddAfterText.Name = "checkBoxAddAfterText"; + this.checkBoxAddAfterText.Size = new System.Drawing.Size(136, 17); + this.checkBoxAddAfterText.TabIndex = 5; + this.checkBoxAddAfterText.Text = "Add new line after texts"; + this.checkBoxAddAfterText.UseVisualStyleBackColor = true; + this.checkBoxAddAfterText.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // checkBoxShowLineNumbers + // + this.checkBoxShowLineNumbers.AutoSize = true; + this.checkBoxShowLineNumbers.Location = new System.Drawing.Point(19, 127); + this.checkBoxShowLineNumbers.Name = "checkBoxShowLineNumbers"; + this.checkBoxShowLineNumbers.Size = new System.Drawing.Size(115, 17); + this.checkBoxShowLineNumbers.TabIndex = 1; + this.checkBoxShowLineNumbers.Text = "Show line numbers"; + this.checkBoxShowLineNumbers.UseVisualStyleBackColor = true; + this.checkBoxShowLineNumbers.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // groupBoxTimeCodeFormat + // + this.groupBoxTimeCodeFormat.Controls.Add(this.comboBoxTimeCodeSeparator); + this.groupBoxTimeCodeFormat.Controls.Add(this.labelTimeCodeSeparator); + this.groupBoxTimeCodeFormat.Controls.Add(this.radioButtonTimeCodeHHMMSSFF); + this.groupBoxTimeCodeFormat.Controls.Add(this.radioButtonTimeCodeMs); + this.groupBoxTimeCodeFormat.Controls.Add(this.radioButtonTimeCodeSrt); + this.groupBoxTimeCodeFormat.Location = new System.Drawing.Point(6, 264); + this.groupBoxTimeCodeFormat.Name = "groupBoxTimeCodeFormat"; + this.groupBoxTimeCodeFormat.Size = new System.Drawing.Size(326, 119); + this.groupBoxTimeCodeFormat.TabIndex = 7; + this.groupBoxTimeCodeFormat.TabStop = false; + this.groupBoxTimeCodeFormat.Text = "Time code format"; + // + // comboBoxTimeCodeSeparator + // + this.comboBoxTimeCodeSeparator.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxTimeCodeSeparator.FormattingEnabled = true; + this.comboBoxTimeCodeSeparator.Items.AddRange(new object[] { + " --> ", + " - ", + " "}); + this.comboBoxTimeCodeSeparator.Location = new System.Drawing.Point(121, 90); + this.comboBoxTimeCodeSeparator.Name = "comboBoxTimeCodeSeparator"; + this.comboBoxTimeCodeSeparator.Size = new System.Drawing.Size(121, 21); + this.comboBoxTimeCodeSeparator.TabIndex = 4; + this.comboBoxTimeCodeSeparator.SelectedIndexChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // labelTimeCodeSeparator + // + this.labelTimeCodeSeparator.AutoSize = true; + this.labelTimeCodeSeparator.Location = new System.Drawing.Point(13, 93); + this.labelTimeCodeSeparator.Name = "labelTimeCodeSeparator"; + this.labelTimeCodeSeparator.Size = new System.Drawing.Size(104, 13); + this.labelTimeCodeSeparator.TabIndex = 3; + this.labelTimeCodeSeparator.Text = "Time code separator"; + // + // radioButtonTimeCodeHHMMSSFF + // + this.radioButtonTimeCodeHHMMSSFF.AutoSize = true; + this.radioButtonTimeCodeHHMMSSFF.Location = new System.Drawing.Point(16, 65); + this.radioButtonTimeCodeHHMMSSFF.Name = "radioButtonTimeCodeHHMMSSFF"; + this.radioButtonTimeCodeHHMMSSFF.Size = new System.Drawing.Size(226, 17); + this.radioButtonTimeCodeHHMMSSFF.TabIndex = 2; + this.radioButtonTimeCodeHHMMSSFF.Text = "HH:MM:SS:FF (00:00:00:01 - 00:00:02:05)"; + this.radioButtonTimeCodeHHMMSSFF.UseVisualStyleBackColor = true; + this.radioButtonTimeCodeHHMMSSFF.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // radioButtonTimeCodeMs + // + this.radioButtonTimeCodeMs.AutoSize = true; + this.radioButtonTimeCodeMs.Location = new System.Drawing.Point(16, 42); + this.radioButtonTimeCodeMs.Name = "radioButtonTimeCodeMs"; + this.radioButtonTimeCodeMs.Size = new System.Drawing.Size(130, 17); + this.radioButtonTimeCodeMs.TabIndex = 1; + this.radioButtonTimeCodeMs.Text = "Milliseconds (0 - 2100)"; + this.radioButtonTimeCodeMs.UseVisualStyleBackColor = true; + this.radioButtonTimeCodeMs.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // radioButtonTimeCodeSrt + // + this.radioButtonTimeCodeSrt.AutoSize = true; + this.radioButtonTimeCodeSrt.Checked = true; + this.radioButtonTimeCodeSrt.Location = new System.Drawing.Point(16, 19); + this.radioButtonTimeCodeSrt.Name = "radioButtonTimeCodeSrt"; + this.radioButtonTimeCodeSrt.Size = new System.Drawing.Size(191, 17); + this.radioButtonTimeCodeSrt.TabIndex = 0; + this.radioButtonTimeCodeSrt.TabStop = true; + this.radioButtonTimeCodeSrt.Text = "Srt (00:00:00.000 --> 00:00:02.100)"; + this.radioButtonTimeCodeSrt.UseVisualStyleBackColor = true; + this.radioButtonTimeCodeSrt.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // groupBoxFormatText + // + this.groupBoxFormatText.Controls.Add(this.checkBoxRemoveStyling); + this.groupBoxFormatText.Controls.Add(this.radioButtonFormatMergeAll); + this.groupBoxFormatText.Controls.Add(this.radioButtonFormatNone); + this.groupBoxFormatText.Controls.Add(this.radioButtonFormatUnbreak); + this.groupBoxFormatText.Location = new System.Drawing.Point(6, 19); + this.groupBoxFormatText.Name = "groupBoxFormatText"; + this.groupBoxFormatText.Size = new System.Drawing.Size(326, 91); + this.groupBoxFormatText.TabIndex = 0; + this.groupBoxFormatText.TabStop = false; + this.groupBoxFormatText.Text = "Format text"; + // + // checkBoxRemoveStyling + // + this.checkBoxRemoveStyling.AutoSize = true; + this.checkBoxRemoveStyling.Checked = true; + this.checkBoxRemoveStyling.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxRemoveStyling.Location = new System.Drawing.Point(14, 68); + this.checkBoxRemoveStyling.Name = "checkBoxRemoveStyling"; + this.checkBoxRemoveStyling.Size = new System.Drawing.Size(98, 17); + this.checkBoxRemoveStyling.TabIndex = 3; + this.checkBoxRemoveStyling.Text = "Remove styling"; + this.checkBoxRemoveStyling.UseVisualStyleBackColor = true; + this.checkBoxRemoveStyling.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // radioButtonFormatMergeAll + // + this.radioButtonFormatMergeAll.AutoSize = true; + this.radioButtonFormatMergeAll.Location = new System.Drawing.Point(159, 19); + this.radioButtonFormatMergeAll.Name = "radioButtonFormatMergeAll"; + this.radioButtonFormatMergeAll.Size = new System.Drawing.Size(92, 17); + this.radioButtonFormatMergeAll.TabIndex = 1; + this.radioButtonFormatMergeAll.Text = "Merge all lines"; + this.radioButtonFormatMergeAll.UseVisualStyleBackColor = true; + this.radioButtonFormatMergeAll.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // radioButtonFormatNone + // + this.radioButtonFormatNone.AutoSize = true; + this.radioButtonFormatNone.Checked = true; + this.radioButtonFormatNone.Location = new System.Drawing.Point(14, 19); + this.radioButtonFormatNone.Name = "radioButtonFormatNone"; + this.radioButtonFormatNone.Size = new System.Drawing.Size(51, 17); + this.radioButtonFormatNone.TabIndex = 0; + this.radioButtonFormatNone.TabStop = true; + this.radioButtonFormatNone.Text = "None"; + this.radioButtonFormatNone.UseVisualStyleBackColor = true; + this.radioButtonFormatNone.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // radioButtonFormatUnbreak + // + this.radioButtonFormatUnbreak.AutoSize = true; + this.radioButtonFormatUnbreak.Location = new System.Drawing.Point(14, 42); + this.radioButtonFormatUnbreak.Name = "radioButtonFormatUnbreak"; + this.radioButtonFormatUnbreak.Size = new System.Drawing.Size(90, 17); + this.radioButtonFormatUnbreak.TabIndex = 2; + this.radioButtonFormatUnbreak.Text = "Unbreak lines"; + this.radioButtonFormatUnbreak.UseVisualStyleBackColor = true; + this.radioButtonFormatUnbreak.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // checkBoxShowTimeCodes + // + this.checkBoxShowTimeCodes.AutoSize = true; + this.checkBoxShowTimeCodes.Location = new System.Drawing.Point(19, 169); + this.checkBoxShowTimeCodes.Name = "checkBoxShowTimeCodes"; + this.checkBoxShowTimeCodes.Size = new System.Drawing.Size(107, 17); + this.checkBoxShowTimeCodes.TabIndex = 3; + this.checkBoxShowTimeCodes.Text = "Show time codes"; + this.checkBoxShowTimeCodes.UseVisualStyleBackColor = true; + this.checkBoxShowTimeCodes.CheckedChanged += new System.EventHandler(this.radioButtonFormatNone_CheckedChanged); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(719, 454); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 2; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(581, 454); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(132, 23); + this.buttonOK.TabIndex = 1; + this.buttonOK.Text = "Save as..."; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // labelPreview + // + this.labelPreview.AutoSize = true; + this.labelPreview.Location = new System.Drawing.Point(13, 21); + this.labelPreview.Name = "labelPreview"; + this.labelPreview.Size = new System.Drawing.Size(45, 13); + this.labelPreview.TabIndex = 3; + this.labelPreview.Text = "Preview"; + // + // ExportText + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(806, 487); + this.Controls.Add(this.labelPreview); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.groupBoxImportOptions); + this.Controls.Add(this.textBoxText); + this.KeyPreview = true; + this.MinimumSize = new System.Drawing.Size(800, 520); + this.Name = "ExportText"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Export plain text"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ExportText_FormClosing); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExportText_KeyDown); + this.groupBoxImportOptions.ResumeLayout(false); + this.groupBoxImportOptions.PerformLayout(); + this.groupBoxTimeCodeFormat.ResumeLayout(false); + this.groupBoxTimeCodeFormat.PerformLayout(); + this.groupBoxFormatText.ResumeLayout(false); + this.groupBoxFormatText.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBoxText; + private System.Windows.Forms.GroupBox groupBoxImportOptions; + private System.Windows.Forms.CheckBox checkBoxShowLineNumbers; + private System.Windows.Forms.GroupBox groupBoxTimeCodeFormat; + private System.Windows.Forms.RadioButton radioButtonTimeCodeMs; + private System.Windows.Forms.RadioButton radioButtonTimeCodeSrt; + private System.Windows.Forms.GroupBox groupBoxFormatText; + private System.Windows.Forms.RadioButton radioButtonFormatMergeAll; + private System.Windows.Forms.RadioButton radioButtonFormatNone; + private System.Windows.Forms.RadioButton radioButtonFormatUnbreak; + private System.Windows.Forms.CheckBox checkBoxShowTimeCodes; + private System.Windows.Forms.CheckBox checkBoxAddNewLine2; + private System.Windows.Forms.CheckBox checkBoxAddAfterText; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.RadioButton radioButtonTimeCodeHHMMSSFF; + private System.Windows.Forms.CheckBox checkBoxAddNewlineAfterLineNumber; + private System.Windows.Forms.CheckBox checkBoxAddNewlineAfterTimeCodes; + private System.Windows.Forms.ComboBox comboBoxTimeCodeSeparator; + private System.Windows.Forms.Label labelTimeCodeSeparator; + private System.Windows.Forms.Label labelPreview; + private System.Windows.Forms.CheckBox checkBoxRemoveStyling; + private System.Windows.Forms.Label labelEncoding; + private System.Windows.Forms.ComboBox comboBoxEncoding; + } } \ No newline at end of file diff --git a/src/Forms/ExportText.cs b/src/ui/Forms/ExportText.cs similarity index 97% rename from src/Forms/ExportText.cs rename to src/ui/Forms/ExportText.cs index 58c99291d..4d85b6938 100644 --- a/src/Forms/ExportText.cs +++ b/src/ui/Forms/ExportText.cs @@ -1,325 +1,325 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.IO; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ExportText : Form - { - public class ExportOptions - { - public bool ShowLineNumbers { get; set; } - public bool AddNewlineAfterLineNumber { get; set; } - public bool ShowTimeCodes { get; set; } - public bool TimeCodeSrt { get; set; } - public bool TimeCodeHHMMSSFF { get; set; } - public bool AddNewlineAfterTimeCodes { get; set; } - public string TimeCodeSeparator { get; set; } - public bool RemoveStyling { get; set; } - public bool FormatUnbreak { get; set; } - public bool AddNewAfterText { get; set; } - public bool AddNewAfterText2 { get; set; } - public bool FormatMergeAll { get; set; } - } - - private Subtitle _subtitle; - private string _fileName; - private bool _loading; - - public ExportText() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - var l = Configuration.Settings.Language.ExportText; - Text = l.Title; - labelPreview.Text = l.Preview; - groupBoxImportOptions.Text = l.ExportOptions; - groupBoxFormatText.Text = l.FormatText; - radioButtonFormatNone.Text = l.None; - radioButtonFormatMergeAll.Text = l.MergeAllLines; - radioButtonFormatUnbreak.Text = l.UnbreakLines; - checkBoxRemoveStyling.Text = l.RemoveStyling; - checkBoxShowLineNumbers.Text = l.ShowLineNumbers; - checkBoxAddNewlineAfterLineNumber.Text = l.AddNewLineAfterLineNumber; - checkBoxShowTimeCodes.Text = l.ShowTimeCode; - checkBoxAddAfterText.Text = l.AddNewLineAfterTexts; - checkBoxAddNewlineAfterTimeCodes.Text = l.AddNewLineAfterTimeCode; - checkBoxAddNewLine2.Text = l.AddNewLineBetweenSubtitles; - groupBoxTimeCodeFormat.Text = l.TimeCodeFormat; - radioButtonTimeCodeSrt.Text = l.Srt; - radioButtonTimeCodeMs.Text = l.Milliseconds; - radioButtonTimeCodeHHMMSSFF.Text = l.HHMMSSFF; - labelTimeCodeSeparator.Text = l.TimeCodeSeparator; - comboBoxTimeCodeSeparator.Left = labelTimeCodeSeparator.Left + labelTimeCodeSeparator.Width + 5; - labelEncoding.Text = Configuration.Settings.Language.Main.Controls.FileEncoding; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - buttonOK.Text = Configuration.Settings.Language.Main.Menu.File.SaveAs; - - _loading = true; - } - - internal void Initialize(Subtitle subtitle, string fileName) - { - _subtitle = subtitle; - _fileName = fileName; - textBoxText.ReadOnly = true; - comboBoxTimeCodeSeparator.SelectedIndex = 0; - LoadSettings(); - _loading = false; - GeneratePreview(); - UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding); - } - - private void LoadSettings() - { - if (Configuration.Settings.Tools.ExportTextFormatText == "None") - { - radioButtonFormatNone.Checked = true; - } - else if (Configuration.Settings.Tools.ExportTextFormatText == "Unbreak") - { - radioButtonFormatUnbreak.Checked = true; - } - else - { - radioButtonFormatMergeAll.Checked = true; - } - - checkBoxRemoveStyling.Checked = Configuration.Settings.Tools.ExportTextRemoveStyling; - checkBoxShowLineNumbers.Checked = Configuration.Settings.Tools.ExportTextShowLineNumbers; - checkBoxAddNewlineAfterLineNumber.Checked = Configuration.Settings.Tools.ExportTextShowLineNumbersNewLine; - checkBoxShowTimeCodes.Checked = Configuration.Settings.Tools.ExportTextShowTimeCodes; - checkBoxAddNewlineAfterTimeCodes.Checked = Configuration.Settings.Tools.ExportTextShowTimeCodesNewLine; - checkBoxAddAfterText.Checked = Configuration.Settings.Tools.ExportTextNewLineAfterText; - checkBoxAddNewLine2.Checked = Configuration.Settings.Tools.ExportTextNewLineBetweenSubtitles; - checkBoxShowTimeCodes.Checked = Configuration.Settings.Tools.ExportTextShowTimeCodes; - - if (Configuration.Settings.Tools.ExportTextTimeCodeFormat == "Frames") - { - radioButtonTimeCodeHHMMSSFF.Checked = true; - } - else if (Configuration.Settings.Tools.ExportTextTimeCodeFormat == "Milliseconds") - { - radioButtonTimeCodeMs.Checked = true; - } - else - { - radioButtonTimeCodeSrt.Checked = true; - } - - if (Configuration.Settings.Tools.ExportTextTimeCodeSeparator == comboBoxTimeCodeSeparator.Items[0].ToString()) - { - comboBoxTimeCodeSeparator.SelectedIndex = 0; - } - else if (Configuration.Settings.Tools.ExportTextTimeCodeSeparator == comboBoxTimeCodeSeparator.Items[1].ToString()) - { - comboBoxTimeCodeSeparator.SelectedIndex = 1; - } - } - - private void GeneratePreview() - { - if (_loading) - { - return; - } - - groupBoxTimeCodeFormat.Enabled = checkBoxShowTimeCodes.Checked; - checkBoxAddAfterText.Enabled = !radioButtonFormatMergeAll.Checked; - checkBoxAddNewLine2.Enabled = !radioButtonFormatMergeAll.Checked; - checkBoxAddNewlineAfterLineNumber.Enabled = checkBoxShowLineNumbers.Checked; - checkBoxAddNewlineAfterTimeCodes.Enabled = checkBoxShowTimeCodes.Checked; - - var exportOptions = new ExportOptions - { - ShowLineNumbers = checkBoxShowLineNumbers.Checked, - AddNewlineAfterLineNumber = checkBoxAddNewlineAfterLineNumber.Checked, - ShowTimeCodes = checkBoxShowTimeCodes.Checked, - TimeCodeSrt = radioButtonTimeCodeSrt.Checked, - TimeCodeHHMMSSFF = radioButtonTimeCodeHHMMSSFF.Checked, - AddNewlineAfterTimeCodes = checkBoxAddNewlineAfterTimeCodes.Checked, - TimeCodeSeparator = comboBoxTimeCodeSeparator.Text, - RemoveStyling = checkBoxRemoveStyling.Checked, - FormatUnbreak = radioButtonFormatUnbreak.Checked, - AddNewAfterText = checkBoxAddAfterText.Checked, - AddNewAfterText2 = checkBoxAddNewLine2.Checked, - FormatMergeAll = radioButtonFormatMergeAll.Checked - }; - - string text = GeneratePlainText(_subtitle, exportOptions); - textBoxText.Text = text; - } - - public static string GeneratePlainText(Subtitle subtitle, ExportOptions exportOptions) - { - var sb = new StringBuilder(); - foreach (Paragraph p in subtitle.Paragraphs) - { - if (exportOptions.ShowLineNumbers) - { - sb.Append(p.Number); - if (exportOptions.AddNewlineAfterLineNumber) - { - sb.AppendLine(); - } - else - { - sb.Append(' '); - } - } - if (exportOptions.ShowTimeCodes) - { - if (exportOptions.TimeCodeSrt) - { - sb.Append(p.StartTime + exportOptions.TimeCodeSeparator + p.EndTime); - } - else if (exportOptions.TimeCodeHHMMSSFF) - { - sb.Append(p.StartTime.ToHHMMSSFF() + exportOptions.TimeCodeSeparator + p.EndTime.ToHHMMSSFF()); - } - else - { - sb.Append(p.StartTime.TotalMilliseconds + exportOptions.TimeCodeSeparator + p.EndTime.TotalMilliseconds); - } - - if (exportOptions.AddNewlineAfterTimeCodes) - { - sb.AppendLine(); - } - else - { - sb.Append(' '); - } - } - string s = p.Text; - if (exportOptions.RemoveStyling) - { - s = HtmlUtil.RemoveHtmlTags(s, true); - } - if (exportOptions.FormatUnbreak) - { - sb.Append(Utilities.UnbreakLine(s)); - } - else - { - sb.Append(s); - } - if (exportOptions.AddNewAfterText) - { - sb.AppendLine(); - } - - if (exportOptions.AddNewAfterText2) - { - sb.AppendLine(); - } - - if (!exportOptions.AddNewAfterText && !exportOptions.AddNewAfterText2) - { - sb.Append(' '); - } - } - string text = sb.ToString().Trim(); - if (exportOptions.FormatMergeAll) - { - text = text.Replace(Environment.NewLine, " "); - text = text.FixExtraSpaces(); - } - return text; - } - - private TextEncoding GetCurrentEncoding() - { - return UiUtil.GetTextEncodingComboBoxCurrentEncoding(comboBoxEncoding); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - GeneratePreview(); - saveFileDialog1.Title = Configuration.Settings.Language.Main.ExportPlainTextAs; - saveFileDialog1.Filter = Configuration.Settings.Language.Main.TextFiles + "|*.txt"; - if (!string.IsNullOrEmpty(_fileName)) - { - saveFileDialog1.FileName = Path.GetFileNameWithoutExtension(_fileName); - } - - if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) - { - FileUtil.WriteAllText(saveFileDialog1.FileName, textBoxText.Text, GetCurrentEncoding()); - DialogResult = DialogResult.OK; - } - } - - private void radioButtonFormatNone_CheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void ExportText_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void ExportText_FormClosing(object sender, FormClosingEventArgs e) - { - if (radioButtonFormatNone.Checked) - { - Configuration.Settings.Tools.ExportTextFormatText = "None"; - } - else if (radioButtonFormatUnbreak.Checked) - { - Configuration.Settings.Tools.ExportTextFormatText = "Unbreak"; - } - else - { - Configuration.Settings.Tools.ExportTextFormatText = "MergeAll"; - } - - Configuration.Settings.Tools.ExportTextRemoveStyling = checkBoxRemoveStyling.Checked; - Configuration.Settings.Tools.ExportTextShowLineNumbers = checkBoxShowLineNumbers.Checked; - Configuration.Settings.Tools.ExportTextShowLineNumbersNewLine = checkBoxAddNewlineAfterLineNumber.Checked; - Configuration.Settings.Tools.ExportTextShowTimeCodes = checkBoxShowTimeCodes.Checked; - Configuration.Settings.Tools.ExportTextShowTimeCodesNewLine = checkBoxAddNewlineAfterTimeCodes.Checked; - Configuration.Settings.Tools.ExportTextNewLineAfterText = checkBoxAddAfterText.Checked; - Configuration.Settings.Tools.ExportTextNewLineBetweenSubtitles = checkBoxAddNewLine2.Checked; - - if (radioButtonTimeCodeHHMMSSFF.Checked) - { - Configuration.Settings.Tools.ExportTextTimeCodeFormat = "Frames"; - } - else if (radioButtonTimeCodeMs.Checked) - { - Configuration.Settings.Tools.ExportTextTimeCodeFormat = "Milliseconds"; - } - else - { - Configuration.Settings.Tools.ExportTextTimeCodeFormat = "Srt"; - } - - Configuration.Settings.Tools.ExportTextTimeCodeSeparator = comboBoxTimeCodeSeparator.Items[comboBoxTimeCodeSeparator.SelectedIndex].ToString(); - } - - public void PrepareForBatchSettings() - { - groupBoxTimeCodeFormat.Visible = false; - labelEncoding.Visible = false; - comboBoxEncoding.Visible = false; - buttonOK.Visible = false; - buttonCancel.Text = Configuration.Settings.Language.General.Ok; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.IO; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ExportText : Form + { + public class ExportOptions + { + public bool ShowLineNumbers { get; set; } + public bool AddNewlineAfterLineNumber { get; set; } + public bool ShowTimeCodes { get; set; } + public bool TimeCodeSrt { get; set; } + public bool TimeCodeHHMMSSFF { get; set; } + public bool AddNewlineAfterTimeCodes { get; set; } + public string TimeCodeSeparator { get; set; } + public bool RemoveStyling { get; set; } + public bool FormatUnbreak { get; set; } + public bool AddNewAfterText { get; set; } + public bool AddNewAfterText2 { get; set; } + public bool FormatMergeAll { get; set; } + } + + private Subtitle _subtitle; + private string _fileName; + private bool _loading; + + public ExportText() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + var l = Configuration.Settings.Language.ExportText; + Text = l.Title; + labelPreview.Text = l.Preview; + groupBoxImportOptions.Text = l.ExportOptions; + groupBoxFormatText.Text = l.FormatText; + radioButtonFormatNone.Text = l.None; + radioButtonFormatMergeAll.Text = l.MergeAllLines; + radioButtonFormatUnbreak.Text = l.UnbreakLines; + checkBoxRemoveStyling.Text = l.RemoveStyling; + checkBoxShowLineNumbers.Text = l.ShowLineNumbers; + checkBoxAddNewlineAfterLineNumber.Text = l.AddNewLineAfterLineNumber; + checkBoxShowTimeCodes.Text = l.ShowTimeCode; + checkBoxAddAfterText.Text = l.AddNewLineAfterTexts; + checkBoxAddNewlineAfterTimeCodes.Text = l.AddNewLineAfterTimeCode; + checkBoxAddNewLine2.Text = l.AddNewLineBetweenSubtitles; + groupBoxTimeCodeFormat.Text = l.TimeCodeFormat; + radioButtonTimeCodeSrt.Text = l.Srt; + radioButtonTimeCodeMs.Text = l.Milliseconds; + radioButtonTimeCodeHHMMSSFF.Text = l.HHMMSSFF; + labelTimeCodeSeparator.Text = l.TimeCodeSeparator; + comboBoxTimeCodeSeparator.Left = labelTimeCodeSeparator.Left + labelTimeCodeSeparator.Width + 5; + labelEncoding.Text = Configuration.Settings.Language.Main.Controls.FileEncoding; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + buttonOK.Text = Configuration.Settings.Language.Main.Menu.File.SaveAs; + + _loading = true; + } + + internal void Initialize(Subtitle subtitle, string fileName) + { + _subtitle = subtitle; + _fileName = fileName; + textBoxText.ReadOnly = true; + comboBoxTimeCodeSeparator.SelectedIndex = 0; + LoadSettings(); + _loading = false; + GeneratePreview(); + UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding); + } + + private void LoadSettings() + { + if (Configuration.Settings.Tools.ExportTextFormatText == "None") + { + radioButtonFormatNone.Checked = true; + } + else if (Configuration.Settings.Tools.ExportTextFormatText == "Unbreak") + { + radioButtonFormatUnbreak.Checked = true; + } + else + { + radioButtonFormatMergeAll.Checked = true; + } + + checkBoxRemoveStyling.Checked = Configuration.Settings.Tools.ExportTextRemoveStyling; + checkBoxShowLineNumbers.Checked = Configuration.Settings.Tools.ExportTextShowLineNumbers; + checkBoxAddNewlineAfterLineNumber.Checked = Configuration.Settings.Tools.ExportTextShowLineNumbersNewLine; + checkBoxShowTimeCodes.Checked = Configuration.Settings.Tools.ExportTextShowTimeCodes; + checkBoxAddNewlineAfterTimeCodes.Checked = Configuration.Settings.Tools.ExportTextShowTimeCodesNewLine; + checkBoxAddAfterText.Checked = Configuration.Settings.Tools.ExportTextNewLineAfterText; + checkBoxAddNewLine2.Checked = Configuration.Settings.Tools.ExportTextNewLineBetweenSubtitles; + checkBoxShowTimeCodes.Checked = Configuration.Settings.Tools.ExportTextShowTimeCodes; + + if (Configuration.Settings.Tools.ExportTextTimeCodeFormat == "Frames") + { + radioButtonTimeCodeHHMMSSFF.Checked = true; + } + else if (Configuration.Settings.Tools.ExportTextTimeCodeFormat == "Milliseconds") + { + radioButtonTimeCodeMs.Checked = true; + } + else + { + radioButtonTimeCodeSrt.Checked = true; + } + + if (Configuration.Settings.Tools.ExportTextTimeCodeSeparator == comboBoxTimeCodeSeparator.Items[0].ToString()) + { + comboBoxTimeCodeSeparator.SelectedIndex = 0; + } + else if (Configuration.Settings.Tools.ExportTextTimeCodeSeparator == comboBoxTimeCodeSeparator.Items[1].ToString()) + { + comboBoxTimeCodeSeparator.SelectedIndex = 1; + } + } + + private void GeneratePreview() + { + if (_loading) + { + return; + } + + groupBoxTimeCodeFormat.Enabled = checkBoxShowTimeCodes.Checked; + checkBoxAddAfterText.Enabled = !radioButtonFormatMergeAll.Checked; + checkBoxAddNewLine2.Enabled = !radioButtonFormatMergeAll.Checked; + checkBoxAddNewlineAfterLineNumber.Enabled = checkBoxShowLineNumbers.Checked; + checkBoxAddNewlineAfterTimeCodes.Enabled = checkBoxShowTimeCodes.Checked; + + var exportOptions = new ExportOptions + { + ShowLineNumbers = checkBoxShowLineNumbers.Checked, + AddNewlineAfterLineNumber = checkBoxAddNewlineAfterLineNumber.Checked, + ShowTimeCodes = checkBoxShowTimeCodes.Checked, + TimeCodeSrt = radioButtonTimeCodeSrt.Checked, + TimeCodeHHMMSSFF = radioButtonTimeCodeHHMMSSFF.Checked, + AddNewlineAfterTimeCodes = checkBoxAddNewlineAfterTimeCodes.Checked, + TimeCodeSeparator = comboBoxTimeCodeSeparator.Text, + RemoveStyling = checkBoxRemoveStyling.Checked, + FormatUnbreak = radioButtonFormatUnbreak.Checked, + AddNewAfterText = checkBoxAddAfterText.Checked, + AddNewAfterText2 = checkBoxAddNewLine2.Checked, + FormatMergeAll = radioButtonFormatMergeAll.Checked + }; + + string text = GeneratePlainText(_subtitle, exportOptions); + textBoxText.Text = text; + } + + public static string GeneratePlainText(Subtitle subtitle, ExportOptions exportOptions) + { + var sb = new StringBuilder(); + foreach (Paragraph p in subtitle.Paragraphs) + { + if (exportOptions.ShowLineNumbers) + { + sb.Append(p.Number); + if (exportOptions.AddNewlineAfterLineNumber) + { + sb.AppendLine(); + } + else + { + sb.Append(' '); + } + } + if (exportOptions.ShowTimeCodes) + { + if (exportOptions.TimeCodeSrt) + { + sb.Append(p.StartTime + exportOptions.TimeCodeSeparator + p.EndTime); + } + else if (exportOptions.TimeCodeHHMMSSFF) + { + sb.Append(p.StartTime.ToHHMMSSFF() + exportOptions.TimeCodeSeparator + p.EndTime.ToHHMMSSFF()); + } + else + { + sb.Append(p.StartTime.TotalMilliseconds + exportOptions.TimeCodeSeparator + p.EndTime.TotalMilliseconds); + } + + if (exportOptions.AddNewlineAfterTimeCodes) + { + sb.AppendLine(); + } + else + { + sb.Append(' '); + } + } + string s = p.Text; + if (exportOptions.RemoveStyling) + { + s = HtmlUtil.RemoveHtmlTags(s, true); + } + if (exportOptions.FormatUnbreak) + { + sb.Append(Utilities.UnbreakLine(s)); + } + else + { + sb.Append(s); + } + if (exportOptions.AddNewAfterText) + { + sb.AppendLine(); + } + + if (exportOptions.AddNewAfterText2) + { + sb.AppendLine(); + } + + if (!exportOptions.AddNewAfterText && !exportOptions.AddNewAfterText2) + { + sb.Append(' '); + } + } + string text = sb.ToString().Trim(); + if (exportOptions.FormatMergeAll) + { + text = text.Replace(Environment.NewLine, " "); + text = text.FixExtraSpaces(); + } + return text; + } + + private TextEncoding GetCurrentEncoding() + { + return UiUtil.GetTextEncodingComboBoxCurrentEncoding(comboBoxEncoding); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + GeneratePreview(); + saveFileDialog1.Title = Configuration.Settings.Language.Main.ExportPlainTextAs; + saveFileDialog1.Filter = Configuration.Settings.Language.Main.TextFiles + "|*.txt"; + if (!string.IsNullOrEmpty(_fileName)) + { + saveFileDialog1.FileName = Path.GetFileNameWithoutExtension(_fileName); + } + + if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) + { + FileUtil.WriteAllText(saveFileDialog1.FileName, textBoxText.Text, GetCurrentEncoding()); + DialogResult = DialogResult.OK; + } + } + + private void radioButtonFormatNone_CheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void ExportText_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void ExportText_FormClosing(object sender, FormClosingEventArgs e) + { + if (radioButtonFormatNone.Checked) + { + Configuration.Settings.Tools.ExportTextFormatText = "None"; + } + else if (radioButtonFormatUnbreak.Checked) + { + Configuration.Settings.Tools.ExportTextFormatText = "Unbreak"; + } + else + { + Configuration.Settings.Tools.ExportTextFormatText = "MergeAll"; + } + + Configuration.Settings.Tools.ExportTextRemoveStyling = checkBoxRemoveStyling.Checked; + Configuration.Settings.Tools.ExportTextShowLineNumbers = checkBoxShowLineNumbers.Checked; + Configuration.Settings.Tools.ExportTextShowLineNumbersNewLine = checkBoxAddNewlineAfterLineNumber.Checked; + Configuration.Settings.Tools.ExportTextShowTimeCodes = checkBoxShowTimeCodes.Checked; + Configuration.Settings.Tools.ExportTextShowTimeCodesNewLine = checkBoxAddNewlineAfterTimeCodes.Checked; + Configuration.Settings.Tools.ExportTextNewLineAfterText = checkBoxAddAfterText.Checked; + Configuration.Settings.Tools.ExportTextNewLineBetweenSubtitles = checkBoxAddNewLine2.Checked; + + if (radioButtonTimeCodeHHMMSSFF.Checked) + { + Configuration.Settings.Tools.ExportTextTimeCodeFormat = "Frames"; + } + else if (radioButtonTimeCodeMs.Checked) + { + Configuration.Settings.Tools.ExportTextTimeCodeFormat = "Milliseconds"; + } + else + { + Configuration.Settings.Tools.ExportTextTimeCodeFormat = "Srt"; + } + + Configuration.Settings.Tools.ExportTextTimeCodeSeparator = comboBoxTimeCodeSeparator.Items[comboBoxTimeCodeSeparator.SelectedIndex].ToString(); + } + + public void PrepareForBatchSettings() + { + groupBoxTimeCodeFormat.Visible = false; + labelEncoding.Visible = false; + comboBoxEncoding.Visible = false; + buttonOK.Visible = false; + buttonCancel.Text = Configuration.Settings.Language.General.Ok; + } + + } +} diff --git a/src/Forms/ExportText.resx b/src/ui/Forms/ExportText.resx similarity index 97% rename from src/Forms/ExportText.resx rename to src/ui/Forms/ExportText.resx index 83ebf8a69..053da59c9 100644 --- a/src/Forms/ExportText.resx +++ b/src/ui/Forms/ExportText.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/ExportTextST.Designer.cs b/src/ui/Forms/ExportTextST.Designer.cs similarity index 98% rename from src/Forms/ExportTextST.Designer.cs rename to src/ui/Forms/ExportTextST.Designer.cs index dcb0739d7..d91a77e5b 100644 --- a/src/Forms/ExportTextST.Designer.cs +++ b/src/ui/Forms/ExportTextST.Designer.cs @@ -1,2138 +1,2138 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class ExportTextST - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.groupBoxPropertiesRoot = new System.Windows.Forms.GroupBox(); - this.textBoxRoot = new System.Windows.Forms.TextBox(); - this.groupBoxTextST = new System.Windows.Forms.GroupBox(); - this.treeView1 = new System.Windows.Forms.TreeView(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonSaveAsPes = new System.Windows.Forms.Button(); - this.buttonImport = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.groupBoxPropertiesRegionStyle = new System.Windows.Forms.GroupBox(); - this.numericUpDownRegionStyleFontOutlineThickness = new System.Windows.Forms.NumericUpDown(); - this.labelRegionStyleFontOutlineThickness = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleFontOutlinePaletteId = new System.Windows.Forms.NumericUpDown(); - this.labelRegionStyleFontOutlinePaletteId = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleFontPaletteId = new System.Windows.Forms.NumericUpDown(); - this.label39 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleFontStyle = new System.Windows.Forms.NumericUpDown(); - this.label38 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleFontIdRef = new System.Windows.Forms.NumericUpDown(); - this.label37 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleLineSpace = new System.Windows.Forms.NumericUpDown(); - this.label33 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleTextVerAlign = new System.Windows.Forms.NumericUpDown(); - this.label34 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleTextHorAlign = new System.Windows.Forms.NumericUpDown(); - this.label35 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleTextFlow = new System.Windows.Forms.NumericUpDown(); - this.label36 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleTBHeight = new System.Windows.Forms.NumericUpDown(); - this.label17 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleTBWidth = new System.Windows.Forms.NumericUpDown(); - this.label30 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleTBVerPos = new System.Windows.Forms.NumericUpDown(); - this.label31 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleTBHorPos = new System.Windows.Forms.NumericUpDown(); - this.label32 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleFontSize = new System.Windows.Forms.NumericUpDown(); - this.label12 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStylePaletteEntryId = new System.Windows.Forms.NumericUpDown(); - this.label11 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleHeight = new System.Windows.Forms.NumericUpDown(); - this.label9 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleWidth = new System.Windows.Forms.NumericUpDown(); - this.label10 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleVPos = new System.Windows.Forms.NumericUpDown(); - this.label8 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleHPos = new System.Windows.Forms.NumericUpDown(); - this.label7 = new System.Windows.Forms.Label(); - this.numericUpDownRegionStyleId = new System.Windows.Forms.NumericUpDown(); - this.label6 = new System.Windows.Forms.Label(); - this.groupBoxPropertiesPalette = new System.Windows.Forms.GroupBox(); - this.label47 = new System.Windows.Forms.Label(); - this.panelPaletteColor = new System.Windows.Forms.Panel(); - this.buttonColor = new System.Windows.Forms.Button(); - this.numericUpDownPaletteOpacity = new System.Windows.Forms.NumericUpDown(); - this.label5 = new System.Windows.Forms.Label(); - this.numericUpDownPaletteCb = new System.Windows.Forms.NumericUpDown(); - this.label4 = new System.Windows.Forms.Label(); - this.numericUpDownPaletteCr = new System.Windows.Forms.NumericUpDown(); - this.label3 = new System.Windows.Forms.Label(); - this.numericUpDownPaletteY = new System.Windows.Forms.NumericUpDown(); - this.label2 = new System.Windows.Forms.Label(); - this.numericUpDownPaletteEntry = new System.Windows.Forms.NumericUpDown(); - this.label1 = new System.Windows.Forms.Label(); - this.groupBoxPropertiesUserStyle = new System.Windows.Forms.GroupBox(); - this.numericUpDownUserStyleLineSpaceDelta = new System.Windows.Forms.NumericUpDown(); - this.label28 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleLineSpaceIncDec = new System.Windows.Forms.NumericUpDown(); - this.label29 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleTBHeightDelta = new System.Windows.Forms.NumericUpDown(); - this.label27 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleTBHeightIncDec = new System.Windows.Forms.NumericUpDown(); - this.label25 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleTBWidthDelta = new System.Windows.Forms.NumericUpDown(); - this.label26 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleTBWidthIncDec = new System.Windows.Forms.NumericUpDown(); - this.label19 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleTBVerPosDelta = new System.Windows.Forms.NumericUpDown(); - this.label20 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleTBVerPosDir = new System.Windows.Forms.NumericUpDown(); - this.label21 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleTBHorPosDelta = new System.Windows.Forms.NumericUpDown(); - this.label22 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleTBHorPosDir = new System.Windows.Forms.NumericUpDown(); - this.label23 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleFontSizeDelta = new System.Windows.Forms.NumericUpDown(); - this.label24 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleFontSizeIncDec = new System.Windows.Forms.NumericUpDown(); - this.label13 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleVerPosDelta = new System.Windows.Forms.NumericUpDown(); - this.label14 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleVerPosDir = new System.Windows.Forms.NumericUpDown(); - this.label15 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleHorPosDelta = new System.Windows.Forms.NumericUpDown(); - this.label16 = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleHorPosDir = new System.Windows.Forms.NumericUpDown(); - this.labelUserStyleHorPosDir = new System.Windows.Forms.Label(); - this.numericUpDownUserStyleId = new System.Windows.Forms.NumericUpDown(); - this.label18 = new System.Windows.Forms.Label(); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.buttonSaveAsM2ts = new System.Windows.Forms.Button(); - this.groupBoxPresentationSegmentRegion = new System.Windows.Forms.GroupBox(); - this.numericUpDownSubRegionStyleIdRef = new System.Windows.Forms.NumericUpDown(); - this.label40 = new System.Windows.Forms.Label(); - this.checkBoxSubRegionForced = new System.Windows.Forms.CheckBox(); - this.checkBoxSubRegionContinuous = new System.Windows.Forms.CheckBox(); - this.contextMenuStripAddPalette = new System.Windows.Forms.ContextMenuStrip(this.components); - this.addPaletteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBoxFontStyle = new System.Windows.Forms.GroupBox(); - this.label43 = new System.Windows.Forms.Label(); - this.label42 = new System.Windows.Forms.Label(); - this.comboBoxChangeFontStyleOutlineThickness = new System.Windows.Forms.ComboBox(); - this.comboBoxChangeFontStyleFontStyle = new System.Windows.Forms.ComboBox(); - this.numericUpDownChangeFontStyleOutlinePaletteId = new System.Windows.Forms.NumericUpDown(); - this.label41 = new System.Windows.Forms.Label(); - this.groupBoxChangeFontSize = new System.Windows.Forms.GroupBox(); - this.groupBoxChangeFontColor = new System.Windows.Forms.GroupBox(); - this.numericUpDownChangeFontColor = new System.Windows.Forms.NumericUpDown(); - this.label45 = new System.Windows.Forms.Label(); - this.numericUpDownChangeFontSize = new System.Windows.Forms.NumericUpDown(); - this.label46 = new System.Windows.Forms.Label(); - this.groupBoxSubtitleText = new System.Windows.Forms.GroupBox(); - this.textBoxSubtitleText = new System.Windows.Forms.TextBox(); - this.label44 = new System.Windows.Forms.Label(); - this.contextMenuStripAddSubtitleContent = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.addFontSetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.addFontStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.addFontSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.addLineBreakToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.addEndOfInlineStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); - this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.contextMenuStripAddSubtitleContentFromSubRegion = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemRegionAddText = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemRegionAddFontStyle = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemRegionAddFontSize = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemRegionAddLineBreak = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemRegionAddInlineStyle = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBoxFontSet = new System.Windows.Forms.GroupBox(); - this.numericUpDownFontSetFontId = new System.Windows.Forms.NumericUpDown(); - this.label48 = new System.Windows.Forms.Label(); - this.contextMenuStripRegionStyle = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemDuplicateRegionStyle = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBoxPropertiesRoot.SuspendLayout(); - this.groupBoxTextST.SuspendLayout(); - this.groupBoxPropertiesRegionStyle.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontOutlineThickness)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontOutlinePaletteId)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontPaletteId)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontStyle)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontIdRef)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleLineSpace)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTextVerAlign)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTextHorAlign)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTextFlow)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBHeight)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBWidth)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBVerPos)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBHorPos)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontSize)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStylePaletteEntryId)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleHeight)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleWidth)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleVPos)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleHPos)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleId)).BeginInit(); - this.groupBoxPropertiesPalette.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteOpacity)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteCb)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteCr)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteY)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteEntry)).BeginInit(); - this.groupBoxPropertiesUserStyle.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleLineSpaceDelta)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleLineSpaceIncDec)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHeightDelta)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHeightIncDec)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBWidthDelta)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBWidthIncDec)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBVerPosDelta)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBVerPosDir)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHorPosDelta)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHorPosDir)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleFontSizeDelta)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleFontSizeIncDec)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleVerPosDelta)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleVerPosDir)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleHorPosDelta)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleHorPosDir)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleId)).BeginInit(); - this.groupBoxPresentationSegmentRegion.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSubRegionStyleIdRef)).BeginInit(); - this.contextMenuStripAddPalette.SuspendLayout(); - this.groupBoxFontStyle.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownChangeFontStyleOutlinePaletteId)).BeginInit(); - this.groupBoxChangeFontSize.SuspendLayout(); - this.groupBoxChangeFontColor.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownChangeFontColor)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownChangeFontSize)).BeginInit(); - this.groupBoxSubtitleText.SuspendLayout(); - this.contextMenuStripAddSubtitleContent.SuspendLayout(); - this.contextMenuStripAddSubtitleContentFromSubRegion.SuspendLayout(); - this.groupBoxFontSet.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSetFontId)).BeginInit(); - this.contextMenuStripRegionStyle.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxPropertiesRoot - // - this.groupBoxPropertiesRoot.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxPropertiesRoot.Controls.Add(this.textBoxRoot); - this.groupBoxPropertiesRoot.Location = new System.Drawing.Point(518, 21); - this.groupBoxPropertiesRoot.Name = "groupBoxPropertiesRoot"; - this.groupBoxPropertiesRoot.Size = new System.Drawing.Size(345, 550); - this.groupBoxPropertiesRoot.TabIndex = 7; - this.groupBoxPropertiesRoot.TabStop = false; - this.groupBoxPropertiesRoot.Text = "Properties"; - // - // textBoxRoot - // - this.textBoxRoot.Dock = System.Windows.Forms.DockStyle.Fill; - this.textBoxRoot.Location = new System.Drawing.Point(3, 16); - this.textBoxRoot.Multiline = true; - this.textBoxRoot.Name = "textBoxRoot"; - this.textBoxRoot.ReadOnly = true; - this.textBoxRoot.Size = new System.Drawing.Size(339, 531); - this.textBoxRoot.TabIndex = 0; - // - // groupBoxTextST - // - this.groupBoxTextST.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxTextST.Controls.Add(this.treeView1); - this.groupBoxTextST.Location = new System.Drawing.Point(7, 21); - this.groupBoxTextST.Name = "groupBoxTextST"; - this.groupBoxTextST.Size = new System.Drawing.Size(505, 550); - this.groupBoxTextST.TabIndex = 6; - this.groupBoxTextST.TabStop = false; - this.groupBoxTextST.Text = "TextST structure"; - // - // treeView1 - // - this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill; - this.treeView1.Location = new System.Drawing.Point(3, 16); - this.treeView1.Name = "treeView1"; - this.treeView1.Size = new System.Drawing.Size(499, 531); - this.treeView1.TabIndex = 0; - this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect); - this.treeView1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.treeView1_MouseUp); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(788, 577); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 9; - this.buttonCancel.Text = "&OK"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonSaveAsPes - // - this.buttonSaveAsPes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSaveAsPes.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonSaveAsPes.Location = new System.Drawing.Point(633, 577); - this.buttonSaveAsPes.Name = "buttonSaveAsPes"; - this.buttonSaveAsPes.Size = new System.Drawing.Size(149, 23); - this.buttonSaveAsPes.TabIndex = 8; - this.buttonSaveAsPes.Text = "Write as PES packets..."; - this.buttonSaveAsPes.UseVisualStyleBackColor = true; - this.buttonSaveAsPes.Click += new System.EventHandler(this.buttonSaveAsPes_Click); - // - // buttonImport - // - this.buttonImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonImport.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonImport.Location = new System.Drawing.Point(724, 3); - this.buttonImport.Name = "buttonImport"; - this.buttonImport.Size = new System.Drawing.Size(139, 21); - this.buttonImport.TabIndex = 7; - this.buttonImport.Text = "Import TextST..."; - this.buttonImport.UseVisualStyleBackColor = true; - this.buttonImport.Click += new System.EventHandler(this.ButtonImportClick); - // - // groupBoxPropertiesRegionStyle - // - this.groupBoxPropertiesRegionStyle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleFontOutlineThickness); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.labelRegionStyleFontOutlineThickness); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleFontOutlinePaletteId); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.labelRegionStyleFontOutlinePaletteId); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleFontPaletteId); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label39); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleFontStyle); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label38); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleFontIdRef); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label37); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleLineSpace); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label33); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTextVerAlign); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label34); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTextHorAlign); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label35); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTextFlow); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label36); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTBHeight); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label17); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTBWidth); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label30); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTBVerPos); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label31); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTBHorPos); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label32); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleFontSize); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label12); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStylePaletteEntryId); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label11); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleHeight); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label9); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleWidth); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label10); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleVPos); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label8); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleHPos); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label7); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleId); - this.groupBoxPropertiesRegionStyle.Controls.Add(this.label6); - this.groupBoxPropertiesRegionStyle.Location = new System.Drawing.Point(48, 12); - this.groupBoxPropertiesRegionStyle.Name = "groupBoxPropertiesRegionStyle"; - this.groupBoxPropertiesRegionStyle.Size = new System.Drawing.Size(230, 549); - this.groupBoxPropertiesRegionStyle.TabIndex = 8; - this.groupBoxPropertiesRegionStyle.TabStop = false; - this.groupBoxPropertiesRegionStyle.Text = "Properties: Region style"; - this.groupBoxPropertiesRegionStyle.Visible = false; - // - // numericUpDownRegionStyleFontOutlineThickness - // - this.numericUpDownRegionStyleFontOutlineThickness.Location = new System.Drawing.Point(143, 516); - this.numericUpDownRegionStyleFontOutlineThickness.Maximum = new decimal(new int[] { - 3, - 0, - 0, - 0}); - this.numericUpDownRegionStyleFontOutlineThickness.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.numericUpDownRegionStyleFontOutlineThickness.Name = "numericUpDownRegionStyleFontOutlineThickness"; - this.numericUpDownRegionStyleFontOutlineThickness.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleFontOutlineThickness.TabIndex = 41; - this.numericUpDownRegionStyleFontOutlineThickness.Value = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.numericUpDownRegionStyleFontOutlineThickness.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleFontOutlineThickness_ValueChanged); - // - // labelRegionStyleFontOutlineThickness - // - this.labelRegionStyleFontOutlineThickness.AutoSize = true; - this.labelRegionStyleFontOutlineThickness.Location = new System.Drawing.Point(10, 518); - this.labelRegionStyleFontOutlineThickness.Name = "labelRegionStyleFontOutlineThickness"; - this.labelRegionStyleFontOutlineThickness.Size = new System.Drawing.Size(110, 13); - this.labelRegionStyleFontOutlineThickness.TabIndex = 40; - this.labelRegionStyleFontOutlineThickness.Text = "Font outline thickness"; - // - // numericUpDownRegionStyleFontOutlinePaletteId - // - this.numericUpDownRegionStyleFontOutlinePaletteId.Location = new System.Drawing.Point(143, 490); - this.numericUpDownRegionStyleFontOutlinePaletteId.Maximum = new decimal(new int[] { - 254, - 0, - 0, - 0}); - this.numericUpDownRegionStyleFontOutlinePaletteId.Name = "numericUpDownRegionStyleFontOutlinePaletteId"; - this.numericUpDownRegionStyleFontOutlinePaletteId.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleFontOutlinePaletteId.TabIndex = 39; - this.numericUpDownRegionStyleFontOutlinePaletteId.Value = new decimal(new int[] { - 8, - 0, - 0, - 0}); - this.numericUpDownRegionStyleFontOutlinePaletteId.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleFontOutlinePaletteId_ValueChanged); - // - // labelRegionStyleFontOutlinePaletteId - // - this.labelRegionStyleFontOutlinePaletteId.AutoSize = true; - this.labelRegionStyleFontOutlinePaletteId.Location = new System.Drawing.Point(10, 492); - this.labelRegionStyleFontOutlinePaletteId.Name = "labelRegionStyleFontOutlinePaletteId"; - this.labelRegionStyleFontOutlinePaletteId.Size = new System.Drawing.Size(108, 13); - this.labelRegionStyleFontOutlinePaletteId.TabIndex = 38; - this.labelRegionStyleFontOutlinePaletteId.Text = "Font outline palette id"; - // - // numericUpDownRegionStyleFontPaletteId - // - this.numericUpDownRegionStyleFontPaletteId.Location = new System.Drawing.Point(143, 464); - this.numericUpDownRegionStyleFontPaletteId.Maximum = new decimal(new int[] { - 254, - 0, - 0, - 0}); - this.numericUpDownRegionStyleFontPaletteId.Name = "numericUpDownRegionStyleFontPaletteId"; - this.numericUpDownRegionStyleFontPaletteId.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleFontPaletteId.TabIndex = 37; - this.numericUpDownRegionStyleFontPaletteId.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleFontPaletteId_ValueChanged); - // - // label39 - // - this.label39.AutoSize = true; - this.label39.Location = new System.Drawing.Point(10, 466); - this.label39.Name = "label39"; - this.label39.Size = new System.Drawing.Size(74, 13); - this.label39.TabIndex = 36; - this.label39.Text = "Font palette id"; - // - // numericUpDownRegionStyleFontStyle - // - this.numericUpDownRegionStyleFontStyle.Location = new System.Drawing.Point(143, 412); - this.numericUpDownRegionStyleFontStyle.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownRegionStyleFontStyle.Name = "numericUpDownRegionStyleFontStyle"; - this.numericUpDownRegionStyleFontStyle.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleFontStyle.TabIndex = 35; - this.numericUpDownRegionStyleFontStyle.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleFontStyle_ValueChanged); - // - // label38 - // - this.label38.AutoSize = true; - this.label38.Location = new System.Drawing.Point(10, 414); - this.label38.Name = "label38"; - this.label38.Size = new System.Drawing.Size(52, 13); - this.label38.TabIndex = 34; - this.label38.Text = "Font style"; - // - // numericUpDownRegionStyleFontIdRef - // - this.numericUpDownRegionStyleFontIdRef.Location = new System.Drawing.Point(143, 386); - this.numericUpDownRegionStyleFontIdRef.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownRegionStyleFontIdRef.Name = "numericUpDownRegionStyleFontIdRef"; - this.numericUpDownRegionStyleFontIdRef.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleFontIdRef.TabIndex = 33; - this.numericUpDownRegionStyleFontIdRef.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleFontIdRef_ValueChanged); - // - // label37 - // - this.label37.AutoSize = true; - this.label37.Location = new System.Drawing.Point(10, 388); - this.label37.Name = "label37"; - this.label37.Size = new System.Drawing.Size(54, 13); - this.label37.TabIndex = 32; - this.label37.Text = "Font id ref"; - // - // numericUpDownRegionStyleLineSpace - // - this.numericUpDownRegionStyleLineSpace.Location = new System.Drawing.Point(143, 360); - this.numericUpDownRegionStyleLineSpace.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownRegionStyleLineSpace.Name = "numericUpDownRegionStyleLineSpace"; - this.numericUpDownRegionStyleLineSpace.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleLineSpace.TabIndex = 31; - this.numericUpDownRegionStyleLineSpace.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleLineSpace_ValueChanged); - // - // label33 - // - this.label33.AutoSize = true; - this.label33.Location = new System.Drawing.Point(10, 362); - this.label33.Name = "label33"; - this.label33.Size = new System.Drawing.Size(59, 13); - this.label33.TabIndex = 30; - this.label33.Text = "Line space"; - // - // numericUpDownRegionStyleTextVerAlign - // - this.numericUpDownRegionStyleTextVerAlign.Location = new System.Drawing.Point(143, 334); - this.numericUpDownRegionStyleTextVerAlign.Maximum = new decimal(new int[] { - 7679, - 0, - 0, - 0}); - this.numericUpDownRegionStyleTextVerAlign.Name = "numericUpDownRegionStyleTextVerAlign"; - this.numericUpDownRegionStyleTextVerAlign.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleTextVerAlign.TabIndex = 29; - this.numericUpDownRegionStyleTextVerAlign.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTextVerAlign_ValueChanged); - // - // label34 - // - this.label34.AutoSize = true; - this.label34.Location = new System.Drawing.Point(10, 336); - this.label34.Name = "label34"; - this.label34.Size = new System.Drawing.Size(113, 13); - this.label34.TabIndex = 28; - this.label34.Text = "Text vertical alignment"; - // - // numericUpDownRegionStyleTextHorAlign - // - this.numericUpDownRegionStyleTextHorAlign.Location = new System.Drawing.Point(143, 308); - this.numericUpDownRegionStyleTextHorAlign.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownRegionStyleTextHorAlign.Name = "numericUpDownRegionStyleTextHorAlign"; - this.numericUpDownRegionStyleTextHorAlign.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleTextHorAlign.TabIndex = 27; - this.numericUpDownRegionStyleTextHorAlign.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTextHorAlign_ValueChanged); - // - // label35 - // - this.label35.AutoSize = true; - this.label35.Location = new System.Drawing.Point(10, 310); - this.label35.Name = "label35"; - this.label35.Size = new System.Drawing.Size(124, 13); - this.label35.TabIndex = 26; - this.label35.Text = "Text horizontal alignment"; - // - // numericUpDownRegionStyleTextFlow - // - this.numericUpDownRegionStyleTextFlow.Location = new System.Drawing.Point(143, 282); - this.numericUpDownRegionStyleTextFlow.Maximum = new decimal(new int[] { - 7679, - 0, - 0, - 0}); - this.numericUpDownRegionStyleTextFlow.Name = "numericUpDownRegionStyleTextFlow"; - this.numericUpDownRegionStyleTextFlow.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleTextFlow.TabIndex = 25; - this.numericUpDownRegionStyleTextFlow.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTextFlow_ValueChanged); - // - // label36 - // - this.label36.AutoSize = true; - this.label36.Location = new System.Drawing.Point(10, 284); - this.label36.Name = "label36"; - this.label36.Size = new System.Drawing.Size(50, 13); - this.label36.TabIndex = 24; - this.label36.Text = "Text flow"; - // - // numericUpDownRegionStyleTBHeight - // - this.numericUpDownRegionStyleTBHeight.Location = new System.Drawing.Point(143, 256); - this.numericUpDownRegionStyleTBHeight.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownRegionStyleTBHeight.Name = "numericUpDownRegionStyleTBHeight"; - this.numericUpDownRegionStyleTBHeight.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleTBHeight.TabIndex = 23; - this.numericUpDownRegionStyleTBHeight.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTBHeight_ValueChanged); - // - // label17 - // - this.label17.AutoSize = true; - this.label17.Location = new System.Drawing.Point(10, 258); - this.label17.Name = "label17"; - this.label17.Size = new System.Drawing.Size(80, 13); - this.label17.TabIndex = 22; - this.label17.Text = "Text box height"; - // - // numericUpDownRegionStyleTBWidth - // - this.numericUpDownRegionStyleTBWidth.Location = new System.Drawing.Point(143, 230); - this.numericUpDownRegionStyleTBWidth.Maximum = new decimal(new int[] { - 7679, - 0, - 0, - 0}); - this.numericUpDownRegionStyleTBWidth.Name = "numericUpDownRegionStyleTBWidth"; - this.numericUpDownRegionStyleTBWidth.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleTBWidth.TabIndex = 21; - this.numericUpDownRegionStyleTBWidth.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTBWidth_ValueChanged); - // - // label30 - // - this.label30.AutoSize = true; - this.label30.Location = new System.Drawing.Point(10, 232); - this.label30.Name = "label30"; - this.label30.Size = new System.Drawing.Size(76, 13); - this.label30.TabIndex = 20; - this.label30.Text = "Text box width"; - // - // numericUpDownRegionStyleTBVerPos - // - this.numericUpDownRegionStyleTBVerPos.Location = new System.Drawing.Point(143, 204); - this.numericUpDownRegionStyleTBVerPos.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownRegionStyleTBVerPos.Name = "numericUpDownRegionStyleTBVerPos"; - this.numericUpDownRegionStyleTBVerPos.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleTBVerPos.TabIndex = 19; - this.numericUpDownRegionStyleTBVerPos.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTBVerPos_ValueChanged); - // - // label31 - // - this.label31.AutoSize = true; - this.label31.Location = new System.Drawing.Point(10, 206); - this.label31.Name = "label31"; - this.label31.Size = new System.Drawing.Size(105, 13); - this.label31.TabIndex = 18; - this.label31.Text = "Text box vertical pos"; - // - // numericUpDownRegionStyleTBHorPos - // - this.numericUpDownRegionStyleTBHorPos.Location = new System.Drawing.Point(143, 178); - this.numericUpDownRegionStyleTBHorPos.Maximum = new decimal(new int[] { - 7679, - 0, - 0, - 0}); - this.numericUpDownRegionStyleTBHorPos.Name = "numericUpDownRegionStyleTBHorPos"; - this.numericUpDownRegionStyleTBHorPos.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleTBHorPos.TabIndex = 17; - this.numericUpDownRegionStyleTBHorPos.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTBHorPos_ValueChanged); - // - // label32 - // - this.label32.AutoSize = true; - this.label32.Location = new System.Drawing.Point(10, 180); - this.label32.Name = "label32"; - this.label32.Size = new System.Drawing.Size(116, 13); - this.label32.TabIndex = 16; - this.label32.Text = "Text box horizontal pos"; - // - // numericUpDownRegionStyleFontSize - // - this.numericUpDownRegionStyleFontSize.Location = new System.Drawing.Point(143, 438); - this.numericUpDownRegionStyleFontSize.Maximum = new decimal(new int[] { - 144, - 0, - 0, - 0}); - this.numericUpDownRegionStyleFontSize.Minimum = new decimal(new int[] { - 8, - 0, - 0, - 0}); - this.numericUpDownRegionStyleFontSize.Name = "numericUpDownRegionStyleFontSize"; - this.numericUpDownRegionStyleFontSize.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleFontSize.TabIndex = 15; - this.numericUpDownRegionStyleFontSize.Value = new decimal(new int[] { - 8, - 0, - 0, - 0}); - this.numericUpDownRegionStyleFontSize.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleFontSize_ValueChanged); - // - // label12 - // - this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(10, 440); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(49, 13); - this.label12.TabIndex = 14; - this.label12.Text = "Font size"; - // - // numericUpDownRegionStylePaletteEntryId - // - this.numericUpDownRegionStylePaletteEntryId.Location = new System.Drawing.Point(143, 152); - this.numericUpDownRegionStylePaletteEntryId.Maximum = new decimal(new int[] { - 254, - 0, - 0, - 0}); - this.numericUpDownRegionStylePaletteEntryId.Name = "numericUpDownRegionStylePaletteEntryId"; - this.numericUpDownRegionStylePaletteEntryId.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStylePaletteEntryId.TabIndex = 13; - this.numericUpDownRegionStylePaletteEntryId.ValueChanged += new System.EventHandler(this.numericUpDownRegionStylePaletteEntryId_ValueChanged); - // - // label11 - // - this.label11.AutoSize = true; - this.label11.Location = new System.Drawing.Point(10, 154); - this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(90, 13); - this.label11.TabIndex = 12; - this.label11.Text = "Bg palette entryId"; - // - // numericUpDownRegionStyleHeight - // - this.numericUpDownRegionStyleHeight.Location = new System.Drawing.Point(143, 126); - this.numericUpDownRegionStyleHeight.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownRegionStyleHeight.Name = "numericUpDownRegionStyleHeight"; - this.numericUpDownRegionStyleHeight.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleHeight.TabIndex = 11; - this.numericUpDownRegionStyleHeight.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleHeight_ValueChanged); - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(10, 128); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(38, 13); - this.label9.TabIndex = 10; - this.label9.Text = "Height"; - // - // numericUpDownRegionStyleWidth - // - this.numericUpDownRegionStyleWidth.Location = new System.Drawing.Point(143, 100); - this.numericUpDownRegionStyleWidth.Maximum = new decimal(new int[] { - 7679, - 0, - 0, - 0}); - this.numericUpDownRegionStyleWidth.Name = "numericUpDownRegionStyleWidth"; - this.numericUpDownRegionStyleWidth.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleWidth.TabIndex = 9; - this.numericUpDownRegionStyleWidth.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleWidth_ValueChanged); - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(10, 102); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(35, 13); - this.label10.TabIndex = 8; - this.label10.Text = "Width"; - // - // numericUpDownRegionStyleVPos - // - this.numericUpDownRegionStyleVPos.Location = new System.Drawing.Point(143, 74); - this.numericUpDownRegionStyleVPos.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownRegionStyleVPos.Name = "numericUpDownRegionStyleVPos"; - this.numericUpDownRegionStyleVPos.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleVPos.TabIndex = 7; - this.numericUpDownRegionStyleVPos.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleVPos_ValueChanged); - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(10, 76); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(81, 13); - this.label8.TabIndex = 6; - this.label8.Text = "Vertical position"; - // - // numericUpDownRegionStyleHPos - // - this.numericUpDownRegionStyleHPos.Location = new System.Drawing.Point(143, 48); - this.numericUpDownRegionStyleHPos.Maximum = new decimal(new int[] { - 7679, - 0, - 0, - 0}); - this.numericUpDownRegionStyleHPos.Name = "numericUpDownRegionStyleHPos"; - this.numericUpDownRegionStyleHPos.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleHPos.TabIndex = 5; - this.numericUpDownRegionStyleHPos.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleHPos_ValueChanged); - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(10, 50); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(93, 13); - this.label7.TabIndex = 4; - this.label7.Text = "Horizontal position"; - // - // numericUpDownRegionStyleId - // - this.numericUpDownRegionStyleId.Location = new System.Drawing.Point(143, 22); - this.numericUpDownRegionStyleId.Maximum = new decimal(new int[] { - 59, - 0, - 0, - 0}); - this.numericUpDownRegionStyleId.Name = "numericUpDownRegionStyleId"; - this.numericUpDownRegionStyleId.Size = new System.Drawing.Size(76, 20); - this.numericUpDownRegionStyleId.TabIndex = 3; - this.numericUpDownRegionStyleId.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleId_ValueChanged); - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(10, 24); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(39, 13); - this.label6.TabIndex = 2; - this.label6.Text = "StyleId"; - // - // groupBoxPropertiesPalette - // - this.groupBoxPropertiesPalette.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxPropertiesPalette.Controls.Add(this.label47); - this.groupBoxPropertiesPalette.Controls.Add(this.panelPaletteColor); - this.groupBoxPropertiesPalette.Controls.Add(this.buttonColor); - this.groupBoxPropertiesPalette.Controls.Add(this.numericUpDownPaletteOpacity); - this.groupBoxPropertiesPalette.Controls.Add(this.label5); - this.groupBoxPropertiesPalette.Controls.Add(this.numericUpDownPaletteCb); - this.groupBoxPropertiesPalette.Controls.Add(this.label4); - this.groupBoxPropertiesPalette.Controls.Add(this.numericUpDownPaletteCr); - this.groupBoxPropertiesPalette.Controls.Add(this.label3); - this.groupBoxPropertiesPalette.Controls.Add(this.numericUpDownPaletteY); - this.groupBoxPropertiesPalette.Controls.Add(this.label2); - this.groupBoxPropertiesPalette.Controls.Add(this.numericUpDownPaletteEntry); - this.groupBoxPropertiesPalette.Controls.Add(this.label1); - this.groupBoxPropertiesPalette.Location = new System.Drawing.Point(231, 3); - this.groupBoxPropertiesPalette.Name = "groupBoxPropertiesPalette"; - this.groupBoxPropertiesPalette.Size = new System.Drawing.Size(261, 211); - this.groupBoxPropertiesPalette.TabIndex = 9; - this.groupBoxPropertiesPalette.TabStop = false; - this.groupBoxPropertiesPalette.Text = "Properties: Region palette"; - this.groupBoxPropertiesPalette.Visible = false; - // - // label47 - // - this.label47.AutoSize = true; - this.label47.Location = new System.Drawing.Point(164, 133); - this.label47.Name = "label47"; - this.label47.Size = new System.Drawing.Size(137, 13); - this.label47.TabIndex = 15; - this.label47.Text = "0 is transparent, 255 is solid"; - // - // panelPaletteColor - // - this.panelPaletteColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelPaletteColor.Location = new System.Drawing.Point(137, 174); - this.panelPaletteColor.Name = "panelPaletteColor"; - this.panelPaletteColor.Size = new System.Drawing.Size(21, 20); - this.panelPaletteColor.TabIndex = 14; - // - // buttonColor - // - this.buttonColor.Location = new System.Drawing.Point(10, 173); - this.buttonColor.Name = "buttonColor"; - this.buttonColor.Size = new System.Drawing.Size(121, 21); - this.buttonColor.TabIndex = 13; - this.buttonColor.Text = "Pick color"; - this.buttonColor.UseVisualStyleBackColor = true; - this.buttonColor.Click += new System.EventHandler(this.buttonColor_Click); - // - // numericUpDownPaletteOpacity - // - this.numericUpDownPaletteOpacity.Location = new System.Drawing.Point(82, 131); - this.numericUpDownPaletteOpacity.Maximum = new decimal(new int[] { - 255, - 0, - 0, - 0}); - this.numericUpDownPaletteOpacity.Name = "numericUpDownPaletteOpacity"; - this.numericUpDownPaletteOpacity.Size = new System.Drawing.Size(76, 20); - this.numericUpDownPaletteOpacity.TabIndex = 9; - this.numericUpDownPaletteOpacity.ValueChanged += new System.EventHandler(this.numericUpDownPaletteOpacity_ValueChanged); - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(7, 133); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(43, 13); - this.label5.TabIndex = 8; - this.label5.Text = "Opacity"; - // - // numericUpDownPaletteCb - // - this.numericUpDownPaletteCb.Location = new System.Drawing.Point(82, 105); - this.numericUpDownPaletteCb.Maximum = new decimal(new int[] { - 240, - 0, - 0, - 0}); - this.numericUpDownPaletteCb.Name = "numericUpDownPaletteCb"; - this.numericUpDownPaletteCb.Size = new System.Drawing.Size(76, 20); - this.numericUpDownPaletteCb.TabIndex = 7; - this.numericUpDownPaletteCb.ValueChanged += new System.EventHandler(this.numericUpDownPaletteCb_ValueChanged); - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(7, 107); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(20, 13); - this.label4.TabIndex = 6; - this.label4.Text = "Cb"; - // - // numericUpDownPaletteCr - // - this.numericUpDownPaletteCr.Location = new System.Drawing.Point(82, 79); - this.numericUpDownPaletteCr.Maximum = new decimal(new int[] { - 240, - 0, - 0, - 0}); - this.numericUpDownPaletteCr.Minimum = new decimal(new int[] { - 16, - 0, - 0, - 0}); - this.numericUpDownPaletteCr.Name = "numericUpDownPaletteCr"; - this.numericUpDownPaletteCr.Size = new System.Drawing.Size(76, 20); - this.numericUpDownPaletteCr.TabIndex = 5; - this.numericUpDownPaletteCr.Value = new decimal(new int[] { - 16, - 0, - 0, - 0}); - this.numericUpDownPaletteCr.ValueChanged += new System.EventHandler(this.numericUpDownPaletteCr_ValueChanged); - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(7, 81); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(17, 13); - this.label3.TabIndex = 4; - this.label3.Text = "Cr"; - // - // numericUpDownPaletteY - // - this.numericUpDownPaletteY.Location = new System.Drawing.Point(82, 53); - this.numericUpDownPaletteY.Maximum = new decimal(new int[] { - 235, - 0, - 0, - 0}); - this.numericUpDownPaletteY.Minimum = new decimal(new int[] { - 16, - 0, - 0, - 0}); - this.numericUpDownPaletteY.Name = "numericUpDownPaletteY"; - this.numericUpDownPaletteY.Size = new System.Drawing.Size(76, 20); - this.numericUpDownPaletteY.TabIndex = 3; - this.numericUpDownPaletteY.Value = new decimal(new int[] { - 16, - 0, - 0, - 0}); - this.numericUpDownPaletteY.ValueChanged += new System.EventHandler(this.numericUpDownPaletteY_ValueChanged); - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(7, 55); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(14, 13); - this.label2.TabIndex = 2; - this.label2.Text = "Y"; - // - // numericUpDownPaletteEntry - // - this.numericUpDownPaletteEntry.Location = new System.Drawing.Point(82, 27); - this.numericUpDownPaletteEntry.Maximum = new decimal(new int[] { - 254, - 0, - 0, - 0}); - this.numericUpDownPaletteEntry.Name = "numericUpDownPaletteEntry"; - this.numericUpDownPaletteEntry.Size = new System.Drawing.Size(76, 20); - this.numericUpDownPaletteEntry.TabIndex = 1; - this.numericUpDownPaletteEntry.ValueChanged += new System.EventHandler(this.numericUpDownPaletteEntry_ValueChanged); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(7, 29); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(40, 13); - this.label1.TabIndex = 0; - this.label1.Text = "EntryId"; - // - // groupBoxPropertiesUserStyle - // - this.groupBoxPropertiesUserStyle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleLineSpaceDelta); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label28); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleLineSpaceIncDec); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label29); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBHeightDelta); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label27); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBHeightIncDec); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label25); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBWidthDelta); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label26); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBWidthIncDec); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label19); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBVerPosDelta); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label20); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBVerPosDir); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label21); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBHorPosDelta); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label22); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBHorPosDir); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label23); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleFontSizeDelta); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label24); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleFontSizeIncDec); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label13); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleVerPosDelta); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label14); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleVerPosDir); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label15); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleHorPosDelta); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label16); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleHorPosDir); - this.groupBoxPropertiesUserStyle.Controls.Add(this.labelUserStyleHorPosDir); - this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleId); - this.groupBoxPropertiesUserStyle.Controls.Add(this.label18); - this.groupBoxPropertiesUserStyle.Location = new System.Drawing.Point(416, 12); - this.groupBoxPropertiesUserStyle.Name = "groupBoxPropertiesUserStyle"; - this.groupBoxPropertiesUserStyle.Size = new System.Drawing.Size(264, 505); - this.groupBoxPropertiesUserStyle.TabIndex = 10; - this.groupBoxPropertiesUserStyle.TabStop = false; - this.groupBoxPropertiesUserStyle.Text = "Properties: User style"; - this.groupBoxPropertiesUserStyle.Visible = false; - // - // numericUpDownUserStyleLineSpaceDelta - // - this.numericUpDownUserStyleLineSpaceDelta.Location = new System.Drawing.Point(184, 438); - this.numericUpDownUserStyleLineSpaceDelta.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownUserStyleLineSpaceDelta.Name = "numericUpDownUserStyleLineSpaceDelta"; - this.numericUpDownUserStyleLineSpaceDelta.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleLineSpaceDelta.TabIndex = 47; - this.numericUpDownUserStyleLineSpaceDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleLineSpaceDelta_ValueChanged); - // - // label28 - // - this.label28.AutoSize = true; - this.label28.Location = new System.Drawing.Point(11, 440); - this.label28.Name = "label28"; - this.label28.Size = new System.Drawing.Size(85, 13); - this.label28.TabIndex = 46; - this.label28.Text = "Line space delta"; - // - // numericUpDownUserStyleLineSpaceIncDec - // - this.numericUpDownUserStyleLineSpaceIncDec.Location = new System.Drawing.Point(184, 412); - this.numericUpDownUserStyleLineSpaceIncDec.Maximum = new decimal(new int[] { - 254, - 0, - 0, - 0}); - this.numericUpDownUserStyleLineSpaceIncDec.Name = "numericUpDownUserStyleLineSpaceIncDec"; - this.numericUpDownUserStyleLineSpaceIncDec.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleLineSpaceIncDec.TabIndex = 45; - this.numericUpDownUserStyleLineSpaceIncDec.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleLineSpaceIncDec_ValueChanged); - // - // label29 - // - this.label29.AutoSize = true; - this.label29.Location = new System.Drawing.Point(11, 414); - this.label29.Name = "label29"; - this.label29.Size = new System.Drawing.Size(151, 13); - this.label29.TabIndex = 44; - this.label29.Text = "Line space increase/decrease"; - // - // numericUpDownUserStyleTBHeightDelta - // - this.numericUpDownUserStyleTBHeightDelta.Location = new System.Drawing.Point(184, 386); - this.numericUpDownUserStyleTBHeightDelta.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownUserStyleTBHeightDelta.Name = "numericUpDownUserStyleTBHeightDelta"; - this.numericUpDownUserStyleTBHeightDelta.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleTBHeightDelta.TabIndex = 43; - this.numericUpDownUserStyleTBHeightDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBHeightDelta_ValueChanged); - // - // label27 - // - this.label27.AutoSize = true; - this.label27.Location = new System.Drawing.Point(11, 388); - this.label27.Name = "label27"; - this.label27.Size = new System.Drawing.Size(106, 13); - this.label27.TabIndex = 42; - this.label27.Text = "Text box height delta"; - // - // numericUpDownUserStyleTBHeightIncDec - // - this.numericUpDownUserStyleTBHeightIncDec.Location = new System.Drawing.Point(184, 360); - this.numericUpDownUserStyleTBHeightIncDec.Maximum = new decimal(new int[] { - 254, - 0, - 0, - 0}); - this.numericUpDownUserStyleTBHeightIncDec.Name = "numericUpDownUserStyleTBHeightIncDec"; - this.numericUpDownUserStyleTBHeightIncDec.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleTBHeightIncDec.TabIndex = 41; - this.numericUpDownUserStyleTBHeightIncDec.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBHeightIncDec_ValueChanged); - // - // label25 - // - this.label25.AutoSize = true; - this.label25.Location = new System.Drawing.Point(11, 362); - this.label25.Name = "label25"; - this.label25.Size = new System.Drawing.Size(172, 13); - this.label25.TabIndex = 40; - this.label25.Text = "Text box height increase/decrease"; - // - // numericUpDownUserStyleTBWidthDelta - // - this.numericUpDownUserStyleTBWidthDelta.Location = new System.Drawing.Point(184, 334); - this.numericUpDownUserStyleTBWidthDelta.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownUserStyleTBWidthDelta.Name = "numericUpDownUserStyleTBWidthDelta"; - this.numericUpDownUserStyleTBWidthDelta.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleTBWidthDelta.TabIndex = 39; - this.numericUpDownUserStyleTBWidthDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBWidthDelta_ValueChanged); - // - // label26 - // - this.label26.AutoSize = true; - this.label26.Location = new System.Drawing.Point(11, 336); - this.label26.Name = "label26"; - this.label26.Size = new System.Drawing.Size(102, 13); - this.label26.TabIndex = 38; - this.label26.Text = "Text box width delta"; - // - // numericUpDownUserStyleTBWidthIncDec - // - this.numericUpDownUserStyleTBWidthIncDec.Location = new System.Drawing.Point(184, 308); - this.numericUpDownUserStyleTBWidthIncDec.Maximum = new decimal(new int[] { - 254, - 0, - 0, - 0}); - this.numericUpDownUserStyleTBWidthIncDec.Name = "numericUpDownUserStyleTBWidthIncDec"; - this.numericUpDownUserStyleTBWidthIncDec.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleTBWidthIncDec.TabIndex = 37; - this.numericUpDownUserStyleTBWidthIncDec.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBWidthIncDec_ValueChanged); - // - // label19 - // - this.label19.AutoSize = true; - this.label19.Location = new System.Drawing.Point(11, 310); - this.label19.Name = "label19"; - this.label19.Size = new System.Drawing.Size(168, 13); - this.label19.TabIndex = 36; - this.label19.Text = "Text box width increase/decrease"; - // - // numericUpDownUserStyleTBVerPosDelta - // - this.numericUpDownUserStyleTBVerPosDelta.Location = new System.Drawing.Point(184, 282); - this.numericUpDownUserStyleTBVerPosDelta.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownUserStyleTBVerPosDelta.Name = "numericUpDownUserStyleTBVerPosDelta"; - this.numericUpDownUserStyleTBVerPosDelta.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleTBVerPosDelta.TabIndex = 35; - this.numericUpDownUserStyleTBVerPosDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBVerPosDelta_ValueChanged); - // - // label20 - // - this.label20.AutoSize = true; - this.label20.Location = new System.Drawing.Point(11, 284); - this.label20.Name = "label20"; - this.label20.Size = new System.Drawing.Size(131, 13); - this.label20.TabIndex = 34; - this.label20.Text = "Text box vertical pos delta"; - // - // numericUpDownUserStyleTBVerPosDir - // - this.numericUpDownUserStyleTBVerPosDir.Location = new System.Drawing.Point(184, 256); - this.numericUpDownUserStyleTBVerPosDir.Maximum = new decimal(new int[] { - 7679, - 0, - 0, - 0}); - this.numericUpDownUserStyleTBVerPosDir.Name = "numericUpDownUserStyleTBVerPosDir"; - this.numericUpDownUserStyleTBVerPosDir.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleTBVerPosDir.TabIndex = 33; - this.numericUpDownUserStyleTBVerPosDir.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBVerPosDir_ValueChanged); - // - // label21 - // - this.label21.AutoSize = true; - this.label21.Location = new System.Drawing.Point(11, 258); - this.label21.Name = "label21"; - this.label21.Size = new System.Drawing.Size(148, 13); - this.label21.TabIndex = 32; - this.label21.Text = "Text box vertical pos direction"; - // - // numericUpDownUserStyleTBHorPosDelta - // - this.numericUpDownUserStyleTBHorPosDelta.Location = new System.Drawing.Point(184, 230); - this.numericUpDownUserStyleTBHorPosDelta.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownUserStyleTBHorPosDelta.Name = "numericUpDownUserStyleTBHorPosDelta"; - this.numericUpDownUserStyleTBHorPosDelta.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleTBHorPosDelta.TabIndex = 31; - this.numericUpDownUserStyleTBHorPosDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBHorPosDelta_ValueChanged); - // - // label22 - // - this.label22.AutoSize = true; - this.label22.Location = new System.Drawing.Point(11, 232); - this.label22.Name = "label22"; - this.label22.Size = new System.Drawing.Size(142, 13); - this.label22.TabIndex = 30; - this.label22.Text = "Text box horizontal pos delta"; - // - // numericUpDownUserStyleTBHorPosDir - // - this.numericUpDownUserStyleTBHorPosDir.Location = new System.Drawing.Point(184, 204); - this.numericUpDownUserStyleTBHorPosDir.Maximum = new decimal(new int[] { - 7679, - 0, - 0, - 0}); - this.numericUpDownUserStyleTBHorPosDir.Name = "numericUpDownUserStyleTBHorPosDir"; - this.numericUpDownUserStyleTBHorPosDir.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleTBHorPosDir.TabIndex = 29; - this.numericUpDownUserStyleTBHorPosDir.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBHorPosDir_ValueChanged); - // - // label23 - // - this.label23.AutoSize = true; - this.label23.Location = new System.Drawing.Point(11, 206); - this.label23.Name = "label23"; - this.label23.Size = new System.Drawing.Size(159, 13); - this.label23.TabIndex = 28; - this.label23.Text = "Text box horizontal pos direction"; - // - // numericUpDownUserStyleFontSizeDelta - // - this.numericUpDownUserStyleFontSizeDelta.Location = new System.Drawing.Point(184, 178); - this.numericUpDownUserStyleFontSizeDelta.Maximum = new decimal(new int[] { - 59, - 0, - 0, - 0}); - this.numericUpDownUserStyleFontSizeDelta.Name = "numericUpDownUserStyleFontSizeDelta"; - this.numericUpDownUserStyleFontSizeDelta.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleFontSizeDelta.TabIndex = 27; - this.numericUpDownUserStyleFontSizeDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleFontSizeDelta_ValueChanged); - // - // label24 - // - this.label24.AutoSize = true; - this.label24.Location = new System.Drawing.Point(11, 180); - this.label24.Name = "label24"; - this.label24.Size = new System.Drawing.Size(75, 13); - this.label24.TabIndex = 26; - this.label24.Text = "Font size delta"; - // - // numericUpDownUserStyleFontSizeIncDec - // - this.numericUpDownUserStyleFontSizeIncDec.Location = new System.Drawing.Point(184, 152); - this.numericUpDownUserStyleFontSizeIncDec.Maximum = new decimal(new int[] { - 254, - 0, - 0, - 0}); - this.numericUpDownUserStyleFontSizeIncDec.Name = "numericUpDownUserStyleFontSizeIncDec"; - this.numericUpDownUserStyleFontSizeIncDec.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleFontSizeIncDec.TabIndex = 25; - this.numericUpDownUserStyleFontSizeIncDec.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleFontSizeIncDec_ValueChanged); - // - // label13 - // - this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(11, 154); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(141, 13); - this.label13.TabIndex = 24; - this.label13.Text = "Font size increase/decrease"; - // - // numericUpDownUserStyleVerPosDelta - // - this.numericUpDownUserStyleVerPosDelta.Location = new System.Drawing.Point(184, 126); - this.numericUpDownUserStyleVerPosDelta.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownUserStyleVerPosDelta.Name = "numericUpDownUserStyleVerPosDelta"; - this.numericUpDownUserStyleVerPosDelta.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleVerPosDelta.TabIndex = 23; - this.numericUpDownUserStyleVerPosDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleVerPosDelta_ValueChanged); - // - // label14 - // - this.label14.AutoSize = true; - this.label14.Location = new System.Drawing.Point(11, 128); - this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(107, 13); - this.label14.TabIndex = 22; - this.label14.Text = "Vertical position delta"; - // - // numericUpDownUserStyleVerPosDir - // - this.numericUpDownUserStyleVerPosDir.Location = new System.Drawing.Point(184, 100); - this.numericUpDownUserStyleVerPosDir.Maximum = new decimal(new int[] { - 7679, - 0, - 0, - 0}); - this.numericUpDownUserStyleVerPosDir.Name = "numericUpDownUserStyleVerPosDir"; - this.numericUpDownUserStyleVerPosDir.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleVerPosDir.TabIndex = 21; - this.numericUpDownUserStyleVerPosDir.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleVerPosDir_ValueChanged); - // - // label15 - // - this.label15.AutoSize = true; - this.label15.Location = new System.Drawing.Point(11, 102); - this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(124, 13); - this.label15.TabIndex = 20; - this.label15.Text = "Vertical position direction"; - // - // numericUpDownUserStyleHorPosDelta - // - this.numericUpDownUserStyleHorPosDelta.Location = new System.Drawing.Point(184, 74); - this.numericUpDownUserStyleHorPosDelta.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownUserStyleHorPosDelta.Name = "numericUpDownUserStyleHorPosDelta"; - this.numericUpDownUserStyleHorPosDelta.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleHorPosDelta.TabIndex = 19; - this.numericUpDownUserStyleHorPosDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleHorPosDelta_ValueChanged); - // - // label16 - // - this.label16.AutoSize = true; - this.label16.Location = new System.Drawing.Point(11, 76); - this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(119, 13); - this.label16.TabIndex = 18; - this.label16.Text = "Horizontal position delta"; - // - // numericUpDownUserStyleHorPosDir - // - this.numericUpDownUserStyleHorPosDir.Location = new System.Drawing.Point(184, 48); - this.numericUpDownUserStyleHorPosDir.Maximum = new decimal(new int[] { - 7679, - 0, - 0, - 0}); - this.numericUpDownUserStyleHorPosDir.Name = "numericUpDownUserStyleHorPosDir"; - this.numericUpDownUserStyleHorPosDir.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleHorPosDir.TabIndex = 17; - this.numericUpDownUserStyleHorPosDir.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleHorPosDir_ValueChanged); - // - // labelUserStyleHorPosDir - // - this.labelUserStyleHorPosDir.AutoSize = true; - this.labelUserStyleHorPosDir.Location = new System.Drawing.Point(11, 50); - this.labelUserStyleHorPosDir.Name = "labelUserStyleHorPosDir"; - this.labelUserStyleHorPosDir.Size = new System.Drawing.Size(136, 13); - this.labelUserStyleHorPosDir.TabIndex = 16; - this.labelUserStyleHorPosDir.Text = "Horizontal position direction"; - // - // numericUpDownUserStyleId - // - this.numericUpDownUserStyleId.Location = new System.Drawing.Point(184, 22); - this.numericUpDownUserStyleId.Maximum = new decimal(new int[] { - 59, - 0, - 0, - 0}); - this.numericUpDownUserStyleId.Name = "numericUpDownUserStyleId"; - this.numericUpDownUserStyleId.Size = new System.Drawing.Size(76, 20); - this.numericUpDownUserStyleId.TabIndex = 15; - this.numericUpDownUserStyleId.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleId_ValueChanged); - // - // label18 - // - this.label18.AutoSize = true; - this.label18.Location = new System.Drawing.Point(11, 24); - this.label18.Name = "label18"; - this.label18.Size = new System.Drawing.Size(39, 13); - this.label18.TabIndex = 14; - this.label18.Text = "StyleId"; - // - // buttonSaveAsM2ts - // - this.buttonSaveAsM2ts.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSaveAsM2ts.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonSaveAsM2ts.Location = new System.Drawing.Point(478, 577); - this.buttonSaveAsM2ts.Name = "buttonSaveAsM2ts"; - this.buttonSaveAsM2ts.Size = new System.Drawing.Size(149, 23); - this.buttonSaveAsM2ts.TabIndex = 113; - this.buttonSaveAsM2ts.Text = "Write as M2TS packets..."; - this.buttonSaveAsM2ts.UseVisualStyleBackColor = true; - this.buttonSaveAsM2ts.Visible = false; - this.buttonSaveAsM2ts.Click += new System.EventHandler(this.buttonSaveAsM2ts_Click); - // - // groupBoxPresentationSegmentRegion - // - this.groupBoxPresentationSegmentRegion.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxPresentationSegmentRegion.Controls.Add(this.numericUpDownSubRegionStyleIdRef); - this.groupBoxPresentationSegmentRegion.Controls.Add(this.label40); - this.groupBoxPresentationSegmentRegion.Controls.Add(this.checkBoxSubRegionForced); - this.groupBoxPresentationSegmentRegion.Controls.Add(this.checkBoxSubRegionContinuous); - this.groupBoxPresentationSegmentRegion.Location = new System.Drawing.Point(404, 4); - this.groupBoxPresentationSegmentRegion.Name = "groupBoxPresentationSegmentRegion"; - this.groupBoxPresentationSegmentRegion.Size = new System.Drawing.Size(213, 129); - this.groupBoxPresentationSegmentRegion.TabIndex = 15; - this.groupBoxPresentationSegmentRegion.TabStop = false; - this.groupBoxPresentationSegmentRegion.Text = "Properties: Subtitle region"; - this.groupBoxPresentationSegmentRegion.Visible = false; - // - // numericUpDownSubRegionStyleIdRef - // - this.numericUpDownSubRegionStyleIdRef.Location = new System.Drawing.Point(106, 74); - this.numericUpDownSubRegionStyleIdRef.Maximum = new decimal(new int[] { - 4319, - 0, - 0, - 0}); - this.numericUpDownSubRegionStyleIdRef.Name = "numericUpDownSubRegionStyleIdRef"; - this.numericUpDownSubRegionStyleIdRef.Size = new System.Drawing.Size(76, 20); - this.numericUpDownSubRegionStyleIdRef.TabIndex = 35; - this.numericUpDownSubRegionStyleIdRef.ValueChanged += new System.EventHandler(this.numericUpDownSubRegionStyleIdRef_ValueChanged); - // - // label40 - // - this.label40.AutoSize = true; - this.label40.Location = new System.Drawing.Point(8, 76); - this.label40.Name = "label40"; - this.label40.Size = new System.Drawing.Size(91, 13); - this.label40.TabIndex = 34; - this.label40.Text = "Region style id ref"; - // - // checkBoxSubRegionForced - // - this.checkBoxSubRegionForced.AutoSize = true; - this.checkBoxSubRegionForced.Location = new System.Drawing.Point(106, 50); - this.checkBoxSubRegionForced.Name = "checkBoxSubRegionForced"; - this.checkBoxSubRegionForced.Size = new System.Drawing.Size(59, 17); - this.checkBoxSubRegionForced.TabIndex = 11; - this.checkBoxSubRegionForced.Text = "Forced"; - this.checkBoxSubRegionForced.UseVisualStyleBackColor = true; - this.checkBoxSubRegionForced.CheckedChanged += new System.EventHandler(this.checkBoxSubRegionForced_CheckedChanged); - // - // checkBoxSubRegionContinuous - // - this.checkBoxSubRegionContinuous.AutoSize = true; - this.checkBoxSubRegionContinuous.Location = new System.Drawing.Point(106, 27); - this.checkBoxSubRegionContinuous.Name = "checkBoxSubRegionContinuous"; - this.checkBoxSubRegionContinuous.Size = new System.Drawing.Size(126, 17); - this.checkBoxSubRegionContinuous.TabIndex = 10; - this.checkBoxSubRegionContinuous.Text = "Continuous from prev"; - this.checkBoxSubRegionContinuous.UseVisualStyleBackColor = true; - this.checkBoxSubRegionContinuous.CheckedChanged += new System.EventHandler(this.checkBoxSubRegionContinuous_CheckedChanged); - // - // contextMenuStripAddPalette - // - this.contextMenuStripAddPalette.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.addPaletteToolStripMenuItem}); - this.contextMenuStripAddPalette.Name = "contextMenuStripAddPalette"; - this.contextMenuStripAddPalette.Size = new System.Drawing.Size(136, 26); - // - // addPaletteToolStripMenuItem - // - this.addPaletteToolStripMenuItem.Name = "addPaletteToolStripMenuItem"; - this.addPaletteToolStripMenuItem.Size = new System.Drawing.Size(135, 22); - this.addPaletteToolStripMenuItem.Text = "Add palette"; - this.addPaletteToolStripMenuItem.Click += new System.EventHandler(this.addPaletteToolStripMenuItem_Click); - // - // groupBoxFontStyle - // - this.groupBoxFontStyle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxFontStyle.Controls.Add(this.label43); - this.groupBoxFontStyle.Controls.Add(this.label42); - this.groupBoxFontStyle.Controls.Add(this.comboBoxChangeFontStyleOutlineThickness); - this.groupBoxFontStyle.Controls.Add(this.comboBoxChangeFontStyleFontStyle); - this.groupBoxFontStyle.Controls.Add(this.numericUpDownChangeFontStyleOutlinePaletteId); - this.groupBoxFontStyle.Controls.Add(this.label41); - this.groupBoxFontStyle.Location = new System.Drawing.Point(16, 471); - this.groupBoxFontStyle.Name = "groupBoxFontStyle"; - this.groupBoxFontStyle.Size = new System.Drawing.Size(230, 133); - this.groupBoxFontStyle.TabIndex = 36; - this.groupBoxFontStyle.TabStop = false; - this.groupBoxFontStyle.Text = "Properties: Subtitle font style"; - this.groupBoxFontStyle.Visible = false; - // - // label43 - // - this.label43.AutoSize = true; - this.label43.Location = new System.Drawing.Point(6, 79); - this.label43.Name = "label43"; - this.label43.Size = new System.Drawing.Size(110, 13); - this.label43.TabIndex = 39; - this.label43.Text = "Font outline thickness"; - // - // label42 - // - this.label42.AutoSize = true; - this.label42.Location = new System.Drawing.Point(6, 26); - this.label42.Name = "label42"; - this.label42.Size = new System.Drawing.Size(52, 13); - this.label42.TabIndex = 38; - this.label42.Text = "Font style"; - // - // comboBoxChangeFontStyleOutlineThickness - // - this.comboBoxChangeFontStyleOutlineThickness.FormattingEnabled = true; - this.comboBoxChangeFontStyleOutlineThickness.Items.AddRange(new object[] { - "Thin border", - "Medium border", - "Thick border"}); - this.comboBoxChangeFontStyleOutlineThickness.Location = new System.Drawing.Point(129, 76); - this.comboBoxChangeFontStyleOutlineThickness.Name = "comboBoxChangeFontStyleOutlineThickness"; - this.comboBoxChangeFontStyleOutlineThickness.Size = new System.Drawing.Size(186, 21); - this.comboBoxChangeFontStyleOutlineThickness.TabIndex = 37; - // - // comboBoxChangeFontStyleFontStyle - // - this.comboBoxChangeFontStyleFontStyle.FormattingEnabled = true; - this.comboBoxChangeFontStyleFontStyle.Items.AddRange(new object[] { - "Normal", - "Bold", - "Italic", - "Bold and Italic", - "Outline-bordered", - "Bold and Outline-bordered", - "Italic and Outline-bordered", - "Bold and Italic and Outline-bordered"}); - this.comboBoxChangeFontStyleFontStyle.Location = new System.Drawing.Point(129, 23); - this.comboBoxChangeFontStyleFontStyle.Name = "comboBoxChangeFontStyleFontStyle"; - this.comboBoxChangeFontStyleFontStyle.Size = new System.Drawing.Size(186, 21); - this.comboBoxChangeFontStyleFontStyle.TabIndex = 36; - // - // numericUpDownChangeFontStyleOutlinePaletteId - // - this.numericUpDownChangeFontStyleOutlinePaletteId.Location = new System.Drawing.Point(129, 50); - this.numericUpDownChangeFontStyleOutlinePaletteId.Maximum = new decimal(new int[] { - 254, - 0, - 0, - 0}); - this.numericUpDownChangeFontStyleOutlinePaletteId.Name = "numericUpDownChangeFontStyleOutlinePaletteId"; - this.numericUpDownChangeFontStyleOutlinePaletteId.Size = new System.Drawing.Size(76, 20); - this.numericUpDownChangeFontStyleOutlinePaletteId.TabIndex = 35; - // - // label41 - // - this.label41.AutoSize = true; - this.label41.Location = new System.Drawing.Point(7, 52); - this.label41.Name = "label41"; - this.label41.Size = new System.Drawing.Size(108, 13); - this.label41.TabIndex = 34; - this.label41.Text = "Font outline palette id"; - // - // groupBoxChangeFontSize - // - this.groupBoxChangeFontSize.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxChangeFontSize.Controls.Add(this.groupBoxChangeFontColor); - this.groupBoxChangeFontSize.Controls.Add(this.numericUpDownChangeFontSize); - this.groupBoxChangeFontSize.Controls.Add(this.label46); - this.groupBoxChangeFontSize.Location = new System.Drawing.Point(355, 510); - this.groupBoxChangeFontSize.Name = "groupBoxChangeFontSize"; - this.groupBoxChangeFontSize.Size = new System.Drawing.Size(183, 133); - this.groupBoxChangeFontSize.TabIndex = 40; - this.groupBoxChangeFontSize.TabStop = false; - this.groupBoxChangeFontSize.Text = "Properties: Subtitle font size"; - this.groupBoxChangeFontSize.Visible = false; - // - // groupBoxChangeFontColor - // - this.groupBoxChangeFontColor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxChangeFontColor.Controls.Add(this.numericUpDownChangeFontColor); - this.groupBoxChangeFontColor.Controls.Add(this.label45); - this.groupBoxChangeFontColor.Location = new System.Drawing.Point(30, 12); - this.groupBoxChangeFontColor.Name = "groupBoxChangeFontColor"; - this.groupBoxChangeFontColor.Size = new System.Drawing.Size(183, 133); - this.groupBoxChangeFontColor.TabIndex = 41; - this.groupBoxChangeFontColor.TabStop = false; - this.groupBoxChangeFontColor.Text = "Properties: Subtitle font color"; - this.groupBoxChangeFontColor.Visible = false; - // - // numericUpDownChangeFontColor - // - this.numericUpDownChangeFontColor.Location = new System.Drawing.Point(100, 18); - this.numericUpDownChangeFontColor.Maximum = new decimal(new int[] { - 254, - 0, - 0, - 0}); - this.numericUpDownChangeFontColor.Name = "numericUpDownChangeFontColor"; - this.numericUpDownChangeFontColor.Size = new System.Drawing.Size(76, 20); - this.numericUpDownChangeFontColor.TabIndex = 15; - this.numericUpDownChangeFontColor.ValueChanged += new System.EventHandler(this.numericUpDownChangeFontColor_ValueChanged); - // - // label45 - // - this.label45.AutoSize = true; - this.label45.Location = new System.Drawing.Point(6, 20); - this.label45.Name = "label45"; - this.label45.Size = new System.Drawing.Size(74, 13); - this.label45.TabIndex = 14; - this.label45.Text = "Font palette id"; - // - // numericUpDownChangeFontSize - // - this.numericUpDownChangeFontSize.Location = new System.Drawing.Point(80, 23); - this.numericUpDownChangeFontSize.Maximum = new decimal(new int[] { - 144, - 0, - 0, - 0}); - this.numericUpDownChangeFontSize.Minimum = new decimal(new int[] { - 8, - 0, - 0, - 0}); - this.numericUpDownChangeFontSize.Name = "numericUpDownChangeFontSize"; - this.numericUpDownChangeFontSize.Size = new System.Drawing.Size(76, 20); - this.numericUpDownChangeFontSize.TabIndex = 35; - this.numericUpDownChangeFontSize.Value = new decimal(new int[] { - 8, - 0, - 0, - 0}); - // - // label46 - // - this.label46.AutoSize = true; - this.label46.Location = new System.Drawing.Point(15, 25); - this.label46.Name = "label46"; - this.label46.Size = new System.Drawing.Size(49, 13); - this.label46.TabIndex = 34; - this.label46.Text = "Font size"; - // - // groupBoxSubtitleText - // - this.groupBoxSubtitleText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxSubtitleText.Controls.Add(this.textBoxSubtitleText); - this.groupBoxSubtitleText.Controls.Add(this.label44); - this.groupBoxSubtitleText.Location = new System.Drawing.Point(284, 526); - this.groupBoxSubtitleText.Name = "groupBoxSubtitleText"; - this.groupBoxSubtitleText.Size = new System.Drawing.Size(145, 111); - this.groupBoxSubtitleText.TabIndex = 41; - this.groupBoxSubtitleText.TabStop = false; - this.groupBoxSubtitleText.Text = "Properties: Subtitle text"; - this.groupBoxSubtitleText.Visible = false; - // - // textBoxSubtitleText - // - this.textBoxSubtitleText.Location = new System.Drawing.Point(46, 22); - this.textBoxSubtitleText.MaxLength = 50; - this.textBoxSubtitleText.Name = "textBoxSubtitleText"; - this.textBoxSubtitleText.Size = new System.Drawing.Size(228, 20); - this.textBoxSubtitleText.TabIndex = 36; - this.textBoxSubtitleText.TextChanged += new System.EventHandler(this.textBoxSubtitleText_TextChanged); - // - // label44 - // - this.label44.AutoSize = true; - this.label44.Location = new System.Drawing.Point(15, 25); - this.label44.Name = "label44"; - this.label44.Size = new System.Drawing.Size(28, 13); - this.label44.TabIndex = 34; - this.label44.Text = "Text"; - // - // contextMenuStripAddSubtitleContent - // - this.contextMenuStripAddSubtitleContent.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItem1, - this.addFontSetToolStripMenuItem, - this.addFontStyleToolStripMenuItem, - this.addFontSizeToolStripMenuItem, - this.addLineBreakToolStripMenuItem, - this.addEndOfInlineStyleToolStripMenuItem, - this.toolStripMenuItem2, - this.deleteToolStripMenuItem}); - this.contextMenuStripAddSubtitleContent.Name = "contextMenuStripAddPalette"; - this.contextMenuStripAddSubtitleContent.Size = new System.Drawing.Size(193, 164); - // - // toolStripMenuItem1 - // - this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(192, 22); - this.toolStripMenuItem1.Text = "Add text"; - this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click); - // - // addFontSetToolStripMenuItem - // - this.addFontSetToolStripMenuItem.Name = "addFontSetToolStripMenuItem"; - this.addFontSetToolStripMenuItem.Size = new System.Drawing.Size(192, 22); - this.addFontSetToolStripMenuItem.Text = "Add font set"; - this.addFontSetToolStripMenuItem.Click += new System.EventHandler(this.addFontSetToolStripMenuItem_Click); - // - // addFontStyleToolStripMenuItem - // - this.addFontStyleToolStripMenuItem.Name = "addFontStyleToolStripMenuItem"; - this.addFontStyleToolStripMenuItem.Size = new System.Drawing.Size(192, 22); - this.addFontStyleToolStripMenuItem.Text = "Add font style"; - this.addFontStyleToolStripMenuItem.Click += new System.EventHandler(this.addFontStyleToolStripMenuItem_Click); - // - // addFontSizeToolStripMenuItem - // - this.addFontSizeToolStripMenuItem.Name = "addFontSizeToolStripMenuItem"; - this.addFontSizeToolStripMenuItem.Size = new System.Drawing.Size(192, 22); - this.addFontSizeToolStripMenuItem.Text = "Add font size"; - this.addFontSizeToolStripMenuItem.Click += new System.EventHandler(this.addFontSizeToolStripMenuItem_Click); - // - // addLineBreakToolStripMenuItem - // - this.addLineBreakToolStripMenuItem.Name = "addLineBreakToolStripMenuItem"; - this.addLineBreakToolStripMenuItem.Size = new System.Drawing.Size(192, 22); - this.addLineBreakToolStripMenuItem.Text = "Add line break"; - this.addLineBreakToolStripMenuItem.Click += new System.EventHandler(this.addLineBreakToolStripMenuItem_Click); - // - // addEndOfInlineStyleToolStripMenuItem - // - this.addEndOfInlineStyleToolStripMenuItem.Name = "addEndOfInlineStyleToolStripMenuItem"; - this.addEndOfInlineStyleToolStripMenuItem.Size = new System.Drawing.Size(192, 22); - this.addEndOfInlineStyleToolStripMenuItem.Text = "Add end of inline style"; - this.addEndOfInlineStyleToolStripMenuItem.Click += new System.EventHandler(this.addEndOfInlineStyleToolStripMenuItem_Click); - // - // toolStripMenuItem2 - // - this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(189, 6); - // - // deleteToolStripMenuItem - // - this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(192, 22); - this.deleteToolStripMenuItem.Text = "Delete"; - this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); - // - // contextMenuStripAddSubtitleContentFromSubRegion - // - this.contextMenuStripAddSubtitleContentFromSubRegion.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemRegionAddText, - this.toolStripMenuItemRegionAddFontStyle, - this.toolStripMenuItemRegionAddFontSize, - this.toolStripMenuItemRegionAddLineBreak, - this.toolStripMenuItemRegionAddInlineStyle}); - this.contextMenuStripAddSubtitleContentFromSubRegion.Name = "contextMenuStripAddPalette"; - this.contextMenuStripAddSubtitleContentFromSubRegion.Size = new System.Drawing.Size(193, 114); - // - // toolStripMenuItemRegionAddText - // - this.toolStripMenuItemRegionAddText.Name = "toolStripMenuItemRegionAddText"; - this.toolStripMenuItemRegionAddText.Size = new System.Drawing.Size(192, 22); - this.toolStripMenuItemRegionAddText.Text = "Add text"; - this.toolStripMenuItemRegionAddText.Click += new System.EventHandler(this.toolStripMenuItemRegionAddText_Click); - // - // toolStripMenuItemRegionAddFontStyle - // - this.toolStripMenuItemRegionAddFontStyle.Name = "toolStripMenuItemRegionAddFontStyle"; - this.toolStripMenuItemRegionAddFontStyle.Size = new System.Drawing.Size(192, 22); - this.toolStripMenuItemRegionAddFontStyle.Text = "Add font style"; - this.toolStripMenuItemRegionAddFontStyle.Click += new System.EventHandler(this.toolStripMenuItemRegionAddFontStyle_Click); - // - // toolStripMenuItemRegionAddFontSize - // - this.toolStripMenuItemRegionAddFontSize.Name = "toolStripMenuItemRegionAddFontSize"; - this.toolStripMenuItemRegionAddFontSize.Size = new System.Drawing.Size(192, 22); - this.toolStripMenuItemRegionAddFontSize.Text = "Add font size"; - this.toolStripMenuItemRegionAddFontSize.Click += new System.EventHandler(this.toolStripMenuItemRegionAddFontSize_Click); - // - // toolStripMenuItemRegionAddLineBreak - // - this.toolStripMenuItemRegionAddLineBreak.Name = "toolStripMenuItemRegionAddLineBreak"; - this.toolStripMenuItemRegionAddLineBreak.Size = new System.Drawing.Size(192, 22); - this.toolStripMenuItemRegionAddLineBreak.Text = "Add line break"; - this.toolStripMenuItemRegionAddLineBreak.Click += new System.EventHandler(this.toolStripMenuItemRegionAddLineBreak_Click); - // - // toolStripMenuItemRegionAddInlineStyle - // - this.toolStripMenuItemRegionAddInlineStyle.Name = "toolStripMenuItemRegionAddInlineStyle"; - this.toolStripMenuItemRegionAddInlineStyle.Size = new System.Drawing.Size(192, 22); - this.toolStripMenuItemRegionAddInlineStyle.Text = "Add end of inline style"; - this.toolStripMenuItemRegionAddInlineStyle.Click += new System.EventHandler(this.toolStripMenuItemRegionAddInlineStyle_Click); - // - // groupBoxFontSet - // - this.groupBoxFontSet.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxFontSet.Controls.Add(this.numericUpDownFontSetFontId); - this.groupBoxFontSet.Controls.Add(this.label48); - this.groupBoxFontSet.Location = new System.Drawing.Point(544, 497); - this.groupBoxFontSet.Name = "groupBoxFontSet"; - this.groupBoxFontSet.Size = new System.Drawing.Size(226, 133); - this.groupBoxFontSet.TabIndex = 42; - this.groupBoxFontSet.TabStop = false; - this.groupBoxFontSet.Text = "Properties: Subtitle font set"; - this.groupBoxFontSet.Visible = false; - // - // numericUpDownFontSetFontId - // - this.numericUpDownFontSetFontId.Location = new System.Drawing.Point(100, 18); - this.numericUpDownFontSetFontId.Maximum = new decimal(new int[] { - 254, - 0, - 0, - 0}); - this.numericUpDownFontSetFontId.Name = "numericUpDownFontSetFontId"; - this.numericUpDownFontSetFontId.Size = new System.Drawing.Size(76, 20); - this.numericUpDownFontSetFontId.TabIndex = 15; - this.numericUpDownFontSetFontId.ValueChanged += new System.EventHandler(this.numericUpDownFontSetFontId_ValueChanged); - // - // label48 - // - this.label48.AutoSize = true; - this.label48.Location = new System.Drawing.Point(6, 20); - this.label48.Name = "label48"; - this.label48.Size = new System.Drawing.Size(81, 13); - this.label48.TabIndex = 14; - this.label48.Text = "Font id from CIF"; - // - // contextMenuStripRegionStyle - // - this.contextMenuStripRegionStyle.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemDuplicateRegionStyle}); - this.contextMenuStripRegionStyle.Name = "contextMenuStripAddPalette"; - this.contextMenuStripRegionStyle.Size = new System.Drawing.Size(125, 26); - // - // toolStripMenuItemDuplicateRegionStyle - // - this.toolStripMenuItemDuplicateRegionStyle.Name = "toolStripMenuItemDuplicateRegionStyle"; - this.toolStripMenuItemDuplicateRegionStyle.Size = new System.Drawing.Size(124, 22); - this.toolStripMenuItemDuplicateRegionStyle.Text = "Duplicate"; - this.toolStripMenuItemDuplicateRegionStyle.Click += new System.EventHandler(this.toolStripMenuItemDuplicateRegionStyle_Click); - // - // ExportTextST - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(871, 610); - this.Controls.Add(this.groupBoxPresentationSegmentRegion); - this.Controls.Add(this.groupBoxFontSet); - this.Controls.Add(this.groupBoxPropertiesPalette); - this.Controls.Add(this.groupBoxChangeFontSize); - this.Controls.Add(this.buttonImport); - this.Controls.Add(this.groupBoxSubtitleText); - this.Controls.Add(this.groupBoxFontStyle); - this.Controls.Add(this.groupBoxPropertiesUserStyle); - this.Controls.Add(this.groupBoxPropertiesRegionStyle); - this.Controls.Add(this.buttonSaveAsM2ts); - this.Controls.Add(this.groupBoxPropertiesRoot); - this.Controls.Add(this.groupBoxTextST); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonSaveAsPes); - this.MinimumSize = new System.Drawing.Size(800, 645); - this.Name = "ExportTextST"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Export to TextST"; - this.groupBoxPropertiesRoot.ResumeLayout(false); - this.groupBoxPropertiesRoot.PerformLayout(); - this.groupBoxTextST.ResumeLayout(false); - this.groupBoxPropertiesRegionStyle.ResumeLayout(false); - this.groupBoxPropertiesRegionStyle.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontOutlineThickness)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontOutlinePaletteId)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontPaletteId)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontStyle)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontIdRef)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleLineSpace)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTextVerAlign)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTextHorAlign)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTextFlow)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBHeight)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBWidth)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBVerPos)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBHorPos)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontSize)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStylePaletteEntryId)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleHeight)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleWidth)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleVPos)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleHPos)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleId)).EndInit(); - this.groupBoxPropertiesPalette.ResumeLayout(false); - this.groupBoxPropertiesPalette.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteOpacity)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteCb)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteCr)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteY)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteEntry)).EndInit(); - this.groupBoxPropertiesUserStyle.ResumeLayout(false); - this.groupBoxPropertiesUserStyle.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleLineSpaceDelta)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleLineSpaceIncDec)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHeightDelta)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHeightIncDec)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBWidthDelta)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBWidthIncDec)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBVerPosDelta)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBVerPosDir)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHorPosDelta)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHorPosDir)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleFontSizeDelta)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleFontSizeIncDec)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleVerPosDelta)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleVerPosDir)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleHorPosDelta)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleHorPosDir)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleId)).EndInit(); - this.groupBoxPresentationSegmentRegion.ResumeLayout(false); - this.groupBoxPresentationSegmentRegion.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSubRegionStyleIdRef)).EndInit(); - this.contextMenuStripAddPalette.ResumeLayout(false); - this.groupBoxFontStyle.ResumeLayout(false); - this.groupBoxFontStyle.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownChangeFontStyleOutlinePaletteId)).EndInit(); - this.groupBoxChangeFontSize.ResumeLayout(false); - this.groupBoxChangeFontSize.PerformLayout(); - this.groupBoxChangeFontColor.ResumeLayout(false); - this.groupBoxChangeFontColor.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownChangeFontColor)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownChangeFontSize)).EndInit(); - this.groupBoxSubtitleText.ResumeLayout(false); - this.groupBoxSubtitleText.PerformLayout(); - this.contextMenuStripAddSubtitleContent.ResumeLayout(false); - this.contextMenuStripAddSubtitleContentFromSubRegion.ResumeLayout(false); - this.groupBoxFontSet.ResumeLayout(false); - this.groupBoxFontSet.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSetFontId)).EndInit(); - this.contextMenuStripRegionStyle.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxPropertiesRoot; - private System.Windows.Forms.GroupBox groupBoxTextST; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonSaveAsPes; - private System.Windows.Forms.Button buttonImport; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.TreeView treeView1; - private System.Windows.Forms.TextBox textBoxRoot; - private System.Windows.Forms.GroupBox groupBoxPropertiesRegionStyle; - private System.Windows.Forms.GroupBox groupBoxPropertiesPalette; - private System.Windows.Forms.GroupBox groupBoxPropertiesUserStyle; - private System.Windows.Forms.NumericUpDown numericUpDownPaletteOpacity; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.NumericUpDown numericUpDownPaletteCb; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.NumericUpDown numericUpDownPaletteCr; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.NumericUpDown numericUpDownPaletteY; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.NumericUpDown numericUpDownPaletteEntry; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Panel panelPaletteColor; - private System.Windows.Forms.Button buttonColor; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleHeight; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleWidth; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleVPos; - private System.Windows.Forms.Label label8; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleHPos; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleId; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleFontSize; - private System.Windows.Forms.Label label12; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStylePaletteEntryId; - private System.Windows.Forms.Label label11; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; - private System.Windows.Forms.Button buttonSaveAsM2ts; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleLineSpaceDelta; - private System.Windows.Forms.Label label28; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleLineSpaceIncDec; - private System.Windows.Forms.Label label29; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBHeightDelta; - private System.Windows.Forms.Label label27; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBHeightIncDec; - private System.Windows.Forms.Label label25; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBWidthDelta; - private System.Windows.Forms.Label label26; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBWidthIncDec; - private System.Windows.Forms.Label label19; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBVerPosDelta; - private System.Windows.Forms.Label label20; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBVerPosDir; - private System.Windows.Forms.Label label21; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBHorPosDelta; - private System.Windows.Forms.Label label22; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBHorPosDir; - private System.Windows.Forms.Label label23; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleFontSizeDelta; - private System.Windows.Forms.Label label24; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleFontSizeIncDec; - private System.Windows.Forms.Label label13; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleVerPosDelta; - private System.Windows.Forms.Label label14; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleVerPosDir; - private System.Windows.Forms.Label label15; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleHorPosDelta; - private System.Windows.Forms.Label label16; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleHorPosDir; - private System.Windows.Forms.Label labelUserStyleHorPosDir; - private System.Windows.Forms.NumericUpDown numericUpDownUserStyleId; - private System.Windows.Forms.Label label18; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleFontOutlineThickness; - private System.Windows.Forms.Label labelRegionStyleFontOutlineThickness; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleFontOutlinePaletteId; - private System.Windows.Forms.Label labelRegionStyleFontOutlinePaletteId; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleFontPaletteId; - private System.Windows.Forms.Label label39; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleFontStyle; - private System.Windows.Forms.Label label38; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleFontIdRef; - private System.Windows.Forms.Label label37; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleLineSpace; - private System.Windows.Forms.Label label33; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTextVerAlign; - private System.Windows.Forms.Label label34; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTextHorAlign; - private System.Windows.Forms.Label label35; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTextFlow; - private System.Windows.Forms.Label label36; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTBHeight; - private System.Windows.Forms.Label label17; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTBWidth; - private System.Windows.Forms.Label label30; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTBVerPos; - private System.Windows.Forms.Label label31; - private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTBHorPos; - private System.Windows.Forms.Label label32; - private System.Windows.Forms.GroupBox groupBoxPresentationSegmentRegion; - private System.Windows.Forms.NumericUpDown numericUpDownSubRegionStyleIdRef; - private System.Windows.Forms.Label label40; - private System.Windows.Forms.CheckBox checkBoxSubRegionForced; - private System.Windows.Forms.CheckBox checkBoxSubRegionContinuous; - private System.Windows.Forms.ContextMenuStrip contextMenuStripAddPalette; - private System.Windows.Forms.ToolStripMenuItem addPaletteToolStripMenuItem; - private System.Windows.Forms.GroupBox groupBoxFontStyle; - private System.Windows.Forms.Label label43; - private System.Windows.Forms.Label label42; - private System.Windows.Forms.ComboBox comboBoxChangeFontStyleOutlineThickness; - private System.Windows.Forms.ComboBox comboBoxChangeFontStyleFontStyle; - private System.Windows.Forms.NumericUpDown numericUpDownChangeFontStyleOutlinePaletteId; - private System.Windows.Forms.Label label41; - private System.Windows.Forms.GroupBox groupBoxChangeFontSize; - private System.Windows.Forms.NumericUpDown numericUpDownChangeFontSize; - private System.Windows.Forms.Label label46; - private System.Windows.Forms.GroupBox groupBoxSubtitleText; - private System.Windows.Forms.TextBox textBoxSubtitleText; - private System.Windows.Forms.Label label44; - private System.Windows.Forms.GroupBox groupBoxChangeFontColor; - private System.Windows.Forms.NumericUpDown numericUpDownChangeFontColor; - private System.Windows.Forms.Label label45; - private System.Windows.Forms.ContextMenuStrip contextMenuStripAddSubtitleContent; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem addFontStyleToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem addFontSizeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem addLineBreakToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem addEndOfInlineStyleToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2; - private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; - private System.Windows.Forms.ContextMenuStrip contextMenuStripAddSubtitleContentFromSubRegion; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRegionAddText; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRegionAddFontStyle; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRegionAddFontSize; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRegionAddLineBreak; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRegionAddInlineStyle; - private System.Windows.Forms.Label label47; - private System.Windows.Forms.GroupBox groupBoxFontSet; - private System.Windows.Forms.NumericUpDown numericUpDownFontSetFontId; - private System.Windows.Forms.Label label48; - private System.Windows.Forms.ToolStripMenuItem addFontSetToolStripMenuItem; - private System.Windows.Forms.ContextMenuStrip contextMenuStripRegionStyle; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDuplicateRegionStyle; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class ExportTextST + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.groupBoxPropertiesRoot = new System.Windows.Forms.GroupBox(); + this.textBoxRoot = new System.Windows.Forms.TextBox(); + this.groupBoxTextST = new System.Windows.Forms.GroupBox(); + this.treeView1 = new System.Windows.Forms.TreeView(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSaveAsPes = new System.Windows.Forms.Button(); + this.buttonImport = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.groupBoxPropertiesRegionStyle = new System.Windows.Forms.GroupBox(); + this.numericUpDownRegionStyleFontOutlineThickness = new System.Windows.Forms.NumericUpDown(); + this.labelRegionStyleFontOutlineThickness = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleFontOutlinePaletteId = new System.Windows.Forms.NumericUpDown(); + this.labelRegionStyleFontOutlinePaletteId = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleFontPaletteId = new System.Windows.Forms.NumericUpDown(); + this.label39 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleFontStyle = new System.Windows.Forms.NumericUpDown(); + this.label38 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleFontIdRef = new System.Windows.Forms.NumericUpDown(); + this.label37 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleLineSpace = new System.Windows.Forms.NumericUpDown(); + this.label33 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleTextVerAlign = new System.Windows.Forms.NumericUpDown(); + this.label34 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleTextHorAlign = new System.Windows.Forms.NumericUpDown(); + this.label35 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleTextFlow = new System.Windows.Forms.NumericUpDown(); + this.label36 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleTBHeight = new System.Windows.Forms.NumericUpDown(); + this.label17 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleTBWidth = new System.Windows.Forms.NumericUpDown(); + this.label30 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleTBVerPos = new System.Windows.Forms.NumericUpDown(); + this.label31 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleTBHorPos = new System.Windows.Forms.NumericUpDown(); + this.label32 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleFontSize = new System.Windows.Forms.NumericUpDown(); + this.label12 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStylePaletteEntryId = new System.Windows.Forms.NumericUpDown(); + this.label11 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleHeight = new System.Windows.Forms.NumericUpDown(); + this.label9 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleWidth = new System.Windows.Forms.NumericUpDown(); + this.label10 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleVPos = new System.Windows.Forms.NumericUpDown(); + this.label8 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleHPos = new System.Windows.Forms.NumericUpDown(); + this.label7 = new System.Windows.Forms.Label(); + this.numericUpDownRegionStyleId = new System.Windows.Forms.NumericUpDown(); + this.label6 = new System.Windows.Forms.Label(); + this.groupBoxPropertiesPalette = new System.Windows.Forms.GroupBox(); + this.label47 = new System.Windows.Forms.Label(); + this.panelPaletteColor = new System.Windows.Forms.Panel(); + this.buttonColor = new System.Windows.Forms.Button(); + this.numericUpDownPaletteOpacity = new System.Windows.Forms.NumericUpDown(); + this.label5 = new System.Windows.Forms.Label(); + this.numericUpDownPaletteCb = new System.Windows.Forms.NumericUpDown(); + this.label4 = new System.Windows.Forms.Label(); + this.numericUpDownPaletteCr = new System.Windows.Forms.NumericUpDown(); + this.label3 = new System.Windows.Forms.Label(); + this.numericUpDownPaletteY = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.numericUpDownPaletteEntry = new System.Windows.Forms.NumericUpDown(); + this.label1 = new System.Windows.Forms.Label(); + this.groupBoxPropertiesUserStyle = new System.Windows.Forms.GroupBox(); + this.numericUpDownUserStyleLineSpaceDelta = new System.Windows.Forms.NumericUpDown(); + this.label28 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleLineSpaceIncDec = new System.Windows.Forms.NumericUpDown(); + this.label29 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleTBHeightDelta = new System.Windows.Forms.NumericUpDown(); + this.label27 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleTBHeightIncDec = new System.Windows.Forms.NumericUpDown(); + this.label25 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleTBWidthDelta = new System.Windows.Forms.NumericUpDown(); + this.label26 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleTBWidthIncDec = new System.Windows.Forms.NumericUpDown(); + this.label19 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleTBVerPosDelta = new System.Windows.Forms.NumericUpDown(); + this.label20 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleTBVerPosDir = new System.Windows.Forms.NumericUpDown(); + this.label21 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleTBHorPosDelta = new System.Windows.Forms.NumericUpDown(); + this.label22 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleTBHorPosDir = new System.Windows.Forms.NumericUpDown(); + this.label23 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleFontSizeDelta = new System.Windows.Forms.NumericUpDown(); + this.label24 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleFontSizeIncDec = new System.Windows.Forms.NumericUpDown(); + this.label13 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleVerPosDelta = new System.Windows.Forms.NumericUpDown(); + this.label14 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleVerPosDir = new System.Windows.Forms.NumericUpDown(); + this.label15 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleHorPosDelta = new System.Windows.Forms.NumericUpDown(); + this.label16 = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleHorPosDir = new System.Windows.Forms.NumericUpDown(); + this.labelUserStyleHorPosDir = new System.Windows.Forms.Label(); + this.numericUpDownUserStyleId = new System.Windows.Forms.NumericUpDown(); + this.label18 = new System.Windows.Forms.Label(); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.buttonSaveAsM2ts = new System.Windows.Forms.Button(); + this.groupBoxPresentationSegmentRegion = new System.Windows.Forms.GroupBox(); + this.numericUpDownSubRegionStyleIdRef = new System.Windows.Forms.NumericUpDown(); + this.label40 = new System.Windows.Forms.Label(); + this.checkBoxSubRegionForced = new System.Windows.Forms.CheckBox(); + this.checkBoxSubRegionContinuous = new System.Windows.Forms.CheckBox(); + this.contextMenuStripAddPalette = new System.Windows.Forms.ContextMenuStrip(this.components); + this.addPaletteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBoxFontStyle = new System.Windows.Forms.GroupBox(); + this.label43 = new System.Windows.Forms.Label(); + this.label42 = new System.Windows.Forms.Label(); + this.comboBoxChangeFontStyleOutlineThickness = new System.Windows.Forms.ComboBox(); + this.comboBoxChangeFontStyleFontStyle = new System.Windows.Forms.ComboBox(); + this.numericUpDownChangeFontStyleOutlinePaletteId = new System.Windows.Forms.NumericUpDown(); + this.label41 = new System.Windows.Forms.Label(); + this.groupBoxChangeFontSize = new System.Windows.Forms.GroupBox(); + this.groupBoxChangeFontColor = new System.Windows.Forms.GroupBox(); + this.numericUpDownChangeFontColor = new System.Windows.Forms.NumericUpDown(); + this.label45 = new System.Windows.Forms.Label(); + this.numericUpDownChangeFontSize = new System.Windows.Forms.NumericUpDown(); + this.label46 = new System.Windows.Forms.Label(); + this.groupBoxSubtitleText = new System.Windows.Forms.GroupBox(); + this.textBoxSubtitleText = new System.Windows.Forms.TextBox(); + this.label44 = new System.Windows.Forms.Label(); + this.contextMenuStripAddSubtitleContent = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.addFontSetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addFontStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addFontSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addLineBreakToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addEndOfInlineStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); + this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.contextMenuStripAddSubtitleContentFromSubRegion = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemRegionAddText = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemRegionAddFontStyle = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemRegionAddFontSize = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemRegionAddLineBreak = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemRegionAddInlineStyle = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBoxFontSet = new System.Windows.Forms.GroupBox(); + this.numericUpDownFontSetFontId = new System.Windows.Forms.NumericUpDown(); + this.label48 = new System.Windows.Forms.Label(); + this.contextMenuStripRegionStyle = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemDuplicateRegionStyle = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBoxPropertiesRoot.SuspendLayout(); + this.groupBoxTextST.SuspendLayout(); + this.groupBoxPropertiesRegionStyle.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontOutlineThickness)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontOutlinePaletteId)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontPaletteId)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontStyle)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontIdRef)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleLineSpace)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTextVerAlign)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTextHorAlign)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTextFlow)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBHeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBWidth)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBVerPos)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBHorPos)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontSize)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStylePaletteEntryId)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleHeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleWidth)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleVPos)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleHPos)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleId)).BeginInit(); + this.groupBoxPropertiesPalette.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteOpacity)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteCb)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteCr)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteY)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteEntry)).BeginInit(); + this.groupBoxPropertiesUserStyle.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleLineSpaceDelta)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleLineSpaceIncDec)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHeightDelta)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHeightIncDec)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBWidthDelta)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBWidthIncDec)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBVerPosDelta)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBVerPosDir)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHorPosDelta)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHorPosDir)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleFontSizeDelta)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleFontSizeIncDec)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleVerPosDelta)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleVerPosDir)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleHorPosDelta)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleHorPosDir)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleId)).BeginInit(); + this.groupBoxPresentationSegmentRegion.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSubRegionStyleIdRef)).BeginInit(); + this.contextMenuStripAddPalette.SuspendLayout(); + this.groupBoxFontStyle.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownChangeFontStyleOutlinePaletteId)).BeginInit(); + this.groupBoxChangeFontSize.SuspendLayout(); + this.groupBoxChangeFontColor.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownChangeFontColor)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownChangeFontSize)).BeginInit(); + this.groupBoxSubtitleText.SuspendLayout(); + this.contextMenuStripAddSubtitleContent.SuspendLayout(); + this.contextMenuStripAddSubtitleContentFromSubRegion.SuspendLayout(); + this.groupBoxFontSet.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSetFontId)).BeginInit(); + this.contextMenuStripRegionStyle.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxPropertiesRoot + // + this.groupBoxPropertiesRoot.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxPropertiesRoot.Controls.Add(this.textBoxRoot); + this.groupBoxPropertiesRoot.Location = new System.Drawing.Point(518, 21); + this.groupBoxPropertiesRoot.Name = "groupBoxPropertiesRoot"; + this.groupBoxPropertiesRoot.Size = new System.Drawing.Size(345, 550); + this.groupBoxPropertiesRoot.TabIndex = 7; + this.groupBoxPropertiesRoot.TabStop = false; + this.groupBoxPropertiesRoot.Text = "Properties"; + // + // textBoxRoot + // + this.textBoxRoot.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBoxRoot.Location = new System.Drawing.Point(3, 16); + this.textBoxRoot.Multiline = true; + this.textBoxRoot.Name = "textBoxRoot"; + this.textBoxRoot.ReadOnly = true; + this.textBoxRoot.Size = new System.Drawing.Size(339, 531); + this.textBoxRoot.TabIndex = 0; + // + // groupBoxTextST + // + this.groupBoxTextST.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxTextST.Controls.Add(this.treeView1); + this.groupBoxTextST.Location = new System.Drawing.Point(7, 21); + this.groupBoxTextST.Name = "groupBoxTextST"; + this.groupBoxTextST.Size = new System.Drawing.Size(505, 550); + this.groupBoxTextST.TabIndex = 6; + this.groupBoxTextST.TabStop = false; + this.groupBoxTextST.Text = "TextST structure"; + // + // treeView1 + // + this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.treeView1.Location = new System.Drawing.Point(3, 16); + this.treeView1.Name = "treeView1"; + this.treeView1.Size = new System.Drawing.Size(499, 531); + this.treeView1.TabIndex = 0; + this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect); + this.treeView1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.treeView1_MouseUp); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(788, 577); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 9; + this.buttonCancel.Text = "&OK"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonSaveAsPes + // + this.buttonSaveAsPes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSaveAsPes.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonSaveAsPes.Location = new System.Drawing.Point(633, 577); + this.buttonSaveAsPes.Name = "buttonSaveAsPes"; + this.buttonSaveAsPes.Size = new System.Drawing.Size(149, 23); + this.buttonSaveAsPes.TabIndex = 8; + this.buttonSaveAsPes.Text = "Write as PES packets..."; + this.buttonSaveAsPes.UseVisualStyleBackColor = true; + this.buttonSaveAsPes.Click += new System.EventHandler(this.buttonSaveAsPes_Click); + // + // buttonImport + // + this.buttonImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonImport.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonImport.Location = new System.Drawing.Point(724, 3); + this.buttonImport.Name = "buttonImport"; + this.buttonImport.Size = new System.Drawing.Size(139, 21); + this.buttonImport.TabIndex = 7; + this.buttonImport.Text = "Import TextST..."; + this.buttonImport.UseVisualStyleBackColor = true; + this.buttonImport.Click += new System.EventHandler(this.ButtonImportClick); + // + // groupBoxPropertiesRegionStyle + // + this.groupBoxPropertiesRegionStyle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleFontOutlineThickness); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.labelRegionStyleFontOutlineThickness); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleFontOutlinePaletteId); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.labelRegionStyleFontOutlinePaletteId); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleFontPaletteId); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label39); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleFontStyle); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label38); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleFontIdRef); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label37); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleLineSpace); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label33); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTextVerAlign); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label34); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTextHorAlign); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label35); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTextFlow); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label36); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTBHeight); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label17); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTBWidth); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label30); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTBVerPos); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label31); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleTBHorPos); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label32); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleFontSize); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label12); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStylePaletteEntryId); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label11); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleHeight); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label9); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleWidth); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label10); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleVPos); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label8); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleHPos); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label7); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.numericUpDownRegionStyleId); + this.groupBoxPropertiesRegionStyle.Controls.Add(this.label6); + this.groupBoxPropertiesRegionStyle.Location = new System.Drawing.Point(48, 12); + this.groupBoxPropertiesRegionStyle.Name = "groupBoxPropertiesRegionStyle"; + this.groupBoxPropertiesRegionStyle.Size = new System.Drawing.Size(230, 549); + this.groupBoxPropertiesRegionStyle.TabIndex = 8; + this.groupBoxPropertiesRegionStyle.TabStop = false; + this.groupBoxPropertiesRegionStyle.Text = "Properties: Region style"; + this.groupBoxPropertiesRegionStyle.Visible = false; + // + // numericUpDownRegionStyleFontOutlineThickness + // + this.numericUpDownRegionStyleFontOutlineThickness.Location = new System.Drawing.Point(143, 516); + this.numericUpDownRegionStyleFontOutlineThickness.Maximum = new decimal(new int[] { + 3, + 0, + 0, + 0}); + this.numericUpDownRegionStyleFontOutlineThickness.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numericUpDownRegionStyleFontOutlineThickness.Name = "numericUpDownRegionStyleFontOutlineThickness"; + this.numericUpDownRegionStyleFontOutlineThickness.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleFontOutlineThickness.TabIndex = 41; + this.numericUpDownRegionStyleFontOutlineThickness.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numericUpDownRegionStyleFontOutlineThickness.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleFontOutlineThickness_ValueChanged); + // + // labelRegionStyleFontOutlineThickness + // + this.labelRegionStyleFontOutlineThickness.AutoSize = true; + this.labelRegionStyleFontOutlineThickness.Location = new System.Drawing.Point(10, 518); + this.labelRegionStyleFontOutlineThickness.Name = "labelRegionStyleFontOutlineThickness"; + this.labelRegionStyleFontOutlineThickness.Size = new System.Drawing.Size(110, 13); + this.labelRegionStyleFontOutlineThickness.TabIndex = 40; + this.labelRegionStyleFontOutlineThickness.Text = "Font outline thickness"; + // + // numericUpDownRegionStyleFontOutlinePaletteId + // + this.numericUpDownRegionStyleFontOutlinePaletteId.Location = new System.Drawing.Point(143, 490); + this.numericUpDownRegionStyleFontOutlinePaletteId.Maximum = new decimal(new int[] { + 254, + 0, + 0, + 0}); + this.numericUpDownRegionStyleFontOutlinePaletteId.Name = "numericUpDownRegionStyleFontOutlinePaletteId"; + this.numericUpDownRegionStyleFontOutlinePaletteId.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleFontOutlinePaletteId.TabIndex = 39; + this.numericUpDownRegionStyleFontOutlinePaletteId.Value = new decimal(new int[] { + 8, + 0, + 0, + 0}); + this.numericUpDownRegionStyleFontOutlinePaletteId.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleFontOutlinePaletteId_ValueChanged); + // + // labelRegionStyleFontOutlinePaletteId + // + this.labelRegionStyleFontOutlinePaletteId.AutoSize = true; + this.labelRegionStyleFontOutlinePaletteId.Location = new System.Drawing.Point(10, 492); + this.labelRegionStyleFontOutlinePaletteId.Name = "labelRegionStyleFontOutlinePaletteId"; + this.labelRegionStyleFontOutlinePaletteId.Size = new System.Drawing.Size(108, 13); + this.labelRegionStyleFontOutlinePaletteId.TabIndex = 38; + this.labelRegionStyleFontOutlinePaletteId.Text = "Font outline palette id"; + // + // numericUpDownRegionStyleFontPaletteId + // + this.numericUpDownRegionStyleFontPaletteId.Location = new System.Drawing.Point(143, 464); + this.numericUpDownRegionStyleFontPaletteId.Maximum = new decimal(new int[] { + 254, + 0, + 0, + 0}); + this.numericUpDownRegionStyleFontPaletteId.Name = "numericUpDownRegionStyleFontPaletteId"; + this.numericUpDownRegionStyleFontPaletteId.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleFontPaletteId.TabIndex = 37; + this.numericUpDownRegionStyleFontPaletteId.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleFontPaletteId_ValueChanged); + // + // label39 + // + this.label39.AutoSize = true; + this.label39.Location = new System.Drawing.Point(10, 466); + this.label39.Name = "label39"; + this.label39.Size = new System.Drawing.Size(74, 13); + this.label39.TabIndex = 36; + this.label39.Text = "Font palette id"; + // + // numericUpDownRegionStyleFontStyle + // + this.numericUpDownRegionStyleFontStyle.Location = new System.Drawing.Point(143, 412); + this.numericUpDownRegionStyleFontStyle.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownRegionStyleFontStyle.Name = "numericUpDownRegionStyleFontStyle"; + this.numericUpDownRegionStyleFontStyle.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleFontStyle.TabIndex = 35; + this.numericUpDownRegionStyleFontStyle.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleFontStyle_ValueChanged); + // + // label38 + // + this.label38.AutoSize = true; + this.label38.Location = new System.Drawing.Point(10, 414); + this.label38.Name = "label38"; + this.label38.Size = new System.Drawing.Size(52, 13); + this.label38.TabIndex = 34; + this.label38.Text = "Font style"; + // + // numericUpDownRegionStyleFontIdRef + // + this.numericUpDownRegionStyleFontIdRef.Location = new System.Drawing.Point(143, 386); + this.numericUpDownRegionStyleFontIdRef.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownRegionStyleFontIdRef.Name = "numericUpDownRegionStyleFontIdRef"; + this.numericUpDownRegionStyleFontIdRef.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleFontIdRef.TabIndex = 33; + this.numericUpDownRegionStyleFontIdRef.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleFontIdRef_ValueChanged); + // + // label37 + // + this.label37.AutoSize = true; + this.label37.Location = new System.Drawing.Point(10, 388); + this.label37.Name = "label37"; + this.label37.Size = new System.Drawing.Size(54, 13); + this.label37.TabIndex = 32; + this.label37.Text = "Font id ref"; + // + // numericUpDownRegionStyleLineSpace + // + this.numericUpDownRegionStyleLineSpace.Location = new System.Drawing.Point(143, 360); + this.numericUpDownRegionStyleLineSpace.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownRegionStyleLineSpace.Name = "numericUpDownRegionStyleLineSpace"; + this.numericUpDownRegionStyleLineSpace.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleLineSpace.TabIndex = 31; + this.numericUpDownRegionStyleLineSpace.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleLineSpace_ValueChanged); + // + // label33 + // + this.label33.AutoSize = true; + this.label33.Location = new System.Drawing.Point(10, 362); + this.label33.Name = "label33"; + this.label33.Size = new System.Drawing.Size(59, 13); + this.label33.TabIndex = 30; + this.label33.Text = "Line space"; + // + // numericUpDownRegionStyleTextVerAlign + // + this.numericUpDownRegionStyleTextVerAlign.Location = new System.Drawing.Point(143, 334); + this.numericUpDownRegionStyleTextVerAlign.Maximum = new decimal(new int[] { + 7679, + 0, + 0, + 0}); + this.numericUpDownRegionStyleTextVerAlign.Name = "numericUpDownRegionStyleTextVerAlign"; + this.numericUpDownRegionStyleTextVerAlign.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleTextVerAlign.TabIndex = 29; + this.numericUpDownRegionStyleTextVerAlign.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTextVerAlign_ValueChanged); + // + // label34 + // + this.label34.AutoSize = true; + this.label34.Location = new System.Drawing.Point(10, 336); + this.label34.Name = "label34"; + this.label34.Size = new System.Drawing.Size(113, 13); + this.label34.TabIndex = 28; + this.label34.Text = "Text vertical alignment"; + // + // numericUpDownRegionStyleTextHorAlign + // + this.numericUpDownRegionStyleTextHorAlign.Location = new System.Drawing.Point(143, 308); + this.numericUpDownRegionStyleTextHorAlign.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownRegionStyleTextHorAlign.Name = "numericUpDownRegionStyleTextHorAlign"; + this.numericUpDownRegionStyleTextHorAlign.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleTextHorAlign.TabIndex = 27; + this.numericUpDownRegionStyleTextHorAlign.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTextHorAlign_ValueChanged); + // + // label35 + // + this.label35.AutoSize = true; + this.label35.Location = new System.Drawing.Point(10, 310); + this.label35.Name = "label35"; + this.label35.Size = new System.Drawing.Size(124, 13); + this.label35.TabIndex = 26; + this.label35.Text = "Text horizontal alignment"; + // + // numericUpDownRegionStyleTextFlow + // + this.numericUpDownRegionStyleTextFlow.Location = new System.Drawing.Point(143, 282); + this.numericUpDownRegionStyleTextFlow.Maximum = new decimal(new int[] { + 7679, + 0, + 0, + 0}); + this.numericUpDownRegionStyleTextFlow.Name = "numericUpDownRegionStyleTextFlow"; + this.numericUpDownRegionStyleTextFlow.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleTextFlow.TabIndex = 25; + this.numericUpDownRegionStyleTextFlow.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTextFlow_ValueChanged); + // + // label36 + // + this.label36.AutoSize = true; + this.label36.Location = new System.Drawing.Point(10, 284); + this.label36.Name = "label36"; + this.label36.Size = new System.Drawing.Size(50, 13); + this.label36.TabIndex = 24; + this.label36.Text = "Text flow"; + // + // numericUpDownRegionStyleTBHeight + // + this.numericUpDownRegionStyleTBHeight.Location = new System.Drawing.Point(143, 256); + this.numericUpDownRegionStyleTBHeight.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownRegionStyleTBHeight.Name = "numericUpDownRegionStyleTBHeight"; + this.numericUpDownRegionStyleTBHeight.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleTBHeight.TabIndex = 23; + this.numericUpDownRegionStyleTBHeight.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTBHeight_ValueChanged); + // + // label17 + // + this.label17.AutoSize = true; + this.label17.Location = new System.Drawing.Point(10, 258); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(80, 13); + this.label17.TabIndex = 22; + this.label17.Text = "Text box height"; + // + // numericUpDownRegionStyleTBWidth + // + this.numericUpDownRegionStyleTBWidth.Location = new System.Drawing.Point(143, 230); + this.numericUpDownRegionStyleTBWidth.Maximum = new decimal(new int[] { + 7679, + 0, + 0, + 0}); + this.numericUpDownRegionStyleTBWidth.Name = "numericUpDownRegionStyleTBWidth"; + this.numericUpDownRegionStyleTBWidth.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleTBWidth.TabIndex = 21; + this.numericUpDownRegionStyleTBWidth.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTBWidth_ValueChanged); + // + // label30 + // + this.label30.AutoSize = true; + this.label30.Location = new System.Drawing.Point(10, 232); + this.label30.Name = "label30"; + this.label30.Size = new System.Drawing.Size(76, 13); + this.label30.TabIndex = 20; + this.label30.Text = "Text box width"; + // + // numericUpDownRegionStyleTBVerPos + // + this.numericUpDownRegionStyleTBVerPos.Location = new System.Drawing.Point(143, 204); + this.numericUpDownRegionStyleTBVerPos.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownRegionStyleTBVerPos.Name = "numericUpDownRegionStyleTBVerPos"; + this.numericUpDownRegionStyleTBVerPos.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleTBVerPos.TabIndex = 19; + this.numericUpDownRegionStyleTBVerPos.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTBVerPos_ValueChanged); + // + // label31 + // + this.label31.AutoSize = true; + this.label31.Location = new System.Drawing.Point(10, 206); + this.label31.Name = "label31"; + this.label31.Size = new System.Drawing.Size(105, 13); + this.label31.TabIndex = 18; + this.label31.Text = "Text box vertical pos"; + // + // numericUpDownRegionStyleTBHorPos + // + this.numericUpDownRegionStyleTBHorPos.Location = new System.Drawing.Point(143, 178); + this.numericUpDownRegionStyleTBHorPos.Maximum = new decimal(new int[] { + 7679, + 0, + 0, + 0}); + this.numericUpDownRegionStyleTBHorPos.Name = "numericUpDownRegionStyleTBHorPos"; + this.numericUpDownRegionStyleTBHorPos.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleTBHorPos.TabIndex = 17; + this.numericUpDownRegionStyleTBHorPos.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleTBHorPos_ValueChanged); + // + // label32 + // + this.label32.AutoSize = true; + this.label32.Location = new System.Drawing.Point(10, 180); + this.label32.Name = "label32"; + this.label32.Size = new System.Drawing.Size(116, 13); + this.label32.TabIndex = 16; + this.label32.Text = "Text box horizontal pos"; + // + // numericUpDownRegionStyleFontSize + // + this.numericUpDownRegionStyleFontSize.Location = new System.Drawing.Point(143, 438); + this.numericUpDownRegionStyleFontSize.Maximum = new decimal(new int[] { + 144, + 0, + 0, + 0}); + this.numericUpDownRegionStyleFontSize.Minimum = new decimal(new int[] { + 8, + 0, + 0, + 0}); + this.numericUpDownRegionStyleFontSize.Name = "numericUpDownRegionStyleFontSize"; + this.numericUpDownRegionStyleFontSize.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleFontSize.TabIndex = 15; + this.numericUpDownRegionStyleFontSize.Value = new decimal(new int[] { + 8, + 0, + 0, + 0}); + this.numericUpDownRegionStyleFontSize.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleFontSize_ValueChanged); + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(10, 440); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(49, 13); + this.label12.TabIndex = 14; + this.label12.Text = "Font size"; + // + // numericUpDownRegionStylePaletteEntryId + // + this.numericUpDownRegionStylePaletteEntryId.Location = new System.Drawing.Point(143, 152); + this.numericUpDownRegionStylePaletteEntryId.Maximum = new decimal(new int[] { + 254, + 0, + 0, + 0}); + this.numericUpDownRegionStylePaletteEntryId.Name = "numericUpDownRegionStylePaletteEntryId"; + this.numericUpDownRegionStylePaletteEntryId.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStylePaletteEntryId.TabIndex = 13; + this.numericUpDownRegionStylePaletteEntryId.ValueChanged += new System.EventHandler(this.numericUpDownRegionStylePaletteEntryId_ValueChanged); + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(10, 154); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(90, 13); + this.label11.TabIndex = 12; + this.label11.Text = "Bg palette entryId"; + // + // numericUpDownRegionStyleHeight + // + this.numericUpDownRegionStyleHeight.Location = new System.Drawing.Point(143, 126); + this.numericUpDownRegionStyleHeight.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownRegionStyleHeight.Name = "numericUpDownRegionStyleHeight"; + this.numericUpDownRegionStyleHeight.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleHeight.TabIndex = 11; + this.numericUpDownRegionStyleHeight.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleHeight_ValueChanged); + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(10, 128); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(38, 13); + this.label9.TabIndex = 10; + this.label9.Text = "Height"; + // + // numericUpDownRegionStyleWidth + // + this.numericUpDownRegionStyleWidth.Location = new System.Drawing.Point(143, 100); + this.numericUpDownRegionStyleWidth.Maximum = new decimal(new int[] { + 7679, + 0, + 0, + 0}); + this.numericUpDownRegionStyleWidth.Name = "numericUpDownRegionStyleWidth"; + this.numericUpDownRegionStyleWidth.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleWidth.TabIndex = 9; + this.numericUpDownRegionStyleWidth.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleWidth_ValueChanged); + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(10, 102); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(35, 13); + this.label10.TabIndex = 8; + this.label10.Text = "Width"; + // + // numericUpDownRegionStyleVPos + // + this.numericUpDownRegionStyleVPos.Location = new System.Drawing.Point(143, 74); + this.numericUpDownRegionStyleVPos.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownRegionStyleVPos.Name = "numericUpDownRegionStyleVPos"; + this.numericUpDownRegionStyleVPos.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleVPos.TabIndex = 7; + this.numericUpDownRegionStyleVPos.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleVPos_ValueChanged); + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(10, 76); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(81, 13); + this.label8.TabIndex = 6; + this.label8.Text = "Vertical position"; + // + // numericUpDownRegionStyleHPos + // + this.numericUpDownRegionStyleHPos.Location = new System.Drawing.Point(143, 48); + this.numericUpDownRegionStyleHPos.Maximum = new decimal(new int[] { + 7679, + 0, + 0, + 0}); + this.numericUpDownRegionStyleHPos.Name = "numericUpDownRegionStyleHPos"; + this.numericUpDownRegionStyleHPos.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleHPos.TabIndex = 5; + this.numericUpDownRegionStyleHPos.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleHPos_ValueChanged); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(10, 50); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(93, 13); + this.label7.TabIndex = 4; + this.label7.Text = "Horizontal position"; + // + // numericUpDownRegionStyleId + // + this.numericUpDownRegionStyleId.Location = new System.Drawing.Point(143, 22); + this.numericUpDownRegionStyleId.Maximum = new decimal(new int[] { + 59, + 0, + 0, + 0}); + this.numericUpDownRegionStyleId.Name = "numericUpDownRegionStyleId"; + this.numericUpDownRegionStyleId.Size = new System.Drawing.Size(76, 20); + this.numericUpDownRegionStyleId.TabIndex = 3; + this.numericUpDownRegionStyleId.ValueChanged += new System.EventHandler(this.numericUpDownRegionStyleId_ValueChanged); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(10, 24); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(39, 13); + this.label6.TabIndex = 2; + this.label6.Text = "StyleId"; + // + // groupBoxPropertiesPalette + // + this.groupBoxPropertiesPalette.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxPropertiesPalette.Controls.Add(this.label47); + this.groupBoxPropertiesPalette.Controls.Add(this.panelPaletteColor); + this.groupBoxPropertiesPalette.Controls.Add(this.buttonColor); + this.groupBoxPropertiesPalette.Controls.Add(this.numericUpDownPaletteOpacity); + this.groupBoxPropertiesPalette.Controls.Add(this.label5); + this.groupBoxPropertiesPalette.Controls.Add(this.numericUpDownPaletteCb); + this.groupBoxPropertiesPalette.Controls.Add(this.label4); + this.groupBoxPropertiesPalette.Controls.Add(this.numericUpDownPaletteCr); + this.groupBoxPropertiesPalette.Controls.Add(this.label3); + this.groupBoxPropertiesPalette.Controls.Add(this.numericUpDownPaletteY); + this.groupBoxPropertiesPalette.Controls.Add(this.label2); + this.groupBoxPropertiesPalette.Controls.Add(this.numericUpDownPaletteEntry); + this.groupBoxPropertiesPalette.Controls.Add(this.label1); + this.groupBoxPropertiesPalette.Location = new System.Drawing.Point(231, 3); + this.groupBoxPropertiesPalette.Name = "groupBoxPropertiesPalette"; + this.groupBoxPropertiesPalette.Size = new System.Drawing.Size(261, 211); + this.groupBoxPropertiesPalette.TabIndex = 9; + this.groupBoxPropertiesPalette.TabStop = false; + this.groupBoxPropertiesPalette.Text = "Properties: Region palette"; + this.groupBoxPropertiesPalette.Visible = false; + // + // label47 + // + this.label47.AutoSize = true; + this.label47.Location = new System.Drawing.Point(164, 133); + this.label47.Name = "label47"; + this.label47.Size = new System.Drawing.Size(137, 13); + this.label47.TabIndex = 15; + this.label47.Text = "0 is transparent, 255 is solid"; + // + // panelPaletteColor + // + this.panelPaletteColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelPaletteColor.Location = new System.Drawing.Point(137, 174); + this.panelPaletteColor.Name = "panelPaletteColor"; + this.panelPaletteColor.Size = new System.Drawing.Size(21, 20); + this.panelPaletteColor.TabIndex = 14; + // + // buttonColor + // + this.buttonColor.Location = new System.Drawing.Point(10, 173); + this.buttonColor.Name = "buttonColor"; + this.buttonColor.Size = new System.Drawing.Size(121, 21); + this.buttonColor.TabIndex = 13; + this.buttonColor.Text = "Pick color"; + this.buttonColor.UseVisualStyleBackColor = true; + this.buttonColor.Click += new System.EventHandler(this.buttonColor_Click); + // + // numericUpDownPaletteOpacity + // + this.numericUpDownPaletteOpacity.Location = new System.Drawing.Point(82, 131); + this.numericUpDownPaletteOpacity.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericUpDownPaletteOpacity.Name = "numericUpDownPaletteOpacity"; + this.numericUpDownPaletteOpacity.Size = new System.Drawing.Size(76, 20); + this.numericUpDownPaletteOpacity.TabIndex = 9; + this.numericUpDownPaletteOpacity.ValueChanged += new System.EventHandler(this.numericUpDownPaletteOpacity_ValueChanged); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(7, 133); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(43, 13); + this.label5.TabIndex = 8; + this.label5.Text = "Opacity"; + // + // numericUpDownPaletteCb + // + this.numericUpDownPaletteCb.Location = new System.Drawing.Point(82, 105); + this.numericUpDownPaletteCb.Maximum = new decimal(new int[] { + 240, + 0, + 0, + 0}); + this.numericUpDownPaletteCb.Name = "numericUpDownPaletteCb"; + this.numericUpDownPaletteCb.Size = new System.Drawing.Size(76, 20); + this.numericUpDownPaletteCb.TabIndex = 7; + this.numericUpDownPaletteCb.ValueChanged += new System.EventHandler(this.numericUpDownPaletteCb_ValueChanged); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(7, 107); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(20, 13); + this.label4.TabIndex = 6; + this.label4.Text = "Cb"; + // + // numericUpDownPaletteCr + // + this.numericUpDownPaletteCr.Location = new System.Drawing.Point(82, 79); + this.numericUpDownPaletteCr.Maximum = new decimal(new int[] { + 240, + 0, + 0, + 0}); + this.numericUpDownPaletteCr.Minimum = new decimal(new int[] { + 16, + 0, + 0, + 0}); + this.numericUpDownPaletteCr.Name = "numericUpDownPaletteCr"; + this.numericUpDownPaletteCr.Size = new System.Drawing.Size(76, 20); + this.numericUpDownPaletteCr.TabIndex = 5; + this.numericUpDownPaletteCr.Value = new decimal(new int[] { + 16, + 0, + 0, + 0}); + this.numericUpDownPaletteCr.ValueChanged += new System.EventHandler(this.numericUpDownPaletteCr_ValueChanged); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(7, 81); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(17, 13); + this.label3.TabIndex = 4; + this.label3.Text = "Cr"; + // + // numericUpDownPaletteY + // + this.numericUpDownPaletteY.Location = new System.Drawing.Point(82, 53); + this.numericUpDownPaletteY.Maximum = new decimal(new int[] { + 235, + 0, + 0, + 0}); + this.numericUpDownPaletteY.Minimum = new decimal(new int[] { + 16, + 0, + 0, + 0}); + this.numericUpDownPaletteY.Name = "numericUpDownPaletteY"; + this.numericUpDownPaletteY.Size = new System.Drawing.Size(76, 20); + this.numericUpDownPaletteY.TabIndex = 3; + this.numericUpDownPaletteY.Value = new decimal(new int[] { + 16, + 0, + 0, + 0}); + this.numericUpDownPaletteY.ValueChanged += new System.EventHandler(this.numericUpDownPaletteY_ValueChanged); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(7, 55); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(14, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Y"; + // + // numericUpDownPaletteEntry + // + this.numericUpDownPaletteEntry.Location = new System.Drawing.Point(82, 27); + this.numericUpDownPaletteEntry.Maximum = new decimal(new int[] { + 254, + 0, + 0, + 0}); + this.numericUpDownPaletteEntry.Name = "numericUpDownPaletteEntry"; + this.numericUpDownPaletteEntry.Size = new System.Drawing.Size(76, 20); + this.numericUpDownPaletteEntry.TabIndex = 1; + this.numericUpDownPaletteEntry.ValueChanged += new System.EventHandler(this.numericUpDownPaletteEntry_ValueChanged); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(7, 29); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(40, 13); + this.label1.TabIndex = 0; + this.label1.Text = "EntryId"; + // + // groupBoxPropertiesUserStyle + // + this.groupBoxPropertiesUserStyle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleLineSpaceDelta); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label28); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleLineSpaceIncDec); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label29); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBHeightDelta); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label27); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBHeightIncDec); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label25); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBWidthDelta); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label26); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBWidthIncDec); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label19); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBVerPosDelta); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label20); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBVerPosDir); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label21); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBHorPosDelta); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label22); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleTBHorPosDir); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label23); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleFontSizeDelta); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label24); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleFontSizeIncDec); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label13); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleVerPosDelta); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label14); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleVerPosDir); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label15); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleHorPosDelta); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label16); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleHorPosDir); + this.groupBoxPropertiesUserStyle.Controls.Add(this.labelUserStyleHorPosDir); + this.groupBoxPropertiesUserStyle.Controls.Add(this.numericUpDownUserStyleId); + this.groupBoxPropertiesUserStyle.Controls.Add(this.label18); + this.groupBoxPropertiesUserStyle.Location = new System.Drawing.Point(416, 12); + this.groupBoxPropertiesUserStyle.Name = "groupBoxPropertiesUserStyle"; + this.groupBoxPropertiesUserStyle.Size = new System.Drawing.Size(264, 505); + this.groupBoxPropertiesUserStyle.TabIndex = 10; + this.groupBoxPropertiesUserStyle.TabStop = false; + this.groupBoxPropertiesUserStyle.Text = "Properties: User style"; + this.groupBoxPropertiesUserStyle.Visible = false; + // + // numericUpDownUserStyleLineSpaceDelta + // + this.numericUpDownUserStyleLineSpaceDelta.Location = new System.Drawing.Point(184, 438); + this.numericUpDownUserStyleLineSpaceDelta.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownUserStyleLineSpaceDelta.Name = "numericUpDownUserStyleLineSpaceDelta"; + this.numericUpDownUserStyleLineSpaceDelta.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleLineSpaceDelta.TabIndex = 47; + this.numericUpDownUserStyleLineSpaceDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleLineSpaceDelta_ValueChanged); + // + // label28 + // + this.label28.AutoSize = true; + this.label28.Location = new System.Drawing.Point(11, 440); + this.label28.Name = "label28"; + this.label28.Size = new System.Drawing.Size(85, 13); + this.label28.TabIndex = 46; + this.label28.Text = "Line space delta"; + // + // numericUpDownUserStyleLineSpaceIncDec + // + this.numericUpDownUserStyleLineSpaceIncDec.Location = new System.Drawing.Point(184, 412); + this.numericUpDownUserStyleLineSpaceIncDec.Maximum = new decimal(new int[] { + 254, + 0, + 0, + 0}); + this.numericUpDownUserStyleLineSpaceIncDec.Name = "numericUpDownUserStyleLineSpaceIncDec"; + this.numericUpDownUserStyleLineSpaceIncDec.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleLineSpaceIncDec.TabIndex = 45; + this.numericUpDownUserStyleLineSpaceIncDec.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleLineSpaceIncDec_ValueChanged); + // + // label29 + // + this.label29.AutoSize = true; + this.label29.Location = new System.Drawing.Point(11, 414); + this.label29.Name = "label29"; + this.label29.Size = new System.Drawing.Size(151, 13); + this.label29.TabIndex = 44; + this.label29.Text = "Line space increase/decrease"; + // + // numericUpDownUserStyleTBHeightDelta + // + this.numericUpDownUserStyleTBHeightDelta.Location = new System.Drawing.Point(184, 386); + this.numericUpDownUserStyleTBHeightDelta.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownUserStyleTBHeightDelta.Name = "numericUpDownUserStyleTBHeightDelta"; + this.numericUpDownUserStyleTBHeightDelta.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleTBHeightDelta.TabIndex = 43; + this.numericUpDownUserStyleTBHeightDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBHeightDelta_ValueChanged); + // + // label27 + // + this.label27.AutoSize = true; + this.label27.Location = new System.Drawing.Point(11, 388); + this.label27.Name = "label27"; + this.label27.Size = new System.Drawing.Size(106, 13); + this.label27.TabIndex = 42; + this.label27.Text = "Text box height delta"; + // + // numericUpDownUserStyleTBHeightIncDec + // + this.numericUpDownUserStyleTBHeightIncDec.Location = new System.Drawing.Point(184, 360); + this.numericUpDownUserStyleTBHeightIncDec.Maximum = new decimal(new int[] { + 254, + 0, + 0, + 0}); + this.numericUpDownUserStyleTBHeightIncDec.Name = "numericUpDownUserStyleTBHeightIncDec"; + this.numericUpDownUserStyleTBHeightIncDec.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleTBHeightIncDec.TabIndex = 41; + this.numericUpDownUserStyleTBHeightIncDec.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBHeightIncDec_ValueChanged); + // + // label25 + // + this.label25.AutoSize = true; + this.label25.Location = new System.Drawing.Point(11, 362); + this.label25.Name = "label25"; + this.label25.Size = new System.Drawing.Size(172, 13); + this.label25.TabIndex = 40; + this.label25.Text = "Text box height increase/decrease"; + // + // numericUpDownUserStyleTBWidthDelta + // + this.numericUpDownUserStyleTBWidthDelta.Location = new System.Drawing.Point(184, 334); + this.numericUpDownUserStyleTBWidthDelta.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownUserStyleTBWidthDelta.Name = "numericUpDownUserStyleTBWidthDelta"; + this.numericUpDownUserStyleTBWidthDelta.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleTBWidthDelta.TabIndex = 39; + this.numericUpDownUserStyleTBWidthDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBWidthDelta_ValueChanged); + // + // label26 + // + this.label26.AutoSize = true; + this.label26.Location = new System.Drawing.Point(11, 336); + this.label26.Name = "label26"; + this.label26.Size = new System.Drawing.Size(102, 13); + this.label26.TabIndex = 38; + this.label26.Text = "Text box width delta"; + // + // numericUpDownUserStyleTBWidthIncDec + // + this.numericUpDownUserStyleTBWidthIncDec.Location = new System.Drawing.Point(184, 308); + this.numericUpDownUserStyleTBWidthIncDec.Maximum = new decimal(new int[] { + 254, + 0, + 0, + 0}); + this.numericUpDownUserStyleTBWidthIncDec.Name = "numericUpDownUserStyleTBWidthIncDec"; + this.numericUpDownUserStyleTBWidthIncDec.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleTBWidthIncDec.TabIndex = 37; + this.numericUpDownUserStyleTBWidthIncDec.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBWidthIncDec_ValueChanged); + // + // label19 + // + this.label19.AutoSize = true; + this.label19.Location = new System.Drawing.Point(11, 310); + this.label19.Name = "label19"; + this.label19.Size = new System.Drawing.Size(168, 13); + this.label19.TabIndex = 36; + this.label19.Text = "Text box width increase/decrease"; + // + // numericUpDownUserStyleTBVerPosDelta + // + this.numericUpDownUserStyleTBVerPosDelta.Location = new System.Drawing.Point(184, 282); + this.numericUpDownUserStyleTBVerPosDelta.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownUserStyleTBVerPosDelta.Name = "numericUpDownUserStyleTBVerPosDelta"; + this.numericUpDownUserStyleTBVerPosDelta.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleTBVerPosDelta.TabIndex = 35; + this.numericUpDownUserStyleTBVerPosDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBVerPosDelta_ValueChanged); + // + // label20 + // + this.label20.AutoSize = true; + this.label20.Location = new System.Drawing.Point(11, 284); + this.label20.Name = "label20"; + this.label20.Size = new System.Drawing.Size(131, 13); + this.label20.TabIndex = 34; + this.label20.Text = "Text box vertical pos delta"; + // + // numericUpDownUserStyleTBVerPosDir + // + this.numericUpDownUserStyleTBVerPosDir.Location = new System.Drawing.Point(184, 256); + this.numericUpDownUserStyleTBVerPosDir.Maximum = new decimal(new int[] { + 7679, + 0, + 0, + 0}); + this.numericUpDownUserStyleTBVerPosDir.Name = "numericUpDownUserStyleTBVerPosDir"; + this.numericUpDownUserStyleTBVerPosDir.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleTBVerPosDir.TabIndex = 33; + this.numericUpDownUserStyleTBVerPosDir.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBVerPosDir_ValueChanged); + // + // label21 + // + this.label21.AutoSize = true; + this.label21.Location = new System.Drawing.Point(11, 258); + this.label21.Name = "label21"; + this.label21.Size = new System.Drawing.Size(148, 13); + this.label21.TabIndex = 32; + this.label21.Text = "Text box vertical pos direction"; + // + // numericUpDownUserStyleTBHorPosDelta + // + this.numericUpDownUserStyleTBHorPosDelta.Location = new System.Drawing.Point(184, 230); + this.numericUpDownUserStyleTBHorPosDelta.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownUserStyleTBHorPosDelta.Name = "numericUpDownUserStyleTBHorPosDelta"; + this.numericUpDownUserStyleTBHorPosDelta.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleTBHorPosDelta.TabIndex = 31; + this.numericUpDownUserStyleTBHorPosDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBHorPosDelta_ValueChanged); + // + // label22 + // + this.label22.AutoSize = true; + this.label22.Location = new System.Drawing.Point(11, 232); + this.label22.Name = "label22"; + this.label22.Size = new System.Drawing.Size(142, 13); + this.label22.TabIndex = 30; + this.label22.Text = "Text box horizontal pos delta"; + // + // numericUpDownUserStyleTBHorPosDir + // + this.numericUpDownUserStyleTBHorPosDir.Location = new System.Drawing.Point(184, 204); + this.numericUpDownUserStyleTBHorPosDir.Maximum = new decimal(new int[] { + 7679, + 0, + 0, + 0}); + this.numericUpDownUserStyleTBHorPosDir.Name = "numericUpDownUserStyleTBHorPosDir"; + this.numericUpDownUserStyleTBHorPosDir.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleTBHorPosDir.TabIndex = 29; + this.numericUpDownUserStyleTBHorPosDir.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleTBHorPosDir_ValueChanged); + // + // label23 + // + this.label23.AutoSize = true; + this.label23.Location = new System.Drawing.Point(11, 206); + this.label23.Name = "label23"; + this.label23.Size = new System.Drawing.Size(159, 13); + this.label23.TabIndex = 28; + this.label23.Text = "Text box horizontal pos direction"; + // + // numericUpDownUserStyleFontSizeDelta + // + this.numericUpDownUserStyleFontSizeDelta.Location = new System.Drawing.Point(184, 178); + this.numericUpDownUserStyleFontSizeDelta.Maximum = new decimal(new int[] { + 59, + 0, + 0, + 0}); + this.numericUpDownUserStyleFontSizeDelta.Name = "numericUpDownUserStyleFontSizeDelta"; + this.numericUpDownUserStyleFontSizeDelta.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleFontSizeDelta.TabIndex = 27; + this.numericUpDownUserStyleFontSizeDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleFontSizeDelta_ValueChanged); + // + // label24 + // + this.label24.AutoSize = true; + this.label24.Location = new System.Drawing.Point(11, 180); + this.label24.Name = "label24"; + this.label24.Size = new System.Drawing.Size(75, 13); + this.label24.TabIndex = 26; + this.label24.Text = "Font size delta"; + // + // numericUpDownUserStyleFontSizeIncDec + // + this.numericUpDownUserStyleFontSizeIncDec.Location = new System.Drawing.Point(184, 152); + this.numericUpDownUserStyleFontSizeIncDec.Maximum = new decimal(new int[] { + 254, + 0, + 0, + 0}); + this.numericUpDownUserStyleFontSizeIncDec.Name = "numericUpDownUserStyleFontSizeIncDec"; + this.numericUpDownUserStyleFontSizeIncDec.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleFontSizeIncDec.TabIndex = 25; + this.numericUpDownUserStyleFontSizeIncDec.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleFontSizeIncDec_ValueChanged); + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(11, 154); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(141, 13); + this.label13.TabIndex = 24; + this.label13.Text = "Font size increase/decrease"; + // + // numericUpDownUserStyleVerPosDelta + // + this.numericUpDownUserStyleVerPosDelta.Location = new System.Drawing.Point(184, 126); + this.numericUpDownUserStyleVerPosDelta.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownUserStyleVerPosDelta.Name = "numericUpDownUserStyleVerPosDelta"; + this.numericUpDownUserStyleVerPosDelta.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleVerPosDelta.TabIndex = 23; + this.numericUpDownUserStyleVerPosDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleVerPosDelta_ValueChanged); + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(11, 128); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(107, 13); + this.label14.TabIndex = 22; + this.label14.Text = "Vertical position delta"; + // + // numericUpDownUserStyleVerPosDir + // + this.numericUpDownUserStyleVerPosDir.Location = new System.Drawing.Point(184, 100); + this.numericUpDownUserStyleVerPosDir.Maximum = new decimal(new int[] { + 7679, + 0, + 0, + 0}); + this.numericUpDownUserStyleVerPosDir.Name = "numericUpDownUserStyleVerPosDir"; + this.numericUpDownUserStyleVerPosDir.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleVerPosDir.TabIndex = 21; + this.numericUpDownUserStyleVerPosDir.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleVerPosDir_ValueChanged); + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(11, 102); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(124, 13); + this.label15.TabIndex = 20; + this.label15.Text = "Vertical position direction"; + // + // numericUpDownUserStyleHorPosDelta + // + this.numericUpDownUserStyleHorPosDelta.Location = new System.Drawing.Point(184, 74); + this.numericUpDownUserStyleHorPosDelta.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownUserStyleHorPosDelta.Name = "numericUpDownUserStyleHorPosDelta"; + this.numericUpDownUserStyleHorPosDelta.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleHorPosDelta.TabIndex = 19; + this.numericUpDownUserStyleHorPosDelta.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleHorPosDelta_ValueChanged); + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(11, 76); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(119, 13); + this.label16.TabIndex = 18; + this.label16.Text = "Horizontal position delta"; + // + // numericUpDownUserStyleHorPosDir + // + this.numericUpDownUserStyleHorPosDir.Location = new System.Drawing.Point(184, 48); + this.numericUpDownUserStyleHorPosDir.Maximum = new decimal(new int[] { + 7679, + 0, + 0, + 0}); + this.numericUpDownUserStyleHorPosDir.Name = "numericUpDownUserStyleHorPosDir"; + this.numericUpDownUserStyleHorPosDir.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleHorPosDir.TabIndex = 17; + this.numericUpDownUserStyleHorPosDir.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleHorPosDir_ValueChanged); + // + // labelUserStyleHorPosDir + // + this.labelUserStyleHorPosDir.AutoSize = true; + this.labelUserStyleHorPosDir.Location = new System.Drawing.Point(11, 50); + this.labelUserStyleHorPosDir.Name = "labelUserStyleHorPosDir"; + this.labelUserStyleHorPosDir.Size = new System.Drawing.Size(136, 13); + this.labelUserStyleHorPosDir.TabIndex = 16; + this.labelUserStyleHorPosDir.Text = "Horizontal position direction"; + // + // numericUpDownUserStyleId + // + this.numericUpDownUserStyleId.Location = new System.Drawing.Point(184, 22); + this.numericUpDownUserStyleId.Maximum = new decimal(new int[] { + 59, + 0, + 0, + 0}); + this.numericUpDownUserStyleId.Name = "numericUpDownUserStyleId"; + this.numericUpDownUserStyleId.Size = new System.Drawing.Size(76, 20); + this.numericUpDownUserStyleId.TabIndex = 15; + this.numericUpDownUserStyleId.ValueChanged += new System.EventHandler(this.numericUpDownUserStyleId_ValueChanged); + // + // label18 + // + this.label18.AutoSize = true; + this.label18.Location = new System.Drawing.Point(11, 24); + this.label18.Name = "label18"; + this.label18.Size = new System.Drawing.Size(39, 13); + this.label18.TabIndex = 14; + this.label18.Text = "StyleId"; + // + // buttonSaveAsM2ts + // + this.buttonSaveAsM2ts.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSaveAsM2ts.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonSaveAsM2ts.Location = new System.Drawing.Point(478, 577); + this.buttonSaveAsM2ts.Name = "buttonSaveAsM2ts"; + this.buttonSaveAsM2ts.Size = new System.Drawing.Size(149, 23); + this.buttonSaveAsM2ts.TabIndex = 113; + this.buttonSaveAsM2ts.Text = "Write as M2TS packets..."; + this.buttonSaveAsM2ts.UseVisualStyleBackColor = true; + this.buttonSaveAsM2ts.Visible = false; + this.buttonSaveAsM2ts.Click += new System.EventHandler(this.buttonSaveAsM2ts_Click); + // + // groupBoxPresentationSegmentRegion + // + this.groupBoxPresentationSegmentRegion.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxPresentationSegmentRegion.Controls.Add(this.numericUpDownSubRegionStyleIdRef); + this.groupBoxPresentationSegmentRegion.Controls.Add(this.label40); + this.groupBoxPresentationSegmentRegion.Controls.Add(this.checkBoxSubRegionForced); + this.groupBoxPresentationSegmentRegion.Controls.Add(this.checkBoxSubRegionContinuous); + this.groupBoxPresentationSegmentRegion.Location = new System.Drawing.Point(404, 4); + this.groupBoxPresentationSegmentRegion.Name = "groupBoxPresentationSegmentRegion"; + this.groupBoxPresentationSegmentRegion.Size = new System.Drawing.Size(213, 129); + this.groupBoxPresentationSegmentRegion.TabIndex = 15; + this.groupBoxPresentationSegmentRegion.TabStop = false; + this.groupBoxPresentationSegmentRegion.Text = "Properties: Subtitle region"; + this.groupBoxPresentationSegmentRegion.Visible = false; + // + // numericUpDownSubRegionStyleIdRef + // + this.numericUpDownSubRegionStyleIdRef.Location = new System.Drawing.Point(106, 74); + this.numericUpDownSubRegionStyleIdRef.Maximum = new decimal(new int[] { + 4319, + 0, + 0, + 0}); + this.numericUpDownSubRegionStyleIdRef.Name = "numericUpDownSubRegionStyleIdRef"; + this.numericUpDownSubRegionStyleIdRef.Size = new System.Drawing.Size(76, 20); + this.numericUpDownSubRegionStyleIdRef.TabIndex = 35; + this.numericUpDownSubRegionStyleIdRef.ValueChanged += new System.EventHandler(this.numericUpDownSubRegionStyleIdRef_ValueChanged); + // + // label40 + // + this.label40.AutoSize = true; + this.label40.Location = new System.Drawing.Point(8, 76); + this.label40.Name = "label40"; + this.label40.Size = new System.Drawing.Size(91, 13); + this.label40.TabIndex = 34; + this.label40.Text = "Region style id ref"; + // + // checkBoxSubRegionForced + // + this.checkBoxSubRegionForced.AutoSize = true; + this.checkBoxSubRegionForced.Location = new System.Drawing.Point(106, 50); + this.checkBoxSubRegionForced.Name = "checkBoxSubRegionForced"; + this.checkBoxSubRegionForced.Size = new System.Drawing.Size(59, 17); + this.checkBoxSubRegionForced.TabIndex = 11; + this.checkBoxSubRegionForced.Text = "Forced"; + this.checkBoxSubRegionForced.UseVisualStyleBackColor = true; + this.checkBoxSubRegionForced.CheckedChanged += new System.EventHandler(this.checkBoxSubRegionForced_CheckedChanged); + // + // checkBoxSubRegionContinuous + // + this.checkBoxSubRegionContinuous.AutoSize = true; + this.checkBoxSubRegionContinuous.Location = new System.Drawing.Point(106, 27); + this.checkBoxSubRegionContinuous.Name = "checkBoxSubRegionContinuous"; + this.checkBoxSubRegionContinuous.Size = new System.Drawing.Size(126, 17); + this.checkBoxSubRegionContinuous.TabIndex = 10; + this.checkBoxSubRegionContinuous.Text = "Continuous from prev"; + this.checkBoxSubRegionContinuous.UseVisualStyleBackColor = true; + this.checkBoxSubRegionContinuous.CheckedChanged += new System.EventHandler(this.checkBoxSubRegionContinuous_CheckedChanged); + // + // contextMenuStripAddPalette + // + this.contextMenuStripAddPalette.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addPaletteToolStripMenuItem}); + this.contextMenuStripAddPalette.Name = "contextMenuStripAddPalette"; + this.contextMenuStripAddPalette.Size = new System.Drawing.Size(136, 26); + // + // addPaletteToolStripMenuItem + // + this.addPaletteToolStripMenuItem.Name = "addPaletteToolStripMenuItem"; + this.addPaletteToolStripMenuItem.Size = new System.Drawing.Size(135, 22); + this.addPaletteToolStripMenuItem.Text = "Add palette"; + this.addPaletteToolStripMenuItem.Click += new System.EventHandler(this.addPaletteToolStripMenuItem_Click); + // + // groupBoxFontStyle + // + this.groupBoxFontStyle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFontStyle.Controls.Add(this.label43); + this.groupBoxFontStyle.Controls.Add(this.label42); + this.groupBoxFontStyle.Controls.Add(this.comboBoxChangeFontStyleOutlineThickness); + this.groupBoxFontStyle.Controls.Add(this.comboBoxChangeFontStyleFontStyle); + this.groupBoxFontStyle.Controls.Add(this.numericUpDownChangeFontStyleOutlinePaletteId); + this.groupBoxFontStyle.Controls.Add(this.label41); + this.groupBoxFontStyle.Location = new System.Drawing.Point(16, 471); + this.groupBoxFontStyle.Name = "groupBoxFontStyle"; + this.groupBoxFontStyle.Size = new System.Drawing.Size(230, 133); + this.groupBoxFontStyle.TabIndex = 36; + this.groupBoxFontStyle.TabStop = false; + this.groupBoxFontStyle.Text = "Properties: Subtitle font style"; + this.groupBoxFontStyle.Visible = false; + // + // label43 + // + this.label43.AutoSize = true; + this.label43.Location = new System.Drawing.Point(6, 79); + this.label43.Name = "label43"; + this.label43.Size = new System.Drawing.Size(110, 13); + this.label43.TabIndex = 39; + this.label43.Text = "Font outline thickness"; + // + // label42 + // + this.label42.AutoSize = true; + this.label42.Location = new System.Drawing.Point(6, 26); + this.label42.Name = "label42"; + this.label42.Size = new System.Drawing.Size(52, 13); + this.label42.TabIndex = 38; + this.label42.Text = "Font style"; + // + // comboBoxChangeFontStyleOutlineThickness + // + this.comboBoxChangeFontStyleOutlineThickness.FormattingEnabled = true; + this.comboBoxChangeFontStyleOutlineThickness.Items.AddRange(new object[] { + "Thin border", + "Medium border", + "Thick border"}); + this.comboBoxChangeFontStyleOutlineThickness.Location = new System.Drawing.Point(129, 76); + this.comboBoxChangeFontStyleOutlineThickness.Name = "comboBoxChangeFontStyleOutlineThickness"; + this.comboBoxChangeFontStyleOutlineThickness.Size = new System.Drawing.Size(186, 21); + this.comboBoxChangeFontStyleOutlineThickness.TabIndex = 37; + // + // comboBoxChangeFontStyleFontStyle + // + this.comboBoxChangeFontStyleFontStyle.FormattingEnabled = true; + this.comboBoxChangeFontStyleFontStyle.Items.AddRange(new object[] { + "Normal", + "Bold", + "Italic", + "Bold and Italic", + "Outline-bordered", + "Bold and Outline-bordered", + "Italic and Outline-bordered", + "Bold and Italic and Outline-bordered"}); + this.comboBoxChangeFontStyleFontStyle.Location = new System.Drawing.Point(129, 23); + this.comboBoxChangeFontStyleFontStyle.Name = "comboBoxChangeFontStyleFontStyle"; + this.comboBoxChangeFontStyleFontStyle.Size = new System.Drawing.Size(186, 21); + this.comboBoxChangeFontStyleFontStyle.TabIndex = 36; + // + // numericUpDownChangeFontStyleOutlinePaletteId + // + this.numericUpDownChangeFontStyleOutlinePaletteId.Location = new System.Drawing.Point(129, 50); + this.numericUpDownChangeFontStyleOutlinePaletteId.Maximum = new decimal(new int[] { + 254, + 0, + 0, + 0}); + this.numericUpDownChangeFontStyleOutlinePaletteId.Name = "numericUpDownChangeFontStyleOutlinePaletteId"; + this.numericUpDownChangeFontStyleOutlinePaletteId.Size = new System.Drawing.Size(76, 20); + this.numericUpDownChangeFontStyleOutlinePaletteId.TabIndex = 35; + // + // label41 + // + this.label41.AutoSize = true; + this.label41.Location = new System.Drawing.Point(7, 52); + this.label41.Name = "label41"; + this.label41.Size = new System.Drawing.Size(108, 13); + this.label41.TabIndex = 34; + this.label41.Text = "Font outline palette id"; + // + // groupBoxChangeFontSize + // + this.groupBoxChangeFontSize.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxChangeFontSize.Controls.Add(this.groupBoxChangeFontColor); + this.groupBoxChangeFontSize.Controls.Add(this.numericUpDownChangeFontSize); + this.groupBoxChangeFontSize.Controls.Add(this.label46); + this.groupBoxChangeFontSize.Location = new System.Drawing.Point(355, 510); + this.groupBoxChangeFontSize.Name = "groupBoxChangeFontSize"; + this.groupBoxChangeFontSize.Size = new System.Drawing.Size(183, 133); + this.groupBoxChangeFontSize.TabIndex = 40; + this.groupBoxChangeFontSize.TabStop = false; + this.groupBoxChangeFontSize.Text = "Properties: Subtitle font size"; + this.groupBoxChangeFontSize.Visible = false; + // + // groupBoxChangeFontColor + // + this.groupBoxChangeFontColor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxChangeFontColor.Controls.Add(this.numericUpDownChangeFontColor); + this.groupBoxChangeFontColor.Controls.Add(this.label45); + this.groupBoxChangeFontColor.Location = new System.Drawing.Point(30, 12); + this.groupBoxChangeFontColor.Name = "groupBoxChangeFontColor"; + this.groupBoxChangeFontColor.Size = new System.Drawing.Size(183, 133); + this.groupBoxChangeFontColor.TabIndex = 41; + this.groupBoxChangeFontColor.TabStop = false; + this.groupBoxChangeFontColor.Text = "Properties: Subtitle font color"; + this.groupBoxChangeFontColor.Visible = false; + // + // numericUpDownChangeFontColor + // + this.numericUpDownChangeFontColor.Location = new System.Drawing.Point(100, 18); + this.numericUpDownChangeFontColor.Maximum = new decimal(new int[] { + 254, + 0, + 0, + 0}); + this.numericUpDownChangeFontColor.Name = "numericUpDownChangeFontColor"; + this.numericUpDownChangeFontColor.Size = new System.Drawing.Size(76, 20); + this.numericUpDownChangeFontColor.TabIndex = 15; + this.numericUpDownChangeFontColor.ValueChanged += new System.EventHandler(this.numericUpDownChangeFontColor_ValueChanged); + // + // label45 + // + this.label45.AutoSize = true; + this.label45.Location = new System.Drawing.Point(6, 20); + this.label45.Name = "label45"; + this.label45.Size = new System.Drawing.Size(74, 13); + this.label45.TabIndex = 14; + this.label45.Text = "Font palette id"; + // + // numericUpDownChangeFontSize + // + this.numericUpDownChangeFontSize.Location = new System.Drawing.Point(80, 23); + this.numericUpDownChangeFontSize.Maximum = new decimal(new int[] { + 144, + 0, + 0, + 0}); + this.numericUpDownChangeFontSize.Minimum = new decimal(new int[] { + 8, + 0, + 0, + 0}); + this.numericUpDownChangeFontSize.Name = "numericUpDownChangeFontSize"; + this.numericUpDownChangeFontSize.Size = new System.Drawing.Size(76, 20); + this.numericUpDownChangeFontSize.TabIndex = 35; + this.numericUpDownChangeFontSize.Value = new decimal(new int[] { + 8, + 0, + 0, + 0}); + // + // label46 + // + this.label46.AutoSize = true; + this.label46.Location = new System.Drawing.Point(15, 25); + this.label46.Name = "label46"; + this.label46.Size = new System.Drawing.Size(49, 13); + this.label46.TabIndex = 34; + this.label46.Text = "Font size"; + // + // groupBoxSubtitleText + // + this.groupBoxSubtitleText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxSubtitleText.Controls.Add(this.textBoxSubtitleText); + this.groupBoxSubtitleText.Controls.Add(this.label44); + this.groupBoxSubtitleText.Location = new System.Drawing.Point(284, 526); + this.groupBoxSubtitleText.Name = "groupBoxSubtitleText"; + this.groupBoxSubtitleText.Size = new System.Drawing.Size(145, 111); + this.groupBoxSubtitleText.TabIndex = 41; + this.groupBoxSubtitleText.TabStop = false; + this.groupBoxSubtitleText.Text = "Properties: Subtitle text"; + this.groupBoxSubtitleText.Visible = false; + // + // textBoxSubtitleText + // + this.textBoxSubtitleText.Location = new System.Drawing.Point(46, 22); + this.textBoxSubtitleText.MaxLength = 50; + this.textBoxSubtitleText.Name = "textBoxSubtitleText"; + this.textBoxSubtitleText.Size = new System.Drawing.Size(228, 20); + this.textBoxSubtitleText.TabIndex = 36; + this.textBoxSubtitleText.TextChanged += new System.EventHandler(this.textBoxSubtitleText_TextChanged); + // + // label44 + // + this.label44.AutoSize = true; + this.label44.Location = new System.Drawing.Point(15, 25); + this.label44.Name = "label44"; + this.label44.Size = new System.Drawing.Size(28, 13); + this.label44.TabIndex = 34; + this.label44.Text = "Text"; + // + // contextMenuStripAddSubtitleContent + // + this.contextMenuStripAddSubtitleContent.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItem1, + this.addFontSetToolStripMenuItem, + this.addFontStyleToolStripMenuItem, + this.addFontSizeToolStripMenuItem, + this.addLineBreakToolStripMenuItem, + this.addEndOfInlineStyleToolStripMenuItem, + this.toolStripMenuItem2, + this.deleteToolStripMenuItem}); + this.contextMenuStripAddSubtitleContent.Name = "contextMenuStripAddPalette"; + this.contextMenuStripAddSubtitleContent.Size = new System.Drawing.Size(193, 164); + // + // toolStripMenuItem1 + // + this.toolStripMenuItem1.Name = "toolStripMenuItem1"; + this.toolStripMenuItem1.Size = new System.Drawing.Size(192, 22); + this.toolStripMenuItem1.Text = "Add text"; + this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click); + // + // addFontSetToolStripMenuItem + // + this.addFontSetToolStripMenuItem.Name = "addFontSetToolStripMenuItem"; + this.addFontSetToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.addFontSetToolStripMenuItem.Text = "Add font set"; + this.addFontSetToolStripMenuItem.Click += new System.EventHandler(this.addFontSetToolStripMenuItem_Click); + // + // addFontStyleToolStripMenuItem + // + this.addFontStyleToolStripMenuItem.Name = "addFontStyleToolStripMenuItem"; + this.addFontStyleToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.addFontStyleToolStripMenuItem.Text = "Add font style"; + this.addFontStyleToolStripMenuItem.Click += new System.EventHandler(this.addFontStyleToolStripMenuItem_Click); + // + // addFontSizeToolStripMenuItem + // + this.addFontSizeToolStripMenuItem.Name = "addFontSizeToolStripMenuItem"; + this.addFontSizeToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.addFontSizeToolStripMenuItem.Text = "Add font size"; + this.addFontSizeToolStripMenuItem.Click += new System.EventHandler(this.addFontSizeToolStripMenuItem_Click); + // + // addLineBreakToolStripMenuItem + // + this.addLineBreakToolStripMenuItem.Name = "addLineBreakToolStripMenuItem"; + this.addLineBreakToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.addLineBreakToolStripMenuItem.Text = "Add line break"; + this.addLineBreakToolStripMenuItem.Click += new System.EventHandler(this.addLineBreakToolStripMenuItem_Click); + // + // addEndOfInlineStyleToolStripMenuItem + // + this.addEndOfInlineStyleToolStripMenuItem.Name = "addEndOfInlineStyleToolStripMenuItem"; + this.addEndOfInlineStyleToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.addEndOfInlineStyleToolStripMenuItem.Text = "Add end of inline style"; + this.addEndOfInlineStyleToolStripMenuItem.Click += new System.EventHandler(this.addEndOfInlineStyleToolStripMenuItem_Click); + // + // toolStripMenuItem2 + // + this.toolStripMenuItem2.Name = "toolStripMenuItem2"; + this.toolStripMenuItem2.Size = new System.Drawing.Size(189, 6); + // + // deleteToolStripMenuItem + // + this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.deleteToolStripMenuItem.Text = "Delete"; + this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); + // + // contextMenuStripAddSubtitleContentFromSubRegion + // + this.contextMenuStripAddSubtitleContentFromSubRegion.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemRegionAddText, + this.toolStripMenuItemRegionAddFontStyle, + this.toolStripMenuItemRegionAddFontSize, + this.toolStripMenuItemRegionAddLineBreak, + this.toolStripMenuItemRegionAddInlineStyle}); + this.contextMenuStripAddSubtitleContentFromSubRegion.Name = "contextMenuStripAddPalette"; + this.contextMenuStripAddSubtitleContentFromSubRegion.Size = new System.Drawing.Size(193, 114); + // + // toolStripMenuItemRegionAddText + // + this.toolStripMenuItemRegionAddText.Name = "toolStripMenuItemRegionAddText"; + this.toolStripMenuItemRegionAddText.Size = new System.Drawing.Size(192, 22); + this.toolStripMenuItemRegionAddText.Text = "Add text"; + this.toolStripMenuItemRegionAddText.Click += new System.EventHandler(this.toolStripMenuItemRegionAddText_Click); + // + // toolStripMenuItemRegionAddFontStyle + // + this.toolStripMenuItemRegionAddFontStyle.Name = "toolStripMenuItemRegionAddFontStyle"; + this.toolStripMenuItemRegionAddFontStyle.Size = new System.Drawing.Size(192, 22); + this.toolStripMenuItemRegionAddFontStyle.Text = "Add font style"; + this.toolStripMenuItemRegionAddFontStyle.Click += new System.EventHandler(this.toolStripMenuItemRegionAddFontStyle_Click); + // + // toolStripMenuItemRegionAddFontSize + // + this.toolStripMenuItemRegionAddFontSize.Name = "toolStripMenuItemRegionAddFontSize"; + this.toolStripMenuItemRegionAddFontSize.Size = new System.Drawing.Size(192, 22); + this.toolStripMenuItemRegionAddFontSize.Text = "Add font size"; + this.toolStripMenuItemRegionAddFontSize.Click += new System.EventHandler(this.toolStripMenuItemRegionAddFontSize_Click); + // + // toolStripMenuItemRegionAddLineBreak + // + this.toolStripMenuItemRegionAddLineBreak.Name = "toolStripMenuItemRegionAddLineBreak"; + this.toolStripMenuItemRegionAddLineBreak.Size = new System.Drawing.Size(192, 22); + this.toolStripMenuItemRegionAddLineBreak.Text = "Add line break"; + this.toolStripMenuItemRegionAddLineBreak.Click += new System.EventHandler(this.toolStripMenuItemRegionAddLineBreak_Click); + // + // toolStripMenuItemRegionAddInlineStyle + // + this.toolStripMenuItemRegionAddInlineStyle.Name = "toolStripMenuItemRegionAddInlineStyle"; + this.toolStripMenuItemRegionAddInlineStyle.Size = new System.Drawing.Size(192, 22); + this.toolStripMenuItemRegionAddInlineStyle.Text = "Add end of inline style"; + this.toolStripMenuItemRegionAddInlineStyle.Click += new System.EventHandler(this.toolStripMenuItemRegionAddInlineStyle_Click); + // + // groupBoxFontSet + // + this.groupBoxFontSet.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFontSet.Controls.Add(this.numericUpDownFontSetFontId); + this.groupBoxFontSet.Controls.Add(this.label48); + this.groupBoxFontSet.Location = new System.Drawing.Point(544, 497); + this.groupBoxFontSet.Name = "groupBoxFontSet"; + this.groupBoxFontSet.Size = new System.Drawing.Size(226, 133); + this.groupBoxFontSet.TabIndex = 42; + this.groupBoxFontSet.TabStop = false; + this.groupBoxFontSet.Text = "Properties: Subtitle font set"; + this.groupBoxFontSet.Visible = false; + // + // numericUpDownFontSetFontId + // + this.numericUpDownFontSetFontId.Location = new System.Drawing.Point(100, 18); + this.numericUpDownFontSetFontId.Maximum = new decimal(new int[] { + 254, + 0, + 0, + 0}); + this.numericUpDownFontSetFontId.Name = "numericUpDownFontSetFontId"; + this.numericUpDownFontSetFontId.Size = new System.Drawing.Size(76, 20); + this.numericUpDownFontSetFontId.TabIndex = 15; + this.numericUpDownFontSetFontId.ValueChanged += new System.EventHandler(this.numericUpDownFontSetFontId_ValueChanged); + // + // label48 + // + this.label48.AutoSize = true; + this.label48.Location = new System.Drawing.Point(6, 20); + this.label48.Name = "label48"; + this.label48.Size = new System.Drawing.Size(81, 13); + this.label48.TabIndex = 14; + this.label48.Text = "Font id from CIF"; + // + // contextMenuStripRegionStyle + // + this.contextMenuStripRegionStyle.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemDuplicateRegionStyle}); + this.contextMenuStripRegionStyle.Name = "contextMenuStripAddPalette"; + this.contextMenuStripRegionStyle.Size = new System.Drawing.Size(125, 26); + // + // toolStripMenuItemDuplicateRegionStyle + // + this.toolStripMenuItemDuplicateRegionStyle.Name = "toolStripMenuItemDuplicateRegionStyle"; + this.toolStripMenuItemDuplicateRegionStyle.Size = new System.Drawing.Size(124, 22); + this.toolStripMenuItemDuplicateRegionStyle.Text = "Duplicate"; + this.toolStripMenuItemDuplicateRegionStyle.Click += new System.EventHandler(this.toolStripMenuItemDuplicateRegionStyle_Click); + // + // ExportTextST + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(871, 610); + this.Controls.Add(this.groupBoxPresentationSegmentRegion); + this.Controls.Add(this.groupBoxFontSet); + this.Controls.Add(this.groupBoxPropertiesPalette); + this.Controls.Add(this.groupBoxChangeFontSize); + this.Controls.Add(this.buttonImport); + this.Controls.Add(this.groupBoxSubtitleText); + this.Controls.Add(this.groupBoxFontStyle); + this.Controls.Add(this.groupBoxPropertiesUserStyle); + this.Controls.Add(this.groupBoxPropertiesRegionStyle); + this.Controls.Add(this.buttonSaveAsM2ts); + this.Controls.Add(this.groupBoxPropertiesRoot); + this.Controls.Add(this.groupBoxTextST); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSaveAsPes); + this.MinimumSize = new System.Drawing.Size(800, 645); + this.Name = "ExportTextST"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Export to TextST"; + this.groupBoxPropertiesRoot.ResumeLayout(false); + this.groupBoxPropertiesRoot.PerformLayout(); + this.groupBoxTextST.ResumeLayout(false); + this.groupBoxPropertiesRegionStyle.ResumeLayout(false); + this.groupBoxPropertiesRegionStyle.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontOutlineThickness)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontOutlinePaletteId)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontPaletteId)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontStyle)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontIdRef)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleLineSpace)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTextVerAlign)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTextHorAlign)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTextFlow)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBHeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBWidth)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBVerPos)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleTBHorPos)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleFontSize)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStylePaletteEntryId)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleHeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleWidth)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleVPos)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleHPos)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRegionStyleId)).EndInit(); + this.groupBoxPropertiesPalette.ResumeLayout(false); + this.groupBoxPropertiesPalette.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteOpacity)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteCb)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteCr)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteY)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPaletteEntry)).EndInit(); + this.groupBoxPropertiesUserStyle.ResumeLayout(false); + this.groupBoxPropertiesUserStyle.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleLineSpaceDelta)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleLineSpaceIncDec)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHeightDelta)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHeightIncDec)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBWidthDelta)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBWidthIncDec)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBVerPosDelta)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBVerPosDir)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHorPosDelta)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleTBHorPosDir)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleFontSizeDelta)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleFontSizeIncDec)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleVerPosDelta)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleVerPosDir)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleHorPosDelta)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleHorPosDir)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownUserStyleId)).EndInit(); + this.groupBoxPresentationSegmentRegion.ResumeLayout(false); + this.groupBoxPresentationSegmentRegion.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSubRegionStyleIdRef)).EndInit(); + this.contextMenuStripAddPalette.ResumeLayout(false); + this.groupBoxFontStyle.ResumeLayout(false); + this.groupBoxFontStyle.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownChangeFontStyleOutlinePaletteId)).EndInit(); + this.groupBoxChangeFontSize.ResumeLayout(false); + this.groupBoxChangeFontSize.PerformLayout(); + this.groupBoxChangeFontColor.ResumeLayout(false); + this.groupBoxChangeFontColor.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownChangeFontColor)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownChangeFontSize)).EndInit(); + this.groupBoxSubtitleText.ResumeLayout(false); + this.groupBoxSubtitleText.PerformLayout(); + this.contextMenuStripAddSubtitleContent.ResumeLayout(false); + this.contextMenuStripAddSubtitleContentFromSubRegion.ResumeLayout(false); + this.groupBoxFontSet.ResumeLayout(false); + this.groupBoxFontSet.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSetFontId)).EndInit(); + this.contextMenuStripRegionStyle.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxPropertiesRoot; + private System.Windows.Forms.GroupBox groupBoxTextST; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonSaveAsPes; + private System.Windows.Forms.Button buttonImport; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.TreeView treeView1; + private System.Windows.Forms.TextBox textBoxRoot; + private System.Windows.Forms.GroupBox groupBoxPropertiesRegionStyle; + private System.Windows.Forms.GroupBox groupBoxPropertiesPalette; + private System.Windows.Forms.GroupBox groupBoxPropertiesUserStyle; + private System.Windows.Forms.NumericUpDown numericUpDownPaletteOpacity; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.NumericUpDown numericUpDownPaletteCb; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.NumericUpDown numericUpDownPaletteCr; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.NumericUpDown numericUpDownPaletteY; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.NumericUpDown numericUpDownPaletteEntry; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel panelPaletteColor; + private System.Windows.Forms.Button buttonColor; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleHeight; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleWidth; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleVPos; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleHPos; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleId; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleFontSize; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStylePaletteEntryId; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.Button buttonSaveAsM2ts; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleLineSpaceDelta; + private System.Windows.Forms.Label label28; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleLineSpaceIncDec; + private System.Windows.Forms.Label label29; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBHeightDelta; + private System.Windows.Forms.Label label27; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBHeightIncDec; + private System.Windows.Forms.Label label25; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBWidthDelta; + private System.Windows.Forms.Label label26; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBWidthIncDec; + private System.Windows.Forms.Label label19; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBVerPosDelta; + private System.Windows.Forms.Label label20; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBVerPosDir; + private System.Windows.Forms.Label label21; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBHorPosDelta; + private System.Windows.Forms.Label label22; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleTBHorPosDir; + private System.Windows.Forms.Label label23; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleFontSizeDelta; + private System.Windows.Forms.Label label24; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleFontSizeIncDec; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleVerPosDelta; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleVerPosDir; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleHorPosDelta; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleHorPosDir; + private System.Windows.Forms.Label labelUserStyleHorPosDir; + private System.Windows.Forms.NumericUpDown numericUpDownUserStyleId; + private System.Windows.Forms.Label label18; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleFontOutlineThickness; + private System.Windows.Forms.Label labelRegionStyleFontOutlineThickness; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleFontOutlinePaletteId; + private System.Windows.Forms.Label labelRegionStyleFontOutlinePaletteId; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleFontPaletteId; + private System.Windows.Forms.Label label39; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleFontStyle; + private System.Windows.Forms.Label label38; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleFontIdRef; + private System.Windows.Forms.Label label37; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleLineSpace; + private System.Windows.Forms.Label label33; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTextVerAlign; + private System.Windows.Forms.Label label34; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTextHorAlign; + private System.Windows.Forms.Label label35; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTextFlow; + private System.Windows.Forms.Label label36; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTBHeight; + private System.Windows.Forms.Label label17; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTBWidth; + private System.Windows.Forms.Label label30; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTBVerPos; + private System.Windows.Forms.Label label31; + private System.Windows.Forms.NumericUpDown numericUpDownRegionStyleTBHorPos; + private System.Windows.Forms.Label label32; + private System.Windows.Forms.GroupBox groupBoxPresentationSegmentRegion; + private System.Windows.Forms.NumericUpDown numericUpDownSubRegionStyleIdRef; + private System.Windows.Forms.Label label40; + private System.Windows.Forms.CheckBox checkBoxSubRegionForced; + private System.Windows.Forms.CheckBox checkBoxSubRegionContinuous; + private System.Windows.Forms.ContextMenuStrip contextMenuStripAddPalette; + private System.Windows.Forms.ToolStripMenuItem addPaletteToolStripMenuItem; + private System.Windows.Forms.GroupBox groupBoxFontStyle; + private System.Windows.Forms.Label label43; + private System.Windows.Forms.Label label42; + private System.Windows.Forms.ComboBox comboBoxChangeFontStyleOutlineThickness; + private System.Windows.Forms.ComboBox comboBoxChangeFontStyleFontStyle; + private System.Windows.Forms.NumericUpDown numericUpDownChangeFontStyleOutlinePaletteId; + private System.Windows.Forms.Label label41; + private System.Windows.Forms.GroupBox groupBoxChangeFontSize; + private System.Windows.Forms.NumericUpDown numericUpDownChangeFontSize; + private System.Windows.Forms.Label label46; + private System.Windows.Forms.GroupBox groupBoxSubtitleText; + private System.Windows.Forms.TextBox textBoxSubtitleText; + private System.Windows.Forms.Label label44; + private System.Windows.Forms.GroupBox groupBoxChangeFontColor; + private System.Windows.Forms.NumericUpDown numericUpDownChangeFontColor; + private System.Windows.Forms.Label label45; + private System.Windows.Forms.ContextMenuStrip contextMenuStripAddSubtitleContent; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem addFontStyleToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem addFontSizeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem addLineBreakToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem addEndOfInlineStyleToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2; + private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip contextMenuStripAddSubtitleContentFromSubRegion; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRegionAddText; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRegionAddFontStyle; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRegionAddFontSize; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRegionAddLineBreak; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRegionAddInlineStyle; + private System.Windows.Forms.Label label47; + private System.Windows.Forms.GroupBox groupBoxFontSet; + private System.Windows.Forms.NumericUpDown numericUpDownFontSetFontId; + private System.Windows.Forms.Label label48; + private System.Windows.Forms.ToolStripMenuItem addFontSetToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip contextMenuStripRegionStyle; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDuplicateRegionStyle; + } } \ No newline at end of file diff --git a/src/Forms/ExportTextST.cs b/src/ui/Forms/ExportTextST.cs similarity index 97% rename from src/Forms/ExportTextST.cs rename to src/ui/Forms/ExportTextST.cs index a0604fb29..76d966388 100644 --- a/src/Forms/ExportTextST.cs +++ b/src/ui/Forms/ExportTextST.cs @@ -1,830 +1,830 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class ExportTextST : Form - { - private Subtitle _subtitle; - private TreeNode _rootNode; - private TreeNode _palettesNode; - private string _fileName; - private TextST _textST; - private TextST.Palette _currentPalette; - private TextST.RegionStyle _currentRegionStyle; - private TextST.UserStyle _currentUserStyle; - private TextST.SubtitleRegion _currentSubtitleRegion; - private TextST.SubtitleRegionContentChangeFontStyle _currentSubtitleFontStyle; - private TextST.SubtitleRegionContentChangeFontSize _currentSubtitleFontSize; - private TextST.SubtitleRegionContentText _currentSubtitleText; - private TextST.SubtitleRegionContentChangeFontColor _currentSubtitleFontColor; - private TextST.SubtitleRegionContentChangeFontSet _currentSubtitleFontSet; - private TreeNode _currentNode; - - private void SetGroupBoxProperties(GroupBox gb) - { - gb.Left = groupBoxPropertiesRoot.Left; - gb.Top = groupBoxPropertiesRoot.Top; - gb.Size = groupBoxPropertiesRoot.Size; - gb.Anchor = groupBoxPropertiesRoot.Anchor; - } - - public ExportTextST(Subtitle subtitle) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - SetGroupBoxProperties(groupBoxPropertiesPalette); - SetGroupBoxProperties(groupBoxPropertiesRegionStyle); - SetGroupBoxProperties(groupBoxPropertiesUserStyle); - SetGroupBoxProperties(groupBoxPresentationSegmentRegion); - SetGroupBoxProperties(groupBoxFontStyle); - SetGroupBoxProperties(groupBoxChangeFontSize); - SetGroupBoxProperties(groupBoxSubtitleText); - SetGroupBoxProperties(groupBoxChangeFontColor); - SetGroupBoxProperties(groupBoxFontSet); - - _subtitle = subtitle; - - _textST = new TextST - { - StyleSegment = TextST.DialogStyleSegment.DefaultDialogStyleSegment, - PresentationSegments = new List(), - }; - _textST.StyleSegment.NumberOfDialogPresentationSegments = _subtitle.Paragraphs.Count; - foreach (var paragraph in _subtitle.Paragraphs) - { - var dps = new TextST.DialogPresentationSegment(paragraph, _textST.StyleSegment.RegionStyles[0]); - _textST.PresentationSegments.Add(dps); - } - - UpdateTreeview(); - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void ButtonImportClick(object sender, EventArgs e) - { - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - _textST = new TextST(); - if (!_textST.IsMine(null, openFileDialog1.FileName)) - { - MessageBox.Show("Not a valid TextST file"); - return; - } - _subtitle = new Subtitle(); - _fileName = openFileDialog1.FileName; - _textST.LoadSubtitle(_subtitle, null, _fileName); - groupBoxTextST.Text = "TextST structure: " + Path.GetFileName(_fileName); - UpdateTreeview(); - } - } - - private void UpdateTreeview() - { - treeView1.Nodes.Clear(); - treeView1.BeginUpdate(); - _rootNode = new TreeNode("TextST"); - treeView1.Nodes.Add(_rootNode); - if (_textST.StyleSegment != null) - { - var styleNode = new TreeNode("Style segment"); - _rootNode.Nodes.Add(styleNode); - - var regionStylesNode = new TreeNode(string.Format("Region styles ({0})", _textST.StyleSegment.RegionStyles.Count)); - styleNode.Nodes.Add(regionStylesNode); - foreach (TextST.RegionStyle regionStyle in _textST.StyleSegment.RegionStyles) - { - var regionStyleNode = new TreeNode("Region style") { Tag = regionStyle }; - regionStylesNode.Nodes.Add(regionStyleNode); - } - - var userStylesNode = new TreeNode(string.Format("User styles ({0})", _textST.StyleSegment.UserStyles.Count)); - styleNode.Nodes.Add(userStylesNode); - foreach (TextST.UserStyle userStyle in _textST.StyleSegment.UserStyles) - { - var regionStyleNode = new TreeNode("User style") { Tag = userStyle }; - userStylesNode.Nodes.Add(regionStyleNode); - } - - _palettesNode = new TreeNode(string.Format("Palettes ({0})", _textST.StyleSegment.Palettes.Count)) { Tag = _textST.StyleSegment.Palettes }; - styleNode.Nodes.Add(_palettesNode); - foreach (TextST.Palette palette in _textST.StyleSegment.Palettes) - { - var paletteNode = new TreeNode("Palette " + palette.PaletteEntryId) { Tag = palette }; - _palettesNode.Nodes.Add(paletteNode); - } - } - - if (_textST.PresentationSegments != null) - { - var presentationSegmentsNode = new TreeNode(string.Format("Presentation segments ({0})", _textST.PresentationSegments.Count)); - _rootNode.Nodes.Add(presentationSegmentsNode); - int count = 0; - foreach (var segment in _textST.PresentationSegments) - { - count++; - var presentationSegmentNode = new TreeNode(string.Format("Segment {0}: {1} -- > {2}", count, - new TimeCode(segment.StartPtsMilliseconds), new TimeCode(segment.EndPtsMilliseconds))) - { Tag = segment }; - presentationSegmentsNode.Nodes.Add(presentationSegmentNode); - - foreach (var subtitleRegion in segment.Regions) - { - var subtitleRegionNode = new TreeNode("Subtitle region") { Tag = subtitleRegion }; - presentationSegmentNode.Nodes.Add(subtitleRegionNode); - - foreach (var content in subtitleRegion.Content) - { - if (content is TextST.SubtitleRegionContentText) - { - var textContent = content as TextST.SubtitleRegionContentText; - var contentNode = new TreeNode(content.Name + ": " + textContent.Text) { Tag = content }; - subtitleRegionNode.Nodes.Add(contentNode); - } - else if (content is TextST.SubtitleRegionContentChangeFontStyle) - { - var fontStyleContent = content as TextST.SubtitleRegionContentChangeFontStyle; - var contentNode = new TreeNode(content.Name + ": " + GetNameFromFrontStyle(fontStyleContent.FontStyle)) { Tag = content }; - subtitleRegionNode.Nodes.Add(contentNode); - } - else - { - var contentNode = new TreeNode(content.Name) { Tag = content }; - subtitleRegionNode.Nodes.Add(contentNode); - } - } - } - } - } - treeView1.ExpandAll(); - treeView1.EndUpdate(); - treeView1.SelectedNode = _rootNode; - } - - private string GetNameFromFrontStyle(int fontStyle) - { - switch (fontStyle) - { - case 0: - return "Normal"; - case 1: - return "Bold"; - case 2: - return "Italic"; - case 3: - return "Bold and italic"; - case 4: - return "Outline-bordered"; - case 5: - return "Bold and outline-bordered"; - case 6: - return "Italic and outline-bordered"; - case 7: - return "Bold and italic and outline-bordered"; - default: - return "Unknown"; - } - } - - private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) - { - groupBoxPropertiesRoot.Visible = false; - groupBoxPropertiesPalette.Visible = false; - groupBoxPropertiesRegionStyle.Visible = false; - groupBoxPropertiesUserStyle.Visible = false; - groupBoxPresentationSegmentRegion.Visible = false; - groupBoxFontStyle.Visible = false; - groupBoxChangeFontSize.Visible = false; - groupBoxSubtitleText.Visible = false; - groupBoxChangeFontColor.Visible = false; - groupBoxFontSet.Visible = false; - if (e.Node != null && _textST != null) - { - _currentNode = e.Node; - if (e.Node == _rootNode) - { - groupBoxPropertiesRoot.Visible = true; - textBoxRoot.Text = "Number of region styles: " + _textST.StyleSegment.RegionStyles.Count + Environment.NewLine + - "Number of user styles: " + _textST.StyleSegment.UserStyles.Count + Environment.NewLine + - "Number of palettes: " + _textST.StyleSegment.Palettes.Count + Environment.NewLine + - "Number of subtitles: " + _textST.StyleSegment.NumberOfDialogPresentationSegments + Environment.NewLine; - } - else if (e.Node.Tag is TextST.Palette) - { - groupBoxPropertiesPalette.Visible = true; - _currentPalette = e.Node.Tag as TextST.Palette; - numericUpDownPaletteEntry.Value = _currentPalette.PaletteEntryId; - numericUpDownPaletteY.Value = _currentPalette.Y; - numericUpDownPaletteCr.Value = _currentPalette.Cr; - numericUpDownPaletteCb.Value = _currentPalette.Cb; - numericUpDownPaletteOpacity.Value = _currentPalette.T; - panelPaletteColor.BackColor = Color.FromArgb(255, _currentPalette.Color); - } - else if (e.Node.Tag is TextST.RegionStyle) - { - groupBoxPropertiesRegionStyle.Visible = true; - _currentRegionStyle = e.Node.Tag as TextST.RegionStyle; - numericUpDownRegionStyleId.Value = _currentRegionStyle.RegionStyleId; - numericUpDownRegionStyleHPos.Value = _currentRegionStyle.RegionHorizontalPosition; - numericUpDownRegionStyleVPos.Value = _currentRegionStyle.RegionVerticalPosition; - numericUpDownRegionStyleWidth.Value = _currentRegionStyle.RegionWidth; - numericUpDownRegionStyleHeight.Value = _currentRegionStyle.RegionHeight; - numericUpDownRegionStylePaletteEntryId.Value = _currentRegionStyle.RegionBgPaletteEntryIdRef; - numericUpDownRegionStyleTBHorPos.Value = _currentRegionStyle.TextBoxHorizontalPosition; - numericUpDownRegionStyleTBVerPos.Value = _currentRegionStyle.RegionVerticalPosition; - numericUpDownRegionStyleTBWidth.Value = _currentRegionStyle.TextBoxWidth; - numericUpDownRegionStyleTBHeight.Value = _currentRegionStyle.TextBoxHeight; - numericUpDownRegionStyleTextFlow.Value = _currentRegionStyle.TextFlow; - numericUpDownRegionStyleTextHorAlign.Value = _currentRegionStyle.TextHorizontalAlignment; - numericUpDownRegionStyleTextVerAlign.Value = _currentRegionStyle.TextVerticalAlignment; - numericUpDownRegionStyleLineSpace.Value = _currentRegionStyle.LineSpace; - numericUpDownRegionStyleFontIdRef.Value = _currentRegionStyle.FontIdRef; - numericUpDownRegionStyleFontStyle.Value = _currentRegionStyle.FontStyle; - numericUpDownRegionStyleFontSize.Value = _currentRegionStyle.FontSize; - numericUpDownRegionStyleFontPaletteId.Value = _currentRegionStyle.FontPaletteEntryIdRef; - numericUpDownRegionStyleFontOutlinePaletteId.Value = _currentRegionStyle.FontOutlinePaletteEntryIdRef; - numericUpDownRegionStyleFontOutlineThickness.Value = _currentRegionStyle.FontOutlineThickness; - } - else if (e.Node.Tag is TextST.UserStyle) - { - groupBoxPropertiesUserStyle.Visible = true; - _currentUserStyle = e.Node.Tag as TextST.UserStyle; - numericUpDownUserStyleId.Value = _currentUserStyle.UserStyleId; - numericUpDownUserStyleHorPosDir.Value = _currentUserStyle.RegionHorizontalPositionDirection; - numericUpDownUserStyleHorPosDelta.Value = _currentUserStyle.RegionHorizontalPositionDelta; - numericUpDownUserStyleVerPosDir.Value = _currentUserStyle.RegionVerticalPositionDirection; - numericUpDownUserStyleVerPosDelta.Value = _currentUserStyle.RegionVerticalPositionDelta; - numericUpDownUserStyleFontSizeIncDec.Value = _currentUserStyle.FontSizeIncDec; - numericUpDownUserStyleFontSizeDelta.Value = _currentUserStyle.FontSizeDelta; - numericUpDownUserStyleTBHorPosDir.Value = _currentUserStyle.TextBoxHorizontalPositionDirection; - numericUpDownUserStyleTBHorPosDelta.Value = _currentUserStyle.TextBoxHorizontalPositionDelta; - numericUpDownUserStyleTBVerPosDir.Value = _currentUserStyle.TextBoxVerticalPositionDirection; - numericUpDownUserStyleTBVerPosDelta.Value = _currentUserStyle.TextBoxVerticalPositionDelta; - numericUpDownUserStyleTBWidthIncDec.Value = _currentUserStyle.TextBoxWidthIncDec; - numericUpDownUserStyleTBWidthDelta.Value = _currentUserStyle.TextBoxWidthDelta; - numericUpDownUserStyleTBHeightIncDec.Value = _currentUserStyle.TextBoxHeightIncDec; - numericUpDownUserStyleTBHeightDelta.Value = _currentUserStyle.TextBoxHeightDelta; - numericUpDownUserStyleLineSpaceIncDec.Value = _currentUserStyle.LineSpaceIncDec; - numericUpDownUserStyleLineSpaceDelta.Value = _currentUserStyle.LineSpaceDelta; - } - else if (e.Node.Tag is TextST.SubtitleRegion) - { - groupBoxPresentationSegmentRegion.Visible = true; - _currentSubtitleRegion = e.Node.Tag as TextST.SubtitleRegion; - checkBoxSubRegionContinuous.Checked = _currentSubtitleRegion.ContinuousPresentation; - checkBoxSubRegionForced.Checked = _currentSubtitleRegion.Forced; - numericUpDownSubRegionStyleIdRef.Value = _currentSubtitleRegion.RegionStyleId; - } - else if (e.Node.Tag is TextST.SubtitleRegionContentChangeFontStyle) - { - groupBoxFontStyle.Visible = true; - _currentSubtitleFontStyle = e.Node.Tag as TextST.SubtitleRegionContentChangeFontStyle; - comboBoxChangeFontStyleFontStyle.SelectedIndex = _currentSubtitleFontStyle.FontStyle; - numericUpDownChangeFontStyleOutlinePaletteId.Value = _currentSubtitleFontStyle.FontOutlinePaletteId; - comboBoxChangeFontStyleOutlineThickness.SelectedIndex = _currentSubtitleFontStyle.FontOutlineThickness - 1; - } - else if (e.Node.Tag is TextST.SubtitleRegionContentChangeFontSize) - { - groupBoxChangeFontSize.Visible = true; - _currentSubtitleFontSize = e.Node.Tag as TextST.SubtitleRegionContentChangeFontSize; - numericUpDownChangeFontSize.Value = _currentSubtitleFontSize.FontSize; - } - else if (e.Node.Tag is TextST.SubtitleRegionContentText) - { - groupBoxSubtitleText.Visible = true; - _currentSubtitleText = e.Node.Tag as TextST.SubtitleRegionContentText; - textBoxSubtitleText.Text = _currentSubtitleText.Text; - } - else if (e.Node.Tag is TextST.SubtitleRegionContentChangeFontColor) - { - groupBoxChangeFontColor.Visible = true; - _currentSubtitleFontColor = e.Node.Tag as TextST.SubtitleRegionContentChangeFontColor; - numericUpDownChangeFontColor.Value = _currentSubtitleFontColor.FontPaletteId; - } - else if (e.Node.Tag is TextST.SubtitleRegionContentChangeFontSet) - { - groupBoxFontSet.Visible = true; - _currentSubtitleFontSet = e.Node.Tag as TextST.SubtitleRegionContentChangeFontSet; - numericUpDownFontSetFontId.Value = _currentSubtitleFontSet.FontId; - } - } - } - - private void buttonColor_Click(object sender, EventArgs e) - { - using (var colorChooser = new ColorChooser { Color = panelPaletteColor.BackColor, ShowAlpha = true }) - { - if (colorChooser.ShowDialog() == DialogResult.OK) - { - panelPaletteColor.BackColor = colorChooser.Color; - } - } - } - - private void buttonSaveAsPes_Click(object sender, EventArgs e) - { - saveFileDialog1.DefaultExt = ".textst"; - saveFileDialog1.FileName = string.Empty; - saveFileDialog1.Filter = "TextST files|*.textst"; - if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) - { - using (var fs = new FileStream(saveFileDialog1.FileName, FileMode.Create)) - { - _textST.StyleSegment.WriteToStream(fs, _subtitle.Paragraphs.Count); - foreach (var presentationSegment in _textST.PresentationSegments) - { - presentationSegment.WriteToStream(fs); - } - } - MessageBox.Show("TextST PES packets saved as " + saveFileDialog1.FileName); - } - } - - private void buttonSaveAsM2ts_Click(object sender, EventArgs e) - { - //saveFileDialog1.DefaultExt = ".m2ts"; - //saveFileDialog1.FileName = string.Empty; - //saveFileDialog1.Filter = "m2ts files|*.m2ts"; - //if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) - //{ - // using (var fs = new FileStream(saveFileDialog1.FileName, FileMode.Create)) - // { - - // } - // MessageBox.Show("TextST M2TS file saved as " + saveFileDialog1.FileName); - //} - } - - private int GetIntFromNumericUpDown(object sender) - { - var numericUpDown = sender as NumericUpDown; - if (numericUpDown != null) - { - return (int)numericUpDown.Value; - } - - return 0; - } - - private void numericUpDownRegionStyleId_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.RegionStyleId = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleHPos_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.RegionHorizontalPosition = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleVPos_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.RegionVerticalPosition = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleWidth_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.RegionWidth = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleHeight_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.RegionHeight = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStylePaletteEntryId_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.RegionBgPaletteEntryIdRef = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleTBHorPos_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.TextBoxHorizontalPosition = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleTBVerPos_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.TextBoxVerticalPosition = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleTBWidth_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.TextBoxWidth = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleTBHeight_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.TextBoxHeight = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleTextFlow_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.TextFlow = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleTextHorAlign_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.TextHorizontalAlignment = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleTextVerAlign_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.TextVerticalAlignment = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleLineSpace_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.LineSpace = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleFontIdRef_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.FontIdRef = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleFontStyle_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.FontStyle = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleFontSize_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.FontSize = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleFontPaletteId_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.FontPaletteEntryIdRef = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleFontOutlinePaletteId_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.FontOutlinePaletteEntryIdRef = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownRegionStyleFontOutlineThickness_ValueChanged(object sender, EventArgs e) - { - _currentRegionStyle.FontOutlineThickness = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleId_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.UserStyleId = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleHorPosDir_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.RegionHorizontalPositionDirection = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleHorPosDelta_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.RegionHorizontalPositionDelta = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleVerPosDir_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.RegionVerticalPositionDirection = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleVerPosDelta_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.RegionVerticalPositionDelta = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleFontSizeIncDec_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.FontSizeIncDec = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleFontSizeDelta_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.FontSizeDelta = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleTBHorPosDir_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.TextBoxHorizontalPositionDirection = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleTBHorPosDelta_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.TextBoxHorizontalPositionDelta = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleTBVerPosDir_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.TextBoxVerticalPositionDirection = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleTBVerPosDelta_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.TextBoxVerticalPositionDelta = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleTBWidthIncDec_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.TextBoxWidthIncDec = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleTBWidthDelta_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.TextBoxWidthDelta = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleTBHeightIncDec_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.TextBoxHeightIncDec = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleTBHeightDelta_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.TextBoxHeightDelta = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleLineSpaceIncDec_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.LineSpaceIncDec = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownUserStyleLineSpaceDelta_ValueChanged(object sender, EventArgs e) - { - _currentUserStyle.LineSpaceDelta = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownPaletteEntry_ValueChanged(object sender, EventArgs e) - { - _currentPalette.PaletteEntryId = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownPaletteY_ValueChanged(object sender, EventArgs e) - { - _currentPalette.Y = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownPaletteCr_ValueChanged(object sender, EventArgs e) - { - _currentPalette.Cr = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownPaletteCb_ValueChanged(object sender, EventArgs e) - { - _currentPalette.Cb = GetIntFromNumericUpDown(sender); - } - - private void numericUpDownPaletteOpacity_ValueChanged(object sender, EventArgs e) - { - _currentPalette.T = GetIntFromNumericUpDown(sender); - } - - private void checkBoxSubRegionContinuous_CheckedChanged(object sender, EventArgs e) - { - _currentSubtitleRegion.ContinuousPresentation = (sender as CheckBox).Checked; - } - - private void checkBoxSubRegionForced_CheckedChanged(object sender, EventArgs e) - { - _currentSubtitleRegion.Forced = (sender as CheckBox).Checked; - } - - private void numericUpDownSubRegionStyleIdRef_ValueChanged(object sender, EventArgs e) - { - _currentSubtitleRegion.RegionStyleId = GetIntFromNumericUpDown(sender); - } - - private void treeView1_MouseUp(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Right) - { - var p = new Point(e.X, e.Y); - TreeNode node = treeView1.GetNodeAt(p); - if (node != null) - { - treeView1.SelectedNode = node; - if (node.Tag is List) - { - contextMenuStripAddPalette.Show(treeView1, p); - } - else if (node.Tag is TextST.SubtitleRegion) - { - contextMenuStripAddSubtitleContentFromSubRegion.Show(treeView1, p); - } - else if (node.Tag is TextST.SubtitleRegionContent) - { - contextMenuStripAddSubtitleContent.Show(treeView1, p); - } - else if (node.Tag is TextST.RegionStyle) - { - contextMenuStripRegionStyle.Show(treeView1, p); - } - } - } - } - - private void addPaletteToolStripMenuItem_Click(object sender, EventArgs e) - { - if (_textST.StyleSegment.Palettes.Count < 254) - { - int id = 1; - while (_textST.StyleSegment.Palettes.Any(p => p.PaletteEntryId == id)) - { - id++; - } - - var palette = new TextST.Palette - { - PaletteEntryId = id, - Y = 235, - Cr = 128, - Cb = 128, - T = 255 - }; - - _textST.StyleSegment.Palettes.Add(palette); - - var paletteNode = new TreeNode("Palette " + id) { Tag = palette }; - _palettesNode.Nodes.Add(paletteNode); - treeView1.SelectedNode = paletteNode; - } - } - - private void textBoxSubtitleText_TextChanged(object sender, EventArgs e) - { - _currentSubtitleText.Text = (sender as TextBox).Text; - _currentNode.Text = "Text: " + _currentSubtitleText.Text; - } - - private void numericUpDownChangeFontColor_ValueChanged(object sender, EventArgs e) - { - _currentSubtitleFontColor.FontPaletteId = GetIntFromNumericUpDown(sender); - } - - private List GetContentList(TextST.SubtitleRegionContent content) - { - foreach (var presentationSegment in _textST.PresentationSegments) - { - foreach (var region in presentationSegment.Regions) - { - if (region.Content.Contains(content)) - { - return region.Content; - } - } - } - return null; - } - - private void AddSubtitleContent(TextST.SubtitleRegionContent newContent, string title) - { - var content = _currentNode.Tag as TextST.SubtitleRegionContent; - if (content != null) - { - var list = GetContentList(content); - if (list != null) - { - var newNode = new TreeNode(title) { Tag = newContent }; - _currentNode.Parent.Nodes.Insert(_currentNode.Parent.Nodes.IndexOf(_currentNode) + 1, newNode); - int index = list.IndexOf(content); - list.Insert(index + 1, newContent); - treeView1.SelectedNode = newNode; - } - } - } - - private void addLineBreakToolStripMenuItem_Click(object sender, EventArgs e) - { - var newContent = new TextST.SubtitleRegionContentLineBreak(); - AddSubtitleContent(newContent, newContent.Name); - } - - private void addEndOfInlineStyleToolStripMenuItem_Click(object sender, EventArgs e) - { - var newContent = new TextST.SubtitleRegionContentEndOfInlineStyle(); - AddSubtitleContent(newContent, newContent.Name); - } - - private void addFontSizeToolStripMenuItem_Click(object sender, EventArgs e) - { - var newContent = new TextST.SubtitleRegionContentChangeFontSize { FontSize = 45 }; - AddSubtitleContent(newContent, newContent.Name); - } - - private void addFontSetToolStripMenuItem_Click(object sender, EventArgs e) - { - var newContent = new TextST.SubtitleRegionContentChangeFontSet(); - AddSubtitleContent(newContent, newContent.Name); - } - - private void addFontStyleToolStripMenuItem_Click(object sender, EventArgs e) - { - var newContent = new TextST.SubtitleRegionContentChangeFontStyle { FontStyle = 0, FontOutlinePaletteId = 0, FontOutlineThickness = 2 }; - AddSubtitleContent(newContent, newContent.Name); - } - - private void toolStripMenuItem1_Click(object sender, EventArgs e) - { - var newContent = new TextST.SubtitleRegionContentText(); - AddSubtitleContent(newContent, newContent.Name + ": "); - } - - private void deleteToolStripMenuItem_Click(object sender, EventArgs e) - { - var content = _currentNode.Tag as TextST.SubtitleRegionContent; - if (content != null) - { - var list = GetContentList(content); - if (list != null) - { - list.Remove(content); - _currentNode.Parent.Nodes.Remove(_currentNode); - } - } - } - - private void AddSubtitleContentFromRoot(TextST.SubtitleRegionContent newContent, string title) - { - var region = _currentNode.Tag as TextST.SubtitleRegion; - if (region != null) - { - var list = region.Content; - if (list != null) - { - var newNode = new TreeNode(title) { Tag = newContent }; - _currentNode.Nodes.Insert(0, newNode); - region.Content.Insert(0, newContent); - treeView1.SelectedNode = newNode; - } - } - } - - private void toolStripMenuItemRegionAddLineBreak_Click(object sender, EventArgs e) - { - var newContent = new TextST.SubtitleRegionContentLineBreak(); - AddSubtitleContentFromRoot(newContent, newContent.Name); - } - - private void toolStripMenuItemRegionAddText_Click(object sender, EventArgs e) - { - var newContent = new TextST.SubtitleRegionContentText(); - AddSubtitleContentFromRoot(newContent, newContent.Name + ": "); - } - - private void toolStripMenuItemRegionAddFontStyle_Click(object sender, EventArgs e) - { - var newContent = new TextST.SubtitleRegionContentChangeFontStyle { FontStyle = 0, FontOutlinePaletteId = 0, FontOutlineThickness = 2 }; - AddSubtitleContentFromRoot(newContent, newContent.Name); - } - - private void toolStripMenuItemRegionAddFontSize_Click(object sender, EventArgs e) - { - var newContent = new TextST.SubtitleRegionContentChangeFontSize { FontSize = 45 }; - AddSubtitleContentFromRoot(newContent, newContent.Name); - } - - private void toolStripMenuItemRegionAddInlineStyle_Click(object sender, EventArgs e) - { - var newContent = new TextST.SubtitleRegionContentEndOfInlineStyle(); - AddSubtitleContentFromRoot(newContent, newContent.Name); - } - - private void numericUpDownFontSetFontId_ValueChanged(object sender, EventArgs e) - { - _currentSubtitleFontSet.FontId = GetIntFromNumericUpDown(sender); - } - - private void toolStripMenuItemDuplicateRegionStyle_Click(object sender, EventArgs e) - { - var regionStyle = _currentNode.Tag as TextST.RegionStyle; - if (regionStyle != null) - { - int regionStyleId = 0; - foreach (var rs in _textST.StyleSegment.RegionStyles) - { - regionStyleId = Math.Max(regionStyleId, rs.RegionStyleId); - } - regionStyleId++; - - var newRegionStyle = new TextST.RegionStyle(regionStyle) { RegionStyleId = regionStyleId }; - _textST.StyleSegment.RegionStyles.Add(newRegionStyle); - var newNode = new TreeNode("Region style") { Tag = newRegionStyle }; - _currentNode.Parent.Nodes.Add(newNode); - _currentNode.Parent.Text = "Region styles (" + _textST.StyleSegment.RegionStyles.Count + ")"; - treeView1.SelectedNode = newNode; - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class ExportTextST : Form + { + private Subtitle _subtitle; + private TreeNode _rootNode; + private TreeNode _palettesNode; + private string _fileName; + private TextST _textST; + private TextST.Palette _currentPalette; + private TextST.RegionStyle _currentRegionStyle; + private TextST.UserStyle _currentUserStyle; + private TextST.SubtitleRegion _currentSubtitleRegion; + private TextST.SubtitleRegionContentChangeFontStyle _currentSubtitleFontStyle; + private TextST.SubtitleRegionContentChangeFontSize _currentSubtitleFontSize; + private TextST.SubtitleRegionContentText _currentSubtitleText; + private TextST.SubtitleRegionContentChangeFontColor _currentSubtitleFontColor; + private TextST.SubtitleRegionContentChangeFontSet _currentSubtitleFontSet; + private TreeNode _currentNode; + + private void SetGroupBoxProperties(GroupBox gb) + { + gb.Left = groupBoxPropertiesRoot.Left; + gb.Top = groupBoxPropertiesRoot.Top; + gb.Size = groupBoxPropertiesRoot.Size; + gb.Anchor = groupBoxPropertiesRoot.Anchor; + } + + public ExportTextST(Subtitle subtitle) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + SetGroupBoxProperties(groupBoxPropertiesPalette); + SetGroupBoxProperties(groupBoxPropertiesRegionStyle); + SetGroupBoxProperties(groupBoxPropertiesUserStyle); + SetGroupBoxProperties(groupBoxPresentationSegmentRegion); + SetGroupBoxProperties(groupBoxFontStyle); + SetGroupBoxProperties(groupBoxChangeFontSize); + SetGroupBoxProperties(groupBoxSubtitleText); + SetGroupBoxProperties(groupBoxChangeFontColor); + SetGroupBoxProperties(groupBoxFontSet); + + _subtitle = subtitle; + + _textST = new TextST + { + StyleSegment = TextST.DialogStyleSegment.DefaultDialogStyleSegment, + PresentationSegments = new List(), + }; + _textST.StyleSegment.NumberOfDialogPresentationSegments = _subtitle.Paragraphs.Count; + foreach (var paragraph in _subtitle.Paragraphs) + { + var dps = new TextST.DialogPresentationSegment(paragraph, _textST.StyleSegment.RegionStyles[0]); + _textST.PresentationSegments.Add(dps); + } + + UpdateTreeview(); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void ButtonImportClick(object sender, EventArgs e) + { + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + _textST = new TextST(); + if (!_textST.IsMine(null, openFileDialog1.FileName)) + { + MessageBox.Show("Not a valid TextST file"); + return; + } + _subtitle = new Subtitle(); + _fileName = openFileDialog1.FileName; + _textST.LoadSubtitle(_subtitle, null, _fileName); + groupBoxTextST.Text = "TextST structure: " + Path.GetFileName(_fileName); + UpdateTreeview(); + } + } + + private void UpdateTreeview() + { + treeView1.Nodes.Clear(); + treeView1.BeginUpdate(); + _rootNode = new TreeNode("TextST"); + treeView1.Nodes.Add(_rootNode); + if (_textST.StyleSegment != null) + { + var styleNode = new TreeNode("Style segment"); + _rootNode.Nodes.Add(styleNode); + + var regionStylesNode = new TreeNode(string.Format("Region styles ({0})", _textST.StyleSegment.RegionStyles.Count)); + styleNode.Nodes.Add(regionStylesNode); + foreach (TextST.RegionStyle regionStyle in _textST.StyleSegment.RegionStyles) + { + var regionStyleNode = new TreeNode("Region style") { Tag = regionStyle }; + regionStylesNode.Nodes.Add(regionStyleNode); + } + + var userStylesNode = new TreeNode(string.Format("User styles ({0})", _textST.StyleSegment.UserStyles.Count)); + styleNode.Nodes.Add(userStylesNode); + foreach (TextST.UserStyle userStyle in _textST.StyleSegment.UserStyles) + { + var regionStyleNode = new TreeNode("User style") { Tag = userStyle }; + userStylesNode.Nodes.Add(regionStyleNode); + } + + _palettesNode = new TreeNode(string.Format("Palettes ({0})", _textST.StyleSegment.Palettes.Count)) { Tag = _textST.StyleSegment.Palettes }; + styleNode.Nodes.Add(_palettesNode); + foreach (TextST.Palette palette in _textST.StyleSegment.Palettes) + { + var paletteNode = new TreeNode("Palette " + palette.PaletteEntryId) { Tag = palette }; + _palettesNode.Nodes.Add(paletteNode); + } + } + + if (_textST.PresentationSegments != null) + { + var presentationSegmentsNode = new TreeNode(string.Format("Presentation segments ({0})", _textST.PresentationSegments.Count)); + _rootNode.Nodes.Add(presentationSegmentsNode); + int count = 0; + foreach (var segment in _textST.PresentationSegments) + { + count++; + var presentationSegmentNode = new TreeNode(string.Format("Segment {0}: {1} -- > {2}", count, + new TimeCode(segment.StartPtsMilliseconds), new TimeCode(segment.EndPtsMilliseconds))) + { Tag = segment }; + presentationSegmentsNode.Nodes.Add(presentationSegmentNode); + + foreach (var subtitleRegion in segment.Regions) + { + var subtitleRegionNode = new TreeNode("Subtitle region") { Tag = subtitleRegion }; + presentationSegmentNode.Nodes.Add(subtitleRegionNode); + + foreach (var content in subtitleRegion.Content) + { + if (content is TextST.SubtitleRegionContentText) + { + var textContent = content as TextST.SubtitleRegionContentText; + var contentNode = new TreeNode(content.Name + ": " + textContent.Text) { Tag = content }; + subtitleRegionNode.Nodes.Add(contentNode); + } + else if (content is TextST.SubtitleRegionContentChangeFontStyle) + { + var fontStyleContent = content as TextST.SubtitleRegionContentChangeFontStyle; + var contentNode = new TreeNode(content.Name + ": " + GetNameFromFrontStyle(fontStyleContent.FontStyle)) { Tag = content }; + subtitleRegionNode.Nodes.Add(contentNode); + } + else + { + var contentNode = new TreeNode(content.Name) { Tag = content }; + subtitleRegionNode.Nodes.Add(contentNode); + } + } + } + } + } + treeView1.ExpandAll(); + treeView1.EndUpdate(); + treeView1.SelectedNode = _rootNode; + } + + private string GetNameFromFrontStyle(int fontStyle) + { + switch (fontStyle) + { + case 0: + return "Normal"; + case 1: + return "Bold"; + case 2: + return "Italic"; + case 3: + return "Bold and italic"; + case 4: + return "Outline-bordered"; + case 5: + return "Bold and outline-bordered"; + case 6: + return "Italic and outline-bordered"; + case 7: + return "Bold and italic and outline-bordered"; + default: + return "Unknown"; + } + } + + private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) + { + groupBoxPropertiesRoot.Visible = false; + groupBoxPropertiesPalette.Visible = false; + groupBoxPropertiesRegionStyle.Visible = false; + groupBoxPropertiesUserStyle.Visible = false; + groupBoxPresentationSegmentRegion.Visible = false; + groupBoxFontStyle.Visible = false; + groupBoxChangeFontSize.Visible = false; + groupBoxSubtitleText.Visible = false; + groupBoxChangeFontColor.Visible = false; + groupBoxFontSet.Visible = false; + if (e.Node != null && _textST != null) + { + _currentNode = e.Node; + if (e.Node == _rootNode) + { + groupBoxPropertiesRoot.Visible = true; + textBoxRoot.Text = "Number of region styles: " + _textST.StyleSegment.RegionStyles.Count + Environment.NewLine + + "Number of user styles: " + _textST.StyleSegment.UserStyles.Count + Environment.NewLine + + "Number of palettes: " + _textST.StyleSegment.Palettes.Count + Environment.NewLine + + "Number of subtitles: " + _textST.StyleSegment.NumberOfDialogPresentationSegments + Environment.NewLine; + } + else if (e.Node.Tag is TextST.Palette) + { + groupBoxPropertiesPalette.Visible = true; + _currentPalette = e.Node.Tag as TextST.Palette; + numericUpDownPaletteEntry.Value = _currentPalette.PaletteEntryId; + numericUpDownPaletteY.Value = _currentPalette.Y; + numericUpDownPaletteCr.Value = _currentPalette.Cr; + numericUpDownPaletteCb.Value = _currentPalette.Cb; + numericUpDownPaletteOpacity.Value = _currentPalette.T; + panelPaletteColor.BackColor = Color.FromArgb(255, _currentPalette.Color); + } + else if (e.Node.Tag is TextST.RegionStyle) + { + groupBoxPropertiesRegionStyle.Visible = true; + _currentRegionStyle = e.Node.Tag as TextST.RegionStyle; + numericUpDownRegionStyleId.Value = _currentRegionStyle.RegionStyleId; + numericUpDownRegionStyleHPos.Value = _currentRegionStyle.RegionHorizontalPosition; + numericUpDownRegionStyleVPos.Value = _currentRegionStyle.RegionVerticalPosition; + numericUpDownRegionStyleWidth.Value = _currentRegionStyle.RegionWidth; + numericUpDownRegionStyleHeight.Value = _currentRegionStyle.RegionHeight; + numericUpDownRegionStylePaletteEntryId.Value = _currentRegionStyle.RegionBgPaletteEntryIdRef; + numericUpDownRegionStyleTBHorPos.Value = _currentRegionStyle.TextBoxHorizontalPosition; + numericUpDownRegionStyleTBVerPos.Value = _currentRegionStyle.RegionVerticalPosition; + numericUpDownRegionStyleTBWidth.Value = _currentRegionStyle.TextBoxWidth; + numericUpDownRegionStyleTBHeight.Value = _currentRegionStyle.TextBoxHeight; + numericUpDownRegionStyleTextFlow.Value = _currentRegionStyle.TextFlow; + numericUpDownRegionStyleTextHorAlign.Value = _currentRegionStyle.TextHorizontalAlignment; + numericUpDownRegionStyleTextVerAlign.Value = _currentRegionStyle.TextVerticalAlignment; + numericUpDownRegionStyleLineSpace.Value = _currentRegionStyle.LineSpace; + numericUpDownRegionStyleFontIdRef.Value = _currentRegionStyle.FontIdRef; + numericUpDownRegionStyleFontStyle.Value = _currentRegionStyle.FontStyle; + numericUpDownRegionStyleFontSize.Value = _currentRegionStyle.FontSize; + numericUpDownRegionStyleFontPaletteId.Value = _currentRegionStyle.FontPaletteEntryIdRef; + numericUpDownRegionStyleFontOutlinePaletteId.Value = _currentRegionStyle.FontOutlinePaletteEntryIdRef; + numericUpDownRegionStyleFontOutlineThickness.Value = _currentRegionStyle.FontOutlineThickness; + } + else if (e.Node.Tag is TextST.UserStyle) + { + groupBoxPropertiesUserStyle.Visible = true; + _currentUserStyle = e.Node.Tag as TextST.UserStyle; + numericUpDownUserStyleId.Value = _currentUserStyle.UserStyleId; + numericUpDownUserStyleHorPosDir.Value = _currentUserStyle.RegionHorizontalPositionDirection; + numericUpDownUserStyleHorPosDelta.Value = _currentUserStyle.RegionHorizontalPositionDelta; + numericUpDownUserStyleVerPosDir.Value = _currentUserStyle.RegionVerticalPositionDirection; + numericUpDownUserStyleVerPosDelta.Value = _currentUserStyle.RegionVerticalPositionDelta; + numericUpDownUserStyleFontSizeIncDec.Value = _currentUserStyle.FontSizeIncDec; + numericUpDownUserStyleFontSizeDelta.Value = _currentUserStyle.FontSizeDelta; + numericUpDownUserStyleTBHorPosDir.Value = _currentUserStyle.TextBoxHorizontalPositionDirection; + numericUpDownUserStyleTBHorPosDelta.Value = _currentUserStyle.TextBoxHorizontalPositionDelta; + numericUpDownUserStyleTBVerPosDir.Value = _currentUserStyle.TextBoxVerticalPositionDirection; + numericUpDownUserStyleTBVerPosDelta.Value = _currentUserStyle.TextBoxVerticalPositionDelta; + numericUpDownUserStyleTBWidthIncDec.Value = _currentUserStyle.TextBoxWidthIncDec; + numericUpDownUserStyleTBWidthDelta.Value = _currentUserStyle.TextBoxWidthDelta; + numericUpDownUserStyleTBHeightIncDec.Value = _currentUserStyle.TextBoxHeightIncDec; + numericUpDownUserStyleTBHeightDelta.Value = _currentUserStyle.TextBoxHeightDelta; + numericUpDownUserStyleLineSpaceIncDec.Value = _currentUserStyle.LineSpaceIncDec; + numericUpDownUserStyleLineSpaceDelta.Value = _currentUserStyle.LineSpaceDelta; + } + else if (e.Node.Tag is TextST.SubtitleRegion) + { + groupBoxPresentationSegmentRegion.Visible = true; + _currentSubtitleRegion = e.Node.Tag as TextST.SubtitleRegion; + checkBoxSubRegionContinuous.Checked = _currentSubtitleRegion.ContinuousPresentation; + checkBoxSubRegionForced.Checked = _currentSubtitleRegion.Forced; + numericUpDownSubRegionStyleIdRef.Value = _currentSubtitleRegion.RegionStyleId; + } + else if (e.Node.Tag is TextST.SubtitleRegionContentChangeFontStyle) + { + groupBoxFontStyle.Visible = true; + _currentSubtitleFontStyle = e.Node.Tag as TextST.SubtitleRegionContentChangeFontStyle; + comboBoxChangeFontStyleFontStyle.SelectedIndex = _currentSubtitleFontStyle.FontStyle; + numericUpDownChangeFontStyleOutlinePaletteId.Value = _currentSubtitleFontStyle.FontOutlinePaletteId; + comboBoxChangeFontStyleOutlineThickness.SelectedIndex = _currentSubtitleFontStyle.FontOutlineThickness - 1; + } + else if (e.Node.Tag is TextST.SubtitleRegionContentChangeFontSize) + { + groupBoxChangeFontSize.Visible = true; + _currentSubtitleFontSize = e.Node.Tag as TextST.SubtitleRegionContentChangeFontSize; + numericUpDownChangeFontSize.Value = _currentSubtitleFontSize.FontSize; + } + else if (e.Node.Tag is TextST.SubtitleRegionContentText) + { + groupBoxSubtitleText.Visible = true; + _currentSubtitleText = e.Node.Tag as TextST.SubtitleRegionContentText; + textBoxSubtitleText.Text = _currentSubtitleText.Text; + } + else if (e.Node.Tag is TextST.SubtitleRegionContentChangeFontColor) + { + groupBoxChangeFontColor.Visible = true; + _currentSubtitleFontColor = e.Node.Tag as TextST.SubtitleRegionContentChangeFontColor; + numericUpDownChangeFontColor.Value = _currentSubtitleFontColor.FontPaletteId; + } + else if (e.Node.Tag is TextST.SubtitleRegionContentChangeFontSet) + { + groupBoxFontSet.Visible = true; + _currentSubtitleFontSet = e.Node.Tag as TextST.SubtitleRegionContentChangeFontSet; + numericUpDownFontSetFontId.Value = _currentSubtitleFontSet.FontId; + } + } + } + + private void buttonColor_Click(object sender, EventArgs e) + { + using (var colorChooser = new ColorChooser { Color = panelPaletteColor.BackColor, ShowAlpha = true }) + { + if (colorChooser.ShowDialog() == DialogResult.OK) + { + panelPaletteColor.BackColor = colorChooser.Color; + } + } + } + + private void buttonSaveAsPes_Click(object sender, EventArgs e) + { + saveFileDialog1.DefaultExt = ".textst"; + saveFileDialog1.FileName = string.Empty; + saveFileDialog1.Filter = "TextST files|*.textst"; + if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) + { + using (var fs = new FileStream(saveFileDialog1.FileName, FileMode.Create)) + { + _textST.StyleSegment.WriteToStream(fs, _subtitle.Paragraphs.Count); + foreach (var presentationSegment in _textST.PresentationSegments) + { + presentationSegment.WriteToStream(fs); + } + } + MessageBox.Show("TextST PES packets saved as " + saveFileDialog1.FileName); + } + } + + private void buttonSaveAsM2ts_Click(object sender, EventArgs e) + { + //saveFileDialog1.DefaultExt = ".m2ts"; + //saveFileDialog1.FileName = string.Empty; + //saveFileDialog1.Filter = "m2ts files|*.m2ts"; + //if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) + //{ + // using (var fs = new FileStream(saveFileDialog1.FileName, FileMode.Create)) + // { + + // } + // MessageBox.Show("TextST M2TS file saved as " + saveFileDialog1.FileName); + //} + } + + private int GetIntFromNumericUpDown(object sender) + { + var numericUpDown = sender as NumericUpDown; + if (numericUpDown != null) + { + return (int)numericUpDown.Value; + } + + return 0; + } + + private void numericUpDownRegionStyleId_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.RegionStyleId = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleHPos_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.RegionHorizontalPosition = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleVPos_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.RegionVerticalPosition = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleWidth_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.RegionWidth = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleHeight_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.RegionHeight = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStylePaletteEntryId_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.RegionBgPaletteEntryIdRef = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleTBHorPos_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.TextBoxHorizontalPosition = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleTBVerPos_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.TextBoxVerticalPosition = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleTBWidth_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.TextBoxWidth = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleTBHeight_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.TextBoxHeight = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleTextFlow_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.TextFlow = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleTextHorAlign_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.TextHorizontalAlignment = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleTextVerAlign_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.TextVerticalAlignment = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleLineSpace_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.LineSpace = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleFontIdRef_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.FontIdRef = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleFontStyle_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.FontStyle = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleFontSize_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.FontSize = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleFontPaletteId_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.FontPaletteEntryIdRef = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleFontOutlinePaletteId_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.FontOutlinePaletteEntryIdRef = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownRegionStyleFontOutlineThickness_ValueChanged(object sender, EventArgs e) + { + _currentRegionStyle.FontOutlineThickness = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleId_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.UserStyleId = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleHorPosDir_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.RegionHorizontalPositionDirection = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleHorPosDelta_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.RegionHorizontalPositionDelta = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleVerPosDir_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.RegionVerticalPositionDirection = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleVerPosDelta_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.RegionVerticalPositionDelta = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleFontSizeIncDec_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.FontSizeIncDec = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleFontSizeDelta_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.FontSizeDelta = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleTBHorPosDir_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.TextBoxHorizontalPositionDirection = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleTBHorPosDelta_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.TextBoxHorizontalPositionDelta = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleTBVerPosDir_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.TextBoxVerticalPositionDirection = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleTBVerPosDelta_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.TextBoxVerticalPositionDelta = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleTBWidthIncDec_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.TextBoxWidthIncDec = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleTBWidthDelta_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.TextBoxWidthDelta = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleTBHeightIncDec_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.TextBoxHeightIncDec = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleTBHeightDelta_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.TextBoxHeightDelta = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleLineSpaceIncDec_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.LineSpaceIncDec = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownUserStyleLineSpaceDelta_ValueChanged(object sender, EventArgs e) + { + _currentUserStyle.LineSpaceDelta = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownPaletteEntry_ValueChanged(object sender, EventArgs e) + { + _currentPalette.PaletteEntryId = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownPaletteY_ValueChanged(object sender, EventArgs e) + { + _currentPalette.Y = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownPaletteCr_ValueChanged(object sender, EventArgs e) + { + _currentPalette.Cr = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownPaletteCb_ValueChanged(object sender, EventArgs e) + { + _currentPalette.Cb = GetIntFromNumericUpDown(sender); + } + + private void numericUpDownPaletteOpacity_ValueChanged(object sender, EventArgs e) + { + _currentPalette.T = GetIntFromNumericUpDown(sender); + } + + private void checkBoxSubRegionContinuous_CheckedChanged(object sender, EventArgs e) + { + _currentSubtitleRegion.ContinuousPresentation = (sender as CheckBox).Checked; + } + + private void checkBoxSubRegionForced_CheckedChanged(object sender, EventArgs e) + { + _currentSubtitleRegion.Forced = (sender as CheckBox).Checked; + } + + private void numericUpDownSubRegionStyleIdRef_ValueChanged(object sender, EventArgs e) + { + _currentSubtitleRegion.RegionStyleId = GetIntFromNumericUpDown(sender); + } + + private void treeView1_MouseUp(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + var p = new Point(e.X, e.Y); + TreeNode node = treeView1.GetNodeAt(p); + if (node != null) + { + treeView1.SelectedNode = node; + if (node.Tag is List) + { + contextMenuStripAddPalette.Show(treeView1, p); + } + else if (node.Tag is TextST.SubtitleRegion) + { + contextMenuStripAddSubtitleContentFromSubRegion.Show(treeView1, p); + } + else if (node.Tag is TextST.SubtitleRegionContent) + { + contextMenuStripAddSubtitleContent.Show(treeView1, p); + } + else if (node.Tag is TextST.RegionStyle) + { + contextMenuStripRegionStyle.Show(treeView1, p); + } + } + } + } + + private void addPaletteToolStripMenuItem_Click(object sender, EventArgs e) + { + if (_textST.StyleSegment.Palettes.Count < 254) + { + int id = 1; + while (_textST.StyleSegment.Palettes.Any(p => p.PaletteEntryId == id)) + { + id++; + } + + var palette = new TextST.Palette + { + PaletteEntryId = id, + Y = 235, + Cr = 128, + Cb = 128, + T = 255 + }; + + _textST.StyleSegment.Palettes.Add(palette); + + var paletteNode = new TreeNode("Palette " + id) { Tag = palette }; + _palettesNode.Nodes.Add(paletteNode); + treeView1.SelectedNode = paletteNode; + } + } + + private void textBoxSubtitleText_TextChanged(object sender, EventArgs e) + { + _currentSubtitleText.Text = (sender as TextBox).Text; + _currentNode.Text = "Text: " + _currentSubtitleText.Text; + } + + private void numericUpDownChangeFontColor_ValueChanged(object sender, EventArgs e) + { + _currentSubtitleFontColor.FontPaletteId = GetIntFromNumericUpDown(sender); + } + + private List GetContentList(TextST.SubtitleRegionContent content) + { + foreach (var presentationSegment in _textST.PresentationSegments) + { + foreach (var region in presentationSegment.Regions) + { + if (region.Content.Contains(content)) + { + return region.Content; + } + } + } + return null; + } + + private void AddSubtitleContent(TextST.SubtitleRegionContent newContent, string title) + { + var content = _currentNode.Tag as TextST.SubtitleRegionContent; + if (content != null) + { + var list = GetContentList(content); + if (list != null) + { + var newNode = new TreeNode(title) { Tag = newContent }; + _currentNode.Parent.Nodes.Insert(_currentNode.Parent.Nodes.IndexOf(_currentNode) + 1, newNode); + int index = list.IndexOf(content); + list.Insert(index + 1, newContent); + treeView1.SelectedNode = newNode; + } + } + } + + private void addLineBreakToolStripMenuItem_Click(object sender, EventArgs e) + { + var newContent = new TextST.SubtitleRegionContentLineBreak(); + AddSubtitleContent(newContent, newContent.Name); + } + + private void addEndOfInlineStyleToolStripMenuItem_Click(object sender, EventArgs e) + { + var newContent = new TextST.SubtitleRegionContentEndOfInlineStyle(); + AddSubtitleContent(newContent, newContent.Name); + } + + private void addFontSizeToolStripMenuItem_Click(object sender, EventArgs e) + { + var newContent = new TextST.SubtitleRegionContentChangeFontSize { FontSize = 45 }; + AddSubtitleContent(newContent, newContent.Name); + } + + private void addFontSetToolStripMenuItem_Click(object sender, EventArgs e) + { + var newContent = new TextST.SubtitleRegionContentChangeFontSet(); + AddSubtitleContent(newContent, newContent.Name); + } + + private void addFontStyleToolStripMenuItem_Click(object sender, EventArgs e) + { + var newContent = new TextST.SubtitleRegionContentChangeFontStyle { FontStyle = 0, FontOutlinePaletteId = 0, FontOutlineThickness = 2 }; + AddSubtitleContent(newContent, newContent.Name); + } + + private void toolStripMenuItem1_Click(object sender, EventArgs e) + { + var newContent = new TextST.SubtitleRegionContentText(); + AddSubtitleContent(newContent, newContent.Name + ": "); + } + + private void deleteToolStripMenuItem_Click(object sender, EventArgs e) + { + var content = _currentNode.Tag as TextST.SubtitleRegionContent; + if (content != null) + { + var list = GetContentList(content); + if (list != null) + { + list.Remove(content); + _currentNode.Parent.Nodes.Remove(_currentNode); + } + } + } + + private void AddSubtitleContentFromRoot(TextST.SubtitleRegionContent newContent, string title) + { + var region = _currentNode.Tag as TextST.SubtitleRegion; + if (region != null) + { + var list = region.Content; + if (list != null) + { + var newNode = new TreeNode(title) { Tag = newContent }; + _currentNode.Nodes.Insert(0, newNode); + region.Content.Insert(0, newContent); + treeView1.SelectedNode = newNode; + } + } + } + + private void toolStripMenuItemRegionAddLineBreak_Click(object sender, EventArgs e) + { + var newContent = new TextST.SubtitleRegionContentLineBreak(); + AddSubtitleContentFromRoot(newContent, newContent.Name); + } + + private void toolStripMenuItemRegionAddText_Click(object sender, EventArgs e) + { + var newContent = new TextST.SubtitleRegionContentText(); + AddSubtitleContentFromRoot(newContent, newContent.Name + ": "); + } + + private void toolStripMenuItemRegionAddFontStyle_Click(object sender, EventArgs e) + { + var newContent = new TextST.SubtitleRegionContentChangeFontStyle { FontStyle = 0, FontOutlinePaletteId = 0, FontOutlineThickness = 2 }; + AddSubtitleContentFromRoot(newContent, newContent.Name); + } + + private void toolStripMenuItemRegionAddFontSize_Click(object sender, EventArgs e) + { + var newContent = new TextST.SubtitleRegionContentChangeFontSize { FontSize = 45 }; + AddSubtitleContentFromRoot(newContent, newContent.Name); + } + + private void toolStripMenuItemRegionAddInlineStyle_Click(object sender, EventArgs e) + { + var newContent = new TextST.SubtitleRegionContentEndOfInlineStyle(); + AddSubtitleContentFromRoot(newContent, newContent.Name); + } + + private void numericUpDownFontSetFontId_ValueChanged(object sender, EventArgs e) + { + _currentSubtitleFontSet.FontId = GetIntFromNumericUpDown(sender); + } + + private void toolStripMenuItemDuplicateRegionStyle_Click(object sender, EventArgs e) + { + var regionStyle = _currentNode.Tag as TextST.RegionStyle; + if (regionStyle != null) + { + int regionStyleId = 0; + foreach (var rs in _textST.StyleSegment.RegionStyles) + { + regionStyleId = Math.Max(regionStyleId, rs.RegionStyleId); + } + regionStyleId++; + + var newRegionStyle = new TextST.RegionStyle(regionStyle) { RegionStyleId = regionStyleId }; + _textST.StyleSegment.RegionStyles.Add(newRegionStyle); + var newNode = new TreeNode("Region style") { Tag = newRegionStyle }; + _currentNode.Parent.Nodes.Add(newNode); + _currentNode.Parent.Text = "Region styles (" + _textST.StyleSegment.RegionStyles.Count + ")"; + treeView1.SelectedNode = newNode; + } + } + + } +} diff --git a/src/Forms/ExportTextST.resx b/src/ui/Forms/ExportTextST.resx similarity index 98% rename from src/Forms/ExportTextST.resx rename to src/ui/Forms/ExportTextST.resx index 483d0d6c8..7634b3297 100644 --- a/src/Forms/ExportTextST.resx +++ b/src/ui/Forms/ExportTextST.resx @@ -1,141 +1,141 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 184, 17 - - - 320, 17 - - - 475, 17 - - - 630, 17 - - - 974, 17 - - - 178 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 184, 17 + + + 320, 17 + + + 475, 17 + + + 630, 17 + + + 974, 17 + + + 178 + \ No newline at end of file diff --git a/src/Forms/ExtractDateTimeInfo.Designer.cs b/src/ui/Forms/ExtractDateTimeInfo.Designer.cs similarity index 98% rename from src/Forms/ExtractDateTimeInfo.Designer.cs rename to src/ui/Forms/ExtractDateTimeInfo.Designer.cs index 56d8818ee..bd831e314 100644 --- a/src/Forms/ExtractDateTimeInfo.Designer.cs +++ b/src/ui/Forms/ExtractDateTimeInfo.Designer.cs @@ -1,274 +1,274 @@ -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ExtractDateTimeInfo - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - TimeCode timeCode1 = new TimeCode(); - TimeCode timeCode2 = new TimeCode(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.buttonOpenVideo = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.labelChooseVideoFile = new System.Windows.Forms.Label(); - this.comboBoxDateTimeFormats = new System.Windows.Forms.ComboBox(); - this.labelWriteFormat = new System.Windows.Forms.Label(); - this.labelVideoFileName = new System.Windows.Forms.Label(); - this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker(); - this.labelStartFrom = new System.Windows.Forms.Label(); - this.labelExample = new System.Windows.Forms.Label(); - this.textBoxExample = new System.Windows.Forms.TextBox(); - this.labelDuration = new System.Windows.Forms.Label(); - this.timeUpDownDuration = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.SuspendLayout(); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // buttonOpenVideo - // - this.buttonOpenVideo.Location = new System.Drawing.Point(12, 29); - this.buttonOpenVideo.Name = "buttonOpenVideo"; - this.buttonOpenVideo.Size = new System.Drawing.Size(28, 22); - this.buttonOpenVideo.TabIndex = 1; - this.buttonOpenVideo.Text = "..."; - this.buttonOpenVideo.UseVisualStyleBackColor = true; - this.buttonOpenVideo.Click += new System.EventHandler(this.buttonOpenVideo_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(303, 269); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 13; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(130, 269); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(167, 23); - this.buttonOK.TabIndex = 12; - this.buttonOK.Text = "&Generate subtitle"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // labelChooseVideoFile - // - this.labelChooseVideoFile.AutoSize = true; - this.labelChooseVideoFile.Location = new System.Drawing.Point(13, 13); - this.labelChooseVideoFile.Name = "labelChooseVideoFile"; - this.labelChooseVideoFile.Size = new System.Drawing.Size(226, 13); - this.labelChooseVideoFile.TabIndex = 0; - this.labelChooseVideoFile.Text = "Choose video file to extract date/time info from"; - // - // comboBoxDateTimeFormats - // - this.comboBoxDateTimeFormats.FormattingEnabled = true; - this.comboBoxDateTimeFormats.Items.AddRange(new object[] { - "M/d/yyyy hh:mm:ss ", - "M/d/yyyy
hh:mm:ss", - "F (Tuesday, April 10, 2012 9:15:07 PM)", - "dd MMM yyyy, HH:mm:ss (10 Apr 2012 21:15:07)", - "Current culture", - "hh:mm:ss", - "HH:mm:ss"}); - this.comboBoxDateTimeFormats.Location = new System.Drawing.Point(12, 153); - this.comboBoxDateTimeFormats.Name = "comboBoxDateTimeFormats"; - this.comboBoxDateTimeFormats.Size = new System.Drawing.Size(366, 21); - this.comboBoxDateTimeFormats.TabIndex = 9; - this.comboBoxDateTimeFormats.SelectedIndexChanged += new System.EventHandler(this.comboBoxDateTimeFormats_SelectedIndexChanged); - this.comboBoxDateTimeFormats.TextChanged += new System.EventHandler(this.comboBoxDateTimeFormats_TextChanged); - // - // labelWriteFormat - // - this.labelWriteFormat.AutoSize = true; - this.labelWriteFormat.Location = new System.Drawing.Point(12, 137); - this.labelWriteFormat.Name = "labelWriteFormat"; - this.labelWriteFormat.Size = new System.Drawing.Size(143, 13); - this.labelWriteFormat.TabIndex = 8; - this.labelWriteFormat.Text = "Date/time format write format"; - // - // labelVideoFileName - // - this.labelVideoFileName.AutoSize = true; - this.labelVideoFileName.Location = new System.Drawing.Point(44, 34); - this.labelVideoFileName.Name = "labelVideoFileName"; - this.labelVideoFileName.Size = new System.Drawing.Size(100, 13); - this.labelVideoFileName.TabIndex = 2; - this.labelVideoFileName.Text = "labelVideoFileName"; - // - // dateTimePicker1 - // - this.dateTimePicker1.CustomFormat = "yyyy-MM-dd"; - this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom; - this.dateTimePicker1.Location = new System.Drawing.Point(12, 87); - this.dateTimePicker1.Name = "dateTimePicker1"; - this.dateTimePicker1.Size = new System.Drawing.Size(101, 20); - this.dateTimePicker1.TabIndex = 4; - // - // labelStartFrom - // - this.labelStartFrom.AutoSize = true; - this.labelStartFrom.Location = new System.Drawing.Point(13, 71); - this.labelStartFrom.Name = "labelStartFrom"; - this.labelStartFrom.Size = new System.Drawing.Size(52, 13); - this.labelStartFrom.TabIndex = 3; - this.labelStartFrom.Text = "Start from"; - // - // labelExample - // - this.labelExample.AutoSize = true; - this.labelExample.Location = new System.Drawing.Point(12, 188); - this.labelExample.Name = "labelExample"; - this.labelExample.Size = new System.Drawing.Size(47, 13); - this.labelExample.TabIndex = 10; - this.labelExample.Text = "Example"; - // - // textBoxExample - // - this.textBoxExample.BackColor = System.Drawing.SystemColors.MenuText; - this.textBoxExample.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBoxExample.ForeColor = System.Drawing.Color.White; - this.textBoxExample.Location = new System.Drawing.Point(12, 204); - this.textBoxExample.Multiline = true; - this.textBoxExample.Name = "textBoxExample"; - this.textBoxExample.Size = new System.Drawing.Size(366, 53); - this.textBoxExample.TabIndex = 11; - // - // labelDuration - // - this.labelDuration.AutoSize = true; - this.labelDuration.Location = new System.Drawing.Point(249, 70); - this.labelDuration.Name = "labelDuration"; - this.labelDuration.Size = new System.Drawing.Size(47, 13); - this.labelDuration.TabIndex = 6; - this.labelDuration.Text = "Duration"; - // - // timeUpDownDuration - // - this.timeUpDownDuration.AutoSize = true; - this.timeUpDownDuration.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownDuration.Font = new System.Drawing.Font("Segoe UI", 9F); - this.timeUpDownDuration.Location = new System.Drawing.Point(252, 87); - this.timeUpDownDuration.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownDuration.Name = "timeUpDownDuration"; - this.timeUpDownDuration.Size = new System.Drawing.Size(96, 27); - this.timeUpDownDuration.TabIndex = 7; - timeCode1.Hours = 0; - timeCode1.Milliseconds = 0; - timeCode1.Minutes = 0; - timeCode1.Seconds = 0; - timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode1.TotalMilliseconds = 0D; - timeCode1.TotalSeconds = 0D; - this.timeUpDownDuration.TimeCode = timeCode1; - this.timeUpDownDuration.UseVideoOffset = false; - // - // timeUpDownStartTime - // - this.timeUpDownStartTime.AutoSize = true; - this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownStartTime.Font = new System.Drawing.Font("Segoe UI", 9F); - this.timeUpDownStartTime.Location = new System.Drawing.Point(118, 86); - this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownStartTime.Name = "timeUpDownStartTime"; - this.timeUpDownStartTime.Size = new System.Drawing.Size(96, 27); - this.timeUpDownStartTime.TabIndex = 5; - timeCode2.Hours = 0; - timeCode2.Milliseconds = 0; - timeCode2.Minutes = 0; - timeCode2.Seconds = 0; - timeCode2.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode2.TotalMilliseconds = 0D; - timeCode2.TotalSeconds = 0D; - this.timeUpDownStartTime.TimeCode = timeCode2; - this.timeUpDownStartTime.UseVideoOffset = false; - // - // ExtractDateTimeInfo - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(390, 302); - this.Controls.Add(this.timeUpDownDuration); - this.Controls.Add(this.labelDuration); - this.Controls.Add(this.timeUpDownStartTime); - this.Controls.Add(this.textBoxExample); - this.Controls.Add(this.labelExample); - this.Controls.Add(this.labelStartFrom); - this.Controls.Add(this.dateTimePicker1); - this.Controls.Add(this.labelVideoFileName); - this.Controls.Add(this.labelWriteFormat); - this.Controls.Add(this.comboBoxDateTimeFormats); - this.Controls.Add(this.labelChooseVideoFile); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonOpenVideo); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ExtractDateTimeInfo"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Extract date and time information"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExtractDateTimeInfo_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Button buttonOpenVideo; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Label labelChooseVideoFile; - private System.Windows.Forms.ComboBox comboBoxDateTimeFormats; - private System.Windows.Forms.Label labelWriteFormat; - private System.Windows.Forms.Label labelVideoFileName; - private System.Windows.Forms.DateTimePicker dateTimePicker1; - private System.Windows.Forms.Label labelStartFrom; - private System.Windows.Forms.Label labelExample; - private System.Windows.Forms.TextBox textBoxExample; - private Controls.TimeUpDown timeUpDownStartTime; - private System.Windows.Forms.Label labelDuration; - private Controls.TimeUpDown timeUpDownDuration; - } +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ExtractDateTimeInfo + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + TimeCode timeCode1 = new TimeCode(); + TimeCode timeCode2 = new TimeCode(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.buttonOpenVideo = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.labelChooseVideoFile = new System.Windows.Forms.Label(); + this.comboBoxDateTimeFormats = new System.Windows.Forms.ComboBox(); + this.labelWriteFormat = new System.Windows.Forms.Label(); + this.labelVideoFileName = new System.Windows.Forms.Label(); + this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker(); + this.labelStartFrom = new System.Windows.Forms.Label(); + this.labelExample = new System.Windows.Forms.Label(); + this.textBoxExample = new System.Windows.Forms.TextBox(); + this.labelDuration = new System.Windows.Forms.Label(); + this.timeUpDownDuration = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.SuspendLayout(); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // buttonOpenVideo + // + this.buttonOpenVideo.Location = new System.Drawing.Point(12, 29); + this.buttonOpenVideo.Name = "buttonOpenVideo"; + this.buttonOpenVideo.Size = new System.Drawing.Size(28, 22); + this.buttonOpenVideo.TabIndex = 1; + this.buttonOpenVideo.Text = "..."; + this.buttonOpenVideo.UseVisualStyleBackColor = true; + this.buttonOpenVideo.Click += new System.EventHandler(this.buttonOpenVideo_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(303, 269); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 13; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(130, 269); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(167, 23); + this.buttonOK.TabIndex = 12; + this.buttonOK.Text = "&Generate subtitle"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // labelChooseVideoFile + // + this.labelChooseVideoFile.AutoSize = true; + this.labelChooseVideoFile.Location = new System.Drawing.Point(13, 13); + this.labelChooseVideoFile.Name = "labelChooseVideoFile"; + this.labelChooseVideoFile.Size = new System.Drawing.Size(226, 13); + this.labelChooseVideoFile.TabIndex = 0; + this.labelChooseVideoFile.Text = "Choose video file to extract date/time info from"; + // + // comboBoxDateTimeFormats + // + this.comboBoxDateTimeFormats.FormattingEnabled = true; + this.comboBoxDateTimeFormats.Items.AddRange(new object[] { + "M/d/yyyy hh:mm:ss ", + "M/d/yyyy
hh:mm:ss", + "F (Tuesday, April 10, 2012 9:15:07 PM)", + "dd MMM yyyy, HH:mm:ss (10 Apr 2012 21:15:07)", + "Current culture", + "hh:mm:ss", + "HH:mm:ss"}); + this.comboBoxDateTimeFormats.Location = new System.Drawing.Point(12, 153); + this.comboBoxDateTimeFormats.Name = "comboBoxDateTimeFormats"; + this.comboBoxDateTimeFormats.Size = new System.Drawing.Size(366, 21); + this.comboBoxDateTimeFormats.TabIndex = 9; + this.comboBoxDateTimeFormats.SelectedIndexChanged += new System.EventHandler(this.comboBoxDateTimeFormats_SelectedIndexChanged); + this.comboBoxDateTimeFormats.TextChanged += new System.EventHandler(this.comboBoxDateTimeFormats_TextChanged); + // + // labelWriteFormat + // + this.labelWriteFormat.AutoSize = true; + this.labelWriteFormat.Location = new System.Drawing.Point(12, 137); + this.labelWriteFormat.Name = "labelWriteFormat"; + this.labelWriteFormat.Size = new System.Drawing.Size(143, 13); + this.labelWriteFormat.TabIndex = 8; + this.labelWriteFormat.Text = "Date/time format write format"; + // + // labelVideoFileName + // + this.labelVideoFileName.AutoSize = true; + this.labelVideoFileName.Location = new System.Drawing.Point(44, 34); + this.labelVideoFileName.Name = "labelVideoFileName"; + this.labelVideoFileName.Size = new System.Drawing.Size(100, 13); + this.labelVideoFileName.TabIndex = 2; + this.labelVideoFileName.Text = "labelVideoFileName"; + // + // dateTimePicker1 + // + this.dateTimePicker1.CustomFormat = "yyyy-MM-dd"; + this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.dateTimePicker1.Location = new System.Drawing.Point(12, 87); + this.dateTimePicker1.Name = "dateTimePicker1"; + this.dateTimePicker1.Size = new System.Drawing.Size(101, 20); + this.dateTimePicker1.TabIndex = 4; + // + // labelStartFrom + // + this.labelStartFrom.AutoSize = true; + this.labelStartFrom.Location = new System.Drawing.Point(13, 71); + this.labelStartFrom.Name = "labelStartFrom"; + this.labelStartFrom.Size = new System.Drawing.Size(52, 13); + this.labelStartFrom.TabIndex = 3; + this.labelStartFrom.Text = "Start from"; + // + // labelExample + // + this.labelExample.AutoSize = true; + this.labelExample.Location = new System.Drawing.Point(12, 188); + this.labelExample.Name = "labelExample"; + this.labelExample.Size = new System.Drawing.Size(47, 13); + this.labelExample.TabIndex = 10; + this.labelExample.Text = "Example"; + // + // textBoxExample + // + this.textBoxExample.BackColor = System.Drawing.SystemColors.MenuText; + this.textBoxExample.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textBoxExample.ForeColor = System.Drawing.Color.White; + this.textBoxExample.Location = new System.Drawing.Point(12, 204); + this.textBoxExample.Multiline = true; + this.textBoxExample.Name = "textBoxExample"; + this.textBoxExample.Size = new System.Drawing.Size(366, 53); + this.textBoxExample.TabIndex = 11; + // + // labelDuration + // + this.labelDuration.AutoSize = true; + this.labelDuration.Location = new System.Drawing.Point(249, 70); + this.labelDuration.Name = "labelDuration"; + this.labelDuration.Size = new System.Drawing.Size(47, 13); + this.labelDuration.TabIndex = 6; + this.labelDuration.Text = "Duration"; + // + // timeUpDownDuration + // + this.timeUpDownDuration.AutoSize = true; + this.timeUpDownDuration.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownDuration.Font = new System.Drawing.Font("Segoe UI", 9F); + this.timeUpDownDuration.Location = new System.Drawing.Point(252, 87); + this.timeUpDownDuration.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownDuration.Name = "timeUpDownDuration"; + this.timeUpDownDuration.Size = new System.Drawing.Size(96, 27); + this.timeUpDownDuration.TabIndex = 7; + timeCode1.Hours = 0; + timeCode1.Milliseconds = 0; + timeCode1.Minutes = 0; + timeCode1.Seconds = 0; + timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode1.TotalMilliseconds = 0D; + timeCode1.TotalSeconds = 0D; + this.timeUpDownDuration.TimeCode = timeCode1; + this.timeUpDownDuration.UseVideoOffset = false; + // + // timeUpDownStartTime + // + this.timeUpDownStartTime.AutoSize = true; + this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownStartTime.Font = new System.Drawing.Font("Segoe UI", 9F); + this.timeUpDownStartTime.Location = new System.Drawing.Point(118, 86); + this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownStartTime.Name = "timeUpDownStartTime"; + this.timeUpDownStartTime.Size = new System.Drawing.Size(96, 27); + this.timeUpDownStartTime.TabIndex = 5; + timeCode2.Hours = 0; + timeCode2.Milliseconds = 0; + timeCode2.Minutes = 0; + timeCode2.Seconds = 0; + timeCode2.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode2.TotalMilliseconds = 0D; + timeCode2.TotalSeconds = 0D; + this.timeUpDownStartTime.TimeCode = timeCode2; + this.timeUpDownStartTime.UseVideoOffset = false; + // + // ExtractDateTimeInfo + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(390, 302); + this.Controls.Add(this.timeUpDownDuration); + this.Controls.Add(this.labelDuration); + this.Controls.Add(this.timeUpDownStartTime); + this.Controls.Add(this.textBoxExample); + this.Controls.Add(this.labelExample); + this.Controls.Add(this.labelStartFrom); + this.Controls.Add(this.dateTimePicker1); + this.Controls.Add(this.labelVideoFileName); + this.Controls.Add(this.labelWriteFormat); + this.Controls.Add(this.comboBoxDateTimeFormats); + this.Controls.Add(this.labelChooseVideoFile); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonOpenVideo); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ExtractDateTimeInfo"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Extract date and time information"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExtractDateTimeInfo_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Button buttonOpenVideo; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Label labelChooseVideoFile; + private System.Windows.Forms.ComboBox comboBoxDateTimeFormats; + private System.Windows.Forms.Label labelWriteFormat; + private System.Windows.Forms.Label labelVideoFileName; + private System.Windows.Forms.DateTimePicker dateTimePicker1; + private System.Windows.Forms.Label labelStartFrom; + private System.Windows.Forms.Label labelExample; + private System.Windows.Forms.TextBox textBoxExample; + private Controls.TimeUpDown timeUpDownStartTime; + private System.Windows.Forms.Label labelDuration; + private Controls.TimeUpDown timeUpDownDuration; + } } \ No newline at end of file diff --git a/src/Forms/ExtractDateTimeInfo.cs b/src/ui/Forms/ExtractDateTimeInfo.cs similarity index 97% rename from src/Forms/ExtractDateTimeInfo.cs rename to src/ui/Forms/ExtractDateTimeInfo.cs index 5d45e1027..7fc93a4f6 100644 --- a/src/Forms/ExtractDateTimeInfo.cs +++ b/src/ui/Forms/ExtractDateTimeInfo.cs @@ -1,150 +1,150 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ExtractDateTimeInfo : PositionAndSizeForm - { - public Subtitle DateTimeSubtitle { get; private set; } - public string VideoFileName { get; private set; } - private readonly List _formats = new List(); - - public ExtractDateTimeInfo() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - comboBoxDateTimeFormats.SelectedIndex = 0; - labelVideoFileName.Text = string.Empty; - timeUpDownStartTime.TimeCode = new TimeCode(); - timeUpDownDuration.TimeCode = new TimeCode(1, 0, 0, 0); - comboBoxDateTimeFormats.Items.Clear(); - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - foreach (string format in Configuration.Settings.Tools.GenerateTimeCodePatterns.Split(';')) - { - _formats.Add(format); - comboBoxDateTimeFormats.Items.Add(format); - } - if (_formats.Count > 0) - { - comboBoxDateTimeFormats.SelectedIndex = 0; - } - - var l = Configuration.Settings.Language.ExtractDateTimeInfo; - Text = l.Title; - labelChooseVideoFile.Text = l.OpenVideoFile; - labelStartFrom.Text = l.StartFrom; - labelDuration.Text = Configuration.Settings.Language.General.Duration; - labelExample.Text = l.Example; - buttonOK.Text = l.GenerateSubtitle; - labelWriteFormat.Text = l.DateTimeFormat; - } - - private static string DecodeFormat(DateTime dateTime, string format) - { - try - { - var sb = new StringBuilder(); - foreach (string s in format.Replace("
", "|").Replace("
", "|").Replace("
", "|").Replace("
", "|").Replace("
", "|").Replace("
", "|").Split('|')) - { - sb.AppendLine(dateTime.ToString(s)); - } - return sb.ToString().Trim(); - } - catch - { - return "Error"; - } - } - - private void buttonOpenVideo_Click(object sender, EventArgs e) - { - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - VideoFileName = openFileDialog1.FileName; - labelVideoFileName.Text = VideoFileName; - - DateTime start; - double durationInSeconds; - string ext = Path.GetExtension(VideoFileName).ToLowerInvariant(); - if (ext == ".mp4" || ext == ".m4v" || ext == ".3gp") - { - MP4Parser mp4Parser = new MP4Parser(VideoFileName); - start = mp4Parser.CreationDate; - durationInSeconds = mp4Parser.Duration.TotalSeconds; - } - else - { - var fi = new FileInfo(VideoFileName); - start = fi.CreationTime; - VideoInfo vi = UiUtil.GetVideoInfo(VideoFileName); - durationInSeconds = vi.TotalMilliseconds / TimeCode.BaseUnit; - if (durationInSeconds < 1) - { - MessageBox.Show("Unable to get duration"); - durationInSeconds = 60 * 60; - } - } - dateTimePicker1.Value = start; - timeUpDownStartTime.TimeCode = new TimeCode(start.Hour, start.Minute, start.Second, start.Millisecond); - timeUpDownDuration.TimeCode = TimeCode.FromSeconds(durationInSeconds); - } - } - - private DateTime GetStartDateTime() - { - return new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day, - timeUpDownStartTime.TimeCode.Hours, timeUpDownStartTime.TimeCode.Minutes, - timeUpDownStartTime.TimeCode.Seconds, timeUpDownStartTime.TimeCode.Milliseconds); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - DateTimeSubtitle = new Subtitle(); - DateTime start = GetStartDateTime(); - double durationInSeconds = timeUpDownDuration.TimeCode.TotalSeconds; - for (int i = 0; i < durationInSeconds; i++) - { - Paragraph p = new Paragraph(); - p.Text = FormatDateTime(start); - start = start.AddSeconds(1); - p.StartTime = TimeCode.FromSeconds(i); - p.EndTime = TimeCode.FromSeconds(i + 0.999); - DateTimeSubtitle.Paragraphs.Add(p); - } - DialogResult = DialogResult.OK; - } - - private string FormatDateTime(DateTime dt) - { - return DecodeFormat(dt, comboBoxDateTimeFormats.Text); - } - - private void comboBoxDateTimeFormats_SelectedIndexChanged(object sender, EventArgs e) - { - textBoxExample.Text = FormatDateTime(DateTime.Now); - } - - private void comboBoxDateTimeFormats_TextChanged(object sender, EventArgs e) - { - textBoxExample.Text = FormatDateTime(DateTime.Now); - } - - private void ExtractDateTimeInfo_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - e.SuppressKeyPress = true; - DialogResult = DialogResult.Cancel; - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ExtractDateTimeInfo : PositionAndSizeForm + { + public Subtitle DateTimeSubtitle { get; private set; } + public string VideoFileName { get; private set; } + private readonly List _formats = new List(); + + public ExtractDateTimeInfo() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + comboBoxDateTimeFormats.SelectedIndex = 0; + labelVideoFileName.Text = string.Empty; + timeUpDownStartTime.TimeCode = new TimeCode(); + timeUpDownDuration.TimeCode = new TimeCode(1, 0, 0, 0); + comboBoxDateTimeFormats.Items.Clear(); + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + foreach (string format in Configuration.Settings.Tools.GenerateTimeCodePatterns.Split(';')) + { + _formats.Add(format); + comboBoxDateTimeFormats.Items.Add(format); + } + if (_formats.Count > 0) + { + comboBoxDateTimeFormats.SelectedIndex = 0; + } + + var l = Configuration.Settings.Language.ExtractDateTimeInfo; + Text = l.Title; + labelChooseVideoFile.Text = l.OpenVideoFile; + labelStartFrom.Text = l.StartFrom; + labelDuration.Text = Configuration.Settings.Language.General.Duration; + labelExample.Text = l.Example; + buttonOK.Text = l.GenerateSubtitle; + labelWriteFormat.Text = l.DateTimeFormat; + } + + private static string DecodeFormat(DateTime dateTime, string format) + { + try + { + var sb = new StringBuilder(); + foreach (string s in format.Replace("
", "|").Replace("
", "|").Replace("
", "|").Replace("
", "|").Replace("
", "|").Replace("
", "|").Split('|')) + { + sb.AppendLine(dateTime.ToString(s)); + } + return sb.ToString().Trim(); + } + catch + { + return "Error"; + } + } + + private void buttonOpenVideo_Click(object sender, EventArgs e) + { + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + VideoFileName = openFileDialog1.FileName; + labelVideoFileName.Text = VideoFileName; + + DateTime start; + double durationInSeconds; + string ext = Path.GetExtension(VideoFileName).ToLowerInvariant(); + if (ext == ".mp4" || ext == ".m4v" || ext == ".3gp") + { + MP4Parser mp4Parser = new MP4Parser(VideoFileName); + start = mp4Parser.CreationDate; + durationInSeconds = mp4Parser.Duration.TotalSeconds; + } + else + { + var fi = new FileInfo(VideoFileName); + start = fi.CreationTime; + VideoInfo vi = UiUtil.GetVideoInfo(VideoFileName); + durationInSeconds = vi.TotalMilliseconds / TimeCode.BaseUnit; + if (durationInSeconds < 1) + { + MessageBox.Show("Unable to get duration"); + durationInSeconds = 60 * 60; + } + } + dateTimePicker1.Value = start; + timeUpDownStartTime.TimeCode = new TimeCode(start.Hour, start.Minute, start.Second, start.Millisecond); + timeUpDownDuration.TimeCode = TimeCode.FromSeconds(durationInSeconds); + } + } + + private DateTime GetStartDateTime() + { + return new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day, + timeUpDownStartTime.TimeCode.Hours, timeUpDownStartTime.TimeCode.Minutes, + timeUpDownStartTime.TimeCode.Seconds, timeUpDownStartTime.TimeCode.Milliseconds); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + DateTimeSubtitle = new Subtitle(); + DateTime start = GetStartDateTime(); + double durationInSeconds = timeUpDownDuration.TimeCode.TotalSeconds; + for (int i = 0; i < durationInSeconds; i++) + { + Paragraph p = new Paragraph(); + p.Text = FormatDateTime(start); + start = start.AddSeconds(1); + p.StartTime = TimeCode.FromSeconds(i); + p.EndTime = TimeCode.FromSeconds(i + 0.999); + DateTimeSubtitle.Paragraphs.Add(p); + } + DialogResult = DialogResult.OK; + } + + private string FormatDateTime(DateTime dt) + { + return DecodeFormat(dt, comboBoxDateTimeFormats.Text); + } + + private void comboBoxDateTimeFormats_SelectedIndexChanged(object sender, EventArgs e) + { + textBoxExample.Text = FormatDateTime(DateTime.Now); + } + + private void comboBoxDateTimeFormats_TextChanged(object sender, EventArgs e) + { + textBoxExample.Text = FormatDateTime(DateTime.Now); + } + + private void ExtractDateTimeInfo_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + e.SuppressKeyPress = true; + DialogResult = DialogResult.Cancel; + } + } + + } +} diff --git a/src/Forms/ExtractDateTimeInfo.resx b/src/ui/Forms/ExtractDateTimeInfo.resx similarity index 97% rename from src/Forms/ExtractDateTimeInfo.resx rename to src/ui/Forms/ExtractDateTimeInfo.resx index 3a7d67153..9bad2f599 100644 --- a/src/Forms/ExtractDateTimeInfo.resx +++ b/src/ui/Forms/ExtractDateTimeInfo.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/FcpProperties.Designer.cs b/src/ui/Forms/FcpProperties.Designer.cs similarity index 97% rename from src/Forms/FcpProperties.Designer.cs rename to src/ui/Forms/FcpProperties.Designer.cs index c9ed2caf0..c4a95429d 100644 --- a/src/Forms/FcpProperties.Designer.cs +++ b/src/ui/Forms/FcpProperties.Designer.cs @@ -1,152 +1,152 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class FcpProperties - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBoxFont = new System.Windows.Forms.GroupBox(); - this.textBoxFontName = new System.Windows.Forms.TextBox(); - this.labelFontName = new System.Windows.Forms.Label(); - this.numericUpDownFontSize = new System.Windows.Forms.NumericUpDown(); - this.labelFontSize = new System.Windows.Forms.Label(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxFont.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSize)).BeginInit(); - this.SuspendLayout(); - // - // groupBoxFont - // - this.groupBoxFont.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxFont.Controls.Add(this.textBoxFontName); - this.groupBoxFont.Controls.Add(this.labelFontName); - this.groupBoxFont.Controls.Add(this.numericUpDownFontSize); - this.groupBoxFont.Controls.Add(this.labelFontSize); - this.groupBoxFont.Location = new System.Drawing.Point(12, 12); - this.groupBoxFont.Name = "groupBoxFont"; - this.groupBoxFont.Size = new System.Drawing.Size(439, 116); - this.groupBoxFont.TabIndex = 0; - this.groupBoxFont.TabStop = false; - this.groupBoxFont.Text = "Font"; - // - // textBoxFontName - // - this.textBoxFontName.Location = new System.Drawing.Point(133, 28); - this.textBoxFontName.Name = "textBoxFontName"; - this.textBoxFontName.Size = new System.Drawing.Size(197, 20); - this.textBoxFontName.TabIndex = 1; - // - // labelFontName - // - this.labelFontName.AutoSize = true; - this.labelFontName.Location = new System.Drawing.Point(9, 35); - this.labelFontName.Name = "labelFontName"; - this.labelFontName.Size = new System.Drawing.Size(35, 13); - this.labelFontName.TabIndex = 0; - this.labelFontName.Text = "Name"; - // - // numericUpDownFontSize - // - this.numericUpDownFontSize.Location = new System.Drawing.Point(133, 54); - this.numericUpDownFontSize.Maximum = new decimal(new int[] { - 200, - 0, - 0, - 0}); - this.numericUpDownFontSize.Name = "numericUpDownFontSize"; - this.numericUpDownFontSize.Size = new System.Drawing.Size(112, 20); - this.numericUpDownFontSize.TabIndex = 3; - // - // labelFontSize - // - this.labelFontSize.AutoSize = true; - this.labelFontSize.Location = new System.Drawing.Point(9, 61); - this.labelFontSize.Name = "labelFontSize"; - this.labelFontSize.Size = new System.Drawing.Size(27, 13); - this.labelFontSize.TabIndex = 2; - this.labelFontSize.Text = "Size"; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(376, 134); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 2; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(295, 134); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 1; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // FcpProperties - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(463, 167); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.groupBoxFont); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.Name = "FcpProperties"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Fincal Cut Pro XML - Properties"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FcpProperties_KeyDown); - this.groupBoxFont.ResumeLayout(false); - this.groupBoxFont.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSize)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxFont; - private System.Windows.Forms.NumericUpDown numericUpDownFontSize; - private System.Windows.Forms.Label labelFontSize; - private System.Windows.Forms.TextBox textBoxFontName; - private System.Windows.Forms.Label labelFontName; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class FcpProperties + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBoxFont = new System.Windows.Forms.GroupBox(); + this.textBoxFontName = new System.Windows.Forms.TextBox(); + this.labelFontName = new System.Windows.Forms.Label(); + this.numericUpDownFontSize = new System.Windows.Forms.NumericUpDown(); + this.labelFontSize = new System.Windows.Forms.Label(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxFont.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSize)).BeginInit(); + this.SuspendLayout(); + // + // groupBoxFont + // + this.groupBoxFont.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFont.Controls.Add(this.textBoxFontName); + this.groupBoxFont.Controls.Add(this.labelFontName); + this.groupBoxFont.Controls.Add(this.numericUpDownFontSize); + this.groupBoxFont.Controls.Add(this.labelFontSize); + this.groupBoxFont.Location = new System.Drawing.Point(12, 12); + this.groupBoxFont.Name = "groupBoxFont"; + this.groupBoxFont.Size = new System.Drawing.Size(439, 116); + this.groupBoxFont.TabIndex = 0; + this.groupBoxFont.TabStop = false; + this.groupBoxFont.Text = "Font"; + // + // textBoxFontName + // + this.textBoxFontName.Location = new System.Drawing.Point(133, 28); + this.textBoxFontName.Name = "textBoxFontName"; + this.textBoxFontName.Size = new System.Drawing.Size(197, 20); + this.textBoxFontName.TabIndex = 1; + // + // labelFontName + // + this.labelFontName.AutoSize = true; + this.labelFontName.Location = new System.Drawing.Point(9, 35); + this.labelFontName.Name = "labelFontName"; + this.labelFontName.Size = new System.Drawing.Size(35, 13); + this.labelFontName.TabIndex = 0; + this.labelFontName.Text = "Name"; + // + // numericUpDownFontSize + // + this.numericUpDownFontSize.Location = new System.Drawing.Point(133, 54); + this.numericUpDownFontSize.Maximum = new decimal(new int[] { + 200, + 0, + 0, + 0}); + this.numericUpDownFontSize.Name = "numericUpDownFontSize"; + this.numericUpDownFontSize.Size = new System.Drawing.Size(112, 20); + this.numericUpDownFontSize.TabIndex = 3; + // + // labelFontSize + // + this.labelFontSize.AutoSize = true; + this.labelFontSize.Location = new System.Drawing.Point(9, 61); + this.labelFontSize.Name = "labelFontSize"; + this.labelFontSize.Size = new System.Drawing.Size(27, 13); + this.labelFontSize.TabIndex = 2; + this.labelFontSize.Text = "Size"; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(376, 134); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 2; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(295, 134); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 1; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // FcpProperties + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(463, 167); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.groupBoxFont); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.Name = "FcpProperties"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Fincal Cut Pro XML - Properties"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FcpProperties_KeyDown); + this.groupBoxFont.ResumeLayout(false); + this.groupBoxFont.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSize)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxFont; + private System.Windows.Forms.NumericUpDown numericUpDownFontSize; + private System.Windows.Forms.Label labelFontSize; + private System.Windows.Forms.TextBox textBoxFontName; + private System.Windows.Forms.Label labelFontName; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + } } \ No newline at end of file diff --git a/src/Forms/FcpProperties.cs b/src/ui/Forms/FcpProperties.cs similarity index 96% rename from src/Forms/FcpProperties.cs rename to src/ui/Forms/FcpProperties.cs index f8710975e..57ba02c41 100644 --- a/src/Forms/FcpProperties.cs +++ b/src/ui/Forms/FcpProperties.cs @@ -1,50 +1,50 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class FcpProperties : PositionAndSizeForm - { - public int FcpFontSize { get; set; } - public string FcpFontName { get; set; } - - public FcpProperties() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - textBoxFontName.Text = Configuration.Settings.SubtitleSettings.FcpFontName; - try - { - numericUpDownFontSize.Value = Configuration.Settings.SubtitleSettings.FcpFontSize; - } - catch - { - numericUpDownFontSize.Value = 18; - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - FcpFontName = textBoxFontName.Text; - FcpFontSize = (int)numericUpDownFontSize.Value; - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void FcpProperties_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class FcpProperties : PositionAndSizeForm + { + public int FcpFontSize { get; set; } + public string FcpFontName { get; set; } + + public FcpProperties() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + textBoxFontName.Text = Configuration.Settings.SubtitleSettings.FcpFontName; + try + { + numericUpDownFontSize.Value = Configuration.Settings.SubtitleSettings.FcpFontSize; + } + catch + { + numericUpDownFontSize.Value = 18; + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + FcpFontName = textBoxFontName.Text; + FcpFontSize = (int)numericUpDownFontSize.Value; + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void FcpProperties_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + } +} diff --git a/src/Forms/Ocr/DownloadTesseract302.resx b/src/ui/Forms/FcpProperties.resx similarity index 100% rename from src/Forms/Ocr/DownloadTesseract302.resx rename to src/ui/Forms/FcpProperties.resx diff --git a/src/Forms/FindDialog.Designer.cs b/src/ui/Forms/FindDialog.Designer.cs similarity index 98% rename from src/Forms/FindDialog.Designer.cs rename to src/ui/Forms/FindDialog.Designer.cs index e393e3ff4..d0ee2c2ff 100644 --- a/src/Forms/FindDialog.Designer.cs +++ b/src/ui/Forms/FindDialog.Designer.cs @@ -1,190 +1,190 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class FindDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.textBoxFind = new System.Windows.Forms.TextBox(); - this.buttonFind = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.radioButtonNormal = new System.Windows.Forms.RadioButton(); - this.radioButtonCaseSensitive = new System.Windows.Forms.RadioButton(); - this.radioButtonRegEx = new System.Windows.Forms.RadioButton(); - this.comboBoxFind = new System.Windows.Forms.ComboBox(); - this.buttonCount = new System.Windows.Forms.Button(); - this.labelCount = new System.Windows.Forms.Label(); - this.checkBoxWholeWord = new System.Windows.Forms.CheckBox(); - this.SuspendLayout(); - // - // textBoxFind - // - this.textBoxFind.Location = new System.Drawing.Point(12, 12); - this.textBoxFind.Name = "textBoxFind"; - this.textBoxFind.Size = new System.Drawing.Size(189, 21); - this.textBoxFind.TabIndex = 0; - this.textBoxFind.TextChanged += new System.EventHandler(this.textBoxFind_TextChanged); - this.textBoxFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxFind_KeyDown); - // - // buttonFind - // - this.buttonFind.Location = new System.Drawing.Point(207, 11); - this.buttonFind.Name = "buttonFind"; - this.buttonFind.Size = new System.Drawing.Size(89, 23); - this.buttonFind.TabIndex = 1; - this.buttonFind.Text = "Find"; - this.buttonFind.UseVisualStyleBackColor = true; - this.buttonFind.Click += new System.EventHandler(this.ButtonFind_Click); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(207, 69); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(89, 23); - this.buttonCancel.TabIndex = 3; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // radioButtonNormal - // - this.radioButtonNormal.AutoSize = true; - this.radioButtonNormal.Checked = true; - this.radioButtonNormal.Location = new System.Drawing.Point(12, 63); - this.radioButtonNormal.Name = "radioButtonNormal"; - this.radioButtonNormal.Size = new System.Drawing.Size(58, 17); - this.radioButtonNormal.TabIndex = 5; - this.radioButtonNormal.TabStop = true; - this.radioButtonNormal.Text = "Normal"; - this.radioButtonNormal.UseVisualStyleBackColor = true; - this.radioButtonNormal.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); - // - // radioButtonCaseSensitive - // - this.radioButtonCaseSensitive.AutoSize = true; - this.radioButtonCaseSensitive.Location = new System.Drawing.Point(12, 86); - this.radioButtonCaseSensitive.Name = "radioButtonCaseSensitive"; - this.radioButtonCaseSensitive.Size = new System.Drawing.Size(94, 17); - this.radioButtonCaseSensitive.TabIndex = 7; - this.radioButtonCaseSensitive.Text = "Case sensitive"; - this.radioButtonCaseSensitive.UseVisualStyleBackColor = true; - this.radioButtonCaseSensitive.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); - // - // radioButtonRegEx - // - this.radioButtonRegEx.AutoSize = true; - this.radioButtonRegEx.Location = new System.Drawing.Point(12, 109); - this.radioButtonRegEx.Name = "radioButtonRegEx"; - this.radioButtonRegEx.Size = new System.Drawing.Size(56, 17); - this.radioButtonRegEx.TabIndex = 9; - this.radioButtonRegEx.Text = "RegEx"; - this.radioButtonRegEx.UseVisualStyleBackColor = true; - this.radioButtonRegEx.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); - // - // comboBoxFind - // - this.comboBoxFind.FormattingEnabled = true; - this.comboBoxFind.Location = new System.Drawing.Point(12, 13); - this.comboBoxFind.Name = "comboBoxFind"; - this.comboBoxFind.Size = new System.Drawing.Size(189, 21); - this.comboBoxFind.TabIndex = 0; - this.comboBoxFind.TextChanged += new System.EventHandler(this.comboBoxFind_TextChanged); - this.comboBoxFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ComboBoxFind_KeyDown); - // - // buttonCount - // - this.buttonCount.Location = new System.Drawing.Point(207, 40); - this.buttonCount.Name = "buttonCount"; - this.buttonCount.Size = new System.Drawing.Size(89, 23); - this.buttonCount.TabIndex = 2; - this.buttonCount.Text = "Count"; - this.buttonCount.UseVisualStyleBackColor = true; - this.buttonCount.Click += new System.EventHandler(this.buttonCount_Click); - // - // labelCount - // - this.labelCount.AutoSize = true; - this.labelCount.Location = new System.Drawing.Point(204, 113); - this.labelCount.Name = "labelCount"; - this.labelCount.Size = new System.Drawing.Size(40, 13); - this.labelCount.TabIndex = 11; - this.labelCount.Text = "Count:"; - // - // checkBoxWholeWord - // - this.checkBoxWholeWord.AutoSize = true; - this.checkBoxWholeWord.Location = new System.Drawing.Point(12, 40); - this.checkBoxWholeWord.Name = "checkBoxWholeWord"; - this.checkBoxWholeWord.Size = new System.Drawing.Size(83, 17); - this.checkBoxWholeWord.TabIndex = 4; - this.checkBoxWholeWord.Text = "Whole word"; - this.checkBoxWholeWord.UseVisualStyleBackColor = true; - this.checkBoxWholeWord.CheckedChanged += new System.EventHandler(this.checkBoxWholeWord_CheckedChanged); - // - // FindDialog - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(307, 135); - this.Controls.Add(this.checkBoxWholeWord); - this.Controls.Add(this.labelCount); - this.Controls.Add(this.buttonCount); - this.Controls.Add(this.comboBoxFind); - this.Controls.Add(this.radioButtonRegEx); - this.Controls.Add(this.radioButtonCaseSensitive); - this.Controls.Add(this.radioButtonNormal); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonFind); - this.Controls.Add(this.textBoxFind); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "FindDialog"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Find"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormFindDialog_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox textBoxFind; - private System.Windows.Forms.Button buttonFind; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.RadioButton radioButtonNormal; - private System.Windows.Forms.RadioButton radioButtonCaseSensitive; - private System.Windows.Forms.RadioButton radioButtonRegEx; - private System.Windows.Forms.ComboBox comboBoxFind; - private System.Windows.Forms.Button buttonCount; - private System.Windows.Forms.Label labelCount; - private System.Windows.Forms.CheckBox checkBoxWholeWord; - } -} +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class FindDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBoxFind = new System.Windows.Forms.TextBox(); + this.buttonFind = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.radioButtonNormal = new System.Windows.Forms.RadioButton(); + this.radioButtonCaseSensitive = new System.Windows.Forms.RadioButton(); + this.radioButtonRegEx = new System.Windows.Forms.RadioButton(); + this.comboBoxFind = new System.Windows.Forms.ComboBox(); + this.buttonCount = new System.Windows.Forms.Button(); + this.labelCount = new System.Windows.Forms.Label(); + this.checkBoxWholeWord = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // textBoxFind + // + this.textBoxFind.Location = new System.Drawing.Point(12, 12); + this.textBoxFind.Name = "textBoxFind"; + this.textBoxFind.Size = new System.Drawing.Size(189, 21); + this.textBoxFind.TabIndex = 0; + this.textBoxFind.TextChanged += new System.EventHandler(this.textBoxFind_TextChanged); + this.textBoxFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxFind_KeyDown); + // + // buttonFind + // + this.buttonFind.Location = new System.Drawing.Point(207, 11); + this.buttonFind.Name = "buttonFind"; + this.buttonFind.Size = new System.Drawing.Size(89, 23); + this.buttonFind.TabIndex = 1; + this.buttonFind.Text = "Find"; + this.buttonFind.UseVisualStyleBackColor = true; + this.buttonFind.Click += new System.EventHandler(this.ButtonFind_Click); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(207, 69); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(89, 23); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // radioButtonNormal + // + this.radioButtonNormal.AutoSize = true; + this.radioButtonNormal.Checked = true; + this.radioButtonNormal.Location = new System.Drawing.Point(12, 63); + this.radioButtonNormal.Name = "radioButtonNormal"; + this.radioButtonNormal.Size = new System.Drawing.Size(58, 17); + this.radioButtonNormal.TabIndex = 5; + this.radioButtonNormal.TabStop = true; + this.radioButtonNormal.Text = "Normal"; + this.radioButtonNormal.UseVisualStyleBackColor = true; + this.radioButtonNormal.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); + // + // radioButtonCaseSensitive + // + this.radioButtonCaseSensitive.AutoSize = true; + this.radioButtonCaseSensitive.Location = new System.Drawing.Point(12, 86); + this.radioButtonCaseSensitive.Name = "radioButtonCaseSensitive"; + this.radioButtonCaseSensitive.Size = new System.Drawing.Size(94, 17); + this.radioButtonCaseSensitive.TabIndex = 7; + this.radioButtonCaseSensitive.Text = "Case sensitive"; + this.radioButtonCaseSensitive.UseVisualStyleBackColor = true; + this.radioButtonCaseSensitive.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); + // + // radioButtonRegEx + // + this.radioButtonRegEx.AutoSize = true; + this.radioButtonRegEx.Location = new System.Drawing.Point(12, 109); + this.radioButtonRegEx.Name = "radioButtonRegEx"; + this.radioButtonRegEx.Size = new System.Drawing.Size(56, 17); + this.radioButtonRegEx.TabIndex = 9; + this.radioButtonRegEx.Text = "RegEx"; + this.radioButtonRegEx.UseVisualStyleBackColor = true; + this.radioButtonRegEx.CheckedChanged += new System.EventHandler(this.RadioButton_CheckedChanged); + // + // comboBoxFind + // + this.comboBoxFind.FormattingEnabled = true; + this.comboBoxFind.Location = new System.Drawing.Point(12, 13); + this.comboBoxFind.Name = "comboBoxFind"; + this.comboBoxFind.Size = new System.Drawing.Size(189, 21); + this.comboBoxFind.TabIndex = 0; + this.comboBoxFind.TextChanged += new System.EventHandler(this.comboBoxFind_TextChanged); + this.comboBoxFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ComboBoxFind_KeyDown); + // + // buttonCount + // + this.buttonCount.Location = new System.Drawing.Point(207, 40); + this.buttonCount.Name = "buttonCount"; + this.buttonCount.Size = new System.Drawing.Size(89, 23); + this.buttonCount.TabIndex = 2; + this.buttonCount.Text = "Count"; + this.buttonCount.UseVisualStyleBackColor = true; + this.buttonCount.Click += new System.EventHandler(this.buttonCount_Click); + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(204, 113); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(40, 13); + this.labelCount.TabIndex = 11; + this.labelCount.Text = "Count:"; + // + // checkBoxWholeWord + // + this.checkBoxWholeWord.AutoSize = true; + this.checkBoxWholeWord.Location = new System.Drawing.Point(12, 40); + this.checkBoxWholeWord.Name = "checkBoxWholeWord"; + this.checkBoxWholeWord.Size = new System.Drawing.Size(83, 17); + this.checkBoxWholeWord.TabIndex = 4; + this.checkBoxWholeWord.Text = "Whole word"; + this.checkBoxWholeWord.UseVisualStyleBackColor = true; + this.checkBoxWholeWord.CheckedChanged += new System.EventHandler(this.checkBoxWholeWord_CheckedChanged); + // + // FindDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(307, 135); + this.Controls.Add(this.checkBoxWholeWord); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.buttonCount); + this.Controls.Add(this.comboBoxFind); + this.Controls.Add(this.radioButtonRegEx); + this.Controls.Add(this.radioButtonCaseSensitive); + this.Controls.Add(this.radioButtonNormal); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonFind); + this.Controls.Add(this.textBoxFind); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FindDialog"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Find"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormFindDialog_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBoxFind; + private System.Windows.Forms.Button buttonFind; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.RadioButton radioButtonNormal; + private System.Windows.Forms.RadioButton radioButtonCaseSensitive; + private System.Windows.Forms.RadioButton radioButtonRegEx; + private System.Windows.Forms.ComboBox comboBoxFind; + private System.Windows.Forms.Button buttonCount; + private System.Windows.Forms.Label labelCount; + private System.Windows.Forms.CheckBox checkBoxWholeWord; + } +} diff --git a/src/Forms/FindDialog.cs b/src/ui/Forms/FindDialog.cs similarity index 97% rename from src/Forms/FindDialog.cs rename to src/ui/Forms/FindDialog.cs index b338381fe..45932391c 100644 --- a/src/Forms/FindDialog.cs +++ b/src/ui/Forms/FindDialog.cs @@ -1,243 +1,243 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Enums; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Drawing; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class FindDialog : PositionAndSizeForm - { - private Regex _regEx; - private readonly Subtitle _subtitle; - public FindDialog(Subtitle subtitle) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.FindDialog.Title; - buttonFind.Text = Configuration.Settings.Language.FindDialog.Find; - radioButtonNormal.Text = Configuration.Settings.Language.FindDialog.Normal; - radioButtonCaseSensitive.Text = Configuration.Settings.Language.FindDialog.CaseSensitive; - radioButtonRegEx.Text = Configuration.Settings.Language.FindDialog.RegularExpression; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - checkBoxWholeWord.Text = Configuration.Settings.Language.FindDialog.WholeWord; - buttonCount.Text = Configuration.Settings.Language.FindDialog.Count; - labelCount.Text = string.Empty; - _subtitle = subtitle; - - if (Width < radioButtonRegEx.Right + 5) - { - Width = radioButtonRegEx.Right + 5; - } - - UiUtil.FixLargeFonts(this, buttonCancel); - } - - private ReplaceType FindReplaceType - { - get - { - var result = new ReplaceType(); - if (radioButtonNormal.Checked) - { - result.FindType = FindType.Normal; - } - else if (radioButtonCaseSensitive.Checked) - { - result.FindType = FindType.CaseSensitive; - } - else - { - result.FindType = FindType.RegEx; - } - - result.WholeWord = checkBoxWholeWord.Checked; - return result; - } - set - { - switch (value.FindType) - { - case FindType.Normal: - radioButtonNormal.Checked = true; - break; - case FindType.CaseSensitive: - radioButtonCaseSensitive.Checked = true; - break; - case FindType.RegEx: - radioButtonRegEx.Checked = true; - break; - } - } - } - - private string FindText - { - get - { - if (Configuration.Settings.Tools.FindHistory.Count == 0) - { - return textBoxFind.Text; - } - - return comboBoxFind.Text; - } - } - - public FindReplaceDialogHelper GetFindDialogHelper(int startLineIndex) - { - return new FindReplaceDialogHelper(FindReplaceType, FindText, _regEx, string.Empty, startLineIndex); - } - - private void FormFindDialog_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void ButtonFind_Click(object sender, EventArgs e) - { - string searchText = FindText; - textBoxFind.Text = searchText; - - if (searchText.Length == 0) - { - DialogResult = DialogResult.Cancel; - } - else if (radioButtonNormal.Checked) - { - DialogResult = DialogResult.OK; - } - else if (radioButtonCaseSensitive.Checked) - { - DialogResult = DialogResult.OK; - } - else if (radioButtonRegEx.Checked) - { - try - { - _regEx = new Regex(RegexUtils.FixNewLine(searchText), RegexOptions.Compiled); - DialogResult = DialogResult.OK; - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - } - } - } - - private void TextBoxFind_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - ButtonFind_Click(null, null); - } - } - - private void ComboBoxFind_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - ButtonFind_Click(null, null); - } - } - - private void RadioButton_CheckedChanged(object sender, EventArgs e) - { - if (sender == radioButtonRegEx) - { - if (textBoxFind.Visible) - { - comboBoxFind.ContextMenu = null; - textBoxFind.ContextMenu = FindReplaceDialogHelper.GetRegExContextMenu(textBoxFind); - } - else - { - textBoxFind.ContextMenu = null; - comboBoxFind.ContextMenu = FindReplaceDialogHelper.GetRegExContextMenu(comboBoxFind); - } - } - else - { - textBoxFind.ContextMenu = null; - comboBoxFind.ContextMenu = null; - } - checkBoxWholeWord.Enabled = !radioButtonRegEx.Checked; - labelCount.Text = string.Empty; - } - - internal void Initialize(string selectedText, FindReplaceDialogHelper findHelper) - { - if (Configuration.Settings.Tools.FindHistory.Count > 0) - { - textBoxFind.Visible = false; - comboBoxFind.Visible = true; - comboBoxFind.Text = selectedText; - comboBoxFind.SelectAll(); - comboBoxFind.Items.Clear(); - for (int index = 0; index < Configuration.Settings.Tools.FindHistory.Count; index++) - { - string s = Configuration.Settings.Tools.FindHistory[index]; - comboBoxFind.Items.Add(s); - } - } - else - { - comboBoxFind.Visible = false; - textBoxFind.Visible = true; - textBoxFind.Text = selectedText; - textBoxFind.SelectAll(); - } - - if (findHelper != null) - { - FindReplaceType = findHelper.FindReplaceType; - checkBoxWholeWord.Checked = findHelper.FindReplaceType.WholeWord; - checkBoxWholeWord.Enabled = FindReplaceType.FindType != FindType.RegEx; - } - } - - internal void SetIcon(Bitmap bitmap) - { - if (bitmap != null) - { - Icon = Icon.FromHandle(bitmap.GetHicon()); - } - } - - private void buttonCount_Click(object sender, EventArgs e) - { - if (FindText.Length == 0) - { - labelCount.Text = string.Empty; - return; - } - var count = GetFindDialogHelper(0).FindCount(_subtitle, checkBoxWholeWord.Checked); - labelCount.ForeColor = count > 0 ? Color.Blue : Color.Red; - labelCount.Text = count == 1 ? Configuration.Settings.Language.FindDialog.OneMatch : string.Format(Configuration.Settings.Language.FindDialog.XNumberOfMatches, count); - } - - private void comboBoxFind_TextChanged(object sender, EventArgs e) - { - labelCount.Text = string.Empty; - } - - private void textBoxFind_TextChanged(object sender, EventArgs e) - { - labelCount.Text = string.Empty; - } - - private void checkBoxWholeWord_CheckedChanged(object sender, EventArgs e) - { - labelCount.Text = string.Empty; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Enums; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Drawing; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class FindDialog : PositionAndSizeForm + { + private Regex _regEx; + private readonly Subtitle _subtitle; + public FindDialog(Subtitle subtitle) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.FindDialog.Title; + buttonFind.Text = Configuration.Settings.Language.FindDialog.Find; + radioButtonNormal.Text = Configuration.Settings.Language.FindDialog.Normal; + radioButtonCaseSensitive.Text = Configuration.Settings.Language.FindDialog.CaseSensitive; + radioButtonRegEx.Text = Configuration.Settings.Language.FindDialog.RegularExpression; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + checkBoxWholeWord.Text = Configuration.Settings.Language.FindDialog.WholeWord; + buttonCount.Text = Configuration.Settings.Language.FindDialog.Count; + labelCount.Text = string.Empty; + _subtitle = subtitle; + + if (Width < radioButtonRegEx.Right + 5) + { + Width = radioButtonRegEx.Right + 5; + } + + UiUtil.FixLargeFonts(this, buttonCancel); + } + + private ReplaceType FindReplaceType + { + get + { + var result = new ReplaceType(); + if (radioButtonNormal.Checked) + { + result.FindType = FindType.Normal; + } + else if (radioButtonCaseSensitive.Checked) + { + result.FindType = FindType.CaseSensitive; + } + else + { + result.FindType = FindType.RegEx; + } + + result.WholeWord = checkBoxWholeWord.Checked; + return result; + } + set + { + switch (value.FindType) + { + case FindType.Normal: + radioButtonNormal.Checked = true; + break; + case FindType.CaseSensitive: + radioButtonCaseSensitive.Checked = true; + break; + case FindType.RegEx: + radioButtonRegEx.Checked = true; + break; + } + } + } + + private string FindText + { + get + { + if (Configuration.Settings.Tools.FindHistory.Count == 0) + { + return textBoxFind.Text; + } + + return comboBoxFind.Text; + } + } + + public FindReplaceDialogHelper GetFindDialogHelper(int startLineIndex) + { + return new FindReplaceDialogHelper(FindReplaceType, FindText, _regEx, string.Empty, startLineIndex); + } + + private void FormFindDialog_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void ButtonFind_Click(object sender, EventArgs e) + { + string searchText = FindText; + textBoxFind.Text = searchText; + + if (searchText.Length == 0) + { + DialogResult = DialogResult.Cancel; + } + else if (radioButtonNormal.Checked) + { + DialogResult = DialogResult.OK; + } + else if (radioButtonCaseSensitive.Checked) + { + DialogResult = DialogResult.OK; + } + else if (radioButtonRegEx.Checked) + { + try + { + _regEx = new Regex(RegexUtils.FixNewLine(searchText), RegexOptions.Compiled); + DialogResult = DialogResult.OK; + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + } + } + } + + private void TextBoxFind_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + ButtonFind_Click(null, null); + } + } + + private void ComboBoxFind_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + ButtonFind_Click(null, null); + } + } + + private void RadioButton_CheckedChanged(object sender, EventArgs e) + { + if (sender == radioButtonRegEx) + { + if (textBoxFind.Visible) + { + comboBoxFind.ContextMenu = null; + textBoxFind.ContextMenu = FindReplaceDialogHelper.GetRegExContextMenu(textBoxFind); + } + else + { + textBoxFind.ContextMenu = null; + comboBoxFind.ContextMenu = FindReplaceDialogHelper.GetRegExContextMenu(comboBoxFind); + } + } + else + { + textBoxFind.ContextMenu = null; + comboBoxFind.ContextMenu = null; + } + checkBoxWholeWord.Enabled = !radioButtonRegEx.Checked; + labelCount.Text = string.Empty; + } + + internal void Initialize(string selectedText, FindReplaceDialogHelper findHelper) + { + if (Configuration.Settings.Tools.FindHistory.Count > 0) + { + textBoxFind.Visible = false; + comboBoxFind.Visible = true; + comboBoxFind.Text = selectedText; + comboBoxFind.SelectAll(); + comboBoxFind.Items.Clear(); + for (int index = 0; index < Configuration.Settings.Tools.FindHistory.Count; index++) + { + string s = Configuration.Settings.Tools.FindHistory[index]; + comboBoxFind.Items.Add(s); + } + } + else + { + comboBoxFind.Visible = false; + textBoxFind.Visible = true; + textBoxFind.Text = selectedText; + textBoxFind.SelectAll(); + } + + if (findHelper != null) + { + FindReplaceType = findHelper.FindReplaceType; + checkBoxWholeWord.Checked = findHelper.FindReplaceType.WholeWord; + checkBoxWholeWord.Enabled = FindReplaceType.FindType != FindType.RegEx; + } + } + + internal void SetIcon(Bitmap bitmap) + { + if (bitmap != null) + { + Icon = Icon.FromHandle(bitmap.GetHicon()); + } + } + + private void buttonCount_Click(object sender, EventArgs e) + { + if (FindText.Length == 0) + { + labelCount.Text = string.Empty; + return; + } + var count = GetFindDialogHelper(0).FindCount(_subtitle, checkBoxWholeWord.Checked); + labelCount.ForeColor = count > 0 ? Color.Blue : Color.Red; + labelCount.Text = count == 1 ? Configuration.Settings.Language.FindDialog.OneMatch : string.Format(Configuration.Settings.Language.FindDialog.XNumberOfMatches, count); + } + + private void comboBoxFind_TextChanged(object sender, EventArgs e) + { + labelCount.Text = string.Empty; + } + + private void textBoxFind_TextChanged(object sender, EventArgs e) + { + labelCount.Text = string.Empty; + } + + private void checkBoxWholeWord_CheckedChanged(object sender, EventArgs e) + { + labelCount.Text = string.Empty; + } + + } +} diff --git a/src/Forms/FindDialog.resx b/src/ui/Forms/FindDialog.resx similarity index 97% rename from src/Forms/FindDialog.resx rename to src/ui/Forms/FindDialog.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/FindDialog.resx +++ b/src/ui/Forms/FindDialog.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/FindSubtitleLine.Designer.cs b/src/ui/Forms/FindSubtitleLine.Designer.cs similarity index 98% rename from src/Forms/FindSubtitleLine.Designer.cs rename to src/ui/Forms/FindSubtitleLine.Designer.cs index 44f3f2829..ce0763a07 100644 --- a/src/Forms/FindSubtitleLine.Designer.cs +++ b/src/ui/Forms/FindSubtitleLine.Designer.cs @@ -1,158 +1,158 @@ -using Nikse.SubtitleEdit.Controls; - -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class FindSubtitleLine - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonFind = new System.Windows.Forms.Button(); - this.textBoxFindText = new System.Windows.Forms.TextBox(); - this.buttonFindNext = new System.Windows.Forms.Button(); - this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.Location = new System.Drawing.Point(453, 315); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 4; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(534, 315); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); - // - // buttonFind - // - this.buttonFind.Location = new System.Drawing.Point(196, 32); - this.buttonFind.Name = "buttonFind"; - this.buttonFind.Size = new System.Drawing.Size(75, 23); - this.buttonFind.TabIndex = 1; - this.buttonFind.Text = "Find"; - this.buttonFind.UseVisualStyleBackColor = true; - this.buttonFind.Click += new System.EventHandler(this.ButtonFindClick); - // - // textBoxFindText - // - this.textBoxFindText.Location = new System.Drawing.Point(12, 32); - this.textBoxFindText.Name = "textBoxFindText"; - this.textBoxFindText.Size = new System.Drawing.Size(178, 21); - this.textBoxFindText.TabIndex = 0; - this.textBoxFindText.TextChanged += new System.EventHandler(this.TextBoxFindTextTextChanged); - this.textBoxFindText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxFindTextKeyDown); - // - // buttonFindNext - // - this.buttonFindNext.Location = new System.Drawing.Point(277, 32); - this.buttonFindNext.Name = "buttonFindNext"; - this.buttonFindNext.Size = new System.Drawing.Size(75, 23); - this.buttonFindNext.TabIndex = 2; - this.buttonFindNext.Text = "Find next"; - this.buttonFindNext.UseVisualStyleBackColor = true; - this.buttonFindNext.Click += new System.EventHandler(this.ButtonFindNextClick); - // - // subtitleListView1 - // - this.subtitleListView1.AllowColumnReorder = true; - this.subtitleListView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.subtitleListView1.FirstVisibleIndex = -1; - this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.subtitleListView1.FullRowSelect = true; - this.subtitleListView1.GridLines = true; - this.subtitleListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.subtitleListView1.HideSelection = false; - this.subtitleListView1.Location = new System.Drawing.Point(12, 59); - this.subtitleListView1.MultiSelect = false; - this.subtitleListView1.Name = "subtitleListView1"; - this.subtitleListView1.OwnerDraw = true; - this.subtitleListView1.Size = new System.Drawing.Size(597, 250); - this.subtitleListView1.SubtitleFontBold = false; - this.subtitleListView1.SubtitleFontName = "Tahoma"; - this.subtitleListView1.SubtitleFontSize = 8; - this.subtitleListView1.TabIndex = 3; - this.subtitleListView1.UseCompatibleStateImageBehavior = false; - this.subtitleListView1.UseSyntaxColoring = true; - this.subtitleListView1.View = System.Windows.Forms.View.Details; - this.subtitleListView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListView1MouseDoubleClick); - // - // FindSubtitleLine - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(621, 345); - this.Controls.Add(this.buttonFindNext); - this.Controls.Add(this.textBoxFindText); - this.Controls.Add(this.buttonFind); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.subtitleListView1); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(630, 370); - this.Name = "FindSubtitleLine"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Find subtitle line"; - this.Load += new System.EventHandler(this.FormFindSubtitleLine_Load); - this.Shown += new System.EventHandler(this.FormFindSubtitleLine_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormFindSubtitleLine_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private SubtitleListView subtitleListView1; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonFind; - private System.Windows.Forms.TextBox textBoxFindText; - private System.Windows.Forms.Button buttonFindNext; - } +using Nikse.SubtitleEdit.Controls; + +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class FindSubtitleLine + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonFind = new System.Windows.Forms.Button(); + this.textBoxFindText = new System.Windows.Forms.TextBox(); + this.buttonFindNext = new System.Windows.Forms.Button(); + this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.Location = new System.Drawing.Point(453, 315); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 4; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(534, 315); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); + // + // buttonFind + // + this.buttonFind.Location = new System.Drawing.Point(196, 32); + this.buttonFind.Name = "buttonFind"; + this.buttonFind.Size = new System.Drawing.Size(75, 23); + this.buttonFind.TabIndex = 1; + this.buttonFind.Text = "Find"; + this.buttonFind.UseVisualStyleBackColor = true; + this.buttonFind.Click += new System.EventHandler(this.ButtonFindClick); + // + // textBoxFindText + // + this.textBoxFindText.Location = new System.Drawing.Point(12, 32); + this.textBoxFindText.Name = "textBoxFindText"; + this.textBoxFindText.Size = new System.Drawing.Size(178, 21); + this.textBoxFindText.TabIndex = 0; + this.textBoxFindText.TextChanged += new System.EventHandler(this.TextBoxFindTextTextChanged); + this.textBoxFindText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxFindTextKeyDown); + // + // buttonFindNext + // + this.buttonFindNext.Location = new System.Drawing.Point(277, 32); + this.buttonFindNext.Name = "buttonFindNext"; + this.buttonFindNext.Size = new System.Drawing.Size(75, 23); + this.buttonFindNext.TabIndex = 2; + this.buttonFindNext.Text = "Find next"; + this.buttonFindNext.UseVisualStyleBackColor = true; + this.buttonFindNext.Click += new System.EventHandler(this.ButtonFindNextClick); + // + // subtitleListView1 + // + this.subtitleListView1.AllowColumnReorder = true; + this.subtitleListView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.subtitleListView1.FirstVisibleIndex = -1; + this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.subtitleListView1.FullRowSelect = true; + this.subtitleListView1.GridLines = true; + this.subtitleListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.subtitleListView1.HideSelection = false; + this.subtitleListView1.Location = new System.Drawing.Point(12, 59); + this.subtitleListView1.MultiSelect = false; + this.subtitleListView1.Name = "subtitleListView1"; + this.subtitleListView1.OwnerDraw = true; + this.subtitleListView1.Size = new System.Drawing.Size(597, 250); + this.subtitleListView1.SubtitleFontBold = false; + this.subtitleListView1.SubtitleFontName = "Tahoma"; + this.subtitleListView1.SubtitleFontSize = 8; + this.subtitleListView1.TabIndex = 3; + this.subtitleListView1.UseCompatibleStateImageBehavior = false; + this.subtitleListView1.UseSyntaxColoring = true; + this.subtitleListView1.View = System.Windows.Forms.View.Details; + this.subtitleListView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListView1MouseDoubleClick); + // + // FindSubtitleLine + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(621, 345); + this.Controls.Add(this.buttonFindNext); + this.Controls.Add(this.textBoxFindText); + this.Controls.Add(this.buttonFind); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.subtitleListView1); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(630, 370); + this.Name = "FindSubtitleLine"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Find subtitle line"; + this.Load += new System.EventHandler(this.FormFindSubtitleLine_Load); + this.Shown += new System.EventHandler(this.FormFindSubtitleLine_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormFindSubtitleLine_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private SubtitleListView subtitleListView1; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonFind; + private System.Windows.Forms.TextBox textBoxFindText; + private System.Windows.Forms.Button buttonFindNext; + } } \ No newline at end of file diff --git a/src/Forms/FindSubtitleLine.cs b/src/ui/Forms/FindSubtitleLine.cs similarity index 97% rename from src/Forms/FindSubtitleLine.cs rename to src/ui/Forms/FindSubtitleLine.cs index 23ac9de52..5f797b37c 100644 --- a/src/Forms/FindSubtitleLine.cs +++ b/src/ui/Forms/FindSubtitleLine.cs @@ -1,207 +1,207 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class FindSubtitleLine : Form - { - private int _startFindIndex = -1; - private List _paragraphs = new List(); - private readonly Keys _mainGeneralGoToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle); - private readonly Keys _mainGeneralGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle); - - public int SelectedIndex - { - get; - private set; - } - - public FindSubtitleLine() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Icon = Properties.Resources.SubtitleEditFormIcon; - - Text = Configuration.Settings.Language.FindSubtitleLine.Title; - buttonFind.Text = Configuration.Settings.Language.FindSubtitleLine.Find; - buttonFindNext.Text = Configuration.Settings.Language.FindSubtitleLine.FindNext; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - subtitleListView1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - UiUtil.InitializeSubtitleFont(subtitleListView1); - subtitleListView1.AutoSizeAllColumns(this); - FixLargeFonts(); - } - - private void FixLargeFonts() - { - using (var graphics = CreateGraphics()) - { - var textSize = graphics.MeasureString(buttonOK.Text, Font); - if (textSize.Height > buttonOK.Height - 4) - { - subtitleListView1.InitializeTimestampColumnWidths(this); - int newButtonHeight = (int)(textSize.Height + 7 + 0.5); - UiUtil.SetButtonHeight(this, newButtonHeight, 1); - } - } - } - - public void Initialize(List paragraphs, string appendTitle) - { - Text += appendTitle; - _paragraphs = paragraphs; - subtitleListView1.Fill(paragraphs); - _startFindIndex = -1; - } - - private void ButtonFindClick(object sender, EventArgs e) - { - _startFindIndex = -1; - FindText(); - } - - private void FindText() - { - if (string.IsNullOrWhiteSpace(textBoxFindText.Text)) - { - return; - } - - for (var index = 0; index < _paragraphs.Count; index++) - { - if (index > _startFindIndex - && _paragraphs[index].Text.Contains(textBoxFindText.Text, StringComparison.OrdinalIgnoreCase)) - { - subtitleListView1.Items[index].Selected = true; - subtitleListView1.HideSelection = false; - subtitleListView1.Items[index].EnsureVisible(); - subtitleListView1.Items[index].Focused = true; - _startFindIndex = index; - return; - } - } - } - - private void ButtonCancelClick(object sender, EventArgs e) - { - SelectedIndex = -1; - } - - private void ButtonOkClick(object sender, EventArgs e) - { - if (subtitleListView1.SelectedItems.Count > 0) - { - SelectedIndex = subtitleListView1.SelectedItems[0].Index; - } - else - { - SelectedIndex = -1; - } - } - - private void TextBoxFindTextKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - ButtonFindClick(sender, null); - } - } - - private void TextBoxFindTextTextChanged(object sender, EventArgs e) - { - _startFindIndex = -1; - } - - private void ButtonFindNextClick(object sender, EventArgs e) - { - FindText(); - } - - private void FormFindSubtitleLine_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.F3) - { - FindText(); - } - else if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (_mainGeneralGoToNextSubtitle == e.KeyData || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)) - { - int selectedIndex = 0; - if (subtitleListView1.SelectedItems.Count > 0) - { - selectedIndex = subtitleListView1.SelectedItems[0].Index; - selectedIndex++; - } - subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex); - } - else if (_mainGeneralGoToPrevSubtitle == e.KeyData || (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt)) - { - int selectedIndex = 0; - if (subtitleListView1.SelectedItems.Count > 0) - { - selectedIndex = subtitleListView1.SelectedItems[0].Index; - selectedIndex--; - } - subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex); - } - else if (e.KeyCode == Keys.Home && e.Alt) - { - subtitleListView1.SelectIndexAndEnsureVisible(0); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.End && e.Alt) - { - subtitleListView1.SelectIndexAndEnsureVisible(subtitleListView1.Items.Count - 1); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.G && subtitleListView1.Items.Count > 1) - { - using (var goToLine = new GoToLine()) - { - goToLine.Initialize(1, subtitleListView1.Items.Count); - if (goToLine.ShowDialog(this) == DialogResult.OK) - { - subtitleListView1.SelectNone(); - subtitleListView1.Items[goToLine.LineNumber - 1].Selected = true; - subtitleListView1.Items[goToLine.LineNumber - 1].EnsureVisible(); - subtitleListView1.Items[goToLine.LineNumber - 1].Focused = true; - } - } - } - } - - private void FormFindSubtitleLine_Load(object sender, EventArgs e) - { - SetFocus(); - } - - private void FormFindSubtitleLine_Shown(object sender, EventArgs e) - { - SetFocus(); - } - - private void SetFocus() - { - if (textBoxFindText.CanFocus) - { - textBoxFindText.Focus(); - } - } - - private void SubtitleListView1MouseDoubleClick(object sender, MouseEventArgs e) - { - ButtonOkClick(null, null); - Close(); - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class FindSubtitleLine : Form + { + private int _startFindIndex = -1; + private List _paragraphs = new List(); + private readonly Keys _mainGeneralGoToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle); + private readonly Keys _mainGeneralGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle); + + public int SelectedIndex + { + get; + private set; + } + + public FindSubtitleLine() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Icon = Properties.Resources.SubtitleEditFormIcon; + + Text = Configuration.Settings.Language.FindSubtitleLine.Title; + buttonFind.Text = Configuration.Settings.Language.FindSubtitleLine.Find; + buttonFindNext.Text = Configuration.Settings.Language.FindSubtitleLine.FindNext; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + subtitleListView1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + UiUtil.InitializeSubtitleFont(subtitleListView1); + subtitleListView1.AutoSizeAllColumns(this); + FixLargeFonts(); + } + + private void FixLargeFonts() + { + using (var graphics = CreateGraphics()) + { + var textSize = graphics.MeasureString(buttonOK.Text, Font); + if (textSize.Height > buttonOK.Height - 4) + { + subtitleListView1.InitializeTimestampColumnWidths(this); + int newButtonHeight = (int)(textSize.Height + 7 + 0.5); + UiUtil.SetButtonHeight(this, newButtonHeight, 1); + } + } + } + + public void Initialize(List paragraphs, string appendTitle) + { + Text += appendTitle; + _paragraphs = paragraphs; + subtitleListView1.Fill(paragraphs); + _startFindIndex = -1; + } + + private void ButtonFindClick(object sender, EventArgs e) + { + _startFindIndex = -1; + FindText(); + } + + private void FindText() + { + if (string.IsNullOrWhiteSpace(textBoxFindText.Text)) + { + return; + } + + for (var index = 0; index < _paragraphs.Count; index++) + { + if (index > _startFindIndex + && _paragraphs[index].Text.Contains(textBoxFindText.Text, StringComparison.OrdinalIgnoreCase)) + { + subtitleListView1.Items[index].Selected = true; + subtitleListView1.HideSelection = false; + subtitleListView1.Items[index].EnsureVisible(); + subtitleListView1.Items[index].Focused = true; + _startFindIndex = index; + return; + } + } + } + + private void ButtonCancelClick(object sender, EventArgs e) + { + SelectedIndex = -1; + } + + private void ButtonOkClick(object sender, EventArgs e) + { + if (subtitleListView1.SelectedItems.Count > 0) + { + SelectedIndex = subtitleListView1.SelectedItems[0].Index; + } + else + { + SelectedIndex = -1; + } + } + + private void TextBoxFindTextKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + ButtonFindClick(sender, null); + } + } + + private void TextBoxFindTextTextChanged(object sender, EventArgs e) + { + _startFindIndex = -1; + } + + private void ButtonFindNextClick(object sender, EventArgs e) + { + FindText(); + } + + private void FormFindSubtitleLine_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.F3) + { + FindText(); + } + else if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (_mainGeneralGoToNextSubtitle == e.KeyData || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)) + { + int selectedIndex = 0; + if (subtitleListView1.SelectedItems.Count > 0) + { + selectedIndex = subtitleListView1.SelectedItems[0].Index; + selectedIndex++; + } + subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex); + } + else if (_mainGeneralGoToPrevSubtitle == e.KeyData || (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt)) + { + int selectedIndex = 0; + if (subtitleListView1.SelectedItems.Count > 0) + { + selectedIndex = subtitleListView1.SelectedItems[0].Index; + selectedIndex--; + } + subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex); + } + else if (e.KeyCode == Keys.Home && e.Alt) + { + subtitleListView1.SelectIndexAndEnsureVisible(0); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.End && e.Alt) + { + subtitleListView1.SelectIndexAndEnsureVisible(subtitleListView1.Items.Count - 1); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.G && subtitleListView1.Items.Count > 1) + { + using (var goToLine = new GoToLine()) + { + goToLine.Initialize(1, subtitleListView1.Items.Count); + if (goToLine.ShowDialog(this) == DialogResult.OK) + { + subtitleListView1.SelectNone(); + subtitleListView1.Items[goToLine.LineNumber - 1].Selected = true; + subtitleListView1.Items[goToLine.LineNumber - 1].EnsureVisible(); + subtitleListView1.Items[goToLine.LineNumber - 1].Focused = true; + } + } + } + } + + private void FormFindSubtitleLine_Load(object sender, EventArgs e) + { + SetFocus(); + } + + private void FormFindSubtitleLine_Shown(object sender, EventArgs e) + { + SetFocus(); + } + + private void SetFocus() + { + if (textBoxFindText.CanFocus) + { + textBoxFindText.Focus(); + } + } + + private void SubtitleListView1MouseDoubleClick(object sender, MouseEventArgs e) + { + ButtonOkClick(null, null); + Close(); + } + + } +} diff --git a/src/Forms/FindSubtitleLine.resx b/src/ui/Forms/FindSubtitleLine.resx similarity index 97% rename from src/Forms/FindSubtitleLine.resx rename to src/ui/Forms/FindSubtitleLine.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/FindSubtitleLine.resx +++ b/src/ui/Forms/FindSubtitleLine.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/FixCommonErrors.Designer.cs b/src/ui/Forms/FixCommonErrors.Designer.cs similarity index 98% rename from src/Forms/FixCommonErrors.Designer.cs rename to src/ui/Forms/FixCommonErrors.Designer.cs index 37a17e563..25020270c 100644 --- a/src/Forms/FixCommonErrors.Designer.cs +++ b/src/ui/Forms/FixCommonErrors.Designer.cs @@ -1,890 +1,890 @@ -using Nikse.SubtitleEdit.Controls; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class FixCommonErrors - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - TimeCode timeCode1 = new TimeCode(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonNextFinish = new System.Windows.Forms.Button(); - this.labelStatus = new System.Windows.Forms.Label(); - this.buttonBack = new System.Windows.Forms.Button(); - this.groupBoxStep1 = new System.Windows.Forms.GroupBox(); - this.buttonResetDefault = new System.Windows.Forms.Button(); - this.comboBoxLanguage = new System.Windows.Forms.ComboBox(); - this.labelLanguage = new System.Windows.Forms.Label(); - this.buttonInverseSelection = new System.Windows.Forms.Button(); - this.buttonSelectAll = new System.Windows.Forms.Button(); - this.listView1 = new System.Windows.Forms.ListView(); - this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.contextMenuStripRules = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemSelectAllRules = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInverseRules = new System.Windows.Forms.ToolStripMenuItem(); - this.selectDefaultToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.setCurrentFixesAsDefaultToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.labelLanguage2 = new System.Windows.Forms.Label(); - this.tabControl1 = new System.Windows.Forms.TabControl(); - this.tabPageFixes = new System.Windows.Forms.TabPage(); - this.splitContainerStep2 = new System.Windows.Forms.SplitContainer(); - this.listViewFixes = new System.Windows.Forms.ListView(); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.contextMenuStripFixes = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); - this.buttonFixesApply = new System.Windows.Forms.Button(); - this.buttonRefreshFixes = new System.Windows.Forms.Button(); - this.buttonFixesSelectAll = new System.Windows.Forms.Button(); - this.buttonFixesInverse = new System.Windows.Forms.Button(); - this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.contextMenuStripListview = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemDelete = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.mergeSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBoxEditPanel = new System.Windows.Forms.GroupBox(); - this.buttonSplitLine = new System.Windows.Forms.Button(); - this.labelSingleLine = new System.Windows.Forms.Label(); - this.buttonUnBreak = new System.Windows.Forms.Button(); - this.buttonAutoBreak = new System.Windows.Forms.Button(); - this.labelStartTimeWarning = new System.Windows.Forms.Label(); - this.labelDurationWarning = new System.Windows.Forms.Label(); - this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.numericUpDownDuration = new System.Windows.Forms.NumericUpDown(); - this.labelDuration = new System.Windows.Forms.Label(); - this.labelStartTime = new System.Windows.Forms.Label(); - this.labelTextLineTotal = new System.Windows.Forms.Label(); - this.labelTextLineLengths = new System.Windows.Forms.Label(); - this.textBoxListViewText = new System.Windows.Forms.TextBox(); - this.tabPageLog = new System.Windows.Forms.TabPage(); - this.textBoxFixedIssues = new System.Windows.Forms.TextBox(); - this.labelNumberOfImportantLogMessages = new System.Windows.Forms.Label(); - this.groupBoxStep1.SuspendLayout(); - this.contextMenuStripRules.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.tabControl1.SuspendLayout(); - this.tabPageFixes.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainerStep2)).BeginInit(); - this.splitContainerStep2.Panel1.SuspendLayout(); - this.splitContainerStep2.Panel2.SuspendLayout(); - this.splitContainerStep2.SuspendLayout(); - this.contextMenuStripFixes.SuspendLayout(); - this.contextMenuStripListview.SuspendLayout(); - this.groupBoxEditPanel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).BeginInit(); - this.tabPageLog.SuspendLayout(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(759, 575); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 10; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); - // - // buttonNextFinish - // - this.buttonNextFinish.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonNextFinish.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonNextFinish.Location = new System.Drawing.Point(678, 575); - this.buttonNextFinish.Name = "buttonNextFinish"; - this.buttonNextFinish.Size = new System.Drawing.Size(75, 23); - this.buttonNextFinish.TabIndex = 9; - this.buttonNextFinish.Text = "&Next >"; - this.buttonNextFinish.UseVisualStyleBackColor = true; - this.buttonNextFinish.Click += new System.EventHandler(this.ButtonFixClick); - // - // labelStatus - // - this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelStatus.AutoSize = true; - this.labelStatus.Location = new System.Drawing.Point(12, 577); - this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(60, 13); - this.labelStatus.TabIndex = 5; - this.labelStatus.Text = "labelStatus"; - // - // buttonBack - // - this.buttonBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonBack.Enabled = false; - this.buttonBack.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonBack.Location = new System.Drawing.Point(597, 575); - this.buttonBack.Name = "buttonBack"; - this.buttonBack.Size = new System.Drawing.Size(75, 23); - this.buttonBack.TabIndex = 8; - this.buttonBack.Text = "< &Back"; - this.buttonBack.UseVisualStyleBackColor = true; - this.buttonBack.Click += new System.EventHandler(this.ButtonBackClick); - // - // groupBoxStep1 - // - this.groupBoxStep1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxStep1.Controls.Add(this.buttonResetDefault); - this.groupBoxStep1.Controls.Add(this.comboBoxLanguage); - this.groupBoxStep1.Controls.Add(this.labelLanguage); - this.groupBoxStep1.Controls.Add(this.buttonInverseSelection); - this.groupBoxStep1.Controls.Add(this.buttonSelectAll); - this.groupBoxStep1.Controls.Add(this.listView1); - this.groupBoxStep1.Location = new System.Drawing.Point(12, 12); - this.groupBoxStep1.Name = "groupBoxStep1"; - this.groupBoxStep1.Size = new System.Drawing.Size(822, 557); - this.groupBoxStep1.TabIndex = 9; - this.groupBoxStep1.TabStop = false; - this.groupBoxStep1.Text = "Step 1/2 - Choose which errors to fix"; - // - // buttonResetDefault - // - this.buttonResetDefault.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonResetDefault.Location = new System.Drawing.Point(193, 530); - this.buttonResetDefault.Name = "buttonResetDefault"; - this.buttonResetDefault.Size = new System.Drawing.Size(100, 23); - this.buttonResetDefault.TabIndex = 12; - this.buttonResetDefault.Text = "Select default"; - this.buttonResetDefault.UseVisualStyleBackColor = true; - this.buttonResetDefault.Click += new System.EventHandler(this.buttonResetDefault_Click); - // - // comboBoxLanguage - // - this.comboBoxLanguage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.comboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxLanguage.FormattingEnabled = true; - this.comboBoxLanguage.Location = new System.Drawing.Point(619, 17); - this.comboBoxLanguage.Name = "comboBoxLanguage"; - this.comboBoxLanguage.Size = new System.Drawing.Size(196, 21); - this.comboBoxLanguage.TabIndex = 0; - this.comboBoxLanguage.SelectedIndexChanged += new System.EventHandler(this.comboBoxLanguage_SelectedIndexChanged); - this.comboBoxLanguage.Enter += new System.EventHandler(this.comboBoxLanguage_Enter); - // - // labelLanguage - // - this.labelLanguage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelLanguage.Location = new System.Drawing.Point(376, 20); - this.labelLanguage.Name = "labelLanguage"; - this.labelLanguage.Size = new System.Drawing.Size(237, 25); - this.labelLanguage.TabIndex = 11; - this.labelLanguage.Text = "Language"; - this.labelLanguage.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // buttonInverseSelection - // - this.buttonInverseSelection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonInverseSelection.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonInverseSelection.Location = new System.Drawing.Point(87, 530); - this.buttonInverseSelection.Name = "buttonInverseSelection"; - this.buttonInverseSelection.Size = new System.Drawing.Size(100, 23); - this.buttonInverseSelection.TabIndex = 3; - this.buttonInverseSelection.Text = "Inverse selection"; - this.buttonInverseSelection.UseVisualStyleBackColor = true; - this.buttonInverseSelection.Click += new System.EventHandler(this.ButtonInverseSelectionClick); - // - // buttonSelectAll - // - this.buttonSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonSelectAll.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonSelectAll.Location = new System.Drawing.Point(6, 530); - this.buttonSelectAll.Name = "buttonSelectAll"; - this.buttonSelectAll.Size = new System.Drawing.Size(75, 23); - this.buttonSelectAll.TabIndex = 2; - this.buttonSelectAll.Text = "Select all"; - this.buttonSelectAll.UseVisualStyleBackColor = true; - this.buttonSelectAll.Click += new System.EventHandler(this.ButtonSelectAllClick); - // - // listView1 - // - this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listView1.CheckBoxes = true; - this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.columnHeader2, - this.columnHeader3}); - this.listView1.ContextMenuStrip = this.contextMenuStripRules; - this.listView1.FullRowSelect = true; - this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.listView1.HideSelection = false; - this.listView1.Location = new System.Drawing.Point(6, 48); - this.listView1.Name = "listView1"; - this.listView1.Size = new System.Drawing.Size(810, 477); - this.listView1.TabIndex = 1; - this.listView1.UseCompatibleStateImageBehavior = false; - this.listView1.View = System.Windows.Forms.View.Details; - // - // columnHeader1 - // - this.columnHeader1.Text = "Apply"; - this.columnHeader1.Width = 53; - // - // columnHeader2 - // - this.columnHeader2.Text = "What to fix"; - this.columnHeader2.Width = 99; - // - // columnHeader3 - // - this.columnHeader3.Text = "Example"; - this.columnHeader3.Width = 158; - // - // contextMenuStripRules - // - this.contextMenuStripRules.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemSelectAllRules, - this.toolStripMenuItemInverseRules, - this.selectDefaultToolStripMenuItem, - this.toolStripSeparator2, - this.setCurrentFixesAsDefaultToolStripMenuItem}); - this.contextMenuStripRules.Name = "contextMenuStrip1"; - this.contextMenuStripRules.Size = new System.Drawing.Size(213, 98); - // - // toolStripMenuItemSelectAllRules - // - this.toolStripMenuItemSelectAllRules.Name = "toolStripMenuItemSelectAllRules"; - this.toolStripMenuItemSelectAllRules.Size = new System.Drawing.Size(212, 22); - this.toolStripMenuItemSelectAllRules.Text = "Select all"; - this.toolStripMenuItemSelectAllRules.Click += new System.EventHandler(this.ButtonSelectAllClick); - // - // toolStripMenuItemInverseRules - // - this.toolStripMenuItemInverseRules.Name = "toolStripMenuItemInverseRules"; - this.toolStripMenuItemInverseRules.Size = new System.Drawing.Size(212, 22); - this.toolStripMenuItemInverseRules.Text = "Inverse selection"; - this.toolStripMenuItemInverseRules.Click += new System.EventHandler(this.ButtonInverseSelectionClick); - // - // selectDefaultToolStripMenuItem - // - this.selectDefaultToolStripMenuItem.Name = "selectDefaultToolStripMenuItem"; - this.selectDefaultToolStripMenuItem.Size = new System.Drawing.Size(212, 22); - this.selectDefaultToolStripMenuItem.Text = "Select default"; - this.selectDefaultToolStripMenuItem.Click += new System.EventHandler(this.selectDefaultToolStripMenuItem_Click); - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(209, 6); - // - // setCurrentFixesAsDefaultToolStripMenuItem - // - this.setCurrentFixesAsDefaultToolStripMenuItem.Name = "setCurrentFixesAsDefaultToolStripMenuItem"; - this.setCurrentFixesAsDefaultToolStripMenuItem.Size = new System.Drawing.Size(212, 22); - this.setCurrentFixesAsDefaultToolStripMenuItem.Text = "Set current fixes as default"; - this.setCurrentFixesAsDefaultToolStripMenuItem.Click += new System.EventHandler(this.setCurrentFixesAsDefaultToolStripMenuItem_Click); - // - // groupBox2 - // - this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox2.Controls.Add(this.labelLanguage2); - this.groupBox2.Controls.Add(this.tabControl1); - this.groupBox2.Location = new System.Drawing.Point(12, 12); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(822, 557); - this.groupBox2.TabIndex = 10; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Step 2/2 - Verify fixes"; - // - // labelLanguage2 - // - this.labelLanguage2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelLanguage2.ForeColor = System.Drawing.SystemColors.GrayText; - this.labelLanguage2.Location = new System.Drawing.Point(650, 14); - this.labelLanguage2.Name = "labelLanguage2"; - this.labelLanguage2.Size = new System.Drawing.Size(160, 13); - this.labelLanguage2.TabIndex = 12; - this.labelLanguage2.Text = "Lang"; - this.labelLanguage2.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // tabControl1 - // - this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tabControl1.Controls.Add(this.tabPageFixes); - this.tabControl1.Controls.Add(this.tabPageLog); - this.tabControl1.Location = new System.Drawing.Point(6, 20); - this.tabControl1.Name = "tabControl1"; - this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(810, 531); - this.tabControl1.TabIndex = 7; - // - // tabPageFixes - // - this.tabPageFixes.Controls.Add(this.splitContainerStep2); - this.tabPageFixes.Location = new System.Drawing.Point(4, 22); - this.tabPageFixes.Name = "tabPageFixes"; - this.tabPageFixes.Padding = new System.Windows.Forms.Padding(3); - this.tabPageFixes.Size = new System.Drawing.Size(802, 505); - this.tabPageFixes.TabIndex = 1; - this.tabPageFixes.Text = "Fixes"; - this.tabPageFixes.UseVisualStyleBackColor = true; - // - // splitContainerStep2 - // - this.splitContainerStep2.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainerStep2.Location = new System.Drawing.Point(3, 3); - this.splitContainerStep2.Name = "splitContainerStep2"; - this.splitContainerStep2.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainerStep2.Panel1 - // - this.splitContainerStep2.Panel1.Controls.Add(this.listViewFixes); - this.splitContainerStep2.Panel1.Controls.Add(this.buttonFixesApply); - this.splitContainerStep2.Panel1.Controls.Add(this.buttonRefreshFixes); - this.splitContainerStep2.Panel1.Controls.Add(this.buttonFixesSelectAll); - this.splitContainerStep2.Panel1.Controls.Add(this.buttonFixesInverse); - // - // splitContainerStep2.Panel2 - // - this.splitContainerStep2.Panel2.Controls.Add(this.subtitleListView1); - this.splitContainerStep2.Panel2.Controls.Add(this.groupBoxEditPanel); - this.splitContainerStep2.Size = new System.Drawing.Size(796, 499); - this.splitContainerStep2.SplitterDistance = 231; - this.splitContainerStep2.TabIndex = 112; - // - // listViewFixes - // - this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewFixes.CheckBoxes = true; - this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader4, - this.columnHeader5, - this.columnHeader6, - this.columnHeader7, - this.columnHeader8}); - this.listViewFixes.ContextMenuStrip = this.contextMenuStripFixes; - this.listViewFixes.FullRowSelect = true; - this.listViewFixes.HideSelection = false; - this.listViewFixes.Location = new System.Drawing.Point(3, 3); - this.listViewFixes.Name = "listViewFixes"; - this.listViewFixes.Size = new System.Drawing.Size(790, 198); - this.listViewFixes.TabIndex = 100; - this.listViewFixes.UseCompatibleStateImageBehavior = false; - this.listViewFixes.View = System.Windows.Forms.View.Details; - this.listViewFixes.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.ListViewFixesColumnClick); - this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.ListViewFixesSelectedIndexChanged); - // - // columnHeader4 - // - this.columnHeader4.Text = "Apply"; - this.columnHeader4.Width = 50; - // - // columnHeader5 - // - this.columnHeader5.Text = "Line#"; - this.columnHeader5.Width = 61; - // - // columnHeader6 - // - this.columnHeader6.Text = "Function"; - this.columnHeader6.Width = 134; - // - // columnHeader7 - // - this.columnHeader7.Text = "Before"; - this.columnHeader7.Width = 281; - // - // columnHeader8 - // - this.columnHeader8.Text = "After"; - this.columnHeader8.Width = 244; - // - // contextMenuStripFixes - // - this.contextMenuStripFixes.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemSelectAll, - this.toolStripMenuItemInverseSelection}); - this.contextMenuStripFixes.Name = "contextMenuStrip1"; - this.contextMenuStripFixes.Size = new System.Drawing.Size(162, 48); - // - // toolStripMenuItemSelectAll - // - this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; - this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(161, 22); - this.toolStripMenuItemSelectAll.Text = "Select all"; - this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); - // - // toolStripMenuItemInverseSelection - // - this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; - this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(161, 22); - this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; - this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); - // - // buttonFixesApply - // - this.buttonFixesApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonFixesApply.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.buttonFixesApply.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonFixesApply.Location = new System.Drawing.Point(628, 206); - this.buttonFixesApply.Name = "buttonFixesApply"; - this.buttonFixesApply.Size = new System.Drawing.Size(165, 23); - this.buttonFixesApply.TabIndex = 108; - this.buttonFixesApply.Text = "Apply &selected fixes"; - this.buttonFixesApply.UseVisualStyleBackColor = true; - this.buttonFixesApply.Click += new System.EventHandler(this.ButtonFixesApplyClick); - // - // buttonRefreshFixes - // - this.buttonRefreshFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRefreshFixes.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonRefreshFixes.Location = new System.Drawing.Point(457, 206); - this.buttonRefreshFixes.Name = "buttonRefreshFixes"; - this.buttonRefreshFixes.Size = new System.Drawing.Size(165, 23); - this.buttonRefreshFixes.TabIndex = 106; - this.buttonRefreshFixes.Text = "&Refresh available fixes"; - this.buttonRefreshFixes.UseVisualStyleBackColor = true; - this.buttonRefreshFixes.Click += new System.EventHandler(this.ButtonRefreshFixesClick); - // - // buttonFixesSelectAll - // - this.buttonFixesSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonFixesSelectAll.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonFixesSelectAll.Location = new System.Drawing.Point(3, 206); - this.buttonFixesSelectAll.Name = "buttonFixesSelectAll"; - this.buttonFixesSelectAll.Size = new System.Drawing.Size(75, 23); - this.buttonFixesSelectAll.TabIndex = 102; - this.buttonFixesSelectAll.Text = "Select &all"; - this.buttonFixesSelectAll.UseVisualStyleBackColor = true; - this.buttonFixesSelectAll.Click += new System.EventHandler(this.ButtonFixesSelectAllClick); - // - // buttonFixesInverse - // - this.buttonFixesInverse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonFixesInverse.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonFixesInverse.Location = new System.Drawing.Point(84, 206); - this.buttonFixesInverse.Name = "buttonFixesInverse"; - this.buttonFixesInverse.Size = new System.Drawing.Size(100, 23); - this.buttonFixesInverse.TabIndex = 104; - this.buttonFixesInverse.Text = "&Inverse selection"; - this.buttonFixesInverse.UseVisualStyleBackColor = true; - this.buttonFixesInverse.Click += new System.EventHandler(this.ButtonFixesInverseClick); - // - // subtitleListView1 - // - this.subtitleListView1.AllowColumnReorder = true; - this.subtitleListView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.subtitleListView1.ContextMenuStrip = this.contextMenuStripListview; - this.subtitleListView1.FirstVisibleIndex = -1; - this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.subtitleListView1.FullRowSelect = true; - this.subtitleListView1.GridLines = true; - this.subtitleListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.subtitleListView1.HideSelection = false; - this.subtitleListView1.Location = new System.Drawing.Point(3, 5); - this.subtitleListView1.Name = "subtitleListView1"; - this.subtitleListView1.OwnerDraw = true; - this.subtitleListView1.Size = new System.Drawing.Size(785, 158); - this.subtitleListView1.SubtitleFontBold = false; - this.subtitleListView1.SubtitleFontName = "Tahoma"; - this.subtitleListView1.SubtitleFontSize = 8; - this.subtitleListView1.TabIndex = 110; - this.subtitleListView1.UseCompatibleStateImageBehavior = false; - this.subtitleListView1.UseSyntaxColoring = true; - this.subtitleListView1.View = System.Windows.Forms.View.Details; - this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView1SelectedIndexChanged); - this.subtitleListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.subtitleListView1_KeyDown); - // - // contextMenuStripListview - // - this.contextMenuStripListview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemDelete, - this.toolStripSeparator1, - this.mergeSelectedLinesToolStripMenuItem}); - this.contextMenuStripListview.Name = "contextMenuStripListview"; - this.contextMenuStripListview.Size = new System.Drawing.Size(182, 54); - this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening); - // - // toolStripMenuItemDelete - // - this.toolStripMenuItemDelete.Name = "toolStripMenuItemDelete"; - this.toolStripMenuItemDelete.Size = new System.Drawing.Size(181, 22); - this.toolStripMenuItemDelete.Text = "Delete"; - this.toolStripMenuItemDelete.Click += new System.EventHandler(this.ToolStripMenuItemDeleteClick); - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(178, 6); - // - // mergeSelectedLinesToolStripMenuItem - // - this.mergeSelectedLinesToolStripMenuItem.Name = "mergeSelectedLinesToolStripMenuItem"; - this.mergeSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(181, 22); - this.mergeSelectedLinesToolStripMenuItem.Text = "Merge selected lines"; - this.mergeSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.MergeSelectedLinesToolStripMenuItemClick); - // - // groupBoxEditPanel - // - this.groupBoxEditPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxEditPanel.Controls.Add(this.buttonSplitLine); - this.groupBoxEditPanel.Controls.Add(this.labelSingleLine); - this.groupBoxEditPanel.Controls.Add(this.buttonUnBreak); - this.groupBoxEditPanel.Controls.Add(this.buttonAutoBreak); - this.groupBoxEditPanel.Controls.Add(this.labelStartTimeWarning); - this.groupBoxEditPanel.Controls.Add(this.labelDurationWarning); - this.groupBoxEditPanel.Controls.Add(this.timeUpDownStartTime); - this.groupBoxEditPanel.Controls.Add(this.numericUpDownDuration); - this.groupBoxEditPanel.Controls.Add(this.labelDuration); - this.groupBoxEditPanel.Controls.Add(this.labelStartTime); - this.groupBoxEditPanel.Controls.Add(this.labelTextLineTotal); - this.groupBoxEditPanel.Controls.Add(this.labelTextLineLengths); - this.groupBoxEditPanel.Controls.Add(this.textBoxListViewText); - this.groupBoxEditPanel.Location = new System.Drawing.Point(8, 160); - this.groupBoxEditPanel.Name = "groupBoxEditPanel"; - this.groupBoxEditPanel.Size = new System.Drawing.Size(780, 101); - this.groupBoxEditPanel.TabIndex = 111; - this.groupBoxEditPanel.TabStop = false; - // - // buttonSplitLine - // - this.buttonSplitLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSplitLine.ForeColor = System.Drawing.Color.Red; - this.buttonSplitLine.Location = new System.Drawing.Point(627, 62); - this.buttonSplitLine.Name = "buttonSplitLine"; - this.buttonSplitLine.Size = new System.Drawing.Size(96, 23); - this.buttonSplitLine.TabIndex = 124; - this.buttonSplitLine.Text = "Split line"; - this.buttonSplitLine.UseVisualStyleBackColor = true; - this.buttonSplitLine.Click += new System.EventHandler(this.ButtonSplitLineClick); - // - // labelSingleLine - // - this.labelSingleLine.AutoSize = true; - this.labelSingleLine.Location = new System.Drawing.Point(296, 79); - this.labelSingleLine.Name = "labelSingleLine"; - this.labelSingleLine.Size = new System.Drawing.Size(23, 13); - this.labelSingleLine.TabIndex = 123; - this.labelSingleLine.Text = "1/1"; - // - // buttonUnBreak - // - this.buttonUnBreak.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUnBreak.Location = new System.Drawing.Point(627, 37); - this.buttonUnBreak.Name = "buttonUnBreak"; - this.buttonUnBreak.Size = new System.Drawing.Size(96, 23); - this.buttonUnBreak.TabIndex = 122; - this.buttonUnBreak.Text = "&Unbreak"; - this.buttonUnBreak.UseVisualStyleBackColor = true; - this.buttonUnBreak.Click += new System.EventHandler(this.ButtonUnBreakClick); - // - // buttonAutoBreak - // - this.buttonAutoBreak.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonAutoBreak.Location = new System.Drawing.Point(627, 12); - this.buttonAutoBreak.Name = "buttonAutoBreak"; - this.buttonAutoBreak.Size = new System.Drawing.Size(96, 23); - this.buttonAutoBreak.TabIndex = 120; - this.buttonAutoBreak.Text = "Auto &br"; - this.buttonAutoBreak.UseVisualStyleBackColor = true; - this.buttonAutoBreak.Click += new System.EventHandler(this.ButtonAutoBreakClick); - // - // labelStartTimeWarning - // - this.labelStartTimeWarning.AutoSize = true; - this.labelStartTimeWarning.ForeColor = System.Drawing.Color.Red; - this.labelStartTimeWarning.Location = new System.Drawing.Point(6, 51); - this.labelStartTimeWarning.Name = "labelStartTimeWarning"; - this.labelStartTimeWarning.Size = new System.Drawing.Size(115, 13); - this.labelStartTimeWarning.TabIndex = 32; - this.labelStartTimeWarning.Text = "labelStartTimeWarning"; - // - // labelDurationWarning - // - this.labelDurationWarning.AutoSize = true; - this.labelDurationWarning.ForeColor = System.Drawing.Color.Red; - this.labelDurationWarning.Location = new System.Drawing.Point(57, 64); - this.labelDurationWarning.Name = "labelDurationWarning"; - this.labelDurationWarning.Size = new System.Drawing.Size(110, 13); - this.labelDurationWarning.TabIndex = 31; - this.labelDurationWarning.Text = "labelDurationWarning"; - // - // timeUpDownStartTime - // - this.timeUpDownStartTime.AutoSize = true; - this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownStartTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); - this.timeUpDownStartTime.Location = new System.Drawing.Point(8, 27); - this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownStartTime.Name = "timeUpDownStartTime"; - this.timeUpDownStartTime.Size = new System.Drawing.Size(111, 27); - this.timeUpDownStartTime.TabIndex = 112; - timeCode1.Hours = 0; - timeCode1.Milliseconds = 0; - timeCode1.Minutes = 0; - timeCode1.Seconds = 0; - timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode1.TotalMilliseconds = 0D; - timeCode1.TotalSeconds = 0D; - this.timeUpDownStartTime.TimeCode = timeCode1; - this.timeUpDownStartTime.UseVideoOffset = false; - // - // numericUpDownDuration - // - this.numericUpDownDuration.DecimalPlaces = 3; - this.numericUpDownDuration.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownDuration.Location = new System.Drawing.Point(99, 28); - this.numericUpDownDuration.Maximum = new decimal(new int[] { - 99999, - 0, - 0, - 0}); - this.numericUpDownDuration.Minimum = new decimal(new int[] { - 99999, - 0, - 0, - -2147483648}); - this.numericUpDownDuration.Name = "numericUpDownDuration"; - this.numericUpDownDuration.Size = new System.Drawing.Size(56, 21); - this.numericUpDownDuration.TabIndex = 114; - this.numericUpDownDuration.ValueChanged += new System.EventHandler(this.NumericUpDownDurationValueChanged); - // - // labelDuration - // - this.labelDuration.AutoSize = true; - this.labelDuration.Location = new System.Drawing.Point(97, 12); - this.labelDuration.Name = "labelDuration"; - this.labelDuration.Size = new System.Drawing.Size(48, 13); - this.labelDuration.TabIndex = 28; - this.labelDuration.Text = "Duration"; - // - // labelStartTime - // - this.labelStartTime.AutoSize = true; - this.labelStartTime.Location = new System.Drawing.Point(6, 12); - this.labelStartTime.Name = "labelStartTime"; - this.labelStartTime.Size = new System.Drawing.Size(54, 13); - this.labelStartTime.TabIndex = 27; - this.labelStartTime.Text = "Start time"; - // - // labelTextLineTotal - // - this.labelTextLineTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelTextLineTotal.Location = new System.Drawing.Point(444, 79); - this.labelTextLineTotal.Name = "labelTextLineTotal"; - this.labelTextLineTotal.Size = new System.Drawing.Size(177, 16); - this.labelTextLineTotal.TabIndex = 26; - this.labelTextLineTotal.Text = "labelTextLineTotal"; - this.labelTextLineTotal.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // labelTextLineLengths - // - this.labelTextLineLengths.AutoSize = true; - this.labelTextLineLengths.Location = new System.Drawing.Point(191, 79); - this.labelTextLineLengths.Name = "labelTextLineLengths"; - this.labelTextLineLengths.Size = new System.Drawing.Size(108, 13); - this.labelTextLineLengths.TabIndex = 25; - this.labelTextLineLengths.Text = "labelTextLineLengths"; - // - // textBoxListViewText - // - this.textBoxListViewText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxListViewText.HideSelection = false; - this.textBoxListViewText.Location = new System.Drawing.Point(194, 12); - this.textBoxListViewText.Multiline = true; - this.textBoxListViewText.Name = "textBoxListViewText"; - this.textBoxListViewText.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxListViewText.Size = new System.Drawing.Size(427, 64); - this.textBoxListViewText.TabIndex = 118; - this.textBoxListViewText.TextChanged += new System.EventHandler(this.TextBoxListViewTextTextChanged); - this.textBoxListViewText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxListViewTextKeyDown); - // - // tabPageLog - // - this.tabPageLog.Controls.Add(this.textBoxFixedIssues); - this.tabPageLog.Location = new System.Drawing.Point(4, 22); - this.tabPageLog.Name = "tabPageLog"; - this.tabPageLog.Size = new System.Drawing.Size(802, 505); - this.tabPageLog.TabIndex = 2; - this.tabPageLog.Text = "Log"; - this.tabPageLog.UseVisualStyleBackColor = true; - // - // textBoxFixedIssues - // - this.textBoxFixedIssues.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxFixedIssues.Location = new System.Drawing.Point(3, 3); - this.textBoxFixedIssues.MaxLength = 65767; - this.textBoxFixedIssues.Multiline = true; - this.textBoxFixedIssues.Name = "textBoxFixedIssues"; - this.textBoxFixedIssues.ReadOnly = true; - this.textBoxFixedIssues.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxFixedIssues.Size = new System.Drawing.Size(796, 499); - this.textBoxFixedIssues.TabIndex = 5; - this.textBoxFixedIssues.WordWrap = false; - // - // labelNumberOfImportantLogMessages - // - this.labelNumberOfImportantLogMessages.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelNumberOfImportantLogMessages.AutoSize = true; - this.labelNumberOfImportantLogMessages.ForeColor = System.Drawing.Color.Red; - this.labelNumberOfImportantLogMessages.Location = new System.Drawing.Point(12, 593); - this.labelNumberOfImportantLogMessages.Name = "labelNumberOfImportantLogMessages"; - this.labelNumberOfImportantLogMessages.Size = new System.Drawing.Size(190, 13); - this.labelNumberOfImportantLogMessages.TabIndex = 11; - this.labelNumberOfImportantLogMessages.Text = "labelNumberOfImportantLogMessages"; - // - // FixCommonErrors - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(846, 608); - this.Controls.Add(this.labelStatus); - this.Controls.Add(this.labelNumberOfImportantLogMessages); - this.Controls.Add(this.buttonBack); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonNextFinish); - this.Controls.Add(this.groupBox2); - this.Controls.Add(this.groupBoxStep1); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(840, 580); - this.Name = "FixCommonErrors"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Fix common errors"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FixCommonErrorsFormClosing); - this.Shown += new System.EventHandler(this.FixCommonErrorsShown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormFixKeyDown); - this.Resize += new System.EventHandler(this.FixCommonErrorsResize); - this.groupBoxStep1.ResumeLayout(false); - this.contextMenuStripRules.ResumeLayout(false); - this.groupBox2.ResumeLayout(false); - this.tabControl1.ResumeLayout(false); - this.tabPageFixes.ResumeLayout(false); - this.splitContainerStep2.Panel1.ResumeLayout(false); - this.splitContainerStep2.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainerStep2)).EndInit(); - this.splitContainerStep2.ResumeLayout(false); - this.contextMenuStripFixes.ResumeLayout(false); - this.contextMenuStripListview.ResumeLayout(false); - this.groupBoxEditPanel.ResumeLayout(false); - this.groupBoxEditPanel.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).EndInit(); - this.tabPageLog.ResumeLayout(false); - this.tabPageLog.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonNextFinish; - private System.Windows.Forms.Label labelStatus; - private System.Windows.Forms.Button buttonBack; - private System.Windows.Forms.GroupBox groupBoxStep1; - private System.Windows.Forms.ListView listView1; - private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.ColumnHeader columnHeader2; - private System.Windows.Forms.ColumnHeader columnHeader3; - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.TabControl tabControl1; - private System.Windows.Forms.TabPage tabPageFixes; - private System.Windows.Forms.ListView listViewFixes; - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeader6; - private System.Windows.Forms.ColumnHeader columnHeader7; - private System.Windows.Forms.ColumnHeader columnHeader8; - private System.Windows.Forms.TabPage tabPageLog; - private System.Windows.Forms.TextBox textBoxFixedIssues; - private System.Windows.Forms.Button buttonInverseSelection; - private System.Windows.Forms.Button buttonSelectAll; - private System.Windows.Forms.GroupBox groupBoxEditPanel; - private SubtitleListView subtitleListView1; - private System.Windows.Forms.Label labelTextLineTotal; - private System.Windows.Forms.Label labelTextLineLengths; - private System.Windows.Forms.TextBox textBoxListViewText; - private System.Windows.Forms.Button buttonFixesApply; - private System.Windows.Forms.Button buttonFixesInverse; - private System.Windows.Forms.Button buttonFixesSelectAll; - private System.Windows.Forms.Label labelStartTimeWarning; - private System.Windows.Forms.Label labelDurationWarning; - private Nikse.SubtitleEdit.Controls.TimeUpDown timeUpDownStartTime; - private System.Windows.Forms.NumericUpDown numericUpDownDuration; - private System.Windows.Forms.Label labelDuration; - private System.Windows.Forms.Label labelStartTime; - private System.Windows.Forms.Button buttonRefreshFixes; - private System.Windows.Forms.Button buttonUnBreak; - private System.Windows.Forms.Button buttonAutoBreak; - private System.Windows.Forms.ContextMenuStrip contextMenuStripListview; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDelete; - private System.Windows.Forms.ToolStripMenuItem mergeSelectedLinesToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.Label labelNumberOfImportantLogMessages; - private System.Windows.Forms.SplitContainer splitContainerStep2; - private System.Windows.Forms.Label labelSingleLine; - private System.Windows.Forms.Button buttonSplitLine; - private System.Windows.Forms.ComboBox comboBoxLanguage; - private System.Windows.Forms.Label labelLanguage; - private System.Windows.Forms.Button buttonResetDefault; - private System.Windows.Forms.ContextMenuStrip contextMenuStripFixes; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; - private System.Windows.Forms.ContextMenuStrip contextMenuStripRules; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAllRules; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseRules; - private System.Windows.Forms.Label labelLanguage2; - private System.Windows.Forms.ToolStripMenuItem selectDefaultToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolStripMenuItem setCurrentFixesAsDefaultToolStripMenuItem; - } +using Nikse.SubtitleEdit.Controls; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class FixCommonErrors + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + TimeCode timeCode1 = new TimeCode(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonNextFinish = new System.Windows.Forms.Button(); + this.labelStatus = new System.Windows.Forms.Label(); + this.buttonBack = new System.Windows.Forms.Button(); + this.groupBoxStep1 = new System.Windows.Forms.GroupBox(); + this.buttonResetDefault = new System.Windows.Forms.Button(); + this.comboBoxLanguage = new System.Windows.Forms.ComboBox(); + this.labelLanguage = new System.Windows.Forms.Label(); + this.buttonInverseSelection = new System.Windows.Forms.Button(); + this.buttonSelectAll = new System.Windows.Forms.Button(); + this.listView1 = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contextMenuStripRules = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemSelectAllRules = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInverseRules = new System.Windows.Forms.ToolStripMenuItem(); + this.selectDefaultToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.setCurrentFixesAsDefaultToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.labelLanguage2 = new System.Windows.Forms.Label(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPageFixes = new System.Windows.Forms.TabPage(); + this.splitContainerStep2 = new System.Windows.Forms.SplitContainer(); + this.listViewFixes = new System.Windows.Forms.ListView(); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contextMenuStripFixes = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); + this.buttonFixesApply = new System.Windows.Forms.Button(); + this.buttonRefreshFixes = new System.Windows.Forms.Button(); + this.buttonFixesSelectAll = new System.Windows.Forms.Button(); + this.buttonFixesInverse = new System.Windows.Forms.Button(); + this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.contextMenuStripListview = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemDelete = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.mergeSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBoxEditPanel = new System.Windows.Forms.GroupBox(); + this.buttonSplitLine = new System.Windows.Forms.Button(); + this.labelSingleLine = new System.Windows.Forms.Label(); + this.buttonUnBreak = new System.Windows.Forms.Button(); + this.buttonAutoBreak = new System.Windows.Forms.Button(); + this.labelStartTimeWarning = new System.Windows.Forms.Label(); + this.labelDurationWarning = new System.Windows.Forms.Label(); + this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.numericUpDownDuration = new System.Windows.Forms.NumericUpDown(); + this.labelDuration = new System.Windows.Forms.Label(); + this.labelStartTime = new System.Windows.Forms.Label(); + this.labelTextLineTotal = new System.Windows.Forms.Label(); + this.labelTextLineLengths = new System.Windows.Forms.Label(); + this.textBoxListViewText = new System.Windows.Forms.TextBox(); + this.tabPageLog = new System.Windows.Forms.TabPage(); + this.textBoxFixedIssues = new System.Windows.Forms.TextBox(); + this.labelNumberOfImportantLogMessages = new System.Windows.Forms.Label(); + this.groupBoxStep1.SuspendLayout(); + this.contextMenuStripRules.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.tabPageFixes.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainerStep2)).BeginInit(); + this.splitContainerStep2.Panel1.SuspendLayout(); + this.splitContainerStep2.Panel2.SuspendLayout(); + this.splitContainerStep2.SuspendLayout(); + this.contextMenuStripFixes.SuspendLayout(); + this.contextMenuStripListview.SuspendLayout(); + this.groupBoxEditPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).BeginInit(); + this.tabPageLog.SuspendLayout(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(759, 575); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 10; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); + // + // buttonNextFinish + // + this.buttonNextFinish.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonNextFinish.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonNextFinish.Location = new System.Drawing.Point(678, 575); + this.buttonNextFinish.Name = "buttonNextFinish"; + this.buttonNextFinish.Size = new System.Drawing.Size(75, 23); + this.buttonNextFinish.TabIndex = 9; + this.buttonNextFinish.Text = "&Next >"; + this.buttonNextFinish.UseVisualStyleBackColor = true; + this.buttonNextFinish.Click += new System.EventHandler(this.ButtonFixClick); + // + // labelStatus + // + this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(12, 577); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(60, 13); + this.labelStatus.TabIndex = 5; + this.labelStatus.Text = "labelStatus"; + // + // buttonBack + // + this.buttonBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonBack.Enabled = false; + this.buttonBack.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonBack.Location = new System.Drawing.Point(597, 575); + this.buttonBack.Name = "buttonBack"; + this.buttonBack.Size = new System.Drawing.Size(75, 23); + this.buttonBack.TabIndex = 8; + this.buttonBack.Text = "< &Back"; + this.buttonBack.UseVisualStyleBackColor = true; + this.buttonBack.Click += new System.EventHandler(this.ButtonBackClick); + // + // groupBoxStep1 + // + this.groupBoxStep1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxStep1.Controls.Add(this.buttonResetDefault); + this.groupBoxStep1.Controls.Add(this.comboBoxLanguage); + this.groupBoxStep1.Controls.Add(this.labelLanguage); + this.groupBoxStep1.Controls.Add(this.buttonInverseSelection); + this.groupBoxStep1.Controls.Add(this.buttonSelectAll); + this.groupBoxStep1.Controls.Add(this.listView1); + this.groupBoxStep1.Location = new System.Drawing.Point(12, 12); + this.groupBoxStep1.Name = "groupBoxStep1"; + this.groupBoxStep1.Size = new System.Drawing.Size(822, 557); + this.groupBoxStep1.TabIndex = 9; + this.groupBoxStep1.TabStop = false; + this.groupBoxStep1.Text = "Step 1/2 - Choose which errors to fix"; + // + // buttonResetDefault + // + this.buttonResetDefault.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonResetDefault.Location = new System.Drawing.Point(193, 530); + this.buttonResetDefault.Name = "buttonResetDefault"; + this.buttonResetDefault.Size = new System.Drawing.Size(100, 23); + this.buttonResetDefault.TabIndex = 12; + this.buttonResetDefault.Text = "Select default"; + this.buttonResetDefault.UseVisualStyleBackColor = true; + this.buttonResetDefault.Click += new System.EventHandler(this.buttonResetDefault_Click); + // + // comboBoxLanguage + // + this.comboBoxLanguage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.comboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxLanguage.FormattingEnabled = true; + this.comboBoxLanguage.Location = new System.Drawing.Point(619, 17); + this.comboBoxLanguage.Name = "comboBoxLanguage"; + this.comboBoxLanguage.Size = new System.Drawing.Size(196, 21); + this.comboBoxLanguage.TabIndex = 0; + this.comboBoxLanguage.SelectedIndexChanged += new System.EventHandler(this.comboBoxLanguage_SelectedIndexChanged); + this.comboBoxLanguage.Enter += new System.EventHandler(this.comboBoxLanguage_Enter); + // + // labelLanguage + // + this.labelLanguage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelLanguage.Location = new System.Drawing.Point(376, 20); + this.labelLanguage.Name = "labelLanguage"; + this.labelLanguage.Size = new System.Drawing.Size(237, 25); + this.labelLanguage.TabIndex = 11; + this.labelLanguage.Text = "Language"; + this.labelLanguage.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // buttonInverseSelection + // + this.buttonInverseSelection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonInverseSelection.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonInverseSelection.Location = new System.Drawing.Point(87, 530); + this.buttonInverseSelection.Name = "buttonInverseSelection"; + this.buttonInverseSelection.Size = new System.Drawing.Size(100, 23); + this.buttonInverseSelection.TabIndex = 3; + this.buttonInverseSelection.Text = "Inverse selection"; + this.buttonInverseSelection.UseVisualStyleBackColor = true; + this.buttonInverseSelection.Click += new System.EventHandler(this.ButtonInverseSelectionClick); + // + // buttonSelectAll + // + this.buttonSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonSelectAll.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonSelectAll.Location = new System.Drawing.Point(6, 530); + this.buttonSelectAll.Name = "buttonSelectAll"; + this.buttonSelectAll.Size = new System.Drawing.Size(75, 23); + this.buttonSelectAll.TabIndex = 2; + this.buttonSelectAll.Text = "Select all"; + this.buttonSelectAll.UseVisualStyleBackColor = true; + this.buttonSelectAll.Click += new System.EventHandler(this.ButtonSelectAllClick); + // + // listView1 + // + this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listView1.CheckBoxes = true; + this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2, + this.columnHeader3}); + this.listView1.ContextMenuStrip = this.contextMenuStripRules; + this.listView1.FullRowSelect = true; + this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.listView1.HideSelection = false; + this.listView1.Location = new System.Drawing.Point(6, 48); + this.listView1.Name = "listView1"; + this.listView1.Size = new System.Drawing.Size(810, 477); + this.listView1.TabIndex = 1; + this.listView1.UseCompatibleStateImageBehavior = false; + this.listView1.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Text = "Apply"; + this.columnHeader1.Width = 53; + // + // columnHeader2 + // + this.columnHeader2.Text = "What to fix"; + this.columnHeader2.Width = 99; + // + // columnHeader3 + // + this.columnHeader3.Text = "Example"; + this.columnHeader3.Width = 158; + // + // contextMenuStripRules + // + this.contextMenuStripRules.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSelectAllRules, + this.toolStripMenuItemInverseRules, + this.selectDefaultToolStripMenuItem, + this.toolStripSeparator2, + this.setCurrentFixesAsDefaultToolStripMenuItem}); + this.contextMenuStripRules.Name = "contextMenuStrip1"; + this.contextMenuStripRules.Size = new System.Drawing.Size(213, 98); + // + // toolStripMenuItemSelectAllRules + // + this.toolStripMenuItemSelectAllRules.Name = "toolStripMenuItemSelectAllRules"; + this.toolStripMenuItemSelectAllRules.Size = new System.Drawing.Size(212, 22); + this.toolStripMenuItemSelectAllRules.Text = "Select all"; + this.toolStripMenuItemSelectAllRules.Click += new System.EventHandler(this.ButtonSelectAllClick); + // + // toolStripMenuItemInverseRules + // + this.toolStripMenuItemInverseRules.Name = "toolStripMenuItemInverseRules"; + this.toolStripMenuItemInverseRules.Size = new System.Drawing.Size(212, 22); + this.toolStripMenuItemInverseRules.Text = "Inverse selection"; + this.toolStripMenuItemInverseRules.Click += new System.EventHandler(this.ButtonInverseSelectionClick); + // + // selectDefaultToolStripMenuItem + // + this.selectDefaultToolStripMenuItem.Name = "selectDefaultToolStripMenuItem"; + this.selectDefaultToolStripMenuItem.Size = new System.Drawing.Size(212, 22); + this.selectDefaultToolStripMenuItem.Text = "Select default"; + this.selectDefaultToolStripMenuItem.Click += new System.EventHandler(this.selectDefaultToolStripMenuItem_Click); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(209, 6); + // + // setCurrentFixesAsDefaultToolStripMenuItem + // + this.setCurrentFixesAsDefaultToolStripMenuItem.Name = "setCurrentFixesAsDefaultToolStripMenuItem"; + this.setCurrentFixesAsDefaultToolStripMenuItem.Size = new System.Drawing.Size(212, 22); + this.setCurrentFixesAsDefaultToolStripMenuItem.Text = "Set current fixes as default"; + this.setCurrentFixesAsDefaultToolStripMenuItem.Click += new System.EventHandler(this.setCurrentFixesAsDefaultToolStripMenuItem_Click); + // + // groupBox2 + // + this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox2.Controls.Add(this.labelLanguage2); + this.groupBox2.Controls.Add(this.tabControl1); + this.groupBox2.Location = new System.Drawing.Point(12, 12); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(822, 557); + this.groupBox2.TabIndex = 10; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Step 2/2 - Verify fixes"; + // + // labelLanguage2 + // + this.labelLanguage2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelLanguage2.ForeColor = System.Drawing.SystemColors.GrayText; + this.labelLanguage2.Location = new System.Drawing.Point(650, 14); + this.labelLanguage2.Name = "labelLanguage2"; + this.labelLanguage2.Size = new System.Drawing.Size(160, 13); + this.labelLanguage2.TabIndex = 12; + this.labelLanguage2.Text = "Lang"; + this.labelLanguage2.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // tabControl1 + // + this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl1.Controls.Add(this.tabPageFixes); + this.tabControl1.Controls.Add(this.tabPageLog); + this.tabControl1.Location = new System.Drawing.Point(6, 20); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(810, 531); + this.tabControl1.TabIndex = 7; + // + // tabPageFixes + // + this.tabPageFixes.Controls.Add(this.splitContainerStep2); + this.tabPageFixes.Location = new System.Drawing.Point(4, 22); + this.tabPageFixes.Name = "tabPageFixes"; + this.tabPageFixes.Padding = new System.Windows.Forms.Padding(3); + this.tabPageFixes.Size = new System.Drawing.Size(802, 505); + this.tabPageFixes.TabIndex = 1; + this.tabPageFixes.Text = "Fixes"; + this.tabPageFixes.UseVisualStyleBackColor = true; + // + // splitContainerStep2 + // + this.splitContainerStep2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainerStep2.Location = new System.Drawing.Point(3, 3); + this.splitContainerStep2.Name = "splitContainerStep2"; + this.splitContainerStep2.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainerStep2.Panel1 + // + this.splitContainerStep2.Panel1.Controls.Add(this.listViewFixes); + this.splitContainerStep2.Panel1.Controls.Add(this.buttonFixesApply); + this.splitContainerStep2.Panel1.Controls.Add(this.buttonRefreshFixes); + this.splitContainerStep2.Panel1.Controls.Add(this.buttonFixesSelectAll); + this.splitContainerStep2.Panel1.Controls.Add(this.buttonFixesInverse); + // + // splitContainerStep2.Panel2 + // + this.splitContainerStep2.Panel2.Controls.Add(this.subtitleListView1); + this.splitContainerStep2.Panel2.Controls.Add(this.groupBoxEditPanel); + this.splitContainerStep2.Size = new System.Drawing.Size(796, 499); + this.splitContainerStep2.SplitterDistance = 231; + this.splitContainerStep2.TabIndex = 112; + // + // listViewFixes + // + this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewFixes.CheckBoxes = true; + this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader4, + this.columnHeader5, + this.columnHeader6, + this.columnHeader7, + this.columnHeader8}); + this.listViewFixes.ContextMenuStrip = this.contextMenuStripFixes; + this.listViewFixes.FullRowSelect = true; + this.listViewFixes.HideSelection = false; + this.listViewFixes.Location = new System.Drawing.Point(3, 3); + this.listViewFixes.Name = "listViewFixes"; + this.listViewFixes.Size = new System.Drawing.Size(790, 198); + this.listViewFixes.TabIndex = 100; + this.listViewFixes.UseCompatibleStateImageBehavior = false; + this.listViewFixes.View = System.Windows.Forms.View.Details; + this.listViewFixes.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.ListViewFixesColumnClick); + this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.ListViewFixesSelectedIndexChanged); + // + // columnHeader4 + // + this.columnHeader4.Text = "Apply"; + this.columnHeader4.Width = 50; + // + // columnHeader5 + // + this.columnHeader5.Text = "Line#"; + this.columnHeader5.Width = 61; + // + // columnHeader6 + // + this.columnHeader6.Text = "Function"; + this.columnHeader6.Width = 134; + // + // columnHeader7 + // + this.columnHeader7.Text = "Before"; + this.columnHeader7.Width = 281; + // + // columnHeader8 + // + this.columnHeader8.Text = "After"; + this.columnHeader8.Width = 244; + // + // contextMenuStripFixes + // + this.contextMenuStripFixes.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSelectAll, + this.toolStripMenuItemInverseSelection}); + this.contextMenuStripFixes.Name = "contextMenuStrip1"; + this.contextMenuStripFixes.Size = new System.Drawing.Size(162, 48); + // + // toolStripMenuItemSelectAll + // + this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; + this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(161, 22); + this.toolStripMenuItemSelectAll.Text = "Select all"; + this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); + // + // toolStripMenuItemInverseSelection + // + this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; + this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(161, 22); + this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; + this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); + // + // buttonFixesApply + // + this.buttonFixesApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonFixesApply.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.buttonFixesApply.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonFixesApply.Location = new System.Drawing.Point(628, 206); + this.buttonFixesApply.Name = "buttonFixesApply"; + this.buttonFixesApply.Size = new System.Drawing.Size(165, 23); + this.buttonFixesApply.TabIndex = 108; + this.buttonFixesApply.Text = "Apply &selected fixes"; + this.buttonFixesApply.UseVisualStyleBackColor = true; + this.buttonFixesApply.Click += new System.EventHandler(this.ButtonFixesApplyClick); + // + // buttonRefreshFixes + // + this.buttonRefreshFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRefreshFixes.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonRefreshFixes.Location = new System.Drawing.Point(457, 206); + this.buttonRefreshFixes.Name = "buttonRefreshFixes"; + this.buttonRefreshFixes.Size = new System.Drawing.Size(165, 23); + this.buttonRefreshFixes.TabIndex = 106; + this.buttonRefreshFixes.Text = "&Refresh available fixes"; + this.buttonRefreshFixes.UseVisualStyleBackColor = true; + this.buttonRefreshFixes.Click += new System.EventHandler(this.ButtonRefreshFixesClick); + // + // buttonFixesSelectAll + // + this.buttonFixesSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonFixesSelectAll.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonFixesSelectAll.Location = new System.Drawing.Point(3, 206); + this.buttonFixesSelectAll.Name = "buttonFixesSelectAll"; + this.buttonFixesSelectAll.Size = new System.Drawing.Size(75, 23); + this.buttonFixesSelectAll.TabIndex = 102; + this.buttonFixesSelectAll.Text = "Select &all"; + this.buttonFixesSelectAll.UseVisualStyleBackColor = true; + this.buttonFixesSelectAll.Click += new System.EventHandler(this.ButtonFixesSelectAllClick); + // + // buttonFixesInverse + // + this.buttonFixesInverse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonFixesInverse.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonFixesInverse.Location = new System.Drawing.Point(84, 206); + this.buttonFixesInverse.Name = "buttonFixesInverse"; + this.buttonFixesInverse.Size = new System.Drawing.Size(100, 23); + this.buttonFixesInverse.TabIndex = 104; + this.buttonFixesInverse.Text = "&Inverse selection"; + this.buttonFixesInverse.UseVisualStyleBackColor = true; + this.buttonFixesInverse.Click += new System.EventHandler(this.ButtonFixesInverseClick); + // + // subtitleListView1 + // + this.subtitleListView1.AllowColumnReorder = true; + this.subtitleListView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.subtitleListView1.ContextMenuStrip = this.contextMenuStripListview; + this.subtitleListView1.FirstVisibleIndex = -1; + this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.subtitleListView1.FullRowSelect = true; + this.subtitleListView1.GridLines = true; + this.subtitleListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.subtitleListView1.HideSelection = false; + this.subtitleListView1.Location = new System.Drawing.Point(3, 5); + this.subtitleListView1.Name = "subtitleListView1"; + this.subtitleListView1.OwnerDraw = true; + this.subtitleListView1.Size = new System.Drawing.Size(785, 158); + this.subtitleListView1.SubtitleFontBold = false; + this.subtitleListView1.SubtitleFontName = "Tahoma"; + this.subtitleListView1.SubtitleFontSize = 8; + this.subtitleListView1.TabIndex = 110; + this.subtitleListView1.UseCompatibleStateImageBehavior = false; + this.subtitleListView1.UseSyntaxColoring = true; + this.subtitleListView1.View = System.Windows.Forms.View.Details; + this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView1SelectedIndexChanged); + this.subtitleListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.subtitleListView1_KeyDown); + // + // contextMenuStripListview + // + this.contextMenuStripListview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemDelete, + this.toolStripSeparator1, + this.mergeSelectedLinesToolStripMenuItem}); + this.contextMenuStripListview.Name = "contextMenuStripListview"; + this.contextMenuStripListview.Size = new System.Drawing.Size(182, 54); + this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening); + // + // toolStripMenuItemDelete + // + this.toolStripMenuItemDelete.Name = "toolStripMenuItemDelete"; + this.toolStripMenuItemDelete.Size = new System.Drawing.Size(181, 22); + this.toolStripMenuItemDelete.Text = "Delete"; + this.toolStripMenuItemDelete.Click += new System.EventHandler(this.ToolStripMenuItemDeleteClick); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(178, 6); + // + // mergeSelectedLinesToolStripMenuItem + // + this.mergeSelectedLinesToolStripMenuItem.Name = "mergeSelectedLinesToolStripMenuItem"; + this.mergeSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(181, 22); + this.mergeSelectedLinesToolStripMenuItem.Text = "Merge selected lines"; + this.mergeSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.MergeSelectedLinesToolStripMenuItemClick); + // + // groupBoxEditPanel + // + this.groupBoxEditPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxEditPanel.Controls.Add(this.buttonSplitLine); + this.groupBoxEditPanel.Controls.Add(this.labelSingleLine); + this.groupBoxEditPanel.Controls.Add(this.buttonUnBreak); + this.groupBoxEditPanel.Controls.Add(this.buttonAutoBreak); + this.groupBoxEditPanel.Controls.Add(this.labelStartTimeWarning); + this.groupBoxEditPanel.Controls.Add(this.labelDurationWarning); + this.groupBoxEditPanel.Controls.Add(this.timeUpDownStartTime); + this.groupBoxEditPanel.Controls.Add(this.numericUpDownDuration); + this.groupBoxEditPanel.Controls.Add(this.labelDuration); + this.groupBoxEditPanel.Controls.Add(this.labelStartTime); + this.groupBoxEditPanel.Controls.Add(this.labelTextLineTotal); + this.groupBoxEditPanel.Controls.Add(this.labelTextLineLengths); + this.groupBoxEditPanel.Controls.Add(this.textBoxListViewText); + this.groupBoxEditPanel.Location = new System.Drawing.Point(8, 160); + this.groupBoxEditPanel.Name = "groupBoxEditPanel"; + this.groupBoxEditPanel.Size = new System.Drawing.Size(780, 101); + this.groupBoxEditPanel.TabIndex = 111; + this.groupBoxEditPanel.TabStop = false; + // + // buttonSplitLine + // + this.buttonSplitLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSplitLine.ForeColor = System.Drawing.Color.Red; + this.buttonSplitLine.Location = new System.Drawing.Point(627, 62); + this.buttonSplitLine.Name = "buttonSplitLine"; + this.buttonSplitLine.Size = new System.Drawing.Size(96, 23); + this.buttonSplitLine.TabIndex = 124; + this.buttonSplitLine.Text = "Split line"; + this.buttonSplitLine.UseVisualStyleBackColor = true; + this.buttonSplitLine.Click += new System.EventHandler(this.ButtonSplitLineClick); + // + // labelSingleLine + // + this.labelSingleLine.AutoSize = true; + this.labelSingleLine.Location = new System.Drawing.Point(296, 79); + this.labelSingleLine.Name = "labelSingleLine"; + this.labelSingleLine.Size = new System.Drawing.Size(23, 13); + this.labelSingleLine.TabIndex = 123; + this.labelSingleLine.Text = "1/1"; + // + // buttonUnBreak + // + this.buttonUnBreak.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUnBreak.Location = new System.Drawing.Point(627, 37); + this.buttonUnBreak.Name = "buttonUnBreak"; + this.buttonUnBreak.Size = new System.Drawing.Size(96, 23); + this.buttonUnBreak.TabIndex = 122; + this.buttonUnBreak.Text = "&Unbreak"; + this.buttonUnBreak.UseVisualStyleBackColor = true; + this.buttonUnBreak.Click += new System.EventHandler(this.ButtonUnBreakClick); + // + // buttonAutoBreak + // + this.buttonAutoBreak.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAutoBreak.Location = new System.Drawing.Point(627, 12); + this.buttonAutoBreak.Name = "buttonAutoBreak"; + this.buttonAutoBreak.Size = new System.Drawing.Size(96, 23); + this.buttonAutoBreak.TabIndex = 120; + this.buttonAutoBreak.Text = "Auto &br"; + this.buttonAutoBreak.UseVisualStyleBackColor = true; + this.buttonAutoBreak.Click += new System.EventHandler(this.ButtonAutoBreakClick); + // + // labelStartTimeWarning + // + this.labelStartTimeWarning.AutoSize = true; + this.labelStartTimeWarning.ForeColor = System.Drawing.Color.Red; + this.labelStartTimeWarning.Location = new System.Drawing.Point(6, 51); + this.labelStartTimeWarning.Name = "labelStartTimeWarning"; + this.labelStartTimeWarning.Size = new System.Drawing.Size(115, 13); + this.labelStartTimeWarning.TabIndex = 32; + this.labelStartTimeWarning.Text = "labelStartTimeWarning"; + // + // labelDurationWarning + // + this.labelDurationWarning.AutoSize = true; + this.labelDurationWarning.ForeColor = System.Drawing.Color.Red; + this.labelDurationWarning.Location = new System.Drawing.Point(57, 64); + this.labelDurationWarning.Name = "labelDurationWarning"; + this.labelDurationWarning.Size = new System.Drawing.Size(110, 13); + this.labelDurationWarning.TabIndex = 31; + this.labelDurationWarning.Text = "labelDurationWarning"; + // + // timeUpDownStartTime + // + this.timeUpDownStartTime.AutoSize = true; + this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownStartTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + this.timeUpDownStartTime.Location = new System.Drawing.Point(8, 27); + this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownStartTime.Name = "timeUpDownStartTime"; + this.timeUpDownStartTime.Size = new System.Drawing.Size(111, 27); + this.timeUpDownStartTime.TabIndex = 112; + timeCode1.Hours = 0; + timeCode1.Milliseconds = 0; + timeCode1.Minutes = 0; + timeCode1.Seconds = 0; + timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode1.TotalMilliseconds = 0D; + timeCode1.TotalSeconds = 0D; + this.timeUpDownStartTime.TimeCode = timeCode1; + this.timeUpDownStartTime.UseVideoOffset = false; + // + // numericUpDownDuration + // + this.numericUpDownDuration.DecimalPlaces = 3; + this.numericUpDownDuration.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownDuration.Location = new System.Drawing.Point(99, 28); + this.numericUpDownDuration.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.numericUpDownDuration.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.numericUpDownDuration.Name = "numericUpDownDuration"; + this.numericUpDownDuration.Size = new System.Drawing.Size(56, 21); + this.numericUpDownDuration.TabIndex = 114; + this.numericUpDownDuration.ValueChanged += new System.EventHandler(this.NumericUpDownDurationValueChanged); + // + // labelDuration + // + this.labelDuration.AutoSize = true; + this.labelDuration.Location = new System.Drawing.Point(97, 12); + this.labelDuration.Name = "labelDuration"; + this.labelDuration.Size = new System.Drawing.Size(48, 13); + this.labelDuration.TabIndex = 28; + this.labelDuration.Text = "Duration"; + // + // labelStartTime + // + this.labelStartTime.AutoSize = true; + this.labelStartTime.Location = new System.Drawing.Point(6, 12); + this.labelStartTime.Name = "labelStartTime"; + this.labelStartTime.Size = new System.Drawing.Size(54, 13); + this.labelStartTime.TabIndex = 27; + this.labelStartTime.Text = "Start time"; + // + // labelTextLineTotal + // + this.labelTextLineTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelTextLineTotal.Location = new System.Drawing.Point(444, 79); + this.labelTextLineTotal.Name = "labelTextLineTotal"; + this.labelTextLineTotal.Size = new System.Drawing.Size(177, 16); + this.labelTextLineTotal.TabIndex = 26; + this.labelTextLineTotal.Text = "labelTextLineTotal"; + this.labelTextLineTotal.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // labelTextLineLengths + // + this.labelTextLineLengths.AutoSize = true; + this.labelTextLineLengths.Location = new System.Drawing.Point(191, 79); + this.labelTextLineLengths.Name = "labelTextLineLengths"; + this.labelTextLineLengths.Size = new System.Drawing.Size(108, 13); + this.labelTextLineLengths.TabIndex = 25; + this.labelTextLineLengths.Text = "labelTextLineLengths"; + // + // textBoxListViewText + // + this.textBoxListViewText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxListViewText.HideSelection = false; + this.textBoxListViewText.Location = new System.Drawing.Point(194, 12); + this.textBoxListViewText.Multiline = true; + this.textBoxListViewText.Name = "textBoxListViewText"; + this.textBoxListViewText.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBoxListViewText.Size = new System.Drawing.Size(427, 64); + this.textBoxListViewText.TabIndex = 118; + this.textBoxListViewText.TextChanged += new System.EventHandler(this.TextBoxListViewTextTextChanged); + this.textBoxListViewText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxListViewTextKeyDown); + // + // tabPageLog + // + this.tabPageLog.Controls.Add(this.textBoxFixedIssues); + this.tabPageLog.Location = new System.Drawing.Point(4, 22); + this.tabPageLog.Name = "tabPageLog"; + this.tabPageLog.Size = new System.Drawing.Size(802, 505); + this.tabPageLog.TabIndex = 2; + this.tabPageLog.Text = "Log"; + this.tabPageLog.UseVisualStyleBackColor = true; + // + // textBoxFixedIssues + // + this.textBoxFixedIssues.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxFixedIssues.Location = new System.Drawing.Point(3, 3); + this.textBoxFixedIssues.MaxLength = 65767; + this.textBoxFixedIssues.Multiline = true; + this.textBoxFixedIssues.Name = "textBoxFixedIssues"; + this.textBoxFixedIssues.ReadOnly = true; + this.textBoxFixedIssues.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBoxFixedIssues.Size = new System.Drawing.Size(796, 499); + this.textBoxFixedIssues.TabIndex = 5; + this.textBoxFixedIssues.WordWrap = false; + // + // labelNumberOfImportantLogMessages + // + this.labelNumberOfImportantLogMessages.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelNumberOfImportantLogMessages.AutoSize = true; + this.labelNumberOfImportantLogMessages.ForeColor = System.Drawing.Color.Red; + this.labelNumberOfImportantLogMessages.Location = new System.Drawing.Point(12, 593); + this.labelNumberOfImportantLogMessages.Name = "labelNumberOfImportantLogMessages"; + this.labelNumberOfImportantLogMessages.Size = new System.Drawing.Size(190, 13); + this.labelNumberOfImportantLogMessages.TabIndex = 11; + this.labelNumberOfImportantLogMessages.Text = "labelNumberOfImportantLogMessages"; + // + // FixCommonErrors + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(846, 608); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.labelNumberOfImportantLogMessages); + this.Controls.Add(this.buttonBack); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonNextFinish); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBoxStep1); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(840, 580); + this.Name = "FixCommonErrors"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Fix common errors"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FixCommonErrorsFormClosing); + this.Shown += new System.EventHandler(this.FixCommonErrorsShown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormFixKeyDown); + this.Resize += new System.EventHandler(this.FixCommonErrorsResize); + this.groupBoxStep1.ResumeLayout(false); + this.contextMenuStripRules.ResumeLayout(false); + this.groupBox2.ResumeLayout(false); + this.tabControl1.ResumeLayout(false); + this.tabPageFixes.ResumeLayout(false); + this.splitContainerStep2.Panel1.ResumeLayout(false); + this.splitContainerStep2.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainerStep2)).EndInit(); + this.splitContainerStep2.ResumeLayout(false); + this.contextMenuStripFixes.ResumeLayout(false); + this.contextMenuStripListview.ResumeLayout(false); + this.groupBoxEditPanel.ResumeLayout(false); + this.groupBoxEditPanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).EndInit(); + this.tabPageLog.ResumeLayout(false); + this.tabPageLog.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonNextFinish; + private System.Windows.Forms.Label labelStatus; + private System.Windows.Forms.Button buttonBack; + private System.Windows.Forms.GroupBox groupBoxStep1; + private System.Windows.Forms.ListView listView1; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.ColumnHeader columnHeader3; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPageFixes; + private System.Windows.Forms.ListView listViewFixes; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader6; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.ColumnHeader columnHeader8; + private System.Windows.Forms.TabPage tabPageLog; + private System.Windows.Forms.TextBox textBoxFixedIssues; + private System.Windows.Forms.Button buttonInverseSelection; + private System.Windows.Forms.Button buttonSelectAll; + private System.Windows.Forms.GroupBox groupBoxEditPanel; + private SubtitleListView subtitleListView1; + private System.Windows.Forms.Label labelTextLineTotal; + private System.Windows.Forms.Label labelTextLineLengths; + private System.Windows.Forms.TextBox textBoxListViewText; + private System.Windows.Forms.Button buttonFixesApply; + private System.Windows.Forms.Button buttonFixesInverse; + private System.Windows.Forms.Button buttonFixesSelectAll; + private System.Windows.Forms.Label labelStartTimeWarning; + private System.Windows.Forms.Label labelDurationWarning; + private Nikse.SubtitleEdit.Controls.TimeUpDown timeUpDownStartTime; + private System.Windows.Forms.NumericUpDown numericUpDownDuration; + private System.Windows.Forms.Label labelDuration; + private System.Windows.Forms.Label labelStartTime; + private System.Windows.Forms.Button buttonRefreshFixes; + private System.Windows.Forms.Button buttonUnBreak; + private System.Windows.Forms.Button buttonAutoBreak; + private System.Windows.Forms.ContextMenuStrip contextMenuStripListview; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDelete; + private System.Windows.Forms.ToolStripMenuItem mergeSelectedLinesToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.Label labelNumberOfImportantLogMessages; + private System.Windows.Forms.SplitContainer splitContainerStep2; + private System.Windows.Forms.Label labelSingleLine; + private System.Windows.Forms.Button buttonSplitLine; + private System.Windows.Forms.ComboBox comboBoxLanguage; + private System.Windows.Forms.Label labelLanguage; + private System.Windows.Forms.Button buttonResetDefault; + private System.Windows.Forms.ContextMenuStrip contextMenuStripFixes; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; + private System.Windows.Forms.ContextMenuStrip contextMenuStripRules; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAllRules; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseRules; + private System.Windows.Forms.Label labelLanguage2; + private System.Windows.Forms.ToolStripMenuItem selectDefaultToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripMenuItem setCurrentFixesAsDefaultToolStripMenuItem; + } } \ No newline at end of file diff --git a/src/Forms/FixCommonErrors.cs b/src/ui/Forms/FixCommonErrors.cs similarity index 97% rename from src/Forms/FixCommonErrors.cs rename to src/ui/Forms/FixCommonErrors.cs index 02e96fcb1..a2916379c 100644 --- a/src/Forms/FixCommonErrors.cs +++ b/src/ui/Forms/FixCommonErrors.cs @@ -1,1977 +1,1977 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Dictionaries; -using Nikse.SubtitleEdit.Core.Enums; -using Nikse.SubtitleEdit.Core.Forms.FixCommonErrors; -using Nikse.SubtitleEdit.Core.Interfaces; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using Nikse.SubtitleEdit.Logic.Ocr; -using Nikse.SubtitleEdit.Logic.SpellCheck; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class FixCommonErrors : Form, IFixCallbacks - { - private const int IndexRemoveEmptyLines = 0; - private const int IndexOverlappingDisplayTime = 1; - private const int IndexTooShortDisplayTime = 2; - private const int IndexTooLongDisplayTime = 3; - private const int IndexTooShortGap = 4; - private const int IndexInvalidItalicTags = 5; - private const int IndexUnneededSpaces = 6; - private const int IndexMissingSpaces = 7; - private const int IndexUnneededPeriods = 8; - private const int IndexFixCommas = 9; - private const int IndexBreakLongLines = 10; - private const int IndexMergeShortLines = 11; - private const int IndexMergeShortLinesAll = 12; - private const int IndexDoubleApostropheToQuote = 13; - private const int IndexFixMusicNotation = 14; - private const int IndexAddPeriodAfterParagraph = 15; - private const int IndexStartWithUppercaseLetterAfterParagraph = 16; - private const int IndexStartWithUppercaseLetterAfterPeriodInsideParagraph = 17; - private const int IndexStartWithUppercaseLetterAfterColon = 18; - private const int IndexAddMissingQuotes = 19; - private const int IndexFixHyphens = 20; - private const int IndexRemoveHyphensSingleLine = 21; - private const int IndexFix3PlusLines = 22; - private const int IndexFixDoubleDash = 23; - private const int IndexFixDoubleGreaterThan = 24; - private const int IndexFixContinuationStyle = 25; - private const int IndexFixMissingOpenBracket = 26; - private const int IndexFixOcrErrorsViaReplaceList = 27; - private const int IndexUppercaseIInsideLowercaseWord = 28; - private const int IndexRemoveSpaceBetweenNumbers = 29; - private const int IndexDialogsOnOneLine = 30; - private const int IndexNormalizeStrings = 31; - private const int IndexFixEllipsesStart = 32; - private int _indexAloneLowercaseIToUppercaseIEnglish = -1; - private int _turkishAnsiIndex = -1; - private int _danishLetterIIndex = -1; - private int _spanishInvertedQuestionAndExclamationMarksIndex = -1; - - private readonly LanguageStructure.FixCommonErrors _language; - private readonly LanguageStructure.General _languageGeneral; - private bool _hasFixesBeenMade; - - private readonly Keys _goToLine = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditGoToLineNumber); - private readonly Keys _preview = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsFixCommonErrorsPreview); - private readonly Keys _mainGeneralGoToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle); - private readonly Keys _mainGeneralGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle); - private readonly Keys _mainListViewGoToNextError = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewGoToNextError); - - private class FixItem - { - public string Name { get; } - public string Example { get; } - public Action Action { get; } - public bool DefaultChecked { get; } - - public FixItem(string name, string example, Action action, bool selected) - { - Name = name; - Example = example; - Action = action; - DefaultChecked = selected; - } - } - - public class LanguageItem - { - public CultureInfo Code { get; } - public string Name { get; } - - public LanguageItem(CultureInfo code, string name) - { - Code = code; - Name = name; - } - - public override string ToString() - { - return Name; - } - } - - private SubtitleFormat _format; - private int _totalFixes; - private int _totalErrors; - private List _fixActions; - private int _subtitleListViewIndex = -1; - private bool _onlyListFixes = true; - private string _autoDetectGoogleLanguage; - private HashSet _nameList; - private HashSet _abbreviationList; - private readonly StringBuilder _newLog = new StringBuilder(); - private readonly StringBuilder _appliedLog = new StringBuilder(); - private int _numberOfImportantLogMessages; - private HashSet _allowedFixes; - private bool _linesDeletedOrMerged; - private bool _oldFixContinuationStyleTicked; - - public SubtitleFormat Format => _format; - - public Encoding Encoding { get; private set; } - public Subtitle Subtitle { get; private set; } - public Subtitle FixedSubtitle { get; private set; } - - public void AddToTotalErrors(int count) - { - _totalErrors += count; - } - - public void AddToDeleteIndices(int index) - { - } - - private void InitializeLanguageNames(LanguageItem firstItem = null) - { - comboBoxLanguage.BeginUpdate(); - comboBoxLanguage.Items.Clear(); - if (firstItem != null) - { - comboBoxLanguage.Items.Add(firstItem); - } - foreach (var ci in Utilities.GetSubtitleLanguageCultures()) - { - comboBoxLanguage.Items.Add(new LanguageItem(ci, ci.EnglishName)); - } - comboBoxLanguage.Sorted = true; - comboBoxLanguage.EndUpdate(); - } - - public void RunBatchSettings(Subtitle subtitle, SubtitleFormat format, TextEncoding encoding, string language) - { - _autoDetectGoogleLanguage = language; - var ci = CultureInfo.GetCultureInfo(_autoDetectGoogleLanguage); - string threeLetterIsoLanguageName = ci.GetThreeLetterIsoLanguageName(); - - InitializeLanguageNames(new LanguageItem(null, "-Auto-")); - int languageIndex = 0; - int j = 0; - foreach (var x in comboBoxLanguage.Items) - { - if (x is LanguageItem xci) - { - if (xci.Code != null && xci.Code.TwoLetterISOLanguageName == ci.TwoLetterISOLanguageName) - { - languageIndex = j; - break; - } - if (xci.Code != null && xci.Code.TwoLetterISOLanguageName == "en") - { - languageIndex = j; - } - } - j++; - } - if (string.IsNullOrEmpty(language)) - { - languageIndex = 0; - } - - comboBoxLanguage.SelectedIndex = languageIndex; - AddFixActions(threeLetterIsoLanguageName); - FixedSubtitle = new Subtitle(subtitle, false); // copy constructor - Subtitle = new Subtitle(subtitle, false); // copy constructor - _format = format; - Encoding = encoding.Encoding; - _onlyListFixes = false; - InitUserInterface(); - groupBoxStep1.Text = string.Empty; - buttonBack.Visible = false; - buttonNextFinish.Visible = false; - buttonCancel.Text = _languageGeneral.Ok; - } - - public string Language - { - get - { - var ci = comboBoxLanguage.SelectedItem as LanguageItem; - return ci?.Code == null ? string.Empty : ci.Code.TwoLetterISOLanguageName; - } - set - { - for (int index = 0; index < comboBoxLanguage.Items.Count; index++) - { - var item = comboBoxLanguage.Items[index]; - if (item.ToString() == value) - { - comboBoxLanguage.SelectedIndex = index; - } - } - } - } - - public bool BatchMode { get; set; } - - public void RunBatch(Subtitle subtitle, SubtitleFormat format, Encoding encoding, string language) - { - _autoDetectGoogleLanguage = language; - var ci = CultureInfo.GetCultureInfo(_autoDetectGoogleLanguage); - string threeLetterIsoLanguageName = ci.GetThreeLetterIsoLanguageName(); - InitializeLanguageNames(); - int languageIndex = 0; - int j = 0; - foreach (var x in comboBoxLanguage.Items) - { - var xci = (LanguageItem)x; - if (xci.Code.TwoLetterISOLanguageName == ci.TwoLetterISOLanguageName) - { - languageIndex = j; - break; - } - if (xci.Code.TwoLetterISOLanguageName == "en") - { - languageIndex = j; - } - j++; - } - comboBoxLanguage.SelectedIndex = languageIndex; - - AddFixActions(threeLetterIsoLanguageName); - - FixedSubtitle = new Subtitle(subtitle, false); // copy constructor - Subtitle = new Subtitle(subtitle, false); // copy constructor - _format = format; - Encoding = encoding; - _onlyListFixes = true; - _hasFixesBeenMade = true; - _numberOfImportantLogMessages = 0; - _onlyListFixes = false; - _totalFixes = 0; - _totalErrors = 0; - RunSelectedActions(); - FixedSubtitle = Subtitle; - } - - public void Initialize(Subtitle subtitle, SubtitleFormat format, Encoding encoding) - { - _autoDetectGoogleLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(encoding); // Guess language via encoding - if (string.IsNullOrEmpty(_autoDetectGoogleLanguage)) - { - _autoDetectGoogleLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); // Guess language based on subtitle contents - } - - if (_autoDetectGoogleLanguage.Equals("zh", StringComparison.OrdinalIgnoreCase)) - { - _autoDetectGoogleLanguage = "zh-CHS"; // Note that "zh-CHS" (Simplified Chinese) and "zh-CHT" (Traditional Chinese) are neutral cultures - } - - CultureInfo ci = CultureInfo.GetCultureInfo(_autoDetectGoogleLanguage); - string threeLetterIsoLanguageName = ci.GetThreeLetterIsoLanguageName(); - InitializeLanguageNames(); - int languageIndex = 0; - int j = 0; - foreach (var x in comboBoxLanguage.Items) - { - var xci = (LanguageItem)x; - if (xci.Code.TwoLetterISOLanguageName == ci.TwoLetterISOLanguageName) - { - languageIndex = j; - break; - } - if (xci.Code.TwoLetterISOLanguageName == "en") - { - languageIndex = j; - } - j++; - } - comboBoxLanguage.SelectedIndex = languageIndex; - - AddFixActions(threeLetterIsoLanguageName); - - FixedSubtitle = new Subtitle(subtitle, false); // copy constructor - Subtitle = new Subtitle(subtitle, false); // copy constructor - _format = format; - Encoding = encoding; - InitUserInterface(); - } - - private void InitUserInterface() - { - labelStatus.Text = string.Empty; - labelTextLineLengths.Text = string.Empty; - labelTextLineTotal.Text = string.Empty; - groupBoxStep1.BringToFront(); - groupBox2.Visible = false; - groupBoxStep1.Visible = true; - listView1.Columns[0].Width = 50; - listView1.Columns[1].Width = 310; - listView1.Columns[2].Width = 400; - - UiUtil.InitializeSubtitleFont(textBoxListViewText); - UiUtil.InitializeSubtitleFont(subtitleListView1); - listViewFixes.ListViewItemSorter = new ListViewSorter { ColumnNumber = 1, IsNumber = true }; - - if (!string.IsNullOrEmpty(Configuration.Settings.CommonErrors.StartSize)) - { - StartPosition = FormStartPosition.Manual; - var arr = Configuration.Settings.CommonErrors.StartSize.Split(';'); - if (arr.Length == 2 && int.TryParse(arr[0], out var x) && int.TryParse(arr[1], out var y)) - { - if (x > 10 && x < 10000 && y > 10 && y < 10000) - { - Width = x; - Height = y; - } - } - } - if (!string.IsNullOrEmpty(Configuration.Settings.CommonErrors.StartPosition)) - { - StartPosition = FormStartPosition.Manual; - var arr = Configuration.Settings.CommonErrors.StartPosition.Split(';'); - if (arr.Length == 2 && int.TryParse(arr[0], out var x) && int.TryParse(arr[1], out var y)) - { - var screen = Screen.FromPoint(Cursor.Position); - if (x > 0 && x < screen.WorkingArea.Width && y > 0 && y < screen.WorkingArea.Height) - { - Left = x; - Top = y; - } - else - { - StartPosition = FormStartPosition.CenterParent; - } - } - } - - if (Screen.PrimaryScreen.WorkingArea.Width <= 124) - { - Width = MinimumSize.Width; - Height = MinimumSize.Height; - } - if (Configuration.Settings.Tools.FixCommonErrorsSkipStepOne && !BatchMode) - { - Next(); - } - Activate(); - } - - private void AddFixActions(string threeLetterIsoLanguageName) - { - _turkishAnsiIndex = -1; - _danishLetterIIndex = -1; - _spanishInvertedQuestionAndExclamationMarksIndex = -1; - _indexAloneLowercaseIToUppercaseIEnglish = -1; - - var ce = Configuration.Settings.CommonErrors; - - _oldFixContinuationStyleTicked = ce.FixContinuationStyleTicked; - if (LanguageAutoDetect.IsLanguageWithoutPeriods(Language)) - { - ce.FixContinuationStyleTicked = false; - } - - _fixActions = new List - { - new FixItem(_language.RemovedEmptyLinesUnsedLineBreaks, string.Empty, () => new FixEmptyLines().Fix(Subtitle, this), ce.EmptyLinesTicked), - new FixItem(_language.FixOverlappingDisplayTimes, string.Empty, () => new FixOverlappingDisplayTimes().Fix(Subtitle, this), ce.OverlappingDisplayTimeTicked), - new FixItem(_language.FixShortDisplayTimes, string.Empty, () => new FixShortDisplayTimes().Fix(Subtitle, this), ce.TooShortDisplayTimeTicked), - new FixItem(_language.FixLongDisplayTimes, string.Empty, () => new FixLongDisplayTimes().Fix(Subtitle, this), ce.TooLongDisplayTimeTicked), - new FixItem(_language.FixShortGaps, string.Empty, () => new FixShortGaps().Fix(Subtitle, this), ce.TooShortGapTicked), - new FixItem(_language.FixInvalidItalicTags, _language.FixInvalidItalicTagsExample, () => new FixInvalidItalicTags().Fix(Subtitle, this), ce.InvalidItalicTagsTicked), - new FixItem(_language.RemoveUnneededSpaces, _language.RemoveUnneededSpacesExample, () => new FixUnneededSpaces().Fix(Subtitle, this), ce.UnneededSpacesTicked), - new FixItem(_language.FixMissingSpaces, _language.FixMissingSpacesExample, () => new FixMissingSpaces().Fix(Subtitle, this), ce.MissingSpacesTicked), - new FixItem(_language.RemoveUnneededPeriods, _language.RemoveUnneededPeriodsExample, () => new FixUnneededPeriods().Fix(Subtitle, this), ce.UnneededPeriodsTicked), - new FixItem(_language.FixCommas, ",, -> ,", () => new FixCommas().Fix(Subtitle, this), ce.FixCommasTicked), - new FixItem(_language.BreakLongLines, string.Empty, () => new FixLongLines().Fix(Subtitle, this), ce.BreakLongLinesTicked), - new FixItem(_language.RemoveLineBreaks, string.Empty, () => new FixShortLines().Fix(Subtitle, this), ce.MergeShortLinesTicked), - new FixItem(_language.RemoveLineBreaksAll, string.Empty, () => new FixShortLinesAll().Fix(Subtitle, this), ce.MergeShortLinesAllTicked), - new FixItem(_language.FixDoubleApostrophes, string.Empty, () => new FixDoubleApostrophes().Fix(Subtitle, this), ce.DoubleApostropheToQuoteTicked), - new FixItem(_language.FixMusicNotation, _language.FixMusicNotationExample, () => new FixMusicNotation().Fix(Subtitle, this), ce.FixMusicNotationTicked), - new FixItem(_language.AddPeriods, string.Empty, () => new FixMissingPeriodsAtEndOfLine().Fix(Subtitle, this), ce.AddPeriodAfterParagraphTicked), - new FixItem(_language.StartWithUppercaseLetterAfterParagraph, string.Empty, () => new FixStartWithUppercaseLetterAfterParagraph().Fix(Subtitle, this) , ce.StartWithUppercaseLetterAfterParagraphTicked), - new FixItem(_language.StartWithUppercaseLetterAfterPeriodInsideParagraph, string.Empty, () => new FixStartWithUppercaseLetterAfterPeriodInsideParagraph().Fix(Subtitle, this) , ce.StartWithUppercaseLetterAfterPeriodInsideParagraphTicked), - new FixItem(_language.StartWithUppercaseLetterAfterColon, string.Empty, () => new FixStartWithUppercaseLetterAfterColon().Fix(Subtitle, this), ce.StartWithUppercaseLetterAfterColonTicked), - new FixItem(_language.AddMissingQuotes, _language.AddMissingQuotesExample, () => new AddMissingQuotes().Fix(Subtitle, this), ce.AddMissingQuotesTicked), - new FixItem( string.Format(_language.FixHyphensInDialogs, GetDialogStyle(Configuration.Settings.General.DialogStyle)), string.Empty, () => new FixHyphensInDialog().Fix(Subtitle, this), ce.FixHyphensTicked), - new FixItem( _language.RemoveHyphensSingleLine, string.Empty, () => new FixHyphensRemoveDashSingleLine().Fix(Subtitle, this), ce.FixHyphensRemoveSingleLineTicked), - new FixItem(_language.Fix3PlusLines, string.Empty, () => new Fix3PlusLines().Fix(Subtitle, this), ce.Fix3PlusLinesTicked), - new FixItem(_language.FixDoubleDash, _language.FixDoubleDashExample, () => new FixDoubleDash().Fix(Subtitle, this), ce.FixDoubleDashTicked), - new FixItem(_language.FixDoubleGreaterThan, _language.FixDoubleGreaterThanExample, () => new FixDoubleGreaterThan().Fix(Subtitle, this), ce.FixDoubleGreaterThanTicked), - new FixItem( string.Format(_language.FixContinuationStyleX, ContinuationUtilities.GetContinuationStyleName(Configuration.Settings.General.ContinuationStyle)), string.Empty, () => new FixContinuationStyle().Fix(Subtitle, this), ce.FixContinuationStyleTicked), - new FixItem(_language.FixMissingOpenBracket, _language.FixMissingOpenBracketExample, () => new FixMissingOpenBracket().Fix(Subtitle, this), ce.FixMissingOpenBracketTicked), - new FixItem(_language.FixCommonOcrErrors, _language.FixOcrErrorExample, () => FixOcrErrorsViaReplaceList(threeLetterIsoLanguageName), ce.FixOcrErrorsViaReplaceListTicked), - new FixItem(_language.FixUppercaseIInsindeLowercaseWords, _language.FixUppercaseIInsindeLowercaseWordsExample, () => new FixUppercaseIInsideWords().Fix(Subtitle, this), ce.UppercaseIInsideLowercaseWordTicked), - new FixItem(_language.RemoveSpaceBetweenNumber, _language.FixSpaceBetweenNumbersExample, () => new RemoveSpaceBetweenNumbers().Fix(Subtitle, this), ce.RemoveSpaceBetweenNumberTicked), - new FixItem(_language.FixDialogsOnOneLine, _language.FixDialogsOneLineExample, () => new FixDialogsOnOneLine().Fix(Subtitle, this), ce.FixDialogsOnOneLineTicked), - new FixItem(_language.NormalizeStrings, string.Empty, () => new NormalizeStrings().Fix(Subtitle, this), ce.NormalizeStringsTicked), - }; - - if (Configuration.Settings.General.ContinuationStyle == ContinuationStyle.None) - { - _fixActions.Add(new FixItem(_language.FixEllipsesStart, _language.FixEllipsesStartExample, () => new FixEllipsesStart().Fix(Subtitle, this), ce.FixEllipsesStartTicked)); - } - if (Language == "en") - { - _indexAloneLowercaseIToUppercaseIEnglish = _fixActions.Count; - _fixActions.Add(new FixItem(_language.FixLowercaseIToUppercaseI, _language.FixLowercaseIToUppercaseIExample, () => new FixAloneLowercaseIToUppercaseI().Fix(Subtitle, this), ce.AloneLowercaseIToUppercaseIEnglishTicked)); - } - if (Language == "tr") - { - _turkishAnsiIndex = _fixActions.Count; - _fixActions.Add(new FixItem(_language.FixTurkishAnsi, "Ý > İ, Ð > Ğ, Þ > Ş, ý > ı, ð > ğ, þ > ş", () => new FixTurkishAnsiToUnicode().Fix(Subtitle, this), ce.TurkishAnsiTicked)); - } - - if (Language == "da") - { - _danishLetterIIndex = _fixActions.Count; - _fixActions.Add(new FixItem(_language.FixDanishLetterI, "Jeg synes i er søde. -> Jeg synes I er søde.", () => new FixDanishLetterI().Fix(Subtitle, this), ce.DanishLetterITicked)); - } - - if (Language == "es") - { - _spanishInvertedQuestionAndExclamationMarksIndex = _fixActions.Count; - _fixActions.Add(new FixItem(_language.FixSpanishInvertedQuestionAndExclamationMarks, "Hablas bien castellano? -> ¿Hablas bien castellano?", () => new FixSpanishInvertedQuestionAndExclamationMarks().Fix(Subtitle, this), ce.SpanishInvertedQuestionAndExclamationMarksTicked)); - } - - listView1.Items.Clear(); - foreach (var fi in _fixActions) - { - AddFixActionItemToListView(fi); - } - } - - private static string GetDialogStyle(DialogType dialogStyle) - { - if (dialogStyle == DialogType.DashSecondLineWithoutSpace) - { - return Configuration.Settings.Language.Settings.DialogStyleDashSecondLineWithoutSpace; - } - if (dialogStyle == DialogType.DashSecondLineWithSpace) - { - return Configuration.Settings.Language.Settings.DialogStyleDashSecondLineWithSpace; - } - if (dialogStyle == DialogType.DashBothLinesWithoutSpace) - { - return Configuration.Settings.Language.Settings.DialogStyleDashSecondLineWithSpace; - } - return Configuration.Settings.Language.Settings.DialogStyleDashBothLinesWithSpace; - } - - public FixCommonErrors() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - labelStartTimeWarning.Text = string.Empty; - labelDurationWarning.Text = string.Empty; - labelNumberOfImportantLogMessages.Text = string.Empty; - labelLanguage2.Text = string.Empty; - Encoding = Encoding.UTF8; - _language = Configuration.Settings.Language.FixCommonErrors; - _languageGeneral = Configuration.Settings.Language.General; - Text = _language.Title; - groupBoxStep1.Text = _language.Step1; - groupBox2.Text = _language.Step2; - listView1.Columns[0].Text = _languageGeneral.Apply; - listView1.Columns[1].Text = _language.WhatToFix; - listView1.Columns[2].Text = _language.Example; - buttonSelectAll.Text = _language.SelectAll; - buttonInverseSelection.Text = _language.InverseSelection; - tabControl1.TabPages[0].Text = _language.Fixes; - tabControl1.TabPages[1].Text = _language.Log; - listViewFixes.Columns[0].Text = _languageGeneral.Apply; - listViewFixes.Columns[1].Text = _languageGeneral.LineNumber; - listViewFixes.Columns[2].Text = _language.Function; - listViewFixes.Columns[3].Text = _languageGeneral.Before; - listViewFixes.Columns[4].Text = _languageGeneral.After; - buttonNextFinish.Text = _language.Next; - buttonBack.Text = _language.Back; - buttonCancel.Text = _languageGeneral.Cancel; - buttonFixesSelectAll.Text = _language.SelectAll; - buttonFixesInverse.Text = _language.InverseSelection; - buttonRefreshFixes.Text = _language.RefreshFixes; - buttonFixesApply.Text = _language.ApplyFixes; - labelStartTime.Text = _languageGeneral.StartTime; - labelDuration.Text = _languageGeneral.Duration; - buttonAutoBreak.Text = _language.AutoBreak; - buttonUnBreak.Text = _language.Unbreak; - buttonSplitLine.Text = _languageGeneral.SplitLine; - subtitleListView1.InitializeLanguage(_languageGeneral, Configuration.Settings); - labelLanguage.Text = Configuration.Settings.Language.ChooseLanguage.Language; - toolStripMenuItemDelete.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.Delete; - mergeSelectedLinesToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.MergeSelectedLines; - buttonResetDefault.Text = _language.SelectDefault; - - toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; - toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; - selectDefaultToolStripMenuItem.Text = _language.SelectDefault; - setCurrentFixesAsDefaultToolStripMenuItem.Text = _language.SetDefault; - - toolStripMenuItemInverseRules.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; - toolStripMenuItemSelectAllRules.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; - - splitContainerStep2.Panel1MinSize = 110; - splitContainerStep2.Panel2MinSize = 160; - - numericUpDownDuration.Left = timeUpDownStartTime.Left + timeUpDownStartTime.Width; - labelDuration.Left = timeUpDownStartTime.Left + timeUpDownStartTime.Width - 3; - FixLargeFonts(); - listView1.Select(); - } - - private void FixLargeFonts() - { - using (var graphics = CreateGraphics()) - { - var textSize = graphics.MeasureString(buttonCancel.Text, Font); - if (textSize.Height > buttonCancel.Height - 4) - { - subtitleListView1.InitializeTimestampColumnWidths(this); - var newButtonHeight = (int)(textSize.Height + 7 + 0.5); - UiUtil.SetButtonHeight(this, newButtonHeight, 1); - } - } - } - - private void AddFixActionItemToListView(FixItem fi) - { - var item = new ListViewItem(string.Empty) { Tag = fi, Checked = fi.DefaultChecked }; - item.SubItems.Add(fi.Name); - item.SubItems.Add(fi.Example); - listView1.Items.Add(item); - } - - public void AddFixToListView(Paragraph p, string action, string before, string after) - { - AddFixToListView(p, action, before, after, true); - } - - public void AddFixToListView(Paragraph p, string action, string before, string after, bool isChecked) - { - if (_onlyListFixes) - { - var item = new ListViewItem(string.Empty) { Checked = isChecked, Tag = p }; - item.SubItems.Add(p.Number.ToString(CultureInfo.InvariantCulture)); - item.SubItems.Add(action); - item.SubItems.Add(UiUtil.GetListViewTextFromString(before)); - item.SubItems.Add(UiUtil.GetListViewTextFromString(after)); - listViewFixes.Items.Add(item); - } - } - - public bool AllowFix(Paragraph p, string action) - { - if (_onlyListFixes || BatchMode) - { - return true; - } - - return _allowedFixes.Contains(p.Number.ToString(CultureInfo.InvariantCulture) + "|" + action); - } - - public void ShowStatus(string message) - { - message = message.Replace(Environment.NewLine, " "); - if (message.Length > 103) - { - message = message.Substring(0, 100) + "..."; - } - - labelStatus.Text = message; - labelStatus.Refresh(); - } - - public void LogStatus(string sender, string message, bool isImportant) - { - if (isImportant) - { - _numberOfImportantLogMessages++; - } - - LogStatus(sender, message); - } - - public void LogStatus(string sender, string message) - { - if (!string.IsNullOrEmpty(message)) - { - message += Environment.NewLine; - if (_onlyListFixes) - { - _newLog.AppendLine(" + " + sender + ": " + message); - } - else - { - _appliedLog.AppendLine(string.Format(_language.FixedOkXY, sender, message)); - } - } - } - - public bool IsName(string candidate) - { - MakeSureNameListIsLoaded(); - return _nameList.Contains(candidate); // O(1) - } - - private void MakeSureNameListIsLoaded() - { - if (_nameList == null) - { - string languageTwoLetterCode = LanguageAutoDetect.AutoDetectGoogleLanguage(Subtitle); - // Will contains both one word names and multi names - var namesList = new NameList(Configuration.DictionariesDirectory, languageTwoLetterCode, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); - _nameList = namesList.GetNames(); - // Multi word names. - foreach (var name in namesList.GetMultiNames()) - { - _nameList.Add(name); - } - } - } - - public HashSet GetAbbreviations() - { - if (_abbreviationList != null) - { - return _abbreviationList; - } - - MakeSureNameListIsLoaded(); - _abbreviationList = new HashSet(); - foreach (string name in _nameList) - { - if (name.EndsWith('.')) - { - _abbreviationList.Add(name); - } - } - return _abbreviationList; - } - - private OcrFixEngine _ocrFixEngine; - private string _ocrFixEngineLanguage; - - public void FixOcrErrorsViaReplaceList(string threeLetterIsoLanguageName) - { - if (_ocrFixEngine == null || _ocrFixEngineLanguage != threeLetterIsoLanguageName) - { - _ocrFixEngine?.Dispose(); - _ocrFixEngineLanguage = threeLetterIsoLanguageName; - _ocrFixEngine = new OcrFixEngine(_ocrFixEngineLanguage, null, this); - } - - string fixAction = _language.FixCommonOcrErrors; - int noOfFixes = 0; - string lastLine = string.Empty; - for (int i = 0; i < Subtitle.Paragraphs.Count; i++) - { - var p = Subtitle.Paragraphs[i]; - string text = _ocrFixEngine.FixOcrErrors(p.Text, i, lastLine, false, OcrFixEngine.AutoGuessLevel.Cautious); - lastLine = text; - if (AllowFix(p, fixAction) && p.Text != text) - { - string oldText = p.Text; - p.Text = text; - noOfFixes++; - AddFixToListView(p, fixAction, oldText, p.Text); - } - Application.DoEvents(); - } - if (noOfFixes > 0) - { - _totalFixes += noOfFixes; - LogStatus(_language.FixCommonOcrErrors, string.Format(_language.CommonOcrErrorsFixed, noOfFixes)); - } - } - - public void UpdateFixStatus(int fixes, string message, string xMessage) - { - if (fixes > 0) - { - _totalFixes += fixes; - LogStatus(message, string.Format(xMessage, fixes)); - } - } - - private void ButtonFixClick(object sender, EventArgs e) - { - if (buttonBack.Enabled) - { - Cursor = Cursors.WaitCursor; - SaveConfiguration(); - Cursor = Cursors.Default; - DialogResult = DialogResult.OK; - } - else - { - Cursor = Cursors.WaitCursor; - Next(); - ShowAvailableFixesStatus(false); - } - Cursor = Cursors.Default; - } - - private void Next() - { - RunSelectedActions(); - - buttonBack.Enabled = true; - buttonNextFinish.Text = _languageGeneral.Ok; - buttonNextFinish.Enabled = _hasFixesBeenMade || _linesDeletedOrMerged; - groupBoxStep1.Visible = false; - groupBox2.Visible = true; - listViewFixes.Sort(); - subtitleListView1.Fill(FixedSubtitle); - if (listViewFixes.Items.Count > 0) - { - listViewFixes.Items[0].Selected = true; - } - else - { - subtitleListView1.SelectIndexAndEnsureVisible(0); - } - } - - private void RunSelectedActions() - { - subtitleListView1.BeginUpdate(); - _newLog.Clear(); - - Subtitle = new Subtitle(FixedSubtitle, false); - if (listView1.Items[IndexFixOcrErrorsViaReplaceList].Checked) - { - var fixItem = (FixItem)listView1.Items[IndexFixOcrErrorsViaReplaceList].Tag; - fixItem.Action.Invoke(); - } - foreach (ListViewItem item in listView1.Items) - { - if (item.Checked && item.Index != IndexRemoveEmptyLines) - { - var fixItem = (FixItem)item.Tag; - fixItem.Action.Invoke(); - } - } - if (listView1.Items[IndexInvalidItalicTags].Checked) - { - var fixItem = (FixItem)listView1.Items[IndexInvalidItalicTags].Tag; - fixItem.Action.Invoke(); - } - if (listView1.Items[IndexRemoveEmptyLines].Checked) - { - var fixItem = (FixItem)listView1.Items[IndexRemoveEmptyLines].Tag; - fixItem.Action.Invoke(); - } - - // build log - textBoxFixedIssues.Text = string.Empty; - if (_newLog.Length >= 0) - { - textBoxFixedIssues.AppendText(_newLog + Environment.NewLine); - } - - textBoxFixedIssues.AppendText(_appliedLog.ToString()); - subtitleListView1.EndUpdate(); - } - - private void FormFixKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#fixcommonerrors"); - } - else if (e.KeyCode == Keys.Enter && buttonNextFinish.Text == _language.Next) - { - ButtonFixClick(null, null); - } - else if (subtitleListView1.Visible && subtitleListView1.Items.Count > 0 && e.KeyData == _goToLine) - { - GoToLineNumber(); - } - else if (e.KeyData == _preview && listViewFixes.Items.Count > 0) - { - GenerateDiff(); - } - else if (_mainGeneralGoToNextSubtitle == e.KeyData || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)) - { - int selectedIndex = 0; - if (subtitleListView1.SelectedItems.Count > 0) - { - selectedIndex = subtitleListView1.SelectedItems[0].Index; - selectedIndex++; - } - subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex); - } - else if (_mainGeneralGoToPrevSubtitle == e.KeyData || (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt)) - { - int selectedIndex = 0; - if (subtitleListView1.SelectedItems.Count > 0) - { - selectedIndex = subtitleListView1.SelectedItems[0].Index; - selectedIndex--; - } - subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex); - } - else if (_mainListViewGoToNextError == e.KeyData) - { - GoToNextSyntaxError(); - e.SuppressKeyPress = true; - } - } - - private void GoToNextSyntaxError() - { - int idx = 0; - try - { - if (listViewFixes.SelectedItems.Count > 0) - { - idx = listViewFixes.SelectedItems[0].Index; - } - - idx++; - if (listViewFixes.Items.Count > idx) - { - listViewFixes.Items[idx].Selected = true; - listViewFixes.Items[idx].EnsureVisible(); - if (idx > 0) - { - listViewFixes.Items[idx - 1].Selected = false; - } - } - } - catch - { - // ignored - } - } - - private void GoToLineNumber() - { - using (var goToLine = new GoToLine()) - { - goToLine.Initialize(1, subtitleListView1.Items.Count); - if (goToLine.ShowDialog(this) == DialogResult.OK) - { - subtitleListView1.SelectNone(); - subtitleListView1.Items[goToLine.LineNumber - 1].Selected = true; - subtitleListView1.Items[goToLine.LineNumber - 1].EnsureVisible(); - subtitleListView1.Items[goToLine.LineNumber - 1].Focused = true; - } - } - } - - private void GenerateDiff() - { - string htmlFileName = FileUtil.GetTempFileName(".html"); - var sb = new StringBuilder(); - sb.Append("Subtitle Edit - Fix common errors preview"); - sb.AppendLine($""); - foreach (ListViewItem item in listViewFixes.Items) - { - if (item.Checked) - { - var p = (Paragraph)item.Tag; - string what = item.SubItems[2].Text; - string before = item.SubItems[3].Text; - string after = item.SubItems[4].Text; - var arr = MakeDiffHtml(before, after); - sb.AppendLine($""); - } - } - sb.Append("
{_languageGeneral.LineNumber}{_language.Function}{_languageGeneral.Before}{_languageGeneral.After}
{p.Number}{what}
{arr[0]}
{arr[1]}
"); - File.WriteAllText(htmlFileName, sb.ToString()); - UiUtil.OpenFile(htmlFileName); - } - - private static string[] MakeDiffHtml(string before, string after) - { - before = before.Replace("
", "↲"); - after = after.Replace("
", "↲"); - before = before.Replace(Environment.NewLine, "↲"); - after = after.Replace(Environment.NewLine, "↲"); - - var beforeColors = new Dictionary(); - var beforeBackgroundColors = new Dictionary(); - var afterColors = new Dictionary(); - var afterBackgroundColors = new Dictionary(); - - // from start - int minLength = Math.Min(before.Length, after.Length); - int startCharactersOk = 0; - for (int i = 0; i < minLength; i++) - { - if (before[i] == after[i]) - { - startCharactersOk++; - } - else - { - if (before.Length > i + 4 && after.Length > i + 4 && - before[i + 1] == after[i + 1] && - before[i + 2] == after[i + 2] && - before[i + 3] == after[i + 3] && - before[i + 4] == after[i + 4]) - { - startCharactersOk++; - - if (char.IsWhiteSpace(before[i])) - { - beforeBackgroundColors.Add(i, Color.Red); - } - else - { - beforeColors.Add(i, Color.Red); - } - - if (char.IsWhiteSpace(after[i])) - { - afterBackgroundColors.Add(i, Color.Red); - } - else - { - afterColors.Add(i, Color.Red); - } - } - else - { - break; - } - } - } - - int maxLength = Math.Max(before.Length, after.Length); - for (int i = startCharactersOk; i <= maxLength; i++) - { - if (i < before.Length) - { - if (char.IsWhiteSpace(before[i])) - { - beforeBackgroundColors.Add(i, Color.Red); - } - else - { - beforeColors.Add(i, Color.Red); - } - } - if (i < after.Length) - { - if (char.IsWhiteSpace(after[i])) - { - afterBackgroundColors.Add(i, Color.Red); - } - else - { - afterColors.Add(i, Color.Red); - } - } - } - - // from end - for (int i = 1; i < minLength; i++) - { - int bLength = before.Length - i; - int aLength = after.Length - i; - if (before[bLength] == after[aLength]) - { - if (beforeColors.ContainsKey(bLength)) - { - beforeColors.Remove(bLength); - } - - if (beforeBackgroundColors.ContainsKey(bLength)) - { - beforeBackgroundColors.Remove(bLength); - } - - if (afterColors.ContainsKey(aLength)) - { - afterColors.Remove(aLength); - } - - if (afterBackgroundColors.ContainsKey(aLength)) - { - afterBackgroundColors.Remove(aLength); - } - } - else - { - break; - } - } - - var sb = new StringBuilder(); - for (int i = 0; i < before.Length; i++) - { - var s = before[i]; - if (beforeColors.ContainsKey(i) && beforeBackgroundColors.ContainsKey(i)) - { - sb.AppendFormat("{2}", ColorTranslator.ToHtml(beforeColors[i]), ColorTranslator.ToHtml(beforeBackgroundColors[i]), s); - } - else if (beforeColors.ContainsKey(i)) - { - sb.AppendFormat("{1}", ColorTranslator.ToHtml(beforeColors[i]), s); - } - else if (beforeBackgroundColors.ContainsKey(i)) - { - sb.AppendFormat("{1}", ColorTranslator.ToHtml(beforeBackgroundColors[i]), s); - } - else - { - sb.Append(s); - } - } - var sb2 = new StringBuilder(); - for (int i = 0; i < after.Length; i++) - { - var s = after[i]; - if (afterColors.ContainsKey(i) && afterBackgroundColors.ContainsKey(i)) - { - sb2.AppendFormat("{2}", ColorTranslator.ToHtml(afterColors[i]), ColorTranslator.ToHtml(afterBackgroundColors[i]), s); - } - else if (afterColors.ContainsKey(i)) - { - sb2.AppendFormat("{1}", ColorTranslator.ToHtml(afterColors[i]), s); - } - else if (afterBackgroundColors.ContainsKey(i)) - { - sb2.AppendFormat("{1}", ColorTranslator.ToHtml(afterBackgroundColors[i]), s); - } - else - { - sb2.Append(s); - } - } - - return new[] { sb.ToString(), sb2.ToString() }; - } - - private void SaveConfiguration() - { - var ce = Configuration.Settings.CommonErrors; - - ce.EmptyLinesTicked = listView1.Items[IndexRemoveEmptyLines].Checked; - ce.OverlappingDisplayTimeTicked = listView1.Items[IndexOverlappingDisplayTime].Checked; - ce.TooShortDisplayTimeTicked = listView1.Items[IndexTooShortDisplayTime].Checked; - ce.TooLongDisplayTimeTicked = listView1.Items[IndexTooLongDisplayTime].Checked; - ce.TooShortGapTicked = listView1.Items[IndexTooShortGap].Checked; - ce.InvalidItalicTagsTicked = listView1.Items[IndexInvalidItalicTags].Checked; - ce.UnneededSpacesTicked = listView1.Items[IndexUnneededSpaces].Checked; - ce.UnneededPeriodsTicked = listView1.Items[IndexUnneededPeriods].Checked; - ce.FixCommasTicked = listView1.Items[IndexFixCommas].Checked; - ce.MissingSpacesTicked = listView1.Items[IndexMissingSpaces].Checked; - ce.BreakLongLinesTicked = listView1.Items[IndexBreakLongLines].Checked; - ce.MergeShortLinesTicked = listView1.Items[IndexMergeShortLines].Checked; - ce.MergeShortLinesAllTicked = listView1.Items[IndexMergeShortLinesAll].Checked; - - ce.UppercaseIInsideLowercaseWordTicked = listView1.Items[IndexUppercaseIInsideLowercaseWord].Checked; - ce.DoubleApostropheToQuoteTicked = listView1.Items[IndexDoubleApostropheToQuote].Checked; - ce.FixMusicNotationTicked = listView1.Items[IndexFixMusicNotation].Checked; - ce.AddPeriodAfterParagraphTicked = listView1.Items[IndexAddPeriodAfterParagraph].Checked; - ce.StartWithUppercaseLetterAfterParagraphTicked = listView1.Items[IndexStartWithUppercaseLetterAfterParagraph].Checked; - ce.StartWithUppercaseLetterAfterPeriodInsideParagraphTicked = listView1.Items[IndexStartWithUppercaseLetterAfterPeriodInsideParagraph].Checked; - ce.StartWithUppercaseLetterAfterColonTicked = listView1.Items[IndexStartWithUppercaseLetterAfterColon].Checked; - ce.AddMissingQuotesTicked = listView1.Items[IndexAddMissingQuotes].Checked; - ce.FixHyphensTicked = listView1.Items[IndexFixHyphens].Checked; - ce.FixHyphensRemoveSingleLineTicked = listView1.Items[IndexRemoveHyphensSingleLine].Checked; - ce.Fix3PlusLinesTicked = listView1.Items[IndexFix3PlusLines].Checked; - ce.FixDoubleDashTicked = listView1.Items[IndexFixDoubleDash].Checked; - ce.FixDoubleGreaterThanTicked = listView1.Items[IndexFixDoubleGreaterThan].Checked; - ce.FixContinuationStyleTicked = listView1.Items[IndexFixContinuationStyle].Checked; - if (LanguageAutoDetect.IsLanguageWithoutPeriods(Language)) - { - ce.FixContinuationStyleTicked = _oldFixContinuationStyleTicked; - } - - if (Configuration.Settings.General.ContinuationStyle == ContinuationStyle.None) - { - ce.FixEllipsesStartTicked = listView1.Items[IndexFixEllipsesStart].Checked; - } - - ce.FixMissingOpenBracketTicked = listView1.Items[IndexFixMissingOpenBracket].Checked; - if (_indexAloneLowercaseIToUppercaseIEnglish >= 0) - { - ce.AloneLowercaseIToUppercaseIEnglishTicked = listView1.Items[_indexAloneLowercaseIToUppercaseIEnglish].Checked; - } - - ce.FixOcrErrorsViaReplaceListTicked = listView1.Items[IndexFixOcrErrorsViaReplaceList].Checked; - ce.RemoveSpaceBetweenNumberTicked = listView1.Items[IndexRemoveSpaceBetweenNumbers].Checked; - ce.FixDialogsOnOneLineTicked = listView1.Items[IndexDialogsOnOneLine].Checked; - ce.NormalizeStringsTicked = listView1.Items[IndexNormalizeStrings].Checked; - if (_danishLetterIIndex >= 0) - { - ce.DanishLetterITicked = listView1.Items[_danishLetterIIndex].Checked; - } - - if (_turkishAnsiIndex >= 0) - { - ce.TurkishAnsiTicked = listView1.Items[_turkishAnsiIndex].Checked; - } - - if (_spanishInvertedQuestionAndExclamationMarksIndex >= 0) - { - ce.SpanishInvertedQuestionAndExclamationMarksTicked = listView1.Items[_spanishInvertedQuestionAndExclamationMarksIndex].Checked; - } - - Configuration.Settings.Save(); - } - - private void ButtonBackClick(object sender, EventArgs e) - { - buttonNextFinish.Enabled = true; - _totalFixes = 0; - _onlyListFixes = true; - buttonBack.Enabled = false; - buttonNextFinish.Text = _language.Next; - groupBox2.Visible = false; - groupBoxStep1.Visible = true; - ShowStatus(string.Empty); - listViewFixes.Items.Clear(); - } - - private void ButtonCancelClick(object sender, EventArgs e) - { - SaveConfiguration(); - } - - private void ListViewFixesColumnClick(object sender, ColumnClickEventArgs e) - { - var sorter = (ListViewSorter)listViewFixes.ListViewItemSorter; - - if (e.Column == sorter.ColumnNumber) - { - sorter.Descending = !sorter.Descending; // inverse sort direction - } - else - { - sorter.ColumnNumber = e.Column; - sorter.Descending = false; - sorter.IsNumber = e.Column == 1; // only index 1 is numeric - } - listViewFixes.Sort(); - } - - private void ButtonSelectAllClick(object sender, EventArgs e) - { - foreach (ListViewItem item in listView1.Items) - { - item.Checked = true; - } - } - - private void ButtonInverseSelectionClick(object sender, EventArgs e) - { - foreach (ListViewItem item in listView1.Items) - { - item.Checked = !item.Checked; - } - } - - private void ListViewFixesSelectedIndexChanged(object sender, EventArgs e) - { - if (listViewFixes.SelectedItems.Count > 0) - { - var p = (Paragraph)listViewFixes.SelectedItems[0].Tag; - - foreach (ListViewItem lvi in subtitleListView1.Items) - { - if (lvi.Tag is Paragraph p2 && p.Id == p2.Id) - { - var index = lvi.Index; - if (index - 1 > 0) - { - subtitleListView1.EnsureVisible(index - 1); - } - - if (index + 1 < subtitleListView1.Items.Count) - { - subtitleListView1.EnsureVisible(index + 1); - } - - subtitleListView1.SelectedIndexChanged -= SubtitleListView1SelectedIndexChanged; - subtitleListView1.SelectNone(); - subtitleListView1.SelectedIndexChanged += SubtitleListView1SelectedIndexChanged; - subtitleListView1.Items[index].Selected = true; - subtitleListView1.EnsureVisible(index); - return; - } - } - } - } - - private void SubtitleListView1SelectedIndexChanged(object sender, EventArgs e) - { - if (FixedSubtitle.Paragraphs.Count > 0) - { - int firstSelectedIndex = 0; - if (subtitleListView1.SelectedItems.Count > 0) - { - firstSelectedIndex = subtitleListView1.SelectedItems[0].Index; - } - - Paragraph p = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex); - if (p != null) - { - InitializeListViewEditBox(p); - _subtitleListViewIndex = firstSelectedIndex; - UpdateOverlapErrors(); - UpdateListViewTextInfo(p.Text); - } - } - } - - private void TextBoxListViewTextTextChanged(object sender, EventArgs e) - { - if (_subtitleListViewIndex >= 0) - { - string text = textBoxListViewText.Text.TrimEnd(); - UpdateListViewTextInfo(text); - - // update _subtitle + listview - FixedSubtitle.Paragraphs[_subtitleListViewIndex].Text = text; - subtitleListView1.SetText(_subtitleListViewIndex, text); - - EnableOkButton(); - UpdateListSyntaxColoring(); - } - } - - private void EnableOkButton() - { - if (!_hasFixesBeenMade) - { - _hasFixesBeenMade = true; - buttonNextFinish.Enabled = true; - } - } - - private void InitializeListViewEditBox(Paragraph p) - { - textBoxListViewText.TextChanged -= TextBoxListViewTextTextChanged; - textBoxListViewText.Text = p.Text; - textBoxListViewText.TextChanged += TextBoxListViewTextTextChanged; - - timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBox_TextChanged; - timeUpDownStartTime.TimeCode = p.StartTime; - timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBox_TextChanged; - - numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged; - numericUpDownDuration.Value = (decimal)(p.Duration.TotalMilliseconds / TimeCode.BaseUnit); - numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged; - } - - private void NumericUpDownDurationValueChanged(object sender, EventArgs e) - { - if (FixedSubtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0) - { - int firstSelectedIndex = subtitleListView1.SelectedItems[0].Index; - - Paragraph currentParagraph = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex); - if (currentParagraph != null) - { - UpdateOverlapErrors(); - - // update _subtitle + listview - currentParagraph.EndTime.TotalMilliseconds = currentParagraph.StartTime.TotalMilliseconds + ((double)numericUpDownDuration.Value * TimeCode.BaseUnit); - subtitleListView1.SetDuration(firstSelectedIndex, currentParagraph, FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex + 1)); - } - } - } - - private void UpdateOverlapErrors() - { - labelStartTimeWarning.Text = string.Empty; - labelDurationWarning.Text = string.Empty; - - TimeCode startTime = timeUpDownStartTime.TimeCode; - if (FixedSubtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0 && startTime != null) - { - int firstSelectedIndex = subtitleListView1.SelectedItems[0].Index; - - Paragraph prevParagraph = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex - 1); - if (prevParagraph != null && prevParagraph.EndTime.TotalMilliseconds > startTime.TotalMilliseconds) - { - labelStartTimeWarning.Text = string.Format(_languageGeneral.OverlapPreviousLineX, (prevParagraph.EndTime.TotalMilliseconds - startTime.TotalMilliseconds) / TimeCode.BaseUnit); - } - - Paragraph nextParagraph = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex + 1); - if (nextParagraph != null) - { - double durationMilliseconds = (double)numericUpDownDuration.Value * TimeCode.BaseUnit; - if (startTime.TotalMilliseconds + durationMilliseconds > nextParagraph.StartTime.TotalMilliseconds) - { - labelDurationWarning.Text = string.Format(_languageGeneral.OverlapNextX, ((startTime.TotalMilliseconds + durationMilliseconds) - nextParagraph.StartTime.TotalMilliseconds) / TimeCode.BaseUnit); - } - - if (labelStartTimeWarning.Text.Length == 0 && - startTime.TotalMilliseconds > nextParagraph.StartTime.TotalMilliseconds) - { - double di = (startTime.TotalMilliseconds - nextParagraph.StartTime.TotalMilliseconds) / TimeCode.BaseUnit; - labelStartTimeWarning.Text = string.Format(_languageGeneral.OverlapNextX, di); - } - else if (numericUpDownDuration.Value < 0) - { - labelDurationWarning.Text = _languageGeneral.Negative; - } - } - } - UpdateListSyntaxColoring(); - } - - private void UpdateListSyntaxColoring() - { - if (FixedSubtitle == null || FixedSubtitle.Paragraphs.Count == 0 || _subtitleListViewIndex < 0 || _subtitleListViewIndex >= Subtitle.Paragraphs.Count) - { - return; - } - - subtitleListView1.SyntaxColorLine(FixedSubtitle.Paragraphs, _subtitleListViewIndex, FixedSubtitle.Paragraphs[_subtitleListViewIndex]); - Paragraph next = FixedSubtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1); - if (next != null) - { - subtitleListView1.SyntaxColorLine(FixedSubtitle.Paragraphs, _subtitleListViewIndex + 1, FixedSubtitle.Paragraphs[_subtitleListViewIndex + 1]); - } - } - - private void MaskedTextBox_TextChanged(object sender, EventArgs e) - { - if (_subtitleListViewIndex >= 0 && - timeUpDownStartTime.TimeCode != null && - FixedSubtitle.Paragraphs.Count > 0 && - subtitleListView1.SelectedItems.Count > 0) - { - TimeCode startTime = timeUpDownStartTime.TimeCode; - labelStartTimeWarning.Text = string.Empty; - labelDurationWarning.Text = string.Empty; - - UpdateOverlapErrors(); - - // update _subtitle + listview - FixedSubtitle.Paragraphs[_subtitleListViewIndex].EndTime.TotalMilliseconds += - (startTime.TotalMilliseconds - FixedSubtitle.Paragraphs[_subtitleListViewIndex].StartTime.TotalMilliseconds); - FixedSubtitle.Paragraphs[_subtitleListViewIndex].StartTime = startTime; - subtitleListView1.SetStartTimeAndDuration(_subtitleListViewIndex, FixedSubtitle.Paragraphs[_subtitleListViewIndex], FixedSubtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1), FixedSubtitle.GetParagraphOrDefault(_subtitleListViewIndex - 1)); - } - } - - private void UpdateListViewTextInfo(string text) - { - labelTextLineLengths.Text = _languageGeneral.SingleLineLengths; - labelSingleLine.Left = labelTextLineLengths.Left + labelTextLineLengths.Width - 6; - text = HtmlUtil.RemoveHtmlTags(text, true); - text = NetflixImsc11Japanese.RemoveTags(text); - UiUtil.GetLineLengths(labelSingleLine, text); - - var s = text.Replace(Environment.NewLine, " "); - labelTextLineTotal.ForeColor = Color.Black; - buttonSplitLine.Visible = false; - var abl = Utilities.AutoBreakLine(s, _autoDetectGoogleLanguage).SplitToLines(); - if (abl.Count > Configuration.Settings.General.MaxNumberOfLines || abl.Any(li => li.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength)) - { - buttonSplitLine.Visible = true; - labelTextLineTotal.ForeColor = Color.Red; - } - labelTextLineTotal.Text = string.Format(_languageGeneral.TotalLengthX, text.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics)); - } - - private void ButtonFixesSelectAllClick(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = true; - } - } - - private void ButtonFixesInverseClick(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = !item.Checked; - } - } - - private void ButtonFixesApplyClick(object sender, EventArgs e) - { - buttonFixesApply.Enabled = false; - _hasFixesBeenMade = true; - Cursor = Cursors.WaitCursor; - ShowStatus(_language.Analysing); - - _subtitleListViewIndex = -1; - int firstSelectedIndex = 0; - if (subtitleListView1.SelectedItems.Count > 0) - { - firstSelectedIndex = subtitleListView1.SelectedItems[0].Index; - } - - _allowedFixes = new HashSet(); - foreach (ListViewItem item in listViewFixes.Items) - { - if (item.Checked) - { - string key = item.SubItems[1].Text + "|" + item.SubItems[2].Text; - if (!_allowedFixes.Contains(key)) - { - _allowedFixes.Add(key); - } - } - } - - _numberOfImportantLogMessages = 0; - _onlyListFixes = false; - _totalFixes = 0; - _totalErrors = 0; - RunSelectedActions(); - FixedSubtitle = new Subtitle(Subtitle, false); - subtitleListView1.Fill(FixedSubtitle); - ShowAvailableFixesStatus(true); - RefreshFixes(); - if (listViewFixes.Items.Count == 0) - { - subtitleListView1.SelectIndexAndEnsureVisible(firstSelectedIndex); - } - - Cursor = Cursors.Default; - if (_numberOfImportantLogMessages == 0) - { - labelNumberOfImportantLogMessages.Text = string.Empty; - } - else - { - labelNumberOfImportantLogMessages.Text = string.Format(_language.NumberOfImportantLogMessages, _numberOfImportantLogMessages); - } - - buttonFixesApply.Enabled = true; - } - - private void ButtonRefreshFixesClick(object sender, EventArgs e) - { - Cursor = Cursors.WaitCursor; - ShowStatus(_language.Analysing); - _totalFixes = 0; - RefreshFixes(); - ShowAvailableFixesStatus(false); - Cursor = Cursors.Default; - } - - private void ShowAvailableFixesStatus(bool applied) - { - labelStatus.ForeColor = DefaultForeColor; - if (_totalFixes == 0 && _totalErrors == 0) - { - ShowStatus(_language.NothingToFix); - if (subtitleListView1.SelectedItems.Count == 0) - { - subtitleListView1.SelectIndexAndEnsureVisible(0); - } - } - else if (_totalFixes > 0) - { - if (_totalErrors > 0) - { - labelStatus.ForeColor = Color.Red; - ShowStatus(string.Format(applied ? _language.XFixedBut : _language.XCouldBeFixedBut, _totalFixes)); - } - else - { - ShowStatus(string.Format(applied ? _language.XFixesApplied : _language.FixesFoundX, _totalFixes)); - } - } - else if (_totalErrors > 0) - { - labelStatus.ForeColor = Color.Red; - ShowStatus(_language.NothingFixableBut); - } - - TopMost = true; - BringToFront(); - TopMost = false; - } - - private void RefreshFixes() - { - listViewFixes.BeginUpdate(); - - // save de-selected fixes - var deSelectedFixes = new List(); - foreach (ListViewItem item in listViewFixes.Items) - { - if (!item.Checked) - { - deSelectedFixes.Add(item.SubItems[1].Text + item.SubItems[2].Text + item.SubItems[3].Text); - } - } - - listViewFixes.Items.Clear(); - _onlyListFixes = true; - Next(); - - // restore de-selected fixes - foreach (ListViewItem item in listViewFixes.Items) - { - if (deSelectedFixes.Contains(item.SubItems[1].Text + item.SubItems[2].Text + item.SubItems[3].Text)) - { - item.Checked = false; - } - } - - listViewFixes.EndUpdate(); - } - - private void ButtonAutoBreakClick(object sender, EventArgs e) - { - if (textBoxListViewText.Text.Length > 0) - { - string oldText = textBoxListViewText.Text; - textBoxListViewText.Text = Utilities.AutoBreakLine(textBoxListViewText.Text, Language); - if (oldText != textBoxListViewText.Text) - { - EnableOkButton(); - } - } - } - - private void ButtonUnBreakClick(object sender, EventArgs e) - { - string oldText = textBoxListViewText.Text; - textBoxListViewText.Text = Utilities.UnbreakLine(textBoxListViewText.Text); - if (oldText != textBoxListViewText.Text) - { - EnableOkButton(); - } - } - - private void ToolStripMenuItemDeleteClick(object sender, EventArgs e) - { - if (FixedSubtitle.Paragraphs.Count <= 0 || subtitleListView1.SelectedItems.Count <= 0) - { - return; - } - - var askText = subtitleListView1.SelectedItems.Count > 1 ? string.Format(Configuration.Settings.Language.Main.DeleteXLinesPrompt, subtitleListView1.SelectedItems.Count) : Configuration.Settings.Language.Main.DeleteOneLinePrompt; - if (Configuration.Settings.General.PromptDeleteLines && MessageBox.Show(askText, Configuration.Settings.Language.General.Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return; - } - - _linesDeletedOrMerged = true; - _subtitleListViewIndex = -1; - var indexes = new List(); - foreach (ListViewItem item in subtitleListView1.SelectedItems) - { - indexes.Add(item.Index); - } - - int firstIndex = subtitleListView1.SelectedItems[0].Index; - - // save de-selected fixes - var deSelectedFixes = new List(); - foreach (ListViewItem item in listViewFixes.Items) - { - if (!item.Checked) - { - int number = Convert.ToInt32(item.SubItems[1].Text); - if (number > firstIndex) - { - number -= subtitleListView1.SelectedItems.Count; - } - - if (number >= 0) - { - deSelectedFixes.Add(number + item.SubItems[2].Text + item.SubItems[3].Text); - } - } - } - - FixedSubtitle.RemoveParagraphsByIndices(indexes); - FixedSubtitle.Renumber(); - subtitleListView1.Fill(FixedSubtitle); - - // refresh fixes - listViewFixes.Items.Clear(); - _onlyListFixes = true; - Next(); - - // restore de-selected fixes - if (deSelectedFixes.Count > 0) - { - foreach (ListViewItem item in listViewFixes.Items) - { - if (deSelectedFixes.Contains(item.SubItems[1].Text + item.SubItems[2].Text + item.SubItems[3].Text)) - { - item.Checked = false; - } - } - } - - if (subtitleListView1.Items.Count > firstIndex) - { - subtitleListView1.SelectIndexAndEnsureVisible(firstIndex, true); - } - else if (subtitleListView1.Items.Count > 0) - { - subtitleListView1.SelectIndexAndEnsureVisible(subtitleListView1.Items.Count - 1, true); - } - } - - private void MergeSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) - { - if (FixedSubtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0) - { - _linesDeletedOrMerged = true; - int startNumber = FixedSubtitle.Paragraphs[0].Number; - int firstSelectedIndex = subtitleListView1.SelectedItems[0].Index; - - // save de-selected fixes - var deSelectedFixes = new List(); - foreach (ListViewItem item in listViewFixes.Items) - { - if (!item.Checked) - { - int firstSelectedNumber = subtitleListView1.GetSelectedParagraph(FixedSubtitle).Number; - int number = Convert.ToInt32(item.SubItems[1].Text); - if (number > firstSelectedNumber) - { - number--; - } - - deSelectedFixes.Add(number + item.SubItems[2].Text + item.SubItems[3].Text); - } - } - - var currentParagraph = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex); - var nextParagraph = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex + 1); - - if (nextParagraph != null && currentParagraph != null) - { - subtitleListView1.SelectedIndexChanged -= SubtitleListView1SelectedIndexChanged; - - currentParagraph.Text = currentParagraph.Text.Replace(Environment.NewLine, " "); - currentParagraph.Text += Environment.NewLine + nextParagraph.Text.Replace(Environment.NewLine, " "); - currentParagraph.EndTime = nextParagraph.EndTime; - - FixedSubtitle.Paragraphs.Remove(nextParagraph); - - FixedSubtitle.Renumber(startNumber); - subtitleListView1.Fill(FixedSubtitle); - subtitleListView1.SelectIndexAndEnsureVisible(firstSelectedIndex); - subtitleListView1.SelectedIndexChanged += SubtitleListView1SelectedIndexChanged; - _subtitleListViewIndex = -1; - SubtitleListView1SelectedIndexChanged(null, null); - } - - // refresh fixes - listViewFixes.Items.Clear(); - _onlyListFixes = true; - Next(); - - // restore de-selected fixes - foreach (ListViewItem item in listViewFixes.Items) - { - if (deSelectedFixes.Contains(item.SubItems[1].Text + item.SubItems[2].Text + item.SubItems[3].Text)) - { - item.Checked = false; - } - } - } - } - - private void ContextMenuStripListviewOpening(object sender, System.ComponentModel.CancelEventArgs e) - { - if (subtitleListView1.SelectedItems.Count == 0) - { - e.Cancel = true; - } - else if (subtitleListView1.SelectedItems.Count == 2 && - subtitleListView1.SelectedItems[0].Index == subtitleListView1.SelectedItems[1].Index - 1) - { - mergeSelectedLinesToolStripMenuItem.Visible = true; - toolStripSeparator1.Visible = true; - } - else - { - mergeSelectedLinesToolStripMenuItem.Visible = false; - toolStripSeparator1.Visible = false; - } - } - - private void FixCommonErrorsResize(object sender, EventArgs e) - { - groupBox2.Width = Width - (groupBox2.Left * 2 + 15); - groupBoxStep1.Width = Width - (groupBoxStep1.Left * 2 + 15); - buttonCancel.Left = Width - (buttonCancel.Width + 26); - buttonNextFinish.Left = buttonCancel.Left - (buttonNextFinish.Width + 6); - buttonBack.Left = buttonNextFinish.Left - (buttonBack.Width + 6); - tabControl1.Width = groupBox2.Width - (tabControl1.Left * 2); - listView1.Width = groupBoxStep1.Width - (listView1.Left * 2); - - ListViewFixesAutoSizeAllColumns(); - subtitleListView1.AutoSizeAllColumns(this); - } - - public void ListViewFixesAutoSizeAllColumns() - { - using (var graphics = CreateGraphics()) - { - var timestampSizeF = graphics.MeasureString(listViewFixes.Columns[0].Text, Font); // Apply - var width = (int)(timestampSizeF.Width + 12); - listViewFixes.Columns[0].Width = width; - - timestampSizeF = graphics.MeasureString(listViewFixes.Columns[1].Text, Font); // line# - width = (int)(timestampSizeF.Width + 12); - listViewFixes.Columns[1].Width = width; - - timestampSizeF = graphics.MeasureString("Auto break all lines and even more stuff", Font); // Function - width = (int)(timestampSizeF.Width + 12); - listViewFixes.Columns[2].Width = width; - - int length = listViewFixes.Columns[0].Width + listViewFixes.Columns[1].Width + listViewFixes.Columns[2].Width; - int lengthAvailable = Width - length; - width = (lengthAvailable - 10) / 2; - listViewFixes.Columns[3].Width = width; // before - listViewFixes.Columns[4].Width = width; // after - } - } - - private void FixCommonErrorsShown(object sender, EventArgs e) - { - FixCommonErrorsResize(null, null); - } - - private void SplitSelectedParagraph(double? splitSeconds) - { - if (FixedSubtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0) - { - subtitleListView1.SelectedIndexChanged -= SubtitleListView1SelectedIndexChanged; - int firstSelectedIndex = subtitleListView1.SelectedItems[0].Index; - - // save de-selected fixes - var deSelectedFixes = new List(); - foreach (ListViewItem item in listViewFixes.Items) - { - if (!item.Checked) - { - int number = Convert.ToInt32(item.SubItems[1].Text); - if (number > firstSelectedIndex) - { - number++; - } - - deSelectedFixes.Add(number + item.SubItems[2].Text + item.SubItems[3].Text); - } - } - - Paragraph currentParagraph = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex); - var newParagraph = new Paragraph(); - - string oldText = currentParagraph.Text; - var lines = currentParagraph.Text.SplitToLines(); - if (lines.Count == 2 && (lines[0].EndsWith('.') || lines[0].EndsWith('!') || lines[0].EndsWith('?'))) - { - currentParagraph.Text = Utilities.AutoBreakLine(lines[0], Language); - newParagraph.Text = Utilities.AutoBreakLine(lines[1], Language); - } - else - { - string s = Utilities.AutoBreakLine(currentParagraph.Text, 5, Configuration.Settings.General.MergeLinesShorterThan, Language); - lines = s.SplitToLines(); - if (lines.Count == 2) - { - currentParagraph.Text = Utilities.AutoBreakLine(lines[0], Language); - newParagraph.Text = Utilities.AutoBreakLine(lines[1], Language); - } - else if (lines.Count > 2) - { - var half = lines.Count / 2; - var sb1 = new StringBuilder(); - for (int i = 0; i < half; i++) - { - sb1.AppendLine(lines[i]); - } - - currentParagraph.Text = Utilities.AutoBreakLine(sb1.ToString(), _autoDetectGoogleLanguage); - sb1 = new StringBuilder(); - for (int i = half; i < lines.Count; i++) - { - sb1.AppendLine(lines[i]); - } - - newParagraph.Text = Utilities.AutoBreakLine(sb1.ToString(), _autoDetectGoogleLanguage); - } - } - - double startFactor = (double)HtmlUtil.RemoveHtmlTags(currentParagraph.Text).Length / HtmlUtil.RemoveHtmlTags(oldText).Length; - if (startFactor < 0.20) - { - startFactor = 0.20; - } - - if (startFactor > 0.80) - { - startFactor = 0.80; - } - - double middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.Duration.TotalMilliseconds * startFactor); - if (splitSeconds.HasValue && splitSeconds.Value > (currentParagraph.StartTime.TotalSeconds + 0.2) && splitSeconds.Value < (currentParagraph.EndTime.TotalSeconds - 0.2)) - { - middle = splitSeconds.Value * TimeCode.BaseUnit; - } - - newParagraph.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; - currentParagraph.EndTime.TotalMilliseconds = middle; - newParagraph.StartTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds + 1; - - FixedSubtitle.Paragraphs.Insert(firstSelectedIndex + 1, newParagraph); - FixedSubtitle.Renumber(); - subtitleListView1.Fill(FixedSubtitle); - textBoxListViewText.Text = currentParagraph.Text; - - subtitleListView1.SelectIndexAndEnsureVisible(firstSelectedIndex); - subtitleListView1.SelectedIndexChanged += SubtitleListView1SelectedIndexChanged; - - // restore de-selected fixes - listViewFixes.Items.Clear(); - _onlyListFixes = true; - Next(); - foreach (ListViewItem item in listViewFixes.Items) - { - if (deSelectedFixes.Contains(item.SubItems[1].Text + item.SubItems[2].Text + item.SubItems[3].Text)) - { - item.Checked = false; - } - } - } - } - - private void ButtonSplitLineClick(object sender, EventArgs e) - { - SplitSelectedParagraph(null); - } - - private void TextBoxListViewTextKeyDown(object sender, KeyEventArgs e) - { - UiUtil.CheckAutoWrap(textBoxListViewText, e, Utilities.GetNumberOfLines(textBoxListViewText.Text)); - } - - private void FixCommonErrorsFormClosing(object sender, FormClosingEventArgs e) - { - if (_ocrFixEngine != null) - { - _ocrFixEngine.Dispose(); - _ocrFixEngine = null; - } - Owner = null; - } - - private void comboBoxLanguage_SelectedIndexChanged(object sender, EventArgs e) - { - if (Subtitle != null) - { - if (comboBoxLanguage.SelectedItem is LanguageItem ci) - { - _autoDetectGoogleLanguage = ci.Code.TwoLetterISOLanguageName; - AddFixActions(ci.Code.GetThreeLetterIsoLanguageName()); - } - } - labelLanguage2.Text = comboBoxLanguage.Text; - } - - private void comboBoxLanguage_Enter(object sender, EventArgs e) - { - SaveConfiguration(); - } - - private void buttonResetDefault_Click(object sender, EventArgs e) - { - Configuration.Settings.CommonErrors.LoadUserDefaultFixes(Configuration.Settings.CommonErrors.DefaultFixes); - AddFixActions(CultureInfo.GetCultureInfo(_autoDetectGoogleLanguage).GetThreeLetterIsoLanguageName()); - } - - private void subtitleListView1_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) - { - subtitleListView1.SelectAll(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.D && e.Modifiers == Keys.Control) - { - subtitleListView1.SelectFirstSelectedItemOnly(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.I && e.Modifiers == (Keys.Control | Keys.Shift)) //InverseSelection - { - subtitleListView1.InverseSelection(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.Delete) - { - ToolStripMenuItemDeleteClick(null, null); - } - } - - private Hunspell _hunspell; - - public bool DoSpell(string word) - { - if (_hunspell == null && Language != null) - { - var fileMatches = Directory.GetFiles(Utilities.DictionaryFolder, Language + "*.dic"); - if (fileMatches.Length > 0) - { - var dictionary = fileMatches[0].Substring(0, fileMatches[0].Length - 4); - try - { - _hunspell = Hunspell.GetHunspell(dictionary); - } - catch - { - _hunspell = null; - } - } - } - - if (_hunspell == null) - { - return false; - } - - return _hunspell.Spell(word); - } - - private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = true; - } - } - - private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = !item.Checked; - } - } - - private void setCurrentFixesAsDefaultToolStripMenuItem_Click(object sender, EventArgs e) - { - SaveConfiguration(); - Configuration.Settings.CommonErrors.SaveUserDefaultFixes(); - AddFixActions(CultureInfo.GetCultureInfo(_autoDetectGoogleLanguage).GetThreeLetterIsoLanguageName()); - } - - private void selectDefaultToolStripMenuItem_Click(object sender, EventArgs e) - { - buttonResetDefault_Click(null, null); - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Dictionaries; +using Nikse.SubtitleEdit.Core.Enums; +using Nikse.SubtitleEdit.Core.Forms.FixCommonErrors; +using Nikse.SubtitleEdit.Core.Interfaces; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using Nikse.SubtitleEdit.Logic.Ocr; +using Nikse.SubtitleEdit.Logic.SpellCheck; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class FixCommonErrors : Form, IFixCallbacks + { + private const int IndexRemoveEmptyLines = 0; + private const int IndexOverlappingDisplayTime = 1; + private const int IndexTooShortDisplayTime = 2; + private const int IndexTooLongDisplayTime = 3; + private const int IndexTooShortGap = 4; + private const int IndexInvalidItalicTags = 5; + private const int IndexUnneededSpaces = 6; + private const int IndexMissingSpaces = 7; + private const int IndexUnneededPeriods = 8; + private const int IndexFixCommas = 9; + private const int IndexBreakLongLines = 10; + private const int IndexMergeShortLines = 11; + private const int IndexMergeShortLinesAll = 12; + private const int IndexDoubleApostropheToQuote = 13; + private const int IndexFixMusicNotation = 14; + private const int IndexAddPeriodAfterParagraph = 15; + private const int IndexStartWithUppercaseLetterAfterParagraph = 16; + private const int IndexStartWithUppercaseLetterAfterPeriodInsideParagraph = 17; + private const int IndexStartWithUppercaseLetterAfterColon = 18; + private const int IndexAddMissingQuotes = 19; + private const int IndexFixHyphens = 20; + private const int IndexRemoveHyphensSingleLine = 21; + private const int IndexFix3PlusLines = 22; + private const int IndexFixDoubleDash = 23; + private const int IndexFixDoubleGreaterThan = 24; + private const int IndexFixContinuationStyle = 25; + private const int IndexFixMissingOpenBracket = 26; + private const int IndexFixOcrErrorsViaReplaceList = 27; + private const int IndexUppercaseIInsideLowercaseWord = 28; + private const int IndexRemoveSpaceBetweenNumbers = 29; + private const int IndexDialogsOnOneLine = 30; + private const int IndexNormalizeStrings = 31; + private const int IndexFixEllipsesStart = 32; + private int _indexAloneLowercaseIToUppercaseIEnglish = -1; + private int _turkishAnsiIndex = -1; + private int _danishLetterIIndex = -1; + private int _spanishInvertedQuestionAndExclamationMarksIndex = -1; + + private readonly LanguageStructure.FixCommonErrors _language; + private readonly LanguageStructure.General _languageGeneral; + private bool _hasFixesBeenMade; + + private readonly Keys _goToLine = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditGoToLineNumber); + private readonly Keys _preview = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsFixCommonErrorsPreview); + private readonly Keys _mainGeneralGoToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle); + private readonly Keys _mainGeneralGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle); + private readonly Keys _mainListViewGoToNextError = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewGoToNextError); + + private class FixItem + { + public string Name { get; } + public string Example { get; } + public Action Action { get; } + public bool DefaultChecked { get; } + + public FixItem(string name, string example, Action action, bool selected) + { + Name = name; + Example = example; + Action = action; + DefaultChecked = selected; + } + } + + public class LanguageItem + { + public CultureInfo Code { get; } + public string Name { get; } + + public LanguageItem(CultureInfo code, string name) + { + Code = code; + Name = name; + } + + public override string ToString() + { + return Name; + } + } + + private SubtitleFormat _format; + private int _totalFixes; + private int _totalErrors; + private List _fixActions; + private int _subtitleListViewIndex = -1; + private bool _onlyListFixes = true; + private string _autoDetectGoogleLanguage; + private HashSet _nameList; + private HashSet _abbreviationList; + private readonly StringBuilder _newLog = new StringBuilder(); + private readonly StringBuilder _appliedLog = new StringBuilder(); + private int _numberOfImportantLogMessages; + private HashSet _allowedFixes; + private bool _linesDeletedOrMerged; + private bool _oldFixContinuationStyleTicked; + + public SubtitleFormat Format => _format; + + public Encoding Encoding { get; private set; } + public Subtitle Subtitle { get; private set; } + public Subtitle FixedSubtitle { get; private set; } + + public void AddToTotalErrors(int count) + { + _totalErrors += count; + } + + public void AddToDeleteIndices(int index) + { + } + + private void InitializeLanguageNames(LanguageItem firstItem = null) + { + comboBoxLanguage.BeginUpdate(); + comboBoxLanguage.Items.Clear(); + if (firstItem != null) + { + comboBoxLanguage.Items.Add(firstItem); + } + foreach (var ci in Utilities.GetSubtitleLanguageCultures()) + { + comboBoxLanguage.Items.Add(new LanguageItem(ci, ci.EnglishName)); + } + comboBoxLanguage.Sorted = true; + comboBoxLanguage.EndUpdate(); + } + + public void RunBatchSettings(Subtitle subtitle, SubtitleFormat format, TextEncoding encoding, string language) + { + _autoDetectGoogleLanguage = language; + var ci = CultureInfo.GetCultureInfo(_autoDetectGoogleLanguage); + string threeLetterIsoLanguageName = ci.GetThreeLetterIsoLanguageName(); + + InitializeLanguageNames(new LanguageItem(null, "-Auto-")); + int languageIndex = 0; + int j = 0; + foreach (var x in comboBoxLanguage.Items) + { + if (x is LanguageItem xci) + { + if (xci.Code != null && xci.Code.TwoLetterISOLanguageName == ci.TwoLetterISOLanguageName) + { + languageIndex = j; + break; + } + if (xci.Code != null && xci.Code.TwoLetterISOLanguageName == "en") + { + languageIndex = j; + } + } + j++; + } + if (string.IsNullOrEmpty(language)) + { + languageIndex = 0; + } + + comboBoxLanguage.SelectedIndex = languageIndex; + AddFixActions(threeLetterIsoLanguageName); + FixedSubtitle = new Subtitle(subtitle, false); // copy constructor + Subtitle = new Subtitle(subtitle, false); // copy constructor + _format = format; + Encoding = encoding.Encoding; + _onlyListFixes = false; + InitUserInterface(); + groupBoxStep1.Text = string.Empty; + buttonBack.Visible = false; + buttonNextFinish.Visible = false; + buttonCancel.Text = _languageGeneral.Ok; + } + + public string Language + { + get + { + var ci = comboBoxLanguage.SelectedItem as LanguageItem; + return ci?.Code == null ? string.Empty : ci.Code.TwoLetterISOLanguageName; + } + set + { + for (int index = 0; index < comboBoxLanguage.Items.Count; index++) + { + var item = comboBoxLanguage.Items[index]; + if (item.ToString() == value) + { + comboBoxLanguage.SelectedIndex = index; + } + } + } + } + + public bool BatchMode { get; set; } + + public void RunBatch(Subtitle subtitle, SubtitleFormat format, Encoding encoding, string language) + { + _autoDetectGoogleLanguage = language; + var ci = CultureInfo.GetCultureInfo(_autoDetectGoogleLanguage); + string threeLetterIsoLanguageName = ci.GetThreeLetterIsoLanguageName(); + InitializeLanguageNames(); + int languageIndex = 0; + int j = 0; + foreach (var x in comboBoxLanguage.Items) + { + var xci = (LanguageItem)x; + if (xci.Code.TwoLetterISOLanguageName == ci.TwoLetterISOLanguageName) + { + languageIndex = j; + break; + } + if (xci.Code.TwoLetterISOLanguageName == "en") + { + languageIndex = j; + } + j++; + } + comboBoxLanguage.SelectedIndex = languageIndex; + + AddFixActions(threeLetterIsoLanguageName); + + FixedSubtitle = new Subtitle(subtitle, false); // copy constructor + Subtitle = new Subtitle(subtitle, false); // copy constructor + _format = format; + Encoding = encoding; + _onlyListFixes = true; + _hasFixesBeenMade = true; + _numberOfImportantLogMessages = 0; + _onlyListFixes = false; + _totalFixes = 0; + _totalErrors = 0; + RunSelectedActions(); + FixedSubtitle = Subtitle; + } + + public void Initialize(Subtitle subtitle, SubtitleFormat format, Encoding encoding) + { + _autoDetectGoogleLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(encoding); // Guess language via encoding + if (string.IsNullOrEmpty(_autoDetectGoogleLanguage)) + { + _autoDetectGoogleLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); // Guess language based on subtitle contents + } + + if (_autoDetectGoogleLanguage.Equals("zh", StringComparison.OrdinalIgnoreCase)) + { + _autoDetectGoogleLanguage = "zh-CHS"; // Note that "zh-CHS" (Simplified Chinese) and "zh-CHT" (Traditional Chinese) are neutral cultures + } + + CultureInfo ci = CultureInfo.GetCultureInfo(_autoDetectGoogleLanguage); + string threeLetterIsoLanguageName = ci.GetThreeLetterIsoLanguageName(); + InitializeLanguageNames(); + int languageIndex = 0; + int j = 0; + foreach (var x in comboBoxLanguage.Items) + { + var xci = (LanguageItem)x; + if (xci.Code.TwoLetterISOLanguageName == ci.TwoLetterISOLanguageName) + { + languageIndex = j; + break; + } + if (xci.Code.TwoLetterISOLanguageName == "en") + { + languageIndex = j; + } + j++; + } + comboBoxLanguage.SelectedIndex = languageIndex; + + AddFixActions(threeLetterIsoLanguageName); + + FixedSubtitle = new Subtitle(subtitle, false); // copy constructor + Subtitle = new Subtitle(subtitle, false); // copy constructor + _format = format; + Encoding = encoding; + InitUserInterface(); + } + + private void InitUserInterface() + { + labelStatus.Text = string.Empty; + labelTextLineLengths.Text = string.Empty; + labelTextLineTotal.Text = string.Empty; + groupBoxStep1.BringToFront(); + groupBox2.Visible = false; + groupBoxStep1.Visible = true; + listView1.Columns[0].Width = 50; + listView1.Columns[1].Width = 310; + listView1.Columns[2].Width = 400; + + UiUtil.InitializeSubtitleFont(textBoxListViewText); + UiUtil.InitializeSubtitleFont(subtitleListView1); + listViewFixes.ListViewItemSorter = new ListViewSorter { ColumnNumber = 1, IsNumber = true }; + + if (!string.IsNullOrEmpty(Configuration.Settings.CommonErrors.StartSize)) + { + StartPosition = FormStartPosition.Manual; + var arr = Configuration.Settings.CommonErrors.StartSize.Split(';'); + if (arr.Length == 2 && int.TryParse(arr[0], out var x) && int.TryParse(arr[1], out var y)) + { + if (x > 10 && x < 10000 && y > 10 && y < 10000) + { + Width = x; + Height = y; + } + } + } + if (!string.IsNullOrEmpty(Configuration.Settings.CommonErrors.StartPosition)) + { + StartPosition = FormStartPosition.Manual; + var arr = Configuration.Settings.CommonErrors.StartPosition.Split(';'); + if (arr.Length == 2 && int.TryParse(arr[0], out var x) && int.TryParse(arr[1], out var y)) + { + var screen = Screen.FromPoint(Cursor.Position); + if (x > 0 && x < screen.WorkingArea.Width && y > 0 && y < screen.WorkingArea.Height) + { + Left = x; + Top = y; + } + else + { + StartPosition = FormStartPosition.CenterParent; + } + } + } + + if (Screen.PrimaryScreen.WorkingArea.Width <= 124) + { + Width = MinimumSize.Width; + Height = MinimumSize.Height; + } + if (Configuration.Settings.Tools.FixCommonErrorsSkipStepOne && !BatchMode) + { + Next(); + } + Activate(); + } + + private void AddFixActions(string threeLetterIsoLanguageName) + { + _turkishAnsiIndex = -1; + _danishLetterIIndex = -1; + _spanishInvertedQuestionAndExclamationMarksIndex = -1; + _indexAloneLowercaseIToUppercaseIEnglish = -1; + + var ce = Configuration.Settings.CommonErrors; + + _oldFixContinuationStyleTicked = ce.FixContinuationStyleTicked; + if (LanguageAutoDetect.IsLanguageWithoutPeriods(Language)) + { + ce.FixContinuationStyleTicked = false; + } + + _fixActions = new List + { + new FixItem(_language.RemovedEmptyLinesUnsedLineBreaks, string.Empty, () => new FixEmptyLines().Fix(Subtitle, this), ce.EmptyLinesTicked), + new FixItem(_language.FixOverlappingDisplayTimes, string.Empty, () => new FixOverlappingDisplayTimes().Fix(Subtitle, this), ce.OverlappingDisplayTimeTicked), + new FixItem(_language.FixShortDisplayTimes, string.Empty, () => new FixShortDisplayTimes().Fix(Subtitle, this), ce.TooShortDisplayTimeTicked), + new FixItem(_language.FixLongDisplayTimes, string.Empty, () => new FixLongDisplayTimes().Fix(Subtitle, this), ce.TooLongDisplayTimeTicked), + new FixItem(_language.FixShortGaps, string.Empty, () => new FixShortGaps().Fix(Subtitle, this), ce.TooShortGapTicked), + new FixItem(_language.FixInvalidItalicTags, _language.FixInvalidItalicTagsExample, () => new FixInvalidItalicTags().Fix(Subtitle, this), ce.InvalidItalicTagsTicked), + new FixItem(_language.RemoveUnneededSpaces, _language.RemoveUnneededSpacesExample, () => new FixUnneededSpaces().Fix(Subtitle, this), ce.UnneededSpacesTicked), + new FixItem(_language.FixMissingSpaces, _language.FixMissingSpacesExample, () => new FixMissingSpaces().Fix(Subtitle, this), ce.MissingSpacesTicked), + new FixItem(_language.RemoveUnneededPeriods, _language.RemoveUnneededPeriodsExample, () => new FixUnneededPeriods().Fix(Subtitle, this), ce.UnneededPeriodsTicked), + new FixItem(_language.FixCommas, ",, -> ,", () => new FixCommas().Fix(Subtitle, this), ce.FixCommasTicked), + new FixItem(_language.BreakLongLines, string.Empty, () => new FixLongLines().Fix(Subtitle, this), ce.BreakLongLinesTicked), + new FixItem(_language.RemoveLineBreaks, string.Empty, () => new FixShortLines().Fix(Subtitle, this), ce.MergeShortLinesTicked), + new FixItem(_language.RemoveLineBreaksAll, string.Empty, () => new FixShortLinesAll().Fix(Subtitle, this), ce.MergeShortLinesAllTicked), + new FixItem(_language.FixDoubleApostrophes, string.Empty, () => new FixDoubleApostrophes().Fix(Subtitle, this), ce.DoubleApostropheToQuoteTicked), + new FixItem(_language.FixMusicNotation, _language.FixMusicNotationExample, () => new FixMusicNotation().Fix(Subtitle, this), ce.FixMusicNotationTicked), + new FixItem(_language.AddPeriods, string.Empty, () => new FixMissingPeriodsAtEndOfLine().Fix(Subtitle, this), ce.AddPeriodAfterParagraphTicked), + new FixItem(_language.StartWithUppercaseLetterAfterParagraph, string.Empty, () => new FixStartWithUppercaseLetterAfterParagraph().Fix(Subtitle, this) , ce.StartWithUppercaseLetterAfterParagraphTicked), + new FixItem(_language.StartWithUppercaseLetterAfterPeriodInsideParagraph, string.Empty, () => new FixStartWithUppercaseLetterAfterPeriodInsideParagraph().Fix(Subtitle, this) , ce.StartWithUppercaseLetterAfterPeriodInsideParagraphTicked), + new FixItem(_language.StartWithUppercaseLetterAfterColon, string.Empty, () => new FixStartWithUppercaseLetterAfterColon().Fix(Subtitle, this), ce.StartWithUppercaseLetterAfterColonTicked), + new FixItem(_language.AddMissingQuotes, _language.AddMissingQuotesExample, () => new AddMissingQuotes().Fix(Subtitle, this), ce.AddMissingQuotesTicked), + new FixItem( string.Format(_language.FixHyphensInDialogs, GetDialogStyle(Configuration.Settings.General.DialogStyle)), string.Empty, () => new FixHyphensInDialog().Fix(Subtitle, this), ce.FixHyphensTicked), + new FixItem( _language.RemoveHyphensSingleLine, string.Empty, () => new FixHyphensRemoveDashSingleLine().Fix(Subtitle, this), ce.FixHyphensRemoveSingleLineTicked), + new FixItem(_language.Fix3PlusLines, string.Empty, () => new Fix3PlusLines().Fix(Subtitle, this), ce.Fix3PlusLinesTicked), + new FixItem(_language.FixDoubleDash, _language.FixDoubleDashExample, () => new FixDoubleDash().Fix(Subtitle, this), ce.FixDoubleDashTicked), + new FixItem(_language.FixDoubleGreaterThan, _language.FixDoubleGreaterThanExample, () => new FixDoubleGreaterThan().Fix(Subtitle, this), ce.FixDoubleGreaterThanTicked), + new FixItem( string.Format(_language.FixContinuationStyleX, ContinuationUtilities.GetContinuationStyleName(Configuration.Settings.General.ContinuationStyle)), string.Empty, () => new FixContinuationStyle().Fix(Subtitle, this), ce.FixContinuationStyleTicked), + new FixItem(_language.FixMissingOpenBracket, _language.FixMissingOpenBracketExample, () => new FixMissingOpenBracket().Fix(Subtitle, this), ce.FixMissingOpenBracketTicked), + new FixItem(_language.FixCommonOcrErrors, _language.FixOcrErrorExample, () => FixOcrErrorsViaReplaceList(threeLetterIsoLanguageName), ce.FixOcrErrorsViaReplaceListTicked), + new FixItem(_language.FixUppercaseIInsindeLowercaseWords, _language.FixUppercaseIInsindeLowercaseWordsExample, () => new FixUppercaseIInsideWords().Fix(Subtitle, this), ce.UppercaseIInsideLowercaseWordTicked), + new FixItem(_language.RemoveSpaceBetweenNumber, _language.FixSpaceBetweenNumbersExample, () => new RemoveSpaceBetweenNumbers().Fix(Subtitle, this), ce.RemoveSpaceBetweenNumberTicked), + new FixItem(_language.FixDialogsOnOneLine, _language.FixDialogsOneLineExample, () => new FixDialogsOnOneLine().Fix(Subtitle, this), ce.FixDialogsOnOneLineTicked), + new FixItem(_language.NormalizeStrings, string.Empty, () => new NormalizeStrings().Fix(Subtitle, this), ce.NormalizeStringsTicked), + }; + + if (Configuration.Settings.General.ContinuationStyle == ContinuationStyle.None) + { + _fixActions.Add(new FixItem(_language.FixEllipsesStart, _language.FixEllipsesStartExample, () => new FixEllipsesStart().Fix(Subtitle, this), ce.FixEllipsesStartTicked)); + } + if (Language == "en") + { + _indexAloneLowercaseIToUppercaseIEnglish = _fixActions.Count; + _fixActions.Add(new FixItem(_language.FixLowercaseIToUppercaseI, _language.FixLowercaseIToUppercaseIExample, () => new FixAloneLowercaseIToUppercaseI().Fix(Subtitle, this), ce.AloneLowercaseIToUppercaseIEnglishTicked)); + } + if (Language == "tr") + { + _turkishAnsiIndex = _fixActions.Count; + _fixActions.Add(new FixItem(_language.FixTurkishAnsi, "Ý > İ, Ð > Ğ, Þ > Ş, ý > ı, ð > ğ, þ > ş", () => new FixTurkishAnsiToUnicode().Fix(Subtitle, this), ce.TurkishAnsiTicked)); + } + + if (Language == "da") + { + _danishLetterIIndex = _fixActions.Count; + _fixActions.Add(new FixItem(_language.FixDanishLetterI, "Jeg synes i er søde. -> Jeg synes I er søde.", () => new FixDanishLetterI().Fix(Subtitle, this), ce.DanishLetterITicked)); + } + + if (Language == "es") + { + _spanishInvertedQuestionAndExclamationMarksIndex = _fixActions.Count; + _fixActions.Add(new FixItem(_language.FixSpanishInvertedQuestionAndExclamationMarks, "Hablas bien castellano? -> ¿Hablas bien castellano?", () => new FixSpanishInvertedQuestionAndExclamationMarks().Fix(Subtitle, this), ce.SpanishInvertedQuestionAndExclamationMarksTicked)); + } + + listView1.Items.Clear(); + foreach (var fi in _fixActions) + { + AddFixActionItemToListView(fi); + } + } + + private static string GetDialogStyle(DialogType dialogStyle) + { + if (dialogStyle == DialogType.DashSecondLineWithoutSpace) + { + return Configuration.Settings.Language.Settings.DialogStyleDashSecondLineWithoutSpace; + } + if (dialogStyle == DialogType.DashSecondLineWithSpace) + { + return Configuration.Settings.Language.Settings.DialogStyleDashSecondLineWithSpace; + } + if (dialogStyle == DialogType.DashBothLinesWithoutSpace) + { + return Configuration.Settings.Language.Settings.DialogStyleDashSecondLineWithSpace; + } + return Configuration.Settings.Language.Settings.DialogStyleDashBothLinesWithSpace; + } + + public FixCommonErrors() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + labelStartTimeWarning.Text = string.Empty; + labelDurationWarning.Text = string.Empty; + labelNumberOfImportantLogMessages.Text = string.Empty; + labelLanguage2.Text = string.Empty; + Encoding = Encoding.UTF8; + _language = Configuration.Settings.Language.FixCommonErrors; + _languageGeneral = Configuration.Settings.Language.General; + Text = _language.Title; + groupBoxStep1.Text = _language.Step1; + groupBox2.Text = _language.Step2; + listView1.Columns[0].Text = _languageGeneral.Apply; + listView1.Columns[1].Text = _language.WhatToFix; + listView1.Columns[2].Text = _language.Example; + buttonSelectAll.Text = _language.SelectAll; + buttonInverseSelection.Text = _language.InverseSelection; + tabControl1.TabPages[0].Text = _language.Fixes; + tabControl1.TabPages[1].Text = _language.Log; + listViewFixes.Columns[0].Text = _languageGeneral.Apply; + listViewFixes.Columns[1].Text = _languageGeneral.LineNumber; + listViewFixes.Columns[2].Text = _language.Function; + listViewFixes.Columns[3].Text = _languageGeneral.Before; + listViewFixes.Columns[4].Text = _languageGeneral.After; + buttonNextFinish.Text = _language.Next; + buttonBack.Text = _language.Back; + buttonCancel.Text = _languageGeneral.Cancel; + buttonFixesSelectAll.Text = _language.SelectAll; + buttonFixesInverse.Text = _language.InverseSelection; + buttonRefreshFixes.Text = _language.RefreshFixes; + buttonFixesApply.Text = _language.ApplyFixes; + labelStartTime.Text = _languageGeneral.StartTime; + labelDuration.Text = _languageGeneral.Duration; + buttonAutoBreak.Text = _language.AutoBreak; + buttonUnBreak.Text = _language.Unbreak; + buttonSplitLine.Text = _languageGeneral.SplitLine; + subtitleListView1.InitializeLanguage(_languageGeneral, Configuration.Settings); + labelLanguage.Text = Configuration.Settings.Language.ChooseLanguage.Language; + toolStripMenuItemDelete.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.Delete; + mergeSelectedLinesToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.MergeSelectedLines; + buttonResetDefault.Text = _language.SelectDefault; + + toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; + toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; + selectDefaultToolStripMenuItem.Text = _language.SelectDefault; + setCurrentFixesAsDefaultToolStripMenuItem.Text = _language.SetDefault; + + toolStripMenuItemInverseRules.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; + toolStripMenuItemSelectAllRules.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; + + splitContainerStep2.Panel1MinSize = 110; + splitContainerStep2.Panel2MinSize = 160; + + numericUpDownDuration.Left = timeUpDownStartTime.Left + timeUpDownStartTime.Width; + labelDuration.Left = timeUpDownStartTime.Left + timeUpDownStartTime.Width - 3; + FixLargeFonts(); + listView1.Select(); + } + + private void FixLargeFonts() + { + using (var graphics = CreateGraphics()) + { + var textSize = graphics.MeasureString(buttonCancel.Text, Font); + if (textSize.Height > buttonCancel.Height - 4) + { + subtitleListView1.InitializeTimestampColumnWidths(this); + var newButtonHeight = (int)(textSize.Height + 7 + 0.5); + UiUtil.SetButtonHeight(this, newButtonHeight, 1); + } + } + } + + private void AddFixActionItemToListView(FixItem fi) + { + var item = new ListViewItem(string.Empty) { Tag = fi, Checked = fi.DefaultChecked }; + item.SubItems.Add(fi.Name); + item.SubItems.Add(fi.Example); + listView1.Items.Add(item); + } + + public void AddFixToListView(Paragraph p, string action, string before, string after) + { + AddFixToListView(p, action, before, after, true); + } + + public void AddFixToListView(Paragraph p, string action, string before, string after, bool isChecked) + { + if (_onlyListFixes) + { + var item = new ListViewItem(string.Empty) { Checked = isChecked, Tag = p }; + item.SubItems.Add(p.Number.ToString(CultureInfo.InvariantCulture)); + item.SubItems.Add(action); + item.SubItems.Add(UiUtil.GetListViewTextFromString(before)); + item.SubItems.Add(UiUtil.GetListViewTextFromString(after)); + listViewFixes.Items.Add(item); + } + } + + public bool AllowFix(Paragraph p, string action) + { + if (_onlyListFixes || BatchMode) + { + return true; + } + + return _allowedFixes.Contains(p.Number.ToString(CultureInfo.InvariantCulture) + "|" + action); + } + + public void ShowStatus(string message) + { + message = message.Replace(Environment.NewLine, " "); + if (message.Length > 103) + { + message = message.Substring(0, 100) + "..."; + } + + labelStatus.Text = message; + labelStatus.Refresh(); + } + + public void LogStatus(string sender, string message, bool isImportant) + { + if (isImportant) + { + _numberOfImportantLogMessages++; + } + + LogStatus(sender, message); + } + + public void LogStatus(string sender, string message) + { + if (!string.IsNullOrEmpty(message)) + { + message += Environment.NewLine; + if (_onlyListFixes) + { + _newLog.AppendLine(" + " + sender + ": " + message); + } + else + { + _appliedLog.AppendLine(string.Format(_language.FixedOkXY, sender, message)); + } + } + } + + public bool IsName(string candidate) + { + MakeSureNameListIsLoaded(); + return _nameList.Contains(candidate); // O(1) + } + + private void MakeSureNameListIsLoaded() + { + if (_nameList == null) + { + string languageTwoLetterCode = LanguageAutoDetect.AutoDetectGoogleLanguage(Subtitle); + // Will contains both one word names and multi names + var namesList = new NameList(Configuration.DictionariesDirectory, languageTwoLetterCode, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); + _nameList = namesList.GetNames(); + // Multi word names. + foreach (var name in namesList.GetMultiNames()) + { + _nameList.Add(name); + } + } + } + + public HashSet GetAbbreviations() + { + if (_abbreviationList != null) + { + return _abbreviationList; + } + + MakeSureNameListIsLoaded(); + _abbreviationList = new HashSet(); + foreach (string name in _nameList) + { + if (name.EndsWith('.')) + { + _abbreviationList.Add(name); + } + } + return _abbreviationList; + } + + private OcrFixEngine _ocrFixEngine; + private string _ocrFixEngineLanguage; + + public void FixOcrErrorsViaReplaceList(string threeLetterIsoLanguageName) + { + if (_ocrFixEngine == null || _ocrFixEngineLanguage != threeLetterIsoLanguageName) + { + _ocrFixEngine?.Dispose(); + _ocrFixEngineLanguage = threeLetterIsoLanguageName; + _ocrFixEngine = new OcrFixEngine(_ocrFixEngineLanguage, null, this); + } + + string fixAction = _language.FixCommonOcrErrors; + int noOfFixes = 0; + string lastLine = string.Empty; + for (int i = 0; i < Subtitle.Paragraphs.Count; i++) + { + var p = Subtitle.Paragraphs[i]; + string text = _ocrFixEngine.FixOcrErrors(p.Text, i, lastLine, false, OcrFixEngine.AutoGuessLevel.Cautious); + lastLine = text; + if (AllowFix(p, fixAction) && p.Text != text) + { + string oldText = p.Text; + p.Text = text; + noOfFixes++; + AddFixToListView(p, fixAction, oldText, p.Text); + } + Application.DoEvents(); + } + if (noOfFixes > 0) + { + _totalFixes += noOfFixes; + LogStatus(_language.FixCommonOcrErrors, string.Format(_language.CommonOcrErrorsFixed, noOfFixes)); + } + } + + public void UpdateFixStatus(int fixes, string message, string xMessage) + { + if (fixes > 0) + { + _totalFixes += fixes; + LogStatus(message, string.Format(xMessage, fixes)); + } + } + + private void ButtonFixClick(object sender, EventArgs e) + { + if (buttonBack.Enabled) + { + Cursor = Cursors.WaitCursor; + SaveConfiguration(); + Cursor = Cursors.Default; + DialogResult = DialogResult.OK; + } + else + { + Cursor = Cursors.WaitCursor; + Next(); + ShowAvailableFixesStatus(false); + } + Cursor = Cursors.Default; + } + + private void Next() + { + RunSelectedActions(); + + buttonBack.Enabled = true; + buttonNextFinish.Text = _languageGeneral.Ok; + buttonNextFinish.Enabled = _hasFixesBeenMade || _linesDeletedOrMerged; + groupBoxStep1.Visible = false; + groupBox2.Visible = true; + listViewFixes.Sort(); + subtitleListView1.Fill(FixedSubtitle); + if (listViewFixes.Items.Count > 0) + { + listViewFixes.Items[0].Selected = true; + } + else + { + subtitleListView1.SelectIndexAndEnsureVisible(0); + } + } + + private void RunSelectedActions() + { + subtitleListView1.BeginUpdate(); + _newLog.Clear(); + + Subtitle = new Subtitle(FixedSubtitle, false); + if (listView1.Items[IndexFixOcrErrorsViaReplaceList].Checked) + { + var fixItem = (FixItem)listView1.Items[IndexFixOcrErrorsViaReplaceList].Tag; + fixItem.Action.Invoke(); + } + foreach (ListViewItem item in listView1.Items) + { + if (item.Checked && item.Index != IndexRemoveEmptyLines) + { + var fixItem = (FixItem)item.Tag; + fixItem.Action.Invoke(); + } + } + if (listView1.Items[IndexInvalidItalicTags].Checked) + { + var fixItem = (FixItem)listView1.Items[IndexInvalidItalicTags].Tag; + fixItem.Action.Invoke(); + } + if (listView1.Items[IndexRemoveEmptyLines].Checked) + { + var fixItem = (FixItem)listView1.Items[IndexRemoveEmptyLines].Tag; + fixItem.Action.Invoke(); + } + + // build log + textBoxFixedIssues.Text = string.Empty; + if (_newLog.Length >= 0) + { + textBoxFixedIssues.AppendText(_newLog + Environment.NewLine); + } + + textBoxFixedIssues.AppendText(_appliedLog.ToString()); + subtitleListView1.EndUpdate(); + } + + private void FormFixKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#fixcommonerrors"); + } + else if (e.KeyCode == Keys.Enter && buttonNextFinish.Text == _language.Next) + { + ButtonFixClick(null, null); + } + else if (subtitleListView1.Visible && subtitleListView1.Items.Count > 0 && e.KeyData == _goToLine) + { + GoToLineNumber(); + } + else if (e.KeyData == _preview && listViewFixes.Items.Count > 0) + { + GenerateDiff(); + } + else if (_mainGeneralGoToNextSubtitle == e.KeyData || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)) + { + int selectedIndex = 0; + if (subtitleListView1.SelectedItems.Count > 0) + { + selectedIndex = subtitleListView1.SelectedItems[0].Index; + selectedIndex++; + } + subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex); + } + else if (_mainGeneralGoToPrevSubtitle == e.KeyData || (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt)) + { + int selectedIndex = 0; + if (subtitleListView1.SelectedItems.Count > 0) + { + selectedIndex = subtitleListView1.SelectedItems[0].Index; + selectedIndex--; + } + subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex); + } + else if (_mainListViewGoToNextError == e.KeyData) + { + GoToNextSyntaxError(); + e.SuppressKeyPress = true; + } + } + + private void GoToNextSyntaxError() + { + int idx = 0; + try + { + if (listViewFixes.SelectedItems.Count > 0) + { + idx = listViewFixes.SelectedItems[0].Index; + } + + idx++; + if (listViewFixes.Items.Count > idx) + { + listViewFixes.Items[idx].Selected = true; + listViewFixes.Items[idx].EnsureVisible(); + if (idx > 0) + { + listViewFixes.Items[idx - 1].Selected = false; + } + } + } + catch + { + // ignored + } + } + + private void GoToLineNumber() + { + using (var goToLine = new GoToLine()) + { + goToLine.Initialize(1, subtitleListView1.Items.Count); + if (goToLine.ShowDialog(this) == DialogResult.OK) + { + subtitleListView1.SelectNone(); + subtitleListView1.Items[goToLine.LineNumber - 1].Selected = true; + subtitleListView1.Items[goToLine.LineNumber - 1].EnsureVisible(); + subtitleListView1.Items[goToLine.LineNumber - 1].Focused = true; + } + } + } + + private void GenerateDiff() + { + string htmlFileName = FileUtil.GetTempFileName(".html"); + var sb = new StringBuilder(); + sb.Append("Subtitle Edit - Fix common errors preview"); + sb.AppendLine($""); + foreach (ListViewItem item in listViewFixes.Items) + { + if (item.Checked) + { + var p = (Paragraph)item.Tag; + string what = item.SubItems[2].Text; + string before = item.SubItems[3].Text; + string after = item.SubItems[4].Text; + var arr = MakeDiffHtml(before, after); + sb.AppendLine($""); + } + } + sb.Append("
{_languageGeneral.LineNumber}{_language.Function}{_languageGeneral.Before}{_languageGeneral.After}
{p.Number}{what}
{arr[0]}
{arr[1]}
"); + File.WriteAllText(htmlFileName, sb.ToString()); + UiUtil.OpenFile(htmlFileName); + } + + private static string[] MakeDiffHtml(string before, string after) + { + before = before.Replace("
", "↲"); + after = after.Replace("
", "↲"); + before = before.Replace(Environment.NewLine, "↲"); + after = after.Replace(Environment.NewLine, "↲"); + + var beforeColors = new Dictionary(); + var beforeBackgroundColors = new Dictionary(); + var afterColors = new Dictionary(); + var afterBackgroundColors = new Dictionary(); + + // from start + int minLength = Math.Min(before.Length, after.Length); + int startCharactersOk = 0; + for (int i = 0; i < minLength; i++) + { + if (before[i] == after[i]) + { + startCharactersOk++; + } + else + { + if (before.Length > i + 4 && after.Length > i + 4 && + before[i + 1] == after[i + 1] && + before[i + 2] == after[i + 2] && + before[i + 3] == after[i + 3] && + before[i + 4] == after[i + 4]) + { + startCharactersOk++; + + if (char.IsWhiteSpace(before[i])) + { + beforeBackgroundColors.Add(i, Color.Red); + } + else + { + beforeColors.Add(i, Color.Red); + } + + if (char.IsWhiteSpace(after[i])) + { + afterBackgroundColors.Add(i, Color.Red); + } + else + { + afterColors.Add(i, Color.Red); + } + } + else + { + break; + } + } + } + + int maxLength = Math.Max(before.Length, after.Length); + for (int i = startCharactersOk; i <= maxLength; i++) + { + if (i < before.Length) + { + if (char.IsWhiteSpace(before[i])) + { + beforeBackgroundColors.Add(i, Color.Red); + } + else + { + beforeColors.Add(i, Color.Red); + } + } + if (i < after.Length) + { + if (char.IsWhiteSpace(after[i])) + { + afterBackgroundColors.Add(i, Color.Red); + } + else + { + afterColors.Add(i, Color.Red); + } + } + } + + // from end + for (int i = 1; i < minLength; i++) + { + int bLength = before.Length - i; + int aLength = after.Length - i; + if (before[bLength] == after[aLength]) + { + if (beforeColors.ContainsKey(bLength)) + { + beforeColors.Remove(bLength); + } + + if (beforeBackgroundColors.ContainsKey(bLength)) + { + beforeBackgroundColors.Remove(bLength); + } + + if (afterColors.ContainsKey(aLength)) + { + afterColors.Remove(aLength); + } + + if (afterBackgroundColors.ContainsKey(aLength)) + { + afterBackgroundColors.Remove(aLength); + } + } + else + { + break; + } + } + + var sb = new StringBuilder(); + for (int i = 0; i < before.Length; i++) + { + var s = before[i]; + if (beforeColors.ContainsKey(i) && beforeBackgroundColors.ContainsKey(i)) + { + sb.AppendFormat("{2}", ColorTranslator.ToHtml(beforeColors[i]), ColorTranslator.ToHtml(beforeBackgroundColors[i]), s); + } + else if (beforeColors.ContainsKey(i)) + { + sb.AppendFormat("{1}", ColorTranslator.ToHtml(beforeColors[i]), s); + } + else if (beforeBackgroundColors.ContainsKey(i)) + { + sb.AppendFormat("{1}", ColorTranslator.ToHtml(beforeBackgroundColors[i]), s); + } + else + { + sb.Append(s); + } + } + var sb2 = new StringBuilder(); + for (int i = 0; i < after.Length; i++) + { + var s = after[i]; + if (afterColors.ContainsKey(i) && afterBackgroundColors.ContainsKey(i)) + { + sb2.AppendFormat("{2}", ColorTranslator.ToHtml(afterColors[i]), ColorTranslator.ToHtml(afterBackgroundColors[i]), s); + } + else if (afterColors.ContainsKey(i)) + { + sb2.AppendFormat("{1}", ColorTranslator.ToHtml(afterColors[i]), s); + } + else if (afterBackgroundColors.ContainsKey(i)) + { + sb2.AppendFormat("{1}", ColorTranslator.ToHtml(afterBackgroundColors[i]), s); + } + else + { + sb2.Append(s); + } + } + + return new[] { sb.ToString(), sb2.ToString() }; + } + + private void SaveConfiguration() + { + var ce = Configuration.Settings.CommonErrors; + + ce.EmptyLinesTicked = listView1.Items[IndexRemoveEmptyLines].Checked; + ce.OverlappingDisplayTimeTicked = listView1.Items[IndexOverlappingDisplayTime].Checked; + ce.TooShortDisplayTimeTicked = listView1.Items[IndexTooShortDisplayTime].Checked; + ce.TooLongDisplayTimeTicked = listView1.Items[IndexTooLongDisplayTime].Checked; + ce.TooShortGapTicked = listView1.Items[IndexTooShortGap].Checked; + ce.InvalidItalicTagsTicked = listView1.Items[IndexInvalidItalicTags].Checked; + ce.UnneededSpacesTicked = listView1.Items[IndexUnneededSpaces].Checked; + ce.UnneededPeriodsTicked = listView1.Items[IndexUnneededPeriods].Checked; + ce.FixCommasTicked = listView1.Items[IndexFixCommas].Checked; + ce.MissingSpacesTicked = listView1.Items[IndexMissingSpaces].Checked; + ce.BreakLongLinesTicked = listView1.Items[IndexBreakLongLines].Checked; + ce.MergeShortLinesTicked = listView1.Items[IndexMergeShortLines].Checked; + ce.MergeShortLinesAllTicked = listView1.Items[IndexMergeShortLinesAll].Checked; + + ce.UppercaseIInsideLowercaseWordTicked = listView1.Items[IndexUppercaseIInsideLowercaseWord].Checked; + ce.DoubleApostropheToQuoteTicked = listView1.Items[IndexDoubleApostropheToQuote].Checked; + ce.FixMusicNotationTicked = listView1.Items[IndexFixMusicNotation].Checked; + ce.AddPeriodAfterParagraphTicked = listView1.Items[IndexAddPeriodAfterParagraph].Checked; + ce.StartWithUppercaseLetterAfterParagraphTicked = listView1.Items[IndexStartWithUppercaseLetterAfterParagraph].Checked; + ce.StartWithUppercaseLetterAfterPeriodInsideParagraphTicked = listView1.Items[IndexStartWithUppercaseLetterAfterPeriodInsideParagraph].Checked; + ce.StartWithUppercaseLetterAfterColonTicked = listView1.Items[IndexStartWithUppercaseLetterAfterColon].Checked; + ce.AddMissingQuotesTicked = listView1.Items[IndexAddMissingQuotes].Checked; + ce.FixHyphensTicked = listView1.Items[IndexFixHyphens].Checked; + ce.FixHyphensRemoveSingleLineTicked = listView1.Items[IndexRemoveHyphensSingleLine].Checked; + ce.Fix3PlusLinesTicked = listView1.Items[IndexFix3PlusLines].Checked; + ce.FixDoubleDashTicked = listView1.Items[IndexFixDoubleDash].Checked; + ce.FixDoubleGreaterThanTicked = listView1.Items[IndexFixDoubleGreaterThan].Checked; + ce.FixContinuationStyleTicked = listView1.Items[IndexFixContinuationStyle].Checked; + if (LanguageAutoDetect.IsLanguageWithoutPeriods(Language)) + { + ce.FixContinuationStyleTicked = _oldFixContinuationStyleTicked; + } + + if (Configuration.Settings.General.ContinuationStyle == ContinuationStyle.None) + { + ce.FixEllipsesStartTicked = listView1.Items[IndexFixEllipsesStart].Checked; + } + + ce.FixMissingOpenBracketTicked = listView1.Items[IndexFixMissingOpenBracket].Checked; + if (_indexAloneLowercaseIToUppercaseIEnglish >= 0) + { + ce.AloneLowercaseIToUppercaseIEnglishTicked = listView1.Items[_indexAloneLowercaseIToUppercaseIEnglish].Checked; + } + + ce.FixOcrErrorsViaReplaceListTicked = listView1.Items[IndexFixOcrErrorsViaReplaceList].Checked; + ce.RemoveSpaceBetweenNumberTicked = listView1.Items[IndexRemoveSpaceBetweenNumbers].Checked; + ce.FixDialogsOnOneLineTicked = listView1.Items[IndexDialogsOnOneLine].Checked; + ce.NormalizeStringsTicked = listView1.Items[IndexNormalizeStrings].Checked; + if (_danishLetterIIndex >= 0) + { + ce.DanishLetterITicked = listView1.Items[_danishLetterIIndex].Checked; + } + + if (_turkishAnsiIndex >= 0) + { + ce.TurkishAnsiTicked = listView1.Items[_turkishAnsiIndex].Checked; + } + + if (_spanishInvertedQuestionAndExclamationMarksIndex >= 0) + { + ce.SpanishInvertedQuestionAndExclamationMarksTicked = listView1.Items[_spanishInvertedQuestionAndExclamationMarksIndex].Checked; + } + + Configuration.Settings.Save(); + } + + private void ButtonBackClick(object sender, EventArgs e) + { + buttonNextFinish.Enabled = true; + _totalFixes = 0; + _onlyListFixes = true; + buttonBack.Enabled = false; + buttonNextFinish.Text = _language.Next; + groupBox2.Visible = false; + groupBoxStep1.Visible = true; + ShowStatus(string.Empty); + listViewFixes.Items.Clear(); + } + + private void ButtonCancelClick(object sender, EventArgs e) + { + SaveConfiguration(); + } + + private void ListViewFixesColumnClick(object sender, ColumnClickEventArgs e) + { + var sorter = (ListViewSorter)listViewFixes.ListViewItemSorter; + + if (e.Column == sorter.ColumnNumber) + { + sorter.Descending = !sorter.Descending; // inverse sort direction + } + else + { + sorter.ColumnNumber = e.Column; + sorter.Descending = false; + sorter.IsNumber = e.Column == 1; // only index 1 is numeric + } + listViewFixes.Sort(); + } + + private void ButtonSelectAllClick(object sender, EventArgs e) + { + foreach (ListViewItem item in listView1.Items) + { + item.Checked = true; + } + } + + private void ButtonInverseSelectionClick(object sender, EventArgs e) + { + foreach (ListViewItem item in listView1.Items) + { + item.Checked = !item.Checked; + } + } + + private void ListViewFixesSelectedIndexChanged(object sender, EventArgs e) + { + if (listViewFixes.SelectedItems.Count > 0) + { + var p = (Paragraph)listViewFixes.SelectedItems[0].Tag; + + foreach (ListViewItem lvi in subtitleListView1.Items) + { + if (lvi.Tag is Paragraph p2 && p.Id == p2.Id) + { + var index = lvi.Index; + if (index - 1 > 0) + { + subtitleListView1.EnsureVisible(index - 1); + } + + if (index + 1 < subtitleListView1.Items.Count) + { + subtitleListView1.EnsureVisible(index + 1); + } + + subtitleListView1.SelectedIndexChanged -= SubtitleListView1SelectedIndexChanged; + subtitleListView1.SelectNone(); + subtitleListView1.SelectedIndexChanged += SubtitleListView1SelectedIndexChanged; + subtitleListView1.Items[index].Selected = true; + subtitleListView1.EnsureVisible(index); + return; + } + } + } + } + + private void SubtitleListView1SelectedIndexChanged(object sender, EventArgs e) + { + if (FixedSubtitle.Paragraphs.Count > 0) + { + int firstSelectedIndex = 0; + if (subtitleListView1.SelectedItems.Count > 0) + { + firstSelectedIndex = subtitleListView1.SelectedItems[0].Index; + } + + Paragraph p = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex); + if (p != null) + { + InitializeListViewEditBox(p); + _subtitleListViewIndex = firstSelectedIndex; + UpdateOverlapErrors(); + UpdateListViewTextInfo(p.Text); + } + } + } + + private void TextBoxListViewTextTextChanged(object sender, EventArgs e) + { + if (_subtitleListViewIndex >= 0) + { + string text = textBoxListViewText.Text.TrimEnd(); + UpdateListViewTextInfo(text); + + // update _subtitle + listview + FixedSubtitle.Paragraphs[_subtitleListViewIndex].Text = text; + subtitleListView1.SetText(_subtitleListViewIndex, text); + + EnableOkButton(); + UpdateListSyntaxColoring(); + } + } + + private void EnableOkButton() + { + if (!_hasFixesBeenMade) + { + _hasFixesBeenMade = true; + buttonNextFinish.Enabled = true; + } + } + + private void InitializeListViewEditBox(Paragraph p) + { + textBoxListViewText.TextChanged -= TextBoxListViewTextTextChanged; + textBoxListViewText.Text = p.Text; + textBoxListViewText.TextChanged += TextBoxListViewTextTextChanged; + + timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBox_TextChanged; + timeUpDownStartTime.TimeCode = p.StartTime; + timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBox_TextChanged; + + numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged; + numericUpDownDuration.Value = (decimal)(p.Duration.TotalMilliseconds / TimeCode.BaseUnit); + numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged; + } + + private void NumericUpDownDurationValueChanged(object sender, EventArgs e) + { + if (FixedSubtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0) + { + int firstSelectedIndex = subtitleListView1.SelectedItems[0].Index; + + Paragraph currentParagraph = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex); + if (currentParagraph != null) + { + UpdateOverlapErrors(); + + // update _subtitle + listview + currentParagraph.EndTime.TotalMilliseconds = currentParagraph.StartTime.TotalMilliseconds + ((double)numericUpDownDuration.Value * TimeCode.BaseUnit); + subtitleListView1.SetDuration(firstSelectedIndex, currentParagraph, FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex + 1)); + } + } + } + + private void UpdateOverlapErrors() + { + labelStartTimeWarning.Text = string.Empty; + labelDurationWarning.Text = string.Empty; + + TimeCode startTime = timeUpDownStartTime.TimeCode; + if (FixedSubtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0 && startTime != null) + { + int firstSelectedIndex = subtitleListView1.SelectedItems[0].Index; + + Paragraph prevParagraph = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex - 1); + if (prevParagraph != null && prevParagraph.EndTime.TotalMilliseconds > startTime.TotalMilliseconds) + { + labelStartTimeWarning.Text = string.Format(_languageGeneral.OverlapPreviousLineX, (prevParagraph.EndTime.TotalMilliseconds - startTime.TotalMilliseconds) / TimeCode.BaseUnit); + } + + Paragraph nextParagraph = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex + 1); + if (nextParagraph != null) + { + double durationMilliseconds = (double)numericUpDownDuration.Value * TimeCode.BaseUnit; + if (startTime.TotalMilliseconds + durationMilliseconds > nextParagraph.StartTime.TotalMilliseconds) + { + labelDurationWarning.Text = string.Format(_languageGeneral.OverlapNextX, ((startTime.TotalMilliseconds + durationMilliseconds) - nextParagraph.StartTime.TotalMilliseconds) / TimeCode.BaseUnit); + } + + if (labelStartTimeWarning.Text.Length == 0 && + startTime.TotalMilliseconds > nextParagraph.StartTime.TotalMilliseconds) + { + double di = (startTime.TotalMilliseconds - nextParagraph.StartTime.TotalMilliseconds) / TimeCode.BaseUnit; + labelStartTimeWarning.Text = string.Format(_languageGeneral.OverlapNextX, di); + } + else if (numericUpDownDuration.Value < 0) + { + labelDurationWarning.Text = _languageGeneral.Negative; + } + } + } + UpdateListSyntaxColoring(); + } + + private void UpdateListSyntaxColoring() + { + if (FixedSubtitle == null || FixedSubtitle.Paragraphs.Count == 0 || _subtitleListViewIndex < 0 || _subtitleListViewIndex >= Subtitle.Paragraphs.Count) + { + return; + } + + subtitleListView1.SyntaxColorLine(FixedSubtitle.Paragraphs, _subtitleListViewIndex, FixedSubtitle.Paragraphs[_subtitleListViewIndex]); + Paragraph next = FixedSubtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1); + if (next != null) + { + subtitleListView1.SyntaxColorLine(FixedSubtitle.Paragraphs, _subtitleListViewIndex + 1, FixedSubtitle.Paragraphs[_subtitleListViewIndex + 1]); + } + } + + private void MaskedTextBox_TextChanged(object sender, EventArgs e) + { + if (_subtitleListViewIndex >= 0 && + timeUpDownStartTime.TimeCode != null && + FixedSubtitle.Paragraphs.Count > 0 && + subtitleListView1.SelectedItems.Count > 0) + { + TimeCode startTime = timeUpDownStartTime.TimeCode; + labelStartTimeWarning.Text = string.Empty; + labelDurationWarning.Text = string.Empty; + + UpdateOverlapErrors(); + + // update _subtitle + listview + FixedSubtitle.Paragraphs[_subtitleListViewIndex].EndTime.TotalMilliseconds += + (startTime.TotalMilliseconds - FixedSubtitle.Paragraphs[_subtitleListViewIndex].StartTime.TotalMilliseconds); + FixedSubtitle.Paragraphs[_subtitleListViewIndex].StartTime = startTime; + subtitleListView1.SetStartTimeAndDuration(_subtitleListViewIndex, FixedSubtitle.Paragraphs[_subtitleListViewIndex], FixedSubtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1), FixedSubtitle.GetParagraphOrDefault(_subtitleListViewIndex - 1)); + } + } + + private void UpdateListViewTextInfo(string text) + { + labelTextLineLengths.Text = _languageGeneral.SingleLineLengths; + labelSingleLine.Left = labelTextLineLengths.Left + labelTextLineLengths.Width - 6; + text = HtmlUtil.RemoveHtmlTags(text, true); + text = NetflixImsc11Japanese.RemoveTags(text); + UiUtil.GetLineLengths(labelSingleLine, text); + + var s = text.Replace(Environment.NewLine, " "); + labelTextLineTotal.ForeColor = Color.Black; + buttonSplitLine.Visible = false; + var abl = Utilities.AutoBreakLine(s, _autoDetectGoogleLanguage).SplitToLines(); + if (abl.Count > Configuration.Settings.General.MaxNumberOfLines || abl.Any(li => li.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength)) + { + buttonSplitLine.Visible = true; + labelTextLineTotal.ForeColor = Color.Red; + } + labelTextLineTotal.Text = string.Format(_languageGeneral.TotalLengthX, text.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics)); + } + + private void ButtonFixesSelectAllClick(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = true; + } + } + + private void ButtonFixesInverseClick(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = !item.Checked; + } + } + + private void ButtonFixesApplyClick(object sender, EventArgs e) + { + buttonFixesApply.Enabled = false; + _hasFixesBeenMade = true; + Cursor = Cursors.WaitCursor; + ShowStatus(_language.Analysing); + + _subtitleListViewIndex = -1; + int firstSelectedIndex = 0; + if (subtitleListView1.SelectedItems.Count > 0) + { + firstSelectedIndex = subtitleListView1.SelectedItems[0].Index; + } + + _allowedFixes = new HashSet(); + foreach (ListViewItem item in listViewFixes.Items) + { + if (item.Checked) + { + string key = item.SubItems[1].Text + "|" + item.SubItems[2].Text; + if (!_allowedFixes.Contains(key)) + { + _allowedFixes.Add(key); + } + } + } + + _numberOfImportantLogMessages = 0; + _onlyListFixes = false; + _totalFixes = 0; + _totalErrors = 0; + RunSelectedActions(); + FixedSubtitle = new Subtitle(Subtitle, false); + subtitleListView1.Fill(FixedSubtitle); + ShowAvailableFixesStatus(true); + RefreshFixes(); + if (listViewFixes.Items.Count == 0) + { + subtitleListView1.SelectIndexAndEnsureVisible(firstSelectedIndex); + } + + Cursor = Cursors.Default; + if (_numberOfImportantLogMessages == 0) + { + labelNumberOfImportantLogMessages.Text = string.Empty; + } + else + { + labelNumberOfImportantLogMessages.Text = string.Format(_language.NumberOfImportantLogMessages, _numberOfImportantLogMessages); + } + + buttonFixesApply.Enabled = true; + } + + private void ButtonRefreshFixesClick(object sender, EventArgs e) + { + Cursor = Cursors.WaitCursor; + ShowStatus(_language.Analysing); + _totalFixes = 0; + RefreshFixes(); + ShowAvailableFixesStatus(false); + Cursor = Cursors.Default; + } + + private void ShowAvailableFixesStatus(bool applied) + { + labelStatus.ForeColor = DefaultForeColor; + if (_totalFixes == 0 && _totalErrors == 0) + { + ShowStatus(_language.NothingToFix); + if (subtitleListView1.SelectedItems.Count == 0) + { + subtitleListView1.SelectIndexAndEnsureVisible(0); + } + } + else if (_totalFixes > 0) + { + if (_totalErrors > 0) + { + labelStatus.ForeColor = Color.Red; + ShowStatus(string.Format(applied ? _language.XFixedBut : _language.XCouldBeFixedBut, _totalFixes)); + } + else + { + ShowStatus(string.Format(applied ? _language.XFixesApplied : _language.FixesFoundX, _totalFixes)); + } + } + else if (_totalErrors > 0) + { + labelStatus.ForeColor = Color.Red; + ShowStatus(_language.NothingFixableBut); + } + + TopMost = true; + BringToFront(); + TopMost = false; + } + + private void RefreshFixes() + { + listViewFixes.BeginUpdate(); + + // save de-selected fixes + var deSelectedFixes = new List(); + foreach (ListViewItem item in listViewFixes.Items) + { + if (!item.Checked) + { + deSelectedFixes.Add(item.SubItems[1].Text + item.SubItems[2].Text + item.SubItems[3].Text); + } + } + + listViewFixes.Items.Clear(); + _onlyListFixes = true; + Next(); + + // restore de-selected fixes + foreach (ListViewItem item in listViewFixes.Items) + { + if (deSelectedFixes.Contains(item.SubItems[1].Text + item.SubItems[2].Text + item.SubItems[3].Text)) + { + item.Checked = false; + } + } + + listViewFixes.EndUpdate(); + } + + private void ButtonAutoBreakClick(object sender, EventArgs e) + { + if (textBoxListViewText.Text.Length > 0) + { + string oldText = textBoxListViewText.Text; + textBoxListViewText.Text = Utilities.AutoBreakLine(textBoxListViewText.Text, Language); + if (oldText != textBoxListViewText.Text) + { + EnableOkButton(); + } + } + } + + private void ButtonUnBreakClick(object sender, EventArgs e) + { + string oldText = textBoxListViewText.Text; + textBoxListViewText.Text = Utilities.UnbreakLine(textBoxListViewText.Text); + if (oldText != textBoxListViewText.Text) + { + EnableOkButton(); + } + } + + private void ToolStripMenuItemDeleteClick(object sender, EventArgs e) + { + if (FixedSubtitle.Paragraphs.Count <= 0 || subtitleListView1.SelectedItems.Count <= 0) + { + return; + } + + var askText = subtitleListView1.SelectedItems.Count > 1 ? string.Format(Configuration.Settings.Language.Main.DeleteXLinesPrompt, subtitleListView1.SelectedItems.Count) : Configuration.Settings.Language.Main.DeleteOneLinePrompt; + if (Configuration.Settings.General.PromptDeleteLines && MessageBox.Show(askText, Configuration.Settings.Language.General.Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return; + } + + _linesDeletedOrMerged = true; + _subtitleListViewIndex = -1; + var indexes = new List(); + foreach (ListViewItem item in subtitleListView1.SelectedItems) + { + indexes.Add(item.Index); + } + + int firstIndex = subtitleListView1.SelectedItems[0].Index; + + // save de-selected fixes + var deSelectedFixes = new List(); + foreach (ListViewItem item in listViewFixes.Items) + { + if (!item.Checked) + { + int number = Convert.ToInt32(item.SubItems[1].Text); + if (number > firstIndex) + { + number -= subtitleListView1.SelectedItems.Count; + } + + if (number >= 0) + { + deSelectedFixes.Add(number + item.SubItems[2].Text + item.SubItems[3].Text); + } + } + } + + FixedSubtitle.RemoveParagraphsByIndices(indexes); + FixedSubtitle.Renumber(); + subtitleListView1.Fill(FixedSubtitle); + + // refresh fixes + listViewFixes.Items.Clear(); + _onlyListFixes = true; + Next(); + + // restore de-selected fixes + if (deSelectedFixes.Count > 0) + { + foreach (ListViewItem item in listViewFixes.Items) + { + if (deSelectedFixes.Contains(item.SubItems[1].Text + item.SubItems[2].Text + item.SubItems[3].Text)) + { + item.Checked = false; + } + } + } + + if (subtitleListView1.Items.Count > firstIndex) + { + subtitleListView1.SelectIndexAndEnsureVisible(firstIndex, true); + } + else if (subtitleListView1.Items.Count > 0) + { + subtitleListView1.SelectIndexAndEnsureVisible(subtitleListView1.Items.Count - 1, true); + } + } + + private void MergeSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) + { + if (FixedSubtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0) + { + _linesDeletedOrMerged = true; + int startNumber = FixedSubtitle.Paragraphs[0].Number; + int firstSelectedIndex = subtitleListView1.SelectedItems[0].Index; + + // save de-selected fixes + var deSelectedFixes = new List(); + foreach (ListViewItem item in listViewFixes.Items) + { + if (!item.Checked) + { + int firstSelectedNumber = subtitleListView1.GetSelectedParagraph(FixedSubtitle).Number; + int number = Convert.ToInt32(item.SubItems[1].Text); + if (number > firstSelectedNumber) + { + number--; + } + + deSelectedFixes.Add(number + item.SubItems[2].Text + item.SubItems[3].Text); + } + } + + var currentParagraph = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex); + var nextParagraph = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex + 1); + + if (nextParagraph != null && currentParagraph != null) + { + subtitleListView1.SelectedIndexChanged -= SubtitleListView1SelectedIndexChanged; + + currentParagraph.Text = currentParagraph.Text.Replace(Environment.NewLine, " "); + currentParagraph.Text += Environment.NewLine + nextParagraph.Text.Replace(Environment.NewLine, " "); + currentParagraph.EndTime = nextParagraph.EndTime; + + FixedSubtitle.Paragraphs.Remove(nextParagraph); + + FixedSubtitle.Renumber(startNumber); + subtitleListView1.Fill(FixedSubtitle); + subtitleListView1.SelectIndexAndEnsureVisible(firstSelectedIndex); + subtitleListView1.SelectedIndexChanged += SubtitleListView1SelectedIndexChanged; + _subtitleListViewIndex = -1; + SubtitleListView1SelectedIndexChanged(null, null); + } + + // refresh fixes + listViewFixes.Items.Clear(); + _onlyListFixes = true; + Next(); + + // restore de-selected fixes + foreach (ListViewItem item in listViewFixes.Items) + { + if (deSelectedFixes.Contains(item.SubItems[1].Text + item.SubItems[2].Text + item.SubItems[3].Text)) + { + item.Checked = false; + } + } + } + } + + private void ContextMenuStripListviewOpening(object sender, System.ComponentModel.CancelEventArgs e) + { + if (subtitleListView1.SelectedItems.Count == 0) + { + e.Cancel = true; + } + else if (subtitleListView1.SelectedItems.Count == 2 && + subtitleListView1.SelectedItems[0].Index == subtitleListView1.SelectedItems[1].Index - 1) + { + mergeSelectedLinesToolStripMenuItem.Visible = true; + toolStripSeparator1.Visible = true; + } + else + { + mergeSelectedLinesToolStripMenuItem.Visible = false; + toolStripSeparator1.Visible = false; + } + } + + private void FixCommonErrorsResize(object sender, EventArgs e) + { + groupBox2.Width = Width - (groupBox2.Left * 2 + 15); + groupBoxStep1.Width = Width - (groupBoxStep1.Left * 2 + 15); + buttonCancel.Left = Width - (buttonCancel.Width + 26); + buttonNextFinish.Left = buttonCancel.Left - (buttonNextFinish.Width + 6); + buttonBack.Left = buttonNextFinish.Left - (buttonBack.Width + 6); + tabControl1.Width = groupBox2.Width - (tabControl1.Left * 2); + listView1.Width = groupBoxStep1.Width - (listView1.Left * 2); + + ListViewFixesAutoSizeAllColumns(); + subtitleListView1.AutoSizeAllColumns(this); + } + + public void ListViewFixesAutoSizeAllColumns() + { + using (var graphics = CreateGraphics()) + { + var timestampSizeF = graphics.MeasureString(listViewFixes.Columns[0].Text, Font); // Apply + var width = (int)(timestampSizeF.Width + 12); + listViewFixes.Columns[0].Width = width; + + timestampSizeF = graphics.MeasureString(listViewFixes.Columns[1].Text, Font); // line# + width = (int)(timestampSizeF.Width + 12); + listViewFixes.Columns[1].Width = width; + + timestampSizeF = graphics.MeasureString("Auto break all lines and even more stuff", Font); // Function + width = (int)(timestampSizeF.Width + 12); + listViewFixes.Columns[2].Width = width; + + int length = listViewFixes.Columns[0].Width + listViewFixes.Columns[1].Width + listViewFixes.Columns[2].Width; + int lengthAvailable = Width - length; + width = (lengthAvailable - 10) / 2; + listViewFixes.Columns[3].Width = width; // before + listViewFixes.Columns[4].Width = width; // after + } + } + + private void FixCommonErrorsShown(object sender, EventArgs e) + { + FixCommonErrorsResize(null, null); + } + + private void SplitSelectedParagraph(double? splitSeconds) + { + if (FixedSubtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0) + { + subtitleListView1.SelectedIndexChanged -= SubtitleListView1SelectedIndexChanged; + int firstSelectedIndex = subtitleListView1.SelectedItems[0].Index; + + // save de-selected fixes + var deSelectedFixes = new List(); + foreach (ListViewItem item in listViewFixes.Items) + { + if (!item.Checked) + { + int number = Convert.ToInt32(item.SubItems[1].Text); + if (number > firstSelectedIndex) + { + number++; + } + + deSelectedFixes.Add(number + item.SubItems[2].Text + item.SubItems[3].Text); + } + } + + Paragraph currentParagraph = FixedSubtitle.GetParagraphOrDefault(firstSelectedIndex); + var newParagraph = new Paragraph(); + + string oldText = currentParagraph.Text; + var lines = currentParagraph.Text.SplitToLines(); + if (lines.Count == 2 && (lines[0].EndsWith('.') || lines[0].EndsWith('!') || lines[0].EndsWith('?'))) + { + currentParagraph.Text = Utilities.AutoBreakLine(lines[0], Language); + newParagraph.Text = Utilities.AutoBreakLine(lines[1], Language); + } + else + { + string s = Utilities.AutoBreakLine(currentParagraph.Text, 5, Configuration.Settings.General.MergeLinesShorterThan, Language); + lines = s.SplitToLines(); + if (lines.Count == 2) + { + currentParagraph.Text = Utilities.AutoBreakLine(lines[0], Language); + newParagraph.Text = Utilities.AutoBreakLine(lines[1], Language); + } + else if (lines.Count > 2) + { + var half = lines.Count / 2; + var sb1 = new StringBuilder(); + for (int i = 0; i < half; i++) + { + sb1.AppendLine(lines[i]); + } + + currentParagraph.Text = Utilities.AutoBreakLine(sb1.ToString(), _autoDetectGoogleLanguage); + sb1 = new StringBuilder(); + for (int i = half; i < lines.Count; i++) + { + sb1.AppendLine(lines[i]); + } + + newParagraph.Text = Utilities.AutoBreakLine(sb1.ToString(), _autoDetectGoogleLanguage); + } + } + + double startFactor = (double)HtmlUtil.RemoveHtmlTags(currentParagraph.Text).Length / HtmlUtil.RemoveHtmlTags(oldText).Length; + if (startFactor < 0.20) + { + startFactor = 0.20; + } + + if (startFactor > 0.80) + { + startFactor = 0.80; + } + + double middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.Duration.TotalMilliseconds * startFactor); + if (splitSeconds.HasValue && splitSeconds.Value > (currentParagraph.StartTime.TotalSeconds + 0.2) && splitSeconds.Value < (currentParagraph.EndTime.TotalSeconds - 0.2)) + { + middle = splitSeconds.Value * TimeCode.BaseUnit; + } + + newParagraph.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; + currentParagraph.EndTime.TotalMilliseconds = middle; + newParagraph.StartTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds + 1; + + FixedSubtitle.Paragraphs.Insert(firstSelectedIndex + 1, newParagraph); + FixedSubtitle.Renumber(); + subtitleListView1.Fill(FixedSubtitle); + textBoxListViewText.Text = currentParagraph.Text; + + subtitleListView1.SelectIndexAndEnsureVisible(firstSelectedIndex); + subtitleListView1.SelectedIndexChanged += SubtitleListView1SelectedIndexChanged; + + // restore de-selected fixes + listViewFixes.Items.Clear(); + _onlyListFixes = true; + Next(); + foreach (ListViewItem item in listViewFixes.Items) + { + if (deSelectedFixes.Contains(item.SubItems[1].Text + item.SubItems[2].Text + item.SubItems[3].Text)) + { + item.Checked = false; + } + } + } + } + + private void ButtonSplitLineClick(object sender, EventArgs e) + { + SplitSelectedParagraph(null); + } + + private void TextBoxListViewTextKeyDown(object sender, KeyEventArgs e) + { + UiUtil.CheckAutoWrap(textBoxListViewText, e, Utilities.GetNumberOfLines(textBoxListViewText.Text)); + } + + private void FixCommonErrorsFormClosing(object sender, FormClosingEventArgs e) + { + if (_ocrFixEngine != null) + { + _ocrFixEngine.Dispose(); + _ocrFixEngine = null; + } + Owner = null; + } + + private void comboBoxLanguage_SelectedIndexChanged(object sender, EventArgs e) + { + if (Subtitle != null) + { + if (comboBoxLanguage.SelectedItem is LanguageItem ci) + { + _autoDetectGoogleLanguage = ci.Code.TwoLetterISOLanguageName; + AddFixActions(ci.Code.GetThreeLetterIsoLanguageName()); + } + } + labelLanguage2.Text = comboBoxLanguage.Text; + } + + private void comboBoxLanguage_Enter(object sender, EventArgs e) + { + SaveConfiguration(); + } + + private void buttonResetDefault_Click(object sender, EventArgs e) + { + Configuration.Settings.CommonErrors.LoadUserDefaultFixes(Configuration.Settings.CommonErrors.DefaultFixes); + AddFixActions(CultureInfo.GetCultureInfo(_autoDetectGoogleLanguage).GetThreeLetterIsoLanguageName()); + } + + private void subtitleListView1_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) + { + subtitleListView1.SelectAll(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.D && e.Modifiers == Keys.Control) + { + subtitleListView1.SelectFirstSelectedItemOnly(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.I && e.Modifiers == (Keys.Control | Keys.Shift)) //InverseSelection + { + subtitleListView1.InverseSelection(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.Delete) + { + ToolStripMenuItemDeleteClick(null, null); + } + } + + private Hunspell _hunspell; + + public bool DoSpell(string word) + { + if (_hunspell == null && Language != null) + { + var fileMatches = Directory.GetFiles(Utilities.DictionaryFolder, Language + "*.dic"); + if (fileMatches.Length > 0) + { + var dictionary = fileMatches[0].Substring(0, fileMatches[0].Length - 4); + try + { + _hunspell = Hunspell.GetHunspell(dictionary); + } + catch + { + _hunspell = null; + } + } + } + + if (_hunspell == null) + { + return false; + } + + return _hunspell.Spell(word); + } + + private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = true; + } + } + + private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = !item.Checked; + } + } + + private void setCurrentFixesAsDefaultToolStripMenuItem_Click(object sender, EventArgs e) + { + SaveConfiguration(); + Configuration.Settings.CommonErrors.SaveUserDefaultFixes(); + AddFixActions(CultureInfo.GetCultureInfo(_autoDetectGoogleLanguage).GetThreeLetterIsoLanguageName()); + } + + private void selectDefaultToolStripMenuItem_Click(object sender, EventArgs e) + { + buttonResetDefault_Click(null, null); + } + } +} diff --git a/src/Forms/FixCommonErrors.resx b/src/ui/Forms/FixCommonErrors.resx similarity index 98% rename from src/Forms/FixCommonErrors.resx rename to src/ui/Forms/FixCommonErrors.resx index 7791be016..ae2263af6 100644 --- a/src/Forms/FixCommonErrors.resx +++ b/src/ui/Forms/FixCommonErrors.resx @@ -1,129 +1,129 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 327, 17 - - - 172, 17 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 327, 17 + + + 172, 17 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/GetDictionaries.Designer.cs b/src/ui/Forms/GetDictionaries.Designer.cs similarity index 98% rename from src/Forms/GetDictionaries.Designer.cs rename to src/ui/Forms/GetDictionaries.Designer.cs index 8328b92c3..b8293e21e 100644 --- a/src/Forms/GetDictionaries.Designer.cs +++ b/src/ui/Forms/GetDictionaries.Designer.cs @@ -1,177 +1,177 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class GetDictionaries - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonOK = new System.Windows.Forms.Button(); - this.labelDescription2 = new System.Windows.Forms.Label(); - this.linkLabelOpenDictionaryFolder = new System.Windows.Forms.LinkLabel(); - this.labelDescription1 = new System.Windows.Forms.Label(); - this.comboBoxDictionaries = new System.Windows.Forms.ComboBox(); - this.buttonDownload = new System.Windows.Forms.Button(); - this.labelChooseLanguageAndClickDownload = new System.Windows.Forms.Label(); - this.labelPleaseWait = new System.Windows.Forms.Label(); - this.buttonDownloadAll = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.Location = new System.Drawing.Point(356, 159); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(104, 23); - this.buttonOK.TabIndex = 20; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - // - // labelDescription2 - // - this.labelDescription2.AutoSize = true; - this.labelDescription2.Location = new System.Drawing.Point(30, 34); - this.labelDescription2.Name = "labelDescription2"; - this.labelDescription2.Size = new System.Drawing.Size(263, 13); - this.labelDescription2.TabIndex = 1; - this.labelDescription2.Text = "uses the spell checking dictionaries from LibreOffice."; - // - // linkLabelOpenDictionaryFolder - // - this.linkLabelOpenDictionaryFolder.AutoSize = true; - this.linkLabelOpenDictionaryFolder.Location = new System.Drawing.Point(30, 164); - this.linkLabelOpenDictionaryFolder.Name = "linkLabelOpenDictionaryFolder"; - this.linkLabelOpenDictionaryFolder.Size = new System.Drawing.Size(126, 13); - this.linkLabelOpenDictionaryFolder.TabIndex = 15; - this.linkLabelOpenDictionaryFolder.TabStop = true; - this.linkLabelOpenDictionaryFolder.Text = "Open \'Dictionaries\' folder"; - this.linkLabelOpenDictionaryFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel4LinkClicked); - // - // labelDescription1 - // - this.labelDescription1.AutoSize = true; - this.labelDescription1.Location = new System.Drawing.Point(30, 16); - this.labelDescription1.Name = "labelDescription1"; - this.labelDescription1.Size = new System.Drawing.Size(316, 13); - this.labelDescription1.TabIndex = 8; - this.labelDescription1.Text = "Subtitle Edit\'s spell check is based on the NHunspell engine which"; - // - // comboBoxDictionaries - // - this.comboBoxDictionaries.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.comboBoxDictionaries.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxDictionaries.FormattingEnabled = true; - this.comboBoxDictionaries.Location = new System.Drawing.Point(33, 98); - this.comboBoxDictionaries.Name = "comboBoxDictionaries"; - this.comboBoxDictionaries.Size = new System.Drawing.Size(317, 21); - this.comboBoxDictionaries.TabIndex = 0; - this.comboBoxDictionaries.SelectedIndexChanged += new System.EventHandler(this.comboBoxDictionaries_SelectedIndexChanged); - // - // buttonDownload - // - this.buttonDownload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDownload.Location = new System.Drawing.Point(356, 97); - this.buttonDownload.Name = "buttonDownload"; - this.buttonDownload.Size = new System.Drawing.Size(104, 25); - this.buttonDownload.TabIndex = 10; - this.buttonDownload.Text = "&Download"; - this.buttonDownload.UseVisualStyleBackColor = true; - this.buttonDownload.Click += new System.EventHandler(this.buttonDownload_Click); - // - // labelChooseLanguageAndClickDownload - // - this.labelChooseLanguageAndClickDownload.AutoSize = true; - this.labelChooseLanguageAndClickDownload.Location = new System.Drawing.Point(30, 79); - this.labelChooseLanguageAndClickDownload.Name = "labelChooseLanguageAndClickDownload"; - this.labelChooseLanguageAndClickDownload.Size = new System.Drawing.Size(207, 13); - this.labelChooseLanguageAndClickDownload.TabIndex = 11; - this.labelChooseLanguageAndClickDownload.Text = "Choose your language and click download"; - // - // labelPleaseWait - // - this.labelPleaseWait.AutoSize = true; - this.labelPleaseWait.Location = new System.Drawing.Point(30, 126); - this.labelPleaseWait.Name = "labelPleaseWait"; - this.labelPleaseWait.Size = new System.Drawing.Size(73, 13); - this.labelPleaseWait.TabIndex = 12; - this.labelPleaseWait.Text = "Please wait..."; - // - // buttonDownloadAll - // - this.buttonDownloadAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDownloadAll.BackColor = System.Drawing.Color.Yellow; - this.buttonDownloadAll.Location = new System.Drawing.Point(296, 54); - this.buttonDownloadAll.Name = "buttonDownloadAll"; - this.buttonDownloadAll.Size = new System.Drawing.Size(164, 25); - this.buttonDownloadAll.TabIndex = 21; - this.buttonDownloadAll.Text = "Download all [DEBUG ONLY]"; - this.buttonDownloadAll.UseVisualStyleBackColor = false; - this.buttonDownloadAll.Visible = false; - this.buttonDownloadAll.Click += new System.EventHandler(this.buttonDownloadAll_Click); - // - // GetDictionaries - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(472, 195); - this.Controls.Add(this.buttonDownloadAll); - this.Controls.Add(this.comboBoxDictionaries); - this.Controls.Add(this.labelPleaseWait); - this.Controls.Add(this.labelChooseLanguageAndClickDownload); - this.Controls.Add(this.buttonDownload); - this.Controls.Add(this.labelDescription1); - this.Controls.Add(this.linkLabelOpenDictionaryFolder); - this.Controls.Add(this.labelDescription2); - this.Controls.Add(this.buttonOK); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "GetDictionaries"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Need dictionaries?"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormGetDictionaries_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Label labelDescription2; - private System.Windows.Forms.LinkLabel linkLabelOpenDictionaryFolder; - private System.Windows.Forms.Label labelDescription1; - private System.Windows.Forms.ComboBox comboBoxDictionaries; - private System.Windows.Forms.Button buttonDownload; - private System.Windows.Forms.Label labelChooseLanguageAndClickDownload; - private System.Windows.Forms.Label labelPleaseWait; - private System.Windows.Forms.Button buttonDownloadAll; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class GetDictionaries + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonOK = new System.Windows.Forms.Button(); + this.labelDescription2 = new System.Windows.Forms.Label(); + this.linkLabelOpenDictionaryFolder = new System.Windows.Forms.LinkLabel(); + this.labelDescription1 = new System.Windows.Forms.Label(); + this.comboBoxDictionaries = new System.Windows.Forms.ComboBox(); + this.buttonDownload = new System.Windows.Forms.Button(); + this.labelChooseLanguageAndClickDownload = new System.Windows.Forms.Label(); + this.labelPleaseWait = new System.Windows.Forms.Label(); + this.buttonDownloadAll = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.Location = new System.Drawing.Point(356, 159); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(104, 23); + this.buttonOK.TabIndex = 20; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + // + // labelDescription2 + // + this.labelDescription2.AutoSize = true; + this.labelDescription2.Location = new System.Drawing.Point(30, 34); + this.labelDescription2.Name = "labelDescription2"; + this.labelDescription2.Size = new System.Drawing.Size(263, 13); + this.labelDescription2.TabIndex = 1; + this.labelDescription2.Text = "uses the spell checking dictionaries from LibreOffice."; + // + // linkLabelOpenDictionaryFolder + // + this.linkLabelOpenDictionaryFolder.AutoSize = true; + this.linkLabelOpenDictionaryFolder.Location = new System.Drawing.Point(30, 164); + this.linkLabelOpenDictionaryFolder.Name = "linkLabelOpenDictionaryFolder"; + this.linkLabelOpenDictionaryFolder.Size = new System.Drawing.Size(126, 13); + this.linkLabelOpenDictionaryFolder.TabIndex = 15; + this.linkLabelOpenDictionaryFolder.TabStop = true; + this.linkLabelOpenDictionaryFolder.Text = "Open \'Dictionaries\' folder"; + this.linkLabelOpenDictionaryFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel4LinkClicked); + // + // labelDescription1 + // + this.labelDescription1.AutoSize = true; + this.labelDescription1.Location = new System.Drawing.Point(30, 16); + this.labelDescription1.Name = "labelDescription1"; + this.labelDescription1.Size = new System.Drawing.Size(316, 13); + this.labelDescription1.TabIndex = 8; + this.labelDescription1.Text = "Subtitle Edit\'s spell check is based on the NHunspell engine which"; + // + // comboBoxDictionaries + // + this.comboBoxDictionaries.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.comboBoxDictionaries.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxDictionaries.FormattingEnabled = true; + this.comboBoxDictionaries.Location = new System.Drawing.Point(33, 98); + this.comboBoxDictionaries.Name = "comboBoxDictionaries"; + this.comboBoxDictionaries.Size = new System.Drawing.Size(317, 21); + this.comboBoxDictionaries.TabIndex = 0; + this.comboBoxDictionaries.SelectedIndexChanged += new System.EventHandler(this.comboBoxDictionaries_SelectedIndexChanged); + // + // buttonDownload + // + this.buttonDownload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDownload.Location = new System.Drawing.Point(356, 97); + this.buttonDownload.Name = "buttonDownload"; + this.buttonDownload.Size = new System.Drawing.Size(104, 25); + this.buttonDownload.TabIndex = 10; + this.buttonDownload.Text = "&Download"; + this.buttonDownload.UseVisualStyleBackColor = true; + this.buttonDownload.Click += new System.EventHandler(this.buttonDownload_Click); + // + // labelChooseLanguageAndClickDownload + // + this.labelChooseLanguageAndClickDownload.AutoSize = true; + this.labelChooseLanguageAndClickDownload.Location = new System.Drawing.Point(30, 79); + this.labelChooseLanguageAndClickDownload.Name = "labelChooseLanguageAndClickDownload"; + this.labelChooseLanguageAndClickDownload.Size = new System.Drawing.Size(207, 13); + this.labelChooseLanguageAndClickDownload.TabIndex = 11; + this.labelChooseLanguageAndClickDownload.Text = "Choose your language and click download"; + // + // labelPleaseWait + // + this.labelPleaseWait.AutoSize = true; + this.labelPleaseWait.Location = new System.Drawing.Point(30, 126); + this.labelPleaseWait.Name = "labelPleaseWait"; + this.labelPleaseWait.Size = new System.Drawing.Size(73, 13); + this.labelPleaseWait.TabIndex = 12; + this.labelPleaseWait.Text = "Please wait..."; + // + // buttonDownloadAll + // + this.buttonDownloadAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDownloadAll.BackColor = System.Drawing.Color.Yellow; + this.buttonDownloadAll.Location = new System.Drawing.Point(296, 54); + this.buttonDownloadAll.Name = "buttonDownloadAll"; + this.buttonDownloadAll.Size = new System.Drawing.Size(164, 25); + this.buttonDownloadAll.TabIndex = 21; + this.buttonDownloadAll.Text = "Download all [DEBUG ONLY]"; + this.buttonDownloadAll.UseVisualStyleBackColor = false; + this.buttonDownloadAll.Visible = false; + this.buttonDownloadAll.Click += new System.EventHandler(this.buttonDownloadAll_Click); + // + // GetDictionaries + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(472, 195); + this.Controls.Add(this.buttonDownloadAll); + this.Controls.Add(this.comboBoxDictionaries); + this.Controls.Add(this.labelPleaseWait); + this.Controls.Add(this.labelChooseLanguageAndClickDownload); + this.Controls.Add(this.buttonDownload); + this.Controls.Add(this.labelDescription1); + this.Controls.Add(this.linkLabelOpenDictionaryFolder); + this.Controls.Add(this.labelDescription2); + this.Controls.Add(this.buttonOK); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "GetDictionaries"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Need dictionaries?"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormGetDictionaries_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Label labelDescription2; + private System.Windows.Forms.LinkLabel linkLabelOpenDictionaryFolder; + private System.Windows.Forms.Label labelDescription1; + private System.Windows.Forms.ComboBox comboBoxDictionaries; + private System.Windows.Forms.Button buttonDownload; + private System.Windows.Forms.Label labelChooseLanguageAndClickDownload; + private System.Windows.Forms.Label labelPleaseWait; + private System.Windows.Forms.Button buttonDownloadAll; + } } \ No newline at end of file diff --git a/src/Forms/GetDictionaries.cs b/src/ui/Forms/GetDictionaries.cs similarity index 97% rename from src/Forms/GetDictionaries.cs rename to src/ui/Forms/GetDictionaries.cs index f4fa65c65..e8b2d431b 100644 --- a/src/Forms/GetDictionaries.cs +++ b/src/ui/Forms/GetDictionaries.cs @@ -1,312 +1,312 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Net; -using System.Windows.Forms; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class GetDictionaries : Form - { - private List _dictionaryDownloadLinks = new List(); - private List _descriptions = new List(); - private List _englishNames = new List(); - private string _xmlName; - private string _downloadLink; - private int _testAllIndex = -1; - - public string SelectedEnglishName { get; private set; } - public string LastDownload { get; private set; } - - public GetDictionaries() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.GetDictionaries.Title; - labelDescription1.Text = Configuration.Settings.Language.GetDictionaries.DescriptionLine1; - labelDescription2.Text = Configuration.Settings.Language.GetDictionaries.DescriptionLine2; - linkLabelOpenDictionaryFolder.Text = Configuration.Settings.Language.GetDictionaries.OpenDictionariesFolder; - labelChooseLanguageAndClickDownload.Text = Configuration.Settings.Language.GetDictionaries.ChooseLanguageAndClickDownload; - buttonDownload.Text = Configuration.Settings.Language.GetDictionaries.Download; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - labelPleaseWait.Text = string.Empty; - - LoadDictionaryList("Nikse.SubtitleEdit.Resources.HunspellDictionaries.xml.gz"); - FixLargeFonts(); -#if DEBUG - buttonDownloadAll.Visible = true; // For testing all download links -#endif - } - - private void LoadDictionaryList(string xmlResourceName) - { - _dictionaryDownloadLinks = new List(); - _descriptions = new List(); - _englishNames = new List(); - _xmlName = xmlResourceName; - System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); - var stream = asm.GetManifestResourceStream(_xmlName); - if (stream != null) - { - comboBoxDictionaries.Items.Clear(); - var doc = new XmlDocument(); - using (var rdr = new StreamReader(stream)) - using (var zip = new GZipStream(rdr.BaseStream, CompressionMode.Decompress)) - using (var reader = XmlReader.Create(zip, new XmlReaderSettings { IgnoreProcessingInstructions = true })) - { - doc.Load(reader); - } - - foreach (XmlNode node in doc.DocumentElement.SelectNodes("Dictionary")) - { - string englishName = node.SelectSingleNode("EnglishName").InnerText; - string nativeName = node.SelectSingleNode("NativeName").InnerText; - string downloadLink = node.SelectSingleNode("DownloadLink").InnerText; - - string description = string.Empty; - if (node.SelectSingleNode("Description") != null) - { - description = node.SelectSingleNode("Description").InnerText; - } - - if (!string.IsNullOrEmpty(downloadLink)) - { - string name = englishName; - if (!string.IsNullOrEmpty(nativeName)) - { - name += " - " + nativeName; - } - - comboBoxDictionaries.Items.Add(name); - _dictionaryDownloadLinks.Add(downloadLink); - _descriptions.Add(description); - _englishNames.Add(englishName); - } - } - comboBoxDictionaries.SelectedIndex = 0; - } - comboBoxDictionaries.AutoCompleteSource = AutoCompleteSource.ListItems; - comboBoxDictionaries.AutoCompleteMode = AutoCompleteMode.Append; - } - - private void FixLargeFonts() - { - if (labelDescription1.Left + labelDescription1.Width + 5 > Width) - { - Width = labelDescription1.Left + labelDescription1.Width + 5; - } - - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void FormGetDictionaries_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#spellcheck"); - e.SuppressKeyPress = true; - } - } - - private void LinkLabel4LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - string dictionaryFolder = Utilities.DictionaryFolder; - if (!Directory.Exists(dictionaryFolder)) - { - Directory.CreateDirectory(dictionaryFolder); - } - - UiUtil.OpenFolder(dictionaryFolder); - } - - private void buttonDownload_Click(object sender, EventArgs e) - { - try - { - labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; - buttonOK.Enabled = false; - buttonDownload.Enabled = false; - buttonDownloadAll.Enabled = false; - comboBoxDictionaries.Enabled = false; - Refresh(); - Cursor = Cursors.WaitCursor; - - int index = comboBoxDictionaries.SelectedIndex; - _downloadLink = _dictionaryDownloadLinks[index]; - string url = _dictionaryDownloadLinks[index]; - SelectedEnglishName = _englishNames[index]; - - var wc = new WebClient { Proxy = Utilities.GetProxy() }; - wc.DownloadDataCompleted += wc_DownloadDataCompleted; - wc.DownloadProgressChanged += (o, args) => - { - labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait + " " + args.ProgressPercentage + "%"; - }; - wc.DownloadDataAsync(new Uri(url)); - } - catch (Exception exception) - { - labelPleaseWait.Text = string.Empty; - buttonOK.Enabled = true; - buttonDownload.Enabled = true; - buttonDownloadAll.Enabled = true; - comboBoxDictionaries.Enabled = true; - Cursor = Cursors.Default; - MessageBox.Show(exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace); - } - } - - private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) - { - Cursor = Cursors.Default; - if (e.Error != null && _xmlName == "Nikse.SubtitleEdit.Resources.HunspellDictionaries.xml.gz") - { - MessageBox.Show("Unable to download " + _downloadLink + Environment.NewLine + - "Switching host - please re-try!"); - LoadDictionaryList("Nikse.SubtitleEdit.Resources.HunspellBackupDictionaries.xml.gz"); - labelPleaseWait.Text = string.Empty; - buttonOK.Enabled = true; - buttonDownload.Enabled = true; - buttonDownloadAll.Enabled = true; - comboBoxDictionaries.Enabled = true; - Cursor = Cursors.Default; - return; - } - - if (e.Error != null) - { - MessageBox.Show(Configuration.Settings.Language.GetTesseractDictionaries.DownloadFailed + Environment.NewLine + - Environment.NewLine + - e.Error.Message); - DialogResult = DialogResult.Cancel; - return; - } - - string dictionaryFolder = Utilities.DictionaryFolder; - if (!Directory.Exists(dictionaryFolder)) - { - Directory.CreateDirectory(dictionaryFolder); - } - - int index = comboBoxDictionaries.SelectedIndex; - - using (var ms = new MemoryStream(e.Result)) - using (ZipExtractor zip = ZipExtractor.Open(ms)) - { - List dir = zip.ReadCentralDir(); - // Extract dic/aff files in dictionary folder - bool found = false; - ExtractDic(dictionaryFolder, zip, dir, ref found); - - if (!found) // check zip inside zip - { - foreach (ZipExtractor.ZipFileEntry entry in dir) - { - if (entry.FilenameInZip.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)) - { - using (var innerMs = new MemoryStream()) - { - zip.ExtractFile(entry, innerMs); - ZipExtractor innerZip = ZipExtractor.Open(innerMs); - List innerDir = innerZip.ReadCentralDir(); - ExtractDic(dictionaryFolder, innerZip, innerDir, ref found); - } - } - } - } - } - - Cursor = Cursors.Default; - labelPleaseWait.Text = string.Empty; - buttonOK.Enabled = true; - buttonDownload.Enabled = true; - buttonDownloadAll.Enabled = true; - comboBoxDictionaries.Enabled = true; - if (_testAllIndex >= 0) - { - DownloadNext(); - return; - } - MessageBox.Show(string.Format(Configuration.Settings.Language.GetDictionaries.XDownloaded, comboBoxDictionaries.Items[index])); - } - - private void ExtractDic(string dictionaryFolder, ZipExtractor zip, List dir, ref bool found) - { - foreach (ZipExtractor.ZipFileEntry entry in dir) - { - if (entry.FilenameInZip.EndsWith(".dic", StringComparison.OrdinalIgnoreCase) || entry.FilenameInZip.EndsWith(".aff", StringComparison.OrdinalIgnoreCase)) - { - string fileName = Path.GetFileName(entry.FilenameInZip); - - // French fix - if (fileName.StartsWith("fr-moderne", StringComparison.Ordinal)) - { - fileName = fileName.Replace("fr-moderne", "fr_FR"); - } - - // German fix - if (fileName.StartsWith("de_DE_frami", StringComparison.Ordinal)) - { - fileName = fileName.Replace("de_DE_frami", "de_DE"); - } - - // Russian fix - if (fileName.StartsWith("russian-aot", StringComparison.Ordinal)) - { - fileName = fileName.Replace("russian-aot", "ru_RU"); - } - - string path = Path.Combine(dictionaryFolder, fileName); - zip.ExtractFile(entry, path); - - found = true; - - LastDownload = fileName; - } - } - } - - private void comboBoxDictionaries_SelectedIndexChanged(object sender, EventArgs e) - { - int index = comboBoxDictionaries.SelectedIndex; - labelPleaseWait.Text = _descriptions[index]; - } - - private void buttonDownloadAll_Click(object sender, EventArgs e) - { - _testAllIndex = comboBoxDictionaries.SelectedIndex - 1; - if (_testAllIndex < -1) - { - _testAllIndex = -1; - } - - DownloadNext(); - } - - private void DownloadNext() - { - _testAllIndex++; - if (_testAllIndex < comboBoxDictionaries.Items.Count) - { - comboBoxDictionaries.SelectedIndex = _testAllIndex; - buttonDownload_Click(null, null); - } - else - { - LoadDictionaryList("Nikse.SubtitleEdit.Resources.HunspellBackupDictionaries.xml.gz"); - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Net; +using System.Windows.Forms; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class GetDictionaries : Form + { + private List _dictionaryDownloadLinks = new List(); + private List _descriptions = new List(); + private List _englishNames = new List(); + private string _xmlName; + private string _downloadLink; + private int _testAllIndex = -1; + + public string SelectedEnglishName { get; private set; } + public string LastDownload { get; private set; } + + public GetDictionaries() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.GetDictionaries.Title; + labelDescription1.Text = Configuration.Settings.Language.GetDictionaries.DescriptionLine1; + labelDescription2.Text = Configuration.Settings.Language.GetDictionaries.DescriptionLine2; + linkLabelOpenDictionaryFolder.Text = Configuration.Settings.Language.GetDictionaries.OpenDictionariesFolder; + labelChooseLanguageAndClickDownload.Text = Configuration.Settings.Language.GetDictionaries.ChooseLanguageAndClickDownload; + buttonDownload.Text = Configuration.Settings.Language.GetDictionaries.Download; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + labelPleaseWait.Text = string.Empty; + + LoadDictionaryList("Nikse.SubtitleEdit.Resources.HunspellDictionaries.xml.gz"); + FixLargeFonts(); +#if DEBUG + buttonDownloadAll.Visible = true; // For testing all download links +#endif + } + + private void LoadDictionaryList(string xmlResourceName) + { + _dictionaryDownloadLinks = new List(); + _descriptions = new List(); + _englishNames = new List(); + _xmlName = xmlResourceName; + System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); + var stream = asm.GetManifestResourceStream(_xmlName); + if (stream != null) + { + comboBoxDictionaries.Items.Clear(); + var doc = new XmlDocument(); + using (var rdr = new StreamReader(stream)) + using (var zip = new GZipStream(rdr.BaseStream, CompressionMode.Decompress)) + using (var reader = XmlReader.Create(zip, new XmlReaderSettings { IgnoreProcessingInstructions = true })) + { + doc.Load(reader); + } + + foreach (XmlNode node in doc.DocumentElement.SelectNodes("Dictionary")) + { + string englishName = node.SelectSingleNode("EnglishName").InnerText; + string nativeName = node.SelectSingleNode("NativeName").InnerText; + string downloadLink = node.SelectSingleNode("DownloadLink").InnerText; + + string description = string.Empty; + if (node.SelectSingleNode("Description") != null) + { + description = node.SelectSingleNode("Description").InnerText; + } + + if (!string.IsNullOrEmpty(downloadLink)) + { + string name = englishName; + if (!string.IsNullOrEmpty(nativeName)) + { + name += " - " + nativeName; + } + + comboBoxDictionaries.Items.Add(name); + _dictionaryDownloadLinks.Add(downloadLink); + _descriptions.Add(description); + _englishNames.Add(englishName); + } + } + comboBoxDictionaries.SelectedIndex = 0; + } + comboBoxDictionaries.AutoCompleteSource = AutoCompleteSource.ListItems; + comboBoxDictionaries.AutoCompleteMode = AutoCompleteMode.Append; + } + + private void FixLargeFonts() + { + if (labelDescription1.Left + labelDescription1.Width + 5 > Width) + { + Width = labelDescription1.Left + labelDescription1.Width + 5; + } + + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void FormGetDictionaries_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#spellcheck"); + e.SuppressKeyPress = true; + } + } + + private void LinkLabel4LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + string dictionaryFolder = Utilities.DictionaryFolder; + if (!Directory.Exists(dictionaryFolder)) + { + Directory.CreateDirectory(dictionaryFolder); + } + + UiUtil.OpenFolder(dictionaryFolder); + } + + private void buttonDownload_Click(object sender, EventArgs e) + { + try + { + labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; + buttonOK.Enabled = false; + buttonDownload.Enabled = false; + buttonDownloadAll.Enabled = false; + comboBoxDictionaries.Enabled = false; + Refresh(); + Cursor = Cursors.WaitCursor; + + int index = comboBoxDictionaries.SelectedIndex; + _downloadLink = _dictionaryDownloadLinks[index]; + string url = _dictionaryDownloadLinks[index]; + SelectedEnglishName = _englishNames[index]; + + var wc = new WebClient { Proxy = Utilities.GetProxy() }; + wc.DownloadDataCompleted += wc_DownloadDataCompleted; + wc.DownloadProgressChanged += (o, args) => + { + labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait + " " + args.ProgressPercentage + "%"; + }; + wc.DownloadDataAsync(new Uri(url)); + } + catch (Exception exception) + { + labelPleaseWait.Text = string.Empty; + buttonOK.Enabled = true; + buttonDownload.Enabled = true; + buttonDownloadAll.Enabled = true; + comboBoxDictionaries.Enabled = true; + Cursor = Cursors.Default; + MessageBox.Show(exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace); + } + } + + private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) + { + Cursor = Cursors.Default; + if (e.Error != null && _xmlName == "Nikse.SubtitleEdit.Resources.HunspellDictionaries.xml.gz") + { + MessageBox.Show("Unable to download " + _downloadLink + Environment.NewLine + + "Switching host - please re-try!"); + LoadDictionaryList("Nikse.SubtitleEdit.Resources.HunspellBackupDictionaries.xml.gz"); + labelPleaseWait.Text = string.Empty; + buttonOK.Enabled = true; + buttonDownload.Enabled = true; + buttonDownloadAll.Enabled = true; + comboBoxDictionaries.Enabled = true; + Cursor = Cursors.Default; + return; + } + + if (e.Error != null) + { + MessageBox.Show(Configuration.Settings.Language.GetTesseractDictionaries.DownloadFailed + Environment.NewLine + + Environment.NewLine + + e.Error.Message); + DialogResult = DialogResult.Cancel; + return; + } + + string dictionaryFolder = Utilities.DictionaryFolder; + if (!Directory.Exists(dictionaryFolder)) + { + Directory.CreateDirectory(dictionaryFolder); + } + + int index = comboBoxDictionaries.SelectedIndex; + + using (var ms = new MemoryStream(e.Result)) + using (ZipExtractor zip = ZipExtractor.Open(ms)) + { + List dir = zip.ReadCentralDir(); + // Extract dic/aff files in dictionary folder + bool found = false; + ExtractDic(dictionaryFolder, zip, dir, ref found); + + if (!found) // check zip inside zip + { + foreach (ZipExtractor.ZipFileEntry entry in dir) + { + if (entry.FilenameInZip.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)) + { + using (var innerMs = new MemoryStream()) + { + zip.ExtractFile(entry, innerMs); + ZipExtractor innerZip = ZipExtractor.Open(innerMs); + List innerDir = innerZip.ReadCentralDir(); + ExtractDic(dictionaryFolder, innerZip, innerDir, ref found); + } + } + } + } + } + + Cursor = Cursors.Default; + labelPleaseWait.Text = string.Empty; + buttonOK.Enabled = true; + buttonDownload.Enabled = true; + buttonDownloadAll.Enabled = true; + comboBoxDictionaries.Enabled = true; + if (_testAllIndex >= 0) + { + DownloadNext(); + return; + } + MessageBox.Show(string.Format(Configuration.Settings.Language.GetDictionaries.XDownloaded, comboBoxDictionaries.Items[index])); + } + + private void ExtractDic(string dictionaryFolder, ZipExtractor zip, List dir, ref bool found) + { + foreach (ZipExtractor.ZipFileEntry entry in dir) + { + if (entry.FilenameInZip.EndsWith(".dic", StringComparison.OrdinalIgnoreCase) || entry.FilenameInZip.EndsWith(".aff", StringComparison.OrdinalIgnoreCase)) + { + string fileName = Path.GetFileName(entry.FilenameInZip); + + // French fix + if (fileName.StartsWith("fr-moderne", StringComparison.Ordinal)) + { + fileName = fileName.Replace("fr-moderne", "fr_FR"); + } + + // German fix + if (fileName.StartsWith("de_DE_frami", StringComparison.Ordinal)) + { + fileName = fileName.Replace("de_DE_frami", "de_DE"); + } + + // Russian fix + if (fileName.StartsWith("russian-aot", StringComparison.Ordinal)) + { + fileName = fileName.Replace("russian-aot", "ru_RU"); + } + + string path = Path.Combine(dictionaryFolder, fileName); + zip.ExtractFile(entry, path); + + found = true; + + LastDownload = fileName; + } + } + } + + private void comboBoxDictionaries_SelectedIndexChanged(object sender, EventArgs e) + { + int index = comboBoxDictionaries.SelectedIndex; + labelPleaseWait.Text = _descriptions[index]; + } + + private void buttonDownloadAll_Click(object sender, EventArgs e) + { + _testAllIndex = comboBoxDictionaries.SelectedIndex - 1; + if (_testAllIndex < -1) + { + _testAllIndex = -1; + } + + DownloadNext(); + } + + private void DownloadNext() + { + _testAllIndex++; + if (_testAllIndex < comboBoxDictionaries.Items.Count) + { + comboBoxDictionaries.SelectedIndex = _testAllIndex; + buttonDownload_Click(null, null); + } + else + { + LoadDictionaryList("Nikse.SubtitleEdit.Resources.HunspellBackupDictionaries.xml.gz"); + } + } + + } +} diff --git a/src/Forms/GetDictionaries.resx b/src/ui/Forms/GetDictionaries.resx similarity index 97% rename from src/Forms/GetDictionaries.resx rename to src/ui/Forms/GetDictionaries.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/GetDictionaries.resx +++ b/src/ui/Forms/GetDictionaries.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/GoToLine.Designer.cs b/src/ui/Forms/GoToLine.Designer.cs similarity index 97% rename from src/Forms/GoToLine.Designer.cs rename to src/ui/Forms/GoToLine.Designer.cs index 51a8b7258..9b5930987 100644 --- a/src/Forms/GoToLine.Designer.cs +++ b/src/ui/Forms/GoToLine.Designer.cs @@ -1,90 +1,90 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class GoToLine - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GoToLine)); - this.labelGoToLine = new System.Windows.Forms.Label(); - this.buttonOK = new System.Windows.Forms.Button(); - this.textBox1 = new System.Windows.Forms.TextBox(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // labelGoToLine - // - resources.ApplyResources(this.labelGoToLine, "labelGoToLine"); - this.labelGoToLine.Name = "labelGoToLine"; - // - // buttonOK - // - resources.ApplyResources(this.buttonOK, "buttonOK"); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // textBox1 - // - resources.ApplyResources(this.textBox1, "textBox1"); - this.textBox1.Name = "textBox1"; - this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBox1KeyDown); - // - // buttonCancel - // - resources.ApplyResources(this.buttonCancel, "buttonCancel"); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); - // - // GoToLine - // - resources.ApplyResources(this, "$this"); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.textBox1); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.labelGoToLine); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "GoToLine"; - this.ShowInTaskbar = false; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormGoToLine_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelGoToLine; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.TextBox textBox1; - private System.Windows.Forms.Button buttonCancel; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class GoToLine + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GoToLine)); + this.labelGoToLine = new System.Windows.Forms.Label(); + this.buttonOK = new System.Windows.Forms.Button(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // labelGoToLine + // + resources.ApplyResources(this.labelGoToLine, "labelGoToLine"); + this.labelGoToLine.Name = "labelGoToLine"; + // + // buttonOK + // + resources.ApplyResources(this.buttonOK, "buttonOK"); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // textBox1 + // + resources.ApplyResources(this.textBox1, "textBox1"); + this.textBox1.Name = "textBox1"; + this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBox1KeyDown); + // + // buttonCancel + // + resources.ApplyResources(this.buttonCancel, "buttonCancel"); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); + // + // GoToLine + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.labelGoToLine); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "GoToLine"; + this.ShowInTaskbar = false; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormGoToLine_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelGoToLine; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button buttonCancel; + } } \ No newline at end of file diff --git a/src/Forms/GoToLine.cs b/src/ui/Forms/GoToLine.cs similarity index 97% rename from src/Forms/GoToLine.cs rename to src/ui/Forms/GoToLine.cs index bbcc11de3..41f631b0f 100644 --- a/src/Forms/GoToLine.cs +++ b/src/ui/Forms/GoToLine.cs @@ -1,108 +1,108 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class GoToLine : Form - { - private int _max; - private int _min; - private int _lineNumber; - - public GoToLine() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Icon = Properties.Resources.SubtitleEditFormIcon; - Text = Configuration.Settings.Language.GoToLine.Title; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - } - - public int LineNumber => _lineNumber; - - public void Initialize(int min, int max) - { - _min = min; - _max = max; - labelGoToLine.Text = string.Format(Text + " ({0} - {1})", min, max); - } - - private void FormGoToLine_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void TextBox1KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - Validate(textBox1.Text); - } - else - { - if (e.KeyCode == Keys.D0 || - e.KeyCode == Keys.D1 || - e.KeyCode == Keys.D2 || - e.KeyCode == Keys.D3 || - e.KeyCode == Keys.D4 || - e.KeyCode == Keys.D5 || - e.KeyCode == Keys.D6 || - e.KeyCode == Keys.D7 || - e.KeyCode == Keys.D8 || - e.KeyCode == Keys.D9 || - e.KeyCode == Keys.Delete || - e.KeyCode == Keys.Left || - e.KeyCode == Keys.Right || - e.KeyCode == Keys.Back || - e.KeyCode == Keys.Home || - e.KeyCode == Keys.End || - e.KeyValue >= 96 && e.KeyValue <= 105) - { - } - else if (e.KeyData == (Keys.Control | Keys.V) && Clipboard.GetText(TextDataFormat.UnicodeText).Length > 0) - { - string p = Clipboard.GetText(TextDataFormat.UnicodeText); - if (!int.TryParse(p, out _)) - { - e.SuppressKeyPress = true; - } - } - else if (e.Modifiers != Keys.Control && e.Modifiers != Keys.Alt) - { - e.SuppressKeyPress = true; - } - } - } - - private void ButtonOkClick(object sender, EventArgs e) - { - Validate(textBox1.Text); - } - - private void ButtonCancelClick(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void Validate(string inp) - { - if (int.TryParse(inp, out _lineNumber) && _lineNumber >= _min && _lineNumber <= _max) - { - DialogResult = DialogResult.OK; - } - else - { - MessageBox.Show(string.Format(Configuration.Settings.Language.GoToLine.XIsNotAValidNumber, textBox1.Text)); - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class GoToLine : Form + { + private int _max; + private int _min; + private int _lineNumber; + + public GoToLine() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Icon = Properties.Resources.SubtitleEditFormIcon; + Text = Configuration.Settings.Language.GoToLine.Title; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + } + + public int LineNumber => _lineNumber; + + public void Initialize(int min, int max) + { + _min = min; + _max = max; + labelGoToLine.Text = string.Format(Text + " ({0} - {1})", min, max); + } + + private void FormGoToLine_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void TextBox1KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + Validate(textBox1.Text); + } + else + { + if (e.KeyCode == Keys.D0 || + e.KeyCode == Keys.D1 || + e.KeyCode == Keys.D2 || + e.KeyCode == Keys.D3 || + e.KeyCode == Keys.D4 || + e.KeyCode == Keys.D5 || + e.KeyCode == Keys.D6 || + e.KeyCode == Keys.D7 || + e.KeyCode == Keys.D8 || + e.KeyCode == Keys.D9 || + e.KeyCode == Keys.Delete || + e.KeyCode == Keys.Left || + e.KeyCode == Keys.Right || + e.KeyCode == Keys.Back || + e.KeyCode == Keys.Home || + e.KeyCode == Keys.End || + e.KeyValue >= 96 && e.KeyValue <= 105) + { + } + else if (e.KeyData == (Keys.Control | Keys.V) && Clipboard.GetText(TextDataFormat.UnicodeText).Length > 0) + { + string p = Clipboard.GetText(TextDataFormat.UnicodeText); + if (!int.TryParse(p, out _)) + { + e.SuppressKeyPress = true; + } + } + else if (e.Modifiers != Keys.Control && e.Modifiers != Keys.Alt) + { + e.SuppressKeyPress = true; + } + } + } + + private void ButtonOkClick(object sender, EventArgs e) + { + Validate(textBox1.Text); + } + + private void ButtonCancelClick(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void Validate(string inp) + { + if (int.TryParse(inp, out _lineNumber) && _lineNumber >= _min && _lineNumber <= _max) + { + DialogResult = DialogResult.OK; + } + else + { + MessageBox.Show(string.Format(Configuration.Settings.Language.GoToLine.XIsNotAValidNumber, textBox1.Text)); + } + } + } +} diff --git a/src/Forms/GoToLine.resx b/src/ui/Forms/GoToLine.resx similarity index 97% rename from src/Forms/GoToLine.resx rename to src/ui/Forms/GoToLine.resx index bc991d283..5d5fb3e73 100644 --- a/src/Forms/GoToLine.resx +++ b/src/ui/Forms/GoToLine.resx @@ -1,246 +1,246 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - True - - - - 12, 9 - - - 73, 13 - - - 0 - - - labelGoToLine - - - labelGoToLine - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - - - 12, 52 - - - 75, 23 - - - 1 - - - &OK - - - buttonOK - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - - - 15, 25 - - - 100, 21 - - - 0 - - - textBox1 - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - - NoControl - - - 93, 52 - - - 75, 23 - - - 2 - - - C&ancel - - - buttonCancel - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - True - - - 6, 13 - - - 243, 88 - - - Tahoma, 8.25pt - - - CenterParent - - - Go to line - - - GoToLine - - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + True + + + + 12, 9 + + + 73, 13 + + + 0 + + + labelGoToLine + + + labelGoToLine + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + 12, 52 + + + 75, 23 + + + 1 + + + &OK + + + buttonOK + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + 15, 25 + + + 100, 21 + + + 0 + + + textBox1 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + + NoControl + + + 93, 52 + + + 75, 23 + + + 2 + + + C&ancel + + + buttonCancel + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + True + + + 6, 13 + + + 243, 88 + + + Tahoma, 8.25pt + + + CenterParent + + + Go to line + + + GoToLine + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/GoogleOrMicrosoftTranslate.Designer.cs b/src/ui/Forms/GoogleOrMicrosoftTranslate.Designer.cs similarity index 97% rename from src/Forms/GoogleOrMicrosoftTranslate.Designer.cs rename to src/ui/Forms/GoogleOrMicrosoftTranslate.Designer.cs index c8b82d349..2421067d6 100644 --- a/src/Forms/GoogleOrMicrosoftTranslate.Designer.cs +++ b/src/ui/Forms/GoogleOrMicrosoftTranslate.Designer.cs @@ -1,202 +1,202 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class GoogleOrMicrosoftTranslate - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonMicrosoft = new System.Windows.Forms.Button(); - this.buttonGoogle = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.labelGoogleTranslate = new System.Windows.Forms.Label(); - this.labelMicrosoftTranslate = new System.Windows.Forms.Label(); - this.comboBoxFrom = new System.Windows.Forms.ComboBox(); - this.buttonTranslate = new System.Windows.Forms.Button(); - this.labelTo = new System.Windows.Forms.Label(); - this.comboBoxTo = new System.Windows.Forms.ComboBox(); - this.labelFrom = new System.Windows.Forms.Label(); - this.textBoxSourceText = new System.Windows.Forms.TextBox(); - this.labelSourceText = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // buttonMicrosoft - // - this.buttonMicrosoft.Location = new System.Drawing.Point(322, 164); - this.buttonMicrosoft.Name = "buttonMicrosoft"; - this.buttonMicrosoft.Size = new System.Drawing.Size(304, 55); - this.buttonMicrosoft.TabIndex = 5; - this.buttonMicrosoft.UseVisualStyleBackColor = true; - this.buttonMicrosoft.Click += new System.EventHandler(this.buttonMicrosoft_Click); - // - // buttonGoogle - // - this.buttonGoogle.Location = new System.Drawing.Point(12, 164); - this.buttonGoogle.Name = "buttonGoogle"; - this.buttonGoogle.Size = new System.Drawing.Size(304, 55); - this.buttonGoogle.TabIndex = 4; - this.buttonGoogle.UseVisualStyleBackColor = true; - this.buttonGoogle.Click += new System.EventHandler(this.buttonGoogle_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(551, 227); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 6; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // labelGoogleTranslate - // - this.labelGoogleTranslate.AutoSize = true; - this.labelGoogleTranslate.Location = new System.Drawing.Point(14, 148); - this.labelGoogleTranslate.Name = "labelGoogleTranslate"; - this.labelGoogleTranslate.Size = new System.Drawing.Size(84, 13); - this.labelGoogleTranslate.TabIndex = 20; - this.labelGoogleTranslate.Text = "Google translate"; - // - // labelMicrosoftTranslate - // - this.labelMicrosoftTranslate.AutoSize = true; - this.labelMicrosoftTranslate.Location = new System.Drawing.Point(319, 148); - this.labelMicrosoftTranslate.Name = "labelMicrosoftTranslate"; - this.labelMicrosoftTranslate.Size = new System.Drawing.Size(93, 13); - this.labelMicrosoftTranslate.TabIndex = 21; - this.labelMicrosoftTranslate.Text = "Microsoft translate"; - // - // comboBoxFrom - // - this.comboBoxFrom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxFrom.FormattingEnabled = true; - this.comboBoxFrom.Location = new System.Drawing.Point(256, 12); - this.comboBoxFrom.Name = "comboBoxFrom"; - this.comboBoxFrom.Size = new System.Drawing.Size(121, 21); - this.comboBoxFrom.TabIndex = 0; - // - // buttonTranslate - // - this.buttonTranslate.Location = new System.Drawing.Point(553, 12); - this.buttonTranslate.Name = "buttonTranslate"; - this.buttonTranslate.Size = new System.Drawing.Size(75, 23); - this.buttonTranslate.TabIndex = 2; - this.buttonTranslate.Text = "Translate"; - this.buttonTranslate.UseVisualStyleBackColor = true; - this.buttonTranslate.Click += new System.EventHandler(this.buttonTranslate_Click); - // - // labelTo - // - this.labelTo.AutoSize = true; - this.labelTo.Location = new System.Drawing.Point(397, 15); - this.labelTo.Name = "labelTo"; - this.labelTo.Size = new System.Drawing.Size(23, 13); - this.labelTo.TabIndex = 25; - this.labelTo.Text = "To:"; - // - // comboBoxTo - // - this.comboBoxTo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxTo.FormattingEnabled = true; - this.comboBoxTo.Location = new System.Drawing.Point(426, 12); - this.comboBoxTo.Name = "comboBoxTo"; - this.comboBoxTo.Size = new System.Drawing.Size(121, 21); - this.comboBoxTo.TabIndex = 1; - // - // labelFrom - // - this.labelFrom.AutoSize = true; - this.labelFrom.Location = new System.Drawing.Point(214, 19); - this.labelFrom.Name = "labelFrom"; - this.labelFrom.Size = new System.Drawing.Size(33, 13); - this.labelFrom.TabIndex = 23; - this.labelFrom.Text = "From:"; - // - // textBoxSourceText - // - this.textBoxSourceText.Location = new System.Drawing.Point(17, 71); - this.textBoxSourceText.Multiline = true; - this.textBoxSourceText.Name = "textBoxSourceText"; - this.textBoxSourceText.Size = new System.Drawing.Size(299, 53); - this.textBoxSourceText.TabIndex = 3; - // - // labelSourceText - // - this.labelSourceText.AutoSize = true; - this.labelSourceText.Location = new System.Drawing.Point(14, 55); - this.labelSourceText.Name = "labelSourceText"; - this.labelSourceText.Size = new System.Drawing.Size(61, 13); - this.labelSourceText.TabIndex = 28; - this.labelSourceText.Text = "Source text"; - // - // GoogleOrMicrosoftTranslate - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(638, 260); - this.Controls.Add(this.labelSourceText); - this.Controls.Add(this.textBoxSourceText); - this.Controls.Add(this.comboBoxFrom); - this.Controls.Add(this.buttonTranslate); - this.Controls.Add(this.labelTo); - this.Controls.Add(this.comboBoxTo); - this.Controls.Add(this.labelFrom); - this.Controls.Add(this.labelMicrosoftTranslate); - this.Controls.Add(this.labelGoogleTranslate); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonGoogle); - this.Controls.Add(this.buttonMicrosoft); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "GoogleOrMicrosoftTranslate"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "GoogleOrMicrosoftTranslate"; - this.Shown += new System.EventHandler(this.GoogleOrMicrosoftTranslate_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GoogleOrMicrosoftTranslate_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonMicrosoft; - private System.Windows.Forms.Button buttonGoogle; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Label labelGoogleTranslate; - private System.Windows.Forms.Label labelMicrosoftTranslate; - private System.Windows.Forms.ComboBox comboBoxFrom; - private System.Windows.Forms.Button buttonTranslate; - private System.Windows.Forms.Label labelTo; - private System.Windows.Forms.ComboBox comboBoxTo; - private System.Windows.Forms.Label labelFrom; - private System.Windows.Forms.TextBox textBoxSourceText; - private System.Windows.Forms.Label labelSourceText; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class GoogleOrMicrosoftTranslate + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonMicrosoft = new System.Windows.Forms.Button(); + this.buttonGoogle = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.labelGoogleTranslate = new System.Windows.Forms.Label(); + this.labelMicrosoftTranslate = new System.Windows.Forms.Label(); + this.comboBoxFrom = new System.Windows.Forms.ComboBox(); + this.buttonTranslate = new System.Windows.Forms.Button(); + this.labelTo = new System.Windows.Forms.Label(); + this.comboBoxTo = new System.Windows.Forms.ComboBox(); + this.labelFrom = new System.Windows.Forms.Label(); + this.textBoxSourceText = new System.Windows.Forms.TextBox(); + this.labelSourceText = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonMicrosoft + // + this.buttonMicrosoft.Location = new System.Drawing.Point(322, 164); + this.buttonMicrosoft.Name = "buttonMicrosoft"; + this.buttonMicrosoft.Size = new System.Drawing.Size(304, 55); + this.buttonMicrosoft.TabIndex = 5; + this.buttonMicrosoft.UseVisualStyleBackColor = true; + this.buttonMicrosoft.Click += new System.EventHandler(this.buttonMicrosoft_Click); + // + // buttonGoogle + // + this.buttonGoogle.Location = new System.Drawing.Point(12, 164); + this.buttonGoogle.Name = "buttonGoogle"; + this.buttonGoogle.Size = new System.Drawing.Size(304, 55); + this.buttonGoogle.TabIndex = 4; + this.buttonGoogle.UseVisualStyleBackColor = true; + this.buttonGoogle.Click += new System.EventHandler(this.buttonGoogle_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(551, 227); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // labelGoogleTranslate + // + this.labelGoogleTranslate.AutoSize = true; + this.labelGoogleTranslate.Location = new System.Drawing.Point(14, 148); + this.labelGoogleTranslate.Name = "labelGoogleTranslate"; + this.labelGoogleTranslate.Size = new System.Drawing.Size(84, 13); + this.labelGoogleTranslate.TabIndex = 20; + this.labelGoogleTranslate.Text = "Google translate"; + // + // labelMicrosoftTranslate + // + this.labelMicrosoftTranslate.AutoSize = true; + this.labelMicrosoftTranslate.Location = new System.Drawing.Point(319, 148); + this.labelMicrosoftTranslate.Name = "labelMicrosoftTranslate"; + this.labelMicrosoftTranslate.Size = new System.Drawing.Size(93, 13); + this.labelMicrosoftTranslate.TabIndex = 21; + this.labelMicrosoftTranslate.Text = "Microsoft translate"; + // + // comboBoxFrom + // + this.comboBoxFrom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxFrom.FormattingEnabled = true; + this.comboBoxFrom.Location = new System.Drawing.Point(256, 12); + this.comboBoxFrom.Name = "comboBoxFrom"; + this.comboBoxFrom.Size = new System.Drawing.Size(121, 21); + this.comboBoxFrom.TabIndex = 0; + // + // buttonTranslate + // + this.buttonTranslate.Location = new System.Drawing.Point(553, 12); + this.buttonTranslate.Name = "buttonTranslate"; + this.buttonTranslate.Size = new System.Drawing.Size(75, 23); + this.buttonTranslate.TabIndex = 2; + this.buttonTranslate.Text = "Translate"; + this.buttonTranslate.UseVisualStyleBackColor = true; + this.buttonTranslate.Click += new System.EventHandler(this.buttonTranslate_Click); + // + // labelTo + // + this.labelTo.AutoSize = true; + this.labelTo.Location = new System.Drawing.Point(397, 15); + this.labelTo.Name = "labelTo"; + this.labelTo.Size = new System.Drawing.Size(23, 13); + this.labelTo.TabIndex = 25; + this.labelTo.Text = "To:"; + // + // comboBoxTo + // + this.comboBoxTo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxTo.FormattingEnabled = true; + this.comboBoxTo.Location = new System.Drawing.Point(426, 12); + this.comboBoxTo.Name = "comboBoxTo"; + this.comboBoxTo.Size = new System.Drawing.Size(121, 21); + this.comboBoxTo.TabIndex = 1; + // + // labelFrom + // + this.labelFrom.AutoSize = true; + this.labelFrom.Location = new System.Drawing.Point(214, 19); + this.labelFrom.Name = "labelFrom"; + this.labelFrom.Size = new System.Drawing.Size(33, 13); + this.labelFrom.TabIndex = 23; + this.labelFrom.Text = "From:"; + // + // textBoxSourceText + // + this.textBoxSourceText.Location = new System.Drawing.Point(17, 71); + this.textBoxSourceText.Multiline = true; + this.textBoxSourceText.Name = "textBoxSourceText"; + this.textBoxSourceText.Size = new System.Drawing.Size(299, 53); + this.textBoxSourceText.TabIndex = 3; + // + // labelSourceText + // + this.labelSourceText.AutoSize = true; + this.labelSourceText.Location = new System.Drawing.Point(14, 55); + this.labelSourceText.Name = "labelSourceText"; + this.labelSourceText.Size = new System.Drawing.Size(61, 13); + this.labelSourceText.TabIndex = 28; + this.labelSourceText.Text = "Source text"; + // + // GoogleOrMicrosoftTranslate + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(638, 260); + this.Controls.Add(this.labelSourceText); + this.Controls.Add(this.textBoxSourceText); + this.Controls.Add(this.comboBoxFrom); + this.Controls.Add(this.buttonTranslate); + this.Controls.Add(this.labelTo); + this.Controls.Add(this.comboBoxTo); + this.Controls.Add(this.labelFrom); + this.Controls.Add(this.labelMicrosoftTranslate); + this.Controls.Add(this.labelGoogleTranslate); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonGoogle); + this.Controls.Add(this.buttonMicrosoft); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "GoogleOrMicrosoftTranslate"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "GoogleOrMicrosoftTranslate"; + this.Shown += new System.EventHandler(this.GoogleOrMicrosoftTranslate_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GoogleOrMicrosoftTranslate_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonMicrosoft; + private System.Windows.Forms.Button buttonGoogle; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Label labelGoogleTranslate; + private System.Windows.Forms.Label labelMicrosoftTranslate; + private System.Windows.Forms.ComboBox comboBoxFrom; + private System.Windows.Forms.Button buttonTranslate; + private System.Windows.Forms.Label labelTo; + private System.Windows.Forms.ComboBox comboBoxTo; + private System.Windows.Forms.Label labelFrom; + private System.Windows.Forms.TextBox textBoxSourceText; + private System.Windows.Forms.Label labelSourceText; + } } \ No newline at end of file diff --git a/src/Forms/GoogleOrMicrosoftTranslate.cs b/src/ui/Forms/GoogleOrMicrosoftTranslate.cs similarity index 97% rename from src/Forms/GoogleOrMicrosoftTranslate.cs rename to src/ui/Forms/GoogleOrMicrosoftTranslate.cs index 430447352..62381a93e 100644 --- a/src/Forms/GoogleOrMicrosoftTranslate.cs +++ b/src/ui/Forms/GoogleOrMicrosoftTranslate.cs @@ -1,176 +1,176 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; -using Nikse.SubtitleEdit.Core.Translate; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class GoogleOrMicrosoftTranslate : Form - { - public string TranslatedText { get; set; } - - public GoogleOrMicrosoftTranslate() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - using (var gt = new GoogleTranslate()) - { - gt.FillComboWithGoogleLanguages(comboBoxFrom); - gt.FillComboWithGoogleLanguages(comboBoxTo); - } - RemovedLanguagesNotInMicrosoftTranslate(comboBoxFrom); - RemovedLanguagesNotInMicrosoftTranslate(comboBoxTo); - - Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.Title; - labelGoogleTranslate.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.GoogleTranslate; - labelMicrosoftTranslate.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.MicrosoftTranslate; - labelFrom.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.From; - labelTo.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.To; - labelSourceText.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.SourceText; - buttonGoogle.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.GoogleTranslate; - buttonMicrosoft.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.MicrosoftTranslate; - buttonTranslate.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.Translate; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonCancel); - buttonGoogle.Text = string.Empty; - buttonMicrosoft.Text = string.Empty; - } - - private static void RemovedLanguagesNotInMicrosoftTranslate(ComboBox comboBox) - { - for (int i = comboBox.Items.Count - 1; i > 0; i--) - { - var item = (GoogleTranslate.ComboBoxItem)comboBox.Items[i]; - if (item.Value != FixMsLocale(item.Value)) - { - comboBox.Items.RemoveAt(i); - } - } - } - - internal void InitializeFromLanguage(string defaultFromLanguage) - { - string defaultToLanguage = Configuration.Settings.Tools.GoogleTranslateLastTargetLanguage; - if (defaultToLanguage == defaultFromLanguage) - { - foreach (string s in Utilities.GetDictionaryLanguages()) - { - string temp = s.Replace("[", string.Empty).Replace("]", string.Empty); - if (temp.Length > 4) - { - temp = temp.Substring(temp.Length - 5, 2).ToLowerInvariant(); - - if (temp != defaultToLanguage) - { - defaultToLanguage = temp; - break; - } - } - } - } - - int i = 0; - comboBoxFrom.SelectedIndex = 0; - foreach (GoogleTranslate.ComboBoxItem item in comboBoxFrom.Items) - { - if (item.Value == defaultFromLanguage) - { - comboBoxFrom.SelectedIndex = i; - break; - } - i++; - } - - i = 0; - comboBoxTo.SelectedIndex = 0; - foreach (GoogleTranslate.ComboBoxItem item in comboBoxTo.Items) - { - if (item.Value == defaultToLanguage) - { - comboBoxTo.SelectedIndex = i; - break; - } - i++; - } - } - - internal void Initialize(Paragraph paragraph) - { - textBoxSourceText.Text = paragraph.Text; - } - - private void GoogleOrMicrosoftTranslate_Shown(object sender, EventArgs e) - { - Refresh(); - Translate(); - } - - private void Translate() - { - Cursor = Cursors.WaitCursor; - try - { - string from = ((GoogleTranslate.ComboBoxItem)comboBoxFrom.SelectedItem).Value; - string to = ((GoogleTranslate.ComboBoxItem)comboBoxTo.SelectedItem).Value; - buttonGoogle.Text = string.Empty; - - // google translate - buttonGoogle.Text = new GoogleTranslator1().Translate(from, to, new List { new Paragraph { Text = textBoxSourceText.Text } }, new StringBuilder()).FirstOrDefault(); - - // ms translator - if (!string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorApiKey) && !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint)) - { - var translator = new MicrosoftTranslator(Configuration.Settings.Tools.MicrosoftTranslatorApiKey, Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint, Configuration.Settings.Tools.MicrosoftTranslatorCategory); - var result = translator.Translate(from, to, new List { new Paragraph { Text = textBoxSourceText.Text } }, new StringBuilder()); - buttonMicrosoft.Text = result[0]; - } - } - finally - { - Cursor = Cursors.Default; - } - } - - private static string FixMsLocale(string from) - { - if ("ar bg zh-CHS zh-CHT cs da nl en et fi fr de el ht he hu id it ja ko lv lt no pl pt ro ru sk sl es sv th tr uk vi".Contains(from)) - { - return from; - } - - return "en"; - } - - private void buttonTranslate_Click(object sender, EventArgs e) - { - Translate(); - } - - private void buttonGoogle_Click(object sender, EventArgs e) - { - TranslatedText = buttonGoogle.Text; - DialogResult = DialogResult.OK; - } - - private void buttonMicrosoft_Click(object sender, EventArgs e) - { - TranslatedText = buttonMicrosoft.Text; - DialogResult = DialogResult.OK; - } - - private void GoogleOrMicrosoftTranslate_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Core.Translate; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class GoogleOrMicrosoftTranslate : Form + { + public string TranslatedText { get; set; } + + public GoogleOrMicrosoftTranslate() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + using (var gt = new GoogleTranslate()) + { + gt.FillComboWithGoogleLanguages(comboBoxFrom); + gt.FillComboWithGoogleLanguages(comboBoxTo); + } + RemovedLanguagesNotInMicrosoftTranslate(comboBoxFrom); + RemovedLanguagesNotInMicrosoftTranslate(comboBoxTo); + + Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.Title; + labelGoogleTranslate.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.GoogleTranslate; + labelMicrosoftTranslate.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.MicrosoftTranslate; + labelFrom.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.From; + labelTo.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.To; + labelSourceText.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.SourceText; + buttonGoogle.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.GoogleTranslate; + buttonMicrosoft.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.MicrosoftTranslate; + buttonTranslate.Text = Configuration.Settings.Language.GoogleOrMicrosoftTranslate.Translate; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonCancel); + buttonGoogle.Text = string.Empty; + buttonMicrosoft.Text = string.Empty; + } + + private static void RemovedLanguagesNotInMicrosoftTranslate(ComboBox comboBox) + { + for (int i = comboBox.Items.Count - 1; i > 0; i--) + { + var item = (GoogleTranslate.ComboBoxItem)comboBox.Items[i]; + if (item.Value != FixMsLocale(item.Value)) + { + comboBox.Items.RemoveAt(i); + } + } + } + + internal void InitializeFromLanguage(string defaultFromLanguage) + { + string defaultToLanguage = Configuration.Settings.Tools.GoogleTranslateLastTargetLanguage; + if (defaultToLanguage == defaultFromLanguage) + { + foreach (string s in Utilities.GetDictionaryLanguages()) + { + string temp = s.Replace("[", string.Empty).Replace("]", string.Empty); + if (temp.Length > 4) + { + temp = temp.Substring(temp.Length - 5, 2).ToLowerInvariant(); + + if (temp != defaultToLanguage) + { + defaultToLanguage = temp; + break; + } + } + } + } + + int i = 0; + comboBoxFrom.SelectedIndex = 0; + foreach (GoogleTranslate.ComboBoxItem item in comboBoxFrom.Items) + { + if (item.Value == defaultFromLanguage) + { + comboBoxFrom.SelectedIndex = i; + break; + } + i++; + } + + i = 0; + comboBoxTo.SelectedIndex = 0; + foreach (GoogleTranslate.ComboBoxItem item in comboBoxTo.Items) + { + if (item.Value == defaultToLanguage) + { + comboBoxTo.SelectedIndex = i; + break; + } + i++; + } + } + + internal void Initialize(Paragraph paragraph) + { + textBoxSourceText.Text = paragraph.Text; + } + + private void GoogleOrMicrosoftTranslate_Shown(object sender, EventArgs e) + { + Refresh(); + Translate(); + } + + private void Translate() + { + Cursor = Cursors.WaitCursor; + try + { + string from = ((GoogleTranslate.ComboBoxItem)comboBoxFrom.SelectedItem).Value; + string to = ((GoogleTranslate.ComboBoxItem)comboBoxTo.SelectedItem).Value; + buttonGoogle.Text = string.Empty; + + // google translate + buttonGoogle.Text = new GoogleTranslator1().Translate(from, to, new List { new Paragraph { Text = textBoxSourceText.Text } }, new StringBuilder()).FirstOrDefault(); + + // ms translator + if (!string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorApiKey) && !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint)) + { + var translator = new MicrosoftTranslator(Configuration.Settings.Tools.MicrosoftTranslatorApiKey, Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint, Configuration.Settings.Tools.MicrosoftTranslatorCategory); + var result = translator.Translate(from, to, new List { new Paragraph { Text = textBoxSourceText.Text } }, new StringBuilder()); + buttonMicrosoft.Text = result[0]; + } + } + finally + { + Cursor = Cursors.Default; + } + } + + private static string FixMsLocale(string from) + { + if ("ar bg zh-CHS zh-CHT cs da nl en et fi fr de el ht he hu id it ja ko lv lt no pl pt ro ru sk sl es sv th tr uk vi".Contains(from)) + { + return from; + } + + return "en"; + } + + private void buttonTranslate_Click(object sender, EventArgs e) + { + Translate(); + } + + private void buttonGoogle_Click(object sender, EventArgs e) + { + TranslatedText = buttonGoogle.Text; + DialogResult = DialogResult.OK; + } + + private void buttonMicrosoft_Click(object sender, EventArgs e) + { + TranslatedText = buttonMicrosoft.Text; + DialogResult = DialogResult.OK; + } + + private void GoogleOrMicrosoftTranslate_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + } +} diff --git a/src/Forms/Ocr/DownloadTesseract4.resx b/src/ui/Forms/GoogleOrMicrosoftTranslate.resx similarity index 100% rename from src/Forms/Ocr/DownloadTesseract4.resx rename to src/ui/Forms/GoogleOrMicrosoftTranslate.resx diff --git a/src/Forms/GoogleTranslate.Designer.cs b/src/ui/Forms/GoogleTranslate.Designer.cs similarity index 98% rename from src/Forms/GoogleTranslate.Designer.cs rename to src/ui/Forms/GoogleTranslate.Designer.cs index 0e134f6f0..9452b3305 100644 --- a/src/Forms/GoogleTranslate.Designer.cs +++ b/src/ui/Forms/GoogleTranslate.Designer.cs @@ -1,251 +1,251 @@ -using Nikse.SubtitleEdit.Controls; - -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class GoogleTranslate - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.comboBoxFrom = new System.Windows.Forms.ComboBox(); - this.labelFrom = new System.Windows.Forms.Label(); - this.labelTo = new System.Windows.Forms.Label(); - this.comboBoxTo = new System.Windows.Forms.ComboBox(); - this.buttonTranslate = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.linkLabelPoweredByGoogleTranslate = new System.Windows.Forms.LinkLabel(); - this.labelPleaseWait = new System.Windows.Forms.Label(); - this.progressBar1 = new System.Windows.Forms.ProgressBar(); - this.subtitleListViewTo = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.subtitleListViewFrom = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.labelApiKeyNotFound = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // comboBoxFrom - // - this.comboBoxFrom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxFrom.FormattingEnabled = true; - this.comboBoxFrom.Location = new System.Drawing.Point(327, 34); - this.comboBoxFrom.Name = "comboBoxFrom"; - this.comboBoxFrom.Size = new System.Drawing.Size(121, 21); - this.comboBoxFrom.TabIndex = 0; - // - // labelFrom - // - this.labelFrom.AutoSize = true; - this.labelFrom.Location = new System.Drawing.Point(285, 41); - this.labelFrom.Name = "labelFrom"; - this.labelFrom.Size = new System.Drawing.Size(35, 13); - this.labelFrom.TabIndex = 1; - this.labelFrom.Text = "From:"; - // - // labelTo - // - this.labelTo.AutoSize = true; - this.labelTo.Location = new System.Drawing.Point(468, 37); - this.labelTo.Name = "labelTo"; - this.labelTo.Size = new System.Drawing.Size(23, 13); - this.labelTo.TabIndex = 4; - this.labelTo.Text = "To:"; - // - // comboBoxTo - // - this.comboBoxTo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxTo.FormattingEnabled = true; - this.comboBoxTo.Location = new System.Drawing.Point(497, 34); - this.comboBoxTo.Name = "comboBoxTo"; - this.comboBoxTo.Size = new System.Drawing.Size(121, 21); - this.comboBoxTo.TabIndex = 3; - // - // buttonTranslate - // - this.buttonTranslate.Location = new System.Drawing.Point(624, 34); - this.buttonTranslate.Name = "buttonTranslate"; - this.buttonTranslate.Size = new System.Drawing.Size(75, 23); - this.buttonTranslate.TabIndex = 5; - this.buttonTranslate.Text = "Translate"; - this.buttonTranslate.UseVisualStyleBackColor = true; - this.buttonTranslate.Click += new System.EventHandler(this.buttonTranslate_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(754, 529); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 6; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(835, 529); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 7; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // linkLabelPoweredByGoogleTranslate - // - this.linkLabelPoweredByGoogleTranslate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.linkLabelPoweredByGoogleTranslate.AutoSize = true; - this.linkLabelPoweredByGoogleTranslate.Location = new System.Drawing.Point(15, 529); - this.linkLabelPoweredByGoogleTranslate.Name = "linkLabelPoweredByGoogleTranslate"; - this.linkLabelPoweredByGoogleTranslate.Size = new System.Drawing.Size(146, 13); - this.linkLabelPoweredByGoogleTranslate.TabIndex = 8; - this.linkLabelPoweredByGoogleTranslate.TabStop = true; - this.linkLabelPoweredByGoogleTranslate.Text = "Powered by Google translate"; - this.linkLabelPoweredByGoogleTranslate.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel1LinkClicked); - // - // labelPleaseWait - // - this.labelPleaseWait.AutoSize = true; - this.labelPleaseWait.Location = new System.Drawing.Point(703, 23); - this.labelPleaseWait.Name = "labelPleaseWait"; - this.labelPleaseWait.Size = new System.Drawing.Size(176, 13); - this.labelPleaseWait.TabIndex = 10; - this.labelPleaseWait.Text = "Please wait... this may take a while"; - // - // progressBar1 - // - this.progressBar1.Location = new System.Drawing.Point(705, 39); - this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(192, 16); - this.progressBar1.TabIndex = 11; - // - // subtitleListViewTo - // - this.subtitleListViewTo.AllowColumnReorder = true; - this.subtitleListViewTo.FirstVisibleIndex = -1; - this.subtitleListViewTo.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.subtitleListViewTo.FullRowSelect = true; - this.subtitleListViewTo.GridLines = true; - this.subtitleListViewTo.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.subtitleListViewTo.HideSelection = false; - this.subtitleListViewTo.Location = new System.Drawing.Point(471, 64); - this.subtitleListViewTo.Name = "subtitleListViewTo"; - this.subtitleListViewTo.OwnerDraw = true; - this.subtitleListViewTo.Size = new System.Drawing.Size(428, 459); - this.subtitleListViewTo.SubtitleFontBold = false; - this.subtitleListViewTo.SubtitleFontName = "Tahoma"; - this.subtitleListViewTo.SubtitleFontSize = 8; - this.subtitleListViewTo.TabIndex = 2; - this.subtitleListViewTo.UseCompatibleStateImageBehavior = false; - this.subtitleListViewTo.UseSyntaxColoring = true; - this.subtitleListViewTo.View = System.Windows.Forms.View.Details; - this.subtitleListViewTo.Click += new System.EventHandler(this.subtitleListViewTo_DoubleClick); - this.subtitleListViewTo.DoubleClick += new System.EventHandler(this.subtitleListViewTo_DoubleClick); - // - // subtitleListViewFrom - // - this.subtitleListViewFrom.AllowColumnReorder = true; - this.subtitleListViewFrom.FirstVisibleIndex = -1; - this.subtitleListViewFrom.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.subtitleListViewFrom.FullRowSelect = true; - this.subtitleListViewFrom.GridLines = true; - this.subtitleListViewFrom.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.subtitleListViewFrom.HideSelection = false; - this.subtitleListViewFrom.Location = new System.Drawing.Point(18, 64); - this.subtitleListViewFrom.Name = "subtitleListViewFrom"; - this.subtitleListViewFrom.OwnerDraw = true; - this.subtitleListViewFrom.Size = new System.Drawing.Size(430, 459); - this.subtitleListViewFrom.SubtitleFontBold = false; - this.subtitleListViewFrom.SubtitleFontName = "Tahoma"; - this.subtitleListViewFrom.SubtitleFontSize = 8; - this.subtitleListViewFrom.TabIndex = 0; - this.subtitleListViewFrom.UseCompatibleStateImageBehavior = false; - this.subtitleListViewFrom.UseSyntaxColoring = true; - this.subtitleListViewFrom.View = System.Windows.Forms.View.Details; - this.subtitleListViewFrom.Click += new System.EventHandler(this.subtitleListViewFrom_DoubleClick); - this.subtitleListViewFrom.DoubleClick += new System.EventHandler(this.subtitleListViewFrom_DoubleClick); - // - // labelApiKeyNotFound - // - this.labelApiKeyNotFound.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelApiKeyNotFound.AutoSize = true; - this.labelApiKeyNotFound.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))); - this.labelApiKeyNotFound.Location = new System.Drawing.Point(202, 529); - this.labelApiKeyNotFound.Name = "labelApiKeyNotFound"; - this.labelApiKeyNotFound.Size = new System.Drawing.Size(145, 13); - this.labelApiKeyNotFound.TabIndex = 12; - this.labelApiKeyNotFound.Text = "Warning: API key not found!"; - // - // GoogleTranslate - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(925, 558); - this.Controls.Add(this.labelApiKeyNotFound); - this.Controls.Add(this.comboBoxFrom); - this.Controls.Add(this.progressBar1); - this.Controls.Add(this.labelPleaseWait); - this.Controls.Add(this.linkLabelPoweredByGoogleTranslate); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonTranslate); - this.Controls.Add(this.labelTo); - this.Controls.Add(this.comboBoxTo); - this.Controls.Add(this.subtitleListViewTo); - this.Controls.Add(this.subtitleListViewFrom); - this.Controls.Add(this.labelFrom); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(900, 500); - this.Name = "GoogleTranslate"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Google translate"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormGoogleTranslate_KeyDown); - this.Resize += new System.EventHandler(this.GoogleTranslate_Resize); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ComboBox comboBoxFrom; - private System.Windows.Forms.Label labelFrom; - private SubtitleListView subtitleListViewFrom; - private SubtitleListView subtitleListViewTo; - private System.Windows.Forms.Label labelTo; - private System.Windows.Forms.ComboBox comboBoxTo; - private System.Windows.Forms.Button buttonTranslate; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.LinkLabel linkLabelPoweredByGoogleTranslate; - private System.Windows.Forms.Label labelPleaseWait; - private System.Windows.Forms.ProgressBar progressBar1; - private System.Windows.Forms.Label labelApiKeyNotFound; - } +using Nikse.SubtitleEdit.Controls; + +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class GoogleTranslate + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.comboBoxFrom = new System.Windows.Forms.ComboBox(); + this.labelFrom = new System.Windows.Forms.Label(); + this.labelTo = new System.Windows.Forms.Label(); + this.comboBoxTo = new System.Windows.Forms.ComboBox(); + this.buttonTranslate = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.linkLabelPoweredByGoogleTranslate = new System.Windows.Forms.LinkLabel(); + this.labelPleaseWait = new System.Windows.Forms.Label(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.subtitleListViewTo = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.subtitleListViewFrom = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.labelApiKeyNotFound = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // comboBoxFrom + // + this.comboBoxFrom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxFrom.FormattingEnabled = true; + this.comboBoxFrom.Location = new System.Drawing.Point(327, 34); + this.comboBoxFrom.Name = "comboBoxFrom"; + this.comboBoxFrom.Size = new System.Drawing.Size(121, 21); + this.comboBoxFrom.TabIndex = 0; + // + // labelFrom + // + this.labelFrom.AutoSize = true; + this.labelFrom.Location = new System.Drawing.Point(285, 41); + this.labelFrom.Name = "labelFrom"; + this.labelFrom.Size = new System.Drawing.Size(35, 13); + this.labelFrom.TabIndex = 1; + this.labelFrom.Text = "From:"; + // + // labelTo + // + this.labelTo.AutoSize = true; + this.labelTo.Location = new System.Drawing.Point(468, 37); + this.labelTo.Name = "labelTo"; + this.labelTo.Size = new System.Drawing.Size(23, 13); + this.labelTo.TabIndex = 4; + this.labelTo.Text = "To:"; + // + // comboBoxTo + // + this.comboBoxTo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxTo.FormattingEnabled = true; + this.comboBoxTo.Location = new System.Drawing.Point(497, 34); + this.comboBoxTo.Name = "comboBoxTo"; + this.comboBoxTo.Size = new System.Drawing.Size(121, 21); + this.comboBoxTo.TabIndex = 3; + // + // buttonTranslate + // + this.buttonTranslate.Location = new System.Drawing.Point(624, 34); + this.buttonTranslate.Name = "buttonTranslate"; + this.buttonTranslate.Size = new System.Drawing.Size(75, 23); + this.buttonTranslate.TabIndex = 5; + this.buttonTranslate.Text = "Translate"; + this.buttonTranslate.UseVisualStyleBackColor = true; + this.buttonTranslate.Click += new System.EventHandler(this.buttonTranslate_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(754, 529); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 6; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(835, 529); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 7; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // linkLabelPoweredByGoogleTranslate + // + this.linkLabelPoweredByGoogleTranslate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.linkLabelPoweredByGoogleTranslate.AutoSize = true; + this.linkLabelPoweredByGoogleTranslate.Location = new System.Drawing.Point(15, 529); + this.linkLabelPoweredByGoogleTranslate.Name = "linkLabelPoweredByGoogleTranslate"; + this.linkLabelPoweredByGoogleTranslate.Size = new System.Drawing.Size(146, 13); + this.linkLabelPoweredByGoogleTranslate.TabIndex = 8; + this.linkLabelPoweredByGoogleTranslate.TabStop = true; + this.linkLabelPoweredByGoogleTranslate.Text = "Powered by Google translate"; + this.linkLabelPoweredByGoogleTranslate.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel1LinkClicked); + // + // labelPleaseWait + // + this.labelPleaseWait.AutoSize = true; + this.labelPleaseWait.Location = new System.Drawing.Point(703, 23); + this.labelPleaseWait.Name = "labelPleaseWait"; + this.labelPleaseWait.Size = new System.Drawing.Size(176, 13); + this.labelPleaseWait.TabIndex = 10; + this.labelPleaseWait.Text = "Please wait... this may take a while"; + // + // progressBar1 + // + this.progressBar1.Location = new System.Drawing.Point(705, 39); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(192, 16); + this.progressBar1.TabIndex = 11; + // + // subtitleListViewTo + // + this.subtitleListViewTo.AllowColumnReorder = true; + this.subtitleListViewTo.FirstVisibleIndex = -1; + this.subtitleListViewTo.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.subtitleListViewTo.FullRowSelect = true; + this.subtitleListViewTo.GridLines = true; + this.subtitleListViewTo.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.subtitleListViewTo.HideSelection = false; + this.subtitleListViewTo.Location = new System.Drawing.Point(471, 64); + this.subtitleListViewTo.Name = "subtitleListViewTo"; + this.subtitleListViewTo.OwnerDraw = true; + this.subtitleListViewTo.Size = new System.Drawing.Size(428, 459); + this.subtitleListViewTo.SubtitleFontBold = false; + this.subtitleListViewTo.SubtitleFontName = "Tahoma"; + this.subtitleListViewTo.SubtitleFontSize = 8; + this.subtitleListViewTo.TabIndex = 2; + this.subtitleListViewTo.UseCompatibleStateImageBehavior = false; + this.subtitleListViewTo.UseSyntaxColoring = true; + this.subtitleListViewTo.View = System.Windows.Forms.View.Details; + this.subtitleListViewTo.Click += new System.EventHandler(this.subtitleListViewTo_DoubleClick); + this.subtitleListViewTo.DoubleClick += new System.EventHandler(this.subtitleListViewTo_DoubleClick); + // + // subtitleListViewFrom + // + this.subtitleListViewFrom.AllowColumnReorder = true; + this.subtitleListViewFrom.FirstVisibleIndex = -1; + this.subtitleListViewFrom.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.subtitleListViewFrom.FullRowSelect = true; + this.subtitleListViewFrom.GridLines = true; + this.subtitleListViewFrom.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.subtitleListViewFrom.HideSelection = false; + this.subtitleListViewFrom.Location = new System.Drawing.Point(18, 64); + this.subtitleListViewFrom.Name = "subtitleListViewFrom"; + this.subtitleListViewFrom.OwnerDraw = true; + this.subtitleListViewFrom.Size = new System.Drawing.Size(430, 459); + this.subtitleListViewFrom.SubtitleFontBold = false; + this.subtitleListViewFrom.SubtitleFontName = "Tahoma"; + this.subtitleListViewFrom.SubtitleFontSize = 8; + this.subtitleListViewFrom.TabIndex = 0; + this.subtitleListViewFrom.UseCompatibleStateImageBehavior = false; + this.subtitleListViewFrom.UseSyntaxColoring = true; + this.subtitleListViewFrom.View = System.Windows.Forms.View.Details; + this.subtitleListViewFrom.Click += new System.EventHandler(this.subtitleListViewFrom_DoubleClick); + this.subtitleListViewFrom.DoubleClick += new System.EventHandler(this.subtitleListViewFrom_DoubleClick); + // + // labelApiKeyNotFound + // + this.labelApiKeyNotFound.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelApiKeyNotFound.AutoSize = true; + this.labelApiKeyNotFound.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))); + this.labelApiKeyNotFound.Location = new System.Drawing.Point(202, 529); + this.labelApiKeyNotFound.Name = "labelApiKeyNotFound"; + this.labelApiKeyNotFound.Size = new System.Drawing.Size(145, 13); + this.labelApiKeyNotFound.TabIndex = 12; + this.labelApiKeyNotFound.Text = "Warning: API key not found!"; + // + // GoogleTranslate + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(925, 558); + this.Controls.Add(this.labelApiKeyNotFound); + this.Controls.Add(this.comboBoxFrom); + this.Controls.Add(this.progressBar1); + this.Controls.Add(this.labelPleaseWait); + this.Controls.Add(this.linkLabelPoweredByGoogleTranslate); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonTranslate); + this.Controls.Add(this.labelTo); + this.Controls.Add(this.comboBoxTo); + this.Controls.Add(this.subtitleListViewTo); + this.Controls.Add(this.subtitleListViewFrom); + this.Controls.Add(this.labelFrom); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(900, 500); + this.Name = "GoogleTranslate"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Google translate"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormGoogleTranslate_KeyDown); + this.Resize += new System.EventHandler(this.GoogleTranslate_Resize); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox comboBoxFrom; + private System.Windows.Forms.Label labelFrom; + private SubtitleListView subtitleListViewFrom; + private SubtitleListView subtitleListViewTo; + private System.Windows.Forms.Label labelTo; + private System.Windows.Forms.ComboBox comboBoxTo; + private System.Windows.Forms.Button buttonTranslate; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.LinkLabel linkLabelPoweredByGoogleTranslate; + private System.Windows.Forms.Label labelPleaseWait; + private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.Label labelApiKeyNotFound; + } } \ No newline at end of file diff --git a/src/Forms/GoogleTranslate.cs b/src/ui/Forms/GoogleTranslate.cs similarity index 97% rename from src/Forms/GoogleTranslate.cs rename to src/ui/Forms/GoogleTranslate.cs index 4b3cfe9b8..6dee72378 100644 --- a/src/Forms/GoogleTranslate.cs +++ b/src/ui/Forms/GoogleTranslate.cs @@ -1,569 +1,569 @@ -using Nikse.SubtitleEdit.Controls; -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Core.Translate; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class GoogleTranslate : PositionAndSizeForm - { - public Subtitle TranslatedSubtitle { get; private set; } - private Subtitle _subtitle; - private bool _breakTranslation; - private bool _googleTranslate = true; - private const string SplitterString = "+-+"; - private ITranslator _translator; - - private enum FormattingType - { - None, - Italic, - ItalicTwoLines - } - - private static string GoogleTranslateUrl => new GoogleTranslator2(Configuration.Settings.Tools.GoogleApiV2Key).GetUrl(); - - private FormattingType[] _formattingTypes; - private bool[] _autoSplit; - - private string _targetTwoLetterIsoLanguageName; - - public class ComboBoxItem - { - public string Text { get; set; } - public string Value { get; set; } - - public ComboBoxItem(string text, string value) - { - if (text.Length > 1) - { - text = char.ToUpper(text[0]) + text.Substring(1).ToLowerInvariant(); - } - - Text = text; - - Value = value; - } - - public override string ToString() - { - return Text; - } - } - - public GoogleTranslate() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.GoogleTranslate.Title; - labelFrom.Text = Configuration.Settings.Language.GoogleTranslate.From; - labelTo.Text = Configuration.Settings.Language.GoogleTranslate.To; - buttonTranslate.Text = Configuration.Settings.Language.GoogleTranslate.Translate; - labelPleaseWait.Text = Configuration.Settings.Language.GoogleTranslate.PleaseWait; - linkLabelPoweredByGoogleTranslate.Text = Configuration.Settings.Language.GoogleTranslate.PoweredByGoogleTranslate; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - labelApiKeyNotFound.Text = string.Empty; - - subtitleListViewFrom.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - subtitleListViewTo.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - subtitleListViewFrom.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); - subtitleListViewFrom.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); - subtitleListViewTo.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); - subtitleListViewTo.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); - UiUtil.InitializeSubtitleFont(subtitleListViewFrom); - UiUtil.InitializeSubtitleFont(subtitleListViewTo); - subtitleListViewFrom.AutoSizeColumns(); - subtitleListViewFrom.AutoSizeColumns(); - UiUtil.FixLargeFonts(this, buttonOK); - } - - internal void Initialize(Subtitle subtitle, Subtitle target, string title, bool googleTranslate, Encoding encoding) - { - if (title != null) - { - Text = title; - } - - _googleTranslate = googleTranslate; - if (!_googleTranslate) - { - _translator = new MicrosoftTranslator(Configuration.Settings.Tools.MicrosoftTranslatorApiKey, Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint, Configuration.Settings.Tools.MicrosoftTranslatorCategory); - linkLabelPoweredByGoogleTranslate.Text = Configuration.Settings.Language.GoogleTranslate.PoweredByMicrosoftTranslate; - } - - labelPleaseWait.Visible = false; - progressBar1.Visible = false; - _subtitle = subtitle; - - if (target != null) - { - TranslatedSubtitle = new Subtitle(target); - subtitleListViewTo.Fill(TranslatedSubtitle); - } - else - { - TranslatedSubtitle = new Subtitle(subtitle); - foreach (var paragraph in TranslatedSubtitle.Paragraphs) - { - paragraph.Text = string.Empty; - } - } - - - string defaultFromLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(encoding); // Guess language via encoding - if (string.IsNullOrEmpty(defaultFromLanguage)) - { - defaultFromLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); // Guess language based on subtitle contents - } - - if (defaultFromLanguage == "he") - { - defaultFromLanguage = "iw"; - } - - FillComboWithLanguages(comboBoxFrom); - int i = 0; - foreach (ComboBoxItem item in comboBoxFrom.Items) - { - if (item.Value == defaultFromLanguage) - { - comboBoxFrom.SelectedIndex = i; - break; - } - i++; - } - - var installedLanguages = new List(); - foreach (InputLanguage language in InputLanguage.InstalledInputLanguages) - { - installedLanguages.Add(language); - } - - FillComboWithLanguages(comboBoxTo); - i = 0; - string uiCultureTargetLanguage = Configuration.Settings.Tools.GoogleTranslateLastTargetLanguage; - if (uiCultureTargetLanguage == defaultFromLanguage) - { - foreach (string s in Utilities.GetDictionaryLanguages()) - { - string temp = s.Replace("[", string.Empty).Replace("]", string.Empty); - if (temp.Length > 4) - { - temp = temp.Substring(temp.Length - 5, 2).ToLowerInvariant(); - if (temp != defaultFromLanguage && installedLanguages.Any(p => p.Culture.TwoLetterISOLanguageName.Contains(temp))) - { - uiCultureTargetLanguage = temp; - break; - } - } - } - } - if (uiCultureTargetLanguage == defaultFromLanguage) - { - foreach (InputLanguage language in installedLanguages) - { - if (language.Culture.TwoLetterISOLanguageName != defaultFromLanguage) - { - uiCultureTargetLanguage = language.Culture.TwoLetterISOLanguageName; - break; - } - } - } - - if (uiCultureTargetLanguage == defaultFromLanguage && defaultFromLanguage == "en") - { - uiCultureTargetLanguage = "es"; - } - if (uiCultureTargetLanguage == defaultFromLanguage) - { - uiCultureTargetLanguage = "en"; - } - - comboBoxTo.SelectedIndex = 0; - foreach (ComboBoxItem item in comboBoxTo.Items) - { - if (item.Value == uiCultureTargetLanguage) - { - comboBoxTo.SelectedIndex = i; - break; - } - i++; - } - - subtitleListViewFrom.Fill(subtitle); - GoogleTranslate_Resize(null, null); - - _formattingTypes = new FormattingType[_subtitle.Paragraphs.Count]; - _autoSplit = new bool[_subtitle.Paragraphs.Count]; - } - - private void Translate(string source, string target, ITranslator translator, int maxTextSize, int maximumRequestArrayLength = 100) - { - buttonOK.Enabled = false; - buttonCancel.Enabled = false; - _breakTranslation = false; - buttonTranslate.Text = Configuration.Settings.Language.General.Cancel; - Cursor.Current = Cursors.WaitCursor; - progressBar1.Maximum = _subtitle.Paragraphs.Count; - progressBar1.Value = 0; - progressBar1.Visible = true; - labelPleaseWait.Visible = true; - var sourceParagraphs = new List(); - try - { - var log = new StringBuilder(); - var sourceLength = 0; - var selectedItems = subtitleListViewFrom.SelectedItems; - var startIndex = selectedItems.Count <= 0 ? 0 : selectedItems[0].Index; - var start = startIndex; - int index = startIndex; - for (int i = startIndex; i < _subtitle.Paragraphs.Count; i++) - { - Paragraph p = _subtitle.Paragraphs[i]; - sourceLength += Utilities.UrlEncode(p.Text).Length; - if ((sourceLength >= maxTextSize || sourceParagraphs.Count >= maximumRequestArrayLength) && sourceParagraphs.Count > 0) - { - var result = translator.Translate(source, target, sourceParagraphs, log); - FillTranslatedText(result, start, index - 1); - sourceLength = 0; - sourceParagraphs.Clear(); - progressBar1.Refresh(); - Application.DoEvents(); - start = index; - } - sourceParagraphs.Add(p); - index++; - progressBar1.Value = index; - if (_breakTranslation) - { - break; - } - } - - if (sourceParagraphs.Count > 0) - { - var result = translator.Translate(source, target, sourceParagraphs, log); - FillTranslatedText(result, start, index - 1); - } - } - catch (WebException webException) - { - if (translator.GetType() == typeof(GoogleTranslator1)) - { - MessageBox.Show("Free API quota exceeded?" + Environment.NewLine + - Environment.NewLine + - webException.Source + ": " + webException.Message); - } - else if (translator.GetType() == typeof(GoogleTranslator2) && webException.Message.Contains("(400) Bad Request")) - { - MessageBox.Show("API key invalid (or perhaps billing is not enabled)?" + Environment.NewLine + - Environment.NewLine + - webException.Source + ": " + webException.Message); - } - else if (translator.GetType() == typeof(GoogleTranslator2) && webException.Message.Contains("(403) Forbidden.")) - { - MessageBox.Show("Perhaps billing is not enabled (or API key is invalid)?" + Environment.NewLine + - Environment.NewLine + - webException.Source + ": " + webException.Message); - } - else - { - MessageBox.Show(webException.Source + ": " + webException.Message); - } - } - finally - { - labelPleaseWait.Visible = false; - progressBar1.Visible = false; - Cursor.Current = Cursors.Default; - buttonTranslate.Text = Configuration.Settings.Language.GoogleTranslate.Translate; - buttonTranslate.Enabled = true; - buttonOK.Enabled = true; - buttonCancel.Enabled = true; - - Configuration.Settings.Tools.GoogleTranslateLastTargetLanguage = _targetTwoLetterIsoLanguageName; - } - } - - private void FillTranslatedText(List translatedLines, int start, int end) - { - int index = start; - foreach (string s in translatedLines) - { - if (index < TranslatedSubtitle.Paragraphs.Count) - { - var cleanText = CleanText(s, index); - TranslatedSubtitle.Paragraphs[index].Text = cleanText; - } - index++; - } - subtitleListViewTo.BeginUpdate(); - subtitleListViewTo.Fill(TranslatedSubtitle); - subtitleListViewTo.SelectIndexAndEnsureVisible(end); - subtitleListViewTo.EndUpdate(); - } - - private void buttonTranslate_Click(object sender, EventArgs e) - { - if (buttonTranslate.Text == Configuration.Settings.Language.General.Cancel) - { - buttonTranslate.Enabled = false; - _breakTranslation = true; - buttonOK.Enabled = true; - buttonCancel.Enabled = true; - return; - } - - _targetTwoLetterIsoLanguageName = ((ComboBoxItem)comboBoxTo.SelectedItem).Value; - Configuration.Settings.Tools.GoogleTranslateLastTargetLanguage = _targetTwoLetterIsoLanguageName; - var source = ((ComboBoxItem)comboBoxFrom.SelectedItem).Value; - - var language = Configuration.Settings.Language.GoogleTranslate; - if (_googleTranslate && string.IsNullOrEmpty(Configuration.Settings.Tools.GoogleApiV2Key)) - { - if (Configuration.Settings.Tools.GoogleApiV2KeyInfoShow) - { - using (var form = new DialogDoNotShowAgain("Subtitle Edit", language.GoogleApiKeyNeeded)) - { - form.ShowDialog(this); - Configuration.Settings.Tools.GoogleApiV2KeyInfoShow = !form.DoNoDisplayAgain; - } - } - - if (Configuration.Settings.Tools.GoogleTranslateNoKeyWarningShow) - { - using (var form = new DialogDoNotShowAgain("Subtitle Edit", language.GoogleNoApiKeyWarning)) - { - form.ShowDialog(this); - Configuration.Settings.Tools.GoogleTranslateNoKeyWarningShow = !form.DoNoDisplayAgain; - } - } - - labelApiKeyNotFound.Left = linkLabelPoweredByGoogleTranslate.Left + linkLabelPoweredByGoogleTranslate.Width + 20; - labelApiKeyNotFound.Text = language.GoogleNoApiKeyWarning; - - Translate(source, _targetTwoLetterIsoLanguageName, new GoogleTranslator1(), Configuration.Settings.Tools.GoogleApiV1ChunkSize); - return; - } - - if (!_googleTranslate && string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorApiKey)) - { - MessageBox.Show(language.MsClientSecretNeeded); - return; - } - - - if (_googleTranslate) - { - Translate(source, _targetTwoLetterIsoLanguageName, new GoogleTranslator2(Configuration.Settings.Tools.GoogleApiV2Key), 1000); - } - else - { - Translate(source, _targetTwoLetterIsoLanguageName, new MicrosoftTranslator(Configuration.Settings.Tools.MicrosoftTranslatorApiKey, Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint, Configuration.Settings.Tools.MicrosoftTranslatorCategory), 1000, MicrosoftTranslator.MaximumRequestArrayLength); - } - } - - private string CleanText(string s, int index) - { - string cleanText = s.Replace("

", string.Empty).Trim(); - int indexOfP = cleanText.IndexOf(SplitterString.Trim(), StringComparison.Ordinal); - if (indexOfP >= 0 && indexOfP < 4) - { - cleanText = cleanText.Remove(0, indexOfP); - } - - cleanText = cleanText.Replace(SplitterString, string.Empty).Trim(); - if (cleanText.Contains('\n') && !cleanText.Contains('\r')) - { - cleanText = cleanText.Replace("\n", Environment.NewLine); - } - - cleanText = cleanText.Replace(" ...", "..."); - cleanText = cleanText.Replace("
", Environment.NewLine); - cleanText = cleanText.Replace("
", Environment.NewLine); - cleanText = cleanText.Replace("< br/>", Environment.NewLine); - cleanText = cleanText.Replace("
", Environment.NewLine); - cleanText = cleanText.Replace("
", Environment.NewLine); - cleanText = cleanText.Replace("< br />", Environment.NewLine); - cleanText = cleanText.Replace("< br / >", Environment.NewLine); - cleanText = cleanText.Replace("< br/ >", Environment.NewLine); - cleanText = cleanText.Replace(Environment.NewLine + " ", Environment.NewLine); - cleanText = cleanText.Replace(" " + Environment.NewLine, Environment.NewLine); - cleanText = cleanText.Replace("", ""); - cleanText = cleanText.Replace("< I>", ""); - cleanText = cleanText.Replace("", ""); - cleanText = cleanText.Replace("", ""); - cleanText = cleanText.Replace("", ""); - cleanText = cleanText.Replace("< i >", ""); - if (cleanText.StartsWith(" ", StringComparison.Ordinal)) - { - cleanText = cleanText.Remove(3, 1); - } - - if (cleanText.EndsWith(" ", StringComparison.Ordinal)) - { - cleanText = cleanText.Remove(cleanText.Length - 5, 1); - } - - cleanText = cleanText.Replace(Environment.NewLine + " ", Environment.NewLine + ""); - cleanText = cleanText.Replace(" " + Environment.NewLine, "" + Environment.NewLine); - - if (_autoSplit[index]) - { - cleanText = Utilities.AutoBreakLine(cleanText); - } - - if (Utilities.GetNumberOfLines(cleanText) == 1 && Utilities.GetNumberOfLines(_subtitle.Paragraphs[index].Text) == 2) - { - if (!_autoSplit[index]) - { - cleanText = Utilities.AutoBreakLine(cleanText); - } - } - - if (_formattingTypes[index] == FormattingType.ItalicTwoLines || _formattingTypes[index] == FormattingType.Italic) - { - cleanText = "" + cleanText + ""; - } - - return cleanText; - } - - public void FillComboWithLanguages(ComboBox comboBox) - { - if (!_googleTranslate) - { - foreach (var bingLanguageCode in _translator.GetTranslationPairs()) - { - comboBox.Items.Add(new ComboBoxItem(bingLanguageCode.Name, bingLanguageCode.Code)); - } - return; - } - - FillComboWithGoogleLanguages(comboBox); - } - - public void FillComboWithGoogleLanguages(ComboBox comboBox) - { - var translator = new GoogleTranslator2(Configuration.Settings.Tools.GoogleApiV2Key); - foreach (var pair in translator.GetTranslationPairs()) - { - comboBox.Items.Add(new ComboBoxItem(pair.Name, pair.Code)); - } - } - - private void LinkLabel1LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - UiUtil.OpenURL(_googleTranslate ? GoogleTranslateUrl : _translator.GetUrl()); - } - - private void ButtonOkClick(object sender, EventArgs e) - { - DialogResult = subtitleListViewTo.Items.Count > 0 ? DialogResult.OK : DialogResult.Cancel; - } - - private void FormGoogleTranslate_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape && labelPleaseWait.Visible == false) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == Keys.Escape && labelPleaseWait.Visible) - { - _breakTranslation = true; - e.SuppressKeyPress = true; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#translation"); - } - } - - private void GoogleTranslate_Resize(object sender, EventArgs e) - { - int width = (Width / 2) - (subtitleListViewFrom.Left * 3) + 19; - subtitleListViewFrom.Width = width; - subtitleListViewTo.Width = width; - - int height = Height - (subtitleListViewFrom.Top + buttonTranslate.Height + 60); - subtitleListViewFrom.Height = height; - subtitleListViewTo.Height = height; - - comboBoxFrom.Left = subtitleListViewFrom.Left + (subtitleListViewFrom.Width - comboBoxFrom.Width); - labelFrom.Left = comboBoxFrom.Left - 5 - labelFrom.Width; - - subtitleListViewTo.Left = width + (subtitleListViewFrom.Left * 2); - labelTo.Left = subtitleListViewTo.Left; - comboBoxTo.Left = labelTo.Left + labelTo.Width + 5; - buttonTranslate.Left = comboBoxTo.Left + comboBoxTo.Width + 9; - labelPleaseWait.Left = buttonTranslate.Left + buttonTranslate.Width + 9; - progressBar1.Left = labelPleaseWait.Left; - progressBar1.Width = subtitleListViewTo.Width - (progressBar1.Left - subtitleListViewTo.Left); - } - - private void SyncListViews(ListView listViewSelected, SubtitleListView listViewOther) - { - if (listViewSelected.SelectedItems.Count > 0) - { - var first = listViewSelected.TopItem.Index; - int index = listViewSelected.SelectedItems[0].Index; - if (index < listViewOther.Items.Count) - { - listViewOther.SelectIndexAndEnsureVisible(index, false); - if (first >= 0) - { - listViewOther.TopItem = listViewOther.Items[first]; - } - } - } - } - - private void subtitleListViewFrom_DoubleClick(object sender, EventArgs e) - { - SyncListViews(subtitleListViewFrom, subtitleListViewTo); - } - - private void subtitleListViewTo_DoubleClick(object sender, EventArgs e) - { - SyncListViews(subtitleListViewTo, subtitleListViewFrom); - } - - public string GetFileNameWithTargetLanguage(string oldFileName, string videoFileName, Subtitle oldSubtitle, SubtitleFormat subtitleFormat) - { - if (!string.IsNullOrEmpty(_targetTwoLetterIsoLanguageName)) - { - if (!string.IsNullOrEmpty(videoFileName)) - { - return Path.GetFileNameWithoutExtension(videoFileName) + "." + _targetTwoLetterIsoLanguageName.ToLowerInvariant() + subtitleFormat.Extension; - } - - if (!string.IsNullOrEmpty(oldFileName)) - { - var s = Path.GetFileNameWithoutExtension(oldFileName); - if (oldSubtitle != null) - { - var lang = "." + LanguageAutoDetect.AutoDetectGoogleLanguage(oldSubtitle); - if (lang.Length == 3 && s.EndsWith(lang, StringComparison.OrdinalIgnoreCase)) - { - s = s.Remove(s.Length - 3); - } - } - return s + "." + _targetTwoLetterIsoLanguageName.ToLowerInvariant() + subtitleFormat.Extension; - } - } - return null; - } - } -} +using Nikse.SubtitleEdit.Controls; +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Core.Translate; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class GoogleTranslate : PositionAndSizeForm + { + public Subtitle TranslatedSubtitle { get; private set; } + private Subtitle _subtitle; + private bool _breakTranslation; + private bool _googleTranslate = true; + private const string SplitterString = "+-+"; + private ITranslator _translator; + + private enum FormattingType + { + None, + Italic, + ItalicTwoLines + } + + private static string GoogleTranslateUrl => new GoogleTranslator2(Configuration.Settings.Tools.GoogleApiV2Key).GetUrl(); + + private FormattingType[] _formattingTypes; + private bool[] _autoSplit; + + private string _targetTwoLetterIsoLanguageName; + + public class ComboBoxItem + { + public string Text { get; set; } + public string Value { get; set; } + + public ComboBoxItem(string text, string value) + { + if (text.Length > 1) + { + text = char.ToUpper(text[0]) + text.Substring(1).ToLowerInvariant(); + } + + Text = text; + + Value = value; + } + + public override string ToString() + { + return Text; + } + } + + public GoogleTranslate() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.GoogleTranslate.Title; + labelFrom.Text = Configuration.Settings.Language.GoogleTranslate.From; + labelTo.Text = Configuration.Settings.Language.GoogleTranslate.To; + buttonTranslate.Text = Configuration.Settings.Language.GoogleTranslate.Translate; + labelPleaseWait.Text = Configuration.Settings.Language.GoogleTranslate.PleaseWait; + linkLabelPoweredByGoogleTranslate.Text = Configuration.Settings.Language.GoogleTranslate.PoweredByGoogleTranslate; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + labelApiKeyNotFound.Text = string.Empty; + + subtitleListViewFrom.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + subtitleListViewTo.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + subtitleListViewFrom.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); + subtitleListViewFrom.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); + subtitleListViewTo.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); + subtitleListViewTo.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); + UiUtil.InitializeSubtitleFont(subtitleListViewFrom); + UiUtil.InitializeSubtitleFont(subtitleListViewTo); + subtitleListViewFrom.AutoSizeColumns(); + subtitleListViewFrom.AutoSizeColumns(); + UiUtil.FixLargeFonts(this, buttonOK); + } + + internal void Initialize(Subtitle subtitle, Subtitle target, string title, bool googleTranslate, Encoding encoding) + { + if (title != null) + { + Text = title; + } + + _googleTranslate = googleTranslate; + if (!_googleTranslate) + { + _translator = new MicrosoftTranslator(Configuration.Settings.Tools.MicrosoftTranslatorApiKey, Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint, Configuration.Settings.Tools.MicrosoftTranslatorCategory); + linkLabelPoweredByGoogleTranslate.Text = Configuration.Settings.Language.GoogleTranslate.PoweredByMicrosoftTranslate; + } + + labelPleaseWait.Visible = false; + progressBar1.Visible = false; + _subtitle = subtitle; + + if (target != null) + { + TranslatedSubtitle = new Subtitle(target); + subtitleListViewTo.Fill(TranslatedSubtitle); + } + else + { + TranslatedSubtitle = new Subtitle(subtitle); + foreach (var paragraph in TranslatedSubtitle.Paragraphs) + { + paragraph.Text = string.Empty; + } + } + + + string defaultFromLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(encoding); // Guess language via encoding + if (string.IsNullOrEmpty(defaultFromLanguage)) + { + defaultFromLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); // Guess language based on subtitle contents + } + + if (defaultFromLanguage == "he") + { + defaultFromLanguage = "iw"; + } + + FillComboWithLanguages(comboBoxFrom); + int i = 0; + foreach (ComboBoxItem item in comboBoxFrom.Items) + { + if (item.Value == defaultFromLanguage) + { + comboBoxFrom.SelectedIndex = i; + break; + } + i++; + } + + var installedLanguages = new List(); + foreach (InputLanguage language in InputLanguage.InstalledInputLanguages) + { + installedLanguages.Add(language); + } + + FillComboWithLanguages(comboBoxTo); + i = 0; + string uiCultureTargetLanguage = Configuration.Settings.Tools.GoogleTranslateLastTargetLanguage; + if (uiCultureTargetLanguage == defaultFromLanguage) + { + foreach (string s in Utilities.GetDictionaryLanguages()) + { + string temp = s.Replace("[", string.Empty).Replace("]", string.Empty); + if (temp.Length > 4) + { + temp = temp.Substring(temp.Length - 5, 2).ToLowerInvariant(); + if (temp != defaultFromLanguage && installedLanguages.Any(p => p.Culture.TwoLetterISOLanguageName.Contains(temp))) + { + uiCultureTargetLanguage = temp; + break; + } + } + } + } + if (uiCultureTargetLanguage == defaultFromLanguage) + { + foreach (InputLanguage language in installedLanguages) + { + if (language.Culture.TwoLetterISOLanguageName != defaultFromLanguage) + { + uiCultureTargetLanguage = language.Culture.TwoLetterISOLanguageName; + break; + } + } + } + + if (uiCultureTargetLanguage == defaultFromLanguage && defaultFromLanguage == "en") + { + uiCultureTargetLanguage = "es"; + } + if (uiCultureTargetLanguage == defaultFromLanguage) + { + uiCultureTargetLanguage = "en"; + } + + comboBoxTo.SelectedIndex = 0; + foreach (ComboBoxItem item in comboBoxTo.Items) + { + if (item.Value == uiCultureTargetLanguage) + { + comboBoxTo.SelectedIndex = i; + break; + } + i++; + } + + subtitleListViewFrom.Fill(subtitle); + GoogleTranslate_Resize(null, null); + + _formattingTypes = new FormattingType[_subtitle.Paragraphs.Count]; + _autoSplit = new bool[_subtitle.Paragraphs.Count]; + } + + private void Translate(string source, string target, ITranslator translator, int maxTextSize, int maximumRequestArrayLength = 100) + { + buttonOK.Enabled = false; + buttonCancel.Enabled = false; + _breakTranslation = false; + buttonTranslate.Text = Configuration.Settings.Language.General.Cancel; + Cursor.Current = Cursors.WaitCursor; + progressBar1.Maximum = _subtitle.Paragraphs.Count; + progressBar1.Value = 0; + progressBar1.Visible = true; + labelPleaseWait.Visible = true; + var sourceParagraphs = new List(); + try + { + var log = new StringBuilder(); + var sourceLength = 0; + var selectedItems = subtitleListViewFrom.SelectedItems; + var startIndex = selectedItems.Count <= 0 ? 0 : selectedItems[0].Index; + var start = startIndex; + int index = startIndex; + for (int i = startIndex; i < _subtitle.Paragraphs.Count; i++) + { + Paragraph p = _subtitle.Paragraphs[i]; + sourceLength += Utilities.UrlEncode(p.Text).Length; + if ((sourceLength >= maxTextSize || sourceParagraphs.Count >= maximumRequestArrayLength) && sourceParagraphs.Count > 0) + { + var result = translator.Translate(source, target, sourceParagraphs, log); + FillTranslatedText(result, start, index - 1); + sourceLength = 0; + sourceParagraphs.Clear(); + progressBar1.Refresh(); + Application.DoEvents(); + start = index; + } + sourceParagraphs.Add(p); + index++; + progressBar1.Value = index; + if (_breakTranslation) + { + break; + } + } + + if (sourceParagraphs.Count > 0) + { + var result = translator.Translate(source, target, sourceParagraphs, log); + FillTranslatedText(result, start, index - 1); + } + } + catch (WebException webException) + { + if (translator.GetType() == typeof(GoogleTranslator1)) + { + MessageBox.Show("Free API quota exceeded?" + Environment.NewLine + + Environment.NewLine + + webException.Source + ": " + webException.Message); + } + else if (translator.GetType() == typeof(GoogleTranslator2) && webException.Message.Contains("(400) Bad Request")) + { + MessageBox.Show("API key invalid (or perhaps billing is not enabled)?" + Environment.NewLine + + Environment.NewLine + + webException.Source + ": " + webException.Message); + } + else if (translator.GetType() == typeof(GoogleTranslator2) && webException.Message.Contains("(403) Forbidden.")) + { + MessageBox.Show("Perhaps billing is not enabled (or API key is invalid)?" + Environment.NewLine + + Environment.NewLine + + webException.Source + ": " + webException.Message); + } + else + { + MessageBox.Show(webException.Source + ": " + webException.Message); + } + } + finally + { + labelPleaseWait.Visible = false; + progressBar1.Visible = false; + Cursor.Current = Cursors.Default; + buttonTranslate.Text = Configuration.Settings.Language.GoogleTranslate.Translate; + buttonTranslate.Enabled = true; + buttonOK.Enabled = true; + buttonCancel.Enabled = true; + + Configuration.Settings.Tools.GoogleTranslateLastTargetLanguage = _targetTwoLetterIsoLanguageName; + } + } + + private void FillTranslatedText(List translatedLines, int start, int end) + { + int index = start; + foreach (string s in translatedLines) + { + if (index < TranslatedSubtitle.Paragraphs.Count) + { + var cleanText = CleanText(s, index); + TranslatedSubtitle.Paragraphs[index].Text = cleanText; + } + index++; + } + subtitleListViewTo.BeginUpdate(); + subtitleListViewTo.Fill(TranslatedSubtitle); + subtitleListViewTo.SelectIndexAndEnsureVisible(end); + subtitleListViewTo.EndUpdate(); + } + + private void buttonTranslate_Click(object sender, EventArgs e) + { + if (buttonTranslate.Text == Configuration.Settings.Language.General.Cancel) + { + buttonTranslate.Enabled = false; + _breakTranslation = true; + buttonOK.Enabled = true; + buttonCancel.Enabled = true; + return; + } + + _targetTwoLetterIsoLanguageName = ((ComboBoxItem)comboBoxTo.SelectedItem).Value; + Configuration.Settings.Tools.GoogleTranslateLastTargetLanguage = _targetTwoLetterIsoLanguageName; + var source = ((ComboBoxItem)comboBoxFrom.SelectedItem).Value; + + var language = Configuration.Settings.Language.GoogleTranslate; + if (_googleTranslate && string.IsNullOrEmpty(Configuration.Settings.Tools.GoogleApiV2Key)) + { + if (Configuration.Settings.Tools.GoogleApiV2KeyInfoShow) + { + using (var form = new DialogDoNotShowAgain("Subtitle Edit", language.GoogleApiKeyNeeded)) + { + form.ShowDialog(this); + Configuration.Settings.Tools.GoogleApiV2KeyInfoShow = !form.DoNoDisplayAgain; + } + } + + if (Configuration.Settings.Tools.GoogleTranslateNoKeyWarningShow) + { + using (var form = new DialogDoNotShowAgain("Subtitle Edit", language.GoogleNoApiKeyWarning)) + { + form.ShowDialog(this); + Configuration.Settings.Tools.GoogleTranslateNoKeyWarningShow = !form.DoNoDisplayAgain; + } + } + + labelApiKeyNotFound.Left = linkLabelPoweredByGoogleTranslate.Left + linkLabelPoweredByGoogleTranslate.Width + 20; + labelApiKeyNotFound.Text = language.GoogleNoApiKeyWarning; + + Translate(source, _targetTwoLetterIsoLanguageName, new GoogleTranslator1(), Configuration.Settings.Tools.GoogleApiV1ChunkSize); + return; + } + + if (!_googleTranslate && string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorApiKey)) + { + MessageBox.Show(language.MsClientSecretNeeded); + return; + } + + + if (_googleTranslate) + { + Translate(source, _targetTwoLetterIsoLanguageName, new GoogleTranslator2(Configuration.Settings.Tools.GoogleApiV2Key), 1000); + } + else + { + Translate(source, _targetTwoLetterIsoLanguageName, new MicrosoftTranslator(Configuration.Settings.Tools.MicrosoftTranslatorApiKey, Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint, Configuration.Settings.Tools.MicrosoftTranslatorCategory), 1000, MicrosoftTranslator.MaximumRequestArrayLength); + } + } + + private string CleanText(string s, int index) + { + string cleanText = s.Replace("

", string.Empty).Trim(); + int indexOfP = cleanText.IndexOf(SplitterString.Trim(), StringComparison.Ordinal); + if (indexOfP >= 0 && indexOfP < 4) + { + cleanText = cleanText.Remove(0, indexOfP); + } + + cleanText = cleanText.Replace(SplitterString, string.Empty).Trim(); + if (cleanText.Contains('\n') && !cleanText.Contains('\r')) + { + cleanText = cleanText.Replace("\n", Environment.NewLine); + } + + cleanText = cleanText.Replace(" ...", "..."); + cleanText = cleanText.Replace("
", Environment.NewLine); + cleanText = cleanText.Replace("
", Environment.NewLine); + cleanText = cleanText.Replace("< br/>", Environment.NewLine); + cleanText = cleanText.Replace("
", Environment.NewLine); + cleanText = cleanText.Replace("
", Environment.NewLine); + cleanText = cleanText.Replace("< br />", Environment.NewLine); + cleanText = cleanText.Replace("< br / >", Environment.NewLine); + cleanText = cleanText.Replace("< br/ >", Environment.NewLine); + cleanText = cleanText.Replace(Environment.NewLine + " ", Environment.NewLine); + cleanText = cleanText.Replace(" " + Environment.NewLine, Environment.NewLine); + cleanText = cleanText.Replace("", ""); + cleanText = cleanText.Replace("< I>", ""); + cleanText = cleanText.Replace("", ""); + cleanText = cleanText.Replace("", ""); + cleanText = cleanText.Replace("", ""); + cleanText = cleanText.Replace("< i >", ""); + if (cleanText.StartsWith(" ", StringComparison.Ordinal)) + { + cleanText = cleanText.Remove(3, 1); + } + + if (cleanText.EndsWith(" ", StringComparison.Ordinal)) + { + cleanText = cleanText.Remove(cleanText.Length - 5, 1); + } + + cleanText = cleanText.Replace(Environment.NewLine + " ", Environment.NewLine + ""); + cleanText = cleanText.Replace(" " + Environment.NewLine, "" + Environment.NewLine); + + if (_autoSplit[index]) + { + cleanText = Utilities.AutoBreakLine(cleanText); + } + + if (Utilities.GetNumberOfLines(cleanText) == 1 && Utilities.GetNumberOfLines(_subtitle.Paragraphs[index].Text) == 2) + { + if (!_autoSplit[index]) + { + cleanText = Utilities.AutoBreakLine(cleanText); + } + } + + if (_formattingTypes[index] == FormattingType.ItalicTwoLines || _formattingTypes[index] == FormattingType.Italic) + { + cleanText = "" + cleanText + ""; + } + + return cleanText; + } + + public void FillComboWithLanguages(ComboBox comboBox) + { + if (!_googleTranslate) + { + foreach (var bingLanguageCode in _translator.GetTranslationPairs()) + { + comboBox.Items.Add(new ComboBoxItem(bingLanguageCode.Name, bingLanguageCode.Code)); + } + return; + } + + FillComboWithGoogleLanguages(comboBox); + } + + public void FillComboWithGoogleLanguages(ComboBox comboBox) + { + var translator = new GoogleTranslator2(Configuration.Settings.Tools.GoogleApiV2Key); + foreach (var pair in translator.GetTranslationPairs()) + { + comboBox.Items.Add(new ComboBoxItem(pair.Name, pair.Code)); + } + } + + private void LinkLabel1LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + UiUtil.OpenURL(_googleTranslate ? GoogleTranslateUrl : _translator.GetUrl()); + } + + private void ButtonOkClick(object sender, EventArgs e) + { + DialogResult = subtitleListViewTo.Items.Count > 0 ? DialogResult.OK : DialogResult.Cancel; + } + + private void FormGoogleTranslate_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape && labelPleaseWait.Visible == false) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == Keys.Escape && labelPleaseWait.Visible) + { + _breakTranslation = true; + e.SuppressKeyPress = true; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#translation"); + } + } + + private void GoogleTranslate_Resize(object sender, EventArgs e) + { + int width = (Width / 2) - (subtitleListViewFrom.Left * 3) + 19; + subtitleListViewFrom.Width = width; + subtitleListViewTo.Width = width; + + int height = Height - (subtitleListViewFrom.Top + buttonTranslate.Height + 60); + subtitleListViewFrom.Height = height; + subtitleListViewTo.Height = height; + + comboBoxFrom.Left = subtitleListViewFrom.Left + (subtitleListViewFrom.Width - comboBoxFrom.Width); + labelFrom.Left = comboBoxFrom.Left - 5 - labelFrom.Width; + + subtitleListViewTo.Left = width + (subtitleListViewFrom.Left * 2); + labelTo.Left = subtitleListViewTo.Left; + comboBoxTo.Left = labelTo.Left + labelTo.Width + 5; + buttonTranslate.Left = comboBoxTo.Left + comboBoxTo.Width + 9; + labelPleaseWait.Left = buttonTranslate.Left + buttonTranslate.Width + 9; + progressBar1.Left = labelPleaseWait.Left; + progressBar1.Width = subtitleListViewTo.Width - (progressBar1.Left - subtitleListViewTo.Left); + } + + private void SyncListViews(ListView listViewSelected, SubtitleListView listViewOther) + { + if (listViewSelected.SelectedItems.Count > 0) + { + var first = listViewSelected.TopItem.Index; + int index = listViewSelected.SelectedItems[0].Index; + if (index < listViewOther.Items.Count) + { + listViewOther.SelectIndexAndEnsureVisible(index, false); + if (first >= 0) + { + listViewOther.TopItem = listViewOther.Items[first]; + } + } + } + } + + private void subtitleListViewFrom_DoubleClick(object sender, EventArgs e) + { + SyncListViews(subtitleListViewFrom, subtitleListViewTo); + } + + private void subtitleListViewTo_DoubleClick(object sender, EventArgs e) + { + SyncListViews(subtitleListViewTo, subtitleListViewFrom); + } + + public string GetFileNameWithTargetLanguage(string oldFileName, string videoFileName, Subtitle oldSubtitle, SubtitleFormat subtitleFormat) + { + if (!string.IsNullOrEmpty(_targetTwoLetterIsoLanguageName)) + { + if (!string.IsNullOrEmpty(videoFileName)) + { + return Path.GetFileNameWithoutExtension(videoFileName) + "." + _targetTwoLetterIsoLanguageName.ToLowerInvariant() + subtitleFormat.Extension; + } + + if (!string.IsNullOrEmpty(oldFileName)) + { + var s = Path.GetFileNameWithoutExtension(oldFileName); + if (oldSubtitle != null) + { + var lang = "." + LanguageAutoDetect.AutoDetectGoogleLanguage(oldSubtitle); + if (lang.Length == 3 && s.EndsWith(lang, StringComparison.OrdinalIgnoreCase)) + { + s = s.Remove(s.Length - 3); + } + } + return s + "." + _targetTwoLetterIsoLanguageName.ToLowerInvariant() + subtitleFormat.Extension; + } + } + return null; + } + } +} diff --git a/src/Forms/GoogleTranslate.resx b/src/ui/Forms/GoogleTranslate.resx similarity index 97% rename from src/Forms/GoogleTranslate.resx rename to src/ui/Forms/GoogleTranslate.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/GoogleTranslate.resx +++ b/src/ui/Forms/GoogleTranslate.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/HardSubExtract.Designer.cs b/src/ui/Forms/HardSubExtract.Designer.cs similarity index 98% rename from src/Forms/HardSubExtract.Designer.cs rename to src/ui/Forms/HardSubExtract.Designer.cs index 3f46bbb45..55ac62ef8 100644 --- a/src/Forms/HardSubExtract.Designer.cs +++ b/src/ui/Forms/HardSubExtract.Designer.cs @@ -1,447 +1,447 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class HardSubExtract - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.label1 = new System.Windows.Forms.Label(); - this.labelCustomRgb = new System.Windows.Forms.Label(); - this.pictureBoxCustomColor = new System.Windows.Forms.PictureBox(); - this.numericUpDownCustomMaxDiff = new System.Windows.Forms.NumericUpDown(); - this.checkBoxCustomColor = new System.Windows.Forms.CheckBox(); - this.checkBoxYellow = new System.Windows.Forms.CheckBox(); - this.numericUpDownPixelsBottom = new System.Windows.Forms.NumericUpDown(); - this.label4 = new System.Windows.Forms.Label(); - this.pictureBox2 = new System.Windows.Forms.PictureBox(); - this.contextMenuStripScreenshot = new System.Windows.Forms.ContextMenuStrip(this.components); - this.saveImageAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.labelClickOnTextColor = new System.Windows.Forms.Label(); - this.openFileDialogVideo = new System.Windows.Forms.OpenFileDialog(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.labelStatus = new System.Windows.Forms.Label(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.button1 = new System.Windows.Forms.Button(); - this.timerRefreshProgressbar = new System.Windows.Forms.Timer(this.components); - this.label8 = new System.Windows.Forms.Label(); - this.tbBlacks = new System.Windows.Forms.TextBox(); - this.label9 = new System.Windows.Forms.Label(); - this.tbFrameNum = new System.Windows.Forms.TextBox(); - this.tbFileName = new System.Windows.Forms.TextBox(); - this.label10 = new System.Windows.Forms.Label(); - this.StartStop = new System.Windows.Forms.Button(); - this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.colorDialog1 = new System.Windows.Forms.ColorDialog(); - this.buttonStop = new System.Windows.Forms.Button(); - this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCustomColor)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCustomMaxDiff)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsBottom)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); - this.contextMenuStripScreenshot.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.groupBox3.SuspendLayout(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.label1); - this.groupBox1.Controls.Add(this.labelCustomRgb); - this.groupBox1.Controls.Add(this.pictureBoxCustomColor); - this.groupBox1.Controls.Add(this.numericUpDownCustomMaxDiff); - this.groupBox1.Controls.Add(this.checkBoxCustomColor); - this.groupBox1.Controls.Add(this.checkBoxYellow); - this.groupBox1.Location = new System.Drawing.Point(12, 85); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(341, 117); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Detection options"; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(9, 80); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(101, 16); - this.label1.TabIndex = 31; - this.label1.Text = "Allow diff per RGB"; - // - // labelCustomRgb - // - this.labelCustomRgb.AutoSize = true; - this.labelCustomRgb.Location = new System.Drawing.Point(177, 56); - this.labelCustomRgb.Name = "labelCustomRgb"; - this.labelCustomRgb.Size = new System.Drawing.Size(30, 13); - this.labelCustomRgb.TabIndex = 37; - this.labelCustomRgb.Text = "RGB"; - // - // pictureBoxCustomColor - // - this.pictureBoxCustomColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pictureBoxCustomColor.Location = new System.Drawing.Point(152, 53); - this.pictureBoxCustomColor.Name = "pictureBoxCustomColor"; - this.pictureBoxCustomColor.Size = new System.Drawing.Size(21, 21); - this.pictureBoxCustomColor.TabIndex = 8; - this.pictureBoxCustomColor.TabStop = false; - this.pictureBoxCustomColor.Click += new System.EventHandler(this.pictureBoxCustomColor_Click); - // - // numericUpDownCustomMaxDiff - // - this.numericUpDownCustomMaxDiff.Location = new System.Drawing.Point(116, 76); - this.numericUpDownCustomMaxDiff.Name = "numericUpDownCustomMaxDiff"; - this.numericUpDownCustomMaxDiff.Size = new System.Drawing.Size(38, 20); - this.numericUpDownCustomMaxDiff.TabIndex = 2; - this.numericUpDownCustomMaxDiff.Value = new decimal(new int[] { - 14, - 0, - 0, - 0}); - // - // checkBoxCustomColor - // - this.checkBoxCustomColor.AutoSize = true; - this.checkBoxCustomColor.Location = new System.Drawing.Point(11, 55); - this.checkBoxCustomColor.Name = "checkBoxCustomColor"; - this.checkBoxCustomColor.Size = new System.Drawing.Size(135, 17); - this.checkBoxCustomColor.TabIndex = 1; - this.checkBoxCustomColor.Text = "Check for custom color"; - this.checkBoxCustomColor.UseVisualStyleBackColor = true; - // - // checkBoxYellow - // - this.checkBoxYellow.AutoSize = true; - this.checkBoxYellow.Checked = true; - this.checkBoxYellow.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxYellow.Location = new System.Drawing.Point(9, 19); - this.checkBoxYellow.Name = "checkBoxYellow"; - this.checkBoxYellow.Size = new System.Drawing.Size(124, 17); - this.checkBoxYellow.TabIndex = 0; - this.checkBoxYellow.Text = "Check for yellow text"; - this.checkBoxYellow.UseVisualStyleBackColor = true; - // - // numericUpDownPixelsBottom - // - this.numericUpDownPixelsBottom.Location = new System.Drawing.Point(192, 16); - this.numericUpDownPixelsBottom.Maximum = new decimal(new int[] { - 2000, - 0, - 0, - 0}); - this.numericUpDownPixelsBottom.Name = "numericUpDownPixelsBottom"; - this.numericUpDownPixelsBottom.Size = new System.Drawing.Size(66, 20); - this.numericUpDownPixelsBottom.TabIndex = 19; - this.numericUpDownPixelsBottom.Value = new decimal(new int[] { - 127, - 0, - 0, - 0}); - this.numericUpDownPixelsBottom.ValueChanged += new System.EventHandler(this.numericUpDownPixelsBottom_ValueChanged); - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(8, 18); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(178, 13); - this.label4.TabIndex = 18; - this.label4.Text = "Search number of pixels from bottom"; - // - // pictureBox2 - // - this.pictureBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.pictureBox2.ContextMenuStrip = this.contextMenuStripScreenshot; - this.pictureBox2.Cursor = System.Windows.Forms.Cursors.Cross; - this.pictureBox2.Location = new System.Drawing.Point(11, 37); - this.pictureBox2.Name = "pictureBox2"; - this.pictureBox2.Size = new System.Drawing.Size(843, 373); - this.pictureBox2.TabIndex = 4; - this.pictureBox2.TabStop = false; - this.pictureBox2.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox2_Paint); - this.pictureBox2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBox2_MouseClick); - // - // contextMenuStripScreenshot - // - this.contextMenuStripScreenshot.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.saveImageAsToolStripMenuItem}); - this.contextMenuStripScreenshot.Name = "contextMenuStripScreenshot"; - this.contextMenuStripScreenshot.Size = new System.Drawing.Size(158, 26); - // - // saveImageAsToolStripMenuItem - // - this.saveImageAsToolStripMenuItem.Name = "saveImageAsToolStripMenuItem"; - this.saveImageAsToolStripMenuItem.Size = new System.Drawing.Size(157, 22); - this.saveImageAsToolStripMenuItem.Text = "Save image as..."; - this.saveImageAsToolStripMenuItem.Click += new System.EventHandler(this.saveImageAsToolStripMenuItem_Click); - // - // labelClickOnTextColor - // - this.labelClickOnTextColor.AutoSize = true; - this.labelClickOnTextColor.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelClickOnTextColor.ForeColor = System.Drawing.Color.Red; - this.labelClickOnTextColor.Location = new System.Drawing.Point(325, 59); - this.labelClickOnTextColor.Name = "labelClickOnTextColor"; - this.labelClickOnTextColor.Size = new System.Drawing.Size(110, 13); - this.labelClickOnTextColor.TabIndex = 19; - this.labelClickOnTextColor.Text = "Click on text color"; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(797, 695); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 25; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(716, 695); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 24; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // labelStatus - // - this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelStatus.AutoSize = true; - this.labelStatus.Location = new System.Drawing.Point(16, 699); - this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(59, 13); - this.labelStatus.TabIndex = 21; - this.labelStatus.Text = "labelStatus"; - // - // groupBox2 - // - this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox2.Controls.Add(this.button1); - this.groupBox2.Controls.Add(this.pictureBox2); - this.groupBox2.Controls.Add(this.numericUpDownPixelsBottom); - this.groupBox2.Controls.Add(this.label4); - this.groupBox2.Controls.Add(this.labelClickOnTextColor); - this.groupBox2.Location = new System.Drawing.Point(12, 273); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(860, 416); - this.groupBox2.TabIndex = 27; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Subtitle area (red rectangle)"; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(357, 11); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(246, 26); - this.button1.TabIndex = 37; - this.button1.Text = "Take screenshot from video player"; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // timerRefreshProgressbar - // - this.timerRefreshProgressbar.Tick += new System.EventHandler(this.TimerRefreshProgressbarTick); - // - // label8 - // - this.label8.Location = new System.Drawing.Point(125, 236); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(96, 23); - this.label8.TabIndex = 34; - this.label8.Text = "# of subtitles"; - // - // tbBlacks - // - this.tbBlacks.Location = new System.Drawing.Point(229, 236); - this.tbBlacks.Name = "tbBlacks"; - this.tbBlacks.ReadOnly = true; - this.tbBlacks.Size = new System.Drawing.Size(48, 20); - this.tbBlacks.TabIndex = 33; - // - // label9 - // - this.label9.Location = new System.Drawing.Point(125, 209); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(100, 23); - this.label9.TabIndex = 32; - this.label9.Text = "Scanning Frame #"; - // - // tbFrameNum - // - this.tbFrameNum.Location = new System.Drawing.Point(229, 209); - this.tbFrameNum.Name = "tbFrameNum"; - this.tbFrameNum.ReadOnly = true; - this.tbFrameNum.Size = new System.Drawing.Size(48, 20); - this.tbFrameNum.TabIndex = 31; - // - // tbFileName - // - this.tbFileName.Location = new System.Drawing.Point(6, 35); - this.tbFileName.Name = "tbFileName"; - this.tbFileName.Size = new System.Drawing.Size(285, 20); - this.tbFileName.TabIndex = 30; - this.tbFileName.Text = "c:\\foo.mpg"; - // - // label10 - // - this.label10.Location = new System.Drawing.Point(6, 16); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(72, 16); - this.label10.TabIndex = 29; - this.label10.Text = "Source file"; - // - // StartStop - // - this.StartStop.Location = new System.Drawing.Point(16, 209); - this.StartStop.Name = "StartStop"; - this.StartStop.Size = new System.Drawing.Size(75, 26); - this.StartStop.TabIndex = 28; - this.StartStop.Text = "Start"; - this.StartStop.Click += new System.EventHandler(this.StartStop_Click); - // - // groupBox3 - // - this.groupBox3.Controls.Add(this.label10); - this.groupBox3.Controls.Add(this.tbFileName); - this.groupBox3.Location = new System.Drawing.Point(12, 12); - this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(341, 67); - this.groupBox3.TabIndex = 35; - this.groupBox3.TabStop = false; - this.groupBox3.Text = "Input"; - // - // buttonStop - // - this.buttonStop.Location = new System.Drawing.Point(18, 240); - this.buttonStop.Name = "buttonStop"; - this.buttonStop.Size = new System.Drawing.Size(75, 26); - this.buttonStop.TabIndex = 36; - this.buttonStop.Text = "Stop"; - this.buttonStop.Click += new System.EventHandler(this.buttonStop_Click); - // - // mediaPlayer - // - this.mediaPlayer.AllowDrop = true; - this.mediaPlayer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.mediaPlayer.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18))))); - this.mediaPlayer.CurrentPosition = 0D; - this.mediaPlayer.FontSizeFactor = 1F; - this.mediaPlayer.LastParagraph = null; - this.mediaPlayer.Location = new System.Drawing.Point(369, 19); - this.mediaPlayer.Margin = new System.Windows.Forms.Padding(0); - this.mediaPlayer.Name = "mediaPlayer"; - this.mediaPlayer.ShowFullscreenButton = true; - this.mediaPlayer.ShowMuteButton = true; - this.mediaPlayer.ShowStopButton = true; - this.mediaPlayer.Size = new System.Drawing.Size(503, 247); - this.mediaPlayer.SmpteMode = false; - this.mediaPlayer.SubtitleText = ""; - this.mediaPlayer.TabIndex = 23; - this.mediaPlayer.TextRightToLeft = System.Windows.Forms.RightToLeft.No; - this.mediaPlayer.VideoHeight = 0; - this.mediaPlayer.VideoPlayer = null; - this.mediaPlayer.VideoWidth = 0; - this.mediaPlayer.Volume = 0D; - // - // HardSubExtract - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(884, 728); - this.Controls.Add(this.buttonStop); - this.Controls.Add(this.groupBox3); - this.Controls.Add(this.label8); - this.Controls.Add(this.StartStop); - this.Controls.Add(this.tbBlacks); - this.Controls.Add(this.label9); - this.Controls.Add(this.tbFrameNum); - this.Controls.Add(this.labelStatus); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.mediaPlayer); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.groupBox2); - this.KeyPreview = true; - this.MinimumSize = new System.Drawing.Size(900, 700); - this.Name = "HardSubExtract"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Import/OCR burned-in subtitles from video file"; - this.Shown += new System.EventHandler(this.HardSubExtract_Shown); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCustomColor)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCustomMaxDiff)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsBottom)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); - this.contextMenuStripScreenshot.ResumeLayout(false); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - this.groupBox3.ResumeLayout(false); - this.groupBox3.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.PictureBox pictureBox2; - private System.Windows.Forms.Label labelClickOnTextColor; - private System.Windows.Forms.NumericUpDown numericUpDownPixelsBottom; - private Controls.VideoPlayerContainer mediaPlayer; - private System.Windows.Forms.OpenFileDialog openFileDialogVideo; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Label labelStatus; - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.Timer timerRefreshProgressbar; - private System.Windows.Forms.Label label8; - private System.Windows.Forms.TextBox tbBlacks; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.TextBox tbFrameNum; - private System.Windows.Forms.TextBox tbFileName; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.Button StartStop; - private System.Windows.Forms.GroupBox groupBox3; - private System.Windows.Forms.CheckBox checkBoxCustomColor; - private System.Windows.Forms.CheckBox checkBoxYellow; - private System.Windows.Forms.NumericUpDown numericUpDownCustomMaxDiff; - private System.Windows.Forms.PictureBox pictureBoxCustomColor; - private System.Windows.Forms.ColorDialog colorDialog1; - private System.Windows.Forms.Button buttonStop; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Label labelCustomRgb; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.ContextMenuStrip contextMenuStripScreenshot; - private System.Windows.Forms.ToolStripMenuItem saveImageAsToolStripMenuItem; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class HardSubExtract + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.label1 = new System.Windows.Forms.Label(); + this.labelCustomRgb = new System.Windows.Forms.Label(); + this.pictureBoxCustomColor = new System.Windows.Forms.PictureBox(); + this.numericUpDownCustomMaxDiff = new System.Windows.Forms.NumericUpDown(); + this.checkBoxCustomColor = new System.Windows.Forms.CheckBox(); + this.checkBoxYellow = new System.Windows.Forms.CheckBox(); + this.numericUpDownPixelsBottom = new System.Windows.Forms.NumericUpDown(); + this.label4 = new System.Windows.Forms.Label(); + this.pictureBox2 = new System.Windows.Forms.PictureBox(); + this.contextMenuStripScreenshot = new System.Windows.Forms.ContextMenuStrip(this.components); + this.saveImageAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.labelClickOnTextColor = new System.Windows.Forms.Label(); + this.openFileDialogVideo = new System.Windows.Forms.OpenFileDialog(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.labelStatus = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.button1 = new System.Windows.Forms.Button(); + this.timerRefreshProgressbar = new System.Windows.Forms.Timer(this.components); + this.label8 = new System.Windows.Forms.Label(); + this.tbBlacks = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.tbFrameNum = new System.Windows.Forms.TextBox(); + this.tbFileName = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.StartStop = new System.Windows.Forms.Button(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.colorDialog1 = new System.Windows.Forms.ColorDialog(); + this.buttonStop = new System.Windows.Forms.Button(); + this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCustomColor)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCustomMaxDiff)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsBottom)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); + this.contextMenuStripScreenshot.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Controls.Add(this.labelCustomRgb); + this.groupBox1.Controls.Add(this.pictureBoxCustomColor); + this.groupBox1.Controls.Add(this.numericUpDownCustomMaxDiff); + this.groupBox1.Controls.Add(this.checkBoxCustomColor); + this.groupBox1.Controls.Add(this.checkBoxYellow); + this.groupBox1.Location = new System.Drawing.Point(12, 85); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(341, 117); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Detection options"; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(9, 80); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(101, 16); + this.label1.TabIndex = 31; + this.label1.Text = "Allow diff per RGB"; + // + // labelCustomRgb + // + this.labelCustomRgb.AutoSize = true; + this.labelCustomRgb.Location = new System.Drawing.Point(177, 56); + this.labelCustomRgb.Name = "labelCustomRgb"; + this.labelCustomRgb.Size = new System.Drawing.Size(30, 13); + this.labelCustomRgb.TabIndex = 37; + this.labelCustomRgb.Text = "RGB"; + // + // pictureBoxCustomColor + // + this.pictureBoxCustomColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pictureBoxCustomColor.Location = new System.Drawing.Point(152, 53); + this.pictureBoxCustomColor.Name = "pictureBoxCustomColor"; + this.pictureBoxCustomColor.Size = new System.Drawing.Size(21, 21); + this.pictureBoxCustomColor.TabIndex = 8; + this.pictureBoxCustomColor.TabStop = false; + this.pictureBoxCustomColor.Click += new System.EventHandler(this.pictureBoxCustomColor_Click); + // + // numericUpDownCustomMaxDiff + // + this.numericUpDownCustomMaxDiff.Location = new System.Drawing.Point(116, 76); + this.numericUpDownCustomMaxDiff.Name = "numericUpDownCustomMaxDiff"; + this.numericUpDownCustomMaxDiff.Size = new System.Drawing.Size(38, 20); + this.numericUpDownCustomMaxDiff.TabIndex = 2; + this.numericUpDownCustomMaxDiff.Value = new decimal(new int[] { + 14, + 0, + 0, + 0}); + // + // checkBoxCustomColor + // + this.checkBoxCustomColor.AutoSize = true; + this.checkBoxCustomColor.Location = new System.Drawing.Point(11, 55); + this.checkBoxCustomColor.Name = "checkBoxCustomColor"; + this.checkBoxCustomColor.Size = new System.Drawing.Size(135, 17); + this.checkBoxCustomColor.TabIndex = 1; + this.checkBoxCustomColor.Text = "Check for custom color"; + this.checkBoxCustomColor.UseVisualStyleBackColor = true; + // + // checkBoxYellow + // + this.checkBoxYellow.AutoSize = true; + this.checkBoxYellow.Checked = true; + this.checkBoxYellow.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxYellow.Location = new System.Drawing.Point(9, 19); + this.checkBoxYellow.Name = "checkBoxYellow"; + this.checkBoxYellow.Size = new System.Drawing.Size(124, 17); + this.checkBoxYellow.TabIndex = 0; + this.checkBoxYellow.Text = "Check for yellow text"; + this.checkBoxYellow.UseVisualStyleBackColor = true; + // + // numericUpDownPixelsBottom + // + this.numericUpDownPixelsBottom.Location = new System.Drawing.Point(192, 16); + this.numericUpDownPixelsBottom.Maximum = new decimal(new int[] { + 2000, + 0, + 0, + 0}); + this.numericUpDownPixelsBottom.Name = "numericUpDownPixelsBottom"; + this.numericUpDownPixelsBottom.Size = new System.Drawing.Size(66, 20); + this.numericUpDownPixelsBottom.TabIndex = 19; + this.numericUpDownPixelsBottom.Value = new decimal(new int[] { + 127, + 0, + 0, + 0}); + this.numericUpDownPixelsBottom.ValueChanged += new System.EventHandler(this.numericUpDownPixelsBottom_ValueChanged); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(8, 18); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(178, 13); + this.label4.TabIndex = 18; + this.label4.Text = "Search number of pixels from bottom"; + // + // pictureBox2 + // + this.pictureBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBox2.ContextMenuStrip = this.contextMenuStripScreenshot; + this.pictureBox2.Cursor = System.Windows.Forms.Cursors.Cross; + this.pictureBox2.Location = new System.Drawing.Point(11, 37); + this.pictureBox2.Name = "pictureBox2"; + this.pictureBox2.Size = new System.Drawing.Size(843, 373); + this.pictureBox2.TabIndex = 4; + this.pictureBox2.TabStop = false; + this.pictureBox2.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox2_Paint); + this.pictureBox2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBox2_MouseClick); + // + // contextMenuStripScreenshot + // + this.contextMenuStripScreenshot.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.saveImageAsToolStripMenuItem}); + this.contextMenuStripScreenshot.Name = "contextMenuStripScreenshot"; + this.contextMenuStripScreenshot.Size = new System.Drawing.Size(158, 26); + // + // saveImageAsToolStripMenuItem + // + this.saveImageAsToolStripMenuItem.Name = "saveImageAsToolStripMenuItem"; + this.saveImageAsToolStripMenuItem.Size = new System.Drawing.Size(157, 22); + this.saveImageAsToolStripMenuItem.Text = "Save image as..."; + this.saveImageAsToolStripMenuItem.Click += new System.EventHandler(this.saveImageAsToolStripMenuItem_Click); + // + // labelClickOnTextColor + // + this.labelClickOnTextColor.AutoSize = true; + this.labelClickOnTextColor.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelClickOnTextColor.ForeColor = System.Drawing.Color.Red; + this.labelClickOnTextColor.Location = new System.Drawing.Point(325, 59); + this.labelClickOnTextColor.Name = "labelClickOnTextColor"; + this.labelClickOnTextColor.Size = new System.Drawing.Size(110, 13); + this.labelClickOnTextColor.TabIndex = 19; + this.labelClickOnTextColor.Text = "Click on text color"; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(797, 695); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 25; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(716, 695); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 24; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // labelStatus + // + this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(16, 699); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(59, 13); + this.labelStatus.TabIndex = 21; + this.labelStatus.Text = "labelStatus"; + // + // groupBox2 + // + this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox2.Controls.Add(this.button1); + this.groupBox2.Controls.Add(this.pictureBox2); + this.groupBox2.Controls.Add(this.numericUpDownPixelsBottom); + this.groupBox2.Controls.Add(this.label4); + this.groupBox2.Controls.Add(this.labelClickOnTextColor); + this.groupBox2.Location = new System.Drawing.Point(12, 273); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(860, 416); + this.groupBox2.TabIndex = 27; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Subtitle area (red rectangle)"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(357, 11); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(246, 26); + this.button1.TabIndex = 37; + this.button1.Text = "Take screenshot from video player"; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // timerRefreshProgressbar + // + this.timerRefreshProgressbar.Tick += new System.EventHandler(this.TimerRefreshProgressbarTick); + // + // label8 + // + this.label8.Location = new System.Drawing.Point(125, 236); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(96, 23); + this.label8.TabIndex = 34; + this.label8.Text = "# of subtitles"; + // + // tbBlacks + // + this.tbBlacks.Location = new System.Drawing.Point(229, 236); + this.tbBlacks.Name = "tbBlacks"; + this.tbBlacks.ReadOnly = true; + this.tbBlacks.Size = new System.Drawing.Size(48, 20); + this.tbBlacks.TabIndex = 33; + // + // label9 + // + this.label9.Location = new System.Drawing.Point(125, 209); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(100, 23); + this.label9.TabIndex = 32; + this.label9.Text = "Scanning Frame #"; + // + // tbFrameNum + // + this.tbFrameNum.Location = new System.Drawing.Point(229, 209); + this.tbFrameNum.Name = "tbFrameNum"; + this.tbFrameNum.ReadOnly = true; + this.tbFrameNum.Size = new System.Drawing.Size(48, 20); + this.tbFrameNum.TabIndex = 31; + // + // tbFileName + // + this.tbFileName.Location = new System.Drawing.Point(6, 35); + this.tbFileName.Name = "tbFileName"; + this.tbFileName.Size = new System.Drawing.Size(285, 20); + this.tbFileName.TabIndex = 30; + this.tbFileName.Text = "c:\\foo.mpg"; + // + // label10 + // + this.label10.Location = new System.Drawing.Point(6, 16); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(72, 16); + this.label10.TabIndex = 29; + this.label10.Text = "Source file"; + // + // StartStop + // + this.StartStop.Location = new System.Drawing.Point(16, 209); + this.StartStop.Name = "StartStop"; + this.StartStop.Size = new System.Drawing.Size(75, 26); + this.StartStop.TabIndex = 28; + this.StartStop.Text = "Start"; + this.StartStop.Click += new System.EventHandler(this.StartStop_Click); + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.label10); + this.groupBox3.Controls.Add(this.tbFileName); + this.groupBox3.Location = new System.Drawing.Point(12, 12); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(341, 67); + this.groupBox3.TabIndex = 35; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Input"; + // + // buttonStop + // + this.buttonStop.Location = new System.Drawing.Point(18, 240); + this.buttonStop.Name = "buttonStop"; + this.buttonStop.Size = new System.Drawing.Size(75, 26); + this.buttonStop.TabIndex = 36; + this.buttonStop.Text = "Stop"; + this.buttonStop.Click += new System.EventHandler(this.buttonStop_Click); + // + // mediaPlayer + // + this.mediaPlayer.AllowDrop = true; + this.mediaPlayer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.mediaPlayer.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18))))); + this.mediaPlayer.CurrentPosition = 0D; + this.mediaPlayer.FontSizeFactor = 1F; + this.mediaPlayer.LastParagraph = null; + this.mediaPlayer.Location = new System.Drawing.Point(369, 19); + this.mediaPlayer.Margin = new System.Windows.Forms.Padding(0); + this.mediaPlayer.Name = "mediaPlayer"; + this.mediaPlayer.ShowFullscreenButton = true; + this.mediaPlayer.ShowMuteButton = true; + this.mediaPlayer.ShowStopButton = true; + this.mediaPlayer.Size = new System.Drawing.Size(503, 247); + this.mediaPlayer.SmpteMode = false; + this.mediaPlayer.SubtitleText = ""; + this.mediaPlayer.TabIndex = 23; + this.mediaPlayer.TextRightToLeft = System.Windows.Forms.RightToLeft.No; + this.mediaPlayer.VideoHeight = 0; + this.mediaPlayer.VideoPlayer = null; + this.mediaPlayer.VideoWidth = 0; + this.mediaPlayer.Volume = 0D; + // + // HardSubExtract + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(884, 728); + this.Controls.Add(this.buttonStop); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.label8); + this.Controls.Add(this.StartStop); + this.Controls.Add(this.tbBlacks); + this.Controls.Add(this.label9); + this.Controls.Add(this.tbFrameNum); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.mediaPlayer); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.groupBox2); + this.KeyPreview = true; + this.MinimumSize = new System.Drawing.Size(900, 700); + this.Name = "HardSubExtract"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Import/OCR burned-in subtitles from video file"; + this.Shown += new System.EventHandler(this.HardSubExtract_Shown); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCustomColor)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCustomMaxDiff)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsBottom)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); + this.contextMenuStripScreenshot.ResumeLayout(false); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.PictureBox pictureBox2; + private System.Windows.Forms.Label labelClickOnTextColor; + private System.Windows.Forms.NumericUpDown numericUpDownPixelsBottom; + private Controls.VideoPlayerContainer mediaPlayer; + private System.Windows.Forms.OpenFileDialog openFileDialogVideo; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Label labelStatus; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Timer timerRefreshProgressbar; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.TextBox tbBlacks; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox tbFrameNum; + private System.Windows.Forms.TextBox tbFileName; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Button StartStop; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.CheckBox checkBoxCustomColor; + private System.Windows.Forms.CheckBox checkBoxYellow; + private System.Windows.Forms.NumericUpDown numericUpDownCustomMaxDiff; + private System.Windows.Forms.PictureBox pictureBoxCustomColor; + private System.Windows.Forms.ColorDialog colorDialog1; + private System.Windows.Forms.Button buttonStop; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label labelCustomRgb; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ContextMenuStrip contextMenuStripScreenshot; + private System.Windows.Forms.ToolStripMenuItem saveImageAsToolStripMenuItem; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + } } \ No newline at end of file diff --git a/src/Forms/HardSubExtract.cs b/src/ui/Forms/HardSubExtract.cs similarity index 97% rename from src/Forms/HardSubExtract.cs rename to src/ui/Forms/HardSubExtract.cs index 1780282e1..a3d26cee2 100644 --- a/src/Forms/HardSubExtract.cs +++ b/src/ui/Forms/HardSubExtract.cs @@ -1,341 +1,341 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using Nikse.SubtitleEdit.Logic.VideoPlayers; -using System; -using System.Drawing; -using System.IO; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -//using Nikse.SubtitleEdit.Logic.DirectShow.Custom; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class HardSubExtract : Form - { - // HardExtractCapture cam = null; - private string _videoFileName; - private LibVlcDynamic _libVlc; - private VideoInfo _videoInfo; - //long startMilliseconds = 0; - public Subtitle SubtitleFromOcr; - //private System.Windows.Forms.Timer timer1; - private const int lineChecksWidth = 50; - private const int lineChecksHeight = 25; - public string OcrFileName; - - public HardSubExtract(string videoFileName) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _videoFileName = videoFileName; - labelClickOnTextColor.Visible = false; - SubtitleFromOcr = new Subtitle(); - labelStatus.Text = string.Empty; - tbFileName.Text = videoFileName; - pictureBoxCustomColor.BackColor = Color.FromArgb(233, 233, 233); - SetCustumRGB(); - } - - private void HardSubExtract_Shown(object sender, EventArgs e) - { - if (openFileDialogVideo.ShowDialog(this) == DialogResult.OK) - { - _videoFileName = openFileDialogVideo.FileName; - tbFileName.Text = openFileDialogVideo.FileName; - _videoInfo = UiUtil.GetVideoInfo(_videoFileName); - var oldPlayer = Configuration.Settings.General.VideoPlayer; - Configuration.Settings.General.VideoPlayer = "VLC"; - UiUtil.InitializeVideoPlayerAndContainer(_videoFileName, _videoInfo, mediaPlayer, VideoLoaded, null); - Configuration.Settings.General.VideoPlayer = oldPlayer; - _libVlc = mediaPlayer.VideoPlayer as LibVlcDynamic; - } - else - { - DialogResult = DialogResult.Cancel; - } - } - - private void VideoLoaded(object sender, EventArgs e) - { - mediaPlayer.Stop(); - mediaPlayer.Volume = Configuration.Settings.General.VideoPlayerDefaultVolume; - // pictureBox2.Image = GetSnapShot(startMilliseconds); - mediaPlayer.Pause(); - timerRefreshProgressbar.Start(); - pictureBox2.Refresh(); - } - - //private Bitmap GetSnapShot(long milliseconds) - //{ - // string fileName = Path.Combine(_folderName, Guid.NewGuid().ToString() + ".png"); - // _libVlc.CurrentPosition = milliseconds / TimeCode.BaseUnit; - // _libVlc.TakeSnapshot(fileName, (uint)_videoInfo.Width, (uint)_videoInfo.Height); - // int i=0; - // while (i < 100 && !File.Exists(fileName)) - // { - // System.Threading.Thread.Sleep(5); - // Application.DoEvents(); - // i++; - // } - // System.Threading.Thread.Sleep(5); - // Application.DoEvents(); - // Bitmap bmp = null; - // try - // { - // using (var ms = new MemoryStream(File.ReadAllBytes(fileName))) - // { - // ms.Position = 0; - // bmp = ((Bitmap)Bitmap.FromStream(ms)); // avoid locking file - // } - // File.Delete(fileName); - // } - // catch - // { - // } - // return bmp; - //} - - private void pictureBox2_MouseClick(object sender, MouseEventArgs e) - { - if (pictureBox2.Image != null) - { - Bitmap bmp = pictureBox2.Image as Bitmap; - if (bmp != null) - { - pictureBoxCustomColor.BackColor = bmp.GetPixel(e.X, e.Y); - SetCustumRGB(); - } - } - } - - private void pictureBox2_Paint(object sender, PaintEventArgs e) - { - Bitmap bmp = pictureBox2.Image as Bitmap; - if (bmp != null) - { - using (Pen p = new Pen(Brushes.Red)) - { - int value = Convert.ToInt32(numericUpDownPixelsBottom.Value); - if (value > bmp.Height) - { - value = bmp.Height - 2; - } - - e.Graphics.DrawRectangle(p, 0, bmp.Height - value, bmp.Width - 1, bmp.Height - (bmp.Height - value) - 1); - } - } - } - - private void TimerRefreshProgressbarTick(object sender, EventArgs e) - { - mediaPlayer.RefreshProgressBar(); - } - - private void numericUpDownPixelsBottom_ValueChanged(object sender, EventArgs e) - { - pictureBox2.Invalidate(); - } - - private void StartStop_Click(object sender, EventArgs e) - { - //Cursor.Current = Cursors.WaitCursor; - //buttonStop.Visible = true; - //StartStop.Enabled = false; - //cam = new HardExtractCapture(tbFileName.Text, (int)numericUpDownPixelsBottom.Value, checkBoxCustomColor.Checked, checkBoxYellow.Checked, pictureBoxCustomColor.BackColor, (int)numericUpDownCustomMaxDiff.Value); - - //// Start displaying statistics - //this.timer1 = new System.Windows.Forms.Timer(this.components); - //this.timer1.Interval = 1000; - //this.timer1.Tick += new System.EventHandler(this.timer1_Tick); - //timer1.Enabled = true; - //cam.Start(); - //cam.WaitUntilDone(); - //timer1.Enabled = false; - - //// Final update - //tbFrameNum.Text = cam.count.ToString(); - //tbBlacks.Text = cam.blacks.ToString(); - - //string fileNameNoExt = Path.GetTempFileName(); - - //Cursor.Current = Cursors.Default; - - //var sub = new Subtitle(); - //for (int i = 0; i < cam.Images.Count; i++) - //{ - // if (cam.StartTimes.Count > i) - // { - // Paragraph p = new Paragraph(); - // p.StartTime.TotalSeconds = cam.StartTimes[i]; - // if (cam.EndTimes.Count > i) - // { - // p.EndTime.TotalSeconds = cam.EndTimes[i]; - // } - // else - // { - // p.EndTime.TotalSeconds = p.StartTime.TotalSeconds + 2.5; - // } - // p.Text = fileNameNoExt + string.Format("{0:0000}", i) + ".bmp"; - // sub.Paragraphs.Add(p); - // var bmp = cam.Images[i].GetBitmap(); - // bmp.Save(p.Text); - // bmp.Dispose(); - // } - //} - //sub.Renumber(); - //if (sub.Paragraphs.Count > 0) - //{ - // OcrFileName = fileNameNoExt + ".srt"; - // File.WriteAllText(OcrFileName, sub.ToText(new SubRip())); - //} - //lock (this) - //{ - // cam.Dispose(); - // cam = null; - //} - //buttonStop.Visible = false; - //StartStop.Enabled = true; - } - - //private void timer1_Tick(object sender, System.EventArgs e) - //{ - //if (cam != null) - //{ - // tbFrameNum.Text = cam.count.ToString(); - // tbBlacks.Text = cam.blacks.ToString(); - // if (cam.Images.Count > 0) - // { - // var old = pictureBox2.Image as Bitmap; - // pictureBox2.Image = cam.Images[cam.Images.Count - 1].GetBitmap(); - // if (old != null) - // old.Dispose(); - // } - //} - //} - - private void pictureBoxCustomColor_Click(object sender, EventArgs e) - { - colorDialog1.Color = pictureBoxCustomColor.BackColor; - if (colorDialog1.ShowDialog(this) == DialogResult.OK) - { - pictureBoxCustomColor.BackColor = colorDialog1.Color; - SetCustumRGB(); - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void buttonStop_Click(object sender, EventArgs e) - { - //if (cam != null) - // cam.Cancel = true; - //buttonStop.Visible = false; - //StartStop.Enabled = true; - } - - private void button1_Click(object sender, EventArgs e) - { - var fileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".bmp"); - try - { - _libVlc.TakeSnapshot(fileName, (uint)_videoInfo.Width, (uint)_videoInfo.Height); - System.Threading.Thread.Sleep(100); - pictureBox2.Image = Image.FromFile(fileName); - System.Threading.Thread.Sleep(50); - } - catch (FileNotFoundException) - { - // the screenshot was not taken - } - catch - { - // TODO: Avoid catching all exceptions - } - finally - { - // whatever happens delete the screenshot if it exists - File.Delete(fileName); - } - } - - private void SetCustumRGB() - { - labelCustomRgb.Text = string.Format("(Red={0},Green={1},Blue={2})", pictureBoxCustomColor.BackColor.R, pictureBoxCustomColor.BackColor.G, pictureBoxCustomColor.BackColor.B); - } - - private void saveImageAsToolStripMenuItem_Click(object sender, EventArgs e) - { - saveFileDialog1.Title = Configuration.Settings.Language.VobSubOcr.SaveSubtitleImageAs; - saveFileDialog1.AddExtension = true; - saveFileDialog1.FileName = "Image"; - saveFileDialog1.Filter = "PNG image|*.png|BMP image|*.bmp|GIF image|*.gif|TIFF image|*.tiff"; - saveFileDialog1.FilterIndex = 0; - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - using (var bmp = pictureBox2.Image as Bitmap) - { - if (bmp == null) - { - MessageBox.Show("No image!"); - return; - } - - try - { - if (saveFileDialog1.FilterIndex == 0) - { - bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png); - } - else if (saveFileDialog1.FilterIndex == 1) - { - bmp.Save(saveFileDialog1.FileName); - } - else if (saveFileDialog1.FilterIndex == 2) - { - bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Gif); - } - else - { - bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Tiff); - } - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - } - } - } - } - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - if (_libVlc != null) - { - _libVlc.Dispose(); - _libVlc = null; - } - } - base.Dispose(disposing); - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using Nikse.SubtitleEdit.Logic.VideoPlayers; +using System; +using System.Drawing; +using System.IO; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +//using Nikse.SubtitleEdit.Logic.DirectShow.Custom; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class HardSubExtract : Form + { + // HardExtractCapture cam = null; + private string _videoFileName; + private LibVlcDynamic _libVlc; + private VideoInfo _videoInfo; + //long startMilliseconds = 0; + public Subtitle SubtitleFromOcr; + //private System.Windows.Forms.Timer timer1; + private const int lineChecksWidth = 50; + private const int lineChecksHeight = 25; + public string OcrFileName; + + public HardSubExtract(string videoFileName) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _videoFileName = videoFileName; + labelClickOnTextColor.Visible = false; + SubtitleFromOcr = new Subtitle(); + labelStatus.Text = string.Empty; + tbFileName.Text = videoFileName; + pictureBoxCustomColor.BackColor = Color.FromArgb(233, 233, 233); + SetCustumRGB(); + } + + private void HardSubExtract_Shown(object sender, EventArgs e) + { + if (openFileDialogVideo.ShowDialog(this) == DialogResult.OK) + { + _videoFileName = openFileDialogVideo.FileName; + tbFileName.Text = openFileDialogVideo.FileName; + _videoInfo = UiUtil.GetVideoInfo(_videoFileName); + var oldPlayer = Configuration.Settings.General.VideoPlayer; + Configuration.Settings.General.VideoPlayer = "VLC"; + UiUtil.InitializeVideoPlayerAndContainer(_videoFileName, _videoInfo, mediaPlayer, VideoLoaded, null); + Configuration.Settings.General.VideoPlayer = oldPlayer; + _libVlc = mediaPlayer.VideoPlayer as LibVlcDynamic; + } + else + { + DialogResult = DialogResult.Cancel; + } + } + + private void VideoLoaded(object sender, EventArgs e) + { + mediaPlayer.Stop(); + mediaPlayer.Volume = Configuration.Settings.General.VideoPlayerDefaultVolume; + // pictureBox2.Image = GetSnapShot(startMilliseconds); + mediaPlayer.Pause(); + timerRefreshProgressbar.Start(); + pictureBox2.Refresh(); + } + + //private Bitmap GetSnapShot(long milliseconds) + //{ + // string fileName = Path.Combine(_folderName, Guid.NewGuid().ToString() + ".png"); + // _libVlc.CurrentPosition = milliseconds / TimeCode.BaseUnit; + // _libVlc.TakeSnapshot(fileName, (uint)_videoInfo.Width, (uint)_videoInfo.Height); + // int i=0; + // while (i < 100 && !File.Exists(fileName)) + // { + // System.Threading.Thread.Sleep(5); + // Application.DoEvents(); + // i++; + // } + // System.Threading.Thread.Sleep(5); + // Application.DoEvents(); + // Bitmap bmp = null; + // try + // { + // using (var ms = new MemoryStream(File.ReadAllBytes(fileName))) + // { + // ms.Position = 0; + // bmp = ((Bitmap)Bitmap.FromStream(ms)); // avoid locking file + // } + // File.Delete(fileName); + // } + // catch + // { + // } + // return bmp; + //} + + private void pictureBox2_MouseClick(object sender, MouseEventArgs e) + { + if (pictureBox2.Image != null) + { + Bitmap bmp = pictureBox2.Image as Bitmap; + if (bmp != null) + { + pictureBoxCustomColor.BackColor = bmp.GetPixel(e.X, e.Y); + SetCustumRGB(); + } + } + } + + private void pictureBox2_Paint(object sender, PaintEventArgs e) + { + Bitmap bmp = pictureBox2.Image as Bitmap; + if (bmp != null) + { + using (Pen p = new Pen(Brushes.Red)) + { + int value = Convert.ToInt32(numericUpDownPixelsBottom.Value); + if (value > bmp.Height) + { + value = bmp.Height - 2; + } + + e.Graphics.DrawRectangle(p, 0, bmp.Height - value, bmp.Width - 1, bmp.Height - (bmp.Height - value) - 1); + } + } + } + + private void TimerRefreshProgressbarTick(object sender, EventArgs e) + { + mediaPlayer.RefreshProgressBar(); + } + + private void numericUpDownPixelsBottom_ValueChanged(object sender, EventArgs e) + { + pictureBox2.Invalidate(); + } + + private void StartStop_Click(object sender, EventArgs e) + { + //Cursor.Current = Cursors.WaitCursor; + //buttonStop.Visible = true; + //StartStop.Enabled = false; + //cam = new HardExtractCapture(tbFileName.Text, (int)numericUpDownPixelsBottom.Value, checkBoxCustomColor.Checked, checkBoxYellow.Checked, pictureBoxCustomColor.BackColor, (int)numericUpDownCustomMaxDiff.Value); + + //// Start displaying statistics + //this.timer1 = new System.Windows.Forms.Timer(this.components); + //this.timer1.Interval = 1000; + //this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + //timer1.Enabled = true; + //cam.Start(); + //cam.WaitUntilDone(); + //timer1.Enabled = false; + + //// Final update + //tbFrameNum.Text = cam.count.ToString(); + //tbBlacks.Text = cam.blacks.ToString(); + + //string fileNameNoExt = Path.GetTempFileName(); + + //Cursor.Current = Cursors.Default; + + //var sub = new Subtitle(); + //for (int i = 0; i < cam.Images.Count; i++) + //{ + // if (cam.StartTimes.Count > i) + // { + // Paragraph p = new Paragraph(); + // p.StartTime.TotalSeconds = cam.StartTimes[i]; + // if (cam.EndTimes.Count > i) + // { + // p.EndTime.TotalSeconds = cam.EndTimes[i]; + // } + // else + // { + // p.EndTime.TotalSeconds = p.StartTime.TotalSeconds + 2.5; + // } + // p.Text = fileNameNoExt + string.Format("{0:0000}", i) + ".bmp"; + // sub.Paragraphs.Add(p); + // var bmp = cam.Images[i].GetBitmap(); + // bmp.Save(p.Text); + // bmp.Dispose(); + // } + //} + //sub.Renumber(); + //if (sub.Paragraphs.Count > 0) + //{ + // OcrFileName = fileNameNoExt + ".srt"; + // File.WriteAllText(OcrFileName, sub.ToText(new SubRip())); + //} + //lock (this) + //{ + // cam.Dispose(); + // cam = null; + //} + //buttonStop.Visible = false; + //StartStop.Enabled = true; + } + + //private void timer1_Tick(object sender, System.EventArgs e) + //{ + //if (cam != null) + //{ + // tbFrameNum.Text = cam.count.ToString(); + // tbBlacks.Text = cam.blacks.ToString(); + // if (cam.Images.Count > 0) + // { + // var old = pictureBox2.Image as Bitmap; + // pictureBox2.Image = cam.Images[cam.Images.Count - 1].GetBitmap(); + // if (old != null) + // old.Dispose(); + // } + //} + //} + + private void pictureBoxCustomColor_Click(object sender, EventArgs e) + { + colorDialog1.Color = pictureBoxCustomColor.BackColor; + if (colorDialog1.ShowDialog(this) == DialogResult.OK) + { + pictureBoxCustomColor.BackColor = colorDialog1.Color; + SetCustumRGB(); + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void buttonStop_Click(object sender, EventArgs e) + { + //if (cam != null) + // cam.Cancel = true; + //buttonStop.Visible = false; + //StartStop.Enabled = true; + } + + private void button1_Click(object sender, EventArgs e) + { + var fileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".bmp"); + try + { + _libVlc.TakeSnapshot(fileName, (uint)_videoInfo.Width, (uint)_videoInfo.Height); + System.Threading.Thread.Sleep(100); + pictureBox2.Image = Image.FromFile(fileName); + System.Threading.Thread.Sleep(50); + } + catch (FileNotFoundException) + { + // the screenshot was not taken + } + catch + { + // TODO: Avoid catching all exceptions + } + finally + { + // whatever happens delete the screenshot if it exists + File.Delete(fileName); + } + } + + private void SetCustumRGB() + { + labelCustomRgb.Text = string.Format("(Red={0},Green={1},Blue={2})", pictureBoxCustomColor.BackColor.R, pictureBoxCustomColor.BackColor.G, pictureBoxCustomColor.BackColor.B); + } + + private void saveImageAsToolStripMenuItem_Click(object sender, EventArgs e) + { + saveFileDialog1.Title = Configuration.Settings.Language.VobSubOcr.SaveSubtitleImageAs; + saveFileDialog1.AddExtension = true; + saveFileDialog1.FileName = "Image"; + saveFileDialog1.Filter = "PNG image|*.png|BMP image|*.bmp|GIF image|*.gif|TIFF image|*.tiff"; + saveFileDialog1.FilterIndex = 0; + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + using (var bmp = pictureBox2.Image as Bitmap) + { + if (bmp == null) + { + MessageBox.Show("No image!"); + return; + } + + try + { + if (saveFileDialog1.FilterIndex == 0) + { + bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png); + } + else if (saveFileDialog1.FilterIndex == 1) + { + bmp.Save(saveFileDialog1.FileName); + } + else if (saveFileDialog1.FilterIndex == 2) + { + bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Gif); + } + else + { + bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Tiff); + } + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + } + } + } + } + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + if (_libVlc != null) + { + _libVlc.Dispose(); + _libVlc = null; + } + } + base.Dispose(disposing); + } + + } +} diff --git a/src/Forms/HardSubExtract.resx b/src/ui/Forms/HardSubExtract.resx similarity index 98% rename from src/Forms/HardSubExtract.resx rename to src/ui/Forms/HardSubExtract.resx index d3f80ccd3..ca09855a0 100644 --- a/src/Forms/HardSubExtract.resx +++ b/src/ui/Forms/HardSubExtract.resx @@ -1,135 +1,135 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 489, 17 - - - 17, 17 - - - 182, 17 - - - 368, 17 - - - 698, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 489, 17 + + + 17, 17 + + + 182, 17 + + + 368, 17 + + + 698, 17 + \ No newline at end of file diff --git a/src/Forms/ImportCdg.Designer.cs b/src/ui/Forms/ImportCdg.Designer.cs similarity index 100% rename from src/Forms/ImportCdg.Designer.cs rename to src/ui/Forms/ImportCdg.Designer.cs diff --git a/src/Forms/ImportCdg.cs b/src/ui/Forms/ImportCdg.cs similarity index 100% rename from src/Forms/ImportCdg.cs rename to src/ui/Forms/ImportCdg.cs diff --git a/src/Forms/ImportCdg.resx b/src/ui/Forms/ImportCdg.resx similarity index 100% rename from src/Forms/ImportCdg.resx rename to src/ui/Forms/ImportCdg.resx diff --git a/src/Forms/ImportFinalDraft.Designer.cs b/src/ui/Forms/ImportFinalDraft.Designer.cs similarity index 100% rename from src/Forms/ImportFinalDraft.Designer.cs rename to src/ui/Forms/ImportFinalDraft.Designer.cs diff --git a/src/Forms/ImportFinalDraft.cs b/src/ui/Forms/ImportFinalDraft.cs similarity index 100% rename from src/Forms/ImportFinalDraft.cs rename to src/ui/Forms/ImportFinalDraft.cs diff --git a/src/Forms/Ocr/GetTesseract302Dictionaries.resx b/src/ui/Forms/ImportFinalDraft.resx similarity index 100% rename from src/Forms/Ocr/GetTesseract302Dictionaries.resx rename to src/ui/Forms/ImportFinalDraft.resx diff --git a/src/Forms/ImportImages.Designer.cs b/src/ui/Forms/ImportImages.Designer.cs similarity index 98% rename from src/Forms/ImportImages.Designer.cs rename to src/ui/Forms/ImportImages.Designer.cs index 792c6c596..1f2efec2c 100644 --- a/src/Forms/ImportImages.Designer.cs +++ b/src/ui/Forms/ImportImages.Designer.cs @@ -1,225 +1,225 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ImportImages - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.groupBoxInput = new System.Windows.Forms.GroupBox(); - this.buttonInputBrowse = new System.Windows.Forms.Button(); - this.labelChooseInputFiles = new System.Windows.Forms.Label(); - this.listViewInputFiles = new System.Windows.Forms.ListView(); - this.columnHeaderFName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderStartTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderEndTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderDuration = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.groupBoxInput.SuspendLayout(); - this.contextMenuStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxInput - // - this.groupBoxInput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxInput.Controls.Add(this.buttonInputBrowse); - this.groupBoxInput.Controls.Add(this.labelChooseInputFiles); - this.groupBoxInput.Controls.Add(this.listViewInputFiles); - this.groupBoxInput.Location = new System.Drawing.Point(12, 12); - this.groupBoxInput.Name = "groupBoxInput"; - this.groupBoxInput.Size = new System.Drawing.Size(1095, 552); - this.groupBoxInput.TabIndex = 1; - this.groupBoxInput.TabStop = false; - this.groupBoxInput.Text = "Input"; - // - // buttonInputBrowse - // - this.buttonInputBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonInputBrowse.Location = new System.Drawing.Point(1060, 41); - this.buttonInputBrowse.Name = "buttonInputBrowse"; - this.buttonInputBrowse.Size = new System.Drawing.Size(26, 23); - this.buttonInputBrowse.TabIndex = 3; - this.buttonInputBrowse.Text = "..."; - this.buttonInputBrowse.UseVisualStyleBackColor = true; - this.buttonInputBrowse.Click += new System.EventHandler(this.buttonInputBrowse_Click); - // - // labelChooseInputFiles - // - this.labelChooseInputFiles.AutoSize = true; - this.labelChooseInputFiles.Location = new System.Drawing.Point(5, 25); - this.labelChooseInputFiles.Name = "labelChooseInputFiles"; - this.labelChooseInputFiles.Size = new System.Drawing.Size(202, 13); - this.labelChooseInputFiles.TabIndex = 0; - this.labelChooseInputFiles.Text = "Choose input files (browse or drag-n-drop)"; - // - // listViewInputFiles - // - this.listViewInputFiles.AllowDrop = true; - this.listViewInputFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewInputFiles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderFName, - this.columnHeaderSize, - this.columnHeaderStartTime, - this.columnHeaderEndTime, - this.columnHeaderDuration}); - this.listViewInputFiles.ContextMenuStrip = this.contextMenuStrip1; - this.listViewInputFiles.FullRowSelect = true; - this.listViewInputFiles.HideSelection = false; - this.listViewInputFiles.Location = new System.Drawing.Point(8, 41); - this.listViewInputFiles.Name = "listViewInputFiles"; - this.listViewInputFiles.Size = new System.Drawing.Size(1049, 497); - this.listViewInputFiles.TabIndex = 2; - this.listViewInputFiles.UseCompatibleStateImageBehavior = false; - this.listViewInputFiles.View = System.Windows.Forms.View.Details; - this.listViewInputFiles.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewInputFiles_DragDrop); - this.listViewInputFiles.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewInputFiles_DragEnter); - // - // columnHeaderFName - // - this.columnHeaderFName.Text = "File name"; - this.columnHeaderFName.Width = 600; - // - // columnHeaderSize - // - this.columnHeaderSize.Text = "Size"; - this.columnHeaderSize.Width = 75; - // - // columnHeaderStartTime - // - this.columnHeaderStartTime.Text = "Start time"; - this.columnHeaderStartTime.Width = 120; - // - // columnHeaderEndTime - // - this.columnHeaderEndTime.Text = "End time"; - this.columnHeaderEndTime.Width = 120; - // - // columnHeaderDuration - // - this.columnHeaderDuration.Text = "Duration"; - this.columnHeaderDuration.Width = 100; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.removeToolStripMenuItem, - this.removeAllToolStripMenuItem}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(133, 48); - this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); - // - // removeToolStripMenuItem - // - this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; - this.removeToolStripMenuItem.Size = new System.Drawing.Size(132, 22); - this.removeToolStripMenuItem.Text = "Remove"; - this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click); - // - // removeAllToolStripMenuItem - // - this.removeAllToolStripMenuItem.Name = "removeAllToolStripMenuItem"; - this.removeAllToolStripMenuItem.Size = new System.Drawing.Size(132, 22); - this.removeAllToolStripMenuItem.Text = "Remove all"; - this.removeAllToolStripMenuItem.Click += new System.EventHandler(this.removeAllToolStripMenuItem_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(951, 570); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 7; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(1032, 570); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 8; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // ImportImages - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1119, 603); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.groupBoxInput); - this.KeyPreview = true; - this.Name = "ImportImages"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "ImportImages"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ImportImages_KeyDown); - this.groupBoxInput.ResumeLayout(false); - this.groupBoxInput.PerformLayout(); - this.contextMenuStrip1.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxInput; - private System.Windows.Forms.Button buttonInputBrowse; - private System.Windows.Forms.Label labelChooseInputFiles; - private System.Windows.Forms.ListView listViewInputFiles; - private System.Windows.Forms.ColumnHeader columnHeaderFName; - private System.Windows.Forms.ColumnHeader columnHeaderSize; - private System.Windows.Forms.ColumnHeader columnHeaderStartTime; - private System.Windows.Forms.ColumnHeader columnHeaderEndTime; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.ColumnHeader columnHeaderDuration; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeAllToolStripMenuItem; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ImportImages + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.groupBoxInput = new System.Windows.Forms.GroupBox(); + this.buttonInputBrowse = new System.Windows.Forms.Button(); + this.labelChooseInputFiles = new System.Windows.Forms.Label(); + this.listViewInputFiles = new System.Windows.Forms.ListView(); + this.columnHeaderFName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderStartTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderEndTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderDuration = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.groupBoxInput.SuspendLayout(); + this.contextMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxInput + // + this.groupBoxInput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxInput.Controls.Add(this.buttonInputBrowse); + this.groupBoxInput.Controls.Add(this.labelChooseInputFiles); + this.groupBoxInput.Controls.Add(this.listViewInputFiles); + this.groupBoxInput.Location = new System.Drawing.Point(12, 12); + this.groupBoxInput.Name = "groupBoxInput"; + this.groupBoxInput.Size = new System.Drawing.Size(1095, 552); + this.groupBoxInput.TabIndex = 1; + this.groupBoxInput.TabStop = false; + this.groupBoxInput.Text = "Input"; + // + // buttonInputBrowse + // + this.buttonInputBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonInputBrowse.Location = new System.Drawing.Point(1060, 41); + this.buttonInputBrowse.Name = "buttonInputBrowse"; + this.buttonInputBrowse.Size = new System.Drawing.Size(26, 23); + this.buttonInputBrowse.TabIndex = 3; + this.buttonInputBrowse.Text = "..."; + this.buttonInputBrowse.UseVisualStyleBackColor = true; + this.buttonInputBrowse.Click += new System.EventHandler(this.buttonInputBrowse_Click); + // + // labelChooseInputFiles + // + this.labelChooseInputFiles.AutoSize = true; + this.labelChooseInputFiles.Location = new System.Drawing.Point(5, 25); + this.labelChooseInputFiles.Name = "labelChooseInputFiles"; + this.labelChooseInputFiles.Size = new System.Drawing.Size(202, 13); + this.labelChooseInputFiles.TabIndex = 0; + this.labelChooseInputFiles.Text = "Choose input files (browse or drag-n-drop)"; + // + // listViewInputFiles + // + this.listViewInputFiles.AllowDrop = true; + this.listViewInputFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewInputFiles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderFName, + this.columnHeaderSize, + this.columnHeaderStartTime, + this.columnHeaderEndTime, + this.columnHeaderDuration}); + this.listViewInputFiles.ContextMenuStrip = this.contextMenuStrip1; + this.listViewInputFiles.FullRowSelect = true; + this.listViewInputFiles.HideSelection = false; + this.listViewInputFiles.Location = new System.Drawing.Point(8, 41); + this.listViewInputFiles.Name = "listViewInputFiles"; + this.listViewInputFiles.Size = new System.Drawing.Size(1049, 497); + this.listViewInputFiles.TabIndex = 2; + this.listViewInputFiles.UseCompatibleStateImageBehavior = false; + this.listViewInputFiles.View = System.Windows.Forms.View.Details; + this.listViewInputFiles.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewInputFiles_DragDrop); + this.listViewInputFiles.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewInputFiles_DragEnter); + // + // columnHeaderFName + // + this.columnHeaderFName.Text = "File name"; + this.columnHeaderFName.Width = 600; + // + // columnHeaderSize + // + this.columnHeaderSize.Text = "Size"; + this.columnHeaderSize.Width = 75; + // + // columnHeaderStartTime + // + this.columnHeaderStartTime.Text = "Start time"; + this.columnHeaderStartTime.Width = 120; + // + // columnHeaderEndTime + // + this.columnHeaderEndTime.Text = "End time"; + this.columnHeaderEndTime.Width = 120; + // + // columnHeaderDuration + // + this.columnHeaderDuration.Text = "Duration"; + this.columnHeaderDuration.Width = 100; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.removeToolStripMenuItem, + this.removeAllToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(133, 48); + this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); + // + // removeToolStripMenuItem + // + this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; + this.removeToolStripMenuItem.Size = new System.Drawing.Size(132, 22); + this.removeToolStripMenuItem.Text = "Remove"; + this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click); + // + // removeAllToolStripMenuItem + // + this.removeAllToolStripMenuItem.Name = "removeAllToolStripMenuItem"; + this.removeAllToolStripMenuItem.Size = new System.Drawing.Size(132, 22); + this.removeAllToolStripMenuItem.Text = "Remove all"; + this.removeAllToolStripMenuItem.Click += new System.EventHandler(this.removeAllToolStripMenuItem_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(951, 570); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 7; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(1032, 570); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 8; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // ImportImages + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1119, 603); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.groupBoxInput); + this.KeyPreview = true; + this.Name = "ImportImages"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "ImportImages"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ImportImages_KeyDown); + this.groupBoxInput.ResumeLayout(false); + this.groupBoxInput.PerformLayout(); + this.contextMenuStrip1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxInput; + private System.Windows.Forms.Button buttonInputBrowse; + private System.Windows.Forms.Label labelChooseInputFiles; + private System.Windows.Forms.ListView listViewInputFiles; + private System.Windows.Forms.ColumnHeader columnHeaderFName; + private System.Windows.Forms.ColumnHeader columnHeaderSize; + private System.Windows.Forms.ColumnHeader columnHeaderStartTime; + private System.Windows.Forms.ColumnHeader columnHeaderEndTime; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.ColumnHeader columnHeaderDuration; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeAllToolStripMenuItem; + } } \ No newline at end of file diff --git a/src/Forms/ImportImages.cs b/src/ui/Forms/ImportImages.cs similarity index 97% rename from src/Forms/ImportImages.cs rename to src/ui/Forms/ImportImages.cs index 2cb3ce898..fc170fc70 100644 --- a/src/Forms/ImportImages.cs +++ b/src/ui/Forms/ImportImages.cs @@ -1,215 +1,215 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.IO; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; -using Nikse.SubtitleEdit.Core.Enums; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ImportImages : PositionAndSizeForm - { - // 0_00_01_042__0_00_03_919_01.jpeg - private static readonly Regex TimeCodeFormat1 = new Regex(@"^\d+_\d+_\d+_\d+__\d+_\d+_\d+_\d+_\d+$", RegexOptions.Compiled); - private static readonly Regex TimeCodeFormat2 = new Regex(@"^\d+_\d+_\d+_\d+__\d+_\d+_\d+_\d+$", RegexOptions.Compiled); - - public Subtitle Subtitle { get; private set; } - private readonly HashSet _filesAlreadyInList; - public ImportImages() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Subtitle = new Subtitle(); - Text = Configuration.Settings.Language.ImportImages.Title; - groupBoxInput.Text = Configuration.Settings.Language.ImportImages.Input; - labelChooseInputFiles.Text = Configuration.Settings.Language.ImportImages.InputDescription; - removeToolStripMenuItem.Text = Configuration.Settings.Language.ImportImages.Remove; - removeAllToolStripMenuItem.Text = Configuration.Settings.Language.ImportImages.RemoveAll; - columnHeaderFName.Text = Configuration.Settings.Language.JoinSubtitles.FileName; - columnHeaderSize.Text = Configuration.Settings.Language.General.Size; - columnHeaderStartTime.Text = Configuration.Settings.Language.General.StartTime; - columnHeaderEndTime.Text = Configuration.Settings.Language.General.EndTime; - columnHeaderDuration.Text = Configuration.Settings.Language.General.Duration; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - _filesAlreadyInList = new HashSet(); - } - - private void buttonInputBrowse_Click(object sender, EventArgs e) - { - buttonInputBrowse.Enabled = false; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = Configuration.Settings.Language.ImportImages.ImageFiles + "|*.png;*.jpg;*.jpeg;*.bmp;*.gif;*.tif;*.tiff"; - openFileDialog1.Multiselect = true; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - foreach (string fileName in openFileDialog1.FileNames) - { - if (!_filesAlreadyInList.Contains(fileName)) - { - AddInputFile(fileName); - } - } - } - buttonInputBrowse.Enabled = true; - } - - private void AddInputFile(string fileName) - { - try - { - var fi = new FileInfo(fileName); - var item = new ListViewItem(fileName); - item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); - var ext = fi.Extension.ToLowerInvariant(); - if (ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".bmp" || ext == ".gif" || ext == ".tif" || ext == ".tiff") - { - _filesAlreadyInList.Add(fileName); - SetTimeCodes(fileName, item); - listViewInputFiles.Items.Add(item); - } - } - catch - { - // ignored - } - } - - private static void SetTimeCodes(string fileName, ListViewItem item) - { - string name = Path.GetFileNameWithoutExtension(fileName); - var p = new Paragraph(); - SetEndTimeAndStartTime(name, p); - item.SubItems.Add(p.StartTime.ToString()); - item.SubItems.Add(p.EndTime.ToString()); - item.SubItems.Add(p.Duration.ToShortString()); - } - - public static void SetEndTimeAndStartTime(string name, Paragraph p) - { - if (name.Contains("-to-")) - { - var arr = name.Replace("-to-", "_").Split('_'); - if (arr.Length == 3 && int.TryParse(arr[1], out var startTime) && int.TryParse(arr[2], out var endTime)) - { - p.StartTime.TotalMilliseconds = startTime; - p.EndTime.TotalMilliseconds = endTime; - } - } - else if (TimeCodeFormat1.IsMatch(name) || TimeCodeFormat2.IsMatch(name)) - { - var arr = name.Replace("__", "_").Split('_'); - if (arr.Length >= 8) - { - try - { - p.StartTime = new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3])); - p.EndTime = new TimeCode(int.Parse(arr[4]), int.Parse(arr[5]), int.Parse(arr[6]), int.Parse(arr[7])); - } - catch (Exception) - { - // ignored - } - } - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewInputFiles.Items) - { - var p = new Paragraph { Text = item.Text }; - string name = Path.GetFileNameWithoutExtension(p.Text); - SetEndTimeAndStartTime(name, p); - Subtitle.Paragraphs.Add(p); - } - Subtitle.Sort(SubtitleSortCriteria.StartTime); - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void listViewInputFiles_DragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) - { - e.Effect = DragDropEffects.All; - } - } - - private void listViewInputFiles_DragDrop(object sender, DragEventArgs e) - { - var fileNames = (string[])e.Data.GetData(DataFormats.FileDrop); - foreach (string fileName in fileNames) - { - AddInputFile(fileName); - } - } - - private void ImportImages_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyData == (Keys.Control | Keys.O)) - { - buttonInputBrowse_Click(null, EventArgs.Empty); - } - } - - private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e) - { - if (listViewInputFiles.Items.Count == 0) - { - e.Cancel = true; - } - else - { - removeToolStripMenuItem.Visible = listViewInputFiles.SelectedItems.Count > 0; - } - } - - private void RemoveSelection(bool removeAll = false) - { - if (listViewInputFiles.Items.Count == 0) - { - return; - } - - if (removeAll) - { - foreach (ListViewItem item in listViewInputFiles.Items) - { - item.Remove(); - _filesAlreadyInList.Remove(item.Text); - } - } - else if (listViewInputFiles.SelectedItems.Count > 0) - { - foreach (ListViewItem item in listViewInputFiles.SelectedItems) - { - item.Remove(); - _filesAlreadyInList.Remove(item.Text); - } - } - } - - private void removeToolStripMenuItem_Click(object sender, EventArgs e) - { - RemoveSelection(); - } - - private void removeAllToolStripMenuItem_Click(object sender, EventArgs e) - { - RemoveSelection(true); - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Core.Enums; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ImportImages : PositionAndSizeForm + { + // 0_00_01_042__0_00_03_919_01.jpeg + private static readonly Regex TimeCodeFormat1 = new Regex(@"^\d+_\d+_\d+_\d+__\d+_\d+_\d+_\d+_\d+$", RegexOptions.Compiled); + private static readonly Regex TimeCodeFormat2 = new Regex(@"^\d+_\d+_\d+_\d+__\d+_\d+_\d+_\d+$", RegexOptions.Compiled); + + public Subtitle Subtitle { get; private set; } + private readonly HashSet _filesAlreadyInList; + public ImportImages() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Subtitle = new Subtitle(); + Text = Configuration.Settings.Language.ImportImages.Title; + groupBoxInput.Text = Configuration.Settings.Language.ImportImages.Input; + labelChooseInputFiles.Text = Configuration.Settings.Language.ImportImages.InputDescription; + removeToolStripMenuItem.Text = Configuration.Settings.Language.ImportImages.Remove; + removeAllToolStripMenuItem.Text = Configuration.Settings.Language.ImportImages.RemoveAll; + columnHeaderFName.Text = Configuration.Settings.Language.JoinSubtitles.FileName; + columnHeaderSize.Text = Configuration.Settings.Language.General.Size; + columnHeaderStartTime.Text = Configuration.Settings.Language.General.StartTime; + columnHeaderEndTime.Text = Configuration.Settings.Language.General.EndTime; + columnHeaderDuration.Text = Configuration.Settings.Language.General.Duration; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + _filesAlreadyInList = new HashSet(); + } + + private void buttonInputBrowse_Click(object sender, EventArgs e) + { + buttonInputBrowse.Enabled = false; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = Configuration.Settings.Language.ImportImages.ImageFiles + "|*.png;*.jpg;*.jpeg;*.bmp;*.gif;*.tif;*.tiff"; + openFileDialog1.Multiselect = true; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + foreach (string fileName in openFileDialog1.FileNames) + { + if (!_filesAlreadyInList.Contains(fileName)) + { + AddInputFile(fileName); + } + } + } + buttonInputBrowse.Enabled = true; + } + + private void AddInputFile(string fileName) + { + try + { + var fi = new FileInfo(fileName); + var item = new ListViewItem(fileName); + item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); + var ext = fi.Extension.ToLowerInvariant(); + if (ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".bmp" || ext == ".gif" || ext == ".tif" || ext == ".tiff") + { + _filesAlreadyInList.Add(fileName); + SetTimeCodes(fileName, item); + listViewInputFiles.Items.Add(item); + } + } + catch + { + // ignored + } + } + + private static void SetTimeCodes(string fileName, ListViewItem item) + { + string name = Path.GetFileNameWithoutExtension(fileName); + var p = new Paragraph(); + SetEndTimeAndStartTime(name, p); + item.SubItems.Add(p.StartTime.ToString()); + item.SubItems.Add(p.EndTime.ToString()); + item.SubItems.Add(p.Duration.ToShortString()); + } + + public static void SetEndTimeAndStartTime(string name, Paragraph p) + { + if (name.Contains("-to-")) + { + var arr = name.Replace("-to-", "_").Split('_'); + if (arr.Length == 3 && int.TryParse(arr[1], out var startTime) && int.TryParse(arr[2], out var endTime)) + { + p.StartTime.TotalMilliseconds = startTime; + p.EndTime.TotalMilliseconds = endTime; + } + } + else if (TimeCodeFormat1.IsMatch(name) || TimeCodeFormat2.IsMatch(name)) + { + var arr = name.Replace("__", "_").Split('_'); + if (arr.Length >= 8) + { + try + { + p.StartTime = new TimeCode(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]), int.Parse(arr[3])); + p.EndTime = new TimeCode(int.Parse(arr[4]), int.Parse(arr[5]), int.Parse(arr[6]), int.Parse(arr[7])); + } + catch (Exception) + { + // ignored + } + } + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewInputFiles.Items) + { + var p = new Paragraph { Text = item.Text }; + string name = Path.GetFileNameWithoutExtension(p.Text); + SetEndTimeAndStartTime(name, p); + Subtitle.Paragraphs.Add(p); + } + Subtitle.Sort(SubtitleSortCriteria.StartTime); + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void listViewInputFiles_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.All; + } + } + + private void listViewInputFiles_DragDrop(object sender, DragEventArgs e) + { + var fileNames = (string[])e.Data.GetData(DataFormats.FileDrop); + foreach (string fileName in fileNames) + { + AddInputFile(fileName); + } + } + + private void ImportImages_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyData == (Keys.Control | Keys.O)) + { + buttonInputBrowse_Click(null, EventArgs.Empty); + } + } + + private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e) + { + if (listViewInputFiles.Items.Count == 0) + { + e.Cancel = true; + } + else + { + removeToolStripMenuItem.Visible = listViewInputFiles.SelectedItems.Count > 0; + } + } + + private void RemoveSelection(bool removeAll = false) + { + if (listViewInputFiles.Items.Count == 0) + { + return; + } + + if (removeAll) + { + foreach (ListViewItem item in listViewInputFiles.Items) + { + item.Remove(); + _filesAlreadyInList.Remove(item.Text); + } + } + else if (listViewInputFiles.SelectedItems.Count > 0) + { + foreach (ListViewItem item in listViewInputFiles.SelectedItems) + { + item.Remove(); + _filesAlreadyInList.Remove(item.Text); + } + } + } + + private void removeToolStripMenuItem_Click(object sender, EventArgs e) + { + RemoveSelection(); + } + + private void removeAllToolStripMenuItem_Click(object sender, EventArgs e) + { + RemoveSelection(true); + } + } +} diff --git a/src/Forms/ImportImages.resx b/src/ui/Forms/ImportImages.resx similarity index 97% rename from src/Forms/ImportImages.resx rename to src/ui/Forms/ImportImages.resx index 2bd4597e5..16ec139ae 100644 --- a/src/Forms/ImportImages.resx +++ b/src/ui/Forms/ImportImages.resx @@ -1,126 +1,126 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 157, 17 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 157, 17 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/ImportSceneChanges.Designer.cs b/src/ui/Forms/ImportSceneChanges.Designer.cs similarity index 98% rename from src/Forms/ImportSceneChanges.Designer.cs rename to src/ui/Forms/ImportSceneChanges.Designer.cs index a867ae151..d6e8bbcb1 100644 --- a/src/Forms/ImportSceneChanges.Designer.cs +++ b/src/ui/Forms/ImportSceneChanges.Designer.cs @@ -1,365 +1,365 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class ImportSceneChanges - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxImportText = new System.Windows.Forms.GroupBox(); - this.textBoxIImport = new System.Windows.Forms.TextBox(); - this.groupBoxTimeCodes = new System.Windows.Forms.GroupBox(); - this.radioButtonMilliseconds = new System.Windows.Forms.RadioButton(); - this.radioButtonSeconds = new System.Windows.Forms.RadioButton(); - this.radioButtonFrames = new System.Windows.Forms.RadioButton(); - this.radioButtonHHMMSSMS = new System.Windows.Forms.RadioButton(); - this.buttonOpenText = new System.Windows.Forms.Button(); - this.textBoxLog = new System.Windows.Forms.TextBox(); - this.groupBoxGenerateSceneChanges = new System.Windows.Forms.GroupBox(); - this.labelThresholdDescription = new System.Windows.Forms.Label(); - this.numericUpDownThreshold = new System.Windows.Forms.NumericUpDown(); - this.labelFfmpegThreshold = new System.Windows.Forms.Label(); - this.buttonDownloadFfmpeg = new System.Windows.Forms.Button(); - this.buttonImportWithFfmpeg = new System.Windows.Forms.Button(); - this.textBoxGenerate = new System.Windows.Forms.TextBox(); - this.progressBar1 = new System.Windows.Forms.ProgressBar(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.groupBoxImportText.SuspendLayout(); - this.groupBoxTimeCodes.SuspendLayout(); - this.groupBoxGenerateSceneChanges.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownThreshold)).BeginInit(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(639, 433); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(87, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(546, 433); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(87, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // groupBoxImportText - // - this.groupBoxImportText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxImportText.Controls.Add(this.textBoxIImport); - this.groupBoxImportText.Controls.Add(this.groupBoxTimeCodes); - this.groupBoxImportText.Controls.Add(this.buttonOpenText); - this.groupBoxImportText.Controls.Add(this.textBoxLog); - this.groupBoxImportText.Location = new System.Drawing.Point(367, 12); - this.groupBoxImportText.Name = "groupBoxImportText"; - this.groupBoxImportText.Size = new System.Drawing.Size(359, 412); - this.groupBoxImportText.TabIndex = 1; - this.groupBoxImportText.TabStop = false; - this.groupBoxImportText.Text = "Import scene changes"; - // - // textBoxIImport - // - this.textBoxIImport.AllowDrop = true; - this.textBoxIImport.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxIImport.Location = new System.Drawing.Point(6, 48); - this.textBoxIImport.MaxLength = 0; - this.textBoxIImport.Multiline = true; - this.textBoxIImport.Name = "textBoxIImport"; - this.textBoxIImport.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxIImport.Size = new System.Drawing.Size(338, 232); - this.textBoxIImport.TabIndex = 1; - // - // groupBoxTimeCodes - // - this.groupBoxTimeCodes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxTimeCodes.Controls.Add(this.radioButtonMilliseconds); - this.groupBoxTimeCodes.Controls.Add(this.radioButtonSeconds); - this.groupBoxTimeCodes.Controls.Add(this.radioButtonFrames); - this.groupBoxTimeCodes.Controls.Add(this.radioButtonHHMMSSMS); - this.groupBoxTimeCodes.Location = new System.Drawing.Point(6, 286); - this.groupBoxTimeCodes.Name = "groupBoxTimeCodes"; - this.groupBoxTimeCodes.Size = new System.Drawing.Size(338, 120); - this.groupBoxTimeCodes.TabIndex = 2; - this.groupBoxTimeCodes.TabStop = false; - this.groupBoxTimeCodes.Text = "Time codes"; - // - // radioButtonMilliseconds - // - this.radioButtonMilliseconds.AutoSize = true; - this.radioButtonMilliseconds.Location = new System.Drawing.Point(18, 67); - this.radioButtonMilliseconds.Name = "radioButtonMilliseconds"; - this.radioButtonMilliseconds.Size = new System.Drawing.Size(82, 17); - this.radioButtonMilliseconds.TabIndex = 2; - this.radioButtonMilliseconds.Text = "Milliseconds"; - this.radioButtonMilliseconds.UseVisualStyleBackColor = true; - // - // radioButtonSeconds - // - this.radioButtonSeconds.AutoSize = true; - this.radioButtonSeconds.Location = new System.Drawing.Point(18, 44); - this.radioButtonSeconds.Name = "radioButtonSeconds"; - this.radioButtonSeconds.Size = new System.Drawing.Size(67, 17); - this.radioButtonSeconds.TabIndex = 1; - this.radioButtonSeconds.Text = "Seconds"; - this.radioButtonSeconds.UseVisualStyleBackColor = true; - // - // radioButtonFrames - // - this.radioButtonFrames.AutoSize = true; - this.radioButtonFrames.Checked = true; - this.radioButtonFrames.Location = new System.Drawing.Point(18, 21); - this.radioButtonFrames.Name = "radioButtonFrames"; - this.radioButtonFrames.Size = new System.Drawing.Size(59, 17); - this.radioButtonFrames.TabIndex = 0; - this.radioButtonFrames.TabStop = true; - this.radioButtonFrames.Text = "Frames"; - this.radioButtonFrames.UseVisualStyleBackColor = true; - // - // radioButtonHHMMSSMS - // - this.radioButtonHHMMSSMS.AutoSize = true; - this.radioButtonHHMMSSMS.Location = new System.Drawing.Point(19, 90); - this.radioButtonHHMMSSMS.Name = "radioButtonHHMMSSMS"; - this.radioButtonHHMMSSMS.Size = new System.Drawing.Size(167, 17); - this.radioButtonHHMMSSMS.TabIndex = 3; - this.radioButtonHHMMSSMS.Text = "HH:MM:SS.ms (00:00:01.500)"; - this.radioButtonHHMMSSMS.UseVisualStyleBackColor = true; - // - // buttonOpenText - // - this.buttonOpenText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOpenText.Location = new System.Drawing.Point(189, 21); - this.buttonOpenText.Name = "buttonOpenText"; - this.buttonOpenText.Size = new System.Drawing.Size(153, 23); - this.buttonOpenText.TabIndex = 0; - this.buttonOpenText.Text = "Open file..."; - this.buttonOpenText.UseVisualStyleBackColor = true; - this.buttonOpenText.Click += new System.EventHandler(this.buttonOpenText_Click); - // - // textBoxLog - // - this.textBoxLog.AllowDrop = true; - this.textBoxLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxLog.Location = new System.Drawing.Point(7, 19); - this.textBoxLog.MaxLength = 0; - this.textBoxLog.Multiline = true; - this.textBoxLog.Name = "textBoxLog"; - this.textBoxLog.ReadOnly = true; - this.textBoxLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxLog.Size = new System.Drawing.Size(337, 387); - this.textBoxLog.TabIndex = 6; - // - // groupBoxGenerateSceneChanges - // - this.groupBoxGenerateSceneChanges.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxGenerateSceneChanges.Controls.Add(this.labelThresholdDescription); - this.groupBoxGenerateSceneChanges.Controls.Add(this.numericUpDownThreshold); - this.groupBoxGenerateSceneChanges.Controls.Add(this.labelFfmpegThreshold); - this.groupBoxGenerateSceneChanges.Controls.Add(this.buttonDownloadFfmpeg); - this.groupBoxGenerateSceneChanges.Controls.Add(this.buttonImportWithFfmpeg); - this.groupBoxGenerateSceneChanges.Controls.Add(this.textBoxGenerate); - this.groupBoxGenerateSceneChanges.Location = new System.Drawing.Point(12, 12); - this.groupBoxGenerateSceneChanges.Name = "groupBoxGenerateSceneChanges"; - this.groupBoxGenerateSceneChanges.Size = new System.Drawing.Size(349, 413); - this.groupBoxGenerateSceneChanges.TabIndex = 0; - this.groupBoxGenerateSceneChanges.TabStop = false; - this.groupBoxGenerateSceneChanges.Text = "Generate scene changes"; - // - // labelThressholdDescription - // - this.labelThresholdDescription.AutoSize = true; - this.labelThresholdDescription.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.labelThresholdDescription.Location = new System.Drawing.Point(115, 384); - this.labelThresholdDescription.Name = "labelThresholdDescription"; - this.labelThresholdDescription.Size = new System.Drawing.Size(195, 13); - this.labelThresholdDescription.TabIndex = 5; - this.labelThresholdDescription.Text = "Lower value gives more scene changes"; - // - // numericUpDownThreshold - // - this.numericUpDownThreshold.DecimalPlaces = 1; - this.numericUpDownThreshold.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownThreshold.Location = new System.Drawing.Point(66, 382); - this.numericUpDownThreshold.Maximum = new decimal(new int[] { - 9, - 0, - 0, - 65536}); - this.numericUpDownThreshold.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownThreshold.Name = "numericUpDownThreshold"; - this.numericUpDownThreshold.Size = new System.Drawing.Size(43, 20); - this.numericUpDownThreshold.TabIndex = 4; - this.numericUpDownThreshold.Value = new decimal(new int[] { - 4, - 0, - 0, - 65536}); - // - // labelFfmpegThreshold - // - this.labelFfmpegThreshold.AutoSize = true; - this.labelFfmpegThreshold.Location = new System.Drawing.Point(6, 384); - this.labelFfmpegThreshold.Name = "labelFfmpegThreshold"; - this.labelFfmpegThreshold.Size = new System.Drawing.Size(54, 13); - this.labelFfmpegThreshold.TabIndex = 3; - this.labelFfmpegThreshold.Text = "Sensitivity"; - // - // buttonDownloadFfmpeg - // - this.buttonDownloadFfmpeg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDownloadFfmpeg.Location = new System.Drawing.Point(159, 19); - this.buttonDownloadFfmpeg.Name = "buttonDownloadFfmpeg"; - this.buttonDownloadFfmpeg.Size = new System.Drawing.Size(184, 23); - this.buttonDownloadFfmpeg.TabIndex = 0; - this.buttonDownloadFfmpeg.Text = "Download ffmpeg"; - this.buttonDownloadFfmpeg.UseVisualStyleBackColor = true; - this.buttonDownloadFfmpeg.Click += new System.EventHandler(this.buttonDownloadFfmpeg_Click); - // - // buttonImportWithFfmpeg - // - this.buttonImportWithFfmpeg.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.buttonImportWithFfmpeg.Location = new System.Drawing.Point(6, 353); - this.buttonImportWithFfmpeg.Name = "buttonImportWithFfmpeg"; - this.buttonImportWithFfmpeg.Size = new System.Drawing.Size(337, 23); - this.buttonImportWithFfmpeg.TabIndex = 2; - this.buttonImportWithFfmpeg.Text = "Generate scene changes with FFmpeg"; - this.buttonImportWithFfmpeg.UseVisualStyleBackColor = true; - this.buttonImportWithFfmpeg.Click += new System.EventHandler(this.buttonImportWithFfmpeg_Click); - // - // textBoxGenerate - // - this.textBoxGenerate.AllowDrop = true; - this.textBoxGenerate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxGenerate.Location = new System.Drawing.Point(6, 48); - this.textBoxGenerate.MaxLength = 0; - this.textBoxGenerate.Multiline = true; - this.textBoxGenerate.Name = "textBoxGenerate"; - this.textBoxGenerate.ReadOnly = true; - this.textBoxGenerate.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxGenerate.Size = new System.Drawing.Size(337, 299); - this.textBoxGenerate.TabIndex = 1; - // - // progressBar1 - // - this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.progressBar1.Location = new System.Drawing.Point(12, 433); - this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(528, 23); - this.progressBar1.TabIndex = 2; - this.progressBar1.Visible = false; - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // ImportSceneChanges - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(738, 468); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.progressBar1); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.groupBoxImportText); - this.Controls.Add(this.groupBoxGenerateSceneChanges); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ImportSceneChanges"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "ImportSceneChanges"; - this.Shown += new System.EventHandler(this.ImportSceneChanges_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ImportSceneChanges_KeyDown); - this.groupBoxImportText.ResumeLayout(false); - this.groupBoxImportText.PerformLayout(); - this.groupBoxTimeCodes.ResumeLayout(false); - this.groupBoxTimeCodes.PerformLayout(); - this.groupBoxGenerateSceneChanges.ResumeLayout(false); - this.groupBoxGenerateSceneChanges.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownThreshold)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.GroupBox groupBoxImportText; - private System.Windows.Forms.GroupBox groupBoxTimeCodes; - private System.Windows.Forms.RadioButton radioButtonMilliseconds; - private System.Windows.Forms.RadioButton radioButtonSeconds; - private System.Windows.Forms.RadioButton radioButtonFrames; - private System.Windows.Forms.RadioButton radioButtonHHMMSSMS; - private System.Windows.Forms.GroupBox groupBoxGenerateSceneChanges; - private System.Windows.Forms.TextBox textBoxGenerate; - private System.Windows.Forms.Button buttonOpenText; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Button buttonImportWithFfmpeg; - private System.Windows.Forms.ProgressBar progressBar1; - private System.Windows.Forms.Button buttonDownloadFfmpeg; - private System.Windows.Forms.TextBox textBoxIImport; - private System.Windows.Forms.Label labelThresholdDescription; - private System.Windows.Forms.NumericUpDown numericUpDownThreshold; - private System.Windows.Forms.Label labelFfmpegThreshold; - private System.Windows.Forms.TextBox textBoxLog; - } -} +namespace Nikse.SubtitleEdit.Forms +{ + partial class ImportSceneChanges + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxImportText = new System.Windows.Forms.GroupBox(); + this.textBoxIImport = new System.Windows.Forms.TextBox(); + this.groupBoxTimeCodes = new System.Windows.Forms.GroupBox(); + this.radioButtonMilliseconds = new System.Windows.Forms.RadioButton(); + this.radioButtonSeconds = new System.Windows.Forms.RadioButton(); + this.radioButtonFrames = new System.Windows.Forms.RadioButton(); + this.radioButtonHHMMSSMS = new System.Windows.Forms.RadioButton(); + this.buttonOpenText = new System.Windows.Forms.Button(); + this.textBoxLog = new System.Windows.Forms.TextBox(); + this.groupBoxGenerateSceneChanges = new System.Windows.Forms.GroupBox(); + this.labelThresholdDescription = new System.Windows.Forms.Label(); + this.numericUpDownThreshold = new System.Windows.Forms.NumericUpDown(); + this.labelFfmpegThreshold = new System.Windows.Forms.Label(); + this.buttonDownloadFfmpeg = new System.Windows.Forms.Button(); + this.buttonImportWithFfmpeg = new System.Windows.Forms.Button(); + this.textBoxGenerate = new System.Windows.Forms.TextBox(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.groupBoxImportText.SuspendLayout(); + this.groupBoxTimeCodes.SuspendLayout(); + this.groupBoxGenerateSceneChanges.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownThreshold)).BeginInit(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(639, 433); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(87, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(546, 433); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(87, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // groupBoxImportText + // + this.groupBoxImportText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImportText.Controls.Add(this.textBoxIImport); + this.groupBoxImportText.Controls.Add(this.groupBoxTimeCodes); + this.groupBoxImportText.Controls.Add(this.buttonOpenText); + this.groupBoxImportText.Controls.Add(this.textBoxLog); + this.groupBoxImportText.Location = new System.Drawing.Point(367, 12); + this.groupBoxImportText.Name = "groupBoxImportText"; + this.groupBoxImportText.Size = new System.Drawing.Size(359, 412); + this.groupBoxImportText.TabIndex = 1; + this.groupBoxImportText.TabStop = false; + this.groupBoxImportText.Text = "Import scene changes"; + // + // textBoxIImport + // + this.textBoxIImport.AllowDrop = true; + this.textBoxIImport.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxIImport.Location = new System.Drawing.Point(6, 48); + this.textBoxIImport.MaxLength = 0; + this.textBoxIImport.Multiline = true; + this.textBoxIImport.Name = "textBoxIImport"; + this.textBoxIImport.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxIImport.Size = new System.Drawing.Size(338, 232); + this.textBoxIImport.TabIndex = 1; + // + // groupBoxTimeCodes + // + this.groupBoxTimeCodes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxTimeCodes.Controls.Add(this.radioButtonMilliseconds); + this.groupBoxTimeCodes.Controls.Add(this.radioButtonSeconds); + this.groupBoxTimeCodes.Controls.Add(this.radioButtonFrames); + this.groupBoxTimeCodes.Controls.Add(this.radioButtonHHMMSSMS); + this.groupBoxTimeCodes.Location = new System.Drawing.Point(6, 286); + this.groupBoxTimeCodes.Name = "groupBoxTimeCodes"; + this.groupBoxTimeCodes.Size = new System.Drawing.Size(338, 120); + this.groupBoxTimeCodes.TabIndex = 2; + this.groupBoxTimeCodes.TabStop = false; + this.groupBoxTimeCodes.Text = "Time codes"; + // + // radioButtonMilliseconds + // + this.radioButtonMilliseconds.AutoSize = true; + this.radioButtonMilliseconds.Location = new System.Drawing.Point(18, 67); + this.radioButtonMilliseconds.Name = "radioButtonMilliseconds"; + this.radioButtonMilliseconds.Size = new System.Drawing.Size(82, 17); + this.radioButtonMilliseconds.TabIndex = 2; + this.radioButtonMilliseconds.Text = "Milliseconds"; + this.radioButtonMilliseconds.UseVisualStyleBackColor = true; + // + // radioButtonSeconds + // + this.radioButtonSeconds.AutoSize = true; + this.radioButtonSeconds.Location = new System.Drawing.Point(18, 44); + this.radioButtonSeconds.Name = "radioButtonSeconds"; + this.radioButtonSeconds.Size = new System.Drawing.Size(67, 17); + this.radioButtonSeconds.TabIndex = 1; + this.radioButtonSeconds.Text = "Seconds"; + this.radioButtonSeconds.UseVisualStyleBackColor = true; + // + // radioButtonFrames + // + this.radioButtonFrames.AutoSize = true; + this.radioButtonFrames.Checked = true; + this.radioButtonFrames.Location = new System.Drawing.Point(18, 21); + this.radioButtonFrames.Name = "radioButtonFrames"; + this.radioButtonFrames.Size = new System.Drawing.Size(59, 17); + this.radioButtonFrames.TabIndex = 0; + this.radioButtonFrames.TabStop = true; + this.radioButtonFrames.Text = "Frames"; + this.radioButtonFrames.UseVisualStyleBackColor = true; + // + // radioButtonHHMMSSMS + // + this.radioButtonHHMMSSMS.AutoSize = true; + this.radioButtonHHMMSSMS.Location = new System.Drawing.Point(19, 90); + this.radioButtonHHMMSSMS.Name = "radioButtonHHMMSSMS"; + this.radioButtonHHMMSSMS.Size = new System.Drawing.Size(167, 17); + this.radioButtonHHMMSSMS.TabIndex = 3; + this.radioButtonHHMMSSMS.Text = "HH:MM:SS.ms (00:00:01.500)"; + this.radioButtonHHMMSSMS.UseVisualStyleBackColor = true; + // + // buttonOpenText + // + this.buttonOpenText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOpenText.Location = new System.Drawing.Point(189, 21); + this.buttonOpenText.Name = "buttonOpenText"; + this.buttonOpenText.Size = new System.Drawing.Size(153, 23); + this.buttonOpenText.TabIndex = 0; + this.buttonOpenText.Text = "Open file..."; + this.buttonOpenText.UseVisualStyleBackColor = true; + this.buttonOpenText.Click += new System.EventHandler(this.buttonOpenText_Click); + // + // textBoxLog + // + this.textBoxLog.AllowDrop = true; + this.textBoxLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxLog.Location = new System.Drawing.Point(7, 19); + this.textBoxLog.MaxLength = 0; + this.textBoxLog.Multiline = true; + this.textBoxLog.Name = "textBoxLog"; + this.textBoxLog.ReadOnly = true; + this.textBoxLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxLog.Size = new System.Drawing.Size(337, 387); + this.textBoxLog.TabIndex = 6; + // + // groupBoxGenerateSceneChanges + // + this.groupBoxGenerateSceneChanges.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxGenerateSceneChanges.Controls.Add(this.labelThresholdDescription); + this.groupBoxGenerateSceneChanges.Controls.Add(this.numericUpDownThreshold); + this.groupBoxGenerateSceneChanges.Controls.Add(this.labelFfmpegThreshold); + this.groupBoxGenerateSceneChanges.Controls.Add(this.buttonDownloadFfmpeg); + this.groupBoxGenerateSceneChanges.Controls.Add(this.buttonImportWithFfmpeg); + this.groupBoxGenerateSceneChanges.Controls.Add(this.textBoxGenerate); + this.groupBoxGenerateSceneChanges.Location = new System.Drawing.Point(12, 12); + this.groupBoxGenerateSceneChanges.Name = "groupBoxGenerateSceneChanges"; + this.groupBoxGenerateSceneChanges.Size = new System.Drawing.Size(349, 413); + this.groupBoxGenerateSceneChanges.TabIndex = 0; + this.groupBoxGenerateSceneChanges.TabStop = false; + this.groupBoxGenerateSceneChanges.Text = "Generate scene changes"; + // + // labelThressholdDescription + // + this.labelThresholdDescription.AutoSize = true; + this.labelThresholdDescription.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + this.labelThresholdDescription.Location = new System.Drawing.Point(115, 384); + this.labelThresholdDescription.Name = "labelThresholdDescription"; + this.labelThresholdDescription.Size = new System.Drawing.Size(195, 13); + this.labelThresholdDescription.TabIndex = 5; + this.labelThresholdDescription.Text = "Lower value gives more scene changes"; + // + // numericUpDownThreshold + // + this.numericUpDownThreshold.DecimalPlaces = 1; + this.numericUpDownThreshold.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownThreshold.Location = new System.Drawing.Point(66, 382); + this.numericUpDownThreshold.Maximum = new decimal(new int[] { + 9, + 0, + 0, + 65536}); + this.numericUpDownThreshold.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownThreshold.Name = "numericUpDownThreshold"; + this.numericUpDownThreshold.Size = new System.Drawing.Size(43, 20); + this.numericUpDownThreshold.TabIndex = 4; + this.numericUpDownThreshold.Value = new decimal(new int[] { + 4, + 0, + 0, + 65536}); + // + // labelFfmpegThreshold + // + this.labelFfmpegThreshold.AutoSize = true; + this.labelFfmpegThreshold.Location = new System.Drawing.Point(6, 384); + this.labelFfmpegThreshold.Name = "labelFfmpegThreshold"; + this.labelFfmpegThreshold.Size = new System.Drawing.Size(54, 13); + this.labelFfmpegThreshold.TabIndex = 3; + this.labelFfmpegThreshold.Text = "Sensitivity"; + // + // buttonDownloadFfmpeg + // + this.buttonDownloadFfmpeg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDownloadFfmpeg.Location = new System.Drawing.Point(159, 19); + this.buttonDownloadFfmpeg.Name = "buttonDownloadFfmpeg"; + this.buttonDownloadFfmpeg.Size = new System.Drawing.Size(184, 23); + this.buttonDownloadFfmpeg.TabIndex = 0; + this.buttonDownloadFfmpeg.Text = "Download ffmpeg"; + this.buttonDownloadFfmpeg.UseVisualStyleBackColor = true; + this.buttonDownloadFfmpeg.Click += new System.EventHandler(this.buttonDownloadFfmpeg_Click); + // + // buttonImportWithFfmpeg + // + this.buttonImportWithFfmpeg.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.buttonImportWithFfmpeg.Location = new System.Drawing.Point(6, 353); + this.buttonImportWithFfmpeg.Name = "buttonImportWithFfmpeg"; + this.buttonImportWithFfmpeg.Size = new System.Drawing.Size(337, 23); + this.buttonImportWithFfmpeg.TabIndex = 2; + this.buttonImportWithFfmpeg.Text = "Generate scene changes with FFmpeg"; + this.buttonImportWithFfmpeg.UseVisualStyleBackColor = true; + this.buttonImportWithFfmpeg.Click += new System.EventHandler(this.buttonImportWithFfmpeg_Click); + // + // textBoxGenerate + // + this.textBoxGenerate.AllowDrop = true; + this.textBoxGenerate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxGenerate.Location = new System.Drawing.Point(6, 48); + this.textBoxGenerate.MaxLength = 0; + this.textBoxGenerate.Multiline = true; + this.textBoxGenerate.Name = "textBoxGenerate"; + this.textBoxGenerate.ReadOnly = true; + this.textBoxGenerate.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxGenerate.Size = new System.Drawing.Size(337, 299); + this.textBoxGenerate.TabIndex = 1; + // + // progressBar1 + // + this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.progressBar1.Location = new System.Drawing.Point(12, 433); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(528, 23); + this.progressBar1.TabIndex = 2; + this.progressBar1.Visible = false; + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // ImportSceneChanges + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(738, 468); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.progressBar1); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.groupBoxImportText); + this.Controls.Add(this.groupBoxGenerateSceneChanges); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ImportSceneChanges"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "ImportSceneChanges"; + this.Shown += new System.EventHandler(this.ImportSceneChanges_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ImportSceneChanges_KeyDown); + this.groupBoxImportText.ResumeLayout(false); + this.groupBoxImportText.PerformLayout(); + this.groupBoxTimeCodes.ResumeLayout(false); + this.groupBoxTimeCodes.PerformLayout(); + this.groupBoxGenerateSceneChanges.ResumeLayout(false); + this.groupBoxGenerateSceneChanges.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownThreshold)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.GroupBox groupBoxImportText; + private System.Windows.Forms.GroupBox groupBoxTimeCodes; + private System.Windows.Forms.RadioButton radioButtonMilliseconds; + private System.Windows.Forms.RadioButton radioButtonSeconds; + private System.Windows.Forms.RadioButton radioButtonFrames; + private System.Windows.Forms.RadioButton radioButtonHHMMSSMS; + private System.Windows.Forms.GroupBox groupBoxGenerateSceneChanges; + private System.Windows.Forms.TextBox textBoxGenerate; + private System.Windows.Forms.Button buttonOpenText; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Button buttonImportWithFfmpeg; + private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.Button buttonDownloadFfmpeg; + private System.Windows.Forms.TextBox textBoxIImport; + private System.Windows.Forms.Label labelThresholdDescription; + private System.Windows.Forms.NumericUpDown numericUpDownThreshold; + private System.Windows.Forms.Label labelFfmpegThreshold; + private System.Windows.Forms.TextBox textBoxLog; + } +} diff --git a/src/Forms/ImportSceneChanges.cs b/src/ui/Forms/ImportSceneChanges.cs similarity index 97% rename from src/Forms/ImportSceneChanges.cs rename to src/ui/Forms/ImportSceneChanges.cs index df6af4fd9..aa3dafb3b 100644 --- a/src/Forms/ImportSceneChanges.cs +++ b/src/ui/Forms/ImportSceneChanges.cs @@ -1,395 +1,395 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class ImportSceneChanges : PositionAndSizeForm - { - public List SceneChangesInSeconds = new List(); - private readonly double _frameRate = 25; - private readonly string _videoFileName; - private bool _abort; - private bool _pause; - private readonly StringBuilder _log; - private SceneChangesGenerator _sceneChangesGenerator; - - public ImportSceneChanges(VideoInfo videoInfo, string videoFileName) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - if (videoInfo != null && videoInfo.FramesPerSecond > 1) - { - _frameRate = videoInfo.FramesPerSecond; - } - - _videoFileName = videoFileName; - - Text = Configuration.Settings.Language.ImportSceneChanges.Title; - groupBoxGenerateSceneChanges.Text = Configuration.Settings.Language.ImportSceneChanges.Generate; - buttonOpenText.Text = Configuration.Settings.Language.ImportSceneChanges.OpenTextFile; - groupBoxImportText.Text = Configuration.Settings.Language.ImportSceneChanges.Import; - radioButtonFrames.Text = Configuration.Settings.Language.ImportSceneChanges.Frames; - radioButtonSeconds.Text = Configuration.Settings.Language.ImportSceneChanges.Seconds; - radioButtonMilliseconds.Text = Configuration.Settings.Language.ImportSceneChanges.Milliseconds; - groupBoxTimeCodes.Text = Configuration.Settings.Language.ImportSceneChanges.TimeCodes; - buttonDownloadFfmpeg.Text = Configuration.Settings.Language.Settings.DownloadFFmpeg; - buttonImportWithFfmpeg.Text = Configuration.Settings.Language.ImportSceneChanges.GetSceneChangesWithFfmpeg; - labelFfmpegThreshold.Text = Configuration.Settings.Language.ImportSceneChanges.Sensitivity; - labelThresholdDescription.Text = Configuration.Settings.Language.ImportSceneChanges.SensitivityDescription; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - buttonImportWithFfmpeg.Enabled = !string.IsNullOrWhiteSpace(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation); - numericUpDownThreshold.Enabled = !string.IsNullOrWhiteSpace(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation); - var isFfmpegAvailable = !string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation); - buttonDownloadFfmpeg.Visible = !isFfmpegAvailable; - if (decimal.TryParse(Configuration.Settings.General.FFmpegSceneThreshold, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var threshold) && - threshold >= numericUpDownThreshold.Minimum && - threshold <= numericUpDownThreshold.Maximum) - { - numericUpDownThreshold.Value = threshold; - } - _log = new StringBuilder(); - textBoxLog.Visible = false; - if (!Configuration.IsRunningOnWindows) - { - buttonDownloadFfmpeg.Visible = false; - buttonImportWithFfmpeg.Enabled = true; - numericUpDownThreshold.Enabled = true; - } - } - - public sealed override string Text - { - get => base.Text; - set => base.Text = value; - } - - private void buttonOpenText_Click(object sender, EventArgs e) - { - openFileDialog1.Title = buttonOpenText.Text; - openFileDialog1.Filter = Configuration.Settings.Language.ImportText.TextFiles + "|*.txt;*.scenechanges;*.xml;*.json" + - "|Matroska xml chapter file|*.xml" + - "|EZTitles shotchanges XML file|*.xml" + - "|JSON scene changes file|*.json" + - "|" + Configuration.Settings.Language.General.AllFiles + "|*.*"; - openFileDialog1.FileName = string.Empty; - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - LoadTextFile(openFileDialog1.FileName); - } - } - - private void LoadTextFile(string fileName) - { - try - { - var res = LoadFromMatroskaChapterFile(fileName); - if (!string.IsNullOrEmpty(res)) - { - textBoxIImport.Text = res; - radioButtonHHMMSSMS.Checked = true; - return; - } - - res = LoadFromEZTitlesShotchangesFile(fileName); - if (!string.IsNullOrEmpty(res)) - { - textBoxIImport.Text = res; - radioButtonFrames.Checked = true; - return; - } - - res = LoadFromJsonShotchangesFile(fileName); - if (!string.IsNullOrEmpty(res)) - { - textBoxIImport.Text = res; - radioButtonHHMMSSMS.Checked = true; - return; - } - - var encoding = LanguageAutoDetect.GetEncodingFromFile(fileName); - string s = File.ReadAllText(fileName, encoding).Trim(); - if (s.Contains('.')) - { - radioButtonSeconds.Checked = true; - } - - if (s.Contains('.') && s.Contains(':')) - { - radioButtonHHMMSSMS.Checked = true; - } - - if (!s.Contains(Environment.NewLine) && s.Contains(';')) - { - var sb = new StringBuilder(); - foreach (string line in s.Split(';')) - { - if (!string.IsNullOrWhiteSpace(line)) - { - sb.AppendLine(line.Trim()); - } - } - textBoxIImport.Text = sb.ToString(); - } - else - { - textBoxIImport.Text = s; - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - private string LoadFromMatroskaChapterFile(string fileName) - { - try - { - var x = new XmlDocument(); - x.Load(fileName); - var xmlNodeList = x.SelectNodes("//ChapterAtom"); - var sb = new StringBuilder(); - if (xmlNodeList != null) - { - foreach (XmlNode chapter in xmlNodeList) - { - var start = chapter.SelectSingleNode("ChapterTimeStart"); - string[] timeParts = start?.InnerText.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries); - if (timeParts?.Length == 4) - { - if (timeParts[3].Length > 3) - { - timeParts[3] = timeParts[3].Substring(0, 3); - } - - var ts = new TimeSpan(0, Convert.ToInt32(timeParts[0]), Convert.ToInt32(timeParts[1]), Convert.ToInt32(timeParts[2]), Convert.ToInt32(timeParts[3])); - sb.AppendLine(new TimeCode(ts).ToShortStringHHMMSSFF()); - } - } - } - return sb.ToString(); - } - catch - { - return null; - } - } - - private string LoadFromEZTitlesShotchangesFile(string fileName) - { - try - { - var x = new XmlDocument(); - x.Load(fileName); - var xmlNodeList = x.SelectNodes("/shotchanges/shotchanges_list/shotchange"); - var sb = new StringBuilder(); - if (xmlNodeList != null) - { - foreach (XmlNode shotChange in xmlNodeList) - { - sb.AppendLine(shotChange.Attributes["frame"]?.InnerText); - } - } - return sb.ToString(); - } - catch - { - return null; - } - } - - private string LoadFromJsonShotchangesFile(string fileName) - { - try - { - var text = FileUtil.ReadAllTextShared(fileName, Encoding.UTF8); - var list = new List(); - foreach (string line in text.Split(',')) - { - string s = line.Trim() + "}"; - string start = Json.ReadTag(s, "frame_time"); - if (start != null) - { - if (double.TryParse(start, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var startSeconds)) - { - list.Add(startSeconds * 1000.0); - } - } - } - - var sb = new StringBuilder(); - foreach (double ms in list.OrderBy(p => p)) - { - sb.AppendLine(new TimeCode(ms).ToShortStringHHMMSSFF()); - } - return sb.ToString(); - } - catch - { - return null; - } - } - - - private static readonly char[] SplitChars = { ':', '.', ',' }; - - private void buttonOK_Click(object sender, EventArgs e) - { - var lines = string.IsNullOrEmpty(textBoxGenerate.Text) ? textBoxIImport.Lines : textBoxGenerate.Lines; - if (radioButtonHHMMSSMS.Checked) - { - SceneChangesInSeconds = SceneChangesGenerator.GetSeconds(lines); - } - else - { - SceneChangesInSeconds = new List(); - foreach (var line in lines) - { - if (double.TryParse(line, out var d)) - { - if (radioButtonFrames.Checked) - { - SceneChangesInSeconds.Add(d / _frameRate); - } - else if (radioButtonSeconds.Checked) - { - SceneChangesInSeconds.Add(d); - } - else if (radioButtonMilliseconds.Checked) - { - SceneChangesInSeconds.Add(d / TimeCode.BaseUnit); - } - } - } - } - - Configuration.Settings.General.FFmpegSceneThreshold = numericUpDownThreshold.Value.ToString(CultureInfo.InvariantCulture); - if (SceneChangesInSeconds.Count > 0) - { - DialogResult = DialogResult.OK; - } - else - { - MessageBox.Show(Configuration.Settings.Language.ImportSceneChanges.NoSceneChangesFound); - } - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - _abort = true; - DialogResult = DialogResult.Cancel; - } - - private void ImportSceneChanges_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == Keys.F8) - { - if (_pause) - { - _pause = false; - textBoxLog.Visible = false; - Cursor = Cursors.WaitCursor; - } - else - { - Cursor = Cursors.Default; - textBoxLog.Text = _log.ToString(); - _pause = true; - textBoxLog.Visible = true; - textBoxLog.BringToFront(); - } - } - } - - private void buttonImportWithFfmpeg_Click(object sender, EventArgs e) - { - _sceneChangesGenerator = new SceneChangesGenerator(); - groupBoxImportText.Enabled = false; - buttonOK.Enabled = false; - progressBar1.Visible = true; - progressBar1.Style = ProgressBarStyle.Marquee; - buttonImportWithFfmpeg.Enabled = false; - numericUpDownThreshold.Enabled = false; - Cursor = Cursors.WaitCursor; - textBoxGenerate.Text = string.Empty; - using (var process = _sceneChangesGenerator.GetProcess(_videoFileName, numericUpDownThreshold.Value)) - { - double lastUpdateSeconds = 0; - radioButtonHHMMSSMS.Checked = true; - while (!process.HasExited) - { - Application.DoEvents(); - System.Threading.Thread.Sleep(100); - - if (_pause && !_abort) - { - continue; - } - - if (_sceneChangesGenerator.LastSeconds > 0.1 && Math.Abs(lastUpdateSeconds - _sceneChangesGenerator.LastSeconds) > 0 - 001) - { - lastUpdateSeconds = _sceneChangesGenerator.LastSeconds; - UpdateImportTextBox(); - } - if (_abort) - { - DialogResult = DialogResult.Cancel; - process.Kill(); - return; - } - } - } - Cursor = Cursors.Default; - UpdateImportTextBox(); - buttonOK.Enabled = true; - if (!_pause) - { - buttonOK_Click(sender, e); - } - } - - private void UpdateImportTextBox() - { - textBoxGenerate.Text = _sceneChangesGenerator.GetTimeCodesString(); - textBoxGenerate.SelectionStart = textBoxGenerate.Text.Length; - textBoxGenerate.ScrollToCaret(); - } - - private void ImportSceneChanges_Shown(object sender, EventArgs e) - { - Activate(); - } - - private void buttonDownloadFfmpeg_Click(object sender, EventArgs e) - { - using (var form = new DownloadFfmpeg()) - { - if (form.ShowDialog(this) == DialogResult.OK && !string.IsNullOrEmpty(form.FFmpegPath)) - { - Configuration.Settings.General.FFmpegLocation = form.FFmpegPath; - buttonDownloadFfmpeg.Visible = false; - buttonImportWithFfmpeg.Enabled = true; - numericUpDownThreshold.Enabled = true; - Configuration.Settings.Save(); - } - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class ImportSceneChanges : PositionAndSizeForm + { + public List SceneChangesInSeconds = new List(); + private readonly double _frameRate = 25; + private readonly string _videoFileName; + private bool _abort; + private bool _pause; + private readonly StringBuilder _log; + private SceneChangesGenerator _sceneChangesGenerator; + + public ImportSceneChanges(VideoInfo videoInfo, string videoFileName) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + if (videoInfo != null && videoInfo.FramesPerSecond > 1) + { + _frameRate = videoInfo.FramesPerSecond; + } + + _videoFileName = videoFileName; + + Text = Configuration.Settings.Language.ImportSceneChanges.Title; + groupBoxGenerateSceneChanges.Text = Configuration.Settings.Language.ImportSceneChanges.Generate; + buttonOpenText.Text = Configuration.Settings.Language.ImportSceneChanges.OpenTextFile; + groupBoxImportText.Text = Configuration.Settings.Language.ImportSceneChanges.Import; + radioButtonFrames.Text = Configuration.Settings.Language.ImportSceneChanges.Frames; + radioButtonSeconds.Text = Configuration.Settings.Language.ImportSceneChanges.Seconds; + radioButtonMilliseconds.Text = Configuration.Settings.Language.ImportSceneChanges.Milliseconds; + groupBoxTimeCodes.Text = Configuration.Settings.Language.ImportSceneChanges.TimeCodes; + buttonDownloadFfmpeg.Text = Configuration.Settings.Language.Settings.DownloadFFmpeg; + buttonImportWithFfmpeg.Text = Configuration.Settings.Language.ImportSceneChanges.GetSceneChangesWithFfmpeg; + labelFfmpegThreshold.Text = Configuration.Settings.Language.ImportSceneChanges.Sensitivity; + labelThresholdDescription.Text = Configuration.Settings.Language.ImportSceneChanges.SensitivityDescription; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + buttonImportWithFfmpeg.Enabled = !string.IsNullOrWhiteSpace(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation); + numericUpDownThreshold.Enabled = !string.IsNullOrWhiteSpace(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation); + var isFfmpegAvailable = !string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation); + buttonDownloadFfmpeg.Visible = !isFfmpegAvailable; + if (decimal.TryParse(Configuration.Settings.General.FFmpegSceneThreshold, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var threshold) && + threshold >= numericUpDownThreshold.Minimum && + threshold <= numericUpDownThreshold.Maximum) + { + numericUpDownThreshold.Value = threshold; + } + _log = new StringBuilder(); + textBoxLog.Visible = false; + if (!Configuration.IsRunningOnWindows) + { + buttonDownloadFfmpeg.Visible = false; + buttonImportWithFfmpeg.Enabled = true; + numericUpDownThreshold.Enabled = true; + } + } + + public sealed override string Text + { + get => base.Text; + set => base.Text = value; + } + + private void buttonOpenText_Click(object sender, EventArgs e) + { + openFileDialog1.Title = buttonOpenText.Text; + openFileDialog1.Filter = Configuration.Settings.Language.ImportText.TextFiles + "|*.txt;*.scenechanges;*.xml;*.json" + + "|Matroska xml chapter file|*.xml" + + "|EZTitles shotchanges XML file|*.xml" + + "|JSON scene changes file|*.json" + + "|" + Configuration.Settings.Language.General.AllFiles + "|*.*"; + openFileDialog1.FileName = string.Empty; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + LoadTextFile(openFileDialog1.FileName); + } + } + + private void LoadTextFile(string fileName) + { + try + { + var res = LoadFromMatroskaChapterFile(fileName); + if (!string.IsNullOrEmpty(res)) + { + textBoxIImport.Text = res; + radioButtonHHMMSSMS.Checked = true; + return; + } + + res = LoadFromEZTitlesShotchangesFile(fileName); + if (!string.IsNullOrEmpty(res)) + { + textBoxIImport.Text = res; + radioButtonFrames.Checked = true; + return; + } + + res = LoadFromJsonShotchangesFile(fileName); + if (!string.IsNullOrEmpty(res)) + { + textBoxIImport.Text = res; + radioButtonHHMMSSMS.Checked = true; + return; + } + + var encoding = LanguageAutoDetect.GetEncodingFromFile(fileName); + string s = File.ReadAllText(fileName, encoding).Trim(); + if (s.Contains('.')) + { + radioButtonSeconds.Checked = true; + } + + if (s.Contains('.') && s.Contains(':')) + { + radioButtonHHMMSSMS.Checked = true; + } + + if (!s.Contains(Environment.NewLine) && s.Contains(';')) + { + var sb = new StringBuilder(); + foreach (string line in s.Split(';')) + { + if (!string.IsNullOrWhiteSpace(line)) + { + sb.AppendLine(line.Trim()); + } + } + textBoxIImport.Text = sb.ToString(); + } + else + { + textBoxIImport.Text = s; + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private string LoadFromMatroskaChapterFile(string fileName) + { + try + { + var x = new XmlDocument(); + x.Load(fileName); + var xmlNodeList = x.SelectNodes("//ChapterAtom"); + var sb = new StringBuilder(); + if (xmlNodeList != null) + { + foreach (XmlNode chapter in xmlNodeList) + { + var start = chapter.SelectSingleNode("ChapterTimeStart"); + string[] timeParts = start?.InnerText.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries); + if (timeParts?.Length == 4) + { + if (timeParts[3].Length > 3) + { + timeParts[3] = timeParts[3].Substring(0, 3); + } + + var ts = new TimeSpan(0, Convert.ToInt32(timeParts[0]), Convert.ToInt32(timeParts[1]), Convert.ToInt32(timeParts[2]), Convert.ToInt32(timeParts[3])); + sb.AppendLine(new TimeCode(ts).ToShortStringHHMMSSFF()); + } + } + } + return sb.ToString(); + } + catch + { + return null; + } + } + + private string LoadFromEZTitlesShotchangesFile(string fileName) + { + try + { + var x = new XmlDocument(); + x.Load(fileName); + var xmlNodeList = x.SelectNodes("/shotchanges/shotchanges_list/shotchange"); + var sb = new StringBuilder(); + if (xmlNodeList != null) + { + foreach (XmlNode shotChange in xmlNodeList) + { + sb.AppendLine(shotChange.Attributes["frame"]?.InnerText); + } + } + return sb.ToString(); + } + catch + { + return null; + } + } + + private string LoadFromJsonShotchangesFile(string fileName) + { + try + { + var text = FileUtil.ReadAllTextShared(fileName, Encoding.UTF8); + var list = new List(); + foreach (string line in text.Split(',')) + { + string s = line.Trim() + "}"; + string start = Json.ReadTag(s, "frame_time"); + if (start != null) + { + if (double.TryParse(start, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var startSeconds)) + { + list.Add(startSeconds * 1000.0); + } + } + } + + var sb = new StringBuilder(); + foreach (double ms in list.OrderBy(p => p)) + { + sb.AppendLine(new TimeCode(ms).ToShortStringHHMMSSFF()); + } + return sb.ToString(); + } + catch + { + return null; + } + } + + + private static readonly char[] SplitChars = { ':', '.', ',' }; + + private void buttonOK_Click(object sender, EventArgs e) + { + var lines = string.IsNullOrEmpty(textBoxGenerate.Text) ? textBoxIImport.Lines : textBoxGenerate.Lines; + if (radioButtonHHMMSSMS.Checked) + { + SceneChangesInSeconds = SceneChangesGenerator.GetSeconds(lines); + } + else + { + SceneChangesInSeconds = new List(); + foreach (var line in lines) + { + if (double.TryParse(line, out var d)) + { + if (radioButtonFrames.Checked) + { + SceneChangesInSeconds.Add(d / _frameRate); + } + else if (radioButtonSeconds.Checked) + { + SceneChangesInSeconds.Add(d); + } + else if (radioButtonMilliseconds.Checked) + { + SceneChangesInSeconds.Add(d / TimeCode.BaseUnit); + } + } + } + } + + Configuration.Settings.General.FFmpegSceneThreshold = numericUpDownThreshold.Value.ToString(CultureInfo.InvariantCulture); + if (SceneChangesInSeconds.Count > 0) + { + DialogResult = DialogResult.OK; + } + else + { + MessageBox.Show(Configuration.Settings.Language.ImportSceneChanges.NoSceneChangesFound); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + _abort = true; + DialogResult = DialogResult.Cancel; + } + + private void ImportSceneChanges_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == Keys.F8) + { + if (_pause) + { + _pause = false; + textBoxLog.Visible = false; + Cursor = Cursors.WaitCursor; + } + else + { + Cursor = Cursors.Default; + textBoxLog.Text = _log.ToString(); + _pause = true; + textBoxLog.Visible = true; + textBoxLog.BringToFront(); + } + } + } + + private void buttonImportWithFfmpeg_Click(object sender, EventArgs e) + { + _sceneChangesGenerator = new SceneChangesGenerator(); + groupBoxImportText.Enabled = false; + buttonOK.Enabled = false; + progressBar1.Visible = true; + progressBar1.Style = ProgressBarStyle.Marquee; + buttonImportWithFfmpeg.Enabled = false; + numericUpDownThreshold.Enabled = false; + Cursor = Cursors.WaitCursor; + textBoxGenerate.Text = string.Empty; + using (var process = _sceneChangesGenerator.GetProcess(_videoFileName, numericUpDownThreshold.Value)) + { + double lastUpdateSeconds = 0; + radioButtonHHMMSSMS.Checked = true; + while (!process.HasExited) + { + Application.DoEvents(); + System.Threading.Thread.Sleep(100); + + if (_pause && !_abort) + { + continue; + } + + if (_sceneChangesGenerator.LastSeconds > 0.1 && Math.Abs(lastUpdateSeconds - _sceneChangesGenerator.LastSeconds) > 0 - 001) + { + lastUpdateSeconds = _sceneChangesGenerator.LastSeconds; + UpdateImportTextBox(); + } + if (_abort) + { + DialogResult = DialogResult.Cancel; + process.Kill(); + return; + } + } + } + Cursor = Cursors.Default; + UpdateImportTextBox(); + buttonOK.Enabled = true; + if (!_pause) + { + buttonOK_Click(sender, e); + } + } + + private void UpdateImportTextBox() + { + textBoxGenerate.Text = _sceneChangesGenerator.GetTimeCodesString(); + textBoxGenerate.SelectionStart = textBoxGenerate.Text.Length; + textBoxGenerate.ScrollToCaret(); + } + + private void ImportSceneChanges_Shown(object sender, EventArgs e) + { + Activate(); + } + + private void buttonDownloadFfmpeg_Click(object sender, EventArgs e) + { + using (var form = new DownloadFfmpeg()) + { + if (form.ShowDialog(this) == DialogResult.OK && !string.IsNullOrEmpty(form.FFmpegPath)) + { + Configuration.Settings.General.FFmpegLocation = form.FFmpegPath; + buttonDownloadFfmpeg.Visible = false; + buttonImportWithFfmpeg.Enabled = true; + numericUpDownThreshold.Enabled = true; + Configuration.Settings.Save(); + } + } + } + } +} diff --git a/src/Forms/ImportSceneChanges.resx b/src/ui/Forms/ImportSceneChanges.resx similarity index 97% rename from src/Forms/ImportSceneChanges.resx rename to src/ui/Forms/ImportSceneChanges.resx index 3a7d67153..9bad2f599 100644 --- a/src/Forms/ImportSceneChanges.resx +++ b/src/ui/Forms/ImportSceneChanges.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/ImportText.Designer.cs b/src/ui/Forms/ImportText.Designer.cs similarity index 98% rename from src/Forms/ImportText.Designer.cs rename to src/ui/Forms/ImportText.Designer.cs index cbb40d855..57fbfac50 100644 --- a/src/Forms/ImportText.Designer.cs +++ b/src/ui/Forms/ImportText.Designer.cs @@ -1,794 +1,794 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class ImportText - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.buttonOpenText = new System.Windows.Forms.Button(); - this.groupBoxImportText = new System.Windows.Forms.GroupBox(); - this.checkBoxMultipleFiles = new System.Windows.Forms.CheckBox(); - this.listViewInputFiles = new System.Windows.Forms.ListView(); - this.columnHeaderFName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.contextMenuStripListView = new System.Windows.Forms.ContextMenuStrip(this.components); - this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.textBoxText = new System.Windows.Forms.TextBox(); - this.groupBoxImportOptions = new System.Windows.Forms.GroupBox(); - this.checkBoxTakeTimeFromFileNames = new System.Windows.Forms.CheckBox(); - this.groupBoxAutoSplitSettings = new System.Windows.Forms.GroupBox(); - this.checkBoxAutoSplitAtEnd = new System.Windows.Forms.CheckBox(); - this.labelSubMaxLen = new System.Windows.Forms.Label(); - this.numericUpDownSubtitleLineMaximumLength = new System.Windows.Forms.NumericUpDown(); - this.textBoxAsEnd = new System.Windows.Forms.TextBox(); - this.checkBoxAutoSplitRemoveLinesNoLetters = new System.Windows.Forms.CheckBox(); - this.checkBoxAutoSplitAtBlankLines = new System.Windows.Forms.CheckBox(); - this.numericUpDownAutoSplitMaxLines = new System.Windows.Forms.NumericUpDown(); - this.labelAutoSplitNumberOfLines = new System.Windows.Forms.Label(); - this.checkBoxAutoBreak = new System.Windows.Forms.CheckBox(); - this.checkBoxGenerateTimeCodes = new System.Windows.Forms.CheckBox(); - this.groupBoxTimeCodes = new System.Windows.Forms.GroupBox(); - this.labelGapBetweenSubtitles = new System.Windows.Forms.Label(); - this.numericUpDownGapBetweenLines = new System.Windows.Forms.NumericUpDown(); - this.groupBoxDuration = new System.Windows.Forms.GroupBox(); - this.numericUpDownDurationFixed = new System.Windows.Forms.NumericUpDown(); - this.radioButtonDurationFixed = new System.Windows.Forms.RadioButton(); - this.radioButtonDurationAuto = new System.Windows.Forms.RadioButton(); - this.checkBoxMergeShortLines = new System.Windows.Forms.CheckBox(); - this.checkBoxRemoveLinesWithoutLetters = new System.Windows.Forms.CheckBox(); - this.groupBoxSplitting = new System.Windows.Forms.GroupBox(); - this.comboBoxLineMode = new System.Windows.Forms.ComboBox(); - this.comboBoxLineBreak = new System.Windows.Forms.ComboBox(); - this.labelLineBreak = new System.Windows.Forms.Label(); - this.radioButtonSplitAtBlankLines = new System.Windows.Forms.RadioButton(); - this.radioButtonAutoSplit = new System.Windows.Forms.RadioButton(); - this.radioButtonLineMode = new System.Windows.Forms.RadioButton(); - this.checkBoxRemoveEmptyLines = new System.Windows.Forms.CheckBox(); - this.buttonRefresh = new System.Windows.Forms.Button(); - this.groupBoxImportResult = new System.Windows.Forms.GroupBox(); - this.contextMenuStripPreview = new System.Windows.Forms.ContextMenuStrip(this.components); - this.startNumberingFromToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.labelStatus = new System.Windows.Forms.Label(); - this.groupBoxImportText.SuspendLayout(); - this.contextMenuStripListView.SuspendLayout(); - this.groupBoxImportOptions.SuspendLayout(); - this.groupBoxAutoSplitSettings.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSubtitleLineMaximumLength)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAutoSplitMaxLines)).BeginInit(); - this.groupBoxTimeCodes.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownGapBetweenLines)).BeginInit(); - this.groupBoxDuration.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationFixed)).BeginInit(); - this.groupBoxSplitting.SuspendLayout(); - this.groupBoxImportResult.SuspendLayout(); - this.contextMenuStripPreview.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOpenText - // - this.buttonOpenText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOpenText.Location = new System.Drawing.Point(475, 19); - this.buttonOpenText.Name = "buttonOpenText"; - this.buttonOpenText.Size = new System.Drawing.Size(143, 23); - this.buttonOpenText.TabIndex = 4; - this.buttonOpenText.Text = "Open file..."; - this.buttonOpenText.UseVisualStyleBackColor = true; - this.buttonOpenText.Click += new System.EventHandler(this.ButtonOpenTextClick); - // - // groupBoxImportText - // - this.groupBoxImportText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxImportText.Controls.Add(this.checkBoxMultipleFiles); - this.groupBoxImportText.Controls.Add(this.buttonOpenText); - this.groupBoxImportText.Controls.Add(this.textBoxText); - this.groupBoxImportText.Controls.Add(this.listViewInputFiles); - this.groupBoxImportText.Location = new System.Drawing.Point(12, 12); - this.groupBoxImportText.Name = "groupBoxImportText"; - this.groupBoxImportText.Size = new System.Drawing.Size(624, 410); - this.groupBoxImportText.TabIndex = 0; - this.groupBoxImportText.TabStop = false; - this.groupBoxImportText.Text = "Import text"; - // - // checkBoxMultipleFiles - // - this.checkBoxMultipleFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.checkBoxMultipleFiles.AutoSize = true; - this.checkBoxMultipleFiles.Location = new System.Drawing.Point(271, 22); - this.checkBoxMultipleFiles.Name = "checkBoxMultipleFiles"; - this.checkBoxMultipleFiles.Size = new System.Drawing.Size(198, 17); - this.checkBoxMultipleFiles.TabIndex = 2; - this.checkBoxMultipleFiles.Text = "Multiple files - one file is one subtitle"; - this.checkBoxMultipleFiles.UseVisualStyleBackColor = true; - this.checkBoxMultipleFiles.CheckedChanged += new System.EventHandler(this.checkBoxMultipleFiles_CheckedChanged); - // - // listViewInputFiles - // - this.listViewInputFiles.AllowDrop = true; - this.listViewInputFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewInputFiles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderFName, - this.columnHeaderSize}); - this.listViewInputFiles.ContextMenuStrip = this.contextMenuStripListView; - this.listViewInputFiles.FullRowSelect = true; - this.listViewInputFiles.HideSelection = false; - this.listViewInputFiles.Location = new System.Drawing.Point(6, 48); - this.listViewInputFiles.Name = "listViewInputFiles"; - this.listViewInputFiles.Size = new System.Drawing.Size(612, 356); - this.listViewInputFiles.TabIndex = 6; - this.listViewInputFiles.UseCompatibleStateImageBehavior = false; - this.listViewInputFiles.View = System.Windows.Forms.View.Details; - this.listViewInputFiles.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewInputFiles_DragDrop); - this.listViewInputFiles.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewInputFiles_DragEnter); - // - // columnHeaderFName - // - this.columnHeaderFName.Text = "File name"; - this.columnHeaderFName.Width = 420; - // - // columnHeaderSize - // - this.columnHeaderSize.Text = "Size"; - this.columnHeaderSize.Width = 81; - // - // contextMenuStripListView - // - this.contextMenuStripListView.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.clearToolStripMenuItem}); - this.contextMenuStripListView.Name = "contextMenuStripListView"; - this.contextMenuStripListView.Size = new System.Drawing.Size(102, 26); - // - // clearToolStripMenuItem - // - this.clearToolStripMenuItem.Name = "clearToolStripMenuItem"; - this.clearToolStripMenuItem.Size = new System.Drawing.Size(101, 22); - this.clearToolStripMenuItem.Text = "Clear"; - this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click); - // - // textBoxText - // - this.textBoxText.AllowDrop = true; - this.textBoxText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxText.Location = new System.Drawing.Point(6, 48); - this.textBoxText.MaxLength = 0; - this.textBoxText.Multiline = true; - this.textBoxText.Name = "textBoxText"; - this.textBoxText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxText.Size = new System.Drawing.Size(612, 356); - this.textBoxText.TabIndex = 1; - this.textBoxText.TextChanged += new System.EventHandler(this.TextBoxTextTextChanged); - this.textBoxText.DragDrop += new System.Windows.Forms.DragEventHandler(this.TextBoxTextDragDrop); - this.textBoxText.DragEnter += new System.Windows.Forms.DragEventHandler(this.TextBoxTextDragEnter); - // - // groupBoxImportOptions - // - this.groupBoxImportOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxImportOptions.Controls.Add(this.checkBoxTakeTimeFromFileNames); - this.groupBoxImportOptions.Controls.Add(this.groupBoxAutoSplitSettings); - this.groupBoxImportOptions.Controls.Add(this.checkBoxAutoBreak); - this.groupBoxImportOptions.Controls.Add(this.checkBoxGenerateTimeCodes); - this.groupBoxImportOptions.Controls.Add(this.groupBoxTimeCodes); - this.groupBoxImportOptions.Controls.Add(this.checkBoxMergeShortLines); - this.groupBoxImportOptions.Controls.Add(this.checkBoxRemoveLinesWithoutLetters); - this.groupBoxImportOptions.Controls.Add(this.groupBoxSplitting); - this.groupBoxImportOptions.Controls.Add(this.checkBoxRemoveEmptyLines); - this.groupBoxImportOptions.Location = new System.Drawing.Point(642, 12); - this.groupBoxImportOptions.Name = "groupBoxImportOptions"; - this.groupBoxImportOptions.Size = new System.Drawing.Size(402, 410); - this.groupBoxImportOptions.TabIndex = 1; - this.groupBoxImportOptions.TabStop = false; - this.groupBoxImportOptions.Text = "Import options"; - // - // checkBoxTakeTimeFromFileNames - // - this.checkBoxTakeTimeFromFileNames.AutoSize = true; - this.checkBoxTakeTimeFromFileNames.Location = new System.Drawing.Point(157, 250); - this.checkBoxTakeTimeFromFileNames.Name = "checkBoxTakeTimeFromFileNames"; - this.checkBoxTakeTimeFromFileNames.Size = new System.Drawing.Size(143, 17); - this.checkBoxTakeTimeFromFileNames.TabIndex = 5; - this.checkBoxTakeTimeFromFileNames.Text = "Take time from file name"; - this.checkBoxTakeTimeFromFileNames.UseVisualStyleBackColor = true; - // - // groupBoxAutoSplitSettings - // - this.groupBoxAutoSplitSettings.Controls.Add(this.checkBoxAutoSplitAtEnd); - this.groupBoxAutoSplitSettings.Controls.Add(this.labelSubMaxLen); - this.groupBoxAutoSplitSettings.Controls.Add(this.numericUpDownSubtitleLineMaximumLength); - this.groupBoxAutoSplitSettings.Controls.Add(this.textBoxAsEnd); - this.groupBoxAutoSplitSettings.Controls.Add(this.checkBoxAutoSplitRemoveLinesNoLetters); - this.groupBoxAutoSplitSettings.Controls.Add(this.checkBoxAutoSplitAtBlankLines); - this.groupBoxAutoSplitSettings.Controls.Add(this.numericUpDownAutoSplitMaxLines); - this.groupBoxAutoSplitSettings.Controls.Add(this.labelAutoSplitNumberOfLines); - this.groupBoxAutoSplitSettings.Location = new System.Drawing.Point(6, 91); - this.groupBoxAutoSplitSettings.Name = "groupBoxAutoSplitSettings"; - this.groupBoxAutoSplitSettings.Size = new System.Drawing.Size(390, 153); - this.groupBoxAutoSplitSettings.TabIndex = 1; - this.groupBoxAutoSplitSettings.TabStop = false; - this.groupBoxAutoSplitSettings.Text = "Auto split text settings"; - // - // checkBoxAutoSplitAtEnd - // - this.checkBoxAutoSplitAtEnd.AutoSize = true; - this.checkBoxAutoSplitAtEnd.Checked = true; - this.checkBoxAutoSplitAtEnd.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxAutoSplitAtEnd.Location = new System.Drawing.Point(6, 119); - this.checkBoxAutoSplitAtEnd.Name = "checkBoxAutoSplitAtEnd"; - this.checkBoxAutoSplitAtEnd.Size = new System.Drawing.Size(109, 17); - this.checkBoxAutoSplitAtEnd.TabIndex = 50; - this.checkBoxAutoSplitAtEnd.Text = "Split at end chars"; - this.checkBoxAutoSplitAtEnd.UseVisualStyleBackColor = true; - this.checkBoxAutoSplitAtEnd.CheckedChanged += new System.EventHandler(this.checkBoxAutoSplitAtEnd_CheckedChanged); - // - // labelSubMaxLen - // - this.labelSubMaxLen.AutoSize = true; - this.labelSubMaxLen.Location = new System.Drawing.Point(6, 47); - this.labelSubMaxLen.Name = "labelSubMaxLen"; - this.labelSubMaxLen.Size = new System.Drawing.Size(103, 13); - this.labelSubMaxLen.TabIndex = 17; - this.labelSubMaxLen.Text = "Subtitle max. length"; - // - // numericUpDownSubtitleLineMaximumLength - // - this.numericUpDownSubtitleLineMaximumLength.Location = new System.Drawing.Point(112, 44); - this.numericUpDownSubtitleLineMaximumLength.Maximum = new decimal(new int[] { - 999, - 0, - 0, - 0}); - this.numericUpDownSubtitleLineMaximumLength.Minimum = new decimal(new int[] { - 10, - 0, - 0, - 0}); - this.numericUpDownSubtitleLineMaximumLength.Name = "numericUpDownSubtitleLineMaximumLength"; - this.numericUpDownSubtitleLineMaximumLength.Size = new System.Drawing.Size(49, 21); - this.numericUpDownSubtitleLineMaximumLength.TabIndex = 20; - this.numericUpDownSubtitleLineMaximumLength.Value = new decimal(new int[] { - 43, - 0, - 0, - 0}); - this.numericUpDownSubtitleLineMaximumLength.ValueChanged += new System.EventHandler(this.numericUpDownSubtitleLineMaximumLength_ValueChanged); - // - // textBoxAsEnd - // - this.textBoxAsEnd.Location = new System.Drawing.Point(118, 117); - this.textBoxAsEnd.MaxLength = 5; - this.textBoxAsEnd.Name = "textBoxAsEnd"; - this.textBoxAsEnd.Size = new System.Drawing.Size(50, 21); - this.textBoxAsEnd.TabIndex = 51; - this.textBoxAsEnd.TextChanged += new System.EventHandler(this.textBoxAsEnd1_TextChanged); - this.textBoxAsEnd.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBoxAsEnd1_KeyPress); - // - // checkBoxAutoSplitRemoveLinesNoLetters - // - this.checkBoxAutoSplitRemoveLinesNoLetters.AutoSize = true; - this.checkBoxAutoSplitRemoveLinesNoLetters.Checked = true; - this.checkBoxAutoSplitRemoveLinesNoLetters.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxAutoSplitRemoveLinesNoLetters.Location = new System.Drawing.Point(6, 96); - this.checkBoxAutoSplitRemoveLinesNoLetters.Name = "checkBoxAutoSplitRemoveLinesNoLetters"; - this.checkBoxAutoSplitRemoveLinesNoLetters.Size = new System.Drawing.Size(162, 17); - this.checkBoxAutoSplitRemoveLinesNoLetters.TabIndex = 40; - this.checkBoxAutoSplitRemoveLinesNoLetters.Text = "Remove lines without letters"; - this.checkBoxAutoSplitRemoveLinesNoLetters.UseVisualStyleBackColor = true; - this.checkBoxAutoSplitRemoveLinesNoLetters.CheckedChanged += new System.EventHandler(this.checkBoxAutoSplitRemoveLinesNoLetters_CheckedChanged); - // - // checkBoxAutoSplitAtBlankLines - // - this.checkBoxAutoSplitAtBlankLines.AutoSize = true; - this.checkBoxAutoSplitAtBlankLines.Checked = true; - this.checkBoxAutoSplitAtBlankLines.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxAutoSplitAtBlankLines.Location = new System.Drawing.Point(6, 73); - this.checkBoxAutoSplitAtBlankLines.Name = "checkBoxAutoSplitAtBlankLines"; - this.checkBoxAutoSplitAtBlankLines.Size = new System.Drawing.Size(111, 17); - this.checkBoxAutoSplitAtBlankLines.TabIndex = 30; - this.checkBoxAutoSplitAtBlankLines.Text = "Split at blank lines"; - this.checkBoxAutoSplitAtBlankLines.UseVisualStyleBackColor = true; - this.checkBoxAutoSplitAtBlankLines.CheckedChanged += new System.EventHandler(this.checkBoxAutoSplitAtBlankLines_CheckedChanged); - // - // numericUpDownAutoSplitMaxLines - // - this.numericUpDownAutoSplitMaxLines.Location = new System.Drawing.Point(115, 17); - this.numericUpDownAutoSplitMaxLines.Maximum = new decimal(new int[] { - 2, - 0, - 0, - 0}); - this.numericUpDownAutoSplitMaxLines.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.numericUpDownAutoSplitMaxLines.Name = "numericUpDownAutoSplitMaxLines"; - this.numericUpDownAutoSplitMaxLines.Size = new System.Drawing.Size(46, 21); - this.numericUpDownAutoSplitMaxLines.TabIndex = 10; - this.numericUpDownAutoSplitMaxLines.Value = new decimal(new int[] { - 2, - 0, - 0, - 0}); - this.numericUpDownAutoSplitMaxLines.ValueChanged += new System.EventHandler(this.numericUpDownAutoSplitMaxLines_ValueChanged); - // - // labelAutoSplitNumberOfLines - // - this.labelAutoSplitNumberOfLines.AutoSize = true; - this.labelAutoSplitNumberOfLines.Location = new System.Drawing.Point(6, 19); - this.labelAutoSplitNumberOfLines.Name = "labelAutoSplitNumberOfLines"; - this.labelAutoSplitNumberOfLines.Size = new System.Drawing.Size(103, 13); - this.labelAutoSplitNumberOfLines.TabIndex = 6; - this.labelAutoSplitNumberOfLines.Text = "Max number of lines"; - // - // checkBoxAutoBreak - // - this.checkBoxAutoBreak.AutoSize = true; - this.checkBoxAutoBreak.Location = new System.Drawing.Point(19, 163); - this.checkBoxAutoBreak.Name = "checkBoxAutoBreak"; - this.checkBoxAutoBreak.Size = new System.Drawing.Size(104, 17); - this.checkBoxAutoBreak.TabIndex = 7; - this.checkBoxAutoBreak.Text = "Auto-break lines"; - this.checkBoxAutoBreak.UseVisualStyleBackColor = true; - this.checkBoxAutoBreak.CheckedChanged += new System.EventHandler(this.checkBoxAutoBreak_CheckedChanged); - // - // checkBoxGenerateTimeCodes - // - this.checkBoxGenerateTimeCodes.AutoSize = true; - this.checkBoxGenerateTimeCodes.Location = new System.Drawing.Point(16, 250); - this.checkBoxGenerateTimeCodes.Name = "checkBoxGenerateTimeCodes"; - this.checkBoxGenerateTimeCodes.Size = new System.Drawing.Size(125, 17); - this.checkBoxGenerateTimeCodes.TabIndex = 4; - this.checkBoxGenerateTimeCodes.Text = "Generate time codes"; - this.checkBoxGenerateTimeCodes.UseVisualStyleBackColor = true; - this.checkBoxGenerateTimeCodes.CheckedChanged += new System.EventHandler(this.checkBoxGenerateTimeCodes_CheckedChanged); - // - // groupBoxTimeCodes - // - this.groupBoxTimeCodes.Controls.Add(this.labelGapBetweenSubtitles); - this.groupBoxTimeCodes.Controls.Add(this.numericUpDownGapBetweenLines); - this.groupBoxTimeCodes.Controls.Add(this.groupBoxDuration); - this.groupBoxTimeCodes.Enabled = false; - this.groupBoxTimeCodes.Location = new System.Drawing.Point(6, 273); - this.groupBoxTimeCodes.Name = "groupBoxTimeCodes"; - this.groupBoxTimeCodes.Size = new System.Drawing.Size(390, 126); - this.groupBoxTimeCodes.TabIndex = 6; - this.groupBoxTimeCodes.TabStop = false; - this.groupBoxTimeCodes.Text = "Time codes"; - // - // labelGapBetweenSubtitles - // - this.labelGapBetweenSubtitles.AutoSize = true; - this.labelGapBetweenSubtitles.Location = new System.Drawing.Point(6, 23); - this.labelGapBetweenSubtitles.Name = "labelGapBetweenSubtitles"; - this.labelGapBetweenSubtitles.Size = new System.Drawing.Size(180, 13); - this.labelGapBetweenSubtitles.TabIndex = 0; - this.labelGapBetweenSubtitles.Text = "Gap between subtitles (milliseconds)"; - // - // numericUpDownGapBetweenLines - // - this.numericUpDownGapBetweenLines.Location = new System.Drawing.Point(192, 20); - this.numericUpDownGapBetweenLines.Maximum = new decimal(new int[] { - 100000, - 0, - 0, - 0}); - this.numericUpDownGapBetweenLines.Name = "numericUpDownGapBetweenLines"; - this.numericUpDownGapBetweenLines.Size = new System.Drawing.Size(64, 21); - this.numericUpDownGapBetweenLines.TabIndex = 1; - this.numericUpDownGapBetweenLines.Value = new decimal(new int[] { - 1000, - 0, - 0, - 0}); - this.numericUpDownGapBetweenLines.ValueChanged += new System.EventHandler(this.NumericUpDownGapBetweenLinesValueChanged); - // - // groupBoxDuration - // - this.groupBoxDuration.Controls.Add(this.numericUpDownDurationFixed); - this.groupBoxDuration.Controls.Add(this.radioButtonDurationFixed); - this.groupBoxDuration.Controls.Add(this.radioButtonDurationAuto); - this.groupBoxDuration.Location = new System.Drawing.Point(9, 47); - this.groupBoxDuration.Name = "groupBoxDuration"; - this.groupBoxDuration.Size = new System.Drawing.Size(247, 70); - this.groupBoxDuration.TabIndex = 2; - this.groupBoxDuration.TabStop = false; - this.groupBoxDuration.Text = "Duration"; - // - // numericUpDownDurationFixed - // - this.numericUpDownDurationFixed.Location = new System.Drawing.Point(111, 42); - this.numericUpDownDurationFixed.Maximum = new decimal(new int[] { - 100000, - 0, - 0, - 0}); - this.numericUpDownDurationFixed.Name = "numericUpDownDurationFixed"; - this.numericUpDownDurationFixed.Size = new System.Drawing.Size(64, 21); - this.numericUpDownDurationFixed.TabIndex = 2; - this.numericUpDownDurationFixed.Value = new decimal(new int[] { - 2000, - 0, - 0, - 0}); - this.numericUpDownDurationFixed.ValueChanged += new System.EventHandler(this.NumericUpDownDurationFixedValueChanged); - // - // radioButtonDurationFixed - // - this.radioButtonDurationFixed.AutoSize = true; - this.radioButtonDurationFixed.Location = new System.Drawing.Point(16, 42); - this.radioButtonDurationFixed.Name = "radioButtonDurationFixed"; - this.radioButtonDurationFixed.Size = new System.Drawing.Size(51, 17); - this.radioButtonDurationFixed.TabIndex = 1; - this.radioButtonDurationFixed.Text = "Fixed"; - this.radioButtonDurationFixed.UseVisualStyleBackColor = true; - this.radioButtonDurationFixed.CheckedChanged += new System.EventHandler(this.RadioButtonDurationFixedCheckedChanged); - // - // radioButtonDurationAuto - // - this.radioButtonDurationAuto.AutoSize = true; - this.radioButtonDurationAuto.Checked = true; - this.radioButtonDurationAuto.Location = new System.Drawing.Point(16, 19); - this.radioButtonDurationAuto.Name = "radioButtonDurationAuto"; - this.radioButtonDurationAuto.Size = new System.Drawing.Size(48, 17); - this.radioButtonDurationAuto.TabIndex = 0; - this.radioButtonDurationAuto.TabStop = true; - this.radioButtonDurationAuto.Text = "Auto"; - this.radioButtonDurationAuto.UseVisualStyleBackColor = true; - this.radioButtonDurationAuto.CheckedChanged += new System.EventHandler(this.RadioButtonDurationAutoCheckedChanged); - // - // checkBoxMergeShortLines - // - this.checkBoxMergeShortLines.AutoSize = true; - this.checkBoxMergeShortLines.Checked = true; - this.checkBoxMergeShortLines.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxMergeShortLines.Location = new System.Drawing.Point(19, 94); - this.checkBoxMergeShortLines.Name = "checkBoxMergeShortLines"; - this.checkBoxMergeShortLines.Size = new System.Drawing.Size(193, 17); - this.checkBoxMergeShortLines.TabIndex = 1; - this.checkBoxMergeShortLines.Text = "Merge short lines with continuation"; - this.checkBoxMergeShortLines.UseVisualStyleBackColor = true; - this.checkBoxMergeShortLines.CheckedChanged += new System.EventHandler(this.CheckBoxMergeShortLinesCheckedChanged); - // - // checkBoxRemoveLinesWithoutLetters - // - this.checkBoxRemoveLinesWithoutLetters.AutoSize = true; - this.checkBoxRemoveLinesWithoutLetters.Checked = true; - this.checkBoxRemoveLinesWithoutLetters.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxRemoveLinesWithoutLetters.Location = new System.Drawing.Point(19, 140); - this.checkBoxRemoveLinesWithoutLetters.Name = "checkBoxRemoveLinesWithoutLetters"; - this.checkBoxRemoveLinesWithoutLetters.Size = new System.Drawing.Size(162, 17); - this.checkBoxRemoveLinesWithoutLetters.TabIndex = 3; - this.checkBoxRemoveLinesWithoutLetters.Text = "Remove lines without letters"; - this.checkBoxRemoveLinesWithoutLetters.UseVisualStyleBackColor = true; - this.checkBoxRemoveLinesWithoutLetters.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveLinesWithoutLettersOrNumbersCheckedChanged); - // - // groupBoxSplitting - // - this.groupBoxSplitting.Controls.Add(this.comboBoxLineMode); - this.groupBoxSplitting.Controls.Add(this.comboBoxLineBreak); - this.groupBoxSplitting.Controls.Add(this.labelLineBreak); - this.groupBoxSplitting.Controls.Add(this.radioButtonSplitAtBlankLines); - this.groupBoxSplitting.Controls.Add(this.radioButtonAutoSplit); - this.groupBoxSplitting.Controls.Add(this.radioButtonLineMode); - this.groupBoxSplitting.Location = new System.Drawing.Point(6, 17); - this.groupBoxSplitting.Name = "groupBoxSplitting"; - this.groupBoxSplitting.Size = new System.Drawing.Size(390, 68); - this.groupBoxSplitting.TabIndex = 0; - this.groupBoxSplitting.TabStop = false; - this.groupBoxSplitting.Text = "Splitting"; - // - // comboBoxLineMode - // - this.comboBoxLineMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxLineMode.FormattingEnabled = true; - this.comboBoxLineMode.Items.AddRange(new object[] { - "One line is a subtitle", - "Two lines is a subtitle"}); - this.comboBoxLineMode.Location = new System.Drawing.Point(31, 41); - this.comboBoxLineMode.Name = "comboBoxLineMode"; - this.comboBoxLineMode.Size = new System.Drawing.Size(144, 21); - this.comboBoxLineMode.TabIndex = 2; - this.comboBoxLineMode.SelectedIndexChanged += new System.EventHandler(this.comboBoxLineMode_SelectedIndexChanged); - // - // comboBoxLineBreak - // - this.comboBoxLineBreak.FormattingEnabled = true; - this.comboBoxLineBreak.Items.AddRange(new object[] { - "|", - "\\N;\\n", - "|;\\N;\\n;//;
;
;
"}); - this.comboBoxLineBreak.Location = new System.Drawing.Point(246, 41); - this.comboBoxLineBreak.Name = "comboBoxLineBreak"; - this.comboBoxLineBreak.Size = new System.Drawing.Size(107, 21); - this.comboBoxLineBreak.TabIndex = 5; - this.comboBoxLineBreak.TextChanged += new System.EventHandler(this.comboBoxLineBreak_TextChanged); - // - // labelLineBreak - // - this.labelLineBreak.AutoSize = true; - this.labelLineBreak.Location = new System.Drawing.Point(184, 44); - this.labelLineBreak.Name = "labelLineBreak"; - this.labelLineBreak.Size = new System.Drawing.Size(56, 13); - this.labelLineBreak.TabIndex = 4; - this.labelLineBreak.Text = "Line break"; - // - // radioButtonSplitAtBlankLines - // - this.radioButtonSplitAtBlankLines.AutoSize = true; - this.radioButtonSplitAtBlankLines.Location = new System.Drawing.Point(183, 19); - this.radioButtonSplitAtBlankLines.Name = "radioButtonSplitAtBlankLines"; - this.radioButtonSplitAtBlankLines.Size = new System.Drawing.Size(110, 17); - this.radioButtonSplitAtBlankLines.TabIndex = 3; - this.radioButtonSplitAtBlankLines.Text = "Split at blank lines"; - this.radioButtonSplitAtBlankLines.UseVisualStyleBackColor = true; - this.radioButtonSplitAtBlankLines.CheckedChanged += new System.EventHandler(this.radioButtonSplitAtBlankLines_CheckedChanged); - // - // radioButtonAutoSplit - // - this.radioButtonAutoSplit.AutoSize = true; - this.radioButtonAutoSplit.Checked = true; - this.radioButtonAutoSplit.Location = new System.Drawing.Point(14, 19); - this.radioButtonAutoSplit.Name = "radioButtonAutoSplit"; - this.radioButtonAutoSplit.Size = new System.Drawing.Size(93, 17); - this.radioButtonAutoSplit.TabIndex = 0; - this.radioButtonAutoSplit.TabStop = true; - this.radioButtonAutoSplit.Text = "Auto split text"; - this.radioButtonAutoSplit.UseVisualStyleBackColor = true; - this.radioButtonAutoSplit.CheckedChanged += new System.EventHandler(this.RadioButtonAutoSplitCheckedChanged); - // - // radioButtonLineMode - // - this.radioButtonLineMode.AutoSize = true; - this.radioButtonLineMode.Location = new System.Drawing.Point(14, 43); - this.radioButtonLineMode.Name = "radioButtonLineMode"; - this.radioButtonLineMode.Size = new System.Drawing.Size(133, 17); - this.radioButtonLineMode.TabIndex = 1; - this.radioButtonLineMode.Text = "One line is one subtitle"; - this.radioButtonLineMode.UseVisualStyleBackColor = true; - this.radioButtonLineMode.CheckedChanged += new System.EventHandler(this.RadioButtonLineModeCheckedChanged); - // - // checkBoxRemoveEmptyLines - // - this.checkBoxRemoveEmptyLines.AutoSize = true; - this.checkBoxRemoveEmptyLines.Checked = true; - this.checkBoxRemoveEmptyLines.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxRemoveEmptyLines.Location = new System.Drawing.Point(19, 117); - this.checkBoxRemoveEmptyLines.Name = "checkBoxRemoveEmptyLines"; - this.checkBoxRemoveEmptyLines.Size = new System.Drawing.Size(122, 17); - this.checkBoxRemoveEmptyLines.TabIndex = 2; - this.checkBoxRemoveEmptyLines.Text = "Remove empty lines"; - this.checkBoxRemoveEmptyLines.UseVisualStyleBackColor = true; - this.checkBoxRemoveEmptyLines.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveEmptyLinesCheckedChanged); - // - // buttonRefresh - // - this.buttonRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRefresh.Location = new System.Drawing.Point(774, 735); - this.buttonRefresh.Name = "buttonRefresh"; - this.buttonRefresh.Size = new System.Drawing.Size(102, 23); - this.buttonRefresh.TabIndex = 103; - this.buttonRefresh.Text = "Refresh"; - this.buttonRefresh.UseVisualStyleBackColor = true; - this.buttonRefresh.Click += new System.EventHandler(this.ButtonRefreshClick); - // - // groupBoxImportResult - // - this.groupBoxImportResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxImportResult.Controls.Add(this.SubtitleListview1); - this.groupBoxImportResult.Location = new System.Drawing.Point(12, 428); - this.groupBoxImportResult.Name = "groupBoxImportResult"; - this.groupBoxImportResult.Size = new System.Drawing.Size(1032, 299); - this.groupBoxImportResult.TabIndex = 2; - this.groupBoxImportResult.TabStop = false; - this.groupBoxImportResult.Text = "Preview"; - // - // contextMenuStripPreview - // - this.contextMenuStripPreview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.startNumberingFromToolStripMenuItem}); - this.contextMenuStripPreview.Name = "contextMenuStripPreview"; - this.contextMenuStripPreview.Size = new System.Drawing.Size(199, 26); - // - // startNumberingFromToolStripMenuItem - // - this.startNumberingFromToolStripMenuItem.Name = "startNumberingFromToolStripMenuItem"; - this.startNumberingFromToolStripMenuItem.Size = new System.Drawing.Size(198, 22); - this.startNumberingFromToolStripMenuItem.Text = "Start numbering from..."; - this.startNumberingFromToolStripMenuItem.Click += new System.EventHandler(this.startNumberingFromToolStripMenuItem_Click); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(963, 735); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 105; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(882, 735); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 104; - this.buttonOK.Text = "&Next >"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // SubtitleListview1 - // - this.SubtitleListview1.AllowColumnReorder = true; - this.SubtitleListview1.AllowDrop = true; - this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.SubtitleListview1.ContextMenuStrip = this.contextMenuStripPreview; - this.SubtitleListview1.FirstVisibleIndex = -1; - this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.SubtitleListview1.FullRowSelect = true; - this.SubtitleListview1.GridLines = true; - this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.SubtitleListview1.HideSelection = false; - this.SubtitleListview1.Location = new System.Drawing.Point(6, 20); - this.SubtitleListview1.MultiSelect = false; - this.SubtitleListview1.Name = "SubtitleListview1"; - this.SubtitleListview1.OwnerDraw = true; - this.SubtitleListview1.Size = new System.Drawing.Size(1020, 257); - this.SubtitleListview1.SubtitleFontBold = false; - this.SubtitleListview1.SubtitleFontName = "Tahoma"; - this.SubtitleListview1.SubtitleFontSize = 8; - this.SubtitleListview1.TabIndex = 0; - this.SubtitleListview1.UseCompatibleStateImageBehavior = false; - this.SubtitleListview1.UseSyntaxColoring = true; - this.SubtitleListview1.View = System.Windows.Forms.View.Details; - // - // labelStatus - // - this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelStatus.AutoSize = true; - this.labelStatus.Location = new System.Drawing.Point(12, 734); - this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(35, 13); - this.labelStatus.TabIndex = 106; - this.labelStatus.Text = "label1"; - // - // ImportText - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1056, 772); - this.Controls.Add(this.labelStatus); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonRefresh); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.groupBoxImportResult); - this.Controls.Add(this.groupBoxImportOptions); - this.Controls.Add(this.groupBoxImportText); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MinimumSize = new System.Drawing.Size(810, 648); - this.Name = "ImportText"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Import text"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ImportText_FormClosing); - this.Shown += new System.EventHandler(this.ImportText_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ImportTextKeyDown); - this.groupBoxImportText.ResumeLayout(false); - this.groupBoxImportText.PerformLayout(); - this.contextMenuStripListView.ResumeLayout(false); - this.groupBoxImportOptions.ResumeLayout(false); - this.groupBoxImportOptions.PerformLayout(); - this.groupBoxAutoSplitSettings.ResumeLayout(false); - this.groupBoxAutoSplitSettings.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSubtitleLineMaximumLength)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAutoSplitMaxLines)).EndInit(); - this.groupBoxTimeCodes.ResumeLayout(false); - this.groupBoxTimeCodes.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownGapBetweenLines)).EndInit(); - this.groupBoxDuration.ResumeLayout(false); - this.groupBoxDuration.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationFixed)).EndInit(); - this.groupBoxSplitting.ResumeLayout(false); - this.groupBoxSplitting.PerformLayout(); - this.groupBoxImportResult.ResumeLayout(false); - this.contextMenuStripPreview.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOpenText; - private Controls.SubtitleListView SubtitleListview1; - private System.Windows.Forms.GroupBox groupBoxImportText; - private System.Windows.Forms.TextBox textBoxText; - private System.Windows.Forms.GroupBox groupBoxImportOptions; - private System.Windows.Forms.GroupBox groupBoxImportResult; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.GroupBox groupBoxSplitting; - private System.Windows.Forms.RadioButton radioButtonAutoSplit; - private System.Windows.Forms.RadioButton radioButtonLineMode; - private System.Windows.Forms.CheckBox checkBoxRemoveEmptyLines; - private System.Windows.Forms.CheckBox checkBoxRemoveLinesWithoutLetters; - private System.Windows.Forms.NumericUpDown numericUpDownGapBetweenLines; - private System.Windows.Forms.Label labelGapBetweenSubtitles; - private System.Windows.Forms.Button buttonRefresh; - private System.Windows.Forms.GroupBox groupBoxDuration; - private System.Windows.Forms.NumericUpDown numericUpDownDurationFixed; - private System.Windows.Forms.RadioButton radioButtonDurationFixed; - private System.Windows.Forms.RadioButton radioButtonDurationAuto; - private System.Windows.Forms.CheckBox checkBoxMergeShortLines; - private System.Windows.Forms.RadioButton radioButtonSplitAtBlankLines; - private System.Windows.Forms.CheckBox checkBoxGenerateTimeCodes; - private System.Windows.Forms.GroupBox groupBoxTimeCodes; - private System.Windows.Forms.Label labelLineBreak; - private System.Windows.Forms.CheckBox checkBoxMultipleFiles; - private System.Windows.Forms.ListView listViewInputFiles; - private System.Windows.Forms.ColumnHeader columnHeaderFName; - private System.Windows.Forms.ColumnHeader columnHeaderSize; - private System.Windows.Forms.CheckBox checkBoxAutoBreak; - private System.Windows.Forms.ComboBox comboBoxLineBreak; - private System.Windows.Forms.ContextMenuStrip contextMenuStripListView; - private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem; - private System.Windows.Forms.ContextMenuStrip contextMenuStripPreview; - private System.Windows.Forms.ToolStripMenuItem startNumberingFromToolStripMenuItem; - private System.Windows.Forms.GroupBox groupBoxAutoSplitSettings; - private System.Windows.Forms.TextBox textBoxAsEnd; - private System.Windows.Forms.CheckBox checkBoxAutoSplitRemoveLinesNoLetters; - private System.Windows.Forms.CheckBox checkBoxAutoSplitAtBlankLines; - private System.Windows.Forms.NumericUpDown numericUpDownAutoSplitMaxLines; - private System.Windows.Forms.Label labelAutoSplitNumberOfLines; - private System.Windows.Forms.Label labelSubMaxLen; - private System.Windows.Forms.NumericUpDown numericUpDownSubtitleLineMaximumLength; - private System.Windows.Forms.CheckBox checkBoxAutoSplitAtEnd; - private System.Windows.Forms.ComboBox comboBoxLineMode; - private System.Windows.Forms.CheckBox checkBoxTakeTimeFromFileNames; - private System.Windows.Forms.Label labelStatus; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class ImportText + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonOpenText = new System.Windows.Forms.Button(); + this.groupBoxImportText = new System.Windows.Forms.GroupBox(); + this.checkBoxMultipleFiles = new System.Windows.Forms.CheckBox(); + this.listViewInputFiles = new System.Windows.Forms.ListView(); + this.columnHeaderFName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contextMenuStripListView = new System.Windows.Forms.ContextMenuStrip(this.components); + this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.textBoxText = new System.Windows.Forms.TextBox(); + this.groupBoxImportOptions = new System.Windows.Forms.GroupBox(); + this.checkBoxTakeTimeFromFileNames = new System.Windows.Forms.CheckBox(); + this.groupBoxAutoSplitSettings = new System.Windows.Forms.GroupBox(); + this.checkBoxAutoSplitAtEnd = new System.Windows.Forms.CheckBox(); + this.labelSubMaxLen = new System.Windows.Forms.Label(); + this.numericUpDownSubtitleLineMaximumLength = new System.Windows.Forms.NumericUpDown(); + this.textBoxAsEnd = new System.Windows.Forms.TextBox(); + this.checkBoxAutoSplitRemoveLinesNoLetters = new System.Windows.Forms.CheckBox(); + this.checkBoxAutoSplitAtBlankLines = new System.Windows.Forms.CheckBox(); + this.numericUpDownAutoSplitMaxLines = new System.Windows.Forms.NumericUpDown(); + this.labelAutoSplitNumberOfLines = new System.Windows.Forms.Label(); + this.checkBoxAutoBreak = new System.Windows.Forms.CheckBox(); + this.checkBoxGenerateTimeCodes = new System.Windows.Forms.CheckBox(); + this.groupBoxTimeCodes = new System.Windows.Forms.GroupBox(); + this.labelGapBetweenSubtitles = new System.Windows.Forms.Label(); + this.numericUpDownGapBetweenLines = new System.Windows.Forms.NumericUpDown(); + this.groupBoxDuration = new System.Windows.Forms.GroupBox(); + this.numericUpDownDurationFixed = new System.Windows.Forms.NumericUpDown(); + this.radioButtonDurationFixed = new System.Windows.Forms.RadioButton(); + this.radioButtonDurationAuto = new System.Windows.Forms.RadioButton(); + this.checkBoxMergeShortLines = new System.Windows.Forms.CheckBox(); + this.checkBoxRemoveLinesWithoutLetters = new System.Windows.Forms.CheckBox(); + this.groupBoxSplitting = new System.Windows.Forms.GroupBox(); + this.comboBoxLineMode = new System.Windows.Forms.ComboBox(); + this.comboBoxLineBreak = new System.Windows.Forms.ComboBox(); + this.labelLineBreak = new System.Windows.Forms.Label(); + this.radioButtonSplitAtBlankLines = new System.Windows.Forms.RadioButton(); + this.radioButtonAutoSplit = new System.Windows.Forms.RadioButton(); + this.radioButtonLineMode = new System.Windows.Forms.RadioButton(); + this.checkBoxRemoveEmptyLines = new System.Windows.Forms.CheckBox(); + this.buttonRefresh = new System.Windows.Forms.Button(); + this.groupBoxImportResult = new System.Windows.Forms.GroupBox(); + this.contextMenuStripPreview = new System.Windows.Forms.ContextMenuStrip(this.components); + this.startNumberingFromToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.labelStatus = new System.Windows.Forms.Label(); + this.groupBoxImportText.SuspendLayout(); + this.contextMenuStripListView.SuspendLayout(); + this.groupBoxImportOptions.SuspendLayout(); + this.groupBoxAutoSplitSettings.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSubtitleLineMaximumLength)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAutoSplitMaxLines)).BeginInit(); + this.groupBoxTimeCodes.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownGapBetweenLines)).BeginInit(); + this.groupBoxDuration.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationFixed)).BeginInit(); + this.groupBoxSplitting.SuspendLayout(); + this.groupBoxImportResult.SuspendLayout(); + this.contextMenuStripPreview.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOpenText + // + this.buttonOpenText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOpenText.Location = new System.Drawing.Point(475, 19); + this.buttonOpenText.Name = "buttonOpenText"; + this.buttonOpenText.Size = new System.Drawing.Size(143, 23); + this.buttonOpenText.TabIndex = 4; + this.buttonOpenText.Text = "Open file..."; + this.buttonOpenText.UseVisualStyleBackColor = true; + this.buttonOpenText.Click += new System.EventHandler(this.ButtonOpenTextClick); + // + // groupBoxImportText + // + this.groupBoxImportText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImportText.Controls.Add(this.checkBoxMultipleFiles); + this.groupBoxImportText.Controls.Add(this.buttonOpenText); + this.groupBoxImportText.Controls.Add(this.textBoxText); + this.groupBoxImportText.Controls.Add(this.listViewInputFiles); + this.groupBoxImportText.Location = new System.Drawing.Point(12, 12); + this.groupBoxImportText.Name = "groupBoxImportText"; + this.groupBoxImportText.Size = new System.Drawing.Size(624, 410); + this.groupBoxImportText.TabIndex = 0; + this.groupBoxImportText.TabStop = false; + this.groupBoxImportText.Text = "Import text"; + // + // checkBoxMultipleFiles + // + this.checkBoxMultipleFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.checkBoxMultipleFiles.AutoSize = true; + this.checkBoxMultipleFiles.Location = new System.Drawing.Point(271, 22); + this.checkBoxMultipleFiles.Name = "checkBoxMultipleFiles"; + this.checkBoxMultipleFiles.Size = new System.Drawing.Size(198, 17); + this.checkBoxMultipleFiles.TabIndex = 2; + this.checkBoxMultipleFiles.Text = "Multiple files - one file is one subtitle"; + this.checkBoxMultipleFiles.UseVisualStyleBackColor = true; + this.checkBoxMultipleFiles.CheckedChanged += new System.EventHandler(this.checkBoxMultipleFiles_CheckedChanged); + // + // listViewInputFiles + // + this.listViewInputFiles.AllowDrop = true; + this.listViewInputFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewInputFiles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderFName, + this.columnHeaderSize}); + this.listViewInputFiles.ContextMenuStrip = this.contextMenuStripListView; + this.listViewInputFiles.FullRowSelect = true; + this.listViewInputFiles.HideSelection = false; + this.listViewInputFiles.Location = new System.Drawing.Point(6, 48); + this.listViewInputFiles.Name = "listViewInputFiles"; + this.listViewInputFiles.Size = new System.Drawing.Size(612, 356); + this.listViewInputFiles.TabIndex = 6; + this.listViewInputFiles.UseCompatibleStateImageBehavior = false; + this.listViewInputFiles.View = System.Windows.Forms.View.Details; + this.listViewInputFiles.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewInputFiles_DragDrop); + this.listViewInputFiles.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewInputFiles_DragEnter); + // + // columnHeaderFName + // + this.columnHeaderFName.Text = "File name"; + this.columnHeaderFName.Width = 420; + // + // columnHeaderSize + // + this.columnHeaderSize.Text = "Size"; + this.columnHeaderSize.Width = 81; + // + // contextMenuStripListView + // + this.contextMenuStripListView.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.clearToolStripMenuItem}); + this.contextMenuStripListView.Name = "contextMenuStripListView"; + this.contextMenuStripListView.Size = new System.Drawing.Size(102, 26); + // + // clearToolStripMenuItem + // + this.clearToolStripMenuItem.Name = "clearToolStripMenuItem"; + this.clearToolStripMenuItem.Size = new System.Drawing.Size(101, 22); + this.clearToolStripMenuItem.Text = "Clear"; + this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click); + // + // textBoxText + // + this.textBoxText.AllowDrop = true; + this.textBoxText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxText.Location = new System.Drawing.Point(6, 48); + this.textBoxText.MaxLength = 0; + this.textBoxText.Multiline = true; + this.textBoxText.Name = "textBoxText"; + this.textBoxText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxText.Size = new System.Drawing.Size(612, 356); + this.textBoxText.TabIndex = 1; + this.textBoxText.TextChanged += new System.EventHandler(this.TextBoxTextTextChanged); + this.textBoxText.DragDrop += new System.Windows.Forms.DragEventHandler(this.TextBoxTextDragDrop); + this.textBoxText.DragEnter += new System.Windows.Forms.DragEventHandler(this.TextBoxTextDragEnter); + // + // groupBoxImportOptions + // + this.groupBoxImportOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImportOptions.Controls.Add(this.checkBoxTakeTimeFromFileNames); + this.groupBoxImportOptions.Controls.Add(this.groupBoxAutoSplitSettings); + this.groupBoxImportOptions.Controls.Add(this.checkBoxAutoBreak); + this.groupBoxImportOptions.Controls.Add(this.checkBoxGenerateTimeCodes); + this.groupBoxImportOptions.Controls.Add(this.groupBoxTimeCodes); + this.groupBoxImportOptions.Controls.Add(this.checkBoxMergeShortLines); + this.groupBoxImportOptions.Controls.Add(this.checkBoxRemoveLinesWithoutLetters); + this.groupBoxImportOptions.Controls.Add(this.groupBoxSplitting); + this.groupBoxImportOptions.Controls.Add(this.checkBoxRemoveEmptyLines); + this.groupBoxImportOptions.Location = new System.Drawing.Point(642, 12); + this.groupBoxImportOptions.Name = "groupBoxImportOptions"; + this.groupBoxImportOptions.Size = new System.Drawing.Size(402, 410); + this.groupBoxImportOptions.TabIndex = 1; + this.groupBoxImportOptions.TabStop = false; + this.groupBoxImportOptions.Text = "Import options"; + // + // checkBoxTakeTimeFromFileNames + // + this.checkBoxTakeTimeFromFileNames.AutoSize = true; + this.checkBoxTakeTimeFromFileNames.Location = new System.Drawing.Point(157, 250); + this.checkBoxTakeTimeFromFileNames.Name = "checkBoxTakeTimeFromFileNames"; + this.checkBoxTakeTimeFromFileNames.Size = new System.Drawing.Size(143, 17); + this.checkBoxTakeTimeFromFileNames.TabIndex = 5; + this.checkBoxTakeTimeFromFileNames.Text = "Take time from file name"; + this.checkBoxTakeTimeFromFileNames.UseVisualStyleBackColor = true; + // + // groupBoxAutoSplitSettings + // + this.groupBoxAutoSplitSettings.Controls.Add(this.checkBoxAutoSplitAtEnd); + this.groupBoxAutoSplitSettings.Controls.Add(this.labelSubMaxLen); + this.groupBoxAutoSplitSettings.Controls.Add(this.numericUpDownSubtitleLineMaximumLength); + this.groupBoxAutoSplitSettings.Controls.Add(this.textBoxAsEnd); + this.groupBoxAutoSplitSettings.Controls.Add(this.checkBoxAutoSplitRemoveLinesNoLetters); + this.groupBoxAutoSplitSettings.Controls.Add(this.checkBoxAutoSplitAtBlankLines); + this.groupBoxAutoSplitSettings.Controls.Add(this.numericUpDownAutoSplitMaxLines); + this.groupBoxAutoSplitSettings.Controls.Add(this.labelAutoSplitNumberOfLines); + this.groupBoxAutoSplitSettings.Location = new System.Drawing.Point(6, 91); + this.groupBoxAutoSplitSettings.Name = "groupBoxAutoSplitSettings"; + this.groupBoxAutoSplitSettings.Size = new System.Drawing.Size(390, 153); + this.groupBoxAutoSplitSettings.TabIndex = 1; + this.groupBoxAutoSplitSettings.TabStop = false; + this.groupBoxAutoSplitSettings.Text = "Auto split text settings"; + // + // checkBoxAutoSplitAtEnd + // + this.checkBoxAutoSplitAtEnd.AutoSize = true; + this.checkBoxAutoSplitAtEnd.Checked = true; + this.checkBoxAutoSplitAtEnd.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxAutoSplitAtEnd.Location = new System.Drawing.Point(6, 119); + this.checkBoxAutoSplitAtEnd.Name = "checkBoxAutoSplitAtEnd"; + this.checkBoxAutoSplitAtEnd.Size = new System.Drawing.Size(109, 17); + this.checkBoxAutoSplitAtEnd.TabIndex = 50; + this.checkBoxAutoSplitAtEnd.Text = "Split at end chars"; + this.checkBoxAutoSplitAtEnd.UseVisualStyleBackColor = true; + this.checkBoxAutoSplitAtEnd.CheckedChanged += new System.EventHandler(this.checkBoxAutoSplitAtEnd_CheckedChanged); + // + // labelSubMaxLen + // + this.labelSubMaxLen.AutoSize = true; + this.labelSubMaxLen.Location = new System.Drawing.Point(6, 47); + this.labelSubMaxLen.Name = "labelSubMaxLen"; + this.labelSubMaxLen.Size = new System.Drawing.Size(103, 13); + this.labelSubMaxLen.TabIndex = 17; + this.labelSubMaxLen.Text = "Subtitle max. length"; + // + // numericUpDownSubtitleLineMaximumLength + // + this.numericUpDownSubtitleLineMaximumLength.Location = new System.Drawing.Point(112, 44); + this.numericUpDownSubtitleLineMaximumLength.Maximum = new decimal(new int[] { + 999, + 0, + 0, + 0}); + this.numericUpDownSubtitleLineMaximumLength.Minimum = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDownSubtitleLineMaximumLength.Name = "numericUpDownSubtitleLineMaximumLength"; + this.numericUpDownSubtitleLineMaximumLength.Size = new System.Drawing.Size(49, 21); + this.numericUpDownSubtitleLineMaximumLength.TabIndex = 20; + this.numericUpDownSubtitleLineMaximumLength.Value = new decimal(new int[] { + 43, + 0, + 0, + 0}); + this.numericUpDownSubtitleLineMaximumLength.ValueChanged += new System.EventHandler(this.numericUpDownSubtitleLineMaximumLength_ValueChanged); + // + // textBoxAsEnd + // + this.textBoxAsEnd.Location = new System.Drawing.Point(118, 117); + this.textBoxAsEnd.MaxLength = 5; + this.textBoxAsEnd.Name = "textBoxAsEnd"; + this.textBoxAsEnd.Size = new System.Drawing.Size(50, 21); + this.textBoxAsEnd.TabIndex = 51; + this.textBoxAsEnd.TextChanged += new System.EventHandler(this.textBoxAsEnd1_TextChanged); + this.textBoxAsEnd.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBoxAsEnd1_KeyPress); + // + // checkBoxAutoSplitRemoveLinesNoLetters + // + this.checkBoxAutoSplitRemoveLinesNoLetters.AutoSize = true; + this.checkBoxAutoSplitRemoveLinesNoLetters.Checked = true; + this.checkBoxAutoSplitRemoveLinesNoLetters.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxAutoSplitRemoveLinesNoLetters.Location = new System.Drawing.Point(6, 96); + this.checkBoxAutoSplitRemoveLinesNoLetters.Name = "checkBoxAutoSplitRemoveLinesNoLetters"; + this.checkBoxAutoSplitRemoveLinesNoLetters.Size = new System.Drawing.Size(162, 17); + this.checkBoxAutoSplitRemoveLinesNoLetters.TabIndex = 40; + this.checkBoxAutoSplitRemoveLinesNoLetters.Text = "Remove lines without letters"; + this.checkBoxAutoSplitRemoveLinesNoLetters.UseVisualStyleBackColor = true; + this.checkBoxAutoSplitRemoveLinesNoLetters.CheckedChanged += new System.EventHandler(this.checkBoxAutoSplitRemoveLinesNoLetters_CheckedChanged); + // + // checkBoxAutoSplitAtBlankLines + // + this.checkBoxAutoSplitAtBlankLines.AutoSize = true; + this.checkBoxAutoSplitAtBlankLines.Checked = true; + this.checkBoxAutoSplitAtBlankLines.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxAutoSplitAtBlankLines.Location = new System.Drawing.Point(6, 73); + this.checkBoxAutoSplitAtBlankLines.Name = "checkBoxAutoSplitAtBlankLines"; + this.checkBoxAutoSplitAtBlankLines.Size = new System.Drawing.Size(111, 17); + this.checkBoxAutoSplitAtBlankLines.TabIndex = 30; + this.checkBoxAutoSplitAtBlankLines.Text = "Split at blank lines"; + this.checkBoxAutoSplitAtBlankLines.UseVisualStyleBackColor = true; + this.checkBoxAutoSplitAtBlankLines.CheckedChanged += new System.EventHandler(this.checkBoxAutoSplitAtBlankLines_CheckedChanged); + // + // numericUpDownAutoSplitMaxLines + // + this.numericUpDownAutoSplitMaxLines.Location = new System.Drawing.Point(115, 17); + this.numericUpDownAutoSplitMaxLines.Maximum = new decimal(new int[] { + 2, + 0, + 0, + 0}); + this.numericUpDownAutoSplitMaxLines.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numericUpDownAutoSplitMaxLines.Name = "numericUpDownAutoSplitMaxLines"; + this.numericUpDownAutoSplitMaxLines.Size = new System.Drawing.Size(46, 21); + this.numericUpDownAutoSplitMaxLines.TabIndex = 10; + this.numericUpDownAutoSplitMaxLines.Value = new decimal(new int[] { + 2, + 0, + 0, + 0}); + this.numericUpDownAutoSplitMaxLines.ValueChanged += new System.EventHandler(this.numericUpDownAutoSplitMaxLines_ValueChanged); + // + // labelAutoSplitNumberOfLines + // + this.labelAutoSplitNumberOfLines.AutoSize = true; + this.labelAutoSplitNumberOfLines.Location = new System.Drawing.Point(6, 19); + this.labelAutoSplitNumberOfLines.Name = "labelAutoSplitNumberOfLines"; + this.labelAutoSplitNumberOfLines.Size = new System.Drawing.Size(103, 13); + this.labelAutoSplitNumberOfLines.TabIndex = 6; + this.labelAutoSplitNumberOfLines.Text = "Max number of lines"; + // + // checkBoxAutoBreak + // + this.checkBoxAutoBreak.AutoSize = true; + this.checkBoxAutoBreak.Location = new System.Drawing.Point(19, 163); + this.checkBoxAutoBreak.Name = "checkBoxAutoBreak"; + this.checkBoxAutoBreak.Size = new System.Drawing.Size(104, 17); + this.checkBoxAutoBreak.TabIndex = 7; + this.checkBoxAutoBreak.Text = "Auto-break lines"; + this.checkBoxAutoBreak.UseVisualStyleBackColor = true; + this.checkBoxAutoBreak.CheckedChanged += new System.EventHandler(this.checkBoxAutoBreak_CheckedChanged); + // + // checkBoxGenerateTimeCodes + // + this.checkBoxGenerateTimeCodes.AutoSize = true; + this.checkBoxGenerateTimeCodes.Location = new System.Drawing.Point(16, 250); + this.checkBoxGenerateTimeCodes.Name = "checkBoxGenerateTimeCodes"; + this.checkBoxGenerateTimeCodes.Size = new System.Drawing.Size(125, 17); + this.checkBoxGenerateTimeCodes.TabIndex = 4; + this.checkBoxGenerateTimeCodes.Text = "Generate time codes"; + this.checkBoxGenerateTimeCodes.UseVisualStyleBackColor = true; + this.checkBoxGenerateTimeCodes.CheckedChanged += new System.EventHandler(this.checkBoxGenerateTimeCodes_CheckedChanged); + // + // groupBoxTimeCodes + // + this.groupBoxTimeCodes.Controls.Add(this.labelGapBetweenSubtitles); + this.groupBoxTimeCodes.Controls.Add(this.numericUpDownGapBetweenLines); + this.groupBoxTimeCodes.Controls.Add(this.groupBoxDuration); + this.groupBoxTimeCodes.Enabled = false; + this.groupBoxTimeCodes.Location = new System.Drawing.Point(6, 273); + this.groupBoxTimeCodes.Name = "groupBoxTimeCodes"; + this.groupBoxTimeCodes.Size = new System.Drawing.Size(390, 126); + this.groupBoxTimeCodes.TabIndex = 6; + this.groupBoxTimeCodes.TabStop = false; + this.groupBoxTimeCodes.Text = "Time codes"; + // + // labelGapBetweenSubtitles + // + this.labelGapBetweenSubtitles.AutoSize = true; + this.labelGapBetweenSubtitles.Location = new System.Drawing.Point(6, 23); + this.labelGapBetweenSubtitles.Name = "labelGapBetweenSubtitles"; + this.labelGapBetweenSubtitles.Size = new System.Drawing.Size(180, 13); + this.labelGapBetweenSubtitles.TabIndex = 0; + this.labelGapBetweenSubtitles.Text = "Gap between subtitles (milliseconds)"; + // + // numericUpDownGapBetweenLines + // + this.numericUpDownGapBetweenLines.Location = new System.Drawing.Point(192, 20); + this.numericUpDownGapBetweenLines.Maximum = new decimal(new int[] { + 100000, + 0, + 0, + 0}); + this.numericUpDownGapBetweenLines.Name = "numericUpDownGapBetweenLines"; + this.numericUpDownGapBetweenLines.Size = new System.Drawing.Size(64, 21); + this.numericUpDownGapBetweenLines.TabIndex = 1; + this.numericUpDownGapBetweenLines.Value = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownGapBetweenLines.ValueChanged += new System.EventHandler(this.NumericUpDownGapBetweenLinesValueChanged); + // + // groupBoxDuration + // + this.groupBoxDuration.Controls.Add(this.numericUpDownDurationFixed); + this.groupBoxDuration.Controls.Add(this.radioButtonDurationFixed); + this.groupBoxDuration.Controls.Add(this.radioButtonDurationAuto); + this.groupBoxDuration.Location = new System.Drawing.Point(9, 47); + this.groupBoxDuration.Name = "groupBoxDuration"; + this.groupBoxDuration.Size = new System.Drawing.Size(247, 70); + this.groupBoxDuration.TabIndex = 2; + this.groupBoxDuration.TabStop = false; + this.groupBoxDuration.Text = "Duration"; + // + // numericUpDownDurationFixed + // + this.numericUpDownDurationFixed.Location = new System.Drawing.Point(111, 42); + this.numericUpDownDurationFixed.Maximum = new decimal(new int[] { + 100000, + 0, + 0, + 0}); + this.numericUpDownDurationFixed.Name = "numericUpDownDurationFixed"; + this.numericUpDownDurationFixed.Size = new System.Drawing.Size(64, 21); + this.numericUpDownDurationFixed.TabIndex = 2; + this.numericUpDownDurationFixed.Value = new decimal(new int[] { + 2000, + 0, + 0, + 0}); + this.numericUpDownDurationFixed.ValueChanged += new System.EventHandler(this.NumericUpDownDurationFixedValueChanged); + // + // radioButtonDurationFixed + // + this.radioButtonDurationFixed.AutoSize = true; + this.radioButtonDurationFixed.Location = new System.Drawing.Point(16, 42); + this.radioButtonDurationFixed.Name = "radioButtonDurationFixed"; + this.radioButtonDurationFixed.Size = new System.Drawing.Size(51, 17); + this.radioButtonDurationFixed.TabIndex = 1; + this.radioButtonDurationFixed.Text = "Fixed"; + this.radioButtonDurationFixed.UseVisualStyleBackColor = true; + this.radioButtonDurationFixed.CheckedChanged += new System.EventHandler(this.RadioButtonDurationFixedCheckedChanged); + // + // radioButtonDurationAuto + // + this.radioButtonDurationAuto.AutoSize = true; + this.radioButtonDurationAuto.Checked = true; + this.radioButtonDurationAuto.Location = new System.Drawing.Point(16, 19); + this.radioButtonDurationAuto.Name = "radioButtonDurationAuto"; + this.radioButtonDurationAuto.Size = new System.Drawing.Size(48, 17); + this.radioButtonDurationAuto.TabIndex = 0; + this.radioButtonDurationAuto.TabStop = true; + this.radioButtonDurationAuto.Text = "Auto"; + this.radioButtonDurationAuto.UseVisualStyleBackColor = true; + this.radioButtonDurationAuto.CheckedChanged += new System.EventHandler(this.RadioButtonDurationAutoCheckedChanged); + // + // checkBoxMergeShortLines + // + this.checkBoxMergeShortLines.AutoSize = true; + this.checkBoxMergeShortLines.Checked = true; + this.checkBoxMergeShortLines.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxMergeShortLines.Location = new System.Drawing.Point(19, 94); + this.checkBoxMergeShortLines.Name = "checkBoxMergeShortLines"; + this.checkBoxMergeShortLines.Size = new System.Drawing.Size(193, 17); + this.checkBoxMergeShortLines.TabIndex = 1; + this.checkBoxMergeShortLines.Text = "Merge short lines with continuation"; + this.checkBoxMergeShortLines.UseVisualStyleBackColor = true; + this.checkBoxMergeShortLines.CheckedChanged += new System.EventHandler(this.CheckBoxMergeShortLinesCheckedChanged); + // + // checkBoxRemoveLinesWithoutLetters + // + this.checkBoxRemoveLinesWithoutLetters.AutoSize = true; + this.checkBoxRemoveLinesWithoutLetters.Checked = true; + this.checkBoxRemoveLinesWithoutLetters.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxRemoveLinesWithoutLetters.Location = new System.Drawing.Point(19, 140); + this.checkBoxRemoveLinesWithoutLetters.Name = "checkBoxRemoveLinesWithoutLetters"; + this.checkBoxRemoveLinesWithoutLetters.Size = new System.Drawing.Size(162, 17); + this.checkBoxRemoveLinesWithoutLetters.TabIndex = 3; + this.checkBoxRemoveLinesWithoutLetters.Text = "Remove lines without letters"; + this.checkBoxRemoveLinesWithoutLetters.UseVisualStyleBackColor = true; + this.checkBoxRemoveLinesWithoutLetters.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveLinesWithoutLettersOrNumbersCheckedChanged); + // + // groupBoxSplitting + // + this.groupBoxSplitting.Controls.Add(this.comboBoxLineMode); + this.groupBoxSplitting.Controls.Add(this.comboBoxLineBreak); + this.groupBoxSplitting.Controls.Add(this.labelLineBreak); + this.groupBoxSplitting.Controls.Add(this.radioButtonSplitAtBlankLines); + this.groupBoxSplitting.Controls.Add(this.radioButtonAutoSplit); + this.groupBoxSplitting.Controls.Add(this.radioButtonLineMode); + this.groupBoxSplitting.Location = new System.Drawing.Point(6, 17); + this.groupBoxSplitting.Name = "groupBoxSplitting"; + this.groupBoxSplitting.Size = new System.Drawing.Size(390, 68); + this.groupBoxSplitting.TabIndex = 0; + this.groupBoxSplitting.TabStop = false; + this.groupBoxSplitting.Text = "Splitting"; + // + // comboBoxLineMode + // + this.comboBoxLineMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxLineMode.FormattingEnabled = true; + this.comboBoxLineMode.Items.AddRange(new object[] { + "One line is a subtitle", + "Two lines is a subtitle"}); + this.comboBoxLineMode.Location = new System.Drawing.Point(31, 41); + this.comboBoxLineMode.Name = "comboBoxLineMode"; + this.comboBoxLineMode.Size = new System.Drawing.Size(144, 21); + this.comboBoxLineMode.TabIndex = 2; + this.comboBoxLineMode.SelectedIndexChanged += new System.EventHandler(this.comboBoxLineMode_SelectedIndexChanged); + // + // comboBoxLineBreak + // + this.comboBoxLineBreak.FormattingEnabled = true; + this.comboBoxLineBreak.Items.AddRange(new object[] { + "|", + "\\N;\\n", + "|;\\N;\\n;//;
;
;
"}); + this.comboBoxLineBreak.Location = new System.Drawing.Point(246, 41); + this.comboBoxLineBreak.Name = "comboBoxLineBreak"; + this.comboBoxLineBreak.Size = new System.Drawing.Size(107, 21); + this.comboBoxLineBreak.TabIndex = 5; + this.comboBoxLineBreak.TextChanged += new System.EventHandler(this.comboBoxLineBreak_TextChanged); + // + // labelLineBreak + // + this.labelLineBreak.AutoSize = true; + this.labelLineBreak.Location = new System.Drawing.Point(184, 44); + this.labelLineBreak.Name = "labelLineBreak"; + this.labelLineBreak.Size = new System.Drawing.Size(56, 13); + this.labelLineBreak.TabIndex = 4; + this.labelLineBreak.Text = "Line break"; + // + // radioButtonSplitAtBlankLines + // + this.radioButtonSplitAtBlankLines.AutoSize = true; + this.radioButtonSplitAtBlankLines.Location = new System.Drawing.Point(183, 19); + this.radioButtonSplitAtBlankLines.Name = "radioButtonSplitAtBlankLines"; + this.radioButtonSplitAtBlankLines.Size = new System.Drawing.Size(110, 17); + this.radioButtonSplitAtBlankLines.TabIndex = 3; + this.radioButtonSplitAtBlankLines.Text = "Split at blank lines"; + this.radioButtonSplitAtBlankLines.UseVisualStyleBackColor = true; + this.radioButtonSplitAtBlankLines.CheckedChanged += new System.EventHandler(this.radioButtonSplitAtBlankLines_CheckedChanged); + // + // radioButtonAutoSplit + // + this.radioButtonAutoSplit.AutoSize = true; + this.radioButtonAutoSplit.Checked = true; + this.radioButtonAutoSplit.Location = new System.Drawing.Point(14, 19); + this.radioButtonAutoSplit.Name = "radioButtonAutoSplit"; + this.radioButtonAutoSplit.Size = new System.Drawing.Size(93, 17); + this.radioButtonAutoSplit.TabIndex = 0; + this.radioButtonAutoSplit.TabStop = true; + this.radioButtonAutoSplit.Text = "Auto split text"; + this.radioButtonAutoSplit.UseVisualStyleBackColor = true; + this.radioButtonAutoSplit.CheckedChanged += new System.EventHandler(this.RadioButtonAutoSplitCheckedChanged); + // + // radioButtonLineMode + // + this.radioButtonLineMode.AutoSize = true; + this.radioButtonLineMode.Location = new System.Drawing.Point(14, 43); + this.radioButtonLineMode.Name = "radioButtonLineMode"; + this.radioButtonLineMode.Size = new System.Drawing.Size(133, 17); + this.radioButtonLineMode.TabIndex = 1; + this.radioButtonLineMode.Text = "One line is one subtitle"; + this.radioButtonLineMode.UseVisualStyleBackColor = true; + this.radioButtonLineMode.CheckedChanged += new System.EventHandler(this.RadioButtonLineModeCheckedChanged); + // + // checkBoxRemoveEmptyLines + // + this.checkBoxRemoveEmptyLines.AutoSize = true; + this.checkBoxRemoveEmptyLines.Checked = true; + this.checkBoxRemoveEmptyLines.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxRemoveEmptyLines.Location = new System.Drawing.Point(19, 117); + this.checkBoxRemoveEmptyLines.Name = "checkBoxRemoveEmptyLines"; + this.checkBoxRemoveEmptyLines.Size = new System.Drawing.Size(122, 17); + this.checkBoxRemoveEmptyLines.TabIndex = 2; + this.checkBoxRemoveEmptyLines.Text = "Remove empty lines"; + this.checkBoxRemoveEmptyLines.UseVisualStyleBackColor = true; + this.checkBoxRemoveEmptyLines.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveEmptyLinesCheckedChanged); + // + // buttonRefresh + // + this.buttonRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRefresh.Location = new System.Drawing.Point(774, 735); + this.buttonRefresh.Name = "buttonRefresh"; + this.buttonRefresh.Size = new System.Drawing.Size(102, 23); + this.buttonRefresh.TabIndex = 103; + this.buttonRefresh.Text = "Refresh"; + this.buttonRefresh.UseVisualStyleBackColor = true; + this.buttonRefresh.Click += new System.EventHandler(this.ButtonRefreshClick); + // + // groupBoxImportResult + // + this.groupBoxImportResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImportResult.Controls.Add(this.SubtitleListview1); + this.groupBoxImportResult.Location = new System.Drawing.Point(12, 428); + this.groupBoxImportResult.Name = "groupBoxImportResult"; + this.groupBoxImportResult.Size = new System.Drawing.Size(1032, 299); + this.groupBoxImportResult.TabIndex = 2; + this.groupBoxImportResult.TabStop = false; + this.groupBoxImportResult.Text = "Preview"; + // + // contextMenuStripPreview + // + this.contextMenuStripPreview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.startNumberingFromToolStripMenuItem}); + this.contextMenuStripPreview.Name = "contextMenuStripPreview"; + this.contextMenuStripPreview.Size = new System.Drawing.Size(199, 26); + // + // startNumberingFromToolStripMenuItem + // + this.startNumberingFromToolStripMenuItem.Name = "startNumberingFromToolStripMenuItem"; + this.startNumberingFromToolStripMenuItem.Size = new System.Drawing.Size(198, 22); + this.startNumberingFromToolStripMenuItem.Text = "Start numbering from..."; + this.startNumberingFromToolStripMenuItem.Click += new System.EventHandler(this.startNumberingFromToolStripMenuItem_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(963, 735); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 105; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(882, 735); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 104; + this.buttonOK.Text = "&Next >"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // SubtitleListview1 + // + this.SubtitleListview1.AllowColumnReorder = true; + this.SubtitleListview1.AllowDrop = true; + this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.SubtitleListview1.ContextMenuStrip = this.contextMenuStripPreview; + this.SubtitleListview1.FirstVisibleIndex = -1; + this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SubtitleListview1.FullRowSelect = true; + this.SubtitleListview1.GridLines = true; + this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.SubtitleListview1.HideSelection = false; + this.SubtitleListview1.Location = new System.Drawing.Point(6, 20); + this.SubtitleListview1.MultiSelect = false; + this.SubtitleListview1.Name = "SubtitleListview1"; + this.SubtitleListview1.OwnerDraw = true; + this.SubtitleListview1.Size = new System.Drawing.Size(1020, 257); + this.SubtitleListview1.SubtitleFontBold = false; + this.SubtitleListview1.SubtitleFontName = "Tahoma"; + this.SubtitleListview1.SubtitleFontSize = 8; + this.SubtitleListview1.TabIndex = 0; + this.SubtitleListview1.UseCompatibleStateImageBehavior = false; + this.SubtitleListview1.UseSyntaxColoring = true; + this.SubtitleListview1.View = System.Windows.Forms.View.Details; + // + // labelStatus + // + this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(12, 734); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(35, 13); + this.labelStatus.TabIndex = 106; + this.labelStatus.Text = "label1"; + // + // ImportText + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1056, 772); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonRefresh); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.groupBoxImportResult); + this.Controls.Add(this.groupBoxImportOptions); + this.Controls.Add(this.groupBoxImportText); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MinimumSize = new System.Drawing.Size(810, 648); + this.Name = "ImportText"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Import text"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ImportText_FormClosing); + this.Shown += new System.EventHandler(this.ImportText_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ImportTextKeyDown); + this.groupBoxImportText.ResumeLayout(false); + this.groupBoxImportText.PerformLayout(); + this.contextMenuStripListView.ResumeLayout(false); + this.groupBoxImportOptions.ResumeLayout(false); + this.groupBoxImportOptions.PerformLayout(); + this.groupBoxAutoSplitSettings.ResumeLayout(false); + this.groupBoxAutoSplitSettings.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSubtitleLineMaximumLength)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAutoSplitMaxLines)).EndInit(); + this.groupBoxTimeCodes.ResumeLayout(false); + this.groupBoxTimeCodes.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownGapBetweenLines)).EndInit(); + this.groupBoxDuration.ResumeLayout(false); + this.groupBoxDuration.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationFixed)).EndInit(); + this.groupBoxSplitting.ResumeLayout(false); + this.groupBoxSplitting.PerformLayout(); + this.groupBoxImportResult.ResumeLayout(false); + this.contextMenuStripPreview.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOpenText; + private Controls.SubtitleListView SubtitleListview1; + private System.Windows.Forms.GroupBox groupBoxImportText; + private System.Windows.Forms.TextBox textBoxText; + private System.Windows.Forms.GroupBox groupBoxImportOptions; + private System.Windows.Forms.GroupBox groupBoxImportResult; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.GroupBox groupBoxSplitting; + private System.Windows.Forms.RadioButton radioButtonAutoSplit; + private System.Windows.Forms.RadioButton radioButtonLineMode; + private System.Windows.Forms.CheckBox checkBoxRemoveEmptyLines; + private System.Windows.Forms.CheckBox checkBoxRemoveLinesWithoutLetters; + private System.Windows.Forms.NumericUpDown numericUpDownGapBetweenLines; + private System.Windows.Forms.Label labelGapBetweenSubtitles; + private System.Windows.Forms.Button buttonRefresh; + private System.Windows.Forms.GroupBox groupBoxDuration; + private System.Windows.Forms.NumericUpDown numericUpDownDurationFixed; + private System.Windows.Forms.RadioButton radioButtonDurationFixed; + private System.Windows.Forms.RadioButton radioButtonDurationAuto; + private System.Windows.Forms.CheckBox checkBoxMergeShortLines; + private System.Windows.Forms.RadioButton radioButtonSplitAtBlankLines; + private System.Windows.Forms.CheckBox checkBoxGenerateTimeCodes; + private System.Windows.Forms.GroupBox groupBoxTimeCodes; + private System.Windows.Forms.Label labelLineBreak; + private System.Windows.Forms.CheckBox checkBoxMultipleFiles; + private System.Windows.Forms.ListView listViewInputFiles; + private System.Windows.Forms.ColumnHeader columnHeaderFName; + private System.Windows.Forms.ColumnHeader columnHeaderSize; + private System.Windows.Forms.CheckBox checkBoxAutoBreak; + private System.Windows.Forms.ComboBox comboBoxLineBreak; + private System.Windows.Forms.ContextMenuStrip contextMenuStripListView; + private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip contextMenuStripPreview; + private System.Windows.Forms.ToolStripMenuItem startNumberingFromToolStripMenuItem; + private System.Windows.Forms.GroupBox groupBoxAutoSplitSettings; + private System.Windows.Forms.TextBox textBoxAsEnd; + private System.Windows.Forms.CheckBox checkBoxAutoSplitRemoveLinesNoLetters; + private System.Windows.Forms.CheckBox checkBoxAutoSplitAtBlankLines; + private System.Windows.Forms.NumericUpDown numericUpDownAutoSplitMaxLines; + private System.Windows.Forms.Label labelAutoSplitNumberOfLines; + private System.Windows.Forms.Label labelSubMaxLen; + private System.Windows.Forms.NumericUpDown numericUpDownSubtitleLineMaximumLength; + private System.Windows.Forms.CheckBox checkBoxAutoSplitAtEnd; + private System.Windows.Forms.ComboBox comboBoxLineMode; + private System.Windows.Forms.CheckBox checkBoxTakeTimeFromFileNames; + private System.Windows.Forms.Label labelStatus; + } } \ No newline at end of file diff --git a/src/Forms/ImportText.cs b/src/ui/Forms/ImportText.cs similarity index 97% rename from src/Forms/ImportText.cs rename to src/ui/Forms/ImportText.cs index c6f740200..9f5601565 100644 --- a/src/Forms/ImportText.cs +++ b/src/ui/Forms/ImportText.cs @@ -1,1400 +1,1400 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Text; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ImportText : Form - { - private Subtitle _subtitleInput; - private string _fileName; - private readonly Timer _refreshTimer = new Timer(); - private readonly bool _exit; - private int _startFromNumber = 1; - - public Subtitle FixedSubtitle { get; private set; } - public SubtitleFormat Format { get; set; } - public string VideoFileName { get; private set; } - - public ImportText(string fileName = null, Form parentForm = null) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.ImportText.Title; - groupBoxImportText.Text = Configuration.Settings.Language.ImportText.Title; - buttonOpenText.Text = Configuration.Settings.Language.ImportText.OpenTextFile; - groupBoxImportOptions.Text = Configuration.Settings.Language.ImportText.ImportOptions; - groupBoxSplitting.Text = Configuration.Settings.Language.ImportText.Splitting; - radioButtonAutoSplit.Text = Configuration.Settings.Language.ImportText.AutoSplitText; - radioButtonLineMode.Text = string.Empty; - comboBoxLineMode.Items.Clear(); - comboBoxLineMode.Items.Add(Configuration.Settings.Language.ImportText.OneLineIsOneSubtitle); - comboBoxLineMode.Items.Add(Configuration.Settings.Language.ImportText.TwoLinesAreOneSubtitle); - comboBoxLineMode.SelectedIndex = 0; - labelLineBreak.Text = Configuration.Settings.Language.ImportText.LineBreak; - columnHeaderFName.Text = Configuration.Settings.Language.JoinSubtitles.FileName; - columnHeaderSize.Text = Configuration.Settings.Language.General.Size; - comboBoxLineBreak.Left = labelLineBreak.Left + labelLineBreak.Width + 3; - comboBoxLineBreak.Width = groupBoxSplitting.Width - comboBoxLineBreak.Left - 5; - checkBoxMultipleFiles.AutoSize = true; - checkBoxMultipleFiles.Left = buttonOpenText.Left - checkBoxMultipleFiles.Width - 9; - checkBoxMultipleFiles.Text = Configuration.Settings.Language.ImportText.OneSubtitleIsOneFile; - listViewInputFiles.Visible = false; - labelSubMaxLen.Text = Configuration.Settings.Language.Settings.SubtitleLineMaximumLength; - numericUpDownSubtitleLineMaximumLength.Left = labelSubMaxLen.Left + labelSubMaxLen.Width + 3; - - radioButtonSplitAtBlankLines.Text = Configuration.Settings.Language.ImportText.SplitAtBlankLines; - checkBoxMergeShortLines.Text = Configuration.Settings.Language.ImportText.MergeShortLines; - checkBoxRemoveEmptyLines.Text = Configuration.Settings.Language.ImportText.RemoveEmptyLines; - checkBoxRemoveLinesWithoutLetters.Text = Configuration.Settings.Language.ImportText.RemoveLinesWithoutLetters; - checkBoxAutoSplitRemoveLinesNoLetters.Text = Configuration.Settings.Language.ImportText.RemoveLinesWithoutLetters; - checkBoxGenerateTimeCodes.Text = Configuration.Settings.Language.ImportText.GenerateTimeCodes; - checkBoxTakeTimeFromFileNames.Text = Configuration.Settings.Language.ImportText.TakeTimeFromFileName; - checkBoxTakeTimeFromFileNames.Left = checkBoxGenerateTimeCodes.Left + checkBoxGenerateTimeCodes.Width + 9; - checkBoxAutoBreak.Text = Configuration.Settings.Language.Settings.MainTextBoxAutoBreak; - labelGapBetweenSubtitles.Text = Configuration.Settings.Language.ImportText.GapBetweenSubtitles; - numericUpDownGapBetweenLines.Left = labelGapBetweenSubtitles.Left + labelGapBetweenSubtitles.Width + 3; - groupBoxDuration.Text = Configuration.Settings.Language.General.Duration; - radioButtonDurationAuto.Text = Configuration.Settings.Language.ImportText.Auto; - radioButtonDurationFixed.Text = Configuration.Settings.Language.ImportText.Fixed; - buttonRefresh.Text = Configuration.Settings.Language.ImportText.Refresh; - groupBoxTimeCodes.Text = Configuration.Settings.Language.ImportText.TimeCodes; - groupBoxImportResult.Text = Configuration.Settings.Language.General.Preview; - clearToolStripMenuItem.Text = Configuration.Settings.Language.DvdSubRip.Clear; - startNumberingFromToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.Tools.StartNumberingFrom; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - UiUtil.InitializeSubtitleFont(listViewInputFiles); - textBoxText.Font = new System.Drawing.Font(listViewInputFiles.Font.FontFamily, listViewInputFiles.Font.Size, listViewInputFiles.Font.Style); - SubtitleListview1.AutoSizeAllColumns(this); - checkBoxTakeTimeFromFileNames.Visible = false; - - if (string.IsNullOrEmpty(Configuration.Settings.Tools.ImportTextSplitting)) - { - radioButtonAutoSplit.Checked = true; - } - else if (Configuration.Settings.Tools.ImportTextSplitting.Equals("blank lines", StringComparison.OrdinalIgnoreCase)) - { - radioButtonSplitAtBlankLines.Checked = true; - } - else if (Configuration.Settings.Tools.ImportTextSplitting.Equals("line", StringComparison.OrdinalIgnoreCase)) - { - radioButtonLineMode.Checked = true; - } - - comboBoxLineBreak.Text = Configuration.Settings.Tools.ImportTextLineBreak; - checkBoxMergeShortLines.Checked = Configuration.Settings.Tools.ImportTextMergeShortLines; - checkBoxRemoveEmptyLines.Checked = Configuration.Settings.Tools.ImportTextRemoveEmptyLines; - checkBoxAutoSplitAtBlankLines.Checked = Configuration.Settings.Tools.ImportTextAutoSplitAtBlank; - checkBoxRemoveLinesWithoutLetters.Checked = Configuration.Settings.Tools.ImportTextRemoveLinesNoLetters; - checkBoxAutoSplitRemoveLinesNoLetters.Checked = Configuration.Settings.Tools.ImportTextRemoveLinesNoLetters; - checkBoxGenerateTimeCodes.Checked = Configuration.Settings.Tools.ImportTextGenerateTimeCodes; - checkBoxTakeTimeFromFileNames.Checked = Configuration.Settings.Tools.ImportTextTakeTimeCodeFromFileName; - checkBoxAutoBreak.Checked = Configuration.Settings.Tools.ImportTextAutoBreak; - textBoxAsEnd.Text = Configuration.Settings.Tools.ImportTextAutoBreakAtEndMarkerText.Replace(" ", string.Empty); - checkBoxAutoSplitAtEnd.Checked = Configuration.Settings.Tools.ImportTextAutoBreakAtEnd; - checkBoxAutoSplitAtEnd.Text = Configuration.Settings.Language.ImportText.SplitAtEndChars; - textBoxAsEnd.Left = checkBoxAutoSplitAtEnd.Left + checkBoxAutoSplitAtEnd.Width; - checkBoxAutoSplitAtBlankLines.Text = Configuration.Settings.Language.ImportText.SplitAtBlankLines; - - groupBoxAutoSplitSettings.Text = Configuration.Settings.Language.Settings.Title; - labelAutoSplitNumberOfLines.Text = Configuration.Settings.Language.Settings.MaximumLines; - numericUpDownSubtitleLineMaximumLength.Left = labelSubMaxLen.Left + labelSubMaxLen.Width + 3; - numericUpDownSubtitleLineMaximumLength.Value = Configuration.Settings.General.SubtitleLineMaximumLength; - - if (Configuration.Settings.Tools.ImportTextAutoSplitNumberOfLines >= numericUpDownAutoSplitMaxLines.Minimum && - Configuration.Settings.Tools.ImportTextAutoSplitNumberOfLines <= numericUpDownAutoSplitMaxLines.Maximum) - { - numericUpDownAutoSplitMaxLines.Value = Configuration.Settings.Tools.ImportTextAutoSplitNumberOfLines; - } - - if (Configuration.Settings.Tools.ImportTextGap >= numericUpDownGapBetweenLines.Minimum && Configuration.Settings.Tools.ImportTextGap <= numericUpDownGapBetweenLines.Maximum) - { - numericUpDownGapBetweenLines.Value = Configuration.Settings.Tools.ImportTextGap; - } - if (Configuration.Settings.Tools.ImportTextDurationAuto) - { - radioButtonDurationAuto.Checked = true; - } - else - { - radioButtonDurationFixed.Checked = true; - } - numericUpDownDurationFixed.Enabled = radioButtonDurationFixed.Checked; - if (Configuration.Settings.Tools.ImportTextFixedDuration >= numericUpDownDurationFixed.Minimum && - Configuration.Settings.Tools.ImportTextFixedDuration <= numericUpDownDurationFixed.Maximum) - { - numericUpDownDurationFixed.Value = Configuration.Settings.Tools.ImportTextFixedDuration; - } - UiUtil.FixLargeFonts(this, buttonOK); - _refreshTimer.Interval = 400; - _refreshTimer.Tick += RefreshTimerTick; - - if (fileName != null && File.Exists(fileName)) - { - if (!LoadSingleFile(fileName, parentForm)) - { - _exit = true; - } - } - } - - private void RefreshTimerTick(object sender, EventArgs e) - { - _refreshTimer.Stop(); - GeneratePreviewReal(); - } - - private void ButtonOpenTextClick(object sender, EventArgs e) - { - Text = Configuration.Settings.Language.ImportText.Title; - openFileDialog1.Title = buttonOpenText.Text; - if (checkBoxMultipleFiles.Visible && checkBoxMultipleFiles.Checked) - { - openFileDialog1.Filter = Configuration.Settings.Language.ImportText.TextFiles + "|*.txt;*.rtf|" + Configuration.Settings.Language.General.AllFiles + " |*.*"; - } - else - { - openFileDialog1.Filter = Configuration.Settings.Language.ImportText.TextFiles + "|*.txt;*.rtf;*.tx3g;*.astx;*" + new FinalDraftTemplate2().Extension + "|Adobe Story|*.astx|Final Draft Template|*" + new FinalDraftTemplate2().Extension + "|" + Configuration.Settings.Language.General.AllFiles + "|*.*"; - } - - openFileDialog1.FileName = string.Empty; - openFileDialog1.Multiselect = checkBoxMultipleFiles.Visible && checkBoxMultipleFiles.Checked; - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - groupBoxImportOptions.Visible = true; - _startFromNumber = 1; - if (checkBoxMultipleFiles.Visible && checkBoxMultipleFiles.Checked) - { - foreach (var fileName in openFileDialog1.FileNames) - { - AddInputFile(fileName); - } - } - else - { - LoadSingleFile(openFileDialog1.FileName, this); - } - GeneratePreview(); - } - } - - private bool LoadSingleFile(string fileName, Form parentForm) - { - groupBoxSplitting.Enabled = true; - textBoxText.Enabled = true; - Format = null; - string ext = string.Empty; - var extension = Path.GetExtension(fileName); - _fileName = fileName; - if (extension != null) - { - ext = extension.ToLowerInvariant(); - } - - var fd = new FinalDraftTemplate2(); - var list = new List(FileUtil.ReadAllLinesShared(fileName, LanguageAutoDetect.GetEncodingFromFile(fileName))); - bool isFinalDraft = fd.IsMine(list, fileName); - - if (ext == ".astx") - { - LoadAdobeStory(fileName); - } - else if (isFinalDraft) - { - return LoadFinalDraftTemplate(fileName, parentForm ?? this); - } - else if (ext == ".tx3g" && new Tx3GTextOnly().IsMine(null, fileName)) - { - LoadTx3G(fileName); - } - else if (ext == ".rtf" && FileUtil.IsRtf(fileName)) - { - LoadRtf(fileName); - } - else if (ext == ".html" && IsHtmlIndexExportFromSubtitleEdit(fileName)) - { - textBoxText.Text = FileUtil.ReadAllTextShared(fileName, Encoding.UTF8); - Text = Configuration.Settings.Language.ImportText.Title + " - " + fileName; - GeneratePreview(); - groupBoxImportOptions.Visible = false; - } - else - { - LoadTextFile(fileName); - } - return true; - } - - private static bool IsHtmlIndexExportFromSubtitleEdit(string fileName) - { - if (string.IsNullOrEmpty(fileName)) - { - return false; - } - - var html = FileUtil.ReadAllTextShared(fileName, Encoding.UTF8); - var s = GetSubtitleFromHtmlIndex(html); - return s.Paragraphs.Count > 0; - } - - private static Subtitle GetSubtitleFromHtmlIndex(string html) - { - var lines = html - .Replace($"
{Environment.NewLine}", "
") - .Replace("
\\n", "
") - .SplitToLines(); - - // A line will look like this: #1:4:06,288->4:09,375

My mommy always said
there were no monsters.


- var subtitle = new Subtitle(); - foreach (var line in lines) - { - var indexOfText = line.IndexOf("background-color:", StringComparison.OrdinalIgnoreCase); - if (indexOfText >= 0) - { - indexOfText = line.IndexOf('>', indexOfText); - } - - var indexOfFirstColon = line.IndexOf(':'); - var indexOfTimeSplit = line.IndexOf("->", StringComparison.Ordinal); - var indexOfFirstDiv = line.IndexOf(" 0 && indexOfFirstColon > 0 && indexOfTimeSplit > 0 && indexOfFirstDiv > 0) - { - var start = line.Substring(indexOfFirstColon + 1, indexOfTimeSplit - indexOfFirstColon - 1); - var end = line.Substring(indexOfTimeSplit + 2, indexOfFirstDiv - indexOfTimeSplit - 2); - var text = line.Substring(indexOfText + 1) - .Replace("
", string.Empty) - .Replace("
", string.Empty) - .Replace("
", string.Empty) - .Replace("
", string.Empty) - .Replace("
", Environment.NewLine) - .Replace("
", Environment.NewLine) - .Trim(); - text = WebUtility.HtmlDecode(text); - var p = new Paragraph(text, DecodeTimeCode(start), DecodeTimeCode(end)); - subtitle.Paragraphs.Add(p); - } - } - subtitle.Renumber(); - return subtitle; - } - - private static double DecodeTimeCode(string tc) - { - var parts = tc.Split(',', '.', ':'); - try - { - if (parts.Length == 2) - { - return new TimeCode(0, 0, int.Parse(parts[0]), int.Parse(parts[1])).TotalMilliseconds; - } - if (parts.Length == 3) - { - return new TimeCode(0, int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2])).TotalMilliseconds; - } - if (parts.Length == 4) - { - return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])).TotalMilliseconds; - } - } - catch - { - return 0; - } - return 0; - } - - private void GeneratePreview() - { - if (radioButtonSplitAtBlankLines.Checked || radioButtonLineMode.Checked) - { - groupBoxAutoSplitSettings.Visible = false; - groupBoxAutoSplitSettings.SendToBack(); - checkBoxMergeShortLines.Enabled = true; - checkBoxRemoveEmptyLines.Enabled = true; - checkBoxAutoBreak.Enabled = true; - checkBoxAutoBreak.Text = Configuration.Settings.Language.Settings.MainTextBoxAutoBreak; - } - else // auto split - { - groupBoxAutoSplitSettings.Visible = true; - groupBoxAutoSplitSettings.BringToFront(); - checkBoxMergeShortLines.Enabled = false; - checkBoxRemoveEmptyLines.Enabled = false; - checkBoxAutoBreak.Enabled = true; - } - - if (_refreshTimer.Enabled) - { - _refreshTimer.Stop(); - } - - _refreshTimer.Start(); - } - - private void GeneratePreviewReal() - { - if (IsHtmlIndexExportFromSubtitleEdit(_fileName)) - { - groupBoxImportOptions.Visible = false; - var html = FileUtil.ReadAllTextShared(_fileName, Encoding.UTF8); - FixedSubtitle = GetSubtitleFromHtmlIndex(html); - groupBoxImportResult.Text = string.Format(Configuration.Settings.Language.ImportText.PreviewLinesModifiedX, FixedSubtitle.Paragraphs.Count); - SubtitleListview1.Fill(FixedSubtitle); - SubtitleListview1.SelectIndexAndEnsureVisible(0); - return; - } - - groupBoxImportOptions.Visible = true; - if (Format == null || Format.GetType() != typeof(CsvNuendo)) - { - FixedSubtitle = new Subtitle(); - if (checkBoxMultipleFiles.Visible && checkBoxMultipleFiles.Checked) - { - ImportMultipleFiles(listViewInputFiles.Items); - } - else if (radioButtonLineMode.Checked) - { - ImportLineMode(textBoxText.Lines); - } - else if (radioButtonAutoSplit.Checked) - { - ImportAutoSplit(textBoxText.Lines); - } - else - { - ImportSplitAtBlankLine(textBoxText.Lines); - } - } - else - { - FixedSubtitle = new Subtitle(_subtitleInput); - if (checkBoxAutoBreak.Enabled && checkBoxAutoBreak.Checked) - { - foreach (var p in FixedSubtitle.Paragraphs) - { - p.Text = Utilities.AutoBreakLine(p.Text); - } - } - } - - if (checkBoxMergeShortLines.Checked) - { - MergeLinesWithContinuation(); - } - - FixedSubtitle.Renumber(_startFromNumber); - if (checkBoxGenerateTimeCodes.Checked && checkBoxTakeTimeFromFileNames.Visible && checkBoxTakeTimeFromFileNames.Checked) - { - // time codes already generated - } - else if (checkBoxGenerateTimeCodes.Checked) - { - FixDurations(); - MakePseudoStartTime(); - } - else - { - foreach (var p in FixedSubtitle.Paragraphs) - { - p.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - p.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - } - } - - groupBoxImportResult.Text = string.Format(Configuration.Settings.Language.ImportText.PreviewLinesModifiedX, FixedSubtitle.Paragraphs.Count); - SubtitleListview1.Fill(FixedSubtitle); - SubtitleListview1.SelectIndexAndEnsureVisible(0); - } - - private void ImportMultipleFiles(ListView.ListViewItemCollection listViewItemCollection) - { - foreach (ListViewItem item in listViewItemCollection) - { - string line; - try - { - line = GetAllText(item.Text).Trim(); - } - catch - { - line = string.Empty; - } - - line = line.Replace("|", Environment.NewLine); - if (comboBoxLineBreak.Text.Length > 0) - { - foreach (var splitter in comboBoxLineBreak.Text.Split(';')) - { - var tempSplitter = splitter.Trim(); - if (tempSplitter.Length > 0) - { - line = line.Replace(tempSplitter, Environment.NewLine); - } - } - } - - if (string.IsNullOrWhiteSpace(line)) - { - if (!checkBoxRemoveEmptyLines.Checked) - { - FixedSubtitle.Paragraphs.Add(new Paragraph()); - ImportImages.SetEndTimeAndStartTime(Path.GetFileNameWithoutExtension(item.Text), FixedSubtitle.Paragraphs.Last()); - } - } - else if (!PlainTextImporter.ContainsLetters(line)) - { - if (!checkBoxRemoveLinesWithoutLetters.Checked) - { - FixedSubtitle.Paragraphs.Add(new Paragraph(line.Trim(), 0, 0)); - ImportImages.SetEndTimeAndStartTime(Path.GetFileNameWithoutExtension(item.Text), FixedSubtitle.Paragraphs.Last()); - } - } - else - { - FixedSubtitle.Paragraphs.Add(new Paragraph(line.Trim(), 0, 0)); - ImportImages.SetEndTimeAndStartTime(Path.GetFileNameWithoutExtension(item.Text), FixedSubtitle.Paragraphs.Last()); - } - } - } - - private void MergeLinesWithContinuation() - { - var temp = new Subtitle(); - bool skipNext = false; - for (int i = 0; i < FixedSubtitle.Paragraphs.Count; i++) - { - Paragraph p = FixedSubtitle.Paragraphs[i]; - if (!skipNext) - { - Paragraph next = FixedSubtitle.GetParagraphOrDefault(i + 1); - - bool merge = !(p.Text.Contains(Environment.NewLine) || next == null) && Configuration.Settings.General.MaxNumberOfLines > 1; - - if (merge && (p.Text.TrimEnd().EndsWith('!') || p.Text.TrimEnd().EndsWith('.'))) - { - var st = new StrippableText(p.Text); - if (st.StrippedText.Length > 0 && char.IsUpper(st.StrippedText[0])) - { - merge = false; - } - } - - if (merge && (p.Text.Length >= Configuration.Settings.General.SubtitleLineMaximumLength - 5 || next.Text.Length >= Configuration.Settings.General.SubtitleLineMaximumLength - 5)) - { - merge = false; - } - - if (merge) - { - temp.Paragraphs.Add(new Paragraph { Text = p.Text + Environment.NewLine + next.Text }); - skipNext = true; - } - else - { - temp.Paragraphs.Add(new Paragraph(p)); - } - } - else - { - skipNext = false; - } - } - FixedSubtitle = temp; - } - - private void MakePseudoStartTime() - { - var millisecondsInterval = (double)numericUpDownGapBetweenLines.Value; - double millisecondsIndex = millisecondsInterval; - foreach (Paragraph p in FixedSubtitle.Paragraphs) - { - p.EndTime.TotalMilliseconds = millisecondsIndex + p.Duration.TotalMilliseconds; - p.StartTime.TotalMilliseconds = millisecondsIndex; - millisecondsIndex += (p.EndTime.TotalMilliseconds - p.StartTime.TotalMilliseconds) + millisecondsInterval; - } - } - - private void FixDurations() - { - foreach (Paragraph p in FixedSubtitle.Paragraphs) - { - if (p.Text.Length == 0) - { - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 2000; - } - else - { - if (radioButtonDurationAuto.Checked) - { - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + (Utilities.GetOptimalDisplayMilliseconds(p.Text)); - } - else - { - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + ((double)numericUpDownDurationFixed.Value); - } - } - } - } - - private void ImportLineMode(IEnumerable lines) - { - var item = new List(); - foreach (string loopLine in lines) - { - // Replace user line break character with Environment.NewLine. - string line = loopLine; - if (comboBoxLineBreak.Text.Length > 0) - { - foreach (string splitter in comboBoxLineBreak.Text.Split(';')) - { - var tempSplitter = splitter.Trim(); - if (tempSplitter.Length > 0) - { - line = line.Replace(tempSplitter, Environment.NewLine); - } - } - } - - if (string.IsNullOrWhiteSpace(line)) - { - if (!checkBoxRemoveEmptyLines.Checked) - { - item.Add(string.Empty); - } - } - else if (!PlainTextImporter.ContainsLetters(line)) - { - if (!checkBoxRemoveLinesWithoutLetters.Checked) - { - item.Add(line.Trim()); - } - } - else - { - string text = line.Trim(); - if (checkBoxAutoBreak.Enabled && checkBoxAutoBreak.Checked && comboBoxLineMode.SelectedIndex == 0) - { - text = Utilities.AutoBreakLine(text); - } - - item.Add(text); - } - - if (item.Count >= comboBoxLineMode.SelectedIndex + 1) - { - FixedSubtitle.Paragraphs.Add(new Paragraph { Text = string.Join(Environment.NewLine, item.ToArray()) }); - item.Clear(); - } - } - if (item.Count > 0) - { - FixedSubtitle.Paragraphs.Add(new Paragraph { Text = string.Join(Environment.NewLine, item.ToArray()) }); - } - } - - private void ImportSplitAtBlankLine(IEnumerable lines) - { - var sb = new StringBuilder(); - foreach (string line in lines) - { - if (string.IsNullOrWhiteSpace(line)) - { - if (sb.Length > 0) - { - string text = sb.ToString().Trim(); - if (checkBoxAutoBreak.Enabled && checkBoxAutoBreak.Checked) - { - text = Utilities.AutoBreakLine(text); - } - - FixedSubtitle.Paragraphs.Add(new Paragraph { Text = text }); - sb.Clear(); - } - } - else if (!PlainTextImporter.ContainsLetters(line)) - { - if (!checkBoxRemoveLinesWithoutLetters.Checked) - { - sb.AppendLine(line.Trim()); - } - } - else - { - sb.AppendLine(line.Trim()); - } - } - if (sb.Length > 0) - { - SplitSingle(sb); - } - } - - private static bool CanMakeThreeLiner(out string text, string input) - { - text = string.Empty; - if (input.Length < Configuration.Settings.General.SubtitleLineMaximumLength * 3 && input.Length > Configuration.Settings.General.SubtitleLineMaximumLength * 1.5) - { - var splitLines = Utilities.AutoBreakLine(input).SplitToLines(); - if (splitLines.Count == 2 && (splitLines[0].Length > Configuration.Settings.General.SubtitleLineMaximumLength || splitLines[1].Length > Configuration.Settings.General.SubtitleLineMaximumLength)) - { - var first = new StringBuilder(); - var second = new StringBuilder(); - var third = new StringBuilder(); - foreach (string word in input.Replace(Environment.NewLine, " ").Replace(" ", " ").Split(' ')) - { - if (first.Length + word.Length < Configuration.Settings.General.SubtitleLineMaximumLength) - { - first.Append(' '); - first.Append(word); - } - else if (second.Length + word.Length < Configuration.Settings.General.SubtitleLineMaximumLength) - { - second.Append(' '); - second.Append(word); - } - else - { - third.Append(' '); - third.Append(word); - } - } - if (third.Length <= Configuration.Settings.General.SubtitleLineMaximumLength && third.Length > 10) - { - if (second.Length > 15) - { - string ending = second.ToString().Substring(second.Length - 9); - int splitPos = -1; - if (ending.Contains(". ")) - { - splitPos = ending.IndexOf(". ", StringComparison.Ordinal) + second.Length - 9; - } - else if (ending.Contains("! ")) - { - splitPos = ending.IndexOf("! ", StringComparison.Ordinal) + second.Length - 9; - } - else if (ending.Contains(", ")) - { - splitPos = ending.IndexOf(", ", StringComparison.Ordinal) + second.Length - 9; - } - else if (ending.Contains("? ")) - { - splitPos = ending.IndexOf("? ", StringComparison.Ordinal) + second.Length - 9; - } - - if (splitPos > 0) - { - text = Utilities.AutoBreakLine(first.ToString().Trim() + second.ToString().Substring(0, splitPos + 1)).Trim() + Environment.NewLine + (second.ToString().Substring(splitPos + 1) + third).Trim(); - return true; - } - } - - text = first + Environment.NewLine + second + Environment.NewLine + third; - return true; - } - } - } - return false; - } - - private void SplitSingle(StringBuilder sb) - { - string t = sb.ToString().Trim(); - var tarr = t.SplitToLines(); - if (checkBoxMergeShortLines.Checked == false && tarr.Count == 3 && - tarr[0].Length < Configuration.Settings.General.SubtitleLineMaximumLength && - tarr[1].Length < Configuration.Settings.General.SubtitleLineMaximumLength && - tarr[2].Length < Configuration.Settings.General.SubtitleLineMaximumLength) - { - FixedSubtitle.Paragraphs.Add(new Paragraph { Text = tarr[0] + Environment.NewLine + tarr[1] }); - return; - } - if (checkBoxMergeShortLines.Checked == false && tarr.Count == 2 && - tarr[0].Length < Configuration.Settings.General.SubtitleLineMaximumLength && - tarr[1].Length < Configuration.Settings.General.SubtitleLineMaximumLength) - { - FixedSubtitle.Paragraphs.Add(new Paragraph { Text = tarr[0] + Environment.NewLine + tarr[1] }); - return; - } - if (checkBoxMergeShortLines.Checked == false && tarr.Count == 1 && tarr[0].Length < Configuration.Settings.General.SubtitleLineMaximumLength) - { - FixedSubtitle.Paragraphs.Add(new Paragraph { Text = tarr[0].Trim() }); - return; - } - - Paragraph p = null; - if (CanMakeThreeLiner(out var threeLiner, sb.ToString())) - { - var parts = threeLiner.SplitToLines(); - FixedSubtitle.Paragraphs.Add(new Paragraph { Text = parts[0] + Environment.NewLine + parts[1] }); - FixedSubtitle.Paragraphs.Add(new Paragraph { Text = parts[2].Trim() }); - return; - } - - foreach (string text in Utilities.AutoBreakLineMoreThanTwoLines(sb.ToString(), Configuration.Settings.General.SubtitleLineMaximumLength, Configuration.Settings.General.MergeLinesShorterThan, "en").SplitToLines()) - { - if (p == null) - { - p = new Paragraph { Text = text }; - } - else if (p.Text.Contains(Environment.NewLine)) - { - FixedSubtitle.Paragraphs.Add(p); - p = new Paragraph(); - if (text.Length >= Configuration.Settings.General.SubtitleLineMaximumLength) - { - p.Text = Utilities.AutoBreakLine(text); - } - else - { - p.Text = text; - } - } - else - { - if (checkBoxMergeShortLines.Checked || p.Text.Length > Configuration.Settings.General.SubtitleLineMaximumLength || text.Length > Configuration.Settings.General.SubtitleLineMaximumLength) - { - p.Text = Utilities.AutoBreakLine(p.Text + Environment.NewLine + text.Trim()); - } - else - { - p.Text = p.Text + Environment.NewLine + text.Trim(); - } - } - } - if (p != null) - { - FixedSubtitle.Paragraphs.Add(p); - } - } - - private void ImportAutoSplit(string[] textLines) - { - var sub = new Subtitle(); - foreach (var line in textLines) - { - sub.Paragraphs.Add(new Paragraph(line, 0, 0)); - } - var language = LanguageAutoDetect.AutoDetectGoogleLanguage(sub); - - var plainTextImporter = new PlainTextImporter(checkBoxAutoSplitAtBlankLines.Checked, - checkBoxAutoSplitRemoveLinesNoLetters.Checked, - (int)numericUpDownAutoSplitMaxLines.Value, - checkBoxAutoSplitAtEnd.Checked ? textBoxAsEnd.Text : string.Empty, - (int)numericUpDownSubtitleLineMaximumLength.Value, - language); - - ImportLineMode(plainTextImporter.ImportAutoSplit(textLines)); - } - - private void ButtonOkClick(object sender, EventArgs e) - { - DialogResult = SubtitleListview1.Items.Count > 0 ? DialogResult.OK : DialogResult.Cancel; - } - - private void ButtonCancelClick(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void CheckBoxRemoveLinesWithoutLettersOrNumbersCheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void CheckBoxRemoveEmptyLinesCheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void RadioButtonLineModeCheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - // textBoxLineBreak and its label are enabled if radioButtonLineMode is checked. - comboBoxLineBreak.Enabled = radioButtonLineMode.Checked; - labelLineBreak.Enabled = radioButtonLineMode.Checked; - } - - private void RadioButtonAutoSplitCheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void TextBoxTextDragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) - { - e.Effect = DragDropEffects.All; - } - } - - private void TextBoxTextDragDrop(object sender, DragEventArgs e) - { - var files = (string[])e.Data.GetData(DataFormats.FileDrop); - if (files.Length == 1) - { - LoadTextFile(files[0]); - } - } - - private static string HtmlToPlainText(string html) - { - var stripFormattingRegex = new Regex(@"<[^>]*(>|$)", RegexOptions.Multiline); // match any character between '<' and '>', even when end tag is missing - var tagWhiteSpaceRegex = new Regex(@"(>|$)(\W|\n|\r)+<", RegexOptions.Multiline); // matches one or more (white space or line breaks) between '>' and '<' - - // Decode html specific characters - var text = WebUtility.HtmlDecode(html); - - // Remove tag whitespace/line breaks - text = tagWhiteSpaceRegex.Replace(text, "><"); - - // Find new lines - text = text.Replace("
", Environment.NewLine); - text = text.Replace("
", Environment.NewLine); - text = text.Replace("
", Environment.NewLine); - text = text.Replace("
", Environment.NewLine); - text = text.Replace("
", Environment.NewLine + Environment.NewLine); - text = text.Replace("
", Environment.NewLine + Environment.NewLine); - text = text.Replace("
", Environment.NewLine + Environment.NewLine); - text = text.Replace("
", Environment.NewLine + Environment.NewLine); - text = text.Replace("

", Environment.NewLine + Environment.NewLine); - text = text.Replace("

", Environment.NewLine + Environment.NewLine); - text = text.Replace(Environment.NewLine + Environment.NewLine + Environment.NewLine, Environment.NewLine + Environment.NewLine); - text = text.Replace(Environment.NewLine + Environment.NewLine + Environment.NewLine, Environment.NewLine + Environment.NewLine); - - text = stripFormattingRegex.Replace(text, string.Empty); - - return text; - } - - private static string GetAllText(string fileName) - { - try - { - var encoding = LanguageAutoDetect.GetEncodingFromFile(fileName); - var text = FileUtil.ReadAllTextShared(fileName, encoding); - if (fileName.EndsWith(".html", StringComparison.OrdinalIgnoreCase) || fileName.EndsWith(".htm", StringComparison.OrdinalIgnoreCase)) - { - text = HtmlToPlainText(text); - } - if (fileName.EndsWith(".rtf", StringComparison.OrdinalIgnoreCase)) - { - text = GetRtfString(fileName); - } - - return text; - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - return string.Empty; - } - } - - private void LoadTextFile(string fileName) - { - textBoxText.Text = GetAllText(fileName); - SetVideoFileName(fileName); - Text = Configuration.Settings.Language.ImportText.Title + " - " + fileName; - GeneratePreview(); - } - - private void LoadTx3G(string fileName) - { - try - { - var sb = new StringBuilder(); - var sub = new Subtitle(); - new Tx3GTextOnly().LoadSubtitle(sub, null, fileName); - foreach (var paragraph in sub.Paragraphs) - { - sb.AppendLine(paragraph.Text); - sb.AppendLine(); - } - textBoxText.Text = sb.ToString(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - radioButtonSplitAtBlankLines.Checked = true; - checkBoxMergeShortLines.Checked = false; - GeneratePreview(); - } - - private void LoadRtf(string fileName) - { - try - { - labelStatus.Text = Configuration.Settings.Language.General.PleaseWait; - labelStatus.Refresh(); - textBoxText.Text = GetRtfString(fileName); - SetVideoFileName(fileName); - Text = Configuration.Settings.Language.ImportText.Title + " - " + fileName; - GeneratePreview(); - } - finally - { - labelStatus.Text = string.Empty; - } - } - - private static string GetRtfString(string fileName) - { - const int bomHeaderLength = 3; - var encoding = FileUtil.HasUtf8Bom(fileName) ? Encoding.UTF8 : Encoding.ASCII; - var bytes = FileUtil.ReadAllBytesShared(fileName); - var rtf = encoding.GetString(bytes); - if (Equals(encoding, Encoding.UTF8)) - { - rtf = encoding.GetString(bytes, bomHeaderLength, bytes.Length - bomHeaderLength); - } - - using (var rtb = new RichTextBox { Rtf = rtf }) - { - var sb = new StringBuilder(); - bool italicOn = false; - bool boldOn = false; - bool underlineOn = false; - for (int i = 0; i < rtb.TextLength; i++) - { - rtb.SelectionStart = i; - rtb.SelectionLength = 1; - if (rtb.SelectionFont.Italic && !italicOn) - { - sb.Append(""); - italicOn = true; - } - - if (rtb.SelectionFont.Bold && !boldOn) - { - sb.Append(""); - boldOn = true; - } - - if (rtb.SelectionFont.Underline && !underlineOn) - { - sb.Append(""); - underlineOn = true; - } - - if (!rtb.SelectionFont.Underline && underlineOn) - { - sb.Append(""); - underlineOn = false; - } - - if (!rtb.SelectionFont.Bold && boldOn) - { - sb.Append(""); - boldOn = false; - } - - if (!rtb.SelectionFont.Italic && italicOn) - { - sb.Append(""); - italicOn = false; - } - - sb.Append(rtb.SelectedText); - } - - if (underlineOn) - { - sb.Append("
"); - } - - if (boldOn) - { - sb.Append(""); - } - - if (italicOn) - { - sb.Append(""); - } - - return string.Join(Environment.NewLine, sb.ToString().SplitToLines()) - .Replace($" {Environment.NewLine}", Environment.NewLine) - .Replace(" ", " ") - .Replace(" ", " ") - .Replace("
", " ") - .Replace($"{Environment.NewLine}", Environment.NewLine) - .Replace($"{Environment.NewLine}", Environment.NewLine) - .Replace($"{Environment.NewLine}", Environment.NewLine) - .Replace($"{Environment.NewLine}", Environment.NewLine) - .Replace($"{Environment.NewLine}", Environment.NewLine) - .Replace($"{Environment.NewLine}", Environment.NewLine) - .Replace($"{Environment.NewLine}", Environment.NewLine); - } - } - - private void LoadAdobeStory(string fileName) - { - try - { - var sb = new StringBuilder(); - var doc = new XmlDocument(); - doc.Load(fileName); - var nodes = doc.DocumentElement?.SelectNodes("//paragraph[@element='Dialog']"); - if (nodes != null) - { - foreach (XmlNode node in nodes) // - { - XmlNode textRun = node.SelectSingleNode("textRun"); // Yeah...I suppose - if (textRun != null) - { - sb.AppendLine(textRun.InnerText); - } - } - } - - textBoxText.Text = sb.ToString(); - VideoFileName = null; - Text = Configuration.Settings.Language.ImportText.Title + " - " + fileName; - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - radioButtonLineMode.Checked = true; - checkBoxMergeShortLines.Checked = false; - GeneratePreview(); - } - - private bool LoadFinalDraftTemplate(string fileName, Form parentForm) - { - try - { - var fd = new FinalDraftTemplate2(); - var sub = new Subtitle(); - var lines = Encoding.UTF8.GetString(FileUtil.ReadAllBytesShared(fileName)).SplitToLines(); - var availableParagraphTypes = fd.GetParagraphTypes(lines); - using (var form = new ImportFinalDraft(availableParagraphTypes)) - { - if (form.ShowDialog(parentForm) == DialogResult.OK) - { - fd.ActiveParagraphTypes = form.ChosenParagraphTypes; - fd.LoadSubtitle(sub, lines, fileName); - } - else - { - return false; - } - } - - textBoxText.Text = sub.ToText(fd); - VideoFileName = null; - Text = Configuration.Settings.Language.ImportText.Title + " - " + fileName; - _subtitleInput = sub; - Format = new CsvNuendo(); - groupBoxSplitting.Enabled = false; - textBoxText.Enabled = false; - if (_subtitleInput.Paragraphs.Any(p => !string.IsNullOrEmpty(p.Actor))) - { - SubtitleListview1.ShowActorColumn(Configuration.Settings.Language.General.Character); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - radioButtonLineMode.Checked = true; - checkBoxMergeShortLines.Checked = false; - GeneratePreview(); - return true; - } - - private void SetVideoFileName(string fileName) - { - VideoFileName = fileName.Substring(0, fileName.Length - Path.GetExtension(fileName).Length); - if (VideoFileName.EndsWith(".en", StringComparison.Ordinal)) - { - VideoFileName = VideoFileName.Remove(VideoFileName.Length - 3); - } - - foreach (var ext in Utilities.VideoFileExtensions) - { - if (File.Exists(VideoFileName + ext)) - { - VideoFileName += ext; - return; - } - } - - var dir = Path.GetDirectoryName(fileName); - if (dir != null) - { - foreach (var ext in Utilities.VideoFileExtensions) - { - var files = Directory.GetFiles(dir, Path.GetFileNameWithoutExtension(VideoFileName) + "*" + ext); - if (files.Length > 0) - { - VideoFileName = files[0]; - return; - } - } - VideoFileName = null; - } - } - - private void ButtonRefreshClick(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void RadioButtonDurationFixedCheckedChanged(object sender, EventArgs e) - { - numericUpDownDurationFixed.Enabled = radioButtonDurationFixed.Checked; - GeneratePreview(); - } - - private void CheckBoxMergeShortLinesCheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void ImportTextKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void TextBoxTextTextChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void NumericUpDownDurationFixedValueChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void NumericUpDownGapBetweenLinesValueChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void RadioButtonDurationAutoCheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void radioButtonSplitAtBlankLines_CheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void checkBoxGenerateTimeCodes_CheckedChanged(object sender, EventArgs e) - { - groupBoxTimeCodes.Enabled = checkBoxGenerateTimeCodes.Checked; - GeneratePreview(); - } - - private void ImportText_FormClosing(object sender, FormClosingEventArgs e) - { - if (radioButtonSplitAtBlankLines.Checked) - { - Configuration.Settings.Tools.ImportTextSplitting = "blank lines"; - } - else if (radioButtonLineMode.Checked) - { - Configuration.Settings.Tools.ImportTextSplitting = "line"; - } - else - { - Configuration.Settings.Tools.ImportTextSplitting = "auto"; - } - - Configuration.Settings.Tools.ImportTextLineBreak = comboBoxLineBreak.Text.Trim(); - Configuration.Settings.Tools.ImportTextMergeShortLines = checkBoxMergeShortLines.Checked; - Configuration.Settings.Tools.ImportTextRemoveEmptyLines = checkBoxRemoveEmptyLines.Checked; - Configuration.Settings.Tools.ImportTextAutoSplitNumberOfLines = numericUpDownAutoSplitMaxLines.Value; - Configuration.Settings.Tools.ImportTextAutoSplitAtBlank = checkBoxAutoSplitAtBlankLines.Checked; - - if (radioButtonAutoSplit.Checked) - { - Configuration.Settings.Tools.ImportTextRemoveLinesNoLetters = checkBoxAutoSplitRemoveLinesNoLetters.Checked; - } - else - { - Configuration.Settings.Tools.ImportTextRemoveLinesNoLetters = checkBoxRemoveLinesWithoutLetters.Checked; - } - - Configuration.Settings.Tools.ImportTextGenerateTimeCodes = checkBoxGenerateTimeCodes.Checked; - Configuration.Settings.Tools.ImportTextTakeTimeCodeFromFileName = checkBoxTakeTimeFromFileNames.Checked; - Configuration.Settings.Tools.ImportTextAutoBreak = checkBoxAutoBreak.Checked; - Configuration.Settings.Tools.ImportTextAutoBreakAtEnd = checkBoxAutoSplitAtEnd.Checked; - Configuration.Settings.Tools.ImportTextAutoBreakAtEndMarkerText = textBoxAsEnd.Text.Replace(" ", string.Empty); - Configuration.Settings.Tools.ImportTextGap = numericUpDownGapBetweenLines.Value; - Configuration.Settings.Tools.ImportTextDurationAuto = radioButtonDurationAuto.Checked; - Configuration.Settings.Tools.ImportTextFixedDuration = numericUpDownDurationFixed.Value; - } - - private void checkBoxMultipleFiles_CheckedChanged(object sender, EventArgs e) - { - Format = null; - textBoxText.Enabled = true; - groupBoxSplitting.Enabled = true; - if (checkBoxMultipleFiles.Checked) - { - listViewInputFiles.Visible = true; - textBoxText.Visible = false; - buttonOpenText.Text = Configuration.Settings.Language.ImportText.OpenTextFiles; - groupBoxSplitting.Enabled = false; - checkBoxTakeTimeFromFileNames.Visible = true; - } - else - { - listViewInputFiles.Visible = false; - textBoxText.Visible = true; - buttonOpenText.Text = Configuration.Settings.Language.ImportText.OpenTextFile; - groupBoxSplitting.Enabled = true; - checkBoxTakeTimeFromFileNames.Visible = false; - } - GeneratePreview(); - } - - private void listViewInputFiles_DragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) - { - e.Effect = DragDropEffects.All; - } - } - - private void listViewInputFiles_DragDrop(object sender, DragEventArgs e) - { - var fileNames = (string[])e.Data.GetData(DataFormats.FileDrop); - foreach (string fileName in fileNames.OrderBy(p => p)) - { - AddInputFile(fileName); - } - GeneratePreview(); - } - - private void AddInputFile(string fileName) - { - try - { - var fi = new FileInfo(fileName); - var item = new ListViewItem(fileName) { Tag = fileName }; - item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); - if (fi.Length < 1024 * 1024) // max 1 mb - { - listViewInputFiles.Items.Add(item); - } - } - catch - { - // ignored - } - } - - private void checkBoxAutoBreak_CheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void comboBoxLineBreak_TextChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void clearToolStripMenuItem_Click(object sender, EventArgs e) - { - listViewInputFiles.Items.Clear(); - } - - private void ImportText_Shown(object sender, EventArgs e) - { - if (textBoxText.Visible && textBoxText.Text.Length > 20) - { - buttonOK.Focus(); - } - - if (_exit) - { - DialogResult = DialogResult.Cancel; - } - - var workingArea = Screen.FromControl(this).WorkingArea; - if (workingArea.Height < Height) - { - Height = Math.Max(workingArea.Height, MinimumSize.Height); - } - } - - private void startNumberingFromToolStripMenuItem_Click(object sender, EventArgs e) - { - using (var startNumberingFrom = new StartNumberingFrom()) - { - if (startNumberingFrom.ShowDialog(this) == DialogResult.OK) - { - _startFromNumber = startNumberingFrom.StartFromNumber; - FixedSubtitle.Renumber(startNumberingFrom.StartFromNumber); - SubtitleListview1.Fill(FixedSubtitle); - } - } - } - - private void numericUpDownAutoSplitMaxLines_ValueChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void textBoxAsEnd1_TextChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void checkBoxAutoSplitAtBlankLines_CheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void checkBoxAutoSplitRemoveLinesNoLetters_CheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void textBoxAsEnd1_KeyPress(object sender, KeyPressEventArgs e) - { - if (e.KeyChar == (char)Keys.Space || char.IsLetterOrDigit(e.KeyChar)) - { - e.Handled = true; - } - } - - private void numericUpDownSubtitleLineMaximumLength_ValueChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void comboBoxLineMode_SelectedIndexChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void checkBoxAutoSplitAtEnd_CheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - } +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ImportText : Form + { + private Subtitle _subtitleInput; + private string _fileName; + private readonly Timer _refreshTimer = new Timer(); + private readonly bool _exit; + private int _startFromNumber = 1; + + public Subtitle FixedSubtitle { get; private set; } + public SubtitleFormat Format { get; set; } + public string VideoFileName { get; private set; } + + public ImportText(string fileName = null, Form parentForm = null) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.ImportText.Title; + groupBoxImportText.Text = Configuration.Settings.Language.ImportText.Title; + buttonOpenText.Text = Configuration.Settings.Language.ImportText.OpenTextFile; + groupBoxImportOptions.Text = Configuration.Settings.Language.ImportText.ImportOptions; + groupBoxSplitting.Text = Configuration.Settings.Language.ImportText.Splitting; + radioButtonAutoSplit.Text = Configuration.Settings.Language.ImportText.AutoSplitText; + radioButtonLineMode.Text = string.Empty; + comboBoxLineMode.Items.Clear(); + comboBoxLineMode.Items.Add(Configuration.Settings.Language.ImportText.OneLineIsOneSubtitle); + comboBoxLineMode.Items.Add(Configuration.Settings.Language.ImportText.TwoLinesAreOneSubtitle); + comboBoxLineMode.SelectedIndex = 0; + labelLineBreak.Text = Configuration.Settings.Language.ImportText.LineBreak; + columnHeaderFName.Text = Configuration.Settings.Language.JoinSubtitles.FileName; + columnHeaderSize.Text = Configuration.Settings.Language.General.Size; + comboBoxLineBreak.Left = labelLineBreak.Left + labelLineBreak.Width + 3; + comboBoxLineBreak.Width = groupBoxSplitting.Width - comboBoxLineBreak.Left - 5; + checkBoxMultipleFiles.AutoSize = true; + checkBoxMultipleFiles.Left = buttonOpenText.Left - checkBoxMultipleFiles.Width - 9; + checkBoxMultipleFiles.Text = Configuration.Settings.Language.ImportText.OneSubtitleIsOneFile; + listViewInputFiles.Visible = false; + labelSubMaxLen.Text = Configuration.Settings.Language.Settings.SubtitleLineMaximumLength; + numericUpDownSubtitleLineMaximumLength.Left = labelSubMaxLen.Left + labelSubMaxLen.Width + 3; + + radioButtonSplitAtBlankLines.Text = Configuration.Settings.Language.ImportText.SplitAtBlankLines; + checkBoxMergeShortLines.Text = Configuration.Settings.Language.ImportText.MergeShortLines; + checkBoxRemoveEmptyLines.Text = Configuration.Settings.Language.ImportText.RemoveEmptyLines; + checkBoxRemoveLinesWithoutLetters.Text = Configuration.Settings.Language.ImportText.RemoveLinesWithoutLetters; + checkBoxAutoSplitRemoveLinesNoLetters.Text = Configuration.Settings.Language.ImportText.RemoveLinesWithoutLetters; + checkBoxGenerateTimeCodes.Text = Configuration.Settings.Language.ImportText.GenerateTimeCodes; + checkBoxTakeTimeFromFileNames.Text = Configuration.Settings.Language.ImportText.TakeTimeFromFileName; + checkBoxTakeTimeFromFileNames.Left = checkBoxGenerateTimeCodes.Left + checkBoxGenerateTimeCodes.Width + 9; + checkBoxAutoBreak.Text = Configuration.Settings.Language.Settings.MainTextBoxAutoBreak; + labelGapBetweenSubtitles.Text = Configuration.Settings.Language.ImportText.GapBetweenSubtitles; + numericUpDownGapBetweenLines.Left = labelGapBetweenSubtitles.Left + labelGapBetweenSubtitles.Width + 3; + groupBoxDuration.Text = Configuration.Settings.Language.General.Duration; + radioButtonDurationAuto.Text = Configuration.Settings.Language.ImportText.Auto; + radioButtonDurationFixed.Text = Configuration.Settings.Language.ImportText.Fixed; + buttonRefresh.Text = Configuration.Settings.Language.ImportText.Refresh; + groupBoxTimeCodes.Text = Configuration.Settings.Language.ImportText.TimeCodes; + groupBoxImportResult.Text = Configuration.Settings.Language.General.Preview; + clearToolStripMenuItem.Text = Configuration.Settings.Language.DvdSubRip.Clear; + startNumberingFromToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.Tools.StartNumberingFrom; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + UiUtil.InitializeSubtitleFont(listViewInputFiles); + textBoxText.Font = new System.Drawing.Font(listViewInputFiles.Font.FontFamily, listViewInputFiles.Font.Size, listViewInputFiles.Font.Style); + SubtitleListview1.AutoSizeAllColumns(this); + checkBoxTakeTimeFromFileNames.Visible = false; + + if (string.IsNullOrEmpty(Configuration.Settings.Tools.ImportTextSplitting)) + { + radioButtonAutoSplit.Checked = true; + } + else if (Configuration.Settings.Tools.ImportTextSplitting.Equals("blank lines", StringComparison.OrdinalIgnoreCase)) + { + radioButtonSplitAtBlankLines.Checked = true; + } + else if (Configuration.Settings.Tools.ImportTextSplitting.Equals("line", StringComparison.OrdinalIgnoreCase)) + { + radioButtonLineMode.Checked = true; + } + + comboBoxLineBreak.Text = Configuration.Settings.Tools.ImportTextLineBreak; + checkBoxMergeShortLines.Checked = Configuration.Settings.Tools.ImportTextMergeShortLines; + checkBoxRemoveEmptyLines.Checked = Configuration.Settings.Tools.ImportTextRemoveEmptyLines; + checkBoxAutoSplitAtBlankLines.Checked = Configuration.Settings.Tools.ImportTextAutoSplitAtBlank; + checkBoxRemoveLinesWithoutLetters.Checked = Configuration.Settings.Tools.ImportTextRemoveLinesNoLetters; + checkBoxAutoSplitRemoveLinesNoLetters.Checked = Configuration.Settings.Tools.ImportTextRemoveLinesNoLetters; + checkBoxGenerateTimeCodes.Checked = Configuration.Settings.Tools.ImportTextGenerateTimeCodes; + checkBoxTakeTimeFromFileNames.Checked = Configuration.Settings.Tools.ImportTextTakeTimeCodeFromFileName; + checkBoxAutoBreak.Checked = Configuration.Settings.Tools.ImportTextAutoBreak; + textBoxAsEnd.Text = Configuration.Settings.Tools.ImportTextAutoBreakAtEndMarkerText.Replace(" ", string.Empty); + checkBoxAutoSplitAtEnd.Checked = Configuration.Settings.Tools.ImportTextAutoBreakAtEnd; + checkBoxAutoSplitAtEnd.Text = Configuration.Settings.Language.ImportText.SplitAtEndChars; + textBoxAsEnd.Left = checkBoxAutoSplitAtEnd.Left + checkBoxAutoSplitAtEnd.Width; + checkBoxAutoSplitAtBlankLines.Text = Configuration.Settings.Language.ImportText.SplitAtBlankLines; + + groupBoxAutoSplitSettings.Text = Configuration.Settings.Language.Settings.Title; + labelAutoSplitNumberOfLines.Text = Configuration.Settings.Language.Settings.MaximumLines; + numericUpDownSubtitleLineMaximumLength.Left = labelSubMaxLen.Left + labelSubMaxLen.Width + 3; + numericUpDownSubtitleLineMaximumLength.Value = Configuration.Settings.General.SubtitleLineMaximumLength; + + if (Configuration.Settings.Tools.ImportTextAutoSplitNumberOfLines >= numericUpDownAutoSplitMaxLines.Minimum && + Configuration.Settings.Tools.ImportTextAutoSplitNumberOfLines <= numericUpDownAutoSplitMaxLines.Maximum) + { + numericUpDownAutoSplitMaxLines.Value = Configuration.Settings.Tools.ImportTextAutoSplitNumberOfLines; + } + + if (Configuration.Settings.Tools.ImportTextGap >= numericUpDownGapBetweenLines.Minimum && Configuration.Settings.Tools.ImportTextGap <= numericUpDownGapBetweenLines.Maximum) + { + numericUpDownGapBetweenLines.Value = Configuration.Settings.Tools.ImportTextGap; + } + if (Configuration.Settings.Tools.ImportTextDurationAuto) + { + radioButtonDurationAuto.Checked = true; + } + else + { + radioButtonDurationFixed.Checked = true; + } + numericUpDownDurationFixed.Enabled = radioButtonDurationFixed.Checked; + if (Configuration.Settings.Tools.ImportTextFixedDuration >= numericUpDownDurationFixed.Minimum && + Configuration.Settings.Tools.ImportTextFixedDuration <= numericUpDownDurationFixed.Maximum) + { + numericUpDownDurationFixed.Value = Configuration.Settings.Tools.ImportTextFixedDuration; + } + UiUtil.FixLargeFonts(this, buttonOK); + _refreshTimer.Interval = 400; + _refreshTimer.Tick += RefreshTimerTick; + + if (fileName != null && File.Exists(fileName)) + { + if (!LoadSingleFile(fileName, parentForm)) + { + _exit = true; + } + } + } + + private void RefreshTimerTick(object sender, EventArgs e) + { + _refreshTimer.Stop(); + GeneratePreviewReal(); + } + + private void ButtonOpenTextClick(object sender, EventArgs e) + { + Text = Configuration.Settings.Language.ImportText.Title; + openFileDialog1.Title = buttonOpenText.Text; + if (checkBoxMultipleFiles.Visible && checkBoxMultipleFiles.Checked) + { + openFileDialog1.Filter = Configuration.Settings.Language.ImportText.TextFiles + "|*.txt;*.rtf|" + Configuration.Settings.Language.General.AllFiles + " |*.*"; + } + else + { + openFileDialog1.Filter = Configuration.Settings.Language.ImportText.TextFiles + "|*.txt;*.rtf;*.tx3g;*.astx;*" + new FinalDraftTemplate2().Extension + "|Adobe Story|*.astx|Final Draft Template|*" + new FinalDraftTemplate2().Extension + "|" + Configuration.Settings.Language.General.AllFiles + "|*.*"; + } + + openFileDialog1.FileName = string.Empty; + openFileDialog1.Multiselect = checkBoxMultipleFiles.Visible && checkBoxMultipleFiles.Checked; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + groupBoxImportOptions.Visible = true; + _startFromNumber = 1; + if (checkBoxMultipleFiles.Visible && checkBoxMultipleFiles.Checked) + { + foreach (var fileName in openFileDialog1.FileNames) + { + AddInputFile(fileName); + } + } + else + { + LoadSingleFile(openFileDialog1.FileName, this); + } + GeneratePreview(); + } + } + + private bool LoadSingleFile(string fileName, Form parentForm) + { + groupBoxSplitting.Enabled = true; + textBoxText.Enabled = true; + Format = null; + string ext = string.Empty; + var extension = Path.GetExtension(fileName); + _fileName = fileName; + if (extension != null) + { + ext = extension.ToLowerInvariant(); + } + + var fd = new FinalDraftTemplate2(); + var list = new List(FileUtil.ReadAllLinesShared(fileName, LanguageAutoDetect.GetEncodingFromFile(fileName))); + bool isFinalDraft = fd.IsMine(list, fileName); + + if (ext == ".astx") + { + LoadAdobeStory(fileName); + } + else if (isFinalDraft) + { + return LoadFinalDraftTemplate(fileName, parentForm ?? this); + } + else if (ext == ".tx3g" && new Tx3GTextOnly().IsMine(null, fileName)) + { + LoadTx3G(fileName); + } + else if (ext == ".rtf" && FileUtil.IsRtf(fileName)) + { + LoadRtf(fileName); + } + else if (ext == ".html" && IsHtmlIndexExportFromSubtitleEdit(fileName)) + { + textBoxText.Text = FileUtil.ReadAllTextShared(fileName, Encoding.UTF8); + Text = Configuration.Settings.Language.ImportText.Title + " - " + fileName; + GeneratePreview(); + groupBoxImportOptions.Visible = false; + } + else + { + LoadTextFile(fileName); + } + return true; + } + + private static bool IsHtmlIndexExportFromSubtitleEdit(string fileName) + { + if (string.IsNullOrEmpty(fileName)) + { + return false; + } + + var html = FileUtil.ReadAllTextShared(fileName, Encoding.UTF8); + var s = GetSubtitleFromHtmlIndex(html); + return s.Paragraphs.Count > 0; + } + + private static Subtitle GetSubtitleFromHtmlIndex(string html) + { + var lines = html + .Replace($"
{Environment.NewLine}", "
") + .Replace("
\\n", "
") + .SplitToLines(); + + // A line will look like this: #1:4:06,288->4:09,375

My mommy always said
there were no monsters.


+ var subtitle = new Subtitle(); + foreach (var line in lines) + { + var indexOfText = line.IndexOf("background-color:", StringComparison.OrdinalIgnoreCase); + if (indexOfText >= 0) + { + indexOfText = line.IndexOf('>', indexOfText); + } + + var indexOfFirstColon = line.IndexOf(':'); + var indexOfTimeSplit = line.IndexOf("->", StringComparison.Ordinal); + var indexOfFirstDiv = line.IndexOf(" 0 && indexOfFirstColon > 0 && indexOfTimeSplit > 0 && indexOfFirstDiv > 0) + { + var start = line.Substring(indexOfFirstColon + 1, indexOfTimeSplit - indexOfFirstColon - 1); + var end = line.Substring(indexOfTimeSplit + 2, indexOfFirstDiv - indexOfTimeSplit - 2); + var text = line.Substring(indexOfText + 1) + .Replace("
", string.Empty) + .Replace("
", string.Empty) + .Replace("
", string.Empty) + .Replace("
", string.Empty) + .Replace("
", Environment.NewLine) + .Replace("
", Environment.NewLine) + .Trim(); + text = WebUtility.HtmlDecode(text); + var p = new Paragraph(text, DecodeTimeCode(start), DecodeTimeCode(end)); + subtitle.Paragraphs.Add(p); + } + } + subtitle.Renumber(); + return subtitle; + } + + private static double DecodeTimeCode(string tc) + { + var parts = tc.Split(',', '.', ':'); + try + { + if (parts.Length == 2) + { + return new TimeCode(0, 0, int.Parse(parts[0]), int.Parse(parts[1])).TotalMilliseconds; + } + if (parts.Length == 3) + { + return new TimeCode(0, int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2])).TotalMilliseconds; + } + if (parts.Length == 4) + { + return new TimeCode(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])).TotalMilliseconds; + } + } + catch + { + return 0; + } + return 0; + } + + private void GeneratePreview() + { + if (radioButtonSplitAtBlankLines.Checked || radioButtonLineMode.Checked) + { + groupBoxAutoSplitSettings.Visible = false; + groupBoxAutoSplitSettings.SendToBack(); + checkBoxMergeShortLines.Enabled = true; + checkBoxRemoveEmptyLines.Enabled = true; + checkBoxAutoBreak.Enabled = true; + checkBoxAutoBreak.Text = Configuration.Settings.Language.Settings.MainTextBoxAutoBreak; + } + else // auto split + { + groupBoxAutoSplitSettings.Visible = true; + groupBoxAutoSplitSettings.BringToFront(); + checkBoxMergeShortLines.Enabled = false; + checkBoxRemoveEmptyLines.Enabled = false; + checkBoxAutoBreak.Enabled = true; + } + + if (_refreshTimer.Enabled) + { + _refreshTimer.Stop(); + } + + _refreshTimer.Start(); + } + + private void GeneratePreviewReal() + { + if (IsHtmlIndexExportFromSubtitleEdit(_fileName)) + { + groupBoxImportOptions.Visible = false; + var html = FileUtil.ReadAllTextShared(_fileName, Encoding.UTF8); + FixedSubtitle = GetSubtitleFromHtmlIndex(html); + groupBoxImportResult.Text = string.Format(Configuration.Settings.Language.ImportText.PreviewLinesModifiedX, FixedSubtitle.Paragraphs.Count); + SubtitleListview1.Fill(FixedSubtitle); + SubtitleListview1.SelectIndexAndEnsureVisible(0); + return; + } + + groupBoxImportOptions.Visible = true; + if (Format == null || Format.GetType() != typeof(CsvNuendo)) + { + FixedSubtitle = new Subtitle(); + if (checkBoxMultipleFiles.Visible && checkBoxMultipleFiles.Checked) + { + ImportMultipleFiles(listViewInputFiles.Items); + } + else if (radioButtonLineMode.Checked) + { + ImportLineMode(textBoxText.Lines); + } + else if (radioButtonAutoSplit.Checked) + { + ImportAutoSplit(textBoxText.Lines); + } + else + { + ImportSplitAtBlankLine(textBoxText.Lines); + } + } + else + { + FixedSubtitle = new Subtitle(_subtitleInput); + if (checkBoxAutoBreak.Enabled && checkBoxAutoBreak.Checked) + { + foreach (var p in FixedSubtitle.Paragraphs) + { + p.Text = Utilities.AutoBreakLine(p.Text); + } + } + } + + if (checkBoxMergeShortLines.Checked) + { + MergeLinesWithContinuation(); + } + + FixedSubtitle.Renumber(_startFromNumber); + if (checkBoxGenerateTimeCodes.Checked && checkBoxTakeTimeFromFileNames.Visible && checkBoxTakeTimeFromFileNames.Checked) + { + // time codes already generated + } + else if (checkBoxGenerateTimeCodes.Checked) + { + FixDurations(); + MakePseudoStartTime(); + } + else + { + foreach (var p in FixedSubtitle.Paragraphs) + { + p.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + p.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + } + } + + groupBoxImportResult.Text = string.Format(Configuration.Settings.Language.ImportText.PreviewLinesModifiedX, FixedSubtitle.Paragraphs.Count); + SubtitleListview1.Fill(FixedSubtitle); + SubtitleListview1.SelectIndexAndEnsureVisible(0); + } + + private void ImportMultipleFiles(ListView.ListViewItemCollection listViewItemCollection) + { + foreach (ListViewItem item in listViewItemCollection) + { + string line; + try + { + line = GetAllText(item.Text).Trim(); + } + catch + { + line = string.Empty; + } + + line = line.Replace("|", Environment.NewLine); + if (comboBoxLineBreak.Text.Length > 0) + { + foreach (var splitter in comboBoxLineBreak.Text.Split(';')) + { + var tempSplitter = splitter.Trim(); + if (tempSplitter.Length > 0) + { + line = line.Replace(tempSplitter, Environment.NewLine); + } + } + } + + if (string.IsNullOrWhiteSpace(line)) + { + if (!checkBoxRemoveEmptyLines.Checked) + { + FixedSubtitle.Paragraphs.Add(new Paragraph()); + ImportImages.SetEndTimeAndStartTime(Path.GetFileNameWithoutExtension(item.Text), FixedSubtitle.Paragraphs.Last()); + } + } + else if (!PlainTextImporter.ContainsLetters(line)) + { + if (!checkBoxRemoveLinesWithoutLetters.Checked) + { + FixedSubtitle.Paragraphs.Add(new Paragraph(line.Trim(), 0, 0)); + ImportImages.SetEndTimeAndStartTime(Path.GetFileNameWithoutExtension(item.Text), FixedSubtitle.Paragraphs.Last()); + } + } + else + { + FixedSubtitle.Paragraphs.Add(new Paragraph(line.Trim(), 0, 0)); + ImportImages.SetEndTimeAndStartTime(Path.GetFileNameWithoutExtension(item.Text), FixedSubtitle.Paragraphs.Last()); + } + } + } + + private void MergeLinesWithContinuation() + { + var temp = new Subtitle(); + bool skipNext = false; + for (int i = 0; i < FixedSubtitle.Paragraphs.Count; i++) + { + Paragraph p = FixedSubtitle.Paragraphs[i]; + if (!skipNext) + { + Paragraph next = FixedSubtitle.GetParagraphOrDefault(i + 1); + + bool merge = !(p.Text.Contains(Environment.NewLine) || next == null) && Configuration.Settings.General.MaxNumberOfLines > 1; + + if (merge && (p.Text.TrimEnd().EndsWith('!') || p.Text.TrimEnd().EndsWith('.'))) + { + var st = new StrippableText(p.Text); + if (st.StrippedText.Length > 0 && char.IsUpper(st.StrippedText[0])) + { + merge = false; + } + } + + if (merge && (p.Text.Length >= Configuration.Settings.General.SubtitleLineMaximumLength - 5 || next.Text.Length >= Configuration.Settings.General.SubtitleLineMaximumLength - 5)) + { + merge = false; + } + + if (merge) + { + temp.Paragraphs.Add(new Paragraph { Text = p.Text + Environment.NewLine + next.Text }); + skipNext = true; + } + else + { + temp.Paragraphs.Add(new Paragraph(p)); + } + } + else + { + skipNext = false; + } + } + FixedSubtitle = temp; + } + + private void MakePseudoStartTime() + { + var millisecondsInterval = (double)numericUpDownGapBetweenLines.Value; + double millisecondsIndex = millisecondsInterval; + foreach (Paragraph p in FixedSubtitle.Paragraphs) + { + p.EndTime.TotalMilliseconds = millisecondsIndex + p.Duration.TotalMilliseconds; + p.StartTime.TotalMilliseconds = millisecondsIndex; + millisecondsIndex += (p.EndTime.TotalMilliseconds - p.StartTime.TotalMilliseconds) + millisecondsInterval; + } + } + + private void FixDurations() + { + foreach (Paragraph p in FixedSubtitle.Paragraphs) + { + if (p.Text.Length == 0) + { + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 2000; + } + else + { + if (radioButtonDurationAuto.Checked) + { + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + (Utilities.GetOptimalDisplayMilliseconds(p.Text)); + } + else + { + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + ((double)numericUpDownDurationFixed.Value); + } + } + } + } + + private void ImportLineMode(IEnumerable lines) + { + var item = new List(); + foreach (string loopLine in lines) + { + // Replace user line break character with Environment.NewLine. + string line = loopLine; + if (comboBoxLineBreak.Text.Length > 0) + { + foreach (string splitter in comboBoxLineBreak.Text.Split(';')) + { + var tempSplitter = splitter.Trim(); + if (tempSplitter.Length > 0) + { + line = line.Replace(tempSplitter, Environment.NewLine); + } + } + } + + if (string.IsNullOrWhiteSpace(line)) + { + if (!checkBoxRemoveEmptyLines.Checked) + { + item.Add(string.Empty); + } + } + else if (!PlainTextImporter.ContainsLetters(line)) + { + if (!checkBoxRemoveLinesWithoutLetters.Checked) + { + item.Add(line.Trim()); + } + } + else + { + string text = line.Trim(); + if (checkBoxAutoBreak.Enabled && checkBoxAutoBreak.Checked && comboBoxLineMode.SelectedIndex == 0) + { + text = Utilities.AutoBreakLine(text); + } + + item.Add(text); + } + + if (item.Count >= comboBoxLineMode.SelectedIndex + 1) + { + FixedSubtitle.Paragraphs.Add(new Paragraph { Text = string.Join(Environment.NewLine, item.ToArray()) }); + item.Clear(); + } + } + if (item.Count > 0) + { + FixedSubtitle.Paragraphs.Add(new Paragraph { Text = string.Join(Environment.NewLine, item.ToArray()) }); + } + } + + private void ImportSplitAtBlankLine(IEnumerable lines) + { + var sb = new StringBuilder(); + foreach (string line in lines) + { + if (string.IsNullOrWhiteSpace(line)) + { + if (sb.Length > 0) + { + string text = sb.ToString().Trim(); + if (checkBoxAutoBreak.Enabled && checkBoxAutoBreak.Checked) + { + text = Utilities.AutoBreakLine(text); + } + + FixedSubtitle.Paragraphs.Add(new Paragraph { Text = text }); + sb.Clear(); + } + } + else if (!PlainTextImporter.ContainsLetters(line)) + { + if (!checkBoxRemoveLinesWithoutLetters.Checked) + { + sb.AppendLine(line.Trim()); + } + } + else + { + sb.AppendLine(line.Trim()); + } + } + if (sb.Length > 0) + { + SplitSingle(sb); + } + } + + private static bool CanMakeThreeLiner(out string text, string input) + { + text = string.Empty; + if (input.Length < Configuration.Settings.General.SubtitleLineMaximumLength * 3 && input.Length > Configuration.Settings.General.SubtitleLineMaximumLength * 1.5) + { + var splitLines = Utilities.AutoBreakLine(input).SplitToLines(); + if (splitLines.Count == 2 && (splitLines[0].Length > Configuration.Settings.General.SubtitleLineMaximumLength || splitLines[1].Length > Configuration.Settings.General.SubtitleLineMaximumLength)) + { + var first = new StringBuilder(); + var second = new StringBuilder(); + var third = new StringBuilder(); + foreach (string word in input.Replace(Environment.NewLine, " ").Replace(" ", " ").Split(' ')) + { + if (first.Length + word.Length < Configuration.Settings.General.SubtitleLineMaximumLength) + { + first.Append(' '); + first.Append(word); + } + else if (second.Length + word.Length < Configuration.Settings.General.SubtitleLineMaximumLength) + { + second.Append(' '); + second.Append(word); + } + else + { + third.Append(' '); + third.Append(word); + } + } + if (third.Length <= Configuration.Settings.General.SubtitleLineMaximumLength && third.Length > 10) + { + if (second.Length > 15) + { + string ending = second.ToString().Substring(second.Length - 9); + int splitPos = -1; + if (ending.Contains(". ")) + { + splitPos = ending.IndexOf(". ", StringComparison.Ordinal) + second.Length - 9; + } + else if (ending.Contains("! ")) + { + splitPos = ending.IndexOf("! ", StringComparison.Ordinal) + second.Length - 9; + } + else if (ending.Contains(", ")) + { + splitPos = ending.IndexOf(", ", StringComparison.Ordinal) + second.Length - 9; + } + else if (ending.Contains("? ")) + { + splitPos = ending.IndexOf("? ", StringComparison.Ordinal) + second.Length - 9; + } + + if (splitPos > 0) + { + text = Utilities.AutoBreakLine(first.ToString().Trim() + second.ToString().Substring(0, splitPos + 1)).Trim() + Environment.NewLine + (second.ToString().Substring(splitPos + 1) + third).Trim(); + return true; + } + } + + text = first + Environment.NewLine + second + Environment.NewLine + third; + return true; + } + } + } + return false; + } + + private void SplitSingle(StringBuilder sb) + { + string t = sb.ToString().Trim(); + var tarr = t.SplitToLines(); + if (checkBoxMergeShortLines.Checked == false && tarr.Count == 3 && + tarr[0].Length < Configuration.Settings.General.SubtitleLineMaximumLength && + tarr[1].Length < Configuration.Settings.General.SubtitleLineMaximumLength && + tarr[2].Length < Configuration.Settings.General.SubtitleLineMaximumLength) + { + FixedSubtitle.Paragraphs.Add(new Paragraph { Text = tarr[0] + Environment.NewLine + tarr[1] }); + return; + } + if (checkBoxMergeShortLines.Checked == false && tarr.Count == 2 && + tarr[0].Length < Configuration.Settings.General.SubtitleLineMaximumLength && + tarr[1].Length < Configuration.Settings.General.SubtitleLineMaximumLength) + { + FixedSubtitle.Paragraphs.Add(new Paragraph { Text = tarr[0] + Environment.NewLine + tarr[1] }); + return; + } + if (checkBoxMergeShortLines.Checked == false && tarr.Count == 1 && tarr[0].Length < Configuration.Settings.General.SubtitleLineMaximumLength) + { + FixedSubtitle.Paragraphs.Add(new Paragraph { Text = tarr[0].Trim() }); + return; + } + + Paragraph p = null; + if (CanMakeThreeLiner(out var threeLiner, sb.ToString())) + { + var parts = threeLiner.SplitToLines(); + FixedSubtitle.Paragraphs.Add(new Paragraph { Text = parts[0] + Environment.NewLine + parts[1] }); + FixedSubtitle.Paragraphs.Add(new Paragraph { Text = parts[2].Trim() }); + return; + } + + foreach (string text in Utilities.AutoBreakLineMoreThanTwoLines(sb.ToString(), Configuration.Settings.General.SubtitleLineMaximumLength, Configuration.Settings.General.MergeLinesShorterThan, "en").SplitToLines()) + { + if (p == null) + { + p = new Paragraph { Text = text }; + } + else if (p.Text.Contains(Environment.NewLine)) + { + FixedSubtitle.Paragraphs.Add(p); + p = new Paragraph(); + if (text.Length >= Configuration.Settings.General.SubtitleLineMaximumLength) + { + p.Text = Utilities.AutoBreakLine(text); + } + else + { + p.Text = text; + } + } + else + { + if (checkBoxMergeShortLines.Checked || p.Text.Length > Configuration.Settings.General.SubtitleLineMaximumLength || text.Length > Configuration.Settings.General.SubtitleLineMaximumLength) + { + p.Text = Utilities.AutoBreakLine(p.Text + Environment.NewLine + text.Trim()); + } + else + { + p.Text = p.Text + Environment.NewLine + text.Trim(); + } + } + } + if (p != null) + { + FixedSubtitle.Paragraphs.Add(p); + } + } + + private void ImportAutoSplit(string[] textLines) + { + var sub = new Subtitle(); + foreach (var line in textLines) + { + sub.Paragraphs.Add(new Paragraph(line, 0, 0)); + } + var language = LanguageAutoDetect.AutoDetectGoogleLanguage(sub); + + var plainTextImporter = new PlainTextImporter(checkBoxAutoSplitAtBlankLines.Checked, + checkBoxAutoSplitRemoveLinesNoLetters.Checked, + (int)numericUpDownAutoSplitMaxLines.Value, + checkBoxAutoSplitAtEnd.Checked ? textBoxAsEnd.Text : string.Empty, + (int)numericUpDownSubtitleLineMaximumLength.Value, + language); + + ImportLineMode(plainTextImporter.ImportAutoSplit(textLines)); + } + + private void ButtonOkClick(object sender, EventArgs e) + { + DialogResult = SubtitleListview1.Items.Count > 0 ? DialogResult.OK : DialogResult.Cancel; + } + + private void ButtonCancelClick(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void CheckBoxRemoveLinesWithoutLettersOrNumbersCheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void CheckBoxRemoveEmptyLinesCheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void RadioButtonLineModeCheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + // textBoxLineBreak and its label are enabled if radioButtonLineMode is checked. + comboBoxLineBreak.Enabled = radioButtonLineMode.Checked; + labelLineBreak.Enabled = radioButtonLineMode.Checked; + } + + private void RadioButtonAutoSplitCheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void TextBoxTextDragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.All; + } + } + + private void TextBoxTextDragDrop(object sender, DragEventArgs e) + { + var files = (string[])e.Data.GetData(DataFormats.FileDrop); + if (files.Length == 1) + { + LoadTextFile(files[0]); + } + } + + private static string HtmlToPlainText(string html) + { + var stripFormattingRegex = new Regex(@"<[^>]*(>|$)", RegexOptions.Multiline); // match any character between '<' and '>', even when end tag is missing + var tagWhiteSpaceRegex = new Regex(@"(>|$)(\W|\n|\r)+<", RegexOptions.Multiline); // matches one or more (white space or line breaks) between '>' and '<' + + // Decode html specific characters + var text = WebUtility.HtmlDecode(html); + + // Remove tag whitespace/line breaks + text = tagWhiteSpaceRegex.Replace(text, "><"); + + // Find new lines + text = text.Replace("
", Environment.NewLine); + text = text.Replace("
", Environment.NewLine); + text = text.Replace("
", Environment.NewLine); + text = text.Replace("
", Environment.NewLine); + text = text.Replace("
", Environment.NewLine + Environment.NewLine); + text = text.Replace("
", Environment.NewLine + Environment.NewLine); + text = text.Replace("
", Environment.NewLine + Environment.NewLine); + text = text.Replace("
", Environment.NewLine + Environment.NewLine); + text = text.Replace("

", Environment.NewLine + Environment.NewLine); + text = text.Replace("

", Environment.NewLine + Environment.NewLine); + text = text.Replace(Environment.NewLine + Environment.NewLine + Environment.NewLine, Environment.NewLine + Environment.NewLine); + text = text.Replace(Environment.NewLine + Environment.NewLine + Environment.NewLine, Environment.NewLine + Environment.NewLine); + + text = stripFormattingRegex.Replace(text, string.Empty); + + return text; + } + + private static string GetAllText(string fileName) + { + try + { + var encoding = LanguageAutoDetect.GetEncodingFromFile(fileName); + var text = FileUtil.ReadAllTextShared(fileName, encoding); + if (fileName.EndsWith(".html", StringComparison.OrdinalIgnoreCase) || fileName.EndsWith(".htm", StringComparison.OrdinalIgnoreCase)) + { + text = HtmlToPlainText(text); + } + if (fileName.EndsWith(".rtf", StringComparison.OrdinalIgnoreCase)) + { + text = GetRtfString(fileName); + } + + return text; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + return string.Empty; + } + } + + private void LoadTextFile(string fileName) + { + textBoxText.Text = GetAllText(fileName); + SetVideoFileName(fileName); + Text = Configuration.Settings.Language.ImportText.Title + " - " + fileName; + GeneratePreview(); + } + + private void LoadTx3G(string fileName) + { + try + { + var sb = new StringBuilder(); + var sub = new Subtitle(); + new Tx3GTextOnly().LoadSubtitle(sub, null, fileName); + foreach (var paragraph in sub.Paragraphs) + { + sb.AppendLine(paragraph.Text); + sb.AppendLine(); + } + textBoxText.Text = sb.ToString(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + radioButtonSplitAtBlankLines.Checked = true; + checkBoxMergeShortLines.Checked = false; + GeneratePreview(); + } + + private void LoadRtf(string fileName) + { + try + { + labelStatus.Text = Configuration.Settings.Language.General.PleaseWait; + labelStatus.Refresh(); + textBoxText.Text = GetRtfString(fileName); + SetVideoFileName(fileName); + Text = Configuration.Settings.Language.ImportText.Title + " - " + fileName; + GeneratePreview(); + } + finally + { + labelStatus.Text = string.Empty; + } + } + + private static string GetRtfString(string fileName) + { + const int bomHeaderLength = 3; + var encoding = FileUtil.HasUtf8Bom(fileName) ? Encoding.UTF8 : Encoding.ASCII; + var bytes = FileUtil.ReadAllBytesShared(fileName); + var rtf = encoding.GetString(bytes); + if (Equals(encoding, Encoding.UTF8)) + { + rtf = encoding.GetString(bytes, bomHeaderLength, bytes.Length - bomHeaderLength); + } + + using (var rtb = new RichTextBox { Rtf = rtf }) + { + var sb = new StringBuilder(); + bool italicOn = false; + bool boldOn = false; + bool underlineOn = false; + for (int i = 0; i < rtb.TextLength; i++) + { + rtb.SelectionStart = i; + rtb.SelectionLength = 1; + if (rtb.SelectionFont.Italic && !italicOn) + { + sb.Append(""); + italicOn = true; + } + + if (rtb.SelectionFont.Bold && !boldOn) + { + sb.Append(""); + boldOn = true; + } + + if (rtb.SelectionFont.Underline && !underlineOn) + { + sb.Append(""); + underlineOn = true; + } + + if (!rtb.SelectionFont.Underline && underlineOn) + { + sb.Append(""); + underlineOn = false; + } + + if (!rtb.SelectionFont.Bold && boldOn) + { + sb.Append(""); + boldOn = false; + } + + if (!rtb.SelectionFont.Italic && italicOn) + { + sb.Append(""); + italicOn = false; + } + + sb.Append(rtb.SelectedText); + } + + if (underlineOn) + { + sb.Append("
"); + } + + if (boldOn) + { + sb.Append("
"); + } + + if (italicOn) + { + sb.Append("
"); + } + + return string.Join(Environment.NewLine, sb.ToString().SplitToLines()) + .Replace($" {Environment.NewLine}", Environment.NewLine) + .Replace(" ", " ") + .Replace(" ", " ") + .Replace(" ", " ") + .Replace($"{Environment.NewLine}", Environment.NewLine) + .Replace($"{Environment.NewLine}", Environment.NewLine) + .Replace($"{Environment.NewLine}", Environment.NewLine) + .Replace($"{Environment.NewLine}", Environment.NewLine) + .Replace($"{Environment.NewLine}", Environment.NewLine) + .Replace($"{Environment.NewLine}", Environment.NewLine) + .Replace($"{Environment.NewLine}", Environment.NewLine); + } + } + + private void LoadAdobeStory(string fileName) + { + try + { + var sb = new StringBuilder(); + var doc = new XmlDocument(); + doc.Load(fileName); + var nodes = doc.DocumentElement?.SelectNodes("//paragraph[@element='Dialog']"); + if (nodes != null) + { + foreach (XmlNode node in nodes) // + { + XmlNode textRun = node.SelectSingleNode("textRun"); // Yeah...I suppose + if (textRun != null) + { + sb.AppendLine(textRun.InnerText); + } + } + } + + textBoxText.Text = sb.ToString(); + VideoFileName = null; + Text = Configuration.Settings.Language.ImportText.Title + " - " + fileName; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + radioButtonLineMode.Checked = true; + checkBoxMergeShortLines.Checked = false; + GeneratePreview(); + } + + private bool LoadFinalDraftTemplate(string fileName, Form parentForm) + { + try + { + var fd = new FinalDraftTemplate2(); + var sub = new Subtitle(); + var lines = Encoding.UTF8.GetString(FileUtil.ReadAllBytesShared(fileName)).SplitToLines(); + var availableParagraphTypes = fd.GetParagraphTypes(lines); + using (var form = new ImportFinalDraft(availableParagraphTypes)) + { + if (form.ShowDialog(parentForm) == DialogResult.OK) + { + fd.ActiveParagraphTypes = form.ChosenParagraphTypes; + fd.LoadSubtitle(sub, lines, fileName); + } + else + { + return false; + } + } + + textBoxText.Text = sub.ToText(fd); + VideoFileName = null; + Text = Configuration.Settings.Language.ImportText.Title + " - " + fileName; + _subtitleInput = sub; + Format = new CsvNuendo(); + groupBoxSplitting.Enabled = false; + textBoxText.Enabled = false; + if (_subtitleInput.Paragraphs.Any(p => !string.IsNullOrEmpty(p.Actor))) + { + SubtitleListview1.ShowActorColumn(Configuration.Settings.Language.General.Character); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + radioButtonLineMode.Checked = true; + checkBoxMergeShortLines.Checked = false; + GeneratePreview(); + return true; + } + + private void SetVideoFileName(string fileName) + { + VideoFileName = fileName.Substring(0, fileName.Length - Path.GetExtension(fileName).Length); + if (VideoFileName.EndsWith(".en", StringComparison.Ordinal)) + { + VideoFileName = VideoFileName.Remove(VideoFileName.Length - 3); + } + + foreach (var ext in Utilities.VideoFileExtensions) + { + if (File.Exists(VideoFileName + ext)) + { + VideoFileName += ext; + return; + } + } + + var dir = Path.GetDirectoryName(fileName); + if (dir != null) + { + foreach (var ext in Utilities.VideoFileExtensions) + { + var files = Directory.GetFiles(dir, Path.GetFileNameWithoutExtension(VideoFileName) + "*" + ext); + if (files.Length > 0) + { + VideoFileName = files[0]; + return; + } + } + VideoFileName = null; + } + } + + private void ButtonRefreshClick(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void RadioButtonDurationFixedCheckedChanged(object sender, EventArgs e) + { + numericUpDownDurationFixed.Enabled = radioButtonDurationFixed.Checked; + GeneratePreview(); + } + + private void CheckBoxMergeShortLinesCheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void ImportTextKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void TextBoxTextTextChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void NumericUpDownDurationFixedValueChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void NumericUpDownGapBetweenLinesValueChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void RadioButtonDurationAutoCheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void radioButtonSplitAtBlankLines_CheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void checkBoxGenerateTimeCodes_CheckedChanged(object sender, EventArgs e) + { + groupBoxTimeCodes.Enabled = checkBoxGenerateTimeCodes.Checked; + GeneratePreview(); + } + + private void ImportText_FormClosing(object sender, FormClosingEventArgs e) + { + if (radioButtonSplitAtBlankLines.Checked) + { + Configuration.Settings.Tools.ImportTextSplitting = "blank lines"; + } + else if (radioButtonLineMode.Checked) + { + Configuration.Settings.Tools.ImportTextSplitting = "line"; + } + else + { + Configuration.Settings.Tools.ImportTextSplitting = "auto"; + } + + Configuration.Settings.Tools.ImportTextLineBreak = comboBoxLineBreak.Text.Trim(); + Configuration.Settings.Tools.ImportTextMergeShortLines = checkBoxMergeShortLines.Checked; + Configuration.Settings.Tools.ImportTextRemoveEmptyLines = checkBoxRemoveEmptyLines.Checked; + Configuration.Settings.Tools.ImportTextAutoSplitNumberOfLines = numericUpDownAutoSplitMaxLines.Value; + Configuration.Settings.Tools.ImportTextAutoSplitAtBlank = checkBoxAutoSplitAtBlankLines.Checked; + + if (radioButtonAutoSplit.Checked) + { + Configuration.Settings.Tools.ImportTextRemoveLinesNoLetters = checkBoxAutoSplitRemoveLinesNoLetters.Checked; + } + else + { + Configuration.Settings.Tools.ImportTextRemoveLinesNoLetters = checkBoxRemoveLinesWithoutLetters.Checked; + } + + Configuration.Settings.Tools.ImportTextGenerateTimeCodes = checkBoxGenerateTimeCodes.Checked; + Configuration.Settings.Tools.ImportTextTakeTimeCodeFromFileName = checkBoxTakeTimeFromFileNames.Checked; + Configuration.Settings.Tools.ImportTextAutoBreak = checkBoxAutoBreak.Checked; + Configuration.Settings.Tools.ImportTextAutoBreakAtEnd = checkBoxAutoSplitAtEnd.Checked; + Configuration.Settings.Tools.ImportTextAutoBreakAtEndMarkerText = textBoxAsEnd.Text.Replace(" ", string.Empty); + Configuration.Settings.Tools.ImportTextGap = numericUpDownGapBetweenLines.Value; + Configuration.Settings.Tools.ImportTextDurationAuto = radioButtonDurationAuto.Checked; + Configuration.Settings.Tools.ImportTextFixedDuration = numericUpDownDurationFixed.Value; + } + + private void checkBoxMultipleFiles_CheckedChanged(object sender, EventArgs e) + { + Format = null; + textBoxText.Enabled = true; + groupBoxSplitting.Enabled = true; + if (checkBoxMultipleFiles.Checked) + { + listViewInputFiles.Visible = true; + textBoxText.Visible = false; + buttonOpenText.Text = Configuration.Settings.Language.ImportText.OpenTextFiles; + groupBoxSplitting.Enabled = false; + checkBoxTakeTimeFromFileNames.Visible = true; + } + else + { + listViewInputFiles.Visible = false; + textBoxText.Visible = true; + buttonOpenText.Text = Configuration.Settings.Language.ImportText.OpenTextFile; + groupBoxSplitting.Enabled = true; + checkBoxTakeTimeFromFileNames.Visible = false; + } + GeneratePreview(); + } + + private void listViewInputFiles_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.All; + } + } + + private void listViewInputFiles_DragDrop(object sender, DragEventArgs e) + { + var fileNames = (string[])e.Data.GetData(DataFormats.FileDrop); + foreach (string fileName in fileNames.OrderBy(p => p)) + { + AddInputFile(fileName); + } + GeneratePreview(); + } + + private void AddInputFile(string fileName) + { + try + { + var fi = new FileInfo(fileName); + var item = new ListViewItem(fileName) { Tag = fileName }; + item.SubItems.Add(Utilities.FormatBytesToDisplayFileSize(fi.Length)); + if (fi.Length < 1024 * 1024) // max 1 mb + { + listViewInputFiles.Items.Add(item); + } + } + catch + { + // ignored + } + } + + private void checkBoxAutoBreak_CheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void comboBoxLineBreak_TextChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void clearToolStripMenuItem_Click(object sender, EventArgs e) + { + listViewInputFiles.Items.Clear(); + } + + private void ImportText_Shown(object sender, EventArgs e) + { + if (textBoxText.Visible && textBoxText.Text.Length > 20) + { + buttonOK.Focus(); + } + + if (_exit) + { + DialogResult = DialogResult.Cancel; + } + + var workingArea = Screen.FromControl(this).WorkingArea; + if (workingArea.Height < Height) + { + Height = Math.Max(workingArea.Height, MinimumSize.Height); + } + } + + private void startNumberingFromToolStripMenuItem_Click(object sender, EventArgs e) + { + using (var startNumberingFrom = new StartNumberingFrom()) + { + if (startNumberingFrom.ShowDialog(this) == DialogResult.OK) + { + _startFromNumber = startNumberingFrom.StartFromNumber; + FixedSubtitle.Renumber(startNumberingFrom.StartFromNumber); + SubtitleListview1.Fill(FixedSubtitle); + } + } + } + + private void numericUpDownAutoSplitMaxLines_ValueChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void textBoxAsEnd1_TextChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void checkBoxAutoSplitAtBlankLines_CheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void checkBoxAutoSplitRemoveLinesNoLetters_CheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void textBoxAsEnd1_KeyPress(object sender, KeyPressEventArgs e) + { + if (e.KeyChar == (char)Keys.Space || char.IsLetterOrDigit(e.KeyChar)) + { + e.Handled = true; + } + } + + private void numericUpDownSubtitleLineMaximumLength_ValueChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void comboBoxLineMode_SelectedIndexChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void checkBoxAutoSplitAtEnd_CheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + } } \ No newline at end of file diff --git a/src/Forms/ImportText.resx b/src/ui/Forms/ImportText.resx similarity index 98% rename from src/Forms/ImportText.resx rename to src/ui/Forms/ImportText.resx index a9db14b14..8da7d2fda 100644 --- a/src/Forms/ImportText.resx +++ b/src/ui/Forms/ImportText.resx @@ -1,129 +1,129 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 157, 17 - - - 350, 17 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 157, 17 + + + 350, 17 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/ImportUnknownFormat.Designer.cs b/src/ui/Forms/ImportUnknownFormat.Designer.cs similarity index 98% rename from src/Forms/ImportUnknownFormat.Designer.cs rename to src/ui/Forms/ImportUnknownFormat.Designer.cs index cf6e001f8..4ddc2e755 100644 --- a/src/Forms/ImportUnknownFormat.Designer.cs +++ b/src/ui/Forms/ImportUnknownFormat.Designer.cs @@ -1,266 +1,266 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class ImportUnknownFormat - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxImportResult = new System.Windows.Forms.GroupBox(); - this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.groupBoxImportOptions = new System.Windows.Forms.GroupBox(); - this.groupBoxTimeCodes = new System.Windows.Forms.GroupBox(); - this.radioButton1 = new System.Windows.Forms.RadioButton(); - this.radioButtonMilliseconds = new System.Windows.Forms.RadioButton(); - this.radioButtonTimeCodeFrames = new System.Windows.Forms.RadioButton(); - this.buttonRefresh = new System.Windows.Forms.Button(); - this.groupBoxImportText = new System.Windows.Forms.GroupBox(); - this.textBoxText = new System.Windows.Forms.TextBox(); - this.buttonOpenText = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.groupBoxImportResult.SuspendLayout(); - this.groupBoxImportOptions.SuspendLayout(); - this.groupBoxTimeCodes.SuspendLayout(); - this.groupBoxImportText.SuspendLayout(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(858, 603); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 9; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(777, 603); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 8; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // groupBoxImportResult - // - this.groupBoxImportResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxImportResult.Controls.Add(this.SubtitleListview1); - this.groupBoxImportResult.Location = new System.Drawing.Point(12, 369); - this.groupBoxImportResult.Name = "groupBoxImportResult"; - this.groupBoxImportResult.Size = new System.Drawing.Size(921, 228); - this.groupBoxImportResult.TabIndex = 7; - this.groupBoxImportResult.TabStop = false; - this.groupBoxImportResult.Text = "Preview"; - // - // SubtitleListview1 - // - this.SubtitleListview1.AllowColumnReorder = true; - this.SubtitleListview1.AllowDrop = true; - this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.SubtitleListview1.FirstVisibleIndex = -1; - this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.SubtitleListview1.FullRowSelect = true; - this.SubtitleListview1.GridLines = true; - this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.SubtitleListview1.HideSelection = false; - this.SubtitleListview1.Location = new System.Drawing.Point(6, 19); - this.SubtitleListview1.MultiSelect = false; - this.SubtitleListview1.Name = "SubtitleListview1"; - this.SubtitleListview1.OwnerDraw = true; - this.SubtitleListview1.Size = new System.Drawing.Size(909, 187); - this.SubtitleListview1.SubtitleFontBold = false; - this.SubtitleListview1.SubtitleFontName = "Tahoma"; - this.SubtitleListview1.SubtitleFontSize = 8; - this.SubtitleListview1.TabIndex = 0; - this.SubtitleListview1.UseCompatibleStateImageBehavior = false; - this.SubtitleListview1.UseSyntaxColoring = true; - this.SubtitleListview1.View = System.Windows.Forms.View.Details; - // - // groupBoxImportOptions - // - this.groupBoxImportOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxImportOptions.Controls.Add(this.groupBoxTimeCodes); - this.groupBoxImportOptions.Controls.Add(this.buttonRefresh); - this.groupBoxImportOptions.Location = new System.Drawing.Point(586, 12); - this.groupBoxImportOptions.Name = "groupBoxImportOptions"; - this.groupBoxImportOptions.Size = new System.Drawing.Size(341, 351); - this.groupBoxImportOptions.TabIndex = 6; - this.groupBoxImportOptions.TabStop = false; - this.groupBoxImportOptions.Text = "Import options"; - // - // groupBoxTimeCodes - // - this.groupBoxTimeCodes.Controls.Add(this.radioButton1); - this.groupBoxTimeCodes.Controls.Add(this.radioButtonMilliseconds); - this.groupBoxTimeCodes.Controls.Add(this.radioButtonTimeCodeFrames); - this.groupBoxTimeCodes.Location = new System.Drawing.Point(6, 19); - this.groupBoxTimeCodes.Name = "groupBoxTimeCodes"; - this.groupBoxTimeCodes.Size = new System.Drawing.Size(329, 99); - this.groupBoxTimeCodes.TabIndex = 5; - this.groupBoxTimeCodes.TabStop = false; - this.groupBoxTimeCodes.Text = "Time codes"; - // - // radioButton1 - // - this.radioButton1.AutoSize = true; - this.radioButton1.Checked = true; - this.radioButton1.Location = new System.Drawing.Point(14, 65); - this.radioButton1.Name = "radioButton1"; - this.radioButton1.Size = new System.Drawing.Size(51, 17); - this.radioButton1.TabIndex = 5; - this.radioButton1.TabStop = true; - this.radioButton1.Text = "Other"; - this.radioButton1.UseVisualStyleBackColor = true; - // - // radioButtonMilliseconds - // - this.radioButtonMilliseconds.AutoSize = true; - this.radioButtonMilliseconds.Location = new System.Drawing.Point(14, 42); - this.radioButtonMilliseconds.Name = "radioButtonMilliseconds"; - this.radioButtonMilliseconds.Size = new System.Drawing.Size(82, 17); - this.radioButtonMilliseconds.TabIndex = 4; - this.radioButtonMilliseconds.Text = "Milliseconds"; - this.radioButtonMilliseconds.UseVisualStyleBackColor = true; - // - // radioButtonTimeCodeFrames - // - this.radioButtonTimeCodeFrames.AutoSize = true; - this.radioButtonTimeCodeFrames.Location = new System.Drawing.Point(14, 19); - this.radioButtonTimeCodeFrames.Name = "radioButtonTimeCodeFrames"; - this.radioButtonTimeCodeFrames.Size = new System.Drawing.Size(59, 17); - this.radioButtonTimeCodeFrames.TabIndex = 3; - this.radioButtonTimeCodeFrames.Text = "Frames"; - this.radioButtonTimeCodeFrames.UseVisualStyleBackColor = true; - // - // buttonRefresh - // - this.buttonRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRefresh.Location = new System.Drawing.Point(6, 124); - this.buttonRefresh.Name = "buttonRefresh"; - this.buttonRefresh.Size = new System.Drawing.Size(102, 23); - this.buttonRefresh.TabIndex = 6; - this.buttonRefresh.Text = "Refresh"; - this.buttonRefresh.UseVisualStyleBackColor = true; - this.buttonRefresh.Click += new System.EventHandler(this.buttonRefresh_Click); - // - // groupBoxImportText - // - this.groupBoxImportText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxImportText.Controls.Add(this.textBoxText); - this.groupBoxImportText.Controls.Add(this.buttonOpenText); - this.groupBoxImportText.Location = new System.Drawing.Point(12, 12); - this.groupBoxImportText.Name = "groupBoxImportText"; - this.groupBoxImportText.Size = new System.Drawing.Size(568, 351); - this.groupBoxImportText.TabIndex = 5; - this.groupBoxImportText.TabStop = false; - this.groupBoxImportText.Text = "Import text"; - // - // textBoxText - // - this.textBoxText.AllowDrop = true; - this.textBoxText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxText.Location = new System.Drawing.Point(6, 42); - this.textBoxText.MaxLength = 0; - this.textBoxText.Multiline = true; - this.textBoxText.Name = "textBoxText"; - this.textBoxText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxText.Size = new System.Drawing.Size(556, 303); - this.textBoxText.TabIndex = 1; - // - // buttonOpenText - // - this.buttonOpenText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOpenText.Location = new System.Drawing.Point(419, 15); - this.buttonOpenText.Name = "buttonOpenText"; - this.buttonOpenText.Size = new System.Drawing.Size(143, 23); - this.buttonOpenText.TabIndex = 0; - this.buttonOpenText.Text = "Open file..."; - this.buttonOpenText.UseVisualStyleBackColor = true; - this.buttonOpenText.Click += new System.EventHandler(this.buttonOpenText_Click); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // ImportUnknownFormat - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(945, 636); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.groupBoxImportResult); - this.Controls.Add(this.groupBoxImportOptions); - this.Controls.Add(this.groupBoxImportText); - this.KeyPreview = true; - this.MinimumSize = new System.Drawing.Size(900, 600); - this.Name = "ImportUnknownFormat"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "ImportUnknownFormat"; - this.groupBoxImportResult.ResumeLayout(false); - this.groupBoxImportOptions.ResumeLayout(false); - this.groupBoxTimeCodes.ResumeLayout(false); - this.groupBoxTimeCodes.PerformLayout(); - this.groupBoxImportText.ResumeLayout(false); - this.groupBoxImportText.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.GroupBox groupBoxImportResult; - private Controls.SubtitleListView SubtitleListview1; - private System.Windows.Forms.GroupBox groupBoxImportOptions; - private System.Windows.Forms.GroupBox groupBoxTimeCodes; - private System.Windows.Forms.Button buttonRefresh; - private System.Windows.Forms.GroupBox groupBoxImportText; - private System.Windows.Forms.TextBox textBoxText; - private System.Windows.Forms.Button buttonOpenText; - private System.Windows.Forms.RadioButton radioButtonTimeCodeFrames; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.RadioButton radioButton1; - private System.Windows.Forms.RadioButton radioButtonMilliseconds; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class ImportUnknownFormat + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxImportResult = new System.Windows.Forms.GroupBox(); + this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.groupBoxImportOptions = new System.Windows.Forms.GroupBox(); + this.groupBoxTimeCodes = new System.Windows.Forms.GroupBox(); + this.radioButton1 = new System.Windows.Forms.RadioButton(); + this.radioButtonMilliseconds = new System.Windows.Forms.RadioButton(); + this.radioButtonTimeCodeFrames = new System.Windows.Forms.RadioButton(); + this.buttonRefresh = new System.Windows.Forms.Button(); + this.groupBoxImportText = new System.Windows.Forms.GroupBox(); + this.textBoxText = new System.Windows.Forms.TextBox(); + this.buttonOpenText = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.groupBoxImportResult.SuspendLayout(); + this.groupBoxImportOptions.SuspendLayout(); + this.groupBoxTimeCodes.SuspendLayout(); + this.groupBoxImportText.SuspendLayout(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(858, 603); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 9; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(777, 603); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 8; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // groupBoxImportResult + // + this.groupBoxImportResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImportResult.Controls.Add(this.SubtitleListview1); + this.groupBoxImportResult.Location = new System.Drawing.Point(12, 369); + this.groupBoxImportResult.Name = "groupBoxImportResult"; + this.groupBoxImportResult.Size = new System.Drawing.Size(921, 228); + this.groupBoxImportResult.TabIndex = 7; + this.groupBoxImportResult.TabStop = false; + this.groupBoxImportResult.Text = "Preview"; + // + // SubtitleListview1 + // + this.SubtitleListview1.AllowColumnReorder = true; + this.SubtitleListview1.AllowDrop = true; + this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.SubtitleListview1.FirstVisibleIndex = -1; + this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SubtitleListview1.FullRowSelect = true; + this.SubtitleListview1.GridLines = true; + this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.SubtitleListview1.HideSelection = false; + this.SubtitleListview1.Location = new System.Drawing.Point(6, 19); + this.SubtitleListview1.MultiSelect = false; + this.SubtitleListview1.Name = "SubtitleListview1"; + this.SubtitleListview1.OwnerDraw = true; + this.SubtitleListview1.Size = new System.Drawing.Size(909, 187); + this.SubtitleListview1.SubtitleFontBold = false; + this.SubtitleListview1.SubtitleFontName = "Tahoma"; + this.SubtitleListview1.SubtitleFontSize = 8; + this.SubtitleListview1.TabIndex = 0; + this.SubtitleListview1.UseCompatibleStateImageBehavior = false; + this.SubtitleListview1.UseSyntaxColoring = true; + this.SubtitleListview1.View = System.Windows.Forms.View.Details; + // + // groupBoxImportOptions + // + this.groupBoxImportOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImportOptions.Controls.Add(this.groupBoxTimeCodes); + this.groupBoxImportOptions.Controls.Add(this.buttonRefresh); + this.groupBoxImportOptions.Location = new System.Drawing.Point(586, 12); + this.groupBoxImportOptions.Name = "groupBoxImportOptions"; + this.groupBoxImportOptions.Size = new System.Drawing.Size(341, 351); + this.groupBoxImportOptions.TabIndex = 6; + this.groupBoxImportOptions.TabStop = false; + this.groupBoxImportOptions.Text = "Import options"; + // + // groupBoxTimeCodes + // + this.groupBoxTimeCodes.Controls.Add(this.radioButton1); + this.groupBoxTimeCodes.Controls.Add(this.radioButtonMilliseconds); + this.groupBoxTimeCodes.Controls.Add(this.radioButtonTimeCodeFrames); + this.groupBoxTimeCodes.Location = new System.Drawing.Point(6, 19); + this.groupBoxTimeCodes.Name = "groupBoxTimeCodes"; + this.groupBoxTimeCodes.Size = new System.Drawing.Size(329, 99); + this.groupBoxTimeCodes.TabIndex = 5; + this.groupBoxTimeCodes.TabStop = false; + this.groupBoxTimeCodes.Text = "Time codes"; + // + // radioButton1 + // + this.radioButton1.AutoSize = true; + this.radioButton1.Checked = true; + this.radioButton1.Location = new System.Drawing.Point(14, 65); + this.radioButton1.Name = "radioButton1"; + this.radioButton1.Size = new System.Drawing.Size(51, 17); + this.radioButton1.TabIndex = 5; + this.radioButton1.TabStop = true; + this.radioButton1.Text = "Other"; + this.radioButton1.UseVisualStyleBackColor = true; + // + // radioButtonMilliseconds + // + this.radioButtonMilliseconds.AutoSize = true; + this.radioButtonMilliseconds.Location = new System.Drawing.Point(14, 42); + this.radioButtonMilliseconds.Name = "radioButtonMilliseconds"; + this.radioButtonMilliseconds.Size = new System.Drawing.Size(82, 17); + this.radioButtonMilliseconds.TabIndex = 4; + this.radioButtonMilliseconds.Text = "Milliseconds"; + this.radioButtonMilliseconds.UseVisualStyleBackColor = true; + // + // radioButtonTimeCodeFrames + // + this.radioButtonTimeCodeFrames.AutoSize = true; + this.radioButtonTimeCodeFrames.Location = new System.Drawing.Point(14, 19); + this.radioButtonTimeCodeFrames.Name = "radioButtonTimeCodeFrames"; + this.radioButtonTimeCodeFrames.Size = new System.Drawing.Size(59, 17); + this.radioButtonTimeCodeFrames.TabIndex = 3; + this.radioButtonTimeCodeFrames.Text = "Frames"; + this.radioButtonTimeCodeFrames.UseVisualStyleBackColor = true; + // + // buttonRefresh + // + this.buttonRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRefresh.Location = new System.Drawing.Point(6, 124); + this.buttonRefresh.Name = "buttonRefresh"; + this.buttonRefresh.Size = new System.Drawing.Size(102, 23); + this.buttonRefresh.TabIndex = 6; + this.buttonRefresh.Text = "Refresh"; + this.buttonRefresh.UseVisualStyleBackColor = true; + this.buttonRefresh.Click += new System.EventHandler(this.buttonRefresh_Click); + // + // groupBoxImportText + // + this.groupBoxImportText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImportText.Controls.Add(this.textBoxText); + this.groupBoxImportText.Controls.Add(this.buttonOpenText); + this.groupBoxImportText.Location = new System.Drawing.Point(12, 12); + this.groupBoxImportText.Name = "groupBoxImportText"; + this.groupBoxImportText.Size = new System.Drawing.Size(568, 351); + this.groupBoxImportText.TabIndex = 5; + this.groupBoxImportText.TabStop = false; + this.groupBoxImportText.Text = "Import text"; + // + // textBoxText + // + this.textBoxText.AllowDrop = true; + this.textBoxText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxText.Location = new System.Drawing.Point(6, 42); + this.textBoxText.MaxLength = 0; + this.textBoxText.Multiline = true; + this.textBoxText.Name = "textBoxText"; + this.textBoxText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxText.Size = new System.Drawing.Size(556, 303); + this.textBoxText.TabIndex = 1; + // + // buttonOpenText + // + this.buttonOpenText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOpenText.Location = new System.Drawing.Point(419, 15); + this.buttonOpenText.Name = "buttonOpenText"; + this.buttonOpenText.Size = new System.Drawing.Size(143, 23); + this.buttonOpenText.TabIndex = 0; + this.buttonOpenText.Text = "Open file..."; + this.buttonOpenText.UseVisualStyleBackColor = true; + this.buttonOpenText.Click += new System.EventHandler(this.buttonOpenText_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // ImportUnknownFormat + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(945, 636); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.groupBoxImportResult); + this.Controls.Add(this.groupBoxImportOptions); + this.Controls.Add(this.groupBoxImportText); + this.KeyPreview = true; + this.MinimumSize = new System.Drawing.Size(900, 600); + this.Name = "ImportUnknownFormat"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "ImportUnknownFormat"; + this.groupBoxImportResult.ResumeLayout(false); + this.groupBoxImportOptions.ResumeLayout(false); + this.groupBoxTimeCodes.ResumeLayout(false); + this.groupBoxTimeCodes.PerformLayout(); + this.groupBoxImportText.ResumeLayout(false); + this.groupBoxImportText.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.GroupBox groupBoxImportResult; + private Controls.SubtitleListView SubtitleListview1; + private System.Windows.Forms.GroupBox groupBoxImportOptions; + private System.Windows.Forms.GroupBox groupBoxTimeCodes; + private System.Windows.Forms.Button buttonRefresh; + private System.Windows.Forms.GroupBox groupBoxImportText; + private System.Windows.Forms.TextBox textBoxText; + private System.Windows.Forms.Button buttonOpenText; + private System.Windows.Forms.RadioButton radioButtonTimeCodeFrames; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.RadioButton radioButton1; + private System.Windows.Forms.RadioButton radioButtonMilliseconds; + } } \ No newline at end of file diff --git a/src/Forms/ImportUnknownFormat.cs b/src/ui/Forms/ImportUnknownFormat.cs similarity index 97% rename from src/Forms/ImportUnknownFormat.cs rename to src/ui/Forms/ImportUnknownFormat.cs index 4f85cc80d..abfe3060c 100644 --- a/src/Forms/ImportUnknownFormat.cs +++ b/src/ui/Forms/ImportUnknownFormat.cs @@ -1,116 +1,116 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.IO; -using System.Linq; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class ImportUnknownFormat : Form - { - public Subtitle ImportedSubitle { get; private set; } - private readonly Timer _refreshTimer = new Timer(); - - public ImportUnknownFormat(string fileName) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _refreshTimer.Interval = 400; - _refreshTimer.Tick += RefreshTimerTick; - - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.AutoSizeAllColumns(this); - - if (!string.IsNullOrEmpty(fileName)) - { - LoadTextFile(fileName); - GeneratePreview(); - } - } - - private void GeneratePreview() - { - if (_refreshTimer.Enabled) - { - _refreshTimer.Stop(); - } - - _refreshTimer.Start(); - } - - private void GeneratePreviewReal() - { - var uknownFormatImporter = new UnknownFormatImporter { UseFrames = radioButtonTimeCodeFrames.Checked }; - ImportedSubitle = uknownFormatImporter.AutoGuessImport(textBoxText.Lines.ToList()); - groupBoxImportResult.Text = string.Format(Configuration.Settings.Language.ImportText.PreviewLinesModifiedX, ImportedSubitle.Paragraphs.Count); - SubtitleListview1.Fill(ImportedSubitle); - if (ImportedSubitle.Paragraphs.Count > 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(0); - } - } - - private void RefreshTimerTick(object sender, EventArgs e) - { - _refreshTimer.Stop(); - GeneratePreviewReal(); - } - - private void LoadTextFile(string fileName) - { - try - { - SubtitleListview1.Items.Clear(); - var encoding = LanguageAutoDetect.GetEncodingFromFile(fileName); - textBoxText.Text = File.ReadAllText(fileName, encoding); - - // check for RTF file - if (fileName.EndsWith(".rtf", StringComparison.OrdinalIgnoreCase) && !textBoxText.Text.TrimStart().StartsWith("{\\rtf", StringComparison.Ordinal)) - { - using (var rtb = new RichTextBox()) - { - rtb.Rtf = textBoxText.Text; - textBoxText.Text = rtb.Text; - } - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - private void buttonOpenText_Click(object sender, EventArgs e) - { - openFileDialog1.Title = buttonOpenText.Text; - openFileDialog1.Filter = Configuration.Settings.Language.ImportText.TextFiles + "|*.txt|" + Configuration.Settings.Language.General.AllFiles + "|*.*"; - openFileDialog1.FileName = string.Empty; - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - LoadTextFile(openFileDialog1.FileName); - } - GeneratePreview(); - } - - private void buttonRefresh_Click(object sender, EventArgs e) - { - GeneratePreviewReal(); - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void buttonOK_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class ImportUnknownFormat : Form + { + public Subtitle ImportedSubitle { get; private set; } + private readonly Timer _refreshTimer = new Timer(); + + public ImportUnknownFormat(string fileName) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _refreshTimer.Interval = 400; + _refreshTimer.Tick += RefreshTimerTick; + + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.AutoSizeAllColumns(this); + + if (!string.IsNullOrEmpty(fileName)) + { + LoadTextFile(fileName); + GeneratePreview(); + } + } + + private void GeneratePreview() + { + if (_refreshTimer.Enabled) + { + _refreshTimer.Stop(); + } + + _refreshTimer.Start(); + } + + private void GeneratePreviewReal() + { + var uknownFormatImporter = new UnknownFormatImporter { UseFrames = radioButtonTimeCodeFrames.Checked }; + ImportedSubitle = uknownFormatImporter.AutoGuessImport(textBoxText.Lines.ToList()); + groupBoxImportResult.Text = string.Format(Configuration.Settings.Language.ImportText.PreviewLinesModifiedX, ImportedSubitle.Paragraphs.Count); + SubtitleListview1.Fill(ImportedSubitle); + if (ImportedSubitle.Paragraphs.Count > 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(0); + } + } + + private void RefreshTimerTick(object sender, EventArgs e) + { + _refreshTimer.Stop(); + GeneratePreviewReal(); + } + + private void LoadTextFile(string fileName) + { + try + { + SubtitleListview1.Items.Clear(); + var encoding = LanguageAutoDetect.GetEncodingFromFile(fileName); + textBoxText.Text = File.ReadAllText(fileName, encoding); + + // check for RTF file + if (fileName.EndsWith(".rtf", StringComparison.OrdinalIgnoreCase) && !textBoxText.Text.TrimStart().StartsWith("{\\rtf", StringComparison.Ordinal)) + { + using (var rtb = new RichTextBox()) + { + rtb.Rtf = textBoxText.Text; + textBoxText.Text = rtb.Text; + } + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void buttonOpenText_Click(object sender, EventArgs e) + { + openFileDialog1.Title = buttonOpenText.Text; + openFileDialog1.Filter = Configuration.Settings.Language.ImportText.TextFiles + "|*.txt|" + Configuration.Settings.Language.General.AllFiles + "|*.*"; + openFileDialog1.FileName = string.Empty; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + LoadTextFile(openFileDialog1.FileName); + } + GeneratePreview(); + } + + private void buttonRefresh_Click(object sender, EventArgs e) + { + GeneratePreviewReal(); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void buttonOK_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + } +} diff --git a/src/Forms/ImportUnknownFormat.resx b/src/ui/Forms/ImportUnknownFormat.resx similarity index 97% rename from src/Forms/ImportUnknownFormat.resx rename to src/ui/Forms/ImportUnknownFormat.resx index 3a7d67153..9bad2f599 100644 --- a/src/Forms/ImportUnknownFormat.resx +++ b/src/ui/Forms/ImportUnknownFormat.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/Interjections.Designer.cs b/src/ui/Forms/Interjections.Designer.cs similarity index 97% rename from src/Forms/Interjections.Designer.cs rename to src/ui/Forms/Interjections.Designer.cs index 9ac78a074..6f4c36527 100644 --- a/src/Forms/Interjections.Designer.cs +++ b/src/ui/Forms/Interjections.Designer.cs @@ -1,147 +1,147 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class Interjections - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBoxNamesIgonoreLists = new System.Windows.Forms.GroupBox(); - this.buttonRemove = new System.Windows.Forms.Button(); - this.listBoxInterjections = new System.Windows.Forms.ListBox(); - this.textBoxInterjection = new System.Windows.Forms.TextBox(); - this.buttonAdd = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxNamesIgonoreLists.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxNamesIgonoreLists - // - this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonRemove); - this.groupBoxNamesIgonoreLists.Controls.Add(this.listBoxInterjections); - this.groupBoxNamesIgonoreLists.Controls.Add(this.textBoxInterjection); - this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonAdd); - this.groupBoxNamesIgonoreLists.Location = new System.Drawing.Point(12, 12); - this.groupBoxNamesIgonoreLists.Name = "groupBoxNamesIgonoreLists"; - this.groupBoxNamesIgonoreLists.Size = new System.Drawing.Size(241, 250); - this.groupBoxNamesIgonoreLists.TabIndex = 3; - this.groupBoxNamesIgonoreLists.TabStop = false; - // - // buttonRemove - // - this.buttonRemove.Enabled = false; - this.buttonRemove.Location = new System.Drawing.Point(159, 16); - this.buttonRemove.Name = "buttonRemove"; - this.buttonRemove.Size = new System.Drawing.Size(75, 23); - this.buttonRemove.TabIndex = 22; - this.buttonRemove.Text = "Remove"; - this.buttonRemove.UseVisualStyleBackColor = true; - this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click); - // - // listBoxInterjections - // - this.listBoxInterjections.FormattingEnabled = true; - this.listBoxInterjections.Location = new System.Drawing.Point(3, 16); - this.listBoxInterjections.Name = "listBoxInterjections"; - this.listBoxInterjections.Size = new System.Drawing.Size(150, 199); - this.listBoxInterjections.TabIndex = 20; - this.listBoxInterjections.SelectedIndexChanged += new System.EventHandler(this.listBoxInterjections_SelectedIndexChanged); - // - // textBoxInterjection - // - this.textBoxInterjection.Location = new System.Drawing.Point(2, 220); - this.textBoxInterjection.Name = "textBoxInterjection"; - this.textBoxInterjection.Size = new System.Drawing.Size(151, 20); - this.textBoxInterjection.TabIndex = 24; - this.textBoxInterjection.TextChanged += new System.EventHandler(this.textBoxInterjection_TextChanged); - this.textBoxInterjection.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxInterjection_KeyDown); - // - // buttonAdd - // - this.buttonAdd.Enabled = false; - this.buttonAdd.Location = new System.Drawing.Point(159, 219); - this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(75, 23); - this.buttonAdd.TabIndex = 26; - this.buttonAdd.Text = "Add"; - this.buttonAdd.UseVisualStyleBackColor = true; - this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(178, 281); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOK - // - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.Location = new System.Drawing.Point(99, 281); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 4; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - // - // Interjections - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(268, 315); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.groupBoxNamesIgonoreLists); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "Interjections"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Interjections"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Interjections_KeyDown); - this.groupBoxNamesIgonoreLists.ResumeLayout(false); - this.groupBoxNamesIgonoreLists.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxNamesIgonoreLists; - private System.Windows.Forms.Button buttonRemove; - private System.Windows.Forms.ListBox listBoxInterjections; - private System.Windows.Forms.TextBox textBoxInterjection; - private System.Windows.Forms.Button buttonAdd; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class Interjections + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBoxNamesIgonoreLists = new System.Windows.Forms.GroupBox(); + this.buttonRemove = new System.Windows.Forms.Button(); + this.listBoxInterjections = new System.Windows.Forms.ListBox(); + this.textBoxInterjection = new System.Windows.Forms.TextBox(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxNamesIgonoreLists.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxNamesIgonoreLists + // + this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonRemove); + this.groupBoxNamesIgonoreLists.Controls.Add(this.listBoxInterjections); + this.groupBoxNamesIgonoreLists.Controls.Add(this.textBoxInterjection); + this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonAdd); + this.groupBoxNamesIgonoreLists.Location = new System.Drawing.Point(12, 12); + this.groupBoxNamesIgonoreLists.Name = "groupBoxNamesIgonoreLists"; + this.groupBoxNamesIgonoreLists.Size = new System.Drawing.Size(241, 250); + this.groupBoxNamesIgonoreLists.TabIndex = 3; + this.groupBoxNamesIgonoreLists.TabStop = false; + // + // buttonRemove + // + this.buttonRemove.Enabled = false; + this.buttonRemove.Location = new System.Drawing.Point(159, 16); + this.buttonRemove.Name = "buttonRemove"; + this.buttonRemove.Size = new System.Drawing.Size(75, 23); + this.buttonRemove.TabIndex = 22; + this.buttonRemove.Text = "Remove"; + this.buttonRemove.UseVisualStyleBackColor = true; + this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click); + // + // listBoxInterjections + // + this.listBoxInterjections.FormattingEnabled = true; + this.listBoxInterjections.Location = new System.Drawing.Point(3, 16); + this.listBoxInterjections.Name = "listBoxInterjections"; + this.listBoxInterjections.Size = new System.Drawing.Size(150, 199); + this.listBoxInterjections.TabIndex = 20; + this.listBoxInterjections.SelectedIndexChanged += new System.EventHandler(this.listBoxInterjections_SelectedIndexChanged); + // + // textBoxInterjection + // + this.textBoxInterjection.Location = new System.Drawing.Point(2, 220); + this.textBoxInterjection.Name = "textBoxInterjection"; + this.textBoxInterjection.Size = new System.Drawing.Size(151, 20); + this.textBoxInterjection.TabIndex = 24; + this.textBoxInterjection.TextChanged += new System.EventHandler(this.textBoxInterjection_TextChanged); + this.textBoxInterjection.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxInterjection_KeyDown); + // + // buttonAdd + // + this.buttonAdd.Enabled = false; + this.buttonAdd.Location = new System.Drawing.Point(159, 219); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(75, 23); + this.buttonAdd.TabIndex = 26; + this.buttonAdd.Text = "Add"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(178, 281); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOK + // + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.Location = new System.Drawing.Point(99, 281); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 4; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + // + // Interjections + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(268, 315); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.groupBoxNamesIgonoreLists); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Interjections"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Interjections"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Interjections_KeyDown); + this.groupBoxNamesIgonoreLists.ResumeLayout(false); + this.groupBoxNamesIgonoreLists.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxNamesIgonoreLists; + private System.Windows.Forms.Button buttonRemove; + private System.Windows.Forms.ListBox listBoxInterjections; + private System.Windows.Forms.TextBox textBoxInterjection; + private System.Windows.Forms.Button buttonAdd; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + } } \ No newline at end of file diff --git a/src/Forms/Interjections.cs b/src/ui/Forms/Interjections.cs similarity index 97% rename from src/Forms/Interjections.cs rename to src/ui/Forms/Interjections.cs index d79f00d52..5ec6422e4 100644 --- a/src/Forms/Interjections.cs +++ b/src/ui/Forms/Interjections.cs @@ -1,159 +1,159 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class Interjections : Form - { - private List _interjections; - - public Interjections() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - } - - public string GetInterjectionsSemiColonSeparatedString() - { - var sb = new StringBuilder(); - foreach (string s in _interjections) - { - sb.Append(';'); - sb.Append(s.Trim()); - } - return sb.ToString().Trim(';'); - } - - private void Interjections_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#remove_text_for_hi"); - } - } - - public void Initialize(string semiColonSeparatedList) - { - _interjections = new List(); - string[] arr = semiColonSeparatedList.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); - foreach (string s in arr) - { - _interjections.Add(s.Trim()); - } - FillListBox(); - Text = Configuration.Settings.Language.Interjections.Title; - - // Add to interjections (or general) - buttonRemove.Text = Configuration.Settings.Language.Settings.Remove; - buttonAdd.Text = Configuration.Settings.Language.MultipleReplace.Add; - - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void buttonAdd_Click(object sender, EventArgs e) - { - string text = textBoxInterjection.Text.Trim(); - if (text.Length == 0) - { - return; - } - - if (!_interjections.Contains(text)) - { - _interjections.Add(text); - FillListBox(); - textBoxInterjection.Text = string.Empty; - textBoxInterjection.Focus(); - for (int i = 0; i < listBoxInterjections.Items.Count; i++) - { - if (listBoxInterjections.Items[i].ToString() == text) - { - listBoxInterjections.SelectedIndex = i; - int top = i - 5; - if (top < 0) - { - top = 0; - } - - listBoxInterjections.TopIndex = top; - break; - } - } - } - else - { - MessageBox.Show(Configuration.Settings.Language.Settings.WordAlreadyExists); - } - } - - private void FillListBox() - { - _interjections.Sort(); - listBoxInterjections.BeginUpdate(); - listBoxInterjections.Items.Clear(); - foreach (string s in _interjections) - { - listBoxInterjections.Items.Add(s); - } - listBoxInterjections.EndUpdate(); - } - - private void buttonRemove_Click(object sender, EventArgs e) - { - int index = listBoxInterjections.SelectedIndex; - string text = listBoxInterjections.Items[index].ToString(); - if (index >= 0) - { - if (MessageBox.Show(string.Format(Configuration.Settings.Language.Settings.RemoveX, text), null, MessageBoxButtons.YesNo) == DialogResult.Yes) - { - _interjections.Remove(text); - listBoxInterjections.Items.RemoveAt(index); - if (index < listBoxInterjections.Items.Count) - { - listBoxInterjections.SelectedIndex = index; - } - else if (listBoxInterjections.Items.Count > 0) - { - listBoxInterjections.SelectedIndex = index - 1; - } - - listBoxInterjections.Focus(); - - return; - } - MessageBox.Show(Configuration.Settings.Language.Settings.WordNotFound); - } - } - - private void listBoxInterjections_SelectedIndexChanged(object sender, EventArgs e) - { - buttonRemove.Enabled = listBoxInterjections.SelectedIndex >= 0; - } - - private void textBoxInterjection_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - buttonAdd_Click(null, null); - } - } - - private void textBoxInterjection_TextChanged(object sender, EventArgs e) - { - buttonAdd.Enabled = textBoxInterjection.Text.Trim().Length > 0; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class Interjections : Form + { + private List _interjections; + + public Interjections() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + } + + public string GetInterjectionsSemiColonSeparatedString() + { + var sb = new StringBuilder(); + foreach (string s in _interjections) + { + sb.Append(';'); + sb.Append(s.Trim()); + } + return sb.ToString().Trim(';'); + } + + private void Interjections_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#remove_text_for_hi"); + } + } + + public void Initialize(string semiColonSeparatedList) + { + _interjections = new List(); + string[] arr = semiColonSeparatedList.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + foreach (string s in arr) + { + _interjections.Add(s.Trim()); + } + FillListBox(); + Text = Configuration.Settings.Language.Interjections.Title; + + // Add to interjections (or general) + buttonRemove.Text = Configuration.Settings.Language.Settings.Remove; + buttonAdd.Text = Configuration.Settings.Language.MultipleReplace.Add; + + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + string text = textBoxInterjection.Text.Trim(); + if (text.Length == 0) + { + return; + } + + if (!_interjections.Contains(text)) + { + _interjections.Add(text); + FillListBox(); + textBoxInterjection.Text = string.Empty; + textBoxInterjection.Focus(); + for (int i = 0; i < listBoxInterjections.Items.Count; i++) + { + if (listBoxInterjections.Items[i].ToString() == text) + { + listBoxInterjections.SelectedIndex = i; + int top = i - 5; + if (top < 0) + { + top = 0; + } + + listBoxInterjections.TopIndex = top; + break; + } + } + } + else + { + MessageBox.Show(Configuration.Settings.Language.Settings.WordAlreadyExists); + } + } + + private void FillListBox() + { + _interjections.Sort(); + listBoxInterjections.BeginUpdate(); + listBoxInterjections.Items.Clear(); + foreach (string s in _interjections) + { + listBoxInterjections.Items.Add(s); + } + listBoxInterjections.EndUpdate(); + } + + private void buttonRemove_Click(object sender, EventArgs e) + { + int index = listBoxInterjections.SelectedIndex; + string text = listBoxInterjections.Items[index].ToString(); + if (index >= 0) + { + if (MessageBox.Show(string.Format(Configuration.Settings.Language.Settings.RemoveX, text), null, MessageBoxButtons.YesNo) == DialogResult.Yes) + { + _interjections.Remove(text); + listBoxInterjections.Items.RemoveAt(index); + if (index < listBoxInterjections.Items.Count) + { + listBoxInterjections.SelectedIndex = index; + } + else if (listBoxInterjections.Items.Count > 0) + { + listBoxInterjections.SelectedIndex = index - 1; + } + + listBoxInterjections.Focus(); + + return; + } + MessageBox.Show(Configuration.Settings.Language.Settings.WordNotFound); + } + } + + private void listBoxInterjections_SelectedIndexChanged(object sender, EventArgs e) + { + buttonRemove.Enabled = listBoxInterjections.SelectedIndex >= 0; + } + + private void textBoxInterjection_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + buttonAdd_Click(null, null); + } + } + + private void textBoxInterjection_TextChanged(object sender, EventArgs e) + { + buttonAdd.Enabled = textBoxInterjection.Text.Trim().Length > 0; + } + + } +} diff --git a/src/Forms/Ocr/GetTesseractDictionaries.resx b/src/ui/Forms/Interjections.resx similarity index 100% rename from src/Forms/Ocr/GetTesseractDictionaries.resx rename to src/ui/Forms/Interjections.resx diff --git a/src/Forms/JoinSubtitles.Designer.cs b/src/ui/Forms/JoinSubtitles.Designer.cs similarity index 98% rename from src/Forms/JoinSubtitles.Designer.cs rename to src/ui/Forms/JoinSubtitles.Designer.cs index c960e5ea2..c4a522b69 100644 --- a/src/Forms/JoinSubtitles.Designer.cs +++ b/src/ui/Forms/JoinSubtitles.Designer.cs @@ -1,284 +1,284 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class JoinSubtitles - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonJoin = new System.Windows.Forms.Button(); - this.listViewParts = new System.Windows.Forms.ListView(); - this.columnHeaderLines = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderStartTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderEndTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderFileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.groupBoxPreview = new System.Windows.Forms.GroupBox(); - this.labelTotalLines = new System.Windows.Forms.Label(); - this.buttonClear = new System.Windows.Forms.Button(); - this.buttonRemoveFile = new System.Windows.Forms.Button(); - this.buttonAddFile = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.radioButtonJoinPlain = new System.Windows.Forms.RadioButton(); - this.numericUpDownAddMs = new System.Windows.Forms.NumericUpDown(); - this.radioButtonJoinAddTime = new System.Windows.Forms.RadioButton(); - this.labelAddTime = new System.Windows.Forms.Label(); - this.groupBoxPreview.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAddMs)).BeginInit(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(694, 385); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(90, 23); - this.buttonCancel.TabIndex = 45; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonJoin - // - this.buttonJoin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonJoin.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonJoin.Location = new System.Drawing.Point(573, 385); - this.buttonJoin.Name = "buttonJoin"; - this.buttonJoin.Size = new System.Drawing.Size(115, 23); - this.buttonJoin.TabIndex = 40; - this.buttonJoin.Text = "&Join"; - this.buttonJoin.UseVisualStyleBackColor = true; - this.buttonJoin.Click += new System.EventHandler(this.buttonSplit_Click); - // - // listViewParts - // - this.listViewParts.AllowDrop = true; - this.listViewParts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewParts.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderLines, - this.columnHeaderStartTime, - this.columnHeaderEndTime, - this.columnHeaderFileName}); - this.listViewParts.FullRowSelect = true; - this.listViewParts.HideSelection = false; - this.listViewParts.Location = new System.Drawing.Point(6, 19); - this.listViewParts.Name = "listViewParts"; - this.listViewParts.Size = new System.Drawing.Size(669, 273); - this.listViewParts.TabIndex = 101; - this.listViewParts.UseCompatibleStateImageBehavior = false; - this.listViewParts.View = System.Windows.Forms.View.Details; - this.listViewParts.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewParts_DragDrop); - this.listViewParts.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewParts_DragEnter); - // - // columnHeaderLines - // - this.columnHeaderLines.Text = "#Lines"; - this.columnHeaderLines.Width = 50; - // - // columnHeaderStartTime - // - this.columnHeaderStartTime.Text = "Start time"; - this.columnHeaderStartTime.Width = 75; - // - // columnHeaderEndTime - // - this.columnHeaderEndTime.Text = "End time"; - this.columnHeaderEndTime.Width = 75; - // - // columnHeaderFileName - // - this.columnHeaderFileName.Text = "File name"; - this.columnHeaderFileName.Width = 455; - // - // groupBoxPreview - // - this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxPreview.Controls.Add(this.labelTotalLines); - this.groupBoxPreview.Controls.Add(this.buttonClear); - this.groupBoxPreview.Controls.Add(this.buttonRemoveFile); - this.groupBoxPreview.Controls.Add(this.buttonAddFile); - this.groupBoxPreview.Controls.Add(this.listViewParts); - this.groupBoxPreview.Location = new System.Drawing.Point(11, 12); - this.groupBoxPreview.Name = "groupBoxPreview"; - this.groupBoxPreview.Size = new System.Drawing.Size(773, 314); - this.groupBoxPreview.TabIndex = 27; - this.groupBoxPreview.TabStop = false; - this.groupBoxPreview.Text = "Add subtitles to join (drop also supported)"; - // - // labelTotalLines - // - this.labelTotalLines.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelTotalLines.AutoSize = true; - this.labelTotalLines.Location = new System.Drawing.Point(7, 295); - this.labelTotalLines.Name = "labelTotalLines"; - this.labelTotalLines.Size = new System.Drawing.Size(78, 13); - this.labelTotalLines.TabIndex = 105; - this.labelTotalLines.Text = "labelTotalLines"; - // - // buttonClear - // - this.buttonClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonClear.Location = new System.Drawing.Point(682, 73); - this.buttonClear.Name = "buttonClear"; - this.buttonClear.Size = new System.Drawing.Size(74, 23); - this.buttonClear.TabIndex = 104; - this.buttonClear.Text = "Clear"; - this.buttonClear.UseVisualStyleBackColor = true; - this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click); - // - // buttonRemoveFile - // - this.buttonRemoveFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRemoveFile.Location = new System.Drawing.Point(683, 46); - this.buttonRemoveFile.Name = "buttonRemoveFile"; - this.buttonRemoveFile.Size = new System.Drawing.Size(74, 23); - this.buttonRemoveFile.TabIndex = 103; - this.buttonRemoveFile.Text = "Remove"; - this.buttonRemoveFile.UseVisualStyleBackColor = true; - this.buttonRemoveFile.Click += new System.EventHandler(this.ButtonRemoveSubtitle_Click); - // - // buttonAddFile - // - this.buttonAddFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonAddFile.Location = new System.Drawing.Point(683, 19); - this.buttonAddFile.Name = "buttonAddFile"; - this.buttonAddFile.Size = new System.Drawing.Size(73, 23); - this.buttonAddFile.TabIndex = 102; - this.buttonAddFile.Text = "Add..."; - this.buttonAddFile.UseVisualStyleBackColor = true; - this.buttonAddFile.Click += new System.EventHandler(this.ButtonAddSubtitleClick); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // radioButtonJoinPlain - // - this.radioButtonJoinPlain.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.radioButtonJoinPlain.AutoSize = true; - this.radioButtonJoinPlain.Location = new System.Drawing.Point(14, 334); - this.radioButtonJoinPlain.Name = "radioButtonJoinPlain"; - this.radioButtonJoinPlain.Size = new System.Drawing.Size(200, 17); - this.radioButtonJoinPlain.TabIndex = 30; - this.radioButtonJoinPlain.TabStop = true; - this.radioButtonJoinPlain.Text = "Files already have correct time codes"; - this.radioButtonJoinPlain.UseVisualStyleBackColor = true; - this.radioButtonJoinPlain.CheckedChanged += new System.EventHandler(this.RadioButtonJoinPlain_CheckedChanged); - // - // numericUpDownAddMs - // - this.numericUpDownAddMs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.numericUpDownAddMs.Location = new System.Drawing.Point(385, 357); - this.numericUpDownAddMs.Maximum = new decimal(new int[] { - 100000, - 0, - 0, - 0}); - this.numericUpDownAddMs.Name = "numericUpDownAddMs"; - this.numericUpDownAddMs.Size = new System.Drawing.Size(60, 20); - this.numericUpDownAddMs.TabIndex = 34; - // - // radioButtonJoinAddTime - // - this.radioButtonJoinAddTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.radioButtonJoinAddTime.AutoSize = true; - this.radioButtonJoinAddTime.Location = new System.Drawing.Point(14, 357); - this.radioButtonJoinAddTime.Name = "radioButtonJoinAddTime"; - this.radioButtonJoinAddTime.Size = new System.Drawing.Size(161, 17); - this.radioButtonJoinAddTime.TabIndex = 32; - this.radioButtonJoinAddTime.TabStop = true; - this.radioButtonJoinAddTime.Text = "Add end time of previous file"; - this.radioButtonJoinAddTime.UseVisualStyleBackColor = true; - this.radioButtonJoinAddTime.CheckedChanged += new System.EventHandler(this.RadioButtonJoinAddTime_CheckedChanged); - // - // labelAddTime - // - this.labelAddTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelAddTime.AutoSize = true; - this.labelAddTime.Location = new System.Drawing.Point(227, 359); - this.labelAddTime.Name = "labelAddTime"; - this.labelAddTime.Size = new System.Drawing.Size(152, 13); - this.labelAddTime.TabIndex = 34; - this.labelAddTime.Text = "Add milliseconds after each file"; - // - // JoinSubtitles - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(796, 420); - this.Controls.Add(this.labelAddTime); - this.Controls.Add(this.radioButtonJoinAddTime); - this.Controls.Add(this.numericUpDownAddMs); - this.Controls.Add(this.radioButtonJoinPlain); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonJoin); - this.Controls.Add(this.groupBoxPreview); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(640, 320); - this.Name = "JoinSubtitles"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Join subtitles"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.JoinSubtitles_FormClosing); - this.Shown += new System.EventHandler(this.JoinSubtitles_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.JoinSubtitles_KeyDown); - this.Resize += new System.EventHandler(this.JoinSubtitles_Resize); - this.groupBoxPreview.ResumeLayout(false); - this.groupBoxPreview.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAddMs)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonJoin; - private System.Windows.Forms.ListView listViewParts; - private System.Windows.Forms.ColumnHeader columnHeaderLines; - private System.Windows.Forms.ColumnHeader columnHeaderStartTime; - private System.Windows.Forms.ColumnHeader columnHeaderFileName; - private System.Windows.Forms.GroupBox groupBoxPreview; - private System.Windows.Forms.Button buttonClear; - private System.Windows.Forms.Button buttonRemoveFile; - private System.Windows.Forms.Button buttonAddFile; - private System.Windows.Forms.ColumnHeader columnHeaderEndTime; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Label labelTotalLines; - private System.Windows.Forms.RadioButton radioButtonJoinPlain; - private System.Windows.Forms.NumericUpDown numericUpDownAddMs; - private System.Windows.Forms.RadioButton radioButtonJoinAddTime; - private System.Windows.Forms.Label labelAddTime; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class JoinSubtitles + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonJoin = new System.Windows.Forms.Button(); + this.listViewParts = new System.Windows.Forms.ListView(); + this.columnHeaderLines = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderStartTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderEndTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderFileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.groupBoxPreview = new System.Windows.Forms.GroupBox(); + this.labelTotalLines = new System.Windows.Forms.Label(); + this.buttonClear = new System.Windows.Forms.Button(); + this.buttonRemoveFile = new System.Windows.Forms.Button(); + this.buttonAddFile = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.radioButtonJoinPlain = new System.Windows.Forms.RadioButton(); + this.numericUpDownAddMs = new System.Windows.Forms.NumericUpDown(); + this.radioButtonJoinAddTime = new System.Windows.Forms.RadioButton(); + this.labelAddTime = new System.Windows.Forms.Label(); + this.groupBoxPreview.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAddMs)).BeginInit(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(694, 385); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(90, 23); + this.buttonCancel.TabIndex = 45; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonJoin + // + this.buttonJoin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonJoin.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonJoin.Location = new System.Drawing.Point(573, 385); + this.buttonJoin.Name = "buttonJoin"; + this.buttonJoin.Size = new System.Drawing.Size(115, 23); + this.buttonJoin.TabIndex = 40; + this.buttonJoin.Text = "&Join"; + this.buttonJoin.UseVisualStyleBackColor = true; + this.buttonJoin.Click += new System.EventHandler(this.buttonSplit_Click); + // + // listViewParts + // + this.listViewParts.AllowDrop = true; + this.listViewParts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewParts.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderLines, + this.columnHeaderStartTime, + this.columnHeaderEndTime, + this.columnHeaderFileName}); + this.listViewParts.FullRowSelect = true; + this.listViewParts.HideSelection = false; + this.listViewParts.Location = new System.Drawing.Point(6, 19); + this.listViewParts.Name = "listViewParts"; + this.listViewParts.Size = new System.Drawing.Size(669, 273); + this.listViewParts.TabIndex = 101; + this.listViewParts.UseCompatibleStateImageBehavior = false; + this.listViewParts.View = System.Windows.Forms.View.Details; + this.listViewParts.DragDrop += new System.Windows.Forms.DragEventHandler(this.listViewParts_DragDrop); + this.listViewParts.DragEnter += new System.Windows.Forms.DragEventHandler(this.listViewParts_DragEnter); + // + // columnHeaderLines + // + this.columnHeaderLines.Text = "#Lines"; + this.columnHeaderLines.Width = 50; + // + // columnHeaderStartTime + // + this.columnHeaderStartTime.Text = "Start time"; + this.columnHeaderStartTime.Width = 75; + // + // columnHeaderEndTime + // + this.columnHeaderEndTime.Text = "End time"; + this.columnHeaderEndTime.Width = 75; + // + // columnHeaderFileName + // + this.columnHeaderFileName.Text = "File name"; + this.columnHeaderFileName.Width = 455; + // + // groupBoxPreview + // + this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxPreview.Controls.Add(this.labelTotalLines); + this.groupBoxPreview.Controls.Add(this.buttonClear); + this.groupBoxPreview.Controls.Add(this.buttonRemoveFile); + this.groupBoxPreview.Controls.Add(this.buttonAddFile); + this.groupBoxPreview.Controls.Add(this.listViewParts); + this.groupBoxPreview.Location = new System.Drawing.Point(11, 12); + this.groupBoxPreview.Name = "groupBoxPreview"; + this.groupBoxPreview.Size = new System.Drawing.Size(773, 314); + this.groupBoxPreview.TabIndex = 27; + this.groupBoxPreview.TabStop = false; + this.groupBoxPreview.Text = "Add subtitles to join (drop also supported)"; + // + // labelTotalLines + // + this.labelTotalLines.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelTotalLines.AutoSize = true; + this.labelTotalLines.Location = new System.Drawing.Point(7, 295); + this.labelTotalLines.Name = "labelTotalLines"; + this.labelTotalLines.Size = new System.Drawing.Size(78, 13); + this.labelTotalLines.TabIndex = 105; + this.labelTotalLines.Text = "labelTotalLines"; + // + // buttonClear + // + this.buttonClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonClear.Location = new System.Drawing.Point(682, 73); + this.buttonClear.Name = "buttonClear"; + this.buttonClear.Size = new System.Drawing.Size(74, 23); + this.buttonClear.TabIndex = 104; + this.buttonClear.Text = "Clear"; + this.buttonClear.UseVisualStyleBackColor = true; + this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click); + // + // buttonRemoveFile + // + this.buttonRemoveFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRemoveFile.Location = new System.Drawing.Point(683, 46); + this.buttonRemoveFile.Name = "buttonRemoveFile"; + this.buttonRemoveFile.Size = new System.Drawing.Size(74, 23); + this.buttonRemoveFile.TabIndex = 103; + this.buttonRemoveFile.Text = "Remove"; + this.buttonRemoveFile.UseVisualStyleBackColor = true; + this.buttonRemoveFile.Click += new System.EventHandler(this.ButtonRemoveSubtitle_Click); + // + // buttonAddFile + // + this.buttonAddFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAddFile.Location = new System.Drawing.Point(683, 19); + this.buttonAddFile.Name = "buttonAddFile"; + this.buttonAddFile.Size = new System.Drawing.Size(73, 23); + this.buttonAddFile.TabIndex = 102; + this.buttonAddFile.Text = "Add..."; + this.buttonAddFile.UseVisualStyleBackColor = true; + this.buttonAddFile.Click += new System.EventHandler(this.ButtonAddSubtitleClick); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // radioButtonJoinPlain + // + this.radioButtonJoinPlain.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.radioButtonJoinPlain.AutoSize = true; + this.radioButtonJoinPlain.Location = new System.Drawing.Point(14, 334); + this.radioButtonJoinPlain.Name = "radioButtonJoinPlain"; + this.radioButtonJoinPlain.Size = new System.Drawing.Size(200, 17); + this.radioButtonJoinPlain.TabIndex = 30; + this.radioButtonJoinPlain.TabStop = true; + this.radioButtonJoinPlain.Text = "Files already have correct time codes"; + this.radioButtonJoinPlain.UseVisualStyleBackColor = true; + this.radioButtonJoinPlain.CheckedChanged += new System.EventHandler(this.RadioButtonJoinPlain_CheckedChanged); + // + // numericUpDownAddMs + // + this.numericUpDownAddMs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.numericUpDownAddMs.Location = new System.Drawing.Point(385, 357); + this.numericUpDownAddMs.Maximum = new decimal(new int[] { + 100000, + 0, + 0, + 0}); + this.numericUpDownAddMs.Name = "numericUpDownAddMs"; + this.numericUpDownAddMs.Size = new System.Drawing.Size(60, 20); + this.numericUpDownAddMs.TabIndex = 34; + // + // radioButtonJoinAddTime + // + this.radioButtonJoinAddTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.radioButtonJoinAddTime.AutoSize = true; + this.radioButtonJoinAddTime.Location = new System.Drawing.Point(14, 357); + this.radioButtonJoinAddTime.Name = "radioButtonJoinAddTime"; + this.radioButtonJoinAddTime.Size = new System.Drawing.Size(161, 17); + this.radioButtonJoinAddTime.TabIndex = 32; + this.radioButtonJoinAddTime.TabStop = true; + this.radioButtonJoinAddTime.Text = "Add end time of previous file"; + this.radioButtonJoinAddTime.UseVisualStyleBackColor = true; + this.radioButtonJoinAddTime.CheckedChanged += new System.EventHandler(this.RadioButtonJoinAddTime_CheckedChanged); + // + // labelAddTime + // + this.labelAddTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelAddTime.AutoSize = true; + this.labelAddTime.Location = new System.Drawing.Point(227, 359); + this.labelAddTime.Name = "labelAddTime"; + this.labelAddTime.Size = new System.Drawing.Size(152, 13); + this.labelAddTime.TabIndex = 34; + this.labelAddTime.Text = "Add milliseconds after each file"; + // + // JoinSubtitles + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(796, 420); + this.Controls.Add(this.labelAddTime); + this.Controls.Add(this.radioButtonJoinAddTime); + this.Controls.Add(this.numericUpDownAddMs); + this.Controls.Add(this.radioButtonJoinPlain); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonJoin); + this.Controls.Add(this.groupBoxPreview); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(640, 320); + this.Name = "JoinSubtitles"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Join subtitles"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.JoinSubtitles_FormClosing); + this.Shown += new System.EventHandler(this.JoinSubtitles_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.JoinSubtitles_KeyDown); + this.Resize += new System.EventHandler(this.JoinSubtitles_Resize); + this.groupBoxPreview.ResumeLayout(false); + this.groupBoxPreview.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownAddMs)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonJoin; + private System.Windows.Forms.ListView listViewParts; + private System.Windows.Forms.ColumnHeader columnHeaderLines; + private System.Windows.Forms.ColumnHeader columnHeaderStartTime; + private System.Windows.Forms.ColumnHeader columnHeaderFileName; + private System.Windows.Forms.GroupBox groupBoxPreview; + private System.Windows.Forms.Button buttonClear; + private System.Windows.Forms.Button buttonRemoveFile; + private System.Windows.Forms.Button buttonAddFile; + private System.Windows.Forms.ColumnHeader columnHeaderEndTime; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Label labelTotalLines; + private System.Windows.Forms.RadioButton radioButtonJoinPlain; + private System.Windows.Forms.NumericUpDown numericUpDownAddMs; + private System.Windows.Forms.RadioButton radioButtonJoinAddTime; + private System.Windows.Forms.Label labelAddTime; + } } \ No newline at end of file diff --git a/src/Forms/JoinSubtitles.cs b/src/ui/Forms/JoinSubtitles.cs similarity index 97% rename from src/Forms/JoinSubtitles.cs rename to src/ui/Forms/JoinSubtitles.cs index 62b213d79..2f2f2944e 100644 --- a/src/Forms/JoinSubtitles.cs +++ b/src/ui/Forms/JoinSubtitles.cs @@ -1,349 +1,349 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class JoinSubtitles : PositionAndSizeForm - { - private readonly List _fileNamesToJoin = new List(); - public Subtitle JoinedSubtitle { get; set; } - public SubtitleFormat JoinedFormat { get; private set; } - - public JoinSubtitles() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - JoinedSubtitle = new Subtitle(); - labelTotalLines.Text = string.Empty; - - listViewParts.Columns[0].Text = Configuration.Settings.Language.JoinSubtitles.NumberOfLines; - listViewParts.Columns[1].Text = Configuration.Settings.Language.JoinSubtitles.StartTime; - listViewParts.Columns[2].Text = Configuration.Settings.Language.JoinSubtitles.EndTime; - listViewParts.Columns[3].Text = Configuration.Settings.Language.JoinSubtitles.FileName; - - buttonAddFile.Text = Configuration.Settings.Language.DvdSubRip.Add; - buttonRemoveFile.Text = Configuration.Settings.Language.DvdSubRip.Remove; - buttonClear.Text = Configuration.Settings.Language.DvdSubRip.Clear; - - Text = Configuration.Settings.Language.JoinSubtitles.Title; - groupBoxPreview.Text = Configuration.Settings.Language.JoinSubtitles.Information; - buttonJoin.Text = Configuration.Settings.Language.JoinSubtitles.Join; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - - radioButtonJoinPlain.Text = Configuration.Settings.Language.JoinSubtitles.AlreadyCorrectTimeCodes; - radioButtonJoinAddTime.Text = Configuration.Settings.Language.JoinSubtitles.AppendTimeCodes; - labelAddTime.Text = Configuration.Settings.Language.JoinSubtitles.AddMs; - - labelAddTime.Left = radioButtonJoinAddTime.Left + radioButtonJoinAddTime.Width + 20; - numericUpDownAddMs.Left = labelAddTime.Left + labelAddTime.Width + 5; - - UiUtil.FixLargeFonts(this, buttonCancel); - - if (Configuration.Settings.Tools.JoinCorrectTimeCodes) - { - radioButtonJoinPlain.Checked = true; - } - else - { - radioButtonJoinAddTime.Checked = true; - } - numericUpDownAddMs.Value = Configuration.Settings.Tools.JoinAddMs; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void buttonSplit_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void JoinSubtitles_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void listViewParts_DragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) - { - e.Effect = DragDropEffects.All; - } - } - - private void listViewParts_DragDrop(object sender, DragEventArgs e) - { - var files = (string[])e.Data.GetData(DataFormats.FileDrop); - foreach (string fileName in files) - { - if (!_fileNamesToJoin.Any(file => file.Equals(fileName, StringComparison.OrdinalIgnoreCase))) - { - _fileNamesToJoin.Add(fileName); - } - } - SortAndLoad(); - } - - private void SortAndLoad() - { - JoinedFormat = new SubRip(); // default subtitle format - string header = null; - SubtitleFormat lastFormat = null; - var subtitles = new List(); - for (int k = 0; k < _fileNamesToJoin.Count; k++) - { - string fileName = _fileNamesToJoin[k]; - try - { - var sub = new Subtitle(); - SubtitleFormat format; - var lines = FileUtil.ReadAllLinesShared(fileName, LanguageAutoDetect.GetEncodingFromFile(fileName)); - if (lastFormat != null && lastFormat.IsMine(lines, fileName)) - { - format = lastFormat; - format.LoadSubtitle(sub, lines, fileName); - } - - format = sub.LoadSubtitle(fileName, out _, null); - - if (format == null) - { - if (lines.Count > 0 && lines.Count < 10 && lines[0].Trim() == "WEBVTT") - { - format = new WebVTT(); // empty WebVTT - } - } - - if (format == null) - { - foreach (var binaryFormat in SubtitleFormat.GetBinaryFormats(true)) - { - if (binaryFormat.IsMine(null, fileName)) - { - binaryFormat.LoadSubtitle(sub, null, fileName); - format = binaryFormat; - break; - } - } - } - - if (format == null) - { - foreach (var f in SubtitleFormat.GetTextOtherFormats()) - { - if (f.IsMine(lines, fileName)) - { - f.LoadSubtitle(sub, lines, fileName); - format = f; - break; - } - } - } - - if (format == null) - { - Revert(k, Configuration.Settings.Language.UnknownSubtitle.Title + Environment.NewLine + fileName); - break; - } - - if (sub.Header != null) - { - header = sub.Header; - } - - lastFormat = lastFormat == null || lastFormat.FriendlyName == format.FriendlyName ? format : new SubRip(); - - subtitles.Add(sub); - } - catch (Exception exception) - { - Revert(k, exception.Message); - return; - } - } - JoinedFormat = lastFormat; - - - if (!radioButtonJoinAddTime.Checked) - { - for (int outer = 0; outer < subtitles.Count; outer++) - { - for (int inner = 1; inner < subtitles.Count; inner++) - { - var a = subtitles[inner - 1]; - var b = subtitles[inner]; - if (a.Paragraphs.Count > 0 && b.Paragraphs.Count > 0 && a.Paragraphs[0].StartTime.TotalMilliseconds > b.Paragraphs[0].StartTime.TotalMilliseconds) - { - string t1 = _fileNamesToJoin[inner - 1]; - _fileNamesToJoin[inner - 1] = _fileNamesToJoin[inner]; - _fileNamesToJoin[inner] = t1; - - var t2 = subtitles[inner - 1]; - subtitles[inner - 1] = subtitles[inner]; - subtitles[inner] = t2; - } - } - } - } - - listViewParts.BeginUpdate(); - listViewParts.Items.Clear(); - int i = 0; - foreach (string fileName in _fileNamesToJoin) - { - var sub = subtitles[i]; - var lvi = new ListViewItem($"{sub.Paragraphs.Count:#,###,###}"); - if (sub.Paragraphs.Count > 0) - { - lvi.SubItems.Add(sub.Paragraphs[0].StartTime.ToString()); - lvi.SubItems.Add(sub.Paragraphs[sub.Paragraphs.Count - 1].StartTime.ToString()); - } - else - { - lvi.SubItems.Add("-"); - lvi.SubItems.Add("-"); - } - lvi.SubItems.Add(fileName); - listViewParts.Items.Add(lvi); - i++; - } - listViewParts.EndUpdate(); - - JoinedSubtitle = new Subtitle(); - if (JoinedFormat != null && JoinedFormat.FriendlyName != SubRip.NameOfFormat) - { - JoinedSubtitle.Header = header; - } - - var addTime = radioButtonJoinAddTime.Checked; - foreach (var sub in subtitles) - { - double addMs = 0; - if (addTime && JoinedSubtitle.Paragraphs.Count > 0) - { - addMs = JoinedSubtitle.Paragraphs.Last().EndTime.TotalMilliseconds + Convert.ToDouble(numericUpDownAddMs.Value); - } - foreach (var p in sub.Paragraphs) - { - p.StartTime.TotalMilliseconds += addMs; - p.EndTime.TotalMilliseconds += addMs; - JoinedSubtitle.Paragraphs.Add(p); - } - } - JoinedSubtitle.Renumber(); - labelTotalLines.Text = string.Format(Configuration.Settings.Language.JoinSubtitles.TotalNumberOfLinesX, JoinedSubtitle.Paragraphs.Count); - } - - private void Revert(int idx, string message) - { - for (int i = _fileNamesToJoin.Count - 1; i >= idx; i--) - { - _fileNamesToJoin.RemoveAt(i); - } - MessageBox.Show(message); - } - - private void JoinSubtitles_Resize(object sender, EventArgs e) - { - columnHeaderFileName.Width = -2; - } - - private void ButtonAddSubtitleClick(object sender, EventArgs e) - { - openFileDialog1.Title = Configuration.Settings.Language.General.OpenSubtitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - openFileDialog1.Multiselect = true; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - var sb = new StringBuilder(); - foreach (string fileName in openFileDialog1.FileNames) - { - Application.DoEvents(); - if (File.Exists(fileName)) - { - var fileInfo = new FileInfo(fileName); - if (fileInfo.Length < Subtitle.MaxFileSize) - { - if (!_fileNamesToJoin.Any(file => file.Equals(fileName, StringComparison.OrdinalIgnoreCase))) - { - _fileNamesToJoin.Add(fileName); - } - } - else - { - sb.AppendLine(string.Format(Configuration.Settings.Language.Main.FileXIsLargerThan10MB, fileName)); - } - } - } - SortAndLoad(); - if (sb.Length > 0) - { - MessageBox.Show(sb.ToString()); - } - JoinSubtitles_Resize(sender, e); - } - } - - private void ButtonRemoveSubtitle_Click(object sender, EventArgs e) - { - for (int i = listViewParts.SelectedIndices.Count - 1; i >= 0; i--) - { - _fileNamesToJoin.RemoveAt(listViewParts.SelectedIndices[i]); - } - if (_fileNamesToJoin.Count == 0) - { - buttonClear_Click(null, null); - } - else - { - SortAndLoad(); - } - } - - private void buttonClear_Click(object sender, EventArgs e) - { - _fileNamesToJoin.Clear(); - listViewParts.Items.Clear(); - JoinedSubtitle = new Subtitle(); - } - - private void JoinSubtitles_Shown(object sender, EventArgs e) - { - columnHeaderFileName.Width = -2; - } - - private void JoinSubtitles_FormClosing(object sender, FormClosingEventArgs e) - { - Configuration.Settings.Tools.JoinCorrectTimeCodes = radioButtonJoinPlain.Checked; - Configuration.Settings.Tools.JoinAddMs = (int)numericUpDownAddMs.Value; - } - - private void RadioButtonJoinAddTime_CheckedChanged(object sender, EventArgs e) - { - numericUpDownAddMs.Enabled = radioButtonJoinAddTime.Checked; - labelAddTime.Enabled = radioButtonJoinAddTime.Checked; - } - - private void RadioButtonJoinPlain_CheckedChanged(object sender, EventArgs e) - { - numericUpDownAddMs.Enabled = radioButtonJoinAddTime.Checked; - labelAddTime.Enabled = radioButtonJoinAddTime.Checked; - SortAndLoad(); - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class JoinSubtitles : PositionAndSizeForm + { + private readonly List _fileNamesToJoin = new List(); + public Subtitle JoinedSubtitle { get; set; } + public SubtitleFormat JoinedFormat { get; private set; } + + public JoinSubtitles() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + JoinedSubtitle = new Subtitle(); + labelTotalLines.Text = string.Empty; + + listViewParts.Columns[0].Text = Configuration.Settings.Language.JoinSubtitles.NumberOfLines; + listViewParts.Columns[1].Text = Configuration.Settings.Language.JoinSubtitles.StartTime; + listViewParts.Columns[2].Text = Configuration.Settings.Language.JoinSubtitles.EndTime; + listViewParts.Columns[3].Text = Configuration.Settings.Language.JoinSubtitles.FileName; + + buttonAddFile.Text = Configuration.Settings.Language.DvdSubRip.Add; + buttonRemoveFile.Text = Configuration.Settings.Language.DvdSubRip.Remove; + buttonClear.Text = Configuration.Settings.Language.DvdSubRip.Clear; + + Text = Configuration.Settings.Language.JoinSubtitles.Title; + groupBoxPreview.Text = Configuration.Settings.Language.JoinSubtitles.Information; + buttonJoin.Text = Configuration.Settings.Language.JoinSubtitles.Join; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + + radioButtonJoinPlain.Text = Configuration.Settings.Language.JoinSubtitles.AlreadyCorrectTimeCodes; + radioButtonJoinAddTime.Text = Configuration.Settings.Language.JoinSubtitles.AppendTimeCodes; + labelAddTime.Text = Configuration.Settings.Language.JoinSubtitles.AddMs; + + labelAddTime.Left = radioButtonJoinAddTime.Left + radioButtonJoinAddTime.Width + 20; + numericUpDownAddMs.Left = labelAddTime.Left + labelAddTime.Width + 5; + + UiUtil.FixLargeFonts(this, buttonCancel); + + if (Configuration.Settings.Tools.JoinCorrectTimeCodes) + { + radioButtonJoinPlain.Checked = true; + } + else + { + radioButtonJoinAddTime.Checked = true; + } + numericUpDownAddMs.Value = Configuration.Settings.Tools.JoinAddMs; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void buttonSplit_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void JoinSubtitles_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void listViewParts_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.All; + } + } + + private void listViewParts_DragDrop(object sender, DragEventArgs e) + { + var files = (string[])e.Data.GetData(DataFormats.FileDrop); + foreach (string fileName in files) + { + if (!_fileNamesToJoin.Any(file => file.Equals(fileName, StringComparison.OrdinalIgnoreCase))) + { + _fileNamesToJoin.Add(fileName); + } + } + SortAndLoad(); + } + + private void SortAndLoad() + { + JoinedFormat = new SubRip(); // default subtitle format + string header = null; + SubtitleFormat lastFormat = null; + var subtitles = new List(); + for (int k = 0; k < _fileNamesToJoin.Count; k++) + { + string fileName = _fileNamesToJoin[k]; + try + { + var sub = new Subtitle(); + SubtitleFormat format; + var lines = FileUtil.ReadAllLinesShared(fileName, LanguageAutoDetect.GetEncodingFromFile(fileName)); + if (lastFormat != null && lastFormat.IsMine(lines, fileName)) + { + format = lastFormat; + format.LoadSubtitle(sub, lines, fileName); + } + + format = sub.LoadSubtitle(fileName, out _, null); + + if (format == null) + { + if (lines.Count > 0 && lines.Count < 10 && lines[0].Trim() == "WEBVTT") + { + format = new WebVTT(); // empty WebVTT + } + } + + if (format == null) + { + foreach (var binaryFormat in SubtitleFormat.GetBinaryFormats(true)) + { + if (binaryFormat.IsMine(null, fileName)) + { + binaryFormat.LoadSubtitle(sub, null, fileName); + format = binaryFormat; + break; + } + } + } + + if (format == null) + { + foreach (var f in SubtitleFormat.GetTextOtherFormats()) + { + if (f.IsMine(lines, fileName)) + { + f.LoadSubtitle(sub, lines, fileName); + format = f; + break; + } + } + } + + if (format == null) + { + Revert(k, Configuration.Settings.Language.UnknownSubtitle.Title + Environment.NewLine + fileName); + break; + } + + if (sub.Header != null) + { + header = sub.Header; + } + + lastFormat = lastFormat == null || lastFormat.FriendlyName == format.FriendlyName ? format : new SubRip(); + + subtitles.Add(sub); + } + catch (Exception exception) + { + Revert(k, exception.Message); + return; + } + } + JoinedFormat = lastFormat; + + + if (!radioButtonJoinAddTime.Checked) + { + for (int outer = 0; outer < subtitles.Count; outer++) + { + for (int inner = 1; inner < subtitles.Count; inner++) + { + var a = subtitles[inner - 1]; + var b = subtitles[inner]; + if (a.Paragraphs.Count > 0 && b.Paragraphs.Count > 0 && a.Paragraphs[0].StartTime.TotalMilliseconds > b.Paragraphs[0].StartTime.TotalMilliseconds) + { + string t1 = _fileNamesToJoin[inner - 1]; + _fileNamesToJoin[inner - 1] = _fileNamesToJoin[inner]; + _fileNamesToJoin[inner] = t1; + + var t2 = subtitles[inner - 1]; + subtitles[inner - 1] = subtitles[inner]; + subtitles[inner] = t2; + } + } + } + } + + listViewParts.BeginUpdate(); + listViewParts.Items.Clear(); + int i = 0; + foreach (string fileName in _fileNamesToJoin) + { + var sub = subtitles[i]; + var lvi = new ListViewItem($"{sub.Paragraphs.Count:#,###,###}"); + if (sub.Paragraphs.Count > 0) + { + lvi.SubItems.Add(sub.Paragraphs[0].StartTime.ToString()); + lvi.SubItems.Add(sub.Paragraphs[sub.Paragraphs.Count - 1].StartTime.ToString()); + } + else + { + lvi.SubItems.Add("-"); + lvi.SubItems.Add("-"); + } + lvi.SubItems.Add(fileName); + listViewParts.Items.Add(lvi); + i++; + } + listViewParts.EndUpdate(); + + JoinedSubtitle = new Subtitle(); + if (JoinedFormat != null && JoinedFormat.FriendlyName != SubRip.NameOfFormat) + { + JoinedSubtitle.Header = header; + } + + var addTime = radioButtonJoinAddTime.Checked; + foreach (var sub in subtitles) + { + double addMs = 0; + if (addTime && JoinedSubtitle.Paragraphs.Count > 0) + { + addMs = JoinedSubtitle.Paragraphs.Last().EndTime.TotalMilliseconds + Convert.ToDouble(numericUpDownAddMs.Value); + } + foreach (var p in sub.Paragraphs) + { + p.StartTime.TotalMilliseconds += addMs; + p.EndTime.TotalMilliseconds += addMs; + JoinedSubtitle.Paragraphs.Add(p); + } + } + JoinedSubtitle.Renumber(); + labelTotalLines.Text = string.Format(Configuration.Settings.Language.JoinSubtitles.TotalNumberOfLinesX, JoinedSubtitle.Paragraphs.Count); + } + + private void Revert(int idx, string message) + { + for (int i = _fileNamesToJoin.Count - 1; i >= idx; i--) + { + _fileNamesToJoin.RemoveAt(i); + } + MessageBox.Show(message); + } + + private void JoinSubtitles_Resize(object sender, EventArgs e) + { + columnHeaderFileName.Width = -2; + } + + private void ButtonAddSubtitleClick(object sender, EventArgs e) + { + openFileDialog1.Title = Configuration.Settings.Language.General.OpenSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + openFileDialog1.Multiselect = true; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + var sb = new StringBuilder(); + foreach (string fileName in openFileDialog1.FileNames) + { + Application.DoEvents(); + if (File.Exists(fileName)) + { + var fileInfo = new FileInfo(fileName); + if (fileInfo.Length < Subtitle.MaxFileSize) + { + if (!_fileNamesToJoin.Any(file => file.Equals(fileName, StringComparison.OrdinalIgnoreCase))) + { + _fileNamesToJoin.Add(fileName); + } + } + else + { + sb.AppendLine(string.Format(Configuration.Settings.Language.Main.FileXIsLargerThan10MB, fileName)); + } + } + } + SortAndLoad(); + if (sb.Length > 0) + { + MessageBox.Show(sb.ToString()); + } + JoinSubtitles_Resize(sender, e); + } + } + + private void ButtonRemoveSubtitle_Click(object sender, EventArgs e) + { + for (int i = listViewParts.SelectedIndices.Count - 1; i >= 0; i--) + { + _fileNamesToJoin.RemoveAt(listViewParts.SelectedIndices[i]); + } + if (_fileNamesToJoin.Count == 0) + { + buttonClear_Click(null, null); + } + else + { + SortAndLoad(); + } + } + + private void buttonClear_Click(object sender, EventArgs e) + { + _fileNamesToJoin.Clear(); + listViewParts.Items.Clear(); + JoinedSubtitle = new Subtitle(); + } + + private void JoinSubtitles_Shown(object sender, EventArgs e) + { + columnHeaderFileName.Width = -2; + } + + private void JoinSubtitles_FormClosing(object sender, FormClosingEventArgs e) + { + Configuration.Settings.Tools.JoinCorrectTimeCodes = radioButtonJoinPlain.Checked; + Configuration.Settings.Tools.JoinAddMs = (int)numericUpDownAddMs.Value; + } + + private void RadioButtonJoinAddTime_CheckedChanged(object sender, EventArgs e) + { + numericUpDownAddMs.Enabled = radioButtonJoinAddTime.Checked; + labelAddTime.Enabled = radioButtonJoinAddTime.Checked; + } + + private void RadioButtonJoinPlain_CheckedChanged(object sender, EventArgs e) + { + numericUpDownAddMs.Enabled = radioButtonJoinAddTime.Checked; + labelAddTime.Enabled = radioButtonJoinAddTime.Checked; + SortAndLoad(); + } + } +} diff --git a/src/Forms/JoinSubtitles.resx b/src/ui/Forms/JoinSubtitles.resx similarity index 97% rename from src/Forms/JoinSubtitles.resx rename to src/ui/Forms/JoinSubtitles.resx index 3a7d67153..9bad2f599 100644 --- a/src/Forms/JoinSubtitles.resx +++ b/src/ui/Forms/JoinSubtitles.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/Main.Designer.cs b/src/ui/Forms/Main.Designer.cs similarity index 98% rename from src/Forms/Main.Designer.cs rename to src/ui/Forms/Main.Designer.cs index 246e28555..95a865a2d 100644 --- a/src/Forms/Main.Designer.cs +++ b/src/ui/Forms/Main.Designer.cs @@ -1,5698 +1,5698 @@ -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class Main - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - if (disposing) - { - if (_networkSession != null) - { - _networkSession.Dispose(); - _networkSession = null; - } - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main)); - TimeCode timeCode4 = new TimeCode(); - TimeCode timeCode5 = new TimeCode(); - TimeCode timeCode6 = new TimeCode(); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.labelStatus = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripSelected = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelProgress = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusNetworking = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStrip1 = new System.Windows.Forms.ToolStrip(); - this.toolStripButtonFileNew = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonFileOpen = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonSave = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonSaveAs = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparatorFindReplace = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripButtonFind = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonReplace = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparatorFixSyncSpell = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripButtonFixCommonErrors = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonRemoveTextForHi = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonVisualSync = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonSpellCheck = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonNetflixQualityCheck = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonSettings = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparatorHelp = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripButtonHelp = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparatorToggle = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripButtonToggleWaveform = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonToggleVideo = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparatorSubtitleFormat = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripLabelSubtitleFormat = new System.Windows.Forms.ToolStripLabel(); - this.comboBoxSubtitleFormats = new System.Windows.Forms.ToolStripComboBox(); - this.toolStripSeparatorEncoding = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripLabelEncoding = new System.Windows.Forms.ToolStripLabel(); - this.comboBoxEncoding = new System.Windows.Forms.ToolStripComboBox(); - this.toolStripSeparatorFrameRate = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripLabelFrameRate = new System.Windows.Forms.ToolStripLabel(); - this.toolStripComboBoxFrameRate = new System.Windows.Forms.ToolStripComboBox(); - this.toolStripButtonGetFrameRate = new System.Windows.Forms.ToolStripButton(); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemOpenKeepVideo = new System.Windows.Forms.ToolStripMenuItem(); - this.reopenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemRestoreAutoBackup = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemDCinemaProperties = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemTTProperties = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemNuendoProperties = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemFcpProperties = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSubStationAlpha = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemAssaStyles = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemEbuProperties = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemDvdStudioProProperties = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator20 = new System.Windows.Forms.ToolStripSeparator(); - this.openOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveOriginalAstoolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItemOpenContainingFolder = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemCompare = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemStatistics = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemPlugins = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItemImportDvdSubtitles = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSubIdx = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemImportBluRaySup = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemImportXSub = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemImportOcrHardSub = new System.Windows.Forms.ToolStripMenuItem(); - this.matroskaImportStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemManualAnsi = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemImportText = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemImportImages = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemImportTimeCodes = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator22 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItemExport = new System.Windows.Forms.ToolStripMenuItem(); - this.adobeEncoreFABImageScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemAvidStl = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemExportAyato = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemExportPngXml = new System.Windows.Forms.ToolStripMenuItem(); - this.bluraySupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemExportBdTextSt = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemExportCapMakerPlus = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemExportCaptionInc = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemCavena890 = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemExportCheetahCap = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemExportDcinemaInterop = new System.Windows.Forms.ToolStripMenuItem(); - this.dCinemaSMPTE2014ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemDost = new System.Windows.Forms.ToolStripMenuItem(); - this.DvdStudioProStl = new System.Windows.Forms.ToolStripMenuItem(); - this.eBUSTLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemEdl = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemEdlClipName = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemExportFcpIImage = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemFcpXmlAdvanced = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemImagePerFrame = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemTextTimeCodePair = new System.Windows.Forms.ToolStripMenuItem(); - this.pACScreenElectronicsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.uniPacExportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.plainTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSpumux = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemExportUltech130 = new System.Windows.Forms.ToolStripMenuItem(); - this.vobSubsubidxToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparatorExportCustomText = new System.Windows.Forms.ToolStripSeparator(); - this.exportCustomTextFormatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator(); - this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemUndo = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemRedo = new System.Windows.Forms.ToolStripMenuItem(); - this.showHistoryforUndoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator14 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItemInsertUnicodeCharacter = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparatorInsertUnicodeCharacter = new System.Windows.Forms.ToolStripSeparator(); - this.findToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.findNextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.replaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.multipleReplaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.gotoLineNumberToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemShowOriginalInPreview = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator25 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItemRightToLeftMode = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemRtlUnicodeControlChars = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemRemoveUnicodeControlChars = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemReverseRightToLeftStartEnd = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator21 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItemModifySelection = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); - this.editSelectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.adjustDisplayTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemApplyDurationLimits = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSubtitlesBridgeGaps = new System.Windows.Forms.ToolStripMenuItem(); - this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.fixToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.startNumberingFromToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeTextForHearImpairedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.ChangeCasingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemAutoMergeShortLines = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemMergeDuplicateText = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemMergeLinesWithSameTimeCodes = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemAutoSplitLongLines = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSortBy = new System.Windows.Forms.ToolStripMenuItem(); - this.sortNumberToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.sortStartTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.sortEndTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.sortDisplayTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.sortTextAlphabeticallytoolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.sortTextMaxLineLengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.sortTextTotalLengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.sortTextNumberOfLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.textCharssecToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.textWordsPerMinutewpmToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.actorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.styleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparatorAscOrDesc = new System.Windows.Forms.ToolStripSeparator(); - this.AscendingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.descendingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.netflixQualityCheckToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator23 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItemMakeEmptyFromCurrent = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemBatchConvert = new System.Windows.Forms.ToolStripMenuItem(); - this.generateDatetimeInfoFromVideoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemMeasurementConverter = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.splitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.appendTextVisuallyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.joinSubtitlesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSpellCheckMain = new System.Windows.Forms.ToolStripMenuItem(); - this.spellCheckToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSpellCheckFromCurrentLine = new System.Windows.Forms.ToolStripMenuItem(); - this.findDoubleWordsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.FindDoubleLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); - this.GetDictionariesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.addWordToNameListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemVideo = new System.Windows.Forms.ToolStripMenuItem(); - this.openVideoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemOpenVideoFromUrl = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemOpenDvd = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSetAudioTrack = new System.Windows.Forms.ToolStripMenuItem(); - this.closeVideoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.openSecondSubtitleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.setVideoOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.smpteTimeModedropFrameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemImportChapters = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemImportSceneChanges = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemRemoveSceneChanges = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemAddWaveformBatch = new System.Windows.Forms.ToolStripMenuItem(); - this.generateTextFromCurrentVideoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); - this.showhideWaveformToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.showhideVideoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator19 = new System.Windows.Forms.ToolStripSeparator(); - this.undockVideoControlsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.redockVideoControlsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSynchronization = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemAdjustAllTimes = new System.Windows.Forms.ToolStripMenuItem(); - this.visualSyncToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemPointSync = new System.Windows.Forms.ToolStripMenuItem(); - this.pointSyncViaOtherSubtitleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemChangeFrameRate2 = new System.Windows.Forms.ToolStripMenuItem(); - this.changeSpeedInPercentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemAutoTranslate = new System.Windows.Forms.ToolStripMenuItem(); - this.translatepoweredByMicrosoftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.translateByGoogleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.translateFromSwedishToDanishToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.changeLanguageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemNetworking = new System.Windows.Forms.ToolStripMenuItem(); - this.startServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.joinSessionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.chatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.showSessionKeyLogToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.leaveSessionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSplitterCheckForUpdates = new System.Windows.Forms.ToolStripSeparator(); - this.helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.contextMenuStripListview = new System.Windows.Forms.ContextMenuStrip(this.components); - this.setStylesForSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.setActorForSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemAssStyles = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSetRegion = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSetLanguage = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemWebVTT = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemPreview = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemDelete = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInsertBefore = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInsertAfter = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInsertSubtitle = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemCopySourceText = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemColumn = new System.Windows.Forms.ToolStripMenuItem(); - this.columnDeleteTextOnlyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemColumnDeleteText = new System.Windows.Forms.ToolStripMenuItem(); - this.ShiftTextCellsDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInsertTextFromSub = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemColumnImportText = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemPasteSpecial = new System.Windows.Forms.ToolStripMenuItem(); - this.copyOriginalTextToCurrentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.moveTextUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.moveTextDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemBookmark = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); - this.splitLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemMergeLines = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemMergeDialog = new System.Windows.Forms.ToolStripMenuItem(); - this.mergeBeforeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.mergeAfterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); - this.extendBeforeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.extendAfterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); - this.removeFormattinglToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeAllFormattingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeBoldToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeItalicToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeUnderlineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeColorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeFontNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeAlignmentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boldToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.italicToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boxToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.underlineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.colorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemFont = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemAlignment = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSurroundWithMusicSymbols = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItemAutoBreakLines = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemUnbreakLines = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparatorBreakLines = new System.Windows.Forms.ToolStripSeparator(); - this.typeEffectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.karokeeEffectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparatorAdvancedFunctions = new System.Windows.Forms.ToolStripSeparator(); - this.showSelectedLinesEarlierlaterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.visualSyncSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemGoogleMicrosoftTranslateSelLine = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemTranslateSelected = new System.Windows.Forms.ToolStripMenuItem(); - this.googleTranslateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.microsoftBingTranslateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.adjustDisplayTimeForSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.fixCommonErrorsInSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.changeCasingForSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSaveSelectedLines = new System.Windows.Forms.ToolStripMenuItem(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.colorDialog1 = new System.Windows.Forms.ColorDialog(); - this.groupBoxVideo = new System.Windows.Forms.GroupBox(); - this.labelNextWord = new System.Windows.Forms.Label(); - this.audioVisualizer = new Nikse.SubtitleEdit.Controls.AudioVisualizer(); - this.checkBoxSyncListViewWithVideoWhilePlaying = new System.Windows.Forms.CheckBox(); - this.labelVideoInfo = new System.Windows.Forms.Label(); - this.trackBarWaveformPosition = new System.Windows.Forms.TrackBar(); - this.panelWaveformControls = new System.Windows.Forms.Panel(); - this.toolStripWaveControls = new System.Windows.Forms.ToolStrip(); - this.toolStripButtonWaveformZoomOut = new System.Windows.Forms.ToolStripButton(); - this.toolStripComboBoxWaveform = new System.Windows.Forms.ToolStripComboBox(); - this.toolStripButtonWaveformZoomIn = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator16 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripButtonWaveformPause = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonWaveformPlay = new System.Windows.Forms.ToolStripButton(); - this.toolStripButtonLockCenter = new System.Windows.Forms.ToolStripButton(); - this.toolStripSplitButtonPlayRate = new System.Windows.Forms.ToolStripSplitButton(); - this.tabControlButtons = new System.Windows.Forms.TabControl(); - this.tabPageTranslate = new System.Windows.Forms.TabPage(); - this.labelTranslateTip = new System.Windows.Forms.Label(); - this.groupBoxTranslateSearch = new System.Windows.Forms.GroupBox(); - this.buttonCustomUrl2 = new System.Windows.Forms.Button(); - this.buttonCustomUrl1 = new System.Windows.Forms.Button(); - this.buttonGoogleTranslateIt = new System.Windows.Forms.Button(); - this.buttonGoogleIt = new System.Windows.Forms.Button(); - this.textBoxSearchWord = new System.Windows.Forms.TextBox(); - this.groupBoxAutoContinue = new System.Windows.Forms.GroupBox(); - this.comboBoxAutoContinue = new System.Windows.Forms.ComboBox(); - this.labelAutoContinueDelay = new System.Windows.Forms.Label(); - this.checkBoxAutoContinue = new System.Windows.Forms.CheckBox(); - this.buttonStop = new System.Windows.Forms.Button(); - this.groupBoxAutoRepeat = new System.Windows.Forms.GroupBox(); - this.comboBoxAutoRepeat = new System.Windows.Forms.ComboBox(); - this.labelAutoRepeatCount = new System.Windows.Forms.Label(); - this.checkBoxAutoRepeatOn = new System.Windows.Forms.CheckBox(); - this.buttonPlayPrevious = new System.Windows.Forms.Button(); - this.buttonPlayCurrent = new System.Windows.Forms.Button(); - this.buttonPlayNext = new System.Windows.Forms.Button(); - this.tabPageCreate = new System.Windows.Forms.TabPage(); - this.timeUpDownVideoPosition = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.buttonGotoSub = new System.Windows.Forms.Button(); - this.buttonBeforeText = new System.Windows.Forms.Button(); - this.buttonSetEnd = new System.Windows.Forms.Button(); - this.buttonInsertNewText = new System.Windows.Forms.Button(); - this.buttonSetStartTime = new System.Windows.Forms.Button(); - this.labelCreateF12 = new System.Windows.Forms.Label(); - this.labelCreateF11 = new System.Windows.Forms.Label(); - this.labelCreateF10 = new System.Windows.Forms.Label(); - this.labelCreateF9 = new System.Windows.Forms.Label(); - this.buttonForward2 = new System.Windows.Forms.Button(); - this.numericUpDownSec2 = new System.Windows.Forms.NumericUpDown(); - this.buttonSecBack2 = new System.Windows.Forms.Button(); - this.buttonForward1 = new System.Windows.Forms.Button(); - this.numericUpDownSec1 = new System.Windows.Forms.NumericUpDown(); - this.labelVideoPosition = new System.Windows.Forms.Label(); - this.buttonSecBack1 = new System.Windows.Forms.Button(); - this.tabPageAdjust = new System.Windows.Forms.TabPage(); - this.timeUpDownVideoPositionAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.buttonAdjustSetEndTime = new System.Windows.Forms.Button(); - this.buttonSetEndAndGoToNext = new System.Windows.Forms.Button(); - this.buttonSetStartAndOffsetRest = new System.Windows.Forms.Button(); - this.buttonAdjustSetStartTime = new System.Windows.Forms.Button(); - this.labelAdjustF12 = new System.Windows.Forms.Label(); - this.labelAdjustF11 = new System.Windows.Forms.Label(); - this.labelAdjustF10 = new System.Windows.Forms.Label(); - this.labelAdjustF9 = new System.Windows.Forms.Label(); - this.buttonAdjustSecForward2 = new System.Windows.Forms.Button(); - this.numericUpDownSecAdjust2 = new System.Windows.Forms.NumericUpDown(); - this.buttonAdjustSecBack2 = new System.Windows.Forms.Button(); - this.buttonAdjustSecForward1 = new System.Windows.Forms.Button(); - this.numericUpDownSecAdjust1 = new System.Windows.Forms.NumericUpDown(); - this.buttonAdjustSecBack1 = new System.Windows.Forms.Button(); - this.labelVideoPosition2 = new System.Windows.Forms.Label(); - this.buttonAdjustGoToPosAndPause = new System.Windows.Forms.Button(); - this.buttonAdjustPlayBefore = new System.Windows.Forms.Button(); - this.ShowSubtitleTimer = new System.Windows.Forms.Timer(this.components); - this.timerAutoDuration = new System.Windows.Forms.Timer(this.components); - this.timerAutoContinue = new System.Windows.Forms.Timer(this.components); - this.timerStillTyping = new System.Windows.Forms.Timer(this.components); - this.timerWaveform = new System.Windows.Forms.Timer(this.components); - this.contextMenuStripWaveform = new System.Windows.Forms.ContextMenuStrip(this.components); - this.addParagraphHereToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.addParagraphAndPasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSetParagraphAsSelection = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemFocusTextbox = new System.Windows.Forms.ToolStripMenuItem(); - this.goToPreviousSubtitleStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.goToNextSubtitleStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.deleteParagraphToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.splitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.mergeWithPreviousToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.mergeWithNextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator(); - this.extendToPreviousToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.extendToNextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItemWaveformPlaySelection = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator24 = new System.Windows.Forms.ToolStripSeparator(); - this.showWaveformAndSpectrogramToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.showOnlyWaveformToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.showOnlySpectrogramToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparatorGuessTimeCodes = new System.Windows.Forms.ToolStripSeparator(); - this.removeSceneChangeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.addSceneChangeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.guessTimeCodesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.seekSilenceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.insertSubtitleHereToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.splitContainerMain = new System.Windows.Forms.SplitContainer(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.tabControlSubtitle = new System.Windows.Forms.TabControl(); - this.tabPage1 = new System.Windows.Forms.TabPage(); - this.splitContainerListViewAndText = new System.Windows.Forms.SplitContainer(); - this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.imageListBookmarks = new System.Windows.Forms.ImageList(this.components); - this.groupBoxEdit = new System.Windows.Forms.GroupBox(); - this.labelAlternateSingleLinePixels = new System.Windows.Forms.Label(); - this.labelSingleLinePixels = new System.Windows.Forms.Label(); - this.panelBookmark = new System.Windows.Forms.Panel(); - this.labelBookmark = new System.Windows.Forms.Label(); - this.pictureBoxBookmark = new System.Windows.Forms.PictureBox(); - this.labelSingleLine = new System.Windows.Forms.Label(); - this.labelAlternateSingleLine = new System.Windows.Forms.Label(); - this.labelDurationWarning = new System.Windows.Forms.Label(); - this.labelStartTimeWarning = new System.Windows.Forms.Label(); - this.buttonSplitLine = new System.Windows.Forms.Button(); - this.labelAlternateCharactersPerSecond = new System.Windows.Forms.Label(); - this.labelTextAlternateLineTotal = new System.Windows.Forms.Label(); - this.labelTextAlternateLineLengths = new System.Windows.Forms.Label(); - this.labelAlternateText = new System.Windows.Forms.Label(); - this.labelText = new System.Windows.Forms.Label(); - this.textBoxListViewTextAlternate = new Nikse.SubtitleEdit.Controls.SETextBox(); - this.contextMenuStripTextBoxListView = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemWebVttVoice = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparatorWebVTT = new System.Windows.Forms.ToolStripSeparator(); - this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSplitTextAtCursor = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemSplitViaWaveform = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator18 = new System.Windows.Forms.ToolStripSeparator(); - this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator17 = new System.Windows.Forms.ToolStripSeparator(); - this.normalToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.boldToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.italicToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.boxToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.underlineToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.colorToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemHorizontalDigits = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemBouten = new System.Windows.Forms.ToolStripMenuItem(); - this.boutendotbeforeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boutendotafterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boutendotoutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boutenfilledcircleoutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boutenopencircleoutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boutenopendotoutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boutenfilledsesameoutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boutenopensesameoutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boutenautooutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.boutenautoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemRuby = new System.Windows.Forms.ToolStripMenuItem(); - this.fontNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator26 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItemInsertUnicodeSymbol = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInsertUnicodeControlCharacters = new System.Windows.Forms.ToolStripMenuItem(); - this.leftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.righttoleftMarkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.startOfLefttorightEmbeddingLREToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.startOfRighttoleftEmbeddingRLEToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.startOfLefttorightOverrideLROToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.startOfRighttoleftOverrideRLOToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.superscriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.subscriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.buttonAutoBreak = new System.Windows.Forms.Button(); - this.labelTextLineLengths = new System.Windows.Forms.Label(); - this.labelTextLineTotal = new System.Windows.Forms.Label(); - this.labelCharactersPerSecond = new System.Windows.Forms.Label(); - this.buttonUnBreak = new System.Windows.Forms.Button(); - this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.numericUpDownDuration = new System.Windows.Forms.NumericUpDown(); - this.buttonPrevious = new System.Windows.Forms.Button(); - this.buttonNext = new System.Windows.Forms.Button(); - this.labelStartTime = new System.Windows.Forms.Label(); - this.textBoxListViewText = new Nikse.SubtitleEdit.Controls.SETextBox(); - this.labelDuration = new System.Windows.Forms.Label(); - this.labelAutoDuration = new System.Windows.Forms.Label(); - this.tabPage2 = new System.Windows.Forms.TabPage(); - this.textBoxSource = new System.Windows.Forms.TextBox(); - this.panelVideoPlayer = new System.Windows.Forms.Panel(); - this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); - this.contextMenuStripEmpty = new System.Windows.Forms.ContextMenuStrip(this.components); - this.insertLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.imageListPlayRate = new System.Windows.Forms.ImageList(this.components); - this.timerTextUndo = new System.Windows.Forms.Timer(this.components); - this.timerAlternateTextUndo = new System.Windows.Forms.Timer(this.components); - this.aSSStylesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.statusStrip1.SuspendLayout(); - this.toolStrip1.SuspendLayout(); - this.menuStrip1.SuspendLayout(); - this.contextMenuStripListview.SuspendLayout(); - this.groupBoxVideo.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.trackBarWaveformPosition)).BeginInit(); - this.panelWaveformControls.SuspendLayout(); - this.toolStripWaveControls.SuspendLayout(); - this.tabControlButtons.SuspendLayout(); - this.tabPageTranslate.SuspendLayout(); - this.groupBoxTranslateSearch.SuspendLayout(); - this.groupBoxAutoContinue.SuspendLayout(); - this.groupBoxAutoRepeat.SuspendLayout(); - this.tabPageCreate.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSec2)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSec1)).BeginInit(); - this.tabPageAdjust.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSecAdjust2)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSecAdjust1)).BeginInit(); - this.contextMenuStripWaveform.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainerMain)).BeginInit(); - this.splitContainerMain.Panel1.SuspendLayout(); - this.splitContainerMain.Panel2.SuspendLayout(); - this.splitContainerMain.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - this.tabControlSubtitle.SuspendLayout(); - this.tabPage1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainerListViewAndText)).BeginInit(); - this.splitContainerListViewAndText.Panel1.SuspendLayout(); - this.splitContainerListViewAndText.Panel2.SuspendLayout(); - this.splitContainerListViewAndText.SuspendLayout(); - this.groupBoxEdit.SuspendLayout(); - this.panelBookmark.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBookmark)).BeginInit(); - this.contextMenuStripTextBoxListView.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).BeginInit(); - this.tabPage2.SuspendLayout(); - this.panelVideoPlayer.SuspendLayout(); - this.contextMenuStripEmpty.SuspendLayout(); - this.SuspendLayout(); - // - // statusStrip1 - // - this.statusStrip1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.labelStatus, - this.toolStripSelected, - this.toolStripStatusLabelProgress, - this.toolStripStatusNetworking}); - this.statusStrip1.Location = new System.Drawing.Point(0, 624); - this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(975, 22); - this.statusStrip1.TabIndex = 4; - this.statusStrip1.Text = "statusStrip1"; - // - // labelStatus - // - this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(0, 17); - this.labelStatus.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.labelStatus.Click += new System.EventHandler(this.labelStatus_Click); - // - // toolStripSelected - // - this.toolStripSelected.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.toolStripSelected.Name = "toolStripSelected"; - this.toolStripSelected.Size = new System.Drawing.Size(746, 17); - this.toolStripSelected.Spring = true; - this.toolStripSelected.Text = "toolStripSelected"; - this.toolStripSelected.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.toolStripSelected.Click += new System.EventHandler(this.toolStripSelected_Click); - // - // toolStripStatusLabelProgress - // - this.toolStripStatusLabelProgress.Name = "toolStripStatusLabelProgress"; - this.toolStripStatusLabelProgress.Size = new System.Drawing.Size(166, 17); - this.toolStripStatusLabelProgress.Text = "toolStripStatusLabelProgress"; - this.toolStripStatusLabelProgress.Visible = false; - // - // toolStripStatusNetworking - // - this.toolStripStatusNetworking.Image = global::Nikse.SubtitleEdit.Properties.Resources.connect; - this.toolStripStatusNetworking.Name = "toolStripStatusNetworking"; - this.toolStripStatusNetworking.Padding = new System.Windows.Forms.Padding(50, 0, 0, 0); - this.toolStripStatusNetworking.Size = new System.Drawing.Size(214, 17); - this.toolStripStatusNetworking.Text = "toolStripStatusNetworking"; - this.toolStripStatusNetworking.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.toolStripStatusNetworking.TextImageRelation = System.Windows.Forms.TextImageRelation.TextBeforeImage; - this.toolStripStatusNetworking.Click += new System.EventHandler(this.toolStripStatusNetworking_Click); - // - // toolStrip1 - // - this.toolStrip1.AutoSize = false; - this.toolStrip1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; - this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripButtonFileNew, - this.toolStripButtonFileOpen, - this.toolStripButtonSave, - this.toolStripButtonSaveAs, - this.toolStripSeparatorFindReplace, - this.toolStripButtonFind, - this.toolStripButtonReplace, - this.toolStripSeparatorFixSyncSpell, - this.toolStripButtonFixCommonErrors, - this.toolStripButtonRemoveTextForHi, - this.toolStripButtonVisualSync, - this.toolStripButtonSpellCheck, - this.toolStripButtonNetflixQualityCheck, - this.toolStripButtonSettings, - this.toolStripSeparatorHelp, - this.toolStripButtonHelp, - this.toolStripSeparatorToggle, - this.toolStripButtonToggleWaveform, - this.toolStripButtonToggleVideo, - this.toolStripSeparatorSubtitleFormat, - this.toolStripLabelSubtitleFormat, - this.comboBoxSubtitleFormats, - this.toolStripSeparatorEncoding, - this.toolStripLabelEncoding, - this.comboBoxEncoding, - this.toolStripSeparatorFrameRate, - this.toolStripLabelFrameRate, - this.toolStripComboBoxFrameRate, - this.toolStripButtonGetFrameRate}); - this.toolStrip1.Location = new System.Drawing.Point(0, 24); - this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(975, 40); - this.toolStrip1.TabIndex = 5; - this.toolStrip1.Text = "toolStrip1"; - // - // toolStripButtonFileNew - // - this.toolStripButtonFileNew.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonFileNew.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.toolStripButtonFileNew.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonFileNew.Image"))); - this.toolStripButtonFileNew.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonFileNew.ImageTransparentColor = System.Drawing.Color.Transparent; - this.toolStripButtonFileNew.Name = "toolStripButtonFileNew"; - this.toolStripButtonFileNew.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonFileNew.Text = "New"; - this.toolStripButtonFileNew.ToolTipText = "New"; - this.toolStripButtonFileNew.Click += new System.EventHandler(this.ToolStripButtonFileNewClick); - // - // toolStripButtonFileOpen - // - this.toolStripButtonFileOpen.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonFileOpen.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.toolStripButtonFileOpen.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonFileOpen.Image"))); - this.toolStripButtonFileOpen.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonFileOpen.ImageTransparentColor = System.Drawing.Color.Transparent; - this.toolStripButtonFileOpen.Name = "toolStripButtonFileOpen"; - this.toolStripButtonFileOpen.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonFileOpen.Text = "toolStripButtonOpen"; - this.toolStripButtonFileOpen.ToolTipText = "Open"; - this.toolStripButtonFileOpen.Click += new System.EventHandler(this.ToolStripButtonFileOpenClick); - // - // toolStripButtonSave - // - this.toolStripButtonSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonSave.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.toolStripButtonSave.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonSave.Image"))); - this.toolStripButtonSave.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonSave.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonSave.Name = "toolStripButtonSave"; - this.toolStripButtonSave.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonSave.Text = "toolStripButtonSave"; - this.toolStripButtonSave.ToolTipText = "Save"; - this.toolStripButtonSave.Click += new System.EventHandler(this.ToolStripButtonSaveClick); - // - // toolStripButtonSaveAs - // - this.toolStripButtonSaveAs.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonSaveAs.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.toolStripButtonSaveAs.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonSaveAs.Image"))); - this.toolStripButtonSaveAs.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonSaveAs.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonSaveAs.Name = "toolStripButtonSaveAs"; - this.toolStripButtonSaveAs.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonSaveAs.Text = "toolStripButtonSaveAs"; - this.toolStripButtonSaveAs.ToolTipText = "Save as"; - this.toolStripButtonSaveAs.Click += new System.EventHandler(this.ToolStripButtonSaveAsClick); - // - // toolStripSeparatorFindReplace - // - this.toolStripSeparatorFindReplace.Name = "toolStripSeparatorFindReplace"; - this.toolStripSeparatorFindReplace.Size = new System.Drawing.Size(6, 40); - // - // toolStripButtonFind - // - this.toolStripButtonFind.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonFind.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.toolStripButtonFind.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonFind.Image"))); - this.toolStripButtonFind.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonFind.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonFind.Name = "toolStripButtonFind"; - this.toolStripButtonFind.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonFind.Text = "Find"; - this.toolStripButtonFind.Click += new System.EventHandler(this.ToolStripButtonFindClick); - // - // toolStripButtonReplace - // - this.toolStripButtonReplace.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonReplace.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.toolStripButtonReplace.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonReplace.Image"))); - this.toolStripButtonReplace.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonReplace.ImageTransparentColor = System.Drawing.Color.White; - this.toolStripButtonReplace.Name = "toolStripButtonReplace"; - this.toolStripButtonReplace.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonReplace.Text = "Replace"; - this.toolStripButtonReplace.ToolTipText = "Replace"; - this.toolStripButtonReplace.Click += new System.EventHandler(this.ToolStripButtonReplaceClick); - // - // toolStripSeparatorFixSyncSpell - // - this.toolStripSeparatorFixSyncSpell.Name = "toolStripSeparatorFixSyncSpell"; - this.toolStripSeparatorFixSyncSpell.Size = new System.Drawing.Size(6, 40); - // - // toolStripButtonFixCommonErrors - // - this.toolStripButtonFixCommonErrors.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonFixCommonErrors.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.toolStripButtonFixCommonErrors.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonFixCommonErrors.Image"))); - this.toolStripButtonFixCommonErrors.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonFixCommonErrors.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonFixCommonErrors.Name = "toolStripButtonFixCommonErrors"; - this.toolStripButtonFixCommonErrors.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonFixCommonErrors.Text = "Fix common errors"; - this.toolStripButtonFixCommonErrors.ToolTipText = "Fix common errors"; - this.toolStripButtonFixCommonErrors.Click += new System.EventHandler(this.toolStripButtonFixCommonErrors_Click); - // - // toolStripButtonRemoveTextForHi - // - this.toolStripButtonRemoveTextForHi.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonRemoveTextForHi.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.toolStripButtonRemoveTextForHi.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonRemoveTextForHi.Image"))); - this.toolStripButtonRemoveTextForHi.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonRemoveTextForHi.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonRemoveTextForHi.Name = "toolStripButtonRemoveTextForHi"; - this.toolStripButtonRemoveTextForHi.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonRemoveTextForHi.Text = "Remove text for HI"; - this.toolStripButtonRemoveTextForHi.ToolTipText = "Fix common errors"; - this.toolStripButtonRemoveTextForHi.Click += new System.EventHandler(this.toolStripButtonRemoveTextForHi_Click); - // - // toolStripButtonVisualSync - // - this.toolStripButtonVisualSync.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonVisualSync.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.toolStripButtonVisualSync.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonVisualSync.Image"))); - this.toolStripButtonVisualSync.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonVisualSync.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonVisualSync.Name = "toolStripButtonVisualSync"; - this.toolStripButtonVisualSync.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonVisualSync.Text = "Visual sync"; - this.toolStripButtonVisualSync.Click += new System.EventHandler(this.ToolStripButtonVisualSyncClick); - // - // toolStripButtonSpellCheck - // - this.toolStripButtonSpellCheck.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonSpellCheck.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.toolStripButtonSpellCheck.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonSpellCheck.Image"))); - this.toolStripButtonSpellCheck.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonSpellCheck.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonSpellCheck.Name = "toolStripButtonSpellCheck"; - this.toolStripButtonSpellCheck.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonSpellCheck.Text = "Spell check"; - this.toolStripButtonSpellCheck.Click += new System.EventHandler(this.ToolStripButtonSpellCheckClick); - // - // toolStripButtonNetflixQualityCheck - // - this.toolStripButtonNetflixQualityCheck.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonNetflixQualityCheck.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonNetflixQualityCheck.Image"))); - this.toolStripButtonNetflixQualityCheck.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonNetflixQualityCheck.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonNetflixQualityCheck.Name = "toolStripButtonNetflixQualityCheck"; - this.toolStripButtonNetflixQualityCheck.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonNetflixQualityCheck.Text = "Netflix quality check"; - this.toolStripButtonNetflixQualityCheck.Click += new System.EventHandler(this.toolStripButtonNetflixGlyphCheck_Click); - // - // toolStripButtonSettings - // - this.toolStripButtonSettings.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonSettings.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.toolStripButtonSettings.Image = global::Nikse.SubtitleEdit.Properties.Resources.Settings; - this.toolStripButtonSettings.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonSettings.ImageTransparentColor = System.Drawing.Color.Transparent; - this.toolStripButtonSettings.Name = "toolStripButtonSettings"; - this.toolStripButtonSettings.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonSettings.Text = "Settings"; - this.toolStripButtonSettings.Click += new System.EventHandler(this.ToolStripButtonSettingsClick); - // - // toolStripSeparatorHelp - // - this.toolStripSeparatorHelp.Name = "toolStripSeparatorHelp"; - this.toolStripSeparatorHelp.Size = new System.Drawing.Size(6, 40); - // - // toolStripButtonHelp - // - this.toolStripButtonHelp.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonHelp.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.toolStripButtonHelp.Image = global::Nikse.SubtitleEdit.Properties.Resources.Help; - this.toolStripButtonHelp.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonHelp.ImageTransparentColor = System.Drawing.Color.Transparent; - this.toolStripButtonHelp.Name = "toolStripButtonHelp"; - this.toolStripButtonHelp.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonHelp.Text = "Help"; - this.toolStripButtonHelp.Click += new System.EventHandler(this.ToolStripButtonHelpClick); - // - // toolStripSeparatorToggle - // - this.toolStripSeparatorToggle.Name = "toolStripSeparatorToggle"; - this.toolStripSeparatorToggle.Size = new System.Drawing.Size(6, 40); - // - // toolStripButtonToggleWaveform - // - this.toolStripButtonToggleWaveform.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonToggleWaveform.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.toolStripButtonToggleWaveform.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonToggleWaveform.Image"))); - this.toolStripButtonToggleWaveform.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonToggleWaveform.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonToggleWaveform.Name = "toolStripButtonToggleWaveform"; - this.toolStripButtonToggleWaveform.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonToggleWaveform.Text = "Show/hide waveform"; - this.toolStripButtonToggleWaveform.Click += new System.EventHandler(this.toolStripButtonToggleWaveform_Click); - // - // toolStripButtonToggleVideo - // - this.toolStripButtonToggleVideo.Checked = true; - this.toolStripButtonToggleVideo.CheckState = System.Windows.Forms.CheckState.Checked; - this.toolStripButtonToggleVideo.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonToggleVideo.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.toolStripButtonToggleVideo.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonToggleVideo.Image"))); - this.toolStripButtonToggleVideo.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.toolStripButtonToggleVideo.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonToggleVideo.Name = "toolStripButtonToggleVideo"; - this.toolStripButtonToggleVideo.Size = new System.Drawing.Size(36, 37); - this.toolStripButtonToggleVideo.Text = "Show/hide video"; - this.toolStripButtonToggleVideo.Click += new System.EventHandler(this.toolStripButtonToggleVideo_Click); - // - // toolStripSeparatorSubtitleFormat - // - this.toolStripSeparatorSubtitleFormat.Name = "toolStripSeparatorSubtitleFormat"; - this.toolStripSeparatorSubtitleFormat.Size = new System.Drawing.Size(6, 40); - // - // toolStripLabelSubtitleFormat - // - this.toolStripLabelSubtitleFormat.Name = "toolStripLabelSubtitleFormat"; - this.toolStripLabelSubtitleFormat.Size = new System.Drawing.Size(86, 37); - this.toolStripLabelSubtitleFormat.Text = "Subtitle format"; - // - // comboBoxSubtitleFormats - // - this.comboBoxSubtitleFormats.DropDownHeight = 215; - this.comboBoxSubtitleFormats.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSubtitleFormats.FlatStyle = System.Windows.Forms.FlatStyle.Standard; - this.comboBoxSubtitleFormats.IntegralHeight = false; - this.comboBoxSubtitleFormats.Name = "comboBoxSubtitleFormats"; - this.comboBoxSubtitleFormats.Size = new System.Drawing.Size(150, 40); - this.comboBoxSubtitleFormats.DropDown += new System.EventHandler(this.comboBoxSubtitleFormats_DropDown); - this.comboBoxSubtitleFormats.DropDownClosed += new System.EventHandler(this.comboBoxSubtitleFormats_DropDownClosed); - this.comboBoxSubtitleFormats.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSubtitleFormatsSelectedIndexChanged); - this.comboBoxSubtitleFormats.Enter += new System.EventHandler(this.ComboBoxSubtitleFormatsEnter); - // - // toolStripSeparatorEncoding - // - this.toolStripSeparatorEncoding.Name = "toolStripSeparatorEncoding"; - this.toolStripSeparatorEncoding.Size = new System.Drawing.Size(6, 40); - // - // toolStripLabelEncoding - // - this.toolStripLabelEncoding.Name = "toolStripLabelEncoding"; - this.toolStripLabelEncoding.Size = new System.Drawing.Size(81, 37); - this.toolStripLabelEncoding.Text = "File encoding"; - // - // comboBoxEncoding - // - this.comboBoxEncoding.DropDownHeight = 215; - this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxEncoding.FlatStyle = System.Windows.Forms.FlatStyle.Standard; - this.comboBoxEncoding.IntegralHeight = false; - this.comboBoxEncoding.Items.AddRange(new object[] { - "ANSI", - "UTF-7", - "UTF-8", - "Unicode", - "Unicode (big endian)"}); - this.comboBoxEncoding.Name = "comboBoxEncoding"; - this.comboBoxEncoding.Size = new System.Drawing.Size(129, 23); - this.comboBoxEncoding.DropDown += new System.EventHandler(this.MenuOpened); - this.comboBoxEncoding.DropDownClosed += new System.EventHandler(this.MenuClosed); - // - // toolStripSeparatorFrameRate - // - this.toolStripSeparatorFrameRate.Name = "toolStripSeparatorFrameRate"; - this.toolStripSeparatorFrameRate.Size = new System.Drawing.Size(6, 40); - // - // toolStripLabelFrameRate - // - this.toolStripLabelFrameRate.Name = "toolStripLabelFrameRate"; - this.toolStripLabelFrameRate.Size = new System.Drawing.Size(67, 15); - this.toolStripLabelFrameRate.Text = "Frame rate"; - // - // toolStripComboBoxFrameRate - // - this.toolStripComboBoxFrameRate.DropDownWidth = 75; - this.toolStripComboBoxFrameRate.FlatStyle = System.Windows.Forms.FlatStyle.Standard; - this.toolStripComboBoxFrameRate.Name = "toolStripComboBoxFrameRate"; - this.toolStripComboBoxFrameRate.Size = new System.Drawing.Size(75, 23); - this.toolStripComboBoxFrameRate.DropDown += new System.EventHandler(this.MenuOpened); - this.toolStripComboBoxFrameRate.DropDownClosed += new System.EventHandler(this.MenuClosed); - this.toolStripComboBoxFrameRate.TextChanged += new System.EventHandler(this.ToolStripComboBoxFrameRateTextChanged); - // - // toolStripButtonGetFrameRate - // - this.toolStripButtonGetFrameRate.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.toolStripButtonGetFrameRate.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonGetFrameRate.Image"))); - this.toolStripButtonGetFrameRate.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonGetFrameRate.Name = "toolStripButtonGetFrameRate"; - this.toolStripButtonGetFrameRate.Size = new System.Drawing.Size(23, 19); - this.toolStripButtonGetFrameRate.Text = "..."; - this.toolStripButtonGetFrameRate.ToolTipText = "Get frame rate from video file"; - this.toolStripButtonGetFrameRate.Click += new System.EventHandler(this.ButtonGetFrameRateClick); - // - // menuStrip1 - // - this.menuStrip1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.fileToolStripMenuItem, - this.editToolStripMenuItem, - this.toolsToolStripMenuItem, - this.toolStripMenuItemSpellCheckMain, - this.toolStripMenuItemVideo, - this.toolStripMenuItemSynchronization, - this.toolStripMenuItemAutoTranslate, - this.optionsToolStripMenuItem, - this.toolStripMenuItemNetworking, - this.helpToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(975, 24); - this.menuStrip1.TabIndex = 6; - this.menuStrip1.Text = "menuStrip1"; - // - // fileToolStripMenuItem - // - this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.newToolStripMenuItem, - this.openToolStripMenuItem, - this.toolStripMenuItemOpenKeepVideo, - this.reopenToolStripMenuItem, - this.saveToolStripMenuItem, - this.saveAsToolStripMenuItem, - this.toolStripMenuItemRestoreAutoBackup, - this.toolStripMenuItemDCinemaProperties, - this.toolStripMenuItemTTProperties, - this.toolStripMenuItemNuendoProperties, - this.toolStripMenuItemFcpProperties, - this.toolStripMenuItemSubStationAlpha, - this.toolStripMenuItemAssaStyles, - this.toolStripMenuItemEbuProperties, - this.toolStripMenuItemDvdStudioProProperties, - this.toolStripSeparator20, - this.openOriginalToolStripMenuItem, - this.saveOriginalToolStripMenuItem, - this.saveOriginalAstoolStripMenuItem, - this.removeOriginalToolStripMenuItem, - this.toolStripSeparator12, - this.toolStripMenuItemOpenContainingFolder, - this.toolStripMenuItemCompare, - this.toolStripMenuItemStatistics, - this.toolStripMenuItemPlugins, - this.toolStripSeparator1, - this.toolStripMenuItemImportDvdSubtitles, - this.toolStripMenuItemSubIdx, - this.toolStripMenuItemImportBluRaySup, - this.toolStripMenuItemImportXSub, - this.toolStripMenuItemImportOcrHardSub, - this.matroskaImportStripMenuItem, - this.toolStripMenuItemManualAnsi, - this.toolStripMenuItemImportText, - this.toolStripMenuItemImportImages, - this.toolStripMenuItemImportTimeCodes, - this.toolStripSeparator22, - this.toolStripMenuItemExport, - this.toolStripSeparator10, - this.exitToolStripMenuItem}); - this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - this.fileToolStripMenuItem.Size = new System.Drawing.Size(39, 20); - this.fileToolStripMenuItem.Text = "File"; - this.fileToolStripMenuItem.DropDownOpening += new System.EventHandler(this.fileToolStripMenuItem_DropDownOpening); - // - // newToolStripMenuItem - // - this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); - this.newToolStripMenuItem.Size = new System.Drawing.Size(335, 22); - this.newToolStripMenuItem.Text = "New"; - this.newToolStripMenuItem.Click += new System.EventHandler(this.NewToolStripMenuItemClick); - // - // openToolStripMenuItem - // - this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); - this.openToolStripMenuItem.Size = new System.Drawing.Size(335, 22); - this.openToolStripMenuItem.Text = "Open"; - this.openToolStripMenuItem.Click += new System.EventHandler(this.OpenToolStripMenuItemClick); - // - // toolStripMenuItemOpenKeepVideo - // - this.toolStripMenuItemOpenKeepVideo.Name = "toolStripMenuItemOpenKeepVideo"; - this.toolStripMenuItemOpenKeepVideo.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemOpenKeepVideo.Text = "Open (keep video)"; - this.toolStripMenuItemOpenKeepVideo.Click += new System.EventHandler(this.toolStripMenuItemOpenKeepVideo_Click); - // - // reopenToolStripMenuItem - // - this.reopenToolStripMenuItem.Name = "reopenToolStripMenuItem"; - this.reopenToolStripMenuItem.Size = new System.Drawing.Size(335, 22); - this.reopenToolStripMenuItem.Text = "Reopen"; - // - // saveToolStripMenuItem - // - this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); - this.saveToolStripMenuItem.Size = new System.Drawing.Size(335, 22); - this.saveToolStripMenuItem.Text = "Save"; - this.saveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItemClick); - // - // saveAsToolStripMenuItem - // - this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; - this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(335, 22); - this.saveAsToolStripMenuItem.Text = "Save as..."; - this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.SaveAsToolStripMenuItemClick); - // - // toolStripMenuItemRestoreAutoBackup - // - this.toolStripMenuItemRestoreAutoBackup.Name = "toolStripMenuItemRestoreAutoBackup"; - this.toolStripMenuItemRestoreAutoBackup.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemRestoreAutoBackup.Text = "Restore auto-backup..."; - this.toolStripMenuItemRestoreAutoBackup.Click += new System.EventHandler(this.toolStripMenuItemRestoreAutoBackup_Click); - // - // toolStripMenuItemDCinemaProperties - // - this.toolStripMenuItemDCinemaProperties.Name = "toolStripMenuItemDCinemaProperties"; - this.toolStripMenuItemDCinemaProperties.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemDCinemaProperties.Text = "DCinema properties..."; - this.toolStripMenuItemDCinemaProperties.Click += new System.EventHandler(this.toolStripMenuItemDCinemaProperties_Click); - // - // toolStripMenuItemTTProperties - // - this.toolStripMenuItemTTProperties.Name = "toolStripMenuItemTTProperties"; - this.toolStripMenuItemTTProperties.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemTTProperties.Text = "Timed Text properties..."; - this.toolStripMenuItemTTProperties.Click += new System.EventHandler(this.toolStripMenuItemTTPropertiesClick); - // - // toolStripMenuItemNuendoProperties - // - this.toolStripMenuItemNuendoProperties.Name = "toolStripMenuItemNuendoProperties"; - this.toolStripMenuItemNuendoProperties.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemNuendoProperties.Text = "Nuendo properties..."; - this.toolStripMenuItemNuendoProperties.Click += new System.EventHandler(this.ToolStripMenuItemNuendoPropertiesClick); - // - // toolStripMenuItemFcpProperties - // - this.toolStripMenuItemFcpProperties.Name = "toolStripMenuItemFcpProperties"; - this.toolStripMenuItemFcpProperties.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemFcpProperties.Text = "Final Cut Pro properties..."; - this.toolStripMenuItemFcpProperties.Click += new System.EventHandler(this.toolStripMenuItemFcpProperties_Click); - // - // toolStripMenuItemSubStationAlpha - // - this.toolStripMenuItemSubStationAlpha.Name = "toolStripMenuItemSubStationAlpha"; - this.toolStripMenuItemSubStationAlpha.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemSubStationAlpha.Text = "Advanced Sub Station Alpha properties..."; - this.toolStripMenuItemSubStationAlpha.Click += new System.EventHandler(this.toolStripMenuItemSubStationAlpha_Click); - // - // toolStripMenuItemAssaStyles - // - this.toolStripMenuItemAssaStyles.Name = "toolStripMenuItemAssaStyles"; - this.toolStripMenuItemAssaStyles.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemAssaStyles.Text = "Advanced Sub Station Alpha styles..."; - this.toolStripMenuItemAssaStyles.Click += new System.EventHandler(this.toolStripMenuItemAssaStyles_Click); - // - // toolStripMenuItemEbuProperties - // - this.toolStripMenuItemEbuProperties.Name = "toolStripMenuItemEbuProperties"; - this.toolStripMenuItemEbuProperties.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemEbuProperties.Text = "Ebu properties..."; - this.toolStripMenuItemEbuProperties.Click += new System.EventHandler(this.toolStripMenuItemEbuProperties_Click); - // - // toolStripMenuItemDvdStudioProProperties - // - this.toolStripMenuItemDvdStudioProProperties.Name = "toolStripMenuItemDvdStudioProProperties"; - this.toolStripMenuItemDvdStudioProProperties.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemDvdStudioProProperties.Text = "DVD Studio Pro properties..."; - this.toolStripMenuItemDvdStudioProProperties.Click += new System.EventHandler(this.toolStripMenuDvdStudioProperties_Click); - // - // toolStripSeparator20 - // - this.toolStripSeparator20.Name = "toolStripSeparator20"; - this.toolStripSeparator20.Size = new System.Drawing.Size(332, 6); - // - // openOriginalToolStripMenuItem - // - this.openOriginalToolStripMenuItem.Name = "openOriginalToolStripMenuItem"; - this.openOriginalToolStripMenuItem.Size = new System.Drawing.Size(335, 22); - this.openOriginalToolStripMenuItem.Text = "Open original (translator mode)..."; - this.openOriginalToolStripMenuItem.Click += new System.EventHandler(this.OpenOriginalToolStripMenuItemClick); - // - // saveOriginalToolStripMenuItem - // - this.saveOriginalToolStripMenuItem.Name = "saveOriginalToolStripMenuItem"; - this.saveOriginalToolStripMenuItem.Size = new System.Drawing.Size(335, 22); - this.saveOriginalToolStripMenuItem.Text = "Save original"; - this.saveOriginalToolStripMenuItem.Click += new System.EventHandler(this.SaveOriginalToolStripMenuItemClick); - // - // saveOriginalAstoolStripMenuItem - // - this.saveOriginalAstoolStripMenuItem.Name = "saveOriginalAstoolStripMenuItem"; - this.saveOriginalAstoolStripMenuItem.Size = new System.Drawing.Size(335, 22); - this.saveOriginalAstoolStripMenuItem.Text = "Save original as..."; - this.saveOriginalAstoolStripMenuItem.Click += new System.EventHandler(this.SaveOriginalAstoolStripMenuItemClick); - // - // removeOriginalToolStripMenuItem - // - this.removeOriginalToolStripMenuItem.Name = "removeOriginalToolStripMenuItem"; - this.removeOriginalToolStripMenuItem.Size = new System.Drawing.Size(335, 22); - this.removeOriginalToolStripMenuItem.Text = "Remove original"; - this.removeOriginalToolStripMenuItem.Click += new System.EventHandler(this.RemoveOriginalToolStripMenuItemClick); - // - // toolStripSeparator12 - // - this.toolStripSeparator12.Name = "toolStripSeparator12"; - this.toolStripSeparator12.Size = new System.Drawing.Size(332, 6); - // - // toolStripMenuItemOpenContainingFolder - // - this.toolStripMenuItemOpenContainingFolder.Name = "toolStripMenuItemOpenContainingFolder"; - this.toolStripMenuItemOpenContainingFolder.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemOpenContainingFolder.Text = "Open containing folder"; - this.toolStripMenuItemOpenContainingFolder.Click += new System.EventHandler(this.toolStripMenuItemOpenContainingFolder_Click); - // - // toolStripMenuItemCompare - // - this.toolStripMenuItemCompare.Name = "toolStripMenuItemCompare"; - this.toolStripMenuItemCompare.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemCompare.Text = "Compare..."; - this.toolStripMenuItemCompare.Click += new System.EventHandler(this.ToolStripMenuItemCompareClick); - // - // toolStripMenuItemStatistics - // - this.toolStripMenuItemStatistics.Name = "toolStripMenuItemStatistics"; - this.toolStripMenuItemStatistics.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemStatistics.Text = "Statistics..."; - this.toolStripMenuItemStatistics.Click += new System.EventHandler(this.toolStripMenuItemStatistics_Click); - // - // toolStripMenuItemPlugins - // - this.toolStripMenuItemPlugins.Name = "toolStripMenuItemPlugins"; - this.toolStripMenuItemPlugins.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemPlugins.Text = "Plugins..."; - this.toolStripMenuItemPlugins.Click += new System.EventHandler(this.toolStripMenuItemPlugins_Click); - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(332, 6); - // - // toolStripMenuItemImportDvdSubtitles - // - this.toolStripMenuItemImportDvdSubtitles.Name = "toolStripMenuItemImportDvdSubtitles"; - this.toolStripMenuItemImportDvdSubtitles.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemImportDvdSubtitles.Text = "Import/OCR subtitle from VOB/IFO (DVD) ..."; - this.toolStripMenuItemImportDvdSubtitles.Click += new System.EventHandler(this.ToolStripMenuItemImportDvdSubtitlesClick); - // - // toolStripMenuItemSubIdx - // - this.toolStripMenuItemSubIdx.Name = "toolStripMenuItemSubIdx"; - this.toolStripMenuItemSubIdx.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemSubIdx.Text = "Import/OCR VobSub (sub/idx) subtitle..."; - this.toolStripMenuItemSubIdx.Click += new System.EventHandler(this.ToolStripMenuItemSubIdxClick1); - // - // toolStripMenuItemImportBluRaySup - // - this.toolStripMenuItemImportBluRaySup.Name = "toolStripMenuItemImportBluRaySup"; - this.toolStripMenuItemImportBluRaySup.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemImportBluRaySup.Text = "Import/OCR Blu-ray sup file..."; - this.toolStripMenuItemImportBluRaySup.Click += new System.EventHandler(this.toolStripMenuItemImportBluRaySup_Click); - // - // toolStripMenuItemImportXSub - // - this.toolStripMenuItemImportXSub.Name = "toolStripMenuItemImportXSub"; - this.toolStripMenuItemImportXSub.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemImportXSub.Text = "Import/OCR XSub from divx/avi..."; - this.toolStripMenuItemImportXSub.Click += new System.EventHandler(this.toolStripMenuItemImportXSub_Click); - // - // toolStripMenuItemImportOcrHardSub - // - this.toolStripMenuItemImportOcrHardSub.Name = "toolStripMenuItemImportOcrHardSub"; - this.toolStripMenuItemImportOcrHardSub.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemImportOcrHardSub.Text = "Import/OCR burned-in subtitles from video file..."; - this.toolStripMenuItemImportOcrHardSub.Click += new System.EventHandler(this.toolStripMenuItemImportOcrHardSub_Click); - // - // matroskaImportStripMenuItem - // - this.matroskaImportStripMenuItem.Name = "matroskaImportStripMenuItem"; - this.matroskaImportStripMenuItem.Size = new System.Drawing.Size(335, 22); - this.matroskaImportStripMenuItem.Text = "Import subtitle from Matroska file..."; - this.matroskaImportStripMenuItem.Click += new System.EventHandler(this.MatroskaImportStripMenuItemClick); - // - // toolStripMenuItemManualAnsi - // - this.toolStripMenuItemManualAnsi.Name = "toolStripMenuItemManualAnsi"; - this.toolStripMenuItemManualAnsi.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemManualAnsi.Text = "Import subtitle with manually chosen encoding..."; - this.toolStripMenuItemManualAnsi.Click += new System.EventHandler(this.ToolStripMenuItemManualAnsiClick); - // - // toolStripMenuItemImportText - // - this.toolStripMenuItemImportText.Name = "toolStripMenuItemImportText"; - this.toolStripMenuItemImportText.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemImportText.Text = "Import text..."; - this.toolStripMenuItemImportText.Click += new System.EventHandler(this.ToolStripMenuItemImportTextClick); - // - // toolStripMenuItemImportImages - // - this.toolStripMenuItemImportImages.Name = "toolStripMenuItemImportImages"; - this.toolStripMenuItemImportImages.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemImportImages.Text = "Import images..."; - this.toolStripMenuItemImportImages.Click += new System.EventHandler(this.toolStripMenuItemImportImages_Click); - // - // toolStripMenuItemImportTimeCodes - // - this.toolStripMenuItemImportTimeCodes.Name = "toolStripMenuItemImportTimeCodes"; - this.toolStripMenuItemImportTimeCodes.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemImportTimeCodes.Text = "Import time codes into existing subtitle..."; - this.toolStripMenuItemImportTimeCodes.Click += new System.EventHandler(this.toolStripMenuItemImportTimeCodes_Click); - // - // toolStripSeparator22 - // - this.toolStripSeparator22.Name = "toolStripSeparator22"; - this.toolStripSeparator22.Size = new System.Drawing.Size(332, 6); - // - // toolStripMenuItemExport - // - this.toolStripMenuItemExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.adobeEncoreFABImageScriptToolStripMenuItem, - this.toolStripMenuItemAvidStl, - this.toolStripMenuItemExportAyato, - this.toolStripMenuItemExportPngXml, - this.bluraySupToolStripMenuItem, - this.toolStripMenuItemExportBdTextSt, - this.toolStripMenuItemExportCapMakerPlus, - this.toolStripMenuItemExportCaptionInc, - this.toolStripMenuItemCavena890, - this.toolStripMenuItemExportCheetahCap, - this.toolStripMenuItemExportDcinemaInterop, - this.dCinemaSMPTE2014ToolStripMenuItem, - this.toolStripMenuItemDost, - this.DvdStudioProStl, - this.eBUSTLToolStripMenuItem, - this.toolStripMenuItemEdl, - this.toolStripMenuItemEdlClipName, - this.toolStripMenuItemExportFcpIImage, - this.toolStripMenuItemFcpXmlAdvanced, - this.toolStripMenuItemImagePerFrame, - this.toolStripMenuItemTextTimeCodePair, - this.pACScreenElectronicsToolStripMenuItem, - this.uniPacExportToolStripMenuItem, - this.plainTextToolStripMenuItem, - this.toolStripMenuItemSpumux, - this.toolStripMenuItemExportUltech130, - this.vobSubsubidxToolStripMenuItem, - this.toolStripSeparatorExportCustomText, - this.exportCustomTextFormatToolStripMenuItem}); - this.toolStripMenuItemExport.Name = "toolStripMenuItemExport"; - this.toolStripMenuItemExport.Size = new System.Drawing.Size(335, 22); - this.toolStripMenuItemExport.Text = "Export"; - // - // adobeEncoreFABImageScriptToolStripMenuItem - // - this.adobeEncoreFABImageScriptToolStripMenuItem.Name = "adobeEncoreFABImageScriptToolStripMenuItem"; - this.adobeEncoreFABImageScriptToolStripMenuItem.Size = new System.Drawing.Size(255, 22); - this.adobeEncoreFABImageScriptToolStripMenuItem.Text = "Adobe Encore FAB image script..."; - this.adobeEncoreFABImageScriptToolStripMenuItem.Click += new System.EventHandler(this.AdobeEncoreFabImageScriptToolStripMenuItemClick); - // - // toolStripMenuItemAvidStl - // - this.toolStripMenuItemAvidStl.Name = "toolStripMenuItemAvidStl"; - this.toolStripMenuItemAvidStl.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemAvidStl.Text = "Avid STL..."; - this.toolStripMenuItemAvidStl.Click += new System.EventHandler(this.toolStripMenuItemAvidStl_Click); - // - // toolStripMenuItemExportAyato - // - this.toolStripMenuItemExportAyato.Name = "toolStripMenuItemExportAyato"; - this.toolStripMenuItemExportAyato.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemExportAyato.Text = "Ayato..."; - this.toolStripMenuItemExportAyato.Click += new System.EventHandler(this.toolStripMenuItemExportAyato_Click); - // - // toolStripMenuItemExportPngXml - // - this.toolStripMenuItemExportPngXml.Name = "toolStripMenuItemExportPngXml"; - this.toolStripMenuItemExportPngXml.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemExportPngXml.Text = "BDN xml/png..."; - this.toolStripMenuItemExportPngXml.Click += new System.EventHandler(this.ToolStripMenuItemExportPngXmlClick); - // - // bluraySupToolStripMenuItem - // - this.bluraySupToolStripMenuItem.Name = "bluraySupToolStripMenuItem"; - this.bluraySupToolStripMenuItem.Size = new System.Drawing.Size(255, 22); - this.bluraySupToolStripMenuItem.Text = "Blu-ray sup..."; - this.bluraySupToolStripMenuItem.Click += new System.EventHandler(this.BluraySupToolStripMenuItemClick); - // - // toolStripMenuItemExportBdTextSt - // - this.toolStripMenuItemExportBdTextSt.Name = "toolStripMenuItemExportBdTextSt"; - this.toolStripMenuItemExportBdTextSt.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemExportBdTextSt.Text = "Blu-ray TextST..."; - this.toolStripMenuItemExportBdTextSt.Click += new System.EventHandler(this.toolStripMenuItemExportBdTextSt_Click); - // - // toolStripMenuItemExportCapMakerPlus - // - this.toolStripMenuItemExportCapMakerPlus.Name = "toolStripMenuItemExportCapMakerPlus"; - this.toolStripMenuItemExportCapMakerPlus.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemExportCapMakerPlus.Text = "CapMaker Plus..."; - this.toolStripMenuItemExportCapMakerPlus.Click += new System.EventHandler(this.toolStripMenuItemExportCapMakerPlus_Click); - // - // toolStripMenuItemExportCaptionInc - // - this.toolStripMenuItemExportCaptionInc.Name = "toolStripMenuItemExportCaptionInc"; - this.toolStripMenuItemExportCaptionInc.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemExportCaptionInc.Text = "Captions Inc..."; - this.toolStripMenuItemExportCaptionInc.Click += new System.EventHandler(this.toolStripMenuItemExportCaptionInc_Click); - // - // toolStripMenuItemCavena890 - // - this.toolStripMenuItemCavena890.Name = "toolStripMenuItemCavena890"; - this.toolStripMenuItemCavena890.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemCavena890.Text = "Cavena 890..."; - this.toolStripMenuItemCavena890.Click += new System.EventHandler(this.ToolStripMenuItemCavena890Click); - // - // toolStripMenuItemExportCheetahCap - // - this.toolStripMenuItemExportCheetahCap.Name = "toolStripMenuItemExportCheetahCap"; - this.toolStripMenuItemExportCheetahCap.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemExportCheetahCap.Text = "Cheetah CAP..."; - this.toolStripMenuItemExportCheetahCap.Click += new System.EventHandler(this.toolStripMenuItemExportCheetahCap_Click); - // - // toolStripMenuItemExportDcinemaInterop - // - this.toolStripMenuItemExportDcinemaInterop.Name = "toolStripMenuItemExportDcinemaInterop"; - this.toolStripMenuItemExportDcinemaInterop.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemExportDcinemaInterop.Text = "D-Cinema interop/png..."; - this.toolStripMenuItemExportDcinemaInterop.Click += new System.EventHandler(this.toolStripMenuItemExportDcinemaInteropClick); - // - // dCinemaSMPTE2014ToolStripMenuItem - // - this.dCinemaSMPTE2014ToolStripMenuItem.Name = "dCinemaSMPTE2014ToolStripMenuItem"; - this.dCinemaSMPTE2014ToolStripMenuItem.Size = new System.Drawing.Size(255, 22); - this.dCinemaSMPTE2014ToolStripMenuItem.Text = "D-Cinema SMPTE 2014"; - this.dCinemaSMPTE2014ToolStripMenuItem.Click += new System.EventHandler(this.dCinemaSMPTE2014ToolStripMenuItem_Click); - // - // toolStripMenuItemDost - // - this.toolStripMenuItemDost.Name = "toolStripMenuItemDost"; - this.toolStripMenuItemDost.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemDost.Text = "DOST..."; - this.toolStripMenuItemDost.Click += new System.EventHandler(this.toolStripMenuItemDost_Click); - // - // DvdStudioProStl - // - this.DvdStudioProStl.Name = "DvdStudioProStl"; - this.DvdStudioProStl.Size = new System.Drawing.Size(255, 22); - this.DvdStudioProStl.Text = "DVD Studio Pro STL"; - this.DvdStudioProStl.Click += new System.EventHandler(this.DvdStudioProStl_Click); - // - // eBUSTLToolStripMenuItem - // - this.eBUSTLToolStripMenuItem.Name = "eBUSTLToolStripMenuItem"; - this.eBUSTLToolStripMenuItem.Size = new System.Drawing.Size(255, 22); - this.eBUSTLToolStripMenuItem.Text = "EBU STL..."; - this.eBUSTLToolStripMenuItem.Click += new System.EventHandler(this.EBustlToolStripMenuItemClick); - // - // toolStripMenuItemEdl - // - this.toolStripMenuItemEdl.Name = "toolStripMenuItemEdl"; - this.toolStripMenuItemEdl.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemEdl.Text = "EDL..."; - this.toolStripMenuItemEdl.Click += new System.EventHandler(this.ExportToEdl); - // - // toolStripMenuItemEdlClipName - // - this.toolStripMenuItemEdlClipName.Name = "toolStripMenuItemEdlClipName"; - this.toolStripMenuItemEdlClipName.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemEdlClipName.Text = "EDL/CLIPNAME..."; - this.toolStripMenuItemEdlClipName.Click += new System.EventHandler(this.ExportToEdlWithClipName); - // - // toolStripMenuItemExportFcpIImage - // - this.toolStripMenuItemExportFcpIImage.Name = "toolStripMenuItemExportFcpIImage"; - this.toolStripMenuItemExportFcpIImage.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemExportFcpIImage.Text = "Final Cut Pro + image..."; - this.toolStripMenuItemExportFcpIImage.Click += new System.EventHandler(this.toolStripMenuItemExportFcpIImage_Click); - // - // toolStripMenuItemFcpXmlAdvanced - // - this.toolStripMenuItemFcpXmlAdvanced.Name = "toolStripMenuItemFcpXmlAdvanced"; - this.toolStripMenuItemFcpXmlAdvanced.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemFcpXmlAdvanced.Text = "Final Cut Pro XML advanced..."; - this.toolStripMenuItemFcpXmlAdvanced.Click += new System.EventHandler(this.toolStripMenuItemFcpXmlAdvanced_Click); - // - // toolStripMenuItemImagePerFrame - // - this.toolStripMenuItemImagePerFrame.Name = "toolStripMenuItemImagePerFrame"; - this.toolStripMenuItemImagePerFrame.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemImagePerFrame.Text = "Image per frame..."; - this.toolStripMenuItemImagePerFrame.Visible = false; - this.toolStripMenuItemImagePerFrame.Click += new System.EventHandler(this.ToolStripMenuItemImagePerFrameClick); - // - // toolStripMenuItemTextTimeCodePair - // - this.toolStripMenuItemTextTimeCodePair.Name = "toolStripMenuItemTextTimeCodePair"; - this.toolStripMenuItemTextTimeCodePair.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemTextTimeCodePair.Text = "Korean ATS file pair..."; - this.toolStripMenuItemTextTimeCodePair.Click += new System.EventHandler(this.toolStripMenuItemTextTimeCodePair_Click); - // - // pACScreenElectronicsToolStripMenuItem - // - this.pACScreenElectronicsToolStripMenuItem.Name = "pACScreenElectronicsToolStripMenuItem"; - this.pACScreenElectronicsToolStripMenuItem.Size = new System.Drawing.Size(255, 22); - this.pACScreenElectronicsToolStripMenuItem.Text = "PAC (Screen Electronics)..."; - this.pACScreenElectronicsToolStripMenuItem.Click += new System.EventHandler(this.PacScreenElectronicsToolStripMenuItemClick); - // - // uniPacExportToolStripMenuItem - // - this.uniPacExportToolStripMenuItem.Name = "uniPacExportToolStripMenuItem"; - this.uniPacExportToolStripMenuItem.Size = new System.Drawing.Size(255, 22); - this.uniPacExportToolStripMenuItem.Text = "PAC Unicode (UniPac)..."; - this.uniPacExportToolStripMenuItem.Click += new System.EventHandler(this.uniPacExportToolStripMenuItem_Click); - // - // plainTextToolStripMenuItem - // - this.plainTextToolStripMenuItem.Name = "plainTextToolStripMenuItem"; - this.plainTextToolStripMenuItem.Size = new System.Drawing.Size(255, 22); - this.plainTextToolStripMenuItem.Text = "Plain text..."; - this.plainTextToolStripMenuItem.Click += new System.EventHandler(this.PlainTextToolStripMenuItemClick); - // - // toolStripMenuItemSpumux - // - this.toolStripMenuItemSpumux.Name = "toolStripMenuItemSpumux"; - this.toolStripMenuItemSpumux.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemSpumux.Text = "Spumux..."; - this.toolStripMenuItemSpumux.Click += new System.EventHandler(this.toolStripMenuItem2_Click); - // - // toolStripMenuItemExportUltech130 - // - this.toolStripMenuItemExportUltech130.Name = "toolStripMenuItemExportUltech130"; - this.toolStripMenuItemExportUltech130.Size = new System.Drawing.Size(255, 22); - this.toolStripMenuItemExportUltech130.Text = "Ultech caption..."; - this.toolStripMenuItemExportUltech130.Click += new System.EventHandler(this.toolStripMenuItemExportUltech130_Click); - // - // vobSubsubidxToolStripMenuItem - // - this.vobSubsubidxToolStripMenuItem.Name = "vobSubsubidxToolStripMenuItem"; - this.vobSubsubidxToolStripMenuItem.Size = new System.Drawing.Size(255, 22); - this.vobSubsubidxToolStripMenuItem.Text = "VobSub (sub/idx)..."; - this.vobSubsubidxToolStripMenuItem.Click += new System.EventHandler(this.VobSubsubidxToolStripMenuItemClick); - // - // toolStripSeparatorExportCustomText - // - this.toolStripSeparatorExportCustomText.Name = "toolStripSeparatorExportCustomText"; - this.toolStripSeparatorExportCustomText.Size = new System.Drawing.Size(252, 6); - // - // exportCustomTextFormatToolStripMenuItem - // - this.exportCustomTextFormatToolStripMenuItem.Name = "exportCustomTextFormatToolStripMenuItem"; - this.exportCustomTextFormatToolStripMenuItem.Size = new System.Drawing.Size(255, 22); - this.exportCustomTextFormatToolStripMenuItem.Text = "Export custom text format..."; - this.exportCustomTextFormatToolStripMenuItem.Click += new System.EventHandler(this.exportCustomTextFormatToolStripMenuItem_Click); - // - // toolStripSeparator10 - // - this.toolStripSeparator10.Name = "toolStripSeparator10"; - this.toolStripSeparator10.Size = new System.Drawing.Size(332, 6); - // - // exitToolStripMenuItem - // - this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(335, 22); - this.exitToolStripMenuItem.Text = "E&xit"; - this.exitToolStripMenuItem.Click += new System.EventHandler(this.ExitToolStripMenuItemClick); - // - // editToolStripMenuItem - // - this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemUndo, - this.toolStripMenuItemRedo, - this.showHistoryforUndoToolStripMenuItem, - this.toolStripSeparator14, - this.toolStripMenuItemInsertUnicodeCharacter, - this.toolStripSeparatorInsertUnicodeCharacter, - this.findToolStripMenuItem, - this.findNextToolStripMenuItem, - this.replaceToolStripMenuItem, - this.multipleReplaceToolStripMenuItem, - this.gotoLineNumberToolStripMenuItem, - this.toolStripMenuItemShowOriginalInPreview, - this.toolStripSeparator25, - this.toolStripMenuItemRightToLeftMode, - this.toolStripMenuItemRtlUnicodeControlChars, - this.toolStripMenuItemRemoveUnicodeControlChars, - this.toolStripMenuItemReverseRightToLeftStartEnd, - this.toolStripSeparator21, - this.toolStripMenuItemModifySelection, - this.toolStripMenuItemInverseSelection, - this.editSelectAllToolStripMenuItem}); - this.editToolStripMenuItem.Name = "editToolStripMenuItem"; - this.editToolStripMenuItem.Size = new System.Drawing.Size(40, 20); - this.editToolStripMenuItem.Text = "Edit"; - this.editToolStripMenuItem.DropDownOpening += new System.EventHandler(this.EditToolStripMenuItemDropDownOpening); - // - // toolStripMenuItemUndo - // - this.toolStripMenuItemUndo.Name = "toolStripMenuItemUndo"; - this.toolStripMenuItemUndo.Size = new System.Drawing.Size(301, 22); - this.toolStripMenuItemUndo.Text = "Undo"; - this.toolStripMenuItemUndo.Click += new System.EventHandler(this.toolStripMenuItemUndo_Click); - // - // toolStripMenuItemRedo - // - this.toolStripMenuItemRedo.Name = "toolStripMenuItemRedo"; - this.toolStripMenuItemRedo.Size = new System.Drawing.Size(301, 22); - this.toolStripMenuItemRedo.Text = "Redo"; - this.toolStripMenuItemRedo.Click += new System.EventHandler(this.toolStripMenuItemRedo_Click); - // - // showHistoryforUndoToolStripMenuItem - // - this.showHistoryforUndoToolStripMenuItem.Name = "showHistoryforUndoToolStripMenuItem"; - this.showHistoryforUndoToolStripMenuItem.Size = new System.Drawing.Size(301, 22); - this.showHistoryforUndoToolStripMenuItem.Text = "Show history (for undo)"; - this.showHistoryforUndoToolStripMenuItem.Click += new System.EventHandler(this.ShowHistoryforUndoToolStripMenuItemClick); - // - // toolStripSeparator14 - // - this.toolStripSeparator14.Name = "toolStripSeparator14"; - this.toolStripSeparator14.Size = new System.Drawing.Size(298, 6); - // - // toolStripMenuItemInsertUnicodeCharacter - // - this.toolStripMenuItemInsertUnicodeCharacter.Name = "toolStripMenuItemInsertUnicodeCharacter"; - this.toolStripMenuItemInsertUnicodeCharacter.Size = new System.Drawing.Size(301, 22); - this.toolStripMenuItemInsertUnicodeCharacter.Text = "Insert unicode character"; - // - // toolStripSeparatorInsertUnicodeCharacter - // - this.toolStripSeparatorInsertUnicodeCharacter.Name = "toolStripSeparatorInsertUnicodeCharacter"; - this.toolStripSeparatorInsertUnicodeCharacter.Size = new System.Drawing.Size(298, 6); - // - // findToolStripMenuItem - // - this.findToolStripMenuItem.Name = "findToolStripMenuItem"; - this.findToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F))); - this.findToolStripMenuItem.Size = new System.Drawing.Size(301, 22); - this.findToolStripMenuItem.Text = "Find"; - this.findToolStripMenuItem.Click += new System.EventHandler(this.FindToolStripMenuItemClick); - // - // findNextToolStripMenuItem - // - this.findNextToolStripMenuItem.Name = "findNextToolStripMenuItem"; - this.findNextToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F3; - this.findNextToolStripMenuItem.Size = new System.Drawing.Size(301, 22); - this.findNextToolStripMenuItem.Text = "Find next"; - this.findNextToolStripMenuItem.Click += new System.EventHandler(this.FindNextToolStripMenuItemClick); - // - // replaceToolStripMenuItem - // - this.replaceToolStripMenuItem.Name = "replaceToolStripMenuItem"; - this.replaceToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.H))); - this.replaceToolStripMenuItem.Size = new System.Drawing.Size(301, 22); - this.replaceToolStripMenuItem.Text = "Replace"; - this.replaceToolStripMenuItem.Click += new System.EventHandler(this.ReplaceToolStripMenuItemClick); - // - // multipleReplaceToolStripMenuItem - // - this.multipleReplaceToolStripMenuItem.Name = "multipleReplaceToolStripMenuItem"; - this.multipleReplaceToolStripMenuItem.Size = new System.Drawing.Size(301, 22); - this.multipleReplaceToolStripMenuItem.Text = "Multiple replace"; - this.multipleReplaceToolStripMenuItem.Click += new System.EventHandler(this.MultipleReplaceToolStripMenuItemClick); - // - // gotoLineNumberToolStripMenuItem - // - this.gotoLineNumberToolStripMenuItem.Name = "gotoLineNumberToolStripMenuItem"; - this.gotoLineNumberToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G))); - this.gotoLineNumberToolStripMenuItem.Size = new System.Drawing.Size(301, 22); - this.gotoLineNumberToolStripMenuItem.Text = "Goto line number..."; - this.gotoLineNumberToolStripMenuItem.Click += new System.EventHandler(this.GotoLineNumberToolStripMenuItemClick); - // - // toolStripMenuItemShowOriginalInPreview - // - this.toolStripMenuItemShowOriginalInPreview.Name = "toolStripMenuItemShowOriginalInPreview"; - this.toolStripMenuItemShowOriginalInPreview.Size = new System.Drawing.Size(301, 22); - this.toolStripMenuItemShowOriginalInPreview.Text = "Show original text in video/audio previews"; - this.toolStripMenuItemShowOriginalInPreview.Click += new System.EventHandler(this.ToolStripMenuItemShowOriginalInPreviewClick); - // - // toolStripSeparator25 - // - this.toolStripSeparator25.Name = "toolStripSeparator25"; - this.toolStripSeparator25.Size = new System.Drawing.Size(298, 6); - // - // toolStripMenuItemRightToLeftMode - // - this.toolStripMenuItemRightToLeftMode.Name = "toolStripMenuItemRightToLeftMode"; - this.toolStripMenuItemRightToLeftMode.Size = new System.Drawing.Size(301, 22); - this.toolStripMenuItemRightToLeftMode.Text = "Right to left mode"; - this.toolStripMenuItemRightToLeftMode.Click += new System.EventHandler(this.ToolStripMenuItemRightToLeftModeClick); - // - // toolStripMenuItemRtlUnicodeControlChars - // - this.toolStripMenuItemRtlUnicodeControlChars.Name = "toolStripMenuItemRtlUnicodeControlChars"; - this.toolStripMenuItemRtlUnicodeControlChars.Size = new System.Drawing.Size(301, 22); - this.toolStripMenuItemRtlUnicodeControlChars.Text = "Fix RTL via Unicode tags"; - this.toolStripMenuItemRtlUnicodeControlChars.Click += new System.EventHandler(this.toolStripMenuItemRtlUnicodeControlChar_Click); - // - // toolStripMenuItemRemoveUnicodeControlChars - // - this.toolStripMenuItemRemoveUnicodeControlChars.Name = "toolStripMenuItemRemoveUnicodeControlChars"; - this.toolStripMenuItemRemoveUnicodeControlChars.Size = new System.Drawing.Size(301, 22); - this.toolStripMenuItemRemoveUnicodeControlChars.Text = "Remove Unicode tags"; - this.toolStripMenuItemRemoveUnicodeControlChars.Click += new System.EventHandler(this.toolStripMenuItemRemoveUnicodeControlChar_Click); - // - // toolStripMenuItemReverseRightToLeftStartEnd - // - this.toolStripMenuItemReverseRightToLeftStartEnd.Name = "toolStripMenuItemReverseRightToLeftStartEnd"; - this.toolStripMenuItemReverseRightToLeftStartEnd.Size = new System.Drawing.Size(301, 22); - this.toolStripMenuItemReverseRightToLeftStartEnd.Text = "Reverse RTL start/end"; - this.toolStripMenuItemReverseRightToLeftStartEnd.Click += new System.EventHandler(this.toolStripMenuItemReverseRightToLeftStartEnd_Click); - // - // toolStripSeparator21 - // - this.toolStripSeparator21.Name = "toolStripSeparator21"; - this.toolStripSeparator21.Size = new System.Drawing.Size(298, 6); - // - // toolStripMenuItemModifySelection - // - this.toolStripMenuItemModifySelection.Name = "toolStripMenuItemModifySelection"; - this.toolStripMenuItemModifySelection.Size = new System.Drawing.Size(301, 22); - this.toolStripMenuItemModifySelection.Text = "Create/modify selection..."; - this.toolStripMenuItemModifySelection.Click += new System.EventHandler(this.toolStripMenuItemModifySelection_Click); - // - // toolStripMenuItemInverseSelection - // - this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; - this.toolStripMenuItemInverseSelection.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.I))); - this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(301, 22); - this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; - this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); - // - // editSelectAllToolStripMenuItem - // - this.editSelectAllToolStripMenuItem.Name = "editSelectAllToolStripMenuItem"; - this.editSelectAllToolStripMenuItem.Size = new System.Drawing.Size(301, 22); - this.editSelectAllToolStripMenuItem.Text = "Select all"; - this.editSelectAllToolStripMenuItem.Click += new System.EventHandler(this.EditSelectAllToolStripMenuItemClick); - // - // toolsToolStripMenuItem - // - this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.adjustDisplayTimeToolStripMenuItem, - this.toolStripMenuItemApplyDurationLimits, - this.toolStripMenuItemSubtitlesBridgeGaps, - this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem, - this.fixToolStripMenuItem, - this.startNumberingFromToolStripMenuItem, - this.removeTextForHearImpairedToolStripMenuItem, - this.ChangeCasingToolStripMenuItem, - this.toolStripMenuItemAutoMergeShortLines, - this.toolStripMenuItemMergeDuplicateText, - this.toolStripMenuItemMergeLinesWithSameTimeCodes, - this.toolStripMenuItemAutoSplitLongLines, - this.toolStripMenuItemSortBy, - this.netflixQualityCheckToolStripMenuItem, - this.toolStripSeparator23, - this.toolStripMenuItemMakeEmptyFromCurrent, - this.toolStripMenuItemBatchConvert, - this.generateDatetimeInfoFromVideoToolStripMenuItem, - this.toolStripMenuItemMeasurementConverter, - this.toolStripSeparator3, - this.splitToolStripMenuItem, - this.appendTextVisuallyToolStripMenuItem, - this.joinSubtitlesToolStripMenuItem}); - this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; - this.toolsToolStripMenuItem.Size = new System.Drawing.Size(49, 20); - this.toolsToolStripMenuItem.Text = "Tools"; - this.toolsToolStripMenuItem.DropDownOpening += new System.EventHandler(this.ToolsToolStripMenuItemDropDownOpening); - // - // adjustDisplayTimeToolStripMenuItem - // - this.adjustDisplayTimeToolStripMenuItem.Name = "adjustDisplayTimeToolStripMenuItem"; - this.adjustDisplayTimeToolStripMenuItem.Size = new System.Drawing.Size(338, 22); - this.adjustDisplayTimeToolStripMenuItem.Text = "Adjust display time..."; - this.adjustDisplayTimeToolStripMenuItem.Click += new System.EventHandler(this.AdjustDisplayTimeToolStripMenuItemClick); - // - // toolStripMenuItemApplyDurationLimits - // - this.toolStripMenuItemApplyDurationLimits.Name = "toolStripMenuItemApplyDurationLimits"; - this.toolStripMenuItemApplyDurationLimits.Size = new System.Drawing.Size(338, 22); - this.toolStripMenuItemApplyDurationLimits.Text = "Apply duration limits..."; - this.toolStripMenuItemApplyDurationLimits.Click += new System.EventHandler(this.toolStripMenuItemApplyDisplayTimeLimits_Click); - // - // toolStripMenuItemSubtitlesBridgeGaps - // - this.toolStripMenuItemSubtitlesBridgeGaps.Name = "toolStripMenuItemSubtitlesBridgeGaps"; - this.toolStripMenuItemSubtitlesBridgeGaps.Size = new System.Drawing.Size(338, 22); - this.toolStripMenuItemSubtitlesBridgeGaps.Text = "Bridge gap between subtitles..."; - this.toolStripMenuItemSubtitlesBridgeGaps.Click += new System.EventHandler(this.toolStripMenuItemBridgeGapsBetweenSubtitles_Click); - // - // setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem - // - this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.Name = "setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem"; - this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.Size = new System.Drawing.Size(338, 22); - this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.Text = "Apply mininum gap between subtitles..."; - this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.Click += new System.EventHandler(this.SetMinimalDisplayTimeDifferenceToolStripMenuItemClick); - // - // fixToolStripMenuItem - // - this.fixToolStripMenuItem.Name = "fixToolStripMenuItem"; - this.fixToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.F))); - this.fixToolStripMenuItem.Size = new System.Drawing.Size(338, 22); - this.fixToolStripMenuItem.Text = "Fix common errors..."; - this.fixToolStripMenuItem.Click += new System.EventHandler(this.FixToolStripMenuItemClick); - // - // startNumberingFromToolStripMenuItem - // - this.startNumberingFromToolStripMenuItem.Name = "startNumberingFromToolStripMenuItem"; - this.startNumberingFromToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.N))); - this.startNumberingFromToolStripMenuItem.Size = new System.Drawing.Size(338, 22); - this.startNumberingFromToolStripMenuItem.Text = "Start numbering from..."; - this.startNumberingFromToolStripMenuItem.Click += new System.EventHandler(this.StartNumberingFromToolStripMenuItemClick); - // - // removeTextForHearImpairedToolStripMenuItem - // - this.removeTextForHearImpairedToolStripMenuItem.Name = "removeTextForHearImpairedToolStripMenuItem"; - this.removeTextForHearImpairedToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.H))); - this.removeTextForHearImpairedToolStripMenuItem.Size = new System.Drawing.Size(338, 22); - this.removeTextForHearImpairedToolStripMenuItem.Text = "Remove text for hearing impaired..."; - this.removeTextForHearImpairedToolStripMenuItem.Click += new System.EventHandler(this.RemoveTextForHearImpairedToolStripMenuItemClick); - // - // ChangeCasingToolStripMenuItem - // - this.ChangeCasingToolStripMenuItem.Name = "ChangeCasingToolStripMenuItem"; - this.ChangeCasingToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.C))); - this.ChangeCasingToolStripMenuItem.Size = new System.Drawing.Size(338, 22); - this.ChangeCasingToolStripMenuItem.Text = "Change casing..."; - this.ChangeCasingToolStripMenuItem.Click += new System.EventHandler(this.ChangeCasingToolStripMenuItem_Click); - // - // toolStripMenuItemAutoMergeShortLines - // - this.toolStripMenuItemAutoMergeShortLines.Name = "toolStripMenuItemAutoMergeShortLines"; - this.toolStripMenuItemAutoMergeShortLines.Size = new System.Drawing.Size(338, 22); - this.toolStripMenuItemAutoMergeShortLines.Text = "Merge short lines..."; - this.toolStripMenuItemAutoMergeShortLines.Click += new System.EventHandler(this.ToolStripMenuItemAutoMergeShortLinesClick); - // - // toolStripMenuItemMergeDuplicateText - // - this.toolStripMenuItemMergeDuplicateText.Name = "toolStripMenuItemMergeDuplicateText"; - this.toolStripMenuItemMergeDuplicateText.Size = new System.Drawing.Size(338, 22); - this.toolStripMenuItemMergeDuplicateText.Text = "Merge lines with same text..."; - this.toolStripMenuItemMergeDuplicateText.Click += new System.EventHandler(this.toolStripMenuItemMergeDuplicateText_Click); - // - // toolStripMenuItemMergeLinesWithSameTimeCodes - // - this.toolStripMenuItemMergeLinesWithSameTimeCodes.Name = "toolStripMenuItemMergeLinesWithSameTimeCodes"; - this.toolStripMenuItemMergeLinesWithSameTimeCodes.Size = new System.Drawing.Size(338, 22); - this.toolStripMenuItemMergeLinesWithSameTimeCodes.Text = "Merge lines with same time codes..."; - this.toolStripMenuItemMergeLinesWithSameTimeCodes.Click += new System.EventHandler(this.toolStripMenuItemMergeLinesWithSameTimeCodes_Click); - // - // toolStripMenuItemAutoSplitLongLines - // - this.toolStripMenuItemAutoSplitLongLines.Name = "toolStripMenuItemAutoSplitLongLines"; - this.toolStripMenuItemAutoSplitLongLines.Size = new System.Drawing.Size(338, 22); - this.toolStripMenuItemAutoSplitLongLines.Text = "Split long lines..."; - this.toolStripMenuItemAutoSplitLongLines.Click += new System.EventHandler(this.toolStripMenuItemAutoSplitLongLines_Click); - // - // toolStripMenuItemSortBy - // - this.toolStripMenuItemSortBy.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.sortNumberToolStripMenuItem, - this.sortStartTimeToolStripMenuItem, - this.sortEndTimeToolStripMenuItem, - this.sortDisplayTimeToolStripMenuItem, - this.sortTextAlphabeticallytoolStripMenuItem, - this.sortTextMaxLineLengthToolStripMenuItem, - this.sortTextTotalLengthToolStripMenuItem, - this.sortTextNumberOfLinesToolStripMenuItem, - this.textCharssecToolStripMenuItem, - this.textWordsPerMinutewpmToolStripMenuItem, - this.actorToolStripMenuItem, - this.styleToolStripMenuItem, - this.toolStripSeparatorAscOrDesc, - this.AscendingToolStripMenuItem, - this.descendingToolStripMenuItem}); - this.toolStripMenuItemSortBy.Name = "toolStripMenuItemSortBy"; - this.toolStripMenuItemSortBy.Size = new System.Drawing.Size(338, 22); - this.toolStripMenuItemSortBy.Text = "Sort by"; - // - // sortNumberToolStripMenuItem - // - this.sortNumberToolStripMenuItem.Name = "sortNumberToolStripMenuItem"; - this.sortNumberToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.sortNumberToolStripMenuItem.Text = "Number"; - this.sortNumberToolStripMenuItem.Click += new System.EventHandler(this.SortNumberToolStripMenuItemClick); - // - // sortStartTimeToolStripMenuItem - // - this.sortStartTimeToolStripMenuItem.Name = "sortStartTimeToolStripMenuItem"; - this.sortStartTimeToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.sortStartTimeToolStripMenuItem.Text = "Start time"; - this.sortStartTimeToolStripMenuItem.Click += new System.EventHandler(this.SortStartTimeToolStripMenuItemClick); - // - // sortEndTimeToolStripMenuItem - // - this.sortEndTimeToolStripMenuItem.Name = "sortEndTimeToolStripMenuItem"; - this.sortEndTimeToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.sortEndTimeToolStripMenuItem.Text = "End time"; - this.sortEndTimeToolStripMenuItem.Click += new System.EventHandler(this.SortEndTimeToolStripMenuItemClick); - // - // sortDisplayTimeToolStripMenuItem - // - this.sortDisplayTimeToolStripMenuItem.Name = "sortDisplayTimeToolStripMenuItem"; - this.sortDisplayTimeToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.sortDisplayTimeToolStripMenuItem.Text = "Duration"; - this.sortDisplayTimeToolStripMenuItem.Click += new System.EventHandler(this.SortDisplayTimeToolStripMenuItemClick); - // - // sortTextAlphabeticallytoolStripMenuItem - // - this.sortTextAlphabeticallytoolStripMenuItem.Name = "sortTextAlphabeticallytoolStripMenuItem"; - this.sortTextAlphabeticallytoolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.sortTextAlphabeticallytoolStripMenuItem.Text = "Text - alphabetically"; - this.sortTextAlphabeticallytoolStripMenuItem.Click += new System.EventHandler(this.SortTextAlphabeticallytoolStripMenuItemClick); - // - // sortTextMaxLineLengthToolStripMenuItem - // - this.sortTextMaxLineLengthToolStripMenuItem.Name = "sortTextMaxLineLengthToolStripMenuItem"; - this.sortTextMaxLineLengthToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.sortTextMaxLineLengthToolStripMenuItem.Text = "Text - single line max. length"; - this.sortTextMaxLineLengthToolStripMenuItem.Click += new System.EventHandler(this.SortTextMaxLineLengthToolStripMenuItemClick); - // - // sortTextTotalLengthToolStripMenuItem - // - this.sortTextTotalLengthToolStripMenuItem.Name = "sortTextTotalLengthToolStripMenuItem"; - this.sortTextTotalLengthToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.sortTextTotalLengthToolStripMenuItem.Text = "Text - total length"; - this.sortTextTotalLengthToolStripMenuItem.Click += new System.EventHandler(this.SortTextTotalLengthToolStripMenuItemClick); - // - // sortTextNumberOfLinesToolStripMenuItem - // - this.sortTextNumberOfLinesToolStripMenuItem.Name = "sortTextNumberOfLinesToolStripMenuItem"; - this.sortTextNumberOfLinesToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.sortTextNumberOfLinesToolStripMenuItem.Text = "Text - number of lines"; - this.sortTextNumberOfLinesToolStripMenuItem.Click += new System.EventHandler(this.SortTextNumberOfLinesToolStripMenuItemClick); - // - // textCharssecToolStripMenuItem - // - this.textCharssecToolStripMenuItem.Name = "textCharssecToolStripMenuItem"; - this.textCharssecToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.textCharssecToolStripMenuItem.Text = "Text - chars/sec"; - this.textCharssecToolStripMenuItem.Click += new System.EventHandler(this.textCharssecToolStripMenuItem_Click); - // - // textWordsPerMinutewpmToolStripMenuItem - // - this.textWordsPerMinutewpmToolStripMenuItem.Name = "textWordsPerMinutewpmToolStripMenuItem"; - this.textWordsPerMinutewpmToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.textWordsPerMinutewpmToolStripMenuItem.Text = "Text - words per minute (wpm)"; - this.textWordsPerMinutewpmToolStripMenuItem.Click += new System.EventHandler(this.textWordsPerMinutewpmToolStripMenuItem_Click); - // - // actorToolStripMenuItem - // - this.actorToolStripMenuItem.Name = "actorToolStripMenuItem"; - this.actorToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.actorToolStripMenuItem.Text = "Actor"; - this.actorToolStripMenuItem.Click += new System.EventHandler(this.actorToolStripMenuItemClick); - // - // styleToolStripMenuItem - // - this.styleToolStripMenuItem.Name = "styleToolStripMenuItem"; - this.styleToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.styleToolStripMenuItem.Text = "Style"; - this.styleToolStripMenuItem.Click += new System.EventHandler(this.styleToolStripMenuItem_Click); - // - // toolStripSeparatorAscOrDesc - // - this.toolStripSeparatorAscOrDesc.Name = "toolStripSeparatorAscOrDesc"; - this.toolStripSeparatorAscOrDesc.Size = new System.Drawing.Size(237, 6); - // - // AscendingToolStripMenuItem - // - this.AscendingToolStripMenuItem.Checked = true; - this.AscendingToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.AscendingToolStripMenuItem.Name = "AscendingToolStripMenuItem"; - this.AscendingToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.AscendingToolStripMenuItem.Text = "Ascending"; - this.AscendingToolStripMenuItem.Click += new System.EventHandler(this.AscendingToolStripMenuItem_Click); - // - // descendingToolStripMenuItem - // - this.descendingToolStripMenuItem.Name = "descendingToolStripMenuItem"; - this.descendingToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.descendingToolStripMenuItem.Text = "Descending"; - this.descendingToolStripMenuItem.Click += new System.EventHandler(this.descendingToolStripMenuItem_Click); - // - // netflixQualityCheckToolStripMenuItem - // - this.netflixQualityCheckToolStripMenuItem.Name = "netflixQualityCheckToolStripMenuItem"; - this.netflixQualityCheckToolStripMenuItem.Size = new System.Drawing.Size(338, 22); - this.netflixQualityCheckToolStripMenuItem.Text = "Netflix quality check"; - this.netflixQualityCheckToolStripMenuItem.Click += new System.EventHandler(this.netflixGlyphCheckToolStripMenuItem_Click); - // - // toolStripSeparator23 - // - this.toolStripSeparator23.Name = "toolStripSeparator23"; - this.toolStripSeparator23.Size = new System.Drawing.Size(335, 6); - // - // toolStripMenuItemMakeEmptyFromCurrent - // - this.toolStripMenuItemMakeEmptyFromCurrent.Name = "toolStripMenuItemMakeEmptyFromCurrent"; - this.toolStripMenuItemMakeEmptyFromCurrent.Size = new System.Drawing.Size(338, 22); - this.toolStripMenuItemMakeEmptyFromCurrent.Text = "Make new empty translation from current subtitle"; - this.toolStripMenuItemMakeEmptyFromCurrent.Click += new System.EventHandler(this.ToolStripMenuItemMakeEmptyFromCurrentClick); - // - // toolStripMenuItemBatchConvert - // - this.toolStripMenuItemBatchConvert.Name = "toolStripMenuItemBatchConvert"; - this.toolStripMenuItemBatchConvert.Size = new System.Drawing.Size(338, 22); - this.toolStripMenuItemBatchConvert.Text = "Batch convert..."; - this.toolStripMenuItemBatchConvert.Click += new System.EventHandler(this.toolStripMenuItemBatchConvert_Click); - // - // generateDatetimeInfoFromVideoToolStripMenuItem - // - this.generateDatetimeInfoFromVideoToolStripMenuItem.Name = "generateDatetimeInfoFromVideoToolStripMenuItem"; - this.generateDatetimeInfoFromVideoToolStripMenuItem.Size = new System.Drawing.Size(338, 22); - this.generateDatetimeInfoFromVideoToolStripMenuItem.Text = "Generate date/time info from video..."; - this.generateDatetimeInfoFromVideoToolStripMenuItem.Click += new System.EventHandler(this.generateDatetimeInfoFromVideoToolStripMenuItem_Click); - // - // toolStripMenuItemMeasurementConverter - // - this.toolStripMenuItemMeasurementConverter.Name = "toolStripMenuItemMeasurementConverter"; - this.toolStripMenuItemMeasurementConverter.Size = new System.Drawing.Size(338, 22); - this.toolStripMenuItemMeasurementConverter.Text = "Measurement converter..."; - this.toolStripMenuItemMeasurementConverter.Click += new System.EventHandler(this.toolStripMenuItemMeasurementConverter_Click); - // - // toolStripSeparator3 - // - this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(335, 6); - // - // splitToolStripMenuItem - // - this.splitToolStripMenuItem.Name = "splitToolStripMenuItem"; - this.splitToolStripMenuItem.Size = new System.Drawing.Size(338, 22); - this.splitToolStripMenuItem.Text = "Split subtitle..."; - this.splitToolStripMenuItem.Click += new System.EventHandler(this.SplitToolStripMenuItemClick); - // - // appendTextVisuallyToolStripMenuItem - // - this.appendTextVisuallyToolStripMenuItem.Name = "appendTextVisuallyToolStripMenuItem"; - this.appendTextVisuallyToolStripMenuItem.Size = new System.Drawing.Size(338, 22); - this.appendTextVisuallyToolStripMenuItem.Text = "Append subtitle..."; - this.appendTextVisuallyToolStripMenuItem.Click += new System.EventHandler(this.AppendTextVisuallyToolStripMenuItemClick); - // - // joinSubtitlesToolStripMenuItem - // - this.joinSubtitlesToolStripMenuItem.Name = "joinSubtitlesToolStripMenuItem"; - this.joinSubtitlesToolStripMenuItem.Size = new System.Drawing.Size(338, 22); - this.joinSubtitlesToolStripMenuItem.Text = "Join subtitles..."; - this.joinSubtitlesToolStripMenuItem.Click += new System.EventHandler(this.joinSubtitlesToolStripMenuItem_Click); - // - // toolStripMenuItemSpellCheckMain - // - this.toolStripMenuItemSpellCheckMain.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.spellCheckToolStripMenuItem, - this.toolStripMenuItemSpellCheckFromCurrentLine, - this.findDoubleWordsToolStripMenuItem, - this.FindDoubleLinesToolStripMenuItem, - this.toolStripSeparator9, - this.GetDictionariesToolStripMenuItem, - this.addWordToNameListToolStripMenuItem}); - this.toolStripMenuItemSpellCheckMain.Name = "toolStripMenuItemSpellCheckMain"; - this.toolStripMenuItemSpellCheckMain.Size = new System.Drawing.Size(82, 20); - this.toolStripMenuItemSpellCheckMain.Text = "Spell check"; - this.toolStripMenuItemSpellCheckMain.DropDownOpening += new System.EventHandler(this.ToolStripMenuItemSpellCheckMainDropDownOpening); - // - // spellCheckToolStripMenuItem - // - this.spellCheckToolStripMenuItem.Name = "spellCheckToolStripMenuItem"; - this.spellCheckToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.S))); - this.spellCheckToolStripMenuItem.Size = new System.Drawing.Size(267, 22); - this.spellCheckToolStripMenuItem.Text = "Spell check..."; - this.spellCheckToolStripMenuItem.Click += new System.EventHandler(this.SpellCheckToolStripMenuItemClick); - // - // toolStripMenuItemSpellCheckFromCurrentLine - // - this.toolStripMenuItemSpellCheckFromCurrentLine.Name = "toolStripMenuItemSpellCheckFromCurrentLine"; - this.toolStripMenuItemSpellCheckFromCurrentLine.Size = new System.Drawing.Size(267, 22); - this.toolStripMenuItemSpellCheckFromCurrentLine.Text = "Spell check from current line..."; - this.toolStripMenuItemSpellCheckFromCurrentLine.Click += new System.EventHandler(this.toolStripMenuItemSpellCheckFromCurrentLine_Click); - // - // findDoubleWordsToolStripMenuItem - // - this.findDoubleWordsToolStripMenuItem.Name = "findDoubleWordsToolStripMenuItem"; - this.findDoubleWordsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.D))); - this.findDoubleWordsToolStripMenuItem.Size = new System.Drawing.Size(267, 22); - this.findDoubleWordsToolStripMenuItem.Text = "Find double words"; - this.findDoubleWordsToolStripMenuItem.Click += new System.EventHandler(this.FindDoubleWordsToolStripMenuItemClick); - // - // FindDoubleLinesToolStripMenuItem - // - this.FindDoubleLinesToolStripMenuItem.Name = "FindDoubleLinesToolStripMenuItem"; - this.FindDoubleLinesToolStripMenuItem.Size = new System.Drawing.Size(267, 22); - this.FindDoubleLinesToolStripMenuItem.Text = "Find double lines"; - this.FindDoubleLinesToolStripMenuItem.Click += new System.EventHandler(this.FindDoubleLinesToolStripMenuItemClick); - // - // toolStripSeparator9 - // - this.toolStripSeparator9.Name = "toolStripSeparator9"; - this.toolStripSeparator9.Size = new System.Drawing.Size(264, 6); - // - // GetDictionariesToolStripMenuItem - // - this.GetDictionariesToolStripMenuItem.Name = "GetDictionariesToolStripMenuItem"; - this.GetDictionariesToolStripMenuItem.Size = new System.Drawing.Size(267, 22); - this.GetDictionariesToolStripMenuItem.Text = "Get dictionary..."; - this.GetDictionariesToolStripMenuItem.Click += new System.EventHandler(this.GetDictionariesToolStripMenuItem_Click); - // - // addWordToNameListToolStripMenuItem - // - this.addWordToNameListToolStripMenuItem.Name = "addWordToNameListToolStripMenuItem"; - this.addWordToNameListToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.L))); - this.addWordToNameListToolStripMenuItem.Size = new System.Drawing.Size(267, 22); - this.addWordToNameListToolStripMenuItem.Text = "Add word to names list"; - this.addWordToNameListToolStripMenuItem.Click += new System.EventHandler(this.AddWordToNameListToolStripMenuItemClick); - // - // toolStripMenuItemVideo - // - this.toolStripMenuItemVideo.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.openVideoToolStripMenuItem, - this.toolStripMenuItemOpenVideoFromUrl, - this.toolStripMenuItemOpenDvd, - this.toolStripMenuItemSetAudioTrack, - this.closeVideoToolStripMenuItem, - this.openSecondSubtitleToolStripMenuItem, - this.setVideoOffsetToolStripMenuItem, - this.smpteTimeModedropFrameToolStripMenuItem, - this.toolStripMenuItemImportChapters, - this.toolStripMenuItemImportSceneChanges, - this.toolStripMenuItemRemoveSceneChanges, - this.toolStripMenuItemAddWaveformBatch, - this.generateTextFromCurrentVideoToolStripMenuItem, - this.toolStripSeparator5, - this.showhideWaveformToolStripMenuItem, - this.showhideVideoToolStripMenuItem, - this.toolStripSeparator19, - this.undockVideoControlsToolStripMenuItem, - this.redockVideoControlsToolStripMenuItem}); - this.toolStripMenuItemVideo.Name = "toolStripMenuItemVideo"; - this.toolStripMenuItemVideo.Size = new System.Drawing.Size(50, 20); - this.toolStripMenuItemVideo.Text = "Video"; - this.toolStripMenuItemVideo.DropDownClosed += new System.EventHandler(this.ToolStripMenuItemVideoDropDownClosed); - this.toolStripMenuItemVideo.DropDownOpening += new System.EventHandler(this.ToolStripMenuItemVideoDropDownOpening); - // - // openVideoToolStripMenuItem - // - this.openVideoToolStripMenuItem.Name = "openVideoToolStripMenuItem"; - this.openVideoToolStripMenuItem.Size = new System.Drawing.Size(257, 22); - this.openVideoToolStripMenuItem.Text = "Open video..."; - this.openVideoToolStripMenuItem.Click += new System.EventHandler(this.buttonOpenVideo_Click); - // - // toolStripMenuItemOpenVideoFromUrl - // - this.toolStripMenuItemOpenVideoFromUrl.Name = "toolStripMenuItemOpenVideoFromUrl"; - this.toolStripMenuItemOpenVideoFromUrl.Size = new System.Drawing.Size(257, 22); - this.toolStripMenuItemOpenVideoFromUrl.Text = "Open video from url..."; - this.toolStripMenuItemOpenVideoFromUrl.Click += new System.EventHandler(this.toolStripMenuItemOpenVideoFromUrl_Click); - // - // toolStripMenuItemOpenDvd - // - this.toolStripMenuItemOpenDvd.Name = "toolStripMenuItemOpenDvd"; - this.toolStripMenuItemOpenDvd.Size = new System.Drawing.Size(257, 22); - this.toolStripMenuItemOpenDvd.Text = "Open DVD..."; - this.toolStripMenuItemOpenDvd.Click += new System.EventHandler(this.toolStripMenuItemOpenDvd_Click); - // - // toolStripMenuItemSetAudioTrack - // - this.toolStripMenuItemSetAudioTrack.Name = "toolStripMenuItemSetAudioTrack"; - this.toolStripMenuItemSetAudioTrack.Size = new System.Drawing.Size(257, 22); - this.toolStripMenuItemSetAudioTrack.Text = "Choose audio track"; - // - // closeVideoToolStripMenuItem - // - this.closeVideoToolStripMenuItem.Name = "closeVideoToolStripMenuItem"; - this.closeVideoToolStripMenuItem.Size = new System.Drawing.Size(257, 22); - this.closeVideoToolStripMenuItem.Text = "Close video"; - this.closeVideoToolStripMenuItem.Click += new System.EventHandler(this.CloseVideoToolStripMenuItemClick); - // - // openSecondSubtitleToolStripMenuItem - // - this.openSecondSubtitleToolStripMenuItem.Name = "openSecondSubtitleToolStripMenuItem"; - this.openSecondSubtitleToolStripMenuItem.Size = new System.Drawing.Size(257, 22); - this.openSecondSubtitleToolStripMenuItem.Text = "Open second subtitle..."; - this.openSecondSubtitleToolStripMenuItem.Click += new System.EventHandler(this.openSecondSubtitleToolStripMenuItem_Click); - // - // setVideoOffsetToolStripMenuItem - // - this.setVideoOffsetToolStripMenuItem.Name = "setVideoOffsetToolStripMenuItem"; - this.setVideoOffsetToolStripMenuItem.Size = new System.Drawing.Size(257, 22); - this.setVideoOffsetToolStripMenuItem.Text = "Set video offset..."; - this.setVideoOffsetToolStripMenuItem.Click += new System.EventHandler(this.setVideoOffsetToolStripMenuItem_Click); - // - // smpteTimeModedropFrameToolStripMenuItem - // - this.smpteTimeModedropFrameToolStripMenuItem.Name = "smpteTimeModedropFrameToolStripMenuItem"; - this.smpteTimeModedropFrameToolStripMenuItem.Size = new System.Drawing.Size(257, 22); - this.smpteTimeModedropFrameToolStripMenuItem.Text = "SMPTE timing (drop frame)"; - this.smpteTimeModedropFrameToolStripMenuItem.Click += new System.EventHandler(this.SmpteTimeModedropFrameToolStripMenuItem_Click); - // - // toolStripMenuItemImportChapters - // - this.toolStripMenuItemImportChapters.Name = "toolStripMenuItemImportChapters"; - this.toolStripMenuItemImportChapters.Size = new System.Drawing.Size(257, 22); - this.toolStripMenuItemImportChapters.Text = "Import chapters from video..."; - this.toolStripMenuItemImportChapters.Click += new System.EventHandler(this.toolStripMenuItemImportChapters_Click); - // - // toolStripMenuItemImportSceneChanges - // - this.toolStripMenuItemImportSceneChanges.Name = "toolStripMenuItemImportSceneChanges"; - this.toolStripMenuItemImportSceneChanges.Size = new System.Drawing.Size(257, 22); - this.toolStripMenuItemImportSceneChanges.Text = "Import scene changes..."; - this.toolStripMenuItemImportSceneChanges.Click += new System.EventHandler(this.toolStripMenuItemImportSceneChanges_Click); - // - // toolStripMenuItemRemoveSceneChanges - // - this.toolStripMenuItemRemoveSceneChanges.Name = "toolStripMenuItemRemoveSceneChanges"; - this.toolStripMenuItemRemoveSceneChanges.Size = new System.Drawing.Size(257, 22); - this.toolStripMenuItemRemoveSceneChanges.Text = "Remove scene changes"; - this.toolStripMenuItemRemoveSceneChanges.Click += new System.EventHandler(this.toolStripMenuItemRemoveSceneChanges_Click); - // - // toolStripMenuItemAddWaveformBatch - // - this.toolStripMenuItemAddWaveformBatch.Name = "toolStripMenuItemAddWaveformBatch"; - this.toolStripMenuItemAddWaveformBatch.Size = new System.Drawing.Size(257, 22); - this.toolStripMenuItemAddWaveformBatch.Text = "Add waveform batch..."; - this.toolStripMenuItemAddWaveformBatch.Click += new System.EventHandler(this.ToolStripMenuItemAddWaveformBatchClick); - // - // generateTextFromCurrentVideoToolStripMenuItem - // - this.generateTextFromCurrentVideoToolStripMenuItem.Name = "generateTextFromCurrentVideoToolStripMenuItem"; - this.generateTextFromCurrentVideoToolStripMenuItem.Size = new System.Drawing.Size(257, 22); - this.generateTextFromCurrentVideoToolStripMenuItem.Text = "Generate text from current video..."; - this.generateTextFromCurrentVideoToolStripMenuItem.Click += new System.EventHandler(this.generateTextFromCurrentVideoToolStripMenuItem_Click); - // - // toolStripSeparator5 - // - this.toolStripSeparator5.Name = "toolStripSeparator5"; - this.toolStripSeparator5.Size = new System.Drawing.Size(254, 6); - // - // showhideWaveformToolStripMenuItem - // - this.showhideWaveformToolStripMenuItem.Name = "showhideWaveformToolStripMenuItem"; - this.showhideWaveformToolStripMenuItem.Size = new System.Drawing.Size(257, 22); - this.showhideWaveformToolStripMenuItem.Text = "Show/hide waveform"; - this.showhideWaveformToolStripMenuItem.Click += new System.EventHandler(this.ShowhideWaveformToolStripMenuItemClick); - // - // showhideVideoToolStripMenuItem - // - this.showhideVideoToolStripMenuItem.Name = "showhideVideoToolStripMenuItem"; - this.showhideVideoToolStripMenuItem.Size = new System.Drawing.Size(257, 22); - this.showhideVideoToolStripMenuItem.Text = "Show/hide video"; - this.showhideVideoToolStripMenuItem.Click += new System.EventHandler(this.toolStripButtonToggleVideo_Click); - // - // toolStripSeparator19 - // - this.toolStripSeparator19.Name = "toolStripSeparator19"; - this.toolStripSeparator19.Size = new System.Drawing.Size(254, 6); - // - // undockVideoControlsToolStripMenuItem - // - this.undockVideoControlsToolStripMenuItem.Name = "undockVideoControlsToolStripMenuItem"; - this.undockVideoControlsToolStripMenuItem.Size = new System.Drawing.Size(257, 22); - this.undockVideoControlsToolStripMenuItem.Text = "Un-dock video controls"; - this.undockVideoControlsToolStripMenuItem.Click += new System.EventHandler(this.UndockVideoControlsToolStripMenuItemClick); - // - // redockVideoControlsToolStripMenuItem - // - this.redockVideoControlsToolStripMenuItem.Name = "redockVideoControlsToolStripMenuItem"; - this.redockVideoControlsToolStripMenuItem.Size = new System.Drawing.Size(257, 22); - this.redockVideoControlsToolStripMenuItem.Text = "Re-dock video controls"; - this.redockVideoControlsToolStripMenuItem.Visible = false; - this.redockVideoControlsToolStripMenuItem.Click += new System.EventHandler(this.RedockVideoControlsToolStripMenuItemClick); - // - // toolStripMenuItemSynchronization - // - this.toolStripMenuItemSynchronization.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemAdjustAllTimes, - this.visualSyncToolStripMenuItem, - this.toolStripMenuItemPointSync, - this.pointSyncViaOtherSubtitleToolStripMenuItem, - this.toolStripMenuItemChangeFrameRate2, - this.changeSpeedInPercentToolStripMenuItem}); - this.toolStripMenuItemSynchronization.Name = "toolStripMenuItemSynchronization"; - this.toolStripMenuItemSynchronization.Size = new System.Drawing.Size(106, 20); - this.toolStripMenuItemSynchronization.Text = "Synchronization"; - // - // toolStripMenuItemAdjustAllTimes - // - this.toolStripMenuItemAdjustAllTimes.Name = "toolStripMenuItemAdjustAllTimes"; - this.toolStripMenuItemAdjustAllTimes.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.A))); - this.toolStripMenuItemAdjustAllTimes.Size = new System.Drawing.Size(324, 22); - this.toolStripMenuItemAdjustAllTimes.Text = "Adjust times (show earlier/later)..."; - this.toolStripMenuItemAdjustAllTimes.Click += new System.EventHandler(this.toolStripMenuItemAdjustAllTimes_Click); - // - // visualSyncToolStripMenuItem - // - this.visualSyncToolStripMenuItem.Name = "visualSyncToolStripMenuItem"; - this.visualSyncToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.V))); - this.visualSyncToolStripMenuItem.Size = new System.Drawing.Size(324, 22); - this.visualSyncToolStripMenuItem.Text = "Visual sync..."; - this.visualSyncToolStripMenuItem.Click += new System.EventHandler(this.VisualSyncToolStripMenuItemClick); - // - // toolStripMenuItemPointSync - // - this.toolStripMenuItemPointSync.Name = "toolStripMenuItemPointSync"; - this.toolStripMenuItemPointSync.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.P))); - this.toolStripMenuItemPointSync.Size = new System.Drawing.Size(324, 22); - this.toolStripMenuItemPointSync.Text = "Point sync..."; - this.toolStripMenuItemPointSync.Click += new System.EventHandler(this.toolStripMenuItemPointSync_Click); - // - // pointSyncViaOtherSubtitleToolStripMenuItem - // - this.pointSyncViaOtherSubtitleToolStripMenuItem.Name = "pointSyncViaOtherSubtitleToolStripMenuItem"; - this.pointSyncViaOtherSubtitleToolStripMenuItem.Size = new System.Drawing.Size(324, 22); - this.pointSyncViaOtherSubtitleToolStripMenuItem.Text = "Point sync via other subtitle..."; - this.pointSyncViaOtherSubtitleToolStripMenuItem.Click += new System.EventHandler(this.pointSyncViaOtherSubtitleToolStripMenuItem_Click); - // - // toolStripMenuItemChangeFrameRate2 - // - this.toolStripMenuItemChangeFrameRate2.Name = "toolStripMenuItemChangeFrameRate2"; - this.toolStripMenuItemChangeFrameRate2.Size = new System.Drawing.Size(324, 22); - this.toolStripMenuItemChangeFrameRate2.Text = "Change frame rate..."; - this.toolStripMenuItemChangeFrameRate2.Click += new System.EventHandler(this.ToolStripMenuItemChangeFrameRateClick); - // - // changeSpeedInPercentToolStripMenuItem - // - this.changeSpeedInPercentToolStripMenuItem.Name = "changeSpeedInPercentToolStripMenuItem"; - this.changeSpeedInPercentToolStripMenuItem.Size = new System.Drawing.Size(324, 22); - this.changeSpeedInPercentToolStripMenuItem.Text = "Change speed in percent..."; - this.changeSpeedInPercentToolStripMenuItem.Click += new System.EventHandler(this.changeSpeedInPercentToolStripMenuItem_Click); - // - // toolStripMenuItemAutoTranslate - // - this.toolStripMenuItemAutoTranslate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.translatepoweredByMicrosoftToolStripMenuItem, - this.translateByGoogleToolStripMenuItem, - this.translateFromSwedishToDanishToolStripMenuItem}); - this.toolStripMenuItemAutoTranslate.Name = "toolStripMenuItemAutoTranslate"; - this.toolStripMenuItemAutoTranslate.Size = new System.Drawing.Size(94, 20); - this.toolStripMenuItemAutoTranslate.Text = "Auto-translate"; - this.toolStripMenuItemAutoTranslate.DropDownOpening += new System.EventHandler(this.toolStripMenuItemAutoTranslate_DropDownOpening); - // - // translatepoweredByMicrosoftToolStripMenuItem - // - this.translatepoweredByMicrosoftToolStripMenuItem.Name = "translatepoweredByMicrosoftToolStripMenuItem"; - this.translatepoweredByMicrosoftToolStripMenuItem.Size = new System.Drawing.Size(402, 22); - this.translatepoweredByMicrosoftToolStripMenuItem.Text = "Translate (powered by Microsoft)..."; - this.translatepoweredByMicrosoftToolStripMenuItem.Click += new System.EventHandler(this.translatepoweredByMicrosoftToolStripMenuItem_Click); - // - // translateByGoogleToolStripMenuItem - // - this.translateByGoogleToolStripMenuItem.Name = "translateByGoogleToolStripMenuItem"; - this.translateByGoogleToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.G))); - this.translateByGoogleToolStripMenuItem.Size = new System.Drawing.Size(402, 22); - this.translateByGoogleToolStripMenuItem.Text = "Translate (powered by Google)..."; - this.translateByGoogleToolStripMenuItem.Click += new System.EventHandler(this.TranslateByGoogleToolStripMenuItemClick); - // - // translateFromSwedishToDanishToolStripMenuItem - // - this.translateFromSwedishToDanishToolStripMenuItem.Name = "translateFromSwedishToDanishToolStripMenuItem"; - this.translateFromSwedishToDanishToolStripMenuItem.Size = new System.Drawing.Size(402, 22); - this.translateFromSwedishToDanishToolStripMenuItem.Text = "Translate from swedish to danish (powered by nikse.dk/mt)..."; - this.translateFromSwedishToDanishToolStripMenuItem.Click += new System.EventHandler(this.TranslateFromSwedishToDanishToolStripMenuItemClick); - // - // optionsToolStripMenuItem - // - this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.settingsToolStripMenuItem, - this.changeLanguageToolStripMenuItem}); - this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; - this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); - this.optionsToolStripMenuItem.Text = "Options"; - // - // settingsToolStripMenuItem - // - this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; - this.settingsToolStripMenuItem.Size = new System.Drawing.Size(181, 22); - this.settingsToolStripMenuItem.Text = "Settings"; - this.settingsToolStripMenuItem.Click += new System.EventHandler(this.SettingsToolStripMenuItemClick); - // - // changeLanguageToolStripMenuItem - // - this.changeLanguageToolStripMenuItem.Name = "changeLanguageToolStripMenuItem"; - this.changeLanguageToolStripMenuItem.Size = new System.Drawing.Size(181, 22); - this.changeLanguageToolStripMenuItem.Text = "Change language..."; - this.changeLanguageToolStripMenuItem.Click += new System.EventHandler(this.ChangeLanguageToolStripMenuItemClick); - // - // toolStripMenuItemNetworking - // - this.toolStripMenuItemNetworking.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.startServerToolStripMenuItem, - this.joinSessionToolStripMenuItem, - this.chatToolStripMenuItem, - this.showSessionKeyLogToolStripMenuItem, - this.leaveSessionToolStripMenuItem}); - this.toolStripMenuItemNetworking.Name = "toolStripMenuItemNetworking"; - this.toolStripMenuItemNetworking.Size = new System.Drawing.Size(81, 20); - this.toolStripMenuItemNetworking.Text = "Networking"; - this.toolStripMenuItemNetworking.DropDownOpening += new System.EventHandler(this.toolStripMenuItemNetworking_DropDownOpening); - // - // startServerToolStripMenuItem - // - this.startServerToolStripMenuItem.Name = "startServerToolStripMenuItem"; - this.startServerToolStripMenuItem.Size = new System.Drawing.Size(217, 22); - this.startServerToolStripMenuItem.Text = "Start new session"; - this.startServerToolStripMenuItem.Click += new System.EventHandler(this.startServerToolStripMenuItem_Click); - // - // joinSessionToolStripMenuItem - // - this.joinSessionToolStripMenuItem.Name = "joinSessionToolStripMenuItem"; - this.joinSessionToolStripMenuItem.Size = new System.Drawing.Size(217, 22); - this.joinSessionToolStripMenuItem.Text = "Join session"; - this.joinSessionToolStripMenuItem.Click += new System.EventHandler(this.joinSessionToolStripMenuItem_Click); - // - // chatToolStripMenuItem - // - this.chatToolStripMenuItem.Name = "chatToolStripMenuItem"; - this.chatToolStripMenuItem.Size = new System.Drawing.Size(217, 22); - this.chatToolStripMenuItem.Text = "Chat"; - this.chatToolStripMenuItem.Click += new System.EventHandler(this.chatToolStripMenuItem_Click); - // - // showSessionKeyLogToolStripMenuItem - // - this.showSessionKeyLogToolStripMenuItem.Name = "showSessionKeyLogToolStripMenuItem"; - this.showSessionKeyLogToolStripMenuItem.Size = new System.Drawing.Size(217, 22); - this.showSessionKeyLogToolStripMenuItem.Text = "Show session info and log"; - this.showSessionKeyLogToolStripMenuItem.Click += new System.EventHandler(this.showSessionKeyLogToolStripMenuItem_Click); - // - // leaveSessionToolStripMenuItem - // - this.leaveSessionToolStripMenuItem.Name = "leaveSessionToolStripMenuItem"; - this.leaveSessionToolStripMenuItem.Size = new System.Drawing.Size(217, 22); - this.leaveSessionToolStripMenuItem.Text = "Leave session"; - this.leaveSessionToolStripMenuItem.Click += new System.EventHandler(this.LeaveSessionToolStripMenuItemClick); - // - // helpToolStripMenuItem - // - this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.checkForUpdatesToolStripMenuItem, - this.toolStripMenuItemSplitterCheckForUpdates, - this.helpToolStripMenuItem1, - this.aboutToolStripMenuItem}); - this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; - this.helpToolStripMenuItem.Size = new System.Drawing.Size(45, 20); - this.helpToolStripMenuItem.Text = "Help"; - this.helpToolStripMenuItem.DropDownClosed += new System.EventHandler(this.MenuClosed); - this.helpToolStripMenuItem.DropDownOpening += new System.EventHandler(this.MenuOpened); - // - // checkForUpdatesToolStripMenuItem - // - this.checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem"; - this.checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(181, 22); - this.checkForUpdatesToolStripMenuItem.Text = "Check for updates..."; - this.checkForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click); - // - // toolStripMenuItemSplitterCheckForUpdates - // - this.toolStripMenuItemSplitterCheckForUpdates.Name = "toolStripMenuItemSplitterCheckForUpdates"; - this.toolStripMenuItemSplitterCheckForUpdates.Size = new System.Drawing.Size(178, 6); - // - // helpToolStripMenuItem1 - // - this.helpToolStripMenuItem1.Name = "helpToolStripMenuItem1"; - this.helpToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.F1; - this.helpToolStripMenuItem1.Size = new System.Drawing.Size(181, 22); - this.helpToolStripMenuItem1.Text = "Help"; - this.helpToolStripMenuItem1.Click += new System.EventHandler(this.HelpToolStripMenuItem1Click); - // - // aboutToolStripMenuItem - // - this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - this.aboutToolStripMenuItem.Size = new System.Drawing.Size(181, 22); - this.aboutToolStripMenuItem.Text = "About"; - this.aboutToolStripMenuItem.Click += new System.EventHandler(this.AboutToolStripMenuItemClick); - // - // contextMenuStripListview - // - this.contextMenuStripListview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.setStylesForSelectedLinesToolStripMenuItem, - this.setActorForSelectedLinesToolStripMenuItem, - this.toolStripMenuItemAssStyles, - this.toolStripMenuItemSetRegion, - this.toolStripMenuItemSetLanguage, - this.toolStripMenuItemWebVTT, - this.toolStripMenuItemPreview, - this.toolStripMenuItemDelete, - this.toolStripMenuItemInsertBefore, - this.toolStripMenuItemInsertAfter, - this.toolStripMenuItemInsertSubtitle, - this.toolStripMenuItemCopySourceText, - this.toolStripMenuItemColumn, - this.toolStripMenuItemBookmark, - this.toolStripSeparator7, - this.splitLineToolStripMenuItem, - this.toolStripMenuItemMergeLines, - this.toolStripMenuItemMergeDialog, - this.mergeBeforeToolStripMenuItem, - this.mergeAfterToolStripMenuItem, - this.toolStripSeparator4, - this.extendBeforeToolStripMenuItem, - this.extendAfterToolStripMenuItem, - this.toolStripSeparator8, - this.removeFormattinglToolStripMenuItem, - this.boldToolStripMenuItem, - this.italicToolStripMenuItem, - this.boxToolStripMenuItem, - this.underlineToolStripMenuItem, - this.colorToolStripMenuItem, - this.toolStripMenuItemFont, - this.toolStripMenuItemAlignment, - this.toolStripMenuItemSurroundWithMusicSymbols, - this.toolStripSeparator2, - this.toolStripMenuItemAutoBreakLines, - this.toolStripMenuItemUnbreakLines, - this.toolStripSeparatorBreakLines, - this.typeEffectToolStripMenuItem, - this.karokeeEffectToolStripMenuItem, - this.toolStripSeparatorAdvancedFunctions, - this.showSelectedLinesEarlierlaterToolStripMenuItem, - this.visualSyncSelectedLinesToolStripMenuItem, - this.toolStripMenuItemGoogleMicrosoftTranslateSelLine, - this.toolStripMenuItemTranslateSelected, - this.adjustDisplayTimeForSelectedLinesToolStripMenuItem, - this.fixCommonErrorsInSelectedLinesToolStripMenuItem, - this.changeCasingForSelectedLinesToolStripMenuItem, - this.toolStripMenuItemSaveSelectedLines}); - this.contextMenuStripListview.Name = "contextMenuStripListview"; - this.contextMenuStripListview.Size = new System.Drawing.Size(285, 964); - this.contextMenuStripListview.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.MenuClosed); - this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening); - this.contextMenuStripListview.Opened += new System.EventHandler(this.MenuOpened); - // - // setStylesForSelectedLinesToolStripMenuItem - // - this.setStylesForSelectedLinesToolStripMenuItem.Name = "setStylesForSelectedLinesToolStripMenuItem"; - this.setStylesForSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.setStylesForSelectedLinesToolStripMenuItem.Text = "ASS: Set styles for selected lines..."; - // - // setActorForSelectedLinesToolStripMenuItem - // - this.setActorForSelectedLinesToolStripMenuItem.Name = "setActorForSelectedLinesToolStripMenuItem"; - this.setActorForSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.setActorForSelectedLinesToolStripMenuItem.Text = "ASS: Set styles for selected lines..."; - // - // toolStripMenuItemAssStyles - // - this.toolStripMenuItemAssStyles.Name = "toolStripMenuItemAssStyles"; - this.toolStripMenuItemAssStyles.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemAssStyles.Text = "ASS: Styles..."; - this.toolStripMenuItemAssStyles.Click += new System.EventHandler(this.toolStripMenuItemAssStyles_Click); - // - // toolStripMenuItemSetRegion - // - this.toolStripMenuItemSetRegion.Name = "toolStripMenuItemSetRegion"; - this.toolStripMenuItemSetRegion.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemSetRegion.Text = "Timed text - set region"; - // - // toolStripMenuItemSetLanguage - // - this.toolStripMenuItemSetLanguage.Name = "toolStripMenuItemSetLanguage"; - this.toolStripMenuItemSetLanguage.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemSetLanguage.Text = "Timed text - set language"; - // - // toolStripMenuItemWebVTT - // - this.toolStripMenuItemWebVTT.Name = "toolStripMenuItemWebVTT"; - this.toolStripMenuItemWebVTT.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemWebVTT.Text = "WebVTT voice"; - // - // toolStripMenuItemPreview - // - this.toolStripMenuItemPreview.Name = "toolStripMenuItemPreview"; - this.toolStripMenuItemPreview.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemPreview.Text = "WebVTT browser preview"; - this.toolStripMenuItemPreview.Click += new System.EventHandler(this.toolStripMenuItemPreview_Click); - // - // toolStripMenuItemDelete - // - this.toolStripMenuItemDelete.Name = "toolStripMenuItemDelete"; - this.toolStripMenuItemDelete.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemDelete.Text = "Delete"; - this.toolStripMenuItemDelete.Click += new System.EventHandler(this.ToolStripMenuItemDeleteClick); - // - // toolStripMenuItemInsertBefore - // - this.toolStripMenuItemInsertBefore.Name = "toolStripMenuItemInsertBefore"; - this.toolStripMenuItemInsertBefore.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemInsertBefore.Text = "Insert before"; - this.toolStripMenuItemInsertBefore.Click += new System.EventHandler(this.ToolStripMenuItemInsertBeforeClick); - // - // toolStripMenuItemInsertAfter - // - this.toolStripMenuItemInsertAfter.Name = "toolStripMenuItemInsertAfter"; - this.toolStripMenuItemInsertAfter.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemInsertAfter.Text = "Insert after"; - this.toolStripMenuItemInsertAfter.Click += new System.EventHandler(this.ToolStripMenuItemInsertAfterClick); - // - // toolStripMenuItemInsertSubtitle - // - this.toolStripMenuItemInsertSubtitle.Name = "toolStripMenuItemInsertSubtitle"; - this.toolStripMenuItemInsertSubtitle.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemInsertSubtitle.Text = "Insert subtitle file after this line..."; - this.toolStripMenuItemInsertSubtitle.Click += new System.EventHandler(this.ToolStripMenuItemInsertSubtitleClick); - // - // toolStripMenuItemCopySourceText - // - this.toolStripMenuItemCopySourceText.Name = "toolStripMenuItemCopySourceText"; - this.toolStripMenuItemCopySourceText.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemCopySourceText.Text = "Copy as text to clipboard"; - this.toolStripMenuItemCopySourceText.Click += new System.EventHandler(this.ToolStripMenuItemCopySourceTextClick); - // - // toolStripMenuItemColumn - // - this.toolStripMenuItemColumn.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.columnDeleteTextOnlyToolStripMenuItem, - this.toolStripMenuItemColumnDeleteText, - this.ShiftTextCellsDownToolStripMenuItem, - this.toolStripMenuItemInsertTextFromSub, - this.toolStripMenuItemColumnImportText, - this.toolStripMenuItemPasteSpecial, - this.copyOriginalTextToCurrentToolStripMenuItem, - this.moveTextUpToolStripMenuItem, - this.moveTextDownToolStripMenuItem}); - this.toolStripMenuItemColumn.Name = "toolStripMenuItemColumn"; - this.toolStripMenuItemColumn.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemColumn.Text = "Column"; - this.toolStripMenuItemColumn.DropDownOpening += new System.EventHandler(this.toolStripMenuItemColumn_DropDownOpening); - // - // columnDeleteTextOnlyToolStripMenuItem - // - this.columnDeleteTextOnlyToolStripMenuItem.Name = "columnDeleteTextOnlyToolStripMenuItem"; - this.columnDeleteTextOnlyToolStripMenuItem.Size = new System.Drawing.Size(314, 22); - this.columnDeleteTextOnlyToolStripMenuItem.Text = "Delete text"; - this.columnDeleteTextOnlyToolStripMenuItem.Click += new System.EventHandler(this.columnDeleteTextOnlyToolStripMenuItem_Click); - // - // toolStripMenuItemColumnDeleteText - // - this.toolStripMenuItemColumnDeleteText.Name = "toolStripMenuItemColumnDeleteText"; - this.toolStripMenuItemColumnDeleteText.Size = new System.Drawing.Size(314, 22); - this.toolStripMenuItemColumnDeleteText.Text = "Delete text and shift text cells up"; - this.toolStripMenuItemColumnDeleteText.Click += new System.EventHandler(this.deleteAndShiftCellsUpToolStripMenuItem_Click); - // - // ShiftTextCellsDownToolStripMenuItem - // - this.ShiftTextCellsDownToolStripMenuItem.Name = "ShiftTextCellsDownToolStripMenuItem"; - this.ShiftTextCellsDownToolStripMenuItem.Size = new System.Drawing.Size(314, 22); - this.ShiftTextCellsDownToolStripMenuItem.Text = "Insert and shift text cells down"; - this.ShiftTextCellsDownToolStripMenuItem.Click += new System.EventHandler(this.ShiftTextCellsDownToolStripMenuItem_Click); - // - // toolStripMenuItemInsertTextFromSub - // - this.toolStripMenuItemInsertTextFromSub.Name = "toolStripMenuItemInsertTextFromSub"; - this.toolStripMenuItemInsertTextFromSub.Size = new System.Drawing.Size(314, 22); - this.toolStripMenuItemInsertTextFromSub.Text = "Insert text from subtitle and shift cells down..."; - this.toolStripMenuItemInsertTextFromSub.Click += new System.EventHandler(this.toolStripMenuItemInsertTextFromSub_Click); - // - // toolStripMenuItemColumnImportText - // - this.toolStripMenuItemColumnImportText.Name = "toolStripMenuItemColumnImportText"; - this.toolStripMenuItemColumnImportText.Size = new System.Drawing.Size(314, 22); - this.toolStripMenuItemColumnImportText.Text = "Import text and shift text cells down..."; - this.toolStripMenuItemColumnImportText.Click += new System.EventHandler(this.toolStripMenuItemColumnImportText_Click); - // - // toolStripMenuItemPasteSpecial - // - this.toolStripMenuItemPasteSpecial.Name = "toolStripMenuItemPasteSpecial"; - this.toolStripMenuItemPasteSpecial.Size = new System.Drawing.Size(314, 22); - this.toolStripMenuItemPasteSpecial.Text = "Paste from clipboard..."; - this.toolStripMenuItemPasteSpecial.Click += new System.EventHandler(this.toolStripMenuItemPasteSpecial_Click); - // - // copyOriginalTextToCurrentToolStripMenuItem - // - this.copyOriginalTextToCurrentToolStripMenuItem.Name = "copyOriginalTextToCurrentToolStripMenuItem"; - this.copyOriginalTextToCurrentToolStripMenuItem.Size = new System.Drawing.Size(314, 22); - this.copyOriginalTextToCurrentToolStripMenuItem.Text = "Copy original text to current"; - this.copyOriginalTextToCurrentToolStripMenuItem.Click += new System.EventHandler(this.copyOriginalTextToCurrentToolStripMenuItem_Click); - // - // moveTextUpToolStripMenuItem - // - this.moveTextUpToolStripMenuItem.Name = "moveTextUpToolStripMenuItem"; - this.moveTextUpToolStripMenuItem.Size = new System.Drawing.Size(314, 22); - this.moveTextUpToolStripMenuItem.Text = "Move text up"; - this.moveTextUpToolStripMenuItem.Click += new System.EventHandler(this.moveTextUpToolStripMenuItem_Click); - // - // moveTextDownToolStripMenuItem - // - this.moveTextDownToolStripMenuItem.Name = "moveTextDownToolStripMenuItem"; - this.moveTextDownToolStripMenuItem.Size = new System.Drawing.Size(314, 22); - this.moveTextDownToolStripMenuItem.Text = "Move text down"; - this.moveTextDownToolStripMenuItem.Click += new System.EventHandler(this.moveTextDownToolStripMenuItem_Click); - // - // toolStripMenuItemBookmark - // - this.toolStripMenuItemBookmark.Name = "toolStripMenuItemBookmark"; - this.toolStripMenuItemBookmark.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemBookmark.Text = "Bookmark..."; - this.toolStripMenuItemBookmark.Click += new System.EventHandler(this.toolStripMenuItemBookmark_Click); - // - // toolStripSeparator7 - // - this.toolStripSeparator7.Name = "toolStripSeparator7"; - this.toolStripSeparator7.Size = new System.Drawing.Size(281, 6); - // - // splitLineToolStripMenuItem - // - this.splitLineToolStripMenuItem.Name = "splitLineToolStripMenuItem"; - this.splitLineToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.splitLineToolStripMenuItem.Text = "Split"; - this.splitLineToolStripMenuItem.Click += new System.EventHandler(this.SplitLineToolStripMenuItemClick); - // - // toolStripMenuItemMergeLines - // - this.toolStripMenuItemMergeLines.Name = "toolStripMenuItemMergeLines"; - this.toolStripMenuItemMergeLines.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.M))); - this.toolStripMenuItemMergeLines.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemMergeLines.Text = "Merge selected lines"; - this.toolStripMenuItemMergeLines.Click += new System.EventHandler(this.ToolStripMenuItemMergeLinesClick); - // - // toolStripMenuItemMergeDialog - // - this.toolStripMenuItemMergeDialog.Name = "toolStripMenuItemMergeDialog"; - this.toolStripMenuItemMergeDialog.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemMergeDialog.Text = "Merge selected lines as dialog"; - this.toolStripMenuItemMergeDialog.Click += new System.EventHandler(this.ToolStripMenuItemMergeDialogClick); - // - // mergeBeforeToolStripMenuItem - // - this.mergeBeforeToolStripMenuItem.Name = "mergeBeforeToolStripMenuItem"; - this.mergeBeforeToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.mergeBeforeToolStripMenuItem.Text = "Merge with line before"; - this.mergeBeforeToolStripMenuItem.Click += new System.EventHandler(this.MergeBeforeToolStripMenuItemClick); - // - // mergeAfterToolStripMenuItem - // - this.mergeAfterToolStripMenuItem.Name = "mergeAfterToolStripMenuItem"; - this.mergeAfterToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.mergeAfterToolStripMenuItem.Text = "Merge with line after"; - this.mergeAfterToolStripMenuItem.Click += new System.EventHandler(this.MergeAfterToolStripMenuItemClick); - // - // toolStripSeparator4 - // - this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(281, 6); - // - // extendBeforeToolStripMenuItem - // - this.extendBeforeToolStripMenuItem.Name = "extendBeforeToolStripMenuItem"; - this.extendBeforeToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.extendBeforeToolStripMenuItem.Text = "Extend to line before"; - this.extendBeforeToolStripMenuItem.Click += new System.EventHandler(this.ExtendBeforeToolStripMenuItemClick); - // - // extendAfterToolStripMenuItem - // - this.extendAfterToolStripMenuItem.Name = "extendAfterToolStripMenuItem"; - this.extendAfterToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.extendAfterToolStripMenuItem.Text = "Extend to line after"; - this.extendAfterToolStripMenuItem.Click += new System.EventHandler(this.ExtendAfterToolStripMenuItemClick); - // - // toolStripSeparator8 - // - this.toolStripSeparator8.Name = "toolStripSeparator8"; - this.toolStripSeparator8.Size = new System.Drawing.Size(281, 6); - // - // removeFormattinglToolStripMenuItem - // - this.removeFormattinglToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.removeAllFormattingsToolStripMenuItem, - this.removeBoldToolStripMenuItem, - this.removeItalicToolStripMenuItem, - this.removeUnderlineToolStripMenuItem, - this.removeColorToolStripMenuItem, - this.removeFontNameToolStripMenuItem, - this.removeAlignmentToolStripMenuItem}); - this.removeFormattinglToolStripMenuItem.Name = "removeFormattinglToolStripMenuItem"; - this.removeFormattinglToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.removeFormattinglToolStripMenuItem.Text = "Remove formatting"; - // - // removeAllFormattingsToolStripMenuItem - // - this.removeAllFormattingsToolStripMenuItem.Name = "removeAllFormattingsToolStripMenuItem"; - this.removeAllFormattingsToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.removeAllFormattingsToolStripMenuItem.Text = "Remove all formattings"; - this.removeAllFormattingsToolStripMenuItem.Click += new System.EventHandler(this.removeAllFormattingsToolStripMenuItem_Click); - // - // removeBoldToolStripMenuItem - // - this.removeBoldToolStripMenuItem.Name = "removeBoldToolStripMenuItem"; - this.removeBoldToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.removeBoldToolStripMenuItem.Text = "Remove bold"; - this.removeBoldToolStripMenuItem.Click += new System.EventHandler(this.removeBoldToolStripMenuItem_Click); - // - // removeItalicToolStripMenuItem - // - this.removeItalicToolStripMenuItem.Name = "removeItalicToolStripMenuItem"; - this.removeItalicToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.removeItalicToolStripMenuItem.Text = "Remove italic"; - this.removeItalicToolStripMenuItem.Click += new System.EventHandler(this.removeItalicToolStripMenuItem_Click); - // - // removeUnderlineToolStripMenuItem - // - this.removeUnderlineToolStripMenuItem.Name = "removeUnderlineToolStripMenuItem"; - this.removeUnderlineToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.removeUnderlineToolStripMenuItem.Text = "Remove underline"; - this.removeUnderlineToolStripMenuItem.Click += new System.EventHandler(this.removeUnderlineToolStripMenuItem_Click); - // - // removeColorToolStripMenuItem - // - this.removeColorToolStripMenuItem.Name = "removeColorToolStripMenuItem"; - this.removeColorToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.removeColorToolStripMenuItem.Text = "Remove color"; - this.removeColorToolStripMenuItem.Click += new System.EventHandler(this.removeColorToolStripMenuItem_Click); - // - // removeFontNameToolStripMenuItem - // - this.removeFontNameToolStripMenuItem.Name = "removeFontNameToolStripMenuItem"; - this.removeFontNameToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.removeFontNameToolStripMenuItem.Text = "Remove font name"; - this.removeFontNameToolStripMenuItem.Click += new System.EventHandler(this.removeFontNameToolStripMenuItem_Click); - // - // removeAlignmentToolStripMenuItem - // - this.removeAlignmentToolStripMenuItem.Name = "removeAlignmentToolStripMenuItem"; - this.removeAlignmentToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.removeAlignmentToolStripMenuItem.Text = "Remove alignment"; - this.removeAlignmentToolStripMenuItem.Click += new System.EventHandler(this.removeAlignmentToolStripMenuItem_Click); - // - // boldToolStripMenuItem - // - this.boldToolStripMenuItem.Name = "boldToolStripMenuItem"; - this.boldToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.boldToolStripMenuItem.Text = "Bold"; - this.boldToolStripMenuItem.Click += new System.EventHandler(this.BoldToolStripMenuItemClick); - // - // italicToolStripMenuItem - // - this.italicToolStripMenuItem.Name = "italicToolStripMenuItem"; - this.italicToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); - this.italicToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.italicToolStripMenuItem.Text = "Italic"; - this.italicToolStripMenuItem.Click += new System.EventHandler(this.ItalicToolStripMenuItemClick); - // - // boxToolStripMenuItem - // - this.boxToolStripMenuItem.Name = "boxToolStripMenuItem"; - this.boxToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.boxToolStripMenuItem.Text = "Box"; - this.boxToolStripMenuItem.Click += new System.EventHandler(this.boxToolStripMenuItem_Click); - // - // underlineToolStripMenuItem - // - this.underlineToolStripMenuItem.Name = "underlineToolStripMenuItem"; - this.underlineToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.underlineToolStripMenuItem.Text = "Underline"; - this.underlineToolStripMenuItem.Click += new System.EventHandler(this.UnderlineToolStripMenuItemClick); - // - // colorToolStripMenuItem - // - this.colorToolStripMenuItem.Name = "colorToolStripMenuItem"; - this.colorToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.colorToolStripMenuItem.Text = "Color..."; - this.colorToolStripMenuItem.Click += new System.EventHandler(this.ColorToolStripMenuItemClick); - // - // toolStripMenuItemFont - // - this.toolStripMenuItemFont.Name = "toolStripMenuItemFont"; - this.toolStripMenuItemFont.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemFont.Text = "Font name..."; - this.toolStripMenuItemFont.Click += new System.EventHandler(this.toolStripMenuItemFont_Click); - // - // toolStripMenuItemAlignment - // - this.toolStripMenuItemAlignment.Name = "toolStripMenuItemAlignment"; - this.toolStripMenuItemAlignment.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemAlignment.Text = "Alignment"; - this.toolStripMenuItemAlignment.Click += new System.EventHandler(this.toolStripMenuItemAlignment_Click); - // - // toolStripMenuItemSurroundWithMusicSymbols - // - this.toolStripMenuItemSurroundWithMusicSymbols.Name = "toolStripMenuItemSurroundWithMusicSymbols"; - this.toolStripMenuItemSurroundWithMusicSymbols.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemSurroundWithMusicSymbols.Text = "♪"; - this.toolStripMenuItemSurroundWithMusicSymbols.Click += new System.EventHandler(this.ToolStripMenuItemSurroundWithMusicSymbolsClick); - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(281, 6); - // - // toolStripMenuItemAutoBreakLines - // - this.toolStripMenuItemAutoBreakLines.Name = "toolStripMenuItemAutoBreakLines"; - this.toolStripMenuItemAutoBreakLines.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemAutoBreakLines.Text = "Auto balance selected lines..."; - this.toolStripMenuItemAutoBreakLines.Click += new System.EventHandler(this.ToolStripMenuItemAutoBreakLinesClick); - // - // toolStripMenuItemUnbreakLines - // - this.toolStripMenuItemUnbreakLines.Name = "toolStripMenuItemUnbreakLines"; - this.toolStripMenuItemUnbreakLines.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemUnbreakLines.Text = "Remove line-breaks in selected lines..."; - this.toolStripMenuItemUnbreakLines.Click += new System.EventHandler(this.ToolStripMenuItemUnbreakLinesClick); - // - // toolStripSeparatorBreakLines - // - this.toolStripSeparatorBreakLines.Name = "toolStripSeparatorBreakLines"; - this.toolStripSeparatorBreakLines.Size = new System.Drawing.Size(281, 6); - // - // typeEffectToolStripMenuItem - // - this.typeEffectToolStripMenuItem.Name = "typeEffectToolStripMenuItem"; - this.typeEffectToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.typeEffectToolStripMenuItem.Text = "Typewriter effect..."; - this.typeEffectToolStripMenuItem.Click += new System.EventHandler(this.TypeEffectToolStripMenuItemClick); - // - // karokeeEffectToolStripMenuItem - // - this.karokeeEffectToolStripMenuItem.Name = "karokeeEffectToolStripMenuItem"; - this.karokeeEffectToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.karokeeEffectToolStripMenuItem.Text = "Karaoke effect..."; - this.karokeeEffectToolStripMenuItem.Click += new System.EventHandler(this.KarokeeEffectToolStripMenuItemClick); - // - // toolStripSeparatorAdvancedFunctions - // - this.toolStripSeparatorAdvancedFunctions.Name = "toolStripSeparatorAdvancedFunctions"; - this.toolStripSeparatorAdvancedFunctions.Size = new System.Drawing.Size(281, 6); - // - // showSelectedLinesEarlierlaterToolStripMenuItem - // - this.showSelectedLinesEarlierlaterToolStripMenuItem.Name = "showSelectedLinesEarlierlaterToolStripMenuItem"; - this.showSelectedLinesEarlierlaterToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.showSelectedLinesEarlierlaterToolStripMenuItem.Text = "Show selected lines earlier/later..."; - this.showSelectedLinesEarlierlaterToolStripMenuItem.Click += new System.EventHandler(this.ShowSelectedLinesEarlierlaterToolStripMenuItemClick); - // - // visualSyncSelectedLinesToolStripMenuItem - // - this.visualSyncSelectedLinesToolStripMenuItem.Name = "visualSyncSelectedLinesToolStripMenuItem"; - this.visualSyncSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.visualSyncSelectedLinesToolStripMenuItem.Text = "Visual sync selected lines..."; - this.visualSyncSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.VisualSyncSelectedLinesToolStripMenuItemClick); - // - // toolStripMenuItemGoogleMicrosoftTranslateSelLine - // - this.toolStripMenuItemGoogleMicrosoftTranslateSelLine.Name = "toolStripMenuItemGoogleMicrosoftTranslateSelLine"; - this.toolStripMenuItemGoogleMicrosoftTranslateSelLine.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemGoogleMicrosoftTranslateSelLine.Text = "Google/Microsoft translate selected line"; - this.toolStripMenuItemGoogleMicrosoftTranslateSelLine.Click += new System.EventHandler(this.ToolStripMenuItemGoogleMicrosoftTranslateSelLineClick); - // - // toolStripMenuItemTranslateSelected - // - this.toolStripMenuItemTranslateSelected.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.googleTranslateToolStripMenuItem, - this.microsoftBingTranslateToolStripMenuItem}); - this.toolStripMenuItemTranslateSelected.Name = "toolStripMenuItemTranslateSelected"; - this.toolStripMenuItemTranslateSelected.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemTranslateSelected.Text = "Translate selected lines via..."; - // - // googleTranslateToolStripMenuItem - // - this.googleTranslateToolStripMenuItem.Name = "googleTranslateToolStripMenuItem"; - this.googleTranslateToolStripMenuItem.Size = new System.Drawing.Size(209, 22); - this.googleTranslateToolStripMenuItem.Text = "Google translate..."; - this.googleTranslateToolStripMenuItem.Click += new System.EventHandler(this.googleTranslateToolStripMenuItem_Click); - // - // microsoftBingTranslateToolStripMenuItem - // - this.microsoftBingTranslateToolStripMenuItem.Name = "microsoftBingTranslateToolStripMenuItem"; - this.microsoftBingTranslateToolStripMenuItem.Size = new System.Drawing.Size(209, 22); - this.microsoftBingTranslateToolStripMenuItem.Text = "Microsoft Bing translate..."; - this.microsoftBingTranslateToolStripMenuItem.Click += new System.EventHandler(this.microsoftBingTranslateToolStripMenuItem_Click); - // - // adjustDisplayTimeForSelectedLinesToolStripMenuItem - // - this.adjustDisplayTimeForSelectedLinesToolStripMenuItem.Name = "adjustDisplayTimeForSelectedLinesToolStripMenuItem"; - this.adjustDisplayTimeForSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.adjustDisplayTimeForSelectedLinesToolStripMenuItem.Text = "Adjust display time for selected lines..."; - this.adjustDisplayTimeForSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.AdjustDisplayTimeForSelectedLinesToolStripMenuItemClick); - // - // fixCommonErrorsInSelectedLinesToolStripMenuItem - // - this.fixCommonErrorsInSelectedLinesToolStripMenuItem.Name = "fixCommonErrorsInSelectedLinesToolStripMenuItem"; - this.fixCommonErrorsInSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.fixCommonErrorsInSelectedLinesToolStripMenuItem.Text = "Fix common errors in selected lines..."; - this.fixCommonErrorsInSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.FixCommonErrorsInSelectedLinesToolStripMenuItemClick); - // - // changeCasingForSelectedLinesToolStripMenuItem - // - this.changeCasingForSelectedLinesToolStripMenuItem.Name = "changeCasingForSelectedLinesToolStripMenuItem"; - this.changeCasingForSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(284, 22); - this.changeCasingForSelectedLinesToolStripMenuItem.Text = "Change casing for selected lines..."; - this.changeCasingForSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.ChangeCasingForSelectedLinesToolStripMenuItemClick); - // - // toolStripMenuItemSaveSelectedLines - // - this.toolStripMenuItemSaveSelectedLines.Name = "toolStripMenuItemSaveSelectedLines"; - this.toolStripMenuItemSaveSelectedLines.Size = new System.Drawing.Size(284, 22); - this.toolStripMenuItemSaveSelectedLines.Text = "Save selected lines as..."; - this.toolStripMenuItemSaveSelectedLines.Click += new System.EventHandler(this.ToolStripMenuItemSaveSelectedLinesClick); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // timer1 - // - this.timer1.Tick += new System.EventHandler(this.timer1_Tick); - // - // groupBoxVideo - // - this.groupBoxVideo.Controls.Add(this.labelNextWord); - this.groupBoxVideo.Controls.Add(this.audioVisualizer); - this.groupBoxVideo.Controls.Add(this.checkBoxSyncListViewWithVideoWhilePlaying); - this.groupBoxVideo.Controls.Add(this.labelVideoInfo); - this.groupBoxVideo.Controls.Add(this.trackBarWaveformPosition); - this.groupBoxVideo.Controls.Add(this.panelWaveformControls); - this.groupBoxVideo.Controls.Add(this.tabControlButtons); - this.groupBoxVideo.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBoxVideo.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.groupBoxVideo.Location = new System.Drawing.Point(0, 0); - this.groupBoxVideo.Margin = new System.Windows.Forms.Padding(0); - this.groupBoxVideo.Name = "groupBoxVideo"; - this.groupBoxVideo.Padding = new System.Windows.Forms.Padding(0); - this.groupBoxVideo.Size = new System.Drawing.Size(975, 305); - this.groupBoxVideo.TabIndex = 1; - this.groupBoxVideo.TabStop = false; - // - // labelNextWord - // - this.labelNextWord.Anchor = System.Windows.Forms.AnchorStyles.None; - this.labelNextWord.AutoSize = true; - this.labelNextWord.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelNextWord.Location = new System.Drawing.Point(401, 9); - this.labelNextWord.Name = "labelNextWord"; - this.labelNextWord.Size = new System.Drawing.Size(71, 17); - this.labelNextWord.TabIndex = 13; - this.labelNextWord.Text = "Next: xxx"; - this.labelNextWord.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // audioVisualizer - // - this.audioVisualizer.AllowDrop = true; - this.audioVisualizer.AllowNewSelection = true; - this.audioVisualizer.AllowOverlap = false; - this.audioVisualizer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.audioVisualizer.BackColor = System.Drawing.Color.Black; - this.audioVisualizer.BackgroundColor = System.Drawing.Color.Black; - this.audioVisualizer.ClosenessForBorderSelection = 15; - this.audioVisualizer.Color = System.Drawing.Color.GreenYellow; - this.audioVisualizer.CursorColor = System.Drawing.Color.Empty; - this.audioVisualizer.ChaptersColor = System.Drawing.Color.Empty; - this.audioVisualizer.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); - this.audioVisualizer.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(18))))); - this.audioVisualizer.InsertAtVideoPositionShortcut = System.Windows.Forms.Keys.Insert; - this.audioVisualizer.Location = new System.Drawing.Point(472, 32); - this.audioVisualizer.Margin = new System.Windows.Forms.Padding(0); - this.audioVisualizer.MouseWheelScrollUpIsForward = true; - this.audioVisualizer.Move100MsLeft = System.Windows.Forms.Keys.None; - this.audioVisualizer.Move100MsRight = System.Windows.Forms.Keys.None; - this.audioVisualizer.MoveOneSecondLeft = System.Windows.Forms.Keys.None; - this.audioVisualizer.MoveOneSecondRight = System.Windows.Forms.Keys.None; - this.audioVisualizer.Name = "audioVisualizer"; - this.audioVisualizer.NewSelectionParagraph = null; - this.audioVisualizer.ParagraphColor = System.Drawing.Color.LimeGreen; - this.audioVisualizer.SceneChanges = ((System.Collections.Generic.List)(resources.GetObject("audioVisualizer.SceneChanges"))); - this.audioVisualizer.SelectedColor = System.Drawing.Color.Red; - this.audioVisualizer.ShowGridLines = true; - this.audioVisualizer.ShowSpectrogram = false; - this.audioVisualizer.ShowWaveform = true; - this.audioVisualizer.Size = new System.Drawing.Size(499, 229); - this.audioVisualizer.StartPositionSeconds = 0D; - this.audioVisualizer.TabIndex = 6; - this.audioVisualizer.TextBold = true; - this.audioVisualizer.TextColor = System.Drawing.Color.Gray; - this.audioVisualizer.TextSize = 9F; - this.audioVisualizer.VerticalZoomFactor = 1D; - this.audioVisualizer.WaveformNotLoadedText = "Click to add waveform"; - this.audioVisualizer.WavePeaks = null; - this.audioVisualizer.ZoomFactor = 1D; - this.audioVisualizer.Click += new System.EventHandler(this.AudioWaveform_Click); - this.audioVisualizer.DragDrop += new System.Windows.Forms.DragEventHandler(this.AudioWaveformDragDrop); - this.audioVisualizer.DragEnter += new System.Windows.Forms.DragEventHandler(this.AudioWaveformDragEnter); - this.audioVisualizer.MouseEnter += new System.EventHandler(this.audioVisualizer_MouseEnter); - // - // checkBoxSyncListViewWithVideoWhilePlaying - // - this.checkBoxSyncListViewWithVideoWhilePlaying.AutoSize = true; - this.checkBoxSyncListViewWithVideoWhilePlaying.Location = new System.Drawing.Point(558, 11); - this.checkBoxSyncListViewWithVideoWhilePlaying.Name = "checkBoxSyncListViewWithVideoWhilePlaying"; - this.checkBoxSyncListViewWithVideoWhilePlaying.Size = new System.Drawing.Size(205, 17); - this.checkBoxSyncListViewWithVideoWhilePlaying.TabIndex = 1; - this.checkBoxSyncListViewWithVideoWhilePlaying.Text = "Sync listview with movie when playing"; - this.checkBoxSyncListViewWithVideoWhilePlaying.UseVisualStyleBackColor = true; - // - // labelVideoInfo - // - this.labelVideoInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelVideoInfo.Location = new System.Drawing.Point(603, 12); - this.labelVideoInfo.Name = "labelVideoInfo"; - this.labelVideoInfo.Size = new System.Drawing.Size(369, 19); - this.labelVideoInfo.TabIndex = 12; - this.labelVideoInfo.Text = "No video file loaded"; - this.labelVideoInfo.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // trackBarWaveformPosition - // - this.trackBarWaveformPosition.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.trackBarWaveformPosition.AutoSize = false; - this.trackBarWaveformPosition.Location = new System.Drawing.Point(674, 267); - this.trackBarWaveformPosition.Maximum = 1000; - this.trackBarWaveformPosition.Name = "trackBarWaveformPosition"; - this.trackBarWaveformPosition.Size = new System.Drawing.Size(297, 20); - this.trackBarWaveformPosition.TabIndex = 11; - this.trackBarWaveformPosition.TickStyle = System.Windows.Forms.TickStyle.None; - this.trackBarWaveformPosition.ValueChanged += new System.EventHandler(this.trackBarWaveformPosition_ValueChanged); - this.trackBarWaveformPosition.KeyDown += new System.Windows.Forms.KeyEventHandler(this.trackBarWaveformPosition_KeyDown); - // - // panelWaveformControls - // - this.panelWaveformControls.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.panelWaveformControls.Controls.Add(this.toolStripWaveControls); - this.panelWaveformControls.Location = new System.Drawing.Point(474, 265); - this.panelWaveformControls.Name = "panelWaveformControls"; - this.panelWaveformControls.Size = new System.Drawing.Size(205, 30); - this.panelWaveformControls.TabIndex = 10; - // - // toolStripWaveControls - // - this.toolStripWaveControls.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.toolStripWaveControls.Dock = System.Windows.Forms.DockStyle.None; - this.toolStripWaveControls.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; - this.toolStripWaveControls.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripButtonWaveformZoomOut, - this.toolStripComboBoxWaveform, - this.toolStripButtonWaveformZoomIn, - this.toolStripSeparator16, - this.toolStripButtonWaveformPause, - this.toolStripButtonWaveformPlay, - this.toolStripButtonLockCenter, - this.toolStripSplitButtonPlayRate}); - this.toolStripWaveControls.Location = new System.Drawing.Point(0, 3); - this.toolStripWaveControls.Name = "toolStripWaveControls"; - this.toolStripWaveControls.Size = new System.Drawing.Size(197, 25); - this.toolStripWaveControls.TabIndex = 0; - this.toolStripWaveControls.Text = "toolStrip2"; - // - // toolStripButtonWaveformZoomOut - // - this.toolStripButtonWaveformZoomOut.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonWaveformZoomOut.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonWaveformZoomOut.Image"))); - this.toolStripButtonWaveformZoomOut.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonWaveformZoomOut.Name = "toolStripButtonWaveformZoomOut"; - this.toolStripButtonWaveformZoomOut.Size = new System.Drawing.Size(23, 22); - this.toolStripButtonWaveformZoomOut.Text = "toolStripButton3"; - this.toolStripButtonWaveformZoomOut.Click += new System.EventHandler(this.toolStripButtonWaveformZoomOut_Click); - // - // toolStripComboBoxWaveform - // - this.toolStripComboBoxWaveform.AutoSize = false; - this.toolStripComboBoxWaveform.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.toolStripComboBoxWaveform.Name = "toolStripComboBoxWaveform"; - this.toolStripComboBoxWaveform.Size = new System.Drawing.Size(62, 23); - // - // toolStripButtonWaveformZoomIn - // - this.toolStripButtonWaveformZoomIn.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonWaveformZoomIn.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonWaveformZoomIn.Image"))); - this.toolStripButtonWaveformZoomIn.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonWaveformZoomIn.Name = "toolStripButtonWaveformZoomIn"; - this.toolStripButtonWaveformZoomIn.Size = new System.Drawing.Size(23, 22); - this.toolStripButtonWaveformZoomIn.Text = "toolStripButton1"; - this.toolStripButtonWaveformZoomIn.Click += new System.EventHandler(this.toolStripButtonWaveformZoomIn_Click); - // - // toolStripSeparator16 - // - this.toolStripSeparator16.Name = "toolStripSeparator16"; - this.toolStripSeparator16.Size = new System.Drawing.Size(6, 25); - // - // toolStripButtonWaveformPause - // - this.toolStripButtonWaveformPause.AutoToolTip = false; - this.toolStripButtonWaveformPause.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonWaveformPause.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonWaveformPause.Image"))); - this.toolStripButtonWaveformPause.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonWaveformPause.Name = "toolStripButtonWaveformPause"; - this.toolStripButtonWaveformPause.Size = new System.Drawing.Size(23, 22); - this.toolStripButtonWaveformPause.Text = "toolStripButton1"; - this.toolStripButtonWaveformPause.Visible = false; - this.toolStripButtonWaveformPause.Click += new System.EventHandler(this.toolStripButtonWaveformPause_Click); - // - // toolStripButtonWaveformPlay - // - this.toolStripButtonWaveformPlay.AutoToolTip = false; - this.toolStripButtonWaveformPlay.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonWaveformPlay.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonWaveformPlay.Image"))); - this.toolStripButtonWaveformPlay.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonWaveformPlay.Name = "toolStripButtonWaveformPlay"; - this.toolStripButtonWaveformPlay.Size = new System.Drawing.Size(23, 22); - this.toolStripButtonWaveformPlay.Text = "toolStripButton1"; - this.toolStripButtonWaveformPlay.Click += new System.EventHandler(this.toolStripButtonWaveformPlay_Click); - // - // toolStripButtonLockCenter - // - this.toolStripButtonLockCenter.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripButtonLockCenter.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonLockCenter.Image"))); - this.toolStripButtonLockCenter.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripButtonLockCenter.Name = "toolStripButtonLockCenter"; - this.toolStripButtonLockCenter.Size = new System.Drawing.Size(23, 22); - this.toolStripButtonLockCenter.Text = "Center"; - this.toolStripButtonLockCenter.Click += new System.EventHandler(this.toolStripButtonLockCenter_Click); - // - // toolStripSplitButtonPlayRate - // - this.toolStripSplitButtonPlayRate.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.toolStripSplitButtonPlayRate.Image = ((System.Drawing.Image)(resources.GetObject("toolStripSplitButtonPlayRate.Image"))); - this.toolStripSplitButtonPlayRate.ImageTransparentColor = System.Drawing.Color.Magenta; - this.toolStripSplitButtonPlayRate.Name = "toolStripSplitButtonPlayRate"; - this.toolStripSplitButtonPlayRate.Size = new System.Drawing.Size(32, 22); - this.toolStripSplitButtonPlayRate.Text = "Play rate (speed)"; - this.toolStripSplitButtonPlayRate.ButtonClick += new System.EventHandler(this.toolStripSplitButtonPlayRate_ButtonClick); - // - // tabControlButtons - // - this.tabControlButtons.Controls.Add(this.tabPageTranslate); - this.tabControlButtons.Controls.Add(this.tabPageCreate); - this.tabControlButtons.Controls.Add(this.tabPageAdjust); - this.tabControlButtons.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed; - this.tabControlButtons.Location = new System.Drawing.Point(6, 12); - this.tabControlButtons.Name = "tabControlButtons"; - this.tabControlButtons.SelectedIndex = 0; - this.tabControlButtons.Size = new System.Drawing.Size(467, 283); - this.tabControlButtons.TabIndex = 0; - this.tabControlButtons.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.TabControlButtonsDrawItem); - this.tabControlButtons.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged); - // - // tabPageTranslate - // - this.tabPageTranslate.Controls.Add(this.labelTranslateTip); - this.tabPageTranslate.Controls.Add(this.groupBoxTranslateSearch); - this.tabPageTranslate.Controls.Add(this.groupBoxAutoContinue); - this.tabPageTranslate.Controls.Add(this.buttonStop); - this.tabPageTranslate.Controls.Add(this.groupBoxAutoRepeat); - this.tabPageTranslate.Controls.Add(this.buttonPlayPrevious); - this.tabPageTranslate.Controls.Add(this.buttonPlayCurrent); - this.tabPageTranslate.Controls.Add(this.buttonPlayNext); - this.tabPageTranslate.Location = new System.Drawing.Point(4, 22); - this.tabPageTranslate.Name = "tabPageTranslate"; - this.tabPageTranslate.Padding = new System.Windows.Forms.Padding(3); - this.tabPageTranslate.Size = new System.Drawing.Size(459, 257); - this.tabPageTranslate.TabIndex = 0; - this.tabPageTranslate.Text = "Translate"; - this.tabPageTranslate.UseVisualStyleBackColor = true; - // - // labelTranslateTip - // - this.labelTranslateTip.AutoSize = true; - this.labelTranslateTip.ForeColor = System.Drawing.Color.Gray; - this.labelTranslateTip.Location = new System.Drawing.Point(16, 225); - this.labelTranslateTip.Name = "labelTranslateTip"; - this.labelTranslateTip.Size = new System.Drawing.Size(294, 13); - this.labelTranslateTip.TabIndex = 7; - this.labelTranslateTip.Text = "Tip: Use to go to previous/next subtitle"; - // - // groupBoxTranslateSearch - // - this.groupBoxTranslateSearch.Controls.Add(this.buttonCustomUrl2); - this.groupBoxTranslateSearch.Controls.Add(this.buttonCustomUrl1); - this.groupBoxTranslateSearch.Controls.Add(this.buttonGoogleTranslateIt); - this.groupBoxTranslateSearch.Controls.Add(this.buttonGoogleIt); - this.groupBoxTranslateSearch.Controls.Add(this.textBoxSearchWord); - this.groupBoxTranslateSearch.Location = new System.Drawing.Point(198, 68); - this.groupBoxTranslateSearch.Name = "groupBoxTranslateSearch"; - this.groupBoxTranslateSearch.Size = new System.Drawing.Size(256, 150); - this.groupBoxTranslateSearch.TabIndex = 6; - this.groupBoxTranslateSearch.TabStop = false; - this.groupBoxTranslateSearch.Text = "Search text online"; - // - // buttonCustomUrl2 - // - this.buttonCustomUrl2.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCustomUrl2.Location = new System.Drawing.Point(6, 118); - this.buttonCustomUrl2.Name = "buttonCustomUrl2"; - this.buttonCustomUrl2.Size = new System.Drawing.Size(244, 23); - this.buttonCustomUrl2.TabIndex = 4; - this.buttonCustomUrl2.Text = "Custom URL"; - this.buttonCustomUrl2.UseVisualStyleBackColor = true; - this.buttonCustomUrl2.Click += new System.EventHandler(this.buttonCustomUrl2_Click); - // - // buttonCustomUrl1 - // - this.buttonCustomUrl1.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCustomUrl1.Location = new System.Drawing.Point(6, 91); - this.buttonCustomUrl1.Name = "buttonCustomUrl1"; - this.buttonCustomUrl1.Size = new System.Drawing.Size(244, 23); - this.buttonCustomUrl1.TabIndex = 3; - this.buttonCustomUrl1.Text = "Custom URL"; - this.buttonCustomUrl1.UseVisualStyleBackColor = true; - this.buttonCustomUrl1.Click += new System.EventHandler(this.buttonCustomUrl_Click); - // - // buttonGoogleTranslateIt - // - this.buttonGoogleTranslateIt.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonGoogleTranslateIt.Location = new System.Drawing.Point(132, 63); - this.buttonGoogleTranslateIt.Name = "buttonGoogleTranslateIt"; - this.buttonGoogleTranslateIt.Size = new System.Drawing.Size(118, 23); - this.buttonGoogleTranslateIt.TabIndex = 2; - this.buttonGoogleTranslateIt.Text = "Google translate it"; - this.buttonGoogleTranslateIt.UseVisualStyleBackColor = true; - this.buttonGoogleTranslateIt.Click += new System.EventHandler(this.buttonGoogleTranslateIt_Click); - // - // buttonGoogleIt - // - this.buttonGoogleIt.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonGoogleIt.Location = new System.Drawing.Point(6, 63); - this.buttonGoogleIt.Name = "buttonGoogleIt"; - this.buttonGoogleIt.Size = new System.Drawing.Size(120, 23); - this.buttonGoogleIt.TabIndex = 1; - this.buttonGoogleIt.Text = "Google it"; - this.buttonGoogleIt.UseVisualStyleBackColor = true; - this.buttonGoogleIt.Click += new System.EventHandler(this.buttonGoogleIt_Click); - // - // textBoxSearchWord - // - this.textBoxSearchWord.Location = new System.Drawing.Point(6, 18); - this.textBoxSearchWord.Multiline = true; - this.textBoxSearchWord.Name = "textBoxSearchWord"; - this.textBoxSearchWord.Size = new System.Drawing.Size(244, 39); - this.textBoxSearchWord.TabIndex = 0; - // - // groupBoxAutoContinue - // - this.groupBoxAutoContinue.Controls.Add(this.comboBoxAutoContinue); - this.groupBoxAutoContinue.Controls.Add(this.labelAutoContinueDelay); - this.groupBoxAutoContinue.Controls.Add(this.checkBoxAutoContinue); - this.groupBoxAutoContinue.Location = new System.Drawing.Point(12, 120); - this.groupBoxAutoContinue.Name = "groupBoxAutoContinue"; - this.groupBoxAutoContinue.Size = new System.Drawing.Size(182, 98); - this.groupBoxAutoContinue.TabIndex = 1; - this.groupBoxAutoContinue.TabStop = false; - this.groupBoxAutoContinue.Text = "Auto continue"; - // - // comboBoxAutoContinue - // - this.comboBoxAutoContinue.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxAutoContinue.FormattingEnabled = true; - this.comboBoxAutoContinue.Items.AddRange(new object[] { - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "10", - "11", - "12", - "13", - "14", - "15"}); - this.comboBoxAutoContinue.Location = new System.Drawing.Point(6, 59); - this.comboBoxAutoContinue.Name = "comboBoxAutoContinue"; - this.comboBoxAutoContinue.Size = new System.Drawing.Size(96, 21); - this.comboBoxAutoContinue.TabIndex = 2; - // - // labelAutoContinueDelay - // - this.labelAutoContinueDelay.AutoSize = true; - this.labelAutoContinueDelay.Location = new System.Drawing.Point(7, 43); - this.labelAutoContinueDelay.Name = "labelAutoContinueDelay"; - this.labelAutoContinueDelay.Size = new System.Drawing.Size(83, 13); - this.labelAutoContinueDelay.TabIndex = 1; - this.labelAutoContinueDelay.Text = "Delay (seconds)"; - // - // checkBoxAutoContinue - // - this.checkBoxAutoContinue.AutoSize = true; - this.checkBoxAutoContinue.Location = new System.Drawing.Point(10, 19); - this.checkBoxAutoContinue.Name = "checkBoxAutoContinue"; - this.checkBoxAutoContinue.Size = new System.Drawing.Size(107, 17); - this.checkBoxAutoContinue.TabIndex = 0; - this.checkBoxAutoContinue.Text = "Auto continue on"; - this.checkBoxAutoContinue.UseVisualStyleBackColor = true; - // - // buttonStop - // - this.buttonStop.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonStop.Location = new System.Drawing.Point(288, 42); - this.buttonStop.Name = "buttonStop"; - this.buttonStop.Size = new System.Drawing.Size(76, 23); - this.buttonStop.TabIndex = 5; - this.buttonStop.Text = "Pa&use"; - this.buttonStop.UseVisualStyleBackColor = true; - this.buttonStop.Click += new System.EventHandler(this.buttonStop_Click); - // - // groupBoxAutoRepeat - // - this.groupBoxAutoRepeat.Controls.Add(this.comboBoxAutoRepeat); - this.groupBoxAutoRepeat.Controls.Add(this.labelAutoRepeatCount); - this.groupBoxAutoRepeat.Controls.Add(this.checkBoxAutoRepeatOn); - this.groupBoxAutoRepeat.Location = new System.Drawing.Point(12, 14); - this.groupBoxAutoRepeat.Name = "groupBoxAutoRepeat"; - this.groupBoxAutoRepeat.Size = new System.Drawing.Size(182, 100); - this.groupBoxAutoRepeat.TabIndex = 0; - this.groupBoxAutoRepeat.TabStop = false; - this.groupBoxAutoRepeat.Text = "Auto repeat"; - // - // comboBoxAutoRepeat - // - this.comboBoxAutoRepeat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxAutoRepeat.FormattingEnabled = true; - this.comboBoxAutoRepeat.Items.AddRange(new object[] { - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9"}); - this.comboBoxAutoRepeat.Location = new System.Drawing.Point(6, 60); - this.comboBoxAutoRepeat.Name = "comboBoxAutoRepeat"; - this.comboBoxAutoRepeat.Size = new System.Drawing.Size(96, 21); - this.comboBoxAutoRepeat.TabIndex = 2; - // - // labelAutoRepeatCount - // - this.labelAutoRepeatCount.AutoSize = true; - this.labelAutoRepeatCount.Location = new System.Drawing.Point(6, 44); - this.labelAutoRepeatCount.Name = "labelAutoRepeatCount"; - this.labelAutoRepeatCount.Size = new System.Drawing.Size(105, 13); - this.labelAutoRepeatCount.TabIndex = 1; - this.labelAutoRepeatCount.Text = "Repeat count (times)"; - // - // checkBoxAutoRepeatOn - // - this.checkBoxAutoRepeatOn.AutoSize = true; - this.checkBoxAutoRepeatOn.Checked = true; - this.checkBoxAutoRepeatOn.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxAutoRepeatOn.Location = new System.Drawing.Point(10, 19); - this.checkBoxAutoRepeatOn.Name = "checkBoxAutoRepeatOn"; - this.checkBoxAutoRepeatOn.Size = new System.Drawing.Size(96, 17); - this.checkBoxAutoRepeatOn.TabIndex = 0; - this.checkBoxAutoRepeatOn.Text = "Auto repeat on"; - this.checkBoxAutoRepeatOn.UseVisualStyleBackColor = true; - // - // buttonPlayPrevious - // - this.buttonPlayPrevious.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonPlayPrevious.Location = new System.Drawing.Point(206, 14); - this.buttonPlayPrevious.Name = "buttonPlayPrevious"; - this.buttonPlayPrevious.Size = new System.Drawing.Size(76, 23); - this.buttonPlayPrevious.TabIndex = 2; - this.buttonPlayPrevious.Text = "<< Previous"; - this.buttonPlayPrevious.UseVisualStyleBackColor = true; - this.buttonPlayPrevious.Click += new System.EventHandler(this.buttonPlayPrevious_Click); - // - // buttonPlayCurrent - // - this.buttonPlayCurrent.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonPlayCurrent.Location = new System.Drawing.Point(288, 14); - this.buttonPlayCurrent.Name = "buttonPlayCurrent"; - this.buttonPlayCurrent.Size = new System.Drawing.Size(76, 23); - this.buttonPlayCurrent.TabIndex = 3; - this.buttonPlayCurrent.Text = "&Play current"; - this.buttonPlayCurrent.UseVisualStyleBackColor = true; - this.buttonPlayCurrent.Click += new System.EventHandler(this.ButtonPlayCurrentClick); - // - // buttonPlayNext - // - this.buttonPlayNext.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonPlayNext.Location = new System.Drawing.Point(369, 14); - this.buttonPlayNext.Name = "buttonPlayNext"; - this.buttonPlayNext.Size = new System.Drawing.Size(76, 23); - this.buttonPlayNext.TabIndex = 4; - this.buttonPlayNext.Text = "Next >>"; - this.buttonPlayNext.UseVisualStyleBackColor = true; - this.buttonPlayNext.Click += new System.EventHandler(this.buttonPlayNext_Click); - // - // tabPageCreate - // - this.tabPageCreate.Controls.Add(this.timeUpDownVideoPosition); - this.tabPageCreate.Controls.Add(this.buttonGotoSub); - this.tabPageCreate.Controls.Add(this.buttonBeforeText); - this.tabPageCreate.Controls.Add(this.buttonSetEnd); - this.tabPageCreate.Controls.Add(this.buttonInsertNewText); - this.tabPageCreate.Controls.Add(this.buttonSetStartTime); - this.tabPageCreate.Controls.Add(this.labelCreateF12); - this.tabPageCreate.Controls.Add(this.labelCreateF11); - this.tabPageCreate.Controls.Add(this.labelCreateF10); - this.tabPageCreate.Controls.Add(this.labelCreateF9); - this.tabPageCreate.Controls.Add(this.buttonForward2); - this.tabPageCreate.Controls.Add(this.numericUpDownSec2); - this.tabPageCreate.Controls.Add(this.buttonSecBack2); - this.tabPageCreate.Controls.Add(this.buttonForward1); - this.tabPageCreate.Controls.Add(this.numericUpDownSec1); - this.tabPageCreate.Controls.Add(this.labelVideoPosition); - this.tabPageCreate.Controls.Add(this.buttonSecBack1); - this.tabPageCreate.Location = new System.Drawing.Point(4, 22); - this.tabPageCreate.Name = "tabPageCreate"; - this.tabPageCreate.Padding = new System.Windows.Forms.Padding(3); - this.tabPageCreate.Size = new System.Drawing.Size(459, 257); - this.tabPageCreate.TabIndex = 1; - this.tabPageCreate.Text = "Create"; - this.tabPageCreate.UseVisualStyleBackColor = true; - // - // timeUpDownVideoPosition - // - this.timeUpDownVideoPosition.AutoSize = true; - this.timeUpDownVideoPosition.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownVideoPosition.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); - this.timeUpDownVideoPosition.Location = new System.Drawing.Point(96, 191); - this.timeUpDownVideoPosition.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownVideoPosition.Name = "timeUpDownVideoPosition"; - this.timeUpDownVideoPosition.Size = new System.Drawing.Size(111, 27); - this.timeUpDownVideoPosition.TabIndex = 12; - timeCode4.Hours = 0; - timeCode4.Milliseconds = 0; - timeCode4.Minutes = 0; - timeCode4.Seconds = 0; - timeCode4.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode4.TotalMilliseconds = 0D; - timeCode4.TotalSeconds = 0D; - this.timeUpDownVideoPosition.TimeCode = timeCode4; - this.timeUpDownVideoPosition.UseVideoOffset = false; - // - // buttonGotoSub - // - this.buttonGotoSub.Location = new System.Drawing.Point(6, 58); - this.buttonGotoSub.Name = "buttonGotoSub"; - this.buttonGotoSub.Size = new System.Drawing.Size(180, 23); - this.buttonGotoSub.TabIndex = 2; - this.buttonGotoSub.Text = "Goto subposition and pause"; - this.buttonGotoSub.UseVisualStyleBackColor = true; - this.buttonGotoSub.Click += new System.EventHandler(this.buttonGotoSub_Click); - this.buttonGotoSub.MouseEnter += new System.EventHandler(this.buttonGotoSub_MouseEnter); - // - // buttonBeforeText - // - this.buttonBeforeText.Location = new System.Drawing.Point(6, 32); - this.buttonBeforeText.Name = "buttonBeforeText"; - this.buttonBeforeText.Size = new System.Drawing.Size(180, 23); - this.buttonBeforeText.TabIndex = 1; - this.buttonBeforeText.Text = "Play from just before &text"; - this.buttonBeforeText.UseVisualStyleBackColor = true; - this.buttonBeforeText.Click += new System.EventHandler(this.buttonBeforeText_Click); - this.buttonBeforeText.MouseEnter += new System.EventHandler(this.buttonBeforeText_MouseEnter); - // - // buttonSetEnd - // - this.buttonSetEnd.Location = new System.Drawing.Point(6, 110); - this.buttonSetEnd.Name = "buttonSetEnd"; - this.buttonSetEnd.Size = new System.Drawing.Size(180, 23); - this.buttonSetEnd.TabIndex = 4; - this.buttonSetEnd.Text = "Set &end time"; - this.buttonSetEnd.UseVisualStyleBackColor = true; - this.buttonSetEnd.Click += new System.EventHandler(this.ButtonSetEndClick); - this.buttonSetEnd.MouseEnter += new System.EventHandler(this.buttonSetEnd_MouseEnter); - // - // buttonInsertNewText - // - this.buttonInsertNewText.Location = new System.Drawing.Point(6, 6); - this.buttonInsertNewText.Name = "buttonInsertNewText"; - this.buttonInsertNewText.Size = new System.Drawing.Size(180, 23); - this.buttonInsertNewText.TabIndex = 0; - this.buttonInsertNewText.Text = "&Insert new subtitle at vpos"; - this.buttonInsertNewText.UseVisualStyleBackColor = true; - this.buttonInsertNewText.Click += new System.EventHandler(this.ButtonInsertNewTextClick); - this.buttonInsertNewText.MouseEnter += new System.EventHandler(this.buttonInsertNewText_MouseEnter); - // - // buttonSetStartTime - // - this.buttonSetStartTime.Location = new System.Drawing.Point(6, 84); - this.buttonSetStartTime.Name = "buttonSetStartTime"; - this.buttonSetStartTime.Size = new System.Drawing.Size(180, 23); - this.buttonSetStartTime.TabIndex = 3; - this.buttonSetStartTime.Text = "Set &start time"; - this.buttonSetStartTime.UseVisualStyleBackColor = true; - this.buttonSetStartTime.Click += new System.EventHandler(this.buttonSetStartTime_Click); - this.buttonSetStartTime.MouseEnter += new System.EventHandler(this.buttonSetStartTime_MouseEnter); - // - // labelCreateF12 - // - this.labelCreateF12.AutoSize = true; - this.labelCreateF12.ForeColor = System.Drawing.Color.Gray; - this.labelCreateF12.Location = new System.Drawing.Point(188, 114); - this.labelCreateF12.Name = "labelCreateF12"; - this.labelCreateF12.Size = new System.Drawing.Size(25, 13); - this.labelCreateF12.TabIndex = 65; - this.labelCreateF12.Text = "F12"; - // - // labelCreateF11 - // - this.labelCreateF11.AutoSize = true; - this.labelCreateF11.ForeColor = System.Drawing.Color.Gray; - this.labelCreateF11.Location = new System.Drawing.Point(188, 88); - this.labelCreateF11.Name = "labelCreateF11"; - this.labelCreateF11.Size = new System.Drawing.Size(25, 13); - this.labelCreateF11.TabIndex = 64; - this.labelCreateF11.Text = "F11"; - // - // labelCreateF10 - // - this.labelCreateF10.AutoSize = true; - this.labelCreateF10.ForeColor = System.Drawing.Color.Gray; - this.labelCreateF10.Location = new System.Drawing.Point(188, 36); - this.labelCreateF10.Name = "labelCreateF10"; - this.labelCreateF10.Size = new System.Drawing.Size(25, 13); - this.labelCreateF10.TabIndex = 63; - this.labelCreateF10.Text = "F10"; - // - // labelCreateF9 - // - this.labelCreateF9.AutoSize = true; - this.labelCreateF9.ForeColor = System.Drawing.Color.Gray; - this.labelCreateF9.Location = new System.Drawing.Point(188, 10); - this.labelCreateF9.Name = "labelCreateF9"; - this.labelCreateF9.Size = new System.Drawing.Size(19, 13); - this.labelCreateF9.TabIndex = 62; - this.labelCreateF9.Text = "F9"; - // - // buttonForward2 - // - this.buttonForward2.Location = new System.Drawing.Point(130, 163); - this.buttonForward2.Name = "buttonForward2"; - this.buttonForward2.Size = new System.Drawing.Size(56, 23); - this.buttonForward2.TabIndex = 10; - this.buttonForward2.Text = " >>"; - this.buttonForward2.UseVisualStyleBackColor = true; - this.buttonForward2.Click += new System.EventHandler(this.buttonForward2_Click); - // - // numericUpDownSec2 - // - this.numericUpDownSec2.DecimalPlaces = 3; - this.numericUpDownSec2.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownSec2.Location = new System.Drawing.Point(66, 164); - this.numericUpDownSec2.Maximum = new decimal(new int[] { - 60, - 0, - 0, - 0}); - this.numericUpDownSec2.Name = "numericUpDownSec2"; - this.numericUpDownSec2.Size = new System.Drawing.Size(58, 20); - this.numericUpDownSec2.TabIndex = 9; - this.numericUpDownSec2.Value = new decimal(new int[] { - 5000, - 0, - 0, - 196608}); - this.numericUpDownSec2.ValueChanged += new System.EventHandler(this.NumericUpDownSec2ValueChanged); - // - // buttonSecBack2 - // - this.buttonSecBack2.Location = new System.Drawing.Point(6, 163); - this.buttonSecBack2.Name = "buttonSecBack2"; - this.buttonSecBack2.Size = new System.Drawing.Size(56, 23); - this.buttonSecBack2.TabIndex = 8; - this.buttonSecBack2.Text = "<<"; - this.buttonSecBack2.UseVisualStyleBackColor = true; - this.buttonSecBack2.Click += new System.EventHandler(this.buttonSecBack2_Click); - // - // buttonForward1 - // - this.buttonForward1.Location = new System.Drawing.Point(130, 137); - this.buttonForward1.Name = "buttonForward1"; - this.buttonForward1.Size = new System.Drawing.Size(56, 23); - this.buttonForward1.TabIndex = 7; - this.buttonForward1.Text = ">>"; - this.buttonForward1.UseVisualStyleBackColor = true; - this.buttonForward1.Click += new System.EventHandler(this.buttonForward1_Click); - // - // numericUpDownSec1 - // - this.numericUpDownSec1.DecimalPlaces = 3; - this.numericUpDownSec1.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownSec1.Location = new System.Drawing.Point(66, 138); - this.numericUpDownSec1.Maximum = new decimal(new int[] { - 60, - 0, - 0, - 0}); - this.numericUpDownSec1.Name = "numericUpDownSec1"; - this.numericUpDownSec1.Size = new System.Drawing.Size(58, 20); - this.numericUpDownSec1.TabIndex = 6; - this.numericUpDownSec1.Value = new decimal(new int[] { - 500, - 0, - 0, - 196608}); - this.numericUpDownSec1.ValueChanged += new System.EventHandler(this.NumericUpDownSec1ValueChanged); - // - // labelVideoPosition - // - this.labelVideoPosition.AutoSize = true; - this.labelVideoPosition.Location = new System.Drawing.Point(6, 196); - this.labelVideoPosition.Name = "labelVideoPosition"; - this.labelVideoPosition.Size = new System.Drawing.Size(76, 13); - this.labelVideoPosition.TabIndex = 11; - this.labelVideoPosition.Text = "Video position:"; - this.labelVideoPosition.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // buttonSecBack1 - // - this.buttonSecBack1.Location = new System.Drawing.Point(6, 137); - this.buttonSecBack1.Name = "buttonSecBack1"; - this.buttonSecBack1.Size = new System.Drawing.Size(56, 23); - this.buttonSecBack1.TabIndex = 5; - this.buttonSecBack1.Text = "<<"; - this.buttonSecBack1.UseVisualStyleBackColor = true; - this.buttonSecBack1.Click += new System.EventHandler(this.buttonSecBack1_Click); - // - // tabPageAdjust - // - this.tabPageAdjust.Controls.Add(this.timeUpDownVideoPositionAdjust); - this.tabPageAdjust.Controls.Add(this.buttonAdjustSetEndTime); - this.tabPageAdjust.Controls.Add(this.buttonSetEndAndGoToNext); - this.tabPageAdjust.Controls.Add(this.buttonSetStartAndOffsetRest); - this.tabPageAdjust.Controls.Add(this.buttonAdjustSetStartTime); - this.tabPageAdjust.Controls.Add(this.labelAdjustF12); - this.tabPageAdjust.Controls.Add(this.labelAdjustF11); - this.tabPageAdjust.Controls.Add(this.labelAdjustF10); - this.tabPageAdjust.Controls.Add(this.labelAdjustF9); - this.tabPageAdjust.Controls.Add(this.buttonAdjustSecForward2); - this.tabPageAdjust.Controls.Add(this.numericUpDownSecAdjust2); - this.tabPageAdjust.Controls.Add(this.buttonAdjustSecBack2); - this.tabPageAdjust.Controls.Add(this.buttonAdjustSecForward1); - this.tabPageAdjust.Controls.Add(this.numericUpDownSecAdjust1); - this.tabPageAdjust.Controls.Add(this.buttonAdjustSecBack1); - this.tabPageAdjust.Controls.Add(this.labelVideoPosition2); - this.tabPageAdjust.Controls.Add(this.buttonAdjustGoToPosAndPause); - this.tabPageAdjust.Controls.Add(this.buttonAdjustPlayBefore); - this.tabPageAdjust.Location = new System.Drawing.Point(4, 22); - this.tabPageAdjust.Name = "tabPageAdjust"; - this.tabPageAdjust.Size = new System.Drawing.Size(459, 257); - this.tabPageAdjust.TabIndex = 2; - this.tabPageAdjust.Text = "Adjust"; - this.tabPageAdjust.UseVisualStyleBackColor = true; - // - // timeUpDownVideoPositionAdjust - // - this.timeUpDownVideoPositionAdjust.AutoSize = true; - this.timeUpDownVideoPositionAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownVideoPositionAdjust.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); - this.timeUpDownVideoPositionAdjust.Location = new System.Drawing.Point(96, 213); - this.timeUpDownVideoPositionAdjust.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownVideoPositionAdjust.Name = "timeUpDownVideoPositionAdjust"; - this.timeUpDownVideoPositionAdjust.Size = new System.Drawing.Size(111, 27); - this.timeUpDownVideoPositionAdjust.TabIndex = 13; - timeCode5.Hours = 0; - timeCode5.Milliseconds = 0; - timeCode5.Minutes = 0; - timeCode5.Seconds = 0; - timeCode5.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode5.TotalMilliseconds = 0D; - timeCode5.TotalSeconds = 0D; - this.timeUpDownVideoPositionAdjust.TimeCode = timeCode5; - this.timeUpDownVideoPositionAdjust.UseVideoOffset = false; - // - // buttonAdjustSetEndTime - // - this.buttonAdjustSetEndTime.Location = new System.Drawing.Point(6, 84); - this.buttonAdjustSetEndTime.Name = "buttonAdjustSetEndTime"; - this.buttonAdjustSetEndTime.Size = new System.Drawing.Size(180, 23); - this.buttonAdjustSetEndTime.TabIndex = 3; - this.buttonAdjustSetEndTime.Text = "Set end time"; - this.buttonAdjustSetEndTime.UseVisualStyleBackColor = true; - this.buttonAdjustSetEndTime.Click += new System.EventHandler(this.ButtonSetEndClick); - this.buttonAdjustSetEndTime.MouseEnter += new System.EventHandler(this.buttonAdjustSetEndTime_MouseEnter); - // - // buttonSetEndAndGoToNext - // - this.buttonSetEndAndGoToNext.Location = new System.Drawing.Point(6, 32); - this.buttonSetEndAndGoToNext.Name = "buttonSetEndAndGoToNext"; - this.buttonSetEndAndGoToNext.Size = new System.Drawing.Size(180, 23); - this.buttonSetEndAndGoToNext.TabIndex = 1; - this.buttonSetEndAndGoToNext.Text = "Set e&nd && goto next"; - this.buttonSetEndAndGoToNext.UseVisualStyleBackColor = true; - this.buttonSetEndAndGoToNext.Click += new System.EventHandler(this.ButtonSetEndAndGoToNextClick); - this.buttonSetEndAndGoToNext.MouseEnter += new System.EventHandler(this.buttonSetEndAndGoToNext_MouseEnter); - // - // buttonSetStartAndOffsetRest - // - this.buttonSetStartAndOffsetRest.Location = new System.Drawing.Point(6, 6); - this.buttonSetStartAndOffsetRest.Name = "buttonSetStartAndOffsetRest"; - this.buttonSetStartAndOffsetRest.Size = new System.Drawing.Size(180, 23); - this.buttonSetStartAndOffsetRest.TabIndex = 0; - this.buttonSetStartAndOffsetRest.Text = "Set sta&rt and offset the rest"; - this.buttonSetStartAndOffsetRest.UseVisualStyleBackColor = true; - this.buttonSetStartAndOffsetRest.Click += new System.EventHandler(this.ButtonSetStartAndOffsetRestClick); - this.buttonSetStartAndOffsetRest.MouseEnter += new System.EventHandler(this.buttonSetStartAndOffsetRest_MouseEnter); - // - // buttonAdjustSetStartTime - // - this.buttonAdjustSetStartTime.Location = new System.Drawing.Point(6, 58); - this.buttonAdjustSetStartTime.Name = "buttonAdjustSetStartTime"; - this.buttonAdjustSetStartTime.Size = new System.Drawing.Size(180, 23); - this.buttonAdjustSetStartTime.TabIndex = 2; - this.buttonAdjustSetStartTime.Text = "Set start time"; - this.buttonAdjustSetStartTime.UseVisualStyleBackColor = true; - this.buttonAdjustSetStartTime.Click += new System.EventHandler(this.buttonSetStartTime_Click); - this.buttonAdjustSetStartTime.MouseEnter += new System.EventHandler(this.buttonAdjustSetStartTime_MouseEnter); - // - // labelAdjustF12 - // - this.labelAdjustF12.AutoSize = true; - this.labelAdjustF12.ForeColor = System.Drawing.Color.Gray; - this.labelAdjustF12.Location = new System.Drawing.Point(188, 88); - this.labelAdjustF12.Name = "labelAdjustF12"; - this.labelAdjustF12.Size = new System.Drawing.Size(25, 13); - this.labelAdjustF12.TabIndex = 64; - this.labelAdjustF12.Text = "F12"; - // - // labelAdjustF11 - // - this.labelAdjustF11.AutoSize = true; - this.labelAdjustF11.ForeColor = System.Drawing.Color.Gray; - this.labelAdjustF11.Location = new System.Drawing.Point(188, 62); - this.labelAdjustF11.Name = "labelAdjustF11"; - this.labelAdjustF11.Size = new System.Drawing.Size(25, 13); - this.labelAdjustF11.TabIndex = 63; - this.labelAdjustF11.Text = "F11"; - // - // labelAdjustF10 - // - this.labelAdjustF10.AutoSize = true; - this.labelAdjustF10.ForeColor = System.Drawing.Color.Gray; - this.labelAdjustF10.Location = new System.Drawing.Point(188, 36); - this.labelAdjustF10.Name = "labelAdjustF10"; - this.labelAdjustF10.Size = new System.Drawing.Size(25, 13); - this.labelAdjustF10.TabIndex = 62; - this.labelAdjustF10.Text = "F10"; - // - // labelAdjustF9 - // - this.labelAdjustF9.AutoSize = true; - this.labelAdjustF9.ForeColor = System.Drawing.Color.Gray; - this.labelAdjustF9.Location = new System.Drawing.Point(188, 10); - this.labelAdjustF9.Name = "labelAdjustF9"; - this.labelAdjustF9.Size = new System.Drawing.Size(19, 13); - this.labelAdjustF9.TabIndex = 61; - this.labelAdjustF9.Text = "F9"; - // - // buttonAdjustSecForward2 - // - this.buttonAdjustSecForward2.Location = new System.Drawing.Point(130, 188); - this.buttonAdjustSecForward2.Name = "buttonAdjustSecForward2"; - this.buttonAdjustSecForward2.Size = new System.Drawing.Size(56, 23); - this.buttonAdjustSecForward2.TabIndex = 11; - this.buttonAdjustSecForward2.Text = ">>"; - this.buttonAdjustSecForward2.UseVisualStyleBackColor = true; - this.buttonAdjustSecForward2.Click += new System.EventHandler(this.buttonAdjustSecForward2_Click); - // - // numericUpDownSecAdjust2 - // - this.numericUpDownSecAdjust2.DecimalPlaces = 3; - this.numericUpDownSecAdjust2.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownSecAdjust2.Location = new System.Drawing.Point(66, 189); - this.numericUpDownSecAdjust2.Maximum = new decimal(new int[] { - 60, - 0, - 0, - 0}); - this.numericUpDownSecAdjust2.Name = "numericUpDownSecAdjust2"; - this.numericUpDownSecAdjust2.Size = new System.Drawing.Size(58, 20); - this.numericUpDownSecAdjust2.TabIndex = 10; - this.numericUpDownSecAdjust2.Value = new decimal(new int[] { - 5000, - 0, - 0, - 196608}); - this.numericUpDownSecAdjust2.ValueChanged += new System.EventHandler(this.NumericUpDownSecAdjust2ValueChanged); - // - // buttonAdjustSecBack2 - // - this.buttonAdjustSecBack2.Location = new System.Drawing.Point(6, 188); - this.buttonAdjustSecBack2.Name = "buttonAdjustSecBack2"; - this.buttonAdjustSecBack2.Size = new System.Drawing.Size(56, 23); - this.buttonAdjustSecBack2.TabIndex = 9; - this.buttonAdjustSecBack2.Text = "<<"; - this.buttonAdjustSecBack2.UseVisualStyleBackColor = true; - this.buttonAdjustSecBack2.Click += new System.EventHandler(this.buttonAdjustSecBack2_Click); - // - // buttonAdjustSecForward1 - // - this.buttonAdjustSecForward1.Location = new System.Drawing.Point(130, 162); - this.buttonAdjustSecForward1.Name = "buttonAdjustSecForward1"; - this.buttonAdjustSecForward1.Size = new System.Drawing.Size(56, 23); - this.buttonAdjustSecForward1.TabIndex = 8; - this.buttonAdjustSecForward1.Text = ">>"; - this.buttonAdjustSecForward1.UseVisualStyleBackColor = true; - this.buttonAdjustSecForward1.Click += new System.EventHandler(this.ButtonAdjustSecForwardClick); - // - // numericUpDownSecAdjust1 - // - this.numericUpDownSecAdjust1.DecimalPlaces = 3; - this.numericUpDownSecAdjust1.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownSecAdjust1.Location = new System.Drawing.Point(66, 163); - this.numericUpDownSecAdjust1.Maximum = new decimal(new int[] { - 60, - 0, - 0, - 0}); - this.numericUpDownSecAdjust1.Name = "numericUpDownSecAdjust1"; - this.numericUpDownSecAdjust1.Size = new System.Drawing.Size(58, 20); - this.numericUpDownSecAdjust1.TabIndex = 7; - this.numericUpDownSecAdjust1.Value = new decimal(new int[] { - 500, - 0, - 0, - 196608}); - this.numericUpDownSecAdjust1.ValueChanged += new System.EventHandler(this.NumericUpDownSecAdjust1ValueChanged); - // - // buttonAdjustSecBack1 - // - this.buttonAdjustSecBack1.Location = new System.Drawing.Point(6, 162); - this.buttonAdjustSecBack1.Name = "buttonAdjustSecBack1"; - this.buttonAdjustSecBack1.Size = new System.Drawing.Size(56, 23); - this.buttonAdjustSecBack1.TabIndex = 6; - this.buttonAdjustSecBack1.Text = "<<"; - this.buttonAdjustSecBack1.UseVisualStyleBackColor = true; - this.buttonAdjustSecBack1.Click += new System.EventHandler(this.ButtonAdjustSecBackClick); - // - // labelVideoPosition2 - // - this.labelVideoPosition2.AutoSize = true; - this.labelVideoPosition2.Location = new System.Drawing.Point(6, 219); - this.labelVideoPosition2.Name = "labelVideoPosition2"; - this.labelVideoPosition2.Size = new System.Drawing.Size(76, 13); - this.labelVideoPosition2.TabIndex = 12; - this.labelVideoPosition2.Text = "Video position:"; - this.labelVideoPosition2.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // buttonAdjustGoToPosAndPause - // - this.buttonAdjustGoToPosAndPause.Location = new System.Drawing.Point(6, 136); - this.buttonAdjustGoToPosAndPause.Name = "buttonAdjustGoToPosAndPause"; - this.buttonAdjustGoToPosAndPause.Size = new System.Drawing.Size(180, 23); - this.buttonAdjustGoToPosAndPause.TabIndex = 5; - this.buttonAdjustGoToPosAndPause.Text = "&Goto subposition and pause"; - this.buttonAdjustGoToPosAndPause.UseVisualStyleBackColor = true; - this.buttonAdjustGoToPosAndPause.Click += new System.EventHandler(this.buttonGotoSub_Click); - this.buttonAdjustGoToPosAndPause.MouseEnter += new System.EventHandler(this.buttonAdjustGoToPosAndPause_MouseEnter); - // - // buttonAdjustPlayBefore - // - this.buttonAdjustPlayBefore.Location = new System.Drawing.Point(6, 110); - this.buttonAdjustPlayBefore.Name = "buttonAdjustPlayBefore"; - this.buttonAdjustPlayBefore.Size = new System.Drawing.Size(180, 23); - this.buttonAdjustPlayBefore.TabIndex = 4; - this.buttonAdjustPlayBefore.Text = "&Play from just before text"; - this.buttonAdjustPlayBefore.UseVisualStyleBackColor = true; - this.buttonAdjustPlayBefore.Click += new System.EventHandler(this.buttonBeforeText_Click); - this.buttonAdjustPlayBefore.MouseEnter += new System.EventHandler(this.buttonAdjustPlayBefore_MouseEnter); - // - // ShowSubtitleTimer - // - this.ShowSubtitleTimer.Enabled = true; - this.ShowSubtitleTimer.Interval = 17; - this.ShowSubtitleTimer.Tick += new System.EventHandler(this.ShowSubtitleTimerTick); - // - // timerAutoDuration - // - this.timerAutoDuration.Interval = 300; - this.timerAutoDuration.Tick += new System.EventHandler(this.timerAutoDuration_Tick); - // - // timerAutoContinue - // - this.timerAutoContinue.Interval = 1000; - this.timerAutoContinue.Tick += new System.EventHandler(this.timerAutoContinue_Tick); - // - // timerStillTyping - // - this.timerStillTyping.Interval = 1500; - this.timerStillTyping.Tick += new System.EventHandler(this.timerStillTyping_Tick); - // - // timerWaveform - // - this.timerWaveform.Tick += new System.EventHandler(this.timerWaveform_Tick); - // - // contextMenuStripWaveform - // - this.contextMenuStripWaveform.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.addParagraphHereToolStripMenuItem, - this.addParagraphAndPasteToolStripMenuItem, - this.toolStripMenuItemSetParagraphAsSelection, - this.toolStripMenuItemFocusTextbox, - this.goToPreviousSubtitleStripMenuItem, - this.goToNextSubtitleStripMenuItem, - this.deleteParagraphToolStripMenuItem, - this.splitToolStripMenuItem1, - this.mergeWithPreviousToolStripMenuItem, - this.mergeWithNextToolStripMenuItem, - this.toolStripSeparator11, - this.extendToPreviousToolStripMenuItem, - this.extendToNextToolStripMenuItem, - this.toolStripSeparator6, - this.toolStripMenuItemWaveformPlaySelection, - this.toolStripSeparator24, - this.showWaveformAndSpectrogramToolStripMenuItem, - this.showOnlyWaveformToolStripMenuItem, - this.showOnlySpectrogramToolStripMenuItem, - this.toolStripSeparatorGuessTimeCodes, - this.removeSceneChangeToolStripMenuItem, - this.addSceneChangeToolStripMenuItem, - this.guessTimeCodesToolStripMenuItem, - this.seekSilenceToolStripMenuItem, - this.insertSubtitleHereToolStripMenuItem}); - this.contextMenuStripWaveform.Name = "contextMenuStripWaveform"; - this.contextMenuStripWaveform.Size = new System.Drawing.Size(275, 490); - this.contextMenuStripWaveform.Closing += new System.Windows.Forms.ToolStripDropDownClosingEventHandler(this.contextMenuStripWaveform_Closing); - this.contextMenuStripWaveform.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripWaveformOpening); - // - // addParagraphHereToolStripMenuItem - // - this.addParagraphHereToolStripMenuItem.Name = "addParagraphHereToolStripMenuItem"; - this.addParagraphHereToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.addParagraphHereToolStripMenuItem.Text = "Add paragraph here"; - this.addParagraphHereToolStripMenuItem.Click += new System.EventHandler(this.addParagraphHereToolStripMenuItem_Click); - // - // addParagraphAndPasteToolStripMenuItem - // - this.addParagraphAndPasteToolStripMenuItem.Name = "addParagraphAndPasteToolStripMenuItem"; - this.addParagraphAndPasteToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.addParagraphAndPasteToolStripMenuItem.Text = "Add paragraph here + paste clipboard"; - this.addParagraphAndPasteToolStripMenuItem.Click += new System.EventHandler(this.addParagraphAndPasteToolStripMenuItem_Click); - // - // toolStripMenuItemSetParagraphAsSelection - // - this.toolStripMenuItemSetParagraphAsSelection.Name = "toolStripMenuItemSetParagraphAsSelection"; - this.toolStripMenuItemSetParagraphAsSelection.Size = new System.Drawing.Size(274, 22); - this.toolStripMenuItemSetParagraphAsSelection.Text = "Set selected paragraph as selection"; - this.toolStripMenuItemSetParagraphAsSelection.Click += new System.EventHandler(this.toolStripMenuItemSetParagraphAsSelection_Click); - // - // toolStripMenuItemFocusTextbox - // - this.toolStripMenuItemFocusTextbox.Name = "toolStripMenuItemFocusTextbox"; - this.toolStripMenuItemFocusTextbox.Size = new System.Drawing.Size(274, 22); - this.toolStripMenuItemFocusTextbox.Text = "Focus textbox"; - this.toolStripMenuItemFocusTextbox.Click += new System.EventHandler(this.toolStripMenuItemFocusTextbox_Click); - // - // goToPreviousSubtitleStripMenuItem - // - this.goToPreviousSubtitleStripMenuItem.Name = "goToPreviousSubtitleStripMenuItem"; - this.goToPreviousSubtitleStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.goToPreviousSubtitleStripMenuItem.Text = "Go to previous subtitle"; - this.goToPreviousSubtitleStripMenuItem.Click += new System.EventHandler(this.goToPreviousSubtitleToolStripMenuItem_Click); - // - // goToNextSubtitleStripMenuItem - // - this.goToNextSubtitleStripMenuItem.Name = "goToNextSubtitleStripMenuItem"; - this.goToNextSubtitleStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.goToNextSubtitleStripMenuItem.Text = "Go to next subtitle"; - this.goToNextSubtitleStripMenuItem.Click += new System.EventHandler(this.goToNextSubtitleToolStripMenuItem_Click); - // - // deleteParagraphToolStripMenuItem - // - this.deleteParagraphToolStripMenuItem.Name = "deleteParagraphToolStripMenuItem"; - this.deleteParagraphToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.deleteParagraphToolStripMenuItem.Text = "Delete paragraph"; - this.deleteParagraphToolStripMenuItem.Click += new System.EventHandler(this.deleteParagraphToolStripMenuItem_Click); - // - // splitToolStripMenuItem1 - // - this.splitToolStripMenuItem1.Name = "splitToolStripMenuItem1"; - this.splitToolStripMenuItem1.Size = new System.Drawing.Size(274, 22); - this.splitToolStripMenuItem1.Text = "Split"; - this.splitToolStripMenuItem1.Click += new System.EventHandler(this.splitToolStripMenuItem1_Click); - // - // mergeWithPreviousToolStripMenuItem - // - this.mergeWithPreviousToolStripMenuItem.Name = "mergeWithPreviousToolStripMenuItem"; - this.mergeWithPreviousToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.mergeWithPreviousToolStripMenuItem.Text = "Merge with previous"; - this.mergeWithPreviousToolStripMenuItem.Click += new System.EventHandler(this.mergeWithPreviousToolStripMenuItem_Click); - // - // mergeWithNextToolStripMenuItem - // - this.mergeWithNextToolStripMenuItem.Name = "mergeWithNextToolStripMenuItem"; - this.mergeWithNextToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.mergeWithNextToolStripMenuItem.Text = "Merge with next"; - this.mergeWithNextToolStripMenuItem.Click += new System.EventHandler(this.mergeWithNextToolStripMenuItem_Click); - // - // toolStripSeparator11 - // - this.toolStripSeparator11.Name = "toolStripSeparator11"; - this.toolStripSeparator11.Size = new System.Drawing.Size(271, 6); - // - // extendToPreviousToolStripMenuItem - // - this.extendToPreviousToolStripMenuItem.Name = "extendToPreviousToolStripMenuItem"; - this.extendToPreviousToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.extendToPreviousToolStripMenuItem.Text = "Extend to previous"; - this.extendToPreviousToolStripMenuItem.Click += new System.EventHandler(this.extendToPreviousToolStripMenuItem_Click); - // - // extendToNextToolStripMenuItem - // - this.extendToNextToolStripMenuItem.Name = "extendToNextToolStripMenuItem"; - this.extendToNextToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.extendToNextToolStripMenuItem.Text = "Extend to next"; - this.extendToNextToolStripMenuItem.Click += new System.EventHandler(this.extendToNextToolStripMenuItem_Click); - // - // toolStripSeparator6 - // - this.toolStripSeparator6.Name = "toolStripSeparator6"; - this.toolStripSeparator6.Size = new System.Drawing.Size(271, 6); - // - // toolStripMenuItemWaveformPlaySelection - // - this.toolStripMenuItemWaveformPlaySelection.Name = "toolStripMenuItemWaveformPlaySelection"; - this.toolStripMenuItemWaveformPlaySelection.Size = new System.Drawing.Size(274, 22); - this.toolStripMenuItemWaveformPlaySelection.Text = "Play selection"; - this.toolStripMenuItemWaveformPlaySelection.Click += new System.EventHandler(this.toolStripMenuItemWaveformPlaySelection_Click); - // - // toolStripSeparator24 - // - this.toolStripSeparator24.Name = "toolStripSeparator24"; - this.toolStripSeparator24.Size = new System.Drawing.Size(271, 6); - // - // showWaveformAndSpectrogramToolStripMenuItem - // - this.showWaveformAndSpectrogramToolStripMenuItem.Name = "showWaveformAndSpectrogramToolStripMenuItem"; - this.showWaveformAndSpectrogramToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.showWaveformAndSpectrogramToolStripMenuItem.Text = "Show waveform and spectrogram"; - this.showWaveformAndSpectrogramToolStripMenuItem.Click += new System.EventHandler(this.ShowWaveformAndSpectrogramToolStripMenuItemClick); - // - // showOnlyWaveformToolStripMenuItem - // - this.showOnlyWaveformToolStripMenuItem.Name = "showOnlyWaveformToolStripMenuItem"; - this.showOnlyWaveformToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.showOnlyWaveformToolStripMenuItem.Text = "Show only waveform"; - this.showOnlyWaveformToolStripMenuItem.Click += new System.EventHandler(this.ShowOnlyWaveformToolStripMenuItemClick); - // - // showOnlySpectrogramToolStripMenuItem - // - this.showOnlySpectrogramToolStripMenuItem.Name = "showOnlySpectrogramToolStripMenuItem"; - this.showOnlySpectrogramToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.showOnlySpectrogramToolStripMenuItem.Text = "Show only spectrogram"; - this.showOnlySpectrogramToolStripMenuItem.Click += new System.EventHandler(this.ShowOnlySpectrogramToolStripMenuItemClick); - // - // toolStripSeparatorGuessTimeCodes - // - this.toolStripSeparatorGuessTimeCodes.Name = "toolStripSeparatorGuessTimeCodes"; - this.toolStripSeparatorGuessTimeCodes.Size = new System.Drawing.Size(271, 6); - // - // removeSceneChangeToolStripMenuItem - // - this.removeSceneChangeToolStripMenuItem.Name = "removeSceneChangeToolStripMenuItem"; - this.removeSceneChangeToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.removeSceneChangeToolStripMenuItem.Text = "Remove scene change"; - this.removeSceneChangeToolStripMenuItem.Click += new System.EventHandler(this.removeSceneChangeToolStripMenuItem_Click); - // - // addSceneChangeToolStripMenuItem - // - this.addSceneChangeToolStripMenuItem.Name = "addSceneChangeToolStripMenuItem"; - this.addSceneChangeToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.addSceneChangeToolStripMenuItem.Text = "Add scene change"; - this.addSceneChangeToolStripMenuItem.Click += new System.EventHandler(this.addSceneChangeToolStripMenuItem_Click); - // - // guessTimeCodesToolStripMenuItem - // - this.guessTimeCodesToolStripMenuItem.Name = "guessTimeCodesToolStripMenuItem"; - this.guessTimeCodesToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.guessTimeCodesToolStripMenuItem.Text = "Guess time codes..."; - this.guessTimeCodesToolStripMenuItem.Click += new System.EventHandler(this.GuessTimeCodesToolStripMenuItemClick); - // - // seekSilenceToolStripMenuItem - // - this.seekSilenceToolStripMenuItem.Name = "seekSilenceToolStripMenuItem"; - this.seekSilenceToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.seekSilenceToolStripMenuItem.Text = "Seek silence..."; - this.seekSilenceToolStripMenuItem.Click += new System.EventHandler(this.seekSilenceToolStripMenuItem_Click); - // - // insertSubtitleHereToolStripMenuItem - // - this.insertSubtitleHereToolStripMenuItem.Name = "insertSubtitleHereToolStripMenuItem"; - this.insertSubtitleHereToolStripMenuItem.Size = new System.Drawing.Size(274, 22); - this.insertSubtitleHereToolStripMenuItem.Text = "Insert subtitle here..."; - this.insertSubtitleHereToolStripMenuItem.Click += new System.EventHandler(this.insertSubtitleHereToolStripMenuItem_Click); - // - // splitContainerMain - // - this.splitContainerMain.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainerMain.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; - this.splitContainerMain.Location = new System.Drawing.Point(0, 64); - this.splitContainerMain.Name = "splitContainerMain"; - this.splitContainerMain.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainerMain.Panel1 - // - this.splitContainerMain.Panel1.Controls.Add(this.splitContainer1); - // - // splitContainerMain.Panel2 - // - this.splitContainerMain.Panel2.Controls.Add(this.groupBoxVideo); - this.splitContainerMain.Size = new System.Drawing.Size(975, 560); - this.splitContainerMain.SplitterDistance = 251; - this.splitContainerMain.TabIndex = 8; - this.splitContainerMain.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.SplitContainerMainSplitterMoved); - // - // splitContainer1 - // - this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.Location = new System.Drawing.Point(0, 0); - this.splitContainer1.Name = "splitContainer1"; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.tabControlSubtitle); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.panelVideoPlayer); - this.splitContainer1.Size = new System.Drawing.Size(975, 251); - this.splitContainer1.SplitterDistance = 743; - this.splitContainer1.TabIndex = 7; - this.splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.SplitContainer1SplitterMoved); - // - // tabControlSubtitle - // - this.tabControlSubtitle.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tabControlSubtitle.Controls.Add(this.tabPage1); - this.tabControlSubtitle.Controls.Add(this.tabPage2); - this.tabControlSubtitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tabControlSubtitle.Location = new System.Drawing.Point(3, 3); - this.tabControlSubtitle.Name = "tabControlSubtitle"; - this.tabControlSubtitle.SelectedIndex = 0; - this.tabControlSubtitle.Size = new System.Drawing.Size(738, 248); - this.tabControlSubtitle.TabIndex = 0; - this.tabControlSubtitle.SelectedIndexChanged += new System.EventHandler(this.TabControlSubtitleSelectedIndexChanged); - this.tabControlSubtitle.Selecting += new System.Windows.Forms.TabControlCancelEventHandler(this.TabControlSubtitleSelecting); - // - // tabPage1 - // - this.tabPage1.Controls.Add(this.splitContainerListViewAndText); - this.tabPage1.Location = new System.Drawing.Point(4, 22); - this.tabPage1.Name = "tabPage1"; - this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(730, 222); - this.tabPage1.TabIndex = 0; - this.tabPage1.Text = "List view"; - this.tabPage1.UseVisualStyleBackColor = true; - // - // splitContainerListViewAndText - // - this.splitContainerListViewAndText.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainerListViewAndText.Location = new System.Drawing.Point(3, 3); - this.splitContainerListViewAndText.Name = "splitContainerListViewAndText"; - this.splitContainerListViewAndText.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainerListViewAndText.Panel1 - // - this.splitContainerListViewAndText.Panel1.Controls.Add(this.SubtitleListview1); - this.splitContainerListViewAndText.Panel1MinSize = 50; - // - // splitContainerListViewAndText.Panel2 - // - this.splitContainerListViewAndText.Panel2.Controls.Add(this.groupBoxEdit); - this.splitContainerListViewAndText.Panel2MinSize = 105; - this.splitContainerListViewAndText.Size = new System.Drawing.Size(724, 216); - this.splitContainerListViewAndText.SplitterDistance = 91; - this.splitContainerListViewAndText.TabIndex = 2; - // - // SubtitleListview1 - // - this.SubtitleListview1.AllowColumnReorder = true; - this.SubtitleListview1.AllowDrop = true; - this.SubtitleListview1.ContextMenuStrip = this.contextMenuStripListview; - this.SubtitleListview1.Dock = System.Windows.Forms.DockStyle.Fill; - this.SubtitleListview1.FirstVisibleIndex = -1; - this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.SubtitleListview1.FullRowSelect = true; - this.SubtitleListview1.GridLines = true; - this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.SubtitleListview1.HideSelection = false; - this.SubtitleListview1.Location = new System.Drawing.Point(0, 0); - this.SubtitleListview1.Name = "SubtitleListview1"; - this.SubtitleListview1.OwnerDraw = true; - this.SubtitleListview1.Size = new System.Drawing.Size(724, 91); - this.SubtitleListview1.StateImageList = this.imageListBookmarks; - this.SubtitleListview1.SubtitleFontBold = false; - this.SubtitleListview1.SubtitleFontName = "Tahoma"; - this.SubtitleListview1.SubtitleFontSize = 8; - this.SubtitleListview1.TabIndex = 0; - this.SubtitleListview1.UseCompatibleStateImageBehavior = false; - this.SubtitleListview1.UseSyntaxColoring = true; - this.SubtitleListview1.View = System.Windows.Forms.View.Details; - this.SubtitleListview1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListview1_SelectedIndexChanged); - this.SubtitleListview1.DragDrop += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragDrop); - this.SubtitleListview1.DragEnter += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragEnter); - this.SubtitleListview1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SubtitleListview1KeyDown); - this.SubtitleListview1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListview1_MouseDoubleClick); - this.SubtitleListview1.MouseEnter += new System.EventHandler(this.SubtitleListview1_MouseEnter); - // - // imageListBookmarks - // - this.imageListBookmarks.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; - this.imageListBookmarks.ImageSize = new System.Drawing.Size(16, 16); - this.imageListBookmarks.TransparentColor = System.Drawing.Color.Transparent; - // - // groupBoxEdit - // - this.groupBoxEdit.Controls.Add(this.labelAlternateSingleLinePixels); - this.groupBoxEdit.Controls.Add(this.labelSingleLinePixels); - this.groupBoxEdit.Controls.Add(this.panelBookmark); - this.groupBoxEdit.Controls.Add(this.pictureBoxBookmark); - this.groupBoxEdit.Controls.Add(this.labelSingleLine); - this.groupBoxEdit.Controls.Add(this.labelAlternateSingleLine); - this.groupBoxEdit.Controls.Add(this.labelDurationWarning); - this.groupBoxEdit.Controls.Add(this.labelStartTimeWarning); - this.groupBoxEdit.Controls.Add(this.buttonSplitLine); - this.groupBoxEdit.Controls.Add(this.labelAlternateCharactersPerSecond); - this.groupBoxEdit.Controls.Add(this.labelTextAlternateLineTotal); - this.groupBoxEdit.Controls.Add(this.labelTextAlternateLineLengths); - this.groupBoxEdit.Controls.Add(this.labelAlternateText); - this.groupBoxEdit.Controls.Add(this.labelText); - this.groupBoxEdit.Controls.Add(this.textBoxListViewTextAlternate); - this.groupBoxEdit.Controls.Add(this.buttonAutoBreak); - this.groupBoxEdit.Controls.Add(this.labelTextLineLengths); - this.groupBoxEdit.Controls.Add(this.labelTextLineTotal); - this.groupBoxEdit.Controls.Add(this.labelCharactersPerSecond); - this.groupBoxEdit.Controls.Add(this.buttonUnBreak); - this.groupBoxEdit.Controls.Add(this.timeUpDownStartTime); - this.groupBoxEdit.Controls.Add(this.numericUpDownDuration); - this.groupBoxEdit.Controls.Add(this.buttonPrevious); - this.groupBoxEdit.Controls.Add(this.buttonNext); - this.groupBoxEdit.Controls.Add(this.labelStartTime); - this.groupBoxEdit.Controls.Add(this.textBoxListViewText); - this.groupBoxEdit.Controls.Add(this.labelDuration); - this.groupBoxEdit.Controls.Add(this.labelAutoDuration); - this.groupBoxEdit.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBoxEdit.Location = new System.Drawing.Point(0, 0); - this.groupBoxEdit.Name = "groupBoxEdit"; - this.groupBoxEdit.Size = new System.Drawing.Size(724, 121); - this.groupBoxEdit.TabIndex = 1; - this.groupBoxEdit.TabStop = false; - // - // labelAlternateSingleLinePixels - // - this.labelAlternateSingleLinePixels.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelAlternateSingleLinePixels.AutoSize = true; - this.labelAlternateSingleLinePixels.Location = new System.Drawing.Point(870, 94); - this.labelAlternateSingleLinePixels.Name = "labelAlternateSingleLinePixels"; - this.labelAlternateSingleLinePixels.Size = new System.Drawing.Size(62, 13); - this.labelAlternateSingleLinePixels.TabIndex = 43; - this.labelAlternateSingleLinePixels.Text = "AltSinLinPix"; - // - // labelSingleLinePixels - // - this.labelSingleLinePixels.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelSingleLinePixels.AutoSize = true; - this.labelSingleLinePixels.Location = new System.Drawing.Point(427, 94); - this.labelSingleLinePixels.Name = "labelSingleLinePixels"; - this.labelSingleLinePixels.Size = new System.Drawing.Size(105, 13); - this.labelSingleLinePixels.TabIndex = 42; - this.labelSingleLinePixels.Text = "labelSingleLinePixels"; - // - // panelBookmark - // - this.panelBookmark.BackColor = System.Drawing.Color.LemonChiffon; - this.panelBookmark.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelBookmark.Controls.Add(this.labelBookmark); - this.panelBookmark.Location = new System.Drawing.Point(207, 38); - this.panelBookmark.Name = "panelBookmark"; - this.panelBookmark.Size = new System.Drawing.Size(200, 25); - this.panelBookmark.TabIndex = 40; - this.panelBookmark.Visible = false; - // - // labelBookmark - // - this.labelBookmark.AutoSize = true; - this.labelBookmark.Location = new System.Drawing.Point(4, 4); - this.labelBookmark.Name = "labelBookmark"; - this.labelBookmark.Size = new System.Drawing.Size(77, 13); - this.labelBookmark.TabIndex = 0; - this.labelBookmark.Text = "labelBookmark"; - this.labelBookmark.DoubleClick += new System.EventHandler(this.labelBookmark_DoubleClick); - // - // pictureBoxBookmark - // - this.pictureBoxBookmark.Image = global::Nikse.SubtitleEdit.Properties.Resources.bookmark22; - this.pictureBoxBookmark.Location = new System.Drawing.Point(211, 28); - this.pictureBoxBookmark.Name = "pictureBoxBookmark"; - this.pictureBoxBookmark.Size = new System.Drawing.Size(22, 22); - this.pictureBoxBookmark.TabIndex = 41; - this.pictureBoxBookmark.TabStop = false; - this.pictureBoxBookmark.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBoxBookmark_MouseClick); - this.pictureBoxBookmark.MouseEnter += new System.EventHandler(this.pictureBoxBookmark_MouseEnter); - // - // labelSingleLine - // - this.labelSingleLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelSingleLine.AutoSize = true; - this.labelSingleLine.Location = new System.Drawing.Point(346, 94); - this.labelSingleLine.Name = "labelSingleLine"; - this.labelSingleLine.Size = new System.Drawing.Size(78, 13); - this.labelSingleLine.TabIndex = 32; - this.labelSingleLine.Text = "labelSingleLine"; - // - // labelAlternateSingleLine - // - this.labelAlternateSingleLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelAlternateSingleLine.AutoSize = true; - this.labelAlternateSingleLine.Location = new System.Drawing.Point(839, 94); - this.labelAlternateSingleLine.Name = "labelAlternateSingleLine"; - this.labelAlternateSingleLine.Size = new System.Drawing.Size(48, 13); - this.labelAlternateSingleLine.TabIndex = 36; - this.labelAlternateSingleLine.Text = "AltSinLin"; - // - // labelDurationWarning - // - this.labelDurationWarning.AutoSize = true; - this.labelDurationWarning.ForeColor = System.Drawing.Color.Red; - this.labelDurationWarning.Location = new System.Drawing.Point(122, 64); - this.labelDurationWarning.Name = "labelDurationWarning"; - this.labelDurationWarning.Size = new System.Drawing.Size(109, 13); - this.labelDurationWarning.TabIndex = 17; - this.labelDurationWarning.Text = "labelDurationWarning"; - // - // labelStartTimeWarning - // - this.labelStartTimeWarning.AutoSize = true; - this.labelStartTimeWarning.ForeColor = System.Drawing.Color.Red; - this.labelStartTimeWarning.Location = new System.Drawing.Point(8, 50); - this.labelStartTimeWarning.Name = "labelStartTimeWarning"; - this.labelStartTimeWarning.Size = new System.Drawing.Size(114, 13); - this.labelStartTimeWarning.TabIndex = 18; - this.labelStartTimeWarning.Text = "labelStartTimeWarning"; - // - // buttonSplitLine - // - this.buttonSplitLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSplitLine.ForeColor = System.Drawing.Color.Red; - this.buttonSplitLine.Location = new System.Drawing.Point(604, 80); - this.buttonSplitLine.Name = "buttonSplitLine"; - this.buttonSplitLine.Size = new System.Drawing.Size(115, 23); - this.buttonSplitLine.TabIndex = 39; - this.buttonSplitLine.Text = "Split line"; - this.buttonSplitLine.UseVisualStyleBackColor = true; - this.buttonSplitLine.Visible = false; - this.buttonSplitLine.Click += new System.EventHandler(this.ButtonSplitLineClick); - // - // labelAlternateCharactersPerSecond - // - this.labelAlternateCharactersPerSecond.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelAlternateCharactersPerSecond.AutoSize = true; - this.labelAlternateCharactersPerSecond.Location = new System.Drawing.Point(636, 11); - this.labelAlternateCharactersPerSecond.Name = "labelAlternateCharactersPerSecond"; - this.labelAlternateCharactersPerSecond.Size = new System.Drawing.Size(64, 13); - this.labelAlternateCharactersPerSecond.TabIndex = 38; - this.labelAlternateCharactersPerSecond.Text = "altCharsSec"; - // - // labelTextAlternateLineTotal - // - this.labelTextAlternateLineTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.labelTextAlternateLineTotal.AutoSize = true; - this.labelTextAlternateLineTotal.Location = new System.Drawing.Point(682, 94); - this.labelTextAlternateLineTotal.Name = "labelTextAlternateLineTotal"; - this.labelTextAlternateLineTotal.Size = new System.Drawing.Size(35, 13); - this.labelTextAlternateLineTotal.TabIndex = 37; - this.labelTextAlternateLineTotal.Text = "AltTot"; - // - // labelTextAlternateLineLengths - // - this.labelTextAlternateLineLengths.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelTextAlternateLineLengths.AutoSize = true; - this.labelTextAlternateLineLengths.Location = new System.Drawing.Point(786, 94); - this.labelTextAlternateLineLengths.Name = "labelTextAlternateLineLengths"; - this.labelTextAlternateLineLengths.Size = new System.Drawing.Size(57, 13); - this.labelTextAlternateLineLengths.TabIndex = 35; - this.labelTextAlternateLineLengths.Text = "AltLineLen"; - // - // labelAlternateText - // - this.labelAlternateText.AutoSize = true; - this.labelAlternateText.Location = new System.Drawing.Point(803, 11); - this.labelAlternateText.Name = "labelAlternateText"; - this.labelAlternateText.Size = new System.Drawing.Size(28, 13); - this.labelAlternateText.TabIndex = 34; - this.labelAlternateText.Text = "Text"; - this.labelAlternateText.Visible = false; - // - // labelText - // - this.labelText.AutoSize = true; - this.labelText.Location = new System.Drawing.Point(239, 11); - this.labelText.Name = "labelText"; - this.labelText.Size = new System.Drawing.Size(28, 13); - this.labelText.TabIndex = 5; - this.labelText.Text = "Text"; - // - // textBoxListViewTextAlternate - // - this.textBoxListViewTextAlternate.AllowDrop = true; - this.textBoxListViewTextAlternate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxListViewTextAlternate.ContextMenuStrip = this.contextMenuStripTextBoxListView; - this.textBoxListViewTextAlternate.Enabled = false; - this.textBoxListViewTextAlternate.HideSelection = false; - this.textBoxListViewTextAlternate.Location = new System.Drawing.Point(946, 28); - this.textBoxListViewTextAlternate.Multiline = true; - this.textBoxListViewTextAlternate.Name = "textBoxListViewTextAlternate"; - this.textBoxListViewTextAlternate.Size = new System.Drawing.Size(0, 63); - this.textBoxListViewTextAlternate.TabIndex = 33; - this.textBoxListViewTextAlternate.Visible = false; - this.textBoxListViewTextAlternate.MouseClick += new System.Windows.Forms.MouseEventHandler(this.TextBoxListViewTextAlternateMouseClick); - this.textBoxListViewTextAlternate.TextChanged += new System.EventHandler(this.textBoxListViewTextAlternate_TextChanged); - this.textBoxListViewTextAlternate.Enter += new System.EventHandler(this.TextBoxListViewTextAlternateEnter); - this.textBoxListViewTextAlternate.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxListViewTextAlternateKeyDown); - this.textBoxListViewTextAlternate.KeyUp += new System.Windows.Forms.KeyEventHandler(this.TextBoxListViewTextAlternateKeyUp); - this.textBoxListViewTextAlternate.MouseMove += new System.Windows.Forms.MouseEventHandler(this.TextBoxListViewTextAlternateMouseMove); - // - // contextMenuStripTextBoxListView - // - this.contextMenuStripTextBoxListView.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemWebVttVoice, - this.toolStripSeparatorWebVTT, - this.cutToolStripMenuItem, - this.copyToolStripMenuItem, - this.pasteToolStripMenuItem, - this.deleteToolStripMenuItem, - this.toolStripMenuItemSplitTextAtCursor, - this.toolStripMenuItemSplitViaWaveform, - this.toolStripSeparator18, - this.selectAllToolStripMenuItem, - this.toolStripSeparator17, - this.normalToolStripMenuItem1, - this.boldToolStripMenuItem1, - this.italicToolStripMenuItem1, - this.boxToolStripMenuItem1, - this.underlineToolStripMenuItem1, - this.colorToolStripMenuItem1, - this.toolStripMenuItemHorizontalDigits, - this.toolStripMenuItemBouten, - this.toolStripMenuItemRuby, - this.fontNameToolStripMenuItem, - this.toolStripSeparator26, - this.toolStripMenuItemInsertUnicodeSymbol, - this.toolStripMenuItemInsertUnicodeControlCharacters, - this.superscriptToolStripMenuItem, - this.subscriptToolStripMenuItem}); - this.contextMenuStripTextBoxListView.Name = "contextMenuStripTextBoxListView"; - this.contextMenuStripTextBoxListView.Size = new System.Drawing.Size(274, 512); - this.contextMenuStripTextBoxListView.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.MenuClosed); - this.contextMenuStripTextBoxListView.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripTextBoxListViewOpening); - this.contextMenuStripTextBoxListView.Opened += new System.EventHandler(this.MenuOpened); - // - // toolStripMenuItemWebVttVoice - // - this.toolStripMenuItemWebVttVoice.Name = "toolStripMenuItemWebVttVoice"; - this.toolStripMenuItemWebVttVoice.Size = new System.Drawing.Size(273, 22); - this.toolStripMenuItemWebVttVoice.Text = "WebVTT voice"; - // - // toolStripSeparatorWebVTT - // - this.toolStripSeparatorWebVTT.Name = "toolStripSeparatorWebVTT"; - this.toolStripSeparatorWebVTT.Size = new System.Drawing.Size(270, 6); - // - // cutToolStripMenuItem - // - this.cutToolStripMenuItem.Name = "cutToolStripMenuItem"; - this.cutToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); - this.cutToolStripMenuItem.Size = new System.Drawing.Size(273, 22); - this.cutToolStripMenuItem.Text = "Cut"; - this.cutToolStripMenuItem.Click += new System.EventHandler(this.cutToolStripMenuItem_Click); - // - // copyToolStripMenuItem - // - this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; - this.copyToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); - this.copyToolStripMenuItem.Size = new System.Drawing.Size(273, 22); - this.copyToolStripMenuItem.Text = "Copy"; - this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); - // - // pasteToolStripMenuItem - // - this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem"; - this.pasteToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V))); - this.pasteToolStripMenuItem.Size = new System.Drawing.Size(273, 22); - this.pasteToolStripMenuItem.Text = "Paste"; - this.pasteToolStripMenuItem.Click += new System.EventHandler(this.PasteToolStripMenuItemClick); - // - // deleteToolStripMenuItem - // - this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(273, 22); - this.deleteToolStripMenuItem.Text = "Delete"; - this.deleteToolStripMenuItem.Click += new System.EventHandler(this.DeleteToolStripMenuItemClick); - // - // toolStripMenuItemSplitTextAtCursor - // - this.toolStripMenuItemSplitTextAtCursor.Name = "toolStripMenuItemSplitTextAtCursor"; - this.toolStripMenuItemSplitTextAtCursor.Size = new System.Drawing.Size(273, 22); - this.toolStripMenuItemSplitTextAtCursor.Text = "Split text at cursor position"; - this.toolStripMenuItemSplitTextAtCursor.Click += new System.EventHandler(this.ToolStripMenuItemSplitTextAtCursorClick); - // - // toolStripMenuItemSplitViaWaveform - // - this.toolStripMenuItemSplitViaWaveform.Name = "toolStripMenuItemSplitViaWaveform"; - this.toolStripMenuItemSplitViaWaveform.Size = new System.Drawing.Size(273, 22); - this.toolStripMenuItemSplitViaWaveform.Text = "Split text at cursor/waveform position"; - this.toolStripMenuItemSplitViaWaveform.Click += new System.EventHandler(this.toolStripMenuItemSplitViaWaveform_Click); - // - // toolStripSeparator18 - // - this.toolStripSeparator18.Name = "toolStripSeparator18"; - this.toolStripSeparator18.Size = new System.Drawing.Size(270, 6); - // - // selectAllToolStripMenuItem - // - this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem"; - this.selectAllToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A))); - this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(273, 22); - this.selectAllToolStripMenuItem.Text = "Select all"; - this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.selectAllToolStripMenuItem_Click); - // - // toolStripSeparator17 - // - this.toolStripSeparator17.Name = "toolStripSeparator17"; - this.toolStripSeparator17.Size = new System.Drawing.Size(270, 6); - // - // normalToolStripMenuItem1 - // - this.normalToolStripMenuItem1.Name = "normalToolStripMenuItem1"; - this.normalToolStripMenuItem1.Size = new System.Drawing.Size(273, 22); - this.normalToolStripMenuItem1.Text = "Normal"; - this.normalToolStripMenuItem1.Click += new System.EventHandler(this.NormalToolStripMenuItem1Click); - // - // boldToolStripMenuItem1 - // - this.boldToolStripMenuItem1.Name = "boldToolStripMenuItem1"; - this.boldToolStripMenuItem1.Size = new System.Drawing.Size(273, 22); - this.boldToolStripMenuItem1.Text = "Bold"; - this.boldToolStripMenuItem1.Click += new System.EventHandler(this.BoldToolStripMenuItem1Click); - // - // italicToolStripMenuItem1 - // - this.italicToolStripMenuItem1.Name = "italicToolStripMenuItem1"; - this.italicToolStripMenuItem1.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); - this.italicToolStripMenuItem1.Size = new System.Drawing.Size(273, 22); - this.italicToolStripMenuItem1.Text = "Italic"; - this.italicToolStripMenuItem1.Click += new System.EventHandler(this.ItalicToolStripMenuItem1Click); - // - // boxToolStripMenuItem1 - // - this.boxToolStripMenuItem1.Name = "boxToolStripMenuItem1"; - this.boxToolStripMenuItem1.Size = new System.Drawing.Size(273, 22); - this.boxToolStripMenuItem1.Text = "Box"; - this.boxToolStripMenuItem1.Click += new System.EventHandler(this.boxToolStripMenuItem1_Click); - // - // underlineToolStripMenuItem1 - // - this.underlineToolStripMenuItem1.Name = "underlineToolStripMenuItem1"; - this.underlineToolStripMenuItem1.Size = new System.Drawing.Size(273, 22); - this.underlineToolStripMenuItem1.Text = "Underline"; - this.underlineToolStripMenuItem1.Click += new System.EventHandler(this.UnderlineToolStripMenuItem1Click); - // - // colorToolStripMenuItem1 - // - this.colorToolStripMenuItem1.Name = "colorToolStripMenuItem1"; - this.colorToolStripMenuItem1.Size = new System.Drawing.Size(273, 22); - this.colorToolStripMenuItem1.Text = "Color..."; - this.colorToolStripMenuItem1.Click += new System.EventHandler(this.ColorToolStripMenuItem1Click); - // - // toolStripMenuItemHorizontalDigits - // - this.toolStripMenuItemHorizontalDigits.Name = "toolStripMenuItemHorizontalDigits"; - this.toolStripMenuItemHorizontalDigits.Size = new System.Drawing.Size(273, 22); - this.toolStripMenuItemHorizontalDigits.Text = "Horizontal digits"; - this.toolStripMenuItemHorizontalDigits.Click += new System.EventHandler(this.toolStripMenuItemHorizontalDigits_Click); - // - // toolStripMenuItemBouten - // - this.toolStripMenuItemBouten.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.boutendotbeforeToolStripMenuItem, - this.boutendotafterToolStripMenuItem, - this.boutendotoutsideToolStripMenuItem, - this.boutenfilledcircleoutsideToolStripMenuItem, - this.boutenopencircleoutsideToolStripMenuItem, - this.boutenopendotoutsideToolStripMenuItem, - this.boutenfilledsesameoutsideToolStripMenuItem, - this.boutenopensesameoutsideToolStripMenuItem, - this.boutenautooutsideToolStripMenuItem, - this.boutenautoToolStripMenuItem}); - this.toolStripMenuItemBouten.Name = "toolStripMenuItemBouten"; - this.toolStripMenuItemBouten.Size = new System.Drawing.Size(273, 22); - this.toolStripMenuItemBouten.Text = "Bouten"; - // - // boutendotbeforeToolStripMenuItem - // - this.boutendotbeforeToolStripMenuItem.Name = "boutendotbeforeToolStripMenuItem"; - this.boutendotbeforeToolStripMenuItem.Size = new System.Drawing.Size(232, 22); - this.boutendotbeforeToolStripMenuItem.Text = "bouten-dot-before"; - this.boutendotbeforeToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); - // - // boutendotafterToolStripMenuItem - // - this.boutendotafterToolStripMenuItem.Name = "boutendotafterToolStripMenuItem"; - this.boutendotafterToolStripMenuItem.Size = new System.Drawing.Size(232, 22); - this.boutendotafterToolStripMenuItem.Text = "bouten-dot-after"; - this.boutendotafterToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); - // - // boutendotoutsideToolStripMenuItem - // - this.boutendotoutsideToolStripMenuItem.Name = "boutendotoutsideToolStripMenuItem"; - this.boutendotoutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); - this.boutendotoutsideToolStripMenuItem.Text = "bouten-dot-outside"; - this.boutendotoutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); - // - // boutenfilledcircleoutsideToolStripMenuItem - // - this.boutenfilledcircleoutsideToolStripMenuItem.Name = "boutenfilledcircleoutsideToolStripMenuItem"; - this.boutenfilledcircleoutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); - this.boutenfilledcircleoutsideToolStripMenuItem.Text = "bouten-filled-circle-outside"; - this.boutenfilledcircleoutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); - // - // boutenopencircleoutsideToolStripMenuItem - // - this.boutenopencircleoutsideToolStripMenuItem.Name = "boutenopencircleoutsideToolStripMenuItem"; - this.boutenopencircleoutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); - this.boutenopencircleoutsideToolStripMenuItem.Text = "bouten-open-circle-outside"; - this.boutenopencircleoutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); - // - // boutenopendotoutsideToolStripMenuItem - // - this.boutenopendotoutsideToolStripMenuItem.Name = "boutenopendotoutsideToolStripMenuItem"; - this.boutenopendotoutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); - this.boutenopendotoutsideToolStripMenuItem.Text = "bouten-open-dot-outside"; - this.boutenopendotoutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); - // - // boutenfilledsesameoutsideToolStripMenuItem - // - this.boutenfilledsesameoutsideToolStripMenuItem.Name = "boutenfilledsesameoutsideToolStripMenuItem"; - this.boutenfilledsesameoutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); - this.boutenfilledsesameoutsideToolStripMenuItem.Text = "bouten-filled-sesame-outside"; - this.boutenfilledsesameoutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); - // - // boutenopensesameoutsideToolStripMenuItem - // - this.boutenopensesameoutsideToolStripMenuItem.Name = "boutenopensesameoutsideToolStripMenuItem"; - this.boutenopensesameoutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); - this.boutenopensesameoutsideToolStripMenuItem.Text = "bouten-open-sesame-outside"; - this.boutenopensesameoutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); - // - // boutenautooutsideToolStripMenuItem - // - this.boutenautooutsideToolStripMenuItem.Name = "boutenautooutsideToolStripMenuItem"; - this.boutenautooutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); - this.boutenautooutsideToolStripMenuItem.Text = "bouten-auto-outside"; - this.boutenautooutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); - // - // boutenautoToolStripMenuItem - // - this.boutenautoToolStripMenuItem.Name = "boutenautoToolStripMenuItem"; - this.boutenautoToolStripMenuItem.Size = new System.Drawing.Size(232, 22); - this.boutenautoToolStripMenuItem.Text = "bouten-auto"; - this.boutenautoToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); - // - // toolStripMenuItemRuby - // - this.toolStripMenuItemRuby.Name = "toolStripMenuItemRuby"; - this.toolStripMenuItemRuby.Size = new System.Drawing.Size(273, 22); - this.toolStripMenuItemRuby.Text = "Ruby..."; - this.toolStripMenuItemRuby.Click += new System.EventHandler(this.toolStripMenuItemRuby_Click); - // - // fontNameToolStripMenuItem - // - this.fontNameToolStripMenuItem.Name = "fontNameToolStripMenuItem"; - this.fontNameToolStripMenuItem.Size = new System.Drawing.Size(273, 22); - this.fontNameToolStripMenuItem.Text = "Font name..."; - this.fontNameToolStripMenuItem.Click += new System.EventHandler(this.FontNameToolStripMenuItemClick); - // - // toolStripSeparator26 - // - this.toolStripSeparator26.Name = "toolStripSeparator26"; - this.toolStripSeparator26.Size = new System.Drawing.Size(270, 6); - // - // toolStripMenuItemInsertUnicodeSymbol - // - this.toolStripMenuItemInsertUnicodeSymbol.Name = "toolStripMenuItemInsertUnicodeSymbol"; - this.toolStripMenuItemInsertUnicodeSymbol.Size = new System.Drawing.Size(273, 22); - this.toolStripMenuItemInsertUnicodeSymbol.Text = "Insert unicode character"; - // - // toolStripMenuItemInsertUnicodeControlCharacters - // - this.toolStripMenuItemInsertUnicodeControlCharacters.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.leftToolStripMenuItem, - this.righttoleftMarkToolStripMenuItem, - this.startOfLefttorightEmbeddingLREToolStripMenuItem, - this.startOfRighttoleftEmbeddingRLEToolStripMenuItem, - this.startOfLefttorightOverrideLROToolStripMenuItem, - this.startOfRighttoleftOverrideRLOToolStripMenuItem}); - this.toolStripMenuItemInsertUnicodeControlCharacters.Name = "toolStripMenuItemInsertUnicodeControlCharacters"; - this.toolStripMenuItemInsertUnicodeControlCharacters.Size = new System.Drawing.Size(273, 22); - this.toolStripMenuItemInsertUnicodeControlCharacters.Text = "Insert unicode control character"; - // - // leftToolStripMenuItem - // - this.leftToolStripMenuItem.Name = "leftToolStripMenuItem"; - this.leftToolStripMenuItem.Size = new System.Drawing.Size(272, 22); - this.leftToolStripMenuItem.Text = "Left-to-right mark (LRM)"; - this.leftToolStripMenuItem.Click += new System.EventHandler(this.leftToolStripMenuItem_Click); - // - // righttoleftMarkToolStripMenuItem - // - this.righttoleftMarkToolStripMenuItem.Name = "righttoleftMarkToolStripMenuItem"; - this.righttoleftMarkToolStripMenuItem.Size = new System.Drawing.Size(272, 22); - this.righttoleftMarkToolStripMenuItem.Text = "Right-to-left mark (RLM)"; - this.righttoleftMarkToolStripMenuItem.Click += new System.EventHandler(this.righttoleftMarkToolStripMenuItem_Click); - // - // startOfLefttorightEmbeddingLREToolStripMenuItem - // - this.startOfLefttorightEmbeddingLREToolStripMenuItem.Name = "startOfLefttorightEmbeddingLREToolStripMenuItem"; - this.startOfLefttorightEmbeddingLREToolStripMenuItem.Size = new System.Drawing.Size(272, 22); - this.startOfLefttorightEmbeddingLREToolStripMenuItem.Text = "Start of left-to-right embedding (LRE)"; - this.startOfLefttorightEmbeddingLREToolStripMenuItem.Click += new System.EventHandler(this.startOfLefttorightEmbeddingLREToolStripMenuItem_Click); - // - // startOfRighttoleftEmbeddingRLEToolStripMenuItem - // - this.startOfRighttoleftEmbeddingRLEToolStripMenuItem.Name = "startOfRighttoleftEmbeddingRLEToolStripMenuItem"; - this.startOfRighttoleftEmbeddingRLEToolStripMenuItem.Size = new System.Drawing.Size(272, 22); - this.startOfRighttoleftEmbeddingRLEToolStripMenuItem.Text = "Start of right-to-left embedding (RLE)"; - this.startOfRighttoleftEmbeddingRLEToolStripMenuItem.Click += new System.EventHandler(this.startOfRighttoleftEmbeddingRLEToolStripMenuItem_Click); - // - // startOfLefttorightOverrideLROToolStripMenuItem - // - this.startOfLefttorightOverrideLROToolStripMenuItem.Name = "startOfLefttorightOverrideLROToolStripMenuItem"; - this.startOfLefttorightOverrideLROToolStripMenuItem.Size = new System.Drawing.Size(272, 22); - this.startOfLefttorightOverrideLROToolStripMenuItem.Text = "Start of left-to-right override (LRO)"; - this.startOfLefttorightOverrideLROToolStripMenuItem.Click += new System.EventHandler(this.startOfLefttorightOverrideLROToolStripMenuItem_Click); - // - // startOfRighttoleftOverrideRLOToolStripMenuItem - // - this.startOfRighttoleftOverrideRLOToolStripMenuItem.Name = "startOfRighttoleftOverrideRLOToolStripMenuItem"; - this.startOfRighttoleftOverrideRLOToolStripMenuItem.Size = new System.Drawing.Size(272, 22); - this.startOfRighttoleftOverrideRLOToolStripMenuItem.Text = "Start of right-to-left override (RLO)"; - this.startOfRighttoleftOverrideRLOToolStripMenuItem.Click += new System.EventHandler(this.startOfRighttoleftOverrideRLOToolStripMenuItem_Click); - // - // superscriptToolStripMenuItem - // - this.superscriptToolStripMenuItem.Name = "superscriptToolStripMenuItem"; - this.superscriptToolStripMenuItem.Size = new System.Drawing.Size(273, 22); - this.superscriptToolStripMenuItem.Text = "Superscript"; - this.superscriptToolStripMenuItem.Click += new System.EventHandler(this.SuperscriptToolStripMenuItemClick); - // - // subscriptToolStripMenuItem - // - this.subscriptToolStripMenuItem.Name = "subscriptToolStripMenuItem"; - this.subscriptToolStripMenuItem.Size = new System.Drawing.Size(273, 22); - this.subscriptToolStripMenuItem.Text = "Subscript"; - this.subscriptToolStripMenuItem.Click += new System.EventHandler(this.SubscriptToolStripMenuItemClick); - // - // buttonAutoBreak - // - this.buttonAutoBreak.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonAutoBreak.Location = new System.Drawing.Point(604, 51); - this.buttonAutoBreak.Name = "buttonAutoBreak"; - this.buttonAutoBreak.Size = new System.Drawing.Size(115, 23); - this.buttonAutoBreak.TabIndex = 7; - this.buttonAutoBreak.Text = "Auto br"; - this.buttonAutoBreak.UseVisualStyleBackColor = true; - this.buttonAutoBreak.Click += new System.EventHandler(this.ButtonAutoBreakClick); - // - // labelTextLineLengths - // - this.labelTextLineLengths.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelTextLineLengths.AutoSize = true; - this.labelTextLineLengths.Location = new System.Drawing.Point(239, 94); - this.labelTextLineLengths.Name = "labelTextLineLengths"; - this.labelTextLineLengths.Size = new System.Drawing.Size(108, 13); - this.labelTextLineLengths.TabIndex = 12; - this.labelTextLineLengths.Text = "labelTextLineLengths"; - // - // labelTextLineTotal - // - this.labelTextLineTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelTextLineTotal.AutoSize = true; - this.labelTextLineTotal.Location = new System.Drawing.Point(1001, 94); - this.labelTextLineTotal.Name = "labelTextLineTotal"; - this.labelTextLineTotal.Size = new System.Drawing.Size(94, 13); - this.labelTextLineTotal.TabIndex = 21; - this.labelTextLineTotal.Text = "labelTextLineTotal"; - // - // labelCharactersPerSecond - // - this.labelCharactersPerSecond.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelCharactersPerSecond.AutoSize = true; - this.labelCharactersPerSecond.Location = new System.Drawing.Point(432, 11); - this.labelCharactersPerSecond.Name = "labelCharactersPerSecond"; - this.labelCharactersPerSecond.Size = new System.Drawing.Size(133, 13); - this.labelCharactersPerSecond.TabIndex = 31; - this.labelCharactersPerSecond.Text = "labelCharactersPerSecond"; - // - // buttonUnBreak - // - this.buttonUnBreak.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUnBreak.Location = new System.Drawing.Point(604, 22); - this.buttonUnBreak.Name = "buttonUnBreak"; - this.buttonUnBreak.Size = new System.Drawing.Size(115, 23); - this.buttonUnBreak.TabIndex = 6; - this.buttonUnBreak.Text = "Unbreak"; - this.buttonUnBreak.UseVisualStyleBackColor = true; - this.buttonUnBreak.Click += new System.EventHandler(this.ButtonUnBreakClick); - // - // timeUpDownStartTime - // - this.timeUpDownStartTime.AutoSize = true; - this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownStartTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); - this.timeUpDownStartTime.Location = new System.Drawing.Point(8, 26); - this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownStartTime.Name = "timeUpDownStartTime"; - this.timeUpDownStartTime.Size = new System.Drawing.Size(111, 27); - this.timeUpDownStartTime.TabIndex = 0; - timeCode6.Hours = 0; - timeCode6.Milliseconds = 0; - timeCode6.Minutes = 0; - timeCode6.Seconds = 0; - timeCode6.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode6.TotalMilliseconds = 0D; - timeCode6.TotalSeconds = 0D; - this.timeUpDownStartTime.TimeCode = timeCode6; - this.timeUpDownStartTime.UseVideoOffset = false; - // - // numericUpDownDuration - // - this.numericUpDownDuration.DecimalPlaces = 3; - this.numericUpDownDuration.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownDuration.Location = new System.Drawing.Point(122, 27); - this.numericUpDownDuration.Maximum = new decimal(new int[] { - 999999999, - 0, - 0, - 0}); - this.numericUpDownDuration.Minimum = new decimal(new int[] { - 99999, - 0, - 0, - -2147483648}); - this.numericUpDownDuration.Name = "numericUpDownDuration"; - this.numericUpDownDuration.Size = new System.Drawing.Size(56, 20); - this.numericUpDownDuration.TabIndex = 1; - this.numericUpDownDuration.ValueChanged += new System.EventHandler(this.NumericUpDownDurationValueChanged); - // - // buttonPrevious - // - this.buttonPrevious.Location = new System.Drawing.Point(8, 78); - this.buttonPrevious.Name = "buttonPrevious"; - this.buttonPrevious.Size = new System.Drawing.Size(72, 23); - this.buttonPrevious.TabIndex = 2; - this.buttonPrevious.Text = "< Prev "; - this.buttonPrevious.UseVisualStyleBackColor = true; - this.buttonPrevious.Click += new System.EventHandler(this.ButtonPreviousClick); - // - // buttonNext - // - this.buttonNext.Location = new System.Drawing.Point(86, 78); - this.buttonNext.Name = "buttonNext"; - this.buttonNext.Size = new System.Drawing.Size(72, 23); - this.buttonNext.TabIndex = 3; - this.buttonNext.Text = "Next >"; - this.buttonNext.UseVisualStyleBackColor = true; - this.buttonNext.Click += new System.EventHandler(this.ButtonNextClick); - // - // labelStartTime - // - this.labelStartTime.AutoSize = true; - this.labelStartTime.Location = new System.Drawing.Point(9, 11); - this.labelStartTime.Name = "labelStartTime"; - this.labelStartTime.Size = new System.Drawing.Size(51, 13); - this.labelStartTime.TabIndex = 3; - this.labelStartTime.Text = "Start time"; - // - // textBoxListViewText - // - this.textBoxListViewText.AllowDrop = true; - this.textBoxListViewText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxListViewText.ContextMenuStrip = this.contextMenuStripTextBoxListView; - this.textBoxListViewText.Enabled = false; - this.textBoxListViewText.HideSelection = false; - this.textBoxListViewText.Location = new System.Drawing.Point(236, 28); - this.textBoxListViewText.Multiline = true; - this.textBoxListViewText.Name = "textBoxListViewText"; - this.textBoxListViewText.Size = new System.Drawing.Size(362, 63); - this.textBoxListViewText.TabIndex = 5; - this.textBoxListViewText.MouseClick += new System.Windows.Forms.MouseEventHandler(this.TextBoxListViewTextMouseClick); - this.textBoxListViewText.TextChanged += new System.EventHandler(this.TextBoxListViewTextTextChanged); - this.textBoxListViewText.Enter += new System.EventHandler(this.TextBoxListViewTextEnter); - this.textBoxListViewText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxListViewTextKeyDown); - this.textBoxListViewText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBoxListViewText_KeyUp); - this.textBoxListViewText.Leave += new System.EventHandler(this.textBoxListViewText_Leave); - this.textBoxListViewText.MouseMove += new System.Windows.Forms.MouseEventHandler(this.textBoxListViewText_MouseMove); - // - // labelDuration - // - this.labelDuration.AutoSize = true; - this.labelDuration.Location = new System.Drawing.Point(122, 11); - this.labelDuration.Name = "labelDuration"; - this.labelDuration.Size = new System.Drawing.Size(47, 13); - this.labelDuration.TabIndex = 4; - this.labelDuration.Text = "Duration"; - // - // labelAutoDuration - // - this.labelAutoDuration.AutoSize = true; - this.labelAutoDuration.Location = new System.Drawing.Point(92, 11); - this.labelAutoDuration.Name = "labelAutoDuration"; - this.labelAutoDuration.Size = new System.Drawing.Size(29, 13); - this.labelAutoDuration.TabIndex = 30; - this.labelAutoDuration.Text = "Auto"; - // - // tabPage2 - // - this.tabPage2.Controls.Add(this.textBoxSource); - this.tabPage2.Location = new System.Drawing.Point(4, 22); - this.tabPage2.Name = "tabPage2"; - this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(730, 222); - this.tabPage2.TabIndex = 1; - this.tabPage2.Text = "Source view"; - this.tabPage2.UseVisualStyleBackColor = true; - // - // textBoxSource - // - this.textBoxSource.AllowDrop = true; - this.textBoxSource.Dock = System.Windows.Forms.DockStyle.Fill; - this.textBoxSource.HideSelection = false; - this.textBoxSource.Location = new System.Drawing.Point(3, 3); - this.textBoxSource.MaxLength = 0; - this.textBoxSource.Multiline = true; - this.textBoxSource.Name = "textBoxSource"; - this.textBoxSource.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxSource.Size = new System.Drawing.Size(724, 216); - this.textBoxSource.TabIndex = 12; - this.textBoxSource.WordWrap = false; - this.textBoxSource.Click += new System.EventHandler(this.TextBoxSourceClick); - this.textBoxSource.TextChanged += new System.EventHandler(this.TextBoxSourceTextChanged); - this.textBoxSource.DragDrop += new System.Windows.Forms.DragEventHandler(this.TextBoxSourceDragDrop); - this.textBoxSource.DragEnter += new System.Windows.Forms.DragEventHandler(this.TextBoxSourceDragEnter); - this.textBoxSource.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxSourceKeyDown); - this.textBoxSource.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBoxSource_KeyUp); - this.textBoxSource.Leave += new System.EventHandler(this.TextBoxSourceLeave); - // - // panelVideoPlayer - // - this.panelVideoPlayer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.panelVideoPlayer.Controls.Add(this.mediaPlayer); - this.panelVideoPlayer.Location = new System.Drawing.Point(1, 1); - this.panelVideoPlayer.Name = "panelVideoPlayer"; - this.panelVideoPlayer.Size = new System.Drawing.Size(220, 246); - this.panelVideoPlayer.TabIndex = 5; - // - // mediaPlayer - // - this.mediaPlayer.AllowDrop = true; - this.mediaPlayer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.mediaPlayer.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18))))); - this.mediaPlayer.CurrentPosition = 0D; - this.mediaPlayer.FontSizeFactor = 1F; - this.mediaPlayer.LastParagraph = null; - this.mediaPlayer.Location = new System.Drawing.Point(0, 0); - this.mediaPlayer.Margin = new System.Windows.Forms.Padding(0); - this.mediaPlayer.Name = "mediaPlayer"; - this.mediaPlayer.ShowFullscreenButton = true; - this.mediaPlayer.ShowMuteButton = true; - this.mediaPlayer.ShowStopButton = true; - this.mediaPlayer.Size = new System.Drawing.Size(219, 246); - this.mediaPlayer.SmpteMode = false; - this.mediaPlayer.SubtitleText = ""; - this.mediaPlayer.TabIndex = 5; - this.mediaPlayer.TextRightToLeft = System.Windows.Forms.RightToLeft.No; - this.mediaPlayer.VideoHeight = 0; - this.mediaPlayer.VideoPlayer = null; - this.mediaPlayer.VideoWidth = 0; - this.mediaPlayer.Volume = 0D; - this.mediaPlayer.DragDrop += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragDrop); - this.mediaPlayer.DragEnter += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragEnter); - // - // contextMenuStripEmpty - // - this.contextMenuStripEmpty.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.insertLineToolStripMenuItem, - this.aSSStylesToolStripMenuItem}); - this.contextMenuStripEmpty.Name = "contextMenuStripEmpty"; - this.contextMenuStripEmpty.Size = new System.Drawing.Size(181, 70); - this.contextMenuStripEmpty.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripEmpty_Opening); - // - // insertLineToolStripMenuItem - // - this.insertLineToolStripMenuItem.Name = "insertLineToolStripMenuItem"; - this.insertLineToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.insertLineToolStripMenuItem.Text = "Insert line"; - this.insertLineToolStripMenuItem.Click += new System.EventHandler(this.InsertLineToolStripMenuItemClick); - // - // imageListPlayRate - // - this.imageListPlayRate.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListPlayRate.ImageStream"))); - this.imageListPlayRate.TransparentColor = System.Drawing.Color.Transparent; - this.imageListPlayRate.Images.SetKeyName(0, "FastForward.png"); - this.imageListPlayRate.Images.SetKeyName(1, "FastForwardHighLight.png"); - // - // timerTextUndo - // - this.timerTextUndo.Interval = 700; - this.timerTextUndo.Tick += new System.EventHandler(this.TimerTextUndoTick); - // - // timerAlternateTextUndo - // - this.timerAlternateTextUndo.Interval = 700; - this.timerAlternateTextUndo.Tick += new System.EventHandler(this.TimerAlternateTextUndoTick); - // - // aSSStylesToolStripMenuItem - // - this.aSSStylesToolStripMenuItem.Name = "aSSStylesToolStripMenuItem"; - this.aSSStylesToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.aSSStylesToolStripMenuItem.Text = "ASS styles..."; - this.aSSStylesToolStripMenuItem.Click += new System.EventHandler(this.aSSStylesToolStripMenuItem_Click); - // - // Main - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(975, 646); - this.Controls.Add(this.splitContainerMain); - this.Controls.Add(this.toolStrip1); - this.Controls.Add(this.statusStrip1); - this.Controls.Add(this.menuStrip1); - this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MainMenuStrip = this.menuStrip1; - this.MinimumSize = new System.Drawing.Size(800, 554); - this.Name = "Main"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormMain_FormClosing); - this.Load += new System.EventHandler(this.Main_Load); - this.Shown += new System.EventHandler(this.Main_Shown); - this.ResizeEnd += new System.EventHandler(this.Main_ResizeEnd); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MainKeyDown); - this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.MainKeyUp); - this.Resize += new System.EventHandler(this.Main_Resize); - this.statusStrip1.ResumeLayout(false); - this.statusStrip1.PerformLayout(); - this.toolStrip1.ResumeLayout(false); - this.toolStrip1.PerformLayout(); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.contextMenuStripListview.ResumeLayout(false); - this.groupBoxVideo.ResumeLayout(false); - this.groupBoxVideo.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.trackBarWaveformPosition)).EndInit(); - this.panelWaveformControls.ResumeLayout(false); - this.panelWaveformControls.PerformLayout(); - this.toolStripWaveControls.ResumeLayout(false); - this.toolStripWaveControls.PerformLayout(); - this.tabControlButtons.ResumeLayout(false); - this.tabPageTranslate.ResumeLayout(false); - this.tabPageTranslate.PerformLayout(); - this.groupBoxTranslateSearch.ResumeLayout(false); - this.groupBoxTranslateSearch.PerformLayout(); - this.groupBoxAutoContinue.ResumeLayout(false); - this.groupBoxAutoContinue.PerformLayout(); - this.groupBoxAutoRepeat.ResumeLayout(false); - this.groupBoxAutoRepeat.PerformLayout(); - this.tabPageCreate.ResumeLayout(false); - this.tabPageCreate.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSec2)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSec1)).EndInit(); - this.tabPageAdjust.ResumeLayout(false); - this.tabPageAdjust.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSecAdjust2)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSecAdjust1)).EndInit(); - this.contextMenuStripWaveform.ResumeLayout(false); - this.splitContainerMain.Panel1.ResumeLayout(false); - this.splitContainerMain.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainerMain)).EndInit(); - this.splitContainerMain.ResumeLayout(false); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); - this.tabControlSubtitle.ResumeLayout(false); - this.tabPage1.ResumeLayout(false); - this.splitContainerListViewAndText.Panel1.ResumeLayout(false); - this.splitContainerListViewAndText.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainerListViewAndText)).EndInit(); - this.splitContainerListViewAndText.ResumeLayout(false); - this.groupBoxEdit.ResumeLayout(false); - this.groupBoxEdit.PerformLayout(); - this.panelBookmark.ResumeLayout(false); - this.panelBookmark.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBookmark)).EndInit(); - this.contextMenuStripTextBoxListView.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).EndInit(); - this.tabPage2.ResumeLayout(false); - this.tabPage2.PerformLayout(); - this.panelVideoPlayer.ResumeLayout(false); - this.contextMenuStripEmpty.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.StatusStrip statusStrip1; - private System.Windows.Forms.ToolStrip toolStrip1; - private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem reopenToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripMenuItem findToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem findNextToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem replaceToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem gotoLineNumberToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; - private System.Windows.Forms.TabControl tabControlSubtitle; - private System.Windows.Forms.TabPage tabPage1; - private Nikse.SubtitleEdit.Controls.SubtitleListView SubtitleListview1; - private System.Windows.Forms.TabPage tabPage2; - private System.Windows.Forms.TextBox textBoxSource; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; - private System.Windows.Forms.ToolStripButton toolStripButtonFileOpen; - private System.Windows.Forms.ToolStripButton toolStripButtonFileNew; - private System.Windows.Forms.ToolStripButton toolStripButtonSave; - private System.Windows.Forms.ToolStripButton toolStripButtonSaveAs; - private System.Windows.Forms.ToolStripButton toolStripButtonFind; - private System.Windows.Forms.ToolStripButton toolStripButtonReplace; - private System.Windows.Forms.ToolStripButton toolStripButtonSpellCheck; - private System.Windows.Forms.ToolStripButton toolStripButtonSettings; - private System.Windows.Forms.ToolStripButton toolStripButtonVisualSync; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorFindReplace; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorFixSyncSpell; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorHelp; - private System.Windows.Forms.ToolStripButton toolStripButtonHelp; - private System.Windows.Forms.Timer timer1; - private System.Windows.Forms.ToolStripStatusLabel labelStatus; - private System.Windows.Forms.ToolStripMenuItem adjustDisplayTimeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem fixToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem startNumberingFromToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeTextForHearImpairedToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; - private System.Windows.Forms.ToolStripMenuItem splitToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem appendTextVisuallyToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem showHistoryforUndoToolStripMenuItem; - private System.Windows.Forms.ContextMenuStrip contextMenuStripListview; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDelete; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertBefore; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertAfter; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; - private System.Windows.Forms.ToolStripMenuItem boldToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem italicToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem underlineToolStripMenuItem; - private System.Windows.Forms.GroupBox groupBoxEdit; - private System.Windows.Forms.Label labelText; - private System.Windows.Forms.Label labelDuration; - private System.Windows.Forms.Label labelStartTime; - //private System.Windows.Forms.TextBox textBoxListViewText; - Nikse.SubtitleEdit.Controls.SETextBox textBoxListViewText; - private System.Windows.Forms.Button buttonPrevious; - private System.Windows.Forms.Button buttonNext; - private System.Windows.Forms.ToolStripMenuItem splitLineToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem mergeBeforeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem mergeAfterToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator8; - private System.Windows.Forms.Button buttonAutoBreak; - private System.Windows.Forms.ToolStripMenuItem removeFormattinglToolStripMenuItem; - private System.Windows.Forms.Label labelTextLineLengths; - private System.Windows.Forms.NumericUpDown numericUpDownDuration; - private System.Windows.Forms.Label labelDurationWarning; - private System.Windows.Forms.Label labelStartTimeWarning; - private System.Windows.Forms.Button buttonUnBreak; - private System.Windows.Forms.ToolStripMenuItem colorToolStripMenuItem; - private System.Windows.Forms.ColorDialog colorDialog1; - private System.Windows.Forms.Label labelTextLineTotal; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolStripMenuItem typeEffectToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem karokeeEffectToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem matroskaImportStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator10; - private Nikse.SubtitleEdit.Controls.TimeUpDown timeUpDownStartTime; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemManualAnsi; - private System.Windows.Forms.ToolStripMenuItem ChangeCasingToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMergeLines; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorAdvancedFunctions; - private System.Windows.Forms.ToolStripMenuItem visualSyncSelectedLinesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem showSelectedLinesEarlierlaterToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem adjustDisplayTimeForSelectedLinesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem fixCommonErrorsInSelectedLinesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem changeCasingForSelectedLinesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSortBy; - private System.Windows.Forms.ToolStripMenuItem sortNumberToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem sortStartTimeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem sortEndTimeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem sortDisplayTimeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem sortTextMaxLineLengthToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem sortTextTotalLengthToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem sortTextNumberOfLinesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem sortTextAlphabeticallytoolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem changeLanguageToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator12; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemCompare; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemUnbreakLines; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAutoBreakLines; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorBreakLines; - private System.Windows.Forms.ToolStripMenuItem multipleReplaceToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportDvdSubtitles; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSubIdx; - private System.Windows.Forms.ToolStripStatusLabel toolStripSelected; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertUnicodeCharacter; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorInsertUnicodeCharacter; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAutoMergeShortLines; - private System.Windows.Forms.ToolStripMenuItem setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportText; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportTimeCodes; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemFont; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator14; - private System.Windows.Forms.GroupBox groupBoxVideo; - private System.Windows.Forms.Button buttonGotoSub; - private System.Windows.Forms.Button buttonBeforeText; - private System.Windows.Forms.Button buttonSetEnd; - private System.Windows.Forms.Button buttonSetStartTime; - private System.Windows.Forms.Button buttonInsertNewText; - private System.Windows.Forms.Button buttonSecBack1; - private System.Windows.Forms.Timer ShowSubtitleTimer; - private System.Windows.Forms.Timer timerAutoDuration; - private System.Windows.Forms.Label labelAutoDuration; - private System.Windows.Forms.Timer timerAutoContinue; - private System.Windows.Forms.ToolStripComboBox comboBoxSubtitleFormats; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorToggle; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorSubtitleFormat; - private System.Windows.Forms.ToolStripLabel toolStripLabelSubtitleFormat; - private System.Windows.Forms.ToolStripLabel toolStripLabelEncoding; - private System.Windows.Forms.ToolStripComboBox comboBoxEncoding; - private System.Windows.Forms.ToolStripButton toolStripButtonToggleVideo; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorEncoding; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorFrameRate; - private System.Windows.Forms.ToolStripLabel toolStripLabelFrameRate; - private System.Windows.Forms.ToolStripComboBox toolStripComboBoxFrameRate; - private System.Windows.Forms.ToolStripButton toolStripButtonGetFrameRate; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSpellCheckMain; - private System.Windows.Forms.ToolStripMenuItem spellCheckToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem findDoubleWordsToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator9; - private System.Windows.Forms.ToolStripMenuItem GetDictionariesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem addWordToNameListToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSynchronization; - private System.Windows.Forms.ToolStripMenuItem visualSyncToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemPointSync; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAdjustAllTimes; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAutoTranslate; - private System.Windows.Forms.ToolStripMenuItem translateByGoogleToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem translateFromSwedishToDanishToolStripMenuItem; - private System.Windows.Forms.Timer timerStillTyping; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemVideo; - private System.Windows.Forms.ToolStripMenuItem openVideoToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; - private System.Windows.Forms.ToolStripMenuItem showhideVideoToolStripMenuItem; - private System.Windows.Forms.Label labelVideoPosition; - private Controls.TimeUpDown timeUpDownVideoPosition; - private System.Windows.Forms.TabControl tabControlButtons; - private System.Windows.Forms.TabPage tabPageTranslate; - private System.Windows.Forms.GroupBox groupBoxTranslateSearch; - private System.Windows.Forms.Button buttonGoogleTranslateIt; - private System.Windows.Forms.Button buttonGoogleIt; - private System.Windows.Forms.TextBox textBoxSearchWord; - private System.Windows.Forms.GroupBox groupBoxAutoContinue; - private System.Windows.Forms.ComboBox comboBoxAutoContinue; - private System.Windows.Forms.Label labelAutoContinueDelay; - private System.Windows.Forms.CheckBox checkBoxAutoContinue; - private System.Windows.Forms.GroupBox groupBoxAutoRepeat; - private System.Windows.Forms.ComboBox comboBoxAutoRepeat; - private System.Windows.Forms.Label labelAutoRepeatCount; - private System.Windows.Forms.CheckBox checkBoxAutoRepeatOn; - private System.Windows.Forms.Button buttonStop; - private System.Windows.Forms.Button buttonPlayPrevious; - private System.Windows.Forms.Button buttonPlayCurrent; - private System.Windows.Forms.Button buttonPlayNext; - private System.Windows.Forms.TabPage tabPageCreate; - private System.Windows.Forms.TabPage tabPageAdjust; - private System.Windows.Forms.Button buttonAdjustGoToPosAndPause; - private System.Windows.Forms.Button buttonAdjustPlayBefore; - private System.Windows.Forms.Button buttonAdjustSetEndTime; - private System.Windows.Forms.Button buttonSetEndAndGoToNext; - private System.Windows.Forms.Button buttonSetStartAndOffsetRest; - private System.Windows.Forms.Button buttonAdjustSetStartTime; - private System.Windows.Forms.Label labelTranslateTip; - private System.Windows.Forms.Button buttonCustomUrl1; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemOpenContainingFolder; - private System.Windows.Forms.NumericUpDown numericUpDownSec1; - private System.Windows.Forms.Button buttonForward1; - private System.Windows.Forms.Label labelVideoPosition2; - private Controls.TimeUpDown timeUpDownVideoPositionAdjust; - private System.Windows.Forms.Button buttonAdjustSecForward1; - private System.Windows.Forms.NumericUpDown numericUpDownSecAdjust1; - private System.Windows.Forms.Button buttonAdjustSecBack1; - private System.Windows.Forms.Button buttonForward2; - private System.Windows.Forms.NumericUpDown numericUpDownSec2; - private System.Windows.Forms.Button buttonSecBack2; - private System.Windows.Forms.Button buttonAdjustSecForward2; - private System.Windows.Forms.NumericUpDown numericUpDownSecAdjust2; - private System.Windows.Forms.Button buttonAdjustSecBack2; - private System.Windows.Forms.CheckBox checkBoxSyncListViewWithVideoWhilePlaying; - private System.Windows.Forms.Label labelAdjustF10; - private System.Windows.Forms.Label labelAdjustF9; - private System.Windows.Forms.Label labelAdjustF11; - private System.Windows.Forms.Label labelAdjustF12; - private System.Windows.Forms.Label labelCreateF12; - private System.Windows.Forms.Label labelCreateF11; - private System.Windows.Forms.Label labelCreateF10; - private System.Windows.Forms.Label labelCreateF9; - private System.Windows.Forms.ToolStripMenuItem translatepoweredByMicrosoftToolStripMenuItem; - private System.Windows.Forms.ToolStripButton toolStripButtonToggleWaveform; - private Controls.VideoPlayerContainer mediaPlayer; - private System.Windows.Forms.Panel panelVideoPlayer; - private Controls.AudioVisualizer audioVisualizer; - private System.Windows.Forms.Timer timerWaveform; - private System.Windows.Forms.ContextMenuStrip contextMenuStripWaveform; - private System.Windows.Forms.ToolStripMenuItem addParagraphHereToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem deleteParagraphToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem splitToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem mergeWithPreviousToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem mergeWithNextToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemWaveformPlaySelection; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator11; - private System.Windows.Forms.Panel panelWaveformControls; - private System.Windows.Forms.ToolStrip toolStripWaveControls; - private System.Windows.Forms.ToolStripButton toolStripButtonWaveformZoomIn; - private System.Windows.Forms.ToolStripComboBox toolStripComboBoxWaveform; - private System.Windows.Forms.ToolStripButton toolStripButtonWaveformZoomOut; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator16; - private System.Windows.Forms.ToolStripButton toolStripButtonWaveformPause; - private System.Windows.Forms.ToolStripButton toolStripButtonWaveformPlay; - private System.Windows.Forms.TrackBar trackBarWaveformPosition; - private System.Windows.Forms.Label labelVideoInfo; - private System.Windows.Forms.ToolStripMenuItem showhideWaveformToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportBluRaySup; - private System.Windows.Forms.Label labelCharactersPerSecond; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemNetworking; - private System.Windows.Forms.ToolStripMenuItem startServerToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem joinSessionToolStripMenuItem; - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusNetworking; - private System.Windows.Forms.ToolStripMenuItem leaveSessionToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem showSessionKeyLogToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem chatToolStripMenuItem; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.SplitContainer splitContainerMain; - private System.Windows.Forms.ToolStripMenuItem undockVideoControlsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem redockVideoControlsToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator19; - private System.Windows.Forms.ToolStripButton toolStripButtonLockCenter; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertSubtitle; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAutoSplitLongLines; - private System.Windows.Forms.ContextMenuStrip contextMenuStripEmpty; - private System.Windows.Forms.ToolStripMenuItem insertLineToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem closeVideoToolStripMenuItem; - private System.Windows.Forms.Label labelSingleLine; - private System.Windows.Forms.Label labelAlternateText; - private System.Windows.Forms.Label labelAlternateCharactersPerSecond; - private System.Windows.Forms.Label labelTextAlternateLineTotal; - private System.Windows.Forms.Label labelAlternateSingleLine; - private System.Windows.Forms.Label labelTextAlternateLineLengths; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator20; - private System.Windows.Forms.ToolStripMenuItem saveOriginalToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveOriginalAstoolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem openOriginalToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeOriginalToolStripMenuItem; - private System.Windows.Forms.ToolStripSplitButton toolStripSplitButtonPlayRate; - private System.Windows.Forms.ImageList imageListPlayRate; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSetAudioTrack; - private System.Windows.Forms.Button buttonSplitLine; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemChangeFrameRate2; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemCopySourceText; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator21; - private System.Windows.Forms.ToolStripMenuItem editSelectAllToolStripMenuItem; - private System.Windows.Forms.ContextMenuStrip contextMenuStripTextBoxListView; - private System.Windows.Forms.ToolStripMenuItem cutToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSplitTextAtCursor; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator18; - private System.Windows.Forms.ToolStripMenuItem selectAllToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator17; - private System.Windows.Forms.ToolStripMenuItem normalToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem boldToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem italicToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem underlineToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem colorToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem fontNameToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator22; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExport; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportPngXml; - private System.Windows.Forms.ToolStripMenuItem pointSyncViaOtherSubtitleToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemGoogleMicrosoftTranslateSelLine; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator23; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMakeEmptyFromCurrent; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator24; - private System.Windows.Forms.ToolStripMenuItem showWaveformAndSpectrogramToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem showOnlyWaveformToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem showOnlySpectrogramToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator26; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertUnicodeSymbol; - private System.Windows.Forms.ToolStripMenuItem setStylesForSelectedLinesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem FindDoubleLinesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem eBUSTLToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem pACScreenElectronicsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemCavena890; - private Controls.SETextBox textBoxListViewTextAlternate; - private System.Windows.Forms.ToolStripMenuItem textCharssecToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem plainTextToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem bluraySupToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem vobSubsubidxToolStripMenuItem; - private System.Windows.Forms.Timer timerTextUndo; - private System.Windows.Forms.Timer timerAlternateTextUndo; - private System.Windows.Forms.ToolStripMenuItem adobeEncoreFABImageScriptToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMergeDialog; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSurroundWithMusicSymbols; - private System.Windows.Forms.ToolStripMenuItem superscriptToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem subscriptToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImagePerFrame; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemApplyDurationLimits; - private System.Windows.Forms.ToolStripMenuItem generateDatetimeInfoFromVideoToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator25; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRightToLeftMode; - private System.Windows.Forms.ToolStripMenuItem joinSubtitlesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemReverseRightToLeftStartEnd; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportCapMakerPlus; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportCheetahCap; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportCaptionInc; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportUltech130; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAssStyles; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSubStationAlpha; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAlignment; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRestoreAutoBackup; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStatistics; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDCinemaProperties; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTextTimeCodePair; - private System.Windows.Forms.ToolStripMenuItem textWordsPerMinutewpmToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTTProperties; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSaveSelectedLines; - private System.Windows.Forms.Button buttonCustomUrl2; - private System.Windows.Forms.ToolStripMenuItem addParagraphAndPasteToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorGuessTimeCodes; - private System.Windows.Forms.ToolStripMenuItem guessTimeCodesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem DvdStudioProStl; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemUndo; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRedo; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemShowOriginalInPreview; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemPlugins; - private System.Windows.Forms.ToolStripMenuItem seekSilenceToolStripMenuItem; - private System.Windows.Forms.SplitContainer splitContainerListViewAndText; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemColumn; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemColumnDeleteText; - private System.Windows.Forms.ToolStripMenuItem ShiftTextCellsDownToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemPasteSpecial; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemColumnImportText; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertTextFromSub; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemOpenKeepVideo; - private System.Windows.Forms.ToolStripMenuItem changeSpeedInPercentToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAvidStl; - private System.Windows.Forms.ToolStripMenuItem columnDeleteTextOnlyToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemBatchConvert; - private System.Windows.Forms.ToolStripMenuItem copyOriginalTextToCurrentToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMergeDuplicateText; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSpumux; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemWebVTT; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemWebVttVoice; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemPreview; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorWebVTT; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemModifySelection; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSpellCheckFromCurrentLine; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportXSub; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportOcrHardSub; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportFcpIImage; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemNuendoProperties; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDost; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMeasurementConverter; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportChapters; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportSceneChanges; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRemoveSceneChanges; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSubtitlesBridgeGaps; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemOpenDvd; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemFcpProperties; - private System.Windows.Forms.ToolStripMenuItem styleToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemFocusTextbox; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorAscOrDesc; - private System.Windows.Forms.ToolStripMenuItem AscendingToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem descendingToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorExportCustomText; - private System.Windows.Forms.ToolStripMenuItem exportCustomTextFormatToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSetLanguage; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertUnicodeControlCharacters; - private System.Windows.Forms.ToolStripMenuItem leftToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem righttoleftMarkToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem startOfLefttorightEmbeddingLREToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem startOfRighttoleftEmbeddingRLEToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem startOfLefttorightOverrideLROToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem startOfRighttoleftOverrideRLOToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRtlUnicodeControlChars; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRemoveUnicodeControlChars; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportImages; - private System.Windows.Forms.ToolStripButton toolStripButtonRemoveTextForHi; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportDcinemaInterop; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMergeLinesWithSameTimeCodes; - private System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripMenuItemSplitterCheckForUpdates; - private System.Windows.Forms.ToolStripMenuItem setVideoOffsetToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDvdStudioProProperties; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemEdlClipName; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAddWaveformBatch; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportBdTextSt; - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelProgress; - private System.Windows.Forms.ToolStripMenuItem uniPacExportToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportAyato; - private System.Windows.Forms.ToolStripButton toolStripButtonFixCommonErrors; - private System.Windows.Forms.ToolStripMenuItem removeSceneChangeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem addSceneChangeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem netflixQualityCheckToolStripMenuItem; - private System.Windows.Forms.ToolStripButton toolStripButtonNetflixQualityCheck; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemEdl; - private System.Windows.Forms.ToolStripMenuItem setActorForSelectedLinesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSetRegion; - private System.Windows.Forms.ToolStripMenuItem insertSubtitleHereToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem actorToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemFcpXmlAdvanced; - private System.Windows.Forms.Label labelNextWord; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemOpenVideoFromUrl; - private System.Windows.Forms.ToolStripMenuItem smpteTimeModedropFrameToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem moveTextUpToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem moveTextDownToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem generateTextFromCurrentVideoToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSplitViaWaveform; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemEbuProperties; - private System.Windows.Forms.ToolStripMenuItem boxToolStripMenuItem; - private System.Windows.Forms.ImageList imageListBookmarks; - private System.Windows.Forms.Panel panelBookmark; - private System.Windows.Forms.Label labelBookmark; - private System.Windows.Forms.PictureBox pictureBoxBookmark; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTranslateSelected; - private System.Windows.Forms.ToolStripMenuItem googleTranslateToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem microsoftBingTranslateToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemBookmark; - private System.Windows.Forms.ToolStripMenuItem removeAllFormattingsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeBoldToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeItalicToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeUnderlineToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeColorToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeFontNameToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeAlignmentToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemBouten; - private System.Windows.Forms.ToolStripMenuItem boutendotbeforeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem boutendotafterToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem boutendotoutsideToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem boutenfilledcircleoutsideToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem boutenopencircleoutsideToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem boutenopendotoutsideToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem boutenfilledsesameoutsideToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem boutenopensesameoutsideToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem boutenautooutsideToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem boutenautoToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemHorizontalDigits; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSetParagraphAsSelection; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRuby; - private System.Windows.Forms.Label labelSingleLinePixels; - private System.Windows.Forms.Label labelAlternateSingleLinePixels; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; - private System.Windows.Forms.ToolStripMenuItem extendBeforeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem extendAfterToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem extendToPreviousToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem extendToNextToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator6; - private System.Windows.Forms.ToolStripMenuItem goToPreviousSubtitleStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem goToNextSubtitleStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem dCinemaSMPTE2014ToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem boxToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAssaStyles; - private System.Windows.Forms.ToolStripMenuItem openSecondSubtitleToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem aSSStylesToolStripMenuItem; - } +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class Main + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + if (disposing) + { + if (_networkSession != null) + { + _networkSession.Dispose(); + _networkSession = null; + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main)); + TimeCode timeCode4 = new TimeCode(); + TimeCode timeCode5 = new TimeCode(); + TimeCode timeCode6 = new TimeCode(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.labelStatus = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripSelected = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabelProgress = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusNetworking = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStrip1 = new System.Windows.Forms.ToolStrip(); + this.toolStripButtonFileNew = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonFileOpen = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonSave = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonSaveAs = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparatorFindReplace = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripButtonFind = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonReplace = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparatorFixSyncSpell = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripButtonFixCommonErrors = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonRemoveTextForHi = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonVisualSync = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonSpellCheck = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonNetflixQualityCheck = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonSettings = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparatorHelp = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripButtonHelp = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparatorToggle = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripButtonToggleWaveform = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonToggleVideo = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparatorSubtitleFormat = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripLabelSubtitleFormat = new System.Windows.Forms.ToolStripLabel(); + this.comboBoxSubtitleFormats = new System.Windows.Forms.ToolStripComboBox(); + this.toolStripSeparatorEncoding = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripLabelEncoding = new System.Windows.Forms.ToolStripLabel(); + this.comboBoxEncoding = new System.Windows.Forms.ToolStripComboBox(); + this.toolStripSeparatorFrameRate = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripLabelFrameRate = new System.Windows.Forms.ToolStripLabel(); + this.toolStripComboBoxFrameRate = new System.Windows.Forms.ToolStripComboBox(); + this.toolStripButtonGetFrameRate = new System.Windows.Forms.ToolStripButton(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemOpenKeepVideo = new System.Windows.Forms.ToolStripMenuItem(); + this.reopenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemRestoreAutoBackup = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemDCinemaProperties = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemTTProperties = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemNuendoProperties = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemFcpProperties = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSubStationAlpha = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemAssaStyles = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemEbuProperties = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemDvdStudioProProperties = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator20 = new System.Windows.Forms.ToolStripSeparator(); + this.openOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveOriginalAstoolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeOriginalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemOpenContainingFolder = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemCompare = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemStatistics = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemPlugins = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemImportDvdSubtitles = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSubIdx = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemImportBluRaySup = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemImportXSub = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemImportOcrHardSub = new System.Windows.Forms.ToolStripMenuItem(); + this.matroskaImportStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemManualAnsi = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemImportText = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemImportImages = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemImportTimeCodes = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator22 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemExport = new System.Windows.Forms.ToolStripMenuItem(); + this.adobeEncoreFABImageScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemAvidStl = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemExportAyato = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemExportPngXml = new System.Windows.Forms.ToolStripMenuItem(); + this.bluraySupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemExportBdTextSt = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemExportCapMakerPlus = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemExportCaptionInc = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemCavena890 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemExportCheetahCap = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemExportDcinemaInterop = new System.Windows.Forms.ToolStripMenuItem(); + this.dCinemaSMPTE2014ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemDost = new System.Windows.Forms.ToolStripMenuItem(); + this.DvdStudioProStl = new System.Windows.Forms.ToolStripMenuItem(); + this.eBUSTLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemEdl = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemEdlClipName = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemExportFcpIImage = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemFcpXmlAdvanced = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemImagePerFrame = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemTextTimeCodePair = new System.Windows.Forms.ToolStripMenuItem(); + this.pACScreenElectronicsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.uniPacExportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.plainTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSpumux = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemExportUltech130 = new System.Windows.Forms.ToolStripMenuItem(); + this.vobSubsubidxToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparatorExportCustomText = new System.Windows.Forms.ToolStripSeparator(); + this.exportCustomTextFormatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator(); + this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemUndo = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemRedo = new System.Windows.Forms.ToolStripMenuItem(); + this.showHistoryforUndoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator14 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemInsertUnicodeCharacter = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparatorInsertUnicodeCharacter = new System.Windows.Forms.ToolStripSeparator(); + this.findToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.findNextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.replaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.multipleReplaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.gotoLineNumberToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemShowOriginalInPreview = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator25 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemRightToLeftMode = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemRtlUnicodeControlChars = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemRemoveUnicodeControlChars = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemReverseRightToLeftStartEnd = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator21 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemModifySelection = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); + this.editSelectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.adjustDisplayTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemApplyDurationLimits = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSubtitlesBridgeGaps = new System.Windows.Forms.ToolStripMenuItem(); + this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.fixToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.startNumberingFromToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeTextForHearImpairedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ChangeCasingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemAutoMergeShortLines = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemMergeDuplicateText = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemMergeLinesWithSameTimeCodes = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemAutoSplitLongLines = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSortBy = new System.Windows.Forms.ToolStripMenuItem(); + this.sortNumberToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.sortStartTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.sortEndTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.sortDisplayTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.sortTextAlphabeticallytoolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.sortTextMaxLineLengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.sortTextTotalLengthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.sortTextNumberOfLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.textCharssecToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.textWordsPerMinutewpmToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.actorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.styleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparatorAscOrDesc = new System.Windows.Forms.ToolStripSeparator(); + this.AscendingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.descendingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.netflixQualityCheckToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator23 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemMakeEmptyFromCurrent = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemBatchConvert = new System.Windows.Forms.ToolStripMenuItem(); + this.generateDatetimeInfoFromVideoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemMeasurementConverter = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.splitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.appendTextVisuallyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.joinSubtitlesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSpellCheckMain = new System.Windows.Forms.ToolStripMenuItem(); + this.spellCheckToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSpellCheckFromCurrentLine = new System.Windows.Forms.ToolStripMenuItem(); + this.findDoubleWordsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.FindDoubleLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); + this.GetDictionariesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addWordToNameListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemVideo = new System.Windows.Forms.ToolStripMenuItem(); + this.openVideoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemOpenVideoFromUrl = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemOpenDvd = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSetAudioTrack = new System.Windows.Forms.ToolStripMenuItem(); + this.closeVideoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openSecondSubtitleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.setVideoOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.smpteTimeModedropFrameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemImportChapters = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemImportSceneChanges = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemRemoveSceneChanges = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemAddWaveformBatch = new System.Windows.Forms.ToolStripMenuItem(); + this.generateTextFromCurrentVideoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); + this.showhideWaveformToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.showhideVideoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator19 = new System.Windows.Forms.ToolStripSeparator(); + this.undockVideoControlsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.redockVideoControlsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSynchronization = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemAdjustAllTimes = new System.Windows.Forms.ToolStripMenuItem(); + this.visualSyncToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemPointSync = new System.Windows.Forms.ToolStripMenuItem(); + this.pointSyncViaOtherSubtitleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemChangeFrameRate2 = new System.Windows.Forms.ToolStripMenuItem(); + this.changeSpeedInPercentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemAutoTranslate = new System.Windows.Forms.ToolStripMenuItem(); + this.translatepoweredByMicrosoftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.translateByGoogleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.translateFromSwedishToDanishToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.changeLanguageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemNetworking = new System.Windows.Forms.ToolStripMenuItem(); + this.startServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.joinSessionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.chatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.showSessionKeyLogToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.leaveSessionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSplitterCheckForUpdates = new System.Windows.Forms.ToolStripSeparator(); + this.helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.contextMenuStripListview = new System.Windows.Forms.ContextMenuStrip(this.components); + this.setStylesForSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.setActorForSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemAssStyles = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSetRegion = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSetLanguage = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemWebVTT = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemPreview = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemDelete = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInsertBefore = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInsertAfter = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInsertSubtitle = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemCopySourceText = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemColumn = new System.Windows.Forms.ToolStripMenuItem(); + this.columnDeleteTextOnlyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemColumnDeleteText = new System.Windows.Forms.ToolStripMenuItem(); + this.ShiftTextCellsDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInsertTextFromSub = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemColumnImportText = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemPasteSpecial = new System.Windows.Forms.ToolStripMenuItem(); + this.copyOriginalTextToCurrentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.moveTextUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.moveTextDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemBookmark = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); + this.splitLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemMergeLines = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemMergeDialog = new System.Windows.Forms.ToolStripMenuItem(); + this.mergeBeforeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mergeAfterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.extendBeforeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.extendAfterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); + this.removeFormattinglToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeAllFormattingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeBoldToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeItalicToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeUnderlineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeColorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeFontNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeAlignmentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boldToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.italicToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boxToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.underlineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.colorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemFont = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemAlignment = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSurroundWithMusicSymbols = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemAutoBreakLines = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemUnbreakLines = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparatorBreakLines = new System.Windows.Forms.ToolStripSeparator(); + this.typeEffectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.karokeeEffectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparatorAdvancedFunctions = new System.Windows.Forms.ToolStripSeparator(); + this.showSelectedLinesEarlierlaterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.visualSyncSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemGoogleMicrosoftTranslateSelLine = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemTranslateSelected = new System.Windows.Forms.ToolStripMenuItem(); + this.googleTranslateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.microsoftBingTranslateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.adjustDisplayTimeForSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.fixCommonErrorsInSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.changeCasingForSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSaveSelectedLines = new System.Windows.Forms.ToolStripMenuItem(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.colorDialog1 = new System.Windows.Forms.ColorDialog(); + this.groupBoxVideo = new System.Windows.Forms.GroupBox(); + this.labelNextWord = new System.Windows.Forms.Label(); + this.audioVisualizer = new Nikse.SubtitleEdit.Controls.AudioVisualizer(); + this.checkBoxSyncListViewWithVideoWhilePlaying = new System.Windows.Forms.CheckBox(); + this.labelVideoInfo = new System.Windows.Forms.Label(); + this.trackBarWaveformPosition = new System.Windows.Forms.TrackBar(); + this.panelWaveformControls = new System.Windows.Forms.Panel(); + this.toolStripWaveControls = new System.Windows.Forms.ToolStrip(); + this.toolStripButtonWaveformZoomOut = new System.Windows.Forms.ToolStripButton(); + this.toolStripComboBoxWaveform = new System.Windows.Forms.ToolStripComboBox(); + this.toolStripButtonWaveformZoomIn = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator16 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripButtonWaveformPause = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonWaveformPlay = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonLockCenter = new System.Windows.Forms.ToolStripButton(); + this.toolStripSplitButtonPlayRate = new System.Windows.Forms.ToolStripSplitButton(); + this.tabControlButtons = new System.Windows.Forms.TabControl(); + this.tabPageTranslate = new System.Windows.Forms.TabPage(); + this.labelTranslateTip = new System.Windows.Forms.Label(); + this.groupBoxTranslateSearch = new System.Windows.Forms.GroupBox(); + this.buttonCustomUrl2 = new System.Windows.Forms.Button(); + this.buttonCustomUrl1 = new System.Windows.Forms.Button(); + this.buttonGoogleTranslateIt = new System.Windows.Forms.Button(); + this.buttonGoogleIt = new System.Windows.Forms.Button(); + this.textBoxSearchWord = new System.Windows.Forms.TextBox(); + this.groupBoxAutoContinue = new System.Windows.Forms.GroupBox(); + this.comboBoxAutoContinue = new System.Windows.Forms.ComboBox(); + this.labelAutoContinueDelay = new System.Windows.Forms.Label(); + this.checkBoxAutoContinue = new System.Windows.Forms.CheckBox(); + this.buttonStop = new System.Windows.Forms.Button(); + this.groupBoxAutoRepeat = new System.Windows.Forms.GroupBox(); + this.comboBoxAutoRepeat = new System.Windows.Forms.ComboBox(); + this.labelAutoRepeatCount = new System.Windows.Forms.Label(); + this.checkBoxAutoRepeatOn = new System.Windows.Forms.CheckBox(); + this.buttonPlayPrevious = new System.Windows.Forms.Button(); + this.buttonPlayCurrent = new System.Windows.Forms.Button(); + this.buttonPlayNext = new System.Windows.Forms.Button(); + this.tabPageCreate = new System.Windows.Forms.TabPage(); + this.timeUpDownVideoPosition = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.buttonGotoSub = new System.Windows.Forms.Button(); + this.buttonBeforeText = new System.Windows.Forms.Button(); + this.buttonSetEnd = new System.Windows.Forms.Button(); + this.buttonInsertNewText = new System.Windows.Forms.Button(); + this.buttonSetStartTime = new System.Windows.Forms.Button(); + this.labelCreateF12 = new System.Windows.Forms.Label(); + this.labelCreateF11 = new System.Windows.Forms.Label(); + this.labelCreateF10 = new System.Windows.Forms.Label(); + this.labelCreateF9 = new System.Windows.Forms.Label(); + this.buttonForward2 = new System.Windows.Forms.Button(); + this.numericUpDownSec2 = new System.Windows.Forms.NumericUpDown(); + this.buttonSecBack2 = new System.Windows.Forms.Button(); + this.buttonForward1 = new System.Windows.Forms.Button(); + this.numericUpDownSec1 = new System.Windows.Forms.NumericUpDown(); + this.labelVideoPosition = new System.Windows.Forms.Label(); + this.buttonSecBack1 = new System.Windows.Forms.Button(); + this.tabPageAdjust = new System.Windows.Forms.TabPage(); + this.timeUpDownVideoPositionAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.buttonAdjustSetEndTime = new System.Windows.Forms.Button(); + this.buttonSetEndAndGoToNext = new System.Windows.Forms.Button(); + this.buttonSetStartAndOffsetRest = new System.Windows.Forms.Button(); + this.buttonAdjustSetStartTime = new System.Windows.Forms.Button(); + this.labelAdjustF12 = new System.Windows.Forms.Label(); + this.labelAdjustF11 = new System.Windows.Forms.Label(); + this.labelAdjustF10 = new System.Windows.Forms.Label(); + this.labelAdjustF9 = new System.Windows.Forms.Label(); + this.buttonAdjustSecForward2 = new System.Windows.Forms.Button(); + this.numericUpDownSecAdjust2 = new System.Windows.Forms.NumericUpDown(); + this.buttonAdjustSecBack2 = new System.Windows.Forms.Button(); + this.buttonAdjustSecForward1 = new System.Windows.Forms.Button(); + this.numericUpDownSecAdjust1 = new System.Windows.Forms.NumericUpDown(); + this.buttonAdjustSecBack1 = new System.Windows.Forms.Button(); + this.labelVideoPosition2 = new System.Windows.Forms.Label(); + this.buttonAdjustGoToPosAndPause = new System.Windows.Forms.Button(); + this.buttonAdjustPlayBefore = new System.Windows.Forms.Button(); + this.ShowSubtitleTimer = new System.Windows.Forms.Timer(this.components); + this.timerAutoDuration = new System.Windows.Forms.Timer(this.components); + this.timerAutoContinue = new System.Windows.Forms.Timer(this.components); + this.timerStillTyping = new System.Windows.Forms.Timer(this.components); + this.timerWaveform = new System.Windows.Forms.Timer(this.components); + this.contextMenuStripWaveform = new System.Windows.Forms.ContextMenuStrip(this.components); + this.addParagraphHereToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addParagraphAndPasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSetParagraphAsSelection = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemFocusTextbox = new System.Windows.Forms.ToolStripMenuItem(); + this.goToPreviousSubtitleStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.goToNextSubtitleStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteParagraphToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.splitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.mergeWithPreviousToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mergeWithNextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator(); + this.extendToPreviousToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.extendToNextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemWaveformPlaySelection = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator24 = new System.Windows.Forms.ToolStripSeparator(); + this.showWaveformAndSpectrogramToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.showOnlyWaveformToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.showOnlySpectrogramToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparatorGuessTimeCodes = new System.Windows.Forms.ToolStripSeparator(); + this.removeSceneChangeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addSceneChangeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.guessTimeCodesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.seekSilenceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.insertSubtitleHereToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.splitContainerMain = new System.Windows.Forms.SplitContainer(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.tabControlSubtitle = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.splitContainerListViewAndText = new System.Windows.Forms.SplitContainer(); + this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.imageListBookmarks = new System.Windows.Forms.ImageList(this.components); + this.groupBoxEdit = new System.Windows.Forms.GroupBox(); + this.labelAlternateSingleLinePixels = new System.Windows.Forms.Label(); + this.labelSingleLinePixels = new System.Windows.Forms.Label(); + this.panelBookmark = new System.Windows.Forms.Panel(); + this.labelBookmark = new System.Windows.Forms.Label(); + this.pictureBoxBookmark = new System.Windows.Forms.PictureBox(); + this.labelSingleLine = new System.Windows.Forms.Label(); + this.labelAlternateSingleLine = new System.Windows.Forms.Label(); + this.labelDurationWarning = new System.Windows.Forms.Label(); + this.labelStartTimeWarning = new System.Windows.Forms.Label(); + this.buttonSplitLine = new System.Windows.Forms.Button(); + this.labelAlternateCharactersPerSecond = new System.Windows.Forms.Label(); + this.labelTextAlternateLineTotal = new System.Windows.Forms.Label(); + this.labelTextAlternateLineLengths = new System.Windows.Forms.Label(); + this.labelAlternateText = new System.Windows.Forms.Label(); + this.labelText = new System.Windows.Forms.Label(); + this.textBoxListViewTextAlternate = new Nikse.SubtitleEdit.Controls.SETextBox(); + this.contextMenuStripTextBoxListView = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemWebVttVoice = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparatorWebVTT = new System.Windows.Forms.ToolStripSeparator(); + this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSplitTextAtCursor = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSplitViaWaveform = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator18 = new System.Windows.Forms.ToolStripSeparator(); + this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator17 = new System.Windows.Forms.ToolStripSeparator(); + this.normalToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.boldToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.italicToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.boxToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.underlineToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.colorToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemHorizontalDigits = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemBouten = new System.Windows.Forms.ToolStripMenuItem(); + this.boutendotbeforeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boutendotafterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boutendotoutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boutenfilledcircleoutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boutenopencircleoutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boutenopendotoutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boutenfilledsesameoutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boutenopensesameoutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boutenautooutsideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.boutenautoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemRuby = new System.Windows.Forms.ToolStripMenuItem(); + this.fontNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator26 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemInsertUnicodeSymbol = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInsertUnicodeControlCharacters = new System.Windows.Forms.ToolStripMenuItem(); + this.leftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.righttoleftMarkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.startOfLefttorightEmbeddingLREToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.startOfRighttoleftEmbeddingRLEToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.startOfLefttorightOverrideLROToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.startOfRighttoleftOverrideRLOToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.superscriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.subscriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.buttonAutoBreak = new System.Windows.Forms.Button(); + this.labelTextLineLengths = new System.Windows.Forms.Label(); + this.labelTextLineTotal = new System.Windows.Forms.Label(); + this.labelCharactersPerSecond = new System.Windows.Forms.Label(); + this.buttonUnBreak = new System.Windows.Forms.Button(); + this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.numericUpDownDuration = new System.Windows.Forms.NumericUpDown(); + this.buttonPrevious = new System.Windows.Forms.Button(); + this.buttonNext = new System.Windows.Forms.Button(); + this.labelStartTime = new System.Windows.Forms.Label(); + this.textBoxListViewText = new Nikse.SubtitleEdit.Controls.SETextBox(); + this.labelDuration = new System.Windows.Forms.Label(); + this.labelAutoDuration = new System.Windows.Forms.Label(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.textBoxSource = new System.Windows.Forms.TextBox(); + this.panelVideoPlayer = new System.Windows.Forms.Panel(); + this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); + this.contextMenuStripEmpty = new System.Windows.Forms.ContextMenuStrip(this.components); + this.insertLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.imageListPlayRate = new System.Windows.Forms.ImageList(this.components); + this.timerTextUndo = new System.Windows.Forms.Timer(this.components); + this.timerAlternateTextUndo = new System.Windows.Forms.Timer(this.components); + this.aSSStylesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.statusStrip1.SuspendLayout(); + this.toolStrip1.SuspendLayout(); + this.menuStrip1.SuspendLayout(); + this.contextMenuStripListview.SuspendLayout(); + this.groupBoxVideo.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.trackBarWaveformPosition)).BeginInit(); + this.panelWaveformControls.SuspendLayout(); + this.toolStripWaveControls.SuspendLayout(); + this.tabControlButtons.SuspendLayout(); + this.tabPageTranslate.SuspendLayout(); + this.groupBoxTranslateSearch.SuspendLayout(); + this.groupBoxAutoContinue.SuspendLayout(); + this.groupBoxAutoRepeat.SuspendLayout(); + this.tabPageCreate.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSec2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSec1)).BeginInit(); + this.tabPageAdjust.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSecAdjust2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSecAdjust1)).BeginInit(); + this.contextMenuStripWaveform.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainerMain)).BeginInit(); + this.splitContainerMain.Panel1.SuspendLayout(); + this.splitContainerMain.Panel2.SuspendLayout(); + this.splitContainerMain.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.tabControlSubtitle.SuspendLayout(); + this.tabPage1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainerListViewAndText)).BeginInit(); + this.splitContainerListViewAndText.Panel1.SuspendLayout(); + this.splitContainerListViewAndText.Panel2.SuspendLayout(); + this.splitContainerListViewAndText.SuspendLayout(); + this.groupBoxEdit.SuspendLayout(); + this.panelBookmark.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBookmark)).BeginInit(); + this.contextMenuStripTextBoxListView.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).BeginInit(); + this.tabPage2.SuspendLayout(); + this.panelVideoPlayer.SuspendLayout(); + this.contextMenuStripEmpty.SuspendLayout(); + this.SuspendLayout(); + // + // statusStrip1 + // + this.statusStrip1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.labelStatus, + this.toolStripSelected, + this.toolStripStatusLabelProgress, + this.toolStripStatusNetworking}); + this.statusStrip1.Location = new System.Drawing.Point(0, 624); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(975, 22); + this.statusStrip1.TabIndex = 4; + this.statusStrip1.Text = "statusStrip1"; + // + // labelStatus + // + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(0, 17); + this.labelStatus.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.labelStatus.Click += new System.EventHandler(this.labelStatus_Click); + // + // toolStripSelected + // + this.toolStripSelected.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripSelected.Name = "toolStripSelected"; + this.toolStripSelected.Size = new System.Drawing.Size(746, 17); + this.toolStripSelected.Spring = true; + this.toolStripSelected.Text = "toolStripSelected"; + this.toolStripSelected.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.toolStripSelected.Click += new System.EventHandler(this.toolStripSelected_Click); + // + // toolStripStatusLabelProgress + // + this.toolStripStatusLabelProgress.Name = "toolStripStatusLabelProgress"; + this.toolStripStatusLabelProgress.Size = new System.Drawing.Size(166, 17); + this.toolStripStatusLabelProgress.Text = "toolStripStatusLabelProgress"; + this.toolStripStatusLabelProgress.Visible = false; + // + // toolStripStatusNetworking + // + this.toolStripStatusNetworking.Image = global::Nikse.SubtitleEdit.Properties.Resources.connect; + this.toolStripStatusNetworking.Name = "toolStripStatusNetworking"; + this.toolStripStatusNetworking.Padding = new System.Windows.Forms.Padding(50, 0, 0, 0); + this.toolStripStatusNetworking.Size = new System.Drawing.Size(214, 17); + this.toolStripStatusNetworking.Text = "toolStripStatusNetworking"; + this.toolStripStatusNetworking.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.toolStripStatusNetworking.TextImageRelation = System.Windows.Forms.TextImageRelation.TextBeforeImage; + this.toolStripStatusNetworking.Click += new System.EventHandler(this.toolStripStatusNetworking_Click); + // + // toolStrip1 + // + this.toolStrip1.AutoSize = false; + this.toolStrip1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripButtonFileNew, + this.toolStripButtonFileOpen, + this.toolStripButtonSave, + this.toolStripButtonSaveAs, + this.toolStripSeparatorFindReplace, + this.toolStripButtonFind, + this.toolStripButtonReplace, + this.toolStripSeparatorFixSyncSpell, + this.toolStripButtonFixCommonErrors, + this.toolStripButtonRemoveTextForHi, + this.toolStripButtonVisualSync, + this.toolStripButtonSpellCheck, + this.toolStripButtonNetflixQualityCheck, + this.toolStripButtonSettings, + this.toolStripSeparatorHelp, + this.toolStripButtonHelp, + this.toolStripSeparatorToggle, + this.toolStripButtonToggleWaveform, + this.toolStripButtonToggleVideo, + this.toolStripSeparatorSubtitleFormat, + this.toolStripLabelSubtitleFormat, + this.comboBoxSubtitleFormats, + this.toolStripSeparatorEncoding, + this.toolStripLabelEncoding, + this.comboBoxEncoding, + this.toolStripSeparatorFrameRate, + this.toolStripLabelFrameRate, + this.toolStripComboBoxFrameRate, + this.toolStripButtonGetFrameRate}); + this.toolStrip1.Location = new System.Drawing.Point(0, 24); + this.toolStrip1.Name = "toolStrip1"; + this.toolStrip1.Size = new System.Drawing.Size(975, 40); + this.toolStrip1.TabIndex = 5; + this.toolStrip1.Text = "toolStrip1"; + // + // toolStripButtonFileNew + // + this.toolStripButtonFileNew.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonFileNew.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.toolStripButtonFileNew.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonFileNew.Image"))); + this.toolStripButtonFileNew.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonFileNew.ImageTransparentColor = System.Drawing.Color.Transparent; + this.toolStripButtonFileNew.Name = "toolStripButtonFileNew"; + this.toolStripButtonFileNew.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonFileNew.Text = "New"; + this.toolStripButtonFileNew.ToolTipText = "New"; + this.toolStripButtonFileNew.Click += new System.EventHandler(this.ToolStripButtonFileNewClick); + // + // toolStripButtonFileOpen + // + this.toolStripButtonFileOpen.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonFileOpen.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.toolStripButtonFileOpen.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonFileOpen.Image"))); + this.toolStripButtonFileOpen.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonFileOpen.ImageTransparentColor = System.Drawing.Color.Transparent; + this.toolStripButtonFileOpen.Name = "toolStripButtonFileOpen"; + this.toolStripButtonFileOpen.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonFileOpen.Text = "toolStripButtonOpen"; + this.toolStripButtonFileOpen.ToolTipText = "Open"; + this.toolStripButtonFileOpen.Click += new System.EventHandler(this.ToolStripButtonFileOpenClick); + // + // toolStripButtonSave + // + this.toolStripButtonSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonSave.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.toolStripButtonSave.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonSave.Image"))); + this.toolStripButtonSave.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonSave.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonSave.Name = "toolStripButtonSave"; + this.toolStripButtonSave.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonSave.Text = "toolStripButtonSave"; + this.toolStripButtonSave.ToolTipText = "Save"; + this.toolStripButtonSave.Click += new System.EventHandler(this.ToolStripButtonSaveClick); + // + // toolStripButtonSaveAs + // + this.toolStripButtonSaveAs.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonSaveAs.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.toolStripButtonSaveAs.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonSaveAs.Image"))); + this.toolStripButtonSaveAs.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonSaveAs.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonSaveAs.Name = "toolStripButtonSaveAs"; + this.toolStripButtonSaveAs.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonSaveAs.Text = "toolStripButtonSaveAs"; + this.toolStripButtonSaveAs.ToolTipText = "Save as"; + this.toolStripButtonSaveAs.Click += new System.EventHandler(this.ToolStripButtonSaveAsClick); + // + // toolStripSeparatorFindReplace + // + this.toolStripSeparatorFindReplace.Name = "toolStripSeparatorFindReplace"; + this.toolStripSeparatorFindReplace.Size = new System.Drawing.Size(6, 40); + // + // toolStripButtonFind + // + this.toolStripButtonFind.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonFind.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.toolStripButtonFind.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonFind.Image"))); + this.toolStripButtonFind.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonFind.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonFind.Name = "toolStripButtonFind"; + this.toolStripButtonFind.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonFind.Text = "Find"; + this.toolStripButtonFind.Click += new System.EventHandler(this.ToolStripButtonFindClick); + // + // toolStripButtonReplace + // + this.toolStripButtonReplace.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonReplace.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.toolStripButtonReplace.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonReplace.Image"))); + this.toolStripButtonReplace.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonReplace.ImageTransparentColor = System.Drawing.Color.White; + this.toolStripButtonReplace.Name = "toolStripButtonReplace"; + this.toolStripButtonReplace.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonReplace.Text = "Replace"; + this.toolStripButtonReplace.ToolTipText = "Replace"; + this.toolStripButtonReplace.Click += new System.EventHandler(this.ToolStripButtonReplaceClick); + // + // toolStripSeparatorFixSyncSpell + // + this.toolStripSeparatorFixSyncSpell.Name = "toolStripSeparatorFixSyncSpell"; + this.toolStripSeparatorFixSyncSpell.Size = new System.Drawing.Size(6, 40); + // + // toolStripButtonFixCommonErrors + // + this.toolStripButtonFixCommonErrors.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonFixCommonErrors.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.toolStripButtonFixCommonErrors.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonFixCommonErrors.Image"))); + this.toolStripButtonFixCommonErrors.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonFixCommonErrors.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonFixCommonErrors.Name = "toolStripButtonFixCommonErrors"; + this.toolStripButtonFixCommonErrors.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonFixCommonErrors.Text = "Fix common errors"; + this.toolStripButtonFixCommonErrors.ToolTipText = "Fix common errors"; + this.toolStripButtonFixCommonErrors.Click += new System.EventHandler(this.toolStripButtonFixCommonErrors_Click); + // + // toolStripButtonRemoveTextForHi + // + this.toolStripButtonRemoveTextForHi.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonRemoveTextForHi.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.toolStripButtonRemoveTextForHi.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonRemoveTextForHi.Image"))); + this.toolStripButtonRemoveTextForHi.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonRemoveTextForHi.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonRemoveTextForHi.Name = "toolStripButtonRemoveTextForHi"; + this.toolStripButtonRemoveTextForHi.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonRemoveTextForHi.Text = "Remove text for HI"; + this.toolStripButtonRemoveTextForHi.ToolTipText = "Fix common errors"; + this.toolStripButtonRemoveTextForHi.Click += new System.EventHandler(this.toolStripButtonRemoveTextForHi_Click); + // + // toolStripButtonVisualSync + // + this.toolStripButtonVisualSync.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonVisualSync.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.toolStripButtonVisualSync.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonVisualSync.Image"))); + this.toolStripButtonVisualSync.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonVisualSync.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonVisualSync.Name = "toolStripButtonVisualSync"; + this.toolStripButtonVisualSync.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonVisualSync.Text = "Visual sync"; + this.toolStripButtonVisualSync.Click += new System.EventHandler(this.ToolStripButtonVisualSyncClick); + // + // toolStripButtonSpellCheck + // + this.toolStripButtonSpellCheck.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonSpellCheck.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.toolStripButtonSpellCheck.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonSpellCheck.Image"))); + this.toolStripButtonSpellCheck.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonSpellCheck.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonSpellCheck.Name = "toolStripButtonSpellCheck"; + this.toolStripButtonSpellCheck.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonSpellCheck.Text = "Spell check"; + this.toolStripButtonSpellCheck.Click += new System.EventHandler(this.ToolStripButtonSpellCheckClick); + // + // toolStripButtonNetflixQualityCheck + // + this.toolStripButtonNetflixQualityCheck.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonNetflixQualityCheck.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonNetflixQualityCheck.Image"))); + this.toolStripButtonNetflixQualityCheck.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonNetflixQualityCheck.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonNetflixQualityCheck.Name = "toolStripButtonNetflixQualityCheck"; + this.toolStripButtonNetflixQualityCheck.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonNetflixQualityCheck.Text = "Netflix quality check"; + this.toolStripButtonNetflixQualityCheck.Click += new System.EventHandler(this.toolStripButtonNetflixGlyphCheck_Click); + // + // toolStripButtonSettings + // + this.toolStripButtonSettings.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonSettings.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.toolStripButtonSettings.Image = global::Nikse.SubtitleEdit.Properties.Resources.Settings; + this.toolStripButtonSettings.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonSettings.ImageTransparentColor = System.Drawing.Color.Transparent; + this.toolStripButtonSettings.Name = "toolStripButtonSettings"; + this.toolStripButtonSettings.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonSettings.Text = "Settings"; + this.toolStripButtonSettings.Click += new System.EventHandler(this.ToolStripButtonSettingsClick); + // + // toolStripSeparatorHelp + // + this.toolStripSeparatorHelp.Name = "toolStripSeparatorHelp"; + this.toolStripSeparatorHelp.Size = new System.Drawing.Size(6, 40); + // + // toolStripButtonHelp + // + this.toolStripButtonHelp.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonHelp.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.toolStripButtonHelp.Image = global::Nikse.SubtitleEdit.Properties.Resources.Help; + this.toolStripButtonHelp.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonHelp.ImageTransparentColor = System.Drawing.Color.Transparent; + this.toolStripButtonHelp.Name = "toolStripButtonHelp"; + this.toolStripButtonHelp.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonHelp.Text = "Help"; + this.toolStripButtonHelp.Click += new System.EventHandler(this.ToolStripButtonHelpClick); + // + // toolStripSeparatorToggle + // + this.toolStripSeparatorToggle.Name = "toolStripSeparatorToggle"; + this.toolStripSeparatorToggle.Size = new System.Drawing.Size(6, 40); + // + // toolStripButtonToggleWaveform + // + this.toolStripButtonToggleWaveform.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonToggleWaveform.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.toolStripButtonToggleWaveform.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonToggleWaveform.Image"))); + this.toolStripButtonToggleWaveform.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonToggleWaveform.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonToggleWaveform.Name = "toolStripButtonToggleWaveform"; + this.toolStripButtonToggleWaveform.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonToggleWaveform.Text = "Show/hide waveform"; + this.toolStripButtonToggleWaveform.Click += new System.EventHandler(this.toolStripButtonToggleWaveform_Click); + // + // toolStripButtonToggleVideo + // + this.toolStripButtonToggleVideo.Checked = true; + this.toolStripButtonToggleVideo.CheckState = System.Windows.Forms.CheckState.Checked; + this.toolStripButtonToggleVideo.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonToggleVideo.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.toolStripButtonToggleVideo.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonToggleVideo.Image"))); + this.toolStripButtonToggleVideo.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.toolStripButtonToggleVideo.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonToggleVideo.Name = "toolStripButtonToggleVideo"; + this.toolStripButtonToggleVideo.Size = new System.Drawing.Size(36, 37); + this.toolStripButtonToggleVideo.Text = "Show/hide video"; + this.toolStripButtonToggleVideo.Click += new System.EventHandler(this.toolStripButtonToggleVideo_Click); + // + // toolStripSeparatorSubtitleFormat + // + this.toolStripSeparatorSubtitleFormat.Name = "toolStripSeparatorSubtitleFormat"; + this.toolStripSeparatorSubtitleFormat.Size = new System.Drawing.Size(6, 40); + // + // toolStripLabelSubtitleFormat + // + this.toolStripLabelSubtitleFormat.Name = "toolStripLabelSubtitleFormat"; + this.toolStripLabelSubtitleFormat.Size = new System.Drawing.Size(86, 37); + this.toolStripLabelSubtitleFormat.Text = "Subtitle format"; + // + // comboBoxSubtitleFormats + // + this.comboBoxSubtitleFormats.DropDownHeight = 215; + this.comboBoxSubtitleFormats.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSubtitleFormats.FlatStyle = System.Windows.Forms.FlatStyle.Standard; + this.comboBoxSubtitleFormats.IntegralHeight = false; + this.comboBoxSubtitleFormats.Name = "comboBoxSubtitleFormats"; + this.comboBoxSubtitleFormats.Size = new System.Drawing.Size(150, 40); + this.comboBoxSubtitleFormats.DropDown += new System.EventHandler(this.comboBoxSubtitleFormats_DropDown); + this.comboBoxSubtitleFormats.DropDownClosed += new System.EventHandler(this.comboBoxSubtitleFormats_DropDownClosed); + this.comboBoxSubtitleFormats.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSubtitleFormatsSelectedIndexChanged); + this.comboBoxSubtitleFormats.Enter += new System.EventHandler(this.ComboBoxSubtitleFormatsEnter); + // + // toolStripSeparatorEncoding + // + this.toolStripSeparatorEncoding.Name = "toolStripSeparatorEncoding"; + this.toolStripSeparatorEncoding.Size = new System.Drawing.Size(6, 40); + // + // toolStripLabelEncoding + // + this.toolStripLabelEncoding.Name = "toolStripLabelEncoding"; + this.toolStripLabelEncoding.Size = new System.Drawing.Size(81, 37); + this.toolStripLabelEncoding.Text = "File encoding"; + // + // comboBoxEncoding + // + this.comboBoxEncoding.DropDownHeight = 215; + this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxEncoding.FlatStyle = System.Windows.Forms.FlatStyle.Standard; + this.comboBoxEncoding.IntegralHeight = false; + this.comboBoxEncoding.Items.AddRange(new object[] { + "ANSI", + "UTF-7", + "UTF-8", + "Unicode", + "Unicode (big endian)"}); + this.comboBoxEncoding.Name = "comboBoxEncoding"; + this.comboBoxEncoding.Size = new System.Drawing.Size(129, 23); + this.comboBoxEncoding.DropDown += new System.EventHandler(this.MenuOpened); + this.comboBoxEncoding.DropDownClosed += new System.EventHandler(this.MenuClosed); + // + // toolStripSeparatorFrameRate + // + this.toolStripSeparatorFrameRate.Name = "toolStripSeparatorFrameRate"; + this.toolStripSeparatorFrameRate.Size = new System.Drawing.Size(6, 40); + // + // toolStripLabelFrameRate + // + this.toolStripLabelFrameRate.Name = "toolStripLabelFrameRate"; + this.toolStripLabelFrameRate.Size = new System.Drawing.Size(67, 15); + this.toolStripLabelFrameRate.Text = "Frame rate"; + // + // toolStripComboBoxFrameRate + // + this.toolStripComboBoxFrameRate.DropDownWidth = 75; + this.toolStripComboBoxFrameRate.FlatStyle = System.Windows.Forms.FlatStyle.Standard; + this.toolStripComboBoxFrameRate.Name = "toolStripComboBoxFrameRate"; + this.toolStripComboBoxFrameRate.Size = new System.Drawing.Size(75, 23); + this.toolStripComboBoxFrameRate.DropDown += new System.EventHandler(this.MenuOpened); + this.toolStripComboBoxFrameRate.DropDownClosed += new System.EventHandler(this.MenuClosed); + this.toolStripComboBoxFrameRate.TextChanged += new System.EventHandler(this.ToolStripComboBoxFrameRateTextChanged); + // + // toolStripButtonGetFrameRate + // + this.toolStripButtonGetFrameRate.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripButtonGetFrameRate.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonGetFrameRate.Image"))); + this.toolStripButtonGetFrameRate.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonGetFrameRate.Name = "toolStripButtonGetFrameRate"; + this.toolStripButtonGetFrameRate.Size = new System.Drawing.Size(23, 19); + this.toolStripButtonGetFrameRate.Text = "..."; + this.toolStripButtonGetFrameRate.ToolTipText = "Get frame rate from video file"; + this.toolStripButtonGetFrameRate.Click += new System.EventHandler(this.ButtonGetFrameRateClick); + // + // menuStrip1 + // + this.menuStrip1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fileToolStripMenuItem, + this.editToolStripMenuItem, + this.toolsToolStripMenuItem, + this.toolStripMenuItemSpellCheckMain, + this.toolStripMenuItemVideo, + this.toolStripMenuItemSynchronization, + this.toolStripMenuItemAutoTranslate, + this.optionsToolStripMenuItem, + this.toolStripMenuItemNetworking, + this.helpToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(975, 24); + this.menuStrip1.TabIndex = 6; + this.menuStrip1.Text = "menuStrip1"; + // + // fileToolStripMenuItem + // + this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.newToolStripMenuItem, + this.openToolStripMenuItem, + this.toolStripMenuItemOpenKeepVideo, + this.reopenToolStripMenuItem, + this.saveToolStripMenuItem, + this.saveAsToolStripMenuItem, + this.toolStripMenuItemRestoreAutoBackup, + this.toolStripMenuItemDCinemaProperties, + this.toolStripMenuItemTTProperties, + this.toolStripMenuItemNuendoProperties, + this.toolStripMenuItemFcpProperties, + this.toolStripMenuItemSubStationAlpha, + this.toolStripMenuItemAssaStyles, + this.toolStripMenuItemEbuProperties, + this.toolStripMenuItemDvdStudioProProperties, + this.toolStripSeparator20, + this.openOriginalToolStripMenuItem, + this.saveOriginalToolStripMenuItem, + this.saveOriginalAstoolStripMenuItem, + this.removeOriginalToolStripMenuItem, + this.toolStripSeparator12, + this.toolStripMenuItemOpenContainingFolder, + this.toolStripMenuItemCompare, + this.toolStripMenuItemStatistics, + this.toolStripMenuItemPlugins, + this.toolStripSeparator1, + this.toolStripMenuItemImportDvdSubtitles, + this.toolStripMenuItemSubIdx, + this.toolStripMenuItemImportBluRaySup, + this.toolStripMenuItemImportXSub, + this.toolStripMenuItemImportOcrHardSub, + this.matroskaImportStripMenuItem, + this.toolStripMenuItemManualAnsi, + this.toolStripMenuItemImportText, + this.toolStripMenuItemImportImages, + this.toolStripMenuItemImportTimeCodes, + this.toolStripSeparator22, + this.toolStripMenuItemExport, + this.toolStripSeparator10, + this.exitToolStripMenuItem}); + this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + this.fileToolStripMenuItem.Size = new System.Drawing.Size(39, 20); + this.fileToolStripMenuItem.Text = "File"; + this.fileToolStripMenuItem.DropDownOpening += new System.EventHandler(this.fileToolStripMenuItem_DropDownOpening); + // + // newToolStripMenuItem + // + this.newToolStripMenuItem.Name = "newToolStripMenuItem"; + this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); + this.newToolStripMenuItem.Size = new System.Drawing.Size(335, 22); + this.newToolStripMenuItem.Text = "New"; + this.newToolStripMenuItem.Click += new System.EventHandler(this.NewToolStripMenuItemClick); + // + // openToolStripMenuItem + // + this.openToolStripMenuItem.Name = "openToolStripMenuItem"; + this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); + this.openToolStripMenuItem.Size = new System.Drawing.Size(335, 22); + this.openToolStripMenuItem.Text = "Open"; + this.openToolStripMenuItem.Click += new System.EventHandler(this.OpenToolStripMenuItemClick); + // + // toolStripMenuItemOpenKeepVideo + // + this.toolStripMenuItemOpenKeepVideo.Name = "toolStripMenuItemOpenKeepVideo"; + this.toolStripMenuItemOpenKeepVideo.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemOpenKeepVideo.Text = "Open (keep video)"; + this.toolStripMenuItemOpenKeepVideo.Click += new System.EventHandler(this.toolStripMenuItemOpenKeepVideo_Click); + // + // reopenToolStripMenuItem + // + this.reopenToolStripMenuItem.Name = "reopenToolStripMenuItem"; + this.reopenToolStripMenuItem.Size = new System.Drawing.Size(335, 22); + this.reopenToolStripMenuItem.Text = "Reopen"; + // + // saveToolStripMenuItem + // + this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; + this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); + this.saveToolStripMenuItem.Size = new System.Drawing.Size(335, 22); + this.saveToolStripMenuItem.Text = "Save"; + this.saveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItemClick); + // + // saveAsToolStripMenuItem + // + this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; + this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(335, 22); + this.saveAsToolStripMenuItem.Text = "Save as..."; + this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.SaveAsToolStripMenuItemClick); + // + // toolStripMenuItemRestoreAutoBackup + // + this.toolStripMenuItemRestoreAutoBackup.Name = "toolStripMenuItemRestoreAutoBackup"; + this.toolStripMenuItemRestoreAutoBackup.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemRestoreAutoBackup.Text = "Restore auto-backup..."; + this.toolStripMenuItemRestoreAutoBackup.Click += new System.EventHandler(this.toolStripMenuItemRestoreAutoBackup_Click); + // + // toolStripMenuItemDCinemaProperties + // + this.toolStripMenuItemDCinemaProperties.Name = "toolStripMenuItemDCinemaProperties"; + this.toolStripMenuItemDCinemaProperties.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemDCinemaProperties.Text = "DCinema properties..."; + this.toolStripMenuItemDCinemaProperties.Click += new System.EventHandler(this.toolStripMenuItemDCinemaProperties_Click); + // + // toolStripMenuItemTTProperties + // + this.toolStripMenuItemTTProperties.Name = "toolStripMenuItemTTProperties"; + this.toolStripMenuItemTTProperties.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemTTProperties.Text = "Timed Text properties..."; + this.toolStripMenuItemTTProperties.Click += new System.EventHandler(this.toolStripMenuItemTTPropertiesClick); + // + // toolStripMenuItemNuendoProperties + // + this.toolStripMenuItemNuendoProperties.Name = "toolStripMenuItemNuendoProperties"; + this.toolStripMenuItemNuendoProperties.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemNuendoProperties.Text = "Nuendo properties..."; + this.toolStripMenuItemNuendoProperties.Click += new System.EventHandler(this.ToolStripMenuItemNuendoPropertiesClick); + // + // toolStripMenuItemFcpProperties + // + this.toolStripMenuItemFcpProperties.Name = "toolStripMenuItemFcpProperties"; + this.toolStripMenuItemFcpProperties.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemFcpProperties.Text = "Final Cut Pro properties..."; + this.toolStripMenuItemFcpProperties.Click += new System.EventHandler(this.toolStripMenuItemFcpProperties_Click); + // + // toolStripMenuItemSubStationAlpha + // + this.toolStripMenuItemSubStationAlpha.Name = "toolStripMenuItemSubStationAlpha"; + this.toolStripMenuItemSubStationAlpha.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemSubStationAlpha.Text = "Advanced Sub Station Alpha properties..."; + this.toolStripMenuItemSubStationAlpha.Click += new System.EventHandler(this.toolStripMenuItemSubStationAlpha_Click); + // + // toolStripMenuItemAssaStyles + // + this.toolStripMenuItemAssaStyles.Name = "toolStripMenuItemAssaStyles"; + this.toolStripMenuItemAssaStyles.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemAssaStyles.Text = "Advanced Sub Station Alpha styles..."; + this.toolStripMenuItemAssaStyles.Click += new System.EventHandler(this.toolStripMenuItemAssaStyles_Click); + // + // toolStripMenuItemEbuProperties + // + this.toolStripMenuItemEbuProperties.Name = "toolStripMenuItemEbuProperties"; + this.toolStripMenuItemEbuProperties.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemEbuProperties.Text = "Ebu properties..."; + this.toolStripMenuItemEbuProperties.Click += new System.EventHandler(this.toolStripMenuItemEbuProperties_Click); + // + // toolStripMenuItemDvdStudioProProperties + // + this.toolStripMenuItemDvdStudioProProperties.Name = "toolStripMenuItemDvdStudioProProperties"; + this.toolStripMenuItemDvdStudioProProperties.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemDvdStudioProProperties.Text = "DVD Studio Pro properties..."; + this.toolStripMenuItemDvdStudioProProperties.Click += new System.EventHandler(this.toolStripMenuDvdStudioProperties_Click); + // + // toolStripSeparator20 + // + this.toolStripSeparator20.Name = "toolStripSeparator20"; + this.toolStripSeparator20.Size = new System.Drawing.Size(332, 6); + // + // openOriginalToolStripMenuItem + // + this.openOriginalToolStripMenuItem.Name = "openOriginalToolStripMenuItem"; + this.openOriginalToolStripMenuItem.Size = new System.Drawing.Size(335, 22); + this.openOriginalToolStripMenuItem.Text = "Open original (translator mode)..."; + this.openOriginalToolStripMenuItem.Click += new System.EventHandler(this.OpenOriginalToolStripMenuItemClick); + // + // saveOriginalToolStripMenuItem + // + this.saveOriginalToolStripMenuItem.Name = "saveOriginalToolStripMenuItem"; + this.saveOriginalToolStripMenuItem.Size = new System.Drawing.Size(335, 22); + this.saveOriginalToolStripMenuItem.Text = "Save original"; + this.saveOriginalToolStripMenuItem.Click += new System.EventHandler(this.SaveOriginalToolStripMenuItemClick); + // + // saveOriginalAstoolStripMenuItem + // + this.saveOriginalAstoolStripMenuItem.Name = "saveOriginalAstoolStripMenuItem"; + this.saveOriginalAstoolStripMenuItem.Size = new System.Drawing.Size(335, 22); + this.saveOriginalAstoolStripMenuItem.Text = "Save original as..."; + this.saveOriginalAstoolStripMenuItem.Click += new System.EventHandler(this.SaveOriginalAstoolStripMenuItemClick); + // + // removeOriginalToolStripMenuItem + // + this.removeOriginalToolStripMenuItem.Name = "removeOriginalToolStripMenuItem"; + this.removeOriginalToolStripMenuItem.Size = new System.Drawing.Size(335, 22); + this.removeOriginalToolStripMenuItem.Text = "Remove original"; + this.removeOriginalToolStripMenuItem.Click += new System.EventHandler(this.RemoveOriginalToolStripMenuItemClick); + // + // toolStripSeparator12 + // + this.toolStripSeparator12.Name = "toolStripSeparator12"; + this.toolStripSeparator12.Size = new System.Drawing.Size(332, 6); + // + // toolStripMenuItemOpenContainingFolder + // + this.toolStripMenuItemOpenContainingFolder.Name = "toolStripMenuItemOpenContainingFolder"; + this.toolStripMenuItemOpenContainingFolder.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemOpenContainingFolder.Text = "Open containing folder"; + this.toolStripMenuItemOpenContainingFolder.Click += new System.EventHandler(this.toolStripMenuItemOpenContainingFolder_Click); + // + // toolStripMenuItemCompare + // + this.toolStripMenuItemCompare.Name = "toolStripMenuItemCompare"; + this.toolStripMenuItemCompare.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemCompare.Text = "Compare..."; + this.toolStripMenuItemCompare.Click += new System.EventHandler(this.ToolStripMenuItemCompareClick); + // + // toolStripMenuItemStatistics + // + this.toolStripMenuItemStatistics.Name = "toolStripMenuItemStatistics"; + this.toolStripMenuItemStatistics.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemStatistics.Text = "Statistics..."; + this.toolStripMenuItemStatistics.Click += new System.EventHandler(this.toolStripMenuItemStatistics_Click); + // + // toolStripMenuItemPlugins + // + this.toolStripMenuItemPlugins.Name = "toolStripMenuItemPlugins"; + this.toolStripMenuItemPlugins.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemPlugins.Text = "Plugins..."; + this.toolStripMenuItemPlugins.Click += new System.EventHandler(this.toolStripMenuItemPlugins_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(332, 6); + // + // toolStripMenuItemImportDvdSubtitles + // + this.toolStripMenuItemImportDvdSubtitles.Name = "toolStripMenuItemImportDvdSubtitles"; + this.toolStripMenuItemImportDvdSubtitles.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemImportDvdSubtitles.Text = "Import/OCR subtitle from VOB/IFO (DVD) ..."; + this.toolStripMenuItemImportDvdSubtitles.Click += new System.EventHandler(this.ToolStripMenuItemImportDvdSubtitlesClick); + // + // toolStripMenuItemSubIdx + // + this.toolStripMenuItemSubIdx.Name = "toolStripMenuItemSubIdx"; + this.toolStripMenuItemSubIdx.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemSubIdx.Text = "Import/OCR VobSub (sub/idx) subtitle..."; + this.toolStripMenuItemSubIdx.Click += new System.EventHandler(this.ToolStripMenuItemSubIdxClick1); + // + // toolStripMenuItemImportBluRaySup + // + this.toolStripMenuItemImportBluRaySup.Name = "toolStripMenuItemImportBluRaySup"; + this.toolStripMenuItemImportBluRaySup.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemImportBluRaySup.Text = "Import/OCR Blu-ray sup file..."; + this.toolStripMenuItemImportBluRaySup.Click += new System.EventHandler(this.toolStripMenuItemImportBluRaySup_Click); + // + // toolStripMenuItemImportXSub + // + this.toolStripMenuItemImportXSub.Name = "toolStripMenuItemImportXSub"; + this.toolStripMenuItemImportXSub.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemImportXSub.Text = "Import/OCR XSub from divx/avi..."; + this.toolStripMenuItemImportXSub.Click += new System.EventHandler(this.toolStripMenuItemImportXSub_Click); + // + // toolStripMenuItemImportOcrHardSub + // + this.toolStripMenuItemImportOcrHardSub.Name = "toolStripMenuItemImportOcrHardSub"; + this.toolStripMenuItemImportOcrHardSub.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemImportOcrHardSub.Text = "Import/OCR burned-in subtitles from video file..."; + this.toolStripMenuItemImportOcrHardSub.Click += new System.EventHandler(this.toolStripMenuItemImportOcrHardSub_Click); + // + // matroskaImportStripMenuItem + // + this.matroskaImportStripMenuItem.Name = "matroskaImportStripMenuItem"; + this.matroskaImportStripMenuItem.Size = new System.Drawing.Size(335, 22); + this.matroskaImportStripMenuItem.Text = "Import subtitle from Matroska file..."; + this.matroskaImportStripMenuItem.Click += new System.EventHandler(this.MatroskaImportStripMenuItemClick); + // + // toolStripMenuItemManualAnsi + // + this.toolStripMenuItemManualAnsi.Name = "toolStripMenuItemManualAnsi"; + this.toolStripMenuItemManualAnsi.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemManualAnsi.Text = "Import subtitle with manually chosen encoding..."; + this.toolStripMenuItemManualAnsi.Click += new System.EventHandler(this.ToolStripMenuItemManualAnsiClick); + // + // toolStripMenuItemImportText + // + this.toolStripMenuItemImportText.Name = "toolStripMenuItemImportText"; + this.toolStripMenuItemImportText.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemImportText.Text = "Import text..."; + this.toolStripMenuItemImportText.Click += new System.EventHandler(this.ToolStripMenuItemImportTextClick); + // + // toolStripMenuItemImportImages + // + this.toolStripMenuItemImportImages.Name = "toolStripMenuItemImportImages"; + this.toolStripMenuItemImportImages.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemImportImages.Text = "Import images..."; + this.toolStripMenuItemImportImages.Click += new System.EventHandler(this.toolStripMenuItemImportImages_Click); + // + // toolStripMenuItemImportTimeCodes + // + this.toolStripMenuItemImportTimeCodes.Name = "toolStripMenuItemImportTimeCodes"; + this.toolStripMenuItemImportTimeCodes.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemImportTimeCodes.Text = "Import time codes into existing subtitle..."; + this.toolStripMenuItemImportTimeCodes.Click += new System.EventHandler(this.toolStripMenuItemImportTimeCodes_Click); + // + // toolStripSeparator22 + // + this.toolStripSeparator22.Name = "toolStripSeparator22"; + this.toolStripSeparator22.Size = new System.Drawing.Size(332, 6); + // + // toolStripMenuItemExport + // + this.toolStripMenuItemExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.adobeEncoreFABImageScriptToolStripMenuItem, + this.toolStripMenuItemAvidStl, + this.toolStripMenuItemExportAyato, + this.toolStripMenuItemExportPngXml, + this.bluraySupToolStripMenuItem, + this.toolStripMenuItemExportBdTextSt, + this.toolStripMenuItemExportCapMakerPlus, + this.toolStripMenuItemExportCaptionInc, + this.toolStripMenuItemCavena890, + this.toolStripMenuItemExportCheetahCap, + this.toolStripMenuItemExportDcinemaInterop, + this.dCinemaSMPTE2014ToolStripMenuItem, + this.toolStripMenuItemDost, + this.DvdStudioProStl, + this.eBUSTLToolStripMenuItem, + this.toolStripMenuItemEdl, + this.toolStripMenuItemEdlClipName, + this.toolStripMenuItemExportFcpIImage, + this.toolStripMenuItemFcpXmlAdvanced, + this.toolStripMenuItemImagePerFrame, + this.toolStripMenuItemTextTimeCodePair, + this.pACScreenElectronicsToolStripMenuItem, + this.uniPacExportToolStripMenuItem, + this.plainTextToolStripMenuItem, + this.toolStripMenuItemSpumux, + this.toolStripMenuItemExportUltech130, + this.vobSubsubidxToolStripMenuItem, + this.toolStripSeparatorExportCustomText, + this.exportCustomTextFormatToolStripMenuItem}); + this.toolStripMenuItemExport.Name = "toolStripMenuItemExport"; + this.toolStripMenuItemExport.Size = new System.Drawing.Size(335, 22); + this.toolStripMenuItemExport.Text = "Export"; + // + // adobeEncoreFABImageScriptToolStripMenuItem + // + this.adobeEncoreFABImageScriptToolStripMenuItem.Name = "adobeEncoreFABImageScriptToolStripMenuItem"; + this.adobeEncoreFABImageScriptToolStripMenuItem.Size = new System.Drawing.Size(255, 22); + this.adobeEncoreFABImageScriptToolStripMenuItem.Text = "Adobe Encore FAB image script..."; + this.adobeEncoreFABImageScriptToolStripMenuItem.Click += new System.EventHandler(this.AdobeEncoreFabImageScriptToolStripMenuItemClick); + // + // toolStripMenuItemAvidStl + // + this.toolStripMenuItemAvidStl.Name = "toolStripMenuItemAvidStl"; + this.toolStripMenuItemAvidStl.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemAvidStl.Text = "Avid STL..."; + this.toolStripMenuItemAvidStl.Click += new System.EventHandler(this.toolStripMenuItemAvidStl_Click); + // + // toolStripMenuItemExportAyato + // + this.toolStripMenuItemExportAyato.Name = "toolStripMenuItemExportAyato"; + this.toolStripMenuItemExportAyato.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemExportAyato.Text = "Ayato..."; + this.toolStripMenuItemExportAyato.Click += new System.EventHandler(this.toolStripMenuItemExportAyato_Click); + // + // toolStripMenuItemExportPngXml + // + this.toolStripMenuItemExportPngXml.Name = "toolStripMenuItemExportPngXml"; + this.toolStripMenuItemExportPngXml.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemExportPngXml.Text = "BDN xml/png..."; + this.toolStripMenuItemExportPngXml.Click += new System.EventHandler(this.ToolStripMenuItemExportPngXmlClick); + // + // bluraySupToolStripMenuItem + // + this.bluraySupToolStripMenuItem.Name = "bluraySupToolStripMenuItem"; + this.bluraySupToolStripMenuItem.Size = new System.Drawing.Size(255, 22); + this.bluraySupToolStripMenuItem.Text = "Blu-ray sup..."; + this.bluraySupToolStripMenuItem.Click += new System.EventHandler(this.BluraySupToolStripMenuItemClick); + // + // toolStripMenuItemExportBdTextSt + // + this.toolStripMenuItemExportBdTextSt.Name = "toolStripMenuItemExportBdTextSt"; + this.toolStripMenuItemExportBdTextSt.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemExportBdTextSt.Text = "Blu-ray TextST..."; + this.toolStripMenuItemExportBdTextSt.Click += new System.EventHandler(this.toolStripMenuItemExportBdTextSt_Click); + // + // toolStripMenuItemExportCapMakerPlus + // + this.toolStripMenuItemExportCapMakerPlus.Name = "toolStripMenuItemExportCapMakerPlus"; + this.toolStripMenuItemExportCapMakerPlus.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemExportCapMakerPlus.Text = "CapMaker Plus..."; + this.toolStripMenuItemExportCapMakerPlus.Click += new System.EventHandler(this.toolStripMenuItemExportCapMakerPlus_Click); + // + // toolStripMenuItemExportCaptionInc + // + this.toolStripMenuItemExportCaptionInc.Name = "toolStripMenuItemExportCaptionInc"; + this.toolStripMenuItemExportCaptionInc.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemExportCaptionInc.Text = "Captions Inc..."; + this.toolStripMenuItemExportCaptionInc.Click += new System.EventHandler(this.toolStripMenuItemExportCaptionInc_Click); + // + // toolStripMenuItemCavena890 + // + this.toolStripMenuItemCavena890.Name = "toolStripMenuItemCavena890"; + this.toolStripMenuItemCavena890.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemCavena890.Text = "Cavena 890..."; + this.toolStripMenuItemCavena890.Click += new System.EventHandler(this.ToolStripMenuItemCavena890Click); + // + // toolStripMenuItemExportCheetahCap + // + this.toolStripMenuItemExportCheetahCap.Name = "toolStripMenuItemExportCheetahCap"; + this.toolStripMenuItemExportCheetahCap.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemExportCheetahCap.Text = "Cheetah CAP..."; + this.toolStripMenuItemExportCheetahCap.Click += new System.EventHandler(this.toolStripMenuItemExportCheetahCap_Click); + // + // toolStripMenuItemExportDcinemaInterop + // + this.toolStripMenuItemExportDcinemaInterop.Name = "toolStripMenuItemExportDcinemaInterop"; + this.toolStripMenuItemExportDcinemaInterop.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemExportDcinemaInterop.Text = "D-Cinema interop/png..."; + this.toolStripMenuItemExportDcinemaInterop.Click += new System.EventHandler(this.toolStripMenuItemExportDcinemaInteropClick); + // + // dCinemaSMPTE2014ToolStripMenuItem + // + this.dCinemaSMPTE2014ToolStripMenuItem.Name = "dCinemaSMPTE2014ToolStripMenuItem"; + this.dCinemaSMPTE2014ToolStripMenuItem.Size = new System.Drawing.Size(255, 22); + this.dCinemaSMPTE2014ToolStripMenuItem.Text = "D-Cinema SMPTE 2014"; + this.dCinemaSMPTE2014ToolStripMenuItem.Click += new System.EventHandler(this.dCinemaSMPTE2014ToolStripMenuItem_Click); + // + // toolStripMenuItemDost + // + this.toolStripMenuItemDost.Name = "toolStripMenuItemDost"; + this.toolStripMenuItemDost.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemDost.Text = "DOST..."; + this.toolStripMenuItemDost.Click += new System.EventHandler(this.toolStripMenuItemDost_Click); + // + // DvdStudioProStl + // + this.DvdStudioProStl.Name = "DvdStudioProStl"; + this.DvdStudioProStl.Size = new System.Drawing.Size(255, 22); + this.DvdStudioProStl.Text = "DVD Studio Pro STL"; + this.DvdStudioProStl.Click += new System.EventHandler(this.DvdStudioProStl_Click); + // + // eBUSTLToolStripMenuItem + // + this.eBUSTLToolStripMenuItem.Name = "eBUSTLToolStripMenuItem"; + this.eBUSTLToolStripMenuItem.Size = new System.Drawing.Size(255, 22); + this.eBUSTLToolStripMenuItem.Text = "EBU STL..."; + this.eBUSTLToolStripMenuItem.Click += new System.EventHandler(this.EBustlToolStripMenuItemClick); + // + // toolStripMenuItemEdl + // + this.toolStripMenuItemEdl.Name = "toolStripMenuItemEdl"; + this.toolStripMenuItemEdl.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemEdl.Text = "EDL..."; + this.toolStripMenuItemEdl.Click += new System.EventHandler(this.ExportToEdl); + // + // toolStripMenuItemEdlClipName + // + this.toolStripMenuItemEdlClipName.Name = "toolStripMenuItemEdlClipName"; + this.toolStripMenuItemEdlClipName.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemEdlClipName.Text = "EDL/CLIPNAME..."; + this.toolStripMenuItemEdlClipName.Click += new System.EventHandler(this.ExportToEdlWithClipName); + // + // toolStripMenuItemExportFcpIImage + // + this.toolStripMenuItemExportFcpIImage.Name = "toolStripMenuItemExportFcpIImage"; + this.toolStripMenuItemExportFcpIImage.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemExportFcpIImage.Text = "Final Cut Pro + image..."; + this.toolStripMenuItemExportFcpIImage.Click += new System.EventHandler(this.toolStripMenuItemExportFcpIImage_Click); + // + // toolStripMenuItemFcpXmlAdvanced + // + this.toolStripMenuItemFcpXmlAdvanced.Name = "toolStripMenuItemFcpXmlAdvanced"; + this.toolStripMenuItemFcpXmlAdvanced.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemFcpXmlAdvanced.Text = "Final Cut Pro XML advanced..."; + this.toolStripMenuItemFcpXmlAdvanced.Click += new System.EventHandler(this.toolStripMenuItemFcpXmlAdvanced_Click); + // + // toolStripMenuItemImagePerFrame + // + this.toolStripMenuItemImagePerFrame.Name = "toolStripMenuItemImagePerFrame"; + this.toolStripMenuItemImagePerFrame.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemImagePerFrame.Text = "Image per frame..."; + this.toolStripMenuItemImagePerFrame.Visible = false; + this.toolStripMenuItemImagePerFrame.Click += new System.EventHandler(this.ToolStripMenuItemImagePerFrameClick); + // + // toolStripMenuItemTextTimeCodePair + // + this.toolStripMenuItemTextTimeCodePair.Name = "toolStripMenuItemTextTimeCodePair"; + this.toolStripMenuItemTextTimeCodePair.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemTextTimeCodePair.Text = "Korean ATS file pair..."; + this.toolStripMenuItemTextTimeCodePair.Click += new System.EventHandler(this.toolStripMenuItemTextTimeCodePair_Click); + // + // pACScreenElectronicsToolStripMenuItem + // + this.pACScreenElectronicsToolStripMenuItem.Name = "pACScreenElectronicsToolStripMenuItem"; + this.pACScreenElectronicsToolStripMenuItem.Size = new System.Drawing.Size(255, 22); + this.pACScreenElectronicsToolStripMenuItem.Text = "PAC (Screen Electronics)..."; + this.pACScreenElectronicsToolStripMenuItem.Click += new System.EventHandler(this.PacScreenElectronicsToolStripMenuItemClick); + // + // uniPacExportToolStripMenuItem + // + this.uniPacExportToolStripMenuItem.Name = "uniPacExportToolStripMenuItem"; + this.uniPacExportToolStripMenuItem.Size = new System.Drawing.Size(255, 22); + this.uniPacExportToolStripMenuItem.Text = "PAC Unicode (UniPac)..."; + this.uniPacExportToolStripMenuItem.Click += new System.EventHandler(this.uniPacExportToolStripMenuItem_Click); + // + // plainTextToolStripMenuItem + // + this.plainTextToolStripMenuItem.Name = "plainTextToolStripMenuItem"; + this.plainTextToolStripMenuItem.Size = new System.Drawing.Size(255, 22); + this.plainTextToolStripMenuItem.Text = "Plain text..."; + this.plainTextToolStripMenuItem.Click += new System.EventHandler(this.PlainTextToolStripMenuItemClick); + // + // toolStripMenuItemSpumux + // + this.toolStripMenuItemSpumux.Name = "toolStripMenuItemSpumux"; + this.toolStripMenuItemSpumux.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemSpumux.Text = "Spumux..."; + this.toolStripMenuItemSpumux.Click += new System.EventHandler(this.toolStripMenuItem2_Click); + // + // toolStripMenuItemExportUltech130 + // + this.toolStripMenuItemExportUltech130.Name = "toolStripMenuItemExportUltech130"; + this.toolStripMenuItemExportUltech130.Size = new System.Drawing.Size(255, 22); + this.toolStripMenuItemExportUltech130.Text = "Ultech caption..."; + this.toolStripMenuItemExportUltech130.Click += new System.EventHandler(this.toolStripMenuItemExportUltech130_Click); + // + // vobSubsubidxToolStripMenuItem + // + this.vobSubsubidxToolStripMenuItem.Name = "vobSubsubidxToolStripMenuItem"; + this.vobSubsubidxToolStripMenuItem.Size = new System.Drawing.Size(255, 22); + this.vobSubsubidxToolStripMenuItem.Text = "VobSub (sub/idx)..."; + this.vobSubsubidxToolStripMenuItem.Click += new System.EventHandler(this.VobSubsubidxToolStripMenuItemClick); + // + // toolStripSeparatorExportCustomText + // + this.toolStripSeparatorExportCustomText.Name = "toolStripSeparatorExportCustomText"; + this.toolStripSeparatorExportCustomText.Size = new System.Drawing.Size(252, 6); + // + // exportCustomTextFormatToolStripMenuItem + // + this.exportCustomTextFormatToolStripMenuItem.Name = "exportCustomTextFormatToolStripMenuItem"; + this.exportCustomTextFormatToolStripMenuItem.Size = new System.Drawing.Size(255, 22); + this.exportCustomTextFormatToolStripMenuItem.Text = "Export custom text format..."; + this.exportCustomTextFormatToolStripMenuItem.Click += new System.EventHandler(this.exportCustomTextFormatToolStripMenuItem_Click); + // + // toolStripSeparator10 + // + this.toolStripSeparator10.Name = "toolStripSeparator10"; + this.toolStripSeparator10.Size = new System.Drawing.Size(332, 6); + // + // exitToolStripMenuItem + // + this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; + this.exitToolStripMenuItem.Size = new System.Drawing.Size(335, 22); + this.exitToolStripMenuItem.Text = "E&xit"; + this.exitToolStripMenuItem.Click += new System.EventHandler(this.ExitToolStripMenuItemClick); + // + // editToolStripMenuItem + // + this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemUndo, + this.toolStripMenuItemRedo, + this.showHistoryforUndoToolStripMenuItem, + this.toolStripSeparator14, + this.toolStripMenuItemInsertUnicodeCharacter, + this.toolStripSeparatorInsertUnicodeCharacter, + this.findToolStripMenuItem, + this.findNextToolStripMenuItem, + this.replaceToolStripMenuItem, + this.multipleReplaceToolStripMenuItem, + this.gotoLineNumberToolStripMenuItem, + this.toolStripMenuItemShowOriginalInPreview, + this.toolStripSeparator25, + this.toolStripMenuItemRightToLeftMode, + this.toolStripMenuItemRtlUnicodeControlChars, + this.toolStripMenuItemRemoveUnicodeControlChars, + this.toolStripMenuItemReverseRightToLeftStartEnd, + this.toolStripSeparator21, + this.toolStripMenuItemModifySelection, + this.toolStripMenuItemInverseSelection, + this.editSelectAllToolStripMenuItem}); + this.editToolStripMenuItem.Name = "editToolStripMenuItem"; + this.editToolStripMenuItem.Size = new System.Drawing.Size(40, 20); + this.editToolStripMenuItem.Text = "Edit"; + this.editToolStripMenuItem.DropDownOpening += new System.EventHandler(this.EditToolStripMenuItemDropDownOpening); + // + // toolStripMenuItemUndo + // + this.toolStripMenuItemUndo.Name = "toolStripMenuItemUndo"; + this.toolStripMenuItemUndo.Size = new System.Drawing.Size(301, 22); + this.toolStripMenuItemUndo.Text = "Undo"; + this.toolStripMenuItemUndo.Click += new System.EventHandler(this.toolStripMenuItemUndo_Click); + // + // toolStripMenuItemRedo + // + this.toolStripMenuItemRedo.Name = "toolStripMenuItemRedo"; + this.toolStripMenuItemRedo.Size = new System.Drawing.Size(301, 22); + this.toolStripMenuItemRedo.Text = "Redo"; + this.toolStripMenuItemRedo.Click += new System.EventHandler(this.toolStripMenuItemRedo_Click); + // + // showHistoryforUndoToolStripMenuItem + // + this.showHistoryforUndoToolStripMenuItem.Name = "showHistoryforUndoToolStripMenuItem"; + this.showHistoryforUndoToolStripMenuItem.Size = new System.Drawing.Size(301, 22); + this.showHistoryforUndoToolStripMenuItem.Text = "Show history (for undo)"; + this.showHistoryforUndoToolStripMenuItem.Click += new System.EventHandler(this.ShowHistoryforUndoToolStripMenuItemClick); + // + // toolStripSeparator14 + // + this.toolStripSeparator14.Name = "toolStripSeparator14"; + this.toolStripSeparator14.Size = new System.Drawing.Size(298, 6); + // + // toolStripMenuItemInsertUnicodeCharacter + // + this.toolStripMenuItemInsertUnicodeCharacter.Name = "toolStripMenuItemInsertUnicodeCharacter"; + this.toolStripMenuItemInsertUnicodeCharacter.Size = new System.Drawing.Size(301, 22); + this.toolStripMenuItemInsertUnicodeCharacter.Text = "Insert unicode character"; + // + // toolStripSeparatorInsertUnicodeCharacter + // + this.toolStripSeparatorInsertUnicodeCharacter.Name = "toolStripSeparatorInsertUnicodeCharacter"; + this.toolStripSeparatorInsertUnicodeCharacter.Size = new System.Drawing.Size(298, 6); + // + // findToolStripMenuItem + // + this.findToolStripMenuItem.Name = "findToolStripMenuItem"; + this.findToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F))); + this.findToolStripMenuItem.Size = new System.Drawing.Size(301, 22); + this.findToolStripMenuItem.Text = "Find"; + this.findToolStripMenuItem.Click += new System.EventHandler(this.FindToolStripMenuItemClick); + // + // findNextToolStripMenuItem + // + this.findNextToolStripMenuItem.Name = "findNextToolStripMenuItem"; + this.findNextToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F3; + this.findNextToolStripMenuItem.Size = new System.Drawing.Size(301, 22); + this.findNextToolStripMenuItem.Text = "Find next"; + this.findNextToolStripMenuItem.Click += new System.EventHandler(this.FindNextToolStripMenuItemClick); + // + // replaceToolStripMenuItem + // + this.replaceToolStripMenuItem.Name = "replaceToolStripMenuItem"; + this.replaceToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.H))); + this.replaceToolStripMenuItem.Size = new System.Drawing.Size(301, 22); + this.replaceToolStripMenuItem.Text = "Replace"; + this.replaceToolStripMenuItem.Click += new System.EventHandler(this.ReplaceToolStripMenuItemClick); + // + // multipleReplaceToolStripMenuItem + // + this.multipleReplaceToolStripMenuItem.Name = "multipleReplaceToolStripMenuItem"; + this.multipleReplaceToolStripMenuItem.Size = new System.Drawing.Size(301, 22); + this.multipleReplaceToolStripMenuItem.Text = "Multiple replace"; + this.multipleReplaceToolStripMenuItem.Click += new System.EventHandler(this.MultipleReplaceToolStripMenuItemClick); + // + // gotoLineNumberToolStripMenuItem + // + this.gotoLineNumberToolStripMenuItem.Name = "gotoLineNumberToolStripMenuItem"; + this.gotoLineNumberToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G))); + this.gotoLineNumberToolStripMenuItem.Size = new System.Drawing.Size(301, 22); + this.gotoLineNumberToolStripMenuItem.Text = "Goto line number..."; + this.gotoLineNumberToolStripMenuItem.Click += new System.EventHandler(this.GotoLineNumberToolStripMenuItemClick); + // + // toolStripMenuItemShowOriginalInPreview + // + this.toolStripMenuItemShowOriginalInPreview.Name = "toolStripMenuItemShowOriginalInPreview"; + this.toolStripMenuItemShowOriginalInPreview.Size = new System.Drawing.Size(301, 22); + this.toolStripMenuItemShowOriginalInPreview.Text = "Show original text in video/audio previews"; + this.toolStripMenuItemShowOriginalInPreview.Click += new System.EventHandler(this.ToolStripMenuItemShowOriginalInPreviewClick); + // + // toolStripSeparator25 + // + this.toolStripSeparator25.Name = "toolStripSeparator25"; + this.toolStripSeparator25.Size = new System.Drawing.Size(298, 6); + // + // toolStripMenuItemRightToLeftMode + // + this.toolStripMenuItemRightToLeftMode.Name = "toolStripMenuItemRightToLeftMode"; + this.toolStripMenuItemRightToLeftMode.Size = new System.Drawing.Size(301, 22); + this.toolStripMenuItemRightToLeftMode.Text = "Right to left mode"; + this.toolStripMenuItemRightToLeftMode.Click += new System.EventHandler(this.ToolStripMenuItemRightToLeftModeClick); + // + // toolStripMenuItemRtlUnicodeControlChars + // + this.toolStripMenuItemRtlUnicodeControlChars.Name = "toolStripMenuItemRtlUnicodeControlChars"; + this.toolStripMenuItemRtlUnicodeControlChars.Size = new System.Drawing.Size(301, 22); + this.toolStripMenuItemRtlUnicodeControlChars.Text = "Fix RTL via Unicode tags"; + this.toolStripMenuItemRtlUnicodeControlChars.Click += new System.EventHandler(this.toolStripMenuItemRtlUnicodeControlChar_Click); + // + // toolStripMenuItemRemoveUnicodeControlChars + // + this.toolStripMenuItemRemoveUnicodeControlChars.Name = "toolStripMenuItemRemoveUnicodeControlChars"; + this.toolStripMenuItemRemoveUnicodeControlChars.Size = new System.Drawing.Size(301, 22); + this.toolStripMenuItemRemoveUnicodeControlChars.Text = "Remove Unicode tags"; + this.toolStripMenuItemRemoveUnicodeControlChars.Click += new System.EventHandler(this.toolStripMenuItemRemoveUnicodeControlChar_Click); + // + // toolStripMenuItemReverseRightToLeftStartEnd + // + this.toolStripMenuItemReverseRightToLeftStartEnd.Name = "toolStripMenuItemReverseRightToLeftStartEnd"; + this.toolStripMenuItemReverseRightToLeftStartEnd.Size = new System.Drawing.Size(301, 22); + this.toolStripMenuItemReverseRightToLeftStartEnd.Text = "Reverse RTL start/end"; + this.toolStripMenuItemReverseRightToLeftStartEnd.Click += new System.EventHandler(this.toolStripMenuItemReverseRightToLeftStartEnd_Click); + // + // toolStripSeparator21 + // + this.toolStripSeparator21.Name = "toolStripSeparator21"; + this.toolStripSeparator21.Size = new System.Drawing.Size(298, 6); + // + // toolStripMenuItemModifySelection + // + this.toolStripMenuItemModifySelection.Name = "toolStripMenuItemModifySelection"; + this.toolStripMenuItemModifySelection.Size = new System.Drawing.Size(301, 22); + this.toolStripMenuItemModifySelection.Text = "Create/modify selection..."; + this.toolStripMenuItemModifySelection.Click += new System.EventHandler(this.toolStripMenuItemModifySelection_Click); + // + // toolStripMenuItemInverseSelection + // + this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; + this.toolStripMenuItemInverseSelection.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.I))); + this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(301, 22); + this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; + this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); + // + // editSelectAllToolStripMenuItem + // + this.editSelectAllToolStripMenuItem.Name = "editSelectAllToolStripMenuItem"; + this.editSelectAllToolStripMenuItem.Size = new System.Drawing.Size(301, 22); + this.editSelectAllToolStripMenuItem.Text = "Select all"; + this.editSelectAllToolStripMenuItem.Click += new System.EventHandler(this.EditSelectAllToolStripMenuItemClick); + // + // toolsToolStripMenuItem + // + this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.adjustDisplayTimeToolStripMenuItem, + this.toolStripMenuItemApplyDurationLimits, + this.toolStripMenuItemSubtitlesBridgeGaps, + this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem, + this.fixToolStripMenuItem, + this.startNumberingFromToolStripMenuItem, + this.removeTextForHearImpairedToolStripMenuItem, + this.ChangeCasingToolStripMenuItem, + this.toolStripMenuItemAutoMergeShortLines, + this.toolStripMenuItemMergeDuplicateText, + this.toolStripMenuItemMergeLinesWithSameTimeCodes, + this.toolStripMenuItemAutoSplitLongLines, + this.toolStripMenuItemSortBy, + this.netflixQualityCheckToolStripMenuItem, + this.toolStripSeparator23, + this.toolStripMenuItemMakeEmptyFromCurrent, + this.toolStripMenuItemBatchConvert, + this.generateDatetimeInfoFromVideoToolStripMenuItem, + this.toolStripMenuItemMeasurementConverter, + this.toolStripSeparator3, + this.splitToolStripMenuItem, + this.appendTextVisuallyToolStripMenuItem, + this.joinSubtitlesToolStripMenuItem}); + this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; + this.toolsToolStripMenuItem.Size = new System.Drawing.Size(49, 20); + this.toolsToolStripMenuItem.Text = "Tools"; + this.toolsToolStripMenuItem.DropDownOpening += new System.EventHandler(this.ToolsToolStripMenuItemDropDownOpening); + // + // adjustDisplayTimeToolStripMenuItem + // + this.adjustDisplayTimeToolStripMenuItem.Name = "adjustDisplayTimeToolStripMenuItem"; + this.adjustDisplayTimeToolStripMenuItem.Size = new System.Drawing.Size(338, 22); + this.adjustDisplayTimeToolStripMenuItem.Text = "Adjust display time..."; + this.adjustDisplayTimeToolStripMenuItem.Click += new System.EventHandler(this.AdjustDisplayTimeToolStripMenuItemClick); + // + // toolStripMenuItemApplyDurationLimits + // + this.toolStripMenuItemApplyDurationLimits.Name = "toolStripMenuItemApplyDurationLimits"; + this.toolStripMenuItemApplyDurationLimits.Size = new System.Drawing.Size(338, 22); + this.toolStripMenuItemApplyDurationLimits.Text = "Apply duration limits..."; + this.toolStripMenuItemApplyDurationLimits.Click += new System.EventHandler(this.toolStripMenuItemApplyDisplayTimeLimits_Click); + // + // toolStripMenuItemSubtitlesBridgeGaps + // + this.toolStripMenuItemSubtitlesBridgeGaps.Name = "toolStripMenuItemSubtitlesBridgeGaps"; + this.toolStripMenuItemSubtitlesBridgeGaps.Size = new System.Drawing.Size(338, 22); + this.toolStripMenuItemSubtitlesBridgeGaps.Text = "Bridge gap between subtitles..."; + this.toolStripMenuItemSubtitlesBridgeGaps.Click += new System.EventHandler(this.toolStripMenuItemBridgeGapsBetweenSubtitles_Click); + // + // setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem + // + this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.Name = "setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem"; + this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.Size = new System.Drawing.Size(338, 22); + this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.Text = "Apply mininum gap between subtitles..."; + this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.Click += new System.EventHandler(this.SetMinimalDisplayTimeDifferenceToolStripMenuItemClick); + // + // fixToolStripMenuItem + // + this.fixToolStripMenuItem.Name = "fixToolStripMenuItem"; + this.fixToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.F))); + this.fixToolStripMenuItem.Size = new System.Drawing.Size(338, 22); + this.fixToolStripMenuItem.Text = "Fix common errors..."; + this.fixToolStripMenuItem.Click += new System.EventHandler(this.FixToolStripMenuItemClick); + // + // startNumberingFromToolStripMenuItem + // + this.startNumberingFromToolStripMenuItem.Name = "startNumberingFromToolStripMenuItem"; + this.startNumberingFromToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.N))); + this.startNumberingFromToolStripMenuItem.Size = new System.Drawing.Size(338, 22); + this.startNumberingFromToolStripMenuItem.Text = "Start numbering from..."; + this.startNumberingFromToolStripMenuItem.Click += new System.EventHandler(this.StartNumberingFromToolStripMenuItemClick); + // + // removeTextForHearImpairedToolStripMenuItem + // + this.removeTextForHearImpairedToolStripMenuItem.Name = "removeTextForHearImpairedToolStripMenuItem"; + this.removeTextForHearImpairedToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.H))); + this.removeTextForHearImpairedToolStripMenuItem.Size = new System.Drawing.Size(338, 22); + this.removeTextForHearImpairedToolStripMenuItem.Text = "Remove text for hearing impaired..."; + this.removeTextForHearImpairedToolStripMenuItem.Click += new System.EventHandler(this.RemoveTextForHearImpairedToolStripMenuItemClick); + // + // ChangeCasingToolStripMenuItem + // + this.ChangeCasingToolStripMenuItem.Name = "ChangeCasingToolStripMenuItem"; + this.ChangeCasingToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.C))); + this.ChangeCasingToolStripMenuItem.Size = new System.Drawing.Size(338, 22); + this.ChangeCasingToolStripMenuItem.Text = "Change casing..."; + this.ChangeCasingToolStripMenuItem.Click += new System.EventHandler(this.ChangeCasingToolStripMenuItem_Click); + // + // toolStripMenuItemAutoMergeShortLines + // + this.toolStripMenuItemAutoMergeShortLines.Name = "toolStripMenuItemAutoMergeShortLines"; + this.toolStripMenuItemAutoMergeShortLines.Size = new System.Drawing.Size(338, 22); + this.toolStripMenuItemAutoMergeShortLines.Text = "Merge short lines..."; + this.toolStripMenuItemAutoMergeShortLines.Click += new System.EventHandler(this.ToolStripMenuItemAutoMergeShortLinesClick); + // + // toolStripMenuItemMergeDuplicateText + // + this.toolStripMenuItemMergeDuplicateText.Name = "toolStripMenuItemMergeDuplicateText"; + this.toolStripMenuItemMergeDuplicateText.Size = new System.Drawing.Size(338, 22); + this.toolStripMenuItemMergeDuplicateText.Text = "Merge lines with same text..."; + this.toolStripMenuItemMergeDuplicateText.Click += new System.EventHandler(this.toolStripMenuItemMergeDuplicateText_Click); + // + // toolStripMenuItemMergeLinesWithSameTimeCodes + // + this.toolStripMenuItemMergeLinesWithSameTimeCodes.Name = "toolStripMenuItemMergeLinesWithSameTimeCodes"; + this.toolStripMenuItemMergeLinesWithSameTimeCodes.Size = new System.Drawing.Size(338, 22); + this.toolStripMenuItemMergeLinesWithSameTimeCodes.Text = "Merge lines with same time codes..."; + this.toolStripMenuItemMergeLinesWithSameTimeCodes.Click += new System.EventHandler(this.toolStripMenuItemMergeLinesWithSameTimeCodes_Click); + // + // toolStripMenuItemAutoSplitLongLines + // + this.toolStripMenuItemAutoSplitLongLines.Name = "toolStripMenuItemAutoSplitLongLines"; + this.toolStripMenuItemAutoSplitLongLines.Size = new System.Drawing.Size(338, 22); + this.toolStripMenuItemAutoSplitLongLines.Text = "Split long lines..."; + this.toolStripMenuItemAutoSplitLongLines.Click += new System.EventHandler(this.toolStripMenuItemAutoSplitLongLines_Click); + // + // toolStripMenuItemSortBy + // + this.toolStripMenuItemSortBy.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.sortNumberToolStripMenuItem, + this.sortStartTimeToolStripMenuItem, + this.sortEndTimeToolStripMenuItem, + this.sortDisplayTimeToolStripMenuItem, + this.sortTextAlphabeticallytoolStripMenuItem, + this.sortTextMaxLineLengthToolStripMenuItem, + this.sortTextTotalLengthToolStripMenuItem, + this.sortTextNumberOfLinesToolStripMenuItem, + this.textCharssecToolStripMenuItem, + this.textWordsPerMinutewpmToolStripMenuItem, + this.actorToolStripMenuItem, + this.styleToolStripMenuItem, + this.toolStripSeparatorAscOrDesc, + this.AscendingToolStripMenuItem, + this.descendingToolStripMenuItem}); + this.toolStripMenuItemSortBy.Name = "toolStripMenuItemSortBy"; + this.toolStripMenuItemSortBy.Size = new System.Drawing.Size(338, 22); + this.toolStripMenuItemSortBy.Text = "Sort by"; + // + // sortNumberToolStripMenuItem + // + this.sortNumberToolStripMenuItem.Name = "sortNumberToolStripMenuItem"; + this.sortNumberToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.sortNumberToolStripMenuItem.Text = "Number"; + this.sortNumberToolStripMenuItem.Click += new System.EventHandler(this.SortNumberToolStripMenuItemClick); + // + // sortStartTimeToolStripMenuItem + // + this.sortStartTimeToolStripMenuItem.Name = "sortStartTimeToolStripMenuItem"; + this.sortStartTimeToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.sortStartTimeToolStripMenuItem.Text = "Start time"; + this.sortStartTimeToolStripMenuItem.Click += new System.EventHandler(this.SortStartTimeToolStripMenuItemClick); + // + // sortEndTimeToolStripMenuItem + // + this.sortEndTimeToolStripMenuItem.Name = "sortEndTimeToolStripMenuItem"; + this.sortEndTimeToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.sortEndTimeToolStripMenuItem.Text = "End time"; + this.sortEndTimeToolStripMenuItem.Click += new System.EventHandler(this.SortEndTimeToolStripMenuItemClick); + // + // sortDisplayTimeToolStripMenuItem + // + this.sortDisplayTimeToolStripMenuItem.Name = "sortDisplayTimeToolStripMenuItem"; + this.sortDisplayTimeToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.sortDisplayTimeToolStripMenuItem.Text = "Duration"; + this.sortDisplayTimeToolStripMenuItem.Click += new System.EventHandler(this.SortDisplayTimeToolStripMenuItemClick); + // + // sortTextAlphabeticallytoolStripMenuItem + // + this.sortTextAlphabeticallytoolStripMenuItem.Name = "sortTextAlphabeticallytoolStripMenuItem"; + this.sortTextAlphabeticallytoolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.sortTextAlphabeticallytoolStripMenuItem.Text = "Text - alphabetically"; + this.sortTextAlphabeticallytoolStripMenuItem.Click += new System.EventHandler(this.SortTextAlphabeticallytoolStripMenuItemClick); + // + // sortTextMaxLineLengthToolStripMenuItem + // + this.sortTextMaxLineLengthToolStripMenuItem.Name = "sortTextMaxLineLengthToolStripMenuItem"; + this.sortTextMaxLineLengthToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.sortTextMaxLineLengthToolStripMenuItem.Text = "Text - single line max. length"; + this.sortTextMaxLineLengthToolStripMenuItem.Click += new System.EventHandler(this.SortTextMaxLineLengthToolStripMenuItemClick); + // + // sortTextTotalLengthToolStripMenuItem + // + this.sortTextTotalLengthToolStripMenuItem.Name = "sortTextTotalLengthToolStripMenuItem"; + this.sortTextTotalLengthToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.sortTextTotalLengthToolStripMenuItem.Text = "Text - total length"; + this.sortTextTotalLengthToolStripMenuItem.Click += new System.EventHandler(this.SortTextTotalLengthToolStripMenuItemClick); + // + // sortTextNumberOfLinesToolStripMenuItem + // + this.sortTextNumberOfLinesToolStripMenuItem.Name = "sortTextNumberOfLinesToolStripMenuItem"; + this.sortTextNumberOfLinesToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.sortTextNumberOfLinesToolStripMenuItem.Text = "Text - number of lines"; + this.sortTextNumberOfLinesToolStripMenuItem.Click += new System.EventHandler(this.SortTextNumberOfLinesToolStripMenuItemClick); + // + // textCharssecToolStripMenuItem + // + this.textCharssecToolStripMenuItem.Name = "textCharssecToolStripMenuItem"; + this.textCharssecToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.textCharssecToolStripMenuItem.Text = "Text - chars/sec"; + this.textCharssecToolStripMenuItem.Click += new System.EventHandler(this.textCharssecToolStripMenuItem_Click); + // + // textWordsPerMinutewpmToolStripMenuItem + // + this.textWordsPerMinutewpmToolStripMenuItem.Name = "textWordsPerMinutewpmToolStripMenuItem"; + this.textWordsPerMinutewpmToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.textWordsPerMinutewpmToolStripMenuItem.Text = "Text - words per minute (wpm)"; + this.textWordsPerMinutewpmToolStripMenuItem.Click += new System.EventHandler(this.textWordsPerMinutewpmToolStripMenuItem_Click); + // + // actorToolStripMenuItem + // + this.actorToolStripMenuItem.Name = "actorToolStripMenuItem"; + this.actorToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.actorToolStripMenuItem.Text = "Actor"; + this.actorToolStripMenuItem.Click += new System.EventHandler(this.actorToolStripMenuItemClick); + // + // styleToolStripMenuItem + // + this.styleToolStripMenuItem.Name = "styleToolStripMenuItem"; + this.styleToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.styleToolStripMenuItem.Text = "Style"; + this.styleToolStripMenuItem.Click += new System.EventHandler(this.styleToolStripMenuItem_Click); + // + // toolStripSeparatorAscOrDesc + // + this.toolStripSeparatorAscOrDesc.Name = "toolStripSeparatorAscOrDesc"; + this.toolStripSeparatorAscOrDesc.Size = new System.Drawing.Size(237, 6); + // + // AscendingToolStripMenuItem + // + this.AscendingToolStripMenuItem.Checked = true; + this.AscendingToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.AscendingToolStripMenuItem.Name = "AscendingToolStripMenuItem"; + this.AscendingToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.AscendingToolStripMenuItem.Text = "Ascending"; + this.AscendingToolStripMenuItem.Click += new System.EventHandler(this.AscendingToolStripMenuItem_Click); + // + // descendingToolStripMenuItem + // + this.descendingToolStripMenuItem.Name = "descendingToolStripMenuItem"; + this.descendingToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.descendingToolStripMenuItem.Text = "Descending"; + this.descendingToolStripMenuItem.Click += new System.EventHandler(this.descendingToolStripMenuItem_Click); + // + // netflixQualityCheckToolStripMenuItem + // + this.netflixQualityCheckToolStripMenuItem.Name = "netflixQualityCheckToolStripMenuItem"; + this.netflixQualityCheckToolStripMenuItem.Size = new System.Drawing.Size(338, 22); + this.netflixQualityCheckToolStripMenuItem.Text = "Netflix quality check"; + this.netflixQualityCheckToolStripMenuItem.Click += new System.EventHandler(this.netflixGlyphCheckToolStripMenuItem_Click); + // + // toolStripSeparator23 + // + this.toolStripSeparator23.Name = "toolStripSeparator23"; + this.toolStripSeparator23.Size = new System.Drawing.Size(335, 6); + // + // toolStripMenuItemMakeEmptyFromCurrent + // + this.toolStripMenuItemMakeEmptyFromCurrent.Name = "toolStripMenuItemMakeEmptyFromCurrent"; + this.toolStripMenuItemMakeEmptyFromCurrent.Size = new System.Drawing.Size(338, 22); + this.toolStripMenuItemMakeEmptyFromCurrent.Text = "Make new empty translation from current subtitle"; + this.toolStripMenuItemMakeEmptyFromCurrent.Click += new System.EventHandler(this.ToolStripMenuItemMakeEmptyFromCurrentClick); + // + // toolStripMenuItemBatchConvert + // + this.toolStripMenuItemBatchConvert.Name = "toolStripMenuItemBatchConvert"; + this.toolStripMenuItemBatchConvert.Size = new System.Drawing.Size(338, 22); + this.toolStripMenuItemBatchConvert.Text = "Batch convert..."; + this.toolStripMenuItemBatchConvert.Click += new System.EventHandler(this.toolStripMenuItemBatchConvert_Click); + // + // generateDatetimeInfoFromVideoToolStripMenuItem + // + this.generateDatetimeInfoFromVideoToolStripMenuItem.Name = "generateDatetimeInfoFromVideoToolStripMenuItem"; + this.generateDatetimeInfoFromVideoToolStripMenuItem.Size = new System.Drawing.Size(338, 22); + this.generateDatetimeInfoFromVideoToolStripMenuItem.Text = "Generate date/time info from video..."; + this.generateDatetimeInfoFromVideoToolStripMenuItem.Click += new System.EventHandler(this.generateDatetimeInfoFromVideoToolStripMenuItem_Click); + // + // toolStripMenuItemMeasurementConverter + // + this.toolStripMenuItemMeasurementConverter.Name = "toolStripMenuItemMeasurementConverter"; + this.toolStripMenuItemMeasurementConverter.Size = new System.Drawing.Size(338, 22); + this.toolStripMenuItemMeasurementConverter.Text = "Measurement converter..."; + this.toolStripMenuItemMeasurementConverter.Click += new System.EventHandler(this.toolStripMenuItemMeasurementConverter_Click); + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(335, 6); + // + // splitToolStripMenuItem + // + this.splitToolStripMenuItem.Name = "splitToolStripMenuItem"; + this.splitToolStripMenuItem.Size = new System.Drawing.Size(338, 22); + this.splitToolStripMenuItem.Text = "Split subtitle..."; + this.splitToolStripMenuItem.Click += new System.EventHandler(this.SplitToolStripMenuItemClick); + // + // appendTextVisuallyToolStripMenuItem + // + this.appendTextVisuallyToolStripMenuItem.Name = "appendTextVisuallyToolStripMenuItem"; + this.appendTextVisuallyToolStripMenuItem.Size = new System.Drawing.Size(338, 22); + this.appendTextVisuallyToolStripMenuItem.Text = "Append subtitle..."; + this.appendTextVisuallyToolStripMenuItem.Click += new System.EventHandler(this.AppendTextVisuallyToolStripMenuItemClick); + // + // joinSubtitlesToolStripMenuItem + // + this.joinSubtitlesToolStripMenuItem.Name = "joinSubtitlesToolStripMenuItem"; + this.joinSubtitlesToolStripMenuItem.Size = new System.Drawing.Size(338, 22); + this.joinSubtitlesToolStripMenuItem.Text = "Join subtitles..."; + this.joinSubtitlesToolStripMenuItem.Click += new System.EventHandler(this.joinSubtitlesToolStripMenuItem_Click); + // + // toolStripMenuItemSpellCheckMain + // + this.toolStripMenuItemSpellCheckMain.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.spellCheckToolStripMenuItem, + this.toolStripMenuItemSpellCheckFromCurrentLine, + this.findDoubleWordsToolStripMenuItem, + this.FindDoubleLinesToolStripMenuItem, + this.toolStripSeparator9, + this.GetDictionariesToolStripMenuItem, + this.addWordToNameListToolStripMenuItem}); + this.toolStripMenuItemSpellCheckMain.Name = "toolStripMenuItemSpellCheckMain"; + this.toolStripMenuItemSpellCheckMain.Size = new System.Drawing.Size(82, 20); + this.toolStripMenuItemSpellCheckMain.Text = "Spell check"; + this.toolStripMenuItemSpellCheckMain.DropDownOpening += new System.EventHandler(this.ToolStripMenuItemSpellCheckMainDropDownOpening); + // + // spellCheckToolStripMenuItem + // + this.spellCheckToolStripMenuItem.Name = "spellCheckToolStripMenuItem"; + this.spellCheckToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.S))); + this.spellCheckToolStripMenuItem.Size = new System.Drawing.Size(267, 22); + this.spellCheckToolStripMenuItem.Text = "Spell check..."; + this.spellCheckToolStripMenuItem.Click += new System.EventHandler(this.SpellCheckToolStripMenuItemClick); + // + // toolStripMenuItemSpellCheckFromCurrentLine + // + this.toolStripMenuItemSpellCheckFromCurrentLine.Name = "toolStripMenuItemSpellCheckFromCurrentLine"; + this.toolStripMenuItemSpellCheckFromCurrentLine.Size = new System.Drawing.Size(267, 22); + this.toolStripMenuItemSpellCheckFromCurrentLine.Text = "Spell check from current line..."; + this.toolStripMenuItemSpellCheckFromCurrentLine.Click += new System.EventHandler(this.toolStripMenuItemSpellCheckFromCurrentLine_Click); + // + // findDoubleWordsToolStripMenuItem + // + this.findDoubleWordsToolStripMenuItem.Name = "findDoubleWordsToolStripMenuItem"; + this.findDoubleWordsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.D))); + this.findDoubleWordsToolStripMenuItem.Size = new System.Drawing.Size(267, 22); + this.findDoubleWordsToolStripMenuItem.Text = "Find double words"; + this.findDoubleWordsToolStripMenuItem.Click += new System.EventHandler(this.FindDoubleWordsToolStripMenuItemClick); + // + // FindDoubleLinesToolStripMenuItem + // + this.FindDoubleLinesToolStripMenuItem.Name = "FindDoubleLinesToolStripMenuItem"; + this.FindDoubleLinesToolStripMenuItem.Size = new System.Drawing.Size(267, 22); + this.FindDoubleLinesToolStripMenuItem.Text = "Find double lines"; + this.FindDoubleLinesToolStripMenuItem.Click += new System.EventHandler(this.FindDoubleLinesToolStripMenuItemClick); + // + // toolStripSeparator9 + // + this.toolStripSeparator9.Name = "toolStripSeparator9"; + this.toolStripSeparator9.Size = new System.Drawing.Size(264, 6); + // + // GetDictionariesToolStripMenuItem + // + this.GetDictionariesToolStripMenuItem.Name = "GetDictionariesToolStripMenuItem"; + this.GetDictionariesToolStripMenuItem.Size = new System.Drawing.Size(267, 22); + this.GetDictionariesToolStripMenuItem.Text = "Get dictionary..."; + this.GetDictionariesToolStripMenuItem.Click += new System.EventHandler(this.GetDictionariesToolStripMenuItem_Click); + // + // addWordToNameListToolStripMenuItem + // + this.addWordToNameListToolStripMenuItem.Name = "addWordToNameListToolStripMenuItem"; + this.addWordToNameListToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.L))); + this.addWordToNameListToolStripMenuItem.Size = new System.Drawing.Size(267, 22); + this.addWordToNameListToolStripMenuItem.Text = "Add word to names list"; + this.addWordToNameListToolStripMenuItem.Click += new System.EventHandler(this.AddWordToNameListToolStripMenuItemClick); + // + // toolStripMenuItemVideo + // + this.toolStripMenuItemVideo.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.openVideoToolStripMenuItem, + this.toolStripMenuItemOpenVideoFromUrl, + this.toolStripMenuItemOpenDvd, + this.toolStripMenuItemSetAudioTrack, + this.closeVideoToolStripMenuItem, + this.openSecondSubtitleToolStripMenuItem, + this.setVideoOffsetToolStripMenuItem, + this.smpteTimeModedropFrameToolStripMenuItem, + this.toolStripMenuItemImportChapters, + this.toolStripMenuItemImportSceneChanges, + this.toolStripMenuItemRemoveSceneChanges, + this.toolStripMenuItemAddWaveformBatch, + this.generateTextFromCurrentVideoToolStripMenuItem, + this.toolStripSeparator5, + this.showhideWaveformToolStripMenuItem, + this.showhideVideoToolStripMenuItem, + this.toolStripSeparator19, + this.undockVideoControlsToolStripMenuItem, + this.redockVideoControlsToolStripMenuItem}); + this.toolStripMenuItemVideo.Name = "toolStripMenuItemVideo"; + this.toolStripMenuItemVideo.Size = new System.Drawing.Size(50, 20); + this.toolStripMenuItemVideo.Text = "Video"; + this.toolStripMenuItemVideo.DropDownClosed += new System.EventHandler(this.ToolStripMenuItemVideoDropDownClosed); + this.toolStripMenuItemVideo.DropDownOpening += new System.EventHandler(this.ToolStripMenuItemVideoDropDownOpening); + // + // openVideoToolStripMenuItem + // + this.openVideoToolStripMenuItem.Name = "openVideoToolStripMenuItem"; + this.openVideoToolStripMenuItem.Size = new System.Drawing.Size(257, 22); + this.openVideoToolStripMenuItem.Text = "Open video..."; + this.openVideoToolStripMenuItem.Click += new System.EventHandler(this.buttonOpenVideo_Click); + // + // toolStripMenuItemOpenVideoFromUrl + // + this.toolStripMenuItemOpenVideoFromUrl.Name = "toolStripMenuItemOpenVideoFromUrl"; + this.toolStripMenuItemOpenVideoFromUrl.Size = new System.Drawing.Size(257, 22); + this.toolStripMenuItemOpenVideoFromUrl.Text = "Open video from url..."; + this.toolStripMenuItemOpenVideoFromUrl.Click += new System.EventHandler(this.toolStripMenuItemOpenVideoFromUrl_Click); + // + // toolStripMenuItemOpenDvd + // + this.toolStripMenuItemOpenDvd.Name = "toolStripMenuItemOpenDvd"; + this.toolStripMenuItemOpenDvd.Size = new System.Drawing.Size(257, 22); + this.toolStripMenuItemOpenDvd.Text = "Open DVD..."; + this.toolStripMenuItemOpenDvd.Click += new System.EventHandler(this.toolStripMenuItemOpenDvd_Click); + // + // toolStripMenuItemSetAudioTrack + // + this.toolStripMenuItemSetAudioTrack.Name = "toolStripMenuItemSetAudioTrack"; + this.toolStripMenuItemSetAudioTrack.Size = new System.Drawing.Size(257, 22); + this.toolStripMenuItemSetAudioTrack.Text = "Choose audio track"; + // + // closeVideoToolStripMenuItem + // + this.closeVideoToolStripMenuItem.Name = "closeVideoToolStripMenuItem"; + this.closeVideoToolStripMenuItem.Size = new System.Drawing.Size(257, 22); + this.closeVideoToolStripMenuItem.Text = "Close video"; + this.closeVideoToolStripMenuItem.Click += new System.EventHandler(this.CloseVideoToolStripMenuItemClick); + // + // openSecondSubtitleToolStripMenuItem + // + this.openSecondSubtitleToolStripMenuItem.Name = "openSecondSubtitleToolStripMenuItem"; + this.openSecondSubtitleToolStripMenuItem.Size = new System.Drawing.Size(257, 22); + this.openSecondSubtitleToolStripMenuItem.Text = "Open second subtitle..."; + this.openSecondSubtitleToolStripMenuItem.Click += new System.EventHandler(this.openSecondSubtitleToolStripMenuItem_Click); + // + // setVideoOffsetToolStripMenuItem + // + this.setVideoOffsetToolStripMenuItem.Name = "setVideoOffsetToolStripMenuItem"; + this.setVideoOffsetToolStripMenuItem.Size = new System.Drawing.Size(257, 22); + this.setVideoOffsetToolStripMenuItem.Text = "Set video offset..."; + this.setVideoOffsetToolStripMenuItem.Click += new System.EventHandler(this.setVideoOffsetToolStripMenuItem_Click); + // + // smpteTimeModedropFrameToolStripMenuItem + // + this.smpteTimeModedropFrameToolStripMenuItem.Name = "smpteTimeModedropFrameToolStripMenuItem"; + this.smpteTimeModedropFrameToolStripMenuItem.Size = new System.Drawing.Size(257, 22); + this.smpteTimeModedropFrameToolStripMenuItem.Text = "SMPTE timing (drop frame)"; + this.smpteTimeModedropFrameToolStripMenuItem.Click += new System.EventHandler(this.SmpteTimeModedropFrameToolStripMenuItem_Click); + // + // toolStripMenuItemImportChapters + // + this.toolStripMenuItemImportChapters.Name = "toolStripMenuItemImportChapters"; + this.toolStripMenuItemImportChapters.Size = new System.Drawing.Size(257, 22); + this.toolStripMenuItemImportChapters.Text = "Import chapters from video..."; + this.toolStripMenuItemImportChapters.Click += new System.EventHandler(this.toolStripMenuItemImportChapters_Click); + // + // toolStripMenuItemImportSceneChanges + // + this.toolStripMenuItemImportSceneChanges.Name = "toolStripMenuItemImportSceneChanges"; + this.toolStripMenuItemImportSceneChanges.Size = new System.Drawing.Size(257, 22); + this.toolStripMenuItemImportSceneChanges.Text = "Import scene changes..."; + this.toolStripMenuItemImportSceneChanges.Click += new System.EventHandler(this.toolStripMenuItemImportSceneChanges_Click); + // + // toolStripMenuItemRemoveSceneChanges + // + this.toolStripMenuItemRemoveSceneChanges.Name = "toolStripMenuItemRemoveSceneChanges"; + this.toolStripMenuItemRemoveSceneChanges.Size = new System.Drawing.Size(257, 22); + this.toolStripMenuItemRemoveSceneChanges.Text = "Remove scene changes"; + this.toolStripMenuItemRemoveSceneChanges.Click += new System.EventHandler(this.toolStripMenuItemRemoveSceneChanges_Click); + // + // toolStripMenuItemAddWaveformBatch + // + this.toolStripMenuItemAddWaveformBatch.Name = "toolStripMenuItemAddWaveformBatch"; + this.toolStripMenuItemAddWaveformBatch.Size = new System.Drawing.Size(257, 22); + this.toolStripMenuItemAddWaveformBatch.Text = "Add waveform batch..."; + this.toolStripMenuItemAddWaveformBatch.Click += new System.EventHandler(this.ToolStripMenuItemAddWaveformBatchClick); + // + // generateTextFromCurrentVideoToolStripMenuItem + // + this.generateTextFromCurrentVideoToolStripMenuItem.Name = "generateTextFromCurrentVideoToolStripMenuItem"; + this.generateTextFromCurrentVideoToolStripMenuItem.Size = new System.Drawing.Size(257, 22); + this.generateTextFromCurrentVideoToolStripMenuItem.Text = "Generate text from current video..."; + this.generateTextFromCurrentVideoToolStripMenuItem.Click += new System.EventHandler(this.generateTextFromCurrentVideoToolStripMenuItem_Click); + // + // toolStripSeparator5 + // + this.toolStripSeparator5.Name = "toolStripSeparator5"; + this.toolStripSeparator5.Size = new System.Drawing.Size(254, 6); + // + // showhideWaveformToolStripMenuItem + // + this.showhideWaveformToolStripMenuItem.Name = "showhideWaveformToolStripMenuItem"; + this.showhideWaveformToolStripMenuItem.Size = new System.Drawing.Size(257, 22); + this.showhideWaveformToolStripMenuItem.Text = "Show/hide waveform"; + this.showhideWaveformToolStripMenuItem.Click += new System.EventHandler(this.ShowhideWaveformToolStripMenuItemClick); + // + // showhideVideoToolStripMenuItem + // + this.showhideVideoToolStripMenuItem.Name = "showhideVideoToolStripMenuItem"; + this.showhideVideoToolStripMenuItem.Size = new System.Drawing.Size(257, 22); + this.showhideVideoToolStripMenuItem.Text = "Show/hide video"; + this.showhideVideoToolStripMenuItem.Click += new System.EventHandler(this.toolStripButtonToggleVideo_Click); + // + // toolStripSeparator19 + // + this.toolStripSeparator19.Name = "toolStripSeparator19"; + this.toolStripSeparator19.Size = new System.Drawing.Size(254, 6); + // + // undockVideoControlsToolStripMenuItem + // + this.undockVideoControlsToolStripMenuItem.Name = "undockVideoControlsToolStripMenuItem"; + this.undockVideoControlsToolStripMenuItem.Size = new System.Drawing.Size(257, 22); + this.undockVideoControlsToolStripMenuItem.Text = "Un-dock video controls"; + this.undockVideoControlsToolStripMenuItem.Click += new System.EventHandler(this.UndockVideoControlsToolStripMenuItemClick); + // + // redockVideoControlsToolStripMenuItem + // + this.redockVideoControlsToolStripMenuItem.Name = "redockVideoControlsToolStripMenuItem"; + this.redockVideoControlsToolStripMenuItem.Size = new System.Drawing.Size(257, 22); + this.redockVideoControlsToolStripMenuItem.Text = "Re-dock video controls"; + this.redockVideoControlsToolStripMenuItem.Visible = false; + this.redockVideoControlsToolStripMenuItem.Click += new System.EventHandler(this.RedockVideoControlsToolStripMenuItemClick); + // + // toolStripMenuItemSynchronization + // + this.toolStripMenuItemSynchronization.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemAdjustAllTimes, + this.visualSyncToolStripMenuItem, + this.toolStripMenuItemPointSync, + this.pointSyncViaOtherSubtitleToolStripMenuItem, + this.toolStripMenuItemChangeFrameRate2, + this.changeSpeedInPercentToolStripMenuItem}); + this.toolStripMenuItemSynchronization.Name = "toolStripMenuItemSynchronization"; + this.toolStripMenuItemSynchronization.Size = new System.Drawing.Size(106, 20); + this.toolStripMenuItemSynchronization.Text = "Synchronization"; + // + // toolStripMenuItemAdjustAllTimes + // + this.toolStripMenuItemAdjustAllTimes.Name = "toolStripMenuItemAdjustAllTimes"; + this.toolStripMenuItemAdjustAllTimes.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.A))); + this.toolStripMenuItemAdjustAllTimes.Size = new System.Drawing.Size(324, 22); + this.toolStripMenuItemAdjustAllTimes.Text = "Adjust times (show earlier/later)..."; + this.toolStripMenuItemAdjustAllTimes.Click += new System.EventHandler(this.toolStripMenuItemAdjustAllTimes_Click); + // + // visualSyncToolStripMenuItem + // + this.visualSyncToolStripMenuItem.Name = "visualSyncToolStripMenuItem"; + this.visualSyncToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.V))); + this.visualSyncToolStripMenuItem.Size = new System.Drawing.Size(324, 22); + this.visualSyncToolStripMenuItem.Text = "Visual sync..."; + this.visualSyncToolStripMenuItem.Click += new System.EventHandler(this.VisualSyncToolStripMenuItemClick); + // + // toolStripMenuItemPointSync + // + this.toolStripMenuItemPointSync.Name = "toolStripMenuItemPointSync"; + this.toolStripMenuItemPointSync.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.P))); + this.toolStripMenuItemPointSync.Size = new System.Drawing.Size(324, 22); + this.toolStripMenuItemPointSync.Text = "Point sync..."; + this.toolStripMenuItemPointSync.Click += new System.EventHandler(this.toolStripMenuItemPointSync_Click); + // + // pointSyncViaOtherSubtitleToolStripMenuItem + // + this.pointSyncViaOtherSubtitleToolStripMenuItem.Name = "pointSyncViaOtherSubtitleToolStripMenuItem"; + this.pointSyncViaOtherSubtitleToolStripMenuItem.Size = new System.Drawing.Size(324, 22); + this.pointSyncViaOtherSubtitleToolStripMenuItem.Text = "Point sync via other subtitle..."; + this.pointSyncViaOtherSubtitleToolStripMenuItem.Click += new System.EventHandler(this.pointSyncViaOtherSubtitleToolStripMenuItem_Click); + // + // toolStripMenuItemChangeFrameRate2 + // + this.toolStripMenuItemChangeFrameRate2.Name = "toolStripMenuItemChangeFrameRate2"; + this.toolStripMenuItemChangeFrameRate2.Size = new System.Drawing.Size(324, 22); + this.toolStripMenuItemChangeFrameRate2.Text = "Change frame rate..."; + this.toolStripMenuItemChangeFrameRate2.Click += new System.EventHandler(this.ToolStripMenuItemChangeFrameRateClick); + // + // changeSpeedInPercentToolStripMenuItem + // + this.changeSpeedInPercentToolStripMenuItem.Name = "changeSpeedInPercentToolStripMenuItem"; + this.changeSpeedInPercentToolStripMenuItem.Size = new System.Drawing.Size(324, 22); + this.changeSpeedInPercentToolStripMenuItem.Text = "Change speed in percent..."; + this.changeSpeedInPercentToolStripMenuItem.Click += new System.EventHandler(this.changeSpeedInPercentToolStripMenuItem_Click); + // + // toolStripMenuItemAutoTranslate + // + this.toolStripMenuItemAutoTranslate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.translatepoweredByMicrosoftToolStripMenuItem, + this.translateByGoogleToolStripMenuItem, + this.translateFromSwedishToDanishToolStripMenuItem}); + this.toolStripMenuItemAutoTranslate.Name = "toolStripMenuItemAutoTranslate"; + this.toolStripMenuItemAutoTranslate.Size = new System.Drawing.Size(94, 20); + this.toolStripMenuItemAutoTranslate.Text = "Auto-translate"; + this.toolStripMenuItemAutoTranslate.DropDownOpening += new System.EventHandler(this.toolStripMenuItemAutoTranslate_DropDownOpening); + // + // translatepoweredByMicrosoftToolStripMenuItem + // + this.translatepoweredByMicrosoftToolStripMenuItem.Name = "translatepoweredByMicrosoftToolStripMenuItem"; + this.translatepoweredByMicrosoftToolStripMenuItem.Size = new System.Drawing.Size(402, 22); + this.translatepoweredByMicrosoftToolStripMenuItem.Text = "Translate (powered by Microsoft)..."; + this.translatepoweredByMicrosoftToolStripMenuItem.Click += new System.EventHandler(this.translatepoweredByMicrosoftToolStripMenuItem_Click); + // + // translateByGoogleToolStripMenuItem + // + this.translateByGoogleToolStripMenuItem.Name = "translateByGoogleToolStripMenuItem"; + this.translateByGoogleToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.G))); + this.translateByGoogleToolStripMenuItem.Size = new System.Drawing.Size(402, 22); + this.translateByGoogleToolStripMenuItem.Text = "Translate (powered by Google)..."; + this.translateByGoogleToolStripMenuItem.Click += new System.EventHandler(this.TranslateByGoogleToolStripMenuItemClick); + // + // translateFromSwedishToDanishToolStripMenuItem + // + this.translateFromSwedishToDanishToolStripMenuItem.Name = "translateFromSwedishToDanishToolStripMenuItem"; + this.translateFromSwedishToDanishToolStripMenuItem.Size = new System.Drawing.Size(402, 22); + this.translateFromSwedishToDanishToolStripMenuItem.Text = "Translate from swedish to danish (powered by nikse.dk/mt)..."; + this.translateFromSwedishToDanishToolStripMenuItem.Click += new System.EventHandler(this.TranslateFromSwedishToDanishToolStripMenuItemClick); + // + // optionsToolStripMenuItem + // + this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.settingsToolStripMenuItem, + this.changeLanguageToolStripMenuItem}); + this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; + this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); + this.optionsToolStripMenuItem.Text = "Options"; + // + // settingsToolStripMenuItem + // + this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; + this.settingsToolStripMenuItem.Size = new System.Drawing.Size(181, 22); + this.settingsToolStripMenuItem.Text = "Settings"; + this.settingsToolStripMenuItem.Click += new System.EventHandler(this.SettingsToolStripMenuItemClick); + // + // changeLanguageToolStripMenuItem + // + this.changeLanguageToolStripMenuItem.Name = "changeLanguageToolStripMenuItem"; + this.changeLanguageToolStripMenuItem.Size = new System.Drawing.Size(181, 22); + this.changeLanguageToolStripMenuItem.Text = "Change language..."; + this.changeLanguageToolStripMenuItem.Click += new System.EventHandler(this.ChangeLanguageToolStripMenuItemClick); + // + // toolStripMenuItemNetworking + // + this.toolStripMenuItemNetworking.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.startServerToolStripMenuItem, + this.joinSessionToolStripMenuItem, + this.chatToolStripMenuItem, + this.showSessionKeyLogToolStripMenuItem, + this.leaveSessionToolStripMenuItem}); + this.toolStripMenuItemNetworking.Name = "toolStripMenuItemNetworking"; + this.toolStripMenuItemNetworking.Size = new System.Drawing.Size(81, 20); + this.toolStripMenuItemNetworking.Text = "Networking"; + this.toolStripMenuItemNetworking.DropDownOpening += new System.EventHandler(this.toolStripMenuItemNetworking_DropDownOpening); + // + // startServerToolStripMenuItem + // + this.startServerToolStripMenuItem.Name = "startServerToolStripMenuItem"; + this.startServerToolStripMenuItem.Size = new System.Drawing.Size(217, 22); + this.startServerToolStripMenuItem.Text = "Start new session"; + this.startServerToolStripMenuItem.Click += new System.EventHandler(this.startServerToolStripMenuItem_Click); + // + // joinSessionToolStripMenuItem + // + this.joinSessionToolStripMenuItem.Name = "joinSessionToolStripMenuItem"; + this.joinSessionToolStripMenuItem.Size = new System.Drawing.Size(217, 22); + this.joinSessionToolStripMenuItem.Text = "Join session"; + this.joinSessionToolStripMenuItem.Click += new System.EventHandler(this.joinSessionToolStripMenuItem_Click); + // + // chatToolStripMenuItem + // + this.chatToolStripMenuItem.Name = "chatToolStripMenuItem"; + this.chatToolStripMenuItem.Size = new System.Drawing.Size(217, 22); + this.chatToolStripMenuItem.Text = "Chat"; + this.chatToolStripMenuItem.Click += new System.EventHandler(this.chatToolStripMenuItem_Click); + // + // showSessionKeyLogToolStripMenuItem + // + this.showSessionKeyLogToolStripMenuItem.Name = "showSessionKeyLogToolStripMenuItem"; + this.showSessionKeyLogToolStripMenuItem.Size = new System.Drawing.Size(217, 22); + this.showSessionKeyLogToolStripMenuItem.Text = "Show session info and log"; + this.showSessionKeyLogToolStripMenuItem.Click += new System.EventHandler(this.showSessionKeyLogToolStripMenuItem_Click); + // + // leaveSessionToolStripMenuItem + // + this.leaveSessionToolStripMenuItem.Name = "leaveSessionToolStripMenuItem"; + this.leaveSessionToolStripMenuItem.Size = new System.Drawing.Size(217, 22); + this.leaveSessionToolStripMenuItem.Text = "Leave session"; + this.leaveSessionToolStripMenuItem.Click += new System.EventHandler(this.LeaveSessionToolStripMenuItemClick); + // + // helpToolStripMenuItem + // + this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.checkForUpdatesToolStripMenuItem, + this.toolStripMenuItemSplitterCheckForUpdates, + this.helpToolStripMenuItem1, + this.aboutToolStripMenuItem}); + this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; + this.helpToolStripMenuItem.Size = new System.Drawing.Size(45, 20); + this.helpToolStripMenuItem.Text = "Help"; + this.helpToolStripMenuItem.DropDownClosed += new System.EventHandler(this.MenuClosed); + this.helpToolStripMenuItem.DropDownOpening += new System.EventHandler(this.MenuOpened); + // + // checkForUpdatesToolStripMenuItem + // + this.checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem"; + this.checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(181, 22); + this.checkForUpdatesToolStripMenuItem.Text = "Check for updates..."; + this.checkForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click); + // + // toolStripMenuItemSplitterCheckForUpdates + // + this.toolStripMenuItemSplitterCheckForUpdates.Name = "toolStripMenuItemSplitterCheckForUpdates"; + this.toolStripMenuItemSplitterCheckForUpdates.Size = new System.Drawing.Size(178, 6); + // + // helpToolStripMenuItem1 + // + this.helpToolStripMenuItem1.Name = "helpToolStripMenuItem1"; + this.helpToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.F1; + this.helpToolStripMenuItem1.Size = new System.Drawing.Size(181, 22); + this.helpToolStripMenuItem1.Text = "Help"; + this.helpToolStripMenuItem1.Click += new System.EventHandler(this.HelpToolStripMenuItem1Click); + // + // aboutToolStripMenuItem + // + this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; + this.aboutToolStripMenuItem.Size = new System.Drawing.Size(181, 22); + this.aboutToolStripMenuItem.Text = "About"; + this.aboutToolStripMenuItem.Click += new System.EventHandler(this.AboutToolStripMenuItemClick); + // + // contextMenuStripListview + // + this.contextMenuStripListview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.setStylesForSelectedLinesToolStripMenuItem, + this.setActorForSelectedLinesToolStripMenuItem, + this.toolStripMenuItemAssStyles, + this.toolStripMenuItemSetRegion, + this.toolStripMenuItemSetLanguage, + this.toolStripMenuItemWebVTT, + this.toolStripMenuItemPreview, + this.toolStripMenuItemDelete, + this.toolStripMenuItemInsertBefore, + this.toolStripMenuItemInsertAfter, + this.toolStripMenuItemInsertSubtitle, + this.toolStripMenuItemCopySourceText, + this.toolStripMenuItemColumn, + this.toolStripMenuItemBookmark, + this.toolStripSeparator7, + this.splitLineToolStripMenuItem, + this.toolStripMenuItemMergeLines, + this.toolStripMenuItemMergeDialog, + this.mergeBeforeToolStripMenuItem, + this.mergeAfterToolStripMenuItem, + this.toolStripSeparator4, + this.extendBeforeToolStripMenuItem, + this.extendAfterToolStripMenuItem, + this.toolStripSeparator8, + this.removeFormattinglToolStripMenuItem, + this.boldToolStripMenuItem, + this.italicToolStripMenuItem, + this.boxToolStripMenuItem, + this.underlineToolStripMenuItem, + this.colorToolStripMenuItem, + this.toolStripMenuItemFont, + this.toolStripMenuItemAlignment, + this.toolStripMenuItemSurroundWithMusicSymbols, + this.toolStripSeparator2, + this.toolStripMenuItemAutoBreakLines, + this.toolStripMenuItemUnbreakLines, + this.toolStripSeparatorBreakLines, + this.typeEffectToolStripMenuItem, + this.karokeeEffectToolStripMenuItem, + this.toolStripSeparatorAdvancedFunctions, + this.showSelectedLinesEarlierlaterToolStripMenuItem, + this.visualSyncSelectedLinesToolStripMenuItem, + this.toolStripMenuItemGoogleMicrosoftTranslateSelLine, + this.toolStripMenuItemTranslateSelected, + this.adjustDisplayTimeForSelectedLinesToolStripMenuItem, + this.fixCommonErrorsInSelectedLinesToolStripMenuItem, + this.changeCasingForSelectedLinesToolStripMenuItem, + this.toolStripMenuItemSaveSelectedLines}); + this.contextMenuStripListview.Name = "contextMenuStripListview"; + this.contextMenuStripListview.Size = new System.Drawing.Size(285, 964); + this.contextMenuStripListview.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.MenuClosed); + this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening); + this.contextMenuStripListview.Opened += new System.EventHandler(this.MenuOpened); + // + // setStylesForSelectedLinesToolStripMenuItem + // + this.setStylesForSelectedLinesToolStripMenuItem.Name = "setStylesForSelectedLinesToolStripMenuItem"; + this.setStylesForSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.setStylesForSelectedLinesToolStripMenuItem.Text = "ASS: Set styles for selected lines..."; + // + // setActorForSelectedLinesToolStripMenuItem + // + this.setActorForSelectedLinesToolStripMenuItem.Name = "setActorForSelectedLinesToolStripMenuItem"; + this.setActorForSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.setActorForSelectedLinesToolStripMenuItem.Text = "ASS: Set styles for selected lines..."; + // + // toolStripMenuItemAssStyles + // + this.toolStripMenuItemAssStyles.Name = "toolStripMenuItemAssStyles"; + this.toolStripMenuItemAssStyles.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemAssStyles.Text = "ASS: Styles..."; + this.toolStripMenuItemAssStyles.Click += new System.EventHandler(this.toolStripMenuItemAssStyles_Click); + // + // toolStripMenuItemSetRegion + // + this.toolStripMenuItemSetRegion.Name = "toolStripMenuItemSetRegion"; + this.toolStripMenuItemSetRegion.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemSetRegion.Text = "Timed text - set region"; + // + // toolStripMenuItemSetLanguage + // + this.toolStripMenuItemSetLanguage.Name = "toolStripMenuItemSetLanguage"; + this.toolStripMenuItemSetLanguage.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemSetLanguage.Text = "Timed text - set language"; + // + // toolStripMenuItemWebVTT + // + this.toolStripMenuItemWebVTT.Name = "toolStripMenuItemWebVTT"; + this.toolStripMenuItemWebVTT.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemWebVTT.Text = "WebVTT voice"; + // + // toolStripMenuItemPreview + // + this.toolStripMenuItemPreview.Name = "toolStripMenuItemPreview"; + this.toolStripMenuItemPreview.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemPreview.Text = "WebVTT browser preview"; + this.toolStripMenuItemPreview.Click += new System.EventHandler(this.toolStripMenuItemPreview_Click); + // + // toolStripMenuItemDelete + // + this.toolStripMenuItemDelete.Name = "toolStripMenuItemDelete"; + this.toolStripMenuItemDelete.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemDelete.Text = "Delete"; + this.toolStripMenuItemDelete.Click += new System.EventHandler(this.ToolStripMenuItemDeleteClick); + // + // toolStripMenuItemInsertBefore + // + this.toolStripMenuItemInsertBefore.Name = "toolStripMenuItemInsertBefore"; + this.toolStripMenuItemInsertBefore.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemInsertBefore.Text = "Insert before"; + this.toolStripMenuItemInsertBefore.Click += new System.EventHandler(this.ToolStripMenuItemInsertBeforeClick); + // + // toolStripMenuItemInsertAfter + // + this.toolStripMenuItemInsertAfter.Name = "toolStripMenuItemInsertAfter"; + this.toolStripMenuItemInsertAfter.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemInsertAfter.Text = "Insert after"; + this.toolStripMenuItemInsertAfter.Click += new System.EventHandler(this.ToolStripMenuItemInsertAfterClick); + // + // toolStripMenuItemInsertSubtitle + // + this.toolStripMenuItemInsertSubtitle.Name = "toolStripMenuItemInsertSubtitle"; + this.toolStripMenuItemInsertSubtitle.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemInsertSubtitle.Text = "Insert subtitle file after this line..."; + this.toolStripMenuItemInsertSubtitle.Click += new System.EventHandler(this.ToolStripMenuItemInsertSubtitleClick); + // + // toolStripMenuItemCopySourceText + // + this.toolStripMenuItemCopySourceText.Name = "toolStripMenuItemCopySourceText"; + this.toolStripMenuItemCopySourceText.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemCopySourceText.Text = "Copy as text to clipboard"; + this.toolStripMenuItemCopySourceText.Click += new System.EventHandler(this.ToolStripMenuItemCopySourceTextClick); + // + // toolStripMenuItemColumn + // + this.toolStripMenuItemColumn.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.columnDeleteTextOnlyToolStripMenuItem, + this.toolStripMenuItemColumnDeleteText, + this.ShiftTextCellsDownToolStripMenuItem, + this.toolStripMenuItemInsertTextFromSub, + this.toolStripMenuItemColumnImportText, + this.toolStripMenuItemPasteSpecial, + this.copyOriginalTextToCurrentToolStripMenuItem, + this.moveTextUpToolStripMenuItem, + this.moveTextDownToolStripMenuItem}); + this.toolStripMenuItemColumn.Name = "toolStripMenuItemColumn"; + this.toolStripMenuItemColumn.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemColumn.Text = "Column"; + this.toolStripMenuItemColumn.DropDownOpening += new System.EventHandler(this.toolStripMenuItemColumn_DropDownOpening); + // + // columnDeleteTextOnlyToolStripMenuItem + // + this.columnDeleteTextOnlyToolStripMenuItem.Name = "columnDeleteTextOnlyToolStripMenuItem"; + this.columnDeleteTextOnlyToolStripMenuItem.Size = new System.Drawing.Size(314, 22); + this.columnDeleteTextOnlyToolStripMenuItem.Text = "Delete text"; + this.columnDeleteTextOnlyToolStripMenuItem.Click += new System.EventHandler(this.columnDeleteTextOnlyToolStripMenuItem_Click); + // + // toolStripMenuItemColumnDeleteText + // + this.toolStripMenuItemColumnDeleteText.Name = "toolStripMenuItemColumnDeleteText"; + this.toolStripMenuItemColumnDeleteText.Size = new System.Drawing.Size(314, 22); + this.toolStripMenuItemColumnDeleteText.Text = "Delete text and shift text cells up"; + this.toolStripMenuItemColumnDeleteText.Click += new System.EventHandler(this.deleteAndShiftCellsUpToolStripMenuItem_Click); + // + // ShiftTextCellsDownToolStripMenuItem + // + this.ShiftTextCellsDownToolStripMenuItem.Name = "ShiftTextCellsDownToolStripMenuItem"; + this.ShiftTextCellsDownToolStripMenuItem.Size = new System.Drawing.Size(314, 22); + this.ShiftTextCellsDownToolStripMenuItem.Text = "Insert and shift text cells down"; + this.ShiftTextCellsDownToolStripMenuItem.Click += new System.EventHandler(this.ShiftTextCellsDownToolStripMenuItem_Click); + // + // toolStripMenuItemInsertTextFromSub + // + this.toolStripMenuItemInsertTextFromSub.Name = "toolStripMenuItemInsertTextFromSub"; + this.toolStripMenuItemInsertTextFromSub.Size = new System.Drawing.Size(314, 22); + this.toolStripMenuItemInsertTextFromSub.Text = "Insert text from subtitle and shift cells down..."; + this.toolStripMenuItemInsertTextFromSub.Click += new System.EventHandler(this.toolStripMenuItemInsertTextFromSub_Click); + // + // toolStripMenuItemColumnImportText + // + this.toolStripMenuItemColumnImportText.Name = "toolStripMenuItemColumnImportText"; + this.toolStripMenuItemColumnImportText.Size = new System.Drawing.Size(314, 22); + this.toolStripMenuItemColumnImportText.Text = "Import text and shift text cells down..."; + this.toolStripMenuItemColumnImportText.Click += new System.EventHandler(this.toolStripMenuItemColumnImportText_Click); + // + // toolStripMenuItemPasteSpecial + // + this.toolStripMenuItemPasteSpecial.Name = "toolStripMenuItemPasteSpecial"; + this.toolStripMenuItemPasteSpecial.Size = new System.Drawing.Size(314, 22); + this.toolStripMenuItemPasteSpecial.Text = "Paste from clipboard..."; + this.toolStripMenuItemPasteSpecial.Click += new System.EventHandler(this.toolStripMenuItemPasteSpecial_Click); + // + // copyOriginalTextToCurrentToolStripMenuItem + // + this.copyOriginalTextToCurrentToolStripMenuItem.Name = "copyOriginalTextToCurrentToolStripMenuItem"; + this.copyOriginalTextToCurrentToolStripMenuItem.Size = new System.Drawing.Size(314, 22); + this.copyOriginalTextToCurrentToolStripMenuItem.Text = "Copy original text to current"; + this.copyOriginalTextToCurrentToolStripMenuItem.Click += new System.EventHandler(this.copyOriginalTextToCurrentToolStripMenuItem_Click); + // + // moveTextUpToolStripMenuItem + // + this.moveTextUpToolStripMenuItem.Name = "moveTextUpToolStripMenuItem"; + this.moveTextUpToolStripMenuItem.Size = new System.Drawing.Size(314, 22); + this.moveTextUpToolStripMenuItem.Text = "Move text up"; + this.moveTextUpToolStripMenuItem.Click += new System.EventHandler(this.moveTextUpToolStripMenuItem_Click); + // + // moveTextDownToolStripMenuItem + // + this.moveTextDownToolStripMenuItem.Name = "moveTextDownToolStripMenuItem"; + this.moveTextDownToolStripMenuItem.Size = new System.Drawing.Size(314, 22); + this.moveTextDownToolStripMenuItem.Text = "Move text down"; + this.moveTextDownToolStripMenuItem.Click += new System.EventHandler(this.moveTextDownToolStripMenuItem_Click); + // + // toolStripMenuItemBookmark + // + this.toolStripMenuItemBookmark.Name = "toolStripMenuItemBookmark"; + this.toolStripMenuItemBookmark.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemBookmark.Text = "Bookmark..."; + this.toolStripMenuItemBookmark.Click += new System.EventHandler(this.toolStripMenuItemBookmark_Click); + // + // toolStripSeparator7 + // + this.toolStripSeparator7.Name = "toolStripSeparator7"; + this.toolStripSeparator7.Size = new System.Drawing.Size(281, 6); + // + // splitLineToolStripMenuItem + // + this.splitLineToolStripMenuItem.Name = "splitLineToolStripMenuItem"; + this.splitLineToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.splitLineToolStripMenuItem.Text = "Split"; + this.splitLineToolStripMenuItem.Click += new System.EventHandler(this.SplitLineToolStripMenuItemClick); + // + // toolStripMenuItemMergeLines + // + this.toolStripMenuItemMergeLines.Name = "toolStripMenuItemMergeLines"; + this.toolStripMenuItemMergeLines.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.M))); + this.toolStripMenuItemMergeLines.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemMergeLines.Text = "Merge selected lines"; + this.toolStripMenuItemMergeLines.Click += new System.EventHandler(this.ToolStripMenuItemMergeLinesClick); + // + // toolStripMenuItemMergeDialog + // + this.toolStripMenuItemMergeDialog.Name = "toolStripMenuItemMergeDialog"; + this.toolStripMenuItemMergeDialog.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemMergeDialog.Text = "Merge selected lines as dialog"; + this.toolStripMenuItemMergeDialog.Click += new System.EventHandler(this.ToolStripMenuItemMergeDialogClick); + // + // mergeBeforeToolStripMenuItem + // + this.mergeBeforeToolStripMenuItem.Name = "mergeBeforeToolStripMenuItem"; + this.mergeBeforeToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.mergeBeforeToolStripMenuItem.Text = "Merge with line before"; + this.mergeBeforeToolStripMenuItem.Click += new System.EventHandler(this.MergeBeforeToolStripMenuItemClick); + // + // mergeAfterToolStripMenuItem + // + this.mergeAfterToolStripMenuItem.Name = "mergeAfterToolStripMenuItem"; + this.mergeAfterToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.mergeAfterToolStripMenuItem.Text = "Merge with line after"; + this.mergeAfterToolStripMenuItem.Click += new System.EventHandler(this.MergeAfterToolStripMenuItemClick); + // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(281, 6); + // + // extendBeforeToolStripMenuItem + // + this.extendBeforeToolStripMenuItem.Name = "extendBeforeToolStripMenuItem"; + this.extendBeforeToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.extendBeforeToolStripMenuItem.Text = "Extend to line before"; + this.extendBeforeToolStripMenuItem.Click += new System.EventHandler(this.ExtendBeforeToolStripMenuItemClick); + // + // extendAfterToolStripMenuItem + // + this.extendAfterToolStripMenuItem.Name = "extendAfterToolStripMenuItem"; + this.extendAfterToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.extendAfterToolStripMenuItem.Text = "Extend to line after"; + this.extendAfterToolStripMenuItem.Click += new System.EventHandler(this.ExtendAfterToolStripMenuItemClick); + // + // toolStripSeparator8 + // + this.toolStripSeparator8.Name = "toolStripSeparator8"; + this.toolStripSeparator8.Size = new System.Drawing.Size(281, 6); + // + // removeFormattinglToolStripMenuItem + // + this.removeFormattinglToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.removeAllFormattingsToolStripMenuItem, + this.removeBoldToolStripMenuItem, + this.removeItalicToolStripMenuItem, + this.removeUnderlineToolStripMenuItem, + this.removeColorToolStripMenuItem, + this.removeFontNameToolStripMenuItem, + this.removeAlignmentToolStripMenuItem}); + this.removeFormattinglToolStripMenuItem.Name = "removeFormattinglToolStripMenuItem"; + this.removeFormattinglToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.removeFormattinglToolStripMenuItem.Text = "Remove formatting"; + // + // removeAllFormattingsToolStripMenuItem + // + this.removeAllFormattingsToolStripMenuItem.Name = "removeAllFormattingsToolStripMenuItem"; + this.removeAllFormattingsToolStripMenuItem.Size = new System.Drawing.Size(197, 22); + this.removeAllFormattingsToolStripMenuItem.Text = "Remove all formattings"; + this.removeAllFormattingsToolStripMenuItem.Click += new System.EventHandler(this.removeAllFormattingsToolStripMenuItem_Click); + // + // removeBoldToolStripMenuItem + // + this.removeBoldToolStripMenuItem.Name = "removeBoldToolStripMenuItem"; + this.removeBoldToolStripMenuItem.Size = new System.Drawing.Size(197, 22); + this.removeBoldToolStripMenuItem.Text = "Remove bold"; + this.removeBoldToolStripMenuItem.Click += new System.EventHandler(this.removeBoldToolStripMenuItem_Click); + // + // removeItalicToolStripMenuItem + // + this.removeItalicToolStripMenuItem.Name = "removeItalicToolStripMenuItem"; + this.removeItalicToolStripMenuItem.Size = new System.Drawing.Size(197, 22); + this.removeItalicToolStripMenuItem.Text = "Remove italic"; + this.removeItalicToolStripMenuItem.Click += new System.EventHandler(this.removeItalicToolStripMenuItem_Click); + // + // removeUnderlineToolStripMenuItem + // + this.removeUnderlineToolStripMenuItem.Name = "removeUnderlineToolStripMenuItem"; + this.removeUnderlineToolStripMenuItem.Size = new System.Drawing.Size(197, 22); + this.removeUnderlineToolStripMenuItem.Text = "Remove underline"; + this.removeUnderlineToolStripMenuItem.Click += new System.EventHandler(this.removeUnderlineToolStripMenuItem_Click); + // + // removeColorToolStripMenuItem + // + this.removeColorToolStripMenuItem.Name = "removeColorToolStripMenuItem"; + this.removeColorToolStripMenuItem.Size = new System.Drawing.Size(197, 22); + this.removeColorToolStripMenuItem.Text = "Remove color"; + this.removeColorToolStripMenuItem.Click += new System.EventHandler(this.removeColorToolStripMenuItem_Click); + // + // removeFontNameToolStripMenuItem + // + this.removeFontNameToolStripMenuItem.Name = "removeFontNameToolStripMenuItem"; + this.removeFontNameToolStripMenuItem.Size = new System.Drawing.Size(197, 22); + this.removeFontNameToolStripMenuItem.Text = "Remove font name"; + this.removeFontNameToolStripMenuItem.Click += new System.EventHandler(this.removeFontNameToolStripMenuItem_Click); + // + // removeAlignmentToolStripMenuItem + // + this.removeAlignmentToolStripMenuItem.Name = "removeAlignmentToolStripMenuItem"; + this.removeAlignmentToolStripMenuItem.Size = new System.Drawing.Size(197, 22); + this.removeAlignmentToolStripMenuItem.Text = "Remove alignment"; + this.removeAlignmentToolStripMenuItem.Click += new System.EventHandler(this.removeAlignmentToolStripMenuItem_Click); + // + // boldToolStripMenuItem + // + this.boldToolStripMenuItem.Name = "boldToolStripMenuItem"; + this.boldToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.boldToolStripMenuItem.Text = "Bold"; + this.boldToolStripMenuItem.Click += new System.EventHandler(this.BoldToolStripMenuItemClick); + // + // italicToolStripMenuItem + // + this.italicToolStripMenuItem.Name = "italicToolStripMenuItem"; + this.italicToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); + this.italicToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.italicToolStripMenuItem.Text = "Italic"; + this.italicToolStripMenuItem.Click += new System.EventHandler(this.ItalicToolStripMenuItemClick); + // + // boxToolStripMenuItem + // + this.boxToolStripMenuItem.Name = "boxToolStripMenuItem"; + this.boxToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.boxToolStripMenuItem.Text = "Box"; + this.boxToolStripMenuItem.Click += new System.EventHandler(this.boxToolStripMenuItem_Click); + // + // underlineToolStripMenuItem + // + this.underlineToolStripMenuItem.Name = "underlineToolStripMenuItem"; + this.underlineToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.underlineToolStripMenuItem.Text = "Underline"; + this.underlineToolStripMenuItem.Click += new System.EventHandler(this.UnderlineToolStripMenuItemClick); + // + // colorToolStripMenuItem + // + this.colorToolStripMenuItem.Name = "colorToolStripMenuItem"; + this.colorToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.colorToolStripMenuItem.Text = "Color..."; + this.colorToolStripMenuItem.Click += new System.EventHandler(this.ColorToolStripMenuItemClick); + // + // toolStripMenuItemFont + // + this.toolStripMenuItemFont.Name = "toolStripMenuItemFont"; + this.toolStripMenuItemFont.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemFont.Text = "Font name..."; + this.toolStripMenuItemFont.Click += new System.EventHandler(this.toolStripMenuItemFont_Click); + // + // toolStripMenuItemAlignment + // + this.toolStripMenuItemAlignment.Name = "toolStripMenuItemAlignment"; + this.toolStripMenuItemAlignment.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemAlignment.Text = "Alignment"; + this.toolStripMenuItemAlignment.Click += new System.EventHandler(this.toolStripMenuItemAlignment_Click); + // + // toolStripMenuItemSurroundWithMusicSymbols + // + this.toolStripMenuItemSurroundWithMusicSymbols.Name = "toolStripMenuItemSurroundWithMusicSymbols"; + this.toolStripMenuItemSurroundWithMusicSymbols.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemSurroundWithMusicSymbols.Text = "♪"; + this.toolStripMenuItemSurroundWithMusicSymbols.Click += new System.EventHandler(this.ToolStripMenuItemSurroundWithMusicSymbolsClick); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(281, 6); + // + // toolStripMenuItemAutoBreakLines + // + this.toolStripMenuItemAutoBreakLines.Name = "toolStripMenuItemAutoBreakLines"; + this.toolStripMenuItemAutoBreakLines.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemAutoBreakLines.Text = "Auto balance selected lines..."; + this.toolStripMenuItemAutoBreakLines.Click += new System.EventHandler(this.ToolStripMenuItemAutoBreakLinesClick); + // + // toolStripMenuItemUnbreakLines + // + this.toolStripMenuItemUnbreakLines.Name = "toolStripMenuItemUnbreakLines"; + this.toolStripMenuItemUnbreakLines.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemUnbreakLines.Text = "Remove line-breaks in selected lines..."; + this.toolStripMenuItemUnbreakLines.Click += new System.EventHandler(this.ToolStripMenuItemUnbreakLinesClick); + // + // toolStripSeparatorBreakLines + // + this.toolStripSeparatorBreakLines.Name = "toolStripSeparatorBreakLines"; + this.toolStripSeparatorBreakLines.Size = new System.Drawing.Size(281, 6); + // + // typeEffectToolStripMenuItem + // + this.typeEffectToolStripMenuItem.Name = "typeEffectToolStripMenuItem"; + this.typeEffectToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.typeEffectToolStripMenuItem.Text = "Typewriter effect..."; + this.typeEffectToolStripMenuItem.Click += new System.EventHandler(this.TypeEffectToolStripMenuItemClick); + // + // karokeeEffectToolStripMenuItem + // + this.karokeeEffectToolStripMenuItem.Name = "karokeeEffectToolStripMenuItem"; + this.karokeeEffectToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.karokeeEffectToolStripMenuItem.Text = "Karaoke effect..."; + this.karokeeEffectToolStripMenuItem.Click += new System.EventHandler(this.KarokeeEffectToolStripMenuItemClick); + // + // toolStripSeparatorAdvancedFunctions + // + this.toolStripSeparatorAdvancedFunctions.Name = "toolStripSeparatorAdvancedFunctions"; + this.toolStripSeparatorAdvancedFunctions.Size = new System.Drawing.Size(281, 6); + // + // showSelectedLinesEarlierlaterToolStripMenuItem + // + this.showSelectedLinesEarlierlaterToolStripMenuItem.Name = "showSelectedLinesEarlierlaterToolStripMenuItem"; + this.showSelectedLinesEarlierlaterToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.showSelectedLinesEarlierlaterToolStripMenuItem.Text = "Show selected lines earlier/later..."; + this.showSelectedLinesEarlierlaterToolStripMenuItem.Click += new System.EventHandler(this.ShowSelectedLinesEarlierlaterToolStripMenuItemClick); + // + // visualSyncSelectedLinesToolStripMenuItem + // + this.visualSyncSelectedLinesToolStripMenuItem.Name = "visualSyncSelectedLinesToolStripMenuItem"; + this.visualSyncSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.visualSyncSelectedLinesToolStripMenuItem.Text = "Visual sync selected lines..."; + this.visualSyncSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.VisualSyncSelectedLinesToolStripMenuItemClick); + // + // toolStripMenuItemGoogleMicrosoftTranslateSelLine + // + this.toolStripMenuItemGoogleMicrosoftTranslateSelLine.Name = "toolStripMenuItemGoogleMicrosoftTranslateSelLine"; + this.toolStripMenuItemGoogleMicrosoftTranslateSelLine.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemGoogleMicrosoftTranslateSelLine.Text = "Google/Microsoft translate selected line"; + this.toolStripMenuItemGoogleMicrosoftTranslateSelLine.Click += new System.EventHandler(this.ToolStripMenuItemGoogleMicrosoftTranslateSelLineClick); + // + // toolStripMenuItemTranslateSelected + // + this.toolStripMenuItemTranslateSelected.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.googleTranslateToolStripMenuItem, + this.microsoftBingTranslateToolStripMenuItem}); + this.toolStripMenuItemTranslateSelected.Name = "toolStripMenuItemTranslateSelected"; + this.toolStripMenuItemTranslateSelected.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemTranslateSelected.Text = "Translate selected lines via..."; + // + // googleTranslateToolStripMenuItem + // + this.googleTranslateToolStripMenuItem.Name = "googleTranslateToolStripMenuItem"; + this.googleTranslateToolStripMenuItem.Size = new System.Drawing.Size(209, 22); + this.googleTranslateToolStripMenuItem.Text = "Google translate..."; + this.googleTranslateToolStripMenuItem.Click += new System.EventHandler(this.googleTranslateToolStripMenuItem_Click); + // + // microsoftBingTranslateToolStripMenuItem + // + this.microsoftBingTranslateToolStripMenuItem.Name = "microsoftBingTranslateToolStripMenuItem"; + this.microsoftBingTranslateToolStripMenuItem.Size = new System.Drawing.Size(209, 22); + this.microsoftBingTranslateToolStripMenuItem.Text = "Microsoft Bing translate..."; + this.microsoftBingTranslateToolStripMenuItem.Click += new System.EventHandler(this.microsoftBingTranslateToolStripMenuItem_Click); + // + // adjustDisplayTimeForSelectedLinesToolStripMenuItem + // + this.adjustDisplayTimeForSelectedLinesToolStripMenuItem.Name = "adjustDisplayTimeForSelectedLinesToolStripMenuItem"; + this.adjustDisplayTimeForSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.adjustDisplayTimeForSelectedLinesToolStripMenuItem.Text = "Adjust display time for selected lines..."; + this.adjustDisplayTimeForSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.AdjustDisplayTimeForSelectedLinesToolStripMenuItemClick); + // + // fixCommonErrorsInSelectedLinesToolStripMenuItem + // + this.fixCommonErrorsInSelectedLinesToolStripMenuItem.Name = "fixCommonErrorsInSelectedLinesToolStripMenuItem"; + this.fixCommonErrorsInSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.fixCommonErrorsInSelectedLinesToolStripMenuItem.Text = "Fix common errors in selected lines..."; + this.fixCommonErrorsInSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.FixCommonErrorsInSelectedLinesToolStripMenuItemClick); + // + // changeCasingForSelectedLinesToolStripMenuItem + // + this.changeCasingForSelectedLinesToolStripMenuItem.Name = "changeCasingForSelectedLinesToolStripMenuItem"; + this.changeCasingForSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(284, 22); + this.changeCasingForSelectedLinesToolStripMenuItem.Text = "Change casing for selected lines..."; + this.changeCasingForSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.ChangeCasingForSelectedLinesToolStripMenuItemClick); + // + // toolStripMenuItemSaveSelectedLines + // + this.toolStripMenuItemSaveSelectedLines.Name = "toolStripMenuItemSaveSelectedLines"; + this.toolStripMenuItemSaveSelectedLines.Size = new System.Drawing.Size(284, 22); + this.toolStripMenuItemSaveSelectedLines.Text = "Save selected lines as..."; + this.toolStripMenuItemSaveSelectedLines.Click += new System.EventHandler(this.ToolStripMenuItemSaveSelectedLinesClick); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // timer1 + // + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // groupBoxVideo + // + this.groupBoxVideo.Controls.Add(this.labelNextWord); + this.groupBoxVideo.Controls.Add(this.audioVisualizer); + this.groupBoxVideo.Controls.Add(this.checkBoxSyncListViewWithVideoWhilePlaying); + this.groupBoxVideo.Controls.Add(this.labelVideoInfo); + this.groupBoxVideo.Controls.Add(this.trackBarWaveformPosition); + this.groupBoxVideo.Controls.Add(this.panelWaveformControls); + this.groupBoxVideo.Controls.Add(this.tabControlButtons); + this.groupBoxVideo.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBoxVideo.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.groupBoxVideo.Location = new System.Drawing.Point(0, 0); + this.groupBoxVideo.Margin = new System.Windows.Forms.Padding(0); + this.groupBoxVideo.Name = "groupBoxVideo"; + this.groupBoxVideo.Padding = new System.Windows.Forms.Padding(0); + this.groupBoxVideo.Size = new System.Drawing.Size(975, 305); + this.groupBoxVideo.TabIndex = 1; + this.groupBoxVideo.TabStop = false; + // + // labelNextWord + // + this.labelNextWord.Anchor = System.Windows.Forms.AnchorStyles.None; + this.labelNextWord.AutoSize = true; + this.labelNextWord.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelNextWord.Location = new System.Drawing.Point(401, 9); + this.labelNextWord.Name = "labelNextWord"; + this.labelNextWord.Size = new System.Drawing.Size(71, 17); + this.labelNextWord.TabIndex = 13; + this.labelNextWord.Text = "Next: xxx"; + this.labelNextWord.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // audioVisualizer + // + this.audioVisualizer.AllowDrop = true; + this.audioVisualizer.AllowNewSelection = true; + this.audioVisualizer.AllowOverlap = false; + this.audioVisualizer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.audioVisualizer.BackColor = System.Drawing.Color.Black; + this.audioVisualizer.BackgroundColor = System.Drawing.Color.Black; + this.audioVisualizer.ClosenessForBorderSelection = 15; + this.audioVisualizer.Color = System.Drawing.Color.GreenYellow; + this.audioVisualizer.CursorColor = System.Drawing.Color.Empty; + this.audioVisualizer.ChaptersColor = System.Drawing.Color.Empty; + this.audioVisualizer.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + this.audioVisualizer.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(18))))); + this.audioVisualizer.InsertAtVideoPositionShortcut = System.Windows.Forms.Keys.Insert; + this.audioVisualizer.Location = new System.Drawing.Point(472, 32); + this.audioVisualizer.Margin = new System.Windows.Forms.Padding(0); + this.audioVisualizer.MouseWheelScrollUpIsForward = true; + this.audioVisualizer.Move100MsLeft = System.Windows.Forms.Keys.None; + this.audioVisualizer.Move100MsRight = System.Windows.Forms.Keys.None; + this.audioVisualizer.MoveOneSecondLeft = System.Windows.Forms.Keys.None; + this.audioVisualizer.MoveOneSecondRight = System.Windows.Forms.Keys.None; + this.audioVisualizer.Name = "audioVisualizer"; + this.audioVisualizer.NewSelectionParagraph = null; + this.audioVisualizer.ParagraphColor = System.Drawing.Color.LimeGreen; + this.audioVisualizer.SceneChanges = ((System.Collections.Generic.List)(resources.GetObject("audioVisualizer.SceneChanges"))); + this.audioVisualizer.SelectedColor = System.Drawing.Color.Red; + this.audioVisualizer.ShowGridLines = true; + this.audioVisualizer.ShowSpectrogram = false; + this.audioVisualizer.ShowWaveform = true; + this.audioVisualizer.Size = new System.Drawing.Size(499, 229); + this.audioVisualizer.StartPositionSeconds = 0D; + this.audioVisualizer.TabIndex = 6; + this.audioVisualizer.TextBold = true; + this.audioVisualizer.TextColor = System.Drawing.Color.Gray; + this.audioVisualizer.TextSize = 9F; + this.audioVisualizer.VerticalZoomFactor = 1D; + this.audioVisualizer.WaveformNotLoadedText = "Click to add waveform"; + this.audioVisualizer.WavePeaks = null; + this.audioVisualizer.ZoomFactor = 1D; + this.audioVisualizer.Click += new System.EventHandler(this.AudioWaveform_Click); + this.audioVisualizer.DragDrop += new System.Windows.Forms.DragEventHandler(this.AudioWaveformDragDrop); + this.audioVisualizer.DragEnter += new System.Windows.Forms.DragEventHandler(this.AudioWaveformDragEnter); + this.audioVisualizer.MouseEnter += new System.EventHandler(this.audioVisualizer_MouseEnter); + // + // checkBoxSyncListViewWithVideoWhilePlaying + // + this.checkBoxSyncListViewWithVideoWhilePlaying.AutoSize = true; + this.checkBoxSyncListViewWithVideoWhilePlaying.Location = new System.Drawing.Point(558, 11); + this.checkBoxSyncListViewWithVideoWhilePlaying.Name = "checkBoxSyncListViewWithVideoWhilePlaying"; + this.checkBoxSyncListViewWithVideoWhilePlaying.Size = new System.Drawing.Size(205, 17); + this.checkBoxSyncListViewWithVideoWhilePlaying.TabIndex = 1; + this.checkBoxSyncListViewWithVideoWhilePlaying.Text = "Sync listview with movie when playing"; + this.checkBoxSyncListViewWithVideoWhilePlaying.UseVisualStyleBackColor = true; + // + // labelVideoInfo + // + this.labelVideoInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelVideoInfo.Location = new System.Drawing.Point(603, 12); + this.labelVideoInfo.Name = "labelVideoInfo"; + this.labelVideoInfo.Size = new System.Drawing.Size(369, 19); + this.labelVideoInfo.TabIndex = 12; + this.labelVideoInfo.Text = "No video file loaded"; + this.labelVideoInfo.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // trackBarWaveformPosition + // + this.trackBarWaveformPosition.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.trackBarWaveformPosition.AutoSize = false; + this.trackBarWaveformPosition.Location = new System.Drawing.Point(674, 267); + this.trackBarWaveformPosition.Maximum = 1000; + this.trackBarWaveformPosition.Name = "trackBarWaveformPosition"; + this.trackBarWaveformPosition.Size = new System.Drawing.Size(297, 20); + this.trackBarWaveformPosition.TabIndex = 11; + this.trackBarWaveformPosition.TickStyle = System.Windows.Forms.TickStyle.None; + this.trackBarWaveformPosition.ValueChanged += new System.EventHandler(this.trackBarWaveformPosition_ValueChanged); + this.trackBarWaveformPosition.KeyDown += new System.Windows.Forms.KeyEventHandler(this.trackBarWaveformPosition_KeyDown); + // + // panelWaveformControls + // + this.panelWaveformControls.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.panelWaveformControls.Controls.Add(this.toolStripWaveControls); + this.panelWaveformControls.Location = new System.Drawing.Point(474, 265); + this.panelWaveformControls.Name = "panelWaveformControls"; + this.panelWaveformControls.Size = new System.Drawing.Size(205, 30); + this.panelWaveformControls.TabIndex = 10; + // + // toolStripWaveControls + // + this.toolStripWaveControls.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.toolStripWaveControls.Dock = System.Windows.Forms.DockStyle.None; + this.toolStripWaveControls.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + this.toolStripWaveControls.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripButtonWaveformZoomOut, + this.toolStripComboBoxWaveform, + this.toolStripButtonWaveformZoomIn, + this.toolStripSeparator16, + this.toolStripButtonWaveformPause, + this.toolStripButtonWaveformPlay, + this.toolStripButtonLockCenter, + this.toolStripSplitButtonPlayRate}); + this.toolStripWaveControls.Location = new System.Drawing.Point(0, 3); + this.toolStripWaveControls.Name = "toolStripWaveControls"; + this.toolStripWaveControls.Size = new System.Drawing.Size(197, 25); + this.toolStripWaveControls.TabIndex = 0; + this.toolStripWaveControls.Text = "toolStrip2"; + // + // toolStripButtonWaveformZoomOut + // + this.toolStripButtonWaveformZoomOut.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonWaveformZoomOut.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonWaveformZoomOut.Image"))); + this.toolStripButtonWaveformZoomOut.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonWaveformZoomOut.Name = "toolStripButtonWaveformZoomOut"; + this.toolStripButtonWaveformZoomOut.Size = new System.Drawing.Size(23, 22); + this.toolStripButtonWaveformZoomOut.Text = "toolStripButton3"; + this.toolStripButtonWaveformZoomOut.Click += new System.EventHandler(this.toolStripButtonWaveformZoomOut_Click); + // + // toolStripComboBoxWaveform + // + this.toolStripComboBoxWaveform.AutoSize = false; + this.toolStripComboBoxWaveform.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.toolStripComboBoxWaveform.Name = "toolStripComboBoxWaveform"; + this.toolStripComboBoxWaveform.Size = new System.Drawing.Size(62, 23); + // + // toolStripButtonWaveformZoomIn + // + this.toolStripButtonWaveformZoomIn.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonWaveformZoomIn.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonWaveformZoomIn.Image"))); + this.toolStripButtonWaveformZoomIn.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonWaveformZoomIn.Name = "toolStripButtonWaveformZoomIn"; + this.toolStripButtonWaveformZoomIn.Size = new System.Drawing.Size(23, 22); + this.toolStripButtonWaveformZoomIn.Text = "toolStripButton1"; + this.toolStripButtonWaveformZoomIn.Click += new System.EventHandler(this.toolStripButtonWaveformZoomIn_Click); + // + // toolStripSeparator16 + // + this.toolStripSeparator16.Name = "toolStripSeparator16"; + this.toolStripSeparator16.Size = new System.Drawing.Size(6, 25); + // + // toolStripButtonWaveformPause + // + this.toolStripButtonWaveformPause.AutoToolTip = false; + this.toolStripButtonWaveformPause.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonWaveformPause.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonWaveformPause.Image"))); + this.toolStripButtonWaveformPause.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonWaveformPause.Name = "toolStripButtonWaveformPause"; + this.toolStripButtonWaveformPause.Size = new System.Drawing.Size(23, 22); + this.toolStripButtonWaveformPause.Text = "toolStripButton1"; + this.toolStripButtonWaveformPause.Visible = false; + this.toolStripButtonWaveformPause.Click += new System.EventHandler(this.toolStripButtonWaveformPause_Click); + // + // toolStripButtonWaveformPlay + // + this.toolStripButtonWaveformPlay.AutoToolTip = false; + this.toolStripButtonWaveformPlay.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonWaveformPlay.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonWaveformPlay.Image"))); + this.toolStripButtonWaveformPlay.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonWaveformPlay.Name = "toolStripButtonWaveformPlay"; + this.toolStripButtonWaveformPlay.Size = new System.Drawing.Size(23, 22); + this.toolStripButtonWaveformPlay.Text = "toolStripButton1"; + this.toolStripButtonWaveformPlay.Click += new System.EventHandler(this.toolStripButtonWaveformPlay_Click); + // + // toolStripButtonLockCenter + // + this.toolStripButtonLockCenter.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonLockCenter.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonLockCenter.Image"))); + this.toolStripButtonLockCenter.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonLockCenter.Name = "toolStripButtonLockCenter"; + this.toolStripButtonLockCenter.Size = new System.Drawing.Size(23, 22); + this.toolStripButtonLockCenter.Text = "Center"; + this.toolStripButtonLockCenter.Click += new System.EventHandler(this.toolStripButtonLockCenter_Click); + // + // toolStripSplitButtonPlayRate + // + this.toolStripSplitButtonPlayRate.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripSplitButtonPlayRate.Image = ((System.Drawing.Image)(resources.GetObject("toolStripSplitButtonPlayRate.Image"))); + this.toolStripSplitButtonPlayRate.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripSplitButtonPlayRate.Name = "toolStripSplitButtonPlayRate"; + this.toolStripSplitButtonPlayRate.Size = new System.Drawing.Size(32, 22); + this.toolStripSplitButtonPlayRate.Text = "Play rate (speed)"; + this.toolStripSplitButtonPlayRate.ButtonClick += new System.EventHandler(this.toolStripSplitButtonPlayRate_ButtonClick); + // + // tabControlButtons + // + this.tabControlButtons.Controls.Add(this.tabPageTranslate); + this.tabControlButtons.Controls.Add(this.tabPageCreate); + this.tabControlButtons.Controls.Add(this.tabPageAdjust); + this.tabControlButtons.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed; + this.tabControlButtons.Location = new System.Drawing.Point(6, 12); + this.tabControlButtons.Name = "tabControlButtons"; + this.tabControlButtons.SelectedIndex = 0; + this.tabControlButtons.Size = new System.Drawing.Size(467, 283); + this.tabControlButtons.TabIndex = 0; + this.tabControlButtons.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.TabControlButtonsDrawItem); + this.tabControlButtons.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged); + // + // tabPageTranslate + // + this.tabPageTranslate.Controls.Add(this.labelTranslateTip); + this.tabPageTranslate.Controls.Add(this.groupBoxTranslateSearch); + this.tabPageTranslate.Controls.Add(this.groupBoxAutoContinue); + this.tabPageTranslate.Controls.Add(this.buttonStop); + this.tabPageTranslate.Controls.Add(this.groupBoxAutoRepeat); + this.tabPageTranslate.Controls.Add(this.buttonPlayPrevious); + this.tabPageTranslate.Controls.Add(this.buttonPlayCurrent); + this.tabPageTranslate.Controls.Add(this.buttonPlayNext); + this.tabPageTranslate.Location = new System.Drawing.Point(4, 22); + this.tabPageTranslate.Name = "tabPageTranslate"; + this.tabPageTranslate.Padding = new System.Windows.Forms.Padding(3); + this.tabPageTranslate.Size = new System.Drawing.Size(459, 257); + this.tabPageTranslate.TabIndex = 0; + this.tabPageTranslate.Text = "Translate"; + this.tabPageTranslate.UseVisualStyleBackColor = true; + // + // labelTranslateTip + // + this.labelTranslateTip.AutoSize = true; + this.labelTranslateTip.ForeColor = System.Drawing.Color.Gray; + this.labelTranslateTip.Location = new System.Drawing.Point(16, 225); + this.labelTranslateTip.Name = "labelTranslateTip"; + this.labelTranslateTip.Size = new System.Drawing.Size(294, 13); + this.labelTranslateTip.TabIndex = 7; + this.labelTranslateTip.Text = "Tip: Use to go to previous/next subtitle"; + // + // groupBoxTranslateSearch + // + this.groupBoxTranslateSearch.Controls.Add(this.buttonCustomUrl2); + this.groupBoxTranslateSearch.Controls.Add(this.buttonCustomUrl1); + this.groupBoxTranslateSearch.Controls.Add(this.buttonGoogleTranslateIt); + this.groupBoxTranslateSearch.Controls.Add(this.buttonGoogleIt); + this.groupBoxTranslateSearch.Controls.Add(this.textBoxSearchWord); + this.groupBoxTranslateSearch.Location = new System.Drawing.Point(198, 68); + this.groupBoxTranslateSearch.Name = "groupBoxTranslateSearch"; + this.groupBoxTranslateSearch.Size = new System.Drawing.Size(256, 150); + this.groupBoxTranslateSearch.TabIndex = 6; + this.groupBoxTranslateSearch.TabStop = false; + this.groupBoxTranslateSearch.Text = "Search text online"; + // + // buttonCustomUrl2 + // + this.buttonCustomUrl2.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCustomUrl2.Location = new System.Drawing.Point(6, 118); + this.buttonCustomUrl2.Name = "buttonCustomUrl2"; + this.buttonCustomUrl2.Size = new System.Drawing.Size(244, 23); + this.buttonCustomUrl2.TabIndex = 4; + this.buttonCustomUrl2.Text = "Custom URL"; + this.buttonCustomUrl2.UseVisualStyleBackColor = true; + this.buttonCustomUrl2.Click += new System.EventHandler(this.buttonCustomUrl2_Click); + // + // buttonCustomUrl1 + // + this.buttonCustomUrl1.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCustomUrl1.Location = new System.Drawing.Point(6, 91); + this.buttonCustomUrl1.Name = "buttonCustomUrl1"; + this.buttonCustomUrl1.Size = new System.Drawing.Size(244, 23); + this.buttonCustomUrl1.TabIndex = 3; + this.buttonCustomUrl1.Text = "Custom URL"; + this.buttonCustomUrl1.UseVisualStyleBackColor = true; + this.buttonCustomUrl1.Click += new System.EventHandler(this.buttonCustomUrl_Click); + // + // buttonGoogleTranslateIt + // + this.buttonGoogleTranslateIt.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonGoogleTranslateIt.Location = new System.Drawing.Point(132, 63); + this.buttonGoogleTranslateIt.Name = "buttonGoogleTranslateIt"; + this.buttonGoogleTranslateIt.Size = new System.Drawing.Size(118, 23); + this.buttonGoogleTranslateIt.TabIndex = 2; + this.buttonGoogleTranslateIt.Text = "Google translate it"; + this.buttonGoogleTranslateIt.UseVisualStyleBackColor = true; + this.buttonGoogleTranslateIt.Click += new System.EventHandler(this.buttonGoogleTranslateIt_Click); + // + // buttonGoogleIt + // + this.buttonGoogleIt.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonGoogleIt.Location = new System.Drawing.Point(6, 63); + this.buttonGoogleIt.Name = "buttonGoogleIt"; + this.buttonGoogleIt.Size = new System.Drawing.Size(120, 23); + this.buttonGoogleIt.TabIndex = 1; + this.buttonGoogleIt.Text = "Google it"; + this.buttonGoogleIt.UseVisualStyleBackColor = true; + this.buttonGoogleIt.Click += new System.EventHandler(this.buttonGoogleIt_Click); + // + // textBoxSearchWord + // + this.textBoxSearchWord.Location = new System.Drawing.Point(6, 18); + this.textBoxSearchWord.Multiline = true; + this.textBoxSearchWord.Name = "textBoxSearchWord"; + this.textBoxSearchWord.Size = new System.Drawing.Size(244, 39); + this.textBoxSearchWord.TabIndex = 0; + // + // groupBoxAutoContinue + // + this.groupBoxAutoContinue.Controls.Add(this.comboBoxAutoContinue); + this.groupBoxAutoContinue.Controls.Add(this.labelAutoContinueDelay); + this.groupBoxAutoContinue.Controls.Add(this.checkBoxAutoContinue); + this.groupBoxAutoContinue.Location = new System.Drawing.Point(12, 120); + this.groupBoxAutoContinue.Name = "groupBoxAutoContinue"; + this.groupBoxAutoContinue.Size = new System.Drawing.Size(182, 98); + this.groupBoxAutoContinue.TabIndex = 1; + this.groupBoxAutoContinue.TabStop = false; + this.groupBoxAutoContinue.Text = "Auto continue"; + // + // comboBoxAutoContinue + // + this.comboBoxAutoContinue.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxAutoContinue.FormattingEnabled = true; + this.comboBoxAutoContinue.Items.AddRange(new object[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15"}); + this.comboBoxAutoContinue.Location = new System.Drawing.Point(6, 59); + this.comboBoxAutoContinue.Name = "comboBoxAutoContinue"; + this.comboBoxAutoContinue.Size = new System.Drawing.Size(96, 21); + this.comboBoxAutoContinue.TabIndex = 2; + // + // labelAutoContinueDelay + // + this.labelAutoContinueDelay.AutoSize = true; + this.labelAutoContinueDelay.Location = new System.Drawing.Point(7, 43); + this.labelAutoContinueDelay.Name = "labelAutoContinueDelay"; + this.labelAutoContinueDelay.Size = new System.Drawing.Size(83, 13); + this.labelAutoContinueDelay.TabIndex = 1; + this.labelAutoContinueDelay.Text = "Delay (seconds)"; + // + // checkBoxAutoContinue + // + this.checkBoxAutoContinue.AutoSize = true; + this.checkBoxAutoContinue.Location = new System.Drawing.Point(10, 19); + this.checkBoxAutoContinue.Name = "checkBoxAutoContinue"; + this.checkBoxAutoContinue.Size = new System.Drawing.Size(107, 17); + this.checkBoxAutoContinue.TabIndex = 0; + this.checkBoxAutoContinue.Text = "Auto continue on"; + this.checkBoxAutoContinue.UseVisualStyleBackColor = true; + // + // buttonStop + // + this.buttonStop.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonStop.Location = new System.Drawing.Point(288, 42); + this.buttonStop.Name = "buttonStop"; + this.buttonStop.Size = new System.Drawing.Size(76, 23); + this.buttonStop.TabIndex = 5; + this.buttonStop.Text = "Pa&use"; + this.buttonStop.UseVisualStyleBackColor = true; + this.buttonStop.Click += new System.EventHandler(this.buttonStop_Click); + // + // groupBoxAutoRepeat + // + this.groupBoxAutoRepeat.Controls.Add(this.comboBoxAutoRepeat); + this.groupBoxAutoRepeat.Controls.Add(this.labelAutoRepeatCount); + this.groupBoxAutoRepeat.Controls.Add(this.checkBoxAutoRepeatOn); + this.groupBoxAutoRepeat.Location = new System.Drawing.Point(12, 14); + this.groupBoxAutoRepeat.Name = "groupBoxAutoRepeat"; + this.groupBoxAutoRepeat.Size = new System.Drawing.Size(182, 100); + this.groupBoxAutoRepeat.TabIndex = 0; + this.groupBoxAutoRepeat.TabStop = false; + this.groupBoxAutoRepeat.Text = "Auto repeat"; + // + // comboBoxAutoRepeat + // + this.comboBoxAutoRepeat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxAutoRepeat.FormattingEnabled = true; + this.comboBoxAutoRepeat.Items.AddRange(new object[] { + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9"}); + this.comboBoxAutoRepeat.Location = new System.Drawing.Point(6, 60); + this.comboBoxAutoRepeat.Name = "comboBoxAutoRepeat"; + this.comboBoxAutoRepeat.Size = new System.Drawing.Size(96, 21); + this.comboBoxAutoRepeat.TabIndex = 2; + // + // labelAutoRepeatCount + // + this.labelAutoRepeatCount.AutoSize = true; + this.labelAutoRepeatCount.Location = new System.Drawing.Point(6, 44); + this.labelAutoRepeatCount.Name = "labelAutoRepeatCount"; + this.labelAutoRepeatCount.Size = new System.Drawing.Size(105, 13); + this.labelAutoRepeatCount.TabIndex = 1; + this.labelAutoRepeatCount.Text = "Repeat count (times)"; + // + // checkBoxAutoRepeatOn + // + this.checkBoxAutoRepeatOn.AutoSize = true; + this.checkBoxAutoRepeatOn.Checked = true; + this.checkBoxAutoRepeatOn.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxAutoRepeatOn.Location = new System.Drawing.Point(10, 19); + this.checkBoxAutoRepeatOn.Name = "checkBoxAutoRepeatOn"; + this.checkBoxAutoRepeatOn.Size = new System.Drawing.Size(96, 17); + this.checkBoxAutoRepeatOn.TabIndex = 0; + this.checkBoxAutoRepeatOn.Text = "Auto repeat on"; + this.checkBoxAutoRepeatOn.UseVisualStyleBackColor = true; + // + // buttonPlayPrevious + // + this.buttonPlayPrevious.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonPlayPrevious.Location = new System.Drawing.Point(206, 14); + this.buttonPlayPrevious.Name = "buttonPlayPrevious"; + this.buttonPlayPrevious.Size = new System.Drawing.Size(76, 23); + this.buttonPlayPrevious.TabIndex = 2; + this.buttonPlayPrevious.Text = "<< Previous"; + this.buttonPlayPrevious.UseVisualStyleBackColor = true; + this.buttonPlayPrevious.Click += new System.EventHandler(this.buttonPlayPrevious_Click); + // + // buttonPlayCurrent + // + this.buttonPlayCurrent.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonPlayCurrent.Location = new System.Drawing.Point(288, 14); + this.buttonPlayCurrent.Name = "buttonPlayCurrent"; + this.buttonPlayCurrent.Size = new System.Drawing.Size(76, 23); + this.buttonPlayCurrent.TabIndex = 3; + this.buttonPlayCurrent.Text = "&Play current"; + this.buttonPlayCurrent.UseVisualStyleBackColor = true; + this.buttonPlayCurrent.Click += new System.EventHandler(this.ButtonPlayCurrentClick); + // + // buttonPlayNext + // + this.buttonPlayNext.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonPlayNext.Location = new System.Drawing.Point(369, 14); + this.buttonPlayNext.Name = "buttonPlayNext"; + this.buttonPlayNext.Size = new System.Drawing.Size(76, 23); + this.buttonPlayNext.TabIndex = 4; + this.buttonPlayNext.Text = "Next >>"; + this.buttonPlayNext.UseVisualStyleBackColor = true; + this.buttonPlayNext.Click += new System.EventHandler(this.buttonPlayNext_Click); + // + // tabPageCreate + // + this.tabPageCreate.Controls.Add(this.timeUpDownVideoPosition); + this.tabPageCreate.Controls.Add(this.buttonGotoSub); + this.tabPageCreate.Controls.Add(this.buttonBeforeText); + this.tabPageCreate.Controls.Add(this.buttonSetEnd); + this.tabPageCreate.Controls.Add(this.buttonInsertNewText); + this.tabPageCreate.Controls.Add(this.buttonSetStartTime); + this.tabPageCreate.Controls.Add(this.labelCreateF12); + this.tabPageCreate.Controls.Add(this.labelCreateF11); + this.tabPageCreate.Controls.Add(this.labelCreateF10); + this.tabPageCreate.Controls.Add(this.labelCreateF9); + this.tabPageCreate.Controls.Add(this.buttonForward2); + this.tabPageCreate.Controls.Add(this.numericUpDownSec2); + this.tabPageCreate.Controls.Add(this.buttonSecBack2); + this.tabPageCreate.Controls.Add(this.buttonForward1); + this.tabPageCreate.Controls.Add(this.numericUpDownSec1); + this.tabPageCreate.Controls.Add(this.labelVideoPosition); + this.tabPageCreate.Controls.Add(this.buttonSecBack1); + this.tabPageCreate.Location = new System.Drawing.Point(4, 22); + this.tabPageCreate.Name = "tabPageCreate"; + this.tabPageCreate.Padding = new System.Windows.Forms.Padding(3); + this.tabPageCreate.Size = new System.Drawing.Size(459, 257); + this.tabPageCreate.TabIndex = 1; + this.tabPageCreate.Text = "Create"; + this.tabPageCreate.UseVisualStyleBackColor = true; + // + // timeUpDownVideoPosition + // + this.timeUpDownVideoPosition.AutoSize = true; + this.timeUpDownVideoPosition.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownVideoPosition.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + this.timeUpDownVideoPosition.Location = new System.Drawing.Point(96, 191); + this.timeUpDownVideoPosition.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownVideoPosition.Name = "timeUpDownVideoPosition"; + this.timeUpDownVideoPosition.Size = new System.Drawing.Size(111, 27); + this.timeUpDownVideoPosition.TabIndex = 12; + timeCode4.Hours = 0; + timeCode4.Milliseconds = 0; + timeCode4.Minutes = 0; + timeCode4.Seconds = 0; + timeCode4.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode4.TotalMilliseconds = 0D; + timeCode4.TotalSeconds = 0D; + this.timeUpDownVideoPosition.TimeCode = timeCode4; + this.timeUpDownVideoPosition.UseVideoOffset = false; + // + // buttonGotoSub + // + this.buttonGotoSub.Location = new System.Drawing.Point(6, 58); + this.buttonGotoSub.Name = "buttonGotoSub"; + this.buttonGotoSub.Size = new System.Drawing.Size(180, 23); + this.buttonGotoSub.TabIndex = 2; + this.buttonGotoSub.Text = "Goto subposition and pause"; + this.buttonGotoSub.UseVisualStyleBackColor = true; + this.buttonGotoSub.Click += new System.EventHandler(this.buttonGotoSub_Click); + this.buttonGotoSub.MouseEnter += new System.EventHandler(this.buttonGotoSub_MouseEnter); + // + // buttonBeforeText + // + this.buttonBeforeText.Location = new System.Drawing.Point(6, 32); + this.buttonBeforeText.Name = "buttonBeforeText"; + this.buttonBeforeText.Size = new System.Drawing.Size(180, 23); + this.buttonBeforeText.TabIndex = 1; + this.buttonBeforeText.Text = "Play from just before &text"; + this.buttonBeforeText.UseVisualStyleBackColor = true; + this.buttonBeforeText.Click += new System.EventHandler(this.buttonBeforeText_Click); + this.buttonBeforeText.MouseEnter += new System.EventHandler(this.buttonBeforeText_MouseEnter); + // + // buttonSetEnd + // + this.buttonSetEnd.Location = new System.Drawing.Point(6, 110); + this.buttonSetEnd.Name = "buttonSetEnd"; + this.buttonSetEnd.Size = new System.Drawing.Size(180, 23); + this.buttonSetEnd.TabIndex = 4; + this.buttonSetEnd.Text = "Set &end time"; + this.buttonSetEnd.UseVisualStyleBackColor = true; + this.buttonSetEnd.Click += new System.EventHandler(this.ButtonSetEndClick); + this.buttonSetEnd.MouseEnter += new System.EventHandler(this.buttonSetEnd_MouseEnter); + // + // buttonInsertNewText + // + this.buttonInsertNewText.Location = new System.Drawing.Point(6, 6); + this.buttonInsertNewText.Name = "buttonInsertNewText"; + this.buttonInsertNewText.Size = new System.Drawing.Size(180, 23); + this.buttonInsertNewText.TabIndex = 0; + this.buttonInsertNewText.Text = "&Insert new subtitle at vpos"; + this.buttonInsertNewText.UseVisualStyleBackColor = true; + this.buttonInsertNewText.Click += new System.EventHandler(this.ButtonInsertNewTextClick); + this.buttonInsertNewText.MouseEnter += new System.EventHandler(this.buttonInsertNewText_MouseEnter); + // + // buttonSetStartTime + // + this.buttonSetStartTime.Location = new System.Drawing.Point(6, 84); + this.buttonSetStartTime.Name = "buttonSetStartTime"; + this.buttonSetStartTime.Size = new System.Drawing.Size(180, 23); + this.buttonSetStartTime.TabIndex = 3; + this.buttonSetStartTime.Text = "Set &start time"; + this.buttonSetStartTime.UseVisualStyleBackColor = true; + this.buttonSetStartTime.Click += new System.EventHandler(this.buttonSetStartTime_Click); + this.buttonSetStartTime.MouseEnter += new System.EventHandler(this.buttonSetStartTime_MouseEnter); + // + // labelCreateF12 + // + this.labelCreateF12.AutoSize = true; + this.labelCreateF12.ForeColor = System.Drawing.Color.Gray; + this.labelCreateF12.Location = new System.Drawing.Point(188, 114); + this.labelCreateF12.Name = "labelCreateF12"; + this.labelCreateF12.Size = new System.Drawing.Size(25, 13); + this.labelCreateF12.TabIndex = 65; + this.labelCreateF12.Text = "F12"; + // + // labelCreateF11 + // + this.labelCreateF11.AutoSize = true; + this.labelCreateF11.ForeColor = System.Drawing.Color.Gray; + this.labelCreateF11.Location = new System.Drawing.Point(188, 88); + this.labelCreateF11.Name = "labelCreateF11"; + this.labelCreateF11.Size = new System.Drawing.Size(25, 13); + this.labelCreateF11.TabIndex = 64; + this.labelCreateF11.Text = "F11"; + // + // labelCreateF10 + // + this.labelCreateF10.AutoSize = true; + this.labelCreateF10.ForeColor = System.Drawing.Color.Gray; + this.labelCreateF10.Location = new System.Drawing.Point(188, 36); + this.labelCreateF10.Name = "labelCreateF10"; + this.labelCreateF10.Size = new System.Drawing.Size(25, 13); + this.labelCreateF10.TabIndex = 63; + this.labelCreateF10.Text = "F10"; + // + // labelCreateF9 + // + this.labelCreateF9.AutoSize = true; + this.labelCreateF9.ForeColor = System.Drawing.Color.Gray; + this.labelCreateF9.Location = new System.Drawing.Point(188, 10); + this.labelCreateF9.Name = "labelCreateF9"; + this.labelCreateF9.Size = new System.Drawing.Size(19, 13); + this.labelCreateF9.TabIndex = 62; + this.labelCreateF9.Text = "F9"; + // + // buttonForward2 + // + this.buttonForward2.Location = new System.Drawing.Point(130, 163); + this.buttonForward2.Name = "buttonForward2"; + this.buttonForward2.Size = new System.Drawing.Size(56, 23); + this.buttonForward2.TabIndex = 10; + this.buttonForward2.Text = " >>"; + this.buttonForward2.UseVisualStyleBackColor = true; + this.buttonForward2.Click += new System.EventHandler(this.buttonForward2_Click); + // + // numericUpDownSec2 + // + this.numericUpDownSec2.DecimalPlaces = 3; + this.numericUpDownSec2.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownSec2.Location = new System.Drawing.Point(66, 164); + this.numericUpDownSec2.Maximum = new decimal(new int[] { + 60, + 0, + 0, + 0}); + this.numericUpDownSec2.Name = "numericUpDownSec2"; + this.numericUpDownSec2.Size = new System.Drawing.Size(58, 20); + this.numericUpDownSec2.TabIndex = 9; + this.numericUpDownSec2.Value = new decimal(new int[] { + 5000, + 0, + 0, + 196608}); + this.numericUpDownSec2.ValueChanged += new System.EventHandler(this.NumericUpDownSec2ValueChanged); + // + // buttonSecBack2 + // + this.buttonSecBack2.Location = new System.Drawing.Point(6, 163); + this.buttonSecBack2.Name = "buttonSecBack2"; + this.buttonSecBack2.Size = new System.Drawing.Size(56, 23); + this.buttonSecBack2.TabIndex = 8; + this.buttonSecBack2.Text = "<<"; + this.buttonSecBack2.UseVisualStyleBackColor = true; + this.buttonSecBack2.Click += new System.EventHandler(this.buttonSecBack2_Click); + // + // buttonForward1 + // + this.buttonForward1.Location = new System.Drawing.Point(130, 137); + this.buttonForward1.Name = "buttonForward1"; + this.buttonForward1.Size = new System.Drawing.Size(56, 23); + this.buttonForward1.TabIndex = 7; + this.buttonForward1.Text = ">>"; + this.buttonForward1.UseVisualStyleBackColor = true; + this.buttonForward1.Click += new System.EventHandler(this.buttonForward1_Click); + // + // numericUpDownSec1 + // + this.numericUpDownSec1.DecimalPlaces = 3; + this.numericUpDownSec1.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownSec1.Location = new System.Drawing.Point(66, 138); + this.numericUpDownSec1.Maximum = new decimal(new int[] { + 60, + 0, + 0, + 0}); + this.numericUpDownSec1.Name = "numericUpDownSec1"; + this.numericUpDownSec1.Size = new System.Drawing.Size(58, 20); + this.numericUpDownSec1.TabIndex = 6; + this.numericUpDownSec1.Value = new decimal(new int[] { + 500, + 0, + 0, + 196608}); + this.numericUpDownSec1.ValueChanged += new System.EventHandler(this.NumericUpDownSec1ValueChanged); + // + // labelVideoPosition + // + this.labelVideoPosition.AutoSize = true; + this.labelVideoPosition.Location = new System.Drawing.Point(6, 196); + this.labelVideoPosition.Name = "labelVideoPosition"; + this.labelVideoPosition.Size = new System.Drawing.Size(76, 13); + this.labelVideoPosition.TabIndex = 11; + this.labelVideoPosition.Text = "Video position:"; + this.labelVideoPosition.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // buttonSecBack1 + // + this.buttonSecBack1.Location = new System.Drawing.Point(6, 137); + this.buttonSecBack1.Name = "buttonSecBack1"; + this.buttonSecBack1.Size = new System.Drawing.Size(56, 23); + this.buttonSecBack1.TabIndex = 5; + this.buttonSecBack1.Text = "<<"; + this.buttonSecBack1.UseVisualStyleBackColor = true; + this.buttonSecBack1.Click += new System.EventHandler(this.buttonSecBack1_Click); + // + // tabPageAdjust + // + this.tabPageAdjust.Controls.Add(this.timeUpDownVideoPositionAdjust); + this.tabPageAdjust.Controls.Add(this.buttonAdjustSetEndTime); + this.tabPageAdjust.Controls.Add(this.buttonSetEndAndGoToNext); + this.tabPageAdjust.Controls.Add(this.buttonSetStartAndOffsetRest); + this.tabPageAdjust.Controls.Add(this.buttonAdjustSetStartTime); + this.tabPageAdjust.Controls.Add(this.labelAdjustF12); + this.tabPageAdjust.Controls.Add(this.labelAdjustF11); + this.tabPageAdjust.Controls.Add(this.labelAdjustF10); + this.tabPageAdjust.Controls.Add(this.labelAdjustF9); + this.tabPageAdjust.Controls.Add(this.buttonAdjustSecForward2); + this.tabPageAdjust.Controls.Add(this.numericUpDownSecAdjust2); + this.tabPageAdjust.Controls.Add(this.buttonAdjustSecBack2); + this.tabPageAdjust.Controls.Add(this.buttonAdjustSecForward1); + this.tabPageAdjust.Controls.Add(this.numericUpDownSecAdjust1); + this.tabPageAdjust.Controls.Add(this.buttonAdjustSecBack1); + this.tabPageAdjust.Controls.Add(this.labelVideoPosition2); + this.tabPageAdjust.Controls.Add(this.buttonAdjustGoToPosAndPause); + this.tabPageAdjust.Controls.Add(this.buttonAdjustPlayBefore); + this.tabPageAdjust.Location = new System.Drawing.Point(4, 22); + this.tabPageAdjust.Name = "tabPageAdjust"; + this.tabPageAdjust.Size = new System.Drawing.Size(459, 257); + this.tabPageAdjust.TabIndex = 2; + this.tabPageAdjust.Text = "Adjust"; + this.tabPageAdjust.UseVisualStyleBackColor = true; + // + // timeUpDownVideoPositionAdjust + // + this.timeUpDownVideoPositionAdjust.AutoSize = true; + this.timeUpDownVideoPositionAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownVideoPositionAdjust.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + this.timeUpDownVideoPositionAdjust.Location = new System.Drawing.Point(96, 213); + this.timeUpDownVideoPositionAdjust.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownVideoPositionAdjust.Name = "timeUpDownVideoPositionAdjust"; + this.timeUpDownVideoPositionAdjust.Size = new System.Drawing.Size(111, 27); + this.timeUpDownVideoPositionAdjust.TabIndex = 13; + timeCode5.Hours = 0; + timeCode5.Milliseconds = 0; + timeCode5.Minutes = 0; + timeCode5.Seconds = 0; + timeCode5.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode5.TotalMilliseconds = 0D; + timeCode5.TotalSeconds = 0D; + this.timeUpDownVideoPositionAdjust.TimeCode = timeCode5; + this.timeUpDownVideoPositionAdjust.UseVideoOffset = false; + // + // buttonAdjustSetEndTime + // + this.buttonAdjustSetEndTime.Location = new System.Drawing.Point(6, 84); + this.buttonAdjustSetEndTime.Name = "buttonAdjustSetEndTime"; + this.buttonAdjustSetEndTime.Size = new System.Drawing.Size(180, 23); + this.buttonAdjustSetEndTime.TabIndex = 3; + this.buttonAdjustSetEndTime.Text = "Set end time"; + this.buttonAdjustSetEndTime.UseVisualStyleBackColor = true; + this.buttonAdjustSetEndTime.Click += new System.EventHandler(this.ButtonSetEndClick); + this.buttonAdjustSetEndTime.MouseEnter += new System.EventHandler(this.buttonAdjustSetEndTime_MouseEnter); + // + // buttonSetEndAndGoToNext + // + this.buttonSetEndAndGoToNext.Location = new System.Drawing.Point(6, 32); + this.buttonSetEndAndGoToNext.Name = "buttonSetEndAndGoToNext"; + this.buttonSetEndAndGoToNext.Size = new System.Drawing.Size(180, 23); + this.buttonSetEndAndGoToNext.TabIndex = 1; + this.buttonSetEndAndGoToNext.Text = "Set e&nd && goto next"; + this.buttonSetEndAndGoToNext.UseVisualStyleBackColor = true; + this.buttonSetEndAndGoToNext.Click += new System.EventHandler(this.ButtonSetEndAndGoToNextClick); + this.buttonSetEndAndGoToNext.MouseEnter += new System.EventHandler(this.buttonSetEndAndGoToNext_MouseEnter); + // + // buttonSetStartAndOffsetRest + // + this.buttonSetStartAndOffsetRest.Location = new System.Drawing.Point(6, 6); + this.buttonSetStartAndOffsetRest.Name = "buttonSetStartAndOffsetRest"; + this.buttonSetStartAndOffsetRest.Size = new System.Drawing.Size(180, 23); + this.buttonSetStartAndOffsetRest.TabIndex = 0; + this.buttonSetStartAndOffsetRest.Text = "Set sta&rt and offset the rest"; + this.buttonSetStartAndOffsetRest.UseVisualStyleBackColor = true; + this.buttonSetStartAndOffsetRest.Click += new System.EventHandler(this.ButtonSetStartAndOffsetRestClick); + this.buttonSetStartAndOffsetRest.MouseEnter += new System.EventHandler(this.buttonSetStartAndOffsetRest_MouseEnter); + // + // buttonAdjustSetStartTime + // + this.buttonAdjustSetStartTime.Location = new System.Drawing.Point(6, 58); + this.buttonAdjustSetStartTime.Name = "buttonAdjustSetStartTime"; + this.buttonAdjustSetStartTime.Size = new System.Drawing.Size(180, 23); + this.buttonAdjustSetStartTime.TabIndex = 2; + this.buttonAdjustSetStartTime.Text = "Set start time"; + this.buttonAdjustSetStartTime.UseVisualStyleBackColor = true; + this.buttonAdjustSetStartTime.Click += new System.EventHandler(this.buttonSetStartTime_Click); + this.buttonAdjustSetStartTime.MouseEnter += new System.EventHandler(this.buttonAdjustSetStartTime_MouseEnter); + // + // labelAdjustF12 + // + this.labelAdjustF12.AutoSize = true; + this.labelAdjustF12.ForeColor = System.Drawing.Color.Gray; + this.labelAdjustF12.Location = new System.Drawing.Point(188, 88); + this.labelAdjustF12.Name = "labelAdjustF12"; + this.labelAdjustF12.Size = new System.Drawing.Size(25, 13); + this.labelAdjustF12.TabIndex = 64; + this.labelAdjustF12.Text = "F12"; + // + // labelAdjustF11 + // + this.labelAdjustF11.AutoSize = true; + this.labelAdjustF11.ForeColor = System.Drawing.Color.Gray; + this.labelAdjustF11.Location = new System.Drawing.Point(188, 62); + this.labelAdjustF11.Name = "labelAdjustF11"; + this.labelAdjustF11.Size = new System.Drawing.Size(25, 13); + this.labelAdjustF11.TabIndex = 63; + this.labelAdjustF11.Text = "F11"; + // + // labelAdjustF10 + // + this.labelAdjustF10.AutoSize = true; + this.labelAdjustF10.ForeColor = System.Drawing.Color.Gray; + this.labelAdjustF10.Location = new System.Drawing.Point(188, 36); + this.labelAdjustF10.Name = "labelAdjustF10"; + this.labelAdjustF10.Size = new System.Drawing.Size(25, 13); + this.labelAdjustF10.TabIndex = 62; + this.labelAdjustF10.Text = "F10"; + // + // labelAdjustF9 + // + this.labelAdjustF9.AutoSize = true; + this.labelAdjustF9.ForeColor = System.Drawing.Color.Gray; + this.labelAdjustF9.Location = new System.Drawing.Point(188, 10); + this.labelAdjustF9.Name = "labelAdjustF9"; + this.labelAdjustF9.Size = new System.Drawing.Size(19, 13); + this.labelAdjustF9.TabIndex = 61; + this.labelAdjustF9.Text = "F9"; + // + // buttonAdjustSecForward2 + // + this.buttonAdjustSecForward2.Location = new System.Drawing.Point(130, 188); + this.buttonAdjustSecForward2.Name = "buttonAdjustSecForward2"; + this.buttonAdjustSecForward2.Size = new System.Drawing.Size(56, 23); + this.buttonAdjustSecForward2.TabIndex = 11; + this.buttonAdjustSecForward2.Text = ">>"; + this.buttonAdjustSecForward2.UseVisualStyleBackColor = true; + this.buttonAdjustSecForward2.Click += new System.EventHandler(this.buttonAdjustSecForward2_Click); + // + // numericUpDownSecAdjust2 + // + this.numericUpDownSecAdjust2.DecimalPlaces = 3; + this.numericUpDownSecAdjust2.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownSecAdjust2.Location = new System.Drawing.Point(66, 189); + this.numericUpDownSecAdjust2.Maximum = new decimal(new int[] { + 60, + 0, + 0, + 0}); + this.numericUpDownSecAdjust2.Name = "numericUpDownSecAdjust2"; + this.numericUpDownSecAdjust2.Size = new System.Drawing.Size(58, 20); + this.numericUpDownSecAdjust2.TabIndex = 10; + this.numericUpDownSecAdjust2.Value = new decimal(new int[] { + 5000, + 0, + 0, + 196608}); + this.numericUpDownSecAdjust2.ValueChanged += new System.EventHandler(this.NumericUpDownSecAdjust2ValueChanged); + // + // buttonAdjustSecBack2 + // + this.buttonAdjustSecBack2.Location = new System.Drawing.Point(6, 188); + this.buttonAdjustSecBack2.Name = "buttonAdjustSecBack2"; + this.buttonAdjustSecBack2.Size = new System.Drawing.Size(56, 23); + this.buttonAdjustSecBack2.TabIndex = 9; + this.buttonAdjustSecBack2.Text = "<<"; + this.buttonAdjustSecBack2.UseVisualStyleBackColor = true; + this.buttonAdjustSecBack2.Click += new System.EventHandler(this.buttonAdjustSecBack2_Click); + // + // buttonAdjustSecForward1 + // + this.buttonAdjustSecForward1.Location = new System.Drawing.Point(130, 162); + this.buttonAdjustSecForward1.Name = "buttonAdjustSecForward1"; + this.buttonAdjustSecForward1.Size = new System.Drawing.Size(56, 23); + this.buttonAdjustSecForward1.TabIndex = 8; + this.buttonAdjustSecForward1.Text = ">>"; + this.buttonAdjustSecForward1.UseVisualStyleBackColor = true; + this.buttonAdjustSecForward1.Click += new System.EventHandler(this.ButtonAdjustSecForwardClick); + // + // numericUpDownSecAdjust1 + // + this.numericUpDownSecAdjust1.DecimalPlaces = 3; + this.numericUpDownSecAdjust1.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownSecAdjust1.Location = new System.Drawing.Point(66, 163); + this.numericUpDownSecAdjust1.Maximum = new decimal(new int[] { + 60, + 0, + 0, + 0}); + this.numericUpDownSecAdjust1.Name = "numericUpDownSecAdjust1"; + this.numericUpDownSecAdjust1.Size = new System.Drawing.Size(58, 20); + this.numericUpDownSecAdjust1.TabIndex = 7; + this.numericUpDownSecAdjust1.Value = new decimal(new int[] { + 500, + 0, + 0, + 196608}); + this.numericUpDownSecAdjust1.ValueChanged += new System.EventHandler(this.NumericUpDownSecAdjust1ValueChanged); + // + // buttonAdjustSecBack1 + // + this.buttonAdjustSecBack1.Location = new System.Drawing.Point(6, 162); + this.buttonAdjustSecBack1.Name = "buttonAdjustSecBack1"; + this.buttonAdjustSecBack1.Size = new System.Drawing.Size(56, 23); + this.buttonAdjustSecBack1.TabIndex = 6; + this.buttonAdjustSecBack1.Text = "<<"; + this.buttonAdjustSecBack1.UseVisualStyleBackColor = true; + this.buttonAdjustSecBack1.Click += new System.EventHandler(this.ButtonAdjustSecBackClick); + // + // labelVideoPosition2 + // + this.labelVideoPosition2.AutoSize = true; + this.labelVideoPosition2.Location = new System.Drawing.Point(6, 219); + this.labelVideoPosition2.Name = "labelVideoPosition2"; + this.labelVideoPosition2.Size = new System.Drawing.Size(76, 13); + this.labelVideoPosition2.TabIndex = 12; + this.labelVideoPosition2.Text = "Video position:"; + this.labelVideoPosition2.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // buttonAdjustGoToPosAndPause + // + this.buttonAdjustGoToPosAndPause.Location = new System.Drawing.Point(6, 136); + this.buttonAdjustGoToPosAndPause.Name = "buttonAdjustGoToPosAndPause"; + this.buttonAdjustGoToPosAndPause.Size = new System.Drawing.Size(180, 23); + this.buttonAdjustGoToPosAndPause.TabIndex = 5; + this.buttonAdjustGoToPosAndPause.Text = "&Goto subposition and pause"; + this.buttonAdjustGoToPosAndPause.UseVisualStyleBackColor = true; + this.buttonAdjustGoToPosAndPause.Click += new System.EventHandler(this.buttonGotoSub_Click); + this.buttonAdjustGoToPosAndPause.MouseEnter += new System.EventHandler(this.buttonAdjustGoToPosAndPause_MouseEnter); + // + // buttonAdjustPlayBefore + // + this.buttonAdjustPlayBefore.Location = new System.Drawing.Point(6, 110); + this.buttonAdjustPlayBefore.Name = "buttonAdjustPlayBefore"; + this.buttonAdjustPlayBefore.Size = new System.Drawing.Size(180, 23); + this.buttonAdjustPlayBefore.TabIndex = 4; + this.buttonAdjustPlayBefore.Text = "&Play from just before text"; + this.buttonAdjustPlayBefore.UseVisualStyleBackColor = true; + this.buttonAdjustPlayBefore.Click += new System.EventHandler(this.buttonBeforeText_Click); + this.buttonAdjustPlayBefore.MouseEnter += new System.EventHandler(this.buttonAdjustPlayBefore_MouseEnter); + // + // ShowSubtitleTimer + // + this.ShowSubtitleTimer.Enabled = true; + this.ShowSubtitleTimer.Interval = 17; + this.ShowSubtitleTimer.Tick += new System.EventHandler(this.ShowSubtitleTimerTick); + // + // timerAutoDuration + // + this.timerAutoDuration.Interval = 300; + this.timerAutoDuration.Tick += new System.EventHandler(this.timerAutoDuration_Tick); + // + // timerAutoContinue + // + this.timerAutoContinue.Interval = 1000; + this.timerAutoContinue.Tick += new System.EventHandler(this.timerAutoContinue_Tick); + // + // timerStillTyping + // + this.timerStillTyping.Interval = 1500; + this.timerStillTyping.Tick += new System.EventHandler(this.timerStillTyping_Tick); + // + // timerWaveform + // + this.timerWaveform.Tick += new System.EventHandler(this.timerWaveform_Tick); + // + // contextMenuStripWaveform + // + this.contextMenuStripWaveform.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addParagraphHereToolStripMenuItem, + this.addParagraphAndPasteToolStripMenuItem, + this.toolStripMenuItemSetParagraphAsSelection, + this.toolStripMenuItemFocusTextbox, + this.goToPreviousSubtitleStripMenuItem, + this.goToNextSubtitleStripMenuItem, + this.deleteParagraphToolStripMenuItem, + this.splitToolStripMenuItem1, + this.mergeWithPreviousToolStripMenuItem, + this.mergeWithNextToolStripMenuItem, + this.toolStripSeparator11, + this.extendToPreviousToolStripMenuItem, + this.extendToNextToolStripMenuItem, + this.toolStripSeparator6, + this.toolStripMenuItemWaveformPlaySelection, + this.toolStripSeparator24, + this.showWaveformAndSpectrogramToolStripMenuItem, + this.showOnlyWaveformToolStripMenuItem, + this.showOnlySpectrogramToolStripMenuItem, + this.toolStripSeparatorGuessTimeCodes, + this.removeSceneChangeToolStripMenuItem, + this.addSceneChangeToolStripMenuItem, + this.guessTimeCodesToolStripMenuItem, + this.seekSilenceToolStripMenuItem, + this.insertSubtitleHereToolStripMenuItem}); + this.contextMenuStripWaveform.Name = "contextMenuStripWaveform"; + this.contextMenuStripWaveform.Size = new System.Drawing.Size(275, 490); + this.contextMenuStripWaveform.Closing += new System.Windows.Forms.ToolStripDropDownClosingEventHandler(this.contextMenuStripWaveform_Closing); + this.contextMenuStripWaveform.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripWaveformOpening); + // + // addParagraphHereToolStripMenuItem + // + this.addParagraphHereToolStripMenuItem.Name = "addParagraphHereToolStripMenuItem"; + this.addParagraphHereToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.addParagraphHereToolStripMenuItem.Text = "Add paragraph here"; + this.addParagraphHereToolStripMenuItem.Click += new System.EventHandler(this.addParagraphHereToolStripMenuItem_Click); + // + // addParagraphAndPasteToolStripMenuItem + // + this.addParagraphAndPasteToolStripMenuItem.Name = "addParagraphAndPasteToolStripMenuItem"; + this.addParagraphAndPasteToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.addParagraphAndPasteToolStripMenuItem.Text = "Add paragraph here + paste clipboard"; + this.addParagraphAndPasteToolStripMenuItem.Click += new System.EventHandler(this.addParagraphAndPasteToolStripMenuItem_Click); + // + // toolStripMenuItemSetParagraphAsSelection + // + this.toolStripMenuItemSetParagraphAsSelection.Name = "toolStripMenuItemSetParagraphAsSelection"; + this.toolStripMenuItemSetParagraphAsSelection.Size = new System.Drawing.Size(274, 22); + this.toolStripMenuItemSetParagraphAsSelection.Text = "Set selected paragraph as selection"; + this.toolStripMenuItemSetParagraphAsSelection.Click += new System.EventHandler(this.toolStripMenuItemSetParagraphAsSelection_Click); + // + // toolStripMenuItemFocusTextbox + // + this.toolStripMenuItemFocusTextbox.Name = "toolStripMenuItemFocusTextbox"; + this.toolStripMenuItemFocusTextbox.Size = new System.Drawing.Size(274, 22); + this.toolStripMenuItemFocusTextbox.Text = "Focus textbox"; + this.toolStripMenuItemFocusTextbox.Click += new System.EventHandler(this.toolStripMenuItemFocusTextbox_Click); + // + // goToPreviousSubtitleStripMenuItem + // + this.goToPreviousSubtitleStripMenuItem.Name = "goToPreviousSubtitleStripMenuItem"; + this.goToPreviousSubtitleStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.goToPreviousSubtitleStripMenuItem.Text = "Go to previous subtitle"; + this.goToPreviousSubtitleStripMenuItem.Click += new System.EventHandler(this.goToPreviousSubtitleToolStripMenuItem_Click); + // + // goToNextSubtitleStripMenuItem + // + this.goToNextSubtitleStripMenuItem.Name = "goToNextSubtitleStripMenuItem"; + this.goToNextSubtitleStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.goToNextSubtitleStripMenuItem.Text = "Go to next subtitle"; + this.goToNextSubtitleStripMenuItem.Click += new System.EventHandler(this.goToNextSubtitleToolStripMenuItem_Click); + // + // deleteParagraphToolStripMenuItem + // + this.deleteParagraphToolStripMenuItem.Name = "deleteParagraphToolStripMenuItem"; + this.deleteParagraphToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.deleteParagraphToolStripMenuItem.Text = "Delete paragraph"; + this.deleteParagraphToolStripMenuItem.Click += new System.EventHandler(this.deleteParagraphToolStripMenuItem_Click); + // + // splitToolStripMenuItem1 + // + this.splitToolStripMenuItem1.Name = "splitToolStripMenuItem1"; + this.splitToolStripMenuItem1.Size = new System.Drawing.Size(274, 22); + this.splitToolStripMenuItem1.Text = "Split"; + this.splitToolStripMenuItem1.Click += new System.EventHandler(this.splitToolStripMenuItem1_Click); + // + // mergeWithPreviousToolStripMenuItem + // + this.mergeWithPreviousToolStripMenuItem.Name = "mergeWithPreviousToolStripMenuItem"; + this.mergeWithPreviousToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.mergeWithPreviousToolStripMenuItem.Text = "Merge with previous"; + this.mergeWithPreviousToolStripMenuItem.Click += new System.EventHandler(this.mergeWithPreviousToolStripMenuItem_Click); + // + // mergeWithNextToolStripMenuItem + // + this.mergeWithNextToolStripMenuItem.Name = "mergeWithNextToolStripMenuItem"; + this.mergeWithNextToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.mergeWithNextToolStripMenuItem.Text = "Merge with next"; + this.mergeWithNextToolStripMenuItem.Click += new System.EventHandler(this.mergeWithNextToolStripMenuItem_Click); + // + // toolStripSeparator11 + // + this.toolStripSeparator11.Name = "toolStripSeparator11"; + this.toolStripSeparator11.Size = new System.Drawing.Size(271, 6); + // + // extendToPreviousToolStripMenuItem + // + this.extendToPreviousToolStripMenuItem.Name = "extendToPreviousToolStripMenuItem"; + this.extendToPreviousToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.extendToPreviousToolStripMenuItem.Text = "Extend to previous"; + this.extendToPreviousToolStripMenuItem.Click += new System.EventHandler(this.extendToPreviousToolStripMenuItem_Click); + // + // extendToNextToolStripMenuItem + // + this.extendToNextToolStripMenuItem.Name = "extendToNextToolStripMenuItem"; + this.extendToNextToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.extendToNextToolStripMenuItem.Text = "Extend to next"; + this.extendToNextToolStripMenuItem.Click += new System.EventHandler(this.extendToNextToolStripMenuItem_Click); + // + // toolStripSeparator6 + // + this.toolStripSeparator6.Name = "toolStripSeparator6"; + this.toolStripSeparator6.Size = new System.Drawing.Size(271, 6); + // + // toolStripMenuItemWaveformPlaySelection + // + this.toolStripMenuItemWaveformPlaySelection.Name = "toolStripMenuItemWaveformPlaySelection"; + this.toolStripMenuItemWaveformPlaySelection.Size = new System.Drawing.Size(274, 22); + this.toolStripMenuItemWaveformPlaySelection.Text = "Play selection"; + this.toolStripMenuItemWaveformPlaySelection.Click += new System.EventHandler(this.toolStripMenuItemWaveformPlaySelection_Click); + // + // toolStripSeparator24 + // + this.toolStripSeparator24.Name = "toolStripSeparator24"; + this.toolStripSeparator24.Size = new System.Drawing.Size(271, 6); + // + // showWaveformAndSpectrogramToolStripMenuItem + // + this.showWaveformAndSpectrogramToolStripMenuItem.Name = "showWaveformAndSpectrogramToolStripMenuItem"; + this.showWaveformAndSpectrogramToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.showWaveformAndSpectrogramToolStripMenuItem.Text = "Show waveform and spectrogram"; + this.showWaveformAndSpectrogramToolStripMenuItem.Click += new System.EventHandler(this.ShowWaveformAndSpectrogramToolStripMenuItemClick); + // + // showOnlyWaveformToolStripMenuItem + // + this.showOnlyWaveformToolStripMenuItem.Name = "showOnlyWaveformToolStripMenuItem"; + this.showOnlyWaveformToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.showOnlyWaveformToolStripMenuItem.Text = "Show only waveform"; + this.showOnlyWaveformToolStripMenuItem.Click += new System.EventHandler(this.ShowOnlyWaveformToolStripMenuItemClick); + // + // showOnlySpectrogramToolStripMenuItem + // + this.showOnlySpectrogramToolStripMenuItem.Name = "showOnlySpectrogramToolStripMenuItem"; + this.showOnlySpectrogramToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.showOnlySpectrogramToolStripMenuItem.Text = "Show only spectrogram"; + this.showOnlySpectrogramToolStripMenuItem.Click += new System.EventHandler(this.ShowOnlySpectrogramToolStripMenuItemClick); + // + // toolStripSeparatorGuessTimeCodes + // + this.toolStripSeparatorGuessTimeCodes.Name = "toolStripSeparatorGuessTimeCodes"; + this.toolStripSeparatorGuessTimeCodes.Size = new System.Drawing.Size(271, 6); + // + // removeSceneChangeToolStripMenuItem + // + this.removeSceneChangeToolStripMenuItem.Name = "removeSceneChangeToolStripMenuItem"; + this.removeSceneChangeToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.removeSceneChangeToolStripMenuItem.Text = "Remove scene change"; + this.removeSceneChangeToolStripMenuItem.Click += new System.EventHandler(this.removeSceneChangeToolStripMenuItem_Click); + // + // addSceneChangeToolStripMenuItem + // + this.addSceneChangeToolStripMenuItem.Name = "addSceneChangeToolStripMenuItem"; + this.addSceneChangeToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.addSceneChangeToolStripMenuItem.Text = "Add scene change"; + this.addSceneChangeToolStripMenuItem.Click += new System.EventHandler(this.addSceneChangeToolStripMenuItem_Click); + // + // guessTimeCodesToolStripMenuItem + // + this.guessTimeCodesToolStripMenuItem.Name = "guessTimeCodesToolStripMenuItem"; + this.guessTimeCodesToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.guessTimeCodesToolStripMenuItem.Text = "Guess time codes..."; + this.guessTimeCodesToolStripMenuItem.Click += new System.EventHandler(this.GuessTimeCodesToolStripMenuItemClick); + // + // seekSilenceToolStripMenuItem + // + this.seekSilenceToolStripMenuItem.Name = "seekSilenceToolStripMenuItem"; + this.seekSilenceToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.seekSilenceToolStripMenuItem.Text = "Seek silence..."; + this.seekSilenceToolStripMenuItem.Click += new System.EventHandler(this.seekSilenceToolStripMenuItem_Click); + // + // insertSubtitleHereToolStripMenuItem + // + this.insertSubtitleHereToolStripMenuItem.Name = "insertSubtitleHereToolStripMenuItem"; + this.insertSubtitleHereToolStripMenuItem.Size = new System.Drawing.Size(274, 22); + this.insertSubtitleHereToolStripMenuItem.Text = "Insert subtitle here..."; + this.insertSubtitleHereToolStripMenuItem.Click += new System.EventHandler(this.insertSubtitleHereToolStripMenuItem_Click); + // + // splitContainerMain + // + this.splitContainerMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainerMain.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.splitContainerMain.Location = new System.Drawing.Point(0, 64); + this.splitContainerMain.Name = "splitContainerMain"; + this.splitContainerMain.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainerMain.Panel1 + // + this.splitContainerMain.Panel1.Controls.Add(this.splitContainer1); + // + // splitContainerMain.Panel2 + // + this.splitContainerMain.Panel2.Controls.Add(this.groupBoxVideo); + this.splitContainerMain.Size = new System.Drawing.Size(975, 560); + this.splitContainerMain.SplitterDistance = 251; + this.splitContainerMain.TabIndex = 8; + this.splitContainerMain.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.SplitContainerMainSplitterMoved); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.tabControlSubtitle); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.panelVideoPlayer); + this.splitContainer1.Size = new System.Drawing.Size(975, 251); + this.splitContainer1.SplitterDistance = 743; + this.splitContainer1.TabIndex = 7; + this.splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.SplitContainer1SplitterMoved); + // + // tabControlSubtitle + // + this.tabControlSubtitle.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabControlSubtitle.Controls.Add(this.tabPage1); + this.tabControlSubtitle.Controls.Add(this.tabPage2); + this.tabControlSubtitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tabControlSubtitle.Location = new System.Drawing.Point(3, 3); + this.tabControlSubtitle.Name = "tabControlSubtitle"; + this.tabControlSubtitle.SelectedIndex = 0; + this.tabControlSubtitle.Size = new System.Drawing.Size(738, 248); + this.tabControlSubtitle.TabIndex = 0; + this.tabControlSubtitle.SelectedIndexChanged += new System.EventHandler(this.TabControlSubtitleSelectedIndexChanged); + this.tabControlSubtitle.Selecting += new System.Windows.Forms.TabControlCancelEventHandler(this.TabControlSubtitleSelecting); + // + // tabPage1 + // + this.tabPage1.Controls.Add(this.splitContainerListViewAndText); + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(730, 222); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "List view"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // splitContainerListViewAndText + // + this.splitContainerListViewAndText.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainerListViewAndText.Location = new System.Drawing.Point(3, 3); + this.splitContainerListViewAndText.Name = "splitContainerListViewAndText"; + this.splitContainerListViewAndText.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainerListViewAndText.Panel1 + // + this.splitContainerListViewAndText.Panel1.Controls.Add(this.SubtitleListview1); + this.splitContainerListViewAndText.Panel1MinSize = 50; + // + // splitContainerListViewAndText.Panel2 + // + this.splitContainerListViewAndText.Panel2.Controls.Add(this.groupBoxEdit); + this.splitContainerListViewAndText.Panel2MinSize = 105; + this.splitContainerListViewAndText.Size = new System.Drawing.Size(724, 216); + this.splitContainerListViewAndText.SplitterDistance = 91; + this.splitContainerListViewAndText.TabIndex = 2; + // + // SubtitleListview1 + // + this.SubtitleListview1.AllowColumnReorder = true; + this.SubtitleListview1.AllowDrop = true; + this.SubtitleListview1.ContextMenuStrip = this.contextMenuStripListview; + this.SubtitleListview1.Dock = System.Windows.Forms.DockStyle.Fill; + this.SubtitleListview1.FirstVisibleIndex = -1; + this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SubtitleListview1.FullRowSelect = true; + this.SubtitleListview1.GridLines = true; + this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.SubtitleListview1.HideSelection = false; + this.SubtitleListview1.Location = new System.Drawing.Point(0, 0); + this.SubtitleListview1.Name = "SubtitleListview1"; + this.SubtitleListview1.OwnerDraw = true; + this.SubtitleListview1.Size = new System.Drawing.Size(724, 91); + this.SubtitleListview1.StateImageList = this.imageListBookmarks; + this.SubtitleListview1.SubtitleFontBold = false; + this.SubtitleListview1.SubtitleFontName = "Tahoma"; + this.SubtitleListview1.SubtitleFontSize = 8; + this.SubtitleListview1.TabIndex = 0; + this.SubtitleListview1.UseCompatibleStateImageBehavior = false; + this.SubtitleListview1.UseSyntaxColoring = true; + this.SubtitleListview1.View = System.Windows.Forms.View.Details; + this.SubtitleListview1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListview1_SelectedIndexChanged); + this.SubtitleListview1.DragDrop += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragDrop); + this.SubtitleListview1.DragEnter += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragEnter); + this.SubtitleListview1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SubtitleListview1KeyDown); + this.SubtitleListview1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListview1_MouseDoubleClick); + this.SubtitleListview1.MouseEnter += new System.EventHandler(this.SubtitleListview1_MouseEnter); + // + // imageListBookmarks + // + this.imageListBookmarks.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; + this.imageListBookmarks.ImageSize = new System.Drawing.Size(16, 16); + this.imageListBookmarks.TransparentColor = System.Drawing.Color.Transparent; + // + // groupBoxEdit + // + this.groupBoxEdit.Controls.Add(this.labelAlternateSingleLinePixels); + this.groupBoxEdit.Controls.Add(this.labelSingleLinePixels); + this.groupBoxEdit.Controls.Add(this.panelBookmark); + this.groupBoxEdit.Controls.Add(this.pictureBoxBookmark); + this.groupBoxEdit.Controls.Add(this.labelSingleLine); + this.groupBoxEdit.Controls.Add(this.labelAlternateSingleLine); + this.groupBoxEdit.Controls.Add(this.labelDurationWarning); + this.groupBoxEdit.Controls.Add(this.labelStartTimeWarning); + this.groupBoxEdit.Controls.Add(this.buttonSplitLine); + this.groupBoxEdit.Controls.Add(this.labelAlternateCharactersPerSecond); + this.groupBoxEdit.Controls.Add(this.labelTextAlternateLineTotal); + this.groupBoxEdit.Controls.Add(this.labelTextAlternateLineLengths); + this.groupBoxEdit.Controls.Add(this.labelAlternateText); + this.groupBoxEdit.Controls.Add(this.labelText); + this.groupBoxEdit.Controls.Add(this.textBoxListViewTextAlternate); + this.groupBoxEdit.Controls.Add(this.buttonAutoBreak); + this.groupBoxEdit.Controls.Add(this.labelTextLineLengths); + this.groupBoxEdit.Controls.Add(this.labelTextLineTotal); + this.groupBoxEdit.Controls.Add(this.labelCharactersPerSecond); + this.groupBoxEdit.Controls.Add(this.buttonUnBreak); + this.groupBoxEdit.Controls.Add(this.timeUpDownStartTime); + this.groupBoxEdit.Controls.Add(this.numericUpDownDuration); + this.groupBoxEdit.Controls.Add(this.buttonPrevious); + this.groupBoxEdit.Controls.Add(this.buttonNext); + this.groupBoxEdit.Controls.Add(this.labelStartTime); + this.groupBoxEdit.Controls.Add(this.textBoxListViewText); + this.groupBoxEdit.Controls.Add(this.labelDuration); + this.groupBoxEdit.Controls.Add(this.labelAutoDuration); + this.groupBoxEdit.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBoxEdit.Location = new System.Drawing.Point(0, 0); + this.groupBoxEdit.Name = "groupBoxEdit"; + this.groupBoxEdit.Size = new System.Drawing.Size(724, 121); + this.groupBoxEdit.TabIndex = 1; + this.groupBoxEdit.TabStop = false; + // + // labelAlternateSingleLinePixels + // + this.labelAlternateSingleLinePixels.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelAlternateSingleLinePixels.AutoSize = true; + this.labelAlternateSingleLinePixels.Location = new System.Drawing.Point(870, 94); + this.labelAlternateSingleLinePixels.Name = "labelAlternateSingleLinePixels"; + this.labelAlternateSingleLinePixels.Size = new System.Drawing.Size(62, 13); + this.labelAlternateSingleLinePixels.TabIndex = 43; + this.labelAlternateSingleLinePixels.Text = "AltSinLinPix"; + // + // labelSingleLinePixels + // + this.labelSingleLinePixels.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelSingleLinePixels.AutoSize = true; + this.labelSingleLinePixels.Location = new System.Drawing.Point(427, 94); + this.labelSingleLinePixels.Name = "labelSingleLinePixels"; + this.labelSingleLinePixels.Size = new System.Drawing.Size(105, 13); + this.labelSingleLinePixels.TabIndex = 42; + this.labelSingleLinePixels.Text = "labelSingleLinePixels"; + // + // panelBookmark + // + this.panelBookmark.BackColor = System.Drawing.Color.LemonChiffon; + this.panelBookmark.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelBookmark.Controls.Add(this.labelBookmark); + this.panelBookmark.Location = new System.Drawing.Point(207, 38); + this.panelBookmark.Name = "panelBookmark"; + this.panelBookmark.Size = new System.Drawing.Size(200, 25); + this.panelBookmark.TabIndex = 40; + this.panelBookmark.Visible = false; + // + // labelBookmark + // + this.labelBookmark.AutoSize = true; + this.labelBookmark.Location = new System.Drawing.Point(4, 4); + this.labelBookmark.Name = "labelBookmark"; + this.labelBookmark.Size = new System.Drawing.Size(77, 13); + this.labelBookmark.TabIndex = 0; + this.labelBookmark.Text = "labelBookmark"; + this.labelBookmark.DoubleClick += new System.EventHandler(this.labelBookmark_DoubleClick); + // + // pictureBoxBookmark + // + this.pictureBoxBookmark.Image = global::Nikse.SubtitleEdit.Properties.Resources.bookmark22; + this.pictureBoxBookmark.Location = new System.Drawing.Point(211, 28); + this.pictureBoxBookmark.Name = "pictureBoxBookmark"; + this.pictureBoxBookmark.Size = new System.Drawing.Size(22, 22); + this.pictureBoxBookmark.TabIndex = 41; + this.pictureBoxBookmark.TabStop = false; + this.pictureBoxBookmark.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBoxBookmark_MouseClick); + this.pictureBoxBookmark.MouseEnter += new System.EventHandler(this.pictureBoxBookmark_MouseEnter); + // + // labelSingleLine + // + this.labelSingleLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelSingleLine.AutoSize = true; + this.labelSingleLine.Location = new System.Drawing.Point(346, 94); + this.labelSingleLine.Name = "labelSingleLine"; + this.labelSingleLine.Size = new System.Drawing.Size(78, 13); + this.labelSingleLine.TabIndex = 32; + this.labelSingleLine.Text = "labelSingleLine"; + // + // labelAlternateSingleLine + // + this.labelAlternateSingleLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelAlternateSingleLine.AutoSize = true; + this.labelAlternateSingleLine.Location = new System.Drawing.Point(839, 94); + this.labelAlternateSingleLine.Name = "labelAlternateSingleLine"; + this.labelAlternateSingleLine.Size = new System.Drawing.Size(48, 13); + this.labelAlternateSingleLine.TabIndex = 36; + this.labelAlternateSingleLine.Text = "AltSinLin"; + // + // labelDurationWarning + // + this.labelDurationWarning.AutoSize = true; + this.labelDurationWarning.ForeColor = System.Drawing.Color.Red; + this.labelDurationWarning.Location = new System.Drawing.Point(122, 64); + this.labelDurationWarning.Name = "labelDurationWarning"; + this.labelDurationWarning.Size = new System.Drawing.Size(109, 13); + this.labelDurationWarning.TabIndex = 17; + this.labelDurationWarning.Text = "labelDurationWarning"; + // + // labelStartTimeWarning + // + this.labelStartTimeWarning.AutoSize = true; + this.labelStartTimeWarning.ForeColor = System.Drawing.Color.Red; + this.labelStartTimeWarning.Location = new System.Drawing.Point(8, 50); + this.labelStartTimeWarning.Name = "labelStartTimeWarning"; + this.labelStartTimeWarning.Size = new System.Drawing.Size(114, 13); + this.labelStartTimeWarning.TabIndex = 18; + this.labelStartTimeWarning.Text = "labelStartTimeWarning"; + // + // buttonSplitLine + // + this.buttonSplitLine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSplitLine.ForeColor = System.Drawing.Color.Red; + this.buttonSplitLine.Location = new System.Drawing.Point(604, 80); + this.buttonSplitLine.Name = "buttonSplitLine"; + this.buttonSplitLine.Size = new System.Drawing.Size(115, 23); + this.buttonSplitLine.TabIndex = 39; + this.buttonSplitLine.Text = "Split line"; + this.buttonSplitLine.UseVisualStyleBackColor = true; + this.buttonSplitLine.Visible = false; + this.buttonSplitLine.Click += new System.EventHandler(this.ButtonSplitLineClick); + // + // labelAlternateCharactersPerSecond + // + this.labelAlternateCharactersPerSecond.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelAlternateCharactersPerSecond.AutoSize = true; + this.labelAlternateCharactersPerSecond.Location = new System.Drawing.Point(636, 11); + this.labelAlternateCharactersPerSecond.Name = "labelAlternateCharactersPerSecond"; + this.labelAlternateCharactersPerSecond.Size = new System.Drawing.Size(64, 13); + this.labelAlternateCharactersPerSecond.TabIndex = 38; + this.labelAlternateCharactersPerSecond.Text = "altCharsSec"; + // + // labelTextAlternateLineTotal + // + this.labelTextAlternateLineTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.labelTextAlternateLineTotal.AutoSize = true; + this.labelTextAlternateLineTotal.Location = new System.Drawing.Point(682, 94); + this.labelTextAlternateLineTotal.Name = "labelTextAlternateLineTotal"; + this.labelTextAlternateLineTotal.Size = new System.Drawing.Size(35, 13); + this.labelTextAlternateLineTotal.TabIndex = 37; + this.labelTextAlternateLineTotal.Text = "AltTot"; + // + // labelTextAlternateLineLengths + // + this.labelTextAlternateLineLengths.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelTextAlternateLineLengths.AutoSize = true; + this.labelTextAlternateLineLengths.Location = new System.Drawing.Point(786, 94); + this.labelTextAlternateLineLengths.Name = "labelTextAlternateLineLengths"; + this.labelTextAlternateLineLengths.Size = new System.Drawing.Size(57, 13); + this.labelTextAlternateLineLengths.TabIndex = 35; + this.labelTextAlternateLineLengths.Text = "AltLineLen"; + // + // labelAlternateText + // + this.labelAlternateText.AutoSize = true; + this.labelAlternateText.Location = new System.Drawing.Point(803, 11); + this.labelAlternateText.Name = "labelAlternateText"; + this.labelAlternateText.Size = new System.Drawing.Size(28, 13); + this.labelAlternateText.TabIndex = 34; + this.labelAlternateText.Text = "Text"; + this.labelAlternateText.Visible = false; + // + // labelText + // + this.labelText.AutoSize = true; + this.labelText.Location = new System.Drawing.Point(239, 11); + this.labelText.Name = "labelText"; + this.labelText.Size = new System.Drawing.Size(28, 13); + this.labelText.TabIndex = 5; + this.labelText.Text = "Text"; + // + // textBoxListViewTextAlternate + // + this.textBoxListViewTextAlternate.AllowDrop = true; + this.textBoxListViewTextAlternate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxListViewTextAlternate.ContextMenuStrip = this.contextMenuStripTextBoxListView; + this.textBoxListViewTextAlternate.Enabled = false; + this.textBoxListViewTextAlternate.HideSelection = false; + this.textBoxListViewTextAlternate.Location = new System.Drawing.Point(946, 28); + this.textBoxListViewTextAlternate.Multiline = true; + this.textBoxListViewTextAlternate.Name = "textBoxListViewTextAlternate"; + this.textBoxListViewTextAlternate.Size = new System.Drawing.Size(0, 63); + this.textBoxListViewTextAlternate.TabIndex = 33; + this.textBoxListViewTextAlternate.Visible = false; + this.textBoxListViewTextAlternate.MouseClick += new System.Windows.Forms.MouseEventHandler(this.TextBoxListViewTextAlternateMouseClick); + this.textBoxListViewTextAlternate.TextChanged += new System.EventHandler(this.textBoxListViewTextAlternate_TextChanged); + this.textBoxListViewTextAlternate.Enter += new System.EventHandler(this.TextBoxListViewTextAlternateEnter); + this.textBoxListViewTextAlternate.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxListViewTextAlternateKeyDown); + this.textBoxListViewTextAlternate.KeyUp += new System.Windows.Forms.KeyEventHandler(this.TextBoxListViewTextAlternateKeyUp); + this.textBoxListViewTextAlternate.MouseMove += new System.Windows.Forms.MouseEventHandler(this.TextBoxListViewTextAlternateMouseMove); + // + // contextMenuStripTextBoxListView + // + this.contextMenuStripTextBoxListView.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemWebVttVoice, + this.toolStripSeparatorWebVTT, + this.cutToolStripMenuItem, + this.copyToolStripMenuItem, + this.pasteToolStripMenuItem, + this.deleteToolStripMenuItem, + this.toolStripMenuItemSplitTextAtCursor, + this.toolStripMenuItemSplitViaWaveform, + this.toolStripSeparator18, + this.selectAllToolStripMenuItem, + this.toolStripSeparator17, + this.normalToolStripMenuItem1, + this.boldToolStripMenuItem1, + this.italicToolStripMenuItem1, + this.boxToolStripMenuItem1, + this.underlineToolStripMenuItem1, + this.colorToolStripMenuItem1, + this.toolStripMenuItemHorizontalDigits, + this.toolStripMenuItemBouten, + this.toolStripMenuItemRuby, + this.fontNameToolStripMenuItem, + this.toolStripSeparator26, + this.toolStripMenuItemInsertUnicodeSymbol, + this.toolStripMenuItemInsertUnicodeControlCharacters, + this.superscriptToolStripMenuItem, + this.subscriptToolStripMenuItem}); + this.contextMenuStripTextBoxListView.Name = "contextMenuStripTextBoxListView"; + this.contextMenuStripTextBoxListView.Size = new System.Drawing.Size(274, 512); + this.contextMenuStripTextBoxListView.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.MenuClosed); + this.contextMenuStripTextBoxListView.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripTextBoxListViewOpening); + this.contextMenuStripTextBoxListView.Opened += new System.EventHandler(this.MenuOpened); + // + // toolStripMenuItemWebVttVoice + // + this.toolStripMenuItemWebVttVoice.Name = "toolStripMenuItemWebVttVoice"; + this.toolStripMenuItemWebVttVoice.Size = new System.Drawing.Size(273, 22); + this.toolStripMenuItemWebVttVoice.Text = "WebVTT voice"; + // + // toolStripSeparatorWebVTT + // + this.toolStripSeparatorWebVTT.Name = "toolStripSeparatorWebVTT"; + this.toolStripSeparatorWebVTT.Size = new System.Drawing.Size(270, 6); + // + // cutToolStripMenuItem + // + this.cutToolStripMenuItem.Name = "cutToolStripMenuItem"; + this.cutToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); + this.cutToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + this.cutToolStripMenuItem.Text = "Cut"; + this.cutToolStripMenuItem.Click += new System.EventHandler(this.cutToolStripMenuItem_Click); + // + // copyToolStripMenuItem + // + this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; + this.copyToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); + this.copyToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + this.copyToolStripMenuItem.Text = "Copy"; + this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); + // + // pasteToolStripMenuItem + // + this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem"; + this.pasteToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V))); + this.pasteToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + this.pasteToolStripMenuItem.Text = "Paste"; + this.pasteToolStripMenuItem.Click += new System.EventHandler(this.PasteToolStripMenuItemClick); + // + // deleteToolStripMenuItem + // + this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + this.deleteToolStripMenuItem.Text = "Delete"; + this.deleteToolStripMenuItem.Click += new System.EventHandler(this.DeleteToolStripMenuItemClick); + // + // toolStripMenuItemSplitTextAtCursor + // + this.toolStripMenuItemSplitTextAtCursor.Name = "toolStripMenuItemSplitTextAtCursor"; + this.toolStripMenuItemSplitTextAtCursor.Size = new System.Drawing.Size(273, 22); + this.toolStripMenuItemSplitTextAtCursor.Text = "Split text at cursor position"; + this.toolStripMenuItemSplitTextAtCursor.Click += new System.EventHandler(this.ToolStripMenuItemSplitTextAtCursorClick); + // + // toolStripMenuItemSplitViaWaveform + // + this.toolStripMenuItemSplitViaWaveform.Name = "toolStripMenuItemSplitViaWaveform"; + this.toolStripMenuItemSplitViaWaveform.Size = new System.Drawing.Size(273, 22); + this.toolStripMenuItemSplitViaWaveform.Text = "Split text at cursor/waveform position"; + this.toolStripMenuItemSplitViaWaveform.Click += new System.EventHandler(this.toolStripMenuItemSplitViaWaveform_Click); + // + // toolStripSeparator18 + // + this.toolStripSeparator18.Name = "toolStripSeparator18"; + this.toolStripSeparator18.Size = new System.Drawing.Size(270, 6); + // + // selectAllToolStripMenuItem + // + this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem"; + this.selectAllToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A))); + this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + this.selectAllToolStripMenuItem.Text = "Select all"; + this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.selectAllToolStripMenuItem_Click); + // + // toolStripSeparator17 + // + this.toolStripSeparator17.Name = "toolStripSeparator17"; + this.toolStripSeparator17.Size = new System.Drawing.Size(270, 6); + // + // normalToolStripMenuItem1 + // + this.normalToolStripMenuItem1.Name = "normalToolStripMenuItem1"; + this.normalToolStripMenuItem1.Size = new System.Drawing.Size(273, 22); + this.normalToolStripMenuItem1.Text = "Normal"; + this.normalToolStripMenuItem1.Click += new System.EventHandler(this.NormalToolStripMenuItem1Click); + // + // boldToolStripMenuItem1 + // + this.boldToolStripMenuItem1.Name = "boldToolStripMenuItem1"; + this.boldToolStripMenuItem1.Size = new System.Drawing.Size(273, 22); + this.boldToolStripMenuItem1.Text = "Bold"; + this.boldToolStripMenuItem1.Click += new System.EventHandler(this.BoldToolStripMenuItem1Click); + // + // italicToolStripMenuItem1 + // + this.italicToolStripMenuItem1.Name = "italicToolStripMenuItem1"; + this.italicToolStripMenuItem1.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); + this.italicToolStripMenuItem1.Size = new System.Drawing.Size(273, 22); + this.italicToolStripMenuItem1.Text = "Italic"; + this.italicToolStripMenuItem1.Click += new System.EventHandler(this.ItalicToolStripMenuItem1Click); + // + // boxToolStripMenuItem1 + // + this.boxToolStripMenuItem1.Name = "boxToolStripMenuItem1"; + this.boxToolStripMenuItem1.Size = new System.Drawing.Size(273, 22); + this.boxToolStripMenuItem1.Text = "Box"; + this.boxToolStripMenuItem1.Click += new System.EventHandler(this.boxToolStripMenuItem1_Click); + // + // underlineToolStripMenuItem1 + // + this.underlineToolStripMenuItem1.Name = "underlineToolStripMenuItem1"; + this.underlineToolStripMenuItem1.Size = new System.Drawing.Size(273, 22); + this.underlineToolStripMenuItem1.Text = "Underline"; + this.underlineToolStripMenuItem1.Click += new System.EventHandler(this.UnderlineToolStripMenuItem1Click); + // + // colorToolStripMenuItem1 + // + this.colorToolStripMenuItem1.Name = "colorToolStripMenuItem1"; + this.colorToolStripMenuItem1.Size = new System.Drawing.Size(273, 22); + this.colorToolStripMenuItem1.Text = "Color..."; + this.colorToolStripMenuItem1.Click += new System.EventHandler(this.ColorToolStripMenuItem1Click); + // + // toolStripMenuItemHorizontalDigits + // + this.toolStripMenuItemHorizontalDigits.Name = "toolStripMenuItemHorizontalDigits"; + this.toolStripMenuItemHorizontalDigits.Size = new System.Drawing.Size(273, 22); + this.toolStripMenuItemHorizontalDigits.Text = "Horizontal digits"; + this.toolStripMenuItemHorizontalDigits.Click += new System.EventHandler(this.toolStripMenuItemHorizontalDigits_Click); + // + // toolStripMenuItemBouten + // + this.toolStripMenuItemBouten.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.boutendotbeforeToolStripMenuItem, + this.boutendotafterToolStripMenuItem, + this.boutendotoutsideToolStripMenuItem, + this.boutenfilledcircleoutsideToolStripMenuItem, + this.boutenopencircleoutsideToolStripMenuItem, + this.boutenopendotoutsideToolStripMenuItem, + this.boutenfilledsesameoutsideToolStripMenuItem, + this.boutenopensesameoutsideToolStripMenuItem, + this.boutenautooutsideToolStripMenuItem, + this.boutenautoToolStripMenuItem}); + this.toolStripMenuItemBouten.Name = "toolStripMenuItemBouten"; + this.toolStripMenuItemBouten.Size = new System.Drawing.Size(273, 22); + this.toolStripMenuItemBouten.Text = "Bouten"; + // + // boutendotbeforeToolStripMenuItem + // + this.boutendotbeforeToolStripMenuItem.Name = "boutendotbeforeToolStripMenuItem"; + this.boutendotbeforeToolStripMenuItem.Size = new System.Drawing.Size(232, 22); + this.boutendotbeforeToolStripMenuItem.Text = "bouten-dot-before"; + this.boutendotbeforeToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); + // + // boutendotafterToolStripMenuItem + // + this.boutendotafterToolStripMenuItem.Name = "boutendotafterToolStripMenuItem"; + this.boutendotafterToolStripMenuItem.Size = new System.Drawing.Size(232, 22); + this.boutendotafterToolStripMenuItem.Text = "bouten-dot-after"; + this.boutendotafterToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); + // + // boutendotoutsideToolStripMenuItem + // + this.boutendotoutsideToolStripMenuItem.Name = "boutendotoutsideToolStripMenuItem"; + this.boutendotoutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); + this.boutendotoutsideToolStripMenuItem.Text = "bouten-dot-outside"; + this.boutendotoutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); + // + // boutenfilledcircleoutsideToolStripMenuItem + // + this.boutenfilledcircleoutsideToolStripMenuItem.Name = "boutenfilledcircleoutsideToolStripMenuItem"; + this.boutenfilledcircleoutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); + this.boutenfilledcircleoutsideToolStripMenuItem.Text = "bouten-filled-circle-outside"; + this.boutenfilledcircleoutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); + // + // boutenopencircleoutsideToolStripMenuItem + // + this.boutenopencircleoutsideToolStripMenuItem.Name = "boutenopencircleoutsideToolStripMenuItem"; + this.boutenopencircleoutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); + this.boutenopencircleoutsideToolStripMenuItem.Text = "bouten-open-circle-outside"; + this.boutenopencircleoutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); + // + // boutenopendotoutsideToolStripMenuItem + // + this.boutenopendotoutsideToolStripMenuItem.Name = "boutenopendotoutsideToolStripMenuItem"; + this.boutenopendotoutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); + this.boutenopendotoutsideToolStripMenuItem.Text = "bouten-open-dot-outside"; + this.boutenopendotoutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); + // + // boutenfilledsesameoutsideToolStripMenuItem + // + this.boutenfilledsesameoutsideToolStripMenuItem.Name = "boutenfilledsesameoutsideToolStripMenuItem"; + this.boutenfilledsesameoutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); + this.boutenfilledsesameoutsideToolStripMenuItem.Text = "bouten-filled-sesame-outside"; + this.boutenfilledsesameoutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); + // + // boutenopensesameoutsideToolStripMenuItem + // + this.boutenopensesameoutsideToolStripMenuItem.Name = "boutenopensesameoutsideToolStripMenuItem"; + this.boutenopensesameoutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); + this.boutenopensesameoutsideToolStripMenuItem.Text = "bouten-open-sesame-outside"; + this.boutenopensesameoutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); + // + // boutenautooutsideToolStripMenuItem + // + this.boutenautooutsideToolStripMenuItem.Name = "boutenautooutsideToolStripMenuItem"; + this.boutenautooutsideToolStripMenuItem.Size = new System.Drawing.Size(232, 22); + this.boutenautooutsideToolStripMenuItem.Text = "bouten-auto-outside"; + this.boutenautooutsideToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); + // + // boutenautoToolStripMenuItem + // + this.boutenautoToolStripMenuItem.Name = "boutenautoToolStripMenuItem"; + this.boutenautoToolStripMenuItem.Size = new System.Drawing.Size(232, 22); + this.boutenautoToolStripMenuItem.Text = "bouten-auto"; + this.boutenautoToolStripMenuItem.Click += new System.EventHandler(this.BoutenToolStripMenuItemClick); + // + // toolStripMenuItemRuby + // + this.toolStripMenuItemRuby.Name = "toolStripMenuItemRuby"; + this.toolStripMenuItemRuby.Size = new System.Drawing.Size(273, 22); + this.toolStripMenuItemRuby.Text = "Ruby..."; + this.toolStripMenuItemRuby.Click += new System.EventHandler(this.toolStripMenuItemRuby_Click); + // + // fontNameToolStripMenuItem + // + this.fontNameToolStripMenuItem.Name = "fontNameToolStripMenuItem"; + this.fontNameToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + this.fontNameToolStripMenuItem.Text = "Font name..."; + this.fontNameToolStripMenuItem.Click += new System.EventHandler(this.FontNameToolStripMenuItemClick); + // + // toolStripSeparator26 + // + this.toolStripSeparator26.Name = "toolStripSeparator26"; + this.toolStripSeparator26.Size = new System.Drawing.Size(270, 6); + // + // toolStripMenuItemInsertUnicodeSymbol + // + this.toolStripMenuItemInsertUnicodeSymbol.Name = "toolStripMenuItemInsertUnicodeSymbol"; + this.toolStripMenuItemInsertUnicodeSymbol.Size = new System.Drawing.Size(273, 22); + this.toolStripMenuItemInsertUnicodeSymbol.Text = "Insert unicode character"; + // + // toolStripMenuItemInsertUnicodeControlCharacters + // + this.toolStripMenuItemInsertUnicodeControlCharacters.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.leftToolStripMenuItem, + this.righttoleftMarkToolStripMenuItem, + this.startOfLefttorightEmbeddingLREToolStripMenuItem, + this.startOfRighttoleftEmbeddingRLEToolStripMenuItem, + this.startOfLefttorightOverrideLROToolStripMenuItem, + this.startOfRighttoleftOverrideRLOToolStripMenuItem}); + this.toolStripMenuItemInsertUnicodeControlCharacters.Name = "toolStripMenuItemInsertUnicodeControlCharacters"; + this.toolStripMenuItemInsertUnicodeControlCharacters.Size = new System.Drawing.Size(273, 22); + this.toolStripMenuItemInsertUnicodeControlCharacters.Text = "Insert unicode control character"; + // + // leftToolStripMenuItem + // + this.leftToolStripMenuItem.Name = "leftToolStripMenuItem"; + this.leftToolStripMenuItem.Size = new System.Drawing.Size(272, 22); + this.leftToolStripMenuItem.Text = "Left-to-right mark (LRM)"; + this.leftToolStripMenuItem.Click += new System.EventHandler(this.leftToolStripMenuItem_Click); + // + // righttoleftMarkToolStripMenuItem + // + this.righttoleftMarkToolStripMenuItem.Name = "righttoleftMarkToolStripMenuItem"; + this.righttoleftMarkToolStripMenuItem.Size = new System.Drawing.Size(272, 22); + this.righttoleftMarkToolStripMenuItem.Text = "Right-to-left mark (RLM)"; + this.righttoleftMarkToolStripMenuItem.Click += new System.EventHandler(this.righttoleftMarkToolStripMenuItem_Click); + // + // startOfLefttorightEmbeddingLREToolStripMenuItem + // + this.startOfLefttorightEmbeddingLREToolStripMenuItem.Name = "startOfLefttorightEmbeddingLREToolStripMenuItem"; + this.startOfLefttorightEmbeddingLREToolStripMenuItem.Size = new System.Drawing.Size(272, 22); + this.startOfLefttorightEmbeddingLREToolStripMenuItem.Text = "Start of left-to-right embedding (LRE)"; + this.startOfLefttorightEmbeddingLREToolStripMenuItem.Click += new System.EventHandler(this.startOfLefttorightEmbeddingLREToolStripMenuItem_Click); + // + // startOfRighttoleftEmbeddingRLEToolStripMenuItem + // + this.startOfRighttoleftEmbeddingRLEToolStripMenuItem.Name = "startOfRighttoleftEmbeddingRLEToolStripMenuItem"; + this.startOfRighttoleftEmbeddingRLEToolStripMenuItem.Size = new System.Drawing.Size(272, 22); + this.startOfRighttoleftEmbeddingRLEToolStripMenuItem.Text = "Start of right-to-left embedding (RLE)"; + this.startOfRighttoleftEmbeddingRLEToolStripMenuItem.Click += new System.EventHandler(this.startOfRighttoleftEmbeddingRLEToolStripMenuItem_Click); + // + // startOfLefttorightOverrideLROToolStripMenuItem + // + this.startOfLefttorightOverrideLROToolStripMenuItem.Name = "startOfLefttorightOverrideLROToolStripMenuItem"; + this.startOfLefttorightOverrideLROToolStripMenuItem.Size = new System.Drawing.Size(272, 22); + this.startOfLefttorightOverrideLROToolStripMenuItem.Text = "Start of left-to-right override (LRO)"; + this.startOfLefttorightOverrideLROToolStripMenuItem.Click += new System.EventHandler(this.startOfLefttorightOverrideLROToolStripMenuItem_Click); + // + // startOfRighttoleftOverrideRLOToolStripMenuItem + // + this.startOfRighttoleftOverrideRLOToolStripMenuItem.Name = "startOfRighttoleftOverrideRLOToolStripMenuItem"; + this.startOfRighttoleftOverrideRLOToolStripMenuItem.Size = new System.Drawing.Size(272, 22); + this.startOfRighttoleftOverrideRLOToolStripMenuItem.Text = "Start of right-to-left override (RLO)"; + this.startOfRighttoleftOverrideRLOToolStripMenuItem.Click += new System.EventHandler(this.startOfRighttoleftOverrideRLOToolStripMenuItem_Click); + // + // superscriptToolStripMenuItem + // + this.superscriptToolStripMenuItem.Name = "superscriptToolStripMenuItem"; + this.superscriptToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + this.superscriptToolStripMenuItem.Text = "Superscript"; + this.superscriptToolStripMenuItem.Click += new System.EventHandler(this.SuperscriptToolStripMenuItemClick); + // + // subscriptToolStripMenuItem + // + this.subscriptToolStripMenuItem.Name = "subscriptToolStripMenuItem"; + this.subscriptToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + this.subscriptToolStripMenuItem.Text = "Subscript"; + this.subscriptToolStripMenuItem.Click += new System.EventHandler(this.SubscriptToolStripMenuItemClick); + // + // buttonAutoBreak + // + this.buttonAutoBreak.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAutoBreak.Location = new System.Drawing.Point(604, 51); + this.buttonAutoBreak.Name = "buttonAutoBreak"; + this.buttonAutoBreak.Size = new System.Drawing.Size(115, 23); + this.buttonAutoBreak.TabIndex = 7; + this.buttonAutoBreak.Text = "Auto br"; + this.buttonAutoBreak.UseVisualStyleBackColor = true; + this.buttonAutoBreak.Click += new System.EventHandler(this.ButtonAutoBreakClick); + // + // labelTextLineLengths + // + this.labelTextLineLengths.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelTextLineLengths.AutoSize = true; + this.labelTextLineLengths.Location = new System.Drawing.Point(239, 94); + this.labelTextLineLengths.Name = "labelTextLineLengths"; + this.labelTextLineLengths.Size = new System.Drawing.Size(108, 13); + this.labelTextLineLengths.TabIndex = 12; + this.labelTextLineLengths.Text = "labelTextLineLengths"; + // + // labelTextLineTotal + // + this.labelTextLineTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelTextLineTotal.AutoSize = true; + this.labelTextLineTotal.Location = new System.Drawing.Point(1001, 94); + this.labelTextLineTotal.Name = "labelTextLineTotal"; + this.labelTextLineTotal.Size = new System.Drawing.Size(94, 13); + this.labelTextLineTotal.TabIndex = 21; + this.labelTextLineTotal.Text = "labelTextLineTotal"; + // + // labelCharactersPerSecond + // + this.labelCharactersPerSecond.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelCharactersPerSecond.AutoSize = true; + this.labelCharactersPerSecond.Location = new System.Drawing.Point(432, 11); + this.labelCharactersPerSecond.Name = "labelCharactersPerSecond"; + this.labelCharactersPerSecond.Size = new System.Drawing.Size(133, 13); + this.labelCharactersPerSecond.TabIndex = 31; + this.labelCharactersPerSecond.Text = "labelCharactersPerSecond"; + // + // buttonUnBreak + // + this.buttonUnBreak.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUnBreak.Location = new System.Drawing.Point(604, 22); + this.buttonUnBreak.Name = "buttonUnBreak"; + this.buttonUnBreak.Size = new System.Drawing.Size(115, 23); + this.buttonUnBreak.TabIndex = 6; + this.buttonUnBreak.Text = "Unbreak"; + this.buttonUnBreak.UseVisualStyleBackColor = true; + this.buttonUnBreak.Click += new System.EventHandler(this.ButtonUnBreakClick); + // + // timeUpDownStartTime + // + this.timeUpDownStartTime.AutoSize = true; + this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownStartTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + this.timeUpDownStartTime.Location = new System.Drawing.Point(8, 26); + this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownStartTime.Name = "timeUpDownStartTime"; + this.timeUpDownStartTime.Size = new System.Drawing.Size(111, 27); + this.timeUpDownStartTime.TabIndex = 0; + timeCode6.Hours = 0; + timeCode6.Milliseconds = 0; + timeCode6.Minutes = 0; + timeCode6.Seconds = 0; + timeCode6.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode6.TotalMilliseconds = 0D; + timeCode6.TotalSeconds = 0D; + this.timeUpDownStartTime.TimeCode = timeCode6; + this.timeUpDownStartTime.UseVideoOffset = false; + // + // numericUpDownDuration + // + this.numericUpDownDuration.DecimalPlaces = 3; + this.numericUpDownDuration.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownDuration.Location = new System.Drawing.Point(122, 27); + this.numericUpDownDuration.Maximum = new decimal(new int[] { + 999999999, + 0, + 0, + 0}); + this.numericUpDownDuration.Minimum = new decimal(new int[] { + 99999, + 0, + 0, + -2147483648}); + this.numericUpDownDuration.Name = "numericUpDownDuration"; + this.numericUpDownDuration.Size = new System.Drawing.Size(56, 20); + this.numericUpDownDuration.TabIndex = 1; + this.numericUpDownDuration.ValueChanged += new System.EventHandler(this.NumericUpDownDurationValueChanged); + // + // buttonPrevious + // + this.buttonPrevious.Location = new System.Drawing.Point(8, 78); + this.buttonPrevious.Name = "buttonPrevious"; + this.buttonPrevious.Size = new System.Drawing.Size(72, 23); + this.buttonPrevious.TabIndex = 2; + this.buttonPrevious.Text = "< Prev "; + this.buttonPrevious.UseVisualStyleBackColor = true; + this.buttonPrevious.Click += new System.EventHandler(this.ButtonPreviousClick); + // + // buttonNext + // + this.buttonNext.Location = new System.Drawing.Point(86, 78); + this.buttonNext.Name = "buttonNext"; + this.buttonNext.Size = new System.Drawing.Size(72, 23); + this.buttonNext.TabIndex = 3; + this.buttonNext.Text = "Next >"; + this.buttonNext.UseVisualStyleBackColor = true; + this.buttonNext.Click += new System.EventHandler(this.ButtonNextClick); + // + // labelStartTime + // + this.labelStartTime.AutoSize = true; + this.labelStartTime.Location = new System.Drawing.Point(9, 11); + this.labelStartTime.Name = "labelStartTime"; + this.labelStartTime.Size = new System.Drawing.Size(51, 13); + this.labelStartTime.TabIndex = 3; + this.labelStartTime.Text = "Start time"; + // + // textBoxListViewText + // + this.textBoxListViewText.AllowDrop = true; + this.textBoxListViewText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxListViewText.ContextMenuStrip = this.contextMenuStripTextBoxListView; + this.textBoxListViewText.Enabled = false; + this.textBoxListViewText.HideSelection = false; + this.textBoxListViewText.Location = new System.Drawing.Point(236, 28); + this.textBoxListViewText.Multiline = true; + this.textBoxListViewText.Name = "textBoxListViewText"; + this.textBoxListViewText.Size = new System.Drawing.Size(362, 63); + this.textBoxListViewText.TabIndex = 5; + this.textBoxListViewText.MouseClick += new System.Windows.Forms.MouseEventHandler(this.TextBoxListViewTextMouseClick); + this.textBoxListViewText.TextChanged += new System.EventHandler(this.TextBoxListViewTextTextChanged); + this.textBoxListViewText.Enter += new System.EventHandler(this.TextBoxListViewTextEnter); + this.textBoxListViewText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxListViewTextKeyDown); + this.textBoxListViewText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBoxListViewText_KeyUp); + this.textBoxListViewText.Leave += new System.EventHandler(this.textBoxListViewText_Leave); + this.textBoxListViewText.MouseMove += new System.Windows.Forms.MouseEventHandler(this.textBoxListViewText_MouseMove); + // + // labelDuration + // + this.labelDuration.AutoSize = true; + this.labelDuration.Location = new System.Drawing.Point(122, 11); + this.labelDuration.Name = "labelDuration"; + this.labelDuration.Size = new System.Drawing.Size(47, 13); + this.labelDuration.TabIndex = 4; + this.labelDuration.Text = "Duration"; + // + // labelAutoDuration + // + this.labelAutoDuration.AutoSize = true; + this.labelAutoDuration.Location = new System.Drawing.Point(92, 11); + this.labelAutoDuration.Name = "labelAutoDuration"; + this.labelAutoDuration.Size = new System.Drawing.Size(29, 13); + this.labelAutoDuration.TabIndex = 30; + this.labelAutoDuration.Text = "Auto"; + // + // tabPage2 + // + this.tabPage2.Controls.Add(this.textBoxSource); + this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(730, 222); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "Source view"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // textBoxSource + // + this.textBoxSource.AllowDrop = true; + this.textBoxSource.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBoxSource.HideSelection = false; + this.textBoxSource.Location = new System.Drawing.Point(3, 3); + this.textBoxSource.MaxLength = 0; + this.textBoxSource.Multiline = true; + this.textBoxSource.Name = "textBoxSource"; + this.textBoxSource.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBoxSource.Size = new System.Drawing.Size(724, 216); + this.textBoxSource.TabIndex = 12; + this.textBoxSource.WordWrap = false; + this.textBoxSource.Click += new System.EventHandler(this.TextBoxSourceClick); + this.textBoxSource.TextChanged += new System.EventHandler(this.TextBoxSourceTextChanged); + this.textBoxSource.DragDrop += new System.Windows.Forms.DragEventHandler(this.TextBoxSourceDragDrop); + this.textBoxSource.DragEnter += new System.Windows.Forms.DragEventHandler(this.TextBoxSourceDragEnter); + this.textBoxSource.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxSourceKeyDown); + this.textBoxSource.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBoxSource_KeyUp); + this.textBoxSource.Leave += new System.EventHandler(this.TextBoxSourceLeave); + // + // panelVideoPlayer + // + this.panelVideoPlayer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panelVideoPlayer.Controls.Add(this.mediaPlayer); + this.panelVideoPlayer.Location = new System.Drawing.Point(1, 1); + this.panelVideoPlayer.Name = "panelVideoPlayer"; + this.panelVideoPlayer.Size = new System.Drawing.Size(220, 246); + this.panelVideoPlayer.TabIndex = 5; + // + // mediaPlayer + // + this.mediaPlayer.AllowDrop = true; + this.mediaPlayer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.mediaPlayer.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18))))); + this.mediaPlayer.CurrentPosition = 0D; + this.mediaPlayer.FontSizeFactor = 1F; + this.mediaPlayer.LastParagraph = null; + this.mediaPlayer.Location = new System.Drawing.Point(0, 0); + this.mediaPlayer.Margin = new System.Windows.Forms.Padding(0); + this.mediaPlayer.Name = "mediaPlayer"; + this.mediaPlayer.ShowFullscreenButton = true; + this.mediaPlayer.ShowMuteButton = true; + this.mediaPlayer.ShowStopButton = true; + this.mediaPlayer.Size = new System.Drawing.Size(219, 246); + this.mediaPlayer.SmpteMode = false; + this.mediaPlayer.SubtitleText = ""; + this.mediaPlayer.TabIndex = 5; + this.mediaPlayer.TextRightToLeft = System.Windows.Forms.RightToLeft.No; + this.mediaPlayer.VideoHeight = 0; + this.mediaPlayer.VideoPlayer = null; + this.mediaPlayer.VideoWidth = 0; + this.mediaPlayer.Volume = 0D; + this.mediaPlayer.DragDrop += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragDrop); + this.mediaPlayer.DragEnter += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragEnter); + // + // contextMenuStripEmpty + // + this.contextMenuStripEmpty.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.insertLineToolStripMenuItem, + this.aSSStylesToolStripMenuItem}); + this.contextMenuStripEmpty.Name = "contextMenuStripEmpty"; + this.contextMenuStripEmpty.Size = new System.Drawing.Size(181, 70); + this.contextMenuStripEmpty.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripEmpty_Opening); + // + // insertLineToolStripMenuItem + // + this.insertLineToolStripMenuItem.Name = "insertLineToolStripMenuItem"; + this.insertLineToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.insertLineToolStripMenuItem.Text = "Insert line"; + this.insertLineToolStripMenuItem.Click += new System.EventHandler(this.InsertLineToolStripMenuItemClick); + // + // imageListPlayRate + // + this.imageListPlayRate.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListPlayRate.ImageStream"))); + this.imageListPlayRate.TransparentColor = System.Drawing.Color.Transparent; + this.imageListPlayRate.Images.SetKeyName(0, "FastForward.png"); + this.imageListPlayRate.Images.SetKeyName(1, "FastForwardHighLight.png"); + // + // timerTextUndo + // + this.timerTextUndo.Interval = 700; + this.timerTextUndo.Tick += new System.EventHandler(this.TimerTextUndoTick); + // + // timerAlternateTextUndo + // + this.timerAlternateTextUndo.Interval = 700; + this.timerAlternateTextUndo.Tick += new System.EventHandler(this.TimerAlternateTextUndoTick); + // + // aSSStylesToolStripMenuItem + // + this.aSSStylesToolStripMenuItem.Name = "aSSStylesToolStripMenuItem"; + this.aSSStylesToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.aSSStylesToolStripMenuItem.Text = "ASS styles..."; + this.aSSStylesToolStripMenuItem.Click += new System.EventHandler(this.aSSStylesToolStripMenuItem_Click); + // + // Main + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(975, 646); + this.Controls.Add(this.splitContainerMain); + this.Controls.Add(this.toolStrip1); + this.Controls.Add(this.statusStrip1); + this.Controls.Add(this.menuStrip1); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MainMenuStrip = this.menuStrip1; + this.MinimumSize = new System.Drawing.Size(800, 554); + this.Name = "Main"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormMain_FormClosing); + this.Load += new System.EventHandler(this.Main_Load); + this.Shown += new System.EventHandler(this.Main_Shown); + this.ResizeEnd += new System.EventHandler(this.Main_ResizeEnd); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MainKeyDown); + this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.MainKeyUp); + this.Resize += new System.EventHandler(this.Main_Resize); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); + this.toolStrip1.ResumeLayout(false); + this.toolStrip1.PerformLayout(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.contextMenuStripListview.ResumeLayout(false); + this.groupBoxVideo.ResumeLayout(false); + this.groupBoxVideo.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.trackBarWaveformPosition)).EndInit(); + this.panelWaveformControls.ResumeLayout(false); + this.panelWaveformControls.PerformLayout(); + this.toolStripWaveControls.ResumeLayout(false); + this.toolStripWaveControls.PerformLayout(); + this.tabControlButtons.ResumeLayout(false); + this.tabPageTranslate.ResumeLayout(false); + this.tabPageTranslate.PerformLayout(); + this.groupBoxTranslateSearch.ResumeLayout(false); + this.groupBoxTranslateSearch.PerformLayout(); + this.groupBoxAutoContinue.ResumeLayout(false); + this.groupBoxAutoContinue.PerformLayout(); + this.groupBoxAutoRepeat.ResumeLayout(false); + this.groupBoxAutoRepeat.PerformLayout(); + this.tabPageCreate.ResumeLayout(false); + this.tabPageCreate.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSec2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSec1)).EndInit(); + this.tabPageAdjust.ResumeLayout(false); + this.tabPageAdjust.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSecAdjust2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSecAdjust1)).EndInit(); + this.contextMenuStripWaveform.ResumeLayout(false); + this.splitContainerMain.Panel1.ResumeLayout(false); + this.splitContainerMain.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainerMain)).EndInit(); + this.splitContainerMain.ResumeLayout(false); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.tabControlSubtitle.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.splitContainerListViewAndText.Panel1.ResumeLayout(false); + this.splitContainerListViewAndText.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainerListViewAndText)).EndInit(); + this.splitContainerListViewAndText.ResumeLayout(false); + this.groupBoxEdit.ResumeLayout(false); + this.groupBoxEdit.PerformLayout(); + this.panelBookmark.ResumeLayout(false); + this.panelBookmark.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBookmark)).EndInit(); + this.contextMenuStripTextBoxListView.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).EndInit(); + this.tabPage2.ResumeLayout(false); + this.tabPage2.PerformLayout(); + this.panelVideoPlayer.ResumeLayout(false); + this.contextMenuStripEmpty.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStrip toolStrip1; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem reopenToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem findToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem findNextToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem replaceToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem gotoLineNumberToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; + private System.Windows.Forms.TabControl tabControlSubtitle; + private System.Windows.Forms.TabPage tabPage1; + private Nikse.SubtitleEdit.Controls.SubtitleListView SubtitleListview1; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.TextBox textBoxSource; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.ToolStripButton toolStripButtonFileOpen; + private System.Windows.Forms.ToolStripButton toolStripButtonFileNew; + private System.Windows.Forms.ToolStripButton toolStripButtonSave; + private System.Windows.Forms.ToolStripButton toolStripButtonSaveAs; + private System.Windows.Forms.ToolStripButton toolStripButtonFind; + private System.Windows.Forms.ToolStripButton toolStripButtonReplace; + private System.Windows.Forms.ToolStripButton toolStripButtonSpellCheck; + private System.Windows.Forms.ToolStripButton toolStripButtonSettings; + private System.Windows.Forms.ToolStripButton toolStripButtonVisualSync; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorFindReplace; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorFixSyncSpell; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorHelp; + private System.Windows.Forms.ToolStripButton toolStripButtonHelp; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.ToolStripStatusLabel labelStatus; + private System.Windows.Forms.ToolStripMenuItem adjustDisplayTimeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem fixToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem startNumberingFromToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeTextForHearImpairedToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripMenuItem splitToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem appendTextVisuallyToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem showHistoryforUndoToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip contextMenuStripListview; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDelete; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertBefore; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertAfter; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; + private System.Windows.Forms.ToolStripMenuItem boldToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem italicToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem underlineToolStripMenuItem; + private System.Windows.Forms.GroupBox groupBoxEdit; + private System.Windows.Forms.Label labelText; + private System.Windows.Forms.Label labelDuration; + private System.Windows.Forms.Label labelStartTime; + //private System.Windows.Forms.TextBox textBoxListViewText; + Nikse.SubtitleEdit.Controls.SETextBox textBoxListViewText; + private System.Windows.Forms.Button buttonPrevious; + private System.Windows.Forms.Button buttonNext; + private System.Windows.Forms.ToolStripMenuItem splitLineToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mergeBeforeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mergeAfterToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator8; + private System.Windows.Forms.Button buttonAutoBreak; + private System.Windows.Forms.ToolStripMenuItem removeFormattinglToolStripMenuItem; + private System.Windows.Forms.Label labelTextLineLengths; + private System.Windows.Forms.NumericUpDown numericUpDownDuration; + private System.Windows.Forms.Label labelDurationWarning; + private System.Windows.Forms.Label labelStartTimeWarning; + private System.Windows.Forms.Button buttonUnBreak; + private System.Windows.Forms.ToolStripMenuItem colorToolStripMenuItem; + private System.Windows.Forms.ColorDialog colorDialog1; + private System.Windows.Forms.Label labelTextLineTotal; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripMenuItem typeEffectToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem karokeeEffectToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem matroskaImportStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator10; + private Nikse.SubtitleEdit.Controls.TimeUpDown timeUpDownStartTime; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemManualAnsi; + private System.Windows.Forms.ToolStripMenuItem ChangeCasingToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMergeLines; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorAdvancedFunctions; + private System.Windows.Forms.ToolStripMenuItem visualSyncSelectedLinesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem showSelectedLinesEarlierlaterToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem adjustDisplayTimeForSelectedLinesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem fixCommonErrorsInSelectedLinesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem changeCasingForSelectedLinesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSortBy; + private System.Windows.Forms.ToolStripMenuItem sortNumberToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem sortStartTimeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem sortEndTimeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem sortDisplayTimeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem sortTextMaxLineLengthToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem sortTextTotalLengthToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem sortTextNumberOfLinesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem sortTextAlphabeticallytoolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem changeLanguageToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator12; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemCompare; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemUnbreakLines; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAutoBreakLines; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorBreakLines; + private System.Windows.Forms.ToolStripMenuItem multipleReplaceToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportDvdSubtitles; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSubIdx; + private System.Windows.Forms.ToolStripStatusLabel toolStripSelected; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertUnicodeCharacter; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorInsertUnicodeCharacter; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAutoMergeShortLines; + private System.Windows.Forms.ToolStripMenuItem setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportText; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportTimeCodes; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemFont; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator14; + private System.Windows.Forms.GroupBox groupBoxVideo; + private System.Windows.Forms.Button buttonGotoSub; + private System.Windows.Forms.Button buttonBeforeText; + private System.Windows.Forms.Button buttonSetEnd; + private System.Windows.Forms.Button buttonSetStartTime; + private System.Windows.Forms.Button buttonInsertNewText; + private System.Windows.Forms.Button buttonSecBack1; + private System.Windows.Forms.Timer ShowSubtitleTimer; + private System.Windows.Forms.Timer timerAutoDuration; + private System.Windows.Forms.Label labelAutoDuration; + private System.Windows.Forms.Timer timerAutoContinue; + private System.Windows.Forms.ToolStripComboBox comboBoxSubtitleFormats; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorToggle; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorSubtitleFormat; + private System.Windows.Forms.ToolStripLabel toolStripLabelSubtitleFormat; + private System.Windows.Forms.ToolStripLabel toolStripLabelEncoding; + private System.Windows.Forms.ToolStripComboBox comboBoxEncoding; + private System.Windows.Forms.ToolStripButton toolStripButtonToggleVideo; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorEncoding; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorFrameRate; + private System.Windows.Forms.ToolStripLabel toolStripLabelFrameRate; + private System.Windows.Forms.ToolStripComboBox toolStripComboBoxFrameRate; + private System.Windows.Forms.ToolStripButton toolStripButtonGetFrameRate; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSpellCheckMain; + private System.Windows.Forms.ToolStripMenuItem spellCheckToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem findDoubleWordsToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator9; + private System.Windows.Forms.ToolStripMenuItem GetDictionariesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem addWordToNameListToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSynchronization; + private System.Windows.Forms.ToolStripMenuItem visualSyncToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemPointSync; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAdjustAllTimes; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAutoTranslate; + private System.Windows.Forms.ToolStripMenuItem translateByGoogleToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem translateFromSwedishToDanishToolStripMenuItem; + private System.Windows.Forms.Timer timerStillTyping; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemVideo; + private System.Windows.Forms.ToolStripMenuItem openVideoToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; + private System.Windows.Forms.ToolStripMenuItem showhideVideoToolStripMenuItem; + private System.Windows.Forms.Label labelVideoPosition; + private Controls.TimeUpDown timeUpDownVideoPosition; + private System.Windows.Forms.TabControl tabControlButtons; + private System.Windows.Forms.TabPage tabPageTranslate; + private System.Windows.Forms.GroupBox groupBoxTranslateSearch; + private System.Windows.Forms.Button buttonGoogleTranslateIt; + private System.Windows.Forms.Button buttonGoogleIt; + private System.Windows.Forms.TextBox textBoxSearchWord; + private System.Windows.Forms.GroupBox groupBoxAutoContinue; + private System.Windows.Forms.ComboBox comboBoxAutoContinue; + private System.Windows.Forms.Label labelAutoContinueDelay; + private System.Windows.Forms.CheckBox checkBoxAutoContinue; + private System.Windows.Forms.GroupBox groupBoxAutoRepeat; + private System.Windows.Forms.ComboBox comboBoxAutoRepeat; + private System.Windows.Forms.Label labelAutoRepeatCount; + private System.Windows.Forms.CheckBox checkBoxAutoRepeatOn; + private System.Windows.Forms.Button buttonStop; + private System.Windows.Forms.Button buttonPlayPrevious; + private System.Windows.Forms.Button buttonPlayCurrent; + private System.Windows.Forms.Button buttonPlayNext; + private System.Windows.Forms.TabPage tabPageCreate; + private System.Windows.Forms.TabPage tabPageAdjust; + private System.Windows.Forms.Button buttonAdjustGoToPosAndPause; + private System.Windows.Forms.Button buttonAdjustPlayBefore; + private System.Windows.Forms.Button buttonAdjustSetEndTime; + private System.Windows.Forms.Button buttonSetEndAndGoToNext; + private System.Windows.Forms.Button buttonSetStartAndOffsetRest; + private System.Windows.Forms.Button buttonAdjustSetStartTime; + private System.Windows.Forms.Label labelTranslateTip; + private System.Windows.Forms.Button buttonCustomUrl1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemOpenContainingFolder; + private System.Windows.Forms.NumericUpDown numericUpDownSec1; + private System.Windows.Forms.Button buttonForward1; + private System.Windows.Forms.Label labelVideoPosition2; + private Controls.TimeUpDown timeUpDownVideoPositionAdjust; + private System.Windows.Forms.Button buttonAdjustSecForward1; + private System.Windows.Forms.NumericUpDown numericUpDownSecAdjust1; + private System.Windows.Forms.Button buttonAdjustSecBack1; + private System.Windows.Forms.Button buttonForward2; + private System.Windows.Forms.NumericUpDown numericUpDownSec2; + private System.Windows.Forms.Button buttonSecBack2; + private System.Windows.Forms.Button buttonAdjustSecForward2; + private System.Windows.Forms.NumericUpDown numericUpDownSecAdjust2; + private System.Windows.Forms.Button buttonAdjustSecBack2; + private System.Windows.Forms.CheckBox checkBoxSyncListViewWithVideoWhilePlaying; + private System.Windows.Forms.Label labelAdjustF10; + private System.Windows.Forms.Label labelAdjustF9; + private System.Windows.Forms.Label labelAdjustF11; + private System.Windows.Forms.Label labelAdjustF12; + private System.Windows.Forms.Label labelCreateF12; + private System.Windows.Forms.Label labelCreateF11; + private System.Windows.Forms.Label labelCreateF10; + private System.Windows.Forms.Label labelCreateF9; + private System.Windows.Forms.ToolStripMenuItem translatepoweredByMicrosoftToolStripMenuItem; + private System.Windows.Forms.ToolStripButton toolStripButtonToggleWaveform; + private Controls.VideoPlayerContainer mediaPlayer; + private System.Windows.Forms.Panel panelVideoPlayer; + private Controls.AudioVisualizer audioVisualizer; + private System.Windows.Forms.Timer timerWaveform; + private System.Windows.Forms.ContextMenuStrip contextMenuStripWaveform; + private System.Windows.Forms.ToolStripMenuItem addParagraphHereToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem deleteParagraphToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem splitToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem mergeWithPreviousToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mergeWithNextToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemWaveformPlaySelection; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator11; + private System.Windows.Forms.Panel panelWaveformControls; + private System.Windows.Forms.ToolStrip toolStripWaveControls; + private System.Windows.Forms.ToolStripButton toolStripButtonWaveformZoomIn; + private System.Windows.Forms.ToolStripComboBox toolStripComboBoxWaveform; + private System.Windows.Forms.ToolStripButton toolStripButtonWaveformZoomOut; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator16; + private System.Windows.Forms.ToolStripButton toolStripButtonWaveformPause; + private System.Windows.Forms.ToolStripButton toolStripButtonWaveformPlay; + private System.Windows.Forms.TrackBar trackBarWaveformPosition; + private System.Windows.Forms.Label labelVideoInfo; + private System.Windows.Forms.ToolStripMenuItem showhideWaveformToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportBluRaySup; + private System.Windows.Forms.Label labelCharactersPerSecond; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemNetworking; + private System.Windows.Forms.ToolStripMenuItem startServerToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem joinSessionToolStripMenuItem; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusNetworking; + private System.Windows.Forms.ToolStripMenuItem leaveSessionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem showSessionKeyLogToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem chatToolStripMenuItem; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.SplitContainer splitContainerMain; + private System.Windows.Forms.ToolStripMenuItem undockVideoControlsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem redockVideoControlsToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator19; + private System.Windows.Forms.ToolStripButton toolStripButtonLockCenter; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertSubtitle; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAutoSplitLongLines; + private System.Windows.Forms.ContextMenuStrip contextMenuStripEmpty; + private System.Windows.Forms.ToolStripMenuItem insertLineToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem closeVideoToolStripMenuItem; + private System.Windows.Forms.Label labelSingleLine; + private System.Windows.Forms.Label labelAlternateText; + private System.Windows.Forms.Label labelAlternateCharactersPerSecond; + private System.Windows.Forms.Label labelTextAlternateLineTotal; + private System.Windows.Forms.Label labelAlternateSingleLine; + private System.Windows.Forms.Label labelTextAlternateLineLengths; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator20; + private System.Windows.Forms.ToolStripMenuItem saveOriginalToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveOriginalAstoolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem openOriginalToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeOriginalToolStripMenuItem; + private System.Windows.Forms.ToolStripSplitButton toolStripSplitButtonPlayRate; + private System.Windows.Forms.ImageList imageListPlayRate; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSetAudioTrack; + private System.Windows.Forms.Button buttonSplitLine; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemChangeFrameRate2; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemCopySourceText; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator21; + private System.Windows.Forms.ToolStripMenuItem editSelectAllToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip contextMenuStripTextBoxListView; + private System.Windows.Forms.ToolStripMenuItem cutToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSplitTextAtCursor; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator18; + private System.Windows.Forms.ToolStripMenuItem selectAllToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator17; + private System.Windows.Forms.ToolStripMenuItem normalToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem boldToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem italicToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem underlineToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem colorToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem fontNameToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator22; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExport; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportPngXml; + private System.Windows.Forms.ToolStripMenuItem pointSyncViaOtherSubtitleToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemGoogleMicrosoftTranslateSelLine; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator23; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMakeEmptyFromCurrent; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator24; + private System.Windows.Forms.ToolStripMenuItem showWaveformAndSpectrogramToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem showOnlyWaveformToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem showOnlySpectrogramToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator26; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertUnicodeSymbol; + private System.Windows.Forms.ToolStripMenuItem setStylesForSelectedLinesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem FindDoubleLinesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem eBUSTLToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem pACScreenElectronicsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemCavena890; + private Controls.SETextBox textBoxListViewTextAlternate; + private System.Windows.Forms.ToolStripMenuItem textCharssecToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem plainTextToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem bluraySupToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem vobSubsubidxToolStripMenuItem; + private System.Windows.Forms.Timer timerTextUndo; + private System.Windows.Forms.Timer timerAlternateTextUndo; + private System.Windows.Forms.ToolStripMenuItem adobeEncoreFABImageScriptToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMergeDialog; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSurroundWithMusicSymbols; + private System.Windows.Forms.ToolStripMenuItem superscriptToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem subscriptToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImagePerFrame; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemApplyDurationLimits; + private System.Windows.Forms.ToolStripMenuItem generateDatetimeInfoFromVideoToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator25; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRightToLeftMode; + private System.Windows.Forms.ToolStripMenuItem joinSubtitlesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemReverseRightToLeftStartEnd; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportCapMakerPlus; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportCheetahCap; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportCaptionInc; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportUltech130; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAssStyles; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSubStationAlpha; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAlignment; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRestoreAutoBackup; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemStatistics; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDCinemaProperties; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTextTimeCodePair; + private System.Windows.Forms.ToolStripMenuItem textWordsPerMinutewpmToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTTProperties; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSaveSelectedLines; + private System.Windows.Forms.Button buttonCustomUrl2; + private System.Windows.Forms.ToolStripMenuItem addParagraphAndPasteToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorGuessTimeCodes; + private System.Windows.Forms.ToolStripMenuItem guessTimeCodesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem DvdStudioProStl; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemUndo; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRedo; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemShowOriginalInPreview; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemPlugins; + private System.Windows.Forms.ToolStripMenuItem seekSilenceToolStripMenuItem; + private System.Windows.Forms.SplitContainer splitContainerListViewAndText; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemColumn; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemColumnDeleteText; + private System.Windows.Forms.ToolStripMenuItem ShiftTextCellsDownToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemPasteSpecial; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemColumnImportText; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertTextFromSub; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemOpenKeepVideo; + private System.Windows.Forms.ToolStripMenuItem changeSpeedInPercentToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAvidStl; + private System.Windows.Forms.ToolStripMenuItem columnDeleteTextOnlyToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemBatchConvert; + private System.Windows.Forms.ToolStripMenuItem copyOriginalTextToCurrentToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMergeDuplicateText; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSpumux; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemWebVTT; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemWebVttVoice; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemPreview; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorWebVTT; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemModifySelection; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSpellCheckFromCurrentLine; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportXSub; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportOcrHardSub; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportFcpIImage; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemNuendoProperties; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDost; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMeasurementConverter; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportChapters; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportSceneChanges; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRemoveSceneChanges; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSubtitlesBridgeGaps; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemOpenDvd; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemFcpProperties; + private System.Windows.Forms.ToolStripMenuItem styleToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemFocusTextbox; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorAscOrDesc; + private System.Windows.Forms.ToolStripMenuItem AscendingToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem descendingToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorExportCustomText; + private System.Windows.Forms.ToolStripMenuItem exportCustomTextFormatToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSetLanguage; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertUnicodeControlCharacters; + private System.Windows.Forms.ToolStripMenuItem leftToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem righttoleftMarkToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem startOfLefttorightEmbeddingLREToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem startOfRighttoleftEmbeddingRLEToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem startOfLefttorightOverrideLROToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem startOfRighttoleftOverrideRLOToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRtlUnicodeControlChars; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRemoveUnicodeControlChars; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportImages; + private System.Windows.Forms.ToolStripButton toolStripButtonRemoveTextForHi; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportDcinemaInterop; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMergeLinesWithSameTimeCodes; + private System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItemSplitterCheckForUpdates; + private System.Windows.Forms.ToolStripMenuItem setVideoOffsetToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDvdStudioProProperties; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemEdlClipName; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAddWaveformBatch; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportBdTextSt; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelProgress; + private System.Windows.Forms.ToolStripMenuItem uniPacExportToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportAyato; + private System.Windows.Forms.ToolStripButton toolStripButtonFixCommonErrors; + private System.Windows.Forms.ToolStripMenuItem removeSceneChangeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem addSceneChangeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem netflixQualityCheckToolStripMenuItem; + private System.Windows.Forms.ToolStripButton toolStripButtonNetflixQualityCheck; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemEdl; + private System.Windows.Forms.ToolStripMenuItem setActorForSelectedLinesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSetRegion; + private System.Windows.Forms.ToolStripMenuItem insertSubtitleHereToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem actorToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemFcpXmlAdvanced; + private System.Windows.Forms.Label labelNextWord; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemOpenVideoFromUrl; + private System.Windows.Forms.ToolStripMenuItem smpteTimeModedropFrameToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem moveTextUpToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem moveTextDownToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem generateTextFromCurrentVideoToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSplitViaWaveform; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemEbuProperties; + private System.Windows.Forms.ToolStripMenuItem boxToolStripMenuItem; + private System.Windows.Forms.ImageList imageListBookmarks; + private System.Windows.Forms.Panel panelBookmark; + private System.Windows.Forms.Label labelBookmark; + private System.Windows.Forms.PictureBox pictureBoxBookmark; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTranslateSelected; + private System.Windows.Forms.ToolStripMenuItem googleTranslateToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem microsoftBingTranslateToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemBookmark; + private System.Windows.Forms.ToolStripMenuItem removeAllFormattingsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeBoldToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeItalicToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeUnderlineToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeColorToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeFontNameToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeAlignmentToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemBouten; + private System.Windows.Forms.ToolStripMenuItem boutendotbeforeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem boutendotafterToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem boutendotoutsideToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem boutenfilledcircleoutsideToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem boutenopencircleoutsideToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem boutenopendotoutsideToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem boutenfilledsesameoutsideToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem boutenopensesameoutsideToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem boutenautooutsideToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem boutenautoToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemHorizontalDigits; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSetParagraphAsSelection; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRuby; + private System.Windows.Forms.Label labelSingleLinePixels; + private System.Windows.Forms.Label labelAlternateSingleLinePixels; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; + private System.Windows.Forms.ToolStripMenuItem extendBeforeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem extendAfterToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem extendToPreviousToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem extendToNextToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator6; + private System.Windows.Forms.ToolStripMenuItem goToPreviousSubtitleStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem goToNextSubtitleStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem dCinemaSMPTE2014ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem boxToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAssaStyles; + private System.Windows.Forms.ToolStripMenuItem openSecondSubtitleToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem aSSStylesToolStripMenuItem; + } } \ No newline at end of file diff --git a/src/Forms/Main.cs b/src/ui/Forms/Main.cs similarity index 97% rename from src/Forms/Main.cs rename to src/ui/Forms/Main.cs index 1edcc0bd7..0b578f3b6 100644 --- a/src/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -1,28846 +1,28846 @@ -using Nikse.SubtitleEdit.Controls; -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.BluRaySup; -using Nikse.SubtitleEdit.Core.ContainerFormats; -using Nikse.SubtitleEdit.Core.ContainerFormats.MaterialExchangeFormat; -using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; -using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4; -using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4.Boxes; -using Nikse.SubtitleEdit.Core.ContainerFormats.TransportStream; -using Nikse.SubtitleEdit.Core.Enums; -using Nikse.SubtitleEdit.Core.Forms; -using Nikse.SubtitleEdit.Core.NetflixQualityCheck; -using Nikse.SubtitleEdit.Core.SpellCheck; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Core.VobSub; -using Nikse.SubtitleEdit.Forms.Networking; -using Nikse.SubtitleEdit.Forms.Ocr; -using Nikse.SubtitleEdit.Forms.Styles; -using Nikse.SubtitleEdit.Logic; -using Nikse.SubtitleEdit.Logic.CommandLineConvert; -using Nikse.SubtitleEdit.Logic.Networking; -using Nikse.SubtitleEdit.Logic.VideoPlayers; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Text; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - - public sealed partial class Main : Form - { - private class ComboBoxZoomItem - { - public string Text { get; set; } - public double ZoomFactor { get; set; } - - public override string ToString() - { - return Text; - } - } - - private const int TabControlListView = 0; - private const int TabControlSourceView = 1; - - private Subtitle _subtitle = new Subtitle(); - - private int _undoIndex = -1; - private string _listViewTextUndoLast; - private int _listViewTextUndoIndex = -1; - private long _listViewTextTicks = -1; - private string _listViewAlternateTextUndoLast; - private long _listViewAlternateTextTicks = -1; - - private Subtitle _subtitleAlternate = new Subtitle(); - private string _subtitleAlternateFileName; - private string _fileName; - - private int _videoAudioTrackNumber = -1; - public int VideoAudioTrackNumber - { - get => _videoAudioTrackNumber; - set - { - if (_videoAudioTrackNumber != value) - { - if (value >= 0 && _videoAudioTrackNumber != -1) - { - ReloadWaveform(VideoFileName, value); - } - _videoAudioTrackNumber = value; - } - } - } - - public string VideoFileName { get; set; } - - private DateTime _fileDateTime; - private string _title; - private FindReplaceDialogHelper _findHelper; - private int _replaceStartLineIndex; - private bool _sourceViewChange; - private int _changeSubtitleHash = -1; - private int _changeAlternateSubtitleHash = -1; - private int _subtitleListViewIndex = -1; - private Paragraph _oldSelectedParagraph; - private bool _converted; - private SubtitleFormat _oldSubtitleFormat; - private List _selectedIndices; - private LanguageStructure.Main _language; - private LanguageStructure.General _languageGeneral; - private SpellCheck _spellCheckForm; - private bool _loading = true; - private bool _exitWhenLoaded; - private int _repeatCount = -1; - private double _endSeconds = -1; - private double _endSecondsNewPosition = -1; - private long _endSecondsNewPositionTicks; - private const double EndDelay = 0.05; - private int _autoContinueDelayCount = -1; - private long _lastTextKeyDownTicks; - private long _lastHistoryTicks; - private long _lastWaveformMenuCloseTicks; - private double? _audioWaveformRightClickSeconds; - private readonly Timer _timerDoSyntaxColoring = new Timer(); - private Timer _timerAutoBackup; - private readonly Timer _timerClearStatus = new Timer(); - private string _textAutoBackup; - private string _textAutoBackupOriginal; - private readonly List _statusLog = new List(); - private bool _disableShowStatus; - private StatusLog _statusLogForm; - private bool _makeHistoryPaused; - private bool _saveAsCalled; - - private CheckForUpdatesHelper _checkForUpdatesHelper; - private Timer _timerCheckForUpdates; - - private NikseWebServiceSession _networkSession; - private NetworkChat _networkChat; - - private ShowEarlierLater _showEarlierOrLater; - private MeasurementConverter _measurementConverter; - - private bool _isVideoControlsUndocked; - private VideoPlayerUndocked _videoPlayerUndocked; - private WaveformUndocked _waveformUndocked; - private VideoControlsUndocked _videoControlsUndocked; - - private GoogleOrMicrosoftTranslate _googleOrMicrosoftTranslate; - - private bool _cancelWordSpellCheck = true; - private bool _cleanupHasRun; - - private bool _clearLastFind; - private FindType _clearLastFindType = FindType.Normal; - private string _clearLastFindText = string.Empty; - private bool _videoLoadedGoToSubPosAndPause; - private string _cutText = string.Empty; - private Paragraph _mainCreateStartDownEndUpParagraph; - private Paragraph _mainAdjustStartDownEndUpAndGoToNextParagraph; - private int _lastDoNotPrompt = -1; - private VideoInfo _videoInfo; - private bool _splitDualSami; - private bool _openFileDialogOn; - private bool _resetVideo = true; - private bool _doAutoBreakOnTextChanged = true; - private readonly static object _syncUndo = new object(); - private string[] _dragAndDropFiles; - private readonly Timer _dragAndDropTimer = new Timer(); // to prevent locking windows explorer - private readonly Timer _dragAndDropVideoTimer = new Timer(); // to prevent locking windows explorer - private long _labelNextTicks = -1; - private bool _showBookmarkLabel = true; - private ContextMenu _bookmarkContextMenu; - private readonly MainShortcuts _shortcuts = new MainShortcuts(); - private long _winLeftDownTicks = -1; - private long _winRightDownTicks = -1; - - public bool IsMenuOpen { get; private set; } - - private bool AutoRepeatContinueOn - { - get { return tabControlButtons.SelectedIndex == 0 && checkBoxAutoContinue.Checked; } - } - - private bool AutoRepeatOn - { - get { return tabControlButtons.SelectedIndex == 0 && checkBoxAutoRepeatOn.Checked; } - } - - public string Title - { - get - { - if (_title == null) - { - var versionInfo = Utilities.AssemblyVersion.Split('.'); - _title = $"{_languageGeneral.Title} {versionInfo[0]}.{versionInfo[1]}.{versionInfo[2]}"; - } - - return _title; - } - } - - private void SetCurrentFormat(string formatName) - { - SetCurrentFormat(SubtitleFormat.FromName(formatName, new SubRip())); - } - - private void SetCurrentFormat(SubtitleFormat format) - { - if (format.IsVobSubIndexFile) - { - UiUtil.InitializeSubtitleFormatComboBox(comboBoxSubtitleFormats, format); - SubtitleListview1.HideNonVobSubColumns(); - } - else if (comboBoxSubtitleFormats.Items.Count == 1) - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); - SetFormatTo(format); - } - else - { - int index = 0; - foreach (string name in comboBoxSubtitleFormats.Items) - { - if (name == format.FriendlyName) - { - comboBoxSubtitleFormats.SelectedIndex = index; - return; - } - - index++; - } - } - } - - protected override void OnLoad(EventArgs e) - { - UiUtil.FixFonts(this, 10000); - UiUtil.FixFonts(contextMenuStripListview); - UiUtil.FixFonts(contextMenuStripTextBoxListView); - UiUtil.FixFonts(contextMenuStripWaveform); - UiUtil.FixLargeFonts(tabControlButtons, buttonAutoBreak); - UiUtil.FixLargeFonts(tabControlButtons, buttonAutoBreak); - UiUtil.FixLargeFonts(groupBoxEdit, buttonAutoBreak); - UiUtil.InitializeSubtitleFont(textBoxSource); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - - using (var graphics = CreateGraphics()) - { - // avoid weird looking layout for high DPI - if (graphics.DpiX > 120) - { - Font = new Font(Font.FontFamily, (float)(Font.Size * graphics.DpiX / 96.0)); - - numericUpDownDuration.Left = timeUpDownStartTime.Right + 15; - numericUpDownDuration.Width += 5; - labelDuration.Left = numericUpDownDuration.Left - 3; - } - var xDiff = timeUpDownStartTime.Top - (labelStartTime.Top + labelStartTime.Height); - if (xDiff < 0) // DPI auto-size fixes: see https://github.com/SubtitleEdit/subtitleedit/issues/3981 - { - xDiff *= -1; - timeUpDownStartTime.Top += xDiff; - numericUpDownDuration.Top += xDiff; - pictureBoxBookmark.Top += xDiff; - textBoxListViewText.Top += xDiff; - textBoxListViewText.Height -= xDiff; - textBoxListViewTextAlternate.Top += xDiff; - textBoxListViewTextAlternate.Height -= xDiff; - comboBoxAutoRepeat.Top += xDiff; - comboBoxAutoContinue.Top += xDiff; - } - } - labelAutoDuration.Left = labelDuration.Left - (labelAutoDuration.Width - 5); - - textBoxListViewText.BackColor = !IsSubtitleLoaded ? SystemColors.ActiveBorder : SystemColors.WindowFrame; - textBoxListViewTextAlternate.BackColor = !IsSubtitleLoaded ? SystemColors.ActiveBorder : SystemColors.WindowFrame; - - base.OnLoad(e); - } - - private static string GetArgumentAfterColon(IEnumerable commandLineArguments, string requestedArgumentName) - { - foreach (var argument in commandLineArguments) - { - if (argument.StartsWith(requestedArgumentName, StringComparison.OrdinalIgnoreCase)) - { - if (requestedArgumentName.EndsWith(':')) - { - return argument.Substring(requestedArgumentName.Length); - } - - return argument; - } - } - - return null; - } - - public Main() - { - if (Configuration.IsRunningOnLinux) - { - NativeMethods.setlocale(NativeMethods.LC_NUMERIC, "C"); - } - - try - { - UiUtil.PreInitialize(this); - InitializeComponent(); - - Icon = Properties.Resources.SubtitleEditFormIcon; - - textBoxListViewTextAlternate.Visible = false; - labelAlternateText.Visible = false; - labelAlternateCharactersPerSecond.Visible = false; - labelTextAlternateLineLengths.Visible = false; - labelAlternateSingleLine.Visible = false; - labelAlternateSingleLinePixels.Visible = false; - labelTextAlternateLineTotal.Visible = false; - labelNextWord.Visible = false; - - SetLanguage(Configuration.Settings.General.Language); - toolStripStatusNetworking.Visible = false; - labelTextLineLengths.Text = string.Empty; - labelCharactersPerSecond.Text = string.Empty; - labelTextLineTotal.Text = string.Empty; - labelStartTimeWarning.Text = string.Empty; - labelDurationWarning.Text = string.Empty; - labelVideoInfo.Text = string.Empty; - labelSingleLine.Text = string.Empty; - labelSingleLinePixels.Text = string.Empty; - Text = Title; - timeUpDownStartTime.TimeCode = new TimeCode(); - timeUpDownStartTime.UseVideoOffset = true; - timeUpDownVideoPosition.UseVideoOffset = true; - timeUpDownVideoPositionAdjust.UseVideoOffset = true; - checkBoxAutoRepeatOn.Checked = Configuration.Settings.General.AutoRepeatOn; - comboBoxAutoRepeat.SelectedIndex = Configuration.Settings.General.AutoRepeatCount; - checkBoxAutoContinue.Checked = Configuration.Settings.General.AutoContinueOn; - checkBoxSyncListViewWithVideoWhilePlaying.Checked = Configuration.Settings.General.SyncListViewWithVideoWhilePlaying; - - SetFormatTo(Configuration.Settings.General.DefaultSubtitleFormat); - - UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding.ComboBox); - - // set up UI interfaces / injections - YouTubeAnnotations.GetYouTubeAnnotationStyles = new UiGetYouTubeAnnotationStyles(); - Ebu.EbuUiHelper = new UiEbuSaveHelper(); - Pac.GetPacEncodingImplementation = new UiGetPacEncoding(this); - RichTextToPlainText.NativeRtfTextConverter = new RtfTextConverterRichTextBox(); - - toolStripComboBoxFrameRate.Items.Add(23.976.ToString(CultureInfo.CurrentCulture)); - toolStripComboBoxFrameRate.Items.Add(24.0.ToString(CultureInfo.CurrentCulture)); - toolStripComboBoxFrameRate.Items.Add(25.0.ToString(CultureInfo.CurrentCulture)); - toolStripComboBoxFrameRate.Items.Add(29.97.ToString(CultureInfo.CurrentCulture)); - toolStripComboBoxFrameRate.Items.Add(30.ToString(CultureInfo.CurrentCulture)); - toolStripComboBoxFrameRate.Text = Configuration.Settings.General.DefaultFrameRate.ToString(); - pictureBoxBookmark.Visible = false; - - UpdateRecentFilesUI(); - InitializeToolbar(); - UpdateNetflixGlyphCheckToolsVisibility(); - Utilities.SetSecurityProtocol(); // download from Github requires TLS 1.2 - - tabControlSubtitle.SelectTab(TabControlSourceView); // AC - ShowSourceLineNumber(); // AC - tabControlSubtitle.SelectTab(TabControlListView); // AC - if (Configuration.Settings.General.StartInSourceView) - { - tabControlSubtitle.SelectTab(TabControlSourceView); - } - - audioVisualizer.Visible = Configuration.Settings.General.ShowAudioVisualizer; - audioVisualizer.ShowWaveform = Configuration.Settings.General.ShowWaveform; - audioVisualizer.ShowSpectrogram = Configuration.Settings.General.ShowSpectrogram; - panelWaveformControls.Visible = Configuration.Settings.General.ShowAudioVisualizer; - trackBarWaveformPosition.Visible = Configuration.Settings.General.ShowAudioVisualizer; - toolStripButtonToggleWaveform.Checked = Configuration.Settings.General.ShowAudioVisualizer; - toolStripButtonToggleVideo.Checked = Configuration.Settings.General.ShowVideoPlayer; - - if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) - { - numericUpDownDuration.DecimalPlaces = 2; - numericUpDownDuration.Increment = (decimal)(0.01); - toolStripSeparatorFrameRate.Visible = true; - toolStripLabelFrameRate.Visible = true; - toolStripComboBoxFrameRate.Visible = true; - toolStripButtonGetFrameRate.Visible = true; - } - - _timerClearStatus.Interval = Configuration.Settings.General.ClearStatusBarAfterSeconds * 1000; - _timerClearStatus.Tick += TimerClearStatus_Tick; - - var commandLineArgs = Environment.GetCommandLineArgs(); - var fileName = string.Empty; - int srcLineNumber = -1; - if (commandLineArgs.Length > 1) - { - // ConvertOrReturn() shall not return if a command line conversion has been requested - CommandLineConverter.ConvertOrReturn(Title, commandLineArgs); - - fileName = commandLineArgs[1]; - - if (fileName.Equals("/batchconvertui", StringComparison.OrdinalIgnoreCase) || fileName.Equals("-batchconvertui", StringComparison.OrdinalIgnoreCase)) - { - new BatchConvert(this.Icon).ShowDialog(); - Environment.Exit(0); - } - - var sourceLineString = GetArgumentAfterColon(commandLineArgs, "/srcline:"); - if (!int.TryParse(sourceLineString, out srcLineNumber)) - { - srcLineNumber = -1; - } - - VideoFileName = GetArgumentAfterColon(commandLineArgs, "/video:"); - } - - labelAutoDuration.Visible = false; - mediaPlayer.SubtitleText = string.Empty; - comboBoxAutoContinue.SelectedIndex = Configuration.Settings.General.AutoContinueDelay; - - timeUpDownVideoPosition.TimeCode = new TimeCode(); - timeUpDownVideoPositionAdjust.TimeCode = new TimeCode(); - timeUpDownVideoPosition.TimeCodeChanged += VideoPositionChanged; - timeUpDownVideoPositionAdjust.TimeCodeChanged += VideoPositionChanged; - timeUpDownVideoPosition.Enabled = false; - timeUpDownVideoPositionAdjust.Enabled = false; - - switch (Configuration.Settings.VideoControls.LastActiveTab) - { - case "Translate": - tabControlButtons.SelectedIndex = 0; - break; - case "Create": - tabControlButtons.SelectedIndex = 1; - break; - case "Adjust": - tabControlButtons.SelectedIndex = 2; - break; - } - - tabControl1_SelectedIndexChanged(null, null); - buttonCustomUrl1.Text = Configuration.Settings.VideoControls.CustomSearchText1; - buttonCustomUrl1.Visible = Configuration.Settings.VideoControls.CustomSearchUrl1.Length > 1; - buttonCustomUrl2.Text = Configuration.Settings.VideoControls.CustomSearchText2; - buttonCustomUrl2.Visible = Configuration.Settings.VideoControls.CustomSearchUrl2.Length > 1; - - CheckAndGetNewlyDownloadedMpvDlls(string.Empty); - - if (fileName.Length > 0 && File.Exists(fileName)) - { - fileName = Path.GetFullPath(fileName); - - if (srcLineNumber < 0) - { - if (!OpenFromRecentFiles(fileName)) - { - OpenSubtitle(fileName, null, VideoFileName, null, true); - } - } - else - { - OpenSubtitle(fileName, null, VideoFileName, null, true); - } - - if (srcLineNumber >= 0 && GetCurrentSubtitleFormat().GetType() == typeof(SubRip) && srcLineNumber < textBoxSource.Lines.Length) - { - int pos = 0; - for (int i = 0; i < srcLineNumber; i++) - { - pos += textBoxSource.Lines[i].Length; - } - - if (pos + 35 < textBoxSource.TextLength) - { - pos += 35; - } - - string s = textBoxSource.Text.Substring(0, pos); - int lastTimeCode = s.LastIndexOf(" --> ", StringComparison.Ordinal); // 00:02:26,407 --> 00:02:31,356 - if (lastTimeCode > 14 && lastTimeCode + 16 >= s.Length) - { - s = s.Substring(0, lastTimeCode - 5); - lastTimeCode = s.LastIndexOf(" --> ", StringComparison.Ordinal); - } - - if (lastTimeCode > 14 && lastTimeCode + 16 < s.Length) - { - string tc = s.Substring(lastTimeCode - 13, 30).Trim(); - int index = 0; - foreach (var p in _subtitle.Paragraphs) - { - if (tc == p.StartTime + " --> " + p.EndTime) - { - SubtitleListview1.SelectNone(); - SubtitleListview1.Items[0].Selected = false; - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - break; - } - - index++; - } - } - } - } - else if (Configuration.Settings.General.StartLoadLastFile && Configuration.Settings.RecentFiles.Files.Count > 0) - { - fileName = Configuration.Settings.RecentFiles.Files[0].FileName; - if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName) && !OpenFromRecentFiles(fileName)) - { - OpenSubtitle(fileName, null); - } - } - - // Initialize events etc. for audio waveform - audioVisualizer.OnDoubleClickNonParagraph += AudioWaveform_OnDoubleClickNonParagraph; - audioVisualizer.OnPositionSelected += AudioWaveform_OnPositionSelected; - audioVisualizer.OnTimeChanged += AudioWaveform_OnTimeChanged; // start and/or end position of paragraph changed - audioVisualizer.OnNewSelectionRightClicked += AudioWaveform_OnNewSelectionRightClicked; - audioVisualizer.OnParagraphRightClicked += AudioWaveform_OnParagraphRightClicked; - audioVisualizer.OnNonParagraphRightClicked += AudioWaveform_OnNonParagraphRightClicked; - audioVisualizer.OnSingleClick += AudioWaveform_OnSingleClick; - audioVisualizer.OnPause += AudioWaveform_OnPause; - audioVisualizer.OnTimeChangedAndOffsetRest += AudioWaveform_OnTimeChangedAndOffsetRest; - audioVisualizer.OnZoomedChanged += AudioWaveform_OnZoomedChanged; - audioVisualizer.InsertAtVideoPosition += audioVisualizer_InsertAtVideoPosition; - audioVisualizer.PasteAtVideoPosition += audioVisualizer_PasteAtVideoPosition; - audioVisualizer.KeyDown += AudioVisualizer_KeyDown; - SetAudioVisualizerSettings(); - if (Configuration.Settings.General.WaveformUpdateIntervalMs > 0 && Configuration.Settings.General.WaveformUpdateIntervalMs < 200) - { - timerWaveform.Interval = Configuration.Settings.General.WaveformUpdateIntervalMs; - } - - InitializeWaveformZoomDropdown(); - toolStripComboBoxWaveform.SelectedIndexChanged += toolStripComboBoxWaveform_SelectedIndexChanged; - - FixLargeFonts(); - - if (Configuration.Settings.General.RightToLeftMode) - { - ToolStripMenuItemRightToLeftModeClick(null, null); - } - - timeUpDownStartTime.SetAutoWidth(); - numericUpDownDuration.Left = timeUpDownStartTime.Right + 4; - labelDurationWarning.Left = numericUpDownDuration.Left; - labelDuration.Left = labelDurationWarning.Left; - - timeUpDownVideoPosition.SetAutoWidth(); - timeUpDownVideoPositionAdjust.SetAutoWidth(); - } - catch (Exception exception) - { - Cursor = Cursors.Default; - MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace); - SeLogger.Error(exception, "Main constructor"); - } - } - - private void AudioVisualizer_KeyDown(object sender, KeyEventArgs e) - { - if (SubtitleListview1.SelectedIndices.Count != 1 || e.Handled) - { - return; - } - - if (e.KeyData == italicToolStripMenuItem.ShortcutKeys) - { - ListViewToggleTag(HtmlUtil.TagItalic); - e.SuppressKeyPress = true; - } - else if (e.KeyData == boldToolStripMenuItem.ShortcutKeys) - { - ListViewToggleTag(HtmlUtil.TagBold); - e.SuppressKeyPress = true; - } - else if (e.KeyData == underlineToolStripMenuItem.ShortcutKeys) - { - ListViewToggleTag(HtmlUtil.TagUnderline); - e.SuppressKeyPress = true; - } - - else if (e.KeyData == removeAllFormattingsToolStripMenuItem.ShortcutKeys) - { - removeAllFormattingsToolStripMenuItem_Click(null, null); - e.SuppressKeyPress = true; - } - - else if (e.KeyData == _shortcuts.MainListViewAlignmentN1) - { - SetAlignment("{\\an1}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN2) - { - SetAlignment("", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN3) - { - SetAlignment("{\\an3}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN4) - { - SetAlignment("{\\an4}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN5) - { - SetAlignment("{\\an5}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN6) - { - SetAlignment("{\\an6}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN7) - { - SetAlignment("{\\an7}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN8) - { - SetAlignment("{\\an8}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN9) - { - SetAlignment("{\\an9}", false); - e.SuppressKeyPress = true; - } - } - - private void InitializeWaveformZoomDropdown() - { - toolStripComboBoxWaveform.Items.Clear(); - for (double zoomCounter = AudioVisualizer.ZoomMinimum; zoomCounter <= AudioVisualizer.ZoomMaximum + (0.001); zoomCounter += 0.1) - { - int percent = (int)Math.Round(zoomCounter * 100); - var item = new ComboBoxZoomItem { Text = percent + "%", ZoomFactor = zoomCounter }; - toolStripComboBoxWaveform.Items.Add(item); - if (percent == 100) - { - toolStripComboBoxWaveform.SelectedIndex = toolStripComboBoxWaveform.Items.Count - 1; - } - } - } - - private void audioVisualizer_InsertAtVideoPosition(object sender, EventArgs e) - { - InsertNewTextAtVideoPosition(); - } - - private void audioVisualizer_PasteAtVideoPosition(object sender, EventArgs e) - { - double videoPositionInMilliseconds = mediaPlayer.CurrentPosition * TimeCode.BaseUnit; - if (_subtitle.GetFirstParagraphOrDefaultByTime(videoPositionInMilliseconds) == null) - { - PastFromClipboard(videoPositionInMilliseconds); - } - } - - private void PastFromClipboard(double videoPositionInMilliseconds) - { - if (Clipboard.ContainsText()) - { - var text = Clipboard.GetText(); - var tmp = new Subtitle(); - var format = new SubRip(); - var list = new List(text.SplitToLines()); - format.LoadSubtitle(tmp, list, null); - if (videoPositionInMilliseconds >= 0 && tmp.Paragraphs.Count > 0) - { - if (tmp.Paragraphs[0].StartTime.TotalMilliseconds > videoPositionInMilliseconds) - { - var c = tmp.Paragraphs[0].StartTime.TotalMilliseconds - videoPositionInMilliseconds; - tmp.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-c)); - } - else - { - var c = videoPositionInMilliseconds - tmp.Paragraphs[0].StartTime.TotalMilliseconds; - tmp.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(c)); - } - } - else - { - var start = videoPositionInMilliseconds; - foreach (var line in list) - { - if (!string.IsNullOrWhiteSpace(line)) - { - var duration = Utilities.GetOptimalDisplayMilliseconds(line); - tmp.Paragraphs.Add(new Paragraph(line.Trim(), start, start + duration)); - start += duration + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - - if (tmp.Paragraphs.Count > 0) - { - MakeHistoryForUndo(_language.BeforeInsertLine); - var selectIndices = new List(); - for (int i = 0; i < tmp.Paragraphs.Count; i++) - { - var p = tmp.Paragraphs[i]; - var idx = _subtitle.InsertParagraphInCorrectTimeOrder(p); - selectIndices.Add(idx); - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) - { - var original = Utilities.GetOriginalParagraph(idx + i + 1, p, _subtitleAlternate.Paragraphs); - if (original == null) - { - _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds)); - } - } - } - - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(selectIndices[0], true); - foreach (var selectIndex in selectIndices) - { - SubtitleListview1.Items[selectIndex].Selected = true; - } - - if (_subtitleListViewIndex >= 0) - { - UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, _subtitle.Paragraphs[_subtitleListViewIndex], textBoxListViewText); - } - else - { - SubtitleListview1.SelectIndexAndEnsureVisible(0); - } - } - } - } - - private void TimerClearStatus_Tick(object sender, EventArgs e) - { - ShowStatus(string.Empty); - } - - private void SetEncoding(Encoding encoding) - { - if (encoding == Encoding.UTF8 && Configuration.Settings.General.DefaultEncoding == TextEncoding.Utf8WithoutBom) - { - comboBoxEncoding.SelectedIndex = TextEncoding.Utf8WithoutBomIndex; - } - - foreach (TextEncoding item in comboBoxEncoding.Items) - { - if (item.Equals(encoding)) - { - comboBoxEncoding.SelectedItem = item; - return; - } - } - - comboBoxEncoding.SelectedIndex = TextEncoding.Utf8WithBomIndex; // UTF-8 with BOM - } - - private void SetEncoding(string encodingName) - { - UiUtil.SetTextEncoding(comboBoxEncoding, encodingName); - } - - private Encoding GetCurrentEncoding() - { - return UiUtil.GetTextEncodingComboBoxCurrentEncoding(comboBoxEncoding.ComboBox).Encoding; - } - - private void AudioWaveform_OnNonParagraphRightClicked(object sender, AudioVisualizer.ParagraphEventArgs e) - { - addParagraphHereToolStripMenuItem.Visible = false; - addParagraphAndPasteToolStripMenuItem.Visible = false; - toolStripMenuItemSetParagraphAsSelection.Visible = false; - deleteParagraphToolStripMenuItem.Visible = false; - toolStripMenuItemFocusTextbox.Visible = true; - splitToolStripMenuItem1.Visible = false; - mergeWithPreviousToolStripMenuItem.Visible = false; - mergeWithNextToolStripMenuItem.Visible = false; - toolStripSeparator11.Visible = false; - extendToPreviousToolStripMenuItem.Visible = false; - extendToNextToolStripMenuItem.Visible = false; - toolStripSeparator6.Visible = false; - toolStripMenuItemWaveformPlaySelection.Visible = false; - toolStripSeparator24.Visible = false; - if (audioVisualizer.GetSceneChangeIndex(e.Seconds) >= 0) - { - removeSceneChangeToolStripMenuItem.Visible = true; - addSceneChangeToolStripMenuItem.Visible = false; - } - else - { - removeSceneChangeToolStripMenuItem.Visible = false; - addSceneChangeToolStripMenuItem.Visible = true; - } - - _audioWaveformRightClickSeconds = e.Seconds; - contextMenuStripWaveform.Show(MousePosition.X, MousePosition.Y); - } - - private void AudioWaveform_OnDoubleClickNonParagraph(object sender, AudioVisualizer.ParagraphEventArgs e) - { - if (mediaPlayer.VideoPlayer != null) - { - _endSeconds = -1; - if (e.Paragraph == null) - { - if (Configuration.Settings.VideoControls.WaveformDoubleClickOnNonParagraphAction == "PlayPause") - { - mediaPlayer.TogglePlayPause(); - } - } - else - { - var index = _subtitle.GetIndex(e.Paragraph); - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - var p = _subtitle.GetParagraphOrDefault(index); - if (p != null) - { - string tc = p.StartTime + " --> " + p.EndTime; - int start = textBoxSource.Text.IndexOf(p.Number + Environment.NewLine + tc, StringComparison.Ordinal); - if (start < 0) - { - start = 0; - } - - start = textBoxSource.Text.IndexOf(tc, start, StringComparison.Ordinal); - if (start > 0) - { - textBoxSource.SelectionStart = start + tc.Length + Environment.NewLine.Length; - textBoxSource.SelectionLength = 0; - textBoxSource.ScrollToCaret(); - } - } - } - } - } - } - - private void AudioWaveform_OnZoomedChanged(object sender, EventArgs e) - { - SelectZoomTextInComboBox(); - } - - private void AudioWaveform_OnTimeChangedAndOffsetRest(object sender, AudioVisualizer.ParagraphEventArgs e) - { - if (mediaPlayer.VideoPlayer == null) - { - return; - } - - int index = _subtitle.Paragraphs.IndexOf(e.Paragraph); - if (index < 0) - { - if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable) - { - index = _subtitleAlternate.GetIndex(e.Paragraph); - if (index >= 0) - { - var current = Utilities.GetOriginalParagraph(index, e.Paragraph, _subtitle.Paragraphs); - if (current != null) - { - index = _subtitle.Paragraphs.IndexOf(current); - } - } - } - else if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible) - { - index = _subtitle.GetIndex(e.Paragraph); - } - } - - if (index >= 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - mediaPlayer.CurrentPosition = e.Seconds; - SetStartAndOffsetTheRest(e.Seconds); - } - - audioVisualizer.Invalidate(); - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - ShowSource(); - } - } - - private void AudioWaveform_OnPause(object sender, EventArgs e) - { - _endSeconds = -1; - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.Pause(); - } - } - - private void AudioWaveform_OnSingleClick(object sender, AudioVisualizer.ParagraphEventArgs e) - { - timerWaveform.Stop(); - _endSeconds = -1; - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.Pause(); - } - - mediaPlayer.CurrentPosition = e.Seconds; - - int index = -1; - if (SubtitleListview1.SelectedItems.Count > 0) - { - index = SubtitleListview1.SelectedItems[0].Index; - } - - SetWaveformPosition(audioVisualizer.StartPositionSeconds, e.Seconds, index); - - if (Configuration.Settings.VideoControls.WaveformSingleClickSelect && e.Paragraph != null) - { - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(e.Paragraph), true); - } - - timerWaveform.Start(); - } - - private void AudioWaveform_OnParagraphRightClicked(object sender, AudioVisualizer.ParagraphEventArgs e) - { - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(e.Paragraph), true); - - addParagraphHereToolStripMenuItem.Visible = false; - addParagraphAndPasteToolStripMenuItem.Visible = false; - toolStripMenuItemSetParagraphAsSelection.Visible = false; - deleteParagraphToolStripMenuItem.Visible = true; - toolStripMenuItemFocusTextbox.Visible = true; - splitToolStripMenuItem1.Visible = true; - mergeWithPreviousToolStripMenuItem.Visible = true; - mergeWithNextToolStripMenuItem.Visible = true; - toolStripSeparator11.Visible = true; - extendToPreviousToolStripMenuItem.Visible = true; - extendToNextToolStripMenuItem.Visible = true; - toolStripSeparator6.Visible = true; - toolStripMenuItemWaveformPlaySelection.Visible = true; - toolStripSeparator24.Visible = true; - if (audioVisualizer.GetSceneChangeIndex(e.Seconds) >= 0) - { - removeSceneChangeToolStripMenuItem.Visible = true; - addSceneChangeToolStripMenuItem.Visible = false; - } - else - { - removeSceneChangeToolStripMenuItem.Visible = false; - addSceneChangeToolStripMenuItem.Visible = true; - } - - _audioWaveformRightClickSeconds = e.Seconds; - contextMenuStripWaveform.Show(MousePosition.X, MousePosition.Y); - } - - private void removeSceneChangeToolStripMenuItem_Click(object sender, EventArgs e) - { - if (!_audioWaveformRightClickSeconds.HasValue) - { - return; - } - - var idx = audioVisualizer.GetSceneChangeIndex(_audioWaveformRightClickSeconds.Value); - RemoveSceneChange(idx); - } - - private void RemoveSceneChange(int idx) - { - if (idx >= 0 && idx < audioVisualizer.SceneChanges.Count) - { - var temp = new List(audioVisualizer.SceneChanges); - temp.RemoveAt(idx); - audioVisualizer.SceneChanges = temp; - SceneChangeHelper.SaveSceneChanges(VideoFileName, temp); - } - } - - private void addSceneChangeToolStripMenuItem_Click(object sender, EventArgs e) - { - if (!_audioWaveformRightClickSeconds.HasValue) - { - return; - } - - var list = audioVisualizer.SceneChanges.Where(p => p > 0).ToList(); - list.Add(_audioWaveformRightClickSeconds.Value); - list.Sort(); - audioVisualizer.SceneChanges = list; - SceneChangeHelper.SaveSceneChanges(VideoFileName, list); - } - - private void AudioWaveform_OnNewSelectionRightClicked(object sender, AudioVisualizer.ParagraphEventArgs e) - { - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(e.Paragraph), true); - - addParagraphHereToolStripMenuItem.Visible = true; - addParagraphAndPasteToolStripMenuItem.Visible = Clipboard.ContainsText(); - - if (SubtitleListview1.SelectedIndices.Count == 1) - { - var p = _subtitle.GetParagraphOrDefault(FirstSelectedIndex); - toolStripMenuItemSetParagraphAsSelection.Visible = p.StartTime.IsMaxTime; - } - - deleteParagraphToolStripMenuItem.Visible = false; - toolStripMenuItemFocusTextbox.Visible = false; - splitToolStripMenuItem1.Visible = false; - mergeWithPreviousToolStripMenuItem.Visible = false; - mergeWithNextToolStripMenuItem.Visible = false; - extendToPreviousToolStripMenuItem.Visible = false; - extendToNextToolStripMenuItem.Visible = false; - toolStripSeparator6.Visible = false; - - contextMenuStripWaveform.Show(MousePosition.X, MousePosition.Y); - } - - private void AudioWaveform_OnTimeChanged(object sender, AudioVisualizer.ParagraphEventArgs e) - { - var paragraph = e.Paragraph; - var beforeParagraph = e.BeforeParagraph; - if (beforeParagraph == null) - { - beforeParagraph = paragraph; - } - - if (Math.Abs(beforeParagraph.StartTime.TotalMilliseconds - paragraph.StartTime.TotalMilliseconds) < 0.01 && - Math.Abs(beforeParagraph.EndTime.TotalMilliseconds - paragraph.EndTime.TotalMilliseconds) < 0.01) - { - _makeHistoryPaused = true; - } - - int selectedIndex = FirstSelectedIndex; - int index = _subtitle.Paragraphs.IndexOf(paragraph); - - // TODO: Moving selected lines - // current idx must also be selected - //if (e.MouseDownParagraphType == AudioVisualizer.MouseDownParagraphType.Whole && SubtitleListview1.SelectedIndices.Count > 1) - //{ - // foreach (int idx in SubtitleListview1.SelectedIndices) - // { - // var p = _subtitle.Paragraphs[idx]; - // if (p != paragraph) - // { - // var dur = p.Duration.TotalMilliseconds; - // p.StartTime.TotalMilliseconds += e.AdjustMs; - // p.EndTime.TotalMilliseconds += e.AdjustMs; - // SubtitleListview1.SetStartTimeAndDuration(idx, p); - // } - // } - //} - - if (index == _subtitleListViewIndex) - { - // Make history item for rollback (change paragraph back for history + change again) - _subtitle.Paragraphs[index] = new Paragraph(beforeParagraph); - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + paragraph.Number + " " + paragraph.Text)); - _subtitle.Paragraphs[index] = paragraph; - _makeHistoryPaused = true; - - Paragraph original = null; - if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible) - { - original = Utilities.GetOriginalParagraph(index, beforeParagraph, _subtitleAlternate.Paragraphs); - } - - if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) - { // so we don't get weird rounds we'll use whole frames when moving start time - double fr = TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate; - if (e.BeforeParagraph != null && e.BeforeParagraph.StartTime.TotalMilliseconds != e.Paragraph.StartTime.TotalMilliseconds && - e.BeforeParagraph.Duration.TotalMilliseconds == e.Paragraph.Duration.TotalMilliseconds) - { - // move paragraph - paragraph.StartTime.TotalMilliseconds = ((int)Math.Round(paragraph.StartTime.TotalMilliseconds / fr)) * fr; - paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + e.BeforeParagraph.Duration.TotalMilliseconds; - } - else if (e.BeforeParagraph != null && e.BeforeParagraph.EndTime.TotalMilliseconds == e.Paragraph.EndTime.TotalMilliseconds) - { - paragraph.EndTime.TotalMilliseconds = ((int)Math.Round(paragraph.EndTime.TotalMilliseconds / fr)) * fr; - int end = SubtitleFormat.MillisecondsToFrames(paragraph.EndTime.TotalMilliseconds); - int dur = SubtitleFormat.MillisecondsToFrames(paragraph.Duration.TotalMilliseconds); - paragraph.StartTime.TotalMilliseconds = SubtitleFormat.FramesToMilliseconds(end - dur); - } - } - - timeUpDownStartTime.TimeCode = paragraph.StartTime; - var durationInSeconds = (decimal)paragraph.Duration.TotalSeconds; - if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum) - { - SetDurationInSeconds((double)durationInSeconds); - if (e.MouseDownParagraphType == AudioVisualizer.MouseDownParagraphType.Start) - { - paragraph.EndTime.TotalMilliseconds = e.BeforeParagraph.EndTime.TotalMilliseconds; - } - } - - MovePrevNext(e, beforeParagraph, index); - - if (original != null) - { - original.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; - original.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; - } - } - else if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable) - { - index = _subtitleAlternate.GetIndex(paragraph); - if (index >= 0) - { - // Make history item for rollback (change paragraph back for history + change again) - _subtitleAlternate.Paragraphs[index] = new Paragraph(beforeParagraph); - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + paragraph.Number + " " + paragraph.Text)); - _subtitleAlternate.Paragraphs[index] = paragraph; - _makeHistoryPaused = true; - - var current = Utilities.GetOriginalParagraph(index, beforeParagraph, _subtitle.Paragraphs); - if (current != null) - { - current.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; - current.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; - - index = _subtitle.GetIndex(current); - - SubtitleListview1.SetStartTimeAndDuration(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - - if (index == selectedIndex) - { - timeUpDownStartTime.TimeCode = paragraph.StartTime; - var durationInSeconds = (decimal)(paragraph.Duration.TotalSeconds); - if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum) - { - SetDurationInSeconds((double)durationInSeconds); - } - } - } - } - } - else if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible) - { - index = _subtitle.GetIndex(paragraph); - if (index >= 0) - { - // Make history item for rollback (change paragraph back for history + change again) - _subtitle.Paragraphs[index] = new Paragraph(beforeParagraph); - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + paragraph.Number + " " + paragraph.Text)); - _subtitle.Paragraphs[index] = paragraph; - _makeHistoryPaused = true; - - MovePrevNext(e, beforeParagraph, index); - - var original = Utilities.GetOriginalParagraph(index, beforeParagraph, _subtitleAlternate.Paragraphs); - if (original != null) - { - original.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; - original.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; - } - - SubtitleListview1.SetStartTimeAndDuration(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - } - } - else - { - if (index >= 0) - { - // Make history item for rollback (change paragraph back for history + change again) - _subtitle.Paragraphs[index] = new Paragraph(beforeParagraph); - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + paragraph.Number + " " + paragraph.Text)); - _subtitle.Paragraphs[index] = paragraph; - _makeHistoryPaused = true; - - MovePrevNext(e, beforeParagraph, index); - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, paragraph); - - if (_subtitleAlternate != null) - { - var original = Utilities.GetOriginalParagraph(index, beforeParagraph, _subtitleAlternate.Paragraphs); - if (original != null) - { - original.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; - original.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; - } - } - } - - SubtitleListview1.SetStartTimeAndDuration(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - } - - beforeParagraph.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; - beforeParagraph.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; - _makeHistoryPaused = false; - - if (Configuration.Settings.VideoControls.WaveformSetVideoPositionOnMoveStartEnd && - (e.MouseDownParagraphType == AudioVisualizer.MouseDownParagraphType.Start || - e.MouseDownParagraphType == AudioVisualizer.MouseDownParagraphType.End)) - { - mediaPlayer.CurrentPosition = e.Seconds; - } - - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - ShowSource(); - } - } - - private void MovePrevNext(AudioVisualizer.ParagraphEventArgs e, Paragraph beforeParagraph, int index) - { - int curIdx = FirstSelectedIndex; - if (e.MovePreviousOrNext && curIdx >= 0) - { - if (e.MouseDownParagraphType == AudioVisualizer.MouseDownParagraphType.Start) - { - var prev = _subtitle.GetParagraphOrDefault(index - 1); - if (prev != null) - { - Paragraph originalPrev = null; - if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible) - { - originalPrev = Utilities.GetOriginalParagraph(index - 1, prev, _subtitleAlternate.Paragraphs); - } - - prev.EndTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + (e.Paragraph.StartTime.TotalMilliseconds - beforeParagraph.StartTime.TotalMilliseconds); - SubtitleListview1.SetStartTimeAndDuration(index - 1, prev, _subtitle.GetParagraphOrDefault(index), _subtitle.GetParagraphOrDefault(index - 2)); - audioVisualizer.Invalidate(); - - if (originalPrev != null) - { - originalPrev.EndTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds; - } - - if (curIdx == index - 1) - { - var durationInSeconds = (decimal)(prev.Duration.TotalSeconds); - if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum) - { - SetDurationInSeconds((double)durationInSeconds); - } - } - } - } - else if (e.MouseDownParagraphType == AudioVisualizer.MouseDownParagraphType.End) - { - var next = _subtitle.GetParagraphOrDefault(index + 1); - if (next != null) - { - Paragraph originalNext = null; - if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible) - { - originalNext = Utilities.GetOriginalParagraph(index + 1, next, _subtitleAlternate.Paragraphs); - } - - next.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds + (e.Paragraph.EndTime.TotalMilliseconds - beforeParagraph.EndTime.TotalMilliseconds); - SubtitleListview1.SetStartTimeAndDuration(index + 1, next, _subtitle.GetParagraphOrDefault(index + 2), _subtitle.GetParagraphOrDefault(index)); - audioVisualizer.Invalidate(); - - if (originalNext != null) - { - originalNext.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds; - } - - if (curIdx == index + 1) - { - timeUpDownStartTime.TimeCode = next.StartTime; - var durationInSeconds = (decimal)(next.Duration.TotalSeconds); - if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum) - { - SetDurationInSeconds((double)durationInSeconds); - } - } - } - } - } - } - - private void AudioWaveform_OnPositionSelected(object sender, AudioVisualizer.ParagraphEventArgs e) - { - mediaPlayer.CurrentPosition = e.Seconds; - if (e.Paragraph != null) - { - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(e.Paragraph), true); - } - } - - private void VideoPositionChanged(object sender, EventArgs e) - { - var tud = (TimeUpDown)sender; - if (tud.Enabled) - { - mediaPlayer.CurrentPosition = tud.TimeCode.TotalSeconds; - } - } - - private void Main_Load(object sender, EventArgs e) - { - splitContainer1.Panel1MinSize = 525; - splitContainer1.Panel2MinSize = 250; - splitContainerMain.Panel1MinSize = 200; - splitContainerMain.Panel2MinSize = 220; - - if (Configuration.Settings.General.StartRememberPositionAndSize && - !string.IsNullOrEmpty(Configuration.Settings.General.StartPosition)) - { - var parts = Configuration.Settings.General.StartPosition.Split(';'); - if (parts.Length == 2) - { - if (int.TryParse(parts[0], out var x) && int.TryParse(parts[1], out var y)) - { - if (x > -100 || y > -100) - { - Left = x; - Top = y; - } - } - } - - if (Configuration.Settings.General.StartSize == "Maximized") - { - CenterFormOnCurrentScreen(); - WindowState = FormWindowState.Maximized; - return; - } - - parts = Configuration.Settings.General.StartSize.Split(';'); - if (parts.Length == 2) - { - if (int.TryParse(parts[0], out var x) && int.TryParse(parts[1], out var y)) - { - Width = x; - Height = y; - } - } - - var ctrlScreen = Screen.FromControl(this); - - if (ctrlScreen.Bounds.Width < Width) - { - Width = ctrlScreen.Bounds.Width; - } - - if (ctrlScreen.Bounds.Height < Height) - { - Height = ctrlScreen.Bounds.Height; - } - - // Fix main window coordinate (Multi-Monitor issue) - if ((ctrlScreen.Bounds.Right < Left) || (ctrlScreen.Bounds.Bottom < Top) || - (ctrlScreen.Bounds.X > Right) || (ctrlScreen.Bounds.Y > Top)) - { - CenterToScreen(); - } - } - else - { - CenterFormOnCurrentScreen(); - } - } - - private void InitializeLanguage() - { - fileToolStripMenuItem.Text = _language.Menu.File.Title; - newToolStripMenuItem.Text = _language.Menu.File.New; - openToolStripMenuItem.Text = _language.Menu.File.Open; - toolStripMenuItemOpenKeepVideo.Text = _language.Menu.File.OpenKeepVideo; - reopenToolStripMenuItem.Text = _language.Menu.File.Reopen; - saveToolStripMenuItem.Text = _language.Menu.File.Save; - saveAsToolStripMenuItem.Text = _language.Menu.File.SaveAs; - toolStripMenuItemRestoreAutoBackup.Text = _language.Menu.File.RestoreAutoBackup; - toolStripMenuItemTTProperties.Text = _language.Menu.File.TimedTextProperties; - openOriginalToolStripMenuItem.Text = _language.Menu.File.OpenOriginal; - saveOriginalToolStripMenuItem.Text = _language.Menu.File.SaveOriginal; - saveOriginalAstoolStripMenuItem.Text = _language.SaveOriginalSubtitleAs; - removeOriginalToolStripMenuItem.Text = _language.Menu.File.CloseOriginal; - - toolStripMenuItemOpenContainingFolder.Text = _language.Menu.File.OpenContainingFolder; - toolStripMenuItemCompare.Text = _language.Menu.File.Compare; - toolStripMenuItemStatistics.Text = _language.Menu.File.Statistics; - toolStripMenuItemPlugins.Text = _language.Menu.File.Plugins; - toolStripMenuItemImportDvdSubtitles.Text = _language.Menu.File.ImportOcrFromDvd; - toolStripMenuItemSubIdx.Text = _language.Menu.File.ImportOcrVobSubSubtitle; - toolStripButtonGetFrameRate.ToolTipText = _language.GetFrameRateFromVideoFile; - toolStripMenuItemImportBluRaySup.Text = _language.Menu.File.ImportBluRaySupFile; - toolStripMenuItemImportXSub.Text = _language.Menu.File.ImportXSub; - matroskaImportStripMenuItem.Text = _language.Menu.File.ImportSubtitleFromMatroskaFile; - toolStripMenuItemManualAnsi.Text = _language.Menu.File.ImportSubtitleWithManualChosenEncoding; - toolStripMenuItemImportText.Text = _language.Menu.File.ImportText; - toolStripMenuItemImportImages.Text = _language.Menu.File.ImportImages; - toolStripMenuItemImportTimeCodes.Text = _language.Menu.File.ImportTimecodes; - toolStripMenuItemExport.Text = _language.Menu.File.Export; - toolStripMenuItemExportPngXml.Text = _language.Menu.File.ExportBdnXml; - bluraySupToolStripMenuItem.Text = _language.Menu.File.ExportBluRaySup; - adobeEncoreFABImageScriptToolStripMenuItem.Text = _language.Menu.File.ExportAdobeEncoreFabImageScript; - toolStripMenuItemTextTimeCodePair.Text = _language.Menu.File.ExportKoreanAtsFilePair; - vobSubsubidxToolStripMenuItem.Text = _language.Menu.File.ExportVobSub; - toolStripMenuItemCavena890.Text = _language.Menu.File.ExportCavena890; - eBUSTLToolStripMenuItem.Text = _language.Menu.File.ExportEbu; - pACScreenElectronicsToolStripMenuItem.Text = _language.Menu.File.ExportPac; - plainTextToolStripMenuItem.Text = _language.Menu.File.ExportPlainText; - toolStripMenuItemAvidStl.Text = _language.Menu.File.ExportAvidStl; - toolStripMenuItemExportCapMakerPlus.Text = _language.Menu.File.ExportCapMakerPlus; - toolStripMenuItemExportCaptionInc.Text = _language.Menu.File.ExportCaptionsInc; - toolStripMenuItemExportCheetahCap.Text = _language.Menu.File.ExportCheetahCap; - toolStripMenuItemExportUltech130.Text = _language.Menu.File.ExportUltech130; - exportCustomTextFormatToolStripMenuItem.Text = _language.Menu.File.ExportCustomTextFormat; - exitToolStripMenuItem.Text = _language.Menu.File.Exit; - - editToolStripMenuItem.Text = _language.Menu.Edit.Title; - showHistoryforUndoToolStripMenuItem.Text = _language.Menu.Edit.ShowUndoHistory; - toolStripMenuItemUndo.Text = _language.Menu.Edit.Undo; - toolStripMenuItemRedo.Text = _language.Menu.Edit.Redo; - - toolStripMenuItemInsertUnicodeCharacter.Text = _language.Menu.Edit.InsertUnicodeSymbol; - - findToolStripMenuItem.Text = _language.Menu.Edit.Find; - findNextToolStripMenuItem.Text = _language.Menu.Edit.FindNext; - replaceToolStripMenuItem.Text = _language.Menu.Edit.Replace; - multipleReplaceToolStripMenuItem.Text = _language.Menu.Edit.MultipleReplace; - gotoLineNumberToolStripMenuItem.Text = _language.Menu.Edit.GoToSubtitleNumber; - toolStripMenuItemRightToLeftMode.Text = _language.Menu.Edit.RightToLeftMode; - - toolStripMenuItemRemoveUnicodeControlChars.Text = _language.Menu.Edit.RemoveUnicodeControlCharacters; - toolStripMenuItemRtlUnicodeControlChars.Text = _language.Menu.Edit.FixRtlViaUnicodeControlCharacters; - - toolStripMenuItemReverseRightToLeftStartEnd.Text = _language.Menu.Edit.ReverseRightToLeftStartEnd; - toolStripMenuItemModifySelection.Text = _language.Menu.Edit.ModifySelection; - toolStripMenuItemInverseSelection.Text = _language.Menu.Edit.InverseSelection; - editSelectAllToolStripMenuItem.Text = _language.Menu.ContextMenu.SelectAll; - - toolsToolStripMenuItem.Text = _language.Menu.Tools.Title; - adjustDisplayTimeToolStripMenuItem.Text = _language.Menu.Tools.AdjustDisplayDuration; - toolStripMenuItemApplyDurationLimits.Text = _language.Menu.Tools.ApplyDurationLimits; - toolStripMenuItemSubtitlesBridgeGaps.Text = _language.Menu.Tools.SubtitlesBridgeGaps; - fixToolStripMenuItem.Text = _language.Menu.Tools.FixCommonErrors; - startNumberingFromToolStripMenuItem.Text = _language.Menu.Tools.StartNumberingFrom; - removeTextForHearImpairedToolStripMenuItem.Text = _language.Menu.Tools.RemoveTextForHearingImpaired; - ChangeCasingToolStripMenuItem.Text = _language.Menu.Tools.ChangeCasing; - toolStripMenuItemChangeFrameRate2.Text = _language.Menu.Tools.ChangeFrameRate; - changeSpeedInPercentToolStripMenuItem.Text = _language.Menu.Tools.ChangeSpeedInPercent; - toolStripMenuItemAutoMergeShortLines.Text = _language.Menu.Tools.MergeShortLines; - toolStripMenuItemMergeDuplicateText.Text = _language.Menu.Tools.MergeDuplicateText; - toolStripMenuItemMergeLinesWithSameTimeCodes.Text = _language.Menu.Tools.MergeSameTimeCodes; - toolStripMenuItemAutoSplitLongLines.Text = _language.Menu.Tools.SplitLongLines; - setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.Text = _language.Menu.Tools.MinimumDisplayTimeBetweenParagraphs; - toolStripMenuItemSortBy.Text = _language.Menu.Tools.SortBy; - netflixQualityCheckToolStripMenuItem.Text = _language.Menu.Tools.NetflixQualityCheck; - toolStripButtonNetflixQualityCheck.Text = _language.Menu.Tools.NetflixQualityCheck; - - sortNumberToolStripMenuItem.Text = _language.Menu.Tools.Number; - sortStartTimeToolStripMenuItem.Text = _language.Menu.Tools.StartTime; - sortEndTimeToolStripMenuItem.Text = _language.Menu.Tools.EndTime; - sortDisplayTimeToolStripMenuItem.Text = _language.Menu.Tools.Duration; - - descendingToolStripMenuItem.Text = _language.Menu.Tools.Descending; - AscendingToolStripMenuItem.Text = _language.Menu.Tools.Ascending; - - sortTextAlphabeticallytoolStripMenuItem.Text = _language.Menu.Tools.TextAlphabetically; - sortTextMaxLineLengthToolStripMenuItem.Text = _language.Menu.Tools.TextSingleLineMaximumLength; - sortTextTotalLengthToolStripMenuItem.Text = _language.Menu.Tools.TextTotalLength; - sortTextNumberOfLinesToolStripMenuItem.Text = _language.Menu.Tools.TextNumberOfLines; - textCharssecToolStripMenuItem.Text = _language.Menu.Tools.TextNumberOfCharactersPerSeconds; - textWordsPerMinutewpmToolStripMenuItem.Text = _language.Menu.Tools.WordsPerMinute; - styleToolStripMenuItem.Text = _language.Menu.Tools.Style; - actorToolStripMenuItem.Text = Configuration.Settings.Language.General.Actor; - - toolStripMenuItemShowOriginalInPreview.Text = _language.Menu.Edit.ShowOriginalTextInAudioAndVideoPreview; - toolStripMenuItemMakeEmptyFromCurrent.Text = _language.Menu.Tools.MakeNewEmptyTranslationFromCurrentSubtitle; - toolStripMenuItemBatchConvert.Text = _language.Menu.Tools.BatchConvert; - generateDatetimeInfoFromVideoToolStripMenuItem.Text = _language.Menu.Tools.GenerateTimeAsText; - toolStripMenuItemMeasurementConverter.Text = _language.Menu.Tools.MeasurementConverter; - splitToolStripMenuItem.Text = _language.Menu.Tools.SplitSubtitle; - appendTextVisuallyToolStripMenuItem.Text = _language.Menu.Tools.AppendSubtitle; - joinSubtitlesToolStripMenuItem.Text = _language.Menu.Tools.JoinSubtitles; - - toolStripMenuItemVideo.Text = _language.Menu.Video.Title; - openVideoToolStripMenuItem.Text = _language.Menu.Video.OpenVideo; - toolStripMenuItemOpenVideoFromUrl.Text = _language.Menu.Video.OpenVideoFromUrl; - toolStripMenuItemOpenDvd.Text = _language.Menu.Video.OpenDvd; - toolStripMenuItemSetAudioTrack.Text = _language.Menu.Video.ChooseAudioTrack; - closeVideoToolStripMenuItem.Text = _language.Menu.Video.CloseVideo; - openSecondSubtitleToolStripMenuItem.Text = _language.Menu.Video.OpenSecondSubtitle; - generateTextFromCurrentVideoToolStripMenuItem.Text = _language.Menu.Video.GenerateTextFromVideo; - - smpteTimeModedropFrameToolStripMenuItem.Text = _language.Menu.Video.SmptTimeMode; - toolStripMenuItemImportChapters.Text = _language.Menu.Video.ImportChaptersFromVideo; - toolStripMenuItemImportSceneChanges.Text = _language.Menu.Video.GenerateImportSceneChanges; - toolStripMenuItemRemoveSceneChanges.Text = _language.Menu.Video.RemoveSceneChanges; - - toolStripMenuItemAddWaveformBatch.Text = _language.Menu.Video.WaveformBatchGenerate; - - if (Configuration.Settings.VideoControls.GenerateSpectrogram) - { - showhideWaveformToolStripMenuItem.Text = _language.Menu.Video.ShowHideWaveformAndSpectrogram; - } - else - { - showhideWaveformToolStripMenuItem.Text = _language.Menu.Video.ShowHideWaveform; - } - - showhideVideoToolStripMenuItem.Text = _language.Menu.Video.ShowHideVideo; - undockVideoControlsToolStripMenuItem.Text = _language.Menu.Video.UnDockVideoControls; - redockVideoControlsToolStripMenuItem.Text = _language.Menu.Video.ReDockVideoControls; - - toolStripMenuItemSpellCheckMain.Text = _language.Menu.SpellCheck.Title; - spellCheckToolStripMenuItem.Text = _language.Menu.SpellCheck.SpellCheck; - toolStripMenuItemSpellCheckFromCurrentLine.Text = _language.Menu.SpellCheck.SpellCheckFromCurrentLine; - findDoubleWordsToolStripMenuItem.Text = _language.Menu.SpellCheck.FindDoubleWords; - FindDoubleLinesToolStripMenuItem.Text = _language.Menu.SpellCheck.FindDoubleLines; - GetDictionariesToolStripMenuItem.Text = _language.Menu.SpellCheck.GetDictionaries; - addWordToNameListToolStripMenuItem.Text = _language.Menu.SpellCheck.AddToNameList; - - toolStripMenuItemSynchronization.Text = _language.Menu.Synchronization.Title; - toolStripMenuItemAdjustAllTimes.Text = _language.Menu.Synchronization.AdjustAllTimes; - visualSyncToolStripMenuItem.Text = _language.Menu.Synchronization.VisualSync; - toolStripMenuItemPointSync.Text = _language.Menu.Synchronization.PointSync; - pointSyncViaOtherSubtitleToolStripMenuItem.Text = _language.Menu.Synchronization.PointSyncViaOtherSubtitle; - - toolStripMenuItemAutoTranslate.Text = _language.Menu.AutoTranslate.Title; - translateByGoogleToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslatePoweredByGoogle; - translatepoweredByMicrosoftToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslatePoweredByMicrosoft; - translateFromSwedishToDanishToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslateFromSwedishToDanish; - - optionsToolStripMenuItem.Text = _language.Menu.Options.Title; - settingsToolStripMenuItem.Text = _language.Menu.Options.Settings; - changeLanguageToolStripMenuItem.Text = _language.Menu.Options.ChooseLanguage + " [" + Configuration.Settings.Language.Name + "]"; - - toolStripMenuItemNetworking.Text = _language.Menu.Networking.Title; - startServerToolStripMenuItem.Text = _language.Menu.Networking.StartNewSession; - joinSessionToolStripMenuItem.Text = _language.Menu.Networking.JoinSession; - showSessionKeyLogToolStripMenuItem.Text = _language.Menu.Networking.ShowSessionInfoAndLog; - chatToolStripMenuItem.Text = _language.Menu.Networking.Chat; - leaveSessionToolStripMenuItem.Text = _language.Menu.Networking.LeaveSession; - - checkForUpdatesToolStripMenuItem.Text = _language.Menu.Help.CheckForUpdates; - helpToolStripMenuItem.Text = _language.Menu.Help.Title; - helpToolStripMenuItem1.Text = _language.Menu.Help.Help; - aboutToolStripMenuItem.Text = _language.Menu.Help.About; - - toolStripButtonFileNew.ToolTipText = _language.Menu.ToolBar.New; - toolStripButtonFileOpen.ToolTipText = _language.Menu.ToolBar.Open; - toolStripButtonSave.ToolTipText = _language.Menu.ToolBar.Save; - toolStripButtonSaveAs.ToolTipText = _language.Menu.ToolBar.SaveAs; - toolStripButtonFind.ToolTipText = _language.Menu.ToolBar.Find; - toolStripButtonReplace.ToolTipText = _language.Menu.ToolBar.Replace; - toolStripButtonFixCommonErrors.ToolTipText = _language.Menu.ToolBar.FixCommonErrors; - toolStripButtonRemoveTextForHi.ToolTipText = _language.Menu.ToolBar.RemoveTextForHi; - toolStripButtonVisualSync.ToolTipText = _language.Menu.ToolBar.VisualSync; - toolStripButtonSpellCheck.ToolTipText = _language.Menu.ToolBar.SpellCheck; - toolStripButtonNetflixQualityCheck.ToolTipText = _language.Menu.ToolBar.NetflixQualityCheck; - toolStripButtonSettings.ToolTipText = _language.Menu.ToolBar.Settings; - toolStripButtonHelp.ToolTipText = _language.Menu.ToolBar.Help; - toolStripButtonToggleWaveform.ToolTipText = _language.Menu.ToolBar.ShowHideWaveform; - toolStripButtonToggleVideo.ToolTipText = _language.Menu.ToolBar.ShowHideVideo; - - toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.SubStationAlphaStyles; - setStylesForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.SubStationAlphaSetStyle; - setActorForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.SetActor; - - toolStripMenuItemDelete.Text = _language.Menu.ContextMenu.Delete; - insertLineToolStripMenuItem.Text = _language.Menu.ContextMenu.InsertFirstLine; - toolStripMenuItemInsertBefore.Text = _language.Menu.ContextMenu.InsertBefore; - toolStripMenuItemInsertAfter.Text = _language.Menu.ContextMenu.InsertAfter; - toolStripMenuItemInsertSubtitle.Text = _language.Menu.ContextMenu.InsertSubtitleAfter; - - toolStripMenuItemCopySourceText.Text = _language.Menu.ContextMenu.CopyToClipboard; - - toolStripMenuItemColumn.Text = _language.Menu.ContextMenu.Column; - columnDeleteTextOnlyToolStripMenuItem.Text = _language.Menu.ContextMenu.ColumnDeleteText; - toolStripMenuItemColumnDeleteText.Text = _language.Menu.ContextMenu.ColumnDeleteTextAndShiftCellsUp; - ShiftTextCellsDownToolStripMenuItem.Text = _language.Menu.ContextMenu.ColumnInsertEmptyTextAndShiftCellsDown; - toolStripMenuItemInsertTextFromSub.Text = _language.Menu.ContextMenu.ColumnInsertTextFromSubtitle; - toolStripMenuItemColumnImportText.Text = _language.Menu.ContextMenu.ColumnImportTextAndShiftCellsDown; - toolStripMenuItemPasteSpecial.Text = _language.Menu.ContextMenu.ColumnPasteFromClipboard; - moveTextUpToolStripMenuItem.Text = _language.Menu.ContextMenu.ColumnTextUp; - moveTextDownToolStripMenuItem.Text = _language.Menu.ContextMenu.ColumnTextDown; - copyOriginalTextToCurrentToolStripMenuItem.Text = _language.Menu.ContextMenu.ColumnCopyOriginalTextToCurrent; - toolStripMenuItemBookmark.Text = Configuration.Settings.Language.Settings.ToggleBookmarksWithComment; - - splitLineToolStripMenuItem.Text = _language.Menu.ContextMenu.Split; - toolStripMenuItemMergeLines.Text = _language.Menu.ContextMenu.MergeSelectedLines; - toolStripMenuItemMergeDialog.Text = _language.Menu.ContextMenu.MergeSelectedLinesAsDialog; - mergeBeforeToolStripMenuItem.Text = _language.Menu.ContextMenu.MergeWithLineBefore; - mergeAfterToolStripMenuItem.Text = _language.Menu.ContextMenu.MergeWithLineAfter; - extendBeforeToolStripMenuItem.Text = _language.Menu.ContextMenu.ExtendToLineBefore; - extendAfterToolStripMenuItem.Text = _language.Menu.ContextMenu.ExtendToLineAfter; - removeFormattinglToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormatting; - removeAllFormattingsToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingAll; - removeBoldToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingBold; - removeItalicToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingItalic; - removeUnderlineToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingUnderline; - removeColorToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingColor; - removeFontNameToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingFontName; - removeAlignmentToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingAlignment; - boldToolStripMenuItem.Text = _languageGeneral.Bold; - underlineToolStripMenuItem.Text = _language.Menu.ContextMenu.Underline; - italicToolStripMenuItem.Text = _languageGeneral.Italic; - colorToolStripMenuItem.Text = _language.Menu.ContextMenu.Color; - toolStripMenuItemFont.Text = _language.Menu.ContextMenu.FontName; - toolStripMenuItemAlignment.Text = _language.Menu.ContextMenu.Alignment; - toolStripMenuItemAutoBreakLines.Text = _language.Menu.ContextMenu.AutoBalanceSelectedLines; - toolStripMenuItemUnbreakLines.Text = _language.Menu.ContextMenu.RemoveLineBreaksFromSelectedLines; - typeEffectToolStripMenuItem.Text = _language.Menu.ContextMenu.TypewriterEffect; - karokeeEffectToolStripMenuItem.Text = _language.Menu.ContextMenu.KaraokeEffect; - showSelectedLinesEarlierlaterToolStripMenuItem.Text = _language.Menu.ContextMenu.ShowSelectedLinesEarlierLater; - visualSyncSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.VisualSyncSelectedLines; - toolStripMenuItemGoogleMicrosoftTranslateSelLine.Text = _language.Menu.ContextMenu.GoogleAndMicrosoftTranslateSelectedLine; - googleTranslateToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslatePoweredByGoogle; - microsoftBingTranslateToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslatePoweredByMicrosoft; - toolStripMenuItemTranslateSelected.Text = _language.Menu.ContextMenu.TranslateSelectedLines; - adjustDisplayTimeForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.AdjustDisplayDurationForSelectedLines; - fixCommonErrorsInSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.FixCommonErrorsInSelectedLines; - changeCasingForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.ChangeCasingForSelectedLines; - toolStripMenuItemSaveSelectedLines.Text = _language.Menu.ContextMenu.SaveSelectedLines; - - // textbox context menu - cutToolStripMenuItem.Text = _language.Menu.ContextMenu.Cut; - copyToolStripMenuItem.Text = _language.Menu.ContextMenu.Copy; - pasteToolStripMenuItem.Text = _language.Menu.ContextMenu.Paste; - deleteToolStripMenuItem.Text = _language.Menu.ContextMenu.Delete; - toolStripMenuItemSplitTextAtCursor.Text = _language.Menu.ContextMenu.SplitLineAtCursorPosition; - toolStripMenuItemSplitViaWaveform.Text = _language.Menu.ContextMenu.SplitLineAtCursorAndWaveformPosition; - selectAllToolStripMenuItem.Text = _language.Menu.ContextMenu.SelectAll; - normalToolStripMenuItem1.Text = _language.Menu.ContextMenu.RemoveFormattingAll; - boldToolStripMenuItem1.Text = _languageGeneral.Bold; - italicToolStripMenuItem1.Text = _languageGeneral.Italic; - boxToolStripMenuItem.Text = _language.Menu.ContextMenu.Box; - underlineToolStripMenuItem1.Text = _language.Menu.ContextMenu.Underline; - colorToolStripMenuItem1.Text = _language.Menu.ContextMenu.Color; - fontNameToolStripMenuItem.Text = _language.Menu.ContextMenu.FontName; - toolStripMenuItemInsertUnicodeSymbol.Text = _language.Menu.Edit.InsertUnicodeSymbol; - toolStripMenuItemInsertUnicodeControlCharacters.Text = _language.Menu.Edit.InsertUnicodeControlCharacters; - superscriptToolStripMenuItem.Text = _language.Menu.ContextMenu.Superscript; - subscriptToolStripMenuItem.Text = _language.Menu.ContextMenu.Subscript; - leftToolStripMenuItem.Text = _language.Menu.Edit.InsertUnicodeControlCharactersLRM; - righttoleftMarkToolStripMenuItem.Text = _language.Menu.Edit.InsertUnicodeControlCharactersRLM; - startOfLefttorightEmbeddingLREToolStripMenuItem.Text = _language.Menu.Edit.InsertUnicodeControlCharactersLRE; - startOfRighttoleftEmbeddingRLEToolStripMenuItem.Text = _language.Menu.Edit.InsertUnicodeControlCharactersRLE; - startOfLefttorightOverrideLROToolStripMenuItem.Text = _language.Menu.Edit.InsertUnicodeControlCharactersLRO; - startOfRighttoleftOverrideRLOToolStripMenuItem.Text = _language.Menu.Edit.InsertUnicodeControlCharactersRLO; - - // main controls - SubtitleListview1.InitializeLanguage(_languageGeneral, Configuration.Settings); - toolStripLabelSubtitleFormat.Text = _language.Controls.SubtitleFormat; - toolStripLabelEncoding.Text = _language.Controls.FileEncoding; - toolStripLabelFrameRate.Text = _languageGeneral.FrameRate; - tabControlSubtitle.TabPages[TabControlSourceView].Text = _language.Controls.SourceView; - tabControlSubtitle.TabPages[TabControlListView].Text = _language.Controls.ListView; - labelStartTime.Text = _languageGeneral.StartTime; - labelDuration.Text = _languageGeneral.Duration; - labelText.Text = _languageGeneral.Text; - UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, _subtitle?.GetParagraphOrDefault(_subtitleListViewIndex), textBoxListViewText); - labelAlternateText.Text = _languageGeneral.OriginalText; - UpdateListViewTextInfo(labelTextAlternateLineLengths, labelAlternateSingleLine, labelAlternateSingleLinePixels, labelTextAlternateLineTotal, labelAlternateCharactersPerSecond, _subtitleAlternate?.GetParagraphOrDefault(_subtitleListViewIndex), textBoxListViewTextAlternate); - buttonPrevious.Text = _language.Controls.Previous; - buttonNext.Text = _language.Controls.Next; - buttonAutoBreak.Text = _language.Controls.AutoBreak; - buttonUnBreak.Text = _language.Controls.Unbreak; - buttonSplitLine.Text = _languageGeneral.SplitLine; - ShowSourceLineNumber(); - - // video controls - tabPageTranslate.Text = _language.VideoControls.Translate + " "; - tabPageCreate.Text = _language.VideoControls.Create + " "; - tabPageAdjust.Text = _language.VideoControls.Adjust + " "; - checkBoxSyncListViewWithVideoWhilePlaying.Text = _language.VideoControls.SelectCurrentElementWhilePlaying; - if (VideoFileName == null) - { - labelVideoInfo.Text = _languageGeneral.NoVideoLoaded; - } - - toolStripButtonLockCenter.Text = _language.VideoControls.Center; - toolStripSplitButtonPlayRate.Text = _language.VideoControls.PlayRate; - groupBoxAutoRepeat.Text = _language.VideoControls.AutoRepeat; - checkBoxAutoRepeatOn.Text = _language.VideoControls.AutoRepeatOn; - labelAutoRepeatCount.Text = _language.VideoControls.AutoRepeatCount; - groupBoxAutoContinue.Text = _language.VideoControls.AutoContinue; - checkBoxAutoContinue.Text = _language.VideoControls.AutoContinueOn; - labelAutoContinueDelay.Text = _language.VideoControls.DelayInSeconds; - buttonPlayPrevious.Text = _language.VideoControls.Previous; - buttonPlayCurrent.Text = _language.VideoControls.PlayCurrent; - buttonPlayNext.Text = _language.VideoControls.Next; - buttonStop.Text = _language.VideoControls.Pause; - groupBoxTranslateSearch.Text = _language.VideoControls.SearchTextOnline; - buttonGoogleIt.Text = _language.VideoControls.GoogleIt; - buttonGoogleTranslateIt.Text = _language.VideoControls.GoogleTranslate; - labelTranslateTip.Text = _language.VideoControls.TranslateTip; - - buttonInsertNewText.Text = _language.VideoControls.InsertNewSubtitleAtVideoPosition; - buttonBeforeText.Text = _language.VideoControls.PlayFromJustBeforeText; - buttonGotoSub.Text = _language.VideoControls.GoToSubtitlePositionAndPause; - buttonSetStartTime.Text = _language.VideoControls.SetStartTime; - buttonSetEnd.Text = _language.VideoControls.SetEndTime; - buttonSecBack1.Text = _language.VideoControls.SecondsBackShort; - buttonSecBack2.Text = _language.VideoControls.SecondsBackShort; - buttonForward1.Text = _language.VideoControls.SecondsForwardShort; - buttonForward2.Text = _language.VideoControls.SecondsForwardShort; - labelVideoPosition.Text = _language.VideoControls.VideoPosition; - labelVideoPosition2.Text = _language.VideoControls.VideoPosition; - - buttonSetStartAndOffsetRest.Text = _language.VideoControls.SetstartTimeAndOffsetOfRest; - buttonSetEndAndGoToNext.Text = _language.VideoControls.SetEndTimeAndGoToNext; - buttonAdjustSetStartTime.Text = _language.VideoControls.SetStartTime; - buttonAdjustSetEndTime.Text = _language.VideoControls.SetEndTime; - buttonAdjustPlayBefore.Text = _language.VideoControls.PlayFromJustBeforeText; - buttonAdjustGoToPosAndPause.Text = _language.VideoControls.GoToSubtitlePositionAndPause; - buttonAdjustSecBack1.Text = _language.VideoControls.SecondsBackShort; - buttonAdjustSecBack2.Text = _language.VideoControls.SecondsBackShort; - buttonAdjustSecForward1.Text = _language.VideoControls.SecondsForwardShort; - buttonAdjustSecForward2.Text = _language.VideoControls.SecondsForwardShort; - - // waveform - var languageWaveform = Configuration.Settings.Language.Waveform; - addParagraphHereToolStripMenuItem.Text = languageWaveform.AddParagraphHere; - addParagraphAndPasteToolStripMenuItem.Text = languageWaveform.AddParagraphHereAndPasteText; - toolStripMenuItemSetParagraphAsSelection.Text = languageWaveform.SetParagraphAsSelection; - deleteParagraphToolStripMenuItem.Text = languageWaveform.DeleteParagraph; - toolStripMenuItemFocusTextbox.Text = languageWaveform.FocusTextBox; - goToPreviousSubtitleStripMenuItem.Text = languageWaveform.GoToPrevious; - goToNextSubtitleStripMenuItem.Text = languageWaveform.GoToNext; - - splitToolStripMenuItem1.Text = languageWaveform.Split; - mergeWithPreviousToolStripMenuItem.Text = languageWaveform.MergeWithPrevious; - mergeWithNextToolStripMenuItem.Text = languageWaveform.MergeWithNext; - extendToPreviousToolStripMenuItem.Text = languageWaveform.ExtendToPrevious; - extendToNextToolStripMenuItem.Text = languageWaveform.ExtendToNext; - toolStripMenuItemWaveformPlaySelection.Text = languageWaveform.PlaySelection; - showWaveformAndSpectrogramToolStripMenuItem.Text = languageWaveform.ShowWaveformAndSpectrogram; - showOnlyWaveformToolStripMenuItem.Text = languageWaveform.ShowWaveformOnly; - showOnlySpectrogramToolStripMenuItem.Text = languageWaveform.ShowSpectrogramOnly; - seekSilenceToolStripMenuItem.Text = languageWaveform.SeekSilence; - insertSubtitleHereToolStripMenuItem.Text = languageWaveform.InsertSubtitleHere; - guessTimeCodesToolStripMenuItem.Text = languageWaveform.GuessTimeCodes; - removeSceneChangeToolStripMenuItem.Text = languageWaveform.RemoveSceneChange; - addSceneChangeToolStripMenuItem.Text = languageWaveform.AddSceneChange; - - toolStripButtonWaveformZoomOut.ToolTipText = languageWaveform.ZoomOut; - toolStripButtonWaveformZoomIn.ToolTipText = languageWaveform.ZoomIn; - - if (Configuration.Settings.VideoControls.GenerateSpectrogram) - { - audioVisualizer.WaveformNotLoadedText = languageWaveform.ClickToAddWaveformAndSpectrogram; - } - else - { - audioVisualizer.WaveformNotLoadedText = languageWaveform.ClickToAddWaveform; - } - - // clear cached language names - DvdSubtitleLanguage.Initialize(); - } - - private void SetFormatTo(string formatName) - { - SetFormatTo(SubtitleFormat.FromName(formatName, new SubRip())); - } - - private void SetFormatTo(SubtitleFormat subtitleFormat) - { - comboBoxSubtitleFormats.SelectedIndexChanged -= ComboBoxSubtitleFormatsSelectedIndexChanged; - UiUtil.InitializeSubtitleFormatComboBox(comboBoxSubtitleFormats, subtitleFormat.FriendlyName); - comboBoxSubtitleFormats.SelectedIndexChanged += ComboBoxSubtitleFormatsSelectedIndexChanged; - } - - private int FirstSelectedIndex - { - get - { - if (SubtitleListview1.SelectedItems.Count == 0) - { - return -1; - } - - return SubtitleListview1.SelectedItems[0].Index; - } - } - - private int FirstVisibleIndex - { - get - { - if (SubtitleListview1.Items.Count == 0 || SubtitleListview1.TopItem == null) - { - return -1; - } - - return SubtitleListview1.TopItem.Index; - } - } - - private long _lastAutoSave; - - private void AutoSave(bool force = false) - { - if (!Configuration.Settings.General.AutoSave || - DateTime.UtcNow.Ticks - _lastAutoSave < 10000 * 3000 && !force) // only check for auto save evety 3 seconds - { - return; - } - - _lastAutoSave = DateTime.UtcNow.Ticks + 1009000; - var currentSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - if (_changeSubtitleHash != currentSubtitleHash && _lastDoNotPrompt != currentSubtitleHash && _subtitle?.Paragraphs.Count > 0) - { - if (string.IsNullOrEmpty(_fileName) || _converted) - { - return; - } - - SaveSubtitle(GetCurrentSubtitleFormat(), false, true); - } - - if (!string.IsNullOrEmpty(_subtitleAlternateFileName) && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - SaveOriginalSubtitle(GetCurrentSubtitleFormat(), true); - } - - _lastAutoSave = DateTime.UtcNow.Ticks; - } - - private bool ContinueNewOrExit() - { - AutoSave(true); - var currentSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - if (_changeSubtitleHash != currentSubtitleHash && _lastDoNotPrompt != currentSubtitleHash && _subtitle?.Paragraphs.Count > 0) - { - string promptText = _language.SaveChangesToUntitled; - if (!string.IsNullOrEmpty(_fileName)) - { - promptText = string.Format(_language.SaveChangesToX, _fileName); - } - - var dr = MessageBox.Show(this, promptText, Title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); - - if (dr == DialogResult.Cancel) - { - return false; - } - - if (dr == DialogResult.Yes) - { - if (string.IsNullOrEmpty(_fileName)) - { - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - saveFileDialog1.Title = _language.SaveSubtitleAs; - if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - _fileName = saveFileDialog1.FileName; - SetTitle(); - Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - Configuration.Settings.Save(); - } - else - { - return false; - } - } - - if (SaveSubtitle(GetCurrentSubtitleFormat()) != DialogResult.OK) - { - return false; - } - } - } - - return ContinueNewOrExitAlternate(); - } - - private bool ContinueNewOrExitAlternate() - { - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0 && _changeAlternateSubtitleHash != _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName)) - { - string promptText = _language.SaveChangesToUntitledOriginal; - if (!string.IsNullOrEmpty(_subtitleAlternateFileName)) - { - promptText = string.Format(_language.SaveChangesToOriginalX, _subtitleAlternateFileName); - } - - var dr = MessageBox.Show(this, promptText, Title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); - - if (dr == DialogResult.Cancel) - { - return false; - } - - if (dr == DialogResult.Yes) - { - if (string.IsNullOrEmpty(_subtitleAlternateFileName)) - { - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - saveFileDialog1.Title = _language.SaveOriginalSubtitleAs; - if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - _subtitleAlternateFileName = saveFileDialog1.FileName; - } - else - { - return false; - } - } - - if (SaveOriginalSubtitle(GetCurrentSubtitleFormat()) != DialogResult.OK) - { - return false; - } - } - } - - _lastDoNotPrompt = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - return true; - } - - private void ExitToolStripMenuItemClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - Application.Exit(); - } - - private void AboutToolStripMenuItemClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - using (var about = new About()) - { - about.Initialize(); - about.ShowDialog(this); - } - } - - private void VisualSyncToolStripMenuItemClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - ShowVisualSync(false); - } - - public void MakeHistoryForUndo(string description, bool resetTextUndo) - { - if (_makeHistoryPaused) - { - return; - } - - if (resetTextUndo) - { - _listViewTextUndoLast = null; - _listViewAlternateTextUndoLast = null; - } - - if (_undoIndex == -1) - { - _subtitle.HistoryItems.Clear(); - } - else - { - // remove items for redo - while (_subtitle.HistoryItems.Count > _undoIndex + 1) - { - _subtitle.HistoryItems.RemoveAt(_subtitle.HistoryItems.Count - 1); - } - } - - _subtitle.FileName = _fileName; - _subtitle.MakeHistoryForUndo(description, GetCurrentSubtitleFormat(), _fileDateTime, _subtitleAlternate, _subtitleAlternateFileName, _subtitleListViewIndex, textBoxListViewText.SelectionStart, textBoxListViewTextAlternate.SelectionStart); - _undoIndex++; - - if (_undoIndex > Subtitle.MaximumHistoryItems) - { - _undoIndex--; - } - } - - public void MakeHistoryForUndo(string description) - { - MakeHistoryForUndo(description, true); - } - - /// - /// Add undo history - but only if last entry is older than 500 ms - /// - /// Undo description - public void MakeHistoryForUndoOnlyIfNotResent(string description) - { - if (_makeHistoryPaused) - { - return; - } - - if ((DateTime.UtcNow.Ticks - _lastHistoryTicks) > 10000 * 500) // only if last change was longer ago than 500 milliseconds - { - MakeHistoryForUndo(description); - _lastHistoryTicks = DateTime.UtcNow.Ticks; - } - } - - private bool IsSubtitleLoaded - { - get { return _subtitle != null && (_subtitle.Paragraphs.Count > 1 || (_subtitle.Paragraphs.Count == 1 && !string.IsNullOrWhiteSpace(_subtitle.Paragraphs[0].Text))); } - } - - private void ShowVisualSync(bool onlySelectedLines) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - using (var visualSync = new VisualSync()) - { - visualSync.VideoFileName = VideoFileName; - visualSync.AudioTrackNumber = VideoAudioTrackNumber; - - SaveSubtitleListviewIndices(); - if (onlySelectedLines) - { - var selectedLines = new Subtitle(); - Subtitle selectedLinesAlternate = null; - if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - selectedLinesAlternate = new Subtitle(); - } - - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.Paragraphs[index]; - selectedLines.Paragraphs.Add(p); - if (selectedLinesAlternate != null) - { - var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - selectedLinesAlternate.Paragraphs.Add(original); - } - } - } - - visualSync.Initialize(toolStripButtonVisualSync.Image as Bitmap, selectedLines, selectedLinesAlternate, _fileName, _language.VisualSyncSelectedLines, CurrentFrameRate); - } - else - { - visualSync.Initialize(toolStripButtonVisualSync.Image as Bitmap, _subtitle, _subtitleAlternate, _fileName, _language.VisualSyncTitle, CurrentFrameRate); - } - - _endSeconds = -1; - mediaPlayer.Pause(); - if (visualSync.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeVisualSync); - - if (onlySelectedLines) - { // we only update selected lines - int i = 0; - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index] = visualSync.Paragraphs[i]; - i++; - } - - ShowStatus(_language.VisualSyncPerformedOnSelectedLines); - } - else - { - _subtitle.Paragraphs.Clear(); - foreach (var p in visualSync.Paragraphs) - { - _subtitle.Paragraphs.Add(new Paragraph(p)); - } - - if (_subtitleAlternate != null && visualSync.ParagraphsAlternate != null) - { - _subtitleAlternate.Paragraphs.Clear(); - foreach (var p in visualSync.ParagraphsAlternate) - { - _subtitleAlternate.Paragraphs.Add(new Paragraph(p)); - } - } - - ShowStatus(_language.VisualSyncPerformed); - } - - if (visualSync.FrameRateChanged) - { - toolStripComboBoxFrameRate.Text = string.Format("{0:0.###}", visualSync.FrameRate); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - if (onlySelectedLines && SubtitleListview1.SelectedItems.Count > 0) - { - SubtitleListview1.EnsureVisible(SubtitleListview1.SelectedItems[SubtitleListview1.SelectedItems.Count - 1].Index); - } - } - - VideoFileName = visualSync.VideoFileName; - } - } - - private void OpenToolStripMenuItemClick(object sender, EventArgs e) - { - openToolStripMenuItem.Enabled = false; - ReloadFromSourceView(); - OpenNewFile(); - openToolStripMenuItem.Enabled = true; - } - - private void OpenNewFile() - { - if (_openFileDialogOn) - { - return; - } - - _openFileDialogOn = true; - _lastDoNotPrompt = -1; - if (!ContinueNewOrExit()) - { - _openFileDialogOn = false; - return; - } - - openFileDialog1.Title = _languageGeneral.OpenSubtitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - RemoveAlternate(true, false); - - // try to open via recent files - if (OpenFromRecentFiles(openFileDialog1.FileName)) - { - return; - } - - OpenSubtitle(openFileDialog1.FileName, null); - } - - _openFileDialogOn = false; - } - - private bool OpenFromRecentFiles(string fileName) - { - var rfe = Configuration.Settings.RecentFiles.Files.FirstOrDefault(p => !string.IsNullOrEmpty(p.FileName) && p.FileName.Equals(fileName, StringComparison.OrdinalIgnoreCase)); - if (rfe != null) - { - OpenRecentFile(rfe); - GotoSubPosAndPause(); - SubtitleListview1.EndUpdate(); - SetRecentIndices(rfe); - if (!string.IsNullOrEmpty(rfe.VideoFileName)) - { - var p = _subtitle.GetParagraphOrDefault(rfe.FirstSelectedIndex); - if (p != null) - { - mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; - } - } - - _openFileDialogOn = false; - return true; - } - - return false; - } - - public double CurrentFrameRate - { - get - { - if (double.TryParse(toolStripComboBoxFrameRate.Text, out var f)) - { - return f; - } - - return Configuration.Settings.General.DefaultFrameRate; - } - } - - private void OpenSubtitle(string fileName, Encoding encoding) - { - OpenSubtitle(fileName, encoding, null, null); - } - - private void ResetHistory() - { - _undoIndex = -1; - _subtitle.HistoryItems.Clear(); - } - - private void OpenSubtitle(string fileName, Encoding encoding, string videoFileName, string originalFileName) - { - OpenSubtitle(fileName, encoding, videoFileName, originalFileName, false); - } - - private void OpenSubtitle(string fileName, Encoding encoding, string videoFileName, string originalFileName, bool updateRecentFile) - { - if (!File.Exists(fileName)) - { - MessageBox.Show(string.Format(_language.FileNotFound, fileName)); - return; - } - - _lastAutoSave = DateTime.UtcNow.Ticks; - bool videoFileLoaded = false; - var file = new FileInfo(fileName); - var ext = file.Extension.ToLowerInvariant(); - - // save last first visible index + first selected index from listview - if (_fileName != null && updateRecentFile) - { - Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - } - Configuration.Settings.General.CurrentVideoOffsetInMs = 0; - - openFileDialog1.InitialDirectory = file.DirectoryName; - - - if (ext == ".idx") - { - var subFileName = fileName.Substring(0, fileName.Length - 3) + "sub"; - if (File.Exists(subFileName) && FileUtil.IsVobSub(subFileName)) - { - ext = ".sub"; - fileName = subFileName; - } - } - - if (ext == ".sub" && IsVobSubFile(fileName, false)) - { - ImportAndOcrVobSubSubtitleNew(fileName, _loading); - return; - } - - if (ext == ".sup") - { - if (FileUtil.IsBluRaySup(fileName)) - { - ImportAndOcrBluRaySup(fileName, _loading); - return; - } - - if (FileUtil.IsSpDvdSup(fileName)) - { - ImportAndOcrSpDvdSup(fileName, _loading); - return; - } - } - - if (ext == ".mkv" || ext == ".mks") - { - ImportSubtitleFromMatroskaFile(fileName); - return; - } - - if (ext == ".divx" || ext == ".avi") - { - if (ImportSubtitleFromDivX(fileName)) - { - return; - } - } - - if ((ext == ".ts" || ext == ".rec" || ext == ".mpeg" || ext == ".mpg") && file.Length > 10000 && FileUtil.IsTransportStream(fileName)) - { - ImportSubtitleFromTransportStream(fileName); - return; - } - - if (((ext == ".m2ts" || ext == ".ts" || ext == ".mts") && file.Length > 10000 && FileUtil.IsM2TransportStream(fileName)) || - (ext == ".textst" && FileUtil.IsMpeg2PrivateStream2(fileName))) - { - bool isTextSt = false; - if (file.Length < 2000000) - { - var textSt = new TextST(); - isTextSt = textSt.IsMine(null, fileName); - } - - if (!isTextSt) - { - ImportSubtitleFromTransportStream(fileName); - return; - } - } - - if ((ext == ".mp4" || ext == ".m4v" || ext == ".3gp") && file.Length > 10000) - { - if (!new IsmtDfxp().IsMine(null, fileName)) - { - if (ImportSubtitleFromMp4(fileName) && !Configuration.Settings.General.DisableVideoAutoLoading) - { - OpenVideo(fileName); - } - - return; - } - } - - if (ext == ".mxf" && FileUtil.IsMaterialExchangeFormat(fileName)) - { - var parser = new MxfParser(fileName); - if (parser.IsValid) - { - var subtitles = parser.GetSubtitles(); - if (subtitles.Count > 0) - { - SetEncoding(Configuration.Settings.General.DefaultEncoding); - var list = new List(subtitles[0].SplitToLines()); - _subtitle = new Subtitle(); - var mxfFormat = _subtitle.ReloadLoadSubtitle(list, null, null); - SetCurrentFormat(mxfFormat); - _fileName = Utilities.GetPathAndFileNameWithoutExtension(fileName) + GetCurrentSubtitleFormat().Extension; - SetTitle(); - ShowStatus(string.Format(_language.LoadedSubtitleX, _fileName)); - _sourceViewChange = false; - _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - ResetHistory(); - SetUndockedWindowsTitle(); - _converted = true; - ShowStatus(string.Format(_language.LoadedSubtitleX, _fileName) + " - " + string.Format(_language.ConvertedToX, mxfFormat.FriendlyName)); - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - return; - } - - MessageBox.Show("No subtitles found!"); - return; - } - } - - if (ext == ".prproj") - { - var f = new AdobePremierePrProj(); - var tempFileName = AdobePremierePrProj.LoadFromZipFile(fileName); - if (!string.IsNullOrEmpty(fileName)) - { - var list = new List(File.ReadAllLines(tempFileName, LanguageAutoDetect.GetEncodingFromFile(tempFileName))); - try - { - File.Delete(tempFileName); - } - catch - { - // ignored - } - if (f.IsMine(list, tempFileName)) - { - f.LoadSubtitle(_subtitle, list, fileName); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - SetEncoding(Configuration.Settings.General.DefaultEncoding); - encoding = GetCurrentEncoding(); - SubtitleListview1.Fill(_subtitle); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - _fileName = Utilities.GetPathAndFileNameWithoutExtension(fileName) + GetCurrentSubtitleFormat().Extension; - SetTitle(); - ShowStatus(string.Format(_language.LoadedSubtitleX, _fileName)); - _converted = true; - return; - } - } - } - - if (file.Length > Subtitle.MaxFileSize) - { - // retry Blu-ray sup (file with wrong extension) - if (FileUtil.IsBluRaySup(fileName)) - { - ImportAndOcrBluRaySup(fileName, _loading); - return; - } - - // retry vobsub (file with wrong extension) - if (IsVobSubFile(fileName, false)) - { - ImportAndOcrVobSubSubtitleNew(fileName, _loading); - return; - } - - var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, fileName); - if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return; - } - } - - var tempSubtitle = new Subtitle(_subtitle, false); - if (_subtitle.HistoryItems.Count > 0 || _subtitle.Paragraphs.Count > 0) - { - MakeHistoryForUndo(string.Format(_language.BeforeLoadOf, Path.GetFileName(fileName))); - } - - var subtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - bool hasChanged = (_changeSubtitleHash != subtitleHash) && (_lastDoNotPrompt != subtitleHash); - - SubtitleFormat format = _subtitle.LoadSubtitle(fileName, out encoding, encoding); - if (format == null) - { - _subtitle = tempSubtitle; - } - - if (!hasChanged) - { - _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - } - - ShowHideTextBasedFeatures(format); - - bool justConverted = false; - - if (ext == ".m2ts" || ext == ".textst") - { - var textST = new TextST(); - if (textST.IsMine(null, fileName)) - { - textST.LoadSubtitle(_subtitle, null, fileName); - _oldSubtitleFormat = textST; - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - SetEncoding(Configuration.Settings.General.DefaultEncoding); - encoding = GetCurrentEncoding(); - justConverted = true; - format = GetCurrentSubtitleFormat(); - } - } - - var encodingFromFile = encoding; - if (format == null) - { - encodingFromFile = LanguageAutoDetect.GetEncodingFromFile(fileName); - } - - if (format == null) - { - var f = new TimeCodesOnly1(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (f.IsMine(list, fileName)) - { - f.LoadSubtitle(_subtitle, list, fileName); - _oldSubtitleFormat = f; - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - SetEncoding(Configuration.Settings.General.DefaultEncoding); - encoding = GetCurrentEncoding(); - justConverted = true; - format = GetCurrentSubtitleFormat(); - } - } - - if (format == null) - { - var f = new TimeCodesOnly2(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (f.IsMine(list, fileName)) - { - f.LoadSubtitle(_subtitle, list, fileName); - _oldSubtitleFormat = f; - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - SetEncoding(Configuration.Settings.General.DefaultEncoding); - encoding = GetCurrentEncoding(); - justConverted = true; - format = GetCurrentSubtitleFormat(); - } - } - - if (format == null) - { - try - { - var bdnXml = new BdnXml(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (bdnXml.IsMine(list, fileName)) - { - if (ContinueNewOrExit()) - { - ImportAndOcrBdnXml(fileName, bdnXml, list); - } - - return; - } - } - catch - { - // ignore - } - } - - if (format == null) - { - try - { - var fcpImage = new FinalCutProImage(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (fcpImage.IsMine(list, fileName)) - { - if (ContinueNewOrExit()) - { - ImportAndOcrDost(fileName, fcpImage, list); - } - - return; - } - } - catch - { - // ignore - } - } - - if (format == null) - { - try - { - var f = new DvdStudioProSpaceGraphic(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (f.IsMine(list, fileName)) - { - if (ContinueNewOrExit()) - { - ImportAndOcrDost(fileName, f, list); - } - - return; - } - } - catch - { - // ignore - } - } - - if (format == null) - { - try - { - var imageFormat = new SpuImage(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (imageFormat.IsMine(list, fileName)) - { - if (ContinueNewOrExit()) - { - ImportAndOcrDost(fileName, imageFormat, list); - } - - return; - } - } - catch - { - format = null; - } - } - - if (format == null) - { - var arib = new AribB36(); - if (arib.IsMine(null, fileName)) - { - arib.LoadSubtitle(_subtitle, null, fileName); - _oldSubtitleFormat = arib; - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - SetEncoding(Configuration.Settings.General.DefaultEncoding); - encoding = GetCurrentEncoding(); - justConverted = true; - format = GetCurrentSubtitleFormat(); - } - } - - if (ext == ".dost") - { - try - { - var dost = new Dost(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (dost.IsMine(list, fileName)) - { - if (ContinueNewOrExit()) - { - ImportAndOcrDost(fileName, dost, list); - } - - return; - } - } - catch - { - format = null; - } - } - - if (format == null) - { - try - { - var timedtextImage = new TimedTextImage(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (timedtextImage.IsMine(list, fileName)) - { - if (ContinueNewOrExit()) - { - ImportAndOcrDost(fileName, timedtextImage, list); - } - - return; - } - } - catch - { - format = null; - } - } - - if (format == null) - { - try - { - var seImageHtmlIndex = new SeImageHtmlIndex(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (seImageHtmlIndex.IsMine(list, fileName)) - { - if (ContinueNewOrExit()) - { - ImportAndOcrDost(fileName, seImageHtmlIndex, list); - } - - return; - } - } - catch - { - format = null; - } - } - - if (format == null || format.Name == Scenarist.NameOfFormat) - { - try - { - var son = new Son(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (son.IsMine(list, fileName)) - { - if (ContinueNewOrExit()) - { - ImportAndOcrSon(fileName, son, list); - } - - return; - } - } - catch - { - format = null; - } - } - - if (format == null || format.Name == SubRip.NameOfFormat) - { - if (_subtitle.Paragraphs.Count > 1) - { - int imageCount = 0; - foreach (var p in _subtitle.Paragraphs) - { - string s = p.Text.ToLowerInvariant(); - if (s.EndsWith(".bmp", StringComparison.Ordinal) || s.EndsWith(".png", StringComparison.Ordinal) || s.EndsWith(".jpg", StringComparison.Ordinal) || s.EndsWith(".tif", StringComparison.Ordinal)) - { - imageCount++; - } - } - - if (imageCount > 2 && imageCount >= _subtitle.Paragraphs.Count - 2) - { - if (ContinueNewOrExit()) - { - ImportAndOcrSrt(_subtitle); - } - - return; - } - } - } - - if (format == null) - { - try - { - var satBoxPng = new SatBoxPng(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (satBoxPng.IsMine(list, fileName)) - { - var subtitle = new Subtitle(); - satBoxPng.LoadSubtitle(subtitle, list, fileName); - if (ContinueNewOrExit()) - { - ImportAndOcrSrt(subtitle); - } - - return; - } - } - catch - { - format = null; - } - } - - if (format == null || format.Name == Scenarist.NameOfFormat) - { - try - { - var sst = new SonicScenaristBitmaps(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (sst.IsMine(list, fileName)) - { - if (ContinueNewOrExit()) - { - ImportAndOcrSst(fileName, sst, list); - } - - return; - } - } - catch - { - format = null; - } - } - - if (format == null) - { - try - { - var htmlSamiArray = new HtmlSamiArray(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (htmlSamiArray.IsMine(list, fileName)) - { - htmlSamiArray.LoadSubtitle(_subtitle, list, fileName); - _oldSubtitleFormat = htmlSamiArray; - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - SetEncoding(Configuration.Settings.General.DefaultEncoding); - encoding = GetCurrentEncoding(); - justConverted = true; - format = GetCurrentSubtitleFormat(); - } - } - catch - { - format = null; - } - } - - if (format == null) - { - foreach (var f in SubtitleFormat.GetBinaryFormats(false)) - { - if (f.IsMine(null, fileName)) - { - f.LoadSubtitle(_subtitle, null, fileName); - _oldSubtitleFormat = f; - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - SetEncoding(Configuration.Settings.General.DefaultEncoding); - encoding = GetCurrentEncoding(); - justConverted = true; - format = GetCurrentSubtitleFormat(); - break; - } - } - } - - if (format == null) - { - var lines = FileUtil.ReadAllTextShared(fileName, encodingFromFile).SplitToLines(); - foreach (var f in SubtitleFormat.GetTextOtherFormats()) - { - if (f.IsMine(lines, fileName)) - { - f.LoadSubtitle(_subtitle, lines, fileName); - _oldSubtitleFormat = f; - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - SetEncoding(Configuration.Settings.General.DefaultEncoding); - encoding = GetCurrentEncoding(); - justConverted = true; - format = GetCurrentSubtitleFormat(); - break; - } - } - } - - if (format == null && ext == ".cdg" && file.Length < 50_000_000) - { - using (var importCdg = new ImportCdg(fileName)) - { - importCdg.ShowDialog(this); - return; - } - } - - // retry vobsub (file with wrong extension) - if (format == null && file.Length > 500 && IsVobSubFile(fileName, false)) - { - ImportAndOcrVobSubSubtitleNew(fileName, _loading); - return; - } - - // retry Blu-ray (file with wrong extension) - if (format == null && file.Length > 500 && FileUtil.IsBluRaySup(fileName)) - { - ImportAndOcrBluRaySup(fileName, _loading); - return; - } - - // retry SP DVD (file with wrong extension) - if (format == null && file.Length > 500 && FileUtil.IsSpDvdSup(fileName)) - { - ImportAndOcrSpDvdSup(fileName, _loading); - return; - } - - // retry Matroska (file with wrong extension) - if (format == null && !string.IsNullOrWhiteSpace(fileName)) - { - using (var matroska = new MatroskaFile(fileName)) - { - if (matroska.IsValid) - { - var subtitleList = matroska.GetTracks(true); - if (subtitleList.Count > 0) - { - ImportSubtitleFromMatroskaFile(fileName); - return; - } - } - } - } - - // check for idx file - if (format == null && file.Length > 100 && ext == ".idx") - { - MessageBox.Show(_language.ErrorLoadIdx); - return; - } - - // check for .rar file - if (format == null && file.Length > 100 && FileUtil.IsRar(fileName)) - { - MessageBox.Show(_language.ErrorLoadRar); - return; - } - - // check for .zip file - if (format == null && file.Length > 100 && FileUtil.IsZip(fileName)) - { - MessageBox.Show(_language.ErrorLoadZip); - return; - } - - // check for .7z file - if (format == null && file.Length > 100 && FileUtil.Is7Zip(fileName)) - { - MessageBox.Show(_language.ErrorLoad7Zip); - return; - } - - // check for .png file - if (format == null && file.Length > 100 && FileUtil.IsPng(fileName)) - { - MessageBox.Show(_language.ErrorLoadPng); - return; - } - - // check for .jpg file - if (format == null && file.Length > 100 && FileUtil.IsJpg(fileName)) - { - MessageBox.Show(_language.ErrorLoadJpg); - return; - } - - // check for .srr file - if (format == null && file.Length > 100 && ext == ".srr" && FileUtil.IsSrr(fileName)) - { - MessageBox.Show(_language.ErrorLoadSrr); - return; - } - - // check for Torrent file - if (format == null && file.Length > 50 && FileUtil.IsTorrentFile(fileName)) - { - MessageBox.Show(_language.ErrorLoadTorrent); - return; - } - - // check for all binary zeroes (I've heard about this a few times... perhaps related to crashes?) - if (format == null && file.Length > 50 && FileUtil.IsSubtitleFileAllBinaryZeroes(fileName)) - { - MessageBox.Show(_language.ErrorLoadBinaryZeroes); - return; - } - - if (format == null && file.Length < 100 * 1000000 && TransportStreamParser.IsDvbSup(fileName)) - { - ImportSubtitleFromDvbSupFile(fileName); - return; - } - - if (format == null && file.Length < 1000000) - { - // check for valid timed text - if (ext == ".xml" || ext == ".dfxp") - { - var sb = new StringBuilder(); - foreach (var line in File.ReadAllLines(fileName, encodingFromFile)) - { - sb.AppendLine(line); - } - - var xmlAsString = sb.ToString().Trim(); - - if (xmlAsString.Contains("http://www.w3.org/ns/ttml") && xmlAsString.Contains(" 1) - { - _subtitle = genericParseSubtitle; - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - SetEncoding(Configuration.Settings.General.DefaultEncoding); - encoding = GetCurrentEncoding(); - justConverted = true; - format = GetCurrentSubtitleFormat(); - ShowStatus("Guessed subtitle format via generic subtitle parser!"); - } - } - catch - { - } - } - - if (format == null && file.Length < 1_000_000 && (FileUtil.IsPlainText(fileName) || new Tx3GTextOnly().IsMine(null, fileName))) - { - ImportPlainText(fileName); - return; - } - - if (format == null) - { - var fd = new FinalDraftTemplate2(); - var list = new List(File.ReadAllLines(fileName, encodingFromFile)); - if (fd.IsMine(list, fileName)) - { - ImportPlainText(fileName); - return; - } - } - - _fileDateTime = File.GetLastWriteTime(fileName); - - if (format != null) - { - RemoveAlternate(true, false); - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); - - new BookmarkPersistence(_subtitle, fileName).Load(); - - if (Configuration.Settings.General.RemoveBlankLinesWhenOpening) - { - _subtitle.RemoveEmptyLines(); - } - - if (Configuration.Settings.General.RemoveBadCharsWhenOpening) - { - foreach (var p in _subtitle.Paragraphs) - { - // Replace U+0456 (CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I) by U+0069 (LATIN SMALL LETTER I) - p.Text = p.Text.Replace("<і>", "").Replace("", ""); - - // remove control characters (e.g. binary zero) - p.Text = p.Text.RemoveControlCharactersButWhiteSpace(); - } - } - - _subtitleListViewIndex = -1; - Configuration.Settings.General.CurrentVideoOffsetInMs = 0; - - var oldSaveFormat = Configuration.Settings.General.LastSaveAsFormat; - SetCurrentFormat(format); - Configuration.Settings.General.LastSaveAsFormat = oldSaveFormat; - - _subtitleAlternateFileName = null; - if (LoadAlternateSubtitleFile(originalFileName)) - { - _subtitleAlternateFileName = originalFileName; - } - - // Seungki begin - _splitDualSami = false; - if (Configuration.Settings.SubtitleSettings.SamiDisplayTwoClassesAsTwoSubtitles && format.GetType() == typeof(Sami) && Sami.GetStylesFromHeader(_subtitle.Header).Count == 2) - { - var classes = Sami.GetStylesFromHeader(_subtitle.Header); - var s1 = new Subtitle(_subtitle); - var s2 = new Subtitle(_subtitle); - s1.Paragraphs.Clear(); - s2.Paragraphs.Clear(); - foreach (var p in _subtitle.Paragraphs) - { - if (p.Extra != null && p.Extra.Equals(classes[0], StringComparison.OrdinalIgnoreCase)) - { - s1.Paragraphs.Add(p); - } - else - { - s2.Paragraphs.Add(p); - } - } - - if (s1.Paragraphs.Count == 0 || s2.Paragraphs.Count == 0) - { - return; - } - - _subtitle = s1; - _subtitleAlternate = s2; - _subtitleAlternateFileName = _fileName; - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); - SubtitleListview1.ShowAlternateTextColumn(classes[1]); - _splitDualSami = true; - } - // Seungki end - - textBoxSource.Text = _subtitle.ToText(format); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - if (SubtitleListview1.Items.Count > 0) - { - SubtitleListview1.Items[0].Selected = true; - SubtitleListview1.Items[0].Focused = true; - } - textBoxListViewText.BackColor = SystemColors.WindowFrame; - textBoxListViewTextAlternate.BackColor = SystemColors.WindowFrame; - - _findHelper = null; - _spellCheckForm = null; - - if (_resetVideo && ModifierKeys != Keys.Shift) - { - VideoFileName = null; - _videoInfo = null; - VideoAudioTrackNumber = -1; - labelVideoInfo.Text = _languageGeneral.NoVideoLoaded; - audioVisualizer.WavePeaks = null; - audioVisualizer.SetSpectrogram(null); - audioVisualizer.SceneChanges = new List(); - audioVisualizer.Chapters = new List(); - } - - if (Configuration.Settings.General.ShowVideoPlayer || Configuration.Settings.General.ShowAudioVisualizer) - { - if (!Configuration.Settings.General.DisableVideoAutoLoading) - { - if (!string.IsNullOrEmpty(videoFileName) && File.Exists(videoFileName)) - { - OpenVideo(videoFileName); - } - else if (!string.IsNullOrEmpty(fileName) && (toolStripButtonToggleVideo.Checked || toolStripButtonToggleWaveform.Checked)) - { - TryToFindAndOpenVideoFile(Utilities.GetPathAndFileNameWithoutExtension(fileName)); - } - - if (VideoFileName == null) - { - CloseVideoToolStripMenuItemClick(this, null); - } - } - } - - videoFileLoaded = VideoFileName != null; - - Configuration.Settings.RecentFiles.Add(fileName, videoFileName, originalFileName); - UpdateRecentFilesUI(); - - _fileName = fileName; - SetTitle(); - ShowStatus(string.Format(_language.LoadedSubtitleX, _fileName)); - _sourceViewChange = false; - - if (Configuration.Settings.General.AutoConvertToUtf8) - { - if (Configuration.Settings.General.DefaultEncoding == TextEncoding.Utf8WithoutBom) - { - SetEncoding(TextEncoding.Utf8WithoutBom); - } - else - { - SetEncoding(TextEncoding.Utf8WithBom); - } - } - else if (encoding == Encoding.UTF8) - { - if (File.Exists(_fileName) && FileUtil.HasUtf8Bom(fileName)) - { - SetEncoding(TextEncoding.Utf8WithBom); - } - else - { - SetEncoding(TextEncoding.Utf8WithoutBom); - } - } - else - { - SetEncoding(encoding); - } - - _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - _converted = false; - ResetHistory(); - SetListViewStateImages(); - SetUndockedWindowsTitle(); - - if (justConverted) - { - _converted = true; - ShowStatus(string.Format(_language.LoadedSubtitleX, _fileName) + " - " + string.Format(_language.ConvertedToX, format.FriendlyName)); - } - - var formatType = format.GetType(); - if (formatType == typeof(SubStationAlpha)) - { - string errors = AdvancedSubStationAlpha.CheckForErrors(_subtitle.Header); - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(this, errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - - errors = (format as SubStationAlpha).Errors; - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(this, errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - else if (formatType == typeof(AdvancedSubStationAlpha)) - { - string errors = AdvancedSubStationAlpha.CheckForErrors(_subtitle.Header); - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(this, errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - - errors = (format as AdvancedSubStationAlpha).Errors; - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(this, errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - else if (formatType == typeof(SubRip)) - { - string errors = (format as SubRip).Errors; - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(this, errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - else if (formatType == typeof(MicroDvd)) - { - string errors = (format as MicroDvd).Errors; - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(this, errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - else if (formatType == typeof(DCinemaSmpte2007)) - { - format.ToText(_subtitle, string.Empty); - string errors = (format as DCinemaSmpte2007).Errors; - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - else if (formatType == typeof(DCinemaSmpte2010)) - { - format.ToText(_subtitle, string.Empty); - string errors = (format as DCinemaSmpte2010).Errors; - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - else if (formatType == typeof(DCinemaSmpte2014)) - { - format.ToText(_subtitle, string.Empty); - string errors = (format as DCinemaSmpte2014).Errors; - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - else if (formatType == typeof(CsvNuendo)) - { - if (_subtitle.Paragraphs.Any(p => !string.IsNullOrEmpty(p.Actor))) - { - bool wasVisible = SubtitleListview1.ColumnIndexActor >= 0; - SubtitleListview1.ShowActorColumn(Configuration.Settings.Language.General.Character); - if (!wasVisible) - { - SaveSubtitleListviewIndices(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - } - } - else - { - if (file.Length < 50) - { - _findHelper = null; - _spellCheckForm = null; - VideoFileName = null; - _videoInfo = null; - VideoAudioTrackNumber = -1; - labelVideoInfo.Text = _languageGeneral.NoVideoLoaded; - audioVisualizer.WavePeaks = null; - audioVisualizer.SetSpectrogram(null); - audioVisualizer.SceneChanges = new List(); - audioVisualizer.Chapters = new List(); - - Configuration.Settings.RecentFiles.Add(fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - Configuration.Settings.Save(); - UpdateRecentFilesUI(); - _fileName = fileName; - SetTitle(); - ShowStatus(string.Format(_language.LoadedEmptyOrShort, _fileName)); - _sourceViewChange = false; - _converted = false; - - MessageBox.Show(_language.FileIsEmptyOrShort); - } - else - { - if (ShowUnknownSubtitle(fileName, true)) - { - ImportPlainText(fileName); - } - - return; - } - } - - if (!videoFileLoaded && mediaPlayer.VideoPlayer != null) - { - mediaPlayer.PauseAndDisposePlayer(); - timer1.Stop(); - } - - ResetShowEarlierOrLater(); - FixRightToLeftDependingOnLanguage(); - } - - private void ShowHideTextBasedFeatures(SubtitleFormat format) - { - textBoxSource.Enabled = format?.IsTextBased == true; - } - - private void SetUndockedWindowsTitle() - { - string title = _languageGeneral.NoVideoLoaded; - if (!string.IsNullOrEmpty(VideoFileName)) - { - title = Path.GetFileNameWithoutExtension(VideoFileName); - } - - if (_videoControlsUndocked != null && !_videoControlsUndocked.IsDisposed) - { - _videoControlsUndocked.Text = string.Format(_languageGeneral.ControlsWindowTitle, title); - } - - if (_videoPlayerUndocked != null && !_videoPlayerUndocked.IsDisposed) - { - _videoPlayerUndocked.Text = string.Format(_languageGeneral.VideoWindowTitle, title); - } - - if (_waveformUndocked != null && !_waveformUndocked.IsDisposed) - { - _waveformUndocked.Text = string.Format(_languageGeneral.AudioWindowTitle, title); - } - } - - private void ImportAndOcrBdnXml(string fileName, BdnXml bdnXml, List list) - { - using (var formSubOcr = new VobSubOcr()) - { - var bdnSubtitle = new Subtitle(); - bdnXml.LoadSubtitle(bdnSubtitle, list, fileName); - bdnSubtitle.FileName = fileName; - formSubOcr.Initialize(bdnSubtitle, Configuration.Settings.VobSubOcr, false); - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportingBdnXml); - FileNew(); - _subtitle.Paragraphs.Clear(); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = Path.ChangeExtension(formSubOcr.FileName, GetCurrentSubtitleFormat().Extension); - SetTitle(); - _converted = true; - } - } - } - - private void ImportAndOcrSon(string fileName, Son format, List list) - { - using (var formSubOcr = new VobSubOcr()) - { - var sub = new Subtitle(); - format.LoadSubtitle(sub, list, fileName); - sub.FileName = fileName; - formSubOcr.Initialize(sub, Configuration.Settings.VobSubOcr, true); - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportingBdnXml); - FileNew(); - _subtitle.Paragraphs.Clear(); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = Path.ChangeExtension(formSubOcr.FileName, GetCurrentSubtitleFormat().Extension); - SetTitle(); - _converted = true; - } - } - } - - private void ImportAndOcrDost(string fileName, SubtitleFormat format, List list) - { - using (var formSubOcr = new VobSubOcr()) - { - var sub = new Subtitle(); - format.LoadSubtitle(sub, list, fileName); - sub.FileName = fileName; - formSubOcr.Initialize(sub, Configuration.Settings.VobSubOcr, false); - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportingBdnXml); - FileNew(); - _subtitle.Paragraphs.Clear(); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = Path.ChangeExtension(formSubOcr.FileName, GetCurrentSubtitleFormat().Extension); - SetTitle(); - _converted = true; - } - } - } - - private void ImportAndOcrSst(string fileName, SonicScenaristBitmaps format, List list) - { - using (var formSubOcr = new VobSubOcr()) - { - var sub = new Subtitle(); - format.LoadSubtitle(sub, list, fileName); - sub.FileName = fileName; - formSubOcr.Initialize(sub, Configuration.Settings.VobSubOcr, true); - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportingBdnXml); - FileNew(); - _subtitle.Paragraphs.Clear(); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = Path.ChangeExtension(formSubOcr.FileName, GetCurrentSubtitleFormat().Extension); - SetTitle(); - _converted = true; - } - } - } - - private void ImportAndOcrSrt(Subtitle subtitle) - { - using (var formSubOcr = new VobSubOcr()) - { - formSubOcr.Initialize(subtitle, Configuration.Settings.VobSubOcr, false); - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportingBdnXml); - FileNew(); - _subtitle.Paragraphs.Clear(); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = Path.ChangeExtension(formSubOcr.FileName, GetCurrentSubtitleFormat().Extension); - SetTitle(); - _converted = true; - } - } - } - - private bool ShowUnknownSubtitle(string fileName, bool allowImportPlainText = false) - { - using (var unknownSubtitle = new UnknownSubtitle()) - { - unknownSubtitle.Initialize(Title, fileName, allowImportPlainText); - unknownSubtitle.ShowDialog(this); - return unknownSubtitle.ImportPlainText; - } - } - - private void UpdateRecentFilesUI() - { - var dropDownItems = new List(); - reopenToolStripMenuItem.DropDownItems.Clear(); - if (Configuration.Settings.General.ShowRecentFiles && Configuration.Settings.RecentFiles.Files.Count > 0) - { - reopenToolStripMenuItem.Visible = true; - var lowerFileNameList = new List(); - foreach (var file in Configuration.Settings.RecentFiles.Files) - { - if (!string.IsNullOrEmpty(file.OriginalFileName) && File.Exists(file.OriginalFileName)) - { - dropDownItems.Add(new ToolStripMenuItem(file.FileName + " + " + file.OriginalFileName, null, ReopenSubtitleToolStripMenuItemClick) { Tag = file.FileName }); - } - else - { - if (!lowerFileNameList.Contains(file.FileName.ToLowerInvariant())) - { - dropDownItems.Add(new ToolStripMenuItem(file.FileName, null, ReopenSubtitleToolStripMenuItemClick) { Tag = file.FileName }); - lowerFileNameList.Add(file.FileName.ToLowerInvariant()); - } - } - UiUtil.FixFonts(dropDownItems[dropDownItems.Count - 1]); - } - reopenToolStripMenuItem.DropDownItems.AddRange(dropDownItems.ToArray()); - } - else - { - Configuration.Settings.RecentFiles.Files.Clear(); - reopenToolStripMenuItem.Visible = false; - } - - reopenToolStripMenuItem.Visible = reopenToolStripMenuItem.DropDownItems.Count > 0; - } - - private void RemoveNotExistingFilesFromRecentFilesUI() - { - if (!Configuration.Settings.General.ShowRecentFiles || Configuration.Settings.RecentFiles.Files.Count == 0) - { - return; - } - - var bw = new BackgroundWorker(); - bw.DoWork += (sender, args) => - { - var recentFilesList = (List)args.Argument; - var notExistingFiles = new List(); - foreach (var entry in recentFilesList) - { - if (!File.Exists(entry.FileName)) - { - notExistingFiles.Add(entry.FileName); - } - } - - args.Result = notExistingFiles; - }; - bw.RunWorkerCompleted += (sender, args) => - { - var notExistingFiles = (List)args.Result; - if (notExistingFiles.Count == 0) - { - return; - } - - try - { - Configuration.Settings.RecentFiles.Files = Configuration.Settings.RecentFiles.Files - .Where(p => !notExistingFiles.Contains(p.FileName)).ToList(); - for (var index = reopenToolStripMenuItem.DropDownItems.Count - 1; index >= 0; index--) - { - ToolStripItem item = reopenToolStripMenuItem.DropDownItems[index]; - if (notExistingFiles.Contains((string)item.Tag)) - { - reopenToolStripMenuItem.DropDownItems.RemoveAt(index); - } - } - } - catch - { - // ignore - } - }; - bw.RunWorkerAsync(Configuration.Settings.RecentFiles.Files); - } - - private void ReopenSubtitleToolStripMenuItemClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - var item = sender as ToolStripItem; - - if (ContinueNewOrExit()) - { - if (!string.IsNullOrEmpty(_fileName)) - { - Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - } - - RecentFileEntry rfe = null; - foreach (var file in Configuration.Settings.RecentFiles.Files.Where(p => !string.IsNullOrEmpty(p.OriginalFileName))) - { - if ((file.FileName + " + " + file.OriginalFileName).Equals(item.Text, StringComparison.OrdinalIgnoreCase)) - { - rfe = file; - break; - } - } - - if (rfe == null) - { - foreach (var file in Configuration.Settings.RecentFiles.Files.Where(p => string.IsNullOrEmpty(p.OriginalFileName))) - { - if (file.FileName.Equals(item.Text, StringComparison.OrdinalIgnoreCase)) - { - rfe = file; - RemoveAlternate(true, false); - break; - } - } - } - - SubtitleListview1.BeginUpdate(); - if (rfe == null) - { - OpenSubtitle(item.Text, null); - } - else - { - OpenRecentFile(rfe); - } - - GotoSubPosAndPause(); - SetRecentIndices(rfe); - SubtitleListview1.EndUpdate(); - if (rfe != null && !string.IsNullOrEmpty(rfe.VideoFileName)) - { - var p = _subtitle.GetParagraphOrDefault(rfe.FirstSelectedIndex); - if (p != null) - { - mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; - } - } - } - } - - private void OpenRecentFile(RecentFileEntry rfe) - { - OpenSubtitle(rfe.FileName, null, rfe.VideoFileName, rfe.OriginalFileName, false); - Configuration.Settings.General.CurrentVideoOffsetInMs = rfe.VideoOffsetInMs; - if (rfe.VideoOffsetInMs != 0) - { - _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-Configuration.Settings.General.CurrentVideoOffsetInMs)); - _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - _subtitleAlternate.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-Configuration.Settings.General.CurrentVideoOffsetInMs)); - _changeAlternateSubtitleHash = _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - else - { - SubtitleListview1.Fill(_subtitle); - } - } - } - - private void GotoSubPosAndPause() - { - if (!string.IsNullOrEmpty(VideoFileName)) - { - _videoLoadedGoToSubPosAndPause = true; - } - else - { - mediaPlayer.SubtitleText = string.Empty; - } - } - - private void SetRecentIndices(RecentFileEntry rfe) - { - if (!Configuration.Settings.General.RememberSelectedLine) - { - return; - } - - ShowSubtitleTimer.Stop(); - Application.DoEvents(); - if (rfe != null && !string.IsNullOrEmpty(rfe.FileName) && - rfe.FirstSelectedIndex >= 0 && rfe.FirstSelectedIndex < SubtitleListview1.Items.Count) - { - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - SubtitleListview1.SelectIndexAndEnsureVisible(rfe.FirstSelectedIndex, true); - _subtitleListViewIndex = -1; - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - RefreshSelectedParagraph(); - } - - if (!_loading) - { - ShowSubtitleTimer.Start(); - } - } - - private void SaveToolStripMenuItemClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - return; - } - - ReloadFromSourceView(); - _saveAsCalled = false; - SaveSubtitle(GetCurrentSubtitleFormat()); - } - - private void SaveAsToolStripMenuItemClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - return; - } - - ReloadFromSourceView(); - FileSaveAs(true); - } - - private DialogResult FileSaveAs(bool allowUsingLastSaveAsFormat) - { - SubtitleFormat currentFormat = null; - if (allowUsingLastSaveAsFormat && !string.IsNullOrEmpty(Configuration.Settings.General.LastSaveAsFormat)) - { - currentFormat = Utilities.GetSubtitleFormatByFriendlyName(Configuration.Settings.General.LastSaveAsFormat); - } - - if (currentFormat == null) - { - currentFormat = GetCurrentSubtitleFormat(); - } - - UiUtil.SetSaveDialogFilter(saveFileDialog1, currentFormat); - - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*" + currentFormat.Extension; - saveFileDialog1.AddExtension = true; - - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - if (!string.IsNullOrWhiteSpace(_fileName) && Configuration.Settings.General.SaveAsUseFileNameFrom.Equals("file", StringComparison.OrdinalIgnoreCase)) - { - saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(_fileName); - saveFileDialog1.InitialDirectory = Path.GetDirectoryName(_fileName); - } - else if (!string.IsNullOrEmpty(VideoFileName) && Configuration.Settings.General.SaveAsUseFileNameFrom.Equals("video", StringComparison.OrdinalIgnoreCase)) - { - if (_converted && !string.IsNullOrEmpty(_fileName) && !File.Exists(_fileName)) - { - saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(_fileName); - } - else - { - saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(VideoFileName); - } - - saveFileDialog1.InitialDirectory = Path.GetDirectoryName(VideoFileName); - } - else if (!string.IsNullOrWhiteSpace(_fileName)) - { - saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(_fileName); - saveFileDialog1.InitialDirectory = Path.GetDirectoryName(_fileName); - } - else if (!string.IsNullOrEmpty(VideoFileName)) - { - saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(VideoFileName); - saveFileDialog1.InitialDirectory = Path.GetDirectoryName(VideoFileName); - } - else - { - saveFileDialog1.FileName = string.Empty; - } - - if (!string.IsNullOrEmpty(saveFileDialog1.FileName) && - saveFileDialog1.FileName.Contains('.') && - !saveFileDialog1.FileName.EndsWith(currentFormat.Extension, StringComparison.OrdinalIgnoreCase)) - { - saveFileDialog1.FileName = saveFileDialog1.FileName + currentFormat.Extension; - } - - var result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - _converted = false; - _fileName = saveFileDialog1.FileName; - _fileDateTime = File.GetLastWriteTime(_fileName); - SetTitle(); - MakeHistoryForUndo(_language.Menu.File.SaveAs); - - int index = 0; - foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) - { - if (saveFileDialog1.FilterIndex == index + 1) - { - // only allow current extension or ".txt" - string ext = Path.GetExtension(_fileName).ToLowerInvariant(); - bool extOk = ext.Equals(format.Extension, StringComparison.OrdinalIgnoreCase) || format.AlternateExtensions.Contains(ext) || ext == ".txt"; - if (!extOk) - { - if (_fileName.EndsWith('.')) - { - _fileName = _fileName.Substring(0, _fileName.Length - 1); - } - - _fileName += format.Extension; - } - - _saveAsCalled = true; - if (SaveSubtitle(format) == DialogResult.OK) - { - Configuration.Settings.General.LastSaveAsFormat = format.Name; - SetCurrentFormat(format); - Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - Configuration.Settings.Save(); - UpdateRecentFilesUI(); - } - - break; - } - - index++; - } - - _converted = false; - } - - return result; - } - - private DialogResult SaveSubtitle(SubtitleFormat format, bool useNewLineWithOnly0A = false, bool skipPrompts = false) - { - if (string.IsNullOrEmpty(_fileName) || _converted) - { - return FileSaveAs(false); - } - - try - { - var sub = GetSaveSubtitle(_subtitle); - - if (format != null && !format.IsTextBased) - { - if (format is Ebu ebu) - { - var header = new Ebu.EbuGeneralSubtitleInformation(); - if (_subtitle != null && _subtitle.Header != null && (_subtitle.Header.Contains("STL2") || _subtitle.Header.Contains("STL3"))) - { - header = Ebu.ReadHeader(Encoding.UTF8.GetBytes(_subtitle.Header)); - } - - if (ebu.Save(_fileName, sub, !_saveAsCalled, header)) - { - _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - Configuration.Settings.Save(); - } - } - - return DialogResult.OK; - } - - string allText = sub.ToText(format); - - // Seungki begin - if (_splitDualSami && _subtitleAlternate?.Paragraphs.Count > 0) - { - var s = new Subtitle(_subtitle); - foreach (var p in _subtitleAlternate.Paragraphs) - { - s.Paragraphs.Add(p); - } - - allText = s.ToText(format); - } - // Seungki end - - var currentEncoding = GetCurrentEncoding(); - bool isUnicode = currentEncoding.Equals(Encoding.Unicode) || currentEncoding.Equals(Encoding.UTF32) || currentEncoding.Equals(Encoding.GetEncoding(12001)) || currentEncoding.Equals(Encoding.UTF7) || currentEncoding.Equals(Encoding.UTF8); - if (!isUnicode) - { - if (!skipPrompts && currentEncoding.GetString(currentEncoding.GetBytes(allText)) != allText) - { - if (MessageBox.Show(string.Format(_language.UnicodeMusicSymbolsAnsiWarning), Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return DialogResult.No; - } - } - - allText = NormalizeUnicode(allText, currentEncoding); - } - - bool containsNegativeTime = false; - var negativeTimeLines = new List(); - foreach (var p in sub.Paragraphs) - { - if (p.StartTime.TotalMilliseconds < 0 || p.EndTime.TotalMilliseconds < 0) - { - containsNegativeTime = true; - negativeTimeLines.Add(sub.Paragraphs.IndexOf(p).ToString(CultureInfo.InvariantCulture)); - if (negativeTimeLines.Count > 10) - { - negativeTimeLines[negativeTimeLines.Count - 1] = negativeTimeLines[negativeTimeLines.Count - 1] + "..."; - break; - } - } - } - - if (containsNegativeTime && !skipPrompts) - { - if (MessageBox.Show(_language.NegativeTimeWarning + Environment.NewLine + - string.Format(Configuration.Settings.Language.MultipleReplace.LinesFoundX, string.Join(", ", negativeTimeLines)), - Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return DialogResult.No; - } - } - - if (!skipPrompts && File.Exists(_fileName)) - { - var fileInfo = new FileInfo(_fileName); - var fileOnDisk = fileInfo.LastWriteTime; - if (_fileDateTime != fileOnDisk && _fileDateTime != new DateTime()) - { - if (MessageBox.Show(string.Format(_language.OverwriteModifiedFile, - _fileName, fileOnDisk.ToShortDateString(), fileOnDisk.ToString("HH:mm:ss"), - Environment.NewLine, _fileDateTime.ToShortDateString(), _fileDateTime.ToString("HH:mm:ss")), - Title + " - " + _language.FileOnDiskModified, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return DialogResult.No; - } - } - - if (fileInfo.IsReadOnly) - { - MessageBox.Show(string.Format(_language.FileXIsReadOnly, _fileName)); - return DialogResult.No; - } - } - - // force encoding - var formatType = format.GetType(); - if (formatType == typeof(WebVTT) || formatType == typeof(WebVTTFileWithLineNumber)) - { - SetEncoding(Encoding.UTF8); - currentEncoding = Encoding.UTF8; - } - else if (formatType == typeof(SwiftInterchange2)) - { - SetEncoding(Encoding.Unicode); - currentEncoding = Encoding.Unicode; - } - - if (Configuration.Settings.General.ShowFormatRequiresUtf8Warning && !currentEncoding.Equals(Encoding.UTF8) && - (formatType == typeof(DCinemaInterop) || formatType == typeof(DCinemaSmpte2007) || - formatType == typeof(DCinemaSmpte2010) || formatType == typeof(DCinemaSmpte2014))) - { - using (var form = new DialogDoNotShowAgain(Title, string.Format(_language.FormatXShouldUseUft8, GetCurrentSubtitleFormat().FriendlyName))) - { - form.ShowDialog(this); - Configuration.Settings.General.ShowFormatRequiresUtf8Warning = !form.DoNoDisplayAgain; - } - } - - if (format.Extension == ".rtf" || formatType == typeof(ProjectionSubtitleList)) - { - var enc = GetCurrentEncoding(); - if (enc != Encoding.ASCII) - { - var oldDisableShowStatus = _disableShowStatus; - _disableShowStatus = false; - ShowStatus("ASCII encoding used for save"); - _disableShowStatus = oldDisableShowStatus; - currentEncoding = Encoding.ASCII; - } - } - - if (useNewLineWithOnly0A) - { - allText = allText.Replace("\r\n", "\n"); - } - - if (formatType == typeof(ItunesTimedText) || formatType == typeof(ScenaristClosedCaptions) || formatType == typeof(ScenaristClosedCaptionsDropFrame)) - { - var outputEnc = new UTF8Encoding(false); // create encoding with no BOM - using (var file = new StreamWriter(_fileName, false, outputEnc)) // open file with encoding - { - file.Write(allText); - } - } - else if (Equals(currentEncoding, Encoding.UTF8) && (formatType == typeof(TmpegEncAW5) || formatType == typeof(TmpegEncXml))) - { - var outputEnc = new UTF8Encoding(false); // create encoding with no BOM - using (var file = new StreamWriter(_fileName, false, outputEnc)) // open file with encoding - { - file.Write(allText); - } - } - else - { - if (string.IsNullOrWhiteSpace(allText)) - { - MessageBox.Show(string.Format(_language.UnableToSaveSubtitleX, _fileName), String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Stop); - return DialogResult.Cancel; - } - - if (comboBoxEncoding.SelectedIndex == TextEncoding.Utf8WithoutBomIndex) - { - var outputEnc = new UTF8Encoding(false); // create encoding with no BOM - using (var file = new StreamWriter(_fileName, false, outputEnc)) // open file with encoding - { - file.Write(allText); - } - } - else - { - // create file - includes BOM for Unicode formats - using (var fs = new FileStream(_fileName, FileMode.Create, FileAccess.Write, FileShare.Read)) - using (var sw = new StreamWriter(fs, currentEncoding)) - { - sw.Write(allText); - } - } - } - - Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - Configuration.Settings.Save(); - new BookmarkPersistence(_subtitle, _fileName).Save(); - _fileDateTime = File.GetLastWriteTime(_fileName); - ShowStatus(string.Format(_language.SavedSubtitleX, _fileName)); - if (formatType == typeof(NetflixTimedText)) - { - NetflixGlyphCheck(true); - } - - _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - return DialogResult.OK; - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - return DialogResult.Cancel; - } - } - - private DialogResult SaveOriginalSubtitle(SubtitleFormat format, bool skipPrompts = false) - { - try - { - var subAlt = GetSaveSubtitle(_subtitleAlternate); - - bool containsNegativeTime = false; - foreach (var p in subAlt.Paragraphs) - { - if (p.StartTime.TotalMilliseconds < 0 || p.EndTime.TotalMilliseconds < 0) - { - containsNegativeTime = true; - break; - } - } - - if (!skipPrompts && containsNegativeTime) - { - if (MessageBox.Show(_language.NegativeTimeWarning, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return DialogResult.No; - } - } - - if (format != null && !format.IsTextBased) - { - if (format is Ebu ebu) - { - if (ebu.Save(_subtitleAlternateFileName, subAlt)) - { - Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - Configuration.Settings.Save(); - ShowStatus(string.Format(_language.SavedOriginalSubtitleX, _subtitleAlternateFileName)); - _changeAlternateSubtitleHash = _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName); - return DialogResult.OK; - } - - return DialogResult.No; - } - - MessageBox.Show("Ups - save original does not support this format - please go to Github and create an issue!"); - } - - string allText = subAlt.ToText(format); - var currentEncoding = GetCurrentEncoding(); - bool isUnicode = currentEncoding != null && (currentEncoding.Equals(Encoding.Unicode) || currentEncoding.Equals(Encoding.UTF32) || currentEncoding.Equals(Encoding.UTF7) || currentEncoding.Equals(Encoding.UTF8)); - if (!skipPrompts && !isUnicode && currentEncoding.GetString(currentEncoding.GetBytes(allText)) != allText) - { - if (MessageBox.Show(string.Format(_language.UnicodeMusicSymbolsAnsiWarning), Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return DialogResult.No; - } - } - - if (!isUnicode) - { - allText = NormalizeUnicode(allText, currentEncoding); - } - - File.WriteAllText(_subtitleAlternateFileName, allText, currentEncoding); - ShowStatus(string.Format(_language.SavedOriginalSubtitleX, _subtitleAlternateFileName)); - _changeAlternateSubtitleHash = _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName); - return DialogResult.OK; - } - catch - { - MessageBox.Show(string.Format(_language.UnableToSaveSubtitleX, _fileName)); - return DialogResult.Cancel; - } - } - - public string NormalizeUnicode(string input, Encoding encoding) - { - const char defHyphen = '-'; // - Hyphen-minus (\u002D) (Basic Latin) - const char defColon = ':'; // : Colon (\u003A) (Basic Latin) - - var text = input; - - bool hasSingleMusicNode = true; - if (encoding.GetString(encoding.GetBytes("♪")) != "♪") - { - text = text.Replace('♪', '#'); - hasSingleMusicNode = false; - } - - if (encoding.GetString(encoding.GetBytes("♫")) != "♫") - { - text = text.Replace('♫', hasSingleMusicNode ? '♪' : '#'); - } - - // Hyphens - return text.Replace('\u2043', defHyphen) // ⁃ Hyphen bullet (\u2043) - .Replace('\u2010', defHyphen) // ‐ Hyphen (\u2010) - .Replace('\u2012', defHyphen) // ‒ Figure dash (\u2012) - .Replace('\u2013', defHyphen) // – En dash (\u2013) - .Replace('\u2014', defHyphen) // — Em dash (\u2014) - .Replace('\u2015', defHyphen) // ― Horizontal bar (\u2015) - - // Colons: - .Replace('\u02F8', defColon) // ˸ Modifier Letter Raised Colon (\u02F8) - .Replace('\uFF1A', defColon) // : Fullwidth Colon (\uFF1A) - .Replace('\uFE13', defColon) // ︓ Presentation Form for Vertical Colon (\uFE13) - - // Others - .Replace("…", "...") - .Replace("⇒", "=>") - - // Spaces - .Replace('\u00A0', ' ') // No-Break Space - .Replace("\u200B", string.Empty) // Zero Width Space - .Replace("\uFEFF", string.Empty) // Zero Width No-Break Space - - // Intellectual property - .Replace("\u00A9", "(Copyright)") // © copyright - .Replace("\u2117", "(Sound-recording Copyright)") // ℗ sound-recording copyright - .Replace("\u00AE", "(Registered Trademark)") // ® registered trademark - .Replace("\u2120", "(Service Mark)") // ℠ service mark - .Replace("\u2122", "(Trademark)") // ™ trademark - - // RTL/LTR markers - .Replace("\u202B", string.Empty) // ‏ - .Replace("\u202A", string.Empty); // &lmr; - } - - private void NewToolStripMenuItemClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - FileNew(); - } - - private void ResetSubtitle(bool forceVideoReload = false) - { - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - - labelStartTimeWarning.Text = string.Empty; - labelDurationWarning.Text = string.Empty; - - Configuration.Settings.General.CurrentVideoOffsetInMs = 0; - _subtitle = new Subtitle(_subtitle.HistoryItems); - _changeAlternateSubtitleHash = -1; - _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - _subtitleAlternateFileName = null; - textBoxSource.Text = string.Empty; - SubtitleListview1.Items.Clear(); - _fileName = string.Empty; - _fileDateTime = new DateTime(); - _oldSubtitleFormat = null; - labelSingleLine.Text = string.Empty; - buttonSplitLine.Visible = false; - labelSingleLinePixels.Text = string.Empty; - RemoveAlternate(true, false); - _splitDualSami = false; - - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); - - var oldDisableShowStatus = _disableShowStatus; - _disableShowStatus = true; - ComboBoxSubtitleFormatsSelectedIndexChanged(null, null); - _disableShowStatus = oldDisableShowStatus; - - SetEncoding(Configuration.Settings.General.DefaultEncoding); - - toolStripComboBoxFrameRate.Text = Configuration.Settings.General.DefaultFrameRate.ToString(); - _findHelper = null; - _spellCheckForm = null; - - if (ModifierKeys != Keys.Shift || forceVideoReload) - { - VideoFileName = null; - _videoInfo = null; - VideoAudioTrackNumber = -1; - labelVideoInfo.Text = _languageGeneral.NoVideoLoaded; - audioVisualizer.WavePeaks = null; - audioVisualizer.SetSpectrogram(null); - audioVisualizer.SceneChanges = new List(); - audioVisualizer.Chapters = new List(); - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.PauseAndDisposePlayer(); - } - - timeUpDownVideoPositionAdjust.TimeCode = new TimeCode(); - timeUpDownVideoPositionAdjust.Enabled = false; - timeUpDownVideoPosition.TimeCode = new TimeCode(); - timeUpDownVideoPosition.Enabled = false; - trackBarWaveformPosition.Value = 0; - timeUpDownStartTime.TimeCode = new TimeCode(); - numericUpDownDuration.Value = 0; - } - - _sourceViewChange = false; - - _subtitleListViewIndex = -1; - textBoxListViewText.Text = string.Empty; - textBoxListViewTextAlternate.Text = string.Empty; - textBoxListViewText.Enabled = false; - textBoxListViewText.BackColor = SystemColors.ActiveBorder; - textBoxListViewTextAlternate.BackColor = SystemColors.ActiveBorder; - labelTextLineLengths.Text = string.Empty; - labelCharactersPerSecond.Text = string.Empty; - labelTextLineTotal.Text = string.Empty; - - _listViewTextUndoLast = null; - _listViewAlternateTextUndoLast = null; - _listViewTextUndoIndex = -1; - - _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - _converted = false; - - SetTitle(); - SetUndockedWindowsTitle(); - mediaPlayer.SubtitleText = string.Empty; - labelNextWord.Visible = false; - ShowStatus(_language.New); - - ResetShowEarlierOrLater(); - - // Set default RTL or LTR - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - textBoxListViewTextAlternate.RightToLeft = Configuration.Settings.General.RightToLeftMode ? RightToLeft.Yes : RightToLeft.No; - } - - if (Configuration.Settings.General.RightToLeftMode) - { - textBoxListViewText.RightToLeft = RightToLeft.Yes; - textBoxSource.RightToLeft = RightToLeft.Yes; - } - else - { - textBoxListViewText.RightToLeft = RightToLeft.No; - textBoxSource.RightToLeft = RightToLeft.No; - } - - SetListViewStateImages(); - pictureBoxBookmark.Visible = false; - panelBookmark.Hide(); - } - - private void ResetShowEarlierOrLater() - { - try - { - if (_showEarlierOrLater != null && !_showEarlierOrLater.IsDisposed) - { - _showEarlierOrLater.ResetTotalAdjustment(); - } - } - catch - { - // form closing or alike - } - } - - private void FileNew() - { - if (ContinueNewOrExit()) - { - if (Configuration.Settings.General.ShowRecentFiles) - { - Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - } - - MakeHistoryForUndo(_language.BeforeNew); - ResetSubtitle(true); - } - } - - private void ComboBoxSubtitleFormatsSelectedIndexChanged(object sender, EventArgs e) - { - if (IsMenuOpen) - { - return; - } - - _converted = true; - var format = GetCurrentSubtitleFormat(); - if (format == null) - { - format = new SubRip(); - } - var formatType = format.GetType(); - - if (_oldSubtitleFormat == null) - { - if (!_loading) - { - MakeHistoryForUndo(string.Format(_language.BeforeConvertingToX, format.FriendlyName)); - } - } - else - { - _subtitle.MakeHistoryForUndo(string.Format(_language.BeforeConvertingToX, format.FriendlyName), _oldSubtitleFormat, _fileDateTime, _subtitleAlternate, _subtitleAlternateFileName, _subtitleListViewIndex, textBoxListViewText.SelectionStart, textBoxListViewTextAlternate.SelectionStart); - _oldSubtitleFormat.RemoveNativeFormatting(_subtitle, format); - SaveSubtitleListviewIndices(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - - if (_oldSubtitleFormat.HasStyleSupport) - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); - } - - if (_networkSession == null) - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Network); - } - - if (formatType == typeof(AdvancedSubStationAlpha) && _oldSubtitleFormat.GetType() == typeof(SubStationAlpha)) - { - _subtitle.Header = AdvancedSubStationAlpha.GetHeaderAndStylesFromSubStationAlpha(_subtitle.Header); - } - else if (formatType == typeof(SubStationAlpha) && _oldSubtitleFormat.GetType() == typeof(AdvancedSubStationAlpha)) - { - _subtitle.Header = SubStationAlpha.GetHeaderAndStylesFromAdvancedSubStationAlpha(_subtitle.Header, string.Empty); - } - } - - ShowSource(); - ShowStatus(string.Format(_language.ConvertedToX, format.FriendlyName)); - if (_fileName != null && _oldSubtitleFormat != null && _fileName.EndsWith(_oldSubtitleFormat.Extension, StringComparison.Ordinal)) - { - _fileName = _fileName.Substring(0, _fileName.Length - _oldSubtitleFormat.Extension.Length) + format.Extension; - } - - _oldSubtitleFormat = format; - Configuration.Settings.General.LastSaveAsFormat = format.Name; - - if ((formatType == typeof(AdvancedSubStationAlpha) || - formatType == typeof(SubStationAlpha) || - formatType == typeof(CsvNuendo)) && (_subtitle.Paragraphs.Any(p => !string.IsNullOrEmpty(p.Actor)) || - Configuration.Settings.Tools.ListViewShowColumnActor)) - { - bool wasVisible = SubtitleListview1.ColumnIndexActor >= 0; - if (formatType == typeof(CsvNuendo)) - { - SubtitleListview1.ShowActorColumn(Configuration.Settings.Language.General.Character); - } - else - { - SubtitleListview1.ShowActorColumn(Configuration.Settings.Language.General.Actor); - } - - if (!wasVisible) - { - SaveSubtitleListviewIndices(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Actor); - } - - if (formatType == typeof(TimedText10) && Configuration.Settings.Tools.ListViewShowColumnRegion) - { - SubtitleListview1.ShowRegionColumn(Configuration.Settings.Language.General.Region); - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Region); - } - - if (format.HasStyleSupport) - { - var styles = new List(); - if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha)) - { - styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); - } - else if (formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText)) - { - styles = TimedText10.GetStylesFromHeader(_subtitle.Header); - } - else if (formatType == typeof(Sami) || formatType == typeof(SamiModern)) - { - styles = Sami.GetStylesFromHeader(_subtitle.Header); - if (string.IsNullOrEmpty(_subtitle.Header)) - { - styles = Sami.GetStylesFromSubtitle(_subtitle); - } - else - { - styles = Sami.GetStylesFromHeader(_subtitle.Header); - } - } - else if (format.Name == "Nuendo") - { - styles = GetNuendoStyles(); - } - - if (styles.Count > 0) - { - foreach (var p in _subtitle.Paragraphs) - { - if (string.IsNullOrEmpty(p.Extra)) - { - p.Extra = styles[0]; - } - } - } - - if (formatType == typeof(Sami) || formatType == typeof(SamiModern)) - { - SubtitleListview1.ShowExtraColumn(_languageGeneral.Class); - } - else if (formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText)) - { - SubtitleListview1.ShowExtraColumn(_languageGeneral.StyleLanguage); - } - else if (format.Name == "Nuendo") - { - SubtitleListview1.ShowExtraColumn(_languageGeneral.Character); - } - else - { - SubtitleListview1.ShowExtraColumn(_languageGeneral.Style); - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - ShowHideTextBasedFeatures(format); - - UpdateNetflixGlyphCheckToolsVisibility(); - } - - private static List GetNuendoStyles() - { - if (!string.IsNullOrEmpty(Configuration.Settings.SubtitleSettings.NuendoCharacterListFile) && File.Exists(Configuration.Settings.SubtitleSettings.NuendoCharacterListFile)) - { - return NuendoProperties.LoadCharacters(Configuration.Settings.SubtitleSettings.NuendoCharacterListFile); - } - - return new List(); - } - - private void ComboBoxSubtitleFormatsEnter(object sender, EventArgs e) - { - SubtitleFormat format = GetCurrentSubtitleFormat(); - if (format != null) - { - _oldSubtitleFormat = format; - } - } - - private SubtitleFormat GetCurrentSubtitleFormat() - { - return Utilities.GetSubtitleFormatByFriendlyName(comboBoxSubtitleFormats.SelectedItem.ToString()); - } - - private void ShowSource() - { - if (_subtitle != null && _subtitle.Paragraphs.Count > 0) - { - SubtitleFormat format = GetCurrentSubtitleFormat(); - if (format != null) - { - textBoxSource.TextChanged -= TextBoxSourceTextChanged; - textBoxSource.Text = GetSaveSubtitle(_subtitle).ToText(format); - textBoxSource.TextChanged += TextBoxSourceTextChanged; - return; - } - } - - textBoxSource.TextChanged -= TextBoxSourceTextChanged; - textBoxSource.Text = string.Empty; - textBoxSource.TextChanged += TextBoxSourceTextChanged; - } - - private void SettingsToolStripMenuItemClick(object sender, EventArgs e) - { - ShowSettings(); - } - - private void ShowSettings() - { - string oldVideoPlayer = Configuration.Settings.General.VideoPlayer; - string oldMpvVideoOutput = Configuration.Settings.General.MpvVideoOutputWindows; - string oldListViewLineSeparatorString = Configuration.Settings.General.ListViewLineSeparatorString; - var oldCpsWhiteSpaceSetting = Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace; - string oldSubtitleFontSettings = Configuration.Settings.General.SubtitleFontName + - Configuration.Settings.General.SubtitleTextBoxFontBold + - Configuration.Settings.General.CenterSubtitleInTextBox + - Configuration.Settings.General.SubtitleTextBoxFontSize + - Configuration.Settings.General.SubtitleFontColor.ToArgb() + - Configuration.Settings.General.SubtitleBackgroundColor.ToArgb() + - Configuration.Settings.General.SubtitleListViewFontBold.ToString() + - Configuration.Settings.General.SubtitleListViewFontSize; - - ; - bool oldUseTimeFormatHHMMSSFF = Configuration.Settings.General.UseTimeFormatHHMMSSFF; - - string oldSyntaxColoring = Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall.ToString() + - Configuration.Settings.Tools.ListViewSyntaxColorDurationBig + - Configuration.Settings.Tools.ListViewSyntaxColorLongLines + - Configuration.Settings.Tools.ListViewSyntaxColorOverlap + - Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines + - Configuration.Settings.General.MaxNumberOfLines + - Configuration.Settings.Tools.ListViewSyntaxErrorColor.ToArgb(); - - var oldAllowEditOfOriginalSubtitle = Configuration.Settings.General.AllowEditOfOriginalSubtitle; - var oldShowColumnEndTime = Configuration.Settings.Tools.ListViewShowColumnEndTime; - var oldShowcolumnDuration = Configuration.Settings.Tools.ListViewShowColumnDuration; - var oldShowColumnCharsPerSec = Configuration.Settings.Tools.ListViewShowColumnCharsPerSec; - var oldShowWordsMinColumn = Configuration.Settings.Tools.ListViewShowColumnWordsPerMin; - var oldSubtitleTextBoxSyntaxColor = Configuration.Settings.General.SubtitleTextBoxSyntaxColor; - var oldSubtitleFontSize = Configuration.Settings.General.SubtitleTextBoxFontSize; - var oldSubtitleTextBoxHtmlColor = Configuration.Settings.General.SubtitleTextBoxHtmlColor.ToArgb().ToString(); - var oldSubtitleTextBoxAssaColor = Configuration.Settings.General.SubtitleTextBoxAssColor.ToArgb().ToString(); - using (var settings = new Settings()) - { - settings.Initialize(Icon, toolStripButtonFileNew.Image, toolStripButtonFileOpen.Image, toolStripButtonSave.Image, toolStripButtonSaveAs.Image, toolStripButtonFind.Image, - toolStripButtonReplace.Image, toolStripButtonFixCommonErrors.Image, toolStripButtonRemoveTextForHi.Image, toolStripButtonVisualSync.Image, - toolStripButtonSpellCheck.Image, toolStripButtonNetflixQualityCheck.Image, toolStripButtonSettings.Image, toolStripButtonHelp.Image); - - if (settings.ShowDialog(this) == DialogResult.Cancel) - { - return; // settings update canceled - } - } - - try - { // can have some problems with fonts... - UiUtil.InitializeSubtitleFont(textBoxSource); - UiUtil.InitializeSubtitleFont(textBoxListViewText); - UiUtil.InitializeSubtitleFont(textBoxListViewTextAlternate); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - InitializeToolbar(); - } - catch (Exception exception) - { - System.Diagnostics.Debug.WriteLine(exception.Message + Environment.NewLine + exception.StackTrace); - } - - UpdateRecentFilesUI(); - buttonCustomUrl1.Text = Configuration.Settings.VideoControls.CustomSearchText1; - buttonCustomUrl1.Visible = Configuration.Settings.VideoControls.CustomSearchUrl1.Length > 1; - buttonCustomUrl2.Text = Configuration.Settings.VideoControls.CustomSearchText2; - buttonCustomUrl2.Visible = Configuration.Settings.VideoControls.CustomSearchUrl2.Length > 1; - - SetAudioVisualizerSettings(); - - string newSyntaxColoring = Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall.ToString() + - Configuration.Settings.Tools.ListViewSyntaxColorDurationBig + - Configuration.Settings.Tools.ListViewSyntaxColorLongLines + - Configuration.Settings.Tools.ListViewSyntaxColorOverlap + - Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines + - Configuration.Settings.General.MaxNumberOfLines + - Configuration.Settings.Tools.ListViewSyntaxErrorColor.ToArgb(); - - if (oldSubtitleFontSettings != Configuration.Settings.General.SubtitleFontName + - Configuration.Settings.General.SubtitleTextBoxFontBold + - Configuration.Settings.General.CenterSubtitleInTextBox + - Configuration.Settings.General.SubtitleTextBoxFontSize + - Configuration.Settings.General.SubtitleFontColor.ToArgb() + - Configuration.Settings.General.SubtitleBackgroundColor.ToArgb() + - Configuration.Settings.General.SubtitleListViewFontBold.ToString() + - Configuration.Settings.General.SubtitleListViewFontSize || - oldSyntaxColoring != newSyntaxColoring || - oldShowColumnEndTime != Configuration.Settings.Tools.ListViewShowColumnEndTime || - oldShowcolumnDuration != Configuration.Settings.Tools.ListViewShowColumnDuration || - oldShowColumnCharsPerSec != Configuration.Settings.Tools.ListViewShowColumnCharsPerSec || - oldShowWordsMinColumn != Configuration.Settings.Tools.ListViewShowColumnWordsPerMin) - { - if (Configuration.Settings.Tools.ListViewShowColumnEndTime) - { - SubtitleListview1.ShowEndColumn(Configuration.Settings.Language.General.EndTime); - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.End); - } - - if (Configuration.Settings.Tools.ListViewShowColumnDuration) - { - SubtitleListview1.ShowDurationColumn(Configuration.Settings.Language.General.Duration); - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Duration); - } - - if (Configuration.Settings.Tools.ListViewShowColumnCharsPerSec) - { - SubtitleListview1.ShowCharsSecColumn(Configuration.Settings.Language.General.CharsPerSec); - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); - } - - if (Configuration.Settings.Tools.ListViewShowColumnWordsPerMin) - { - SubtitleListview1.ShowWordsMinColumn(Configuration.Settings.Language.General.WordsPerMin); - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); - } - - try - { // can have some problems with fonts... - UiUtil.InitializeSubtitleFont(textBoxListViewText); - UiUtil.InitializeSubtitleFont(textBoxListViewTextAlternate); - UiUtil.InitializeSubtitleFont(textBoxSource); - SubtitleListview1.SubtitleFontName = Configuration.Settings.General.SubtitleFontName; - SubtitleListview1.SubtitleFontBold = Configuration.Settings.General.SubtitleListViewFontBold; - SubtitleListview1.SubtitleFontSize = Configuration.Settings.General.SubtitleListViewFontSize; - } - catch (Exception exception) - { - System.Diagnostics.Debug.WriteLine(exception.Message + Environment.NewLine + exception.StackTrace); - } - - SubtitleListview1.ForeColor = Configuration.Settings.General.SubtitleFontColor; - SubtitleListview1.BackColor = Configuration.Settings.General.SubtitleBackgroundColor; - - SaveSubtitleListviewIndices(); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.AutoSizeAllColumns(this); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - mediaPlayer.SetSubtitleFont(); - ShowSubtitle(); - } - - mediaPlayer.SetSubtitleFont(); - mediaPlayer.ShowStopButton = Configuration.Settings.General.VideoPlayerShowStopButton; - mediaPlayer.ShowMuteButton = Configuration.Settings.General.VideoPlayerShowMuteButton; - mediaPlayer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton; - - if (oldListViewLineSeparatorString != Configuration.Settings.General.ListViewLineSeparatorString || - oldCpsWhiteSpaceSetting != Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace) - { - SubtitleListview1.InitializeLanguage(_languageGeneral, Configuration.Settings); - SaveSubtitleListviewIndices(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - - if (oldAllowEditOfOriginalSubtitle != Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - AddAlternate(); - } - else - { - RemoveAlternate(false, false); - } - - Main_ResizeEnd(null, null); - } - - SetLanguage(Configuration.Settings.General.Language); - - textBoxListViewTextAlternate.Enabled = Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleListViewIndex >= 0; - - SetShortcuts(); - - CheckAndGetNewlyDownloadedMpvDlls("Please restart to use new libmpv dll"); - - if (!string.IsNullOrEmpty(VideoFileName) && oldVideoPlayer != Configuration.Settings.General.VideoPlayer && mediaPlayer.VideoPlayer != null || - (oldMpvVideoOutput != Configuration.Settings.General.MpvVideoOutputWindows && Configuration.Settings.General.VideoPlayer.Equals("MPV", StringComparison.OrdinalIgnoreCase))) - { - string vfn = VideoFileName; - CloseVideoToolStripMenuItemClick(null, null); - OpenVideo(vfn); - } - - StartOrStopAutoBackup(); - - SetTitle(); - if (Configuration.Settings.VideoControls.GenerateSpectrogram) - { - audioVisualizer.WaveformNotLoadedText = Configuration.Settings.Language.Waveform.ClickToAddWaveformAndSpectrogram; - showhideWaveformToolStripMenuItem.Text = _language.Menu.Video.ShowHideWaveformAndSpectrogram; - } - else - { - audioVisualizer.WaveformNotLoadedText = Configuration.Settings.Language.Waveform.ClickToAddWaveform; - showhideWaveformToolStripMenuItem.Text = _language.Menu.Video.ShowHideWaveform; - } - - audioVisualizer.Invalidate(); - - if (oldUseTimeFormatHHMMSSFF != Configuration.Settings.General.UseTimeFormatHHMMSSFF) - { - RefreshTimeCodeMode(); - } - - if (oldSubtitleTextBoxSyntaxColor != Configuration.Settings.General.SubtitleTextBoxSyntaxColor || - oldSubtitleFontSize != Configuration.Settings.General.SubtitleTextBoxFontSize || - oldSubtitleTextBoxHtmlColor != Configuration.Settings.General.SubtitleTextBoxHtmlColor.ToArgb().ToString() || - oldSubtitleTextBoxAssaColor != Configuration.Settings.General.SubtitleTextBoxAssColor.ToArgb().ToString()) - { - textBoxListViewText.Initialize(Configuration.Settings.General.SubtitleTextBoxSyntaxColor); - textBoxListViewTextAlternate.Initialize(Configuration.Settings.General.SubtitleTextBoxSyntaxColor); - RefreshSelectedParagraph(); - } - textBoxListViewText.BackColor = !IsSubtitleLoaded ? SystemColors.ActiveBorder : SystemColors.WindowFrame; - textBoxListViewTextAlternate.BackColor = !IsSubtitleLoaded ? SystemColors.ActiveBorder : SystemColors.WindowFrame; - - SubtitleListview1.SyntaxColorAllLines(_subtitle); - mediaPlayer.LastParagraph = null; - Application.DoEvents(); - UiUtil.ShowSubtitle(_subtitle, mediaPlayer); - mediaPlayer.VideoPlayerContainerResize(null, null); - ShowLineInformationListView(); - ShowSourceLineNumber(); - } - - private void SetAudioVisualizerSettings() - { - audioVisualizer.ShowGridLines = Configuration.Settings.VideoControls.WaveformDrawGrid; - audioVisualizer.GridColor = Configuration.Settings.VideoControls.WaveformGridColor; - audioVisualizer.SelectedColor = Configuration.Settings.VideoControls.WaveformSelectedColor; - audioVisualizer.Color = Configuration.Settings.VideoControls.WaveformColor; - audioVisualizer.BackgroundColor = Configuration.Settings.VideoControls.WaveformBackgroundColor; - audioVisualizer.TextColor = Configuration.Settings.VideoControls.WaveformTextColor; - audioVisualizer.CursorColor = Configuration.Settings.VideoControls.WaveformCursorColor; - audioVisualizer.ChaptersColor = Configuration.Settings.VideoControls.WaveformChaptersColor; - audioVisualizer.TextSize = Configuration.Settings.VideoControls.WaveformTextSize; - audioVisualizer.TextBold = Configuration.Settings.VideoControls.WaveformTextBold; - audioVisualizer.MouseWheelScrollUpIsForward = Configuration.Settings.VideoControls.WaveformMouseWheelScrollUpIsForward; - audioVisualizer.AllowOverlap = Configuration.Settings.VideoControls.WaveformAllowOverlap; - audioVisualizer.ClosenessForBorderSelection = Configuration.Settings.VideoControls.WaveformBorderHitMs; - } - - private void CheckAndGetNewlyDownloadedMpvDlls(string message) - { - if (Configuration.Settings.General.VideoPlayer != "MPV") - { - return; - } - - var newMpvFiles = Directory.GetFiles(Configuration.DataDirectory, "*.dll.new-mpv"); - if (newMpvFiles.Length <= 0) - { - return; - } - - if (mediaPlayer != null && mediaPlayer.VideoPlayer != null) - { - var mpv = mediaPlayer.VideoPlayer as LibMpvDynamic; - mediaPlayer.VideoPlayer = null; - mpv?.HardDispose(); - } - - foreach (string newDllFileName in newMpvFiles) - { - if (File.Exists(newDllFileName)) // dll was in use, so unload + copy new dll + load - { - try - { - string targetFileName = newDllFileName.Replace(".dll.new-mpv", ".dll"); - File.Copy(newDllFileName, targetFileName, true); - File.Delete(newDllFileName); - ShowStatus("libmpv updated"); - } - catch - { - // ignore - } - } - } - - if (!string.IsNullOrEmpty(message)) - { - MessageBox.Show(message); - } - } - - private void AddAlternate() - { - buttonUnBreak.Visible = false; - buttonAutoBreak.Visible = false; - buttonSplitLine.Visible = false; - textBoxListViewTextAlternate.Visible = true; - labelAlternateText.Visible = true; - labelAlternateCharactersPerSecond.Visible = true; - labelTextAlternateLineLengths.Visible = true; - labelAlternateSingleLine.Visible = true; - labelAlternateSingleLinePixels.Visible = true; - labelTextAlternateLineTotal.Visible = true; - } - - private int ShowSubtitle() - { - if (_splitDualSami) - { - return UiUtil.ShowSubtitle(_subtitle, _subtitleAlternate, mediaPlayer); - } - - if (SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable) - { - return UiUtil.ShowSubtitle(_subtitleAlternate, mediaPlayer); - } - - return UiUtil.ShowSubtitle(_subtitle, mediaPlayer); - } - - private static void TryLoadIcon(ToolStripButton button, string iconName) - { - string fullPath = Configuration.IconsDirectory + iconName + ".png"; - if (File.Exists(fullPath)) - { - button.Image = new Bitmap(fullPath); - } - } - - private void InitializeToolbar() - { - var gs = Configuration.Settings.General; - - TryLoadIcon(toolStripButtonFileNew, "New"); - TryLoadIcon(toolStripButtonFileOpen, "Open"); - TryLoadIcon(toolStripButtonSave, "Save"); - TryLoadIcon(toolStripButtonSaveAs, "SaveAs"); - TryLoadIcon(toolStripButtonFind, "Find"); - TryLoadIcon(toolStripButtonReplace, "Replace"); - TryLoadIcon(toolStripButtonFixCommonErrors, "FixCommonErrors"); - TryLoadIcon(toolStripButtonRemoveTextForHi, "RemoveTextForHi"); - TryLoadIcon(toolStripButtonVisualSync, "VisualSync"); - TryLoadIcon(toolStripButtonSpellCheck, "SpellCheck"); - TryLoadIcon(toolStripButtonNetflixQualityCheck, "NetflixGlyphCheck"); - TryLoadIcon(toolStripButtonSettings, "Settings"); - TryLoadIcon(toolStripButtonHelp, "Help"); - - TryLoadIcon(toolStripButtonToggleWaveform, "WaveformToggle"); - TryLoadIcon(toolStripButtonToggleVideo, "VideoToggle"); - - toolStripButtonFileNew.Visible = gs.ShowToolbarNew; - toolStripButtonFileOpen.Visible = gs.ShowToolbarOpen; - toolStripButtonSave.Visible = gs.ShowToolbarSave; - toolStripButtonSaveAs.Visible = gs.ShowToolbarSaveAs; - toolStripButtonFind.Visible = gs.ShowToolbarFind; - toolStripButtonReplace.Visible = gs.ShowToolbarReplace; - toolStripButtonFixCommonErrors.Visible = gs.ShowToolbarFixCommonErrors; - toolStripButtonRemoveTextForHi.Visible = gs.ShowToolbarRemoveTextForHi; - - toolStripButtonVisualSync.Visible = gs.ShowToolbarVisualSync; - toolStripButtonSpellCheck.Visible = gs.ShowToolbarSpellCheck; - toolStripButtonNetflixQualityCheck.Visible = gs.ShowToolbarNetflixGlyphCheck; - toolStripButtonSettings.Visible = gs.ShowToolbarSettings; - toolStripButtonHelp.Visible = gs.ShowToolbarHelp; - - toolStripSeparatorFrameRate.Visible = gs.ShowFrameRate; - toolStripLabelFrameRate.Visible = gs.ShowFrameRate; - toolStripComboBoxFrameRate.Visible = gs.ShowFrameRate; - toolStripButtonGetFrameRate.Visible = gs.ShowFrameRate; - - toolStripSeparatorFindReplace.Visible = gs.ShowToolbarFind || gs.ShowToolbarReplace; - toolStripSeparatorFixSyncSpell.Visible = gs.ShowToolbarFixCommonErrors || gs.ShowToolbarVisualSync || gs.ShowToolbarSpellCheck || gs.ShowToolbarSettings; - toolStripSeparatorHelp.Visible = gs.ShowToolbarHelp; - - toolStrip1.Visible = gs.ShowToolbarNew || gs.ShowToolbarOpen || gs.ShowToolbarSave || gs.ShowToolbarSaveAs || gs.ShowToolbarFind || gs.ShowToolbarReplace || - gs.ShowToolbarFixCommonErrors || gs.ShowToolbarVisualSync || gs.ShowToolbarSpellCheck || gs.ShowToolbarNetflixGlyphCheck || - gs.ShowToolbarSettings || gs.ShowToolbarHelp; - - UpdateNetflixGlyphCheckToolsVisibility(); - } - - private void ToolStripButtonFileNewClick(object sender, EventArgs e) - { - _lastDoNotPrompt = -1; - ReloadFromSourceView(); - FileNew(); - ShowHideTextBasedFeatures(GetCurrentSubtitleFormat()); - } - - private void ToolStripButtonFileOpenClick(object sender, EventArgs e) - { - toolStripButtonFileOpen.Enabled = false; - ReloadFromSourceView(); - OpenNewFile(); - toolStripButtonFileOpen.Enabled = true; - } - - private void ToolStripButtonSaveClick(object sender, EventArgs e) - { - var useOnly0AForNewLine = ModifierKeys == (Keys.Control | Keys.Shift); - SaveAll(useOnly0AForNewLine); - } - - private void SaveAll(bool useOnly0AForNewLine = false) - { - if (!IsSubtitleLoaded) - { - return; - } - - ReloadFromSourceView(); - _disableShowStatus = true; - _saveAsCalled = false; - var result = SaveSubtitle(GetCurrentSubtitleFormat(), useOnly0AForNewLine); - if (result != DialogResult.OK) - { - _disableShowStatus = false; - return; - } - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate.Paragraphs.Count > 0) - { - SaveOriginalToolStripMenuItemClick(null, null); - _disableShowStatus = false; - ShowStatus(string.Format(_language.SavedSubtitleX, Path.GetFileName(_fileName)) + " + " + - string.Format(_language.SavedOriginalSubtitleX, Path.GetFileName(_subtitleAlternateFileName))); - return; - } - - _disableShowStatus = false; - ShowStatus(string.Format(_language.SavedSubtitleX, Path.GetFileName(_fileName))); - - if (Configuration.Settings.General.ShowNegativeDurationInfoOnSave) - { - var sb = new StringBuilder(); - for (var index = 0; index < _subtitle.Paragraphs.Count; index++) - { - var p = _subtitle.Paragraphs[index]; - if (p.Duration.TotalMilliseconds < 0) - { - if (sb.Length < 20) - { - if (sb.Length > 0) - { - sb.Append(", "); - } - sb.Append((index + 1).ToString(CultureInfo.InvariantCulture)); - } - else - { - sb.Append("..."); - break; - } - } - } - - if (sb.Length > 0) - { - using (var form = new DialogDoNotShowAgain(Title, string.Format(_language.SubtitleContainsNegativeDurationsX, sb.ToString()))) - { - form.ShowDialog(this); - Configuration.Settings.General.ShowNegativeDurationInfoOnSave = !form.DoNoDisplayAgain; - } - } - } - } - - private void ToolStripButtonSaveAsClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - FileSaveAs(true); - } - - private void ToolStripButtonFindClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - Find(); - } - - private void ToolStripButtonVisualSyncClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - ShowVisualSync(false); - } - - private void ToolStripButtonSettingsClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - ShowSettings(); - } - - private void TextBoxSourceClick(object sender, EventArgs e) - { - ShowSourceLineNumber(); - } - - private void TextBoxSourceKeyDown(object sender, KeyEventArgs e) - { - ShowSourceLineNumber(); - if (e.Modifiers == Keys.Control && e.KeyCode == Keys.A) - { - textBoxSource.SelectAll(); - e.SuppressKeyPress = true; - } - - if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D) - { - textBoxSource.SelectionLength = 0; - e.SuppressKeyPress = true; - } - } - - private void textBoxSource_KeyUp(object sender, KeyEventArgs e) - { - ShowSourceLineNumber(); - } - - private void TextBoxSourceTextChanged(object sender, EventArgs e) - { - ShowSourceLineNumber(); - _sourceViewChange = true; - labelStatus.Text = string.Empty; - } - - private bool ShowProfileInStatusBar => Configuration.Settings.General.CurrentProfile != "Default"; - - private void ShowSourceLineNumber() - { - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - var profile = Configuration.Settings.General.CurrentProfile + " "; - if (!ShowProfileInStatusBar) - { - profile = string.Empty; - } - - toolStripSelected.Text = profile + string.Format(_language.LineNumberX, textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart) + 1); - } - } - - private void ButtonGetFrameRateClick(object sender, EventArgs e) - { - openFileDialog1.Title = _language.OpenVideoFile; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = Utilities.GetVideoFileFilter(false); - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - VideoFileName = openFileDialog1.FileName; - var info = UiUtil.GetVideoInfo(openFileDialog1.FileName); - if (info != null && info.Success) - { - string oldFrameRate = toolStripComboBoxFrameRate.Text; - toolStripComboBoxFrameRate.Text = string.Format("{0:0.###}", info.FramesPerSecond); - - if (oldFrameRate != toolStripComboBoxFrameRate.Text) - { - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - } - } - } - - private void FindToolStripMenuItemClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - Find(); - } - - private void Find() - { - string selectedText; - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - selectedText = textBoxSource.SelectedText; - } - else - { - if (textBoxListViewTextAlternate.Focused) - { - selectedText = textBoxListViewTextAlternate.SelectedText; - } - else - { - selectedText = textBoxListViewText.SelectedText; - } - } - - if (selectedText.Length == 0 && _findHelper != null) - { - if (_clearLastFind) - { - _clearLastFind = false; - _findHelper.FindReplaceType.FindType = _clearLastFindType; - selectedText = _clearLastFindText; - } - else - { - selectedText = _findHelper.FindText; - } - } - - using (var findDialog = new FindDialog(_subtitle)) - { - findDialog.SetIcon(toolStripButtonFind.Image as Bitmap); - findDialog.Initialize(selectedText, _findHelper); - if (findDialog.ShowDialog(this) != DialogResult.OK) - { - if (_findHelper != null) - { - _findHelper.InProgress = false; - } - - return; - } - - _findHelper = findDialog.GetFindDialogHelper(_subtitleListViewIndex); - _findHelper.InProgress = true; - if (!string.IsNullOrWhiteSpace(_findHelper.FindText)) - { - if (Configuration.Settings.Tools.FindHistory.Count == 0 || Configuration.Settings.Tools.FindHistory[0] != _findHelper.FindText) - { - Configuration.Settings.Tools.FindHistory.Insert(0, _findHelper.FindText); - } - } - - ShowStatus(string.Format(_language.SearchingForXFromLineY, _findHelper.FindText, _subtitleListViewIndex + 1)); - if (tabControlSubtitle.SelectedIndex == TabControlListView) - { - var tb = GetFindReplaceTextBox(); - int startPos = tb.SelectedText.Length > 0 ? tb.SelectionStart + 1 : tb.SelectionStart; - bool found = _findHelper.Find(_subtitle, _subtitleAlternate, _subtitleListViewIndex, startPos); - tb = GetFindReplaceTextBox(); - //if we fail to find the text, we might want to start searching from the top of the file. - if (!found && _findHelper.StartLineIndex >= 1) - { - if (MessageBox.Show(_language.FindContinue, _language.FindContinueTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) - { - found = _findHelper.Find(_subtitle, _subtitleAlternate, -1); - } - } - - if (found) - { - SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); - tb.Focus(); - tb.SelectionStart = _findHelper.SelectedPosition; - tb.SelectionLength = _findHelper.FindTextLength; - ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1)); - _findHelper.SelectedPosition++; - } - else - { - ShowStatus(string.Format(_language.XNotFound, _findHelper.FindText)); - } - } - else if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - if (_findHelper.Find(textBoxSource, textBoxSource.SelectionStart)) - { - textBoxSource.SelectionStart = _findHelper.SelectedIndex; - textBoxSource.SelectionLength = _findHelper.FindTextLength; - textBoxSource.ScrollToCaret(); - ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart))); - } - else - { - ShowStatus(string.Format(_language.XNotFound, _findHelper.FindText)); - } - } - } - - if (_findHelper != null) - { - _findHelper.InProgress = false; - } - } - - private void FindNextToolStripMenuItemClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - FindNext(); - } - - private SETextBox GetFindReplaceTextBox() - { - return _findHelper.MatchInOriginal ? textBoxListViewTextAlternate : textBoxListViewText; - } - - private void FindNext() - { - if (_findHelper != null) - { - _findHelper.InProgress = true; - var tb = GetFindReplaceTextBox(); - if (tabControlSubtitle.SelectedIndex == TabControlListView) - { - int selectedIndex = -1; - if (SubtitleListview1.SelectedItems.Count > 0) - { - selectedIndex = SubtitleListview1.SelectedItems[0].Index; - } - - int textBoxStart = tb.SelectionStart; - if (_findHelper.SelectedPosition - 1 == tb.SelectionStart && tb.SelectionLength > 0 || - _findHelper.FindText.Equals(tb.SelectedText, StringComparison.OrdinalIgnoreCase)) - { - textBoxStart = tb.SelectionStart + 1; - } - - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, selectedIndex, textBoxStart, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) - { - tb = GetFindReplaceTextBox(); - SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); - ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1)); - tb.Focus(); - tb.SelectionStart = _findHelper.SelectedPosition; - tb.SelectionLength = _findHelper.FindTextLength; - _findHelper.SelectedPosition++; - } - else - { - if (_findHelper.StartLineIndex >= 1) - { - if (MessageBox.Show(_language.FindContinue, _language.FindContinueTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) - { - _findHelper.StartLineIndex = 0; - if (_findHelper.Find(_subtitle, _subtitleAlternate, 0)) - { - SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); - tb.Focus(); - tb.SelectionStart = _findHelper.SelectedPosition; - tb.SelectionLength = _findHelper.FindTextLength; - ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1)); - _findHelper.SelectedPosition++; - return; - } - } - } - - ShowStatus(string.Format(_language.XNotFound, _findHelper.FindText)); - } - } - else if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - if (_findHelper.FindNext(textBoxSource.Text, textBoxSource.SelectionStart)) - { - textBoxSource.SelectionStart = _findHelper.SelectedIndex; - textBoxSource.SelectionLength = _findHelper.FindTextLength; - textBoxSource.ScrollToCaret(); - ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart))); - } - else - { - ShowStatus(string.Format(_language.XNotFound, _findHelper.FindText)); - } - } - } - else - { - Find(); - } - - if (_findHelper != null) - { - _findHelper.InProgress = false; - } - } - - private void FindPrevious() - { - if (_findHelper == null) - { - return; - } - - _findHelper.InProgress = true; - var tb = GetFindReplaceTextBox(); - if (tabControlSubtitle.SelectedIndex == TabControlListView) - { - int selectedIndex = -1; - if (SubtitleListview1.SelectedItems.Count > 0) - { - selectedIndex = SubtitleListview1.SelectedItems[0].Index; - } - - int textBoxStart = tb.SelectionStart; - if (_findHelper.SelectedPosition - 1 == tb.SelectionStart && tb.SelectionLength > 0 || - _findHelper.FindText.Equals(tb.SelectedText, StringComparison.OrdinalIgnoreCase)) - { - textBoxStart = tb.SelectionStart - 1; - } - - if (_findHelper.FindPrevious(_subtitle, _subtitleAlternate, selectedIndex, textBoxStart, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) - { - tb = GetFindReplaceTextBox(); - SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); - ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1)); - tb.Focus(); - tb.SelectionStart = _findHelper.SelectedPosition; - tb.SelectionLength = _findHelper.FindTextLength; - _findHelper.SelectedPosition--; - } - else - { - ShowStatus(string.Format(_language.XNotFound, _findHelper.FindText)); - } - } - else if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - if (_findHelper.FindPrevious(textBoxSource.Text, textBoxSource.SelectionStart)) - { - textBoxSource.SelectionStart = _findHelper.SelectedIndex; - textBoxSource.SelectionLength = _findHelper.FindTextLength; - textBoxSource.ScrollToCaret(); - ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart))); - } - else - { - ShowStatus(string.Format(_language.XNotFound, _findHelper.FindText)); - } - } - - _findHelper.InProgress = false; - } - - private void ToolStripButtonReplaceClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - Replace(null); - } - - private void ReplaceToolStripMenuItemClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - Replace(null); - } - - private void ReplaceSourceView(ReplaceDialog replaceDialog) - { - bool isFirst = true; - string selectedText = textBoxSource.SelectedText; - if (selectedText.Length == 0 && _findHelper != null) - { - selectedText = _findHelper.FindText; - } - - if (replaceDialog == null) - { - replaceDialog = new ReplaceDialog(); - replaceDialog.SetIcon(toolStripButtonReplace.Image as Bitmap); - _findHelper = _findHelper ?? replaceDialog.GetFindDialogHelper(_subtitleListViewIndex); - } - else - { - isFirst = false; - } - - replaceDialog.Initialize(selectedText, _findHelper); - if (replaceDialog.ShowDialog(this) == DialogResult.OK) - { - _findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex); - ShowStatus(string.Format(_language.SearchingForXFromLineY, _findHelper.FindText, _subtitleListViewIndex + 1)); - if (replaceDialog.ReplaceAll) - { - SourceListReplaceAll(replaceDialog, _findHelper); - return; - } - - int replaceCount = 0; - var searchStringFound = false; - int start = textBoxSource.SelectionStart; - if (isFirst) - { - MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText)); - _makeHistoryPaused = true; - if (start >= 0) - { - start--; - } - } - else - { - if (textBoxSource.SelectionLength > 0 && start > 0 && !replaceDialog.FindOnly) - { - start--; - } - } - - if (_findHelper.FindNext(textBoxSource.Text, start)) - { - textBoxSource.SelectionStart = _findHelper.SelectedIndex; - textBoxSource.SelectionLength = _findHelper.FindTextLength; - if (!replaceDialog.FindOnly) - { - textBoxSource.SelectedText = _findHelper.ReplaceText; - } - - textBoxSource.ScrollToCaret(); - - replaceCount++; - searchStringFound = true; - - if (!replaceDialog.FindOnly) - { - if (_findHelper.FindNext(textBoxSource.Text, start)) - { - textBoxSource.SelectionStart = _findHelper.SelectedIndex; - textBoxSource.SelectionLength = _findHelper.FindTextLength; - textBoxSource.ScrollToCaret(); - } - - Replace(replaceDialog); - return; - } - } - - if (replaceDialog.FindOnly) - { - if (searchStringFound) - { - ShowStatus(string.Format(_language.MatchFoundX, _findHelper.FindText)); - } - else - { - ShowStatus(string.Format(_language.NoMatchFoundX, _findHelper.FindText)); - } - - Replace(replaceDialog); - return; - } - - ReloadFromSourceView(); - if (replaceCount == 0) - { - ShowStatus(_language.FoundNothingToReplace); - } - else - { - ShowStatus(string.Format(_language.ReplaceCountX, replaceCount)); - } - } - - if (_makeHistoryPaused) - { - RestartHistory(); - } - - replaceDialog.Dispose(); - } - - private void SourceListReplaceAll(ReplaceDialog replaceDialog, FindReplaceDialogHelper findHelper) - { - if (_findHelper.FindReplaceType.FindType == FindType.RegEx) - { - SourceListReplaceAllRegEx(replaceDialog); - return; - } - - int replaceCount = 0; - bool searchStringFound = true; - int start = textBoxSource.SelectionStart; - bool isFirst = true; - string text = textBoxSource.Text; - while (searchStringFound) - { - searchStringFound = false; - if (isFirst) - { - MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText)); - isFirst = false; - _makeHistoryPaused = true; - if (start >= 0) - { - start--; - } - } - else - { - start--; - } - - if (_findHelper.FindNext(text, start)) - { - text = text.Remove(findHelper.SelectedIndex, findHelper.FindTextLength).Insert(findHelper.SelectedIndex, findHelper.ReplaceText); - start = findHelper.SelectedIndex + findHelper.FindTextLength; - replaceCount++; - searchStringFound = true; - } - } - - textBoxSource.Text = text; - ReloadFromSourceView(); - if (replaceCount == 0) - { - ShowStatus(_language.FoundNothingToReplace); - } - else - { - ShowStatus(string.Format(_language.ReplaceCountX, replaceCount)); - } - - if (_makeHistoryPaused) - { - RestartHistory(); - } - - replaceDialog.Dispose(); - } - - private void SourceListReplaceAllRegEx(ReplaceDialog replaceDialog) - { - var start = textBoxSource.SelectionStart; - var s = textBoxSource.Text; - var r = new Regex(_findHelper.FindText, RegexOptions.Multiline); - var matches = r.Matches(s, start); - - if (matches.Count > 0) - { - MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText)); - } - - var result = RegexUtils.ReplaceNewLineSafe(r, s, _findHelper.ReplaceText, int.MaxValue, start); - - // update UI - textBoxSource.Text = result; - ShowStatus(matches.Count == 0 ? _language.FoundNothingToReplace : string.Format(_language.ReplaceCountX, matches.Count)); - - // replace again from beginning - if (start > 1) - { - string msgText = _language.ReplaceContinueNotFound; - if (matches.Count > 0) - { - msgText = string.Format(_language.ReplaceXContinue, matches.Count); - } - - if (MessageBox.Show(msgText, _language.ReplaceContinueTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) - { - s = result.Substring(0, start - 1); - var rest = result.Remove(0, start - 1); - if (s.EndsWith('\r') && rest.StartsWith('\n')) - { // don't split "\r\n" - s = s.Substring(0, s.Length - 1); - rest = '\r' + rest; - } - - matches = r.Matches(s); - result = RegexUtils.ReplaceNewLineSafe(r, s, _findHelper.ReplaceText); - - // update UI - textBoxSource.Text = result + rest; - ShowStatus(matches.Count == 0 ? _language.FoundNothingToReplace : string.Format(_language.ReplaceCountX, matches.Count)); - } - } - - replaceDialog.Dispose(); - ReloadFromSourceView(); - } - - private void ReplaceListView(ReplaceDialog replaceDialog) - { - SaveSubtitleListviewIndices(); - int firstIndex = FirstSelectedIndex; - bool isFirst = true; - string selectedText; - if (textBoxListViewTextAlternate.Focused) - { - selectedText = textBoxListViewTextAlternate.SelectedText; - } - else - { - selectedText = textBoxListViewText.SelectedText; - } - - if (selectedText.Length == 0 && _findHelper != null) - { - selectedText = _findHelper.FindText; - } - - if (replaceDialog == null) - { - replaceDialog = new ReplaceDialog(); - replaceDialog.SetIcon(toolStripButtonReplace.Image as Bitmap); - _findHelper = _findHelper ?? replaceDialog.GetFindDialogHelper(_subtitleListViewIndex); - _findHelper.InProgress = true; - int index = 0; - - if (SubtitleListview1.SelectedItems.Count > 0) - { - index = SubtitleListview1.SelectedItems[0].Index; - } - - _findHelper.SelectedIndex = index; - if (textBoxListViewTextAlternate.Focused) - { - _findHelper.SelectedPosition = textBoxListViewTextAlternate.SelectionStart; - _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; - } - else - { - _findHelper.SelectedPosition = textBoxListViewText.SelectionStart; - _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; - } - - _replaceStartLineIndex = index; - } - else - { - isFirst = false; - if (_findHelper != null) - { - selectedText = _findHelper.FindText; - _findHelper.InProgress = true; - } - - } - - replaceDialog.Initialize(selectedText, _findHelper); - if (replaceDialog.ShowDialog(this) == DialogResult.OK) - { - if (_findHelper == null) - { - _findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex); - _findHelper.InProgress = true; - } - else - { - int line = _findHelper.SelectedIndex; - int pos = _findHelper.ReplaceFromPosition; - bool success = _findHelper.Success; - var matchInOriginal = _findHelper.MatchInOriginal; - _findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex); - _findHelper.SelectedIndex = line; - _findHelper.SelectedPosition = pos; - _findHelper.Success = success; - _findHelper.MatchInOriginal = matchInOriginal; - _findHelper.InProgress = true; - } - - ShowStatus(string.Format(_language.SearchingForXFromLineY, _findHelper.FindText, _subtitleListViewIndex + 1)); - int replaceCount = 0; - bool searchStringFound = true; - int stopAtIndex = int.MaxValue; - while (searchStringFound) - { - searchStringFound = false; - if (isFirst) - { - MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText)); - isFirst = false; - _makeHistoryPaused = true; - } - - if (replaceDialog.ReplaceAll) - { - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) - { - if (_findHelper.SelectedIndex > stopAtIndex) - { - break; - } - - SetTextForFindAndReplace(true, replaceDialog.ReplaceAll); - searchStringFound = true; - replaceCount++; - } - else - { - textBoxListViewText.Visible = true; - _subtitleListViewIndex = -1; - if (firstIndex >= 0 && firstIndex < SubtitleListview1.Items.Count) - { - SubtitleListview1.Items[firstIndex].Selected = true; - SubtitleListview1.Items[firstIndex].Focused = true; - SubtitleListview1.Focus(); - textBoxListViewText.Text = _subtitle.Paragraphs[firstIndex].Text; - if (_subtitleAlternate != null && textBoxListViewTextAlternate.Visible) - { - var orginial = Utilities.GetOriginalParagraph(_findHelper.SelectedIndex, _subtitle.Paragraphs[_findHelper.SelectedIndex], _subtitleAlternate.Paragraphs); - if (orginial != null) - { - textBoxListViewTextAlternate.Text = orginial.Text; - } - } - } - else - { - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - } - - ShowStatus(string.Format(_language.NoMatchFoundX, _findHelper.FindText)); - - if (_replaceStartLineIndex >= 1) // Prompt for start over - { - _replaceStartLineIndex = 0; - string msgText = _language.ReplaceContinueNotFound; - if (replaceCount > 0) - { - msgText = string.Format(_language.ReplaceXContinue, replaceCount); - } - - if (MessageBox.Show(msgText, _language.ReplaceContinueTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) - { - stopAtIndex = firstIndex; - _findHelper.MatchInOriginal = false; - _findHelper.StartLineIndex = 0; - _findHelper.SelectedIndex = 0; - _findHelper.SelectedPosition = 0; - _findHelper.ReplaceFromPosition = 0; - SetTextForFindAndReplace(false, replaceDialog.ReplaceAll); - - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) - { - SetTextForFindAndReplace(true, replaceDialog.ReplaceAll); - _findHelper.SelectedPosition += _findHelper.ReplaceText.Length; - _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; - searchStringFound = true; - replaceCount++; - } - } - } - } - } - else if (replaceDialog.FindOnly) - { - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) - { - var tb = GetFindReplaceTextBox(); - SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); - tb.Focus(); - tb.SelectionStart = _findHelper.SelectedPosition; - tb.SelectionLength = _findHelper.FindTextLength; - _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; - _findHelper.SelectedPosition += _findHelper.FindTextLength; - ShowStatus(string.Format(_language.NoXFoundAtLineY, _findHelper.SelectedIndex + 1, _findHelper.FindText)); - Replace(replaceDialog); - if (replaceDialog != null && !replaceDialog.IsDisposed) - { - replaceDialog.Dispose(); - } - - _findHelper.InProgress = false; - return; - } - - if (_replaceStartLineIndex >= 1) // Prompt for start over - { - _replaceStartLineIndex = 0; - if (MessageBox.Show(_language.FindContinue, _language.FindContinueTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) - { - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - _findHelper.StartLineIndex = 0; - _findHelper.SelectedIndex = 0; - _findHelper.SelectedPosition = 0; - _findHelper.ReplaceFromPosition = 0; - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) - { - var tb = GetFindReplaceTextBox(); - SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); - tb.Focus(); - tb.SelectionStart = _findHelper.SelectedPosition; - tb.SelectionLength = _findHelper.FindTextLength; - _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; - _findHelper.SelectedPosition += _findHelper.FindTextLength; - ShowStatus(string.Format(_language.NoXFoundAtLineY, _findHelper.SelectedIndex + 1, _findHelper.FindText)); - Replace(replaceDialog); - if (replaceDialog != null) - { - replaceDialog.Dispose(); - } - - _findHelper.InProgress = false; - return; - } - } - else - { - if (replaceDialog != null && !replaceDialog.IsDisposed) - { - replaceDialog.Dispose(); - } - - _findHelper.InProgress = false; - return; - } - } - - ShowStatus(string.Format(_language.NoMatchFoundX, _findHelper.FindText)); - } - else if (!replaceDialog.FindOnly) // replace once only - { - var tb = GetFindReplaceTextBox(); - string msg = string.Empty; - if (_findHelper.FindReplaceType.FindType == FindType.RegEx) - { - if (_findHelper.Success) - { - if (_findHelper.FindReplaceType.FindType == FindType.RegEx) - { - ReplaceViaRegularExpression(tb, replaceDialog.ReplaceAll); - } - else - { - tb.SelectedText = _findHelper.ReplaceText; - } - - msg = _language.OneReplacementMade + " "; - } - } - else if (tb.SelectionLength == _findHelper.FindTextLength) - { - tb.SelectedText = _findHelper.ReplaceText; - msg = _language.OneReplacementMade + " "; - _findHelper.SelectedPosition += _findHelper.ReplaceText.Length; - } - - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) - { - SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); - tb = GetFindReplaceTextBox(); - tb.Focus(); - tb.SelectionStart = _findHelper.SelectedPosition; - tb.SelectionLength = _findHelper.FindTextLength; - if (_findHelper.FindReplaceType.FindType != FindType.RegEx) - { - _findHelper.SelectedPosition += _findHelper.ReplaceText.Length; - } - - ShowStatus(string.Format(msg + _language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1)); - } - else - { - ShowStatus(msg + string.Format(_language.XNotFound, _findHelper.FindText)); - - // Prompt for start over - if (_replaceStartLineIndex >= 1) - { - _replaceStartLineIndex = 0; - if (MessageBox.Show(_language.FindContinue, _language.FindContinueTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) - { - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - _findHelper.StartLineIndex = 0; - _findHelper.SelectedIndex = 0; - _findHelper.SelectedPosition = 0; - _findHelper.ReplaceFromPosition = 0; - if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) - { - SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); - tb = GetFindReplaceTextBox(); - tb.Focus(); - tb.SelectionStart = _findHelper.SelectedPosition; - tb.SelectionLength = _findHelper.FindTextLength; - _findHelper.SelectedPosition += _findHelper.ReplaceText.Length; - ShowStatus(string.Format(msg + _language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1)); - } - } - else - { - if (replaceDialog != null && !replaceDialog.IsDisposed) - { - replaceDialog.Dispose(); - } - - _findHelper.InProgress = false; - return; - } - } - else - { - if (replaceDialog != null && !replaceDialog.IsDisposed) - { - replaceDialog.Dispose(); - } - - _findHelper.InProgress = false; - return; - } - } - - Replace(replaceDialog); - if (replaceDialog != null && !replaceDialog.IsDisposed) - { - replaceDialog.Dispose(); - } - - _findHelper.InProgress = false; - return; - } - - if (_findHelper.SelectedIndex > stopAtIndex) - { - break; - } - } - - ShowSource(); - if (replaceCount == 0) - { - ShowStatus(_language.FoundNothingToReplace); - } - else - { - ShowStatus(string.Format(_language.ReplaceCountX, replaceCount)); - SubtitleListview1.SyntaxColorAllLines(_subtitle); - } - } - - RestoreSubtitleListviewIndices(); - if (_makeHistoryPaused) - { - RestartHistory(); - } - - replaceDialog.Dispose(); - _findHelper.InProgress = false; - } - - private void ReplaceViaRegularExpression(SETextBox tb, bool replaceAll) - { - var r = new Regex(RegexUtils.FixNewLine(_findHelper.FindText), RegexOptions.Multiline); - if (replaceAll) - { - string result = RegexUtils.ReplaceNewLineSafe(r, tb.Text, _findHelper.ReplaceText); - if (result != tb.Text) - { - tb.Text = result; - } - - _findHelper.SelectedPosition = tb.Text.Length; - _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; - } - else - { - string result = RegexUtils.ReplaceNewLineSafe(r, tb.Text, _findHelper.ReplaceText, 1, _findHelper.SelectedPosition); - if (result != tb.Text) - { - var match = r.Match(string.Join(Environment.NewLine, tb.Text.SplitToLines())); - if (match != null && match.Success && !_findHelper.FindText.StartsWith('^') && _findHelper.ReplaceText.Length > 0) - { - var add = Math.Abs(match.Length - _findHelper.ReplaceText.Length); - _findHelper.SelectedPosition += add; - _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; - } - - tb.Text = result; - } - - if (_findHelper.FindText.StartsWith('^')) - { - _findHelper.SelectedPosition++; - } - } - } - - private void SetTextForFindAndReplace(bool replace, bool replaceAll) - { - _subtitleListViewIndex = _findHelper.SelectedIndex; - textBoxListViewText.Text = _subtitle.Paragraphs[_findHelper.SelectedIndex].Text; - if (_subtitleAlternate != null && textBoxListViewTextAlternate.Visible) - { - var orginial = Utilities.GetOriginalParagraph(_findHelper.SelectedIndex, _subtitle.Paragraphs[_findHelper.SelectedIndex], _subtitleAlternate.Paragraphs); - if (orginial != null) - { - textBoxListViewTextAlternate.Text = orginial.Text; - } - } - - if (replace) - { - var tb = GetFindReplaceTextBox(); - tb.SelectionStart = _findHelper.SelectedPosition; - tb.SelectionLength = _findHelper.FindTextLength; - if (_findHelper.FindReplaceType.FindType == FindType.RegEx) - { - ReplaceViaRegularExpression(tb, replaceAll); - _findHelper.SelectedPosition += _findHelper.FindTextLength; - _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; - } - else - { - tb.SelectedText = _findHelper.ReplaceText; - _findHelper.SelectedPosition += _findHelper.ReplaceText.Length; - _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; - } - } - } - - private void Replace(ReplaceDialog replaceDialog) - { - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - ReplaceSourceView(replaceDialog); - } - else - { - ReplaceListView(replaceDialog); - } - } - - public void ShowStatus(string message, bool log = true) - { - if (_disableShowStatus) - { - return; - } - - labelStatus.Text = message.Replace("&", "&&"); - statusStrip1.Refresh(); - if (!string.IsNullOrEmpty(message)) - { - _timerClearStatus.Stop(); - if (log) - { - _timerClearStatus.Interval = Configuration.Settings.General.ClearStatusBarAfterSeconds * 1000; - _statusLog.Add(string.Format("{0:0000}-{1:00}-{2:00} {3}: {4}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.ToLongTimeString(), message)); - } - else - { - _timerClearStatus.Interval = 1500; - } - _timerClearStatus.Start(); - } - ShowSourceLineNumber(); - ShowLineInformationListView(); - } - - private void ReloadFromSourceView() - { - if (_sourceViewChange) - { - SaveSubtitleListviewIndices(); - if (!string.IsNullOrWhiteSpace(textBoxSource.Text)) - { - var oldSubtitle = new Subtitle(_subtitle); - var format = GetCurrentSubtitleFormat(); - var list = textBoxSource.Lines.ToList(); - format = new Subtitle().ReloadLoadSubtitle(list, null, format); - if (format == null) - { - MessageBox.Show(_language.UnableToParseSourceView); - return; - } - - _sourceViewChange = false; - MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView); - _subtitle.ReloadLoadSubtitle(list, null, format); - - int index = 0; - foreach (string formatName in comboBoxSubtitleFormats.Items) - { - if (formatName == format.FriendlyName) - { - comboBoxSubtitleFormats.SelectedIndex = index; - break; - } - - index++; - } - - for (int i = 0; i < oldSubtitle.Paragraphs.Count; i++) - { - if (oldSubtitle.Paragraphs[i].Bookmark != null) - { - var newParagraph = _subtitle.GetFirstAlike(oldSubtitle.Paragraphs[i]); - if (newParagraph != null) - { - newParagraph.Bookmark = oldSubtitle.Paragraphs[i].Bookmark; - } - } - } - - if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) - { - _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-Configuration.Settings.General.CurrentVideoOffsetInMs)); - } - - var formatType = format.GetType(); - if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha)) - { - string errors = AdvancedSubStationAlpha.CheckForErrors(_subtitle.Header); - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - else if (formatType == typeof(SubRip)) - { - string errors = (format as SubRip).Errors; - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - else if (formatType == typeof(MicroDvd)) - { - string errors = (format as MicroDvd).Errors; - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - else if (formatType == typeof(DCinemaSmpte2007)) - { - format.ToText(_subtitle, string.Empty); - string errors = (format as DCinemaSmpte2007).Errors; - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - else if (formatType == typeof(DCinemaSmpte2010)) - { - format.ToText(_subtitle, string.Empty); - string errors = (format as DCinemaSmpte2010).Errors; - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - else if (formatType == typeof(DCinemaSmpte2014)) - { - format.ToText(_subtitle, string.Empty); - string errors = (format as DCinemaSmpte2014).Errors; - if (!string.IsNullOrEmpty(errors)) - { - MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - } - } - else - { - _sourceViewChange = false; - MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView); - _sourceViewChange = false; - _subtitle.Paragraphs.Clear(); - } - - _subtitleListViewIndex = -1; - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - - private void HelpToolStripMenuItem1Click(object sender, EventArgs e) - { - ReloadFromSourceView(); - Utilities.ShowHelp(string.Empty); - } - - private void ToolStripButtonHelpClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - Utilities.ShowHelp(string.Empty); - } - - private void GotoLineNumberToolStripMenuItemClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - using (var goToLine = new GoToLine()) - { - if (tabControlSubtitle.SelectedIndex == TabControlListView) - { - goToLine.Initialize(1, SubtitleListview1.Items.Count); - } - else if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - goToLine.Initialize(1, textBoxSource.Lines.Length); - } - - if (goToLine.ShowDialog(this) == DialogResult.OK) - { - if (tabControlSubtitle.SelectedIndex == TabControlListView) - { - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - SubtitleListview1.SelectNone(); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - - SubtitleListview1.Items[goToLine.LineNumber - 1].Selected = true; - SubtitleListview1.Items[goToLine.LineNumber - 1].EnsureVisible(); - SubtitleListview1.Items[goToLine.LineNumber - 1].Focused = true; - ShowStatus(string.Format(_language.GoToLineNumberX, goToLine.LineNumber)); - } - else if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - textBoxSource.SelectionStart = textBoxSource.GetFirstCharIndexFromLine(goToLine.LineNumber - 1); - textBoxSource.SelectionLength = textBoxSource.Lines[goToLine.LineNumber - 1].Length; - textBoxSource.ScrollToCaret(); - ShowSourceLineNumber(); - } - } - } - } - - private void TextBoxSourceLeave(object sender, EventArgs e) - { - ReloadFromSourceView(); - } - - private void AdjustDisplayTimeToolStripMenuItemClick(object sender, EventArgs e) - { - AdjustDisplayTime(false); - } - - private void AdjustDisplayTime(bool onlySelectedLines) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - using (var adjustDisplayTime = new AdjustDisplayDuration()) - { - List selectedIndices = null; - if (onlySelectedLines) - { - adjustDisplayTime.Text += " - " + _language.SelectedLines; - selectedIndices = new List(); - foreach (int item in SubtitleListview1.SelectedIndices) - { - selectedIndices.Add(item); - } - } - - if (adjustDisplayTime.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeDisplayTimeAdjustment); - if (adjustDisplayTime.AdjustUsingPercent) - { - double percent = double.Parse(adjustDisplayTime.AdjustValue); - _subtitle.AdjustDisplayTimeUsingPercent(percent, selectedIndices); - ShowStatus(string.Format(_language.DisplayTimesAdjustedX, double.Parse(adjustDisplayTime.AdjustValue, CultureInfo.InvariantCulture) + "%")); - } - else if (adjustDisplayTime.AdjustUsingSeconds) - { - double seconds = double.Parse(adjustDisplayTime.AdjustValue, CultureInfo.InvariantCulture); - _subtitle.AdjustDisplayTimeUsingSeconds(seconds, selectedIndices); - ShowStatus(string.Format(_language.DisplayTimesAdjustedX, double.Parse(adjustDisplayTime.AdjustValue, CultureInfo.InvariantCulture))); - } - else if (adjustDisplayTime.AdjustUsingRecalc) - { - double maxCharSeconds = (double)(adjustDisplayTime.MaxCharactersPerSecond); - _subtitle.RecalculateDisplayTimes(maxCharSeconds, selectedIndices, (double)adjustDisplayTime.OptimalCharactersPerSecond, adjustDisplayTime.ExtendOnly); - ShowStatus(string.Format(_language.DisplayTimesAdjustedX, adjustDisplayTime.AdjustValue)); - } - else - { // fixed duration - _subtitle.SetFixedDuration(selectedIndices, adjustDisplayTime.FixedMilliseconds); - ShowStatus(string.Format(_language.DisplayTimesAdjustedX, adjustDisplayTime.FixedMilliseconds)); - } - - SaveSubtitleListviewIndices(); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - } - - private void FixToolStripMenuItemClick(object sender, EventArgs e) - { - if (_networkSession == null) - { - FixCommonErrors(false); - } - } - - private void FixCommonErrors(bool onlySelectedLines) - { - if (IsSubtitleLoaded) - { - ReloadFromSourceView(); - SaveSubtitleListviewIndices(); - using (var fixErrors = new FixCommonErrors()) - { - if (onlySelectedLines) - { - var selectedLines = new Subtitle(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]); - } - - fixErrors.Initialize(selectedLines, GetCurrentSubtitleFormat(), GetCurrentEncoding()); - } - else - { - fixErrors.Initialize(_subtitle, GetCurrentSubtitleFormat(), GetCurrentEncoding()); - } - - if (fixErrors.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeCommonErrorFixes); - _subtitle.Renumber(); - if (onlySelectedLines) - { - // we only update selected lines - if (_networkSession != null) - { - var deletes = new List(); - _networkSession.TimerStop(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - var pOld = _subtitle.Paragraphs[index]; - var p = fixErrors.FixedSubtitle.GetParagraphOrDefaultById(pOld.Id); - if (p == null) - { - deletes.Add(index); - } - else - { - _subtitle.Paragraphs[index] = p; - SubtitleListview1.SetTimeAndText(index, p, _subtitle.GetParagraphOrDefault(index + 1)); - } - } - - NetworkGetSendUpdates(deletes, 0, null); - } - else - { - var selectedIndices = SubtitleListview1.GetSelectedIndices(); - for (int index = selectedIndices.Length - 1; index >= 0; index--) - { - var idx = selectedIndices[index]; - var pOld = _subtitle.Paragraphs[idx]; - var p = fixErrors.FixedSubtitle.GetParagraphOrDefaultById(pOld.Id); - if (p == null) - { - _subtitle.Paragraphs.RemoveAt(idx); - } - else - { - _subtitle.Paragraphs[idx] = p; - } - } - } - - ShowStatus(_language.CommonErrorsFixedInSelectedLines); - } - else - { - _subtitle.Paragraphs.Clear(); - foreach (var p in fixErrors.FixedSubtitle.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowStatus(_language.CommonErrorsFixed); - } - - _subtitle.Renumber(); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - - Configuration.Settings.CommonErrors.StartSize = fixErrors.Width + ";" + fixErrors.Height; - Configuration.Settings.CommonErrors.StartPosition = fixErrors.Left + ";" + fixErrors.Top; - } - } - else - { - DisplaySubtitleNotLoadedMessage(); - } - - ShowInTaskbar = true; - } - - private void StartNumberingFromToolStripMenuItemClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - using (var startNumberingFrom = new StartNumberingFrom()) - { - if (startNumberingFrom.ShowDialog(this) == DialogResult.OK) - { - SaveSubtitleListviewIndices(); - MakeHistoryForUndo(_language.BeforeRenumbering); - ShowStatus(string.Format(_language.RenumberedStartingFromX, startNumberingFrom.StartFromNumber)); - _subtitle.Renumber(startNumberingFrom.StartFromNumber); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - } - - internal void ReloadFromSubtitle(Subtitle subtitle, string messageForUndo) - { - MakeHistoryForUndo(messageForUndo); - _subtitle.Paragraphs.Clear(); - _subtitle.Paragraphs.AddRange(subtitle.Paragraphs); - _subtitleListViewIndex = -1; - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - if (_subtitle.Paragraphs.Count > 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - } - } - - private void RemoveTextForHearImpairedToolStripMenuItemClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - using (var removeTextFromHearImpaired = new FormRemoveTextForHearImpaired(this, _subtitle)) - { - removeTextFromHearImpaired.Initialize(_subtitle); - if (removeTextFromHearImpaired.ShowDialog(this) == DialogResult.OK) - { - int count = removeTextFromHearImpaired.TotalFixes; - if (count == 1) - { - ShowStatus(_language.TextingForHearingImpairedRemovedOneLine); - } - else if (count > 1) - { - ShowStatus(string.Format(_language.TextingForHearingImpairedRemovedXLines, count)); - } - } - } - } - - private void SplitToolStripMenuItemClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - double lengthInSeconds = 0; - if (mediaPlayer.VideoPlayer != null) - { - lengthInSeconds = mediaPlayer.Duration; - } - - if (Configuration.Settings.Tools.SplitAdvanced) - { - using (var split = new Split()) - { - split.Initialize(_subtitle, _fileName, GetCurrentSubtitleFormat()); - if (split.ShowDialog(this) == DialogResult.OK) - { - ShowStatus(_language.SubtitleSplitted); - } - else if (split.ShowBasic) - { - Configuration.Settings.Tools.SplitAdvanced = false; - SplitToolStripMenuItemClick(null, null); - } - } - } - else - { - using (var splitSubtitle = new SplitSubtitle()) - { - splitSubtitle.Initialize(_subtitle, _fileName, GetCurrentSubtitleFormat(), GetCurrentEncoding(), lengthInSeconds); - if (splitSubtitle.ShowDialog(this) == DialogResult.OK) - { - ShowStatus(_language.SubtitleSplitted); - } - else if (splitSubtitle.ShowAdvanced) - { - Configuration.Settings.Tools.SplitAdvanced = true; - SplitToolStripMenuItemClick(null, null); - } - } - } - } - - private void AppendTextVisuallyToolStripMenuItemClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - - if (MessageBox.Show(_language.SubtitleAppendPrompt, _language.SubtitleAppendPromptTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) - { - openFileDialog1.Title = _language.OpenSubtitleToAppend; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - bool success = false; - string fileName = openFileDialog1.FileName; - if (File.Exists(fileName)) - { - var fileInfo = new FileInfo(fileName); - var subtitleToAppend = new Subtitle(); - SubtitleFormat format; - - // do not allow blu-ray/vobsub - string extension = Path.GetExtension(fileName).ToLowerInvariant(); - if (extension == ".sub" && (IsVobSubFile(fileName, false) || FileUtil.IsSpDvdSup(fileName))) - { - format = null; - } - else if (extension == ".sup" && FileUtil.IsBluRaySup(fileName)) - { - format = null; - } - else if (fileInfo.Length < Subtitle.MaxFileSize) - { - format = subtitleToAppend.LoadSubtitle(fileName, out var encoding, null); - - if (format == null) - { - var ebu = new Ebu(); - if (ebu.IsMine(null, fileName)) - { - ebu.LoadSubtitle(subtitleToAppend, null, fileName); - format = ebu; - } - } - - if (format == null) - { - var pac = new Pac(); - if (pac.IsMine(null, fileName)) - { - pac.LoadSubtitle(subtitleToAppend, null, fileName); - format = pac; - } - } - - if (format == null) - { - var cavena890 = new Cavena890(); - if (cavena890.IsMine(null, fileName)) - { - cavena890.LoadSubtitle(subtitleToAppend, null, fileName); - format = cavena890; - } - } - } - else - { - MessageBox.Show(string.Format(_language.FileXIsLargerThan10MB, fileName)); - return; - } - - if (format != null && subtitleToAppend.Paragraphs.Count > 1) - { - using (var visualSync = new VisualSync()) - { - visualSync.Initialize(toolStripButtonVisualSync.Image as Bitmap, subtitleToAppend, null, _fileName, _language.AppendViaVisualSyncTitle, CurrentFrameRate); - visualSync.ShowDialog(this); - if (visualSync.OkPressed) - { - if (MessageBox.Show(_language.AppendSynchronizedSubtitlePrompt, _language.SubtitleAppendPromptTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) - { - int start = _subtitle.Paragraphs.Count + 1; - var fr = CurrentFrameRate; - MakeHistoryForUndo(_language.BeforeAppend); - foreach (var p in visualSync.Paragraphs) - { - _subtitle.Paragraphs.Add(new Paragraph(p)); - } - - if (format.GetType() == typeof(AdvancedSubStationAlpha) && GetCurrentSubtitleFormat().GetType() == typeof(AdvancedSubStationAlpha)) - { - var currentStyles = new List(); - if (_subtitle.Header != null) - { - currentStyles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); - } - - foreach (var styleName in AdvancedSubStationAlpha.GetStylesFromHeader(subtitleToAppend.Header)) - { - bool alreadyExists = false; - foreach (var currentStyleName in currentStyles) - { - if (currentStyleName.Trim().Equals(styleName.Trim(), StringComparison.OrdinalIgnoreCase)) - { - alreadyExists = true; - } - } - - if (!alreadyExists) - { - var newStyle = AdvancedSubStationAlpha.GetSsaStyle(styleName, subtitleToAppend.Header); - _subtitle.Header = AdvancedSubStationAlpha.AddSsaStyle(newStyle, _subtitle.Header); - } - } - } - - _subtitle.Renumber(); - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - - // select appended lines - for (int i = start; i < _subtitle.Paragraphs.Count; i++) - { - SubtitleListview1.Items[i].Selected = true; - } - - SubtitleListview1.EnsureVisible(start); - - ShowStatus(string.Format(_language.SubtitleAppendedX, fileName)); - success = true; - } - } - } - } - } - - if (!success) - { - ShowStatus(_language.SubtitleNotAppended); - } - } - } - } - - private void TranslateByGoogleToolStripMenuItemClick(object sender, EventArgs e) - { - TranslateViaGoogle(false, true); - } - - private void TranslateViaGoogle(bool onlySelectedLines, bool useGoogle) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - bool isAlternateVisible = SubtitleListview1.IsAlternateTextColumnVisible; - ReloadFromSourceView(); - using (var googleTranslate = new GoogleTranslate()) - { - SaveSubtitleListviewIndices(); - string title = _language.GoogleTranslate; - if (!useGoogle) - { - title = _language.MicrosoftTranslate; - } - - if (onlySelectedLines) - { - var selectedLines = new Subtitle(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]); - } - - title += " - " + _language.SelectedLines; - if (_subtitleAlternate != null) - { - var paragraphs = new List(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - var original = Utilities.GetOriginalParagraph(index, _subtitle.Paragraphs[index], _subtitleAlternate.Paragraphs); - if (original != null) - { - paragraphs.Add(original); - } - } - - if (paragraphs.Count == selectedLines.Paragraphs.Count) - { - googleTranslate.Initialize(new Subtitle(paragraphs), selectedLines, title, useGoogle, GetCurrentEncoding()); - } - else - { - googleTranslate.Initialize(selectedLines, null, title, useGoogle, GetCurrentEncoding()); - } - } - else - { - googleTranslate.Initialize(selectedLines, null, title, useGoogle, GetCurrentEncoding()); - } - } - else - { - googleTranslate.Initialize(_subtitle, null, title, useGoogle, GetCurrentEncoding()); - } - - if (googleTranslate.ShowDialog(this) == DialogResult.OK) - { - _subtitleListViewIndex = -1; - string oldFileName = _fileName; - MakeHistoryForUndo(_language.BeforeGoogleTranslation); - if (onlySelectedLines) - { - // we only update selected lines - int i = 0; - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index] = googleTranslate.TranslatedSubtitle.Paragraphs[i]; - i++; - } - - ShowStatus(_language.SelectedLinesTranslated); - } - else - { - ShowSubtitleTimer.Stop(); - var oldHash = _changeSubtitleHash; - _subtitleAlternate = new Subtitle(_subtitle); - _subtitleAlternateFileName = _fileName; - _fileName = null; - _subtitle.Paragraphs.Clear(); - foreach (var p in googleTranslate.TranslatedSubtitle.Paragraphs) - { - _subtitle.Paragraphs.Add(new Paragraph(p)); - } - - ShowStatus(_language.SubtitleTranslated); - _changeAlternateSubtitleHash = oldHash; - _changeSubtitleHash = -1; - ShowSubtitleTimer.Start(); - } - - ShowSource(); - - if (!onlySelectedLines) - { - SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); - SubtitleListview1.AutoSizeAllColumns(this); - var oldHash = _changeAlternateSubtitleHash; - SetupAlternateEdit(); - _changeAlternateSubtitleHash = oldHash; - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - if (!onlySelectedLines) - { - ResetHistory(); - _fileName = googleTranslate.GetFileNameWithTargetLanguage(oldFileName, VideoFileName, _subtitleAlternate, GetCurrentSubtitleFormat()); - } - - RestoreSubtitleListviewIndices(); - _converted = true; - SetTitle(); - SetEncoding(Encoding.UTF8); - if (!isAlternateVisible) - { - toolStripMenuItemShowOriginalInPreview.Checked = false; - Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable = false; - audioVisualizer.Invalidate(); - } - } - } - } - - private static string GetTranslateStringFromNikseDk(string input) - { - WebRequest.DefaultWebProxy = Utilities.GetProxy(); - //var request = WebRequest.Create("http://localhost:54942/MultiTranslator/TranslateForSubtitleEdit"); - var request = WebRequest.Create("https://www.nikse.dk/MultiTranslator/TranslateForSubtitleEdit"); - request.Method = "POST"; - var postData = String.Format("languagePair={1}&text={0}", Utilities.UrlEncode(input), "svda"); - var byteArray = Encoding.UTF8.GetBytes(postData); - request.ContentType = "application/x-www-form-urlencoded"; - request.ContentLength = byteArray.Length; - using (var dataStream = request.GetRequestStream()) - { - dataStream.Write(byteArray, 0, byteArray.Length); - } - - using (var response = request.GetResponse()) - using (var reader = new StreamReader(response.GetResponseStream())) - { - return reader.ReadToEnd(); - } - } - - private void TranslateFromSwedishToDanishToolStripMenuItemClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - bool isSwedish = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle) == "sv"; - string promptText = _language.TranslateSwedishToDanish; - if (!isSwedish) - { - promptText = _language.TranslateSwedishToDanishWarning; - } - - if (MessageBox.Show(promptText, Title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) - { - try - { - _subtitleAlternate = new Subtitle(_subtitle); - _subtitleAlternateFileName = null; - int firstSelectedIndex = 0; - if (SubtitleListview1.SelectedItems.Count > 0) - { - firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - } - - _subtitleListViewIndex = -1; - - Cursor.Current = Cursors.WaitCursor; - ShowStatus(_language.TranslatingViaNikseDkMt); - var sb = new StringBuilder(); - var output = new StringBuilder(); - foreach (var p in _subtitle.Paragraphs) - { - var s = p.Text.Replace(Environment.NewLine, "
"); - s = "

" + s + "

"; - sb.Append(s); - - if (sb.Length > 9000) - { - output.Append(GetTranslateStringFromNikseDk(sb.ToString())); - sb.Length = 0; - } - } - - if (sb.Length > 0) - { - output.Append(GetTranslateStringFromNikseDk(sb.ToString())); - } - - MakeHistoryForUndo(_language.BeforeSwedishToDanishTranslation); - var result = output.ToString(); - if (result.Length > 0) - { - int index = 0; - foreach (var s in result.Split(new[] { "

", "

" }, StringSplitOptions.RemoveEmptyEntries)) - { - if (index < _subtitle.Paragraphs.Count) - { - _subtitle.Paragraphs[index].Text = s.Trim(); - } - - index++; - } - - ShowSource(); - SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); - SubtitleListview1.AutoSizeAllColumns(this); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - ShowStatus(_language.TranslationFromSwedishToDanishComplete); - SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); - _converted = true; - } - } - catch - { - ShowStatus(_language.TranslationFromSwedishToDanishFailed); - } - - Cursor.Current = Cursors.Default; - } - } - - /// - /// Undo or Redo - /// - /// True equals undo, false triggers redo - private void UndoToIndex(bool undo) - { - if (_networkSession != null) - { - return; - } - - lock (_syncUndo) - { - if (!undo && _undoIndex >= _subtitle.HistoryItems.Count - 1) - { - return; - } - - if (undo && (_subtitle == null || !_subtitle.CanUndo || _undoIndex < 0)) - { - return; - } - - // Add latest changes if any (also stop changes from being added while redoing/undoing) - timerTextUndo.Stop(); - timerAlternateTextUndo.Stop(); - _listViewTextTicks = 0; - _listViewAlternateTextTicks = 0; - TimerTextUndoTick(null, null); - TimerAlternateTextUndoTick(null, null); - - try - { - int selectedIndex = FirstSelectedIndex; - if (undo) - { - _subtitle.HistoryItems[_undoIndex].RedoParagraphs = new List(); - _subtitle.HistoryItems[_undoIndex].RedoParagraphsAlternate = new List(); - - foreach (var p in _subtitle.Paragraphs) - { - _subtitle.HistoryItems[_undoIndex].RedoParagraphs.Add(new Paragraph(p)); - } - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null) - { - foreach (var p in _subtitleAlternate.Paragraphs) - { - _subtitle.HistoryItems[_undoIndex].RedoParagraphsAlternate.Add(new Paragraph(p)); - } - } - - _subtitle.HistoryItems[_undoIndex].RedoFileName = _fileName; - _subtitle.HistoryItems[_undoIndex].RedoFileModified = _fileDateTime; - _subtitle.HistoryItems[_undoIndex].RedoOriginalFileName = _subtitleAlternateFileName; - - if (selectedIndex >= 0) - { - _subtitle.HistoryItems[_undoIndex].RedoParagraphs[selectedIndex].Text = - textBoxListViewText.Text; - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && - selectedIndex < _subtitle.HistoryItems[_undoIndex].RedoParagraphsAlternate.Count) - { - _subtitle.HistoryItems[_undoIndex].RedoParagraphsAlternate[selectedIndex].Text = - textBoxListViewTextAlternate.Text; - } - - _subtitle.HistoryItems[_undoIndex].RedoLineIndex = selectedIndex; - _subtitle.HistoryItems[_undoIndex].RedoLinePosition = textBoxListViewText.SelectionStart; - _subtitle.HistoryItems[_undoIndex].RedoLinePositionAlternate = textBoxListViewTextAlternate.SelectionStart; - } - else - { - _subtitle.HistoryItems[_undoIndex].RedoLineIndex = -1; - _subtitle.HistoryItems[_undoIndex].RedoLinePosition = -1; - } - } - else - { - _undoIndex++; - } - - var text = _subtitle.HistoryItems[_undoIndex].Description; - - _subtitleListViewIndex = -1; - textBoxListViewText.Text = string.Empty; - textBoxListViewTextAlternate.Text = string.Empty; - string oldFileName = _fileName; - DateTime oldFileDateTime = _fileDateTime; - - string oldAlternameFileName = _subtitleAlternateFileName; - _fileName = _subtitle.UndoHistory(_undoIndex, out var subtitleFormatFriendlyName, out _fileDateTime, out _subtitleAlternate, out _subtitleAlternateFileName); - if (string.IsNullOrEmpty(oldAlternameFileName) && !string.IsNullOrEmpty(_subtitleAlternateFileName)) - { - SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); - SubtitleListview1.AutoSizeAllColumns(this); - } - else if (SubtitleListview1.IsAlternateTextColumnVisible && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count == 0) - { - RemoveAlternate(true, false); - } - - if (!undo) - { - // TODO: Sometimes redo paragraphs can be null - how? - if (_subtitle.HistoryItems[_undoIndex].RedoParagraphs != null) - { - _subtitle.Paragraphs.Clear(); - foreach (var p in _subtitle.HistoryItems[_undoIndex].RedoParagraphs) - { - _subtitle.Paragraphs.Add(new Paragraph(p)); - } - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null) - { - _subtitleAlternate.Paragraphs.Clear(); - foreach (var p in _subtitle.HistoryItems[_undoIndex].RedoParagraphsAlternate) - { - _subtitleAlternate.Paragraphs.Add(new Paragraph(p)); - } - } - } - else - { - System.Diagnostics.Debug.WriteLine("Undo failed at undo index: " + _undoIndex); - } - - _subtitle.HistoryItems[_undoIndex].RedoParagraphs = null; - _subtitle.HistoryItems[_undoIndex].RedoParagraphsAlternate = null; - if (SubtitleListview1.IsAlternateTextColumnVisible && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count == 0) - { - RemoveAlternate(true, false); - } - } - - if (oldFileName == null || oldFileName.Equals(_fileName, StringComparison.OrdinalIgnoreCase)) - { - _fileDateTime = oldFileDateTime; // undo will not give overwrite-newer-file warning - } - - comboBoxSubtitleFormats.SelectedIndexChanged -= ComboBoxSubtitleFormatsSelectedIndexChanged; - SetCurrentFormat(subtitleFormatFriendlyName); - comboBoxSubtitleFormats.SelectedIndexChanged += ComboBoxSubtitleFormatsSelectedIndexChanged; - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - - if (selectedIndex >= _subtitle.Paragraphs.Count) - { - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.Paragraphs.Count - 1, true); - } - else if (selectedIndex >= 0 && selectedIndex < _subtitle.Paragraphs.Count) - { - SubtitleListview1.SelectIndexAndEnsureVisible(selectedIndex, true); - } - else - { - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - } - - audioVisualizer.Invalidate(); - if (undo) - { - if (_subtitle.HistoryItems[_undoIndex].LineIndex == FirstSelectedIndex) - { - textBoxListViewText.SelectionStart = _subtitle.HistoryItems[_undoIndex].LinePosition; - if (_subtitleAlternate != null) - { - textBoxListViewTextAlternate.SelectionStart = - _subtitle.HistoryItems[_undoIndex].LinePositionAlternate; - } - } - - ShowStatus(_language.UndoPerformed + ": " + text.Replace(Environment.NewLine, " ")); - _undoIndex--; - } - else - { - if (_subtitle.HistoryItems[_undoIndex].RedoLineIndex >= 0 && - _subtitle.HistoryItems[_undoIndex].RedoLineIndex == FirstSelectedIndex) - { - textBoxListViewText.SelectionStart = _subtitle.HistoryItems[_undoIndex].RedoLinePosition; - } - - if (_subtitleAlternate != null && _subtitle.HistoryItems[_undoIndex].RedoLineIndex >= 0 && - _subtitle.HistoryItems[_undoIndex].RedoLineIndex == FirstSelectedIndex) - { - textBoxListViewTextAlternate.SelectionStart = _subtitle.HistoryItems[_undoIndex].RedoLinePositionAlternate; - } - - _fileName = _subtitle.HistoryItems[_undoIndex].RedoFileName; - _subtitleAlternateFileName = _subtitle.HistoryItems[_undoIndex].RedoOriginalFileName; - ShowStatus(_language.RedoPerformed); - } - } - catch (Exception exception) - { - System.Diagnostics.Debug.WriteLine(exception.Message); - } - - timerTextUndo.Start(); - timerAlternateTextUndo.Start(); - SetTitle(); - SetListViewStateImages(); - } - } - - private void ShowHistoryforUndoToolStripMenuItemClick(object sender, EventArgs e) - { - if (_subtitle != null && _subtitle.CanUndo) - { - ReloadFromSourceView(); - using (var showHistory = new ShowHistory()) - { - showHistory.Initialize(_subtitle, _undoIndex); - if (showHistory.ShowDialog(this) == DialogResult.OK) - { - _subtitleListViewIndex = -1; - textBoxListViewText.Text = string.Empty; - textBoxListViewTextAlternate.Text = string.Empty; - - Cursor.Current = Cursors.WaitCursor; - SubtitleListview1.BeginUpdate(); - int rollBackCount = 0; - while (_undoIndex > showHistory.SelectedIndex && rollBackCount < Subtitle.MaximumHistoryItems) - { - UndoToIndex(true); - rollBackCount++; - } - SubtitleListview1.EndUpdate(); - Cursor.Current = Cursors.Default; - audioVisualizer.Invalidate(); - } - } - } - else - { - MessageBox.Show(_language.NothingToUndo, Title, MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } - - private void ToolStripButtonSpellCheckClick(object sender, EventArgs e) - { - SpellCheck(true, 0); - } - - private void SpellCheckToolStripMenuItemClick(object sender, EventArgs e) - { - SpellCheck(true, 0); - } - - private void SpellCheck(bool autoDetect, int startFromLine) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - try - { - string dictionaryFolder = Utilities.DictionaryFolder; - if (!Directory.Exists(dictionaryFolder) || Directory.GetFiles(dictionaryFolder, "*.dic").Length == 0) - { - ShowGetDictionaries(); - return; - } - - if (_subtitle != null && _subtitle.Paragraphs.Count > 0) - { - if (_spellCheckForm != null) - { - var result = MessageBox.Show(_language.ContinueWithCurrentSpellCheck, Title, MessageBoxButtons.YesNoCancel); - if (result == DialogResult.Cancel) - { - return; - } - - if (result == DialogResult.No) - { - _spellCheckForm.Dispose(); - _spellCheckForm = new SpellCheck(); - _spellCheckForm.DoSpellCheck(autoDetect, _subtitle, dictionaryFolder, this, startFromLine); - } - else - { - _spellCheckForm.ContinueSpellCheck(_subtitle); - } - } - else - { - _spellCheckForm = new SpellCheck(); - _spellCheckForm.DoSpellCheck(autoDetect, _subtitle, dictionaryFolder, this, startFromLine); - } - } - } - catch (Exception ex) - { - MessageBox.Show(string.Format("{0}{1}{2}{3}{4}", ex.Source, Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace), _title, MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - public void ChangeWholeTextMainPart(ref int noOfChangedWords, ref bool firstChange, int i, Paragraph p) - { - SubtitleListview1.SetText(i, p.Text); - noOfChangedWords++; - if (firstChange) - { - MakeHistoryForUndo(_language.BeforeSpellCheck); - firstChange = false; - } - - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - ShowSource(); - } - else - { - RefreshSelectedParagraph(); - } - } - - public void DeleteLine() - { - MakeHistoryForUndo(Configuration.Settings.Language.Main.OneLineDeleted); - DeleteSelectedLines(); - } - - public void FocusParagraph(int index) - { - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - tabControlSubtitle.SelectedIndex = TabControlListView; - } - - if (tabControlSubtitle.SelectedIndex == TabControlListView) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - } - } - - private void RefreshSelectedParagraph() - { - var idx = FirstSelectedIndex; - if (idx == -1 && _subtitle?.Paragraphs?.Count > 0) - { - idx = 0; - } - - var p = _subtitle.GetParagraphOrDefault(idx); - _subtitleListViewIndex = -1; - SubtitleListview1_SelectedIndexChanged(null, null); - if (p != null) - { - SubtitleListview1.SetStartTimeAndDuration(idx, p, _subtitle.GetParagraphOrDefault(idx + 1), _subtitle.GetParagraphOrDefault(idx - 1)); - } - } - - private void RefreshSelectedParagraphs() - { - foreach (var index in SubtitleListview1.GetSelectedIndices()) - { - var p = _subtitle.GetParagraphOrDefault(index); - if (p != null) - { - SubtitleListview1.SetStartTimeAndDuration(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - } - } - - _subtitleListViewIndex = -1; - SubtitleListview1_SelectedIndexChanged(null, null); - } - - private int GetPositionFromWordIndex(string text, int wordIndex) - { - var sb = new StringBuilder(); - int index = -1; - for (int i = 0; i < text.Length; i++) - { - if (SpellCheckWordLists.SplitChars.Contains(text[i])) - { - if (sb.Length > 0) - { - index++; - if (index == wordIndex) - { - int pos = i - sb.Length; - if (pos > 0) - { - pos--; - } - - if (pos >= 0) - { - return pos; - } - } - } - - sb.Clear(); - } - else - { - sb.Append(text[i]); - } - } - - if (sb.Length > 0) - { - index++; - if (index == wordIndex) - { - int pos = text.Length - 1 - sb.Length; - if (pos >= 0) - { - return pos; - } - } - } - - return 0; - } - - public void CorrectWord(string changeWord, Paragraph p, string oldWord, ref bool firstChange, int wordIndex) - { - if (oldWord != changeWord) - { - if (firstChange) - { - MakeHistoryForUndo(_language.BeforeSpellCheck); - firstChange = false; - } - - int startIndex = p.Text.IndexOf(oldWord, StringComparison.Ordinal); - if (wordIndex >= 0) - { - startIndex = p.Text.IndexOf(oldWord, GetPositionFromWordIndex(p.Text, wordIndex), StringComparison.Ordinal); - } - - while (startIndex >= 0 && startIndex < p.Text.Length && p.Text.Substring(startIndex).Contains(oldWord)) - { - bool startOk = startIndex == 0 || - "«»“” <>-—+/'\"[](){}¿¡….,;:!?%&$£\r\n؛،؟\u200E\u200F\u202A\u202B\u202C\u202D\u202E\u00C2\u00A0".Contains(p.Text[startIndex - 1]) || - char.IsPunctuation(p.Text[startIndex - 1]) || - startIndex == p.Text.Length - oldWord.Length; - if (startOk) - { - int end = startIndex + oldWord.Length; - if (end <= p.Text.Length && end == p.Text.Length || - "«»“” ,.!?:;'()<>\"-—+/[]{}%&$£…\r\n؛،؟\u200E\u200F\u202A\u202B\u202C\u202D\u202E\u00C2\u00A0".Contains(p.Text[end]) || - char.IsPunctuation(p.Text[end])) - { - var lengthBefore = p.Text.Length; - p.Text = p.Text.Remove(startIndex, oldWord.Length).Insert(startIndex, changeWord); - var lengthAfter = p.Text.Length; - if (lengthAfter > lengthBefore) - { - startIndex += (lengthAfter - lengthBefore); - } - } - } - - if (startIndex + 2 >= p.Text.Length) - { - startIndex = -1; - } - else - { - startIndex = p.Text.IndexOf(oldWord, startIndex + 2, StringComparison.Ordinal); - } - - // stop if using index - if (wordIndex >= 0) - { - startIndex = -1; - } - } - - ShowStatus(string.Format(_language.SpellCheckChangedXToY, oldWord, changeWord)); - SubtitleListview1.SetText(_subtitle.GetIndex(p), p.Text); - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - ShowSource(); - } - else - { - RefreshSelectedParagraph(); - } - } - } - - private void GetDictionariesToolStripMenuItem_Click(object sender, EventArgs e) - { - ShowGetDictionaries(); - } - - private void ShowGetDictionaries() - { - using (var form = new GetDictionaries()) - { - form.ShowDialog(this); - } - } - - private void ContextMenuStripListviewOpening(object sender, System.ComponentModel.CancelEventArgs e) - { - var format = GetCurrentSubtitleFormat(); - var formatType = format.GetType(); - var coordinates = SubtitleListview1.PointToClient(Cursor.Position); - var hitTest = SubtitleListview1.HitTest(coordinates); - if (coordinates.Y < 19 || (hitTest.Item != null && hitTest.Item.Index == 0 && coordinates.Y < hitTest.Item.Position.Y)) - { - e.Cancel = true; - var cm = new ContextMenuStrip(); - var contextMenuStripLvHeaderResizeToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.Main.Menu.ContextMenu.SizeAllColumnsToFit); - contextMenuStripLvHeaderResizeToolStripMenuItem.Click += (sender2, e2) => { SubtitleListview1.AutoSizeColumns(); }; - cm.Items.Add(contextMenuStripLvHeaderResizeToolStripMenuItem); - - var tss = new ToolStripSeparator(); - UiUtil.FixFonts(tss); - cm.Items.Add(tss); - - // End time - var contextMenuStripLvHeaderEndTimeToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.General.EndTime); - contextMenuStripLvHeaderEndTimeToolStripMenuItem.CheckOnClick = true; - contextMenuStripLvHeaderEndTimeToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnEndTime; - contextMenuStripLvHeaderEndTimeToolStripMenuItem.Click += (sender2, e2) => - { - SubtitleListview1.BeginUpdate(); - Configuration.Settings.Tools.ListViewShowColumnEndTime = contextMenuStripLvHeaderEndTimeToolStripMenuItem.Checked; - if (Configuration.Settings.Tools.ListViewShowColumnEndTime) - { - SubtitleListview1.ShowEndColumn(Configuration.Settings.Language.General.EndTime); - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.End); - } - - SaveSubtitleListviewIndices(); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - SubtitleListview1.EndUpdate(); - }; - cm.Items.Add(contextMenuStripLvHeaderEndTimeToolStripMenuItem); - - // Duration - var contextMenuStripLvHeaderDurationToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.General.Duration); - contextMenuStripLvHeaderDurationToolStripMenuItem.CheckOnClick = true; - contextMenuStripLvHeaderDurationToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnDuration; - contextMenuStripLvHeaderDurationToolStripMenuItem.Click += (sender2, e2) => - { - SubtitleListview1.BeginUpdate(); - Configuration.Settings.Tools.ListViewShowColumnDuration = contextMenuStripLvHeaderDurationToolStripMenuItem.Checked; - if (Configuration.Settings.Tools.ListViewShowColumnDuration) - { - SubtitleListview1.ShowDurationColumn(Configuration.Settings.Language.General.Duration); - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Duration); - } - - SaveSubtitleListviewIndices(); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - SubtitleListview1.EndUpdate(); - }; - cm.Items.Add(contextMenuStripLvHeaderDurationToolStripMenuItem); - - // CPS - var contextMenuStripLvHeaderCpsToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.General.CharsPerSec); - contextMenuStripLvHeaderCpsToolStripMenuItem.CheckOnClick = true; - contextMenuStripLvHeaderCpsToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnCharsPerSec; - contextMenuStripLvHeaderCpsToolStripMenuItem.Click += (sender2, e2) => - { - SubtitleListview1.BeginUpdate(); - Configuration.Settings.Tools.ListViewShowColumnCharsPerSec = contextMenuStripLvHeaderCpsToolStripMenuItem.Checked; - if (Configuration.Settings.Tools.ListViewShowColumnCharsPerSec) - { - SubtitleListview1.ShowCharsSecColumn(Configuration.Settings.Language.General.CharsPerSec); - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); - } - - SaveSubtitleListviewIndices(); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - SubtitleListview1.EndUpdate(); - }; - cm.Items.Add(contextMenuStripLvHeaderCpsToolStripMenuItem); - - // WPM - var contextMenuStripLvHeaderWpmToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.General.WordsPerMin); - contextMenuStripLvHeaderWpmToolStripMenuItem.CheckOnClick = true; - contextMenuStripLvHeaderWpmToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnWordsPerMin; - contextMenuStripLvHeaderWpmToolStripMenuItem.Click += (sender2, e2) => - { - SubtitleListview1.BeginUpdate(); - Configuration.Settings.Tools.ListViewShowColumnWordsPerMin = contextMenuStripLvHeaderWpmToolStripMenuItem.Checked; - if (Configuration.Settings.Tools.ListViewShowColumnWordsPerMin) - { - SubtitleListview1.ShowWordsMinColumn(Configuration.Settings.Language.General.WordsPerMin); - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); - } - - SaveSubtitleListviewIndices(); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - SubtitleListview1.EndUpdate(); - }; - cm.Items.Add(contextMenuStripLvHeaderWpmToolStripMenuItem); - - // GAP - var contextMenuStripLvHeaderGapToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.General.Gap); - contextMenuStripLvHeaderGapToolStripMenuItem.CheckOnClick = true; - contextMenuStripLvHeaderGapToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnGap; - contextMenuStripLvHeaderGapToolStripMenuItem.Click += (sender2, e2) => - { - SubtitleListview1.BeginUpdate(); - Configuration.Settings.Tools.ListViewShowColumnGap = contextMenuStripLvHeaderGapToolStripMenuItem.Checked; - if (Configuration.Settings.Tools.ListViewShowColumnGap) - { - SubtitleListview1.ShowGapColumn(Configuration.Settings.Language.General.Gap); - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Gap); - } - - SaveSubtitleListviewIndices(); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - SubtitleListview1.EndUpdate(); - }; - cm.Items.Add(contextMenuStripLvHeaderGapToolStripMenuItem); - - if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha) || formatType == typeof(CsvNuendo)) - { - // ACTOR - var actorTitle = formatType == typeof(CsvNuendo) ? Configuration.Settings.Language.General.Character : Configuration.Settings.Language.General.Actor; - var contextMenuStripLvHeaderActorToolStripMenuItem = new ToolStripMenuItem(actorTitle); - contextMenuStripLvHeaderActorToolStripMenuItem.CheckOnClick = true; - contextMenuStripLvHeaderActorToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnActor; - contextMenuStripLvHeaderActorToolStripMenuItem.Click += (sender2, e2) => - { - SubtitleListview1.BeginUpdate(); - Configuration.Settings.Tools.ListViewShowColumnActor = contextMenuStripLvHeaderActorToolStripMenuItem.Checked; - if (Configuration.Settings.Tools.ListViewShowColumnActor) - { - SubtitleListview1.ShowActorColumn(actorTitle); - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Actor); - } - - SaveSubtitleListviewIndices(); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - SubtitleListview1.EndUpdate(); - }; - cm.Items.Add(contextMenuStripLvHeaderActorToolStripMenuItem); - } - - if (formatType == typeof(TimedText10)) - { - // REGION - var contextMenuStripLvHeaderRegionToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.General.Region); - contextMenuStripLvHeaderRegionToolStripMenuItem.CheckOnClick = true; - contextMenuStripLvHeaderRegionToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnRegion; - contextMenuStripLvHeaderRegionToolStripMenuItem.Click += (sender2, e2) => - { - SubtitleListview1.BeginUpdate(); - Configuration.Settings.Tools.ListViewShowColumnRegion = contextMenuStripLvHeaderRegionToolStripMenuItem.Checked; - if (Configuration.Settings.Tools.ListViewShowColumnRegion) - { - SubtitleListview1.ShowRegionColumn(Configuration.Settings.Language.General.Region); - } - else - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Region); - } - - SaveSubtitleListviewIndices(); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - SubtitleListview1.EndUpdate(); - }; - cm.Items.Add(contextMenuStripLvHeaderRegionToolStripMenuItem); - } - - cm.Show(SubtitleListview1, coordinates); - return; - } - - toolStripMenuItemPreview.Visible = formatType == typeof(WebVTT) && - !string.IsNullOrEmpty(VideoFileName) && - (VideoFileName.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) || VideoFileName.EndsWith(".m4v", StringComparison.OrdinalIgnoreCase) || VideoFileName.EndsWith(".webm", StringComparison.OrdinalIgnoreCase)) && - IsSubtitleLoaded; - - toolStripMenuItemSetRegion.Visible = false; - toolStripMenuItemSetLanguage.Visible = false; - List actors = null; - if ((formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha) || formatType == typeof(CsvNuendo)) && SubtitleListview1.SelectedItems.Count > 0) - { - actors = new List(); - toolStripMenuItemWebVTT.Visible = false; - var styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); - setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Clear(); - foreach (var style in styles) - { - setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Add(style, null, tsi_Click); - } - - setStylesForSelectedLinesToolStripMenuItem.Visible = styles.Count > 1; - toolStripMenuItemAssStyles.Visible = true; - if (formatType == typeof(AdvancedSubStationAlpha)) - { - toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.AdvancedSubStationAlphaStyles; - setStylesForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.AdvancedSubStationAlphaSetStyle; - } - else - { - toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.SubStationAlphaStyles; - setStylesForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.SubStationAlphaSetStyle; - } - - // actor - foreach (var p in _subtitle.Paragraphs) - { - if (!string.IsNullOrEmpty(p.Actor) && !actors.Contains(p.Actor)) - { - actors.Add(p.Actor); - } - - actors.Sort(); - } - - setActorForSelectedLinesToolStripMenuItem.DropDownItems.Clear(); - foreach (var actor in actors) - { - setActorForSelectedLinesToolStripMenuItem.DropDownItems.Add(actor, null, actor_Click); - } - - if (actors.Count > 0) - { - var tss = new ToolStripSeparator(); - UiUtil.FixFonts(tss); - setActorForSelectedLinesToolStripMenuItem.DropDownItems.Add(tss); - } - - setActorForSelectedLinesToolStripMenuItem.DropDownItems.Add(_language.Menu.ContextMenu.NewActor, null, SetNewActor); - if (actors.Count > 0) - { - setActorForSelectedLinesToolStripMenuItem.DropDownItems.Add(_language.Menu.ContextMenu.RemoveActors, null, RemoveActors); - } - } - else if (((formatType == typeof(TimedText10) && Configuration.Settings.SubtitleSettings.TimedText10ShowStyleAndLanguage) || formatType == typeof(ItunesTimedText)) && SubtitleListview1.SelectedItems.Count > 0) - { - toolStripMenuItemWebVTT.Visible = false; - toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.TimedTextStyles; - var styles = TimedText10.GetStylesFromHeader(_subtitle.Header); - setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Clear(); - foreach (var style in styles) - { - setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Add(style, null, tsi_Click); - } - - setStylesForSelectedLinesToolStripMenuItem.Visible = styles.Count >= 1; - toolStripMenuItemAssStyles.Visible = true; - setStylesForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.TimedTextSetStyle; - - // regions - if (string.IsNullOrEmpty(_subtitle.Header) || !_subtitle.Header.Contains("http://www.w3.org/ns/ttml")) - { - _subtitle.Header = new TimedText10().ToText(_subtitle, string.Empty); - } - - var regions = TimedText10.GetRegionsFromHeader(_subtitle.Header); - toolStripMenuItemSetRegion.DropDownItems.Clear(); - toolStripMenuItemSetRegion.Text = _language.Menu.ContextMenu.TimedTextSetRegion; - if (regions.Count > 0) - { - toolStripMenuItemSetRegion.Visible = true; - foreach (var region in regions) - { - toolStripMenuItemSetRegion.DropDownItems.Add(region, null, SetRegionClick); - } - - toolStripMenuItemSetRegion.DropDownItems.Add("-"); - var clear = new ToolStripMenuItem(Configuration.Settings.Language.DvdSubRip.Clear); - toolStripMenuItemSetRegion.DropDownItems.Add(clear); - clear.Click += (sender2, e2) => - { - MakeHistoryForUndo("Set region: " + Configuration.Settings.Language.DvdSubRip.Clear); - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Region = null; - SubtitleListview1.SetTimeAndText(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); - } - }; - } - else - { - toolStripMenuItemSetRegion.Visible = false; - } - - // languages - var languages = TimedText10.GetUsedLanguages(_subtitle); - toolStripMenuItemSetLanguage.DropDownItems.Clear(); - toolStripMenuItemSetLanguage.Text = _language.Menu.ContextMenu.TimedTextSetLanguage; - toolStripMenuItemSetLanguage.Visible = true; - if (languages.Count > 0) - { - foreach (var language in languages) - { - toolStripMenuItemSetLanguage.DropDownItems.Add(language, null, AddLanguageClick); - } - - toolStripMenuItemSetLanguage.DropDownItems.Add("-"); - } - - var newItem = new ToolStripMenuItem(_language.New); - toolStripMenuItemSetLanguage.DropDownItems.Add(newItem); - newItem.Click += (senderNew, eNew) => - { - var moreLanguages = new List(); - foreach (CultureInfo x in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) - { - var twoLetterLower = x.TwoLetterISOLanguageName.ToLowerInvariant(); - if (!languages.Contains(twoLetterLower) && - !languages.Contains(x.GetThreeLetterIsoLanguageName().ToLowerInvariant()) && - twoLetterLower != "iv") - { - moreLanguages.Add(x); - } - } - - moreLanguages = moreLanguages.OrderBy(p => p.TwoLetterISOLanguageName).ToList(); - using (var form = new TimedTextNewLanguage(moreLanguages, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle))) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - if (!string.IsNullOrEmpty(form.Language)) - { - MakeHistoryForUndo("Set language: " + form.Language); - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Language = form.Language; - _subtitle.Paragraphs[index].Extra = TimedText10.SetExtra(_subtitle.Paragraphs[index]); - SubtitleListview1.SetExtraText(index, _subtitle.Paragraphs[index].Extra, SubtitleListview1.ForeColor); - } - } - } - } - }; - - if (languages.Count > 0) - { - var clearLanguage = new ToolStripMenuItem(Configuration.Settings.Language.DvdSubRip.Clear); - toolStripMenuItemSetLanguage.DropDownItems.Add(clearLanguage); - clearLanguage.Click += (sender2, e2) => - { - MakeHistoryForUndo("Set language: " + Configuration.Settings.Language.DvdSubRip.Clear); - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Language = null; - _subtitle.Paragraphs[index].Extra = TimedText10.SetExtra(_subtitle.Paragraphs[index]); - SubtitleListview1.SetTimeAndText(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); - } - }; - } - } - else if ((formatType == typeof(Sami) || formatType == typeof(SamiModern)) && SubtitleListview1.SelectedItems.Count > 0) - { - toolStripMenuItemWebVTT.Visible = false; - toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.TimedTextStyles; - var styles = Sami.GetStylesFromHeader(_subtitle.Header); - setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Clear(); - foreach (var style in styles) - { - setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Add(style, null, tsi_Click); - } - - setStylesForSelectedLinesToolStripMenuItem.Visible = styles.Count > 1; - toolStripMenuItemAssStyles.Visible = false; - setStylesForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.SamiSetStyle; - } - else if (formatType == typeof(WebVTT) && SubtitleListview1.SelectedItems.Count > 0) - { - setStylesForSelectedLinesToolStripMenuItem.Visible = false; - toolStripMenuItemAssStyles.Visible = false; - toolStripMenuItemWebVTT.Visible = true; - var voices = WebVTT.GetVoices(_subtitle); - toolStripMenuItemWebVTT.DropDownItems.Clear(); - foreach (var style in voices) - { - toolStripMenuItemWebVTT.DropDownItems.Add(style, null, WebVTTSetVoice); - } - - toolStripMenuItemWebVTT.DropDownItems.Add(_language.Menu.ContextMenu.WebVTTSetNewVoice, null, WebVTTSetNewVoice); - if (voices.Count > 0) - { - toolStripMenuItemWebVTT.DropDownItems.Add(_language.Menu.ContextMenu.WebVTTRemoveVoices, null, WebVTTRemoveVoices); - } - } - else if ((format.Name == "Nuendo" && SubtitleListview1.SelectedItems.Count > 0)) - { - toolStripMenuItemWebVTT.Visible = false; - var styles = GetNuendoStyles(); - setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Clear(); - foreach (var style in styles) - { - setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Add(style, null, NuendoSetStyle); - } - - setStylesForSelectedLinesToolStripMenuItem.Visible = styles.Count > 1; - toolStripMenuItemAssStyles.Visible = false; - setStylesForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.NuendoSetStyle; - } - else - { - setStylesForSelectedLinesToolStripMenuItem.Visible = false; - toolStripMenuItemAssStyles.Visible = false; - toolStripMenuItemWebVTT.Visible = false; - } - - if (actors != null) - { - setActorForSelectedLinesToolStripMenuItem.Visible = true; - } - else - { - setActorForSelectedLinesToolStripMenuItem.Visible = false; - } - - if (formatType == typeof(Ebu)) - { - Ebu.EbuGeneralSubtitleInformation header; - if (_subtitle != null && _subtitle.Header != null && (_subtitle.Header.Contains("STL2") || _subtitle.Header.Contains("STL3"))) - { - header = Ebu.ReadHeader(Encoding.UTF8.GetBytes(_subtitle.Header)); - } - else - { - header = new Ebu.EbuGeneralSubtitleInformation(); - } - - var open = header.DisplayStandardCode != "1" && header.DisplayStandardCode != "2"; - boxToolStripMenuItem.Visible = open; - } - else - { - boxToolStripMenuItem.Visible = false; - } - - microsoftBingTranslateToolStripMenuItem.Visible = - !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorApiKey) && - !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint); - - toolStripMenuItemGoogleMicrosoftTranslateSelLine.Visible = false; - if (SubtitleListview1.SelectedItems.Count == 0) - { - contextMenuStripEmpty.Show(MousePosition.X, MousePosition.Y); - e.Cancel = true; - } - else - { - bool noNetWorkSession = _networkSession == null; - - toolStripMenuItemSaveSelectedLines.Visible = false; - toolStripMenuItemInsertBefore.Visible = true; - toolStripMenuItemInsertAfter.Visible = true; - toolStripMenuItemInsertSubtitle.Visible = noNetWorkSession; - toolStripMenuItemMergeLines.Visible = true; - mergeAfterToolStripMenuItem.Visible = true; - mergeBeforeToolStripMenuItem.Visible = true; - splitLineToolStripMenuItem.Visible = true; - toolStripSeparator7.Visible = true; - typeEffectToolStripMenuItem.Visible = noNetWorkSession; - karokeeEffectToolStripMenuItem.Visible = noNetWorkSession; - toolStripSeparatorAdvancedFunctions.Visible = noNetWorkSession; - adjustDisplayTimeForSelectedLinesToolStripMenuItem.Visible = true; - visualSyncSelectedLinesToolStripMenuItem.Visible = true; - toolStripMenuItemGoogleMicrosoftTranslateSelLine.Visible = false; - toolStripMenuItemUnbreakLines.Visible = true; - toolStripMenuItemAutoBreakLines.Visible = true; - toolStripSeparatorBreakLines.Visible = true; - toolStripMenuItemSurroundWithMusicSymbols.Visible = IsUnicode || Configuration.Settings.Tools.MusicSymbol == "#" || Configuration.Settings.Tools.MusicSymbol == "*"; - if (SubtitleListview1.SelectedItems.Count == 1) - { - toolStripMenuItemMergeLines.Visible = false; - visualSyncSelectedLinesToolStripMenuItem.Visible = false; - toolStripMenuItemUnbreakLines.Visible = false; - toolStripMenuItemAutoBreakLines.Visible = false; - toolStripSeparatorBreakLines.Visible = false; - if (_subtitleAlternate != null && noNetWorkSession && !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftBingApiId)) - { - toolStripMenuItemGoogleMicrosoftTranslateSelLine.Visible = true; - } - - toolStripMenuItemMergeDialog.Visible = false; - } - else if (SubtitleListview1.SelectedItems.Count == 2) - { - toolStripMenuItemInsertBefore.Visible = false; - toolStripMenuItemInsertAfter.Visible = false; - toolStripMenuItemInsertSubtitle.Visible = false; - mergeAfterToolStripMenuItem.Visible = false; - mergeBeforeToolStripMenuItem.Visible = false; - splitLineToolStripMenuItem.Visible = false; - toolStripMenuItemMergeDialog.Visible = true; - } - else if (SubtitleListview1.SelectedItems.Count >= 2) - { - toolStripMenuItemSaveSelectedLines.Visible = true; - toolStripMenuItemInsertBefore.Visible = false; - toolStripMenuItemInsertAfter.Visible = false; - toolStripMenuItemInsertSubtitle.Visible = false; - splitLineToolStripMenuItem.Visible = false; - mergeAfterToolStripMenuItem.Visible = false; - mergeBeforeToolStripMenuItem.Visible = false; - toolStripSeparator7.Visible = false; - - if (SubtitleListview1.SelectedItems.Count > 25) - { - toolStripMenuItemMergeLines.Visible = false; - } - else if (SubtitleListview1.SelectedItems.Count > 2) - { // only allow merge if text is not way too long - try - { - int totalLength = 0; - foreach (int index in SubtitleListview1.SelectedIndices) - { - totalLength += _subtitle.Paragraphs[index].Text.Length; - } - - if (totalLength > Configuration.Settings.General.SubtitleLineMaximumLength * 2.5) - { - toolStripMenuItemMergeLines.Visible = false; - } - } - catch - { - } - } - - toolStripMenuItemMergeDialog.Visible = false; - } - - if (formatType != typeof(SubRip)) - { - toolStripSeparatorAdvancedFunctions.Visible = SubtitleListview1.SelectedItems.Count == 1 && noNetWorkSession; - } - } - - toolStripMenuItemPasteSpecial.Visible = Clipboard.ContainsText(); - toolStripMenuItemSurroundWithMusicSymbols.Text = Configuration.Settings.Tools.MusicSymbol; - if (string.IsNullOrEmpty(Configuration.Settings.Tools.MusicSymbol)) - { - toolStripMenuItemSurroundWithMusicSymbols.Visible = false; - } - } - - private void tsi_Click(object sender, EventArgs e) - { - string style = (sender as ToolStripItem).Text; - if (!string.IsNullOrEmpty(style)) - { - MakeHistoryForUndo("Set style: " + style); - - var format = GetCurrentSubtitleFormat(); - var formatType = format.GetType(); - if ((formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText))) - { - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Style = style; - _subtitle.Paragraphs[index].Extra = TimedText10.SetExtra(_subtitle.Paragraphs[index]); - SubtitleListview1.SetExtraText(index, _subtitle.Paragraphs[index].Extra, SubtitleListview1.ForeColor); - } - } - else - { - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Extra = style; - SubtitleListview1.SetExtraText(index, style, SubtitleListview1.ForeColor); - } - } - } - } - - private void actor_Click(object sender, EventArgs e) - { - string actor = (sender as ToolStripItem).Text; - if (!string.IsNullOrEmpty(actor)) - { - MakeHistoryForUndo(Configuration.Settings.Language.Main.Menu.ContextMenu.SetActor + ": " + actor); - - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Actor = actor; - SubtitleListview1.SetTimeAndText(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); - } - } - } - - private void SetRegionClick(object sender, EventArgs e) - { - string region = (sender as ToolStripItem).Text; - if (!string.IsNullOrEmpty(region)) - { - MakeHistoryForUndo("Set region: " + region); - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Region = region; - SubtitleListview1.SetTimeAndText(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); - } - } - } - - private void AddLanguageClick(object sender, EventArgs e) - { - string lang = (sender as ToolStripItem).Text; - if (!string.IsNullOrEmpty(lang)) - { - MakeHistoryForUndo("Set language: " + lang); - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Language = lang; - _subtitle.Paragraphs[index].Extra = TimedText10.SetExtra(_subtitle.Paragraphs[index]); - SubtitleListview1.SetExtraText(index, _subtitle.Paragraphs[index].Extra, SubtitleListview1.ForeColor); - } - } - } - - private void NuendoSetStyle(object sender, EventArgs e) - { - string style = (sender as ToolStripItem).Text; - if (!string.IsNullOrEmpty(style)) - { - int indexOfComment = style.IndexOf('['); - if (indexOfComment > 0) - { - style = style.Substring(0, indexOfComment).Trim(); - } - - MakeHistoryForUndo("Set style: " + style); - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Extra = style; - _subtitle.Paragraphs[index].Actor = style; - SubtitleListview1.SetExtraText(index, style, SubtitleListview1.ForeColor); - } - } - } - - private void WebVTTSetVoice(object sender, EventArgs e) - { - string voice = (sender as ToolStripItem).Text; - if (!string.IsNullOrEmpty(voice)) - { - MakeHistoryForUndo("Set voice: " + voice); - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Text = WebVTT.RemoveTag("v", _subtitle.Paragraphs[index].Text); - _subtitle.Paragraphs[index].Text = string.Format("{1}", voice, _subtitle.Paragraphs[index].Text); - SubtitleListview1.SetText(index, _subtitle.Paragraphs[index].Text); - } - - RefreshSelectedParagraph(); - } - } - - private void WebVTTSetNewVoice(object sender, EventArgs e) - { - using (var form = new TextPrompt(Configuration.Settings.Language.WebVttNewVoice.Title, Configuration.Settings.Language.WebVttNewVoice.VoiceName)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - string voice = form.InputText; - if (!string.IsNullOrEmpty(voice)) - { - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Text = WebVTT.RemoveTag("v", _subtitle.Paragraphs[index].Text); - _subtitle.Paragraphs[index].Text = string.Format("{1}", voice, _subtitle.Paragraphs[index].Text); - SubtitleListview1.SetText(index, _subtitle.Paragraphs[index].Text); - } - - RefreshSelectedParagraph(); - } - } - } - } - - private void SetNewActor(object sender, EventArgs e) - { - using (var form = new TextPrompt(Configuration.Settings.Language.Main.Menu.ContextMenu.NewActor.Replace("...", string.Empty), Configuration.Settings.Language.General.Actor)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - string actor = form.InputText; - if (!string.IsNullOrEmpty(actor)) - { - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Actor = actor; - SubtitleListview1.SetTimeAndText(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); - } - } - } - } - } - - private void WebVTTRemoveVoices(object sender, EventArgs e) - { - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Text = WebVTT.RemoveTag("v", _subtitle.Paragraphs[index].Text); - SubtitleListview1.SetText(index, _subtitle.Paragraphs[index].Text); - } - - RefreshSelectedParagraph(); - } - - private void RemoveActors(object sender, EventArgs e) - { - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Actor = null; - SubtitleListview1.SetTimeAndText(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); - } - } - - private void WebVTTSetVoiceTextBox(object sender, EventArgs e) - { - string voice = (sender as ToolStripItem).Text; - if (!string.IsNullOrEmpty(voice)) - { - var tb = GetFocusedTextBox(); - - if (tb.SelectionLength > 0) - { - string s = tb.SelectedText; - s = WebVTT.RemoveTag("v", s); - if (tb.SelectedText == tb.Text) - { - s = string.Format("{1}", voice, s); - } - else - { - s = string.Format("{1}", voice, s); - } - - tb.SelectedText = s; - } - } - } - - private void WebVTTSetNewVoiceTextBox(object sender, EventArgs e) - { - using (var form = new TextPrompt(Configuration.Settings.Language.WebVttNewVoice.Title, Configuration.Settings.Language.WebVttNewVoice.VoiceName)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - string voice = form.InputText; - if (!string.IsNullOrEmpty(voice)) - { - var tb = GetFocusedTextBox(); - - if (tb.SelectionLength > 0) - { - string s = tb.SelectedText; - s = WebVTT.RemoveTag("v", s); - if (tb.SelectedText == tb.Text) - { - s = string.Format("{1}", voice, s); - } - else - { - s = string.Format("{1}", voice, s); - } - - tb.SelectedText = s; - } - } - } - } - } - - private void BoldToolStripMenuItemClick(object sender, EventArgs e) - { - ListViewToggleTag(HtmlUtil.TagBold); - } - - private void ItalicToolStripMenuItemClick(object sender, EventArgs e) - { - ListViewToggleTag(HtmlUtil.TagItalic); - } - - private void UnderlineToolStripMenuItemClick(object sender, EventArgs e) - { - ListViewToggleTag(HtmlUtil.TagUnderline); - } - - private void ListViewToggleTag(string tag) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) - { - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - MakeHistoryForUndo(string.Format(_language.BeforeAddingTagX, tag)); - - var indices = new List(); - foreach (ListViewItem item in SubtitleListview1.SelectedItems) - { - indices.Add(item.Index); - } - - SubtitleListview1.BeginUpdate(); - foreach (int i in indices) - { - var p = _subtitle.GetParagraphOrDefault(i); - if (p != null) - { - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(i, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - original.Text = HtmlUtil.ToggleTag(original.Text, tag); - SubtitleListview1.SetAlternateText(i, original.Text); - } - } - - p.Text = HtmlUtil.ToggleTag(p.Text, tag); - SubtitleListview1.SetText(i, p.Text); - } - } - - SubtitleListview1.EndUpdate(); - - ShowStatus(string.Format(_language.TagXAdded, tag)); - ShowSource(); - RefreshSelectedParagraph(); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - } - } - - private void ToolStripMenuItemDeleteClick(object sender, EventArgs e) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) - { - string statusText; - string historyText; - string askText; - - if (SubtitleListview1.SelectedItems.Count > 1) - { - statusText = string.Format(_language.XLinesDeleted, SubtitleListview1.SelectedItems.Count); - historyText = string.Format(_language.BeforeDeletingXLines, SubtitleListview1.SelectedItems.Count); - askText = string.Format(_language.DeleteXLinesPrompt, SubtitleListview1.SelectedItems.Count); - } - else - { - statusText = _language.OneLineDeleted; - historyText = _language.BeforeDeletingOneLine; - askText = _language.DeleteOneLinePrompt; - } - - if (Configuration.Settings.General.PromptDeleteLines && MessageBox.Show(askText, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - _cutText = string.Empty; - return; - } - - if (!string.IsNullOrEmpty(_cutText)) - { - Clipboard.SetText(_cutText); - _cutText = string.Empty; - } - - MakeHistoryForUndo(historyText); - DeleteSelectedLines(); - - ResetTextInfoIfEmpty(); - - ShowStatus(statusText); - ShowSource(); - } - } - - private void ResetTextInfoIfEmpty() - { - if (_subtitle.Paragraphs.Count == 0) - { - labelStartTimeWarning.Text = string.Empty; - labelDurationWarning.Text = string.Empty; - _subtitleListViewIndex = -1; - textBoxListViewText.Text = string.Empty; - textBoxListViewTextAlternate.Text = string.Empty; - textBoxListViewText.Enabled = false; - textBoxListViewText.BackColor = SystemColors.ActiveBorder; - textBoxListViewTextAlternate.BackColor = SystemColors.ActiveBorder; - buttonSplitLine.Visible = false; - labelTextLineLengths.Text = string.Empty; - labelCharactersPerSecond.Text = string.Empty; - labelTextLineTotal.Text = string.Empty; - textBoxListViewText.Enabled = false; - labelSingleLine.Text = string.Empty; - labelSingleLinePixels.Text = string.Empty; - timeUpDownStartTime.TimeCode = new TimeCode(); - numericUpDownDuration.Value = 0; - ShowHideBookmark(new Paragraph()); - labelAlternateSingleLine.Text = string.Empty; - labelAlternateSingleLinePixels.Text = string.Empty; - textBoxListViewTextAlternate.Enabled = false; - labelAlternateCharactersPerSecond.Text = string.Empty; - labelTextAlternateLineLengths.Text = string.Empty; - labelTextAlternateLineTotal.Text = string.Empty; - } - } - - private void DeleteSelectedLines() - { - _subtitleListViewIndex = -1; - textBoxListViewText.Text = string.Empty; - textBoxListViewTextAlternate.Text = string.Empty; - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - var alternateIndices = new List(); - foreach (ListViewItem item in SubtitleListview1.SelectedItems) - { - var p = _subtitle.GetParagraphOrDefault(item.Index); - if (p != null) - { - var original = Utilities.GetOriginalParagraph(item.Index, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - alternateIndices.Add(_subtitleAlternate.GetIndex(original)); - } - } - } - - alternateIndices.Reverse(); - foreach (int i in alternateIndices) - { - if (i < _subtitleAlternate.Paragraphs.Count) - { - _subtitleAlternate.Paragraphs.RemoveAt(i); - } - } - - _subtitleAlternate.Renumber(); - } - - var indices = new List(); - foreach (ListViewItem item in SubtitleListview1.SelectedItems) - { - indices.Add(item.Index); - } - - int firstIndex = SubtitleListview1.SelectedItems[0].Index; - - if (_networkSession != null) - { - _networkSession.TimerStop(); - NetworkGetSendUpdates(indices, 0, null); - } - else - { - indices.Reverse(); - foreach (int i in indices) - { - _subtitle.Paragraphs.RemoveAt(i); - } - - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - if (SubtitleListview1.FirstVisibleIndex == 0) - { - SubtitleListview1.FirstVisibleIndex = -1; - } - - if (SubtitleListview1.Items.Count > firstIndex) - { - SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex, true); - } - else if (SubtitleListview1.Items.Count > 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(SubtitleListview1.Items.Count - 1, true); - } - } - - ResetTextInfoIfEmpty(); - SetListViewStateImages(); - } - - private void ToolStripMenuItemInsertBeforeClick(object sender, EventArgs e) - { - if (_subtitle.Paragraphs.Count > 0) - { - InsertBefore(); - } - - textBoxListViewText.Focus(); - } - - private void InsertBefore() - { - MakeHistoryForUndo(_language.BeforeInsertLine); - - int firstSelectedIndex = 0; - if (SubtitleListview1.SelectedItems.Count > 0) - { - firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - } - - int addMilliseconds = Configuration.Settings.General.MinimumMillisecondsBetweenLines + 1; - if (addMilliseconds < 1) - { - addMilliseconds = 1; - } - - var newParagraph = new Paragraph(); - - SetStyleForNewParagraph(newParagraph, firstSelectedIndex); - - var prev = _subtitle.GetParagraphOrDefault(firstSelectedIndex - 1); - var next = _subtitle.GetParagraphOrDefault(firstSelectedIndex); - if (prev != null && next != null) - { - newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - addMilliseconds; - newParagraph.StartTime.TotalMilliseconds = newParagraph.EndTime.TotalMilliseconds - 2000; - if (newParagraph.StartTime.TotalMilliseconds <= prev.EndTime.TotalMilliseconds) - { - newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1; - } - - if (newParagraph.Duration.TotalMilliseconds < 100) - { - newParagraph.EndTime.TotalMilliseconds += 100; - } - - if (next.StartTime.IsMaxTime && prev.EndTime.IsMaxTime) - { - newParagraph.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - newParagraph.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - } - else if (next.StartTime.TotalMilliseconds == 0 && prev.EndTime.TotalMilliseconds == 0) - { - newParagraph.StartTime.TotalMilliseconds = 0; - newParagraph.EndTime.TotalMilliseconds = 0; - } - else if (prev.StartTime.TotalMilliseconds == next.StartTime.TotalMilliseconds && - prev.EndTime.TotalMilliseconds == next.EndTime.TotalMilliseconds) - { - newParagraph.StartTime.TotalMilliseconds = prev.StartTime.TotalMilliseconds; - newParagraph.EndTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds; - } - } - else if (prev != null) - { - newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + addMilliseconds; - newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs; - if (newParagraph.StartTime.TotalMilliseconds > newParagraph.EndTime.TotalMilliseconds) - { - newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1; - } - } - else if (next != null) - { - newParagraph.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - (2000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines); - newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - - if (next.StartTime.IsMaxTime) - { - newParagraph.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - newParagraph.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - } - else if (next.StartTime.TotalMilliseconds == 0 && next.EndTime.TotalMilliseconds == 0) - { - newParagraph.StartTime.TotalMilliseconds = 0; - newParagraph.EndTime.TotalMilliseconds = 0; - } - } - else - { - newParagraph.StartTime.TotalMilliseconds = 1000; - newParagraph.EndTime.TotalMilliseconds = 3000; - if (newParagraph.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds) - { - newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + - Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds; - } - } - - if (_networkSession != null) - { - _networkSession.TimerStop(); - NetworkGetSendUpdates(new List(), firstSelectedIndex, newParagraph); - } - else - { - _subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph); - _subtitleListViewIndex = -1; - _subtitle.Renumber(); - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible) - { - var currentOriginal = Utilities.GetOriginalParagraph(firstSelectedIndex, _subtitle.Paragraphs[firstSelectedIndex], _subtitleAlternate.Paragraphs); - if (currentOriginal != null) - { - _subtitleAlternate.Paragraphs.Insert(_subtitleAlternate.Paragraphs.IndexOf(currentOriginal), new Paragraph(newParagraph)); - } - else - { - _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph)); - } - - _subtitleAlternate.Renumber(); - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); - ShowSource(); - ShowStatus(_language.LineInserted); - } - - private void ToolStripMenuItemInsertAfterClick(object sender, EventArgs e) - { - if (_subtitle.Paragraphs.Count > 0) - { - InsertAfter(string.Empty); - textBoxListViewText.Focus(); - } - } - - private void InsertAfter(string text) - { - MakeHistoryForUndo(_language.BeforeInsertLine); - - int firstSelectedIndex = 0; - if (SubtitleListview1.SelectedItems.Count > 0) - { - firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index + 1; - } - - var newParagraph = new Paragraph { Text = text }; - - SetStyleForNewParagraph(newParagraph, firstSelectedIndex); - - var prev = _subtitle.GetParagraphOrDefault(firstSelectedIndex - 1); - var next = _subtitle.GetParagraphOrDefault(firstSelectedIndex); - if (prev != null) - { - int addMilliseconds = Configuration.Settings.General.MinimumMillisecondsBetweenLines; - if (addMilliseconds < 1) - { - addMilliseconds = 1; - } - - newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + addMilliseconds; - newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs; - if (next != null && newParagraph.EndTime.TotalMilliseconds > next.StartTime.TotalMilliseconds) - { - newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - - if (newParagraph.StartTime.TotalMilliseconds > newParagraph.EndTime.TotalMilliseconds) - { - newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1; - } - - if (next != null && next.StartTime.IsMaxTime && prev.EndTime.IsMaxTime) - { - newParagraph.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - newParagraph.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - } - else if (next != null && next.StartTime.TotalMilliseconds == 0 && prev.EndTime.TotalMilliseconds == 0) - { - newParagraph.StartTime.TotalMilliseconds = 0; - newParagraph.EndTime.TotalMilliseconds = 0; - } - else if (next == null && prev.EndTime.IsMaxTime) - { - newParagraph.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - newParagraph.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - } - else if (next == null && prev.EndTime.TotalMilliseconds == 0) - { - newParagraph.StartTime.TotalMilliseconds = 0; - newParagraph.EndTime.TotalMilliseconds = 0; - } - else if (next != null && - prev.StartTime.TotalMilliseconds == next.StartTime.TotalMilliseconds && - prev.EndTime.TotalMilliseconds == next.EndTime.TotalMilliseconds) - { - newParagraph.StartTime.TotalMilliseconds = prev.StartTime.TotalMilliseconds; - newParagraph.EndTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds; - } - } - else if (next != null) - { - newParagraph.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 2000; - newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1; - } - else - { - newParagraph.StartTime.TotalMilliseconds = 1000; - newParagraph.EndTime.TotalMilliseconds = 3000; - if (newParagraph.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds) - { - newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + - Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds; - } - } - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - var currentOriginal = Utilities.GetOriginalParagraph(firstSelectedIndex - 1, _subtitle.Paragraphs[firstSelectedIndex - 1], _subtitleAlternate.Paragraphs); - if (currentOriginal != null) - { - _subtitleAlternate.Paragraphs.Insert(_subtitleAlternate.Paragraphs.IndexOf(currentOriginal) + 1, new Paragraph(newParagraph)); - } - else - { - _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph)); - } - - _subtitleAlternate.Renumber(); - } - - if (_networkSession != null) - { - _networkSession.TimerStop(); - NetworkGetSendUpdates(new List(), firstSelectedIndex, newParagraph); - } - else - { - _subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph); - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); - ShowSource(); - ShowStatus(_language.LineInserted); - } - - private void SetStyleForNewParagraph(Paragraph newParagraph, int nearestIndex) - { - var format = GetCurrentSubtitleFormat(); - bool useExtraForStyle = format.HasStyleSupport; - var formatType = format.GetType(); - var styles = new List(); - if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha)) - { - styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); - } - else if (formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText)) - { - styles = TimedText10.GetStylesFromHeader(_subtitle.Header); - } - else if (formatType == typeof(Sami) || formatType == typeof(SamiModern)) - { - styles = Sami.GetStylesFromHeader(_subtitle.Header); - } - - string style = "Default"; - if (styles.Count > 0) - { - style = styles[0]; - } - - if (useExtraForStyle) - { - newParagraph.Extra = style; - if (format.GetType() == typeof(TimedText10) || format.GetType() == typeof(ItunesTimedText)) - { - if (styles.Count > 0) - { - newParagraph.Style = style; - } - - var c = _subtitle.GetParagraphOrDefault(nearestIndex); - if (c != null) - { - newParagraph.Style = c.Style; - newParagraph.Region = c.Region; - newParagraph.Language = c.Language; - } - - newParagraph.Extra = TimedText10.SetExtra(newParagraph); - } - } - } - - private void SubtitleListView1SelectedIndexChange() - { - StopAutoDuration(); - ShowLineInformationListView(); - if (_subtitle.Paragraphs.Count > 0) - { - int firstSelectedIndex = 0; - if (SubtitleListview1.SelectedItems.Count > 0) - { - firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - } - - if (_subtitleListViewIndex >= 0) - { - if (_subtitleListViewIndex == firstSelectedIndex) - { - return; - } - - bool showSource = false; - - var last = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex); - if (textBoxListViewText.Text != last.Text) - { - last.Text = textBoxListViewText.Text.TrimEnd(); - SubtitleListview1.SetText(_subtitleListViewIndex, last.Text); - showSource = true; - } - - var startTime = timeUpDownStartTime.TimeCode; - if (startTime != null) - { - if (Math.Abs(last.StartTime.TotalMilliseconds - startTime.TotalMilliseconds) > 0.5) - { - var dur = last.Duration.TotalMilliseconds; - last.StartTime.TotalMilliseconds = startTime.TotalMilliseconds; - last.EndTime.TotalMilliseconds = startTime.TotalMilliseconds + dur; - SubtitleListview1.SetStartTimeAndDuration(_subtitleListViewIndex, last, _subtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1), _subtitle.GetParagraphOrDefault(_subtitleListViewIndex - 1)); - showSource = true; - } - } - - var duration = GetDurationInMilliseconds(); - if (duration > 0 && duration < 100000 && Math.Abs(duration - last.Duration.TotalMilliseconds) > 0.5) - { - last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + duration; - SubtitleListview1.SetDuration(_subtitleListViewIndex, last, _subtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1)); - showSource = true; - } - - if (showSource) - { - ShowSource(); - } - } - - var p = _subtitle.GetParagraphOrDefault(firstSelectedIndex); - if (p != null) - { - InitializeListViewEditBox(p); - _subtitleListViewIndex = firstSelectedIndex; - _oldSelectedParagraph = new Paragraph(p); - UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, p, textBoxListViewText); - FixVerticalScrollBars(textBoxListViewText, ref _lastNumberOfNewLines); - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - InitializeListViewEditBoxAlternate(p, firstSelectedIndex); - labelAlternateCharactersPerSecond.Left = textBoxListViewTextAlternate.Left + (textBoxListViewTextAlternate.Width - labelAlternateCharactersPerSecond.Width); - labelTextAlternateLineTotal.Left = textBoxListViewTextAlternate.Left + (textBoxListViewTextAlternate.Width - labelTextAlternateLineTotal.Width); - } - } - } - } - - private long _lastSubtitleListviewSelectedIndexChangedTick = -1; - private long _lastLastSubtitleListviewSelectedIndexChangedTick = -1; - - private void SubtitleListview1_SelectedIndexChanged(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedIndices.Count == 0) - { - _listViewTextUndoIndex = -1; - return; - } - - if (DateTime.UtcNow.Ticks - _lastLastSubtitleListviewSelectedIndexChangedTick < 10000 * 50) // only if last change was less ago than 50 milliseconds - { - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(50), () => - { - SubtitleListview1_SelectedIndexChanged(null, null); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - }); - return; - } - - if (!_makeHistoryPaused) - { - _listViewTextTicks = 0; - _listViewAlternateTextTicks = 0; - TimerTextUndoTick(null, null); - TimerAlternateTextUndoTick(null, null); - } - - _listViewTextUndoIndex = -1; - SubtitleListView1SelectedIndexChange(); - if (_findHelper != null && !_findHelper.InProgress) - { - _findHelper.StartLineIndex = _subtitleListViewIndex; - _findHelper.SelectedIndex = _subtitleListViewIndex; - _findHelper.SelectedPosition = 0; - _findHelper.ReplaceFromPosition = 0; - _findHelper.MatchInOriginal = false; - } - - _lastLastSubtitleListviewSelectedIndexChangedTick = _lastSubtitleListviewSelectedIndexChangedTick; - _lastSubtitleListviewSelectedIndexChangedTick = DateTime.UtcNow.Ticks; - } - - private void ShowLineInformationListView() - { - var profile = Configuration.Settings.General.CurrentProfile + " "; - if (!ShowProfileInStatusBar) - { - profile = string.Empty; - } - - if (tabControlSubtitle.SelectedIndex == TabControlListView) - { - if (SubtitleListview1.SelectedItems.Count == 1) - { - toolStripSelected.Text = profile + string.Format("{0}/{1}", SubtitleListview1.SelectedItems[0].Index + 1, SubtitleListview1.Items.Count); - } - else - { - toolStripSelected.Text = profile + string.Format(_language.XLinesSelected, SubtitleListview1.SelectedItems.Count); - } - } - } - - private void UpdateListViewTextCharactersPerSeconds(Label charsPerSecond, Paragraph paragraph) - { - if (paragraph.Duration.TotalSeconds > 0) - { - double charactersPerSecond = Utilities.GetCharactersPerSecond(paragraph); - if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds && - Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall) - { - charsPerSecond.ForeColor = Color.Red; - } - else - { - charsPerSecond.ForeColor = UiUtil.ForeColor; - } - - charsPerSecond.Text = string.Format(_language.CharactersPerSecond, charactersPerSecond); - } - else - { - if (Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall) - { - charsPerSecond.ForeColor = UiUtil.ForeColor; - } - else - { - charsPerSecond.ForeColor = Color.Red; - } - - charsPerSecond.Text = string.Format(_language.CharactersPerSecond, _languageGeneral.NotAvailable); - } - } - - private void UpdateListViewTextInfo(Label lineLengths, Label singleLine, Label singleLinePixels, Label lineTotal, Label charactersPerSecond, Paragraph paragraph, SETextBox textBox) - { - if (paragraph == null) - { - return; - } - - bool textBoxHasFocus = textBox.Focused; - string text = paragraph.Text; - lineLengths.Text = _languageGeneral.SingleLineLengths.Trim(); - singleLine.Left = lineLengths.Left + lineLengths.Width - 3; - singleLinePixels.Left = lineLengths.Left + lineLengths.Width + 50; - text = HtmlUtil.RemoveHtmlTags(text, true); - text = NetflixImsc11Japanese.RemoveTags(text); - UiUtil.GetLineLengths(singleLine, text); - - if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) - { - UiUtil.GetLinePixelWidths(singleLinePixels, text); - labelSingleLinePixels.Visible = !(textBoxListViewText.Width / 3 < labelTextLineLengths.Width); - } - else - { - labelSingleLinePixels.Visible = false; - } - - buttonSplitLine.Visible = false; - - var s = text.Replace(Environment.NewLine, " "); - var len = text.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics); - - int numberOfLines = Utilities.GetNumberOfLines(text.Trim()); - int maxLines = int.MaxValue; - if (Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines) - { - maxLines = Configuration.Settings.General.MaxNumberOfLines; - } - - var splitLines = text.SplitToLines(); - if (numberOfLines <= maxLines) - { - if (len <= Configuration.Settings.General.SubtitleLineMaximumLength * Math.Max(numberOfLines, 2) && - splitLines.Count == 2 && splitLines[0].StartsWith('-') && splitLines[1].StartsWith('-') && - (splitLines[0].CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength || - splitLines[1].CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength)) - { - if (buttonUnBreak.Visible) - { - if (!textBoxHasFocus) - { - if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) - { - var totalLengthPixels = TextWidth.CalcPixelWidth(s); - lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", len, totalLengthPixels)); - } - else - { - lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, len); - } - } - - buttonSplitLine.Visible = true; - } - } - else if (len <= Configuration.Settings.General.SubtitleLineMaximumLength * Math.Max(numberOfLines, 2)) - { - lineTotal.ForeColor = UiUtil.ForeColor; - if (!textBoxHasFocus) - { - if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) - { - var totalLengthPixels = TextWidth.CalcPixelWidth(s); - lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", len, totalLengthPixels)); - } - else - { - lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, len); - } - } - } - else - { - lineTotal.ForeColor = Color.Red; - if (!textBoxHasFocus) - { - if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) - { - var totalLengthPixels = TextWidth.CalcPixelWidth(s); - lineTotal.Text = string.Format(_languageGeneral.TotalLengthXSplitLine, string.Format("{0} {1}", len, totalLengthPixels)); - } - else - { - lineTotal.Text = string.Format(_languageGeneral.TotalLengthXSplitLine, len); - } - } - - if (buttonUnBreak.Visible) - { - if (!textBoxHasFocus) - { - if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) - { - var totalLengthPixels = TextWidth.CalcPixelWidth(s); - lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", len, totalLengthPixels)); - } - else - { - lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, len); - } - } - - var lang = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); - var abl = Utilities.AutoBreakLine(s, lang).SplitToLines(); - if (abl.Count > maxLines || abl.Any(li => li.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength)) - { - buttonSplitLine.Visible = true; - } - } - } - } - else - { - if (!textBoxHasFocus) - { - if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) - { - var totalLengthPixels = TextWidth.CalcPixelWidth(s); - lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", len, totalLengthPixels)); - } - else - { - lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, len); - } - } - - var lang = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); - var abl = Utilities.AutoBreakLine(s, lang).SplitToLines(); - if (abl.Count > maxLines || abl.Any(li => li.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength) && - !textBoxListViewTextAlternate.Visible) - { - buttonSplitLine.Visible = true; - } - } - - UpdateListViewTextCharactersPerSeconds(charactersPerSecond, paragraph); - charactersPerSecond.Left = textBox.Left + (textBox.Width - labelCharactersPerSecond.Width); - lineTotal.Left = textBox.Left + (textBox.Width - lineTotal.Width); - } - - private void ButtonNextClick(object sender, EventArgs e) - { - MoveNextPrevious(0); - } - - private void ButtonPreviousClick(object sender, EventArgs e) - { - MoveNextPrevious(1); - } - - private void MoveNextPrevious(int firstSelectedIndex) - { - if (_subtitle.Paragraphs.Count == 0) - { - return; - } - - SubtitleListview1.SuspendLayout(); - var temp = firstSelectedIndex; - if (SubtitleListview1.SelectedItems.Count > 0) - { - firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - } - - firstSelectedIndex = temp == 0 ? firstSelectedIndex + 1 : firstSelectedIndex - 1; - var p = _subtitle.GetParagraphOrDefault(firstSelectedIndex); - if (p != null) - { - SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); - } - - SubtitleListview1.ResumeLayout(); - } - - private void ButtonAutoBreakClick(object sender, EventArgs e) - { - string language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); - string languageOriginal = string.Empty; - if (_subtitleAlternate != null) - { - languageOriginal = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate); - } - - var textCaretPos = textBoxListViewText.SelectionStart; - - if (SubtitleListview1.SelectedItems.Count > 1) - { - bool historyAdded = false; - SubtitleListview1.BeginUpdate(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.GetParagraphOrDefault(index); - if (p != null) - { - var oldText = p.Text; - var newText = Utilities.AutoBreakLine(p.Text, language); - if (oldText != newText) - { - if (!historyAdded) - { - historyAdded = true; - MakeHistoryForUndo(_language.Controls.AutoBreak.RemoveChar('&')); - } - - p.Text = newText; - SubtitleListview1.SetText(index, p.Text); - } - - if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - oldText = original.Text; - newText = Utilities.AutoBreakLine(original.Text, language); - if (oldText != newText) - { - if (!historyAdded) - { - historyAdded = true; - MakeHistoryForUndo(_language.Controls.AutoBreak.RemoveChar('&')); - } - - original.Text = newText; - SubtitleListview1.SetAlternateText(index, original.Text); - } - } - } - - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, p); - } - } - - SubtitleListview1.EndUpdate(); - RefreshSelectedParagraph(); - } - else - { - var fixedText = Utilities.AutoBreakLine(textBoxListViewText.Text, language); - var makeHistory = textBoxListViewText.Text != fixedText; - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var alternateFixedText = Utilities.AutoBreakLine(textBoxListViewTextAlternate.Text, languageOriginal); - if (!makeHistory) - { - makeHistory = textBoxListViewTextAlternate.Text != alternateFixedText; - } - - if (makeHistory) - { - MakeHistoryForUndo(_language.Controls.AutoBreak.RemoveChar('&')); - textBoxListViewText.Text = fixedText; - } - - textBoxListViewTextAlternate.Text = alternateFixedText; - } - else if (makeHistory) - { - MakeHistoryForUndo(_language.Controls.AutoBreak.RemoveChar('&')); - textBoxListViewText.Text = fixedText; - } - } - - var s = textBoxListViewText.Text; - var startText = s.Substring(0, Math.Min(textCaretPos, s.Length)); - var numberOfNewLines = Utilities.CountTagInText(startText, Environment.NewLine); - textCaretPos += numberOfNewLines; - if (s.Length > textCaretPos && '\n' == s[textCaretPos]) - { - textCaretPos--; - } - - if (textCaretPos > 0) - { - textBoxListViewText.SelectionStart = textCaretPos; - } - } - - private int _lastNumberOfNewLines = -1; - private int _lastNumberOfNewLinesAlternate = -1; - - private static void FixVerticalScrollBars(SETextBox tb, ref int lastNumberOfNewLines) - { - var noOfNewLines = Utilities.GetNumberOfLines(tb.Text); - if (noOfNewLines == lastNumberOfNewLines) - { - return; - } - - lastNumberOfNewLines = noOfNewLines; - try - { - if (noOfNewLines <= 1 && tb.Text.Length <= 300 || TextRenderer.MeasureText(tb.Text, tb.Font).Height < tb.Height) - { - tb.ScrollBars = RichTextBoxScrollBars.None; - } - else - { - tb.ScrollBars = RichTextBoxScrollBars.Vertical; - } - } - catch - { - // ignored - } - } - - private void TextBoxListViewTextTextChanged(object sender, EventArgs e) - { - var idx = _subtitleListViewIndex; - if (idx < 0 || idx >= _subtitle.Paragraphs.Count) - { - return; - } - - // Writing when text is selected gives a double event + some trouble (typed letter disappears or a crash happens). - // This tries to fix this - changing scrollbars is bad during this double event!? - // Also check https://stackoverflow.com/questions/28331672/c-sharp-textchanged-event-fires-twice-in-a-multiline-textbox - if (textBoxListViewText.Text == string.Empty) - { - _subtitle.Paragraphs[idx].Text = string.Empty; - UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, _subtitle.Paragraphs[idx], textBoxListViewText); - SubtitleListview1.SetText(idx, string.Empty); - _listViewTextUndoIndex = idx; - labelStatus.Text = string.Empty; - StartUpdateListSyntaxColoring(); - return; - } - - textBoxListViewText.TextChanged -= TextBoxListViewTextTextChanged; - if (_doAutoBreakOnTextChanged) - { - UiUtil.CheckAutoWrap(textBoxListViewText, new KeyEventArgs(Keys.None), Utilities.GetNumberOfLines(textBoxListViewText.Text)); - } - - // update _subtitle + listview - string text = textBoxListViewText.Text.TrimEnd(); - if (ContainsNonStandardNewLines(text)) - { - var lines = text.SplitToLines(); - text = string.Join(Environment.NewLine, lines); - textBoxListViewText.Text = text; - } - - if (idx < 0 || idx >= _subtitle.Paragraphs.Count) - { - return; - } - - _subtitle.Paragraphs[idx].Text = text; - UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, _subtitle.Paragraphs[idx], textBoxListViewText); - SubtitleListview1.SetText(idx, text); - - _listViewTextUndoIndex = _subtitleListViewIndex; - labelStatus.Text = string.Empty; - - StartUpdateListSyntaxColoring(); - FixVerticalScrollBars(textBoxListViewText, ref _lastNumberOfNewLines); - textBoxListViewText.TextChanged += TextBoxListViewTextTextChanged; - } - - private bool ContainsNonStandardNewLines(string s) - { - if (Environment.NewLine == "\r\n") - { - int i = 0; - while (i < s.Length) - { - var ch = s[i]; - if (ch == '\r') - { - if (i >= s.Length - 1 || s[i + 1] != '\n') - { - return true; - } - - i++; - } - else if (ch == '\n') - { - return true; - } - - i++; - } - - return false; - } - else if (Environment.NewLine == "\n") - { - return s.Contains('\r'); - } - else - { - s = s.Replace(Environment.NewLine, string.Empty); - return s.Contains('\n') || s.Contains('\r'); - } - } - - private void TextBoxListViewTextAlternateTextChanged(object sender, EventArgs e) - { - if (_subtitleListViewIndex >= 0) - { - var p = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex); - if (p == null) - { - return; - } - - var original = Utilities.GetOriginalParagraph(_subtitleListViewIndex, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - if (textBoxListViewTextAlternate.Text == string.Empty) - { - UpdateListViewTextInfo(labelTextAlternateLineLengths, labelAlternateSingleLine, labelAlternateSingleLinePixels, labelTextAlternateLineTotal, labelAlternateCharactersPerSecond, original, textBoxListViewTextAlternate); - SubtitleListview1.SetAlternateText(_subtitleListViewIndex, string.Empty); - _listViewTextUndoIndex = _subtitleListViewIndex; - labelStatus.Text = string.Empty; - StartUpdateListSyntaxColoring(); - return; - } - - int numberOfNewLines = Utilities.GetNumberOfLines(textBoxListViewTextAlternate.Text); - UiUtil.CheckAutoWrap(textBoxListViewTextAlternate, new KeyEventArgs(Keys.None), numberOfNewLines); - - // update _subtitle + listview - string text = textBoxListViewTextAlternate.Text.TrimEnd(); - if (ContainsNonStandardNewLines(text)) - { - var lines = text.SplitToLines(); - text = string.Join(Environment.NewLine, lines); - textBoxListViewTextAlternate.Text = text; - } - - original.Text = text; - UpdateListViewTextInfo(labelTextAlternateLineLengths, labelAlternateSingleLine, labelAlternateSingleLinePixels, labelTextAlternateLineTotal, labelAlternateCharactersPerSecond, original, textBoxListViewTextAlternate); - SubtitleListview1.SetAlternateText(_subtitleListViewIndex, text); - _listViewTextUndoIndex = _subtitleListViewIndex; - } - - labelStatus.Text = string.Empty; - - StartUpdateListSyntaxColoring(); - FixVerticalScrollBars(textBoxListViewTextAlternate, ref _lastNumberOfNewLinesAlternate); - } - } - - private void TextBoxListViewTextKeyDown(object sender, KeyEventArgs e) - { - _listViewTextTicks = DateTime.UtcNow.Ticks; - - if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.ShiftKey) - { - return; - } - - if (e.Modifiers == Keys.Control && e.KeyCode == (Keys.LButton | Keys.ShiftKey)) - { // surround ctrl+v action with history (for undo) - _listViewTextTicks = 0; - TimerTextUndoTick(sender, e); - Application.DoEvents(); - System.Threading.Thread.Sleep(50); - Application.DoEvents(); - _listViewTextTicks = 0; - TimerTextUndoTick(sender, e); - return; - } - - int numberOfLines = Utilities.GetNumberOfLines(textBoxListViewText.Text); - - if (e.Modifiers == Keys.None && e.KeyCode == Keys.Enter && numberOfLines > Configuration.Settings.General.MaxNumberOfLines) - { - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainTextBoxAutoBreak) - { - BreakUnbreakTextBox(false, textBoxListViewText); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainTextBoxUnbreak) - { - BreakUnbreakTextBox(true, textBoxListViewText); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainTextBoxBreakAtCursorPosition) - { - var text = Utilities.ReSplit(textBoxListViewText.Text, textBoxListViewText.SelectionStart); - if (text != textBoxListViewText.Text) - { - MakeHistoryForUndo(string.Format(_language.BeforeReplace, Configuration.Settings.Language.Settings.MainTextBoxAutoBreakFromPos)); - textBoxListViewText.Text = text; - var lines = textBoxListViewText.Text.SplitToLines(); - if (lines.Count > 0) - { - textBoxListViewText.SelectionStart = lines[0].Length; - } - } - - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainTextBoxBreakAtCursorPositionAndGoToNext) - { - var text = Utilities.ReSplit(textBoxListViewText.Text, textBoxListViewText.SelectionStart); - if (text != textBoxListViewText.Text) - { - MakeHistoryForUndo(string.Format(_language.BeforeReplace, Configuration.Settings.Language.Settings.MainTextBoxAutoBreakFromPosAndGoToNext)); - textBoxListViewText.Text = text; - ButtonNextClick(null, null); - } - - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.I) - { - if (textBoxListViewText.SelectionLength == 0) - { - if (textBoxListViewText.Text.Contains("", StringComparison.Ordinal)) - { - textBoxListViewText.Text = HtmlUtil.RemoveOpenCloseTags(textBoxListViewText.Text, HtmlUtil.TagItalic); - } - else - { - textBoxListViewText.Text = string.Format("{0}", textBoxListViewText.Text); - } - } - else - { - TextBoxListViewToggleTag(HtmlUtil.TagItalic); - e.SuppressKeyPress = true; - } - } - - if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D) - { - textBoxListViewText.SelectionLength = 0; - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainTextBoxSplitAtCursor == e.KeyData) - { - ToolStripMenuItemSplitTextAtCursorClick(null, null); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainTextBoxSplitAtCursorAndVideoPos == e.KeyData) - { - toolStripMenuItemSplitViaWaveform_Click(null, null); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainTextBoxSplitSelectedLineBilingual == e.KeyData) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count >= 1 && SubtitleListview1.SelectedItems.Count < 10) - { - e.SuppressKeyPress = true; - SplitSelectedLineBilingual(); - } - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN1) - { - SetAlignment("{\\an1}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN2) - { - SetAlignment("", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN3) - { - SetAlignment("{\\an3}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN4) - { - SetAlignment("{\\an4}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN5) - { - SetAlignment("{\\an5}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN6) - { - SetAlignment("{\\an6}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN7) - { - SetAlignment("{\\an7}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN8) - { - SetAlignment("{\\an8}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN9) - { - SetAlignment("{\\an9}", false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewToggleMusicSymbols) - { - textBoxListViewText.Text = ToogleMusicSymbols("♪", textBoxListViewText.Text); - } - else if (e.KeyData == _shortcuts.MainInsertBefore) - { - InsertBefore(); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainInsertAfter) - { - InsertAfter(string.Empty); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewRemoveTimeCodes) - { - int i = _subtitleListViewIndex; - var p = _subtitle.GetParagraphOrDefault(i); - if (p != null) - { - p.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - p.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - RefreshSelectedParagraph(); - } - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainTextBoxSelectionToLower == e.KeyData && textBoxListViewText.SelectionLength > 0) // selection to lowercase - { - int start = textBoxListViewText.SelectionStart; - int length = textBoxListViewText.SelectionLength; - textBoxListViewText.SelectedText = textBoxListViewText.SelectedText.ToLowerInvariant(); - textBoxListViewText.SelectionStart = start; - textBoxListViewText.SelectionLength = length; - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainTextBoxSelectionToUpper == e.KeyData && textBoxListViewText.SelectionLength > 0) // selection to uppercase - { - int start = textBoxListViewText.SelectionStart; - int length = textBoxListViewText.SelectionLength; - textBoxListViewText.SelectedText = textBoxListViewText.SelectedText.ToUpperInvariant(); - textBoxListViewText.SelectionStart = start; - textBoxListViewText.SelectionLength = length; - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainTextBoxSelectionToggleCasing == e.KeyData && textBoxListViewText.SelectionLength > 0) // selection to uppercase - { - int start = textBoxListViewText.SelectionStart; - int length = textBoxListViewText.SelectionLength; - var text = ToggleCasing(textBoxListViewText.SelectedText); - textBoxListViewText.SelectedText = text; - textBoxListViewText.SelectionStart = start; - textBoxListViewText.SelectionLength = length; - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainTextBoxToggleAutoDuration == e.KeyData) // toggle auto-duration - { - if (timerAutoDuration.Enabled) - { - timerAutoDuration.Stop(); - labelAutoDuration.Visible = false; - } - else - { - timerAutoDuration.Start(); - labelAutoDuration.Visible = true; - } - - e.SuppressKeyPress = true; - } - - // last key down in text - _lastTextKeyDownTicks = DateTime.UtcNow.Ticks; - - UpdatePositionAndTotalLength(labelTextLineTotal, textBoxListViewText); - } - - private string ToggleCasing(string text) - { - if (string.IsNullOrWhiteSpace(text) || text.ToLower() == text.ToUpper()) - { - return text; - } - - var containsLowercase = false; - var containsUppercase = false; - for (var i = 0; i < text.Length; i++) - { - var ch = text[i]; - - if (!containsLowercase && char.IsLower(ch)) - { - containsLowercase = true; - } - - if (!containsUppercase && char.IsUpper(ch)) - { - containsUppercase = true; - } - - i++; - } - - if (containsUppercase && containsLowercase) - { - return text.ToUpperInvariant(); - } - - if (containsUppercase && !containsLowercase) - { - return text.ToLowerInvariant(); - } - - return System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(text); - } - - private void MoveFirstWordInNextUp(SETextBox tb) - { - int firstIndex = FirstSelectedIndex; - if (firstIndex >= 0) - { - var p = _subtitle.GetParagraphOrDefault(firstIndex); - var next = _subtitle.GetParagraphOrDefault(firstIndex + 1); - - if (tb == textBoxListViewTextAlternate) - { - p = Utilities.GetOriginalParagraph(firstIndex, p, _subtitleAlternate.Paragraphs); - next = Utilities.GetOriginalParagraph(firstIndex + 1, next, _subtitleAlternate.Paragraphs); - } - - if (p != null && next != null) - { - var moveUpDown = new MoveWordUpDown(p.Text, next.Text); - moveUpDown.MoveWordUp(); - if (moveUpDown.S1 != p.Text && moveUpDown.S2 != next.Text) - { - MakeHistoryForUndo(_language.BeforeLineUpdatedInListView); - p.Text = moveUpDown.S1; - next.Text = moveUpDown.S2; - if (tb == textBoxListViewTextAlternate) - { - SubtitleListview1.SetAlternateText(firstIndex, p.Text); - SubtitleListview1.SetAlternateText(firstIndex + 1, next.Text); - } - else - { - SubtitleListview1.SetText(firstIndex, p.Text); - SubtitleListview1.SetText(firstIndex + 1, next.Text); - } - var selectionStart = textBoxListViewText.SelectionStart; - tb.Text = p.Text; - if (selectionStart >= 0) - { - tb.SelectionStart = selectionStart; - } - } - } - } - } - - private void MoveLastWordDown(SETextBox tb) - { - int firstIndex = FirstSelectedIndex; - if (firstIndex >= 0) - { - var p = _subtitle.GetParagraphOrDefault(firstIndex); - var next = _subtitle.GetParagraphOrDefault(firstIndex + 1); - - if (tb == textBoxListViewTextAlternate) - { - p = Utilities.GetOriginalParagraph(firstIndex, p, _subtitleAlternate.Paragraphs); - next = Utilities.GetOriginalParagraph(firstIndex + 1, next, _subtitleAlternate.Paragraphs); - } - - if (p != null && next != null) - { - var moveUpDown = new MoveWordUpDown(p.Text, next.Text); - moveUpDown.MoveWordDown(); - if (moveUpDown.S1 != p.Text && moveUpDown.S2 != next.Text) - { - MakeHistoryForUndo(_language.BeforeLineUpdatedInListView); - p.Text = moveUpDown.S1; - next.Text = moveUpDown.S2; - if (tb == textBoxListViewTextAlternate) - { - SubtitleListview1.SetAlternateText(firstIndex, p.Text); - SubtitleListview1.SetAlternateText(firstIndex + 1, next.Text); - } - else - { - SubtitleListview1.SetText(firstIndex, p.Text); - SubtitleListview1.SetText(firstIndex + 1, next.Text); - } - var selectionStart = textBoxListViewText.SelectionStart; - tb.Text = p.Text; - if (selectionStart >= 0) - { - tb.SelectionStart = selectionStart; - } - } - } - } - } - - private void MakeAutoDurationSelectedLines() - { - if (_subtitle.Paragraphs.Count == 0) - { - return; - } - - if (SubtitleListview1.SelectedItems.Count == 1) - { - MakeAutoDuration(); - return; - } - - if (SubtitleListview1.SelectedItems.Count > 1) - { - MakeHistoryForUndo(_language.BeforeAutoDuration); - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.GetParagraphOrDefault(index); - if (p == null) - { - return; - } - - double duration = Utilities.GetOptimalDisplayMilliseconds(textBoxListViewText.Text); - var next = _subtitle.GetParagraphOrDefault(index + 1); - if (next != null && p.StartTime.TotalMilliseconds + duration + Configuration.Settings.General.MinimumMillisecondsBetweenLines > next.StartTime.TotalMilliseconds) - { - duration = next.StartTime.TotalMilliseconds - p.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - - if (duration > 500) - { - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + duration; - } - } - - SaveSubtitleListviewIndices(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - RefreshSelectedParagraph(); - } - } - - private void MakeAutoDuration() - { - int i = _subtitleListViewIndex; - var p = _subtitle.GetParagraphOrDefault(i); - if (p == null) - { - return; - } - - double duration = Utilities.GetOptimalDisplayMilliseconds(textBoxListViewText.Text); - var next = _subtitle.GetParagraphOrDefault(i + 1); - if (next != null && p.StartTime.TotalMilliseconds + duration + Configuration.Settings.General.MinimumMillisecondsBetweenLines > next.StartTime.TotalMilliseconds) - { - duration = next.StartTime.TotalMilliseconds - p.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - if (duration < 400) - { - return; - } - } - - SetDurationInSeconds(duration / TimeCode.BaseUnit); - - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + duration; - SubtitleListview1.SetDuration(i, p, _subtitle.GetParagraphOrDefault(i + 1)); - } - - private void SplitLineToolStripMenuItemClick(object sender, EventArgs e) - { - SplitSelectedParagraph(null, null); - } - - private void SplitSelectedParagraph(double? splitSeconds, int? textIndex) - { - string language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); - int? alternateTextIndex = null; - if (textBoxListViewTextAlternate.Focused) - { - alternateTextIndex = textIndex; - textIndex = null; - } - - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) - { - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - MakeHistoryForUndo(_language.BeforeSplitLine); - - int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - - var currentParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex); - var newParagraph = new Paragraph(currentParagraph); - newParagraph.NewSection = false; - - currentParagraph.Text = currentParagraph.Text.Replace("< /i>", ""); - currentParagraph.Text = currentParagraph.Text.Replace("< i>", ""); - string oldText = currentParagraph.Text; - var lines = currentParagraph.Text.SplitToLines(); - if (textIndex != null && textIndex.Value > 1 && textIndex.Value < oldText.Length - 1) - { - string a = oldText.Substring(0, textIndex.Value).Trim(); - string b = oldText.Substring(textIndex.Value).Trim(); - - if (oldText.TrimStart().StartsWith("", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("", StringComparison.Ordinal) && - Utilities.CountTagInText(oldText, "") == 1 && Utilities.CountTagInText(oldText, "") == 1) - { - a = a + ""; - b = "" + b; - } - else if (oldText.TrimStart().StartsWith("", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("", StringComparison.Ordinal) && - Utilities.CountTagInText(oldText, "") == 1 && Utilities.CountTagInText(oldText, "") == 1) - { - a = a + "
"; - b = "" + b; - } - - string aTrimmed = HtmlUtil.RemoveHtmlTags(a).TrimEnd('"').TrimEnd().TrimEnd('\'').TrimEnd(); - if (Configuration.Settings.General.SplitRemovesDashes && (aTrimmed.EndsWith('.') || aTrimmed.EndsWith('!') || aTrimmed.EndsWith('?') || aTrimmed.EndsWith('؟'))) - { - a = DialogSplitMerge.RemoveStartDash(a); - b = DialogSplitMerge.RemoveStartDash(b); - } - - currentParagraph.Text = Utilities.AutoBreakLine(a, language); - newParagraph.Text = Utilities.AutoBreakLine(b, language); - } - else - { - var l0 = string.Empty; - if (lines.Count > 0) - { - l0 = HtmlUtil.RemoveHtmlTags(lines[0], true).Trim().TrimEnd('"', '\'').TrimEnd(); - } - - if (lines.Count == 2 && (l0.EndsWith('.') || l0.EndsWith('!') || l0.EndsWith('?') || l0.EndsWith('؟'))) - { - currentParagraph.Text = Utilities.AutoBreakLine(lines[0], language); - newParagraph.Text = Utilities.AutoBreakLine(lines[1], language); - if (currentParagraph.Text.StartsWith("", StringComparison.Ordinal) && !currentParagraph.Text.Contains("") && - newParagraph.Text.EndsWith("", StringComparison.Ordinal) && !newParagraph.Text.Contains("")) - { - currentParagraph.Text = currentParagraph.Text + ""; - newParagraph.Text = "" + newParagraph.Text; - } - - if (currentParagraph.Text.StartsWith("", StringComparison.Ordinal) && !currentParagraph.Text.Contains("") && - newParagraph.Text.EndsWith("", StringComparison.Ordinal) && !newParagraph.Text.Contains("")) - { - currentParagraph.Text = currentParagraph.Text + ""; - newParagraph.Text = "" + newParagraph.Text; - } - - if (Configuration.Settings.General.SplitRemovesDashes) - { - currentParagraph.Text = DialogSplitMerge.RemoveStartDash(currentParagraph.Text); - newParagraph.Text = DialogSplitMerge.RemoveStartDash(newParagraph.Text); - } - } - else - { - string s = currentParagraph.Text; - var arr = HtmlUtil.RemoveHtmlTags(s, true).SplitToLines(); - if (arr.Count == 1 || arr.Count == 2 && (arr[0].Length > Configuration.Settings.General.SubtitleLineMaximumLength || arr[1].Length > Configuration.Settings.General.SubtitleLineMaximumLength)) - { - if (arr.Count == 2 && arr[0].StartsWith('-') && arr[1].StartsWith('-')) - { - if (lines[0].StartsWith("-", StringComparison.Ordinal)) - { - lines[0] = "" + lines[0].Remove(0, 4).TrimStart(); - } - - lines[0] = lines[0].TrimStart('-').TrimStart(); - lines[1] = lines[1].TrimStart('-').TrimStart(); - s = lines[0] + Environment.NewLine + lines[1]; - } - else - { - s = Utilities.AutoBreakLine(currentParagraph.Text, 5, Configuration.Settings.General.MergeLinesShorterThan, language); - } - } - - lines = s.SplitToLines(); - if (lines.Count == 1) - { - s = Utilities.AutoBreakLine(currentParagraph.Text, 3, 20, language); - lines = s.SplitToLines(); - } - - if (lines.Count == 1) - { - s = Utilities.AutoBreakLine(currentParagraph.Text, 3, 18, language); - lines = s.SplitToLines(); - } - - if (lines.Count == 1) - { - s = Utilities.AutoBreakLine(currentParagraph.Text, 3, 15, language); - lines = s.SplitToLines(); - } - - if (lines.Count == 2) - { - if (Utilities.CountTagInText(s, "") == 1 && lines[0].Contains("", StringComparison.Ordinal) && lines[1].Contains("", StringComparison.Ordinal)) - { - lines[0] += ""; - lines[1] = "" + lines[1]; - } - - currentParagraph.Text = Utilities.AutoBreakLine(lines[0], language); - newParagraph.Text = Utilities.AutoBreakLine(lines[1], language); - } - else if (lines.Count == 1) - { - currentParagraph.Text = Utilities.AutoBreakLine(lines[0], language); - newParagraph.Text = string.Empty; - } - else if (lines.Count == 3) - { - currentParagraph.Text = Utilities.AutoBreakLine(lines[0] + Environment.NewLine + lines[1], language); - newParagraph.Text = lines[2]; - } - else if (lines.Count > 3) - { - var half = lines.Count / 2; - var sb1 = new StringBuilder(); - for (int i = 0; i < half; i++) - { - sb1.AppendLine(lines[i]); - } - - currentParagraph.Text = Utilities.AutoBreakLine(sb1.ToString(), language); - sb1 = new StringBuilder(); - for (int i = half; i < lines.Count; i++) - { - sb1.AppendLine(lines[i]); - } - - newParagraph.Text = Utilities.AutoBreakLine(sb1.ToString(), language); - } - - if (currentParagraph.Text.Contains("", StringComparison.Ordinal) && !currentParagraph.Text.Contains("", StringComparison.Ordinal) && - newParagraph.Text.Contains("", StringComparison.Ordinal) && !newParagraph.Text.Contains("", StringComparison.Ordinal)) - { - currentParagraph.Text = currentParagraph.Text + ""; - newParagraph.Text = "" + newParagraph.Text; - } - - if (currentParagraph.Text.Contains("", StringComparison.Ordinal) && !currentParagraph.Text.Contains("", StringComparison.Ordinal) && - newParagraph.Text.Contains("", StringComparison.Ordinal) && !newParagraph.Text.Contains("")) - { - currentParagraph.Text = currentParagraph.Text + ""; - newParagraph.Text = "" + newParagraph.Text; - } - - if (currentParagraph.Text.StartsWith("-", StringComparison.Ordinal) && (currentParagraph.Text.EndsWith(".", StringComparison.Ordinal) || currentParagraph.Text.EndsWith("!", StringComparison.Ordinal)) && - newParagraph.Text.StartsWith("-", StringComparison.Ordinal) && (newParagraph.Text.EndsWith(".", StringComparison.Ordinal) || newParagraph.Text.EndsWith("!", StringComparison.Ordinal))) - { - currentParagraph.Text = currentParagraph.Text.Remove(3, 1); - newParagraph.Text = newParagraph.Text.Remove(3, 1); - } - } - } - - if (currentParagraph.Text.StartsWith(" ", StringComparison.Ordinal)) - { - currentParagraph.Text = currentParagraph.Text.Remove(3, 1); - } - - if (newParagraph.Text.StartsWith(" ", StringComparison.Ordinal)) - { - newParagraph.Text = newParagraph.Text.Remove(3, 1); - } - - var continuationStyle = Configuration.Settings.General.ContinuationStyle; - if (continuationStyle != ContinuationStyle.None) - { - if (language == "ar") - { - currentParagraph.Text = ContinuationUtilities.ConvertToForArabic(currentParagraph.Text); - newParagraph.Text = ContinuationUtilities.ConvertToForArabic(newParagraph.Text); - } - - var continuationProfile = ContinuationUtilities.GetContinuationProfile(continuationStyle); - if (ContinuationUtilities.ShouldAddSuffix(currentParagraph.Text, continuationProfile)) - { - currentParagraph.Text = ContinuationUtilities.AddSuffixIfNeeded(currentParagraph.Text, continuationProfile, false); - newParagraph.Text = ContinuationUtilities.AddPrefixIfNeeded(newParagraph.Text, continuationProfile, false); - } - - if (language == "ar") - { - currentParagraph.Text = ContinuationUtilities.ConvertBackForArabic(currentParagraph.Text); - newParagraph.Text = ContinuationUtilities.ConvertBackForArabic(newParagraph.Text); - } - } - - FixSplitItalicTag(currentParagraph, newParagraph); - FixSplitFontTag(currentParagraph, newParagraph); - SetSplitTime(splitSeconds, currentParagraph, newParagraph, oldText); - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - var originalCurrent = Utilities.GetOriginalParagraph(firstSelectedIndex, currentParagraph, _subtitleAlternate.Paragraphs); - if (originalCurrent != null) - { - string languageOriginal = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate); - - originalCurrent.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; - var originalNew = new Paragraph(newParagraph); - originalNew.NewSection = false; - - lines = originalCurrent.Text.SplitToLines(); - - var l0Trimmed = string.Empty; - if (lines.Count > 0) - { - l0Trimmed = HtmlUtil.RemoveHtmlTags(lines[0]).TrimEnd('\'').TrimEnd('"'); - } - - oldText = originalCurrent.Text; - if (alternateTextIndex != null && alternateTextIndex.Value > 1 && alternateTextIndex.Value < oldText.Length - 1) - { - originalCurrent.Text = Utilities.AutoBreakLine(oldText.Substring(0, alternateTextIndex.Value).Trim(), language); - originalNew.Text = Utilities.AutoBreakLine(oldText.Substring(alternateTextIndex.Value).Trim(), language); - if (originalCurrent.Text.Contains("", StringComparison.Ordinal) && !originalCurrent.Text.Contains("", StringComparison.Ordinal) && - originalNew.Text.Contains("", StringComparison.Ordinal) && !originalNew.Text.Contains("", StringComparison.Ordinal)) - { - if (originalCurrent.Text.StartsWith("-", StringComparison.Ordinal) && (originalCurrent.Text.EndsWith(".", StringComparison.Ordinal) || originalCurrent.Text.EndsWith("?", StringComparison.Ordinal) || - originalCurrent.Text.EndsWith("!", StringComparison.Ordinal) || originalCurrent.Text.EndsWith("؟", StringComparison.Ordinal)) && originalNew.Text.StartsWith("-", StringComparison.Ordinal)) - { - originalCurrent.Text = "" + originalCurrent.Text.Remove(0, 4).Trim(); - originalNew.Text = originalNew.Text.TrimStart('-').Trim(); - } - - originalCurrent.Text = originalCurrent.Text + ""; - originalNew.Text = "" + originalNew.Text; - } - - if (originalCurrent.Text.Contains("", StringComparison.Ordinal) && !originalCurrent.Text.Contains("") && - originalNew.Text.Contains("", StringComparison.Ordinal) && !originalNew.Text.Contains("")) - { - originalCurrent.Text = originalCurrent.Text + ""; - originalNew.Text = "" + originalNew.Text; - } - - if (Configuration.Settings.General.SplitRemovesDashes && (l0Trimmed.EndsWith('.') || l0Trimmed.EndsWith('!') || l0Trimmed.EndsWith('?') || l0Trimmed.EndsWith('؟'))) - { - originalCurrent.Text = DialogSplitMerge.RemoveStartDash(originalCurrent.Text); - originalNew.Text = DialogSplitMerge.RemoveStartDash(originalNew.Text); - } - - lines.Clear(); - } - else if (lines.Count == 2 && (l0Trimmed.EndsWith('.') || l0Trimmed.EndsWith('!') || l0Trimmed.EndsWith('?') || l0Trimmed.EndsWith('؟'))) - { - string a = lines[0].Trim(); - string b = lines[1].Trim(); - if (oldText.TrimStart().StartsWith("", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("", StringComparison.Ordinal) && - Utilities.CountTagInText(oldText, "") == 1 && Utilities.CountTagInText(oldText, "") == 1) - { - a = a + ""; - b = "" + b; - } - - if (oldText.TrimStart().StartsWith("", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("", StringComparison.Ordinal) && - Utilities.CountTagInText(oldText, "") == 1 && Utilities.CountTagInText(oldText, "") == 1) - { - a = a + ""; - b = "" + b; - } - - if (Configuration.Settings.General.SplitRemovesDashes) - { - a = DialogSplitMerge.RemoveStartDash(a); - b = DialogSplitMerge.RemoveStartDash(b); - } - - lines[0] = a; - lines[1] = b; - originalCurrent.Text = Utilities.AutoBreakLine(a); - originalNew.Text = Utilities.AutoBreakLine(b); - } - else if (Utilities.GetNumberOfLines(originalCurrent.Text) == 2) - { - lines = originalCurrent.Text.SplitToLines(); - } - else - { - string s = Utilities.AutoBreakLine(originalCurrent.Text, 5, Configuration.Settings.General.MergeLinesShorterThan, languageOriginal); - lines = s.SplitToLines(); - } - - if (lines.Count == 1) - { - string s = Utilities.AutoBreakLine(lines[0], 3, 20, languageOriginal); - lines = s.SplitToLines(); - } - - if (lines.Count == 1) - { - string s = Utilities.AutoBreakLine(lines[0], 3, 18, languageOriginal); - lines = s.SplitToLines(); - } - - if (lines.Count == 1) - { - string s = Utilities.AutoBreakLine(lines[0], 3, 15, languageOriginal); - lines = s.SplitToLines(); - } - - if (lines.Count == 2) - { - string a = lines[0].Trim(); - string b = lines[1].Trim(); - if (oldText.TrimStart().StartsWith("", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("", StringComparison.Ordinal) && - Utilities.CountTagInText(oldText, "") == 1 && Utilities.CountTagInText(oldText, "") == 1) - { - a = a + ""; - b = "" + b; - } - - if (oldText.TrimStart().StartsWith("", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("", StringComparison.Ordinal) && - Utilities.CountTagInText(oldText, "") == 1 && Utilities.CountTagInText(oldText, "") == 1) - { - a = a + ""; - b = "" + b; - } - - if (Configuration.Settings.General.SplitRemovesDashes && (l0Trimmed.EndsWith('.') || l0Trimmed.EndsWith('!') || l0Trimmed.EndsWith('?') || l0Trimmed.EndsWith('؟'))) - { - a = DialogSplitMerge.RemoveStartDash(a); - b = DialogSplitMerge.RemoveStartDash(b); - } - - lines[0] = a; - lines[1] = b; - - originalCurrent.Text = Utilities.AutoBreakLine(lines[0]); - originalNew.Text = Utilities.AutoBreakLine(lines[1]); - } - else if (lines.Count == 1) - { - originalNew.Text = string.Empty; - } - - if (originalCurrent != null && originalNew != null) - { - if (originalCurrent.Text.StartsWith(" ", StringComparison.Ordinal)) - { - originalCurrent.Text = originalCurrent.Text.Remove(3, 1); - } - - if (originalNew.Text.StartsWith(" ", StringComparison.Ordinal)) - { - originalCurrent.Text = originalCurrent.Text.Remove(3, 1); - } - - if (continuationStyle != ContinuationStyle.None) - { - if (languageOriginal == "ar") - { - originalCurrent.Text = ContinuationUtilities.ConvertToForArabic(originalCurrent.Text); - originalNew.Text = ContinuationUtilities.ConvertToForArabic(originalNew.Text); - } - - var continuationProfile = ContinuationUtilities.GetContinuationProfile(continuationStyle); - if (ContinuationUtilities.ShouldAddSuffix(originalCurrent.Text, continuationProfile)) - { - originalCurrent.Text = ContinuationUtilities.AddSuffixIfNeeded(originalCurrent.Text, continuationProfile, false); - originalNew.Text = ContinuationUtilities.AddPrefixIfNeeded(originalNew.Text, continuationProfile, false); - } - - if (languageOriginal == "ar") - { - originalCurrent.Text = ContinuationUtilities.ConvertBackForArabic(originalCurrent.Text); - originalNew.Text = ContinuationUtilities.ConvertBackForArabic(originalNew.Text); - } - } - } - - _subtitleAlternate.InsertParagraphInCorrectTimeOrder(originalNew); - _subtitleAlternate.Renumber(); - FixSplitItalicTag(originalCurrent, originalNew); - FixSplitFontTag(originalCurrent, originalNew); - } - } - - if (_networkSession != null) - { - _networkSession.TimerStop(); - SetDurationInSeconds(currentParagraph.Duration.TotalSeconds); - _networkSession.UpdateLine(_subtitle.GetIndex(currentParagraph), currentParagraph); - NetworkGetSendUpdates(new List(), firstSelectedIndex + 1, newParagraph); - } - else - { - _subtitle.Paragraphs.Insert(firstSelectedIndex + 1, newParagraph); - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - SubtitleListview1.SelectIndexAndEnsureVisible(Configuration.Settings.General.SplitBehavior == 0 ? firstSelectedIndex + 1 : firstSelectedIndex, true); - ShowSource(); - ShowStatus(_language.LineSplitted); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - RefreshSelectedParagraph(); - } - } - - private void FixSplitItalicTag(Paragraph currentParagraph, Paragraph nextParagraph) - { - if (currentParagraph == null || nextParagraph == null) - { - return; - } - - var startIdx = currentParagraph.Text.LastIndexOf("", StringComparison.OrdinalIgnoreCase); - if (startIdx >= 0 && - !currentParagraph.Text.Contains("", StringComparison.OrdinalIgnoreCase) && - nextParagraph.Text.Contains("", StringComparison.OrdinalIgnoreCase)) - { - var endIdx = currentParagraph.Text.IndexOf('>', startIdx); - if (endIdx >= 0) - { - var fontTag = currentParagraph.Text.Substring(startIdx, endIdx - startIdx + 1); - var pre = string.Empty; - if (currentParagraph.Text.StartsWith('{') && currentParagraph.Text.IndexOf('}') > 0) - { - var i = currentParagraph.Text.IndexOf('}'); - pre = currentParagraph.Text.Substring(0, i + 1); - currentParagraph.Text = currentParagraph.Text.Remove(0, i + 1); - } - - currentParagraph.Text = pre + currentParagraph.Text + ""; - nextParagraph.Text = pre + fontTag + nextParagraph.Text; - } - } - } - - private void FixSplitFontTag(Paragraph currentParagraph, Paragraph nextParagraph) - { - if (currentParagraph == null || nextParagraph == null) - { - return; - } - - var startIdx = currentParagraph.Text.LastIndexOf("= 0 && - !currentParagraph.Text.Contains("", StringComparison.OrdinalIgnoreCase) && - nextParagraph.Text.Contains("
", StringComparison.OrdinalIgnoreCase)) - { - var endIdx = currentParagraph.Text.IndexOf('>', startIdx); - if (endIdx >= 0) - { - var fontTag = currentParagraph.Text.Substring(startIdx, endIdx - startIdx + 1); - var pre = string.Empty; - if (currentParagraph.Text.StartsWith('{') && currentParagraph.Text.IndexOf('}') > 0) - { - var i = currentParagraph.Text.IndexOf('}'); - pre = currentParagraph.Text.Substring(0, i + 1); - currentParagraph.Text = currentParagraph.Text.Remove(0, i + 1); - } - - currentParagraph.Text = pre + currentParagraph.Text + "
"; - nextParagraph.Text = pre + fontTag + nextParagraph.Text; - } - } - } - - private void SetSplitTime(double? splitSeconds, Paragraph currentParagraph, Paragraph newParagraph, string oldText) - { - double middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.Duration.TotalMilliseconds / 2); - if (!string.IsNullOrWhiteSpace(HtmlUtil.RemoveHtmlTags(oldText))) - { - var lineOneTextNoHtml = HtmlUtil.RemoveHtmlTags(currentParagraph.Text, true).Replace(Environment.NewLine, string.Empty); - var lineTwoTextNoHtml = HtmlUtil.RemoveHtmlTags(newParagraph.Text, true).Replace(Environment.NewLine, string.Empty); - if (Math.Abs(lineOneTextNoHtml.Length - lineTwoTextNoHtml.Length) > 2) - { - // give more time to the paragraph with most text - var oldTextNoHtml = HtmlUtil.RemoveHtmlTags(oldText, true).Replace(Environment.NewLine, string.Empty); - var startFactor = (double)lineOneTextNoHtml.Length / oldTextNoHtml.Length; - if (startFactor < 0.25) - { - startFactor = 0.25; - } - - if (startFactor > 0.75) - { - startFactor = 0.75; - } - - middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.Duration.TotalMilliseconds * startFactor); - } - } - - if (currentParagraph.StartTime.IsMaxTime && currentParagraph.EndTime.IsMaxTime) - { - newParagraph.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - newParagraph.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - } - else - { - if (splitSeconds.HasValue && splitSeconds.Value > (currentParagraph.StartTime.TotalSeconds + 0.2) && splitSeconds.Value < (currentParagraph.EndTime.TotalSeconds - 0.2)) - { - middle = splitSeconds.Value * TimeCode.BaseUnit; - } - - newParagraph.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; - currentParagraph.EndTime.TotalMilliseconds = middle; - newParagraph.StartTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds + 1; - if (Configuration.Settings.General.MinimumMillisecondsBetweenLines > 0) - { - if (splitSeconds == null || Configuration.Settings.General.SplitBehavior == 1) - { - // SE decides split point (not user), so split gap time evenly - var halfGap = (int)Math.Round(Configuration.Settings.General.MinimumMillisecondsBetweenLines / 2.0); - currentParagraph.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds - halfGap; - } - else if (Configuration.Settings.General.SplitBehavior == 0) - { - currentParagraph.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - newParagraph.StartTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - - private void MergeBeforeToolStripMenuItemClick(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedItems.Count >= 1) - { - var idx = SubtitleListview1.SelectedItems[0].Index; - if (idx > 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(idx - 1, true); - MergeAfterToolStripMenuItemClick(null, null); - } - } - } - - private void MergeSelectedLinesBilingual() - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 1) - { - var sb1 = new StringBuilder(); - var sb2 = new StringBuilder(); - var deleteIndices = new List(); - bool first = true; - int firstIndex = 0; - double durationMilliseconds = 0; - int next = 0; - foreach (int index in SubtitleListview1.SelectedIndices) - { - if (first) - { - firstIndex = index; - next = index + 1; - first = !first; - } - else - { - deleteIndices.Add(index); - if (next != index) - { - return; - } - - next++; - } - - var arr = _subtitle.Paragraphs[index].Text.Trim().SplitToLines(); - if (arr.Count > 0) - { - int mid = (int)(arr.Count / 2); - for (var i = 0; i < arr.Count; i++) - { - var l = arr[i]; - if (i < mid) - { - sb1.Append(l + " "); - } - else - { - sb2.Append(l + " "); - } - } - } - - durationMilliseconds += _subtitle.Paragraphs[index].Duration.TotalMilliseconds; - } - - if (sb1.Length > 150 || sb2.Length > 150) - { - return; - } - - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - MakeHistoryForUndo(_language.BeforeMergeLines); - - var currentParagraph = _subtitle.Paragraphs[firstIndex]; - string text1 = sb1.ToString().TrimEnd(); - string text2 = sb2.ToString().TrimEnd(); - - currentParagraph.Text = text1 + Environment.NewLine + text2; - - //display time - currentParagraph.EndTime.TotalMilliseconds = currentParagraph.StartTime.TotalMilliseconds + durationMilliseconds; - - var nextParagraph = _subtitle.GetParagraphOrDefault(next); - if (nextParagraph != null && currentParagraph.EndTime.TotalMilliseconds > nextParagraph.StartTime.TotalMilliseconds && currentParagraph.StartTime.TotalMilliseconds < nextParagraph.StartTime.TotalMilliseconds) - { - currentParagraph.EndTime.TotalMilliseconds = nextParagraph.StartTime.TotalMilliseconds - 1; - } - - if (_networkSession != null) - { - _networkSession.TimerStop(); - _networkSession.UpdateLine(firstIndex, currentParagraph); - NetworkGetSendUpdates(deleteIndices, 0, null); - } - else - { - for (int i = deleteIndices.Count - 1; i >= 0; i--) - { - _subtitle.Paragraphs.RemoveAt(deleteIndices[i]); - } - - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - ShowSource(); - ShowStatus(_language.LinesMerged); - SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex, true); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - RefreshSelectedParagraph(); - } - } - - private void SplitSelectedLineBilingual() - { - var idx = FirstSelectedIndex; - if (_subtitle.Paragraphs.Count < 1 || idx < 0) - { - return; - } - - var p = _subtitle.GetParagraphOrDefault(idx); - if (p == null) - { - return; - } - - var tb = textBoxListViewText; - var lines = tb.Text.SplitToLines(); - if (lines.Count != 2 || tb.SelectionLength < 3 || lines[0].Length < 2 || lines[1].Length < 2) - { - return; - } - - var start = tb.SelectionStart; - var end = start + tb.SelectionLength; - var indexOfNewLine = tb.Text.IndexOf(Environment.NewLine, StringComparison.Ordinal); - if (end < indexOfNewLine || start > indexOfNewLine) - { - return; - } - - MakeHistoryForUndo(_language.BeforeSplitLine); - var oldText = p.Text; - string text1 = lines[0].Substring(0, start).Trim() + Environment.NewLine + lines[1].Substring(0, end - indexOfNewLine - 2).Trim(); - string text2 = lines[0].Remove(0, start).Trim() + Environment.NewLine + lines[1].Remove(0, end - indexOfNewLine - 2).Trim(); - var newParagraph = new Paragraph(p); - newParagraph.NewSection = false; - double? splitPos = null; - if (!string.IsNullOrEmpty(VideoFileName)) - { - splitPos = mediaPlayer.CurrentPosition; - } - - SetSplitTime(splitPos, p, newParagraph, oldText); - _subtitle.InsertParagraphInCorrectTimeOrder(newParagraph); - _subtitle.Renumber(); - if (Configuration.Settings.General.SplitBehavior > 0) - { - _subtitleListViewIndex = -1; - } - p.Text = text1; - newParagraph.Text = text2; - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(idx, true); - } - - private void MergeSelectedLines(BreakMode breakMode = BreakMode.Normal) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 1) - { - var sb = new StringBuilder(); - var deleteIndices = new List(); - bool first = true; - int firstIndex = 0; - double endMilliseconds = 0; - int next = 0; - foreach (int index in SubtitleListview1.SelectedIndices) - { - if (first) - { - firstIndex = index; - next = index + 1; - first = !first; - } - else - { - deleteIndices.Add(index); - if (next != index) - { - return; - } - - next++; - } - - var continuationStyle = Configuration.Settings.General.ContinuationStyle; - if (continuationStyle != ContinuationStyle.None) - { - var continuationProfile = ContinuationUtilities.GetContinuationProfile(continuationStyle); - if (next < firstIndex + SubtitleListview1.SelectedIndices.Count) - { - var mergeResult = ContinuationUtilities.MergeHelper(_subtitle.Paragraphs[index].Text, _subtitle.Paragraphs[index + 1].Text, continuationProfile, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle)); - _subtitle.Paragraphs[index].Text = mergeResult.Item1; - _subtitle.Paragraphs[index + 1].Text = mergeResult.Item2; - } - } - - var addText = _subtitle.Paragraphs[index].Text; - - if (firstIndex != index) - { - addText = RemoveAssStartAlignmentTag(addText); - } - - if (breakMode == BreakMode.UnbreakNoSpace) - { - sb.Append(addText); - } - else - { - sb.AppendLine(addText); - } - - endMilliseconds = _subtitle.Paragraphs[index].EndTime.TotalMilliseconds; - } - - if (sb.Length > 200) - { - return; - } - - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - MakeHistoryForUndo(_language.BeforeMergeLines); - - var currentParagraph = _subtitle.Paragraphs[firstIndex]; - string text = sb.ToString(); - text = HtmlUtil.FixInvalidItalicTags(text); - text = ChangeAllLinesTagsToSingleTag(text, "i"); - text = ChangeAllLinesTagsToSingleTag(text, "b"); - text = ChangeAllLinesTagsToSingleTag(text, "u"); - if (breakMode == BreakMode.Unbreak) - { - text = Utilities.UnbreakLine(text); - } - else if (breakMode == BreakMode.UnbreakNoSpace) - { - text = text.Replace(" " + Environment.NewLine + " ", string.Empty) - .Replace(Environment.NewLine + " ", string.Empty) - .Replace(" " + Environment.NewLine, string.Empty) - .Replace(Environment.NewLine, string.Empty); - } - else - { - text = Utilities.AutoBreakLine(text, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle)); - } - - currentParagraph.Text = text; - - //display time - currentParagraph.EndTime.TotalMilliseconds = endMilliseconds; - - var nextParagraph = _subtitle.GetParagraphOrDefault(next); - if (nextParagraph != null && currentParagraph.EndTime.TotalMilliseconds > nextParagraph.StartTime.TotalMilliseconds && currentParagraph.StartTime.TotalMilliseconds < nextParagraph.StartTime.TotalMilliseconds) - { - currentParagraph.EndTime.TotalMilliseconds = nextParagraph.StartTime.TotalMilliseconds - 1; - } - - // original subtitle - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(firstIndex, currentParagraph, _subtitleAlternate.Paragraphs); - if (original != null) - { - var originalTexts = new StringBuilder(); - originalTexts.Append(original.Text.TrimEnd()); - if (breakMode != BreakMode.UnbreakNoSpace) - { - originalTexts.Append(" "); - } - - for (int i = 0; i < deleteIndices.Count; i++) - { - var originalNext = Utilities.GetOriginalParagraph(deleteIndices[i], _subtitle.Paragraphs[deleteIndices[i]], _subtitleAlternate.Paragraphs); - if (originalNext != null) - { - if (breakMode == BreakMode.UnbreakNoSpace) - { - originalTexts.Append(originalNext.Text.Trim()); - } - else - { - originalTexts.Append(originalNext.Text + " "); - } - } - - } - - for (int i = deleteIndices.Count - 1; i >= 0; i--) - { - var originalNext = Utilities.GetOriginalParagraph(deleteIndices[i], _subtitle.Paragraphs[deleteIndices[i]], _subtitleAlternate.Paragraphs); - if (originalNext != null) - { - _subtitleAlternate.Paragraphs.Remove(originalNext); - } - } - - original.Text = originalTexts.ToString().Replace(" ", " "); - original.Text = ChangeAllLinesTagsToSingleTag(original.Text, "i"); - original.Text = ChangeAllLinesTagsToSingleTag(original.Text, "b"); - original.Text = ChangeAllLinesTagsToSingleTag(original.Text, "u"); - - if (breakMode == BreakMode.Unbreak) - { - original.Text = Utilities.UnbreakLine(original.Text); - } - else if (breakMode == BreakMode.UnbreakNoSpace) - { - original.Text = original.Text.Replace(" " + Environment.NewLine + " ", string.Empty) - .Replace(Environment.NewLine + " ", string.Empty) - .Replace(" " + Environment.NewLine, string.Empty) - .Replace(Environment.NewLine, string.Empty); - } - else - { - original.Text = Utilities.AutoBreakLine(original.Text, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate)); - } - - original.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; - _subtitleAlternate.Renumber(); - } - } - - if (_networkSession != null) - { - _networkSession.TimerStop(); - _networkSession.UpdateLine(firstIndex, currentParagraph); - NetworkGetSendUpdates(deleteIndices, 0, null); - } - else - { - for (int i = deleteIndices.Count - 1; i >= 0; i--) - { - _subtitle.Paragraphs.RemoveAt(deleteIndices[i]); - } - - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - ShowSource(); - ShowStatus(_language.LinesMerged); - SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex, true); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - RefreshSelectedParagraph(); - } - } - - private void ExtendBeforeToolStripMenuItemClick(object sender, EventArgs e) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) - { - ExtendSelectedLinesToPreviousLine(); - } - } - - private void ExtendAfterToolStripMenuItemClick(object sender, EventArgs e) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) - { - ExtendSelectedLinesToNextLine(); - } - } - - private static string ChangeAllLinesTagsToSingleTag(string text, string tag) - { - if (!text.Contains("<" + tag + ">")) - { - return text; - } - - foreach (var line in text.SplitToLines()) - { - if (!line.TrimStart().StartsWith("<" + tag + ">", StringComparison.Ordinal) || !line.TrimEnd().EndsWith("", StringComparison.Ordinal)) - { - return text; - } - } - - return "<" + tag + ">" + HtmlUtil.RemoveOpenCloseTags(text, tag).Trim() + ""; - } - - private void MergeAfterToolStripMenuItemClick(object sender, EventArgs e) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) - { - if (SubtitleListview1.SelectedItems.Count > 2) - { - MergeSelectedLines(); - return; - } - - MergeWithLineAfter(false); - } - } - - public enum BreakMode - { - AutoBreak, - Normal, - Unbreak, - UnbreakNoSpace - } - - private void MergeWithLineAfter(bool insertDash, BreakMode breakMode = BreakMode.Normal) - { - var dialogHelper = new DialogSplitMerge { DialogStyle = Configuration.Settings.General.DialogStyle }; - int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - - var currentParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex); - var nextParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex + 1); - - if (nextParagraph != null && currentParagraph != null) - { - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - MakeHistoryForUndo(_language.BeforeMergeLines); - - var continuationStyle = Configuration.Settings.General.ContinuationStyle; - if (continuationStyle != ContinuationStyle.None) - { - var continuationProfile = ContinuationUtilities.GetContinuationProfile(continuationStyle); - var mergeResult = ContinuationUtilities.MergeHelper(currentParagraph.Text, nextParagraph.Text, continuationProfile, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle)); - currentParagraph.Text = mergeResult.Item1; - nextParagraph.Text = mergeResult.Item2; - } - - if (_subtitleAlternate != null) - { - var original = Utilities.GetOriginalParagraph(firstSelectedIndex, currentParagraph, _subtitleAlternate.Paragraphs); - var originalNext = Utilities.GetOriginalParagraph(firstSelectedIndex + 1, nextParagraph, _subtitleAlternate.Paragraphs); - - if (original != null && originalNext != null) - { - if (continuationStyle != ContinuationStyle.None) - { - var continuationProfile = ContinuationUtilities.GetContinuationProfile(continuationStyle); - var mergeResult = ContinuationUtilities.MergeHelper(original.Text, originalNext.Text, continuationProfile, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate)); - original.Text = mergeResult.Item1; - originalNext.Text = mergeResult.Item2; - } - } - - if (originalNext != null) - { - if (original == null) - { - originalNext.StartTime.TotalMilliseconds = currentParagraph.StartTime.TotalMilliseconds; - originalNext.EndTime.TotalMilliseconds = nextParagraph.EndTime.TotalMilliseconds; - } - else - { - if (insertDash && !string.IsNullOrEmpty(original.Text) && !string.IsNullOrEmpty(originalNext.Text)) - { - string s = Utilities.UnbreakLine(original.Text); - original.Text = dialogHelper.InsertStartDash(s, 0); - - s = Utilities.UnbreakLine(originalNext.Text); - original.Text += Environment.NewLine + dialogHelper.InsertStartDash(s, 1); - - original.Text = original.Text.Replace("" + Environment.NewLine + "", Environment.NewLine).TrimEnd(); - } - else - { - string old1 = original.Text; - string old2 = originalNext.Text; - - if (breakMode == BreakMode.Unbreak) - { - original.Text = old1.Replace(Environment.NewLine, " "); - original.Text += Environment.NewLine + old2.Replace(Environment.NewLine, " "); - original.Text = Utilities.UnbreakLine(original.Text); - } - else if (breakMode == BreakMode.UnbreakNoSpace) - { - original.Text = old1.TrimEnd() + old2.TrimStart(); - } - else - { - original.Text = old1.Replace(Environment.NewLine, " "); - original.Text += Environment.NewLine + old2.Replace(Environment.NewLine, " "); - - if (old1.Contains(Environment.NewLine) || old2.Contains(Environment.NewLine) || - old1.Length > Configuration.Settings.General.SubtitleLineMaximumLength || old2.Length > Configuration.Settings.General.SubtitleLineMaximumLength) - { - original.Text = Utilities.AutoBreakLine(original.Text, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate)); - } - } - - original.Text = ChangeAllLinesTagsToSingleTag(original.Text, "i"); - original.Text = ChangeAllLinesTagsToSingleTag(original.Text, "b"); - original.Text = ChangeAllLinesTagsToSingleTag(original.Text, "u"); - - if (string.IsNullOrWhiteSpace(old1)) - { - original.Text = original.Text.TrimStart(); - } - - if (string.IsNullOrWhiteSpace(old2)) - { - original.Text = original.Text.TrimEnd(); - } - } - - original.EndTime = originalNext.EndTime; - _subtitleAlternate.Paragraphs.Remove(originalNext); - } - - _subtitleAlternate.Renumber(); - } - } - - if (insertDash && !string.IsNullOrEmpty(currentParagraph.Text) && !string.IsNullOrEmpty(nextParagraph.Text)) - { - string s = Utilities.UnbreakLine(currentParagraph.Text); - currentParagraph.Text = dialogHelper.InsertStartDash(s, 0); - - s = Utilities.UnbreakLine(RemoveAssStartAlignmentTag(nextParagraph.Text)); - currentParagraph.Text += Environment.NewLine + dialogHelper.InsertStartDash(s, 1); - - currentParagraph.Text = currentParagraph.Text.Replace("" + Environment.NewLine + "", Environment.NewLine).TrimEnd(); - } - else - { - string old1 = currentParagraph.Text; - string old2 = nextParagraph.Text; - if (breakMode == BreakMode.Unbreak) - { - currentParagraph.Text = currentParagraph.Text.Replace(Environment.NewLine, " "); - currentParagraph.Text += Environment.NewLine + nextParagraph.Text.Replace(Environment.NewLine, " "); - currentParagraph.Text = Utilities.UnbreakLine(RemoveAssStartAlignmentTag(currentParagraph.Text)); - } - else if (breakMode == BreakMode.UnbreakNoSpace) - { - currentParagraph.Text = currentParagraph.Text.TrimEnd() + RemoveAssStartAlignmentTag(nextParagraph.Text).TrimStart(); - } - else if (breakMode == BreakMode.AutoBreak) - { - currentParagraph.Text = currentParagraph.Text.Replace(Environment.NewLine, " "); - currentParagraph.Text += Environment.NewLine + RemoveAssStartAlignmentTag(nextParagraph.Text).Replace(Environment.NewLine, " "); - var language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); - currentParagraph.Text = Utilities.AutoBreakLine(currentParagraph.Text, language); - } - else - { - currentParagraph.Text = (currentParagraph.Text.Trim() + Environment.NewLine + - RemoveAssStartAlignmentTag(nextParagraph.Text).Trim()).Trim(); - } - - currentParagraph.Text = ChangeAllLinesTagsToSingleTag(currentParagraph.Text, "i"); - currentParagraph.Text = ChangeAllLinesTagsToSingleTag(currentParagraph.Text, "b"); - currentParagraph.Text = ChangeAllLinesTagsToSingleTag(currentParagraph.Text, "u"); - - if (old1.Contains(Environment.NewLine) || old2.Contains(Environment.NewLine) || - old1.Length > Configuration.Settings.General.SubtitleLineMaximumLength || old2.Length > Configuration.Settings.General.SubtitleLineMaximumLength) - { - currentParagraph.Text = Utilities.AutoBreakLine(currentParagraph.Text, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle)); - } - - if (string.IsNullOrWhiteSpace(old1) && old2 != null) - { - currentParagraph.Text = old2.Trim(); - } - - if (string.IsNullOrWhiteSpace(old2) && old1 != null) - { - currentParagraph.Text = old1.Trim(); - } - } - - currentParagraph.EndTime.TotalMilliseconds = nextParagraph.EndTime.TotalMilliseconds; - - if (_networkSession != null) - { - _networkSession.TimerStop(); - SetDurationInSeconds(currentParagraph.Duration.TotalSeconds); - _networkSession.UpdateLine(_subtitle.GetIndex(currentParagraph), currentParagraph); - var deleteIndices = new List(); - deleteIndices.Add(_subtitle.GetIndex(nextParagraph)); - NetworkGetSendUpdates(deleteIndices, 0, null); - } - else - { - _subtitle.Paragraphs.Remove(nextParagraph); - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - ShowSource(); - ShowStatus(_language.LinesMerged); - SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - RefreshSelectedParagraph(); - SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); - } - } - - private static string RemoveAssStartAlignmentTag(string text) - { - var s = text.TrimStart(); - if (s.StartsWith("{\\an") && s.Length > 5 && s[5] == '}') - { - s = s.Remove(0, 6); - } - return s; - } - - private void UpdateStartTimeInfo(TimeCode startTime) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0 && startTime != null) - { - UpdateOverlapErrors(startTime); - - // update _subtitle + listview - var p = _subtitle.Paragraphs[_subtitleListViewIndex]; - p.EndTime.TotalMilliseconds += (startTime.TotalMilliseconds - p.StartTime.TotalMilliseconds); - p.StartTime = startTime; - SubtitleListview1.SetStartTimeAndDuration(_subtitleListViewIndex, p, _subtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1), _subtitle.GetParagraphOrDefault(_subtitleListViewIndex - 1)); - StartUpdateListSyntaxColoring(); - } - } - - private void StartUpdateListSyntaxColoring() - { - if (!_timerDoSyntaxColoring.Enabled) - { - _timerDoSyntaxColoring.Start(); - } - } - - private void UpdateListSyntaxColoring() - { - if (_loading || _subtitle == null || _subtitleListViewIndex < 0 || _subtitleListViewIndex >= _subtitle.Paragraphs.Count) - { - return; - } - - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, _subtitleListViewIndex, _subtitle.Paragraphs[_subtitleListViewIndex]); - var idx = _subtitleListViewIndex + 1; - var p = _subtitle.GetParagraphOrDefault(idx); - if (p != null) - { - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, idx, p); - } - - idx = _subtitleListViewIndex - 1; - p = _subtitle.GetParagraphOrDefault(idx); - if (p != null) - { - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, idx, p); - } - } - - private void UpdateOverlapErrors(TimeCode startTime) - { - string startTimeWarning = string.Empty; - string durationWarning = string.Empty; - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0 && startTime != null) - { - int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - - var prevParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex - 1); - if (prevParagraph != null && !prevParagraph.EndTime.IsMaxTime && prevParagraph.EndTime.TotalMilliseconds > startTime.TotalMilliseconds && Configuration.Settings.Tools.ListViewSyntaxColorOverlap) - { - startTimeWarning = string.Format(_languageGeneral.OverlapPreviousLineX, prevParagraph.EndTime.TotalSeconds - startTime.TotalSeconds); - } - - var nextParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex + 1); - if (nextParagraph != null) - { - double durationMilliSeconds = GetDurationInMilliseconds(); - if (startTime.TotalMilliseconds + durationMilliSeconds > nextParagraph.StartTime.TotalMilliseconds && - Configuration.Settings.Tools.ListViewSyntaxColorOverlap && - !startTime.IsMaxTime) - { - durationWarning = string.Format(_languageGeneral.OverlapX, ((startTime.TotalMilliseconds + durationMilliSeconds) - nextParagraph.StartTime.TotalMilliseconds) / TimeCode.BaseUnit); - } - - if (startTimeWarning.Length == 0 && - startTime.TotalMilliseconds > nextParagraph.StartTime.TotalMilliseconds && - Configuration.Settings.Tools.ListViewSyntaxColorOverlap && - !startTime.IsMaxTime) - { - double di = (startTime.TotalMilliseconds - nextParagraph.StartTime.TotalMilliseconds) / TimeCode.BaseUnit; - startTimeWarning = string.Format(_languageGeneral.OverlapNextX, di); - } - else if (numericUpDownDuration.Value < 0) - { - durationWarning = _languageGeneral.Negative; - } - } - } - - labelStartTimeWarning.Text = startTimeWarning; - labelDurationWarning.Text = durationWarning; - } - - private double _durationMsInitialValue = 0; - private bool _durationIsDirty = false; - - private double GetDurationInMilliseconds() - { - if (!_durationIsDirty) - { - return _durationMsInitialValue; - } - - if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) - { - var seconds = (int)numericUpDownDuration.Value; - var frames = (int)Math.Round((Convert.ToDouble(numericUpDownDuration.Value) % 1.0 * 100.0)); - return seconds * TimeCode.BaseUnit + frames * (TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate); - } - - return ((double)numericUpDownDuration.Value * TimeCode.BaseUnit); - } - - private bool _skipDurationChangedEvent = false; - private void SetDurationInSeconds(double seconds) - { - _durationIsDirty = false; - _durationMsInitialValue = seconds * 1000.0; - if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) - { - var wholeSeconds = (int)seconds; - var frames = SubtitleFormat.MillisecondsToFrames(seconds % 1.0 * TimeCode.BaseUnit); - var extraSeconds = (int)(frames / Configuration.Settings.General.CurrentFrameRate); - var restFrames = (int)(frames % Configuration.Settings.General.CurrentFrameRate); - var v = (decimal)(wholeSeconds + extraSeconds + restFrames / 100.0); - if (v >= numericUpDownDuration.Minimum && v <= numericUpDownDuration.Maximum) - { - _skipDurationChangedEvent = true; - numericUpDownDuration.Value = (decimal)(wholeSeconds + extraSeconds + restFrames / 100.0); - _skipDurationChangedEvent = false; - - int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - var currentParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex); - if (currentParagraph != null) - { - UpdateOverlapErrors(timeUpDownStartTime.TimeCode); - UpdateListViewTextCharactersPerSeconds(labelCharactersPerSecond, currentParagraph); - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - var original = Utilities.GetOriginalParagraph(firstSelectedIndex, currentParagraph, _subtitleAlternate.Paragraphs); - if (original != null) - { - original.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; - UpdateListViewTextCharactersPerSeconds(labelAlternateCharactersPerSecond, original); - } - } - - SubtitleListview1.SetDuration(firstSelectedIndex, currentParagraph, _subtitle.GetParagraphOrDefault(firstSelectedIndex + 1)); - StartUpdateListSyntaxColoring(); - } - } - } - else - { - var d = (decimal)seconds; - if (d > numericUpDownDuration.Maximum) - { - numericUpDownDuration.Value = numericUpDownDuration.Maximum; - } - else if (d < numericUpDownDuration.Minimum) - { - numericUpDownDuration.Value = numericUpDownDuration.Minimum; - } - else - { - numericUpDownDuration.Value = d; - } - } - } - - private void NumericUpDownDurationValueChanged(object sender, EventArgs e) - { - if (_skipDurationChangedEvent) - { - return; - } - - _durationIsDirty = true; - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) - { - int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - - var currentParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex); - if (currentParagraph != null) - { - // update _subtitle + listview - string oldDuration = currentParagraph.Duration.ToString(); - - var temp = new Paragraph(currentParagraph); - - if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) - { - var seconds = (int)numericUpDownDuration.Value; - var frames = Convert.ToInt32((numericUpDownDuration.Value - seconds) * 100); - if (frames > Math.Round(Configuration.Settings.General.CurrentFrameRate) - 1) - { - numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged; - if (frames >= 99) - { - numericUpDownDuration.Value = (decimal)(seconds + (Math.Round((Configuration.Settings.General.CurrentFrameRate - 1)) / 100.0)); - } - else - { - numericUpDownDuration.Value = seconds + 1; - } - - numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged; - } - } - - temp.EndTime.TotalMilliseconds = currentParagraph.StartTime.TotalMilliseconds + GetDurationInMilliseconds(); - - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.DisplayTimeAdjustedX, "#" + currentParagraph.Number + ": " + oldDuration + " -> " + temp.Duration)); - - currentParagraph.EndTime.TotalMilliseconds = temp.EndTime.TotalMilliseconds; - SubtitleListview1.SetDuration(firstSelectedIndex, currentParagraph, _subtitle.GetParagraphOrDefault(firstSelectedIndex + 1)); - - UpdateOverlapErrors(timeUpDownStartTime.TimeCode); - UpdateListViewTextCharactersPerSeconds(labelCharactersPerSecond, currentParagraph); - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - var original = Utilities.GetOriginalParagraph(firstSelectedIndex, currentParagraph, _subtitleAlternate.Paragraphs); - if (original != null) - { - original.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; - UpdateListViewTextCharactersPerSeconds(labelAlternateCharactersPerSecond, original); - } - } - - StartUpdateListSyntaxColoring(); - } - - labelStatus.Text = string.Empty; - StartUpdateListSyntaxColoring(); - } - } - - private void InitializeListViewEditBoxAlternate(Paragraph p, int firstSelectedIndex) - { - if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - var original = Utilities.GetOriginalParagraph(firstSelectedIndex, p, _subtitleAlternate.Paragraphs); - if (original == null) - { - textBoxListViewTextAlternate.Enabled = false; - textBoxListViewTextAlternate.Text = string.Empty; - labelAlternateCharactersPerSecond.Text = string.Empty; - } - else - { - textBoxListViewTextAlternate.Enabled = true; - textBoxListViewTextAlternate.TextChanged -= TextBoxListViewTextAlternateTextChanged; - textBoxListViewTextAlternate.Text = original.Text; - textBoxListViewTextAlternate.TextChanged += TextBoxListViewTextAlternateTextChanged; - UpdateListViewTextCharactersPerSeconds(labelAlternateCharactersPerSecond, original); - _listViewAlternateTextUndoLast = original.Text; - } - } - } - - private void InitializeListViewEditBox(Paragraph p) - { - textBoxListViewText.TextChanged -= TextBoxListViewTextTextChanged; - textBoxListViewText.Text = p.Text; - textBoxListViewText.TextChanged += TextBoxListViewTextTextChanged; - _listViewTextUndoLast = p.Text; - - timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; - timeUpDownStartTime.TimeCode = p.StartTime; - timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; - - numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged; - if (p.Duration.TotalSeconds > (double)numericUpDownDuration.Maximum) - { - SetDurationInSeconds((double)numericUpDownDuration.Maximum); - } - else - { - SetDurationInSeconds(p.Duration.TotalSeconds); - } - - numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged; - - UpdateOverlapErrors(timeUpDownStartTime.TimeCode); - UpdateListViewTextCharactersPerSeconds(labelCharactersPerSecond, p); - if (_subtitle != null && _subtitle.Paragraphs.Count > 0) - { - textBoxListViewText.Enabled = true; - } - - StartUpdateListSyntaxColoring(); - ShowHideBookmark(p); - } - - private void MaskedTextBoxTextChanged(object sender, EventArgs e) - { - if (_subtitleListViewIndex >= 0) - { - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.StarTimeAdjustedX, "#" + (_subtitleListViewIndex + 1) + ": " + timeUpDownStartTime.TimeCode)); - - int firstSelectedIndex = FirstSelectedIndex; - var oldParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex); - if (oldParagraph != null) - { - oldParagraph = new Paragraph(oldParagraph, false); - } - - UpdateStartTimeInfo(timeUpDownStartTime.TimeCode); - - UpdateOriginalTimeCodes(oldParagraph); - labelStatus.Text = string.Empty; - } - } - - private void UpdateOriginalTimeCodes(Paragraph currentPargraphBeforeChange, Paragraph p2Before = null) - { - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - Paragraph p1 = null; - Paragraph o1 = null; - if (currentPargraphBeforeChange != null) - { - p1 = _subtitle.GetParagraphOrDefaultById(currentPargraphBeforeChange.Id); - if (p1 != null) - { - o1 = Utilities.GetOriginalParagraph(_subtitle.Paragraphs.IndexOf(p1), currentPargraphBeforeChange, _subtitleAlternate.Paragraphs); - } - } - - Paragraph p2 = null; - Paragraph o2 = null; - if (p2Before != null) - { - p2 = _subtitle.GetParagraphOrDefaultById(p2Before.Id); - if (p2 != null) - { - o2 = Utilities.GetOriginalParagraph(_subtitle.Paragraphs.IndexOf(p2), p2Before, _subtitleAlternate.Paragraphs); - } - } - - if (o1 != null) - { - o1.StartTime.TotalMilliseconds = p1.StartTime.TotalMilliseconds; - o1.EndTime.TotalMilliseconds = p1.EndTime.TotalMilliseconds; - } - - if (o2 != null) - { - o2.StartTime.TotalMilliseconds = p2.StartTime.TotalMilliseconds; - o2.EndTime.TotalMilliseconds = p2.EndTime.TotalMilliseconds; - } - } - } - - private void FormMain_FormClosing(object sender, FormClosingEventArgs e) - { - _lastDoNotPrompt = -1; - ReloadFromSourceView(); - if (!ContinueNewOrExit()) - { - e.Cancel = true; - } - else - { - if (_networkSession != null) - { - try - { - _networkSession.TimerStop(); - _networkSession.Leave(); - } - catch - { - } - } - - if (Configuration.Settings.General.StartRememberPositionAndSize && WindowState != FormWindowState.Minimized) - { - Configuration.Settings.General.StartPosition = Left + ";" + Top; - if (WindowState == FormWindowState.Maximized) - { - Configuration.Settings.General.StartSize = "Maximized"; - } - else - { - Configuration.Settings.General.StartSize = Width + ";" + Height; - } - - Configuration.Settings.General.SplitContainerMainSplitterDistance = splitContainerMain.SplitterDistance; - Configuration.Settings.General.SplitContainer1SplitterDistance = splitContainer1.SplitterDistance; - Configuration.Settings.General.SplitContainerListViewAndTextSplitterDistance = splitContainerListViewAndText.SplitterDistance; - } - - Configuration.Settings.General.AutoRepeatOn = checkBoxAutoRepeatOn.Checked; - if (int.TryParse(comboBoxAutoRepeat.Text, out var autoRepeat)) - { - Configuration.Settings.General.AutoRepeatCount = autoRepeat; - } - - Configuration.Settings.General.AutoContinueOn = checkBoxAutoContinue.Checked; - Configuration.Settings.General.AutoContinueDelay = comboBoxAutoContinue.SelectedIndex; - Configuration.Settings.General.SyncListViewWithVideoWhilePlaying = checkBoxSyncListViewWithVideoWhilePlaying.Checked; - Configuration.Settings.General.ShowWaveform = audioVisualizer.ShowWaveform; - Configuration.Settings.General.ShowSpectrogram = audioVisualizer.ShowSpectrogram; - if (Configuration.Settings.General.ShowRecentFiles) - { - if (!string.IsNullOrEmpty(_fileName)) - { - Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - - } - else - { - Configuration.Settings.RecentFiles.Add(null, null, null); - } - } - - if (SubtitleListview1.StateImageList?.Images.Count > 0) - { - Configuration.Settings.General.ListViewNumberWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Width - 18; - } - else - { - Configuration.Settings.General.ListViewNumberWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Width; - } - - SaveUndockedPositions(); - SaveListViewWidths(); - Configuration.Settings.Save(); - - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.PauseAndDisposePlayer(); - } - } - } - - private void SaveListViewWidths() - { - if (Configuration.Settings.General.ListViewColumnsRememberSize) - { - if (SubtitleListview1.ColumnIndexNumber >= 0) - { - Configuration.Settings.General.ListViewNumberWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Width; - } - - if (SubtitleListview1.ColumnIndexStart >= 0) - { - Configuration.Settings.General.ListViewStartWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexStart].Width; - } - - if (SubtitleListview1.ColumnIndexEnd >= 0) - { - Configuration.Settings.General.ListViewEndWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexEnd].Width; - } - - if (SubtitleListview1.ColumnIndexDuration >= 0) - { - Configuration.Settings.General.ListViewDurationWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexDuration].Width; - } - - if (SubtitleListview1.ColumnIndexCps >= 0) - { - Configuration.Settings.General.ListViewCpsWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexCps].Width; - } - - if (SubtitleListview1.ColumnIndexWpm >= 0) - { - Configuration.Settings.General.ListViewWpmWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexWpm].Width; - } - - if (SubtitleListview1.ColumnIndexText >= 0) - { - Configuration.Settings.General.ListViewTextWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexText].Width; - } - } - } - - private void SaveUndockedPositions() - { - if (_videoPlayerUndocked != null && !_videoPlayerUndocked.IsDisposed) - { - Configuration.Settings.General.UndockedVideoFullscreen = _videoPlayerUndocked.IsFullscreen; - Configuration.Settings.General.UndockedVideoPosition = _videoPlayerUndocked.Left + @";" + _videoPlayerUndocked.Top + @";" + _videoPlayerUndocked.Width + @";" + _videoPlayerUndocked.Height; - } - - if (_waveformUndocked != null && !_waveformUndocked.IsDisposed) - { - Configuration.Settings.General.UndockedWaveformPosition = _waveformUndocked.Left + @";" + _waveformUndocked.Top + @";" + _waveformUndocked.Width + @";" + _waveformUndocked.Height; - } - - if (_videoControlsUndocked != null && !_videoControlsUndocked.IsDisposed) - { - Configuration.Settings.General.UndockedVideoControlsPosition = _videoControlsUndocked.Left + @";" + _videoControlsUndocked.Top + @";" + _videoControlsUndocked.Width + @";" + _videoControlsUndocked.Height; - } - } - - private void ButtonUnBreakClick(object sender, EventArgs e) - { - Unbreak(); - } - - private void BreakUnbreakTextBox(bool unbreak, SETextBox tb) - { - var textCaretPos = tb.SelectionStart; - var startText = tb.Text.Substring(0, textCaretPos); - var numberOfNewLines = Utilities.CountTagInText(startText, Environment.NewLine); - if (unbreak) - { - textCaretPos -= numberOfNewLines; - tb.Text = Utilities.UnbreakLine(tb.Text); - } - else - { - int i = 0; - string s; - bool useLanguage = false; - var language = "en"; - if (Configuration.Settings.Tools.UseNoLineBreakAfter && tb == textBoxListViewText) - { - language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); - useLanguage = true; - } - else if (Configuration.Settings.Tools.UseNoLineBreakAfter && tb == textBoxListViewTextAlternate) - { - language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate); - useLanguage = true; - } - - if (useLanguage) - { - s = Utilities.AutoBreakLine(tb.Text, language); - } - else - { - s = Utilities.AutoBreakLine(tb.Text); - } - - while (i < textCaretPos && i < s.Length) - { - var ch = s[i]; - if (ch == '\n') - { - textCaretPos++; - } - - i++; - } - - textCaretPos -= numberOfNewLines; - tb.Text = s; - } - - tb.SelectionStart = textCaretPos; - } - - private void Unbreak(bool removeNewLineOnly = false) - { - _doAutoBreakOnTextChanged = false; - - var textCaretPos = textBoxListViewText.SelectionStart; - var startText = textBoxListViewText.Text.Substring(0, textCaretPos); - var numberOfNewLines = Utilities.CountTagInText(startText, Environment.NewLine); - textCaretPos -= numberOfNewLines; - bool historyAdded = false; - - if (SubtitleListview1.SelectedItems.Count > 1) - { - SubtitleListview1.BeginUpdate(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.GetParagraphOrDefault(index); - var oldText = p.Text; - var newText = p.Text; - if (removeNewLineOnly) - { - newText = newText.Replace(Environment.NewLine, string.Empty); - } - else - { - newText = Utilities.UnbreakLine(newText); - } - - if (oldText != newText) - { - if (!historyAdded) - { - historyAdded = true; - MakeHistoryForUndo(_language.BeforeRemoveLineBreaksInSelectedLines); - } - - p.Text = newText; - SubtitleListview1.SetText(index, p.Text); - } - - if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - oldText = original.Text; - newText = original.Text; - if (removeNewLineOnly) - { - newText = newText.Replace(Environment.NewLine, string.Empty); - } - else - { - newText = Utilities.UnbreakLine(newText); - } - - if (oldText != newText) - { - if (!historyAdded) - { - historyAdded = true; - MakeHistoryForUndo(_language.BeforeRemoveLineBreaksInSelectedLines); - } - - original.Text = newText; - SubtitleListview1.SetAlternateText(index, original.Text); - } - } - } - } - - SubtitleListview1.EndUpdate(); - RefreshSelectedParagraph(); - } - else - { - var fixedText = removeNewLineOnly ? textBoxListViewText.Text.Replace(Environment.NewLine, string.Empty) : Utilities.UnbreakLine(textBoxListViewText.Text); - var makeHistory = textBoxListViewText.Text != fixedText; - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var alternateFixedText = Utilities.UnbreakLine(textBoxListViewTextAlternate.Text); - if (!makeHistory) - { - makeHistory = textBoxListViewTextAlternate.Text != alternateFixedText; - } - - if (makeHistory) - { - MakeHistoryForUndo(_language.BeforeRemoveLineBreaksInSelectedLines); - textBoxListViewText.Text = fixedText; - } - - textBoxListViewTextAlternate.Text = alternateFixedText; - } - else if (makeHistory) - { - MakeHistoryForUndo(_language.BeforeRemoveLineBreaksInSelectedLines); - textBoxListViewText.Text = fixedText; - } - } - - _doAutoBreakOnTextChanged = true; - textBoxListViewText.SelectionStart = textCaretPos; - } - - private void TabControlSubtitleSelectedIndexChanged(object sender, EventArgs e) - { - var format = GetCurrentSubtitleFormat(); - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - ShowSource(); - ShowSourceLineNumber(); - if (textBoxSource.CanFocus) - { - textBoxSource.Focus(); - } - - // go to correct line in source view - if (SubtitleListview1.SelectedItems.Count > 0) - { - if (format.GetType() == typeof(SubRip)) - { - var p = _subtitle.GetParagraphOrDefault(FirstSelectedIndex); - if (p != null) - { - string tc = p.StartTime + " --> " + p.EndTime; - int start = textBoxSource.Text.IndexOf(p.Number + Environment.NewLine + tc, StringComparison.Ordinal); - if (start < 0) - { - start = 0; - } - - start = textBoxSource.Text.IndexOf(tc, start, StringComparison.Ordinal); - if (start > 0) - { - textBoxSource.SelectionStart = start + tc.Length + Environment.NewLine.Length; - textBoxSource.SelectionLength = 0; - textBoxSource.ScrollToCaret(); - } - } - } - else if (format.GetType() == typeof(SubStationAlpha) || format.GetType() == typeof(AdvancedSubStationAlpha)) - { - var p = _subtitle.GetParagraphOrDefault(FirstSelectedIndex); - if (p != null) - { - const string timeCodeFormat = "{0}:{1:00}:{2:00}.{3:00}"; // h:mm:ss.cc - string startTimeCode = string.Format(timeCodeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10); - string endTimeCode = string.Format(timeCodeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10); - string tc = startTimeCode + "," + endTimeCode; - int start = textBoxSource.Text.IndexOf(tc, StringComparison.Ordinal); - if (start > 0) - { - int start2 = textBoxSource.Text.LastIndexOf("Dialogue:", start, StringComparison.Ordinal); - if (start2 > 0) - { - start2 = (textBoxSource.Text + Environment.NewLine).IndexOf(Environment.NewLine, start2, StringComparison.Ordinal); - } - - if (start2 > 0) - { - start = start2; - } - - textBoxSource.SelectionStart = start; - textBoxSource.SelectionLength = 0; - textBoxSource.ScrollToCaret(); - } - } - } - } - } - else - { - ReloadFromSourceView(); - ShowLineInformationListView(); - if (SubtitleListview1.CanFocus) - { - SubtitleListview1.Focus(); - } - - // go to (select + focus) correct line in list view - if (textBoxSource.SelectionStart > 0 && textBoxSource.TextLength > 30) - { - if (format.GetType() == typeof(SubRip)) - { - var timeCodeRegEx = new Regex(@"^-?\d+:-?\d+:-?\d+[:,]-?\d+\s*-->\s*-?\d+:-?\d+:-?\d+[:,]-?\d+$"); - var lineNumber = textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart); - var lines = textBoxSource.Lines.ToList(); - if (lineNumber >= lines.Count) - { - lineNumber = lines.Count - 1; - } - - var currentLine = lines[lineNumber]; - var nextLine = lineNumber + 1 < lines.Count ? lines[lineNumber + 1] : string.Empty; - var startLine = 0; - if (Utilities.IsInteger(currentLine) && timeCodeRegEx.IsMatch(nextLine)) - { - startLine = lineNumber; - } - else - { - for (int i = lineNumber; i > 0; i--) - { - if (timeCodeRegEx.IsMatch(lines[i]) && Utilities.IsInteger(lines[i - 1])) - { - startLine = i - 1; - break; - } - } - } - - var sb = new StringBuilder(); - for (int i = startLine; i < lines.Count; i++) - { - sb.AppendLine(lines[i]); - } - - var sub = new Subtitle(); - new SubRip().LoadSubtitle(sub, sb.ToString().SplitToLines().ToList(), null); - if (sub.Paragraphs.Count > 0) - { - foreach (var p in _subtitle.Paragraphs) - { - if (sub.Paragraphs[0].Number == p.Number && - sub.Paragraphs[0].StartTime.TotalMilliseconds == p.StartTime.TotalMilliseconds && - sub.Paragraphs[0].EndTime.TotalMilliseconds == p.EndTime.TotalMilliseconds) - { - _subtitleListViewIndex = -1; - var index = _subtitle.Paragraphs.IndexOf(p); - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - break; - } - } - } - } - else if (format.GetType() == typeof(SubStationAlpha) || format.GetType() == typeof(AdvancedSubStationAlpha)) - { - int pos = textBoxSource.SelectionStart; - string s = textBoxSource.Text; - if (pos > 0) - { - pos--; - } - - while (pos > 0 && pos + 3 < s.Length && !s.Substring(pos, 3).StartsWith(Environment.NewLine, StringComparison.Ordinal)) - { - pos--; - } - - s = s.Substring(pos).Trim(); - int lastTimeCode = s.IndexOf("Dialogue:", StringComparison.Ordinal); - - if (lastTimeCode >= 0) - { - string tc = s.Substring(lastTimeCode).Trim(); - while (tc.Length > 0 && !char.IsDigit(tc[0])) - { - tc = tc.Remove(0, 1); - } - - if (tc.Length > 12) - { - TimeCode realTC; - tc = tc.Substring(0, 13); - var timeCode = tc.Split(new[] { ':', '.', ',' }, StringSplitOptions.RemoveEmptyEntries); - try - { - realTC = new TimeCode(int.Parse(timeCode[1]), int.Parse(timeCode[2]), int.Parse(timeCode[3]), int.Parse(timeCode[4]) * 10); - } - catch - { - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - return; - } - - int index = 0; - foreach (var p in _subtitle.Paragraphs) - { - if (Math.Abs(realTC.TotalMilliseconds - p.StartTime.TotalMilliseconds) < 50) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - break; - } - - index++; - } - } - } - } - } - else if (textBoxSource.SelectionStart == 0 && textBoxSource.TextLength > 30) - { - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - } - } - } - - private void ColorToolStripMenuItemClick(object sender, EventArgs e) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) - { - - string color; - var formatType = GetCurrentSubtitleFormat().GetType(); - if (formatType == typeof(Ebu)) - { - using (var form = new EbuColorPicker(true)) - { - if (form.ShowDialog(this) != DialogResult.OK) - { - return; - } - - color = form.Color; - } - } - else if (formatType == typeof(ScenaristClosedCaptions) || formatType == typeof(ScenaristClosedCaptionsDropFrame)) - { - using (var form = new EbuColorPicker(false)) - { - if (form.ShowDialog(this) != DialogResult.OK) - { - return; - } - - color = form.Color; - } - } - else - { - if (colorDialog1.ShowDialog(this) != DialogResult.OK) - { - return; - } - - color = Utilities.ColorToHex(colorDialog1.Color); - } - - MakeHistoryForUndo(_language.BeforeSettingColor); - foreach (ListViewItem item in SubtitleListview1.SelectedItems) - { - var p = _subtitle.GetParagraphOrDefault(item.Index); - if (p != null) - { - SetFontColor(p, color); - SubtitleListview1.SetText(item.Index, p.Text); - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) - { - var original = Utilities.GetOriginalParagraph(item.Index, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - SetFontColor(original, color); - SubtitleListview1.SetAlternateText(item.Index, original.Text); - } - } - } - } - - RefreshSelectedParagraph(); - - } - } - - private static void SetFontColor(Paragraph p, string color) - { - if (p == null) - { - return; - } - - string pre = string.Empty; - if (p.Text.StartsWith("{\\", StringComparison.Ordinal) && p.Text.IndexOf('}') >= 0) - { - int endIndex = p.Text.IndexOf('}') + 1; - pre = p.Text.Substring(0, endIndex); - p.Text = p.Text.Remove(0, endIndex); - } - - string s = p.Text; - if (s.StartsWith("'); - if (end > 0) - { - string f = s.Substring(0, end); - - if (f.Contains(" face=", StringComparison.OrdinalIgnoreCase) && !f.Contains(" color=", StringComparison.OrdinalIgnoreCase)) - { - var start = s.IndexOf(" face=", StringComparison.OrdinalIgnoreCase); - s = s.Insert(start, string.Format(" color=\"{0}\"", color)); - p.Text = pre + s; - return; - } - - var colorStart = f.IndexOf(" color=", StringComparison.OrdinalIgnoreCase); - if (colorStart >= 0) - { - if (s.IndexOf('"', colorStart + 8) > 0) - { - end = s.IndexOf('"', colorStart + 8); - } - - s = s.Substring(0, colorStart) + string.Format(" color=\"{0}", color) + s.Substring(end); - p.Text = pre + s; - return; - } - } - } - - p.Text = $"{pre}{p.Text}"; - } - - private void toolStripMenuItemFont_Click(object sender, EventArgs e) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) - { - using (var form = new ChooseFontName()) - { - - if (form.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeSettingFontName); - - foreach (ListViewItem item in SubtitleListview1.SelectedItems) - { - var p = _subtitle.GetParagraphOrDefault(item.Index); - if (p != null) - { - SetFontName(p, form.FontName); - SubtitleListview1.SetText(item.Index, p.Text); - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) - { - var original = Utilities.GetOriginalParagraph(item.Index, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - SetFontName(original, form.FontName); - SubtitleListview1.SetAlternateText(item.Index, original.Text); - } - } - } - } - - RefreshSelectedParagraph(); - } - } - } - } - - private void SetFontName(Paragraph p, string fontName) - { - if (p == null) - { - return; - } - - string pre = string.Empty; - if (p.Text.StartsWith("{\\", StringComparison.Ordinal) && p.Text.IndexOf('}') >= 0) - { - int endIndex = p.Text.IndexOf('}') + 1; - pre = p.Text.Substring(0, endIndex); - p.Text = p.Text.Remove(0, endIndex); - } - - string s = p.Text; - if (s.StartsWith("'); - if (end > 0) - { - var f = s.Substring(0, end); - - if (f.Contains(" color=", StringComparison.OrdinalIgnoreCase) && !f.Contains(" face=", StringComparison.OrdinalIgnoreCase)) - { - var start = s.IndexOf(" color=", StringComparison.OrdinalIgnoreCase); - p.Text = pre + s.Insert(start, string.Format(" face=\"{0}\"", fontName)); - return; - } - - var faceStart = f.IndexOf(" face=", StringComparison.OrdinalIgnoreCase); - if (f.Contains(" face=", StringComparison.OrdinalIgnoreCase)) - { - if (s.IndexOf('"', faceStart + 7) > 0) - { - end = s.IndexOf('"', faceStart + 7); - } - - p.Text = pre + s.Substring(0, faceStart) + string.Format(" face=\"{0}", fontName) + s.Substring(end); - return; - } - } - } - - p.Text = $"{pre}{s}"; - } - - private void TypeEffectToolStripMenuItemClick(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedItems.Count > 0) - { - using (var typewriter = new EffectTypewriter()) - { - typewriter.Initialize(SubtitleListview1.GetSelectedParagraph(_subtitle)); - - if (typewriter.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeTypeWriterEffect); - bool isframeBased = GetCurrentSubtitleFormat().IsFrameBased; - int lastSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - int i = SubtitleListview1.SelectedItems.Count - 1; - while (i >= 0) - { - var item = SubtitleListview1.SelectedItems[i]; - var p = _subtitle.GetParagraphOrDefault(item.Index); - if (p != null) - { - typewriter.Initialize(p); - typewriter.MakeAnimation(); - int index = item.Index; - _subtitle.Paragraphs.RemoveAt(index); - foreach (var tp in typewriter.TypewriterParagraphs) - { - _subtitle.Paragraphs.Insert(index, tp); - index++; - } - } - - i--; - } - - _subtitle.Renumber(); - _subtitleListViewIndex = -1; - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(lastSelectedIndex, true); - } - } - } - } - - private void KarokeeEffectToolStripMenuItemClick(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedItems.Count > 0) - { - using (var karaoke = new EffectKaraoke()) - { - karaoke.Initialize(SubtitleListview1.GetSelectedParagraph(_subtitle)); - - if (karaoke.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeKaraokeEffect); - int lastSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - bool isframeBased = GetCurrentSubtitleFormat().IsFrameBased; - - int i = SubtitleListview1.SelectedItems.Count - 1; - while (i >= 0) - { - var item = SubtitleListview1.SelectedItems[i]; - var p = _subtitle.GetParagraphOrDefault(item.Index); - if (p != null) - { - int index = item.Index; - _subtitle.Paragraphs.RemoveAt(index); - foreach (var kp in karaoke.MakeAnimation(p)) - { - _subtitle.Paragraphs.Insert(index, kp); - index++; - } - } - - i--; - } - - _subtitle.Renumber(); - _subtitleListViewIndex = -1; - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(lastSelectedIndex, true); - } - } - } - } - - private void MatroskaImportStripMenuItemClick(object sender, EventArgs e) - { - openFileDialog1.Title = _language.OpenMatroskaFile; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = _language.MatroskaFiles + "|*.mkv;*.mks|" + _languageGeneral.AllFiles + "|*.*"; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - openFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName); - ImportSubtitleFromMatroskaFile(openFileDialog1.FileName); - } - } - - private void ImportSubtitleFromMatroskaFile(string fileName) - { - using (var matroska = new MatroskaFile(fileName)) - { - if (matroska.IsValid) - { - var subtitleList = matroska.GetTracks(true); - if (subtitleList.Count == 0) - { - MessageBox.Show(_language.NoSubtitlesFound); - } - else if (ContinueNewOrExit()) - { - if (subtitleList.Count > 1) - { - using (var subtitleChooser = new MatroskaSubtitleChooser("mkv")) - { - subtitleChooser.Initialize(subtitleList); - if (_loading) - { - subtitleChooser.Icon = (Icon)this.Icon.Clone(); - subtitleChooser.ShowInTaskbar = true; - subtitleChooser.ShowIcon = true; - } - - if (subtitleChooser.ShowDialog(this) == DialogResult.OK) - { - if (LoadMatroskaSubtitle(subtitleList[subtitleChooser.SelectedIndex], matroska, false) && - (Path.GetExtension(matroska.Path).Equals(".mkv", StringComparison.OrdinalIgnoreCase) || - Path.GetExtension(matroska.Path).Equals(".mks", StringComparison.OrdinalIgnoreCase))) - { - if (!Configuration.Settings.General.DisableVideoAutoLoading) - { - matroska.Dispose(); - OpenVideo(matroska.Path); - } - } - else - { - _exitWhenLoaded = _loading; - } - } - } - } - else - { - var ext = Path.GetExtension(matroska.Path).ToLowerInvariant(); - if (LoadMatroskaSubtitle(subtitleList[0], matroska, false) && - (ext == ".mkv" || ext == ".mks")) - { - if (!Configuration.Settings.General.DisableVideoAutoLoading) - { - matroska.Dispose(); - if (ext == ".mkv") - { - OpenVideo(matroska.Path); - } - else - { - TryToFindAndOpenVideoFile(Path.Combine(Path.GetDirectoryName(matroska.Path), Path.GetFileNameWithoutExtension(matroska.Path))); - } - } - } - else - { - _exitWhenLoaded = _loading; - } - } - } - } - else - { - MessageBox.Show(string.Format(_language.NotAValidMatroskaFileX, fileName)); - } - } - } - - private int _lastProgressPercent = -1; - - private void UpdateProgress(long position, long total, string statusMessage) - { - var percent = (int)Math.Round(position * 100.0 / total); - if (percent == _lastProgressPercent) - { - return; - } - - ShowStatus(string.Format("{0}, {1:0}%", statusMessage, _lastProgressPercent)); - statusStrip1.Refresh(); - TaskbarList.SetProgressValue(Handle, percent, 100); - if (DateTime.UtcNow.Ticks % 10 == 0) - { - Application.DoEvents(); - } - - _lastProgressPercent = percent; - } - - private void MatroskaProgress(long position, long total) - { - UpdateProgress(position, total, _language.ParsingMatroskaFile); - } - - private Subtitle LoadMatroskaSubtitleForSync(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska) - { - var subtitle = new Subtitle(); - bool isSsa = false; - - if (matroskaSubtitleInfo.CodecId.Equals("S_VOBSUB", StringComparison.OrdinalIgnoreCase)) - { - return subtitle; - } - - if (matroskaSubtitleInfo.CodecId.Equals("S_HDMV/PGS", StringComparison.OrdinalIgnoreCase)) - { - return subtitle; - } - - SubtitleFormat format; - var codecPrivate = matroskaSubtitleInfo.GetCodecPrivate(); - if (codecPrivate.Contains("[script info]", StringComparison.OrdinalIgnoreCase)) - { - if (codecPrivate.Contains("[V4 Styles]", StringComparison.OrdinalIgnoreCase)) - { - format = new SubStationAlpha(); - } - else - { - format = new AdvancedSubStationAlpha(); - } - - isSsa = true; - } - else - { - format = new SubRip(); - } - - var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress); - TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); - if (isSsa) - { - foreach (var p in Utilities.LoadMatroskaSSA(matroskaSubtitleInfo, matroska.Path, format, sub).Paragraphs) - { - subtitle.Paragraphs.Add(p); - } - } - else - { - foreach (var p in sub) - { - subtitle.Paragraphs.Add(new Paragraph(p.GetText(matroskaSubtitleInfo), p.Start, p.End)); - } - } - - return subtitle; - } - - private bool LoadMatroskaSubtitle(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska, bool batchMode) - { - if (matroskaSubtitleInfo.CodecId.Equals("S_VOBSUB", StringComparison.OrdinalIgnoreCase)) - { - if (batchMode) - { - return false; - } - - return LoadVobSubFromMatroska(matroskaSubtitleInfo, matroska); - } - - if (matroskaSubtitleInfo.CodecId.Equals("S_HDMV/PGS", StringComparison.OrdinalIgnoreCase)) - { - if (batchMode) - { - return false; - } - - return LoadBluRaySubFromMatroska(matroskaSubtitleInfo, matroska); - } - - if (matroskaSubtitleInfo.CodecId.Equals("S_HDMV/TEXTST", StringComparison.OrdinalIgnoreCase)) - { - if (batchMode) - { - return false; - } - - return LoadTextSTFromMatroska(matroskaSubtitleInfo, matroska, batchMode); - } - - if (matroskaSubtitleInfo.CodecId.Equals("S_DVBSUB", StringComparison.OrdinalIgnoreCase)) - { - if (batchMode) - { - return false; - } - - return LoadDvbFromMatroska(matroskaSubtitleInfo, matroska, batchMode); - } - - ShowStatus(_language.ParsingMatroskaFile); - Refresh(); - Cursor.Current = Cursors.WaitCursor; - var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress); - TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); - Cursor.Current = Cursors.Default; - - MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); - _subtitleListViewIndex = -1; - if (!batchMode) - { - ResetSubtitle(); - } - - _subtitle.Paragraphs.Clear(); - - var format = Utilities.LoadMatroskaTextSubtitle(matroskaSubtitleInfo, matroska, sub, _subtitle); - - if (matroskaSubtitleInfo.GetCodecPrivate().Contains("[script info]", StringComparison.OrdinalIgnoreCase)) - { - if (_networkSession == null) - { - SubtitleListview1.ShowExtraColumn(_languageGeneral.Style); - } - } - else if (_networkSession == null) - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); - } - - comboBoxSubtitleFormats.SelectedIndexChanged -= ComboBoxSubtitleFormatsSelectedIndexChanged; - SetCurrentFormat(format); - comboBoxSubtitleFormats.SelectedIndexChanged += ComboBoxSubtitleFormatsSelectedIndexChanged; - _oldSubtitleFormat = format; - SetEncoding(Encoding.UTF8); - ShowStatus(_language.SubtitleImportedFromMatroskaFile); - _subtitle.Renumber(); - if (matroska.Path.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase) || matroska.Path.EndsWith(".mks", StringComparison.OrdinalIgnoreCase)) - { - _fileName = matroska.Path.Remove(matroska.Path.Length - 4) + format.Extension; - } - - SetTitle(); - _fileDateTime = new DateTime(); - _converted = true; - - if (batchMode) - { - return true; - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - if (_subtitle.Paragraphs.Count > 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - } - - ShowSource(); - return true; - } - - private bool LoadTextSTFromMatroska(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska, bool batchMode) - { - ShowStatus(_language.ParsingMatroskaFile); - Refresh(); - Cursor.Current = Cursors.WaitCursor; - var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress); - TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); - Cursor.Current = Cursors.Default; - - MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); - _subtitleListViewIndex = -1; - if (!batchMode) - { - ResetSubtitle(); - } - - _subtitle.Paragraphs.Clear(); - - Utilities.LoadMatroskaTextSubtitle(matroskaSubtitleInfo, matroska, sub, _subtitle); - for (int index = 0; index < sub.Count; index++) - { - try - { - var msub = sub[index]; - int idx = -6; // MakeMKV starts at DialogPresentationSegment - var data = msub.GetData(matroskaSubtitleInfo); - if (VobSubParser.IsPrivateStream2(data, 0)) - { - idx = 0; // starts with MPEG2 private stream 2 (just to be sure) - } - - var dps = new TextST.DialogPresentationSegment(data, idx); - _subtitle.Paragraphs[index].Text = dps.Text; - } - catch (Exception exception) - { - _subtitle.Paragraphs[index].Text = exception.Message; - } - } - - if (_networkSession == null) - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); - } - - comboBoxSubtitleFormats.SelectedIndexChanged -= ComboBoxSubtitleFormatsSelectedIndexChanged; - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - comboBoxSubtitleFormats.SelectedIndexChanged += ComboBoxSubtitleFormatsSelectedIndexChanged; - SetEncoding(Encoding.UTF8); - ShowStatus(_language.SubtitleImportedFromMatroskaFile); - _subtitle.Renumber(); - if (matroska.Path.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase) || matroska.Path.EndsWith(".mks", StringComparison.OrdinalIgnoreCase)) - { - _fileName = matroska.Path.Remove(matroska.Path.Length - 4) + GetCurrentSubtitleFormat().Extension; - } - - SetTitle(); - _fileDateTime = new DateTime(); - _converted = true; - if (batchMode) - { - return true; - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - if (_subtitle.Paragraphs.Count > 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - } - - ShowSource(); - return true; - } - - private bool LoadDvbFromMatroska(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska, bool batchMode) - { - ShowStatus(_language.ParsingMatroskaFile); - Refresh(); - Cursor.Current = Cursors.WaitCursor; - var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress); - TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); - Cursor.Current = Cursors.Default; - - MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); - _subtitleListViewIndex = -1; - if (!batchMode) - { - ResetSubtitle(); - } - - _subtitle.Paragraphs.Clear(); - var subtitleImages = new List(); - var subtitle = new Subtitle(); - Utilities.LoadMatroskaTextSubtitle(matroskaSubtitleInfo, matroska, sub, _subtitle); - for (int index = 0; index < sub.Count; index++) - { - try - { - var msub = sub[index]; - DvbSubPes pes = null; - var data = msub.GetData(matroskaSubtitleInfo); - if (data != null && data.Length > 9 && data[0] == 15 && data[1] >= SubtitleSegment.PageCompositionSegment && data[1] <= SubtitleSegment.DisplayDefinitionSegment) // sync byte + segment id - { - var buffer = new byte[data.Length + 3]; - Buffer.BlockCopy(data, 0, buffer, 2, data.Length); - buffer[0] = 32; - buffer[1] = 0; - buffer[buffer.Length - 1] = 255; - pes = new DvbSubPes(0, buffer); - } - else if (VobSubParser.IsMpeg2PackHeader(data)) - { - pes = new DvbSubPes(data, Mpeg2Header.Length); - } - else if (VobSubParser.IsPrivateStream1(data, 0)) - { - pes = new DvbSubPes(data, 0); - } - else if (data.Length > 9 && data[0] == 32 && data[1] == 0 && data[2] == 14 && data[3] == 16) - { - pes = new DvbSubPes(0, data); - } - - if (pes == null && subtitle.Paragraphs.Count > 0) - { - var last = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1]; - if (last.Duration.TotalMilliseconds < 100) - { - last.EndTime.TotalMilliseconds = msub.Start; - if (last.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) - { - last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + 3000; - } - } - } - - if (pes != null && pes.PageCompositions != null && pes.PageCompositions.Any(p => p.Regions.Count > 0)) - { - subtitleImages.Add(pes); - subtitle.Paragraphs.Add(new Paragraph(string.Empty, msub.Start, msub.End)); - } - } - catch - { - // continue - } - } - - if (subtitleImages.Count == 0) - { - return false; - } - - for (int index = 0; index < subtitle.Paragraphs.Count; index++) - { - var p = subtitle.Paragraphs[index]; - if (p.Duration.TotalMilliseconds < 200) - { - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 3000; - } - - var next = subtitle.GetParagraphOrDefault(index + 1); - if (next != null && next.StartTime.TotalMilliseconds < p.EndTime.TotalMilliseconds) - { - p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - - using (var formSubOcr = new VobSubOcr()) - { - formSubOcr.Initialize(subtitle, subtitleImages, Configuration.Settings.VobSubOcr); // TODO: language??? - if (_loading) - { - formSubOcr.Icon = (Icon)Icon.Clone(); - formSubOcr.ShowInTaskbar = true; - formSubOcr.ShowIcon = true; - } - - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - ResetSubtitle(); - _subtitle.Paragraphs.Clear(); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = Utilities.GetPathAndFileNameWithoutExtension(matroska.Path) + GetCurrentSubtitleFormat().Extension; - _converted = true; - SetTitle(); - - Configuration.Settings.Save(); - return true; - } - } - - return false; - } - - public static void CopyStream(Stream input, Stream output) - { - var buffer = new byte[128 * 1024]; - int len; - while ((len = input.Read(buffer, 0, buffer.Length)) > 0) - { - output.Write(buffer, 0, len); - } - - output.Flush(); - } - - private bool LoadVobSubFromMatroska(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska) - { - if (matroskaSubtitleInfo.ContentEncodingType == 1) - { - MessageBox.Show(_language.NoSupportEncryptedVobSub); - } - - ShowStatus(_language.ParsingMatroskaFile); - Refresh(); - Cursor.Current = Cursors.WaitCursor; - var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress); - TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); - Cursor.Current = Cursors.Default; - - MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); - _subtitleListViewIndex = -1; - _subtitle.Paragraphs.Clear(); - - List mergedVobSubPacks = new List(); - var idx = new Core.VobSub.Idx(matroskaSubtitleInfo.GetCodecPrivate().SplitToLines()); - foreach (var p in sub) - { - mergedVobSubPacks.Add(new VobSubMergedPack(p.GetData(matroskaSubtitleInfo), TimeSpan.FromMilliseconds(p.Start), 32, null)); - if (mergedVobSubPacks.Count > 0) - { - mergedVobSubPacks[mergedVobSubPacks.Count - 1].EndTime = TimeSpan.FromMilliseconds(p.End); - } - - // fix overlapping (some versions of Handbrake makes overlapping time codes - thx Hawke) - if (mergedVobSubPacks.Count > 1 && mergedVobSubPacks[mergedVobSubPacks.Count - 2].EndTime > mergedVobSubPacks[mergedVobSubPacks.Count - 1].StartTime) - { - mergedVobSubPacks[mergedVobSubPacks.Count - 2].EndTime = TimeSpan.FromMilliseconds(mergedVobSubPacks[mergedVobSubPacks.Count - 1].StartTime.TotalMilliseconds - 1); - } - } - - // Remove bad packs - for (int i = mergedVobSubPacks.Count - 1; i >= 0; i--) - { - if (mergedVobSubPacks[i].SubPicture.SubPictureDateSize <= 2) - { - mergedVobSubPacks.RemoveAt(i); - } - else if (mergedVobSubPacks[i].SubPicture.SubPictureDateSize <= 67 && mergedVobSubPacks[i].SubPicture.Delay.TotalMilliseconds < 35) - { - mergedVobSubPacks.RemoveAt(i); - } - } - - using (var formSubOcr = new VobSubOcr()) - { - formSubOcr.Initialize(mergedVobSubPacks, idx.Palette, Configuration.Settings.VobSubOcr, null); // TODO: language??? - if (_loading) - { - formSubOcr.Icon = (Icon)Icon.Clone(); - formSubOcr.ShowInTaskbar = true; - formSubOcr.ShowIcon = true; - } - - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - ResetSubtitle(); - _subtitle.Paragraphs.Clear(); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = Utilities.GetPathAndFileNameWithoutExtension(matroska.Path) + GetCurrentSubtitleFormat().Extension; - _converted = true; - SetTitle(); - - Configuration.Settings.Save(); - return true; - } - } - - return false; - } - - private bool LoadBluRaySubFromMatroska(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska) - { - if (matroskaSubtitleInfo.ContentEncodingType == 1) - { - MessageBox.Show(_language.NoSupportEncryptedVobSub); - } - - ShowStatus(_language.ParsingMatroskaFile); - Refresh(); - Cursor.Current = Cursors.WaitCursor; - var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress); - TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); - Cursor.Current = Cursors.Default; - - int noOfErrors = 0; - string lastError = string.Empty; - MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); - _subtitleListViewIndex = -1; - _subtitle.Paragraphs.Clear(); - var subtitles = new List(); - var log = new StringBuilder(); - var clusterStream = new MemoryStream(); - var lastPalettes = new Dictionary>(); - var lastBitmapObjects = new Dictionary>(); - foreach (var p in sub) - { - byte[] buffer = p.GetData(matroskaSubtitleInfo); - if (buffer != null && buffer.Length > 2) - { - clusterStream.Write(buffer, 0, buffer.Length); - if (ContainsBluRayStartSegment(buffer)) - { - if (subtitles.Count > 0 && subtitles[subtitles.Count - 1].StartTime == subtitles[subtitles.Count - 1].EndTime) - { - subtitles[subtitles.Count - 1].EndTime = (long)((p.Start - 1) * 90.0); - } - - clusterStream.Position = 0; - var list = BluRaySupParser.ParseBluRaySup(clusterStream, log, true, lastPalettes, lastBitmapObjects); - foreach (var sup in list) - { - sup.StartTime = (long)((p.Start - 1) * 90.0); - sup.EndTime = (long)((p.End - 1) * 90.0); - subtitles.Add(sup); - - // fix overlapping - if (subtitles.Count > 1 && sub[subtitles.Count - 2].End > sub[subtitles.Count - 1].Start) - { - subtitles[subtitles.Count - 2].EndTime = subtitles[subtitles.Count - 1].StartTime - 1; - } - } - - clusterStream = new MemoryStream(); - } - } - else if (subtitles.Count > 0) - { - var lastSub = subtitles[subtitles.Count - 1]; - if (lastSub.StartTime == lastSub.EndTime) - { - lastSub.EndTime = (long)((p.Start - 1) * 90.0); - if (lastSub.EndTime - lastSub.StartTime > 1000000) - { - lastSub.EndTime = lastSub.StartTime; - } - } - } - } - - if (noOfErrors > 0) - { - MessageBox.Show(string.Format("{0} error(s) occurred during extraction of bdsup\r\n\r\n{1}", noOfErrors, lastError)); - } - - using (var formSubOcr = new VobSubOcr()) - { - formSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, matroska.Path); - if (_loading) - { - formSubOcr.Icon = (Icon)Icon.Clone(); - formSubOcr.ShowInTaskbar = true; - formSubOcr.ShowIcon = true; - } - - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportingDvdSubtitle); - - _subtitle.Paragraphs.Clear(); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = string.Empty; - SetTitle(); - - Configuration.Settings.Save(); - return true; - } - } - - return false; - } - - private bool ContainsBluRayStartSegment(byte[] buffer) - { - const int epochStart = 0x80; - var position = 0; - while (position + 3 <= buffer.Length) - { - var segmentType = buffer[position]; - if (segmentType == epochStart) - { - return true; - } - - int length = BluRaySupParser.BigEndianInt16(buffer, position + 1) + 3; - position += length; - } - - return false; - } - - private void ImportSubtitleFromDvbSupFile(string fileName) - { - using (var formSubOcr = new VobSubOcr()) - { - string language = null; - var programMapTableParser = new ProgramMapTableParser(); - programMapTableParser.Parse(fileName); // get languages - if (programMapTableParser.GetSubtitlePacketIds().Count > 0) - { - language = programMapTableParser.GetSubtitleLanguageTwoLetter(programMapTableParser.GetSubtitlePacketIds().First()); - } - - var subtitles = TransportStreamParser.GetDvbSup(fileName); - formSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, fileName, language); - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportingDvdSubtitle); - - _subtitle.Paragraphs.Clear(); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = string.Empty; - SetTitle(); - - Configuration.Settings.Save(); - } - } - } - - private bool ImportSubtitleFromTransportStream(string fileName) - { - ShowStatus(_language.ParsingTransportStream); - Refresh(); - var tsParser = new TransportStreamParser(); - tsParser.Parse(fileName, (pos, total) => UpdateProgress(pos, total, _language.ParsingTransportStreamFile)); - ShowStatus(string.Empty); - TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); - - if (tsParser.SubtitlePacketIds.Count == 0 && tsParser.TeletextSubtitlesLookup.Count == 0) - { - MessageBox.Show(_language.NoSubtitlesFound); - _exitWhenLoaded = _loading; - return false; - } - - if (tsParser.SubtitlePacketIds.Count == 0 && tsParser.TeletextSubtitlesLookup.Count == 1 && tsParser.TeletextSubtitlesLookup.First().Value.Count() == 1) - { - _subtitle = new Subtitle(tsParser.TeletextSubtitlesLookup.First().Value.First().Value); - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle); - SubtitleListview1.SelectIndexAndEnsureVisible(0); - if (!Configuration.Settings.General.DisableVideoAutoLoading) - { - OpenVideo(fileName); - } - - _fileName = Path.GetFileNameWithoutExtension(fileName) + GetCurrentSubtitleFormat().Extension; - _converted = true; - SetTitle(); - return true; - } - - int packetId; - if (tsParser.SubtitlePacketIds.Count + tsParser.TeletextSubtitlesLookup.Sum(p => p.Value.Count()) > 1) - { - using (var subChooser = new TransportStreamSubtitleChooser()) - { - subChooser.Initialize(tsParser, fileName); - if (subChooser.ShowDialog(this) == DialogResult.Cancel) - { - return false; - } - - if (subChooser.IsTeletext) - { - new SubRip().LoadSubtitle(_subtitle, subChooser.Srt.SplitToLines(), null); - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle); - SubtitleListview1.SelectIndexAndEnsureVisible(0); - if (!Configuration.Settings.General.DisableVideoAutoLoading) - { - OpenVideo(fileName); - } - - _fileName = Path.GetFileNameWithoutExtension(fileName) + GetCurrentSubtitleFormat().Extension; - _converted = true; - SetTitle(); - return true; - } - - packetId = tsParser.SubtitlePacketIds[subChooser.SelectedIndex]; - } - } - else - { - packetId = tsParser.SubtitlePacketIds[0]; - } - - - var subtitles = tsParser.GetDvbSubtitles(packetId); - using (var formSubOcr = new VobSubOcr()) - { - string language = null; - var programMapTableParser = new ProgramMapTableParser(); - programMapTableParser.Parse(fileName); // get languages - if (programMapTableParser.GetSubtitlePacketIds().Count > 0) - { - language = programMapTableParser.GetSubtitleLanguage(packetId); - } - - formSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, fileName, language); - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportingDvdSubtitle); - - _subtitle.Paragraphs.Clear(); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = string.Empty; - if (!string.IsNullOrEmpty(formSubOcr.FileName)) - { - var currentFormat = GetCurrentSubtitleFormat(); - _fileName = Utilities.GetPathAndFileNameWithoutExtension(formSubOcr.FileName) + currentFormat.Extension; - if (!Configuration.Settings.General.DisableVideoAutoLoading) - { - OpenVideo(fileName); - } - _converted = true; - } - SetTitle(); - Configuration.Settings.Save(); - return true; - } - } - - _exitWhenLoaded = _loading; - return false; - } - - private bool ImportSubtitleFromMp4(string fileName) - { - var mp4Parser = new MP4Parser(fileName); - var mp4SubtitleTracks = mp4Parser.GetSubtitleTracks(); - if (mp4SubtitleTracks.Count == 0) - { - MessageBox.Show(_language.NoSubtitlesFound); - return false; - } - else if (mp4SubtitleTracks.Count == 1) - { - LoadMp4Subtitle(fileName, mp4SubtitleTracks[0]); - return true; - } - else - { - using (var subtitleChooser = new MatroskaSubtitleChooser("mp4")) - { - subtitleChooser.Initialize(mp4SubtitleTracks); - if (subtitleChooser.ShowDialog(this) == DialogResult.OK) - { - LoadMp4Subtitle(fileName, mp4SubtitleTracks[subtitleChooser.SelectedIndex]); - return true; - } - } - - return false; - } - } - - private bool ImportSubtitleFromDivX(string fileName) - { - var count = 0; - var list = new List(); - using (var f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - var searchBuffer = new byte[2048]; - long pos = 0; - long length = f.Length - 50; - while (pos < length) - { - f.Position = pos; - int readCount = f.Read(searchBuffer, 0, searchBuffer.Length); - for (int i = 0; i < readCount; i++) - { - if (searchBuffer[i] != 0x5b || (i + 4 < readCount && (searchBuffer[i + 1] < 0x30 || searchBuffer[i + 1] > 0x39 || searchBuffer[i + 3] != 0x3a))) - { - continue; - } - - f.Position = pos + i + 1; - - var buffer = new byte[26]; - f.Read(buffer, 0, buffer.Length); - - if (buffer[2] == 0x3a && // : - buffer[5] == 0x3a && // : - buffer[8] == 0x2e && // . - buffer[12] == 0x2d && // - - buffer[15] == 0x3a && // : - buffer[18] == 0x3a && // : - buffer[21] == 0x2e && // . - buffer[25] == 0x5d) // ] - { // subtitle time code - string timeCode = Encoding.ASCII.GetString(buffer, 0, 25); - - f.Read(buffer, 0, 2); - int width = BitConverter.ToUInt16(buffer, 0); - f.Read(buffer, 0, 2); - int height = BitConverter.ToUInt16(buffer, 0); - f.Read(buffer, 0, 2); - int x = BitConverter.ToUInt16(buffer, 0); - f.Read(buffer, 0, 2); - int y = BitConverter.ToUInt16(buffer, 0); - f.Read(buffer, 0, 2); - int xEnd = BitConverter.ToUInt16(buffer, 0); - f.Read(buffer, 0, 2); - int yEnd = BitConverter.ToUInt16(buffer, 0); - f.Read(buffer, 0, 2); - int RleLength = BitConverter.ToUInt16(buffer, 0); - - var colorBuffer = new byte[4 * 3]; // four colors with rgb (3 bytes) - f.Read(colorBuffer, 0, colorBuffer.Length); - - buffer = new byte[RleLength]; - int bytesRead = f.Read(buffer, 0, buffer.Length); - - if (width > 0 && height > 0 && bytesRead == buffer.Length) - { - var xSub = new XSub(timeCode, width, height, colorBuffer, buffer); - list.Add(xSub); - count++; - } - } - } - - pos += searchBuffer.Length; - } - } - - if (count == 0) - { - return false; - } - - using (var formSubOcr = new VobSubOcr()) - { - formSubOcr.Initialize(list, Configuration.Settings.VobSubOcr, fileName); // TODO: language??? - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); - _subtitleListViewIndex = -1; - FileNew(); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = Utilities.GetPathAndFileNameWithoutExtension(fileName) + GetCurrentSubtitleFormat().Extension; - _converted = true; - SetTitle(); - - Configuration.Settings.Save(); - if (!Configuration.Settings.General.DisableVideoAutoLoading) - { - OpenVideo(fileName); - } - } - } - - return true; - } - - private static Subtitle LoadMp4SubtitleForSync(Trak mp4SubtitleTrack) - { - var subtitle = new Subtitle(); - if (mp4SubtitleTrack.Mdia.IsVobSubSubtitle) - { - return subtitle; - } - else - { - subtitle.Paragraphs.AddRange(mp4SubtitleTrack.Mdia.Minf.Stbl.GetParagraphs()); - } - - return subtitle; - } - - private void LoadMp4Subtitle(string fileName, Trak mp4SubtitleTrack) - { - if (mp4SubtitleTrack.Mdia.IsVobSubSubtitle) - { - var subPicturesWithTimeCodes = new List(); - var paragraphs = mp4SubtitleTrack.Mdia.Minf.Stbl.GetParagraphs(); - for (int i = 0; i < paragraphs.Count; i++) - { - if (mp4SubtitleTrack.Mdia.Minf.Stbl.SubPictures.Count > i) - { - var start = paragraphs[i].StartTime.TimeSpan; - var end = paragraphs[i].EndTime.TimeSpan; - subPicturesWithTimeCodes.Add(new VobSubOcr.SubPicturesWithSeparateTimeCodes(mp4SubtitleTrack.Mdia.Minf.Stbl.SubPictures[i], start, end)); - } - } - - using (var formSubOcr = new VobSubOcr()) - { - formSubOcr.Initialize(subPicturesWithTimeCodes, Configuration.Settings.VobSubOcr, fileName); // TODO: language??? - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); - _subtitleListViewIndex = -1; - FileNew(); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = Utilities.GetPathAndFileNameWithoutExtension(fileName) + GetCurrentSubtitleFormat().Extension; - _converted = true; - SetTitle(); - - Configuration.Settings.Save(); - } - } - } - else - { - MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); - _subtitleListViewIndex = -1; - FileNew(); - - _subtitle.Paragraphs.AddRange(mp4SubtitleTrack.Mdia.Minf.Stbl.GetParagraphs()); - - SetEncoding(Encoding.UTF8); - ShowStatus(_language.SubtitleImportedFromMatroskaFile); - _subtitle.Renumber(); - if (fileName.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) || fileName.EndsWith(".m4v", StringComparison.OrdinalIgnoreCase)) - { - _fileName = fileName.Substring(0, fileName.Length - 4) + GetCurrentSubtitleFormat().Extension; - } - - SetTitle(); - _fileDateTime = new DateTime(); - _converted = true; - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - if (_subtitle.Paragraphs.Count > 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - } - - ShowSource(); - } - } - - private void SubtitleListview1_DragEnter(object sender, DragEventArgs e) - { - // make sure they're actually dropping files (not text or anything else) - if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) - { - e.Effect = DragDropEffects.All; - } - } - - private void SubtitleListview1_DragDrop(object sender, DragEventArgs e) - { - _dragAndDropFiles = (string[])e.Data.GetData(DataFormats.FileDrop); - if (_dragAndDropFiles.Length == 1) - { - _dragAndDropTimer.Start(); - } - else - { - MessageBox.Show(_language.DropOnlyOneFile); - } - } - - private void DoSubtitleListview1Drop(object sender, EventArgs e) - { - _dragAndDropTimer.Stop(); - - if (ContinueNewOrExit()) - { - string fileName = _dragAndDropFiles[0]; - var file = new FileInfo(fileName); - - // Do not allow directory drop - if (FileUtil.IsDirectory(fileName)) - { - MessageBox.Show(_language.ErrorDirectoryDropNotAllowed, file.Name, MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - - var dirName = Path.GetDirectoryName(fileName); - saveFileDialog1.InitialDirectory = dirName; - openFileDialog1.InitialDirectory = dirName; - var ext = file.Extension.ToLowerInvariant(); - - if (ext == ".mkv" || ext == ".mks") - { - using (var matroska = new MatroskaFile(fileName)) - { - if (matroska.IsValid) - { - var subtitleList = matroska.GetTracks(true); - if (subtitleList.Count == 0) - { - MessageBox.Show(_language.NoSubtitlesFound); - } - else if (subtitleList.Count > 1) - { - using (var subtitleChooser = new MatroskaSubtitleChooser("mkv")) - { - subtitleChooser.Initialize(subtitleList); - if (subtitleChooser.ShowDialog(this) == DialogResult.OK) - { - ResetSubtitle(); - if (LoadMatroskaSubtitle(subtitleList[subtitleChooser.SelectedIndex], matroska, false) && - (ext.Equals(".mkv", StringComparison.Ordinal) || ext.Equals(".mks", StringComparison.Ordinal)) && - !Configuration.Settings.General.DisableVideoAutoLoading) - { - OpenVideo(fileName); - } - } - } - } - else - { - ResetSubtitle(); - if (LoadMatroskaSubtitle(subtitleList[0], matroska, false) && - (ext.Equals(".mkv", StringComparison.Ordinal) || ext.Equals(".mks", StringComparison.Ordinal)) && - !Configuration.Settings.General.DisableVideoAutoLoading) - { - OpenVideo(fileName); - } - } - - return; - } - } - } - else if (ext == ".mp4" || ext == ".m4v" || ext == ".3gp") - { - var mp4Parser = new MP4Parser(fileName); - var mp4SubtitleTracks = mp4Parser.GetSubtitleTracks(); - if (mp4SubtitleTracks.Count > 0) - { - ImportSubtitleFromMp4(fileName); - return; - } - - MessageBox.Show(_language.NoSubtitlesFound); - return; - } - else if (ext == ".vob" || ext == ".ifo") - { - ImportDvdSubtitle(fileName); - return; - } - else if (ext == ".idx") - { - var subFileName = fileName.Substring(0, fileName.Length - 3) + "sub"; - if (File.Exists(subFileName) && FileUtil.IsVobSub(subFileName)) - { - ImportAndOcrVobSubSubtitleNew(subFileName, _loading); - return; - } - } - - comboBoxEncoding.BeginUpdate(); - comboBoxSubtitleFormats.BeginUpdate(); - - if (file.Length < Subtitle.MaxFileSize) - { - if (!OpenFromRecentFiles(fileName)) - { - OpenSubtitle(fileName, null); - } - } - else if (file.Length < 150000000 && ext == ".sub" && IsVobSubFile(fileName, true)) // max 150 mb - { - OpenSubtitle(fileName, null); - } - else if (file.Length < 250000000 && ext == ".sup" && FileUtil.IsBluRaySup(fileName)) // max 250 mb - { - OpenSubtitle(fileName, null); - } - else if ((ext == ".ts" || ext == ".rec" || ext == ".mpg" || ext == ".mpeg") && FileUtil.IsTransportStream(fileName)) - { - OpenSubtitle(fileName, null); - } - else if ((ext == ".m2ts" || ext == ".ts" || ext == ".mts") && FileUtil.IsM2TransportStream(fileName)) - { - OpenSubtitle(fileName, null); - } - else - { - MessageBox.Show(string.Format(_language.DropFileXNotAccepted, fileName)); - } - - comboBoxSubtitleFormats.EndUpdate(); - comboBoxEncoding.EndUpdate(); - } - } - - private void TextBoxSourceDragEnter(object sender, DragEventArgs e) - { - // make sure they're actually dropping files (not text or anything else) - if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) - { - e.Effect = DragDropEffects.All; - } - } - - private void TextBoxSourceDragDrop(object sender, DragEventArgs e) - { - var files = (string[])e.Data.GetData(DataFormats.FileDrop); - if (files.Length == 1) - { - if (ContinueNewOrExit()) - { - OpenSubtitle(files[0], null); - } - } - else - { - MessageBox.Show(_language.DropOnlyOneFile); - } - } - - private void ToolStripMenuItemManualAnsiClick(object sender, EventArgs e) - { - ReloadFromSourceView(); - openFileDialog1.Title = _language.OpenAnsiSubtitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - using (var chooseEncoding = new ChooseEncoding()) - { - chooseEncoding.Initialize(openFileDialog1.FileName); - if (chooseEncoding.ShowDialog(this) == DialogResult.OK) - { - Encoding encoding = chooseEncoding.GetEncoding(); - SetEncoding(Encoding.UTF8); - OpenSubtitle(openFileDialog1.FileName, encoding); - } - } - } - } - - private void ChangeCasingToolStripMenuItem_Click(object sender, EventArgs e) - { - ChangeCasing(false); - } - - private void ChangeCasing(bool onlySelectedLines) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - SaveSubtitleListviewIndices(); - using (var changeCasing = new ChangeCasing()) - { - if (onlySelectedLines) - { - changeCasing.Text += " - " + _language.SelectedLines; - } - - ReloadFromSourceView(); - if (changeCasing.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeChangeCasing); - - Cursor.Current = Cursors.WaitCursor; - var selectedLines = new Subtitle(); - var selectedIndices = new List(SubtitleListview1.GetSelectedIndices()); - if (onlySelectedLines) - { - foreach (int index in selectedIndices) - { - selectedLines.Paragraphs.Add(new Paragraph(_subtitle.Paragraphs[index])); - } - } - else - { - foreach (var p in _subtitle.Paragraphs) - { - selectedLines.Paragraphs.Add(new Paragraph(p)); - } - } - - bool saveChangeCaseChanges = true; - var casingNamesLinesChanged = 0; - - if (changeCasing.ChangeNamesToo && changeCasing.OnlyAllUpper) - { - selectedIndices = new List(); - var allUpperSubtitle = new Subtitle(); - var sub = onlySelectedLines ? selectedLines : _subtitle; - for (var index = 0; index < sub.Paragraphs.Count; index++) - { - var p = sub.Paragraphs[index]; - var noTags = HtmlUtil.RemoveHtmlTags(p.Text, true); - if (noTags == noTags.ToUpperInvariant()) - { - allUpperSubtitle.Paragraphs.Add(p); - selectedIndices.Add(index); - } - } - - selectedLines = allUpperSubtitle; - onlySelectedLines = true; - } - - changeCasing.FixCasing(selectedLines, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle)); - if (changeCasing.ChangeNamesToo) - { - using (var changeCasingNames = new ChangeCasingNames()) - { - changeCasingNames.Initialize(selectedLines); - if (changeCasingNames.ShowDialog(this) == DialogResult.OK) - { - changeCasingNames.FixCasing(); - casingNamesLinesChanged = changeCasingNames.LinesChanged; - - if (changeCasing.LinesChanged == 0) - { - ShowStatus(string.Format(_language.CasingCompleteMessageOnlyNames, casingNamesLinesChanged, _subtitle.Paragraphs.Count)); - } - else - { - ShowStatus(string.Format(_language.CasingCompleteMessage, changeCasing.LinesChanged, _subtitle.Paragraphs.Count, casingNamesLinesChanged)); - } - } - else - { - saveChangeCaseChanges = false; - } - } - } - else - { - ShowStatus(string.Format(_language.CasingCompleteMessageNoNames, changeCasing.LinesChanged, _subtitle.Paragraphs.Count)); - } - - if (saveChangeCaseChanges) - { - if (onlySelectedLines) - { - int i = 0; - foreach (int index in selectedIndices) - { - _subtitle.Paragraphs[index].Text = selectedLines.Paragraphs[i].Text; - i++; - } - } - else - { - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - _subtitle.Paragraphs[i].Text = selectedLines.Paragraphs[i].Text; - } - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - if (changeCasing.LinesChanged > 0 || casingNamesLinesChanged > 0) - { - _subtitleListViewIndex = -1; - RestoreSubtitleListviewIndices(); - UpdateSourceView(); - } - } - - Cursor.Current = Cursors.Default; - } - } - } - - private void ToolStripMenuItemChangeFrameRateClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - int lastSelectedIndex = 0; - if (SubtitleListview1.SelectedItems.Count > 0) - { - lastSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - } - - ReloadFromSourceView(); - using (var changeFrameRate = new ChangeFrameRate()) - { - changeFrameRate.Initialize(CurrentFrameRate.ToString()); - if (changeFrameRate.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeChangeFrameRate); - - double oldFrameRate = changeFrameRate.OldFrameRate; - double newFrameRate = changeFrameRate.NewFrameRate; - _subtitle.ChangeFrameRate(oldFrameRate, newFrameRate); - - ShowStatus(string.Format(_language.FrameRateChangedFromXToY, oldFrameRate, newFrameRate)); - toolStripComboBoxFrameRate.Text = newFrameRate.ToString(); - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(lastSelectedIndex, true); - } - } - } - - private bool IsVobSubFile(string subFileName, bool verbose) - { - try - { - if (FileUtil.IsVobSub(subFileName)) - { - if (!verbose) - { - return true; - } - - var idxFileName = Utilities.GetPathAndFileNameWithoutExtension(subFileName) + ".idx"; - if (File.Exists(idxFileName)) - { - return true; - } - - var dr = MessageBox.Show(string.Format(_language.IdxFileNotFoundWarning, idxFileName), _title, MessageBoxButtons.YesNoCancel); - return dr == DialogResult.Yes; - } - - if (verbose) - { - MessageBox.Show(string.Format(_language.InvalidVobSubHeader, subFileName)); - } - } - catch (Exception ex) - { - if (verbose) - { - MessageBox.Show(ex.Message); - } - } - - return false; - } - - private void ImportAndOcrSpDvdSup(string fileName, bool showInTaskbar) - { - var spList = new List(); - - using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - var buffer = new byte[SpHeader.SpHeaderLength]; - int bytesRead = fs.Read(buffer, 0, buffer.Length); - var header = new SpHeader(buffer); - - while (header.Identifier == "SP" && bytesRead > 0 && header.NextBlockPosition > 4) - { - buffer = new byte[header.NextBlockPosition]; - bytesRead = fs.Read(buffer, 0, buffer.Length); - if (bytesRead == buffer.Length) - { - header.AddPicture(buffer); - spList.Add(header); - } - - buffer = new byte[SpHeader.SpHeaderLength]; - bytesRead = fs.Read(buffer, 0, buffer.Length); - while (bytesRead == buffer.Length && Encoding.ASCII.GetString(buffer, 0, 2) != "SP") - { - fs.Seek(fs.Position - buffer.Length + 1, SeekOrigin.Begin); - bytesRead = fs.Read(buffer, 0, buffer.Length); - } - header = new SpHeader(buffer); - } - } - - using (var vobSubOcr = new VobSubOcr()) - { - if (showInTaskbar) - { - vobSubOcr.Icon = (Icon)this.Icon.Clone(); - vobSubOcr.ShowInTaskbar = true; - vobSubOcr.ShowIcon = true; - } - - vobSubOcr.Initialize(fileName, null, Configuration.Settings.VobSubOcr, spList); - if (vobSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportingVobSubFile); - FileNew(); - _subtitle.Paragraphs.Clear(); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - foreach (var p in vobSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = Path.ChangeExtension(vobSubOcr.FileName, GetCurrentSubtitleFormat().Extension); - SetTitle(); - _converted = true; - - Configuration.Settings.Save(); - } - else - { - _exitWhenLoaded = _loading; - } - } - } - - private void ImportAndOcrVobSubSubtitleNew(string fileName, bool showInTaskbar) - { - if (!IsVobSubFile(fileName, true)) - { - return; - } - - using (var vobSubOcr = new VobSubOcr()) - { - if (showInTaskbar) - { - vobSubOcr.Icon = (Icon)Icon.Clone(); - vobSubOcr.ShowInTaskbar = true; - vobSubOcr.ShowIcon = true; - } - - if (vobSubOcr.Initialize(fileName, Configuration.Settings.VobSubOcr, this) && vobSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportingVobSubFile); - FileNew(); - _subtitle.Paragraphs.Clear(); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - foreach (var p in vobSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = Path.ChangeExtension(vobSubOcr.FileName, GetCurrentSubtitleFormat().Extension); - SetTitle(); - _converted = true; - - Configuration.Settings.Save(); - } - else - { - _exitWhenLoaded = _loading; - } - } - } - - private void ToolStripMenuItemMergeLinesClick(object sender, EventArgs e) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count >= 1) - { - // check consecutive numbers - var last = SubtitleListview1.SelectedIndices[0] - 1; - foreach (int index in SubtitleListview1.SelectedIndices) - { - if (last != index - 1) - { - return; - } - - last = index; - } - - MergeAfterToolStripMenuItemClick(null, null); - } - } - - private void VisualSyncSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) - { - ShowVisualSync(true); - } - - private void SaveSubtitleListviewIndices() - { - _selectedIndices = new List(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - _selectedIndices.Add(index); - } - } - - private void RestoreSubtitleListviewIndices() - { - _subtitleListViewIndex = -1; - if (_selectedIndices != null) - { - SubtitleListview1.SelectNone(); - int i = 0; - foreach (int index in _selectedIndices) - { - if (index >= 0 && index < SubtitleListview1.Items.Count) - { - SubtitleListview1.Items[index].Selected = true; - if (i == 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - } - } - - i++; - } - } - } - - private void ShowSelectedLinesEarlierlaterToolStripMenuItemClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - if (_showEarlierOrLater != null && !_showEarlierOrLater.IsDisposed) - { - _showEarlierOrLater.WindowState = FormWindowState.Normal; - _showEarlierOrLater.Focus(); - return; - } - - bool waveformEnabled = timerWaveform.Enabled; - timerWaveform.Stop(); - timer1.Stop(); - - _showEarlierOrLater = new ShowEarlierLater(); - if (!_showEarlierOrLater.IsPositionAndSizeSaved) - { - _showEarlierOrLater.Top = Top + 100; - _showEarlierOrLater.Left = Left + (Width / 2) - (_showEarlierOrLater.Width / 3); - } - - _showEarlierOrLater.Initialize(ShowEarlierOrLater, true); - MakeHistoryForUndo(_language.BeforeShowSelectedLinesEarlierLater); - _showEarlierOrLater.Show(this); - - timerWaveform.Enabled = waveformEnabled; - timer1.Start(); - - RefreshSelectedParagraph(); - } - - public static Control FindFocusedControl(Control control) - { - var container = control as ContainerControl; - while (container != null) - { - control = container.ActiveControl; - container = control as ContainerControl; - } - - return control; - } - - internal void MainKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.LWin) - { - _winLeftDownTicks = DateTime.UtcNow.Ticks; - } - - if (e.KeyCode == Keys.RWin) - { - _winRightDownTicks = DateTime.UtcNow.Ticks; - } - - if ((DateTime.UtcNow.Ticks - _winLeftDownTicks) <= 10000 * 999 || (DateTime.UtcNow.Ticks - _winRightDownTicks) <= 10000 * 999) // less than 999 ms - { - // if it's less than one second since Win key was pressed we ignore key (not perfect...) - e.SuppressKeyPress = true; - return; - } - - if (e.Modifiers == Keys.Alt && e.KeyCode == (Keys.RButton | Keys.ShiftKey) && (textBoxListViewText.Focused || textBoxListViewTextAlternate.Focused)) - { // annoying that focus leaves textbox while typing, when pressing Alt alone - e.SuppressKeyPress = true; - return; - } - - if (e.Modifiers == Keys.Alt && e.KeyCode == (Keys.RButton | Keys.ShiftKey)) - { - return; - } - - if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.ShiftKey) - { - return; - } - - if (e.Modifiers == Keys.Control && e.KeyCode == (Keys.LButton | Keys.ShiftKey)) - { - return; - } - - if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.ShiftKey) - { - return; - } - - var fc = FindFocusedControl(this); - if (fc != null && e.Modifiers != Keys.Control && e.Modifiers != Keys.Alt && e.Modifiers != (Keys.Control | Keys.Shift) && e.Modifiers != (Keys.Control | Keys.Alt) && e.Modifiers != (Keys.Control | Keys.Shift | Keys.Alt)) - { - // do not check for shortcuts if text is being entered and a textbox is focused - if ((fc.Parent.Name == textBoxListViewText.Name || fc.Parent.Name == textBoxListViewTextAlternate.Name || fc.Name == textBoxSearchWord.Name) && - ((e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z) || (e.KeyCode >= Keys.OemSemicolon && e.KeyCode <= Keys.OemBackslash))) - { - return; - } - - // do not check for shortcuts if a number is being entered and a time box is focused - if (fc.Parent != null && (fc.Parent.Name == timeUpDownStartTime.Name || fc.Parent.Name == numericUpDownDuration.Name) && - (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9 || e.KeyValue >= 48 && e.KeyValue <= 57)) - { - return; - } - } - - bool inListView = tabControlSubtitle.SelectedIndex == TabControlListView; - - - if (e.KeyCode == Keys.Escape && !_cancelWordSpellCheck) - { - _cancelWordSpellCheck = true; - } - else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformVerticalZoom) - { - audioVisualizer.VerticalZoomFactor *= 1.1; - e.SuppressKeyPress = true; - } - else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformVerticalZoomOut) - { - audioVisualizer.VerticalZoomFactor /= 1.1; - e.SuppressKeyPress = true; - } - else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformZoomIn) - { - audioVisualizer.ZoomIn(); - e.SuppressKeyPress = true; - } - else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformZoomOut) - { - audioVisualizer.ZoomOut(); - e.SuppressKeyPress = true; - } - else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformSplit) - { - if (mediaPlayer.IsPaused) - { - var pos = mediaPlayer.VideoPlayer.CurrentPosition; - var paragraph = _subtitle.GetFirstParagraphOrDefaultByTime(pos * TimeCode.BaseUnit); - if (paragraph != null && - pos * TimeCode.BaseUnit + 100 > paragraph.StartTime.TotalMilliseconds && - pos * TimeCode.BaseUnit - 100 < paragraph.EndTime.TotalMilliseconds) - { - SubtitleListview1.SelectIndexAndEnsureVisible(paragraph); - SplitSelectedParagraph(pos, null); - } - } - - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.VideoPlayFirstSelected && !string.IsNullOrEmpty(VideoFileName)) - { - PlayFirstSelectedSubtitle(); - } - else if (audioVisualizer.Visible && (e.KeyData == _shortcuts.WaveformPlaySelection || e.KeyData == _shortcuts.WaveformPlaySelectionEnd)) - { - WaveformPlaySelection(nearEnd: e.KeyData == _shortcuts.WaveformPlaySelectionEnd); - e.SuppressKeyPress = true; - } - else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformSearchSilenceForward) - { - if (audioVisualizer.WavePeaks != null) - { - audioVisualizer.FindDataBelowThreshold(Configuration.Settings.VideoControls.WaveformSeeksSilenceMaxVolume, Configuration.Settings.VideoControls.WaveformSeeksSilenceDurationSeconds); - } - e.SuppressKeyPress = true; - } - else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformSearchSilenceBack) - { - if (audioVisualizer.WavePeaks != null) - { - audioVisualizer.FindDataBelowThresholdBack(Configuration.Settings.VideoControls.WaveformSeeksSilenceMaxVolume, Configuration.Settings.VideoControls.WaveformSeeksSilenceDurationSeconds); - } - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainInsertAfter == e.KeyData && inListView) - { - InsertAfter(string.Empty); - e.SuppressKeyPress = true; - textBoxListViewText.Focus(); - } - else if (_shortcuts.MainInsertBefore == e.KeyData && inListView) - { - InsertBefore(); - e.SuppressKeyPress = true; - textBoxListViewText.Focus(); - } - else if (_shortcuts.MainMergeDialog == e.KeyData && inListView) - { - MergeDialogs(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainListViewToggleDashes == e.KeyData && inListView) - { - if (textBoxListViewText.Focused) - { - ToggleDashesTextBox(textBoxListViewText); - } - else if (textBoxListViewTextAlternate.Focused) - { - ToggleDashesTextBox(textBoxListViewTextAlternate); - } - else - { - ToggleDashes(); - } - e.SuppressKeyPress = true; - } - else if (!toolStripMenuItemRtlUnicodeControlChars.Visible && _shortcuts.MainEditFixRTLViaUnicodeChars == e.KeyData && inListView) - { - toolStripMenuItemRtlUnicodeControlChar_Click(null, null); - e.SuppressKeyPress = true; - } - else if (!toolStripMenuItemRemoveUnicodeControlChars.Visible && _shortcuts.MainEditRemoveRTLUnicodeChars == e.KeyData && inListView) - { - toolStripMenuItemRemoveUnicodeControlChar_Click(null, null); - e.SuppressKeyPress = true; - } - else if (!toolStripMenuItemReverseRightToLeftStartEnd.Visible && _shortcuts.MainEditReverseStartAndEndingForRtl == e.KeyData && inListView) - { - ReverseStartAndEndingForRtl(); - e.SuppressKeyPress = true; - } - else if (toolStripMenuItemUndo.ShortcutKeys == e.KeyData) // undo - { - toolStripMenuItemUndo_Click(sender, e); - e.SuppressKeyPress = true; - } - else if (toolStripMenuItemRedo.ShortcutKeys == e.KeyData) // redo - { - toolStripMenuItemRedo_Click(sender, e); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt) - { - if (AutoRepeatContinueOn || AutoRepeatOn) - { - PlayNext(); - } - else - { - ButtonNextClick(null, null); - } - } - else if (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt) - { - if (AutoRepeatContinueOn || AutoRepeatOn) - { - PlayPrevious(); - } - else - { - ButtonPreviousClick(null, null); - } - - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralGoToNextSubtitle == e.KeyData) - { - MoveNextPrevious(0); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralGoToNextSubtitleCursorAtEnd == e.KeyData) - { - MoveNextPrevious(0); - textBoxListViewText.SelectionStart = textBoxListViewText.Text.Length; - textBoxListViewText.SelectionLength = 0; - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralGoToPrevSubtitle == e.KeyData) - { - if (AutoRepeatContinueOn || AutoRepeatOn) - { - PlayPrevious(); - } - else - { - ButtonPreviousClick(null, null); - } - - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralGoToStartOfCurrentSubtitle == e.KeyData) - { - if (SubtitleListview1.SelectedItems.Count == 1 && mediaPlayer.VideoPlayer != null) - { - mediaPlayer.CurrentPosition = _subtitle.Paragraphs[SubtitleListview1.SelectedItems[0].Index].StartTime.TotalSeconds; - e.SuppressKeyPress = true; - } - - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralGoToEndOfCurrentSubtitle == e.KeyData) - { - if (SubtitleListview1.SelectedItems.Count == 1 && mediaPlayer.VideoPlayer != null) - { - mediaPlayer.CurrentPosition = _subtitle.Paragraphs[SubtitleListview1.SelectedItems[0].Index].EndTime.TotalSeconds; - e.SuppressKeyPress = true; - } - - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGoToPreviousSubtitleAndFocusVideo == e.KeyData) - { - int newIndex = _subtitleListViewIndex - 1; - if (newIndex >= 0) - { - _subtitleListViewIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisibleFaster(newIndex); - _subtitleListViewIndex = newIndex; - textBoxListViewText.Focus(); - textBoxListViewText.SelectAll(); - GotoSubtitleIndex(newIndex); - ShowSubtitle(); - e.SuppressKeyPress = true; - } - } - else if (_shortcuts.MainGoToNextSubtitleAndFocusVideo == e.KeyData) - { - int newIndex = _subtitleListViewIndex + 1; - if (newIndex < _subtitle.Paragraphs.Count) - { - _subtitleListViewIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisibleFaster(newIndex); - _subtitleListViewIndex = newIndex; - textBoxListViewText.Focus(); - textBoxListViewText.SelectAll(); - GotoSubtitleIndex(newIndex); - ShowSubtitle(); - e.SuppressKeyPress = true; - } - } - else if (_shortcuts.MainGoToNextSubtitleAndPlay == e.KeyData && mediaPlayer != null) - { - int newIndex = _subtitleListViewIndex + 1; - if (newIndex < _subtitle.Paragraphs.Count) - { - _subtitleListViewIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisibleFaster(newIndex); - _subtitleListViewIndex = newIndex; - textBoxListViewText.Focus(); - textBoxListViewText.SelectAll(); - GotoSubtitleIndex(newIndex); - var p = _subtitle.GetParagraphOrDefault(newIndex); - if (p != null) - { - mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; - ShowSubtitle(); - mediaPlayer.Play(); - _endSeconds = p.EndTime.TotalSeconds; - } - - e.SuppressKeyPress = true; - } - } - else if (_shortcuts.MainGoToPrevSubtitleAndPlay == e.KeyData && mediaPlayer != null) - { - int newIndex = _subtitleListViewIndex - 1; - if (newIndex > 0) - { - _subtitleListViewIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisibleFaster(newIndex); - _subtitleListViewIndex = newIndex; - textBoxListViewText.Focus(); - textBoxListViewText.SelectAll(); - GotoSubtitleIndex(newIndex); - var p = _subtitle.GetParagraphOrDefault(newIndex); - if (p != null) - { - mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; - ShowSubtitle(); - mediaPlayer.Play(); - _endSeconds = p.EndTime.TotalSeconds; - } - - e.SuppressKeyPress = true; - } - } - else if (_shortcuts.MainUnbreakNoSpace == e.KeyData) - { - Unbreak(true); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralToggleBookmarks == e.KeyData) - { - ToggleBookmarks(false); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralClearBookmarks == e.KeyData) - { - ClearBookmarks(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralGoToBookmark == e.KeyData) - { - e.SuppressKeyPress = true; - GoToBookmark(); - } - else if (_shortcuts.MainGeneralGoToPreviousBookmark == e.KeyData) - { - GoToPrevoiusBookmark(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralGoToNextBookmark == e.KeyData) - { - GoToNextBookmark(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralChooseProfile == e.KeyData) - { - ChooseProfile(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralDuplicateLine == e.KeyData && SubtitleListview1.SelectedItems.Count == 1) - { - DuplicateLine(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralFileSaveAll == e.KeyData) - { - SaveAll(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainToggleFocus == e.KeyData && inListView) - { - if (SubtitleListview1.Focused) - { - textBoxListViewText.Focus(); - } - else - { - SubtitleListview1.Focus(); - } - - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.Home && e.Modifiers == Keys.Alt) - { - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.End && e.Modifiers == Keys.Alt) - { - SubtitleListview1.SelectIndexAndEnsureVisible(SubtitleListview1.Items.Count - 1, true); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralGoToFirstSelectedLine == e.KeyData) //Locate first selected line in subtitle listview - { - if (SubtitleListview1.SelectedItems.Count > 0) - { - SubtitleListview1.SelectedItems[0].EnsureVisible(); - } - - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralGoToFirstEmptyLine == e.KeyData) //Go to first empty line - if any - { - GoToFirstEmptyLine(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralMergeSelectedLines == e.KeyData) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count >= 1) - { - e.SuppressKeyPress = true; - if (SubtitleListview1.SelectedItems.Count == 2) - { - MergeAfterToolStripMenuItemClick(null, null); - } - else - { - MergeSelectedLines(); - } - } - } - else if (_shortcuts.MainGeneralMergeSelectedLinesAndAutoBreak == e.KeyData) - { - e.SuppressKeyPress = true; - if (SubtitleListview1.SelectedItems.Count == 2) - { - MergeWithLineAfter(false, BreakMode.AutoBreak); - } - else - { - MergeSelectedLines(BreakMode.AutoBreak); - } - } - else if (_shortcuts.MainGeneralMergeSelectedLinesAndUnbreak == e.KeyData) - { - e.SuppressKeyPress = true; - if (SubtitleListview1.SelectedItems.Count == 2) - { - MergeWithLineAfter(false, BreakMode.Unbreak); - } - else - { - MergeSelectedLines(BreakMode.Unbreak); - } - } - else if (_shortcuts.MainGeneralMergeSelectedLinesAndUnbreakNoSpace == e.KeyData) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count >= 1) - { - e.SuppressKeyPress = true; - if (SubtitleListview1.SelectedItems.Count == 2) - { - MergeWithLineAfter(false, BreakMode.UnbreakNoSpace); - } - else - { - MergeSelectedLines(BreakMode.UnbreakNoSpace); - } - } - } - else if (_shortcuts.MainGeneralMergeSelectedLinesBilingual == e.KeyData) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count >= 1 && SubtitleListview1.SelectedItems.Count < 10) - { - e.SuppressKeyPress = true; - MergeSelectedLinesBilingual(); - } - } - else if (_shortcuts.MainGeneralMergeSelectedLinesOnlyFirstText == e.KeyData) - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count >= 1) - { - e.SuppressKeyPress = true; - MergeSelectedLinesOnlyFirstText(); - } - } - else if (_shortcuts.MainGeneralMergeWithNext == e.KeyData) - { - if (SubtitleListview1.SelectedItems.Count >= 1) - { - var idx = SubtitleListview1.SelectedItems[0].Index; - if (idx >= 0 && _subtitle.Paragraphs.Count > idx + 1) - { - SubtitleListview1.SelectIndexAndEnsureVisible(idx, true); - MergeAfterToolStripMenuItemClick(null, null); - e.SuppressKeyPress = true; - } - } - } - else if (_shortcuts.MainGeneralMergeWithPrevious == e.KeyData) - { - if (SubtitleListview1.SelectedItems.Count >= 1) - { - var idx = SubtitleListview1.SelectedItems[0].Index; - if (idx > 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(idx - 1, true); - MergeAfterToolStripMenuItemClick(null, null); - e.SuppressKeyPress = true; - } - } - } - else if (_shortcuts.MainGeneralToggleTranslationMode == e.KeyData) - { // toggle translator mode - EditToolStripMenuItemDropDownOpening(null, null); - toolStripMenuItemTranslationMode_Click(null, null); - } - else if (e.KeyData == _shortcuts.VideoPlayPauseToggle) - { - if (mediaPlayer.VideoPlayer != null) - { - if (_shortcuts.VideoPlayPauseToggle == Keys.Space && - (textBoxListViewText.Focused || textBoxListViewTextAlternate.Focused || textBoxSearchWord.Focused)) - { - return; - } - - _endSeconds = -1; - e.SuppressKeyPress = true; - System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(1), () => mediaPlayer.TogglePlayPause()); - } - } - else if (e.KeyData == _shortcuts.VideoPause) - { - if (mediaPlayer.VideoPlayer != null) - { - _endSeconds = -1; - mediaPlayer.Pause(); - e.SuppressKeyPress = true; - } - } - else if (_shortcuts.MainVideoPlayFromJustBefore == e.KeyData) - { - buttonBeforeText_Click(null, null); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.Right) - { - if (!textBoxListViewText.Focused && !textBoxListViewTextAlternate.Focused) - { - mediaPlayer.CurrentPosition += 1.0; - e.SuppressKeyPress = true; - } - } - else if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.Left) - { - if (!textBoxListViewText.Focused && !textBoxListViewTextAlternate.Focused) - { - mediaPlayer.CurrentPosition -= 1.0; - e.SuppressKeyPress = true; - } - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Space) - { - if (!textBoxListViewText.Focused && !textBoxListViewTextAlternate.Focused && !textBoxSource.Focused && mediaPlayer.VideoPlayer != null) - { - if (audioVisualizer.Focused || mediaPlayer.Focused || SubtitleListview1.Focused) - { - _endSeconds = -1; - mediaPlayer.TogglePlayPause(); - e.SuppressKeyPress = true; - } - } - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.D1) - { - if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle != null && mediaPlayer.VideoPlayer != null) - { - var p = _subtitle.GetParagraphOrDefault(SubtitleListview1.SelectedItems[0].Index); - if (p != null) - { - mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; - } - } - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.D2) - { - if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle != null && mediaPlayer.VideoPlayer != null) - { - var p = _subtitle.GetParagraphOrDefault(SubtitleListview1.SelectedItems[0].Index); - if (p != null) - { - mediaPlayer.CurrentPosition = p.EndTime.TotalSeconds; - } - } - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.D3) - { - if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle != null && mediaPlayer.VideoPlayer != null) - { - int index = SubtitleListview1.SelectedItems[0].Index - 1; - var p = _subtitle.GetParagraphOrDefault(index); - if (p != null) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; - } - } - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.D4) - { - if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle != null && mediaPlayer.VideoPlayer != null) - { - int index = SubtitleListview1.SelectedItems[0].Index + 1; - var p = _subtitle.GetParagraphOrDefault(index); - if (p != null) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; - } - } - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainVideoToggleStartEndCurrent == e.KeyData) - { - if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle != null && mediaPlayer.VideoPlayer != null) - { - mediaPlayer.Pause(); - var p = _subtitle.GetParagraphOrDefault(SubtitleListview1.SelectedItems[0].Index); - if (p != null) - { - if (Math.Abs(mediaPlayer.CurrentPosition - p.StartTime.TotalSeconds) < 0.1) - { - mediaPlayer.CurrentPosition = p.EndTime.TotalSeconds; - } - else - { - mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; - } - } - } - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainVideoPlayCurrent == e.KeyData) - { - if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle != null && mediaPlayer.VideoPlayer != null) - { - var p = _subtitle.GetParagraphOrDefault(SubtitleListview1.SelectedItems[0].Index); - if (p != null) - { - mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; - ShowSubtitle(); - mediaPlayer.Play(); - _endSeconds = p.EndTime.TotalSeconds; - } - } - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainVideoGoToStartCurrent == e.KeyData) - { - if (mediaPlayer.VideoPlayer != null) - { - GotoSubPositionAndPause(); - } - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainVideo3000MsLeft == e.KeyData) - { - if (mediaPlayer.VideoPlayer != null) - { - GoBackSeconds(3); - } - e.SuppressKeyPress = true; - } - else if (e.Modifiers == (Keys.Control | Keys.Alt | Keys.Shift) && e.KeyCode == Keys.W) // watermark - { - var enc = GetCurrentEncoding(); - if (enc != Encoding.UTF8 && enc != Encoding.UTF32 && enc != Encoding.Unicode && enc != Encoding.UTF7) - { - MessageBox.Show(Configuration.Settings.Language.Watermark.ErrorUnicodeEncodingOnly); - } - else - { - using (var watermarkForm = new Watermark()) - { - MakeHistoryForUndo(Configuration.Settings.Language.Watermark.BeforeWatermark); - watermarkForm.Initialize(_subtitle, FirstSelectedIndex); - if (watermarkForm.ShowDialog(this) == DialogResult.OK) - { - watermarkForm.AddOrRemove(_subtitle); - RefreshSelectedParagraph(); - } - } - } - - e.SuppressKeyPress = true; - } - else if (e.Modifiers == (Keys.Control | Keys.Alt | Keys.Shift) && e.KeyCode == Keys.F) // Toggle HHMMSSFF / HHMMSSMMM - { - Configuration.Settings.General.UseTimeFormatHHMMSSFF = !Configuration.Settings.General.UseTimeFormatHHMMSSFF; - RefreshTimeCodeMode(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralSwitchTranslationAndOriginal == e.KeyData) // switch original/current - { - if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0 && _networkSession == null) - { - int firstIndex = FirstSelectedIndex; - double firstMs = -1; - if (firstIndex >= 0) - { - firstMs = _subtitle.Paragraphs[firstIndex].StartTime.TotalMilliseconds; - } - - var temp = _subtitle; - _subtitle = _subtitleAlternate; - _subtitleAlternate = temp; - - var tempName = _fileName; - _fileName = _subtitleAlternateFileName; - _subtitleAlternateFileName = tempName; - - var tempChangeSubText = _changeSubtitleHash; - _changeSubtitleHash = _changeAlternateSubtitleHash; - _changeAlternateSubtitleHash = tempChangeSubText; - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - - _subtitleListViewIndex = -1; - if (firstIndex >= 0 && _subtitle.Paragraphs.Count > firstIndex && Math.Abs(_subtitle.Paragraphs[firstIndex].StartTime.TotalMilliseconds - firstMs) < 0.01) - { - SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex, true); - } - else - { - RefreshSelectedParagraph(); - } - - SetTitle(); - - _fileDateTime = new DateTime(); - } - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainGeneralMergeTranslationAndOriginal == e.KeyData) // Merge translation and original - { - if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0 && _networkSession == null) - { - if (ContinueNewOrExit()) - { - var subtitle = new Subtitle(); - var fr = CurrentFrameRate; - var format = GetCurrentSubtitleFormat(); - var videoFileName = VideoFileName; - foreach (var p in _subtitle.Paragraphs) - { - var newP = new Paragraph(p); - var original = Utilities.GetOriginalParagraph(_subtitle.GetIndex(p), p, _subtitleAlternate.Paragraphs); - if (original != null) - { - newP.Text = (newP.Text.TrimEnd() + Environment.NewLine + original.Text.TrimStart()).Trim(); - } - - subtitle.Paragraphs.Add(newP); - } - - RemoveAlternate(true, true); - FileNew(); - SetCurrentFormat(format); - toolStripComboBoxFrameRate.Text = fr.ToString(); - _subtitle = subtitle; - _subtitleListViewIndex = -1; - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - if (!string.IsNullOrEmpty(videoFileName)) - { - OpenVideo(videoFileName); - } - e.SuppressKeyPress = true; - } - } - } - else if (e.KeyData == _shortcuts.ToggleVideoDockUndock) - { - if (_isVideoControlsUndocked) - { - RedockVideoControlsToolStripMenuItemClick(null, null); - } - else - { - UndockVideoControlsToolStripMenuItemClick(null, null); - } - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.MainVideoFoucsSetVideoPosition) - { - timeUpDownVideoPositionAdjust.Focus(); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video1FrameLeft) - { - if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv) - { - libMpv.GetPreviousFrame(); - } - else - { - MoveVideoSeconds(-1.0 / Configuration.Settings.General.CurrentFrameRate); - } - - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video1FrameRight) - { - if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv) - { - libMpv.GetNextFrame(); - } - else - { - MoveVideoSeconds(1.0 / Configuration.Settings.General.CurrentFrameRate); - } - - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.Video1FrameLeftWithPlay) - { - if (mediaPlayer.VideoPlayer != null) - { - double startSeconds = mediaPlayer.CurrentPosition - (1.0 / Configuration.Settings.General.CurrentFrameRate); - _endSeconds = startSeconds + (1.0 / Configuration.Settings.General.CurrentFrameRate); - _endSecondsNewPosition = startSeconds; - mediaPlayer.CurrentPosition = startSeconds; - UiUtil.ShowSubtitle(_subtitle, mediaPlayer); - mediaPlayer.Play(); - _endSecondsNewPositionTicks = DateTime.UtcNow.Ticks; - } - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.Video1FrameRightWithPlay) - { - if (mediaPlayer.VideoPlayer != null) - { - double startSeconds = mediaPlayer.CurrentPosition + (1.0 / Configuration.Settings.General.CurrentFrameRate); - _endSeconds = startSeconds + (1.0 / Configuration.Settings.General.CurrentFrameRate); - _endSecondsNewPosition = startSeconds; - mediaPlayer.CurrentPosition = startSeconds; - UiUtil.ShowSubtitle(_subtitle, mediaPlayer); - mediaPlayer.Play(); - _endSecondsNewPositionTicks = DateTime.UtcNow.Ticks; - } - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video100MsLeft) - { - MoveVideoSeconds(-0.1); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video100MsRight) - { - MoveVideoSeconds(0.1); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video500MsLeft) - { - MoveVideoSeconds(-0.5); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video500MsRight) - { - MoveVideoSeconds(0.5); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video1000MsLeft) - { - MoveVideoSeconds(-1.0); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video1000MsRight) - { - MoveVideoSeconds(1.0); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video5000MsLeft) - { - MoveVideoSeconds(-5.0); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video5000MsRight) - { - MoveVideoSeconds(5.0); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.VideoXSMsLeft) - { - ButtonAdjustSecBackClick(null, null); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.VideoXSMsRight) - { - ButtonAdjustSecForwardClick(null, null); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.VideoXLMsLeft) - { - buttonAdjustSecBack2_Click(null, null); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.VideoXLMsRight) - { - buttonAdjustSecForward2_Click(null, null); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainToolsBeamer == e.KeyData) - { - using (var beamer = new Beamer(this, _subtitle, _subtitleListViewIndex)) - { - beamer.ShowDialog(this); - } - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainVideoFullscreen) // fullscreen - { - GoFullscreen(false); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainVideoSlower) - { - e.SuppressKeyPress = true; - for (var index = 0; index < toolStripSplitButtonPlayRate.DropDownItems.Count; index++) - { - var item = (ToolStripMenuItem)toolStripSplitButtonPlayRate.DropDownItems[index]; - if (item.Checked && index > 0) - { - SetPlayRate(toolStripSplitButtonPlayRate.DropDownItems[index - 1], null); - return; - } - } - } - else if (e.KeyData == _shortcuts.MainVideoFaster) - { - e.SuppressKeyPress = true; - for (var index = 0; index < toolStripSplitButtonPlayRate.DropDownItems.Count; index++) - { - var item = (ToolStripMenuItem)toolStripSplitButtonPlayRate.DropDownItems[index]; - if (item.Checked && index + 1 < toolStripSplitButtonPlayRate.DropDownItems.Count) - { - SetPlayRate(toolStripSplitButtonPlayRate.DropDownItems[index + 1], null); - return; - } - } - } - else if (e.KeyData == _shortcuts.MainVideoReset) - { - e.SuppressKeyPress = true; - if (audioVisualizer != null) - { - audioVisualizer.ZoomFactor = 1.0; - audioVisualizer.VerticalZoomFactor = 1.0; - InitializeWaveformZoomDropdown(); - } - - if (mediaPlayer != null && mediaPlayer.VideoPlayer != null) - { - mediaPlayer.VideoPlayer.PlayRate = 1.0; - InitializePlayRateDropDown(); - toolStripSplitButtonPlayRate.Image = imageListPlayRate.Images[0]; - } - } - else if (audioVisualizer.Focused && audioVisualizer.NewSelectionParagraph != null && e.KeyData == _shortcuts.WaveformAddTextAtHere) - { - addParagraphHereToolStripMenuItem_Click(null, null); - e.SuppressKeyPress = true; - } - else if (audioVisualizer.Focused && audioVisualizer.NewSelectionParagraph != null && e.KeyData == _shortcuts.WaveformAddTextAtHereFromClipboard) - { - addParagraphAndPasteToolStripMenuItem_Click(null, null); - e.SuppressKeyPress = true; - } - else if (audioVisualizer.Focused && audioVisualizer.NewSelectionParagraph != null && e.KeyData == _shortcuts.WaveformSetParagraphAsNewSelection) - { - toolStripMenuItemSetParagraphAsSelection_Click(null, null); - e.SuppressKeyPress = true; - } - else if (audioVisualizer.Focused && e.KeyData == _shortcuts.WaveformFocusListView) - { - SubtitleListview1.Focus(); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.VideoGoToPrevSubtitle) - { - GoToPreviousSubtitle(mediaPlayer.CurrentPosition * TimeCode.BaseUnit); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.VideoGoToNextSubtitle) - { - GoToNextSubtitle(mediaPlayer.CurrentPosition * TimeCode.BaseUnit); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.VideoSelectNextSubtitle) - { - var cp = mediaPlayer.CurrentPosition * TimeCode.BaseUnit; - foreach (var p in _subtitle.Paragraphs) - { - if (p.StartTime.TotalMilliseconds > cp) - { - SubtitleListview1.SelectNone(); - SubtitleListview1.Items[_subtitle.Paragraphs.IndexOf(p)].Selected = true; - SubtitleListview1.Items[_subtitle.Paragraphs.IndexOf(p)].Focused = true; - break; - } - } - - e.SuppressKeyPress = true; - } - else if (mediaPlayer.Chapters?.Count > 0 && e.KeyData == _shortcuts.VideoGoToPrevChapter) - { - var cp = mediaPlayer.CurrentPosition - 0.01; - foreach (var chapter in mediaPlayer.Chapters.Reverse()) - { - if (chapter.StartTime < cp) - { - mediaPlayer.CurrentPosition = chapter.StartTime; - break; - } - } - - e.SuppressKeyPress = true; - } - else if (mediaPlayer.Chapters?.Count > 0 && e.KeyData == _shortcuts.VideoGoToNextChapter) - { - var cp = mediaPlayer.CurrentPosition + 0.01; - foreach (var chapter in mediaPlayer.Chapters) - { - if (chapter.StartTime > cp) - { - mediaPlayer.CurrentPosition = chapter.StartTime; - break; - } - } - - e.SuppressKeyPress = true; - } - else if (audioVisualizer.SceneChanges != null && e.KeyData == _shortcuts.WaveformGoToPreviousSceneChange) - { - var cp = mediaPlayer.CurrentPosition - 0.01; - foreach (var sceneChange in audioVisualizer.SceneChanges.Reverse()) - { - if (sceneChange < cp) - { - mediaPlayer.CurrentPosition = sceneChange; - break; - } - } - - e.SuppressKeyPress = true; - } - else if (audioVisualizer.SceneChanges != null && e.KeyData == _shortcuts.WaveformGoToNextSceneChange) - { - var cp = mediaPlayer.CurrentPosition + 0.01; - foreach (var sceneChange in audioVisualizer.SceneChanges) - { - if (sceneChange > cp) - { - mediaPlayer.CurrentPosition = sceneChange; - break; - } - } - - e.SuppressKeyPress = true; - } - else if (audioVisualizer.SceneChanges != null && mediaPlayer.IsPaused && e.KeyData == _shortcuts.WaveformToggleSceneChange) - { - var cp = mediaPlayer.CurrentPosition; - var idx = audioVisualizer.GetSceneChangeIndex(cp); - if (idx >= 0) - { - RemoveSceneChange(idx); - if (audioVisualizer.SceneChanges.Count == 0) - { - SceneChangeHelper.DeleteSceneChanges(VideoFileName); - } - } - else - { // add scene change - var list = audioVisualizer.SceneChanges.Where(p => p > 0).ToList(); - list.Add(cp); - list.Sort(); - audioVisualizer.SceneChanges = list; - SceneChangeHelper.SaveSceneChanges(VideoFileName, list); - } - - e.SuppressKeyPress = true; - } - else if (audioVisualizer.SceneChanges != null && mediaPlayer.IsPaused && e.KeyData == _shortcuts.WaveformGuessStart) - { - AutoGuessStartTime(_subtitleListViewIndex); - e.SuppressKeyPress = true; - } - else if (audioVisualizer.Focused && e.KeyCode == Keys.Delete) - { - ToolStripMenuItemDeleteClick(null, null); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainToolsAutoDuration == e.KeyData) - { - MakeAutoDuration(); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == (Keys.Control | Keys.Alt | Keys.Shift) && e.KeyCode == Keys.I) - { - using (var form = new ImportUnknownFormat(string.Empty)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - if (form.ImportedSubitle?.Paragraphs.Count > 0) - { - _subtitle = form.ImportedSubitle; - _fileName = null; - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SetTitle(); - } - } - } - - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainTextBoxMoveLastWordDown) - { - if (textBoxListViewTextAlternate.Focused) - { - MoveLastWordDown(textBoxListViewTextAlternate); - } - else - { - MoveLastWordDown(textBoxListViewText); - } - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainTextBoxMoveFirstWordFromNextUp) - { - if (textBoxListViewTextAlternate.Focused) - { - MoveFirstWordInNextUp(textBoxListViewTextAlternate); - } - else - { - MoveFirstWordInNextUp(textBoxListViewText); - } - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainTextBoxMoveLastWordDownCurrent) - { - if (textBoxListViewTextAlternate.Focused) - { - MoveWordUpDownInCurrent(true, textBoxListViewTextAlternate); - } - else - { - MoveWordUpDownInCurrent(true, textBoxListViewText); - } - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainTextBoxMoveFirstWordUpCurrent) - { - if (textBoxListViewTextAlternate.Focused) - { - MoveWordUpDownInCurrent(false, textBoxListViewTextAlternate); - } - else - { - MoveWordUpDownInCurrent(false, textBoxListViewText); - } - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAutoCalcCurrentDuration == e.KeyData) - { - e.SuppressKeyPress = true; - if (SubtitleListview1.SelectedItems.Count >= 1) - { - MakeHistoryForUndo(_language.BeforeDisplayTimeAdjustment); - _makeHistoryPaused = true; - var idx = SubtitleListview1.SelectedItems[0].Index; - _subtitle.RecalculateDisplayTime(Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds, idx, Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds); - SetDurationInSeconds(_subtitle.Paragraphs[idx].Duration.TotalSeconds); - _makeHistoryPaused = false; - } - } - else if (e.KeyCode == Keys.F3 && e.Modifiers == Keys.Shift) - { - FindPrevious(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustExtendCurrentSubtitle == e.KeyData) - { - ExtendCurrentSubtitle(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustExtendToNextSubtitle == e.KeyData) - { - ExtendSelectedLinesToNextLine(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustExtendToPreviousSubtitle == e.KeyData) - { - ExtendSelectedLinesToPreviousLine(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustExtendPreviousLineEndToCurrentStart == e.KeyData) - { - ExtendPreviousEndToCurrentStart(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustExtendNextLineStartToCurrentEnd == e.KeyData) - { - ExtendNextStartToCurrentEnd(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustSnapStartToNextSceneChange == e.KeyData) - { - SnapSelectedLinesStartToNextSceneChange(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustSnapStartToNextSceneChangeWithGap == e.KeyData) - { - SnapSelectedLinesStartToNextSceneChange(true); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustSnapEndToPreviousSceneChange == e.KeyData) - { - SnapSelectedLinesEndToPreviousSceneChange(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustSnapEndToPreviousSceneChangeWithGap == e.KeyData) - { - SnapSelectedLinesEndToPreviousSceneChange(true); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustExtendToNextSceneChange == e.KeyData) - { - ExtendSelectedLinesToNextSceneChange(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustExtendToNextSceneChangeWithGap == e.KeyData) - { - ExtendSelectedLinesToNextSceneChange(true); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustExtendToPreviousSceneChange == e.KeyData) - { - ExtendSelectedLinesToPreviousSceneChange(); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustExtendToPreviousSceneChangeWithGap == e.KeyData) - { - ExtendSelectedLinesToPreviousSceneChange(true); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewGoToNextError) - { - GoToNextSyntaxError(); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainWaveformAdd) - { - if (audioVisualizer.WavePeaks == null) - { - AudioWaveform_Click(null, null); - } - e.SuppressKeyPress = true; - } - - - //TABS: Create / adjust / translate - - // create - else if (_shortcuts.MainCreateInsertSubAtVideoPos == e.KeyData) - { - ButtonInsertNewTextClick(null, null); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainCreateInsertSubAtVideoPosNoTextBoxFocus == e.KeyData) - { - var p = InsertNewTextAtVideoPosition(); - p.Text = string.Empty; - SubtitleListview1.SetText(_subtitle.GetIndex(p), p.Text); - textBoxListViewText.Text = p.Text; - e.SuppressKeyPress = true; - } - else if (tabControlButtons.SelectedTab == tabPageCreate && e.Modifiers == Keys.Alt && e.KeyCode == Keys.F9) - { - StopAutoDuration(); - ButtonSetEndClick(null, null); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainCreateSetStart == e.KeyData) - { - buttonSetStartTime_Click(null, null); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainCreateSetEnd == e.KeyData) - { - StopAutoDuration(); - ButtonSetEndClick(null, null); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustSetEndAndPause == e.KeyData) - { - StopAutoDuration(); - mediaPlayer.Pause(); - ButtonSetEndClick(null, null); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainCreateSetEndAddNewAndGoToNew == e.KeyData) - { - StopAutoDuration(); - e.SuppressKeyPress = true; - - if (SubtitleListview1.SelectedItems.Count == 1) - { - double videoPosition = mediaPlayer.CurrentPosition; - if (!mediaPlayer.IsPaused) - { - videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; - } - - int index = SubtitleListview1.SelectedItems[0].Index; - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + _subtitle.Paragraphs[index].Number + " " + _subtitle.Paragraphs[index].Text)); - - var p = _subtitle.Paragraphs[index]; - p.EndTime = TimeCode.FromSeconds(videoPosition); - if (p.Duration.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds) - { - var newEndTime = new TimeCode(p.EndTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines); - double charactersPerSecond = Utilities.GetCharactersPerSecond(new Paragraph(p) { EndTime = newEndTime }); - if (charactersPerSecond <= Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds) - { - p.EndTime = newEndTime; - } - } - - SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds); - ButtonInsertNewTextClick(null, null); - } - } - else if (_shortcuts.MainCreateStartDownEndUp == e.KeyData) - { - if (_mainCreateStartDownEndUpParagraph == null) - { - _mainCreateStartDownEndUpParagraph = InsertNewTextAtVideoPosition(); - } - - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustSelected100MsForward == e.KeyData) - { - ShowEarlierOrLater(100, SelectionChoice.SelectionOnly); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustSelected100MsBack == e.KeyData) - { - ShowEarlierOrLater(-100, SelectionChoice.SelectionOnly); - e.SuppressKeyPress = true; - } - - - // adjust - else if (_shortcuts.MainAdjustSelected100MsForward == e.KeyData) - { - ShowEarlierOrLater(100, SelectionChoice.SelectionOnly); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustSelected100MsBack == e.KeyData) - { - ShowEarlierOrLater(-100, SelectionChoice.SelectionOnly); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustAdjustStartXMsBack == e.KeyData) - { - MoveStartCurrent(-Configuration.Settings.Tools.MoveStartEndMs, false); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustAdjustStartXMsForward == e.KeyData) - { - MoveStartCurrent(Configuration.Settings.Tools.MoveStartEndMs, false); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustAdjustEndXMsBack == e.KeyData) - { - MoveEndCurrent(-Configuration.Settings.Tools.MoveStartEndMs, false); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustAdjustEndXMsForward == e.KeyData) - { - MoveEndCurrent(Configuration.Settings.Tools.MoveStartEndMs, false); - e.SuppressKeyPress = true; - } - - else if (_shortcuts.MainAdjustMoveStartOneFrameBack == e.KeyData) - { - MoveStartCurrent(-(int)Math.Round(1000.0 / CurrentFrameRate), false); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustMoveStartOneFrameForward == e.KeyData) - { - MoveStartCurrent((int)Math.Round(1000.0 / CurrentFrameRate), false); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustMoveEndOneFrameBack == e.KeyData) - { - MoveEndCurrent(-(int)Math.Round(1000.0 / CurrentFrameRate), false); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustMoveEndOneFrameForward == e.KeyData) - { - MoveEndCurrent((int)Math.Round(1000.0 / CurrentFrameRate), false); - e.SuppressKeyPress = true; - } - - else if (_shortcuts.MainAdjustMoveStartOneFrameBackKeepGapPrev == e.KeyData) - { - MoveStartCurrent(-(int)Math.Round(1000.0 / CurrentFrameRate), true); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustMoveStartOneFrameForwardKeepGapPrev == e.KeyData) - { - MoveStartCurrent((int)Math.Round(1000.0 / CurrentFrameRate), true); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustMoveEndOneFrameBackKeepGapNext == e.KeyData) - { - MoveEndCurrent(-(int)Math.Round(1000.0 / CurrentFrameRate), true); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainAdjustMoveEndOneFrameForwardKeepGapNext == e.KeyData) - { - MoveEndCurrent((int)Math.Round(1000.0 / CurrentFrameRate), true); - e.SuppressKeyPress = true; - } - - else if (mediaPlayer.VideoPlayer != null && (_shortcuts.MainAdjustSetStartAndOffsetTheRest == e.KeyData || _shortcuts.MainAdjustSetStartAndOffsetTheRest2 == e.KeyData)) - { - ButtonSetStartAndOffsetRestClick(null, null); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetEndAndOffsetTheRest == e.KeyData) - { - SetEndAndOffsetTheRest(false); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetEndAndOffsetTheRestAndGoToNext == e.KeyData) - { - SetEndAndOffsetTheRest(true); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetEndAndGotoNext == e.KeyData) - { - ShowNextSubtitleLabel(); - ButtonSetEndAndGoToNextClick(null, null); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetStartKeepDuration == e.KeyData) - { - SetStartTime(true, mediaPlayer.CurrentPosition); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustInsertViaEndAutoStart == e.KeyData) - { - SetCurrentViaEndPositionAndGotoNext(FirstSelectedIndex, false); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustInsertViaEndAutoStartAndGoToNext == e.KeyData) - { - ShowNextSubtitleLabel(); - SetCurrentViaEndPositionAndGotoNext(FirstSelectedIndex, true); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetStartAutoDurationAndGoToNext == e.KeyData) - { - SetCurrentStartAutoDurationAndGotoNext(FirstSelectedIndex); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetEndNextStartAndGoToNext == e.KeyData) - { - ShowNextSubtitleLabel(); - SetCurrentEndNextStartAndGoToNext(FirstSelectedIndex); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustStartDownEndUpAndGoToNext == e.KeyData && _mainAdjustStartDownEndUpAndGoToNextParagraph == null) - { - ShowNextSubtitleLabel(); - _mainAdjustStartDownEndUpAndGoToNextParagraph = _subtitle.GetParagraphOrDefault(FirstSelectedIndex); - SetStartTime(true, mediaPlayer.CurrentPosition); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetStartAndEndOfPrevious == e.KeyData) - { - var pos = mediaPlayer.CurrentPosition; - SetStartAndEndOfPrevious(pos, false); - e.SuppressKeyPress = true; - } - else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetStartAndEndOfPreviousAndGoToNext == e.KeyData) - { - var pos = mediaPlayer.CurrentPosition; - SetStartAndEndOfPrevious(pos, true); - e.SuppressKeyPress = true; - } - - // translate - else if (_shortcuts.MainTranslateGoogleIt == e.KeyData) - { - e.SuppressKeyPress = true; - buttonGoogleIt_Click(null, null); - } - else if (_shortcuts.MainTranslateCustomSearch1 == e.KeyData) - { - e.SuppressKeyPress = true; - RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl1); - } - else if (_shortcuts.MainTranslateCustomSearch2 == e.KeyData) - { - e.SuppressKeyPress = true; - RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl2); - } - else if (_shortcuts.MainTranslateCustomSearch3 == e.KeyData) - { - e.SuppressKeyPress = true; - RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl3); - } - else if (_shortcuts.MainTranslateCustomSearch4 == e.KeyData) - { - e.SuppressKeyPress = true; - RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl4); - } - else if (_shortcuts.MainTranslateCustomSearch5 == e.KeyData) - { - e.SuppressKeyPress = true; - RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl5); - } - // put new entries above tabs - } - - private void SetStartAndEndOfPrevious(double positionInSeconds, bool goToNext) - { - int index = SubtitleListview1.SelectedItems[0].Index; - var current = _subtitle.GetParagraphOrDefault(index); - if (SubtitleListview1.SelectedItems.Count != 1 || current == null) - { - return; - } - - if (positionInSeconds > current.EndTime.TotalSeconds - Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds / 1000) - { - return; - } - - // previous sub - var p = _subtitle.GetParagraphOrDefault(index - 1); - if (p == null || p.StartTime.TotalMilliseconds < p.StartTime.TotalMilliseconds - 9000) - { - SetStartTime(false, mediaPlayer.CurrentPosition); - return; - } - - if (positionInSeconds < p.StartTime.TotalSeconds + Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds / 1000) - { - return; - } - - SetStartTime(false, mediaPlayer.CurrentPosition); - - var oldParagraph = new Paragraph(p, false); - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + p.Number + " " + p.Text)); - p.EndTime.TotalMilliseconds = positionInSeconds * TimeCode.BaseUnit - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - if (oldParagraph.StartTime.IsMaxTime) - { - p.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds - Utilities.GetOptimalDisplayMilliseconds(p.Text); - } - - SubtitleListview1.SetStartTimeAndDuration(index, current, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - SubtitleListview1.SetStartTimeAndDuration(index - 1, p, current, _subtitle.GetParagraphOrDefault(index - 2)); - UpdateOriginalTimeCodes(oldParagraph); - ShowSource(); - - var next = _subtitle.GetParagraphOrDefault(index - 1); - if (goToNext && next != null) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true); - } - } - - private void ExtendCurrentSubtitle() - { - if (SubtitleListview1.SelectedItems.Count == 1) - { - var historyAdded = false; - var idx = SubtitleListview1.SelectedItems[0].Index; - var p = _subtitle.Paragraphs[idx]; - var next = _subtitle.GetParagraphOrDefault(idx + 1); - if (next == null || next.StartTime.TotalMilliseconds > p.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle)); - historyAdded = true; - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds; - } - else - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle)); - historyAdded = true; - p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - var originalNext = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) + 1); - if (originalNext == null || originalNext.StartTime.TotalMilliseconds > original.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines) - { - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle)); - } - - original.EndTime.TotalMilliseconds = original.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds; - } - else - { - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle)); - } - - original.EndTime.TotalMilliseconds = originalNext.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - - RefreshSelectedParagraph(); - } - } - - private void ExtendSelectedLinesToNextLine() - { - var historyAdded = false; - foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems) - { - var idx = selectedItem.Index; - var p = _subtitle.Paragraphs[idx]; - var next = _subtitle.GetParagraphOrDefault(idx + 1); - if (next != null) - { - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToNextSubtitle)); - historyAdded = true; - } - p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - var originalNext = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) + 1); - if (originalNext != null) - { - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToNextSubtitle)); - historyAdded = true; - } - - original.EndTime.TotalMilliseconds = originalNext.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - - RefreshSelectedParagraphs(); - } - } - - private void ExtendSelectedLinesToPreviousLine() - { - var historyAdded = false; - foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems) - { - var idx = selectedItem.Index; - var p = _subtitle.Paragraphs[idx]; - var previous = _subtitle.GetParagraphOrDefault(idx - 1); - if (previous != null) - { - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - var originalPrevious = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) - 1); - if (originalPrevious != null) - { - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToPreviousSubtitle)); - historyAdded = true; - } - - original.StartTime.TotalMilliseconds = originalPrevious.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToPreviousSubtitle)); - historyAdded = true; - } - - p.StartTime.TotalMilliseconds = previous.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - - RefreshSelectedParagraphs(); - } - } - - private void ExtendPreviousEndToCurrentStart() - { - if (SubtitleListview1.SelectedItems.Count == 1) - { - var historyAdded = false; - var idx = SubtitleListview1.SelectedItems[0].Index; - var p = _subtitle.Paragraphs[idx]; - var previous = _subtitle.GetParagraphOrDefault(idx - 1); - if (previous != null) - { - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendPreviousLineEndToCurrentStart)); - historyAdded = true; - } - previous.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - var originalPrevious = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) - 1); - if (originalPrevious != null) - { - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendPreviousLineEndToCurrentStart)); - historyAdded = true; - } - - originalPrevious.EndTime.TotalMilliseconds = original.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - - SubtitleListview1.SetStartTimeAndDuration(idx - 1, previous, _subtitle.GetParagraphOrDefault(idx), _subtitle.GetParagraphOrDefault(idx - 2)); - } - } - - private void ExtendNextStartToCurrentEnd() - { - if (SubtitleListview1.SelectedItems.Count == 1) - { - var historyAdded = false; - var idx = SubtitleListview1.SelectedItems[0].Index; - var p = _subtitle.Paragraphs[idx]; - var next = _subtitle.GetParagraphOrDefault(idx + 1); - if (next != null) - { - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendNextLineStartToCurrentEnd)); - historyAdded = true; - } - next.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - var originalNext = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) + 1); - if (originalNext != null) - { - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendNextLineStartToCurrentEnd)); - historyAdded = true; - } - - originalNext.StartTime.TotalMilliseconds = original.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - - SubtitleListview1.SetStartTimeAndDuration(idx + 1, next, _subtitle.GetParagraphOrDefault(idx + 2), _subtitle.GetParagraphOrDefault(idx)); - } - } - - private void SnapSelectedLinesStartToNextSceneChange(bool withGap = false) - { - var historyAdded = false; - foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems) - { - var idx = selectedItem.Index; - var p = _subtitle.Paragraphs[idx]; - List nextSceneChanges = audioVisualizer.SceneChanges.Count > 0 ? audioVisualizer.SceneChanges.Where(x => x > p.StartTime.TotalSeconds + 0.01).ToList() : new List(); - if (nextSceneChanges.Count > 0) - { - double nearestSceneChange = nextSceneChanges.Aggregate((x, y) => Math.Abs(x - p.StartTime.TotalSeconds) < Math.Abs(y - p.StartTime.TotalSeconds) ? x : y); - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustSnapStartToNextSceneChange)); - historyAdded = true; - } - - if (!withGap) - { - if (nearestSceneChange * 1000 < p.EndTime.TotalMilliseconds) - { - original.StartTime.TotalMilliseconds = nearestSceneChange * 1000; - } - } - else - { - if (nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines < p.EndTime.TotalMilliseconds) - { - original.StartTime.TotalMilliseconds = nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - - } - } - } - } - - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustSnapStartToNextSceneChange)); - historyAdded = true; - } - - if (!withGap) - { - if (nearestSceneChange * 1000 < p.EndTime.TotalMilliseconds) - { - p.StartTime.TotalMilliseconds = nearestSceneChange * 1000; - } - } - else - { - if (nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines < p.EndTime.TotalMilliseconds) - { - p.StartTime.TotalMilliseconds = nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - } - - RefreshSelectedParagraphs(); - } - } - - private void SnapSelectedLinesEndToPreviousSceneChange(bool withGap = false) - { - var historyAdded = false; - foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems) - { - var idx = selectedItem.Index; - var p = _subtitle.Paragraphs[idx]; - List previousSceneChanges = audioVisualizer.SceneChanges.Count > 0 ? audioVisualizer.SceneChanges.Where(x => x < p.EndTime.TotalSeconds + 0.01).ToList() : new List(); - if (previousSceneChanges.Count > 0) - { - double nearestSceneChange = previousSceneChanges.Aggregate((x, y) => Math.Abs(x - p.EndTime.TotalSeconds) < Math.Abs(y - p.EndTime.TotalSeconds) ? x : y); - - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustSnapEndToPreviousSceneChange)); - historyAdded = true; - } - - if (!withGap) - { - if (nearestSceneChange * 1000 > p.StartTime.TotalMilliseconds) - { - p.EndTime.TotalMilliseconds = nearestSceneChange * 1000; - } - } - else - { - if (nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines > p.StartTime.TotalMilliseconds) - { - p.EndTime.TotalMilliseconds = nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustSnapEndToPreviousSceneChange)); - historyAdded = true; - } - - if (!withGap) - { - if (nearestSceneChange * 1000 > p.StartTime.TotalMilliseconds) - { - original.EndTime.TotalMilliseconds = nearestSceneChange * 1000; - } - } - else - { - if (nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines > p.StartTime.TotalMilliseconds) - { - original.EndTime.TotalMilliseconds = nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - - } - } - } - } - } - - RefreshSelectedParagraphs(); - } - } - - private void ExtendSelectedLinesToNextSceneChange(bool withGap = false) - { - var historyAdded = false; - foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems) - { - var idx = selectedItem.Index; - var p = _subtitle.Paragraphs[idx]; - List nextSceneChanges = audioVisualizer.SceneChanges.Count > 0 ? audioVisualizer.SceneChanges.Where(x => x > p.EndTime.TotalSeconds + 0.01).ToList() : new List(); - if (nextSceneChanges.Count > 0) - { - var next = _subtitle.GetParagraphOrDefault(idx + 1); - double nearestSceneChange = nextSceneChanges.Aggregate((x, y) => Math.Abs(x - p.EndTime.TotalSeconds) < Math.Abs(y - p.EndTime.TotalSeconds) ? x : y); - double nearestStartTimeWithGap = next != null ? next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines : Double.MaxValue; - - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToNextSceneChange)); - historyAdded = true; - } - - if (!withGap) - { - p.EndTime.TotalMilliseconds = Math.Min(nearestSceneChange * 1000, nearestStartTimeWithGap); - } - else - { - p.EndTime.TotalMilliseconds = Math.Min(nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines, nearestStartTimeWithGap); - } - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - var originalNext = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) + 1); - double nearestOriginalStartTimeWithGap = originalNext != null ? originalNext.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines : Double.MaxValue; - - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToNextSceneChange)); - historyAdded = true; - } - - if (!withGap) - { - original.EndTime.TotalMilliseconds = Math.Min(nearestSceneChange * 1000, nearestOriginalStartTimeWithGap); - - } - else - { - original.EndTime.TotalMilliseconds = Math.Min(nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines, nearestStartTimeWithGap); - } - } - } - } - - RefreshSelectedParagraphs(); - } - } - - private void ExtendSelectedLinesToPreviousSceneChange(bool withGap = false) - { - var historyAdded = false; - foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems) - { - var idx = selectedItem.Index; - var p = _subtitle.Paragraphs[idx]; - List previousSceneChanges = audioVisualizer.SceneChanges.Count > 0 ? audioVisualizer.SceneChanges.Where(x => x < p.StartTime.TotalSeconds - 0.01).ToList() : new List(); - if (previousSceneChanges.Count > 0) - { - var previous = _subtitle.GetParagraphOrDefault(idx - 1); - double nearestSceneChange = previousSceneChanges.Aggregate((x, y) => Math.Abs(x - p.StartTime.TotalSeconds) < Math.Abs(y - p.StartTime.TotalSeconds) ? x : y); - double nearestEndTimeWithGap = previous != null ? previous.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines : -9999; - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - var originalPrevious = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) - 1); - double nearestOriginalEndTimeWithGap = originalPrevious != null ? originalPrevious.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines : -9999; - - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToPreviousSceneChange)); - historyAdded = true; - } - - if (!withGap) - { - original.StartTime.TotalMilliseconds = Math.Max(nearestSceneChange * 1000, nearestOriginalEndTimeWithGap); - } - else - { - original.StartTime.TotalMilliseconds = Math.Max(nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines, nearestOriginalEndTimeWithGap); - } - } - } - - if (!historyAdded) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToPreviousSceneChange)); - historyAdded = true; - } - - if (!withGap) - { - p.StartTime.TotalMilliseconds = Math.Max(nearestSceneChange * 1000, nearestEndTimeWithGap); - } - else - { - p.StartTime.TotalMilliseconds = Math.Max(nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines, nearestEndTimeWithGap); - } - } - - RefreshSelectedParagraphs(); - } - } - - private void GoToPreviousSubtitle(double currentPosition) - { - var found = false; - foreach (var p in _subtitle.Paragraphs) - { - if (p.StartTime.TotalMilliseconds > currentPosition - 1) - { - var prev = _subtitle.GetParagraphOrDefault(_subtitle.Paragraphs.IndexOf(p) - 1); - if (prev == null) - { - break; - } - - mediaPlayer.CurrentPosition = prev.StartTime.TotalSeconds; - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.Paragraphs.IndexOf(prev), true); - if (audioVisualizer.WavePeaks != null && p.StartTime.TotalSeconds > audioVisualizer.EndPositionSeconds + 0.2) - { - audioVisualizer.StartPositionSeconds = mediaPlayer.CurrentPosition - 0.2; - } - found = true; - break; - } - } - if (!found && _subtitle.Paragraphs.Count > 0 && _subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1].StartTime.TotalMilliseconds < currentPosition) - { - var p = _subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1]; - mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.Paragraphs.Count - 1, true); - if (audioVisualizer.WavePeaks != null && p.StartTime.TotalSeconds > audioVisualizer.EndPositionSeconds + 0.2) - { - audioVisualizer.StartPositionSeconds = mediaPlayer.CurrentPosition - 0.2; - } - } - } - - private void GoToNextSubtitle(double currentPosition) - { - foreach (var p in _subtitle.Paragraphs) - { - if (p.StartTime.TotalMilliseconds > currentPosition) - { - mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.Paragraphs.IndexOf(p), true); - if (audioVisualizer.WavePeaks != null && p.StartTime.TotalSeconds > audioVisualizer.EndPositionSeconds + 0.2) - { - audioVisualizer.StartPositionSeconds = mediaPlayer.CurrentPosition - 0.2; - } - - break; - } - } - } - - private void AutoGuessStartTime(int index) - { - var p = _subtitle.GetParagraphOrDefault(index); - if (p == null) - { - return; - } - - var silenceLengthInSeconds = 0.08; - var lowPercent = audioVisualizer.FindLowPercentage(p.StartTime.TotalSeconds - 0.3, p.StartTime.TotalSeconds + 0.1); - var highPercent = audioVisualizer.FindHighPercentage(p.StartTime.TotalSeconds - 0.3, p.StartTime.TotalSeconds + 0.4); - var add = 5.0; - if (highPercent > 40) - { - add = 8; - } - else if (highPercent < 5) - { - add = highPercent - lowPercent - 0.3; - } - for (var startVolume = lowPercent + add; startVolume < 14; startVolume += 0.3) - { - var pos = audioVisualizer.FindDataBelowThresholdBackForStart(startVolume, silenceLengthInSeconds, p.StartTime.TotalSeconds); - var pos2 = audioVisualizer.FindDataBelowThresholdBackForStart(startVolume + 0.3, silenceLengthInSeconds, p.StartTime.TotalSeconds); - if (pos >= 0 && pos > p.StartTime.TotalSeconds - 1) - { - if (pos2 > pos && pos2 >= 0 && pos2 > p.StartTime.TotalSeconds - 1) - { - pos = pos2; - } - - var newStartTimeMs = pos * TimeCode.BaseUnit; - var prev = _subtitle.GetParagraphOrDefault(index - 1); - if (prev != null && prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines >= newStartTimeMs) - { - newStartTimeMs = prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - if (newStartTimeMs >= p.StartTime.TotalMilliseconds) - { - break; // cannot move start time - } - } - - // check for scene changes - if (audioVisualizer.SceneChanges != null) - { - var matchingSceneChanges = audioVisualizer.SceneChanges - .Where(sc => sc > p.StartTime.TotalSeconds - 0.3 && sc < p.StartTime.TotalSeconds + 0.2) - .OrderBy(sc => Math.Abs(sc - p.StartTime.TotalSeconds)); - if (matchingSceneChanges.Count() > 0) - { - newStartTimeMs = matchingSceneChanges.First() * TimeCode.BaseUnit; - } - } - - if (Math.Abs(p.StartTime.TotalMilliseconds - newStartTimeMs) < 10) - { - break; // diff too small - } - - var newEndTimeMs = p.EndTime.TotalMilliseconds; - if (newStartTimeMs > p.StartTime.TotalMilliseconds) - { - var temp = new Paragraph(p); - temp.StartTime.TotalMilliseconds = newStartTimeMs; - if (temp.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds || - Utilities.GetCharactersPerSecond(temp) > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds) - { - var next = _subtitle.GetParagraphOrDefault(index + 1); - if (next == null || - next.StartTime.TotalMilliseconds > newStartTimeMs + p.Duration.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines) - { - newEndTimeMs = newStartTimeMs + p.Duration.TotalMilliseconds; - } - } - } - - MakeHistoryForUndo(string.Format(Configuration.Settings.Language.Main.BeforeX, Configuration.Settings.Language.Settings.WaveformGuessStart)); - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - original.StartTime.TotalMilliseconds = newStartTimeMs; - original.EndTime.TotalMilliseconds = newEndTimeMs; - } - } - - p.StartTime.TotalMilliseconds = newStartTimeMs; - p.EndTime.TotalMilliseconds = newEndTimeMs; - RefreshSelectedParagraph(); - SubtitleListview1.SetStartTimeAndDuration(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - break; - } - } - } - - private void GoToBookmark() - { - using (var form = new BookmarksGoTo(_subtitle)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - SubtitleListview1.SelectIndexAndEnsureVisible(form.BookmarkIndex, true); - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.VideoPlayer.CurrentPosition = _subtitle.Paragraphs[form.BookmarkIndex].StartTime.TotalSeconds; - } - } - } - } - - private void GoToPrevoiusBookmark() - { - int idx = FirstSelectedIndex - 1; - try - { - for (int i = idx; i >= 0; i--) - { - var p = _subtitle.Paragraphs[i]; - if (p.Bookmark != null) - { - SubtitleListview1.SelectIndexAndEnsureVisible(i, true); - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.VideoPlayer.CurrentPosition = _subtitle.Paragraphs[i].StartTime.TotalSeconds; - } - - return; - } - } - } - catch - { - } - } - - private void GoToNextBookmark() - { - int idx = FirstSelectedIndex + 1; - try - { - for (int i = idx; i < _subtitle.Paragraphs.Count; i++) - { - var p = _subtitle.Paragraphs[i]; - if (p.Bookmark != null) - { - SubtitleListview1.SelectIndexAndEnsureVisible(i, true); - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.VideoPlayer.CurrentPosition = _subtitle.Paragraphs[i].StartTime.TotalSeconds; - } - - return; - } - } - } - catch - { - } - } - - private void ToggleBookmarks(bool setText) - { - bool first = true; - string newValue = null; - if (setText) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.ToggleBookmarksWithComment)); - } - else - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.ToggleBookmarks)); - } - - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.Paragraphs[index]; - if (first) - { - if (p.Bookmark == null) - { - if (setText) - { - using (var form = new BookmarkAdd(p)) - { - var result = form.ShowDialog(this); - if (result != DialogResult.OK) - { - return; - } - - newValue = form.Comment; - } - } - else - { - newValue = string.Empty; - } - } - else - { - newValue = null; - } - - first = false; - } - - p.Bookmark = newValue; - SubtitleListview1.ShowState(index, p); - ShowHideBookmark(p); - } - - SetListViewStateImages(); - new BookmarkPersistence(_subtitle, _fileName).Save(); - } - - private void SetListViewStateImages() - { - var oldStaeImageList = SubtitleListview1.StateImageList; - SubtitleListview1.StateImageList = _subtitle != null && _subtitle.Paragraphs.Any(p => p.Bookmark != null) ? imageListBookmarks : null; - if (SubtitleListview1.StateImageList == null) - { - SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Text = Configuration.Settings.Language.General.NumberSymbol; - } - else - { - SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Text = " " + Configuration.Settings.Language.General.NumberSymbol; - } - - if (oldStaeImageList == SubtitleListview1.StateImageList) - { - return; - } - - if (!_loading) - { - if (SubtitleListview1.StateImageList == null) - { - SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Width = Configuration.Settings.General.ListViewNumberWidth - 18; - } - else - { - SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Width = Configuration.Settings.General.ListViewNumberWidth + 18; - } - } - - SubtitleListview1.SubtitleListViewLastColumnFill(null, null); - } - - private void ClearBookmarks() - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.ClearBookmarks)); - for (var index = 0; index < _subtitle.Paragraphs.Count; index++) - { - var paragraph = _subtitle.Paragraphs[index]; - if (paragraph.Bookmark != null) - { - paragraph.Bookmark = null; - SubtitleListview1.ShowState(index, paragraph); - } - } - - var p = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex); - if (p != null) - { - ShowHideBookmark(p); - } - - SetListViewStateImages(); - new BookmarkPersistence(_subtitle, _fileName).Save(); - } - - private void MoveWordUpDownInCurrent(bool down, SETextBox tb) - { - int firstIndex = FirstSelectedIndex; - if (firstIndex < 0) - { - return; - } - - var p = _subtitle.GetParagraphOrDefault(firstIndex); - if (tb == textBoxListViewTextAlternate) - { - p = Utilities.GetOriginalParagraph(firstIndex, p, _subtitleAlternate.Paragraphs); - } - - if (p == null) - { - return; - } - - var lines = p.Text.SplitToLines(); - if (lines.Count == 1) - { - lines.Add(string.Empty); - } - - if (lines.Count != 2) - { - return; - } - - var line1Words = lines[0].Split(' ').ToList(); - var line2Words = lines[1].Split(' ').ToList(); - if (down) - { - if (line1Words.Count > 0) - { - line2Words.Insert(0, line1Words[line1Words.Count - 1]); - line1Words.RemoveAt(line1Words.Count - 1); - } - } - else // up - { - if (line2Words.Count > 0) - { - line1Words.Add(line2Words[0]); - line2Words.RemoveAt(0); - } - } - - var newText = (string.Join(" ", line1Words.ToArray()).Trim() + Environment.NewLine + - string.Join(" ", line2Words.ToArray()).Trim()).Trim(); - if (newText != p.Text) - { - var oldText = p.Text; - MakeHistoryForUndo(_language.BeforeLineUpdatedInListView); - var textCaretPos = textBoxListViewText.SelectionStart; - p.Text = newText; - if (tb == textBoxListViewTextAlternate) - { - SubtitleListview1.SetAlternateText(firstIndex, p.Text); - } - else - { - SubtitleListview1.SetText(firstIndex, p.Text); - } - tb.Text = p.Text; - - // keep cursor position - KeepCursorMoveWordUpdown(down, newText, oldText, textCaretPos); - } - } - - private void KeepCursorMoveWordUpdown(bool down, string newText, string oldText, int textCaretPos) - { - if (textCaretPos > textBoxListViewText.Text.Length) - { - // set cursor at end of textbox - textBoxListViewText.SelectionStart = textCaretPos; - int end = textBoxListViewText.Text.Length; - textBoxListViewText.SelectionStart = end; - textBoxListViewText.SelectionLength = 0; - return; - } - - int indexOfNewLine = newText.IndexOf(Environment.NewLine, StringComparison.Ordinal); - int oldIndexOfNewLine = oldText.IndexOf(Environment.NewLine, StringComparison.Ordinal); - - if (down) - { - if (indexOfNewLine == -1 && oldIndexOfNewLine > 0 && textCaretPos > oldIndexOfNewLine) - { - textCaretPos--; - } - else if (textCaretPos > indexOfNewLine && textCaretPos > oldIndexOfNewLine && oldIndexOfNewLine >= 0 || - textCaretPos < indexOfNewLine && (oldIndexOfNewLine == -1 || textCaretPos < oldIndexOfNewLine) || - textCaretPos < oldIndexOfNewLine && indexOfNewLine == -1) - { - } - else - { - textCaretPos++; - } - } - else // up - { - if (textCaretPos <= oldIndexOfNewLine || textCaretPos > oldIndexOfNewLine && textCaretPos > indexOfNewLine && indexOfNewLine >= 0) - { - } - else - { - textCaretPos--; - } - } - - if (textBoxListViewText.Text.Length > textCaretPos && '\n' == textBoxListViewText.Text[textCaretPos]) - { - textCaretPos--; - } - - if (textCaretPos >= 0) - { - textBoxListViewText.SelectionStart = textCaretPos; - textBoxListViewText.SelectionStart = textCaretPos; - textBoxListViewText.SelectionStart = textCaretPos; - } - } - - private void MoveStartCurrent(int ms, bool keepGapPrevIfClose) - { - var i = _subtitleListViewIndex; - if (i < 0 || i >= _subtitle.Paragraphs.Count || ms == 0) - { - return; - } - - var p = _subtitle.GetParagraphOrDefault(i); - if (p == null) - { - return; - } - - // snap to scene change - if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && audioVisualizer?.SceneChanges?.Count > 0) - { - var seconds = (p.StartTime.TotalMilliseconds + ms) / 1000.0; - var closest = audioVisualizer.SceneChanges.OrderBy(sc => Math.Abs(seconds - sc)).First() * 1000.0; - if (Math.Abs(p.StartTime.TotalMilliseconds + ms - closest) < CurrentFrameRate * 0.9) - { - ms = (int)Math.Round(closest - p.StartTime.TotalMilliseconds); - } - } - - var prevGap = 0.0; - var prev = _subtitle.GetParagraphOrDefault(i - 1); - if (keepGapPrevIfClose && prev != null) - { - if (prev.EndTime.TotalMilliseconds <= p.StartTime.TotalMilliseconds && prev.EndTime.TotalMilliseconds + 200 >= p.StartTime.TotalMilliseconds) - { - prevGap = p.StartTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds; - if (ms < 0 && prev.Duration.TotalMilliseconds + ms < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds) - { - return; - } - } - else - { - prev = null; - } - } - - if (ms > 0) - { - if (p.StartTime.TotalMilliseconds + ms + Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds > p.EndTime.TotalMilliseconds) - { - return; // do not allow duration smaller than min duration in ms - } - - p.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + ms; - } - else - { - if (p.Duration.TotalMilliseconds + Math.Abs(ms) > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) - { - return; - } - - if (p.StartTime.TotalMilliseconds + ms < 0) - { - return; - } - - if (keepGapPrevIfClose || prev == null || p.StartTime.TotalMilliseconds - (Math.Abs(ms) + Configuration.Settings.General.MinimumMillisecondsBetweenLines) > prev.EndTime.TotalMilliseconds) - { - p.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + ms; - } - else - { - var newStartMs = prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - if (newStartMs < p.StartTime.TotalMilliseconds) - { - p.StartTime.TotalMilliseconds = newStartMs; - } - } - } - - SubtitleListview1.SetStartTimeAndDuration(i, p, _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1)); - timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; - timeUpDownStartTime.TimeCode = p.StartTime; - timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; - SetDurationInSeconds(p.Duration.TotalSeconds); - - if (keepGapPrevIfClose && prev != null) - { - prev.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds - prevGap; - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(_subtitle.GetIndex(prev), prev, _subtitleAlternate.Paragraphs); - if (original != null) - { - original.EndTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds; - } - } - SubtitleListview1.SetStartTimeAndDuration(i - 1, prev, p, _subtitle.GetParagraphOrDefault(i - 2)); - } - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(_subtitle.GetIndex(p), p, _subtitleAlternate.Paragraphs); - if (original != null) - { - original.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds; - original.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds; - } - } - - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, i, p); - } - - private void MoveEndCurrent(int ms, bool keepGapNextIfClose) - { - var i = _subtitleListViewIndex; - if (i < 0 || i >= _subtitle.Paragraphs.Count || ms == 0) - { - return; - } - - var p = _subtitle.GetParagraphOrDefault(i); - if (p == null) - { - return; - } - - // snap to scene change - if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && audioVisualizer?.SceneChanges?.Count > 0) - { - var seconds = (p.EndTime.TotalMilliseconds + ms) / 1000.0; - var closest = audioVisualizer.SceneChanges.OrderBy(sc => Math.Abs(seconds - sc)).First() * 1000.0; - if (Math.Abs(p.EndTime.TotalMilliseconds + ms - closest) < CurrentFrameRate * 0.9) - { - ms = (int)Math.Round(closest - p.EndTime.TotalMilliseconds); - } - } - - var nextGap = 0.0; - var next = _subtitle.GetParagraphOrDefault(i + 1); - if (keepGapNextIfClose && next != null) - { - if (next.StartTime.TotalMilliseconds >= p.EndTime.TotalMilliseconds && next.StartTime.TotalMilliseconds - 200 < p.EndTime.TotalMilliseconds) - { - nextGap = next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds; - if (ms > 0 && next.Duration.TotalMilliseconds + ms < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds) - { - return; - } - } - else - { - next = null; - } - } - - if (ms > 0) - { - if (p.Duration.TotalMilliseconds + ms > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) - { - return; - } - - if (keepGapNextIfClose || next == null || p.EndTime.TotalMilliseconds + ms + Configuration.Settings.General.MinimumMillisecondsBetweenLines < next.StartTime.TotalMilliseconds) - { - p.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds + ms; - } - else - { - var newEndMs = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - if (newEndMs > p.EndTime.TotalMilliseconds) - { - p.EndTime.TotalMilliseconds = newEndMs; - } - } - } - else - { - if (p.EndTime.TotalMilliseconds + ms - Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds < p.StartTime.TotalMilliseconds) - { - return; // do not allow duration smaller than min duration in ms - } - - p.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds + ms; - } - - SubtitleListview1.SetStartTimeAndDuration(i, p, _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1)); - timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; - timeUpDownStartTime.TimeCode = p.StartTime; - timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; - SetDurationInSeconds(p.Duration.TotalSeconds); - - if (keepGapNextIfClose && next != null) - { - next.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds + nextGap; - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(_subtitle.GetIndex(next), next, _subtitleAlternate.Paragraphs); - if (original != null) - { - original.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds; - } - } - SubtitleListview1.SetStartTimeAndDuration(i + 1, next, _subtitle.GetParagraphOrDefault(i + 2), p); - } - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(_subtitle.GetIndex(p), p, _subtitleAlternate.Paragraphs); - if (original != null) - { - original.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds; - original.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds; - } - } - - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, i, p); - } - - private void ShowNextSubtitleLabel() - { - if (audioVisualizer.Visible && audioVisualizer.WavePeaks != null && audioVisualizer.Width > 300 && _subtitleListViewIndex >= 0) - { - var next = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1); - if (next != null && !string.IsNullOrEmpty(next.Text)) - { - labelNextWord.Top = audioVisualizer.Top; - labelNextWord.Text = string.Format(_language.NextX, HtmlUtil.RemoveHtmlTags(next.Text, true).Replace(Environment.NewLine, " ")); - labelNextWord.Left = audioVisualizer.Width / 2 - labelNextWord.Width / 2 + audioVisualizer.Left; - labelNextWord.Visible = true; - _labelNextTicks = DateTime.UtcNow.Ticks; - } - else - { - labelNextWord.Visible = false; - } - } - else - { - labelNextWord.Visible = false; - } - } - - private void MergeSelectedLinesOnlyFirstText() - { - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 1) - { - var deleteIndices = new List(); - bool first = true; - int firstIndex = 0; - int next = 0; - string text = string.Empty; - double endTime = 0; - foreach (int index in SubtitleListview1.SelectedIndices) - { - if (first) - { - firstIndex = index; - next = index + 1; - } - else - { - deleteIndices.Add(index); - if (next != index) - { - return; - } - - next++; - } - - first = false; - if (string.IsNullOrEmpty(text)) - { - text = _subtitle.Paragraphs[index].Text.Trim(); - } - - endTime = _subtitle.Paragraphs[index].EndTime.TotalMilliseconds; - } - - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - MakeHistoryForUndo(_language.BeforeMergeLines); - - var currentParagraph = _subtitle.Paragraphs[firstIndex]; - currentParagraph.Text = text; - currentParagraph.EndTime.TotalMilliseconds = endTime; - - var nextParagraph = _subtitle.GetParagraphOrDefault(next); - if (nextParagraph != null && currentParagraph.EndTime.TotalMilliseconds > nextParagraph.StartTime.TotalMilliseconds && currentParagraph.StartTime.TotalMilliseconds < nextParagraph.StartTime.TotalMilliseconds) - { - currentParagraph.EndTime.TotalMilliseconds = nextParagraph.StartTime.TotalMilliseconds - 1; - } - - // original subtitle - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(firstIndex, currentParagraph, _subtitleAlternate.Paragraphs); - if (original != null) - { - string originalText = string.Empty; - for (int i = 0; i < deleteIndices.Count; i++) - { - var originalNext = Utilities.GetOriginalParagraph(deleteIndices[i], _subtitle.Paragraphs[deleteIndices[i]], _subtitleAlternate.Paragraphs); - if (originalNext != null && string.IsNullOrEmpty(originalText)) - { - originalText = originalNext.Text; - } - } - - for (int i = deleteIndices.Count - 1; i >= 0; i--) - { - var originalNext = Utilities.GetOriginalParagraph(deleteIndices[i], _subtitle.Paragraphs[deleteIndices[i]], _subtitleAlternate.Paragraphs); - if (originalNext != null) - { - _subtitleAlternate.Paragraphs.Remove(originalNext); - } - } - - original.Text = originalText; - original.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; - _subtitleAlternate.Renumber(); - } - } - - if (_networkSession != null) - { - _networkSession.TimerStop(); - _networkSession.UpdateLine(firstIndex, currentParagraph); - NetworkGetSendUpdates(deleteIndices, 0, null); - } - else - { - for (int i = deleteIndices.Count - 1; i >= 0; i--) - { - _subtitle.Paragraphs.RemoveAt(deleteIndices[i]); - } - - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - ShowSource(); - ShowStatus(_language.LinesMerged); - SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex, true); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - RefreshSelectedParagraph(); - } - } - - private void GoToFirstEmptyLine() - { - var index = FirstSelectedIndex + 1; - for (; index < _subtitle.Paragraphs.Count; index++) - { - if (string.IsNullOrWhiteSpace(_subtitle.Paragraphs[index].Text)) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.VideoPlayer.CurrentPosition = _subtitle.Paragraphs[index].StartTime.TotalSeconds; - } - - return; - } - } - } - - private void PlayFirstSelectedSubtitle() - { - if (_subtitleListViewIndex >= 0 && mediaPlayer.VideoPlayer != null) - { - GotoSubtitleIndex(_subtitleListViewIndex); - var paragraph = _subtitle.Paragraphs[_subtitleListViewIndex]; - double startSeconds = paragraph.StartTime.TotalSeconds; - _endSeconds = paragraph.EndTime.TotalSeconds; - mediaPlayer.CurrentPosition = startSeconds; - ShowSubtitle(); - mediaPlayer.Play(); - } - } - - private void SetEndAndOffsetTheRest(bool goToNext) - { - if (SubtitleListview1.SelectedItems.Count == 1) - { - bool oldSync = checkBoxSyncListViewWithVideoWhilePlaying.Checked; - checkBoxSyncListViewWithVideoWhilePlaying.Checked = false; - - int index = SubtitleListview1.SelectedItems[0].Index; - double videoPosition = mediaPlayer.CurrentPosition; - if (!mediaPlayer.IsPaused) - { - videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; - } - - var tc = TimeCode.FromSeconds(videoPosition); - - double offset = tc.TotalMilliseconds - _subtitle.Paragraphs[index].EndTime.TotalMilliseconds; - if (_subtitle.Paragraphs[index].StartTime.TotalMilliseconds + 100 > tc.TotalMilliseconds || offset > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) - { - return; - } - - MakeHistoryForUndo(_language.BeforeSetEndTimeAndOffsetTheRest + @" " + _subtitle.Paragraphs[index].Number + @" - " + tc); - - numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged; - _subtitle.Paragraphs[index].EndTime.TotalSeconds = videoPosition; - SubtitleListview1.SetDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); - checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync; - numericUpDownDuration.Value = (decimal)_subtitle.Paragraphs[index].Duration.TotalSeconds; - numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged; - RefreshSelectedParagraph(); - - for (int i = index + 1; i < SubtitleListview1.Items.Count; i++) - { - if (!_subtitle.Paragraphs[i].StartTime.IsMaxTime) - { - _subtitle.Paragraphs[i].StartTime = new TimeCode(_subtitle.Paragraphs[i].StartTime.TotalMilliseconds + offset); - _subtitle.Paragraphs[i].EndTime = new TimeCode(_subtitle.Paragraphs[i].EndTime.TotalMilliseconds + offset); - SubtitleListview1.SetDuration(i, _subtitle.Paragraphs[i], _subtitle.GetParagraphOrDefault(i + 1)); - } - } - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - var original = Utilities.GetOriginalParagraph(index, _subtitle.Paragraphs[index], _subtitleAlternate.Paragraphs); - if (original != null) - { - index = _subtitleAlternate.GetIndex(original); - for (int i = index; i < _subtitleAlternate.Paragraphs.Count; i++) - { - if (!_subtitleAlternate.Paragraphs[i].StartTime.IsMaxTime) - { - _subtitleAlternate.Paragraphs[i].StartTime = new TimeCode(_subtitleAlternate.Paragraphs[i].StartTime.TotalMilliseconds + offset); - _subtitleAlternate.Paragraphs[i].EndTime = new TimeCode(_subtitleAlternate.Paragraphs[i].EndTime.TotalMilliseconds + offset); - } - } - } - } - - checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync; - - if (goToNext) - { - _subtitleListViewIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true); - if (mediaPlayer.IsPaused && index + 1 < _subtitle.Paragraphs.Count) - { - mediaPlayer.CurrentPosition = _subtitle.Paragraphs[index + 1].StartTime.TotalSeconds; - } - } - } - } - - private void MoveVideoSeconds(double seconds) - { - var oldPosition = mediaPlayer.CurrentPosition; - var newPosition = oldPosition + seconds; - if (newPosition < 0) - { - newPosition = 0; - } - - if (mediaPlayer.IsPaused && Configuration.Settings.General.MoveVideo100Or500MsPlaySmallSample) - { - mediaPlayer.CurrentPosition = newPosition; - mediaPlayer.Play(); - System.Threading.Thread.Sleep(99); - mediaPlayer.Stop(); - } - - mediaPlayer.CurrentPosition = newPosition; - } - - private void RunCustomSearch(string url) - { - if (!string.IsNullOrEmpty(url)) - { - RunTranslateSearch((text) => - { - url = string.Format(url, Utilities.UrlEncode(text)); - UiUtil.OpenURL(url); - }); - } - } - - private void GoFullscreen(bool force) - { - if (mediaPlayer.VideoPlayer == null && !force) - { - return; - } - - mediaPlayer.ShowFullScreenControls(); - bool setRedockOnFullscreenEnd = false; - - if (_videoPlayerUndocked == null || _videoPlayerUndocked.IsDisposed) - { - UndockVideoControlsToolStripMenuItemClick(null, null); - setRedockOnFullscreenEnd = true; - } - - if (_videoPlayerUndocked != null && !_videoPlayerUndocked.IsDisposed) - { - _videoPlayerUndocked.Focus(); - _videoPlayerUndocked.GoFullscreen(); - if (setRedockOnFullscreenEnd) - { - _videoPlayerUndocked.RedockOnFullscreenEnd = true; - } - } - } - - private void RefreshTimeCodeMode() - { - if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) - { - numericUpDownDuration.DecimalPlaces = 2; - numericUpDownDuration.Increment = (decimal)(0.01); - - toolStripSeparatorFrameRate.Visible = true; - toolStripLabelFrameRate.Visible = true; - toolStripComboBoxFrameRate.Visible = true; - toolStripButtonGetFrameRate.Visible = true; - } - else - { - numericUpDownDuration.DecimalPlaces = 3; - numericUpDownDuration.Increment = (decimal)(0.1); - - toolStripSeparatorFrameRate.Visible = Configuration.Settings.General.ShowFrameRate; - toolStripLabelFrameRate.Visible = Configuration.Settings.General.ShowFrameRate; - toolStripComboBoxFrameRate.Visible = Configuration.Settings.General.ShowFrameRate; - toolStripButtonGetFrameRate.Visible = Configuration.Settings.General.ShowFrameRate; - } - - SaveSubtitleListviewIndices(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - RefreshSelectedParagraph(); - } - - private void ReverseStartAndEndingForRtl() - { - MakeHistoryForUndo(toolStripMenuItemReverseRightToLeftStartEnd.Text); - int selectedIndex = FirstSelectedIndex; - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.Paragraphs[index]; - p.Text = Utilities.ReverseStartAndEndingForRightToLeft(p.Text); - SubtitleListview1.SetText(index, p.Text); - if (index == selectedIndex) - { - textBoxListViewText.Text = p.Text; - } - } - } - - private void MergeDialogs() - { - if (SubtitleListview1.SelectedItems.Count == 1 || SubtitleListview1.SelectedItems.Count == 2 && SubtitleListview1.SelectedIndices[0] + 1 == SubtitleListview1.SelectedIndices[1]) - { - MergeWithLineAfter(true); - } - } - - private void ToggleDashes() - { - var index = FirstSelectedIndex; - if (index >= 0) - { - var hasStartDash = false; - var p = _subtitle.Paragraphs[index]; - var lines = p.Text.SplitToLines(); - foreach (var line in lines) - { - var trimmed = HtmlUtil.RemoveHtmlTags(line, true).TrimStart(); - if (trimmed.StartsWith('-')) - { - hasStartDash = true; - break; - } - } - - if (!hasStartDash && _subtitleAlternate != null && textBoxListViewTextAlternate.Visible) - { - var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - lines = original.Text.SplitToLines(); - foreach (var line in lines) - { - var trimmed = HtmlUtil.RemoveHtmlTags(line, true).TrimStart(); - if (trimmed.StartsWith('-')) - { - hasStartDash = true; - break; - } - } - } - } - - MakeHistoryForUndo(_language.BeforeToggleDialogDashes); - if (hasStartDash) - { - RemoveDashes(); - } - else - { - AddDashes(); - } - } - } - - private void ToggleDashesTextBox(SETextBox tb) - { - var hasStartDash = false; - var lines = tb.Text.TrimEnd().SplitToLines(); - foreach (var line in lines) - { - var trimmed = HtmlUtil.RemoveHtmlTags(line, true).TrimStart(); - if (trimmed.StartsWith('-')) - { - hasStartDash = true; - break; - } - } - - MakeHistoryForUndo(_language.BeforeToggleDialogDashes); - var sb = new StringBuilder(); - if (hasStartDash) - { - // remove dashes - foreach (var line in lines) - { - var pre = string.Empty; - var s = SplitStartTags(line, ref pre); - sb.AppendLine(pre + s.TrimStart('-').TrimStart()); - } - - tb.Text = sb.ToString().Trim(); - } - else - { - // add dashes - if (CouldBeDialog(lines)) - { - foreach (var line in lines) - { - var pre = string.Empty; - var s = SplitStartTags(line, ref pre); - sb.AppendLine(pre + "- " + s); - } - } - else - { - sb.Append(tb.Text); - } - - var text = sb.ToString().Trim(); - var dialogHelper = new DialogSplitMerge { DialogStyle = Configuration.Settings.General.DialogStyle, SkipLineEndingCheck = true }; - text = dialogHelper.FixDashesAndSpaces(text); - tb.Text = text; - } - } - - private void AddDashes() - { - var dialogHelper = new DialogSplitMerge { DialogStyle = Configuration.Settings.General.DialogStyle, SkipLineEndingCheck = true }; - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.Paragraphs[index]; - var lines = p.Text.SplitToLines(); - var sb = new StringBuilder(); - if (CouldBeDialog(lines)) - { - foreach (var line in lines) - { - var pre = string.Empty; - var s = SplitStartTags(line, ref pre); - sb.AppendLine(pre + "- " + s); - } - } - else - { - sb.Append(p.Text); - } - - var text = sb.ToString().Trim(); - text = dialogHelper.FixDashesAndSpaces(text); - _subtitle.Paragraphs[index].Text = text; - SubtitleListview1.SetText(index, text); - if (index == _subtitleListViewIndex) - { - textBoxListViewText.Text = text; - } - - if (_subtitleAlternate != null && textBoxListViewTextAlternate.Visible) - { - var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - lines = original.Text.SplitToLines(); - sb = new StringBuilder(); - if (CouldBeDialog(lines)) - { - foreach (var line in lines) - { - var pre = string.Empty; - var s = SplitStartTags(line, ref pre); - if (!line.StartsWith("-")) - { - sb.AppendLine(pre + "- " + s); - } - else - { - sb.AppendLine(pre + s); - } - } - } - else - { - sb.Append(original.Text); - } - - text = sb.ToString().Trim(); - text = dialogHelper.FixDashesAndSpaces(text); - _subtitleAlternate.Paragraphs[index].Text = text; - SubtitleListview1.SetAlternateText(index, text); - if (index == _subtitleListViewIndex) - { - textBoxListViewTextAlternate.Text = text; - } - } - } - } - } - - private static bool CouldBeDialog(List lines) - { - return lines.Count >= 2 && lines.Count <= 3; - } - - private void RemoveDashes() - { - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.Paragraphs[index]; - var lines = p.Text.SplitToLines(); - var sb = new StringBuilder(); - foreach (var line in lines) - { - var pre = string.Empty; - var s = SplitStartTags(line, ref pre); - sb.AppendLine(pre + s.TrimStart('-').TrimStart()); - } - - string text = sb.ToString().Trim(); - _subtitle.Paragraphs[index].Text = text; - SubtitleListview1.SetText(index, text); - if (index == _subtitleListViewIndex) - { - textBoxListViewText.Text = text; - } - - if (_subtitleAlternate != null && textBoxListViewTextAlternate.Visible) - { - var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - lines = original.Text.SplitToLines(); - sb = new StringBuilder(); - foreach (var line in lines) - { - var pre = string.Empty; - var s = SplitStartTags(line, ref pre); - sb.AppendLine(pre + s.TrimStart('-').TrimStart()); - } - - text = sb.ToString().Trim(); - _subtitleAlternate.Paragraphs[index].Text = text; - SubtitleListview1.SetAlternateText(index, text); - if (index == _subtitleListViewIndex) - { - textBoxListViewTextAlternate.Text = text; - } - } - } - } - } - - private static string SplitStartTags(string line, ref string pre) - { - var s = line; - if (s.StartsWith("{\\", StringComparison.Ordinal) && s.IndexOf('}') > 0) - { - pre = s.Substring(0, s.IndexOf('}') + 1); - s = s.Remove(0, pre.Length); - } - - bool updated = true; - while (updated) - { - updated = false; - if (s.StartsWith(' ')) - { - pre += ' '; - s = s.Remove(0, 1); - updated = true; - } - else if (s.StartsWith("", StringComparison.OrdinalIgnoreCase) || - s.StartsWith("", StringComparison.OrdinalIgnoreCase) || - s.StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - pre += s.Substring(0, 3); - s = s.Remove(0, 3); - updated = true; - } - else if (s.StartsWith("'); - if (endFont > 0) - { - pre += s.Substring(0, endFont + 1); - s = s.Remove(0, endFont + 1); - updated = true; - } - } - } - - return s; - } - - private void SetTitle() - { - var text = "Untitled"; - string separator = " + "; - if (!string.IsNullOrEmpty(_fileName)) - { - text = _fileName; - } - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - text += separator; - if (string.IsNullOrEmpty(_fileName)) - { - text = text + _language.New + " + "; - } - - if (!string.IsNullOrEmpty(_subtitleAlternateFileName)) - { - text += _subtitleAlternateFileName; - } - else - { - text += _language.New; - } - } - - Text = text + " - " + Title; - } - - private void SubtitleListview1KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control) //Ctrl+c = Copy to clipboard - { - var tmp = new Subtitle(); - foreach (int i in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.GetParagraphOrDefault(i); - if (p != null) - { - tmp.Paragraphs.Add(new Paragraph(p)); - } - } - - if (tmp.Paragraphs.Count > 0) - { - if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) - { - tmp.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(Configuration.Settings.General.CurrentVideoOffsetInMs)); - } - - Clipboard.SetText(tmp.ToText(new SubRip()).TrimEnd()); - } - - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewCopyText) - { - var sb = new StringBuilder(); - foreach (int i in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.GetParagraphOrDefault(i); - if (p != null) - { - sb.AppendLine(p.Text + Environment.NewLine); - } - } - - if (sb.ToString().TrimEnd().Length > 0) - { - Clipboard.SetText(sb.ToString().TrimEnd()); - } - - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAutoDuration) - { - MakeAutoDurationSelectedLines(); - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN1) - { - SetAlignment("{\\an1}", true); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN2) - { - SetAlignment("", true); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN3) - { - SetAlignment("{\\an3}", true); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN4) - { - SetAlignment("{\\an4}", true); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN5) - { - SetAlignment("{\\an5}", true); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN6) - { - SetAlignment("{\\an6}", true); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN7) - { - SetAlignment("{\\an7}", true); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN8) - { - SetAlignment("{\\an8}", true); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewAlignmentN9) - { - SetAlignment("{\\an9}", true); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewFocusWaveform) - { - if (audioVisualizer.CanFocus) - { - audioVisualizer.Focus(); - e.SuppressKeyPress = true; - } - } - else if (e.KeyData == _shortcuts.MainListViewGoToNextError) - { - GoToNextSyntaxError(); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainListViewRemoveTimeCodes) - { - RemoveTimeCodesFromSelectedLines(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control) //Ctrl+V = Paste from clipboard - { - if (Clipboard.ContainsText()) - { - var text = Clipboard.GetText(); - var tmp = new Subtitle(); - var format = new SubRip(); - var list = new List(text.SplitToLines()); - format.LoadSubtitle(tmp, list, null); - if (SubtitleListview1.SelectedItems.Count == 1 && tmp.Paragraphs.Count > 0) - { - MakeHistoryForUndo(_language.BeforeInsertLine); - int firstIndex = FirstSelectedIndex; - var lastParagraph = _subtitle.Paragraphs[firstIndex]; - double addMs = 0; - if (lastParagraph.EndTime.TotalMilliseconds > tmp.Paragraphs[0].StartTime.TotalMilliseconds) - { // add time to pasted subtitles to prevent overlap, but only if necessary - addMs = lastParagraph.EndTime.TotalMilliseconds - tmp.Paragraphs[0].StartTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - else if (firstIndex <= _subtitle.Paragraphs.Count - 2 && _subtitle.Paragraphs[firstIndex + 1].StartTime.TotalMilliseconds < tmp.Paragraphs[0].StartTime.TotalMilliseconds) - { // inserting between two subtitle... with overlapping codes - addMs = lastParagraph.EndTime.TotalMilliseconds - tmp.Paragraphs[0].StartTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - - var selectIndices = new List(); - for (int i = 0; i < tmp.Paragraphs.Count; i++) - { - var p = tmp.Paragraphs[i]; - p.StartTime.TotalMilliseconds += addMs; - p.EndTime.TotalMilliseconds += addMs; - _subtitle.Paragraphs.Insert(firstIndex + i + 1, p); - selectIndices.Insert(0, firstIndex + i + 1); - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) - { - var original = Utilities.GetOriginalParagraph(firstIndex + i + 1, p, _subtitleAlternate.Paragraphs); - if (original == null) - { - _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds)); - } - } - } - - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.BeginUpdate(); - foreach (var selectIndex in selectIndices) - { - SubtitleListview1.Items[selectIndex].Selected = true; - } - - SubtitleListview1.EndUpdate(); - SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex + 1, true); - } - else if (SubtitleListview1.Items.Count == 0 && tmp.Paragraphs.Count > 0) - { // insert into empty subtitle - MakeHistoryForUndo(_language.BeforeInsertLine); - foreach (var p in tmp.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) - { - var original = Utilities.GetOriginalParagraph(_subtitle.Paragraphs.Count - 1, p, _subtitleAlternate.Paragraphs); - if (original == null) - { - _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds)); - } - } - } - - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - } - else if (SubtitleListview1.Items.Count > 1 && tmp.Paragraphs.Count > 0) - { - // multiple lines selected - first delete, then insert - int firstIndex = FirstSelectedIndex; - if (firstIndex >= 0) - { - var idx = firstIndex; - MakeHistoryForUndo(_language.BeforeInsertLine); - _makeHistoryPaused = true; - - DeleteSelectedLines(); - _subtitleListViewIndex = -1; - var selectedIndices = new List(); - foreach (var p in tmp.Paragraphs) - { - _subtitle.Paragraphs.Insert(idx, p); - selectedIndices.Add(idx); - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) - { - var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); - if (original == null) - { - _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds)); - } - } - - idx++; - } - - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex, true); - foreach (var selectedIndex in selectedIndices) - { - SubtitleListview1.Items[selectedIndex].Selected = true; - } - RestartHistory(); - } - } - else if (SubtitleListview1.Items.Count > 0 && list.Count >= 1 && list.Count < 4 && !text.Trim().Contains(Environment.NewLine + Environment.NewLine)) - { - // less than 4 lines of text, just insert into first selected - textBoxListViewText.Text = text.Trim(); - } - else if (list.Count >= 1 && list.Count < 2000) - { - MakeHistoryForUndo(_language.BeforeInsertLine); - _makeHistoryPaused = true; - SubtitleListview1.BeginUpdate(); - foreach (var line in list) - { - if (!string.IsNullOrWhiteSpace(line)) - { - var s = line.Trim().Length > Configuration.Settings.General.SubtitleLineMaximumLength ? Utilities.AutoBreakLine(line) : line.Trim(); - InsertAfter(s); - } - } - SubtitleListview1.EndUpdate(); - RestartHistory(); - } - - if (_subtitleListViewIndex >= 0) - { - UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, _subtitle.Paragraphs[_subtitleListViewIndex], textBoxListViewText); - } - else - { - SubtitleListview1.SelectIndexAndEnsureVisible(0); - } - } - else if (Clipboard.ContainsFileDropList()) - { - var fileDropList = Clipboard.GetFileDropList(); - if (fileDropList.Count == 1) - { - ShowStatus(Configuration.Settings.Language.General.PleaseWait, false); - OpenSubtitle(fileDropList[0], null); - } - } - - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.X && e.Modifiers == Keys.Control) //Ctrl+X = Cut to clipboard - { - var tmp = new Subtitle(); - foreach (int i in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.GetParagraphOrDefault(i); - if (p != null) - { - tmp.Paragraphs.Add(new Paragraph(p)); - } - } - - e.SuppressKeyPress = true; - _cutText = tmp.ToText(new SubRip()); - ToolStripMenuItemDeleteClick(null, null); - } - else if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) - { - SubtitleListview1.SelectAll(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.D && e.Modifiers == Keys.Control) - { - SubtitleListview1.SelectFirstSelectedItemOnly(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.Delete && SubtitleListview1.SelectedItems.Count > 0) //Delete - { - ToolStripMenuItemDeleteClick(null, null); - } - else if (e.KeyData == _shortcuts.MainInsertBefore) - { - InsertBefore(); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainInsertAfter) - { - InsertAfter(string.Empty); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Home) - { - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.End) - { - SubtitleListview1.SelectIndexAndEnsureVisible(SubtitleListview1.Items.Count - 1, true); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Enter) - { - SubtitleListview1_MouseDoubleClick(null, null); - } - } - - private void RemoveTimeCodesFromSelectedLines() - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.RemoveTimeCodes)); - - var indices = new List(); - foreach (ListViewItem item in SubtitleListview1.SelectedItems) - { - indices.Add(item.Index); - } - foreach (int i in indices) - { - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) - { - var original = Utilities.GetOriginalParagraph(i, _subtitle.Paragraphs[i], _subtitleAlternate.Paragraphs); - if (original != null) - { - original.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - original.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - } - } - _subtitle.Paragraphs[i].StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - _subtitle.Paragraphs[i].EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; - } - - SaveSubtitleListviewIndices(); - _subtitleListViewIndex = -1; - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - ShowSource(); - RestoreSubtitleListviewIndices(); - } - - private void SetAlignment(string tag, bool selectedLines) - { - if (selectedLines) - { - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - MakeHistoryForUndo(string.Format(_language.BeforeAddingTagX, tag)); - - var indices = new List(); - foreach (ListViewItem item in SubtitleListview1.SelectedItems) - { - indices.Add(item.Index); - } - - bool first = true; - SubtitleListview1.BeginUpdate(); - foreach (int i in indices) - { - if (first) - { - if (_subtitle.Paragraphs[i].Text.StartsWith(tag, StringComparison.Ordinal)) - { - tag = string.Empty; - } - - if (_subtitle.Paragraphs[i].Text.StartsWith(tag.Replace("}", "\\"), StringComparison.Ordinal)) - { - tag = string.Empty; - } - - first = false; - } - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) - { - var original = Utilities.GetOriginalParagraph(i, _subtitle.Paragraphs[i], _subtitleAlternate.Paragraphs); - if (original != null) - { - original.Text = SetAlignTag(original.Text, tag); - SubtitleListview1.SetAlternateText(i, original.Text); - } - } - - _subtitle.Paragraphs[i].Text = SetAlignTag(_subtitle.Paragraphs[i].Text, tag); - SubtitleListview1.SetText(i, _subtitle.Paragraphs[i].Text); - } - - SubtitleListview1.EndUpdate(); - - ShowStatus(string.Format(_language.TagXAdded, tag)); - ShowSource(); - RefreshSelectedParagraph(); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - } - else - { - var tb = GetFocusedTextBox(); - var pos = tb.SelectionStart; - int oldLength = tb.Text.Length; - bool atEnd = pos == oldLength; - tb.Text = SetAlignTag(tb.Text, tag); - if (atEnd) - { - tb.SelectionStart = tb.Text.Length; - } - else if (pos == 0) - { - tb.SelectionStart = 0; - } - else if (oldLength == tb.Text.Length) - { - tb.SelectionStart = pos; - } - else if (pos + 5 <= tb.Text.Length) - { - tb.SelectionStart = pos + 5; - } - } - } - - private void GoToNextSyntaxError() - { - int idx = FirstSelectedIndex + 1; - try - { - for (int i = idx; i < _subtitle.Paragraphs.Count; i++) - { - var item = SubtitleListview1.Items[i]; - if (item.SubItems[SubtitleListview1.ColumnIndexDuration].BackColor == Configuration.Settings.Tools.ListViewSyntaxErrorColor || - item.SubItems[SubtitleListview1.ColumnIndexText].BackColor == Configuration.Settings.Tools.ListViewSyntaxErrorColor || - item.SubItems[SubtitleListview1.ColumnIndexStart].BackColor == Configuration.Settings.Tools.ListViewSyntaxErrorColor || - (SubtitleListview1.ColumnIndexCps >= 0 && item.SubItems[SubtitleListview1.ColumnIndexCps].BackColor == Configuration.Settings.Tools.ListViewSyntaxErrorColor) || - (SubtitleListview1.ColumnIndexWpm >= 0 && item.SubItems[SubtitleListview1.ColumnIndexWpm].BackColor == Configuration.Settings.Tools.ListViewSyntaxErrorColor) || - (SubtitleListview1.ColumnIndexGap >= 0 && item.SubItems[SubtitleListview1.ColumnIndexGap].BackColor == Configuration.Settings.Tools.ListViewSyntaxErrorColor)) - { - SubtitleListview1.SelectIndexAndEnsureVisible(i, true); - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.VideoPlayer.CurrentPosition = _subtitle.Paragraphs[i].StartTime.TotalSeconds; - } - - return; - } - } - } - catch - { - } - } - - private void RestartHistory() - { - _listViewTextUndoLast = null; - _listViewTextUndoIndex = -1; - _listViewTextTicks = -1; - _listViewAlternateTextUndoLast = null; - _listViewAlternateTextTicks = -1; - _undoIndex = _subtitle.HistoryItems.Count - 1; - _makeHistoryPaused = false; - } - - private void AdjustDisplayTimeForSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) - { - AdjustDisplayTime(true); - } - - private void FixCommonErrorsInSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) - { - FixCommonErrors(true); - } - - private void FindDoubleWordsToolStripMenuItemClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - var regex = new Regex(@"\b(\w+)\s+\1\b"); - _clearLastFind = true; - if (_findHelper != null) - { - _clearLastFindType = _findHelper.FindReplaceType.FindType; - _clearLastFindText = _findHelper.FindText; - } - - _findHelper = new FindReplaceDialogHelper(new ReplaceType { FindType = FindType.RegEx }, string.Format(_language.DoubleWordsViaRegEx, regex), regex, string.Empty, _subtitleListViewIndex); - - ReloadFromSourceView(); - FindNext(); - } - - private void ChangeCasingForSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) - { - ChangeCasing(true); - } - - private void CenterFormOnCurrentScreen() - { - var screen = Screen.FromControl(this); - Left = screen.Bounds.X + ((screen.Bounds.Width - Width) / 2); - Top = screen.Bounds.Y + ((screen.Bounds.Height - Height) / 2); - } - - private void SortSubtitle(SubtitleSortCriteria subtitleSortCriteria, string description) - { - var firstSelectedIndex = 0; - if (SubtitleListview1.SelectedItems.Count > 0) - { - firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - } - - _subtitleListViewIndex = -1; - MakeHistoryForUndo(string.Format(_language.BeforeSortX, description)); - _subtitle.Sort(subtitleSortCriteria); - if (descendingToolStripMenuItem.Checked) - { - _subtitle.Paragraphs.Reverse(); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); - ShowStatus(string.Format(_language.SortedByX, description)); - } - - private void SortNumberToolStripMenuItemClick(object sender, EventArgs e) - { - SortSubtitle(SubtitleSortCriteria.Number, (sender as ToolStripItem).Text); - } - - private void SortStartTimeToolStripMenuItemClick(object sender, EventArgs e) - { - SortSubtitle(SubtitleSortCriteria.StartTime, (sender as ToolStripItem).Text); - } - - private void SortEndTimeToolStripMenuItemClick(object sender, EventArgs e) - { - SortSubtitle(SubtitleSortCriteria.EndTime, (sender as ToolStripItem).Text); - } - - private void SortDisplayTimeToolStripMenuItemClick(object sender, EventArgs e) - { - SortSubtitle(SubtitleSortCriteria.Duration, (sender as ToolStripItem).Text); - } - - private void SortTextMaxLineLengthToolStripMenuItemClick(object sender, EventArgs e) - { - SortSubtitle(SubtitleSortCriteria.TextMaxLineLength, (sender as ToolStripItem).Text); - } - - private void SortTextTotalLengthToolStripMenuItemClick(object sender, EventArgs e) - { - SortSubtitle(SubtitleSortCriteria.TextTotalLength, (sender as ToolStripItem).Text); - } - - private void SortTextNumberOfLinesToolStripMenuItemClick(object sender, EventArgs e) - { - SortSubtitle(SubtitleSortCriteria.TextNumberOfLines, (sender as ToolStripItem).Text); - } - - private void SortTextAlphabeticallytoolStripMenuItemClick(object sender, EventArgs e) - { - SortSubtitle(SubtitleSortCriteria.Text, (sender as ToolStripItem).Text); - } - - private void textCharssecToolStripMenuItem_Click(object sender, EventArgs e) - { - SortSubtitle(SubtitleSortCriteria.TextCharactersPerSeconds, (sender as ToolStripItem).Text); - } - - private void ChangeLanguageToolStripMenuItemClick(object sender, EventArgs e) - { - using (var cl = new ChooseLanguage()) - { - if (cl.ShowDialog(this) == DialogResult.OK) - { - SetLanguage(cl.CultureName); - Configuration.Settings.Save(); - } - } - } - - private void SetLanguage(string cultureName) - { - if (string.IsNullOrEmpty(cultureName)) - { - cultureName = "en-US"; - } - - if (cultureName != "en-US") - { - try - { - Configuration.Settings.Language = Language.Load(Path.Combine(Configuration.BaseDirectory, "Languages", cultureName + ".xml")); - } - catch (Exception ex) - { - var cap = "Language file load error"; - var msg = "Could not load language file " + cultureName + ".xml" + - "\n\nError Message:\n" + ex.Message + - "\n\nStack Trace:\n" + ex.StackTrace; - MessageBox.Show(this, msg, cap); - cultureName = "en-US"; - } - } - - if (cultureName == "en-US") - { - Configuration.Settings.Language = new Language(); // default is en-US - } - - Configuration.Settings.General.Language = cultureName; - _languageGeneral = Configuration.Settings.Language.General; - _language = Configuration.Settings.Language.Main; - InitializeLanguage(); - } - - private void ToolStripMenuItemCompareClick(object sender, EventArgs e) - { - var compareForm = new Compare(); - if (_subtitleAlternate != null && _subtitleAlternateFileName != null && SubtitleListview1.IsAlternateTextColumnVisible) - { - compareForm.Initialize(_subtitle, _fileName, _subtitleAlternate, _subtitleAlternateFileName); - } - else - { - compareForm.Initialize(_subtitle, _fileName, _languageGeneral.CurrentSubtitle); - } - - compareForm.Show(this); - compareForm.Activate(); - } - - private void ToolStripMenuItemAutoBreakLinesClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - using (var autoBreakUnbreakLines = new AutoBreakUnbreakLines()) - { - var selectedLines = new Subtitle(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]); - } - - autoBreakUnbreakLines.Initialize(selectedLines, true); - - if (autoBreakUnbreakLines.ShowDialog() == DialogResult.OK && autoBreakUnbreakLines.FixedText.Count > 0) - { - MakeHistoryForUndo(_language.BeforeAutoBalanceSelectedLines); - SubtitleListview1.BeginUpdate(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.GetParagraphOrDefault(index); - if (autoBreakUnbreakLines.FixedText.ContainsKey(p.Id)) - { - p.Text = autoBreakUnbreakLines.FixedText[p.Id]; - SubtitleListview1.SetText(index, p.Text); - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, p); - } - } - - SubtitleListview1.EndUpdate(); - RefreshSelectedParagraph(); - ShowStatus(string.Format(_language.NumberOfLinesAutoBalancedX, autoBreakUnbreakLines.FixedText.Count)); - } - } - } - - private void ToolStripMenuItemUnbreakLinesClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - using (var autoBreakUnbreakLines = new AutoBreakUnbreakLines()) - { - var selectedLines = new Subtitle(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]); - } - - autoBreakUnbreakLines.Initialize(selectedLines, false); - - if (autoBreakUnbreakLines.ShowDialog() == DialogResult.OK && autoBreakUnbreakLines.FixedText.Count > 0) - { - MakeHistoryForUndo(_language.BeforeRemoveLineBreaksInSelectedLines); - - SubtitleListview1.BeginUpdate(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.GetParagraphOrDefault(index); - if (autoBreakUnbreakLines.FixedText.ContainsKey(p.Id)) - { - p.Text = autoBreakUnbreakLines.FixedText[p.Id]; - SubtitleListview1.SetText(index, p.Text); - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, p); - } - } - - SubtitleListview1.EndUpdate(); - RefreshSelectedParagraph(); - ShowStatus(string.Format(_language.NumberOfWithRemovedLineBreakX, autoBreakUnbreakLines.FixedText.Count)); - } - } - } - - private void MultipleReplaceToolStripMenuItemClick(object sender, EventArgs e) - { - using (var multipleReplace = new MultipleReplace()) - { - multipleReplace.Initialize(_subtitle); - if (multipleReplace.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeMultipleReplace); - SaveSubtitleListviewIndices(); - - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - _subtitle.Paragraphs[i].Text = multipleReplace.FixedSubtitle.Paragraphs[i].Text; - } - - _subtitle.RemoveParagraphsByIndices(multipleReplace.DeleteIndices); - _subtitle.Renumber(); - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - RefreshSelectedParagraph(); - ShowSource(); - ShowStatus(string.Format(_language.NumberOfLinesReplacedX, multipleReplace.FixCount)); - } - } - } - - private void ToolStripMenuItemImportDvdSubtitlesClick(object sender, EventArgs e) - { - if (!ContinueNewOrExit()) - { - return; - } - - ImportDvdSubtitle(null); - } - - private void ImportDvdSubtitle(string fileName) - { - using (var formSubRip = new DvdSubRip(Handle, fileName)) - { - if (formSubRip.ShowDialog(this) == DialogResult.OK) - { - using (var showSubtitles = new DvdSubRipChooseLanguage()) - { - showSubtitles.Initialize(formSubRip.MergedVobSubPacks, formSubRip.Palette, formSubRip.Languages, formSubRip.SelectedLanguage); - if (formSubRip.Languages.Count == 1 || showSubtitles.ShowDialog(this) == DialogResult.OK) - { - using (var formSubOcr = new VobSubOcr()) - { - var subs = formSubRip.MergedVobSubPacks; - if (showSubtitles.SelectedVobSubMergedPacks != null) - { - subs = showSubtitles.SelectedVobSubMergedPacks; - } - - formSubOcr.Initialize(subs, formSubRip.Palette, Configuration.Settings.VobSubOcr, formSubRip.SelectedLanguage); - if (formSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportingDvdSubtitle); - FileNew(); - _subtitle.Paragraphs.Clear(); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = string.Empty; - SetTitle(); - - Configuration.Settings.Save(); - } - } - } - } - } - } - } - - private void ToolStripMenuItemSubIdxClick1(object sender, EventArgs e) - { - if (ContinueNewOrExit()) - { - openFileDialog1.Title = _language.OpenVobSubFile; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = _language.VobSubFiles + "|*.sub"; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - ImportAndOcrVobSubSubtitleNew(openFileDialog1.FileName, false); - openFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName); - } - } - } - - private void SubtitleListview1_MouseDoubleClick(object sender, MouseEventArgs e) - { - if (Configuration.Settings.General.ListViewDoubleClickAction == 1) - { - GotoSubPositionAndPause(); - } - else if (Configuration.Settings.General.ListViewDoubleClickAction == 2) - { - if (AutoRepeatContinueOn || AutoRepeatOn) - { - PlayCurrent(); - } - else - { - buttonBeforeText_Click(null, null); - } - } - else if (Configuration.Settings.General.ListViewDoubleClickAction == 3) - { - GotoSubPositionAndPause(-0.5); - } - else if (Configuration.Settings.General.ListViewDoubleClickAction == 4) - { - GotoSubPositionAndPause(-1.0); - } - else if (Configuration.Settings.General.ListViewDoubleClickAction == 5) - { - if (AutoRepeatContinueOn || AutoRepeatOn) - { - PlayCurrent(); - } - else - { - if (SubtitleListview1.SelectedItems.Count > 0) - { - int index = SubtitleListview1.SelectedItems[0].Index; - - mediaPlayer.Pause(); - double pos = _subtitle.Paragraphs[index].StartTime.TotalSeconds; - if (pos > 1) - { - mediaPlayer.CurrentPosition = (_subtitle.Paragraphs[index].StartTime.TotalSeconds) - 1.0; - } - else - { - mediaPlayer.CurrentPosition = _subtitle.Paragraphs[index].StartTime.TotalSeconds; - } - - mediaPlayer.Play(); - } - } - } - else if (Configuration.Settings.General.ListViewDoubleClickAction == 6) - { - GotoSubPositionAndPause(); - textBoxListViewText.Focus(); - } - else if (Configuration.Settings.General.ListViewDoubleClickAction == 7) - { - textBoxListViewText.Focus(); - } - } - - private void AddWordToNameListToolStripMenuItemClick(object sender, EventArgs e) - { - using (var addToNamesList = new AddToNameList()) - { - addToNamesList.Initialize(_subtitle, textBoxListViewText.SelectedText); - if (addToNamesList.ShowDialog(this) == DialogResult.OK) - { - ShowStatus(string.Format(_language.NameXAddedToNameList, addToNamesList.NewName)); - } - else if (!string.IsNullOrEmpty(addToNamesList.NewName)) - { - ShowStatus(string.Format(_language.NameXNotAddedToNameList, addToNamesList.NewName)); - } - } - } - - private bool IsUnicode - { - get - { - var enc = GetCurrentEncoding(); - return enc == Encoding.UTF8 || enc == Encoding.Unicode || enc == Encoding.UTF7 || enc == Encoding.UTF32 || enc == Encoding.BigEndianUnicode; - } - } - - private void EditToolStripMenuItemDropDownOpening(object sender, EventArgs e) - { - toolStripMenuItemRemoveUnicodeControlChars.Visible = IsUnicode; - toolStripMenuItemRtlUnicodeControlChars.Visible = IsUnicode; - if (!IsUnicode || _subtitleListViewIndex == -1) - { - toolStripMenuItemInsertUnicodeCharacter.Visible = false; - toolStripSeparatorInsertUnicodeCharacter.Visible = false; - } - else - { - if (toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Count == 0) - { - foreach (var s in Configuration.Settings.Tools.UnicodeSymbolsToInsert.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) - { - toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Add(s, null, InsertUnicodeGlyphAllowMultiLine); - if (Environment.OSVersion.Version.Major < 6 && Configuration.Settings.General.SubtitleFontName == Utilities.WinXP2KUnicodeFontName) // 6 == Vista/Win2008Server/Win7 - { - toolStripMenuItemInsertUnicodeCharacter.DropDownItems[toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Count - 1].Font = new Font(Utilities.WinXP2KUnicodeFontName, toolStripMenuItemInsertUnicodeSymbol.Font.Size); - } - } - } - - toolStripMenuItemInsertUnicodeCharacter.Visible = toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Count > 0; - toolStripSeparatorInsertUnicodeCharacter.Visible = toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Count > 0; - } - - lock (_syncUndo) - { - toolStripMenuItemUndo.Enabled = _subtitle != null && _subtitle.CanUndo && _undoIndex >= 0; - toolStripMenuItemRedo.Enabled = _subtitle != null && _subtitle.CanUndo && _undoIndex < _subtitle.HistoryItems.Count - 1; - } - - showHistoryforUndoToolStripMenuItem.Enabled = _subtitle != null && _subtitle.CanUndo; - toolStripMenuItemShowOriginalInPreview.Visible = SubtitleListview1.IsAlternateTextColumnVisible; - - if (_networkSession != null) - { - toolStripMenuItemUndo.Enabled = false; - toolStripMenuItemRedo.Enabled = false; - showHistoryforUndoToolStripMenuItem.Enabled = false; - } - } - - private void InsertUnicodeGlyph(object sender, EventArgs e) - { - if (sender is ToolStripItem item) - { - PasteIntoActiveTextBox(item.Text); - } - } - - private void InsertUnicodeGlyphAllowMultiLine(object sender, EventArgs e) - { - if (sender is ToolStripItem item) - { - PasteIntoActiveTextBox(item.Text, true); - } - } - - private void ToolStripMenuItemAutoMergeShortLinesClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - using (var formMergeShortLines = new MergeShortLines()) - { - formMergeShortLines.Initialize(_subtitle); - if (formMergeShortLines.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeMergeShortLines); - _subtitle.Paragraphs.Clear(); - foreach (var p in formMergeShortLines.MergedSubtitle.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - _subtitle.Renumber(); - - ShowStatus(string.Format(_language.MergedShortLinesX, formMergeShortLines.NumberOfMerges)); - SaveSubtitleListviewIndices(); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - } - - private void toolStripMenuItemAutoSplitLongLines_Click(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - using (var splitLongLines = new SplitLongLines()) - { - splitLongLines.Initialize(_subtitle); - if (splitLongLines.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeSplitLongLines); - _subtitle.Paragraphs.Clear(); - foreach (var p in splitLongLines.SplitSubtitle.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowStatus(string.Format(_language.LongLinesSplitX, splitLongLines.NumberOfSplits)); - SaveSubtitleListviewIndices(); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - } - - private void SetMinimalDisplayTimeDifferenceToolStripMenuItemClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - using (var setMinDisplayDiff = new SetMinimumDisplayTimeBetweenParagraphs()) - { - setMinDisplayDiff.Initialize(_subtitle); - if (setMinDisplayDiff.ShowDialog() == DialogResult.OK && setMinDisplayDiff.FixCount > 0) - { - MakeHistoryForUndo(_language.BeforeSetMinimumDisplayTimeBetweenParagraphs); - _subtitle.Paragraphs.Clear(); - foreach (var p in setMinDisplayDiff.FixedSubtitle.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowStatus(string.Format(_language.XMinimumDisplayTimeBetweenParagraphsChanged, setMinDisplayDiff.FixCount)); - SaveSubtitleListviewIndices(); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - } - - private void ToolStripMenuItemImportTextClick(object sender, EventArgs e) - { - ImportPlainText(null); - } - - private void ImportPlainText(string fileName) - { - using (var importText = new ImportText(fileName, this)) - { - if (importText.ShowDialog(this) == DialogResult.OK) - { - if (ContinueNewOrExit()) - { - MakeHistoryForUndo(_language.BeforeImportText); - - ResetSubtitle(); - if (!string.IsNullOrEmpty(importText.VideoFileName)) - { - if (!Configuration.Settings.General.DisableVideoAutoLoading) - { - OpenVideo(importText.VideoFileName); - } - - _fileName = importText.VideoFileName; - _converted = true; - SetTitle(); - } - - _subtitleListViewIndex = -1; - if (importText.Format != null) - { - SetCurrentFormat(importText.Format); - } - - _subtitle = new Subtitle(importText.FixedSubtitle.Paragraphs, _subtitle.HistoryItems); - ShowStatus(_language.TextImported); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - } - } - } - } - - private void toolStripMenuItemPointSync_Click(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - using (var pointSync = new SyncPointsSync()) - { - pointSync.Initialize(_subtitle, _fileName, VideoFileName, VideoAudioTrackNumber); - mediaPlayer.Pause(); - if (pointSync.ShowDialog(this) == DialogResult.OK) - { - _subtitleListViewIndex = -1; - MakeHistoryForUndo(_language.BeforePointSynchronization); - _subtitle.Paragraphs.Clear(); - foreach (var p in pointSync.FixedSubtitle.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - ShowStatus(_language.PointSynchronizationDone); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - Activate(); - VideoFileName = pointSync.VideoFileName; - } - } - - private void pointSyncViaOtherSubtitleToolStripMenuItem_Click(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - using (var pointSync = new SyncPointsSync()) - { - openFileDialog1.Title = _language.OpenOtherSubtitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - if (openFileDialog1.ShowDialog() == DialogResult.OK && File.Exists(openFileDialog1.FileName)) - { - var file = new FileInfo(openFileDialog1.FileName); - var fileName = file.FullName; - var extension = file.Extension.ToLowerInvariant(); - - // TODO: Check for mkv etc - if (extension == ".sub") - { - if (IsVobSubFile(fileName, false)) - { - MessageBox.Show(_language.NoSupportHereVobSub); - return; - } - } - - if (extension == ".sup") - { - if (FileUtil.IsBluRaySup(fileName)) - { - MessageBox.Show(_language.NoSupportHereBluRaySup); - return; - } - else if (FileUtil.IsSpDvdSup(fileName)) - { - MessageBox.Show(_language.NoSupportHereDvdSup); - return; - } - } - - var sub = new Subtitle(); - if (extension == ".mkv" || extension == ".mks") - { - using (var matroska = new MatroskaFile(fileName)) - { - if (matroska.IsValid) - { - var subtitleList = matroska.GetTracks(true); - if (subtitleList.Count > 1) - { - using (var subtitleChooser = new MatroskaSubtitleChooser("mkv")) - { - subtitleChooser.Initialize(subtitleList); - if (_loading) - { - subtitleChooser.Icon = (Icon)Icon.Clone(); - subtitleChooser.ShowInTaskbar = true; - subtitleChooser.ShowIcon = true; - } - - if (subtitleChooser.ShowDialog(this) == DialogResult.OK) - { - sub = LoadMatroskaSubtitleForSync(subtitleList[subtitleChooser.SelectedIndex], matroska); - } - } - } - else if (subtitleList.Count > 0) - { - sub = LoadMatroskaSubtitleForSync(subtitleList[0], matroska); - } - else - { - MessageBox.Show(_language.NoSubtitlesFound); - return; - } - } - } - } - - if (extension == ".divx" || extension == ".avi") - { - MessageBox.Show(_language.NoSupportHereDivx); - return; - } - - if ((extension == ".mp4" || extension == ".m4v" || extension == ".3gp") && file.Length > 10000) - { - var mp4Parser = new MP4Parser(fileName); - var mp4SubtitleTracks = mp4Parser.GetSubtitleTracks(); - if (mp4SubtitleTracks.Count == 0) - { - MessageBox.Show(_language.NoSubtitlesFound); - return; - } - else if (mp4SubtitleTracks.Count == 1) - { - sub = LoadMp4SubtitleForSync(mp4SubtitleTracks[0]); - } - else - { - using (var subtitleChooser = new MatroskaSubtitleChooser("mp4")) - { - subtitleChooser.Initialize(mp4SubtitleTracks); - if (subtitleChooser.ShowDialog(this) == DialogResult.OK) - { - sub = LoadMp4SubtitleForSync(mp4SubtitleTracks[0]); - } - } - } - } - - if (file.Length > 1024 * 1024 * 10 && sub.Paragraphs.Count == 0) // max 10 mb - { - var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, fileName); - if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return; - } - } - - sub.Renumber(); - if (sub.Paragraphs.Count == 0) - { - var f = sub.LoadSubtitle(fileName, out var enc, null); - if (f == null) - { - ShowUnknownSubtitle(fileName); - return; - } - } - - pointSync.Initialize(_subtitle, _fileName, VideoFileName, VideoAudioTrackNumber, fileName, sub); - mediaPlayer.Pause(); - if (pointSync.ShowDialog(this) == DialogResult.OK) - { - _subtitleListViewIndex = -1; - MakeHistoryForUndo(_language.BeforePointSynchronization); - _subtitle.Paragraphs.Clear(); - foreach (var p in pointSync.FixedSubtitle.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - ShowStatus(_language.PointSynchronizationDone); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - VideoFileName = pointSync.VideoFileName; - } - } - } - - private void toolStripMenuItemImportTimeCodes_Click(object sender, EventArgs e) - { - if (_subtitle.Paragraphs.Count < 1) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - openFileDialog1.Title = _languageGeneral.OpenSubtitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - var timeCodeSubtitle = new Subtitle(); - SubtitleFormat format = null; - - if (format == null && - openFileDialog1.FileName.EndsWith(".sup", StringComparison.OrdinalIgnoreCase) && - FileUtil.IsBluRaySup(openFileDialog1.FileName)) - { - var log = new StringBuilder(); - var subtitles = BluRaySupParser.ParseBluRaySup(openFileDialog1.FileName, log); - if (subtitles.Count > 0) - { - foreach (var sup in subtitles) - { - timeCodeSubtitle.Paragraphs.Add(new Paragraph(sup.StartTimeCode, sup.EndTimeCode, string.Empty)); - } - - format = new SubRip(); // just to set format to something - } - } - - if (format == null) - { - format = timeCodeSubtitle.LoadSubtitle(openFileDialog1.FileName, out var encoding, null); - } - - if (format == null) - { - var formats = SubtitleFormat.GetBinaryFormats(true).Union(SubtitleFormat.GetTextOtherFormats()).Union(new SubtitleFormat[] - { - new TimeCodesOnly1(), - new TimeCodesOnly2() - }).ToArray(); - format = SubtitleFormat.LoadSubtitleFromFile(formats, openFileDialog1.FileName, timeCodeSubtitle); - } - - if (format == null) - { - ShowUnknownSubtitle(openFileDialog1.FileName); - return; - } - - if (timeCodeSubtitle.Paragraphs.Count != _subtitle.Paragraphs.Count) - { - var text = string.Format(_language.ImportTimeCodesDifferentNumberOfLinesWarning, timeCodeSubtitle.Paragraphs.Count, _subtitle.Paragraphs.Count); - if (MessageBox.Show(this, text, _title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return; - } - } - - MakeHistoryForUndo(_language.BeforeTimeCodeImport); - - int count = 0; - for (int i = 0; i < timeCodeSubtitle.Paragraphs.Count; i++) - { - var existing = _subtitle.GetParagraphOrDefault(i); - - var newTimeCode = timeCodeSubtitle.GetParagraphOrDefault(i); - if (existing == null || newTimeCode == null) - { - break; - } - - Paragraph original = null; - if (existing != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && - _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0 && SubtitleListview1.IsAlternateTextColumnVisible) - { - original = Utilities.GetOriginalParagraph(i, existing, _subtitleAlternate.Paragraphs); - } - - existing.StartTime.TotalMilliseconds = newTimeCode.StartTime.TotalMilliseconds; - existing.EndTime.TotalMilliseconds = newTimeCode.EndTime.TotalMilliseconds; - - if (original != null) - { - original.StartTime.TotalMilliseconds = newTimeCode.StartTime.TotalMilliseconds; - original.EndTime.TotalMilliseconds = newTimeCode.EndTime.TotalMilliseconds; - } - - count++; - } - - ShowStatus(string.Format(_language.TimeCodeImportedFromXY, Path.GetFileName(openFileDialog1.FileName), count)); - SaveSubtitleListviewIndices(); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - - private void toolStripMenuItemTranslationMode_Click(object sender, EventArgs e) - { - if (_subtitle == null || _subtitle.Paragraphs.Count == 0) - { - return; - } - - if (SubtitleListview1.IsAlternateTextColumnVisible) - { - RemoveAlternate(true, true); - } - else - { - OpenAlternateSubtitle(); - SetTitle(); - } - } - - private void OpenAlternateSubtitle() - { - if (ContinueNewOrExitAlternate()) - { - SaveSubtitleListviewIndices(); - openFileDialog1.Title = _languageGeneral.OpenOriginalSubtitleFile; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - if (openFileDialog1.ShowDialog(this) != DialogResult.OK) - { - return; - } - - if (!LoadAlternateSubtitleFile(openFileDialog1.FileName)) - { - return; - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - - Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - Configuration.Settings.Save(); - UpdateRecentFilesUI(); - MainResize(); - if (SubtitleListview1.SelectedIndices.Count == 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - } - RefreshSelectedParagraph(); - } - } - - private bool LoadAlternateSubtitleFile(string fileName) - { - if (!File.Exists(fileName)) - { - return false; - } - - var file = new FileInfo(fileName); - - if (file.Extension.Equals(".sub", StringComparison.OrdinalIgnoreCase) && IsVobSubFile(fileName, false)) - { - return false; - } - - if (file.Length > 1024 * 1024 * 10) // max 10 mb - { - var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, fileName); - if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return false; - } - } - - _subtitleAlternate = new Subtitle(); - _subtitleAlternateFileName = fileName; - SubtitleFormat format = _subtitleAlternate.LoadSubtitle(fileName, out _, null); - - if (format == null) - { - foreach (var binaryFormat in SubtitleFormat.GetBinaryFormats(false)) - { - if (binaryFormat.IsMine(null, fileName)) - { - binaryFormat.LoadSubtitle(_subtitleAlternate, null, fileName); - format = binaryFormat; - break; - } - } - } - - if (format == null) - { - var lines = FileUtil.ReadAllTextShared(fileName, LanguageAutoDetect.GetEncodingFromFile(fileName)).SplitToLines(); - foreach (var f in SubtitleFormat.GetTextOtherFormats()) - { - if (f.IsMine(lines, fileName)) - { - f.LoadSubtitle(_subtitleAlternate, lines, fileName); - format = f; - break; - } - } - } - - if (format == null) - { - return false; - } - - SetupAlternateEdit(); - FixRightToLeftDependingOnLanguage(); - return true; - } - - private void SetupAlternateEdit() - { - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate.Paragraphs.Count > 0) - { - InsertMissingParagraphs(_subtitle, _subtitleAlternate); - InsertMissingParagraphs(_subtitleAlternate, _subtitle); - - buttonUnBreak.Visible = false; - buttonAutoBreak.Visible = false; - buttonSplitLine.Visible = false; - - textBoxListViewText.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; - textBoxListViewText.Width = (groupBoxEdit.Width - (textBoxListViewText.Left + 10)) / 2; - textBoxListViewTextAlternate.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; - textBoxListViewTextAlternate.Left = textBoxListViewText.Left + textBoxListViewText.Width + 3; - textBoxListViewTextAlternate.Width = textBoxListViewText.Width; - textBoxListViewTextAlternate.Visible = true; - labelAlternateText.Text = _languageGeneral.OriginalText; - labelAlternateText.Visible = true; - labelAlternateCharactersPerSecond.Visible = true; - labelTextAlternateLineLengths.Visible = true; - labelAlternateSingleLine.Visible = true; - labelAlternateSingleLinePixels.Visible = true; - labelTextAlternateLineTotal.Visible = true; - - labelCharactersPerSecond.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelCharactersPerSecond.Width); - labelTextLineTotal.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelTextLineTotal.Width); - Main_Resize(null, null); - _changeAlternateSubtitleHash = _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName); - - SetTitle(); - } - - SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); - SubtitleListview1.AutoSizeAllColumns(this); - } - - private static void InsertMissingParagraphs(Subtitle masterSubtitle, Subtitle insertIntoSubtitle) - { - int index = 0; - foreach (var p in masterSubtitle.Paragraphs) - { - var insertParagraph = Utilities.GetOriginalParagraph(index, p, insertIntoSubtitle.Paragraphs); - if (insertParagraph == null) - { - insertParagraph = new Paragraph(p); - insertParagraph.Text = string.Empty; - if (p.StartTime.IsMaxTime) - { - insertIntoSubtitle.Paragraphs.Add(new Paragraph(p, true) { Text = string.Empty }); - } - else - { - insertIntoSubtitle.InsertParagraphInCorrectTimeOrder(insertParagraph); - } - } - - index++; - } - - insertIntoSubtitle.Renumber(); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - private void OpenVideo(string fileName) - { - if (!_resetVideo) - { - return; - } - - if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) - { - if (_loading) - { - VideoFileName = fileName; - return; - } - - var fi = new FileInfo(fileName); - if (fi.Length < 1000) - { - return; - } - - ShowSubtitleTimer.Stop(); - Cursor = Cursors.WaitCursor; - VideoFileName = fileName; - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.PauseAndDisposePlayer(); - } - - _endSeconds = -1; - - _videoInfo = UiUtil.GetVideoInfo(fileName); - if (_videoInfo.FramesPerSecond > 0) - { - toolStripComboBoxFrameRate.Text = string.Format("{0:0.###}", _videoInfo.FramesPerSecond); - } - - string oldVideoPlayer = Configuration.Settings.General.VideoPlayer; - var ok = UiUtil.InitializeVideoPlayerAndContainer(fileName, _videoInfo, mediaPlayer, VideoLoaded, VideoEnded); - if (!ok && oldVideoPlayer != Configuration.Settings.General.VideoPlayer) - { - CloseVideoToolStripMenuItemClick(null, null); - VideoFileName = fileName; - _videoInfo = UiUtil.GetVideoInfo(fileName); - UiUtil.InitializeVideoPlayerAndContainer(fileName, _videoInfo, mediaPlayer, VideoLoaded, VideoEnded); - } - - mediaPlayer.Volume = 0; - mediaPlayer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton; - mediaPlayer.OnButtonClicked -= MediaPlayer_OnButtonClicked; - mediaPlayer.OnButtonClicked += MediaPlayer_OnButtonClicked; - - if (_videoInfo.VideoCodec != null) - { - labelVideoInfo.Text = Path.GetFileName(fileName) + " " + _videoInfo.Width + "x" + _videoInfo.Height + " " + _videoInfo.VideoCodec.Trim(); - } - else - { - labelVideoInfo.Text = Path.GetFileName(fileName) + " " + _videoInfo.Width + "x" + _videoInfo.Height; - } - - if (_videoInfo.FramesPerSecond > 0) - { - labelVideoInfo.Text = labelVideoInfo.Text + " " + string.Format("{0:0.0##}", _videoInfo.FramesPerSecond); - } - - - string peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(fileName); - string spectrogramFolder = WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(fileName); - if (File.Exists(peakWaveFileName)) - { - audioVisualizer.ZoomFactor = 1.0; - audioVisualizer.VerticalZoomFactor = 1.0; - SelectZoomTextInComboBox(); - audioVisualizer.WavePeaks = WavePeakData.FromDisk(peakWaveFileName); - audioVisualizer.SetSpectrogram(SpectrogramData.FromDisk(spectrogramFolder)); - audioVisualizer.SceneChanges = SceneChangeHelper.FromDisk(VideoFileName); - SetWaveformPosition(0, 0, 0); - timerWaveform.Start(); - } - - Cursor = Cursors.Default; - - SetUndockedWindowsTitle(); - ShowSubtitleTimer.Start(); - } - } - - private void MediaPlayer_OnButtonClicked(object sender, EventArgs e) - { - if (sender is PictureBox pb && pb.Name == "_pictureBoxFullscreenOver") - { - if (_videoPlayerUndocked != null && !_videoPlayerUndocked.IsDisposed && _videoPlayerUndocked.IsFullscreen) - { - _videoPlayerUndocked.NoFullscreen(); - } - else - { - GoFullscreen(false); - } - } - } - - private void SetWaveformPosition(double startPositionSeconds, double currentVideoPositionSeconds, int subtitleIndex) - { - if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable) - { - int index = -1; - if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle.Paragraphs.Count > 0) - { - int i = SubtitleListview1.SelectedItems[0].Index; - var p = Utilities.GetOriginalParagraph(i, _subtitle.Paragraphs[i], _subtitleAlternate.Paragraphs); - index = _subtitleAlternate.GetIndex(p); - } - - audioVisualizer.SetPosition(startPositionSeconds, _subtitleAlternate, currentVideoPositionSeconds, index, SubtitleListview1.SelectedIndices); - } - else - { - audioVisualizer.SetPosition(startPositionSeconds, _subtitle, currentVideoPositionSeconds, subtitleIndex, SubtitleListview1.SelectedIndices); - } - } - - private void VideoLoaded(object sender, EventArgs e) - { - if (_loading) - { - Application.DoEvents(); - } - - mediaPlayer.Volume = Configuration.Settings.General.VideoPlayerDefaultVolume; - timer1.Start(); - - trackBarWaveformPosition.Maximum = (int)mediaPlayer.Duration; - - if (_videoLoadedGoToSubPosAndPause) - { - Application.DoEvents(); - _videoLoadedGoToSubPosAndPause = false; - GotoSubPositionAndPause(); - } - - mediaPlayer.Pause(); - mediaPlayer.UpdatePlayerName(); - - // Keep current play rate - for (var index = 0; index < toolStripSplitButtonPlayRate.DropDownItems.Count; index++) - { - var item = (ToolStripMenuItem)toolStripSplitButtonPlayRate.DropDownItems[index]; - if (item.Checked) - { - SetPlayRate(item, null, true); - break; - } - } - - if (mediaPlayer.VideoPlayer is LibMpvDynamic && !Configuration.Settings.General.MpvHandlesPreviewText) - { - (mediaPlayer.VideoPlayer as LibMpvDynamic)?.RemoveSubtitle(); - } - - if (trackBarWaveformPosition.Maximum <= 0) - { - trackBarWaveformPosition.Maximum = (int)mediaPlayer.Duration; - } - } - - private void VideoEnded(object sender, EventArgs e) - { - mediaPlayer.Pause(); - } - - private void TryToFindAndOpenVideoFile(string fileNameNoExtension) - { - string movieFileName = null; - - foreach (var extension in Utilities.VideoFileExtensions) - { - var fileName = fileNameNoExtension + extension; - if (File.Exists(fileName)) - { - bool skipLoad = false; - if (extension == ".m2ts" && new FileInfo(fileName).Length < 2000000) - { - var textSt = new TextST(); - skipLoad = textSt.IsMine(null, fileName); // don't load TextST files as video/audio file - } - - if (!skipLoad) - { - movieFileName = fileName; - break; - } - } - } - - if (movieFileName != null) - { - OpenVideo(movieFileName); - } - else - { - var index = fileNameNoExtension.LastIndexOf('.'); - if (index > 0) - { - TryToFindAndOpenVideoFile(fileNameNoExtension.Remove(index)); - } - } - } - - internal void GoBackSeconds(double seconds) - { - if (mediaPlayer.CurrentPosition > seconds) - { - mediaPlayer.CurrentPosition -= seconds; - } - else - { - mediaPlayer.CurrentPosition = 0; - } - - ShowSubtitle(); - } - - private void ButtonStartHalfASecondBackClick(object sender, EventArgs e) - { - GoBackSeconds(0.5); - } - - private void ButtonStartThreeSecondsBackClick(object sender, EventArgs e) - { - GoBackSeconds(3.0); - } - - private void ButtonStartOneMinuteBackClick(object sender, EventArgs e) - { - GoBackSeconds(60); - } - - private void ButtonStartHalfASecondAheadClick(object sender, EventArgs e) - { - GoBackSeconds(-0.5); - } - - private void ButtonStartThreeSecondsAheadClick(object sender, EventArgs e) - { - GoBackSeconds(-3); - } - - private void ButtonStartOneMinuteAheadClick(object sender, EventArgs e) - { - GoBackSeconds(-60); - } - - private void ShowSubtitleTimerTick(object sender, EventArgs e) - { - ShowSubtitleTimer.Stop(); - - if (_subtitle == null || _subtitle.Paragraphs.Count == 0) - { - ShowSubtitleTimer.Interval = 250; - } - else - { - ShowSubtitleTimer.Interval = 17; - } - - if (mediaPlayer.VideoPlayer != null) - { - int oldIndex = FirstSelectedIndex; - int index = ShowSubtitle(); - if (index != -1 && checkBoxSyncListViewWithVideoWhilePlaying.Checked && oldIndex != index) - { - if ((DateTime.UtcNow.Ticks - _lastTextKeyDownTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds - { - if (_endSeconds <= 0 || !checkBoxAutoRepeatOn.Checked) - { - if (!timerAutoDuration.Enabled && !mediaPlayer.IsPaused && (mediaPlayer.CurrentPosition > 0.2 || index > 0)) - { - SubtitleListview1.SelectIndexAndEnsureVisibleFaster(index); - } - } - } - } - } - - var currentChanged = _changeSubtitleHash != _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - var originalActive = Configuration.Settings.General.AllowEditOfOriginalSubtitle && - _subtitleAlternate != null && - _subtitleAlternate.Paragraphs.Count > 0; - var originalChanged = originalActive && - _changeAlternateSubtitleHash != _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName); - if (currentChanged || originalChanged) - { - AddTitleBarChangeAsterisk(currentChanged, originalChanged, originalActive); - AutoSave(); - } - else if (Text.Contains('*')) - { - Text = Text.RemoveChar('*').TrimEnd(); - } - - ShowSubtitleTimer.Start(); - } - - private void AddTitleBarChangeAsterisk(bool currentChanged, bool originalChanged, bool originalActive) - { - if (Configuration.Settings.General.TitleBarAsterisk.Equals("before", StringComparison.Ordinal)) - { - if (!Text.Contains('*')) - { - Text = "*" + Text; - } - } - else if (Configuration.Settings.General.TitleBarAsterisk.Equals("after", StringComparison.Ordinal)) - { - var s = Text.RemoveChar('*').TrimEnd(); - if (currentChanged && !originalActive || originalChanged) - { - var length = Title.Length; - if (s.Length > length) - { - s = s.Substring(0, s.Length - length).TrimEnd(' ', '*', '-') + "* - " + Title; - } - } - if (currentChanged) - { - s = s.Replace(" + ", "* + "); - } - - Text = s; - } - } - - private void HideVideoPlayer() - { - mediaPlayer.Pause(); - - int textHeight = splitContainerListViewAndText.Height - splitContainerListViewAndText.SplitterDistance; - - splitContainer1.Panel2Collapsed = true; - splitContainerMain.Panel2Collapsed = true; - Main_Resize(null, null); - - splitContainerListViewAndText.SplitterDistance = splitContainerListViewAndText.Height - textHeight; - } - - private void ShowVideoPlayer() - { - if (_isVideoControlsUndocked) - { - ShowHideUndockedVideoControls(); - } - else - { - if (toolStripButtonToggleVideo.Checked && toolStripButtonToggleWaveform.Checked) - { - splitContainer1.Panel2Collapsed = false; - MoveVideoUp(); - } - else - { - splitContainer1.Panel2Collapsed = true; - MoveVideoDown(); - } - - splitContainerMain.Panel2Collapsed = false; - if (toolStripButtonToggleVideo.Checked) - { - if (audioVisualizer.Visible) - { - audioVisualizer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; - } - else - { - panelVideoPlayer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; - } - } - else if (audioVisualizer.Visible) - { - audioVisualizer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; - } - - audioVisualizer.Width = groupBoxVideo.Width - (audioVisualizer.Left + 10); - - checkBoxSyncListViewWithVideoWhilePlaying.Left = tabControlButtons.Left + tabControlButtons.Width + 5; - panelWaveformControls.Left = audioVisualizer.Left; - trackBarWaveformPosition.Left = panelWaveformControls.Left + panelWaveformControls.Width + 5; - trackBarWaveformPosition.Width = audioVisualizer.Left + audioVisualizer.Width - trackBarWaveformPosition.Left + 5; - } - - if (mediaPlayer.VideoPlayer == null && !string.IsNullOrEmpty(_fileName) && string.IsNullOrEmpty(VideoFileName) && !Configuration.Settings.General.DisableVideoAutoLoading) - { - TryToFindAndOpenVideoFile(Utilities.GetPathAndFileNameWithoutExtension(_fileName)); - } - - Main_Resize(null, null); - } - - private void ShowHideUndockedVideoControls() - { - if (_videoPlayerUndocked == null || _videoPlayerUndocked.IsDisposed) - { - UnDockVideoPlayer(); - } - - _videoPlayerUndocked.Visible = false; - if (toolStripButtonToggleVideo.Checked) - { - _videoPlayerUndocked.Show(this); - if (_videoPlayerUndocked.WindowState == FormWindowState.Minimized) - { - _videoPlayerUndocked.WindowState = FormWindowState.Normal; - } - } - - if (_waveformUndocked == null || _waveformUndocked.IsDisposed) - { - UnDockWaveform(); - } - - _waveformUndocked.Visible = false; - if (toolStripButtonToggleWaveform.Checked) - { - _waveformUndocked.Show(this); - if (_waveformUndocked.WindowState == FormWindowState.Minimized) - { - _waveformUndocked.WindowState = FormWindowState.Normal; - } - } - - if (toolStripButtonToggleVideo.Checked || toolStripButtonToggleWaveform.Checked) - { - if (_videoControlsUndocked == null || _videoControlsUndocked.IsDisposed) - { - UnDockVideoButtons(); - } - - _videoControlsUndocked.Visible = false; - _videoControlsUndocked.Show(this); - } - else - { - if (_videoControlsUndocked != null && !_videoControlsUndocked.IsDisposed) - { - _videoControlsUndocked.Visible = false; - } - } - } - - private void MoveVideoUp() - { - if (splitContainer1.Panel2.Controls.Count == 0) - { - var control = panelVideoPlayer; - groupBoxVideo.Controls.Remove(control); - splitContainer1.Panel2.Controls.Add(control); - } - - panelVideoPlayer.Top = 0; - panelVideoPlayer.Left = 0; - panelVideoPlayer.Height = splitContainer1.Panel2.Height - 2; - panelVideoPlayer.Width = splitContainer1.Panel2.Width - 2; - } - - private void MoveVideoDown() - { - if (splitContainer1.Panel2.Controls.Count > 0) - { - var control = panelVideoPlayer; - splitContainer1.Panel2.Controls.Clear(); - groupBoxVideo.Controls.Add(control); - } - - panelVideoPlayer.Top = 32; - panelVideoPlayer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; - panelVideoPlayer.Height = groupBoxVideo.Height - (panelVideoPlayer.Top + 5); - panelVideoPlayer.Width = groupBoxVideo.Width - (panelVideoPlayer.Left + 5); - } - - private void FixLargeFonts() - { - using (var graphics = CreateGraphics()) - { - var textSize = graphics.MeasureString(buttonPlayPrevious.Text, Font); - if (textSize.Height > buttonPlayPrevious.Height - 4) - { - int newButtonHeight = 23; - UiUtil.SetButtonHeight(this, newButtonHeight, -4); - - // List view - SubtitleListview1.InitializeTimestampColumnWidths(this); - const int adjustUp = 8; - SubtitleListview1.Height = SubtitleListview1.Height - adjustUp; - groupBoxEdit.Top = groupBoxEdit.Top - adjustUp; - groupBoxEdit.Height = groupBoxEdit.Height + adjustUp; - numericUpDownDuration.Left = timeUpDownStartTime.Left + timeUpDownStartTime.Width; - numericUpDownDuration.Width = numericUpDownDuration.Width + 5; - labelDuration.Left = numericUpDownDuration.Left - 3; - - // Video controls - Create - timeUpDownVideoPosition.Left = labelVideoPosition.Left + labelVideoPosition.Width; - int buttonWidth = labelVideoPosition.Width + timeUpDownVideoPosition.Width; - buttonInsertNewText.Width = buttonWidth; - buttonBeforeText.Width = buttonWidth; - buttonGotoSub.Width = buttonWidth; - buttonSetStartTime.Width = buttonWidth; - buttonSetEnd.Width = buttonWidth; - int FKeyLeft = buttonInsertNewText.Left + buttonInsertNewText.Width; - labelCreateF9.Left = FKeyLeft; - labelCreateF10.Left = FKeyLeft; - labelCreateF11.Left = FKeyLeft; - labelCreateF12.Left = FKeyLeft; - buttonForward1.Left = buttonInsertNewText.Left + buttonInsertNewText.Width - buttonForward1.Width; - numericUpDownSec1.Width = buttonInsertNewText.Width - (numericUpDownSec1.Left + buttonForward1.Width); - buttonForward2.Left = buttonInsertNewText.Left + buttonInsertNewText.Width - buttonForward2.Width; - numericUpDownSec2.Width = buttonInsertNewText.Width - (numericUpDownSec2.Left + buttonForward2.Width); - - // Video controls - Adjust - timeUpDownVideoPositionAdjust.Left = labelVideoPosition2.Left + labelVideoPosition2.Width; - buttonSetStartAndOffsetRest.Width = buttonWidth; - buttonSetEndAndGoToNext.Width = buttonWidth; - buttonAdjustSetStartTime.Width = buttonWidth; - buttonAdjustSetEndTime.Width = buttonWidth; - buttonAdjustPlayBefore.Width = buttonWidth; - buttonAdjustGoToPosAndPause.Width = buttonWidth; - labelAdjustF9.Left = FKeyLeft; - labelAdjustF10.Left = FKeyLeft; - labelAdjustF11.Left = FKeyLeft; - labelAdjustF12.Left = FKeyLeft; - buttonAdjustSecForward1.Left = buttonInsertNewText.Left + buttonInsertNewText.Width - buttonAdjustSecForward1.Width; - numericUpDownSecAdjust1.Width = buttonInsertNewText.Width - (numericUpDownSecAdjust2.Left + buttonAdjustSecForward1.Width); - buttonAdjustSecForward2.Left = buttonInsertNewText.Left + buttonInsertNewText.Width - buttonAdjustSecForward2.Width; - numericUpDownSecAdjust2.Width = buttonInsertNewText.Width - (numericUpDownSecAdjust2.Left + buttonAdjustSecForward2.Width); - - tabControl1_SelectedIndexChanged(null, null); - } - } - } - - private void Main_Resize(object sender, EventArgs e) - { - if (_loading) - { - return; - } - - if (WindowState == FormWindowState.Maximized) - { - Main_ResizeEnd(sender, e); - return; - } - - panelVideoPlayer.Invalidate(); - } - - private void Main_ResizeEnd(object sender, EventArgs e) - { - if (_loading) - { - return; - } - - panelVideoPlayer.Invalidate(); - MainResize(); - - // Due to strange bug in listview when maximizing - SaveSubtitleListviewIndices(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex, true); - - panelVideoPlayer.Refresh(); - } - - private void MainResize() - { - var tbText = textBoxListViewText; - var tbOriginal = textBoxListViewTextAlternate; - int firstLeft = 236; - - var lbText = labelText; - var lbTextOriginal = labelAlternateText; - - var lbSingleLine = labelTextLineLengths; - var lbSingleLineOriginal = labelTextAlternateLineLengths; - - tbText.Left = firstLeft; - tbOriginal.Left = firstLeft; - lbText.Left = firstLeft; - lbTextOriginal.Left = firstLeft; - tbText.Width = groupBoxEdit.Width - (tbText.Left + 10 + (groupBoxEdit.Width - buttonUnBreak.Left)); - - if (Configuration.Settings.General.RightToLeftMode && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - tbText = textBoxListViewTextAlternate; - tbOriginal = textBoxListViewText; - - lbText = labelAlternateText; - lbTextOriginal = labelText; - - lbSingleLine = labelTextAlternateLineLengths; - lbSingleLineOriginal = labelTextLineLengths; - } - else - { - labelTextLineLengths.Left = firstLeft; - } - - tbText.Left = firstLeft; - lbText.Left = firstLeft; - lbSingleLine.Left = firstLeft; - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0 && - textBoxListViewTextAlternate.Visible) - { - tbText.Width = (groupBoxEdit.Width - (tbText.Left + 10)) / 2; - tbOriginal.Left = tbText.Left + tbText.Width + 3; - lbTextOriginal.Left = tbOriginal.Left; - - tbOriginal.Width = tbText.Width; - - labelAlternateCharactersPerSecond.Left = tbOriginal.Left + (tbOriginal.Width - labelAlternateCharactersPerSecond.Width); - lbSingleLineOriginal.Left = tbOriginal.Left; - labelAlternateSingleLine.Left = labelTextAlternateLineLengths.Left + labelTextAlternateLineLengths.Width; - labelAlternateSingleLinePixels.Left = labelAlternateSingleLine.Left + labelAlternateSingleLine.Width + 10; - labelTextAlternateLineTotal.Left = tbOriginal.Left + (tbOriginal.Width - labelTextAlternateLineTotal.Width); - if (textBoxListViewText.Width / 2.1 < labelTextLineLengths.Width) - { - labelTextAlternateLineTotal.Visible = false; - } - else - { - labelTextAlternateLineTotal.Visible = true; - } - - if (textBoxListViewText.Width / 3 < labelTextLineLengths.Width) - { - labelAlternateSingleLinePixels.Visible = false; - } - else - { - labelAlternateSingleLinePixels.Visible = Configuration.Settings.Tools.ListViewSyntaxColorWideLines; - } - } - - labelAlternateCharactersPerSecond.Top = labelCharactersPerSecond.Top; - labelCharactersPerSecond.Left = tbText.Left + (tbText.Width - labelCharactersPerSecond.Width); - labelTextLineTotal.Left = tbText.Left + (tbText.Width - labelTextLineTotal.Width); - SubtitleListview1.AutoSizeAllColumns(this); - - if (textBoxListViewText.Width / 2.1 < labelTextLineLengths.Width) - { - labelTextLineTotal.Visible = false; - } - else - { - labelTextLineTotal.Visible = true; - } - - if (textBoxListViewText.Width / 3 < labelTextLineLengths.Width) - { - labelSingleLinePixels.Visible = false; - } - else - { - labelSingleLinePixels.Visible = Configuration.Settings.Tools.ListViewSyntaxColorWideLines; - } - - FixRightToLeftDependingOnLanguage(); - } - - private void FixRightToLeftDependingOnLanguage() - { - if (Configuration.Settings.General.RightToLeftMode) - { - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - if (LanguageAutoDetect.CouldBeRightToLeftLanguage(_subtitleAlternate)) - { - textBoxListViewTextAlternate.RightToLeft = RightToLeft.Yes; - } - else - { - textBoxListViewTextAlternate.RightToLeft = RightToLeft.No; - } - } - - if (LanguageAutoDetect.CouldBeRightToLeftLanguage(_subtitle)) - { - textBoxListViewText.RightToLeft = RightToLeft.Yes; - textBoxSource.RightToLeft = RightToLeft.Yes; - } - else - { - - textBoxListViewText.RightToLeft = RightToLeft.No; - textBoxSource.RightToLeft = RightToLeft.No; - } - } - else - { - textBoxListViewText.RightToLeft = RightToLeft.No; - textBoxSource.RightToLeft = RightToLeft.No; - } - } - - private void PlayCurrent() - { - if (_subtitleListViewIndex >= 0) - { - GotoSubtitleIndex(_subtitleListViewIndex); - textBoxListViewText.Focus(); - ReadyAutoRepeat(); - PlayPart(_subtitle.Paragraphs[_subtitleListViewIndex]); - } - } - - private void ReadyAutoRepeat() - { - if (checkBoxAutoRepeatOn.Checked) - { - _repeatCount = int.Parse(comboBoxAutoRepeat.Text); - } - else - { - _repeatCount = -1; - } - - if (mediaPlayer.VideoPlayer != null) - { - labelStatus.Text = _language.VideoControls.Playing; - } - } - - private void PlayNext() - { - int newIndex = _subtitleListViewIndex + 1; - if (newIndex < _subtitle.Paragraphs.Count) - { - foreach (ListViewItem item in SubtitleListview1.SelectedItems) - { - item.Selected = false; - } - - SubtitleListview1.Items[newIndex].Selected = true; - SubtitleListview1.Items[newIndex].EnsureVisible(); - SubtitleListview1.Items[newIndex].Focused = true; - textBoxListViewText.Focus(); - textBoxListViewText.SelectAll(); - _subtitleListViewIndex = newIndex; - GotoSubtitleIndex(newIndex); - ShowSubtitle(); - PlayCurrent(); - } - } - - private void PlayPrevious() - { - if (_subtitleListViewIndex > 0) - { - int newIndex = _subtitleListViewIndex - 1; - foreach (ListViewItem item in SubtitleListview1.SelectedItems) - { - item.Selected = false; - } - - SubtitleListview1.Items[newIndex].Selected = true; - SubtitleListview1.Items[newIndex].EnsureVisible(); - SubtitleListview1.Items[newIndex].Focused = true; - textBoxListViewText.Focus(); - textBoxListViewText.SelectAll(); - GotoSubtitleIndex(newIndex); - ShowSubtitle(); - _subtitleListViewIndex = newIndex; - PlayCurrent(); - } - } - - private void GotoSubtitleIndex(int index) - { - if (mediaPlayer.VideoPlayer != null && mediaPlayer.Duration > 0) - { - mediaPlayer.CurrentPosition = _subtitle.Paragraphs[index].StartTime.TotalSeconds; - } - } - - private void PlayPart(Paragraph paragraph) - { - if (mediaPlayer.VideoPlayer != null) - { - double startSeconds = paragraph.StartTime.TotalSeconds; - if (startSeconds > 0.05) - { - startSeconds -= 0.05; // go a little back - } - - _endSeconds = paragraph.EndTime.TotalSeconds; - if (mediaPlayer.Duration > _endSeconds + 0.05) - { - _endSeconds += 0.05; // go a little forward - } - - mediaPlayer.CurrentPosition = startSeconds; - ShowSubtitle(); - mediaPlayer.Play(); - } - } - - private void buttonSetStartTime_Click(object sender, EventArgs e) - { - SetStartTime(false, mediaPlayer.CurrentPosition); - } - - private void SetStartTime(bool adjustEndTime, double videoPosition) - { - if (SubtitleListview1.SelectedItems.Count == 1) - { - timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; - int index = SubtitleListview1.SelectedItems[0].Index; - var p = _subtitle.Paragraphs[index]; - var oldParagraph = new Paragraph(p, false); - if (oldParagraph.StartTime.IsMaxTime || oldParagraph.EndTime.IsMaxTime) - { - adjustEndTime = true; - } - - if (!mediaPlayer.IsPaused) - { - videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; - } - - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + p.Number + " " + p.Text)); - - timeUpDownStartTime.TimeCode = TimeCode.FromSeconds(videoPosition); - - var duration = p.Duration.TotalMilliseconds; - - p.StartTime.TotalMilliseconds = videoPosition * TimeCode.BaseUnit; - if (adjustEndTime) - { - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + duration; - } - - if (oldParagraph.StartTime.IsMaxTime) - { - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text); - } - - SubtitleListview1.SetStartTimeAndDuration(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - timeUpDownStartTime.TimeCode = p.StartTime; - timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; - - if (!adjustEndTime) - { - SetDurationInSeconds(p.Duration.TotalSeconds); - } - - UpdateOriginalTimeCodes(oldParagraph); - ShowSource(); - RefreshSelectedParagraph(); - } - } - - private void ButtonSetEndClick(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedItems.Count == 1) - { - double videoPosition = mediaPlayer.CurrentPosition; - if (!mediaPlayer.IsPaused) - { - videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; - } - - int index = SubtitleListview1.SelectedItems[0].Index; - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + _subtitle.Paragraphs[index].Number + " " + _subtitle.Paragraphs[index].Text)); - - if (_subtitle.Paragraphs[index].StartTime.IsMaxTime) - { - timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; - _subtitle.Paragraphs[index].EndTime.TotalSeconds = videoPosition; - _subtitle.Paragraphs[index].StartTime.TotalMilliseconds = _subtitle.Paragraphs[index].EndTime.TotalMilliseconds - Utilities.GetOptimalDisplayMilliseconds(_subtitle.Paragraphs[index].Text); - if (_subtitle.Paragraphs[index].StartTime.TotalMilliseconds < 0) - { - _subtitle.Paragraphs[index].StartTime.TotalMilliseconds = 0; - } - - timeUpDownStartTime.TimeCode = _subtitle.Paragraphs[index].StartTime; - SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; - } - else - { - _subtitle.Paragraphs[index].EndTime = TimeCode.FromSeconds(videoPosition); - } - - SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds); - } - } - - private void ButtonInsertNewTextClick(object sender, EventArgs e) - { - mediaPlayer.Pause(); - - var newParagraph = InsertNewTextAtVideoPosition(); - - textBoxListViewText.Focus(); - timerAutoDuration.Start(); - - ShowStatus(string.Format(_language.VideoControls.NewTextInsertAtX, newParagraph.StartTime.ToShortString())); - } - - private Paragraph InsertNewTextAtVideoPosition() - { - // current movie Position - double videoPositionInMilliseconds = mediaPlayer.CurrentPosition * TimeCode.BaseUnit; - if (!mediaPlayer.IsPaused && videoPositionInMilliseconds > Configuration.Settings.General.SetStartEndHumanDelay) - { - videoPositionInMilliseconds -= Configuration.Settings.General.SetStartEndHumanDelay; - } - - var tc = new TimeCode(videoPositionInMilliseconds); - MakeHistoryForUndo(_language.BeforeInsertSubtitleAtVideoPosition + " " + tc); - - // find index where to insert - int index = 0; - foreach (var p in _subtitle.Paragraphs) - { - if (p.StartTime.TotalMilliseconds > videoPositionInMilliseconds) - { - break; - } - - index++; - } - - // prevent overlap - var endTotalMilliseconds = videoPositionInMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs; - var next = _subtitle.GetParagraphOrDefault(index); - if (next != null) - { - if (endTotalMilliseconds > next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines) - { - endTotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - } - } - - // create and insert - var newParagraph = new Paragraph(string.Empty, videoPositionInMilliseconds, endTotalMilliseconds); - SetStyleForNewParagraph(newParagraph, index); - if (_networkSession != null) - { - _networkSession.TimerStop(); - NetworkGetSendUpdates(new List(), index, newParagraph); - } - else - { - _subtitle.Paragraphs.Insert(index, newParagraph); - - // check if original is available - and insert new paragraph in the original too - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph)); - _subtitleAlternate.Renumber(); - } - - _subtitleListViewIndex = -1; - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - return newParagraph; - } - - private void timerAutoDuration_Tick(object sender, EventArgs e) - { - labelAutoDuration.Visible = !labelAutoDuration.Visible; - if (SubtitleListview1.SelectedItems.Count > 0) - { - try - { - int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - var currentParagraph = _subtitle.Paragraphs[firstSelectedIndex]; - var nextParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex + 1); - double duration = Utilities.GetOptimalDisplayMilliseconds(textBoxListViewText.Text); - if (currentParagraph.StartTime.TotalMilliseconds + duration + Configuration.Settings.General.MinimumMillisecondsBetweenLines > nextParagraph?.StartTime.TotalMilliseconds) - { - var newEndTime = nextParagraph.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; - if (newEndTime - currentParagraph.StartTime.TotalMilliseconds > 100) - { - duration = newEndTime - currentParagraph.StartTime.TotalMilliseconds; - } - else - { - return; // too close to next subtitle - } - } - - SetDurationInSeconds(duration / TimeCode.BaseUnit); - currentParagraph.EndTime.TotalMilliseconds = currentParagraph.StartTime.TotalMilliseconds + duration; - SubtitleListview1.SetDuration(firstSelectedIndex, currentParagraph, _subtitle.GetParagraphOrDefault(firstSelectedIndex + 1)); - } - catch - { - // ignore - } - } - } - - private void buttonBeforeText_Click(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedItems.Count > 0) - { - int index = SubtitleListview1.SelectedItems[0].Index; - - mediaPlayer.Pause(); - double pos = _subtitle.Paragraphs[index].StartTime.TotalSeconds; - if (pos > 1) - { - mediaPlayer.CurrentPosition = (_subtitle.Paragraphs[index].StartTime.TotalSeconds) - 0.5; - } - else - { - mediaPlayer.CurrentPosition = _subtitle.Paragraphs[index].StartTime.TotalSeconds; - } - - mediaPlayer.Play(); - } - } - - private void GotoSubPositionAndPause() - { - GotoSubPositionAndPause(0); - } - - private void GotoSubPositionAndPause(double adjustSeconds) - { - if (SubtitleListview1.SelectedItems.Count > 0) - { - int index = SubtitleListview1.SelectedItems[0].Index; - if (index == -1 || index >= _subtitle.Paragraphs.Count) - { - return; - } - - var p = _subtitle.Paragraphs[index]; - mediaPlayer.Pause(); - if (p.StartTime.IsMaxTime) - { - return; - } - - double newPos = p.StartTime.TotalSeconds + adjustSeconds; - if (newPos < 0) - { - newPos = 0; - } - - mediaPlayer.CurrentPosition = newPos; - ShowSubtitle(); - - double startPos = mediaPlayer.CurrentPosition - 1; - if (startPos < 0) - { - startPos = 0; - } - - SetWaveformPosition(startPos, mediaPlayer.CurrentPosition, index); - } - } - - private void buttonGotoSub_Click(object sender, EventArgs e) - { - GotoSubPositionAndPause(); - } - - private void buttonOpenVideo_Click(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(openFileDialog1.InitialDirectory) && !string.IsNullOrEmpty(_fileName)) - { - openFileDialog1.InitialDirectory = Path.GetDirectoryName(_fileName); - } - - openFileDialog1.Title = _languageGeneral.OpenVideoFileTitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = Utilities.GetVideoFileFilter(true); - - openFileDialog1.FileName = string.Empty; - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - if (audioVisualizer.WavePeaks != null) - { - audioVisualizer.WavePeaks = null; - audioVisualizer.SetSpectrogram(null); - audioVisualizer.SceneChanges = new List(); - audioVisualizer.Chapters = new List(); - } - - openFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName); - if (!panelVideoPlayer.Visible) - { - toolStripButtonToggleVideo_Click(null, null); - } - - OpenVideo(openFileDialog1.FileName); - } - } - - private void toolStripButtonToggleVideo_Click(object sender, EventArgs e) - { - toolStripButtonToggleVideo.Checked = !toolStripButtonToggleVideo.Checked; - panelVideoPlayer.Visible = toolStripButtonToggleVideo.Checked; - mediaPlayer.BringToFront(); - if (!toolStripButtonToggleVideo.Checked && !toolStripButtonToggleWaveform.Checked) - { - if (_isVideoControlsUndocked) - { - ShowHideUndockedVideoControls(); - } - else - { - HideVideoPlayer(); - } - } - else - { - ShowVideoPlayer(); - } - - Configuration.Settings.General.ShowVideoPlayer = toolStripButtonToggleVideo.Checked; - if (!_loading) - { - Refresh(); - } - } - - private void toolStripButtonToggleWaveform_Click(object sender, EventArgs e) - { - toolStripButtonToggleWaveform.Checked = !toolStripButtonToggleWaveform.Checked; - audioVisualizer.Visible = toolStripButtonToggleWaveform.Checked; - trackBarWaveformPosition.Visible = toolStripButtonToggleWaveform.Checked; - panelWaveformControls.Visible = toolStripButtonToggleWaveform.Checked; - if (!toolStripButtonToggleWaveform.Checked && !toolStripButtonToggleVideo.Checked) - { - if (_isVideoControlsUndocked) - { - ShowHideUndockedVideoControls(); - } - else - { - HideVideoPlayer(); - } - } - else - { - ShowVideoPlayer(); - } - - Configuration.Settings.General.ShowAudioVisualizer = toolStripButtonToggleWaveform.Checked; - Refresh(); - } - - public void ShowEarlierOrLater(double adjustMilliseconds, SelectionChoice selection) - { - var tc = new TimeCode(adjustMilliseconds); - MakeHistoryForUndo(_language.BeforeShowSelectedLinesEarlierLater + ": " + tc); - if (adjustMilliseconds < 0) - { - if (selection == SelectionChoice.AllLines) - { - ShowStatus(string.Format(_language.ShowAllLinesXSecondsLinesEarlier, adjustMilliseconds / -TimeCode.BaseUnit)); - } - else if (selection == SelectionChoice.SelectionOnly) - { - ShowStatus(string.Format(_language.ShowSelectedLinesXSecondsLinesEarlier, adjustMilliseconds / -TimeCode.BaseUnit)); - } - else if (selection == SelectionChoice.SelectionAndForward) - { - ShowStatus(string.Format(_language.ShowSelectionAndForwardXSecondsLinesEarlier, adjustMilliseconds / -TimeCode.BaseUnit)); - } - } - else - { - if (selection == SelectionChoice.AllLines) - { - ShowStatus(string.Format(_language.ShowAllLinesXSecondsLinesLater, adjustMilliseconds / TimeCode.BaseUnit)); - } - else if (selection == SelectionChoice.SelectionOnly) - { - ShowStatus(string.Format(_language.ShowSelectedLinesXSecondsLinesLater, adjustMilliseconds / TimeCode.BaseUnit)); - } - else if (selection == SelectionChoice.SelectionAndForward) - { - ShowStatus(string.Format(_language.ShowSelectionAndForwardXSecondsLinesLater, adjustMilliseconds / TimeCode.BaseUnit)); - } - } - - int startFrom = 0; - if (selection == SelectionChoice.SelectionAndForward) - { - if (SubtitleListview1.SelectedItems.Count > 0) - { - startFrom = SubtitleListview1.SelectedItems[0].Index; - } - else - { - startFrom = _subtitle.Paragraphs.Count; - } - } - - // don't overlap previous/next - if (selection == SelectionChoice.SelectionOnly && SubtitleListview1.SelectedItems.Count == 1 && - !Configuration.Settings.VideoControls.WaveformAllowOverlap && - GetCurrentSubtitleFormat().GetType() != typeof(AdvancedSubStationAlpha)) - { - var current = _subtitle.GetParagraphOrDefault(FirstSelectedIndex); - if (current != null) - { - if (adjustMilliseconds >= 0) - { - var next = _subtitle.GetParagraphOrDefault(FirstSelectedIndex + 1); - if (next != null && current.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines > next.StartTime.TotalMilliseconds - adjustMilliseconds) - { - var newAdjustMs = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines - current.EndTime.TotalMilliseconds; - if (newAdjustMs > 0) - { - adjustMilliseconds = newAdjustMs; - } - else - { - return; - } - } - } - else - { - var prev = _subtitle.GetParagraphOrDefault(FirstSelectedIndex - 1); - if (prev != null && current.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines + adjustMilliseconds < prev.EndTime.TotalMilliseconds) - { - var newAdjustMs = prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines - current.StartTime.TotalMilliseconds; - if (newAdjustMs < 0) - { - adjustMilliseconds = newAdjustMs; - } - else - { - return; - } - } - } - } - } - - SubtitleListview1.BeginUpdate(); - for (int i = startFrom; i < _subtitle.Paragraphs.Count; i++) - { - switch (selection) - { - case SelectionChoice.SelectionOnly: - if (SubtitleListview1.Items[i].Selected) - { - ShowEarlierOrLaterParagraph(adjustMilliseconds, i); - } - - break; - case SelectionChoice.AllLines: - case SelectionChoice.SelectionAndForward: - ShowEarlierOrLaterParagraph(adjustMilliseconds, i); - break; - } - } - - SubtitleListview1.EndUpdate(); - RefreshSelectedParagraph(); - UpdateSourceView(); - UpdateListSyntaxColoring(); - } - - private void ShowEarlierOrLaterParagraph(double adjustMilliseconds, int i) - { - var p = _subtitle.GetParagraphOrDefault(i); - if (p != null && !p.StartTime.IsMaxTime) - { - if (_subtitleAlternate != null) - { - var original = Utilities.GetOriginalParagraph(i, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - original.StartTime.TotalMilliseconds += adjustMilliseconds; - original.EndTime.TotalMilliseconds += adjustMilliseconds; - } - } - - p.StartTime.TotalMilliseconds += adjustMilliseconds; - p.EndTime.TotalMilliseconds += adjustMilliseconds; - SubtitleListview1.SetStartTimeAndDuration(i, p, _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1)); - } - } - - private void UpdateSourceView() - { - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - ShowSource(); - } - } - - private void toolStripMenuItemAdjustAllTimes_Click(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedItems.Count > 1) - { - ShowSelectedLinesEarlierlaterToolStripMenuItemClick(null, null); - return; - } - - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - mediaPlayer.Pause(); - - if (_showEarlierOrLater != null && !_showEarlierOrLater.IsDisposed) - { - _showEarlierOrLater.WindowState = FormWindowState.Normal; - _showEarlierOrLater.Focus(); - return; - } - - _showEarlierOrLater = new ShowEarlierLater(); - if (!_showEarlierOrLater.IsPositionAndSizeSaved) - { - _showEarlierOrLater.Top = Top + 100; - _showEarlierOrLater.Left = Left + Width / 2 - _showEarlierOrLater.Width / 3; - } - - SaveSubtitleListviewIndices(); - _showEarlierOrLater.Initialize(ShowEarlierOrLater, false); - _showEarlierOrLater.Show(this); - } - - private void timer1_Tick(object sender, EventArgs e) - { - if (mediaPlayer.VideoPlayer != null) - { - if (!mediaPlayer.IsPaused) - { - timeUpDownVideoPosition.Enabled = false; - timeUpDownVideoPositionAdjust.Enabled = false; - - if (_endSeconds >= 0 && mediaPlayer.CurrentPosition > _endSeconds && !(AutoRepeatContinueOn || AutoRepeatOn)) - { - mediaPlayer.Pause(); - if (_endSecondsNewPosition >= 0 && _endSecondsNewPositionTicks > DateTime.UtcNow.Ticks - (10000 * 900)) // 900 ms - { - mediaPlayer.CurrentPosition = _endSecondsNewPosition; - } - else - { - mediaPlayer.CurrentPosition = _endSeconds + EndDelay; - } - - _endSeconds = -1; - _endSecondsNewPosition = -1; - _endSecondsNewPositionTicks = 0; - } - - if (AutoRepeatContinueOn || AutoRepeatOn) - { - if (_endSeconds >= 0 && mediaPlayer.CurrentPosition > _endSeconds && checkBoxAutoRepeatOn.Checked) - { - mediaPlayer.Pause(); - _endSeconds = -1; - - if (checkBoxAutoRepeatOn.Checked && _repeatCount > 0) - { - if (_repeatCount == 1) - { - labelStatus.Text = _language.VideoControls.RepeatingLastTime; - } - else - { - labelStatus.Text = string.Format(_language.VideoControls.RepeatingXTimesLeft, _repeatCount); - } - - _repeatCount--; - if (_subtitleListViewIndex >= 0 && _subtitleListViewIndex < _subtitle.Paragraphs.Count) - { - PlayPart(_subtitle.Paragraphs[_subtitleListViewIndex]); - } - } - else if (checkBoxAutoContinue.Checked) - { - _autoContinueDelayCount = int.Parse(comboBoxAutoContinue.Text); - if (_repeatCount == 1) - { - labelStatus.Text = _language.VideoControls.AutoContinueInOneSecond; - } - else - { - labelStatus.Text = string.Format(_language.VideoControls.AutoContinueInXSeconds, _autoContinueDelayCount); - } - - timerAutoContinue.Start(); - } - } - } - } - else - { - timeUpDownVideoPosition.Enabled = true; - timeUpDownVideoPositionAdjust.Enabled = true; - } - - int index = ShowSubtitle(); - - double pos = mediaPlayer.CurrentPosition * TimeCode.BaseUnit; - if (!timeUpDownVideoPosition.MaskedTextBox.Focused && timeUpDownVideoPosition.TimeCode.TotalMilliseconds != pos) - { - timeUpDownVideoPosition.TimeCode = new TimeCode(pos); - } - - if (!timeUpDownVideoPositionAdjust.MaskedTextBox.Focused && timeUpDownVideoPositionAdjust.TimeCode.TotalMilliseconds != pos) - { - timeUpDownVideoPositionAdjust.TimeCode = new TimeCode(pos); - } - - mediaPlayer.RefreshProgressBar(); - - trackBarWaveformPosition.ValueChanged -= trackBarWaveformPosition_ValueChanged; - int value = (int)mediaPlayer.CurrentPosition; - if (value > trackBarWaveformPosition.Maximum) - { - value = trackBarWaveformPosition.Maximum; - } - - if (value < trackBarWaveformPosition.Minimum) - { - value = trackBarWaveformPosition.Minimum; - } - - trackBarWaveformPosition.Value = value; - trackBarWaveformPosition.ValueChanged += trackBarWaveformPosition_ValueChanged; - - if (labelNextWord.Visible && _labelNextTicks + 100000000 < DateTime.UtcNow.Ticks) - { - labelNextWord.Visible = false; - } - } - } - - private void StopAutoDuration() - { - timerAutoDuration.Stop(); - labelAutoDuration.Visible = false; - } - - private void textBoxListViewText_Leave(object sender, EventArgs e) - { - StopAutoDuration(); - } - - private void timerAutoContinue_Tick(object sender, EventArgs e) - { - _autoContinueDelayCount--; - - if (_autoContinueDelayCount == 0) - { - timerAutoContinue.Stop(); - - if (timerStillTyping.Enabled) - { - labelStatus.Text = _language.VideoControls.StillTypingAutoContinueStopped; - } - else - { - labelStatus.Text = string.Empty; - PlayNext(); - } - } - else - { - if (_repeatCount == 1) - { - labelStatus.Text = _language.VideoControls.AutoContinueInOneSecond; - } - else - { - labelStatus.Text = string.Format(_language.VideoControls.AutoContinueInXSeconds, _autoContinueDelayCount); - } - } - } - - private void timerStillTyping_Tick(object sender, EventArgs e) - { - timerStillTyping.Stop(); - } - - private void textBoxListViewText_MouseMove(object sender, MouseEventArgs e) - { - if ((AutoRepeatContinueOn || AutoRepeatOn) && !textBoxSearchWord.Focused && textBoxListViewText.Focused) - { - string selectedText = textBoxListViewText.SelectedText; - if (!string.IsNullOrEmpty(selectedText)) - { - selectedText = selectedText.Trim(); - selectedText = selectedText.TrimEnd('.', ',', '!', '?'); - selectedText = selectedText.TrimEnd(); - if (!string.IsNullOrEmpty(selectedText) && selectedText != textBoxSearchWord.Text) - { - textBoxSearchWord.Text = HtmlUtil.RemoveHtmlTags(selectedText); - } - } - } - } - - private void textBoxListViewText_KeyUp(object sender, KeyEventArgs e) - { - textBoxListViewText_MouseMove(sender, null); - textBoxListViewText.ClearUndo(); - UpdatePositionAndTotalLength(labelTextLineTotal, textBoxListViewText); - } - - public void RunTranslateSearch(Action act) - { - var text = textBoxSearchWord.Text; - if (tabControlButtons.SelectedTab != tabPageTranslate) - { - var tb = GetFocusedTextBox(); - if (tb.SelectionLength == 0) - { - text = tb.Text; - } - else - { - text = tb.SelectedText; - } - } - - if (!string.IsNullOrWhiteSpace(text)) - { - act(text); - } - } - - private void buttonGoogleIt_Click(object sender, EventArgs e) - { - RunTranslateSearch((text) => { UiUtil.OpenURL("https://www.google.com/search?q=" + Utilities.UrlEncode(text)); }); - } - - private void buttonGoogleTranslateIt_Click(object sender, EventArgs e) - { - RunTranslateSearch((text) => - { - string languageId = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); - UiUtil.OpenURL("https://translate.google.com/#auto|" + languageId + "|" + Utilities.UrlEncode(text)); - }); - } - - private void ButtonPlayCurrentClick(object sender, EventArgs e) - { - PlayCurrent(); - } - - private void buttonPlayNext_Click(object sender, EventArgs e) - { - PlayNext(); - } - - private void buttonPlayPrevious_Click(object sender, EventArgs e) - { - PlayPrevious(); - } - - private void buttonStop_Click(object sender, EventArgs e) - { - _endSeconds = -1; - timerAutoContinue.Stop(); - mediaPlayer.Pause(); - labelStatus.Text = string.Empty; - } - - private void fileToolStripMenuItem_DropDownOpening(object sender, EventArgs e) - { - toolStripMenuItemOpenContainingFolder.Visible = !string.IsNullOrEmpty(_fileName) && File.Exists(_fileName); - bool subtitleLoaded = IsSubtitleLoaded; - toolStripMenuItemStatistics.Visible = subtitleLoaded; - toolStripSeparator22.Visible = subtitleLoaded; - toolStripMenuItemExport.Visible = subtitleLoaded; - openOriginalToolStripMenuItem.Visible = subtitleLoaded; - toolStripMenuItemOpenKeepVideo.Visible = VideoFileName != null; - if (subtitleLoaded && Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - saveOriginalToolStripMenuItem.Visible = true; - saveOriginalAstoolStripMenuItem.Visible = true; - removeOriginalToolStripMenuItem.Visible = true; - } - else - { - saveOriginalToolStripMenuItem.Visible = false; - saveOriginalAstoolStripMenuItem.Visible = false; - if (subtitleLoaded && SubtitleListview1.IsAlternateTextColumnVisible && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - removeOriginalToolStripMenuItem.Visible = true; - } - else - { - removeOriginalToolStripMenuItem.Visible = false; - } - } - - var format = GetCurrentSubtitleFormat(); - var ft = format.GetType(); - if (ft == typeof(AdvancedSubStationAlpha)) - { - toolStripMenuItemSubStationAlpha.Visible = true; - toolStripMenuItemSubStationAlpha.Text = _language.Menu.File.AdvancedSubStationAlphaProperties; - - toolStripMenuItemAssStyles.Visible = true; - toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.AdvancedSubStationAlphaStyles; - - toolStripMenuItemAssaStyles.Visible = true; - } - else if (ft == typeof(SubStationAlpha)) - { - toolStripMenuItemSubStationAlpha.Visible = true; - toolStripMenuItemSubStationAlpha.Text = _language.Menu.File.SubStationAlphaProperties; - - toolStripMenuItemAssStyles.Visible = true; - toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.AdvancedSubStationAlphaStyles; - - toolStripMenuItemAssaStyles.Visible = true; - } - else - { - toolStripMenuItemSubStationAlpha.Visible = false; - toolStripMenuItemAssStyles.Visible = false; - toolStripMenuItemAssaStyles.Visible = false; - } - - if (ft == typeof(Ebu)) - { - toolStripMenuItemEbuProperties.Text = _language.Menu.File.EbuProperties; - toolStripMenuItemEbuProperties.Visible = !string.IsNullOrEmpty(_language.Menu.File.EbuProperties); - } - else - { - toolStripMenuItemEbuProperties.Visible = false; - } - - if (ft == typeof(DvdStudioPro) || - ft == typeof(DvdStudioProSpace) || - ft == typeof(DvdStudioProSpaceOne) || - ft == typeof(DvdStudioProSpaceOneSemicolon)) - { - toolStripMenuItemDvdStudioProProperties.Text = _language.Menu.File.DvdStuioProProperties; - toolStripMenuItemDvdStudioProProperties.Visible = true; - } - else - { - toolStripMenuItemDvdStudioProProperties.Visible = false; - } - - if (ft == typeof(DCinemaInterop) || ft == typeof(DCinemaSmpte2014) || ft == typeof(DCinemaSmpte2010) || ft == typeof(DCinemaSmpte2007)) - { - toolStripMenuItemDCinemaProperties.Visible = true; - } - else - { - toolStripMenuItemDCinemaProperties.Visible = false; - } - - if (ft == typeof(TimedText10) || ft == typeof(ItunesTimedText)) - { - toolStripMenuItemTTProperties.Visible = true; - } - else - { - toolStripMenuItemTTProperties.Visible = false; - } - - toolStripMenuItemNuendoProperties.Visible = format.Name == "Nuendo"; - toolStripMenuItemFcpProperties.Visible = ft == typeof(FinalCutProXml); - - toolStripSeparator20.Visible = subtitleLoaded; - } - - private void toolStripMenuItemOpenContainingFolder_Click(object sender, EventArgs e) - { - UiUtil.OpenFolderFromFileName(_fileName); - } - - private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) - { - if (tabControlButtons.SelectedIndex == 0) - { - tabControlButtons.Width = groupBoxTranslateSearch.Left + groupBoxTranslateSearch.Width + 10; - Configuration.Settings.VideoControls.LastActiveTab = "Translate"; - } - else if (tabControlButtons.SelectedIndex == 1) - { - tabControlButtons.Width = buttonInsertNewText.Left + buttonInsertNewText.Width + 35; - Configuration.Settings.VideoControls.LastActiveTab = "Create"; - } - else if (tabControlButtons.SelectedIndex == 2) - { - tabControlButtons.Width = buttonInsertNewText.Left + buttonInsertNewText.Width + 35; - Configuration.Settings.VideoControls.LastActiveTab = "Adjust"; - } - - if (!_isVideoControlsUndocked) - { - if (toolStripButtonToggleWaveform.Checked) - { - audioVisualizer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; - } - - if (!toolStripButtonToggleWaveform.Checked && toolStripButtonToggleVideo.Checked) - { - panelVideoPlayer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; - panelVideoPlayer.Width = groupBoxVideo.Width - (panelVideoPlayer.Left + 10); - } - - audioVisualizer.Width = groupBoxVideo.Width - (audioVisualizer.Left + 10); - panelWaveformControls.Left = audioVisualizer.Left; - trackBarWaveformPosition.Left = panelWaveformControls.Left + panelWaveformControls.Width + 5; - trackBarWaveformPosition.Width = groupBoxVideo.Width - (trackBarWaveformPosition.Left + 10); - Main_Resize(null, null); - checkBoxSyncListViewWithVideoWhilePlaying.Left = tabControlButtons.Left + tabControlButtons.Width + 5; - if (!_loading) - { - Refresh(); - } - } - else if (_videoControlsUndocked != null && !_videoControlsUndocked.IsDisposed) - { - _videoControlsUndocked.Width = tabControlButtons.Width + 20; - _videoControlsUndocked.Height = tabControlButtons.Height + 65; - } - } - - private void buttonSecBack1_Click(object sender, EventArgs e) - { - GoBackSeconds((double)numericUpDownSec1.Value); - } - - private void buttonForward1_Click(object sender, EventArgs e) - { - GoBackSeconds(-(double)numericUpDownSec1.Value); - } - - private void ButtonSetStartAndOffsetRestClick(object sender, EventArgs e) - { - SetStartAndOffsetTheRest(mediaPlayer.CurrentPosition); - } - - private void SetStartAndOffsetTheRest(double videoPosition) - { - if (SubtitleListview1.SelectedItems.Count == 1) - { - bool oldSync = checkBoxSyncListViewWithVideoWhilePlaying.Checked; - checkBoxSyncListViewWithVideoWhilePlaying.Checked = false; - - timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; - int index = SubtitleListview1.SelectedItems[0].Index; - var oldP = new Paragraph(_subtitle.Paragraphs[index]); - if (!mediaPlayer.IsPaused) - { - videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; - } - - var tc = TimeCode.FromSeconds(videoPosition); - timeUpDownStartTime.TimeCode = tc; - - MakeHistoryForUndo(_language.BeforeSetStartTimeAndOffsetTheRest + @" " + oldP.Number + @" - " + tc); - - double offset = oldP.StartTime.TotalMilliseconds - tc.TotalMilliseconds; - - if (oldP.StartTime.IsMaxTime) - { - _subtitle.Paragraphs[index].StartTime.TotalSeconds = videoPosition; - _subtitle.Paragraphs[index].EndTime.TotalMilliseconds = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(_subtitle.Paragraphs[index].Text); - SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync; - timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; - RefreshSelectedParagraph(); - return; - } - - _subtitle.Paragraphs[index].StartTime = new TimeCode(_subtitle.Paragraphs[index].StartTime.TotalMilliseconds - offset); - _subtitle.Paragraphs[index].EndTime = new TimeCode(_subtitle.Paragraphs[index].EndTime.TotalMilliseconds - offset); - SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - - for (int i = index + 1; i < SubtitleListview1.Items.Count; i++) - { - if (!_subtitle.Paragraphs[i].StartTime.IsMaxTime) - { - _subtitle.Paragraphs[i].StartTime = new TimeCode(_subtitle.Paragraphs[i].StartTime.TotalMilliseconds - offset); - _subtitle.Paragraphs[i].EndTime = new TimeCode(_subtitle.Paragraphs[i].EndTime.TotalMilliseconds - offset); - SubtitleListview1.SetStartTimeAndDuration(i, _subtitle.Paragraphs[i], _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1)); - } - } - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - var original = Utilities.GetOriginalParagraph(index, oldP, _subtitleAlternate.Paragraphs); - if (original != null) - { - index = _subtitleAlternate.GetIndex(original); - for (int i = index; i < _subtitleAlternate.Paragraphs.Count; i++) - { - if (!_subtitleAlternate.Paragraphs[i].StartTime.IsMaxTime) - { - _subtitleAlternate.Paragraphs[i].StartTime = new TimeCode(_subtitleAlternate.Paragraphs[i].StartTime.TotalMilliseconds - offset); - _subtitleAlternate.Paragraphs[i].EndTime = new TimeCode(_subtitleAlternate.Paragraphs[i].EndTime.TotalMilliseconds - offset); - } - } - } - } - - ShowSource(); - checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync; - timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; - } - } - - private void ButtonSetEndAndGoToNextClick(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedItems.Count == 1) - { - int index = SubtitleListview1.SelectedItems[0].Index; - double videoPosition = mediaPlayer.CurrentPosition; - if (!mediaPlayer.IsPaused) - { - videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; - } - - string oldDuration = _subtitle.Paragraphs[index].Duration.ToString(); - var temp = new Paragraph(_subtitle.Paragraphs[index]); - temp.EndTime.TotalMilliseconds = TimeCode.FromSeconds(videoPosition).TotalMilliseconds; - MakeHistoryForUndo(string.Format(_language.DisplayTimeAdjustedX, "#" + _subtitle.Paragraphs[index].Number + ": " + oldDuration + " -> " + temp.Duration)); - _makeHistoryPaused = true; - - if (_subtitle.Paragraphs[index].StartTime.IsMaxTime) - { - timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; - _subtitle.Paragraphs[index].EndTime.TotalSeconds = videoPosition; - _subtitle.Paragraphs[index].StartTime.TotalMilliseconds = _subtitle.Paragraphs[index].EndTime.TotalMilliseconds - Utilities.GetOptimalDisplayMilliseconds(_subtitle.Paragraphs[index].Text); - if (_subtitle.Paragraphs[index].StartTime.TotalMilliseconds < 0) - { - _subtitle.Paragraphs[index].StartTime.TotalMilliseconds = 0; - } - - timeUpDownStartTime.TimeCode = _subtitle.Paragraphs[index].StartTime; - SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; - } - else - { - _subtitle.Paragraphs[index].EndTime = TimeCode.FromSeconds(videoPosition); - } - - SubtitleListview1.SetDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); - SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds); - - if (index + 1 < _subtitle.Paragraphs.Count) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true); - } - - _makeHistoryPaused = false; - } - } - - private void ButtonAdjustSecBackClick(object sender, EventArgs e) - { - GoBackSeconds((double)numericUpDownSecAdjust1.Value); - } - - private void ButtonAdjustSecForwardClick(object sender, EventArgs e) - { - GoBackSeconds(-(double)numericUpDownSecAdjust1.Value); - } - - private void StartOrStopAutoBackup() - { - _timerAutoBackup?.Dispose(); - if (Configuration.Settings.General.AutoBackupSeconds > 0) - { - _timerAutoBackup = new Timer(); - _timerAutoBackup.Tick += TimerAutoBackupTick; - _timerAutoBackup.Interval = 1000 * Configuration.Settings.General.AutoBackupSeconds; // take backup every x second if changes were made - _timerAutoBackup.Start(); - } - } - - private void Main_Shown(object sender, EventArgs e) - { - splitContainerListViewAndText.SplitterMoved += splitContainerListViewAndText_SplitterMoved; - splitContainerListViewAndText.SizeChanged += splitContainerListViewAndText_SizeChanged; - - imageListBookmarks.Images.Add(pictureBoxBookmark.Image); - SetListViewStateImages(); - - toolStripButtonToggleVideo.Checked = !Configuration.Settings.General.ShowVideoPlayer; - toolStripButtonToggleVideo_Click(null, null); - - StartOrStopAutoBackup(); - - SetPositionFromXYString(Configuration.Settings.General.UndockedVideoPosition, "VideoPlayerUndocked"); - SetPositionFromXYString(Configuration.Settings.General.UndockedWaveformPosition, "WaveformUndocked"); - SetPositionFromXYString(Configuration.Settings.General.UndockedVideoControlsPosition, "VideoControlsUndocked"); - if (Configuration.Settings.General.Undocked && Configuration.Settings.General.StartRememberPositionAndSize) - { - Configuration.Settings.General.Undocked = false; - UndockVideoControlsToolStripMenuItemClick(null, null); - if (Configuration.Settings.General.UndockedVideoFullscreen) - { - GoFullscreen(true); - } - } - - Main_Resize(null, null); - - toolStripButtonLockCenter.Checked = Configuration.Settings.General.WaveformCenter; - audioVisualizer.Locked = toolStripButtonLockCenter.Checked; - - numericUpDownSec1.Value = (decimal)(Configuration.Settings.General.SmallDelayMilliseconds / TimeCode.BaseUnit); - numericUpDownSec2.Value = (decimal)(Configuration.Settings.General.LargeDelayMilliseconds / TimeCode.BaseUnit); - - numericUpDownSecAdjust1.Value = (decimal)(Configuration.Settings.General.SmallDelayMilliseconds / TimeCode.BaseUnit); - numericUpDownSecAdjust2.Value = (decimal)(Configuration.Settings.General.LargeDelayMilliseconds / TimeCode.BaseUnit); - - SetShortcuts(); - MainResize(); - _loading = false; - OpenVideo(VideoFileName); - ShowSubtitleTimer.Stop(); - lock (_syncUndo) - { - timerTextUndo.Start(); - timerAlternateTextUndo.Start(); - } - - if (Configuration.IsRunningOnLinux) - { - numericUpDownDuration.Left = timeUpDownStartTime.Left + timeUpDownStartTime.Width + 10; - numericUpDownDuration.Width += 10; - numericUpDownSec1.Width += 10; - numericUpDownSec2.Width += 10; - numericUpDownSecAdjust1.Width += 10; - numericUpDownSecAdjust2.Width += 10; - labelDuration.Left = numericUpDownDuration.Left; - } - - _timerDoSyntaxColoring.Interval = 100; - _timerDoSyntaxColoring.Tick += _timerDoSyntaxColoring_Tick; - - var showBeta = Configuration.Settings.General.ShowBetaStuff; - generateDatetimeInfoFromVideoToolStripMenuItem.Visible = showBeta; - toolStripMenuItemExportCaptionInc.Visible = showBeta; - toolStripMenuItemExportUltech130.Visible = showBeta; - toolStripMenuItemInverseSelection.Visible = showBeta; - toolStripMenuItemSpellCheckFromCurrentLine.Visible = showBeta; - toolStripMenuItemImportOcrHardSub.Visible = showBeta; - toolStripMenuItemOpenDvd.Visible = showBeta; - - if (Configuration.Settings.General.StartRememberPositionAndSize && - Configuration.Settings.General.SplitContainerMainSplitterDistance > 0 && - Configuration.Settings.General.SplitContainer1SplitterDistance > 0 && - Configuration.Settings.General.SplitContainerListViewAndTextSplitterDistance > 0) - { - splitContainerMain.SplitterDistance = Configuration.Settings.General.SplitContainerMainSplitterDistance; - splitContainer1.SplitterDistance = Configuration.Settings.General.SplitContainer1SplitterDistance; - splitContainerListViewAndText.SplitterDistance = Configuration.Settings.General.SplitContainerListViewAndTextSplitterDistance; - } - - mediaPlayer.InitializeVolume(Configuration.Settings.General.VideoPlayerDefaultVolume); - tabControlSubtitle.Invalidate(); - - if (string.IsNullOrEmpty(Configuration.Settings.Language.CheckForUpdates.CheckingForUpdates)) - { - checkForUpdatesToolStripMenuItem.Visible = false; - toolStripMenuItemSplitterCheckForUpdates.Visible = false; - } - else if (Configuration.Settings.General.CheckForUpdates && Configuration.Settings.General.LastCheckForUpdates < DateTime.Now.AddDays(-5)) - { - _checkForUpdatesHelper = new CheckForUpdatesHelper(); - _checkForUpdatesHelper.CheckForUpdates(); - _timerCheckForUpdates = new Timer(); - _timerCheckForUpdates.Interval = 7000; - _timerCheckForUpdates.Tick += TimerCheckForUpdatesTick; - _timerCheckForUpdates.Start(); - Configuration.Settings.General.LastCheckForUpdates = DateTime.Now; - } - - _dragAndDropTimer.Interval = 50; - _dragAndDropTimer.Tick += DoSubtitleListview1Drop; - - _dragAndDropVideoTimer.Interval = 50; - _dragAndDropVideoTimer.Tick += DropVideoTick; - - if (_exitWhenLoaded) - { - Application.Exit(); - } - - // Fix some large font issue - if (numericUpDownDuration.Left + numericUpDownDuration.Width > textBoxListViewText.Left) - { - numericUpDownDuration.Left = timeUpDownStartTime.Left + timeUpDownStartTime.Width + 5; - numericUpDownDuration.Width = textBoxListViewText.Left - numericUpDownDuration.Left - 5; - labelDuration.Left = numericUpDownDuration.Left; - } - - if (string.IsNullOrEmpty(_fileName) && (_subtitle == null || _subtitle.Paragraphs.Count == 0)) - { - _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - } - - comboBoxSubtitleFormats.AutoCompleteSource = AutoCompleteSource.ListItems; - comboBoxSubtitleFormats.AutoCompleteMode = AutoCompleteMode.Append; - InitializePlayRateDropDown(); - - LoadPlugins(); - - mediaPlayer.OnEmptyPlayerClicked += MediaPlayer_OnEmptyPlayerClicked; - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex, true); - if (Configuration.Settings.General.StartInSourceView) - { - textBoxSource.Focus(); - } - else - { - SubtitleListview1.Focus(); - } - - UiUtil.FixFonts(toolStripComboBoxWaveform); - UiUtil.FixFonts(toolStripComboBoxFrameRate); - UiUtil.FixFonts(comboBoxSubtitleFormats); - UiUtil.FixFonts(comboBoxEncoding); - UiUtil.FixFonts(toolStripSplitButtonPlayRate); - - _lastTextKeyDownTicks = DateTime.UtcNow.Ticks; - if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - var idx = _subtitleListViewIndex; - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisibleFaster(idx); - } - - SetTitle(); - labelSingleLine.Left = labelTextLineLengths.Left + labelTextLineLengths.Width - 6; - RemoveNotExistingFilesFromRecentFilesUI(); - ShowSubtitleTimer.Start(); - } - - private void InitializePlayRateDropDown() - { - toolStripSplitButtonPlayRate.DropDownItems.Clear(); - var foreColor = UiUtil.ForeColor; - var backColor = UiUtil.BackColor; - for (int i = 30; i <= 300; i += 10) - { - toolStripSplitButtonPlayRate.DropDownItems.Add(new ToolStripMenuItem(i + "%", null, SetPlayRate) { Checked = i == 100, BackColor = backColor, ForeColor = foreColor }); - } - } - - private void MediaPlayer_OnEmptyPlayerClicked(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(VideoFileName)) - { - buttonOpenVideo_Click(sender, e); - } - } - - private void SetPlayRate(object sender, EventArgs e) - { - SetPlayRate(sender, e, false); - } - - private void SetPlayRate(object sender, EventArgs e, bool skipStatusMessage) - { - if (!(sender is ToolStripMenuItem playRateDropDownItem) || mediaPlayer == null || mediaPlayer.VideoPlayer == null) - { - return; - } - - foreach (ToolStripMenuItem item in toolStripSplitButtonPlayRate.DropDownItems) - { - item.Checked = false; - } - - playRateDropDownItem.Checked = true; - var percentText = playRateDropDownItem.Text.TrimEnd('%'); - if (!skipStatusMessage) - { - ShowStatus(string.Format(_language.SetPlayRateX, percentText)); - } - - var factor = double.Parse(percentText) / 100.0; - toolStripSplitButtonPlayRate.Image = Math.Abs(factor - 1) < 0.01 ? imageListPlayRate.Images[0] : imageListPlayRate.Images[1]; - mediaPlayer.VideoPlayer.PlayRate = factor; - } - - private void TimerCheckForUpdatesTick(object sender, EventArgs e) - { - _timerCheckForUpdates.Stop(); - if (_checkForUpdatesHelper.IsUpdateAvailable()) - { - using (var form = new CheckForUpdates(this, _checkForUpdatesHelper)) - { - form.ShowDialog(this); - } - } - - _checkForUpdatesHelper = null; - _timerCheckForUpdates = null; - } - - private void _timerDoSyntaxColoring_Tick(object sender, EventArgs e) - { - UpdateListSyntaxColoring(); - _timerDoSyntaxColoring.Stop(); - } - - private static void SetPositionFromXYString(string positionAndSize, string name) - { - var parts = positionAndSize.Split(';'); - if (parts.Length == 4) - { - if (int.TryParse(parts[0], out var left) - && int.TryParse(parts[1], out var top) - && int.TryParse(parts[2], out var width) - && int.TryParse(parts[3], out var height)) - { - PositionAndSizeForm.SetPositionAndSize(name, new Rectangle(left, top, width, height)); - } - else - { - System.Diagnostics.Debug.WriteLine("Could not set position and size for '{0}'.", name); - } - } - } - - private void SetShortcuts() - { - _shortcuts.SetShortcuts(); - newToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileNew); - openToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileOpen); - toolStripMenuItemOpenKeepVideo.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileOpenKeepVideo); - saveToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileSave); - saveOriginalToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileSaveOriginal); - saveOriginalAstoolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileSaveOriginalAs); - saveAsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileSaveAs); - openOriginalToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileOpenOriginal); - removeOriginalToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileCloseOriginal); - toolStripMenuItemCompare.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileCompare); - toolStripMenuItemImportText.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileImportPlainText); - toolStripMenuItemImportTimeCodes.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileImportTimeCodes); - eBUSTLToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileExportEbu); - pACScreenElectronicsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileExportPac); - plainTextToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileExportPlainText); - - toolStripMenuItemUndo.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditUndo); - toolStripMenuItemRedo.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditRedo); - findToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditFind); - findNextToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditFindNext); - replaceToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditReplace); - multipleReplaceToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditMultipleReplace); - gotoLineNumberToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditGoToLineNumber); - toolStripMenuItemRightToLeftMode.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditRightToLeft); - toolStripMenuItemShowOriginalInPreview.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditToggleTranslationOriginalInPreviews); - toolStripMenuItemInverseSelection.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditInverseSelection); - toolStripMenuItemModifySelection.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditModifySelection); - - fixToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsFixCommonErrors); - toolStripMenuItemAutoMergeShortLines.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsMergeShortLines); - toolStripMenuItemMergeDuplicateText.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsMergeDuplicateText); - toolStripMenuItemMergeLinesWithSameTimeCodes.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsMergeSameTimeCodes); - toolStripMenuItemMakeEmptyFromCurrent.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsMakeEmptyFromCurrent); - toolStripMenuItemAutoSplitLongLines.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsSplitLongLines); - toolStripMenuItemSubtitlesBridgeGaps.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsDurationsBridgeGap); - setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsMinimumDisplayTimeBetweenParagraphs); - startNumberingFromToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsRenumber); - removeTextForHearImpairedToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsRemoveTextForHI); - ChangeCasingToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsChangeCasing); - toolStripMenuItemShowOriginalInPreview.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditToggleTranslationOriginalInPreviews); - toolStripMenuItemBatchConvert.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsBatchConvert); - toolStripMenuItemMeasurementConverter.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsMeasurementConverter); - splitToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsSplit); - appendTextVisuallyToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsAppend); - joinSubtitlesToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsJoin); - - openVideoToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoOpen); - closeVideoToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoClose); - showhideVideoToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoShowHideVideo); - toolStripMenuItemBookmark.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralToggleBookmarksWithText); - - spellCheckToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSpellCheck); - findDoubleWordsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSpellCheckFindDoubleWords); - addWordToNameListToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSpellCheckAddWordToNames); - - translateByGoogleToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTranslateGoogleTranslate); - - toolStripMenuItemAdjustAllTimes.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSynchronizationAdjustTimes); - visualSyncToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSynchronizationVisualSync); - toolStripMenuItemPointSync.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSynchronizationPointSync); - pointSyncViaOtherSubtitleToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSynchronizationPointSyncViaFile); - toolStripMenuItemChangeFrameRate2.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSynchronizationChangeFrameRate); - italicToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewItalic); - removeAllFormattingsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainRemoveFormatting); - boldToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewBold); - boldToolStripMenuItem1.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewBold); - underlineToolStripMenuItem1.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewUnderline); - underlineToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewUnderline); - boxToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewBox); - boxToolStripMenuItem1.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewBox); - splitLineToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewSplit); - toolStripMenuItemSurroundWithMusicSymbols.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewToggleMusicSymbols); - toolStripMenuItemAlignment.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewAlignment); - copyOriginalTextToCurrentToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewCopyTextFromOriginalToCurrent); - columnDeleteTextOnlyToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColumnDeleteText); - toolStripMenuItemColumnDeleteText.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColumnDeleteTextAndShiftUp); - ShiftTextCellsDownToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColumnInsertText); - toolStripMenuItemPasteSpecial.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColumnPaste); - toolStripMenuItemRuby.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxSelectionToRuby); - moveTextUpToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColumnTextUp); - moveTextDownToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColumnTextDown); - toolStripMenuItemReverseRightToLeftStartEnd.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditReverseStartAndEndingForRTL); - italicToolStripMenuItem1.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxItalic); - - audioVisualizer.InsertAtVideoPositionShortcut = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainWaveformInsertAtCurrentPosition); - audioVisualizer.Move100MsLeft = UiUtil.GetKeys(Configuration.Settings.Shortcuts.Waveform100MsLeft); - audioVisualizer.Move100MsRight = UiUtil.GetKeys(Configuration.Settings.Shortcuts.Waveform100MsRight); - audioVisualizer.MoveOneSecondLeft = UiUtil.GetKeys(Configuration.Settings.Shortcuts.Waveform1000MsLeft); - audioVisualizer.MoveOneSecondRight = UiUtil.GetKeys(Configuration.Settings.Shortcuts.Waveform1000MsRight); - - UiUtil.HelpKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralHelp); - helpToolStripMenuItem1.ShortcutKeys = UiUtil.HelpKeys; - - - // shortcut hints - if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest2) && Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest2.Length < 5) - { - labelAdjustF9.Text = Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest2; - } - else if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest) && Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest.Length < 5) - { - labelAdjustF9.Text = Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest; - } - else - { - labelAdjustF9.Text = string.Empty; - } - - if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainAdjustSetEndAndGotoNext) && Configuration.Settings.Shortcuts.MainAdjustSetEndAndGotoNext.Length < 5) - { - labelAdjustF10.Text = Configuration.Settings.Shortcuts.MainAdjustSetEndAndGotoNext; - } - else - { - labelAdjustF10.Text = string.Empty; - } - - if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainCreateSetStart) && Configuration.Settings.Shortcuts.MainCreateSetStart.Length < 5) - { - labelAdjustF11.Text = Configuration.Settings.Shortcuts.MainCreateSetStart; - labelCreateF11.Text = Configuration.Settings.Shortcuts.MainCreateSetStart; - } - else - { - labelAdjustF11.Text = string.Empty; - labelCreateF11.Text = string.Empty; - } - - if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainCreateSetEnd) && Configuration.Settings.Shortcuts.MainCreateSetEnd.Length < 5) - { - labelAdjustF12.Text = Configuration.Settings.Shortcuts.MainCreateSetEnd; - labelCreateF12.Text = Configuration.Settings.Shortcuts.MainCreateSetEnd; - } - else - { - labelAdjustF12.Text = string.Empty; - labelCreateF12.Text = string.Empty; - } - - if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainCreateInsertSubAtVideoPos) && Configuration.Settings.Shortcuts.MainCreateInsertSubAtVideoPos.Length < 5) - { - labelCreateF9.Text = Configuration.Settings.Shortcuts.MainCreateInsertSubAtVideoPos; - } - else - { - labelCreateF9.Text = string.Empty; - } - - if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore) && Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore.Length < 5) - { - labelCreateF10.Text = Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore; - } - else - { - labelCreateF10.Text = string.Empty; - } - } - - public static object GetPropertiesAndDoAction(string pluginFileName, out string name, out string text, out decimal version, out string description, out string actionType, out string shortcut, out System.Reflection.MethodInfo mi) - { - name = null; - text = null; - version = 0; - description = null; - actionType = null; - shortcut = null; - mi = null; - Assembly assembly; - try - { - assembly = Assembly.Load(File.ReadAllBytes(pluginFileName)); - } - catch - { - return null; - } - - // note: *objectName must not include path or file extension - string objectName = Path.GetFileNameWithoutExtension(pluginFileName); - if (assembly != null) - { - Type pluginType = assembly.GetType("Nikse.SubtitleEdit.PluginLogic." + objectName); - if (pluginType == null) - { - return null; - } - - object pluginObject = Activator.CreateInstance(pluginType); - - // IPlugin - var t = pluginType.GetInterface("IPlugin"); - if (t == null) - { - return null; - } - - PropertyInfo pi = t.GetProperty("Name"); - if (pi != null) - { - name = (string)pi.GetValue(pluginObject, null); - } - - pi = t.GetProperty("Text"); - if (pi != null) - { - text = (string)pi.GetValue(pluginObject, null); - } - - pi = t.GetProperty("Description"); - if (pi != null) - { - description = (string)pi.GetValue(pluginObject, null); - } - - pi = t.GetProperty("Version"); - if (pi != null) - { - version = Convert.ToDecimal(pi.GetValue(pluginObject, null)); - } - - pi = t.GetProperty("ActionType"); - if (pi != null) - { - actionType = (string)pi.GetValue(pluginObject, null); - } - - mi = t.GetMethod("DoAction"); - - pi = t.GetProperty("Shortcut"); - if (pi != null) - { - shortcut = (string)pi.GetValue(pluginObject, null); - } - - return pluginObject; - } - - return null; - } - - private void LoadPlugins() - { - var path = Configuration.PluginsDirectory; - if (!Directory.Exists(path)) - { - return; - } - - UiUtil.CleanUpMenuItemPlugin(fileToolStripMenuItem); - UiUtil.CleanUpMenuItemPlugin(toolsToolStripMenuItem); - UiUtil.CleanUpMenuItemPlugin(toolStripMenuItemSpellCheckMain); - UiUtil.CleanUpMenuItemPlugin(toolStripMenuItemSynchronization); - UiUtil.CleanUpMenuItemPlugin(toolStripMenuItemAutoTranslate); - UiUtil.CleanUpMenuItemPlugin(toolStripMenuItemTranslateSelected); - - var fileMenuItems = new List(); - var toolsMenuItems = new List(); - var translateMenuItems = new List(); - var translateSelectedLinesMenuItems = new List(); - var syncMenuItems = new List(); - var spellCheckMenuItems = new List(); - - foreach (var pluginFileName in Directory.GetFiles(path, "*.DLL")) - { - try - { - GetPropertiesAndDoAction(pluginFileName, out var name, out var text, out var version, out var description, out var actionType, out var shortcut, out var mi); - if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(actionType) && mi != null) - { - var item = new ToolStripMenuItem { Text = text, Tag = pluginFileName }; - UiUtil.FixFonts(item); - - if (!string.IsNullOrEmpty(shortcut)) - { - item.ShortcutKeys = UiUtil.GetKeys(shortcut); - } - - if (actionType.Equals("File", StringComparison.OrdinalIgnoreCase)) - { - AddSeparator(fileMenuItems.Count, fileToolStripMenuItem, 2); - item.Click += PluginToolClick; - fileMenuItems.Add(item); - } - else if (actionType.Equals("Tool", StringComparison.OrdinalIgnoreCase)) - { - AddSeparator(toolsMenuItems.Count, toolsToolStripMenuItem); - item.Click += PluginToolClick; - toolsMenuItems.Add(item); - } - else if (actionType.Equals("Sync", StringComparison.OrdinalIgnoreCase)) - { - AddSeparator(syncMenuItems.Count, toolStripMenuItemSynchronization); - item.Click += PluginToolClick; - syncMenuItems.Add(item); - } - else if (actionType.Equals("Translate", StringComparison.OrdinalIgnoreCase)) - { - AddSeparator(translateMenuItems.Count, toolStripMenuItemAutoTranslate); - item.Click += PluginClickTranslate; - translateMenuItems.Add(item); - - // selected lines - item = new ToolStripMenuItem(); - item.Text = text; - item.Tag = pluginFileName; - UiUtil.FixFonts(item); - AddSeparator(translateMenuItems.Count - 1, toolStripMenuItemTranslateSelected); - item.Click += PluginClickTranslateSelectedLines; - translateSelectedLinesMenuItems.Add(item); - } - else if (actionType.Equals("SpellCheck", StringComparison.OrdinalIgnoreCase)) - { - AddSeparator(spellCheckMenuItems.Count, toolStripMenuItemSpellCheckMain); - item.Click += PluginClickNoFormatChange; - spellCheckMenuItems.Add(item); - } - } - } - catch (Exception exception) - { - MessageBox.Show(string.Format(_language.ErrorLoadingPluginXErrorY, pluginFileName, exception.Message)); - } - } - foreach (var fileMenuItem in fileMenuItems) - { - fileToolStripMenuItem.DropDownItems.Insert(fileToolStripMenuItem.DropDownItems.Count - 2, fileMenuItem); - } - toolsToolStripMenuItem.DropDownItems.AddRange(toolsMenuItems.OrderBy(p => p.Text).ToArray()); - toolStripMenuItemAutoTranslate.DropDownItems.AddRange(translateMenuItems.OrderBy(p => p.Text).ToArray()); - toolStripMenuItemTranslateSelected.DropDownItems.AddRange(translateSelectedLinesMenuItems.OrderBy(p => p.Text).ToArray()); - toolStripMenuItemSynchronization.DropDownItems.AddRange(syncMenuItems.OrderBy(p => p.Text).ToArray()); - toolStripMenuItemSpellCheckMain.DropDownItems.AddRange(spellCheckMenuItems.OrderBy(p => p.Text).ToArray()); - } - - private void AddSeparator(int pluginCount, ToolStripMenuItem parent, int? relativeOffset = null) - { - if (pluginCount == 0) - { - var tss = new ToolStripSeparator(); - if (relativeOffset == null) - { - if (parent.DropDownItems.Count > 0 && parent.DropDownItems[parent.DropDownItems.Count - 1].GetType() == typeof(ToolStripSeparator)) - { - return; // don't app separator after separator - } - - parent.DropDownItems.Add(tss); - } - else - { - if (parent.DropDownItems.Count - relativeOffset.Value >= 0 && - relativeOffset.Value < parent.DropDownItems.Count && - parent.DropDownItems.Count > 0 && - parent.DropDownItems[parent.DropDownItems.Count - relativeOffset.Value].GetType() == typeof(ToolStripSeparator)) - { - return; // don't app separator after separator - } - - parent.DropDownItems.Insert(parent.DropDownItems.Count - relativeOffset.Value, tss); - } - - UiUtil.FixFonts(tss); - } - } - - private void PluginToolClick(object sender, EventArgs e) - { - CallPlugin(sender, true, false); - } - - private void PluginClickNoFormatChange(object sender, EventArgs e) - { - CallPlugin(sender, false, false); - } - - private void PluginClickTranslate(object sender, EventArgs e) - { - CallPlugin(sender, false, true); - } - - private void PluginClickTranslateSelectedLines(object sender, EventArgs e) - { - CallPluginTranslateSelectedLines(sender); - } - - private void CallPlugin(object sender, bool allowChangeFormat, bool translate) - { - try - { - var item = (ToolStripItem)sender; - var pluginObject = GetPropertiesAndDoAction(item.Tag.ToString(), out var name, out var text, out var version, out var description, out var actionType, out var shortcut, out var mi); - if (mi == null) - { - return; - } - - string rawText = null; - var format = GetCurrentSubtitleFormat(); - if (format != null) - { - rawText = _subtitle.ToText(format); - } - - string pluginResult = (string)mi.Invoke(pluginObject, - new object[] - { - this, - _subtitle.ToText(new SubRip()), - Configuration.Settings.General.CurrentFrameRate, - Configuration.Settings.General.ListViewLineSeparatorString, - _fileName, - VideoFileName, - rawText - }); - - if (!string.IsNullOrEmpty(pluginResult) && pluginResult.Length > 10 && text != pluginResult) - { - var lines = new List(pluginResult.SplitToLines()); - - MakeHistoryForUndo(string.Format(_language.BeforeRunningPluginXVersionY, name, version)); - - var s = new Subtitle(); - SubtitleFormat newFormat = null; - foreach (var subtitleFormat in SubtitleFormat.AllSubtitleFormats) - { - if (subtitleFormat.IsMine(lines, null)) - { - subtitleFormat.LoadSubtitle(s, lines, null); - newFormat = subtitleFormat; - break; - } - } - - if (translate) - { - _subtitleAlternate = new Subtitle(_subtitle); - _subtitleAlternateFileName = _fileName; - - var language = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(s); - if (language != null && !string.IsNullOrEmpty(_fileName)) - { - _fileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); - var oldLang = "." + LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate); - if (oldLang.Length == 3 && _fileName.EndsWith(oldLang, StringComparison.OrdinalIgnoreCase)) - { - _fileName = _fileName.Remove(_fileName.Length - 3); - } - - _fileName += "." + language + GetCurrentSubtitleFormat().Extension; - } - else - { - _fileName = null; - } - - _subtitle.Paragraphs.Clear(); - foreach (var p in s.Paragraphs) - { - _subtitle.Paragraphs.Add(new Paragraph(p)); - } - - ShowStatus(_language.SubtitleTranslated); - ShowSource(); - SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); - SubtitleListview1.AutoSizeAllColumns(this); - SetupAlternateEdit(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - ResetHistory(); - RestoreSubtitleListviewIndices(); - _converted = true; - SetTitle(); - return; - } - - if (newFormat != null) - { - if (allowChangeFormat && newFormat.GetType() == typeof(SubRip) && IsOnlyTextChanged(_subtitle, s)) - { - allowChangeFormat = false; - } - - if (!allowChangeFormat && IsOnlyTextChanged(_subtitle, s)) - { - for (int k = 0; k < s.Paragraphs.Count; k++) - { - _subtitle.Paragraphs[k].Text = s.Paragraphs[k].Text; - } - } - else - { - _subtitle.Paragraphs.Clear(); - _subtitle.Header = s.Header; - _subtitle.Footer = s.Footer; - foreach (var p in s.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - } - - if (allowChangeFormat) - { - SetCurrentFormat(newFormat); - } - - SaveSubtitleListviewIndices(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - ShowSource(); - - ShowStatus(string.Format(_language.PluginXExecuted, name)); - } - else - { - MessageBox.Show(_language.UnableToReadPluginResult); - } - } - } - catch (Exception exception) - { - MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace); - if (exception.InnerException != null) - { - MessageBox.Show(exception.InnerException.Message + Environment.NewLine + exception.InnerException.StackTrace); - } - } - } - - private void CallPluginTranslateSelectedLines(object sender) - { - try - { - var item = (ToolStripItem)sender; - var pluginObject = GetPropertiesAndDoAction(item.Tag.ToString(), out var name, out var text, out var version, out var description, out var actionType, out var shortcut, out var mi); - if (mi == null) - { - return; - } - - SaveSubtitleListviewIndices(); - var selectedLines = new Subtitle(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.Paragraphs[index]; - if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - p = original; - } - else - { - p = new Paragraph(string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds); - } - } - - selectedLines.Paragraphs.Add(p); - } - - string rawText = null; - SubtitleFormat format = GetCurrentSubtitleFormat(); - if (format != null) - { - rawText = selectedLines.ToText(format); - } - - string pluginResult = (string)mi.Invoke(pluginObject, - new object[] - { - this, - selectedLines.ToText(new SubRip()), - Configuration.Settings.General.CurrentFrameRate, - Configuration.Settings.General.ListViewLineSeparatorString, - _fileName, - VideoFileName, - rawText - }); - - if (!string.IsNullOrEmpty(pluginResult) && pluginResult.Length > 10 && text != pluginResult) - { - var lines = new List(pluginResult.SplitToLines()); - MakeHistoryForUndo(string.Format(_language.BeforeRunningPluginXVersionY, name, version)); - var s = new Subtitle(); - var f = new SubRip(); - if (f.IsMine(lines, null)) - { - f.LoadSubtitle(s, lines, null); - - // we only update selected lines - int i = 0; - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index] = s.Paragraphs[i]; - i++; - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - ShowStatus(string.Format(_language.PluginXExecuted, name)); - } - } - } - catch (Exception exception) - { - MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace); - if (exception.InnerException != null) - { - MessageBox.Show(exception.InnerException.Message + Environment.NewLine + exception.InnerException.StackTrace); - } - } - } - - private bool IsOnlyTextChanged(Subtitle s1, Subtitle s2) - { - if (s1.Paragraphs.Count != s2.Paragraphs.Count) - { - return false; - } - - for (int i = 0; i < s1.Paragraphs.Count; i++) - { - var p1 = s1.Paragraphs[i]; - var p2 = s2.Paragraphs[i]; - if (Math.Abs(p1.StartTime.TotalMilliseconds - p2.StartTime.TotalMilliseconds) > 0.01) - { - return false; - } - - if (Math.Abs(p1.EndTime.TotalMilliseconds - p2.EndTime.TotalMilliseconds) > 0.01) - { - return false; - } - } - - return true; - } - - private string _lastWrittenAutoBackup = string.Empty; - private bool _showAutoBackupError = true; - - private void TimerAutoBackupTick(object sender, EventArgs e) - { - string currentText = string.Empty; - if (_subtitle != null && _subtitle.Paragraphs.Count > 0) - { - var saveFormat = GetCurrentSubtitleFormat(); - if (!saveFormat.IsTextBased) - { - saveFormat = new SubRip(); - } - - currentText = _subtitle.ToText(saveFormat); - if (_textAutoBackup == null) - { - _textAutoBackup = currentText; - } - - if ((Configuration.Settings.General.AutoSave || - !string.IsNullOrEmpty(_textAutoBackup) && currentText.Trim() != _textAutoBackup.Trim() && !string.IsNullOrWhiteSpace(currentText)) && - _lastWrittenAutoBackup != currentText) - { - if (!Directory.Exists(Configuration.AutoBackupDirectory)) - { - try - { - Directory.CreateDirectory(Configuration.AutoBackupDirectory); - } - catch (Exception exception) - { - 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.AutoBackupDirectory, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, title, saveFormat.Extension); - try - { - File.WriteAllText(fileName, currentText); - _lastWrittenAutoBackup = currentText; - } - catch (Exception exception) - { - if (_showAutoBackupError) - { - MessageBox.Show("Unable to save auto-backup to file: " + fileName + Environment.NewLine + - Environment.NewLine + - exception.Message + Environment.NewLine + exception.StackTrace); - _showAutoBackupError = false; - } - } - - if (!_cleanupHasRun) - { - // let the cleanup process be handled by worker thread - System.Threading.Tasks.Task.Factory.StartNew(() => { RestoreAutoBackup.CleanAutoBackupFolder(Configuration.AutoBackupDirectory, Configuration.Settings.General.AutoBackupDeleteAfterMonths); }); - _cleanupHasRun = true; - } - } - } - - _textAutoBackup = currentText; - - if (_subtitleAlternateFileName != null && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - var saveFormat = GetCurrentSubtitleFormat(); - if (!saveFormat.IsTextBased) - { - saveFormat = new SubRip(); - } - - string currentTextAlternate = _subtitleAlternate.ToText(saveFormat); - if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - if (_textAutoBackupOriginal == null) - { - _textAutoBackupOriginal = currentTextAlternate; - } - - if (Configuration.Settings.General.AutoSave || - !string.IsNullOrEmpty(_textAutoBackupOriginal) && currentTextAlternate.Trim() != _textAutoBackupOriginal.Trim() && !string.IsNullOrWhiteSpace(currentTextAlternate)) - { - if (!Directory.Exists(Configuration.AutoBackupDirectory)) - { - try - { - Directory.CreateDirectory(Configuration.AutoBackupDirectory); - } - catch (Exception exception) - { - MessageBox.Show(string.Format(_language.UnableToCreateBackupDirectory, Configuration.AutoBackupDirectory, exception.Message)); - return; - } - } - - 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.AutoBackupDirectory, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, "_Original" + title, saveFormat.Extension); - File.WriteAllText(fileName, currentTextAlternate); - } - } - - _textAutoBackupOriginal = currentTextAlternate; - } - } - - private void DropVideoTick(object sender, EventArgs e) - { - _dragAndDropVideoTimer.Stop(); - OpenVideo(VideoFileName); - } - - private void mediaPlayer_DragDrop(object sender, DragEventArgs e) - { - var files = (string[])e.Data.GetData(DataFormats.FileDrop); - if (files.Length == 1) - { - string fileName = files[0]; - string ext = Path.GetExtension(fileName).ToLowerInvariant(); - if (Utilities.GetVideoFileFilter(true).Contains(ext)) - { - if (string.IsNullOrEmpty(_fileName)) - { - var dirName = Path.GetDirectoryName(fileName); - saveFileDialog1.InitialDirectory = dirName; - openFileDialog1.InitialDirectory = dirName; - } - - VideoFileName = fileName; - _dragAndDropVideoTimer.Start(); - } - else - { - try - { - var fi = new FileInfo(fileName); - if (fi.Length < Subtitle.MaxFileSize) - { - var lines = new List(File.ReadAllLines(fileName)); - foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) - { - if (format.IsMine(lines, fileName)) - { - OpenSubtitle(fileName, null); - return; - } - } - } - } - catch - { - } - - MessageBox.Show(string.Format(_language.DropFileXNotAccepted, fileName)); - } - } - else - { - MessageBox.Show(_language.DropOnlyOneFile); - } - } - - private void mediaPlayer_DragEnter(object sender, DragEventArgs e) - { - // make sure they're actually dropping files (not text or anything else) - if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) - { - e.Effect = DragDropEffects.All; - } - } - - private void buttonSecBack2_Click(object sender, EventArgs e) - { - GoBackSeconds((double)numericUpDownSec2.Value); - } - - private void buttonForward2_Click(object sender, EventArgs e) - { - GoBackSeconds(-(double)numericUpDownSec2.Value); - } - - private void buttonAdjustSecBack2_Click(object sender, EventArgs e) - { - GoBackSeconds((double)numericUpDownSecAdjust2.Value); - } - - private void buttonAdjustSecForward2_Click(object sender, EventArgs e) - { - GoBackSeconds(-(double)numericUpDownSecAdjust2.Value); - } - - private void translatepoweredByMicrosoftToolStripMenuItem_Click(object sender, EventArgs e) - { - TranslateViaGoogle(false, false); - } - - private void AudioWaveform_Click(object sender, EventArgs e) - { - if (audioVisualizer.WavePeaks == null) - { - if (VideoFileName != null && (VideoFileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || - VideoFileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase))) - { - return; - } - - if (string.IsNullOrEmpty(VideoFileName)) - { - buttonOpenVideo_Click(sender, e); - if (string.IsNullOrEmpty(VideoFileName)) - { - return; - } - - if (audioVisualizer.WavePeaks != null && File.Exists(WavePeakGenerator.GetPeakWaveFileName(VideoFileName))) - { - return; // waveform already exists and is loaded - } - } - - mediaPlayer.Pause(); - using (var addWaveform = new AddWaveform()) - { - var videoAudioTrackNumber = VideoAudioTrackNumber; - if (mediaPlayer.VideoPlayer is LibVlcDynamic && VideoAudioTrackNumber != -1) - { - videoAudioTrackNumber -= 1; - } - - var peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(VideoFileName, videoAudioTrackNumber); - var spectrogramFolder = WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(VideoFileName, videoAudioTrackNumber); - - if (WavePeakGenerator.IsFileValidForVisualizer(VideoFileName)) - { - addWaveform.InitializeViaWaveFile(VideoFileName, peakWaveFileName, spectrogramFolder); - } - else - { - addWaveform.Initialize(VideoFileName, peakWaveFileName, spectrogramFolder, videoAudioTrackNumber); - } - - if (addWaveform.ShowDialog() == DialogResult.OK) - { - audioVisualizer.ZoomFactor = 1.0; - audioVisualizer.VerticalZoomFactor = 1.0; - SelectZoomTextInComboBox(); - audioVisualizer.WavePeaks = addWaveform.Peaks; - audioVisualizer.SetSpectrogram(addWaveform.Spectrogram); - timerWaveform.Start(); - } - - if (videoAudioTrackNumber != addWaveform.AudioTrackNumber) - { - if (mediaPlayer.VideoPlayer is LibVlcDynamic libVlc) - { - libVlc.AudioTrackNumber = addWaveform.AudioTrackNumber + 1; - VideoAudioTrackNumber = addWaveform.AudioTrackNumber + 1; - } - else if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv) - { - libMpv.AudioTrackNumber = addWaveform.AudioTrackNumber; - VideoAudioTrackNumber = addWaveform.AudioTrackNumber; - } - } - } - - if (mediaPlayer.Chapters?.Count > 0) - { - audioVisualizer.Chapters = mediaPlayer.Chapters; - } - } - } - - private void ReloadWaveform(string fileName, int audioTrackNumber) - { - if (audioVisualizer.WavePeaks != null) - { - audioVisualizer.WavePeaks = null; - audioVisualizer.SetSpectrogram(null); - audioVisualizer.SceneChanges = new List(); - audioVisualizer.Chapters = new List(); - } - - if (mediaPlayer.VideoPlayer is LibVlcDynamic && audioTrackNumber != -1) - { - audioTrackNumber -= 1; - } - - var peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(fileName, audioTrackNumber); - var spectrogramFolder = WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(VideoFileName, audioTrackNumber); - - if (File.Exists(peakWaveFileName)) - { - audioVisualizer.ZoomFactor = 1.0; - audioVisualizer.VerticalZoomFactor = 1.0; - SelectZoomTextInComboBox(); - audioVisualizer.WavePeaks = WavePeakData.FromDisk(peakWaveFileName); - audioVisualizer.SetSpectrogram(SpectrogramData.FromDisk(spectrogramFolder)); - audioVisualizer.SceneChanges = SceneChangeHelper.FromDisk(VideoFileName); - SetWaveformPosition(0, 0, 0); - timerWaveform.Start(); - } - } - - private void timerWaveform_Tick(object sender, EventArgs e) - { - if (audioVisualizer.Visible && mediaPlayer.VideoPlayer != null && audioVisualizer.WavePeaks != null) - { - int index = -1; - if (SubtitleListview1.SelectedItems.Count > 0) - { - index = SubtitleListview1.SelectedItems[0].Index; - } - - if (audioVisualizer.Locked) - { - double startPos = mediaPlayer.CurrentPosition - ((audioVisualizer.EndPositionSeconds - audioVisualizer.StartPositionSeconds) / 2.0); - if (startPos < 0) - { - startPos = 0; - } - - SetWaveformPosition(startPos, mediaPlayer.CurrentPosition, index); - } - else if (mediaPlayer.CurrentPosition > audioVisualizer.EndPositionSeconds || mediaPlayer.CurrentPosition < audioVisualizer.StartPositionSeconds) - { - double startPos = mediaPlayer.CurrentPosition - 0.01; - if (startPos < 0) - { - startPos = 0; - } - - audioVisualizer.ClearSelection(); - SetWaveformPosition(startPos, mediaPlayer.CurrentPosition, index); - } - else - { - SetWaveformPosition(audioVisualizer.StartPositionSeconds, mediaPlayer.CurrentPosition, index); - } - - bool paused = mediaPlayer.IsPaused; - toolStripButtonWaveformPause.Visible = !paused; - toolStripButtonWaveformPlay.Visible = paused; - } - else - { - toolStripButtonWaveformPlay.Visible = true; - toolStripButtonWaveformPause.Visible = false; - } - } - - private void addParagraphHereToolStripMenuItem_Click(object sender, EventArgs e) - { - audioVisualizer.ClearSelection(); - var newParagraph = new Paragraph(audioVisualizer.NewSelectionParagraph); - - mediaPlayer.Pause(); - - // find index where to insert - int index = 0; - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - var p = _subtitle.Paragraphs[i]; - if (p.StartTime.TotalMilliseconds > newParagraph.StartTime.TotalMilliseconds && - (!p.StartTime.IsMaxTime || !HasSmallerStartTimes(_subtitle, i + 1, newParagraph.StartTime.TotalMilliseconds))) - { - break; - } - - index++; - } - - SetStyleForNewParagraph(newParagraph, index); - - MakeHistoryForUndo(_language.BeforeInsertLine); - - // create and insert - if (_networkSession != null) - { - _networkSession.TimerStop(); - NetworkGetSendUpdates(new List(), index, newParagraph); - } - else - { - _subtitle.Paragraphs.Insert(index, newParagraph); - - if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph)); - _subtitleAlternate.Renumber(); - } - - _subtitleListViewIndex = -1; - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - - textBoxListViewText.Focus(); - audioVisualizer.NewSelectionParagraph = null; - - ShowStatus(string.Format(_language.VideoControls.NewTextInsertAtX, newParagraph.StartTime.ToShortString())); - audioVisualizer.Invalidate(); - } - - private static bool HasSmallerStartTimes(Subtitle subtitle, int startIndex, double startMs) - { - for (int i = startIndex; i < subtitle.Paragraphs.Count; i++) - { - var p = subtitle.Paragraphs[i]; - if (startMs > p.StartTime.TotalMilliseconds && !p.StartTime.IsMaxTime) - { - return true; - } - } - - return false; - } - - private void addParagraphAndPasteToolStripMenuItem_Click(object sender, EventArgs e) - { - addParagraphHereToolStripMenuItem_Click(sender, e); - textBoxListViewText.Text = Clipboard.GetText(); - } - - private void mergeWithPreviousToolStripMenuItem_Click(object sender, EventArgs e) - { - int index = _subtitle.GetIndex(audioVisualizer.RightClickedParagraph); - if (index >= 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - MergeBeforeToolStripMenuItemClick(null, null); - } - - audioVisualizer.Invalidate(); - } - - private void deleteParagraphToolStripMenuItem_Click(object sender, EventArgs e) - { - int index = _subtitle.GetIndex(audioVisualizer.RightClickedParagraph); - if (index >= 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - ToolStripMenuItemDeleteClick(null, null); - } - - audioVisualizer.Invalidate(); - } - - private void splitToolStripMenuItem1_Click(object sender, EventArgs e) - { - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - if (audioVisualizer.RightClickedParagraph.StartTime.TotalMilliseconds == _subtitle.Paragraphs[i].StartTime.TotalMilliseconds && - audioVisualizer.RightClickedParagraph.EndTime.TotalMilliseconds == _subtitle.Paragraphs[i].EndTime.TotalMilliseconds) - { - SubtitleListview1.SelectIndexAndEnsureVisible(i, true); - SplitSelectedParagraph(_audioWaveformRightClickSeconds, null); - break; - } - } - - audioVisualizer.Invalidate(); - } - - private void mergeWithNextToolStripMenuItem_Click(object sender, EventArgs e) - { - int index = _subtitle.GetIndex(audioVisualizer.RightClickedParagraph); - if (index >= 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - MergeAfterToolStripMenuItemClick(null, null); - } - - audioVisualizer.Invalidate(); - } - - private void extendToPreviousToolStripMenuItem_Click(object sender, EventArgs e) - { - int index = _subtitle.GetIndex(audioVisualizer.RightClickedParagraph); - if (index >= 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - ExtendSelectedLinesToPreviousLine(); - } - - audioVisualizer.Invalidate(); - } - - private void extendToNextToolStripMenuItem_Click(object sender, EventArgs e) - { - int index = _subtitle.GetIndex(audioVisualizer.RightClickedParagraph); - if (index >= 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - ExtendSelectedLinesToNextLine(); - } - - audioVisualizer.Invalidate(); - } - - private void goToPreviousSubtitleToolStripMenuItem_Click(object sender, EventArgs e) - { - if (audioVisualizer.RightClickedParagraph != null) - { - GoToPreviousSubtitle(audioVisualizer.RightClickedParagraph.StartTime.TotalMilliseconds); - } - else - { - GoToPreviousSubtitle(mediaPlayer.CurrentPosition * TimeCode.BaseUnit); - } - } - - private void goToNextSubtitleToolStripMenuItem_Click(object sender, EventArgs e) - { - if (audioVisualizer.RightClickedParagraph != null) - { - GoToNextSubtitle(audioVisualizer.RightClickedParagraph.StartTime.TotalMilliseconds); - } - else - { - GoToNextSubtitle(mediaPlayer.CurrentPosition * TimeCode.BaseUnit); - } - } - - private void buttonWaveformZoomIn_Click(object sender, EventArgs e) - { - if (audioVisualizer.WavePeaks != null && audioVisualizer.Visible) - { - audioVisualizer.ZoomFactor += 0.1; - } - } - - private void buttonWaveformZoomOut_Click(object sender, EventArgs e) - { - if (audioVisualizer.WavePeaks != null && audioVisualizer.Visible) - { - audioVisualizer.ZoomFactor -= 0.1; - } - } - - private void buttonWaveformZoomReset_Click(object sender, EventArgs e) - { - if (audioVisualizer.WavePeaks != null && audioVisualizer.Visible) - { - audioVisualizer.ZoomFactor = 1.0; - } - } - - private void toolStripMenuItemWaveformPlaySelection_Click(object sender, EventArgs e) - { - WaveformPlaySelection(); - } - - private void WaveformPlaySelection(bool nearEnd = false) - { - if (mediaPlayer.VideoPlayer != null) - { - var p = - audioVisualizer.NewSelectionParagraph ?? - audioVisualizer.SelectedParagraph; - - if (p != null) - { - double startSeconds = p.StartTime.TotalSeconds; - _endSeconds = p.EndTime.TotalSeconds; - if (nearEnd) - { - startSeconds = Math.Max(startSeconds, _endSeconds - 1.0); - } - - mediaPlayer.CurrentPosition = startSeconds; - UiUtil.ShowSubtitle(_subtitle, mediaPlayer); - mediaPlayer.Play(); - } - } - } - - private void toolStripButtonWaveformZoomIn_Click(object sender, EventArgs e) - { - if (audioVisualizer.WavePeaks != null && audioVisualizer.Visible) - { - audioVisualizer.ZoomFactor += 0.1; - SelectZoomTextInComboBox(); - } - } - - private void toolStripButtonWaveformZoomOut_Click(object sender, EventArgs e) - { - if (audioVisualizer.WavePeaks != null && audioVisualizer.Visible) - { - audioVisualizer.ZoomFactor -= 0.1; - SelectZoomTextInComboBox(); - } - } - - private void toolStripComboBoxWaveform_SelectedIndexChanged(object sender, EventArgs e) - { - try - { - if (toolStripComboBoxWaveform.SelectedItem is ComboBoxZoomItem item) - { - audioVisualizer.ZoomFactor = item.ZoomFactor; - } - } - catch - { - // ignore - } - } - - private void SelectZoomTextInComboBox() - { - int i = 0; - foreach (ComboBoxZoomItem item in toolStripComboBoxWaveform.Items) - { - if (Math.Abs(audioVisualizer.ZoomFactor - item.ZoomFactor) < 0.001) - { - toolStripComboBoxWaveform.SelectedIndex = i; - return; - } - - i++; - } - } - - private void toolStripButtonWaveformPause_Click(object sender, EventArgs e) - { - mediaPlayer.Pause(); - } - - private void toolStripButtonWaveformPlay_Click(object sender, EventArgs e) - { - mediaPlayer.Play(); - } - - private void toolStripButtonLockCenter_Click(object sender, EventArgs e) - { - toolStripButtonLockCenter.Checked = !toolStripButtonLockCenter.Checked; - audioVisualizer.Locked = toolStripButtonLockCenter.Checked; - Configuration.Settings.General.WaveformCenter = audioVisualizer.Locked; - } - - private void trackBarWaveformPosition_ValueChanged(object sender, EventArgs e) - { - mediaPlayer.CurrentPosition = trackBarWaveformPosition.Value; - } - - private void buttonCustomUrl_Click(object sender, EventArgs e) - { - RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl1); - } - - private void buttonCustomUrl2_Click(object sender, EventArgs e) - { - RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl2); - } - - private void ShowhideWaveformToolStripMenuItemClick(object sender, EventArgs e) - { - toolStripButtonToggleWaveform_Click(null, null); - } - - private void AudioWaveformDragEnter(object sender, DragEventArgs e) - { - // make sure they're actually dropping files (not text or anything else) - if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) - { - e.Effect = DragDropEffects.All; - } - } - - private void AudioWaveformDragDrop(object sender, DragEventArgs e) - { - var files = (string[])e.Data.GetData(DataFormats.FileDrop); - if (files.Length != 1) - { - MessageBox.Show(_language.DropOnlyOneFile); - return; - } - - string fileName = files[0]; - string ext = Path.GetExtension(fileName).ToLowerInvariant(); - if (ext != ".wav" || !WavePeakGenerator.IsFileValidForVisualizer(fileName)) - { - if (audioVisualizer.WavePeaks == null && (Utilities.VideoFileExtensions.Contains(ext) || Utilities.AudioFileExtensions.Contains(ext))) - { - VideoFileName = fileName; - AudioWaveform_Click(null, null); - OpenVideo(VideoFileName); - return; - } - - try - { - var fi = new FileInfo(fileName); - if (fi.Length < 1024 * 500) - { - var lines = new List(File.ReadAllLines(fileName)); - foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) - { - if (format.IsMine(lines, fileName)) - { - OpenSubtitle(fileName, null); - return; - } - } - } - } - catch - { - } - } - - if (ext != ".wav") - { - MessageBox.Show(".wav only!"); - return; - } - - if (VideoFileName == null) - { - OpenVideo(fileName); - return; - } - - using (var addWaveform = new AddWaveform()) - { - string peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(VideoFileName); - string spectrogramFolder = WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(VideoFileName); - addWaveform.InitializeViaWaveFile(fileName, peakWaveFileName, spectrogramFolder); - if (addWaveform.ShowDialog() == DialogResult.OK) - { - audioVisualizer.WavePeaks = addWaveform.Peaks; - audioVisualizer.SetSpectrogram(addWaveform.Spectrogram); - timerWaveform.Start(); - } - } - } - - private void toolStripMenuItemImportBluRaySup_Click(object sender, EventArgs e) - { - if (ContinueNewOrExit()) - { - openFileDialog1.Title = _language.OpenBluRaySupFile; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = _language.BluRaySupFiles + "|*.sup"; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - if (!FileUtil.IsBluRaySup(openFileDialog1.FileName) && FileUtil.IsSpDvdSup(openFileDialog1.FileName)) - { - ImportAndOcrSpDvdSup(openFileDialog1.FileName, false); - return; - } - - ImportAndOcrBluRaySup(openFileDialog1.FileName, false); - } - } - } - - private void ImportAndOcrBluRaySup(string fileName, bool showInTaskbar) - { - var log = new StringBuilder(); - var subtitles = BluRaySupParser.ParseBluRaySup(fileName, log); - if (subtitles.Count == 0) - { - string msg = _language.BlurayNotSubtitlesFound + Environment.NewLine + Environment.NewLine + log.ToString(); - if (msg.Length > 800) - { - msg = msg.Substring(0, 800); - } - - MessageBox.Show(msg.Trim() + "..."); - return; - } - - using (var vobSubOcr = new VobSubOcr()) - { - if (showInTaskbar) - { - vobSubOcr.Icon = (Icon)Icon.Clone(); - vobSubOcr.ShowInTaskbar = true; - vobSubOcr.ShowIcon = true; - } - - vobSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, fileName); - vobSubOcr.FileName = Path.GetFileName(fileName); - if (vobSubOcr.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeImportingBluRaySupFile); - FileNew(); - _subtitle.Paragraphs.Clear(); - SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); - foreach (var p in vobSubOcr.SubtitleFromOcr.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - _subtitleListViewIndex = -1; - SubtitleListview1.FirstVisibleIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - - _fileName = Path.ChangeExtension(fileName, GetCurrentSubtitleFormat().Extension); - SetTitle(); - _converted = true; - - Configuration.Settings.Save(); - } - else - { - _exitWhenLoaded = _loading; - } - } - } - - private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) - { - GetFocusedTextBox().SelectAll(); - } - - private void cutToolStripMenuItem_Click(object sender, EventArgs e) - { - GetFocusedTextBox().Cut(); - } - - private void copyToolStripMenuItem_Click(object sender, EventArgs e) - { - GetFocusedTextBox().Copy(); - } - - private void PasteToolStripMenuItemClick(object sender, EventArgs e) - { - GetFocusedTextBox().Paste(); - } - - private void DeleteToolStripMenuItemClick(object sender, EventArgs e) - { - GetFocusedTextBox().SelectedText = string.Empty; - } - - private void NormalToolStripMenuItem1Click(object sender, EventArgs e) - { - var tb = GetFocusedTextBox(); - - if (tb.SelectionLength == 0) - { - var allText = HtmlUtil.RemoveHtmlTags(tb.Text); - allText = NetflixImsc11Japanese.RemoveTags(allText); - tb.Text = allText; - return; - } - - string text = tb.SelectedText; - int selectionStart = tb.SelectionStart; - text = HtmlUtil.RemoveHtmlTags(text); - text = NetflixImsc11Japanese.RemoveTags(text); - tb.SelectedText = text; - tb.SelectionStart = selectionStart; - tb.SelectionLength = text.Length; - } - - private SETextBox GetFocusedTextBox() - { - if (!textBoxListViewTextAlternate.Visible) - { - return textBoxListViewText; - } - - return textBoxListViewTextAlternate.Focused ? textBoxListViewTextAlternate : textBoxListViewText; - } - - private void TextBoxListViewToggleTag(string tag) - { - var tb = GetFocusedTextBox(); - - string text; - int selectionStart = tb.SelectionStart; - - // No text selected. - if (tb.SelectedText.Length == 0) - { - text = tb.Text; - - // Split lines (split a subtitle into its lines). - var lines = text.SplitToLines(); - - // Get current line index (the line where the cursor is current located). - int numberOfNewLines = 0; - for (int i = 0; i < tb.SelectionStart && i < text.Length; i++) - { - if (text[i] == '\n') - { - numberOfNewLines++; - } - } - int selectedLineIdx = numberOfNewLines; // Do not use 'GetLineFromCharIndex' as it also counts when lines are wrapped - - // Get line from index. - string selectedLine = lines[selectedLineIdx]; - - // Test if line at where cursor is current at is a dialog. - bool isDialog = selectedLine.StartsWith('-') || - selectedLine.StartsWith("<" + tag + ">-", StringComparison.OrdinalIgnoreCase); - - // Will be used keep cursor in its previous location after toggle/untoggle. - int textLen = text.Length; - - // 1st set the cursor position to zero. - tb.SelectionStart = 0; - - // If is dialog, only toggle/Untoggle line where caret/cursor is current at. - if (isDialog) - { - lines[selectedLineIdx] = HtmlUtil.ToggleTag(selectedLine, tag); - text = string.Join(Environment.NewLine, lines); - } - else - { - text = HtmlUtil.ToggleTag(text, tag); - } - - tb.Text = text; - // Note: Math.Max will prevent blowing if caret is at the begining and tag was untoggled. - tb.SelectionStart = textLen > text.Length ? Math.Max(selectionStart - 3, 0) : selectionStart + 3; - } - else - { - string post = string.Empty; - string pre = string.Empty; - // There is text selected - text = tb.SelectedText; - while (text.EndsWith(' ') || text.EndsWith(Environment.NewLine, StringComparison.Ordinal) || text.StartsWith(' ') || text.StartsWith(Environment.NewLine, StringComparison.Ordinal)) - { - if (text.EndsWith(' ')) - { - post += " "; - text = text.Remove(text.Length - 1); - } - - if (text.EndsWith(Environment.NewLine, StringComparison.Ordinal)) - { - post += Environment.NewLine; - text = text.Remove(text.Length - 2); - } - - if (text.StartsWith(' ')) - { - pre += " "; - text = text.Remove(0, 1); - } - - if (text.StartsWith(Environment.NewLine, StringComparison.Ordinal)) - { - pre += Environment.NewLine; - text = text.Remove(0, 2); - } - } - - text = HtmlUtil.ToggleTag(text, tag); - // Update text and maintain selection. - if (pre.Length > 0) - { - text = pre + text; - selectionStart += pre.Length; - } - - if (post.Length > 0) - { - text = text + post; - } - - tb.SelectedText = text; - tb.SelectionStart = selectionStart; - tb.SelectionLength = text.Length; - } - } - - private void BoldToolStripMenuItem1Click(object sender, EventArgs e) - { - TextBoxListViewToggleTag(HtmlUtil.TagBold); - } - - private void ItalicToolStripMenuItem1Click(object sender, EventArgs e) - { - TextBoxListViewToggleTag(HtmlUtil.TagItalic); - } - - private void UnderlineToolStripMenuItem1Click(object sender, EventArgs e) - { - TextBoxListViewToggleTag(HtmlUtil.TagUnderline); - } - - private void ColorToolStripMenuItem1Click(object sender, EventArgs e) - { - var tb = GetFocusedTextBox(); - string text = tb.SelectedText; - if (string.IsNullOrEmpty(text) && tb.Text.Length > 0) - { - text = tb.Text; - tb.SelectAll(); - } - int selectionStart = tb.SelectionStart; - - string color; - var formatType = GetCurrentSubtitleFormat().GetType(); - if (formatType == typeof(Ebu)) - { - using (var form = new EbuColorPicker(true)) - { - if (form.ShowDialog(this) != DialogResult.OK) - { - return; - } - - color = form.Color; - } - } - else if (formatType == typeof(ScenaristClosedCaptions) || formatType == typeof(ScenaristClosedCaptionsDropFrame)) - { - using (var form = new EbuColorPicker(false)) - { - if (form.ShowDialog(this) != DialogResult.OK) - { - return; - } - - color = form.Color; - } - } - else - { - if (colorDialog1.ShowDialog(this) != DialogResult.OK) - { - return; - } - - color = Utilities.ColorToHex(colorDialog1.Color); - } - - bool done = false; - string pre = string.Empty; - if (selectionStart == 0 && text.StartsWith("{\\", StringComparison.Ordinal) && text.IndexOf('}') >= 0) - { - int endIndex = text.IndexOf('}') + 1; - pre = text.Substring(0, endIndex); - text = text.Remove(0, endIndex); - } - - string s = text; - if (s.StartsWith("'); - if (end > 0) - { - string f = s.Substring(0, end); - if (f.Contains(" face=", StringComparison.OrdinalIgnoreCase) && !f.Contains(" color=", StringComparison.OrdinalIgnoreCase)) - { - var start = s.IndexOf(" face=", StringComparison.OrdinalIgnoreCase); - s = s.Insert(start, string.Format(" color=\"{0}\"", color)); - text = s; - done = true; - } - else if (f.Contains(" color=", StringComparison.OrdinalIgnoreCase)) - { - int colorStart = f.IndexOf(" color=", StringComparison.OrdinalIgnoreCase); - if (s.IndexOf('"', colorStart + " color=".Length + 1) > 0) - { - end = s.IndexOf('"', colorStart + " color=".Length + 1); - } - - s = s.Substring(0, colorStart) + string.Format(" color=\"{0}", color) + s.Substring(end); - text = s; - done = true; - } - } - } - - if (!done) - { - text = $"{pre}{text}"; - } - else - { - text = pre + text; - } - - tb.SelectedText = text; - tb.SelectionStart = selectionStart; - tb.SelectionLength = text.Length; - } - - private void FontNameToolStripMenuItemClick(object sender, EventArgs e) - { - var tb = GetFocusedTextBox(); - - // font name - string text = tb.SelectedText; - if (string.IsNullOrEmpty(text) && tb.Text.Length > 0) - { - text = tb.Text; - tb.SelectAll(); - } - int selectionStart = tb.SelectionStart; - - using (var form = new ChooseFontName()) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - bool done = false; - - string pre = string.Empty; - if (selectionStart == 0 && text.StartsWith("{\\", StringComparison.Ordinal) && text.IndexOf('}') >= 0) - { - int endIndex = text.IndexOf('}') + 1; - pre = text.Substring(0, endIndex); - text = text.Remove(0, endIndex); - } - - if (text.StartsWith("'); - if (end > 0) - { - string f = text.Substring(0, end); - if (f.Contains(" color=", StringComparison.OrdinalIgnoreCase) && !f.Contains(" face=", StringComparison.OrdinalIgnoreCase)) - { - var start = text.IndexOf(" color=", StringComparison.OrdinalIgnoreCase); - text = text.Insert(start, string.Format(" face=\"{0}\"", form.FontName)); - done = true; - } - else if (f.Contains(" face=", StringComparison.OrdinalIgnoreCase)) - { - int faceStart = f.IndexOf(" face=", StringComparison.OrdinalIgnoreCase); - if (text.IndexOf('"', faceStart + " face=".Length + 1) > 0) - { - end = text.IndexOf('"', faceStart + " face=".Length + 1); - } - - text = text.Substring(0, faceStart) + string.Format(" face=\"{0}", form.FontName) + text.Substring(end); - done = true; - } - } - } - - if (!done) - { - text = $"{pre}{text}"; - } - else - { - text = pre + text; - } - - tb.SelectedText = text; - tb.SelectionStart = selectionStart; - tb.SelectionLength = text.Length; - } - } - } - - public void SetSubtitle(Subtitle subtitle, string message) - { - _subtitle = subtitle; - SubtitleListview1.Fill(subtitle, _subtitleAlternate); - ShowStatus(message); - } - - #region Networking - - private void startServerToolStripMenuItem_Click(object sender, EventArgs e) - { - using (var networkNew = new NetworkStart()) - { - _networkSession = new NikseWebServiceSession(_subtitle, _subtitleAlternate, TimerWebServiceTick, OnUpdateUserLogEntries); - networkNew.Initialize(_networkSession, _fileName); - if (networkNew.ShowDialog(this) == DialogResult.OK) - { - _networkSession.AppendToLog(string.Format(_language.XStartedSessionYAtZ, _networkSession.CurrentUser.UserName, _networkSession.SessionId, DateTime.Now.ToLongTimeString())); - toolStripStatusNetworking.Visible = true; - toolStripStatusNetworking.Text = _language.NetworkMode; - EnableDisableControlsNotWorkingInNetworkMode(false); - SubtitleListview1.ShowNetworkColumn(_language.UserAndAction); - SubtitleListview1.AutoSizeAllColumns(this); - TimerWebServiceTick(null, null); - } - else - { - _networkSession = null; - } - } - } - - private void joinSessionToolStripMenuItem_Click(object sender, EventArgs e) - { - _networkSession = new NikseWebServiceSession(_subtitle, _subtitleAlternate, TimerWebServiceTick, OnUpdateUserLogEntries); - using (var networkJoin = new NetworkJoin()) - { - networkJoin.Initialize(_networkSession); - - if (networkJoin.ShowDialog(this) == DialogResult.OK) - { - _subtitle = _networkSession.Subtitle; - _subtitleAlternate = _networkSession.OriginalSubtitle; - if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); - } - - _fileName = networkJoin.FileName; - SetTitle(); - toolStripStatusNetworking.Visible = true; - toolStripStatusNetworking.Text = _language.NetworkMode; - EnableDisableControlsNotWorkingInNetworkMode(false); - _networkSession.AppendToLog(string.Format(_language.XStartedSessionYAtZ, _networkSession.CurrentUser.UserName, _networkSession.SessionId, DateTime.Now.ToLongTimeString())); - SubtitleListview1.ShowNetworkColumn(_language.UserAndAction); - SubtitleListview1.AutoSizeAllColumns(this); - _subtitleListViewIndex = -1; - _oldSelectedParagraph = null; - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - buttonUnBreak.Visible = false; - buttonAutoBreak.Visible = false; - buttonSplitLine.Visible = false; - - textBoxListViewText.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; - textBoxListViewText.Width = (groupBoxEdit.Width - (textBoxListViewText.Left + 10)) / 2; - textBoxListViewTextAlternate.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; - textBoxListViewTextAlternate.Left = textBoxListViewText.Left + textBoxListViewText.Width + 3; - textBoxListViewTextAlternate.Width = textBoxListViewText.Width; - textBoxListViewTextAlternate.Visible = true; - labelAlternateText.Text = _languageGeneral.OriginalText; - labelAlternateText.Visible = true; - labelAlternateCharactersPerSecond.Visible = true; - labelTextAlternateLineLengths.Visible = true; - labelAlternateSingleLine.Visible = true; - labelAlternateSingleLinePixels.Visible = true; - labelTextAlternateLineTotal.Visible = true; - - labelCharactersPerSecond.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelCharactersPerSecond.Width); - labelTextLineTotal.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelTextLineTotal.Width); - AddAlternate(); - Main_Resize(null, null); - _changeAlternateSubtitleHash = _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName); - } - else - { - RemoveAlternate(false, true); - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - TimerWebServiceTick(null, null); - } - else - { - _networkSession = null; - } - } - } - - private void EnableDisableControlsNotWorkingInNetworkMode(bool enabled) - { - //Top menu - newToolStripMenuItem.Enabled = enabled; - openToolStripMenuItem.Enabled = enabled; - reopenToolStripMenuItem.Enabled = enabled; - toolStripMenuItemOpenContainingFolder.Enabled = enabled; - toolStripMenuItemCompare.Enabled = enabled; - toolStripMenuItemImportDvdSubtitles.Enabled = enabled; - toolStripMenuItemSubIdx.Enabled = enabled; - toolStripMenuItemImportBluRaySup.Enabled = enabled; - matroskaImportStripMenuItem.Enabled = enabled; - toolStripMenuItemManualAnsi.Enabled = enabled; - toolStripMenuItemImportText.Enabled = enabled; - toolStripMenuItemImportTimeCodes.Enabled = enabled; - - showHistoryforUndoToolStripMenuItem.Enabled = enabled; - multipleReplaceToolStripMenuItem.Enabled = enabled; - - toolsToolStripMenuItem.Enabled = enabled; - - toolStripMenuItemSynchronization.Enabled = enabled; - - toolStripMenuItemAutoTranslate.Enabled = enabled; - - //Toolbar - toolStripButtonFileNew.Enabled = enabled; - toolStripButtonFileOpen.Enabled = enabled; - toolStripMenuItemOpenKeepVideo.Enabled = enabled; - toolStripMenuItemRestoreAutoBackup.Enabled = enabled; - toolStripButtonVisualSync.Enabled = enabled; - - // textbox source - textBoxSource.ReadOnly = !enabled; - } - - internal void TimerWebServiceTick(object sender, EventArgs e) - { - if (_networkSession == null) - { - return; - } - - List deleteIndices = new List(); - NetworkGetSendUpdates(deleteIndices, 0, null); - } - - private void NetworkGetSendUpdates(List deleteIndices, int insertIndex, Paragraph insertParagraph) - { - _networkSession.TimerStop(); - - bool doReFill = false; - bool updateListViewStatus = false; - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - string message = string.Empty; - - int numberOfLines = 0; - List updates = null; - int numberOfRetries = 10; - while (numberOfRetries > 0) - { - numberOfRetries--; - try - { - updates = _networkSession.GetUpdates(out message, out numberOfLines); - numberOfRetries = 0; - } - catch (Exception exception) - { - if (numberOfRetries <= 0) - { - if (exception.InnerException != null) - { - MessageBox.Show(string.Format(_language.NetworkUnableToConnectToServer, exception.InnerException.Message + Environment.NewLine + exception.InnerException.StackTrace)); - } - else - { - MessageBox.Show(string.Format(_language.NetworkUnableToConnectToServer, exception.Message + Environment.NewLine + exception.StackTrace)); - } - - _networkSession.TimerStop(); - if (_networkChat != null && !_networkChat.IsDisposed) - { - _networkChat.Close(); - _networkChat = null; - } - - _networkSession = null; - EnableDisableControlsNotWorkingInNetworkMode(true); - toolStripStatusNetworking.Visible = false; - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Network); - _networkChat = null; - return; - } - - Application.DoEvents(); - System.Threading.Thread.Sleep(250); - } - } - - int currentSelectedIndex = -1; - if (SubtitleListview1.SelectedItems.Count > 0) - { - currentSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - } - - int oldCurrentSelectedIndex = currentSelectedIndex; - if (message == "OK") - { - foreach (var update in updates) - { - if (!string.IsNullOrEmpty(update.Text)) - { - if (!update.Text.Contains(Environment.NewLine)) - { - update.Text = update.Text.Replace("\n", Environment.NewLine); - } - - update.Text = WebUtility.HtmlDecode(update.Text).Replace("
", Environment.NewLine); - } - - if (update.User.Ip != _networkSession.CurrentUser.Ip || update.User.UserName != _networkSession.CurrentUser.UserName) - { - if (update.Action == "USR") - { - _networkSession.Users.Add(update.User); - if (_networkChat != null && !_networkChat.IsDisposed) - { - _networkChat.AddUser(update.User); - } - - _networkSession.AppendToLog(string.Format(_language.NetworkNewUser, update.User.UserName, update.User.Ip)); - } - else if (update.Action == "MSG") - { - _networkSession.ChatLog.Add(new NikseWebServiceSession.ChatEntry { User = update.User, Message = update.Text }); - if (_networkChat == null || _networkChat.IsDisposed) - { - _networkChat = new NetworkChat(); - _networkChat.Initialize(_networkSession); - _networkChat.Show(this); - } - else - { - _networkChat.AddChatMessage(update.User, update.Text); - } - - if (!string.IsNullOrEmpty(Configuration.Settings.NetworkSettings.NewMessageSound) && File.Exists(Configuration.Settings.NetworkSettings.NewMessageSound)) - { - try - { - using (var soundPlayer = new System.Media.SoundPlayer(Configuration.Settings.NetworkSettings.NewMessageSound)) - { - soundPlayer.Play(); - } - } - catch - { - } - } - - _networkSession.AppendToLog(string.Format(_language.NetworkMessage, update.User.UserName, update.User.Ip, update.Text)); - } - else if (update.Action == "DEL") - { - doReFill = true; - _subtitle.Paragraphs.RemoveAt(update.Index); - if (_networkSession.LastSubtitle != null) - { - _networkSession.LastSubtitle.Paragraphs.RemoveAt(update.Index); - } - - _networkSession.AppendToLog(string.Format(_language.NetworkDelete, update.User.UserName, update.User.Ip, update.Index)); - _networkSession.AdjustUpdateLogToDelete(update.Index); - - if (deleteIndices.Count > 0) - { - for (int i = deleteIndices.Count - 1; i >= 0; i--) - { - int index = deleteIndices[i]; - if (index == update.Index) - { - deleteIndices.RemoveAt(i); - } - else if (index > update.Index) - { - deleteIndices[i] = index - 1; - } - } - } - - if (insertIndex > update.Index) - { - insertIndex--; - } - - if (currentSelectedIndex >= 0 && currentSelectedIndex > update.Index) - { - currentSelectedIndex--; - } - } - else if (update.Action == "INS") - { - doReFill = true; - var p = new Paragraph(update.Text, update.StartMilliseconds, update.EndMilliseconds); - _subtitle.Paragraphs.Insert(update.Index, p); - if (_networkSession.LastSubtitle != null) - { - _networkSession.LastSubtitle.Paragraphs.Insert(update.Index, new Paragraph(p)); - } - - _networkSession.AppendToLog(string.Format(_language.NetworkInsert, update.User.UserName, update.User.Ip, update.Index, UiUtil.GetListViewTextFromString(update.Text))); - _networkSession.AddToWsUserLog(update.User, update.Index, update.Action, false); - updateListViewStatus = true; - _networkSession.AdjustUpdateLogToInsert(update.Index); - - if (deleteIndices.Count > 0) - { - for (int i = deleteIndices.Count - 1; i >= 0; i--) - { - int index = deleteIndices[i]; - if (index > update.Index) - { - deleteIndices[i] = index + 1; - } - } - } - - if (insertIndex > update.Index) - { - insertIndex++; - } - - if (currentSelectedIndex >= 0 && currentSelectedIndex > update.Index) - { - currentSelectedIndex++; - } - } - else if (update.Action == "UPD") - { - updateListViewStatus = true; - var p = _subtitle.GetParagraphOrDefault(update.Index); - if (p != null) - { - p.StartTime.TotalMilliseconds = update.StartMilliseconds; - p.EndTime.TotalMilliseconds = update.EndMilliseconds; - p.Text = update.Text; - SubtitleListview1.SetTimeAndText(update.Index, p, _subtitle.GetParagraphOrDefault(update.Index + 1)); - _networkSession.AppendToLog(string.Format(_language.NetworkUpdate, update.User.UserName, update.User.Ip, update.Index, UiUtil.GetListViewTextFromString(update.Text))); - _networkSession.AddToWsUserLog(update.User, update.Index, update.Action, true); - updateListViewStatus = true; - } - - if (_networkSession.LastSubtitle != null) - { - p = _networkSession.LastSubtitle.GetParagraphOrDefault(update.Index); - if (p != null) - { - p.StartTime.TotalMilliseconds = update.StartMilliseconds; - p.EndTime.TotalMilliseconds = update.EndMilliseconds; - p.Text = update.Text; - } - } - } - else if (update.Action == "BYE") - { - if (_networkChat != null && !_networkChat.IsDisposed) - { - _networkChat.RemoveUser(update.User); - } - - SeNetworkService.SeUser removeUser = null; - foreach (var user in _networkSession.Users) - { - if (user.UserName == update.User.UserName) - { - removeUser = user; - break; - } - } - - if (removeUser != null) - { - _networkSession.Users.Remove(removeUser); - } - - _networkSession.AppendToLog(string.Format(_language.NetworkByeUser, update.User.UserName, update.User.Ip)); - } - else - { - _networkSession.AppendToLog("UNKNOWN ACTION: " + update.Action + " by " + update.User.UserName + " (" + update.User.Ip + ")"); - } - } - } - - if (numberOfLines != _subtitle.Paragraphs.Count) - { - _subtitle = _networkSession.ReloadSubtitle(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - UpdateListviewWithUserLogEntries(); - _networkSession.LastSubtitle = new Subtitle(_subtitle); - _oldSelectedParagraph = null; - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - _networkSession.TimerStart(); - RefreshSelectedParagraph(); - return; - } - - if (deleteIndices.Count > 0) - { - deleteIndices.Sort(); - deleteIndices.Reverse(); - foreach (int i in deleteIndices) - { - _subtitle.Paragraphs.RemoveAt(i); - if (_networkSession.LastSubtitle != null && i < _networkSession.LastSubtitle.Paragraphs.Count) - { - _networkSession.LastSubtitle.Paragraphs.RemoveAt(i); - } - } - - _networkSession.DeleteLines(deleteIndices); - doReFill = true; - } - - if (insertIndex >= 0 && insertParagraph != null) - { - _subtitle.Paragraphs.Insert(insertIndex, insertParagraph); - if (_networkSession.LastSubtitle != null && insertIndex < _networkSession.LastSubtitle.Paragraphs.Count) - { - _networkSession.LastSubtitle.Paragraphs.Insert(insertIndex, insertParagraph); - } - - _networkSession.InsertLine(insertIndex, insertParagraph); - doReFill = true; - } - - _networkSession.CheckForAndSubmitUpdates(); // updates only (no inserts/deletes) - } - else - { - if (message == "Session not found!") - { - message = _networkSession.Restart(); - if (message == "Reload") - { - _subtitle = _networkSession.ReloadSubtitle(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - UpdateListviewWithUserLogEntries(); - _networkSession.LastSubtitle = new Subtitle(_subtitle); - _oldSelectedParagraph = null; - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - _networkSession.TimerStart(); - RefreshSelectedParagraph(); - return; - } - - if (message == "OK") - { - _networkSession.TimerStart(); - RefreshSelectedParagraph(); - return; - } - } - else if (message == "User not found!") - { - message = _networkSession.ReJoin(); - if (message == "Reload") - { - _subtitle = _networkSession.ReloadSubtitle(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - UpdateListviewWithUserLogEntries(); - _networkSession.LastSubtitle = new Subtitle(_subtitle); - _oldSelectedParagraph = null; - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - _networkSession.TimerStart(); - RefreshSelectedParagraph(); - return; - } - } - - MessageBox.Show(message); - LeaveSessionToolStripMenuItemClick(null, null); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - return; - } - - if (doReFill) - { - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - UpdateListviewWithUserLogEntries(); - - if (oldCurrentSelectedIndex != currentSelectedIndex) - { - _oldSelectedParagraph = null; - _subtitleListViewIndex = currentSelectedIndex; - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex); - } - else if (_oldSelectedParagraph != null) - { - var p = _subtitle.GetFirstAlike(_oldSelectedParagraph); - if (p == null) - { - var tmp = new Paragraph(_oldSelectedParagraph); - tmp.Text = textBoxListViewText.Text; - p = _subtitle.GetFirstAlike(tmp); - } - - if (p == null) - { - int idx = oldCurrentSelectedIndex; - if (idx >= _subtitle.Paragraphs.Count) - { - idx = _subtitle.Paragraphs.Count - 1; - } - - if (idx >= 0 && idx < _subtitle.Paragraphs.Count) - { - SubtitleListview1.SelectIndexAndEnsureVisible(idx); - _listViewTextUndoIndex = -1; - SubtitleListView1SelectedIndexChange(); - textBoxListViewText.Text = _subtitle.Paragraphs[idx].Text; - } - } - else - { - _subtitleListViewIndex = _subtitle.GetIndex(p); - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex); - _listViewTextUndoIndex = -1; - SubtitleListView1SelectedIndexChange(); - } - } - } - else if (updateListViewStatus) - { - UpdateListviewWithUserLogEntries(); - } - - _networkSession.LastSubtitle = new Subtitle(_subtitle); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - _networkSession.TimerStart(); - } - - private void UpdateListviewWithUserLogEntries() - { - SubtitleListview1.BeginUpdate(); - foreach (UpdateLogEntry entry in _networkSession.UpdateLog) - { - SubtitleListview1.SetNetworkText(entry.Index, entry.ToString(), Utilities.GetColorFromUserName(entry.UserName)); - } - - SubtitleListview1.EndUpdate(); - } - - private void LeaveSessionToolStripMenuItemClick(object sender, EventArgs e) - { - if (_networkSession != null) - { - _networkSession.TimerStop(); - _networkSession.Leave(); - } - - if (_networkChat != null && !_networkChat.IsDisposed) - { - _networkChat.Close(); - _networkChat = null; - } - - _networkSession = null; - EnableDisableControlsNotWorkingInNetworkMode(true); - toolStripStatusNetworking.Visible = false; - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Network); - _networkChat = null; - } - - private void toolStripMenuItemNetworking_DropDownOpening(object sender, EventArgs e) - { - startServerToolStripMenuItem.Visible = _networkSession == null; - joinSessionToolStripMenuItem.Visible = _networkSession == null; - showSessionKeyLogToolStripMenuItem.Visible = _networkSession != null; - leaveSessionToolStripMenuItem.Visible = _networkSession != null; - chatToolStripMenuItem.Visible = _networkSession != null; - } - - internal void OnUpdateUserLogEntries(object sender, EventArgs e) - { - UpdateListviewWithUserLogEntries(); - } - - private void toolStripStatusNetworking_Click(object sender, EventArgs e) - { - showSessionKeyLogToolStripMenuItem_Click(null, null); - } - - private void showSessionKeyLogToolStripMenuItem_Click(object sender, EventArgs e) - { - using (var networkLog = new NetworkLogAndInfo()) - { - networkLog.Initialize(_networkSession); - networkLog.ShowDialog(this); - } - } - - private void chatToolStripMenuItem_Click(object sender, EventArgs e) - { - if (_networkSession != null) - { - if (_networkChat == null || _networkChat.IsDisposed) - { - _networkChat = new NetworkChat(); - _networkChat.Initialize(_networkSession); - _networkChat.Show(this); - } - else - { - _networkChat.WindowState = FormWindowState.Normal; - } - } - } - - #endregion Networking - - private void UnDockVideoPlayer() - { - bool firstUndock = _videoPlayerUndocked != null && !_videoPlayerUndocked.IsDisposed; - - _videoPlayerUndocked = new VideoPlayerUndocked(this, mediaPlayer); - - if (firstUndock) - { - Configuration.Settings.General.UndockedVideoPosition = _videoPlayerUndocked.Left + @";" + _videoPlayerUndocked.Top + @";" + _videoPlayerUndocked.Width + @";" + _videoPlayerUndocked.Height; - } - - Control control = null; - if (splitContainer1.Panel2.Controls.Count == 0) - { - control = panelVideoPlayer; - groupBoxVideo.Controls.Remove(control); - } - else - { - control = panelVideoPlayer; - splitContainer1.Panel2.Controls.Clear(); - } - - if (control != null) - { - control.Top = 0; - control.Left = 0; - control.Width = _videoPlayerUndocked.PanelContainer.Width; - control.Height = _videoPlayerUndocked.PanelContainer.Height; - _videoPlayerUndocked.PanelContainer.Controls.Add(control); - } - } - - public void ReDockVideoPlayer(Control control) - { - groupBoxVideo.Controls.Add(control); - mediaPlayer.FontSizeFactor = 1.0F; - mediaPlayer.SetSubtitleFont(); - mediaPlayer.SubtitleText = string.Empty; - } - - private void UnDockWaveform() - { - _waveformUndocked = new WaveformUndocked(this); - - var control = audioVisualizer; - groupBoxVideo.Controls.Remove(control); - control.Top = 0; - control.Left = 0; - control.Width = _waveformUndocked.PanelContainer.Width; - control.Height = _waveformUndocked.PanelContainer.Height - panelWaveformControls.Height; - _waveformUndocked.PanelContainer.Controls.Add(control); - - var control2 = (Control)panelWaveformControls; - groupBoxVideo.Controls.Remove(control2); - control2.Top = control.Height; - control2.Left = 0; - _waveformUndocked.PanelContainer.Controls.Add(control2); - - var control3 = (Control)trackBarWaveformPosition; - groupBoxVideo.Controls.Remove(control3); - control3.Top = control.Height; - control3.Left = control2.Width + 2; - control3.Width = _waveformUndocked.PanelContainer.Width - control3.Left; - _waveformUndocked.PanelContainer.Controls.Add(control3); - } - - public void ReDockWaveform(Control waveform, Control buttons, Control trackBar) - { - groupBoxVideo.Controls.Add(waveform); - waveform.Top = 30; - waveform.Height = groupBoxVideo.Height - (waveform.Top + buttons.Height + 10); - - groupBoxVideo.Controls.Add(buttons); - buttons.Top = waveform.Top + waveform.Height + 5; - - groupBoxVideo.Controls.Add(trackBar); - trackBar.Top = buttons.Top; - } - - private void UnDockVideoButtons() - { - _videoControlsUndocked = new VideoControlsUndocked(this); - var control = tabControlButtons; - groupBoxVideo.Controls.Remove(control); - control.Top = 25; - control.Left = 0; - _videoControlsUndocked.PanelContainer.Controls.Add(control); - - groupBoxVideo.Controls.Remove(checkBoxSyncListViewWithVideoWhilePlaying); - _videoControlsUndocked.PanelContainer.Controls.Add(checkBoxSyncListViewWithVideoWhilePlaying); - checkBoxSyncListViewWithVideoWhilePlaying.Top = 5; - checkBoxSyncListViewWithVideoWhilePlaying.Left = 5; - - splitContainerMain.Panel2Collapsed = true; - splitContainer1.Panel2Collapsed = true; - } - - public void ReDockVideoButtons(Control videoButtons, Control checkBoxSyncSubWithVideo) - { - groupBoxVideo.Controls.Add(videoButtons); - videoButtons.Top = 12; - videoButtons.Left = 5; - - groupBoxVideo.Controls.Add(checkBoxSyncSubWithVideo); - checkBoxSyncSubWithVideo.Top = 11; - checkBoxSyncSubWithVideo.Left = videoButtons.Left + videoButtons.Width + 5; - } - - private void UndockVideoControlsToolStripMenuItemClick(object sender, EventArgs e) - { - if (Configuration.Settings.General.Undocked) - { - return; - } - - Configuration.Settings.General.Undocked = true; - if (!_loading) - { - Configuration.Settings.General.SplitContainerMainSplitterDistance = splitContainerMain.SplitterDistance; - Configuration.Settings.General.SplitContainer1SplitterDistance = splitContainer1.SplitterDistance; - Configuration.Settings.General.SplitContainerListViewAndTextSplitterDistance = splitContainerListViewAndText.SplitterDistance; - } - - var top = Math.Max(Top, 0); - var left = Math.Max(Left, 0); - UnDockVideoPlayer(); - splitContainerListViewAndText.SplitterDistance = splitContainerListViewAndText.Height - 109; - if (toolStripButtonToggleVideo.Checked) - { - _videoPlayerUndocked.Show(this); - if (_videoPlayerUndocked.Top < 0 || _videoPlayerUndocked.Left < 0) - { - _videoPlayerUndocked.WindowState = FormWindowState.Normal; - _videoPlayerUndocked.Top = top + 40; - _videoPlayerUndocked.Left = Math.Abs(left - 20); - _videoPlayerUndocked.Width = 600; - _videoPlayerUndocked.Height = 400; - } - } - - UnDockWaveform(); - if (toolStripButtonToggleWaveform.Checked) - { - _waveformUndocked.Show(this); - if (_waveformUndocked.Top < 0 || _waveformUndocked.Left < 0) - { - _waveformUndocked.WindowState = FormWindowState.Normal; - _waveformUndocked.Top = top + 60; - _waveformUndocked.Left = Math.Abs(left - 15); - _waveformUndocked.Width = 600; - _waveformUndocked.Height = 200; - } - } - - UnDockVideoButtons(); - _videoControlsUndocked.Show(this); - if (_videoControlsUndocked.Top < 0 || _videoControlsUndocked.Left < 0) - { - _videoControlsUndocked.WindowState = FormWindowState.Normal; - _videoControlsUndocked.Top = top + 40; - _videoControlsUndocked.Left = Math.Abs(left - 10); - _videoControlsUndocked.Width = tabControlButtons.Width + 20; - _videoControlsUndocked.Height = tabControlButtons.Height + 65; - } - - _isVideoControlsUndocked = true; - SetUndockedWindowsTitle(); - - undockVideoControlsToolStripMenuItem.Visible = false; - redockVideoControlsToolStripMenuItem.Visible = true; - - tabControl1_SelectedIndexChanged(null, null); - _videoControlsUndocked.Refresh(); - } - - public void RedockVideoControlsToolStripMenuItemClick(object sender, EventArgs e) - { - if (!Configuration.Settings.General.Undocked) - { - return; - } - - mediaPlayer.ShowNonFullScreenControls(); - - SaveUndockedPositions(); - - Configuration.Settings.General.Undocked = false; - - if (_videoControlsUndocked != null && !_videoControlsUndocked.IsDisposed) - { - var control = _videoControlsUndocked.PanelContainer.Controls[0]; - var controlCheckBox = _videoControlsUndocked.PanelContainer.Controls[1]; - _videoControlsUndocked.PanelContainer.Controls.Clear(); - ReDockVideoButtons(control, controlCheckBox); - _videoControlsUndocked.Close(); - _videoControlsUndocked = null; - } - - if (_waveformUndocked != null && !_waveformUndocked.IsDisposed) - { - var controlWaveform = _waveformUndocked.PanelContainer.Controls[0]; - var controlButtons = _waveformUndocked.PanelContainer.Controls[1]; - var controlTrackBar = _waveformUndocked.PanelContainer.Controls[2]; - _waveformUndocked.PanelContainer.Controls.Clear(); - ReDockWaveform(controlWaveform, controlButtons, controlTrackBar); - _waveformUndocked.Close(); - _waveformUndocked = null; - } - - if (_videoPlayerUndocked != null && !_videoPlayerUndocked.IsDisposed) - { - var control = _videoPlayerUndocked.PanelContainer.Controls[0]; - _videoPlayerUndocked.PanelContainer.Controls.Remove(control); - ReDockVideoPlayer(control); - _videoPlayerUndocked.Close(); - _videoPlayerUndocked = null; - mediaPlayer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton; - } - - _isVideoControlsUndocked = false; - _videoPlayerUndocked = null; - _waveformUndocked = null; - _videoControlsUndocked = null; - ShowVideoPlayer(); - - audioVisualizer.Visible = toolStripButtonToggleWaveform.Checked; - trackBarWaveformPosition.Visible = toolStripButtonToggleWaveform.Checked; - panelWaveformControls.Visible = toolStripButtonToggleWaveform.Checked; - if (!toolStripButtonToggleVideo.Checked) - { - HideVideoPlayer(); - } - - mediaPlayer.Invalidate(); - Refresh(); - - undockVideoControlsToolStripMenuItem.Visible = true; - redockVideoControlsToolStripMenuItem.Visible = false; - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex, true); - - splitContainerMain.SplitterDistance = Configuration.Settings.General.SplitContainerMainSplitterDistance; - splitContainer1.SplitterDistance = Configuration.Settings.General.SplitContainer1SplitterDistance; - splitContainerListViewAndText.SplitterDistance = Configuration.Settings.General.SplitContainerListViewAndTextSplitterDistance; - } - - private void Bw_DoWork(object sender, DoWorkEventArgs e) - { - System.Threading.Thread.Sleep(1200); - } - - internal void SetWaveformToggleOff() - { - toolStripButtonToggleWaveform.Checked = false; - } - - internal void SetVideoPlayerToggleOff() - { - toolStripButtonToggleVideo.Checked = false; - } - - private void ToolStripMenuItemInsertSubtitleClick(object sender, EventArgs e) - { - openFileDialog1.Title = _languageGeneral.OpenSubtitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - if (!File.Exists(openFileDialog1.FileName)) - { - return; - } - - var fi = new FileInfo(openFileDialog1.FileName); - if (fi.Length > 1024 * 1024 * 10) // max 10 mb - { - var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, openFileDialog1.FileName); - if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return; - } - } - - MakeHistoryForUndo(string.Format(_language.BeforeInsertLine, openFileDialog1.FileName)); - - var subtitle = new Subtitle(); - SubtitleFormat format = subtitle.LoadSubtitle(openFileDialog1.FileName, out var encoding, null); - - if (format != null) - { - SaveSubtitleListviewIndices(); - if (Configuration.Settings.General.RemoveBlankLinesWhenOpening) - { - subtitle.RemoveEmptyLines(); - } - - int index = FirstSelectedIndex + 1; - if (index < 0) - { - index = 0; - } - - var last = _subtitle.GetParagraphOrDefault(index - 1); - var newFirst = subtitle.GetParagraphOrDefault(0); - if (last != null && newFirst != null && newFirst.StartTime.TotalMilliseconds < last.EndTime.TotalMilliseconds) - { - var addMilliseconds = last.EndTime.TotalMilliseconds - newFirst.StartTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; - subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(addMilliseconds)); - } - - foreach (var p in subtitle.Paragraphs) - { - _subtitle.Paragraphs.Insert(index, new Paragraph(p)); - index++; - } - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - index = FirstSelectedIndex; - if (index < 0) - { - index = 0; - } - - var current = _subtitle.GetParagraphOrDefault(index); - if (current != null) - { - var original = Utilities.GetOriginalParagraph(index, current, _subtitleAlternate.Paragraphs); - if (original != null) - { - index = _subtitleAlternate.GetIndex(original); - foreach (var p in subtitle.Paragraphs) - { - _subtitleAlternate.Paragraphs.Insert(index, new Paragraph(p)); - index++; - } - - if (subtitle.Paragraphs.Count > 0) - { - _subtitleAlternate.Renumber(); - } - } - } - } - - _subtitle.Renumber(); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - } - - private void InsertLineToolStripMenuItemClick(object sender, EventArgs e) - { - if (_subtitle == null || _subtitle.Paragraphs.Count == 0) - { - InsertBefore(); - } - else - { - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.Paragraphs.Count - 1, true); - InsertAfter(string.Empty); - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.Paragraphs.Count - 1, true); - } - } - - private void CloseVideoToolStripMenuItemClick(object sender, EventArgs e) - { - timer1.Stop(); - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.PauseAndDisposePlayer(); - } - - mediaPlayer.SetPlayerName(string.Empty); - mediaPlayer.ResetTimeLabel(); - mediaPlayer.VideoPlayer = null; - mediaPlayer.CurrentPosition = 0; - VideoFileName = null; - _videoInfo = null; - VideoAudioTrackNumber = -1; - labelVideoInfo.Text = _languageGeneral.NoVideoLoaded; - audioVisualizer.WavePeaks = null; - audioVisualizer.SetSpectrogram(null); - audioVisualizer.SceneChanges = new List(); - audioVisualizer.Chapters = new List(); - timeUpDownVideoPositionAdjust.TimeCode = new TimeCode(); - timeUpDownVideoPositionAdjust.Enabled = false; - timeUpDownVideoPosition.TimeCode = new TimeCode(); - timeUpDownVideoPosition.Enabled = false; - } - - private void ToolStripMenuItemVideoDropDownOpening(object sender, EventArgs e) - { - if (_isVideoControlsUndocked) - { - redockVideoControlsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls); - undockVideoControlsToolStripMenuItem.ShortcutKeys = Keys.None; - } - else - { - undockVideoControlsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls); - redockVideoControlsToolStripMenuItem.ShortcutKeys = Keys.None; - } - - closeVideoToolStripMenuItem.Visible = !string.IsNullOrEmpty(VideoFileName); - setVideoOffsetToolStripMenuItem.Visible = !string.IsNullOrEmpty(VideoFileName); - smpteTimeModedropFrameToolStripMenuItem.Visible = !string.IsNullOrEmpty(VideoFileName); - if (!string.IsNullOrEmpty(VideoFileName)) - { - if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) - { - setVideoOffsetToolStripMenuItem.Text = string.Format("{0} [{1}]", _language.Menu.Video.SetVideoOffset, new TimeCode(Configuration.Settings.General.CurrentVideoOffsetInMs).ToShortDisplayString()); - } - else - { - setVideoOffsetToolStripMenuItem.Text = _language.Menu.Video.SetVideoOffset; - } - - smpteTimeModedropFrameToolStripMenuItem.Checked = mediaPlayer.SmpteMode; - } - - toolStripMenuItemOpenVideoFromUrl.Visible = Configuration.Settings.General.VideoPlayer.Trim().Equals("MPV", StringComparison.OrdinalIgnoreCase) && - LibMpvDynamic.IsInstalled && - File.Exists(Path.Combine(Configuration.DataDirectory, "youtube-dl.exe")); - - toolStripMenuItemSetAudioTrack.Visible = false; - openSecondSubtitleToolStripMenuItem.Visible = false; - if (mediaPlayer.VideoPlayer is LibVlcDynamic libVlc) - { - openSecondSubtitleToolStripMenuItem.Visible = true; - var audioTracks = libVlc.GetAudioTracks(); - VideoAudioTrackNumber = libVlc.AudioTrackNumber; - if (audioTracks.Count > 1) - { - toolStripMenuItemSetAudioTrack.DropDownItems.Clear(); - for (int i = 0; i < audioTracks.Count; i++) - { - var at = audioTracks[i]; - toolStripMenuItemSetAudioTrack.DropDownItems.Add(string.IsNullOrWhiteSpace(at.Value) ? at.Key.ToString(CultureInfo.InvariantCulture) : at.Value, null, ChooseAudioTrack); - toolStripMenuItemSetAudioTrack.DropDownItems[toolStripMenuItemSetAudioTrack.DropDownItems.Count - 1].Tag = at.Key.ToString(CultureInfo.InvariantCulture); - if (at.Key == VideoAudioTrackNumber) - { - toolStripMenuItemSetAudioTrack.DropDownItems[toolStripMenuItemSetAudioTrack.DropDownItems.Count - 1].Select(); - } - } - - toolStripMenuItemSetAudioTrack.Visible = true; - } - } - else if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv) - { - openSecondSubtitleToolStripMenuItem.Visible = true; - var audioTracks = libMpv.AudioTracks; - VideoAudioTrackNumber = libMpv.AudioTrackNumber; - if (audioTracks.Count > 1) - { - toolStripMenuItemSetAudioTrack.DropDownItems.Clear(); - for (int i = 0; i < audioTracks.Count; i++) - { - var at = audioTracks[i]; - var trackText = string.IsNullOrWhiteSpace(at.Value) ? at.Key.ToString(CultureInfo.InvariantCulture) : "Track " + at.Key + " - " + char.ToUpper(at.Value[0]) + at.Value.Substring(1); - toolStripMenuItemSetAudioTrack.DropDownItems.Add(trackText, null, ChooseAudioTrack); - toolStripMenuItemSetAudioTrack.DropDownItems[toolStripMenuItemSetAudioTrack.DropDownItems.Count - 1].Tag = at.Key.ToString(CultureInfo.InvariantCulture); - if (i == VideoAudioTrackNumber) - { - toolStripMenuItemSetAudioTrack.DropDownItems[toolStripMenuItemSetAudioTrack.DropDownItems.Count - 1].Select(); - } - } - - toolStripMenuItemSetAudioTrack.Visible = true; - } - } - - if (mediaPlayer.VideoPlayer != null && audioVisualizer.WavePeaks != null && audioVisualizer.WavePeaks.Peaks.Count > 0) - { - toolStripMenuItemImportSceneChanges.Visible = true; - toolStripMenuItemRemoveSceneChanges.Visible = audioVisualizer.SceneChanges.Count > 0; - } - else - { - toolStripMenuItemImportSceneChanges.Visible = false; - toolStripMenuItemRemoveSceneChanges.Visible = false; - } - - if (mediaPlayer.VideoPlayer != null && VideoFileName.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase)) - { - toolStripMenuItemImportChapters.Visible = true; - } - else - { - toolStripMenuItemImportChapters.Visible = false; - } - - generateTextFromCurrentVideoToolStripMenuItem.Visible = Directory.Exists(Path.Combine(Configuration.DataDirectory, "pocketsphinx")); - } - - private void ChooseAudioTrack(object sender, EventArgs e) - { - if (mediaPlayer.VideoPlayer is LibVlcDynamic libVlc) - { - var item = sender as ToolStripItem; - int number = int.Parse(item.Tag.ToString()); - libVlc.AudioTrackNumber = number; - VideoAudioTrackNumber = number; - } - else if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv) - { - var item = sender as ToolStripItem; - int number = int.Parse(item.Tag.ToString()); - number--; - libMpv.AudioTrackNumber = number; - VideoAudioTrackNumber = number; - } - } - - private void textBoxListViewTextAlternate_TextChanged(object sender, EventArgs e) - { - if (_subtitleAlternate == null || _subtitleAlternate.Paragraphs.Count < 1) - { - return; - } - - if (_subtitleListViewIndex >= 0) - { - var original = Utilities.GetOriginalParagraph(_subtitleListViewIndex, _subtitle.Paragraphs[_subtitleListViewIndex], _subtitleAlternate.Paragraphs); - if (original != null) - { - string text = textBoxListViewTextAlternate.Text.TrimEnd(); - - // update _subtitle + listview - original.Text = text; - UpdateListViewTextInfo(labelTextAlternateLineLengths, labelAlternateSingleLine, labelAlternateSingleLinePixels, labelTextAlternateLineTotal, labelAlternateCharactersPerSecond, original, textBoxListViewTextAlternate); - SubtitleListview1.SetAlternateText(_subtitleListViewIndex, text); - FixVerticalScrollBars(textBoxListViewTextAlternate, ref _lastNumberOfNewLinesAlternate); - } - } - } - - private void TextBoxListViewTextAlternateKeyDown(object sender, KeyEventArgs e) - { - _listViewAlternateTextTicks = DateTime.UtcNow.Ticks; - if (_subtitleAlternate == null || _subtitleAlternate.Paragraphs.Count < 1) - { - return; - } - - if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.ShiftKey) - { - return; - } - - if (e.Modifiers == Keys.Control && e.KeyCode == (Keys.LButton | Keys.ShiftKey)) - { // surround ctrl+v action with history (for undo) - _listViewAlternateTextTicks = 0; - TimerAlternateTextUndoTick(sender, e); - Application.DoEvents(); - System.Threading.Thread.Sleep(50); - Application.DoEvents(); - _listViewAlternateTextTicks = 0; - TimerAlternateTextUndoTick(sender, e); - return; - } - - int numberOfLines = Utilities.GetNumberOfLines(textBoxListViewTextAlternate.Text); - - if (e.Modifiers == Keys.None && e.KeyCode == Keys.Enter && numberOfLines > Configuration.Settings.General.MaxNumberOfLines) - { - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainTextBoxAutoBreak) - { - BreakUnbreakTextBox(false, textBoxListViewTextAlternate); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainTextBoxUnbreak) - { - BreakUnbreakTextBox(true, textBoxListViewTextAlternate); - e.SuppressKeyPress = true; - } - else if (e.KeyData == _shortcuts.MainTextBoxBreakAtCursorPosition) - { - textBoxListViewTextAlternate.Text = Utilities.ReSplit(textBoxListViewTextAlternate.Text, textBoxListViewTextAlternate.SelectionStart); - var lines = textBoxListViewTextAlternate.Text.SplitToLines(); - if (lines.Count > 0) - { - textBoxListViewTextAlternate.SelectionStart = lines[0].Length; - } - - e.SuppressKeyPress = true; - } - - else if (e.KeyData == _shortcuts.MainTextBoxBreakAtCursorPosition) - { - textBoxListViewText.Text = Utilities.ReSplit(textBoxListViewText.Text, textBoxListViewText.SelectionStart); - ButtonNextClick(null, null); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.I) - { - if (textBoxListViewTextAlternate.SelectionLength == 0) - { - if (textBoxListViewTextAlternate.Text.Contains("")) - { - textBoxListViewTextAlternate.Text = HtmlUtil.RemoveOpenCloseTags(textBoxListViewTextAlternate.Text, HtmlUtil.TagItalic); - } - else - { - textBoxListViewTextAlternate.Text = string.Format("{0}", textBoxListViewTextAlternate.Text); - } - } - else - { - TextBoxListViewToggleTag(HtmlUtil.TagItalic); - e.SuppressKeyPress = true; - } - } - - if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D) - { - textBoxListViewTextAlternate.SelectionLength = 0; - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainTextBoxSelectionToLower == e.KeyData) // selection to lowercase - { - if (textBoxListViewTextAlternate.SelectionLength > 0) - { - int start = textBoxListViewTextAlternate.SelectionStart; - int length = textBoxListViewTextAlternate.SelectionLength; - textBoxListViewTextAlternate.SelectedText = textBoxListViewTextAlternate.SelectedText.ToLowerInvariant(); - textBoxListViewTextAlternate.SelectionStart = start; - textBoxListViewTextAlternate.SelectionLength = length; - e.SuppressKeyPress = true; - } - } - else if (_shortcuts.MainTextBoxSelectionToUpper == e.KeyData) // selection to uppercase - { - if (textBoxListViewTextAlternate.SelectionLength > 0) - { - int start = textBoxListViewTextAlternate.SelectionStart; - int length = textBoxListViewTextAlternate.SelectionLength; - textBoxListViewTextAlternate.SelectedText = textBoxListViewTextAlternate.SelectedText.ToUpperInvariant(); - textBoxListViewTextAlternate.SelectionStart = start; - textBoxListViewTextAlternate.SelectionLength = length; - e.SuppressKeyPress = true; - } - } - else if (_shortcuts.MainTextBoxSelectionToggleCasing == e.KeyData && textBoxListViewTextAlternate.SelectionLength > 0) // selection to uppercase - { - int start = textBoxListViewTextAlternate.SelectionStart; - int length = textBoxListViewTextAlternate.SelectionLength; - var text = ToggleCasing(textBoxListViewTextAlternate.SelectedText); - textBoxListViewTextAlternate.SelectedText = text; - textBoxListViewTextAlternate.SelectionStart = start; - textBoxListViewTextAlternate.SelectionLength = length; - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainTextBoxSplitAtCursor == e.KeyData && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - ToolStripMenuItemSplitTextAtCursorClick(null, null); - e.SuppressKeyPress = true; - } - else if (_shortcuts.MainTextBoxSplitAtCursorAndVideoPos == e.KeyData && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - toolStripMenuItemSplitViaWaveform_Click(null, null); - e.SuppressKeyPress = true; - } - - // last key down in text - _lastTextKeyDownTicks = DateTime.UtcNow.Ticks; - - UpdatePositionAndTotalLength(labelTextAlternateLineTotal, textBoxListViewTextAlternate); - } - - private void OpenOriginalToolStripMenuItemClick(object sender, EventArgs e) - { - OpenAlternateSubtitle(); - } - - private void SaveOriginalAstoolStripMenuItemClick(object sender, EventArgs e) - { - if (_subtitleAlternate == null || _subtitleAlternate.Paragraphs.Count == 0) - { - return; - } - - SubtitleFormat currentFormat = GetCurrentSubtitleFormat(); - if (currentFormat == null) - { - currentFormat = new SubRip(); - } - - UiUtil.SetSaveDialogFilter(saveFileDialog1, currentFormat); - - saveFileDialog1.Title = _language.SaveOriginalSubtitleAs; - saveFileDialog1.DefaultExt = "*" + currentFormat.Extension; - saveFileDialog1.AddExtension = true; - - if (!string.IsNullOrEmpty(VideoFileName)) - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); - } - else if (!string.IsNullOrEmpty(_subtitleAlternateFileName)) - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_subtitleAlternateFileName); - } - else - { - saveFileDialog1.FileName = string.Empty; - } - - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - _subtitleAlternateFileName = saveFileDialog1.FileName; - SaveOriginalSubtitle(currentFormat); - SetTitle(); - if (_fileName != null) - { - Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - } - } - } - - private void SaveOriginalToolStripMenuItemClick(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(_subtitleAlternateFileName)) - { - SaveOriginalAstoolStripMenuItemClick(null, null); - return; - } - - try - { - SaveOriginalSubtitle(GetCurrentSubtitleFormat()); - } - catch - { - MessageBox.Show(string.Format(_language.UnableToSaveSubtitleX, _subtitleAlternateFileName)); - } - } - - private void RemoveOriginalToolStripMenuItemClick(object sender, EventArgs e) - { - if (ContinueNewOrExitAlternate()) - { - RemoveAlternate(true, true); - } - } - - private void RemoveAlternate(bool removeFromListView, bool updateRecentFiles) - { - if (removeFromListView) - { - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.TextAlternate); - SubtitleListview1.AutoSizeAllColumns(this); - _subtitleAlternate = new Subtitle(); - _subtitleAlternateFileName = null; - - if (_fileName != null && updateRecentFiles) - { - Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); - Configuration.Settings.Save(); - UpdateRecentFilesUI(); - } - } - - buttonUnBreak.Visible = true; - buttonAutoBreak.Visible = true; - textBoxListViewTextAlternate.Visible = false; - labelAlternateText.Visible = false; - labelAlternateCharactersPerSecond.Visible = false; - labelTextAlternateLineLengths.Visible = false; - labelAlternateSingleLine.Visible = false; - labelAlternateSingleLinePixels.Visible = false; - labelTextAlternateLineTotal.Visible = false; - textBoxListViewText.Width = (groupBoxEdit.Width - (textBoxListViewText.Left + 8 + buttonUnBreak.Width)); - textBoxListViewText.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; - labelTextLineTotal.Left = 236; - labelTextAlternateLineTotal.Left = 236; - - MainResize(); - SetTitle(); - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex, true); - } - - private void ToolStripMenuItemSpellCheckMainDropDownOpening(object sender, EventArgs e) - { - addWordToNameListToolStripMenuItem.Visible = true; - } - - private void SplitContainer1SplitterMoved(object sender, SplitterEventArgs e) - { - Main_Resize(null, null); - } - - private void ButtonSplitLineClick(object sender, EventArgs e) - { - SplitSelectedParagraph(null, null); - } - - private void ToolStripMenuItemCopySourceTextClick(object sender, EventArgs e) - { - var selectedLines = new Subtitle(_subtitle); - selectedLines.Paragraphs.Clear(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - selectedLines.Paragraphs.Add(new Paragraph(_subtitle.Paragraphs[index])); - } - - if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) - { - selectedLines.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(Configuration.Settings.General.CurrentVideoOffsetInMs)); - } - - Clipboard.SetText(selectedLines.ToText(GetCurrentSubtitleFormat()).TrimEnd()); - } - - public void PlayPause() - { - mediaPlayer.TogglePlayPause(); - } - - public void SetCurrentViaEndPositionAndGotoNext(int index, bool goToNext) - { - var p = _subtitle.GetParagraphOrDefault(index); - if (p == null) - { - return; - } - - if (mediaPlayer.VideoPlayer == null || string.IsNullOrEmpty(VideoFileName)) - { - MessageBox.Show(_languageGeneral.NoVideoLoaded); - return; - } - - var oldParagraph = new Paragraph(p, false); - - //if (autoDuration) - //{ - // // TODO: auto duration - // // TODO: Search for start via wave file (must only be minor adjustment) - //} - - // current movie Position - double durationTotalMilliseconds = p.Duration.TotalMilliseconds; - double totalMillisecondsEnd = mediaPlayer.CurrentPosition * TimeCode.BaseUnit; - - var tc = new TimeCode(totalMillisecondsEnd - durationTotalMilliseconds); - MakeHistoryForUndo(_language.BeforeSetEndAndVideoPosition + " " + tc); - _makeHistoryPaused = true; - - if (p.StartTime.IsMaxTime) - { - p.EndTime.TotalSeconds = mediaPlayer.CurrentPosition; - p.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds - Utilities.GetOptimalDisplayMilliseconds(p.Text); - } - else - { - p.StartTime.TotalMilliseconds = totalMillisecondsEnd - durationTotalMilliseconds; - p.EndTime.TotalMilliseconds = totalMillisecondsEnd; - } - - timeUpDownStartTime.TimeCode = p.StartTime; - var durationInSeconds = (decimal)(p.Duration.TotalSeconds); - if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum) - { - SetDurationInSeconds((double)durationInSeconds); - } - - UpdateOriginalTimeCodes(oldParagraph); - RestartHistory(); - - if (goToNext) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true); - } - - ShowStatus(string.Format(_language.VideoControls.AdjustedViaEndTime, p.StartTime.ToShortString())); - audioVisualizer.Invalidate(); - } - - public void SetCurrentStartAutoDurationAndGotoNext(int index) - { - var prev = _subtitle.GetParagraphOrDefault(index - 1); - var p = _subtitle.GetParagraphOrDefault(index); - if (p == null) - { - return; - } - - double videoPosition = mediaPlayer.CurrentPosition; - if (prev != null && Math.Abs(prev.StartTime.TotalSeconds - videoPosition) < 0.3) - { - ShowStatus("Subtitle already here"); - return; - } - - ShowNextSubtitleLabel(); - - if (mediaPlayer.VideoPlayer == null || string.IsNullOrEmpty(VideoFileName)) - { - MessageBox.Show(_languageGeneral.NoVideoLoaded); - return; - } - - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + p.Number + " " + p.Text)); - - timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; - var oldParagraph = new Paragraph(_subtitle.Paragraphs[index], false); - if (!mediaPlayer.IsPaused) - { - videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; - } - - timeUpDownStartTime.TimeCode = TimeCode.FromSeconds(videoPosition); - - double duration = Utilities.GetOptimalDisplayMilliseconds(textBoxListViewText.Text); - - _subtitle.Paragraphs[index].StartTime.TotalMilliseconds = TimeSpan.FromSeconds(videoPosition).TotalMilliseconds; - if (prev != null && prev.EndTime.TotalMilliseconds > _subtitle.Paragraphs[index].StartTime.TotalMilliseconds) - { - int minDiff = Configuration.Settings.General.MinimumMillisecondsBetweenLines + 1; - if (minDiff < 1) - { - minDiff = 1; - } - - prev.EndTime.TotalMilliseconds = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds - minDiff; - } - - _subtitle.Paragraphs[index].EndTime.TotalMilliseconds = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds + duration; - SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - timeUpDownStartTime.TimeCode = _subtitle.Paragraphs[index].StartTime; - timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; - UpdateOriginalTimeCodes(oldParagraph); - _subtitleListViewIndex = -1; - SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true); - audioVisualizer.Invalidate(); - } - - public void SetCurrentEndNextStartAndGoToNext(int index) - { - var p = _subtitle.GetParagraphOrDefault(index); - var next = _subtitle.GetParagraphOrDefault(index + 1); - if (p == null) - { - return; - } - - if (mediaPlayer.VideoPlayer == null || string.IsNullOrEmpty(VideoFileName)) - { - MessageBox.Show(_languageGeneral.NoVideoLoaded); - return; - } - - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + p.Number + " " + p.Text)); - var p1 = new Paragraph(p, false); - Paragraph p2 = null; - if (next != null) - { - p2 = new Paragraph(next, false); - } - - double videoPosition = mediaPlayer.CurrentPosition; - if (!mediaPlayer.IsPaused) - { - videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; - } - - p.EndTime = TimeCode.FromSeconds(videoPosition); - if (p.StartTime.IsMaxTime) - { - timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; - p.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds - Utilities.GetOptimalDisplayMilliseconds(p.Text); - if (p.StartTime.TotalMilliseconds < 0) - { - p.StartTime.TotalMilliseconds = 0; - } - - timeUpDownStartTime.TimeCode = p.StartTime; - SubtitleListview1.SetStartTimeAndDuration(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; - } - - if (p.Duration.TotalSeconds < 0 || p.Duration.TotalSeconds > 10) - { - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text); - } - - SubtitleListview1.SetStartTimeAndDuration(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); - - SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds + 0.001); - if (next != null) - { - int addMilliseconds = Configuration.Settings.General.MinimumMillisecondsBetweenLines; - if (addMilliseconds < 1 || addMilliseconds > 500) - { - addMilliseconds = 1; - } - - var oldDuration = next.Duration.TotalMilliseconds; - if (next.StartTime.IsMaxTime || next.EndTime.IsMaxTime) - { - oldDuration = Utilities.GetOptimalDisplayMilliseconds(p.Text); - } - - next.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds + addMilliseconds; - next.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds + oldDuration; - SubtitleListview1.SetStartTimeAndDuration(index + 1, next, _subtitle.GetParagraphOrDefault(index + 2), _subtitle.GetParagraphOrDefault(index)); - SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true); - } - - UpdateOriginalTimeCodes(p1, p2); - audioVisualizer.Invalidate(); - } - - private void EditSelectAllToolStripMenuItemClick(object sender, EventArgs e) - { - for (int i = 0; i < SubtitleListview1.Items.Count; i++) - { - SubtitleListview1.Items[i].Selected = true; - } - } - - private void ToolStripMenuItemSplitTextAtCursorClick(object sender, EventArgs e) - { - var tb = GetFocusedTextBox(); - - int? pos = null; - if (tb.SelectionStart > 1 && tb.SelectionStart < tb.Text.Length - 1) - { - pos = tb.SelectionStart; - } - - SplitSelectedParagraph(null, pos); - tb.Focus(); - tb.SelectionStart = tb.Text.Length; - } - - private void toolStripMenuItemSplitViaWaveform_Click(object sender, EventArgs e) - { - var tb = GetFocusedTextBox(); - if (tb.SelectionStart > 1 && tb.SelectionStart < tb.Text.Length - 1) - { - int? pos = tb.SelectionStart; - SplitSelectedParagraph(mediaPlayer.CurrentPosition, pos); - tb.Focus(); - tb.SelectionStart = tb.Text.Length; - } - } - - private void ContextMenuStripTextBoxListViewOpening(object sender, System.ComponentModel.CancelEventArgs e) - { - var tb = GetFocusedTextBox(); - toolStripMenuItemSplitTextAtCursor.Visible = tb.Text.Length > 1; - - if (IsUnicode) - { - if (toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Count == 0) - { - foreach (var s in Configuration.Settings.Tools.UnicodeSymbolsToInsert.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) - { - toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Add(s, null, InsertUnicodeGlyph); - if (Environment.OSVersion.Version.Major < 6 && Configuration.Settings.General.SubtitleFontName == Utilities.WinXP2KUnicodeFontName) // 6 == Vista/Win2008Server/Win7 - { - toolStripMenuItemInsertUnicodeSymbol.DropDownItems[toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Count - 1].Font = new Font(Utilities.WinXP2KUnicodeFontName, toolStripMenuItemInsertUnicodeSymbol.Font.Size); - } - } - } - - toolStripMenuItemInsertUnicodeSymbol.Visible = toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Count > 0; - toolStripSeparator26.Visible = toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Count > 0; - - superscriptToolStripMenuItem.Visible = tb.SelectionLength > 0; - subscriptToolStripMenuItem.Visible = tb.SelectionLength > 0; - toolStripMenuItemInsertUnicodeControlCharacters.Visible = true; - } - else - { - toolStripMenuItemInsertUnicodeSymbol.Visible = false; - toolStripSeparator26.Visible = false; - superscriptToolStripMenuItem.Visible = false; - subscriptToolStripMenuItem.Visible = false; - toolStripMenuItemInsertUnicodeControlCharacters.Visible = false; - } - - var formatType = GetCurrentSubtitleFormat().GetType(); - if (formatType == typeof(WebVTT) && tb.SelectionLength > 0) - { - toolStripSeparatorWebVTT.Visible = true; - toolStripMenuItemWebVttVoice.Visible = true; - var voices = WebVTT.GetVoices(_subtitle); - toolStripMenuItemWebVttVoice.DropDownItems.Clear(); - foreach (var style in voices) - { - toolStripMenuItemWebVttVoice.DropDownItems.Add(style, null, WebVTTSetVoiceTextBox); - } - - toolStripMenuItemWebVttVoice.DropDownItems.Add(_language.Menu.ContextMenu.WebVTTSetNewVoice, null, WebVTTSetNewVoiceTextBox); - } - else - { - toolStripSeparatorWebVTT.Visible = false; - toolStripMenuItemWebVttVoice.Visible = false; - toolStripMenuItemWebVttVoice.Visible = false; - } - - if (formatType == typeof(NetflixImsc11Japanese)) - { - boldToolStripMenuItem1.Visible = false; - underlineToolStripMenuItem1.Visible = false; - colorToolStripMenuItem1.Visible = false; - fontNameToolStripMenuItem.Visible = false; - toolStripMenuItemHorizontalDigits.Visible = true; - if (tb.SelectionLength > 0) - { - toolStripMenuItemBouten.Visible = true; - toolStripMenuItemRuby.Visible = true; - } - else - { - toolStripMenuItemBouten.Visible = false; - toolStripMenuItemRuby.Visible = true; - } - - if (tb.SelectionLength > 1 && tb.SelectionLength < 8) - { - toolStripMenuItemHorizontalDigits.Visible = true; - } - else - { - toolStripMenuItemHorizontalDigits.Visible = false; - } - } - else if (formatType == typeof(Sami) || formatType == typeof(SamiModern)) - { - boldToolStripMenuItem1.Visible = true; - underlineToolStripMenuItem1.Visible = true; - colorToolStripMenuItem1.Visible = true; - fontNameToolStripMenuItem.Visible = true; - toolStripMenuItemHorizontalDigits.Visible = false; - toolStripMenuItemBouten.Visible = false; - if (tb.SelectionLength > 0) - { - toolStripMenuItemRuby.Visible = true; - } - else - { - toolStripMenuItemRuby.Visible = true; - } - } - else if (formatType == typeof(Ebu)) - { - Ebu.EbuGeneralSubtitleInformation header; - if (_subtitle != null && _subtitle.Header != null && (_subtitle.Header.Contains("STL2") || _subtitle.Header.Contains("STL3"))) - { - header = Ebu.ReadHeader(Encoding.UTF8.GetBytes(_subtitle.Header)); - } - else - { - header = new Ebu.EbuGeneralSubtitleInformation(); - } - - var open = header.DisplayStandardCode != "1" && header.DisplayStandardCode != "2"; - boxToolStripMenuItem.Visible = open; - } - else - { - boxToolStripMenuItem1.Visible = false; - boldToolStripMenuItem1.Visible = true; - underlineToolStripMenuItem1.Visible = true; - colorToolStripMenuItem1.Visible = true; - fontNameToolStripMenuItem.Visible = true; - toolStripMenuItemBouten.Visible = false; - toolStripMenuItemRuby.Visible = false; - toolStripMenuItemHorizontalDigits.Visible = false; - } - - if (tb.SelectionStart > 1 && tb.SelectionStart < tb.Text.Length - 1 && !string.IsNullOrEmpty(VideoFileName) && mediaPlayer != null && - _subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) - { - int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - var currentParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex); - var splitSeconds = mediaPlayer.CurrentPosition; - if (splitSeconds > (currentParagraph.StartTime.TotalSeconds + 0.2) && splitSeconds < (currentParagraph.EndTime.TotalSeconds - 0.2)) - { - toolStripMenuItemSplitViaWaveform.Visible = true; - } - else - { - toolStripMenuItemSplitViaWaveform.Visible = false; - } - } - else - { - toolStripMenuItemSplitViaWaveform.Visible = false; - } - } - - private void ToolStripMenuItemExportPngXmlClick(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "BDNXML", _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - private void TabControlSubtitleSelecting(object sender, TabControlCancelEventArgs e) - { - if (tabControlSubtitle.SelectedIndex != TabControlSourceView && textBoxSource.Text.Trim().Length > 1) - { - var currentFormat = GetCurrentSubtitleFormat(); - if (currentFormat != null && !currentFormat.IsTextBased) - { - return; - } - - var format = new Subtitle().ReloadLoadSubtitle(textBoxSource.Lines.ToList(), null, currentFormat); - if (format == null) - { - e.Cancel = true; - } - } - } - - private void ToolStripComboBoxFrameRateTextChanged(object sender, EventArgs e) - { - Configuration.Settings.General.CurrentFrameRate = CurrentFrameRate; - if (_loading) - { - return; - } - - SubtitleListview1.UpdateFrames(_subtitle); - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - ShowSource(); - } - } - - private void ToolStripMenuItemGoogleMicrosoftTranslateSelLineClick(object sender, EventArgs e) - { - int firstSelectedIndex = FirstSelectedIndex; - if (firstSelectedIndex >= 0) - { - var p = _subtitle.GetParagraphOrDefault(firstSelectedIndex); - if (p != null) - { - string defaultFromLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); - if (_subtitleAlternate != null) - { - var o = Utilities.GetOriginalParagraph(firstSelectedIndex, p, _subtitleAlternate.Paragraphs); - if (o != null) - { - p = o; - defaultFromLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate); - } - } - - Cursor = Cursors.WaitCursor; - if (_googleOrMicrosoftTranslate == null || _googleOrMicrosoftTranslate.IsDisposed) - { - _googleOrMicrosoftTranslate = new GoogleOrMicrosoftTranslate(); - _googleOrMicrosoftTranslate.InitializeFromLanguage(defaultFromLanguage); - } - - _googleOrMicrosoftTranslate.Initialize(p); - Cursor = Cursors.Default; - if (_googleOrMicrosoftTranslate.ShowDialog() == DialogResult.OK) - { - textBoxListViewText.Text = _googleOrMicrosoftTranslate.TranslatedText; - } - } - } - } - - private void NumericUpDownSec1ValueChanged(object sender, EventArgs e) - { - Configuration.Settings.General.SmallDelayMilliseconds = (int)(numericUpDownSec1.Value * 1000); - } - - private void NumericUpDownSec2ValueChanged(object sender, EventArgs e) - { - Configuration.Settings.General.LargeDelayMilliseconds = (int)(numericUpDownSec2.Value * 1000); - } - - private void NumericUpDownSecAdjust1ValueChanged(object sender, EventArgs e) - { - Configuration.Settings.General.SmallDelayMilliseconds = (int)(numericUpDownSecAdjust1.Value * 1000); - } - - private void NumericUpDownSecAdjust2ValueChanged(object sender, EventArgs e) - { - Configuration.Settings.General.LargeDelayMilliseconds = (int)(numericUpDownSecAdjust2.Value * 1000); - } - - private void ToolStripMenuItemMakeEmptyFromCurrentClick(object sender, EventArgs e) - { - if (ContinueNewOrExit()) - { - bool isAlternateVisible = SubtitleListview1.IsAlternateTextColumnVisible; - _subtitleAlternate = new Subtitle(_subtitle); - _subtitleAlternateFileName = null; - int oldIndex = FirstSelectedIndex; - if (oldIndex < 0) - { - oldIndex = 0; - } - - foreach (var p in _subtitle.Paragraphs) - { - if (Configuration.Settings.General.RemoveBlankLinesWhenOpening && string.IsNullOrEmpty(Configuration.Settings.Tools.NewEmptyTranslationText)) - { - p.Text = "-"; - } - else if (Configuration.Settings.Tools.NewEmptyTranslationText != null) - { - p.Text = Configuration.Settings.Tools.NewEmptyTranslationText; - } - else - { - p.Text = string.Empty; - } - } - - SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); - _subtitleListViewIndex = -1; - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(oldIndex, true); - textBoxListViewText.Focus(); - Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable = true; - - _subtitleAlternateFileName = _fileName; - _fileName = null; - SetupAlternateEdit(); - ResetHistory(); - - if (!isAlternateVisible || toolStripMenuItemShowOriginalInPreview.Checked) - { - toolStripMenuItemShowOriginalInPreview.Checked = false; - Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable = false; - audioVisualizer.Invalidate(); - } - } - } - - private void ToolStripMenuItemShowOriginalInPreviewClick(object sender, EventArgs e) - { - toolStripMenuItemShowOriginalInPreview.Checked = !toolStripMenuItemShowOriginalInPreview.Checked; - Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable = toolStripMenuItemShowOriginalInPreview.Checked; - } - - private void ToolStripMenuItemVideoDropDownClosed(object sender, EventArgs e) - { - redockVideoControlsToolStripMenuItem.ShortcutKeys = Keys.None; - undockVideoControlsToolStripMenuItem.ShortcutKeys = Keys.None; - } - - private void ToolsToolStripMenuItemDropDownOpening(object sender, EventArgs e) - { - if (_subtitle?.Paragraphs.Count > 0 && _networkSession == null) - { - toolStripSeparator23.Visible = true; - toolStripMenuItemMakeEmptyFromCurrent.Visible = !SubtitleListview1.IsAlternateTextColumnVisible; - toolStripMenuItemShowOriginalInPreview.Checked = Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable; - } - else - { - toolStripSeparator23.Visible = false; - toolStripMenuItemMakeEmptyFromCurrent.Visible = false; - toolStripMenuItemShowOriginalInPreview.Checked = false; - } - - var f = GetCurrentSubtitleFormat(); - styleToolStripMenuItem.Visible = f.HasStyleSupport; - var formatType = f.GetType(); - actorToolStripMenuItem.Visible = formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha); - } - - private void ContextMenuStripWaveformOpening(object sender, System.ComponentModel.CancelEventArgs e) - { - if (audioVisualizer.IsSpectrogramAvailable) - { - if (audioVisualizer.ShowSpectrogram && audioVisualizer.ShowWaveform) - { - showWaveformAndSpectrogramToolStripMenuItem.Visible = false; - showOnlyWaveformToolStripMenuItem.Visible = true; - showOnlySpectrogramToolStripMenuItem.Visible = true; - toolStripSeparatorGuessTimeCodes.Visible = true; - } - else if (audioVisualizer.ShowSpectrogram) - { - showWaveformAndSpectrogramToolStripMenuItem.Visible = true; - showOnlyWaveformToolStripMenuItem.Visible = true; - showOnlySpectrogramToolStripMenuItem.Visible = false; - toolStripSeparatorGuessTimeCodes.Visible = true; - } - else - { - showWaveformAndSpectrogramToolStripMenuItem.Visible = true; - showOnlyWaveformToolStripMenuItem.Visible = false; - showOnlySpectrogramToolStripMenuItem.Visible = true; - toolStripSeparatorGuessTimeCodes.Visible = true; - } - } - else - { - toolStripSeparator24.Visible = false; - showWaveformAndSpectrogramToolStripMenuItem.Visible = false; - showOnlyWaveformToolStripMenuItem.Visible = false; - showOnlySpectrogramToolStripMenuItem.Visible = false; - toolStripSeparatorGuessTimeCodes.Visible = false; - } - - insertSubtitleHereToolStripMenuItem.Visible = !_subtitle.Paragraphs.Any(p => p.StartTime.TotalSeconds <= mediaPlayer.CurrentPosition + 1.0 && - p.EndTime.TotalSeconds <= mediaPlayer.CurrentPosition + 1.0 && - p.EndTime.TotalSeconds >= mediaPlayer.CurrentPosition); - } - - private void ShowWaveformAndSpectrogramToolStripMenuItemClick(object sender, EventArgs e) - { - audioVisualizer.ShowSpectrogram = true; - audioVisualizer.ShowWaveform = true; - } - - private void ShowOnlyWaveformToolStripMenuItemClick(object sender, EventArgs e) - { - audioVisualizer.ShowSpectrogram = false; - audioVisualizer.ShowWaveform = true; - } - - private void ShowOnlySpectrogramToolStripMenuItemClick(object sender, EventArgs e) - { - audioVisualizer.ShowSpectrogram = true; - audioVisualizer.ShowWaveform = false; - } - - private void SplitContainerMainSplitterMoved(object sender, SplitterEventArgs e) - { - mediaPlayer.Refresh(); - } - - private void FindDoubleLinesToolStripMenuItemClick(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - for (int i = FirstSelectedIndex + 1; i < _subtitle.Paragraphs.Count; i++) - { - var current = _subtitle.GetParagraphOrDefault(i); - var next = _subtitle.GetParagraphOrDefault(i + 1); - if (current != null && next != null) - { - if (current.Text.Trim().Equals(next.Text.Trim(), StringComparison.OrdinalIgnoreCase)) - { - SubtitleListview1.SelectIndexAndEnsureVisible(i, true); - SubtitleListview1.Items[i + 1].Selected = true; - break; - } - } - } - } - - private void TextBoxListViewTextAlternateMouseMove(object sender, MouseEventArgs e) - { - if (Control.ModifierKeys == Keys.Control && MouseButtons == MouseButtons.Left) - { - if (!string.IsNullOrEmpty(textBoxListViewTextAlternate.SelectedText)) - { - textBoxListViewTextAlternate.DoDragDrop(textBoxListViewTextAlternate.SelectedText, DragDropEffects.Copy); - } - else - { - textBoxListViewTextAlternate.DoDragDrop(textBoxListViewTextAlternate.Text, DragDropEffects.Copy); - } - } - else if ((AutoRepeatContinueOn || AutoRepeatOn) && !textBoxSearchWord.Focused && textBoxListViewTextAlternate.Focused) - { - string selectedText = textBoxListViewTextAlternate.SelectedText; - if (!string.IsNullOrEmpty(selectedText)) - { - selectedText = selectedText.Trim(); - selectedText = selectedText.TrimEnd('.', ',', '!', '?').TrimEnd(); - if (!string.IsNullOrEmpty(selectedText) && selectedText != textBoxSearchWord.Text) - { - textBoxSearchWord.Text = HtmlUtil.RemoveHtmlTags(selectedText); - } - } - } - } - - private void EBustlToolStripMenuItemClick(object sender, EventArgs e) - { - var ebu = new Ebu(); - saveFileDialog1.Filter = ebu.Name + "|*" + ebu.Extension; - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*" + ebu.Extension; - saveFileDialog1.AddExtension = true; - - if (!string.IsNullOrEmpty(VideoFileName)) - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); - } - else - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); - } - - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - string fileName = saveFileDialog1.FileName; - string ext = Path.GetExtension(fileName); - bool extOk = ext.Equals(ebu.Extension, StringComparison.OrdinalIgnoreCase); - if (!extOk) - { - if (fileName.EndsWith('.')) - { - fileName = fileName.Substring(0, fileName.Length - 1); - } - - fileName += ebu.Extension; - } - - new Ebu().Save(fileName, GetSaveSubtitle(_subtitle)); - } - } - - private void ToolStripMenuItemCavena890Click(object sender, EventArgs e) - { - var cavena890 = new Cavena890(); - saveFileDialog1.Filter = cavena890.Name + "|*" + cavena890.Extension; - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*" + cavena890.Extension; - saveFileDialog1.AddExtension = true; - - if (!string.IsNullOrEmpty(VideoFileName)) - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); - } - else - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); - } - - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - string fileName = saveFileDialog1.FileName; - string ext = Path.GetExtension(fileName); - bool extOk = ext.Equals(cavena890.Extension, StringComparison.OrdinalIgnoreCase); - if (!extOk) - { - if (fileName.EndsWith('.')) - { - fileName = fileName.Substring(0, fileName.Length - 1); - } - - fileName += cavena890.Extension; - } - - using (var form = new Cavena890SaveOptions(_subtitle, _fileName)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - cavena890.Save(fileName, GetSaveSubtitle(_subtitle)); - } - } - } - } - - private void PacScreenElectronicsToolStripMenuItemClick(object sender, EventArgs e) - { - var pac = new Pac(); - saveFileDialog1.Filter = pac.Name + "|*" + pac.Extension; - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*" + pac.Extension; - saveFileDialog1.AddExtension = true; - - if (!string.IsNullOrEmpty(VideoFileName)) - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); - } - else - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); - } - - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - string fileName = saveFileDialog1.FileName; - string ext = Path.GetExtension(fileName); - bool extOk = ext.Equals(pac.Extension, StringComparison.OrdinalIgnoreCase); - if (!extOk) - { - if (fileName.EndsWith('.')) - { - fileName = fileName.Substring(0, fileName.Length - 1); - } - - fileName += pac.Extension; - } - - pac.Save(fileName, GetSaveSubtitle(_subtitle)); - } - } - - private void uniPacExportToolStripMenuItem_Click(object sender, EventArgs e) - { - var uniPac = new PacUnicode(); - saveFileDialog1.Filter = uniPac.Name + "|*" + uniPac.Extension; - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*" + uniPac.Extension; - saveFileDialog1.AddExtension = true; - - if (!string.IsNullOrEmpty(VideoFileName)) - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); - } - else - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); - } - - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - string fileName = saveFileDialog1.FileName; - string ext = Path.GetExtension(fileName); - bool extOk = ext.Equals(uniPac.Extension, StringComparison.OrdinalIgnoreCase); - if (!extOk) - { - if (fileName.EndsWith('.')) - { - fileName = fileName.Substring(0, fileName.Length - 1); - } - - fileName += uniPac.Extension; - } - - uniPac.Save(fileName, GetSaveSubtitle(_subtitle)); - } - } - - private void toolStripMenuItemExportAyato_Click(object sender, EventArgs e) - { - var ayato = new Ayato(); - saveFileDialog1.Filter = ayato.Name + "|*" + ayato.Extension; - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*" + ayato.Extension; - saveFileDialog1.AddExtension = true; - - if (!string.IsNullOrEmpty(VideoFileName)) - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); - } - else - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); - } - - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - string fileName = saveFileDialog1.FileName; - string ext = Path.GetExtension(fileName); - bool extOk = ext.Equals(ayato.Extension, StringComparison.OrdinalIgnoreCase); - if (!extOk) - { - if (fileName.EndsWith('.')) - { - fileName = fileName.Substring(0, fileName.Length - 1); - } - - fileName += ayato.Extension; - } - - ayato.Save(fileName, VideoFileName, GetSaveSubtitle(_subtitle)); - } - } - - private void TextBoxListViewTextEnter(object sender, EventArgs e) - { - if (_findHelper != null) - { - _findHelper.MatchInOriginal = false; - } - - if (_measurementConverter != null) - { - _measurementConverter.IsOriginalActive = false; - } - } - - private void TextBoxListViewTextAlternateEnter(object sender, EventArgs e) - { - if (_findHelper != null) - { - _findHelper.MatchInOriginal = true; - } - - if (_measurementConverter != null) - { - _measurementConverter.IsOriginalActive = true; - } - } - - private void PlainTextToolStripMenuItemClick(object sender, EventArgs e) - { - using (var exportText = new ExportText()) - { - exportText.Initialize(GetSaveSubtitle(_subtitle), _fileName); - if (exportText.ShowDialog() == DialogResult.OK) - { - ShowStatus(_language.SubtitleExported); - } - } - } - - private void BluraySupToolStripMenuItemClick(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.BluraySup, _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - private void VobSubsubidxToolStripMenuItemClick(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.VobSub, _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - private void TextBoxListViewTextAlternateKeyUp(object sender, KeyEventArgs e) - { - textBoxListViewTextAlternate.ClearUndo(); - UpdatePositionAndTotalLength(labelTextAlternateLineTotal, textBoxListViewTextAlternate); - } - - private void TimerTextUndoTick(object sender, EventArgs e) - { - if (_subtitle == null || _subtitle.Paragraphs.Count == 0 || _listViewTextTicks == -1 || !CanFocus) - { - return; - } - - // progress check - ShowTranslationProgress(); - - // text undo - int index = _listViewTextUndoIndex; - if (index == -1) - { - index = _subtitleListViewIndex; - } - - if (index < 0 || index >= _subtitle.Paragraphs.Count) - { - return; - } - - if ((DateTime.UtcNow.Ticks - _listViewTextTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds - { - if (index < 0 || index >= _subtitle.Paragraphs.Count) - { - return; - } - - string newText = _subtitle.Paragraphs[index].Text.TrimEnd(); - string oldText = _listViewTextUndoLast; - if (oldText == null) - { - return; - } - - if (_listViewTextUndoLast != newText) - { - MakeHistoryForUndo(_languageGeneral.Text + ": " + _listViewTextUndoLast.TrimEnd() + " -> " + newText, false); - int hidx = _subtitle.HistoryItems.Count - 1; - if (hidx >= 0 && hidx < _subtitle.HistoryItems.Count) - { - _subtitle.HistoryItems[hidx].Subtitle.Paragraphs[index].Text = _listViewTextUndoLast; - } - - _listViewTextUndoLast = newText; - _listViewTextUndoIndex = -1; - } - } - } - - private void ShowTranslationProgress() - { - if (Configuration.Settings.General.ShowProgress) - { - if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - int numberOfNonBlankLines = 0; - foreach (var paragraph in _subtitle.Paragraphs) - { - if (!string.IsNullOrWhiteSpace(paragraph.Text)) - { - numberOfNonBlankLines++; - } - } - - int percent = (int)Math.Round(numberOfNonBlankLines * 100.0 / _subtitle.Paragraphs.Count); - toolStripStatusLabelProgress.Text = string.Format("{0}% completed", percent); - if (!toolStripStatusLabelProgress.Visible) - { - toolStripStatusLabelProgress.Visible = true; - } - } - else if (_subtitle.Paragraphs.Count > 0 && !string.IsNullOrWhiteSpace(VideoFileName) && mediaPlayer != null && mediaPlayer.VideoPlayer != null && mediaPlayer.VideoPlayer.Duration > 0) - { - var last = _subtitle.Paragraphs.LastOrDefault(); - if (last != null && !last.StartTime.IsMaxTime) - { - var subtitleEndSeconds = last.EndTime.TotalSeconds; - var videoEndSeconds = mediaPlayer.VideoPlayer.Duration; - int percent = (int)Math.Round(subtitleEndSeconds * 100.0 / videoEndSeconds); - toolStripStatusLabelProgress.Text = string.Format("{0}% completed", percent); - if (!toolStripStatusLabelProgress.Visible) - { - toolStripStatusLabelProgress.Visible = true; - } - } - } - else - { - toolStripStatusLabelProgress.Visible = false; - } - } - } - - private void TimerAlternateTextUndoTick(object sender, EventArgs e) - { - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - int index = _listViewTextUndoIndex; - if (index == -1) - { - index = _subtitleListViewIndex; - } - - if (_listViewAlternateTextTicks == -1 || !CanFocus || _subtitleAlternate == null || _subtitleAlternate.Paragraphs.Count == 0 || index < 0 || index >= _subtitleAlternate.Paragraphs.Count) - { - return; - } - - if ((DateTime.UtcNow.Ticks - _listViewAlternateTextTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds - { - var original = Utilities.GetOriginalParagraph(index, _subtitle.Paragraphs[index], _subtitleAlternate.Paragraphs); - if (original != null) - { - index = _subtitleAlternate.Paragraphs.IndexOf(original); - } - else - { - return; - } - - string newText = _subtitleAlternate.Paragraphs[index].Text.TrimEnd(); - string oldText = _listViewAlternateTextUndoLast; - if (oldText == null || index < 0) - { - return; - } - - if (_listViewAlternateTextUndoLast != newText && _subtitle.HistoryItems.Count > 0 && - index < _subtitle.HistoryItems[_subtitle.HistoryItems.Count - 1].OriginalSubtitle.Paragraphs.Count) - { - MakeHistoryForUndo(_languageGeneral.Text + ": " + _listViewAlternateTextUndoLast.TrimEnd() + " -> " + newText, false); - _subtitle.HistoryItems[_subtitle.HistoryItems.Count - 1].OriginalSubtitle.Paragraphs[index].Text = _listViewAlternateTextUndoLast; - - _listViewAlternateTextUndoLast = newText; - _listViewTextUndoIndex = -1; - } - } - } - } - - private void UpdatePositionAndTotalLength(Label lineTotal, SETextBox textBox) - { - if (string.IsNullOrEmpty(textBox.Text)) - { - lineTotal.Text = string.Empty; - return; - } - - int extraNewLineLength = Environment.NewLine.Length - 1; - int lineBreakPos = textBox.Text.IndexOf(Environment.NewLine, StringComparison.Ordinal); - int pos = textBox.SelectionStart; - var s = HtmlUtil.RemoveHtmlTags(textBox.Text, true).Replace(Environment.NewLine, string.Empty); // we don't count new line in total length... correct? - int totalLength = s.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics); - string totalL; - - if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) - { - var totalLengthPixels = TextWidth.CalcPixelWidth(s); - totalL = " " + string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", totalLength, totalLengthPixels)); - } - else - { - totalL = " " + string.Format(_languageGeneral.TotalLengthX, totalLength); - } - - if (lineBreakPos < 0 || pos <= lineBreakPos) - { - lineTotal.Text = "1," + (pos + 1) + totalL; - lineTotal.Left = textBox.Left + (textBox.Width - lineTotal.Width); - return; - } - - int secondLineBreakPos = textBox.Text.IndexOf(Environment.NewLine, lineBreakPos + 1, StringComparison.Ordinal); - if (secondLineBreakPos < 0 || pos <= secondLineBreakPos + extraNewLineLength) - { - lineTotal.Text = "2," + (pos - (lineBreakPos + extraNewLineLength)) + totalL; - lineTotal.Left = textBox.Left + (textBox.Width - lineTotal.Width); - return; - } - - int thirdLineBreakPos = textBox.Text.IndexOf(Environment.NewLine, secondLineBreakPos + 1, StringComparison.Ordinal); - if (thirdLineBreakPos < 0 || pos < thirdLineBreakPos + (extraNewLineLength * 2)) - { - lineTotal.Text = "3," + (pos - (secondLineBreakPos + extraNewLineLength)) + totalL; - lineTotal.Left = textBox.Left + (textBox.Width - lineTotal.Width); - return; - } - - int forthLineBreakPos = textBox.Text.IndexOf(Environment.NewLine, thirdLineBreakPos + 1, StringComparison.Ordinal); - if (forthLineBreakPos < 0 || pos < forthLineBreakPos + (extraNewLineLength * 3)) - { - lineTotal.Text = "4," + (pos - (thirdLineBreakPos + extraNewLineLength)) + totalL; - lineTotal.Left = textBox.Left + (textBox.Width - lineTotal.Width); - return; - } - - lineTotal.Text = string.Empty; - } - - private void TextBoxListViewTextMouseClick(object sender, MouseEventArgs e) - { - UpdatePositionAndTotalLength(labelTextLineTotal, textBoxListViewText); - } - - private void TextBoxListViewTextAlternateMouseClick(object sender, MouseEventArgs e) - { - UpdatePositionAndTotalLength(labelTextAlternateLineTotal, textBoxListViewTextAlternate); - } - - private void TabControlButtonsDrawItem(object sender, DrawItemEventArgs e) - { - var tc = (TabControl)sender; - var textBrush = new SolidBrush(ForeColor); - var tabFont = new Font(tc.Font, FontStyle.Regular); - if (e.State == DrawItemState.Selected) - { - tabFont = new Font(tc.Font, FontStyle.Bold); - e.Graphics.FillRectangle(new SolidBrush(SystemColors.Window), e.Bounds); - } - - Rectangle tabBounds = tc.GetTabRect(e.Index); - var stringFlags = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; - e.Graphics.DrawString(tc.TabPages[e.Index].Text.Trim(), tabFont, textBrush, tabBounds, new StringFormat(stringFlags)); - } - - public void GotoNextSubPosFromVideoPos() - { - if (mediaPlayer.VideoPlayer != null && _subtitle != null) - { - double ms = mediaPlayer.VideoPlayer.CurrentPosition * TimeCode.BaseUnit; - foreach (var p in _subtitle.Paragraphs) - { - if (p.EndTime.TotalMilliseconds > ms && p.StartTime.TotalMilliseconds < ms) - { - // current sub - } - else if (p.Duration.TotalSeconds < 10 && p.StartTime.TotalMilliseconds > ms) - { - mediaPlayer.VideoPlayer.CurrentPosition = p.StartTime.TotalSeconds; - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(p), true); - return; - } - } - } - } - - public void GotoPrevSubPosFromvideoPos() - { - if (mediaPlayer.VideoPlayer != null && _subtitle != null) - { - double ms = mediaPlayer.VideoPlayer.CurrentPosition * TimeCode.BaseUnit; - int i = _subtitle.Paragraphs.Count - 1; - while (i >= 0) - { - var p = _subtitle.Paragraphs[i]; - if (p.EndTime.TotalMilliseconds > ms && p.StartTime.TotalMilliseconds < ms) - { - // current sub - } - else if (p.Duration.TotalSeconds < 10 && p.StartTime.TotalMilliseconds < ms) - { - mediaPlayer.VideoPlayer.CurrentPosition = p.StartTime.TotalSeconds; - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(p), true); - return; - } - - i--; - } - } - } - - private void AdobeEncoreFabImageScriptToolStripMenuItemClick(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.Fab, _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - private void ToolStripMenuItemMergeDialogClick(object sender, EventArgs e) - { - MergeDialogs(); - } - - private void MainKeyUp(object sender, KeyEventArgs e) - { - if (_mainCreateStartDownEndUpParagraph != null) - { - var p = _subtitle.Paragraphs[_subtitleListViewIndex]; - if (p.ToString() == _mainCreateStartDownEndUpParagraph.ToString()) - { - ButtonSetEndClick(null, null); - } - - _mainCreateStartDownEndUpParagraph = null; - } - else if (_mainAdjustStartDownEndUpAndGoToNextParagraph != null) - { - var p = _subtitle.Paragraphs[_subtitleListViewIndex]; - if (p.ToString() == _mainAdjustStartDownEndUpAndGoToNextParagraph.ToString()) - { - double videoPositionInSeconds = mediaPlayer.CurrentPosition; - if (p.StartTime.TotalSeconds + 0.1 < videoPositionInSeconds) - { - ButtonSetEndClick(null, null); - } - - SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex + 1, true); - } - - _mainAdjustStartDownEndUpAndGoToNextParagraph = null; - } - } - - private void ToolStripMenuItemSurroundWithMusicSymbolsClick(object sender, EventArgs e) - { - string tag = Configuration.Settings.Tools.MusicSymbol; - if (string.IsNullOrWhiteSpace(tag)) - { - return; - } - - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) - { - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - MakeHistoryForUndo(string.Format(_language.BeforeAddingTagX, tag)); - - var indices = new List(); - foreach (ListViewItem item in SubtitleListview1.SelectedItems) - { - indices.Add(item.Index); - } - - SubtitleListview1.BeginUpdate(); - foreach (int i in indices) - { - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(i, _subtitle.Paragraphs[i], _subtitleAlternate.Paragraphs); - if (original != null) - { - original.Text = ToogleMusicSymbols(tag, original.Text); - SubtitleListview1.SetAlternateText(i, original.Text); - } - } - - _subtitle.Paragraphs[i].Text = ToogleMusicSymbols(tag, _subtitle.Paragraphs[i].Text); - SubtitleListview1.SetText(i, _subtitle.Paragraphs[i].Text); - } - - SubtitleListview1.EndUpdate(); - - ShowStatus(string.Format(_language.TagXAdded, tag)); - ShowSource(); - RefreshSelectedParagraph(); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - } - } - - private string ToogleMusicSymbols(string tag, string text) - { - string pre = string.Empty; - string post = string.Empty; - var indexOfEndBracket = text.IndexOf('}'); - if (text.StartsWith("{\\", StringComparison.Ordinal) && indexOfEndBracket > 1) - { - pre = text.Substring(0, indexOfEndBracket + 1); - text = text.Remove(0, indexOfEndBracket + 1); - } - - bool updated = true; - while (updated) - { - updated = false; - if (text.StartsWith(' ')) - { - pre += ' '; - text = text.Remove(0, 1); - updated = true; - } - else if (text.StartsWith("'); - if (endFont > 0) - { - pre += text.Substring(0, endFont + 1); - text = text.Remove(0, endFont + 1); - updated = true; - } - - if (text.EndsWith("
", StringComparison.OrdinalIgnoreCase)) - { - var endTag = "
"; - post += endTag; - text = text.Remove(text.Length - endTag.Length, endTag.Length); - } - } - } - - if (text.Contains(tag)) - { - text = pre + text.Replace(tag, string.Empty).Replace(Environment.NewLine + " ", Environment.NewLine).Replace(" " + Environment.NewLine, Environment.NewLine).Trim() + post; - } - else - { - if (Configuration.Settings.Tools.MusicSymbolStyle.Equals("single", StringComparison.OrdinalIgnoreCase)) - { - text = string.Format("{0}{1} {2}{3}", pre, tag, text.Replace(Environment.NewLine, Environment.NewLine + tag + " "), post); - } - else - { - text = string.Format("{0}{1} {2} {1}{3}", pre, tag, text.Replace(Environment.NewLine, " " + tag + Environment.NewLine + tag + " "), post); - } - } - - return text; - } - - private void SuperscriptToolStripMenuItemClick(object sender, EventArgs e) - { - var tb = GetFocusedTextBox(); - - string text = tb.SelectedText; - int selectionStart = tb.SelectionStart; - text = Utilities.ToSuperscript(text); - tb.SelectedText = text; - tb.SelectionStart = selectionStart; - tb.SelectionLength = text.Length; - } - - private void SubscriptToolStripMenuItemClick(object sender, EventArgs e) - { - var tb = GetFocusedTextBox(); - - string text = tb.SelectedText; - int selectionStart = tb.SelectionStart; - text = Utilities.ToSubscript(text); - tb.SelectedText = text; - tb.SelectionStart = selectionStart; - tb.SelectionLength = text.Length; - } - - private void ToolStripMenuItemImagePerFrameClick(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.ImageFrame, _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - private void toolStripMenuItemApplyDisplayTimeLimits_Click(object sender, EventArgs e) - { - ApplyDisplayTimeLimits(false); - } - - private void ApplyDisplayTimeLimits(bool onlySelectedLines) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - using (var applyDurationLimits = new ApplyDurationLimits()) - { - if (onlySelectedLines) - { - var selectedLines = new Subtitle(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]); - } - - applyDurationLimits.Initialize(selectedLines); - } - else - { - applyDurationLimits.Initialize(_subtitle); - } - - if (applyDurationLimits.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeDisplayTimeAdjustment); - - if (onlySelectedLines) - { // we only update selected lines - int i = 0; - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index] = applyDurationLimits.FixedSubtitle.Paragraphs[i]; - i++; - } - - ShowStatus(_language.VisualSyncPerformedOnSelectedLines); - SubtitleListview1.SyntaxColorAllLines(_subtitle); - } - else - { - SaveSubtitleListviewIndices(); - _subtitle.Paragraphs.Clear(); - foreach (var p in applyDurationLimits.FixedSubtitle.Paragraphs) - { - _subtitle.Paragraphs.Add(new Paragraph(p)); - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - ShowSource(); - } - } - } - - private void generateDatetimeInfoFromVideoToolStripMenuItem_Click(object sender, EventArgs e) - { - ReloadFromSourceView(); - using (var extractDateTimeInfo = new ExtractDateTimeInfo()) - { - if (extractDateTimeInfo.ShowDialog(this) == DialogResult.OK) - { - if (ContinueNewOrExit()) - { - MakeHistoryForUndo(_language.BeforeDisplayTimeAdjustment); - - ResetSubtitle(); - _subtitle.Paragraphs.Clear(); - foreach (var p in extractDateTimeInfo.DateTimeSubtitle.Paragraphs) - { - _subtitle.Paragraphs.Add(new Paragraph(p)); - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - ShowSource(); - OpenVideo(extractDateTimeInfo.VideoFileName); - } - } - } - } - - private void ToolStripMenuItemRightToLeftModeClick(object sender, EventArgs e) - { - var focusedItem = SubtitleListview1.FocusedItem; - toolStripMenuItemRightToLeftMode.Checked = !toolStripMenuItemRightToLeftMode.Checked; - if (!toolStripMenuItemRightToLeftMode.Checked) - { - RightToLeft = RightToLeft.No; - textBoxListViewText.RightToLeft = RightToLeft.No; - textBoxListViewTextAlternate.RightToLeft = RightToLeft.No; - SubtitleListview1.RightToLeft = RightToLeft.No; - SubtitleListview1.RightToLeftLayout = false; - textBoxSource.RightToLeft = RightToLeft.No; - mediaPlayer.TextRightToLeft = RightToLeft.No; - textBoxSearchWord.RightToLeft = RightToLeft.No; - Configuration.Settings.General.RightToLeftMode = false; - } - else - { - //RightToLeft = RightToLeft.Yes; - is this better? TimeUpDown custom control needs to support RTL before enabling this - textBoxListViewText.RightToLeft = RightToLeft.Yes; - textBoxListViewTextAlternate.RightToLeft = RightToLeft.Yes; - SubtitleListview1.RightToLeft = RightToLeft.Yes; - SubtitleListview1.RightToLeftLayout = true; - textBoxSource.RightToLeft = RightToLeft.Yes; - mediaPlayer.TextRightToLeft = RightToLeft.Yes; - textBoxSearchWord.RightToLeft = RightToLeft.Yes; - Configuration.Settings.General.RightToLeftMode = true; - } - - MainResize(); - TextBoxListViewTextTextChanged(null, null); - textBoxListViewTextAlternate_TextChanged(null, null); - if (focusedItem != null) - { - SubtitleListview1.SelectIndexAndEnsureVisible(focusedItem.Index, true); - } - } - - private void joinSubtitlesToolStripMenuItem_Click(object sender, EventArgs e) - { - ReloadFromSourceView(); - using (var joinSubtitles = new JoinSubtitles()) - { - if (joinSubtitles.ShowDialog(this) == DialogResult.OK && joinSubtitles.JoinedSubtitle != null && joinSubtitles.JoinedSubtitle.Paragraphs.Count > 0 && ContinueNewOrExit()) - { - MakeHistoryForUndo(_language.BeforeDisplaySubtitleJoin); - - ResetSubtitle(); - _subtitle.Paragraphs.Clear(); - _subtitle.Paragraphs.AddRange(joinSubtitles.JoinedSubtitle.Paragraphs); - SetCurrentFormat(joinSubtitles.JoinedFormat); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(0, true); - ShowSource(); - ShowStatus(_language.SubtitlesJoined); - } - } - } - - private void toolStripMenuItemReverseRightToLeftStartEnd_Click(object sender, EventArgs e) - { - ReverseStartAndEndingForRtl(); - } - - private void toolStripMenuItemExportCapMakerPlus_Click(object sender, EventArgs e) - { - var capMakerPlus = new CapMakerPlus(); - saveFileDialog1.Filter = capMakerPlus.Name + "|*" + capMakerPlus.Extension; - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*" + capMakerPlus.Extension; - saveFileDialog1.AddExtension = true; - - if (!string.IsNullOrEmpty(VideoFileName)) - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); - } - else - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); - } - - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - string fileName = saveFileDialog1.FileName; - string ext = Path.GetExtension(fileName); - bool extOk = ext.Equals(capMakerPlus.Extension, StringComparison.OrdinalIgnoreCase); - if (!extOk) - { - if (fileName.EndsWith('.')) - { - fileName = fileName.Substring(0, fileName.Length - 1); - } - - fileName += capMakerPlus.Extension; - } - - CapMakerPlus.Save(fileName, GetSaveSubtitle(_subtitle)); - } - } - - private void toolStripMenuItemExportCheetahCap_Click(object sender, EventArgs e) - { - var cheetahCaption = new CheetahCaption(); - saveFileDialog1.Filter = cheetahCaption.Name + "|*" + cheetahCaption.Extension; - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*" + cheetahCaption.Extension; - saveFileDialog1.AddExtension = true; - - if (!string.IsNullOrEmpty(VideoFileName)) - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); - } - else - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); - } - - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - string fileName = saveFileDialog1.FileName; - string ext = Path.GetExtension(fileName); - bool extOk = ext.Equals(cheetahCaption.Extension, StringComparison.OrdinalIgnoreCase); - if (!extOk) - { - if (fileName.EndsWith('.')) - { - fileName = fileName.Substring(0, fileName.Length - 1); - } - - fileName += cheetahCaption.Extension; - } - - CheetahCaption.Save(fileName, GetSaveSubtitle(_subtitle)); - } - } - - private void toolStripMenuItemExportCaptionInc_Click(object sender, EventArgs e) - { - var captionInc = new CaptionsInc(); - saveFileDialog1.Filter = captionInc.Name + "|*" + captionInc.Extension; - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*" + captionInc.Extension; - saveFileDialog1.AddExtension = true; - - if (!string.IsNullOrEmpty(VideoFileName)) - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); - } - else - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); - } - - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - string fileName = saveFileDialog1.FileName; - string ext = Path.GetExtension(fileName); - bool extOk = ext.Equals(captionInc.Extension, StringComparison.OrdinalIgnoreCase); - if (!extOk) - { - if (fileName.EndsWith('.')) - { - fileName = fileName.Substring(0, fileName.Length - 1); - } - - fileName += captionInc.Extension; - } - - CaptionsInc.Save(fileName, GetSaveSubtitle(_subtitle)); - } - } - - private void toolStripMenuItemExportUltech130_Click(object sender, EventArgs e) - { - var ultech130 = new Ultech130(); - saveFileDialog1.Filter = ultech130.Name + "|*" + ultech130.Extension; - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*" + ultech130.Extension; - saveFileDialog1.AddExtension = true; - - if (!string.IsNullOrEmpty(VideoFileName)) - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); - } - else - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); - } - - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - string fileName = saveFileDialog1.FileName; - string ext = Path.GetExtension(fileName); - bool extOk = ext.Equals(ultech130.Extension, StringComparison.OrdinalIgnoreCase); - if (!extOk) - { - if (fileName.EndsWith('.')) - { - fileName = fileName.Substring(0, fileName.Length - 1); - } - - fileName += ultech130.Extension; - } - - Ultech130.Save(fileName, GetSaveSubtitle(_subtitle)); - } - } - - private void toolStripMenuItemAssStyles_Click(object sender, EventArgs e) - { - StylesForm styles = null; - try - { - var format = GetCurrentSubtitleFormat(); - var formatType = format.GetType(); - if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha)) - { - styles = new SubStationAlphaStyles(_subtitle, format); - if (styles.ShowDialog(this) == DialogResult.OK) - { - if (_subtitle.Header != styles.Header) - { - MakeHistoryForUndo(styles.Text); - } - - _subtitle.Header = styles.Header; - var styleList = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); - if ((styles as SubStationAlphaStyles).RenameActions.Count > 0) - { - foreach (var renameAction in (styles as SubStationAlphaStyles).RenameActions) - { - for (var i = 0; i < _subtitle.Paragraphs.Count; i++) - { - var p = _subtitle.Paragraphs[i]; - if (p.Extra == renameAction.OldName) - { - p.Extra = renameAction.NewName; - } - } - } - - CleanRemovedStyles(styleList); - SaveSubtitleListviewIndices(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - else - { - CleanRemovedStyles(styleList); - } - } - } - else if (formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText)) - { - styles = new TimedTextStyles(_subtitle); - if (styles.ShowDialog(this) == DialogResult.OK) - { - if (_subtitle.Header != styles.Header) - { - MakeHistoryForUndo(styles.Text); - } - - _subtitle.Header = styles.Header; - } - } - } - finally - { - mediaPlayer.LastParagraph = null; - UiUtil.ShowSubtitle(_subtitle, mediaPlayer); - styles?.Dispose(); - } - } - - private void CleanRemovedStyles(List styleList) - { - for (var i = 0; i < _subtitle.Paragraphs.Count; i++) - { - var p = _subtitle.Paragraphs[i]; - if (p.Extra == null || !styleList.Any(s => s.Equals(p.Extra == "*Default" ? "Default" : p.Extra, StringComparison.OrdinalIgnoreCase))) - { - p.Extra = styleList[0]; - SubtitleListview1.SetExtraText(i, p.Extra, SubtitleListview1.ForeColor); - } - } - } - - private void toolStripMenuItemSubStationAlpha_Click(object sender, EventArgs e) - { - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - ReloadFromSourceView(); - } - - using (var properties = new SubStationAlphaProperties(_subtitle, GetCurrentSubtitleFormat(), VideoFileName, _fileName)) - { - if (properties.ShowDialog(this) == DialogResult.OK && tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - ShowSource(); - } - } - } - - private static string RemoveAssAlignmentTags(string s) - { - return s.Replace("{\\an1}", string.Empty) // ASS tags alone - .Replace("{\\an2}", string.Empty) - .Replace("{\\an3}", string.Empty) - .Replace("{\\an4}", string.Empty) - .Replace("{\\an5}", string.Empty) - .Replace("{\\an6}", string.Empty) - .Replace("{\\an7}", string.Empty) - .Replace("{\\an8}", string.Empty) - .Replace("{\\an9}", string.Empty) - - .Replace("{an1\\", "{") // ASS multi tags (start) - .Replace("{an2\\", "{") - .Replace("{an3\\", "{") - .Replace("{an4\\", "{") - .Replace("{an5\\", "{") - .Replace("{an6\\", "{") - .Replace("{an7\\", "{") - .Replace("{an8\\", "{") - .Replace("{an9\\", "{") - - .Replace("\\an1\\", "\\") // ASS multi tags (middle) - .Replace("\\an2\\", "\\") - .Replace("\\an3\\", "\\") - .Replace("\\an4\\", "\\") - .Replace("\\an5\\", "\\") - .Replace("\\an6\\", "\\") - .Replace("\\an7\\", "\\") - .Replace("\\an8\\", "\\") - .Replace("\\an9\\", "\\") - - .Replace("\\an1}", "}") // ASS multi tags (end) - .Replace("\\an2}", "}") - .Replace("\\an3}", "}") - .Replace("\\an4}", "}") - .Replace("\\an5}", "}") - .Replace("\\an6}", "}") - .Replace("\\an7}", "}") - .Replace("\\an8}", "}") - .Replace("\\an9}", "}") - - .Replace("{\\a1}", string.Empty) // SSA tags - .Replace("{\\a2}", string.Empty) - .Replace("{\\a3}", string.Empty) - .Replace("{\\a4}", string.Empty) - .Replace("{\\a5}", string.Empty) - .Replace("{\\a6}", string.Empty) - .Replace("{\\a7}", string.Empty) - .Replace("{\\a8}", string.Empty) - .Replace("{\\a9}", string.Empty); - } - - private static string SetAlignTag(string s, string tag) - { - var text = RemoveAssAlignmentTags(s); - if (text.StartsWith("{\\", StringComparison.Ordinal) && text.Contains('}')) - { - if (!string.IsNullOrEmpty(tag)) - { - return text.Insert(1, "\\" + tag.TrimStart('{').TrimStart('\\').TrimEnd('}')); - } - - return text; - } - else - { - return string.Format(@"{0}{1}", tag, text); - } - } - - private void toolStripMenuItemAlignment_Click(object sender, EventArgs e) - { - var formatType = GetCurrentSubtitleFormat().GetType(); - - if (formatType == typeof(NetflixImsc11Japanese)) - { - using (var f = new AlignmentPickerJapanese(textBoxListViewText.Text)) - { - if (f.ShowDialog(this) == DialogResult.OK) - { - SetAlignment(f.ContentAlignment, true); - } - } - - return; - } - - using (var f = new AlignmentPicker(textBoxListViewText.Text)) - { - f.TopMost = true; - f.StartPosition = FormStartPosition.Manual; - f.Left = Cursor.Position.X - 150; - f.Top = Cursor.Position.Y - 75; - if (f.ShowDialog(this) == DialogResult.OK) - { - string tag = string.Empty; - if (formatType == typeof(SubStationAlpha)) - { - //1: Bottom left - //2: Bottom center - //3: Bottom right - //9: Middle left - //10: Middle center - //11: Middle right - //5: Top left - //6: Top center - //7: Top right - switch (f.Alignment) - { - case ContentAlignment.BottomLeft: - tag = "{\\a1}"; - break; - case ContentAlignment.BottomCenter: - tag = "{\\a2}"; - break; - case ContentAlignment.BottomRight: - tag = "{\\a3}"; - break; - case ContentAlignment.MiddleLeft: - tag = "{\\a9}"; - break; - case ContentAlignment.MiddleCenter: - tag = "{\\a10}"; - break; - case ContentAlignment.MiddleRight: - tag = "{\\a11}"; - break; - case ContentAlignment.TopLeft: - tag = "{\\a5}"; - break; - case ContentAlignment.TopCenter: - tag = "{\\a6}"; - break; - case ContentAlignment.TopRight: - tag = "{\\a7}"; - break; - } - } - else - { - //1: Bottom left - //2: Bottom center - //3: Bottom right - //4: Middle left - //5: Middle center - //6: Middle right - //7: Top left - //8: Top center - //9: Top right - switch (f.Alignment) - { - case ContentAlignment.BottomLeft: - tag = "{\\an1}"; - break; - case ContentAlignment.BottomCenter: - if (formatType == typeof(SubRip)) - { - tag = string.Empty; - } - else - { - tag = "{\\an2}"; - } - - break; - case ContentAlignment.BottomRight: - tag = "{\\an3}"; - break; - case ContentAlignment.MiddleLeft: - tag = "{\\an4}"; - break; - case ContentAlignment.MiddleCenter: - tag = "{\\an5}"; - break; - case ContentAlignment.MiddleRight: - tag = "{\\an6}"; - break; - case ContentAlignment.TopLeft: - tag = "{\\an7}"; - break; - case ContentAlignment.TopCenter: - tag = "{\\an8}"; - break; - case ContentAlignment.TopRight: - tag = "{\\an9}"; - break; - } - } - - if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) - { - SetAlignment(tag, true); - } - } - } - } - - private void toolStripMenuItemRestoreAutoBackup_Click(object sender, EventArgs e) - { - _lastDoNotPrompt = -1; - using (var restoreAutoBackup = new RestoreAutoBackup()) - { - if (restoreAutoBackup.ShowDialog(this) == DialogResult.OK && !string.IsNullOrEmpty(restoreAutoBackup.AutoBackupFileName)) - { - if (ContinueNewOrExit()) - { - OpenSubtitle(restoreAutoBackup.AutoBackupFileName, null); - _fileName = _fileName.Remove(0, Configuration.AutoBackupDirectory.Length).TrimStart(Path.DirectorySeparatorChar); - _converted = true; - SetTitle(); - } - } - } - } - - private void labelStatus_Click(object sender, EventArgs e) - { - if (_statusLog.Count == 0) - { - return; - } - - if (_statusLogForm == null || _statusLogForm.IsDisposed) - { - _statusLogForm = new StatusLog(_statusLog); - _statusLogForm.Show(this); - } - else - { - _statusLogForm.Show(); - } - } - - private void toolStripMenuItemStatistics_Click(object sender, EventArgs e) - { - using (var stats = new Statistics(_subtitle, _fileName, GetCurrentSubtitleFormat())) - { - stats.ShowDialog(this); - } - } - - private void toolStripMenuItemDCinemaProperties_Click(object sender, EventArgs e) - { - PositionAndSizeForm properties = null; - try - { - if (GetCurrentSubtitleFormat().GetType() == typeof(DCinemaInterop)) - { - properties = new DCinema.DCinemaPropertiesInterop(); - } - else - { - properties = new DCinema.DCinemaPropertiesSmpte(); - } - - properties.ShowDialog(this); - } - finally - { - properties?.Dispose(); - } - } - - private void toolStripMenuItemTextTimeCodePair_Click(object sender, EventArgs e) - { - if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) - { - saveFileDialog1.Filter = _language.TextFiles + "|*.txt"; - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*.txt"; - saveFileDialog1.AddExtension = true; - - string fname = saveFileDialog1.FileName; - if (string.IsNullOrEmpty(fname)) - { - fname = "ATS"; - } - - if (!fname.EndsWith(".txt", StringComparison.Ordinal)) - { - fname += ".txt"; - } - - string fileNameTimeCode = fname.Insert(fname.Length - 4, "_timecode"); - string fileNameText = fname.Insert(fname.Length - 4, "_text"); - - var timeCodeLines = new StringBuilder(); - var textLines = new StringBuilder(); - - const string timeCodeWriteFormat = "{0:00}:{1:00}:{2:00}:{3:00}"; - foreach (var p in GetSaveSubtitle(_subtitle).Paragraphs) - { - timeCodeLines.AppendLine(string.Format(timeCodeWriteFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, SubtitleFormat.MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds))); - timeCodeLines.AppendLine(string.Format(timeCodeWriteFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, SubtitleFormat.MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds))); - - textLines.AppendLine(HtmlUtil.RemoveHtmlTags(p.Text).Replace(Environment.NewLine, "|")); - textLines.AppendLine(); - } - - File.WriteAllText(fileNameTimeCode, timeCodeLines.ToString(), Encoding.UTF8); - File.WriteAllText(fileNameText, textLines.ToString(), Encoding.UTF8); - } - } - - private void textWordsPerMinutewpmToolStripMenuItem_Click(object sender, EventArgs e) - { - SortSubtitle(SubtitleSortCriteria.WordsPerMinute, (sender as ToolStripItem).Text); - } - - private void toolStripMenuItemTTPropertiesClick(object sender, EventArgs e) - { - var subtitleFormatType = GetCurrentSubtitleFormat().GetType(); - if (subtitleFormatType != typeof(TimedText10) && subtitleFormatType != typeof(ItunesTimedText)) - { - return; - } - - using (var properties = new TimedTextProperties(_subtitle)) - { - properties.ShowDialog(this); - } - } - - private void ToolStripMenuItemSaveSelectedLinesClick(object sender, EventArgs e) - { - var newSub = new Subtitle(_subtitle); - newSub.Header = _subtitle.Header; - newSub.Paragraphs.Clear(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - newSub.Paragraphs.Add(_subtitle.Paragraphs[index]); - } - - SubtitleFormat currentFormat = GetCurrentSubtitleFormat(); - UiUtil.SetSaveDialogFilter(saveFileDialog1, currentFormat); - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*" + currentFormat.Extension; - saveFileDialog1.AddExtension = true; - if (!string.IsNullOrEmpty(_fileName)) - { - saveFileDialog1.InitialDirectory = Path.GetDirectoryName(_fileName); - } - - if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) - { - int index = 0; - foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) - { - if (saveFileDialog1.FilterIndex == index + 1) - { - // only allow current extension or ".txt" - string fileName = saveFileDialog1.FileName; - string ext = Path.GetExtension(fileName).ToLowerInvariant(); - bool extOk = ext.Equals(format.Extension, StringComparison.OrdinalIgnoreCase) || format.AlternateExtensions.Contains(ext) || ext == ".txt"; - if (!extOk) - { - if (fileName.EndsWith('.')) - { - fileName = fileName.TrimEnd('.'); - } - - fileName += format.Extension; - } - - if (format.IsTextBased) - { - string allText = GetSaveSubtitle(newSub).ToText(format); - File.WriteAllText(fileName, allText, GetCurrentEncoding()); - ShowStatus(string.Format(_language.XLinesSavedAsY, newSub.Paragraphs.Count, fileName)); - return; - } - else if (format.GetType() == typeof(Ebu)) - { - new Ebu().Save(fileName, GetSaveSubtitle(newSub)); - ShowStatus(string.Format(_language.XLinesSavedAsY, newSub.Paragraphs.Count, fileName)); - return; - } - } - - index++; - } - } - } - - private void GuessTimeCodesToolStripMenuItemClick(object sender, EventArgs e) - { - using (var form = new WaveformGenerateTimeCodes()) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.BeforeGuessingTimeCodes)); - - double startFromSeconds = 0; - if (form.StartFromVideoPosition) - { - startFromSeconds = mediaPlayer.CurrentPosition; - } - - if (form.DeleteAll) - { - _subtitle.Paragraphs.Clear(); - } - else if (form.DeleteForward) - { - for (int i = _subtitle.Paragraphs.Count - 1; i > 0; i--) - { - if (_subtitle.Paragraphs[i].EndTime.TotalSeconds + 1 > startFromSeconds) - { - _subtitle.Paragraphs.RemoveAt(i); - } - } - } - - audioVisualizer.GenerateTimeCodes(_subtitle, startFromSeconds, form.BlockSize, form.VolumeMinimum, form.VolumeMaximum, form.DefaultMilliseconds); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RefreshSelectedParagraph(); - } - } - } - - private void DvdStudioProStl_Click(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "STL", _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - private void toolStripMenuItemPlugins_Click(object sender, EventArgs e) - { - using (var form = new PluginsGet()) - { - form.ShowDialog(this); - LoadPlugins(); - } - } - - private void toolStripMenuItemUndo_Click(object sender, EventArgs e) - { - UndoToIndex(true); - } - - private void toolStripMenuItemRedo_Click(object sender, EventArgs e) - { - UndoToIndex(false); - } - - private void seekSilenceToolStripMenuItem_Click(object sender, EventArgs e) - { - if (audioVisualizer.WavePeaks == null) - { - return; - } - - using (var form = new SeekSilence()) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - if (form.SeekForward) - { - audioVisualizer.FindDataBelowThreshold(form.VolumeBelow, form.SecondsDuration); - } - else - { - audioVisualizer.FindDataBelowThresholdBack(form.VolumeBelow, form.SecondsDuration); - } - } - } - } - - private void toolStripMenuItemPasteSpecial_Click(object sender, EventArgs e) - { - string text = Clipboard.GetText(); - var tmp = new Subtitle(); - var list = new List(text.SplitToLines()); - new SubRip().LoadSubtitle(tmp, list, null); - if (tmp.Paragraphs.Count == 0) - { - tmp = SubtitleFormat.LoadSubtitleFromLines(list, null) ?? new Subtitle(); - } - - if (SubtitleListview1.SelectedItems.Count == 1 && text.Length > 0) - { - var form = new ColumnPaste(SubtitleListview1.IsAlternateTextColumnVisible && _subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle, tmp.Paragraphs.Count == 0); - if (form.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeColumnPaste); - - if (tmp.Paragraphs.Count == 0) - { - foreach (var line in text.SplitToLines()) - { - tmp.Paragraphs.Add(new Paragraph(line, 0, 0)); - } - } - - int index = FirstSelectedIndex; - - if (!form.PasteOverwrite) - { - for (int i = 0; i < tmp.Paragraphs.Count; i++) - { - if (form.PasteAll) - { - for (int k = _subtitle.Paragraphs.Count - 2; k >= index; k--) - { - _subtitle.Paragraphs[k + 1] = new Paragraph(_subtitle.Paragraphs[k]); - } - - if (index + i < _subtitle.Paragraphs.Count) - { - _subtitle.Paragraphs[index + i].Text = string.Empty; - } - } - else if (form.PasteTimeCodesOnly) - { - for (int k = _subtitle.Paragraphs.Count - 2; k >= index; k--) - { - _subtitle.Paragraphs[k + 1].StartTime.TotalMilliseconds = _subtitle.Paragraphs[k].StartTime.TotalMilliseconds; - _subtitle.Paragraphs[k + 1].EndTime.TotalMilliseconds = _subtitle.Paragraphs[k].EndTime.TotalMilliseconds; - } - } - else if (form.PasteTextOnly) - { - for (int k = _subtitle.Paragraphs.Count - 2; k >= index; k--) - { - _subtitle.Paragraphs[k + 1].Text = _subtitle.Paragraphs[k].Text; - } - } - else if (form.PasteOriginalTextOnly) - { - for (int k = _subtitle.Paragraphs.Count - 2; k >= index; k--) - { - var original = Utilities.GetOriginalParagraph(k, _subtitle.Paragraphs[k], _subtitleAlternate.Paragraphs); - var originalNext = Utilities.GetOriginalParagraph(k + 1, _subtitle.Paragraphs[k + 1], _subtitleAlternate.Paragraphs); - if (original != null) - { - originalNext.Text = original.Text; - } - } - - if (index + i < _subtitle.Paragraphs.Count) - { - var original = Utilities.GetOriginalParagraph(index, _subtitle.Paragraphs[index + i], _subtitleAlternate.Paragraphs); - if (original != null) - { - original.Text = string.Empty; - } - } - } - } - } - - if (form.PasteOverwrite) - { - for (int i = 0; i < tmp.Paragraphs.Count; i++) - { - if (form.PasteAll) - { - if (index + i < _subtitle.Paragraphs.Count) - { - _subtitle.Paragraphs[index + i].Text = tmp.Paragraphs[i].Text; - _subtitle.Paragraphs[index + i].StartTime.TotalMilliseconds = tmp.Paragraphs[i].StartTime.TotalMilliseconds; - _subtitle.Paragraphs[index + i].EndTime.TotalMilliseconds = tmp.Paragraphs[i].EndTime.TotalMilliseconds; - } - } - else if (form.PasteTimeCodesOnly) - { - if (index + i < _subtitle.Paragraphs.Count) - { - _subtitle.Paragraphs[index + i].StartTime.TotalMilliseconds = tmp.Paragraphs[i].StartTime.TotalMilliseconds; - _subtitle.Paragraphs[index + i].EndTime.TotalMilliseconds = tmp.Paragraphs[i].EndTime.TotalMilliseconds; - } - } - else if (form.PasteTextOnly) - { - if (index + i < _subtitle.Paragraphs.Count) - { - _subtitle.Paragraphs[index + i].Text = tmp.Paragraphs[i].Text; - } - } - else if (form.PasteOriginalTextOnly) - { - if (index + i < _subtitle.Paragraphs.Count) - { - var original = Utilities.GetOriginalParagraph(index + i, _subtitle.Paragraphs[index + i], _subtitleAlternate.Paragraphs); - if (original != null) - { - original.Text = tmp.Paragraphs[i].Text; - } - } - } - } - } - else - { - for (int i = 0; i + index < _subtitle.Paragraphs.Count && i < tmp.Paragraphs.Count; i++) - { - if (index + i < _subtitle.Paragraphs.Count) - { - if (form.PasteAll) - { - _subtitle.Paragraphs[index + i].Text = tmp.Paragraphs[i].Text; - _subtitle.Paragraphs[index + i].StartTime.TotalMilliseconds = tmp.Paragraphs[i].StartTime.TotalMilliseconds; - _subtitle.Paragraphs[index + i].EndTime.TotalMilliseconds = tmp.Paragraphs[i].EndTime.TotalMilliseconds; - } - else if (form.PasteTimeCodesOnly) - { - _subtitle.Paragraphs[index + i].StartTime.TotalMilliseconds = tmp.Paragraphs[i].StartTime.TotalMilliseconds; - _subtitle.Paragraphs[index + i].EndTime.TotalMilliseconds = tmp.Paragraphs[i].EndTime.TotalMilliseconds; - } - else if (form.PasteTextOnly) - { - _subtitle.Paragraphs[index + i].Text = tmp.Paragraphs[i].Text; - } - else if (form.PasteOriginalTextOnly) - { - var original = Utilities.GetOriginalParagraph(index + i, _subtitle.Paragraphs[index + i], _subtitleAlternate.Paragraphs); - if (original != null) - { - original.Text = tmp.Paragraphs[i].Text; - } - } - } - } - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - RefreshSelectedParagraph(); - } - - form.Dispose(); - } - } - - private void deleteAndShiftCellsUpToolStripMenuItem_Click(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedIndices.Count < 1) - { - return; - } - - int first = FirstSelectedIndex; - List list = new List(); - foreach (int index in SubtitleListview1.SelectedIndices) - { - list.Add(index); - } - - list.Sort(); - list.Reverse(); - - MakeHistoryForUndo(_language.BeforeColumnDelete); - foreach (int index in list) - { - for (int k = index; k < _subtitle.Paragraphs.Count - 1; k++) - { - _subtitle.Paragraphs[k].Text = _subtitle.Paragraphs[k + 1].Text; - } - - _subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1].Text = string.Empty; - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(first, true); - RefreshSelectedParagraph(); - } - - private void toolStripMenuItemColumnImportText_Click(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedIndices.Count < 1) - { - return; - } - - using (var importText = new ImportText()) - { - if (importText.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeColumnImportText); - int index = FirstSelectedIndex; - for (int i = 0; i < importText.FixedSubtitle.Paragraphs.Count; i++) - { - for (int k = _subtitle.Paragraphs.Count - 2; k > index; k--) - { - _subtitle.Paragraphs[k + 1].Text = _subtitle.Paragraphs[k].Text; - } - - if (index + i < _subtitle.Paragraphs.Count) - { - _subtitle.Paragraphs[index + i].Text = string.Empty; - } - } - - for (int i = 0; i + index < _subtitle.Paragraphs.Count && i < importText.FixedSubtitle.Paragraphs.Count; i++) - { - _subtitle.Paragraphs[index + i].Text = importText.FixedSubtitle.Paragraphs[i].Text; - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - RefreshSelectedParagraph(); - } - } - } - - private void ShiftTextCellsDownToolStripMenuItem_Click(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedIndices.Count < 1) - { - return; - } - - int index = FirstSelectedIndex; - int count = SubtitleListview1.SelectedIndices.Count; - MakeHistoryForUndo(_language.BeforeColumnShiftCellsDown); - for (int i = 0; i < count; i++) - { - for (int k = _subtitle.Paragraphs.Count - 2; k >= index; k--) - { - _subtitle.Paragraphs[k + 1].Text = _subtitle.Paragraphs[k].Text; - } - - if (index + i < _subtitle.Paragraphs.Count) - { - _subtitle.Paragraphs[index + i].Text = string.Empty; - } - } - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - RefreshSelectedParagraph(); - } - - private void toolStripMenuItemInsertTextFromSub_Click(object sender, EventArgs e) - { - openFileDialog1.Title = _languageGeneral.OpenSubtitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - if (!File.Exists(openFileDialog1.FileName)) - { - return; - } - - var fi = new FileInfo(openFileDialog1.FileName); - if (fi.Length > 1024 * 1024 * 10) // max 10 mb - { - var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, openFileDialog1.FileName); - if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return; - } - } - - var tmp = new Subtitle(); - SubtitleFormat format = tmp.LoadSubtitle(openFileDialog1.FileName, out var encoding, null); - if (format != null) - { - if (Configuration.Settings.General.RemoveBlankLinesWhenOpening) - { - tmp.RemoveEmptyLines(); - } - - if (SubtitleListview1.SelectedIndices.Count < 1) - { - return; - } - - MakeHistoryForUndo(_language.BeforeColumnShiftCellsDown); - - int index = FirstSelectedIndex; - for (int i = 0; i < tmp.Paragraphs.Count; i++) - { - { - for (int k = _subtitle.Paragraphs.Count - 2; k > index; k--) - { - _subtitle.Paragraphs[k + 1].Text = _subtitle.Paragraphs[k].Text; - } - } - } - - for (int i = 0; i + index < _subtitle.Paragraphs.Count && i < tmp.Paragraphs.Count; i++) - { - _subtitle.Paragraphs[index + i].Text = tmp.Paragraphs[i].Text; - } - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - RefreshSelectedParagraph(); - } - } - } - - private void toolStripMenuItemOpenKeepVideo_Click(object sender, EventArgs e) - { - openToolStripMenuItem.Enabled = false; - ReloadFromSourceView(); - _resetVideo = false; - OpenNewFile(); - _resetVideo = true; - openToolStripMenuItem.Enabled = true; - } - - private void changeSpeedInPercentToolStripMenuItem_Click(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - using (var form = new ChangeSpeedInPercent(SubtitleListview1.SelectedItems.Count)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeAdjustSpeedInPercent); - SaveSubtitleListviewIndices(); - if (form.AdjustAllLines) - { - _subtitle = form.AdjustAllParagraphs(_subtitle); - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) - { - _subtitleAlternate = form.AdjustAllParagraphs(_subtitleAlternate); - } - } - else - { - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.GetParagraphOrDefault(index); - if (p != null) - { - form.AdjustParagraph(p); - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) - { - var original = Utilities.GetOriginalParagraph(index, p, _subtitle.Paragraphs); - if (original != null) - { - form.AdjustParagraph(original); - } - } - } - } - } - - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - } - - private void toolStripMenuItemAvidStl_Click(object sender, EventArgs e) - { - var avidStl = new AvidStl(); - saveFileDialog1.Filter = avidStl.Name + "|*" + avidStl.Extension; - saveFileDialog1.Title = _language.SaveSubtitleAs; - saveFileDialog1.DefaultExt = "*" + avidStl.Extension; - saveFileDialog1.AddExtension = true; - - if (!string.IsNullOrEmpty(VideoFileName)) - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); - } - else - { - saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); - } - - if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) - { - saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; - } - - DialogResult result = saveFileDialog1.ShowDialog(this); - if (result == DialogResult.OK) - { - openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; - string fileName = saveFileDialog1.FileName; - string ext = Path.GetExtension(fileName); - bool extOk = ext.Equals(avidStl.Extension, StringComparison.OrdinalIgnoreCase); - if (!extOk) - { - if (fileName.EndsWith('.')) - { - fileName = fileName.Substring(0, fileName.Length - 1); - } - - fileName += avidStl.Extension; - } - - AvidStl.Save(fileName, GetSaveSubtitle(_subtitle)); - } - } - - private Subtitle GetSaveSubtitle(Subtitle subtitle) - { - var sub = new Subtitle(subtitle); - if (string.IsNullOrEmpty(sub.FileName)) - { - sub.FileName = "Untitled"; - } - - if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) - { - sub.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(Configuration.Settings.General.CurrentVideoOffsetInMs)); - } - - return sub; - } - - private void columnDeleteTextOnlyToolStripMenuItem_Click(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedIndices.Count < 1) - { - return; - } - - MakeHistoryForUndo(_language.BeforeColumnDelete); - foreach (int index in SubtitleListview1.SelectedIndices) - { - _subtitle.Paragraphs[index].Text = string.Empty; - SubtitleListview1.SetText(index, string.Empty); - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, _subtitle.Paragraphs[index]); - } - - RefreshSelectedParagraph(); - } - - private void toolStripMenuItemBatchConvert_Click(object sender, EventArgs e) - { - Visible = false; - using (var form = new BatchConvert(Icon)) - { - form.ShowDialog(this); - } - - Visible = true; - } - - private void copyOriginalTextToCurrentToolStripMenuItem_Click(object sender, EventArgs e) - { - if (_subtitleAlternate == null || !SubtitleListview1.IsAlternateTextColumnVisible || SubtitleListview1.SelectedIndices.Count < 1) - { - return; - } - - bool first = true; - foreach (int index in SubtitleListview1.SelectedIndices) - { - var original = Utilities.GetOriginalParagraph(index, _subtitle.Paragraphs[index], _subtitleAlternate.Paragraphs); - if (original != null) - { - if (first) - { - MakeHistoryForUndo(_language.BeforeColumnPaste); - } - - SubtitleListview1.SetText(index, original.Text); - _subtitle.Paragraphs[index].Text = original.Text; - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, _subtitle.Paragraphs[index]); - first = false; - } - } - - RefreshSelectedParagraph(); - } - - private void toolStripMenuItemColumn_DropDownOpening(object sender, EventArgs e) - { - copyOriginalTextToCurrentToolStripMenuItem.Visible = !string.IsNullOrEmpty(copyOriginalTextToCurrentToolStripMenuItem.Text) && - SubtitleListview1.IsAlternateTextColumnVisible && - _subtitleAlternate != null; - } - - private void toolStripMenuItemMergeDuplicateText_Click(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - using (var form = new MergeDoubleLines()) - { - form.Initialize(_subtitle); - if (form.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeMergeLinesWithSameText); - _subtitle.Paragraphs.Clear(); - foreach (var p in form.MergedSubtitle.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowStatus(string.Format(_language.MergedShortLinesX, form.NumberOfMerges)); - SaveSubtitleListviewIndices(); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - } - - private void toolStripMenuItemMergeLinesWithSameTimeCodes_Click(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - ReloadFromSourceView(); - using (var form = new MergeTextWithSameTimeCodes()) - { - form.Initialize(_subtitle); - if (form.ShowDialog(this) == DialogResult.OK) - { - MakeHistoryForUndo(_language.BeforeMergeLinesWithSameText); - _subtitle.Paragraphs.Clear(); - foreach (var p in form.MergedSubtitle.Paragraphs) - { - _subtitle.Paragraphs.Add(p); - } - - ShowStatus(string.Format(_language.MergedShortLinesX, form.NumberOfMerges)); - SaveSubtitleListviewIndices(); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - } - - private void toolStripMenuItem2_Click(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.Spumux, _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - private void toolStripMenuItemModifySelection_Click(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - using (var form = new ModifySelection(_subtitle, GetCurrentSubtitleFormat(), SubtitleListview1)) - { - form.ShowDialog(this); - } - } - - private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - foreach (ListViewItem item in SubtitleListview1.Items) - { - item.Selected = !item.Selected; - } - } - - private void toolStripMenuItemSpellCheckFromCurrentLine_Click(object sender, EventArgs e) - { - _spellCheckForm = null; - SpellCheck(true, FirstSelectedIndex); - } - - private void toolStripMenuItemImportXSub_Click(object sender, EventArgs e) - { - if (ContinueNewOrExit()) - { - openFileDialog1.Title = _language.OpenXSubFiles; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = _language.XSubFiles + "|*.divx;*.avi"; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - ShowStatus(_languageGeneral.PleaseWait); - if (ImportSubtitleFromDivX(openFileDialog1.FileName)) - { - ShowStatus(string.Format(_language.LoadedSubtitleX, openFileDialog1.FileName)); - } - else - { - ShowStatus(string.Empty); - MessageBox.Show(_language.NotAValidXSubFile); - } - } - } - } - - private void toolStripMenuItemImportOcrHardSub_Click(object sender, EventArgs e) - { - using (var form = new HardSubExtract(VideoFileName)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - if (!string.IsNullOrEmpty(form.OcrFileName)) - { - MakeHistoryForUndo(_language.BeforeAutoBalanceSelectedLines); - OpenSubtitle(form.OcrFileName, null); - } - } - } - } - - private void toolStripMenuItemExportFcpIImage_Click(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.Fcp, _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - private void ToolStripMenuItemNuendoPropertiesClick(object sender, EventArgs e) - { - using (var form = new NuendoProperties()) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - Configuration.Settings.SubtitleSettings.NuendoCharacterListFile = form.CharacterListFile; - } - } - } - - private void toolStripMenuItemDost_Click(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.Dost, _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - private void toolStripMenuItemMeasurementConverter_Click(object sender, EventArgs e) - { - var selectedText = string.Empty; - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - selectedText = textBoxSource.SelectedText; - } - else - { - selectedText = GetFocusedTextBox().SelectedText; - } - - if (_measurementConverter != null && !_measurementConverter.IsDisposed) - { - _measurementConverter.WindowState = FormWindowState.Normal; - _measurementConverter.Input = selectedText; - _measurementConverter.IsOriginalActive = GetFocusedTextBox() == textBoxListViewTextAlternate; - _measurementConverter.Focus(); - return; - } - - _measurementConverter = new MeasurementConverter - { - Input = selectedText, - IsOriginalActive = GetFocusedTextBox() == textBoxListViewTextAlternate, - }; - _measurementConverter.InsertClicked += measurementConverter_InsertClicked; - _measurementConverter.Show(this); - } - - private void measurementConverter_InsertClicked(object sender, MeasurementConverter.InsertEventArgs e) - { - if (IsSubtitleLoaded) - { - var tb = e.IsOriginalActive ? textBoxListViewTextAlternate : textBoxListViewText; - tb.SelectedText = e.Result; - } - } - - private async void toolStripMenuItemImportChapters_Click(object sender, EventArgs e) - { - toolStripMenuItemImportChapters.Enabled = false; - ShowStatus(_language.ImportingChapters); - - var chaps = new List(); - using (var matroska = new MatroskaFile(VideoFileName)) - { - chaps = await System.Threading.Tasks.Task.Run(() => matroska.GetChapters()); - } - - if (chaps?.Count > 0) - { - mediaPlayer.Chapters = chaps; - - if (audioVisualizer.WavePeaks != null) - { - audioVisualizer.Chapters = chaps; - } - - ShowStatus(string.Format(_language.XChaptersImported, chaps?.Count)); - } - else - { - ShowStatus(_language.NoChapters); - MessageBox.Show(_language.NoChapters, Title); - } - - toolStripMenuItemImportChapters.Enabled = true; - } - - private void toolStripMenuItemImportSceneChanges_Click(object sender, EventArgs e) - { - using (var form = new ImportSceneChanges(_videoInfo, VideoFileName)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - audioVisualizer.SceneChanges = form.SceneChangesInSeconds; - SceneChangeHelper.SaveSceneChanges(VideoFileName, audioVisualizer.SceneChanges); - ShowStatus(string.Format(_language.XSceneChangesImported, form.SceneChangesInSeconds.Count)); - } - } - } - - private void toolStripMenuItemRemoveSceneChanges_Click(object sender, EventArgs e) - { - if (audioVisualizer.SceneChanges != null) - { - audioVisualizer.SceneChanges = new List(); - SceneChangeHelper.DeleteSceneChanges(VideoFileName); - } - } - - private void toolStripMenuItemBridgeGapsBetweenSubtitles_Click(object sender, EventArgs e) - { - if (!IsSubtitleLoaded) - { - DisplaySubtitleNotLoadedMessage(); - return; - } - - using (var form = new DurationsBridgeGaps(_subtitle)) - { - if (form.ShowDialog(this) == DialogResult.OK && form.FixedCount > 0) - { - int index = FirstSelectedIndex; - if (index < 0) - { - index = 0; - } - - MakeHistoryForUndo(_language.BeforeDurationsBridgeGap); - SaveSubtitleListviewIndices(); - _subtitle.Paragraphs.Clear(); - _subtitle.Paragraphs.AddRange(form.FixedSubtitle.Paragraphs); - - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - RestoreSubtitleListviewIndices(); - } - } - } - - private void toolStripMenuItemOpenDvd_Click(object sender, EventArgs e) - { - using (var form = new OpenVideoDvd()) - { - if (form.ShowDialog(this) == DialogResult.OK && !string.IsNullOrEmpty(form.DvdPath)) - { - VideoFileName = form.DvdPath; - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.PauseAndDisposePlayer(); - } - - _endSeconds = -1; - - _videoInfo = new VideoInfo(); - _videoInfo.Width = 720; - _videoInfo.Height = 576; - _videoInfo.FramesPerSecond = 25; - _videoInfo.VideoCodec = "MPEG2"; - toolStripComboBoxFrameRate.Text = string.Format("{0:0.###}", _videoInfo.FramesPerSecond); - - var oldVideoPlayer = Configuration.Settings.General.VideoPlayer; - try - { - Configuration.Settings.General.VideoPlayer = "VLC"; - UiUtil.InitializeVideoPlayerAndContainer(VideoFileName, _videoInfo, mediaPlayer, VideoLoaded, VideoEnded); - mediaPlayer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton; - mediaPlayer.OnButtonClicked -= MediaPlayer_OnButtonClicked; - mediaPlayer.OnButtonClicked += MediaPlayer_OnButtonClicked; - mediaPlayer.Volume = 0; - labelVideoInfo.Text = string.Format("DVD {0}x{1} {2}", _videoInfo.Width, _videoInfo.Height, _videoInfo.VideoCodec.Trim()); - if (_videoInfo.FramesPerSecond > 0) - { - labelVideoInfo.Text += string.Format(" {0:0.0##}", _videoInfo.FramesPerSecond); - } - } - finally - { - Configuration.Settings.General.VideoPlayer = oldVideoPlayer; - } - } - } - } - - private void toolStripMenuItemFcpProperties_Click(object sender, EventArgs e) - { - using (var form = new FcpProperties()) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - Configuration.Settings.SubtitleSettings.FcpFontSize = form.FcpFontSize; - Configuration.Settings.SubtitleSettings.FcpFontName = form.FcpFontName; - } - } - } - - private void styleToolStripMenuItem_Click(object sender, EventArgs e) - { - SortSubtitle(SubtitleSortCriteria.Style, (sender as ToolStripItem).Text); - } - - private void toolStripMenuItemFocusTextbox_Click(object sender, EventArgs e) - { - int index = _subtitle.GetIndex(audioVisualizer.RightClickedParagraph); - if (index >= 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(index, true); - } - - textBoxListViewText.Focus(); - textBoxListViewText.SelectAll(); - } - - private void AscendingToolStripMenuItem_Click(object sender, EventArgs e) - { - descendingToolStripMenuItem.Checked = false; - AscendingToolStripMenuItem.Checked = true; - toolsToolStripMenuItem.ShowDropDown(); - toolStripMenuItemSortBy.ShowDropDown(); - } - - private void descendingToolStripMenuItem_Click(object sender, EventArgs e) - { - AscendingToolStripMenuItem.Checked = false; - descendingToolStripMenuItem.Checked = true; - toolsToolStripMenuItem.ShowDropDown(); - toolStripMenuItemSortBy.ShowDropDown(); - } - - private void exportCustomTextFormatToolStripMenuItem_Click(object sender, EventArgs e) - { - using (var form = new ExportCustomText(GetSaveSubtitle(_subtitle), GetSaveSubtitle(_subtitleAlternate), _fileName)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - ShowStatus(form.LogMessage); - } - } - } - - private void PasteIntoActiveTextBox(string s, bool allowMultiLine = false) - { - if (tabControlSubtitle.SelectedIndex == TabControlSourceView) - { - textBoxSource.SelectedText = s; - } - else - { - if (textBoxListViewTextAlternate.Visible && textBoxListViewTextAlternate.Enabled && textBoxListViewTextAlternate.Focused) - { - if (!string.IsNullOrEmpty(textBoxListViewTextAlternate.SelectedText)) - { - textBoxListViewTextAlternate.SelectedText = s; - } - else - { - var selectionStart = textBoxListViewTextAlternate.SelectionStart; - textBoxListViewTextAlternate.Text = textBoxListViewTextAlternate.Text.Insert(textBoxListViewTextAlternate.SelectionStart, s); - textBoxListViewTextAlternate.SelectionStart = selectionStart + s.Length; - } - } - else - { - if (SubtitleListview1.SelectedItems.Count > 1 && !textBoxListViewText.Focused && allowMultiLine) - { - foreach (ListViewItem item in SubtitleListview1.SelectedItems) - { - var p = _subtitle.GetParagraphOrDefault(item.Index); - if (p == null) - { - continue; - } - - p.Text = s + " " + p.Text; - SubtitleListview1.SetText(item.Index, p.Text); - } - RefreshSelectedParagraph(); - } - else - { - if (!string.IsNullOrEmpty(textBoxListViewText.SelectedText)) - { - textBoxListViewText.SelectedText = s; - } - else - { - var selectionStart = textBoxListViewText.SelectionStart; - textBoxListViewText.Text = textBoxListViewText.Text.Insert(textBoxListViewText.SelectionStart, s); - textBoxListViewText.SelectionStart = selectionStart + s.Length; - } - } - - ShowSource(); - } - } - } - - private void leftToolStripMenuItem_Click(object sender, EventArgs e) - { - PasteIntoActiveTextBox("\u200E"); // LRM, Left-to-Right Mark, acts as a Latin character. - } - - private void righttoleftMarkToolStripMenuItem_Click(object sender, EventArgs e) - { - PasteIntoActiveTextBox("\u200F"); // RLM, Right-to-Left Mark, acts as an Arabic character. - } - - private void startOfLefttorightEmbeddingLREToolStripMenuItem_Click(object sender, EventArgs e) - { - PasteIntoActiveTextBox("\u202A"); - } - - private void startOfRighttoleftEmbeddingRLEToolStripMenuItem_Click(object sender, EventArgs e) - { - PasteIntoActiveTextBox("\u202B"); - } - - private void startOfLefttorightOverrideLROToolStripMenuItem_Click(object sender, EventArgs e) - { - PasteIntoActiveTextBox("\u202D"); - } - - private void startOfRighttoleftOverrideRLOToolStripMenuItem_Click(object sender, EventArgs e) - { - PasteIntoActiveTextBox("\u202E"); - } - - private void toolStripMenuItemRtlUnicodeControlChar_Click(object sender, EventArgs e) - { - if (IsUnicode) - { - int selectedIndex = FirstSelectedIndex; - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.Paragraphs[index]; - p.Text = Utilities.FixRtlViaUnicodeChars(p.Text); - SubtitleListview1.SetText(index, p.Text); - if (index == selectedIndex) - { - textBoxListViewText.Text = p.Text; - } - } - - RefreshSelectedParagraph(); - } - } - - private void toolStripMenuItemRemoveUnicodeControlChar_Click(object sender, EventArgs e) - { - if (IsUnicode) - { - int selectedIndex = FirstSelectedIndex; - foreach (int index in SubtitleListview1.SelectedIndices) - { - var p = _subtitle.Paragraphs[index]; - p.Text = Utilities.RemoveUnicodeControlChars(p.Text); - SubtitleListview1.SetText(index, p.Text); - if (index == selectedIndex) - { - textBoxListViewText.Text = p.Text; - } - } - - RefreshSelectedParagraph(); - } - } - - private void toolStripMenuItemImportImages_Click(object sender, EventArgs e) - { - if (!ContinueNewOrExit()) - { - return; - } - - if (!string.IsNullOrEmpty(VideoFileName) && mediaPlayer.VideoPlayer != null) - { - mediaPlayer.Pause(); - } - - using (var form = new ImportImages()) - { - if (form.ShowDialog(this) == DialogResult.OK && form.Subtitle.Paragraphs.Count > 0) - { - ImportAndOcrSrt(form.Subtitle); - } - } - } - - private void audioVisualizer_MouseEnter(object sender, EventArgs e) - { - if (Configuration.Settings.VideoControls.WaveformFocusOnMouseEnter && audioVisualizer.WavePeaks != null && !audioVisualizer.Focused && audioVisualizer.CanFocus) - { - if (Math.Abs(_lastWaveformMenuCloseTicks - DateTime.UtcNow.Ticks) > 10000 * 500) // only if last change was longer ago than 500 milliseconds - { - audioVisualizer.Focus(); - } - } - } - - private void SubtitleListview1_MouseEnter(object sender, EventArgs e) - { - if (Configuration.Settings.VideoControls.WaveformFocusOnMouseEnter && Configuration.Settings.VideoControls.WaveformListViewFocusOnMouseEnter && SubtitleListview1.CanFocus) - { - SubtitleListview1.Focus(); - } - } - - private void toolStripButtonFixCommonErrors_Click(object sender, EventArgs e) - { - FixCommonErrors(false); - } - - private void toolStripButtonRemoveTextForHi_Click(object sender, EventArgs e) - { - RemoveTextForHearImpairedToolStripMenuItemClick(sender, e); - } - - private void toolStripMenuItemExportDcinemaInteropClick(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.DCinemaInterop, _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - private void dCinemaSMPTE2014ToolStripMenuItem_Click(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.DCinemaInterop, _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - internal Subtitle UndoFromSpellCheck(Subtitle subtitle) - { - var idx = FirstSelectedIndex; - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - if (_subtitle.Paragraphs[i].Text != subtitle.Paragraphs[i].Text) - { - _subtitle.Paragraphs[i].Text = subtitle.Paragraphs[i].Text; - SubtitleListview1.SetText(i, _subtitle.Paragraphs[i].Text); - } - - if (idx == i) - { - SubtitleListview1.SetText(idx, _subtitle.Paragraphs[idx].Text); - } - } - - RefreshSelectedParagraph(); - return _subtitle; - } - - private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e) - { - try - { - if (_timerCheckForUpdates != null) - { - _timerCheckForUpdates.Stop(); - } - } - catch - { - } - - using (var form = new CheckForUpdates(this)) - { - form.ShowDialog(this); - } - - Configuration.Settings.General.LastCheckForUpdates = DateTime.Now; - } - - private void setVideoOffsetToolStripMenuItem_Click(object sender, EventArgs e) - { - if (!string.IsNullOrEmpty(VideoFileName) && mediaPlayer.VideoPlayer != null) - { - mediaPlayer.Pause(); - } - - using (var form = new SetVideoOffset()) - { - form.VideoOffset = new TimeCode(10, 0, 0, 0); - if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) - { - form.VideoOffset = new TimeCode(Configuration.Settings.General.CurrentVideoOffsetInMs); - } - - var oldVideoOffset = Configuration.Settings.General.CurrentVideoOffsetInMs; - if (form.ShowDialog(this) == DialogResult.OK) - { - var change = _changeSubtitleHash != _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - if (form.FromCurrentVideoPosition && mediaPlayer.VideoPlayer != null) - { - Configuration.Settings.General.CurrentVideoOffsetInMs = (long)(Math.Round((form.VideoOffset.TotalSeconds - mediaPlayer.VideoPlayer.CurrentPosition) * 1000.0)); - change = true; - } - else - { - Configuration.Settings.General.CurrentVideoOffsetInMs = (long)(Math.Round(form.VideoOffset.TotalSeconds * 1000.0)); - } - - if (form.DoNotaddVideoOffsetToTimeCodes) - { - if (form.Reset) - { - _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(oldVideoOffset)); - _subtitleAlternate?.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(oldVideoOffset)); - } - else - { - _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-Configuration.Settings.General.CurrentVideoOffsetInMs)); - _subtitleAlternate?.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-Configuration.Settings.General.CurrentVideoOffsetInMs)); - } - } - else - { - change = true; - } - - if (!change) - { - _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); - } - else if (change && _changeSubtitleHash == _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName)) - { - _changeSubtitleHash = -1; - } - - SaveSubtitleListviewIndices(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RefreshSelectedParagraph(); - RestoreSubtitleListviewIndices(); - } - } - } - - private void toolStripMenuItemEbuProperties_Click(object sender, EventArgs e) - { - using (var properties = new EbuSaveOptions()) - { - if (_subtitle != null && _subtitle.Header != null && (_subtitle.Header.Contains("STL2") || _subtitle.Header.Contains("STL3"))) - { - var header = Ebu.ReadHeader(Encoding.UTF8.GetBytes(_subtitle.Header)); - properties.Initialize(header, Ebu.EbuUiHelper.JustificationCode, null, _subtitle); - } - else - { - var header = new Ebu.EbuGeneralSubtitleInformation(); - if (!string.IsNullOrEmpty(_fileName) && new Ebu().IsMine(null, _fileName)) - { - properties.Initialize(header, Ebu.EbuUiHelper.JustificationCode, _fileName, _subtitle); - } - else - { - properties.Initialize(header, Ebu.EbuUiHelper.JustificationCode, null, _subtitle); - } - } - - if (properties.ShowDialog(this) == DialogResult.OK) - { - Ebu.EbuUiHelper.JustificationCode = properties.JustificationCode; - } - } - } - - private void ExportToEdlWithClipName(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.EdlClipName, _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - private void ExportToEdl(object sender, EventArgs e) - { - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.Edl, _fileName, _videoInfo, VideoFileName); - exportBdnXmlPng.ShowDialog(this); - } - } - - private void ToolStripMenuItemAddWaveformBatchClick(object sender, EventArgs e) - { - using (var form = new AddWaveformBatch()) - { - form.ShowDialog(this); - } - } - - private void DisplaySubtitleNotLoadedMessage() - { - MessageBox.Show(this, _language.NoSubtitleLoaded, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); - } - - private void toolStripMenuItemExportBdTextSt_Click(object sender, EventArgs e) - { - using (var form = new ExportTextST(_subtitle)) - { - form.ShowDialog(this); - } - } - - private void ChooseProfile() - { - using (var form = new ProfileChoose(Configuration.Settings.General.Profiles, Configuration.Settings.General.CurrentProfile)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - SubtitleListview1.BeginUpdate(); - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, i, _subtitle.Paragraphs[i]); - } - - SubtitleListview1.EndUpdate(); - if (_subtitleListViewIndex >= 0) - { - UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, _subtitle.Paragraphs[_subtitleListViewIndex], textBoxListViewText); - } - - ShowLineInformationListView(); - ShowSourceLineNumber(); - } - } - } - - private void DuplicateLine() - { - if (SubtitleListview1.SelectedItems.Count != 1) - { - return; - } - - var firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; - MakeHistoryForUndo(_language.BeforeInsertLine); - var newParagraph = new Paragraph(); - SetStyleForNewParagraph(newParagraph, firstSelectedIndex); - var cur = _subtitle.GetParagraphOrDefault(firstSelectedIndex); - newParagraph.StartTime.TotalMilliseconds = cur.StartTime.TotalMilliseconds; - newParagraph.EndTime.TotalMilliseconds = cur.EndTime.TotalMilliseconds; - newParagraph.Text = cur.Text; - - if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) - { - var currentOriginal = Utilities.GetOriginalParagraph(firstSelectedIndex, _subtitle.Paragraphs[firstSelectedIndex], _subtitleAlternate.Paragraphs); - if (currentOriginal != null) - { - _subtitleAlternate.Paragraphs.Insert(_subtitleAlternate.Paragraphs.IndexOf(currentOriginal) + 1, new Paragraph(currentOriginal)); - } - else - { - _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph)); - } - _subtitleAlternate.Renumber(); - } - - if (_networkSession != null) - { - _networkSession.TimerStop(); - NetworkGetSendUpdates(new List(), firstSelectedIndex, newParagraph); - } - else - { - _subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph); - _subtitle.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - } - - SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); - ShowSource(); - ShowStatus(_language.LineInserted); - } - - private void toolStripSelected_Click(object sender, EventArgs e) - { - if (!ShowProfileInStatusBar) - { - labelStatus_Click(sender, e); - return; - } - - var x = statusStrip1.PointToClient(Cursor.Position).X; - var textWidth = TextRenderer.MeasureText(toolStripSelected.Text, toolStripSelected.Font).Width; - if (toolStripStatusLabelProgress.Visible) - { - textWidth += toolStripStatusLabelProgress.Width + 5; - } - - var min = statusStrip1.Width - textWidth - 20; - var max = min + TextRenderer.MeasureText(Configuration.Settings.General.CurrentProfile, toolStripSelected.Font).Width + 10; - if (x >= min && x <= max) - { - ChooseProfile(); // profile name in status bar clicked - } - else - { - labelStatus_Click(sender, e); - } - } - - private void contextMenuStripWaveform_Closing(object sender, ToolStripDropDownClosingEventArgs e) - { - _lastWaveformMenuCloseTicks = DateTime.UtcNow.Ticks; - } - - private void MenuOpened(object sender, EventArgs e) - { - IsMenuOpen = true; - } - - private void MenuClosed(object sender, ToolStripDropDownClosedEventArgs e) - { - IsMenuOpen = false; - } - - private void MenuClosed(object sender, EventArgs e) - { - IsMenuOpen = false; - } - - private void UpdateNetflixGlyphCheckToolsVisibility() - { - bool showTools = IsNetflixGlyphCheckAvailable(); - toolStripButtonNetflixQualityCheck.Visible = showTools && Configuration.Settings.General.ShowToolbarNetflixGlyphCheck; - } - - private bool IsNetflixGlyphCheckAvailable() - { - var formatType = GetCurrentSubtitleFormat().GetType(); - return formatType == typeof(TimedText10) || formatType == typeof(NetflixTimedText) || formatType == typeof(NetflixImsc11Japanese) || formatType == typeof(Ebu); - } - - private void NetflixGlyphCheck(bool isSaving) - { - ReloadFromSourceView(); - - string fileName = string.IsNullOrEmpty(_fileName) ? "UntitledSubtitle" : Path.GetFileNameWithoutExtension(_fileName); - string language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); - - var netflixController = new NetflixQualityController { Language = language, VideoFileName = VideoFileName }; - if (!string.IsNullOrEmpty(VideoFileName) && _videoInfo != null && _videoInfo.FramesPerSecond > 20) - { - netflixController.FrameRate = _videoInfo.FramesPerSecond; - } - else if (!string.IsNullOrEmpty(VideoFileName) && CurrentFrameRate != 23.976 && CurrentFrameRate != 24) - { - netflixController.FrameRate = CurrentFrameRate; - } - - netflixController.RunChecks(_subtitle); - - if (netflixController.Records.Count > 0) - { - string reportPath = Path.GetTempPath() + fileName + "_NetflixQualityCheck.csv"; - netflixController.SaveCsv(reportPath); - if (!isSaving) - { - using (var form = new NetflixFixErrors(_subtitle, GetCurrentSubtitleFormat(), _fileName, VideoFileName)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - // Do nothing for now - } - } - } - else - { - ShowStatus(string.Format(_language.SavedSubtitleX, _fileName) + " - " + - string.Format(Configuration.Settings.Language.NetflixQualityCheck.FoundXIssues, netflixController.Records.Count)); - } - } - else if (!isSaving) - { - MessageBox.Show("Netflix Quality Check found no issues.", "Netflix Quality Check"); - } - } - - private void netflixGlyphCheckToolStripMenuItem_Click(object sender, EventArgs e) - { - NetflixGlyphCheck(false); - } - - private void toolStripButtonNetflixGlyphCheck_Click(object sender, EventArgs e) - { - NetflixGlyphCheck(false); - } - - private void insertSubtitleHereToolStripMenuItem_Click(object sender, EventArgs e) - { - openFileDialog1.Title = _languageGeneral.OpenSubtitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK && File.Exists(openFileDialog1.FileName)) - { - var fi = new FileInfo(openFileDialog1.FileName); - if (fi.Length > 1024 * 1024 * 10) // max 10 mb - { - var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, openFileDialog1.FileName); - if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return; - } - } - - var subtitle = new Subtitle(); - SubtitleFormat format = subtitle.LoadSubtitle(openFileDialog1.FileName, out var encoding, null); - if (format != null && subtitle.Paragraphs.Count > 0) - { - SaveSubtitleListviewIndices(); - - if (Configuration.Settings.General.RemoveBlankLinesWhenOpening) - { - subtitle.RemoveEmptyLines(); - } - - var adjustment = mediaPlayer.CurrentPosition - subtitle.Paragraphs[0].StartTime.TotalSeconds; - if (adjustment < 0) - { - adjustment = 0; - } - - foreach (Paragraph newP in subtitle.Paragraphs) - { - newP.Adjust(1.0d, adjustment); - if (_subtitle.Paragraphs.Any(p => newP.StartTime.TotalMilliseconds >= p.StartTime.TotalMilliseconds && - newP.StartTime.TotalMilliseconds <= p.EndTime.TotalMilliseconds || - newP.EndTime.TotalMilliseconds >= p.StartTime.TotalMilliseconds && - newP.EndTime.TotalMilliseconds <= p.EndTime.TotalMilliseconds)) - { - // new subs will overlap existing subs - if (MessageBox.Show(_language.PromptInsertSubtitleOverlap, _languageGeneral.Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) - { - return; - } - - break; - } - } - - MakeHistoryForUndo(string.Format(_language.BeforeInsertSubtitleAtVideoPosition, openFileDialog1.FileName)); - - foreach (var p in subtitle.Paragraphs) - { - _subtitle.InsertParagraphInCorrectTimeOrder(p); - } - - _subtitle.Renumber(); - ShowSource(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - RestoreSubtitleListviewIndices(); - } - } - } - - private void actorToolStripMenuItemClick(object sender, EventArgs e) - { - SortSubtitle(SubtitleSortCriteria.Actor, (sender as ToolStripItem).Text); - } - - private void toolStripMenuItemFcpXmlAdvanced_Click(object sender, EventArgs e) - { - using (var dialog = new ExportFcpXmlAdvanced(_subtitle, VideoFileName)) - { - dialog.ShowDialog(this); - } - } - - private void toolStripMenuItemOpenVideoFromUrl_Click(object sender, EventArgs e) - { - using (var form = new TextPrompt(Configuration.Settings.Language.Main.OpenVideoFile, "Url")) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - string url = form.InputText; - if (!string.IsNullOrEmpty(url)) - { - if (audioVisualizer.WavePeaks != null) - { - audioVisualizer.WavePeaks = null; - audioVisualizer.SetSpectrogram(null); - audioVisualizer.SceneChanges = new List(); - audioVisualizer.Chapters = new List(); - } - - if (!panelVideoPlayer.Visible) - { - toolStripButtonToggleVideo_Click(null, null); - } - - ShowSubtitleTimer.Stop(); - Cursor = Cursors.WaitCursor; - VideoFileName = url; - if (mediaPlayer.VideoPlayer != null) - { - mediaPlayer.PauseAndDisposePlayer(); - } - - _endSeconds = -1; - UiUtil.InitializeVideoPlayerAndContainer(url, _videoInfo, mediaPlayer, VideoLoaded, VideoEnded); - mediaPlayer.Volume = 0; - mediaPlayer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton; - mediaPlayer.OnButtonClicked -= MediaPlayer_OnButtonClicked; - mediaPlayer.OnButtonClicked += MediaPlayer_OnButtonClicked; - labelVideoInfo.Text = url; - Cursor = Cursors.Default; - SetUndockedWindowsTitle(); - ShowSubtitleTimer.Start(); - } - } - } - } - - private void SmpteTimeModedropFrameToolStripMenuItem_Click(object sender, EventArgs e) - { - smpteTimeModedropFrameToolStripMenuItem.Checked = !smpteTimeModedropFrameToolStripMenuItem.Checked; - mediaPlayer.SmpteMode = smpteTimeModedropFrameToolStripMenuItem.Checked; - } - - private void moveTextUpToolStripMenuItem_Click(object sender, EventArgs e) - { - var indices = SubtitleListview1.SelectedIndices.OfType().OrderBy(p => p).ToList(); - if (indices.Count == 0 || indices[0] - 1 < 0) - { - return; - } - - MakeHistoryForUndo(string.Format(_language.BeforeX, _language.Menu.ContextMenu.ColumnTextUp)); - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - SubtitleListview1.BeginUpdate(); - foreach (int index in indices) - { - if (index - 1 >= 0) - { - var p = _subtitle.Paragraphs[index]; - var prev = _subtitle.Paragraphs[index - 1]; - var prevText = prev.Text; - prev.Text = p.Text; - p.Text = prevText; - SubtitleListview1.Items[index - 1].Selected = true; - SubtitleListview1.Items[index].Selected = false; - SubtitleListview1.SetText(index - 1, prev.Text); - SubtitleListview1.SetText(index, p.Text); - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index - 1, prev); - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, p); - } - } - - SubtitleListview1.EndUpdate(); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - SubtitleListview1.EnsureVisible(FirstSelectedIndex); - _subtitleListViewIndex = -1; - SubtitleListview1_SelectedIndexChanged(null, null); - } - - private void moveTextDownToolStripMenuItem_Click(object sender, EventArgs e) - { - var indices = SubtitleListview1.SelectedIndices.OfType().OrderByDescending(p => p).ToList(); - if (indices.Count == 0 || indices[0] + 1 >= _subtitle.Paragraphs.Count) - { - return; - } - - MakeHistoryForUndo(string.Format(_language.BeforeX, _language.Menu.ContextMenu.ColumnTextDown)); - SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; - SubtitleListview1.BeginUpdate(); - foreach (int index in indices) - { - if (index + 1 < _subtitle.Paragraphs.Count) - { - var p = _subtitle.Paragraphs[index]; - var next = _subtitle.Paragraphs[index + 1]; - var nextText = next.Text; - next.Text = p.Text; - p.Text = nextText; - SubtitleListview1.Items[index + 1].Selected = true; - SubtitleListview1.Items[index].Selected = false; - SubtitleListview1.SetText(index, p.Text); - SubtitleListview1.SetText(index + 1, next.Text); - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, p); - SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index + 1, next); - } - } - - SubtitleListview1.EndUpdate(); - SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; - SubtitleListview1.EnsureVisible(FirstSelectedIndex); - SubtitleListview1.EnsureVisible(indices[0]); - _subtitleListViewIndex = -1; - SubtitleListview1_SelectedIndexChanged(null, null); - } - - private void generateTextFromCurrentVideoToolStripMenuItem_Click(object sender, EventArgs e) - { - using (var form = new AudioToText(VideoFileName, _videoInfo)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - _subtitle.Paragraphs.Clear(); - _subtitle.Paragraphs.AddRange(form.Subtitle.Paragraphs); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - if (_subtitle.Paragraphs.Count > 1) - { - ToolStripMenuItemAutoMergeShortLinesClick(sender, e); - } - } - } - } - - private void toolStripMenuDvdStudioProperties_Click(object sender, EventArgs e) - { - using (var form = new DvdStudioProProperties()) - { - form.ShowDialog(this); - } - } - - private void boxToolStripMenuItem_Click(object sender, EventArgs e) - { - ListViewToggleTag("box"); - } - - private void ShowHideBookmark(Paragraph p) - { - if (!string.IsNullOrWhiteSpace(p.Bookmark)) - { - pictureBoxBookmark.Show(); - if (_showBookmarkLabel) - { - panelBookmark.Show(); - using (var graphics = CreateGraphics()) - { - var textSize = graphics.MeasureString(p.Bookmark, Font); - labelBookmark.Text = p.Bookmark; - panelBookmark.Left = pictureBoxBookmark.Left; - panelBookmark.Top = pictureBoxBookmark.Top + pictureBoxBookmark.Height + 9; - panelBookmark.Width = (int)textSize.Width + 20; - panelBookmark.Height = (int)textSize.Height + 20; - panelBookmark.Show(); - } - } - else - { - panelBookmark.Hide(); - } - } - else if (p.Bookmark != null) - { - pictureBoxBookmark.Show(); - panelBookmark.Hide(); - } - else if (panelBookmark.Visible || pictureBoxBookmark.Visible) - { - panelBookmark.Hide(); - pictureBoxBookmark.Hide(); - } - } - - private void pictureBoxBookmark_MouseClick(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Left) - { - if (panelBookmark.Visible) - { - panelBookmark.Hide(); - _showBookmarkLabel = false; - } - else - { - _showBookmarkLabel = true; - var p = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex); - if (p != null) - { - ShowHideBookmark(p); - } - } - } - } - - private void pictureBoxBookmark_MouseEnter(object sender, EventArgs e) - { - if (_bookmarkContextMenu != null) - { - return; - } - - _bookmarkContextMenu = new ContextMenu(); - - // edit bookmark - var menuItem = new MenuItem(Configuration.Settings.Language.Main.Menu.ContextMenu.EditBookmark); - menuItem.Click += (sender2, e2) => { labelBookmark_DoubleClick(null, null); }; - _bookmarkContextMenu.MenuItems.Add(menuItem); - - // remove bookmark - menuItem = new MenuItem(Configuration.Settings.Language.Main.Menu.ContextMenu.RemoveBookmark); - menuItem.Click += (sender2, e2) => - { - var p2 = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex); - if (p2 != null) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Main.Menu.ContextMenu.RemoveBookmark)); - p2.Bookmark = null; - SubtitleListview1.ShowState(_subtitleListViewIndex, p2); - ShowHideBookmark(p2); - SetListViewStateImages(); - new BookmarkPersistence(_subtitle, _fileName).Save(); - } - }; - _bookmarkContextMenu.MenuItems.Add(menuItem); - - _bookmarkContextMenu.MenuItems.Add("-"); - - // go to bookmark - menuItem = new MenuItem(Configuration.Settings.Language.Settings.GoToBookmark); - menuItem.Click += (sender2, e2) => { GoToBookmark(); }; - _bookmarkContextMenu.MenuItems.Add(menuItem); - - // clear all bookmarks - menuItem = new MenuItem(Configuration.Settings.Language.Settings.ClearBookmarks); - menuItem.Click += (sender2, e2) => { ClearBookmarks(); }; - _bookmarkContextMenu.MenuItems.Add(menuItem); - - pictureBoxBookmark.ContextMenu = _bookmarkContextMenu; - } - - private void labelBookmark_DoubleClick(object sender, EventArgs e) - { - var p1 = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex); - if (p1 != null) - { - using (var form = new BookmarkAdd(p1)) - { - var result = form.ShowDialog(this); - if (result == DialogResult.OK) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Main.Menu.ContextMenu.EditBookmark)); - p1.Bookmark = form.Comment; - SubtitleListview1.ShowState(_subtitleListViewIndex, p1); - ShowHideBookmark(p1); - SetListViewStateImages(); - new BookmarkPersistence(_subtitle, _fileName).Save(); - } - } - } - } - - private void googleTranslateToolStripMenuItem_Click(object sender, EventArgs e) - { - TranslateViaGoogle(true, true); - } - - private void microsoftBingTranslateToolStripMenuItem_Click(object sender, EventArgs e) - { - TranslateViaGoogle(true, false); - } - - private void toolStripMenuItemBookmark_Click(object sender, EventArgs e) - { - ToggleBookmarks(true); - } - - private void RunActionOnAllParagraphs(Func action, string historyMessage) - { - if (_subtitle.Paragraphs.Count <= 0 || SubtitleListview1.SelectedItems.Count <= 0) - { - return; - } - - int linesUpdated = 0; - var selectedIndices = SubtitleListview1.GetSelectedIndices(); - for (int i = selectedIndices.Length - 1; i >= 0; i--) - { - int idx = selectedIndices[i]; - var p = _subtitle.GetParagraphOrDefault(idx); - if (p != null) - { - var newText = action.Invoke(p); - if (newText != p.Text) - { - if (linesUpdated == 0) - { - MakeHistoryForUndo(historyMessage); - } - if (newText.IsOnlyControlCharactersOrWhiteSpace()) - { - _subtitle.Paragraphs.RemoveAt(idx); - } - else - { - p.Text = newText; - } - linesUpdated++; - } - - if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) - { - var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); - if (original != null) - { - newText = action.Invoke(original); - if (newText != original.Text) - { - if (linesUpdated == 0) - { - MakeHistoryForUndo(historyMessage); - } - if (newText.IsOnlyControlCharactersOrWhiteSpace()) - { - _subtitleAlternate.Paragraphs.RemoveAt(idx); - } - else - { - original.Text = newText; - } - linesUpdated++; - } - } - } - } - } - - if (linesUpdated == 0) - { - return; // nothing changed - } - - var firstIdx = FirstSelectedIndex; - _subtitle.Renumber(); - _subtitleAlternate?.Renumber(); - SubtitleListview1.Fill(_subtitle, _subtitleAlternate); - ShowSource(); - SubtitleListview1.SelectIndexAndEnsureVisibleFaster(firstIdx); - RefreshSelectedParagraph(); - ShowStatus(string.Format(_language.LinesUpdatedX, linesUpdated)); - } - - private void removeAllFormattingsToolStripMenuItem_Click(object sender, EventArgs e) - { - RunActionOnAllParagraphs((p) => - { - var s = p.Text.Replace("♪", string.Empty).Replace("♫", string.Empty); - s = NetflixImsc11Japanese.RemoveTags(s); - return HtmlUtil.RemoveHtmlTags(s, true).Trim(); - }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingAll)); - } - - private void removeBoldToolStripMenuItem_Click(object sender, EventArgs e) - { - RunActionOnAllParagraphs((p) => - { - return p.Text.Replace("", string.Empty) - .Replace("", string.Empty) - .Replace("", string.Empty) - .Replace("", string.Empty); - }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingBold)); - } - - private void removeItalicToolStripMenuItem_Click(object sender, EventArgs e) - { - RunActionOnAllParagraphs((p) => - { - return p.Text.Replace("", string.Empty) - .Replace("", string.Empty) - .Replace("", string.Empty) - .Replace("", string.Empty); - }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingItalic)); - } - - private void removeUnderlineToolStripMenuItem_Click(object sender, EventArgs e) - { - RunActionOnAllParagraphs((p) => - { - return p.Text.Replace("", string.Empty) - .Replace("", string.Empty) - .Replace("", string.Empty) - .Replace("", string.Empty); - }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingUnderline)); - } - - private void removeColorToolStripMenuItem_Click(object sender, EventArgs e) - { - RunActionOnAllParagraphs((p) => - { - if (!p.Text.Contains(" 4) - { - var font = s.Substring(match.Index - 5); - if (font.StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - s = s.Remove(match.Index - 5, 7); - var endIndex = s.IndexOf("", match.Index - 5, StringComparison.OrdinalIgnoreCase); - if (endIndex >= 0) - { - s = s.Remove(endIndex, 7); - } - } - else if (s.Length > match.Index + 1 && s[match.Index + 1] == '>') - { - s = s.Remove(match.Index, 1); - } - } - - match = r.Match(s); - } - - return s.Trim(); - }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingColor)); - } - - private void removeFontNameToolStripMenuItem_Click(object sender, EventArgs e) - { - RunActionOnAllParagraphs((p) => - { - if (!p.Text.Contains(" 4) - { - var font = s.Substring(match.Index - 5); - if (font.StartsWith("", StringComparison.OrdinalIgnoreCase)) - { - s = s.Remove(match.Index - 5, 7); - var endIndex = s.IndexOf("", match.Index - 5, StringComparison.OrdinalIgnoreCase); - if (endIndex >= 0) - { - s = s.Remove(endIndex, 7); - } - } - else if (s.Length > match.Index + 1 && s[match.Index + 1] == '>') - { - s = s.Remove(match.Index, 1); - } - } - - match = r.Match(s); - } - - return s; - }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingFontName)); - } - - private void removeAlignmentToolStripMenuItem_Click(object sender, EventArgs e) - { - RunActionOnAllParagraphs((p) => - { - if (!p.Text.Contains('{')) - { - return p.Text; - } - - return RemoveAssAlignmentTags(p.Text); - }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingAlignment)); - } - - private void BoutenToolStripMenuItemClick(object sender, EventArgs e) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, (sender as ToolStripMenuItem).Text)); - TextBoxListViewToggleTag((sender as ToolStripMenuItem).Text); - } - - private void toolStripMenuItemHorizontalDigits_Click(object sender, EventArgs e) - { - MakeHistoryForUndo(string.Format(_language.BeforeX, "horizontalDigit")); - TextBoxListViewToggleTag("horizontalDigit"); - } - - private void toolStripMenuItemSetParagraphAsSelection_Click(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedItems.Count == 1 && audioVisualizer != null && audioVisualizer.NewSelectionParagraph != null) - { - var idx = SubtitleListview1.SelectedItems[0].Index; - var p = _subtitle.Paragraphs[idx]; - ButtonSetEndAndGoToNextClick(null, null); - p.StartTime.TotalMilliseconds = audioVisualizer.NewSelectionParagraph.StartTime.TotalMilliseconds; - p.EndTime.TotalMilliseconds = audioVisualizer.NewSelectionParagraph.EndTime.TotalMilliseconds; - SubtitleListview1.SetStartTimeAndDuration(idx, p, _subtitle.GetParagraphOrDefault(idx - 1), _subtitle.GetParagraphOrDefault(idx + 1)); - mediaPlayer.CurrentPosition = audioVisualizer.NewSelectionParagraph.EndTime.TotalSeconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines / 1000.0; - audioVisualizer.NewSelectionParagraph = null; - } - } - - private void toolStripMenuItemRuby_Click(object sender, EventArgs e) - { - var tb = GetFocusedTextBox(); - string before = string.Empty; - string text = tb.SelectedText; - string after = string.Empty; - - int selectionStart = tb.SelectionStart; - if (selectionStart > 0) - { - before = tb.Text.Substring(0, selectionStart); - } - - if (tb.Text.Length > selectionStart + text.Length) - { - after = tb.Text.Remove(0, selectionStart + text.Length); - } - - if (text.StartsWith(' ')) - { - before += " "; - text = text.TrimStart(); - } - - if (text.EndsWith(' ')) - { - after = " " + after; - } - - using (var form = new RubyJapanese(before, text, after)) - { - if (form.ShowDialog(this) != DialogResult.OK) - { - return; - } - - var rubyText = form.RubyText; - if (form.RubyItalic) - { - rubyText = "" + rubyText + ""; - } - else - { - rubyText = "" + rubyText + ""; - } - var rubyHtml = before + "" + form.RubyBaseText + "" + rubyText + "" + after; // sami ruby tag fix - var formatType = GetCurrentSubtitleFormat().GetType(); - if (formatType == typeof(Sami)) // sami ruby tag fix - { - rubyHtml = rubyHtml.Replace("ruby-container", "ruby") - .Replace("ruby-text", "rt") - .Replace("", string.Empty) - .Replace("", string.Empty) // sami ruby tag fix rp remove - .Replace("", string.Empty) // sami ruby tag fix italic remove - .Replace("", string.Empty) - .Replace("", string.Empty) - .Replace("", string.Empty); - } - tb.Text = rubyHtml; - } - } - - private void toolStripMenuItemAutoTranslate_DropDownOpening(object sender, EventArgs e) - { - translatepoweredByMicrosoftToolStripMenuItem.Visible = - !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorApiKey) && - !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint); - } - - private void comboBoxSubtitleFormats_DropDownClosed(object sender, EventArgs e) - { - MenuClosed(sender, e); - if (_oldSubtitleFormat.FriendlyName != GetCurrentSubtitleFormat().FriendlyName) - { - ComboBoxSubtitleFormatsSelectedIndexChanged(sender, e); - } - } - - private void comboBoxSubtitleFormats_DropDown(object sender, EventArgs e) - { - _oldSubtitleFormat = GetCurrentSubtitleFormat(); - MenuOpened(sender, e); - } - - private void toolStripSplitButtonPlayRate_ButtonClick(object sender, EventArgs e) - { - toolStripSplitButtonPlayRate.ShowDropDown(); - } - - private void ShowButtonShortcut(string shortcut) - { - if (string.IsNullOrEmpty(shortcut)) - { - ShowStatus(string.Empty, false); - } - else - { - ShowStatus(string.Format(Configuration.Settings.Language.General.ShortcutX, shortcut), false); - } - } - - private void buttonSetStartAndOffsetRest_MouseEnter(object sender, EventArgs e) - { - if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest2)) - { - ShowButtonShortcut(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest2); - } - else - { - ShowButtonShortcut(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest); - } - } - - private void buttonSetEndAndGoToNext_MouseEnter(object sender, EventArgs e) - { - ShowButtonShortcut(Configuration.Settings.Shortcuts.MainAdjustSetEndAndGotoNext); - } - - private void buttonAdjustSetStartTime_MouseEnter(object sender, EventArgs e) - { - ShowButtonShortcut(Configuration.Settings.Shortcuts.MainCreateSetStart); - } - - private void buttonAdjustSetEndTime_MouseEnter(object sender, EventArgs e) - { - ShowButtonShortcut(Configuration.Settings.Shortcuts.MainCreateSetEnd); - } - - private void buttonInsertNewText_MouseEnter(object sender, EventArgs e) - { - ShowButtonShortcut(Configuration.Settings.Shortcuts.MainCreateInsertSubAtVideoPos); - } - - private void buttonAdjustPlayBefore_MouseEnter(object sender, EventArgs e) - { - ShowButtonShortcut(Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore); - } - - private void buttonAdjustGoToPosAndPause_MouseEnter(object sender, EventArgs e) - { - ShowButtonShortcut(Configuration.Settings.Shortcuts.MainVideoGoToStartCurrent); - } - - private void buttonBeforeText_MouseEnter(object sender, EventArgs e) - { - ShowButtonShortcut(Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore); - } - - private void buttonGotoSub_MouseEnter(object sender, EventArgs e) - { - ShowButtonShortcut(Configuration.Settings.Shortcuts.MainVideoGoToStartCurrent); - } - - private void buttonSetStartTime_MouseEnter(object sender, EventArgs e) - { - ShowButtonShortcut(Configuration.Settings.Shortcuts.MainCreateSetStart); - } - - private void buttonSetEnd_MouseEnter(object sender, EventArgs e) - { - ShowButtonShortcut(Configuration.Settings.Shortcuts.MainCreateSetEnd); - } - - private void boxToolStripMenuItem1_Click(object sender, EventArgs e) - { - var tb = GetFocusedTextBox(); - tb.Text = HtmlUtil.ToggleTag(tb.Text, "box"); - } - - private void toolStripMenuItemPreview_Click(object sender, EventArgs e) - { - var htmlFileName = Path.Combine(Path.GetTempPath(), $"WebVttPreview_{Guid.NewGuid()}.html"); - var subText = Encoding.UTF8.GetBytes(new WebVTT().ToText(_subtitle, "preview")); - File.WriteAllText(htmlFileName, @" - - - - WebVTT preview - - - - -" - .Replace('\'', '"') - .Replace("[BASE64]", Convert.ToBase64String(subText)) - .Replace("[VIDEO]", "file://" + VideoFileName) - .Replace("[EXT]", Path.GetExtension(VideoFileName).TrimStart('.').ToLowerInvariant()), Encoding.UTF8); - UiUtil.OpenFile(htmlFileName); - - System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(25000), () => - { - try - { - File.Delete(htmlFileName); - } - catch - { - // Ignore - } - }); - } - - private void trackBarWaveformPosition_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Space) - { - mediaPlayer.TogglePlayPause(); - e.SuppressKeyPress = true; - } - } - - private void toolStripMenuItemAssaStyles_Click(object sender, EventArgs e) - { - toolStripMenuItemAssStyles_Click(sender, e); - } - - private void openSecondSubtitleToolStripMenuItem_Click(object sender, EventArgs e) - { - openFileDialog1.Title = _languageGeneral.OpenSubtitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; - if (openFileDialog1.ShowDialog(this) != DialogResult.OK) - { - return; - } - - if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv) - { - if (Configuration.Settings.General.MpvHandlesPreviewText) - { - Configuration.Settings.General.MpvHandlesPreviewText = false; - mediaPlayer.VideoPlayer = libMpv; - mediaPlayer.SubtitleText = string.Empty; - } - libMpv.LoadSubtitle(openFileDialog1.FileName); - } - else if (mediaPlayer.VideoPlayer is LibVlcDynamic libvlc) - { - libvlc.LoadSecondSubtitle(openFileDialog1.FileName); - } - } - - private void aSSStylesToolStripMenuItem_Click(object sender, EventArgs e) - { - toolStripMenuItemAssStyles_Click(sender, e); - } - - private void contextMenuStripEmpty_Opening(object sender, CancelEventArgs e) - { - var format = GetCurrentSubtitleFormat(); - var formatType = format.GetType(); - if (formatType == typeof(AdvancedSubStationAlpha)) - { - aSSStylesToolStripMenuItem.Visible = true; - aSSStylesToolStripMenuItem.Text = _language.Menu.ContextMenu.AdvancedSubStationAlphaStyles; - } - else if (formatType == typeof(SubStationAlpha)) - { - aSSStylesToolStripMenuItem.Visible = true; - aSSStylesToolStripMenuItem.Text = _language.Menu.ContextMenu.SubStationAlphaStyles; - } - else - { - aSSStylesToolStripMenuItem.Visible = false; - } - } - - private void splitContainerListViewAndText_SplitterMoved(object sender, SplitterEventArgs e) - { - if (Configuration.Settings.General.SubtitleTextBoxMaxHeight < splitContainerListViewAndText.Panel2MinSize && - Configuration.Settings.General.SubtitleTextBoxMaxHeight > 1000) - { - return; - } - - if (splitContainerListViewAndText.Panel2.Height > Configuration.Settings.General.SubtitleTextBoxMaxHeight) - { - splitContainerListViewAndText.SplitterDistance = splitContainerListViewAndText.Height - Configuration.Settings.General.SubtitleTextBoxMaxHeight; - } - } - - private void splitContainerListViewAndText_SizeChanged(object sender, EventArgs e) - { - splitContainerListViewAndText_SplitterMoved(null, null); - } - } -} +using Nikse.SubtitleEdit.Controls; +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.BluRaySup; +using Nikse.SubtitleEdit.Core.ContainerFormats; +using Nikse.SubtitleEdit.Core.ContainerFormats.MaterialExchangeFormat; +using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; +using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4; +using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4.Boxes; +using Nikse.SubtitleEdit.Core.ContainerFormats.TransportStream; +using Nikse.SubtitleEdit.Core.Enums; +using Nikse.SubtitleEdit.Core.Forms; +using Nikse.SubtitleEdit.Core.NetflixQualityCheck; +using Nikse.SubtitleEdit.Core.SpellCheck; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Core.VobSub; +using Nikse.SubtitleEdit.Forms.Networking; +using Nikse.SubtitleEdit.Forms.Ocr; +using Nikse.SubtitleEdit.Forms.Styles; +using Nikse.SubtitleEdit.Logic; +using Nikse.SubtitleEdit.Logic.CommandLineConvert; +using Nikse.SubtitleEdit.Logic.Networking; +using Nikse.SubtitleEdit.Logic.VideoPlayers; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + + public sealed partial class Main : Form + { + private class ComboBoxZoomItem + { + public string Text { get; set; } + public double ZoomFactor { get; set; } + + public override string ToString() + { + return Text; + } + } + + private const int TabControlListView = 0; + private const int TabControlSourceView = 1; + + private Subtitle _subtitle = new Subtitle(); + + private int _undoIndex = -1; + private string _listViewTextUndoLast; + private int _listViewTextUndoIndex = -1; + private long _listViewTextTicks = -1; + private string _listViewAlternateTextUndoLast; + private long _listViewAlternateTextTicks = -1; + + private Subtitle _subtitleAlternate = new Subtitle(); + private string _subtitleAlternateFileName; + private string _fileName; + + private int _videoAudioTrackNumber = -1; + public int VideoAudioTrackNumber + { + get => _videoAudioTrackNumber; + set + { + if (_videoAudioTrackNumber != value) + { + if (value >= 0 && _videoAudioTrackNumber != -1) + { + ReloadWaveform(VideoFileName, value); + } + _videoAudioTrackNumber = value; + } + } + } + + public string VideoFileName { get; set; } + + private DateTime _fileDateTime; + private string _title; + private FindReplaceDialogHelper _findHelper; + private int _replaceStartLineIndex; + private bool _sourceViewChange; + private int _changeSubtitleHash = -1; + private int _changeAlternateSubtitleHash = -1; + private int _subtitleListViewIndex = -1; + private Paragraph _oldSelectedParagraph; + private bool _converted; + private SubtitleFormat _oldSubtitleFormat; + private List _selectedIndices; + private LanguageStructure.Main _language; + private LanguageStructure.General _languageGeneral; + private SpellCheck _spellCheckForm; + private bool _loading = true; + private bool _exitWhenLoaded; + private int _repeatCount = -1; + private double _endSeconds = -1; + private double _endSecondsNewPosition = -1; + private long _endSecondsNewPositionTicks; + private const double EndDelay = 0.05; + private int _autoContinueDelayCount = -1; + private long _lastTextKeyDownTicks; + private long _lastHistoryTicks; + private long _lastWaveformMenuCloseTicks; + private double? _audioWaveformRightClickSeconds; + private readonly Timer _timerDoSyntaxColoring = new Timer(); + private Timer _timerAutoBackup; + private readonly Timer _timerClearStatus = new Timer(); + private string _textAutoBackup; + private string _textAutoBackupOriginal; + private readonly List _statusLog = new List(); + private bool _disableShowStatus; + private StatusLog _statusLogForm; + private bool _makeHistoryPaused; + private bool _saveAsCalled; + + private CheckForUpdatesHelper _checkForUpdatesHelper; + private Timer _timerCheckForUpdates; + + private NikseWebServiceSession _networkSession; + private NetworkChat _networkChat; + + private ShowEarlierLater _showEarlierOrLater; + private MeasurementConverter _measurementConverter; + + private bool _isVideoControlsUndocked; + private VideoPlayerUndocked _videoPlayerUndocked; + private WaveformUndocked _waveformUndocked; + private VideoControlsUndocked _videoControlsUndocked; + + private GoogleOrMicrosoftTranslate _googleOrMicrosoftTranslate; + + private bool _cancelWordSpellCheck = true; + private bool _cleanupHasRun; + + private bool _clearLastFind; + private FindType _clearLastFindType = FindType.Normal; + private string _clearLastFindText = string.Empty; + private bool _videoLoadedGoToSubPosAndPause; + private string _cutText = string.Empty; + private Paragraph _mainCreateStartDownEndUpParagraph; + private Paragraph _mainAdjustStartDownEndUpAndGoToNextParagraph; + private int _lastDoNotPrompt = -1; + private VideoInfo _videoInfo; + private bool _splitDualSami; + private bool _openFileDialogOn; + private bool _resetVideo = true; + private bool _doAutoBreakOnTextChanged = true; + private readonly static object _syncUndo = new object(); + private string[] _dragAndDropFiles; + private readonly Timer _dragAndDropTimer = new Timer(); // to prevent locking windows explorer + private readonly Timer _dragAndDropVideoTimer = new Timer(); // to prevent locking windows explorer + private long _labelNextTicks = -1; + private bool _showBookmarkLabel = true; + private ContextMenu _bookmarkContextMenu; + private readonly MainShortcuts _shortcuts = new MainShortcuts(); + private long _winLeftDownTicks = -1; + private long _winRightDownTicks = -1; + + public bool IsMenuOpen { get; private set; } + + private bool AutoRepeatContinueOn + { + get { return tabControlButtons.SelectedIndex == 0 && checkBoxAutoContinue.Checked; } + } + + private bool AutoRepeatOn + { + get { return tabControlButtons.SelectedIndex == 0 && checkBoxAutoRepeatOn.Checked; } + } + + public string Title + { + get + { + if (_title == null) + { + var versionInfo = Utilities.AssemblyVersion.Split('.'); + _title = $"{_languageGeneral.Title} {versionInfo[0]}.{versionInfo[1]}.{versionInfo[2]}"; + } + + return _title; + } + } + + private void SetCurrentFormat(string formatName) + { + SetCurrentFormat(SubtitleFormat.FromName(formatName, new SubRip())); + } + + private void SetCurrentFormat(SubtitleFormat format) + { + if (format.IsVobSubIndexFile) + { + UiUtil.InitializeSubtitleFormatComboBox(comboBoxSubtitleFormats, format); + SubtitleListview1.HideNonVobSubColumns(); + } + else if (comboBoxSubtitleFormats.Items.Count == 1) + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); + SetFormatTo(format); + } + else + { + int index = 0; + foreach (string name in comboBoxSubtitleFormats.Items) + { + if (name == format.FriendlyName) + { + comboBoxSubtitleFormats.SelectedIndex = index; + return; + } + + index++; + } + } + } + + protected override void OnLoad(EventArgs e) + { + UiUtil.FixFonts(this, 10000); + UiUtil.FixFonts(contextMenuStripListview); + UiUtil.FixFonts(contextMenuStripTextBoxListView); + UiUtil.FixFonts(contextMenuStripWaveform); + UiUtil.FixLargeFonts(tabControlButtons, buttonAutoBreak); + UiUtil.FixLargeFonts(tabControlButtons, buttonAutoBreak); + UiUtil.FixLargeFonts(groupBoxEdit, buttonAutoBreak); + UiUtil.InitializeSubtitleFont(textBoxSource); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + + using (var graphics = CreateGraphics()) + { + // avoid weird looking layout for high DPI + if (graphics.DpiX > 120) + { + Font = new Font(Font.FontFamily, (float)(Font.Size * graphics.DpiX / 96.0)); + + numericUpDownDuration.Left = timeUpDownStartTime.Right + 15; + numericUpDownDuration.Width += 5; + labelDuration.Left = numericUpDownDuration.Left - 3; + } + var xDiff = timeUpDownStartTime.Top - (labelStartTime.Top + labelStartTime.Height); + if (xDiff < 0) // DPI auto-size fixes: see https://github.com/SubtitleEdit/subtitleedit/issues/3981 + { + xDiff *= -1; + timeUpDownStartTime.Top += xDiff; + numericUpDownDuration.Top += xDiff; + pictureBoxBookmark.Top += xDiff; + textBoxListViewText.Top += xDiff; + textBoxListViewText.Height -= xDiff; + textBoxListViewTextAlternate.Top += xDiff; + textBoxListViewTextAlternate.Height -= xDiff; + comboBoxAutoRepeat.Top += xDiff; + comboBoxAutoContinue.Top += xDiff; + } + } + labelAutoDuration.Left = labelDuration.Left - (labelAutoDuration.Width - 5); + + textBoxListViewText.BackColor = !IsSubtitleLoaded ? SystemColors.ActiveBorder : SystemColors.WindowFrame; + textBoxListViewTextAlternate.BackColor = !IsSubtitleLoaded ? SystemColors.ActiveBorder : SystemColors.WindowFrame; + + base.OnLoad(e); + } + + private static string GetArgumentAfterColon(IEnumerable commandLineArguments, string requestedArgumentName) + { + foreach (var argument in commandLineArguments) + { + if (argument.StartsWith(requestedArgumentName, StringComparison.OrdinalIgnoreCase)) + { + if (requestedArgumentName.EndsWith(':')) + { + return argument.Substring(requestedArgumentName.Length); + } + + return argument; + } + } + + return null; + } + + public Main() + { + if (Configuration.IsRunningOnLinux) + { + NativeMethods.setlocale(NativeMethods.LC_NUMERIC, "C"); + } + + try + { + UiUtil.PreInitialize(this); + InitializeComponent(); + + Icon = Properties.Resources.SubtitleEditFormIcon; + + textBoxListViewTextAlternate.Visible = false; + labelAlternateText.Visible = false; + labelAlternateCharactersPerSecond.Visible = false; + labelTextAlternateLineLengths.Visible = false; + labelAlternateSingleLine.Visible = false; + labelAlternateSingleLinePixels.Visible = false; + labelTextAlternateLineTotal.Visible = false; + labelNextWord.Visible = false; + + SetLanguage(Configuration.Settings.General.Language); + toolStripStatusNetworking.Visible = false; + labelTextLineLengths.Text = string.Empty; + labelCharactersPerSecond.Text = string.Empty; + labelTextLineTotal.Text = string.Empty; + labelStartTimeWarning.Text = string.Empty; + labelDurationWarning.Text = string.Empty; + labelVideoInfo.Text = string.Empty; + labelSingleLine.Text = string.Empty; + labelSingleLinePixels.Text = string.Empty; + Text = Title; + timeUpDownStartTime.TimeCode = new TimeCode(); + timeUpDownStartTime.UseVideoOffset = true; + timeUpDownVideoPosition.UseVideoOffset = true; + timeUpDownVideoPositionAdjust.UseVideoOffset = true; + checkBoxAutoRepeatOn.Checked = Configuration.Settings.General.AutoRepeatOn; + comboBoxAutoRepeat.SelectedIndex = Configuration.Settings.General.AutoRepeatCount; + checkBoxAutoContinue.Checked = Configuration.Settings.General.AutoContinueOn; + checkBoxSyncListViewWithVideoWhilePlaying.Checked = Configuration.Settings.General.SyncListViewWithVideoWhilePlaying; + + SetFormatTo(Configuration.Settings.General.DefaultSubtitleFormat); + + UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding.ComboBox); + + // set up UI interfaces / injections + YouTubeAnnotations.GetYouTubeAnnotationStyles = new UiGetYouTubeAnnotationStyles(); + Ebu.EbuUiHelper = new UiEbuSaveHelper(); + Pac.GetPacEncodingImplementation = new UiGetPacEncoding(this); + RichTextToPlainText.NativeRtfTextConverter = new RtfTextConverterRichTextBox(); + + toolStripComboBoxFrameRate.Items.Add(23.976.ToString(CultureInfo.CurrentCulture)); + toolStripComboBoxFrameRate.Items.Add(24.0.ToString(CultureInfo.CurrentCulture)); + toolStripComboBoxFrameRate.Items.Add(25.0.ToString(CultureInfo.CurrentCulture)); + toolStripComboBoxFrameRate.Items.Add(29.97.ToString(CultureInfo.CurrentCulture)); + toolStripComboBoxFrameRate.Items.Add(30.ToString(CultureInfo.CurrentCulture)); + toolStripComboBoxFrameRate.Text = Configuration.Settings.General.DefaultFrameRate.ToString(); + pictureBoxBookmark.Visible = false; + + UpdateRecentFilesUI(); + InitializeToolbar(); + UpdateNetflixGlyphCheckToolsVisibility(); + Utilities.SetSecurityProtocol(); // download from Github requires TLS 1.2 + + tabControlSubtitle.SelectTab(TabControlSourceView); // AC + ShowSourceLineNumber(); // AC + tabControlSubtitle.SelectTab(TabControlListView); // AC + if (Configuration.Settings.General.StartInSourceView) + { + tabControlSubtitle.SelectTab(TabControlSourceView); + } + + audioVisualizer.Visible = Configuration.Settings.General.ShowAudioVisualizer; + audioVisualizer.ShowWaveform = Configuration.Settings.General.ShowWaveform; + audioVisualizer.ShowSpectrogram = Configuration.Settings.General.ShowSpectrogram; + panelWaveformControls.Visible = Configuration.Settings.General.ShowAudioVisualizer; + trackBarWaveformPosition.Visible = Configuration.Settings.General.ShowAudioVisualizer; + toolStripButtonToggleWaveform.Checked = Configuration.Settings.General.ShowAudioVisualizer; + toolStripButtonToggleVideo.Checked = Configuration.Settings.General.ShowVideoPlayer; + + if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) + { + numericUpDownDuration.DecimalPlaces = 2; + numericUpDownDuration.Increment = (decimal)(0.01); + toolStripSeparatorFrameRate.Visible = true; + toolStripLabelFrameRate.Visible = true; + toolStripComboBoxFrameRate.Visible = true; + toolStripButtonGetFrameRate.Visible = true; + } + + _timerClearStatus.Interval = Configuration.Settings.General.ClearStatusBarAfterSeconds * 1000; + _timerClearStatus.Tick += TimerClearStatus_Tick; + + var commandLineArgs = Environment.GetCommandLineArgs(); + var fileName = string.Empty; + int srcLineNumber = -1; + if (commandLineArgs.Length > 1) + { + // ConvertOrReturn() shall not return if a command line conversion has been requested + CommandLineConverter.ConvertOrReturn(Title, commandLineArgs); + + fileName = commandLineArgs[1]; + + if (fileName.Equals("/batchconvertui", StringComparison.OrdinalIgnoreCase) || fileName.Equals("-batchconvertui", StringComparison.OrdinalIgnoreCase)) + { + new BatchConvert(this.Icon).ShowDialog(); + Environment.Exit(0); + } + + var sourceLineString = GetArgumentAfterColon(commandLineArgs, "/srcline:"); + if (!int.TryParse(sourceLineString, out srcLineNumber)) + { + srcLineNumber = -1; + } + + VideoFileName = GetArgumentAfterColon(commandLineArgs, "/video:"); + } + + labelAutoDuration.Visible = false; + mediaPlayer.SubtitleText = string.Empty; + comboBoxAutoContinue.SelectedIndex = Configuration.Settings.General.AutoContinueDelay; + + timeUpDownVideoPosition.TimeCode = new TimeCode(); + timeUpDownVideoPositionAdjust.TimeCode = new TimeCode(); + timeUpDownVideoPosition.TimeCodeChanged += VideoPositionChanged; + timeUpDownVideoPositionAdjust.TimeCodeChanged += VideoPositionChanged; + timeUpDownVideoPosition.Enabled = false; + timeUpDownVideoPositionAdjust.Enabled = false; + + switch (Configuration.Settings.VideoControls.LastActiveTab) + { + case "Translate": + tabControlButtons.SelectedIndex = 0; + break; + case "Create": + tabControlButtons.SelectedIndex = 1; + break; + case "Adjust": + tabControlButtons.SelectedIndex = 2; + break; + } + + tabControl1_SelectedIndexChanged(null, null); + buttonCustomUrl1.Text = Configuration.Settings.VideoControls.CustomSearchText1; + buttonCustomUrl1.Visible = Configuration.Settings.VideoControls.CustomSearchUrl1.Length > 1; + buttonCustomUrl2.Text = Configuration.Settings.VideoControls.CustomSearchText2; + buttonCustomUrl2.Visible = Configuration.Settings.VideoControls.CustomSearchUrl2.Length > 1; + + CheckAndGetNewlyDownloadedMpvDlls(string.Empty); + + if (fileName.Length > 0 && File.Exists(fileName)) + { + fileName = Path.GetFullPath(fileName); + + if (srcLineNumber < 0) + { + if (!OpenFromRecentFiles(fileName)) + { + OpenSubtitle(fileName, null, VideoFileName, null, true); + } + } + else + { + OpenSubtitle(fileName, null, VideoFileName, null, true); + } + + if (srcLineNumber >= 0 && GetCurrentSubtitleFormat().GetType() == typeof(SubRip) && srcLineNumber < textBoxSource.Lines.Length) + { + int pos = 0; + for (int i = 0; i < srcLineNumber; i++) + { + pos += textBoxSource.Lines[i].Length; + } + + if (pos + 35 < textBoxSource.TextLength) + { + pos += 35; + } + + string s = textBoxSource.Text.Substring(0, pos); + int lastTimeCode = s.LastIndexOf(" --> ", StringComparison.Ordinal); // 00:02:26,407 --> 00:02:31,356 + if (lastTimeCode > 14 && lastTimeCode + 16 >= s.Length) + { + s = s.Substring(0, lastTimeCode - 5); + lastTimeCode = s.LastIndexOf(" --> ", StringComparison.Ordinal); + } + + if (lastTimeCode > 14 && lastTimeCode + 16 < s.Length) + { + string tc = s.Substring(lastTimeCode - 13, 30).Trim(); + int index = 0; + foreach (var p in _subtitle.Paragraphs) + { + if (tc == p.StartTime + " --> " + p.EndTime) + { + SubtitleListview1.SelectNone(); + SubtitleListview1.Items[0].Selected = false; + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + break; + } + + index++; + } + } + } + } + else if (Configuration.Settings.General.StartLoadLastFile && Configuration.Settings.RecentFiles.Files.Count > 0) + { + fileName = Configuration.Settings.RecentFiles.Files[0].FileName; + if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName) && !OpenFromRecentFiles(fileName)) + { + OpenSubtitle(fileName, null); + } + } + + // Initialize events etc. for audio waveform + audioVisualizer.OnDoubleClickNonParagraph += AudioWaveform_OnDoubleClickNonParagraph; + audioVisualizer.OnPositionSelected += AudioWaveform_OnPositionSelected; + audioVisualizer.OnTimeChanged += AudioWaveform_OnTimeChanged; // start and/or end position of paragraph changed + audioVisualizer.OnNewSelectionRightClicked += AudioWaveform_OnNewSelectionRightClicked; + audioVisualizer.OnParagraphRightClicked += AudioWaveform_OnParagraphRightClicked; + audioVisualizer.OnNonParagraphRightClicked += AudioWaveform_OnNonParagraphRightClicked; + audioVisualizer.OnSingleClick += AudioWaveform_OnSingleClick; + audioVisualizer.OnPause += AudioWaveform_OnPause; + audioVisualizer.OnTimeChangedAndOffsetRest += AudioWaveform_OnTimeChangedAndOffsetRest; + audioVisualizer.OnZoomedChanged += AudioWaveform_OnZoomedChanged; + audioVisualizer.InsertAtVideoPosition += audioVisualizer_InsertAtVideoPosition; + audioVisualizer.PasteAtVideoPosition += audioVisualizer_PasteAtVideoPosition; + audioVisualizer.KeyDown += AudioVisualizer_KeyDown; + SetAudioVisualizerSettings(); + if (Configuration.Settings.General.WaveformUpdateIntervalMs > 0 && Configuration.Settings.General.WaveformUpdateIntervalMs < 200) + { + timerWaveform.Interval = Configuration.Settings.General.WaveformUpdateIntervalMs; + } + + InitializeWaveformZoomDropdown(); + toolStripComboBoxWaveform.SelectedIndexChanged += toolStripComboBoxWaveform_SelectedIndexChanged; + + FixLargeFonts(); + + if (Configuration.Settings.General.RightToLeftMode) + { + ToolStripMenuItemRightToLeftModeClick(null, null); + } + + timeUpDownStartTime.SetAutoWidth(); + numericUpDownDuration.Left = timeUpDownStartTime.Right + 4; + labelDurationWarning.Left = numericUpDownDuration.Left; + labelDuration.Left = labelDurationWarning.Left; + + timeUpDownVideoPosition.SetAutoWidth(); + timeUpDownVideoPositionAdjust.SetAutoWidth(); + } + catch (Exception exception) + { + Cursor = Cursors.Default; + MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace); + SeLogger.Error(exception, "Main constructor"); + } + } + + private void AudioVisualizer_KeyDown(object sender, KeyEventArgs e) + { + if (SubtitleListview1.SelectedIndices.Count != 1 || e.Handled) + { + return; + } + + if (e.KeyData == italicToolStripMenuItem.ShortcutKeys) + { + ListViewToggleTag(HtmlUtil.TagItalic); + e.SuppressKeyPress = true; + } + else if (e.KeyData == boldToolStripMenuItem.ShortcutKeys) + { + ListViewToggleTag(HtmlUtil.TagBold); + e.SuppressKeyPress = true; + } + else if (e.KeyData == underlineToolStripMenuItem.ShortcutKeys) + { + ListViewToggleTag(HtmlUtil.TagUnderline); + e.SuppressKeyPress = true; + } + + else if (e.KeyData == removeAllFormattingsToolStripMenuItem.ShortcutKeys) + { + removeAllFormattingsToolStripMenuItem_Click(null, null); + e.SuppressKeyPress = true; + } + + else if (e.KeyData == _shortcuts.MainListViewAlignmentN1) + { + SetAlignment("{\\an1}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN2) + { + SetAlignment("", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN3) + { + SetAlignment("{\\an3}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN4) + { + SetAlignment("{\\an4}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN5) + { + SetAlignment("{\\an5}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN6) + { + SetAlignment("{\\an6}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN7) + { + SetAlignment("{\\an7}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN8) + { + SetAlignment("{\\an8}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN9) + { + SetAlignment("{\\an9}", false); + e.SuppressKeyPress = true; + } + } + + private void InitializeWaveformZoomDropdown() + { + toolStripComboBoxWaveform.Items.Clear(); + for (double zoomCounter = AudioVisualizer.ZoomMinimum; zoomCounter <= AudioVisualizer.ZoomMaximum + (0.001); zoomCounter += 0.1) + { + int percent = (int)Math.Round(zoomCounter * 100); + var item = new ComboBoxZoomItem { Text = percent + "%", ZoomFactor = zoomCounter }; + toolStripComboBoxWaveform.Items.Add(item); + if (percent == 100) + { + toolStripComboBoxWaveform.SelectedIndex = toolStripComboBoxWaveform.Items.Count - 1; + } + } + } + + private void audioVisualizer_InsertAtVideoPosition(object sender, EventArgs e) + { + InsertNewTextAtVideoPosition(); + } + + private void audioVisualizer_PasteAtVideoPosition(object sender, EventArgs e) + { + double videoPositionInMilliseconds = mediaPlayer.CurrentPosition * TimeCode.BaseUnit; + if (_subtitle.GetFirstParagraphOrDefaultByTime(videoPositionInMilliseconds) == null) + { + PastFromClipboard(videoPositionInMilliseconds); + } + } + + private void PastFromClipboard(double videoPositionInMilliseconds) + { + if (Clipboard.ContainsText()) + { + var text = Clipboard.GetText(); + var tmp = new Subtitle(); + var format = new SubRip(); + var list = new List(text.SplitToLines()); + format.LoadSubtitle(tmp, list, null); + if (videoPositionInMilliseconds >= 0 && tmp.Paragraphs.Count > 0) + { + if (tmp.Paragraphs[0].StartTime.TotalMilliseconds > videoPositionInMilliseconds) + { + var c = tmp.Paragraphs[0].StartTime.TotalMilliseconds - videoPositionInMilliseconds; + tmp.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-c)); + } + else + { + var c = videoPositionInMilliseconds - tmp.Paragraphs[0].StartTime.TotalMilliseconds; + tmp.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(c)); + } + } + else + { + var start = videoPositionInMilliseconds; + foreach (var line in list) + { + if (!string.IsNullOrWhiteSpace(line)) + { + var duration = Utilities.GetOptimalDisplayMilliseconds(line); + tmp.Paragraphs.Add(new Paragraph(line.Trim(), start, start + duration)); + start += duration + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + + if (tmp.Paragraphs.Count > 0) + { + MakeHistoryForUndo(_language.BeforeInsertLine); + var selectIndices = new List(); + for (int i = 0; i < tmp.Paragraphs.Count; i++) + { + var p = tmp.Paragraphs[i]; + var idx = _subtitle.InsertParagraphInCorrectTimeOrder(p); + selectIndices.Add(idx); + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) + { + var original = Utilities.GetOriginalParagraph(idx + i + 1, p, _subtitleAlternate.Paragraphs); + if (original == null) + { + _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds)); + } + } + } + + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(selectIndices[0], true); + foreach (var selectIndex in selectIndices) + { + SubtitleListview1.Items[selectIndex].Selected = true; + } + + if (_subtitleListViewIndex >= 0) + { + UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, _subtitle.Paragraphs[_subtitleListViewIndex], textBoxListViewText); + } + else + { + SubtitleListview1.SelectIndexAndEnsureVisible(0); + } + } + } + } + + private void TimerClearStatus_Tick(object sender, EventArgs e) + { + ShowStatus(string.Empty); + } + + private void SetEncoding(Encoding encoding) + { + if (encoding == Encoding.UTF8 && Configuration.Settings.General.DefaultEncoding == TextEncoding.Utf8WithoutBom) + { + comboBoxEncoding.SelectedIndex = TextEncoding.Utf8WithoutBomIndex; + } + + foreach (TextEncoding item in comboBoxEncoding.Items) + { + if (item.Equals(encoding)) + { + comboBoxEncoding.SelectedItem = item; + return; + } + } + + comboBoxEncoding.SelectedIndex = TextEncoding.Utf8WithBomIndex; // UTF-8 with BOM + } + + private void SetEncoding(string encodingName) + { + UiUtil.SetTextEncoding(comboBoxEncoding, encodingName); + } + + private Encoding GetCurrentEncoding() + { + return UiUtil.GetTextEncodingComboBoxCurrentEncoding(comboBoxEncoding.ComboBox).Encoding; + } + + private void AudioWaveform_OnNonParagraphRightClicked(object sender, AudioVisualizer.ParagraphEventArgs e) + { + addParagraphHereToolStripMenuItem.Visible = false; + addParagraphAndPasteToolStripMenuItem.Visible = false; + toolStripMenuItemSetParagraphAsSelection.Visible = false; + deleteParagraphToolStripMenuItem.Visible = false; + toolStripMenuItemFocusTextbox.Visible = true; + splitToolStripMenuItem1.Visible = false; + mergeWithPreviousToolStripMenuItem.Visible = false; + mergeWithNextToolStripMenuItem.Visible = false; + toolStripSeparator11.Visible = false; + extendToPreviousToolStripMenuItem.Visible = false; + extendToNextToolStripMenuItem.Visible = false; + toolStripSeparator6.Visible = false; + toolStripMenuItemWaveformPlaySelection.Visible = false; + toolStripSeparator24.Visible = false; + if (audioVisualizer.GetSceneChangeIndex(e.Seconds) >= 0) + { + removeSceneChangeToolStripMenuItem.Visible = true; + addSceneChangeToolStripMenuItem.Visible = false; + } + else + { + removeSceneChangeToolStripMenuItem.Visible = false; + addSceneChangeToolStripMenuItem.Visible = true; + } + + _audioWaveformRightClickSeconds = e.Seconds; + contextMenuStripWaveform.Show(MousePosition.X, MousePosition.Y); + } + + private void AudioWaveform_OnDoubleClickNonParagraph(object sender, AudioVisualizer.ParagraphEventArgs e) + { + if (mediaPlayer.VideoPlayer != null) + { + _endSeconds = -1; + if (e.Paragraph == null) + { + if (Configuration.Settings.VideoControls.WaveformDoubleClickOnNonParagraphAction == "PlayPause") + { + mediaPlayer.TogglePlayPause(); + } + } + else + { + var index = _subtitle.GetIndex(e.Paragraph); + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + var p = _subtitle.GetParagraphOrDefault(index); + if (p != null) + { + string tc = p.StartTime + " --> " + p.EndTime; + int start = textBoxSource.Text.IndexOf(p.Number + Environment.NewLine + tc, StringComparison.Ordinal); + if (start < 0) + { + start = 0; + } + + start = textBoxSource.Text.IndexOf(tc, start, StringComparison.Ordinal); + if (start > 0) + { + textBoxSource.SelectionStart = start + tc.Length + Environment.NewLine.Length; + textBoxSource.SelectionLength = 0; + textBoxSource.ScrollToCaret(); + } + } + } + } + } + } + + private void AudioWaveform_OnZoomedChanged(object sender, EventArgs e) + { + SelectZoomTextInComboBox(); + } + + private void AudioWaveform_OnTimeChangedAndOffsetRest(object sender, AudioVisualizer.ParagraphEventArgs e) + { + if (mediaPlayer.VideoPlayer == null) + { + return; + } + + int index = _subtitle.Paragraphs.IndexOf(e.Paragraph); + if (index < 0) + { + if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable) + { + index = _subtitleAlternate.GetIndex(e.Paragraph); + if (index >= 0) + { + var current = Utilities.GetOriginalParagraph(index, e.Paragraph, _subtitle.Paragraphs); + if (current != null) + { + index = _subtitle.Paragraphs.IndexOf(current); + } + } + } + else if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible) + { + index = _subtitle.GetIndex(e.Paragraph); + } + } + + if (index >= 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + mediaPlayer.CurrentPosition = e.Seconds; + SetStartAndOffsetTheRest(e.Seconds); + } + + audioVisualizer.Invalidate(); + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + ShowSource(); + } + } + + private void AudioWaveform_OnPause(object sender, EventArgs e) + { + _endSeconds = -1; + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.Pause(); + } + } + + private void AudioWaveform_OnSingleClick(object sender, AudioVisualizer.ParagraphEventArgs e) + { + timerWaveform.Stop(); + _endSeconds = -1; + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.Pause(); + } + + mediaPlayer.CurrentPosition = e.Seconds; + + int index = -1; + if (SubtitleListview1.SelectedItems.Count > 0) + { + index = SubtitleListview1.SelectedItems[0].Index; + } + + SetWaveformPosition(audioVisualizer.StartPositionSeconds, e.Seconds, index); + + if (Configuration.Settings.VideoControls.WaveformSingleClickSelect && e.Paragraph != null) + { + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(e.Paragraph), true); + } + + timerWaveform.Start(); + } + + private void AudioWaveform_OnParagraphRightClicked(object sender, AudioVisualizer.ParagraphEventArgs e) + { + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(e.Paragraph), true); + + addParagraphHereToolStripMenuItem.Visible = false; + addParagraphAndPasteToolStripMenuItem.Visible = false; + toolStripMenuItemSetParagraphAsSelection.Visible = false; + deleteParagraphToolStripMenuItem.Visible = true; + toolStripMenuItemFocusTextbox.Visible = true; + splitToolStripMenuItem1.Visible = true; + mergeWithPreviousToolStripMenuItem.Visible = true; + mergeWithNextToolStripMenuItem.Visible = true; + toolStripSeparator11.Visible = true; + extendToPreviousToolStripMenuItem.Visible = true; + extendToNextToolStripMenuItem.Visible = true; + toolStripSeparator6.Visible = true; + toolStripMenuItemWaveformPlaySelection.Visible = true; + toolStripSeparator24.Visible = true; + if (audioVisualizer.GetSceneChangeIndex(e.Seconds) >= 0) + { + removeSceneChangeToolStripMenuItem.Visible = true; + addSceneChangeToolStripMenuItem.Visible = false; + } + else + { + removeSceneChangeToolStripMenuItem.Visible = false; + addSceneChangeToolStripMenuItem.Visible = true; + } + + _audioWaveformRightClickSeconds = e.Seconds; + contextMenuStripWaveform.Show(MousePosition.X, MousePosition.Y); + } + + private void removeSceneChangeToolStripMenuItem_Click(object sender, EventArgs e) + { + if (!_audioWaveformRightClickSeconds.HasValue) + { + return; + } + + var idx = audioVisualizer.GetSceneChangeIndex(_audioWaveformRightClickSeconds.Value); + RemoveSceneChange(idx); + } + + private void RemoveSceneChange(int idx) + { + if (idx >= 0 && idx < audioVisualizer.SceneChanges.Count) + { + var temp = new List(audioVisualizer.SceneChanges); + temp.RemoveAt(idx); + audioVisualizer.SceneChanges = temp; + SceneChangeHelper.SaveSceneChanges(VideoFileName, temp); + } + } + + private void addSceneChangeToolStripMenuItem_Click(object sender, EventArgs e) + { + if (!_audioWaveformRightClickSeconds.HasValue) + { + return; + } + + var list = audioVisualizer.SceneChanges.Where(p => p > 0).ToList(); + list.Add(_audioWaveformRightClickSeconds.Value); + list.Sort(); + audioVisualizer.SceneChanges = list; + SceneChangeHelper.SaveSceneChanges(VideoFileName, list); + } + + private void AudioWaveform_OnNewSelectionRightClicked(object sender, AudioVisualizer.ParagraphEventArgs e) + { + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(e.Paragraph), true); + + addParagraphHereToolStripMenuItem.Visible = true; + addParagraphAndPasteToolStripMenuItem.Visible = Clipboard.ContainsText(); + + if (SubtitleListview1.SelectedIndices.Count == 1) + { + var p = _subtitle.GetParagraphOrDefault(FirstSelectedIndex); + toolStripMenuItemSetParagraphAsSelection.Visible = p.StartTime.IsMaxTime; + } + + deleteParagraphToolStripMenuItem.Visible = false; + toolStripMenuItemFocusTextbox.Visible = false; + splitToolStripMenuItem1.Visible = false; + mergeWithPreviousToolStripMenuItem.Visible = false; + mergeWithNextToolStripMenuItem.Visible = false; + extendToPreviousToolStripMenuItem.Visible = false; + extendToNextToolStripMenuItem.Visible = false; + toolStripSeparator6.Visible = false; + + contextMenuStripWaveform.Show(MousePosition.X, MousePosition.Y); + } + + private void AudioWaveform_OnTimeChanged(object sender, AudioVisualizer.ParagraphEventArgs e) + { + var paragraph = e.Paragraph; + var beforeParagraph = e.BeforeParagraph; + if (beforeParagraph == null) + { + beforeParagraph = paragraph; + } + + if (Math.Abs(beforeParagraph.StartTime.TotalMilliseconds - paragraph.StartTime.TotalMilliseconds) < 0.01 && + Math.Abs(beforeParagraph.EndTime.TotalMilliseconds - paragraph.EndTime.TotalMilliseconds) < 0.01) + { + _makeHistoryPaused = true; + } + + int selectedIndex = FirstSelectedIndex; + int index = _subtitle.Paragraphs.IndexOf(paragraph); + + // TODO: Moving selected lines + // current idx must also be selected + //if (e.MouseDownParagraphType == AudioVisualizer.MouseDownParagraphType.Whole && SubtitleListview1.SelectedIndices.Count > 1) + //{ + // foreach (int idx in SubtitleListview1.SelectedIndices) + // { + // var p = _subtitle.Paragraphs[idx]; + // if (p != paragraph) + // { + // var dur = p.Duration.TotalMilliseconds; + // p.StartTime.TotalMilliseconds += e.AdjustMs; + // p.EndTime.TotalMilliseconds += e.AdjustMs; + // SubtitleListview1.SetStartTimeAndDuration(idx, p); + // } + // } + //} + + if (index == _subtitleListViewIndex) + { + // Make history item for rollback (change paragraph back for history + change again) + _subtitle.Paragraphs[index] = new Paragraph(beforeParagraph); + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + paragraph.Number + " " + paragraph.Text)); + _subtitle.Paragraphs[index] = paragraph; + _makeHistoryPaused = true; + + Paragraph original = null; + if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible) + { + original = Utilities.GetOriginalParagraph(index, beforeParagraph, _subtitleAlternate.Paragraphs); + } + + if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) + { // so we don't get weird rounds we'll use whole frames when moving start time + double fr = TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate; + if (e.BeforeParagraph != null && e.BeforeParagraph.StartTime.TotalMilliseconds != e.Paragraph.StartTime.TotalMilliseconds && + e.BeforeParagraph.Duration.TotalMilliseconds == e.Paragraph.Duration.TotalMilliseconds) + { + // move paragraph + paragraph.StartTime.TotalMilliseconds = ((int)Math.Round(paragraph.StartTime.TotalMilliseconds / fr)) * fr; + paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + e.BeforeParagraph.Duration.TotalMilliseconds; + } + else if (e.BeforeParagraph != null && e.BeforeParagraph.EndTime.TotalMilliseconds == e.Paragraph.EndTime.TotalMilliseconds) + { + paragraph.EndTime.TotalMilliseconds = ((int)Math.Round(paragraph.EndTime.TotalMilliseconds / fr)) * fr; + int end = SubtitleFormat.MillisecondsToFrames(paragraph.EndTime.TotalMilliseconds); + int dur = SubtitleFormat.MillisecondsToFrames(paragraph.Duration.TotalMilliseconds); + paragraph.StartTime.TotalMilliseconds = SubtitleFormat.FramesToMilliseconds(end - dur); + } + } + + timeUpDownStartTime.TimeCode = paragraph.StartTime; + var durationInSeconds = (decimal)paragraph.Duration.TotalSeconds; + if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum) + { + SetDurationInSeconds((double)durationInSeconds); + if (e.MouseDownParagraphType == AudioVisualizer.MouseDownParagraphType.Start) + { + paragraph.EndTime.TotalMilliseconds = e.BeforeParagraph.EndTime.TotalMilliseconds; + } + } + + MovePrevNext(e, beforeParagraph, index); + + if (original != null) + { + original.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; + original.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; + } + } + else if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable) + { + index = _subtitleAlternate.GetIndex(paragraph); + if (index >= 0) + { + // Make history item for rollback (change paragraph back for history + change again) + _subtitleAlternate.Paragraphs[index] = new Paragraph(beforeParagraph); + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + paragraph.Number + " " + paragraph.Text)); + _subtitleAlternate.Paragraphs[index] = paragraph; + _makeHistoryPaused = true; + + var current = Utilities.GetOriginalParagraph(index, beforeParagraph, _subtitle.Paragraphs); + if (current != null) + { + current.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; + current.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; + + index = _subtitle.GetIndex(current); + + SubtitleListview1.SetStartTimeAndDuration(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + + if (index == selectedIndex) + { + timeUpDownStartTime.TimeCode = paragraph.StartTime; + var durationInSeconds = (decimal)(paragraph.Duration.TotalSeconds); + if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum) + { + SetDurationInSeconds((double)durationInSeconds); + } + } + } + } + } + else if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible) + { + index = _subtitle.GetIndex(paragraph); + if (index >= 0) + { + // Make history item for rollback (change paragraph back for history + change again) + _subtitle.Paragraphs[index] = new Paragraph(beforeParagraph); + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + paragraph.Number + " " + paragraph.Text)); + _subtitle.Paragraphs[index] = paragraph; + _makeHistoryPaused = true; + + MovePrevNext(e, beforeParagraph, index); + + var original = Utilities.GetOriginalParagraph(index, beforeParagraph, _subtitleAlternate.Paragraphs); + if (original != null) + { + original.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; + original.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; + } + + SubtitleListview1.SetStartTimeAndDuration(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + } + } + else + { + if (index >= 0) + { + // Make history item for rollback (change paragraph back for history + change again) + _subtitle.Paragraphs[index] = new Paragraph(beforeParagraph); + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + paragraph.Number + " " + paragraph.Text)); + _subtitle.Paragraphs[index] = paragraph; + _makeHistoryPaused = true; + + MovePrevNext(e, beforeParagraph, index); + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, paragraph); + + if (_subtitleAlternate != null) + { + var original = Utilities.GetOriginalParagraph(index, beforeParagraph, _subtitleAlternate.Paragraphs); + if (original != null) + { + original.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; + original.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; + } + } + } + + SubtitleListview1.SetStartTimeAndDuration(index, paragraph, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + } + + beforeParagraph.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; + beforeParagraph.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; + _makeHistoryPaused = false; + + if (Configuration.Settings.VideoControls.WaveformSetVideoPositionOnMoveStartEnd && + (e.MouseDownParagraphType == AudioVisualizer.MouseDownParagraphType.Start || + e.MouseDownParagraphType == AudioVisualizer.MouseDownParagraphType.End)) + { + mediaPlayer.CurrentPosition = e.Seconds; + } + + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + ShowSource(); + } + } + + private void MovePrevNext(AudioVisualizer.ParagraphEventArgs e, Paragraph beforeParagraph, int index) + { + int curIdx = FirstSelectedIndex; + if (e.MovePreviousOrNext && curIdx >= 0) + { + if (e.MouseDownParagraphType == AudioVisualizer.MouseDownParagraphType.Start) + { + var prev = _subtitle.GetParagraphOrDefault(index - 1); + if (prev != null) + { + Paragraph originalPrev = null; + if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible) + { + originalPrev = Utilities.GetOriginalParagraph(index - 1, prev, _subtitleAlternate.Paragraphs); + } + + prev.EndTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + (e.Paragraph.StartTime.TotalMilliseconds - beforeParagraph.StartTime.TotalMilliseconds); + SubtitleListview1.SetStartTimeAndDuration(index - 1, prev, _subtitle.GetParagraphOrDefault(index), _subtitle.GetParagraphOrDefault(index - 2)); + audioVisualizer.Invalidate(); + + if (originalPrev != null) + { + originalPrev.EndTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds; + } + + if (curIdx == index - 1) + { + var durationInSeconds = (decimal)(prev.Duration.TotalSeconds); + if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum) + { + SetDurationInSeconds((double)durationInSeconds); + } + } + } + } + else if (e.MouseDownParagraphType == AudioVisualizer.MouseDownParagraphType.End) + { + var next = _subtitle.GetParagraphOrDefault(index + 1); + if (next != null) + { + Paragraph originalNext = null; + if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible) + { + originalNext = Utilities.GetOriginalParagraph(index + 1, next, _subtitleAlternate.Paragraphs); + } + + next.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds + (e.Paragraph.EndTime.TotalMilliseconds - beforeParagraph.EndTime.TotalMilliseconds); + SubtitleListview1.SetStartTimeAndDuration(index + 1, next, _subtitle.GetParagraphOrDefault(index + 2), _subtitle.GetParagraphOrDefault(index)); + audioVisualizer.Invalidate(); + + if (originalNext != null) + { + originalNext.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds; + } + + if (curIdx == index + 1) + { + timeUpDownStartTime.TimeCode = next.StartTime; + var durationInSeconds = (decimal)(next.Duration.TotalSeconds); + if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum) + { + SetDurationInSeconds((double)durationInSeconds); + } + } + } + } + } + } + + private void AudioWaveform_OnPositionSelected(object sender, AudioVisualizer.ParagraphEventArgs e) + { + mediaPlayer.CurrentPosition = e.Seconds; + if (e.Paragraph != null) + { + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(e.Paragraph), true); + } + } + + private void VideoPositionChanged(object sender, EventArgs e) + { + var tud = (TimeUpDown)sender; + if (tud.Enabled) + { + mediaPlayer.CurrentPosition = tud.TimeCode.TotalSeconds; + } + } + + private void Main_Load(object sender, EventArgs e) + { + splitContainer1.Panel1MinSize = 525; + splitContainer1.Panel2MinSize = 250; + splitContainerMain.Panel1MinSize = 200; + splitContainerMain.Panel2MinSize = 220; + + if (Configuration.Settings.General.StartRememberPositionAndSize && + !string.IsNullOrEmpty(Configuration.Settings.General.StartPosition)) + { + var parts = Configuration.Settings.General.StartPosition.Split(';'); + if (parts.Length == 2) + { + if (int.TryParse(parts[0], out var x) && int.TryParse(parts[1], out var y)) + { + if (x > -100 || y > -100) + { + Left = x; + Top = y; + } + } + } + + if (Configuration.Settings.General.StartSize == "Maximized") + { + CenterFormOnCurrentScreen(); + WindowState = FormWindowState.Maximized; + return; + } + + parts = Configuration.Settings.General.StartSize.Split(';'); + if (parts.Length == 2) + { + if (int.TryParse(parts[0], out var x) && int.TryParse(parts[1], out var y)) + { + Width = x; + Height = y; + } + } + + var ctrlScreen = Screen.FromControl(this); + + if (ctrlScreen.Bounds.Width < Width) + { + Width = ctrlScreen.Bounds.Width; + } + + if (ctrlScreen.Bounds.Height < Height) + { + Height = ctrlScreen.Bounds.Height; + } + + // Fix main window coordinate (Multi-Monitor issue) + if ((ctrlScreen.Bounds.Right < Left) || (ctrlScreen.Bounds.Bottom < Top) || + (ctrlScreen.Bounds.X > Right) || (ctrlScreen.Bounds.Y > Top)) + { + CenterToScreen(); + } + } + else + { + CenterFormOnCurrentScreen(); + } + } + + private void InitializeLanguage() + { + fileToolStripMenuItem.Text = _language.Menu.File.Title; + newToolStripMenuItem.Text = _language.Menu.File.New; + openToolStripMenuItem.Text = _language.Menu.File.Open; + toolStripMenuItemOpenKeepVideo.Text = _language.Menu.File.OpenKeepVideo; + reopenToolStripMenuItem.Text = _language.Menu.File.Reopen; + saveToolStripMenuItem.Text = _language.Menu.File.Save; + saveAsToolStripMenuItem.Text = _language.Menu.File.SaveAs; + toolStripMenuItemRestoreAutoBackup.Text = _language.Menu.File.RestoreAutoBackup; + toolStripMenuItemTTProperties.Text = _language.Menu.File.TimedTextProperties; + openOriginalToolStripMenuItem.Text = _language.Menu.File.OpenOriginal; + saveOriginalToolStripMenuItem.Text = _language.Menu.File.SaveOriginal; + saveOriginalAstoolStripMenuItem.Text = _language.SaveOriginalSubtitleAs; + removeOriginalToolStripMenuItem.Text = _language.Menu.File.CloseOriginal; + + toolStripMenuItemOpenContainingFolder.Text = _language.Menu.File.OpenContainingFolder; + toolStripMenuItemCompare.Text = _language.Menu.File.Compare; + toolStripMenuItemStatistics.Text = _language.Menu.File.Statistics; + toolStripMenuItemPlugins.Text = _language.Menu.File.Plugins; + toolStripMenuItemImportDvdSubtitles.Text = _language.Menu.File.ImportOcrFromDvd; + toolStripMenuItemSubIdx.Text = _language.Menu.File.ImportOcrVobSubSubtitle; + toolStripButtonGetFrameRate.ToolTipText = _language.GetFrameRateFromVideoFile; + toolStripMenuItemImportBluRaySup.Text = _language.Menu.File.ImportBluRaySupFile; + toolStripMenuItemImportXSub.Text = _language.Menu.File.ImportXSub; + matroskaImportStripMenuItem.Text = _language.Menu.File.ImportSubtitleFromMatroskaFile; + toolStripMenuItemManualAnsi.Text = _language.Menu.File.ImportSubtitleWithManualChosenEncoding; + toolStripMenuItemImportText.Text = _language.Menu.File.ImportText; + toolStripMenuItemImportImages.Text = _language.Menu.File.ImportImages; + toolStripMenuItemImportTimeCodes.Text = _language.Menu.File.ImportTimecodes; + toolStripMenuItemExport.Text = _language.Menu.File.Export; + toolStripMenuItemExportPngXml.Text = _language.Menu.File.ExportBdnXml; + bluraySupToolStripMenuItem.Text = _language.Menu.File.ExportBluRaySup; + adobeEncoreFABImageScriptToolStripMenuItem.Text = _language.Menu.File.ExportAdobeEncoreFabImageScript; + toolStripMenuItemTextTimeCodePair.Text = _language.Menu.File.ExportKoreanAtsFilePair; + vobSubsubidxToolStripMenuItem.Text = _language.Menu.File.ExportVobSub; + toolStripMenuItemCavena890.Text = _language.Menu.File.ExportCavena890; + eBUSTLToolStripMenuItem.Text = _language.Menu.File.ExportEbu; + pACScreenElectronicsToolStripMenuItem.Text = _language.Menu.File.ExportPac; + plainTextToolStripMenuItem.Text = _language.Menu.File.ExportPlainText; + toolStripMenuItemAvidStl.Text = _language.Menu.File.ExportAvidStl; + toolStripMenuItemExportCapMakerPlus.Text = _language.Menu.File.ExportCapMakerPlus; + toolStripMenuItemExportCaptionInc.Text = _language.Menu.File.ExportCaptionsInc; + toolStripMenuItemExportCheetahCap.Text = _language.Menu.File.ExportCheetahCap; + toolStripMenuItemExportUltech130.Text = _language.Menu.File.ExportUltech130; + exportCustomTextFormatToolStripMenuItem.Text = _language.Menu.File.ExportCustomTextFormat; + exitToolStripMenuItem.Text = _language.Menu.File.Exit; + + editToolStripMenuItem.Text = _language.Menu.Edit.Title; + showHistoryforUndoToolStripMenuItem.Text = _language.Menu.Edit.ShowUndoHistory; + toolStripMenuItemUndo.Text = _language.Menu.Edit.Undo; + toolStripMenuItemRedo.Text = _language.Menu.Edit.Redo; + + toolStripMenuItemInsertUnicodeCharacter.Text = _language.Menu.Edit.InsertUnicodeSymbol; + + findToolStripMenuItem.Text = _language.Menu.Edit.Find; + findNextToolStripMenuItem.Text = _language.Menu.Edit.FindNext; + replaceToolStripMenuItem.Text = _language.Menu.Edit.Replace; + multipleReplaceToolStripMenuItem.Text = _language.Menu.Edit.MultipleReplace; + gotoLineNumberToolStripMenuItem.Text = _language.Menu.Edit.GoToSubtitleNumber; + toolStripMenuItemRightToLeftMode.Text = _language.Menu.Edit.RightToLeftMode; + + toolStripMenuItemRemoveUnicodeControlChars.Text = _language.Menu.Edit.RemoveUnicodeControlCharacters; + toolStripMenuItemRtlUnicodeControlChars.Text = _language.Menu.Edit.FixRtlViaUnicodeControlCharacters; + + toolStripMenuItemReverseRightToLeftStartEnd.Text = _language.Menu.Edit.ReverseRightToLeftStartEnd; + toolStripMenuItemModifySelection.Text = _language.Menu.Edit.ModifySelection; + toolStripMenuItemInverseSelection.Text = _language.Menu.Edit.InverseSelection; + editSelectAllToolStripMenuItem.Text = _language.Menu.ContextMenu.SelectAll; + + toolsToolStripMenuItem.Text = _language.Menu.Tools.Title; + adjustDisplayTimeToolStripMenuItem.Text = _language.Menu.Tools.AdjustDisplayDuration; + toolStripMenuItemApplyDurationLimits.Text = _language.Menu.Tools.ApplyDurationLimits; + toolStripMenuItemSubtitlesBridgeGaps.Text = _language.Menu.Tools.SubtitlesBridgeGaps; + fixToolStripMenuItem.Text = _language.Menu.Tools.FixCommonErrors; + startNumberingFromToolStripMenuItem.Text = _language.Menu.Tools.StartNumberingFrom; + removeTextForHearImpairedToolStripMenuItem.Text = _language.Menu.Tools.RemoveTextForHearingImpaired; + ChangeCasingToolStripMenuItem.Text = _language.Menu.Tools.ChangeCasing; + toolStripMenuItemChangeFrameRate2.Text = _language.Menu.Tools.ChangeFrameRate; + changeSpeedInPercentToolStripMenuItem.Text = _language.Menu.Tools.ChangeSpeedInPercent; + toolStripMenuItemAutoMergeShortLines.Text = _language.Menu.Tools.MergeShortLines; + toolStripMenuItemMergeDuplicateText.Text = _language.Menu.Tools.MergeDuplicateText; + toolStripMenuItemMergeLinesWithSameTimeCodes.Text = _language.Menu.Tools.MergeSameTimeCodes; + toolStripMenuItemAutoSplitLongLines.Text = _language.Menu.Tools.SplitLongLines; + setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.Text = _language.Menu.Tools.MinimumDisplayTimeBetweenParagraphs; + toolStripMenuItemSortBy.Text = _language.Menu.Tools.SortBy; + netflixQualityCheckToolStripMenuItem.Text = _language.Menu.Tools.NetflixQualityCheck; + toolStripButtonNetflixQualityCheck.Text = _language.Menu.Tools.NetflixQualityCheck; + + sortNumberToolStripMenuItem.Text = _language.Menu.Tools.Number; + sortStartTimeToolStripMenuItem.Text = _language.Menu.Tools.StartTime; + sortEndTimeToolStripMenuItem.Text = _language.Menu.Tools.EndTime; + sortDisplayTimeToolStripMenuItem.Text = _language.Menu.Tools.Duration; + + descendingToolStripMenuItem.Text = _language.Menu.Tools.Descending; + AscendingToolStripMenuItem.Text = _language.Menu.Tools.Ascending; + + sortTextAlphabeticallytoolStripMenuItem.Text = _language.Menu.Tools.TextAlphabetically; + sortTextMaxLineLengthToolStripMenuItem.Text = _language.Menu.Tools.TextSingleLineMaximumLength; + sortTextTotalLengthToolStripMenuItem.Text = _language.Menu.Tools.TextTotalLength; + sortTextNumberOfLinesToolStripMenuItem.Text = _language.Menu.Tools.TextNumberOfLines; + textCharssecToolStripMenuItem.Text = _language.Menu.Tools.TextNumberOfCharactersPerSeconds; + textWordsPerMinutewpmToolStripMenuItem.Text = _language.Menu.Tools.WordsPerMinute; + styleToolStripMenuItem.Text = _language.Menu.Tools.Style; + actorToolStripMenuItem.Text = Configuration.Settings.Language.General.Actor; + + toolStripMenuItemShowOriginalInPreview.Text = _language.Menu.Edit.ShowOriginalTextInAudioAndVideoPreview; + toolStripMenuItemMakeEmptyFromCurrent.Text = _language.Menu.Tools.MakeNewEmptyTranslationFromCurrentSubtitle; + toolStripMenuItemBatchConvert.Text = _language.Menu.Tools.BatchConvert; + generateDatetimeInfoFromVideoToolStripMenuItem.Text = _language.Menu.Tools.GenerateTimeAsText; + toolStripMenuItemMeasurementConverter.Text = _language.Menu.Tools.MeasurementConverter; + splitToolStripMenuItem.Text = _language.Menu.Tools.SplitSubtitle; + appendTextVisuallyToolStripMenuItem.Text = _language.Menu.Tools.AppendSubtitle; + joinSubtitlesToolStripMenuItem.Text = _language.Menu.Tools.JoinSubtitles; + + toolStripMenuItemVideo.Text = _language.Menu.Video.Title; + openVideoToolStripMenuItem.Text = _language.Menu.Video.OpenVideo; + toolStripMenuItemOpenVideoFromUrl.Text = _language.Menu.Video.OpenVideoFromUrl; + toolStripMenuItemOpenDvd.Text = _language.Menu.Video.OpenDvd; + toolStripMenuItemSetAudioTrack.Text = _language.Menu.Video.ChooseAudioTrack; + closeVideoToolStripMenuItem.Text = _language.Menu.Video.CloseVideo; + openSecondSubtitleToolStripMenuItem.Text = _language.Menu.Video.OpenSecondSubtitle; + generateTextFromCurrentVideoToolStripMenuItem.Text = _language.Menu.Video.GenerateTextFromVideo; + + smpteTimeModedropFrameToolStripMenuItem.Text = _language.Menu.Video.SmptTimeMode; + toolStripMenuItemImportChapters.Text = _language.Menu.Video.ImportChaptersFromVideo; + toolStripMenuItemImportSceneChanges.Text = _language.Menu.Video.GenerateImportSceneChanges; + toolStripMenuItemRemoveSceneChanges.Text = _language.Menu.Video.RemoveSceneChanges; + + toolStripMenuItemAddWaveformBatch.Text = _language.Menu.Video.WaveformBatchGenerate; + + if (Configuration.Settings.VideoControls.GenerateSpectrogram) + { + showhideWaveformToolStripMenuItem.Text = _language.Menu.Video.ShowHideWaveformAndSpectrogram; + } + else + { + showhideWaveformToolStripMenuItem.Text = _language.Menu.Video.ShowHideWaveform; + } + + showhideVideoToolStripMenuItem.Text = _language.Menu.Video.ShowHideVideo; + undockVideoControlsToolStripMenuItem.Text = _language.Menu.Video.UnDockVideoControls; + redockVideoControlsToolStripMenuItem.Text = _language.Menu.Video.ReDockVideoControls; + + toolStripMenuItemSpellCheckMain.Text = _language.Menu.SpellCheck.Title; + spellCheckToolStripMenuItem.Text = _language.Menu.SpellCheck.SpellCheck; + toolStripMenuItemSpellCheckFromCurrentLine.Text = _language.Menu.SpellCheck.SpellCheckFromCurrentLine; + findDoubleWordsToolStripMenuItem.Text = _language.Menu.SpellCheck.FindDoubleWords; + FindDoubleLinesToolStripMenuItem.Text = _language.Menu.SpellCheck.FindDoubleLines; + GetDictionariesToolStripMenuItem.Text = _language.Menu.SpellCheck.GetDictionaries; + addWordToNameListToolStripMenuItem.Text = _language.Menu.SpellCheck.AddToNameList; + + toolStripMenuItemSynchronization.Text = _language.Menu.Synchronization.Title; + toolStripMenuItemAdjustAllTimes.Text = _language.Menu.Synchronization.AdjustAllTimes; + visualSyncToolStripMenuItem.Text = _language.Menu.Synchronization.VisualSync; + toolStripMenuItemPointSync.Text = _language.Menu.Synchronization.PointSync; + pointSyncViaOtherSubtitleToolStripMenuItem.Text = _language.Menu.Synchronization.PointSyncViaOtherSubtitle; + + toolStripMenuItemAutoTranslate.Text = _language.Menu.AutoTranslate.Title; + translateByGoogleToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslatePoweredByGoogle; + translatepoweredByMicrosoftToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslatePoweredByMicrosoft; + translateFromSwedishToDanishToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslateFromSwedishToDanish; + + optionsToolStripMenuItem.Text = _language.Menu.Options.Title; + settingsToolStripMenuItem.Text = _language.Menu.Options.Settings; + changeLanguageToolStripMenuItem.Text = _language.Menu.Options.ChooseLanguage + " [" + Configuration.Settings.Language.Name + "]"; + + toolStripMenuItemNetworking.Text = _language.Menu.Networking.Title; + startServerToolStripMenuItem.Text = _language.Menu.Networking.StartNewSession; + joinSessionToolStripMenuItem.Text = _language.Menu.Networking.JoinSession; + showSessionKeyLogToolStripMenuItem.Text = _language.Menu.Networking.ShowSessionInfoAndLog; + chatToolStripMenuItem.Text = _language.Menu.Networking.Chat; + leaveSessionToolStripMenuItem.Text = _language.Menu.Networking.LeaveSession; + + checkForUpdatesToolStripMenuItem.Text = _language.Menu.Help.CheckForUpdates; + helpToolStripMenuItem.Text = _language.Menu.Help.Title; + helpToolStripMenuItem1.Text = _language.Menu.Help.Help; + aboutToolStripMenuItem.Text = _language.Menu.Help.About; + + toolStripButtonFileNew.ToolTipText = _language.Menu.ToolBar.New; + toolStripButtonFileOpen.ToolTipText = _language.Menu.ToolBar.Open; + toolStripButtonSave.ToolTipText = _language.Menu.ToolBar.Save; + toolStripButtonSaveAs.ToolTipText = _language.Menu.ToolBar.SaveAs; + toolStripButtonFind.ToolTipText = _language.Menu.ToolBar.Find; + toolStripButtonReplace.ToolTipText = _language.Menu.ToolBar.Replace; + toolStripButtonFixCommonErrors.ToolTipText = _language.Menu.ToolBar.FixCommonErrors; + toolStripButtonRemoveTextForHi.ToolTipText = _language.Menu.ToolBar.RemoveTextForHi; + toolStripButtonVisualSync.ToolTipText = _language.Menu.ToolBar.VisualSync; + toolStripButtonSpellCheck.ToolTipText = _language.Menu.ToolBar.SpellCheck; + toolStripButtonNetflixQualityCheck.ToolTipText = _language.Menu.ToolBar.NetflixQualityCheck; + toolStripButtonSettings.ToolTipText = _language.Menu.ToolBar.Settings; + toolStripButtonHelp.ToolTipText = _language.Menu.ToolBar.Help; + toolStripButtonToggleWaveform.ToolTipText = _language.Menu.ToolBar.ShowHideWaveform; + toolStripButtonToggleVideo.ToolTipText = _language.Menu.ToolBar.ShowHideVideo; + + toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.SubStationAlphaStyles; + setStylesForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.SubStationAlphaSetStyle; + setActorForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.SetActor; + + toolStripMenuItemDelete.Text = _language.Menu.ContextMenu.Delete; + insertLineToolStripMenuItem.Text = _language.Menu.ContextMenu.InsertFirstLine; + toolStripMenuItemInsertBefore.Text = _language.Menu.ContextMenu.InsertBefore; + toolStripMenuItemInsertAfter.Text = _language.Menu.ContextMenu.InsertAfter; + toolStripMenuItemInsertSubtitle.Text = _language.Menu.ContextMenu.InsertSubtitleAfter; + + toolStripMenuItemCopySourceText.Text = _language.Menu.ContextMenu.CopyToClipboard; + + toolStripMenuItemColumn.Text = _language.Menu.ContextMenu.Column; + columnDeleteTextOnlyToolStripMenuItem.Text = _language.Menu.ContextMenu.ColumnDeleteText; + toolStripMenuItemColumnDeleteText.Text = _language.Menu.ContextMenu.ColumnDeleteTextAndShiftCellsUp; + ShiftTextCellsDownToolStripMenuItem.Text = _language.Menu.ContextMenu.ColumnInsertEmptyTextAndShiftCellsDown; + toolStripMenuItemInsertTextFromSub.Text = _language.Menu.ContextMenu.ColumnInsertTextFromSubtitle; + toolStripMenuItemColumnImportText.Text = _language.Menu.ContextMenu.ColumnImportTextAndShiftCellsDown; + toolStripMenuItemPasteSpecial.Text = _language.Menu.ContextMenu.ColumnPasteFromClipboard; + moveTextUpToolStripMenuItem.Text = _language.Menu.ContextMenu.ColumnTextUp; + moveTextDownToolStripMenuItem.Text = _language.Menu.ContextMenu.ColumnTextDown; + copyOriginalTextToCurrentToolStripMenuItem.Text = _language.Menu.ContextMenu.ColumnCopyOriginalTextToCurrent; + toolStripMenuItemBookmark.Text = Configuration.Settings.Language.Settings.ToggleBookmarksWithComment; + + splitLineToolStripMenuItem.Text = _language.Menu.ContextMenu.Split; + toolStripMenuItemMergeLines.Text = _language.Menu.ContextMenu.MergeSelectedLines; + toolStripMenuItemMergeDialog.Text = _language.Menu.ContextMenu.MergeSelectedLinesAsDialog; + mergeBeforeToolStripMenuItem.Text = _language.Menu.ContextMenu.MergeWithLineBefore; + mergeAfterToolStripMenuItem.Text = _language.Menu.ContextMenu.MergeWithLineAfter; + extendBeforeToolStripMenuItem.Text = _language.Menu.ContextMenu.ExtendToLineBefore; + extendAfterToolStripMenuItem.Text = _language.Menu.ContextMenu.ExtendToLineAfter; + removeFormattinglToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormatting; + removeAllFormattingsToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingAll; + removeBoldToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingBold; + removeItalicToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingItalic; + removeUnderlineToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingUnderline; + removeColorToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingColor; + removeFontNameToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingFontName; + removeAlignmentToolStripMenuItem.Text = _language.Menu.ContextMenu.RemoveFormattingAlignment; + boldToolStripMenuItem.Text = _languageGeneral.Bold; + underlineToolStripMenuItem.Text = _language.Menu.ContextMenu.Underline; + italicToolStripMenuItem.Text = _languageGeneral.Italic; + colorToolStripMenuItem.Text = _language.Menu.ContextMenu.Color; + toolStripMenuItemFont.Text = _language.Menu.ContextMenu.FontName; + toolStripMenuItemAlignment.Text = _language.Menu.ContextMenu.Alignment; + toolStripMenuItemAutoBreakLines.Text = _language.Menu.ContextMenu.AutoBalanceSelectedLines; + toolStripMenuItemUnbreakLines.Text = _language.Menu.ContextMenu.RemoveLineBreaksFromSelectedLines; + typeEffectToolStripMenuItem.Text = _language.Menu.ContextMenu.TypewriterEffect; + karokeeEffectToolStripMenuItem.Text = _language.Menu.ContextMenu.KaraokeEffect; + showSelectedLinesEarlierlaterToolStripMenuItem.Text = _language.Menu.ContextMenu.ShowSelectedLinesEarlierLater; + visualSyncSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.VisualSyncSelectedLines; + toolStripMenuItemGoogleMicrosoftTranslateSelLine.Text = _language.Menu.ContextMenu.GoogleAndMicrosoftTranslateSelectedLine; + googleTranslateToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslatePoweredByGoogle; + microsoftBingTranslateToolStripMenuItem.Text = _language.Menu.AutoTranslate.TranslatePoweredByMicrosoft; + toolStripMenuItemTranslateSelected.Text = _language.Menu.ContextMenu.TranslateSelectedLines; + adjustDisplayTimeForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.AdjustDisplayDurationForSelectedLines; + fixCommonErrorsInSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.FixCommonErrorsInSelectedLines; + changeCasingForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.ChangeCasingForSelectedLines; + toolStripMenuItemSaveSelectedLines.Text = _language.Menu.ContextMenu.SaveSelectedLines; + + // textbox context menu + cutToolStripMenuItem.Text = _language.Menu.ContextMenu.Cut; + copyToolStripMenuItem.Text = _language.Menu.ContextMenu.Copy; + pasteToolStripMenuItem.Text = _language.Menu.ContextMenu.Paste; + deleteToolStripMenuItem.Text = _language.Menu.ContextMenu.Delete; + toolStripMenuItemSplitTextAtCursor.Text = _language.Menu.ContextMenu.SplitLineAtCursorPosition; + toolStripMenuItemSplitViaWaveform.Text = _language.Menu.ContextMenu.SplitLineAtCursorAndWaveformPosition; + selectAllToolStripMenuItem.Text = _language.Menu.ContextMenu.SelectAll; + normalToolStripMenuItem1.Text = _language.Menu.ContextMenu.RemoveFormattingAll; + boldToolStripMenuItem1.Text = _languageGeneral.Bold; + italicToolStripMenuItem1.Text = _languageGeneral.Italic; + boxToolStripMenuItem.Text = _language.Menu.ContextMenu.Box; + underlineToolStripMenuItem1.Text = _language.Menu.ContextMenu.Underline; + colorToolStripMenuItem1.Text = _language.Menu.ContextMenu.Color; + fontNameToolStripMenuItem.Text = _language.Menu.ContextMenu.FontName; + toolStripMenuItemInsertUnicodeSymbol.Text = _language.Menu.Edit.InsertUnicodeSymbol; + toolStripMenuItemInsertUnicodeControlCharacters.Text = _language.Menu.Edit.InsertUnicodeControlCharacters; + superscriptToolStripMenuItem.Text = _language.Menu.ContextMenu.Superscript; + subscriptToolStripMenuItem.Text = _language.Menu.ContextMenu.Subscript; + leftToolStripMenuItem.Text = _language.Menu.Edit.InsertUnicodeControlCharactersLRM; + righttoleftMarkToolStripMenuItem.Text = _language.Menu.Edit.InsertUnicodeControlCharactersRLM; + startOfLefttorightEmbeddingLREToolStripMenuItem.Text = _language.Menu.Edit.InsertUnicodeControlCharactersLRE; + startOfRighttoleftEmbeddingRLEToolStripMenuItem.Text = _language.Menu.Edit.InsertUnicodeControlCharactersRLE; + startOfLefttorightOverrideLROToolStripMenuItem.Text = _language.Menu.Edit.InsertUnicodeControlCharactersLRO; + startOfRighttoleftOverrideRLOToolStripMenuItem.Text = _language.Menu.Edit.InsertUnicodeControlCharactersRLO; + + // main controls + SubtitleListview1.InitializeLanguage(_languageGeneral, Configuration.Settings); + toolStripLabelSubtitleFormat.Text = _language.Controls.SubtitleFormat; + toolStripLabelEncoding.Text = _language.Controls.FileEncoding; + toolStripLabelFrameRate.Text = _languageGeneral.FrameRate; + tabControlSubtitle.TabPages[TabControlSourceView].Text = _language.Controls.SourceView; + tabControlSubtitle.TabPages[TabControlListView].Text = _language.Controls.ListView; + labelStartTime.Text = _languageGeneral.StartTime; + labelDuration.Text = _languageGeneral.Duration; + labelText.Text = _languageGeneral.Text; + UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, _subtitle?.GetParagraphOrDefault(_subtitleListViewIndex), textBoxListViewText); + labelAlternateText.Text = _languageGeneral.OriginalText; + UpdateListViewTextInfo(labelTextAlternateLineLengths, labelAlternateSingleLine, labelAlternateSingleLinePixels, labelTextAlternateLineTotal, labelAlternateCharactersPerSecond, _subtitleAlternate?.GetParagraphOrDefault(_subtitleListViewIndex), textBoxListViewTextAlternate); + buttonPrevious.Text = _language.Controls.Previous; + buttonNext.Text = _language.Controls.Next; + buttonAutoBreak.Text = _language.Controls.AutoBreak; + buttonUnBreak.Text = _language.Controls.Unbreak; + buttonSplitLine.Text = _languageGeneral.SplitLine; + ShowSourceLineNumber(); + + // video controls + tabPageTranslate.Text = _language.VideoControls.Translate + " "; + tabPageCreate.Text = _language.VideoControls.Create + " "; + tabPageAdjust.Text = _language.VideoControls.Adjust + " "; + checkBoxSyncListViewWithVideoWhilePlaying.Text = _language.VideoControls.SelectCurrentElementWhilePlaying; + if (VideoFileName == null) + { + labelVideoInfo.Text = _languageGeneral.NoVideoLoaded; + } + + toolStripButtonLockCenter.Text = _language.VideoControls.Center; + toolStripSplitButtonPlayRate.Text = _language.VideoControls.PlayRate; + groupBoxAutoRepeat.Text = _language.VideoControls.AutoRepeat; + checkBoxAutoRepeatOn.Text = _language.VideoControls.AutoRepeatOn; + labelAutoRepeatCount.Text = _language.VideoControls.AutoRepeatCount; + groupBoxAutoContinue.Text = _language.VideoControls.AutoContinue; + checkBoxAutoContinue.Text = _language.VideoControls.AutoContinueOn; + labelAutoContinueDelay.Text = _language.VideoControls.DelayInSeconds; + buttonPlayPrevious.Text = _language.VideoControls.Previous; + buttonPlayCurrent.Text = _language.VideoControls.PlayCurrent; + buttonPlayNext.Text = _language.VideoControls.Next; + buttonStop.Text = _language.VideoControls.Pause; + groupBoxTranslateSearch.Text = _language.VideoControls.SearchTextOnline; + buttonGoogleIt.Text = _language.VideoControls.GoogleIt; + buttonGoogleTranslateIt.Text = _language.VideoControls.GoogleTranslate; + labelTranslateTip.Text = _language.VideoControls.TranslateTip; + + buttonInsertNewText.Text = _language.VideoControls.InsertNewSubtitleAtVideoPosition; + buttonBeforeText.Text = _language.VideoControls.PlayFromJustBeforeText; + buttonGotoSub.Text = _language.VideoControls.GoToSubtitlePositionAndPause; + buttonSetStartTime.Text = _language.VideoControls.SetStartTime; + buttonSetEnd.Text = _language.VideoControls.SetEndTime; + buttonSecBack1.Text = _language.VideoControls.SecondsBackShort; + buttonSecBack2.Text = _language.VideoControls.SecondsBackShort; + buttonForward1.Text = _language.VideoControls.SecondsForwardShort; + buttonForward2.Text = _language.VideoControls.SecondsForwardShort; + labelVideoPosition.Text = _language.VideoControls.VideoPosition; + labelVideoPosition2.Text = _language.VideoControls.VideoPosition; + + buttonSetStartAndOffsetRest.Text = _language.VideoControls.SetstartTimeAndOffsetOfRest; + buttonSetEndAndGoToNext.Text = _language.VideoControls.SetEndTimeAndGoToNext; + buttonAdjustSetStartTime.Text = _language.VideoControls.SetStartTime; + buttonAdjustSetEndTime.Text = _language.VideoControls.SetEndTime; + buttonAdjustPlayBefore.Text = _language.VideoControls.PlayFromJustBeforeText; + buttonAdjustGoToPosAndPause.Text = _language.VideoControls.GoToSubtitlePositionAndPause; + buttonAdjustSecBack1.Text = _language.VideoControls.SecondsBackShort; + buttonAdjustSecBack2.Text = _language.VideoControls.SecondsBackShort; + buttonAdjustSecForward1.Text = _language.VideoControls.SecondsForwardShort; + buttonAdjustSecForward2.Text = _language.VideoControls.SecondsForwardShort; + + // waveform + var languageWaveform = Configuration.Settings.Language.Waveform; + addParagraphHereToolStripMenuItem.Text = languageWaveform.AddParagraphHere; + addParagraphAndPasteToolStripMenuItem.Text = languageWaveform.AddParagraphHereAndPasteText; + toolStripMenuItemSetParagraphAsSelection.Text = languageWaveform.SetParagraphAsSelection; + deleteParagraphToolStripMenuItem.Text = languageWaveform.DeleteParagraph; + toolStripMenuItemFocusTextbox.Text = languageWaveform.FocusTextBox; + goToPreviousSubtitleStripMenuItem.Text = languageWaveform.GoToPrevious; + goToNextSubtitleStripMenuItem.Text = languageWaveform.GoToNext; + + splitToolStripMenuItem1.Text = languageWaveform.Split; + mergeWithPreviousToolStripMenuItem.Text = languageWaveform.MergeWithPrevious; + mergeWithNextToolStripMenuItem.Text = languageWaveform.MergeWithNext; + extendToPreviousToolStripMenuItem.Text = languageWaveform.ExtendToPrevious; + extendToNextToolStripMenuItem.Text = languageWaveform.ExtendToNext; + toolStripMenuItemWaveformPlaySelection.Text = languageWaveform.PlaySelection; + showWaveformAndSpectrogramToolStripMenuItem.Text = languageWaveform.ShowWaveformAndSpectrogram; + showOnlyWaveformToolStripMenuItem.Text = languageWaveform.ShowWaveformOnly; + showOnlySpectrogramToolStripMenuItem.Text = languageWaveform.ShowSpectrogramOnly; + seekSilenceToolStripMenuItem.Text = languageWaveform.SeekSilence; + insertSubtitleHereToolStripMenuItem.Text = languageWaveform.InsertSubtitleHere; + guessTimeCodesToolStripMenuItem.Text = languageWaveform.GuessTimeCodes; + removeSceneChangeToolStripMenuItem.Text = languageWaveform.RemoveSceneChange; + addSceneChangeToolStripMenuItem.Text = languageWaveform.AddSceneChange; + + toolStripButtonWaveformZoomOut.ToolTipText = languageWaveform.ZoomOut; + toolStripButtonWaveformZoomIn.ToolTipText = languageWaveform.ZoomIn; + + if (Configuration.Settings.VideoControls.GenerateSpectrogram) + { + audioVisualizer.WaveformNotLoadedText = languageWaveform.ClickToAddWaveformAndSpectrogram; + } + else + { + audioVisualizer.WaveformNotLoadedText = languageWaveform.ClickToAddWaveform; + } + + // clear cached language names + DvdSubtitleLanguage.Initialize(); + } + + private void SetFormatTo(string formatName) + { + SetFormatTo(SubtitleFormat.FromName(formatName, new SubRip())); + } + + private void SetFormatTo(SubtitleFormat subtitleFormat) + { + comboBoxSubtitleFormats.SelectedIndexChanged -= ComboBoxSubtitleFormatsSelectedIndexChanged; + UiUtil.InitializeSubtitleFormatComboBox(comboBoxSubtitleFormats, subtitleFormat.FriendlyName); + comboBoxSubtitleFormats.SelectedIndexChanged += ComboBoxSubtitleFormatsSelectedIndexChanged; + } + + private int FirstSelectedIndex + { + get + { + if (SubtitleListview1.SelectedItems.Count == 0) + { + return -1; + } + + return SubtitleListview1.SelectedItems[0].Index; + } + } + + private int FirstVisibleIndex + { + get + { + if (SubtitleListview1.Items.Count == 0 || SubtitleListview1.TopItem == null) + { + return -1; + } + + return SubtitleListview1.TopItem.Index; + } + } + + private long _lastAutoSave; + + private void AutoSave(bool force = false) + { + if (!Configuration.Settings.General.AutoSave || + DateTime.UtcNow.Ticks - _lastAutoSave < 10000 * 3000 && !force) // only check for auto save evety 3 seconds + { + return; + } + + _lastAutoSave = DateTime.UtcNow.Ticks + 1009000; + var currentSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + if (_changeSubtitleHash != currentSubtitleHash && _lastDoNotPrompt != currentSubtitleHash && _subtitle?.Paragraphs.Count > 0) + { + if (string.IsNullOrEmpty(_fileName) || _converted) + { + return; + } + + SaveSubtitle(GetCurrentSubtitleFormat(), false, true); + } + + if (!string.IsNullOrEmpty(_subtitleAlternateFileName) && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + SaveOriginalSubtitle(GetCurrentSubtitleFormat(), true); + } + + _lastAutoSave = DateTime.UtcNow.Ticks; + } + + private bool ContinueNewOrExit() + { + AutoSave(true); + var currentSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + if (_changeSubtitleHash != currentSubtitleHash && _lastDoNotPrompt != currentSubtitleHash && _subtitle?.Paragraphs.Count > 0) + { + string promptText = _language.SaveChangesToUntitled; + if (!string.IsNullOrEmpty(_fileName)) + { + promptText = string.Format(_language.SaveChangesToX, _fileName); + } + + var dr = MessageBox.Show(this, promptText, Title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); + + if (dr == DialogResult.Cancel) + { + return false; + } + + if (dr == DialogResult.Yes) + { + if (string.IsNullOrEmpty(_fileName)) + { + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + saveFileDialog1.Title = _language.SaveSubtitleAs; + if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + _fileName = saveFileDialog1.FileName; + SetTitle(); + Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + Configuration.Settings.Save(); + } + else + { + return false; + } + } + + if (SaveSubtitle(GetCurrentSubtitleFormat()) != DialogResult.OK) + { + return false; + } + } + } + + return ContinueNewOrExitAlternate(); + } + + private bool ContinueNewOrExitAlternate() + { + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0 && _changeAlternateSubtitleHash != _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName)) + { + string promptText = _language.SaveChangesToUntitledOriginal; + if (!string.IsNullOrEmpty(_subtitleAlternateFileName)) + { + promptText = string.Format(_language.SaveChangesToOriginalX, _subtitleAlternateFileName); + } + + var dr = MessageBox.Show(this, promptText, Title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); + + if (dr == DialogResult.Cancel) + { + return false; + } + + if (dr == DialogResult.Yes) + { + if (string.IsNullOrEmpty(_subtitleAlternateFileName)) + { + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + saveFileDialog1.Title = _language.SaveOriginalSubtitleAs; + if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + _subtitleAlternateFileName = saveFileDialog1.FileName; + } + else + { + return false; + } + } + + if (SaveOriginalSubtitle(GetCurrentSubtitleFormat()) != DialogResult.OK) + { + return false; + } + } + } + + _lastDoNotPrompt = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + return true; + } + + private void ExitToolStripMenuItemClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + Application.Exit(); + } + + private void AboutToolStripMenuItemClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + using (var about = new About()) + { + about.Initialize(); + about.ShowDialog(this); + } + } + + private void VisualSyncToolStripMenuItemClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + ShowVisualSync(false); + } + + public void MakeHistoryForUndo(string description, bool resetTextUndo) + { + if (_makeHistoryPaused) + { + return; + } + + if (resetTextUndo) + { + _listViewTextUndoLast = null; + _listViewAlternateTextUndoLast = null; + } + + if (_undoIndex == -1) + { + _subtitle.HistoryItems.Clear(); + } + else + { + // remove items for redo + while (_subtitle.HistoryItems.Count > _undoIndex + 1) + { + _subtitle.HistoryItems.RemoveAt(_subtitle.HistoryItems.Count - 1); + } + } + + _subtitle.FileName = _fileName; + _subtitle.MakeHistoryForUndo(description, GetCurrentSubtitleFormat(), _fileDateTime, _subtitleAlternate, _subtitleAlternateFileName, _subtitleListViewIndex, textBoxListViewText.SelectionStart, textBoxListViewTextAlternate.SelectionStart); + _undoIndex++; + + if (_undoIndex > Subtitle.MaximumHistoryItems) + { + _undoIndex--; + } + } + + public void MakeHistoryForUndo(string description) + { + MakeHistoryForUndo(description, true); + } + + /// + /// Add undo history - but only if last entry is older than 500 ms + /// + /// Undo description + public void MakeHistoryForUndoOnlyIfNotResent(string description) + { + if (_makeHistoryPaused) + { + return; + } + + if ((DateTime.UtcNow.Ticks - _lastHistoryTicks) > 10000 * 500) // only if last change was longer ago than 500 milliseconds + { + MakeHistoryForUndo(description); + _lastHistoryTicks = DateTime.UtcNow.Ticks; + } + } + + private bool IsSubtitleLoaded + { + get { return _subtitle != null && (_subtitle.Paragraphs.Count > 1 || (_subtitle.Paragraphs.Count == 1 && !string.IsNullOrWhiteSpace(_subtitle.Paragraphs[0].Text))); } + } + + private void ShowVisualSync(bool onlySelectedLines) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + using (var visualSync = new VisualSync()) + { + visualSync.VideoFileName = VideoFileName; + visualSync.AudioTrackNumber = VideoAudioTrackNumber; + + SaveSubtitleListviewIndices(); + if (onlySelectedLines) + { + var selectedLines = new Subtitle(); + Subtitle selectedLinesAlternate = null; + if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + selectedLinesAlternate = new Subtitle(); + } + + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.Paragraphs[index]; + selectedLines.Paragraphs.Add(p); + if (selectedLinesAlternate != null) + { + var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + selectedLinesAlternate.Paragraphs.Add(original); + } + } + } + + visualSync.Initialize(toolStripButtonVisualSync.Image as Bitmap, selectedLines, selectedLinesAlternate, _fileName, _language.VisualSyncSelectedLines, CurrentFrameRate); + } + else + { + visualSync.Initialize(toolStripButtonVisualSync.Image as Bitmap, _subtitle, _subtitleAlternate, _fileName, _language.VisualSyncTitle, CurrentFrameRate); + } + + _endSeconds = -1; + mediaPlayer.Pause(); + if (visualSync.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeVisualSync); + + if (onlySelectedLines) + { // we only update selected lines + int i = 0; + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index] = visualSync.Paragraphs[i]; + i++; + } + + ShowStatus(_language.VisualSyncPerformedOnSelectedLines); + } + else + { + _subtitle.Paragraphs.Clear(); + foreach (var p in visualSync.Paragraphs) + { + _subtitle.Paragraphs.Add(new Paragraph(p)); + } + + if (_subtitleAlternate != null && visualSync.ParagraphsAlternate != null) + { + _subtitleAlternate.Paragraphs.Clear(); + foreach (var p in visualSync.ParagraphsAlternate) + { + _subtitleAlternate.Paragraphs.Add(new Paragraph(p)); + } + } + + ShowStatus(_language.VisualSyncPerformed); + } + + if (visualSync.FrameRateChanged) + { + toolStripComboBoxFrameRate.Text = string.Format("{0:0.###}", visualSync.FrameRate); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + if (onlySelectedLines && SubtitleListview1.SelectedItems.Count > 0) + { + SubtitleListview1.EnsureVisible(SubtitleListview1.SelectedItems[SubtitleListview1.SelectedItems.Count - 1].Index); + } + } + + VideoFileName = visualSync.VideoFileName; + } + } + + private void OpenToolStripMenuItemClick(object sender, EventArgs e) + { + openToolStripMenuItem.Enabled = false; + ReloadFromSourceView(); + OpenNewFile(); + openToolStripMenuItem.Enabled = true; + } + + private void OpenNewFile() + { + if (_openFileDialogOn) + { + return; + } + + _openFileDialogOn = true; + _lastDoNotPrompt = -1; + if (!ContinueNewOrExit()) + { + _openFileDialogOn = false; + return; + } + + openFileDialog1.Title = _languageGeneral.OpenSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + RemoveAlternate(true, false); + + // try to open via recent files + if (OpenFromRecentFiles(openFileDialog1.FileName)) + { + return; + } + + OpenSubtitle(openFileDialog1.FileName, null); + } + + _openFileDialogOn = false; + } + + private bool OpenFromRecentFiles(string fileName) + { + var rfe = Configuration.Settings.RecentFiles.Files.FirstOrDefault(p => !string.IsNullOrEmpty(p.FileName) && p.FileName.Equals(fileName, StringComparison.OrdinalIgnoreCase)); + if (rfe != null) + { + OpenRecentFile(rfe); + GotoSubPosAndPause(); + SubtitleListview1.EndUpdate(); + SetRecentIndices(rfe); + if (!string.IsNullOrEmpty(rfe.VideoFileName)) + { + var p = _subtitle.GetParagraphOrDefault(rfe.FirstSelectedIndex); + if (p != null) + { + mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; + } + } + + _openFileDialogOn = false; + return true; + } + + return false; + } + + public double CurrentFrameRate + { + get + { + if (double.TryParse(toolStripComboBoxFrameRate.Text, out var f)) + { + return f; + } + + return Configuration.Settings.General.DefaultFrameRate; + } + } + + private void OpenSubtitle(string fileName, Encoding encoding) + { + OpenSubtitle(fileName, encoding, null, null); + } + + private void ResetHistory() + { + _undoIndex = -1; + _subtitle.HistoryItems.Clear(); + } + + private void OpenSubtitle(string fileName, Encoding encoding, string videoFileName, string originalFileName) + { + OpenSubtitle(fileName, encoding, videoFileName, originalFileName, false); + } + + private void OpenSubtitle(string fileName, Encoding encoding, string videoFileName, string originalFileName, bool updateRecentFile) + { + if (!File.Exists(fileName)) + { + MessageBox.Show(string.Format(_language.FileNotFound, fileName)); + return; + } + + _lastAutoSave = DateTime.UtcNow.Ticks; + bool videoFileLoaded = false; + var file = new FileInfo(fileName); + var ext = file.Extension.ToLowerInvariant(); + + // save last first visible index + first selected index from listview + if (_fileName != null && updateRecentFile) + { + Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + } + Configuration.Settings.General.CurrentVideoOffsetInMs = 0; + + openFileDialog1.InitialDirectory = file.DirectoryName; + + + if (ext == ".idx") + { + var subFileName = fileName.Substring(0, fileName.Length - 3) + "sub"; + if (File.Exists(subFileName) && FileUtil.IsVobSub(subFileName)) + { + ext = ".sub"; + fileName = subFileName; + } + } + + if (ext == ".sub" && IsVobSubFile(fileName, false)) + { + ImportAndOcrVobSubSubtitleNew(fileName, _loading); + return; + } + + if (ext == ".sup") + { + if (FileUtil.IsBluRaySup(fileName)) + { + ImportAndOcrBluRaySup(fileName, _loading); + return; + } + + if (FileUtil.IsSpDvdSup(fileName)) + { + ImportAndOcrSpDvdSup(fileName, _loading); + return; + } + } + + if (ext == ".mkv" || ext == ".mks") + { + ImportSubtitleFromMatroskaFile(fileName); + return; + } + + if (ext == ".divx" || ext == ".avi") + { + if (ImportSubtitleFromDivX(fileName)) + { + return; + } + } + + if ((ext == ".ts" || ext == ".rec" || ext == ".mpeg" || ext == ".mpg") && file.Length > 10000 && FileUtil.IsTransportStream(fileName)) + { + ImportSubtitleFromTransportStream(fileName); + return; + } + + if (((ext == ".m2ts" || ext == ".ts" || ext == ".mts") && file.Length > 10000 && FileUtil.IsM2TransportStream(fileName)) || + (ext == ".textst" && FileUtil.IsMpeg2PrivateStream2(fileName))) + { + bool isTextSt = false; + if (file.Length < 2000000) + { + var textSt = new TextST(); + isTextSt = textSt.IsMine(null, fileName); + } + + if (!isTextSt) + { + ImportSubtitleFromTransportStream(fileName); + return; + } + } + + if ((ext == ".mp4" || ext == ".m4v" || ext == ".3gp") && file.Length > 10000) + { + if (!new IsmtDfxp().IsMine(null, fileName)) + { + if (ImportSubtitleFromMp4(fileName) && !Configuration.Settings.General.DisableVideoAutoLoading) + { + OpenVideo(fileName); + } + + return; + } + } + + if (ext == ".mxf" && FileUtil.IsMaterialExchangeFormat(fileName)) + { + var parser = new MxfParser(fileName); + if (parser.IsValid) + { + var subtitles = parser.GetSubtitles(); + if (subtitles.Count > 0) + { + SetEncoding(Configuration.Settings.General.DefaultEncoding); + var list = new List(subtitles[0].SplitToLines()); + _subtitle = new Subtitle(); + var mxfFormat = _subtitle.ReloadLoadSubtitle(list, null, null); + SetCurrentFormat(mxfFormat); + _fileName = Utilities.GetPathAndFileNameWithoutExtension(fileName) + GetCurrentSubtitleFormat().Extension; + SetTitle(); + ShowStatus(string.Format(_language.LoadedSubtitleX, _fileName)); + _sourceViewChange = false; + _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + ResetHistory(); + SetUndockedWindowsTitle(); + _converted = true; + ShowStatus(string.Format(_language.LoadedSubtitleX, _fileName) + " - " + string.Format(_language.ConvertedToX, mxfFormat.FriendlyName)); + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + return; + } + + MessageBox.Show("No subtitles found!"); + return; + } + } + + if (ext == ".prproj") + { + var f = new AdobePremierePrProj(); + var tempFileName = AdobePremierePrProj.LoadFromZipFile(fileName); + if (!string.IsNullOrEmpty(fileName)) + { + var list = new List(File.ReadAllLines(tempFileName, LanguageAutoDetect.GetEncodingFromFile(tempFileName))); + try + { + File.Delete(tempFileName); + } + catch + { + // ignored + } + if (f.IsMine(list, tempFileName)) + { + f.LoadSubtitle(_subtitle, list, fileName); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + SetEncoding(Configuration.Settings.General.DefaultEncoding); + encoding = GetCurrentEncoding(); + SubtitleListview1.Fill(_subtitle); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + _fileName = Utilities.GetPathAndFileNameWithoutExtension(fileName) + GetCurrentSubtitleFormat().Extension; + SetTitle(); + ShowStatus(string.Format(_language.LoadedSubtitleX, _fileName)); + _converted = true; + return; + } + } + } + + if (file.Length > Subtitle.MaxFileSize) + { + // retry Blu-ray sup (file with wrong extension) + if (FileUtil.IsBluRaySup(fileName)) + { + ImportAndOcrBluRaySup(fileName, _loading); + return; + } + + // retry vobsub (file with wrong extension) + if (IsVobSubFile(fileName, false)) + { + ImportAndOcrVobSubSubtitleNew(fileName, _loading); + return; + } + + var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, fileName); + if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return; + } + } + + var tempSubtitle = new Subtitle(_subtitle, false); + if (_subtitle.HistoryItems.Count > 0 || _subtitle.Paragraphs.Count > 0) + { + MakeHistoryForUndo(string.Format(_language.BeforeLoadOf, Path.GetFileName(fileName))); + } + + var subtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + bool hasChanged = (_changeSubtitleHash != subtitleHash) && (_lastDoNotPrompt != subtitleHash); + + SubtitleFormat format = _subtitle.LoadSubtitle(fileName, out encoding, encoding); + if (format == null) + { + _subtitle = tempSubtitle; + } + + if (!hasChanged) + { + _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + } + + ShowHideTextBasedFeatures(format); + + bool justConverted = false; + + if (ext == ".m2ts" || ext == ".textst") + { + var textST = new TextST(); + if (textST.IsMine(null, fileName)) + { + textST.LoadSubtitle(_subtitle, null, fileName); + _oldSubtitleFormat = textST; + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + SetEncoding(Configuration.Settings.General.DefaultEncoding); + encoding = GetCurrentEncoding(); + justConverted = true; + format = GetCurrentSubtitleFormat(); + } + } + + var encodingFromFile = encoding; + if (format == null) + { + encodingFromFile = LanguageAutoDetect.GetEncodingFromFile(fileName); + } + + if (format == null) + { + var f = new TimeCodesOnly1(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (f.IsMine(list, fileName)) + { + f.LoadSubtitle(_subtitle, list, fileName); + _oldSubtitleFormat = f; + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + SetEncoding(Configuration.Settings.General.DefaultEncoding); + encoding = GetCurrentEncoding(); + justConverted = true; + format = GetCurrentSubtitleFormat(); + } + } + + if (format == null) + { + var f = new TimeCodesOnly2(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (f.IsMine(list, fileName)) + { + f.LoadSubtitle(_subtitle, list, fileName); + _oldSubtitleFormat = f; + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + SetEncoding(Configuration.Settings.General.DefaultEncoding); + encoding = GetCurrentEncoding(); + justConverted = true; + format = GetCurrentSubtitleFormat(); + } + } + + if (format == null) + { + try + { + var bdnXml = new BdnXml(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (bdnXml.IsMine(list, fileName)) + { + if (ContinueNewOrExit()) + { + ImportAndOcrBdnXml(fileName, bdnXml, list); + } + + return; + } + } + catch + { + // ignore + } + } + + if (format == null) + { + try + { + var fcpImage = new FinalCutProImage(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (fcpImage.IsMine(list, fileName)) + { + if (ContinueNewOrExit()) + { + ImportAndOcrDost(fileName, fcpImage, list); + } + + return; + } + } + catch + { + // ignore + } + } + + if (format == null) + { + try + { + var f = new DvdStudioProSpaceGraphic(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (f.IsMine(list, fileName)) + { + if (ContinueNewOrExit()) + { + ImportAndOcrDost(fileName, f, list); + } + + return; + } + } + catch + { + // ignore + } + } + + if (format == null) + { + try + { + var imageFormat = new SpuImage(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (imageFormat.IsMine(list, fileName)) + { + if (ContinueNewOrExit()) + { + ImportAndOcrDost(fileName, imageFormat, list); + } + + return; + } + } + catch + { + format = null; + } + } + + if (format == null) + { + var arib = new AribB36(); + if (arib.IsMine(null, fileName)) + { + arib.LoadSubtitle(_subtitle, null, fileName); + _oldSubtitleFormat = arib; + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + SetEncoding(Configuration.Settings.General.DefaultEncoding); + encoding = GetCurrentEncoding(); + justConverted = true; + format = GetCurrentSubtitleFormat(); + } + } + + if (ext == ".dost") + { + try + { + var dost = new Dost(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (dost.IsMine(list, fileName)) + { + if (ContinueNewOrExit()) + { + ImportAndOcrDost(fileName, dost, list); + } + + return; + } + } + catch + { + format = null; + } + } + + if (format == null) + { + try + { + var timedtextImage = new TimedTextImage(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (timedtextImage.IsMine(list, fileName)) + { + if (ContinueNewOrExit()) + { + ImportAndOcrDost(fileName, timedtextImage, list); + } + + return; + } + } + catch + { + format = null; + } + } + + if (format == null) + { + try + { + var seImageHtmlIndex = new SeImageHtmlIndex(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (seImageHtmlIndex.IsMine(list, fileName)) + { + if (ContinueNewOrExit()) + { + ImportAndOcrDost(fileName, seImageHtmlIndex, list); + } + + return; + } + } + catch + { + format = null; + } + } + + if (format == null || format.Name == Scenarist.NameOfFormat) + { + try + { + var son = new Son(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (son.IsMine(list, fileName)) + { + if (ContinueNewOrExit()) + { + ImportAndOcrSon(fileName, son, list); + } + + return; + } + } + catch + { + format = null; + } + } + + if (format == null || format.Name == SubRip.NameOfFormat) + { + if (_subtitle.Paragraphs.Count > 1) + { + int imageCount = 0; + foreach (var p in _subtitle.Paragraphs) + { + string s = p.Text.ToLowerInvariant(); + if (s.EndsWith(".bmp", StringComparison.Ordinal) || s.EndsWith(".png", StringComparison.Ordinal) || s.EndsWith(".jpg", StringComparison.Ordinal) || s.EndsWith(".tif", StringComparison.Ordinal)) + { + imageCount++; + } + } + + if (imageCount > 2 && imageCount >= _subtitle.Paragraphs.Count - 2) + { + if (ContinueNewOrExit()) + { + ImportAndOcrSrt(_subtitle); + } + + return; + } + } + } + + if (format == null) + { + try + { + var satBoxPng = new SatBoxPng(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (satBoxPng.IsMine(list, fileName)) + { + var subtitle = new Subtitle(); + satBoxPng.LoadSubtitle(subtitle, list, fileName); + if (ContinueNewOrExit()) + { + ImportAndOcrSrt(subtitle); + } + + return; + } + } + catch + { + format = null; + } + } + + if (format == null || format.Name == Scenarist.NameOfFormat) + { + try + { + var sst = new SonicScenaristBitmaps(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (sst.IsMine(list, fileName)) + { + if (ContinueNewOrExit()) + { + ImportAndOcrSst(fileName, sst, list); + } + + return; + } + } + catch + { + format = null; + } + } + + if (format == null) + { + try + { + var htmlSamiArray = new HtmlSamiArray(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (htmlSamiArray.IsMine(list, fileName)) + { + htmlSamiArray.LoadSubtitle(_subtitle, list, fileName); + _oldSubtitleFormat = htmlSamiArray; + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + SetEncoding(Configuration.Settings.General.DefaultEncoding); + encoding = GetCurrentEncoding(); + justConverted = true; + format = GetCurrentSubtitleFormat(); + } + } + catch + { + format = null; + } + } + + if (format == null) + { + foreach (var f in SubtitleFormat.GetBinaryFormats(false)) + { + if (f.IsMine(null, fileName)) + { + f.LoadSubtitle(_subtitle, null, fileName); + _oldSubtitleFormat = f; + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + SetEncoding(Configuration.Settings.General.DefaultEncoding); + encoding = GetCurrentEncoding(); + justConverted = true; + format = GetCurrentSubtitleFormat(); + break; + } + } + } + + if (format == null) + { + var lines = FileUtil.ReadAllTextShared(fileName, encodingFromFile).SplitToLines(); + foreach (var f in SubtitleFormat.GetTextOtherFormats()) + { + if (f.IsMine(lines, fileName)) + { + f.LoadSubtitle(_subtitle, lines, fileName); + _oldSubtitleFormat = f; + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + SetEncoding(Configuration.Settings.General.DefaultEncoding); + encoding = GetCurrentEncoding(); + justConverted = true; + format = GetCurrentSubtitleFormat(); + break; + } + } + } + + if (format == null && ext == ".cdg" && file.Length < 50_000_000) + { + using (var importCdg = new ImportCdg(fileName)) + { + importCdg.ShowDialog(this); + return; + } + } + + // retry vobsub (file with wrong extension) + if (format == null && file.Length > 500 && IsVobSubFile(fileName, false)) + { + ImportAndOcrVobSubSubtitleNew(fileName, _loading); + return; + } + + // retry Blu-ray (file with wrong extension) + if (format == null && file.Length > 500 && FileUtil.IsBluRaySup(fileName)) + { + ImportAndOcrBluRaySup(fileName, _loading); + return; + } + + // retry SP DVD (file with wrong extension) + if (format == null && file.Length > 500 && FileUtil.IsSpDvdSup(fileName)) + { + ImportAndOcrSpDvdSup(fileName, _loading); + return; + } + + // retry Matroska (file with wrong extension) + if (format == null && !string.IsNullOrWhiteSpace(fileName)) + { + using (var matroska = new MatroskaFile(fileName)) + { + if (matroska.IsValid) + { + var subtitleList = matroska.GetTracks(true); + if (subtitleList.Count > 0) + { + ImportSubtitleFromMatroskaFile(fileName); + return; + } + } + } + } + + // check for idx file + if (format == null && file.Length > 100 && ext == ".idx") + { + MessageBox.Show(_language.ErrorLoadIdx); + return; + } + + // check for .rar file + if (format == null && file.Length > 100 && FileUtil.IsRar(fileName)) + { + MessageBox.Show(_language.ErrorLoadRar); + return; + } + + // check for .zip file + if (format == null && file.Length > 100 && FileUtil.IsZip(fileName)) + { + MessageBox.Show(_language.ErrorLoadZip); + return; + } + + // check for .7z file + if (format == null && file.Length > 100 && FileUtil.Is7Zip(fileName)) + { + MessageBox.Show(_language.ErrorLoad7Zip); + return; + } + + // check for .png file + if (format == null && file.Length > 100 && FileUtil.IsPng(fileName)) + { + MessageBox.Show(_language.ErrorLoadPng); + return; + } + + // check for .jpg file + if (format == null && file.Length > 100 && FileUtil.IsJpg(fileName)) + { + MessageBox.Show(_language.ErrorLoadJpg); + return; + } + + // check for .srr file + if (format == null && file.Length > 100 && ext == ".srr" && FileUtil.IsSrr(fileName)) + { + MessageBox.Show(_language.ErrorLoadSrr); + return; + } + + // check for Torrent file + if (format == null && file.Length > 50 && FileUtil.IsTorrentFile(fileName)) + { + MessageBox.Show(_language.ErrorLoadTorrent); + return; + } + + // check for all binary zeroes (I've heard about this a few times... perhaps related to crashes?) + if (format == null && file.Length > 50 && FileUtil.IsSubtitleFileAllBinaryZeroes(fileName)) + { + MessageBox.Show(_language.ErrorLoadBinaryZeroes); + return; + } + + if (format == null && file.Length < 100 * 1000000 && TransportStreamParser.IsDvbSup(fileName)) + { + ImportSubtitleFromDvbSupFile(fileName); + return; + } + + if (format == null && file.Length < 1000000) + { + // check for valid timed text + if (ext == ".xml" || ext == ".dfxp") + { + var sb = new StringBuilder(); + foreach (var line in File.ReadAllLines(fileName, encodingFromFile)) + { + sb.AppendLine(line); + } + + var xmlAsString = sb.ToString().Trim(); + + if (xmlAsString.Contains("http://www.w3.org/ns/ttml") && xmlAsString.Contains(" 1) + { + _subtitle = genericParseSubtitle; + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + SetEncoding(Configuration.Settings.General.DefaultEncoding); + encoding = GetCurrentEncoding(); + justConverted = true; + format = GetCurrentSubtitleFormat(); + ShowStatus("Guessed subtitle format via generic subtitle parser!"); + } + } + catch + { + } + } + + if (format == null && file.Length < 1_000_000 && (FileUtil.IsPlainText(fileName) || new Tx3GTextOnly().IsMine(null, fileName))) + { + ImportPlainText(fileName); + return; + } + + if (format == null) + { + var fd = new FinalDraftTemplate2(); + var list = new List(File.ReadAllLines(fileName, encodingFromFile)); + if (fd.IsMine(list, fileName)) + { + ImportPlainText(fileName); + return; + } + } + + _fileDateTime = File.GetLastWriteTime(fileName); + + if (format != null) + { + RemoveAlternate(true, false); + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); + + new BookmarkPersistence(_subtitle, fileName).Load(); + + if (Configuration.Settings.General.RemoveBlankLinesWhenOpening) + { + _subtitle.RemoveEmptyLines(); + } + + if (Configuration.Settings.General.RemoveBadCharsWhenOpening) + { + foreach (var p in _subtitle.Paragraphs) + { + // Replace U+0456 (CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I) by U+0069 (LATIN SMALL LETTER I) + p.Text = p.Text.Replace("<і>", "").Replace("", ""); + + // remove control characters (e.g. binary zero) + p.Text = p.Text.RemoveControlCharactersButWhiteSpace(); + } + } + + _subtitleListViewIndex = -1; + Configuration.Settings.General.CurrentVideoOffsetInMs = 0; + + var oldSaveFormat = Configuration.Settings.General.LastSaveAsFormat; + SetCurrentFormat(format); + Configuration.Settings.General.LastSaveAsFormat = oldSaveFormat; + + _subtitleAlternateFileName = null; + if (LoadAlternateSubtitleFile(originalFileName)) + { + _subtitleAlternateFileName = originalFileName; + } + + // Seungki begin + _splitDualSami = false; + if (Configuration.Settings.SubtitleSettings.SamiDisplayTwoClassesAsTwoSubtitles && format.GetType() == typeof(Sami) && Sami.GetStylesFromHeader(_subtitle.Header).Count == 2) + { + var classes = Sami.GetStylesFromHeader(_subtitle.Header); + var s1 = new Subtitle(_subtitle); + var s2 = new Subtitle(_subtitle); + s1.Paragraphs.Clear(); + s2.Paragraphs.Clear(); + foreach (var p in _subtitle.Paragraphs) + { + if (p.Extra != null && p.Extra.Equals(classes[0], StringComparison.OrdinalIgnoreCase)) + { + s1.Paragraphs.Add(p); + } + else + { + s2.Paragraphs.Add(p); + } + } + + if (s1.Paragraphs.Count == 0 || s2.Paragraphs.Count == 0) + { + return; + } + + _subtitle = s1; + _subtitleAlternate = s2; + _subtitleAlternateFileName = _fileName; + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); + SubtitleListview1.ShowAlternateTextColumn(classes[1]); + _splitDualSami = true; + } + // Seungki end + + textBoxSource.Text = _subtitle.ToText(format); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (SubtitleListview1.Items.Count > 0) + { + SubtitleListview1.Items[0].Selected = true; + SubtitleListview1.Items[0].Focused = true; + } + textBoxListViewText.BackColor = SystemColors.WindowFrame; + textBoxListViewTextAlternate.BackColor = SystemColors.WindowFrame; + + _findHelper = null; + _spellCheckForm = null; + + if (_resetVideo && ModifierKeys != Keys.Shift) + { + VideoFileName = null; + _videoInfo = null; + VideoAudioTrackNumber = -1; + labelVideoInfo.Text = _languageGeneral.NoVideoLoaded; + audioVisualizer.WavePeaks = null; + audioVisualizer.SetSpectrogram(null); + audioVisualizer.SceneChanges = new List(); + audioVisualizer.Chapters = new List(); + } + + if (Configuration.Settings.General.ShowVideoPlayer || Configuration.Settings.General.ShowAudioVisualizer) + { + if (!Configuration.Settings.General.DisableVideoAutoLoading) + { + if (!string.IsNullOrEmpty(videoFileName) && File.Exists(videoFileName)) + { + OpenVideo(videoFileName); + } + else if (!string.IsNullOrEmpty(fileName) && (toolStripButtonToggleVideo.Checked || toolStripButtonToggleWaveform.Checked)) + { + TryToFindAndOpenVideoFile(Utilities.GetPathAndFileNameWithoutExtension(fileName)); + } + + if (VideoFileName == null) + { + CloseVideoToolStripMenuItemClick(this, null); + } + } + } + + videoFileLoaded = VideoFileName != null; + + Configuration.Settings.RecentFiles.Add(fileName, videoFileName, originalFileName); + UpdateRecentFilesUI(); + + _fileName = fileName; + SetTitle(); + ShowStatus(string.Format(_language.LoadedSubtitleX, _fileName)); + _sourceViewChange = false; + + if (Configuration.Settings.General.AutoConvertToUtf8) + { + if (Configuration.Settings.General.DefaultEncoding == TextEncoding.Utf8WithoutBom) + { + SetEncoding(TextEncoding.Utf8WithoutBom); + } + else + { + SetEncoding(TextEncoding.Utf8WithBom); + } + } + else if (encoding == Encoding.UTF8) + { + if (File.Exists(_fileName) && FileUtil.HasUtf8Bom(fileName)) + { + SetEncoding(TextEncoding.Utf8WithBom); + } + else + { + SetEncoding(TextEncoding.Utf8WithoutBom); + } + } + else + { + SetEncoding(encoding); + } + + _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + _converted = false; + ResetHistory(); + SetListViewStateImages(); + SetUndockedWindowsTitle(); + + if (justConverted) + { + _converted = true; + ShowStatus(string.Format(_language.LoadedSubtitleX, _fileName) + " - " + string.Format(_language.ConvertedToX, format.FriendlyName)); + } + + var formatType = format.GetType(); + if (formatType == typeof(SubStationAlpha)) + { + string errors = AdvancedSubStationAlpha.CheckForErrors(_subtitle.Header); + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(this, errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + + errors = (format as SubStationAlpha).Errors; + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(this, errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else if (formatType == typeof(AdvancedSubStationAlpha)) + { + string errors = AdvancedSubStationAlpha.CheckForErrors(_subtitle.Header); + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(this, errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + + errors = (format as AdvancedSubStationAlpha).Errors; + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(this, errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else if (formatType == typeof(SubRip)) + { + string errors = (format as SubRip).Errors; + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(this, errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else if (formatType == typeof(MicroDvd)) + { + string errors = (format as MicroDvd).Errors; + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(this, errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else if (formatType == typeof(DCinemaSmpte2007)) + { + format.ToText(_subtitle, string.Empty); + string errors = (format as DCinemaSmpte2007).Errors; + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else if (formatType == typeof(DCinemaSmpte2010)) + { + format.ToText(_subtitle, string.Empty); + string errors = (format as DCinemaSmpte2010).Errors; + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else if (formatType == typeof(DCinemaSmpte2014)) + { + format.ToText(_subtitle, string.Empty); + string errors = (format as DCinemaSmpte2014).Errors; + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else if (formatType == typeof(CsvNuendo)) + { + if (_subtitle.Paragraphs.Any(p => !string.IsNullOrEmpty(p.Actor))) + { + bool wasVisible = SubtitleListview1.ColumnIndexActor >= 0; + SubtitleListview1.ShowActorColumn(Configuration.Settings.Language.General.Character); + if (!wasVisible) + { + SaveSubtitleListviewIndices(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + } + } + else + { + if (file.Length < 50) + { + _findHelper = null; + _spellCheckForm = null; + VideoFileName = null; + _videoInfo = null; + VideoAudioTrackNumber = -1; + labelVideoInfo.Text = _languageGeneral.NoVideoLoaded; + audioVisualizer.WavePeaks = null; + audioVisualizer.SetSpectrogram(null); + audioVisualizer.SceneChanges = new List(); + audioVisualizer.Chapters = new List(); + + Configuration.Settings.RecentFiles.Add(fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + Configuration.Settings.Save(); + UpdateRecentFilesUI(); + _fileName = fileName; + SetTitle(); + ShowStatus(string.Format(_language.LoadedEmptyOrShort, _fileName)); + _sourceViewChange = false; + _converted = false; + + MessageBox.Show(_language.FileIsEmptyOrShort); + } + else + { + if (ShowUnknownSubtitle(fileName, true)) + { + ImportPlainText(fileName); + } + + return; + } + } + + if (!videoFileLoaded && mediaPlayer.VideoPlayer != null) + { + mediaPlayer.PauseAndDisposePlayer(); + timer1.Stop(); + } + + ResetShowEarlierOrLater(); + FixRightToLeftDependingOnLanguage(); + } + + private void ShowHideTextBasedFeatures(SubtitleFormat format) + { + textBoxSource.Enabled = format?.IsTextBased == true; + } + + private void SetUndockedWindowsTitle() + { + string title = _languageGeneral.NoVideoLoaded; + if (!string.IsNullOrEmpty(VideoFileName)) + { + title = Path.GetFileNameWithoutExtension(VideoFileName); + } + + if (_videoControlsUndocked != null && !_videoControlsUndocked.IsDisposed) + { + _videoControlsUndocked.Text = string.Format(_languageGeneral.ControlsWindowTitle, title); + } + + if (_videoPlayerUndocked != null && !_videoPlayerUndocked.IsDisposed) + { + _videoPlayerUndocked.Text = string.Format(_languageGeneral.VideoWindowTitle, title); + } + + if (_waveformUndocked != null && !_waveformUndocked.IsDisposed) + { + _waveformUndocked.Text = string.Format(_languageGeneral.AudioWindowTitle, title); + } + } + + private void ImportAndOcrBdnXml(string fileName, BdnXml bdnXml, List list) + { + using (var formSubOcr = new VobSubOcr()) + { + var bdnSubtitle = new Subtitle(); + bdnXml.LoadSubtitle(bdnSubtitle, list, fileName); + bdnSubtitle.FileName = fileName; + formSubOcr.Initialize(bdnSubtitle, Configuration.Settings.VobSubOcr, false); + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportingBdnXml); + FileNew(); + _subtitle.Paragraphs.Clear(); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = Path.ChangeExtension(formSubOcr.FileName, GetCurrentSubtitleFormat().Extension); + SetTitle(); + _converted = true; + } + } + } + + private void ImportAndOcrSon(string fileName, Son format, List list) + { + using (var formSubOcr = new VobSubOcr()) + { + var sub = new Subtitle(); + format.LoadSubtitle(sub, list, fileName); + sub.FileName = fileName; + formSubOcr.Initialize(sub, Configuration.Settings.VobSubOcr, true); + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportingBdnXml); + FileNew(); + _subtitle.Paragraphs.Clear(); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = Path.ChangeExtension(formSubOcr.FileName, GetCurrentSubtitleFormat().Extension); + SetTitle(); + _converted = true; + } + } + } + + private void ImportAndOcrDost(string fileName, SubtitleFormat format, List list) + { + using (var formSubOcr = new VobSubOcr()) + { + var sub = new Subtitle(); + format.LoadSubtitle(sub, list, fileName); + sub.FileName = fileName; + formSubOcr.Initialize(sub, Configuration.Settings.VobSubOcr, false); + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportingBdnXml); + FileNew(); + _subtitle.Paragraphs.Clear(); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = Path.ChangeExtension(formSubOcr.FileName, GetCurrentSubtitleFormat().Extension); + SetTitle(); + _converted = true; + } + } + } + + private void ImportAndOcrSst(string fileName, SonicScenaristBitmaps format, List list) + { + using (var formSubOcr = new VobSubOcr()) + { + var sub = new Subtitle(); + format.LoadSubtitle(sub, list, fileName); + sub.FileName = fileName; + formSubOcr.Initialize(sub, Configuration.Settings.VobSubOcr, true); + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportingBdnXml); + FileNew(); + _subtitle.Paragraphs.Clear(); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = Path.ChangeExtension(formSubOcr.FileName, GetCurrentSubtitleFormat().Extension); + SetTitle(); + _converted = true; + } + } + } + + private void ImportAndOcrSrt(Subtitle subtitle) + { + using (var formSubOcr = new VobSubOcr()) + { + formSubOcr.Initialize(subtitle, Configuration.Settings.VobSubOcr, false); + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportingBdnXml); + FileNew(); + _subtitle.Paragraphs.Clear(); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = Path.ChangeExtension(formSubOcr.FileName, GetCurrentSubtitleFormat().Extension); + SetTitle(); + _converted = true; + } + } + } + + private bool ShowUnknownSubtitle(string fileName, bool allowImportPlainText = false) + { + using (var unknownSubtitle = new UnknownSubtitle()) + { + unknownSubtitle.Initialize(Title, fileName, allowImportPlainText); + unknownSubtitle.ShowDialog(this); + return unknownSubtitle.ImportPlainText; + } + } + + private void UpdateRecentFilesUI() + { + var dropDownItems = new List(); + reopenToolStripMenuItem.DropDownItems.Clear(); + if (Configuration.Settings.General.ShowRecentFiles && Configuration.Settings.RecentFiles.Files.Count > 0) + { + reopenToolStripMenuItem.Visible = true; + var lowerFileNameList = new List(); + foreach (var file in Configuration.Settings.RecentFiles.Files) + { + if (!string.IsNullOrEmpty(file.OriginalFileName) && File.Exists(file.OriginalFileName)) + { + dropDownItems.Add(new ToolStripMenuItem(file.FileName + " + " + file.OriginalFileName, null, ReopenSubtitleToolStripMenuItemClick) { Tag = file.FileName }); + } + else + { + if (!lowerFileNameList.Contains(file.FileName.ToLowerInvariant())) + { + dropDownItems.Add(new ToolStripMenuItem(file.FileName, null, ReopenSubtitleToolStripMenuItemClick) { Tag = file.FileName }); + lowerFileNameList.Add(file.FileName.ToLowerInvariant()); + } + } + UiUtil.FixFonts(dropDownItems[dropDownItems.Count - 1]); + } + reopenToolStripMenuItem.DropDownItems.AddRange(dropDownItems.ToArray()); + } + else + { + Configuration.Settings.RecentFiles.Files.Clear(); + reopenToolStripMenuItem.Visible = false; + } + + reopenToolStripMenuItem.Visible = reopenToolStripMenuItem.DropDownItems.Count > 0; + } + + private void RemoveNotExistingFilesFromRecentFilesUI() + { + if (!Configuration.Settings.General.ShowRecentFiles || Configuration.Settings.RecentFiles.Files.Count == 0) + { + return; + } + + var bw = new BackgroundWorker(); + bw.DoWork += (sender, args) => + { + var recentFilesList = (List)args.Argument; + var notExistingFiles = new List(); + foreach (var entry in recentFilesList) + { + if (!File.Exists(entry.FileName)) + { + notExistingFiles.Add(entry.FileName); + } + } + + args.Result = notExistingFiles; + }; + bw.RunWorkerCompleted += (sender, args) => + { + var notExistingFiles = (List)args.Result; + if (notExistingFiles.Count == 0) + { + return; + } + + try + { + Configuration.Settings.RecentFiles.Files = Configuration.Settings.RecentFiles.Files + .Where(p => !notExistingFiles.Contains(p.FileName)).ToList(); + for (var index = reopenToolStripMenuItem.DropDownItems.Count - 1; index >= 0; index--) + { + ToolStripItem item = reopenToolStripMenuItem.DropDownItems[index]; + if (notExistingFiles.Contains((string)item.Tag)) + { + reopenToolStripMenuItem.DropDownItems.RemoveAt(index); + } + } + } + catch + { + // ignore + } + }; + bw.RunWorkerAsync(Configuration.Settings.RecentFiles.Files); + } + + private void ReopenSubtitleToolStripMenuItemClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + var item = sender as ToolStripItem; + + if (ContinueNewOrExit()) + { + if (!string.IsNullOrEmpty(_fileName)) + { + Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + } + + RecentFileEntry rfe = null; + foreach (var file in Configuration.Settings.RecentFiles.Files.Where(p => !string.IsNullOrEmpty(p.OriginalFileName))) + { + if ((file.FileName + " + " + file.OriginalFileName).Equals(item.Text, StringComparison.OrdinalIgnoreCase)) + { + rfe = file; + break; + } + } + + if (rfe == null) + { + foreach (var file in Configuration.Settings.RecentFiles.Files.Where(p => string.IsNullOrEmpty(p.OriginalFileName))) + { + if (file.FileName.Equals(item.Text, StringComparison.OrdinalIgnoreCase)) + { + rfe = file; + RemoveAlternate(true, false); + break; + } + } + } + + SubtitleListview1.BeginUpdate(); + if (rfe == null) + { + OpenSubtitle(item.Text, null); + } + else + { + OpenRecentFile(rfe); + } + + GotoSubPosAndPause(); + SetRecentIndices(rfe); + SubtitleListview1.EndUpdate(); + if (rfe != null && !string.IsNullOrEmpty(rfe.VideoFileName)) + { + var p = _subtitle.GetParagraphOrDefault(rfe.FirstSelectedIndex); + if (p != null) + { + mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; + } + } + } + } + + private void OpenRecentFile(RecentFileEntry rfe) + { + OpenSubtitle(rfe.FileName, null, rfe.VideoFileName, rfe.OriginalFileName, false); + Configuration.Settings.General.CurrentVideoOffsetInMs = rfe.VideoOffsetInMs; + if (rfe.VideoOffsetInMs != 0) + { + _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-Configuration.Settings.General.CurrentVideoOffsetInMs)); + _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + _subtitleAlternate.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-Configuration.Settings.General.CurrentVideoOffsetInMs)); + _changeAlternateSubtitleHash = _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + else + { + SubtitleListview1.Fill(_subtitle); + } + } + } + + private void GotoSubPosAndPause() + { + if (!string.IsNullOrEmpty(VideoFileName)) + { + _videoLoadedGoToSubPosAndPause = true; + } + else + { + mediaPlayer.SubtitleText = string.Empty; + } + } + + private void SetRecentIndices(RecentFileEntry rfe) + { + if (!Configuration.Settings.General.RememberSelectedLine) + { + return; + } + + ShowSubtitleTimer.Stop(); + Application.DoEvents(); + if (rfe != null && !string.IsNullOrEmpty(rfe.FileName) && + rfe.FirstSelectedIndex >= 0 && rfe.FirstSelectedIndex < SubtitleListview1.Items.Count) + { + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + SubtitleListview1.SelectIndexAndEnsureVisible(rfe.FirstSelectedIndex, true); + _subtitleListViewIndex = -1; + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + RefreshSelectedParagraph(); + } + + if (!_loading) + { + ShowSubtitleTimer.Start(); + } + } + + private void SaveToolStripMenuItemClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + return; + } + + ReloadFromSourceView(); + _saveAsCalled = false; + SaveSubtitle(GetCurrentSubtitleFormat()); + } + + private void SaveAsToolStripMenuItemClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + return; + } + + ReloadFromSourceView(); + FileSaveAs(true); + } + + private DialogResult FileSaveAs(bool allowUsingLastSaveAsFormat) + { + SubtitleFormat currentFormat = null; + if (allowUsingLastSaveAsFormat && !string.IsNullOrEmpty(Configuration.Settings.General.LastSaveAsFormat)) + { + currentFormat = Utilities.GetSubtitleFormatByFriendlyName(Configuration.Settings.General.LastSaveAsFormat); + } + + if (currentFormat == null) + { + currentFormat = GetCurrentSubtitleFormat(); + } + + UiUtil.SetSaveDialogFilter(saveFileDialog1, currentFormat); + + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*" + currentFormat.Extension; + saveFileDialog1.AddExtension = true; + + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + if (!string.IsNullOrWhiteSpace(_fileName) && Configuration.Settings.General.SaveAsUseFileNameFrom.Equals("file", StringComparison.OrdinalIgnoreCase)) + { + saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(_fileName); + saveFileDialog1.InitialDirectory = Path.GetDirectoryName(_fileName); + } + else if (!string.IsNullOrEmpty(VideoFileName) && Configuration.Settings.General.SaveAsUseFileNameFrom.Equals("video", StringComparison.OrdinalIgnoreCase)) + { + if (_converted && !string.IsNullOrEmpty(_fileName) && !File.Exists(_fileName)) + { + saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(_fileName); + } + else + { + saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(VideoFileName); + } + + saveFileDialog1.InitialDirectory = Path.GetDirectoryName(VideoFileName); + } + else if (!string.IsNullOrWhiteSpace(_fileName)) + { + saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(_fileName); + saveFileDialog1.InitialDirectory = Path.GetDirectoryName(_fileName); + } + else if (!string.IsNullOrEmpty(VideoFileName)) + { + saveFileDialog1.FileName = Utilities.GetFileNameWithoutExtension(VideoFileName); + saveFileDialog1.InitialDirectory = Path.GetDirectoryName(VideoFileName); + } + else + { + saveFileDialog1.FileName = string.Empty; + } + + if (!string.IsNullOrEmpty(saveFileDialog1.FileName) && + saveFileDialog1.FileName.Contains('.') && + !saveFileDialog1.FileName.EndsWith(currentFormat.Extension, StringComparison.OrdinalIgnoreCase)) + { + saveFileDialog1.FileName = saveFileDialog1.FileName + currentFormat.Extension; + } + + var result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + _converted = false; + _fileName = saveFileDialog1.FileName; + _fileDateTime = File.GetLastWriteTime(_fileName); + SetTitle(); + MakeHistoryForUndo(_language.Menu.File.SaveAs); + + int index = 0; + foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) + { + if (saveFileDialog1.FilterIndex == index + 1) + { + // only allow current extension or ".txt" + string ext = Path.GetExtension(_fileName).ToLowerInvariant(); + bool extOk = ext.Equals(format.Extension, StringComparison.OrdinalIgnoreCase) || format.AlternateExtensions.Contains(ext) || ext == ".txt"; + if (!extOk) + { + if (_fileName.EndsWith('.')) + { + _fileName = _fileName.Substring(0, _fileName.Length - 1); + } + + _fileName += format.Extension; + } + + _saveAsCalled = true; + if (SaveSubtitle(format) == DialogResult.OK) + { + Configuration.Settings.General.LastSaveAsFormat = format.Name; + SetCurrentFormat(format); + Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + Configuration.Settings.Save(); + UpdateRecentFilesUI(); + } + + break; + } + + index++; + } + + _converted = false; + } + + return result; + } + + private DialogResult SaveSubtitle(SubtitleFormat format, bool useNewLineWithOnly0A = false, bool skipPrompts = false) + { + if (string.IsNullOrEmpty(_fileName) || _converted) + { + return FileSaveAs(false); + } + + try + { + var sub = GetSaveSubtitle(_subtitle); + + if (format != null && !format.IsTextBased) + { + if (format is Ebu ebu) + { + var header = new Ebu.EbuGeneralSubtitleInformation(); + if (_subtitle != null && _subtitle.Header != null && (_subtitle.Header.Contains("STL2") || _subtitle.Header.Contains("STL3"))) + { + header = Ebu.ReadHeader(Encoding.UTF8.GetBytes(_subtitle.Header)); + } + + if (ebu.Save(_fileName, sub, !_saveAsCalled, header)) + { + _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + Configuration.Settings.Save(); + } + } + + return DialogResult.OK; + } + + string allText = sub.ToText(format); + + // Seungki begin + if (_splitDualSami && _subtitleAlternate?.Paragraphs.Count > 0) + { + var s = new Subtitle(_subtitle); + foreach (var p in _subtitleAlternate.Paragraphs) + { + s.Paragraphs.Add(p); + } + + allText = s.ToText(format); + } + // Seungki end + + var currentEncoding = GetCurrentEncoding(); + bool isUnicode = currentEncoding.Equals(Encoding.Unicode) || currentEncoding.Equals(Encoding.UTF32) || currentEncoding.Equals(Encoding.GetEncoding(12001)) || currentEncoding.Equals(Encoding.UTF7) || currentEncoding.Equals(Encoding.UTF8); + if (!isUnicode) + { + if (!skipPrompts && currentEncoding.GetString(currentEncoding.GetBytes(allText)) != allText) + { + if (MessageBox.Show(string.Format(_language.UnicodeMusicSymbolsAnsiWarning), Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return DialogResult.No; + } + } + + allText = NormalizeUnicode(allText, currentEncoding); + } + + bool containsNegativeTime = false; + var negativeTimeLines = new List(); + foreach (var p in sub.Paragraphs) + { + if (p.StartTime.TotalMilliseconds < 0 || p.EndTime.TotalMilliseconds < 0) + { + containsNegativeTime = true; + negativeTimeLines.Add(sub.Paragraphs.IndexOf(p).ToString(CultureInfo.InvariantCulture)); + if (negativeTimeLines.Count > 10) + { + negativeTimeLines[negativeTimeLines.Count - 1] = negativeTimeLines[negativeTimeLines.Count - 1] + "..."; + break; + } + } + } + + if (containsNegativeTime && !skipPrompts) + { + if (MessageBox.Show(_language.NegativeTimeWarning + Environment.NewLine + + string.Format(Configuration.Settings.Language.MultipleReplace.LinesFoundX, string.Join(", ", negativeTimeLines)), + Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return DialogResult.No; + } + } + + if (!skipPrompts && File.Exists(_fileName)) + { + var fileInfo = new FileInfo(_fileName); + var fileOnDisk = fileInfo.LastWriteTime; + if (_fileDateTime != fileOnDisk && _fileDateTime != new DateTime()) + { + if (MessageBox.Show(string.Format(_language.OverwriteModifiedFile, + _fileName, fileOnDisk.ToShortDateString(), fileOnDisk.ToString("HH:mm:ss"), + Environment.NewLine, _fileDateTime.ToShortDateString(), _fileDateTime.ToString("HH:mm:ss")), + Title + " - " + _language.FileOnDiskModified, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return DialogResult.No; + } + } + + if (fileInfo.IsReadOnly) + { + MessageBox.Show(string.Format(_language.FileXIsReadOnly, _fileName)); + return DialogResult.No; + } + } + + // force encoding + var formatType = format.GetType(); + if (formatType == typeof(WebVTT) || formatType == typeof(WebVTTFileWithLineNumber)) + { + SetEncoding(Encoding.UTF8); + currentEncoding = Encoding.UTF8; + } + else if (formatType == typeof(SwiftInterchange2)) + { + SetEncoding(Encoding.Unicode); + currentEncoding = Encoding.Unicode; + } + + if (Configuration.Settings.General.ShowFormatRequiresUtf8Warning && !currentEncoding.Equals(Encoding.UTF8) && + (formatType == typeof(DCinemaInterop) || formatType == typeof(DCinemaSmpte2007) || + formatType == typeof(DCinemaSmpte2010) || formatType == typeof(DCinemaSmpte2014))) + { + using (var form = new DialogDoNotShowAgain(Title, string.Format(_language.FormatXShouldUseUft8, GetCurrentSubtitleFormat().FriendlyName))) + { + form.ShowDialog(this); + Configuration.Settings.General.ShowFormatRequiresUtf8Warning = !form.DoNoDisplayAgain; + } + } + + if (format.Extension == ".rtf" || formatType == typeof(ProjectionSubtitleList)) + { + var enc = GetCurrentEncoding(); + if (enc != Encoding.ASCII) + { + var oldDisableShowStatus = _disableShowStatus; + _disableShowStatus = false; + ShowStatus("ASCII encoding used for save"); + _disableShowStatus = oldDisableShowStatus; + currentEncoding = Encoding.ASCII; + } + } + + if (useNewLineWithOnly0A) + { + allText = allText.Replace("\r\n", "\n"); + } + + if (formatType == typeof(ItunesTimedText) || formatType == typeof(ScenaristClosedCaptions) || formatType == typeof(ScenaristClosedCaptionsDropFrame)) + { + var outputEnc = new UTF8Encoding(false); // create encoding with no BOM + using (var file = new StreamWriter(_fileName, false, outputEnc)) // open file with encoding + { + file.Write(allText); + } + } + else if (Equals(currentEncoding, Encoding.UTF8) && (formatType == typeof(TmpegEncAW5) || formatType == typeof(TmpegEncXml))) + { + var outputEnc = new UTF8Encoding(false); // create encoding with no BOM + using (var file = new StreamWriter(_fileName, false, outputEnc)) // open file with encoding + { + file.Write(allText); + } + } + else + { + if (string.IsNullOrWhiteSpace(allText)) + { + MessageBox.Show(string.Format(_language.UnableToSaveSubtitleX, _fileName), String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Stop); + return DialogResult.Cancel; + } + + if (comboBoxEncoding.SelectedIndex == TextEncoding.Utf8WithoutBomIndex) + { + var outputEnc = new UTF8Encoding(false); // create encoding with no BOM + using (var file = new StreamWriter(_fileName, false, outputEnc)) // open file with encoding + { + file.Write(allText); + } + } + else + { + // create file - includes BOM for Unicode formats + using (var fs = new FileStream(_fileName, FileMode.Create, FileAccess.Write, FileShare.Read)) + using (var sw = new StreamWriter(fs, currentEncoding)) + { + sw.Write(allText); + } + } + } + + Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + Configuration.Settings.Save(); + new BookmarkPersistence(_subtitle, _fileName).Save(); + _fileDateTime = File.GetLastWriteTime(_fileName); + ShowStatus(string.Format(_language.SavedSubtitleX, _fileName)); + if (formatType == typeof(NetflixTimedText)) + { + NetflixGlyphCheck(true); + } + + _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + return DialogResult.OK; + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + return DialogResult.Cancel; + } + } + + private DialogResult SaveOriginalSubtitle(SubtitleFormat format, bool skipPrompts = false) + { + try + { + var subAlt = GetSaveSubtitle(_subtitleAlternate); + + bool containsNegativeTime = false; + foreach (var p in subAlt.Paragraphs) + { + if (p.StartTime.TotalMilliseconds < 0 || p.EndTime.TotalMilliseconds < 0) + { + containsNegativeTime = true; + break; + } + } + + if (!skipPrompts && containsNegativeTime) + { + if (MessageBox.Show(_language.NegativeTimeWarning, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return DialogResult.No; + } + } + + if (format != null && !format.IsTextBased) + { + if (format is Ebu ebu) + { + if (ebu.Save(_subtitleAlternateFileName, subAlt)) + { + Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + Configuration.Settings.Save(); + ShowStatus(string.Format(_language.SavedOriginalSubtitleX, _subtitleAlternateFileName)); + _changeAlternateSubtitleHash = _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName); + return DialogResult.OK; + } + + return DialogResult.No; + } + + MessageBox.Show("Ups - save original does not support this format - please go to Github and create an issue!"); + } + + string allText = subAlt.ToText(format); + var currentEncoding = GetCurrentEncoding(); + bool isUnicode = currentEncoding != null && (currentEncoding.Equals(Encoding.Unicode) || currentEncoding.Equals(Encoding.UTF32) || currentEncoding.Equals(Encoding.UTF7) || currentEncoding.Equals(Encoding.UTF8)); + if (!skipPrompts && !isUnicode && currentEncoding.GetString(currentEncoding.GetBytes(allText)) != allText) + { + if (MessageBox.Show(string.Format(_language.UnicodeMusicSymbolsAnsiWarning), Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return DialogResult.No; + } + } + + if (!isUnicode) + { + allText = NormalizeUnicode(allText, currentEncoding); + } + + File.WriteAllText(_subtitleAlternateFileName, allText, currentEncoding); + ShowStatus(string.Format(_language.SavedOriginalSubtitleX, _subtitleAlternateFileName)); + _changeAlternateSubtitleHash = _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName); + return DialogResult.OK; + } + catch + { + MessageBox.Show(string.Format(_language.UnableToSaveSubtitleX, _fileName)); + return DialogResult.Cancel; + } + } + + public string NormalizeUnicode(string input, Encoding encoding) + { + const char defHyphen = '-'; // - Hyphen-minus (\u002D) (Basic Latin) + const char defColon = ':'; // : Colon (\u003A) (Basic Latin) + + var text = input; + + bool hasSingleMusicNode = true; + if (encoding.GetString(encoding.GetBytes("♪")) != "♪") + { + text = text.Replace('♪', '#'); + hasSingleMusicNode = false; + } + + if (encoding.GetString(encoding.GetBytes("♫")) != "♫") + { + text = text.Replace('♫', hasSingleMusicNode ? '♪' : '#'); + } + + // Hyphens + return text.Replace('\u2043', defHyphen) // ⁃ Hyphen bullet (\u2043) + .Replace('\u2010', defHyphen) // ‐ Hyphen (\u2010) + .Replace('\u2012', defHyphen) // ‒ Figure dash (\u2012) + .Replace('\u2013', defHyphen) // – En dash (\u2013) + .Replace('\u2014', defHyphen) // — Em dash (\u2014) + .Replace('\u2015', defHyphen) // ― Horizontal bar (\u2015) + + // Colons: + .Replace('\u02F8', defColon) // ˸ Modifier Letter Raised Colon (\u02F8) + .Replace('\uFF1A', defColon) // : Fullwidth Colon (\uFF1A) + .Replace('\uFE13', defColon) // ︓ Presentation Form for Vertical Colon (\uFE13) + + // Others + .Replace("…", "...") + .Replace("⇒", "=>") + + // Spaces + .Replace('\u00A0', ' ') // No-Break Space + .Replace("\u200B", string.Empty) // Zero Width Space + .Replace("\uFEFF", string.Empty) // Zero Width No-Break Space + + // Intellectual property + .Replace("\u00A9", "(Copyright)") // © copyright + .Replace("\u2117", "(Sound-recording Copyright)") // ℗ sound-recording copyright + .Replace("\u00AE", "(Registered Trademark)") // ® registered trademark + .Replace("\u2120", "(Service Mark)") // ℠ service mark + .Replace("\u2122", "(Trademark)") // ™ trademark + + // RTL/LTR markers + .Replace("\u202B", string.Empty) // ‏ + .Replace("\u202A", string.Empty); // &lmr; + } + + private void NewToolStripMenuItemClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + FileNew(); + } + + private void ResetSubtitle(bool forceVideoReload = false) + { + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + + labelStartTimeWarning.Text = string.Empty; + labelDurationWarning.Text = string.Empty; + + Configuration.Settings.General.CurrentVideoOffsetInMs = 0; + _subtitle = new Subtitle(_subtitle.HistoryItems); + _changeAlternateSubtitleHash = -1; + _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + _subtitleAlternateFileName = null; + textBoxSource.Text = string.Empty; + SubtitleListview1.Items.Clear(); + _fileName = string.Empty; + _fileDateTime = new DateTime(); + _oldSubtitleFormat = null; + labelSingleLine.Text = string.Empty; + buttonSplitLine.Visible = false; + labelSingleLinePixels.Text = string.Empty; + RemoveAlternate(true, false); + _splitDualSami = false; + + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); + + var oldDisableShowStatus = _disableShowStatus; + _disableShowStatus = true; + ComboBoxSubtitleFormatsSelectedIndexChanged(null, null); + _disableShowStatus = oldDisableShowStatus; + + SetEncoding(Configuration.Settings.General.DefaultEncoding); + + toolStripComboBoxFrameRate.Text = Configuration.Settings.General.DefaultFrameRate.ToString(); + _findHelper = null; + _spellCheckForm = null; + + if (ModifierKeys != Keys.Shift || forceVideoReload) + { + VideoFileName = null; + _videoInfo = null; + VideoAudioTrackNumber = -1; + labelVideoInfo.Text = _languageGeneral.NoVideoLoaded; + audioVisualizer.WavePeaks = null; + audioVisualizer.SetSpectrogram(null); + audioVisualizer.SceneChanges = new List(); + audioVisualizer.Chapters = new List(); + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.PauseAndDisposePlayer(); + } + + timeUpDownVideoPositionAdjust.TimeCode = new TimeCode(); + timeUpDownVideoPositionAdjust.Enabled = false; + timeUpDownVideoPosition.TimeCode = new TimeCode(); + timeUpDownVideoPosition.Enabled = false; + trackBarWaveformPosition.Value = 0; + timeUpDownStartTime.TimeCode = new TimeCode(); + numericUpDownDuration.Value = 0; + } + + _sourceViewChange = false; + + _subtitleListViewIndex = -1; + textBoxListViewText.Text = string.Empty; + textBoxListViewTextAlternate.Text = string.Empty; + textBoxListViewText.Enabled = false; + textBoxListViewText.BackColor = SystemColors.ActiveBorder; + textBoxListViewTextAlternate.BackColor = SystemColors.ActiveBorder; + labelTextLineLengths.Text = string.Empty; + labelCharactersPerSecond.Text = string.Empty; + labelTextLineTotal.Text = string.Empty; + + _listViewTextUndoLast = null; + _listViewAlternateTextUndoLast = null; + _listViewTextUndoIndex = -1; + + _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + _converted = false; + + SetTitle(); + SetUndockedWindowsTitle(); + mediaPlayer.SubtitleText = string.Empty; + labelNextWord.Visible = false; + ShowStatus(_language.New); + + ResetShowEarlierOrLater(); + + // Set default RTL or LTR + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + textBoxListViewTextAlternate.RightToLeft = Configuration.Settings.General.RightToLeftMode ? RightToLeft.Yes : RightToLeft.No; + } + + if (Configuration.Settings.General.RightToLeftMode) + { + textBoxListViewText.RightToLeft = RightToLeft.Yes; + textBoxSource.RightToLeft = RightToLeft.Yes; + } + else + { + textBoxListViewText.RightToLeft = RightToLeft.No; + textBoxSource.RightToLeft = RightToLeft.No; + } + + SetListViewStateImages(); + pictureBoxBookmark.Visible = false; + panelBookmark.Hide(); + } + + private void ResetShowEarlierOrLater() + { + try + { + if (_showEarlierOrLater != null && !_showEarlierOrLater.IsDisposed) + { + _showEarlierOrLater.ResetTotalAdjustment(); + } + } + catch + { + // form closing or alike + } + } + + private void FileNew() + { + if (ContinueNewOrExit()) + { + if (Configuration.Settings.General.ShowRecentFiles) + { + Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + } + + MakeHistoryForUndo(_language.BeforeNew); + ResetSubtitle(true); + } + } + + private void ComboBoxSubtitleFormatsSelectedIndexChanged(object sender, EventArgs e) + { + if (IsMenuOpen) + { + return; + } + + _converted = true; + var format = GetCurrentSubtitleFormat(); + if (format == null) + { + format = new SubRip(); + } + var formatType = format.GetType(); + + if (_oldSubtitleFormat == null) + { + if (!_loading) + { + MakeHistoryForUndo(string.Format(_language.BeforeConvertingToX, format.FriendlyName)); + } + } + else + { + _subtitle.MakeHistoryForUndo(string.Format(_language.BeforeConvertingToX, format.FriendlyName), _oldSubtitleFormat, _fileDateTime, _subtitleAlternate, _subtitleAlternateFileName, _subtitleListViewIndex, textBoxListViewText.SelectionStart, textBoxListViewTextAlternate.SelectionStart); + _oldSubtitleFormat.RemoveNativeFormatting(_subtitle, format); + SaveSubtitleListviewIndices(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + + if (_oldSubtitleFormat.HasStyleSupport) + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); + } + + if (_networkSession == null) + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Network); + } + + if (formatType == typeof(AdvancedSubStationAlpha) && _oldSubtitleFormat.GetType() == typeof(SubStationAlpha)) + { + _subtitle.Header = AdvancedSubStationAlpha.GetHeaderAndStylesFromSubStationAlpha(_subtitle.Header); + } + else if (formatType == typeof(SubStationAlpha) && _oldSubtitleFormat.GetType() == typeof(AdvancedSubStationAlpha)) + { + _subtitle.Header = SubStationAlpha.GetHeaderAndStylesFromAdvancedSubStationAlpha(_subtitle.Header, string.Empty); + } + } + + ShowSource(); + ShowStatus(string.Format(_language.ConvertedToX, format.FriendlyName)); + if (_fileName != null && _oldSubtitleFormat != null && _fileName.EndsWith(_oldSubtitleFormat.Extension, StringComparison.Ordinal)) + { + _fileName = _fileName.Substring(0, _fileName.Length - _oldSubtitleFormat.Extension.Length) + format.Extension; + } + + _oldSubtitleFormat = format; + Configuration.Settings.General.LastSaveAsFormat = format.Name; + + if ((formatType == typeof(AdvancedSubStationAlpha) || + formatType == typeof(SubStationAlpha) || + formatType == typeof(CsvNuendo)) && (_subtitle.Paragraphs.Any(p => !string.IsNullOrEmpty(p.Actor)) || + Configuration.Settings.Tools.ListViewShowColumnActor)) + { + bool wasVisible = SubtitleListview1.ColumnIndexActor >= 0; + if (formatType == typeof(CsvNuendo)) + { + SubtitleListview1.ShowActorColumn(Configuration.Settings.Language.General.Character); + } + else + { + SubtitleListview1.ShowActorColumn(Configuration.Settings.Language.General.Actor); + } + + if (!wasVisible) + { + SaveSubtitleListviewIndices(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Actor); + } + + if (formatType == typeof(TimedText10) && Configuration.Settings.Tools.ListViewShowColumnRegion) + { + SubtitleListview1.ShowRegionColumn(Configuration.Settings.Language.General.Region); + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Region); + } + + if (format.HasStyleSupport) + { + var styles = new List(); + if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha)) + { + styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); + } + else if (formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText)) + { + styles = TimedText10.GetStylesFromHeader(_subtitle.Header); + } + else if (formatType == typeof(Sami) || formatType == typeof(SamiModern)) + { + styles = Sami.GetStylesFromHeader(_subtitle.Header); + if (string.IsNullOrEmpty(_subtitle.Header)) + { + styles = Sami.GetStylesFromSubtitle(_subtitle); + } + else + { + styles = Sami.GetStylesFromHeader(_subtitle.Header); + } + } + else if (format.Name == "Nuendo") + { + styles = GetNuendoStyles(); + } + + if (styles.Count > 0) + { + foreach (var p in _subtitle.Paragraphs) + { + if (string.IsNullOrEmpty(p.Extra)) + { + p.Extra = styles[0]; + } + } + } + + if (formatType == typeof(Sami) || formatType == typeof(SamiModern)) + { + SubtitleListview1.ShowExtraColumn(_languageGeneral.Class); + } + else if (formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText)) + { + SubtitleListview1.ShowExtraColumn(_languageGeneral.StyleLanguage); + } + else if (format.Name == "Nuendo") + { + SubtitleListview1.ShowExtraColumn(_languageGeneral.Character); + } + else + { + SubtitleListview1.ShowExtraColumn(_languageGeneral.Style); + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + ShowHideTextBasedFeatures(format); + + UpdateNetflixGlyphCheckToolsVisibility(); + } + + private static List GetNuendoStyles() + { + if (!string.IsNullOrEmpty(Configuration.Settings.SubtitleSettings.NuendoCharacterListFile) && File.Exists(Configuration.Settings.SubtitleSettings.NuendoCharacterListFile)) + { + return NuendoProperties.LoadCharacters(Configuration.Settings.SubtitleSettings.NuendoCharacterListFile); + } + + return new List(); + } + + private void ComboBoxSubtitleFormatsEnter(object sender, EventArgs e) + { + SubtitleFormat format = GetCurrentSubtitleFormat(); + if (format != null) + { + _oldSubtitleFormat = format; + } + } + + private SubtitleFormat GetCurrentSubtitleFormat() + { + return Utilities.GetSubtitleFormatByFriendlyName(comboBoxSubtitleFormats.SelectedItem.ToString()); + } + + private void ShowSource() + { + if (_subtitle != null && _subtitle.Paragraphs.Count > 0) + { + SubtitleFormat format = GetCurrentSubtitleFormat(); + if (format != null) + { + textBoxSource.TextChanged -= TextBoxSourceTextChanged; + textBoxSource.Text = GetSaveSubtitle(_subtitle).ToText(format); + textBoxSource.TextChanged += TextBoxSourceTextChanged; + return; + } + } + + textBoxSource.TextChanged -= TextBoxSourceTextChanged; + textBoxSource.Text = string.Empty; + textBoxSource.TextChanged += TextBoxSourceTextChanged; + } + + private void SettingsToolStripMenuItemClick(object sender, EventArgs e) + { + ShowSettings(); + } + + private void ShowSettings() + { + string oldVideoPlayer = Configuration.Settings.General.VideoPlayer; + string oldMpvVideoOutput = Configuration.Settings.General.MpvVideoOutputWindows; + string oldListViewLineSeparatorString = Configuration.Settings.General.ListViewLineSeparatorString; + var oldCpsWhiteSpaceSetting = Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace; + string oldSubtitleFontSettings = Configuration.Settings.General.SubtitleFontName + + Configuration.Settings.General.SubtitleTextBoxFontBold + + Configuration.Settings.General.CenterSubtitleInTextBox + + Configuration.Settings.General.SubtitleTextBoxFontSize + + Configuration.Settings.General.SubtitleFontColor.ToArgb() + + Configuration.Settings.General.SubtitleBackgroundColor.ToArgb() + + Configuration.Settings.General.SubtitleListViewFontBold.ToString() + + Configuration.Settings.General.SubtitleListViewFontSize; + + ; + bool oldUseTimeFormatHHMMSSFF = Configuration.Settings.General.UseTimeFormatHHMMSSFF; + + string oldSyntaxColoring = Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall.ToString() + + Configuration.Settings.Tools.ListViewSyntaxColorDurationBig + + Configuration.Settings.Tools.ListViewSyntaxColorLongLines + + Configuration.Settings.Tools.ListViewSyntaxColorOverlap + + Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines + + Configuration.Settings.General.MaxNumberOfLines + + Configuration.Settings.Tools.ListViewSyntaxErrorColor.ToArgb(); + + var oldAllowEditOfOriginalSubtitle = Configuration.Settings.General.AllowEditOfOriginalSubtitle; + var oldShowColumnEndTime = Configuration.Settings.Tools.ListViewShowColumnEndTime; + var oldShowcolumnDuration = Configuration.Settings.Tools.ListViewShowColumnDuration; + var oldShowColumnCharsPerSec = Configuration.Settings.Tools.ListViewShowColumnCharsPerSec; + var oldShowWordsMinColumn = Configuration.Settings.Tools.ListViewShowColumnWordsPerMin; + var oldSubtitleTextBoxSyntaxColor = Configuration.Settings.General.SubtitleTextBoxSyntaxColor; + var oldSubtitleFontSize = Configuration.Settings.General.SubtitleTextBoxFontSize; + var oldSubtitleTextBoxHtmlColor = Configuration.Settings.General.SubtitleTextBoxHtmlColor.ToArgb().ToString(); + var oldSubtitleTextBoxAssaColor = Configuration.Settings.General.SubtitleTextBoxAssColor.ToArgb().ToString(); + using (var settings = new Settings()) + { + settings.Initialize(Icon, toolStripButtonFileNew.Image, toolStripButtonFileOpen.Image, toolStripButtonSave.Image, toolStripButtonSaveAs.Image, toolStripButtonFind.Image, + toolStripButtonReplace.Image, toolStripButtonFixCommonErrors.Image, toolStripButtonRemoveTextForHi.Image, toolStripButtonVisualSync.Image, + toolStripButtonSpellCheck.Image, toolStripButtonNetflixQualityCheck.Image, toolStripButtonSettings.Image, toolStripButtonHelp.Image); + + if (settings.ShowDialog(this) == DialogResult.Cancel) + { + return; // settings update canceled + } + } + + try + { // can have some problems with fonts... + UiUtil.InitializeSubtitleFont(textBoxSource); + UiUtil.InitializeSubtitleFont(textBoxListViewText); + UiUtil.InitializeSubtitleFont(textBoxListViewTextAlternate); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + InitializeToolbar(); + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception.Message + Environment.NewLine + exception.StackTrace); + } + + UpdateRecentFilesUI(); + buttonCustomUrl1.Text = Configuration.Settings.VideoControls.CustomSearchText1; + buttonCustomUrl1.Visible = Configuration.Settings.VideoControls.CustomSearchUrl1.Length > 1; + buttonCustomUrl2.Text = Configuration.Settings.VideoControls.CustomSearchText2; + buttonCustomUrl2.Visible = Configuration.Settings.VideoControls.CustomSearchUrl2.Length > 1; + + SetAudioVisualizerSettings(); + + string newSyntaxColoring = Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall.ToString() + + Configuration.Settings.Tools.ListViewSyntaxColorDurationBig + + Configuration.Settings.Tools.ListViewSyntaxColorLongLines + + Configuration.Settings.Tools.ListViewSyntaxColorOverlap + + Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines + + Configuration.Settings.General.MaxNumberOfLines + + Configuration.Settings.Tools.ListViewSyntaxErrorColor.ToArgb(); + + if (oldSubtitleFontSettings != Configuration.Settings.General.SubtitleFontName + + Configuration.Settings.General.SubtitleTextBoxFontBold + + Configuration.Settings.General.CenterSubtitleInTextBox + + Configuration.Settings.General.SubtitleTextBoxFontSize + + Configuration.Settings.General.SubtitleFontColor.ToArgb() + + Configuration.Settings.General.SubtitleBackgroundColor.ToArgb() + + Configuration.Settings.General.SubtitleListViewFontBold.ToString() + + Configuration.Settings.General.SubtitleListViewFontSize || + oldSyntaxColoring != newSyntaxColoring || + oldShowColumnEndTime != Configuration.Settings.Tools.ListViewShowColumnEndTime || + oldShowcolumnDuration != Configuration.Settings.Tools.ListViewShowColumnDuration || + oldShowColumnCharsPerSec != Configuration.Settings.Tools.ListViewShowColumnCharsPerSec || + oldShowWordsMinColumn != Configuration.Settings.Tools.ListViewShowColumnWordsPerMin) + { + if (Configuration.Settings.Tools.ListViewShowColumnEndTime) + { + SubtitleListview1.ShowEndColumn(Configuration.Settings.Language.General.EndTime); + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.End); + } + + if (Configuration.Settings.Tools.ListViewShowColumnDuration) + { + SubtitleListview1.ShowDurationColumn(Configuration.Settings.Language.General.Duration); + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Duration); + } + + if (Configuration.Settings.Tools.ListViewShowColumnCharsPerSec) + { + SubtitleListview1.ShowCharsSecColumn(Configuration.Settings.Language.General.CharsPerSec); + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); + } + + if (Configuration.Settings.Tools.ListViewShowColumnWordsPerMin) + { + SubtitleListview1.ShowWordsMinColumn(Configuration.Settings.Language.General.WordsPerMin); + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); + } + + try + { // can have some problems with fonts... + UiUtil.InitializeSubtitleFont(textBoxListViewText); + UiUtil.InitializeSubtitleFont(textBoxListViewTextAlternate); + UiUtil.InitializeSubtitleFont(textBoxSource); + SubtitleListview1.SubtitleFontName = Configuration.Settings.General.SubtitleFontName; + SubtitleListview1.SubtitleFontBold = Configuration.Settings.General.SubtitleListViewFontBold; + SubtitleListview1.SubtitleFontSize = Configuration.Settings.General.SubtitleListViewFontSize; + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception.Message + Environment.NewLine + exception.StackTrace); + } + + SubtitleListview1.ForeColor = Configuration.Settings.General.SubtitleFontColor; + SubtitleListview1.BackColor = Configuration.Settings.General.SubtitleBackgroundColor; + + SaveSubtitleListviewIndices(); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.AutoSizeAllColumns(this); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + mediaPlayer.SetSubtitleFont(); + ShowSubtitle(); + } + + mediaPlayer.SetSubtitleFont(); + mediaPlayer.ShowStopButton = Configuration.Settings.General.VideoPlayerShowStopButton; + mediaPlayer.ShowMuteButton = Configuration.Settings.General.VideoPlayerShowMuteButton; + mediaPlayer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton; + + if (oldListViewLineSeparatorString != Configuration.Settings.General.ListViewLineSeparatorString || + oldCpsWhiteSpaceSetting != Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace) + { + SubtitleListview1.InitializeLanguage(_languageGeneral, Configuration.Settings); + SaveSubtitleListviewIndices(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + + if (oldAllowEditOfOriginalSubtitle != Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + AddAlternate(); + } + else + { + RemoveAlternate(false, false); + } + + Main_ResizeEnd(null, null); + } + + SetLanguage(Configuration.Settings.General.Language); + + textBoxListViewTextAlternate.Enabled = Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleListViewIndex >= 0; + + SetShortcuts(); + + CheckAndGetNewlyDownloadedMpvDlls("Please restart to use new libmpv dll"); + + if (!string.IsNullOrEmpty(VideoFileName) && oldVideoPlayer != Configuration.Settings.General.VideoPlayer && mediaPlayer.VideoPlayer != null || + (oldMpvVideoOutput != Configuration.Settings.General.MpvVideoOutputWindows && Configuration.Settings.General.VideoPlayer.Equals("MPV", StringComparison.OrdinalIgnoreCase))) + { + string vfn = VideoFileName; + CloseVideoToolStripMenuItemClick(null, null); + OpenVideo(vfn); + } + + StartOrStopAutoBackup(); + + SetTitle(); + if (Configuration.Settings.VideoControls.GenerateSpectrogram) + { + audioVisualizer.WaveformNotLoadedText = Configuration.Settings.Language.Waveform.ClickToAddWaveformAndSpectrogram; + showhideWaveformToolStripMenuItem.Text = _language.Menu.Video.ShowHideWaveformAndSpectrogram; + } + else + { + audioVisualizer.WaveformNotLoadedText = Configuration.Settings.Language.Waveform.ClickToAddWaveform; + showhideWaveformToolStripMenuItem.Text = _language.Menu.Video.ShowHideWaveform; + } + + audioVisualizer.Invalidate(); + + if (oldUseTimeFormatHHMMSSFF != Configuration.Settings.General.UseTimeFormatHHMMSSFF) + { + RefreshTimeCodeMode(); + } + + if (oldSubtitleTextBoxSyntaxColor != Configuration.Settings.General.SubtitleTextBoxSyntaxColor || + oldSubtitleFontSize != Configuration.Settings.General.SubtitleTextBoxFontSize || + oldSubtitleTextBoxHtmlColor != Configuration.Settings.General.SubtitleTextBoxHtmlColor.ToArgb().ToString() || + oldSubtitleTextBoxAssaColor != Configuration.Settings.General.SubtitleTextBoxAssColor.ToArgb().ToString()) + { + textBoxListViewText.Initialize(Configuration.Settings.General.SubtitleTextBoxSyntaxColor); + textBoxListViewTextAlternate.Initialize(Configuration.Settings.General.SubtitleTextBoxSyntaxColor); + RefreshSelectedParagraph(); + } + textBoxListViewText.BackColor = !IsSubtitleLoaded ? SystemColors.ActiveBorder : SystemColors.WindowFrame; + textBoxListViewTextAlternate.BackColor = !IsSubtitleLoaded ? SystemColors.ActiveBorder : SystemColors.WindowFrame; + + SubtitleListview1.SyntaxColorAllLines(_subtitle); + mediaPlayer.LastParagraph = null; + Application.DoEvents(); + UiUtil.ShowSubtitle(_subtitle, mediaPlayer); + mediaPlayer.VideoPlayerContainerResize(null, null); + ShowLineInformationListView(); + ShowSourceLineNumber(); + } + + private void SetAudioVisualizerSettings() + { + audioVisualizer.ShowGridLines = Configuration.Settings.VideoControls.WaveformDrawGrid; + audioVisualizer.GridColor = Configuration.Settings.VideoControls.WaveformGridColor; + audioVisualizer.SelectedColor = Configuration.Settings.VideoControls.WaveformSelectedColor; + audioVisualizer.Color = Configuration.Settings.VideoControls.WaveformColor; + audioVisualizer.BackgroundColor = Configuration.Settings.VideoControls.WaveformBackgroundColor; + audioVisualizer.TextColor = Configuration.Settings.VideoControls.WaveformTextColor; + audioVisualizer.CursorColor = Configuration.Settings.VideoControls.WaveformCursorColor; + audioVisualizer.ChaptersColor = Configuration.Settings.VideoControls.WaveformChaptersColor; + audioVisualizer.TextSize = Configuration.Settings.VideoControls.WaveformTextSize; + audioVisualizer.TextBold = Configuration.Settings.VideoControls.WaveformTextBold; + audioVisualizer.MouseWheelScrollUpIsForward = Configuration.Settings.VideoControls.WaveformMouseWheelScrollUpIsForward; + audioVisualizer.AllowOverlap = Configuration.Settings.VideoControls.WaveformAllowOverlap; + audioVisualizer.ClosenessForBorderSelection = Configuration.Settings.VideoControls.WaveformBorderHitMs; + } + + private void CheckAndGetNewlyDownloadedMpvDlls(string message) + { + if (Configuration.Settings.General.VideoPlayer != "MPV") + { + return; + } + + var newMpvFiles = Directory.GetFiles(Configuration.DataDirectory, "*.dll.new-mpv"); + if (newMpvFiles.Length <= 0) + { + return; + } + + if (mediaPlayer != null && mediaPlayer.VideoPlayer != null) + { + var mpv = mediaPlayer.VideoPlayer as LibMpvDynamic; + mediaPlayer.VideoPlayer = null; + mpv?.HardDispose(); + } + + foreach (string newDllFileName in newMpvFiles) + { + if (File.Exists(newDllFileName)) // dll was in use, so unload + copy new dll + load + { + try + { + string targetFileName = newDllFileName.Replace(".dll.new-mpv", ".dll"); + File.Copy(newDllFileName, targetFileName, true); + File.Delete(newDllFileName); + ShowStatus("libmpv updated"); + } + catch + { + // ignore + } + } + } + + if (!string.IsNullOrEmpty(message)) + { + MessageBox.Show(message); + } + } + + private void AddAlternate() + { + buttonUnBreak.Visible = false; + buttonAutoBreak.Visible = false; + buttonSplitLine.Visible = false; + textBoxListViewTextAlternate.Visible = true; + labelAlternateText.Visible = true; + labelAlternateCharactersPerSecond.Visible = true; + labelTextAlternateLineLengths.Visible = true; + labelAlternateSingleLine.Visible = true; + labelAlternateSingleLinePixels.Visible = true; + labelTextAlternateLineTotal.Visible = true; + } + + private int ShowSubtitle() + { + if (_splitDualSami) + { + return UiUtil.ShowSubtitle(_subtitle, _subtitleAlternate, mediaPlayer); + } + + if (SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable) + { + return UiUtil.ShowSubtitle(_subtitleAlternate, mediaPlayer); + } + + return UiUtil.ShowSubtitle(_subtitle, mediaPlayer); + } + + private static void TryLoadIcon(ToolStripButton button, string iconName) + { + string fullPath = Configuration.IconsDirectory + iconName + ".png"; + if (File.Exists(fullPath)) + { + button.Image = new Bitmap(fullPath); + } + } + + private void InitializeToolbar() + { + var gs = Configuration.Settings.General; + + TryLoadIcon(toolStripButtonFileNew, "New"); + TryLoadIcon(toolStripButtonFileOpen, "Open"); + TryLoadIcon(toolStripButtonSave, "Save"); + TryLoadIcon(toolStripButtonSaveAs, "SaveAs"); + TryLoadIcon(toolStripButtonFind, "Find"); + TryLoadIcon(toolStripButtonReplace, "Replace"); + TryLoadIcon(toolStripButtonFixCommonErrors, "FixCommonErrors"); + TryLoadIcon(toolStripButtonRemoveTextForHi, "RemoveTextForHi"); + TryLoadIcon(toolStripButtonVisualSync, "VisualSync"); + TryLoadIcon(toolStripButtonSpellCheck, "SpellCheck"); + TryLoadIcon(toolStripButtonNetflixQualityCheck, "NetflixGlyphCheck"); + TryLoadIcon(toolStripButtonSettings, "Settings"); + TryLoadIcon(toolStripButtonHelp, "Help"); + + TryLoadIcon(toolStripButtonToggleWaveform, "WaveformToggle"); + TryLoadIcon(toolStripButtonToggleVideo, "VideoToggle"); + + toolStripButtonFileNew.Visible = gs.ShowToolbarNew; + toolStripButtonFileOpen.Visible = gs.ShowToolbarOpen; + toolStripButtonSave.Visible = gs.ShowToolbarSave; + toolStripButtonSaveAs.Visible = gs.ShowToolbarSaveAs; + toolStripButtonFind.Visible = gs.ShowToolbarFind; + toolStripButtonReplace.Visible = gs.ShowToolbarReplace; + toolStripButtonFixCommonErrors.Visible = gs.ShowToolbarFixCommonErrors; + toolStripButtonRemoveTextForHi.Visible = gs.ShowToolbarRemoveTextForHi; + + toolStripButtonVisualSync.Visible = gs.ShowToolbarVisualSync; + toolStripButtonSpellCheck.Visible = gs.ShowToolbarSpellCheck; + toolStripButtonNetflixQualityCheck.Visible = gs.ShowToolbarNetflixGlyphCheck; + toolStripButtonSettings.Visible = gs.ShowToolbarSettings; + toolStripButtonHelp.Visible = gs.ShowToolbarHelp; + + toolStripSeparatorFrameRate.Visible = gs.ShowFrameRate; + toolStripLabelFrameRate.Visible = gs.ShowFrameRate; + toolStripComboBoxFrameRate.Visible = gs.ShowFrameRate; + toolStripButtonGetFrameRate.Visible = gs.ShowFrameRate; + + toolStripSeparatorFindReplace.Visible = gs.ShowToolbarFind || gs.ShowToolbarReplace; + toolStripSeparatorFixSyncSpell.Visible = gs.ShowToolbarFixCommonErrors || gs.ShowToolbarVisualSync || gs.ShowToolbarSpellCheck || gs.ShowToolbarSettings; + toolStripSeparatorHelp.Visible = gs.ShowToolbarHelp; + + toolStrip1.Visible = gs.ShowToolbarNew || gs.ShowToolbarOpen || gs.ShowToolbarSave || gs.ShowToolbarSaveAs || gs.ShowToolbarFind || gs.ShowToolbarReplace || + gs.ShowToolbarFixCommonErrors || gs.ShowToolbarVisualSync || gs.ShowToolbarSpellCheck || gs.ShowToolbarNetflixGlyphCheck || + gs.ShowToolbarSettings || gs.ShowToolbarHelp; + + UpdateNetflixGlyphCheckToolsVisibility(); + } + + private void ToolStripButtonFileNewClick(object sender, EventArgs e) + { + _lastDoNotPrompt = -1; + ReloadFromSourceView(); + FileNew(); + ShowHideTextBasedFeatures(GetCurrentSubtitleFormat()); + } + + private void ToolStripButtonFileOpenClick(object sender, EventArgs e) + { + toolStripButtonFileOpen.Enabled = false; + ReloadFromSourceView(); + OpenNewFile(); + toolStripButtonFileOpen.Enabled = true; + } + + private void ToolStripButtonSaveClick(object sender, EventArgs e) + { + var useOnly0AForNewLine = ModifierKeys == (Keys.Control | Keys.Shift); + SaveAll(useOnly0AForNewLine); + } + + private void SaveAll(bool useOnly0AForNewLine = false) + { + if (!IsSubtitleLoaded) + { + return; + } + + ReloadFromSourceView(); + _disableShowStatus = true; + _saveAsCalled = false; + var result = SaveSubtitle(GetCurrentSubtitleFormat(), useOnly0AForNewLine); + if (result != DialogResult.OK) + { + _disableShowStatus = false; + return; + } + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate.Paragraphs.Count > 0) + { + SaveOriginalToolStripMenuItemClick(null, null); + _disableShowStatus = false; + ShowStatus(string.Format(_language.SavedSubtitleX, Path.GetFileName(_fileName)) + " + " + + string.Format(_language.SavedOriginalSubtitleX, Path.GetFileName(_subtitleAlternateFileName))); + return; + } + + _disableShowStatus = false; + ShowStatus(string.Format(_language.SavedSubtitleX, Path.GetFileName(_fileName))); + + if (Configuration.Settings.General.ShowNegativeDurationInfoOnSave) + { + var sb = new StringBuilder(); + for (var index = 0; index < _subtitle.Paragraphs.Count; index++) + { + var p = _subtitle.Paragraphs[index]; + if (p.Duration.TotalMilliseconds < 0) + { + if (sb.Length < 20) + { + if (sb.Length > 0) + { + sb.Append(", "); + } + sb.Append((index + 1).ToString(CultureInfo.InvariantCulture)); + } + else + { + sb.Append("..."); + break; + } + } + } + + if (sb.Length > 0) + { + using (var form = new DialogDoNotShowAgain(Title, string.Format(_language.SubtitleContainsNegativeDurationsX, sb.ToString()))) + { + form.ShowDialog(this); + Configuration.Settings.General.ShowNegativeDurationInfoOnSave = !form.DoNoDisplayAgain; + } + } + } + } + + private void ToolStripButtonSaveAsClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + FileSaveAs(true); + } + + private void ToolStripButtonFindClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + Find(); + } + + private void ToolStripButtonVisualSyncClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + ShowVisualSync(false); + } + + private void ToolStripButtonSettingsClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + ShowSettings(); + } + + private void TextBoxSourceClick(object sender, EventArgs e) + { + ShowSourceLineNumber(); + } + + private void TextBoxSourceKeyDown(object sender, KeyEventArgs e) + { + ShowSourceLineNumber(); + if (e.Modifiers == Keys.Control && e.KeyCode == Keys.A) + { + textBoxSource.SelectAll(); + e.SuppressKeyPress = true; + } + + if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D) + { + textBoxSource.SelectionLength = 0; + e.SuppressKeyPress = true; + } + } + + private void textBoxSource_KeyUp(object sender, KeyEventArgs e) + { + ShowSourceLineNumber(); + } + + private void TextBoxSourceTextChanged(object sender, EventArgs e) + { + ShowSourceLineNumber(); + _sourceViewChange = true; + labelStatus.Text = string.Empty; + } + + private bool ShowProfileInStatusBar => Configuration.Settings.General.CurrentProfile != "Default"; + + private void ShowSourceLineNumber() + { + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + var profile = Configuration.Settings.General.CurrentProfile + " "; + if (!ShowProfileInStatusBar) + { + profile = string.Empty; + } + + toolStripSelected.Text = profile + string.Format(_language.LineNumberX, textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart) + 1); + } + } + + private void ButtonGetFrameRateClick(object sender, EventArgs e) + { + openFileDialog1.Title = _language.OpenVideoFile; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = Utilities.GetVideoFileFilter(false); + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + VideoFileName = openFileDialog1.FileName; + var info = UiUtil.GetVideoInfo(openFileDialog1.FileName); + if (info != null && info.Success) + { + string oldFrameRate = toolStripComboBoxFrameRate.Text; + toolStripComboBoxFrameRate.Text = string.Format("{0:0.###}", info.FramesPerSecond); + + if (oldFrameRate != toolStripComboBoxFrameRate.Text) + { + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + } + } + } + + private void FindToolStripMenuItemClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + Find(); + } + + private void Find() + { + string selectedText; + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + selectedText = textBoxSource.SelectedText; + } + else + { + if (textBoxListViewTextAlternate.Focused) + { + selectedText = textBoxListViewTextAlternate.SelectedText; + } + else + { + selectedText = textBoxListViewText.SelectedText; + } + } + + if (selectedText.Length == 0 && _findHelper != null) + { + if (_clearLastFind) + { + _clearLastFind = false; + _findHelper.FindReplaceType.FindType = _clearLastFindType; + selectedText = _clearLastFindText; + } + else + { + selectedText = _findHelper.FindText; + } + } + + using (var findDialog = new FindDialog(_subtitle)) + { + findDialog.SetIcon(toolStripButtonFind.Image as Bitmap); + findDialog.Initialize(selectedText, _findHelper); + if (findDialog.ShowDialog(this) != DialogResult.OK) + { + if (_findHelper != null) + { + _findHelper.InProgress = false; + } + + return; + } + + _findHelper = findDialog.GetFindDialogHelper(_subtitleListViewIndex); + _findHelper.InProgress = true; + if (!string.IsNullOrWhiteSpace(_findHelper.FindText)) + { + if (Configuration.Settings.Tools.FindHistory.Count == 0 || Configuration.Settings.Tools.FindHistory[0] != _findHelper.FindText) + { + Configuration.Settings.Tools.FindHistory.Insert(0, _findHelper.FindText); + } + } + + ShowStatus(string.Format(_language.SearchingForXFromLineY, _findHelper.FindText, _subtitleListViewIndex + 1)); + if (tabControlSubtitle.SelectedIndex == TabControlListView) + { + var tb = GetFindReplaceTextBox(); + int startPos = tb.SelectedText.Length > 0 ? tb.SelectionStart + 1 : tb.SelectionStart; + bool found = _findHelper.Find(_subtitle, _subtitleAlternate, _subtitleListViewIndex, startPos); + tb = GetFindReplaceTextBox(); + //if we fail to find the text, we might want to start searching from the top of the file. + if (!found && _findHelper.StartLineIndex >= 1) + { + if (MessageBox.Show(_language.FindContinue, _language.FindContinueTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + found = _findHelper.Find(_subtitle, _subtitleAlternate, -1); + } + } + + if (found) + { + SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); + tb.Focus(); + tb.SelectionStart = _findHelper.SelectedPosition; + tb.SelectionLength = _findHelper.FindTextLength; + ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1)); + _findHelper.SelectedPosition++; + } + else + { + ShowStatus(string.Format(_language.XNotFound, _findHelper.FindText)); + } + } + else if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + if (_findHelper.Find(textBoxSource, textBoxSource.SelectionStart)) + { + textBoxSource.SelectionStart = _findHelper.SelectedIndex; + textBoxSource.SelectionLength = _findHelper.FindTextLength; + textBoxSource.ScrollToCaret(); + ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart))); + } + else + { + ShowStatus(string.Format(_language.XNotFound, _findHelper.FindText)); + } + } + } + + if (_findHelper != null) + { + _findHelper.InProgress = false; + } + } + + private void FindNextToolStripMenuItemClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + FindNext(); + } + + private SETextBox GetFindReplaceTextBox() + { + return _findHelper.MatchInOriginal ? textBoxListViewTextAlternate : textBoxListViewText; + } + + private void FindNext() + { + if (_findHelper != null) + { + _findHelper.InProgress = true; + var tb = GetFindReplaceTextBox(); + if (tabControlSubtitle.SelectedIndex == TabControlListView) + { + int selectedIndex = -1; + if (SubtitleListview1.SelectedItems.Count > 0) + { + selectedIndex = SubtitleListview1.SelectedItems[0].Index; + } + + int textBoxStart = tb.SelectionStart; + if (_findHelper.SelectedPosition - 1 == tb.SelectionStart && tb.SelectionLength > 0 || + _findHelper.FindText.Equals(tb.SelectedText, StringComparison.OrdinalIgnoreCase)) + { + textBoxStart = tb.SelectionStart + 1; + } + + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, selectedIndex, textBoxStart, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) + { + tb = GetFindReplaceTextBox(); + SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); + ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1)); + tb.Focus(); + tb.SelectionStart = _findHelper.SelectedPosition; + tb.SelectionLength = _findHelper.FindTextLength; + _findHelper.SelectedPosition++; + } + else + { + if (_findHelper.StartLineIndex >= 1) + { + if (MessageBox.Show(_language.FindContinue, _language.FindContinueTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + _findHelper.StartLineIndex = 0; + if (_findHelper.Find(_subtitle, _subtitleAlternate, 0)) + { + SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); + tb.Focus(); + tb.SelectionStart = _findHelper.SelectedPosition; + tb.SelectionLength = _findHelper.FindTextLength; + ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1)); + _findHelper.SelectedPosition++; + return; + } + } + } + + ShowStatus(string.Format(_language.XNotFound, _findHelper.FindText)); + } + } + else if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + if (_findHelper.FindNext(textBoxSource.Text, textBoxSource.SelectionStart)) + { + textBoxSource.SelectionStart = _findHelper.SelectedIndex; + textBoxSource.SelectionLength = _findHelper.FindTextLength; + textBoxSource.ScrollToCaret(); + ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart))); + } + else + { + ShowStatus(string.Format(_language.XNotFound, _findHelper.FindText)); + } + } + } + else + { + Find(); + } + + if (_findHelper != null) + { + _findHelper.InProgress = false; + } + } + + private void FindPrevious() + { + if (_findHelper == null) + { + return; + } + + _findHelper.InProgress = true; + var tb = GetFindReplaceTextBox(); + if (tabControlSubtitle.SelectedIndex == TabControlListView) + { + int selectedIndex = -1; + if (SubtitleListview1.SelectedItems.Count > 0) + { + selectedIndex = SubtitleListview1.SelectedItems[0].Index; + } + + int textBoxStart = tb.SelectionStart; + if (_findHelper.SelectedPosition - 1 == tb.SelectionStart && tb.SelectionLength > 0 || + _findHelper.FindText.Equals(tb.SelectedText, StringComparison.OrdinalIgnoreCase)) + { + textBoxStart = tb.SelectionStart - 1; + } + + if (_findHelper.FindPrevious(_subtitle, _subtitleAlternate, selectedIndex, textBoxStart, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) + { + tb = GetFindReplaceTextBox(); + SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); + ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1)); + tb.Focus(); + tb.SelectionStart = _findHelper.SelectedPosition; + tb.SelectionLength = _findHelper.FindTextLength; + _findHelper.SelectedPosition--; + } + else + { + ShowStatus(string.Format(_language.XNotFound, _findHelper.FindText)); + } + } + else if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + if (_findHelper.FindPrevious(textBoxSource.Text, textBoxSource.SelectionStart)) + { + textBoxSource.SelectionStart = _findHelper.SelectedIndex; + textBoxSource.SelectionLength = _findHelper.FindTextLength; + textBoxSource.ScrollToCaret(); + ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart))); + } + else + { + ShowStatus(string.Format(_language.XNotFound, _findHelper.FindText)); + } + } + + _findHelper.InProgress = false; + } + + private void ToolStripButtonReplaceClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + Replace(null); + } + + private void ReplaceToolStripMenuItemClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + Replace(null); + } + + private void ReplaceSourceView(ReplaceDialog replaceDialog) + { + bool isFirst = true; + string selectedText = textBoxSource.SelectedText; + if (selectedText.Length == 0 && _findHelper != null) + { + selectedText = _findHelper.FindText; + } + + if (replaceDialog == null) + { + replaceDialog = new ReplaceDialog(); + replaceDialog.SetIcon(toolStripButtonReplace.Image as Bitmap); + _findHelper = _findHelper ?? replaceDialog.GetFindDialogHelper(_subtitleListViewIndex); + } + else + { + isFirst = false; + } + + replaceDialog.Initialize(selectedText, _findHelper); + if (replaceDialog.ShowDialog(this) == DialogResult.OK) + { + _findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex); + ShowStatus(string.Format(_language.SearchingForXFromLineY, _findHelper.FindText, _subtitleListViewIndex + 1)); + if (replaceDialog.ReplaceAll) + { + SourceListReplaceAll(replaceDialog, _findHelper); + return; + } + + int replaceCount = 0; + var searchStringFound = false; + int start = textBoxSource.SelectionStart; + if (isFirst) + { + MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText)); + _makeHistoryPaused = true; + if (start >= 0) + { + start--; + } + } + else + { + if (textBoxSource.SelectionLength > 0 && start > 0 && !replaceDialog.FindOnly) + { + start--; + } + } + + if (_findHelper.FindNext(textBoxSource.Text, start)) + { + textBoxSource.SelectionStart = _findHelper.SelectedIndex; + textBoxSource.SelectionLength = _findHelper.FindTextLength; + if (!replaceDialog.FindOnly) + { + textBoxSource.SelectedText = _findHelper.ReplaceText; + } + + textBoxSource.ScrollToCaret(); + + replaceCount++; + searchStringFound = true; + + if (!replaceDialog.FindOnly) + { + if (_findHelper.FindNext(textBoxSource.Text, start)) + { + textBoxSource.SelectionStart = _findHelper.SelectedIndex; + textBoxSource.SelectionLength = _findHelper.FindTextLength; + textBoxSource.ScrollToCaret(); + } + + Replace(replaceDialog); + return; + } + } + + if (replaceDialog.FindOnly) + { + if (searchStringFound) + { + ShowStatus(string.Format(_language.MatchFoundX, _findHelper.FindText)); + } + else + { + ShowStatus(string.Format(_language.NoMatchFoundX, _findHelper.FindText)); + } + + Replace(replaceDialog); + return; + } + + ReloadFromSourceView(); + if (replaceCount == 0) + { + ShowStatus(_language.FoundNothingToReplace); + } + else + { + ShowStatus(string.Format(_language.ReplaceCountX, replaceCount)); + } + } + + if (_makeHistoryPaused) + { + RestartHistory(); + } + + replaceDialog.Dispose(); + } + + private void SourceListReplaceAll(ReplaceDialog replaceDialog, FindReplaceDialogHelper findHelper) + { + if (_findHelper.FindReplaceType.FindType == FindType.RegEx) + { + SourceListReplaceAllRegEx(replaceDialog); + return; + } + + int replaceCount = 0; + bool searchStringFound = true; + int start = textBoxSource.SelectionStart; + bool isFirst = true; + string text = textBoxSource.Text; + while (searchStringFound) + { + searchStringFound = false; + if (isFirst) + { + MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText)); + isFirst = false; + _makeHistoryPaused = true; + if (start >= 0) + { + start--; + } + } + else + { + start--; + } + + if (_findHelper.FindNext(text, start)) + { + text = text.Remove(findHelper.SelectedIndex, findHelper.FindTextLength).Insert(findHelper.SelectedIndex, findHelper.ReplaceText); + start = findHelper.SelectedIndex + findHelper.FindTextLength; + replaceCount++; + searchStringFound = true; + } + } + + textBoxSource.Text = text; + ReloadFromSourceView(); + if (replaceCount == 0) + { + ShowStatus(_language.FoundNothingToReplace); + } + else + { + ShowStatus(string.Format(_language.ReplaceCountX, replaceCount)); + } + + if (_makeHistoryPaused) + { + RestartHistory(); + } + + replaceDialog.Dispose(); + } + + private void SourceListReplaceAllRegEx(ReplaceDialog replaceDialog) + { + var start = textBoxSource.SelectionStart; + var s = textBoxSource.Text; + var r = new Regex(_findHelper.FindText, RegexOptions.Multiline); + var matches = r.Matches(s, start); + + if (matches.Count > 0) + { + MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText)); + } + + var result = RegexUtils.ReplaceNewLineSafe(r, s, _findHelper.ReplaceText, int.MaxValue, start); + + // update UI + textBoxSource.Text = result; + ShowStatus(matches.Count == 0 ? _language.FoundNothingToReplace : string.Format(_language.ReplaceCountX, matches.Count)); + + // replace again from beginning + if (start > 1) + { + string msgText = _language.ReplaceContinueNotFound; + if (matches.Count > 0) + { + msgText = string.Format(_language.ReplaceXContinue, matches.Count); + } + + if (MessageBox.Show(msgText, _language.ReplaceContinueTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + s = result.Substring(0, start - 1); + var rest = result.Remove(0, start - 1); + if (s.EndsWith('\r') && rest.StartsWith('\n')) + { // don't split "\r\n" + s = s.Substring(0, s.Length - 1); + rest = '\r' + rest; + } + + matches = r.Matches(s); + result = RegexUtils.ReplaceNewLineSafe(r, s, _findHelper.ReplaceText); + + // update UI + textBoxSource.Text = result + rest; + ShowStatus(matches.Count == 0 ? _language.FoundNothingToReplace : string.Format(_language.ReplaceCountX, matches.Count)); + } + } + + replaceDialog.Dispose(); + ReloadFromSourceView(); + } + + private void ReplaceListView(ReplaceDialog replaceDialog) + { + SaveSubtitleListviewIndices(); + int firstIndex = FirstSelectedIndex; + bool isFirst = true; + string selectedText; + if (textBoxListViewTextAlternate.Focused) + { + selectedText = textBoxListViewTextAlternate.SelectedText; + } + else + { + selectedText = textBoxListViewText.SelectedText; + } + + if (selectedText.Length == 0 && _findHelper != null) + { + selectedText = _findHelper.FindText; + } + + if (replaceDialog == null) + { + replaceDialog = new ReplaceDialog(); + replaceDialog.SetIcon(toolStripButtonReplace.Image as Bitmap); + _findHelper = _findHelper ?? replaceDialog.GetFindDialogHelper(_subtitleListViewIndex); + _findHelper.InProgress = true; + int index = 0; + + if (SubtitleListview1.SelectedItems.Count > 0) + { + index = SubtitleListview1.SelectedItems[0].Index; + } + + _findHelper.SelectedIndex = index; + if (textBoxListViewTextAlternate.Focused) + { + _findHelper.SelectedPosition = textBoxListViewTextAlternate.SelectionStart; + _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; + } + else + { + _findHelper.SelectedPosition = textBoxListViewText.SelectionStart; + _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; + } + + _replaceStartLineIndex = index; + } + else + { + isFirst = false; + if (_findHelper != null) + { + selectedText = _findHelper.FindText; + _findHelper.InProgress = true; + } + + } + + replaceDialog.Initialize(selectedText, _findHelper); + if (replaceDialog.ShowDialog(this) == DialogResult.OK) + { + if (_findHelper == null) + { + _findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex); + _findHelper.InProgress = true; + } + else + { + int line = _findHelper.SelectedIndex; + int pos = _findHelper.ReplaceFromPosition; + bool success = _findHelper.Success; + var matchInOriginal = _findHelper.MatchInOriginal; + _findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex); + _findHelper.SelectedIndex = line; + _findHelper.SelectedPosition = pos; + _findHelper.Success = success; + _findHelper.MatchInOriginal = matchInOriginal; + _findHelper.InProgress = true; + } + + ShowStatus(string.Format(_language.SearchingForXFromLineY, _findHelper.FindText, _subtitleListViewIndex + 1)); + int replaceCount = 0; + bool searchStringFound = true; + int stopAtIndex = int.MaxValue; + while (searchStringFound) + { + searchStringFound = false; + if (isFirst) + { + MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText)); + isFirst = false; + _makeHistoryPaused = true; + } + + if (replaceDialog.ReplaceAll) + { + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) + { + if (_findHelper.SelectedIndex > stopAtIndex) + { + break; + } + + SetTextForFindAndReplace(true, replaceDialog.ReplaceAll); + searchStringFound = true; + replaceCount++; + } + else + { + textBoxListViewText.Visible = true; + _subtitleListViewIndex = -1; + if (firstIndex >= 0 && firstIndex < SubtitleListview1.Items.Count) + { + SubtitleListview1.Items[firstIndex].Selected = true; + SubtitleListview1.Items[firstIndex].Focused = true; + SubtitleListview1.Focus(); + textBoxListViewText.Text = _subtitle.Paragraphs[firstIndex].Text; + if (_subtitleAlternate != null && textBoxListViewTextAlternate.Visible) + { + var orginial = Utilities.GetOriginalParagraph(_findHelper.SelectedIndex, _subtitle.Paragraphs[_findHelper.SelectedIndex], _subtitleAlternate.Paragraphs); + if (orginial != null) + { + textBoxListViewTextAlternate.Text = orginial.Text; + } + } + } + else + { + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + } + + ShowStatus(string.Format(_language.NoMatchFoundX, _findHelper.FindText)); + + if (_replaceStartLineIndex >= 1) // Prompt for start over + { + _replaceStartLineIndex = 0; + string msgText = _language.ReplaceContinueNotFound; + if (replaceCount > 0) + { + msgText = string.Format(_language.ReplaceXContinue, replaceCount); + } + + if (MessageBox.Show(msgText, _language.ReplaceContinueTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + stopAtIndex = firstIndex; + _findHelper.MatchInOriginal = false; + _findHelper.StartLineIndex = 0; + _findHelper.SelectedIndex = 0; + _findHelper.SelectedPosition = 0; + _findHelper.ReplaceFromPosition = 0; + SetTextForFindAndReplace(false, replaceDialog.ReplaceAll); + + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) + { + SetTextForFindAndReplace(true, replaceDialog.ReplaceAll); + _findHelper.SelectedPosition += _findHelper.ReplaceText.Length; + _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; + searchStringFound = true; + replaceCount++; + } + } + } + } + } + else if (replaceDialog.FindOnly) + { + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) + { + var tb = GetFindReplaceTextBox(); + SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); + tb.Focus(); + tb.SelectionStart = _findHelper.SelectedPosition; + tb.SelectionLength = _findHelper.FindTextLength; + _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; + _findHelper.SelectedPosition += _findHelper.FindTextLength; + ShowStatus(string.Format(_language.NoXFoundAtLineY, _findHelper.SelectedIndex + 1, _findHelper.FindText)); + Replace(replaceDialog); + if (replaceDialog != null && !replaceDialog.IsDisposed) + { + replaceDialog.Dispose(); + } + + _findHelper.InProgress = false; + return; + } + + if (_replaceStartLineIndex >= 1) // Prompt for start over + { + _replaceStartLineIndex = 0; + if (MessageBox.Show(_language.FindContinue, _language.FindContinueTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + _findHelper.StartLineIndex = 0; + _findHelper.SelectedIndex = 0; + _findHelper.SelectedPosition = 0; + _findHelper.ReplaceFromPosition = 0; + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) + { + var tb = GetFindReplaceTextBox(); + SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); + tb.Focus(); + tb.SelectionStart = _findHelper.SelectedPosition; + tb.SelectionLength = _findHelper.FindTextLength; + _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; + _findHelper.SelectedPosition += _findHelper.FindTextLength; + ShowStatus(string.Format(_language.NoXFoundAtLineY, _findHelper.SelectedIndex + 1, _findHelper.FindText)); + Replace(replaceDialog); + if (replaceDialog != null) + { + replaceDialog.Dispose(); + } + + _findHelper.InProgress = false; + return; + } + } + else + { + if (replaceDialog != null && !replaceDialog.IsDisposed) + { + replaceDialog.Dispose(); + } + + _findHelper.InProgress = false; + return; + } + } + + ShowStatus(string.Format(_language.NoMatchFoundX, _findHelper.FindText)); + } + else if (!replaceDialog.FindOnly) // replace once only + { + var tb = GetFindReplaceTextBox(); + string msg = string.Empty; + if (_findHelper.FindReplaceType.FindType == FindType.RegEx) + { + if (_findHelper.Success) + { + if (_findHelper.FindReplaceType.FindType == FindType.RegEx) + { + ReplaceViaRegularExpression(tb, replaceDialog.ReplaceAll); + } + else + { + tb.SelectedText = _findHelper.ReplaceText; + } + + msg = _language.OneReplacementMade + " "; + } + } + else if (tb.SelectionLength == _findHelper.FindTextLength) + { + tb.SelectedText = _findHelper.ReplaceText; + msg = _language.OneReplacementMade + " "; + _findHelper.SelectedPosition += _findHelper.ReplaceText.Length; + } + + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) + { + SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); + tb = GetFindReplaceTextBox(); + tb.Focus(); + tb.SelectionStart = _findHelper.SelectedPosition; + tb.SelectionLength = _findHelper.FindTextLength; + if (_findHelper.FindReplaceType.FindType != FindType.RegEx) + { + _findHelper.SelectedPosition += _findHelper.ReplaceText.Length; + } + + ShowStatus(string.Format(msg + _language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1)); + } + else + { + ShowStatus(msg + string.Format(_language.XNotFound, _findHelper.FindText)); + + // Prompt for start over + if (_replaceStartLineIndex >= 1) + { + _replaceStartLineIndex = 0; + if (MessageBox.Show(_language.FindContinue, _language.FindContinueTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + _findHelper.StartLineIndex = 0; + _findHelper.SelectedIndex = 0; + _findHelper.SelectedPosition = 0; + _findHelper.ReplaceFromPosition = 0; + if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle)) + { + SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true); + tb = GetFindReplaceTextBox(); + tb.Focus(); + tb.SelectionStart = _findHelper.SelectedPosition; + tb.SelectionLength = _findHelper.FindTextLength; + _findHelper.SelectedPosition += _findHelper.ReplaceText.Length; + ShowStatus(string.Format(msg + _language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1)); + } + } + else + { + if (replaceDialog != null && !replaceDialog.IsDisposed) + { + replaceDialog.Dispose(); + } + + _findHelper.InProgress = false; + return; + } + } + else + { + if (replaceDialog != null && !replaceDialog.IsDisposed) + { + replaceDialog.Dispose(); + } + + _findHelper.InProgress = false; + return; + } + } + + Replace(replaceDialog); + if (replaceDialog != null && !replaceDialog.IsDisposed) + { + replaceDialog.Dispose(); + } + + _findHelper.InProgress = false; + return; + } + + if (_findHelper.SelectedIndex > stopAtIndex) + { + break; + } + } + + ShowSource(); + if (replaceCount == 0) + { + ShowStatus(_language.FoundNothingToReplace); + } + else + { + ShowStatus(string.Format(_language.ReplaceCountX, replaceCount)); + SubtitleListview1.SyntaxColorAllLines(_subtitle); + } + } + + RestoreSubtitleListviewIndices(); + if (_makeHistoryPaused) + { + RestartHistory(); + } + + replaceDialog.Dispose(); + _findHelper.InProgress = false; + } + + private void ReplaceViaRegularExpression(SETextBox tb, bool replaceAll) + { + var r = new Regex(RegexUtils.FixNewLine(_findHelper.FindText), RegexOptions.Multiline); + if (replaceAll) + { + string result = RegexUtils.ReplaceNewLineSafe(r, tb.Text, _findHelper.ReplaceText); + if (result != tb.Text) + { + tb.Text = result; + } + + _findHelper.SelectedPosition = tb.Text.Length; + _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; + } + else + { + string result = RegexUtils.ReplaceNewLineSafe(r, tb.Text, _findHelper.ReplaceText, 1, _findHelper.SelectedPosition); + if (result != tb.Text) + { + var match = r.Match(string.Join(Environment.NewLine, tb.Text.SplitToLines())); + if (match != null && match.Success && !_findHelper.FindText.StartsWith('^') && _findHelper.ReplaceText.Length > 0) + { + var add = Math.Abs(match.Length - _findHelper.ReplaceText.Length); + _findHelper.SelectedPosition += add; + _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; + } + + tb.Text = result; + } + + if (_findHelper.FindText.StartsWith('^')) + { + _findHelper.SelectedPosition++; + } + } + } + + private void SetTextForFindAndReplace(bool replace, bool replaceAll) + { + _subtitleListViewIndex = _findHelper.SelectedIndex; + textBoxListViewText.Text = _subtitle.Paragraphs[_findHelper.SelectedIndex].Text; + if (_subtitleAlternate != null && textBoxListViewTextAlternate.Visible) + { + var orginial = Utilities.GetOriginalParagraph(_findHelper.SelectedIndex, _subtitle.Paragraphs[_findHelper.SelectedIndex], _subtitleAlternate.Paragraphs); + if (orginial != null) + { + textBoxListViewTextAlternate.Text = orginial.Text; + } + } + + if (replace) + { + var tb = GetFindReplaceTextBox(); + tb.SelectionStart = _findHelper.SelectedPosition; + tb.SelectionLength = _findHelper.FindTextLength; + if (_findHelper.FindReplaceType.FindType == FindType.RegEx) + { + ReplaceViaRegularExpression(tb, replaceAll); + _findHelper.SelectedPosition += _findHelper.FindTextLength; + _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; + } + else + { + tb.SelectedText = _findHelper.ReplaceText; + _findHelper.SelectedPosition += _findHelper.ReplaceText.Length; + _findHelper.ReplaceFromPosition = _findHelper.SelectedPosition; + } + } + } + + private void Replace(ReplaceDialog replaceDialog) + { + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + ReplaceSourceView(replaceDialog); + } + else + { + ReplaceListView(replaceDialog); + } + } + + public void ShowStatus(string message, bool log = true) + { + if (_disableShowStatus) + { + return; + } + + labelStatus.Text = message.Replace("&", "&&"); + statusStrip1.Refresh(); + if (!string.IsNullOrEmpty(message)) + { + _timerClearStatus.Stop(); + if (log) + { + _timerClearStatus.Interval = Configuration.Settings.General.ClearStatusBarAfterSeconds * 1000; + _statusLog.Add(string.Format("{0:0000}-{1:00}-{2:00} {3}: {4}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.ToLongTimeString(), message)); + } + else + { + _timerClearStatus.Interval = 1500; + } + _timerClearStatus.Start(); + } + ShowSourceLineNumber(); + ShowLineInformationListView(); + } + + private void ReloadFromSourceView() + { + if (_sourceViewChange) + { + SaveSubtitleListviewIndices(); + if (!string.IsNullOrWhiteSpace(textBoxSource.Text)) + { + var oldSubtitle = new Subtitle(_subtitle); + var format = GetCurrentSubtitleFormat(); + var list = textBoxSource.Lines.ToList(); + format = new Subtitle().ReloadLoadSubtitle(list, null, format); + if (format == null) + { + MessageBox.Show(_language.UnableToParseSourceView); + return; + } + + _sourceViewChange = false; + MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView); + _subtitle.ReloadLoadSubtitle(list, null, format); + + int index = 0; + foreach (string formatName in comboBoxSubtitleFormats.Items) + { + if (formatName == format.FriendlyName) + { + comboBoxSubtitleFormats.SelectedIndex = index; + break; + } + + index++; + } + + for (int i = 0; i < oldSubtitle.Paragraphs.Count; i++) + { + if (oldSubtitle.Paragraphs[i].Bookmark != null) + { + var newParagraph = _subtitle.GetFirstAlike(oldSubtitle.Paragraphs[i]); + if (newParagraph != null) + { + newParagraph.Bookmark = oldSubtitle.Paragraphs[i].Bookmark; + } + } + } + + if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) + { + _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-Configuration.Settings.General.CurrentVideoOffsetInMs)); + } + + var formatType = format.GetType(); + if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha)) + { + string errors = AdvancedSubStationAlpha.CheckForErrors(_subtitle.Header); + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else if (formatType == typeof(SubRip)) + { + string errors = (format as SubRip).Errors; + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else if (formatType == typeof(MicroDvd)) + { + string errors = (format as MicroDvd).Errors; + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else if (formatType == typeof(DCinemaSmpte2007)) + { + format.ToText(_subtitle, string.Empty); + string errors = (format as DCinemaSmpte2007).Errors; + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else if (formatType == typeof(DCinemaSmpte2010)) + { + format.ToText(_subtitle, string.Empty); + string errors = (format as DCinemaSmpte2010).Errors; + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else if (formatType == typeof(DCinemaSmpte2014)) + { + format.ToText(_subtitle, string.Empty); + string errors = (format as DCinemaSmpte2014).Errors; + if (!string.IsNullOrEmpty(errors)) + { + MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + } + else + { + _sourceViewChange = false; + MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView); + _sourceViewChange = false; + _subtitle.Paragraphs.Clear(); + } + + _subtitleListViewIndex = -1; + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + + private void HelpToolStripMenuItem1Click(object sender, EventArgs e) + { + ReloadFromSourceView(); + Utilities.ShowHelp(string.Empty); + } + + private void ToolStripButtonHelpClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + Utilities.ShowHelp(string.Empty); + } + + private void GotoLineNumberToolStripMenuItemClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + using (var goToLine = new GoToLine()) + { + if (tabControlSubtitle.SelectedIndex == TabControlListView) + { + goToLine.Initialize(1, SubtitleListview1.Items.Count); + } + else if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + goToLine.Initialize(1, textBoxSource.Lines.Length); + } + + if (goToLine.ShowDialog(this) == DialogResult.OK) + { + if (tabControlSubtitle.SelectedIndex == TabControlListView) + { + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + SubtitleListview1.SelectNone(); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + + SubtitleListview1.Items[goToLine.LineNumber - 1].Selected = true; + SubtitleListview1.Items[goToLine.LineNumber - 1].EnsureVisible(); + SubtitleListview1.Items[goToLine.LineNumber - 1].Focused = true; + ShowStatus(string.Format(_language.GoToLineNumberX, goToLine.LineNumber)); + } + else if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + textBoxSource.SelectionStart = textBoxSource.GetFirstCharIndexFromLine(goToLine.LineNumber - 1); + textBoxSource.SelectionLength = textBoxSource.Lines[goToLine.LineNumber - 1].Length; + textBoxSource.ScrollToCaret(); + ShowSourceLineNumber(); + } + } + } + } + + private void TextBoxSourceLeave(object sender, EventArgs e) + { + ReloadFromSourceView(); + } + + private void AdjustDisplayTimeToolStripMenuItemClick(object sender, EventArgs e) + { + AdjustDisplayTime(false); + } + + private void AdjustDisplayTime(bool onlySelectedLines) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + using (var adjustDisplayTime = new AdjustDisplayDuration()) + { + List selectedIndices = null; + if (onlySelectedLines) + { + adjustDisplayTime.Text += " - " + _language.SelectedLines; + selectedIndices = new List(); + foreach (int item in SubtitleListview1.SelectedIndices) + { + selectedIndices.Add(item); + } + } + + if (adjustDisplayTime.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeDisplayTimeAdjustment); + if (adjustDisplayTime.AdjustUsingPercent) + { + double percent = double.Parse(adjustDisplayTime.AdjustValue); + _subtitle.AdjustDisplayTimeUsingPercent(percent, selectedIndices); + ShowStatus(string.Format(_language.DisplayTimesAdjustedX, double.Parse(adjustDisplayTime.AdjustValue, CultureInfo.InvariantCulture) + "%")); + } + else if (adjustDisplayTime.AdjustUsingSeconds) + { + double seconds = double.Parse(adjustDisplayTime.AdjustValue, CultureInfo.InvariantCulture); + _subtitle.AdjustDisplayTimeUsingSeconds(seconds, selectedIndices); + ShowStatus(string.Format(_language.DisplayTimesAdjustedX, double.Parse(adjustDisplayTime.AdjustValue, CultureInfo.InvariantCulture))); + } + else if (adjustDisplayTime.AdjustUsingRecalc) + { + double maxCharSeconds = (double)(adjustDisplayTime.MaxCharactersPerSecond); + _subtitle.RecalculateDisplayTimes(maxCharSeconds, selectedIndices, (double)adjustDisplayTime.OptimalCharactersPerSecond, adjustDisplayTime.ExtendOnly); + ShowStatus(string.Format(_language.DisplayTimesAdjustedX, adjustDisplayTime.AdjustValue)); + } + else + { // fixed duration + _subtitle.SetFixedDuration(selectedIndices, adjustDisplayTime.FixedMilliseconds); + ShowStatus(string.Format(_language.DisplayTimesAdjustedX, adjustDisplayTime.FixedMilliseconds)); + } + + SaveSubtitleListviewIndices(); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + } + + private void FixToolStripMenuItemClick(object sender, EventArgs e) + { + if (_networkSession == null) + { + FixCommonErrors(false); + } + } + + private void FixCommonErrors(bool onlySelectedLines) + { + if (IsSubtitleLoaded) + { + ReloadFromSourceView(); + SaveSubtitleListviewIndices(); + using (var fixErrors = new FixCommonErrors()) + { + if (onlySelectedLines) + { + var selectedLines = new Subtitle(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]); + } + + fixErrors.Initialize(selectedLines, GetCurrentSubtitleFormat(), GetCurrentEncoding()); + } + else + { + fixErrors.Initialize(_subtitle, GetCurrentSubtitleFormat(), GetCurrentEncoding()); + } + + if (fixErrors.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeCommonErrorFixes); + _subtitle.Renumber(); + if (onlySelectedLines) + { + // we only update selected lines + if (_networkSession != null) + { + var deletes = new List(); + _networkSession.TimerStop(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + var pOld = _subtitle.Paragraphs[index]; + var p = fixErrors.FixedSubtitle.GetParagraphOrDefaultById(pOld.Id); + if (p == null) + { + deletes.Add(index); + } + else + { + _subtitle.Paragraphs[index] = p; + SubtitleListview1.SetTimeAndText(index, p, _subtitle.GetParagraphOrDefault(index + 1)); + } + } + + NetworkGetSendUpdates(deletes, 0, null); + } + else + { + var selectedIndices = SubtitleListview1.GetSelectedIndices(); + for (int index = selectedIndices.Length - 1; index >= 0; index--) + { + var idx = selectedIndices[index]; + var pOld = _subtitle.Paragraphs[idx]; + var p = fixErrors.FixedSubtitle.GetParagraphOrDefaultById(pOld.Id); + if (p == null) + { + _subtitle.Paragraphs.RemoveAt(idx); + } + else + { + _subtitle.Paragraphs[idx] = p; + } + } + } + + ShowStatus(_language.CommonErrorsFixedInSelectedLines); + } + else + { + _subtitle.Paragraphs.Clear(); + foreach (var p in fixErrors.FixedSubtitle.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowStatus(_language.CommonErrorsFixed); + } + + _subtitle.Renumber(); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + + Configuration.Settings.CommonErrors.StartSize = fixErrors.Width + ";" + fixErrors.Height; + Configuration.Settings.CommonErrors.StartPosition = fixErrors.Left + ";" + fixErrors.Top; + } + } + else + { + DisplaySubtitleNotLoadedMessage(); + } + + ShowInTaskbar = true; + } + + private void StartNumberingFromToolStripMenuItemClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + using (var startNumberingFrom = new StartNumberingFrom()) + { + if (startNumberingFrom.ShowDialog(this) == DialogResult.OK) + { + SaveSubtitleListviewIndices(); + MakeHistoryForUndo(_language.BeforeRenumbering); + ShowStatus(string.Format(_language.RenumberedStartingFromX, startNumberingFrom.StartFromNumber)); + _subtitle.Renumber(startNumberingFrom.StartFromNumber); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + } + + internal void ReloadFromSubtitle(Subtitle subtitle, string messageForUndo) + { + MakeHistoryForUndo(messageForUndo); + _subtitle.Paragraphs.Clear(); + _subtitle.Paragraphs.AddRange(subtitle.Paragraphs); + _subtitleListViewIndex = -1; + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (_subtitle.Paragraphs.Count > 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + } + } + + private void RemoveTextForHearImpairedToolStripMenuItemClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + using (var removeTextFromHearImpaired = new FormRemoveTextForHearImpaired(this, _subtitle)) + { + removeTextFromHearImpaired.Initialize(_subtitle); + if (removeTextFromHearImpaired.ShowDialog(this) == DialogResult.OK) + { + int count = removeTextFromHearImpaired.TotalFixes; + if (count == 1) + { + ShowStatus(_language.TextingForHearingImpairedRemovedOneLine); + } + else if (count > 1) + { + ShowStatus(string.Format(_language.TextingForHearingImpairedRemovedXLines, count)); + } + } + } + } + + private void SplitToolStripMenuItemClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + double lengthInSeconds = 0; + if (mediaPlayer.VideoPlayer != null) + { + lengthInSeconds = mediaPlayer.Duration; + } + + if (Configuration.Settings.Tools.SplitAdvanced) + { + using (var split = new Split()) + { + split.Initialize(_subtitle, _fileName, GetCurrentSubtitleFormat()); + if (split.ShowDialog(this) == DialogResult.OK) + { + ShowStatus(_language.SubtitleSplitted); + } + else if (split.ShowBasic) + { + Configuration.Settings.Tools.SplitAdvanced = false; + SplitToolStripMenuItemClick(null, null); + } + } + } + else + { + using (var splitSubtitle = new SplitSubtitle()) + { + splitSubtitle.Initialize(_subtitle, _fileName, GetCurrentSubtitleFormat(), GetCurrentEncoding(), lengthInSeconds); + if (splitSubtitle.ShowDialog(this) == DialogResult.OK) + { + ShowStatus(_language.SubtitleSplitted); + } + else if (splitSubtitle.ShowAdvanced) + { + Configuration.Settings.Tools.SplitAdvanced = true; + SplitToolStripMenuItemClick(null, null); + } + } + } + } + + private void AppendTextVisuallyToolStripMenuItemClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + + if (MessageBox.Show(_language.SubtitleAppendPrompt, _language.SubtitleAppendPromptTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + openFileDialog1.Title = _language.OpenSubtitleToAppend; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + bool success = false; + string fileName = openFileDialog1.FileName; + if (File.Exists(fileName)) + { + var fileInfo = new FileInfo(fileName); + var subtitleToAppend = new Subtitle(); + SubtitleFormat format; + + // do not allow blu-ray/vobsub + string extension = Path.GetExtension(fileName).ToLowerInvariant(); + if (extension == ".sub" && (IsVobSubFile(fileName, false) || FileUtil.IsSpDvdSup(fileName))) + { + format = null; + } + else if (extension == ".sup" && FileUtil.IsBluRaySup(fileName)) + { + format = null; + } + else if (fileInfo.Length < Subtitle.MaxFileSize) + { + format = subtitleToAppend.LoadSubtitle(fileName, out var encoding, null); + + if (format == null) + { + var ebu = new Ebu(); + if (ebu.IsMine(null, fileName)) + { + ebu.LoadSubtitle(subtitleToAppend, null, fileName); + format = ebu; + } + } + + if (format == null) + { + var pac = new Pac(); + if (pac.IsMine(null, fileName)) + { + pac.LoadSubtitle(subtitleToAppend, null, fileName); + format = pac; + } + } + + if (format == null) + { + var cavena890 = new Cavena890(); + if (cavena890.IsMine(null, fileName)) + { + cavena890.LoadSubtitle(subtitleToAppend, null, fileName); + format = cavena890; + } + } + } + else + { + MessageBox.Show(string.Format(_language.FileXIsLargerThan10MB, fileName)); + return; + } + + if (format != null && subtitleToAppend.Paragraphs.Count > 1) + { + using (var visualSync = new VisualSync()) + { + visualSync.Initialize(toolStripButtonVisualSync.Image as Bitmap, subtitleToAppend, null, _fileName, _language.AppendViaVisualSyncTitle, CurrentFrameRate); + visualSync.ShowDialog(this); + if (visualSync.OkPressed) + { + if (MessageBox.Show(_language.AppendSynchronizedSubtitlePrompt, _language.SubtitleAppendPromptTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + int start = _subtitle.Paragraphs.Count + 1; + var fr = CurrentFrameRate; + MakeHistoryForUndo(_language.BeforeAppend); + foreach (var p in visualSync.Paragraphs) + { + _subtitle.Paragraphs.Add(new Paragraph(p)); + } + + if (format.GetType() == typeof(AdvancedSubStationAlpha) && GetCurrentSubtitleFormat().GetType() == typeof(AdvancedSubStationAlpha)) + { + var currentStyles = new List(); + if (_subtitle.Header != null) + { + currentStyles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); + } + + foreach (var styleName in AdvancedSubStationAlpha.GetStylesFromHeader(subtitleToAppend.Header)) + { + bool alreadyExists = false; + foreach (var currentStyleName in currentStyles) + { + if (currentStyleName.Trim().Equals(styleName.Trim(), StringComparison.OrdinalIgnoreCase)) + { + alreadyExists = true; + } + } + + if (!alreadyExists) + { + var newStyle = AdvancedSubStationAlpha.GetSsaStyle(styleName, subtitleToAppend.Header); + _subtitle.Header = AdvancedSubStationAlpha.AddSsaStyle(newStyle, _subtitle.Header); + } + } + } + + _subtitle.Renumber(); + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + + // select appended lines + for (int i = start; i < _subtitle.Paragraphs.Count; i++) + { + SubtitleListview1.Items[i].Selected = true; + } + + SubtitleListview1.EnsureVisible(start); + + ShowStatus(string.Format(_language.SubtitleAppendedX, fileName)); + success = true; + } + } + } + } + } + + if (!success) + { + ShowStatus(_language.SubtitleNotAppended); + } + } + } + } + + private void TranslateByGoogleToolStripMenuItemClick(object sender, EventArgs e) + { + TranslateViaGoogle(false, true); + } + + private void TranslateViaGoogle(bool onlySelectedLines, bool useGoogle) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + bool isAlternateVisible = SubtitleListview1.IsAlternateTextColumnVisible; + ReloadFromSourceView(); + using (var googleTranslate = new GoogleTranslate()) + { + SaveSubtitleListviewIndices(); + string title = _language.GoogleTranslate; + if (!useGoogle) + { + title = _language.MicrosoftTranslate; + } + + if (onlySelectedLines) + { + var selectedLines = new Subtitle(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]); + } + + title += " - " + _language.SelectedLines; + if (_subtitleAlternate != null) + { + var paragraphs = new List(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + var original = Utilities.GetOriginalParagraph(index, _subtitle.Paragraphs[index], _subtitleAlternate.Paragraphs); + if (original != null) + { + paragraphs.Add(original); + } + } + + if (paragraphs.Count == selectedLines.Paragraphs.Count) + { + googleTranslate.Initialize(new Subtitle(paragraphs), selectedLines, title, useGoogle, GetCurrentEncoding()); + } + else + { + googleTranslate.Initialize(selectedLines, null, title, useGoogle, GetCurrentEncoding()); + } + } + else + { + googleTranslate.Initialize(selectedLines, null, title, useGoogle, GetCurrentEncoding()); + } + } + else + { + googleTranslate.Initialize(_subtitle, null, title, useGoogle, GetCurrentEncoding()); + } + + if (googleTranslate.ShowDialog(this) == DialogResult.OK) + { + _subtitleListViewIndex = -1; + string oldFileName = _fileName; + MakeHistoryForUndo(_language.BeforeGoogleTranslation); + if (onlySelectedLines) + { + // we only update selected lines + int i = 0; + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index] = googleTranslate.TranslatedSubtitle.Paragraphs[i]; + i++; + } + + ShowStatus(_language.SelectedLinesTranslated); + } + else + { + ShowSubtitleTimer.Stop(); + var oldHash = _changeSubtitleHash; + _subtitleAlternate = new Subtitle(_subtitle); + _subtitleAlternateFileName = _fileName; + _fileName = null; + _subtitle.Paragraphs.Clear(); + foreach (var p in googleTranslate.TranslatedSubtitle.Paragraphs) + { + _subtitle.Paragraphs.Add(new Paragraph(p)); + } + + ShowStatus(_language.SubtitleTranslated); + _changeAlternateSubtitleHash = oldHash; + _changeSubtitleHash = -1; + ShowSubtitleTimer.Start(); + } + + ShowSource(); + + if (!onlySelectedLines) + { + SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); + SubtitleListview1.AutoSizeAllColumns(this); + var oldHash = _changeAlternateSubtitleHash; + SetupAlternateEdit(); + _changeAlternateSubtitleHash = oldHash; + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (!onlySelectedLines) + { + ResetHistory(); + _fileName = googleTranslate.GetFileNameWithTargetLanguage(oldFileName, VideoFileName, _subtitleAlternate, GetCurrentSubtitleFormat()); + } + + RestoreSubtitleListviewIndices(); + _converted = true; + SetTitle(); + SetEncoding(Encoding.UTF8); + if (!isAlternateVisible) + { + toolStripMenuItemShowOriginalInPreview.Checked = false; + Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable = false; + audioVisualizer.Invalidate(); + } + } + } + } + + private static string GetTranslateStringFromNikseDk(string input) + { + WebRequest.DefaultWebProxy = Utilities.GetProxy(); + //var request = WebRequest.Create("http://localhost:54942/MultiTranslator/TranslateForSubtitleEdit"); + var request = WebRequest.Create("https://www.nikse.dk/MultiTranslator/TranslateForSubtitleEdit"); + request.Method = "POST"; + var postData = String.Format("languagePair={1}&text={0}", Utilities.UrlEncode(input), "svda"); + var byteArray = Encoding.UTF8.GetBytes(postData); + request.ContentType = "application/x-www-form-urlencoded"; + request.ContentLength = byteArray.Length; + using (var dataStream = request.GetRequestStream()) + { + dataStream.Write(byteArray, 0, byteArray.Length); + } + + using (var response = request.GetResponse()) + using (var reader = new StreamReader(response.GetResponseStream())) + { + return reader.ReadToEnd(); + } + } + + private void TranslateFromSwedishToDanishToolStripMenuItemClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + bool isSwedish = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle) == "sv"; + string promptText = _language.TranslateSwedishToDanish; + if (!isSwedish) + { + promptText = _language.TranslateSwedishToDanishWarning; + } + + if (MessageBox.Show(promptText, Title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + try + { + _subtitleAlternate = new Subtitle(_subtitle); + _subtitleAlternateFileName = null; + int firstSelectedIndex = 0; + if (SubtitleListview1.SelectedItems.Count > 0) + { + firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + } + + _subtitleListViewIndex = -1; + + Cursor.Current = Cursors.WaitCursor; + ShowStatus(_language.TranslatingViaNikseDkMt); + var sb = new StringBuilder(); + var output = new StringBuilder(); + foreach (var p in _subtitle.Paragraphs) + { + var s = p.Text.Replace(Environment.NewLine, "
"); + s = "

" + s + "

"; + sb.Append(s); + + if (sb.Length > 9000) + { + output.Append(GetTranslateStringFromNikseDk(sb.ToString())); + sb.Length = 0; + } + } + + if (sb.Length > 0) + { + output.Append(GetTranslateStringFromNikseDk(sb.ToString())); + } + + MakeHistoryForUndo(_language.BeforeSwedishToDanishTranslation); + var result = output.ToString(); + if (result.Length > 0) + { + int index = 0; + foreach (var s in result.Split(new[] { "

", "

" }, StringSplitOptions.RemoveEmptyEntries)) + { + if (index < _subtitle.Paragraphs.Count) + { + _subtitle.Paragraphs[index].Text = s.Trim(); + } + + index++; + } + + ShowSource(); + SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); + SubtitleListview1.AutoSizeAllColumns(this); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + ShowStatus(_language.TranslationFromSwedishToDanishComplete); + SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); + _converted = true; + } + } + catch + { + ShowStatus(_language.TranslationFromSwedishToDanishFailed); + } + + Cursor.Current = Cursors.Default; + } + } + + /// + /// Undo or Redo + /// + /// True equals undo, false triggers redo + private void UndoToIndex(bool undo) + { + if (_networkSession != null) + { + return; + } + + lock (_syncUndo) + { + if (!undo && _undoIndex >= _subtitle.HistoryItems.Count - 1) + { + return; + } + + if (undo && (_subtitle == null || !_subtitle.CanUndo || _undoIndex < 0)) + { + return; + } + + // Add latest changes if any (also stop changes from being added while redoing/undoing) + timerTextUndo.Stop(); + timerAlternateTextUndo.Stop(); + _listViewTextTicks = 0; + _listViewAlternateTextTicks = 0; + TimerTextUndoTick(null, null); + TimerAlternateTextUndoTick(null, null); + + try + { + int selectedIndex = FirstSelectedIndex; + if (undo) + { + _subtitle.HistoryItems[_undoIndex].RedoParagraphs = new List(); + _subtitle.HistoryItems[_undoIndex].RedoParagraphsAlternate = new List(); + + foreach (var p in _subtitle.Paragraphs) + { + _subtitle.HistoryItems[_undoIndex].RedoParagraphs.Add(new Paragraph(p)); + } + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null) + { + foreach (var p in _subtitleAlternate.Paragraphs) + { + _subtitle.HistoryItems[_undoIndex].RedoParagraphsAlternate.Add(new Paragraph(p)); + } + } + + _subtitle.HistoryItems[_undoIndex].RedoFileName = _fileName; + _subtitle.HistoryItems[_undoIndex].RedoFileModified = _fileDateTime; + _subtitle.HistoryItems[_undoIndex].RedoOriginalFileName = _subtitleAlternateFileName; + + if (selectedIndex >= 0) + { + _subtitle.HistoryItems[_undoIndex].RedoParagraphs[selectedIndex].Text = + textBoxListViewText.Text; + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && + selectedIndex < _subtitle.HistoryItems[_undoIndex].RedoParagraphsAlternate.Count) + { + _subtitle.HistoryItems[_undoIndex].RedoParagraphsAlternate[selectedIndex].Text = + textBoxListViewTextAlternate.Text; + } + + _subtitle.HistoryItems[_undoIndex].RedoLineIndex = selectedIndex; + _subtitle.HistoryItems[_undoIndex].RedoLinePosition = textBoxListViewText.SelectionStart; + _subtitle.HistoryItems[_undoIndex].RedoLinePositionAlternate = textBoxListViewTextAlternate.SelectionStart; + } + else + { + _subtitle.HistoryItems[_undoIndex].RedoLineIndex = -1; + _subtitle.HistoryItems[_undoIndex].RedoLinePosition = -1; + } + } + else + { + _undoIndex++; + } + + var text = _subtitle.HistoryItems[_undoIndex].Description; + + _subtitleListViewIndex = -1; + textBoxListViewText.Text = string.Empty; + textBoxListViewTextAlternate.Text = string.Empty; + string oldFileName = _fileName; + DateTime oldFileDateTime = _fileDateTime; + + string oldAlternameFileName = _subtitleAlternateFileName; + _fileName = _subtitle.UndoHistory(_undoIndex, out var subtitleFormatFriendlyName, out _fileDateTime, out _subtitleAlternate, out _subtitleAlternateFileName); + if (string.IsNullOrEmpty(oldAlternameFileName) && !string.IsNullOrEmpty(_subtitleAlternateFileName)) + { + SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); + SubtitleListview1.AutoSizeAllColumns(this); + } + else if (SubtitleListview1.IsAlternateTextColumnVisible && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count == 0) + { + RemoveAlternate(true, false); + } + + if (!undo) + { + // TODO: Sometimes redo paragraphs can be null - how? + if (_subtitle.HistoryItems[_undoIndex].RedoParagraphs != null) + { + _subtitle.Paragraphs.Clear(); + foreach (var p in _subtitle.HistoryItems[_undoIndex].RedoParagraphs) + { + _subtitle.Paragraphs.Add(new Paragraph(p)); + } + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null) + { + _subtitleAlternate.Paragraphs.Clear(); + foreach (var p in _subtitle.HistoryItems[_undoIndex].RedoParagraphsAlternate) + { + _subtitleAlternate.Paragraphs.Add(new Paragraph(p)); + } + } + } + else + { + System.Diagnostics.Debug.WriteLine("Undo failed at undo index: " + _undoIndex); + } + + _subtitle.HistoryItems[_undoIndex].RedoParagraphs = null; + _subtitle.HistoryItems[_undoIndex].RedoParagraphsAlternate = null; + if (SubtitleListview1.IsAlternateTextColumnVisible && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count == 0) + { + RemoveAlternate(true, false); + } + } + + if (oldFileName == null || oldFileName.Equals(_fileName, StringComparison.OrdinalIgnoreCase)) + { + _fileDateTime = oldFileDateTime; // undo will not give overwrite-newer-file warning + } + + comboBoxSubtitleFormats.SelectedIndexChanged -= ComboBoxSubtitleFormatsSelectedIndexChanged; + SetCurrentFormat(subtitleFormatFriendlyName); + comboBoxSubtitleFormats.SelectedIndexChanged += ComboBoxSubtitleFormatsSelectedIndexChanged; + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + + if (selectedIndex >= _subtitle.Paragraphs.Count) + { + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.Paragraphs.Count - 1, true); + } + else if (selectedIndex >= 0 && selectedIndex < _subtitle.Paragraphs.Count) + { + SubtitleListview1.SelectIndexAndEnsureVisible(selectedIndex, true); + } + else + { + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + } + + audioVisualizer.Invalidate(); + if (undo) + { + if (_subtitle.HistoryItems[_undoIndex].LineIndex == FirstSelectedIndex) + { + textBoxListViewText.SelectionStart = _subtitle.HistoryItems[_undoIndex].LinePosition; + if (_subtitleAlternate != null) + { + textBoxListViewTextAlternate.SelectionStart = + _subtitle.HistoryItems[_undoIndex].LinePositionAlternate; + } + } + + ShowStatus(_language.UndoPerformed + ": " + text.Replace(Environment.NewLine, " ")); + _undoIndex--; + } + else + { + if (_subtitle.HistoryItems[_undoIndex].RedoLineIndex >= 0 && + _subtitle.HistoryItems[_undoIndex].RedoLineIndex == FirstSelectedIndex) + { + textBoxListViewText.SelectionStart = _subtitle.HistoryItems[_undoIndex].RedoLinePosition; + } + + if (_subtitleAlternate != null && _subtitle.HistoryItems[_undoIndex].RedoLineIndex >= 0 && + _subtitle.HistoryItems[_undoIndex].RedoLineIndex == FirstSelectedIndex) + { + textBoxListViewTextAlternate.SelectionStart = _subtitle.HistoryItems[_undoIndex].RedoLinePositionAlternate; + } + + _fileName = _subtitle.HistoryItems[_undoIndex].RedoFileName; + _subtitleAlternateFileName = _subtitle.HistoryItems[_undoIndex].RedoOriginalFileName; + ShowStatus(_language.RedoPerformed); + } + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception.Message); + } + + timerTextUndo.Start(); + timerAlternateTextUndo.Start(); + SetTitle(); + SetListViewStateImages(); + } + } + + private void ShowHistoryforUndoToolStripMenuItemClick(object sender, EventArgs e) + { + if (_subtitle != null && _subtitle.CanUndo) + { + ReloadFromSourceView(); + using (var showHistory = new ShowHistory()) + { + showHistory.Initialize(_subtitle, _undoIndex); + if (showHistory.ShowDialog(this) == DialogResult.OK) + { + _subtitleListViewIndex = -1; + textBoxListViewText.Text = string.Empty; + textBoxListViewTextAlternate.Text = string.Empty; + + Cursor.Current = Cursors.WaitCursor; + SubtitleListview1.BeginUpdate(); + int rollBackCount = 0; + while (_undoIndex > showHistory.SelectedIndex && rollBackCount < Subtitle.MaximumHistoryItems) + { + UndoToIndex(true); + rollBackCount++; + } + SubtitleListview1.EndUpdate(); + Cursor.Current = Cursors.Default; + audioVisualizer.Invalidate(); + } + } + } + else + { + MessageBox.Show(_language.NothingToUndo, Title, MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void ToolStripButtonSpellCheckClick(object sender, EventArgs e) + { + SpellCheck(true, 0); + } + + private void SpellCheckToolStripMenuItemClick(object sender, EventArgs e) + { + SpellCheck(true, 0); + } + + private void SpellCheck(bool autoDetect, int startFromLine) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + try + { + string dictionaryFolder = Utilities.DictionaryFolder; + if (!Directory.Exists(dictionaryFolder) || Directory.GetFiles(dictionaryFolder, "*.dic").Length == 0) + { + ShowGetDictionaries(); + return; + } + + if (_subtitle != null && _subtitle.Paragraphs.Count > 0) + { + if (_spellCheckForm != null) + { + var result = MessageBox.Show(_language.ContinueWithCurrentSpellCheck, Title, MessageBoxButtons.YesNoCancel); + if (result == DialogResult.Cancel) + { + return; + } + + if (result == DialogResult.No) + { + _spellCheckForm.Dispose(); + _spellCheckForm = new SpellCheck(); + _spellCheckForm.DoSpellCheck(autoDetect, _subtitle, dictionaryFolder, this, startFromLine); + } + else + { + _spellCheckForm.ContinueSpellCheck(_subtitle); + } + } + else + { + _spellCheckForm = new SpellCheck(); + _spellCheckForm.DoSpellCheck(autoDetect, _subtitle, dictionaryFolder, this, startFromLine); + } + } + } + catch (Exception ex) + { + MessageBox.Show(string.Format("{0}{1}{2}{3}{4}", ex.Source, Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace), _title, MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + public void ChangeWholeTextMainPart(ref int noOfChangedWords, ref bool firstChange, int i, Paragraph p) + { + SubtitleListview1.SetText(i, p.Text); + noOfChangedWords++; + if (firstChange) + { + MakeHistoryForUndo(_language.BeforeSpellCheck); + firstChange = false; + } + + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + ShowSource(); + } + else + { + RefreshSelectedParagraph(); + } + } + + public void DeleteLine() + { + MakeHistoryForUndo(Configuration.Settings.Language.Main.OneLineDeleted); + DeleteSelectedLines(); + } + + public void FocusParagraph(int index) + { + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + tabControlSubtitle.SelectedIndex = TabControlListView; + } + + if (tabControlSubtitle.SelectedIndex == TabControlListView) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + } + } + + private void RefreshSelectedParagraph() + { + var idx = FirstSelectedIndex; + if (idx == -1 && _subtitle?.Paragraphs?.Count > 0) + { + idx = 0; + } + + var p = _subtitle.GetParagraphOrDefault(idx); + _subtitleListViewIndex = -1; + SubtitleListview1_SelectedIndexChanged(null, null); + if (p != null) + { + SubtitleListview1.SetStartTimeAndDuration(idx, p, _subtitle.GetParagraphOrDefault(idx + 1), _subtitle.GetParagraphOrDefault(idx - 1)); + } + } + + private void RefreshSelectedParagraphs() + { + foreach (var index in SubtitleListview1.GetSelectedIndices()) + { + var p = _subtitle.GetParagraphOrDefault(index); + if (p != null) + { + SubtitleListview1.SetStartTimeAndDuration(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + } + } + + _subtitleListViewIndex = -1; + SubtitleListview1_SelectedIndexChanged(null, null); + } + + private int GetPositionFromWordIndex(string text, int wordIndex) + { + var sb = new StringBuilder(); + int index = -1; + for (int i = 0; i < text.Length; i++) + { + if (SpellCheckWordLists.SplitChars.Contains(text[i])) + { + if (sb.Length > 0) + { + index++; + if (index == wordIndex) + { + int pos = i - sb.Length; + if (pos > 0) + { + pos--; + } + + if (pos >= 0) + { + return pos; + } + } + } + + sb.Clear(); + } + else + { + sb.Append(text[i]); + } + } + + if (sb.Length > 0) + { + index++; + if (index == wordIndex) + { + int pos = text.Length - 1 - sb.Length; + if (pos >= 0) + { + return pos; + } + } + } + + return 0; + } + + public void CorrectWord(string changeWord, Paragraph p, string oldWord, ref bool firstChange, int wordIndex) + { + if (oldWord != changeWord) + { + if (firstChange) + { + MakeHistoryForUndo(_language.BeforeSpellCheck); + firstChange = false; + } + + int startIndex = p.Text.IndexOf(oldWord, StringComparison.Ordinal); + if (wordIndex >= 0) + { + startIndex = p.Text.IndexOf(oldWord, GetPositionFromWordIndex(p.Text, wordIndex), StringComparison.Ordinal); + } + + while (startIndex >= 0 && startIndex < p.Text.Length && p.Text.Substring(startIndex).Contains(oldWord)) + { + bool startOk = startIndex == 0 || + "«»“” <>-—+/'\"[](){}¿¡….,;:!?%&$£\r\n؛،؟\u200E\u200F\u202A\u202B\u202C\u202D\u202E\u00C2\u00A0".Contains(p.Text[startIndex - 1]) || + char.IsPunctuation(p.Text[startIndex - 1]) || + startIndex == p.Text.Length - oldWord.Length; + if (startOk) + { + int end = startIndex + oldWord.Length; + if (end <= p.Text.Length && end == p.Text.Length || + "«»“” ,.!?:;'()<>\"-—+/[]{}%&$£…\r\n؛،؟\u200E\u200F\u202A\u202B\u202C\u202D\u202E\u00C2\u00A0".Contains(p.Text[end]) || + char.IsPunctuation(p.Text[end])) + { + var lengthBefore = p.Text.Length; + p.Text = p.Text.Remove(startIndex, oldWord.Length).Insert(startIndex, changeWord); + var lengthAfter = p.Text.Length; + if (lengthAfter > lengthBefore) + { + startIndex += (lengthAfter - lengthBefore); + } + } + } + + if (startIndex + 2 >= p.Text.Length) + { + startIndex = -1; + } + else + { + startIndex = p.Text.IndexOf(oldWord, startIndex + 2, StringComparison.Ordinal); + } + + // stop if using index + if (wordIndex >= 0) + { + startIndex = -1; + } + } + + ShowStatus(string.Format(_language.SpellCheckChangedXToY, oldWord, changeWord)); + SubtitleListview1.SetText(_subtitle.GetIndex(p), p.Text); + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + ShowSource(); + } + else + { + RefreshSelectedParagraph(); + } + } + } + + private void GetDictionariesToolStripMenuItem_Click(object sender, EventArgs e) + { + ShowGetDictionaries(); + } + + private void ShowGetDictionaries() + { + using (var form = new GetDictionaries()) + { + form.ShowDialog(this); + } + } + + private void ContextMenuStripListviewOpening(object sender, System.ComponentModel.CancelEventArgs e) + { + var format = GetCurrentSubtitleFormat(); + var formatType = format.GetType(); + var coordinates = SubtitleListview1.PointToClient(Cursor.Position); + var hitTest = SubtitleListview1.HitTest(coordinates); + if (coordinates.Y < 19 || (hitTest.Item != null && hitTest.Item.Index == 0 && coordinates.Y < hitTest.Item.Position.Y)) + { + e.Cancel = true; + var cm = new ContextMenuStrip(); + var contextMenuStripLvHeaderResizeToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.Main.Menu.ContextMenu.SizeAllColumnsToFit); + contextMenuStripLvHeaderResizeToolStripMenuItem.Click += (sender2, e2) => { SubtitleListview1.AutoSizeColumns(); }; + cm.Items.Add(contextMenuStripLvHeaderResizeToolStripMenuItem); + + var tss = new ToolStripSeparator(); + UiUtil.FixFonts(tss); + cm.Items.Add(tss); + + // End time + var contextMenuStripLvHeaderEndTimeToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.General.EndTime); + contextMenuStripLvHeaderEndTimeToolStripMenuItem.CheckOnClick = true; + contextMenuStripLvHeaderEndTimeToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnEndTime; + contextMenuStripLvHeaderEndTimeToolStripMenuItem.Click += (sender2, e2) => + { + SubtitleListview1.BeginUpdate(); + Configuration.Settings.Tools.ListViewShowColumnEndTime = contextMenuStripLvHeaderEndTimeToolStripMenuItem.Checked; + if (Configuration.Settings.Tools.ListViewShowColumnEndTime) + { + SubtitleListview1.ShowEndColumn(Configuration.Settings.Language.General.EndTime); + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.End); + } + + SaveSubtitleListviewIndices(); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + SubtitleListview1.EndUpdate(); + }; + cm.Items.Add(contextMenuStripLvHeaderEndTimeToolStripMenuItem); + + // Duration + var contextMenuStripLvHeaderDurationToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.General.Duration); + contextMenuStripLvHeaderDurationToolStripMenuItem.CheckOnClick = true; + contextMenuStripLvHeaderDurationToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnDuration; + contextMenuStripLvHeaderDurationToolStripMenuItem.Click += (sender2, e2) => + { + SubtitleListview1.BeginUpdate(); + Configuration.Settings.Tools.ListViewShowColumnDuration = contextMenuStripLvHeaderDurationToolStripMenuItem.Checked; + if (Configuration.Settings.Tools.ListViewShowColumnDuration) + { + SubtitleListview1.ShowDurationColumn(Configuration.Settings.Language.General.Duration); + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Duration); + } + + SaveSubtitleListviewIndices(); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + SubtitleListview1.EndUpdate(); + }; + cm.Items.Add(contextMenuStripLvHeaderDurationToolStripMenuItem); + + // CPS + var contextMenuStripLvHeaderCpsToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.General.CharsPerSec); + contextMenuStripLvHeaderCpsToolStripMenuItem.CheckOnClick = true; + contextMenuStripLvHeaderCpsToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnCharsPerSec; + contextMenuStripLvHeaderCpsToolStripMenuItem.Click += (sender2, e2) => + { + SubtitleListview1.BeginUpdate(); + Configuration.Settings.Tools.ListViewShowColumnCharsPerSec = contextMenuStripLvHeaderCpsToolStripMenuItem.Checked; + if (Configuration.Settings.Tools.ListViewShowColumnCharsPerSec) + { + SubtitleListview1.ShowCharsSecColumn(Configuration.Settings.Language.General.CharsPerSec); + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); + } + + SaveSubtitleListviewIndices(); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + SubtitleListview1.EndUpdate(); + }; + cm.Items.Add(contextMenuStripLvHeaderCpsToolStripMenuItem); + + // WPM + var contextMenuStripLvHeaderWpmToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.General.WordsPerMin); + contextMenuStripLvHeaderWpmToolStripMenuItem.CheckOnClick = true; + contextMenuStripLvHeaderWpmToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnWordsPerMin; + contextMenuStripLvHeaderWpmToolStripMenuItem.Click += (sender2, e2) => + { + SubtitleListview1.BeginUpdate(); + Configuration.Settings.Tools.ListViewShowColumnWordsPerMin = contextMenuStripLvHeaderWpmToolStripMenuItem.Checked; + if (Configuration.Settings.Tools.ListViewShowColumnWordsPerMin) + { + SubtitleListview1.ShowWordsMinColumn(Configuration.Settings.Language.General.WordsPerMin); + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); + } + + SaveSubtitleListviewIndices(); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + SubtitleListview1.EndUpdate(); + }; + cm.Items.Add(contextMenuStripLvHeaderWpmToolStripMenuItem); + + // GAP + var contextMenuStripLvHeaderGapToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.General.Gap); + contextMenuStripLvHeaderGapToolStripMenuItem.CheckOnClick = true; + contextMenuStripLvHeaderGapToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnGap; + contextMenuStripLvHeaderGapToolStripMenuItem.Click += (sender2, e2) => + { + SubtitleListview1.BeginUpdate(); + Configuration.Settings.Tools.ListViewShowColumnGap = contextMenuStripLvHeaderGapToolStripMenuItem.Checked; + if (Configuration.Settings.Tools.ListViewShowColumnGap) + { + SubtitleListview1.ShowGapColumn(Configuration.Settings.Language.General.Gap); + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Gap); + } + + SaveSubtitleListviewIndices(); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + SubtitleListview1.EndUpdate(); + }; + cm.Items.Add(contextMenuStripLvHeaderGapToolStripMenuItem); + + if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha) || formatType == typeof(CsvNuendo)) + { + // ACTOR + var actorTitle = formatType == typeof(CsvNuendo) ? Configuration.Settings.Language.General.Character : Configuration.Settings.Language.General.Actor; + var contextMenuStripLvHeaderActorToolStripMenuItem = new ToolStripMenuItem(actorTitle); + contextMenuStripLvHeaderActorToolStripMenuItem.CheckOnClick = true; + contextMenuStripLvHeaderActorToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnActor; + contextMenuStripLvHeaderActorToolStripMenuItem.Click += (sender2, e2) => + { + SubtitleListview1.BeginUpdate(); + Configuration.Settings.Tools.ListViewShowColumnActor = contextMenuStripLvHeaderActorToolStripMenuItem.Checked; + if (Configuration.Settings.Tools.ListViewShowColumnActor) + { + SubtitleListview1.ShowActorColumn(actorTitle); + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Actor); + } + + SaveSubtitleListviewIndices(); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + SubtitleListview1.EndUpdate(); + }; + cm.Items.Add(contextMenuStripLvHeaderActorToolStripMenuItem); + } + + if (formatType == typeof(TimedText10)) + { + // REGION + var contextMenuStripLvHeaderRegionToolStripMenuItem = new ToolStripMenuItem(Configuration.Settings.Language.General.Region); + contextMenuStripLvHeaderRegionToolStripMenuItem.CheckOnClick = true; + contextMenuStripLvHeaderRegionToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnRegion; + contextMenuStripLvHeaderRegionToolStripMenuItem.Click += (sender2, e2) => + { + SubtitleListview1.BeginUpdate(); + Configuration.Settings.Tools.ListViewShowColumnRegion = contextMenuStripLvHeaderRegionToolStripMenuItem.Checked; + if (Configuration.Settings.Tools.ListViewShowColumnRegion) + { + SubtitleListview1.ShowRegionColumn(Configuration.Settings.Language.General.Region); + } + else + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Region); + } + + SaveSubtitleListviewIndices(); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + SubtitleListview1.EndUpdate(); + }; + cm.Items.Add(contextMenuStripLvHeaderRegionToolStripMenuItem); + } + + cm.Show(SubtitleListview1, coordinates); + return; + } + + toolStripMenuItemPreview.Visible = formatType == typeof(WebVTT) && + !string.IsNullOrEmpty(VideoFileName) && + (VideoFileName.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) || VideoFileName.EndsWith(".m4v", StringComparison.OrdinalIgnoreCase) || VideoFileName.EndsWith(".webm", StringComparison.OrdinalIgnoreCase)) && + IsSubtitleLoaded; + + toolStripMenuItemSetRegion.Visible = false; + toolStripMenuItemSetLanguage.Visible = false; + List actors = null; + if ((formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha) || formatType == typeof(CsvNuendo)) && SubtitleListview1.SelectedItems.Count > 0) + { + actors = new List(); + toolStripMenuItemWebVTT.Visible = false; + var styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); + setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Clear(); + foreach (var style in styles) + { + setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Add(style, null, tsi_Click); + } + + setStylesForSelectedLinesToolStripMenuItem.Visible = styles.Count > 1; + toolStripMenuItemAssStyles.Visible = true; + if (formatType == typeof(AdvancedSubStationAlpha)) + { + toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.AdvancedSubStationAlphaStyles; + setStylesForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.AdvancedSubStationAlphaSetStyle; + } + else + { + toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.SubStationAlphaStyles; + setStylesForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.SubStationAlphaSetStyle; + } + + // actor + foreach (var p in _subtitle.Paragraphs) + { + if (!string.IsNullOrEmpty(p.Actor) && !actors.Contains(p.Actor)) + { + actors.Add(p.Actor); + } + + actors.Sort(); + } + + setActorForSelectedLinesToolStripMenuItem.DropDownItems.Clear(); + foreach (var actor in actors) + { + setActorForSelectedLinesToolStripMenuItem.DropDownItems.Add(actor, null, actor_Click); + } + + if (actors.Count > 0) + { + var tss = new ToolStripSeparator(); + UiUtil.FixFonts(tss); + setActorForSelectedLinesToolStripMenuItem.DropDownItems.Add(tss); + } + + setActorForSelectedLinesToolStripMenuItem.DropDownItems.Add(_language.Menu.ContextMenu.NewActor, null, SetNewActor); + if (actors.Count > 0) + { + setActorForSelectedLinesToolStripMenuItem.DropDownItems.Add(_language.Menu.ContextMenu.RemoveActors, null, RemoveActors); + } + } + else if (((formatType == typeof(TimedText10) && Configuration.Settings.SubtitleSettings.TimedText10ShowStyleAndLanguage) || formatType == typeof(ItunesTimedText)) && SubtitleListview1.SelectedItems.Count > 0) + { + toolStripMenuItemWebVTT.Visible = false; + toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.TimedTextStyles; + var styles = TimedText10.GetStylesFromHeader(_subtitle.Header); + setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Clear(); + foreach (var style in styles) + { + setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Add(style, null, tsi_Click); + } + + setStylesForSelectedLinesToolStripMenuItem.Visible = styles.Count >= 1; + toolStripMenuItemAssStyles.Visible = true; + setStylesForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.TimedTextSetStyle; + + // regions + if (string.IsNullOrEmpty(_subtitle.Header) || !_subtitle.Header.Contains("http://www.w3.org/ns/ttml")) + { + _subtitle.Header = new TimedText10().ToText(_subtitle, string.Empty); + } + + var regions = TimedText10.GetRegionsFromHeader(_subtitle.Header); + toolStripMenuItemSetRegion.DropDownItems.Clear(); + toolStripMenuItemSetRegion.Text = _language.Menu.ContextMenu.TimedTextSetRegion; + if (regions.Count > 0) + { + toolStripMenuItemSetRegion.Visible = true; + foreach (var region in regions) + { + toolStripMenuItemSetRegion.DropDownItems.Add(region, null, SetRegionClick); + } + + toolStripMenuItemSetRegion.DropDownItems.Add("-"); + var clear = new ToolStripMenuItem(Configuration.Settings.Language.DvdSubRip.Clear); + toolStripMenuItemSetRegion.DropDownItems.Add(clear); + clear.Click += (sender2, e2) => + { + MakeHistoryForUndo("Set region: " + Configuration.Settings.Language.DvdSubRip.Clear); + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Region = null; + SubtitleListview1.SetTimeAndText(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); + } + }; + } + else + { + toolStripMenuItemSetRegion.Visible = false; + } + + // languages + var languages = TimedText10.GetUsedLanguages(_subtitle); + toolStripMenuItemSetLanguage.DropDownItems.Clear(); + toolStripMenuItemSetLanguage.Text = _language.Menu.ContextMenu.TimedTextSetLanguage; + toolStripMenuItemSetLanguage.Visible = true; + if (languages.Count > 0) + { + foreach (var language in languages) + { + toolStripMenuItemSetLanguage.DropDownItems.Add(language, null, AddLanguageClick); + } + + toolStripMenuItemSetLanguage.DropDownItems.Add("-"); + } + + var newItem = new ToolStripMenuItem(_language.New); + toolStripMenuItemSetLanguage.DropDownItems.Add(newItem); + newItem.Click += (senderNew, eNew) => + { + var moreLanguages = new List(); + foreach (CultureInfo x in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) + { + var twoLetterLower = x.TwoLetterISOLanguageName.ToLowerInvariant(); + if (!languages.Contains(twoLetterLower) && + !languages.Contains(x.GetThreeLetterIsoLanguageName().ToLowerInvariant()) && + twoLetterLower != "iv") + { + moreLanguages.Add(x); + } + } + + moreLanguages = moreLanguages.OrderBy(p => p.TwoLetterISOLanguageName).ToList(); + using (var form = new TimedTextNewLanguage(moreLanguages, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle))) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + if (!string.IsNullOrEmpty(form.Language)) + { + MakeHistoryForUndo("Set language: " + form.Language); + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Language = form.Language; + _subtitle.Paragraphs[index].Extra = TimedText10.SetExtra(_subtitle.Paragraphs[index]); + SubtitleListview1.SetExtraText(index, _subtitle.Paragraphs[index].Extra, SubtitleListview1.ForeColor); + } + } + } + } + }; + + if (languages.Count > 0) + { + var clearLanguage = new ToolStripMenuItem(Configuration.Settings.Language.DvdSubRip.Clear); + toolStripMenuItemSetLanguage.DropDownItems.Add(clearLanguage); + clearLanguage.Click += (sender2, e2) => + { + MakeHistoryForUndo("Set language: " + Configuration.Settings.Language.DvdSubRip.Clear); + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Language = null; + _subtitle.Paragraphs[index].Extra = TimedText10.SetExtra(_subtitle.Paragraphs[index]); + SubtitleListview1.SetTimeAndText(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); + } + }; + } + } + else if ((formatType == typeof(Sami) || formatType == typeof(SamiModern)) && SubtitleListview1.SelectedItems.Count > 0) + { + toolStripMenuItemWebVTT.Visible = false; + toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.TimedTextStyles; + var styles = Sami.GetStylesFromHeader(_subtitle.Header); + setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Clear(); + foreach (var style in styles) + { + setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Add(style, null, tsi_Click); + } + + setStylesForSelectedLinesToolStripMenuItem.Visible = styles.Count > 1; + toolStripMenuItemAssStyles.Visible = false; + setStylesForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.SamiSetStyle; + } + else if (formatType == typeof(WebVTT) && SubtitleListview1.SelectedItems.Count > 0) + { + setStylesForSelectedLinesToolStripMenuItem.Visible = false; + toolStripMenuItemAssStyles.Visible = false; + toolStripMenuItemWebVTT.Visible = true; + var voices = WebVTT.GetVoices(_subtitle); + toolStripMenuItemWebVTT.DropDownItems.Clear(); + foreach (var style in voices) + { + toolStripMenuItemWebVTT.DropDownItems.Add(style, null, WebVTTSetVoice); + } + + toolStripMenuItemWebVTT.DropDownItems.Add(_language.Menu.ContextMenu.WebVTTSetNewVoice, null, WebVTTSetNewVoice); + if (voices.Count > 0) + { + toolStripMenuItemWebVTT.DropDownItems.Add(_language.Menu.ContextMenu.WebVTTRemoveVoices, null, WebVTTRemoveVoices); + } + } + else if ((format.Name == "Nuendo" && SubtitleListview1.SelectedItems.Count > 0)) + { + toolStripMenuItemWebVTT.Visible = false; + var styles = GetNuendoStyles(); + setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Clear(); + foreach (var style in styles) + { + setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Add(style, null, NuendoSetStyle); + } + + setStylesForSelectedLinesToolStripMenuItem.Visible = styles.Count > 1; + toolStripMenuItemAssStyles.Visible = false; + setStylesForSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.NuendoSetStyle; + } + else + { + setStylesForSelectedLinesToolStripMenuItem.Visible = false; + toolStripMenuItemAssStyles.Visible = false; + toolStripMenuItemWebVTT.Visible = false; + } + + if (actors != null) + { + setActorForSelectedLinesToolStripMenuItem.Visible = true; + } + else + { + setActorForSelectedLinesToolStripMenuItem.Visible = false; + } + + if (formatType == typeof(Ebu)) + { + Ebu.EbuGeneralSubtitleInformation header; + if (_subtitle != null && _subtitle.Header != null && (_subtitle.Header.Contains("STL2") || _subtitle.Header.Contains("STL3"))) + { + header = Ebu.ReadHeader(Encoding.UTF8.GetBytes(_subtitle.Header)); + } + else + { + header = new Ebu.EbuGeneralSubtitleInformation(); + } + + var open = header.DisplayStandardCode != "1" && header.DisplayStandardCode != "2"; + boxToolStripMenuItem.Visible = open; + } + else + { + boxToolStripMenuItem.Visible = false; + } + + microsoftBingTranslateToolStripMenuItem.Visible = + !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorApiKey) && + !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint); + + toolStripMenuItemGoogleMicrosoftTranslateSelLine.Visible = false; + if (SubtitleListview1.SelectedItems.Count == 0) + { + contextMenuStripEmpty.Show(MousePosition.X, MousePosition.Y); + e.Cancel = true; + } + else + { + bool noNetWorkSession = _networkSession == null; + + toolStripMenuItemSaveSelectedLines.Visible = false; + toolStripMenuItemInsertBefore.Visible = true; + toolStripMenuItemInsertAfter.Visible = true; + toolStripMenuItemInsertSubtitle.Visible = noNetWorkSession; + toolStripMenuItemMergeLines.Visible = true; + mergeAfterToolStripMenuItem.Visible = true; + mergeBeforeToolStripMenuItem.Visible = true; + splitLineToolStripMenuItem.Visible = true; + toolStripSeparator7.Visible = true; + typeEffectToolStripMenuItem.Visible = noNetWorkSession; + karokeeEffectToolStripMenuItem.Visible = noNetWorkSession; + toolStripSeparatorAdvancedFunctions.Visible = noNetWorkSession; + adjustDisplayTimeForSelectedLinesToolStripMenuItem.Visible = true; + visualSyncSelectedLinesToolStripMenuItem.Visible = true; + toolStripMenuItemGoogleMicrosoftTranslateSelLine.Visible = false; + toolStripMenuItemUnbreakLines.Visible = true; + toolStripMenuItemAutoBreakLines.Visible = true; + toolStripSeparatorBreakLines.Visible = true; + toolStripMenuItemSurroundWithMusicSymbols.Visible = IsUnicode || Configuration.Settings.Tools.MusicSymbol == "#" || Configuration.Settings.Tools.MusicSymbol == "*"; + if (SubtitleListview1.SelectedItems.Count == 1) + { + toolStripMenuItemMergeLines.Visible = false; + visualSyncSelectedLinesToolStripMenuItem.Visible = false; + toolStripMenuItemUnbreakLines.Visible = false; + toolStripMenuItemAutoBreakLines.Visible = false; + toolStripSeparatorBreakLines.Visible = false; + if (_subtitleAlternate != null && noNetWorkSession && !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftBingApiId)) + { + toolStripMenuItemGoogleMicrosoftTranslateSelLine.Visible = true; + } + + toolStripMenuItemMergeDialog.Visible = false; + } + else if (SubtitleListview1.SelectedItems.Count == 2) + { + toolStripMenuItemInsertBefore.Visible = false; + toolStripMenuItemInsertAfter.Visible = false; + toolStripMenuItemInsertSubtitle.Visible = false; + mergeAfterToolStripMenuItem.Visible = false; + mergeBeforeToolStripMenuItem.Visible = false; + splitLineToolStripMenuItem.Visible = false; + toolStripMenuItemMergeDialog.Visible = true; + } + else if (SubtitleListview1.SelectedItems.Count >= 2) + { + toolStripMenuItemSaveSelectedLines.Visible = true; + toolStripMenuItemInsertBefore.Visible = false; + toolStripMenuItemInsertAfter.Visible = false; + toolStripMenuItemInsertSubtitle.Visible = false; + splitLineToolStripMenuItem.Visible = false; + mergeAfterToolStripMenuItem.Visible = false; + mergeBeforeToolStripMenuItem.Visible = false; + toolStripSeparator7.Visible = false; + + if (SubtitleListview1.SelectedItems.Count > 25) + { + toolStripMenuItemMergeLines.Visible = false; + } + else if (SubtitleListview1.SelectedItems.Count > 2) + { // only allow merge if text is not way too long + try + { + int totalLength = 0; + foreach (int index in SubtitleListview1.SelectedIndices) + { + totalLength += _subtitle.Paragraphs[index].Text.Length; + } + + if (totalLength > Configuration.Settings.General.SubtitleLineMaximumLength * 2.5) + { + toolStripMenuItemMergeLines.Visible = false; + } + } + catch + { + } + } + + toolStripMenuItemMergeDialog.Visible = false; + } + + if (formatType != typeof(SubRip)) + { + toolStripSeparatorAdvancedFunctions.Visible = SubtitleListview1.SelectedItems.Count == 1 && noNetWorkSession; + } + } + + toolStripMenuItemPasteSpecial.Visible = Clipboard.ContainsText(); + toolStripMenuItemSurroundWithMusicSymbols.Text = Configuration.Settings.Tools.MusicSymbol; + if (string.IsNullOrEmpty(Configuration.Settings.Tools.MusicSymbol)) + { + toolStripMenuItemSurroundWithMusicSymbols.Visible = false; + } + } + + private void tsi_Click(object sender, EventArgs e) + { + string style = (sender as ToolStripItem).Text; + if (!string.IsNullOrEmpty(style)) + { + MakeHistoryForUndo("Set style: " + style); + + var format = GetCurrentSubtitleFormat(); + var formatType = format.GetType(); + if ((formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText))) + { + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Style = style; + _subtitle.Paragraphs[index].Extra = TimedText10.SetExtra(_subtitle.Paragraphs[index]); + SubtitleListview1.SetExtraText(index, _subtitle.Paragraphs[index].Extra, SubtitleListview1.ForeColor); + } + } + else + { + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Extra = style; + SubtitleListview1.SetExtraText(index, style, SubtitleListview1.ForeColor); + } + } + } + } + + private void actor_Click(object sender, EventArgs e) + { + string actor = (sender as ToolStripItem).Text; + if (!string.IsNullOrEmpty(actor)) + { + MakeHistoryForUndo(Configuration.Settings.Language.Main.Menu.ContextMenu.SetActor + ": " + actor); + + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Actor = actor; + SubtitleListview1.SetTimeAndText(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); + } + } + } + + private void SetRegionClick(object sender, EventArgs e) + { + string region = (sender as ToolStripItem).Text; + if (!string.IsNullOrEmpty(region)) + { + MakeHistoryForUndo("Set region: " + region); + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Region = region; + SubtitleListview1.SetTimeAndText(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); + } + } + } + + private void AddLanguageClick(object sender, EventArgs e) + { + string lang = (sender as ToolStripItem).Text; + if (!string.IsNullOrEmpty(lang)) + { + MakeHistoryForUndo("Set language: " + lang); + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Language = lang; + _subtitle.Paragraphs[index].Extra = TimedText10.SetExtra(_subtitle.Paragraphs[index]); + SubtitleListview1.SetExtraText(index, _subtitle.Paragraphs[index].Extra, SubtitleListview1.ForeColor); + } + } + } + + private void NuendoSetStyle(object sender, EventArgs e) + { + string style = (sender as ToolStripItem).Text; + if (!string.IsNullOrEmpty(style)) + { + int indexOfComment = style.IndexOf('['); + if (indexOfComment > 0) + { + style = style.Substring(0, indexOfComment).Trim(); + } + + MakeHistoryForUndo("Set style: " + style); + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Extra = style; + _subtitle.Paragraphs[index].Actor = style; + SubtitleListview1.SetExtraText(index, style, SubtitleListview1.ForeColor); + } + } + } + + private void WebVTTSetVoice(object sender, EventArgs e) + { + string voice = (sender as ToolStripItem).Text; + if (!string.IsNullOrEmpty(voice)) + { + MakeHistoryForUndo("Set voice: " + voice); + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Text = WebVTT.RemoveTag("v", _subtitle.Paragraphs[index].Text); + _subtitle.Paragraphs[index].Text = string.Format("{1}", voice, _subtitle.Paragraphs[index].Text); + SubtitleListview1.SetText(index, _subtitle.Paragraphs[index].Text); + } + + RefreshSelectedParagraph(); + } + } + + private void WebVTTSetNewVoice(object sender, EventArgs e) + { + using (var form = new TextPrompt(Configuration.Settings.Language.WebVttNewVoice.Title, Configuration.Settings.Language.WebVttNewVoice.VoiceName)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + string voice = form.InputText; + if (!string.IsNullOrEmpty(voice)) + { + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Text = WebVTT.RemoveTag("v", _subtitle.Paragraphs[index].Text); + _subtitle.Paragraphs[index].Text = string.Format("{1}", voice, _subtitle.Paragraphs[index].Text); + SubtitleListview1.SetText(index, _subtitle.Paragraphs[index].Text); + } + + RefreshSelectedParagraph(); + } + } + } + } + + private void SetNewActor(object sender, EventArgs e) + { + using (var form = new TextPrompt(Configuration.Settings.Language.Main.Menu.ContextMenu.NewActor.Replace("...", string.Empty), Configuration.Settings.Language.General.Actor)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + string actor = form.InputText; + if (!string.IsNullOrEmpty(actor)) + { + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Actor = actor; + SubtitleListview1.SetTimeAndText(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); + } + } + } + } + } + + private void WebVTTRemoveVoices(object sender, EventArgs e) + { + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Text = WebVTT.RemoveTag("v", _subtitle.Paragraphs[index].Text); + SubtitleListview1.SetText(index, _subtitle.Paragraphs[index].Text); + } + + RefreshSelectedParagraph(); + } + + private void RemoveActors(object sender, EventArgs e) + { + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Actor = null; + SubtitleListview1.SetTimeAndText(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); + } + } + + private void WebVTTSetVoiceTextBox(object sender, EventArgs e) + { + string voice = (sender as ToolStripItem).Text; + if (!string.IsNullOrEmpty(voice)) + { + var tb = GetFocusedTextBox(); + + if (tb.SelectionLength > 0) + { + string s = tb.SelectedText; + s = WebVTT.RemoveTag("v", s); + if (tb.SelectedText == tb.Text) + { + s = string.Format("{1}", voice, s); + } + else + { + s = string.Format("{1}", voice, s); + } + + tb.SelectedText = s; + } + } + } + + private void WebVTTSetNewVoiceTextBox(object sender, EventArgs e) + { + using (var form = new TextPrompt(Configuration.Settings.Language.WebVttNewVoice.Title, Configuration.Settings.Language.WebVttNewVoice.VoiceName)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + string voice = form.InputText; + if (!string.IsNullOrEmpty(voice)) + { + var tb = GetFocusedTextBox(); + + if (tb.SelectionLength > 0) + { + string s = tb.SelectedText; + s = WebVTT.RemoveTag("v", s); + if (tb.SelectedText == tb.Text) + { + s = string.Format("{1}", voice, s); + } + else + { + s = string.Format("{1}", voice, s); + } + + tb.SelectedText = s; + } + } + } + } + } + + private void BoldToolStripMenuItemClick(object sender, EventArgs e) + { + ListViewToggleTag(HtmlUtil.TagBold); + } + + private void ItalicToolStripMenuItemClick(object sender, EventArgs e) + { + ListViewToggleTag(HtmlUtil.TagItalic); + } + + private void UnderlineToolStripMenuItemClick(object sender, EventArgs e) + { + ListViewToggleTag(HtmlUtil.TagUnderline); + } + + private void ListViewToggleTag(string tag) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) + { + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + MakeHistoryForUndo(string.Format(_language.BeforeAddingTagX, tag)); + + var indices = new List(); + foreach (ListViewItem item in SubtitleListview1.SelectedItems) + { + indices.Add(item.Index); + } + + SubtitleListview1.BeginUpdate(); + foreach (int i in indices) + { + var p = _subtitle.GetParagraphOrDefault(i); + if (p != null) + { + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(i, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + original.Text = HtmlUtil.ToggleTag(original.Text, tag); + SubtitleListview1.SetAlternateText(i, original.Text); + } + } + + p.Text = HtmlUtil.ToggleTag(p.Text, tag); + SubtitleListview1.SetText(i, p.Text); + } + } + + SubtitleListview1.EndUpdate(); + + ShowStatus(string.Format(_language.TagXAdded, tag)); + ShowSource(); + RefreshSelectedParagraph(); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + } + } + + private void ToolStripMenuItemDeleteClick(object sender, EventArgs e) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) + { + string statusText; + string historyText; + string askText; + + if (SubtitleListview1.SelectedItems.Count > 1) + { + statusText = string.Format(_language.XLinesDeleted, SubtitleListview1.SelectedItems.Count); + historyText = string.Format(_language.BeforeDeletingXLines, SubtitleListview1.SelectedItems.Count); + askText = string.Format(_language.DeleteXLinesPrompt, SubtitleListview1.SelectedItems.Count); + } + else + { + statusText = _language.OneLineDeleted; + historyText = _language.BeforeDeletingOneLine; + askText = _language.DeleteOneLinePrompt; + } + + if (Configuration.Settings.General.PromptDeleteLines && MessageBox.Show(askText, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + _cutText = string.Empty; + return; + } + + if (!string.IsNullOrEmpty(_cutText)) + { + Clipboard.SetText(_cutText); + _cutText = string.Empty; + } + + MakeHistoryForUndo(historyText); + DeleteSelectedLines(); + + ResetTextInfoIfEmpty(); + + ShowStatus(statusText); + ShowSource(); + } + } + + private void ResetTextInfoIfEmpty() + { + if (_subtitle.Paragraphs.Count == 0) + { + labelStartTimeWarning.Text = string.Empty; + labelDurationWarning.Text = string.Empty; + _subtitleListViewIndex = -1; + textBoxListViewText.Text = string.Empty; + textBoxListViewTextAlternate.Text = string.Empty; + textBoxListViewText.Enabled = false; + textBoxListViewText.BackColor = SystemColors.ActiveBorder; + textBoxListViewTextAlternate.BackColor = SystemColors.ActiveBorder; + buttonSplitLine.Visible = false; + labelTextLineLengths.Text = string.Empty; + labelCharactersPerSecond.Text = string.Empty; + labelTextLineTotal.Text = string.Empty; + textBoxListViewText.Enabled = false; + labelSingleLine.Text = string.Empty; + labelSingleLinePixels.Text = string.Empty; + timeUpDownStartTime.TimeCode = new TimeCode(); + numericUpDownDuration.Value = 0; + ShowHideBookmark(new Paragraph()); + labelAlternateSingleLine.Text = string.Empty; + labelAlternateSingleLinePixels.Text = string.Empty; + textBoxListViewTextAlternate.Enabled = false; + labelAlternateCharactersPerSecond.Text = string.Empty; + labelTextAlternateLineLengths.Text = string.Empty; + labelTextAlternateLineTotal.Text = string.Empty; + } + } + + private void DeleteSelectedLines() + { + _subtitleListViewIndex = -1; + textBoxListViewText.Text = string.Empty; + textBoxListViewTextAlternate.Text = string.Empty; + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + var alternateIndices = new List(); + foreach (ListViewItem item in SubtitleListview1.SelectedItems) + { + var p = _subtitle.GetParagraphOrDefault(item.Index); + if (p != null) + { + var original = Utilities.GetOriginalParagraph(item.Index, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + alternateIndices.Add(_subtitleAlternate.GetIndex(original)); + } + } + } + + alternateIndices.Reverse(); + foreach (int i in alternateIndices) + { + if (i < _subtitleAlternate.Paragraphs.Count) + { + _subtitleAlternate.Paragraphs.RemoveAt(i); + } + } + + _subtitleAlternate.Renumber(); + } + + var indices = new List(); + foreach (ListViewItem item in SubtitleListview1.SelectedItems) + { + indices.Add(item.Index); + } + + int firstIndex = SubtitleListview1.SelectedItems[0].Index; + + if (_networkSession != null) + { + _networkSession.TimerStop(); + NetworkGetSendUpdates(indices, 0, null); + } + else + { + indices.Reverse(); + foreach (int i in indices) + { + _subtitle.Paragraphs.RemoveAt(i); + } + + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (SubtitleListview1.FirstVisibleIndex == 0) + { + SubtitleListview1.FirstVisibleIndex = -1; + } + + if (SubtitleListview1.Items.Count > firstIndex) + { + SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex, true); + } + else if (SubtitleListview1.Items.Count > 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(SubtitleListview1.Items.Count - 1, true); + } + } + + ResetTextInfoIfEmpty(); + SetListViewStateImages(); + } + + private void ToolStripMenuItemInsertBeforeClick(object sender, EventArgs e) + { + if (_subtitle.Paragraphs.Count > 0) + { + InsertBefore(); + } + + textBoxListViewText.Focus(); + } + + private void InsertBefore() + { + MakeHistoryForUndo(_language.BeforeInsertLine); + + int firstSelectedIndex = 0; + if (SubtitleListview1.SelectedItems.Count > 0) + { + firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + } + + int addMilliseconds = Configuration.Settings.General.MinimumMillisecondsBetweenLines + 1; + if (addMilliseconds < 1) + { + addMilliseconds = 1; + } + + var newParagraph = new Paragraph(); + + SetStyleForNewParagraph(newParagraph, firstSelectedIndex); + + var prev = _subtitle.GetParagraphOrDefault(firstSelectedIndex - 1); + var next = _subtitle.GetParagraphOrDefault(firstSelectedIndex); + if (prev != null && next != null) + { + newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - addMilliseconds; + newParagraph.StartTime.TotalMilliseconds = newParagraph.EndTime.TotalMilliseconds - 2000; + if (newParagraph.StartTime.TotalMilliseconds <= prev.EndTime.TotalMilliseconds) + { + newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1; + } + + if (newParagraph.Duration.TotalMilliseconds < 100) + { + newParagraph.EndTime.TotalMilliseconds += 100; + } + + if (next.StartTime.IsMaxTime && prev.EndTime.IsMaxTime) + { + newParagraph.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + newParagraph.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + } + else if (next.StartTime.TotalMilliseconds == 0 && prev.EndTime.TotalMilliseconds == 0) + { + newParagraph.StartTime.TotalMilliseconds = 0; + newParagraph.EndTime.TotalMilliseconds = 0; + } + else if (prev.StartTime.TotalMilliseconds == next.StartTime.TotalMilliseconds && + prev.EndTime.TotalMilliseconds == next.EndTime.TotalMilliseconds) + { + newParagraph.StartTime.TotalMilliseconds = prev.StartTime.TotalMilliseconds; + newParagraph.EndTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds; + } + } + else if (prev != null) + { + newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + addMilliseconds; + newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs; + if (newParagraph.StartTime.TotalMilliseconds > newParagraph.EndTime.TotalMilliseconds) + { + newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1; + } + } + else if (next != null) + { + newParagraph.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - (2000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines); + newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + + if (next.StartTime.IsMaxTime) + { + newParagraph.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + newParagraph.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + } + else if (next.StartTime.TotalMilliseconds == 0 && next.EndTime.TotalMilliseconds == 0) + { + newParagraph.StartTime.TotalMilliseconds = 0; + newParagraph.EndTime.TotalMilliseconds = 0; + } + } + else + { + newParagraph.StartTime.TotalMilliseconds = 1000; + newParagraph.EndTime.TotalMilliseconds = 3000; + if (newParagraph.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds) + { + newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + + Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds; + } + } + + if (_networkSession != null) + { + _networkSession.TimerStop(); + NetworkGetSendUpdates(new List(), firstSelectedIndex, newParagraph); + } + else + { + _subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph); + _subtitleListViewIndex = -1; + _subtitle.Renumber(); + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible) + { + var currentOriginal = Utilities.GetOriginalParagraph(firstSelectedIndex, _subtitle.Paragraphs[firstSelectedIndex], _subtitleAlternate.Paragraphs); + if (currentOriginal != null) + { + _subtitleAlternate.Paragraphs.Insert(_subtitleAlternate.Paragraphs.IndexOf(currentOriginal), new Paragraph(newParagraph)); + } + else + { + _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph)); + } + + _subtitleAlternate.Renumber(); + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); + ShowSource(); + ShowStatus(_language.LineInserted); + } + + private void ToolStripMenuItemInsertAfterClick(object sender, EventArgs e) + { + if (_subtitle.Paragraphs.Count > 0) + { + InsertAfter(string.Empty); + textBoxListViewText.Focus(); + } + } + + private void InsertAfter(string text) + { + MakeHistoryForUndo(_language.BeforeInsertLine); + + int firstSelectedIndex = 0; + if (SubtitleListview1.SelectedItems.Count > 0) + { + firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index + 1; + } + + var newParagraph = new Paragraph { Text = text }; + + SetStyleForNewParagraph(newParagraph, firstSelectedIndex); + + var prev = _subtitle.GetParagraphOrDefault(firstSelectedIndex - 1); + var next = _subtitle.GetParagraphOrDefault(firstSelectedIndex); + if (prev != null) + { + int addMilliseconds = Configuration.Settings.General.MinimumMillisecondsBetweenLines; + if (addMilliseconds < 1) + { + addMilliseconds = 1; + } + + newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + addMilliseconds; + newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs; + if (next != null && newParagraph.EndTime.TotalMilliseconds > next.StartTime.TotalMilliseconds) + { + newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + + if (newParagraph.StartTime.TotalMilliseconds > newParagraph.EndTime.TotalMilliseconds) + { + newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1; + } + + if (next != null && next.StartTime.IsMaxTime && prev.EndTime.IsMaxTime) + { + newParagraph.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + newParagraph.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + } + else if (next != null && next.StartTime.TotalMilliseconds == 0 && prev.EndTime.TotalMilliseconds == 0) + { + newParagraph.StartTime.TotalMilliseconds = 0; + newParagraph.EndTime.TotalMilliseconds = 0; + } + else if (next == null && prev.EndTime.IsMaxTime) + { + newParagraph.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + newParagraph.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + } + else if (next == null && prev.EndTime.TotalMilliseconds == 0) + { + newParagraph.StartTime.TotalMilliseconds = 0; + newParagraph.EndTime.TotalMilliseconds = 0; + } + else if (next != null && + prev.StartTime.TotalMilliseconds == next.StartTime.TotalMilliseconds && + prev.EndTime.TotalMilliseconds == next.EndTime.TotalMilliseconds) + { + newParagraph.StartTime.TotalMilliseconds = prev.StartTime.TotalMilliseconds; + newParagraph.EndTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds; + } + } + else if (next != null) + { + newParagraph.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 2000; + newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1; + } + else + { + newParagraph.StartTime.TotalMilliseconds = 1000; + newParagraph.EndTime.TotalMilliseconds = 3000; + if (newParagraph.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds) + { + newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + + Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds; + } + } + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + var currentOriginal = Utilities.GetOriginalParagraph(firstSelectedIndex - 1, _subtitle.Paragraphs[firstSelectedIndex - 1], _subtitleAlternate.Paragraphs); + if (currentOriginal != null) + { + _subtitleAlternate.Paragraphs.Insert(_subtitleAlternate.Paragraphs.IndexOf(currentOriginal) + 1, new Paragraph(newParagraph)); + } + else + { + _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph)); + } + + _subtitleAlternate.Renumber(); + } + + if (_networkSession != null) + { + _networkSession.TimerStop(); + NetworkGetSendUpdates(new List(), firstSelectedIndex, newParagraph); + } + else + { + _subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph); + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); + ShowSource(); + ShowStatus(_language.LineInserted); + } + + private void SetStyleForNewParagraph(Paragraph newParagraph, int nearestIndex) + { + var format = GetCurrentSubtitleFormat(); + bool useExtraForStyle = format.HasStyleSupport; + var formatType = format.GetType(); + var styles = new List(); + if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha)) + { + styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); + } + else if (formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText)) + { + styles = TimedText10.GetStylesFromHeader(_subtitle.Header); + } + else if (formatType == typeof(Sami) || formatType == typeof(SamiModern)) + { + styles = Sami.GetStylesFromHeader(_subtitle.Header); + } + + string style = "Default"; + if (styles.Count > 0) + { + style = styles[0]; + } + + if (useExtraForStyle) + { + newParagraph.Extra = style; + if (format.GetType() == typeof(TimedText10) || format.GetType() == typeof(ItunesTimedText)) + { + if (styles.Count > 0) + { + newParagraph.Style = style; + } + + var c = _subtitle.GetParagraphOrDefault(nearestIndex); + if (c != null) + { + newParagraph.Style = c.Style; + newParagraph.Region = c.Region; + newParagraph.Language = c.Language; + } + + newParagraph.Extra = TimedText10.SetExtra(newParagraph); + } + } + } + + private void SubtitleListView1SelectedIndexChange() + { + StopAutoDuration(); + ShowLineInformationListView(); + if (_subtitle.Paragraphs.Count > 0) + { + int firstSelectedIndex = 0; + if (SubtitleListview1.SelectedItems.Count > 0) + { + firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + } + + if (_subtitleListViewIndex >= 0) + { + if (_subtitleListViewIndex == firstSelectedIndex) + { + return; + } + + bool showSource = false; + + var last = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex); + if (textBoxListViewText.Text != last.Text) + { + last.Text = textBoxListViewText.Text.TrimEnd(); + SubtitleListview1.SetText(_subtitleListViewIndex, last.Text); + showSource = true; + } + + var startTime = timeUpDownStartTime.TimeCode; + if (startTime != null) + { + if (Math.Abs(last.StartTime.TotalMilliseconds - startTime.TotalMilliseconds) > 0.5) + { + var dur = last.Duration.TotalMilliseconds; + last.StartTime.TotalMilliseconds = startTime.TotalMilliseconds; + last.EndTime.TotalMilliseconds = startTime.TotalMilliseconds + dur; + SubtitleListview1.SetStartTimeAndDuration(_subtitleListViewIndex, last, _subtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1), _subtitle.GetParagraphOrDefault(_subtitleListViewIndex - 1)); + showSource = true; + } + } + + var duration = GetDurationInMilliseconds(); + if (duration > 0 && duration < 100000 && Math.Abs(duration - last.Duration.TotalMilliseconds) > 0.5) + { + last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + duration; + SubtitleListview1.SetDuration(_subtitleListViewIndex, last, _subtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1)); + showSource = true; + } + + if (showSource) + { + ShowSource(); + } + } + + var p = _subtitle.GetParagraphOrDefault(firstSelectedIndex); + if (p != null) + { + InitializeListViewEditBox(p); + _subtitleListViewIndex = firstSelectedIndex; + _oldSelectedParagraph = new Paragraph(p); + UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, p, textBoxListViewText); + FixVerticalScrollBars(textBoxListViewText, ref _lastNumberOfNewLines); + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + InitializeListViewEditBoxAlternate(p, firstSelectedIndex); + labelAlternateCharactersPerSecond.Left = textBoxListViewTextAlternate.Left + (textBoxListViewTextAlternate.Width - labelAlternateCharactersPerSecond.Width); + labelTextAlternateLineTotal.Left = textBoxListViewTextAlternate.Left + (textBoxListViewTextAlternate.Width - labelTextAlternateLineTotal.Width); + } + } + } + } + + private long _lastSubtitleListviewSelectedIndexChangedTick = -1; + private long _lastLastSubtitleListviewSelectedIndexChangedTick = -1; + + private void SubtitleListview1_SelectedIndexChanged(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedIndices.Count == 0) + { + _listViewTextUndoIndex = -1; + return; + } + + if (DateTime.UtcNow.Ticks - _lastLastSubtitleListviewSelectedIndexChangedTick < 10000 * 50) // only if last change was less ago than 50 milliseconds + { + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(50), () => + { + SubtitleListview1_SelectedIndexChanged(null, null); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + }); + return; + } + + if (!_makeHistoryPaused) + { + _listViewTextTicks = 0; + _listViewAlternateTextTicks = 0; + TimerTextUndoTick(null, null); + TimerAlternateTextUndoTick(null, null); + } + + _listViewTextUndoIndex = -1; + SubtitleListView1SelectedIndexChange(); + if (_findHelper != null && !_findHelper.InProgress) + { + _findHelper.StartLineIndex = _subtitleListViewIndex; + _findHelper.SelectedIndex = _subtitleListViewIndex; + _findHelper.SelectedPosition = 0; + _findHelper.ReplaceFromPosition = 0; + _findHelper.MatchInOriginal = false; + } + + _lastLastSubtitleListviewSelectedIndexChangedTick = _lastSubtitleListviewSelectedIndexChangedTick; + _lastSubtitleListviewSelectedIndexChangedTick = DateTime.UtcNow.Ticks; + } + + private void ShowLineInformationListView() + { + var profile = Configuration.Settings.General.CurrentProfile + " "; + if (!ShowProfileInStatusBar) + { + profile = string.Empty; + } + + if (tabControlSubtitle.SelectedIndex == TabControlListView) + { + if (SubtitleListview1.SelectedItems.Count == 1) + { + toolStripSelected.Text = profile + string.Format("{0}/{1}", SubtitleListview1.SelectedItems[0].Index + 1, SubtitleListview1.Items.Count); + } + else + { + toolStripSelected.Text = profile + string.Format(_language.XLinesSelected, SubtitleListview1.SelectedItems.Count); + } + } + } + + private void UpdateListViewTextCharactersPerSeconds(Label charsPerSecond, Paragraph paragraph) + { + if (paragraph.Duration.TotalSeconds > 0) + { + double charactersPerSecond = Utilities.GetCharactersPerSecond(paragraph); + if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds && + Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall) + { + charsPerSecond.ForeColor = Color.Red; + } + else + { + charsPerSecond.ForeColor = UiUtil.ForeColor; + } + + charsPerSecond.Text = string.Format(_language.CharactersPerSecond, charactersPerSecond); + } + else + { + if (Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall) + { + charsPerSecond.ForeColor = UiUtil.ForeColor; + } + else + { + charsPerSecond.ForeColor = Color.Red; + } + + charsPerSecond.Text = string.Format(_language.CharactersPerSecond, _languageGeneral.NotAvailable); + } + } + + private void UpdateListViewTextInfo(Label lineLengths, Label singleLine, Label singleLinePixels, Label lineTotal, Label charactersPerSecond, Paragraph paragraph, SETextBox textBox) + { + if (paragraph == null) + { + return; + } + + bool textBoxHasFocus = textBox.Focused; + string text = paragraph.Text; + lineLengths.Text = _languageGeneral.SingleLineLengths.Trim(); + singleLine.Left = lineLengths.Left + lineLengths.Width - 3; + singleLinePixels.Left = lineLengths.Left + lineLengths.Width + 50; + text = HtmlUtil.RemoveHtmlTags(text, true); + text = NetflixImsc11Japanese.RemoveTags(text); + UiUtil.GetLineLengths(singleLine, text); + + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + UiUtil.GetLinePixelWidths(singleLinePixels, text); + labelSingleLinePixels.Visible = !(textBoxListViewText.Width / 3 < labelTextLineLengths.Width); + } + else + { + labelSingleLinePixels.Visible = false; + } + + buttonSplitLine.Visible = false; + + var s = text.Replace(Environment.NewLine, " "); + var len = text.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics); + + int numberOfLines = Utilities.GetNumberOfLines(text.Trim()); + int maxLines = int.MaxValue; + if (Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines) + { + maxLines = Configuration.Settings.General.MaxNumberOfLines; + } + + var splitLines = text.SplitToLines(); + if (numberOfLines <= maxLines) + { + if (len <= Configuration.Settings.General.SubtitleLineMaximumLength * Math.Max(numberOfLines, 2) && + splitLines.Count == 2 && splitLines[0].StartsWith('-') && splitLines[1].StartsWith('-') && + (splitLines[0].CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength || + splitLines[1].CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength)) + { + if (buttonUnBreak.Visible) + { + if (!textBoxHasFocus) + { + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var totalLengthPixels = TextWidth.CalcPixelWidth(s); + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", len, totalLengthPixels)); + } + else + { + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, len); + } + } + + buttonSplitLine.Visible = true; + } + } + else if (len <= Configuration.Settings.General.SubtitleLineMaximumLength * Math.Max(numberOfLines, 2)) + { + lineTotal.ForeColor = UiUtil.ForeColor; + if (!textBoxHasFocus) + { + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var totalLengthPixels = TextWidth.CalcPixelWidth(s); + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", len, totalLengthPixels)); + } + else + { + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, len); + } + } + } + else + { + lineTotal.ForeColor = Color.Red; + if (!textBoxHasFocus) + { + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var totalLengthPixels = TextWidth.CalcPixelWidth(s); + lineTotal.Text = string.Format(_languageGeneral.TotalLengthXSplitLine, string.Format("{0} {1}", len, totalLengthPixels)); + } + else + { + lineTotal.Text = string.Format(_languageGeneral.TotalLengthXSplitLine, len); + } + } + + if (buttonUnBreak.Visible) + { + if (!textBoxHasFocus) + { + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var totalLengthPixels = TextWidth.CalcPixelWidth(s); + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", len, totalLengthPixels)); + } + else + { + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, len); + } + } + + var lang = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); + var abl = Utilities.AutoBreakLine(s, lang).SplitToLines(); + if (abl.Count > maxLines || abl.Any(li => li.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength)) + { + buttonSplitLine.Visible = true; + } + } + } + } + else + { + if (!textBoxHasFocus) + { + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var totalLengthPixels = TextWidth.CalcPixelWidth(s); + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", len, totalLengthPixels)); + } + else + { + lineTotal.Text = string.Format(_languageGeneral.TotalLengthX, len); + } + } + + var lang = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); + var abl = Utilities.AutoBreakLine(s, lang).SplitToLines(); + if (abl.Count > maxLines || abl.Any(li => li.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength) && + !textBoxListViewTextAlternate.Visible) + { + buttonSplitLine.Visible = true; + } + } + + UpdateListViewTextCharactersPerSeconds(charactersPerSecond, paragraph); + charactersPerSecond.Left = textBox.Left + (textBox.Width - labelCharactersPerSecond.Width); + lineTotal.Left = textBox.Left + (textBox.Width - lineTotal.Width); + } + + private void ButtonNextClick(object sender, EventArgs e) + { + MoveNextPrevious(0); + } + + private void ButtonPreviousClick(object sender, EventArgs e) + { + MoveNextPrevious(1); + } + + private void MoveNextPrevious(int firstSelectedIndex) + { + if (_subtitle.Paragraphs.Count == 0) + { + return; + } + + SubtitleListview1.SuspendLayout(); + var temp = firstSelectedIndex; + if (SubtitleListview1.SelectedItems.Count > 0) + { + firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + } + + firstSelectedIndex = temp == 0 ? firstSelectedIndex + 1 : firstSelectedIndex - 1; + var p = _subtitle.GetParagraphOrDefault(firstSelectedIndex); + if (p != null) + { + SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); + } + + SubtitleListview1.ResumeLayout(); + } + + private void ButtonAutoBreakClick(object sender, EventArgs e) + { + string language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); + string languageOriginal = string.Empty; + if (_subtitleAlternate != null) + { + languageOriginal = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate); + } + + var textCaretPos = textBoxListViewText.SelectionStart; + + if (SubtitleListview1.SelectedItems.Count > 1) + { + bool historyAdded = false; + SubtitleListview1.BeginUpdate(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.GetParagraphOrDefault(index); + if (p != null) + { + var oldText = p.Text; + var newText = Utilities.AutoBreakLine(p.Text, language); + if (oldText != newText) + { + if (!historyAdded) + { + historyAdded = true; + MakeHistoryForUndo(_language.Controls.AutoBreak.RemoveChar('&')); + } + + p.Text = newText; + SubtitleListview1.SetText(index, p.Text); + } + + if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + oldText = original.Text; + newText = Utilities.AutoBreakLine(original.Text, language); + if (oldText != newText) + { + if (!historyAdded) + { + historyAdded = true; + MakeHistoryForUndo(_language.Controls.AutoBreak.RemoveChar('&')); + } + + original.Text = newText; + SubtitleListview1.SetAlternateText(index, original.Text); + } + } + } + + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, p); + } + } + + SubtitleListview1.EndUpdate(); + RefreshSelectedParagraph(); + } + else + { + var fixedText = Utilities.AutoBreakLine(textBoxListViewText.Text, language); + var makeHistory = textBoxListViewText.Text != fixedText; + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var alternateFixedText = Utilities.AutoBreakLine(textBoxListViewTextAlternate.Text, languageOriginal); + if (!makeHistory) + { + makeHistory = textBoxListViewTextAlternate.Text != alternateFixedText; + } + + if (makeHistory) + { + MakeHistoryForUndo(_language.Controls.AutoBreak.RemoveChar('&')); + textBoxListViewText.Text = fixedText; + } + + textBoxListViewTextAlternate.Text = alternateFixedText; + } + else if (makeHistory) + { + MakeHistoryForUndo(_language.Controls.AutoBreak.RemoveChar('&')); + textBoxListViewText.Text = fixedText; + } + } + + var s = textBoxListViewText.Text; + var startText = s.Substring(0, Math.Min(textCaretPos, s.Length)); + var numberOfNewLines = Utilities.CountTagInText(startText, Environment.NewLine); + textCaretPos += numberOfNewLines; + if (s.Length > textCaretPos && '\n' == s[textCaretPos]) + { + textCaretPos--; + } + + if (textCaretPos > 0) + { + textBoxListViewText.SelectionStart = textCaretPos; + } + } + + private int _lastNumberOfNewLines = -1; + private int _lastNumberOfNewLinesAlternate = -1; + + private static void FixVerticalScrollBars(SETextBox tb, ref int lastNumberOfNewLines) + { + var noOfNewLines = Utilities.GetNumberOfLines(tb.Text); + if (noOfNewLines == lastNumberOfNewLines) + { + return; + } + + lastNumberOfNewLines = noOfNewLines; + try + { + if (noOfNewLines <= 1 && tb.Text.Length <= 300 || TextRenderer.MeasureText(tb.Text, tb.Font).Height < tb.Height) + { + tb.ScrollBars = RichTextBoxScrollBars.None; + } + else + { + tb.ScrollBars = RichTextBoxScrollBars.Vertical; + } + } + catch + { + // ignored + } + } + + private void TextBoxListViewTextTextChanged(object sender, EventArgs e) + { + var idx = _subtitleListViewIndex; + if (idx < 0 || idx >= _subtitle.Paragraphs.Count) + { + return; + } + + // Writing when text is selected gives a double event + some trouble (typed letter disappears or a crash happens). + // This tries to fix this - changing scrollbars is bad during this double event!? + // Also check https://stackoverflow.com/questions/28331672/c-sharp-textchanged-event-fires-twice-in-a-multiline-textbox + if (textBoxListViewText.Text == string.Empty) + { + _subtitle.Paragraphs[idx].Text = string.Empty; + UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, _subtitle.Paragraphs[idx], textBoxListViewText); + SubtitleListview1.SetText(idx, string.Empty); + _listViewTextUndoIndex = idx; + labelStatus.Text = string.Empty; + StartUpdateListSyntaxColoring(); + return; + } + + textBoxListViewText.TextChanged -= TextBoxListViewTextTextChanged; + if (_doAutoBreakOnTextChanged) + { + UiUtil.CheckAutoWrap(textBoxListViewText, new KeyEventArgs(Keys.None), Utilities.GetNumberOfLines(textBoxListViewText.Text)); + } + + // update _subtitle + listview + string text = textBoxListViewText.Text.TrimEnd(); + if (ContainsNonStandardNewLines(text)) + { + var lines = text.SplitToLines(); + text = string.Join(Environment.NewLine, lines); + textBoxListViewText.Text = text; + } + + if (idx < 0 || idx >= _subtitle.Paragraphs.Count) + { + return; + } + + _subtitle.Paragraphs[idx].Text = text; + UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, _subtitle.Paragraphs[idx], textBoxListViewText); + SubtitleListview1.SetText(idx, text); + + _listViewTextUndoIndex = _subtitleListViewIndex; + labelStatus.Text = string.Empty; + + StartUpdateListSyntaxColoring(); + FixVerticalScrollBars(textBoxListViewText, ref _lastNumberOfNewLines); + textBoxListViewText.TextChanged += TextBoxListViewTextTextChanged; + } + + private bool ContainsNonStandardNewLines(string s) + { + if (Environment.NewLine == "\r\n") + { + int i = 0; + while (i < s.Length) + { + var ch = s[i]; + if (ch == '\r') + { + if (i >= s.Length - 1 || s[i + 1] != '\n') + { + return true; + } + + i++; + } + else if (ch == '\n') + { + return true; + } + + i++; + } + + return false; + } + else if (Environment.NewLine == "\n") + { + return s.Contains('\r'); + } + else + { + s = s.Replace(Environment.NewLine, string.Empty); + return s.Contains('\n') || s.Contains('\r'); + } + } + + private void TextBoxListViewTextAlternateTextChanged(object sender, EventArgs e) + { + if (_subtitleListViewIndex >= 0) + { + var p = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex); + if (p == null) + { + return; + } + + var original = Utilities.GetOriginalParagraph(_subtitleListViewIndex, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + if (textBoxListViewTextAlternate.Text == string.Empty) + { + UpdateListViewTextInfo(labelTextAlternateLineLengths, labelAlternateSingleLine, labelAlternateSingleLinePixels, labelTextAlternateLineTotal, labelAlternateCharactersPerSecond, original, textBoxListViewTextAlternate); + SubtitleListview1.SetAlternateText(_subtitleListViewIndex, string.Empty); + _listViewTextUndoIndex = _subtitleListViewIndex; + labelStatus.Text = string.Empty; + StartUpdateListSyntaxColoring(); + return; + } + + int numberOfNewLines = Utilities.GetNumberOfLines(textBoxListViewTextAlternate.Text); + UiUtil.CheckAutoWrap(textBoxListViewTextAlternate, new KeyEventArgs(Keys.None), numberOfNewLines); + + // update _subtitle + listview + string text = textBoxListViewTextAlternate.Text.TrimEnd(); + if (ContainsNonStandardNewLines(text)) + { + var lines = text.SplitToLines(); + text = string.Join(Environment.NewLine, lines); + textBoxListViewTextAlternate.Text = text; + } + + original.Text = text; + UpdateListViewTextInfo(labelTextAlternateLineLengths, labelAlternateSingleLine, labelAlternateSingleLinePixels, labelTextAlternateLineTotal, labelAlternateCharactersPerSecond, original, textBoxListViewTextAlternate); + SubtitleListview1.SetAlternateText(_subtitleListViewIndex, text); + _listViewTextUndoIndex = _subtitleListViewIndex; + } + + labelStatus.Text = string.Empty; + + StartUpdateListSyntaxColoring(); + FixVerticalScrollBars(textBoxListViewTextAlternate, ref _lastNumberOfNewLinesAlternate); + } + } + + private void TextBoxListViewTextKeyDown(object sender, KeyEventArgs e) + { + _listViewTextTicks = DateTime.UtcNow.Ticks; + + if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.ShiftKey) + { + return; + } + + if (e.Modifiers == Keys.Control && e.KeyCode == (Keys.LButton | Keys.ShiftKey)) + { // surround ctrl+v action with history (for undo) + _listViewTextTicks = 0; + TimerTextUndoTick(sender, e); + Application.DoEvents(); + System.Threading.Thread.Sleep(50); + Application.DoEvents(); + _listViewTextTicks = 0; + TimerTextUndoTick(sender, e); + return; + } + + int numberOfLines = Utilities.GetNumberOfLines(textBoxListViewText.Text); + + if (e.Modifiers == Keys.None && e.KeyCode == Keys.Enter && numberOfLines > Configuration.Settings.General.MaxNumberOfLines) + { + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainTextBoxAutoBreak) + { + BreakUnbreakTextBox(false, textBoxListViewText); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainTextBoxUnbreak) + { + BreakUnbreakTextBox(true, textBoxListViewText); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainTextBoxBreakAtCursorPosition) + { + var text = Utilities.ReSplit(textBoxListViewText.Text, textBoxListViewText.SelectionStart); + if (text != textBoxListViewText.Text) + { + MakeHistoryForUndo(string.Format(_language.BeforeReplace, Configuration.Settings.Language.Settings.MainTextBoxAutoBreakFromPos)); + textBoxListViewText.Text = text; + var lines = textBoxListViewText.Text.SplitToLines(); + if (lines.Count > 0) + { + textBoxListViewText.SelectionStart = lines[0].Length; + } + } + + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainTextBoxBreakAtCursorPositionAndGoToNext) + { + var text = Utilities.ReSplit(textBoxListViewText.Text, textBoxListViewText.SelectionStart); + if (text != textBoxListViewText.Text) + { + MakeHistoryForUndo(string.Format(_language.BeforeReplace, Configuration.Settings.Language.Settings.MainTextBoxAutoBreakFromPosAndGoToNext)); + textBoxListViewText.Text = text; + ButtonNextClick(null, null); + } + + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.I) + { + if (textBoxListViewText.SelectionLength == 0) + { + if (textBoxListViewText.Text.Contains("", StringComparison.Ordinal)) + { + textBoxListViewText.Text = HtmlUtil.RemoveOpenCloseTags(textBoxListViewText.Text, HtmlUtil.TagItalic); + } + else + { + textBoxListViewText.Text = string.Format("{0}", textBoxListViewText.Text); + } + } + else + { + TextBoxListViewToggleTag(HtmlUtil.TagItalic); + e.SuppressKeyPress = true; + } + } + + if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D) + { + textBoxListViewText.SelectionLength = 0; + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainTextBoxSplitAtCursor == e.KeyData) + { + ToolStripMenuItemSplitTextAtCursorClick(null, null); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainTextBoxSplitAtCursorAndVideoPos == e.KeyData) + { + toolStripMenuItemSplitViaWaveform_Click(null, null); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainTextBoxSplitSelectedLineBilingual == e.KeyData) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count >= 1 && SubtitleListview1.SelectedItems.Count < 10) + { + e.SuppressKeyPress = true; + SplitSelectedLineBilingual(); + } + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN1) + { + SetAlignment("{\\an1}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN2) + { + SetAlignment("", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN3) + { + SetAlignment("{\\an3}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN4) + { + SetAlignment("{\\an4}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN5) + { + SetAlignment("{\\an5}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN6) + { + SetAlignment("{\\an6}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN7) + { + SetAlignment("{\\an7}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN8) + { + SetAlignment("{\\an8}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN9) + { + SetAlignment("{\\an9}", false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewToggleMusicSymbols) + { + textBoxListViewText.Text = ToogleMusicSymbols("♪", textBoxListViewText.Text); + } + else if (e.KeyData == _shortcuts.MainInsertBefore) + { + InsertBefore(); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainInsertAfter) + { + InsertAfter(string.Empty); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewRemoveTimeCodes) + { + int i = _subtitleListViewIndex; + var p = _subtitle.GetParagraphOrDefault(i); + if (p != null) + { + p.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + p.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + RefreshSelectedParagraph(); + } + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainTextBoxSelectionToLower == e.KeyData && textBoxListViewText.SelectionLength > 0) // selection to lowercase + { + int start = textBoxListViewText.SelectionStart; + int length = textBoxListViewText.SelectionLength; + textBoxListViewText.SelectedText = textBoxListViewText.SelectedText.ToLowerInvariant(); + textBoxListViewText.SelectionStart = start; + textBoxListViewText.SelectionLength = length; + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainTextBoxSelectionToUpper == e.KeyData && textBoxListViewText.SelectionLength > 0) // selection to uppercase + { + int start = textBoxListViewText.SelectionStart; + int length = textBoxListViewText.SelectionLength; + textBoxListViewText.SelectedText = textBoxListViewText.SelectedText.ToUpperInvariant(); + textBoxListViewText.SelectionStart = start; + textBoxListViewText.SelectionLength = length; + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainTextBoxSelectionToggleCasing == e.KeyData && textBoxListViewText.SelectionLength > 0) // selection to uppercase + { + int start = textBoxListViewText.SelectionStart; + int length = textBoxListViewText.SelectionLength; + var text = ToggleCasing(textBoxListViewText.SelectedText); + textBoxListViewText.SelectedText = text; + textBoxListViewText.SelectionStart = start; + textBoxListViewText.SelectionLength = length; + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainTextBoxToggleAutoDuration == e.KeyData) // toggle auto-duration + { + if (timerAutoDuration.Enabled) + { + timerAutoDuration.Stop(); + labelAutoDuration.Visible = false; + } + else + { + timerAutoDuration.Start(); + labelAutoDuration.Visible = true; + } + + e.SuppressKeyPress = true; + } + + // last key down in text + _lastTextKeyDownTicks = DateTime.UtcNow.Ticks; + + UpdatePositionAndTotalLength(labelTextLineTotal, textBoxListViewText); + } + + private string ToggleCasing(string text) + { + if (string.IsNullOrWhiteSpace(text) || text.ToLower() == text.ToUpper()) + { + return text; + } + + var containsLowercase = false; + var containsUppercase = false; + for (var i = 0; i < text.Length; i++) + { + var ch = text[i]; + + if (!containsLowercase && char.IsLower(ch)) + { + containsLowercase = true; + } + + if (!containsUppercase && char.IsUpper(ch)) + { + containsUppercase = true; + } + + i++; + } + + if (containsUppercase && containsLowercase) + { + return text.ToUpperInvariant(); + } + + if (containsUppercase && !containsLowercase) + { + return text.ToLowerInvariant(); + } + + return System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(text); + } + + private void MoveFirstWordInNextUp(SETextBox tb) + { + int firstIndex = FirstSelectedIndex; + if (firstIndex >= 0) + { + var p = _subtitle.GetParagraphOrDefault(firstIndex); + var next = _subtitle.GetParagraphOrDefault(firstIndex + 1); + + if (tb == textBoxListViewTextAlternate) + { + p = Utilities.GetOriginalParagraph(firstIndex, p, _subtitleAlternate.Paragraphs); + next = Utilities.GetOriginalParagraph(firstIndex + 1, next, _subtitleAlternate.Paragraphs); + } + + if (p != null && next != null) + { + var moveUpDown = new MoveWordUpDown(p.Text, next.Text); + moveUpDown.MoveWordUp(); + if (moveUpDown.S1 != p.Text && moveUpDown.S2 != next.Text) + { + MakeHistoryForUndo(_language.BeforeLineUpdatedInListView); + p.Text = moveUpDown.S1; + next.Text = moveUpDown.S2; + if (tb == textBoxListViewTextAlternate) + { + SubtitleListview1.SetAlternateText(firstIndex, p.Text); + SubtitleListview1.SetAlternateText(firstIndex + 1, next.Text); + } + else + { + SubtitleListview1.SetText(firstIndex, p.Text); + SubtitleListview1.SetText(firstIndex + 1, next.Text); + } + var selectionStart = textBoxListViewText.SelectionStart; + tb.Text = p.Text; + if (selectionStart >= 0) + { + tb.SelectionStart = selectionStart; + } + } + } + } + } + + private void MoveLastWordDown(SETextBox tb) + { + int firstIndex = FirstSelectedIndex; + if (firstIndex >= 0) + { + var p = _subtitle.GetParagraphOrDefault(firstIndex); + var next = _subtitle.GetParagraphOrDefault(firstIndex + 1); + + if (tb == textBoxListViewTextAlternate) + { + p = Utilities.GetOriginalParagraph(firstIndex, p, _subtitleAlternate.Paragraphs); + next = Utilities.GetOriginalParagraph(firstIndex + 1, next, _subtitleAlternate.Paragraphs); + } + + if (p != null && next != null) + { + var moveUpDown = new MoveWordUpDown(p.Text, next.Text); + moveUpDown.MoveWordDown(); + if (moveUpDown.S1 != p.Text && moveUpDown.S2 != next.Text) + { + MakeHistoryForUndo(_language.BeforeLineUpdatedInListView); + p.Text = moveUpDown.S1; + next.Text = moveUpDown.S2; + if (tb == textBoxListViewTextAlternate) + { + SubtitleListview1.SetAlternateText(firstIndex, p.Text); + SubtitleListview1.SetAlternateText(firstIndex + 1, next.Text); + } + else + { + SubtitleListview1.SetText(firstIndex, p.Text); + SubtitleListview1.SetText(firstIndex + 1, next.Text); + } + var selectionStart = textBoxListViewText.SelectionStart; + tb.Text = p.Text; + if (selectionStart >= 0) + { + tb.SelectionStart = selectionStart; + } + } + } + } + } + + private void MakeAutoDurationSelectedLines() + { + if (_subtitle.Paragraphs.Count == 0) + { + return; + } + + if (SubtitleListview1.SelectedItems.Count == 1) + { + MakeAutoDuration(); + return; + } + + if (SubtitleListview1.SelectedItems.Count > 1) + { + MakeHistoryForUndo(_language.BeforeAutoDuration); + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.GetParagraphOrDefault(index); + if (p == null) + { + return; + } + + double duration = Utilities.GetOptimalDisplayMilliseconds(textBoxListViewText.Text); + var next = _subtitle.GetParagraphOrDefault(index + 1); + if (next != null && p.StartTime.TotalMilliseconds + duration + Configuration.Settings.General.MinimumMillisecondsBetweenLines > next.StartTime.TotalMilliseconds) + { + duration = next.StartTime.TotalMilliseconds - p.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + + if (duration > 500) + { + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + duration; + } + } + + SaveSubtitleListviewIndices(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + RefreshSelectedParagraph(); + } + } + + private void MakeAutoDuration() + { + int i = _subtitleListViewIndex; + var p = _subtitle.GetParagraphOrDefault(i); + if (p == null) + { + return; + } + + double duration = Utilities.GetOptimalDisplayMilliseconds(textBoxListViewText.Text); + var next = _subtitle.GetParagraphOrDefault(i + 1); + if (next != null && p.StartTime.TotalMilliseconds + duration + Configuration.Settings.General.MinimumMillisecondsBetweenLines > next.StartTime.TotalMilliseconds) + { + duration = next.StartTime.TotalMilliseconds - p.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + if (duration < 400) + { + return; + } + } + + SetDurationInSeconds(duration / TimeCode.BaseUnit); + + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + duration; + SubtitleListview1.SetDuration(i, p, _subtitle.GetParagraphOrDefault(i + 1)); + } + + private void SplitLineToolStripMenuItemClick(object sender, EventArgs e) + { + SplitSelectedParagraph(null, null); + } + + private void SplitSelectedParagraph(double? splitSeconds, int? textIndex) + { + string language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); + int? alternateTextIndex = null; + if (textBoxListViewTextAlternate.Focused) + { + alternateTextIndex = textIndex; + textIndex = null; + } + + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) + { + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + MakeHistoryForUndo(_language.BeforeSplitLine); + + int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + + var currentParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex); + var newParagraph = new Paragraph(currentParagraph); + newParagraph.NewSection = false; + + currentParagraph.Text = currentParagraph.Text.Replace("< /i>", ""); + currentParagraph.Text = currentParagraph.Text.Replace("< i>", ""); + string oldText = currentParagraph.Text; + var lines = currentParagraph.Text.SplitToLines(); + if (textIndex != null && textIndex.Value > 1 && textIndex.Value < oldText.Length - 1) + { + string a = oldText.Substring(0, textIndex.Value).Trim(); + string b = oldText.Substring(textIndex.Value).Trim(); + + if (oldText.TrimStart().StartsWith("", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("", StringComparison.Ordinal) && + Utilities.CountTagInText(oldText, "") == 1 && Utilities.CountTagInText(oldText, "") == 1) + { + a = a + ""; + b = "" + b; + } + else if (oldText.TrimStart().StartsWith("", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("", StringComparison.Ordinal) && + Utilities.CountTagInText(oldText, "") == 1 && Utilities.CountTagInText(oldText, "") == 1) + { + a = a + "
"; + b = "" + b; + } + + string aTrimmed = HtmlUtil.RemoveHtmlTags(a).TrimEnd('"').TrimEnd().TrimEnd('\'').TrimEnd(); + if (Configuration.Settings.General.SplitRemovesDashes && (aTrimmed.EndsWith('.') || aTrimmed.EndsWith('!') || aTrimmed.EndsWith('?') || aTrimmed.EndsWith('؟'))) + { + a = DialogSplitMerge.RemoveStartDash(a); + b = DialogSplitMerge.RemoveStartDash(b); + } + + currentParagraph.Text = Utilities.AutoBreakLine(a, language); + newParagraph.Text = Utilities.AutoBreakLine(b, language); + } + else + { + var l0 = string.Empty; + if (lines.Count > 0) + { + l0 = HtmlUtil.RemoveHtmlTags(lines[0], true).Trim().TrimEnd('"', '\'').TrimEnd(); + } + + if (lines.Count == 2 && (l0.EndsWith('.') || l0.EndsWith('!') || l0.EndsWith('?') || l0.EndsWith('؟'))) + { + currentParagraph.Text = Utilities.AutoBreakLine(lines[0], language); + newParagraph.Text = Utilities.AutoBreakLine(lines[1], language); + if (currentParagraph.Text.StartsWith("", StringComparison.Ordinal) && !currentParagraph.Text.Contains("") && + newParagraph.Text.EndsWith("", StringComparison.Ordinal) && !newParagraph.Text.Contains("")) + { + currentParagraph.Text = currentParagraph.Text + ""; + newParagraph.Text = "" + newParagraph.Text; + } + + if (currentParagraph.Text.StartsWith("", StringComparison.Ordinal) && !currentParagraph.Text.Contains("") && + newParagraph.Text.EndsWith("", StringComparison.Ordinal) && !newParagraph.Text.Contains("")) + { + currentParagraph.Text = currentParagraph.Text + ""; + newParagraph.Text = "" + newParagraph.Text; + } + + if (Configuration.Settings.General.SplitRemovesDashes) + { + currentParagraph.Text = DialogSplitMerge.RemoveStartDash(currentParagraph.Text); + newParagraph.Text = DialogSplitMerge.RemoveStartDash(newParagraph.Text); + } + } + else + { + string s = currentParagraph.Text; + var arr = HtmlUtil.RemoveHtmlTags(s, true).SplitToLines(); + if (arr.Count == 1 || arr.Count == 2 && (arr[0].Length > Configuration.Settings.General.SubtitleLineMaximumLength || arr[1].Length > Configuration.Settings.General.SubtitleLineMaximumLength)) + { + if (arr.Count == 2 && arr[0].StartsWith('-') && arr[1].StartsWith('-')) + { + if (lines[0].StartsWith("-", StringComparison.Ordinal)) + { + lines[0] = "" + lines[0].Remove(0, 4).TrimStart(); + } + + lines[0] = lines[0].TrimStart('-').TrimStart(); + lines[1] = lines[1].TrimStart('-').TrimStart(); + s = lines[0] + Environment.NewLine + lines[1]; + } + else + { + s = Utilities.AutoBreakLine(currentParagraph.Text, 5, Configuration.Settings.General.MergeLinesShorterThan, language); + } + } + + lines = s.SplitToLines(); + if (lines.Count == 1) + { + s = Utilities.AutoBreakLine(currentParagraph.Text, 3, 20, language); + lines = s.SplitToLines(); + } + + if (lines.Count == 1) + { + s = Utilities.AutoBreakLine(currentParagraph.Text, 3, 18, language); + lines = s.SplitToLines(); + } + + if (lines.Count == 1) + { + s = Utilities.AutoBreakLine(currentParagraph.Text, 3, 15, language); + lines = s.SplitToLines(); + } + + if (lines.Count == 2) + { + if (Utilities.CountTagInText(s, "") == 1 && lines[0].Contains("", StringComparison.Ordinal) && lines[1].Contains("", StringComparison.Ordinal)) + { + lines[0] += ""; + lines[1] = "" + lines[1]; + } + + currentParagraph.Text = Utilities.AutoBreakLine(lines[0], language); + newParagraph.Text = Utilities.AutoBreakLine(lines[1], language); + } + else if (lines.Count == 1) + { + currentParagraph.Text = Utilities.AutoBreakLine(lines[0], language); + newParagraph.Text = string.Empty; + } + else if (lines.Count == 3) + { + currentParagraph.Text = Utilities.AutoBreakLine(lines[0] + Environment.NewLine + lines[1], language); + newParagraph.Text = lines[2]; + } + else if (lines.Count > 3) + { + var half = lines.Count / 2; + var sb1 = new StringBuilder(); + for (int i = 0; i < half; i++) + { + sb1.AppendLine(lines[i]); + } + + currentParagraph.Text = Utilities.AutoBreakLine(sb1.ToString(), language); + sb1 = new StringBuilder(); + for (int i = half; i < lines.Count; i++) + { + sb1.AppendLine(lines[i]); + } + + newParagraph.Text = Utilities.AutoBreakLine(sb1.ToString(), language); + } + + if (currentParagraph.Text.Contains("", StringComparison.Ordinal) && !currentParagraph.Text.Contains("", StringComparison.Ordinal) && + newParagraph.Text.Contains("", StringComparison.Ordinal) && !newParagraph.Text.Contains("", StringComparison.Ordinal)) + { + currentParagraph.Text = currentParagraph.Text + ""; + newParagraph.Text = "" + newParagraph.Text; + } + + if (currentParagraph.Text.Contains("", StringComparison.Ordinal) && !currentParagraph.Text.Contains("", StringComparison.Ordinal) && + newParagraph.Text.Contains("", StringComparison.Ordinal) && !newParagraph.Text.Contains("")) + { + currentParagraph.Text = currentParagraph.Text + ""; + newParagraph.Text = "" + newParagraph.Text; + } + + if (currentParagraph.Text.StartsWith("-", StringComparison.Ordinal) && (currentParagraph.Text.EndsWith(".", StringComparison.Ordinal) || currentParagraph.Text.EndsWith("!", StringComparison.Ordinal)) && + newParagraph.Text.StartsWith("-", StringComparison.Ordinal) && (newParagraph.Text.EndsWith(".", StringComparison.Ordinal) || newParagraph.Text.EndsWith("!", StringComparison.Ordinal))) + { + currentParagraph.Text = currentParagraph.Text.Remove(3, 1); + newParagraph.Text = newParagraph.Text.Remove(3, 1); + } + } + } + + if (currentParagraph.Text.StartsWith(" ", StringComparison.Ordinal)) + { + currentParagraph.Text = currentParagraph.Text.Remove(3, 1); + } + + if (newParagraph.Text.StartsWith(" ", StringComparison.Ordinal)) + { + newParagraph.Text = newParagraph.Text.Remove(3, 1); + } + + var continuationStyle = Configuration.Settings.General.ContinuationStyle; + if (continuationStyle != ContinuationStyle.None) + { + if (language == "ar") + { + currentParagraph.Text = ContinuationUtilities.ConvertToForArabic(currentParagraph.Text); + newParagraph.Text = ContinuationUtilities.ConvertToForArabic(newParagraph.Text); + } + + var continuationProfile = ContinuationUtilities.GetContinuationProfile(continuationStyle); + if (ContinuationUtilities.ShouldAddSuffix(currentParagraph.Text, continuationProfile)) + { + currentParagraph.Text = ContinuationUtilities.AddSuffixIfNeeded(currentParagraph.Text, continuationProfile, false); + newParagraph.Text = ContinuationUtilities.AddPrefixIfNeeded(newParagraph.Text, continuationProfile, false); + } + + if (language == "ar") + { + currentParagraph.Text = ContinuationUtilities.ConvertBackForArabic(currentParagraph.Text); + newParagraph.Text = ContinuationUtilities.ConvertBackForArabic(newParagraph.Text); + } + } + + FixSplitItalicTag(currentParagraph, newParagraph); + FixSplitFontTag(currentParagraph, newParagraph); + SetSplitTime(splitSeconds, currentParagraph, newParagraph, oldText); + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + var originalCurrent = Utilities.GetOriginalParagraph(firstSelectedIndex, currentParagraph, _subtitleAlternate.Paragraphs); + if (originalCurrent != null) + { + string languageOriginal = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate); + + originalCurrent.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; + var originalNew = new Paragraph(newParagraph); + originalNew.NewSection = false; + + lines = originalCurrent.Text.SplitToLines(); + + var l0Trimmed = string.Empty; + if (lines.Count > 0) + { + l0Trimmed = HtmlUtil.RemoveHtmlTags(lines[0]).TrimEnd('\'').TrimEnd('"'); + } + + oldText = originalCurrent.Text; + if (alternateTextIndex != null && alternateTextIndex.Value > 1 && alternateTextIndex.Value < oldText.Length - 1) + { + originalCurrent.Text = Utilities.AutoBreakLine(oldText.Substring(0, alternateTextIndex.Value).Trim(), language); + originalNew.Text = Utilities.AutoBreakLine(oldText.Substring(alternateTextIndex.Value).Trim(), language); + if (originalCurrent.Text.Contains("", StringComparison.Ordinal) && !originalCurrent.Text.Contains("", StringComparison.Ordinal) && + originalNew.Text.Contains("", StringComparison.Ordinal) && !originalNew.Text.Contains("", StringComparison.Ordinal)) + { + if (originalCurrent.Text.StartsWith("-", StringComparison.Ordinal) && (originalCurrent.Text.EndsWith(".", StringComparison.Ordinal) || originalCurrent.Text.EndsWith("?", StringComparison.Ordinal) || + originalCurrent.Text.EndsWith("!", StringComparison.Ordinal) || originalCurrent.Text.EndsWith("؟", StringComparison.Ordinal)) && originalNew.Text.StartsWith("-", StringComparison.Ordinal)) + { + originalCurrent.Text = "" + originalCurrent.Text.Remove(0, 4).Trim(); + originalNew.Text = originalNew.Text.TrimStart('-').Trim(); + } + + originalCurrent.Text = originalCurrent.Text + ""; + originalNew.Text = "" + originalNew.Text; + } + + if (originalCurrent.Text.Contains("", StringComparison.Ordinal) && !originalCurrent.Text.Contains("") && + originalNew.Text.Contains("", StringComparison.Ordinal) && !originalNew.Text.Contains("")) + { + originalCurrent.Text = originalCurrent.Text + ""; + originalNew.Text = "" + originalNew.Text; + } + + if (Configuration.Settings.General.SplitRemovesDashes && (l0Trimmed.EndsWith('.') || l0Trimmed.EndsWith('!') || l0Trimmed.EndsWith('?') || l0Trimmed.EndsWith('؟'))) + { + originalCurrent.Text = DialogSplitMerge.RemoveStartDash(originalCurrent.Text); + originalNew.Text = DialogSplitMerge.RemoveStartDash(originalNew.Text); + } + + lines.Clear(); + } + else if (lines.Count == 2 && (l0Trimmed.EndsWith('.') || l0Trimmed.EndsWith('!') || l0Trimmed.EndsWith('?') || l0Trimmed.EndsWith('؟'))) + { + string a = lines[0].Trim(); + string b = lines[1].Trim(); + if (oldText.TrimStart().StartsWith("", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("", StringComparison.Ordinal) && + Utilities.CountTagInText(oldText, "") == 1 && Utilities.CountTagInText(oldText, "") == 1) + { + a = a + ""; + b = "" + b; + } + + if (oldText.TrimStart().StartsWith("", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("", StringComparison.Ordinal) && + Utilities.CountTagInText(oldText, "") == 1 && Utilities.CountTagInText(oldText, "") == 1) + { + a = a + ""; + b = "" + b; + } + + if (Configuration.Settings.General.SplitRemovesDashes) + { + a = DialogSplitMerge.RemoveStartDash(a); + b = DialogSplitMerge.RemoveStartDash(b); + } + + lines[0] = a; + lines[1] = b; + originalCurrent.Text = Utilities.AutoBreakLine(a); + originalNew.Text = Utilities.AutoBreakLine(b); + } + else if (Utilities.GetNumberOfLines(originalCurrent.Text) == 2) + { + lines = originalCurrent.Text.SplitToLines(); + } + else + { + string s = Utilities.AutoBreakLine(originalCurrent.Text, 5, Configuration.Settings.General.MergeLinesShorterThan, languageOriginal); + lines = s.SplitToLines(); + } + + if (lines.Count == 1) + { + string s = Utilities.AutoBreakLine(lines[0], 3, 20, languageOriginal); + lines = s.SplitToLines(); + } + + if (lines.Count == 1) + { + string s = Utilities.AutoBreakLine(lines[0], 3, 18, languageOriginal); + lines = s.SplitToLines(); + } + + if (lines.Count == 1) + { + string s = Utilities.AutoBreakLine(lines[0], 3, 15, languageOriginal); + lines = s.SplitToLines(); + } + + if (lines.Count == 2) + { + string a = lines[0].Trim(); + string b = lines[1].Trim(); + if (oldText.TrimStart().StartsWith("", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("", StringComparison.Ordinal) && + Utilities.CountTagInText(oldText, "") == 1 && Utilities.CountTagInText(oldText, "") == 1) + { + a = a + ""; + b = "" + b; + } + + if (oldText.TrimStart().StartsWith("", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("", StringComparison.Ordinal) && + Utilities.CountTagInText(oldText, "") == 1 && Utilities.CountTagInText(oldText, "") == 1) + { + a = a + ""; + b = "" + b; + } + + if (Configuration.Settings.General.SplitRemovesDashes && (l0Trimmed.EndsWith('.') || l0Trimmed.EndsWith('!') || l0Trimmed.EndsWith('?') || l0Trimmed.EndsWith('؟'))) + { + a = DialogSplitMerge.RemoveStartDash(a); + b = DialogSplitMerge.RemoveStartDash(b); + } + + lines[0] = a; + lines[1] = b; + + originalCurrent.Text = Utilities.AutoBreakLine(lines[0]); + originalNew.Text = Utilities.AutoBreakLine(lines[1]); + } + else if (lines.Count == 1) + { + originalNew.Text = string.Empty; + } + + if (originalCurrent != null && originalNew != null) + { + if (originalCurrent.Text.StartsWith(" ", StringComparison.Ordinal)) + { + originalCurrent.Text = originalCurrent.Text.Remove(3, 1); + } + + if (originalNew.Text.StartsWith(" ", StringComparison.Ordinal)) + { + originalCurrent.Text = originalCurrent.Text.Remove(3, 1); + } + + if (continuationStyle != ContinuationStyle.None) + { + if (languageOriginal == "ar") + { + originalCurrent.Text = ContinuationUtilities.ConvertToForArabic(originalCurrent.Text); + originalNew.Text = ContinuationUtilities.ConvertToForArabic(originalNew.Text); + } + + var continuationProfile = ContinuationUtilities.GetContinuationProfile(continuationStyle); + if (ContinuationUtilities.ShouldAddSuffix(originalCurrent.Text, continuationProfile)) + { + originalCurrent.Text = ContinuationUtilities.AddSuffixIfNeeded(originalCurrent.Text, continuationProfile, false); + originalNew.Text = ContinuationUtilities.AddPrefixIfNeeded(originalNew.Text, continuationProfile, false); + } + + if (languageOriginal == "ar") + { + originalCurrent.Text = ContinuationUtilities.ConvertBackForArabic(originalCurrent.Text); + originalNew.Text = ContinuationUtilities.ConvertBackForArabic(originalNew.Text); + } + } + } + + _subtitleAlternate.InsertParagraphInCorrectTimeOrder(originalNew); + _subtitleAlternate.Renumber(); + FixSplitItalicTag(originalCurrent, originalNew); + FixSplitFontTag(originalCurrent, originalNew); + } + } + + if (_networkSession != null) + { + _networkSession.TimerStop(); + SetDurationInSeconds(currentParagraph.Duration.TotalSeconds); + _networkSession.UpdateLine(_subtitle.GetIndex(currentParagraph), currentParagraph); + NetworkGetSendUpdates(new List(), firstSelectedIndex + 1, newParagraph); + } + else + { + _subtitle.Paragraphs.Insert(firstSelectedIndex + 1, newParagraph); + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + SubtitleListview1.SelectIndexAndEnsureVisible(Configuration.Settings.General.SplitBehavior == 0 ? firstSelectedIndex + 1 : firstSelectedIndex, true); + ShowSource(); + ShowStatus(_language.LineSplitted); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + RefreshSelectedParagraph(); + } + } + + private void FixSplitItalicTag(Paragraph currentParagraph, Paragraph nextParagraph) + { + if (currentParagraph == null || nextParagraph == null) + { + return; + } + + var startIdx = currentParagraph.Text.LastIndexOf("", StringComparison.OrdinalIgnoreCase); + if (startIdx >= 0 && + !currentParagraph.Text.Contains("", StringComparison.OrdinalIgnoreCase) && + nextParagraph.Text.Contains("", StringComparison.OrdinalIgnoreCase)) + { + var endIdx = currentParagraph.Text.IndexOf('>', startIdx); + if (endIdx >= 0) + { + var fontTag = currentParagraph.Text.Substring(startIdx, endIdx - startIdx + 1); + var pre = string.Empty; + if (currentParagraph.Text.StartsWith('{') && currentParagraph.Text.IndexOf('}') > 0) + { + var i = currentParagraph.Text.IndexOf('}'); + pre = currentParagraph.Text.Substring(0, i + 1); + currentParagraph.Text = currentParagraph.Text.Remove(0, i + 1); + } + + currentParagraph.Text = pre + currentParagraph.Text + ""; + nextParagraph.Text = pre + fontTag + nextParagraph.Text; + } + } + } + + private void FixSplitFontTag(Paragraph currentParagraph, Paragraph nextParagraph) + { + if (currentParagraph == null || nextParagraph == null) + { + return; + } + + var startIdx = currentParagraph.Text.LastIndexOf("= 0 && + !currentParagraph.Text.Contains("", StringComparison.OrdinalIgnoreCase) && + nextParagraph.Text.Contains("
", StringComparison.OrdinalIgnoreCase)) + { + var endIdx = currentParagraph.Text.IndexOf('>', startIdx); + if (endIdx >= 0) + { + var fontTag = currentParagraph.Text.Substring(startIdx, endIdx - startIdx + 1); + var pre = string.Empty; + if (currentParagraph.Text.StartsWith('{') && currentParagraph.Text.IndexOf('}') > 0) + { + var i = currentParagraph.Text.IndexOf('}'); + pre = currentParagraph.Text.Substring(0, i + 1); + currentParagraph.Text = currentParagraph.Text.Remove(0, i + 1); + } + + currentParagraph.Text = pre + currentParagraph.Text + "
"; + nextParagraph.Text = pre + fontTag + nextParagraph.Text; + } + } + } + + private void SetSplitTime(double? splitSeconds, Paragraph currentParagraph, Paragraph newParagraph, string oldText) + { + double middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.Duration.TotalMilliseconds / 2); + if (!string.IsNullOrWhiteSpace(HtmlUtil.RemoveHtmlTags(oldText))) + { + var lineOneTextNoHtml = HtmlUtil.RemoveHtmlTags(currentParagraph.Text, true).Replace(Environment.NewLine, string.Empty); + var lineTwoTextNoHtml = HtmlUtil.RemoveHtmlTags(newParagraph.Text, true).Replace(Environment.NewLine, string.Empty); + if (Math.Abs(lineOneTextNoHtml.Length - lineTwoTextNoHtml.Length) > 2) + { + // give more time to the paragraph with most text + var oldTextNoHtml = HtmlUtil.RemoveHtmlTags(oldText, true).Replace(Environment.NewLine, string.Empty); + var startFactor = (double)lineOneTextNoHtml.Length / oldTextNoHtml.Length; + if (startFactor < 0.25) + { + startFactor = 0.25; + } + + if (startFactor > 0.75) + { + startFactor = 0.75; + } + + middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.Duration.TotalMilliseconds * startFactor); + } + } + + if (currentParagraph.StartTime.IsMaxTime && currentParagraph.EndTime.IsMaxTime) + { + newParagraph.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + newParagraph.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + } + else + { + if (splitSeconds.HasValue && splitSeconds.Value > (currentParagraph.StartTime.TotalSeconds + 0.2) && splitSeconds.Value < (currentParagraph.EndTime.TotalSeconds - 0.2)) + { + middle = splitSeconds.Value * TimeCode.BaseUnit; + } + + newParagraph.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; + currentParagraph.EndTime.TotalMilliseconds = middle; + newParagraph.StartTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds + 1; + if (Configuration.Settings.General.MinimumMillisecondsBetweenLines > 0) + { + if (splitSeconds == null || Configuration.Settings.General.SplitBehavior == 1) + { + // SE decides split point (not user), so split gap time evenly + var halfGap = (int)Math.Round(Configuration.Settings.General.MinimumMillisecondsBetweenLines / 2.0); + currentParagraph.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds - halfGap; + } + else if (Configuration.Settings.General.SplitBehavior == 0) + { + currentParagraph.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + newParagraph.StartTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + + private void MergeBeforeToolStripMenuItemClick(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedItems.Count >= 1) + { + var idx = SubtitleListview1.SelectedItems[0].Index; + if (idx > 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(idx - 1, true); + MergeAfterToolStripMenuItemClick(null, null); + } + } + } + + private void MergeSelectedLinesBilingual() + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 1) + { + var sb1 = new StringBuilder(); + var sb2 = new StringBuilder(); + var deleteIndices = new List(); + bool first = true; + int firstIndex = 0; + double durationMilliseconds = 0; + int next = 0; + foreach (int index in SubtitleListview1.SelectedIndices) + { + if (first) + { + firstIndex = index; + next = index + 1; + first = !first; + } + else + { + deleteIndices.Add(index); + if (next != index) + { + return; + } + + next++; + } + + var arr = _subtitle.Paragraphs[index].Text.Trim().SplitToLines(); + if (arr.Count > 0) + { + int mid = (int)(arr.Count / 2); + for (var i = 0; i < arr.Count; i++) + { + var l = arr[i]; + if (i < mid) + { + sb1.Append(l + " "); + } + else + { + sb2.Append(l + " "); + } + } + } + + durationMilliseconds += _subtitle.Paragraphs[index].Duration.TotalMilliseconds; + } + + if (sb1.Length > 150 || sb2.Length > 150) + { + return; + } + + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + MakeHistoryForUndo(_language.BeforeMergeLines); + + var currentParagraph = _subtitle.Paragraphs[firstIndex]; + string text1 = sb1.ToString().TrimEnd(); + string text2 = sb2.ToString().TrimEnd(); + + currentParagraph.Text = text1 + Environment.NewLine + text2; + + //display time + currentParagraph.EndTime.TotalMilliseconds = currentParagraph.StartTime.TotalMilliseconds + durationMilliseconds; + + var nextParagraph = _subtitle.GetParagraphOrDefault(next); + if (nextParagraph != null && currentParagraph.EndTime.TotalMilliseconds > nextParagraph.StartTime.TotalMilliseconds && currentParagraph.StartTime.TotalMilliseconds < nextParagraph.StartTime.TotalMilliseconds) + { + currentParagraph.EndTime.TotalMilliseconds = nextParagraph.StartTime.TotalMilliseconds - 1; + } + + if (_networkSession != null) + { + _networkSession.TimerStop(); + _networkSession.UpdateLine(firstIndex, currentParagraph); + NetworkGetSendUpdates(deleteIndices, 0, null); + } + else + { + for (int i = deleteIndices.Count - 1; i >= 0; i--) + { + _subtitle.Paragraphs.RemoveAt(deleteIndices[i]); + } + + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + ShowSource(); + ShowStatus(_language.LinesMerged); + SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex, true); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + RefreshSelectedParagraph(); + } + } + + private void SplitSelectedLineBilingual() + { + var idx = FirstSelectedIndex; + if (_subtitle.Paragraphs.Count < 1 || idx < 0) + { + return; + } + + var p = _subtitle.GetParagraphOrDefault(idx); + if (p == null) + { + return; + } + + var tb = textBoxListViewText; + var lines = tb.Text.SplitToLines(); + if (lines.Count != 2 || tb.SelectionLength < 3 || lines[0].Length < 2 || lines[1].Length < 2) + { + return; + } + + var start = tb.SelectionStart; + var end = start + tb.SelectionLength; + var indexOfNewLine = tb.Text.IndexOf(Environment.NewLine, StringComparison.Ordinal); + if (end < indexOfNewLine || start > indexOfNewLine) + { + return; + } + + MakeHistoryForUndo(_language.BeforeSplitLine); + var oldText = p.Text; + string text1 = lines[0].Substring(0, start).Trim() + Environment.NewLine + lines[1].Substring(0, end - indexOfNewLine - 2).Trim(); + string text2 = lines[0].Remove(0, start).Trim() + Environment.NewLine + lines[1].Remove(0, end - indexOfNewLine - 2).Trim(); + var newParagraph = new Paragraph(p); + newParagraph.NewSection = false; + double? splitPos = null; + if (!string.IsNullOrEmpty(VideoFileName)) + { + splitPos = mediaPlayer.CurrentPosition; + } + + SetSplitTime(splitPos, p, newParagraph, oldText); + _subtitle.InsertParagraphInCorrectTimeOrder(newParagraph); + _subtitle.Renumber(); + if (Configuration.Settings.General.SplitBehavior > 0) + { + _subtitleListViewIndex = -1; + } + p.Text = text1; + newParagraph.Text = text2; + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(idx, true); + } + + private void MergeSelectedLines(BreakMode breakMode = BreakMode.Normal) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 1) + { + var sb = new StringBuilder(); + var deleteIndices = new List(); + bool first = true; + int firstIndex = 0; + double endMilliseconds = 0; + int next = 0; + foreach (int index in SubtitleListview1.SelectedIndices) + { + if (first) + { + firstIndex = index; + next = index + 1; + first = !first; + } + else + { + deleteIndices.Add(index); + if (next != index) + { + return; + } + + next++; + } + + var continuationStyle = Configuration.Settings.General.ContinuationStyle; + if (continuationStyle != ContinuationStyle.None) + { + var continuationProfile = ContinuationUtilities.GetContinuationProfile(continuationStyle); + if (next < firstIndex + SubtitleListview1.SelectedIndices.Count) + { + var mergeResult = ContinuationUtilities.MergeHelper(_subtitle.Paragraphs[index].Text, _subtitle.Paragraphs[index + 1].Text, continuationProfile, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle)); + _subtitle.Paragraphs[index].Text = mergeResult.Item1; + _subtitle.Paragraphs[index + 1].Text = mergeResult.Item2; + } + } + + var addText = _subtitle.Paragraphs[index].Text; + + if (firstIndex != index) + { + addText = RemoveAssStartAlignmentTag(addText); + } + + if (breakMode == BreakMode.UnbreakNoSpace) + { + sb.Append(addText); + } + else + { + sb.AppendLine(addText); + } + + endMilliseconds = _subtitle.Paragraphs[index].EndTime.TotalMilliseconds; + } + + if (sb.Length > 200) + { + return; + } + + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + MakeHistoryForUndo(_language.BeforeMergeLines); + + var currentParagraph = _subtitle.Paragraphs[firstIndex]; + string text = sb.ToString(); + text = HtmlUtil.FixInvalidItalicTags(text); + text = ChangeAllLinesTagsToSingleTag(text, "i"); + text = ChangeAllLinesTagsToSingleTag(text, "b"); + text = ChangeAllLinesTagsToSingleTag(text, "u"); + if (breakMode == BreakMode.Unbreak) + { + text = Utilities.UnbreakLine(text); + } + else if (breakMode == BreakMode.UnbreakNoSpace) + { + text = text.Replace(" " + Environment.NewLine + " ", string.Empty) + .Replace(Environment.NewLine + " ", string.Empty) + .Replace(" " + Environment.NewLine, string.Empty) + .Replace(Environment.NewLine, string.Empty); + } + else + { + text = Utilities.AutoBreakLine(text, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle)); + } + + currentParagraph.Text = text; + + //display time + currentParagraph.EndTime.TotalMilliseconds = endMilliseconds; + + var nextParagraph = _subtitle.GetParagraphOrDefault(next); + if (nextParagraph != null && currentParagraph.EndTime.TotalMilliseconds > nextParagraph.StartTime.TotalMilliseconds && currentParagraph.StartTime.TotalMilliseconds < nextParagraph.StartTime.TotalMilliseconds) + { + currentParagraph.EndTime.TotalMilliseconds = nextParagraph.StartTime.TotalMilliseconds - 1; + } + + // original subtitle + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(firstIndex, currentParagraph, _subtitleAlternate.Paragraphs); + if (original != null) + { + var originalTexts = new StringBuilder(); + originalTexts.Append(original.Text.TrimEnd()); + if (breakMode != BreakMode.UnbreakNoSpace) + { + originalTexts.Append(" "); + } + + for (int i = 0; i < deleteIndices.Count; i++) + { + var originalNext = Utilities.GetOriginalParagraph(deleteIndices[i], _subtitle.Paragraphs[deleteIndices[i]], _subtitleAlternate.Paragraphs); + if (originalNext != null) + { + if (breakMode == BreakMode.UnbreakNoSpace) + { + originalTexts.Append(originalNext.Text.Trim()); + } + else + { + originalTexts.Append(originalNext.Text + " "); + } + } + + } + + for (int i = deleteIndices.Count - 1; i >= 0; i--) + { + var originalNext = Utilities.GetOriginalParagraph(deleteIndices[i], _subtitle.Paragraphs[deleteIndices[i]], _subtitleAlternate.Paragraphs); + if (originalNext != null) + { + _subtitleAlternate.Paragraphs.Remove(originalNext); + } + } + + original.Text = originalTexts.ToString().Replace(" ", " "); + original.Text = ChangeAllLinesTagsToSingleTag(original.Text, "i"); + original.Text = ChangeAllLinesTagsToSingleTag(original.Text, "b"); + original.Text = ChangeAllLinesTagsToSingleTag(original.Text, "u"); + + if (breakMode == BreakMode.Unbreak) + { + original.Text = Utilities.UnbreakLine(original.Text); + } + else if (breakMode == BreakMode.UnbreakNoSpace) + { + original.Text = original.Text.Replace(" " + Environment.NewLine + " ", string.Empty) + .Replace(Environment.NewLine + " ", string.Empty) + .Replace(" " + Environment.NewLine, string.Empty) + .Replace(Environment.NewLine, string.Empty); + } + else + { + original.Text = Utilities.AutoBreakLine(original.Text, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate)); + } + + original.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; + _subtitleAlternate.Renumber(); + } + } + + if (_networkSession != null) + { + _networkSession.TimerStop(); + _networkSession.UpdateLine(firstIndex, currentParagraph); + NetworkGetSendUpdates(deleteIndices, 0, null); + } + else + { + for (int i = deleteIndices.Count - 1; i >= 0; i--) + { + _subtitle.Paragraphs.RemoveAt(deleteIndices[i]); + } + + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + ShowSource(); + ShowStatus(_language.LinesMerged); + SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex, true); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + RefreshSelectedParagraph(); + } + } + + private void ExtendBeforeToolStripMenuItemClick(object sender, EventArgs e) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) + { + ExtendSelectedLinesToPreviousLine(); + } + } + + private void ExtendAfterToolStripMenuItemClick(object sender, EventArgs e) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) + { + ExtendSelectedLinesToNextLine(); + } + } + + private static string ChangeAllLinesTagsToSingleTag(string text, string tag) + { + if (!text.Contains("<" + tag + ">")) + { + return text; + } + + foreach (var line in text.SplitToLines()) + { + if (!line.TrimStart().StartsWith("<" + tag + ">", StringComparison.Ordinal) || !line.TrimEnd().EndsWith("", StringComparison.Ordinal)) + { + return text; + } + } + + return "<" + tag + ">" + HtmlUtil.RemoveOpenCloseTags(text, tag).Trim() + ""; + } + + private void MergeAfterToolStripMenuItemClick(object sender, EventArgs e) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) + { + if (SubtitleListview1.SelectedItems.Count > 2) + { + MergeSelectedLines(); + return; + } + + MergeWithLineAfter(false); + } + } + + public enum BreakMode + { + AutoBreak, + Normal, + Unbreak, + UnbreakNoSpace + } + + private void MergeWithLineAfter(bool insertDash, BreakMode breakMode = BreakMode.Normal) + { + var dialogHelper = new DialogSplitMerge { DialogStyle = Configuration.Settings.General.DialogStyle }; + int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + + var currentParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex); + var nextParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex + 1); + + if (nextParagraph != null && currentParagraph != null) + { + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + MakeHistoryForUndo(_language.BeforeMergeLines); + + var continuationStyle = Configuration.Settings.General.ContinuationStyle; + if (continuationStyle != ContinuationStyle.None) + { + var continuationProfile = ContinuationUtilities.GetContinuationProfile(continuationStyle); + var mergeResult = ContinuationUtilities.MergeHelper(currentParagraph.Text, nextParagraph.Text, continuationProfile, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle)); + currentParagraph.Text = mergeResult.Item1; + nextParagraph.Text = mergeResult.Item2; + } + + if (_subtitleAlternate != null) + { + var original = Utilities.GetOriginalParagraph(firstSelectedIndex, currentParagraph, _subtitleAlternate.Paragraphs); + var originalNext = Utilities.GetOriginalParagraph(firstSelectedIndex + 1, nextParagraph, _subtitleAlternate.Paragraphs); + + if (original != null && originalNext != null) + { + if (continuationStyle != ContinuationStyle.None) + { + var continuationProfile = ContinuationUtilities.GetContinuationProfile(continuationStyle); + var mergeResult = ContinuationUtilities.MergeHelper(original.Text, originalNext.Text, continuationProfile, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate)); + original.Text = mergeResult.Item1; + originalNext.Text = mergeResult.Item2; + } + } + + if (originalNext != null) + { + if (original == null) + { + originalNext.StartTime.TotalMilliseconds = currentParagraph.StartTime.TotalMilliseconds; + originalNext.EndTime.TotalMilliseconds = nextParagraph.EndTime.TotalMilliseconds; + } + else + { + if (insertDash && !string.IsNullOrEmpty(original.Text) && !string.IsNullOrEmpty(originalNext.Text)) + { + string s = Utilities.UnbreakLine(original.Text); + original.Text = dialogHelper.InsertStartDash(s, 0); + + s = Utilities.UnbreakLine(originalNext.Text); + original.Text += Environment.NewLine + dialogHelper.InsertStartDash(s, 1); + + original.Text = original.Text.Replace("" + Environment.NewLine + "", Environment.NewLine).TrimEnd(); + } + else + { + string old1 = original.Text; + string old2 = originalNext.Text; + + if (breakMode == BreakMode.Unbreak) + { + original.Text = old1.Replace(Environment.NewLine, " "); + original.Text += Environment.NewLine + old2.Replace(Environment.NewLine, " "); + original.Text = Utilities.UnbreakLine(original.Text); + } + else if (breakMode == BreakMode.UnbreakNoSpace) + { + original.Text = old1.TrimEnd() + old2.TrimStart(); + } + else + { + original.Text = old1.Replace(Environment.NewLine, " "); + original.Text += Environment.NewLine + old2.Replace(Environment.NewLine, " "); + + if (old1.Contains(Environment.NewLine) || old2.Contains(Environment.NewLine) || + old1.Length > Configuration.Settings.General.SubtitleLineMaximumLength || old2.Length > Configuration.Settings.General.SubtitleLineMaximumLength) + { + original.Text = Utilities.AutoBreakLine(original.Text, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate)); + } + } + + original.Text = ChangeAllLinesTagsToSingleTag(original.Text, "i"); + original.Text = ChangeAllLinesTagsToSingleTag(original.Text, "b"); + original.Text = ChangeAllLinesTagsToSingleTag(original.Text, "u"); + + if (string.IsNullOrWhiteSpace(old1)) + { + original.Text = original.Text.TrimStart(); + } + + if (string.IsNullOrWhiteSpace(old2)) + { + original.Text = original.Text.TrimEnd(); + } + } + + original.EndTime = originalNext.EndTime; + _subtitleAlternate.Paragraphs.Remove(originalNext); + } + + _subtitleAlternate.Renumber(); + } + } + + if (insertDash && !string.IsNullOrEmpty(currentParagraph.Text) && !string.IsNullOrEmpty(nextParagraph.Text)) + { + string s = Utilities.UnbreakLine(currentParagraph.Text); + currentParagraph.Text = dialogHelper.InsertStartDash(s, 0); + + s = Utilities.UnbreakLine(RemoveAssStartAlignmentTag(nextParagraph.Text)); + currentParagraph.Text += Environment.NewLine + dialogHelper.InsertStartDash(s, 1); + + currentParagraph.Text = currentParagraph.Text.Replace("" + Environment.NewLine + "", Environment.NewLine).TrimEnd(); + } + else + { + string old1 = currentParagraph.Text; + string old2 = nextParagraph.Text; + if (breakMode == BreakMode.Unbreak) + { + currentParagraph.Text = currentParagraph.Text.Replace(Environment.NewLine, " "); + currentParagraph.Text += Environment.NewLine + nextParagraph.Text.Replace(Environment.NewLine, " "); + currentParagraph.Text = Utilities.UnbreakLine(RemoveAssStartAlignmentTag(currentParagraph.Text)); + } + else if (breakMode == BreakMode.UnbreakNoSpace) + { + currentParagraph.Text = currentParagraph.Text.TrimEnd() + RemoveAssStartAlignmentTag(nextParagraph.Text).TrimStart(); + } + else if (breakMode == BreakMode.AutoBreak) + { + currentParagraph.Text = currentParagraph.Text.Replace(Environment.NewLine, " "); + currentParagraph.Text += Environment.NewLine + RemoveAssStartAlignmentTag(nextParagraph.Text).Replace(Environment.NewLine, " "); + var language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); + currentParagraph.Text = Utilities.AutoBreakLine(currentParagraph.Text, language); + } + else + { + currentParagraph.Text = (currentParagraph.Text.Trim() + Environment.NewLine + + RemoveAssStartAlignmentTag(nextParagraph.Text).Trim()).Trim(); + } + + currentParagraph.Text = ChangeAllLinesTagsToSingleTag(currentParagraph.Text, "i"); + currentParagraph.Text = ChangeAllLinesTagsToSingleTag(currentParagraph.Text, "b"); + currentParagraph.Text = ChangeAllLinesTagsToSingleTag(currentParagraph.Text, "u"); + + if (old1.Contains(Environment.NewLine) || old2.Contains(Environment.NewLine) || + old1.Length > Configuration.Settings.General.SubtitleLineMaximumLength || old2.Length > Configuration.Settings.General.SubtitleLineMaximumLength) + { + currentParagraph.Text = Utilities.AutoBreakLine(currentParagraph.Text, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle)); + } + + if (string.IsNullOrWhiteSpace(old1) && old2 != null) + { + currentParagraph.Text = old2.Trim(); + } + + if (string.IsNullOrWhiteSpace(old2) && old1 != null) + { + currentParagraph.Text = old1.Trim(); + } + } + + currentParagraph.EndTime.TotalMilliseconds = nextParagraph.EndTime.TotalMilliseconds; + + if (_networkSession != null) + { + _networkSession.TimerStop(); + SetDurationInSeconds(currentParagraph.Duration.TotalSeconds); + _networkSession.UpdateLine(_subtitle.GetIndex(currentParagraph), currentParagraph); + var deleteIndices = new List(); + deleteIndices.Add(_subtitle.GetIndex(nextParagraph)); + NetworkGetSendUpdates(deleteIndices, 0, null); + } + else + { + _subtitle.Paragraphs.Remove(nextParagraph); + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + ShowSource(); + ShowStatus(_language.LinesMerged); + SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + RefreshSelectedParagraph(); + SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); + } + } + + private static string RemoveAssStartAlignmentTag(string text) + { + var s = text.TrimStart(); + if (s.StartsWith("{\\an") && s.Length > 5 && s[5] == '}') + { + s = s.Remove(0, 6); + } + return s; + } + + private void UpdateStartTimeInfo(TimeCode startTime) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0 && startTime != null) + { + UpdateOverlapErrors(startTime); + + // update _subtitle + listview + var p = _subtitle.Paragraphs[_subtitleListViewIndex]; + p.EndTime.TotalMilliseconds += (startTime.TotalMilliseconds - p.StartTime.TotalMilliseconds); + p.StartTime = startTime; + SubtitleListview1.SetStartTimeAndDuration(_subtitleListViewIndex, p, _subtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1), _subtitle.GetParagraphOrDefault(_subtitleListViewIndex - 1)); + StartUpdateListSyntaxColoring(); + } + } + + private void StartUpdateListSyntaxColoring() + { + if (!_timerDoSyntaxColoring.Enabled) + { + _timerDoSyntaxColoring.Start(); + } + } + + private void UpdateListSyntaxColoring() + { + if (_loading || _subtitle == null || _subtitleListViewIndex < 0 || _subtitleListViewIndex >= _subtitle.Paragraphs.Count) + { + return; + } + + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, _subtitleListViewIndex, _subtitle.Paragraphs[_subtitleListViewIndex]); + var idx = _subtitleListViewIndex + 1; + var p = _subtitle.GetParagraphOrDefault(idx); + if (p != null) + { + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, idx, p); + } + + idx = _subtitleListViewIndex - 1; + p = _subtitle.GetParagraphOrDefault(idx); + if (p != null) + { + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, idx, p); + } + } + + private void UpdateOverlapErrors(TimeCode startTime) + { + string startTimeWarning = string.Empty; + string durationWarning = string.Empty; + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0 && startTime != null) + { + int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + + var prevParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex - 1); + if (prevParagraph != null && !prevParagraph.EndTime.IsMaxTime && prevParagraph.EndTime.TotalMilliseconds > startTime.TotalMilliseconds && Configuration.Settings.Tools.ListViewSyntaxColorOverlap) + { + startTimeWarning = string.Format(_languageGeneral.OverlapPreviousLineX, prevParagraph.EndTime.TotalSeconds - startTime.TotalSeconds); + } + + var nextParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex + 1); + if (nextParagraph != null) + { + double durationMilliSeconds = GetDurationInMilliseconds(); + if (startTime.TotalMilliseconds + durationMilliSeconds > nextParagraph.StartTime.TotalMilliseconds && + Configuration.Settings.Tools.ListViewSyntaxColorOverlap && + !startTime.IsMaxTime) + { + durationWarning = string.Format(_languageGeneral.OverlapX, ((startTime.TotalMilliseconds + durationMilliSeconds) - nextParagraph.StartTime.TotalMilliseconds) / TimeCode.BaseUnit); + } + + if (startTimeWarning.Length == 0 && + startTime.TotalMilliseconds > nextParagraph.StartTime.TotalMilliseconds && + Configuration.Settings.Tools.ListViewSyntaxColorOverlap && + !startTime.IsMaxTime) + { + double di = (startTime.TotalMilliseconds - nextParagraph.StartTime.TotalMilliseconds) / TimeCode.BaseUnit; + startTimeWarning = string.Format(_languageGeneral.OverlapNextX, di); + } + else if (numericUpDownDuration.Value < 0) + { + durationWarning = _languageGeneral.Negative; + } + } + } + + labelStartTimeWarning.Text = startTimeWarning; + labelDurationWarning.Text = durationWarning; + } + + private double _durationMsInitialValue = 0; + private bool _durationIsDirty = false; + + private double GetDurationInMilliseconds() + { + if (!_durationIsDirty) + { + return _durationMsInitialValue; + } + + if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) + { + var seconds = (int)numericUpDownDuration.Value; + var frames = (int)Math.Round((Convert.ToDouble(numericUpDownDuration.Value) % 1.0 * 100.0)); + return seconds * TimeCode.BaseUnit + frames * (TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate); + } + + return ((double)numericUpDownDuration.Value * TimeCode.BaseUnit); + } + + private bool _skipDurationChangedEvent = false; + private void SetDurationInSeconds(double seconds) + { + _durationIsDirty = false; + _durationMsInitialValue = seconds * 1000.0; + if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) + { + var wholeSeconds = (int)seconds; + var frames = SubtitleFormat.MillisecondsToFrames(seconds % 1.0 * TimeCode.BaseUnit); + var extraSeconds = (int)(frames / Configuration.Settings.General.CurrentFrameRate); + var restFrames = (int)(frames % Configuration.Settings.General.CurrentFrameRate); + var v = (decimal)(wholeSeconds + extraSeconds + restFrames / 100.0); + if (v >= numericUpDownDuration.Minimum && v <= numericUpDownDuration.Maximum) + { + _skipDurationChangedEvent = true; + numericUpDownDuration.Value = (decimal)(wholeSeconds + extraSeconds + restFrames / 100.0); + _skipDurationChangedEvent = false; + + int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + var currentParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex); + if (currentParagraph != null) + { + UpdateOverlapErrors(timeUpDownStartTime.TimeCode); + UpdateListViewTextCharactersPerSeconds(labelCharactersPerSecond, currentParagraph); + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + var original = Utilities.GetOriginalParagraph(firstSelectedIndex, currentParagraph, _subtitleAlternate.Paragraphs); + if (original != null) + { + original.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; + UpdateListViewTextCharactersPerSeconds(labelAlternateCharactersPerSecond, original); + } + } + + SubtitleListview1.SetDuration(firstSelectedIndex, currentParagraph, _subtitle.GetParagraphOrDefault(firstSelectedIndex + 1)); + StartUpdateListSyntaxColoring(); + } + } + } + else + { + var d = (decimal)seconds; + if (d > numericUpDownDuration.Maximum) + { + numericUpDownDuration.Value = numericUpDownDuration.Maximum; + } + else if (d < numericUpDownDuration.Minimum) + { + numericUpDownDuration.Value = numericUpDownDuration.Minimum; + } + else + { + numericUpDownDuration.Value = d; + } + } + } + + private void NumericUpDownDurationValueChanged(object sender, EventArgs e) + { + if (_skipDurationChangedEvent) + { + return; + } + + _durationIsDirty = true; + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) + { + int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + + var currentParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex); + if (currentParagraph != null) + { + // update _subtitle + listview + string oldDuration = currentParagraph.Duration.ToString(); + + var temp = new Paragraph(currentParagraph); + + if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) + { + var seconds = (int)numericUpDownDuration.Value; + var frames = Convert.ToInt32((numericUpDownDuration.Value - seconds) * 100); + if (frames > Math.Round(Configuration.Settings.General.CurrentFrameRate) - 1) + { + numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged; + if (frames >= 99) + { + numericUpDownDuration.Value = (decimal)(seconds + (Math.Round((Configuration.Settings.General.CurrentFrameRate - 1)) / 100.0)); + } + else + { + numericUpDownDuration.Value = seconds + 1; + } + + numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged; + } + } + + temp.EndTime.TotalMilliseconds = currentParagraph.StartTime.TotalMilliseconds + GetDurationInMilliseconds(); + + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.DisplayTimeAdjustedX, "#" + currentParagraph.Number + ": " + oldDuration + " -> " + temp.Duration)); + + currentParagraph.EndTime.TotalMilliseconds = temp.EndTime.TotalMilliseconds; + SubtitleListview1.SetDuration(firstSelectedIndex, currentParagraph, _subtitle.GetParagraphOrDefault(firstSelectedIndex + 1)); + + UpdateOverlapErrors(timeUpDownStartTime.TimeCode); + UpdateListViewTextCharactersPerSeconds(labelCharactersPerSecond, currentParagraph); + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + var original = Utilities.GetOriginalParagraph(firstSelectedIndex, currentParagraph, _subtitleAlternate.Paragraphs); + if (original != null) + { + original.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; + UpdateListViewTextCharactersPerSeconds(labelAlternateCharactersPerSecond, original); + } + } + + StartUpdateListSyntaxColoring(); + } + + labelStatus.Text = string.Empty; + StartUpdateListSyntaxColoring(); + } + } + + private void InitializeListViewEditBoxAlternate(Paragraph p, int firstSelectedIndex) + { + if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + var original = Utilities.GetOriginalParagraph(firstSelectedIndex, p, _subtitleAlternate.Paragraphs); + if (original == null) + { + textBoxListViewTextAlternate.Enabled = false; + textBoxListViewTextAlternate.Text = string.Empty; + labelAlternateCharactersPerSecond.Text = string.Empty; + } + else + { + textBoxListViewTextAlternate.Enabled = true; + textBoxListViewTextAlternate.TextChanged -= TextBoxListViewTextAlternateTextChanged; + textBoxListViewTextAlternate.Text = original.Text; + textBoxListViewTextAlternate.TextChanged += TextBoxListViewTextAlternateTextChanged; + UpdateListViewTextCharactersPerSeconds(labelAlternateCharactersPerSecond, original); + _listViewAlternateTextUndoLast = original.Text; + } + } + } + + private void InitializeListViewEditBox(Paragraph p) + { + textBoxListViewText.TextChanged -= TextBoxListViewTextTextChanged; + textBoxListViewText.Text = p.Text; + textBoxListViewText.TextChanged += TextBoxListViewTextTextChanged; + _listViewTextUndoLast = p.Text; + + timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; + timeUpDownStartTime.TimeCode = p.StartTime; + timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; + + numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged; + if (p.Duration.TotalSeconds > (double)numericUpDownDuration.Maximum) + { + SetDurationInSeconds((double)numericUpDownDuration.Maximum); + } + else + { + SetDurationInSeconds(p.Duration.TotalSeconds); + } + + numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged; + + UpdateOverlapErrors(timeUpDownStartTime.TimeCode); + UpdateListViewTextCharactersPerSeconds(labelCharactersPerSecond, p); + if (_subtitle != null && _subtitle.Paragraphs.Count > 0) + { + textBoxListViewText.Enabled = true; + } + + StartUpdateListSyntaxColoring(); + ShowHideBookmark(p); + } + + private void MaskedTextBoxTextChanged(object sender, EventArgs e) + { + if (_subtitleListViewIndex >= 0) + { + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.StarTimeAdjustedX, "#" + (_subtitleListViewIndex + 1) + ": " + timeUpDownStartTime.TimeCode)); + + int firstSelectedIndex = FirstSelectedIndex; + var oldParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex); + if (oldParagraph != null) + { + oldParagraph = new Paragraph(oldParagraph, false); + } + + UpdateStartTimeInfo(timeUpDownStartTime.TimeCode); + + UpdateOriginalTimeCodes(oldParagraph); + labelStatus.Text = string.Empty; + } + } + + private void UpdateOriginalTimeCodes(Paragraph currentPargraphBeforeChange, Paragraph p2Before = null) + { + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + Paragraph p1 = null; + Paragraph o1 = null; + if (currentPargraphBeforeChange != null) + { + p1 = _subtitle.GetParagraphOrDefaultById(currentPargraphBeforeChange.Id); + if (p1 != null) + { + o1 = Utilities.GetOriginalParagraph(_subtitle.Paragraphs.IndexOf(p1), currentPargraphBeforeChange, _subtitleAlternate.Paragraphs); + } + } + + Paragraph p2 = null; + Paragraph o2 = null; + if (p2Before != null) + { + p2 = _subtitle.GetParagraphOrDefaultById(p2Before.Id); + if (p2 != null) + { + o2 = Utilities.GetOriginalParagraph(_subtitle.Paragraphs.IndexOf(p2), p2Before, _subtitleAlternate.Paragraphs); + } + } + + if (o1 != null) + { + o1.StartTime.TotalMilliseconds = p1.StartTime.TotalMilliseconds; + o1.EndTime.TotalMilliseconds = p1.EndTime.TotalMilliseconds; + } + + if (o2 != null) + { + o2.StartTime.TotalMilliseconds = p2.StartTime.TotalMilliseconds; + o2.EndTime.TotalMilliseconds = p2.EndTime.TotalMilliseconds; + } + } + } + + private void FormMain_FormClosing(object sender, FormClosingEventArgs e) + { + _lastDoNotPrompt = -1; + ReloadFromSourceView(); + if (!ContinueNewOrExit()) + { + e.Cancel = true; + } + else + { + if (_networkSession != null) + { + try + { + _networkSession.TimerStop(); + _networkSession.Leave(); + } + catch + { + } + } + + if (Configuration.Settings.General.StartRememberPositionAndSize && WindowState != FormWindowState.Minimized) + { + Configuration.Settings.General.StartPosition = Left + ";" + Top; + if (WindowState == FormWindowState.Maximized) + { + Configuration.Settings.General.StartSize = "Maximized"; + } + else + { + Configuration.Settings.General.StartSize = Width + ";" + Height; + } + + Configuration.Settings.General.SplitContainerMainSplitterDistance = splitContainerMain.SplitterDistance; + Configuration.Settings.General.SplitContainer1SplitterDistance = splitContainer1.SplitterDistance; + Configuration.Settings.General.SplitContainerListViewAndTextSplitterDistance = splitContainerListViewAndText.SplitterDistance; + } + + Configuration.Settings.General.AutoRepeatOn = checkBoxAutoRepeatOn.Checked; + if (int.TryParse(comboBoxAutoRepeat.Text, out var autoRepeat)) + { + Configuration.Settings.General.AutoRepeatCount = autoRepeat; + } + + Configuration.Settings.General.AutoContinueOn = checkBoxAutoContinue.Checked; + Configuration.Settings.General.AutoContinueDelay = comboBoxAutoContinue.SelectedIndex; + Configuration.Settings.General.SyncListViewWithVideoWhilePlaying = checkBoxSyncListViewWithVideoWhilePlaying.Checked; + Configuration.Settings.General.ShowWaveform = audioVisualizer.ShowWaveform; + Configuration.Settings.General.ShowSpectrogram = audioVisualizer.ShowSpectrogram; + if (Configuration.Settings.General.ShowRecentFiles) + { + if (!string.IsNullOrEmpty(_fileName)) + { + Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + + } + else + { + Configuration.Settings.RecentFiles.Add(null, null, null); + } + } + + if (SubtitleListview1.StateImageList?.Images.Count > 0) + { + Configuration.Settings.General.ListViewNumberWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Width - 18; + } + else + { + Configuration.Settings.General.ListViewNumberWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Width; + } + + SaveUndockedPositions(); + SaveListViewWidths(); + Configuration.Settings.Save(); + + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.PauseAndDisposePlayer(); + } + } + } + + private void SaveListViewWidths() + { + if (Configuration.Settings.General.ListViewColumnsRememberSize) + { + if (SubtitleListview1.ColumnIndexNumber >= 0) + { + Configuration.Settings.General.ListViewNumberWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Width; + } + + if (SubtitleListview1.ColumnIndexStart >= 0) + { + Configuration.Settings.General.ListViewStartWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexStart].Width; + } + + if (SubtitleListview1.ColumnIndexEnd >= 0) + { + Configuration.Settings.General.ListViewEndWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexEnd].Width; + } + + if (SubtitleListview1.ColumnIndexDuration >= 0) + { + Configuration.Settings.General.ListViewDurationWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexDuration].Width; + } + + if (SubtitleListview1.ColumnIndexCps >= 0) + { + Configuration.Settings.General.ListViewCpsWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexCps].Width; + } + + if (SubtitleListview1.ColumnIndexWpm >= 0) + { + Configuration.Settings.General.ListViewWpmWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexWpm].Width; + } + + if (SubtitleListview1.ColumnIndexText >= 0) + { + Configuration.Settings.General.ListViewTextWidth = SubtitleListview1.Columns[SubtitleListview1.ColumnIndexText].Width; + } + } + } + + private void SaveUndockedPositions() + { + if (_videoPlayerUndocked != null && !_videoPlayerUndocked.IsDisposed) + { + Configuration.Settings.General.UndockedVideoFullscreen = _videoPlayerUndocked.IsFullscreen; + Configuration.Settings.General.UndockedVideoPosition = _videoPlayerUndocked.Left + @";" + _videoPlayerUndocked.Top + @";" + _videoPlayerUndocked.Width + @";" + _videoPlayerUndocked.Height; + } + + if (_waveformUndocked != null && !_waveformUndocked.IsDisposed) + { + Configuration.Settings.General.UndockedWaveformPosition = _waveformUndocked.Left + @";" + _waveformUndocked.Top + @";" + _waveformUndocked.Width + @";" + _waveformUndocked.Height; + } + + if (_videoControlsUndocked != null && !_videoControlsUndocked.IsDisposed) + { + Configuration.Settings.General.UndockedVideoControlsPosition = _videoControlsUndocked.Left + @";" + _videoControlsUndocked.Top + @";" + _videoControlsUndocked.Width + @";" + _videoControlsUndocked.Height; + } + } + + private void ButtonUnBreakClick(object sender, EventArgs e) + { + Unbreak(); + } + + private void BreakUnbreakTextBox(bool unbreak, SETextBox tb) + { + var textCaretPos = tb.SelectionStart; + var startText = tb.Text.Substring(0, textCaretPos); + var numberOfNewLines = Utilities.CountTagInText(startText, Environment.NewLine); + if (unbreak) + { + textCaretPos -= numberOfNewLines; + tb.Text = Utilities.UnbreakLine(tb.Text); + } + else + { + int i = 0; + string s; + bool useLanguage = false; + var language = "en"; + if (Configuration.Settings.Tools.UseNoLineBreakAfter && tb == textBoxListViewText) + { + language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); + useLanguage = true; + } + else if (Configuration.Settings.Tools.UseNoLineBreakAfter && tb == textBoxListViewTextAlternate) + { + language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate); + useLanguage = true; + } + + if (useLanguage) + { + s = Utilities.AutoBreakLine(tb.Text, language); + } + else + { + s = Utilities.AutoBreakLine(tb.Text); + } + + while (i < textCaretPos && i < s.Length) + { + var ch = s[i]; + if (ch == '\n') + { + textCaretPos++; + } + + i++; + } + + textCaretPos -= numberOfNewLines; + tb.Text = s; + } + + tb.SelectionStart = textCaretPos; + } + + private void Unbreak(bool removeNewLineOnly = false) + { + _doAutoBreakOnTextChanged = false; + + var textCaretPos = textBoxListViewText.SelectionStart; + var startText = textBoxListViewText.Text.Substring(0, textCaretPos); + var numberOfNewLines = Utilities.CountTagInText(startText, Environment.NewLine); + textCaretPos -= numberOfNewLines; + bool historyAdded = false; + + if (SubtitleListview1.SelectedItems.Count > 1) + { + SubtitleListview1.BeginUpdate(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.GetParagraphOrDefault(index); + var oldText = p.Text; + var newText = p.Text; + if (removeNewLineOnly) + { + newText = newText.Replace(Environment.NewLine, string.Empty); + } + else + { + newText = Utilities.UnbreakLine(newText); + } + + if (oldText != newText) + { + if (!historyAdded) + { + historyAdded = true; + MakeHistoryForUndo(_language.BeforeRemoveLineBreaksInSelectedLines); + } + + p.Text = newText; + SubtitleListview1.SetText(index, p.Text); + } + + if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + oldText = original.Text; + newText = original.Text; + if (removeNewLineOnly) + { + newText = newText.Replace(Environment.NewLine, string.Empty); + } + else + { + newText = Utilities.UnbreakLine(newText); + } + + if (oldText != newText) + { + if (!historyAdded) + { + historyAdded = true; + MakeHistoryForUndo(_language.BeforeRemoveLineBreaksInSelectedLines); + } + + original.Text = newText; + SubtitleListview1.SetAlternateText(index, original.Text); + } + } + } + } + + SubtitleListview1.EndUpdate(); + RefreshSelectedParagraph(); + } + else + { + var fixedText = removeNewLineOnly ? textBoxListViewText.Text.Replace(Environment.NewLine, string.Empty) : Utilities.UnbreakLine(textBoxListViewText.Text); + var makeHistory = textBoxListViewText.Text != fixedText; + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var alternateFixedText = Utilities.UnbreakLine(textBoxListViewTextAlternate.Text); + if (!makeHistory) + { + makeHistory = textBoxListViewTextAlternate.Text != alternateFixedText; + } + + if (makeHistory) + { + MakeHistoryForUndo(_language.BeforeRemoveLineBreaksInSelectedLines); + textBoxListViewText.Text = fixedText; + } + + textBoxListViewTextAlternate.Text = alternateFixedText; + } + else if (makeHistory) + { + MakeHistoryForUndo(_language.BeforeRemoveLineBreaksInSelectedLines); + textBoxListViewText.Text = fixedText; + } + } + + _doAutoBreakOnTextChanged = true; + textBoxListViewText.SelectionStart = textCaretPos; + } + + private void TabControlSubtitleSelectedIndexChanged(object sender, EventArgs e) + { + var format = GetCurrentSubtitleFormat(); + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + ShowSource(); + ShowSourceLineNumber(); + if (textBoxSource.CanFocus) + { + textBoxSource.Focus(); + } + + // go to correct line in source view + if (SubtitleListview1.SelectedItems.Count > 0) + { + if (format.GetType() == typeof(SubRip)) + { + var p = _subtitle.GetParagraphOrDefault(FirstSelectedIndex); + if (p != null) + { + string tc = p.StartTime + " --> " + p.EndTime; + int start = textBoxSource.Text.IndexOf(p.Number + Environment.NewLine + tc, StringComparison.Ordinal); + if (start < 0) + { + start = 0; + } + + start = textBoxSource.Text.IndexOf(tc, start, StringComparison.Ordinal); + if (start > 0) + { + textBoxSource.SelectionStart = start + tc.Length + Environment.NewLine.Length; + textBoxSource.SelectionLength = 0; + textBoxSource.ScrollToCaret(); + } + } + } + else if (format.GetType() == typeof(SubStationAlpha) || format.GetType() == typeof(AdvancedSubStationAlpha)) + { + var p = _subtitle.GetParagraphOrDefault(FirstSelectedIndex); + if (p != null) + { + const string timeCodeFormat = "{0}:{1:00}:{2:00}.{3:00}"; // h:mm:ss.cc + string startTimeCode = string.Format(timeCodeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10); + string endTimeCode = string.Format(timeCodeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10); + string tc = startTimeCode + "," + endTimeCode; + int start = textBoxSource.Text.IndexOf(tc, StringComparison.Ordinal); + if (start > 0) + { + int start2 = textBoxSource.Text.LastIndexOf("Dialogue:", start, StringComparison.Ordinal); + if (start2 > 0) + { + start2 = (textBoxSource.Text + Environment.NewLine).IndexOf(Environment.NewLine, start2, StringComparison.Ordinal); + } + + if (start2 > 0) + { + start = start2; + } + + textBoxSource.SelectionStart = start; + textBoxSource.SelectionLength = 0; + textBoxSource.ScrollToCaret(); + } + } + } + } + } + else + { + ReloadFromSourceView(); + ShowLineInformationListView(); + if (SubtitleListview1.CanFocus) + { + SubtitleListview1.Focus(); + } + + // go to (select + focus) correct line in list view + if (textBoxSource.SelectionStart > 0 && textBoxSource.TextLength > 30) + { + if (format.GetType() == typeof(SubRip)) + { + var timeCodeRegEx = new Regex(@"^-?\d+:-?\d+:-?\d+[:,]-?\d+\s*-->\s*-?\d+:-?\d+:-?\d+[:,]-?\d+$"); + var lineNumber = textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart); + var lines = textBoxSource.Lines.ToList(); + if (lineNumber >= lines.Count) + { + lineNumber = lines.Count - 1; + } + + var currentLine = lines[lineNumber]; + var nextLine = lineNumber + 1 < lines.Count ? lines[lineNumber + 1] : string.Empty; + var startLine = 0; + if (Utilities.IsInteger(currentLine) && timeCodeRegEx.IsMatch(nextLine)) + { + startLine = lineNumber; + } + else + { + for (int i = lineNumber; i > 0; i--) + { + if (timeCodeRegEx.IsMatch(lines[i]) && Utilities.IsInteger(lines[i - 1])) + { + startLine = i - 1; + break; + } + } + } + + var sb = new StringBuilder(); + for (int i = startLine; i < lines.Count; i++) + { + sb.AppendLine(lines[i]); + } + + var sub = new Subtitle(); + new SubRip().LoadSubtitle(sub, sb.ToString().SplitToLines().ToList(), null); + if (sub.Paragraphs.Count > 0) + { + foreach (var p in _subtitle.Paragraphs) + { + if (sub.Paragraphs[0].Number == p.Number && + sub.Paragraphs[0].StartTime.TotalMilliseconds == p.StartTime.TotalMilliseconds && + sub.Paragraphs[0].EndTime.TotalMilliseconds == p.EndTime.TotalMilliseconds) + { + _subtitleListViewIndex = -1; + var index = _subtitle.Paragraphs.IndexOf(p); + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + break; + } + } + } + } + else if (format.GetType() == typeof(SubStationAlpha) || format.GetType() == typeof(AdvancedSubStationAlpha)) + { + int pos = textBoxSource.SelectionStart; + string s = textBoxSource.Text; + if (pos > 0) + { + pos--; + } + + while (pos > 0 && pos + 3 < s.Length && !s.Substring(pos, 3).StartsWith(Environment.NewLine, StringComparison.Ordinal)) + { + pos--; + } + + s = s.Substring(pos).Trim(); + int lastTimeCode = s.IndexOf("Dialogue:", StringComparison.Ordinal); + + if (lastTimeCode >= 0) + { + string tc = s.Substring(lastTimeCode).Trim(); + while (tc.Length > 0 && !char.IsDigit(tc[0])) + { + tc = tc.Remove(0, 1); + } + + if (tc.Length > 12) + { + TimeCode realTC; + tc = tc.Substring(0, 13); + var timeCode = tc.Split(new[] { ':', '.', ',' }, StringSplitOptions.RemoveEmptyEntries); + try + { + realTC = new TimeCode(int.Parse(timeCode[1]), int.Parse(timeCode[2]), int.Parse(timeCode[3]), int.Parse(timeCode[4]) * 10); + } + catch + { + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + return; + } + + int index = 0; + foreach (var p in _subtitle.Paragraphs) + { + if (Math.Abs(realTC.TotalMilliseconds - p.StartTime.TotalMilliseconds) < 50) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + break; + } + + index++; + } + } + } + } + } + else if (textBoxSource.SelectionStart == 0 && textBoxSource.TextLength > 30) + { + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + } + } + } + + private void ColorToolStripMenuItemClick(object sender, EventArgs e) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) + { + + string color; + var formatType = GetCurrentSubtitleFormat().GetType(); + if (formatType == typeof(Ebu)) + { + using (var form = new EbuColorPicker(true)) + { + if (form.ShowDialog(this) != DialogResult.OK) + { + return; + } + + color = form.Color; + } + } + else if (formatType == typeof(ScenaristClosedCaptions) || formatType == typeof(ScenaristClosedCaptionsDropFrame)) + { + using (var form = new EbuColorPicker(false)) + { + if (form.ShowDialog(this) != DialogResult.OK) + { + return; + } + + color = form.Color; + } + } + else + { + if (colorDialog1.ShowDialog(this) != DialogResult.OK) + { + return; + } + + color = Utilities.ColorToHex(colorDialog1.Color); + } + + MakeHistoryForUndo(_language.BeforeSettingColor); + foreach (ListViewItem item in SubtitleListview1.SelectedItems) + { + var p = _subtitle.GetParagraphOrDefault(item.Index); + if (p != null) + { + SetFontColor(p, color); + SubtitleListview1.SetText(item.Index, p.Text); + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) + { + var original = Utilities.GetOriginalParagraph(item.Index, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + SetFontColor(original, color); + SubtitleListview1.SetAlternateText(item.Index, original.Text); + } + } + } + } + + RefreshSelectedParagraph(); + + } + } + + private static void SetFontColor(Paragraph p, string color) + { + if (p == null) + { + return; + } + + string pre = string.Empty; + if (p.Text.StartsWith("{\\", StringComparison.Ordinal) && p.Text.IndexOf('}') >= 0) + { + int endIndex = p.Text.IndexOf('}') + 1; + pre = p.Text.Substring(0, endIndex); + p.Text = p.Text.Remove(0, endIndex); + } + + string s = p.Text; + if (s.StartsWith("'); + if (end > 0) + { + string f = s.Substring(0, end); + + if (f.Contains(" face=", StringComparison.OrdinalIgnoreCase) && !f.Contains(" color=", StringComparison.OrdinalIgnoreCase)) + { + var start = s.IndexOf(" face=", StringComparison.OrdinalIgnoreCase); + s = s.Insert(start, string.Format(" color=\"{0}\"", color)); + p.Text = pre + s; + return; + } + + var colorStart = f.IndexOf(" color=", StringComparison.OrdinalIgnoreCase); + if (colorStart >= 0) + { + if (s.IndexOf('"', colorStart + 8) > 0) + { + end = s.IndexOf('"', colorStart + 8); + } + + s = s.Substring(0, colorStart) + string.Format(" color=\"{0}", color) + s.Substring(end); + p.Text = pre + s; + return; + } + } + } + + p.Text = $"{pre}{p.Text}"; + } + + private void toolStripMenuItemFont_Click(object sender, EventArgs e) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) + { + using (var form = new ChooseFontName()) + { + + if (form.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeSettingFontName); + + foreach (ListViewItem item in SubtitleListview1.SelectedItems) + { + var p = _subtitle.GetParagraphOrDefault(item.Index); + if (p != null) + { + SetFontName(p, form.FontName); + SubtitleListview1.SetText(item.Index, p.Text); + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) + { + var original = Utilities.GetOriginalParagraph(item.Index, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + SetFontName(original, form.FontName); + SubtitleListview1.SetAlternateText(item.Index, original.Text); + } + } + } + } + + RefreshSelectedParagraph(); + } + } + } + } + + private void SetFontName(Paragraph p, string fontName) + { + if (p == null) + { + return; + } + + string pre = string.Empty; + if (p.Text.StartsWith("{\\", StringComparison.Ordinal) && p.Text.IndexOf('}') >= 0) + { + int endIndex = p.Text.IndexOf('}') + 1; + pre = p.Text.Substring(0, endIndex); + p.Text = p.Text.Remove(0, endIndex); + } + + string s = p.Text; + if (s.StartsWith("'); + if (end > 0) + { + var f = s.Substring(0, end); + + if (f.Contains(" color=", StringComparison.OrdinalIgnoreCase) && !f.Contains(" face=", StringComparison.OrdinalIgnoreCase)) + { + var start = s.IndexOf(" color=", StringComparison.OrdinalIgnoreCase); + p.Text = pre + s.Insert(start, string.Format(" face=\"{0}\"", fontName)); + return; + } + + var faceStart = f.IndexOf(" face=", StringComparison.OrdinalIgnoreCase); + if (f.Contains(" face=", StringComparison.OrdinalIgnoreCase)) + { + if (s.IndexOf('"', faceStart + 7) > 0) + { + end = s.IndexOf('"', faceStart + 7); + } + + p.Text = pre + s.Substring(0, faceStart) + string.Format(" face=\"{0}", fontName) + s.Substring(end); + return; + } + } + } + + p.Text = $"{pre}{s}"; + } + + private void TypeEffectToolStripMenuItemClick(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedItems.Count > 0) + { + using (var typewriter = new EffectTypewriter()) + { + typewriter.Initialize(SubtitleListview1.GetSelectedParagraph(_subtitle)); + + if (typewriter.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeTypeWriterEffect); + bool isframeBased = GetCurrentSubtitleFormat().IsFrameBased; + int lastSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + int i = SubtitleListview1.SelectedItems.Count - 1; + while (i >= 0) + { + var item = SubtitleListview1.SelectedItems[i]; + var p = _subtitle.GetParagraphOrDefault(item.Index); + if (p != null) + { + typewriter.Initialize(p); + typewriter.MakeAnimation(); + int index = item.Index; + _subtitle.Paragraphs.RemoveAt(index); + foreach (var tp in typewriter.TypewriterParagraphs) + { + _subtitle.Paragraphs.Insert(index, tp); + index++; + } + } + + i--; + } + + _subtitle.Renumber(); + _subtitleListViewIndex = -1; + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(lastSelectedIndex, true); + } + } + } + } + + private void KarokeeEffectToolStripMenuItemClick(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedItems.Count > 0) + { + using (var karaoke = new EffectKaraoke()) + { + karaoke.Initialize(SubtitleListview1.GetSelectedParagraph(_subtitle)); + + if (karaoke.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeKaraokeEffect); + int lastSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + bool isframeBased = GetCurrentSubtitleFormat().IsFrameBased; + + int i = SubtitleListview1.SelectedItems.Count - 1; + while (i >= 0) + { + var item = SubtitleListview1.SelectedItems[i]; + var p = _subtitle.GetParagraphOrDefault(item.Index); + if (p != null) + { + int index = item.Index; + _subtitle.Paragraphs.RemoveAt(index); + foreach (var kp in karaoke.MakeAnimation(p)) + { + _subtitle.Paragraphs.Insert(index, kp); + index++; + } + } + + i--; + } + + _subtitle.Renumber(); + _subtitleListViewIndex = -1; + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(lastSelectedIndex, true); + } + } + } + } + + private void MatroskaImportStripMenuItemClick(object sender, EventArgs e) + { + openFileDialog1.Title = _language.OpenMatroskaFile; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = _language.MatroskaFiles + "|*.mkv;*.mks|" + _languageGeneral.AllFiles + "|*.*"; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + openFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName); + ImportSubtitleFromMatroskaFile(openFileDialog1.FileName); + } + } + + private void ImportSubtitleFromMatroskaFile(string fileName) + { + using (var matroska = new MatroskaFile(fileName)) + { + if (matroska.IsValid) + { + var subtitleList = matroska.GetTracks(true); + if (subtitleList.Count == 0) + { + MessageBox.Show(_language.NoSubtitlesFound); + } + else if (ContinueNewOrExit()) + { + if (subtitleList.Count > 1) + { + using (var subtitleChooser = new MatroskaSubtitleChooser("mkv")) + { + subtitleChooser.Initialize(subtitleList); + if (_loading) + { + subtitleChooser.Icon = (Icon)this.Icon.Clone(); + subtitleChooser.ShowInTaskbar = true; + subtitleChooser.ShowIcon = true; + } + + if (subtitleChooser.ShowDialog(this) == DialogResult.OK) + { + if (LoadMatroskaSubtitle(subtitleList[subtitleChooser.SelectedIndex], matroska, false) && + (Path.GetExtension(matroska.Path).Equals(".mkv", StringComparison.OrdinalIgnoreCase) || + Path.GetExtension(matroska.Path).Equals(".mks", StringComparison.OrdinalIgnoreCase))) + { + if (!Configuration.Settings.General.DisableVideoAutoLoading) + { + matroska.Dispose(); + OpenVideo(matroska.Path); + } + } + else + { + _exitWhenLoaded = _loading; + } + } + } + } + else + { + var ext = Path.GetExtension(matroska.Path).ToLowerInvariant(); + if (LoadMatroskaSubtitle(subtitleList[0], matroska, false) && + (ext == ".mkv" || ext == ".mks")) + { + if (!Configuration.Settings.General.DisableVideoAutoLoading) + { + matroska.Dispose(); + if (ext == ".mkv") + { + OpenVideo(matroska.Path); + } + else + { + TryToFindAndOpenVideoFile(Path.Combine(Path.GetDirectoryName(matroska.Path), Path.GetFileNameWithoutExtension(matroska.Path))); + } + } + } + else + { + _exitWhenLoaded = _loading; + } + } + } + } + else + { + MessageBox.Show(string.Format(_language.NotAValidMatroskaFileX, fileName)); + } + } + } + + private int _lastProgressPercent = -1; + + private void UpdateProgress(long position, long total, string statusMessage) + { + var percent = (int)Math.Round(position * 100.0 / total); + if (percent == _lastProgressPercent) + { + return; + } + + ShowStatus(string.Format("{0}, {1:0}%", statusMessage, _lastProgressPercent)); + statusStrip1.Refresh(); + TaskbarList.SetProgressValue(Handle, percent, 100); + if (DateTime.UtcNow.Ticks % 10 == 0) + { + Application.DoEvents(); + } + + _lastProgressPercent = percent; + } + + private void MatroskaProgress(long position, long total) + { + UpdateProgress(position, total, _language.ParsingMatroskaFile); + } + + private Subtitle LoadMatroskaSubtitleForSync(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska) + { + var subtitle = new Subtitle(); + bool isSsa = false; + + if (matroskaSubtitleInfo.CodecId.Equals("S_VOBSUB", StringComparison.OrdinalIgnoreCase)) + { + return subtitle; + } + + if (matroskaSubtitleInfo.CodecId.Equals("S_HDMV/PGS", StringComparison.OrdinalIgnoreCase)) + { + return subtitle; + } + + SubtitleFormat format; + var codecPrivate = matroskaSubtitleInfo.GetCodecPrivate(); + if (codecPrivate.Contains("[script info]", StringComparison.OrdinalIgnoreCase)) + { + if (codecPrivate.Contains("[V4 Styles]", StringComparison.OrdinalIgnoreCase)) + { + format = new SubStationAlpha(); + } + else + { + format = new AdvancedSubStationAlpha(); + } + + isSsa = true; + } + else + { + format = new SubRip(); + } + + var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress); + TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); + if (isSsa) + { + foreach (var p in Utilities.LoadMatroskaSSA(matroskaSubtitleInfo, matroska.Path, format, sub).Paragraphs) + { + subtitle.Paragraphs.Add(p); + } + } + else + { + foreach (var p in sub) + { + subtitle.Paragraphs.Add(new Paragraph(p.GetText(matroskaSubtitleInfo), p.Start, p.End)); + } + } + + return subtitle; + } + + private bool LoadMatroskaSubtitle(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska, bool batchMode) + { + if (matroskaSubtitleInfo.CodecId.Equals("S_VOBSUB", StringComparison.OrdinalIgnoreCase)) + { + if (batchMode) + { + return false; + } + + return LoadVobSubFromMatroska(matroskaSubtitleInfo, matroska); + } + + if (matroskaSubtitleInfo.CodecId.Equals("S_HDMV/PGS", StringComparison.OrdinalIgnoreCase)) + { + if (batchMode) + { + return false; + } + + return LoadBluRaySubFromMatroska(matroskaSubtitleInfo, matroska); + } + + if (matroskaSubtitleInfo.CodecId.Equals("S_HDMV/TEXTST", StringComparison.OrdinalIgnoreCase)) + { + if (batchMode) + { + return false; + } + + return LoadTextSTFromMatroska(matroskaSubtitleInfo, matroska, batchMode); + } + + if (matroskaSubtitleInfo.CodecId.Equals("S_DVBSUB", StringComparison.OrdinalIgnoreCase)) + { + if (batchMode) + { + return false; + } + + return LoadDvbFromMatroska(matroskaSubtitleInfo, matroska, batchMode); + } + + ShowStatus(_language.ParsingMatroskaFile); + Refresh(); + Cursor.Current = Cursors.WaitCursor; + var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress); + TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); + Cursor.Current = Cursors.Default; + + MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); + _subtitleListViewIndex = -1; + if (!batchMode) + { + ResetSubtitle(); + } + + _subtitle.Paragraphs.Clear(); + + var format = Utilities.LoadMatroskaTextSubtitle(matroskaSubtitleInfo, matroska, sub, _subtitle); + + if (matroskaSubtitleInfo.GetCodecPrivate().Contains("[script info]", StringComparison.OrdinalIgnoreCase)) + { + if (_networkSession == null) + { + SubtitleListview1.ShowExtraColumn(_languageGeneral.Style); + } + } + else if (_networkSession == null) + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); + } + + comboBoxSubtitleFormats.SelectedIndexChanged -= ComboBoxSubtitleFormatsSelectedIndexChanged; + SetCurrentFormat(format); + comboBoxSubtitleFormats.SelectedIndexChanged += ComboBoxSubtitleFormatsSelectedIndexChanged; + _oldSubtitleFormat = format; + SetEncoding(Encoding.UTF8); + ShowStatus(_language.SubtitleImportedFromMatroskaFile); + _subtitle.Renumber(); + if (matroska.Path.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase) || matroska.Path.EndsWith(".mks", StringComparison.OrdinalIgnoreCase)) + { + _fileName = matroska.Path.Remove(matroska.Path.Length - 4) + format.Extension; + } + + SetTitle(); + _fileDateTime = new DateTime(); + _converted = true; + + if (batchMode) + { + return true; + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (_subtitle.Paragraphs.Count > 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + } + + ShowSource(); + return true; + } + + private bool LoadTextSTFromMatroska(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska, bool batchMode) + { + ShowStatus(_language.ParsingMatroskaFile); + Refresh(); + Cursor.Current = Cursors.WaitCursor; + var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress); + TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); + Cursor.Current = Cursors.Default; + + MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); + _subtitleListViewIndex = -1; + if (!batchMode) + { + ResetSubtitle(); + } + + _subtitle.Paragraphs.Clear(); + + Utilities.LoadMatroskaTextSubtitle(matroskaSubtitleInfo, matroska, sub, _subtitle); + for (int index = 0; index < sub.Count; index++) + { + try + { + var msub = sub[index]; + int idx = -6; // MakeMKV starts at DialogPresentationSegment + var data = msub.GetData(matroskaSubtitleInfo); + if (VobSubParser.IsPrivateStream2(data, 0)) + { + idx = 0; // starts with MPEG2 private stream 2 (just to be sure) + } + + var dps = new TextST.DialogPresentationSegment(data, idx); + _subtitle.Paragraphs[index].Text = dps.Text; + } + catch (Exception exception) + { + _subtitle.Paragraphs[index].Text = exception.Message; + } + } + + if (_networkSession == null) + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Extra); + } + + comboBoxSubtitleFormats.SelectedIndexChanged -= ComboBoxSubtitleFormatsSelectedIndexChanged; + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + comboBoxSubtitleFormats.SelectedIndexChanged += ComboBoxSubtitleFormatsSelectedIndexChanged; + SetEncoding(Encoding.UTF8); + ShowStatus(_language.SubtitleImportedFromMatroskaFile); + _subtitle.Renumber(); + if (matroska.Path.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase) || matroska.Path.EndsWith(".mks", StringComparison.OrdinalIgnoreCase)) + { + _fileName = matroska.Path.Remove(matroska.Path.Length - 4) + GetCurrentSubtitleFormat().Extension; + } + + SetTitle(); + _fileDateTime = new DateTime(); + _converted = true; + if (batchMode) + { + return true; + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (_subtitle.Paragraphs.Count > 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + } + + ShowSource(); + return true; + } + + private bool LoadDvbFromMatroska(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska, bool batchMode) + { + ShowStatus(_language.ParsingMatroskaFile); + Refresh(); + Cursor.Current = Cursors.WaitCursor; + var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress); + TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); + Cursor.Current = Cursors.Default; + + MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); + _subtitleListViewIndex = -1; + if (!batchMode) + { + ResetSubtitle(); + } + + _subtitle.Paragraphs.Clear(); + var subtitleImages = new List(); + var subtitle = new Subtitle(); + Utilities.LoadMatroskaTextSubtitle(matroskaSubtitleInfo, matroska, sub, _subtitle); + for (int index = 0; index < sub.Count; index++) + { + try + { + var msub = sub[index]; + DvbSubPes pes = null; + var data = msub.GetData(matroskaSubtitleInfo); + if (data != null && data.Length > 9 && data[0] == 15 && data[1] >= SubtitleSegment.PageCompositionSegment && data[1] <= SubtitleSegment.DisplayDefinitionSegment) // sync byte + segment id + { + var buffer = new byte[data.Length + 3]; + Buffer.BlockCopy(data, 0, buffer, 2, data.Length); + buffer[0] = 32; + buffer[1] = 0; + buffer[buffer.Length - 1] = 255; + pes = new DvbSubPes(0, buffer); + } + else if (VobSubParser.IsMpeg2PackHeader(data)) + { + pes = new DvbSubPes(data, Mpeg2Header.Length); + } + else if (VobSubParser.IsPrivateStream1(data, 0)) + { + pes = new DvbSubPes(data, 0); + } + else if (data.Length > 9 && data[0] == 32 && data[1] == 0 && data[2] == 14 && data[3] == 16) + { + pes = new DvbSubPes(0, data); + } + + if (pes == null && subtitle.Paragraphs.Count > 0) + { + var last = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1]; + if (last.Duration.TotalMilliseconds < 100) + { + last.EndTime.TotalMilliseconds = msub.Start; + if (last.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) + { + last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + 3000; + } + } + } + + if (pes != null && pes.PageCompositions != null && pes.PageCompositions.Any(p => p.Regions.Count > 0)) + { + subtitleImages.Add(pes); + subtitle.Paragraphs.Add(new Paragraph(string.Empty, msub.Start, msub.End)); + } + } + catch + { + // continue + } + } + + if (subtitleImages.Count == 0) + { + return false; + } + + for (int index = 0; index < subtitle.Paragraphs.Count; index++) + { + var p = subtitle.Paragraphs[index]; + if (p.Duration.TotalMilliseconds < 200) + { + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 3000; + } + + var next = subtitle.GetParagraphOrDefault(index + 1); + if (next != null && next.StartTime.TotalMilliseconds < p.EndTime.TotalMilliseconds) + { + p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + + using (var formSubOcr = new VobSubOcr()) + { + formSubOcr.Initialize(subtitle, subtitleImages, Configuration.Settings.VobSubOcr); // TODO: language??? + if (_loading) + { + formSubOcr.Icon = (Icon)Icon.Clone(); + formSubOcr.ShowInTaskbar = true; + formSubOcr.ShowIcon = true; + } + + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + ResetSubtitle(); + _subtitle.Paragraphs.Clear(); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = Utilities.GetPathAndFileNameWithoutExtension(matroska.Path) + GetCurrentSubtitleFormat().Extension; + _converted = true; + SetTitle(); + + Configuration.Settings.Save(); + return true; + } + } + + return false; + } + + public static void CopyStream(Stream input, Stream output) + { + var buffer = new byte[128 * 1024]; + int len; + while ((len = input.Read(buffer, 0, buffer.Length)) > 0) + { + output.Write(buffer, 0, len); + } + + output.Flush(); + } + + private bool LoadVobSubFromMatroska(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska) + { + if (matroskaSubtitleInfo.ContentEncodingType == 1) + { + MessageBox.Show(_language.NoSupportEncryptedVobSub); + } + + ShowStatus(_language.ParsingMatroskaFile); + Refresh(); + Cursor.Current = Cursors.WaitCursor; + var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress); + TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); + Cursor.Current = Cursors.Default; + + MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); + _subtitleListViewIndex = -1; + _subtitle.Paragraphs.Clear(); + + List mergedVobSubPacks = new List(); + var idx = new Core.VobSub.Idx(matroskaSubtitleInfo.GetCodecPrivate().SplitToLines()); + foreach (var p in sub) + { + mergedVobSubPacks.Add(new VobSubMergedPack(p.GetData(matroskaSubtitleInfo), TimeSpan.FromMilliseconds(p.Start), 32, null)); + if (mergedVobSubPacks.Count > 0) + { + mergedVobSubPacks[mergedVobSubPacks.Count - 1].EndTime = TimeSpan.FromMilliseconds(p.End); + } + + // fix overlapping (some versions of Handbrake makes overlapping time codes - thx Hawke) + if (mergedVobSubPacks.Count > 1 && mergedVobSubPacks[mergedVobSubPacks.Count - 2].EndTime > mergedVobSubPacks[mergedVobSubPacks.Count - 1].StartTime) + { + mergedVobSubPacks[mergedVobSubPacks.Count - 2].EndTime = TimeSpan.FromMilliseconds(mergedVobSubPacks[mergedVobSubPacks.Count - 1].StartTime.TotalMilliseconds - 1); + } + } + + // Remove bad packs + for (int i = mergedVobSubPacks.Count - 1; i >= 0; i--) + { + if (mergedVobSubPacks[i].SubPicture.SubPictureDateSize <= 2) + { + mergedVobSubPacks.RemoveAt(i); + } + else if (mergedVobSubPacks[i].SubPicture.SubPictureDateSize <= 67 && mergedVobSubPacks[i].SubPicture.Delay.TotalMilliseconds < 35) + { + mergedVobSubPacks.RemoveAt(i); + } + } + + using (var formSubOcr = new VobSubOcr()) + { + formSubOcr.Initialize(mergedVobSubPacks, idx.Palette, Configuration.Settings.VobSubOcr, null); // TODO: language??? + if (_loading) + { + formSubOcr.Icon = (Icon)Icon.Clone(); + formSubOcr.ShowInTaskbar = true; + formSubOcr.ShowIcon = true; + } + + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + ResetSubtitle(); + _subtitle.Paragraphs.Clear(); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = Utilities.GetPathAndFileNameWithoutExtension(matroska.Path) + GetCurrentSubtitleFormat().Extension; + _converted = true; + SetTitle(); + + Configuration.Settings.Save(); + return true; + } + } + + return false; + } + + private bool LoadBluRaySubFromMatroska(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska) + { + if (matroskaSubtitleInfo.ContentEncodingType == 1) + { + MessageBox.Show(_language.NoSupportEncryptedVobSub); + } + + ShowStatus(_language.ParsingMatroskaFile); + Refresh(); + Cursor.Current = Cursors.WaitCursor; + var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress); + TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); + Cursor.Current = Cursors.Default; + + int noOfErrors = 0; + string lastError = string.Empty; + MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); + _subtitleListViewIndex = -1; + _subtitle.Paragraphs.Clear(); + var subtitles = new List(); + var log = new StringBuilder(); + var clusterStream = new MemoryStream(); + var lastPalettes = new Dictionary>(); + var lastBitmapObjects = new Dictionary>(); + foreach (var p in sub) + { + byte[] buffer = p.GetData(matroskaSubtitleInfo); + if (buffer != null && buffer.Length > 2) + { + clusterStream.Write(buffer, 0, buffer.Length); + if (ContainsBluRayStartSegment(buffer)) + { + if (subtitles.Count > 0 && subtitles[subtitles.Count - 1].StartTime == subtitles[subtitles.Count - 1].EndTime) + { + subtitles[subtitles.Count - 1].EndTime = (long)((p.Start - 1) * 90.0); + } + + clusterStream.Position = 0; + var list = BluRaySupParser.ParseBluRaySup(clusterStream, log, true, lastPalettes, lastBitmapObjects); + foreach (var sup in list) + { + sup.StartTime = (long)((p.Start - 1) * 90.0); + sup.EndTime = (long)((p.End - 1) * 90.0); + subtitles.Add(sup); + + // fix overlapping + if (subtitles.Count > 1 && sub[subtitles.Count - 2].End > sub[subtitles.Count - 1].Start) + { + subtitles[subtitles.Count - 2].EndTime = subtitles[subtitles.Count - 1].StartTime - 1; + } + } + + clusterStream = new MemoryStream(); + } + } + else if (subtitles.Count > 0) + { + var lastSub = subtitles[subtitles.Count - 1]; + if (lastSub.StartTime == lastSub.EndTime) + { + lastSub.EndTime = (long)((p.Start - 1) * 90.0); + if (lastSub.EndTime - lastSub.StartTime > 1000000) + { + lastSub.EndTime = lastSub.StartTime; + } + } + } + } + + if (noOfErrors > 0) + { + MessageBox.Show(string.Format("{0} error(s) occurred during extraction of bdsup\r\n\r\n{1}", noOfErrors, lastError)); + } + + using (var formSubOcr = new VobSubOcr()) + { + formSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, matroska.Path); + if (_loading) + { + formSubOcr.Icon = (Icon)Icon.Clone(); + formSubOcr.ShowInTaskbar = true; + formSubOcr.ShowIcon = true; + } + + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportingDvdSubtitle); + + _subtitle.Paragraphs.Clear(); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = string.Empty; + SetTitle(); + + Configuration.Settings.Save(); + return true; + } + } + + return false; + } + + private bool ContainsBluRayStartSegment(byte[] buffer) + { + const int epochStart = 0x80; + var position = 0; + while (position + 3 <= buffer.Length) + { + var segmentType = buffer[position]; + if (segmentType == epochStart) + { + return true; + } + + int length = BluRaySupParser.BigEndianInt16(buffer, position + 1) + 3; + position += length; + } + + return false; + } + + private void ImportSubtitleFromDvbSupFile(string fileName) + { + using (var formSubOcr = new VobSubOcr()) + { + string language = null; + var programMapTableParser = new ProgramMapTableParser(); + programMapTableParser.Parse(fileName); // get languages + if (programMapTableParser.GetSubtitlePacketIds().Count > 0) + { + language = programMapTableParser.GetSubtitleLanguageTwoLetter(programMapTableParser.GetSubtitlePacketIds().First()); + } + + var subtitles = TransportStreamParser.GetDvbSup(fileName); + formSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, fileName, language); + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportingDvdSubtitle); + + _subtitle.Paragraphs.Clear(); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = string.Empty; + SetTitle(); + + Configuration.Settings.Save(); + } + } + } + + private bool ImportSubtitleFromTransportStream(string fileName) + { + ShowStatus(_language.ParsingTransportStream); + Refresh(); + var tsParser = new TransportStreamParser(); + tsParser.Parse(fileName, (pos, total) => UpdateProgress(pos, total, _language.ParsingTransportStreamFile)); + ShowStatus(string.Empty); + TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress); + + if (tsParser.SubtitlePacketIds.Count == 0 && tsParser.TeletextSubtitlesLookup.Count == 0) + { + MessageBox.Show(_language.NoSubtitlesFound); + _exitWhenLoaded = _loading; + return false; + } + + if (tsParser.SubtitlePacketIds.Count == 0 && tsParser.TeletextSubtitlesLookup.Count == 1 && tsParser.TeletextSubtitlesLookup.First().Value.Count() == 1) + { + _subtitle = new Subtitle(tsParser.TeletextSubtitlesLookup.First().Value.First().Value); + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle); + SubtitleListview1.SelectIndexAndEnsureVisible(0); + if (!Configuration.Settings.General.DisableVideoAutoLoading) + { + OpenVideo(fileName); + } + + _fileName = Path.GetFileNameWithoutExtension(fileName) + GetCurrentSubtitleFormat().Extension; + _converted = true; + SetTitle(); + return true; + } + + int packetId; + if (tsParser.SubtitlePacketIds.Count + tsParser.TeletextSubtitlesLookup.Sum(p => p.Value.Count()) > 1) + { + using (var subChooser = new TransportStreamSubtitleChooser()) + { + subChooser.Initialize(tsParser, fileName); + if (subChooser.ShowDialog(this) == DialogResult.Cancel) + { + return false; + } + + if (subChooser.IsTeletext) + { + new SubRip().LoadSubtitle(_subtitle, subChooser.Srt.SplitToLines(), null); + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle); + SubtitleListview1.SelectIndexAndEnsureVisible(0); + if (!Configuration.Settings.General.DisableVideoAutoLoading) + { + OpenVideo(fileName); + } + + _fileName = Path.GetFileNameWithoutExtension(fileName) + GetCurrentSubtitleFormat().Extension; + _converted = true; + SetTitle(); + return true; + } + + packetId = tsParser.SubtitlePacketIds[subChooser.SelectedIndex]; + } + } + else + { + packetId = tsParser.SubtitlePacketIds[0]; + } + + + var subtitles = tsParser.GetDvbSubtitles(packetId); + using (var formSubOcr = new VobSubOcr()) + { + string language = null; + var programMapTableParser = new ProgramMapTableParser(); + programMapTableParser.Parse(fileName); // get languages + if (programMapTableParser.GetSubtitlePacketIds().Count > 0) + { + language = programMapTableParser.GetSubtitleLanguage(packetId); + } + + formSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, fileName, language); + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportingDvdSubtitle); + + _subtitle.Paragraphs.Clear(); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = string.Empty; + if (!string.IsNullOrEmpty(formSubOcr.FileName)) + { + var currentFormat = GetCurrentSubtitleFormat(); + _fileName = Utilities.GetPathAndFileNameWithoutExtension(formSubOcr.FileName) + currentFormat.Extension; + if (!Configuration.Settings.General.DisableVideoAutoLoading) + { + OpenVideo(fileName); + } + _converted = true; + } + SetTitle(); + Configuration.Settings.Save(); + return true; + } + } + + _exitWhenLoaded = _loading; + return false; + } + + private bool ImportSubtitleFromMp4(string fileName) + { + var mp4Parser = new MP4Parser(fileName); + var mp4SubtitleTracks = mp4Parser.GetSubtitleTracks(); + if (mp4SubtitleTracks.Count == 0) + { + MessageBox.Show(_language.NoSubtitlesFound); + return false; + } + else if (mp4SubtitleTracks.Count == 1) + { + LoadMp4Subtitle(fileName, mp4SubtitleTracks[0]); + return true; + } + else + { + using (var subtitleChooser = new MatroskaSubtitleChooser("mp4")) + { + subtitleChooser.Initialize(mp4SubtitleTracks); + if (subtitleChooser.ShowDialog(this) == DialogResult.OK) + { + LoadMp4Subtitle(fileName, mp4SubtitleTracks[subtitleChooser.SelectedIndex]); + return true; + } + } + + return false; + } + } + + private bool ImportSubtitleFromDivX(string fileName) + { + var count = 0; + var list = new List(); + using (var f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + var searchBuffer = new byte[2048]; + long pos = 0; + long length = f.Length - 50; + while (pos < length) + { + f.Position = pos; + int readCount = f.Read(searchBuffer, 0, searchBuffer.Length); + for (int i = 0; i < readCount; i++) + { + if (searchBuffer[i] != 0x5b || (i + 4 < readCount && (searchBuffer[i + 1] < 0x30 || searchBuffer[i + 1] > 0x39 || searchBuffer[i + 3] != 0x3a))) + { + continue; + } + + f.Position = pos + i + 1; + + var buffer = new byte[26]; + f.Read(buffer, 0, buffer.Length); + + if (buffer[2] == 0x3a && // : + buffer[5] == 0x3a && // : + buffer[8] == 0x2e && // . + buffer[12] == 0x2d && // - + buffer[15] == 0x3a && // : + buffer[18] == 0x3a && // : + buffer[21] == 0x2e && // . + buffer[25] == 0x5d) // ] + { // subtitle time code + string timeCode = Encoding.ASCII.GetString(buffer, 0, 25); + + f.Read(buffer, 0, 2); + int width = BitConverter.ToUInt16(buffer, 0); + f.Read(buffer, 0, 2); + int height = BitConverter.ToUInt16(buffer, 0); + f.Read(buffer, 0, 2); + int x = BitConverter.ToUInt16(buffer, 0); + f.Read(buffer, 0, 2); + int y = BitConverter.ToUInt16(buffer, 0); + f.Read(buffer, 0, 2); + int xEnd = BitConverter.ToUInt16(buffer, 0); + f.Read(buffer, 0, 2); + int yEnd = BitConverter.ToUInt16(buffer, 0); + f.Read(buffer, 0, 2); + int RleLength = BitConverter.ToUInt16(buffer, 0); + + var colorBuffer = new byte[4 * 3]; // four colors with rgb (3 bytes) + f.Read(colorBuffer, 0, colorBuffer.Length); + + buffer = new byte[RleLength]; + int bytesRead = f.Read(buffer, 0, buffer.Length); + + if (width > 0 && height > 0 && bytesRead == buffer.Length) + { + var xSub = new XSub(timeCode, width, height, colorBuffer, buffer); + list.Add(xSub); + count++; + } + } + } + + pos += searchBuffer.Length; + } + } + + if (count == 0) + { + return false; + } + + using (var formSubOcr = new VobSubOcr()) + { + formSubOcr.Initialize(list, Configuration.Settings.VobSubOcr, fileName); // TODO: language??? + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); + _subtitleListViewIndex = -1; + FileNew(); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = Utilities.GetPathAndFileNameWithoutExtension(fileName) + GetCurrentSubtitleFormat().Extension; + _converted = true; + SetTitle(); + + Configuration.Settings.Save(); + if (!Configuration.Settings.General.DisableVideoAutoLoading) + { + OpenVideo(fileName); + } + } + } + + return true; + } + + private static Subtitle LoadMp4SubtitleForSync(Trak mp4SubtitleTrack) + { + var subtitle = new Subtitle(); + if (mp4SubtitleTrack.Mdia.IsVobSubSubtitle) + { + return subtitle; + } + else + { + subtitle.Paragraphs.AddRange(mp4SubtitleTrack.Mdia.Minf.Stbl.GetParagraphs()); + } + + return subtitle; + } + + private void LoadMp4Subtitle(string fileName, Trak mp4SubtitleTrack) + { + if (mp4SubtitleTrack.Mdia.IsVobSubSubtitle) + { + var subPicturesWithTimeCodes = new List(); + var paragraphs = mp4SubtitleTrack.Mdia.Minf.Stbl.GetParagraphs(); + for (int i = 0; i < paragraphs.Count; i++) + { + if (mp4SubtitleTrack.Mdia.Minf.Stbl.SubPictures.Count > i) + { + var start = paragraphs[i].StartTime.TimeSpan; + var end = paragraphs[i].EndTime.TimeSpan; + subPicturesWithTimeCodes.Add(new VobSubOcr.SubPicturesWithSeparateTimeCodes(mp4SubtitleTrack.Mdia.Minf.Stbl.SubPictures[i], start, end)); + } + } + + using (var formSubOcr = new VobSubOcr()) + { + formSubOcr.Initialize(subPicturesWithTimeCodes, Configuration.Settings.VobSubOcr, fileName); // TODO: language??? + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); + _subtitleListViewIndex = -1; + FileNew(); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = Utilities.GetPathAndFileNameWithoutExtension(fileName) + GetCurrentSubtitleFormat().Extension; + _converted = true; + SetTitle(); + + Configuration.Settings.Save(); + } + } + } + else + { + MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile); + _subtitleListViewIndex = -1; + FileNew(); + + _subtitle.Paragraphs.AddRange(mp4SubtitleTrack.Mdia.Minf.Stbl.GetParagraphs()); + + SetEncoding(Encoding.UTF8); + ShowStatus(_language.SubtitleImportedFromMatroskaFile); + _subtitle.Renumber(); + if (fileName.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) || fileName.EndsWith(".m4v", StringComparison.OrdinalIgnoreCase)) + { + _fileName = fileName.Substring(0, fileName.Length - 4) + GetCurrentSubtitleFormat().Extension; + } + + SetTitle(); + _fileDateTime = new DateTime(); + _converted = true; + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (_subtitle.Paragraphs.Count > 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + } + + ShowSource(); + } + } + + private void SubtitleListview1_DragEnter(object sender, DragEventArgs e) + { + // make sure they're actually dropping files (not text or anything else) + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.All; + } + } + + private void SubtitleListview1_DragDrop(object sender, DragEventArgs e) + { + _dragAndDropFiles = (string[])e.Data.GetData(DataFormats.FileDrop); + if (_dragAndDropFiles.Length == 1) + { + _dragAndDropTimer.Start(); + } + else + { + MessageBox.Show(_language.DropOnlyOneFile); + } + } + + private void DoSubtitleListview1Drop(object sender, EventArgs e) + { + _dragAndDropTimer.Stop(); + + if (ContinueNewOrExit()) + { + string fileName = _dragAndDropFiles[0]; + var file = new FileInfo(fileName); + + // Do not allow directory drop + if (FileUtil.IsDirectory(fileName)) + { + MessageBox.Show(_language.ErrorDirectoryDropNotAllowed, file.Name, MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + var dirName = Path.GetDirectoryName(fileName); + saveFileDialog1.InitialDirectory = dirName; + openFileDialog1.InitialDirectory = dirName; + var ext = file.Extension.ToLowerInvariant(); + + if (ext == ".mkv" || ext == ".mks") + { + using (var matroska = new MatroskaFile(fileName)) + { + if (matroska.IsValid) + { + var subtitleList = matroska.GetTracks(true); + if (subtitleList.Count == 0) + { + MessageBox.Show(_language.NoSubtitlesFound); + } + else if (subtitleList.Count > 1) + { + using (var subtitleChooser = new MatroskaSubtitleChooser("mkv")) + { + subtitleChooser.Initialize(subtitleList); + if (subtitleChooser.ShowDialog(this) == DialogResult.OK) + { + ResetSubtitle(); + if (LoadMatroskaSubtitle(subtitleList[subtitleChooser.SelectedIndex], matroska, false) && + (ext.Equals(".mkv", StringComparison.Ordinal) || ext.Equals(".mks", StringComparison.Ordinal)) && + !Configuration.Settings.General.DisableVideoAutoLoading) + { + OpenVideo(fileName); + } + } + } + } + else + { + ResetSubtitle(); + if (LoadMatroskaSubtitle(subtitleList[0], matroska, false) && + (ext.Equals(".mkv", StringComparison.Ordinal) || ext.Equals(".mks", StringComparison.Ordinal)) && + !Configuration.Settings.General.DisableVideoAutoLoading) + { + OpenVideo(fileName); + } + } + + return; + } + } + } + else if (ext == ".mp4" || ext == ".m4v" || ext == ".3gp") + { + var mp4Parser = new MP4Parser(fileName); + var mp4SubtitleTracks = mp4Parser.GetSubtitleTracks(); + if (mp4SubtitleTracks.Count > 0) + { + ImportSubtitleFromMp4(fileName); + return; + } + + MessageBox.Show(_language.NoSubtitlesFound); + return; + } + else if (ext == ".vob" || ext == ".ifo") + { + ImportDvdSubtitle(fileName); + return; + } + else if (ext == ".idx") + { + var subFileName = fileName.Substring(0, fileName.Length - 3) + "sub"; + if (File.Exists(subFileName) && FileUtil.IsVobSub(subFileName)) + { + ImportAndOcrVobSubSubtitleNew(subFileName, _loading); + return; + } + } + + comboBoxEncoding.BeginUpdate(); + comboBoxSubtitleFormats.BeginUpdate(); + + if (file.Length < Subtitle.MaxFileSize) + { + if (!OpenFromRecentFiles(fileName)) + { + OpenSubtitle(fileName, null); + } + } + else if (file.Length < 150000000 && ext == ".sub" && IsVobSubFile(fileName, true)) // max 150 mb + { + OpenSubtitle(fileName, null); + } + else if (file.Length < 250000000 && ext == ".sup" && FileUtil.IsBluRaySup(fileName)) // max 250 mb + { + OpenSubtitle(fileName, null); + } + else if ((ext == ".ts" || ext == ".rec" || ext == ".mpg" || ext == ".mpeg") && FileUtil.IsTransportStream(fileName)) + { + OpenSubtitle(fileName, null); + } + else if ((ext == ".m2ts" || ext == ".ts" || ext == ".mts") && FileUtil.IsM2TransportStream(fileName)) + { + OpenSubtitle(fileName, null); + } + else + { + MessageBox.Show(string.Format(_language.DropFileXNotAccepted, fileName)); + } + + comboBoxSubtitleFormats.EndUpdate(); + comboBoxEncoding.EndUpdate(); + } + } + + private void TextBoxSourceDragEnter(object sender, DragEventArgs e) + { + // make sure they're actually dropping files (not text or anything else) + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.All; + } + } + + private void TextBoxSourceDragDrop(object sender, DragEventArgs e) + { + var files = (string[])e.Data.GetData(DataFormats.FileDrop); + if (files.Length == 1) + { + if (ContinueNewOrExit()) + { + OpenSubtitle(files[0], null); + } + } + else + { + MessageBox.Show(_language.DropOnlyOneFile); + } + } + + private void ToolStripMenuItemManualAnsiClick(object sender, EventArgs e) + { + ReloadFromSourceView(); + openFileDialog1.Title = _language.OpenAnsiSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + using (var chooseEncoding = new ChooseEncoding()) + { + chooseEncoding.Initialize(openFileDialog1.FileName); + if (chooseEncoding.ShowDialog(this) == DialogResult.OK) + { + Encoding encoding = chooseEncoding.GetEncoding(); + SetEncoding(Encoding.UTF8); + OpenSubtitle(openFileDialog1.FileName, encoding); + } + } + } + } + + private void ChangeCasingToolStripMenuItem_Click(object sender, EventArgs e) + { + ChangeCasing(false); + } + + private void ChangeCasing(bool onlySelectedLines) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + SaveSubtitleListviewIndices(); + using (var changeCasing = new ChangeCasing()) + { + if (onlySelectedLines) + { + changeCasing.Text += " - " + _language.SelectedLines; + } + + ReloadFromSourceView(); + if (changeCasing.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeChangeCasing); + + Cursor.Current = Cursors.WaitCursor; + var selectedLines = new Subtitle(); + var selectedIndices = new List(SubtitleListview1.GetSelectedIndices()); + if (onlySelectedLines) + { + foreach (int index in selectedIndices) + { + selectedLines.Paragraphs.Add(new Paragraph(_subtitle.Paragraphs[index])); + } + } + else + { + foreach (var p in _subtitle.Paragraphs) + { + selectedLines.Paragraphs.Add(new Paragraph(p)); + } + } + + bool saveChangeCaseChanges = true; + var casingNamesLinesChanged = 0; + + if (changeCasing.ChangeNamesToo && changeCasing.OnlyAllUpper) + { + selectedIndices = new List(); + var allUpperSubtitle = new Subtitle(); + var sub = onlySelectedLines ? selectedLines : _subtitle; + for (var index = 0; index < sub.Paragraphs.Count; index++) + { + var p = sub.Paragraphs[index]; + var noTags = HtmlUtil.RemoveHtmlTags(p.Text, true); + if (noTags == noTags.ToUpperInvariant()) + { + allUpperSubtitle.Paragraphs.Add(p); + selectedIndices.Add(index); + } + } + + selectedLines = allUpperSubtitle; + onlySelectedLines = true; + } + + changeCasing.FixCasing(selectedLines, LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle)); + if (changeCasing.ChangeNamesToo) + { + using (var changeCasingNames = new ChangeCasingNames()) + { + changeCasingNames.Initialize(selectedLines); + if (changeCasingNames.ShowDialog(this) == DialogResult.OK) + { + changeCasingNames.FixCasing(); + casingNamesLinesChanged = changeCasingNames.LinesChanged; + + if (changeCasing.LinesChanged == 0) + { + ShowStatus(string.Format(_language.CasingCompleteMessageOnlyNames, casingNamesLinesChanged, _subtitle.Paragraphs.Count)); + } + else + { + ShowStatus(string.Format(_language.CasingCompleteMessage, changeCasing.LinesChanged, _subtitle.Paragraphs.Count, casingNamesLinesChanged)); + } + } + else + { + saveChangeCaseChanges = false; + } + } + } + else + { + ShowStatus(string.Format(_language.CasingCompleteMessageNoNames, changeCasing.LinesChanged, _subtitle.Paragraphs.Count)); + } + + if (saveChangeCaseChanges) + { + if (onlySelectedLines) + { + int i = 0; + foreach (int index in selectedIndices) + { + _subtitle.Paragraphs[index].Text = selectedLines.Paragraphs[i].Text; + i++; + } + } + else + { + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + _subtitle.Paragraphs[i].Text = selectedLines.Paragraphs[i].Text; + } + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (changeCasing.LinesChanged > 0 || casingNamesLinesChanged > 0) + { + _subtitleListViewIndex = -1; + RestoreSubtitleListviewIndices(); + UpdateSourceView(); + } + } + + Cursor.Current = Cursors.Default; + } + } + } + + private void ToolStripMenuItemChangeFrameRateClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + int lastSelectedIndex = 0; + if (SubtitleListview1.SelectedItems.Count > 0) + { + lastSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + } + + ReloadFromSourceView(); + using (var changeFrameRate = new ChangeFrameRate()) + { + changeFrameRate.Initialize(CurrentFrameRate.ToString()); + if (changeFrameRate.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeChangeFrameRate); + + double oldFrameRate = changeFrameRate.OldFrameRate; + double newFrameRate = changeFrameRate.NewFrameRate; + _subtitle.ChangeFrameRate(oldFrameRate, newFrameRate); + + ShowStatus(string.Format(_language.FrameRateChangedFromXToY, oldFrameRate, newFrameRate)); + toolStripComboBoxFrameRate.Text = newFrameRate.ToString(); + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(lastSelectedIndex, true); + } + } + } + + private bool IsVobSubFile(string subFileName, bool verbose) + { + try + { + if (FileUtil.IsVobSub(subFileName)) + { + if (!verbose) + { + return true; + } + + var idxFileName = Utilities.GetPathAndFileNameWithoutExtension(subFileName) + ".idx"; + if (File.Exists(idxFileName)) + { + return true; + } + + var dr = MessageBox.Show(string.Format(_language.IdxFileNotFoundWarning, idxFileName), _title, MessageBoxButtons.YesNoCancel); + return dr == DialogResult.Yes; + } + + if (verbose) + { + MessageBox.Show(string.Format(_language.InvalidVobSubHeader, subFileName)); + } + } + catch (Exception ex) + { + if (verbose) + { + MessageBox.Show(ex.Message); + } + } + + return false; + } + + private void ImportAndOcrSpDvdSup(string fileName, bool showInTaskbar) + { + var spList = new List(); + + using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + var buffer = new byte[SpHeader.SpHeaderLength]; + int bytesRead = fs.Read(buffer, 0, buffer.Length); + var header = new SpHeader(buffer); + + while (header.Identifier == "SP" && bytesRead > 0 && header.NextBlockPosition > 4) + { + buffer = new byte[header.NextBlockPosition]; + bytesRead = fs.Read(buffer, 0, buffer.Length); + if (bytesRead == buffer.Length) + { + header.AddPicture(buffer); + spList.Add(header); + } + + buffer = new byte[SpHeader.SpHeaderLength]; + bytesRead = fs.Read(buffer, 0, buffer.Length); + while (bytesRead == buffer.Length && Encoding.ASCII.GetString(buffer, 0, 2) != "SP") + { + fs.Seek(fs.Position - buffer.Length + 1, SeekOrigin.Begin); + bytesRead = fs.Read(buffer, 0, buffer.Length); + } + header = new SpHeader(buffer); + } + } + + using (var vobSubOcr = new VobSubOcr()) + { + if (showInTaskbar) + { + vobSubOcr.Icon = (Icon)this.Icon.Clone(); + vobSubOcr.ShowInTaskbar = true; + vobSubOcr.ShowIcon = true; + } + + vobSubOcr.Initialize(fileName, null, Configuration.Settings.VobSubOcr, spList); + if (vobSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportingVobSubFile); + FileNew(); + _subtitle.Paragraphs.Clear(); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + foreach (var p in vobSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = Path.ChangeExtension(vobSubOcr.FileName, GetCurrentSubtitleFormat().Extension); + SetTitle(); + _converted = true; + + Configuration.Settings.Save(); + } + else + { + _exitWhenLoaded = _loading; + } + } + } + + private void ImportAndOcrVobSubSubtitleNew(string fileName, bool showInTaskbar) + { + if (!IsVobSubFile(fileName, true)) + { + return; + } + + using (var vobSubOcr = new VobSubOcr()) + { + if (showInTaskbar) + { + vobSubOcr.Icon = (Icon)Icon.Clone(); + vobSubOcr.ShowInTaskbar = true; + vobSubOcr.ShowIcon = true; + } + + if (vobSubOcr.Initialize(fileName, Configuration.Settings.VobSubOcr, this) && vobSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportingVobSubFile); + FileNew(); + _subtitle.Paragraphs.Clear(); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + foreach (var p in vobSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = Path.ChangeExtension(vobSubOcr.FileName, GetCurrentSubtitleFormat().Extension); + SetTitle(); + _converted = true; + + Configuration.Settings.Save(); + } + else + { + _exitWhenLoaded = _loading; + } + } + } + + private void ToolStripMenuItemMergeLinesClick(object sender, EventArgs e) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count >= 1) + { + // check consecutive numbers + var last = SubtitleListview1.SelectedIndices[0] - 1; + foreach (int index in SubtitleListview1.SelectedIndices) + { + if (last != index - 1) + { + return; + } + + last = index; + } + + MergeAfterToolStripMenuItemClick(null, null); + } + } + + private void VisualSyncSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) + { + ShowVisualSync(true); + } + + private void SaveSubtitleListviewIndices() + { + _selectedIndices = new List(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + _selectedIndices.Add(index); + } + } + + private void RestoreSubtitleListviewIndices() + { + _subtitleListViewIndex = -1; + if (_selectedIndices != null) + { + SubtitleListview1.SelectNone(); + int i = 0; + foreach (int index in _selectedIndices) + { + if (index >= 0 && index < SubtitleListview1.Items.Count) + { + SubtitleListview1.Items[index].Selected = true; + if (i == 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + } + } + + i++; + } + } + } + + private void ShowSelectedLinesEarlierlaterToolStripMenuItemClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + if (_showEarlierOrLater != null && !_showEarlierOrLater.IsDisposed) + { + _showEarlierOrLater.WindowState = FormWindowState.Normal; + _showEarlierOrLater.Focus(); + return; + } + + bool waveformEnabled = timerWaveform.Enabled; + timerWaveform.Stop(); + timer1.Stop(); + + _showEarlierOrLater = new ShowEarlierLater(); + if (!_showEarlierOrLater.IsPositionAndSizeSaved) + { + _showEarlierOrLater.Top = Top + 100; + _showEarlierOrLater.Left = Left + (Width / 2) - (_showEarlierOrLater.Width / 3); + } + + _showEarlierOrLater.Initialize(ShowEarlierOrLater, true); + MakeHistoryForUndo(_language.BeforeShowSelectedLinesEarlierLater); + _showEarlierOrLater.Show(this); + + timerWaveform.Enabled = waveformEnabled; + timer1.Start(); + + RefreshSelectedParagraph(); + } + + public static Control FindFocusedControl(Control control) + { + var container = control as ContainerControl; + while (container != null) + { + control = container.ActiveControl; + container = control as ContainerControl; + } + + return control; + } + + internal void MainKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.LWin) + { + _winLeftDownTicks = DateTime.UtcNow.Ticks; + } + + if (e.KeyCode == Keys.RWin) + { + _winRightDownTicks = DateTime.UtcNow.Ticks; + } + + if ((DateTime.UtcNow.Ticks - _winLeftDownTicks) <= 10000 * 999 || (DateTime.UtcNow.Ticks - _winRightDownTicks) <= 10000 * 999) // less than 999 ms + { + // if it's less than one second since Win key was pressed we ignore key (not perfect...) + e.SuppressKeyPress = true; + return; + } + + if (e.Modifiers == Keys.Alt && e.KeyCode == (Keys.RButton | Keys.ShiftKey) && (textBoxListViewText.Focused || textBoxListViewTextAlternate.Focused)) + { // annoying that focus leaves textbox while typing, when pressing Alt alone + e.SuppressKeyPress = true; + return; + } + + if (e.Modifiers == Keys.Alt && e.KeyCode == (Keys.RButton | Keys.ShiftKey)) + { + return; + } + + if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.ShiftKey) + { + return; + } + + if (e.Modifiers == Keys.Control && e.KeyCode == (Keys.LButton | Keys.ShiftKey)) + { + return; + } + + if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.ShiftKey) + { + return; + } + + var fc = FindFocusedControl(this); + if (fc != null && e.Modifiers != Keys.Control && e.Modifiers != Keys.Alt && e.Modifiers != (Keys.Control | Keys.Shift) && e.Modifiers != (Keys.Control | Keys.Alt) && e.Modifiers != (Keys.Control | Keys.Shift | Keys.Alt)) + { + // do not check for shortcuts if text is being entered and a textbox is focused + if ((fc.Parent.Name == textBoxListViewText.Name || fc.Parent.Name == textBoxListViewTextAlternate.Name || fc.Name == textBoxSearchWord.Name) && + ((e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z) || (e.KeyCode >= Keys.OemSemicolon && e.KeyCode <= Keys.OemBackslash))) + { + return; + } + + // do not check for shortcuts if a number is being entered and a time box is focused + if (fc.Parent != null && (fc.Parent.Name == timeUpDownStartTime.Name || fc.Parent.Name == numericUpDownDuration.Name) && + (e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9 || e.KeyValue >= 48 && e.KeyValue <= 57)) + { + return; + } + } + + bool inListView = tabControlSubtitle.SelectedIndex == TabControlListView; + + + if (e.KeyCode == Keys.Escape && !_cancelWordSpellCheck) + { + _cancelWordSpellCheck = true; + } + else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformVerticalZoom) + { + audioVisualizer.VerticalZoomFactor *= 1.1; + e.SuppressKeyPress = true; + } + else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformVerticalZoomOut) + { + audioVisualizer.VerticalZoomFactor /= 1.1; + e.SuppressKeyPress = true; + } + else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformZoomIn) + { + audioVisualizer.ZoomIn(); + e.SuppressKeyPress = true; + } + else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformZoomOut) + { + audioVisualizer.ZoomOut(); + e.SuppressKeyPress = true; + } + else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformSplit) + { + if (mediaPlayer.IsPaused) + { + var pos = mediaPlayer.VideoPlayer.CurrentPosition; + var paragraph = _subtitle.GetFirstParagraphOrDefaultByTime(pos * TimeCode.BaseUnit); + if (paragraph != null && + pos * TimeCode.BaseUnit + 100 > paragraph.StartTime.TotalMilliseconds && + pos * TimeCode.BaseUnit - 100 < paragraph.EndTime.TotalMilliseconds) + { + SubtitleListview1.SelectIndexAndEnsureVisible(paragraph); + SplitSelectedParagraph(pos, null); + } + } + + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.VideoPlayFirstSelected && !string.IsNullOrEmpty(VideoFileName)) + { + PlayFirstSelectedSubtitle(); + } + else if (audioVisualizer.Visible && (e.KeyData == _shortcuts.WaveformPlaySelection || e.KeyData == _shortcuts.WaveformPlaySelectionEnd)) + { + WaveformPlaySelection(nearEnd: e.KeyData == _shortcuts.WaveformPlaySelectionEnd); + e.SuppressKeyPress = true; + } + else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformSearchSilenceForward) + { + if (audioVisualizer.WavePeaks != null) + { + audioVisualizer.FindDataBelowThreshold(Configuration.Settings.VideoControls.WaveformSeeksSilenceMaxVolume, Configuration.Settings.VideoControls.WaveformSeeksSilenceDurationSeconds); + } + e.SuppressKeyPress = true; + } + else if (audioVisualizer.Visible && e.KeyData == _shortcuts.WaveformSearchSilenceBack) + { + if (audioVisualizer.WavePeaks != null) + { + audioVisualizer.FindDataBelowThresholdBack(Configuration.Settings.VideoControls.WaveformSeeksSilenceMaxVolume, Configuration.Settings.VideoControls.WaveformSeeksSilenceDurationSeconds); + } + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainInsertAfter == e.KeyData && inListView) + { + InsertAfter(string.Empty); + e.SuppressKeyPress = true; + textBoxListViewText.Focus(); + } + else if (_shortcuts.MainInsertBefore == e.KeyData && inListView) + { + InsertBefore(); + e.SuppressKeyPress = true; + textBoxListViewText.Focus(); + } + else if (_shortcuts.MainMergeDialog == e.KeyData && inListView) + { + MergeDialogs(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainListViewToggleDashes == e.KeyData && inListView) + { + if (textBoxListViewText.Focused) + { + ToggleDashesTextBox(textBoxListViewText); + } + else if (textBoxListViewTextAlternate.Focused) + { + ToggleDashesTextBox(textBoxListViewTextAlternate); + } + else + { + ToggleDashes(); + } + e.SuppressKeyPress = true; + } + else if (!toolStripMenuItemRtlUnicodeControlChars.Visible && _shortcuts.MainEditFixRTLViaUnicodeChars == e.KeyData && inListView) + { + toolStripMenuItemRtlUnicodeControlChar_Click(null, null); + e.SuppressKeyPress = true; + } + else if (!toolStripMenuItemRemoveUnicodeControlChars.Visible && _shortcuts.MainEditRemoveRTLUnicodeChars == e.KeyData && inListView) + { + toolStripMenuItemRemoveUnicodeControlChar_Click(null, null); + e.SuppressKeyPress = true; + } + else if (!toolStripMenuItemReverseRightToLeftStartEnd.Visible && _shortcuts.MainEditReverseStartAndEndingForRtl == e.KeyData && inListView) + { + ReverseStartAndEndingForRtl(); + e.SuppressKeyPress = true; + } + else if (toolStripMenuItemUndo.ShortcutKeys == e.KeyData) // undo + { + toolStripMenuItemUndo_Click(sender, e); + e.SuppressKeyPress = true; + } + else if (toolStripMenuItemRedo.ShortcutKeys == e.KeyData) // redo + { + toolStripMenuItemRedo_Click(sender, e); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt) + { + if (AutoRepeatContinueOn || AutoRepeatOn) + { + PlayNext(); + } + else + { + ButtonNextClick(null, null); + } + } + else if (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt) + { + if (AutoRepeatContinueOn || AutoRepeatOn) + { + PlayPrevious(); + } + else + { + ButtonPreviousClick(null, null); + } + + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralGoToNextSubtitle == e.KeyData) + { + MoveNextPrevious(0); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralGoToNextSubtitleCursorAtEnd == e.KeyData) + { + MoveNextPrevious(0); + textBoxListViewText.SelectionStart = textBoxListViewText.Text.Length; + textBoxListViewText.SelectionLength = 0; + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralGoToPrevSubtitle == e.KeyData) + { + if (AutoRepeatContinueOn || AutoRepeatOn) + { + PlayPrevious(); + } + else + { + ButtonPreviousClick(null, null); + } + + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralGoToStartOfCurrentSubtitle == e.KeyData) + { + if (SubtitleListview1.SelectedItems.Count == 1 && mediaPlayer.VideoPlayer != null) + { + mediaPlayer.CurrentPosition = _subtitle.Paragraphs[SubtitleListview1.SelectedItems[0].Index].StartTime.TotalSeconds; + e.SuppressKeyPress = true; + } + + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralGoToEndOfCurrentSubtitle == e.KeyData) + { + if (SubtitleListview1.SelectedItems.Count == 1 && mediaPlayer.VideoPlayer != null) + { + mediaPlayer.CurrentPosition = _subtitle.Paragraphs[SubtitleListview1.SelectedItems[0].Index].EndTime.TotalSeconds; + e.SuppressKeyPress = true; + } + + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGoToPreviousSubtitleAndFocusVideo == e.KeyData) + { + int newIndex = _subtitleListViewIndex - 1; + if (newIndex >= 0) + { + _subtitleListViewIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisibleFaster(newIndex); + _subtitleListViewIndex = newIndex; + textBoxListViewText.Focus(); + textBoxListViewText.SelectAll(); + GotoSubtitleIndex(newIndex); + ShowSubtitle(); + e.SuppressKeyPress = true; + } + } + else if (_shortcuts.MainGoToNextSubtitleAndFocusVideo == e.KeyData) + { + int newIndex = _subtitleListViewIndex + 1; + if (newIndex < _subtitle.Paragraphs.Count) + { + _subtitleListViewIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisibleFaster(newIndex); + _subtitleListViewIndex = newIndex; + textBoxListViewText.Focus(); + textBoxListViewText.SelectAll(); + GotoSubtitleIndex(newIndex); + ShowSubtitle(); + e.SuppressKeyPress = true; + } + } + else if (_shortcuts.MainGoToNextSubtitleAndPlay == e.KeyData && mediaPlayer != null) + { + int newIndex = _subtitleListViewIndex + 1; + if (newIndex < _subtitle.Paragraphs.Count) + { + _subtitleListViewIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisibleFaster(newIndex); + _subtitleListViewIndex = newIndex; + textBoxListViewText.Focus(); + textBoxListViewText.SelectAll(); + GotoSubtitleIndex(newIndex); + var p = _subtitle.GetParagraphOrDefault(newIndex); + if (p != null) + { + mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; + ShowSubtitle(); + mediaPlayer.Play(); + _endSeconds = p.EndTime.TotalSeconds; + } + + e.SuppressKeyPress = true; + } + } + else if (_shortcuts.MainGoToPrevSubtitleAndPlay == e.KeyData && mediaPlayer != null) + { + int newIndex = _subtitleListViewIndex - 1; + if (newIndex > 0) + { + _subtitleListViewIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisibleFaster(newIndex); + _subtitleListViewIndex = newIndex; + textBoxListViewText.Focus(); + textBoxListViewText.SelectAll(); + GotoSubtitleIndex(newIndex); + var p = _subtitle.GetParagraphOrDefault(newIndex); + if (p != null) + { + mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; + ShowSubtitle(); + mediaPlayer.Play(); + _endSeconds = p.EndTime.TotalSeconds; + } + + e.SuppressKeyPress = true; + } + } + else if (_shortcuts.MainUnbreakNoSpace == e.KeyData) + { + Unbreak(true); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralToggleBookmarks == e.KeyData) + { + ToggleBookmarks(false); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralClearBookmarks == e.KeyData) + { + ClearBookmarks(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralGoToBookmark == e.KeyData) + { + e.SuppressKeyPress = true; + GoToBookmark(); + } + else if (_shortcuts.MainGeneralGoToPreviousBookmark == e.KeyData) + { + GoToPrevoiusBookmark(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralGoToNextBookmark == e.KeyData) + { + GoToNextBookmark(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralChooseProfile == e.KeyData) + { + ChooseProfile(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralDuplicateLine == e.KeyData && SubtitleListview1.SelectedItems.Count == 1) + { + DuplicateLine(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralFileSaveAll == e.KeyData) + { + SaveAll(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainToggleFocus == e.KeyData && inListView) + { + if (SubtitleListview1.Focused) + { + textBoxListViewText.Focus(); + } + else + { + SubtitleListview1.Focus(); + } + + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.Home && e.Modifiers == Keys.Alt) + { + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.End && e.Modifiers == Keys.Alt) + { + SubtitleListview1.SelectIndexAndEnsureVisible(SubtitleListview1.Items.Count - 1, true); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralGoToFirstSelectedLine == e.KeyData) //Locate first selected line in subtitle listview + { + if (SubtitleListview1.SelectedItems.Count > 0) + { + SubtitleListview1.SelectedItems[0].EnsureVisible(); + } + + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralGoToFirstEmptyLine == e.KeyData) //Go to first empty line - if any + { + GoToFirstEmptyLine(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralMergeSelectedLines == e.KeyData) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count >= 1) + { + e.SuppressKeyPress = true; + if (SubtitleListview1.SelectedItems.Count == 2) + { + MergeAfterToolStripMenuItemClick(null, null); + } + else + { + MergeSelectedLines(); + } + } + } + else if (_shortcuts.MainGeneralMergeSelectedLinesAndAutoBreak == e.KeyData) + { + e.SuppressKeyPress = true; + if (SubtitleListview1.SelectedItems.Count == 2) + { + MergeWithLineAfter(false, BreakMode.AutoBreak); + } + else + { + MergeSelectedLines(BreakMode.AutoBreak); + } + } + else if (_shortcuts.MainGeneralMergeSelectedLinesAndUnbreak == e.KeyData) + { + e.SuppressKeyPress = true; + if (SubtitleListview1.SelectedItems.Count == 2) + { + MergeWithLineAfter(false, BreakMode.Unbreak); + } + else + { + MergeSelectedLines(BreakMode.Unbreak); + } + } + else if (_shortcuts.MainGeneralMergeSelectedLinesAndUnbreakNoSpace == e.KeyData) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count >= 1) + { + e.SuppressKeyPress = true; + if (SubtitleListview1.SelectedItems.Count == 2) + { + MergeWithLineAfter(false, BreakMode.UnbreakNoSpace); + } + else + { + MergeSelectedLines(BreakMode.UnbreakNoSpace); + } + } + } + else if (_shortcuts.MainGeneralMergeSelectedLinesBilingual == e.KeyData) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count >= 1 && SubtitleListview1.SelectedItems.Count < 10) + { + e.SuppressKeyPress = true; + MergeSelectedLinesBilingual(); + } + } + else if (_shortcuts.MainGeneralMergeSelectedLinesOnlyFirstText == e.KeyData) + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count >= 1) + { + e.SuppressKeyPress = true; + MergeSelectedLinesOnlyFirstText(); + } + } + else if (_shortcuts.MainGeneralMergeWithNext == e.KeyData) + { + if (SubtitleListview1.SelectedItems.Count >= 1) + { + var idx = SubtitleListview1.SelectedItems[0].Index; + if (idx >= 0 && _subtitle.Paragraphs.Count > idx + 1) + { + SubtitleListview1.SelectIndexAndEnsureVisible(idx, true); + MergeAfterToolStripMenuItemClick(null, null); + e.SuppressKeyPress = true; + } + } + } + else if (_shortcuts.MainGeneralMergeWithPrevious == e.KeyData) + { + if (SubtitleListview1.SelectedItems.Count >= 1) + { + var idx = SubtitleListview1.SelectedItems[0].Index; + if (idx > 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(idx - 1, true); + MergeAfterToolStripMenuItemClick(null, null); + e.SuppressKeyPress = true; + } + } + } + else if (_shortcuts.MainGeneralToggleTranslationMode == e.KeyData) + { // toggle translator mode + EditToolStripMenuItemDropDownOpening(null, null); + toolStripMenuItemTranslationMode_Click(null, null); + } + else if (e.KeyData == _shortcuts.VideoPlayPauseToggle) + { + if (mediaPlayer.VideoPlayer != null) + { + if (_shortcuts.VideoPlayPauseToggle == Keys.Space && + (textBoxListViewText.Focused || textBoxListViewTextAlternate.Focused || textBoxSearchWord.Focused)) + { + return; + } + + _endSeconds = -1; + e.SuppressKeyPress = true; + System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(1), () => mediaPlayer.TogglePlayPause()); + } + } + else if (e.KeyData == _shortcuts.VideoPause) + { + if (mediaPlayer.VideoPlayer != null) + { + _endSeconds = -1; + mediaPlayer.Pause(); + e.SuppressKeyPress = true; + } + } + else if (_shortcuts.MainVideoPlayFromJustBefore == e.KeyData) + { + buttonBeforeText_Click(null, null); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.Right) + { + if (!textBoxListViewText.Focused && !textBoxListViewTextAlternate.Focused) + { + mediaPlayer.CurrentPosition += 1.0; + e.SuppressKeyPress = true; + } + } + else if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.Left) + { + if (!textBoxListViewText.Focused && !textBoxListViewTextAlternate.Focused) + { + mediaPlayer.CurrentPosition -= 1.0; + e.SuppressKeyPress = true; + } + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Space) + { + if (!textBoxListViewText.Focused && !textBoxListViewTextAlternate.Focused && !textBoxSource.Focused && mediaPlayer.VideoPlayer != null) + { + if (audioVisualizer.Focused || mediaPlayer.Focused || SubtitleListview1.Focused) + { + _endSeconds = -1; + mediaPlayer.TogglePlayPause(); + e.SuppressKeyPress = true; + } + } + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.D1) + { + if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle != null && mediaPlayer.VideoPlayer != null) + { + var p = _subtitle.GetParagraphOrDefault(SubtitleListview1.SelectedItems[0].Index); + if (p != null) + { + mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; + } + } + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.D2) + { + if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle != null && mediaPlayer.VideoPlayer != null) + { + var p = _subtitle.GetParagraphOrDefault(SubtitleListview1.SelectedItems[0].Index); + if (p != null) + { + mediaPlayer.CurrentPosition = p.EndTime.TotalSeconds; + } + } + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.D3) + { + if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle != null && mediaPlayer.VideoPlayer != null) + { + int index = SubtitleListview1.SelectedItems[0].Index - 1; + var p = _subtitle.GetParagraphOrDefault(index); + if (p != null) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; + } + } + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.D4) + { + if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle != null && mediaPlayer.VideoPlayer != null) + { + int index = SubtitleListview1.SelectedItems[0].Index + 1; + var p = _subtitle.GetParagraphOrDefault(index); + if (p != null) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; + } + } + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainVideoToggleStartEndCurrent == e.KeyData) + { + if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle != null && mediaPlayer.VideoPlayer != null) + { + mediaPlayer.Pause(); + var p = _subtitle.GetParagraphOrDefault(SubtitleListview1.SelectedItems[0].Index); + if (p != null) + { + if (Math.Abs(mediaPlayer.CurrentPosition - p.StartTime.TotalSeconds) < 0.1) + { + mediaPlayer.CurrentPosition = p.EndTime.TotalSeconds; + } + else + { + mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; + } + } + } + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainVideoPlayCurrent == e.KeyData) + { + if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle != null && mediaPlayer.VideoPlayer != null) + { + var p = _subtitle.GetParagraphOrDefault(SubtitleListview1.SelectedItems[0].Index); + if (p != null) + { + mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; + ShowSubtitle(); + mediaPlayer.Play(); + _endSeconds = p.EndTime.TotalSeconds; + } + } + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainVideoGoToStartCurrent == e.KeyData) + { + if (mediaPlayer.VideoPlayer != null) + { + GotoSubPositionAndPause(); + } + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainVideo3000MsLeft == e.KeyData) + { + if (mediaPlayer.VideoPlayer != null) + { + GoBackSeconds(3); + } + e.SuppressKeyPress = true; + } + else if (e.Modifiers == (Keys.Control | Keys.Alt | Keys.Shift) && e.KeyCode == Keys.W) // watermark + { + var enc = GetCurrentEncoding(); + if (enc != Encoding.UTF8 && enc != Encoding.UTF32 && enc != Encoding.Unicode && enc != Encoding.UTF7) + { + MessageBox.Show(Configuration.Settings.Language.Watermark.ErrorUnicodeEncodingOnly); + } + else + { + using (var watermarkForm = new Watermark()) + { + MakeHistoryForUndo(Configuration.Settings.Language.Watermark.BeforeWatermark); + watermarkForm.Initialize(_subtitle, FirstSelectedIndex); + if (watermarkForm.ShowDialog(this) == DialogResult.OK) + { + watermarkForm.AddOrRemove(_subtitle); + RefreshSelectedParagraph(); + } + } + } + + e.SuppressKeyPress = true; + } + else if (e.Modifiers == (Keys.Control | Keys.Alt | Keys.Shift) && e.KeyCode == Keys.F) // Toggle HHMMSSFF / HHMMSSMMM + { + Configuration.Settings.General.UseTimeFormatHHMMSSFF = !Configuration.Settings.General.UseTimeFormatHHMMSSFF; + RefreshTimeCodeMode(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralSwitchTranslationAndOriginal == e.KeyData) // switch original/current + { + if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0 && _networkSession == null) + { + int firstIndex = FirstSelectedIndex; + double firstMs = -1; + if (firstIndex >= 0) + { + firstMs = _subtitle.Paragraphs[firstIndex].StartTime.TotalMilliseconds; + } + + var temp = _subtitle; + _subtitle = _subtitleAlternate; + _subtitleAlternate = temp; + + var tempName = _fileName; + _fileName = _subtitleAlternateFileName; + _subtitleAlternateFileName = tempName; + + var tempChangeSubText = _changeSubtitleHash; + _changeSubtitleHash = _changeAlternateSubtitleHash; + _changeAlternateSubtitleHash = tempChangeSubText; + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + + _subtitleListViewIndex = -1; + if (firstIndex >= 0 && _subtitle.Paragraphs.Count > firstIndex && Math.Abs(_subtitle.Paragraphs[firstIndex].StartTime.TotalMilliseconds - firstMs) < 0.01) + { + SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex, true); + } + else + { + RefreshSelectedParagraph(); + } + + SetTitle(); + + _fileDateTime = new DateTime(); + } + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainGeneralMergeTranslationAndOriginal == e.KeyData) // Merge translation and original + { + if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0 && _networkSession == null) + { + if (ContinueNewOrExit()) + { + var subtitle = new Subtitle(); + var fr = CurrentFrameRate; + var format = GetCurrentSubtitleFormat(); + var videoFileName = VideoFileName; + foreach (var p in _subtitle.Paragraphs) + { + var newP = new Paragraph(p); + var original = Utilities.GetOriginalParagraph(_subtitle.GetIndex(p), p, _subtitleAlternate.Paragraphs); + if (original != null) + { + newP.Text = (newP.Text.TrimEnd() + Environment.NewLine + original.Text.TrimStart()).Trim(); + } + + subtitle.Paragraphs.Add(newP); + } + + RemoveAlternate(true, true); + FileNew(); + SetCurrentFormat(format); + toolStripComboBoxFrameRate.Text = fr.ToString(); + _subtitle = subtitle; + _subtitleListViewIndex = -1; + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + if (!string.IsNullOrEmpty(videoFileName)) + { + OpenVideo(videoFileName); + } + e.SuppressKeyPress = true; + } + } + } + else if (e.KeyData == _shortcuts.ToggleVideoDockUndock) + { + if (_isVideoControlsUndocked) + { + RedockVideoControlsToolStripMenuItemClick(null, null); + } + else + { + UndockVideoControlsToolStripMenuItemClick(null, null); + } + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.MainVideoFoucsSetVideoPosition) + { + timeUpDownVideoPositionAdjust.Focus(); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video1FrameLeft) + { + if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv) + { + libMpv.GetPreviousFrame(); + } + else + { + MoveVideoSeconds(-1.0 / Configuration.Settings.General.CurrentFrameRate); + } + + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video1FrameRight) + { + if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv) + { + libMpv.GetNextFrame(); + } + else + { + MoveVideoSeconds(1.0 / Configuration.Settings.General.CurrentFrameRate); + } + + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.Video1FrameLeftWithPlay) + { + if (mediaPlayer.VideoPlayer != null) + { + double startSeconds = mediaPlayer.CurrentPosition - (1.0 / Configuration.Settings.General.CurrentFrameRate); + _endSeconds = startSeconds + (1.0 / Configuration.Settings.General.CurrentFrameRate); + _endSecondsNewPosition = startSeconds; + mediaPlayer.CurrentPosition = startSeconds; + UiUtil.ShowSubtitle(_subtitle, mediaPlayer); + mediaPlayer.Play(); + _endSecondsNewPositionTicks = DateTime.UtcNow.Ticks; + } + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.Video1FrameRightWithPlay) + { + if (mediaPlayer.VideoPlayer != null) + { + double startSeconds = mediaPlayer.CurrentPosition + (1.0 / Configuration.Settings.General.CurrentFrameRate); + _endSeconds = startSeconds + (1.0 / Configuration.Settings.General.CurrentFrameRate); + _endSecondsNewPosition = startSeconds; + mediaPlayer.CurrentPosition = startSeconds; + UiUtil.ShowSubtitle(_subtitle, mediaPlayer); + mediaPlayer.Play(); + _endSecondsNewPositionTicks = DateTime.UtcNow.Ticks; + } + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video100MsLeft) + { + MoveVideoSeconds(-0.1); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video100MsRight) + { + MoveVideoSeconds(0.1); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video500MsLeft) + { + MoveVideoSeconds(-0.5); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video500MsRight) + { + MoveVideoSeconds(0.5); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video1000MsLeft) + { + MoveVideoSeconds(-1.0); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video1000MsRight) + { + MoveVideoSeconds(1.0); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video5000MsLeft) + { + MoveVideoSeconds(-5.0); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.Video5000MsRight) + { + MoveVideoSeconds(5.0); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.VideoXSMsLeft) + { + ButtonAdjustSecBackClick(null, null); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.VideoXSMsRight) + { + ButtonAdjustSecForwardClick(null, null); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.VideoXLMsLeft) + { + buttonAdjustSecBack2_Click(null, null); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && e.KeyData == _shortcuts.VideoXLMsRight) + { + buttonAdjustSecForward2_Click(null, null); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainToolsBeamer == e.KeyData) + { + using (var beamer = new Beamer(this, _subtitle, _subtitleListViewIndex)) + { + beamer.ShowDialog(this); + } + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainVideoFullscreen) // fullscreen + { + GoFullscreen(false); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainVideoSlower) + { + e.SuppressKeyPress = true; + for (var index = 0; index < toolStripSplitButtonPlayRate.DropDownItems.Count; index++) + { + var item = (ToolStripMenuItem)toolStripSplitButtonPlayRate.DropDownItems[index]; + if (item.Checked && index > 0) + { + SetPlayRate(toolStripSplitButtonPlayRate.DropDownItems[index - 1], null); + return; + } + } + } + else if (e.KeyData == _shortcuts.MainVideoFaster) + { + e.SuppressKeyPress = true; + for (var index = 0; index < toolStripSplitButtonPlayRate.DropDownItems.Count; index++) + { + var item = (ToolStripMenuItem)toolStripSplitButtonPlayRate.DropDownItems[index]; + if (item.Checked && index + 1 < toolStripSplitButtonPlayRate.DropDownItems.Count) + { + SetPlayRate(toolStripSplitButtonPlayRate.DropDownItems[index + 1], null); + return; + } + } + } + else if (e.KeyData == _shortcuts.MainVideoReset) + { + e.SuppressKeyPress = true; + if (audioVisualizer != null) + { + audioVisualizer.ZoomFactor = 1.0; + audioVisualizer.VerticalZoomFactor = 1.0; + InitializeWaveformZoomDropdown(); + } + + if (mediaPlayer != null && mediaPlayer.VideoPlayer != null) + { + mediaPlayer.VideoPlayer.PlayRate = 1.0; + InitializePlayRateDropDown(); + toolStripSplitButtonPlayRate.Image = imageListPlayRate.Images[0]; + } + } + else if (audioVisualizer.Focused && audioVisualizer.NewSelectionParagraph != null && e.KeyData == _shortcuts.WaveformAddTextAtHere) + { + addParagraphHereToolStripMenuItem_Click(null, null); + e.SuppressKeyPress = true; + } + else if (audioVisualizer.Focused && audioVisualizer.NewSelectionParagraph != null && e.KeyData == _shortcuts.WaveformAddTextAtHereFromClipboard) + { + addParagraphAndPasteToolStripMenuItem_Click(null, null); + e.SuppressKeyPress = true; + } + else if (audioVisualizer.Focused && audioVisualizer.NewSelectionParagraph != null && e.KeyData == _shortcuts.WaveformSetParagraphAsNewSelection) + { + toolStripMenuItemSetParagraphAsSelection_Click(null, null); + e.SuppressKeyPress = true; + } + else if (audioVisualizer.Focused && e.KeyData == _shortcuts.WaveformFocusListView) + { + SubtitleListview1.Focus(); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.VideoGoToPrevSubtitle) + { + GoToPreviousSubtitle(mediaPlayer.CurrentPosition * TimeCode.BaseUnit); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.VideoGoToNextSubtitle) + { + GoToNextSubtitle(mediaPlayer.CurrentPosition * TimeCode.BaseUnit); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.VideoSelectNextSubtitle) + { + var cp = mediaPlayer.CurrentPosition * TimeCode.BaseUnit; + foreach (var p in _subtitle.Paragraphs) + { + if (p.StartTime.TotalMilliseconds > cp) + { + SubtitleListview1.SelectNone(); + SubtitleListview1.Items[_subtitle.Paragraphs.IndexOf(p)].Selected = true; + SubtitleListview1.Items[_subtitle.Paragraphs.IndexOf(p)].Focused = true; + break; + } + } + + e.SuppressKeyPress = true; + } + else if (mediaPlayer.Chapters?.Count > 0 && e.KeyData == _shortcuts.VideoGoToPrevChapter) + { + var cp = mediaPlayer.CurrentPosition - 0.01; + foreach (var chapter in mediaPlayer.Chapters.Reverse()) + { + if (chapter.StartTime < cp) + { + mediaPlayer.CurrentPosition = chapter.StartTime; + break; + } + } + + e.SuppressKeyPress = true; + } + else if (mediaPlayer.Chapters?.Count > 0 && e.KeyData == _shortcuts.VideoGoToNextChapter) + { + var cp = mediaPlayer.CurrentPosition + 0.01; + foreach (var chapter in mediaPlayer.Chapters) + { + if (chapter.StartTime > cp) + { + mediaPlayer.CurrentPosition = chapter.StartTime; + break; + } + } + + e.SuppressKeyPress = true; + } + else if (audioVisualizer.SceneChanges != null && e.KeyData == _shortcuts.WaveformGoToPreviousSceneChange) + { + var cp = mediaPlayer.CurrentPosition - 0.01; + foreach (var sceneChange in audioVisualizer.SceneChanges.Reverse()) + { + if (sceneChange < cp) + { + mediaPlayer.CurrentPosition = sceneChange; + break; + } + } + + e.SuppressKeyPress = true; + } + else if (audioVisualizer.SceneChanges != null && e.KeyData == _shortcuts.WaveformGoToNextSceneChange) + { + var cp = mediaPlayer.CurrentPosition + 0.01; + foreach (var sceneChange in audioVisualizer.SceneChanges) + { + if (sceneChange > cp) + { + mediaPlayer.CurrentPosition = sceneChange; + break; + } + } + + e.SuppressKeyPress = true; + } + else if (audioVisualizer.SceneChanges != null && mediaPlayer.IsPaused && e.KeyData == _shortcuts.WaveformToggleSceneChange) + { + var cp = mediaPlayer.CurrentPosition; + var idx = audioVisualizer.GetSceneChangeIndex(cp); + if (idx >= 0) + { + RemoveSceneChange(idx); + if (audioVisualizer.SceneChanges.Count == 0) + { + SceneChangeHelper.DeleteSceneChanges(VideoFileName); + } + } + else + { // add scene change + var list = audioVisualizer.SceneChanges.Where(p => p > 0).ToList(); + list.Add(cp); + list.Sort(); + audioVisualizer.SceneChanges = list; + SceneChangeHelper.SaveSceneChanges(VideoFileName, list); + } + + e.SuppressKeyPress = true; + } + else if (audioVisualizer.SceneChanges != null && mediaPlayer.IsPaused && e.KeyData == _shortcuts.WaveformGuessStart) + { + AutoGuessStartTime(_subtitleListViewIndex); + e.SuppressKeyPress = true; + } + else if (audioVisualizer.Focused && e.KeyCode == Keys.Delete) + { + ToolStripMenuItemDeleteClick(null, null); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainToolsAutoDuration == e.KeyData) + { + MakeAutoDuration(); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == (Keys.Control | Keys.Alt | Keys.Shift) && e.KeyCode == Keys.I) + { + using (var form = new ImportUnknownFormat(string.Empty)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + if (form.ImportedSubitle?.Paragraphs.Count > 0) + { + _subtitle = form.ImportedSubitle; + _fileName = null; + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SetTitle(); + } + } + } + + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainTextBoxMoveLastWordDown) + { + if (textBoxListViewTextAlternate.Focused) + { + MoveLastWordDown(textBoxListViewTextAlternate); + } + else + { + MoveLastWordDown(textBoxListViewText); + } + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainTextBoxMoveFirstWordFromNextUp) + { + if (textBoxListViewTextAlternate.Focused) + { + MoveFirstWordInNextUp(textBoxListViewTextAlternate); + } + else + { + MoveFirstWordInNextUp(textBoxListViewText); + } + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainTextBoxMoveLastWordDownCurrent) + { + if (textBoxListViewTextAlternate.Focused) + { + MoveWordUpDownInCurrent(true, textBoxListViewTextAlternate); + } + else + { + MoveWordUpDownInCurrent(true, textBoxListViewText); + } + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainTextBoxMoveFirstWordUpCurrent) + { + if (textBoxListViewTextAlternate.Focused) + { + MoveWordUpDownInCurrent(false, textBoxListViewTextAlternate); + } + else + { + MoveWordUpDownInCurrent(false, textBoxListViewText); + } + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAutoCalcCurrentDuration == e.KeyData) + { + e.SuppressKeyPress = true; + if (SubtitleListview1.SelectedItems.Count >= 1) + { + MakeHistoryForUndo(_language.BeforeDisplayTimeAdjustment); + _makeHistoryPaused = true; + var idx = SubtitleListview1.SelectedItems[0].Index; + _subtitle.RecalculateDisplayTime(Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds, idx, Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds); + SetDurationInSeconds(_subtitle.Paragraphs[idx].Duration.TotalSeconds); + _makeHistoryPaused = false; + } + } + else if (e.KeyCode == Keys.F3 && e.Modifiers == Keys.Shift) + { + FindPrevious(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustExtendCurrentSubtitle == e.KeyData) + { + ExtendCurrentSubtitle(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustExtendToNextSubtitle == e.KeyData) + { + ExtendSelectedLinesToNextLine(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustExtendToPreviousSubtitle == e.KeyData) + { + ExtendSelectedLinesToPreviousLine(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustExtendPreviousLineEndToCurrentStart == e.KeyData) + { + ExtendPreviousEndToCurrentStart(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustExtendNextLineStartToCurrentEnd == e.KeyData) + { + ExtendNextStartToCurrentEnd(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustSnapStartToNextSceneChange == e.KeyData) + { + SnapSelectedLinesStartToNextSceneChange(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustSnapStartToNextSceneChangeWithGap == e.KeyData) + { + SnapSelectedLinesStartToNextSceneChange(true); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustSnapEndToPreviousSceneChange == e.KeyData) + { + SnapSelectedLinesEndToPreviousSceneChange(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustSnapEndToPreviousSceneChangeWithGap == e.KeyData) + { + SnapSelectedLinesEndToPreviousSceneChange(true); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustExtendToNextSceneChange == e.KeyData) + { + ExtendSelectedLinesToNextSceneChange(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustExtendToNextSceneChangeWithGap == e.KeyData) + { + ExtendSelectedLinesToNextSceneChange(true); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustExtendToPreviousSceneChange == e.KeyData) + { + ExtendSelectedLinesToPreviousSceneChange(); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustExtendToPreviousSceneChangeWithGap == e.KeyData) + { + ExtendSelectedLinesToPreviousSceneChange(true); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewGoToNextError) + { + GoToNextSyntaxError(); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainWaveformAdd) + { + if (audioVisualizer.WavePeaks == null) + { + AudioWaveform_Click(null, null); + } + e.SuppressKeyPress = true; + } + + + //TABS: Create / adjust / translate + + // create + else if (_shortcuts.MainCreateInsertSubAtVideoPos == e.KeyData) + { + ButtonInsertNewTextClick(null, null); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainCreateInsertSubAtVideoPosNoTextBoxFocus == e.KeyData) + { + var p = InsertNewTextAtVideoPosition(); + p.Text = string.Empty; + SubtitleListview1.SetText(_subtitle.GetIndex(p), p.Text); + textBoxListViewText.Text = p.Text; + e.SuppressKeyPress = true; + } + else if (tabControlButtons.SelectedTab == tabPageCreate && e.Modifiers == Keys.Alt && e.KeyCode == Keys.F9) + { + StopAutoDuration(); + ButtonSetEndClick(null, null); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainCreateSetStart == e.KeyData) + { + buttonSetStartTime_Click(null, null); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainCreateSetEnd == e.KeyData) + { + StopAutoDuration(); + ButtonSetEndClick(null, null); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustSetEndAndPause == e.KeyData) + { + StopAutoDuration(); + mediaPlayer.Pause(); + ButtonSetEndClick(null, null); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainCreateSetEndAddNewAndGoToNew == e.KeyData) + { + StopAutoDuration(); + e.SuppressKeyPress = true; + + if (SubtitleListview1.SelectedItems.Count == 1) + { + double videoPosition = mediaPlayer.CurrentPosition; + if (!mediaPlayer.IsPaused) + { + videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; + } + + int index = SubtitleListview1.SelectedItems[0].Index; + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + _subtitle.Paragraphs[index].Number + " " + _subtitle.Paragraphs[index].Text)); + + var p = _subtitle.Paragraphs[index]; + p.EndTime = TimeCode.FromSeconds(videoPosition); + if (p.Duration.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds) + { + var newEndTime = new TimeCode(p.EndTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines); + double charactersPerSecond = Utilities.GetCharactersPerSecond(new Paragraph(p) { EndTime = newEndTime }); + if (charactersPerSecond <= Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds) + { + p.EndTime = newEndTime; + } + } + + SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds); + ButtonInsertNewTextClick(null, null); + } + } + else if (_shortcuts.MainCreateStartDownEndUp == e.KeyData) + { + if (_mainCreateStartDownEndUpParagraph == null) + { + _mainCreateStartDownEndUpParagraph = InsertNewTextAtVideoPosition(); + } + + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustSelected100MsForward == e.KeyData) + { + ShowEarlierOrLater(100, SelectionChoice.SelectionOnly); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustSelected100MsBack == e.KeyData) + { + ShowEarlierOrLater(-100, SelectionChoice.SelectionOnly); + e.SuppressKeyPress = true; + } + + + // adjust + else if (_shortcuts.MainAdjustSelected100MsForward == e.KeyData) + { + ShowEarlierOrLater(100, SelectionChoice.SelectionOnly); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustSelected100MsBack == e.KeyData) + { + ShowEarlierOrLater(-100, SelectionChoice.SelectionOnly); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustAdjustStartXMsBack == e.KeyData) + { + MoveStartCurrent(-Configuration.Settings.Tools.MoveStartEndMs, false); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustAdjustStartXMsForward == e.KeyData) + { + MoveStartCurrent(Configuration.Settings.Tools.MoveStartEndMs, false); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustAdjustEndXMsBack == e.KeyData) + { + MoveEndCurrent(-Configuration.Settings.Tools.MoveStartEndMs, false); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustAdjustEndXMsForward == e.KeyData) + { + MoveEndCurrent(Configuration.Settings.Tools.MoveStartEndMs, false); + e.SuppressKeyPress = true; + } + + else if (_shortcuts.MainAdjustMoveStartOneFrameBack == e.KeyData) + { + MoveStartCurrent(-(int)Math.Round(1000.0 / CurrentFrameRate), false); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustMoveStartOneFrameForward == e.KeyData) + { + MoveStartCurrent((int)Math.Round(1000.0 / CurrentFrameRate), false); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustMoveEndOneFrameBack == e.KeyData) + { + MoveEndCurrent(-(int)Math.Round(1000.0 / CurrentFrameRate), false); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustMoveEndOneFrameForward == e.KeyData) + { + MoveEndCurrent((int)Math.Round(1000.0 / CurrentFrameRate), false); + e.SuppressKeyPress = true; + } + + else if (_shortcuts.MainAdjustMoveStartOneFrameBackKeepGapPrev == e.KeyData) + { + MoveStartCurrent(-(int)Math.Round(1000.0 / CurrentFrameRate), true); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustMoveStartOneFrameForwardKeepGapPrev == e.KeyData) + { + MoveStartCurrent((int)Math.Round(1000.0 / CurrentFrameRate), true); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustMoveEndOneFrameBackKeepGapNext == e.KeyData) + { + MoveEndCurrent(-(int)Math.Round(1000.0 / CurrentFrameRate), true); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainAdjustMoveEndOneFrameForwardKeepGapNext == e.KeyData) + { + MoveEndCurrent((int)Math.Round(1000.0 / CurrentFrameRate), true); + e.SuppressKeyPress = true; + } + + else if (mediaPlayer.VideoPlayer != null && (_shortcuts.MainAdjustSetStartAndOffsetTheRest == e.KeyData || _shortcuts.MainAdjustSetStartAndOffsetTheRest2 == e.KeyData)) + { + ButtonSetStartAndOffsetRestClick(null, null); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetEndAndOffsetTheRest == e.KeyData) + { + SetEndAndOffsetTheRest(false); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetEndAndOffsetTheRestAndGoToNext == e.KeyData) + { + SetEndAndOffsetTheRest(true); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetEndAndGotoNext == e.KeyData) + { + ShowNextSubtitleLabel(); + ButtonSetEndAndGoToNextClick(null, null); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetStartKeepDuration == e.KeyData) + { + SetStartTime(true, mediaPlayer.CurrentPosition); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustInsertViaEndAutoStart == e.KeyData) + { + SetCurrentViaEndPositionAndGotoNext(FirstSelectedIndex, false); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustInsertViaEndAutoStartAndGoToNext == e.KeyData) + { + ShowNextSubtitleLabel(); + SetCurrentViaEndPositionAndGotoNext(FirstSelectedIndex, true); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetStartAutoDurationAndGoToNext == e.KeyData) + { + SetCurrentStartAutoDurationAndGotoNext(FirstSelectedIndex); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetEndNextStartAndGoToNext == e.KeyData) + { + ShowNextSubtitleLabel(); + SetCurrentEndNextStartAndGoToNext(FirstSelectedIndex); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustStartDownEndUpAndGoToNext == e.KeyData && _mainAdjustStartDownEndUpAndGoToNextParagraph == null) + { + ShowNextSubtitleLabel(); + _mainAdjustStartDownEndUpAndGoToNextParagraph = _subtitle.GetParagraphOrDefault(FirstSelectedIndex); + SetStartTime(true, mediaPlayer.CurrentPosition); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetStartAndEndOfPrevious == e.KeyData) + { + var pos = mediaPlayer.CurrentPosition; + SetStartAndEndOfPrevious(pos, false); + e.SuppressKeyPress = true; + } + else if (mediaPlayer.VideoPlayer != null && _shortcuts.MainAdjustSetStartAndEndOfPreviousAndGoToNext == e.KeyData) + { + var pos = mediaPlayer.CurrentPosition; + SetStartAndEndOfPrevious(pos, true); + e.SuppressKeyPress = true; + } + + // translate + else if (_shortcuts.MainTranslateGoogleIt == e.KeyData) + { + e.SuppressKeyPress = true; + buttonGoogleIt_Click(null, null); + } + else if (_shortcuts.MainTranslateCustomSearch1 == e.KeyData) + { + e.SuppressKeyPress = true; + RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl1); + } + else if (_shortcuts.MainTranslateCustomSearch2 == e.KeyData) + { + e.SuppressKeyPress = true; + RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl2); + } + else if (_shortcuts.MainTranslateCustomSearch3 == e.KeyData) + { + e.SuppressKeyPress = true; + RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl3); + } + else if (_shortcuts.MainTranslateCustomSearch4 == e.KeyData) + { + e.SuppressKeyPress = true; + RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl4); + } + else if (_shortcuts.MainTranslateCustomSearch5 == e.KeyData) + { + e.SuppressKeyPress = true; + RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl5); + } + // put new entries above tabs + } + + private void SetStartAndEndOfPrevious(double positionInSeconds, bool goToNext) + { + int index = SubtitleListview1.SelectedItems[0].Index; + var current = _subtitle.GetParagraphOrDefault(index); + if (SubtitleListview1.SelectedItems.Count != 1 || current == null) + { + return; + } + + if (positionInSeconds > current.EndTime.TotalSeconds - Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds / 1000) + { + return; + } + + // previous sub + var p = _subtitle.GetParagraphOrDefault(index - 1); + if (p == null || p.StartTime.TotalMilliseconds < p.StartTime.TotalMilliseconds - 9000) + { + SetStartTime(false, mediaPlayer.CurrentPosition); + return; + } + + if (positionInSeconds < p.StartTime.TotalSeconds + Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds / 1000) + { + return; + } + + SetStartTime(false, mediaPlayer.CurrentPosition); + + var oldParagraph = new Paragraph(p, false); + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + p.Number + " " + p.Text)); + p.EndTime.TotalMilliseconds = positionInSeconds * TimeCode.BaseUnit - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + if (oldParagraph.StartTime.IsMaxTime) + { + p.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds - Utilities.GetOptimalDisplayMilliseconds(p.Text); + } + + SubtitleListview1.SetStartTimeAndDuration(index, current, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + SubtitleListview1.SetStartTimeAndDuration(index - 1, p, current, _subtitle.GetParagraphOrDefault(index - 2)); + UpdateOriginalTimeCodes(oldParagraph); + ShowSource(); + + var next = _subtitle.GetParagraphOrDefault(index - 1); + if (goToNext && next != null) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true); + } + } + + private void ExtendCurrentSubtitle() + { + if (SubtitleListview1.SelectedItems.Count == 1) + { + var historyAdded = false; + var idx = SubtitleListview1.SelectedItems[0].Index; + var p = _subtitle.Paragraphs[idx]; + var next = _subtitle.GetParagraphOrDefault(idx + 1); + if (next == null || next.StartTime.TotalMilliseconds > p.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle)); + historyAdded = true; + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds; + } + else + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle)); + historyAdded = true; + p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + var originalNext = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) + 1); + if (originalNext == null || originalNext.StartTime.TotalMilliseconds > original.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines) + { + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle)); + } + + original.EndTime.TotalMilliseconds = original.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds; + } + else + { + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle)); + } + + original.EndTime.TotalMilliseconds = originalNext.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + + RefreshSelectedParagraph(); + } + } + + private void ExtendSelectedLinesToNextLine() + { + var historyAdded = false; + foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems) + { + var idx = selectedItem.Index; + var p = _subtitle.Paragraphs[idx]; + var next = _subtitle.GetParagraphOrDefault(idx + 1); + if (next != null) + { + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToNextSubtitle)); + historyAdded = true; + } + p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + var originalNext = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) + 1); + if (originalNext != null) + { + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToNextSubtitle)); + historyAdded = true; + } + + original.EndTime.TotalMilliseconds = originalNext.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + + RefreshSelectedParagraphs(); + } + } + + private void ExtendSelectedLinesToPreviousLine() + { + var historyAdded = false; + foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems) + { + var idx = selectedItem.Index; + var p = _subtitle.Paragraphs[idx]; + var previous = _subtitle.GetParagraphOrDefault(idx - 1); + if (previous != null) + { + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + var originalPrevious = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) - 1); + if (originalPrevious != null) + { + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToPreviousSubtitle)); + historyAdded = true; + } + + original.StartTime.TotalMilliseconds = originalPrevious.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToPreviousSubtitle)); + historyAdded = true; + } + + p.StartTime.TotalMilliseconds = previous.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + + RefreshSelectedParagraphs(); + } + } + + private void ExtendPreviousEndToCurrentStart() + { + if (SubtitleListview1.SelectedItems.Count == 1) + { + var historyAdded = false; + var idx = SubtitleListview1.SelectedItems[0].Index; + var p = _subtitle.Paragraphs[idx]; + var previous = _subtitle.GetParagraphOrDefault(idx - 1); + if (previous != null) + { + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendPreviousLineEndToCurrentStart)); + historyAdded = true; + } + previous.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + var originalPrevious = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) - 1); + if (originalPrevious != null) + { + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendPreviousLineEndToCurrentStart)); + historyAdded = true; + } + + originalPrevious.EndTime.TotalMilliseconds = original.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + + SubtitleListview1.SetStartTimeAndDuration(idx - 1, previous, _subtitle.GetParagraphOrDefault(idx), _subtitle.GetParagraphOrDefault(idx - 2)); + } + } + + private void ExtendNextStartToCurrentEnd() + { + if (SubtitleListview1.SelectedItems.Count == 1) + { + var historyAdded = false; + var idx = SubtitleListview1.SelectedItems[0].Index; + var p = _subtitle.Paragraphs[idx]; + var next = _subtitle.GetParagraphOrDefault(idx + 1); + if (next != null) + { + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendNextLineStartToCurrentEnd)); + historyAdded = true; + } + next.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + var originalNext = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) + 1); + if (originalNext != null) + { + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendNextLineStartToCurrentEnd)); + historyAdded = true; + } + + originalNext.StartTime.TotalMilliseconds = original.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + + SubtitleListview1.SetStartTimeAndDuration(idx + 1, next, _subtitle.GetParagraphOrDefault(idx + 2), _subtitle.GetParagraphOrDefault(idx)); + } + } + + private void SnapSelectedLinesStartToNextSceneChange(bool withGap = false) + { + var historyAdded = false; + foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems) + { + var idx = selectedItem.Index; + var p = _subtitle.Paragraphs[idx]; + List nextSceneChanges = audioVisualizer.SceneChanges.Count > 0 ? audioVisualizer.SceneChanges.Where(x => x > p.StartTime.TotalSeconds + 0.01).ToList() : new List(); + if (nextSceneChanges.Count > 0) + { + double nearestSceneChange = nextSceneChanges.Aggregate((x, y) => Math.Abs(x - p.StartTime.TotalSeconds) < Math.Abs(y - p.StartTime.TotalSeconds) ? x : y); + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustSnapStartToNextSceneChange)); + historyAdded = true; + } + + if (!withGap) + { + if (nearestSceneChange * 1000 < p.EndTime.TotalMilliseconds) + { + original.StartTime.TotalMilliseconds = nearestSceneChange * 1000; + } + } + else + { + if (nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines < p.EndTime.TotalMilliseconds) + { + original.StartTime.TotalMilliseconds = nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + + } + } + } + } + + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustSnapStartToNextSceneChange)); + historyAdded = true; + } + + if (!withGap) + { + if (nearestSceneChange * 1000 < p.EndTime.TotalMilliseconds) + { + p.StartTime.TotalMilliseconds = nearestSceneChange * 1000; + } + } + else + { + if (nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines < p.EndTime.TotalMilliseconds) + { + p.StartTime.TotalMilliseconds = nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + } + + RefreshSelectedParagraphs(); + } + } + + private void SnapSelectedLinesEndToPreviousSceneChange(bool withGap = false) + { + var historyAdded = false; + foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems) + { + var idx = selectedItem.Index; + var p = _subtitle.Paragraphs[idx]; + List previousSceneChanges = audioVisualizer.SceneChanges.Count > 0 ? audioVisualizer.SceneChanges.Where(x => x < p.EndTime.TotalSeconds + 0.01).ToList() : new List(); + if (previousSceneChanges.Count > 0) + { + double nearestSceneChange = previousSceneChanges.Aggregate((x, y) => Math.Abs(x - p.EndTime.TotalSeconds) < Math.Abs(y - p.EndTime.TotalSeconds) ? x : y); + + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustSnapEndToPreviousSceneChange)); + historyAdded = true; + } + + if (!withGap) + { + if (nearestSceneChange * 1000 > p.StartTime.TotalMilliseconds) + { + p.EndTime.TotalMilliseconds = nearestSceneChange * 1000; + } + } + else + { + if (nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines > p.StartTime.TotalMilliseconds) + { + p.EndTime.TotalMilliseconds = nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustSnapEndToPreviousSceneChange)); + historyAdded = true; + } + + if (!withGap) + { + if (nearestSceneChange * 1000 > p.StartTime.TotalMilliseconds) + { + original.EndTime.TotalMilliseconds = nearestSceneChange * 1000; + } + } + else + { + if (nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines > p.StartTime.TotalMilliseconds) + { + original.EndTime.TotalMilliseconds = nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + + } + } + } + } + } + + RefreshSelectedParagraphs(); + } + } + + private void ExtendSelectedLinesToNextSceneChange(bool withGap = false) + { + var historyAdded = false; + foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems) + { + var idx = selectedItem.Index; + var p = _subtitle.Paragraphs[idx]; + List nextSceneChanges = audioVisualizer.SceneChanges.Count > 0 ? audioVisualizer.SceneChanges.Where(x => x > p.EndTime.TotalSeconds + 0.01).ToList() : new List(); + if (nextSceneChanges.Count > 0) + { + var next = _subtitle.GetParagraphOrDefault(idx + 1); + double nearestSceneChange = nextSceneChanges.Aggregate((x, y) => Math.Abs(x - p.EndTime.TotalSeconds) < Math.Abs(y - p.EndTime.TotalSeconds) ? x : y); + double nearestStartTimeWithGap = next != null ? next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines : Double.MaxValue; + + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToNextSceneChange)); + historyAdded = true; + } + + if (!withGap) + { + p.EndTime.TotalMilliseconds = Math.Min(nearestSceneChange * 1000, nearestStartTimeWithGap); + } + else + { + p.EndTime.TotalMilliseconds = Math.Min(nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines, nearestStartTimeWithGap); + } + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + var originalNext = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) + 1); + double nearestOriginalStartTimeWithGap = originalNext != null ? originalNext.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines : Double.MaxValue; + + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToNextSceneChange)); + historyAdded = true; + } + + if (!withGap) + { + original.EndTime.TotalMilliseconds = Math.Min(nearestSceneChange * 1000, nearestOriginalStartTimeWithGap); + + } + else + { + original.EndTime.TotalMilliseconds = Math.Min(nearestSceneChange * 1000 - Configuration.Settings.General.MinimumMillisecondsBetweenLines, nearestStartTimeWithGap); + } + } + } + } + + RefreshSelectedParagraphs(); + } + } + + private void ExtendSelectedLinesToPreviousSceneChange(bool withGap = false) + { + var historyAdded = false; + foreach (ListViewItem selectedItem in SubtitleListview1.SelectedItems) + { + var idx = selectedItem.Index; + var p = _subtitle.Paragraphs[idx]; + List previousSceneChanges = audioVisualizer.SceneChanges.Count > 0 ? audioVisualizer.SceneChanges.Where(x => x < p.StartTime.TotalSeconds - 0.01).ToList() : new List(); + if (previousSceneChanges.Count > 0) + { + var previous = _subtitle.GetParagraphOrDefault(idx - 1); + double nearestSceneChange = previousSceneChanges.Aggregate((x, y) => Math.Abs(x - p.StartTime.TotalSeconds) < Math.Abs(y - p.StartTime.TotalSeconds) ? x : y); + double nearestEndTimeWithGap = previous != null ? previous.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines : -9999; + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + var originalPrevious = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) - 1); + double nearestOriginalEndTimeWithGap = originalPrevious != null ? originalPrevious.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines : -9999; + + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToPreviousSceneChange)); + historyAdded = true; + } + + if (!withGap) + { + original.StartTime.TotalMilliseconds = Math.Max(nearestSceneChange * 1000, nearestOriginalEndTimeWithGap); + } + else + { + original.StartTime.TotalMilliseconds = Math.Max(nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines, nearestOriginalEndTimeWithGap); + } + } + } + + if (!historyAdded) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToPreviousSceneChange)); + historyAdded = true; + } + + if (!withGap) + { + p.StartTime.TotalMilliseconds = Math.Max(nearestSceneChange * 1000, nearestEndTimeWithGap); + } + else + { + p.StartTime.TotalMilliseconds = Math.Max(nearestSceneChange * 1000 + Configuration.Settings.General.MinimumMillisecondsBetweenLines, nearestEndTimeWithGap); + } + } + + RefreshSelectedParagraphs(); + } + } + + private void GoToPreviousSubtitle(double currentPosition) + { + var found = false; + foreach (var p in _subtitle.Paragraphs) + { + if (p.StartTime.TotalMilliseconds > currentPosition - 1) + { + var prev = _subtitle.GetParagraphOrDefault(_subtitle.Paragraphs.IndexOf(p) - 1); + if (prev == null) + { + break; + } + + mediaPlayer.CurrentPosition = prev.StartTime.TotalSeconds; + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.Paragraphs.IndexOf(prev), true); + if (audioVisualizer.WavePeaks != null && p.StartTime.TotalSeconds > audioVisualizer.EndPositionSeconds + 0.2) + { + audioVisualizer.StartPositionSeconds = mediaPlayer.CurrentPosition - 0.2; + } + found = true; + break; + } + } + if (!found && _subtitle.Paragraphs.Count > 0 && _subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1].StartTime.TotalMilliseconds < currentPosition) + { + var p = _subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1]; + mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.Paragraphs.Count - 1, true); + if (audioVisualizer.WavePeaks != null && p.StartTime.TotalSeconds > audioVisualizer.EndPositionSeconds + 0.2) + { + audioVisualizer.StartPositionSeconds = mediaPlayer.CurrentPosition - 0.2; + } + } + } + + private void GoToNextSubtitle(double currentPosition) + { + foreach (var p in _subtitle.Paragraphs) + { + if (p.StartTime.TotalMilliseconds > currentPosition) + { + mediaPlayer.CurrentPosition = p.StartTime.TotalSeconds; + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.Paragraphs.IndexOf(p), true); + if (audioVisualizer.WavePeaks != null && p.StartTime.TotalSeconds > audioVisualizer.EndPositionSeconds + 0.2) + { + audioVisualizer.StartPositionSeconds = mediaPlayer.CurrentPosition - 0.2; + } + + break; + } + } + } + + private void AutoGuessStartTime(int index) + { + var p = _subtitle.GetParagraphOrDefault(index); + if (p == null) + { + return; + } + + var silenceLengthInSeconds = 0.08; + var lowPercent = audioVisualizer.FindLowPercentage(p.StartTime.TotalSeconds - 0.3, p.StartTime.TotalSeconds + 0.1); + var highPercent = audioVisualizer.FindHighPercentage(p.StartTime.TotalSeconds - 0.3, p.StartTime.TotalSeconds + 0.4); + var add = 5.0; + if (highPercent > 40) + { + add = 8; + } + else if (highPercent < 5) + { + add = highPercent - lowPercent - 0.3; + } + for (var startVolume = lowPercent + add; startVolume < 14; startVolume += 0.3) + { + var pos = audioVisualizer.FindDataBelowThresholdBackForStart(startVolume, silenceLengthInSeconds, p.StartTime.TotalSeconds); + var pos2 = audioVisualizer.FindDataBelowThresholdBackForStart(startVolume + 0.3, silenceLengthInSeconds, p.StartTime.TotalSeconds); + if (pos >= 0 && pos > p.StartTime.TotalSeconds - 1) + { + if (pos2 > pos && pos2 >= 0 && pos2 > p.StartTime.TotalSeconds - 1) + { + pos = pos2; + } + + var newStartTimeMs = pos * TimeCode.BaseUnit; + var prev = _subtitle.GetParagraphOrDefault(index - 1); + if (prev != null && prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines >= newStartTimeMs) + { + newStartTimeMs = prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + if (newStartTimeMs >= p.StartTime.TotalMilliseconds) + { + break; // cannot move start time + } + } + + // check for scene changes + if (audioVisualizer.SceneChanges != null) + { + var matchingSceneChanges = audioVisualizer.SceneChanges + .Where(sc => sc > p.StartTime.TotalSeconds - 0.3 && sc < p.StartTime.TotalSeconds + 0.2) + .OrderBy(sc => Math.Abs(sc - p.StartTime.TotalSeconds)); + if (matchingSceneChanges.Count() > 0) + { + newStartTimeMs = matchingSceneChanges.First() * TimeCode.BaseUnit; + } + } + + if (Math.Abs(p.StartTime.TotalMilliseconds - newStartTimeMs) < 10) + { + break; // diff too small + } + + var newEndTimeMs = p.EndTime.TotalMilliseconds; + if (newStartTimeMs > p.StartTime.TotalMilliseconds) + { + var temp = new Paragraph(p); + temp.StartTime.TotalMilliseconds = newStartTimeMs; + if (temp.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds || + Utilities.GetCharactersPerSecond(temp) > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds) + { + var next = _subtitle.GetParagraphOrDefault(index + 1); + if (next == null || + next.StartTime.TotalMilliseconds > newStartTimeMs + p.Duration.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines) + { + newEndTimeMs = newStartTimeMs + p.Duration.TotalMilliseconds; + } + } + } + + MakeHistoryForUndo(string.Format(Configuration.Settings.Language.Main.BeforeX, Configuration.Settings.Language.Settings.WaveformGuessStart)); + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + original.StartTime.TotalMilliseconds = newStartTimeMs; + original.EndTime.TotalMilliseconds = newEndTimeMs; + } + } + + p.StartTime.TotalMilliseconds = newStartTimeMs; + p.EndTime.TotalMilliseconds = newEndTimeMs; + RefreshSelectedParagraph(); + SubtitleListview1.SetStartTimeAndDuration(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + break; + } + } + } + + private void GoToBookmark() + { + using (var form = new BookmarksGoTo(_subtitle)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + SubtitleListview1.SelectIndexAndEnsureVisible(form.BookmarkIndex, true); + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.VideoPlayer.CurrentPosition = _subtitle.Paragraphs[form.BookmarkIndex].StartTime.TotalSeconds; + } + } + } + } + + private void GoToPrevoiusBookmark() + { + int idx = FirstSelectedIndex - 1; + try + { + for (int i = idx; i >= 0; i--) + { + var p = _subtitle.Paragraphs[i]; + if (p.Bookmark != null) + { + SubtitleListview1.SelectIndexAndEnsureVisible(i, true); + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.VideoPlayer.CurrentPosition = _subtitle.Paragraphs[i].StartTime.TotalSeconds; + } + + return; + } + } + } + catch + { + } + } + + private void GoToNextBookmark() + { + int idx = FirstSelectedIndex + 1; + try + { + for (int i = idx; i < _subtitle.Paragraphs.Count; i++) + { + var p = _subtitle.Paragraphs[i]; + if (p.Bookmark != null) + { + SubtitleListview1.SelectIndexAndEnsureVisible(i, true); + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.VideoPlayer.CurrentPosition = _subtitle.Paragraphs[i].StartTime.TotalSeconds; + } + + return; + } + } + } + catch + { + } + } + + private void ToggleBookmarks(bool setText) + { + bool first = true; + string newValue = null; + if (setText) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.ToggleBookmarksWithComment)); + } + else + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.ToggleBookmarks)); + } + + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.Paragraphs[index]; + if (first) + { + if (p.Bookmark == null) + { + if (setText) + { + using (var form = new BookmarkAdd(p)) + { + var result = form.ShowDialog(this); + if (result != DialogResult.OK) + { + return; + } + + newValue = form.Comment; + } + } + else + { + newValue = string.Empty; + } + } + else + { + newValue = null; + } + + first = false; + } + + p.Bookmark = newValue; + SubtitleListview1.ShowState(index, p); + ShowHideBookmark(p); + } + + SetListViewStateImages(); + new BookmarkPersistence(_subtitle, _fileName).Save(); + } + + private void SetListViewStateImages() + { + var oldStaeImageList = SubtitleListview1.StateImageList; + SubtitleListview1.StateImageList = _subtitle != null && _subtitle.Paragraphs.Any(p => p.Bookmark != null) ? imageListBookmarks : null; + if (SubtitleListview1.StateImageList == null) + { + SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Text = Configuration.Settings.Language.General.NumberSymbol; + } + else + { + SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Text = " " + Configuration.Settings.Language.General.NumberSymbol; + } + + if (oldStaeImageList == SubtitleListview1.StateImageList) + { + return; + } + + if (!_loading) + { + if (SubtitleListview1.StateImageList == null) + { + SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Width = Configuration.Settings.General.ListViewNumberWidth - 18; + } + else + { + SubtitleListview1.Columns[SubtitleListview1.ColumnIndexNumber].Width = Configuration.Settings.General.ListViewNumberWidth + 18; + } + } + + SubtitleListview1.SubtitleListViewLastColumnFill(null, null); + } + + private void ClearBookmarks() + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.ClearBookmarks)); + for (var index = 0; index < _subtitle.Paragraphs.Count; index++) + { + var paragraph = _subtitle.Paragraphs[index]; + if (paragraph.Bookmark != null) + { + paragraph.Bookmark = null; + SubtitleListview1.ShowState(index, paragraph); + } + } + + var p = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex); + if (p != null) + { + ShowHideBookmark(p); + } + + SetListViewStateImages(); + new BookmarkPersistence(_subtitle, _fileName).Save(); + } + + private void MoveWordUpDownInCurrent(bool down, SETextBox tb) + { + int firstIndex = FirstSelectedIndex; + if (firstIndex < 0) + { + return; + } + + var p = _subtitle.GetParagraphOrDefault(firstIndex); + if (tb == textBoxListViewTextAlternate) + { + p = Utilities.GetOriginalParagraph(firstIndex, p, _subtitleAlternate.Paragraphs); + } + + if (p == null) + { + return; + } + + var lines = p.Text.SplitToLines(); + if (lines.Count == 1) + { + lines.Add(string.Empty); + } + + if (lines.Count != 2) + { + return; + } + + var line1Words = lines[0].Split(' ').ToList(); + var line2Words = lines[1].Split(' ').ToList(); + if (down) + { + if (line1Words.Count > 0) + { + line2Words.Insert(0, line1Words[line1Words.Count - 1]); + line1Words.RemoveAt(line1Words.Count - 1); + } + } + else // up + { + if (line2Words.Count > 0) + { + line1Words.Add(line2Words[0]); + line2Words.RemoveAt(0); + } + } + + var newText = (string.Join(" ", line1Words.ToArray()).Trim() + Environment.NewLine + + string.Join(" ", line2Words.ToArray()).Trim()).Trim(); + if (newText != p.Text) + { + var oldText = p.Text; + MakeHistoryForUndo(_language.BeforeLineUpdatedInListView); + var textCaretPos = textBoxListViewText.SelectionStart; + p.Text = newText; + if (tb == textBoxListViewTextAlternate) + { + SubtitleListview1.SetAlternateText(firstIndex, p.Text); + } + else + { + SubtitleListview1.SetText(firstIndex, p.Text); + } + tb.Text = p.Text; + + // keep cursor position + KeepCursorMoveWordUpdown(down, newText, oldText, textCaretPos); + } + } + + private void KeepCursorMoveWordUpdown(bool down, string newText, string oldText, int textCaretPos) + { + if (textCaretPos > textBoxListViewText.Text.Length) + { + // set cursor at end of textbox + textBoxListViewText.SelectionStart = textCaretPos; + int end = textBoxListViewText.Text.Length; + textBoxListViewText.SelectionStart = end; + textBoxListViewText.SelectionLength = 0; + return; + } + + int indexOfNewLine = newText.IndexOf(Environment.NewLine, StringComparison.Ordinal); + int oldIndexOfNewLine = oldText.IndexOf(Environment.NewLine, StringComparison.Ordinal); + + if (down) + { + if (indexOfNewLine == -1 && oldIndexOfNewLine > 0 && textCaretPos > oldIndexOfNewLine) + { + textCaretPos--; + } + else if (textCaretPos > indexOfNewLine && textCaretPos > oldIndexOfNewLine && oldIndexOfNewLine >= 0 || + textCaretPos < indexOfNewLine && (oldIndexOfNewLine == -1 || textCaretPos < oldIndexOfNewLine) || + textCaretPos < oldIndexOfNewLine && indexOfNewLine == -1) + { + } + else + { + textCaretPos++; + } + } + else // up + { + if (textCaretPos <= oldIndexOfNewLine || textCaretPos > oldIndexOfNewLine && textCaretPos > indexOfNewLine && indexOfNewLine >= 0) + { + } + else + { + textCaretPos--; + } + } + + if (textBoxListViewText.Text.Length > textCaretPos && '\n' == textBoxListViewText.Text[textCaretPos]) + { + textCaretPos--; + } + + if (textCaretPos >= 0) + { + textBoxListViewText.SelectionStart = textCaretPos; + textBoxListViewText.SelectionStart = textCaretPos; + textBoxListViewText.SelectionStart = textCaretPos; + } + } + + private void MoveStartCurrent(int ms, bool keepGapPrevIfClose) + { + var i = _subtitleListViewIndex; + if (i < 0 || i >= _subtitle.Paragraphs.Count || ms == 0) + { + return; + } + + var p = _subtitle.GetParagraphOrDefault(i); + if (p == null) + { + return; + } + + // snap to scene change + if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && audioVisualizer?.SceneChanges?.Count > 0) + { + var seconds = (p.StartTime.TotalMilliseconds + ms) / 1000.0; + var closest = audioVisualizer.SceneChanges.OrderBy(sc => Math.Abs(seconds - sc)).First() * 1000.0; + if (Math.Abs(p.StartTime.TotalMilliseconds + ms - closest) < CurrentFrameRate * 0.9) + { + ms = (int)Math.Round(closest - p.StartTime.TotalMilliseconds); + } + } + + var prevGap = 0.0; + var prev = _subtitle.GetParagraphOrDefault(i - 1); + if (keepGapPrevIfClose && prev != null) + { + if (prev.EndTime.TotalMilliseconds <= p.StartTime.TotalMilliseconds && prev.EndTime.TotalMilliseconds + 200 >= p.StartTime.TotalMilliseconds) + { + prevGap = p.StartTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds; + if (ms < 0 && prev.Duration.TotalMilliseconds + ms < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds) + { + return; + } + } + else + { + prev = null; + } + } + + if (ms > 0) + { + if (p.StartTime.TotalMilliseconds + ms + Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds > p.EndTime.TotalMilliseconds) + { + return; // do not allow duration smaller than min duration in ms + } + + p.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + ms; + } + else + { + if (p.Duration.TotalMilliseconds + Math.Abs(ms) > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) + { + return; + } + + if (p.StartTime.TotalMilliseconds + ms < 0) + { + return; + } + + if (keepGapPrevIfClose || prev == null || p.StartTime.TotalMilliseconds - (Math.Abs(ms) + Configuration.Settings.General.MinimumMillisecondsBetweenLines) > prev.EndTime.TotalMilliseconds) + { + p.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + ms; + } + else + { + var newStartMs = prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + if (newStartMs < p.StartTime.TotalMilliseconds) + { + p.StartTime.TotalMilliseconds = newStartMs; + } + } + } + + SubtitleListview1.SetStartTimeAndDuration(i, p, _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1)); + timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; + timeUpDownStartTime.TimeCode = p.StartTime; + timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; + SetDurationInSeconds(p.Duration.TotalSeconds); + + if (keepGapPrevIfClose && prev != null) + { + prev.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds - prevGap; + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(_subtitle.GetIndex(prev), prev, _subtitleAlternate.Paragraphs); + if (original != null) + { + original.EndTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds; + } + } + SubtitleListview1.SetStartTimeAndDuration(i - 1, prev, p, _subtitle.GetParagraphOrDefault(i - 2)); + } + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(_subtitle.GetIndex(p), p, _subtitleAlternate.Paragraphs); + if (original != null) + { + original.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds; + original.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds; + } + } + + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, i, p); + } + + private void MoveEndCurrent(int ms, bool keepGapNextIfClose) + { + var i = _subtitleListViewIndex; + if (i < 0 || i >= _subtitle.Paragraphs.Count || ms == 0) + { + return; + } + + var p = _subtitle.GetParagraphOrDefault(i); + if (p == null) + { + return; + } + + // snap to scene change + if (Configuration.Settings.VideoControls.WaveformSnapToSceneChanges && audioVisualizer?.SceneChanges?.Count > 0) + { + var seconds = (p.EndTime.TotalMilliseconds + ms) / 1000.0; + var closest = audioVisualizer.SceneChanges.OrderBy(sc => Math.Abs(seconds - sc)).First() * 1000.0; + if (Math.Abs(p.EndTime.TotalMilliseconds + ms - closest) < CurrentFrameRate * 0.9) + { + ms = (int)Math.Round(closest - p.EndTime.TotalMilliseconds); + } + } + + var nextGap = 0.0; + var next = _subtitle.GetParagraphOrDefault(i + 1); + if (keepGapNextIfClose && next != null) + { + if (next.StartTime.TotalMilliseconds >= p.EndTime.TotalMilliseconds && next.StartTime.TotalMilliseconds - 200 < p.EndTime.TotalMilliseconds) + { + nextGap = next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds; + if (ms > 0 && next.Duration.TotalMilliseconds + ms < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds) + { + return; + } + } + else + { + next = null; + } + } + + if (ms > 0) + { + if (p.Duration.TotalMilliseconds + ms > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) + { + return; + } + + if (keepGapNextIfClose || next == null || p.EndTime.TotalMilliseconds + ms + Configuration.Settings.General.MinimumMillisecondsBetweenLines < next.StartTime.TotalMilliseconds) + { + p.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds + ms; + } + else + { + var newEndMs = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + if (newEndMs > p.EndTime.TotalMilliseconds) + { + p.EndTime.TotalMilliseconds = newEndMs; + } + } + } + else + { + if (p.EndTime.TotalMilliseconds + ms - Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds < p.StartTime.TotalMilliseconds) + { + return; // do not allow duration smaller than min duration in ms + } + + p.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds + ms; + } + + SubtitleListview1.SetStartTimeAndDuration(i, p, _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1)); + timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; + timeUpDownStartTime.TimeCode = p.StartTime; + timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; + SetDurationInSeconds(p.Duration.TotalSeconds); + + if (keepGapNextIfClose && next != null) + { + next.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds + nextGap; + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(_subtitle.GetIndex(next), next, _subtitleAlternate.Paragraphs); + if (original != null) + { + original.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds; + } + } + SubtitleListview1.SetStartTimeAndDuration(i + 1, next, _subtitle.GetParagraphOrDefault(i + 2), p); + } + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(_subtitle.GetIndex(p), p, _subtitleAlternate.Paragraphs); + if (original != null) + { + original.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds; + original.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds; + } + } + + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, i, p); + } + + private void ShowNextSubtitleLabel() + { + if (audioVisualizer.Visible && audioVisualizer.WavePeaks != null && audioVisualizer.Width > 300 && _subtitleListViewIndex >= 0) + { + var next = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex + 1); + if (next != null && !string.IsNullOrEmpty(next.Text)) + { + labelNextWord.Top = audioVisualizer.Top; + labelNextWord.Text = string.Format(_language.NextX, HtmlUtil.RemoveHtmlTags(next.Text, true).Replace(Environment.NewLine, " ")); + labelNextWord.Left = audioVisualizer.Width / 2 - labelNextWord.Width / 2 + audioVisualizer.Left; + labelNextWord.Visible = true; + _labelNextTicks = DateTime.UtcNow.Ticks; + } + else + { + labelNextWord.Visible = false; + } + } + else + { + labelNextWord.Visible = false; + } + } + + private void MergeSelectedLinesOnlyFirstText() + { + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 1) + { + var deleteIndices = new List(); + bool first = true; + int firstIndex = 0; + int next = 0; + string text = string.Empty; + double endTime = 0; + foreach (int index in SubtitleListview1.SelectedIndices) + { + if (first) + { + firstIndex = index; + next = index + 1; + } + else + { + deleteIndices.Add(index); + if (next != index) + { + return; + } + + next++; + } + + first = false; + if (string.IsNullOrEmpty(text)) + { + text = _subtitle.Paragraphs[index].Text.Trim(); + } + + endTime = _subtitle.Paragraphs[index].EndTime.TotalMilliseconds; + } + + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + MakeHistoryForUndo(_language.BeforeMergeLines); + + var currentParagraph = _subtitle.Paragraphs[firstIndex]; + currentParagraph.Text = text; + currentParagraph.EndTime.TotalMilliseconds = endTime; + + var nextParagraph = _subtitle.GetParagraphOrDefault(next); + if (nextParagraph != null && currentParagraph.EndTime.TotalMilliseconds > nextParagraph.StartTime.TotalMilliseconds && currentParagraph.StartTime.TotalMilliseconds < nextParagraph.StartTime.TotalMilliseconds) + { + currentParagraph.EndTime.TotalMilliseconds = nextParagraph.StartTime.TotalMilliseconds - 1; + } + + // original subtitle + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(firstIndex, currentParagraph, _subtitleAlternate.Paragraphs); + if (original != null) + { + string originalText = string.Empty; + for (int i = 0; i < deleteIndices.Count; i++) + { + var originalNext = Utilities.GetOriginalParagraph(deleteIndices[i], _subtitle.Paragraphs[deleteIndices[i]], _subtitleAlternate.Paragraphs); + if (originalNext != null && string.IsNullOrEmpty(originalText)) + { + originalText = originalNext.Text; + } + } + + for (int i = deleteIndices.Count - 1; i >= 0; i--) + { + var originalNext = Utilities.GetOriginalParagraph(deleteIndices[i], _subtitle.Paragraphs[deleteIndices[i]], _subtitleAlternate.Paragraphs); + if (originalNext != null) + { + _subtitleAlternate.Paragraphs.Remove(originalNext); + } + } + + original.Text = originalText; + original.EndTime.TotalMilliseconds = currentParagraph.EndTime.TotalMilliseconds; + _subtitleAlternate.Renumber(); + } + } + + if (_networkSession != null) + { + _networkSession.TimerStop(); + _networkSession.UpdateLine(firstIndex, currentParagraph); + NetworkGetSendUpdates(deleteIndices, 0, null); + } + else + { + for (int i = deleteIndices.Count - 1; i >= 0; i--) + { + _subtitle.Paragraphs.RemoveAt(deleteIndices[i]); + } + + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + ShowSource(); + ShowStatus(_language.LinesMerged); + SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex, true); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + RefreshSelectedParagraph(); + } + } + + private void GoToFirstEmptyLine() + { + var index = FirstSelectedIndex + 1; + for (; index < _subtitle.Paragraphs.Count; index++) + { + if (string.IsNullOrWhiteSpace(_subtitle.Paragraphs[index].Text)) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.VideoPlayer.CurrentPosition = _subtitle.Paragraphs[index].StartTime.TotalSeconds; + } + + return; + } + } + } + + private void PlayFirstSelectedSubtitle() + { + if (_subtitleListViewIndex >= 0 && mediaPlayer.VideoPlayer != null) + { + GotoSubtitleIndex(_subtitleListViewIndex); + var paragraph = _subtitle.Paragraphs[_subtitleListViewIndex]; + double startSeconds = paragraph.StartTime.TotalSeconds; + _endSeconds = paragraph.EndTime.TotalSeconds; + mediaPlayer.CurrentPosition = startSeconds; + ShowSubtitle(); + mediaPlayer.Play(); + } + } + + private void SetEndAndOffsetTheRest(bool goToNext) + { + if (SubtitleListview1.SelectedItems.Count == 1) + { + bool oldSync = checkBoxSyncListViewWithVideoWhilePlaying.Checked; + checkBoxSyncListViewWithVideoWhilePlaying.Checked = false; + + int index = SubtitleListview1.SelectedItems[0].Index; + double videoPosition = mediaPlayer.CurrentPosition; + if (!mediaPlayer.IsPaused) + { + videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; + } + + var tc = TimeCode.FromSeconds(videoPosition); + + double offset = tc.TotalMilliseconds - _subtitle.Paragraphs[index].EndTime.TotalMilliseconds; + if (_subtitle.Paragraphs[index].StartTime.TotalMilliseconds + 100 > tc.TotalMilliseconds || offset > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds) + { + return; + } + + MakeHistoryForUndo(_language.BeforeSetEndTimeAndOffsetTheRest + @" " + _subtitle.Paragraphs[index].Number + @" - " + tc); + + numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged; + _subtitle.Paragraphs[index].EndTime.TotalSeconds = videoPosition; + SubtitleListview1.SetDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); + checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync; + numericUpDownDuration.Value = (decimal)_subtitle.Paragraphs[index].Duration.TotalSeconds; + numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged; + RefreshSelectedParagraph(); + + for (int i = index + 1; i < SubtitleListview1.Items.Count; i++) + { + if (!_subtitle.Paragraphs[i].StartTime.IsMaxTime) + { + _subtitle.Paragraphs[i].StartTime = new TimeCode(_subtitle.Paragraphs[i].StartTime.TotalMilliseconds + offset); + _subtitle.Paragraphs[i].EndTime = new TimeCode(_subtitle.Paragraphs[i].EndTime.TotalMilliseconds + offset); + SubtitleListview1.SetDuration(i, _subtitle.Paragraphs[i], _subtitle.GetParagraphOrDefault(i + 1)); + } + } + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + var original = Utilities.GetOriginalParagraph(index, _subtitle.Paragraphs[index], _subtitleAlternate.Paragraphs); + if (original != null) + { + index = _subtitleAlternate.GetIndex(original); + for (int i = index; i < _subtitleAlternate.Paragraphs.Count; i++) + { + if (!_subtitleAlternate.Paragraphs[i].StartTime.IsMaxTime) + { + _subtitleAlternate.Paragraphs[i].StartTime = new TimeCode(_subtitleAlternate.Paragraphs[i].StartTime.TotalMilliseconds + offset); + _subtitleAlternate.Paragraphs[i].EndTime = new TimeCode(_subtitleAlternate.Paragraphs[i].EndTime.TotalMilliseconds + offset); + } + } + } + } + + checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync; + + if (goToNext) + { + _subtitleListViewIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true); + if (mediaPlayer.IsPaused && index + 1 < _subtitle.Paragraphs.Count) + { + mediaPlayer.CurrentPosition = _subtitle.Paragraphs[index + 1].StartTime.TotalSeconds; + } + } + } + } + + private void MoveVideoSeconds(double seconds) + { + var oldPosition = mediaPlayer.CurrentPosition; + var newPosition = oldPosition + seconds; + if (newPosition < 0) + { + newPosition = 0; + } + + if (mediaPlayer.IsPaused && Configuration.Settings.General.MoveVideo100Or500MsPlaySmallSample) + { + mediaPlayer.CurrentPosition = newPosition; + mediaPlayer.Play(); + System.Threading.Thread.Sleep(99); + mediaPlayer.Stop(); + } + + mediaPlayer.CurrentPosition = newPosition; + } + + private void RunCustomSearch(string url) + { + if (!string.IsNullOrEmpty(url)) + { + RunTranslateSearch((text) => + { + url = string.Format(url, Utilities.UrlEncode(text)); + UiUtil.OpenURL(url); + }); + } + } + + private void GoFullscreen(bool force) + { + if (mediaPlayer.VideoPlayer == null && !force) + { + return; + } + + mediaPlayer.ShowFullScreenControls(); + bool setRedockOnFullscreenEnd = false; + + if (_videoPlayerUndocked == null || _videoPlayerUndocked.IsDisposed) + { + UndockVideoControlsToolStripMenuItemClick(null, null); + setRedockOnFullscreenEnd = true; + } + + if (_videoPlayerUndocked != null && !_videoPlayerUndocked.IsDisposed) + { + _videoPlayerUndocked.Focus(); + _videoPlayerUndocked.GoFullscreen(); + if (setRedockOnFullscreenEnd) + { + _videoPlayerUndocked.RedockOnFullscreenEnd = true; + } + } + } + + private void RefreshTimeCodeMode() + { + if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) + { + numericUpDownDuration.DecimalPlaces = 2; + numericUpDownDuration.Increment = (decimal)(0.01); + + toolStripSeparatorFrameRate.Visible = true; + toolStripLabelFrameRate.Visible = true; + toolStripComboBoxFrameRate.Visible = true; + toolStripButtonGetFrameRate.Visible = true; + } + else + { + numericUpDownDuration.DecimalPlaces = 3; + numericUpDownDuration.Increment = (decimal)(0.1); + + toolStripSeparatorFrameRate.Visible = Configuration.Settings.General.ShowFrameRate; + toolStripLabelFrameRate.Visible = Configuration.Settings.General.ShowFrameRate; + toolStripComboBoxFrameRate.Visible = Configuration.Settings.General.ShowFrameRate; + toolStripButtonGetFrameRate.Visible = Configuration.Settings.General.ShowFrameRate; + } + + SaveSubtitleListviewIndices(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + RefreshSelectedParagraph(); + } + + private void ReverseStartAndEndingForRtl() + { + MakeHistoryForUndo(toolStripMenuItemReverseRightToLeftStartEnd.Text); + int selectedIndex = FirstSelectedIndex; + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.Paragraphs[index]; + p.Text = Utilities.ReverseStartAndEndingForRightToLeft(p.Text); + SubtitleListview1.SetText(index, p.Text); + if (index == selectedIndex) + { + textBoxListViewText.Text = p.Text; + } + } + } + + private void MergeDialogs() + { + if (SubtitleListview1.SelectedItems.Count == 1 || SubtitleListview1.SelectedItems.Count == 2 && SubtitleListview1.SelectedIndices[0] + 1 == SubtitleListview1.SelectedIndices[1]) + { + MergeWithLineAfter(true); + } + } + + private void ToggleDashes() + { + var index = FirstSelectedIndex; + if (index >= 0) + { + var hasStartDash = false; + var p = _subtitle.Paragraphs[index]; + var lines = p.Text.SplitToLines(); + foreach (var line in lines) + { + var trimmed = HtmlUtil.RemoveHtmlTags(line, true).TrimStart(); + if (trimmed.StartsWith('-')) + { + hasStartDash = true; + break; + } + } + + if (!hasStartDash && _subtitleAlternate != null && textBoxListViewTextAlternate.Visible) + { + var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + lines = original.Text.SplitToLines(); + foreach (var line in lines) + { + var trimmed = HtmlUtil.RemoveHtmlTags(line, true).TrimStart(); + if (trimmed.StartsWith('-')) + { + hasStartDash = true; + break; + } + } + } + } + + MakeHistoryForUndo(_language.BeforeToggleDialogDashes); + if (hasStartDash) + { + RemoveDashes(); + } + else + { + AddDashes(); + } + } + } + + private void ToggleDashesTextBox(SETextBox tb) + { + var hasStartDash = false; + var lines = tb.Text.TrimEnd().SplitToLines(); + foreach (var line in lines) + { + var trimmed = HtmlUtil.RemoveHtmlTags(line, true).TrimStart(); + if (trimmed.StartsWith('-')) + { + hasStartDash = true; + break; + } + } + + MakeHistoryForUndo(_language.BeforeToggleDialogDashes); + var sb = new StringBuilder(); + if (hasStartDash) + { + // remove dashes + foreach (var line in lines) + { + var pre = string.Empty; + var s = SplitStartTags(line, ref pre); + sb.AppendLine(pre + s.TrimStart('-').TrimStart()); + } + + tb.Text = sb.ToString().Trim(); + } + else + { + // add dashes + if (CouldBeDialog(lines)) + { + foreach (var line in lines) + { + var pre = string.Empty; + var s = SplitStartTags(line, ref pre); + sb.AppendLine(pre + "- " + s); + } + } + else + { + sb.Append(tb.Text); + } + + var text = sb.ToString().Trim(); + var dialogHelper = new DialogSplitMerge { DialogStyle = Configuration.Settings.General.DialogStyle, SkipLineEndingCheck = true }; + text = dialogHelper.FixDashesAndSpaces(text); + tb.Text = text; + } + } + + private void AddDashes() + { + var dialogHelper = new DialogSplitMerge { DialogStyle = Configuration.Settings.General.DialogStyle, SkipLineEndingCheck = true }; + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.Paragraphs[index]; + var lines = p.Text.SplitToLines(); + var sb = new StringBuilder(); + if (CouldBeDialog(lines)) + { + foreach (var line in lines) + { + var pre = string.Empty; + var s = SplitStartTags(line, ref pre); + sb.AppendLine(pre + "- " + s); + } + } + else + { + sb.Append(p.Text); + } + + var text = sb.ToString().Trim(); + text = dialogHelper.FixDashesAndSpaces(text); + _subtitle.Paragraphs[index].Text = text; + SubtitleListview1.SetText(index, text); + if (index == _subtitleListViewIndex) + { + textBoxListViewText.Text = text; + } + + if (_subtitleAlternate != null && textBoxListViewTextAlternate.Visible) + { + var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + lines = original.Text.SplitToLines(); + sb = new StringBuilder(); + if (CouldBeDialog(lines)) + { + foreach (var line in lines) + { + var pre = string.Empty; + var s = SplitStartTags(line, ref pre); + if (!line.StartsWith("-")) + { + sb.AppendLine(pre + "- " + s); + } + else + { + sb.AppendLine(pre + s); + } + } + } + else + { + sb.Append(original.Text); + } + + text = sb.ToString().Trim(); + text = dialogHelper.FixDashesAndSpaces(text); + _subtitleAlternate.Paragraphs[index].Text = text; + SubtitleListview1.SetAlternateText(index, text); + if (index == _subtitleListViewIndex) + { + textBoxListViewTextAlternate.Text = text; + } + } + } + } + } + + private static bool CouldBeDialog(List lines) + { + return lines.Count >= 2 && lines.Count <= 3; + } + + private void RemoveDashes() + { + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.Paragraphs[index]; + var lines = p.Text.SplitToLines(); + var sb = new StringBuilder(); + foreach (var line in lines) + { + var pre = string.Empty; + var s = SplitStartTags(line, ref pre); + sb.AppendLine(pre + s.TrimStart('-').TrimStart()); + } + + string text = sb.ToString().Trim(); + _subtitle.Paragraphs[index].Text = text; + SubtitleListview1.SetText(index, text); + if (index == _subtitleListViewIndex) + { + textBoxListViewText.Text = text; + } + + if (_subtitleAlternate != null && textBoxListViewTextAlternate.Visible) + { + var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + lines = original.Text.SplitToLines(); + sb = new StringBuilder(); + foreach (var line in lines) + { + var pre = string.Empty; + var s = SplitStartTags(line, ref pre); + sb.AppendLine(pre + s.TrimStart('-').TrimStart()); + } + + text = sb.ToString().Trim(); + _subtitleAlternate.Paragraphs[index].Text = text; + SubtitleListview1.SetAlternateText(index, text); + if (index == _subtitleListViewIndex) + { + textBoxListViewTextAlternate.Text = text; + } + } + } + } + } + + private static string SplitStartTags(string line, ref string pre) + { + var s = line; + if (s.StartsWith("{\\", StringComparison.Ordinal) && s.IndexOf('}') > 0) + { + pre = s.Substring(0, s.IndexOf('}') + 1); + s = s.Remove(0, pre.Length); + } + + bool updated = true; + while (updated) + { + updated = false; + if (s.StartsWith(' ')) + { + pre += ' '; + s = s.Remove(0, 1); + updated = true; + } + else if (s.StartsWith("", StringComparison.OrdinalIgnoreCase) || + s.StartsWith("", StringComparison.OrdinalIgnoreCase) || + s.StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + pre += s.Substring(0, 3); + s = s.Remove(0, 3); + updated = true; + } + else if (s.StartsWith("'); + if (endFont > 0) + { + pre += s.Substring(0, endFont + 1); + s = s.Remove(0, endFont + 1); + updated = true; + } + } + } + + return s; + } + + private void SetTitle() + { + var text = "Untitled"; + string separator = " + "; + if (!string.IsNullOrEmpty(_fileName)) + { + text = _fileName; + } + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + text += separator; + if (string.IsNullOrEmpty(_fileName)) + { + text = text + _language.New + " + "; + } + + if (!string.IsNullOrEmpty(_subtitleAlternateFileName)) + { + text += _subtitleAlternateFileName; + } + else + { + text += _language.New; + } + } + + Text = text + " - " + Title; + } + + private void SubtitleListview1KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control) //Ctrl+c = Copy to clipboard + { + var tmp = new Subtitle(); + foreach (int i in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.GetParagraphOrDefault(i); + if (p != null) + { + tmp.Paragraphs.Add(new Paragraph(p)); + } + } + + if (tmp.Paragraphs.Count > 0) + { + if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) + { + tmp.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(Configuration.Settings.General.CurrentVideoOffsetInMs)); + } + + Clipboard.SetText(tmp.ToText(new SubRip()).TrimEnd()); + } + + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewCopyText) + { + var sb = new StringBuilder(); + foreach (int i in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.GetParagraphOrDefault(i); + if (p != null) + { + sb.AppendLine(p.Text + Environment.NewLine); + } + } + + if (sb.ToString().TrimEnd().Length > 0) + { + Clipboard.SetText(sb.ToString().TrimEnd()); + } + + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAutoDuration) + { + MakeAutoDurationSelectedLines(); + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN1) + { + SetAlignment("{\\an1}", true); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN2) + { + SetAlignment("", true); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN3) + { + SetAlignment("{\\an3}", true); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN4) + { + SetAlignment("{\\an4}", true); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN5) + { + SetAlignment("{\\an5}", true); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN6) + { + SetAlignment("{\\an6}", true); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN7) + { + SetAlignment("{\\an7}", true); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN8) + { + SetAlignment("{\\an8}", true); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewAlignmentN9) + { + SetAlignment("{\\an9}", true); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewFocusWaveform) + { + if (audioVisualizer.CanFocus) + { + audioVisualizer.Focus(); + e.SuppressKeyPress = true; + } + } + else if (e.KeyData == _shortcuts.MainListViewGoToNextError) + { + GoToNextSyntaxError(); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainListViewRemoveTimeCodes) + { + RemoveTimeCodesFromSelectedLines(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control) //Ctrl+V = Paste from clipboard + { + if (Clipboard.ContainsText()) + { + var text = Clipboard.GetText(); + var tmp = new Subtitle(); + var format = new SubRip(); + var list = new List(text.SplitToLines()); + format.LoadSubtitle(tmp, list, null); + if (SubtitleListview1.SelectedItems.Count == 1 && tmp.Paragraphs.Count > 0) + { + MakeHistoryForUndo(_language.BeforeInsertLine); + int firstIndex = FirstSelectedIndex; + var lastParagraph = _subtitle.Paragraphs[firstIndex]; + double addMs = 0; + if (lastParagraph.EndTime.TotalMilliseconds > tmp.Paragraphs[0].StartTime.TotalMilliseconds) + { // add time to pasted subtitles to prevent overlap, but only if necessary + addMs = lastParagraph.EndTime.TotalMilliseconds - tmp.Paragraphs[0].StartTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + else if (firstIndex <= _subtitle.Paragraphs.Count - 2 && _subtitle.Paragraphs[firstIndex + 1].StartTime.TotalMilliseconds < tmp.Paragraphs[0].StartTime.TotalMilliseconds) + { // inserting between two subtitle... with overlapping codes + addMs = lastParagraph.EndTime.TotalMilliseconds - tmp.Paragraphs[0].StartTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + + var selectIndices = new List(); + for (int i = 0; i < tmp.Paragraphs.Count; i++) + { + var p = tmp.Paragraphs[i]; + p.StartTime.TotalMilliseconds += addMs; + p.EndTime.TotalMilliseconds += addMs; + _subtitle.Paragraphs.Insert(firstIndex + i + 1, p); + selectIndices.Insert(0, firstIndex + i + 1); + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) + { + var original = Utilities.GetOriginalParagraph(firstIndex + i + 1, p, _subtitleAlternate.Paragraphs); + if (original == null) + { + _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds)); + } + } + } + + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.BeginUpdate(); + foreach (var selectIndex in selectIndices) + { + SubtitleListview1.Items[selectIndex].Selected = true; + } + + SubtitleListview1.EndUpdate(); + SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex + 1, true); + } + else if (SubtitleListview1.Items.Count == 0 && tmp.Paragraphs.Count > 0) + { // insert into empty subtitle + MakeHistoryForUndo(_language.BeforeInsertLine); + foreach (var p in tmp.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) + { + var original = Utilities.GetOriginalParagraph(_subtitle.Paragraphs.Count - 1, p, _subtitleAlternate.Paragraphs); + if (original == null) + { + _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds)); + } + } + } + + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + } + else if (SubtitleListview1.Items.Count > 1 && tmp.Paragraphs.Count > 0) + { + // multiple lines selected - first delete, then insert + int firstIndex = FirstSelectedIndex; + if (firstIndex >= 0) + { + var idx = firstIndex; + MakeHistoryForUndo(_language.BeforeInsertLine); + _makeHistoryPaused = true; + + DeleteSelectedLines(); + _subtitleListViewIndex = -1; + var selectedIndices = new List(); + foreach (var p in tmp.Paragraphs) + { + _subtitle.Paragraphs.Insert(idx, p); + selectedIndices.Add(idx); + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) + { + var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); + if (original == null) + { + _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds)); + } + } + + idx++; + } + + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(firstIndex, true); + foreach (var selectedIndex in selectedIndices) + { + SubtitleListview1.Items[selectedIndex].Selected = true; + } + RestartHistory(); + } + } + else if (SubtitleListview1.Items.Count > 0 && list.Count >= 1 && list.Count < 4 && !text.Trim().Contains(Environment.NewLine + Environment.NewLine)) + { + // less than 4 lines of text, just insert into first selected + textBoxListViewText.Text = text.Trim(); + } + else if (list.Count >= 1 && list.Count < 2000) + { + MakeHistoryForUndo(_language.BeforeInsertLine); + _makeHistoryPaused = true; + SubtitleListview1.BeginUpdate(); + foreach (var line in list) + { + if (!string.IsNullOrWhiteSpace(line)) + { + var s = line.Trim().Length > Configuration.Settings.General.SubtitleLineMaximumLength ? Utilities.AutoBreakLine(line) : line.Trim(); + InsertAfter(s); + } + } + SubtitleListview1.EndUpdate(); + RestartHistory(); + } + + if (_subtitleListViewIndex >= 0) + { + UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, _subtitle.Paragraphs[_subtitleListViewIndex], textBoxListViewText); + } + else + { + SubtitleListview1.SelectIndexAndEnsureVisible(0); + } + } + else if (Clipboard.ContainsFileDropList()) + { + var fileDropList = Clipboard.GetFileDropList(); + if (fileDropList.Count == 1) + { + ShowStatus(Configuration.Settings.Language.General.PleaseWait, false); + OpenSubtitle(fileDropList[0], null); + } + } + + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.X && e.Modifiers == Keys.Control) //Ctrl+X = Cut to clipboard + { + var tmp = new Subtitle(); + foreach (int i in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.GetParagraphOrDefault(i); + if (p != null) + { + tmp.Paragraphs.Add(new Paragraph(p)); + } + } + + e.SuppressKeyPress = true; + _cutText = tmp.ToText(new SubRip()); + ToolStripMenuItemDeleteClick(null, null); + } + else if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) + { + SubtitleListview1.SelectAll(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.D && e.Modifiers == Keys.Control) + { + SubtitleListview1.SelectFirstSelectedItemOnly(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.Delete && SubtitleListview1.SelectedItems.Count > 0) //Delete + { + ToolStripMenuItemDeleteClick(null, null); + } + else if (e.KeyData == _shortcuts.MainInsertBefore) + { + InsertBefore(); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainInsertAfter) + { + InsertAfter(string.Empty); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Home) + { + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.End) + { + SubtitleListview1.SelectIndexAndEnsureVisible(SubtitleListview1.Items.Count - 1, true); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Enter) + { + SubtitleListview1_MouseDoubleClick(null, null); + } + } + + private void RemoveTimeCodesFromSelectedLines() + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.RemoveTimeCodes)); + + var indices = new List(); + foreach (ListViewItem item in SubtitleListview1.SelectedItems) + { + indices.Add(item.Index); + } + foreach (int i in indices) + { + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) + { + var original = Utilities.GetOriginalParagraph(i, _subtitle.Paragraphs[i], _subtitleAlternate.Paragraphs); + if (original != null) + { + original.StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + original.EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + } + } + _subtitle.Paragraphs[i].StartTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + _subtitle.Paragraphs[i].EndTime.TotalMilliseconds = TimeCode.MaxTimeTotalMilliseconds; + } + + SaveSubtitleListviewIndices(); + _subtitleListViewIndex = -1; + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + ShowSource(); + RestoreSubtitleListviewIndices(); + } + + private void SetAlignment(string tag, bool selectedLines) + { + if (selectedLines) + { + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + MakeHistoryForUndo(string.Format(_language.BeforeAddingTagX, tag)); + + var indices = new List(); + foreach (ListViewItem item in SubtitleListview1.SelectedItems) + { + indices.Add(item.Index); + } + + bool first = true; + SubtitleListview1.BeginUpdate(); + foreach (int i in indices) + { + if (first) + { + if (_subtitle.Paragraphs[i].Text.StartsWith(tag, StringComparison.Ordinal)) + { + tag = string.Empty; + } + + if (_subtitle.Paragraphs[i].Text.StartsWith(tag.Replace("}", "\\"), StringComparison.Ordinal)) + { + tag = string.Empty; + } + + first = false; + } + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) + { + var original = Utilities.GetOriginalParagraph(i, _subtitle.Paragraphs[i], _subtitleAlternate.Paragraphs); + if (original != null) + { + original.Text = SetAlignTag(original.Text, tag); + SubtitleListview1.SetAlternateText(i, original.Text); + } + } + + _subtitle.Paragraphs[i].Text = SetAlignTag(_subtitle.Paragraphs[i].Text, tag); + SubtitleListview1.SetText(i, _subtitle.Paragraphs[i].Text); + } + + SubtitleListview1.EndUpdate(); + + ShowStatus(string.Format(_language.TagXAdded, tag)); + ShowSource(); + RefreshSelectedParagraph(); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + } + else + { + var tb = GetFocusedTextBox(); + var pos = tb.SelectionStart; + int oldLength = tb.Text.Length; + bool atEnd = pos == oldLength; + tb.Text = SetAlignTag(tb.Text, tag); + if (atEnd) + { + tb.SelectionStart = tb.Text.Length; + } + else if (pos == 0) + { + tb.SelectionStart = 0; + } + else if (oldLength == tb.Text.Length) + { + tb.SelectionStart = pos; + } + else if (pos + 5 <= tb.Text.Length) + { + tb.SelectionStart = pos + 5; + } + } + } + + private void GoToNextSyntaxError() + { + int idx = FirstSelectedIndex + 1; + try + { + for (int i = idx; i < _subtitle.Paragraphs.Count; i++) + { + var item = SubtitleListview1.Items[i]; + if (item.SubItems[SubtitleListview1.ColumnIndexDuration].BackColor == Configuration.Settings.Tools.ListViewSyntaxErrorColor || + item.SubItems[SubtitleListview1.ColumnIndexText].BackColor == Configuration.Settings.Tools.ListViewSyntaxErrorColor || + item.SubItems[SubtitleListview1.ColumnIndexStart].BackColor == Configuration.Settings.Tools.ListViewSyntaxErrorColor || + (SubtitleListview1.ColumnIndexCps >= 0 && item.SubItems[SubtitleListview1.ColumnIndexCps].BackColor == Configuration.Settings.Tools.ListViewSyntaxErrorColor) || + (SubtitleListview1.ColumnIndexWpm >= 0 && item.SubItems[SubtitleListview1.ColumnIndexWpm].BackColor == Configuration.Settings.Tools.ListViewSyntaxErrorColor) || + (SubtitleListview1.ColumnIndexGap >= 0 && item.SubItems[SubtitleListview1.ColumnIndexGap].BackColor == Configuration.Settings.Tools.ListViewSyntaxErrorColor)) + { + SubtitleListview1.SelectIndexAndEnsureVisible(i, true); + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.VideoPlayer.CurrentPosition = _subtitle.Paragraphs[i].StartTime.TotalSeconds; + } + + return; + } + } + } + catch + { + } + } + + private void RestartHistory() + { + _listViewTextUndoLast = null; + _listViewTextUndoIndex = -1; + _listViewTextTicks = -1; + _listViewAlternateTextUndoLast = null; + _listViewAlternateTextTicks = -1; + _undoIndex = _subtitle.HistoryItems.Count - 1; + _makeHistoryPaused = false; + } + + private void AdjustDisplayTimeForSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) + { + AdjustDisplayTime(true); + } + + private void FixCommonErrorsInSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) + { + FixCommonErrors(true); + } + + private void FindDoubleWordsToolStripMenuItemClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + var regex = new Regex(@"\b(\w+)\s+\1\b"); + _clearLastFind = true; + if (_findHelper != null) + { + _clearLastFindType = _findHelper.FindReplaceType.FindType; + _clearLastFindText = _findHelper.FindText; + } + + _findHelper = new FindReplaceDialogHelper(new ReplaceType { FindType = FindType.RegEx }, string.Format(_language.DoubleWordsViaRegEx, regex), regex, string.Empty, _subtitleListViewIndex); + + ReloadFromSourceView(); + FindNext(); + } + + private void ChangeCasingForSelectedLinesToolStripMenuItemClick(object sender, EventArgs e) + { + ChangeCasing(true); + } + + private void CenterFormOnCurrentScreen() + { + var screen = Screen.FromControl(this); + Left = screen.Bounds.X + ((screen.Bounds.Width - Width) / 2); + Top = screen.Bounds.Y + ((screen.Bounds.Height - Height) / 2); + } + + private void SortSubtitle(SubtitleSortCriteria subtitleSortCriteria, string description) + { + var firstSelectedIndex = 0; + if (SubtitleListview1.SelectedItems.Count > 0) + { + firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + } + + _subtitleListViewIndex = -1; + MakeHistoryForUndo(string.Format(_language.BeforeSortX, description)); + _subtitle.Sort(subtitleSortCriteria); + if (descendingToolStripMenuItem.Checked) + { + _subtitle.Paragraphs.Reverse(); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); + ShowStatus(string.Format(_language.SortedByX, description)); + } + + private void SortNumberToolStripMenuItemClick(object sender, EventArgs e) + { + SortSubtitle(SubtitleSortCriteria.Number, (sender as ToolStripItem).Text); + } + + private void SortStartTimeToolStripMenuItemClick(object sender, EventArgs e) + { + SortSubtitle(SubtitleSortCriteria.StartTime, (sender as ToolStripItem).Text); + } + + private void SortEndTimeToolStripMenuItemClick(object sender, EventArgs e) + { + SortSubtitle(SubtitleSortCriteria.EndTime, (sender as ToolStripItem).Text); + } + + private void SortDisplayTimeToolStripMenuItemClick(object sender, EventArgs e) + { + SortSubtitle(SubtitleSortCriteria.Duration, (sender as ToolStripItem).Text); + } + + private void SortTextMaxLineLengthToolStripMenuItemClick(object sender, EventArgs e) + { + SortSubtitle(SubtitleSortCriteria.TextMaxLineLength, (sender as ToolStripItem).Text); + } + + private void SortTextTotalLengthToolStripMenuItemClick(object sender, EventArgs e) + { + SortSubtitle(SubtitleSortCriteria.TextTotalLength, (sender as ToolStripItem).Text); + } + + private void SortTextNumberOfLinesToolStripMenuItemClick(object sender, EventArgs e) + { + SortSubtitle(SubtitleSortCriteria.TextNumberOfLines, (sender as ToolStripItem).Text); + } + + private void SortTextAlphabeticallytoolStripMenuItemClick(object sender, EventArgs e) + { + SortSubtitle(SubtitleSortCriteria.Text, (sender as ToolStripItem).Text); + } + + private void textCharssecToolStripMenuItem_Click(object sender, EventArgs e) + { + SortSubtitle(SubtitleSortCriteria.TextCharactersPerSeconds, (sender as ToolStripItem).Text); + } + + private void ChangeLanguageToolStripMenuItemClick(object sender, EventArgs e) + { + using (var cl = new ChooseLanguage()) + { + if (cl.ShowDialog(this) == DialogResult.OK) + { + SetLanguage(cl.CultureName); + Configuration.Settings.Save(); + } + } + } + + private void SetLanguage(string cultureName) + { + if (string.IsNullOrEmpty(cultureName)) + { + cultureName = "en-US"; + } + + if (cultureName != "en-US") + { + try + { + Configuration.Settings.Language = Language.Load(Path.Combine(Configuration.BaseDirectory, "Languages", cultureName + ".xml")); + } + catch (Exception ex) + { + var cap = "Language file load error"; + var msg = "Could not load language file " + cultureName + ".xml" + + "\n\nError Message:\n" + ex.Message + + "\n\nStack Trace:\n" + ex.StackTrace; + MessageBox.Show(this, msg, cap); + cultureName = "en-US"; + } + } + + if (cultureName == "en-US") + { + Configuration.Settings.Language = new Language(); // default is en-US + } + + Configuration.Settings.General.Language = cultureName; + _languageGeneral = Configuration.Settings.Language.General; + _language = Configuration.Settings.Language.Main; + InitializeLanguage(); + } + + private void ToolStripMenuItemCompareClick(object sender, EventArgs e) + { + var compareForm = new Compare(); + if (_subtitleAlternate != null && _subtitleAlternateFileName != null && SubtitleListview1.IsAlternateTextColumnVisible) + { + compareForm.Initialize(_subtitle, _fileName, _subtitleAlternate, _subtitleAlternateFileName); + } + else + { + compareForm.Initialize(_subtitle, _fileName, _languageGeneral.CurrentSubtitle); + } + + compareForm.Show(this); + compareForm.Activate(); + } + + private void ToolStripMenuItemAutoBreakLinesClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + using (var autoBreakUnbreakLines = new AutoBreakUnbreakLines()) + { + var selectedLines = new Subtitle(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]); + } + + autoBreakUnbreakLines.Initialize(selectedLines, true); + + if (autoBreakUnbreakLines.ShowDialog() == DialogResult.OK && autoBreakUnbreakLines.FixedText.Count > 0) + { + MakeHistoryForUndo(_language.BeforeAutoBalanceSelectedLines); + SubtitleListview1.BeginUpdate(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.GetParagraphOrDefault(index); + if (autoBreakUnbreakLines.FixedText.ContainsKey(p.Id)) + { + p.Text = autoBreakUnbreakLines.FixedText[p.Id]; + SubtitleListview1.SetText(index, p.Text); + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, p); + } + } + + SubtitleListview1.EndUpdate(); + RefreshSelectedParagraph(); + ShowStatus(string.Format(_language.NumberOfLinesAutoBalancedX, autoBreakUnbreakLines.FixedText.Count)); + } + } + } + + private void ToolStripMenuItemUnbreakLinesClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + using (var autoBreakUnbreakLines = new AutoBreakUnbreakLines()) + { + var selectedLines = new Subtitle(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]); + } + + autoBreakUnbreakLines.Initialize(selectedLines, false); + + if (autoBreakUnbreakLines.ShowDialog() == DialogResult.OK && autoBreakUnbreakLines.FixedText.Count > 0) + { + MakeHistoryForUndo(_language.BeforeRemoveLineBreaksInSelectedLines); + + SubtitleListview1.BeginUpdate(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.GetParagraphOrDefault(index); + if (autoBreakUnbreakLines.FixedText.ContainsKey(p.Id)) + { + p.Text = autoBreakUnbreakLines.FixedText[p.Id]; + SubtitleListview1.SetText(index, p.Text); + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, p); + } + } + + SubtitleListview1.EndUpdate(); + RefreshSelectedParagraph(); + ShowStatus(string.Format(_language.NumberOfWithRemovedLineBreakX, autoBreakUnbreakLines.FixedText.Count)); + } + } + } + + private void MultipleReplaceToolStripMenuItemClick(object sender, EventArgs e) + { + using (var multipleReplace = new MultipleReplace()) + { + multipleReplace.Initialize(_subtitle); + if (multipleReplace.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeMultipleReplace); + SaveSubtitleListviewIndices(); + + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + _subtitle.Paragraphs[i].Text = multipleReplace.FixedSubtitle.Paragraphs[i].Text; + } + + _subtitle.RemoveParagraphsByIndices(multipleReplace.DeleteIndices); + _subtitle.Renumber(); + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + RefreshSelectedParagraph(); + ShowSource(); + ShowStatus(string.Format(_language.NumberOfLinesReplacedX, multipleReplace.FixCount)); + } + } + } + + private void ToolStripMenuItemImportDvdSubtitlesClick(object sender, EventArgs e) + { + if (!ContinueNewOrExit()) + { + return; + } + + ImportDvdSubtitle(null); + } + + private void ImportDvdSubtitle(string fileName) + { + using (var formSubRip = new DvdSubRip(Handle, fileName)) + { + if (formSubRip.ShowDialog(this) == DialogResult.OK) + { + using (var showSubtitles = new DvdSubRipChooseLanguage()) + { + showSubtitles.Initialize(formSubRip.MergedVobSubPacks, formSubRip.Palette, formSubRip.Languages, formSubRip.SelectedLanguage); + if (formSubRip.Languages.Count == 1 || showSubtitles.ShowDialog(this) == DialogResult.OK) + { + using (var formSubOcr = new VobSubOcr()) + { + var subs = formSubRip.MergedVobSubPacks; + if (showSubtitles.SelectedVobSubMergedPacks != null) + { + subs = showSubtitles.SelectedVobSubMergedPacks; + } + + formSubOcr.Initialize(subs, formSubRip.Palette, Configuration.Settings.VobSubOcr, formSubRip.SelectedLanguage); + if (formSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportingDvdSubtitle); + FileNew(); + _subtitle.Paragraphs.Clear(); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + foreach (var p in formSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = string.Empty; + SetTitle(); + + Configuration.Settings.Save(); + } + } + } + } + } + } + } + + private void ToolStripMenuItemSubIdxClick1(object sender, EventArgs e) + { + if (ContinueNewOrExit()) + { + openFileDialog1.Title = _language.OpenVobSubFile; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = _language.VobSubFiles + "|*.sub"; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + ImportAndOcrVobSubSubtitleNew(openFileDialog1.FileName, false); + openFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName); + } + } + } + + private void SubtitleListview1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (Configuration.Settings.General.ListViewDoubleClickAction == 1) + { + GotoSubPositionAndPause(); + } + else if (Configuration.Settings.General.ListViewDoubleClickAction == 2) + { + if (AutoRepeatContinueOn || AutoRepeatOn) + { + PlayCurrent(); + } + else + { + buttonBeforeText_Click(null, null); + } + } + else if (Configuration.Settings.General.ListViewDoubleClickAction == 3) + { + GotoSubPositionAndPause(-0.5); + } + else if (Configuration.Settings.General.ListViewDoubleClickAction == 4) + { + GotoSubPositionAndPause(-1.0); + } + else if (Configuration.Settings.General.ListViewDoubleClickAction == 5) + { + if (AutoRepeatContinueOn || AutoRepeatOn) + { + PlayCurrent(); + } + else + { + if (SubtitleListview1.SelectedItems.Count > 0) + { + int index = SubtitleListview1.SelectedItems[0].Index; + + mediaPlayer.Pause(); + double pos = _subtitle.Paragraphs[index].StartTime.TotalSeconds; + if (pos > 1) + { + mediaPlayer.CurrentPosition = (_subtitle.Paragraphs[index].StartTime.TotalSeconds) - 1.0; + } + else + { + mediaPlayer.CurrentPosition = _subtitle.Paragraphs[index].StartTime.TotalSeconds; + } + + mediaPlayer.Play(); + } + } + } + else if (Configuration.Settings.General.ListViewDoubleClickAction == 6) + { + GotoSubPositionAndPause(); + textBoxListViewText.Focus(); + } + else if (Configuration.Settings.General.ListViewDoubleClickAction == 7) + { + textBoxListViewText.Focus(); + } + } + + private void AddWordToNameListToolStripMenuItemClick(object sender, EventArgs e) + { + using (var addToNamesList = new AddToNameList()) + { + addToNamesList.Initialize(_subtitle, textBoxListViewText.SelectedText); + if (addToNamesList.ShowDialog(this) == DialogResult.OK) + { + ShowStatus(string.Format(_language.NameXAddedToNameList, addToNamesList.NewName)); + } + else if (!string.IsNullOrEmpty(addToNamesList.NewName)) + { + ShowStatus(string.Format(_language.NameXNotAddedToNameList, addToNamesList.NewName)); + } + } + } + + private bool IsUnicode + { + get + { + var enc = GetCurrentEncoding(); + return enc == Encoding.UTF8 || enc == Encoding.Unicode || enc == Encoding.UTF7 || enc == Encoding.UTF32 || enc == Encoding.BigEndianUnicode; + } + } + + private void EditToolStripMenuItemDropDownOpening(object sender, EventArgs e) + { + toolStripMenuItemRemoveUnicodeControlChars.Visible = IsUnicode; + toolStripMenuItemRtlUnicodeControlChars.Visible = IsUnicode; + if (!IsUnicode || _subtitleListViewIndex == -1) + { + toolStripMenuItemInsertUnicodeCharacter.Visible = false; + toolStripSeparatorInsertUnicodeCharacter.Visible = false; + } + else + { + if (toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Count == 0) + { + foreach (var s in Configuration.Settings.Tools.UnicodeSymbolsToInsert.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) + { + toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Add(s, null, InsertUnicodeGlyphAllowMultiLine); + if (Environment.OSVersion.Version.Major < 6 && Configuration.Settings.General.SubtitleFontName == Utilities.WinXP2KUnicodeFontName) // 6 == Vista/Win2008Server/Win7 + { + toolStripMenuItemInsertUnicodeCharacter.DropDownItems[toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Count - 1].Font = new Font(Utilities.WinXP2KUnicodeFontName, toolStripMenuItemInsertUnicodeSymbol.Font.Size); + } + } + } + + toolStripMenuItemInsertUnicodeCharacter.Visible = toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Count > 0; + toolStripSeparatorInsertUnicodeCharacter.Visible = toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Count > 0; + } + + lock (_syncUndo) + { + toolStripMenuItemUndo.Enabled = _subtitle != null && _subtitle.CanUndo && _undoIndex >= 0; + toolStripMenuItemRedo.Enabled = _subtitle != null && _subtitle.CanUndo && _undoIndex < _subtitle.HistoryItems.Count - 1; + } + + showHistoryforUndoToolStripMenuItem.Enabled = _subtitle != null && _subtitle.CanUndo; + toolStripMenuItemShowOriginalInPreview.Visible = SubtitleListview1.IsAlternateTextColumnVisible; + + if (_networkSession != null) + { + toolStripMenuItemUndo.Enabled = false; + toolStripMenuItemRedo.Enabled = false; + showHistoryforUndoToolStripMenuItem.Enabled = false; + } + } + + private void InsertUnicodeGlyph(object sender, EventArgs e) + { + if (sender is ToolStripItem item) + { + PasteIntoActiveTextBox(item.Text); + } + } + + private void InsertUnicodeGlyphAllowMultiLine(object sender, EventArgs e) + { + if (sender is ToolStripItem item) + { + PasteIntoActiveTextBox(item.Text, true); + } + } + + private void ToolStripMenuItemAutoMergeShortLinesClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + using (var formMergeShortLines = new MergeShortLines()) + { + formMergeShortLines.Initialize(_subtitle); + if (formMergeShortLines.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeMergeShortLines); + _subtitle.Paragraphs.Clear(); + foreach (var p in formMergeShortLines.MergedSubtitle.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + _subtitle.Renumber(); + + ShowStatus(string.Format(_language.MergedShortLinesX, formMergeShortLines.NumberOfMerges)); + SaveSubtitleListviewIndices(); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + } + + private void toolStripMenuItemAutoSplitLongLines_Click(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + using (var splitLongLines = new SplitLongLines()) + { + splitLongLines.Initialize(_subtitle); + if (splitLongLines.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeSplitLongLines); + _subtitle.Paragraphs.Clear(); + foreach (var p in splitLongLines.SplitSubtitle.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowStatus(string.Format(_language.LongLinesSplitX, splitLongLines.NumberOfSplits)); + SaveSubtitleListviewIndices(); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + } + + private void SetMinimalDisplayTimeDifferenceToolStripMenuItemClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + using (var setMinDisplayDiff = new SetMinimumDisplayTimeBetweenParagraphs()) + { + setMinDisplayDiff.Initialize(_subtitle); + if (setMinDisplayDiff.ShowDialog() == DialogResult.OK && setMinDisplayDiff.FixCount > 0) + { + MakeHistoryForUndo(_language.BeforeSetMinimumDisplayTimeBetweenParagraphs); + _subtitle.Paragraphs.Clear(); + foreach (var p in setMinDisplayDiff.FixedSubtitle.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowStatus(string.Format(_language.XMinimumDisplayTimeBetweenParagraphsChanged, setMinDisplayDiff.FixCount)); + SaveSubtitleListviewIndices(); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + } + + private void ToolStripMenuItemImportTextClick(object sender, EventArgs e) + { + ImportPlainText(null); + } + + private void ImportPlainText(string fileName) + { + using (var importText = new ImportText(fileName, this)) + { + if (importText.ShowDialog(this) == DialogResult.OK) + { + if (ContinueNewOrExit()) + { + MakeHistoryForUndo(_language.BeforeImportText); + + ResetSubtitle(); + if (!string.IsNullOrEmpty(importText.VideoFileName)) + { + if (!Configuration.Settings.General.DisableVideoAutoLoading) + { + OpenVideo(importText.VideoFileName); + } + + _fileName = importText.VideoFileName; + _converted = true; + SetTitle(); + } + + _subtitleListViewIndex = -1; + if (importText.Format != null) + { + SetCurrentFormat(importText.Format); + } + + _subtitle = new Subtitle(importText.FixedSubtitle.Paragraphs, _subtitle.HistoryItems); + ShowStatus(_language.TextImported); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + } + } + } + } + + private void toolStripMenuItemPointSync_Click(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + using (var pointSync = new SyncPointsSync()) + { + pointSync.Initialize(_subtitle, _fileName, VideoFileName, VideoAudioTrackNumber); + mediaPlayer.Pause(); + if (pointSync.ShowDialog(this) == DialogResult.OK) + { + _subtitleListViewIndex = -1; + MakeHistoryForUndo(_language.BeforePointSynchronization); + _subtitle.Paragraphs.Clear(); + foreach (var p in pointSync.FixedSubtitle.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + ShowStatus(_language.PointSynchronizationDone); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + Activate(); + VideoFileName = pointSync.VideoFileName; + } + } + + private void pointSyncViaOtherSubtitleToolStripMenuItem_Click(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + using (var pointSync = new SyncPointsSync()) + { + openFileDialog1.Title = _language.OpenOtherSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + if (openFileDialog1.ShowDialog() == DialogResult.OK && File.Exists(openFileDialog1.FileName)) + { + var file = new FileInfo(openFileDialog1.FileName); + var fileName = file.FullName; + var extension = file.Extension.ToLowerInvariant(); + + // TODO: Check for mkv etc + if (extension == ".sub") + { + if (IsVobSubFile(fileName, false)) + { + MessageBox.Show(_language.NoSupportHereVobSub); + return; + } + } + + if (extension == ".sup") + { + if (FileUtil.IsBluRaySup(fileName)) + { + MessageBox.Show(_language.NoSupportHereBluRaySup); + return; + } + else if (FileUtil.IsSpDvdSup(fileName)) + { + MessageBox.Show(_language.NoSupportHereDvdSup); + return; + } + } + + var sub = new Subtitle(); + if (extension == ".mkv" || extension == ".mks") + { + using (var matroska = new MatroskaFile(fileName)) + { + if (matroska.IsValid) + { + var subtitleList = matroska.GetTracks(true); + if (subtitleList.Count > 1) + { + using (var subtitleChooser = new MatroskaSubtitleChooser("mkv")) + { + subtitleChooser.Initialize(subtitleList); + if (_loading) + { + subtitleChooser.Icon = (Icon)Icon.Clone(); + subtitleChooser.ShowInTaskbar = true; + subtitleChooser.ShowIcon = true; + } + + if (subtitleChooser.ShowDialog(this) == DialogResult.OK) + { + sub = LoadMatroskaSubtitleForSync(subtitleList[subtitleChooser.SelectedIndex], matroska); + } + } + } + else if (subtitleList.Count > 0) + { + sub = LoadMatroskaSubtitleForSync(subtitleList[0], matroska); + } + else + { + MessageBox.Show(_language.NoSubtitlesFound); + return; + } + } + } + } + + if (extension == ".divx" || extension == ".avi") + { + MessageBox.Show(_language.NoSupportHereDivx); + return; + } + + if ((extension == ".mp4" || extension == ".m4v" || extension == ".3gp") && file.Length > 10000) + { + var mp4Parser = new MP4Parser(fileName); + var mp4SubtitleTracks = mp4Parser.GetSubtitleTracks(); + if (mp4SubtitleTracks.Count == 0) + { + MessageBox.Show(_language.NoSubtitlesFound); + return; + } + else if (mp4SubtitleTracks.Count == 1) + { + sub = LoadMp4SubtitleForSync(mp4SubtitleTracks[0]); + } + else + { + using (var subtitleChooser = new MatroskaSubtitleChooser("mp4")) + { + subtitleChooser.Initialize(mp4SubtitleTracks); + if (subtitleChooser.ShowDialog(this) == DialogResult.OK) + { + sub = LoadMp4SubtitleForSync(mp4SubtitleTracks[0]); + } + } + } + } + + if (file.Length > 1024 * 1024 * 10 && sub.Paragraphs.Count == 0) // max 10 mb + { + var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, fileName); + if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return; + } + } + + sub.Renumber(); + if (sub.Paragraphs.Count == 0) + { + var f = sub.LoadSubtitle(fileName, out var enc, null); + if (f == null) + { + ShowUnknownSubtitle(fileName); + return; + } + } + + pointSync.Initialize(_subtitle, _fileName, VideoFileName, VideoAudioTrackNumber, fileName, sub); + mediaPlayer.Pause(); + if (pointSync.ShowDialog(this) == DialogResult.OK) + { + _subtitleListViewIndex = -1; + MakeHistoryForUndo(_language.BeforePointSynchronization); + _subtitle.Paragraphs.Clear(); + foreach (var p in pointSync.FixedSubtitle.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + ShowStatus(_language.PointSynchronizationDone); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + VideoFileName = pointSync.VideoFileName; + } + } + } + + private void toolStripMenuItemImportTimeCodes_Click(object sender, EventArgs e) + { + if (_subtitle.Paragraphs.Count < 1) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + openFileDialog1.Title = _languageGeneral.OpenSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + var timeCodeSubtitle = new Subtitle(); + SubtitleFormat format = null; + + if (format == null && + openFileDialog1.FileName.EndsWith(".sup", StringComparison.OrdinalIgnoreCase) && + FileUtil.IsBluRaySup(openFileDialog1.FileName)) + { + var log = new StringBuilder(); + var subtitles = BluRaySupParser.ParseBluRaySup(openFileDialog1.FileName, log); + if (subtitles.Count > 0) + { + foreach (var sup in subtitles) + { + timeCodeSubtitle.Paragraphs.Add(new Paragraph(sup.StartTimeCode, sup.EndTimeCode, string.Empty)); + } + + format = new SubRip(); // just to set format to something + } + } + + if (format == null) + { + format = timeCodeSubtitle.LoadSubtitle(openFileDialog1.FileName, out var encoding, null); + } + + if (format == null) + { + var formats = SubtitleFormat.GetBinaryFormats(true).Union(SubtitleFormat.GetTextOtherFormats()).Union(new SubtitleFormat[] + { + new TimeCodesOnly1(), + new TimeCodesOnly2() + }).ToArray(); + format = SubtitleFormat.LoadSubtitleFromFile(formats, openFileDialog1.FileName, timeCodeSubtitle); + } + + if (format == null) + { + ShowUnknownSubtitle(openFileDialog1.FileName); + return; + } + + if (timeCodeSubtitle.Paragraphs.Count != _subtitle.Paragraphs.Count) + { + var text = string.Format(_language.ImportTimeCodesDifferentNumberOfLinesWarning, timeCodeSubtitle.Paragraphs.Count, _subtitle.Paragraphs.Count); + if (MessageBox.Show(this, text, _title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return; + } + } + + MakeHistoryForUndo(_language.BeforeTimeCodeImport); + + int count = 0; + for (int i = 0; i < timeCodeSubtitle.Paragraphs.Count; i++) + { + var existing = _subtitle.GetParagraphOrDefault(i); + + var newTimeCode = timeCodeSubtitle.GetParagraphOrDefault(i); + if (existing == null || newTimeCode == null) + { + break; + } + + Paragraph original = null; + if (existing != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && + _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0 && SubtitleListview1.IsAlternateTextColumnVisible) + { + original = Utilities.GetOriginalParagraph(i, existing, _subtitleAlternate.Paragraphs); + } + + existing.StartTime.TotalMilliseconds = newTimeCode.StartTime.TotalMilliseconds; + existing.EndTime.TotalMilliseconds = newTimeCode.EndTime.TotalMilliseconds; + + if (original != null) + { + original.StartTime.TotalMilliseconds = newTimeCode.StartTime.TotalMilliseconds; + original.EndTime.TotalMilliseconds = newTimeCode.EndTime.TotalMilliseconds; + } + + count++; + } + + ShowStatus(string.Format(_language.TimeCodeImportedFromXY, Path.GetFileName(openFileDialog1.FileName), count)); + SaveSubtitleListviewIndices(); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + + private void toolStripMenuItemTranslationMode_Click(object sender, EventArgs e) + { + if (_subtitle == null || _subtitle.Paragraphs.Count == 0) + { + return; + } + + if (SubtitleListview1.IsAlternateTextColumnVisible) + { + RemoveAlternate(true, true); + } + else + { + OpenAlternateSubtitle(); + SetTitle(); + } + } + + private void OpenAlternateSubtitle() + { + if (ContinueNewOrExitAlternate()) + { + SaveSubtitleListviewIndices(); + openFileDialog1.Title = _languageGeneral.OpenOriginalSubtitleFile; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + if (openFileDialog1.ShowDialog(this) != DialogResult.OK) + { + return; + } + + if (!LoadAlternateSubtitleFile(openFileDialog1.FileName)) + { + return; + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + + Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + Configuration.Settings.Save(); + UpdateRecentFilesUI(); + MainResize(); + if (SubtitleListview1.SelectedIndices.Count == 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + } + RefreshSelectedParagraph(); + } + } + + private bool LoadAlternateSubtitleFile(string fileName) + { + if (!File.Exists(fileName)) + { + return false; + } + + var file = new FileInfo(fileName); + + if (file.Extension.Equals(".sub", StringComparison.OrdinalIgnoreCase) && IsVobSubFile(fileName, false)) + { + return false; + } + + if (file.Length > 1024 * 1024 * 10) // max 10 mb + { + var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, fileName); + if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return false; + } + } + + _subtitleAlternate = new Subtitle(); + _subtitleAlternateFileName = fileName; + SubtitleFormat format = _subtitleAlternate.LoadSubtitle(fileName, out _, null); + + if (format == null) + { + foreach (var binaryFormat in SubtitleFormat.GetBinaryFormats(false)) + { + if (binaryFormat.IsMine(null, fileName)) + { + binaryFormat.LoadSubtitle(_subtitleAlternate, null, fileName); + format = binaryFormat; + break; + } + } + } + + if (format == null) + { + var lines = FileUtil.ReadAllTextShared(fileName, LanguageAutoDetect.GetEncodingFromFile(fileName)).SplitToLines(); + foreach (var f in SubtitleFormat.GetTextOtherFormats()) + { + if (f.IsMine(lines, fileName)) + { + f.LoadSubtitle(_subtitleAlternate, lines, fileName); + format = f; + break; + } + } + } + + if (format == null) + { + return false; + } + + SetupAlternateEdit(); + FixRightToLeftDependingOnLanguage(); + return true; + } + + private void SetupAlternateEdit() + { + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate.Paragraphs.Count > 0) + { + InsertMissingParagraphs(_subtitle, _subtitleAlternate); + InsertMissingParagraphs(_subtitleAlternate, _subtitle); + + buttonUnBreak.Visible = false; + buttonAutoBreak.Visible = false; + buttonSplitLine.Visible = false; + + textBoxListViewText.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; + textBoxListViewText.Width = (groupBoxEdit.Width - (textBoxListViewText.Left + 10)) / 2; + textBoxListViewTextAlternate.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; + textBoxListViewTextAlternate.Left = textBoxListViewText.Left + textBoxListViewText.Width + 3; + textBoxListViewTextAlternate.Width = textBoxListViewText.Width; + textBoxListViewTextAlternate.Visible = true; + labelAlternateText.Text = _languageGeneral.OriginalText; + labelAlternateText.Visible = true; + labelAlternateCharactersPerSecond.Visible = true; + labelTextAlternateLineLengths.Visible = true; + labelAlternateSingleLine.Visible = true; + labelAlternateSingleLinePixels.Visible = true; + labelTextAlternateLineTotal.Visible = true; + + labelCharactersPerSecond.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelCharactersPerSecond.Width); + labelTextLineTotal.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelTextLineTotal.Width); + Main_Resize(null, null); + _changeAlternateSubtitleHash = _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName); + + SetTitle(); + } + + SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); + SubtitleListview1.AutoSizeAllColumns(this); + } + + private static void InsertMissingParagraphs(Subtitle masterSubtitle, Subtitle insertIntoSubtitle) + { + int index = 0; + foreach (var p in masterSubtitle.Paragraphs) + { + var insertParagraph = Utilities.GetOriginalParagraph(index, p, insertIntoSubtitle.Paragraphs); + if (insertParagraph == null) + { + insertParagraph = new Paragraph(p); + insertParagraph.Text = string.Empty; + if (p.StartTime.IsMaxTime) + { + insertIntoSubtitle.Paragraphs.Add(new Paragraph(p, true) { Text = string.Empty }); + } + else + { + insertIntoSubtitle.InsertParagraphInCorrectTimeOrder(insertParagraph); + } + } + + index++; + } + + insertIntoSubtitle.Renumber(); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + private void OpenVideo(string fileName) + { + if (!_resetVideo) + { + return; + } + + if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) + { + if (_loading) + { + VideoFileName = fileName; + return; + } + + var fi = new FileInfo(fileName); + if (fi.Length < 1000) + { + return; + } + + ShowSubtitleTimer.Stop(); + Cursor = Cursors.WaitCursor; + VideoFileName = fileName; + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.PauseAndDisposePlayer(); + } + + _endSeconds = -1; + + _videoInfo = UiUtil.GetVideoInfo(fileName); + if (_videoInfo.FramesPerSecond > 0) + { + toolStripComboBoxFrameRate.Text = string.Format("{0:0.###}", _videoInfo.FramesPerSecond); + } + + string oldVideoPlayer = Configuration.Settings.General.VideoPlayer; + var ok = UiUtil.InitializeVideoPlayerAndContainer(fileName, _videoInfo, mediaPlayer, VideoLoaded, VideoEnded); + if (!ok && oldVideoPlayer != Configuration.Settings.General.VideoPlayer) + { + CloseVideoToolStripMenuItemClick(null, null); + VideoFileName = fileName; + _videoInfo = UiUtil.GetVideoInfo(fileName); + UiUtil.InitializeVideoPlayerAndContainer(fileName, _videoInfo, mediaPlayer, VideoLoaded, VideoEnded); + } + + mediaPlayer.Volume = 0; + mediaPlayer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton; + mediaPlayer.OnButtonClicked -= MediaPlayer_OnButtonClicked; + mediaPlayer.OnButtonClicked += MediaPlayer_OnButtonClicked; + + if (_videoInfo.VideoCodec != null) + { + labelVideoInfo.Text = Path.GetFileName(fileName) + " " + _videoInfo.Width + "x" + _videoInfo.Height + " " + _videoInfo.VideoCodec.Trim(); + } + else + { + labelVideoInfo.Text = Path.GetFileName(fileName) + " " + _videoInfo.Width + "x" + _videoInfo.Height; + } + + if (_videoInfo.FramesPerSecond > 0) + { + labelVideoInfo.Text = labelVideoInfo.Text + " " + string.Format("{0:0.0##}", _videoInfo.FramesPerSecond); + } + + + string peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(fileName); + string spectrogramFolder = WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(fileName); + if (File.Exists(peakWaveFileName)) + { + audioVisualizer.ZoomFactor = 1.0; + audioVisualizer.VerticalZoomFactor = 1.0; + SelectZoomTextInComboBox(); + audioVisualizer.WavePeaks = WavePeakData.FromDisk(peakWaveFileName); + audioVisualizer.SetSpectrogram(SpectrogramData.FromDisk(spectrogramFolder)); + audioVisualizer.SceneChanges = SceneChangeHelper.FromDisk(VideoFileName); + SetWaveformPosition(0, 0, 0); + timerWaveform.Start(); + } + + Cursor = Cursors.Default; + + SetUndockedWindowsTitle(); + ShowSubtitleTimer.Start(); + } + } + + private void MediaPlayer_OnButtonClicked(object sender, EventArgs e) + { + if (sender is PictureBox pb && pb.Name == "_pictureBoxFullscreenOver") + { + if (_videoPlayerUndocked != null && !_videoPlayerUndocked.IsDisposed && _videoPlayerUndocked.IsFullscreen) + { + _videoPlayerUndocked.NoFullscreen(); + } + else + { + GoFullscreen(false); + } + } + } + + private void SetWaveformPosition(double startPositionSeconds, double currentVideoPositionSeconds, int subtitleIndex) + { + if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable) + { + int index = -1; + if (SubtitleListview1.SelectedItems.Count > 0 && _subtitle.Paragraphs.Count > 0) + { + int i = SubtitleListview1.SelectedItems[0].Index; + var p = Utilities.GetOriginalParagraph(i, _subtitle.Paragraphs[i], _subtitleAlternate.Paragraphs); + index = _subtitleAlternate.GetIndex(p); + } + + audioVisualizer.SetPosition(startPositionSeconds, _subtitleAlternate, currentVideoPositionSeconds, index, SubtitleListview1.SelectedIndices); + } + else + { + audioVisualizer.SetPosition(startPositionSeconds, _subtitle, currentVideoPositionSeconds, subtitleIndex, SubtitleListview1.SelectedIndices); + } + } + + private void VideoLoaded(object sender, EventArgs e) + { + if (_loading) + { + Application.DoEvents(); + } + + mediaPlayer.Volume = Configuration.Settings.General.VideoPlayerDefaultVolume; + timer1.Start(); + + trackBarWaveformPosition.Maximum = (int)mediaPlayer.Duration; + + if (_videoLoadedGoToSubPosAndPause) + { + Application.DoEvents(); + _videoLoadedGoToSubPosAndPause = false; + GotoSubPositionAndPause(); + } + + mediaPlayer.Pause(); + mediaPlayer.UpdatePlayerName(); + + // Keep current play rate + for (var index = 0; index < toolStripSplitButtonPlayRate.DropDownItems.Count; index++) + { + var item = (ToolStripMenuItem)toolStripSplitButtonPlayRate.DropDownItems[index]; + if (item.Checked) + { + SetPlayRate(item, null, true); + break; + } + } + + if (mediaPlayer.VideoPlayer is LibMpvDynamic && !Configuration.Settings.General.MpvHandlesPreviewText) + { + (mediaPlayer.VideoPlayer as LibMpvDynamic)?.RemoveSubtitle(); + } + + if (trackBarWaveformPosition.Maximum <= 0) + { + trackBarWaveformPosition.Maximum = (int)mediaPlayer.Duration; + } + } + + private void VideoEnded(object sender, EventArgs e) + { + mediaPlayer.Pause(); + } + + private void TryToFindAndOpenVideoFile(string fileNameNoExtension) + { + string movieFileName = null; + + foreach (var extension in Utilities.VideoFileExtensions) + { + var fileName = fileNameNoExtension + extension; + if (File.Exists(fileName)) + { + bool skipLoad = false; + if (extension == ".m2ts" && new FileInfo(fileName).Length < 2000000) + { + var textSt = new TextST(); + skipLoad = textSt.IsMine(null, fileName); // don't load TextST files as video/audio file + } + + if (!skipLoad) + { + movieFileName = fileName; + break; + } + } + } + + if (movieFileName != null) + { + OpenVideo(movieFileName); + } + else + { + var index = fileNameNoExtension.LastIndexOf('.'); + if (index > 0) + { + TryToFindAndOpenVideoFile(fileNameNoExtension.Remove(index)); + } + } + } + + internal void GoBackSeconds(double seconds) + { + if (mediaPlayer.CurrentPosition > seconds) + { + mediaPlayer.CurrentPosition -= seconds; + } + else + { + mediaPlayer.CurrentPosition = 0; + } + + ShowSubtitle(); + } + + private void ButtonStartHalfASecondBackClick(object sender, EventArgs e) + { + GoBackSeconds(0.5); + } + + private void ButtonStartThreeSecondsBackClick(object sender, EventArgs e) + { + GoBackSeconds(3.0); + } + + private void ButtonStartOneMinuteBackClick(object sender, EventArgs e) + { + GoBackSeconds(60); + } + + private void ButtonStartHalfASecondAheadClick(object sender, EventArgs e) + { + GoBackSeconds(-0.5); + } + + private void ButtonStartThreeSecondsAheadClick(object sender, EventArgs e) + { + GoBackSeconds(-3); + } + + private void ButtonStartOneMinuteAheadClick(object sender, EventArgs e) + { + GoBackSeconds(-60); + } + + private void ShowSubtitleTimerTick(object sender, EventArgs e) + { + ShowSubtitleTimer.Stop(); + + if (_subtitle == null || _subtitle.Paragraphs.Count == 0) + { + ShowSubtitleTimer.Interval = 250; + } + else + { + ShowSubtitleTimer.Interval = 17; + } + + if (mediaPlayer.VideoPlayer != null) + { + int oldIndex = FirstSelectedIndex; + int index = ShowSubtitle(); + if (index != -1 && checkBoxSyncListViewWithVideoWhilePlaying.Checked && oldIndex != index) + { + if ((DateTime.UtcNow.Ticks - _lastTextKeyDownTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds + { + if (_endSeconds <= 0 || !checkBoxAutoRepeatOn.Checked) + { + if (!timerAutoDuration.Enabled && !mediaPlayer.IsPaused && (mediaPlayer.CurrentPosition > 0.2 || index > 0)) + { + SubtitleListview1.SelectIndexAndEnsureVisibleFaster(index); + } + } + } + } + } + + var currentChanged = _changeSubtitleHash != _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + var originalActive = Configuration.Settings.General.AllowEditOfOriginalSubtitle && + _subtitleAlternate != null && + _subtitleAlternate.Paragraphs.Count > 0; + var originalChanged = originalActive && + _changeAlternateSubtitleHash != _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName); + if (currentChanged || originalChanged) + { + AddTitleBarChangeAsterisk(currentChanged, originalChanged, originalActive); + AutoSave(); + } + else if (Text.Contains('*')) + { + Text = Text.RemoveChar('*').TrimEnd(); + } + + ShowSubtitleTimer.Start(); + } + + private void AddTitleBarChangeAsterisk(bool currentChanged, bool originalChanged, bool originalActive) + { + if (Configuration.Settings.General.TitleBarAsterisk.Equals("before", StringComparison.Ordinal)) + { + if (!Text.Contains('*')) + { + Text = "*" + Text; + } + } + else if (Configuration.Settings.General.TitleBarAsterisk.Equals("after", StringComparison.Ordinal)) + { + var s = Text.RemoveChar('*').TrimEnd(); + if (currentChanged && !originalActive || originalChanged) + { + var length = Title.Length; + if (s.Length > length) + { + s = s.Substring(0, s.Length - length).TrimEnd(' ', '*', '-') + "* - " + Title; + } + } + if (currentChanged) + { + s = s.Replace(" + ", "* + "); + } + + Text = s; + } + } + + private void HideVideoPlayer() + { + mediaPlayer.Pause(); + + int textHeight = splitContainerListViewAndText.Height - splitContainerListViewAndText.SplitterDistance; + + splitContainer1.Panel2Collapsed = true; + splitContainerMain.Panel2Collapsed = true; + Main_Resize(null, null); + + splitContainerListViewAndText.SplitterDistance = splitContainerListViewAndText.Height - textHeight; + } + + private void ShowVideoPlayer() + { + if (_isVideoControlsUndocked) + { + ShowHideUndockedVideoControls(); + } + else + { + if (toolStripButtonToggleVideo.Checked && toolStripButtonToggleWaveform.Checked) + { + splitContainer1.Panel2Collapsed = false; + MoveVideoUp(); + } + else + { + splitContainer1.Panel2Collapsed = true; + MoveVideoDown(); + } + + splitContainerMain.Panel2Collapsed = false; + if (toolStripButtonToggleVideo.Checked) + { + if (audioVisualizer.Visible) + { + audioVisualizer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + } + else + { + panelVideoPlayer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + } + } + else if (audioVisualizer.Visible) + { + audioVisualizer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + } + + audioVisualizer.Width = groupBoxVideo.Width - (audioVisualizer.Left + 10); + + checkBoxSyncListViewWithVideoWhilePlaying.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + panelWaveformControls.Left = audioVisualizer.Left; + trackBarWaveformPosition.Left = panelWaveformControls.Left + panelWaveformControls.Width + 5; + trackBarWaveformPosition.Width = audioVisualizer.Left + audioVisualizer.Width - trackBarWaveformPosition.Left + 5; + } + + if (mediaPlayer.VideoPlayer == null && !string.IsNullOrEmpty(_fileName) && string.IsNullOrEmpty(VideoFileName) && !Configuration.Settings.General.DisableVideoAutoLoading) + { + TryToFindAndOpenVideoFile(Utilities.GetPathAndFileNameWithoutExtension(_fileName)); + } + + Main_Resize(null, null); + } + + private void ShowHideUndockedVideoControls() + { + if (_videoPlayerUndocked == null || _videoPlayerUndocked.IsDisposed) + { + UnDockVideoPlayer(); + } + + _videoPlayerUndocked.Visible = false; + if (toolStripButtonToggleVideo.Checked) + { + _videoPlayerUndocked.Show(this); + if (_videoPlayerUndocked.WindowState == FormWindowState.Minimized) + { + _videoPlayerUndocked.WindowState = FormWindowState.Normal; + } + } + + if (_waveformUndocked == null || _waveformUndocked.IsDisposed) + { + UnDockWaveform(); + } + + _waveformUndocked.Visible = false; + if (toolStripButtonToggleWaveform.Checked) + { + _waveformUndocked.Show(this); + if (_waveformUndocked.WindowState == FormWindowState.Minimized) + { + _waveformUndocked.WindowState = FormWindowState.Normal; + } + } + + if (toolStripButtonToggleVideo.Checked || toolStripButtonToggleWaveform.Checked) + { + if (_videoControlsUndocked == null || _videoControlsUndocked.IsDisposed) + { + UnDockVideoButtons(); + } + + _videoControlsUndocked.Visible = false; + _videoControlsUndocked.Show(this); + } + else + { + if (_videoControlsUndocked != null && !_videoControlsUndocked.IsDisposed) + { + _videoControlsUndocked.Visible = false; + } + } + } + + private void MoveVideoUp() + { + if (splitContainer1.Panel2.Controls.Count == 0) + { + var control = panelVideoPlayer; + groupBoxVideo.Controls.Remove(control); + splitContainer1.Panel2.Controls.Add(control); + } + + panelVideoPlayer.Top = 0; + panelVideoPlayer.Left = 0; + panelVideoPlayer.Height = splitContainer1.Panel2.Height - 2; + panelVideoPlayer.Width = splitContainer1.Panel2.Width - 2; + } + + private void MoveVideoDown() + { + if (splitContainer1.Panel2.Controls.Count > 0) + { + var control = panelVideoPlayer; + splitContainer1.Panel2.Controls.Clear(); + groupBoxVideo.Controls.Add(control); + } + + panelVideoPlayer.Top = 32; + panelVideoPlayer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + panelVideoPlayer.Height = groupBoxVideo.Height - (panelVideoPlayer.Top + 5); + panelVideoPlayer.Width = groupBoxVideo.Width - (panelVideoPlayer.Left + 5); + } + + private void FixLargeFonts() + { + using (var graphics = CreateGraphics()) + { + var textSize = graphics.MeasureString(buttonPlayPrevious.Text, Font); + if (textSize.Height > buttonPlayPrevious.Height - 4) + { + int newButtonHeight = 23; + UiUtil.SetButtonHeight(this, newButtonHeight, -4); + + // List view + SubtitleListview1.InitializeTimestampColumnWidths(this); + const int adjustUp = 8; + SubtitleListview1.Height = SubtitleListview1.Height - adjustUp; + groupBoxEdit.Top = groupBoxEdit.Top - adjustUp; + groupBoxEdit.Height = groupBoxEdit.Height + adjustUp; + numericUpDownDuration.Left = timeUpDownStartTime.Left + timeUpDownStartTime.Width; + numericUpDownDuration.Width = numericUpDownDuration.Width + 5; + labelDuration.Left = numericUpDownDuration.Left - 3; + + // Video controls - Create + timeUpDownVideoPosition.Left = labelVideoPosition.Left + labelVideoPosition.Width; + int buttonWidth = labelVideoPosition.Width + timeUpDownVideoPosition.Width; + buttonInsertNewText.Width = buttonWidth; + buttonBeforeText.Width = buttonWidth; + buttonGotoSub.Width = buttonWidth; + buttonSetStartTime.Width = buttonWidth; + buttonSetEnd.Width = buttonWidth; + int FKeyLeft = buttonInsertNewText.Left + buttonInsertNewText.Width; + labelCreateF9.Left = FKeyLeft; + labelCreateF10.Left = FKeyLeft; + labelCreateF11.Left = FKeyLeft; + labelCreateF12.Left = FKeyLeft; + buttonForward1.Left = buttonInsertNewText.Left + buttonInsertNewText.Width - buttonForward1.Width; + numericUpDownSec1.Width = buttonInsertNewText.Width - (numericUpDownSec1.Left + buttonForward1.Width); + buttonForward2.Left = buttonInsertNewText.Left + buttonInsertNewText.Width - buttonForward2.Width; + numericUpDownSec2.Width = buttonInsertNewText.Width - (numericUpDownSec2.Left + buttonForward2.Width); + + // Video controls - Adjust + timeUpDownVideoPositionAdjust.Left = labelVideoPosition2.Left + labelVideoPosition2.Width; + buttonSetStartAndOffsetRest.Width = buttonWidth; + buttonSetEndAndGoToNext.Width = buttonWidth; + buttonAdjustSetStartTime.Width = buttonWidth; + buttonAdjustSetEndTime.Width = buttonWidth; + buttonAdjustPlayBefore.Width = buttonWidth; + buttonAdjustGoToPosAndPause.Width = buttonWidth; + labelAdjustF9.Left = FKeyLeft; + labelAdjustF10.Left = FKeyLeft; + labelAdjustF11.Left = FKeyLeft; + labelAdjustF12.Left = FKeyLeft; + buttonAdjustSecForward1.Left = buttonInsertNewText.Left + buttonInsertNewText.Width - buttonAdjustSecForward1.Width; + numericUpDownSecAdjust1.Width = buttonInsertNewText.Width - (numericUpDownSecAdjust2.Left + buttonAdjustSecForward1.Width); + buttonAdjustSecForward2.Left = buttonInsertNewText.Left + buttonInsertNewText.Width - buttonAdjustSecForward2.Width; + numericUpDownSecAdjust2.Width = buttonInsertNewText.Width - (numericUpDownSecAdjust2.Left + buttonAdjustSecForward2.Width); + + tabControl1_SelectedIndexChanged(null, null); + } + } + } + + private void Main_Resize(object sender, EventArgs e) + { + if (_loading) + { + return; + } + + if (WindowState == FormWindowState.Maximized) + { + Main_ResizeEnd(sender, e); + return; + } + + panelVideoPlayer.Invalidate(); + } + + private void Main_ResizeEnd(object sender, EventArgs e) + { + if (_loading) + { + return; + } + + panelVideoPlayer.Invalidate(); + MainResize(); + + // Due to strange bug in listview when maximizing + SaveSubtitleListviewIndices(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex, true); + + panelVideoPlayer.Refresh(); + } + + private void MainResize() + { + var tbText = textBoxListViewText; + var tbOriginal = textBoxListViewTextAlternate; + int firstLeft = 236; + + var lbText = labelText; + var lbTextOriginal = labelAlternateText; + + var lbSingleLine = labelTextLineLengths; + var lbSingleLineOriginal = labelTextAlternateLineLengths; + + tbText.Left = firstLeft; + tbOriginal.Left = firstLeft; + lbText.Left = firstLeft; + lbTextOriginal.Left = firstLeft; + tbText.Width = groupBoxEdit.Width - (tbText.Left + 10 + (groupBoxEdit.Width - buttonUnBreak.Left)); + + if (Configuration.Settings.General.RightToLeftMode && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + tbText = textBoxListViewTextAlternate; + tbOriginal = textBoxListViewText; + + lbText = labelAlternateText; + lbTextOriginal = labelText; + + lbSingleLine = labelTextAlternateLineLengths; + lbSingleLineOriginal = labelTextLineLengths; + } + else + { + labelTextLineLengths.Left = firstLeft; + } + + tbText.Left = firstLeft; + lbText.Left = firstLeft; + lbSingleLine.Left = firstLeft; + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0 && + textBoxListViewTextAlternate.Visible) + { + tbText.Width = (groupBoxEdit.Width - (tbText.Left + 10)) / 2; + tbOriginal.Left = tbText.Left + tbText.Width + 3; + lbTextOriginal.Left = tbOriginal.Left; + + tbOriginal.Width = tbText.Width; + + labelAlternateCharactersPerSecond.Left = tbOriginal.Left + (tbOriginal.Width - labelAlternateCharactersPerSecond.Width); + lbSingleLineOriginal.Left = tbOriginal.Left; + labelAlternateSingleLine.Left = labelTextAlternateLineLengths.Left + labelTextAlternateLineLengths.Width; + labelAlternateSingleLinePixels.Left = labelAlternateSingleLine.Left + labelAlternateSingleLine.Width + 10; + labelTextAlternateLineTotal.Left = tbOriginal.Left + (tbOriginal.Width - labelTextAlternateLineTotal.Width); + if (textBoxListViewText.Width / 2.1 < labelTextLineLengths.Width) + { + labelTextAlternateLineTotal.Visible = false; + } + else + { + labelTextAlternateLineTotal.Visible = true; + } + + if (textBoxListViewText.Width / 3 < labelTextLineLengths.Width) + { + labelAlternateSingleLinePixels.Visible = false; + } + else + { + labelAlternateSingleLinePixels.Visible = Configuration.Settings.Tools.ListViewSyntaxColorWideLines; + } + } + + labelAlternateCharactersPerSecond.Top = labelCharactersPerSecond.Top; + labelCharactersPerSecond.Left = tbText.Left + (tbText.Width - labelCharactersPerSecond.Width); + labelTextLineTotal.Left = tbText.Left + (tbText.Width - labelTextLineTotal.Width); + SubtitleListview1.AutoSizeAllColumns(this); + + if (textBoxListViewText.Width / 2.1 < labelTextLineLengths.Width) + { + labelTextLineTotal.Visible = false; + } + else + { + labelTextLineTotal.Visible = true; + } + + if (textBoxListViewText.Width / 3 < labelTextLineLengths.Width) + { + labelSingleLinePixels.Visible = false; + } + else + { + labelSingleLinePixels.Visible = Configuration.Settings.Tools.ListViewSyntaxColorWideLines; + } + + FixRightToLeftDependingOnLanguage(); + } + + private void FixRightToLeftDependingOnLanguage() + { + if (Configuration.Settings.General.RightToLeftMode) + { + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + if (LanguageAutoDetect.CouldBeRightToLeftLanguage(_subtitleAlternate)) + { + textBoxListViewTextAlternate.RightToLeft = RightToLeft.Yes; + } + else + { + textBoxListViewTextAlternate.RightToLeft = RightToLeft.No; + } + } + + if (LanguageAutoDetect.CouldBeRightToLeftLanguage(_subtitle)) + { + textBoxListViewText.RightToLeft = RightToLeft.Yes; + textBoxSource.RightToLeft = RightToLeft.Yes; + } + else + { + + textBoxListViewText.RightToLeft = RightToLeft.No; + textBoxSource.RightToLeft = RightToLeft.No; + } + } + else + { + textBoxListViewText.RightToLeft = RightToLeft.No; + textBoxSource.RightToLeft = RightToLeft.No; + } + } + + private void PlayCurrent() + { + if (_subtitleListViewIndex >= 0) + { + GotoSubtitleIndex(_subtitleListViewIndex); + textBoxListViewText.Focus(); + ReadyAutoRepeat(); + PlayPart(_subtitle.Paragraphs[_subtitleListViewIndex]); + } + } + + private void ReadyAutoRepeat() + { + if (checkBoxAutoRepeatOn.Checked) + { + _repeatCount = int.Parse(comboBoxAutoRepeat.Text); + } + else + { + _repeatCount = -1; + } + + if (mediaPlayer.VideoPlayer != null) + { + labelStatus.Text = _language.VideoControls.Playing; + } + } + + private void PlayNext() + { + int newIndex = _subtitleListViewIndex + 1; + if (newIndex < _subtitle.Paragraphs.Count) + { + foreach (ListViewItem item in SubtitleListview1.SelectedItems) + { + item.Selected = false; + } + + SubtitleListview1.Items[newIndex].Selected = true; + SubtitleListview1.Items[newIndex].EnsureVisible(); + SubtitleListview1.Items[newIndex].Focused = true; + textBoxListViewText.Focus(); + textBoxListViewText.SelectAll(); + _subtitleListViewIndex = newIndex; + GotoSubtitleIndex(newIndex); + ShowSubtitle(); + PlayCurrent(); + } + } + + private void PlayPrevious() + { + if (_subtitleListViewIndex > 0) + { + int newIndex = _subtitleListViewIndex - 1; + foreach (ListViewItem item in SubtitleListview1.SelectedItems) + { + item.Selected = false; + } + + SubtitleListview1.Items[newIndex].Selected = true; + SubtitleListview1.Items[newIndex].EnsureVisible(); + SubtitleListview1.Items[newIndex].Focused = true; + textBoxListViewText.Focus(); + textBoxListViewText.SelectAll(); + GotoSubtitleIndex(newIndex); + ShowSubtitle(); + _subtitleListViewIndex = newIndex; + PlayCurrent(); + } + } + + private void GotoSubtitleIndex(int index) + { + if (mediaPlayer.VideoPlayer != null && mediaPlayer.Duration > 0) + { + mediaPlayer.CurrentPosition = _subtitle.Paragraphs[index].StartTime.TotalSeconds; + } + } + + private void PlayPart(Paragraph paragraph) + { + if (mediaPlayer.VideoPlayer != null) + { + double startSeconds = paragraph.StartTime.TotalSeconds; + if (startSeconds > 0.05) + { + startSeconds -= 0.05; // go a little back + } + + _endSeconds = paragraph.EndTime.TotalSeconds; + if (mediaPlayer.Duration > _endSeconds + 0.05) + { + _endSeconds += 0.05; // go a little forward + } + + mediaPlayer.CurrentPosition = startSeconds; + ShowSubtitle(); + mediaPlayer.Play(); + } + } + + private void buttonSetStartTime_Click(object sender, EventArgs e) + { + SetStartTime(false, mediaPlayer.CurrentPosition); + } + + private void SetStartTime(bool adjustEndTime, double videoPosition) + { + if (SubtitleListview1.SelectedItems.Count == 1) + { + timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; + int index = SubtitleListview1.SelectedItems[0].Index; + var p = _subtitle.Paragraphs[index]; + var oldParagraph = new Paragraph(p, false); + if (oldParagraph.StartTime.IsMaxTime || oldParagraph.EndTime.IsMaxTime) + { + adjustEndTime = true; + } + + if (!mediaPlayer.IsPaused) + { + videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; + } + + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + p.Number + " " + p.Text)); + + timeUpDownStartTime.TimeCode = TimeCode.FromSeconds(videoPosition); + + var duration = p.Duration.TotalMilliseconds; + + p.StartTime.TotalMilliseconds = videoPosition * TimeCode.BaseUnit; + if (adjustEndTime) + { + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + duration; + } + + if (oldParagraph.StartTime.IsMaxTime) + { + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text); + } + + SubtitleListview1.SetStartTimeAndDuration(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + timeUpDownStartTime.TimeCode = p.StartTime; + timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; + + if (!adjustEndTime) + { + SetDurationInSeconds(p.Duration.TotalSeconds); + } + + UpdateOriginalTimeCodes(oldParagraph); + ShowSource(); + RefreshSelectedParagraph(); + } + } + + private void ButtonSetEndClick(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedItems.Count == 1) + { + double videoPosition = mediaPlayer.CurrentPosition; + if (!mediaPlayer.IsPaused) + { + videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; + } + + int index = SubtitleListview1.SelectedItems[0].Index; + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + _subtitle.Paragraphs[index].Number + " " + _subtitle.Paragraphs[index].Text)); + + if (_subtitle.Paragraphs[index].StartTime.IsMaxTime) + { + timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; + _subtitle.Paragraphs[index].EndTime.TotalSeconds = videoPosition; + _subtitle.Paragraphs[index].StartTime.TotalMilliseconds = _subtitle.Paragraphs[index].EndTime.TotalMilliseconds - Utilities.GetOptimalDisplayMilliseconds(_subtitle.Paragraphs[index].Text); + if (_subtitle.Paragraphs[index].StartTime.TotalMilliseconds < 0) + { + _subtitle.Paragraphs[index].StartTime.TotalMilliseconds = 0; + } + + timeUpDownStartTime.TimeCode = _subtitle.Paragraphs[index].StartTime; + SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; + } + else + { + _subtitle.Paragraphs[index].EndTime = TimeCode.FromSeconds(videoPosition); + } + + SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds); + } + } + + private void ButtonInsertNewTextClick(object sender, EventArgs e) + { + mediaPlayer.Pause(); + + var newParagraph = InsertNewTextAtVideoPosition(); + + textBoxListViewText.Focus(); + timerAutoDuration.Start(); + + ShowStatus(string.Format(_language.VideoControls.NewTextInsertAtX, newParagraph.StartTime.ToShortString())); + } + + private Paragraph InsertNewTextAtVideoPosition() + { + // current movie Position + double videoPositionInMilliseconds = mediaPlayer.CurrentPosition * TimeCode.BaseUnit; + if (!mediaPlayer.IsPaused && videoPositionInMilliseconds > Configuration.Settings.General.SetStartEndHumanDelay) + { + videoPositionInMilliseconds -= Configuration.Settings.General.SetStartEndHumanDelay; + } + + var tc = new TimeCode(videoPositionInMilliseconds); + MakeHistoryForUndo(_language.BeforeInsertSubtitleAtVideoPosition + " " + tc); + + // find index where to insert + int index = 0; + foreach (var p in _subtitle.Paragraphs) + { + if (p.StartTime.TotalMilliseconds > videoPositionInMilliseconds) + { + break; + } + + index++; + } + + // prevent overlap + var endTotalMilliseconds = videoPositionInMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs; + var next = _subtitle.GetParagraphOrDefault(index); + if (next != null) + { + if (endTotalMilliseconds > next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines) + { + endTotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + } + } + + // create and insert + var newParagraph = new Paragraph(string.Empty, videoPositionInMilliseconds, endTotalMilliseconds); + SetStyleForNewParagraph(newParagraph, index); + if (_networkSession != null) + { + _networkSession.TimerStop(); + NetworkGetSendUpdates(new List(), index, newParagraph); + } + else + { + _subtitle.Paragraphs.Insert(index, newParagraph); + + // check if original is available - and insert new paragraph in the original too + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph)); + _subtitleAlternate.Renumber(); + } + + _subtitleListViewIndex = -1; + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + return newParagraph; + } + + private void timerAutoDuration_Tick(object sender, EventArgs e) + { + labelAutoDuration.Visible = !labelAutoDuration.Visible; + if (SubtitleListview1.SelectedItems.Count > 0) + { + try + { + int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + var currentParagraph = _subtitle.Paragraphs[firstSelectedIndex]; + var nextParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex + 1); + double duration = Utilities.GetOptimalDisplayMilliseconds(textBoxListViewText.Text); + if (currentParagraph.StartTime.TotalMilliseconds + duration + Configuration.Settings.General.MinimumMillisecondsBetweenLines > nextParagraph?.StartTime.TotalMilliseconds) + { + var newEndTime = nextParagraph.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; + if (newEndTime - currentParagraph.StartTime.TotalMilliseconds > 100) + { + duration = newEndTime - currentParagraph.StartTime.TotalMilliseconds; + } + else + { + return; // too close to next subtitle + } + } + + SetDurationInSeconds(duration / TimeCode.BaseUnit); + currentParagraph.EndTime.TotalMilliseconds = currentParagraph.StartTime.TotalMilliseconds + duration; + SubtitleListview1.SetDuration(firstSelectedIndex, currentParagraph, _subtitle.GetParagraphOrDefault(firstSelectedIndex + 1)); + } + catch + { + // ignore + } + } + } + + private void buttonBeforeText_Click(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedItems.Count > 0) + { + int index = SubtitleListview1.SelectedItems[0].Index; + + mediaPlayer.Pause(); + double pos = _subtitle.Paragraphs[index].StartTime.TotalSeconds; + if (pos > 1) + { + mediaPlayer.CurrentPosition = (_subtitle.Paragraphs[index].StartTime.TotalSeconds) - 0.5; + } + else + { + mediaPlayer.CurrentPosition = _subtitle.Paragraphs[index].StartTime.TotalSeconds; + } + + mediaPlayer.Play(); + } + } + + private void GotoSubPositionAndPause() + { + GotoSubPositionAndPause(0); + } + + private void GotoSubPositionAndPause(double adjustSeconds) + { + if (SubtitleListview1.SelectedItems.Count > 0) + { + int index = SubtitleListview1.SelectedItems[0].Index; + if (index == -1 || index >= _subtitle.Paragraphs.Count) + { + return; + } + + var p = _subtitle.Paragraphs[index]; + mediaPlayer.Pause(); + if (p.StartTime.IsMaxTime) + { + return; + } + + double newPos = p.StartTime.TotalSeconds + adjustSeconds; + if (newPos < 0) + { + newPos = 0; + } + + mediaPlayer.CurrentPosition = newPos; + ShowSubtitle(); + + double startPos = mediaPlayer.CurrentPosition - 1; + if (startPos < 0) + { + startPos = 0; + } + + SetWaveformPosition(startPos, mediaPlayer.CurrentPosition, index); + } + } + + private void buttonGotoSub_Click(object sender, EventArgs e) + { + GotoSubPositionAndPause(); + } + + private void buttonOpenVideo_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(openFileDialog1.InitialDirectory) && !string.IsNullOrEmpty(_fileName)) + { + openFileDialog1.InitialDirectory = Path.GetDirectoryName(_fileName); + } + + openFileDialog1.Title = _languageGeneral.OpenVideoFileTitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = Utilities.GetVideoFileFilter(true); + + openFileDialog1.FileName = string.Empty; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + if (audioVisualizer.WavePeaks != null) + { + audioVisualizer.WavePeaks = null; + audioVisualizer.SetSpectrogram(null); + audioVisualizer.SceneChanges = new List(); + audioVisualizer.Chapters = new List(); + } + + openFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName); + if (!panelVideoPlayer.Visible) + { + toolStripButtonToggleVideo_Click(null, null); + } + + OpenVideo(openFileDialog1.FileName); + } + } + + private void toolStripButtonToggleVideo_Click(object sender, EventArgs e) + { + toolStripButtonToggleVideo.Checked = !toolStripButtonToggleVideo.Checked; + panelVideoPlayer.Visible = toolStripButtonToggleVideo.Checked; + mediaPlayer.BringToFront(); + if (!toolStripButtonToggleVideo.Checked && !toolStripButtonToggleWaveform.Checked) + { + if (_isVideoControlsUndocked) + { + ShowHideUndockedVideoControls(); + } + else + { + HideVideoPlayer(); + } + } + else + { + ShowVideoPlayer(); + } + + Configuration.Settings.General.ShowVideoPlayer = toolStripButtonToggleVideo.Checked; + if (!_loading) + { + Refresh(); + } + } + + private void toolStripButtonToggleWaveform_Click(object sender, EventArgs e) + { + toolStripButtonToggleWaveform.Checked = !toolStripButtonToggleWaveform.Checked; + audioVisualizer.Visible = toolStripButtonToggleWaveform.Checked; + trackBarWaveformPosition.Visible = toolStripButtonToggleWaveform.Checked; + panelWaveformControls.Visible = toolStripButtonToggleWaveform.Checked; + if (!toolStripButtonToggleWaveform.Checked && !toolStripButtonToggleVideo.Checked) + { + if (_isVideoControlsUndocked) + { + ShowHideUndockedVideoControls(); + } + else + { + HideVideoPlayer(); + } + } + else + { + ShowVideoPlayer(); + } + + Configuration.Settings.General.ShowAudioVisualizer = toolStripButtonToggleWaveform.Checked; + Refresh(); + } + + public void ShowEarlierOrLater(double adjustMilliseconds, SelectionChoice selection) + { + var tc = new TimeCode(adjustMilliseconds); + MakeHistoryForUndo(_language.BeforeShowSelectedLinesEarlierLater + ": " + tc); + if (adjustMilliseconds < 0) + { + if (selection == SelectionChoice.AllLines) + { + ShowStatus(string.Format(_language.ShowAllLinesXSecondsLinesEarlier, adjustMilliseconds / -TimeCode.BaseUnit)); + } + else if (selection == SelectionChoice.SelectionOnly) + { + ShowStatus(string.Format(_language.ShowSelectedLinesXSecondsLinesEarlier, adjustMilliseconds / -TimeCode.BaseUnit)); + } + else if (selection == SelectionChoice.SelectionAndForward) + { + ShowStatus(string.Format(_language.ShowSelectionAndForwardXSecondsLinesEarlier, adjustMilliseconds / -TimeCode.BaseUnit)); + } + } + else + { + if (selection == SelectionChoice.AllLines) + { + ShowStatus(string.Format(_language.ShowAllLinesXSecondsLinesLater, adjustMilliseconds / TimeCode.BaseUnit)); + } + else if (selection == SelectionChoice.SelectionOnly) + { + ShowStatus(string.Format(_language.ShowSelectedLinesXSecondsLinesLater, adjustMilliseconds / TimeCode.BaseUnit)); + } + else if (selection == SelectionChoice.SelectionAndForward) + { + ShowStatus(string.Format(_language.ShowSelectionAndForwardXSecondsLinesLater, adjustMilliseconds / TimeCode.BaseUnit)); + } + } + + int startFrom = 0; + if (selection == SelectionChoice.SelectionAndForward) + { + if (SubtitleListview1.SelectedItems.Count > 0) + { + startFrom = SubtitleListview1.SelectedItems[0].Index; + } + else + { + startFrom = _subtitle.Paragraphs.Count; + } + } + + // don't overlap previous/next + if (selection == SelectionChoice.SelectionOnly && SubtitleListview1.SelectedItems.Count == 1 && + !Configuration.Settings.VideoControls.WaveformAllowOverlap && + GetCurrentSubtitleFormat().GetType() != typeof(AdvancedSubStationAlpha)) + { + var current = _subtitle.GetParagraphOrDefault(FirstSelectedIndex); + if (current != null) + { + if (adjustMilliseconds >= 0) + { + var next = _subtitle.GetParagraphOrDefault(FirstSelectedIndex + 1); + if (next != null && current.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines > next.StartTime.TotalMilliseconds - adjustMilliseconds) + { + var newAdjustMs = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines - current.EndTime.TotalMilliseconds; + if (newAdjustMs > 0) + { + adjustMilliseconds = newAdjustMs; + } + else + { + return; + } + } + } + else + { + var prev = _subtitle.GetParagraphOrDefault(FirstSelectedIndex - 1); + if (prev != null && current.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines + adjustMilliseconds < prev.EndTime.TotalMilliseconds) + { + var newAdjustMs = prev.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines - current.StartTime.TotalMilliseconds; + if (newAdjustMs < 0) + { + adjustMilliseconds = newAdjustMs; + } + else + { + return; + } + } + } + } + } + + SubtitleListview1.BeginUpdate(); + for (int i = startFrom; i < _subtitle.Paragraphs.Count; i++) + { + switch (selection) + { + case SelectionChoice.SelectionOnly: + if (SubtitleListview1.Items[i].Selected) + { + ShowEarlierOrLaterParagraph(adjustMilliseconds, i); + } + + break; + case SelectionChoice.AllLines: + case SelectionChoice.SelectionAndForward: + ShowEarlierOrLaterParagraph(adjustMilliseconds, i); + break; + } + } + + SubtitleListview1.EndUpdate(); + RefreshSelectedParagraph(); + UpdateSourceView(); + UpdateListSyntaxColoring(); + } + + private void ShowEarlierOrLaterParagraph(double adjustMilliseconds, int i) + { + var p = _subtitle.GetParagraphOrDefault(i); + if (p != null && !p.StartTime.IsMaxTime) + { + if (_subtitleAlternate != null) + { + var original = Utilities.GetOriginalParagraph(i, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + original.StartTime.TotalMilliseconds += adjustMilliseconds; + original.EndTime.TotalMilliseconds += adjustMilliseconds; + } + } + + p.StartTime.TotalMilliseconds += adjustMilliseconds; + p.EndTime.TotalMilliseconds += adjustMilliseconds; + SubtitleListview1.SetStartTimeAndDuration(i, p, _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1)); + } + } + + private void UpdateSourceView() + { + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + ShowSource(); + } + } + + private void toolStripMenuItemAdjustAllTimes_Click(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedItems.Count > 1) + { + ShowSelectedLinesEarlierlaterToolStripMenuItemClick(null, null); + return; + } + + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + mediaPlayer.Pause(); + + if (_showEarlierOrLater != null && !_showEarlierOrLater.IsDisposed) + { + _showEarlierOrLater.WindowState = FormWindowState.Normal; + _showEarlierOrLater.Focus(); + return; + } + + _showEarlierOrLater = new ShowEarlierLater(); + if (!_showEarlierOrLater.IsPositionAndSizeSaved) + { + _showEarlierOrLater.Top = Top + 100; + _showEarlierOrLater.Left = Left + Width / 2 - _showEarlierOrLater.Width / 3; + } + + SaveSubtitleListviewIndices(); + _showEarlierOrLater.Initialize(ShowEarlierOrLater, false); + _showEarlierOrLater.Show(this); + } + + private void timer1_Tick(object sender, EventArgs e) + { + if (mediaPlayer.VideoPlayer != null) + { + if (!mediaPlayer.IsPaused) + { + timeUpDownVideoPosition.Enabled = false; + timeUpDownVideoPositionAdjust.Enabled = false; + + if (_endSeconds >= 0 && mediaPlayer.CurrentPosition > _endSeconds && !(AutoRepeatContinueOn || AutoRepeatOn)) + { + mediaPlayer.Pause(); + if (_endSecondsNewPosition >= 0 && _endSecondsNewPositionTicks > DateTime.UtcNow.Ticks - (10000 * 900)) // 900 ms + { + mediaPlayer.CurrentPosition = _endSecondsNewPosition; + } + else + { + mediaPlayer.CurrentPosition = _endSeconds + EndDelay; + } + + _endSeconds = -1; + _endSecondsNewPosition = -1; + _endSecondsNewPositionTicks = 0; + } + + if (AutoRepeatContinueOn || AutoRepeatOn) + { + if (_endSeconds >= 0 && mediaPlayer.CurrentPosition > _endSeconds && checkBoxAutoRepeatOn.Checked) + { + mediaPlayer.Pause(); + _endSeconds = -1; + + if (checkBoxAutoRepeatOn.Checked && _repeatCount > 0) + { + if (_repeatCount == 1) + { + labelStatus.Text = _language.VideoControls.RepeatingLastTime; + } + else + { + labelStatus.Text = string.Format(_language.VideoControls.RepeatingXTimesLeft, _repeatCount); + } + + _repeatCount--; + if (_subtitleListViewIndex >= 0 && _subtitleListViewIndex < _subtitle.Paragraphs.Count) + { + PlayPart(_subtitle.Paragraphs[_subtitleListViewIndex]); + } + } + else if (checkBoxAutoContinue.Checked) + { + _autoContinueDelayCount = int.Parse(comboBoxAutoContinue.Text); + if (_repeatCount == 1) + { + labelStatus.Text = _language.VideoControls.AutoContinueInOneSecond; + } + else + { + labelStatus.Text = string.Format(_language.VideoControls.AutoContinueInXSeconds, _autoContinueDelayCount); + } + + timerAutoContinue.Start(); + } + } + } + } + else + { + timeUpDownVideoPosition.Enabled = true; + timeUpDownVideoPositionAdjust.Enabled = true; + } + + int index = ShowSubtitle(); + + double pos = mediaPlayer.CurrentPosition * TimeCode.BaseUnit; + if (!timeUpDownVideoPosition.MaskedTextBox.Focused && timeUpDownVideoPosition.TimeCode.TotalMilliseconds != pos) + { + timeUpDownVideoPosition.TimeCode = new TimeCode(pos); + } + + if (!timeUpDownVideoPositionAdjust.MaskedTextBox.Focused && timeUpDownVideoPositionAdjust.TimeCode.TotalMilliseconds != pos) + { + timeUpDownVideoPositionAdjust.TimeCode = new TimeCode(pos); + } + + mediaPlayer.RefreshProgressBar(); + + trackBarWaveformPosition.ValueChanged -= trackBarWaveformPosition_ValueChanged; + int value = (int)mediaPlayer.CurrentPosition; + if (value > trackBarWaveformPosition.Maximum) + { + value = trackBarWaveformPosition.Maximum; + } + + if (value < trackBarWaveformPosition.Minimum) + { + value = trackBarWaveformPosition.Minimum; + } + + trackBarWaveformPosition.Value = value; + trackBarWaveformPosition.ValueChanged += trackBarWaveformPosition_ValueChanged; + + if (labelNextWord.Visible && _labelNextTicks + 100000000 < DateTime.UtcNow.Ticks) + { + labelNextWord.Visible = false; + } + } + } + + private void StopAutoDuration() + { + timerAutoDuration.Stop(); + labelAutoDuration.Visible = false; + } + + private void textBoxListViewText_Leave(object sender, EventArgs e) + { + StopAutoDuration(); + } + + private void timerAutoContinue_Tick(object sender, EventArgs e) + { + _autoContinueDelayCount--; + + if (_autoContinueDelayCount == 0) + { + timerAutoContinue.Stop(); + + if (timerStillTyping.Enabled) + { + labelStatus.Text = _language.VideoControls.StillTypingAutoContinueStopped; + } + else + { + labelStatus.Text = string.Empty; + PlayNext(); + } + } + else + { + if (_repeatCount == 1) + { + labelStatus.Text = _language.VideoControls.AutoContinueInOneSecond; + } + else + { + labelStatus.Text = string.Format(_language.VideoControls.AutoContinueInXSeconds, _autoContinueDelayCount); + } + } + } + + private void timerStillTyping_Tick(object sender, EventArgs e) + { + timerStillTyping.Stop(); + } + + private void textBoxListViewText_MouseMove(object sender, MouseEventArgs e) + { + if ((AutoRepeatContinueOn || AutoRepeatOn) && !textBoxSearchWord.Focused && textBoxListViewText.Focused) + { + string selectedText = textBoxListViewText.SelectedText; + if (!string.IsNullOrEmpty(selectedText)) + { + selectedText = selectedText.Trim(); + selectedText = selectedText.TrimEnd('.', ',', '!', '?'); + selectedText = selectedText.TrimEnd(); + if (!string.IsNullOrEmpty(selectedText) && selectedText != textBoxSearchWord.Text) + { + textBoxSearchWord.Text = HtmlUtil.RemoveHtmlTags(selectedText); + } + } + } + } + + private void textBoxListViewText_KeyUp(object sender, KeyEventArgs e) + { + textBoxListViewText_MouseMove(sender, null); + textBoxListViewText.ClearUndo(); + UpdatePositionAndTotalLength(labelTextLineTotal, textBoxListViewText); + } + + public void RunTranslateSearch(Action act) + { + var text = textBoxSearchWord.Text; + if (tabControlButtons.SelectedTab != tabPageTranslate) + { + var tb = GetFocusedTextBox(); + if (tb.SelectionLength == 0) + { + text = tb.Text; + } + else + { + text = tb.SelectedText; + } + } + + if (!string.IsNullOrWhiteSpace(text)) + { + act(text); + } + } + + private void buttonGoogleIt_Click(object sender, EventArgs e) + { + RunTranslateSearch((text) => { UiUtil.OpenURL("https://www.google.com/search?q=" + Utilities.UrlEncode(text)); }); + } + + private void buttonGoogleTranslateIt_Click(object sender, EventArgs e) + { + RunTranslateSearch((text) => + { + string languageId = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); + UiUtil.OpenURL("https://translate.google.com/#auto|" + languageId + "|" + Utilities.UrlEncode(text)); + }); + } + + private void ButtonPlayCurrentClick(object sender, EventArgs e) + { + PlayCurrent(); + } + + private void buttonPlayNext_Click(object sender, EventArgs e) + { + PlayNext(); + } + + private void buttonPlayPrevious_Click(object sender, EventArgs e) + { + PlayPrevious(); + } + + private void buttonStop_Click(object sender, EventArgs e) + { + _endSeconds = -1; + timerAutoContinue.Stop(); + mediaPlayer.Pause(); + labelStatus.Text = string.Empty; + } + + private void fileToolStripMenuItem_DropDownOpening(object sender, EventArgs e) + { + toolStripMenuItemOpenContainingFolder.Visible = !string.IsNullOrEmpty(_fileName) && File.Exists(_fileName); + bool subtitleLoaded = IsSubtitleLoaded; + toolStripMenuItemStatistics.Visible = subtitleLoaded; + toolStripSeparator22.Visible = subtitleLoaded; + toolStripMenuItemExport.Visible = subtitleLoaded; + openOriginalToolStripMenuItem.Visible = subtitleLoaded; + toolStripMenuItemOpenKeepVideo.Visible = VideoFileName != null; + if (subtitleLoaded && Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + saveOriginalToolStripMenuItem.Visible = true; + saveOriginalAstoolStripMenuItem.Visible = true; + removeOriginalToolStripMenuItem.Visible = true; + } + else + { + saveOriginalToolStripMenuItem.Visible = false; + saveOriginalAstoolStripMenuItem.Visible = false; + if (subtitleLoaded && SubtitleListview1.IsAlternateTextColumnVisible && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + removeOriginalToolStripMenuItem.Visible = true; + } + else + { + removeOriginalToolStripMenuItem.Visible = false; + } + } + + var format = GetCurrentSubtitleFormat(); + var ft = format.GetType(); + if (ft == typeof(AdvancedSubStationAlpha)) + { + toolStripMenuItemSubStationAlpha.Visible = true; + toolStripMenuItemSubStationAlpha.Text = _language.Menu.File.AdvancedSubStationAlphaProperties; + + toolStripMenuItemAssStyles.Visible = true; + toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.AdvancedSubStationAlphaStyles; + + toolStripMenuItemAssaStyles.Visible = true; + } + else if (ft == typeof(SubStationAlpha)) + { + toolStripMenuItemSubStationAlpha.Visible = true; + toolStripMenuItemSubStationAlpha.Text = _language.Menu.File.SubStationAlphaProperties; + + toolStripMenuItemAssStyles.Visible = true; + toolStripMenuItemAssStyles.Text = _language.Menu.ContextMenu.AdvancedSubStationAlphaStyles; + + toolStripMenuItemAssaStyles.Visible = true; + } + else + { + toolStripMenuItemSubStationAlpha.Visible = false; + toolStripMenuItemAssStyles.Visible = false; + toolStripMenuItemAssaStyles.Visible = false; + } + + if (ft == typeof(Ebu)) + { + toolStripMenuItemEbuProperties.Text = _language.Menu.File.EbuProperties; + toolStripMenuItemEbuProperties.Visible = !string.IsNullOrEmpty(_language.Menu.File.EbuProperties); + } + else + { + toolStripMenuItemEbuProperties.Visible = false; + } + + if (ft == typeof(DvdStudioPro) || + ft == typeof(DvdStudioProSpace) || + ft == typeof(DvdStudioProSpaceOne) || + ft == typeof(DvdStudioProSpaceOneSemicolon)) + { + toolStripMenuItemDvdStudioProProperties.Text = _language.Menu.File.DvdStuioProProperties; + toolStripMenuItemDvdStudioProProperties.Visible = true; + } + else + { + toolStripMenuItemDvdStudioProProperties.Visible = false; + } + + if (ft == typeof(DCinemaInterop) || ft == typeof(DCinemaSmpte2014) || ft == typeof(DCinemaSmpte2010) || ft == typeof(DCinemaSmpte2007)) + { + toolStripMenuItemDCinemaProperties.Visible = true; + } + else + { + toolStripMenuItemDCinemaProperties.Visible = false; + } + + if (ft == typeof(TimedText10) || ft == typeof(ItunesTimedText)) + { + toolStripMenuItemTTProperties.Visible = true; + } + else + { + toolStripMenuItemTTProperties.Visible = false; + } + + toolStripMenuItemNuendoProperties.Visible = format.Name == "Nuendo"; + toolStripMenuItemFcpProperties.Visible = ft == typeof(FinalCutProXml); + + toolStripSeparator20.Visible = subtitleLoaded; + } + + private void toolStripMenuItemOpenContainingFolder_Click(object sender, EventArgs e) + { + UiUtil.OpenFolderFromFileName(_fileName); + } + + private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) + { + if (tabControlButtons.SelectedIndex == 0) + { + tabControlButtons.Width = groupBoxTranslateSearch.Left + groupBoxTranslateSearch.Width + 10; + Configuration.Settings.VideoControls.LastActiveTab = "Translate"; + } + else if (tabControlButtons.SelectedIndex == 1) + { + tabControlButtons.Width = buttonInsertNewText.Left + buttonInsertNewText.Width + 35; + Configuration.Settings.VideoControls.LastActiveTab = "Create"; + } + else if (tabControlButtons.SelectedIndex == 2) + { + tabControlButtons.Width = buttonInsertNewText.Left + buttonInsertNewText.Width + 35; + Configuration.Settings.VideoControls.LastActiveTab = "Adjust"; + } + + if (!_isVideoControlsUndocked) + { + if (toolStripButtonToggleWaveform.Checked) + { + audioVisualizer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + } + + if (!toolStripButtonToggleWaveform.Checked && toolStripButtonToggleVideo.Checked) + { + panelVideoPlayer.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + panelVideoPlayer.Width = groupBoxVideo.Width - (panelVideoPlayer.Left + 10); + } + + audioVisualizer.Width = groupBoxVideo.Width - (audioVisualizer.Left + 10); + panelWaveformControls.Left = audioVisualizer.Left; + trackBarWaveformPosition.Left = panelWaveformControls.Left + panelWaveformControls.Width + 5; + trackBarWaveformPosition.Width = groupBoxVideo.Width - (trackBarWaveformPosition.Left + 10); + Main_Resize(null, null); + checkBoxSyncListViewWithVideoWhilePlaying.Left = tabControlButtons.Left + tabControlButtons.Width + 5; + if (!_loading) + { + Refresh(); + } + } + else if (_videoControlsUndocked != null && !_videoControlsUndocked.IsDisposed) + { + _videoControlsUndocked.Width = tabControlButtons.Width + 20; + _videoControlsUndocked.Height = tabControlButtons.Height + 65; + } + } + + private void buttonSecBack1_Click(object sender, EventArgs e) + { + GoBackSeconds((double)numericUpDownSec1.Value); + } + + private void buttonForward1_Click(object sender, EventArgs e) + { + GoBackSeconds(-(double)numericUpDownSec1.Value); + } + + private void ButtonSetStartAndOffsetRestClick(object sender, EventArgs e) + { + SetStartAndOffsetTheRest(mediaPlayer.CurrentPosition); + } + + private void SetStartAndOffsetTheRest(double videoPosition) + { + if (SubtitleListview1.SelectedItems.Count == 1) + { + bool oldSync = checkBoxSyncListViewWithVideoWhilePlaying.Checked; + checkBoxSyncListViewWithVideoWhilePlaying.Checked = false; + + timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; + int index = SubtitleListview1.SelectedItems[0].Index; + var oldP = new Paragraph(_subtitle.Paragraphs[index]); + if (!mediaPlayer.IsPaused) + { + videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; + } + + var tc = TimeCode.FromSeconds(videoPosition); + timeUpDownStartTime.TimeCode = tc; + + MakeHistoryForUndo(_language.BeforeSetStartTimeAndOffsetTheRest + @" " + oldP.Number + @" - " + tc); + + double offset = oldP.StartTime.TotalMilliseconds - tc.TotalMilliseconds; + + if (oldP.StartTime.IsMaxTime) + { + _subtitle.Paragraphs[index].StartTime.TotalSeconds = videoPosition; + _subtitle.Paragraphs[index].EndTime.TotalMilliseconds = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(_subtitle.Paragraphs[index].Text); + SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync; + timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; + RefreshSelectedParagraph(); + return; + } + + _subtitle.Paragraphs[index].StartTime = new TimeCode(_subtitle.Paragraphs[index].StartTime.TotalMilliseconds - offset); + _subtitle.Paragraphs[index].EndTime = new TimeCode(_subtitle.Paragraphs[index].EndTime.TotalMilliseconds - offset); + SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + + for (int i = index + 1; i < SubtitleListview1.Items.Count; i++) + { + if (!_subtitle.Paragraphs[i].StartTime.IsMaxTime) + { + _subtitle.Paragraphs[i].StartTime = new TimeCode(_subtitle.Paragraphs[i].StartTime.TotalMilliseconds - offset); + _subtitle.Paragraphs[i].EndTime = new TimeCode(_subtitle.Paragraphs[i].EndTime.TotalMilliseconds - offset); + SubtitleListview1.SetStartTimeAndDuration(i, _subtitle.Paragraphs[i], _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1)); + } + } + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + var original = Utilities.GetOriginalParagraph(index, oldP, _subtitleAlternate.Paragraphs); + if (original != null) + { + index = _subtitleAlternate.GetIndex(original); + for (int i = index; i < _subtitleAlternate.Paragraphs.Count; i++) + { + if (!_subtitleAlternate.Paragraphs[i].StartTime.IsMaxTime) + { + _subtitleAlternate.Paragraphs[i].StartTime = new TimeCode(_subtitleAlternate.Paragraphs[i].StartTime.TotalMilliseconds - offset); + _subtitleAlternate.Paragraphs[i].EndTime = new TimeCode(_subtitleAlternate.Paragraphs[i].EndTime.TotalMilliseconds - offset); + } + } + } + } + + ShowSource(); + checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync; + timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; + } + } + + private void ButtonSetEndAndGoToNextClick(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedItems.Count == 1) + { + int index = SubtitleListview1.SelectedItems[0].Index; + double videoPosition = mediaPlayer.CurrentPosition; + if (!mediaPlayer.IsPaused) + { + videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; + } + + string oldDuration = _subtitle.Paragraphs[index].Duration.ToString(); + var temp = new Paragraph(_subtitle.Paragraphs[index]); + temp.EndTime.TotalMilliseconds = TimeCode.FromSeconds(videoPosition).TotalMilliseconds; + MakeHistoryForUndo(string.Format(_language.DisplayTimeAdjustedX, "#" + _subtitle.Paragraphs[index].Number + ": " + oldDuration + " -> " + temp.Duration)); + _makeHistoryPaused = true; + + if (_subtitle.Paragraphs[index].StartTime.IsMaxTime) + { + timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; + _subtitle.Paragraphs[index].EndTime.TotalSeconds = videoPosition; + _subtitle.Paragraphs[index].StartTime.TotalMilliseconds = _subtitle.Paragraphs[index].EndTime.TotalMilliseconds - Utilities.GetOptimalDisplayMilliseconds(_subtitle.Paragraphs[index].Text); + if (_subtitle.Paragraphs[index].StartTime.TotalMilliseconds < 0) + { + _subtitle.Paragraphs[index].StartTime.TotalMilliseconds = 0; + } + + timeUpDownStartTime.TimeCode = _subtitle.Paragraphs[index].StartTime; + SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; + } + else + { + _subtitle.Paragraphs[index].EndTime = TimeCode.FromSeconds(videoPosition); + } + + SubtitleListview1.SetDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1)); + SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds); + + if (index + 1 < _subtitle.Paragraphs.Count) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true); + } + + _makeHistoryPaused = false; + } + } + + private void ButtonAdjustSecBackClick(object sender, EventArgs e) + { + GoBackSeconds((double)numericUpDownSecAdjust1.Value); + } + + private void ButtonAdjustSecForwardClick(object sender, EventArgs e) + { + GoBackSeconds(-(double)numericUpDownSecAdjust1.Value); + } + + private void StartOrStopAutoBackup() + { + _timerAutoBackup?.Dispose(); + if (Configuration.Settings.General.AutoBackupSeconds > 0) + { + _timerAutoBackup = new Timer(); + _timerAutoBackup.Tick += TimerAutoBackupTick; + _timerAutoBackup.Interval = 1000 * Configuration.Settings.General.AutoBackupSeconds; // take backup every x second if changes were made + _timerAutoBackup.Start(); + } + } + + private void Main_Shown(object sender, EventArgs e) + { + splitContainerListViewAndText.SplitterMoved += splitContainerListViewAndText_SplitterMoved; + splitContainerListViewAndText.SizeChanged += splitContainerListViewAndText_SizeChanged; + + imageListBookmarks.Images.Add(pictureBoxBookmark.Image); + SetListViewStateImages(); + + toolStripButtonToggleVideo.Checked = !Configuration.Settings.General.ShowVideoPlayer; + toolStripButtonToggleVideo_Click(null, null); + + StartOrStopAutoBackup(); + + SetPositionFromXYString(Configuration.Settings.General.UndockedVideoPosition, "VideoPlayerUndocked"); + SetPositionFromXYString(Configuration.Settings.General.UndockedWaveformPosition, "WaveformUndocked"); + SetPositionFromXYString(Configuration.Settings.General.UndockedVideoControlsPosition, "VideoControlsUndocked"); + if (Configuration.Settings.General.Undocked && Configuration.Settings.General.StartRememberPositionAndSize) + { + Configuration.Settings.General.Undocked = false; + UndockVideoControlsToolStripMenuItemClick(null, null); + if (Configuration.Settings.General.UndockedVideoFullscreen) + { + GoFullscreen(true); + } + } + + Main_Resize(null, null); + + toolStripButtonLockCenter.Checked = Configuration.Settings.General.WaveformCenter; + audioVisualizer.Locked = toolStripButtonLockCenter.Checked; + + numericUpDownSec1.Value = (decimal)(Configuration.Settings.General.SmallDelayMilliseconds / TimeCode.BaseUnit); + numericUpDownSec2.Value = (decimal)(Configuration.Settings.General.LargeDelayMilliseconds / TimeCode.BaseUnit); + + numericUpDownSecAdjust1.Value = (decimal)(Configuration.Settings.General.SmallDelayMilliseconds / TimeCode.BaseUnit); + numericUpDownSecAdjust2.Value = (decimal)(Configuration.Settings.General.LargeDelayMilliseconds / TimeCode.BaseUnit); + + SetShortcuts(); + MainResize(); + _loading = false; + OpenVideo(VideoFileName); + ShowSubtitleTimer.Stop(); + lock (_syncUndo) + { + timerTextUndo.Start(); + timerAlternateTextUndo.Start(); + } + + if (Configuration.IsRunningOnLinux) + { + numericUpDownDuration.Left = timeUpDownStartTime.Left + timeUpDownStartTime.Width + 10; + numericUpDownDuration.Width += 10; + numericUpDownSec1.Width += 10; + numericUpDownSec2.Width += 10; + numericUpDownSecAdjust1.Width += 10; + numericUpDownSecAdjust2.Width += 10; + labelDuration.Left = numericUpDownDuration.Left; + } + + _timerDoSyntaxColoring.Interval = 100; + _timerDoSyntaxColoring.Tick += _timerDoSyntaxColoring_Tick; + + var showBeta = Configuration.Settings.General.ShowBetaStuff; + generateDatetimeInfoFromVideoToolStripMenuItem.Visible = showBeta; + toolStripMenuItemExportCaptionInc.Visible = showBeta; + toolStripMenuItemExportUltech130.Visible = showBeta; + toolStripMenuItemInverseSelection.Visible = showBeta; + toolStripMenuItemSpellCheckFromCurrentLine.Visible = showBeta; + toolStripMenuItemImportOcrHardSub.Visible = showBeta; + toolStripMenuItemOpenDvd.Visible = showBeta; + + if (Configuration.Settings.General.StartRememberPositionAndSize && + Configuration.Settings.General.SplitContainerMainSplitterDistance > 0 && + Configuration.Settings.General.SplitContainer1SplitterDistance > 0 && + Configuration.Settings.General.SplitContainerListViewAndTextSplitterDistance > 0) + { + splitContainerMain.SplitterDistance = Configuration.Settings.General.SplitContainerMainSplitterDistance; + splitContainer1.SplitterDistance = Configuration.Settings.General.SplitContainer1SplitterDistance; + splitContainerListViewAndText.SplitterDistance = Configuration.Settings.General.SplitContainerListViewAndTextSplitterDistance; + } + + mediaPlayer.InitializeVolume(Configuration.Settings.General.VideoPlayerDefaultVolume); + tabControlSubtitle.Invalidate(); + + if (string.IsNullOrEmpty(Configuration.Settings.Language.CheckForUpdates.CheckingForUpdates)) + { + checkForUpdatesToolStripMenuItem.Visible = false; + toolStripMenuItemSplitterCheckForUpdates.Visible = false; + } + else if (Configuration.Settings.General.CheckForUpdates && Configuration.Settings.General.LastCheckForUpdates < DateTime.Now.AddDays(-5)) + { + _checkForUpdatesHelper = new CheckForUpdatesHelper(); + _checkForUpdatesHelper.CheckForUpdates(); + _timerCheckForUpdates = new Timer(); + _timerCheckForUpdates.Interval = 7000; + _timerCheckForUpdates.Tick += TimerCheckForUpdatesTick; + _timerCheckForUpdates.Start(); + Configuration.Settings.General.LastCheckForUpdates = DateTime.Now; + } + + _dragAndDropTimer.Interval = 50; + _dragAndDropTimer.Tick += DoSubtitleListview1Drop; + + _dragAndDropVideoTimer.Interval = 50; + _dragAndDropVideoTimer.Tick += DropVideoTick; + + if (_exitWhenLoaded) + { + Application.Exit(); + } + + // Fix some large font issue + if (numericUpDownDuration.Left + numericUpDownDuration.Width > textBoxListViewText.Left) + { + numericUpDownDuration.Left = timeUpDownStartTime.Left + timeUpDownStartTime.Width + 5; + numericUpDownDuration.Width = textBoxListViewText.Left - numericUpDownDuration.Left - 5; + labelDuration.Left = numericUpDownDuration.Left; + } + + if (string.IsNullOrEmpty(_fileName) && (_subtitle == null || _subtitle.Paragraphs.Count == 0)) + { + _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + } + + comboBoxSubtitleFormats.AutoCompleteSource = AutoCompleteSource.ListItems; + comboBoxSubtitleFormats.AutoCompleteMode = AutoCompleteMode.Append; + InitializePlayRateDropDown(); + + LoadPlugins(); + + mediaPlayer.OnEmptyPlayerClicked += MediaPlayer_OnEmptyPlayerClicked; + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex, true); + if (Configuration.Settings.General.StartInSourceView) + { + textBoxSource.Focus(); + } + else + { + SubtitleListview1.Focus(); + } + + UiUtil.FixFonts(toolStripComboBoxWaveform); + UiUtil.FixFonts(toolStripComboBoxFrameRate); + UiUtil.FixFonts(comboBoxSubtitleFormats); + UiUtil.FixFonts(comboBoxEncoding); + UiUtil.FixFonts(toolStripSplitButtonPlayRate); + + _lastTextKeyDownTicks = DateTime.UtcNow.Ticks; + if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + var idx = _subtitleListViewIndex; + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisibleFaster(idx); + } + + SetTitle(); + labelSingleLine.Left = labelTextLineLengths.Left + labelTextLineLengths.Width - 6; + RemoveNotExistingFilesFromRecentFilesUI(); + ShowSubtitleTimer.Start(); + } + + private void InitializePlayRateDropDown() + { + toolStripSplitButtonPlayRate.DropDownItems.Clear(); + var foreColor = UiUtil.ForeColor; + var backColor = UiUtil.BackColor; + for (int i = 30; i <= 300; i += 10) + { + toolStripSplitButtonPlayRate.DropDownItems.Add(new ToolStripMenuItem(i + "%", null, SetPlayRate) { Checked = i == 100, BackColor = backColor, ForeColor = foreColor }); + } + } + + private void MediaPlayer_OnEmptyPlayerClicked(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(VideoFileName)) + { + buttonOpenVideo_Click(sender, e); + } + } + + private void SetPlayRate(object sender, EventArgs e) + { + SetPlayRate(sender, e, false); + } + + private void SetPlayRate(object sender, EventArgs e, bool skipStatusMessage) + { + if (!(sender is ToolStripMenuItem playRateDropDownItem) || mediaPlayer == null || mediaPlayer.VideoPlayer == null) + { + return; + } + + foreach (ToolStripMenuItem item in toolStripSplitButtonPlayRate.DropDownItems) + { + item.Checked = false; + } + + playRateDropDownItem.Checked = true; + var percentText = playRateDropDownItem.Text.TrimEnd('%'); + if (!skipStatusMessage) + { + ShowStatus(string.Format(_language.SetPlayRateX, percentText)); + } + + var factor = double.Parse(percentText) / 100.0; + toolStripSplitButtonPlayRate.Image = Math.Abs(factor - 1) < 0.01 ? imageListPlayRate.Images[0] : imageListPlayRate.Images[1]; + mediaPlayer.VideoPlayer.PlayRate = factor; + } + + private void TimerCheckForUpdatesTick(object sender, EventArgs e) + { + _timerCheckForUpdates.Stop(); + if (_checkForUpdatesHelper.IsUpdateAvailable()) + { + using (var form = new CheckForUpdates(this, _checkForUpdatesHelper)) + { + form.ShowDialog(this); + } + } + + _checkForUpdatesHelper = null; + _timerCheckForUpdates = null; + } + + private void _timerDoSyntaxColoring_Tick(object sender, EventArgs e) + { + UpdateListSyntaxColoring(); + _timerDoSyntaxColoring.Stop(); + } + + private static void SetPositionFromXYString(string positionAndSize, string name) + { + var parts = positionAndSize.Split(';'); + if (parts.Length == 4) + { + if (int.TryParse(parts[0], out var left) + && int.TryParse(parts[1], out var top) + && int.TryParse(parts[2], out var width) + && int.TryParse(parts[3], out var height)) + { + PositionAndSizeForm.SetPositionAndSize(name, new Rectangle(left, top, width, height)); + } + else + { + System.Diagnostics.Debug.WriteLine("Could not set position and size for '{0}'.", name); + } + } + } + + private void SetShortcuts() + { + _shortcuts.SetShortcuts(); + newToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileNew); + openToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileOpen); + toolStripMenuItemOpenKeepVideo.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileOpenKeepVideo); + saveToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileSave); + saveOriginalToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileSaveOriginal); + saveOriginalAstoolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileSaveOriginalAs); + saveAsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileSaveAs); + openOriginalToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileOpenOriginal); + removeOriginalToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileCloseOriginal); + toolStripMenuItemCompare.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileCompare); + toolStripMenuItemImportText.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileImportPlainText); + toolStripMenuItemImportTimeCodes.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileImportTimeCodes); + eBUSTLToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileExportEbu); + pACScreenElectronicsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileExportPac); + plainTextToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainFileExportPlainText); + + toolStripMenuItemUndo.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditUndo); + toolStripMenuItemRedo.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditRedo); + findToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditFind); + findNextToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditFindNext); + replaceToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditReplace); + multipleReplaceToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditMultipleReplace); + gotoLineNumberToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditGoToLineNumber); + toolStripMenuItemRightToLeftMode.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditRightToLeft); + toolStripMenuItemShowOriginalInPreview.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditToggleTranslationOriginalInPreviews); + toolStripMenuItemInverseSelection.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditInverseSelection); + toolStripMenuItemModifySelection.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditModifySelection); + + fixToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsFixCommonErrors); + toolStripMenuItemAutoMergeShortLines.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsMergeShortLines); + toolStripMenuItemMergeDuplicateText.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsMergeDuplicateText); + toolStripMenuItemMergeLinesWithSameTimeCodes.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsMergeSameTimeCodes); + toolStripMenuItemMakeEmptyFromCurrent.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsMakeEmptyFromCurrent); + toolStripMenuItemAutoSplitLongLines.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsSplitLongLines); + toolStripMenuItemSubtitlesBridgeGaps.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsDurationsBridgeGap); + setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsMinimumDisplayTimeBetweenParagraphs); + startNumberingFromToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsRenumber); + removeTextForHearImpairedToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsRemoveTextForHI); + ChangeCasingToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsChangeCasing); + toolStripMenuItemShowOriginalInPreview.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditToggleTranslationOriginalInPreviews); + toolStripMenuItemBatchConvert.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsBatchConvert); + toolStripMenuItemMeasurementConverter.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsMeasurementConverter); + splitToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsSplit); + appendTextVisuallyToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsAppend); + joinSubtitlesToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainToolsJoin); + + openVideoToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoOpen); + closeVideoToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoClose); + showhideVideoToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoShowHideVideo); + toolStripMenuItemBookmark.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralToggleBookmarksWithText); + + spellCheckToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSpellCheck); + findDoubleWordsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSpellCheckFindDoubleWords); + addWordToNameListToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSpellCheckAddWordToNames); + + translateByGoogleToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTranslateGoogleTranslate); + + toolStripMenuItemAdjustAllTimes.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSynchronizationAdjustTimes); + visualSyncToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSynchronizationVisualSync); + toolStripMenuItemPointSync.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSynchronizationPointSync); + pointSyncViaOtherSubtitleToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSynchronizationPointSyncViaFile); + toolStripMenuItemChangeFrameRate2.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainSynchronizationChangeFrameRate); + italicToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewItalic); + removeAllFormattingsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainRemoveFormatting); + boldToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewBold); + boldToolStripMenuItem1.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewBold); + underlineToolStripMenuItem1.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewUnderline); + underlineToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewUnderline); + boxToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewBox); + boxToolStripMenuItem1.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewBox); + splitLineToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewSplit); + toolStripMenuItemSurroundWithMusicSymbols.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewToggleMusicSymbols); + toolStripMenuItemAlignment.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewAlignment); + copyOriginalTextToCurrentToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewCopyTextFromOriginalToCurrent); + columnDeleteTextOnlyToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColumnDeleteText); + toolStripMenuItemColumnDeleteText.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColumnDeleteTextAndShiftUp); + ShiftTextCellsDownToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColumnInsertText); + toolStripMenuItemPasteSpecial.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColumnPaste); + toolStripMenuItemRuby.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxSelectionToRuby); + moveTextUpToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColumnTextUp); + moveTextDownToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColumnTextDown); + toolStripMenuItemReverseRightToLeftStartEnd.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainEditReverseStartAndEndingForRTL); + italicToolStripMenuItem1.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxItalic); + + audioVisualizer.InsertAtVideoPositionShortcut = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainWaveformInsertAtCurrentPosition); + audioVisualizer.Move100MsLeft = UiUtil.GetKeys(Configuration.Settings.Shortcuts.Waveform100MsLeft); + audioVisualizer.Move100MsRight = UiUtil.GetKeys(Configuration.Settings.Shortcuts.Waveform100MsRight); + audioVisualizer.MoveOneSecondLeft = UiUtil.GetKeys(Configuration.Settings.Shortcuts.Waveform1000MsLeft); + audioVisualizer.MoveOneSecondRight = UiUtil.GetKeys(Configuration.Settings.Shortcuts.Waveform1000MsRight); + + UiUtil.HelpKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralHelp); + helpToolStripMenuItem1.ShortcutKeys = UiUtil.HelpKeys; + + + // shortcut hints + if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest2) && Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest2.Length < 5) + { + labelAdjustF9.Text = Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest2; + } + else if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest) && Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest.Length < 5) + { + labelAdjustF9.Text = Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest; + } + else + { + labelAdjustF9.Text = string.Empty; + } + + if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainAdjustSetEndAndGotoNext) && Configuration.Settings.Shortcuts.MainAdjustSetEndAndGotoNext.Length < 5) + { + labelAdjustF10.Text = Configuration.Settings.Shortcuts.MainAdjustSetEndAndGotoNext; + } + else + { + labelAdjustF10.Text = string.Empty; + } + + if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainCreateSetStart) && Configuration.Settings.Shortcuts.MainCreateSetStart.Length < 5) + { + labelAdjustF11.Text = Configuration.Settings.Shortcuts.MainCreateSetStart; + labelCreateF11.Text = Configuration.Settings.Shortcuts.MainCreateSetStart; + } + else + { + labelAdjustF11.Text = string.Empty; + labelCreateF11.Text = string.Empty; + } + + if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainCreateSetEnd) && Configuration.Settings.Shortcuts.MainCreateSetEnd.Length < 5) + { + labelAdjustF12.Text = Configuration.Settings.Shortcuts.MainCreateSetEnd; + labelCreateF12.Text = Configuration.Settings.Shortcuts.MainCreateSetEnd; + } + else + { + labelAdjustF12.Text = string.Empty; + labelCreateF12.Text = string.Empty; + } + + if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainCreateInsertSubAtVideoPos) && Configuration.Settings.Shortcuts.MainCreateInsertSubAtVideoPos.Length < 5) + { + labelCreateF9.Text = Configuration.Settings.Shortcuts.MainCreateInsertSubAtVideoPos; + } + else + { + labelCreateF9.Text = string.Empty; + } + + if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore) && Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore.Length < 5) + { + labelCreateF10.Text = Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore; + } + else + { + labelCreateF10.Text = string.Empty; + } + } + + public static object GetPropertiesAndDoAction(string pluginFileName, out string name, out string text, out decimal version, out string description, out string actionType, out string shortcut, out System.Reflection.MethodInfo mi) + { + name = null; + text = null; + version = 0; + description = null; + actionType = null; + shortcut = null; + mi = null; + Assembly assembly; + try + { + assembly = Assembly.Load(File.ReadAllBytes(pluginFileName)); + } + catch + { + return null; + } + + // note: *objectName must not include path or file extension + string objectName = Path.GetFileNameWithoutExtension(pluginFileName); + if (assembly != null) + { + Type pluginType = assembly.GetType("Nikse.SubtitleEdit.PluginLogic." + objectName); + if (pluginType == null) + { + return null; + } + + object pluginObject = Activator.CreateInstance(pluginType); + + // IPlugin + var t = pluginType.GetInterface("IPlugin"); + if (t == null) + { + return null; + } + + PropertyInfo pi = t.GetProperty("Name"); + if (pi != null) + { + name = (string)pi.GetValue(pluginObject, null); + } + + pi = t.GetProperty("Text"); + if (pi != null) + { + text = (string)pi.GetValue(pluginObject, null); + } + + pi = t.GetProperty("Description"); + if (pi != null) + { + description = (string)pi.GetValue(pluginObject, null); + } + + pi = t.GetProperty("Version"); + if (pi != null) + { + version = Convert.ToDecimal(pi.GetValue(pluginObject, null)); + } + + pi = t.GetProperty("ActionType"); + if (pi != null) + { + actionType = (string)pi.GetValue(pluginObject, null); + } + + mi = t.GetMethod("DoAction"); + + pi = t.GetProperty("Shortcut"); + if (pi != null) + { + shortcut = (string)pi.GetValue(pluginObject, null); + } + + return pluginObject; + } + + return null; + } + + private void LoadPlugins() + { + var path = Configuration.PluginsDirectory; + if (!Directory.Exists(path)) + { + return; + } + + UiUtil.CleanUpMenuItemPlugin(fileToolStripMenuItem); + UiUtil.CleanUpMenuItemPlugin(toolsToolStripMenuItem); + UiUtil.CleanUpMenuItemPlugin(toolStripMenuItemSpellCheckMain); + UiUtil.CleanUpMenuItemPlugin(toolStripMenuItemSynchronization); + UiUtil.CleanUpMenuItemPlugin(toolStripMenuItemAutoTranslate); + UiUtil.CleanUpMenuItemPlugin(toolStripMenuItemTranslateSelected); + + var fileMenuItems = new List(); + var toolsMenuItems = new List(); + var translateMenuItems = new List(); + var translateSelectedLinesMenuItems = new List(); + var syncMenuItems = new List(); + var spellCheckMenuItems = new List(); + + foreach (var pluginFileName in Directory.GetFiles(path, "*.DLL")) + { + try + { + GetPropertiesAndDoAction(pluginFileName, out var name, out var text, out var version, out var description, out var actionType, out var shortcut, out var mi); + if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(actionType) && mi != null) + { + var item = new ToolStripMenuItem { Text = text, Tag = pluginFileName }; + UiUtil.FixFonts(item); + + if (!string.IsNullOrEmpty(shortcut)) + { + item.ShortcutKeys = UiUtil.GetKeys(shortcut); + } + + if (actionType.Equals("File", StringComparison.OrdinalIgnoreCase)) + { + AddSeparator(fileMenuItems.Count, fileToolStripMenuItem, 2); + item.Click += PluginToolClick; + fileMenuItems.Add(item); + } + else if (actionType.Equals("Tool", StringComparison.OrdinalIgnoreCase)) + { + AddSeparator(toolsMenuItems.Count, toolsToolStripMenuItem); + item.Click += PluginToolClick; + toolsMenuItems.Add(item); + } + else if (actionType.Equals("Sync", StringComparison.OrdinalIgnoreCase)) + { + AddSeparator(syncMenuItems.Count, toolStripMenuItemSynchronization); + item.Click += PluginToolClick; + syncMenuItems.Add(item); + } + else if (actionType.Equals("Translate", StringComparison.OrdinalIgnoreCase)) + { + AddSeparator(translateMenuItems.Count, toolStripMenuItemAutoTranslate); + item.Click += PluginClickTranslate; + translateMenuItems.Add(item); + + // selected lines + item = new ToolStripMenuItem(); + item.Text = text; + item.Tag = pluginFileName; + UiUtil.FixFonts(item); + AddSeparator(translateMenuItems.Count - 1, toolStripMenuItemTranslateSelected); + item.Click += PluginClickTranslateSelectedLines; + translateSelectedLinesMenuItems.Add(item); + } + else if (actionType.Equals("SpellCheck", StringComparison.OrdinalIgnoreCase)) + { + AddSeparator(spellCheckMenuItems.Count, toolStripMenuItemSpellCheckMain); + item.Click += PluginClickNoFormatChange; + spellCheckMenuItems.Add(item); + } + } + } + catch (Exception exception) + { + MessageBox.Show(string.Format(_language.ErrorLoadingPluginXErrorY, pluginFileName, exception.Message)); + } + } + foreach (var fileMenuItem in fileMenuItems) + { + fileToolStripMenuItem.DropDownItems.Insert(fileToolStripMenuItem.DropDownItems.Count - 2, fileMenuItem); + } + toolsToolStripMenuItem.DropDownItems.AddRange(toolsMenuItems.OrderBy(p => p.Text).ToArray()); + toolStripMenuItemAutoTranslate.DropDownItems.AddRange(translateMenuItems.OrderBy(p => p.Text).ToArray()); + toolStripMenuItemTranslateSelected.DropDownItems.AddRange(translateSelectedLinesMenuItems.OrderBy(p => p.Text).ToArray()); + toolStripMenuItemSynchronization.DropDownItems.AddRange(syncMenuItems.OrderBy(p => p.Text).ToArray()); + toolStripMenuItemSpellCheckMain.DropDownItems.AddRange(spellCheckMenuItems.OrderBy(p => p.Text).ToArray()); + } + + private void AddSeparator(int pluginCount, ToolStripMenuItem parent, int? relativeOffset = null) + { + if (pluginCount == 0) + { + var tss = new ToolStripSeparator(); + if (relativeOffset == null) + { + if (parent.DropDownItems.Count > 0 && parent.DropDownItems[parent.DropDownItems.Count - 1].GetType() == typeof(ToolStripSeparator)) + { + return; // don't app separator after separator + } + + parent.DropDownItems.Add(tss); + } + else + { + if (parent.DropDownItems.Count - relativeOffset.Value >= 0 && + relativeOffset.Value < parent.DropDownItems.Count && + parent.DropDownItems.Count > 0 && + parent.DropDownItems[parent.DropDownItems.Count - relativeOffset.Value].GetType() == typeof(ToolStripSeparator)) + { + return; // don't app separator after separator + } + + parent.DropDownItems.Insert(parent.DropDownItems.Count - relativeOffset.Value, tss); + } + + UiUtil.FixFonts(tss); + } + } + + private void PluginToolClick(object sender, EventArgs e) + { + CallPlugin(sender, true, false); + } + + private void PluginClickNoFormatChange(object sender, EventArgs e) + { + CallPlugin(sender, false, false); + } + + private void PluginClickTranslate(object sender, EventArgs e) + { + CallPlugin(sender, false, true); + } + + private void PluginClickTranslateSelectedLines(object sender, EventArgs e) + { + CallPluginTranslateSelectedLines(sender); + } + + private void CallPlugin(object sender, bool allowChangeFormat, bool translate) + { + try + { + var item = (ToolStripItem)sender; + var pluginObject = GetPropertiesAndDoAction(item.Tag.ToString(), out var name, out var text, out var version, out var description, out var actionType, out var shortcut, out var mi); + if (mi == null) + { + return; + } + + string rawText = null; + var format = GetCurrentSubtitleFormat(); + if (format != null) + { + rawText = _subtitle.ToText(format); + } + + string pluginResult = (string)mi.Invoke(pluginObject, + new object[] + { + this, + _subtitle.ToText(new SubRip()), + Configuration.Settings.General.CurrentFrameRate, + Configuration.Settings.General.ListViewLineSeparatorString, + _fileName, + VideoFileName, + rawText + }); + + if (!string.IsNullOrEmpty(pluginResult) && pluginResult.Length > 10 && text != pluginResult) + { + var lines = new List(pluginResult.SplitToLines()); + + MakeHistoryForUndo(string.Format(_language.BeforeRunningPluginXVersionY, name, version)); + + var s = new Subtitle(); + SubtitleFormat newFormat = null; + foreach (var subtitleFormat in SubtitleFormat.AllSubtitleFormats) + { + if (subtitleFormat.IsMine(lines, null)) + { + subtitleFormat.LoadSubtitle(s, lines, null); + newFormat = subtitleFormat; + break; + } + } + + if (translate) + { + _subtitleAlternate = new Subtitle(_subtitle); + _subtitleAlternateFileName = _fileName; + + var language = LanguageAutoDetect.AutoDetectGoogleLanguageOrNull(s); + if (language != null && !string.IsNullOrEmpty(_fileName)) + { + _fileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); + var oldLang = "." + LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate); + if (oldLang.Length == 3 && _fileName.EndsWith(oldLang, StringComparison.OrdinalIgnoreCase)) + { + _fileName = _fileName.Remove(_fileName.Length - 3); + } + + _fileName += "." + language + GetCurrentSubtitleFormat().Extension; + } + else + { + _fileName = null; + } + + _subtitle.Paragraphs.Clear(); + foreach (var p in s.Paragraphs) + { + _subtitle.Paragraphs.Add(new Paragraph(p)); + } + + ShowStatus(_language.SubtitleTranslated); + ShowSource(); + SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); + SubtitleListview1.AutoSizeAllColumns(this); + SetupAlternateEdit(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + ResetHistory(); + RestoreSubtitleListviewIndices(); + _converted = true; + SetTitle(); + return; + } + + if (newFormat != null) + { + if (allowChangeFormat && newFormat.GetType() == typeof(SubRip) && IsOnlyTextChanged(_subtitle, s)) + { + allowChangeFormat = false; + } + + if (!allowChangeFormat && IsOnlyTextChanged(_subtitle, s)) + { + for (int k = 0; k < s.Paragraphs.Count; k++) + { + _subtitle.Paragraphs[k].Text = s.Paragraphs[k].Text; + } + } + else + { + _subtitle.Paragraphs.Clear(); + _subtitle.Header = s.Header; + _subtitle.Footer = s.Footer; + foreach (var p in s.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + } + + if (allowChangeFormat) + { + SetCurrentFormat(newFormat); + } + + SaveSubtitleListviewIndices(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + ShowSource(); + + ShowStatus(string.Format(_language.PluginXExecuted, name)); + } + else + { + MessageBox.Show(_language.UnableToReadPluginResult); + } + } + } + catch (Exception exception) + { + MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace); + if (exception.InnerException != null) + { + MessageBox.Show(exception.InnerException.Message + Environment.NewLine + exception.InnerException.StackTrace); + } + } + } + + private void CallPluginTranslateSelectedLines(object sender) + { + try + { + var item = (ToolStripItem)sender; + var pluginObject = GetPropertiesAndDoAction(item.Tag.ToString(), out var name, out var text, out var version, out var description, out var actionType, out var shortcut, out var mi); + if (mi == null) + { + return; + } + + SaveSubtitleListviewIndices(); + var selectedLines = new Subtitle(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.Paragraphs[index]; + if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + var original = Utilities.GetOriginalParagraph(index, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + p = original; + } + else + { + p = new Paragraph(string.Empty, p.StartTime.TotalMilliseconds, p.EndTime.TotalMilliseconds); + } + } + + selectedLines.Paragraphs.Add(p); + } + + string rawText = null; + SubtitleFormat format = GetCurrentSubtitleFormat(); + if (format != null) + { + rawText = selectedLines.ToText(format); + } + + string pluginResult = (string)mi.Invoke(pluginObject, + new object[] + { + this, + selectedLines.ToText(new SubRip()), + Configuration.Settings.General.CurrentFrameRate, + Configuration.Settings.General.ListViewLineSeparatorString, + _fileName, + VideoFileName, + rawText + }); + + if (!string.IsNullOrEmpty(pluginResult) && pluginResult.Length > 10 && text != pluginResult) + { + var lines = new List(pluginResult.SplitToLines()); + MakeHistoryForUndo(string.Format(_language.BeforeRunningPluginXVersionY, name, version)); + var s = new Subtitle(); + var f = new SubRip(); + if (f.IsMine(lines, null)) + { + f.LoadSubtitle(s, lines, null); + + // we only update selected lines + int i = 0; + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index] = s.Paragraphs[i]; + i++; + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + ShowStatus(string.Format(_language.PluginXExecuted, name)); + } + } + } + catch (Exception exception) + { + MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace); + if (exception.InnerException != null) + { + MessageBox.Show(exception.InnerException.Message + Environment.NewLine + exception.InnerException.StackTrace); + } + } + } + + private bool IsOnlyTextChanged(Subtitle s1, Subtitle s2) + { + if (s1.Paragraphs.Count != s2.Paragraphs.Count) + { + return false; + } + + for (int i = 0; i < s1.Paragraphs.Count; i++) + { + var p1 = s1.Paragraphs[i]; + var p2 = s2.Paragraphs[i]; + if (Math.Abs(p1.StartTime.TotalMilliseconds - p2.StartTime.TotalMilliseconds) > 0.01) + { + return false; + } + + if (Math.Abs(p1.EndTime.TotalMilliseconds - p2.EndTime.TotalMilliseconds) > 0.01) + { + return false; + } + } + + return true; + } + + private string _lastWrittenAutoBackup = string.Empty; + private bool _showAutoBackupError = true; + + private void TimerAutoBackupTick(object sender, EventArgs e) + { + string currentText = string.Empty; + if (_subtitle != null && _subtitle.Paragraphs.Count > 0) + { + var saveFormat = GetCurrentSubtitleFormat(); + if (!saveFormat.IsTextBased) + { + saveFormat = new SubRip(); + } + + currentText = _subtitle.ToText(saveFormat); + if (_textAutoBackup == null) + { + _textAutoBackup = currentText; + } + + if ((Configuration.Settings.General.AutoSave || + !string.IsNullOrEmpty(_textAutoBackup) && currentText.Trim() != _textAutoBackup.Trim() && !string.IsNullOrWhiteSpace(currentText)) && + _lastWrittenAutoBackup != currentText) + { + if (!Directory.Exists(Configuration.AutoBackupDirectory)) + { + try + { + Directory.CreateDirectory(Configuration.AutoBackupDirectory); + } + catch (Exception exception) + { + 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.AutoBackupDirectory, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, title, saveFormat.Extension); + try + { + File.WriteAllText(fileName, currentText); + _lastWrittenAutoBackup = currentText; + } + catch (Exception exception) + { + if (_showAutoBackupError) + { + MessageBox.Show("Unable to save auto-backup to file: " + fileName + Environment.NewLine + + Environment.NewLine + + exception.Message + Environment.NewLine + exception.StackTrace); + _showAutoBackupError = false; + } + } + + if (!_cleanupHasRun) + { + // let the cleanup process be handled by worker thread + System.Threading.Tasks.Task.Factory.StartNew(() => { RestoreAutoBackup.CleanAutoBackupFolder(Configuration.AutoBackupDirectory, Configuration.Settings.General.AutoBackupDeleteAfterMonths); }); + _cleanupHasRun = true; + } + } + } + + _textAutoBackup = currentText; + + if (_subtitleAlternateFileName != null && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + var saveFormat = GetCurrentSubtitleFormat(); + if (!saveFormat.IsTextBased) + { + saveFormat = new SubRip(); + } + + string currentTextAlternate = _subtitleAlternate.ToText(saveFormat); + if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + if (_textAutoBackupOriginal == null) + { + _textAutoBackupOriginal = currentTextAlternate; + } + + if (Configuration.Settings.General.AutoSave || + !string.IsNullOrEmpty(_textAutoBackupOriginal) && currentTextAlternate.Trim() != _textAutoBackupOriginal.Trim() && !string.IsNullOrWhiteSpace(currentTextAlternate)) + { + if (!Directory.Exists(Configuration.AutoBackupDirectory)) + { + try + { + Directory.CreateDirectory(Configuration.AutoBackupDirectory); + } + catch (Exception exception) + { + MessageBox.Show(string.Format(_language.UnableToCreateBackupDirectory, Configuration.AutoBackupDirectory, exception.Message)); + return; + } + } + + 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.AutoBackupDirectory, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, "_Original" + title, saveFormat.Extension); + File.WriteAllText(fileName, currentTextAlternate); + } + } + + _textAutoBackupOriginal = currentTextAlternate; + } + } + + private void DropVideoTick(object sender, EventArgs e) + { + _dragAndDropVideoTimer.Stop(); + OpenVideo(VideoFileName); + } + + private void mediaPlayer_DragDrop(object sender, DragEventArgs e) + { + var files = (string[])e.Data.GetData(DataFormats.FileDrop); + if (files.Length == 1) + { + string fileName = files[0]; + string ext = Path.GetExtension(fileName).ToLowerInvariant(); + if (Utilities.GetVideoFileFilter(true).Contains(ext)) + { + if (string.IsNullOrEmpty(_fileName)) + { + var dirName = Path.GetDirectoryName(fileName); + saveFileDialog1.InitialDirectory = dirName; + openFileDialog1.InitialDirectory = dirName; + } + + VideoFileName = fileName; + _dragAndDropVideoTimer.Start(); + } + else + { + try + { + var fi = new FileInfo(fileName); + if (fi.Length < Subtitle.MaxFileSize) + { + var lines = new List(File.ReadAllLines(fileName)); + foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) + { + if (format.IsMine(lines, fileName)) + { + OpenSubtitle(fileName, null); + return; + } + } + } + } + catch + { + } + + MessageBox.Show(string.Format(_language.DropFileXNotAccepted, fileName)); + } + } + else + { + MessageBox.Show(_language.DropOnlyOneFile); + } + } + + private void mediaPlayer_DragEnter(object sender, DragEventArgs e) + { + // make sure they're actually dropping files (not text or anything else) + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.All; + } + } + + private void buttonSecBack2_Click(object sender, EventArgs e) + { + GoBackSeconds((double)numericUpDownSec2.Value); + } + + private void buttonForward2_Click(object sender, EventArgs e) + { + GoBackSeconds(-(double)numericUpDownSec2.Value); + } + + private void buttonAdjustSecBack2_Click(object sender, EventArgs e) + { + GoBackSeconds((double)numericUpDownSecAdjust2.Value); + } + + private void buttonAdjustSecForward2_Click(object sender, EventArgs e) + { + GoBackSeconds(-(double)numericUpDownSecAdjust2.Value); + } + + private void translatepoweredByMicrosoftToolStripMenuItem_Click(object sender, EventArgs e) + { + TranslateViaGoogle(false, false); + } + + private void AudioWaveform_Click(object sender, EventArgs e) + { + if (audioVisualizer.WavePeaks == null) + { + if (VideoFileName != null && (VideoFileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || + VideoFileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase))) + { + return; + } + + if (string.IsNullOrEmpty(VideoFileName)) + { + buttonOpenVideo_Click(sender, e); + if (string.IsNullOrEmpty(VideoFileName)) + { + return; + } + + if (audioVisualizer.WavePeaks != null && File.Exists(WavePeakGenerator.GetPeakWaveFileName(VideoFileName))) + { + return; // waveform already exists and is loaded + } + } + + mediaPlayer.Pause(); + using (var addWaveform = new AddWaveform()) + { + var videoAudioTrackNumber = VideoAudioTrackNumber; + if (mediaPlayer.VideoPlayer is LibVlcDynamic && VideoAudioTrackNumber != -1) + { + videoAudioTrackNumber -= 1; + } + + var peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(VideoFileName, videoAudioTrackNumber); + var spectrogramFolder = WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(VideoFileName, videoAudioTrackNumber); + + if (WavePeakGenerator.IsFileValidForVisualizer(VideoFileName)) + { + addWaveform.InitializeViaWaveFile(VideoFileName, peakWaveFileName, spectrogramFolder); + } + else + { + addWaveform.Initialize(VideoFileName, peakWaveFileName, spectrogramFolder, videoAudioTrackNumber); + } + + if (addWaveform.ShowDialog() == DialogResult.OK) + { + audioVisualizer.ZoomFactor = 1.0; + audioVisualizer.VerticalZoomFactor = 1.0; + SelectZoomTextInComboBox(); + audioVisualizer.WavePeaks = addWaveform.Peaks; + audioVisualizer.SetSpectrogram(addWaveform.Spectrogram); + timerWaveform.Start(); + } + + if (videoAudioTrackNumber != addWaveform.AudioTrackNumber) + { + if (mediaPlayer.VideoPlayer is LibVlcDynamic libVlc) + { + libVlc.AudioTrackNumber = addWaveform.AudioTrackNumber + 1; + VideoAudioTrackNumber = addWaveform.AudioTrackNumber + 1; + } + else if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv) + { + libMpv.AudioTrackNumber = addWaveform.AudioTrackNumber; + VideoAudioTrackNumber = addWaveform.AudioTrackNumber; + } + } + } + + if (mediaPlayer.Chapters?.Count > 0) + { + audioVisualizer.Chapters = mediaPlayer.Chapters; + } + } + } + + private void ReloadWaveform(string fileName, int audioTrackNumber) + { + if (audioVisualizer.WavePeaks != null) + { + audioVisualizer.WavePeaks = null; + audioVisualizer.SetSpectrogram(null); + audioVisualizer.SceneChanges = new List(); + audioVisualizer.Chapters = new List(); + } + + if (mediaPlayer.VideoPlayer is LibVlcDynamic && audioTrackNumber != -1) + { + audioTrackNumber -= 1; + } + + var peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(fileName, audioTrackNumber); + var spectrogramFolder = WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(VideoFileName, audioTrackNumber); + + if (File.Exists(peakWaveFileName)) + { + audioVisualizer.ZoomFactor = 1.0; + audioVisualizer.VerticalZoomFactor = 1.0; + SelectZoomTextInComboBox(); + audioVisualizer.WavePeaks = WavePeakData.FromDisk(peakWaveFileName); + audioVisualizer.SetSpectrogram(SpectrogramData.FromDisk(spectrogramFolder)); + audioVisualizer.SceneChanges = SceneChangeHelper.FromDisk(VideoFileName); + SetWaveformPosition(0, 0, 0); + timerWaveform.Start(); + } + } + + private void timerWaveform_Tick(object sender, EventArgs e) + { + if (audioVisualizer.Visible && mediaPlayer.VideoPlayer != null && audioVisualizer.WavePeaks != null) + { + int index = -1; + if (SubtitleListview1.SelectedItems.Count > 0) + { + index = SubtitleListview1.SelectedItems[0].Index; + } + + if (audioVisualizer.Locked) + { + double startPos = mediaPlayer.CurrentPosition - ((audioVisualizer.EndPositionSeconds - audioVisualizer.StartPositionSeconds) / 2.0); + if (startPos < 0) + { + startPos = 0; + } + + SetWaveformPosition(startPos, mediaPlayer.CurrentPosition, index); + } + else if (mediaPlayer.CurrentPosition > audioVisualizer.EndPositionSeconds || mediaPlayer.CurrentPosition < audioVisualizer.StartPositionSeconds) + { + double startPos = mediaPlayer.CurrentPosition - 0.01; + if (startPos < 0) + { + startPos = 0; + } + + audioVisualizer.ClearSelection(); + SetWaveformPosition(startPos, mediaPlayer.CurrentPosition, index); + } + else + { + SetWaveformPosition(audioVisualizer.StartPositionSeconds, mediaPlayer.CurrentPosition, index); + } + + bool paused = mediaPlayer.IsPaused; + toolStripButtonWaveformPause.Visible = !paused; + toolStripButtonWaveformPlay.Visible = paused; + } + else + { + toolStripButtonWaveformPlay.Visible = true; + toolStripButtonWaveformPause.Visible = false; + } + } + + private void addParagraphHereToolStripMenuItem_Click(object sender, EventArgs e) + { + audioVisualizer.ClearSelection(); + var newParagraph = new Paragraph(audioVisualizer.NewSelectionParagraph); + + mediaPlayer.Pause(); + + // find index where to insert + int index = 0; + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + var p = _subtitle.Paragraphs[i]; + if (p.StartTime.TotalMilliseconds > newParagraph.StartTime.TotalMilliseconds && + (!p.StartTime.IsMaxTime || !HasSmallerStartTimes(_subtitle, i + 1, newParagraph.StartTime.TotalMilliseconds))) + { + break; + } + + index++; + } + + SetStyleForNewParagraph(newParagraph, index); + + MakeHistoryForUndo(_language.BeforeInsertLine); + + // create and insert + if (_networkSession != null) + { + _networkSession.TimerStop(); + NetworkGetSendUpdates(new List(), index, newParagraph); + } + else + { + _subtitle.Paragraphs.Insert(index, newParagraph); + + if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph)); + _subtitleAlternate.Renumber(); + } + + _subtitleListViewIndex = -1; + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + + textBoxListViewText.Focus(); + audioVisualizer.NewSelectionParagraph = null; + + ShowStatus(string.Format(_language.VideoControls.NewTextInsertAtX, newParagraph.StartTime.ToShortString())); + audioVisualizer.Invalidate(); + } + + private static bool HasSmallerStartTimes(Subtitle subtitle, int startIndex, double startMs) + { + for (int i = startIndex; i < subtitle.Paragraphs.Count; i++) + { + var p = subtitle.Paragraphs[i]; + if (startMs > p.StartTime.TotalMilliseconds && !p.StartTime.IsMaxTime) + { + return true; + } + } + + return false; + } + + private void addParagraphAndPasteToolStripMenuItem_Click(object sender, EventArgs e) + { + addParagraphHereToolStripMenuItem_Click(sender, e); + textBoxListViewText.Text = Clipboard.GetText(); + } + + private void mergeWithPreviousToolStripMenuItem_Click(object sender, EventArgs e) + { + int index = _subtitle.GetIndex(audioVisualizer.RightClickedParagraph); + if (index >= 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + MergeBeforeToolStripMenuItemClick(null, null); + } + + audioVisualizer.Invalidate(); + } + + private void deleteParagraphToolStripMenuItem_Click(object sender, EventArgs e) + { + int index = _subtitle.GetIndex(audioVisualizer.RightClickedParagraph); + if (index >= 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + ToolStripMenuItemDeleteClick(null, null); + } + + audioVisualizer.Invalidate(); + } + + private void splitToolStripMenuItem1_Click(object sender, EventArgs e) + { + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + if (audioVisualizer.RightClickedParagraph.StartTime.TotalMilliseconds == _subtitle.Paragraphs[i].StartTime.TotalMilliseconds && + audioVisualizer.RightClickedParagraph.EndTime.TotalMilliseconds == _subtitle.Paragraphs[i].EndTime.TotalMilliseconds) + { + SubtitleListview1.SelectIndexAndEnsureVisible(i, true); + SplitSelectedParagraph(_audioWaveformRightClickSeconds, null); + break; + } + } + + audioVisualizer.Invalidate(); + } + + private void mergeWithNextToolStripMenuItem_Click(object sender, EventArgs e) + { + int index = _subtitle.GetIndex(audioVisualizer.RightClickedParagraph); + if (index >= 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + MergeAfterToolStripMenuItemClick(null, null); + } + + audioVisualizer.Invalidate(); + } + + private void extendToPreviousToolStripMenuItem_Click(object sender, EventArgs e) + { + int index = _subtitle.GetIndex(audioVisualizer.RightClickedParagraph); + if (index >= 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + ExtendSelectedLinesToPreviousLine(); + } + + audioVisualizer.Invalidate(); + } + + private void extendToNextToolStripMenuItem_Click(object sender, EventArgs e) + { + int index = _subtitle.GetIndex(audioVisualizer.RightClickedParagraph); + if (index >= 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + ExtendSelectedLinesToNextLine(); + } + + audioVisualizer.Invalidate(); + } + + private void goToPreviousSubtitleToolStripMenuItem_Click(object sender, EventArgs e) + { + if (audioVisualizer.RightClickedParagraph != null) + { + GoToPreviousSubtitle(audioVisualizer.RightClickedParagraph.StartTime.TotalMilliseconds); + } + else + { + GoToPreviousSubtitle(mediaPlayer.CurrentPosition * TimeCode.BaseUnit); + } + } + + private void goToNextSubtitleToolStripMenuItem_Click(object sender, EventArgs e) + { + if (audioVisualizer.RightClickedParagraph != null) + { + GoToNextSubtitle(audioVisualizer.RightClickedParagraph.StartTime.TotalMilliseconds); + } + else + { + GoToNextSubtitle(mediaPlayer.CurrentPosition * TimeCode.BaseUnit); + } + } + + private void buttonWaveformZoomIn_Click(object sender, EventArgs e) + { + if (audioVisualizer.WavePeaks != null && audioVisualizer.Visible) + { + audioVisualizer.ZoomFactor += 0.1; + } + } + + private void buttonWaveformZoomOut_Click(object sender, EventArgs e) + { + if (audioVisualizer.WavePeaks != null && audioVisualizer.Visible) + { + audioVisualizer.ZoomFactor -= 0.1; + } + } + + private void buttonWaveformZoomReset_Click(object sender, EventArgs e) + { + if (audioVisualizer.WavePeaks != null && audioVisualizer.Visible) + { + audioVisualizer.ZoomFactor = 1.0; + } + } + + private void toolStripMenuItemWaveformPlaySelection_Click(object sender, EventArgs e) + { + WaveformPlaySelection(); + } + + private void WaveformPlaySelection(bool nearEnd = false) + { + if (mediaPlayer.VideoPlayer != null) + { + var p = + audioVisualizer.NewSelectionParagraph ?? + audioVisualizer.SelectedParagraph; + + if (p != null) + { + double startSeconds = p.StartTime.TotalSeconds; + _endSeconds = p.EndTime.TotalSeconds; + if (nearEnd) + { + startSeconds = Math.Max(startSeconds, _endSeconds - 1.0); + } + + mediaPlayer.CurrentPosition = startSeconds; + UiUtil.ShowSubtitle(_subtitle, mediaPlayer); + mediaPlayer.Play(); + } + } + } + + private void toolStripButtonWaveformZoomIn_Click(object sender, EventArgs e) + { + if (audioVisualizer.WavePeaks != null && audioVisualizer.Visible) + { + audioVisualizer.ZoomFactor += 0.1; + SelectZoomTextInComboBox(); + } + } + + private void toolStripButtonWaveformZoomOut_Click(object sender, EventArgs e) + { + if (audioVisualizer.WavePeaks != null && audioVisualizer.Visible) + { + audioVisualizer.ZoomFactor -= 0.1; + SelectZoomTextInComboBox(); + } + } + + private void toolStripComboBoxWaveform_SelectedIndexChanged(object sender, EventArgs e) + { + try + { + if (toolStripComboBoxWaveform.SelectedItem is ComboBoxZoomItem item) + { + audioVisualizer.ZoomFactor = item.ZoomFactor; + } + } + catch + { + // ignore + } + } + + private void SelectZoomTextInComboBox() + { + int i = 0; + foreach (ComboBoxZoomItem item in toolStripComboBoxWaveform.Items) + { + if (Math.Abs(audioVisualizer.ZoomFactor - item.ZoomFactor) < 0.001) + { + toolStripComboBoxWaveform.SelectedIndex = i; + return; + } + + i++; + } + } + + private void toolStripButtonWaveformPause_Click(object sender, EventArgs e) + { + mediaPlayer.Pause(); + } + + private void toolStripButtonWaveformPlay_Click(object sender, EventArgs e) + { + mediaPlayer.Play(); + } + + private void toolStripButtonLockCenter_Click(object sender, EventArgs e) + { + toolStripButtonLockCenter.Checked = !toolStripButtonLockCenter.Checked; + audioVisualizer.Locked = toolStripButtonLockCenter.Checked; + Configuration.Settings.General.WaveformCenter = audioVisualizer.Locked; + } + + private void trackBarWaveformPosition_ValueChanged(object sender, EventArgs e) + { + mediaPlayer.CurrentPosition = trackBarWaveformPosition.Value; + } + + private void buttonCustomUrl_Click(object sender, EventArgs e) + { + RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl1); + } + + private void buttonCustomUrl2_Click(object sender, EventArgs e) + { + RunCustomSearch(Configuration.Settings.VideoControls.CustomSearchUrl2); + } + + private void ShowhideWaveformToolStripMenuItemClick(object sender, EventArgs e) + { + toolStripButtonToggleWaveform_Click(null, null); + } + + private void AudioWaveformDragEnter(object sender, DragEventArgs e) + { + // make sure they're actually dropping files (not text or anything else) + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.All; + } + } + + private void AudioWaveformDragDrop(object sender, DragEventArgs e) + { + var files = (string[])e.Data.GetData(DataFormats.FileDrop); + if (files.Length != 1) + { + MessageBox.Show(_language.DropOnlyOneFile); + return; + } + + string fileName = files[0]; + string ext = Path.GetExtension(fileName).ToLowerInvariant(); + if (ext != ".wav" || !WavePeakGenerator.IsFileValidForVisualizer(fileName)) + { + if (audioVisualizer.WavePeaks == null && (Utilities.VideoFileExtensions.Contains(ext) || Utilities.AudioFileExtensions.Contains(ext))) + { + VideoFileName = fileName; + AudioWaveform_Click(null, null); + OpenVideo(VideoFileName); + return; + } + + try + { + var fi = new FileInfo(fileName); + if (fi.Length < 1024 * 500) + { + var lines = new List(File.ReadAllLines(fileName)); + foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) + { + if (format.IsMine(lines, fileName)) + { + OpenSubtitle(fileName, null); + return; + } + } + } + } + catch + { + } + } + + if (ext != ".wav") + { + MessageBox.Show(".wav only!"); + return; + } + + if (VideoFileName == null) + { + OpenVideo(fileName); + return; + } + + using (var addWaveform = new AddWaveform()) + { + string peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(VideoFileName); + string spectrogramFolder = WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(VideoFileName); + addWaveform.InitializeViaWaveFile(fileName, peakWaveFileName, spectrogramFolder); + if (addWaveform.ShowDialog() == DialogResult.OK) + { + audioVisualizer.WavePeaks = addWaveform.Peaks; + audioVisualizer.SetSpectrogram(addWaveform.Spectrogram); + timerWaveform.Start(); + } + } + } + + private void toolStripMenuItemImportBluRaySup_Click(object sender, EventArgs e) + { + if (ContinueNewOrExit()) + { + openFileDialog1.Title = _language.OpenBluRaySupFile; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = _language.BluRaySupFiles + "|*.sup"; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + if (!FileUtil.IsBluRaySup(openFileDialog1.FileName) && FileUtil.IsSpDvdSup(openFileDialog1.FileName)) + { + ImportAndOcrSpDvdSup(openFileDialog1.FileName, false); + return; + } + + ImportAndOcrBluRaySup(openFileDialog1.FileName, false); + } + } + } + + private void ImportAndOcrBluRaySup(string fileName, bool showInTaskbar) + { + var log = new StringBuilder(); + var subtitles = BluRaySupParser.ParseBluRaySup(fileName, log); + if (subtitles.Count == 0) + { + string msg = _language.BlurayNotSubtitlesFound + Environment.NewLine + Environment.NewLine + log.ToString(); + if (msg.Length > 800) + { + msg = msg.Substring(0, 800); + } + + MessageBox.Show(msg.Trim() + "..."); + return; + } + + using (var vobSubOcr = new VobSubOcr()) + { + if (showInTaskbar) + { + vobSubOcr.Icon = (Icon)Icon.Clone(); + vobSubOcr.ShowInTaskbar = true; + vobSubOcr.ShowIcon = true; + } + + vobSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, fileName); + vobSubOcr.FileName = Path.GetFileName(fileName); + if (vobSubOcr.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeImportingBluRaySupFile); + FileNew(); + _subtitle.Paragraphs.Clear(); + SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat); + foreach (var p in vobSubOcr.SubtitleFromOcr.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + _subtitleListViewIndex = -1; + SubtitleListview1.FirstVisibleIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + + _fileName = Path.ChangeExtension(fileName, GetCurrentSubtitleFormat().Extension); + SetTitle(); + _converted = true; + + Configuration.Settings.Save(); + } + else + { + _exitWhenLoaded = _loading; + } + } + } + + private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) + { + GetFocusedTextBox().SelectAll(); + } + + private void cutToolStripMenuItem_Click(object sender, EventArgs e) + { + GetFocusedTextBox().Cut(); + } + + private void copyToolStripMenuItem_Click(object sender, EventArgs e) + { + GetFocusedTextBox().Copy(); + } + + private void PasteToolStripMenuItemClick(object sender, EventArgs e) + { + GetFocusedTextBox().Paste(); + } + + private void DeleteToolStripMenuItemClick(object sender, EventArgs e) + { + GetFocusedTextBox().SelectedText = string.Empty; + } + + private void NormalToolStripMenuItem1Click(object sender, EventArgs e) + { + var tb = GetFocusedTextBox(); + + if (tb.SelectionLength == 0) + { + var allText = HtmlUtil.RemoveHtmlTags(tb.Text); + allText = NetflixImsc11Japanese.RemoveTags(allText); + tb.Text = allText; + return; + } + + string text = tb.SelectedText; + int selectionStart = tb.SelectionStart; + text = HtmlUtil.RemoveHtmlTags(text); + text = NetflixImsc11Japanese.RemoveTags(text); + tb.SelectedText = text; + tb.SelectionStart = selectionStart; + tb.SelectionLength = text.Length; + } + + private SETextBox GetFocusedTextBox() + { + if (!textBoxListViewTextAlternate.Visible) + { + return textBoxListViewText; + } + + return textBoxListViewTextAlternate.Focused ? textBoxListViewTextAlternate : textBoxListViewText; + } + + private void TextBoxListViewToggleTag(string tag) + { + var tb = GetFocusedTextBox(); + + string text; + int selectionStart = tb.SelectionStart; + + // No text selected. + if (tb.SelectedText.Length == 0) + { + text = tb.Text; + + // Split lines (split a subtitle into its lines). + var lines = text.SplitToLines(); + + // Get current line index (the line where the cursor is current located). + int numberOfNewLines = 0; + for (int i = 0; i < tb.SelectionStart && i < text.Length; i++) + { + if (text[i] == '\n') + { + numberOfNewLines++; + } + } + int selectedLineIdx = numberOfNewLines; // Do not use 'GetLineFromCharIndex' as it also counts when lines are wrapped + + // Get line from index. + string selectedLine = lines[selectedLineIdx]; + + // Test if line at where cursor is current at is a dialog. + bool isDialog = selectedLine.StartsWith('-') || + selectedLine.StartsWith("<" + tag + ">-", StringComparison.OrdinalIgnoreCase); + + // Will be used keep cursor in its previous location after toggle/untoggle. + int textLen = text.Length; + + // 1st set the cursor position to zero. + tb.SelectionStart = 0; + + // If is dialog, only toggle/Untoggle line where caret/cursor is current at. + if (isDialog) + { + lines[selectedLineIdx] = HtmlUtil.ToggleTag(selectedLine, tag); + text = string.Join(Environment.NewLine, lines); + } + else + { + text = HtmlUtil.ToggleTag(text, tag); + } + + tb.Text = text; + // Note: Math.Max will prevent blowing if caret is at the begining and tag was untoggled. + tb.SelectionStart = textLen > text.Length ? Math.Max(selectionStart - 3, 0) : selectionStart + 3; + } + else + { + string post = string.Empty; + string pre = string.Empty; + // There is text selected + text = tb.SelectedText; + while (text.EndsWith(' ') || text.EndsWith(Environment.NewLine, StringComparison.Ordinal) || text.StartsWith(' ') || text.StartsWith(Environment.NewLine, StringComparison.Ordinal)) + { + if (text.EndsWith(' ')) + { + post += " "; + text = text.Remove(text.Length - 1); + } + + if (text.EndsWith(Environment.NewLine, StringComparison.Ordinal)) + { + post += Environment.NewLine; + text = text.Remove(text.Length - 2); + } + + if (text.StartsWith(' ')) + { + pre += " "; + text = text.Remove(0, 1); + } + + if (text.StartsWith(Environment.NewLine, StringComparison.Ordinal)) + { + pre += Environment.NewLine; + text = text.Remove(0, 2); + } + } + + text = HtmlUtil.ToggleTag(text, tag); + // Update text and maintain selection. + if (pre.Length > 0) + { + text = pre + text; + selectionStart += pre.Length; + } + + if (post.Length > 0) + { + text = text + post; + } + + tb.SelectedText = text; + tb.SelectionStart = selectionStart; + tb.SelectionLength = text.Length; + } + } + + private void BoldToolStripMenuItem1Click(object sender, EventArgs e) + { + TextBoxListViewToggleTag(HtmlUtil.TagBold); + } + + private void ItalicToolStripMenuItem1Click(object sender, EventArgs e) + { + TextBoxListViewToggleTag(HtmlUtil.TagItalic); + } + + private void UnderlineToolStripMenuItem1Click(object sender, EventArgs e) + { + TextBoxListViewToggleTag(HtmlUtil.TagUnderline); + } + + private void ColorToolStripMenuItem1Click(object sender, EventArgs e) + { + var tb = GetFocusedTextBox(); + string text = tb.SelectedText; + if (string.IsNullOrEmpty(text) && tb.Text.Length > 0) + { + text = tb.Text; + tb.SelectAll(); + } + int selectionStart = tb.SelectionStart; + + string color; + var formatType = GetCurrentSubtitleFormat().GetType(); + if (formatType == typeof(Ebu)) + { + using (var form = new EbuColorPicker(true)) + { + if (form.ShowDialog(this) != DialogResult.OK) + { + return; + } + + color = form.Color; + } + } + else if (formatType == typeof(ScenaristClosedCaptions) || formatType == typeof(ScenaristClosedCaptionsDropFrame)) + { + using (var form = new EbuColorPicker(false)) + { + if (form.ShowDialog(this) != DialogResult.OK) + { + return; + } + + color = form.Color; + } + } + else + { + if (colorDialog1.ShowDialog(this) != DialogResult.OK) + { + return; + } + + color = Utilities.ColorToHex(colorDialog1.Color); + } + + bool done = false; + string pre = string.Empty; + if (selectionStart == 0 && text.StartsWith("{\\", StringComparison.Ordinal) && text.IndexOf('}') >= 0) + { + int endIndex = text.IndexOf('}') + 1; + pre = text.Substring(0, endIndex); + text = text.Remove(0, endIndex); + } + + string s = text; + if (s.StartsWith("'); + if (end > 0) + { + string f = s.Substring(0, end); + if (f.Contains(" face=", StringComparison.OrdinalIgnoreCase) && !f.Contains(" color=", StringComparison.OrdinalIgnoreCase)) + { + var start = s.IndexOf(" face=", StringComparison.OrdinalIgnoreCase); + s = s.Insert(start, string.Format(" color=\"{0}\"", color)); + text = s; + done = true; + } + else if (f.Contains(" color=", StringComparison.OrdinalIgnoreCase)) + { + int colorStart = f.IndexOf(" color=", StringComparison.OrdinalIgnoreCase); + if (s.IndexOf('"', colorStart + " color=".Length + 1) > 0) + { + end = s.IndexOf('"', colorStart + " color=".Length + 1); + } + + s = s.Substring(0, colorStart) + string.Format(" color=\"{0}", color) + s.Substring(end); + text = s; + done = true; + } + } + } + + if (!done) + { + text = $"{pre}{text}"; + } + else + { + text = pre + text; + } + + tb.SelectedText = text; + tb.SelectionStart = selectionStart; + tb.SelectionLength = text.Length; + } + + private void FontNameToolStripMenuItemClick(object sender, EventArgs e) + { + var tb = GetFocusedTextBox(); + + // font name + string text = tb.SelectedText; + if (string.IsNullOrEmpty(text) && tb.Text.Length > 0) + { + text = tb.Text; + tb.SelectAll(); + } + int selectionStart = tb.SelectionStart; + + using (var form = new ChooseFontName()) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + bool done = false; + + string pre = string.Empty; + if (selectionStart == 0 && text.StartsWith("{\\", StringComparison.Ordinal) && text.IndexOf('}') >= 0) + { + int endIndex = text.IndexOf('}') + 1; + pre = text.Substring(0, endIndex); + text = text.Remove(0, endIndex); + } + + if (text.StartsWith("'); + if (end > 0) + { + string f = text.Substring(0, end); + if (f.Contains(" color=", StringComparison.OrdinalIgnoreCase) && !f.Contains(" face=", StringComparison.OrdinalIgnoreCase)) + { + var start = text.IndexOf(" color=", StringComparison.OrdinalIgnoreCase); + text = text.Insert(start, string.Format(" face=\"{0}\"", form.FontName)); + done = true; + } + else if (f.Contains(" face=", StringComparison.OrdinalIgnoreCase)) + { + int faceStart = f.IndexOf(" face=", StringComparison.OrdinalIgnoreCase); + if (text.IndexOf('"', faceStart + " face=".Length + 1) > 0) + { + end = text.IndexOf('"', faceStart + " face=".Length + 1); + } + + text = text.Substring(0, faceStart) + string.Format(" face=\"{0}", form.FontName) + text.Substring(end); + done = true; + } + } + } + + if (!done) + { + text = $"{pre}{text}"; + } + else + { + text = pre + text; + } + + tb.SelectedText = text; + tb.SelectionStart = selectionStart; + tb.SelectionLength = text.Length; + } + } + } + + public void SetSubtitle(Subtitle subtitle, string message) + { + _subtitle = subtitle; + SubtitleListview1.Fill(subtitle, _subtitleAlternate); + ShowStatus(message); + } + + #region Networking + + private void startServerToolStripMenuItem_Click(object sender, EventArgs e) + { + using (var networkNew = new NetworkStart()) + { + _networkSession = new NikseWebServiceSession(_subtitle, _subtitleAlternate, TimerWebServiceTick, OnUpdateUserLogEntries); + networkNew.Initialize(_networkSession, _fileName); + if (networkNew.ShowDialog(this) == DialogResult.OK) + { + _networkSession.AppendToLog(string.Format(_language.XStartedSessionYAtZ, _networkSession.CurrentUser.UserName, _networkSession.SessionId, DateTime.Now.ToLongTimeString())); + toolStripStatusNetworking.Visible = true; + toolStripStatusNetworking.Text = _language.NetworkMode; + EnableDisableControlsNotWorkingInNetworkMode(false); + SubtitleListview1.ShowNetworkColumn(_language.UserAndAction); + SubtitleListview1.AutoSizeAllColumns(this); + TimerWebServiceTick(null, null); + } + else + { + _networkSession = null; + } + } + } + + private void joinSessionToolStripMenuItem_Click(object sender, EventArgs e) + { + _networkSession = new NikseWebServiceSession(_subtitle, _subtitleAlternate, TimerWebServiceTick, OnUpdateUserLogEntries); + using (var networkJoin = new NetworkJoin()) + { + networkJoin.Initialize(_networkSession); + + if (networkJoin.ShowDialog(this) == DialogResult.OK) + { + _subtitle = _networkSession.Subtitle; + _subtitleAlternate = _networkSession.OriginalSubtitle; + if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); + } + + _fileName = networkJoin.FileName; + SetTitle(); + toolStripStatusNetworking.Visible = true; + toolStripStatusNetworking.Text = _language.NetworkMode; + EnableDisableControlsNotWorkingInNetworkMode(false); + _networkSession.AppendToLog(string.Format(_language.XStartedSessionYAtZ, _networkSession.CurrentUser.UserName, _networkSession.SessionId, DateTime.Now.ToLongTimeString())); + SubtitleListview1.ShowNetworkColumn(_language.UserAndAction); + SubtitleListview1.AutoSizeAllColumns(this); + _subtitleListViewIndex = -1; + _oldSelectedParagraph = null; + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + buttonUnBreak.Visible = false; + buttonAutoBreak.Visible = false; + buttonSplitLine.Visible = false; + + textBoxListViewText.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; + textBoxListViewText.Width = (groupBoxEdit.Width - (textBoxListViewText.Left + 10)) / 2; + textBoxListViewTextAlternate.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; + textBoxListViewTextAlternate.Left = textBoxListViewText.Left + textBoxListViewText.Width + 3; + textBoxListViewTextAlternate.Width = textBoxListViewText.Width; + textBoxListViewTextAlternate.Visible = true; + labelAlternateText.Text = _languageGeneral.OriginalText; + labelAlternateText.Visible = true; + labelAlternateCharactersPerSecond.Visible = true; + labelTextAlternateLineLengths.Visible = true; + labelAlternateSingleLine.Visible = true; + labelAlternateSingleLinePixels.Visible = true; + labelTextAlternateLineTotal.Visible = true; + + labelCharactersPerSecond.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelCharactersPerSecond.Width); + labelTextLineTotal.Left = textBoxListViewText.Left + (textBoxListViewText.Width - labelTextLineTotal.Width); + AddAlternate(); + Main_Resize(null, null); + _changeAlternateSubtitleHash = _subtitleAlternate.GetFastHashCode(GetCurrentEncoding().BodyName); + } + else + { + RemoveAlternate(false, true); + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + TimerWebServiceTick(null, null); + } + else + { + _networkSession = null; + } + } + } + + private void EnableDisableControlsNotWorkingInNetworkMode(bool enabled) + { + //Top menu + newToolStripMenuItem.Enabled = enabled; + openToolStripMenuItem.Enabled = enabled; + reopenToolStripMenuItem.Enabled = enabled; + toolStripMenuItemOpenContainingFolder.Enabled = enabled; + toolStripMenuItemCompare.Enabled = enabled; + toolStripMenuItemImportDvdSubtitles.Enabled = enabled; + toolStripMenuItemSubIdx.Enabled = enabled; + toolStripMenuItemImportBluRaySup.Enabled = enabled; + matroskaImportStripMenuItem.Enabled = enabled; + toolStripMenuItemManualAnsi.Enabled = enabled; + toolStripMenuItemImportText.Enabled = enabled; + toolStripMenuItemImportTimeCodes.Enabled = enabled; + + showHistoryforUndoToolStripMenuItem.Enabled = enabled; + multipleReplaceToolStripMenuItem.Enabled = enabled; + + toolsToolStripMenuItem.Enabled = enabled; + + toolStripMenuItemSynchronization.Enabled = enabled; + + toolStripMenuItemAutoTranslate.Enabled = enabled; + + //Toolbar + toolStripButtonFileNew.Enabled = enabled; + toolStripButtonFileOpen.Enabled = enabled; + toolStripMenuItemOpenKeepVideo.Enabled = enabled; + toolStripMenuItemRestoreAutoBackup.Enabled = enabled; + toolStripButtonVisualSync.Enabled = enabled; + + // textbox source + textBoxSource.ReadOnly = !enabled; + } + + internal void TimerWebServiceTick(object sender, EventArgs e) + { + if (_networkSession == null) + { + return; + } + + List deleteIndices = new List(); + NetworkGetSendUpdates(deleteIndices, 0, null); + } + + private void NetworkGetSendUpdates(List deleteIndices, int insertIndex, Paragraph insertParagraph) + { + _networkSession.TimerStop(); + + bool doReFill = false; + bool updateListViewStatus = false; + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + string message = string.Empty; + + int numberOfLines = 0; + List updates = null; + int numberOfRetries = 10; + while (numberOfRetries > 0) + { + numberOfRetries--; + try + { + updates = _networkSession.GetUpdates(out message, out numberOfLines); + numberOfRetries = 0; + } + catch (Exception exception) + { + if (numberOfRetries <= 0) + { + if (exception.InnerException != null) + { + MessageBox.Show(string.Format(_language.NetworkUnableToConnectToServer, exception.InnerException.Message + Environment.NewLine + exception.InnerException.StackTrace)); + } + else + { + MessageBox.Show(string.Format(_language.NetworkUnableToConnectToServer, exception.Message + Environment.NewLine + exception.StackTrace)); + } + + _networkSession.TimerStop(); + if (_networkChat != null && !_networkChat.IsDisposed) + { + _networkChat.Close(); + _networkChat = null; + } + + _networkSession = null; + EnableDisableControlsNotWorkingInNetworkMode(true); + toolStripStatusNetworking.Visible = false; + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Network); + _networkChat = null; + return; + } + + Application.DoEvents(); + System.Threading.Thread.Sleep(250); + } + } + + int currentSelectedIndex = -1; + if (SubtitleListview1.SelectedItems.Count > 0) + { + currentSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + } + + int oldCurrentSelectedIndex = currentSelectedIndex; + if (message == "OK") + { + foreach (var update in updates) + { + if (!string.IsNullOrEmpty(update.Text)) + { + if (!update.Text.Contains(Environment.NewLine)) + { + update.Text = update.Text.Replace("\n", Environment.NewLine); + } + + update.Text = WebUtility.HtmlDecode(update.Text).Replace("
", Environment.NewLine); + } + + if (update.User.Ip != _networkSession.CurrentUser.Ip || update.User.UserName != _networkSession.CurrentUser.UserName) + { + if (update.Action == "USR") + { + _networkSession.Users.Add(update.User); + if (_networkChat != null && !_networkChat.IsDisposed) + { + _networkChat.AddUser(update.User); + } + + _networkSession.AppendToLog(string.Format(_language.NetworkNewUser, update.User.UserName, update.User.Ip)); + } + else if (update.Action == "MSG") + { + _networkSession.ChatLog.Add(new NikseWebServiceSession.ChatEntry { User = update.User, Message = update.Text }); + if (_networkChat == null || _networkChat.IsDisposed) + { + _networkChat = new NetworkChat(); + _networkChat.Initialize(_networkSession); + _networkChat.Show(this); + } + else + { + _networkChat.AddChatMessage(update.User, update.Text); + } + + if (!string.IsNullOrEmpty(Configuration.Settings.NetworkSettings.NewMessageSound) && File.Exists(Configuration.Settings.NetworkSettings.NewMessageSound)) + { + try + { + using (var soundPlayer = new System.Media.SoundPlayer(Configuration.Settings.NetworkSettings.NewMessageSound)) + { + soundPlayer.Play(); + } + } + catch + { + } + } + + _networkSession.AppendToLog(string.Format(_language.NetworkMessage, update.User.UserName, update.User.Ip, update.Text)); + } + else if (update.Action == "DEL") + { + doReFill = true; + _subtitle.Paragraphs.RemoveAt(update.Index); + if (_networkSession.LastSubtitle != null) + { + _networkSession.LastSubtitle.Paragraphs.RemoveAt(update.Index); + } + + _networkSession.AppendToLog(string.Format(_language.NetworkDelete, update.User.UserName, update.User.Ip, update.Index)); + _networkSession.AdjustUpdateLogToDelete(update.Index); + + if (deleteIndices.Count > 0) + { + for (int i = deleteIndices.Count - 1; i >= 0; i--) + { + int index = deleteIndices[i]; + if (index == update.Index) + { + deleteIndices.RemoveAt(i); + } + else if (index > update.Index) + { + deleteIndices[i] = index - 1; + } + } + } + + if (insertIndex > update.Index) + { + insertIndex--; + } + + if (currentSelectedIndex >= 0 && currentSelectedIndex > update.Index) + { + currentSelectedIndex--; + } + } + else if (update.Action == "INS") + { + doReFill = true; + var p = new Paragraph(update.Text, update.StartMilliseconds, update.EndMilliseconds); + _subtitle.Paragraphs.Insert(update.Index, p); + if (_networkSession.LastSubtitle != null) + { + _networkSession.LastSubtitle.Paragraphs.Insert(update.Index, new Paragraph(p)); + } + + _networkSession.AppendToLog(string.Format(_language.NetworkInsert, update.User.UserName, update.User.Ip, update.Index, UiUtil.GetListViewTextFromString(update.Text))); + _networkSession.AddToWsUserLog(update.User, update.Index, update.Action, false); + updateListViewStatus = true; + _networkSession.AdjustUpdateLogToInsert(update.Index); + + if (deleteIndices.Count > 0) + { + for (int i = deleteIndices.Count - 1; i >= 0; i--) + { + int index = deleteIndices[i]; + if (index > update.Index) + { + deleteIndices[i] = index + 1; + } + } + } + + if (insertIndex > update.Index) + { + insertIndex++; + } + + if (currentSelectedIndex >= 0 && currentSelectedIndex > update.Index) + { + currentSelectedIndex++; + } + } + else if (update.Action == "UPD") + { + updateListViewStatus = true; + var p = _subtitle.GetParagraphOrDefault(update.Index); + if (p != null) + { + p.StartTime.TotalMilliseconds = update.StartMilliseconds; + p.EndTime.TotalMilliseconds = update.EndMilliseconds; + p.Text = update.Text; + SubtitleListview1.SetTimeAndText(update.Index, p, _subtitle.GetParagraphOrDefault(update.Index + 1)); + _networkSession.AppendToLog(string.Format(_language.NetworkUpdate, update.User.UserName, update.User.Ip, update.Index, UiUtil.GetListViewTextFromString(update.Text))); + _networkSession.AddToWsUserLog(update.User, update.Index, update.Action, true); + updateListViewStatus = true; + } + + if (_networkSession.LastSubtitle != null) + { + p = _networkSession.LastSubtitle.GetParagraphOrDefault(update.Index); + if (p != null) + { + p.StartTime.TotalMilliseconds = update.StartMilliseconds; + p.EndTime.TotalMilliseconds = update.EndMilliseconds; + p.Text = update.Text; + } + } + } + else if (update.Action == "BYE") + { + if (_networkChat != null && !_networkChat.IsDisposed) + { + _networkChat.RemoveUser(update.User); + } + + SeNetworkService.SeUser removeUser = null; + foreach (var user in _networkSession.Users) + { + if (user.UserName == update.User.UserName) + { + removeUser = user; + break; + } + } + + if (removeUser != null) + { + _networkSession.Users.Remove(removeUser); + } + + _networkSession.AppendToLog(string.Format(_language.NetworkByeUser, update.User.UserName, update.User.Ip)); + } + else + { + _networkSession.AppendToLog("UNKNOWN ACTION: " + update.Action + " by " + update.User.UserName + " (" + update.User.Ip + ")"); + } + } + } + + if (numberOfLines != _subtitle.Paragraphs.Count) + { + _subtitle = _networkSession.ReloadSubtitle(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + UpdateListviewWithUserLogEntries(); + _networkSession.LastSubtitle = new Subtitle(_subtitle); + _oldSelectedParagraph = null; + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + _networkSession.TimerStart(); + RefreshSelectedParagraph(); + return; + } + + if (deleteIndices.Count > 0) + { + deleteIndices.Sort(); + deleteIndices.Reverse(); + foreach (int i in deleteIndices) + { + _subtitle.Paragraphs.RemoveAt(i); + if (_networkSession.LastSubtitle != null && i < _networkSession.LastSubtitle.Paragraphs.Count) + { + _networkSession.LastSubtitle.Paragraphs.RemoveAt(i); + } + } + + _networkSession.DeleteLines(deleteIndices); + doReFill = true; + } + + if (insertIndex >= 0 && insertParagraph != null) + { + _subtitle.Paragraphs.Insert(insertIndex, insertParagraph); + if (_networkSession.LastSubtitle != null && insertIndex < _networkSession.LastSubtitle.Paragraphs.Count) + { + _networkSession.LastSubtitle.Paragraphs.Insert(insertIndex, insertParagraph); + } + + _networkSession.InsertLine(insertIndex, insertParagraph); + doReFill = true; + } + + _networkSession.CheckForAndSubmitUpdates(); // updates only (no inserts/deletes) + } + else + { + if (message == "Session not found!") + { + message = _networkSession.Restart(); + if (message == "Reload") + { + _subtitle = _networkSession.ReloadSubtitle(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + UpdateListviewWithUserLogEntries(); + _networkSession.LastSubtitle = new Subtitle(_subtitle); + _oldSelectedParagraph = null; + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + _networkSession.TimerStart(); + RefreshSelectedParagraph(); + return; + } + + if (message == "OK") + { + _networkSession.TimerStart(); + RefreshSelectedParagraph(); + return; + } + } + else if (message == "User not found!") + { + message = _networkSession.ReJoin(); + if (message == "Reload") + { + _subtitle = _networkSession.ReloadSubtitle(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + UpdateListviewWithUserLogEntries(); + _networkSession.LastSubtitle = new Subtitle(_subtitle); + _oldSelectedParagraph = null; + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + _networkSession.TimerStart(); + RefreshSelectedParagraph(); + return; + } + } + + MessageBox.Show(message); + LeaveSessionToolStripMenuItemClick(null, null); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + return; + } + + if (doReFill) + { + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + UpdateListviewWithUserLogEntries(); + + if (oldCurrentSelectedIndex != currentSelectedIndex) + { + _oldSelectedParagraph = null; + _subtitleListViewIndex = currentSelectedIndex; + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex); + } + else if (_oldSelectedParagraph != null) + { + var p = _subtitle.GetFirstAlike(_oldSelectedParagraph); + if (p == null) + { + var tmp = new Paragraph(_oldSelectedParagraph); + tmp.Text = textBoxListViewText.Text; + p = _subtitle.GetFirstAlike(tmp); + } + + if (p == null) + { + int idx = oldCurrentSelectedIndex; + if (idx >= _subtitle.Paragraphs.Count) + { + idx = _subtitle.Paragraphs.Count - 1; + } + + if (idx >= 0 && idx < _subtitle.Paragraphs.Count) + { + SubtitleListview1.SelectIndexAndEnsureVisible(idx); + _listViewTextUndoIndex = -1; + SubtitleListView1SelectedIndexChange(); + textBoxListViewText.Text = _subtitle.Paragraphs[idx].Text; + } + } + else + { + _subtitleListViewIndex = _subtitle.GetIndex(p); + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex); + _listViewTextUndoIndex = -1; + SubtitleListView1SelectedIndexChange(); + } + } + } + else if (updateListViewStatus) + { + UpdateListviewWithUserLogEntries(); + } + + _networkSession.LastSubtitle = new Subtitle(_subtitle); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + _networkSession.TimerStart(); + } + + private void UpdateListviewWithUserLogEntries() + { + SubtitleListview1.BeginUpdate(); + foreach (UpdateLogEntry entry in _networkSession.UpdateLog) + { + SubtitleListview1.SetNetworkText(entry.Index, entry.ToString(), Utilities.GetColorFromUserName(entry.UserName)); + } + + SubtitleListview1.EndUpdate(); + } + + private void LeaveSessionToolStripMenuItemClick(object sender, EventArgs e) + { + if (_networkSession != null) + { + _networkSession.TimerStop(); + _networkSession.Leave(); + } + + if (_networkChat != null && !_networkChat.IsDisposed) + { + _networkChat.Close(); + _networkChat = null; + } + + _networkSession = null; + EnableDisableControlsNotWorkingInNetworkMode(true); + toolStripStatusNetworking.Visible = false; + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.Network); + _networkChat = null; + } + + private void toolStripMenuItemNetworking_DropDownOpening(object sender, EventArgs e) + { + startServerToolStripMenuItem.Visible = _networkSession == null; + joinSessionToolStripMenuItem.Visible = _networkSession == null; + showSessionKeyLogToolStripMenuItem.Visible = _networkSession != null; + leaveSessionToolStripMenuItem.Visible = _networkSession != null; + chatToolStripMenuItem.Visible = _networkSession != null; + } + + internal void OnUpdateUserLogEntries(object sender, EventArgs e) + { + UpdateListviewWithUserLogEntries(); + } + + private void toolStripStatusNetworking_Click(object sender, EventArgs e) + { + showSessionKeyLogToolStripMenuItem_Click(null, null); + } + + private void showSessionKeyLogToolStripMenuItem_Click(object sender, EventArgs e) + { + using (var networkLog = new NetworkLogAndInfo()) + { + networkLog.Initialize(_networkSession); + networkLog.ShowDialog(this); + } + } + + private void chatToolStripMenuItem_Click(object sender, EventArgs e) + { + if (_networkSession != null) + { + if (_networkChat == null || _networkChat.IsDisposed) + { + _networkChat = new NetworkChat(); + _networkChat.Initialize(_networkSession); + _networkChat.Show(this); + } + else + { + _networkChat.WindowState = FormWindowState.Normal; + } + } + } + + #endregion Networking + + private void UnDockVideoPlayer() + { + bool firstUndock = _videoPlayerUndocked != null && !_videoPlayerUndocked.IsDisposed; + + _videoPlayerUndocked = new VideoPlayerUndocked(this, mediaPlayer); + + if (firstUndock) + { + Configuration.Settings.General.UndockedVideoPosition = _videoPlayerUndocked.Left + @";" + _videoPlayerUndocked.Top + @";" + _videoPlayerUndocked.Width + @";" + _videoPlayerUndocked.Height; + } + + Control control = null; + if (splitContainer1.Panel2.Controls.Count == 0) + { + control = panelVideoPlayer; + groupBoxVideo.Controls.Remove(control); + } + else + { + control = panelVideoPlayer; + splitContainer1.Panel2.Controls.Clear(); + } + + if (control != null) + { + control.Top = 0; + control.Left = 0; + control.Width = _videoPlayerUndocked.PanelContainer.Width; + control.Height = _videoPlayerUndocked.PanelContainer.Height; + _videoPlayerUndocked.PanelContainer.Controls.Add(control); + } + } + + public void ReDockVideoPlayer(Control control) + { + groupBoxVideo.Controls.Add(control); + mediaPlayer.FontSizeFactor = 1.0F; + mediaPlayer.SetSubtitleFont(); + mediaPlayer.SubtitleText = string.Empty; + } + + private void UnDockWaveform() + { + _waveformUndocked = new WaveformUndocked(this); + + var control = audioVisualizer; + groupBoxVideo.Controls.Remove(control); + control.Top = 0; + control.Left = 0; + control.Width = _waveformUndocked.PanelContainer.Width; + control.Height = _waveformUndocked.PanelContainer.Height - panelWaveformControls.Height; + _waveformUndocked.PanelContainer.Controls.Add(control); + + var control2 = (Control)panelWaveformControls; + groupBoxVideo.Controls.Remove(control2); + control2.Top = control.Height; + control2.Left = 0; + _waveformUndocked.PanelContainer.Controls.Add(control2); + + var control3 = (Control)trackBarWaveformPosition; + groupBoxVideo.Controls.Remove(control3); + control3.Top = control.Height; + control3.Left = control2.Width + 2; + control3.Width = _waveformUndocked.PanelContainer.Width - control3.Left; + _waveformUndocked.PanelContainer.Controls.Add(control3); + } + + public void ReDockWaveform(Control waveform, Control buttons, Control trackBar) + { + groupBoxVideo.Controls.Add(waveform); + waveform.Top = 30; + waveform.Height = groupBoxVideo.Height - (waveform.Top + buttons.Height + 10); + + groupBoxVideo.Controls.Add(buttons); + buttons.Top = waveform.Top + waveform.Height + 5; + + groupBoxVideo.Controls.Add(trackBar); + trackBar.Top = buttons.Top; + } + + private void UnDockVideoButtons() + { + _videoControlsUndocked = new VideoControlsUndocked(this); + var control = tabControlButtons; + groupBoxVideo.Controls.Remove(control); + control.Top = 25; + control.Left = 0; + _videoControlsUndocked.PanelContainer.Controls.Add(control); + + groupBoxVideo.Controls.Remove(checkBoxSyncListViewWithVideoWhilePlaying); + _videoControlsUndocked.PanelContainer.Controls.Add(checkBoxSyncListViewWithVideoWhilePlaying); + checkBoxSyncListViewWithVideoWhilePlaying.Top = 5; + checkBoxSyncListViewWithVideoWhilePlaying.Left = 5; + + splitContainerMain.Panel2Collapsed = true; + splitContainer1.Panel2Collapsed = true; + } + + public void ReDockVideoButtons(Control videoButtons, Control checkBoxSyncSubWithVideo) + { + groupBoxVideo.Controls.Add(videoButtons); + videoButtons.Top = 12; + videoButtons.Left = 5; + + groupBoxVideo.Controls.Add(checkBoxSyncSubWithVideo); + checkBoxSyncSubWithVideo.Top = 11; + checkBoxSyncSubWithVideo.Left = videoButtons.Left + videoButtons.Width + 5; + } + + private void UndockVideoControlsToolStripMenuItemClick(object sender, EventArgs e) + { + if (Configuration.Settings.General.Undocked) + { + return; + } + + Configuration.Settings.General.Undocked = true; + if (!_loading) + { + Configuration.Settings.General.SplitContainerMainSplitterDistance = splitContainerMain.SplitterDistance; + Configuration.Settings.General.SplitContainer1SplitterDistance = splitContainer1.SplitterDistance; + Configuration.Settings.General.SplitContainerListViewAndTextSplitterDistance = splitContainerListViewAndText.SplitterDistance; + } + + var top = Math.Max(Top, 0); + var left = Math.Max(Left, 0); + UnDockVideoPlayer(); + splitContainerListViewAndText.SplitterDistance = splitContainerListViewAndText.Height - 109; + if (toolStripButtonToggleVideo.Checked) + { + _videoPlayerUndocked.Show(this); + if (_videoPlayerUndocked.Top < 0 || _videoPlayerUndocked.Left < 0) + { + _videoPlayerUndocked.WindowState = FormWindowState.Normal; + _videoPlayerUndocked.Top = top + 40; + _videoPlayerUndocked.Left = Math.Abs(left - 20); + _videoPlayerUndocked.Width = 600; + _videoPlayerUndocked.Height = 400; + } + } + + UnDockWaveform(); + if (toolStripButtonToggleWaveform.Checked) + { + _waveformUndocked.Show(this); + if (_waveformUndocked.Top < 0 || _waveformUndocked.Left < 0) + { + _waveformUndocked.WindowState = FormWindowState.Normal; + _waveformUndocked.Top = top + 60; + _waveformUndocked.Left = Math.Abs(left - 15); + _waveformUndocked.Width = 600; + _waveformUndocked.Height = 200; + } + } + + UnDockVideoButtons(); + _videoControlsUndocked.Show(this); + if (_videoControlsUndocked.Top < 0 || _videoControlsUndocked.Left < 0) + { + _videoControlsUndocked.WindowState = FormWindowState.Normal; + _videoControlsUndocked.Top = top + 40; + _videoControlsUndocked.Left = Math.Abs(left - 10); + _videoControlsUndocked.Width = tabControlButtons.Width + 20; + _videoControlsUndocked.Height = tabControlButtons.Height + 65; + } + + _isVideoControlsUndocked = true; + SetUndockedWindowsTitle(); + + undockVideoControlsToolStripMenuItem.Visible = false; + redockVideoControlsToolStripMenuItem.Visible = true; + + tabControl1_SelectedIndexChanged(null, null); + _videoControlsUndocked.Refresh(); + } + + public void RedockVideoControlsToolStripMenuItemClick(object sender, EventArgs e) + { + if (!Configuration.Settings.General.Undocked) + { + return; + } + + mediaPlayer.ShowNonFullScreenControls(); + + SaveUndockedPositions(); + + Configuration.Settings.General.Undocked = false; + + if (_videoControlsUndocked != null && !_videoControlsUndocked.IsDisposed) + { + var control = _videoControlsUndocked.PanelContainer.Controls[0]; + var controlCheckBox = _videoControlsUndocked.PanelContainer.Controls[1]; + _videoControlsUndocked.PanelContainer.Controls.Clear(); + ReDockVideoButtons(control, controlCheckBox); + _videoControlsUndocked.Close(); + _videoControlsUndocked = null; + } + + if (_waveformUndocked != null && !_waveformUndocked.IsDisposed) + { + var controlWaveform = _waveformUndocked.PanelContainer.Controls[0]; + var controlButtons = _waveformUndocked.PanelContainer.Controls[1]; + var controlTrackBar = _waveformUndocked.PanelContainer.Controls[2]; + _waveformUndocked.PanelContainer.Controls.Clear(); + ReDockWaveform(controlWaveform, controlButtons, controlTrackBar); + _waveformUndocked.Close(); + _waveformUndocked = null; + } + + if (_videoPlayerUndocked != null && !_videoPlayerUndocked.IsDisposed) + { + var control = _videoPlayerUndocked.PanelContainer.Controls[0]; + _videoPlayerUndocked.PanelContainer.Controls.Remove(control); + ReDockVideoPlayer(control); + _videoPlayerUndocked.Close(); + _videoPlayerUndocked = null; + mediaPlayer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton; + } + + _isVideoControlsUndocked = false; + _videoPlayerUndocked = null; + _waveformUndocked = null; + _videoControlsUndocked = null; + ShowVideoPlayer(); + + audioVisualizer.Visible = toolStripButtonToggleWaveform.Checked; + trackBarWaveformPosition.Visible = toolStripButtonToggleWaveform.Checked; + panelWaveformControls.Visible = toolStripButtonToggleWaveform.Checked; + if (!toolStripButtonToggleVideo.Checked) + { + HideVideoPlayer(); + } + + mediaPlayer.Invalidate(); + Refresh(); + + undockVideoControlsToolStripMenuItem.Visible = true; + redockVideoControlsToolStripMenuItem.Visible = false; + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex, true); + + splitContainerMain.SplitterDistance = Configuration.Settings.General.SplitContainerMainSplitterDistance; + splitContainer1.SplitterDistance = Configuration.Settings.General.SplitContainer1SplitterDistance; + splitContainerListViewAndText.SplitterDistance = Configuration.Settings.General.SplitContainerListViewAndTextSplitterDistance; + } + + private void Bw_DoWork(object sender, DoWorkEventArgs e) + { + System.Threading.Thread.Sleep(1200); + } + + internal void SetWaveformToggleOff() + { + toolStripButtonToggleWaveform.Checked = false; + } + + internal void SetVideoPlayerToggleOff() + { + toolStripButtonToggleVideo.Checked = false; + } + + private void ToolStripMenuItemInsertSubtitleClick(object sender, EventArgs e) + { + openFileDialog1.Title = _languageGeneral.OpenSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + if (!File.Exists(openFileDialog1.FileName)) + { + return; + } + + var fi = new FileInfo(openFileDialog1.FileName); + if (fi.Length > 1024 * 1024 * 10) // max 10 mb + { + var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, openFileDialog1.FileName); + if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return; + } + } + + MakeHistoryForUndo(string.Format(_language.BeforeInsertLine, openFileDialog1.FileName)); + + var subtitle = new Subtitle(); + SubtitleFormat format = subtitle.LoadSubtitle(openFileDialog1.FileName, out var encoding, null); + + if (format != null) + { + SaveSubtitleListviewIndices(); + if (Configuration.Settings.General.RemoveBlankLinesWhenOpening) + { + subtitle.RemoveEmptyLines(); + } + + int index = FirstSelectedIndex + 1; + if (index < 0) + { + index = 0; + } + + var last = _subtitle.GetParagraphOrDefault(index - 1); + var newFirst = subtitle.GetParagraphOrDefault(0); + if (last != null && newFirst != null && newFirst.StartTime.TotalMilliseconds < last.EndTime.TotalMilliseconds) + { + var addMilliseconds = last.EndTime.TotalMilliseconds - newFirst.StartTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines; + subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(addMilliseconds)); + } + + foreach (var p in subtitle.Paragraphs) + { + _subtitle.Paragraphs.Insert(index, new Paragraph(p)); + index++; + } + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + index = FirstSelectedIndex; + if (index < 0) + { + index = 0; + } + + var current = _subtitle.GetParagraphOrDefault(index); + if (current != null) + { + var original = Utilities.GetOriginalParagraph(index, current, _subtitleAlternate.Paragraphs); + if (original != null) + { + index = _subtitleAlternate.GetIndex(original); + foreach (var p in subtitle.Paragraphs) + { + _subtitleAlternate.Paragraphs.Insert(index, new Paragraph(p)); + index++; + } + + if (subtitle.Paragraphs.Count > 0) + { + _subtitleAlternate.Renumber(); + } + } + } + } + + _subtitle.Renumber(); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + } + + private void InsertLineToolStripMenuItemClick(object sender, EventArgs e) + { + if (_subtitle == null || _subtitle.Paragraphs.Count == 0) + { + InsertBefore(); + } + else + { + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.Paragraphs.Count - 1, true); + InsertAfter(string.Empty); + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.Paragraphs.Count - 1, true); + } + } + + private void CloseVideoToolStripMenuItemClick(object sender, EventArgs e) + { + timer1.Stop(); + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.PauseAndDisposePlayer(); + } + + mediaPlayer.SetPlayerName(string.Empty); + mediaPlayer.ResetTimeLabel(); + mediaPlayer.VideoPlayer = null; + mediaPlayer.CurrentPosition = 0; + VideoFileName = null; + _videoInfo = null; + VideoAudioTrackNumber = -1; + labelVideoInfo.Text = _languageGeneral.NoVideoLoaded; + audioVisualizer.WavePeaks = null; + audioVisualizer.SetSpectrogram(null); + audioVisualizer.SceneChanges = new List(); + audioVisualizer.Chapters = new List(); + timeUpDownVideoPositionAdjust.TimeCode = new TimeCode(); + timeUpDownVideoPositionAdjust.Enabled = false; + timeUpDownVideoPosition.TimeCode = new TimeCode(); + timeUpDownVideoPosition.Enabled = false; + } + + private void ToolStripMenuItemVideoDropDownOpening(object sender, EventArgs e) + { + if (_isVideoControlsUndocked) + { + redockVideoControlsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls); + undockVideoControlsToolStripMenuItem.ShortcutKeys = Keys.None; + } + else + { + undockVideoControlsToolStripMenuItem.ShortcutKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls); + redockVideoControlsToolStripMenuItem.ShortcutKeys = Keys.None; + } + + closeVideoToolStripMenuItem.Visible = !string.IsNullOrEmpty(VideoFileName); + setVideoOffsetToolStripMenuItem.Visible = !string.IsNullOrEmpty(VideoFileName); + smpteTimeModedropFrameToolStripMenuItem.Visible = !string.IsNullOrEmpty(VideoFileName); + if (!string.IsNullOrEmpty(VideoFileName)) + { + if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) + { + setVideoOffsetToolStripMenuItem.Text = string.Format("{0} [{1}]", _language.Menu.Video.SetVideoOffset, new TimeCode(Configuration.Settings.General.CurrentVideoOffsetInMs).ToShortDisplayString()); + } + else + { + setVideoOffsetToolStripMenuItem.Text = _language.Menu.Video.SetVideoOffset; + } + + smpteTimeModedropFrameToolStripMenuItem.Checked = mediaPlayer.SmpteMode; + } + + toolStripMenuItemOpenVideoFromUrl.Visible = Configuration.Settings.General.VideoPlayer.Trim().Equals("MPV", StringComparison.OrdinalIgnoreCase) && + LibMpvDynamic.IsInstalled && + File.Exists(Path.Combine(Configuration.DataDirectory, "youtube-dl.exe")); + + toolStripMenuItemSetAudioTrack.Visible = false; + openSecondSubtitleToolStripMenuItem.Visible = false; + if (mediaPlayer.VideoPlayer is LibVlcDynamic libVlc) + { + openSecondSubtitleToolStripMenuItem.Visible = true; + var audioTracks = libVlc.GetAudioTracks(); + VideoAudioTrackNumber = libVlc.AudioTrackNumber; + if (audioTracks.Count > 1) + { + toolStripMenuItemSetAudioTrack.DropDownItems.Clear(); + for (int i = 0; i < audioTracks.Count; i++) + { + var at = audioTracks[i]; + toolStripMenuItemSetAudioTrack.DropDownItems.Add(string.IsNullOrWhiteSpace(at.Value) ? at.Key.ToString(CultureInfo.InvariantCulture) : at.Value, null, ChooseAudioTrack); + toolStripMenuItemSetAudioTrack.DropDownItems[toolStripMenuItemSetAudioTrack.DropDownItems.Count - 1].Tag = at.Key.ToString(CultureInfo.InvariantCulture); + if (at.Key == VideoAudioTrackNumber) + { + toolStripMenuItemSetAudioTrack.DropDownItems[toolStripMenuItemSetAudioTrack.DropDownItems.Count - 1].Select(); + } + } + + toolStripMenuItemSetAudioTrack.Visible = true; + } + } + else if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv) + { + openSecondSubtitleToolStripMenuItem.Visible = true; + var audioTracks = libMpv.AudioTracks; + VideoAudioTrackNumber = libMpv.AudioTrackNumber; + if (audioTracks.Count > 1) + { + toolStripMenuItemSetAudioTrack.DropDownItems.Clear(); + for (int i = 0; i < audioTracks.Count; i++) + { + var at = audioTracks[i]; + var trackText = string.IsNullOrWhiteSpace(at.Value) ? at.Key.ToString(CultureInfo.InvariantCulture) : "Track " + at.Key + " - " + char.ToUpper(at.Value[0]) + at.Value.Substring(1); + toolStripMenuItemSetAudioTrack.DropDownItems.Add(trackText, null, ChooseAudioTrack); + toolStripMenuItemSetAudioTrack.DropDownItems[toolStripMenuItemSetAudioTrack.DropDownItems.Count - 1].Tag = at.Key.ToString(CultureInfo.InvariantCulture); + if (i == VideoAudioTrackNumber) + { + toolStripMenuItemSetAudioTrack.DropDownItems[toolStripMenuItemSetAudioTrack.DropDownItems.Count - 1].Select(); + } + } + + toolStripMenuItemSetAudioTrack.Visible = true; + } + } + + if (mediaPlayer.VideoPlayer != null && audioVisualizer.WavePeaks != null && audioVisualizer.WavePeaks.Peaks.Count > 0) + { + toolStripMenuItemImportSceneChanges.Visible = true; + toolStripMenuItemRemoveSceneChanges.Visible = audioVisualizer.SceneChanges.Count > 0; + } + else + { + toolStripMenuItemImportSceneChanges.Visible = false; + toolStripMenuItemRemoveSceneChanges.Visible = false; + } + + if (mediaPlayer.VideoPlayer != null && VideoFileName.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase)) + { + toolStripMenuItemImportChapters.Visible = true; + } + else + { + toolStripMenuItemImportChapters.Visible = false; + } + + generateTextFromCurrentVideoToolStripMenuItem.Visible = Directory.Exists(Path.Combine(Configuration.DataDirectory, "pocketsphinx")); + } + + private void ChooseAudioTrack(object sender, EventArgs e) + { + if (mediaPlayer.VideoPlayer is LibVlcDynamic libVlc) + { + var item = sender as ToolStripItem; + int number = int.Parse(item.Tag.ToString()); + libVlc.AudioTrackNumber = number; + VideoAudioTrackNumber = number; + } + else if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv) + { + var item = sender as ToolStripItem; + int number = int.Parse(item.Tag.ToString()); + number--; + libMpv.AudioTrackNumber = number; + VideoAudioTrackNumber = number; + } + } + + private void textBoxListViewTextAlternate_TextChanged(object sender, EventArgs e) + { + if (_subtitleAlternate == null || _subtitleAlternate.Paragraphs.Count < 1) + { + return; + } + + if (_subtitleListViewIndex >= 0) + { + var original = Utilities.GetOriginalParagraph(_subtitleListViewIndex, _subtitle.Paragraphs[_subtitleListViewIndex], _subtitleAlternate.Paragraphs); + if (original != null) + { + string text = textBoxListViewTextAlternate.Text.TrimEnd(); + + // update _subtitle + listview + original.Text = text; + UpdateListViewTextInfo(labelTextAlternateLineLengths, labelAlternateSingleLine, labelAlternateSingleLinePixels, labelTextAlternateLineTotal, labelAlternateCharactersPerSecond, original, textBoxListViewTextAlternate); + SubtitleListview1.SetAlternateText(_subtitleListViewIndex, text); + FixVerticalScrollBars(textBoxListViewTextAlternate, ref _lastNumberOfNewLinesAlternate); + } + } + } + + private void TextBoxListViewTextAlternateKeyDown(object sender, KeyEventArgs e) + { + _listViewAlternateTextTicks = DateTime.UtcNow.Ticks; + if (_subtitleAlternate == null || _subtitleAlternate.Paragraphs.Count < 1) + { + return; + } + + if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.ShiftKey) + { + return; + } + + if (e.Modifiers == Keys.Control && e.KeyCode == (Keys.LButton | Keys.ShiftKey)) + { // surround ctrl+v action with history (for undo) + _listViewAlternateTextTicks = 0; + TimerAlternateTextUndoTick(sender, e); + Application.DoEvents(); + System.Threading.Thread.Sleep(50); + Application.DoEvents(); + _listViewAlternateTextTicks = 0; + TimerAlternateTextUndoTick(sender, e); + return; + } + + int numberOfLines = Utilities.GetNumberOfLines(textBoxListViewTextAlternate.Text); + + if (e.Modifiers == Keys.None && e.KeyCode == Keys.Enter && numberOfLines > Configuration.Settings.General.MaxNumberOfLines) + { + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainTextBoxAutoBreak) + { + BreakUnbreakTextBox(false, textBoxListViewTextAlternate); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainTextBoxUnbreak) + { + BreakUnbreakTextBox(true, textBoxListViewTextAlternate); + e.SuppressKeyPress = true; + } + else if (e.KeyData == _shortcuts.MainTextBoxBreakAtCursorPosition) + { + textBoxListViewTextAlternate.Text = Utilities.ReSplit(textBoxListViewTextAlternate.Text, textBoxListViewTextAlternate.SelectionStart); + var lines = textBoxListViewTextAlternate.Text.SplitToLines(); + if (lines.Count > 0) + { + textBoxListViewTextAlternate.SelectionStart = lines[0].Length; + } + + e.SuppressKeyPress = true; + } + + else if (e.KeyData == _shortcuts.MainTextBoxBreakAtCursorPosition) + { + textBoxListViewText.Text = Utilities.ReSplit(textBoxListViewText.Text, textBoxListViewText.SelectionStart); + ButtonNextClick(null, null); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.I) + { + if (textBoxListViewTextAlternate.SelectionLength == 0) + { + if (textBoxListViewTextAlternate.Text.Contains("")) + { + textBoxListViewTextAlternate.Text = HtmlUtil.RemoveOpenCloseTags(textBoxListViewTextAlternate.Text, HtmlUtil.TagItalic); + } + else + { + textBoxListViewTextAlternate.Text = string.Format("{0}", textBoxListViewTextAlternate.Text); + } + } + else + { + TextBoxListViewToggleTag(HtmlUtil.TagItalic); + e.SuppressKeyPress = true; + } + } + + if (e.Modifiers == Keys.Control && e.KeyCode == Keys.D) + { + textBoxListViewTextAlternate.SelectionLength = 0; + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainTextBoxSelectionToLower == e.KeyData) // selection to lowercase + { + if (textBoxListViewTextAlternate.SelectionLength > 0) + { + int start = textBoxListViewTextAlternate.SelectionStart; + int length = textBoxListViewTextAlternate.SelectionLength; + textBoxListViewTextAlternate.SelectedText = textBoxListViewTextAlternate.SelectedText.ToLowerInvariant(); + textBoxListViewTextAlternate.SelectionStart = start; + textBoxListViewTextAlternate.SelectionLength = length; + e.SuppressKeyPress = true; + } + } + else if (_shortcuts.MainTextBoxSelectionToUpper == e.KeyData) // selection to uppercase + { + if (textBoxListViewTextAlternate.SelectionLength > 0) + { + int start = textBoxListViewTextAlternate.SelectionStart; + int length = textBoxListViewTextAlternate.SelectionLength; + textBoxListViewTextAlternate.SelectedText = textBoxListViewTextAlternate.SelectedText.ToUpperInvariant(); + textBoxListViewTextAlternate.SelectionStart = start; + textBoxListViewTextAlternate.SelectionLength = length; + e.SuppressKeyPress = true; + } + } + else if (_shortcuts.MainTextBoxSelectionToggleCasing == e.KeyData && textBoxListViewTextAlternate.SelectionLength > 0) // selection to uppercase + { + int start = textBoxListViewTextAlternate.SelectionStart; + int length = textBoxListViewTextAlternate.SelectionLength; + var text = ToggleCasing(textBoxListViewTextAlternate.SelectedText); + textBoxListViewTextAlternate.SelectedText = text; + textBoxListViewTextAlternate.SelectionStart = start; + textBoxListViewTextAlternate.SelectionLength = length; + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainTextBoxSplitAtCursor == e.KeyData && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + ToolStripMenuItemSplitTextAtCursorClick(null, null); + e.SuppressKeyPress = true; + } + else if (_shortcuts.MainTextBoxSplitAtCursorAndVideoPos == e.KeyData && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + toolStripMenuItemSplitViaWaveform_Click(null, null); + e.SuppressKeyPress = true; + } + + // last key down in text + _lastTextKeyDownTicks = DateTime.UtcNow.Ticks; + + UpdatePositionAndTotalLength(labelTextAlternateLineTotal, textBoxListViewTextAlternate); + } + + private void OpenOriginalToolStripMenuItemClick(object sender, EventArgs e) + { + OpenAlternateSubtitle(); + } + + private void SaveOriginalAstoolStripMenuItemClick(object sender, EventArgs e) + { + if (_subtitleAlternate == null || _subtitleAlternate.Paragraphs.Count == 0) + { + return; + } + + SubtitleFormat currentFormat = GetCurrentSubtitleFormat(); + if (currentFormat == null) + { + currentFormat = new SubRip(); + } + + UiUtil.SetSaveDialogFilter(saveFileDialog1, currentFormat); + + saveFileDialog1.Title = _language.SaveOriginalSubtitleAs; + saveFileDialog1.DefaultExt = "*" + currentFormat.Extension; + saveFileDialog1.AddExtension = true; + + if (!string.IsNullOrEmpty(VideoFileName)) + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); + } + else if (!string.IsNullOrEmpty(_subtitleAlternateFileName)) + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_subtitleAlternateFileName); + } + else + { + saveFileDialog1.FileName = string.Empty; + } + + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + _subtitleAlternateFileName = saveFileDialog1.FileName; + SaveOriginalSubtitle(currentFormat); + SetTitle(); + if (_fileName != null) + { + Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + } + } + } + + private void SaveOriginalToolStripMenuItemClick(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(_subtitleAlternateFileName)) + { + SaveOriginalAstoolStripMenuItemClick(null, null); + return; + } + + try + { + SaveOriginalSubtitle(GetCurrentSubtitleFormat()); + } + catch + { + MessageBox.Show(string.Format(_language.UnableToSaveSubtitleX, _subtitleAlternateFileName)); + } + } + + private void RemoveOriginalToolStripMenuItemClick(object sender, EventArgs e) + { + if (ContinueNewOrExitAlternate()) + { + RemoveAlternate(true, true); + } + } + + private void RemoveAlternate(bool removeFromListView, bool updateRecentFiles) + { + if (removeFromListView) + { + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.TextAlternate); + SubtitleListview1.AutoSizeAllColumns(this); + _subtitleAlternate = new Subtitle(); + _subtitleAlternateFileName = null; + + if (_fileName != null && updateRecentFiles) + { + Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, VideoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs); + Configuration.Settings.Save(); + UpdateRecentFilesUI(); + } + } + + buttonUnBreak.Visible = true; + buttonAutoBreak.Visible = true; + textBoxListViewTextAlternate.Visible = false; + labelAlternateText.Visible = false; + labelAlternateCharactersPerSecond.Visible = false; + labelTextAlternateLineLengths.Visible = false; + labelAlternateSingleLine.Visible = false; + labelAlternateSingleLinePixels.Visible = false; + labelTextAlternateLineTotal.Visible = false; + textBoxListViewText.Width = (groupBoxEdit.Width - (textBoxListViewText.Left + 8 + buttonUnBreak.Width)); + textBoxListViewText.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; + labelTextLineTotal.Left = 236; + labelTextAlternateLineTotal.Left = 236; + + MainResize(); + SetTitle(); + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex, true); + } + + private void ToolStripMenuItemSpellCheckMainDropDownOpening(object sender, EventArgs e) + { + addWordToNameListToolStripMenuItem.Visible = true; + } + + private void SplitContainer1SplitterMoved(object sender, SplitterEventArgs e) + { + Main_Resize(null, null); + } + + private void ButtonSplitLineClick(object sender, EventArgs e) + { + SplitSelectedParagraph(null, null); + } + + private void ToolStripMenuItemCopySourceTextClick(object sender, EventArgs e) + { + var selectedLines = new Subtitle(_subtitle); + selectedLines.Paragraphs.Clear(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + selectedLines.Paragraphs.Add(new Paragraph(_subtitle.Paragraphs[index])); + } + + if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) + { + selectedLines.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(Configuration.Settings.General.CurrentVideoOffsetInMs)); + } + + Clipboard.SetText(selectedLines.ToText(GetCurrentSubtitleFormat()).TrimEnd()); + } + + public void PlayPause() + { + mediaPlayer.TogglePlayPause(); + } + + public void SetCurrentViaEndPositionAndGotoNext(int index, bool goToNext) + { + var p = _subtitle.GetParagraphOrDefault(index); + if (p == null) + { + return; + } + + if (mediaPlayer.VideoPlayer == null || string.IsNullOrEmpty(VideoFileName)) + { + MessageBox.Show(_languageGeneral.NoVideoLoaded); + return; + } + + var oldParagraph = new Paragraph(p, false); + + //if (autoDuration) + //{ + // // TODO: auto duration + // // TODO: Search for start via wave file (must only be minor adjustment) + //} + + // current movie Position + double durationTotalMilliseconds = p.Duration.TotalMilliseconds; + double totalMillisecondsEnd = mediaPlayer.CurrentPosition * TimeCode.BaseUnit; + + var tc = new TimeCode(totalMillisecondsEnd - durationTotalMilliseconds); + MakeHistoryForUndo(_language.BeforeSetEndAndVideoPosition + " " + tc); + _makeHistoryPaused = true; + + if (p.StartTime.IsMaxTime) + { + p.EndTime.TotalSeconds = mediaPlayer.CurrentPosition; + p.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds - Utilities.GetOptimalDisplayMilliseconds(p.Text); + } + else + { + p.StartTime.TotalMilliseconds = totalMillisecondsEnd - durationTotalMilliseconds; + p.EndTime.TotalMilliseconds = totalMillisecondsEnd; + } + + timeUpDownStartTime.TimeCode = p.StartTime; + var durationInSeconds = (decimal)(p.Duration.TotalSeconds); + if (durationInSeconds >= numericUpDownDuration.Minimum && durationInSeconds <= numericUpDownDuration.Maximum) + { + SetDurationInSeconds((double)durationInSeconds); + } + + UpdateOriginalTimeCodes(oldParagraph); + RestartHistory(); + + if (goToNext) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true); + } + + ShowStatus(string.Format(_language.VideoControls.AdjustedViaEndTime, p.StartTime.ToShortString())); + audioVisualizer.Invalidate(); + } + + public void SetCurrentStartAutoDurationAndGotoNext(int index) + { + var prev = _subtitle.GetParagraphOrDefault(index - 1); + var p = _subtitle.GetParagraphOrDefault(index); + if (p == null) + { + return; + } + + double videoPosition = mediaPlayer.CurrentPosition; + if (prev != null && Math.Abs(prev.StartTime.TotalSeconds - videoPosition) < 0.3) + { + ShowStatus("Subtitle already here"); + return; + } + + ShowNextSubtitleLabel(); + + if (mediaPlayer.VideoPlayer == null || string.IsNullOrEmpty(VideoFileName)) + { + MessageBox.Show(_languageGeneral.NoVideoLoaded); + return; + } + + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + p.Number + " " + p.Text)); + + timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; + var oldParagraph = new Paragraph(_subtitle.Paragraphs[index], false); + if (!mediaPlayer.IsPaused) + { + videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; + } + + timeUpDownStartTime.TimeCode = TimeCode.FromSeconds(videoPosition); + + double duration = Utilities.GetOptimalDisplayMilliseconds(textBoxListViewText.Text); + + _subtitle.Paragraphs[index].StartTime.TotalMilliseconds = TimeSpan.FromSeconds(videoPosition).TotalMilliseconds; + if (prev != null && prev.EndTime.TotalMilliseconds > _subtitle.Paragraphs[index].StartTime.TotalMilliseconds) + { + int minDiff = Configuration.Settings.General.MinimumMillisecondsBetweenLines + 1; + if (minDiff < 1) + { + minDiff = 1; + } + + prev.EndTime.TotalMilliseconds = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds - minDiff; + } + + _subtitle.Paragraphs[index].EndTime.TotalMilliseconds = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds + duration; + SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index], _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + timeUpDownStartTime.TimeCode = _subtitle.Paragraphs[index].StartTime; + timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; + UpdateOriginalTimeCodes(oldParagraph); + _subtitleListViewIndex = -1; + SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true); + audioVisualizer.Invalidate(); + } + + public void SetCurrentEndNextStartAndGoToNext(int index) + { + var p = _subtitle.GetParagraphOrDefault(index); + var next = _subtitle.GetParagraphOrDefault(index + 1); + if (p == null) + { + return; + } + + if (mediaPlayer.VideoPlayer == null || string.IsNullOrEmpty(VideoFileName)) + { + MessageBox.Show(_languageGeneral.NoVideoLoaded); + return; + } + + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + p.Number + " " + p.Text)); + var p1 = new Paragraph(p, false); + Paragraph p2 = null; + if (next != null) + { + p2 = new Paragraph(next, false); + } + + double videoPosition = mediaPlayer.CurrentPosition; + if (!mediaPlayer.IsPaused) + { + videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit; + } + + p.EndTime = TimeCode.FromSeconds(videoPosition); + if (p.StartTime.IsMaxTime) + { + timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged; + p.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds - Utilities.GetOptimalDisplayMilliseconds(p.Text); + if (p.StartTime.TotalMilliseconds < 0) + { + p.StartTime.TotalMilliseconds = 0; + } + + timeUpDownStartTime.TimeCode = p.StartTime; + SubtitleListview1.SetStartTimeAndDuration(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBoxTextChanged; + } + + if (p.Duration.TotalSeconds < 0 || p.Duration.TotalSeconds > 10) + { + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text); + } + + SubtitleListview1.SetStartTimeAndDuration(index, p, _subtitle.GetParagraphOrDefault(index + 1), _subtitle.GetParagraphOrDefault(index - 1)); + + SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds + 0.001); + if (next != null) + { + int addMilliseconds = Configuration.Settings.General.MinimumMillisecondsBetweenLines; + if (addMilliseconds < 1 || addMilliseconds > 500) + { + addMilliseconds = 1; + } + + var oldDuration = next.Duration.TotalMilliseconds; + if (next.StartTime.IsMaxTime || next.EndTime.IsMaxTime) + { + oldDuration = Utilities.GetOptimalDisplayMilliseconds(p.Text); + } + + next.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds + addMilliseconds; + next.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds + oldDuration; + SubtitleListview1.SetStartTimeAndDuration(index + 1, next, _subtitle.GetParagraphOrDefault(index + 2), _subtitle.GetParagraphOrDefault(index)); + SubtitleListview1.SelectIndexAndEnsureVisible(index + 1, true); + } + + UpdateOriginalTimeCodes(p1, p2); + audioVisualizer.Invalidate(); + } + + private void EditSelectAllToolStripMenuItemClick(object sender, EventArgs e) + { + for (int i = 0; i < SubtitleListview1.Items.Count; i++) + { + SubtitleListview1.Items[i].Selected = true; + } + } + + private void ToolStripMenuItemSplitTextAtCursorClick(object sender, EventArgs e) + { + var tb = GetFocusedTextBox(); + + int? pos = null; + if (tb.SelectionStart > 1 && tb.SelectionStart < tb.Text.Length - 1) + { + pos = tb.SelectionStart; + } + + SplitSelectedParagraph(null, pos); + tb.Focus(); + tb.SelectionStart = tb.Text.Length; + } + + private void toolStripMenuItemSplitViaWaveform_Click(object sender, EventArgs e) + { + var tb = GetFocusedTextBox(); + if (tb.SelectionStart > 1 && tb.SelectionStart < tb.Text.Length - 1) + { + int? pos = tb.SelectionStart; + SplitSelectedParagraph(mediaPlayer.CurrentPosition, pos); + tb.Focus(); + tb.SelectionStart = tb.Text.Length; + } + } + + private void ContextMenuStripTextBoxListViewOpening(object sender, System.ComponentModel.CancelEventArgs e) + { + var tb = GetFocusedTextBox(); + toolStripMenuItemSplitTextAtCursor.Visible = tb.Text.Length > 1; + + if (IsUnicode) + { + if (toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Count == 0) + { + foreach (var s in Configuration.Settings.Tools.UnicodeSymbolsToInsert.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) + { + toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Add(s, null, InsertUnicodeGlyph); + if (Environment.OSVersion.Version.Major < 6 && Configuration.Settings.General.SubtitleFontName == Utilities.WinXP2KUnicodeFontName) // 6 == Vista/Win2008Server/Win7 + { + toolStripMenuItemInsertUnicodeSymbol.DropDownItems[toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Count - 1].Font = new Font(Utilities.WinXP2KUnicodeFontName, toolStripMenuItemInsertUnicodeSymbol.Font.Size); + } + } + } + + toolStripMenuItemInsertUnicodeSymbol.Visible = toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Count > 0; + toolStripSeparator26.Visible = toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Count > 0; + + superscriptToolStripMenuItem.Visible = tb.SelectionLength > 0; + subscriptToolStripMenuItem.Visible = tb.SelectionLength > 0; + toolStripMenuItemInsertUnicodeControlCharacters.Visible = true; + } + else + { + toolStripMenuItemInsertUnicodeSymbol.Visible = false; + toolStripSeparator26.Visible = false; + superscriptToolStripMenuItem.Visible = false; + subscriptToolStripMenuItem.Visible = false; + toolStripMenuItemInsertUnicodeControlCharacters.Visible = false; + } + + var formatType = GetCurrentSubtitleFormat().GetType(); + if (formatType == typeof(WebVTT) && tb.SelectionLength > 0) + { + toolStripSeparatorWebVTT.Visible = true; + toolStripMenuItemWebVttVoice.Visible = true; + var voices = WebVTT.GetVoices(_subtitle); + toolStripMenuItemWebVttVoice.DropDownItems.Clear(); + foreach (var style in voices) + { + toolStripMenuItemWebVttVoice.DropDownItems.Add(style, null, WebVTTSetVoiceTextBox); + } + + toolStripMenuItemWebVttVoice.DropDownItems.Add(_language.Menu.ContextMenu.WebVTTSetNewVoice, null, WebVTTSetNewVoiceTextBox); + } + else + { + toolStripSeparatorWebVTT.Visible = false; + toolStripMenuItemWebVttVoice.Visible = false; + toolStripMenuItemWebVttVoice.Visible = false; + } + + if (formatType == typeof(NetflixImsc11Japanese)) + { + boldToolStripMenuItem1.Visible = false; + underlineToolStripMenuItem1.Visible = false; + colorToolStripMenuItem1.Visible = false; + fontNameToolStripMenuItem.Visible = false; + toolStripMenuItemHorizontalDigits.Visible = true; + if (tb.SelectionLength > 0) + { + toolStripMenuItemBouten.Visible = true; + toolStripMenuItemRuby.Visible = true; + } + else + { + toolStripMenuItemBouten.Visible = false; + toolStripMenuItemRuby.Visible = true; + } + + if (tb.SelectionLength > 1 && tb.SelectionLength < 8) + { + toolStripMenuItemHorizontalDigits.Visible = true; + } + else + { + toolStripMenuItemHorizontalDigits.Visible = false; + } + } + else if (formatType == typeof(Sami) || formatType == typeof(SamiModern)) + { + boldToolStripMenuItem1.Visible = true; + underlineToolStripMenuItem1.Visible = true; + colorToolStripMenuItem1.Visible = true; + fontNameToolStripMenuItem.Visible = true; + toolStripMenuItemHorizontalDigits.Visible = false; + toolStripMenuItemBouten.Visible = false; + if (tb.SelectionLength > 0) + { + toolStripMenuItemRuby.Visible = true; + } + else + { + toolStripMenuItemRuby.Visible = true; + } + } + else if (formatType == typeof(Ebu)) + { + Ebu.EbuGeneralSubtitleInformation header; + if (_subtitle != null && _subtitle.Header != null && (_subtitle.Header.Contains("STL2") || _subtitle.Header.Contains("STL3"))) + { + header = Ebu.ReadHeader(Encoding.UTF8.GetBytes(_subtitle.Header)); + } + else + { + header = new Ebu.EbuGeneralSubtitleInformation(); + } + + var open = header.DisplayStandardCode != "1" && header.DisplayStandardCode != "2"; + boxToolStripMenuItem.Visible = open; + } + else + { + boxToolStripMenuItem1.Visible = false; + boldToolStripMenuItem1.Visible = true; + underlineToolStripMenuItem1.Visible = true; + colorToolStripMenuItem1.Visible = true; + fontNameToolStripMenuItem.Visible = true; + toolStripMenuItemBouten.Visible = false; + toolStripMenuItemRuby.Visible = false; + toolStripMenuItemHorizontalDigits.Visible = false; + } + + if (tb.SelectionStart > 1 && tb.SelectionStart < tb.Text.Length - 1 && !string.IsNullOrEmpty(VideoFileName) && mediaPlayer != null && + _subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) + { + int firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + var currentParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex); + var splitSeconds = mediaPlayer.CurrentPosition; + if (splitSeconds > (currentParagraph.StartTime.TotalSeconds + 0.2) && splitSeconds < (currentParagraph.EndTime.TotalSeconds - 0.2)) + { + toolStripMenuItemSplitViaWaveform.Visible = true; + } + else + { + toolStripMenuItemSplitViaWaveform.Visible = false; + } + } + else + { + toolStripMenuItemSplitViaWaveform.Visible = false; + } + } + + private void ToolStripMenuItemExportPngXmlClick(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "BDNXML", _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + private void TabControlSubtitleSelecting(object sender, TabControlCancelEventArgs e) + { + if (tabControlSubtitle.SelectedIndex != TabControlSourceView && textBoxSource.Text.Trim().Length > 1) + { + var currentFormat = GetCurrentSubtitleFormat(); + if (currentFormat != null && !currentFormat.IsTextBased) + { + return; + } + + var format = new Subtitle().ReloadLoadSubtitle(textBoxSource.Lines.ToList(), null, currentFormat); + if (format == null) + { + e.Cancel = true; + } + } + } + + private void ToolStripComboBoxFrameRateTextChanged(object sender, EventArgs e) + { + Configuration.Settings.General.CurrentFrameRate = CurrentFrameRate; + if (_loading) + { + return; + } + + SubtitleListview1.UpdateFrames(_subtitle); + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + ShowSource(); + } + } + + private void ToolStripMenuItemGoogleMicrosoftTranslateSelLineClick(object sender, EventArgs e) + { + int firstSelectedIndex = FirstSelectedIndex; + if (firstSelectedIndex >= 0) + { + var p = _subtitle.GetParagraphOrDefault(firstSelectedIndex); + if (p != null) + { + string defaultFromLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); + if (_subtitleAlternate != null) + { + var o = Utilities.GetOriginalParagraph(firstSelectedIndex, p, _subtitleAlternate.Paragraphs); + if (o != null) + { + p = o; + defaultFromLanguage = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitleAlternate); + } + } + + Cursor = Cursors.WaitCursor; + if (_googleOrMicrosoftTranslate == null || _googleOrMicrosoftTranslate.IsDisposed) + { + _googleOrMicrosoftTranslate = new GoogleOrMicrosoftTranslate(); + _googleOrMicrosoftTranslate.InitializeFromLanguage(defaultFromLanguage); + } + + _googleOrMicrosoftTranslate.Initialize(p); + Cursor = Cursors.Default; + if (_googleOrMicrosoftTranslate.ShowDialog() == DialogResult.OK) + { + textBoxListViewText.Text = _googleOrMicrosoftTranslate.TranslatedText; + } + } + } + } + + private void NumericUpDownSec1ValueChanged(object sender, EventArgs e) + { + Configuration.Settings.General.SmallDelayMilliseconds = (int)(numericUpDownSec1.Value * 1000); + } + + private void NumericUpDownSec2ValueChanged(object sender, EventArgs e) + { + Configuration.Settings.General.LargeDelayMilliseconds = (int)(numericUpDownSec2.Value * 1000); + } + + private void NumericUpDownSecAdjust1ValueChanged(object sender, EventArgs e) + { + Configuration.Settings.General.SmallDelayMilliseconds = (int)(numericUpDownSecAdjust1.Value * 1000); + } + + private void NumericUpDownSecAdjust2ValueChanged(object sender, EventArgs e) + { + Configuration.Settings.General.LargeDelayMilliseconds = (int)(numericUpDownSecAdjust2.Value * 1000); + } + + private void ToolStripMenuItemMakeEmptyFromCurrentClick(object sender, EventArgs e) + { + if (ContinueNewOrExit()) + { + bool isAlternateVisible = SubtitleListview1.IsAlternateTextColumnVisible; + _subtitleAlternate = new Subtitle(_subtitle); + _subtitleAlternateFileName = null; + int oldIndex = FirstSelectedIndex; + if (oldIndex < 0) + { + oldIndex = 0; + } + + foreach (var p in _subtitle.Paragraphs) + { + if (Configuration.Settings.General.RemoveBlankLinesWhenOpening && string.IsNullOrEmpty(Configuration.Settings.Tools.NewEmptyTranslationText)) + { + p.Text = "-"; + } + else if (Configuration.Settings.Tools.NewEmptyTranslationText != null) + { + p.Text = Configuration.Settings.Tools.NewEmptyTranslationText; + } + else + { + p.Text = string.Empty; + } + } + + SubtitleListview1.ShowAlternateTextColumn(_languageGeneral.OriginalText); + _subtitleListViewIndex = -1; + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(oldIndex, true); + textBoxListViewText.Focus(); + Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable = true; + + _subtitleAlternateFileName = _fileName; + _fileName = null; + SetupAlternateEdit(); + ResetHistory(); + + if (!isAlternateVisible || toolStripMenuItemShowOriginalInPreview.Checked) + { + toolStripMenuItemShowOriginalInPreview.Checked = false; + Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable = false; + audioVisualizer.Invalidate(); + } + } + } + + private void ToolStripMenuItemShowOriginalInPreviewClick(object sender, EventArgs e) + { + toolStripMenuItemShowOriginalInPreview.Checked = !toolStripMenuItemShowOriginalInPreview.Checked; + Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable = toolStripMenuItemShowOriginalInPreview.Checked; + } + + private void ToolStripMenuItemVideoDropDownClosed(object sender, EventArgs e) + { + redockVideoControlsToolStripMenuItem.ShortcutKeys = Keys.None; + undockVideoControlsToolStripMenuItem.ShortcutKeys = Keys.None; + } + + private void ToolsToolStripMenuItemDropDownOpening(object sender, EventArgs e) + { + if (_subtitle?.Paragraphs.Count > 0 && _networkSession == null) + { + toolStripSeparator23.Visible = true; + toolStripMenuItemMakeEmptyFromCurrent.Visible = !SubtitleListview1.IsAlternateTextColumnVisible; + toolStripMenuItemShowOriginalInPreview.Checked = Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable; + } + else + { + toolStripSeparator23.Visible = false; + toolStripMenuItemMakeEmptyFromCurrent.Visible = false; + toolStripMenuItemShowOriginalInPreview.Checked = false; + } + + var f = GetCurrentSubtitleFormat(); + styleToolStripMenuItem.Visible = f.HasStyleSupport; + var formatType = f.GetType(); + actorToolStripMenuItem.Visible = formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha); + } + + private void ContextMenuStripWaveformOpening(object sender, System.ComponentModel.CancelEventArgs e) + { + if (audioVisualizer.IsSpectrogramAvailable) + { + if (audioVisualizer.ShowSpectrogram && audioVisualizer.ShowWaveform) + { + showWaveformAndSpectrogramToolStripMenuItem.Visible = false; + showOnlyWaveformToolStripMenuItem.Visible = true; + showOnlySpectrogramToolStripMenuItem.Visible = true; + toolStripSeparatorGuessTimeCodes.Visible = true; + } + else if (audioVisualizer.ShowSpectrogram) + { + showWaveformAndSpectrogramToolStripMenuItem.Visible = true; + showOnlyWaveformToolStripMenuItem.Visible = true; + showOnlySpectrogramToolStripMenuItem.Visible = false; + toolStripSeparatorGuessTimeCodes.Visible = true; + } + else + { + showWaveformAndSpectrogramToolStripMenuItem.Visible = true; + showOnlyWaveformToolStripMenuItem.Visible = false; + showOnlySpectrogramToolStripMenuItem.Visible = true; + toolStripSeparatorGuessTimeCodes.Visible = true; + } + } + else + { + toolStripSeparator24.Visible = false; + showWaveformAndSpectrogramToolStripMenuItem.Visible = false; + showOnlyWaveformToolStripMenuItem.Visible = false; + showOnlySpectrogramToolStripMenuItem.Visible = false; + toolStripSeparatorGuessTimeCodes.Visible = false; + } + + insertSubtitleHereToolStripMenuItem.Visible = !_subtitle.Paragraphs.Any(p => p.StartTime.TotalSeconds <= mediaPlayer.CurrentPosition + 1.0 && + p.EndTime.TotalSeconds <= mediaPlayer.CurrentPosition + 1.0 && + p.EndTime.TotalSeconds >= mediaPlayer.CurrentPosition); + } + + private void ShowWaveformAndSpectrogramToolStripMenuItemClick(object sender, EventArgs e) + { + audioVisualizer.ShowSpectrogram = true; + audioVisualizer.ShowWaveform = true; + } + + private void ShowOnlyWaveformToolStripMenuItemClick(object sender, EventArgs e) + { + audioVisualizer.ShowSpectrogram = false; + audioVisualizer.ShowWaveform = true; + } + + private void ShowOnlySpectrogramToolStripMenuItemClick(object sender, EventArgs e) + { + audioVisualizer.ShowSpectrogram = true; + audioVisualizer.ShowWaveform = false; + } + + private void SplitContainerMainSplitterMoved(object sender, SplitterEventArgs e) + { + mediaPlayer.Refresh(); + } + + private void FindDoubleLinesToolStripMenuItemClick(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + for (int i = FirstSelectedIndex + 1; i < _subtitle.Paragraphs.Count; i++) + { + var current = _subtitle.GetParagraphOrDefault(i); + var next = _subtitle.GetParagraphOrDefault(i + 1); + if (current != null && next != null) + { + if (current.Text.Trim().Equals(next.Text.Trim(), StringComparison.OrdinalIgnoreCase)) + { + SubtitleListview1.SelectIndexAndEnsureVisible(i, true); + SubtitleListview1.Items[i + 1].Selected = true; + break; + } + } + } + } + + private void TextBoxListViewTextAlternateMouseMove(object sender, MouseEventArgs e) + { + if (Control.ModifierKeys == Keys.Control && MouseButtons == MouseButtons.Left) + { + if (!string.IsNullOrEmpty(textBoxListViewTextAlternate.SelectedText)) + { + textBoxListViewTextAlternate.DoDragDrop(textBoxListViewTextAlternate.SelectedText, DragDropEffects.Copy); + } + else + { + textBoxListViewTextAlternate.DoDragDrop(textBoxListViewTextAlternate.Text, DragDropEffects.Copy); + } + } + else if ((AutoRepeatContinueOn || AutoRepeatOn) && !textBoxSearchWord.Focused && textBoxListViewTextAlternate.Focused) + { + string selectedText = textBoxListViewTextAlternate.SelectedText; + if (!string.IsNullOrEmpty(selectedText)) + { + selectedText = selectedText.Trim(); + selectedText = selectedText.TrimEnd('.', ',', '!', '?').TrimEnd(); + if (!string.IsNullOrEmpty(selectedText) && selectedText != textBoxSearchWord.Text) + { + textBoxSearchWord.Text = HtmlUtil.RemoveHtmlTags(selectedText); + } + } + } + } + + private void EBustlToolStripMenuItemClick(object sender, EventArgs e) + { + var ebu = new Ebu(); + saveFileDialog1.Filter = ebu.Name + "|*" + ebu.Extension; + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*" + ebu.Extension; + saveFileDialog1.AddExtension = true; + + if (!string.IsNullOrEmpty(VideoFileName)) + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); + } + else + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); + } + + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + string fileName = saveFileDialog1.FileName; + string ext = Path.GetExtension(fileName); + bool extOk = ext.Equals(ebu.Extension, StringComparison.OrdinalIgnoreCase); + if (!extOk) + { + if (fileName.EndsWith('.')) + { + fileName = fileName.Substring(0, fileName.Length - 1); + } + + fileName += ebu.Extension; + } + + new Ebu().Save(fileName, GetSaveSubtitle(_subtitle)); + } + } + + private void ToolStripMenuItemCavena890Click(object sender, EventArgs e) + { + var cavena890 = new Cavena890(); + saveFileDialog1.Filter = cavena890.Name + "|*" + cavena890.Extension; + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*" + cavena890.Extension; + saveFileDialog1.AddExtension = true; + + if (!string.IsNullOrEmpty(VideoFileName)) + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); + } + else + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); + } + + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + string fileName = saveFileDialog1.FileName; + string ext = Path.GetExtension(fileName); + bool extOk = ext.Equals(cavena890.Extension, StringComparison.OrdinalIgnoreCase); + if (!extOk) + { + if (fileName.EndsWith('.')) + { + fileName = fileName.Substring(0, fileName.Length - 1); + } + + fileName += cavena890.Extension; + } + + using (var form = new Cavena890SaveOptions(_subtitle, _fileName)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + cavena890.Save(fileName, GetSaveSubtitle(_subtitle)); + } + } + } + } + + private void PacScreenElectronicsToolStripMenuItemClick(object sender, EventArgs e) + { + var pac = new Pac(); + saveFileDialog1.Filter = pac.Name + "|*" + pac.Extension; + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*" + pac.Extension; + saveFileDialog1.AddExtension = true; + + if (!string.IsNullOrEmpty(VideoFileName)) + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); + } + else + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); + } + + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + string fileName = saveFileDialog1.FileName; + string ext = Path.GetExtension(fileName); + bool extOk = ext.Equals(pac.Extension, StringComparison.OrdinalIgnoreCase); + if (!extOk) + { + if (fileName.EndsWith('.')) + { + fileName = fileName.Substring(0, fileName.Length - 1); + } + + fileName += pac.Extension; + } + + pac.Save(fileName, GetSaveSubtitle(_subtitle)); + } + } + + private void uniPacExportToolStripMenuItem_Click(object sender, EventArgs e) + { + var uniPac = new PacUnicode(); + saveFileDialog1.Filter = uniPac.Name + "|*" + uniPac.Extension; + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*" + uniPac.Extension; + saveFileDialog1.AddExtension = true; + + if (!string.IsNullOrEmpty(VideoFileName)) + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); + } + else + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); + } + + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + string fileName = saveFileDialog1.FileName; + string ext = Path.GetExtension(fileName); + bool extOk = ext.Equals(uniPac.Extension, StringComparison.OrdinalIgnoreCase); + if (!extOk) + { + if (fileName.EndsWith('.')) + { + fileName = fileName.Substring(0, fileName.Length - 1); + } + + fileName += uniPac.Extension; + } + + uniPac.Save(fileName, GetSaveSubtitle(_subtitle)); + } + } + + private void toolStripMenuItemExportAyato_Click(object sender, EventArgs e) + { + var ayato = new Ayato(); + saveFileDialog1.Filter = ayato.Name + "|*" + ayato.Extension; + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*" + ayato.Extension; + saveFileDialog1.AddExtension = true; + + if (!string.IsNullOrEmpty(VideoFileName)) + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); + } + else + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); + } + + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + string fileName = saveFileDialog1.FileName; + string ext = Path.GetExtension(fileName); + bool extOk = ext.Equals(ayato.Extension, StringComparison.OrdinalIgnoreCase); + if (!extOk) + { + if (fileName.EndsWith('.')) + { + fileName = fileName.Substring(0, fileName.Length - 1); + } + + fileName += ayato.Extension; + } + + ayato.Save(fileName, VideoFileName, GetSaveSubtitle(_subtitle)); + } + } + + private void TextBoxListViewTextEnter(object sender, EventArgs e) + { + if (_findHelper != null) + { + _findHelper.MatchInOriginal = false; + } + + if (_measurementConverter != null) + { + _measurementConverter.IsOriginalActive = false; + } + } + + private void TextBoxListViewTextAlternateEnter(object sender, EventArgs e) + { + if (_findHelper != null) + { + _findHelper.MatchInOriginal = true; + } + + if (_measurementConverter != null) + { + _measurementConverter.IsOriginalActive = true; + } + } + + private void PlainTextToolStripMenuItemClick(object sender, EventArgs e) + { + using (var exportText = new ExportText()) + { + exportText.Initialize(GetSaveSubtitle(_subtitle), _fileName); + if (exportText.ShowDialog() == DialogResult.OK) + { + ShowStatus(_language.SubtitleExported); + } + } + } + + private void BluraySupToolStripMenuItemClick(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.BluraySup, _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + private void VobSubsubidxToolStripMenuItemClick(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.VobSub, _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + private void TextBoxListViewTextAlternateKeyUp(object sender, KeyEventArgs e) + { + textBoxListViewTextAlternate.ClearUndo(); + UpdatePositionAndTotalLength(labelTextAlternateLineTotal, textBoxListViewTextAlternate); + } + + private void TimerTextUndoTick(object sender, EventArgs e) + { + if (_subtitle == null || _subtitle.Paragraphs.Count == 0 || _listViewTextTicks == -1 || !CanFocus) + { + return; + } + + // progress check + ShowTranslationProgress(); + + // text undo + int index = _listViewTextUndoIndex; + if (index == -1) + { + index = _subtitleListViewIndex; + } + + if (index < 0 || index >= _subtitle.Paragraphs.Count) + { + return; + } + + if ((DateTime.UtcNow.Ticks - _listViewTextTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds + { + if (index < 0 || index >= _subtitle.Paragraphs.Count) + { + return; + } + + string newText = _subtitle.Paragraphs[index].Text.TrimEnd(); + string oldText = _listViewTextUndoLast; + if (oldText == null) + { + return; + } + + if (_listViewTextUndoLast != newText) + { + MakeHistoryForUndo(_languageGeneral.Text + ": " + _listViewTextUndoLast.TrimEnd() + " -> " + newText, false); + int hidx = _subtitle.HistoryItems.Count - 1; + if (hidx >= 0 && hidx < _subtitle.HistoryItems.Count) + { + _subtitle.HistoryItems[hidx].Subtitle.Paragraphs[index].Text = _listViewTextUndoLast; + } + + _listViewTextUndoLast = newText; + _listViewTextUndoIndex = -1; + } + } + } + + private void ShowTranslationProgress() + { + if (Configuration.Settings.General.ShowProgress) + { + if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + int numberOfNonBlankLines = 0; + foreach (var paragraph in _subtitle.Paragraphs) + { + if (!string.IsNullOrWhiteSpace(paragraph.Text)) + { + numberOfNonBlankLines++; + } + } + + int percent = (int)Math.Round(numberOfNonBlankLines * 100.0 / _subtitle.Paragraphs.Count); + toolStripStatusLabelProgress.Text = string.Format("{0}% completed", percent); + if (!toolStripStatusLabelProgress.Visible) + { + toolStripStatusLabelProgress.Visible = true; + } + } + else if (_subtitle.Paragraphs.Count > 0 && !string.IsNullOrWhiteSpace(VideoFileName) && mediaPlayer != null && mediaPlayer.VideoPlayer != null && mediaPlayer.VideoPlayer.Duration > 0) + { + var last = _subtitle.Paragraphs.LastOrDefault(); + if (last != null && !last.StartTime.IsMaxTime) + { + var subtitleEndSeconds = last.EndTime.TotalSeconds; + var videoEndSeconds = mediaPlayer.VideoPlayer.Duration; + int percent = (int)Math.Round(subtitleEndSeconds * 100.0 / videoEndSeconds); + toolStripStatusLabelProgress.Text = string.Format("{0}% completed", percent); + if (!toolStripStatusLabelProgress.Visible) + { + toolStripStatusLabelProgress.Visible = true; + } + } + } + else + { + toolStripStatusLabelProgress.Visible = false; + } + } + } + + private void TimerAlternateTextUndoTick(object sender, EventArgs e) + { + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + int index = _listViewTextUndoIndex; + if (index == -1) + { + index = _subtitleListViewIndex; + } + + if (_listViewAlternateTextTicks == -1 || !CanFocus || _subtitleAlternate == null || _subtitleAlternate.Paragraphs.Count == 0 || index < 0 || index >= _subtitleAlternate.Paragraphs.Count) + { + return; + } + + if ((DateTime.UtcNow.Ticks - _listViewAlternateTextTicks) > 10000 * 700) // only if last typed char was entered > 700 milliseconds + { + var original = Utilities.GetOriginalParagraph(index, _subtitle.Paragraphs[index], _subtitleAlternate.Paragraphs); + if (original != null) + { + index = _subtitleAlternate.Paragraphs.IndexOf(original); + } + else + { + return; + } + + string newText = _subtitleAlternate.Paragraphs[index].Text.TrimEnd(); + string oldText = _listViewAlternateTextUndoLast; + if (oldText == null || index < 0) + { + return; + } + + if (_listViewAlternateTextUndoLast != newText && _subtitle.HistoryItems.Count > 0 && + index < _subtitle.HistoryItems[_subtitle.HistoryItems.Count - 1].OriginalSubtitle.Paragraphs.Count) + { + MakeHistoryForUndo(_languageGeneral.Text + ": " + _listViewAlternateTextUndoLast.TrimEnd() + " -> " + newText, false); + _subtitle.HistoryItems[_subtitle.HistoryItems.Count - 1].OriginalSubtitle.Paragraphs[index].Text = _listViewAlternateTextUndoLast; + + _listViewAlternateTextUndoLast = newText; + _listViewTextUndoIndex = -1; + } + } + } + } + + private void UpdatePositionAndTotalLength(Label lineTotal, SETextBox textBox) + { + if (string.IsNullOrEmpty(textBox.Text)) + { + lineTotal.Text = string.Empty; + return; + } + + int extraNewLineLength = Environment.NewLine.Length - 1; + int lineBreakPos = textBox.Text.IndexOf(Environment.NewLine, StringComparison.Ordinal); + int pos = textBox.SelectionStart; + var s = HtmlUtil.RemoveHtmlTags(textBox.Text, true).Replace(Environment.NewLine, string.Empty); // we don't count new line in total length... correct? + int totalLength = s.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics); + string totalL; + + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var totalLengthPixels = TextWidth.CalcPixelWidth(s); + totalL = " " + string.Format(_languageGeneral.TotalLengthX, string.Format("{0} {1}", totalLength, totalLengthPixels)); + } + else + { + totalL = " " + string.Format(_languageGeneral.TotalLengthX, totalLength); + } + + if (lineBreakPos < 0 || pos <= lineBreakPos) + { + lineTotal.Text = "1," + (pos + 1) + totalL; + lineTotal.Left = textBox.Left + (textBox.Width - lineTotal.Width); + return; + } + + int secondLineBreakPos = textBox.Text.IndexOf(Environment.NewLine, lineBreakPos + 1, StringComparison.Ordinal); + if (secondLineBreakPos < 0 || pos <= secondLineBreakPos + extraNewLineLength) + { + lineTotal.Text = "2," + (pos - (lineBreakPos + extraNewLineLength)) + totalL; + lineTotal.Left = textBox.Left + (textBox.Width - lineTotal.Width); + return; + } + + int thirdLineBreakPos = textBox.Text.IndexOf(Environment.NewLine, secondLineBreakPos + 1, StringComparison.Ordinal); + if (thirdLineBreakPos < 0 || pos < thirdLineBreakPos + (extraNewLineLength * 2)) + { + lineTotal.Text = "3," + (pos - (secondLineBreakPos + extraNewLineLength)) + totalL; + lineTotal.Left = textBox.Left + (textBox.Width - lineTotal.Width); + return; + } + + int forthLineBreakPos = textBox.Text.IndexOf(Environment.NewLine, thirdLineBreakPos + 1, StringComparison.Ordinal); + if (forthLineBreakPos < 0 || pos < forthLineBreakPos + (extraNewLineLength * 3)) + { + lineTotal.Text = "4," + (pos - (thirdLineBreakPos + extraNewLineLength)) + totalL; + lineTotal.Left = textBox.Left + (textBox.Width - lineTotal.Width); + return; + } + + lineTotal.Text = string.Empty; + } + + private void TextBoxListViewTextMouseClick(object sender, MouseEventArgs e) + { + UpdatePositionAndTotalLength(labelTextLineTotal, textBoxListViewText); + } + + private void TextBoxListViewTextAlternateMouseClick(object sender, MouseEventArgs e) + { + UpdatePositionAndTotalLength(labelTextAlternateLineTotal, textBoxListViewTextAlternate); + } + + private void TabControlButtonsDrawItem(object sender, DrawItemEventArgs e) + { + var tc = (TabControl)sender; + var textBrush = new SolidBrush(ForeColor); + var tabFont = new Font(tc.Font, FontStyle.Regular); + if (e.State == DrawItemState.Selected) + { + tabFont = new Font(tc.Font, FontStyle.Bold); + e.Graphics.FillRectangle(new SolidBrush(SystemColors.Window), e.Bounds); + } + + Rectangle tabBounds = tc.GetTabRect(e.Index); + var stringFlags = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; + e.Graphics.DrawString(tc.TabPages[e.Index].Text.Trim(), tabFont, textBrush, tabBounds, new StringFormat(stringFlags)); + } + + public void GotoNextSubPosFromVideoPos() + { + if (mediaPlayer.VideoPlayer != null && _subtitle != null) + { + double ms = mediaPlayer.VideoPlayer.CurrentPosition * TimeCode.BaseUnit; + foreach (var p in _subtitle.Paragraphs) + { + if (p.EndTime.TotalMilliseconds > ms && p.StartTime.TotalMilliseconds < ms) + { + // current sub + } + else if (p.Duration.TotalSeconds < 10 && p.StartTime.TotalMilliseconds > ms) + { + mediaPlayer.VideoPlayer.CurrentPosition = p.StartTime.TotalSeconds; + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(p), true); + return; + } + } + } + } + + public void GotoPrevSubPosFromvideoPos() + { + if (mediaPlayer.VideoPlayer != null && _subtitle != null) + { + double ms = mediaPlayer.VideoPlayer.CurrentPosition * TimeCode.BaseUnit; + int i = _subtitle.Paragraphs.Count - 1; + while (i >= 0) + { + var p = _subtitle.Paragraphs[i]; + if (p.EndTime.TotalMilliseconds > ms && p.StartTime.TotalMilliseconds < ms) + { + // current sub + } + else if (p.Duration.TotalSeconds < 10 && p.StartTime.TotalMilliseconds < ms) + { + mediaPlayer.VideoPlayer.CurrentPosition = p.StartTime.TotalSeconds; + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(p), true); + return; + } + + i--; + } + } + } + + private void AdobeEncoreFabImageScriptToolStripMenuItemClick(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.Fab, _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + private void ToolStripMenuItemMergeDialogClick(object sender, EventArgs e) + { + MergeDialogs(); + } + + private void MainKeyUp(object sender, KeyEventArgs e) + { + if (_mainCreateStartDownEndUpParagraph != null) + { + var p = _subtitle.Paragraphs[_subtitleListViewIndex]; + if (p.ToString() == _mainCreateStartDownEndUpParagraph.ToString()) + { + ButtonSetEndClick(null, null); + } + + _mainCreateStartDownEndUpParagraph = null; + } + else if (_mainAdjustStartDownEndUpAndGoToNextParagraph != null) + { + var p = _subtitle.Paragraphs[_subtitleListViewIndex]; + if (p.ToString() == _mainAdjustStartDownEndUpAndGoToNextParagraph.ToString()) + { + double videoPositionInSeconds = mediaPlayer.CurrentPosition; + if (p.StartTime.TotalSeconds + 0.1 < videoPositionInSeconds) + { + ButtonSetEndClick(null, null); + } + + SubtitleListview1.SelectIndexAndEnsureVisible(_subtitleListViewIndex + 1, true); + } + + _mainAdjustStartDownEndUpAndGoToNextParagraph = null; + } + } + + private void ToolStripMenuItemSurroundWithMusicSymbolsClick(object sender, EventArgs e) + { + string tag = Configuration.Settings.Tools.MusicSymbol; + if (string.IsNullOrWhiteSpace(tag)) + { + return; + } + + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) + { + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + MakeHistoryForUndo(string.Format(_language.BeforeAddingTagX, tag)); + + var indices = new List(); + foreach (ListViewItem item in SubtitleListview1.SelectedItems) + { + indices.Add(item.Index); + } + + SubtitleListview1.BeginUpdate(); + foreach (int i in indices) + { + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(i, _subtitle.Paragraphs[i], _subtitleAlternate.Paragraphs); + if (original != null) + { + original.Text = ToogleMusicSymbols(tag, original.Text); + SubtitleListview1.SetAlternateText(i, original.Text); + } + } + + _subtitle.Paragraphs[i].Text = ToogleMusicSymbols(tag, _subtitle.Paragraphs[i].Text); + SubtitleListview1.SetText(i, _subtitle.Paragraphs[i].Text); + } + + SubtitleListview1.EndUpdate(); + + ShowStatus(string.Format(_language.TagXAdded, tag)); + ShowSource(); + RefreshSelectedParagraph(); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + } + } + + private string ToogleMusicSymbols(string tag, string text) + { + string pre = string.Empty; + string post = string.Empty; + var indexOfEndBracket = text.IndexOf('}'); + if (text.StartsWith("{\\", StringComparison.Ordinal) && indexOfEndBracket > 1) + { + pre = text.Substring(0, indexOfEndBracket + 1); + text = text.Remove(0, indexOfEndBracket + 1); + } + + bool updated = true; + while (updated) + { + updated = false; + if (text.StartsWith(' ')) + { + pre += ' '; + text = text.Remove(0, 1); + updated = true; + } + else if (text.StartsWith("'); + if (endFont > 0) + { + pre += text.Substring(0, endFont + 1); + text = text.Remove(0, endFont + 1); + updated = true; + } + + if (text.EndsWith("
", StringComparison.OrdinalIgnoreCase)) + { + var endTag = "
"; + post += endTag; + text = text.Remove(text.Length - endTag.Length, endTag.Length); + } + } + } + + if (text.Contains(tag)) + { + text = pre + text.Replace(tag, string.Empty).Replace(Environment.NewLine + " ", Environment.NewLine).Replace(" " + Environment.NewLine, Environment.NewLine).Trim() + post; + } + else + { + if (Configuration.Settings.Tools.MusicSymbolStyle.Equals("single", StringComparison.OrdinalIgnoreCase)) + { + text = string.Format("{0}{1} {2}{3}", pre, tag, text.Replace(Environment.NewLine, Environment.NewLine + tag + " "), post); + } + else + { + text = string.Format("{0}{1} {2} {1}{3}", pre, tag, text.Replace(Environment.NewLine, " " + tag + Environment.NewLine + tag + " "), post); + } + } + + return text; + } + + private void SuperscriptToolStripMenuItemClick(object sender, EventArgs e) + { + var tb = GetFocusedTextBox(); + + string text = tb.SelectedText; + int selectionStart = tb.SelectionStart; + text = Utilities.ToSuperscript(text); + tb.SelectedText = text; + tb.SelectionStart = selectionStart; + tb.SelectionLength = text.Length; + } + + private void SubscriptToolStripMenuItemClick(object sender, EventArgs e) + { + var tb = GetFocusedTextBox(); + + string text = tb.SelectedText; + int selectionStart = tb.SelectionStart; + text = Utilities.ToSubscript(text); + tb.SelectedText = text; + tb.SelectionStart = selectionStart; + tb.SelectionLength = text.Length; + } + + private void ToolStripMenuItemImagePerFrameClick(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.ImageFrame, _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + private void toolStripMenuItemApplyDisplayTimeLimits_Click(object sender, EventArgs e) + { + ApplyDisplayTimeLimits(false); + } + + private void ApplyDisplayTimeLimits(bool onlySelectedLines) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + using (var applyDurationLimits = new ApplyDurationLimits()) + { + if (onlySelectedLines) + { + var selectedLines = new Subtitle(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]); + } + + applyDurationLimits.Initialize(selectedLines); + } + else + { + applyDurationLimits.Initialize(_subtitle); + } + + if (applyDurationLimits.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeDisplayTimeAdjustment); + + if (onlySelectedLines) + { // we only update selected lines + int i = 0; + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index] = applyDurationLimits.FixedSubtitle.Paragraphs[i]; + i++; + } + + ShowStatus(_language.VisualSyncPerformedOnSelectedLines); + SubtitleListview1.SyntaxColorAllLines(_subtitle); + } + else + { + SaveSubtitleListviewIndices(); + _subtitle.Paragraphs.Clear(); + foreach (var p in applyDurationLimits.FixedSubtitle.Paragraphs) + { + _subtitle.Paragraphs.Add(new Paragraph(p)); + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + ShowSource(); + } + } + } + + private void generateDatetimeInfoFromVideoToolStripMenuItem_Click(object sender, EventArgs e) + { + ReloadFromSourceView(); + using (var extractDateTimeInfo = new ExtractDateTimeInfo()) + { + if (extractDateTimeInfo.ShowDialog(this) == DialogResult.OK) + { + if (ContinueNewOrExit()) + { + MakeHistoryForUndo(_language.BeforeDisplayTimeAdjustment); + + ResetSubtitle(); + _subtitle.Paragraphs.Clear(); + foreach (var p in extractDateTimeInfo.DateTimeSubtitle.Paragraphs) + { + _subtitle.Paragraphs.Add(new Paragraph(p)); + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + ShowSource(); + OpenVideo(extractDateTimeInfo.VideoFileName); + } + } + } + } + + private void ToolStripMenuItemRightToLeftModeClick(object sender, EventArgs e) + { + var focusedItem = SubtitleListview1.FocusedItem; + toolStripMenuItemRightToLeftMode.Checked = !toolStripMenuItemRightToLeftMode.Checked; + if (!toolStripMenuItemRightToLeftMode.Checked) + { + RightToLeft = RightToLeft.No; + textBoxListViewText.RightToLeft = RightToLeft.No; + textBoxListViewTextAlternate.RightToLeft = RightToLeft.No; + SubtitleListview1.RightToLeft = RightToLeft.No; + SubtitleListview1.RightToLeftLayout = false; + textBoxSource.RightToLeft = RightToLeft.No; + mediaPlayer.TextRightToLeft = RightToLeft.No; + textBoxSearchWord.RightToLeft = RightToLeft.No; + Configuration.Settings.General.RightToLeftMode = false; + } + else + { + //RightToLeft = RightToLeft.Yes; - is this better? TimeUpDown custom control needs to support RTL before enabling this + textBoxListViewText.RightToLeft = RightToLeft.Yes; + textBoxListViewTextAlternate.RightToLeft = RightToLeft.Yes; + SubtitleListview1.RightToLeft = RightToLeft.Yes; + SubtitleListview1.RightToLeftLayout = true; + textBoxSource.RightToLeft = RightToLeft.Yes; + mediaPlayer.TextRightToLeft = RightToLeft.Yes; + textBoxSearchWord.RightToLeft = RightToLeft.Yes; + Configuration.Settings.General.RightToLeftMode = true; + } + + MainResize(); + TextBoxListViewTextTextChanged(null, null); + textBoxListViewTextAlternate_TextChanged(null, null); + if (focusedItem != null) + { + SubtitleListview1.SelectIndexAndEnsureVisible(focusedItem.Index, true); + } + } + + private void joinSubtitlesToolStripMenuItem_Click(object sender, EventArgs e) + { + ReloadFromSourceView(); + using (var joinSubtitles = new JoinSubtitles()) + { + if (joinSubtitles.ShowDialog(this) == DialogResult.OK && joinSubtitles.JoinedSubtitle != null && joinSubtitles.JoinedSubtitle.Paragraphs.Count > 0 && ContinueNewOrExit()) + { + MakeHistoryForUndo(_language.BeforeDisplaySubtitleJoin); + + ResetSubtitle(); + _subtitle.Paragraphs.Clear(); + _subtitle.Paragraphs.AddRange(joinSubtitles.JoinedSubtitle.Paragraphs); + SetCurrentFormat(joinSubtitles.JoinedFormat); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(0, true); + ShowSource(); + ShowStatus(_language.SubtitlesJoined); + } + } + } + + private void toolStripMenuItemReverseRightToLeftStartEnd_Click(object sender, EventArgs e) + { + ReverseStartAndEndingForRtl(); + } + + private void toolStripMenuItemExportCapMakerPlus_Click(object sender, EventArgs e) + { + var capMakerPlus = new CapMakerPlus(); + saveFileDialog1.Filter = capMakerPlus.Name + "|*" + capMakerPlus.Extension; + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*" + capMakerPlus.Extension; + saveFileDialog1.AddExtension = true; + + if (!string.IsNullOrEmpty(VideoFileName)) + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); + } + else + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); + } + + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + string fileName = saveFileDialog1.FileName; + string ext = Path.GetExtension(fileName); + bool extOk = ext.Equals(capMakerPlus.Extension, StringComparison.OrdinalIgnoreCase); + if (!extOk) + { + if (fileName.EndsWith('.')) + { + fileName = fileName.Substring(0, fileName.Length - 1); + } + + fileName += capMakerPlus.Extension; + } + + CapMakerPlus.Save(fileName, GetSaveSubtitle(_subtitle)); + } + } + + private void toolStripMenuItemExportCheetahCap_Click(object sender, EventArgs e) + { + var cheetahCaption = new CheetahCaption(); + saveFileDialog1.Filter = cheetahCaption.Name + "|*" + cheetahCaption.Extension; + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*" + cheetahCaption.Extension; + saveFileDialog1.AddExtension = true; + + if (!string.IsNullOrEmpty(VideoFileName)) + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); + } + else + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); + } + + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + string fileName = saveFileDialog1.FileName; + string ext = Path.GetExtension(fileName); + bool extOk = ext.Equals(cheetahCaption.Extension, StringComparison.OrdinalIgnoreCase); + if (!extOk) + { + if (fileName.EndsWith('.')) + { + fileName = fileName.Substring(0, fileName.Length - 1); + } + + fileName += cheetahCaption.Extension; + } + + CheetahCaption.Save(fileName, GetSaveSubtitle(_subtitle)); + } + } + + private void toolStripMenuItemExportCaptionInc_Click(object sender, EventArgs e) + { + var captionInc = new CaptionsInc(); + saveFileDialog1.Filter = captionInc.Name + "|*" + captionInc.Extension; + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*" + captionInc.Extension; + saveFileDialog1.AddExtension = true; + + if (!string.IsNullOrEmpty(VideoFileName)) + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); + } + else + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); + } + + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + string fileName = saveFileDialog1.FileName; + string ext = Path.GetExtension(fileName); + bool extOk = ext.Equals(captionInc.Extension, StringComparison.OrdinalIgnoreCase); + if (!extOk) + { + if (fileName.EndsWith('.')) + { + fileName = fileName.Substring(0, fileName.Length - 1); + } + + fileName += captionInc.Extension; + } + + CaptionsInc.Save(fileName, GetSaveSubtitle(_subtitle)); + } + } + + private void toolStripMenuItemExportUltech130_Click(object sender, EventArgs e) + { + var ultech130 = new Ultech130(); + saveFileDialog1.Filter = ultech130.Name + "|*" + ultech130.Extension; + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*" + ultech130.Extension; + saveFileDialog1.AddExtension = true; + + if (!string.IsNullOrEmpty(VideoFileName)) + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); + } + else + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); + } + + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + string fileName = saveFileDialog1.FileName; + string ext = Path.GetExtension(fileName); + bool extOk = ext.Equals(ultech130.Extension, StringComparison.OrdinalIgnoreCase); + if (!extOk) + { + if (fileName.EndsWith('.')) + { + fileName = fileName.Substring(0, fileName.Length - 1); + } + + fileName += ultech130.Extension; + } + + Ultech130.Save(fileName, GetSaveSubtitle(_subtitle)); + } + } + + private void toolStripMenuItemAssStyles_Click(object sender, EventArgs e) + { + StylesForm styles = null; + try + { + var format = GetCurrentSubtitleFormat(); + var formatType = format.GetType(); + if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha)) + { + styles = new SubStationAlphaStyles(_subtitle, format); + if (styles.ShowDialog(this) == DialogResult.OK) + { + if (_subtitle.Header != styles.Header) + { + MakeHistoryForUndo(styles.Text); + } + + _subtitle.Header = styles.Header; + var styleList = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); + if ((styles as SubStationAlphaStyles).RenameActions.Count > 0) + { + foreach (var renameAction in (styles as SubStationAlphaStyles).RenameActions) + { + for (var i = 0; i < _subtitle.Paragraphs.Count; i++) + { + var p = _subtitle.Paragraphs[i]; + if (p.Extra == renameAction.OldName) + { + p.Extra = renameAction.NewName; + } + } + } + + CleanRemovedStyles(styleList); + SaveSubtitleListviewIndices(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + else + { + CleanRemovedStyles(styleList); + } + } + } + else if (formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText)) + { + styles = new TimedTextStyles(_subtitle); + if (styles.ShowDialog(this) == DialogResult.OK) + { + if (_subtitle.Header != styles.Header) + { + MakeHistoryForUndo(styles.Text); + } + + _subtitle.Header = styles.Header; + } + } + } + finally + { + mediaPlayer.LastParagraph = null; + UiUtil.ShowSubtitle(_subtitle, mediaPlayer); + styles?.Dispose(); + } + } + + private void CleanRemovedStyles(List styleList) + { + for (var i = 0; i < _subtitle.Paragraphs.Count; i++) + { + var p = _subtitle.Paragraphs[i]; + if (p.Extra == null || !styleList.Any(s => s.Equals(p.Extra == "*Default" ? "Default" : p.Extra, StringComparison.OrdinalIgnoreCase))) + { + p.Extra = styleList[0]; + SubtitleListview1.SetExtraText(i, p.Extra, SubtitleListview1.ForeColor); + } + } + } + + private void toolStripMenuItemSubStationAlpha_Click(object sender, EventArgs e) + { + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + ReloadFromSourceView(); + } + + using (var properties = new SubStationAlphaProperties(_subtitle, GetCurrentSubtitleFormat(), VideoFileName, _fileName)) + { + if (properties.ShowDialog(this) == DialogResult.OK && tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + ShowSource(); + } + } + } + + private static string RemoveAssAlignmentTags(string s) + { + return s.Replace("{\\an1}", string.Empty) // ASS tags alone + .Replace("{\\an2}", string.Empty) + .Replace("{\\an3}", string.Empty) + .Replace("{\\an4}", string.Empty) + .Replace("{\\an5}", string.Empty) + .Replace("{\\an6}", string.Empty) + .Replace("{\\an7}", string.Empty) + .Replace("{\\an8}", string.Empty) + .Replace("{\\an9}", string.Empty) + + .Replace("{an1\\", "{") // ASS multi tags (start) + .Replace("{an2\\", "{") + .Replace("{an3\\", "{") + .Replace("{an4\\", "{") + .Replace("{an5\\", "{") + .Replace("{an6\\", "{") + .Replace("{an7\\", "{") + .Replace("{an8\\", "{") + .Replace("{an9\\", "{") + + .Replace("\\an1\\", "\\") // ASS multi tags (middle) + .Replace("\\an2\\", "\\") + .Replace("\\an3\\", "\\") + .Replace("\\an4\\", "\\") + .Replace("\\an5\\", "\\") + .Replace("\\an6\\", "\\") + .Replace("\\an7\\", "\\") + .Replace("\\an8\\", "\\") + .Replace("\\an9\\", "\\") + + .Replace("\\an1}", "}") // ASS multi tags (end) + .Replace("\\an2}", "}") + .Replace("\\an3}", "}") + .Replace("\\an4}", "}") + .Replace("\\an5}", "}") + .Replace("\\an6}", "}") + .Replace("\\an7}", "}") + .Replace("\\an8}", "}") + .Replace("\\an9}", "}") + + .Replace("{\\a1}", string.Empty) // SSA tags + .Replace("{\\a2}", string.Empty) + .Replace("{\\a3}", string.Empty) + .Replace("{\\a4}", string.Empty) + .Replace("{\\a5}", string.Empty) + .Replace("{\\a6}", string.Empty) + .Replace("{\\a7}", string.Empty) + .Replace("{\\a8}", string.Empty) + .Replace("{\\a9}", string.Empty); + } + + private static string SetAlignTag(string s, string tag) + { + var text = RemoveAssAlignmentTags(s); + if (text.StartsWith("{\\", StringComparison.Ordinal) && text.Contains('}')) + { + if (!string.IsNullOrEmpty(tag)) + { + return text.Insert(1, "\\" + tag.TrimStart('{').TrimStart('\\').TrimEnd('}')); + } + + return text; + } + else + { + return string.Format(@"{0}{1}", tag, text); + } + } + + private void toolStripMenuItemAlignment_Click(object sender, EventArgs e) + { + var formatType = GetCurrentSubtitleFormat().GetType(); + + if (formatType == typeof(NetflixImsc11Japanese)) + { + using (var f = new AlignmentPickerJapanese(textBoxListViewText.Text)) + { + if (f.ShowDialog(this) == DialogResult.OK) + { + SetAlignment(f.ContentAlignment, true); + } + } + + return; + } + + using (var f = new AlignmentPicker(textBoxListViewText.Text)) + { + f.TopMost = true; + f.StartPosition = FormStartPosition.Manual; + f.Left = Cursor.Position.X - 150; + f.Top = Cursor.Position.Y - 75; + if (f.ShowDialog(this) == DialogResult.OK) + { + string tag = string.Empty; + if (formatType == typeof(SubStationAlpha)) + { + //1: Bottom left + //2: Bottom center + //3: Bottom right + //9: Middle left + //10: Middle center + //11: Middle right + //5: Top left + //6: Top center + //7: Top right + switch (f.Alignment) + { + case ContentAlignment.BottomLeft: + tag = "{\\a1}"; + break; + case ContentAlignment.BottomCenter: + tag = "{\\a2}"; + break; + case ContentAlignment.BottomRight: + tag = "{\\a3}"; + break; + case ContentAlignment.MiddleLeft: + tag = "{\\a9}"; + break; + case ContentAlignment.MiddleCenter: + tag = "{\\a10}"; + break; + case ContentAlignment.MiddleRight: + tag = "{\\a11}"; + break; + case ContentAlignment.TopLeft: + tag = "{\\a5}"; + break; + case ContentAlignment.TopCenter: + tag = "{\\a6}"; + break; + case ContentAlignment.TopRight: + tag = "{\\a7}"; + break; + } + } + else + { + //1: Bottom left + //2: Bottom center + //3: Bottom right + //4: Middle left + //5: Middle center + //6: Middle right + //7: Top left + //8: Top center + //9: Top right + switch (f.Alignment) + { + case ContentAlignment.BottomLeft: + tag = "{\\an1}"; + break; + case ContentAlignment.BottomCenter: + if (formatType == typeof(SubRip)) + { + tag = string.Empty; + } + else + { + tag = "{\\an2}"; + } + + break; + case ContentAlignment.BottomRight: + tag = "{\\an3}"; + break; + case ContentAlignment.MiddleLeft: + tag = "{\\an4}"; + break; + case ContentAlignment.MiddleCenter: + tag = "{\\an5}"; + break; + case ContentAlignment.MiddleRight: + tag = "{\\an6}"; + break; + case ContentAlignment.TopLeft: + tag = "{\\an7}"; + break; + case ContentAlignment.TopCenter: + tag = "{\\an8}"; + break; + case ContentAlignment.TopRight: + tag = "{\\an9}"; + break; + } + } + + if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0) + { + SetAlignment(tag, true); + } + } + } + } + + private void toolStripMenuItemRestoreAutoBackup_Click(object sender, EventArgs e) + { + _lastDoNotPrompt = -1; + using (var restoreAutoBackup = new RestoreAutoBackup()) + { + if (restoreAutoBackup.ShowDialog(this) == DialogResult.OK && !string.IsNullOrEmpty(restoreAutoBackup.AutoBackupFileName)) + { + if (ContinueNewOrExit()) + { + OpenSubtitle(restoreAutoBackup.AutoBackupFileName, null); + _fileName = _fileName.Remove(0, Configuration.AutoBackupDirectory.Length).TrimStart(Path.DirectorySeparatorChar); + _converted = true; + SetTitle(); + } + } + } + } + + private void labelStatus_Click(object sender, EventArgs e) + { + if (_statusLog.Count == 0) + { + return; + } + + if (_statusLogForm == null || _statusLogForm.IsDisposed) + { + _statusLogForm = new StatusLog(_statusLog); + _statusLogForm.Show(this); + } + else + { + _statusLogForm.Show(); + } + } + + private void toolStripMenuItemStatistics_Click(object sender, EventArgs e) + { + using (var stats = new Statistics(_subtitle, _fileName, GetCurrentSubtitleFormat())) + { + stats.ShowDialog(this); + } + } + + private void toolStripMenuItemDCinemaProperties_Click(object sender, EventArgs e) + { + PositionAndSizeForm properties = null; + try + { + if (GetCurrentSubtitleFormat().GetType() == typeof(DCinemaInterop)) + { + properties = new DCinema.DCinemaPropertiesInterop(); + } + else + { + properties = new DCinema.DCinemaPropertiesSmpte(); + } + + properties.ShowDialog(this); + } + finally + { + properties?.Dispose(); + } + } + + private void toolStripMenuItemTextTimeCodePair_Click(object sender, EventArgs e) + { + if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) + { + saveFileDialog1.Filter = _language.TextFiles + "|*.txt"; + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*.txt"; + saveFileDialog1.AddExtension = true; + + string fname = saveFileDialog1.FileName; + if (string.IsNullOrEmpty(fname)) + { + fname = "ATS"; + } + + if (!fname.EndsWith(".txt", StringComparison.Ordinal)) + { + fname += ".txt"; + } + + string fileNameTimeCode = fname.Insert(fname.Length - 4, "_timecode"); + string fileNameText = fname.Insert(fname.Length - 4, "_text"); + + var timeCodeLines = new StringBuilder(); + var textLines = new StringBuilder(); + + const string timeCodeWriteFormat = "{0:00}:{1:00}:{2:00}:{3:00}"; + foreach (var p in GetSaveSubtitle(_subtitle).Paragraphs) + { + timeCodeLines.AppendLine(string.Format(timeCodeWriteFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, SubtitleFormat.MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds))); + timeCodeLines.AppendLine(string.Format(timeCodeWriteFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, SubtitleFormat.MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds))); + + textLines.AppendLine(HtmlUtil.RemoveHtmlTags(p.Text).Replace(Environment.NewLine, "|")); + textLines.AppendLine(); + } + + File.WriteAllText(fileNameTimeCode, timeCodeLines.ToString(), Encoding.UTF8); + File.WriteAllText(fileNameText, textLines.ToString(), Encoding.UTF8); + } + } + + private void textWordsPerMinutewpmToolStripMenuItem_Click(object sender, EventArgs e) + { + SortSubtitle(SubtitleSortCriteria.WordsPerMinute, (sender as ToolStripItem).Text); + } + + private void toolStripMenuItemTTPropertiesClick(object sender, EventArgs e) + { + var subtitleFormatType = GetCurrentSubtitleFormat().GetType(); + if (subtitleFormatType != typeof(TimedText10) && subtitleFormatType != typeof(ItunesTimedText)) + { + return; + } + + using (var properties = new TimedTextProperties(_subtitle)) + { + properties.ShowDialog(this); + } + } + + private void ToolStripMenuItemSaveSelectedLinesClick(object sender, EventArgs e) + { + var newSub = new Subtitle(_subtitle); + newSub.Header = _subtitle.Header; + newSub.Paragraphs.Clear(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + newSub.Paragraphs.Add(_subtitle.Paragraphs[index]); + } + + SubtitleFormat currentFormat = GetCurrentSubtitleFormat(); + UiUtil.SetSaveDialogFilter(saveFileDialog1, currentFormat); + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*" + currentFormat.Extension; + saveFileDialog1.AddExtension = true; + if (!string.IsNullOrEmpty(_fileName)) + { + saveFileDialog1.InitialDirectory = Path.GetDirectoryName(_fileName); + } + + if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) + { + int index = 0; + foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) + { + if (saveFileDialog1.FilterIndex == index + 1) + { + // only allow current extension or ".txt" + string fileName = saveFileDialog1.FileName; + string ext = Path.GetExtension(fileName).ToLowerInvariant(); + bool extOk = ext.Equals(format.Extension, StringComparison.OrdinalIgnoreCase) || format.AlternateExtensions.Contains(ext) || ext == ".txt"; + if (!extOk) + { + if (fileName.EndsWith('.')) + { + fileName = fileName.TrimEnd('.'); + } + + fileName += format.Extension; + } + + if (format.IsTextBased) + { + string allText = GetSaveSubtitle(newSub).ToText(format); + File.WriteAllText(fileName, allText, GetCurrentEncoding()); + ShowStatus(string.Format(_language.XLinesSavedAsY, newSub.Paragraphs.Count, fileName)); + return; + } + else if (format.GetType() == typeof(Ebu)) + { + new Ebu().Save(fileName, GetSaveSubtitle(newSub)); + ShowStatus(string.Format(_language.XLinesSavedAsY, newSub.Paragraphs.Count, fileName)); + return; + } + } + + index++; + } + } + } + + private void GuessTimeCodesToolStripMenuItemClick(object sender, EventArgs e) + { + using (var form = new WaveformGenerateTimeCodes()) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.BeforeGuessingTimeCodes)); + + double startFromSeconds = 0; + if (form.StartFromVideoPosition) + { + startFromSeconds = mediaPlayer.CurrentPosition; + } + + if (form.DeleteAll) + { + _subtitle.Paragraphs.Clear(); + } + else if (form.DeleteForward) + { + for (int i = _subtitle.Paragraphs.Count - 1; i > 0; i--) + { + if (_subtitle.Paragraphs[i].EndTime.TotalSeconds + 1 > startFromSeconds) + { + _subtitle.Paragraphs.RemoveAt(i); + } + } + } + + audioVisualizer.GenerateTimeCodes(_subtitle, startFromSeconds, form.BlockSize, form.VolumeMinimum, form.VolumeMaximum, form.DefaultMilliseconds); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RefreshSelectedParagraph(); + } + } + } + + private void DvdStudioProStl_Click(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "STL", _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + private void toolStripMenuItemPlugins_Click(object sender, EventArgs e) + { + using (var form = new PluginsGet()) + { + form.ShowDialog(this); + LoadPlugins(); + } + } + + private void toolStripMenuItemUndo_Click(object sender, EventArgs e) + { + UndoToIndex(true); + } + + private void toolStripMenuItemRedo_Click(object sender, EventArgs e) + { + UndoToIndex(false); + } + + private void seekSilenceToolStripMenuItem_Click(object sender, EventArgs e) + { + if (audioVisualizer.WavePeaks == null) + { + return; + } + + using (var form = new SeekSilence()) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + if (form.SeekForward) + { + audioVisualizer.FindDataBelowThreshold(form.VolumeBelow, form.SecondsDuration); + } + else + { + audioVisualizer.FindDataBelowThresholdBack(form.VolumeBelow, form.SecondsDuration); + } + } + } + } + + private void toolStripMenuItemPasteSpecial_Click(object sender, EventArgs e) + { + string text = Clipboard.GetText(); + var tmp = new Subtitle(); + var list = new List(text.SplitToLines()); + new SubRip().LoadSubtitle(tmp, list, null); + if (tmp.Paragraphs.Count == 0) + { + tmp = SubtitleFormat.LoadSubtitleFromLines(list, null) ?? new Subtitle(); + } + + if (SubtitleListview1.SelectedItems.Count == 1 && text.Length > 0) + { + var form = new ColumnPaste(SubtitleListview1.IsAlternateTextColumnVisible && _subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle, tmp.Paragraphs.Count == 0); + if (form.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeColumnPaste); + + if (tmp.Paragraphs.Count == 0) + { + foreach (var line in text.SplitToLines()) + { + tmp.Paragraphs.Add(new Paragraph(line, 0, 0)); + } + } + + int index = FirstSelectedIndex; + + if (!form.PasteOverwrite) + { + for (int i = 0; i < tmp.Paragraphs.Count; i++) + { + if (form.PasteAll) + { + for (int k = _subtitle.Paragraphs.Count - 2; k >= index; k--) + { + _subtitle.Paragraphs[k + 1] = new Paragraph(_subtitle.Paragraphs[k]); + } + + if (index + i < _subtitle.Paragraphs.Count) + { + _subtitle.Paragraphs[index + i].Text = string.Empty; + } + } + else if (form.PasteTimeCodesOnly) + { + for (int k = _subtitle.Paragraphs.Count - 2; k >= index; k--) + { + _subtitle.Paragraphs[k + 1].StartTime.TotalMilliseconds = _subtitle.Paragraphs[k].StartTime.TotalMilliseconds; + _subtitle.Paragraphs[k + 1].EndTime.TotalMilliseconds = _subtitle.Paragraphs[k].EndTime.TotalMilliseconds; + } + } + else if (form.PasteTextOnly) + { + for (int k = _subtitle.Paragraphs.Count - 2; k >= index; k--) + { + _subtitle.Paragraphs[k + 1].Text = _subtitle.Paragraphs[k].Text; + } + } + else if (form.PasteOriginalTextOnly) + { + for (int k = _subtitle.Paragraphs.Count - 2; k >= index; k--) + { + var original = Utilities.GetOriginalParagraph(k, _subtitle.Paragraphs[k], _subtitleAlternate.Paragraphs); + var originalNext = Utilities.GetOriginalParagraph(k + 1, _subtitle.Paragraphs[k + 1], _subtitleAlternate.Paragraphs); + if (original != null) + { + originalNext.Text = original.Text; + } + } + + if (index + i < _subtitle.Paragraphs.Count) + { + var original = Utilities.GetOriginalParagraph(index, _subtitle.Paragraphs[index + i], _subtitleAlternate.Paragraphs); + if (original != null) + { + original.Text = string.Empty; + } + } + } + } + } + + if (form.PasteOverwrite) + { + for (int i = 0; i < tmp.Paragraphs.Count; i++) + { + if (form.PasteAll) + { + if (index + i < _subtitle.Paragraphs.Count) + { + _subtitle.Paragraphs[index + i].Text = tmp.Paragraphs[i].Text; + _subtitle.Paragraphs[index + i].StartTime.TotalMilliseconds = tmp.Paragraphs[i].StartTime.TotalMilliseconds; + _subtitle.Paragraphs[index + i].EndTime.TotalMilliseconds = tmp.Paragraphs[i].EndTime.TotalMilliseconds; + } + } + else if (form.PasteTimeCodesOnly) + { + if (index + i < _subtitle.Paragraphs.Count) + { + _subtitle.Paragraphs[index + i].StartTime.TotalMilliseconds = tmp.Paragraphs[i].StartTime.TotalMilliseconds; + _subtitle.Paragraphs[index + i].EndTime.TotalMilliseconds = tmp.Paragraphs[i].EndTime.TotalMilliseconds; + } + } + else if (form.PasteTextOnly) + { + if (index + i < _subtitle.Paragraphs.Count) + { + _subtitle.Paragraphs[index + i].Text = tmp.Paragraphs[i].Text; + } + } + else if (form.PasteOriginalTextOnly) + { + if (index + i < _subtitle.Paragraphs.Count) + { + var original = Utilities.GetOriginalParagraph(index + i, _subtitle.Paragraphs[index + i], _subtitleAlternate.Paragraphs); + if (original != null) + { + original.Text = tmp.Paragraphs[i].Text; + } + } + } + } + } + else + { + for (int i = 0; i + index < _subtitle.Paragraphs.Count && i < tmp.Paragraphs.Count; i++) + { + if (index + i < _subtitle.Paragraphs.Count) + { + if (form.PasteAll) + { + _subtitle.Paragraphs[index + i].Text = tmp.Paragraphs[i].Text; + _subtitle.Paragraphs[index + i].StartTime.TotalMilliseconds = tmp.Paragraphs[i].StartTime.TotalMilliseconds; + _subtitle.Paragraphs[index + i].EndTime.TotalMilliseconds = tmp.Paragraphs[i].EndTime.TotalMilliseconds; + } + else if (form.PasteTimeCodesOnly) + { + _subtitle.Paragraphs[index + i].StartTime.TotalMilliseconds = tmp.Paragraphs[i].StartTime.TotalMilliseconds; + _subtitle.Paragraphs[index + i].EndTime.TotalMilliseconds = tmp.Paragraphs[i].EndTime.TotalMilliseconds; + } + else if (form.PasteTextOnly) + { + _subtitle.Paragraphs[index + i].Text = tmp.Paragraphs[i].Text; + } + else if (form.PasteOriginalTextOnly) + { + var original = Utilities.GetOriginalParagraph(index + i, _subtitle.Paragraphs[index + i], _subtitleAlternate.Paragraphs); + if (original != null) + { + original.Text = tmp.Paragraphs[i].Text; + } + } + } + } + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + RefreshSelectedParagraph(); + } + + form.Dispose(); + } + } + + private void deleteAndShiftCellsUpToolStripMenuItem_Click(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedIndices.Count < 1) + { + return; + } + + int first = FirstSelectedIndex; + List list = new List(); + foreach (int index in SubtitleListview1.SelectedIndices) + { + list.Add(index); + } + + list.Sort(); + list.Reverse(); + + MakeHistoryForUndo(_language.BeforeColumnDelete); + foreach (int index in list) + { + for (int k = index; k < _subtitle.Paragraphs.Count - 1; k++) + { + _subtitle.Paragraphs[k].Text = _subtitle.Paragraphs[k + 1].Text; + } + + _subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1].Text = string.Empty; + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(first, true); + RefreshSelectedParagraph(); + } + + private void toolStripMenuItemColumnImportText_Click(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedIndices.Count < 1) + { + return; + } + + using (var importText = new ImportText()) + { + if (importText.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeColumnImportText); + int index = FirstSelectedIndex; + for (int i = 0; i < importText.FixedSubtitle.Paragraphs.Count; i++) + { + for (int k = _subtitle.Paragraphs.Count - 2; k > index; k--) + { + _subtitle.Paragraphs[k + 1].Text = _subtitle.Paragraphs[k].Text; + } + + if (index + i < _subtitle.Paragraphs.Count) + { + _subtitle.Paragraphs[index + i].Text = string.Empty; + } + } + + for (int i = 0; i + index < _subtitle.Paragraphs.Count && i < importText.FixedSubtitle.Paragraphs.Count; i++) + { + _subtitle.Paragraphs[index + i].Text = importText.FixedSubtitle.Paragraphs[i].Text; + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + RefreshSelectedParagraph(); + } + } + } + + private void ShiftTextCellsDownToolStripMenuItem_Click(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedIndices.Count < 1) + { + return; + } + + int index = FirstSelectedIndex; + int count = SubtitleListview1.SelectedIndices.Count; + MakeHistoryForUndo(_language.BeforeColumnShiftCellsDown); + for (int i = 0; i < count; i++) + { + for (int k = _subtitle.Paragraphs.Count - 2; k >= index; k--) + { + _subtitle.Paragraphs[k + 1].Text = _subtitle.Paragraphs[k].Text; + } + + if (index + i < _subtitle.Paragraphs.Count) + { + _subtitle.Paragraphs[index + i].Text = string.Empty; + } + } + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + RefreshSelectedParagraph(); + } + + private void toolStripMenuItemInsertTextFromSub_Click(object sender, EventArgs e) + { + openFileDialog1.Title = _languageGeneral.OpenSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + if (!File.Exists(openFileDialog1.FileName)) + { + return; + } + + var fi = new FileInfo(openFileDialog1.FileName); + if (fi.Length > 1024 * 1024 * 10) // max 10 mb + { + var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, openFileDialog1.FileName); + if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return; + } + } + + var tmp = new Subtitle(); + SubtitleFormat format = tmp.LoadSubtitle(openFileDialog1.FileName, out var encoding, null); + if (format != null) + { + if (Configuration.Settings.General.RemoveBlankLinesWhenOpening) + { + tmp.RemoveEmptyLines(); + } + + if (SubtitleListview1.SelectedIndices.Count < 1) + { + return; + } + + MakeHistoryForUndo(_language.BeforeColumnShiftCellsDown); + + int index = FirstSelectedIndex; + for (int i = 0; i < tmp.Paragraphs.Count; i++) + { + { + for (int k = _subtitle.Paragraphs.Count - 2; k > index; k--) + { + _subtitle.Paragraphs[k + 1].Text = _subtitle.Paragraphs[k].Text; + } + } + } + + for (int i = 0; i + index < _subtitle.Paragraphs.Count && i < tmp.Paragraphs.Count; i++) + { + _subtitle.Paragraphs[index + i].Text = tmp.Paragraphs[i].Text; + } + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + RefreshSelectedParagraph(); + } + } + } + + private void toolStripMenuItemOpenKeepVideo_Click(object sender, EventArgs e) + { + openToolStripMenuItem.Enabled = false; + ReloadFromSourceView(); + _resetVideo = false; + OpenNewFile(); + _resetVideo = true; + openToolStripMenuItem.Enabled = true; + } + + private void changeSpeedInPercentToolStripMenuItem_Click(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + using (var form = new ChangeSpeedInPercent(SubtitleListview1.SelectedItems.Count)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeAdjustSpeedInPercent); + SaveSubtitleListviewIndices(); + if (form.AdjustAllLines) + { + _subtitle = form.AdjustAllParagraphs(_subtitle); + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) + { + _subtitleAlternate = form.AdjustAllParagraphs(_subtitleAlternate); + } + } + else + { + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.GetParagraphOrDefault(index); + if (p != null) + { + form.AdjustParagraph(p); + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible) + { + var original = Utilities.GetOriginalParagraph(index, p, _subtitle.Paragraphs); + if (original != null) + { + form.AdjustParagraph(original); + } + } + } + } + } + + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + } + + private void toolStripMenuItemAvidStl_Click(object sender, EventArgs e) + { + var avidStl = new AvidStl(); + saveFileDialog1.Filter = avidStl.Name + "|*" + avidStl.Extension; + saveFileDialog1.Title = _language.SaveSubtitleAs; + saveFileDialog1.DefaultExt = "*" + avidStl.Extension; + saveFileDialog1.AddExtension = true; + + if (!string.IsNullOrEmpty(VideoFileName)) + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(VideoFileName); + } + else + { + saveFileDialog1.FileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); + } + + if (!string.IsNullOrEmpty(openFileDialog1.InitialDirectory)) + { + saveFileDialog1.InitialDirectory = openFileDialog1.InitialDirectory; + } + + DialogResult result = saveFileDialog1.ShowDialog(this); + if (result == DialogResult.OK) + { + openFileDialog1.InitialDirectory = saveFileDialog1.InitialDirectory; + string fileName = saveFileDialog1.FileName; + string ext = Path.GetExtension(fileName); + bool extOk = ext.Equals(avidStl.Extension, StringComparison.OrdinalIgnoreCase); + if (!extOk) + { + if (fileName.EndsWith('.')) + { + fileName = fileName.Substring(0, fileName.Length - 1); + } + + fileName += avidStl.Extension; + } + + AvidStl.Save(fileName, GetSaveSubtitle(_subtitle)); + } + } + + private Subtitle GetSaveSubtitle(Subtitle subtitle) + { + var sub = new Subtitle(subtitle); + if (string.IsNullOrEmpty(sub.FileName)) + { + sub.FileName = "Untitled"; + } + + if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) + { + sub.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(Configuration.Settings.General.CurrentVideoOffsetInMs)); + } + + return sub; + } + + private void columnDeleteTextOnlyToolStripMenuItem_Click(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedIndices.Count < 1) + { + return; + } + + MakeHistoryForUndo(_language.BeforeColumnDelete); + foreach (int index in SubtitleListview1.SelectedIndices) + { + _subtitle.Paragraphs[index].Text = string.Empty; + SubtitleListview1.SetText(index, string.Empty); + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, _subtitle.Paragraphs[index]); + } + + RefreshSelectedParagraph(); + } + + private void toolStripMenuItemBatchConvert_Click(object sender, EventArgs e) + { + Visible = false; + using (var form = new BatchConvert(Icon)) + { + form.ShowDialog(this); + } + + Visible = true; + } + + private void copyOriginalTextToCurrentToolStripMenuItem_Click(object sender, EventArgs e) + { + if (_subtitleAlternate == null || !SubtitleListview1.IsAlternateTextColumnVisible || SubtitleListview1.SelectedIndices.Count < 1) + { + return; + } + + bool first = true; + foreach (int index in SubtitleListview1.SelectedIndices) + { + var original = Utilities.GetOriginalParagraph(index, _subtitle.Paragraphs[index], _subtitleAlternate.Paragraphs); + if (original != null) + { + if (first) + { + MakeHistoryForUndo(_language.BeforeColumnPaste); + } + + SubtitleListview1.SetText(index, original.Text); + _subtitle.Paragraphs[index].Text = original.Text; + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, _subtitle.Paragraphs[index]); + first = false; + } + } + + RefreshSelectedParagraph(); + } + + private void toolStripMenuItemColumn_DropDownOpening(object sender, EventArgs e) + { + copyOriginalTextToCurrentToolStripMenuItem.Visible = !string.IsNullOrEmpty(copyOriginalTextToCurrentToolStripMenuItem.Text) && + SubtitleListview1.IsAlternateTextColumnVisible && + _subtitleAlternate != null; + } + + private void toolStripMenuItemMergeDuplicateText_Click(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + using (var form = new MergeDoubleLines()) + { + form.Initialize(_subtitle); + if (form.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeMergeLinesWithSameText); + _subtitle.Paragraphs.Clear(); + foreach (var p in form.MergedSubtitle.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowStatus(string.Format(_language.MergedShortLinesX, form.NumberOfMerges)); + SaveSubtitleListviewIndices(); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + } + + private void toolStripMenuItemMergeLinesWithSameTimeCodes_Click(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + ReloadFromSourceView(); + using (var form = new MergeTextWithSameTimeCodes()) + { + form.Initialize(_subtitle); + if (form.ShowDialog(this) == DialogResult.OK) + { + MakeHistoryForUndo(_language.BeforeMergeLinesWithSameText); + _subtitle.Paragraphs.Clear(); + foreach (var p in form.MergedSubtitle.Paragraphs) + { + _subtitle.Paragraphs.Add(p); + } + + ShowStatus(string.Format(_language.MergedShortLinesX, form.NumberOfMerges)); + SaveSubtitleListviewIndices(); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + } + + private void toolStripMenuItem2_Click(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.Spumux, _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + private void toolStripMenuItemModifySelection_Click(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + using (var form = new ModifySelection(_subtitle, GetCurrentSubtitleFormat(), SubtitleListview1)) + { + form.ShowDialog(this); + } + } + + private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + foreach (ListViewItem item in SubtitleListview1.Items) + { + item.Selected = !item.Selected; + } + } + + private void toolStripMenuItemSpellCheckFromCurrentLine_Click(object sender, EventArgs e) + { + _spellCheckForm = null; + SpellCheck(true, FirstSelectedIndex); + } + + private void toolStripMenuItemImportXSub_Click(object sender, EventArgs e) + { + if (ContinueNewOrExit()) + { + openFileDialog1.Title = _language.OpenXSubFiles; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = _language.XSubFiles + "|*.divx;*.avi"; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + ShowStatus(_languageGeneral.PleaseWait); + if (ImportSubtitleFromDivX(openFileDialog1.FileName)) + { + ShowStatus(string.Format(_language.LoadedSubtitleX, openFileDialog1.FileName)); + } + else + { + ShowStatus(string.Empty); + MessageBox.Show(_language.NotAValidXSubFile); + } + } + } + } + + private void toolStripMenuItemImportOcrHardSub_Click(object sender, EventArgs e) + { + using (var form = new HardSubExtract(VideoFileName)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + if (!string.IsNullOrEmpty(form.OcrFileName)) + { + MakeHistoryForUndo(_language.BeforeAutoBalanceSelectedLines); + OpenSubtitle(form.OcrFileName, null); + } + } + } + } + + private void toolStripMenuItemExportFcpIImage_Click(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.Fcp, _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + private void ToolStripMenuItemNuendoPropertiesClick(object sender, EventArgs e) + { + using (var form = new NuendoProperties()) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + Configuration.Settings.SubtitleSettings.NuendoCharacterListFile = form.CharacterListFile; + } + } + } + + private void toolStripMenuItemDost_Click(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.Dost, _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + private void toolStripMenuItemMeasurementConverter_Click(object sender, EventArgs e) + { + var selectedText = string.Empty; + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + selectedText = textBoxSource.SelectedText; + } + else + { + selectedText = GetFocusedTextBox().SelectedText; + } + + if (_measurementConverter != null && !_measurementConverter.IsDisposed) + { + _measurementConverter.WindowState = FormWindowState.Normal; + _measurementConverter.Input = selectedText; + _measurementConverter.IsOriginalActive = GetFocusedTextBox() == textBoxListViewTextAlternate; + _measurementConverter.Focus(); + return; + } + + _measurementConverter = new MeasurementConverter + { + Input = selectedText, + IsOriginalActive = GetFocusedTextBox() == textBoxListViewTextAlternate, + }; + _measurementConverter.InsertClicked += measurementConverter_InsertClicked; + _measurementConverter.Show(this); + } + + private void measurementConverter_InsertClicked(object sender, MeasurementConverter.InsertEventArgs e) + { + if (IsSubtitleLoaded) + { + var tb = e.IsOriginalActive ? textBoxListViewTextAlternate : textBoxListViewText; + tb.SelectedText = e.Result; + } + } + + private async void toolStripMenuItemImportChapters_Click(object sender, EventArgs e) + { + toolStripMenuItemImportChapters.Enabled = false; + ShowStatus(_language.ImportingChapters); + + var chaps = new List(); + using (var matroska = new MatroskaFile(VideoFileName)) + { + chaps = await System.Threading.Tasks.Task.Run(() => matroska.GetChapters()); + } + + if (chaps?.Count > 0) + { + mediaPlayer.Chapters = chaps; + + if (audioVisualizer.WavePeaks != null) + { + audioVisualizer.Chapters = chaps; + } + + ShowStatus(string.Format(_language.XChaptersImported, chaps?.Count)); + } + else + { + ShowStatus(_language.NoChapters); + MessageBox.Show(_language.NoChapters, Title); + } + + toolStripMenuItemImportChapters.Enabled = true; + } + + private void toolStripMenuItemImportSceneChanges_Click(object sender, EventArgs e) + { + using (var form = new ImportSceneChanges(_videoInfo, VideoFileName)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + audioVisualizer.SceneChanges = form.SceneChangesInSeconds; + SceneChangeHelper.SaveSceneChanges(VideoFileName, audioVisualizer.SceneChanges); + ShowStatus(string.Format(_language.XSceneChangesImported, form.SceneChangesInSeconds.Count)); + } + } + } + + private void toolStripMenuItemRemoveSceneChanges_Click(object sender, EventArgs e) + { + if (audioVisualizer.SceneChanges != null) + { + audioVisualizer.SceneChanges = new List(); + SceneChangeHelper.DeleteSceneChanges(VideoFileName); + } + } + + private void toolStripMenuItemBridgeGapsBetweenSubtitles_Click(object sender, EventArgs e) + { + if (!IsSubtitleLoaded) + { + DisplaySubtitleNotLoadedMessage(); + return; + } + + using (var form = new DurationsBridgeGaps(_subtitle)) + { + if (form.ShowDialog(this) == DialogResult.OK && form.FixedCount > 0) + { + int index = FirstSelectedIndex; + if (index < 0) + { + index = 0; + } + + MakeHistoryForUndo(_language.BeforeDurationsBridgeGap); + SaveSubtitleListviewIndices(); + _subtitle.Paragraphs.Clear(); + _subtitle.Paragraphs.AddRange(form.FixedSubtitle.Paragraphs); + + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + RestoreSubtitleListviewIndices(); + } + } + } + + private void toolStripMenuItemOpenDvd_Click(object sender, EventArgs e) + { + using (var form = new OpenVideoDvd()) + { + if (form.ShowDialog(this) == DialogResult.OK && !string.IsNullOrEmpty(form.DvdPath)) + { + VideoFileName = form.DvdPath; + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.PauseAndDisposePlayer(); + } + + _endSeconds = -1; + + _videoInfo = new VideoInfo(); + _videoInfo.Width = 720; + _videoInfo.Height = 576; + _videoInfo.FramesPerSecond = 25; + _videoInfo.VideoCodec = "MPEG2"; + toolStripComboBoxFrameRate.Text = string.Format("{0:0.###}", _videoInfo.FramesPerSecond); + + var oldVideoPlayer = Configuration.Settings.General.VideoPlayer; + try + { + Configuration.Settings.General.VideoPlayer = "VLC"; + UiUtil.InitializeVideoPlayerAndContainer(VideoFileName, _videoInfo, mediaPlayer, VideoLoaded, VideoEnded); + mediaPlayer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton; + mediaPlayer.OnButtonClicked -= MediaPlayer_OnButtonClicked; + mediaPlayer.OnButtonClicked += MediaPlayer_OnButtonClicked; + mediaPlayer.Volume = 0; + labelVideoInfo.Text = string.Format("DVD {0}x{1} {2}", _videoInfo.Width, _videoInfo.Height, _videoInfo.VideoCodec.Trim()); + if (_videoInfo.FramesPerSecond > 0) + { + labelVideoInfo.Text += string.Format(" {0:0.0##}", _videoInfo.FramesPerSecond); + } + } + finally + { + Configuration.Settings.General.VideoPlayer = oldVideoPlayer; + } + } + } + } + + private void toolStripMenuItemFcpProperties_Click(object sender, EventArgs e) + { + using (var form = new FcpProperties()) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + Configuration.Settings.SubtitleSettings.FcpFontSize = form.FcpFontSize; + Configuration.Settings.SubtitleSettings.FcpFontName = form.FcpFontName; + } + } + } + + private void styleToolStripMenuItem_Click(object sender, EventArgs e) + { + SortSubtitle(SubtitleSortCriteria.Style, (sender as ToolStripItem).Text); + } + + private void toolStripMenuItemFocusTextbox_Click(object sender, EventArgs e) + { + int index = _subtitle.GetIndex(audioVisualizer.RightClickedParagraph); + if (index >= 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(index, true); + } + + textBoxListViewText.Focus(); + textBoxListViewText.SelectAll(); + } + + private void AscendingToolStripMenuItem_Click(object sender, EventArgs e) + { + descendingToolStripMenuItem.Checked = false; + AscendingToolStripMenuItem.Checked = true; + toolsToolStripMenuItem.ShowDropDown(); + toolStripMenuItemSortBy.ShowDropDown(); + } + + private void descendingToolStripMenuItem_Click(object sender, EventArgs e) + { + AscendingToolStripMenuItem.Checked = false; + descendingToolStripMenuItem.Checked = true; + toolsToolStripMenuItem.ShowDropDown(); + toolStripMenuItemSortBy.ShowDropDown(); + } + + private void exportCustomTextFormatToolStripMenuItem_Click(object sender, EventArgs e) + { + using (var form = new ExportCustomText(GetSaveSubtitle(_subtitle), GetSaveSubtitle(_subtitleAlternate), _fileName)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + ShowStatus(form.LogMessage); + } + } + } + + private void PasteIntoActiveTextBox(string s, bool allowMultiLine = false) + { + if (tabControlSubtitle.SelectedIndex == TabControlSourceView) + { + textBoxSource.SelectedText = s; + } + else + { + if (textBoxListViewTextAlternate.Visible && textBoxListViewTextAlternate.Enabled && textBoxListViewTextAlternate.Focused) + { + if (!string.IsNullOrEmpty(textBoxListViewTextAlternate.SelectedText)) + { + textBoxListViewTextAlternate.SelectedText = s; + } + else + { + var selectionStart = textBoxListViewTextAlternate.SelectionStart; + textBoxListViewTextAlternate.Text = textBoxListViewTextAlternate.Text.Insert(textBoxListViewTextAlternate.SelectionStart, s); + textBoxListViewTextAlternate.SelectionStart = selectionStart + s.Length; + } + } + else + { + if (SubtitleListview1.SelectedItems.Count > 1 && !textBoxListViewText.Focused && allowMultiLine) + { + foreach (ListViewItem item in SubtitleListview1.SelectedItems) + { + var p = _subtitle.GetParagraphOrDefault(item.Index); + if (p == null) + { + continue; + } + + p.Text = s + " " + p.Text; + SubtitleListview1.SetText(item.Index, p.Text); + } + RefreshSelectedParagraph(); + } + else + { + if (!string.IsNullOrEmpty(textBoxListViewText.SelectedText)) + { + textBoxListViewText.SelectedText = s; + } + else + { + var selectionStart = textBoxListViewText.SelectionStart; + textBoxListViewText.Text = textBoxListViewText.Text.Insert(textBoxListViewText.SelectionStart, s); + textBoxListViewText.SelectionStart = selectionStart + s.Length; + } + } + + ShowSource(); + } + } + } + + private void leftToolStripMenuItem_Click(object sender, EventArgs e) + { + PasteIntoActiveTextBox("\u200E"); // LRM, Left-to-Right Mark, acts as a Latin character. + } + + private void righttoleftMarkToolStripMenuItem_Click(object sender, EventArgs e) + { + PasteIntoActiveTextBox("\u200F"); // RLM, Right-to-Left Mark, acts as an Arabic character. + } + + private void startOfLefttorightEmbeddingLREToolStripMenuItem_Click(object sender, EventArgs e) + { + PasteIntoActiveTextBox("\u202A"); + } + + private void startOfRighttoleftEmbeddingRLEToolStripMenuItem_Click(object sender, EventArgs e) + { + PasteIntoActiveTextBox("\u202B"); + } + + private void startOfLefttorightOverrideLROToolStripMenuItem_Click(object sender, EventArgs e) + { + PasteIntoActiveTextBox("\u202D"); + } + + private void startOfRighttoleftOverrideRLOToolStripMenuItem_Click(object sender, EventArgs e) + { + PasteIntoActiveTextBox("\u202E"); + } + + private void toolStripMenuItemRtlUnicodeControlChar_Click(object sender, EventArgs e) + { + if (IsUnicode) + { + int selectedIndex = FirstSelectedIndex; + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.Paragraphs[index]; + p.Text = Utilities.FixRtlViaUnicodeChars(p.Text); + SubtitleListview1.SetText(index, p.Text); + if (index == selectedIndex) + { + textBoxListViewText.Text = p.Text; + } + } + + RefreshSelectedParagraph(); + } + } + + private void toolStripMenuItemRemoveUnicodeControlChar_Click(object sender, EventArgs e) + { + if (IsUnicode) + { + int selectedIndex = FirstSelectedIndex; + foreach (int index in SubtitleListview1.SelectedIndices) + { + var p = _subtitle.Paragraphs[index]; + p.Text = Utilities.RemoveUnicodeControlChars(p.Text); + SubtitleListview1.SetText(index, p.Text); + if (index == selectedIndex) + { + textBoxListViewText.Text = p.Text; + } + } + + RefreshSelectedParagraph(); + } + } + + private void toolStripMenuItemImportImages_Click(object sender, EventArgs e) + { + if (!ContinueNewOrExit()) + { + return; + } + + if (!string.IsNullOrEmpty(VideoFileName) && mediaPlayer.VideoPlayer != null) + { + mediaPlayer.Pause(); + } + + using (var form = new ImportImages()) + { + if (form.ShowDialog(this) == DialogResult.OK && form.Subtitle.Paragraphs.Count > 0) + { + ImportAndOcrSrt(form.Subtitle); + } + } + } + + private void audioVisualizer_MouseEnter(object sender, EventArgs e) + { + if (Configuration.Settings.VideoControls.WaveformFocusOnMouseEnter && audioVisualizer.WavePeaks != null && !audioVisualizer.Focused && audioVisualizer.CanFocus) + { + if (Math.Abs(_lastWaveformMenuCloseTicks - DateTime.UtcNow.Ticks) > 10000 * 500) // only if last change was longer ago than 500 milliseconds + { + audioVisualizer.Focus(); + } + } + } + + private void SubtitleListview1_MouseEnter(object sender, EventArgs e) + { + if (Configuration.Settings.VideoControls.WaveformFocusOnMouseEnter && Configuration.Settings.VideoControls.WaveformListViewFocusOnMouseEnter && SubtitleListview1.CanFocus) + { + SubtitleListview1.Focus(); + } + } + + private void toolStripButtonFixCommonErrors_Click(object sender, EventArgs e) + { + FixCommonErrors(false); + } + + private void toolStripButtonRemoveTextForHi_Click(object sender, EventArgs e) + { + RemoveTextForHearImpairedToolStripMenuItemClick(sender, e); + } + + private void toolStripMenuItemExportDcinemaInteropClick(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.DCinemaInterop, _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + private void dCinemaSMPTE2014ToolStripMenuItem_Click(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.DCinemaInterop, _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + internal Subtitle UndoFromSpellCheck(Subtitle subtitle) + { + var idx = FirstSelectedIndex; + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + if (_subtitle.Paragraphs[i].Text != subtitle.Paragraphs[i].Text) + { + _subtitle.Paragraphs[i].Text = subtitle.Paragraphs[i].Text; + SubtitleListview1.SetText(i, _subtitle.Paragraphs[i].Text); + } + + if (idx == i) + { + SubtitleListview1.SetText(idx, _subtitle.Paragraphs[idx].Text); + } + } + + RefreshSelectedParagraph(); + return _subtitle; + } + + private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + if (_timerCheckForUpdates != null) + { + _timerCheckForUpdates.Stop(); + } + } + catch + { + } + + using (var form = new CheckForUpdates(this)) + { + form.ShowDialog(this); + } + + Configuration.Settings.General.LastCheckForUpdates = DateTime.Now; + } + + private void setVideoOffsetToolStripMenuItem_Click(object sender, EventArgs e) + { + if (!string.IsNullOrEmpty(VideoFileName) && mediaPlayer.VideoPlayer != null) + { + mediaPlayer.Pause(); + } + + using (var form = new SetVideoOffset()) + { + form.VideoOffset = new TimeCode(10, 0, 0, 0); + if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0) + { + form.VideoOffset = new TimeCode(Configuration.Settings.General.CurrentVideoOffsetInMs); + } + + var oldVideoOffset = Configuration.Settings.General.CurrentVideoOffsetInMs; + if (form.ShowDialog(this) == DialogResult.OK) + { + var change = _changeSubtitleHash != _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + if (form.FromCurrentVideoPosition && mediaPlayer.VideoPlayer != null) + { + Configuration.Settings.General.CurrentVideoOffsetInMs = (long)(Math.Round((form.VideoOffset.TotalSeconds - mediaPlayer.VideoPlayer.CurrentPosition) * 1000.0)); + change = true; + } + else + { + Configuration.Settings.General.CurrentVideoOffsetInMs = (long)(Math.Round(form.VideoOffset.TotalSeconds * 1000.0)); + } + + if (form.DoNotaddVideoOffsetToTimeCodes) + { + if (form.Reset) + { + _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(oldVideoOffset)); + _subtitleAlternate?.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(oldVideoOffset)); + } + else + { + _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-Configuration.Settings.General.CurrentVideoOffsetInMs)); + _subtitleAlternate?.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-Configuration.Settings.General.CurrentVideoOffsetInMs)); + } + } + else + { + change = true; + } + + if (!change) + { + _changeSubtitleHash = _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName); + } + else if (change && _changeSubtitleHash == _subtitle.GetFastHashCode(GetCurrentEncoding().BodyName)) + { + _changeSubtitleHash = -1; + } + + SaveSubtitleListviewIndices(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RefreshSelectedParagraph(); + RestoreSubtitleListviewIndices(); + } + } + } + + private void toolStripMenuItemEbuProperties_Click(object sender, EventArgs e) + { + using (var properties = new EbuSaveOptions()) + { + if (_subtitle != null && _subtitle.Header != null && (_subtitle.Header.Contains("STL2") || _subtitle.Header.Contains("STL3"))) + { + var header = Ebu.ReadHeader(Encoding.UTF8.GetBytes(_subtitle.Header)); + properties.Initialize(header, Ebu.EbuUiHelper.JustificationCode, null, _subtitle); + } + else + { + var header = new Ebu.EbuGeneralSubtitleInformation(); + if (!string.IsNullOrEmpty(_fileName) && new Ebu().IsMine(null, _fileName)) + { + properties.Initialize(header, Ebu.EbuUiHelper.JustificationCode, _fileName, _subtitle); + } + else + { + properties.Initialize(header, Ebu.EbuUiHelper.JustificationCode, null, _subtitle); + } + } + + if (properties.ShowDialog(this) == DialogResult.OK) + { + Ebu.EbuUiHelper.JustificationCode = properties.JustificationCode; + } + } + } + + private void ExportToEdlWithClipName(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.EdlClipName, _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + private void ExportToEdl(object sender, EventArgs e) + { + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), ExportPngXml.ExportFormats.Edl, _fileName, _videoInfo, VideoFileName); + exportBdnXmlPng.ShowDialog(this); + } + } + + private void ToolStripMenuItemAddWaveformBatchClick(object sender, EventArgs e) + { + using (var form = new AddWaveformBatch()) + { + form.ShowDialog(this); + } + } + + private void DisplaySubtitleNotLoadedMessage() + { + MessageBox.Show(this, _language.NoSubtitleLoaded, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + + private void toolStripMenuItemExportBdTextSt_Click(object sender, EventArgs e) + { + using (var form = new ExportTextST(_subtitle)) + { + form.ShowDialog(this); + } + } + + private void ChooseProfile() + { + using (var form = new ProfileChoose(Configuration.Settings.General.Profiles, Configuration.Settings.General.CurrentProfile)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + SubtitleListview1.BeginUpdate(); + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, i, _subtitle.Paragraphs[i]); + } + + SubtitleListview1.EndUpdate(); + if (_subtitleListViewIndex >= 0) + { + UpdateListViewTextInfo(labelTextLineLengths, labelSingleLine, labelSingleLinePixels, labelTextLineTotal, labelCharactersPerSecond, _subtitle.Paragraphs[_subtitleListViewIndex], textBoxListViewText); + } + + ShowLineInformationListView(); + ShowSourceLineNumber(); + } + } + } + + private void DuplicateLine() + { + if (SubtitleListview1.SelectedItems.Count != 1) + { + return; + } + + var firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index; + MakeHistoryForUndo(_language.BeforeInsertLine); + var newParagraph = new Paragraph(); + SetStyleForNewParagraph(newParagraph, firstSelectedIndex); + var cur = _subtitle.GetParagraphOrDefault(firstSelectedIndex); + newParagraph.StartTime.TotalMilliseconds = cur.StartTime.TotalMilliseconds; + newParagraph.EndTime.TotalMilliseconds = cur.EndTime.TotalMilliseconds; + newParagraph.Text = cur.Text; + + if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0) + { + var currentOriginal = Utilities.GetOriginalParagraph(firstSelectedIndex, _subtitle.Paragraphs[firstSelectedIndex], _subtitleAlternate.Paragraphs); + if (currentOriginal != null) + { + _subtitleAlternate.Paragraphs.Insert(_subtitleAlternate.Paragraphs.IndexOf(currentOriginal) + 1, new Paragraph(currentOriginal)); + } + else + { + _subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph)); + } + _subtitleAlternate.Renumber(); + } + + if (_networkSession != null) + { + _networkSession.TimerStop(); + NetworkGetSendUpdates(new List(), firstSelectedIndex, newParagraph); + } + else + { + _subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph); + _subtitle.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + } + + SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true); + ShowSource(); + ShowStatus(_language.LineInserted); + } + + private void toolStripSelected_Click(object sender, EventArgs e) + { + if (!ShowProfileInStatusBar) + { + labelStatus_Click(sender, e); + return; + } + + var x = statusStrip1.PointToClient(Cursor.Position).X; + var textWidth = TextRenderer.MeasureText(toolStripSelected.Text, toolStripSelected.Font).Width; + if (toolStripStatusLabelProgress.Visible) + { + textWidth += toolStripStatusLabelProgress.Width + 5; + } + + var min = statusStrip1.Width - textWidth - 20; + var max = min + TextRenderer.MeasureText(Configuration.Settings.General.CurrentProfile, toolStripSelected.Font).Width + 10; + if (x >= min && x <= max) + { + ChooseProfile(); // profile name in status bar clicked + } + else + { + labelStatus_Click(sender, e); + } + } + + private void contextMenuStripWaveform_Closing(object sender, ToolStripDropDownClosingEventArgs e) + { + _lastWaveformMenuCloseTicks = DateTime.UtcNow.Ticks; + } + + private void MenuOpened(object sender, EventArgs e) + { + IsMenuOpen = true; + } + + private void MenuClosed(object sender, ToolStripDropDownClosedEventArgs e) + { + IsMenuOpen = false; + } + + private void MenuClosed(object sender, EventArgs e) + { + IsMenuOpen = false; + } + + private void UpdateNetflixGlyphCheckToolsVisibility() + { + bool showTools = IsNetflixGlyphCheckAvailable(); + toolStripButtonNetflixQualityCheck.Visible = showTools && Configuration.Settings.General.ShowToolbarNetflixGlyphCheck; + } + + private bool IsNetflixGlyphCheckAvailable() + { + var formatType = GetCurrentSubtitleFormat().GetType(); + return formatType == typeof(TimedText10) || formatType == typeof(NetflixTimedText) || formatType == typeof(NetflixImsc11Japanese) || formatType == typeof(Ebu); + } + + private void NetflixGlyphCheck(bool isSaving) + { + ReloadFromSourceView(); + + string fileName = string.IsNullOrEmpty(_fileName) ? "UntitledSubtitle" : Path.GetFileNameWithoutExtension(_fileName); + string language = LanguageAutoDetect.AutoDetectGoogleLanguage(_subtitle); + + var netflixController = new NetflixQualityController { Language = language, VideoFileName = VideoFileName }; + if (!string.IsNullOrEmpty(VideoFileName) && _videoInfo != null && _videoInfo.FramesPerSecond > 20) + { + netflixController.FrameRate = _videoInfo.FramesPerSecond; + } + else if (!string.IsNullOrEmpty(VideoFileName) && CurrentFrameRate != 23.976 && CurrentFrameRate != 24) + { + netflixController.FrameRate = CurrentFrameRate; + } + + netflixController.RunChecks(_subtitle); + + if (netflixController.Records.Count > 0) + { + string reportPath = Path.GetTempPath() + fileName + "_NetflixQualityCheck.csv"; + netflixController.SaveCsv(reportPath); + if (!isSaving) + { + using (var form = new NetflixFixErrors(_subtitle, GetCurrentSubtitleFormat(), _fileName, VideoFileName)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + // Do nothing for now + } + } + } + else + { + ShowStatus(string.Format(_language.SavedSubtitleX, _fileName) + " - " + + string.Format(Configuration.Settings.Language.NetflixQualityCheck.FoundXIssues, netflixController.Records.Count)); + } + } + else if (!isSaving) + { + MessageBox.Show("Netflix Quality Check found no issues.", "Netflix Quality Check"); + } + } + + private void netflixGlyphCheckToolStripMenuItem_Click(object sender, EventArgs e) + { + NetflixGlyphCheck(false); + } + + private void toolStripButtonNetflixGlyphCheck_Click(object sender, EventArgs e) + { + NetflixGlyphCheck(false); + } + + private void insertSubtitleHereToolStripMenuItem_Click(object sender, EventArgs e) + { + openFileDialog1.Title = _languageGeneral.OpenSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK && File.Exists(openFileDialog1.FileName)) + { + var fi = new FileInfo(openFileDialog1.FileName); + if (fi.Length > 1024 * 1024 * 10) // max 10 mb + { + var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, openFileDialog1.FileName); + if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return; + } + } + + var subtitle = new Subtitle(); + SubtitleFormat format = subtitle.LoadSubtitle(openFileDialog1.FileName, out var encoding, null); + if (format != null && subtitle.Paragraphs.Count > 0) + { + SaveSubtitleListviewIndices(); + + if (Configuration.Settings.General.RemoveBlankLinesWhenOpening) + { + subtitle.RemoveEmptyLines(); + } + + var adjustment = mediaPlayer.CurrentPosition - subtitle.Paragraphs[0].StartTime.TotalSeconds; + if (adjustment < 0) + { + adjustment = 0; + } + + foreach (Paragraph newP in subtitle.Paragraphs) + { + newP.Adjust(1.0d, adjustment); + if (_subtitle.Paragraphs.Any(p => newP.StartTime.TotalMilliseconds >= p.StartTime.TotalMilliseconds && + newP.StartTime.TotalMilliseconds <= p.EndTime.TotalMilliseconds || + newP.EndTime.TotalMilliseconds >= p.StartTime.TotalMilliseconds && + newP.EndTime.TotalMilliseconds <= p.EndTime.TotalMilliseconds)) + { + // new subs will overlap existing subs + if (MessageBox.Show(_language.PromptInsertSubtitleOverlap, _languageGeneral.Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) + { + return; + } + + break; + } + } + + MakeHistoryForUndo(string.Format(_language.BeforeInsertSubtitleAtVideoPosition, openFileDialog1.FileName)); + + foreach (var p in subtitle.Paragraphs) + { + _subtitle.InsertParagraphInCorrectTimeOrder(p); + } + + _subtitle.Renumber(); + ShowSource(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + RestoreSubtitleListviewIndices(); + } + } + } + + private void actorToolStripMenuItemClick(object sender, EventArgs e) + { + SortSubtitle(SubtitleSortCriteria.Actor, (sender as ToolStripItem).Text); + } + + private void toolStripMenuItemFcpXmlAdvanced_Click(object sender, EventArgs e) + { + using (var dialog = new ExportFcpXmlAdvanced(_subtitle, VideoFileName)) + { + dialog.ShowDialog(this); + } + } + + private void toolStripMenuItemOpenVideoFromUrl_Click(object sender, EventArgs e) + { + using (var form = new TextPrompt(Configuration.Settings.Language.Main.OpenVideoFile, "Url")) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + string url = form.InputText; + if (!string.IsNullOrEmpty(url)) + { + if (audioVisualizer.WavePeaks != null) + { + audioVisualizer.WavePeaks = null; + audioVisualizer.SetSpectrogram(null); + audioVisualizer.SceneChanges = new List(); + audioVisualizer.Chapters = new List(); + } + + if (!panelVideoPlayer.Visible) + { + toolStripButtonToggleVideo_Click(null, null); + } + + ShowSubtitleTimer.Stop(); + Cursor = Cursors.WaitCursor; + VideoFileName = url; + if (mediaPlayer.VideoPlayer != null) + { + mediaPlayer.PauseAndDisposePlayer(); + } + + _endSeconds = -1; + UiUtil.InitializeVideoPlayerAndContainer(url, _videoInfo, mediaPlayer, VideoLoaded, VideoEnded); + mediaPlayer.Volume = 0; + mediaPlayer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton; + mediaPlayer.OnButtonClicked -= MediaPlayer_OnButtonClicked; + mediaPlayer.OnButtonClicked += MediaPlayer_OnButtonClicked; + labelVideoInfo.Text = url; + Cursor = Cursors.Default; + SetUndockedWindowsTitle(); + ShowSubtitleTimer.Start(); + } + } + } + } + + private void SmpteTimeModedropFrameToolStripMenuItem_Click(object sender, EventArgs e) + { + smpteTimeModedropFrameToolStripMenuItem.Checked = !smpteTimeModedropFrameToolStripMenuItem.Checked; + mediaPlayer.SmpteMode = smpteTimeModedropFrameToolStripMenuItem.Checked; + } + + private void moveTextUpToolStripMenuItem_Click(object sender, EventArgs e) + { + var indices = SubtitleListview1.SelectedIndices.OfType().OrderBy(p => p).ToList(); + if (indices.Count == 0 || indices[0] - 1 < 0) + { + return; + } + + MakeHistoryForUndo(string.Format(_language.BeforeX, _language.Menu.ContextMenu.ColumnTextUp)); + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + SubtitleListview1.BeginUpdate(); + foreach (int index in indices) + { + if (index - 1 >= 0) + { + var p = _subtitle.Paragraphs[index]; + var prev = _subtitle.Paragraphs[index - 1]; + var prevText = prev.Text; + prev.Text = p.Text; + p.Text = prevText; + SubtitleListview1.Items[index - 1].Selected = true; + SubtitleListview1.Items[index].Selected = false; + SubtitleListview1.SetText(index - 1, prev.Text); + SubtitleListview1.SetText(index, p.Text); + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index - 1, prev); + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, p); + } + } + + SubtitleListview1.EndUpdate(); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + SubtitleListview1.EnsureVisible(FirstSelectedIndex); + _subtitleListViewIndex = -1; + SubtitleListview1_SelectedIndexChanged(null, null); + } + + private void moveTextDownToolStripMenuItem_Click(object sender, EventArgs e) + { + var indices = SubtitleListview1.SelectedIndices.OfType().OrderByDescending(p => p).ToList(); + if (indices.Count == 0 || indices[0] + 1 >= _subtitle.Paragraphs.Count) + { + return; + } + + MakeHistoryForUndo(string.Format(_language.BeforeX, _language.Menu.ContextMenu.ColumnTextDown)); + SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged; + SubtitleListview1.BeginUpdate(); + foreach (int index in indices) + { + if (index + 1 < _subtitle.Paragraphs.Count) + { + var p = _subtitle.Paragraphs[index]; + var next = _subtitle.Paragraphs[index + 1]; + var nextText = next.Text; + next.Text = p.Text; + p.Text = nextText; + SubtitleListview1.Items[index + 1].Selected = true; + SubtitleListview1.Items[index].Selected = false; + SubtitleListview1.SetText(index, p.Text); + SubtitleListview1.SetText(index + 1, next.Text); + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index, p); + SubtitleListview1.SyntaxColorLine(_subtitle.Paragraphs, index + 1, next); + } + } + + SubtitleListview1.EndUpdate(); + SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged; + SubtitleListview1.EnsureVisible(FirstSelectedIndex); + SubtitleListview1.EnsureVisible(indices[0]); + _subtitleListViewIndex = -1; + SubtitleListview1_SelectedIndexChanged(null, null); + } + + private void generateTextFromCurrentVideoToolStripMenuItem_Click(object sender, EventArgs e) + { + using (var form = new AudioToText(VideoFileName, _videoInfo)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + _subtitle.Paragraphs.Clear(); + _subtitle.Paragraphs.AddRange(form.Subtitle.Paragraphs); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + if (_subtitle.Paragraphs.Count > 1) + { + ToolStripMenuItemAutoMergeShortLinesClick(sender, e); + } + } + } + } + + private void toolStripMenuDvdStudioProperties_Click(object sender, EventArgs e) + { + using (var form = new DvdStudioProProperties()) + { + form.ShowDialog(this); + } + } + + private void boxToolStripMenuItem_Click(object sender, EventArgs e) + { + ListViewToggleTag("box"); + } + + private void ShowHideBookmark(Paragraph p) + { + if (!string.IsNullOrWhiteSpace(p.Bookmark)) + { + pictureBoxBookmark.Show(); + if (_showBookmarkLabel) + { + panelBookmark.Show(); + using (var graphics = CreateGraphics()) + { + var textSize = graphics.MeasureString(p.Bookmark, Font); + labelBookmark.Text = p.Bookmark; + panelBookmark.Left = pictureBoxBookmark.Left; + panelBookmark.Top = pictureBoxBookmark.Top + pictureBoxBookmark.Height + 9; + panelBookmark.Width = (int)textSize.Width + 20; + panelBookmark.Height = (int)textSize.Height + 20; + panelBookmark.Show(); + } + } + else + { + panelBookmark.Hide(); + } + } + else if (p.Bookmark != null) + { + pictureBoxBookmark.Show(); + panelBookmark.Hide(); + } + else if (panelBookmark.Visible || pictureBoxBookmark.Visible) + { + panelBookmark.Hide(); + pictureBoxBookmark.Hide(); + } + } + + private void pictureBoxBookmark_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (panelBookmark.Visible) + { + panelBookmark.Hide(); + _showBookmarkLabel = false; + } + else + { + _showBookmarkLabel = true; + var p = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex); + if (p != null) + { + ShowHideBookmark(p); + } + } + } + } + + private void pictureBoxBookmark_MouseEnter(object sender, EventArgs e) + { + if (_bookmarkContextMenu != null) + { + return; + } + + _bookmarkContextMenu = new ContextMenu(); + + // edit bookmark + var menuItem = new MenuItem(Configuration.Settings.Language.Main.Menu.ContextMenu.EditBookmark); + menuItem.Click += (sender2, e2) => { labelBookmark_DoubleClick(null, null); }; + _bookmarkContextMenu.MenuItems.Add(menuItem); + + // remove bookmark + menuItem = new MenuItem(Configuration.Settings.Language.Main.Menu.ContextMenu.RemoveBookmark); + menuItem.Click += (sender2, e2) => + { + var p2 = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex); + if (p2 != null) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Main.Menu.ContextMenu.RemoveBookmark)); + p2.Bookmark = null; + SubtitleListview1.ShowState(_subtitleListViewIndex, p2); + ShowHideBookmark(p2); + SetListViewStateImages(); + new BookmarkPersistence(_subtitle, _fileName).Save(); + } + }; + _bookmarkContextMenu.MenuItems.Add(menuItem); + + _bookmarkContextMenu.MenuItems.Add("-"); + + // go to bookmark + menuItem = new MenuItem(Configuration.Settings.Language.Settings.GoToBookmark); + menuItem.Click += (sender2, e2) => { GoToBookmark(); }; + _bookmarkContextMenu.MenuItems.Add(menuItem); + + // clear all bookmarks + menuItem = new MenuItem(Configuration.Settings.Language.Settings.ClearBookmarks); + menuItem.Click += (sender2, e2) => { ClearBookmarks(); }; + _bookmarkContextMenu.MenuItems.Add(menuItem); + + pictureBoxBookmark.ContextMenu = _bookmarkContextMenu; + } + + private void labelBookmark_DoubleClick(object sender, EventArgs e) + { + var p1 = _subtitle.GetParagraphOrDefault(_subtitleListViewIndex); + if (p1 != null) + { + using (var form = new BookmarkAdd(p1)) + { + var result = form.ShowDialog(this); + if (result == DialogResult.OK) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Main.Menu.ContextMenu.EditBookmark)); + p1.Bookmark = form.Comment; + SubtitleListview1.ShowState(_subtitleListViewIndex, p1); + ShowHideBookmark(p1); + SetListViewStateImages(); + new BookmarkPersistence(_subtitle, _fileName).Save(); + } + } + } + } + + private void googleTranslateToolStripMenuItem_Click(object sender, EventArgs e) + { + TranslateViaGoogle(true, true); + } + + private void microsoftBingTranslateToolStripMenuItem_Click(object sender, EventArgs e) + { + TranslateViaGoogle(true, false); + } + + private void toolStripMenuItemBookmark_Click(object sender, EventArgs e) + { + ToggleBookmarks(true); + } + + private void RunActionOnAllParagraphs(Func action, string historyMessage) + { + if (_subtitle.Paragraphs.Count <= 0 || SubtitleListview1.SelectedItems.Count <= 0) + { + return; + } + + int linesUpdated = 0; + var selectedIndices = SubtitleListview1.GetSelectedIndices(); + for (int i = selectedIndices.Length - 1; i >= 0; i--) + { + int idx = selectedIndices[i]; + var p = _subtitle.GetParagraphOrDefault(idx); + if (p != null) + { + var newText = action.Invoke(p); + if (newText != p.Text) + { + if (linesUpdated == 0) + { + MakeHistoryForUndo(historyMessage); + } + if (newText.IsOnlyControlCharactersOrWhiteSpace()) + { + _subtitle.Paragraphs.RemoveAt(idx); + } + else + { + p.Text = newText; + } + linesUpdated++; + } + + if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle) + { + var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs); + if (original != null) + { + newText = action.Invoke(original); + if (newText != original.Text) + { + if (linesUpdated == 0) + { + MakeHistoryForUndo(historyMessage); + } + if (newText.IsOnlyControlCharactersOrWhiteSpace()) + { + _subtitleAlternate.Paragraphs.RemoveAt(idx); + } + else + { + original.Text = newText; + } + linesUpdated++; + } + } + } + } + } + + if (linesUpdated == 0) + { + return; // nothing changed + } + + var firstIdx = FirstSelectedIndex; + _subtitle.Renumber(); + _subtitleAlternate?.Renumber(); + SubtitleListview1.Fill(_subtitle, _subtitleAlternate); + ShowSource(); + SubtitleListview1.SelectIndexAndEnsureVisibleFaster(firstIdx); + RefreshSelectedParagraph(); + ShowStatus(string.Format(_language.LinesUpdatedX, linesUpdated)); + } + + private void removeAllFormattingsToolStripMenuItem_Click(object sender, EventArgs e) + { + RunActionOnAllParagraphs((p) => + { + var s = p.Text.Replace("♪", string.Empty).Replace("♫", string.Empty); + s = NetflixImsc11Japanese.RemoveTags(s); + return HtmlUtil.RemoveHtmlTags(s, true).Trim(); + }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingAll)); + } + + private void removeBoldToolStripMenuItem_Click(object sender, EventArgs e) + { + RunActionOnAllParagraphs((p) => + { + return p.Text.Replace("", string.Empty) + .Replace("", string.Empty) + .Replace("", string.Empty) + .Replace("", string.Empty); + }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingBold)); + } + + private void removeItalicToolStripMenuItem_Click(object sender, EventArgs e) + { + RunActionOnAllParagraphs((p) => + { + return p.Text.Replace("", string.Empty) + .Replace("", string.Empty) + .Replace("", string.Empty) + .Replace("", string.Empty); + }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingItalic)); + } + + private void removeUnderlineToolStripMenuItem_Click(object sender, EventArgs e) + { + RunActionOnAllParagraphs((p) => + { + return p.Text.Replace("", string.Empty) + .Replace("", string.Empty) + .Replace("", string.Empty) + .Replace("", string.Empty); + }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingUnderline)); + } + + private void removeColorToolStripMenuItem_Click(object sender, EventArgs e) + { + RunActionOnAllParagraphs((p) => + { + if (!p.Text.Contains(" 4) + { + var font = s.Substring(match.Index - 5); + if (font.StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + s = s.Remove(match.Index - 5, 7); + var endIndex = s.IndexOf("", match.Index - 5, StringComparison.OrdinalIgnoreCase); + if (endIndex >= 0) + { + s = s.Remove(endIndex, 7); + } + } + else if (s.Length > match.Index + 1 && s[match.Index + 1] == '>') + { + s = s.Remove(match.Index, 1); + } + } + + match = r.Match(s); + } + + return s.Trim(); + }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingColor)); + } + + private void removeFontNameToolStripMenuItem_Click(object sender, EventArgs e) + { + RunActionOnAllParagraphs((p) => + { + if (!p.Text.Contains(" 4) + { + var font = s.Substring(match.Index - 5); + if (font.StartsWith("", StringComparison.OrdinalIgnoreCase)) + { + s = s.Remove(match.Index - 5, 7); + var endIndex = s.IndexOf("", match.Index - 5, StringComparison.OrdinalIgnoreCase); + if (endIndex >= 0) + { + s = s.Remove(endIndex, 7); + } + } + else if (s.Length > match.Index + 1 && s[match.Index + 1] == '>') + { + s = s.Remove(match.Index, 1); + } + } + + match = r.Match(s); + } + + return s; + }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingFontName)); + } + + private void removeAlignmentToolStripMenuItem_Click(object sender, EventArgs e) + { + RunActionOnAllParagraphs((p) => + { + if (!p.Text.Contains('{')) + { + return p.Text; + } + + return RemoveAssAlignmentTags(p.Text); + }, string.Format(_language.BeforeX, _language.Menu.ContextMenu.RemoveFormattingAlignment)); + } + + private void BoutenToolStripMenuItemClick(object sender, EventArgs e) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, (sender as ToolStripMenuItem).Text)); + TextBoxListViewToggleTag((sender as ToolStripMenuItem).Text); + } + + private void toolStripMenuItemHorizontalDigits_Click(object sender, EventArgs e) + { + MakeHistoryForUndo(string.Format(_language.BeforeX, "horizontalDigit")); + TextBoxListViewToggleTag("horizontalDigit"); + } + + private void toolStripMenuItemSetParagraphAsSelection_Click(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedItems.Count == 1 && audioVisualizer != null && audioVisualizer.NewSelectionParagraph != null) + { + var idx = SubtitleListview1.SelectedItems[0].Index; + var p = _subtitle.Paragraphs[idx]; + ButtonSetEndAndGoToNextClick(null, null); + p.StartTime.TotalMilliseconds = audioVisualizer.NewSelectionParagraph.StartTime.TotalMilliseconds; + p.EndTime.TotalMilliseconds = audioVisualizer.NewSelectionParagraph.EndTime.TotalMilliseconds; + SubtitleListview1.SetStartTimeAndDuration(idx, p, _subtitle.GetParagraphOrDefault(idx - 1), _subtitle.GetParagraphOrDefault(idx + 1)); + mediaPlayer.CurrentPosition = audioVisualizer.NewSelectionParagraph.EndTime.TotalSeconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines / 1000.0; + audioVisualizer.NewSelectionParagraph = null; + } + } + + private void toolStripMenuItemRuby_Click(object sender, EventArgs e) + { + var tb = GetFocusedTextBox(); + string before = string.Empty; + string text = tb.SelectedText; + string after = string.Empty; + + int selectionStart = tb.SelectionStart; + if (selectionStart > 0) + { + before = tb.Text.Substring(0, selectionStart); + } + + if (tb.Text.Length > selectionStart + text.Length) + { + after = tb.Text.Remove(0, selectionStart + text.Length); + } + + if (text.StartsWith(' ')) + { + before += " "; + text = text.TrimStart(); + } + + if (text.EndsWith(' ')) + { + after = " " + after; + } + + using (var form = new RubyJapanese(before, text, after)) + { + if (form.ShowDialog(this) != DialogResult.OK) + { + return; + } + + var rubyText = form.RubyText; + if (form.RubyItalic) + { + rubyText = "" + rubyText + ""; + } + else + { + rubyText = "" + rubyText + ""; + } + var rubyHtml = before + "" + form.RubyBaseText + "" + rubyText + "" + after; // sami ruby tag fix + var formatType = GetCurrentSubtitleFormat().GetType(); + if (formatType == typeof(Sami)) // sami ruby tag fix + { + rubyHtml = rubyHtml.Replace("ruby-container", "ruby") + .Replace("ruby-text", "rt") + .Replace("", string.Empty) + .Replace("", string.Empty) // sami ruby tag fix rp remove + .Replace("", string.Empty) // sami ruby tag fix italic remove + .Replace("", string.Empty) + .Replace("", string.Empty) + .Replace("", string.Empty); + } + tb.Text = rubyHtml; + } + } + + private void toolStripMenuItemAutoTranslate_DropDownOpening(object sender, EventArgs e) + { + translatepoweredByMicrosoftToolStripMenuItem.Visible = + !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorApiKey) && + !string.IsNullOrEmpty(Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint); + } + + private void comboBoxSubtitleFormats_DropDownClosed(object sender, EventArgs e) + { + MenuClosed(sender, e); + if (_oldSubtitleFormat.FriendlyName != GetCurrentSubtitleFormat().FriendlyName) + { + ComboBoxSubtitleFormatsSelectedIndexChanged(sender, e); + } + } + + private void comboBoxSubtitleFormats_DropDown(object sender, EventArgs e) + { + _oldSubtitleFormat = GetCurrentSubtitleFormat(); + MenuOpened(sender, e); + } + + private void toolStripSplitButtonPlayRate_ButtonClick(object sender, EventArgs e) + { + toolStripSplitButtonPlayRate.ShowDropDown(); + } + + private void ShowButtonShortcut(string shortcut) + { + if (string.IsNullOrEmpty(shortcut)) + { + ShowStatus(string.Empty, false); + } + else + { + ShowStatus(string.Format(Configuration.Settings.Language.General.ShortcutX, shortcut), false); + } + } + + private void buttonSetStartAndOffsetRest_MouseEnter(object sender, EventArgs e) + { + if (!string.IsNullOrEmpty(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest2)) + { + ShowButtonShortcut(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest2); + } + else + { + ShowButtonShortcut(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest); + } + } + + private void buttonSetEndAndGoToNext_MouseEnter(object sender, EventArgs e) + { + ShowButtonShortcut(Configuration.Settings.Shortcuts.MainAdjustSetEndAndGotoNext); + } + + private void buttonAdjustSetStartTime_MouseEnter(object sender, EventArgs e) + { + ShowButtonShortcut(Configuration.Settings.Shortcuts.MainCreateSetStart); + } + + private void buttonAdjustSetEndTime_MouseEnter(object sender, EventArgs e) + { + ShowButtonShortcut(Configuration.Settings.Shortcuts.MainCreateSetEnd); + } + + private void buttonInsertNewText_MouseEnter(object sender, EventArgs e) + { + ShowButtonShortcut(Configuration.Settings.Shortcuts.MainCreateInsertSubAtVideoPos); + } + + private void buttonAdjustPlayBefore_MouseEnter(object sender, EventArgs e) + { + ShowButtonShortcut(Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore); + } + + private void buttonAdjustGoToPosAndPause_MouseEnter(object sender, EventArgs e) + { + ShowButtonShortcut(Configuration.Settings.Shortcuts.MainVideoGoToStartCurrent); + } + + private void buttonBeforeText_MouseEnter(object sender, EventArgs e) + { + ShowButtonShortcut(Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore); + } + + private void buttonGotoSub_MouseEnter(object sender, EventArgs e) + { + ShowButtonShortcut(Configuration.Settings.Shortcuts.MainVideoGoToStartCurrent); + } + + private void buttonSetStartTime_MouseEnter(object sender, EventArgs e) + { + ShowButtonShortcut(Configuration.Settings.Shortcuts.MainCreateSetStart); + } + + private void buttonSetEnd_MouseEnter(object sender, EventArgs e) + { + ShowButtonShortcut(Configuration.Settings.Shortcuts.MainCreateSetEnd); + } + + private void boxToolStripMenuItem1_Click(object sender, EventArgs e) + { + var tb = GetFocusedTextBox(); + tb.Text = HtmlUtil.ToggleTag(tb.Text, "box"); + } + + private void toolStripMenuItemPreview_Click(object sender, EventArgs e) + { + var htmlFileName = Path.Combine(Path.GetTempPath(), $"WebVttPreview_{Guid.NewGuid()}.html"); + var subText = Encoding.UTF8.GetBytes(new WebVTT().ToText(_subtitle, "preview")); + File.WriteAllText(htmlFileName, @" + + + + WebVTT preview + + + + +" + .Replace('\'', '"') + .Replace("[BASE64]", Convert.ToBase64String(subText)) + .Replace("[VIDEO]", "file://" + VideoFileName) + .Replace("[EXT]", Path.GetExtension(VideoFileName).TrimStart('.').ToLowerInvariant()), Encoding.UTF8); + UiUtil.OpenFile(htmlFileName); + + System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(25000), () => + { + try + { + File.Delete(htmlFileName); + } + catch + { + // Ignore + } + }); + } + + private void trackBarWaveformPosition_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Space) + { + mediaPlayer.TogglePlayPause(); + e.SuppressKeyPress = true; + } + } + + private void toolStripMenuItemAssaStyles_Click(object sender, EventArgs e) + { + toolStripMenuItemAssStyles_Click(sender, e); + } + + private void openSecondSubtitleToolStripMenuItem_Click(object sender, EventArgs e) + { + openFileDialog1.Title = _languageGeneral.OpenSubtitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = UiUtil.SubtitleExtensionFilter.Value; + if (openFileDialog1.ShowDialog(this) != DialogResult.OK) + { + return; + } + + if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv) + { + if (Configuration.Settings.General.MpvHandlesPreviewText) + { + Configuration.Settings.General.MpvHandlesPreviewText = false; + mediaPlayer.VideoPlayer = libMpv; + mediaPlayer.SubtitleText = string.Empty; + } + libMpv.LoadSubtitle(openFileDialog1.FileName); + } + else if (mediaPlayer.VideoPlayer is LibVlcDynamic libvlc) + { + libvlc.LoadSecondSubtitle(openFileDialog1.FileName); + } + } + + private void aSSStylesToolStripMenuItem_Click(object sender, EventArgs e) + { + toolStripMenuItemAssStyles_Click(sender, e); + } + + private void contextMenuStripEmpty_Opening(object sender, CancelEventArgs e) + { + var format = GetCurrentSubtitleFormat(); + var formatType = format.GetType(); + if (formatType == typeof(AdvancedSubStationAlpha)) + { + aSSStylesToolStripMenuItem.Visible = true; + aSSStylesToolStripMenuItem.Text = _language.Menu.ContextMenu.AdvancedSubStationAlphaStyles; + } + else if (formatType == typeof(SubStationAlpha)) + { + aSSStylesToolStripMenuItem.Visible = true; + aSSStylesToolStripMenuItem.Text = _language.Menu.ContextMenu.SubStationAlphaStyles; + } + else + { + aSSStylesToolStripMenuItem.Visible = false; + } + } + + private void splitContainerListViewAndText_SplitterMoved(object sender, SplitterEventArgs e) + { + if (Configuration.Settings.General.SubtitleTextBoxMaxHeight < splitContainerListViewAndText.Panel2MinSize && + Configuration.Settings.General.SubtitleTextBoxMaxHeight > 1000) + { + return; + } + + if (splitContainerListViewAndText.Panel2.Height > Configuration.Settings.General.SubtitleTextBoxMaxHeight) + { + splitContainerListViewAndText.SplitterDistance = splitContainerListViewAndText.Height - Configuration.Settings.General.SubtitleTextBoxMaxHeight; + } + } + + private void splitContainerListViewAndText_SizeChanged(object sender, EventArgs e) + { + splitContainerListViewAndText_SplitterMoved(null, null); + } + } +} diff --git a/src/Forms/Main.resx b/src/ui/Forms/Main.resx similarity index 98% rename from src/Forms/Main.resx rename to src/ui/Forms/Main.resx index fcd792a4a..afe2ae3cf 100644 --- a/src/Forms/Main.resx +++ b/src/ui/Forms/Main.resx @@ -1,760 +1,760 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 934, 17 - - - 217, 17 - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAS0SURBVFhH7ZfbTxxlGMaxeqU36l9h0sQLvfNGLwxNpYtY - DEUKTWyR1gilVsV6CkZrQjTWNtZDQ+SwyAoFgQWkZrssIGmXUEhKik3UcD4flvNyxsd5vsw7+WZmQZt4 - 4YVv8uR79zs8v2dmJ8wS93/9p6qrq+ux7u7upXA4jObmZqVQKISWlhZrbG1tVWpra7NJ5vW9HMWHnvQm - w8S5ixt6e3u3Nzc3sbq6qrS2tob19XVsbGyA8xy3trawvb2NnZ0dJfac0/fwDM+KD+fpTYaJc1d7e7va - uLKygmg0GjOAE+4MESsAvejJNTJMnLuampqwvLysNsu4VxBde4F1TzJMnLsaGxuxtLSkxM27wTkSyqv+ - u9tPD3qJLxkmzl0NDQ1YXFxUihWCowThSCClz+l7dbj4kmHi3FVfX4/5+XksLCzYQlDydehB2FM6mHvk - dutwetKbDBPnLr/fb4Nz1OEc5cokiA5mr+/lWd2L3mSYOHfV1dWplHNzc7Y7ISZiKgBdnJOwAhSo7kmG - iXNXbW2tDc5R4BzllhLCXpeA2etndC96k2Hi3FVdXY1IJILZ2Vk18oAehL1+dU5xjXvYC5geuicZJs5d - VVVVNjhHSe4MEktOMHvdi95kmDh3cXFmZgbT09NWEI7OMHtJh+oe9KT3ngEqKiowNTVliYfkICVmeigd - JkDZL+d1TzJMnLsqKysxOTlpwTmKEc3FmNLD6FCKcxJc96I3GSbOXT6fDxMTExgfH1ejHKL0K6ExP+sS - GMXPck486LkyuwWf74fdA5SXl1twjjy4VxCnuBaZWcCdP35G7a2T+O6Xp5R+7MxCz+/XsLUCBBoCuwco - KyvD2NgYRkdHVQD2EkYPFEtc6x++i6vhbHjD6bgxcAm/TlfhriH23o50XO3IRmNd1+4BvF6vgo+MjLiC - OMPYNYHpyQhKQ6+hvOMU2oYvwv9bngVizzmfsXb52ssA4u4zl+xVUlKC4eFhFYCjhNEDxRLXuu6E8Hnt - Ifh6TqPo9imU3H7V+rHCnnO+nlxc8CfjvO+ZIhNpr+LiYgwNDSk4RwniDOMU1wob8vDp9Zfw5Y1MXLpp - KPyK9bpmzzmuXQgdw/ulz8b+WcZ39eDgIAYGBlQA9pQE0kWwhGOfdyUBn1zPULdd3ozyupY3KNcKghl4 - o/CA6zngd7KP7+r+/n6bJJBIDybi3NmvPPggkKaM+adYXkyUvCO49mEgA7nfJLC3PQf3G3qYAWjmDCFy - hhFxvsD7FnIqkvF2UzrymtKQ99NR6x3BnnNce91/BG8WeSIm06oHDe3n73c+1X19ffes5ptBHC9IRLY/ - Fdk1RwylWn8p2XPujLGW+cXzeKc643uTaRU/PNHZ2Yn8/Pw/GYJXFgsUS9G5qPEdb+Dc1zk4etmDE/Up - OFGZYn3P7LOMuWOFSTh9MRMG7Ulj2hVgf3x8/Ef8jyYYDKofDjU1Nf9YtwI9CAe6kfNZFlI+TkRqaRLS - yl5UYp9yPhFnvj2J5OOJV8gymVapZ8DQ44YOGDps6gVDSfeow553PUHP2aejz507COpQbsJa4nuJrcba - QUNkkGV7Blj7DD1g6CFDjxh69F8WPelNBllGxcX9Bb3GzFtcbliFAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAXSSURBVFhH7ZRrbJNlHMVfozGR+MFEv/hJUMQbIETZZHId - KjJAgshNEMcCyMVkclFgEBgbKIJAIoImCsSQOWBubKXsxtxG6UZ3ZVzWru3arevW3bp2625ASI7/8/ad - m04TSdg3nuTkffb8zzm/p++2Kg/Xw/Vw/XNlZGRcNhqNSEtLQ0pKyiDxnHP6tMiDXQaD4R6fd+7cQW9v - 7yDxfKDvgS2dTndZ1r3k5OSunp4eUN3d3YPUN9Pr9Z3iR1JS0v8W3yAzZGnY/pWbm6t+sq6uLlCdnZ3/ - qT7P/YoXH8j62zpz5oxaHggE0NHRMSRiNxlkadj+lZCQgPb2dvj9/iEVGWRp2P6VmJio3tDn8w2pyCBL - w/avc+fOwev1wuPxDKnIIEvD9q9EfSbsTW2w2+2wiay2oCyazPepvlxfDzvZTQZZGja4bOkLo6ryP4cj - bwlqchegNm8hXPmL0GBYjIYrS+ExLkNjwTI0X12BVtMKeIsj0Va6Er6yKFXc84wzeuhlhll2sIud7CaD - LDI1vKJYsj+CuywWXvMP8Fp/Qlv1r/A7f0O763cE3Dp0NWahuykXt9uM6PUV47a/AncDlbjXZVPFPc/U - mXjoZYZZdrCLnewmgywyNbyimJLeh6c0Fs3X9qC5Ih7N1/ei5ebX8FUegN9yEO3WQ+iwHkHAfhRdjqPo - dh5Dl/M4emp/VMW9eiYzeuhlhll2sIudarcwyDIlzeq/gC7x3bvu4q2oL4mBpywGjdd2SmAXWm7Eoe1W - PHzmfVL2jZR+K+UHEbB9hw77IXRWH1bFvXpmOyCe/eLdL5m9aKuMkw75YBW7pXOHdG9Hfel2uIu/BJka - XlGyE94J1BZGo75oExqKN6KxdDOayraipWIbWq/HwHtzp1xkF3y3YuE3x6HdEg9/1V50WPap4l49kxk9 - 9DLDLDvYxU521xdtBFlkanhFyTw1vbU6Pwp1xrWoK1wPt2mDmKPlVUWjsWwzWsq3yKv7Sgq3wXsjBm03 - dgiIT7mYKLjfoc7ooZcZZtnBrnrpdLO7YC3IIlPDK0r6iakua84yuAyRcoFIMa6SwGp4itah0bQOTSUb - 0CxFLeXRaC7/Aq3XNsFbvhmtFZtUqXs540z1iJcZZtlRd3W19K6CqyASNcKoEhaZGl5R0o5Ptlamz4cj - dzGceUtRa/gYrivL4TZGor5wJRpMUfCY1qCxaA08xZ+huWQtmkrlYsXrg5I9zzhTPeJlhll2sIudNflL - VYZZWGRqePkjPBZacl03C47seXDkzBPjfDhz5f9W/n9dl5egTsJu43LUF3wir3AFPFc/RYN8moZCeVKy - 5xlnqke8zDDLjhr5DnDmzYf90jzYhVEhLDI1vKJcOB6SX54SDmv2TNiy3kN1dgQcl2bD+cdc1OZ+IAUf - wiWqMyyQX5N8ZxgWou7KIvl5cVCy5xlnqke8zDDLDnaxk91kkEWmhleU5KPjzxedDUNV+jRY9JNhuTgN - tozpsGfNQHXWTDhzZsqbmYWaSxHyZmZLcQRqcuYKZE5QsucZZ/TQywyz7GCXRU9NEsZUFJ2dCDI1vFzg - 8LjTxtMTYNGFwpw6QVWVLgxWfRhsFyfBnj4FtsypcGRMQ3VmOJyZM+TXFQ5HlqbsGXIWLsDpcIjPljlF - MpPl6/Zt6ZiIqgsTpfNNVRZdCIyn3wCZGl4ZdnLfS3pTwmhYLryOW+fH/CVz6jgJjJcCXm4CrBdDZB8q - 5SGw6d+Sy4UGJXuecUYPvcHMeLVjYCcZZJFJNi/w9JEtwxPTvn8V7oxRMKeMws2kAUp+GZUpr8B8/jVY - UkfLfIy8Hbls6liRFKoaq55xpnrEywyzA7vYTQZZZJLNCwx75qlH52QfH4mzB0bg59jh+Hn3c4N0Ys8I - /BL7PE7GvYBT8SNxMv5F2cuTkr16JjN66P23DnaTQRaZZPMCj4meFYWJIkQc8Dlbez4I9XX1dZNFJtnq - ekT0uOgJ0ZNDLDLIEqai/Ak8fjdf/Xa8KgAAAABJRU5ErkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAWySURBVFhH1ZZtTFZlGMdptbU+1Prq5ke/5BpbfmyWuMkH - rEinuabzrRCTnjLNVhMCJMEXUBEBY5M3RSdSCAjkM5WpvGgYQrwnPqgg+M6boKVt/87v9pzngHvWhwYf - urb/nsN9Xdf/d5/7XOd5CPpfRcHltz/8qWWB8utnK6s2WPtrZxpxzVpRc7ioeVY9BVHYuEA1ffFqG8hS - 1+ARXRspMeKatbr+LTrasFB2+eRH1oXZqurdqFM9lm5smChrjVzWxdn/bQM5OTmbKisrVVBQIOvar9zc - XOXl5anKW6WM6nfkvf6VKrrXBxQ5aqilh97xXnhXVFQoPz//axvrRllZmW7evKn79+/rwYMHevjwoUZG - Rszn6OioiNSqd1XqW6/iri8Dihw1BD3jPfDEGwYsG+tGdna27ty5o8HBQQ0PDxvR7BiMjY1p5/E5Kvrj - Cx3t8AQUOWoePXpk6p1+xw9vGLBsrBuZmZnq6enR7du3TaGzEeDOBpIK5+hw++c62BoVUOSoodbpGxoa - 8vvhDQOWjXUjIyND169fNzscGBgwopm/OU5MtxSEKLclSgd+XxdQ5Kihlh4H7vjhBQOWjXUjLS1N165d - M7vkeSGaMeFIiS1F85XV9JkyL68NKHJbisJMLXfvHLvjhzcMWDbWjdTUVHV3d+vWrVtmWNjxtuNLFZ0z - T7FH5yvmyHzF5b6n9Ia1Sr0UGVDkEg6GK/pwmNUTpujseUo5scp44Yk3DFg21o09e/aoq6tL/f39unfv - nmlo8V20zBZrx6U12t3mUcqva4x2XIgIKCe/u9Vj9URYm1iiVl+98cITbxiwbKwbKSkp5hkhp+Gv0adq - 6DivTZkLFH9mpRLrIvRDzaf/KmqopafxSq3+fPjUf0OOPywb60ZycrJ5Rryju3btUk1NjWlE1c0ntWHv - QkWfWqHY6k/0/bnVAUWOGmovdZ4z80M/XnjiDQOWjXVj+/bt6u3t1dWrV82ktre3m+K7d++aQTpzuUye - lIX6xrtC351drW+rVk0Qa+SoOd900j98eOCFJ94wYNlYN1js6OhQX1+fOSYGhk9MnNeo4kKh1u1cpK9+ - Wa6N1jFv4G4tcc3auh2L5P2txF/PsbMBxwtvGAE3sHXrVrW1tZnXhEIGhi8NNoCRY1p4Jk8RSR8pqmKZ - PN7lRlHly6y1xfr5bMEEOL2cIH4IbxiwbKwbCQkJam1tNa8J39fOJpyBxAyNjY4p50SmViYtUUTlUkWU - L9XKrUuUV5llvnycOmfwOAG88MQbBiwb60Z8fLyam5v9zwlVV1cbI+7C2Qifg8OD2nssWR9vW2K0vzhN - w0PDE2ro4ZoBdPzwhgHLxroRFxenpqYm857euHHDNJSWlurx48fm+Tkb4bOwsFC+dp8SDico6ViSfK0+ - sza+hh56S0pKjBeeeMOAZWPdiI2NVWNjozo7O81RMbV1dXU6dOiQOVqMMeWTHP87HPjxgBHXrI2voYde - PMjhiTcMWDbWjZiYGDU0NJgihsXR6dOnzXc308tPK3fn/NI9L3LUUEsPveO98IYBy8a6ER0dbd5Xdop8 - Pp9ftbW1SkxMNPJ6vWppaTHPk9cLcc0aOaeOnvEeji8MWDbWjc2bN5tkeXn5hE0410zxlStXzLNOT083 - JpGRkUZcs0aOGmfin/fAGwYsG+sGBrwi9fX15vho5Ni4O+fN4JifPHlifm4DBTlqnIlHeOCFJ94wYNlY - f7xoTebfJGlgaPi3iabJEF544g0DFsxn6KCgFyy97vF4VFxcrH379gU0mQzhDQMWTJsd9JKlmbNmzVJ4 - eLjCwsKmVDBgwbTZQS9beis4OFhz585VaGioQkJCpkR4w4AF02abXbwxbdq0ihkzZmj69OlTKhiwYNps - 8xxes/SmpVBL4ZY+sPX+JMnxwxsGLJhmBggumMpXLL1qieRUCG8YsCxmUNA/O3EGtY+g2+oAAAAASUVO - RK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAYASURBVFhHzZbbT1VHFIdP0yaN6SV9sYmJj760aUz1D2jk - AS0FMa22Wo8WowSt1bSJVwQOiBBpASEgVYtUImpLrcChB5AgNa2AlnpBQEEUL3i/IspNbqvzLfZmY6Wt - JpJ0Jb/MnJm1ft/s2bP3Pq7/VawvfnXpruog2bD/FYnwuSTSKKrIqNglnhKXRO83belgG23aGEv0h8+R - Sw21eOCFJ94wLNyTkV0VJNIjzxQDAwPS398vfX190tvbKz09PfLo0SPp7u6Wrq4u6ezslI6ODunvNsnG - G4aFezJSyt9U0xMnTqhqamrk5MmTUltbK3V1dVJfXy+nTp3SHJOucHsB/wZvb2+Xhw8fSm+XyKbysSMv - ID83f2VC2bMtALAN/68dYBEDZhc2lo0V78/eFYPUYVGUX2RWN8mYqP9TB0D0NHC8YfjyfU/uwr7cfdLY - Ui7Ree9K6NYx4v7WJe4Ml8yj3eKSxMJpkloYID/UL5VdtV/IHtPurhsUfcaYI4dcarTWeOCFJ94wYFlY - J7Izc6WnvUfu3r0rbW1tcv/+fb1vXAVXQ8TtnSbZNUtkx/HF8j2qsWT6jDFHDmFfue1FizcMWBbWiYyM - DLl48aLcvHlT7t27p6KQ3xhhGLXjPck8GiZbqhcbmZa+/h4cY44cG059a2vrkB9eMGBZWCfS0tLkwoUL - cuPGDV0pohgTdoGIzHlf0o+ESmrVohHFXGTO4A6we1w1HrYf3jBgWVgnUlNT5fz583L9+nW5c+eOrtiz - e5aszPCTtdlTZVXWVAnfOk02VS6Ub35fZEQ7XIt0LjLzA5Prb2r8tTYud6564Yk3DFgW1omUlBQ5e/as - XLt2TW7fvq0FNWcqZOV3M2T9rwtk45HFEn9wgSq2PGRExVnzGw+HmZoQWZP1ofE4rF544g0DloV1Iikp - Se8Rsgt6O3uluv43WZYcJOGFn4qn7DOJLJ1vFGJk+vzWMcTYfM0hd7mpOdpQIT0dvUMXZPvDsrBOJCYm - 6j0qLCyU5ORkqaio0EJ08LhPPk8IlBX5c2R1yTxZVeSWNSVuWV08KPqMMUcOuZW1ZXp+qMcLT7xhwLKw - TiQkJMjly5fl3LlzelJPnz6tybdu3dKDVPpHnoRuCJTl++bIVz63fFk49zExxlxobKCU/+kdOnx44IUn - 3jBgWVgnGGxoaJCrV6/qNnFgaDGxHyNvxR4JiQ6SJT99LEsLzJXmzVbRZywkKlB+qfxxKJ9tZwG2F94w - RlxAXFycvud5TEjkwLS0tOgCMLJNd5ZsE3f4dFm4Z5aE7v1ERd8dHii79mc+BqeWHcQP4Q0DloV1IjY2 - Vj82PCZXrlwZWoR9IDFDHe0dsiVvk8xeO0Pcu2eKO2em9rd50/TlY+fZB48dwAtPvGHAsrBOxMTE6FfP - vk/o0KFDasRV2AuhbW1rla93xslH4TNUSTkJ+tIZnkMNfQ6g7Yc3DFgW1ono6Gj9/PKcXrp0SQu8Xq9+ - B7h/9kJoc3NzpbmpWTyZHqMoaT7TrGPDc6ihtqCgQL3wxBsGLAvrhMfj0f8AjY2NulWc2qqqKsnJydGt - xRhTWuaKi4tl+/btKvqMDc+hhlo8mMMTbxiwLKwTkZGRcuzYMU3isNg6cOCAvrs5vQ8ePNCr4z0/kpgj - h1xqqB3uhTcMWBbWiYiICH1eWSlqbm4eUmVlpcTHx6tKS0v13xH3k8cL0WeMOTuPmuEeti8MWBbWiXXr - 1umkz+d7bBF2n1Pc1NSk93rz5s1qEhYWpqLPGHPk2Cf+7x54w4BlYZ3AgEekurpat49Cto2rs58Mtpm/ - Xf8UzJFjn3iEB1544g0DloUdihfNyexjkgIOTVZWlhY9D+GFJ94wYMEcRLtcLxi9sWzZMsnLy5P09PQR - TZ6H8IYBC6bFdr1k9PbkyZMlODhYAgICRlUwYMG02K6XjSZNnDhR/Pz8xN/fX6ZMmTIqwhsGLJgWW1fx - 1rhx44omTJgg48ePH1XBgAXTYut9eN3oHSN/o2Cj6ZaCnpNsP7xhwIKpZ4Cgw6kcY/SaEZOjIbxhwDJM - l+svNTWhA+4N0kEAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAjzSURBVFhH1Zd5VFNnGsbtaKviUgUCJMABUbYgZREQIeYi - IIpsCkGQhCQQwi4QFlFcIhaOVmqtohVaLKWtFkXFBRS3gk5ZrChLGbSZWo5UGZdTHK0jKoFnvs9zPe0f - U6H29I95zvkl9yT3vs/7ve97v5uM+b9U8NHhKezhX6/FO4bH85PqYuziaornJJ/UOCachJ2yBg7xtZib - ePbH2cpTH/MTTif8JUlZxR3zdlAchb9KPbymqAO7y2+joeYJOuuBtoZB1NY+wPZPeiCTNQ/axx6Dlax2 - KXvpn1N8PN7kx1QdtJcdQuH2azi1rx9f7voeWTnViI3dBWZBIsJC1Sgu/hYXj95DbzvQ1fwEgqTjsJcf - Oj2nFDpsqNeQGuNmyw889FXUPqnY9RPKd38PUUg+eCYCcFzEz8zMlg+azROD6xH4nMsl8DwhFCjwj4bb - uPsjsEHd8pTP7BsirZvKRvxjspN+vm9ewuHH+3f1Ii+5Ag4OEbD0ZIb43gn3HL1Fda6ewg/c3fmp7kKv - TU5eYdX8hYpblu4RmO0gwtZ3a/EDqYaaJGEt+ewiG3L0Mo85wNhEfoqdmzuwdc1JmJlJBy0Csx87CwIO - hy1ZoJJIlsUUFBTEXb58ufDvDQ0729vbd5d/vDVjvm/IDot50sc2fL52Xe4hXG4E+DK11kJUHsmGHlnx - 8a1vWoeXIm1VPQoKW+DhnQ6+j+KJt5dXXowsQrFqVXbU+vV5AZ1d7ZlarbYJrAYGBvqbmpq2hAQtVtgx - 0oeuAiWqj/ShsuoOLJfvAbP9wTTW4tUyE3+8wiFKPfxh0XUo4j6DpVv6U0//0K+UsbLo/Py8oI8+2uld - UVbm0tbW4jf0/Pk+1v+FHj7sr6w6cCAxcFl0sblrMFKU+3Hy6CNIZOWDZkuL17AWr5ZF4Pvv8xVq7bYt - HXD3zYK1r/xBcly4PD9/fUBFRcm8U+eP2dXX15uTshv09vbOGhoa2kyoI5zo7+/P+/TzT4Jy0uMjnH2V - Pzm5iYf3lmiwSt0Iy6Xbq1iLV8t26bYOSeIhrFUdg4PvygGv0NiT69ZlicpKSoSNdXU2N5qbDa9evcrp - 6urS7elpm0bfr7e26mvIZxdOn56xv6zCpago3z9UllFh6xr2dOOmJqjf+w42wUX3WItXa9aSrUhMqUFa - YiVsHNIGIqXyrdu2vbekpqZ6zrVr13jdty7ptbW1TdNoWqYS88l3CRqNhhw36d640WzY3NBgW1ZWsiA1 - I0tl4cYMqTJrsHPXHZgHFGLMGLzB2vyO1OpxJovUSMs4h5Tkk5jpkYzMjDjxnj3FXs1nGmx/IGV/8KBt - GjXtbWqaSIzHU0g7JtGkrl9v1W9ubjavrCx3L8jPDTLlR2ujpLuw/YM7mOVfMGC38vxM1un3NcNvA5Rk - J8vJbIYrk/wsNjF9XWlpqceFlgszWkmpCW/fBnSA1jfJ3L1B5mFcT0/PhGvXvpnysgrVBw865uSpYy34 - Mm1qejU2bvonTHzXkgqMGaECROa+G7pE8n3IVbViYVDJYIA043Bp6W6Plgu/JkB4kQA9nyQxtqen/jcJ - dBoePFjuKEtZ/wHfJ/ZJXu4FJKnOwWzhmvsvDEaS8fyMbQyzZyhzZRPCVhyHb8SGR1VfFXmdOVNjSyf/ - 5r87p9Pe01WT97doC27fbtXpYVtwpbHR7MK5A26+4aoOhmGGVme3YIWiCqbCnEOsxas1yyc7ypa/VpuW - 8jVSUm5CFFkOceKaPefOHXbu7u7mdl+6pHfjRuvbdA5o78lgTqED2dnZOb1Po+E0NtbbZG0syHXyT4Ys - Zi+yVd/CLVj9lCtMzWMtRtDiHeNNmAyIJF8iKakVcYqbCBHvfbpj97t+F8+etWpv/8Ggu/uSHr396OD1 - kKEkienRW/PK+UazY5WV7u5hqr6gyM1ITvoacsUx6JLNjBd9RI91GFm2Xmk+xvPTIZEeRFLiXcQrO+An - /eSJNEe96XZnnY1G02HS2Un3Aw2njxj3dHUZ3e29Mitzw9aV7qKcPrfQ7KdxihOIib0IQy8VrK3ntrGh - Ry9jQUalFZP/H5m8FokJt6BUdiNKoR72ExfcD0/auL1wW3FkZ2OdzfvFXwRHZ20pZCS5V1xC0hEctQWx - 8mooY+sxx78IK5JXQ+BsO+TItzrChh6lyJ5gPC/xsZ1/9i9RkgOQx3yDuPhuSGLVwyFx+wd8AtXPnUVr - hvn81VqviOxfGKZgKEpSBkn0EYjFx/HOwkIYeyZjQ1oEqkq3wMrCROtkb72JjT46MUz9BO789BMmQrKy - sHLIZbWIktRBLj6PGNkpiCVfIEa6D/Kow5BGHYdUfALLllfAQJAJx8AsLI2WQxzsidyUcOwsWA0zY8NB - RxvLFWz40cvII3kJT6ACd8H658LAD7FoWSlCl3+O8MhKhEV8icXLSiAM+hD2zKaHPH6ylsc1+tcKSRoC - pFlYFBiK8AAG2YlRWJcZB3NTrtba1NqFDT16zYkv1TH0TE01Eqj2mgpVN3nCDPAEacNcYRq4jKqPJ1z5 - BU+QnckJV0821td9T09P7z7ju/zR4shUMAIGoYsFUMVHQCkJAYfDecbh6BixoV9f/PDy/xVkLH0x4nDC - eYYTH7m4u/f5hsowz+UdhCzyRLoyHCL/BZg50+JnLpdLf7SOvD2/QvTicYSJhLcJ+gQewYRgrDt1qp/R - 9Ol3ra0te4ULA+DiZIsAHw+sjBHBR+AMJ/4s+nwYT3itJOhK6cX0jwg1pqb0aWdHcCa4EjzeGjs2RF9f - 9zsDA4N+17lucJxthUC/+VAlRGCGKRcGurrp5LwJhFGLZvs3An0YTSLQHY6u+qX5HIIHwZuwhBBKyNKf - OrWLw9F95uI4G072VhAFeWO2jTkMDfROk+9p9UatlwnQ0tMeTifQWTAn2BKcCO4EL8IiQjBBQsiaMmVC - B8+QA3MO52dTE8NHxuSYfM4n0Er+Yb1M4rf9p22YQbAm2BMcCbQi9LajLXHT0dEJNDXi1OsZ6B0ymDSJ - nkOv/9ODSKEzQdtC+0krQ2eD/iui0OPJBNoy+j09jy6A1Zgx/wWhJW0kH0ZaIwAAAABJRU5ErkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAmESURBVFhH1Zd7WFNHGsbjVusdK5BAgm4QFCGAgFzkJkFE - BAFRCAZICCEhGEFAQK0iGmihFdG2ohYRt5S2WlEoyoripQW1cpEoYFlQVspCpa5txWqpQrm8naHx0q6P - tXv5Y9/n+eXMyZn53pnvm3Nywvi/lPO6zydrmv97zYxrGzszujySG1G2Sz+8tM1CXgoTaTHMI0swcXnJ - l0zRsX1G0rKVzuv2//cnZRR1zGOOrAQ+iarhjdlN2FPQjarjD3C1EmioGkB5+V28nd+BiIiaAdPIY+CK - y5Zphv5nsrVVjzGVFh22jChG5tutOHmgBx/tvo7kdaWQyXaDv0CJoEAVdu26hPNHv0FXI9Bc8wDzVpbB - Qlx0ih1dNkET6t8Qv3K0ueTQPU95+YPC3V+hYM91CALSwZnmCqadqJ/LXTHAdRKB7ez3E5tN4LjAzVWO - v1V14/aXwBZVbZ8Z/4MhB9EJLU3EPyZTUcEBp5UlvQd3dyElphBWVkLMcuEP8TxWfmPtIaiwd3F7y9GR - t9rRzf01G/egUt4i+c1ZjkJYWAmw7fVy3CDZUJFJGIe+f14TckSwtR1zh2vs3ePt7a/56l9lKMjjmwr3 - I+fNJmzbeAJcrmTAyG9t71xX35KgJQsSxeLlkRkZGVH19fWZF6qqchobG/cU7Nu2Zr5nwE4jJ0mvKY83 - mPpqMeovAjyJatAgIC+IxlUzGGN653HwnZ0NeuzscNvG5s6I4dOytY0eMzs4D/HrK5GRWQtnjwTwFsof - eLi7p0RGCOXr168N27w5xfdqc2OSZshjVVdXbw3w95ab8yX37F0VKP3kaxw88k9M8c+9RdY+qmBTEnZm - v4lTqSn4qqICPYaGGBaLJ2qG/yJ20PZQqzDV8DvZ1yCPeh+zHBL6XHwCP1bIIsLT01P83303x6Nw/367 - hoZar6GffjqgGTaie/d6Dh0pKlL6LQ/fZWi/FLGKgzhxdAC2irO972yP/77wUCFov6ztW3EqLhY9U7VG - zn8ltvcb23ly1eCOrU1w9EzGbE/p3ZioYGl6+mbfwsK9Tic/PWZeWVlpSNLO6urqmknHDA0NVdBjT09P - ynsf5PuvS4gWzvVUfGXjED783l6gaNViFGXzh3bm7MSBAx9iS2YGPk6OQ+dMRg4d9yvpLUptEiuLsSnx - GKw84x66B8pOpKYmC/bv3et2saLCtL2mRu/KlSvM5uZm7Y6Ohlfo8ZpardtGvjt36tSMg/sL7bKz030W - h6wp1LYW9n2mdMeddGOgdSNQ7I/MrG3IemsHSsO9T2osfy3uogwoY48jXnkIplbxD0Mk0m07dmQtOX68 - 1La1tZXTcrNOp6Gh4ZW2tlotYj7pNqGtrY20q7Xb22v0aqqqzHbl57oLY1Oi9y3Vx/V0a/JwSEH/0QDc - fd8fOa9vRv4GwW6N3W/E54/mLEhB/JqziI05AWPnGCStiRLl5u5yrzldZXaDpP3u3YZXqGlXdfV4YjyW - QsoxkU7q2jW17sXLl7m7jx6c90XkmJpW1ZzH5jf3+uNiOKP3aOSU5Rq3Z4vL3wTFqjKsS6qBPT+mX6ZM - SM3Ly3M+V3tuhpqkmjClG5gAqMfQ/mQ/jO7o6BjX2vr5ZJqFln/Usy+tGP1pR5pF/9PmNdJJuCRkOI+Y - PE+68+OaBdIDeDVRjUX+ewd8JWtK8vL2ONeeezIBwuMJUHV0VI5MoO3KCeZlIaO0Ic3i4dPm9XIGdPj8 - IU3354vptHoHn587lBRXjaDQMngKt9w/8nG2++nTx83ozu/8/upUWnu6anJ8mZagu1s9ofPChan1IYyS - a2kmPz5trpYxsD5qK0Y5JhVrLJ4vlltsmBlv02B87GeIje2EIKQAIuXG3LNnS+a2tLSwW+rqdNrb1VPo - PqC1Jxtzcrv6zJRLIYzDvzWvj2Qga3U+HJaq+nRdlSkai9/RzLixBvwECMQfYdUqNaLknQgQ/aVv557X - vc6fOWPS2HiD1dJSp0NvP7rxvid1vxz8tLn/iHkdMd8sextS+RloO8T3TbbfoKNx+H1xnGIWGsxPgFhy - GKuUtxGtaIKXJP+BZJ3qte6rFaZtbU3TGm9cZDXeusFqpObpT8y/3heAOlLzDZJURETWQs89EUZG0xs0 - oV9cBq5xh0z46T9GSMuhXHkTCkULwuSqYS9RxrcCZfpbiuw8H7VwVPmXKss+fEHMS/3RnbcMdaTmKeKN - kEgvwNYnG6ExG+BkPWPI0sTwE03oFxR5Jhg4KXvNfdb+ECYugjTyc0RFt0AsUw0HyI48LBDbo2ULuc+v - bvzFPH8Z6umGC0+DSHQacxZlwsAlBlvihTiStxUmRtMGLWcbv6aJ/mLiclXj9J0T/krLsTSoAMGicoSK - 6nFEvATX0qyemJOV10cxkBb+BpavOAiWaxKs/ZKxLFwK0VIXvBobjJyMDeAaMAd4s4xCNeFfXPrzlD5M - l9j7+i6Z93L5dkMtW8jjtfHJyi+RlcsC18CSn3GPw4sZ5LD1b4WK4+ErScZiv0AE+/KxVhmG1KQoGE7T - GzSaPt1OE/qP6bx49KHraeb9j833LUO1TAs8Xtwgx+29Dzmua5OYwapJBrraWTo6Ot/yPVfc9w5ZDb4r - H4HerkiMFkIhDgCTyexnMhn6mrAvpsthjNM3VEa9T5s3RU3shYLhqenySC/RD30mM5ijN/6+naPj156B - EXCym4OAxS5IUARD4LMAxsbcO2w2m760jqL9n6v27fZHu0tjSc3fRF/JL+YNoeN/rBcxvMhlajiWMIWg - S+AQphEMtLW0vPSnTr09e/asLrdFvrCzMYPvQmfERQqw0HUubHgz6QsJHfv8SXQfFpMXTNUwbd8qCEdd - xPgfqkMY3uSU/h5MIlBjampMMCfMJdgTnF9+6aUAXV3tL1gsVo/9PAdYW5jAz2s+ElcKMWM6Gyxt7QTS - bxzh2doc7rQ4OsgaDzrPoblKNfjdSSVqwxkycomunKaQPuHoqh+Z2xLor54HYQkhkJCsq6XVzGRq99tZ - W8DG0gQCfw9YmBpCj6Vzilyn2Xu23Gz+TNOE41lL/t75QdD267m+BuScpuzRBKYS6IYyJJgRbAiOBHfC - YsJSgpiQPHnyuCaOHhOGTOad6dP07huQNvmeR6BleLbmsRhzNM3f6k+E0YTxhEf1p2WYQZhNsCRYE2hG - 6G1HS+IwYcIEv+n6zEodlk4xa+JE2oeO//2N+BzRwY8yQvcErSfNDP2TSv8VUWib7hX6Ck6v0350ARox - GD8DWVnn/SrmSbcAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAaOSURBVFhHvZf7TxNZFMeN/8MmTfo/NGnib+6KCyLig5e6 - PlBACrKoiMTHGszKgmij7Cb8ALrZRcQHIm9aSi1t6SOUrm3ptFNaaIuVWqY7QZBf1F9MJmfvubTFBwgl - ZE8yadqZud/PedxzT7fEraamZmtXV5eourpa/ODBAxF+j93akAHAVq/XK7JaXWKr1Sq22Wwi/C12+3ND - sba2Nklr6yPmypUr3L17fzLNzc2SjUCgyMzMjMjnC0o9Hg/jcDg4s9nGORi3w2bzimKPLRuKNDY2S+Ry - OVtXVy+UlpbBkSNHhYaG39nGxsakIFB8dnZWEgqHmUAgwBuNRmHCOwn4OTU1xXgJWOzRZWtqahLdvv0H - k5KSItTW1sO1a79CUVExHDr0kyCXJwcxMzMnikSijMUyJkQiHExOBai4z+dj/f6QZMUUlJVViWWyci4z - cx/gdf36b3D1ajUUFBTBwYOHCUTDuiBioZeGw6/5yCwHU/4g2B0MuFwuHtMRF4+nCOuD/nbp0iVRZWUl - jUBGRibghVG4fPkXOHmyEPLyDlGIO3e+DYGLRiIRxmgyC/5AEGx2JxiMoxAMTnPkdzE+g4IYCZoOn8+B - ELQGysvLJfn5+SxC7NmzF3bvzqRRuHjxMpw4UQC5uQfXhAgEIuJQKMSh545xFxUfVGlAMzzMa7XabaQm - xCQVUhINFtPimfByLleAglGIgoKCBMTevfshPX0PjUJV1UXIzz8JOTl5BEK+KgQKEI+4cacbTOYxGHqu - g56+QXjWPSCoNcM83sN0oHjoVRi83iCH78Re/xSikELs25dFITAKlZVVcOxYPmRn564IgaF1E+8sFgdv - NFuoeG+/Cjq7ByiEVmeEF7ZxWpSvSXG+eTMPGK3PANCWIYooxIED2QQig0ahoqISjh49DllZ2RRCoVAk - qhq3l2dyijEQ71RDWujuHYSnz/qgq0cBOr2JpgRTM8tFYeHtIqkPu7CwsMDMzc2t3BcQorDwFIUgXsOu - XRlw/vwFOHfuPBw+fARInQijo1YGi6imBrbqTCbpMMm1kuQcRZ887YGOzn7QaA10JwQC08BF/4W3RNzl - dgvz8/Ps4uLiytsSbQlCJjl1Kg6RB2lpuylAcXEp1gPU19fzpG1va2l5KCWFxg4onwsY8sftXdDe0QPq - 5/pE2Jc8fwukK64tHrdliJIExPc/7ITU1HTSqGRQW3tDKC4uIRC1/N17fwmtbe3w8HEnPGnvhiG1jjYg - l8vHvyS55rgox/M89+HDB+bdu3dri8cNIWQymaSk5DRL0iBkZeXA9u07sEHR4sR0lJb+DOcqLsDNWw3w - 9/1HZOsNCxaLBYWZYDAoxe2JfYDkXPz+/fvVD6TVDCHwYNJoNEx9fQO/c2eqkJaWDgSKXvv3Z0EWqZNb - 8gboeNYjjFos7JjdLsXGlLTYaoYL4XFK8r7t7NkKHiORkpIKMtlpem4cP34C7re2Ec9trNPpXH+IkzFc - tKWlRVpSUsJj6PHc2LHjRzhdVg4trQ8Bw+52uxM9f1MNFyWNQ2K329mcnFzSpA5ge8btCDdvymnL/fLQ - 2TRbEp+V4JHa2dktNDXdJS36Kpw5cxbq6m4IfX19PO0BSuVH18Q3jt2NWNxzFO/t7RO6unqgs7MH2ts7 - QKlUCQzDsGNjY1KdToeNiEWICe8mQcTFJ4hXfX0DQm9vP/T3K1CY7vFg8BWL9/E53ClqtV4ShyBHLeuP - 3Ystl5zhi36/X0Lyyg4MKIT+fiUoFCpQqdRUnGwxFkevTwWWINQJCJ8vsDEIfIEMkwlxpXKQCquHNAnP - vxSP29cQweTSgQ86nR5a7QqFUqDCag0Ma7Qx8eCq4nGjEHq9xGAwsozLQyGwI67ZmJbEnRKL5QWhHxQ0 - RFSj0YFWO5IQj+c89sqqhhBYmCaTmQ4gOCHjuLYq/LK4hVWphgStbgR05NLrDVQ8EFi/eNywc46PO5kY - AF0nGo2uPAPguU4AGL1+RPB6fTBm/QcMBhN9CbdgsuJocacwnbgOiSCEw2GepOLrZqXX68UjI0bOYrFC - lAwOM+EwGRxY8PsDPOYvWfG44XtY0OgEQuCFO+grh/R6q5jkixsZMZOWysL09EvqPRkeVg5ZEoZC6ATW - weTkJBnTgx+n/P5h8vld7JGlmT4UeuUgRy5nMps5lvVwOLuvVfHrNUwxiQIZiBwcphqj8tm6+AUhBkkq - MBqkB5ARe/POc1wHIXDdb/5L/v9ty5b/AGTnP4sdijhBAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAWWSURBVFhHrVZ7TJNXFCfZlpmYkCVzy7LpmE6zaEzmMnHz - AZ8g8n60VAoTbIEVy0MKUqSMUT6qRVYqMLGKRQRpi/gYiQqJy+oWN/Dx3zLHlo2YzSX7Q+yLGFGcjm/9 - fbu3fFWRFv0lJ+0599xzzj3fOefekEDBstbQ7SUHVmdkNxuSU/V+BBnWoEPUnx8K1YdeLyhu0yYkVDjX - RZVw4RsKnkhrmWIOOtt3HP6qpWVwCdn+bNDqrBEiUe3fH0Uq/ZxFbCrzI+EaiElUuyy2oWZiZm6wnbjS - sClB7TOK029OqLlcWmFuyslpWyyk4nKTHmsbNpX69BGYsmx/F8OwLxKTgWNXbfuyqLiye9QYk1Ix0Wo6 - b2TZmY1hzRvcOrli3x26D5nT6Y93EpXAsaOq20GNZGezk3b7r2txkrLKjlyptGGMYYrvCwkyrEGHZbvn - 5eTuHaT7IxjVBNtgWUlMz46WtvNJNJVIu1Zni4I8T2msFxZhWJj8wceRhT4epy3XdP1RVHRwEQLJUrbe - pmtZsj29vPFAIFM09dONaVL2G8jazfadNChGXDGRskVXjgLFqVMz9Kr49JqbNBgUrbX/6kKcmgYcVBbi - RXv+ogFUVvVUqI2W+XAAHnVh7RvaSFR9UKuN8/WNp8/SIApV5uOQ49OAR4tm5Xy5mVeeDXHxn/MBRMdV - cUglBgxOAuNfNJ89StQeA759ikQ7ir3IEnhJ5r4a8NibINYFF0BMYjUHHlMOfFRMyW0N2/0OrzQD0qUN - IjjbGKvm5HJ2Xo3WKqYzxNsdl4na0/FoAGKJoRF8slh/DbzFcjlbvKVJSUmns4ZDDmRmt0Ug3TQAZJAO - Krp/VtAAqJFG45ndMQnyB1Wa3h8xhITDBgQHnd0Xj2Av0iwMoGxXl4bqyRVNB3gHsyFNUIRwSMQ8EtPq - f4IcvR+f9NkYPR2tcpmi5Rd+ndRAeWX3EPigihD9jlOC0AVEzAOVDicYTOAx72EcVKA8spOObtmnbX24 - xJjY8inw66N3/IMpyRuZDc6ro6Fb5Yc+RPXjGxLxjIhNruEDkOWZduJ/kkjL2WzDqzCU4ByUta3hElF/ - vjjY8W0pzQBSjCmITkHd0OrHxKTT9LmixzpsRmrhRDjpEIDwIkMd8BueBXrDuWPohDr21EWeb+qX0TGL - 3/bO73yzvlF3MgktjEG2LW8f9/2lG9Fkae4QZxqscJaUtmcY1Z2cWTcOHifdvfe0hqj5gDoCTY2OvkxE - zwaxdDoAuaK5gH5fPNWISgiceYzGjc64NNvIihUPQe7I6BFXXf3Ru319i4ja3EADwDiWZLGTfDDeaqdd - wpnNL7krqvtcYe9xrjcWc663lk7TgjDOuWbN5O1ui4g3NheUlHXshlMh0RsPcDcYmv2cPoH4IAYHl5Mt - weHcud8WlKoO81crCHc+Bg3WnCwb6ghfM/kkp37kzYy7svpr3mAwKFYdsKeks5NW64VbRaouU77SZKLO - Ac/AgN756pvTjvAZKL27Yvq/d80hz7+O4iRbAwNaCqee6Tbz7KptdL2ykPNIt3H/PnzIcVNTfgTZ5J83 - OMfSlZwjMooLuiBpALiIiMgPnuZWPgDn6gju7ql+7t6ZAR/d+WGIm7Bf4Dyt+/lsOBWFnNtuf5tsDQyo - dgSADsBznYh98HT2fOBLv7fi/Uj4Obw1cEtZMhL0bEgS1Vpo8Uk+Ya/jlYO7Ho9SPEB+vvL7crdEcvOx - 9nuUUA/K4kRiNnD0nriSR69VEC6e9UzpGEYw/qM7Rg/2MM5l74/NGIRX7kgVn8S8IGaDQ22dRROf+n8t - PEoIQlV5LGecZZeMpUhdfEd4a4LS2Gsr77u35jZxGRkvEHNzA245Wb7JkJxecxb3vjiTvYYHK4aU8N2A - YYPBdEuWbxi39hqe7jgk5D+PjCzUX//SZwAAAABJRU5ErkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAb1SURBVFhH7VZZTFVXFL2x/WjSjyZtmrapBYk21hqgIGMF - J5RJVFRkFo0KinFAVBCNmIqKiKKiOGsCFiwFHKKCA4NARREZtNZE44QgziMKosDqWdt3eU/jR9ukST+6 - k5Uz3XvWOvvsve/V/rf/7T9hBQUFtkuWLOmsCQpC7ezZqJ01C39EReG3vDyUnihDetGvCKxdgKi6lYj+ - PRE/1WxAeVk5ThaVISqlCpFJdYhcWYvIxDqk/XwK5eWl2LdvHzw9PTF16lTBjBkzcOjQIZSUlODIkSMt - 5DTQa1pxSUnbhQsX2h/fuoX8MWNQ5O+PksBAVKgXdSu9Vgy/oskILY5A6Ilw7LmeaVgBZidVYHR0IXyJ - qGNoetAp8+fOnUNwcDAC1V7+as9JkybJvBLRodBmoNe0vXv34nV7O9rUYv3Jk8iys0POgAHIUyhdsEBe - osUXz4dHzlB45LnBI9cNlfXlMt/c3AqnoCw4Bv8icI/Iw5WrDXLaoqIiFBcXS3v8+HHBsWPHUFhYCAO9 - pu3atQvPnj0TNDc344hy1/ru3ZGqkNitGwrCw9Ha2orGRw3wzLCH1aavYa3wYYKGS/eqlYROZBdchMXQ - TTBX+HJAKo4XFom4ly9f4sWLF3j+/LnszT5NXYFRwLZt2/DkyRM8ffpU8D5rb+1AZ9sb175lnGp/0zU1 - nrKlpUWIdXLurR90+/btRgFbtmzB48eP8ejRI2mTkpIQrk4dEREBX19fpKeniwdu3LiBKBWc06ZNQ2Rk - JLy9vdHY2IjOzk5x7fTp0wVcX7x4cReZfji2Ogc537Ar27hxo2zCxfz8fISEhAgYPFlZWYYzASpTEBYW - JuD6lStXZP7mzZuYPHkyJk6cKIiOjpZ53aOmxGwfPnwIchroNW3z5s3ywqVLl+Dn54fRo0fLyefMmSPz - NMbJ2LFjZX3UqFHYv3+/zPOOZ6m0HTdunIDR3tHRgdTNW2SdpCQk8YMHD6TPNjU19W0P0MV9+/aV3KVr - ScY0ovqdO3fKGucJnpCb8HT0hpubG7y8vDBy5Ei5Il7DZ191R8qa1XLSw4cPS/DxnXv37uH+/ftYt26d - UcD69etFLRf1Bwi+oKvWwZOYgvb69WuJl7i4OGzYsAEHDhyA3Y+uqKmpwcGDB+UAjInLly/L/rQ1a9YY - BSQnJ+POnTu4ffs27t69K30+yD6F6MIoRhenC2Q08+TLli3D1q1bpY2Pj8d3VjbYs2cPsrOzJeVycnKQ - kJDQFVM7duwwCkhMTERTU5MIYKuLeZ8gHRxfvHhRyFesWCEnpOtnzpwp10ABFMcUZ4zt3r0bubm5IkJV - XWRmZhoFLF++HLdUGWZKEewTuqB3RbHP9GIwTpkyReq8nrYEx70tf5BUYwykpaVJS0Fs6aGMjAyjAKoi - cUNDQ5cQkr5PCMExs8DDw0OCcMKECZKGeq2nuXn5GHqQ0zPoGGtr166Va6LXDfSaxvymSymAOa2LMRWk - gwKYWhTNjAgNDZWaMH78eBFDY9Wz6P29ZBYDl0FI4tWrVyMlJQVLly7F3LlzjQJ4f7zX2tpa1NXViYj6 - +vouQToo4Pz583j16pWk64gRIyTvAwICpGgRtOrqaji5qA9ZSbFEO4kZ6Kyw+pg1xkCvaYsWLZKT8UWC - JZcC2OrQRVAkT9+nTx8MHDhQ6gULFwsUoZvHCF+MDQiClZ0jbBycpLW2d0I/Zxc4uQ6EraMzvrW0XSgC - YmNju+6buHbtGq5fvy4tQQEcs+X904YMGSIxwIrJYGRLIcz7uNgYJCetlOdoVWfOiFDCf5wfvL080b9/ - f6MH5s+fL+49ox6sqqoSEWzPnj0rnmFr2qeX6EIHBwepgATjYfjw4dJ3cXGRNeY6je9wzcfHR67O0dFR - xBroNY3Viy4/ffq0gK6urKwUMA5M+xRGMLJtbGzg7u6OYcOGCVatWiUxxCtlavMzTOOvGL3FZ9naqR+e - hQsXGgXww2B653Q3x+9CjwOCVdDW1hb29vYYNGgQBg8ejJiYGCE0NX4xKY7rBD3Tr18/+V8w0GsfMD9J - fOrUKQEFmPZ1z/AZvU9B6ucS5ubmcHJygqurq9wrW17BAPU7x5bgHOHs7IwePXqgoqJCftPITQGfsjrx - 3rlAMPD0/tWrV3FS/ScS7/YpcN68eTAzM4OVlZWQ8X5JRFEE+xRmbW0tYnk9rBPkJDcFdOdHg7/ldC03 - /qvgV5CgIH6uSdCzZ09YWlrKmC3HPDXHZWVlUsLJRU5yU8DnKn9jWLdZsxlIfxdHjx6VLx7/ExhoJLWw - sJCWY85znc+Rg1zkJDcFfKzQW8FLIUQhTCHU0P/H6NWr1/l35rgn92afXOQkt9hHCp8ofKHwjYLZvwTu - TQ5yKU5N+xNUiLSfSZ3YnAAAAABJRU5ErkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAASfSURBVFhH7ZVLTGNVHMY7PqLRnSsTY8yEhXFjXEx0Y8SN - MRNgoKVAX/QFLbRAeZe2tL1QoOUxgBQGihSKwHR4l7Y8ypsZnsNjoBAeA6MTZ+IYjC5cGqOf5+IdYzIb - GVoXxl/y5d5zztdzvn/PzTms//lP0rsSbfEExRje5qN7Lf4B0/3vMRxMxc6pG0c/eeDb06B3U4Cbd2Kb - mOHw0rche+jfLcDhj8NYeVyH/dMh3H3Ugv51JbrucsHYwoPLFfnq4EY6qb4bq9/dwMw3Zkw9MGHxkR2b - 33fBuRDuAMuSX0eDFLZP+zBxUoqJYxPGjg1Y+LoBgcNyOOeTwhdgcKv4HfeSDGtPXJh7WA//CQX/kRH+ - Ywpz39rRPi9G2yRXz9hDT+eiinz1Biw/dsJ7bIb3vhmeAwMCx5Xou6dD8zQ/fNU7l+RXOhbSSeXN8N+v - xPChEQP7xRg6IEGObLgREKF6ip3A2ENP86wc/ZsUxk/qMHBgRP+eEbf29CQAhY5lDRpIAMYaehyzKk7z - mBK+oxr07lNw7xWjZ1cPd9CA7l0d6nwiWEdEHzH20FM7KkXHmo4sXoKuHQNcQT06yZ537mjRMJWKmmHe - 81dvHeL6bL6EKqb5DBV+ifa6V04WK0bHtg7tZGHnVhGcm4Vo3cyH1cNHh0f1NmM/H9oe9s/WAQloWXqF - YIH1AjP0F9ZBCRoXctG2WYSWdS0cG/nkWQAHUbUnBZYm3i+M9Xzo2rh9JjcfjqAZDlKddVAGi1uAMi/3 - MmNh2QbFLeX9UjRu5aFxnWgtD/aVHNhXc3F9UYOSXgHyd95/nbH/c/I6Y/jads7ZJLXLWahZzDhT6ZAU - 5q8EoG4lCWifuUeEqrkMfLGSi9qlHNQt0f5s1K5mg7opgq7tOW9BTQsHlE+OijklymfTUTGvgm1ejarb - maD8ChS6BNA5EoeNXSLUrGSjkgStWsiEjaj6jgaWaTV0nRf48NSN12CcToV5RgnztALUVBpKZpUoJWHK - 59QoGSchnEKY/KmoWFDDMqeChYQsI2NlpJ3v5CGnKS7ATHd+FFVR91R2NopGxDBMpMAwKUdxQAFDQAkj - HWqGBKI1rYKJFglomkon7TTovSnIakq8+KEjrok2KutjkdcnQNG4DNoJOQrHU8h7KrTkqSeBdJOp0AX+ - lH6SBJxRQGVPgMoWX89MczEkVdFx8upYpLmSkOeTINsnRe6oDDl+6Zny/HLk+lPOVDCWgsweIWT18aE9 - chUNcRGRtsjfpE1sZHrFyCTbkuGREJEnaWeRdhYJpxmTQGaNBZ+KVjM/DR2tytaXeVTMD0JbDNL6hUgf - EUE5JCRKJhJBRcLIvkyE0BoXvguHhmv6/HZSaRQkPTzISRBpPx+yAQHkA3wkllwDrzTmM8YaNi4l24Rm - jinqd35bAkRDSUgmF01CXRzYxmi6+leInjmuQ8UlopeI3vhU/rE6Vh8Ntj0Wid0cxBRdxZWr78aTsTcZ - D+0NOU8D0It8EvFhRJnEKQG7jIN4Kv4J3ceMhS0ADf33vkb0FtF7RB8wot/pPnosbFvwFLq6F4no/f67 - 6L6wVR5GWKw/AKiF4yhMyBvPAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALmSURBVFhHtZfPaxNBFMdHs7/GpPtzehS86sGzB7178e7B - P8CLdw9CjlaxIig0YAtaiq3WNglFUCwGT6VUQaEtpRXT7GYFD+KlIvij63thErazr2CT7Be+p3lv3ydv - 9s1O2GHasPwk5iLjluZekCGk6oaTUC4zpsmQ/9Mb0yUB2mawIENIUcXRRwZYAoAdK8gArHPxp2k6p2RY - RlRx9JEByoazv2zQXYh4MC7DMqKKo/sCmNXspEV0ITbF93XGSjL0gKji6L4AqrqdNAwvCwAOzdFrMvSA - qOLovgAwcapgkwCx5W3DQ4/L8J7Uwl33DTAJ27Bm0iPZNtxLMrwntXDXfQM8hW2Y1hwSILTEsgzvSS3c - dd8A6NuFkWSTOJjKXOxHuntWpnSULpr2QAAT2kiyqNNdiKxgUqZ0lC6a9kAA0/Ae3IEufKZGkjs/t1lp - VKblA4DjOAYArw45mNqWuCHT2DzEpgt3PRAA+h4A3AdDwV8qQKw7X+BgMjDvEXQrndf1wAA4jtiFiPuz - GQBwZLlXMO8BxKTzuh4YAMexA6D550gAU7zDvFsQs0hsw8AAaBxHXIuNYIWCaGneeYTEl1bNHQoAjiOu - hbq4TAHAXeE5AmCcmjsUAPxluNaAh8U8CFUAvCvgO4CdwslJ5w4FAB8ql1lkeddVAPRrGFXswkweAGi5 - zEJm+1u89EMF2IXDCg+tirINQwdAxZaoqADomu4m4wCRzssFoGn4p/GDpAJsQRdwHJ+ktiEXAFTbCl6q - AOgZ+IQ/TG1DbgDhCe8iBfAeLjF3U9uQGwDoWMTFJgVRgbGdk9uQJwBr8+AqBfAWLrT4DcG8XAE+MFaE - q/o3FSCEl3FCbkOuAKg2F2MqAPoFjOQz2Ib8AZh3ssnFbxXgE3ThMWxD7gAo+Ms2pwKga3CfPDLAglHc - qxeKzbrurNZ0e6lq2FNV3bkpl0ntGv6ZVcNZWYM/LR917+sGL+7tQFcaXPylARj7BzrmrMNw48QGAAAA - AElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAf2SURBVFhH7ZdnbFTZGYYvUrQp2AaL6oZtwNheM+M+9hSX - GXuap/fiscf2YDCmZYNICKtlFVZRJLQChSIhluxGdHlZBERaRInpZU0xhpiyICCARO8oP5KgN993zDgO - yf4Lmz+x9Ojcc8857/PNuWeKpf///c//du/enUU83blzJzZu3IgNGzYI+HrTpk2CzZs3D7Zbt27Fli1b - RDuU+L2hc+Pr385lFzvZLe3du/fLvr6+vz979gwPHz4UPHr0SLSPHz/GkydP8PTpU/A48/z5c7x48QIv - X77Eq1evBHzN93gsPo/X8FrOGJrJ8Dg72S3t2rXrrzzp7t27uHfvnuD+/fuiffDgwXcWxG1cNvTe20LO - GJrJsIvnsVvi7bh9+zbu3LmDsrIy5ObmIicnB3l5eSgoKIBMJkNpaSkU5QoolUqo1WpotVrU19fDaDQK - +LqmpgYajUbMUSgUKC4ugVwuFxmcxZmczQ52sZPdooBbt26Jm5mZmXC5XLBarXA6nYhM88Ht8iAYCiIU - DKFjbiui0ShisRja29sxf+FszJw5U1y3tcUwa147mpqaEA6HEQgEEZ0egtvtFlmcydnsYBc7RQHbt2/H - zZs3xY3x48dDr9cLLBYLfBEHHE4HvH4v/AEf2jrDCIUahaS5OYqOn8aooBZRVKSxCbGZTSQOwOfzweV0 - IdjsEjlms3kwlx3sYie7pW3btuH69euCUaNGo7ZWizqdDibaWn+TA063Df6wC4GQBy0dYfh9fioihHCw - Ee0dUdqZMMJUVMAfQvO0IDy0Yyy3We3wNjphNplh0Buh0+pENjviPnZLXV1duHbtmrgxmgZNLh3MDh0c - gQZ4mhrQNMuJT7va0DLLh2jMj8Z2LyKxACJtfjS1BQdoDSDc6ke42YtgxE2Fu+EJ2+D2W2F3m2DxGEWm - 2VmH0aMHCmAnuyV+7169elWQPDIZao0aVdUa6I1aBGIWRD+w40/4CNE5LkQ63XB57fRY7PRcHWhs9cLh - oF2ia6vdhiCJebvN5gbU03bbvCZodVrUVNdApVJBpVQhOTl50MduiT8wLl26JEhMGIGKigoqQA29RYdg - RwNWdkdxCh/i0x3NaJ5tpwIaYHOYSWgVQoutARarBSazCe6wBQajnuR1QtzgrhMvRqMmuaoSCspOSkwa - 9LFb4k+mS5cu4iKRmJCAsopiKGsUMNg0CMzR48DrBfjt3lbsuP8BInPssPkMaHAQVgMCLVZY7EaY6Fpv - 0sMVosNm1EGrr0KtrpoK0KGqRg2VphLllWUoLS9BQuJw4WInu6X169fjwoULuNh/AYkjh6POroA1qIZn - Rh0WrfOgGz+DL1aPXvwS0xZaEJhhgi9qgr/NgI4PnTRmhKfZgGDrQN8fM8HbQrsRMcFD80z+Kph9Ghjc - SmittAMjE4WLneyWvvjidzjXdw69fWcxIjkBSm0Rqs2lMHsr8Pv+Fvxmhx/2SBW6bnXi19tCcIZ0sIV1 - iC204hwWY/oiG+xNtWhd8M++o7kW9nAdFVuPekcldFYF1PVFqKguxIhRicLFTnZTAZ/T53Ivzvadxqix - SbiPT3AHH+MmHbxv6dkHZ2hhi2iweLMHf3g6D67WaninabHr3ixs+bYTu/8yj/o1/9b/6nYnruNX+DPl - cB7zAEswatxI4WInu6V16z7DmbOncab3ND2Cn6BcLRPVVplLYAqUQaMvRo2lFNaIkt4Ni2BtVGLuMiu6 - X89HoLMOX7+ajdUnm/HHIf01p6M4hPnwd9SiykTrTaVQ6QpRRtkJ5GAXO9ktrV37Gb7p+Qanek5ieOKP - afuLUGmQQVknR2XtVFRSW20rRENEgS8fT8eizx3Yj7n4xVp6n7dXYdpHevRgARZvcA32T+HnmPGJkXaO - Tr+hEEq9HErK5Gx2sIud7JbWrFmDkydP4ATx3g9/gJy8yZhC5OROQomqgL5EslFQlIPy2gJ83GXFAczB - uv4IHahCmMLlqNDJYAiUQmsvGuybGstRqnofVZZCkZWbnzOQSbCDXexktyjgxIkTOH78OIYNG4bsidnI - zspEFiEvy8WEzAm0cCLkijxYW8rQT+8GW5sCpZo8qPQy5MsnC3hOYWUesidlEZSRnQlZeS6yqOUszuRs - drCLnaKA1atX49ixYwL6gYT09HSkpaYhlSgomoT0lIw3RWRBVV+AwHwN5OX01ZpPRVVMwYQJmcjImICM - 1HRMpULS0jOQlpYmyKf1qdRyFmdyNjviPnZLK1euxJEjRwQ8mF88EbnyTMEU2QDvl2TR/SzIKiZCVjZJ - tPnF2cijsTx5FnKLCBkRX8PtG+JZDGezI+5jtyjg8OHDAh5MSUnBuHHjBBzALd9LSRlPryiTXlEK0jJS - RT+X5OPGD8wdOv+7+pzDjrhPFLBixQocOnRIwIO8TfyNxUwqyBi8Hjt2NCZPzcSYMWOIscS/jr89/z/1 - 448g7mO3tHz5chw4cADd3d1ISkoSE94l7GAXO9ktCjh48KCAqzp69Kg4oT09PThz5gx6e3tx/vx59Pf3 - 4/Lly7hy5crg74cbN24I4t/vPMZzeC6v4bWcwVmcydnsiPtEAcuWLfsbn8j9+/dj37593wvsYie7pSVL - lnxN/zy85kPBg3v27HmnsINd7GS3RD8aa1etWiUOxNKlS78X2MVOdtO5kJKJEqKB8BH+N/D1f5Ohuexi - J7ulYcSPiJHEWCKFSH1HcDY72EVOadg/ANIxAuUaGiw0AAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAWfSURBVFhH7ZZLSFdbFMYPSHTRyjRNMx9ZqT3MXmplD80e - vspHT8tHggqVUhBBcBFBhCZaUNGghAY5KhoY0UBJSEszSa2JA8EsmkTkQAQVNFfnt/5ny7Hk3jsouIM2 - fJx99lp7feustfbax/oz/oz/xZg/f35vYmKibNu2TXbt2iV79uyR3bt3y86dO8Xb21sSEhIE+Y4dO2aw - ZcsWiYqK0vn27dsV6G3dulXCw8Nl06ZNkpSUpDawZXS8vLzUlk3b62G3x+rVq2V4eFgVU1NTdVNRUZGY - 8enTJ6mpqZH6+nq5ffu2PH361JGIDA0Nyb179+TOnTty69Yt6e3tdSQi169flzNnzsiJEyckPT1dBgYG - HIkInA69Dl1MSUmR7u5uKS4uluTkZPX0/fv3MjIyIpcvX5YVK1bIhg0bFJWVlfL582f58OGDfnlsbKyu - r1+/Xh1B1tfXJ2FhYbJy5UqJjIyUNWvWSGtrq3LB6aG2R2BgoExMTEh8fLycOnVKCgsLJT8/X53YuHGj - dHR06Kbjx49LSEiIhIaGyvLly6W5uVnXx8fHlXjZsmWKiIgI+fr1q8o6OzvF399f/Pz8FAcOHJCxsTGB - 06G3rJiYmK4FCxaohxkZGXLw4EFVJGzkEjJbTRYvXiyLFi2aBdapE19f31lYuHChypYsWaLACeOIj4+P - wAm3DkLHCAgI0OLavHmzhpWQr1q1SkZHR1V+/vx5dSwtLU0d/fjxo64zjh49qg7jfF5enrMq0t/fr4VN - sZLSsrIyXYfTodehi0FBQfLo0SO8U08J65cvX2RqakouXryo7+SaArpx44bKBgcH1RlTG+Sb1FC4z549 - 07Xo6GjdQzrfvHmjXHB6qO0RHBw8zdeQW3JDyCiayclJVX7y5InYOpp/cnzs2DFdZ1y5ckVTxF7kOGYG - X7506dIZ9PT06Pq3b9+wN+3QW5Yd5inyy1ebXOEEubTFP+UXXdbBjzVhZPPmzdO5G9g1e+C0555BaHJz - cyUzM1MOHTokhw8flpycHM3ryZMnZ04Gx7OkpERKS0ulvLxczp07p2DOGjJ0CgoKdA97jxw5oraxh13q - hHc4HXpPI9q/f7/U1tZqs7l06ZI8fPhQsrOzVRkjHEHjDAQ0KsgAczcpKTLEkGZlZc2cLnjArEZEvmlC - nPfHjx9rzjm/r1+/1qIBdDjw9u1beffunT7dYI3GQ56B2YeNV69eKbD/8uVL5YLTobcsjhtNBwG9IC4u - Tu8Fejn3AmkhhBwv0sIXEhFaLE+zxhMdE3Lz5Rxbji9tHg644HToLYsqpv9TwfT8qqoqrW5yW1dXJ42N - jZo7jOEMht1P9xwdN+m+fftk7969SspdYy4op7l5BseHm6q9vV3JHjx4IE1NTZoKLh5CBwgjIe3q6voJ - yMyT9AH2vHjxQtHW1qZ4/vy5csHp0FsWDYhrlO5H6Ola5holBYSNryCEfBFPCok5YO6Wocse9gK+GpvY - Nlc2nA69ZdGCab/0fVoxlxKKbDLOYITGYpzi6YZZQ8eE2U2KTWzDARecDr3HAQScTQOU8NQ4gyFCZyLE - HCLA3JAxp+cbUmxgy20brlkO0PWofPq2udfdcG9ED2DYOGhITBTZY+zNBWRwOvSeIkRw8+ZNqaiokKtX - r6ojbnARXbt2Tc6ePSunT5+W6upqWbduna7zNOAEXbhwQf+GfrRhANesIuSiwVBLS4s0NDTobTYX+PUC - 9+/fn1MOkN+9e3dOGYADLjgdesuLily7dq02oX8Cm+dad+O/6MDlnAIvHPDnhdD8mxO/wgE44HIc8MeB - UPuunrRb4zRCfkb4gfgdwDYccMEJNw4E2v90f5sfEfM/8LsAB1xwwo0DPjZibGTYKLBRbKPQmf9KYBPb - zOGCE24df9nwtRFkI8xG+G8CtuGAy+a0rO/+JNNA0Q6kqwAAAABJRU5ErkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG - YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 - 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw - bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc - VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 - c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 - Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo - mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ - kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D - TgDQASA1MVpwzwAAAABJRU5ErkJggg== - - - - 322, 17 - - - 459, 56 - - - 673, 17 - - - 1050, 17 - - - 372, 56 - - - 813, 17 - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u - ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u - PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB - AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLkRvdWJsZQMAAAAGX2l0 - ZW1zBV9zaXplCF92ZXJzaW9uBwAABggIAgAAAAkDAAAAAAAAAAAAAAAPAwAAAAAAAAAGCw== - - - - 650, 56 - - - 650, 56 - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHISURBVDhPrZDfS1NhGMf7f6Sb8A8IuwvEguqiGyF/lEFZ - usbUgsUcYxynzGNNPLN0c26xyXRpiIHo5o6xFmGtcl2IN9oQXEs3qSQ/9R5MZeckCH3guXu+n+f7vqf+ - K8XSDslUmuFQBEd3H3aXm8GRIHH1FdvFIvtrxuQ2NgiEo4RjU2Q+LrO1ta3Nu8yHP8Iw3iE/X3I5Y4lY - FOHZRJJyfuzuUSj9IjQ+jUfxatL92CGitrhczt/wWn6Xz+s/keRB4omEXiAqitpHKQ+/XfmOf0KlX1H0 - ArtL1qoJ2ruDWLoC3LU/5cZ9D7WtPVy+6WDh0w4xdZ22jna9wCb1HAjuOX3ceqhQZ5G52ixxsdHG+doH - vFwqEYmvYW6z6AVeX4Cl9xnD2uKyCE+9KfJodI5euVcvmE+qDI8+OzYsxmx1MTkZ1QsKhW8MPBkiGH3x - z3Cne4SqKy1ElDt6gWBldZW+/gGcbgXfeFL7MPFmUdts7eLspdu4rTV8XXYQ83cYSzbzeaZnZnBKEg1N - 17nWUIet00ZkLKxNVeVpVE+FJgk9bjKWHEc6nabmQvWBJCDXn1ySep3SJM9dZzA1nju5QJDNZjGZWlhc - VPkN8D3f8pYPr2wAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHbSURBVDhPrZLfS1NxGMb7f6Kb6A8Iu4lALKgughA0TYVl - 2RLpByzmGOPsB2PGyrlS5zZzi6k1kSUS5o62ipitki62iOZd8zgzKqlPvYc6rM4KhB54787zeZ7vw9n1 - X6VtVMnmnjAynsTpHcDh8RMei7OgLrOuafz8rL7evisTTaRITKcpvFylWt3Ub6Xw4gcwwdBwhGLpTX2I - JIt5/mGWP/V5+xva1lfGJ2cJhoZ4X6mYIVJbkmt10RvXT8zlyjav176gBMJk5ubMAKkotWsl5guuUcP8 - rPiJyJSK4vWaAQ5PQH/vL2OfO8o5xy06LgdpPu/jWJeTxVcfmVbX6OjqNAPsis8ASKrlaojWvgAnuhWO - tNs51HyF+/ktkgtlLGe7zYBwJEb+ecEYTGpLamOLTU8Wc/rpB67FHqC4FTNgcfkRI7Hbvw0mqQdPXjLM - cr02D6nUhBmgaRsM3hwmnpoxBqtNluv3j9FwvIeJGxYzQFQslRi4PojLH2J0MqsPJm+W2r02N/uPnsFv - a2J91cn8lK8+RH6S2UwGl6LQ1nmalrZW7P12kncSpGfu0bBvD2pwtw75a5N/Kb+Sp+lwowGJBk7tHJJ7 - nNMhdz17sbYf2DlAJHtZrT0sLal8B8x71HTDfCJyAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACiSURBVDhPYxgFmKB389//XRt+/c+e/PATNj5BAFJ89eGf - /7qhq/5j4xMEbWu//b/19Pd/Vb9FYA3ofIKgccXn/5cf/v4v5zYLrAGdTxDULn7//8T13//F7CaBNaDz - CYKKea/+777w8z+/WTdYAzqfICiZ/fz/+pM//3MatII1oPMJgoLpj/8v2PP5P6tOI1gDOp8gAMU3m24T - XAM6f9gBBgYAkeCWT284Yq8AAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAD2SURBVDhPY8AGQlf9Z4YyyQMpHY9l6uv/M0G5pIPCWc// - J077oES2Ibkzn/1P6L73P37Saw2yvJMx5en/eft//w9quPk6ofOpLcmGJPQ8+T9736//nVv//ncrvfw/ - sfeRPUmGRHY9+j9l26//JUv//k+Y/ve/Te5Z0gwJbH74v3Xte7Bm45Iv/6Wjr/03jlz236HgdDxRhnhU - 3f9fMvcdXLOiS89/Ge+VgVBpwsC+9O7/wJZncM3S3iu8oFLEAYu8O/9tCq6ANUv6rLKBChMPDLNuQzR7 - LnOFCpEGdNJu/JfyWeML5ZIOpLzX+gFzFOkpcAAAAwMAylWGggwmxE0AAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJcSURBVDhPnZLbTxNBGMX5j3zyf/CSGBNjTIwxSk00BqMx - GC+kpqIhKKkYNbSlF3oBWloKtHhLKVjQXh54McYHH6A2lBIQW+htt9vuHL+ZBbr10UlOdjPffL+Zc2a6 - fNEMfJE0vFESfT2RFK69KggZhjV1v9wkFeCaXoFTaBmOUAKO4Gd0eSMZ/Dt4U/y7iugqgzWuwhSUcaw7 - A8ZYh46fNGgA/WS9wXCVdpxfVRFIMrz+0ITR3wloNBm+fiscAtIdgIrMcMWcx1RKhWuJwfyuiUfjkgDI - CoNCzXyTNmAuJRp5sUrNxSrD5aE83AkV1gUVLyIK7nvrAlCWtHUV+h4BXOEv8BDEFV6BnUKx+uO49DwP - GzWPxFoYmGmg160BJqMpjAaWSIuw+RfbAD4kInM63+Xi4AYsMRVvPrbQH5Jxx6UBWipDs8WwX9edwH0A - UKmoULFEFi4MaIBh8m8MSLjlqAqASla5/8KeHjCTFABOl6i4U2Y4/yyHt59aGIpQgBMSeuwagJ9wt8KQ - +6MDeOY0QE1WUaRiYQ8415+j6yP/YQX3PHXctFUEgIf3uwys7UB3C7NJ8cIcwYQIxzIRw1nTL5jnm3hC - D+juWA03rBog+D5N9QWxZmQ81g5R3D/R+RVulYAzj7MYnFXQNynhtpMAFg1QlUEnoDX6DFz0rjmgVOP+ - gdwucNqYxdPpBh746hRgDdcPAIUSwwb5z+otOEPLIt3tfYZ8UfN3qm8dpilZ+O8ZrR4B1rYZfm4BPzZ1 - AO6dp88nDnXi4bp4/73uWgdAv4ZLAOwE4D//JwP+Am/6K+qXWlDMAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEsSURBVDhPYxh8YM6WCf+X7Z/hAeXCAS5xDDB5Vef/lunV - /2es70mBCoEBLnEM0LOw6f+Oh0sxFOMSZ1i0Z+p/kPNANoAUtcyo+b/76Yr/0443gBVPXdPZBBQ/gy4O - NwSk+eTHLf+PvFv3f/+rVf93Plnyf9uDxf97Dpb9b9iUC1a84cp8rOLTN/Ymg/127P3G/2sfTf6/+Eb3 - /xlnGyGKtub8L1mV9D9lUtj/9LIEnOJgv+17ufJ/2+bi/7Wrsv6XLEj6nzU9CqzIr9z5v4yS9P+0jkis - 4iaOJkEMIL8payv91zHT/m/qYPzfxtPqf0JvIFyRvpVuk4md8Rl0cRMnE19wGKCD+kkVWBXhEscAIIUg - RSp6KiiKcIljAJBCXXNdYygXDnCJD3nAwAAAPZ0MvaekYv4AAAAASUVORK5CYII= - - - - 941, 56 - - - 17, 95 - - - 354, 95 - - - 510, 95 - - - 647, 95 - - - 167, 56 - - - 1095, 56 - - - 437, 17 - - - 171, 95 - - - 17, 56 - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w - LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 - ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2 - CAAAAk1TRnQBSQFMAgEBAgEAAbgBJwG4AScBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo - AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA - AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 - AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA - AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm - AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM - AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA - ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz - AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ - AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM - AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA - AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA - AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ - AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/ - AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA - AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm - ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ - Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz - AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA - AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM - AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM - ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM - Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA - AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM - AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ - AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz - AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm - AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw - AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/xEAEHUwABB1MAAQdSQA - AewB9AQAAewB9AQABHUB7AV1AewFdSQAAewBDwHyAwAB7AEPAfIDAAR1AewBDwR1AewBDwR1JAAB7AFJ - AQ8B8gIAAewBSQEPAfICAAR1AewBSQEPA3UB7AFJAQ8DdSAAAewBEQFDARUBFAFyAUkBDwEHAesBFAFy - AUkBDwHyAQAB7AERAUMBFQEUAXIBSQEPAQcB6wEUAXIBSQEPAnUgAAHtAQgBeARyAUkBDwRyAUkBDwHy - Ae0BCAF4BHIBSQEPBHIBSQEPAXUgAAGSAQgDmAJ4AnIBbQGYAngCcgFtAZIBCAOYAngCcgFtAZgCeAJy - AW0gAAEcAcIECAJ4AewBmQIIAngB7AHzARwBwgQIAngB7AGZAggCeAHsAXUgAAGYARwBkgHtAewBCAGY - AewB8AHvAewBCAGYAewB8wEAAZgBHAGSAe0B7AEIAZgB7AHwAe8B7AEIAZgB7AJ1JAAB7QEIAewB8wIA - Ae0BCAHsAfMCAAR1Ae0BCAHsA3UB7QEIAewDdSQAAZIB7AHzAwABkgHsAfMDAAR1AZIB7AR1AZIB7AR1 - JAABHAH0BAABHAH0BAAEdQEcBXUBHAV1MAAQdTAAEHUgAAFCAU0BPgcAAT4DAAEoAwABQAMAARADAAEB - AQABAQUAAYAXAAP/AQAC/wYAAv8GAAL/BgAB8wHPBgAB8QHHBgAB8AHDBwABAR8AAQEGAAHwAcMGAAHx - AccGAAHzAc8GAAL/BgAC/wYACw== - - - - 783, 95 - - - 916, 95 - - - 115 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 934, 17 + + + 217, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAS0SURBVFhH7ZfbTxxlGMaxeqU36l9h0sQLvfNGLwxNpYtY + DEUKTWyR1gilVsV6CkZrQjTWNtZDQ+SwyAoFgQWkZrssIGmXUEhKik3UcD4flvNyxsd5vsw7+WZmQZt4 + 4YVv8uR79zs8v2dmJ8wS93/9p6qrq+ux7u7upXA4jObmZqVQKISWlhZrbG1tVWpra7NJ5vW9HMWHnvQm + w8S5ixt6e3u3Nzc3sbq6qrS2tob19XVsbGyA8xy3trawvb2NnZ0dJfac0/fwDM+KD+fpTYaJc1d7e7va + uLKygmg0GjOAE+4MESsAvejJNTJMnLuampqwvLysNsu4VxBde4F1TzJMnLsaGxuxtLSkxM27wTkSyqv+ + u9tPD3qJLxkmzl0NDQ1YXFxUihWCowThSCClz+l7dbj4kmHi3FVfX4/5+XksLCzYQlDydehB2FM6mHvk + dutwetKbDBPnLr/fb4Nz1OEc5cokiA5mr+/lWd2L3mSYOHfV1dWplHNzc7Y7ISZiKgBdnJOwAhSo7kmG + iXNXbW2tDc5R4BzllhLCXpeA2etndC96k2Hi3FVdXY1IJILZ2Vk18oAehL1+dU5xjXvYC5geuicZJs5d + VVVVNjhHSe4MEktOMHvdi95kmDh3cXFmZgbT09NWEI7OMHtJh+oe9KT3ngEqKiowNTVliYfkICVmeigd + JkDZL+d1TzJMnLsqKysxOTlpwTmKEc3FmNLD6FCKcxJc96I3GSbOXT6fDxMTExgfH1ejHKL0K6ExP+sS + GMXPck486LkyuwWf74fdA5SXl1twjjy4VxCnuBaZWcCdP35G7a2T+O6Xp5R+7MxCz+/XsLUCBBoCuwco + KyvD2NgYRkdHVQD2EkYPFEtc6x++i6vhbHjD6bgxcAm/TlfhriH23o50XO3IRmNd1+4BvF6vgo+MjLiC + OMPYNYHpyQhKQ6+hvOMU2oYvwv9bngVizzmfsXb52ssA4u4zl+xVUlKC4eFhFYCjhNEDxRLXuu6E8Hnt + Ifh6TqPo9imU3H7V+rHCnnO+nlxc8CfjvO+ZIhNpr+LiYgwNDSk4RwniDOMU1wob8vDp9Zfw5Y1MXLpp + KPyK9bpmzzmuXQgdw/ulz8b+WcZ39eDgIAYGBlQA9pQE0kWwhGOfdyUBn1zPULdd3ozyupY3KNcKghl4 + o/CA6zngd7KP7+r+/n6bJJBIDybi3NmvPPggkKaM+adYXkyUvCO49mEgA7nfJLC3PQf3G3qYAWjmDCFy + hhFxvsD7FnIqkvF2UzrymtKQ99NR6x3BnnNce91/BG8WeSIm06oHDe3n73c+1X19ffes5ptBHC9IRLY/ + Fdk1RwylWn8p2XPujLGW+cXzeKc643uTaRU/PNHZ2Yn8/Pw/GYJXFgsUS9G5qPEdb+Dc1zk4etmDE/Up + OFGZYn3P7LOMuWOFSTh9MRMG7Ulj2hVgf3x8/Ef8jyYYDKofDjU1Nf9YtwI9CAe6kfNZFlI+TkRqaRLS + yl5UYp9yPhFnvj2J5OOJV8gymVapZ8DQ44YOGDps6gVDSfeow553PUHP2aejz507COpQbsJa4nuJrcba + QUNkkGV7Blj7DD1g6CFDjxh69F8WPelNBllGxcX9Bb3GzFtcbliFAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAXSSURBVFhH7ZRrbJNlHMVfozGR+MFEv/hJUMQbIETZZHId + KjJAgshNEMcCyMVkclFgEBgbKIJAIoImCsSQOWBubKXsxtxG6UZ3ZVzWru3arevW3bp2625ASI7/8/ad + m04TSdg3nuTkffb8zzm/p++2Kg/Xw/Vw/XNlZGRcNhqNSEtLQ0pKyiDxnHP6tMiDXQaD4R6fd+7cQW9v + 7yDxfKDvgS2dTndZ1r3k5OSunp4eUN3d3YPUN9Pr9Z3iR1JS0v8W3yAzZGnY/pWbm6t+sq6uLlCdnZ3/ + qT7P/YoXH8j62zpz5oxaHggE0NHRMSRiNxlkadj+lZCQgPb2dvj9/iEVGWRp2P6VmJio3tDn8w2pyCBL + w/avc+fOwev1wuPxDKnIIEvD9q9EfSbsTW2w2+2wiay2oCyazPepvlxfDzvZTQZZGja4bOkLo6ryP4cj + bwlqchegNm8hXPmL0GBYjIYrS+ExLkNjwTI0X12BVtMKeIsj0Va6Er6yKFXc84wzeuhlhll2sIud7CaD + LDI1vKJYsj+CuywWXvMP8Fp/Qlv1r/A7f0O763cE3Dp0NWahuykXt9uM6PUV47a/AncDlbjXZVPFPc/U + mXjoZYZZdrCLnewmgywyNbyimJLeh6c0Fs3X9qC5Ih7N1/ei5ebX8FUegN9yEO3WQ+iwHkHAfhRdjqPo + dh5Dl/M4emp/VMW9eiYzeuhlhll2sIudarcwyDIlzeq/gC7x3bvu4q2oL4mBpywGjdd2SmAXWm7Eoe1W + PHzmfVL2jZR+K+UHEbB9hw77IXRWH1bFvXpmOyCe/eLdL5m9aKuMkw75YBW7pXOHdG9Hfel2uIu/BJka + XlGyE94J1BZGo75oExqKN6KxdDOayraipWIbWq/HwHtzp1xkF3y3YuE3x6HdEg9/1V50WPap4l49kxk9 + 9DLDLDvYxU521xdtBFlkanhFyTw1vbU6Pwp1xrWoK1wPt2mDmKPlVUWjsWwzWsq3yKv7Sgq3wXsjBm03 + dgiIT7mYKLjfoc7ooZcZZtnBrnrpdLO7YC3IIlPDK0r6iakua84yuAyRcoFIMa6SwGp4itah0bQOTSUb + 0CxFLeXRaC7/Aq3XNsFbvhmtFZtUqXs540z1iJcZZtlRd3W19K6CqyASNcKoEhaZGl5R0o5Ptlamz4cj + dzGceUtRa/gYrivL4TZGor5wJRpMUfCY1qCxaA08xZ+huWQtmkrlYsXrg5I9zzhTPeJlhll2sIudNflL + VYZZWGRqePkjPBZacl03C47seXDkzBPjfDhz5f9W/n9dl5egTsJu43LUF3wir3AFPFc/RYN8moZCeVKy + 5xlnqke8zDDLjhr5DnDmzYf90jzYhVEhLDI1vKJcOB6SX54SDmv2TNiy3kN1dgQcl2bD+cdc1OZ+IAUf + wiWqMyyQX5N8ZxgWou7KIvl5cVCy5xlnqke8zDDLDnaxk91kkEWmhleU5KPjzxedDUNV+jRY9JNhuTgN + tozpsGfNQHXWTDhzZsqbmYWaSxHyZmZLcQRqcuYKZE5QsucZZ/TQywyz7GCXRU9NEsZUFJ2dCDI1vFzg + 8LjTxtMTYNGFwpw6QVWVLgxWfRhsFyfBnj4FtsypcGRMQ3VmOJyZM+TXFQ5HlqbsGXIWLsDpcIjPljlF + MpPl6/Zt6ZiIqgsTpfNNVRZdCIyn3wCZGl4ZdnLfS3pTwmhYLryOW+fH/CVz6jgJjJcCXm4CrBdDZB8q + 5SGw6d+Sy4UGJXuecUYPvcHMeLVjYCcZZJFJNi/w9JEtwxPTvn8V7oxRMKeMws2kAUp+GZUpr8B8/jVY + UkfLfIy8Hbls6liRFKoaq55xpnrEywyzA7vYTQZZZJLNCwx75qlH52QfH4mzB0bg59jh+Hn3c4N0Ys8I + /BL7PE7GvYBT8SNxMv5F2cuTkr16JjN66P23DnaTQRaZZPMCj4meFYWJIkQc8Dlbez4I9XX1dZNFJtnq + ekT0uOgJ0ZNDLDLIEqai/Ak8fjdf/Xa8KgAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAWySURBVFhH1ZZtTFZlGMdptbU+1Prq5ke/5BpbfmyWuMkH + rEinuabzrRCTnjLNVhMCJMEXUBEBY5M3RSdSCAjkM5WpvGgYQrwnPqgg+M6boKVt/87v9pzngHvWhwYf + urb/nsN9Xdf/d5/7XOd5CPpfRcHltz/8qWWB8utnK6s2WPtrZxpxzVpRc7ioeVY9BVHYuEA1ffFqG8hS + 1+ARXRspMeKatbr+LTrasFB2+eRH1oXZqurdqFM9lm5smChrjVzWxdn/bQM5OTmbKisrVVBQIOvar9zc + XOXl5anKW6WM6nfkvf6VKrrXBxQ5aqilh97xXnhXVFQoPz//axvrRllZmW7evKn79+/rwYMHevjwoUZG + Rszn6OioiNSqd1XqW6/iri8Dihw1BD3jPfDEGwYsG+tGdna27ty5o8HBQQ0PDxvR7BiMjY1p5/E5Kvrj + Cx3t8AQUOWoePXpk6p1+xw9vGLBsrBuZmZnq6enR7du3TaGzEeDOBpIK5+hw++c62BoVUOSoodbpGxoa + 8vvhDQOWjXUjIyND169fNzscGBgwopm/OU5MtxSEKLclSgd+XxdQ5Kihlh4H7vjhBQOWjXUjLS1N165d + M7vkeSGaMeFIiS1F85XV9JkyL68NKHJbisJMLXfvHLvjhzcMWDbWjdTUVHV3d+vWrVtmWNjxtuNLFZ0z + T7FH5yvmyHzF5b6n9Ia1Sr0UGVDkEg6GK/pwmNUTpujseUo5scp44Yk3DFg21o09e/aoq6tL/f39unfv + nmlo8V20zBZrx6U12t3mUcqva4x2XIgIKCe/u9Vj9URYm1iiVl+98cITbxiwbKwbKSkp5hkhp+Gv0adq + 6DivTZkLFH9mpRLrIvRDzaf/KmqopafxSq3+fPjUf0OOPywb60ZycrJ5Rryju3btUk1NjWlE1c0ntWHv + QkWfWqHY6k/0/bnVAUWOGmovdZ4z80M/XnjiDQOWjXVj+/bt6u3t1dWrV82ktre3m+K7d++aQTpzuUye + lIX6xrtC351drW+rVk0Qa+SoOd900j98eOCFJ94wYNlYN1js6OhQX1+fOSYGhk9MnNeo4kKh1u1cpK9+ + Wa6N1jFv4G4tcc3auh2L5P2txF/PsbMBxwtvGAE3sHXrVrW1tZnXhEIGhi8NNoCRY1p4Jk8RSR8pqmKZ + PN7lRlHly6y1xfr5bMEEOL2cIH4IbxiwbKwbCQkJam1tNa8J39fOJpyBxAyNjY4p50SmViYtUUTlUkWU + L9XKrUuUV5llvnycOmfwOAG88MQbBiwb60Z8fLyam5v9zwlVV1cbI+7C2Qifg8OD2nssWR9vW2K0vzhN + w0PDE2ro4ZoBdPzwhgHLxroRFxenpqYm857euHHDNJSWlurx48fm+Tkb4bOwsFC+dp8SDico6ViSfK0+ + sza+hh56S0pKjBeeeMOAZWPdiI2NVWNjozo7O81RMbV1dXU6dOiQOVqMMeWTHP87HPjxgBHXrI2voYde + PMjhiTcMWDbWjZiYGDU0NJgihsXR6dOnzXc308tPK3fn/NI9L3LUUEsPveO98IYBy8a6ER0dbd5Xdop8 + Pp9ftbW1SkxMNPJ6vWppaTHPk9cLcc0aOaeOnvEeji8MWDbWjc2bN5tkeXn5hE0410zxlStXzLNOT083 + JpGRkUZcs0aOGmfin/fAGwYsG+sGBrwi9fX15vho5Ni4O+fN4JifPHlifm4DBTlqnIlHeOCFJ94wYNlY + f7xoTebfJGlgaPi3iabJEF544g0DFsxn6KCgFyy97vF4VFxcrH379gU0mQzhDQMWTJsd9JKlmbNmzVJ4 + eLjCwsKmVDBgwbTZQS9beis4OFhz585VaGioQkJCpkR4w4AF02abXbwxbdq0ihkzZmj69OlTKhiwYNps + 8xxes/SmpVBL4ZY+sPX+JMnxwxsGLJhmBggumMpXLL1qieRUCG8YsCxmUNA/O3EGtY+g2+oAAAAASUVO + RK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAYASURBVFhHzZbbT1VHFIdP0yaN6SV9sYmJj760aUz1D2jk + AS0FMa22Wo8WowSt1bSJVwQOiBBpASEgVYtUImpLrcChB5AgNa2AlnpBQEEUL3i/IspNbqvzLfZmY6Wt + JpJ0Jb/MnJm1ft/s2bP3Pq7/VawvfnXpruog2bD/FYnwuSTSKKrIqNglnhKXRO83belgG23aGEv0h8+R + Sw21eOCFJ94wLNyTkV0VJNIjzxQDAwPS398vfX190tvbKz09PfLo0SPp7u6Wrq4u6ezslI6ODunvNsnG + G4aFezJSyt9U0xMnTqhqamrk5MmTUltbK3V1dVJfXy+nTp3SHJOucHsB/wZvb2+Xhw8fSm+XyKbysSMv + ID83f2VC2bMtALAN/68dYBEDZhc2lo0V78/eFYPUYVGUX2RWN8mYqP9TB0D0NHC8YfjyfU/uwr7cfdLY + Ui7Ree9K6NYx4v7WJe4Ml8yj3eKSxMJpkloYID/UL5VdtV/IHtPurhsUfcaYI4dcarTWeOCFJ94wYFlY + J7Izc6WnvUfu3r0rbW1tcv/+fb1vXAVXQ8TtnSbZNUtkx/HF8j2qsWT6jDFHDmFfue1FizcMWBbWiYyM + DLl48aLcvHlT7t27p6KQ3xhhGLXjPck8GiZbqhcbmZa+/h4cY44cG059a2vrkB9eMGBZWCfS0tLkwoUL + cuPGDV0pohgTdoGIzHlf0o+ESmrVohHFXGTO4A6we1w1HrYf3jBgWVgnUlNT5fz583L9+nW5c+eOrtiz + e5aszPCTtdlTZVXWVAnfOk02VS6Ub35fZEQ7XIt0LjLzA5Prb2r8tTYud6564Yk3DFgW1omUlBQ5e/as + XLt2TW7fvq0FNWcqZOV3M2T9rwtk45HFEn9wgSq2PGRExVnzGw+HmZoQWZP1ofE4rF544g0DloV1Iikp + Se8Rsgt6O3uluv43WZYcJOGFn4qn7DOJLJ1vFGJk+vzWMcTYfM0hd7mpOdpQIT0dvUMXZPvDsrBOJCYm + 6j0qLCyU5ORkqaio0EJ08LhPPk8IlBX5c2R1yTxZVeSWNSVuWV08KPqMMUcOuZW1ZXp+qMcLT7xhwLKw + TiQkJMjly5fl3LlzelJPnz6tybdu3dKDVPpHnoRuCJTl++bIVz63fFk49zExxlxobKCU/+kdOnx44IUn + 3jBgWVgnGGxoaJCrV6/qNnFgaDGxHyNvxR4JiQ6SJT99LEsLzJXmzVbRZywkKlB+qfxxKJ9tZwG2F94w + RlxAXFycvud5TEjkwLS0tOgCMLJNd5ZsE3f4dFm4Z5aE7v1ERd8dHii79mc+BqeWHcQP4Q0DloV1IjY2 + Vj82PCZXrlwZWoR9IDFDHe0dsiVvk8xeO0Pcu2eKO2em9rd50/TlY+fZB48dwAtPvGHAsrBOxMTE6FfP + vk/o0KFDasRV2AuhbW1rla93xslH4TNUSTkJ+tIZnkMNfQ6g7Yc3DFgW1ono6Gj9/PKcXrp0SQu8Xq9+ + B7h/9kJoc3NzpbmpWTyZHqMoaT7TrGPDc6ihtqCgQL3wxBsGLAvrhMfj0f8AjY2NulWc2qqqKsnJydGt + xRhTWuaKi4tl+/btKvqMDc+hhlo8mMMTbxiwLKwTkZGRcuzYMU3isNg6cOCAvrs5vQ8ePNCr4z0/kpgj + h1xqqB3uhTcMWBbWiYiICH1eWSlqbm4eUmVlpcTHx6tKS0v13xH3k8cL0WeMOTuPmuEeti8MWBbWiXXr + 1umkz+d7bBF2n1Pc1NSk93rz5s1qEhYWpqLPGHPk2Cf+7x54w4BlYZ3AgEekurpat49Cto2rs58Mtpm/ + Xf8UzJFjn3iEB1544g0DloUdihfNyexjkgIOTVZWlhY9D+GFJ94wYMEcRLtcLxi9sWzZMsnLy5P09PQR + TZ6H8IYBC6bFdr1k9PbkyZMlODhYAgICRlUwYMG02K6XjSZNnDhR/Pz8xN/fX6ZMmTIqwhsGLJgWW1fx + 1rhx44omTJgg48ePH1XBgAXTYut9eN3oHSN/o2Cj6ZaCnpNsP7xhwIKpZ4Cgw6kcY/SaEZOjIbxhwDJM + l+svNTWhA+4N0kEAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAjzSURBVFhH1Zd5VFNnGsbtaKviUgUCJMABUbYgZREQIeYi + IIpsCkGQhCQQwi4QFlFcIhaOVmqtohVaLKWtFkXFBRS3gk5ZrChLGbSZWo5UGZdTHK0jKoFnvs9zPe0f + U6H29I95zvkl9yT3vs/7ve97v5uM+b9U8NHhKezhX6/FO4bH85PqYuziaornJJ/UOCachJ2yBg7xtZib + ePbH2cpTH/MTTif8JUlZxR3zdlAchb9KPbymqAO7y2+joeYJOuuBtoZB1NY+wPZPeiCTNQ/axx6Dlax2 + KXvpn1N8PN7kx1QdtJcdQuH2azi1rx9f7voeWTnViI3dBWZBIsJC1Sgu/hYXj95DbzvQ1fwEgqTjsJcf + Oj2nFDpsqNeQGuNmyw889FXUPqnY9RPKd38PUUg+eCYCcFzEz8zMlg+azROD6xH4nMsl8DwhFCjwj4bb + uPsjsEHd8pTP7BsirZvKRvxjspN+vm9ewuHH+3f1Ii+5Ag4OEbD0ZIb43gn3HL1Fda6ewg/c3fmp7kKv + TU5eYdX8hYpblu4RmO0gwtZ3a/EDqYaaJGEt+ewiG3L0Mo85wNhEfoqdmzuwdc1JmJlJBy0Csx87CwIO + hy1ZoJJIlsUUFBTEXb58ufDvDQ0729vbd5d/vDVjvm/IDot50sc2fL52Xe4hXG4E+DK11kJUHsmGHlnx + 8a1vWoeXIm1VPQoKW+DhnQ6+j+KJt5dXXowsQrFqVXbU+vV5AZ1d7ZlarbYJrAYGBvqbmpq2hAQtVtgx + 0oeuAiWqj/ShsuoOLJfvAbP9wTTW4tUyE3+8wiFKPfxh0XUo4j6DpVv6U0//0K+UsbLo/Py8oI8+2uld + UVbm0tbW4jf0/Pk+1v+FHj7sr6w6cCAxcFl0sblrMFKU+3Hy6CNIZOWDZkuL17AWr5ZF4Pvv8xVq7bYt + HXD3zYK1r/xBcly4PD9/fUBFRcm8U+eP2dXX15uTshv09vbOGhoa2kyoI5zo7+/P+/TzT4Jy0uMjnH2V + Pzm5iYf3lmiwSt0Iy6Xbq1iLV8t26bYOSeIhrFUdg4PvygGv0NiT69ZlicpKSoSNdXU2N5qbDa9evcrp + 6urS7elpm0bfr7e26mvIZxdOn56xv6zCpago3z9UllFh6xr2dOOmJqjf+w42wUX3WItXa9aSrUhMqUFa + YiVsHNIGIqXyrdu2vbekpqZ6zrVr13jdty7ptbW1TdNoWqYS88l3CRqNhhw36d640WzY3NBgW1ZWsiA1 + I0tl4cYMqTJrsHPXHZgHFGLMGLzB2vyO1OpxJovUSMs4h5Tkk5jpkYzMjDjxnj3FXs1nGmx/IGV/8KBt + GjXtbWqaSIzHU0g7JtGkrl9v1W9ubjavrCx3L8jPDTLlR2ujpLuw/YM7mOVfMGC38vxM1un3NcNvA5Rk + J8vJbIYrk/wsNjF9XWlpqceFlgszWkmpCW/fBnSA1jfJ3L1B5mFcT0/PhGvXvpnysgrVBw865uSpYy34 + Mm1qejU2bvonTHzXkgqMGaECROa+G7pE8n3IVbViYVDJYIA043Bp6W6Plgu/JkB4kQA9nyQxtqen/jcJ + dBoePFjuKEtZ/wHfJ/ZJXu4FJKnOwWzhmvsvDEaS8fyMbQyzZyhzZRPCVhyHb8SGR1VfFXmdOVNjSyf/ + 5r87p9Pe01WT97doC27fbtXpYVtwpbHR7MK5A26+4aoOhmGGVme3YIWiCqbCnEOsxas1yyc7ypa/VpuW + 8jVSUm5CFFkOceKaPefOHXbu7u7mdl+6pHfjRuvbdA5o78lgTqED2dnZOb1Po+E0NtbbZG0syHXyT4Ys + Zi+yVd/CLVj9lCtMzWMtRtDiHeNNmAyIJF8iKakVcYqbCBHvfbpj97t+F8+etWpv/8Ggu/uSHr396OD1 + kKEkienRW/PK+UazY5WV7u5hqr6gyM1ITvoacsUx6JLNjBd9RI91GFm2Xmk+xvPTIZEeRFLiXcQrO+An + /eSJNEe96XZnnY1G02HS2Un3Aw2njxj3dHUZ3e29Mitzw9aV7qKcPrfQ7KdxihOIib0IQy8VrK3ntrGh + Ry9jQUalFZP/H5m8FokJt6BUdiNKoR72ExfcD0/auL1wW3FkZ2OdzfvFXwRHZ20pZCS5V1xC0hEctQWx + 8mooY+sxx78IK5JXQ+BsO+TItzrChh6lyJ5gPC/xsZ1/9i9RkgOQx3yDuPhuSGLVwyFx+wd8AtXPnUVr + hvn81VqviOxfGKZgKEpSBkn0EYjFx/HOwkIYeyZjQ1oEqkq3wMrCROtkb72JjT46MUz9BO789BMmQrKy + sHLIZbWIktRBLj6PGNkpiCVfIEa6D/Kow5BGHYdUfALLllfAQJAJx8AsLI2WQxzsidyUcOwsWA0zY8NB + RxvLFWz40cvII3kJT6ACd8H658LAD7FoWSlCl3+O8MhKhEV8icXLSiAM+hD2zKaHPH6ylsc1+tcKSRoC + pFlYFBiK8AAG2YlRWJcZB3NTrtba1NqFDT16zYkv1TH0TE01Eqj2mgpVN3nCDPAEacNcYRq4jKqPJ1z5 + BU+QnckJV0821td9T09P7z7ju/zR4shUMAIGoYsFUMVHQCkJAYfDecbh6BixoV9f/PDy/xVkLH0x4nDC + eYYTH7m4u/f5hsowz+UdhCzyRLoyHCL/BZg50+JnLpdLf7SOvD2/QvTicYSJhLcJ+gQewYRgrDt1qp/R + 9Ol3ra0te4ULA+DiZIsAHw+sjBHBR+AMJ/4s+nwYT3itJOhK6cX0jwg1pqb0aWdHcCa4EjzeGjs2RF9f + 9zsDA4N+17lucJxthUC/+VAlRGCGKRcGurrp5LwJhFGLZvs3An0YTSLQHY6u+qX5HIIHwZuwhBBKyNKf + OrWLw9F95uI4G072VhAFeWO2jTkMDfROk+9p9UatlwnQ0tMeTifQWTAn2BKcCO4EL8IiQjBBQsiaMmVC + B8+QA3MO52dTE8NHxuSYfM4n0Er+Yb1M4rf9p22YQbAm2BMcCbQi9LajLXHT0dEJNDXi1OsZ6B0ymDSJ + nkOv/9ODSKEzQdtC+0krQ2eD/iui0OPJBNoy+j09jy6A1Zgx/wWhJW0kH0ZaIwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAmESURBVFhH1Zd7WFNHGsbjVusdK5BAgm4QFCGAgFzkJkFE + BAFRCAZICCEhGEFAQK0iGmihFdG2ohYRt5S2WlEoyoripQW1cpEoYFlQVspCpa5txWqpQrm8naHx0q6P + tXv5Y9/n+eXMyZn53pnvm3Nywvi/lPO6zydrmv97zYxrGzszujySG1G2Sz+8tM1CXgoTaTHMI0swcXnJ + l0zRsX1G0rKVzuv2//cnZRR1zGOOrAQ+iarhjdlN2FPQjarjD3C1EmioGkB5+V28nd+BiIiaAdPIY+CK + y5Zphv5nsrVVjzGVFh22jChG5tutOHmgBx/tvo7kdaWQyXaDv0CJoEAVdu26hPNHv0FXI9Bc8wDzVpbB + Qlx0ih1dNkET6t8Qv3K0ueTQPU95+YPC3V+hYM91CALSwZnmCqadqJ/LXTHAdRKB7ez3E5tN4LjAzVWO + v1V14/aXwBZVbZ8Z/4MhB9EJLU3EPyZTUcEBp5UlvQd3dyElphBWVkLMcuEP8TxWfmPtIaiwd3F7y9GR + t9rRzf01G/egUt4i+c1ZjkJYWAmw7fVy3CDZUJFJGIe+f14TckSwtR1zh2vs3ePt7a/56l9lKMjjmwr3 + I+fNJmzbeAJcrmTAyG9t71xX35KgJQsSxeLlkRkZGVH19fWZF6qqchobG/cU7Nu2Zr5nwE4jJ0mvKY83 + mPpqMeovAjyJatAgIC+IxlUzGGN653HwnZ0NeuzscNvG5s6I4dOytY0eMzs4D/HrK5GRWQtnjwTwFsof + eLi7p0RGCOXr168N27w5xfdqc2OSZshjVVdXbw3w95ab8yX37F0VKP3kaxw88k9M8c+9RdY+qmBTEnZm + v4lTqSn4qqICPYaGGBaLJ2qG/yJ20PZQqzDV8DvZ1yCPeh+zHBL6XHwCP1bIIsLT01P83303x6Nw/367 + hoZar6GffjqgGTaie/d6Dh0pKlL6LQ/fZWi/FLGKgzhxdAC2irO972yP/77wUCFov6ztW3EqLhY9U7VG + zn8ltvcb23ly1eCOrU1w9EzGbE/p3ZioYGl6+mbfwsK9Tic/PWZeWVlpSNLO6urqmknHDA0NVdBjT09P + ynsf5PuvS4gWzvVUfGXjED783l6gaNViFGXzh3bm7MSBAx9iS2YGPk6OQ+dMRg4d9yvpLUptEiuLsSnx + GKw84x66B8pOpKYmC/bv3et2saLCtL2mRu/KlSvM5uZm7Y6Ohlfo8ZpardtGvjt36tSMg/sL7bKz030W + h6wp1LYW9n2mdMeddGOgdSNQ7I/MrG3IemsHSsO9T2osfy3uogwoY48jXnkIplbxD0Mk0m07dmQtOX68 + 1La1tZXTcrNOp6Gh4ZW2tlotYj7pNqGtrY20q7Xb22v0aqqqzHbl57oLY1Oi9y3Vx/V0a/JwSEH/0QDc + fd8fOa9vRv4GwW6N3W/E54/mLEhB/JqziI05AWPnGCStiRLl5u5yrzldZXaDpP3u3YZXqGlXdfV4YjyW + QsoxkU7q2jW17sXLl7m7jx6c90XkmJpW1ZzH5jf3+uNiOKP3aOSU5Rq3Z4vL3wTFqjKsS6qBPT+mX6ZM + SM3Ly3M+V3tuhpqkmjClG5gAqMfQ/mQ/jO7o6BjX2vr5ZJqFln/Usy+tGP1pR5pF/9PmNdJJuCRkOI+Y + PE+68+OaBdIDeDVRjUX+ewd8JWtK8vL2ONeeezIBwuMJUHV0VI5MoO3KCeZlIaO0Ic3i4dPm9XIGdPj8 + IU3354vptHoHn587lBRXjaDQMngKt9w/8nG2++nTx83ozu/8/upUWnu6anJ8mZagu1s9ofPChan1IYyS + a2kmPz5trpYxsD5qK0Y5JhVrLJ4vlltsmBlv02B87GeIje2EIKQAIuXG3LNnS+a2tLSwW+rqdNrb1VPo + PqC1Jxtzcrv6zJRLIYzDvzWvj2Qga3U+HJaq+nRdlSkai9/RzLixBvwECMQfYdUqNaLknQgQ/aVv557X + vc6fOWPS2HiD1dJSp0NvP7rxvid1vxz8tLn/iHkdMd8sextS+RloO8T3TbbfoKNx+H1xnGIWGsxPgFhy + GKuUtxGtaIKXJP+BZJ3qte6rFaZtbU3TGm9cZDXeusFqpObpT8y/3heAOlLzDZJURETWQs89EUZG0xs0 + oV9cBq5xh0z46T9GSMuhXHkTCkULwuSqYS9RxrcCZfpbiuw8H7VwVPmXKss+fEHMS/3RnbcMdaTmKeKN + kEgvwNYnG6ExG+BkPWPI0sTwE03oFxR5Jhg4KXvNfdb+ECYugjTyc0RFt0AsUw0HyI48LBDbo2ULuc+v + bvzFPH8Z6umGC0+DSHQacxZlwsAlBlvihTiStxUmRtMGLWcbv6aJ/mLiclXj9J0T/krLsTSoAMGicoSK + 6nFEvATX0qyemJOV10cxkBb+BpavOAiWaxKs/ZKxLFwK0VIXvBobjJyMDeAaMAd4s4xCNeFfXPrzlD5M + l9j7+i6Z93L5dkMtW8jjtfHJyi+RlcsC18CSn3GPw4sZ5LD1b4WK4+ErScZiv0AE+/KxVhmG1KQoGE7T + GzSaPt1OE/qP6bx49KHraeb9j833LUO1TAs8Xtwgx+29Dzmua5OYwapJBrraWTo6Ot/yPVfc9w5ZDb4r + H4HerkiMFkIhDgCTyexnMhn6mrAvpsthjNM3VEa9T5s3RU3shYLhqenySC/RD30mM5ijN/6+naPj156B + EXCym4OAxS5IUARD4LMAxsbcO2w2m760jqL9n6v27fZHu0tjSc3fRF/JL+YNoeN/rBcxvMhlajiWMIWg + S+AQphEMtLW0vPSnTr09e/asLrdFvrCzMYPvQmfERQqw0HUubHgz6QsJHfv8SXQfFpMXTNUwbd8qCEdd + xPgfqkMY3uSU/h5MIlBjampMMCfMJdgTnF9+6aUAXV3tL1gsVo/9PAdYW5jAz2s+ElcKMWM6Gyxt7QTS + bxzh2doc7rQ4OsgaDzrPoblKNfjdSSVqwxkycomunKaQPuHoqh+Z2xLor54HYQkhkJCsq6XVzGRq99tZ + W8DG0gQCfw9YmBpCj6Vzilyn2Xu23Gz+TNOE41lL/t75QdD267m+BuScpuzRBKYS6IYyJJgRbAiOBHfC + YsJSgpiQPHnyuCaOHhOGTOad6dP07huQNvmeR6BleLbmsRhzNM3f6k+E0YTxhEf1p2WYQZhNsCRYE2hG + 6G1HS+IwYcIEv+n6zEodlk4xa+JE2oeO//2N+BzRwY8yQvcErSfNDP2TSv8VUWib7hX6Ck6v0350ARox + GD8DWVnn/SrmSbcAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAaOSURBVFhHvZf7TxNZFMeN/8MmTfo/NGnib+6KCyLig5e6 + PlBACrKoiMTHGszKgmij7Cb8ALrZRcQHIm9aSi1t6SOUrm3ptFNaaIuVWqY7QZBf1F9MJmfvubTFBwgl + ZE8yadqZud/PedxzT7fEraamZmtXV5eourpa/ODBAxF+j93akAHAVq/XK7JaXWKr1Sq22Wwi/C12+3ND + sba2Nklr6yPmypUr3L17fzLNzc2SjUCgyMzMjMjnC0o9Hg/jcDg4s9nGORi3w2bzimKPLRuKNDY2S+Ry + OVtXVy+UlpbBkSNHhYaG39nGxsakIFB8dnZWEgqHmUAgwBuNRmHCOwn4OTU1xXgJWOzRZWtqahLdvv0H + k5KSItTW1sO1a79CUVExHDr0kyCXJwcxMzMnikSijMUyJkQiHExOBai4z+dj/f6QZMUUlJVViWWyci4z + cx/gdf36b3D1ajUUFBTBwYOHCUTDuiBioZeGw6/5yCwHU/4g2B0MuFwuHtMRF4+nCOuD/nbp0iVRZWUl + jUBGRibghVG4fPkXOHmyEPLyDlGIO3e+DYGLRiIRxmgyC/5AEGx2JxiMoxAMTnPkdzE+g4IYCZoOn8+B + ELQGysvLJfn5+SxC7NmzF3bvzqRRuHjxMpw4UQC5uQfXhAgEIuJQKMSh545xFxUfVGlAMzzMa7XabaQm + xCQVUhINFtPimfByLleAglGIgoKCBMTevfshPX0PjUJV1UXIzz8JOTl5BEK+KgQKEI+4cacbTOYxGHqu + g56+QXjWPSCoNcM83sN0oHjoVRi83iCH78Re/xSikELs25dFITAKlZVVcOxYPmRn564IgaF1E+8sFgdv + NFuoeG+/Cjq7ByiEVmeEF7ZxWpSvSXG+eTMPGK3PANCWIYooxIED2QQig0ahoqISjh49DllZ2RRCoVAk + qhq3l2dyijEQ71RDWujuHYSnz/qgq0cBOr2JpgRTM8tFYeHtIqkPu7CwsMDMzc2t3BcQorDwFIUgXsOu + XRlw/vwFOHfuPBw+fARInQijo1YGi6imBrbqTCbpMMm1kuQcRZ887YGOzn7QaA10JwQC08BF/4W3RNzl + dgvz8/Ps4uLiytsSbQlCJjl1Kg6RB2lpuylAcXEp1gPU19fzpG1va2l5KCWFxg4onwsY8sftXdDe0QPq + 5/pE2Jc8fwukK64tHrdliJIExPc/7ITU1HTSqGRQW3tDKC4uIRC1/N17fwmtbe3w8HEnPGnvhiG1jjYg + l8vHvyS55rgox/M89+HDB+bdu3dri8cNIWQymaSk5DRL0iBkZeXA9u07sEHR4sR0lJb+DOcqLsDNWw3w + 9/1HZOsNCxaLBYWZYDAoxe2JfYDkXPz+/fvVD6TVDCHwYNJoNEx9fQO/c2eqkJaWDgSKXvv3Z0EWqZNb + 8gboeNYjjFos7JjdLsXGlLTYaoYL4XFK8r7t7NkKHiORkpIKMtlpem4cP34C7re2Ec9trNPpXH+IkzFc + tKWlRVpSUsJj6PHc2LHjRzhdVg4trQ8Bw+52uxM9f1MNFyWNQ2K329mcnFzSpA5ge8btCDdvymnL/fLQ + 2TRbEp+V4JHa2dktNDXdJS36Kpw5cxbq6m4IfX19PO0BSuVH18Q3jt2NWNxzFO/t7RO6unqgs7MH2ts7 + QKlUCQzDsGNjY1KdToeNiEWICe8mQcTFJ4hXfX0DQm9vP/T3K1CY7vFg8BWL9/E53ClqtV4ShyBHLeuP + 3Ystl5zhi36/X0Lyyg4MKIT+fiUoFCpQqdRUnGwxFkevTwWWINQJCJ8vsDEIfIEMkwlxpXKQCquHNAnP + vxSP29cQweTSgQ86nR5a7QqFUqDCag0Ma7Qx8eCq4nGjEHq9xGAwsozLQyGwI67ZmJbEnRKL5QWhHxQ0 + RFSj0YFWO5IQj+c89sqqhhBYmCaTmQ4gOCHjuLYq/LK4hVWphgStbgR05NLrDVQ8EFi/eNywc46PO5kY + AF0nGo2uPAPguU4AGL1+RPB6fTBm/QcMBhN9CbdgsuJocacwnbgOiSCEw2GepOLrZqXX68UjI0bOYrFC + lAwOM+EwGRxY8PsDPOYvWfG44XtY0OgEQuCFO+grh/R6q5jkixsZMZOWysL09EvqPRkeVg5ZEoZC6ATW + weTkJBnTgx+n/P5h8vld7JGlmT4UeuUgRy5nMps5lvVwOLuvVfHrNUwxiQIZiBwcphqj8tm6+AUhBkkq + MBqkB5ARe/POc1wHIXDdb/5L/v9ty5b/AGTnP4sdijhBAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAWWSURBVFhHrVZ7TJNXFCfZlpmYkCVzy7LpmE6zaEzmMnHz + AZ8g8n60VAoTbIEVy0MKUqSMUT6qRVYqMLGKRQRpi/gYiQqJy+oWN/Dx3zLHlo2YzSX7Q+yLGFGcjm/9 + fbu3fFWRFv0lJ+0599xzzj3fOefekEDBstbQ7SUHVmdkNxuSU/V+BBnWoEPUnx8K1YdeLyhu0yYkVDjX + RZVw4RsKnkhrmWIOOtt3HP6qpWVwCdn+bNDqrBEiUe3fH0Uq/ZxFbCrzI+EaiElUuyy2oWZiZm6wnbjS + sClB7TOK029OqLlcWmFuyslpWyyk4nKTHmsbNpX69BGYsmx/F8OwLxKTgWNXbfuyqLiye9QYk1Ix0Wo6 + b2TZmY1hzRvcOrli3x26D5nT6Y93EpXAsaOq20GNZGezk3b7r2txkrLKjlyptGGMYYrvCwkyrEGHZbvn + 5eTuHaT7IxjVBNtgWUlMz46WtvNJNJVIu1Zni4I8T2msFxZhWJj8wceRhT4epy3XdP1RVHRwEQLJUrbe + pmtZsj29vPFAIFM09dONaVL2G8jazfadNChGXDGRskVXjgLFqVMz9Kr49JqbNBgUrbX/6kKcmgYcVBbi + RXv+ogFUVvVUqI2W+XAAHnVh7RvaSFR9UKuN8/WNp8/SIApV5uOQ49OAR4tm5Xy5mVeeDXHxn/MBRMdV + cUglBgxOAuNfNJ89StQeA759ikQ7ir3IEnhJ5r4a8NibINYFF0BMYjUHHlMOfFRMyW0N2/0OrzQD0qUN + IjjbGKvm5HJ2Xo3WKqYzxNsdl4na0/FoAGKJoRF8slh/DbzFcjlbvKVJSUmns4ZDDmRmt0Ug3TQAZJAO + Krp/VtAAqJFG45ndMQnyB1Wa3h8xhITDBgQHnd0Xj2Av0iwMoGxXl4bqyRVNB3gHsyFNUIRwSMQ8EtPq + f4IcvR+f9NkYPR2tcpmi5Rd+ndRAeWX3EPigihD9jlOC0AVEzAOVDicYTOAx72EcVKA8spOObtmnbX24 + xJjY8inw66N3/IMpyRuZDc6ro6Fb5Yc+RPXjGxLxjIhNruEDkOWZduJ/kkjL2WzDqzCU4ByUta3hElF/ + vjjY8W0pzQBSjCmITkHd0OrHxKTT9LmixzpsRmrhRDjpEIDwIkMd8BueBXrDuWPohDr21EWeb+qX0TGL + 3/bO73yzvlF3MgktjEG2LW8f9/2lG9Fkae4QZxqscJaUtmcY1Z2cWTcOHifdvfe0hqj5gDoCTY2OvkxE + zwaxdDoAuaK5gH5fPNWISgiceYzGjc64NNvIihUPQe7I6BFXXf3Ru319i4ja3EADwDiWZLGTfDDeaqdd + wpnNL7krqvtcYe9xrjcWc663lk7TgjDOuWbN5O1ui4g3NheUlHXshlMh0RsPcDcYmv2cPoH4IAYHl5Mt + weHcud8WlKoO81crCHc+Bg3WnCwb6ghfM/kkp37kzYy7svpr3mAwKFYdsKeks5NW64VbRaouU77SZKLO + Ac/AgN756pvTjvAZKL27Yvq/d80hz7+O4iRbAwNaCqee6Tbz7KptdL2ykPNIt3H/PnzIcVNTfgTZ5J83 + OMfSlZwjMooLuiBpALiIiMgPnuZWPgDn6gju7ql+7t6ZAR/d+WGIm7Bf4Dyt+/lsOBWFnNtuf5tsDQyo + dgSADsBznYh98HT2fOBLv7fi/Uj4Obw1cEtZMhL0bEgS1Vpo8Uk+Ya/jlYO7Ho9SPEB+vvL7crdEcvOx + 9nuUUA/K4kRiNnD0nriSR69VEC6e9UzpGEYw/qM7Rg/2MM5l74/NGIRX7kgVn8S8IGaDQ22dRROf+n8t + PEoIQlV5LGecZZeMpUhdfEd4a4LS2Gsr77u35jZxGRkvEHNzA245Wb7JkJxecxb3vjiTvYYHK4aU8N2A + YYPBdEuWbxi39hqe7jgk5D+PjCzUX//SZwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAb1SURBVFhH7VZZTFVXFL2x/WjSjyZtmrapBYk21hqgIGMF + J5RJVFRkFo0KinFAVBCNmIqKiKKiOGsCFiwFHKKCA4NARREZtNZE44QgziMKosDqWdt3eU/jR9ukST+6 + k5Uz3XvWOvvsve/V/rf/7T9hBQUFtkuWLOmsCQpC7ezZqJ01C39EReG3vDyUnihDetGvCKxdgKi6lYj+ + PRE/1WxAeVk5ThaVISqlCpFJdYhcWYvIxDqk/XwK5eWl2LdvHzw9PTF16lTBjBkzcOjQIZSUlODIkSMt + 5DTQa1pxSUnbhQsX2h/fuoX8MWNQ5O+PksBAVKgXdSu9Vgy/oskILY5A6Ilw7LmeaVgBZidVYHR0IXyJ + qGNoetAp8+fOnUNwcDAC1V7+as9JkybJvBLRodBmoNe0vXv34nV7O9rUYv3Jk8iys0POgAHIUyhdsEBe + osUXz4dHzlB45LnBI9cNlfXlMt/c3AqnoCw4Bv8icI/Iw5WrDXLaoqIiFBcXS3v8+HHBsWPHUFhYCAO9 + pu3atQvPnj0TNDc344hy1/ru3ZGqkNitGwrCw9Ha2orGRw3wzLCH1aavYa3wYYKGS/eqlYROZBdchMXQ + TTBX+HJAKo4XFom4ly9f4sWLF3j+/LnszT5NXYFRwLZt2/DkyRM8ffpU8D5rb+1AZ9sb175lnGp/0zU1 + nrKlpUWIdXLurR90+/btRgFbtmzB48eP8ejRI2mTkpIQrk4dEREBX19fpKeniwdu3LiBKBWc06ZNQ2Rk + JLy9vdHY2IjOzk5x7fTp0wVcX7x4cReZfji2Ogc537Ar27hxo2zCxfz8fISEhAgYPFlZWYYzASpTEBYW + JuD6lStXZP7mzZuYPHkyJk6cKIiOjpZ53aOmxGwfPnwIchroNW3z5s3ywqVLl+Dn54fRo0fLyefMmSPz + NMbJ2LFjZX3UqFHYv3+/zPOOZ6m0HTdunIDR3tHRgdTNW2SdpCQk8YMHD6TPNjU19W0P0MV9+/aV3KVr + ScY0ovqdO3fKGucJnpCb8HT0hpubG7y8vDBy5Ei5Il7DZ191R8qa1XLSw4cPS/DxnXv37uH+/ftYt26d + UcD69etFLRf1Bwi+oKvWwZOYgvb69WuJl7i4OGzYsAEHDhyA3Y+uqKmpwcGDB+UAjInLly/L/rQ1a9YY + BSQnJ+POnTu4ffs27t69K30+yD6F6MIoRhenC2Q08+TLli3D1q1bpY2Pj8d3VjbYs2cPsrOzJeVycnKQ + kJDQFVM7duwwCkhMTERTU5MIYKuLeZ8gHRxfvHhRyFesWCEnpOtnzpwp10ABFMcUZ4zt3r0bubm5IkJV + XWRmZhoFLF++HLdUGWZKEewTuqB3RbHP9GIwTpkyReq8nrYEx70tf5BUYwykpaVJS0Fs6aGMjAyjAKoi + cUNDQ5cQkr5PCMExs8DDw0OCcMKECZKGeq2nuXn5GHqQ0zPoGGtr166Va6LXDfSaxvymSymAOa2LMRWk + gwKYWhTNjAgNDZWaMH78eBFDY9Wz6P29ZBYDl0FI4tWrVyMlJQVLly7F3LlzjQJ4f7zX2tpa1NXViYj6 + +vouQToo4Pz583j16pWk64gRIyTvAwICpGgRtOrqaji5qA9ZSbFEO4kZ6Kyw+pg1xkCvaYsWLZKT8UWC + JZcC2OrQRVAkT9+nTx8MHDhQ6gULFwsUoZvHCF+MDQiClZ0jbBycpLW2d0I/Zxc4uQ6EraMzvrW0XSgC + YmNju+6buHbtGq5fvy4tQQEcs+X904YMGSIxwIrJYGRLIcz7uNgYJCetlOdoVWfOiFDCf5wfvL080b9/ + f6MH5s+fL+49ox6sqqoSEWzPnj0rnmFr2qeX6EIHBwepgATjYfjw4dJ3cXGRNeY6je9wzcfHR67O0dFR + xBroNY3Viy4/ffq0gK6urKwUMA5M+xRGMLJtbGzg7u6OYcOGCVatWiUxxCtlavMzTOOvGL3FZ9naqR+e + hQsXGgXww2B653Q3x+9CjwOCVdDW1hb29vYYNGgQBg8ejJiYGCE0NX4xKY7rBD3Tr18/+V8w0GsfMD9J + fOrUKQEFmPZ1z/AZvU9B6ucS5ubmcHJygqurq9wrW17BAPU7x5bgHOHs7IwePXqgoqJCftPITQGfsjrx + 3rlAMPD0/tWrV3FS/ScS7/YpcN68eTAzM4OVlZWQ8X5JRFEE+xRmbW0tYnk9rBPkJDcFdOdHg7/ldC03 + /qvgV5CgIH6uSdCzZ09YWlrKmC3HPDXHZWVlUsLJRU5yU8DnKn9jWLdZsxlIfxdHjx6VLx7/ExhoJLWw + sJCWY85znc+Rg1zkJDcFfKzQW8FLIUQhTCHU0P/H6NWr1/l35rgn92afXOQkt9hHCp8ofKHwjYLZvwTu + TQ5yKU5N+xNUiLSfSZ3YnAAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAASfSURBVFhH7ZVLTGNVHMY7PqLRnSsTY8yEhXFjXEx0Y8SN + MRNgoKVAX/QFLbRAeZe2tL1QoOUxgBQGihSKwHR4l7Y8ypsZnsNjoBAeA6MTZ+IYjC5cGqOf5+IdYzIb + GVoXxl/y5d5zztdzvn/PzTms//lP0rsSbfEExRje5qN7Lf4B0/3vMRxMxc6pG0c/eeDb06B3U4Cbd2Kb + mOHw0rche+jfLcDhj8NYeVyH/dMh3H3Ugv51JbrucsHYwoPLFfnq4EY6qb4bq9/dwMw3Zkw9MGHxkR2b + 33fBuRDuAMuSX0eDFLZP+zBxUoqJYxPGjg1Y+LoBgcNyOOeTwhdgcKv4HfeSDGtPXJh7WA//CQX/kRH+ + Ywpz39rRPi9G2yRXz9hDT+eiinz1Biw/dsJ7bIb3vhmeAwMCx5Xou6dD8zQ/fNU7l+RXOhbSSeXN8N+v + xPChEQP7xRg6IEGObLgREKF6ip3A2ENP86wc/ZsUxk/qMHBgRP+eEbf29CQAhY5lDRpIAMYaehyzKk7z + mBK+oxr07lNw7xWjZ1cPd9CA7l0d6nwiWEdEHzH20FM7KkXHmo4sXoKuHQNcQT06yZ537mjRMJWKmmHe + 81dvHeL6bL6EKqb5DBV+ifa6V04WK0bHtg7tZGHnVhGcm4Vo3cyH1cNHh0f1NmM/H9oe9s/WAQloWXqF + YIH1AjP0F9ZBCRoXctG2WYSWdS0cG/nkWQAHUbUnBZYm3i+M9Xzo2rh9JjcfjqAZDlKddVAGi1uAMi/3 + MmNh2QbFLeX9UjRu5aFxnWgtD/aVHNhXc3F9UYOSXgHyd95/nbH/c/I6Y/jads7ZJLXLWahZzDhT6ZAU + 5q8EoG4lCWifuUeEqrkMfLGSi9qlHNQt0f5s1K5mg7opgq7tOW9BTQsHlE+OijklymfTUTGvgm1ejarb + maD8ChS6BNA5EoeNXSLUrGSjkgStWsiEjaj6jgaWaTV0nRf48NSN12CcToV5RgnztALUVBpKZpUoJWHK + 59QoGSchnEKY/KmoWFDDMqeChYQsI2NlpJ3v5CGnKS7ATHd+FFVR91R2NopGxDBMpMAwKUdxQAFDQAkj + HWqGBKI1rYKJFglomkon7TTovSnIakq8+KEjrok2KutjkdcnQNG4DNoJOQrHU8h7KrTkqSeBdJOp0AX+ + lH6SBJxRQGVPgMoWX89MczEkVdFx8upYpLmSkOeTINsnRe6oDDl+6Zny/HLk+lPOVDCWgsweIWT18aE9 + chUNcRGRtsjfpE1sZHrFyCTbkuGREJEnaWeRdhYJpxmTQGaNBZ+KVjM/DR2tytaXeVTMD0JbDNL6hUgf + EUE5JCRKJhJBRcLIvkyE0BoXvguHhmv6/HZSaRQkPTzISRBpPx+yAQHkA3wkllwDrzTmM8YaNi4l24Rm + jinqd35bAkRDSUgmF01CXRzYxmi6+leInjmuQ8UlopeI3vhU/rE6Vh8Ntj0Wid0cxBRdxZWr78aTsTcZ + D+0NOU8D0It8EvFhRJnEKQG7jIN4Kv4J3ceMhS0ADf33vkb0FtF7RB8wot/pPnosbFvwFLq6F4no/f67 + 6L6wVR5GWKw/AKiF4yhMyBvPAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALmSURBVFhHtZfPaxNBFMdHs7/GpPtzehS86sGzB7178e7B + P8CLdw9CjlaxIig0YAtaiq3WNglFUCwGT6VUQaEtpRXT7GYFD+KlIvij63thErazr2CT7Be+p3lv3ydv + 9s1O2GHasPwk5iLjluZekCGk6oaTUC4zpsmQ/9Mb0yUB2mawIENIUcXRRwZYAoAdK8gArHPxp2k6p2RY + RlRx9JEByoazv2zQXYh4MC7DMqKKo/sCmNXspEV0ITbF93XGSjL0gKji6L4AqrqdNAwvCwAOzdFrMvSA + qOLovgAwcapgkwCx5W3DQ4/L8J7Uwl33DTAJ27Bm0iPZNtxLMrwntXDXfQM8hW2Y1hwSILTEsgzvSS3c + dd8A6NuFkWSTOJjKXOxHuntWpnSULpr2QAAT2kiyqNNdiKxgUqZ0lC6a9kAA0/Ae3IEufKZGkjs/t1lp + VKblA4DjOAYArw45mNqWuCHT2DzEpgt3PRAA+h4A3AdDwV8qQKw7X+BgMjDvEXQrndf1wAA4jtiFiPuz + GQBwZLlXMO8BxKTzuh4YAMexA6D550gAU7zDvFsQs0hsw8AAaBxHXIuNYIWCaGneeYTEl1bNHQoAjiOu + hbq4TAHAXeE5AmCcmjsUAPxluNaAh8U8CFUAvCvgO4CdwslJ5w4FAB8ql1lkeddVAPRrGFXswkweAGi5 + zEJm+1u89EMF2IXDCg+tirINQwdAxZaoqADomu4m4wCRzssFoGn4p/GDpAJsQRdwHJ+ktiEXAFTbCl6q + AOgZ+IQ/TG1DbgDhCe8iBfAeLjF3U9uQGwDoWMTFJgVRgbGdk9uQJwBr8+AqBfAWLrT4DcG8XAE+MFaE + q/o3FSCEl3FCbkOuAKg2F2MqAPoFjOQz2Ib8AZh3ssnFbxXgE3ThMWxD7gAo+Ms2pwKga3CfPDLAglHc + qxeKzbrurNZ0e6lq2FNV3bkpl0ntGv6ZVcNZWYM/LR917+sGL+7tQFcaXPylARj7BzrmrMNw48QGAAAA + AElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAf2SURBVFhH7ZdnbFTZGYYvUrQp2AaL6oZtwNheM+M+9hSX + GXuap/fiscf2YDCmZYNICKtlFVZRJLQChSIhluxGdHlZBERaRInpZU0xhpiyICCARO8oP5KgN993zDgO + yf4Lmz+x9Ojcc8857/PNuWeKpf///c//du/enUU83blzJzZu3IgNGzYI+HrTpk2CzZs3D7Zbt27Fli1b + RDuU+L2hc+Pr385lFzvZLe3du/fLvr6+vz979gwPHz4UPHr0SLSPHz/GkydP8PTpU/A48/z5c7x48QIv + X77Eq1evBHzN93gsPo/X8FrOGJrJ8Dg72S3t2rXrrzzp7t27uHfvnuD+/fuiffDgwXcWxG1cNvTe20LO + GJrJsIvnsVvi7bh9+zbu3LmDsrIy5ObmIicnB3l5eSgoKIBMJkNpaSkU5QoolUqo1WpotVrU19fDaDQK + +LqmpgYajUbMUSgUKC4ugVwuFxmcxZmczQ52sZPdooBbt26Jm5mZmXC5XLBarXA6nYhM88Ht8iAYCiIU + DKFjbiui0ShisRja29sxf+FszJw5U1y3tcUwa147mpqaEA6HEQgEEZ0egtvtFlmcydnsYBc7RQHbt2/H + zZs3xY3x48dDr9cLLBYLfBEHHE4HvH4v/AEf2jrDCIUahaS5OYqOn8aooBZRVKSxCbGZTSQOwOfzweV0 + IdjsEjlms3kwlx3sYie7pW3btuH69euCUaNGo7ZWizqdDibaWn+TA063Df6wC4GQBy0dYfh9fioihHCw + Ee0dUdqZMMJUVMAfQvO0IDy0Yyy3We3wNjphNplh0Buh0+pENjviPnZLXV1duHbtmrgxmgZNLh3MDh0c + gQZ4mhrQNMuJT7va0DLLh2jMj8Z2LyKxACJtfjS1BQdoDSDc6ke42YtgxE2Fu+EJ2+D2W2F3m2DxGEWm + 2VmH0aMHCmAnuyV+7169elWQPDIZao0aVdUa6I1aBGIWRD+w40/4CNE5LkQ63XB57fRY7PRcHWhs9cLh + oF2ia6vdhiCJebvN5gbU03bbvCZodVrUVNdApVJBpVQhOTl50MduiT8wLl26JEhMGIGKigoqQA29RYdg + RwNWdkdxCh/i0x3NaJ5tpwIaYHOYSWgVQoutARarBSazCe6wBQajnuR1QtzgrhMvRqMmuaoSCspOSkwa + 9LFb4k+mS5cu4iKRmJCAsopiKGsUMNg0CMzR48DrBfjt3lbsuP8BInPssPkMaHAQVgMCLVZY7EaY6Fpv + 0sMVosNm1EGrr0KtrpoK0KGqRg2VphLllWUoLS9BQuJw4WInu6X169fjwoULuNh/AYkjh6POroA1qIZn + Rh0WrfOgGz+DL1aPXvwS0xZaEJhhgi9qgr/NgI4PnTRmhKfZgGDrQN8fM8HbQrsRMcFD80z+Kph9Ghjc + SmittAMjE4WLneyWvvjidzjXdw69fWcxIjkBSm0Rqs2lMHsr8Pv+Fvxmhx/2SBW6bnXi19tCcIZ0sIV1 + iC204hwWY/oiG+xNtWhd8M++o7kW9nAdFVuPekcldFYF1PVFqKguxIhRicLFTnZTAZ/T53Ivzvadxqix + SbiPT3AHH+MmHbxv6dkHZ2hhi2iweLMHf3g6D67WaninabHr3ixs+bYTu/8yj/o1/9b/6nYnruNX+DPl + cB7zAEswatxI4WInu6V16z7DmbOncab3ND2Cn6BcLRPVVplLYAqUQaMvRo2lFNaIkt4Ni2BtVGLuMiu6 + X89HoLMOX7+ajdUnm/HHIf01p6M4hPnwd9SiykTrTaVQ6QpRRtkJ5GAXO9ktrV37Gb7p+Qanek5ieOKP + afuLUGmQQVknR2XtVFRSW20rRENEgS8fT8eizx3Yj7n4xVp6n7dXYdpHevRgARZvcA32T+HnmPGJkXaO + Tr+hEEq9HErK5Gx2sIud7JbWrFmDkydP4ATx3g9/gJy8yZhC5OROQomqgL5EslFQlIPy2gJ83GXFAczB + uv4IHahCmMLlqNDJYAiUQmsvGuybGstRqnofVZZCkZWbnzOQSbCDXexktyjgxIkTOH78OIYNG4bsidnI + zspEFiEvy8WEzAm0cCLkijxYW8rQT+8GW5sCpZo8qPQy5MsnC3hOYWUesidlEZSRnQlZeS6yqOUszuRs + drCLnaKA1atX49ixYwL6gYT09HSkpaYhlSgomoT0lIw3RWRBVV+AwHwN5OX01ZpPRVVMwYQJmcjImICM + 1HRMpULS0jOQlpYmyKf1qdRyFmdyNjviPnZLK1euxJEjRwQ8mF88EbnyTMEU2QDvl2TR/SzIKiZCVjZJ + tPnF2cijsTx5FnKLCBkRX8PtG+JZDGezI+5jtyjg8OHDAh5MSUnBuHHjBBzALd9LSRlPryiTXlEK0jJS + RT+X5OPGD8wdOv+7+pzDjrhPFLBixQocOnRIwIO8TfyNxUwqyBi8Hjt2NCZPzcSYMWOIscS/jr89/z/1 + 448g7mO3tHz5chw4cADd3d1ISkoSE94l7GAXO9ktCjh48KCAqzp69Kg4oT09PThz5gx6e3tx/vx59Pf3 + 4/Lly7hy5crg74cbN24I4t/vPMZzeC6v4bWcwVmcydnsiPtEAcuWLfsbn8j9+/dj37593wvsYie7pSVL + lnxN/zy85kPBg3v27HmnsINd7GS3RD8aa1etWiUOxNKlS78X2MVOdtO5kJKJEqKB8BH+N/D1f5Ohuexi + J7ulYcSPiJHEWCKFSH1HcDY72EVOadg/ANIxAuUaGiw0AAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAWfSURBVFhH7ZZLSFdbFMYPSHTRyjRNMx9ZqT3MXmplD80e + vspHT8tHggqVUhBBcBFBhCZaUNGghAY5KhoY0UBJSEszSa2JA8EsmkTkQAQVNFfnt/5ny7Hk3jsouIM2 + fJx99lp7feustfbax/oz/oz/xZg/f35vYmKibNu2TXbt2iV79uyR3bt3y86dO8Xb21sSEhIE+Y4dO2aw + ZcsWiYqK0vn27dsV6G3dulXCw8Nl06ZNkpSUpDawZXS8vLzUlk3b62G3x+rVq2V4eFgVU1NTdVNRUZGY + 8enTJ6mpqZH6+nq5ffu2PH361JGIDA0Nyb179+TOnTty69Yt6e3tdSQi169flzNnzsiJEyckPT1dBgYG + HIkInA69Dl1MSUmR7u5uKS4uluTkZPX0/fv3MjIyIpcvX5YVK1bIhg0bFJWVlfL582f58OGDfnlsbKyu + r1+/Xh1B1tfXJ2FhYbJy5UqJjIyUNWvWSGtrq3LB6aG2R2BgoExMTEh8fLycOnVKCgsLJT8/X53YuHGj + dHR06Kbjx49LSEiIhIaGyvLly6W5uVnXx8fHlXjZsmWKiIgI+fr1q8o6OzvF399f/Pz8FAcOHJCxsTGB + 06G3rJiYmK4FCxaohxkZGXLw4EFVJGzkEjJbTRYvXiyLFi2aBdapE19f31lYuHChypYsWaLACeOIj4+P + wAm3DkLHCAgI0OLavHmzhpWQr1q1SkZHR1V+/vx5dSwtLU0d/fjxo64zjh49qg7jfF5enrMq0t/fr4VN + sZLSsrIyXYfTodehi0FBQfLo0SO8U08J65cvX2RqakouXryo7+SaArpx44bKBgcH1RlTG+Sb1FC4z549 + 07Xo6GjdQzrfvHmjXHB6qO0RHBw8zdeQW3JDyCiayclJVX7y5InYOpp/cnzs2DFdZ1y5ckVTxF7kOGYG + X7506dIZ9PT06Pq3b9+wN+3QW5Yd5inyy1ebXOEEubTFP+UXXdbBjzVhZPPmzdO5G9g1e+C0555BaHJz + cyUzM1MOHTokhw8flpycHM3ryZMnZ04Gx7OkpERKS0ulvLxczp07p2DOGjJ0CgoKdA97jxw5oraxh13q + hHc4HXpPI9q/f7/U1tZqs7l06ZI8fPhQsrOzVRkjHEHjDAQ0KsgAczcpKTLEkGZlZc2cLnjArEZEvmlC + nPfHjx9rzjm/r1+/1qIBdDjw9u1beffunT7dYI3GQ56B2YeNV69eKbD/8uVL5YLTobcsjhtNBwG9IC4u + Tu8Fejn3AmkhhBwv0sIXEhFaLE+zxhMdE3Lz5Rxbji9tHg644HToLYsqpv9TwfT8qqoqrW5yW1dXJ42N + jZo7jOEMht1P9xwdN+m+fftk7969SspdYy4op7l5BseHm6q9vV3JHjx4IE1NTZoKLh5CBwgjIe3q6voJ + yMyT9AH2vHjxQtHW1qZ4/vy5csHp0FsWDYhrlO5H6Ola5holBYSNryCEfBFPCok5YO6Wocse9gK+GpvY + Nlc2nA69ZdGCab/0fVoxlxKKbDLOYITGYpzi6YZZQ8eE2U2KTWzDARecDr3HAQScTQOU8NQ4gyFCZyLE + HCLA3JAxp+cbUmxgy20brlkO0PWofPq2udfdcG9ED2DYOGhITBTZY+zNBWRwOvSeIkRw8+ZNqaiokKtX + r6ojbnARXbt2Tc6ePSunT5+W6upqWbduna7zNOAEXbhwQf+GfrRhANesIuSiwVBLS4s0NDTobTYX+PUC + 9+/fn1MOkN+9e3dOGYADLjgdesuLily7dq02oX8Cm+dad+O/6MDlnAIvHPDnhdD8mxO/wgE44HIc8MeB + UPuunrRb4zRCfkb4gfgdwDYccMEJNw4E2v90f5sfEfM/8LsAB1xwwo0DPjZibGTYKLBRbKPQmf9KYBPb + zOGCE24df9nwtRFkI8xG+G8CtuGAy+a0rO/+JNNA0Q6kqwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + 322, 17 + + + 459, 56 + + + 673, 17 + + + 1050, 17 + + + 372, 56 + + + 813, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u + ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u + PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB + AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLkRvdWJsZQMAAAAGX2l0 + ZW1zBV9zaXplCF92ZXJzaW9uBwAABggIAgAAAAkDAAAAAAAAAAAAAAAPAwAAAAAAAAAGCw== + + + + 650, 56 + + + 650, 56 + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHISURBVDhPrZDfS1NhGMf7f6Sb8A8IuwvEguqiGyF/lEFZ + usbUgsUcYxynzGNNPLN0c26xyXRpiIHo5o6xFmGtcl2IN9oQXEs3qSQ/9R5MZeckCH3guXu+n+f7vqf+ + K8XSDslUmuFQBEd3H3aXm8GRIHH1FdvFIvtrxuQ2NgiEo4RjU2Q+LrO1ta3Nu8yHP8Iw3iE/X3I5Y4lY + FOHZRJJyfuzuUSj9IjQ+jUfxatL92CGitrhczt/wWn6Xz+s/keRB4omEXiAqitpHKQ+/XfmOf0KlX1H0 + ArtL1qoJ2ruDWLoC3LU/5cZ9D7WtPVy+6WDh0w4xdZ22jna9wCb1HAjuOX3ceqhQZ5G52ixxsdHG+doH + vFwqEYmvYW6z6AVeX4Cl9xnD2uKyCE+9KfJodI5euVcvmE+qDI8+OzYsxmx1MTkZ1QsKhW8MPBkiGH3x + z3Cne4SqKy1ElDt6gWBldZW+/gGcbgXfeFL7MPFmUdts7eLspdu4rTV8XXYQ83cYSzbzeaZnZnBKEg1N + 17nWUIet00ZkLKxNVeVpVE+FJgk9bjKWHEc6nabmQvWBJCDXn1ySep3SJM9dZzA1nju5QJDNZjGZWlhc + VPkN8D3f8pYPr2wAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHbSURBVDhPrZLfS1NxGMb7f6Kb6A8Iu4lALKgughA0TYVl + 2RLpByzmGOPsB2PGyrlS5zZzi6k1kSUS5o62ipitki62iOZd8zgzKqlPvYc6rM4KhB54787zeZ7vw9n1 + X6VtVMnmnjAynsTpHcDh8RMei7OgLrOuafz8rL7evisTTaRITKcpvFylWt3Ub6Xw4gcwwdBwhGLpTX2I + JIt5/mGWP/V5+xva1lfGJ2cJhoZ4X6mYIVJbkmt10RvXT8zlyjav176gBMJk5ubMAKkotWsl5guuUcP8 + rPiJyJSK4vWaAQ5PQH/vL2OfO8o5xy06LgdpPu/jWJeTxVcfmVbX6OjqNAPsis8ASKrlaojWvgAnuhWO + tNs51HyF+/ktkgtlLGe7zYBwJEb+ecEYTGpLamOLTU8Wc/rpB67FHqC4FTNgcfkRI7Hbvw0mqQdPXjLM + cr02D6nUhBmgaRsM3hwmnpoxBqtNluv3j9FwvIeJGxYzQFQslRi4PojLH2J0MqsPJm+W2r02N/uPnsFv + a2J91cn8lK8+RH6S2UwGl6LQ1nmalrZW7P12kncSpGfu0bBvD2pwtw75a5N/Kb+Sp+lwowGJBk7tHJJ7 + nNMhdz17sbYf2DlAJHtZrT0sLal8B8x71HTDfCJyAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACiSURBVDhPYxgFmKB389//XRt+/c+e/PATNj5BAFJ89eGf + /7qhq/5j4xMEbWu//b/19Pd/Vb9FYA3ofIKgccXn/5cf/v4v5zYLrAGdTxDULn7//8T13//F7CaBNaDz + CYKKea/+777w8z+/WTdYAzqfICiZ/fz/+pM//3MatII1oPMJgoLpj/8v2PP5P6tOI1gDOp8gAMU3m24T + XAM6f9gBBgYAkeCWT284Yq8AAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAD2SURBVDhPY8AGQlf9Z4YyyQMpHY9l6uv/M0G5pIPCWc// + J077oES2Ibkzn/1P6L73P37Saw2yvJMx5en/eft//w9quPk6ofOpLcmGJPQ8+T9736//nVv//ncrvfw/ + sfeRPUmGRHY9+j9l26//JUv//k+Y/ve/Te5Z0gwJbH74v3Xte7Bm45Iv/6Wjr/03jlz236HgdDxRhnhU + 3f9fMvcdXLOiS89/Ge+VgVBpwsC+9O7/wJZncM3S3iu8oFLEAYu8O/9tCq6ANUv6rLKBChMPDLNuQzR7 + LnOFCpEGdNJu/JfyWeML5ZIOpLzX+gFzFOkpcAAAAwMAylWGggwmxE0AAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJcSURBVDhPnZLbTxNBGMX5j3zyf/CSGBNjTIwxSk00BqMx + GC+kpqIhKKkYNbSlF3oBWloKtHhLKVjQXh54McYHH6A2lBIQW+htt9vuHL+ZBbr10UlOdjPffL+Zc2a6 + fNEMfJE0vFESfT2RFK69KggZhjV1v9wkFeCaXoFTaBmOUAKO4Gd0eSMZ/Dt4U/y7iugqgzWuwhSUcaw7 + A8ZYh46fNGgA/WS9wXCVdpxfVRFIMrz+0ITR3wloNBm+fiscAtIdgIrMcMWcx1RKhWuJwfyuiUfjkgDI + CoNCzXyTNmAuJRp5sUrNxSrD5aE83AkV1gUVLyIK7nvrAlCWtHUV+h4BXOEv8BDEFV6BnUKx+uO49DwP + GzWPxFoYmGmg160BJqMpjAaWSIuw+RfbAD4kInM63+Xi4AYsMRVvPrbQH5Jxx6UBWipDs8WwX9edwH0A + UKmoULFEFi4MaIBh8m8MSLjlqAqASla5/8KeHjCTFABOl6i4U2Y4/yyHt59aGIpQgBMSeuwagJ9wt8KQ + +6MDeOY0QE1WUaRiYQ8415+j6yP/YQX3PHXctFUEgIf3uwys7UB3C7NJ8cIcwYQIxzIRw1nTL5jnm3hC + D+juWA03rBog+D5N9QWxZmQ81g5R3D/R+RVulYAzj7MYnFXQNynhtpMAFg1QlUEnoDX6DFz0rjmgVOP+ + gdwucNqYxdPpBh746hRgDdcPAIUSwwb5z+otOEPLIt3tfYZ8UfN3qm8dpilZ+O8ZrR4B1rYZfm4BPzZ1 + AO6dp88nDnXi4bp4/73uWgdAv4ZLAOwE4D//JwP+Am/6K+qXWlDMAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEsSURBVDhPYxh8YM6WCf+X7Z/hAeXCAS5xDDB5Vef/lunV + /2es70mBCoEBLnEM0LOw6f+Oh0sxFOMSZ1i0Z+p/kPNANoAUtcyo+b/76Yr/0443gBVPXdPZBBQ/gy4O + NwSk+eTHLf+PvFv3f/+rVf93Plnyf9uDxf97Dpb9b9iUC1a84cp8rOLTN/Ymg/127P3G/2sfTf6/+Eb3 + /xlnGyGKtub8L1mV9D9lUtj/9LIEnOJgv+17ufJ/2+bi/7Wrsv6XLEj6nzU9CqzIr9z5v4yS9P+0jkis + 4iaOJkEMIL8payv91zHT/m/qYPzfxtPqf0JvIFyRvpVuk4md8Rl0cRMnE19wGKCD+kkVWBXhEscAIIUg + RSp6KiiKcIljAJBCXXNdYygXDnCJD3nAwAAAPZ0MvaekYv4AAAAASUVORK5CYII= + + + + 941, 56 + + + 17, 95 + + + 354, 95 + + + 510, 95 + + + 647, 95 + + + 167, 56 + + + 1095, 56 + + + 437, 17 + + + 171, 95 + + + 17, 56 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2 + CAAAAk1TRnQBSQFMAgEBAgEAAbgBJwG4AScBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA + AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 + AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA + AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm + AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM + AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA + ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz + AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ + AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM + AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA + AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA + AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ + AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/ + AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA + AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm + ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ + Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz + AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA + AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM + AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM + ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM + Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA + AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM + AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ + AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz + AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm + AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw + AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/xEAEHUwABB1MAAQdSQA + AewB9AQAAewB9AQABHUB7AV1AewFdSQAAewBDwHyAwAB7AEPAfIDAAR1AewBDwR1AewBDwR1JAAB7AFJ + AQ8B8gIAAewBSQEPAfICAAR1AewBSQEPA3UB7AFJAQ8DdSAAAewBEQFDARUBFAFyAUkBDwEHAesBFAFy + AUkBDwHyAQAB7AERAUMBFQEUAXIBSQEPAQcB6wEUAXIBSQEPAnUgAAHtAQgBeARyAUkBDwRyAUkBDwHy + Ae0BCAF4BHIBSQEPBHIBSQEPAXUgAAGSAQgDmAJ4AnIBbQGYAngCcgFtAZIBCAOYAngCcgFtAZgCeAJy + AW0gAAEcAcIECAJ4AewBmQIIAngB7AHzARwBwgQIAngB7AGZAggCeAHsAXUgAAGYARwBkgHtAewBCAGY + AewB8AHvAewBCAGYAewB8wEAAZgBHAGSAe0B7AEIAZgB7AHwAe8B7AEIAZgB7AJ1JAAB7QEIAewB8wIA + Ae0BCAHsAfMCAAR1Ae0BCAHsA3UB7QEIAewDdSQAAZIB7AHzAwABkgHsAfMDAAR1AZIB7AR1AZIB7AR1 + JAABHAH0BAABHAH0BAAEdQEcBXUBHAV1MAAQdTAAEHUgAAFCAU0BPgcAAT4DAAEoAwABQAMAARADAAEB + AQABAQUAAYAXAAP/AQAC/wYAAv8GAAL/BgAB8wHPBgAB8QHHBgAB8AHDBwABAR8AAQEGAAHwAcMGAAHx + AccGAAHzAc8GAAL/BgAC/wYACw== + + + + 783, 95 + + + 916, 95 + + + 115 + \ No newline at end of file diff --git a/src/Forms/MatroskaSubtitleChooser.Designer.cs b/src/ui/Forms/MatroskaSubtitleChooser.Designer.cs similarity index 98% rename from src/Forms/MatroskaSubtitleChooser.Designer.cs rename to src/ui/Forms/MatroskaSubtitleChooser.Designer.cs index 2b8548acb..1d4ad68b3 100644 --- a/src/Forms/MatroskaSubtitleChooser.Designer.cs +++ b/src/ui/Forms/MatroskaSubtitleChooser.Designer.cs @@ -1,182 +1,182 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class MatroskaSubtitleChooser - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.listBox1 = new System.Windows.Forms.ListBox(); - this.labelChoose = new System.Windows.Forms.Label(); - this.listView1 = new System.Windows.Forms.ListView(); - this.columnHeaderTrack = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderLanguage = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderCodec = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderDefault = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderForced = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.BackColor = System.Drawing.SystemColors.Control; - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(491, 302); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 46; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = false; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(410, 302); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 45; - this.buttonOK.Text = "OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // listBox1 - // - this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listBox1.FormattingEnabled = true; - this.listBox1.Location = new System.Drawing.Point(12, 43); - this.listBox1.Name = "listBox1"; - this.listBox1.Size = new System.Drawing.Size(554, 251); - this.listBox1.TabIndex = 47; - this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged); - this.listBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listBox1_KeyDown); - this.listBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listBox1_MouseDoubleClick); - // - // labelChoose - // - this.labelChoose.AutoSize = true; - this.labelChoose.Location = new System.Drawing.Point(9, 20); - this.labelChoose.Name = "labelChoose"; - this.labelChoose.Size = new System.Drawing.Size(224, 13); - this.labelChoose.TabIndex = 48; - this.labelChoose.Text = "More than one subtitle found - please choose"; - // - // listView1 - // - this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderTrack, - this.columnHeaderName, - this.columnHeaderLanguage, - this.columnHeaderCodec, - this.columnHeaderDefault, - this.columnHeaderForced}); - this.listView1.FullRowSelect = true; - this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.listView1.HideSelection = false; - this.listView1.Location = new System.Drawing.Point(13, 43); - this.listView1.MultiSelect = false; - this.listView1.Name = "listView1"; - this.listView1.Size = new System.Drawing.Size(553, 253); - this.listView1.TabIndex = 49; - this.listView1.UseCompatibleStateImageBehavior = false; - this.listView1.View = System.Windows.Forms.View.Details; - this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged); - this.listView1.DoubleClick += new System.EventHandler(this.listView1_DoubleClick); - this.listView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listView1_KeyDown); - // - // columnHeaderTrack - // - this.columnHeaderTrack.Text = "Track#"; - // - // columnHeaderName - // - this.columnHeaderName.Text = "Name"; - this.columnHeaderName.Width = 180; - // - // columnHeaderLanguage - // - this.columnHeaderLanguage.Text = "Language"; - // - // columnHeaderCodec - // - this.columnHeaderCodec.Text = "Codec"; - this.columnHeaderCodec.Width = 100; - // - // columnHeaderDefault - // - this.columnHeaderDefault.Text = "Default"; - // - // columnHeaderForced - // - this.columnHeaderForced.Text = "Forced"; - // - // MatroskaSubtitleChooser - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(579, 329); - this.Controls.Add(this.labelChoose); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.listBox1); - this.Controls.Add(this.listView1); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(400, 250); - this.Name = "MatroskaSubtitleChooser"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Choose subtitle from Matroska file"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormMatroskaSubtitleChooser_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.ListBox listBox1; - private System.Windows.Forms.Label labelChoose; - private System.Windows.Forms.ListView listView1; - private System.Windows.Forms.ColumnHeader columnHeaderTrack; - private System.Windows.Forms.ColumnHeader columnHeaderName; - private System.Windows.Forms.ColumnHeader columnHeaderLanguage; - private System.Windows.Forms.ColumnHeader columnHeaderCodec; - private System.Windows.Forms.ColumnHeader columnHeaderDefault; - private System.Windows.Forms.ColumnHeader columnHeaderForced; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class MatroskaSubtitleChooser + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.listBox1 = new System.Windows.Forms.ListBox(); + this.labelChoose = new System.Windows.Forms.Label(); + this.listView1 = new System.Windows.Forms.ListView(); + this.columnHeaderTrack = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderLanguage = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderCodec = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderDefault = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderForced = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.BackColor = System.Drawing.SystemColors.Control; + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(491, 302); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 46; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = false; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(410, 302); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 45; + this.buttonOK.Text = "OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // listBox1 + // + this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listBox1.FormattingEnabled = true; + this.listBox1.Location = new System.Drawing.Point(12, 43); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(554, 251); + this.listBox1.TabIndex = 47; + this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged); + this.listBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listBox1_KeyDown); + this.listBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listBox1_MouseDoubleClick); + // + // labelChoose + // + this.labelChoose.AutoSize = true; + this.labelChoose.Location = new System.Drawing.Point(9, 20); + this.labelChoose.Name = "labelChoose"; + this.labelChoose.Size = new System.Drawing.Size(224, 13); + this.labelChoose.TabIndex = 48; + this.labelChoose.Text = "More than one subtitle found - please choose"; + // + // listView1 + // + this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderTrack, + this.columnHeaderName, + this.columnHeaderLanguage, + this.columnHeaderCodec, + this.columnHeaderDefault, + this.columnHeaderForced}); + this.listView1.FullRowSelect = true; + this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.listView1.HideSelection = false; + this.listView1.Location = new System.Drawing.Point(13, 43); + this.listView1.MultiSelect = false; + this.listView1.Name = "listView1"; + this.listView1.Size = new System.Drawing.Size(553, 253); + this.listView1.TabIndex = 49; + this.listView1.UseCompatibleStateImageBehavior = false; + this.listView1.View = System.Windows.Forms.View.Details; + this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged); + this.listView1.DoubleClick += new System.EventHandler(this.listView1_DoubleClick); + this.listView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listView1_KeyDown); + // + // columnHeaderTrack + // + this.columnHeaderTrack.Text = "Track#"; + // + // columnHeaderName + // + this.columnHeaderName.Text = "Name"; + this.columnHeaderName.Width = 180; + // + // columnHeaderLanguage + // + this.columnHeaderLanguage.Text = "Language"; + // + // columnHeaderCodec + // + this.columnHeaderCodec.Text = "Codec"; + this.columnHeaderCodec.Width = 100; + // + // columnHeaderDefault + // + this.columnHeaderDefault.Text = "Default"; + // + // columnHeaderForced + // + this.columnHeaderForced.Text = "Forced"; + // + // MatroskaSubtitleChooser + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(579, 329); + this.Controls.Add(this.labelChoose); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.listBox1); + this.Controls.Add(this.listView1); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(400, 250); + this.Name = "MatroskaSubtitleChooser"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Choose subtitle from Matroska file"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormMatroskaSubtitleChooser_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.Label labelChoose; + private System.Windows.Forms.ListView listView1; + private System.Windows.Forms.ColumnHeader columnHeaderTrack; + private System.Windows.Forms.ColumnHeader columnHeaderName; + private System.Windows.Forms.ColumnHeader columnHeaderLanguage; + private System.Windows.Forms.ColumnHeader columnHeaderCodec; + private System.Windows.Forms.ColumnHeader columnHeaderDefault; + private System.Windows.Forms.ColumnHeader columnHeaderForced; + } } \ No newline at end of file diff --git a/src/Forms/MatroskaSubtitleChooser.cs b/src/ui/Forms/MatroskaSubtitleChooser.cs similarity index 97% rename from src/Forms/MatroskaSubtitleChooser.cs rename to src/ui/Forms/MatroskaSubtitleChooser.cs index 2ffa511f3..4d5a69f10 100644 --- a/src/Forms/MatroskaSubtitleChooser.cs +++ b/src/ui/Forms/MatroskaSubtitleChooser.cs @@ -1,126 +1,126 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; -using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4.Boxes; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class MatroskaSubtitleChooser : Form - { - public MatroskaSubtitleChooser(string fileType) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = fileType.Equals("mp4", StringComparison.Ordinal) ? Configuration.Settings.Language.MatroskaSubtitleChooser.TitleMp4 : Configuration.Settings.Language.MatroskaSubtitleChooser.Title; - labelChoose.Text = Configuration.Settings.Language.MatroskaSubtitleChooser.PleaseChoose; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - } - - public int SelectedIndex { get; private set; } - - internal void Initialize(List subtitleInfoList) - { - listBox1.Visible = false; - listView1.Visible = true; - var format = Configuration.Settings.Language.MatroskaSubtitleChooser.TrackXLanguageYTypeZ; - foreach (var info in subtitleInfoList) - { - AddListViewItem(info); - } - listView1.Items[0].Selected = true; - listView1.FocusedItem = listView1.Items[0]; - } - - private void AddListViewItem(MatroskaTrackInfo info) - { - var item = new ListViewItem(info.TrackNumber.ToString()); - item.SubItems.Add(info.Name); - item.SubItems.Add(info.Language); - item.SubItems.Add(info.CodecId); - item.SubItems.Add(info.IsDefault.ToString(CultureInfo.InvariantCulture)); - item.SubItems.Add(info.IsForced.ToString(CultureInfo.InvariantCulture)); - listView1.Items.Add(item); - } - - internal void Initialize(List mp4SubtitleTracks) - { - listBox1.Visible = true; - listView1.Visible = false; - int i = 0; - foreach (var track in mp4SubtitleTracks) - { - i++; - string handler = (track.Mdia.HandlerType + " " + track.Mdia.HandlerName).Trim(); - if (handler.Length > 1) - { - handler = " - " + handler; - } - - string s = $"{i}: {track.Mdia.Mdhd.Iso639ThreeLetterCode} - {track.Mdia.Mdhd.LanguageString}{handler}"; - listBox1.Items.Add(s); - } - listBox1.SelectedIndex = 0; - } - - private void FormMatroskaSubtitleChooser_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void ButtonOkClick(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void listView1_SelectedIndexChanged(object sender, EventArgs e) - { - if (listView1.SelectedItems.Count > 0) - { - SelectedIndex = listView1.SelectedItems[0].Index; - } - } - - private void listBox1_SelectedIndexChanged(object sender, EventArgs e) - { - SelectedIndex = listBox1.SelectedIndex; - } - - private void listView1_DoubleClick(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void listView1_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - DialogResult = DialogResult.OK; - } - } - - private void listBox1_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - DialogResult = DialogResult.OK; - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.ContainerFormats.Matroska; +using Nikse.SubtitleEdit.Core.ContainerFormats.Mp4.Boxes; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class MatroskaSubtitleChooser : Form + { + public MatroskaSubtitleChooser(string fileType) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = fileType.Equals("mp4", StringComparison.Ordinal) ? Configuration.Settings.Language.MatroskaSubtitleChooser.TitleMp4 : Configuration.Settings.Language.MatroskaSubtitleChooser.Title; + labelChoose.Text = Configuration.Settings.Language.MatroskaSubtitleChooser.PleaseChoose; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + } + + public int SelectedIndex { get; private set; } + + internal void Initialize(List subtitleInfoList) + { + listBox1.Visible = false; + listView1.Visible = true; + var format = Configuration.Settings.Language.MatroskaSubtitleChooser.TrackXLanguageYTypeZ; + foreach (var info in subtitleInfoList) + { + AddListViewItem(info); + } + listView1.Items[0].Selected = true; + listView1.FocusedItem = listView1.Items[0]; + } + + private void AddListViewItem(MatroskaTrackInfo info) + { + var item = new ListViewItem(info.TrackNumber.ToString()); + item.SubItems.Add(info.Name); + item.SubItems.Add(info.Language); + item.SubItems.Add(info.CodecId); + item.SubItems.Add(info.IsDefault.ToString(CultureInfo.InvariantCulture)); + item.SubItems.Add(info.IsForced.ToString(CultureInfo.InvariantCulture)); + listView1.Items.Add(item); + } + + internal void Initialize(List mp4SubtitleTracks) + { + listBox1.Visible = true; + listView1.Visible = false; + int i = 0; + foreach (var track in mp4SubtitleTracks) + { + i++; + string handler = (track.Mdia.HandlerType + " " + track.Mdia.HandlerName).Trim(); + if (handler.Length > 1) + { + handler = " - " + handler; + } + + string s = $"{i}: {track.Mdia.Mdhd.Iso639ThreeLetterCode} - {track.Mdia.Mdhd.LanguageString}{handler}"; + listBox1.Items.Add(s); + } + listBox1.SelectedIndex = 0; + } + + private void FormMatroskaSubtitleChooser_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void ButtonOkClick(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void listView1_SelectedIndexChanged(object sender, EventArgs e) + { + if (listView1.SelectedItems.Count > 0) + { + SelectedIndex = listView1.SelectedItems[0].Index; + } + } + + private void listBox1_SelectedIndexChanged(object sender, EventArgs e) + { + SelectedIndex = listBox1.SelectedIndex; + } + + private void listView1_DoubleClick(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void listView1_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + DialogResult = DialogResult.OK; + } + } + + private void listBox1_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + DialogResult = DialogResult.OK; + } + } + } +} diff --git a/src/Forms/MatroskaSubtitleChooser.resx b/src/ui/Forms/MatroskaSubtitleChooser.resx similarity index 97% rename from src/Forms/MatroskaSubtitleChooser.resx rename to src/ui/Forms/MatroskaSubtitleChooser.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/MatroskaSubtitleChooser.resx +++ b/src/ui/Forms/MatroskaSubtitleChooser.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/MeasurementConverter.Designer.cs b/src/ui/Forms/MeasurementConverter.Designer.cs similarity index 98% rename from src/Forms/MeasurementConverter.Designer.cs rename to src/ui/Forms/MeasurementConverter.Designer.cs index 68dbd8fab..c38a23a7d 100644 --- a/src/Forms/MeasurementConverter.Designer.cs +++ b/src/ui/Forms/MeasurementConverter.Designer.cs @@ -1,205 +1,205 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class MeasurementConverter - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.listBoxCategory = new System.Windows.Forms.ListBox(); - this.labelConvertFrom = new System.Windows.Forms.Label(); - this.comboBoxFrom = new System.Windows.Forms.ComboBox(); - this.textBoxInput = new System.Windows.Forms.TextBox(); - this.labelConvertTo = new System.Windows.Forms.Label(); - this.comboBoxTo = new System.Windows.Forms.ComboBox(); - this.textBoxResult = new System.Windows.Forms.TextBox(); - this.linkLabel1 = new System.Windows.Forms.LinkLabel(); - this.checkBoxCloseOnInsert = new System.Windows.Forms.CheckBox(); - this.buttonInsert = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // listBoxCategory - // - this.listBoxCategory.FormattingEnabled = true; - this.listBoxCategory.ItemHeight = 16; - this.listBoxCategory.Location = new System.Drawing.Point(10, 10); - this.listBoxCategory.Name = "listBoxCategory"; - this.listBoxCategory.Size = new System.Drawing.Size(106, 170); - this.listBoxCategory.TabIndex = 0; - this.listBoxCategory.SelectedIndexChanged += new System.EventHandler(this.listBoxCategory_SelectedIndexChanged); - this.listBoxCategory.LostFocus += new System.EventHandler(this.listBoxCategory_LostFocus); - // - // labelConvertFrom - // - this.labelConvertFrom.AutoSize = true; - this.labelConvertFrom.Location = new System.Drawing.Point(124, 32); - this.labelConvertFrom.Name = "labelConvertFrom"; - this.labelConvertFrom.Size = new System.Drawing.Size(89, 17); - this.labelConvertFrom.TabIndex = 1; - this.labelConvertFrom.Text = "Convert from:"; - // - // comboBoxFrom - // - this.comboBoxFrom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxFrom.FormattingEnabled = true; - this.comboBoxFrom.Location = new System.Drawing.Point(127, 54); - this.comboBoxFrom.Name = "comboBoxFrom"; - this.comboBoxFrom.Size = new System.Drawing.Size(132, 24); - this.comboBoxFrom.TabIndex = 2; - this.comboBoxFrom.SelectedIndexChanged += new System.EventHandler(this.comboBoxFrom_SelectedIndexChanged); - // - // textBoxInput - // - this.textBoxInput.Location = new System.Drawing.Point(127, 86); - this.textBoxInput.Name = "textBoxInput"; - this.textBoxInput.Size = new System.Drawing.Size(132, 22); - this.textBoxInput.TabIndex = 3; - this.textBoxInput.TextChanged += new System.EventHandler(this.textBoxInput_TextChanged); - this.textBoxInput.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBoxInput_KeyPress); - this.textBoxInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBoxInput_KeyUp); - // - // labelConvertTo - // - this.labelConvertTo.AutoSize = true; - this.labelConvertTo.Location = new System.Drawing.Point(264, 32); - this.labelConvertTo.Name = "labelConvertTo"; - this.labelConvertTo.Size = new System.Drawing.Size(56, 13); - this.labelConvertTo.TabIndex = 4; - this.labelConvertTo.Text = "Convert to:"; - // - // comboBoxTo - // - this.comboBoxTo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxTo.FormattingEnabled = true; - this.comboBoxTo.Location = new System.Drawing.Point(267, 54); - this.comboBoxTo.Name = "comboBoxTo"; - this.comboBoxTo.Size = new System.Drawing.Size(132, 24); - this.comboBoxTo.TabIndex = 5; - this.comboBoxTo.SelectedIndexChanged += new System.EventHandler(this.comboBoxTo_SelectedIndexChanged); - // - // textBoxResult - // - this.textBoxResult.Location = new System.Drawing.Point(267, 86); - this.textBoxResult.Name = "textBoxResult"; - this.textBoxResult.ReadOnly = true; - this.textBoxResult.Size = new System.Drawing.Size(132, 22); - this.textBoxResult.TabIndex = 6; - // - // linkLabel1 - // - this.linkLabel1.Location = new System.Drawing.Point(218, 112); - this.linkLabel1.Name = "linkLabel1"; - this.linkLabel1.Size = new System.Drawing.Size(181, 23); - this.linkLabel1.TabIndex = 7; - this.linkLabel1.TabStop = true; - this.linkLabel1.Text = "Copy to clipboard"; - this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.TopRight; - this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); - // - // checkBoxCloseOnInsert - // - this.checkBoxCloseOnInsert.AutoSize = true; - this.checkBoxCloseOnInsert.Location = new System.Drawing.Point(127, 158); - this.checkBoxCloseOnInsert.Name = "checkBoxCloseOnInsert"; - this.checkBoxCloseOnInsert.Size = new System.Drawing.Size(83, 17); - this.checkBoxCloseOnInsert.TabIndex = 8; - this.checkBoxCloseOnInsert.Text = "Close on insert"; - this.checkBoxCloseOnInsert.UseVisualStyleBackColor = true; - // - // buttonInsert - // - this.buttonInsert.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonInsert.DialogResult = System.Windows.Forms.DialogResult.Yes; - this.buttonInsert.Location = new System.Drawing.Point(245, 155); - this.buttonInsert.Name = "buttonInsert"; - this.buttonInsert.Size = new System.Drawing.Size(75, 23); - this.buttonInsert.TabIndex = 9; - this.buttonInsert.Text = "&Insert"; - this.buttonInsert.UseVisualStyleBackColor = true; - this.buttonInsert.Click += new System.EventHandler(this.buttonInsert_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(323, 155); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 10; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // MeasurementConverter - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(410, 190); - this.Controls.Add(this.listBoxCategory); - this.Controls.Add(this.labelConvertFrom); - this.Controls.Add(this.comboBoxFrom); - this.Controls.Add(this.textBoxInput); - this.Controls.Add(this.labelConvertTo); - this.Controls.Add(this.comboBoxTo); - this.Controls.Add(this.textBoxResult); - this.Controls.Add(this.linkLabel1); - this.Controls.Add(this.checkBoxCloseOnInsert); - this.Controls.Add(this.buttonInsert); - this.Controls.Add(this.buttonOK); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "MeasurementConverter"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Measurement converter"; - this.Activated += new System.EventHandler(this.MeasurementConverter_Activated); - this.Deactivate += new System.EventHandler(this.MeasurementConverter_Deactivate); - this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MeasurementConverter_FormClosed); - this.Load += new System.EventHandler(this.MeasurementConverter_Load); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MeasurementConverter_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ListBox listBoxCategory; - private System.Windows.Forms.Label labelConvertFrom; - private System.Windows.Forms.ComboBox comboBoxFrom; - private System.Windows.Forms.TextBox textBoxInput; - private System.Windows.Forms.Label labelConvertTo; - private System.Windows.Forms.ComboBox comboBoxTo; - private System.Windows.Forms.TextBox textBoxResult; - private System.Windows.Forms.LinkLabel linkLabel1; - private System.Windows.Forms.CheckBox checkBoxCloseOnInsert; - private System.Windows.Forms.Button buttonInsert; - private System.Windows.Forms.Button buttonOK; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class MeasurementConverter + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.listBoxCategory = new System.Windows.Forms.ListBox(); + this.labelConvertFrom = new System.Windows.Forms.Label(); + this.comboBoxFrom = new System.Windows.Forms.ComboBox(); + this.textBoxInput = new System.Windows.Forms.TextBox(); + this.labelConvertTo = new System.Windows.Forms.Label(); + this.comboBoxTo = new System.Windows.Forms.ComboBox(); + this.textBoxResult = new System.Windows.Forms.TextBox(); + this.linkLabel1 = new System.Windows.Forms.LinkLabel(); + this.checkBoxCloseOnInsert = new System.Windows.Forms.CheckBox(); + this.buttonInsert = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // listBoxCategory + // + this.listBoxCategory.FormattingEnabled = true; + this.listBoxCategory.ItemHeight = 16; + this.listBoxCategory.Location = new System.Drawing.Point(10, 10); + this.listBoxCategory.Name = "listBoxCategory"; + this.listBoxCategory.Size = new System.Drawing.Size(106, 170); + this.listBoxCategory.TabIndex = 0; + this.listBoxCategory.SelectedIndexChanged += new System.EventHandler(this.listBoxCategory_SelectedIndexChanged); + this.listBoxCategory.LostFocus += new System.EventHandler(this.listBoxCategory_LostFocus); + // + // labelConvertFrom + // + this.labelConvertFrom.AutoSize = true; + this.labelConvertFrom.Location = new System.Drawing.Point(124, 32); + this.labelConvertFrom.Name = "labelConvertFrom"; + this.labelConvertFrom.Size = new System.Drawing.Size(89, 17); + this.labelConvertFrom.TabIndex = 1; + this.labelConvertFrom.Text = "Convert from:"; + // + // comboBoxFrom + // + this.comboBoxFrom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxFrom.FormattingEnabled = true; + this.comboBoxFrom.Location = new System.Drawing.Point(127, 54); + this.comboBoxFrom.Name = "comboBoxFrom"; + this.comboBoxFrom.Size = new System.Drawing.Size(132, 24); + this.comboBoxFrom.TabIndex = 2; + this.comboBoxFrom.SelectedIndexChanged += new System.EventHandler(this.comboBoxFrom_SelectedIndexChanged); + // + // textBoxInput + // + this.textBoxInput.Location = new System.Drawing.Point(127, 86); + this.textBoxInput.Name = "textBoxInput"; + this.textBoxInput.Size = new System.Drawing.Size(132, 22); + this.textBoxInput.TabIndex = 3; + this.textBoxInput.TextChanged += new System.EventHandler(this.textBoxInput_TextChanged); + this.textBoxInput.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBoxInput_KeyPress); + this.textBoxInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBoxInput_KeyUp); + // + // labelConvertTo + // + this.labelConvertTo.AutoSize = true; + this.labelConvertTo.Location = new System.Drawing.Point(264, 32); + this.labelConvertTo.Name = "labelConvertTo"; + this.labelConvertTo.Size = new System.Drawing.Size(56, 13); + this.labelConvertTo.TabIndex = 4; + this.labelConvertTo.Text = "Convert to:"; + // + // comboBoxTo + // + this.comboBoxTo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxTo.FormattingEnabled = true; + this.comboBoxTo.Location = new System.Drawing.Point(267, 54); + this.comboBoxTo.Name = "comboBoxTo"; + this.comboBoxTo.Size = new System.Drawing.Size(132, 24); + this.comboBoxTo.TabIndex = 5; + this.comboBoxTo.SelectedIndexChanged += new System.EventHandler(this.comboBoxTo_SelectedIndexChanged); + // + // textBoxResult + // + this.textBoxResult.Location = new System.Drawing.Point(267, 86); + this.textBoxResult.Name = "textBoxResult"; + this.textBoxResult.ReadOnly = true; + this.textBoxResult.Size = new System.Drawing.Size(132, 22); + this.textBoxResult.TabIndex = 6; + // + // linkLabel1 + // + this.linkLabel1.Location = new System.Drawing.Point(218, 112); + this.linkLabel1.Name = "linkLabel1"; + this.linkLabel1.Size = new System.Drawing.Size(181, 23); + this.linkLabel1.TabIndex = 7; + this.linkLabel1.TabStop = true; + this.linkLabel1.Text = "Copy to clipboard"; + this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.TopRight; + this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); + // + // checkBoxCloseOnInsert + // + this.checkBoxCloseOnInsert.AutoSize = true; + this.checkBoxCloseOnInsert.Location = new System.Drawing.Point(127, 158); + this.checkBoxCloseOnInsert.Name = "checkBoxCloseOnInsert"; + this.checkBoxCloseOnInsert.Size = new System.Drawing.Size(83, 17); + this.checkBoxCloseOnInsert.TabIndex = 8; + this.checkBoxCloseOnInsert.Text = "Close on insert"; + this.checkBoxCloseOnInsert.UseVisualStyleBackColor = true; + // + // buttonInsert + // + this.buttonInsert.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonInsert.DialogResult = System.Windows.Forms.DialogResult.Yes; + this.buttonInsert.Location = new System.Drawing.Point(245, 155); + this.buttonInsert.Name = "buttonInsert"; + this.buttonInsert.Size = new System.Drawing.Size(75, 23); + this.buttonInsert.TabIndex = 9; + this.buttonInsert.Text = "&Insert"; + this.buttonInsert.UseVisualStyleBackColor = true; + this.buttonInsert.Click += new System.EventHandler(this.buttonInsert_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(323, 155); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 10; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // MeasurementConverter + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(410, 190); + this.Controls.Add(this.listBoxCategory); + this.Controls.Add(this.labelConvertFrom); + this.Controls.Add(this.comboBoxFrom); + this.Controls.Add(this.textBoxInput); + this.Controls.Add(this.labelConvertTo); + this.Controls.Add(this.comboBoxTo); + this.Controls.Add(this.textBoxResult); + this.Controls.Add(this.linkLabel1); + this.Controls.Add(this.checkBoxCloseOnInsert); + this.Controls.Add(this.buttonInsert); + this.Controls.Add(this.buttonOK); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MeasurementConverter"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Measurement converter"; + this.Activated += new System.EventHandler(this.MeasurementConverter_Activated); + this.Deactivate += new System.EventHandler(this.MeasurementConverter_Deactivate); + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MeasurementConverter_FormClosed); + this.Load += new System.EventHandler(this.MeasurementConverter_Load); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MeasurementConverter_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ListBox listBoxCategory; + private System.Windows.Forms.Label labelConvertFrom; + private System.Windows.Forms.ComboBox comboBoxFrom; + private System.Windows.Forms.TextBox textBoxInput; + private System.Windows.Forms.Label labelConvertTo; + private System.Windows.Forms.ComboBox comboBoxTo; + private System.Windows.Forms.TextBox textBoxResult; + private System.Windows.Forms.LinkLabel linkLabel1; + private System.Windows.Forms.CheckBox checkBoxCloseOnInsert; + private System.Windows.Forms.Button buttonInsert; + private System.Windows.Forms.Button buttonOK; + } } \ No newline at end of file diff --git a/src/Forms/MeasurementConverter.cs b/src/ui/Forms/MeasurementConverter.cs similarity index 97% rename from src/Forms/MeasurementConverter.cs rename to src/ui/Forms/MeasurementConverter.cs index b004dbf5f..2ca7fd1ce 100644 --- a/src/Forms/MeasurementConverter.cs +++ b/src/ui/Forms/MeasurementConverter.cs @@ -1,4907 +1,4907 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class MeasurementConverter : Form - { - public class InsertEventArgs : EventArgs - { - public string Result { get; set; } - public bool IsOriginalActive { get; set; } - } - - public event EventHandler InsertClicked; - - public string Input { get; set; } - public bool IsOriginalActive { get; set; } - - private string Output { get; set; } - - private readonly Color _defaultBackColor; - - private readonly string[] _fields = Configuration.Settings.General.MeasurementConverterCategories.Split(';'); - - private readonly List _length = new List { Configuration.Settings.Language.MeasurementConverter.Kilometers, - Configuration.Settings.Language.MeasurementConverter.Meters, - Configuration.Settings.Language.MeasurementConverter.Centimeters, - Configuration.Settings.Language.MeasurementConverter.Millimeters, - Configuration.Settings.Language.MeasurementConverter.Micrometers, - Configuration.Settings.Language.MeasurementConverter.Nanometers, - Configuration.Settings.Language.MeasurementConverter.Angstroms, - Configuration.Settings.Language.MeasurementConverter.MilesTerrestial, - Configuration.Settings.Language.MeasurementConverter.MilesNautical, - Configuration.Settings.Language.MeasurementConverter.Yards, - Configuration.Settings.Language.MeasurementConverter.Feet, - Configuration.Settings.Language.MeasurementConverter.Inches, - Configuration.Settings.Language.MeasurementConverter.Chains, - Configuration.Settings.Language.MeasurementConverter.Fathoms, - Configuration.Settings.Language.MeasurementConverter.Hands, - Configuration.Settings.Language.MeasurementConverter.Rods, - Configuration.Settings.Language.MeasurementConverter.Spans }; - - private readonly List _mass = new List { Configuration.Settings.Language.MeasurementConverter.LongTonnes, - Configuration.Settings.Language.MeasurementConverter.ShortTonnes, - Configuration.Settings.Language.MeasurementConverter.Tonnes, - Configuration.Settings.Language.MeasurementConverter.Kilos, - Configuration.Settings.Language.MeasurementConverter.Grams, - Configuration.Settings.Language.MeasurementConverter.Milligrams, - Configuration.Settings.Language.MeasurementConverter.Micrograms, - Configuration.Settings.Language.MeasurementConverter.Pounds, - Configuration.Settings.Language.MeasurementConverter.Ounces, - Configuration.Settings.Language.MeasurementConverter.Carats, - Configuration.Settings.Language.MeasurementConverter.Drams, - Configuration.Settings.Language.MeasurementConverter.Grains, - Configuration.Settings.Language.MeasurementConverter.Stones }; - - private readonly List _volume = new List { Configuration.Settings.Language.MeasurementConverter.CubicKilometers, - Configuration.Settings.Language.MeasurementConverter.CubicMeters, - Configuration.Settings.Language.MeasurementConverter.Litres, - Configuration.Settings.Language.MeasurementConverter.CubicCentimeters, - Configuration.Settings.Language.MeasurementConverter.CubicMillimeters, - Configuration.Settings.Language.MeasurementConverter.CubicMiles, - Configuration.Settings.Language.MeasurementConverter.CubicYards, - Configuration.Settings.Language.MeasurementConverter.CubicFTs, - Configuration.Settings.Language.MeasurementConverter.CubicInches, - Configuration.Settings.Language.MeasurementConverter.OilBarrels, - Configuration.Settings.Language.MeasurementConverter.GallonUS, - Configuration.Settings.Language.MeasurementConverter.QuartsUS, - Configuration.Settings.Language.MeasurementConverter.PintsUS, - Configuration.Settings.Language.MeasurementConverter.FluidOuncesUS, - Configuration.Settings.Language.MeasurementConverter.Bushels, - Configuration.Settings.Language.MeasurementConverter.Pecks, - Configuration.Settings.Language.MeasurementConverter.GallonsUK, - Configuration.Settings.Language.MeasurementConverter.QuartsUK, - Configuration.Settings.Language.MeasurementConverter.PintsUK, - Configuration.Settings.Language.MeasurementConverter.FluidOuncesUK }; - - private readonly List _area = new List {Configuration.Settings.Language.MeasurementConverter.SquareKilometers, - Configuration.Settings.Language.MeasurementConverter.SquareMeters, - Configuration.Settings.Language.MeasurementConverter.SquareCentimeters, - Configuration.Settings.Language.MeasurementConverter.SquareMillimeters, - Configuration.Settings.Language.MeasurementConverter.SquareMiles, - Configuration.Settings.Language.MeasurementConverter.SquareYards, - Configuration.Settings.Language.MeasurementConverter.SquareFTs, - Configuration.Settings.Language.MeasurementConverter.SquareInches, - Configuration.Settings.Language.MeasurementConverter.Hectares, - Configuration.Settings.Language.MeasurementConverter.Acres, - Configuration.Settings.Language.MeasurementConverter.Ares }; - - private readonly List _time = new List { Configuration.Settings.Language.MeasurementConverter.Hours, - Configuration.Settings.Language.MeasurementConverter.Minutes, - Configuration.Settings.Language.MeasurementConverter.Seconds, - Configuration.Settings.Language.MeasurementConverter.Milliseconds, - Configuration.Settings.Language.MeasurementConverter.Microseconds }; - - private readonly List _temperature = new List { Configuration.Settings.Language.MeasurementConverter.Fahrenheit, - Configuration.Settings.Language.MeasurementConverter.Celsius, - Configuration.Settings.Language.MeasurementConverter.Kelvin }; - - private readonly List _velocity = new List { Configuration.Settings.Language.MeasurementConverter.KilometersPerHour, - Configuration.Settings.Language.MeasurementConverter.MetersPerSecond, - Configuration.Settings.Language.MeasurementConverter.MilesPerHour, - Configuration.Settings.Language.MeasurementConverter.YardsPerMinute, - Configuration.Settings.Language.MeasurementConverter.FTsPerSecond, - Configuration.Settings.Language.MeasurementConverter.Knots }; - - private readonly List _force = new List { Configuration.Settings.Language.MeasurementConverter.PoundsForce, - Configuration.Settings.Language.MeasurementConverter.Newtons, - Configuration.Settings.Language.MeasurementConverter.KilosForce }; - - private readonly List _energy = new List { Configuration.Settings.Language.MeasurementConverter.Jouls, - Configuration.Settings.Language.MeasurementConverter.Calories, - Configuration.Settings.Language.MeasurementConverter.Ergs, - Configuration.Settings.Language.MeasurementConverter.ElectronVolts, - Configuration.Settings.Language.MeasurementConverter.Btus }; - - private readonly List _power = new List { Configuration.Settings.Language.MeasurementConverter.Watts, - Configuration.Settings.Language.MeasurementConverter.Horsepower }; - - private readonly List _pressure = new List { Configuration.Settings.Language.MeasurementConverter.Atmospheres, - Configuration.Settings.Language.MeasurementConverter.Bars, - Configuration.Settings.Language.MeasurementConverter.Pascals, - Configuration.Settings.Language.MeasurementConverter.MillimetersOfMercury, - Configuration.Settings.Language.MeasurementConverter.PoundPerSquareInch, - Configuration.Settings.Language.MeasurementConverter.KilogramPerSquareCentimeter, - Configuration.Settings.Language.MeasurementConverter.KiloPascals }; - - public MeasurementConverter() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _defaultBackColor = Color.White; - var l = Configuration.Settings.Language.MeasurementConverter; - Text = l.Title; - labelConvertFrom.Text = l.ConvertFrom; - labelConvertTo.Text = l.ConvertTo; - linkLabel1.Text = l.CopyToClipboard; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - checkBoxCloseOnInsert.Checked = Configuration.Settings.General.MeasurementConverterCloseOnInsert; - - _defaultBackColor = textBoxInput.BackColor; - - listBoxCategory.Items.Add(l.Length); - listBoxCategory.Items.Add(l.Mass); - listBoxCategory.Items.Add(l.Volume); - listBoxCategory.Items.Add(l.Area); - listBoxCategory.Items.Add(l.Time); - listBoxCategory.Items.Add(l.Temperature); - listBoxCategory.Items.Add(l.Velocity); - listBoxCategory.Items.Add(l.Force); - listBoxCategory.Items.Add(l.Energy); - listBoxCategory.Items.Add(l.Power); - listBoxCategory.Items.Add(l.Pressure); - - listBoxCategory.SelectedItem = _fields[0]; - - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void comboBoxFrom_SelectedIndexChanged(object sender, EventArgs e) - { - string cat = listBoxCategory.SelectedItem.ToString(); - string text = comboBoxFrom.SelectedItem.ToString(); - var l = Configuration.Settings.Language.MeasurementConverter; - - comboBoxTo.Items.Clear(); - - if (cat == l.Length) - { - comboBoxTo.Items.AddRange(_length.Cast().ToArray()); - } - else if (cat == l.Mass) - { - comboBoxTo.Items.AddRange(_mass.Cast().ToArray()); - } - else if (cat == l.Volume) - { - comboBoxTo.Items.AddRange(_volume.Cast().ToArray()); - } - else if (cat == l.Area) - { - comboBoxTo.Items.AddRange(_area.Cast().ToArray()); - } - else if (cat == l.Time) - { - comboBoxTo.Items.AddRange(_time.Cast().ToArray()); - } - else if (cat == l.Temperature) - { - comboBoxTo.Items.AddRange(_temperature.Cast().ToArray()); - } - else if (cat == l.Velocity) - { - comboBoxTo.Items.AddRange(_velocity.Cast().ToArray()); - } - else if (cat == l.Force) - { - comboBoxTo.Items.AddRange(_force.Cast().ToArray()); - } - else if (cat == l.Energy) - { - comboBoxTo.Items.AddRange(_energy.Cast().ToArray()); - } - else if (cat == l.Power) - { - comboBoxTo.Items.AddRange(_power.Cast().ToArray()); - } - else if (cat == l.Pressure) - { - comboBoxTo.Items.AddRange(_pressure.Cast().ToArray()); - } - comboBoxTo.Items.Remove(text); - - if (comboBoxTo.Items.Count > 0) - { - if (comboBoxTo.Items.Contains(_fields[2])) - { - comboBoxTo.SelectedItem = _fields[2]; - } - else - { - comboBoxTo.SelectedIndex = 0; - } - } - - textBoxInput_TextChanged(null, null); - } - - private void ShowResult(double d) - { - textBoxResult.Text = $"{d:0.##}"; - Output = $"{d:0.##}"; - } - - private void comboBoxTo_SelectedIndexChanged(object sender, EventArgs e) - { - textBoxInput_TextChanged(null, null); - } - - private void buttonInsert_Click(object sender, EventArgs e) - { - InsertClicked?.Invoke(this, new InsertEventArgs { Result = Output, IsOriginalActive = IsOriginalActive }); - - if (checkBoxCloseOnInsert.Checked) - { - Configuration.Settings.General.MeasurementConverterCloseOnInsert = checkBoxCloseOnInsert.Checked; - Configuration.Settings.General.MeasurementConverterCategories = listBoxCategory.SelectedItem + ";" + comboBoxFrom.SelectedItem + ";" + comboBoxTo.SelectedItem; - Close(); - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - Configuration.Settings.General.MeasurementConverterCloseOnInsert = checkBoxCloseOnInsert.Checked; - Configuration.Settings.General.MeasurementConverterCategories = listBoxCategory.SelectedItem + ";" + comboBoxFrom.SelectedItem + ";" + comboBoxTo.SelectedItem; - Close(); - } - - private void MeasurementConverter_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - Close(); - } - } - - private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - if (textBoxResult.Text.Length > 0) - { - Clipboard.SetText(textBoxResult.Text); - } - } - - private void textBoxInput_TextChanged(object sender, EventArgs e) - { - if (comboBoxFrom.SelectedIndex == -1 || comboBoxTo.SelectedIndex == -1) - { - return; - } - - if (!double.TryParse(textBoxInput.Text, out var d)) - { - textBoxInput.BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - return; - } - - textBoxInput.BackColor = _defaultBackColor; - - string text = comboBoxFrom.SelectedItem.ToString(); - string textTo = comboBoxTo.SelectedItem.ToString(); - - string cat = listBoxCategory.SelectedItem.ToString(); - var l = Configuration.Settings.Language.MeasurementConverter; - - if (cat == l.Length) - { - if (text == l.Kilometers) - { - if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) * 100000); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 1000000); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 1000000000); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 1000000000000); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 10000000000000); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 1.609); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 1.852); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) * 1093.61); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) * 3280.84); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) * 39370.1); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) * 49.71); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) * 546.807); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) * 9842.52); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) * 198.839); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) * 4374.45); - } - } - else if (text == l.Meters) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) * 100); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 1000000); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 1000000000); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 10000000000); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 1609); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 1852); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) * 1.094); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) * 3.281); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) * 39.37); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 20.117); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) / 1.829); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) * 9.843); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) / 5.029); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) * 4.374); - } - } - else if (text == l.Centimeters) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 100000); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) / 100); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 10); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 10000); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 1e+7); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 1e+8); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 160934); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 185200); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) / 91.44); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) / 30.48); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) / 2.54); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 2012); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) / 183); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) / 10.16); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) / 503); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) / 22.86); - } - } - else if (text == l.Millimeters) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 1e+6); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) / 10); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 1e+6); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 1e+7); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 1.609e+6); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 1.852e+6); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) / 914); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) / 305); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) / 25.4); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 20117); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) / 1829); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) / 102); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) / 5029); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) / 229); - } - } - else if (text == l.Micrometers) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 1e+9); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) / 1e+6); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) / 10000); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 10000); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 1.609e+9); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 1.852e+9); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) / 914400); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) / 304800); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) / 25400); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 2.012e+7); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) / 1.829e+6); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) / 101600); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) / 5.029e+6); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) / 228600); - } - } - else if (text == l.Nanometers) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 1e+12); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) / 1e+9); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) / 1e+7); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) / 1e+6); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 10); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 1.609e+12); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 1.852e+12); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) / 9.144e+8); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) / 3.048e+8); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) / 2.54e+7); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 2.012e+10); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) / 1.829e+9); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) / 1.016e+8); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) / 5.029e+9); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) / 2.286e+8); - } - } - else if (text == l.Angstroms) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 1e+13); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) / 1e+10); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) / 1e+8); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) / 1e+7); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) / 10000); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) / 10); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 1.609e+13); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 1.852e+13); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) / 9.144e+9); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) / 3.048e+9); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) / 2.54e+8); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 2.012e+11); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) / 1.829e+10); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) / 1.016e+9); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) / 5.029e+10); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) / 2.286e+9); - } - } - else if (text == l.MilesTerrestial) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) * 1.609); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) * 1609); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) * 160934); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 1.609e+6); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 1.609e+9); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 1.609e+12); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 1.609e+13); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 1.151); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) * 1760); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) * 5280); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) * 63360); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) * 80); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) * 880); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) * 15840); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) * 320); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) * 7040); - } - } - else if (text == l.MilesNautical) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) * 1.852); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) * 1852); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) * 185200); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 1.852e+6); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 1.852e+9); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 1.852e+12); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 1.852e+13); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) * 1.151); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) * 2025); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) * 6076); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) * 72913); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) * 92.062); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) * 1013); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) * 18228); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) * 368); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) * 8101); - } - } - else if (text == l.Yards) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 1094); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) / 1.094); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) * 91.44); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 914); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 914400); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 9.144e+8); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 9.144e+9); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 1760); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 2025); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) * 3); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) * 36); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 22); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) / 2); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) * 9); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) / 5.5); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) * 4); - } - } - else if (text == l.Feet) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 3281); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) / 3.281); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) * 30.48); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 305); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 304800); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 3.048e+8); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 3.048e+9); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 5280); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 6076); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) / 3); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) * 12); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 66); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) / 6); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) * 3); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) / 16.5); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) * 1.333); - } - } - else if (text == l.Inches) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 39370); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) / 39.37); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) * 2.54); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 25.4); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 25400); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 2.54e+7); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 2.54e+8); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 63360); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 72913); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) / 36); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) / 12); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 792); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) / 72); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) / 4); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) / 198); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) / 9); - } - } - else if (text == l.Chains) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 49.71); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) * 20.117); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) * 2012); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 20117); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 2.012e+7); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 2.012e+10); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 2.012e+11); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 80); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 92.062); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) * 22); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) * 66); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) * 792); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) * 11); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) * 198); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) * 4); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) * 88); - } - } - else if (text == l.Fathoms) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 547); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) * 1.829); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) * 183); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 1829); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 1.829e+6); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 1.829e+9); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 1.829e+10); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 880); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 1013); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) * 2); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) * 6); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) * 72); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 11); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) * 18); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) / 2.75); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) * 8); - } - } - else if (text == l.Hands) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 9843); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) / 9.843); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) * 10.16); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 102); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 101600); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 1.016e+8); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 1.016e+9); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 15840); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 18228); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) / 9); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) / 3); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) * 4); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 198); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) / 18); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) / 49.5); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) / 2.25); - } - } - else if (text == l.Rods) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 199); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) * 5.029); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) * 503); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 5029); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 5.029e+6); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 5.029e+9); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 5.029e+10); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 320); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 368); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) * 5.5); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) * 16.5); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) * 198); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 4); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) * 2.75); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) * 49.5); - } - else if (textTo == l.Spans) - { - ShowResult(Convert.ToDouble(d) * 22); - } - } - else if (text == l.Spans) - { - if (textTo == l.Kilometers) - { - ShowResult(Convert.ToDouble(d) / 4374); - } - else if (textTo == l.Meters) - { - ShowResult(Convert.ToDouble(d) / 4.374); - } - else if (textTo == l.Centimeters) - { - ShowResult(Convert.ToDouble(d) * 22.86); - } - else if (textTo == l.Millimeters) - { - ShowResult(Convert.ToDouble(d) * 229); - } - else if (textTo == l.Micrometers) - { - ShowResult(Convert.ToDouble(d) * 228600); - } - else if (textTo == l.Nanometers) - { - ShowResult(Convert.ToDouble(d) * 2.286e+8); - } - else if (textTo == l.Angstroms) - { - ShowResult(Convert.ToDouble(d) * 2.286e+9); - } - else if (textTo == l.MilesTerrestial) - { - ShowResult(Convert.ToDouble(d) / 7040); - } - else if (textTo == l.MilesNautical) - { - ShowResult(Convert.ToDouble(d) / 8101); - } - else if (textTo == l.Yards) - { - ShowResult(Convert.ToDouble(d) / 4); - } - else if (textTo == l.Feet) - { - ShowResult(Convert.ToDouble(d) / 1.333); - } - else if (textTo == l.Inches) - { - ShowResult(Convert.ToDouble(d) * 9); - } - else if (textTo == l.Chains) - { - ShowResult(Convert.ToDouble(d) / 88); - } - else if (textTo == l.Fathoms) - { - ShowResult(Convert.ToDouble(d) / 8); - } - else if (textTo == l.Hands) - { - ShowResult(Convert.ToDouble(d) * 2.25); - } - else if (textTo == l.Rods) - { - ShowResult(Convert.ToDouble(d) / 22); - } - } - } - else if (cat == l.Mass) - { - if (text == l.LongTonnes) - { - if (textTo == l.ShortTonnes) - { - ShowResult(Convert.ToDouble(d) * 1.12); - } - else if (textTo == l.Tonnes) - { - ShowResult(Convert.ToDouble(d) * 1.016); - } - else if (textTo == l.Kilos) - { - ShowResult(Convert.ToDouble(d) * 1016); - } - else if (textTo == l.Grams) - { - ShowResult(Convert.ToDouble(d) * 1.016e+6); - } - else if (textTo == l.Milligrams) - { - ShowResult(Convert.ToDouble(d) * 1.016e+9); - } - else if (textTo == l.Micrograms) - { - ShowResult(Convert.ToDouble(d) * 1.016e+12); - } - else if (textTo == l.Pounds) - { - ShowResult(Convert.ToDouble(d) * 2240); - } - else if (textTo == l.Ounces) - { - ShowResult(Convert.ToDouble(d) * 35840); - } - else if (textTo == l.Carats) - { - ShowResult(Convert.ToDouble(d) * 5.08e+6); - } - else if (textTo == l.Drams) - { - ShowResult(Convert.ToDouble(d) * 573438); - } - else if (textTo == l.Grains) - { - ShowResult(Convert.ToDouble(d) * 1.568e+7); - } - else if (textTo == l.Stones) - { - ShowResult(Convert.ToDouble(d) * 160); - } - } - else if (text == l.ShortTonnes) - { - if (textTo == l.LongTonnes) - { - ShowResult(Convert.ToDouble(d) / 1.12); - } - else if (textTo == l.Tonnes) - { - ShowResult(Convert.ToDouble(d) / 1.102); - } - else if (textTo == l.Kilos) - { - ShowResult(Convert.ToDouble(d) * 907); - } - else if (textTo == l.Grams) - { - ShowResult(Convert.ToDouble(d) * 907185); - } - else if (textTo == l.Milligrams) - { - ShowResult(Convert.ToDouble(d) * 9.072e+8); - } - else if (textTo == l.Micrograms) - { - ShowResult(Convert.ToDouble(d) * 9.072e+11); - } - else if (textTo == l.Pounds) - { - ShowResult(Convert.ToDouble(d) * 2000); - } - else if (textTo == l.Ounces) - { - ShowResult(Convert.ToDouble(d) * 32000); - } - else if (textTo == l.Carats) - { - ShowResult(Convert.ToDouble(d) * 4.536e+6); - } - else if (textTo == l.Drams) - { - ShowResult(Convert.ToDouble(d) * 511999); - } - else if (textTo == l.Grains) - { - ShowResult(Convert.ToDouble(d) * 1.4e+7); - } - else if (textTo == l.Stones) - { - ShowResult(Convert.ToDouble(d) * 143); - } - } - else if (text == l.Tonnes) - { - if (textTo == l.LongTonnes) - { - ShowResult(Convert.ToDouble(d) / 1.016); - } - else if (textTo == l.ShortTonnes) - { - ShowResult(Convert.ToDouble(d) * 1.102); - } - else if (textTo == l.Kilos) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - else if (textTo == l.Grams) - { - ShowResult(Convert.ToDouble(d) * 1e+6); - } - else if (textTo == l.Milligrams) - { - ShowResult(Convert.ToDouble(d) * 1e+9); - } - else if (textTo == l.Micrograms) - { - ShowResult(Convert.ToDouble(d) * 1e+12); - } - else if (textTo == l.Pounds) - { - ShowResult(Convert.ToDouble(d) * 2205); - } - else if (textTo == l.Ounces) - { - ShowResult(Convert.ToDouble(d) * 35274); - } - else if (textTo == l.Carats) - { - ShowResult(Convert.ToDouble(d) * 5e+6); - } - else if (textTo == l.Drams) - { - ShowResult(Convert.ToDouble(d) * 564382); - } - else if (textTo == l.Grains) - { - ShowResult(Convert.ToDouble(d) * 1.543e+7); - } - else if (textTo == l.Stones) - { - ShowResult(Convert.ToDouble(d) * 157); - } - } - else if (text == l.Kilos) - { - if (textTo == l.LongTonnes) - { - ShowResult(Convert.ToDouble(d) / 1016); - } - else if (textTo == l.ShortTonnes) - { - ShowResult(Convert.ToDouble(d) / 907); - } - else if (textTo == l.Tonnes) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - else if (textTo == l.Grams) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - else if (textTo == l.Milligrams) - { - ShowResult(Convert.ToDouble(d) * 1e+6); - } - else if (textTo == l.Micrograms) - { - ShowResult(Convert.ToDouble(d) * 1e+9); - } - else if (textTo == l.Pounds) - { - ShowResult(Convert.ToDouble(d) * 2.205); - } - else if (textTo == l.Ounces) - { - ShowResult(Convert.ToDouble(d) * 35.274); - } - else if (textTo == l.Carats) - { - ShowResult(Convert.ToDouble(d) * 5000); - } - else if (textTo == l.Drams) - { - ShowResult(Convert.ToDouble(d) * 564); - } - else if (textTo == l.Grains) - { - ShowResult(Convert.ToDouble(d) * 15432); - } - else if (textTo == l.Stones) - { - ShowResult(Convert.ToDouble(d) / 6.35); - } - } - else if (text == l.Grams) - { - if (textTo == l.LongTonnes) - { - ShowResult(Convert.ToDouble(d) / 1.016e+6); - } - else if (textTo == l.ShortTonnes) - { - ShowResult(Convert.ToDouble(d) / 907185); - } - else if (textTo == l.Tonnes) - { - ShowResult(Convert.ToDouble(d) / 1e+6); - } - else if (textTo == l.Kilos) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - else if (textTo == l.Milligrams) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - else if (textTo == l.Micrograms) - { - ShowResult(Convert.ToDouble(d) * 1e+6); - } - else if (textTo == l.Pounds) - { - ShowResult(Convert.ToDouble(d) / 454); - } - else if (textTo == l.Ounces) - { - ShowResult(Convert.ToDouble(d) / 28.35); - } - else if (textTo == l.Carats) - { - ShowResult(Convert.ToDouble(d) * 5); - } - else if (textTo == l.Drams) - { - ShowResult(Convert.ToDouble(d) / 1.772); - } - else if (textTo == l.Grains) - { - ShowResult(Convert.ToDouble(d) * 15.432); - } - else if (textTo == l.Stones) - { - ShowResult(Convert.ToDouble(d) / 6350); - } - } - else if (text == l.Milligrams) - { - if (textTo == l.LongTonnes) - { - ShowResult(Convert.ToDouble(d) / 1.016e+9); - } - else if (textTo == l.ShortTonnes) - { - ShowResult(Convert.ToDouble(d) / 9.072e+8); - } - else if (textTo == l.Tonnes) - { - ShowResult(Convert.ToDouble(d) / 1e+9); - } - else if (textTo == l.Kilos) - { - ShowResult(Convert.ToDouble(d) / 1e+6); - } - else if (textTo == l.Grams) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - else if (textTo == l.Micrograms) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - else if (textTo == l.Pounds) - { - ShowResult(Convert.ToDouble(d) / 453592); - } - else if (textTo == l.Ounces) - { - ShowResult(Convert.ToDouble(d) / 28350); - } - else if (textTo == l.Carats) - { - ShowResult(Convert.ToDouble(d) / 200); - } - else if (textTo == l.Drams) - { - ShowResult(Convert.ToDouble(d) / 1772); - } - else if (textTo == l.Grains) - { - ShowResult(Convert.ToDouble(d) / 64.799); - } - else if (textTo == l.Stones) - { - ShowResult(Convert.ToDouble(d) / 6.35e+6); - } - } - else if (text == l.Micrograms) - { - if (textTo == l.LongTonnes) - { - ShowResult(Convert.ToDouble(d) / 1.016e+12); - } - else if (textTo == l.ShortTonnes) - { - ShowResult(Convert.ToDouble(d) / 9.072e+11); - } - else if (textTo == l.Tonnes) - { - ShowResult(Convert.ToDouble(d) / 1e+12); - } - else if (textTo == l.Kilos) - { - ShowResult(Convert.ToDouble(d) / 1e+9); - } - else if (textTo == l.Grams) - { - ShowResult(Convert.ToDouble(d) / 1e+6); - } - else if (textTo == l.Milligrams) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - else if (textTo == l.Pounds) - { - ShowResult(Convert.ToDouble(d) / 4.536e+8); - } - else if (textTo == l.Ounces) - { - ShowResult(Convert.ToDouble(d) / 2.835e+7); - } - else if (textTo == l.Carats) - { - ShowResult(Convert.ToDouble(d) / 200000); - } - else if (textTo == l.Drams) - { - ShowResult(Convert.ToDouble(d) / 1.772e+6); - } - else if (textTo == l.Grains) - { - ShowResult(Convert.ToDouble(d) / 64799); - } - else if (textTo == l.Stones) - { - ShowResult(Convert.ToDouble(d) / 6.35e+9); - } - } - else if (text == l.Pounds) - { - if (textTo == l.LongTonnes) - { - ShowResult(Convert.ToDouble(d) / 2240); - } - else if (textTo == l.ShortTonnes) - { - ShowResult(Convert.ToDouble(d) / 2000); - } - else if (textTo == l.Tonnes) - { - ShowResult(Convert.ToDouble(d) / 2205); - } - else if (textTo == l.Kilos) - { - ShowResult(Convert.ToDouble(d) / 2.205); - } - else if (textTo == l.Grams) - { - ShowResult(Convert.ToDouble(d) * 454); - } - else if (textTo == l.Milligrams) - { - ShowResult(Convert.ToDouble(d) * 453592); - } - else if (textTo == l.Micrograms) - { - ShowResult(Convert.ToDouble(d) * 4.536e+8); - } - else if (textTo == l.Ounces) - { - ShowResult(Convert.ToDouble(d) * 16); - } - else if (textTo == l.Carats) - { - ShowResult(Convert.ToDouble(d) * 2268); - } - else if (textTo == l.Drams) - { - ShowResult(Convert.ToDouble(d) * 256); - } - else if (textTo == l.Grains) - { - ShowResult(Convert.ToDouble(d) * 7000); - } - else if (textTo == l.Stones) - { - ShowResult(Convert.ToDouble(d) / 14); - } - } - else if (text == l.Ounces) - { - if (textTo == l.LongTonnes) - { - ShowResult(Convert.ToDouble(d) / 35840); - } - else if (textTo == l.ShortTonnes) - { - ShowResult(Convert.ToDouble(d) / 32000); - } - else if (textTo == l.Tonnes) - { - ShowResult(Convert.ToDouble(d) / 35274); - } - else if (textTo == l.Kilos) - { - ShowResult(Convert.ToDouble(d) / 35.274); - } - else if (textTo == l.Grams) - { - ShowResult(Convert.ToDouble(d) * 28.35); - } - else if (textTo == l.Milligrams) - { - ShowResult(Convert.ToDouble(d) * 28350); - } - else if (textTo == l.Micrograms) - { - ShowResult(Convert.ToDouble(d) * 2.835e+7); - } - else if (textTo == l.Pounds) - { - ShowResult(Convert.ToDouble(d) / 16); - } - else if (textTo == l.Carats) - { - ShowResult(Convert.ToDouble(d) * 142); - } - else if (textTo == l.Drams) - { - ShowResult(Convert.ToDouble(d) * 16); - } - else if (textTo == l.Grains) - { - ShowResult(Convert.ToDouble(d) * 438); - } - else if (textTo == l.Stones) - { - ShowResult(Convert.ToDouble(d) / 224); - } - } - else if (text == l.Carats) - { - if (textTo == l.LongTonnes) - { - ShowResult(Convert.ToDouble(d) / 5.08e+6); - } - else if (textTo == l.ShortTonnes) - { - ShowResult(Convert.ToDouble(d) / 4.536e+6); - } - else if (textTo == l.Tonnes) - { - ShowResult(Convert.ToDouble(d) / 5e+6); - } - else if (textTo == l.Kilos) - { - ShowResult(Convert.ToDouble(d) / 5000); - } - else if (textTo == l.Grams) - { - ShowResult(Convert.ToDouble(d) / 5); - } - else if (textTo == l.Milligrams) - { - ShowResult(Convert.ToDouble(d) * 200); - } - else if (textTo == l.Micrograms) - { - ShowResult(Convert.ToDouble(d) * 200000); - } - else if (textTo == l.Pounds) - { - ShowResult(Convert.ToDouble(d) / 2268); - } - else if (textTo == l.Ounces) - { - ShowResult(Convert.ToDouble(d) / 142); - } - else if (textTo == l.Drams) - { - ShowResult(Convert.ToDouble(d) / 8.859); - } - else if (textTo == l.Grains) - { - ShowResult(Convert.ToDouble(d) * 3.086); - } - else if (textTo == l.Stones) - { - ShowResult(Convert.ToDouble(d) / 31751); - } - } - else if (text == l.Drams) - { - if (textTo == l.LongTonnes) - { - ShowResult(Convert.ToDouble(d) / 573438); - } - else if (textTo == l.ShortTonnes) - { - ShowResult(Convert.ToDouble(d) / 511999); - } - else if (textTo == l.Tonnes) - { - ShowResult(Convert.ToDouble(d) / 564382); - } - else if (textTo == l.Kilos) - { - ShowResult(Convert.ToDouble(d) / 564); - } - else if (textTo == l.Grams) - { - ShowResult(Convert.ToDouble(d) * 1.772); - } - else if (textTo == l.Milligrams) - { - ShowResult(Convert.ToDouble(d) * 1772); - } - else if (textTo == l.Micrograms) - { - ShowResult(Convert.ToDouble(d) * 1.772e+6); - } - else if (textTo == l.Pounds) - { - ShowResult(Convert.ToDouble(d) / 256); - } - else if (textTo == l.Ounces) - { - ShowResult(Convert.ToDouble(d) / 16); - } - else if (textTo == l.Carats) - { - ShowResult(Convert.ToDouble(d) * 8.859); - } - else if (textTo == l.Grains) - { - ShowResult(Convert.ToDouble(d) * 27.344); - } - else if (textTo == l.Stones) - { - ShowResult(Convert.ToDouble(d) / 3584); - } - } - else if (text == l.Grains) - { - if (textTo == l.LongTonnes) - { - ShowResult(Convert.ToDouble(d) / 1.568e+7); - } - else if (textTo == l.ShortTonnes) - { - ShowResult(Convert.ToDouble(d) / 1.4e+7); - } - else if (textTo == l.Tonnes) - { - ShowResult(Convert.ToDouble(d) / 1.543e+7); - } - else if (textTo == l.Kilos) - { - ShowResult(Convert.ToDouble(d) / 15432); - } - else if (textTo == l.Grams) - { - ShowResult(Convert.ToDouble(d) / 15.432); - } - else if (textTo == l.Milligrams) - { - ShowResult(Convert.ToDouble(d) * 64.799); - } - else if (textTo == l.Micrograms) - { - ShowResult(Convert.ToDouble(d) * 64799); - } - else if (textTo == l.Pounds) - { - ShowResult(Convert.ToDouble(d) / 7000); - } - else if (textTo == l.Ounces) - { - ShowResult(Convert.ToDouble(d) / 438); - } - else if (textTo == l.Carats) - { - ShowResult(Convert.ToDouble(d) / 3.086); - } - else if (textTo == l.Drams) - { - ShowResult(Convert.ToDouble(d) / 27.344); - } - else if (textTo == l.Stones) - { - ShowResult(Convert.ToDouble(d) / 98000); - } - } - else if (text == l.Stones) - { - if (textTo == l.LongTonnes) - { - ShowResult(Convert.ToDouble(d) / 160); - } - else if (textTo == l.ShortTonnes) - { - ShowResult(Convert.ToDouble(d) / 143); - } - else if (textTo == l.Tonnes) - { - ShowResult(Convert.ToDouble(d) / 157); - } - else if (textTo == l.Kilos) - { - ShowResult(Convert.ToDouble(d) * 6.35); - } - else if (textTo == l.Grams) - { - ShowResult(Convert.ToDouble(d) * 6350); - } - else if (textTo == l.Milligrams) - { - ShowResult(Convert.ToDouble(d) * 6.35e+6); - } - else if (textTo == l.Micrograms) - { - ShowResult(Convert.ToDouble(d) * 6.35e+9); - } - else if (textTo == l.Pounds) - { - ShowResult(Convert.ToDouble(d) * 14); - } - else if (textTo == l.Ounces) - { - ShowResult(Convert.ToDouble(d) * 224); - } - else if (textTo == l.Carats) - { - ShowResult(Convert.ToDouble(d) * 31751); - } - else if (textTo == l.Drams) - { - ShowResult(Convert.ToDouble(d) * 3584); - } - else if (textTo == l.Grains) - { - ShowResult(Convert.ToDouble(d) * 98000); - } - } - } - else if (cat == l.Volume) - { - if (text == l.CubicKilometers) - { - if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) * 1e+9); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) * 1e+12); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 1e+15); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 1e+18); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 4.168); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) * 1.308e+9); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) * 3.531e+10); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 6.102e+13); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) * 6.29e+9); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) * 2.642e+11); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) * 1.057e+12); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 2.113e+12); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 3.381e+13); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) * 2.838e+10); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) * 1.135e+11); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) * 2.2e+11); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) * 8.799e+11); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 1.76e+12); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 3.52e+13); - } - } - else if (text == l.CubicMeters) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 1e+9); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 1e+6); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 1e+9); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 4.168e+9); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) * 1.308); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) * 35.315); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 61024); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) * 6.29); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) * 264); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) * 1057); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 2113); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 33814); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) * 28.378); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) * 114); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) * 220); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) * 880); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 1760); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 35195); - } - } - else if (text == l.Litres) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 1e+12); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 1e+6); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 4.168e+12); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 765); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 28.317); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 61.024); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 159); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) / 3.785); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) * 1.057); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 2.113); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 33.814); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 35.239); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) / 8.81); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) / 4.546); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) / 1.137); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 1.76); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 35.195); - } - } - else if (text == l.CubicCentimeters) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 1e+15); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 1e+6); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 4.168e+15); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 764555); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 28317); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) / 16.387); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 158987); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) / 3785); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) / 946); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) / 473); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) / 29.574); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 35239); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) / 8810); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) / 4546); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) / 1137); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) / 568); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) / 28.413); - } - } - else if (text == l.CubicMillimeters) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 1e+18); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 1e+9); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) / 1e+6); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 4.168e+18); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 7.646e+8); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 2.832e+7); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) / 16387); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 1.59e+8); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) / 3.785e+6); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) / 946353); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) / 473176); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) / 29574); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 3.524e+7); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) / 8.81e+6); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) / 4.546e+6); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) / 1.137e+6); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) / 568261); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) / 28413); - } - } - else if (text == l.CubicMiles) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) * 4.168); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) * 4.168e+9); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) * 4.168e+12); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 4.168e+15); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 4.168e+18); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) * 5.452e+9); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) * 1.472e+11); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 2.544e+14); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) * 2.622e+10); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) * 1.101e+12); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) * 4.404e+12); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 8.809e+12); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 1.409e+14); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) * 1.183e+11); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) * 4.731e+11); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) * 9.169e+11); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) * 3.667e+12); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 7.335e+12); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 1.467e+14); - } - } - else if (text == l.CubicYards) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 1.308e+9); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 1.308); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) * 765); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 764555); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 7.646e+8); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 5.452e+9); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) * 27); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 46656); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) * 4.809); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) * 202); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) * 808); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 1616); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 25853); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) * 21.696); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) * 86.785); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) * 168); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) * 673); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 1345); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 26909); - } - } - else if (text == l.CubicFTs) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 3.531e+10); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 35.315); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) * 28.317); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 28317); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 2.832e+7); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 1.472e+11); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 27); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 1728); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 5.615); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) * 7.481); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) * 29.922); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 59.844); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 958); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 1.244); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) * 3.214); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) * 6.229); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) * 24.915); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 49.831); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 997); - } - } - else if (text == l.CubicInches) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 6.102e+13); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 61024); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) / 61.024); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 16.387); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 16387); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 2.544e+14); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 46656); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 1728); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 9702); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) / 231); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) / 57.75); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) / 28.875); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) / 1.805); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 2150); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) / 538); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) / 277); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) / 69.355); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) / 34.677); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) / 1.734); - } - } - else if (text == l.OilBarrels) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 6.29e+9); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 6.29); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) * 159); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 158987); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 1.59e+8); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 2.622e+10); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 4.809); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) * 5.615); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 9702); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) * 42); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) * 168); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 336); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 5376); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) * 4.512); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) * 18.047); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) * 34.972); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) * 140); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 280); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 5596); - } - } - else if (text == l.GallonUS) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 2.642e+11); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 264); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) * 3.785); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 3785); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 3.785e+6); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 1.101e+12); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 202); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 7.481); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 231); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 42); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) * 4); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 8); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 128); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 9.309); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) / 2.327); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) / 1.201); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) * 3.331); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 6.661); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 133); - } - } - else if (text == l.QuartsUS) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 1.057e+12); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 1057); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) / 1.057); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 946); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 946353); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 4.404e+12); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 808); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 29.922); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 57.75); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 168); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) / 4); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 2); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 32); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 37.237); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) / 9.309); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) / 4.804); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) / 1.201); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 1.665); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 33.307); - } - } - else if (text == l.PintsUS) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 2.113e+12); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 2113); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) / 2.113); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 473); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 473176); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 8.809e+12); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 1616); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 59.844); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 28.875); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 336); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) / 8); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) / 2); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 16); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 74.473); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) / 18.618); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) / 9.608); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) / 2.402); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) / 1.201); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 16.653); - } - } - else if (text == l.FluidOuncesUS) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 3.381e+13); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 33814); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) / 33.814); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 29.574); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 29574); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 1.409e+14); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 25853); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 958); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 1.805); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 5376); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) / 128); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) / 32); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) / 16); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 1192); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) / 298); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) / 154); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) / 38.43); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) / 19.215); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 1.041); - } - } - else if (text == l.Bushels) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 2.838e+10); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 28.378); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) * 35.239); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 35239); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 3.524e+7); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 1.183e+11); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 21.696); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) * 1.244); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 2150); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 4.512); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) * 9.309); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) * 37.237); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 74.473); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 1192); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) * 4); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) * 7.752); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) * 31.006); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 62.012); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 1240); - } - } - else if (text == l.Pecks) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 1.135e+11); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 114); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) * 8.81); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 8810); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 8.81e+6); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 4.731e+11); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 86.785); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 3.214); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 538); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 18.047); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) * 2.327); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) * 9.309); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 18.618); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 298); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 4); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) * 1.938); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) * 7.752); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 15.503); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 310); - } - } - else if (text == l.GallonsUK) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 2.2e+11); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 220); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) * 4.546); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 4546); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 4.546e+6); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 9.169e+11); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 168); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 6.229); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 277); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 34.972); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) * 1.201); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) * 4.804); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 9.608); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 154); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 7.752); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) / 1.938); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) * 4); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 8); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 160); - } - } - else if (text == l.QuartsUK) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 2.2e+11); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 880); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) * 1.137); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 4546); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 4.546e+6); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 9.169e+11); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 168); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 24.915); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 69.355); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 34.972); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) / 3.331); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) * 1.201); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) * 2.402); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 38.43); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 7.752); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) / 1.938); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) / 4); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) * 4); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 160); - } - } - else if (text == l.PintsUK) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 1.76e+12); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 1760); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) / 1.76); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 568); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 568261); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 7.335e+12); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 1345); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 49.831); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 34.677); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 280); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) / 6.661); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) / 1.665); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d)); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) * 1.201); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 62.012); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) / 15.503); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) / 8); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) / 2); - } - else if (textTo == l.FluidOuncesUK) - { - ShowResult(Convert.ToDouble(d) * 20); - } - } - else if (text == l.FluidOuncesUK) - { - if (textTo == l.CubicKilometers) - { - ShowResult(Convert.ToDouble(d) / 3.52e+13); - } - else if (textTo == l.CubicMeters) - { - ShowResult(Convert.ToDouble(d) / 35195); - } - else if (textTo == l.Litres) - { - ShowResult(Convert.ToDouble(d) / 35.195); - } - else if (textTo == l.CubicCentimeters) - { - ShowResult(Convert.ToDouble(d) * 28.413); - } - else if (textTo == l.CubicMillimeters) - { - ShowResult(Convert.ToDouble(d) * 28413); - } - else if (textTo == l.CubicMiles) - { - ShowResult(Convert.ToDouble(d) / 1.467e+14); - } - else if (textTo == l.CubicYards) - { - ShowResult(Convert.ToDouble(d) / 26909); - } - else if (textTo == l.CubicFTs) - { - ShowResult(Convert.ToDouble(d) / 997); - } - else if (textTo == l.CubicInches) - { - ShowResult(Convert.ToDouble(d) * 1.734); - } - else if (textTo == l.OilBarrels) - { - ShowResult(Convert.ToDouble(d) / 5596); - } - else if (textTo == l.GallonUS) - { - ShowResult(Convert.ToDouble(d) / 133); - } - else if (textTo == l.QuartsUS) - { - ShowResult(Convert.ToDouble(d) / 33.307); - } - else if (textTo == l.PintsUS) - { - ShowResult(Convert.ToDouble(d) / 16.653); - } - else if (textTo == l.FluidOuncesUS) - { - ShowResult(Convert.ToDouble(d) / 1.041); - } - else if (textTo == l.Bushels) - { - ShowResult(Convert.ToDouble(d) / 1240); - } - else if (textTo == l.Pecks) - { - ShowResult(Convert.ToDouble(d) / 310); - } - else if (textTo == l.GallonsUK) - { - ShowResult(Convert.ToDouble(d) / 160); - } - else if (textTo == l.QuartsUK) - { - ShowResult(Convert.ToDouble(d) / 40); - } - else if (textTo == l.PintsUK) - { - ShowResult(Convert.ToDouble(d) / 20); - } - } - } - else if (cat == l.Area) - { - if (text == l.SquareKilometers) - { - if (textTo == l.SquareMeters) - { - ShowResult(Convert.ToDouble(d) * 1e+6); - } - else if (textTo == l.SquareCentimeters) - { - ShowResult(Convert.ToDouble(d) * 1e+10); - } - else if (textTo == l.SquareMillimeters) - { - ShowResult(Convert.ToDouble(d) * 1e+12); - } - else if (textTo == l.SquareMiles) - { - ShowResult(Convert.ToDouble(d) / 2.59); - } - else if (textTo == l.SquareYards) - { - ShowResult(Convert.ToDouble(d) * 1.196e+6); - } - else if (textTo == l.SquareFTs) - { - ShowResult(Convert.ToDouble(d) * 1.076e+7); - } - else if (textTo == l.SquareInches) - { - ShowResult(Convert.ToDouble(d) * 1.55e+9); - } - else if (textTo == l.Hectares) - { - ShowResult(Convert.ToDouble(d) * 100); - } - else if (textTo == l.Acres) - { - ShowResult(Convert.ToDouble(d) * 247); - } - else if (textTo == l.Ares) - { - ShowResult(Convert.ToDouble(d) * 10000); - } - } - else if (text == l.SquareMeters) - { - if (textTo == l.SquareKilometers) - { - ShowResult(Convert.ToDouble(d) / 1e+6); - } - else if (textTo == l.SquareCentimeters) - { - ShowResult(Convert.ToDouble(d) * 10000); - } - else if (textTo == l.SquareMillimeters) - { - ShowResult(Convert.ToDouble(d) * 1e+6); - } - else if (textTo == l.SquareMiles) - { - ShowResult(Convert.ToDouble(d) / 2.59e+6); - } - else if (textTo == l.SquareYards) - { - ShowResult(Convert.ToDouble(d) * 1.196); - } - else if (textTo == l.SquareFTs) - { - ShowResult(Convert.ToDouble(d) * 10.764); - } - else if (textTo == l.SquareInches) - { - ShowResult(Convert.ToDouble(d) * 1550); - } - else if (textTo == l.Hectares) - { - ShowResult(Convert.ToDouble(d) / 10000); - } - else if (textTo == l.Acres) - { - ShowResult(Convert.ToDouble(d) / 4047); - } - else if (textTo == l.Ares) - { - ShowResult(Convert.ToDouble(d) * 100); - } - } - else if (text == l.SquareCentimeters) - { - if (textTo == l.SquareKilometers) - { - ShowResult(Convert.ToDouble(d) / 1e+10); - } - else if (textTo == l.SquareMeters) - { - ShowResult(Convert.ToDouble(d) / 10000); - } - else if (textTo == l.SquareMillimeters) - { - ShowResult(Convert.ToDouble(d) * 100); - } - else if (textTo == l.SquareMiles) - { - ShowResult(Convert.ToDouble(d) / 2.59e+10); - } - else if (textTo == l.SquareYards) - { - ShowResult(Convert.ToDouble(d) / 8361); - } - else if (textTo == l.SquareFTs) - { - ShowResult(Convert.ToDouble(d) / 929); - } - else if (textTo == l.SquareInches) - { - ShowResult(Convert.ToDouble(d) / 6.452); - } - else if (textTo == l.Hectares) - { - ShowResult(Convert.ToDouble(d) / 1e+8); - } - else if (textTo == l.Acres) - { - ShowResult(Convert.ToDouble(d) / 4.047e+7); - } - else if (textTo == l.Ares) - { - ShowResult(Convert.ToDouble(d) / 1e+6); - } - } - else if (text == l.SquareMillimeters) - { - if (textTo == l.SquareKilometers) - { - ShowResult(Convert.ToDouble(d) / 1e+12); - } - else if (textTo == l.SquareMeters) - { - ShowResult(Convert.ToDouble(d) / 1e+6); - } - else if (textTo == l.SquareCentimeters) - { - ShowResult(Convert.ToDouble(d) / 100); - } - else if (textTo == l.SquareMiles) - { - ShowResult(Convert.ToDouble(d) / 2.59e+12); - } - else if (textTo == l.SquareYards) - { - ShowResult(Convert.ToDouble(d) / 836127); - } - else if (textTo == l.SquareFTs) - { - ShowResult(Convert.ToDouble(d) / 92903); - } - else if (textTo == l.SquareInches) - { - ShowResult(Convert.ToDouble(d) / 645); - } - else if (textTo == l.Hectares) - { - ShowResult(Convert.ToDouble(d) / 1e+10); - } - else if (textTo == l.Acres) - { - ShowResult(Convert.ToDouble(d) / 4.047e+9); - } - else if (textTo == l.Ares) - { - ShowResult(Convert.ToDouble(d) / 1e+8); - } - } - else if (text == l.SquareMiles) - { - if (textTo == l.SquareKilometers) - { - ShowResult(Convert.ToDouble(d) * 2.59); - } - else if (textTo == l.SquareMeters) - { - ShowResult(Convert.ToDouble(d) * 2.59e+6); - } - else if (textTo == l.SquareCentimeters) - { - ShowResult(Convert.ToDouble(d) * 2.59e+10); - } - else if (textTo == l.SquareMillimeters) - { - ShowResult(Convert.ToDouble(d) * 2.59e+12); - } - else if (textTo == l.SquareYards) - { - ShowResult(Convert.ToDouble(d) * 3.098e+6); - } - else if (textTo == l.SquareFTs) - { - ShowResult(Convert.ToDouble(d) * 2.788e+7); - } - else if (textTo == l.SquareInches) - { - ShowResult(Convert.ToDouble(d) * 4.014e+9); - } - else if (textTo == l.Hectares) - { - ShowResult(Convert.ToDouble(d) * 259); - } - else if (textTo == l.Acres) - { - ShowResult(Convert.ToDouble(d) * 640); - } - else if (textTo == l.Ares) - { - ShowResult(Convert.ToDouble(d) * 25900); - } - } - else if (text == l.SquareYards) - { - if (textTo == l.SquareKilometers) - { - ShowResult(Convert.ToDouble(d) / 1.196e+6); - } - else if (textTo == l.SquareMeters) - { - ShowResult(Convert.ToDouble(d) / 1.196); - } - else if (textTo == l.SquareCentimeters) - { - ShowResult(Convert.ToDouble(d) * 8361); - } - else if (textTo == l.SquareMillimeters) - { - ShowResult(Convert.ToDouble(d) * 836127); - } - else if (textTo == l.SquareMiles) - { - ShowResult(Convert.ToDouble(d) / 3.098e+6); - } - else if (textTo == l.SquareFTs) - { - ShowResult(Convert.ToDouble(d) * 9); - } - else if (textTo == l.SquareInches) - { - ShowResult(Convert.ToDouble(d) * 1296); - } - else if (textTo == l.Hectares) - { - ShowResult(Convert.ToDouble(d) / 11960); - } - else if (textTo == l.Acres) - { - ShowResult(Convert.ToDouble(d) / 4840); - } - else if (textTo == l.Ares) - { - ShowResult(Convert.ToDouble(d) / 120); - } - } - else if (text == l.SquareFTs) - { - if (textTo == l.SquareKilometers) - { - ShowResult(Convert.ToDouble(d) / 1.076e+7); - } - else if (textTo == l.SquareMeters) - { - ShowResult(Convert.ToDouble(d) / 10.764); - } - else if (textTo == l.SquareCentimeters) - { - ShowResult(Convert.ToDouble(d) * 929); - } - else if (textTo == l.SquareMillimeters) - { - ShowResult(Convert.ToDouble(d) * 92903); - } - else if (textTo == l.SquareMiles) - { - ShowResult(Convert.ToDouble(d) / 2.788e+7); - } - else if (textTo == l.SquareYards) - { - ShowResult(Convert.ToDouble(d) / 9); - } - else if (textTo == l.SquareInches) - { - ShowResult(Convert.ToDouble(d)); - } - else if (textTo == l.Hectares) - { - ShowResult(Convert.ToDouble(d) * 144); - } - else if (textTo == l.Acres) - { - ShowResult(Convert.ToDouble(d) / 43560); - } - else if (textTo == l.Ares) - { - ShowResult(Convert.ToDouble(d) / 1076); - } - } - else if (text == l.SquareInches) - { - if (textTo == l.SquareKilometers) - { - ShowResult(Convert.ToDouble(d) / 1.55e+9); - } - else if (textTo == l.SquareMeters) - { - ShowResult(Convert.ToDouble(d) / 1550); - } - else if (textTo == l.SquareCentimeters) - { - ShowResult(Convert.ToDouble(d) * 6.452); - } - else if (textTo == l.SquareMillimeters) - { - ShowResult(Convert.ToDouble(d) * 645); - } - else if (textTo == l.SquareMiles) - { - ShowResult(Convert.ToDouble(d) / 4.014e+9); - } - else if (textTo == l.SquareYards) - { - ShowResult(Convert.ToDouble(d) / 1296); - } - else if (textTo == l.SquareFTs) - { - ShowResult(Convert.ToDouble(d) / 144); - } - else if (textTo == l.Hectares) - { - ShowResult(Convert.ToDouble(d) / 1.55e+7); - } - else if (textTo == l.Acres) - { - ShowResult(Convert.ToDouble(d) / 6.273e+6); - } - else if (textTo == l.Ares) - { - ShowResult(Convert.ToDouble(d) / 6.273e+6); - } - } - else if (text == l.Hectares) - { - if (textTo == l.SquareKilometers) - { - ShowResult(Convert.ToDouble(d) / 100); - } - else if (textTo == l.SquareMeters) - { - ShowResult(Convert.ToDouble(d) * 10000); - } - else if (textTo == l.SquareCentimeters) - { - ShowResult(Convert.ToDouble(d) * 1e+8); - } - else if (textTo == l.SquareMillimeters) - { - ShowResult(Convert.ToDouble(d) * 1e+10); - } - else if (textTo == l.SquareMiles) - { - ShowResult(Convert.ToDouble(d) / 259); - } - else if (textTo == l.SquareYards) - { - ShowResult(Convert.ToDouble(d) * 11960); - } - else if (textTo == l.SquareFTs) - { - ShowResult(Convert.ToDouble(d) * 107639); - } - else if (textTo == l.SquareInches) - { - ShowResult(Convert.ToDouble(d) * 1.55e+7); - } - else if (textTo == l.Acres) - { - ShowResult(Convert.ToDouble(d) * 2.471); - } - else if (textTo == l.Ares) - { - ShowResult(Convert.ToDouble(d) * 100); - } - } - else if (text == l.Acres) - { - if (textTo == l.SquareKilometers) - { - ShowResult(Convert.ToDouble(d) / 247); - } - else if (textTo == l.SquareMeters) - { - ShowResult(Convert.ToDouble(d) * 4047); - } - else if (textTo == l.SquareCentimeters) - { - ShowResult(Convert.ToDouble(d) * 4.047e+7); - } - else if (textTo == l.SquareMillimeters) - { - ShowResult(Convert.ToDouble(d) * 4.047e+9); - } - else if (textTo == l.SquareMiles) - { - ShowResult(Convert.ToDouble(d) / 640); - } - else if (textTo == l.SquareYards) - { - ShowResult(Convert.ToDouble(d) * 4840); - } - else if (textTo == l.SquareFTs) - { - ShowResult(Convert.ToDouble(d) * 43560); - } - else if (textTo == l.SquareInches) - { - ShowResult(Convert.ToDouble(d) * 6.273e+6); - } - else if (textTo == l.Hectares) - { - ShowResult(Convert.ToDouble(d) / 2.471); - } - else if (textTo == l.Ares) - { - ShowResult(Convert.ToDouble(d) * 40.469); - } - } - else if (text == l.Ares) - { - if (textTo == l.SquareKilometers) - { - ShowResult(Convert.ToDouble(d) / 10000); - } - else if (textTo == l.SquareMeters) - { - ShowResult(Convert.ToDouble(d) * 100); - } - else if (textTo == l.SquareCentimeters) - { - ShowResult(Convert.ToDouble(d) * 1e+6); - } - else if (textTo == l.SquareMillimeters) - { - ShowResult(Convert.ToDouble(d) * 1e+8); - } - else if (textTo == l.SquareMiles) - { - ShowResult(Convert.ToDouble(d) / 25900); - } - else if (textTo == l.SquareYards) - { - ShowResult(Convert.ToDouble(d) * 120); - } - else if (textTo == l.SquareFTs) - { - ShowResult(Convert.ToDouble(d) * 1076); - } - else if (textTo == l.SquareInches) - { - ShowResult(Convert.ToDouble(d) * 155000); - } - else if (textTo == l.Hectares) - { - ShowResult(Convert.ToDouble(d) / 100); - } - else if (textTo == l.Acres) - { - ShowResult(Convert.ToDouble(d) / 40.469); - } - } - } - else if (cat == l.Time) - { - if (text == l.Hours) - { - if (textTo == l.Minutes) - { - ShowResult(Convert.ToDouble(d) * 60); - } - else if (textTo == l.Seconds) - { - ShowResult(Convert.ToDouble(d) * 3600); - } - else if (textTo == l.Milliseconds) - { - ShowResult(Convert.ToDouble(d) * 3.6e+6); - } - else if (textTo == l.Microseconds) - { - ShowResult(Convert.ToDouble(d) * 3.6e+9); - } - } - else if (text == l.Minutes) - { - if (textTo == l.Hours) - { - ShowResult(Convert.ToDouble(d) / 60); - } - else if (textTo == l.Seconds) - { - ShowResult(Convert.ToDouble(d) * 60); - } - else if (textTo == l.Milliseconds) - { - ShowResult(Convert.ToDouble(d) * 60000); - } - else if (textTo == l.Microseconds) - { - ShowResult(Convert.ToDouble(d) * 6e+7); - } - } - else if (text == l.Seconds) - { - if (textTo == l.Hours) - { - ShowResult(Convert.ToDouble(d) / 3600); - } - else if (textTo == l.Minutes) - { - ShowResult(Convert.ToDouble(d) / 60); - } - else if (textTo == l.Milliseconds) - { - ShowResult(Convert.ToDouble(d) * TimeCode.BaseUnit); - } - else if (textTo == l.Microseconds) - { - ShowResult(Convert.ToDouble(d) * 1e+6); - } - } - else if (text == l.Milliseconds) - { - if (textTo == l.Hours) - { - ShowResult(Convert.ToDouble(d) / 3.6e+6); - } - else if (textTo == l.Minutes) - { - ShowResult(Convert.ToDouble(d) / 60000); - } - else if (textTo == l.Seconds) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - else if (textTo == l.Microseconds) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - } - else if (text == l.Microseconds) - { - if (textTo == l.Hours) - { - ShowResult(Convert.ToDouble(d) / 3.6e+9); - } - else if (textTo == l.Minutes) - { - ShowResult(Convert.ToDouble(d) / 6e+7); - } - else if (textTo == l.Seconds) - { - ShowResult(Convert.ToDouble(d) / 1e+6); - } - else if (textTo == l.Milliseconds) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - } - } - else if (cat == l.Temperature) - { - if (text == l.Fahrenheit) - { - if (textTo == l.Celsius) - { - ShowResult((Convert.ToDouble(d) - 32) * 5 / 9); - } - else if (textTo == l.Kelvin) - { - ShowResult((Convert.ToDouble(d) - 32) * 5 / 9 + 273.15); - } - } - else if (text == l.Celsius) - { - if (textTo == l.Fahrenheit) - { - ShowResult(Convert.ToDouble(d) * 1.80 + 32); - } - else if (textTo == l.Kelvin) - { - ShowResult(Convert.ToDouble(d) + 273.15); - } - } - else if (text == l.Kelvin) - { - if (textTo == l.Fahrenheit) - { - ShowResult((Convert.ToDouble(d) - 273.15) * 9 / 5 + 32); - } - else if (textTo == l.Celsius) - { - ShowResult(Convert.ToDouble(d) - 273.15); - } - } - } - else if (cat == l.Velocity) - { - if (text == l.KilometersPerHour) - { - if (textTo == l.MetersPerSecond) - { - ShowResult(Convert.ToDouble(d) / 3.6); - } - else if (textTo == l.MilesPerHour) - { - ShowResult(Convert.ToDouble(d) / 1.609); - } - else if (textTo == l.YardsPerMinute) - { - ShowResult(Convert.ToDouble(d) * 18.227); - } - else if (textTo == l.FTsPerSecond) - { - ShowResult(Convert.ToDouble(d) / 1.097); - } - else if (textTo == l.Knots) - { - ShowResult(Convert.ToDouble(d) / 1.852); - } - } - if (text == l.MetersPerSecond) - { - if (textTo == l.KilometersPerHour) - { - ShowResult(Convert.ToDouble(d) * 3.6); - } - else if (textTo == l.MilesPerHour) - { - ShowResult(Convert.ToDouble(d) * 2.237); - } - else if (textTo == l.YardsPerMinute) - { - ShowResult(Convert.ToDouble(d) * 65.617); - } - else if (textTo == l.FTsPerSecond) - { - ShowResult(Convert.ToDouble(d) * 3.281); - } - else if (textTo == l.Knots) - { - ShowResult(Convert.ToDouble(d) * 1.944); - } - } - if (text == l.MilesPerHour) - { - if (textTo == l.KilometersPerHour) - { - ShowResult(Convert.ToDouble(d) * 1.609); - } - else if (textTo == l.MetersPerSecond) - { - ShowResult(Convert.ToDouble(d) / 2.237); - } - else if (textTo == l.YardsPerMinute) - { - ShowResult(Convert.ToDouble(d) * 29.333); - } - else if (textTo == l.FTsPerSecond) - { - ShowResult(Convert.ToDouble(d) * 1.467); - } - else if (textTo == l.Knots) - { - ShowResult(Convert.ToDouble(d) / 1.151); - } - } - if (text == l.YardsPerMinute) - { - if (textTo == l.KilometersPerHour) - { - ShowResult(Convert.ToDouble(d) / 18.227); - } - else if (textTo == l.MetersPerSecond) - { - ShowResult(Convert.ToDouble(d) / 65.617); - } - else if (textTo == l.MilesPerHour) - { - ShowResult(Convert.ToDouble(d) / 29.333); - } - else if (textTo == l.FTsPerSecond) - { - ShowResult(Convert.ToDouble(d) / 20); - } - else if (textTo == l.Knots) - { - ShowResult(Convert.ToDouble(d) / 33.756); - } - } - if (text == l.FTsPerSecond) - { - if (textTo == l.KilometersPerHour) - { - ShowResult(Convert.ToDouble(d) * 1.097); - } - else if (textTo == l.MetersPerSecond) - { - ShowResult(Convert.ToDouble(d) / 3.281); - } - else if (textTo == l.MilesPerHour) - { - ShowResult(Convert.ToDouble(d) / 1.467); - } - else if (textTo == l.YardsPerMinute) - { - ShowResult(Convert.ToDouble(d) * 20); - } - else if (textTo == l.Knots) - { - ShowResult(Convert.ToDouble(d) / 1.688); - } - } - if (text == l.Knots) - { - if (textTo == l.KilometersPerHour) - { - ShowResult(Convert.ToDouble(d) * 1.852); - } - else if (textTo == l.MetersPerSecond) - { - ShowResult(Convert.ToDouble(d) / 1.944); - } - else if (textTo == l.MilesPerHour) - { - ShowResult(Convert.ToDouble(d) * 1.151); - } - else if (textTo == l.YardsPerMinute) - { - ShowResult(Convert.ToDouble(d) * 33.756); - } - else if (textTo == l.FTsPerSecond) - { - ShowResult(Convert.ToDouble(d) * 1.688); - } - } - } - else if (cat == l.Force) - { - if (text == l.PoundsForce) - { - if (textTo == l.Newtons) - { - ShowResult(Convert.ToDouble(d) * 4.448); - } - else if (textTo == l.KilosForce) - { - ShowResult(Convert.ToDouble(d) / 2.205); - } - } - if (text == l.Newtons) - { - if (textTo == l.PoundsForce) - { - ShowResult(Convert.ToDouble(d) / 4.448); - } - else if (textTo == l.KilosForce) - { - ShowResult(Convert.ToDouble(d) / 9.807); - } - } - if (text == l.KilosForce) - { - if (textTo == l.PoundsForce) - { - ShowResult(Convert.ToDouble(d) * 2.205); - } - else if (textTo == l.Newtons) - { - ShowResult(Convert.ToDouble(d) * 9.807); - } - } - } - else if (cat == l.Energy) - { - if (text == l.Jouls) - { - if (textTo == l.Calories) - { - ShowResult(Convert.ToDouble(d) / 4.184); - } - else if (textTo == l.Ergs) - { - ShowResult(Convert.ToDouble(d) / 10000000); - } - else if (textTo == l.ElectronVolts) - { - ShowResult(Convert.ToDouble(d) * 6.242e+18); - } - else if (textTo == l.Btus) - { - ShowResult(Convert.ToDouble(d) / 1055); - } - } - else if (text == l.Calories) - { - if (textTo == l.Jouls) - { - ShowResult(Convert.ToDouble(d) * 4.184); - } - else if (textTo == l.Ergs) - { - ShowResult(Convert.ToDouble(d) * 41840000); - } - else if (textTo == l.ElectronVolts) - { - ShowResult(Convert.ToDouble(d) * 9.223e+18); - } - else if (textTo == l.Btus) - { - ShowResult(Convert.ToDouble(d) * 3.966); - } - } - else if (text == l.Ergs) - { - if (textTo == l.Jouls) - { - ShowResult(Convert.ToDouble(d) / 10000000); - } - else if (textTo == l.Calories) - { - ShowResult(Convert.ToDouble(d) / 4.184e+10); - } - else if (textTo == l.ElectronVolts) - { - ShowResult(Convert.ToDouble(d) * 6.242e+11); - } - else if (textTo == l.Btus) - { - ShowResult(Convert.ToDouble(d) / 1.055e+10); - } - } - else if (text == l.ElectronVolts) - { - if (textTo == l.Jouls) - { - ShowResult(Convert.ToDouble(d) / 6.242e+18); - } - else if (textTo == l.Calories) - { - ShowResult(Convert.ToDouble(d) / 9.223e+18); - } - else if (textTo == l.Ergs) - { - ShowResult(Convert.ToDouble(d) / 6.242e+11); - } - else if (textTo == l.Btus) - { - ShowResult(Convert.ToDouble(d) / 9.223e+18); - } - } - else if (text == l.Btus) - { - if (textTo == l.Jouls) - { - ShowResult(Convert.ToDouble(d) * 1055); - } - else if (textTo == l.Calories) - { - ShowResult(Convert.ToDouble(d) / 3.966); - } - else if (textTo == l.Ergs) - { - ShowResult(Convert.ToDouble(d) * 1.055e+10); - } - else if (textTo == l.ElectronVolts) - { - ShowResult(Convert.ToDouble(d) * 9.223e+18); - } - } - } - else if (cat == l.Power) - { - if (text == l.Watts) - { - if (textTo == l.Horsepower) - { - ShowResult(Convert.ToDouble(d) / 746); - } - } - else if (text == l.Horsepower) - { - if (textTo == l.Watts) - { - ShowResult(Convert.ToDouble(d) * 746); - } - } - } - else if (cat == l.Pressure) - { - if (text == l.Atmospheres) - { - if (textTo == l.Bars) - { - ShowResult(Convert.ToDouble(d) * 1.013); - } - else if (textTo == l.Pascals) - { - ShowResult(Convert.ToDouble(d) * 101325); - } - else if (textTo == l.MillimetersOfMercury) - { - ShowResult(Convert.ToDouble(d) * 760); - } - else if (textTo == l.PoundPerSquareInch) - { - ShowResult(Convert.ToDouble(d) * 14.696); - } - else if (textTo == l.KilogramPerSquareCentimeter) - { - ShowResult(Convert.ToDouble(d) * 1.033); - } - else if (textTo == l.KiloPascals) - { - ShowResult(Convert.ToDouble(d) * 101); - } - } - if (text == l.Bars) - { - if (textTo == l.Atmospheres) - { - ShowResult(Convert.ToDouble(d) / 1.013); - } - else if (textTo == l.Pascals) - { - ShowResult(Convert.ToDouble(d) * 100000); - } - else if (textTo == l.MillimetersOfMercury) - { - ShowResult(Convert.ToDouble(d) * 750); - } - else if (textTo == l.PoundPerSquareInch) - { - ShowResult(Convert.ToDouble(d) * 14.504); - } - else if (textTo == l.KilogramPerSquareCentimeter) - { - ShowResult(Convert.ToDouble(d) * 1.02); - } - else if (textTo == l.KiloPascals) - { - ShowResult(Convert.ToDouble(d) * 100); - } - } - if (text == l.Pascals) - { - if (textTo == l.Atmospheres) - { - ShowResult(Convert.ToDouble(d) / 101325); - } - else if (textTo == l.Bars) - { - ShowResult(Convert.ToDouble(d) / 100000); - } - else if (textTo == l.MillimetersOfMercury) - { - ShowResult(Convert.ToDouble(d) / 133); - } - else if (textTo == l.PoundPerSquareInch) - { - ShowResult(Convert.ToDouble(d) / 6895); - } - else if (textTo == l.KilogramPerSquareCentimeter) - { - ShowResult(Convert.ToDouble(d) / 98067); - } - else if (textTo == l.KiloPascals) - { - ShowResult(Convert.ToDouble(d) / 1000); - } - } - if (text == l.MillimetersOfMercury) - { - if (textTo == l.Atmospheres) - { - ShowResult(Convert.ToDouble(d) / 760); - } - else if (textTo == l.Bars) - { - ShowResult(Convert.ToDouble(d) / 750); - } - else if (textTo == l.Pascals) - { - ShowResult(Convert.ToDouble(d) * 133); - } - else if (textTo == l.PoundPerSquareInch) - { - ShowResult(Convert.ToDouble(d) / 51.715); - } - else if (textTo == l.KilogramPerSquareCentimeter) - { - ShowResult(Convert.ToDouble(d) / 736); - } - else if (textTo == l.KiloPascals) - { - ShowResult(Convert.ToDouble(d) / 7.501); - } - } - if (text == l.PoundPerSquareInch) - { - if (textTo == l.Atmospheres) - { - ShowResult(Convert.ToDouble(d) / 14.696); - } - else if (textTo == l.Bars) - { - ShowResult(Convert.ToDouble(d) / 14.504); - } - else if (textTo == l.Pascals) - { - ShowResult(Convert.ToDouble(d) * 6895); - } - else if (textTo == l.MillimetersOfMercury) - { - ShowResult(Convert.ToDouble(d) * 51.715); - } - else if (textTo == l.KilogramPerSquareCentimeter) - { - ShowResult(Convert.ToDouble(d) / 14.223); - } - else if (textTo == l.KiloPascals) - { - ShowResult(Convert.ToDouble(d) * 6.895); - } - } - if (text == l.KilogramPerSquareCentimeter) - { - if (textTo == l.Atmospheres) - { - ShowResult(Convert.ToDouble(d) / 1.033); - } - else if (textTo == l.Bars) - { - ShowResult(Convert.ToDouble(d) / 1.02); - } - else if (textTo == l.Pascals) - { - ShowResult(Convert.ToDouble(d) * 98067); - } - else if (textTo == l.MillimetersOfMercury) - { - ShowResult(Convert.ToDouble(d) * 736); - } - else if (textTo == l.PoundPerSquareInch) - { - ShowResult(Convert.ToDouble(d) * 14.223); - } - else if (textTo == l.KiloPascals) - { - ShowResult(Convert.ToDouble(d) * 98.066); - } - } - if (text == l.KiloPascals) - { - if (textTo == l.Atmospheres) - { - ShowResult(Convert.ToDouble(d) / 101); - } - else if (textTo == l.Bars) - { - ShowResult(Convert.ToDouble(d) / 100); - } - else if (textTo == l.Pascals) - { - ShowResult(Convert.ToDouble(d) * 1000); - } - else if (textTo == l.MillimetersOfMercury) - { - ShowResult(Convert.ToDouble(d) * 7.501); - } - else if (textTo == l.PoundPerSquareInch) - { - ShowResult(Convert.ToDouble(d) / 6.895); - } - else if (textTo == l.KilogramPerSquareCentimeter) - { - ShowResult(Convert.ToDouble(d) / 98.066); - } - } - } - } - - private void textBoxInput_KeyUp(object sender, KeyEventArgs e) - { - textBoxInput_TextChanged(null, null); - } - - private void textBoxInput_KeyPress(object sender, KeyPressEventArgs e) - { - if (char.IsControl(e.KeyChar) || char.IsDigit(e.KeyChar)) - { - return; - } - - if (e.KeyChar == '.' && !((sender as TextBox).Text.IndexOf('.') > -1) || e.KeyChar == ',' || e.KeyChar == '-' && !((sender as TextBox).Text.IndexOf('-') > -1)) - { - return; - } - - e.Handled = true; - } - - private void listBoxCategory_SelectedIndexChanged(object sender, EventArgs e) - { - string cat = listBoxCategory.SelectedItem.ToString(); - var l = Configuration.Settings.Language.MeasurementConverter; - - comboBoxFrom.Items.Clear(); - - if (cat == l.Length) - { - comboBoxFrom.Items.AddRange(_length.Cast().ToArray()); - } - else if (cat == l.Mass) - { - comboBoxFrom.Items.AddRange(_mass.Cast().ToArray()); - } - else if (cat == l.Volume) - { - comboBoxFrom.Items.AddRange(_volume.Cast().ToArray()); - } - else if (cat == l.Area) - { - comboBoxFrom.Items.AddRange(_area.Cast().ToArray()); - } - else if (cat == l.Time) - { - comboBoxFrom.Items.AddRange(_time.Cast().ToArray()); - } - else if (cat == l.Temperature) - { - comboBoxFrom.Items.AddRange(_temperature.Cast().ToArray()); - } - else if (cat == l.Velocity) - { - comboBoxFrom.Items.AddRange(_velocity.Cast().ToArray()); - } - else if (cat == l.Force) - { - comboBoxFrom.Items.AddRange(_force.Cast().ToArray()); - } - else if (cat == l.Energy) - { - comboBoxFrom.Items.AddRange(_energy.Cast().ToArray()); - } - else if (cat == l.Power) - { - comboBoxFrom.Items.AddRange(_power.Cast().ToArray()); - } - else if (cat == l.Pressure) - { - comboBoxFrom.Items.AddRange(_pressure.Cast().ToArray()); - } - - if (comboBoxFrom.Items.Count > 0) - { - if (comboBoxFrom.Items.Contains(_fields[1])) - { - comboBoxFrom.SelectedItem = _fields[1]; - } - else - { - comboBoxFrom.SelectedIndex = 0; - } - } - - comboBoxFrom_SelectedIndexChanged(null, null); - } - - private void listBoxCategory_LostFocus(object sender, EventArgs e) - { - // avoid flickering when losing focus - listBoxCategory.Update(); - } - - private void MeasurementConverter_Activated(object sender, EventArgs e) - { - Opacity = 1; - textBoxInput.Text = double.TryParse(Input, out _) ? Input : "1"; - } - - private void MeasurementConverter_FormClosed(object sender, FormClosedEventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void MeasurementConverter_Deactivate(object sender, EventArgs e) - { - if (DialogResult != DialogResult.Cancel) - { - Opacity = 0.5; - } - } - - private void MeasurementConverter_Load(object sender, EventArgs e) - { - CenterToParent(); - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class MeasurementConverter : Form + { + public class InsertEventArgs : EventArgs + { + public string Result { get; set; } + public bool IsOriginalActive { get; set; } + } + + public event EventHandler InsertClicked; + + public string Input { get; set; } + public bool IsOriginalActive { get; set; } + + private string Output { get; set; } + + private readonly Color _defaultBackColor; + + private readonly string[] _fields = Configuration.Settings.General.MeasurementConverterCategories.Split(';'); + + private readonly List _length = new List { Configuration.Settings.Language.MeasurementConverter.Kilometers, + Configuration.Settings.Language.MeasurementConverter.Meters, + Configuration.Settings.Language.MeasurementConverter.Centimeters, + Configuration.Settings.Language.MeasurementConverter.Millimeters, + Configuration.Settings.Language.MeasurementConverter.Micrometers, + Configuration.Settings.Language.MeasurementConverter.Nanometers, + Configuration.Settings.Language.MeasurementConverter.Angstroms, + Configuration.Settings.Language.MeasurementConverter.MilesTerrestial, + Configuration.Settings.Language.MeasurementConverter.MilesNautical, + Configuration.Settings.Language.MeasurementConverter.Yards, + Configuration.Settings.Language.MeasurementConverter.Feet, + Configuration.Settings.Language.MeasurementConverter.Inches, + Configuration.Settings.Language.MeasurementConverter.Chains, + Configuration.Settings.Language.MeasurementConverter.Fathoms, + Configuration.Settings.Language.MeasurementConverter.Hands, + Configuration.Settings.Language.MeasurementConverter.Rods, + Configuration.Settings.Language.MeasurementConverter.Spans }; + + private readonly List _mass = new List { Configuration.Settings.Language.MeasurementConverter.LongTonnes, + Configuration.Settings.Language.MeasurementConverter.ShortTonnes, + Configuration.Settings.Language.MeasurementConverter.Tonnes, + Configuration.Settings.Language.MeasurementConverter.Kilos, + Configuration.Settings.Language.MeasurementConverter.Grams, + Configuration.Settings.Language.MeasurementConverter.Milligrams, + Configuration.Settings.Language.MeasurementConverter.Micrograms, + Configuration.Settings.Language.MeasurementConverter.Pounds, + Configuration.Settings.Language.MeasurementConverter.Ounces, + Configuration.Settings.Language.MeasurementConverter.Carats, + Configuration.Settings.Language.MeasurementConverter.Drams, + Configuration.Settings.Language.MeasurementConverter.Grains, + Configuration.Settings.Language.MeasurementConverter.Stones }; + + private readonly List _volume = new List { Configuration.Settings.Language.MeasurementConverter.CubicKilometers, + Configuration.Settings.Language.MeasurementConverter.CubicMeters, + Configuration.Settings.Language.MeasurementConverter.Litres, + Configuration.Settings.Language.MeasurementConverter.CubicCentimeters, + Configuration.Settings.Language.MeasurementConverter.CubicMillimeters, + Configuration.Settings.Language.MeasurementConverter.CubicMiles, + Configuration.Settings.Language.MeasurementConverter.CubicYards, + Configuration.Settings.Language.MeasurementConverter.CubicFTs, + Configuration.Settings.Language.MeasurementConverter.CubicInches, + Configuration.Settings.Language.MeasurementConverter.OilBarrels, + Configuration.Settings.Language.MeasurementConverter.GallonUS, + Configuration.Settings.Language.MeasurementConverter.QuartsUS, + Configuration.Settings.Language.MeasurementConverter.PintsUS, + Configuration.Settings.Language.MeasurementConverter.FluidOuncesUS, + Configuration.Settings.Language.MeasurementConverter.Bushels, + Configuration.Settings.Language.MeasurementConverter.Pecks, + Configuration.Settings.Language.MeasurementConverter.GallonsUK, + Configuration.Settings.Language.MeasurementConverter.QuartsUK, + Configuration.Settings.Language.MeasurementConverter.PintsUK, + Configuration.Settings.Language.MeasurementConverter.FluidOuncesUK }; + + private readonly List _area = new List {Configuration.Settings.Language.MeasurementConverter.SquareKilometers, + Configuration.Settings.Language.MeasurementConverter.SquareMeters, + Configuration.Settings.Language.MeasurementConverter.SquareCentimeters, + Configuration.Settings.Language.MeasurementConverter.SquareMillimeters, + Configuration.Settings.Language.MeasurementConverter.SquareMiles, + Configuration.Settings.Language.MeasurementConverter.SquareYards, + Configuration.Settings.Language.MeasurementConverter.SquareFTs, + Configuration.Settings.Language.MeasurementConverter.SquareInches, + Configuration.Settings.Language.MeasurementConverter.Hectares, + Configuration.Settings.Language.MeasurementConverter.Acres, + Configuration.Settings.Language.MeasurementConverter.Ares }; + + private readonly List _time = new List { Configuration.Settings.Language.MeasurementConverter.Hours, + Configuration.Settings.Language.MeasurementConverter.Minutes, + Configuration.Settings.Language.MeasurementConverter.Seconds, + Configuration.Settings.Language.MeasurementConverter.Milliseconds, + Configuration.Settings.Language.MeasurementConverter.Microseconds }; + + private readonly List _temperature = new List { Configuration.Settings.Language.MeasurementConverter.Fahrenheit, + Configuration.Settings.Language.MeasurementConverter.Celsius, + Configuration.Settings.Language.MeasurementConverter.Kelvin }; + + private readonly List _velocity = new List { Configuration.Settings.Language.MeasurementConverter.KilometersPerHour, + Configuration.Settings.Language.MeasurementConverter.MetersPerSecond, + Configuration.Settings.Language.MeasurementConverter.MilesPerHour, + Configuration.Settings.Language.MeasurementConverter.YardsPerMinute, + Configuration.Settings.Language.MeasurementConverter.FTsPerSecond, + Configuration.Settings.Language.MeasurementConverter.Knots }; + + private readonly List _force = new List { Configuration.Settings.Language.MeasurementConverter.PoundsForce, + Configuration.Settings.Language.MeasurementConverter.Newtons, + Configuration.Settings.Language.MeasurementConverter.KilosForce }; + + private readonly List _energy = new List { Configuration.Settings.Language.MeasurementConverter.Jouls, + Configuration.Settings.Language.MeasurementConverter.Calories, + Configuration.Settings.Language.MeasurementConverter.Ergs, + Configuration.Settings.Language.MeasurementConverter.ElectronVolts, + Configuration.Settings.Language.MeasurementConverter.Btus }; + + private readonly List _power = new List { Configuration.Settings.Language.MeasurementConverter.Watts, + Configuration.Settings.Language.MeasurementConverter.Horsepower }; + + private readonly List _pressure = new List { Configuration.Settings.Language.MeasurementConverter.Atmospheres, + Configuration.Settings.Language.MeasurementConverter.Bars, + Configuration.Settings.Language.MeasurementConverter.Pascals, + Configuration.Settings.Language.MeasurementConverter.MillimetersOfMercury, + Configuration.Settings.Language.MeasurementConverter.PoundPerSquareInch, + Configuration.Settings.Language.MeasurementConverter.KilogramPerSquareCentimeter, + Configuration.Settings.Language.MeasurementConverter.KiloPascals }; + + public MeasurementConverter() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _defaultBackColor = Color.White; + var l = Configuration.Settings.Language.MeasurementConverter; + Text = l.Title; + labelConvertFrom.Text = l.ConvertFrom; + labelConvertTo.Text = l.ConvertTo; + linkLabel1.Text = l.CopyToClipboard; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + checkBoxCloseOnInsert.Checked = Configuration.Settings.General.MeasurementConverterCloseOnInsert; + + _defaultBackColor = textBoxInput.BackColor; + + listBoxCategory.Items.Add(l.Length); + listBoxCategory.Items.Add(l.Mass); + listBoxCategory.Items.Add(l.Volume); + listBoxCategory.Items.Add(l.Area); + listBoxCategory.Items.Add(l.Time); + listBoxCategory.Items.Add(l.Temperature); + listBoxCategory.Items.Add(l.Velocity); + listBoxCategory.Items.Add(l.Force); + listBoxCategory.Items.Add(l.Energy); + listBoxCategory.Items.Add(l.Power); + listBoxCategory.Items.Add(l.Pressure); + + listBoxCategory.SelectedItem = _fields[0]; + + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void comboBoxFrom_SelectedIndexChanged(object sender, EventArgs e) + { + string cat = listBoxCategory.SelectedItem.ToString(); + string text = comboBoxFrom.SelectedItem.ToString(); + var l = Configuration.Settings.Language.MeasurementConverter; + + comboBoxTo.Items.Clear(); + + if (cat == l.Length) + { + comboBoxTo.Items.AddRange(_length.Cast().ToArray()); + } + else if (cat == l.Mass) + { + comboBoxTo.Items.AddRange(_mass.Cast().ToArray()); + } + else if (cat == l.Volume) + { + comboBoxTo.Items.AddRange(_volume.Cast().ToArray()); + } + else if (cat == l.Area) + { + comboBoxTo.Items.AddRange(_area.Cast().ToArray()); + } + else if (cat == l.Time) + { + comboBoxTo.Items.AddRange(_time.Cast().ToArray()); + } + else if (cat == l.Temperature) + { + comboBoxTo.Items.AddRange(_temperature.Cast().ToArray()); + } + else if (cat == l.Velocity) + { + comboBoxTo.Items.AddRange(_velocity.Cast().ToArray()); + } + else if (cat == l.Force) + { + comboBoxTo.Items.AddRange(_force.Cast().ToArray()); + } + else if (cat == l.Energy) + { + comboBoxTo.Items.AddRange(_energy.Cast().ToArray()); + } + else if (cat == l.Power) + { + comboBoxTo.Items.AddRange(_power.Cast().ToArray()); + } + else if (cat == l.Pressure) + { + comboBoxTo.Items.AddRange(_pressure.Cast().ToArray()); + } + comboBoxTo.Items.Remove(text); + + if (comboBoxTo.Items.Count > 0) + { + if (comboBoxTo.Items.Contains(_fields[2])) + { + comboBoxTo.SelectedItem = _fields[2]; + } + else + { + comboBoxTo.SelectedIndex = 0; + } + } + + textBoxInput_TextChanged(null, null); + } + + private void ShowResult(double d) + { + textBoxResult.Text = $"{d:0.##}"; + Output = $"{d:0.##}"; + } + + private void comboBoxTo_SelectedIndexChanged(object sender, EventArgs e) + { + textBoxInput_TextChanged(null, null); + } + + private void buttonInsert_Click(object sender, EventArgs e) + { + InsertClicked?.Invoke(this, new InsertEventArgs { Result = Output, IsOriginalActive = IsOriginalActive }); + + if (checkBoxCloseOnInsert.Checked) + { + Configuration.Settings.General.MeasurementConverterCloseOnInsert = checkBoxCloseOnInsert.Checked; + Configuration.Settings.General.MeasurementConverterCategories = listBoxCategory.SelectedItem + ";" + comboBoxFrom.SelectedItem + ";" + comboBoxTo.SelectedItem; + Close(); + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + Configuration.Settings.General.MeasurementConverterCloseOnInsert = checkBoxCloseOnInsert.Checked; + Configuration.Settings.General.MeasurementConverterCategories = listBoxCategory.SelectedItem + ";" + comboBoxFrom.SelectedItem + ";" + comboBoxTo.SelectedItem; + Close(); + } + + private void MeasurementConverter_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + Close(); + } + } + + private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + if (textBoxResult.Text.Length > 0) + { + Clipboard.SetText(textBoxResult.Text); + } + } + + private void textBoxInput_TextChanged(object sender, EventArgs e) + { + if (comboBoxFrom.SelectedIndex == -1 || comboBoxTo.SelectedIndex == -1) + { + return; + } + + if (!double.TryParse(textBoxInput.Text, out var d)) + { + textBoxInput.BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + return; + } + + textBoxInput.BackColor = _defaultBackColor; + + string text = comboBoxFrom.SelectedItem.ToString(); + string textTo = comboBoxTo.SelectedItem.ToString(); + + string cat = listBoxCategory.SelectedItem.ToString(); + var l = Configuration.Settings.Language.MeasurementConverter; + + if (cat == l.Length) + { + if (text == l.Kilometers) + { + if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) * 100000); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 1000000); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 1000000000); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 1000000000000); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 10000000000000); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 1.609); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 1.852); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) * 1093.61); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) * 3280.84); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) * 39370.1); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) * 49.71); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) * 546.807); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) * 9842.52); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) * 198.839); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) * 4374.45); + } + } + else if (text == l.Meters) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) * 100); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 1000000); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 1000000000); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 10000000000); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 1609); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 1852); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) * 1.094); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) * 3.281); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) * 39.37); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 20.117); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) / 1.829); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) * 9.843); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) / 5.029); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) * 4.374); + } + } + else if (text == l.Centimeters) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 100000); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) / 100); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 10); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 10000); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 1e+7); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 1e+8); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 160934); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 185200); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) / 91.44); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) / 30.48); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) / 2.54); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 2012); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) / 183); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) / 10.16); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) / 503); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) / 22.86); + } + } + else if (text == l.Millimeters) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 1e+6); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) / 10); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 1e+6); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 1e+7); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 1.609e+6); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 1.852e+6); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) / 914); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) / 305); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) / 25.4); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 20117); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) / 1829); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) / 102); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) / 5029); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) / 229); + } + } + else if (text == l.Micrometers) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 1e+9); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) / 1e+6); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) / 10000); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 10000); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 1.609e+9); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 1.852e+9); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) / 914400); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) / 304800); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) / 25400); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 2.012e+7); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) / 1.829e+6); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) / 101600); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) / 5.029e+6); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) / 228600); + } + } + else if (text == l.Nanometers) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 1e+12); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) / 1e+9); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) / 1e+7); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) / 1e+6); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 10); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 1.609e+12); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 1.852e+12); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) / 9.144e+8); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) / 3.048e+8); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) / 2.54e+7); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 2.012e+10); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) / 1.829e+9); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) / 1.016e+8); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) / 5.029e+9); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) / 2.286e+8); + } + } + else if (text == l.Angstroms) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 1e+13); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) / 1e+10); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) / 1e+8); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) / 1e+7); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) / 10000); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) / 10); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 1.609e+13); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 1.852e+13); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) / 9.144e+9); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) / 3.048e+9); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) / 2.54e+8); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 2.012e+11); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) / 1.829e+10); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) / 1.016e+9); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) / 5.029e+10); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) / 2.286e+9); + } + } + else if (text == l.MilesTerrestial) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) * 1.609); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) * 1609); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) * 160934); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 1.609e+6); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 1.609e+9); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 1.609e+12); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 1.609e+13); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 1.151); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) * 1760); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) * 5280); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) * 63360); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) * 80); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) * 880); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) * 15840); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) * 320); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) * 7040); + } + } + else if (text == l.MilesNautical) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) * 1.852); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) * 1852); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) * 185200); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 1.852e+6); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 1.852e+9); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 1.852e+12); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 1.852e+13); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) * 1.151); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) * 2025); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) * 6076); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) * 72913); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) * 92.062); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) * 1013); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) * 18228); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) * 368); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) * 8101); + } + } + else if (text == l.Yards) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 1094); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) / 1.094); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) * 91.44); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 914); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 914400); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 9.144e+8); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 9.144e+9); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 1760); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 2025); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) * 3); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) * 36); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 22); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) / 2); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) * 9); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) / 5.5); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) * 4); + } + } + else if (text == l.Feet) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 3281); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) / 3.281); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) * 30.48); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 305); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 304800); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 3.048e+8); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 3.048e+9); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 5280); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 6076); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) / 3); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) * 12); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 66); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) / 6); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) * 3); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) / 16.5); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) * 1.333); + } + } + else if (text == l.Inches) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 39370); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) / 39.37); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) * 2.54); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 25.4); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 25400); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 2.54e+7); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 2.54e+8); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 63360); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 72913); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) / 36); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) / 12); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 792); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) / 72); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) / 4); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) / 198); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) / 9); + } + } + else if (text == l.Chains) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 49.71); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) * 20.117); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) * 2012); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 20117); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 2.012e+7); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 2.012e+10); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 2.012e+11); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 80); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 92.062); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) * 22); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) * 66); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) * 792); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) * 11); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) * 198); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) * 4); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) * 88); + } + } + else if (text == l.Fathoms) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 547); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) * 1.829); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) * 183); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 1829); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 1.829e+6); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 1.829e+9); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 1.829e+10); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 880); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 1013); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) * 2); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) * 6); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) * 72); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 11); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) * 18); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) / 2.75); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) * 8); + } + } + else if (text == l.Hands) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 9843); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) / 9.843); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) * 10.16); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 102); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 101600); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 1.016e+8); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 1.016e+9); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 15840); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 18228); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) / 9); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) / 3); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) * 4); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 198); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) / 18); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) / 49.5); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) / 2.25); + } + } + else if (text == l.Rods) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 199); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) * 5.029); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) * 503); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 5029); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 5.029e+6); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 5.029e+9); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 5.029e+10); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 320); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 368); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) * 5.5); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) * 16.5); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) * 198); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 4); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) * 2.75); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) * 49.5); + } + else if (textTo == l.Spans) + { + ShowResult(Convert.ToDouble(d) * 22); + } + } + else if (text == l.Spans) + { + if (textTo == l.Kilometers) + { + ShowResult(Convert.ToDouble(d) / 4374); + } + else if (textTo == l.Meters) + { + ShowResult(Convert.ToDouble(d) / 4.374); + } + else if (textTo == l.Centimeters) + { + ShowResult(Convert.ToDouble(d) * 22.86); + } + else if (textTo == l.Millimeters) + { + ShowResult(Convert.ToDouble(d) * 229); + } + else if (textTo == l.Micrometers) + { + ShowResult(Convert.ToDouble(d) * 228600); + } + else if (textTo == l.Nanometers) + { + ShowResult(Convert.ToDouble(d) * 2.286e+8); + } + else if (textTo == l.Angstroms) + { + ShowResult(Convert.ToDouble(d) * 2.286e+9); + } + else if (textTo == l.MilesTerrestial) + { + ShowResult(Convert.ToDouble(d) / 7040); + } + else if (textTo == l.MilesNautical) + { + ShowResult(Convert.ToDouble(d) / 8101); + } + else if (textTo == l.Yards) + { + ShowResult(Convert.ToDouble(d) / 4); + } + else if (textTo == l.Feet) + { + ShowResult(Convert.ToDouble(d) / 1.333); + } + else if (textTo == l.Inches) + { + ShowResult(Convert.ToDouble(d) * 9); + } + else if (textTo == l.Chains) + { + ShowResult(Convert.ToDouble(d) / 88); + } + else if (textTo == l.Fathoms) + { + ShowResult(Convert.ToDouble(d) / 8); + } + else if (textTo == l.Hands) + { + ShowResult(Convert.ToDouble(d) * 2.25); + } + else if (textTo == l.Rods) + { + ShowResult(Convert.ToDouble(d) / 22); + } + } + } + else if (cat == l.Mass) + { + if (text == l.LongTonnes) + { + if (textTo == l.ShortTonnes) + { + ShowResult(Convert.ToDouble(d) * 1.12); + } + else if (textTo == l.Tonnes) + { + ShowResult(Convert.ToDouble(d) * 1.016); + } + else if (textTo == l.Kilos) + { + ShowResult(Convert.ToDouble(d) * 1016); + } + else if (textTo == l.Grams) + { + ShowResult(Convert.ToDouble(d) * 1.016e+6); + } + else if (textTo == l.Milligrams) + { + ShowResult(Convert.ToDouble(d) * 1.016e+9); + } + else if (textTo == l.Micrograms) + { + ShowResult(Convert.ToDouble(d) * 1.016e+12); + } + else if (textTo == l.Pounds) + { + ShowResult(Convert.ToDouble(d) * 2240); + } + else if (textTo == l.Ounces) + { + ShowResult(Convert.ToDouble(d) * 35840); + } + else if (textTo == l.Carats) + { + ShowResult(Convert.ToDouble(d) * 5.08e+6); + } + else if (textTo == l.Drams) + { + ShowResult(Convert.ToDouble(d) * 573438); + } + else if (textTo == l.Grains) + { + ShowResult(Convert.ToDouble(d) * 1.568e+7); + } + else if (textTo == l.Stones) + { + ShowResult(Convert.ToDouble(d) * 160); + } + } + else if (text == l.ShortTonnes) + { + if (textTo == l.LongTonnes) + { + ShowResult(Convert.ToDouble(d) / 1.12); + } + else if (textTo == l.Tonnes) + { + ShowResult(Convert.ToDouble(d) / 1.102); + } + else if (textTo == l.Kilos) + { + ShowResult(Convert.ToDouble(d) * 907); + } + else if (textTo == l.Grams) + { + ShowResult(Convert.ToDouble(d) * 907185); + } + else if (textTo == l.Milligrams) + { + ShowResult(Convert.ToDouble(d) * 9.072e+8); + } + else if (textTo == l.Micrograms) + { + ShowResult(Convert.ToDouble(d) * 9.072e+11); + } + else if (textTo == l.Pounds) + { + ShowResult(Convert.ToDouble(d) * 2000); + } + else if (textTo == l.Ounces) + { + ShowResult(Convert.ToDouble(d) * 32000); + } + else if (textTo == l.Carats) + { + ShowResult(Convert.ToDouble(d) * 4.536e+6); + } + else if (textTo == l.Drams) + { + ShowResult(Convert.ToDouble(d) * 511999); + } + else if (textTo == l.Grains) + { + ShowResult(Convert.ToDouble(d) * 1.4e+7); + } + else if (textTo == l.Stones) + { + ShowResult(Convert.ToDouble(d) * 143); + } + } + else if (text == l.Tonnes) + { + if (textTo == l.LongTonnes) + { + ShowResult(Convert.ToDouble(d) / 1.016); + } + else if (textTo == l.ShortTonnes) + { + ShowResult(Convert.ToDouble(d) * 1.102); + } + else if (textTo == l.Kilos) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + else if (textTo == l.Grams) + { + ShowResult(Convert.ToDouble(d) * 1e+6); + } + else if (textTo == l.Milligrams) + { + ShowResult(Convert.ToDouble(d) * 1e+9); + } + else if (textTo == l.Micrograms) + { + ShowResult(Convert.ToDouble(d) * 1e+12); + } + else if (textTo == l.Pounds) + { + ShowResult(Convert.ToDouble(d) * 2205); + } + else if (textTo == l.Ounces) + { + ShowResult(Convert.ToDouble(d) * 35274); + } + else if (textTo == l.Carats) + { + ShowResult(Convert.ToDouble(d) * 5e+6); + } + else if (textTo == l.Drams) + { + ShowResult(Convert.ToDouble(d) * 564382); + } + else if (textTo == l.Grains) + { + ShowResult(Convert.ToDouble(d) * 1.543e+7); + } + else if (textTo == l.Stones) + { + ShowResult(Convert.ToDouble(d) * 157); + } + } + else if (text == l.Kilos) + { + if (textTo == l.LongTonnes) + { + ShowResult(Convert.ToDouble(d) / 1016); + } + else if (textTo == l.ShortTonnes) + { + ShowResult(Convert.ToDouble(d) / 907); + } + else if (textTo == l.Tonnes) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + else if (textTo == l.Grams) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + else if (textTo == l.Milligrams) + { + ShowResult(Convert.ToDouble(d) * 1e+6); + } + else if (textTo == l.Micrograms) + { + ShowResult(Convert.ToDouble(d) * 1e+9); + } + else if (textTo == l.Pounds) + { + ShowResult(Convert.ToDouble(d) * 2.205); + } + else if (textTo == l.Ounces) + { + ShowResult(Convert.ToDouble(d) * 35.274); + } + else if (textTo == l.Carats) + { + ShowResult(Convert.ToDouble(d) * 5000); + } + else if (textTo == l.Drams) + { + ShowResult(Convert.ToDouble(d) * 564); + } + else if (textTo == l.Grains) + { + ShowResult(Convert.ToDouble(d) * 15432); + } + else if (textTo == l.Stones) + { + ShowResult(Convert.ToDouble(d) / 6.35); + } + } + else if (text == l.Grams) + { + if (textTo == l.LongTonnes) + { + ShowResult(Convert.ToDouble(d) / 1.016e+6); + } + else if (textTo == l.ShortTonnes) + { + ShowResult(Convert.ToDouble(d) / 907185); + } + else if (textTo == l.Tonnes) + { + ShowResult(Convert.ToDouble(d) / 1e+6); + } + else if (textTo == l.Kilos) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + else if (textTo == l.Milligrams) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + else if (textTo == l.Micrograms) + { + ShowResult(Convert.ToDouble(d) * 1e+6); + } + else if (textTo == l.Pounds) + { + ShowResult(Convert.ToDouble(d) / 454); + } + else if (textTo == l.Ounces) + { + ShowResult(Convert.ToDouble(d) / 28.35); + } + else if (textTo == l.Carats) + { + ShowResult(Convert.ToDouble(d) * 5); + } + else if (textTo == l.Drams) + { + ShowResult(Convert.ToDouble(d) / 1.772); + } + else if (textTo == l.Grains) + { + ShowResult(Convert.ToDouble(d) * 15.432); + } + else if (textTo == l.Stones) + { + ShowResult(Convert.ToDouble(d) / 6350); + } + } + else if (text == l.Milligrams) + { + if (textTo == l.LongTonnes) + { + ShowResult(Convert.ToDouble(d) / 1.016e+9); + } + else if (textTo == l.ShortTonnes) + { + ShowResult(Convert.ToDouble(d) / 9.072e+8); + } + else if (textTo == l.Tonnes) + { + ShowResult(Convert.ToDouble(d) / 1e+9); + } + else if (textTo == l.Kilos) + { + ShowResult(Convert.ToDouble(d) / 1e+6); + } + else if (textTo == l.Grams) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + else if (textTo == l.Micrograms) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + else if (textTo == l.Pounds) + { + ShowResult(Convert.ToDouble(d) / 453592); + } + else if (textTo == l.Ounces) + { + ShowResult(Convert.ToDouble(d) / 28350); + } + else if (textTo == l.Carats) + { + ShowResult(Convert.ToDouble(d) / 200); + } + else if (textTo == l.Drams) + { + ShowResult(Convert.ToDouble(d) / 1772); + } + else if (textTo == l.Grains) + { + ShowResult(Convert.ToDouble(d) / 64.799); + } + else if (textTo == l.Stones) + { + ShowResult(Convert.ToDouble(d) / 6.35e+6); + } + } + else if (text == l.Micrograms) + { + if (textTo == l.LongTonnes) + { + ShowResult(Convert.ToDouble(d) / 1.016e+12); + } + else if (textTo == l.ShortTonnes) + { + ShowResult(Convert.ToDouble(d) / 9.072e+11); + } + else if (textTo == l.Tonnes) + { + ShowResult(Convert.ToDouble(d) / 1e+12); + } + else if (textTo == l.Kilos) + { + ShowResult(Convert.ToDouble(d) / 1e+9); + } + else if (textTo == l.Grams) + { + ShowResult(Convert.ToDouble(d) / 1e+6); + } + else if (textTo == l.Milligrams) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + else if (textTo == l.Pounds) + { + ShowResult(Convert.ToDouble(d) / 4.536e+8); + } + else if (textTo == l.Ounces) + { + ShowResult(Convert.ToDouble(d) / 2.835e+7); + } + else if (textTo == l.Carats) + { + ShowResult(Convert.ToDouble(d) / 200000); + } + else if (textTo == l.Drams) + { + ShowResult(Convert.ToDouble(d) / 1.772e+6); + } + else if (textTo == l.Grains) + { + ShowResult(Convert.ToDouble(d) / 64799); + } + else if (textTo == l.Stones) + { + ShowResult(Convert.ToDouble(d) / 6.35e+9); + } + } + else if (text == l.Pounds) + { + if (textTo == l.LongTonnes) + { + ShowResult(Convert.ToDouble(d) / 2240); + } + else if (textTo == l.ShortTonnes) + { + ShowResult(Convert.ToDouble(d) / 2000); + } + else if (textTo == l.Tonnes) + { + ShowResult(Convert.ToDouble(d) / 2205); + } + else if (textTo == l.Kilos) + { + ShowResult(Convert.ToDouble(d) / 2.205); + } + else if (textTo == l.Grams) + { + ShowResult(Convert.ToDouble(d) * 454); + } + else if (textTo == l.Milligrams) + { + ShowResult(Convert.ToDouble(d) * 453592); + } + else if (textTo == l.Micrograms) + { + ShowResult(Convert.ToDouble(d) * 4.536e+8); + } + else if (textTo == l.Ounces) + { + ShowResult(Convert.ToDouble(d) * 16); + } + else if (textTo == l.Carats) + { + ShowResult(Convert.ToDouble(d) * 2268); + } + else if (textTo == l.Drams) + { + ShowResult(Convert.ToDouble(d) * 256); + } + else if (textTo == l.Grains) + { + ShowResult(Convert.ToDouble(d) * 7000); + } + else if (textTo == l.Stones) + { + ShowResult(Convert.ToDouble(d) / 14); + } + } + else if (text == l.Ounces) + { + if (textTo == l.LongTonnes) + { + ShowResult(Convert.ToDouble(d) / 35840); + } + else if (textTo == l.ShortTonnes) + { + ShowResult(Convert.ToDouble(d) / 32000); + } + else if (textTo == l.Tonnes) + { + ShowResult(Convert.ToDouble(d) / 35274); + } + else if (textTo == l.Kilos) + { + ShowResult(Convert.ToDouble(d) / 35.274); + } + else if (textTo == l.Grams) + { + ShowResult(Convert.ToDouble(d) * 28.35); + } + else if (textTo == l.Milligrams) + { + ShowResult(Convert.ToDouble(d) * 28350); + } + else if (textTo == l.Micrograms) + { + ShowResult(Convert.ToDouble(d) * 2.835e+7); + } + else if (textTo == l.Pounds) + { + ShowResult(Convert.ToDouble(d) / 16); + } + else if (textTo == l.Carats) + { + ShowResult(Convert.ToDouble(d) * 142); + } + else if (textTo == l.Drams) + { + ShowResult(Convert.ToDouble(d) * 16); + } + else if (textTo == l.Grains) + { + ShowResult(Convert.ToDouble(d) * 438); + } + else if (textTo == l.Stones) + { + ShowResult(Convert.ToDouble(d) / 224); + } + } + else if (text == l.Carats) + { + if (textTo == l.LongTonnes) + { + ShowResult(Convert.ToDouble(d) / 5.08e+6); + } + else if (textTo == l.ShortTonnes) + { + ShowResult(Convert.ToDouble(d) / 4.536e+6); + } + else if (textTo == l.Tonnes) + { + ShowResult(Convert.ToDouble(d) / 5e+6); + } + else if (textTo == l.Kilos) + { + ShowResult(Convert.ToDouble(d) / 5000); + } + else if (textTo == l.Grams) + { + ShowResult(Convert.ToDouble(d) / 5); + } + else if (textTo == l.Milligrams) + { + ShowResult(Convert.ToDouble(d) * 200); + } + else if (textTo == l.Micrograms) + { + ShowResult(Convert.ToDouble(d) * 200000); + } + else if (textTo == l.Pounds) + { + ShowResult(Convert.ToDouble(d) / 2268); + } + else if (textTo == l.Ounces) + { + ShowResult(Convert.ToDouble(d) / 142); + } + else if (textTo == l.Drams) + { + ShowResult(Convert.ToDouble(d) / 8.859); + } + else if (textTo == l.Grains) + { + ShowResult(Convert.ToDouble(d) * 3.086); + } + else if (textTo == l.Stones) + { + ShowResult(Convert.ToDouble(d) / 31751); + } + } + else if (text == l.Drams) + { + if (textTo == l.LongTonnes) + { + ShowResult(Convert.ToDouble(d) / 573438); + } + else if (textTo == l.ShortTonnes) + { + ShowResult(Convert.ToDouble(d) / 511999); + } + else if (textTo == l.Tonnes) + { + ShowResult(Convert.ToDouble(d) / 564382); + } + else if (textTo == l.Kilos) + { + ShowResult(Convert.ToDouble(d) / 564); + } + else if (textTo == l.Grams) + { + ShowResult(Convert.ToDouble(d) * 1.772); + } + else if (textTo == l.Milligrams) + { + ShowResult(Convert.ToDouble(d) * 1772); + } + else if (textTo == l.Micrograms) + { + ShowResult(Convert.ToDouble(d) * 1.772e+6); + } + else if (textTo == l.Pounds) + { + ShowResult(Convert.ToDouble(d) / 256); + } + else if (textTo == l.Ounces) + { + ShowResult(Convert.ToDouble(d) / 16); + } + else if (textTo == l.Carats) + { + ShowResult(Convert.ToDouble(d) * 8.859); + } + else if (textTo == l.Grains) + { + ShowResult(Convert.ToDouble(d) * 27.344); + } + else if (textTo == l.Stones) + { + ShowResult(Convert.ToDouble(d) / 3584); + } + } + else if (text == l.Grains) + { + if (textTo == l.LongTonnes) + { + ShowResult(Convert.ToDouble(d) / 1.568e+7); + } + else if (textTo == l.ShortTonnes) + { + ShowResult(Convert.ToDouble(d) / 1.4e+7); + } + else if (textTo == l.Tonnes) + { + ShowResult(Convert.ToDouble(d) / 1.543e+7); + } + else if (textTo == l.Kilos) + { + ShowResult(Convert.ToDouble(d) / 15432); + } + else if (textTo == l.Grams) + { + ShowResult(Convert.ToDouble(d) / 15.432); + } + else if (textTo == l.Milligrams) + { + ShowResult(Convert.ToDouble(d) * 64.799); + } + else if (textTo == l.Micrograms) + { + ShowResult(Convert.ToDouble(d) * 64799); + } + else if (textTo == l.Pounds) + { + ShowResult(Convert.ToDouble(d) / 7000); + } + else if (textTo == l.Ounces) + { + ShowResult(Convert.ToDouble(d) / 438); + } + else if (textTo == l.Carats) + { + ShowResult(Convert.ToDouble(d) / 3.086); + } + else if (textTo == l.Drams) + { + ShowResult(Convert.ToDouble(d) / 27.344); + } + else if (textTo == l.Stones) + { + ShowResult(Convert.ToDouble(d) / 98000); + } + } + else if (text == l.Stones) + { + if (textTo == l.LongTonnes) + { + ShowResult(Convert.ToDouble(d) / 160); + } + else if (textTo == l.ShortTonnes) + { + ShowResult(Convert.ToDouble(d) / 143); + } + else if (textTo == l.Tonnes) + { + ShowResult(Convert.ToDouble(d) / 157); + } + else if (textTo == l.Kilos) + { + ShowResult(Convert.ToDouble(d) * 6.35); + } + else if (textTo == l.Grams) + { + ShowResult(Convert.ToDouble(d) * 6350); + } + else if (textTo == l.Milligrams) + { + ShowResult(Convert.ToDouble(d) * 6.35e+6); + } + else if (textTo == l.Micrograms) + { + ShowResult(Convert.ToDouble(d) * 6.35e+9); + } + else if (textTo == l.Pounds) + { + ShowResult(Convert.ToDouble(d) * 14); + } + else if (textTo == l.Ounces) + { + ShowResult(Convert.ToDouble(d) * 224); + } + else if (textTo == l.Carats) + { + ShowResult(Convert.ToDouble(d) * 31751); + } + else if (textTo == l.Drams) + { + ShowResult(Convert.ToDouble(d) * 3584); + } + else if (textTo == l.Grains) + { + ShowResult(Convert.ToDouble(d) * 98000); + } + } + } + else if (cat == l.Volume) + { + if (text == l.CubicKilometers) + { + if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) * 1e+9); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) * 1e+12); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 1e+15); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 1e+18); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 4.168); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) * 1.308e+9); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) * 3.531e+10); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 6.102e+13); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) * 6.29e+9); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) * 2.642e+11); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) * 1.057e+12); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 2.113e+12); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 3.381e+13); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) * 2.838e+10); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) * 1.135e+11); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) * 2.2e+11); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) * 8.799e+11); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 1.76e+12); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 3.52e+13); + } + } + else if (text == l.CubicMeters) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 1e+9); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 1e+6); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 1e+9); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 4.168e+9); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) * 1.308); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) * 35.315); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 61024); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) * 6.29); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) * 264); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) * 1057); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 2113); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 33814); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) * 28.378); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) * 114); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) * 220); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) * 880); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 1760); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 35195); + } + } + else if (text == l.Litres) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 1e+12); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 1e+6); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 4.168e+12); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 765); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 28.317); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 61.024); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 159); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) / 3.785); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) * 1.057); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 2.113); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 33.814); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 35.239); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) / 8.81); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) / 4.546); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) / 1.137); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 1.76); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 35.195); + } + } + else if (text == l.CubicCentimeters) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 1e+15); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 1e+6); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 4.168e+15); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 764555); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 28317); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) / 16.387); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 158987); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) / 3785); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) / 946); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) / 473); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) / 29.574); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 35239); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) / 8810); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) / 4546); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) / 1137); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) / 568); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) / 28.413); + } + } + else if (text == l.CubicMillimeters) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 1e+18); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 1e+9); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) / 1e+6); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 4.168e+18); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 7.646e+8); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 2.832e+7); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) / 16387); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 1.59e+8); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) / 3.785e+6); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) / 946353); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) / 473176); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) / 29574); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 3.524e+7); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) / 8.81e+6); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) / 4.546e+6); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) / 1.137e+6); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) / 568261); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) / 28413); + } + } + else if (text == l.CubicMiles) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) * 4.168); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) * 4.168e+9); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) * 4.168e+12); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 4.168e+15); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 4.168e+18); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) * 5.452e+9); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) * 1.472e+11); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 2.544e+14); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) * 2.622e+10); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) * 1.101e+12); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) * 4.404e+12); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 8.809e+12); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 1.409e+14); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) * 1.183e+11); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) * 4.731e+11); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) * 9.169e+11); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) * 3.667e+12); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 7.335e+12); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 1.467e+14); + } + } + else if (text == l.CubicYards) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 1.308e+9); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 1.308); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) * 765); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 764555); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 7.646e+8); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 5.452e+9); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) * 27); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 46656); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) * 4.809); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) * 202); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) * 808); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 1616); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 25853); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) * 21.696); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) * 86.785); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) * 168); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) * 673); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 1345); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 26909); + } + } + else if (text == l.CubicFTs) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 3.531e+10); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 35.315); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) * 28.317); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 28317); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 2.832e+7); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 1.472e+11); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 27); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 1728); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 5.615); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) * 7.481); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) * 29.922); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 59.844); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 958); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 1.244); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) * 3.214); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) * 6.229); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) * 24.915); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 49.831); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 997); + } + } + else if (text == l.CubicInches) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 6.102e+13); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 61024); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) / 61.024); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 16.387); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 16387); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 2.544e+14); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 46656); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 1728); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 9702); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) / 231); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) / 57.75); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) / 28.875); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) / 1.805); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 2150); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) / 538); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) / 277); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) / 69.355); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) / 34.677); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) / 1.734); + } + } + else if (text == l.OilBarrels) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 6.29e+9); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 6.29); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) * 159); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 158987); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 1.59e+8); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 2.622e+10); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 4.809); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) * 5.615); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 9702); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) * 42); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) * 168); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 336); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 5376); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) * 4.512); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) * 18.047); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) * 34.972); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) * 140); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 280); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 5596); + } + } + else if (text == l.GallonUS) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 2.642e+11); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 264); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) * 3.785); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 3785); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 3.785e+6); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 1.101e+12); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 202); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 7.481); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 231); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 42); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) * 4); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 8); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 128); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 9.309); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) / 2.327); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) / 1.201); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) * 3.331); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 6.661); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 133); + } + } + else if (text == l.QuartsUS) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 1.057e+12); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 1057); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) / 1.057); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 946); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 946353); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 4.404e+12); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 808); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 29.922); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 57.75); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 168); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) / 4); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 2); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 32); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 37.237); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) / 9.309); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) / 4.804); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) / 1.201); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 1.665); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 33.307); + } + } + else if (text == l.PintsUS) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 2.113e+12); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 2113); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) / 2.113); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 473); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 473176); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 8.809e+12); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 1616); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 59.844); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 28.875); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 336); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) / 8); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) / 2); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 16); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 74.473); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) / 18.618); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) / 9.608); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) / 2.402); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) / 1.201); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 16.653); + } + } + else if (text == l.FluidOuncesUS) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 3.381e+13); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 33814); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) / 33.814); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 29.574); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 29574); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 1.409e+14); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 25853); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 958); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 1.805); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 5376); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) / 128); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) / 32); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) / 16); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 1192); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) / 298); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) / 154); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) / 38.43); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) / 19.215); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 1.041); + } + } + else if (text == l.Bushels) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 2.838e+10); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 28.378); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) * 35.239); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 35239); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 3.524e+7); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 1.183e+11); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 21.696); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) * 1.244); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 2150); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 4.512); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) * 9.309); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) * 37.237); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 74.473); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 1192); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) * 4); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) * 7.752); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) * 31.006); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 62.012); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 1240); + } + } + else if (text == l.Pecks) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 1.135e+11); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 114); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) * 8.81); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 8810); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 8.81e+6); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 4.731e+11); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 86.785); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 3.214); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 538); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 18.047); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) * 2.327); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) * 9.309); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 18.618); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 298); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 4); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) * 1.938); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) * 7.752); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 15.503); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 310); + } + } + else if (text == l.GallonsUK) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 2.2e+11); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 220); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) * 4.546); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 4546); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 4.546e+6); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 9.169e+11); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 168); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 6.229); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 277); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 34.972); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) * 1.201); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) * 4.804); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 9.608); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 154); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 7.752); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) / 1.938); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) * 4); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 8); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 160); + } + } + else if (text == l.QuartsUK) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 2.2e+11); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 880); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) * 1.137); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 4546); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 4.546e+6); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 9.169e+11); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 168); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 24.915); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 69.355); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 34.972); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) / 3.331); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) * 1.201); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) * 2.402); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 38.43); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 7.752); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) / 1.938); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) / 4); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) * 4); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 160); + } + } + else if (text == l.PintsUK) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 1.76e+12); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 1760); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) / 1.76); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 568); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 568261); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 7.335e+12); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 1345); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 49.831); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 34.677); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 280); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) / 6.661); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) / 1.665); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d)); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) * 1.201); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 62.012); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) / 15.503); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) / 8); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) / 2); + } + else if (textTo == l.FluidOuncesUK) + { + ShowResult(Convert.ToDouble(d) * 20); + } + } + else if (text == l.FluidOuncesUK) + { + if (textTo == l.CubicKilometers) + { + ShowResult(Convert.ToDouble(d) / 3.52e+13); + } + else if (textTo == l.CubicMeters) + { + ShowResult(Convert.ToDouble(d) / 35195); + } + else if (textTo == l.Litres) + { + ShowResult(Convert.ToDouble(d) / 35.195); + } + else if (textTo == l.CubicCentimeters) + { + ShowResult(Convert.ToDouble(d) * 28.413); + } + else if (textTo == l.CubicMillimeters) + { + ShowResult(Convert.ToDouble(d) * 28413); + } + else if (textTo == l.CubicMiles) + { + ShowResult(Convert.ToDouble(d) / 1.467e+14); + } + else if (textTo == l.CubicYards) + { + ShowResult(Convert.ToDouble(d) / 26909); + } + else if (textTo == l.CubicFTs) + { + ShowResult(Convert.ToDouble(d) / 997); + } + else if (textTo == l.CubicInches) + { + ShowResult(Convert.ToDouble(d) * 1.734); + } + else if (textTo == l.OilBarrels) + { + ShowResult(Convert.ToDouble(d) / 5596); + } + else if (textTo == l.GallonUS) + { + ShowResult(Convert.ToDouble(d) / 133); + } + else if (textTo == l.QuartsUS) + { + ShowResult(Convert.ToDouble(d) / 33.307); + } + else if (textTo == l.PintsUS) + { + ShowResult(Convert.ToDouble(d) / 16.653); + } + else if (textTo == l.FluidOuncesUS) + { + ShowResult(Convert.ToDouble(d) / 1.041); + } + else if (textTo == l.Bushels) + { + ShowResult(Convert.ToDouble(d) / 1240); + } + else if (textTo == l.Pecks) + { + ShowResult(Convert.ToDouble(d) / 310); + } + else if (textTo == l.GallonsUK) + { + ShowResult(Convert.ToDouble(d) / 160); + } + else if (textTo == l.QuartsUK) + { + ShowResult(Convert.ToDouble(d) / 40); + } + else if (textTo == l.PintsUK) + { + ShowResult(Convert.ToDouble(d) / 20); + } + } + } + else if (cat == l.Area) + { + if (text == l.SquareKilometers) + { + if (textTo == l.SquareMeters) + { + ShowResult(Convert.ToDouble(d) * 1e+6); + } + else if (textTo == l.SquareCentimeters) + { + ShowResult(Convert.ToDouble(d) * 1e+10); + } + else if (textTo == l.SquareMillimeters) + { + ShowResult(Convert.ToDouble(d) * 1e+12); + } + else if (textTo == l.SquareMiles) + { + ShowResult(Convert.ToDouble(d) / 2.59); + } + else if (textTo == l.SquareYards) + { + ShowResult(Convert.ToDouble(d) * 1.196e+6); + } + else if (textTo == l.SquareFTs) + { + ShowResult(Convert.ToDouble(d) * 1.076e+7); + } + else if (textTo == l.SquareInches) + { + ShowResult(Convert.ToDouble(d) * 1.55e+9); + } + else if (textTo == l.Hectares) + { + ShowResult(Convert.ToDouble(d) * 100); + } + else if (textTo == l.Acres) + { + ShowResult(Convert.ToDouble(d) * 247); + } + else if (textTo == l.Ares) + { + ShowResult(Convert.ToDouble(d) * 10000); + } + } + else if (text == l.SquareMeters) + { + if (textTo == l.SquareKilometers) + { + ShowResult(Convert.ToDouble(d) / 1e+6); + } + else if (textTo == l.SquareCentimeters) + { + ShowResult(Convert.ToDouble(d) * 10000); + } + else if (textTo == l.SquareMillimeters) + { + ShowResult(Convert.ToDouble(d) * 1e+6); + } + else if (textTo == l.SquareMiles) + { + ShowResult(Convert.ToDouble(d) / 2.59e+6); + } + else if (textTo == l.SquareYards) + { + ShowResult(Convert.ToDouble(d) * 1.196); + } + else if (textTo == l.SquareFTs) + { + ShowResult(Convert.ToDouble(d) * 10.764); + } + else if (textTo == l.SquareInches) + { + ShowResult(Convert.ToDouble(d) * 1550); + } + else if (textTo == l.Hectares) + { + ShowResult(Convert.ToDouble(d) / 10000); + } + else if (textTo == l.Acres) + { + ShowResult(Convert.ToDouble(d) / 4047); + } + else if (textTo == l.Ares) + { + ShowResult(Convert.ToDouble(d) * 100); + } + } + else if (text == l.SquareCentimeters) + { + if (textTo == l.SquareKilometers) + { + ShowResult(Convert.ToDouble(d) / 1e+10); + } + else if (textTo == l.SquareMeters) + { + ShowResult(Convert.ToDouble(d) / 10000); + } + else if (textTo == l.SquareMillimeters) + { + ShowResult(Convert.ToDouble(d) * 100); + } + else if (textTo == l.SquareMiles) + { + ShowResult(Convert.ToDouble(d) / 2.59e+10); + } + else if (textTo == l.SquareYards) + { + ShowResult(Convert.ToDouble(d) / 8361); + } + else if (textTo == l.SquareFTs) + { + ShowResult(Convert.ToDouble(d) / 929); + } + else if (textTo == l.SquareInches) + { + ShowResult(Convert.ToDouble(d) / 6.452); + } + else if (textTo == l.Hectares) + { + ShowResult(Convert.ToDouble(d) / 1e+8); + } + else if (textTo == l.Acres) + { + ShowResult(Convert.ToDouble(d) / 4.047e+7); + } + else if (textTo == l.Ares) + { + ShowResult(Convert.ToDouble(d) / 1e+6); + } + } + else if (text == l.SquareMillimeters) + { + if (textTo == l.SquareKilometers) + { + ShowResult(Convert.ToDouble(d) / 1e+12); + } + else if (textTo == l.SquareMeters) + { + ShowResult(Convert.ToDouble(d) / 1e+6); + } + else if (textTo == l.SquareCentimeters) + { + ShowResult(Convert.ToDouble(d) / 100); + } + else if (textTo == l.SquareMiles) + { + ShowResult(Convert.ToDouble(d) / 2.59e+12); + } + else if (textTo == l.SquareYards) + { + ShowResult(Convert.ToDouble(d) / 836127); + } + else if (textTo == l.SquareFTs) + { + ShowResult(Convert.ToDouble(d) / 92903); + } + else if (textTo == l.SquareInches) + { + ShowResult(Convert.ToDouble(d) / 645); + } + else if (textTo == l.Hectares) + { + ShowResult(Convert.ToDouble(d) / 1e+10); + } + else if (textTo == l.Acres) + { + ShowResult(Convert.ToDouble(d) / 4.047e+9); + } + else if (textTo == l.Ares) + { + ShowResult(Convert.ToDouble(d) / 1e+8); + } + } + else if (text == l.SquareMiles) + { + if (textTo == l.SquareKilometers) + { + ShowResult(Convert.ToDouble(d) * 2.59); + } + else if (textTo == l.SquareMeters) + { + ShowResult(Convert.ToDouble(d) * 2.59e+6); + } + else if (textTo == l.SquareCentimeters) + { + ShowResult(Convert.ToDouble(d) * 2.59e+10); + } + else if (textTo == l.SquareMillimeters) + { + ShowResult(Convert.ToDouble(d) * 2.59e+12); + } + else if (textTo == l.SquareYards) + { + ShowResult(Convert.ToDouble(d) * 3.098e+6); + } + else if (textTo == l.SquareFTs) + { + ShowResult(Convert.ToDouble(d) * 2.788e+7); + } + else if (textTo == l.SquareInches) + { + ShowResult(Convert.ToDouble(d) * 4.014e+9); + } + else if (textTo == l.Hectares) + { + ShowResult(Convert.ToDouble(d) * 259); + } + else if (textTo == l.Acres) + { + ShowResult(Convert.ToDouble(d) * 640); + } + else if (textTo == l.Ares) + { + ShowResult(Convert.ToDouble(d) * 25900); + } + } + else if (text == l.SquareYards) + { + if (textTo == l.SquareKilometers) + { + ShowResult(Convert.ToDouble(d) / 1.196e+6); + } + else if (textTo == l.SquareMeters) + { + ShowResult(Convert.ToDouble(d) / 1.196); + } + else if (textTo == l.SquareCentimeters) + { + ShowResult(Convert.ToDouble(d) * 8361); + } + else if (textTo == l.SquareMillimeters) + { + ShowResult(Convert.ToDouble(d) * 836127); + } + else if (textTo == l.SquareMiles) + { + ShowResult(Convert.ToDouble(d) / 3.098e+6); + } + else if (textTo == l.SquareFTs) + { + ShowResult(Convert.ToDouble(d) * 9); + } + else if (textTo == l.SquareInches) + { + ShowResult(Convert.ToDouble(d) * 1296); + } + else if (textTo == l.Hectares) + { + ShowResult(Convert.ToDouble(d) / 11960); + } + else if (textTo == l.Acres) + { + ShowResult(Convert.ToDouble(d) / 4840); + } + else if (textTo == l.Ares) + { + ShowResult(Convert.ToDouble(d) / 120); + } + } + else if (text == l.SquareFTs) + { + if (textTo == l.SquareKilometers) + { + ShowResult(Convert.ToDouble(d) / 1.076e+7); + } + else if (textTo == l.SquareMeters) + { + ShowResult(Convert.ToDouble(d) / 10.764); + } + else if (textTo == l.SquareCentimeters) + { + ShowResult(Convert.ToDouble(d) * 929); + } + else if (textTo == l.SquareMillimeters) + { + ShowResult(Convert.ToDouble(d) * 92903); + } + else if (textTo == l.SquareMiles) + { + ShowResult(Convert.ToDouble(d) / 2.788e+7); + } + else if (textTo == l.SquareYards) + { + ShowResult(Convert.ToDouble(d) / 9); + } + else if (textTo == l.SquareInches) + { + ShowResult(Convert.ToDouble(d)); + } + else if (textTo == l.Hectares) + { + ShowResult(Convert.ToDouble(d) * 144); + } + else if (textTo == l.Acres) + { + ShowResult(Convert.ToDouble(d) / 43560); + } + else if (textTo == l.Ares) + { + ShowResult(Convert.ToDouble(d) / 1076); + } + } + else if (text == l.SquareInches) + { + if (textTo == l.SquareKilometers) + { + ShowResult(Convert.ToDouble(d) / 1.55e+9); + } + else if (textTo == l.SquareMeters) + { + ShowResult(Convert.ToDouble(d) / 1550); + } + else if (textTo == l.SquareCentimeters) + { + ShowResult(Convert.ToDouble(d) * 6.452); + } + else if (textTo == l.SquareMillimeters) + { + ShowResult(Convert.ToDouble(d) * 645); + } + else if (textTo == l.SquareMiles) + { + ShowResult(Convert.ToDouble(d) / 4.014e+9); + } + else if (textTo == l.SquareYards) + { + ShowResult(Convert.ToDouble(d) / 1296); + } + else if (textTo == l.SquareFTs) + { + ShowResult(Convert.ToDouble(d) / 144); + } + else if (textTo == l.Hectares) + { + ShowResult(Convert.ToDouble(d) / 1.55e+7); + } + else if (textTo == l.Acres) + { + ShowResult(Convert.ToDouble(d) / 6.273e+6); + } + else if (textTo == l.Ares) + { + ShowResult(Convert.ToDouble(d) / 6.273e+6); + } + } + else if (text == l.Hectares) + { + if (textTo == l.SquareKilometers) + { + ShowResult(Convert.ToDouble(d) / 100); + } + else if (textTo == l.SquareMeters) + { + ShowResult(Convert.ToDouble(d) * 10000); + } + else if (textTo == l.SquareCentimeters) + { + ShowResult(Convert.ToDouble(d) * 1e+8); + } + else if (textTo == l.SquareMillimeters) + { + ShowResult(Convert.ToDouble(d) * 1e+10); + } + else if (textTo == l.SquareMiles) + { + ShowResult(Convert.ToDouble(d) / 259); + } + else if (textTo == l.SquareYards) + { + ShowResult(Convert.ToDouble(d) * 11960); + } + else if (textTo == l.SquareFTs) + { + ShowResult(Convert.ToDouble(d) * 107639); + } + else if (textTo == l.SquareInches) + { + ShowResult(Convert.ToDouble(d) * 1.55e+7); + } + else if (textTo == l.Acres) + { + ShowResult(Convert.ToDouble(d) * 2.471); + } + else if (textTo == l.Ares) + { + ShowResult(Convert.ToDouble(d) * 100); + } + } + else if (text == l.Acres) + { + if (textTo == l.SquareKilometers) + { + ShowResult(Convert.ToDouble(d) / 247); + } + else if (textTo == l.SquareMeters) + { + ShowResult(Convert.ToDouble(d) * 4047); + } + else if (textTo == l.SquareCentimeters) + { + ShowResult(Convert.ToDouble(d) * 4.047e+7); + } + else if (textTo == l.SquareMillimeters) + { + ShowResult(Convert.ToDouble(d) * 4.047e+9); + } + else if (textTo == l.SquareMiles) + { + ShowResult(Convert.ToDouble(d) / 640); + } + else if (textTo == l.SquareYards) + { + ShowResult(Convert.ToDouble(d) * 4840); + } + else if (textTo == l.SquareFTs) + { + ShowResult(Convert.ToDouble(d) * 43560); + } + else if (textTo == l.SquareInches) + { + ShowResult(Convert.ToDouble(d) * 6.273e+6); + } + else if (textTo == l.Hectares) + { + ShowResult(Convert.ToDouble(d) / 2.471); + } + else if (textTo == l.Ares) + { + ShowResult(Convert.ToDouble(d) * 40.469); + } + } + else if (text == l.Ares) + { + if (textTo == l.SquareKilometers) + { + ShowResult(Convert.ToDouble(d) / 10000); + } + else if (textTo == l.SquareMeters) + { + ShowResult(Convert.ToDouble(d) * 100); + } + else if (textTo == l.SquareCentimeters) + { + ShowResult(Convert.ToDouble(d) * 1e+6); + } + else if (textTo == l.SquareMillimeters) + { + ShowResult(Convert.ToDouble(d) * 1e+8); + } + else if (textTo == l.SquareMiles) + { + ShowResult(Convert.ToDouble(d) / 25900); + } + else if (textTo == l.SquareYards) + { + ShowResult(Convert.ToDouble(d) * 120); + } + else if (textTo == l.SquareFTs) + { + ShowResult(Convert.ToDouble(d) * 1076); + } + else if (textTo == l.SquareInches) + { + ShowResult(Convert.ToDouble(d) * 155000); + } + else if (textTo == l.Hectares) + { + ShowResult(Convert.ToDouble(d) / 100); + } + else if (textTo == l.Acres) + { + ShowResult(Convert.ToDouble(d) / 40.469); + } + } + } + else if (cat == l.Time) + { + if (text == l.Hours) + { + if (textTo == l.Minutes) + { + ShowResult(Convert.ToDouble(d) * 60); + } + else if (textTo == l.Seconds) + { + ShowResult(Convert.ToDouble(d) * 3600); + } + else if (textTo == l.Milliseconds) + { + ShowResult(Convert.ToDouble(d) * 3.6e+6); + } + else if (textTo == l.Microseconds) + { + ShowResult(Convert.ToDouble(d) * 3.6e+9); + } + } + else if (text == l.Minutes) + { + if (textTo == l.Hours) + { + ShowResult(Convert.ToDouble(d) / 60); + } + else if (textTo == l.Seconds) + { + ShowResult(Convert.ToDouble(d) * 60); + } + else if (textTo == l.Milliseconds) + { + ShowResult(Convert.ToDouble(d) * 60000); + } + else if (textTo == l.Microseconds) + { + ShowResult(Convert.ToDouble(d) * 6e+7); + } + } + else if (text == l.Seconds) + { + if (textTo == l.Hours) + { + ShowResult(Convert.ToDouble(d) / 3600); + } + else if (textTo == l.Minutes) + { + ShowResult(Convert.ToDouble(d) / 60); + } + else if (textTo == l.Milliseconds) + { + ShowResult(Convert.ToDouble(d) * TimeCode.BaseUnit); + } + else if (textTo == l.Microseconds) + { + ShowResult(Convert.ToDouble(d) * 1e+6); + } + } + else if (text == l.Milliseconds) + { + if (textTo == l.Hours) + { + ShowResult(Convert.ToDouble(d) / 3.6e+6); + } + else if (textTo == l.Minutes) + { + ShowResult(Convert.ToDouble(d) / 60000); + } + else if (textTo == l.Seconds) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + else if (textTo == l.Microseconds) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + } + else if (text == l.Microseconds) + { + if (textTo == l.Hours) + { + ShowResult(Convert.ToDouble(d) / 3.6e+9); + } + else if (textTo == l.Minutes) + { + ShowResult(Convert.ToDouble(d) / 6e+7); + } + else if (textTo == l.Seconds) + { + ShowResult(Convert.ToDouble(d) / 1e+6); + } + else if (textTo == l.Milliseconds) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + } + } + else if (cat == l.Temperature) + { + if (text == l.Fahrenheit) + { + if (textTo == l.Celsius) + { + ShowResult((Convert.ToDouble(d) - 32) * 5 / 9); + } + else if (textTo == l.Kelvin) + { + ShowResult((Convert.ToDouble(d) - 32) * 5 / 9 + 273.15); + } + } + else if (text == l.Celsius) + { + if (textTo == l.Fahrenheit) + { + ShowResult(Convert.ToDouble(d) * 1.80 + 32); + } + else if (textTo == l.Kelvin) + { + ShowResult(Convert.ToDouble(d) + 273.15); + } + } + else if (text == l.Kelvin) + { + if (textTo == l.Fahrenheit) + { + ShowResult((Convert.ToDouble(d) - 273.15) * 9 / 5 + 32); + } + else if (textTo == l.Celsius) + { + ShowResult(Convert.ToDouble(d) - 273.15); + } + } + } + else if (cat == l.Velocity) + { + if (text == l.KilometersPerHour) + { + if (textTo == l.MetersPerSecond) + { + ShowResult(Convert.ToDouble(d) / 3.6); + } + else if (textTo == l.MilesPerHour) + { + ShowResult(Convert.ToDouble(d) / 1.609); + } + else if (textTo == l.YardsPerMinute) + { + ShowResult(Convert.ToDouble(d) * 18.227); + } + else if (textTo == l.FTsPerSecond) + { + ShowResult(Convert.ToDouble(d) / 1.097); + } + else if (textTo == l.Knots) + { + ShowResult(Convert.ToDouble(d) / 1.852); + } + } + if (text == l.MetersPerSecond) + { + if (textTo == l.KilometersPerHour) + { + ShowResult(Convert.ToDouble(d) * 3.6); + } + else if (textTo == l.MilesPerHour) + { + ShowResult(Convert.ToDouble(d) * 2.237); + } + else if (textTo == l.YardsPerMinute) + { + ShowResult(Convert.ToDouble(d) * 65.617); + } + else if (textTo == l.FTsPerSecond) + { + ShowResult(Convert.ToDouble(d) * 3.281); + } + else if (textTo == l.Knots) + { + ShowResult(Convert.ToDouble(d) * 1.944); + } + } + if (text == l.MilesPerHour) + { + if (textTo == l.KilometersPerHour) + { + ShowResult(Convert.ToDouble(d) * 1.609); + } + else if (textTo == l.MetersPerSecond) + { + ShowResult(Convert.ToDouble(d) / 2.237); + } + else if (textTo == l.YardsPerMinute) + { + ShowResult(Convert.ToDouble(d) * 29.333); + } + else if (textTo == l.FTsPerSecond) + { + ShowResult(Convert.ToDouble(d) * 1.467); + } + else if (textTo == l.Knots) + { + ShowResult(Convert.ToDouble(d) / 1.151); + } + } + if (text == l.YardsPerMinute) + { + if (textTo == l.KilometersPerHour) + { + ShowResult(Convert.ToDouble(d) / 18.227); + } + else if (textTo == l.MetersPerSecond) + { + ShowResult(Convert.ToDouble(d) / 65.617); + } + else if (textTo == l.MilesPerHour) + { + ShowResult(Convert.ToDouble(d) / 29.333); + } + else if (textTo == l.FTsPerSecond) + { + ShowResult(Convert.ToDouble(d) / 20); + } + else if (textTo == l.Knots) + { + ShowResult(Convert.ToDouble(d) / 33.756); + } + } + if (text == l.FTsPerSecond) + { + if (textTo == l.KilometersPerHour) + { + ShowResult(Convert.ToDouble(d) * 1.097); + } + else if (textTo == l.MetersPerSecond) + { + ShowResult(Convert.ToDouble(d) / 3.281); + } + else if (textTo == l.MilesPerHour) + { + ShowResult(Convert.ToDouble(d) / 1.467); + } + else if (textTo == l.YardsPerMinute) + { + ShowResult(Convert.ToDouble(d) * 20); + } + else if (textTo == l.Knots) + { + ShowResult(Convert.ToDouble(d) / 1.688); + } + } + if (text == l.Knots) + { + if (textTo == l.KilometersPerHour) + { + ShowResult(Convert.ToDouble(d) * 1.852); + } + else if (textTo == l.MetersPerSecond) + { + ShowResult(Convert.ToDouble(d) / 1.944); + } + else if (textTo == l.MilesPerHour) + { + ShowResult(Convert.ToDouble(d) * 1.151); + } + else if (textTo == l.YardsPerMinute) + { + ShowResult(Convert.ToDouble(d) * 33.756); + } + else if (textTo == l.FTsPerSecond) + { + ShowResult(Convert.ToDouble(d) * 1.688); + } + } + } + else if (cat == l.Force) + { + if (text == l.PoundsForce) + { + if (textTo == l.Newtons) + { + ShowResult(Convert.ToDouble(d) * 4.448); + } + else if (textTo == l.KilosForce) + { + ShowResult(Convert.ToDouble(d) / 2.205); + } + } + if (text == l.Newtons) + { + if (textTo == l.PoundsForce) + { + ShowResult(Convert.ToDouble(d) / 4.448); + } + else if (textTo == l.KilosForce) + { + ShowResult(Convert.ToDouble(d) / 9.807); + } + } + if (text == l.KilosForce) + { + if (textTo == l.PoundsForce) + { + ShowResult(Convert.ToDouble(d) * 2.205); + } + else if (textTo == l.Newtons) + { + ShowResult(Convert.ToDouble(d) * 9.807); + } + } + } + else if (cat == l.Energy) + { + if (text == l.Jouls) + { + if (textTo == l.Calories) + { + ShowResult(Convert.ToDouble(d) / 4.184); + } + else if (textTo == l.Ergs) + { + ShowResult(Convert.ToDouble(d) / 10000000); + } + else if (textTo == l.ElectronVolts) + { + ShowResult(Convert.ToDouble(d) * 6.242e+18); + } + else if (textTo == l.Btus) + { + ShowResult(Convert.ToDouble(d) / 1055); + } + } + else if (text == l.Calories) + { + if (textTo == l.Jouls) + { + ShowResult(Convert.ToDouble(d) * 4.184); + } + else if (textTo == l.Ergs) + { + ShowResult(Convert.ToDouble(d) * 41840000); + } + else if (textTo == l.ElectronVolts) + { + ShowResult(Convert.ToDouble(d) * 9.223e+18); + } + else if (textTo == l.Btus) + { + ShowResult(Convert.ToDouble(d) * 3.966); + } + } + else if (text == l.Ergs) + { + if (textTo == l.Jouls) + { + ShowResult(Convert.ToDouble(d) / 10000000); + } + else if (textTo == l.Calories) + { + ShowResult(Convert.ToDouble(d) / 4.184e+10); + } + else if (textTo == l.ElectronVolts) + { + ShowResult(Convert.ToDouble(d) * 6.242e+11); + } + else if (textTo == l.Btus) + { + ShowResult(Convert.ToDouble(d) / 1.055e+10); + } + } + else if (text == l.ElectronVolts) + { + if (textTo == l.Jouls) + { + ShowResult(Convert.ToDouble(d) / 6.242e+18); + } + else if (textTo == l.Calories) + { + ShowResult(Convert.ToDouble(d) / 9.223e+18); + } + else if (textTo == l.Ergs) + { + ShowResult(Convert.ToDouble(d) / 6.242e+11); + } + else if (textTo == l.Btus) + { + ShowResult(Convert.ToDouble(d) / 9.223e+18); + } + } + else if (text == l.Btus) + { + if (textTo == l.Jouls) + { + ShowResult(Convert.ToDouble(d) * 1055); + } + else if (textTo == l.Calories) + { + ShowResult(Convert.ToDouble(d) / 3.966); + } + else if (textTo == l.Ergs) + { + ShowResult(Convert.ToDouble(d) * 1.055e+10); + } + else if (textTo == l.ElectronVolts) + { + ShowResult(Convert.ToDouble(d) * 9.223e+18); + } + } + } + else if (cat == l.Power) + { + if (text == l.Watts) + { + if (textTo == l.Horsepower) + { + ShowResult(Convert.ToDouble(d) / 746); + } + } + else if (text == l.Horsepower) + { + if (textTo == l.Watts) + { + ShowResult(Convert.ToDouble(d) * 746); + } + } + } + else if (cat == l.Pressure) + { + if (text == l.Atmospheres) + { + if (textTo == l.Bars) + { + ShowResult(Convert.ToDouble(d) * 1.013); + } + else if (textTo == l.Pascals) + { + ShowResult(Convert.ToDouble(d) * 101325); + } + else if (textTo == l.MillimetersOfMercury) + { + ShowResult(Convert.ToDouble(d) * 760); + } + else if (textTo == l.PoundPerSquareInch) + { + ShowResult(Convert.ToDouble(d) * 14.696); + } + else if (textTo == l.KilogramPerSquareCentimeter) + { + ShowResult(Convert.ToDouble(d) * 1.033); + } + else if (textTo == l.KiloPascals) + { + ShowResult(Convert.ToDouble(d) * 101); + } + } + if (text == l.Bars) + { + if (textTo == l.Atmospheres) + { + ShowResult(Convert.ToDouble(d) / 1.013); + } + else if (textTo == l.Pascals) + { + ShowResult(Convert.ToDouble(d) * 100000); + } + else if (textTo == l.MillimetersOfMercury) + { + ShowResult(Convert.ToDouble(d) * 750); + } + else if (textTo == l.PoundPerSquareInch) + { + ShowResult(Convert.ToDouble(d) * 14.504); + } + else if (textTo == l.KilogramPerSquareCentimeter) + { + ShowResult(Convert.ToDouble(d) * 1.02); + } + else if (textTo == l.KiloPascals) + { + ShowResult(Convert.ToDouble(d) * 100); + } + } + if (text == l.Pascals) + { + if (textTo == l.Atmospheres) + { + ShowResult(Convert.ToDouble(d) / 101325); + } + else if (textTo == l.Bars) + { + ShowResult(Convert.ToDouble(d) / 100000); + } + else if (textTo == l.MillimetersOfMercury) + { + ShowResult(Convert.ToDouble(d) / 133); + } + else if (textTo == l.PoundPerSquareInch) + { + ShowResult(Convert.ToDouble(d) / 6895); + } + else if (textTo == l.KilogramPerSquareCentimeter) + { + ShowResult(Convert.ToDouble(d) / 98067); + } + else if (textTo == l.KiloPascals) + { + ShowResult(Convert.ToDouble(d) / 1000); + } + } + if (text == l.MillimetersOfMercury) + { + if (textTo == l.Atmospheres) + { + ShowResult(Convert.ToDouble(d) / 760); + } + else if (textTo == l.Bars) + { + ShowResult(Convert.ToDouble(d) / 750); + } + else if (textTo == l.Pascals) + { + ShowResult(Convert.ToDouble(d) * 133); + } + else if (textTo == l.PoundPerSquareInch) + { + ShowResult(Convert.ToDouble(d) / 51.715); + } + else if (textTo == l.KilogramPerSquareCentimeter) + { + ShowResult(Convert.ToDouble(d) / 736); + } + else if (textTo == l.KiloPascals) + { + ShowResult(Convert.ToDouble(d) / 7.501); + } + } + if (text == l.PoundPerSquareInch) + { + if (textTo == l.Atmospheres) + { + ShowResult(Convert.ToDouble(d) / 14.696); + } + else if (textTo == l.Bars) + { + ShowResult(Convert.ToDouble(d) / 14.504); + } + else if (textTo == l.Pascals) + { + ShowResult(Convert.ToDouble(d) * 6895); + } + else if (textTo == l.MillimetersOfMercury) + { + ShowResult(Convert.ToDouble(d) * 51.715); + } + else if (textTo == l.KilogramPerSquareCentimeter) + { + ShowResult(Convert.ToDouble(d) / 14.223); + } + else if (textTo == l.KiloPascals) + { + ShowResult(Convert.ToDouble(d) * 6.895); + } + } + if (text == l.KilogramPerSquareCentimeter) + { + if (textTo == l.Atmospheres) + { + ShowResult(Convert.ToDouble(d) / 1.033); + } + else if (textTo == l.Bars) + { + ShowResult(Convert.ToDouble(d) / 1.02); + } + else if (textTo == l.Pascals) + { + ShowResult(Convert.ToDouble(d) * 98067); + } + else if (textTo == l.MillimetersOfMercury) + { + ShowResult(Convert.ToDouble(d) * 736); + } + else if (textTo == l.PoundPerSquareInch) + { + ShowResult(Convert.ToDouble(d) * 14.223); + } + else if (textTo == l.KiloPascals) + { + ShowResult(Convert.ToDouble(d) * 98.066); + } + } + if (text == l.KiloPascals) + { + if (textTo == l.Atmospheres) + { + ShowResult(Convert.ToDouble(d) / 101); + } + else if (textTo == l.Bars) + { + ShowResult(Convert.ToDouble(d) / 100); + } + else if (textTo == l.Pascals) + { + ShowResult(Convert.ToDouble(d) * 1000); + } + else if (textTo == l.MillimetersOfMercury) + { + ShowResult(Convert.ToDouble(d) * 7.501); + } + else if (textTo == l.PoundPerSquareInch) + { + ShowResult(Convert.ToDouble(d) / 6.895); + } + else if (textTo == l.KilogramPerSquareCentimeter) + { + ShowResult(Convert.ToDouble(d) / 98.066); + } + } + } + } + + private void textBoxInput_KeyUp(object sender, KeyEventArgs e) + { + textBoxInput_TextChanged(null, null); + } + + private void textBoxInput_KeyPress(object sender, KeyPressEventArgs e) + { + if (char.IsControl(e.KeyChar) || char.IsDigit(e.KeyChar)) + { + return; + } + + if (e.KeyChar == '.' && !((sender as TextBox).Text.IndexOf('.') > -1) || e.KeyChar == ',' || e.KeyChar == '-' && !((sender as TextBox).Text.IndexOf('-') > -1)) + { + return; + } + + e.Handled = true; + } + + private void listBoxCategory_SelectedIndexChanged(object sender, EventArgs e) + { + string cat = listBoxCategory.SelectedItem.ToString(); + var l = Configuration.Settings.Language.MeasurementConverter; + + comboBoxFrom.Items.Clear(); + + if (cat == l.Length) + { + comboBoxFrom.Items.AddRange(_length.Cast().ToArray()); + } + else if (cat == l.Mass) + { + comboBoxFrom.Items.AddRange(_mass.Cast().ToArray()); + } + else if (cat == l.Volume) + { + comboBoxFrom.Items.AddRange(_volume.Cast().ToArray()); + } + else if (cat == l.Area) + { + comboBoxFrom.Items.AddRange(_area.Cast().ToArray()); + } + else if (cat == l.Time) + { + comboBoxFrom.Items.AddRange(_time.Cast().ToArray()); + } + else if (cat == l.Temperature) + { + comboBoxFrom.Items.AddRange(_temperature.Cast().ToArray()); + } + else if (cat == l.Velocity) + { + comboBoxFrom.Items.AddRange(_velocity.Cast().ToArray()); + } + else if (cat == l.Force) + { + comboBoxFrom.Items.AddRange(_force.Cast().ToArray()); + } + else if (cat == l.Energy) + { + comboBoxFrom.Items.AddRange(_energy.Cast().ToArray()); + } + else if (cat == l.Power) + { + comboBoxFrom.Items.AddRange(_power.Cast().ToArray()); + } + else if (cat == l.Pressure) + { + comboBoxFrom.Items.AddRange(_pressure.Cast().ToArray()); + } + + if (comboBoxFrom.Items.Count > 0) + { + if (comboBoxFrom.Items.Contains(_fields[1])) + { + comboBoxFrom.SelectedItem = _fields[1]; + } + else + { + comboBoxFrom.SelectedIndex = 0; + } + } + + comboBoxFrom_SelectedIndexChanged(null, null); + } + + private void listBoxCategory_LostFocus(object sender, EventArgs e) + { + // avoid flickering when losing focus + listBoxCategory.Update(); + } + + private void MeasurementConverter_Activated(object sender, EventArgs e) + { + Opacity = 1; + textBoxInput.Text = double.TryParse(Input, out _) ? Input : "1"; + } + + private void MeasurementConverter_FormClosed(object sender, FormClosedEventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void MeasurementConverter_Deactivate(object sender, EventArgs e) + { + if (DialogResult != DialogResult.Cancel) + { + Opacity = 0.5; + } + } + + private void MeasurementConverter_Load(object sender, EventArgs e) + { + CenterToParent(); + } + } +} diff --git a/src/Forms/ProfileChoose.resx b/src/ui/Forms/MeasurementConverter.resx similarity index 100% rename from src/Forms/ProfileChoose.resx rename to src/ui/Forms/MeasurementConverter.resx diff --git a/src/Forms/MergeDoubleLines.Designer.cs b/src/ui/Forms/MergeDoubleLines.Designer.cs similarity index 98% rename from src/Forms/MergeDoubleLines.Designer.cs rename to src/ui/Forms/MergeDoubleLines.Designer.cs index fb99a9606..9bb1b6ee1 100644 --- a/src/Forms/MergeDoubleLines.Designer.cs +++ b/src/ui/Forms/MergeDoubleLines.Designer.cs @@ -1,258 +1,258 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class MergeDoubleLines - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); - this.listViewFixes = new System.Windows.Forms.ListView(); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderText = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.checkBoxIncludeIncrementing = new System.Windows.Forms.CheckBox(); - this.numericUpDownMaxMillisecondsBetweenLines = new System.Windows.Forms.NumericUpDown(); - this.labelMaxMillisecondsBetweenLines = new System.Windows.Forms.Label(); - this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBoxLinesFound.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).BeginInit(); - this.contextMenuStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // columnHeader4 - // - this.columnHeader4.Text = "Apply"; - this.columnHeader4.Width = 45; - // - // groupBoxLinesFound - // - this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxLinesFound.Controls.Add(this.listViewFixes); - this.groupBoxLinesFound.Location = new System.Drawing.Point(15, 55); - this.groupBoxLinesFound.Name = "groupBoxLinesFound"; - this.groupBoxLinesFound.Size = new System.Drawing.Size(1025, 196); - this.groupBoxLinesFound.TabIndex = 45; - this.groupBoxLinesFound.TabStop = false; - this.groupBoxLinesFound.Text = "Lines that will be merged"; - // - // listViewFixes - // - this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewFixes.CheckBoxes = true; - this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader4, - this.columnHeader5, - this.columnHeaderText}); - this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; - this.listViewFixes.FullRowSelect = true; - this.listViewFixes.HideSelection = false; - this.listViewFixes.Location = new System.Drawing.Point(6, 19); - this.listViewFixes.Name = "listViewFixes"; - this.listViewFixes.Size = new System.Drawing.Size(1013, 177); - this.listViewFixes.TabIndex = 0; - this.listViewFixes.UseCompatibleStateImageBehavior = false; - this.listViewFixes.View = System.Windows.Forms.View.Details; - this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged); - // - // columnHeader5 - // - this.columnHeader5.Text = "Line#"; - this.columnHeader5.Width = 122; - // - // columnHeaderText - // - this.columnHeaderText.Text = "New text"; - this.columnHeaderText.Width = 500; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(884, 692); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 41; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(965, 692); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 42; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); - // - // checkBoxIncludeIncrementing - // - this.checkBoxIncludeIncrementing.AutoSize = true; - this.checkBoxIncludeIncrementing.Checked = true; - this.checkBoxIncludeIncrementing.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxIncludeIncrementing.Location = new System.Drawing.Point(306, 16); - this.checkBoxIncludeIncrementing.Name = "checkBoxIncludeIncrementing"; - this.checkBoxIncludeIncrementing.Size = new System.Drawing.Size(148, 17); - this.checkBoxIncludeIncrementing.TabIndex = 47; - this.checkBoxIncludeIncrementing.Text = "Include incrementing lines"; - this.checkBoxIncludeIncrementing.UseVisualStyleBackColor = true; - this.checkBoxIncludeIncrementing.CheckedChanged += new System.EventHandler(this.checkBoxFixIncrementing_CheckedChanged); - // - // numericUpDownMaxMillisecondsBetweenLines - // - this.numericUpDownMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(202, 15); - this.numericUpDownMaxMillisecondsBetweenLines.Maximum = new decimal(new int[] { - 10000, - 0, - 0, - 0}); - this.numericUpDownMaxMillisecondsBetweenLines.Name = "numericUpDownMaxMillisecondsBetweenLines"; - this.numericUpDownMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(64, 20); - this.numericUpDownMaxMillisecondsBetweenLines.TabIndex = 48; - this.numericUpDownMaxMillisecondsBetweenLines.Value = new decimal(new int[] { - 250, - 0, - 0, - 0}); - this.numericUpDownMaxMillisecondsBetweenLines.ValueChanged += new System.EventHandler(this.numericUpDownMaxMillisecondsBetweenLines_ValueChanged); - // - // labelMaxMillisecondsBetweenLines - // - this.labelMaxMillisecondsBetweenLines.AutoSize = true; - this.labelMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(18, 17); - this.labelMaxMillisecondsBetweenLines.Name = "labelMaxMillisecondsBetweenLines"; - this.labelMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(178, 13); - this.labelMaxMillisecondsBetweenLines.TabIndex = 49; - this.labelMaxMillisecondsBetweenLines.Text = "Maximum milliseconds between lines"; - // - // SubtitleListview1 - // - this.SubtitleListview1.AllowColumnReorder = true; - this.SubtitleListview1.AllowDrop = true; - this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.SubtitleListview1.FirstVisibleIndex = -1; - this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.SubtitleListview1.FullRowSelect = true; - this.SubtitleListview1.GridLines = true; - this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.SubtitleListview1.HideSelection = false; - this.SubtitleListview1.Location = new System.Drawing.Point(12, 257); - this.SubtitleListview1.Name = "SubtitleListview1"; - this.SubtitleListview1.OwnerDraw = true; - this.SubtitleListview1.Size = new System.Drawing.Size(1028, 429); - this.SubtitleListview1.SubtitleFontBold = false; - this.SubtitleListview1.SubtitleFontName = "Tahoma"; - this.SubtitleListview1.SubtitleFontSize = 8; - this.SubtitleListview1.TabIndex = 40; - this.SubtitleListview1.UseCompatibleStateImageBehavior = false; - this.SubtitleListview1.UseSyntaxColoring = true; - this.SubtitleListview1.View = System.Windows.Forms.View.Details; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemSelectAll, - this.toolStripMenuItemInverseSelection}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(162, 48); - // - // toolStripMenuItemSelectAll - // - this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; - this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemSelectAll.Text = "Select all"; - this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); - // - // toolStripMenuItemInverseSelection - // - this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; - this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; - this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); - // - // MergeDoubleLines - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1052, 725); - this.Controls.Add(this.numericUpDownMaxMillisecondsBetweenLines); - this.Controls.Add(this.labelMaxMillisecondsBetweenLines); - this.Controls.Add(this.checkBoxIncludeIncrementing); - this.Controls.Add(this.groupBoxLinesFound); - this.Controls.Add(this.SubtitleListview1); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.KeyPreview = true; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(750, 400); - this.Name = "MergeDoubleLines"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Merge lines with same text"; - this.Shown += new System.EventHandler(this.MergeDoubleLines_Shown); - this.ResizeEnd += new System.EventHandler(this.MergeDoubleLines_ResizeEnd); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MergeDoubleLines_KeyDown); - this.groupBoxLinesFound.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).EndInit(); - this.contextMenuStrip1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.GroupBox groupBoxLinesFound; - private System.Windows.Forms.ListView listViewFixes; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeaderText; - private Controls.SubtitleListView SubtitleListview1; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.CheckBox checkBoxIncludeIncrementing; - private System.Windows.Forms.NumericUpDown numericUpDownMaxMillisecondsBetweenLines; - private System.Windows.Forms.Label labelMaxMillisecondsBetweenLines; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class MergeDoubleLines + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); + this.listViewFixes = new System.Windows.Forms.ListView(); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderText = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.checkBoxIncludeIncrementing = new System.Windows.Forms.CheckBox(); + this.numericUpDownMaxMillisecondsBetweenLines = new System.Windows.Forms.NumericUpDown(); + this.labelMaxMillisecondsBetweenLines = new System.Windows.Forms.Label(); + this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBoxLinesFound.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).BeginInit(); + this.contextMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // columnHeader4 + // + this.columnHeader4.Text = "Apply"; + this.columnHeader4.Width = 45; + // + // groupBoxLinesFound + // + this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxLinesFound.Controls.Add(this.listViewFixes); + this.groupBoxLinesFound.Location = new System.Drawing.Point(15, 55); + this.groupBoxLinesFound.Name = "groupBoxLinesFound"; + this.groupBoxLinesFound.Size = new System.Drawing.Size(1025, 196); + this.groupBoxLinesFound.TabIndex = 45; + this.groupBoxLinesFound.TabStop = false; + this.groupBoxLinesFound.Text = "Lines that will be merged"; + // + // listViewFixes + // + this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewFixes.CheckBoxes = true; + this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader4, + this.columnHeader5, + this.columnHeaderText}); + this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; + this.listViewFixes.FullRowSelect = true; + this.listViewFixes.HideSelection = false; + this.listViewFixes.Location = new System.Drawing.Point(6, 19); + this.listViewFixes.Name = "listViewFixes"; + this.listViewFixes.Size = new System.Drawing.Size(1013, 177); + this.listViewFixes.TabIndex = 0; + this.listViewFixes.UseCompatibleStateImageBehavior = false; + this.listViewFixes.View = System.Windows.Forms.View.Details; + this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged); + // + // columnHeader5 + // + this.columnHeader5.Text = "Line#"; + this.columnHeader5.Width = 122; + // + // columnHeaderText + // + this.columnHeaderText.Text = "New text"; + this.columnHeaderText.Width = 500; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(884, 692); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 41; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(965, 692); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 42; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); + // + // checkBoxIncludeIncrementing + // + this.checkBoxIncludeIncrementing.AutoSize = true; + this.checkBoxIncludeIncrementing.Checked = true; + this.checkBoxIncludeIncrementing.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxIncludeIncrementing.Location = new System.Drawing.Point(306, 16); + this.checkBoxIncludeIncrementing.Name = "checkBoxIncludeIncrementing"; + this.checkBoxIncludeIncrementing.Size = new System.Drawing.Size(148, 17); + this.checkBoxIncludeIncrementing.TabIndex = 47; + this.checkBoxIncludeIncrementing.Text = "Include incrementing lines"; + this.checkBoxIncludeIncrementing.UseVisualStyleBackColor = true; + this.checkBoxIncludeIncrementing.CheckedChanged += new System.EventHandler(this.checkBoxFixIncrementing_CheckedChanged); + // + // numericUpDownMaxMillisecondsBetweenLines + // + this.numericUpDownMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(202, 15); + this.numericUpDownMaxMillisecondsBetweenLines.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.numericUpDownMaxMillisecondsBetweenLines.Name = "numericUpDownMaxMillisecondsBetweenLines"; + this.numericUpDownMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(64, 20); + this.numericUpDownMaxMillisecondsBetweenLines.TabIndex = 48; + this.numericUpDownMaxMillisecondsBetweenLines.Value = new decimal(new int[] { + 250, + 0, + 0, + 0}); + this.numericUpDownMaxMillisecondsBetweenLines.ValueChanged += new System.EventHandler(this.numericUpDownMaxMillisecondsBetweenLines_ValueChanged); + // + // labelMaxMillisecondsBetweenLines + // + this.labelMaxMillisecondsBetweenLines.AutoSize = true; + this.labelMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(18, 17); + this.labelMaxMillisecondsBetweenLines.Name = "labelMaxMillisecondsBetweenLines"; + this.labelMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(178, 13); + this.labelMaxMillisecondsBetweenLines.TabIndex = 49; + this.labelMaxMillisecondsBetweenLines.Text = "Maximum milliseconds between lines"; + // + // SubtitleListview1 + // + this.SubtitleListview1.AllowColumnReorder = true; + this.SubtitleListview1.AllowDrop = true; + this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.SubtitleListview1.FirstVisibleIndex = -1; + this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SubtitleListview1.FullRowSelect = true; + this.SubtitleListview1.GridLines = true; + this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.SubtitleListview1.HideSelection = false; + this.SubtitleListview1.Location = new System.Drawing.Point(12, 257); + this.SubtitleListview1.Name = "SubtitleListview1"; + this.SubtitleListview1.OwnerDraw = true; + this.SubtitleListview1.Size = new System.Drawing.Size(1028, 429); + this.SubtitleListview1.SubtitleFontBold = false; + this.SubtitleListview1.SubtitleFontName = "Tahoma"; + this.SubtitleListview1.SubtitleFontSize = 8; + this.SubtitleListview1.TabIndex = 40; + this.SubtitleListview1.UseCompatibleStateImageBehavior = false; + this.SubtitleListview1.UseSyntaxColoring = true; + this.SubtitleListview1.View = System.Windows.Forms.View.Details; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSelectAll, + this.toolStripMenuItemInverseSelection}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(162, 48); + // + // toolStripMenuItemSelectAll + // + this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; + this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemSelectAll.Text = "Select all"; + this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); + // + // toolStripMenuItemInverseSelection + // + this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; + this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; + this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); + // + // MergeDoubleLines + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1052, 725); + this.Controls.Add(this.numericUpDownMaxMillisecondsBetweenLines); + this.Controls.Add(this.labelMaxMillisecondsBetweenLines); + this.Controls.Add(this.checkBoxIncludeIncrementing); + this.Controls.Add(this.groupBoxLinesFound); + this.Controls.Add(this.SubtitleListview1); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.KeyPreview = true; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(750, 400); + this.Name = "MergeDoubleLines"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Merge lines with same text"; + this.Shown += new System.EventHandler(this.MergeDoubleLines_Shown); + this.ResizeEnd += new System.EventHandler(this.MergeDoubleLines_ResizeEnd); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MergeDoubleLines_KeyDown); + this.groupBoxLinesFound.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).EndInit(); + this.contextMenuStrip1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.GroupBox groupBoxLinesFound; + private System.Windows.Forms.ListView listViewFixes; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeaderText; + private Controls.SubtitleListView SubtitleListview1; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.CheckBox checkBoxIncludeIncrementing; + private System.Windows.Forms.NumericUpDown numericUpDownMaxMillisecondsBetweenLines; + private System.Windows.Forms.Label labelMaxMillisecondsBetweenLines; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; + } } \ No newline at end of file diff --git a/src/Forms/MergeDoubleLines.cs b/src/ui/Forms/MergeDoubleLines.cs similarity index 97% rename from src/Forms/MergeDoubleLines.cs rename to src/ui/Forms/MergeDoubleLines.cs index f1f2ee7e5..8a49a54bd 100644 --- a/src/Forms/MergeDoubleLines.cs +++ b/src/ui/Forms/MergeDoubleLines.cs @@ -1,348 +1,348 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class MergeDoubleLines : PositionAndSizeForm - { - private Subtitle _subtitle; - private bool _loading = true; - private readonly Timer _previewTimer = new Timer(); - - public int NumberOfMerges { get; private set; } - public Subtitle MergedSubtitle { get; private set; } - - public MergeDoubleLines() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _previewTimer.Tick += previewTimer_Tick; - _previewTimer.Interval = 250; - UiUtil.FixLargeFonts(this, buttonOK); - } - - public void Initialize(Subtitle subtitle) - { - if (subtitle.Paragraphs.Count > 0) - { - subtitle.Renumber(subtitle.Paragraphs[0].Number); - } - - Text = Configuration.Settings.Language.MergeDoubleLines.Title; - labelMaxMillisecondsBetweenLines.Text = Configuration.Settings.Language.MergeDoubleLines.MaxMillisecondsBetweenLines; - checkBoxIncludeIncrementing.Text = Configuration.Settings.Language.MergeDoubleLines.IncludeIncrementing; - numericUpDownMaxMillisecondsBetweenLines.Left = labelMaxMillisecondsBetweenLines.Left + labelMaxMillisecondsBetweenLines.Width + 3; - checkBoxIncludeIncrementing.Left = numericUpDownMaxMillisecondsBetweenLines.Left + numericUpDownMaxMillisecondsBetweenLines.Width + 10; - - listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; - listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; - listViewFixes.Columns[2].Text = Configuration.Settings.Language.MergedShortLines.MergedText; - - toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; - toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.AutoSizeAllColumns(this); - NumberOfMerges = 0; - _subtitle = subtitle; - MergeDoubleLines_ResizeEnd(null, null); - } - - private void AddToListView(Paragraph p, string lineNumbers, string newText) - { - var item = new ListViewItem(string.Empty) { Tag = p, Checked = true }; - item.SubItems.Add(lineNumbers.TrimEnd(',')); - item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); - listViewFixes.Items.Add(item); - } - - private void GeneratePreview() - { - if (_subtitle == null) - { - return; - } - - NumberOfMerges = 0; - SubtitleListview1.Items.Clear(); - SubtitleListview1.BeginUpdate(); - MergedSubtitle = MergeLinesWithSameTextInSubtitle(_subtitle, out var count, true, checkBoxIncludeIncrementing.Checked, true, (int)numericUpDownMaxMillisecondsBetweenLines.Value); - NumberOfMerges = count; - - SubtitleListview1.Fill(_subtitle); - - UpdateBackgroundColor(); - - SubtitleListview1.EndUpdate(); - groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.MergedShortLines.NumberOfMergesX, NumberOfMerges); - } - - private bool IsFixAllowed(Paragraph p) - { - foreach (ListViewItem item in listViewFixes.Items) - { - string numbers = item.SubItems[1].Text; - foreach (string number in numbers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) - { - if (number == p.Number.ToString(CultureInfo.InvariantCulture)) - { - return item.Checked; - } - } - } - return true; - } - - public Subtitle MergeLinesWithSameTextInSubtitle(Subtitle subtitle, out int numberOfMerges, bool clearFixes, bool fixIncrementing, bool lineAfterNext, int maxMsBetween) - { - var mergedIndexes = new List(); - var removed = new List(); - if (!_loading) - { - listViewFixes.ItemChecked -= listViewFixes_ItemChecked; - } - - if (clearFixes) - { - listViewFixes.Items.Clear(); - } - - numberOfMerges = 0; - var mergedSubtitle = new Subtitle(); - Paragraph p = null; - var lineNumbers = new StringBuilder(); - for (int i = 1; i < subtitle.Paragraphs.Count; i++) - { - if (removed.Contains(i - 1)) - { - continue; - } - - p = new Paragraph(subtitle.GetParagraphOrDefault(i - 1)); - mergedSubtitle.Paragraphs.Add(p); - - for (int j = i; j < subtitle.Paragraphs.Count; j++) - { - if (removed.Contains(j)) - { - continue; - } - - var next = subtitle.GetParagraphOrDefault(j); - var incrementText = string.Empty; - if ((MergeLinesSameTextUtils.QualifiesForMerge(p, next, maxMsBetween) || fixIncrementing && MergeLinesSameTextUtils.QualifiesForMergeIncrement(p, next, maxMsBetween, out incrementText)) && IsFixAllowed(p)) - { - p.Text = next.Text; - if (!string.IsNullOrEmpty(incrementText)) - { - p.Text = incrementText; - } - - p.EndTime.TotalMilliseconds = next.EndTime.TotalMilliseconds; - if (lineNumbers.Length > 0) - { - lineNumbers.Append(next.Number); - lineNumbers.Append(','); - } - else - { - lineNumbers.Append(p.Number); - lineNumbers.Append(','); - lineNumbers.Append(next.Number); - lineNumbers.Append(','); - } - - removed.Add(j); - numberOfMerges++; - if (!mergedIndexes.Contains(j)) - { - mergedIndexes.Add(j); - } - - if (!mergedIndexes.Contains(i - 1)) - { - mergedIndexes.Add(i - 1); - } - } - } - - if (!removed.Contains(i - 1) && lineNumbers.Length > 0 && clearFixes) - { - AddToListView(p, lineNumbers.ToString(), p.Text); - lineNumbers.Clear(); - } - } - - if (lineNumbers.Length > 0 && clearFixes && p != null) - { - AddToListView(p, lineNumbers.ToString(), p.Text); - } - - if (!mergedIndexes.Contains(subtitle.Paragraphs.Count - 1)) - { - mergedSubtitle.Paragraphs.Add(new Paragraph(subtitle.GetParagraphOrDefault(subtitle.Paragraphs.Count - 1))); - } - - if (!_loading) - { - listViewFixes.ItemChecked += listViewFixes_ItemChecked; - } - - mergedSubtitle.Renumber(); - return mergedSubtitle; - } - - private void ButtonCancelClick(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void ButtonOkClick(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e) - { - if (listViewFixes.SelectedIndices.Count > 0) - { - int index = listViewFixes.SelectedIndices[0]; - ListViewItem item = listViewFixes.Items[index]; - var numbers = item.SubItems[1].Text.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - foreach (string number in numbers) - { - foreach (var p in _subtitle.Paragraphs) - { - if (p.Number.ToString(CultureInfo.InvariantCulture) == number) - { - index = _subtitle.GetIndex(p); - SubtitleListview1.EnsureVisible(index); - } - } - } - } - } - - private void listViewFixes_ItemChecked(object sender, ItemCheckedEventArgs e) - { - if (_loading) - { - return; - } - - NumberOfMerges = 0; - SubtitleListview1.Items.Clear(); - SubtitleListview1.BeginUpdate(); - MergedSubtitle = MergeLinesWithSameTextInSubtitle(_subtitle, out var count, false, checkBoxIncludeIncrementing.Checked, true, (int)numericUpDownMaxMillisecondsBetweenLines.Value); - NumberOfMerges = count; - SubtitleListview1.Fill(_subtitle); - UpdateBackgroundColor(); - SubtitleListview1.EndUpdate(); - groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.MergedShortLines.NumberOfMergesX, NumberOfMerges); - } - - private void UpdateBackgroundColor() - { - var colors = new List - { - Color.Green, - Color.LimeGreen, - Color.GreenYellow, - }; - int colorIdx = 0; - - for (int i = 0; i < listViewFixes.Items.Count; i++) - { - ListViewItem item = listViewFixes.Items[i]; - var lineNumbers = item.SubItems[1].Text; - if (item.Checked && !string.IsNullOrEmpty(lineNumbers)) - { - var numbers = lineNumbers.Split(','); - foreach (var number in numbers) - { - SubtitleListview1.SetBackgroundColor(Convert.ToInt32(number) - 1, colors[colorIdx]); - } - - colorIdx++; - if (colorIdx >= colors.Count) - { - colorIdx = 0; - } - } - } - } - - private void MergeDoubleLines_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void MergeDoubleLines_Shown(object sender, EventArgs e) - { - GeneratePreview(); - listViewFixes.Focus(); - if (listViewFixes.Items.Count > 0) - { - listViewFixes.Items[0].Selected = true; - } - - _loading = false; - listViewFixes.ItemChecked += listViewFixes_ItemChecked; - } - - private void checkBoxFixIncrementing_CheckedChanged(object sender, EventArgs e) - { - Cursor = Cursors.WaitCursor; - GeneratePreview(); - Cursor = Cursors.Default; - } - - private void numericUpDownMaxMillisecondsBetweenLines_ValueChanged(object sender, EventArgs e) - { - _previewTimer.Stop(); - _previewTimer.Start(); - } - - private void previewTimer_Tick(object sender, EventArgs e) - { - _previewTimer.Stop(); - Cursor = Cursors.WaitCursor; - GeneratePreview(); - Cursor = Cursors.Default; - } - - private void MergeDoubleLines_ResizeEnd(object sender, EventArgs e) - { - columnHeaderText.Width = -2; - } - - private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = true; - } - } - - private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = !item.Checked; - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class MergeDoubleLines : PositionAndSizeForm + { + private Subtitle _subtitle; + private bool _loading = true; + private readonly Timer _previewTimer = new Timer(); + + public int NumberOfMerges { get; private set; } + public Subtitle MergedSubtitle { get; private set; } + + public MergeDoubleLines() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _previewTimer.Tick += previewTimer_Tick; + _previewTimer.Interval = 250; + UiUtil.FixLargeFonts(this, buttonOK); + } + + public void Initialize(Subtitle subtitle) + { + if (subtitle.Paragraphs.Count > 0) + { + subtitle.Renumber(subtitle.Paragraphs[0].Number); + } + + Text = Configuration.Settings.Language.MergeDoubleLines.Title; + labelMaxMillisecondsBetweenLines.Text = Configuration.Settings.Language.MergeDoubleLines.MaxMillisecondsBetweenLines; + checkBoxIncludeIncrementing.Text = Configuration.Settings.Language.MergeDoubleLines.IncludeIncrementing; + numericUpDownMaxMillisecondsBetweenLines.Left = labelMaxMillisecondsBetweenLines.Left + labelMaxMillisecondsBetweenLines.Width + 3; + checkBoxIncludeIncrementing.Left = numericUpDownMaxMillisecondsBetweenLines.Left + numericUpDownMaxMillisecondsBetweenLines.Width + 10; + + listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; + listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; + listViewFixes.Columns[2].Text = Configuration.Settings.Language.MergedShortLines.MergedText; + + toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; + toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.AutoSizeAllColumns(this); + NumberOfMerges = 0; + _subtitle = subtitle; + MergeDoubleLines_ResizeEnd(null, null); + } + + private void AddToListView(Paragraph p, string lineNumbers, string newText) + { + var item = new ListViewItem(string.Empty) { Tag = p, Checked = true }; + item.SubItems.Add(lineNumbers.TrimEnd(',')); + item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); + listViewFixes.Items.Add(item); + } + + private void GeneratePreview() + { + if (_subtitle == null) + { + return; + } + + NumberOfMerges = 0; + SubtitleListview1.Items.Clear(); + SubtitleListview1.BeginUpdate(); + MergedSubtitle = MergeLinesWithSameTextInSubtitle(_subtitle, out var count, true, checkBoxIncludeIncrementing.Checked, true, (int)numericUpDownMaxMillisecondsBetweenLines.Value); + NumberOfMerges = count; + + SubtitleListview1.Fill(_subtitle); + + UpdateBackgroundColor(); + + SubtitleListview1.EndUpdate(); + groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.MergedShortLines.NumberOfMergesX, NumberOfMerges); + } + + private bool IsFixAllowed(Paragraph p) + { + foreach (ListViewItem item in listViewFixes.Items) + { + string numbers = item.SubItems[1].Text; + foreach (string number in numbers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) + { + if (number == p.Number.ToString(CultureInfo.InvariantCulture)) + { + return item.Checked; + } + } + } + return true; + } + + public Subtitle MergeLinesWithSameTextInSubtitle(Subtitle subtitle, out int numberOfMerges, bool clearFixes, bool fixIncrementing, bool lineAfterNext, int maxMsBetween) + { + var mergedIndexes = new List(); + var removed = new List(); + if (!_loading) + { + listViewFixes.ItemChecked -= listViewFixes_ItemChecked; + } + + if (clearFixes) + { + listViewFixes.Items.Clear(); + } + + numberOfMerges = 0; + var mergedSubtitle = new Subtitle(); + Paragraph p = null; + var lineNumbers = new StringBuilder(); + for (int i = 1; i < subtitle.Paragraphs.Count; i++) + { + if (removed.Contains(i - 1)) + { + continue; + } + + p = new Paragraph(subtitle.GetParagraphOrDefault(i - 1)); + mergedSubtitle.Paragraphs.Add(p); + + for (int j = i; j < subtitle.Paragraphs.Count; j++) + { + if (removed.Contains(j)) + { + continue; + } + + var next = subtitle.GetParagraphOrDefault(j); + var incrementText = string.Empty; + if ((MergeLinesSameTextUtils.QualifiesForMerge(p, next, maxMsBetween) || fixIncrementing && MergeLinesSameTextUtils.QualifiesForMergeIncrement(p, next, maxMsBetween, out incrementText)) && IsFixAllowed(p)) + { + p.Text = next.Text; + if (!string.IsNullOrEmpty(incrementText)) + { + p.Text = incrementText; + } + + p.EndTime.TotalMilliseconds = next.EndTime.TotalMilliseconds; + if (lineNumbers.Length > 0) + { + lineNumbers.Append(next.Number); + lineNumbers.Append(','); + } + else + { + lineNumbers.Append(p.Number); + lineNumbers.Append(','); + lineNumbers.Append(next.Number); + lineNumbers.Append(','); + } + + removed.Add(j); + numberOfMerges++; + if (!mergedIndexes.Contains(j)) + { + mergedIndexes.Add(j); + } + + if (!mergedIndexes.Contains(i - 1)) + { + mergedIndexes.Add(i - 1); + } + } + } + + if (!removed.Contains(i - 1) && lineNumbers.Length > 0 && clearFixes) + { + AddToListView(p, lineNumbers.ToString(), p.Text); + lineNumbers.Clear(); + } + } + + if (lineNumbers.Length > 0 && clearFixes && p != null) + { + AddToListView(p, lineNumbers.ToString(), p.Text); + } + + if (!mergedIndexes.Contains(subtitle.Paragraphs.Count - 1)) + { + mergedSubtitle.Paragraphs.Add(new Paragraph(subtitle.GetParagraphOrDefault(subtitle.Paragraphs.Count - 1))); + } + + if (!_loading) + { + listViewFixes.ItemChecked += listViewFixes_ItemChecked; + } + + mergedSubtitle.Renumber(); + return mergedSubtitle; + } + + private void ButtonCancelClick(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void ButtonOkClick(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e) + { + if (listViewFixes.SelectedIndices.Count > 0) + { + int index = listViewFixes.SelectedIndices[0]; + ListViewItem item = listViewFixes.Items[index]; + var numbers = item.SubItems[1].Text.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + foreach (string number in numbers) + { + foreach (var p in _subtitle.Paragraphs) + { + if (p.Number.ToString(CultureInfo.InvariantCulture) == number) + { + index = _subtitle.GetIndex(p); + SubtitleListview1.EnsureVisible(index); + } + } + } + } + } + + private void listViewFixes_ItemChecked(object sender, ItemCheckedEventArgs e) + { + if (_loading) + { + return; + } + + NumberOfMerges = 0; + SubtitleListview1.Items.Clear(); + SubtitleListview1.BeginUpdate(); + MergedSubtitle = MergeLinesWithSameTextInSubtitle(_subtitle, out var count, false, checkBoxIncludeIncrementing.Checked, true, (int)numericUpDownMaxMillisecondsBetweenLines.Value); + NumberOfMerges = count; + SubtitleListview1.Fill(_subtitle); + UpdateBackgroundColor(); + SubtitleListview1.EndUpdate(); + groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.MergedShortLines.NumberOfMergesX, NumberOfMerges); + } + + private void UpdateBackgroundColor() + { + var colors = new List + { + Color.Green, + Color.LimeGreen, + Color.GreenYellow, + }; + int colorIdx = 0; + + for (int i = 0; i < listViewFixes.Items.Count; i++) + { + ListViewItem item = listViewFixes.Items[i]; + var lineNumbers = item.SubItems[1].Text; + if (item.Checked && !string.IsNullOrEmpty(lineNumbers)) + { + var numbers = lineNumbers.Split(','); + foreach (var number in numbers) + { + SubtitleListview1.SetBackgroundColor(Convert.ToInt32(number) - 1, colors[colorIdx]); + } + + colorIdx++; + if (colorIdx >= colors.Count) + { + colorIdx = 0; + } + } + } + } + + private void MergeDoubleLines_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void MergeDoubleLines_Shown(object sender, EventArgs e) + { + GeneratePreview(); + listViewFixes.Focus(); + if (listViewFixes.Items.Count > 0) + { + listViewFixes.Items[0].Selected = true; + } + + _loading = false; + listViewFixes.ItemChecked += listViewFixes_ItemChecked; + } + + private void checkBoxFixIncrementing_CheckedChanged(object sender, EventArgs e) + { + Cursor = Cursors.WaitCursor; + GeneratePreview(); + Cursor = Cursors.Default; + } + + private void numericUpDownMaxMillisecondsBetweenLines_ValueChanged(object sender, EventArgs e) + { + _previewTimer.Stop(); + _previewTimer.Start(); + } + + private void previewTimer_Tick(object sender, EventArgs e) + { + _previewTimer.Stop(); + Cursor = Cursors.WaitCursor; + GeneratePreview(); + Cursor = Cursors.Default; + } + + private void MergeDoubleLines_ResizeEnd(object sender, EventArgs e) + { + columnHeaderText.Width = -2; + } + + private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = true; + } + } + + private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = !item.Checked; + } + } + } +} diff --git a/src/Forms/MergeDoubleLines.resx b/src/ui/Forms/MergeDoubleLines.resx similarity index 97% rename from src/Forms/MergeDoubleLines.resx rename to src/ui/Forms/MergeDoubleLines.resx index 661dc1126..ad537526f 100644 --- a/src/Forms/MergeDoubleLines.resx +++ b/src/ui/Forms/MergeDoubleLines.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/MergeShortLines.Designer.cs b/src/ui/Forms/MergeShortLines.Designer.cs similarity index 98% rename from src/Forms/MergeShortLines.Designer.cs rename to src/ui/Forms/MergeShortLines.Designer.cs index 9fa68289d..0af707bc6 100644 --- a/src/Forms/MergeShortLines.Designer.cs +++ b/src/ui/Forms/MergeShortLines.Designer.cs @@ -1,305 +1,305 @@ -using Nikse.SubtitleEdit.Controls; - -namespace Nikse.SubtitleEdit.Forms -{ - partial class MergeShortLines - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.numericUpDownMaxCharacters = new System.Windows.Forms.NumericUpDown(); - this.labelMaxCharacters = new System.Windows.Forms.Label(); - this.labelMaxMillisecondsBetweenLines = new System.Windows.Forms.Label(); - this.numericUpDownMaxMillisecondsBetweenLines = new System.Windows.Forms.NumericUpDown(); - this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); - this.listViewFixes = new System.Windows.Forms.ListView(); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.checkBoxOnlyContinuationLines = new System.Windows.Forms.CheckBox(); - this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).BeginInit(); - this.groupBoxLinesFound.SuspendLayout(); - this.contextMenuStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(608, 562); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 6; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(689, 562); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 8; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); - // - // numericUpDownMaxCharacters - // - this.numericUpDownMaxCharacters.Location = new System.Drawing.Point(190, 27); - this.numericUpDownMaxCharacters.Maximum = new decimal(new int[] { - 999, - 0, - 0, - 0}); - this.numericUpDownMaxCharacters.Minimum = new decimal(new int[] { - 10, - 0, - 0, - 0}); - this.numericUpDownMaxCharacters.Name = "numericUpDownMaxCharacters"; - this.numericUpDownMaxCharacters.Size = new System.Drawing.Size(64, 21); - this.numericUpDownMaxCharacters.TabIndex = 0; - this.numericUpDownMaxCharacters.Value = new decimal(new int[] { - 65, - 0, - 0, - 0}); - this.numericUpDownMaxCharacters.ValueChanged += new System.EventHandler(this.NumericUpDownMaxCharactersValueChanged); - // - // labelMaxCharacters - // - this.labelMaxCharacters.AutoSize = true; - this.labelMaxCharacters.Location = new System.Drawing.Point(187, 9); - this.labelMaxCharacters.Name = "labelMaxCharacters"; - this.labelMaxCharacters.Size = new System.Drawing.Size(190, 13); - this.labelMaxCharacters.TabIndex = 32; - this.labelMaxCharacters.Text = "Maximum characters in one paragraph"; - // - // labelMaxMillisecondsBetweenLines - // - this.labelMaxMillisecondsBetweenLines.AutoSize = true; - this.labelMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(483, 9); - this.labelMaxMillisecondsBetweenLines.Name = "labelMaxMillisecondsBetweenLines"; - this.labelMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(178, 13); - this.labelMaxMillisecondsBetweenLines.TabIndex = 33; - this.labelMaxMillisecondsBetweenLines.Text = "Maximum milliseconds between lines"; - // - // numericUpDownMaxMillisecondsBetweenLines - // - this.numericUpDownMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(486, 26); - this.numericUpDownMaxMillisecondsBetweenLines.Maximum = new decimal(new int[] { - 10000, - 0, - 0, - 0}); - this.numericUpDownMaxMillisecondsBetweenLines.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.numericUpDownMaxMillisecondsBetweenLines.Name = "numericUpDownMaxMillisecondsBetweenLines"; - this.numericUpDownMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(64, 21); - this.numericUpDownMaxMillisecondsBetweenLines.TabIndex = 2; - this.numericUpDownMaxMillisecondsBetweenLines.Value = new decimal(new int[] { - 250, - 0, - 0, - 0}); - this.numericUpDownMaxMillisecondsBetweenLines.ValueChanged += new System.EventHandler(this.NumericUpDownMaxMillisecondsBetweenLinesValueChanged); - // - // groupBoxLinesFound - // - this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxLinesFound.Controls.Add(this.listViewFixes); - this.groupBoxLinesFound.Location = new System.Drawing.Point(13, 68); - this.groupBoxLinesFound.Name = "groupBoxLinesFound"; - this.groupBoxLinesFound.Size = new System.Drawing.Size(752, 200); - this.groupBoxLinesFound.TabIndex = 36; - this.groupBoxLinesFound.TabStop = false; - this.groupBoxLinesFound.Text = "Lines that will be merged"; - // - // listViewFixes - // - this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewFixes.CheckBoxes = true; - this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader4, - this.columnHeader5, - this.columnHeader7}); - this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; - this.listViewFixes.FullRowSelect = true; - this.listViewFixes.HideSelection = false; - this.listViewFixes.Location = new System.Drawing.Point(6, 23); - this.listViewFixes.Name = "listViewFixes"; - this.listViewFixes.Size = new System.Drawing.Size(740, 171); - this.listViewFixes.TabIndex = 0; - this.listViewFixes.UseCompatibleStateImageBehavior = false; - this.listViewFixes.View = System.Windows.Forms.View.Details; - this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged); - // - // columnHeader4 - // - this.columnHeader4.Text = "Apply"; - this.columnHeader4.Width = 45; - // - // columnHeader5 - // - this.columnHeader5.Text = "Line#"; - this.columnHeader5.Width = 122; - // - // columnHeader7 - // - this.columnHeader7.Text = "New text"; - this.columnHeader7.Width = 500; - // - // checkBoxOnlyContinuationLines - // - this.checkBoxOnlyContinuationLines.AutoSize = true; - this.checkBoxOnlyContinuationLines.Checked = true; - this.checkBoxOnlyContinuationLines.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxOnlyContinuationLines.Location = new System.Drawing.Point(190, 54); - this.checkBoxOnlyContinuationLines.Name = "checkBoxOnlyContinuationLines"; - this.checkBoxOnlyContinuationLines.Size = new System.Drawing.Size(167, 17); - this.checkBoxOnlyContinuationLines.TabIndex = 37; - this.checkBoxOnlyContinuationLines.Text = "Only merge continuation lines"; - this.checkBoxOnlyContinuationLines.UseVisualStyleBackColor = true; - this.checkBoxOnlyContinuationLines.CheckedChanged += new System.EventHandler(this.checkBoxOnlyContinuationLines_CheckedChanged); - // - // SubtitleListview1 - // - this.SubtitleListview1.AllowColumnReorder = true; - this.SubtitleListview1.AllowDrop = true; - this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.SubtitleListview1.FirstVisibleIndex = -1; - this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.SubtitleListview1.FullRowSelect = true; - this.SubtitleListview1.GridLines = true; - this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.SubtitleListview1.HideSelection = false; - this.SubtitleListview1.Location = new System.Drawing.Point(10, 274); - this.SubtitleListview1.Name = "SubtitleListview1"; - this.SubtitleListview1.OwnerDraw = true; - this.SubtitleListview1.Size = new System.Drawing.Size(757, 282); - this.SubtitleListview1.SubtitleFontBold = false; - this.SubtitleListview1.SubtitleFontName = "Tahoma"; - this.SubtitleListview1.SubtitleFontSize = 8; - this.SubtitleListview1.TabIndex = 4; - this.SubtitleListview1.UseCompatibleStateImageBehavior = false; - this.SubtitleListview1.UseSyntaxColoring = true; - this.SubtitleListview1.View = System.Windows.Forms.View.Details; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemSelectAll, - this.toolStripMenuItemInverseSelection}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70); - // - // toolStripMenuItemSelectAll - // - this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; - this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemSelectAll.Text = "Select all"; - this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); - // - // toolStripMenuItemInverseSelection - // - this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; - this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; - this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); - // - // MergeShortLines - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(776, 595); - this.Controls.Add(this.checkBoxOnlyContinuationLines); - this.Controls.Add(this.numericUpDownMaxCharacters); - this.Controls.Add(this.groupBoxLinesFound); - this.Controls.Add(this.numericUpDownMaxMillisecondsBetweenLines); - this.Controls.Add(this.labelMaxMillisecondsBetweenLines); - this.Controls.Add(this.labelMaxCharacters); - this.Controls.Add(this.SubtitleListview1); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MinimumSize = new System.Drawing.Size(750, 400); - this.Name = "MergeShortLines"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "MergeShortLines"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MergeShortLines_FormClosing); - this.Shown += new System.EventHandler(this.MergeShortLines_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MergeShortLines_KeyDown); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).EndInit(); - this.groupBoxLinesFound.ResumeLayout(false); - this.contextMenuStrip1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private SubtitleListView SubtitleListview1; - private System.Windows.Forms.NumericUpDown numericUpDownMaxCharacters; - private System.Windows.Forms.Label labelMaxCharacters; - private System.Windows.Forms.Label labelMaxMillisecondsBetweenLines; - private System.Windows.Forms.NumericUpDown numericUpDownMaxMillisecondsBetweenLines; - private System.Windows.Forms.GroupBox groupBoxLinesFound; - private System.Windows.Forms.ListView listViewFixes; - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeader7; - private System.Windows.Forms.CheckBox checkBoxOnlyContinuationLines; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; - } +using Nikse.SubtitleEdit.Controls; + +namespace Nikse.SubtitleEdit.Forms +{ + partial class MergeShortLines + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.numericUpDownMaxCharacters = new System.Windows.Forms.NumericUpDown(); + this.labelMaxCharacters = new System.Windows.Forms.Label(); + this.labelMaxMillisecondsBetweenLines = new System.Windows.Forms.Label(); + this.numericUpDownMaxMillisecondsBetweenLines = new System.Windows.Forms.NumericUpDown(); + this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); + this.listViewFixes = new System.Windows.Forms.ListView(); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.checkBoxOnlyContinuationLines = new System.Windows.Forms.CheckBox(); + this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).BeginInit(); + this.groupBoxLinesFound.SuspendLayout(); + this.contextMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(608, 562); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 6; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(689, 562); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 8; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); + // + // numericUpDownMaxCharacters + // + this.numericUpDownMaxCharacters.Location = new System.Drawing.Point(190, 27); + this.numericUpDownMaxCharacters.Maximum = new decimal(new int[] { + 999, + 0, + 0, + 0}); + this.numericUpDownMaxCharacters.Minimum = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDownMaxCharacters.Name = "numericUpDownMaxCharacters"; + this.numericUpDownMaxCharacters.Size = new System.Drawing.Size(64, 21); + this.numericUpDownMaxCharacters.TabIndex = 0; + this.numericUpDownMaxCharacters.Value = new decimal(new int[] { + 65, + 0, + 0, + 0}); + this.numericUpDownMaxCharacters.ValueChanged += new System.EventHandler(this.NumericUpDownMaxCharactersValueChanged); + // + // labelMaxCharacters + // + this.labelMaxCharacters.AutoSize = true; + this.labelMaxCharacters.Location = new System.Drawing.Point(187, 9); + this.labelMaxCharacters.Name = "labelMaxCharacters"; + this.labelMaxCharacters.Size = new System.Drawing.Size(190, 13); + this.labelMaxCharacters.TabIndex = 32; + this.labelMaxCharacters.Text = "Maximum characters in one paragraph"; + // + // labelMaxMillisecondsBetweenLines + // + this.labelMaxMillisecondsBetweenLines.AutoSize = true; + this.labelMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(483, 9); + this.labelMaxMillisecondsBetweenLines.Name = "labelMaxMillisecondsBetweenLines"; + this.labelMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(178, 13); + this.labelMaxMillisecondsBetweenLines.TabIndex = 33; + this.labelMaxMillisecondsBetweenLines.Text = "Maximum milliseconds between lines"; + // + // numericUpDownMaxMillisecondsBetweenLines + // + this.numericUpDownMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(486, 26); + this.numericUpDownMaxMillisecondsBetweenLines.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.numericUpDownMaxMillisecondsBetweenLines.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numericUpDownMaxMillisecondsBetweenLines.Name = "numericUpDownMaxMillisecondsBetweenLines"; + this.numericUpDownMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(64, 21); + this.numericUpDownMaxMillisecondsBetweenLines.TabIndex = 2; + this.numericUpDownMaxMillisecondsBetweenLines.Value = new decimal(new int[] { + 250, + 0, + 0, + 0}); + this.numericUpDownMaxMillisecondsBetweenLines.ValueChanged += new System.EventHandler(this.NumericUpDownMaxMillisecondsBetweenLinesValueChanged); + // + // groupBoxLinesFound + // + this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxLinesFound.Controls.Add(this.listViewFixes); + this.groupBoxLinesFound.Location = new System.Drawing.Point(13, 68); + this.groupBoxLinesFound.Name = "groupBoxLinesFound"; + this.groupBoxLinesFound.Size = new System.Drawing.Size(752, 200); + this.groupBoxLinesFound.TabIndex = 36; + this.groupBoxLinesFound.TabStop = false; + this.groupBoxLinesFound.Text = "Lines that will be merged"; + // + // listViewFixes + // + this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewFixes.CheckBoxes = true; + this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader4, + this.columnHeader5, + this.columnHeader7}); + this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; + this.listViewFixes.FullRowSelect = true; + this.listViewFixes.HideSelection = false; + this.listViewFixes.Location = new System.Drawing.Point(6, 23); + this.listViewFixes.Name = "listViewFixes"; + this.listViewFixes.Size = new System.Drawing.Size(740, 171); + this.listViewFixes.TabIndex = 0; + this.listViewFixes.UseCompatibleStateImageBehavior = false; + this.listViewFixes.View = System.Windows.Forms.View.Details; + this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged); + // + // columnHeader4 + // + this.columnHeader4.Text = "Apply"; + this.columnHeader4.Width = 45; + // + // columnHeader5 + // + this.columnHeader5.Text = "Line#"; + this.columnHeader5.Width = 122; + // + // columnHeader7 + // + this.columnHeader7.Text = "New text"; + this.columnHeader7.Width = 500; + // + // checkBoxOnlyContinuationLines + // + this.checkBoxOnlyContinuationLines.AutoSize = true; + this.checkBoxOnlyContinuationLines.Checked = true; + this.checkBoxOnlyContinuationLines.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxOnlyContinuationLines.Location = new System.Drawing.Point(190, 54); + this.checkBoxOnlyContinuationLines.Name = "checkBoxOnlyContinuationLines"; + this.checkBoxOnlyContinuationLines.Size = new System.Drawing.Size(167, 17); + this.checkBoxOnlyContinuationLines.TabIndex = 37; + this.checkBoxOnlyContinuationLines.Text = "Only merge continuation lines"; + this.checkBoxOnlyContinuationLines.UseVisualStyleBackColor = true; + this.checkBoxOnlyContinuationLines.CheckedChanged += new System.EventHandler(this.checkBoxOnlyContinuationLines_CheckedChanged); + // + // SubtitleListview1 + // + this.SubtitleListview1.AllowColumnReorder = true; + this.SubtitleListview1.AllowDrop = true; + this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.SubtitleListview1.FirstVisibleIndex = -1; + this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SubtitleListview1.FullRowSelect = true; + this.SubtitleListview1.GridLines = true; + this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.SubtitleListview1.HideSelection = false; + this.SubtitleListview1.Location = new System.Drawing.Point(10, 274); + this.SubtitleListview1.Name = "SubtitleListview1"; + this.SubtitleListview1.OwnerDraw = true; + this.SubtitleListview1.Size = new System.Drawing.Size(757, 282); + this.SubtitleListview1.SubtitleFontBold = false; + this.SubtitleListview1.SubtitleFontName = "Tahoma"; + this.SubtitleListview1.SubtitleFontSize = 8; + this.SubtitleListview1.TabIndex = 4; + this.SubtitleListview1.UseCompatibleStateImageBehavior = false; + this.SubtitleListview1.UseSyntaxColoring = true; + this.SubtitleListview1.View = System.Windows.Forms.View.Details; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSelectAll, + this.toolStripMenuItemInverseSelection}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70); + // + // toolStripMenuItemSelectAll + // + this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; + this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemSelectAll.Text = "Select all"; + this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); + // + // toolStripMenuItemInverseSelection + // + this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; + this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; + this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); + // + // MergeShortLines + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(776, 595); + this.Controls.Add(this.checkBoxOnlyContinuationLines); + this.Controls.Add(this.numericUpDownMaxCharacters); + this.Controls.Add(this.groupBoxLinesFound); + this.Controls.Add(this.numericUpDownMaxMillisecondsBetweenLines); + this.Controls.Add(this.labelMaxMillisecondsBetweenLines); + this.Controls.Add(this.labelMaxCharacters); + this.Controls.Add(this.SubtitleListview1); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MinimumSize = new System.Drawing.Size(750, 400); + this.Name = "MergeShortLines"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "MergeShortLines"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MergeShortLines_FormClosing); + this.Shown += new System.EventHandler(this.MergeShortLines_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MergeShortLines_KeyDown); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharacters)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxMillisecondsBetweenLines)).EndInit(); + this.groupBoxLinesFound.ResumeLayout(false); + this.contextMenuStrip1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private SubtitleListView SubtitleListview1; + private System.Windows.Forms.NumericUpDown numericUpDownMaxCharacters; + private System.Windows.Forms.Label labelMaxCharacters; + private System.Windows.Forms.Label labelMaxMillisecondsBetweenLines; + private System.Windows.Forms.NumericUpDown numericUpDownMaxMillisecondsBetweenLines; + private System.Windows.Forms.GroupBox groupBoxLinesFound; + private System.Windows.Forms.ListView listViewFixes; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.CheckBox checkBoxOnlyContinuationLines; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; + } } \ No newline at end of file diff --git a/src/Forms/MergeShortLines.cs b/src/ui/Forms/MergeShortLines.cs similarity index 97% rename from src/Forms/MergeShortLines.cs rename to src/ui/Forms/MergeShortLines.cs index 8df0d2ef8..0543f6657 100644 --- a/src/Forms/MergeShortLines.cs +++ b/src/ui/Forms/MergeShortLines.cs @@ -1,326 +1,326 @@ -using Nikse.SubtitleEdit.Controls; -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class MergeShortLines : PositionAndSizeForm - { - public int NumberOfMerges { get; private set; } - public Subtitle MergedSubtitle { get; private set; } - - private Subtitle _subtitle; - - public MergeShortLines() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - UiUtil.FixLargeFonts(this, buttonOK); - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); - SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); - } - - private void MergeShortLines_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - public void Initialize(Subtitle subtitle) - { - if (subtitle.Paragraphs.Count > 0) - { - subtitle.Renumber(); - } - - Text = Configuration.Settings.Language.MergedShortLines.Title; - labelMaxCharacters.Text = Configuration.Settings.Language.MergedShortLines.MaximumCharacters; - labelMaxMillisecondsBetweenLines.Text = Configuration.Settings.Language.MergedShortLines.MaximumMillisecondsBetween; - - checkBoxOnlyContinuationLines.Text = Configuration.Settings.Language.MergedShortLines.OnlyMergeContinuationLines; - - listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; - listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; - listViewFixes.Columns[2].Text = Configuration.Settings.Language.MergedShortLines.MergedText; - - toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; - toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.AutoSizeAllColumns(this); - NumberOfMerges = 0; - if (Configuration.Settings.Tools.MergeShortLinesMaxChars > numericUpDownMaxCharacters.Maximum) - { - numericUpDownMaxCharacters.Value = numericUpDownMaxCharacters.Maximum; - } - else if (Configuration.Settings.Tools.MergeShortLinesMaxChars < numericUpDownMaxCharacters.Minimum) - { - numericUpDownMaxCharacters.Value = numericUpDownMaxCharacters.Minimum; - } - else - { - numericUpDownMaxCharacters.Value = Configuration.Settings.Tools.MergeShortLinesMaxChars; - } - numericUpDownMaxMillisecondsBetweenLines.Value = Configuration.Settings.Tools.MergeShortLinesMaxGap; - checkBoxOnlyContinuationLines.Checked = Configuration.Settings.Tools.MergeShortLinesOnlyContinuous; - _subtitle = subtitle; - } - - private void AddToListView(Paragraph p, string lineNumbers, string newText) - { - var item = new ListViewItem(string.Empty) { Tag = p, Checked = true }; - item.SubItems.Add(lineNumbers.TrimEnd(',')); - item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); - listViewFixes.Items.Add(item); - } - - private void GeneratePreview() - { - if (_subtitle == null) - { - return; - } - - var mergedIndexes = new List(); - - NumberOfMerges = 0; - SubtitleListview1.Items.Clear(); - SubtitleListview1.BeginUpdate(); - MergedSubtitle = MergeShortLinesInSubtitle(_subtitle, mergedIndexes, out var count, (double)numericUpDownMaxMillisecondsBetweenLines.Value, (int)numericUpDownMaxCharacters.Value, true); - NumberOfMerges = count; - - SubtitleListview1.Fill(_subtitle); - - foreach (var index in mergedIndexes) - { - SubtitleListview1.SetBackgroundColor(index, Color.Green); - } - - SubtitleListview1.EndUpdate(); - groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.MergedShortLines.NumberOfMergesX, NumberOfMerges); - } - - private bool IsFixAllowed(Paragraph p) - { - foreach (ListViewItem item in listViewFixes.Items) - { - string numbers = item.SubItems[1].Text; - foreach (string number in numbers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) - { - if (number == p.Number.ToString(CultureInfo.InvariantCulture)) - { - return item.Checked; - } - } - } - return true; - } - - public Subtitle MergeShortLinesInSubtitle(Subtitle subtitle, List mergedIndexes, out int numberOfMerges, double maxMillisecondsBetweenLines, int maxCharacters, bool clearFixes) - { - listViewFixes.ItemChecked -= listViewFixes_ItemChecked; - if (clearFixes) - { - listViewFixes.Items.Clear(); - } - - numberOfMerges = 0; - string language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); - var mergedSubtitle = new Subtitle(); - bool lastMerged = false; - Paragraph p = null; - var lineNumbers = new StringBuilder(); - bool onlyContinuousLines = checkBoxOnlyContinuationLines.Checked; - for (int i = 1; i < subtitle.Paragraphs.Count; i++) - { - if (!lastMerged) - { - p = new Paragraph(subtitle.GetParagraphOrDefault(i - 1)); - mergedSubtitle.Paragraphs.Add(p); - } - Paragraph next = subtitle.GetParagraphOrDefault(i); - if (next != null) - { - if (Utilities.QualifiesForMerge(p, next, maxMillisecondsBetweenLines, maxCharacters, onlyContinuousLines) && IsFixAllowed(p)) - { - if (MergeShortLinesUtils.GetStartTag(p.Text) == MergeShortLinesUtils.GetStartTag(next.Text) && - MergeShortLinesUtils.GetEndTag(p.Text) == MergeShortLinesUtils.GetEndTag(next.Text)) - { - string s1 = p.Text.Trim(); - s1 = s1.Substring(0, s1.Length - MergeShortLinesUtils.GetEndTag(s1).Length); - string s2 = next.Text.Trim(); - s2 = s2.Substring(MergeShortLinesUtils.GetStartTag(s2).Length); - p.Text = Utilities.AutoBreakLine(s1 + Environment.NewLine + s2, language); - } - else - { - p.Text = Utilities.AutoBreakLine(p.Text + Environment.NewLine + next.Text, language); - } - p.EndTime = next.EndTime; - - if (lastMerged) - { - lineNumbers.Append(next.Number); - lineNumbers.Append(','); - } - else - { - lineNumbers.Append(p.Number); - lineNumbers.Append(','); - lineNumbers.Append(next.Number); - lineNumbers.Append(','); - } - - lastMerged = true; - numberOfMerges++; - if (!mergedIndexes.Contains(i)) - { - mergedIndexes.Add(i); - } - - if (!mergedIndexes.Contains(i - 1)) - { - mergedIndexes.Add(i - 1); - } - } - else - { - lastMerged = false; - } - } - else - { - lastMerged = false; - } - if (!lastMerged && lineNumbers.Length > 0 && clearFixes) - { - AddToListView(p, lineNumbers.ToString(), p.Text); - lineNumbers.Clear(); - } - } - if (!lastMerged) - { - mergedSubtitle.Paragraphs.Add(new Paragraph(subtitle.GetParagraphOrDefault(subtitle.Paragraphs.Count - 1))); - } - - listViewFixes.ItemChecked += listViewFixes_ItemChecked; - return mergedSubtitle; - } - - private void NumericUpDownMaxCharactersValueChanged(object sender, EventArgs e) - { - Cursor = Cursors.WaitCursor; - GeneratePreview(); - Cursor = Cursors.Default; - } - - private void NumericUpDownMaxMillisecondsBetweenLinesValueChanged(object sender, EventArgs e) - { - Cursor = Cursors.WaitCursor; - GeneratePreview(); - Cursor = Cursors.Default; - } - - private void ButtonCancelClick(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void ButtonOkClick(object sender, EventArgs e) - { - Configuration.Settings.Tools.MergeShortLinesMaxGap = (int)numericUpDownMaxMillisecondsBetweenLines.Value; - Configuration.Settings.Tools.MergeShortLinesOnlyContinuous = checkBoxOnlyContinuationLines.Checked; - DialogResult = DialogResult.OK; - } - - private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e) - { - if (listViewFixes.SelectedIndices.Count > 0) - { - int index = listViewFixes.SelectedIndices[0]; - ListViewItem item = listViewFixes.Items[index]; - string[] numbers = item.SubItems[1].Text.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - foreach (string number in numbers) - { - foreach (Paragraph p in _subtitle.Paragraphs) - { - if (p.Number.ToString(CultureInfo.InvariantCulture) == number) - { - index = _subtitle.GetIndex(p); - SubtitleListview1.EnsureVisible(index); - } - } - } - } - } - - private void listViewFixes_ItemChecked(object sender, ItemCheckedEventArgs e) - { - var mergedIndexes = new List(); - - NumberOfMerges = 0; - SubtitleListview1.Items.Clear(); - SubtitleListview1.BeginUpdate(); - int count; - MergedSubtitle = MergeShortLinesInSubtitle(_subtitle, mergedIndexes, out count, (double)numericUpDownMaxMillisecondsBetweenLines.Value, (int)numericUpDownMaxCharacters.Value, false); - NumberOfMerges = count; - SubtitleListview1.Fill(_subtitle); - foreach (var index in mergedIndexes) - { - SubtitleListview1.SetBackgroundColor(index, Color.Green); - } - SubtitleListview1.EndUpdate(); - groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.MergedShortLines.NumberOfMergesX, NumberOfMerges); - } - - private void MergeShortLines_Shown(object sender, EventArgs e) - { - GeneratePreview(); - listViewFixes.Focus(); - if (listViewFixes.Items.Count > 0) - { - listViewFixes.Items[0].Selected = true; - } - } - - private void checkBoxOnlyContinuationLines_CheckedChanged(object sender, EventArgs e) - { - Cursor = Cursors.WaitCursor; - GeneratePreview(); - Cursor = Cursors.Default; - } - - private void MergeShortLines_FormClosing(object sender, FormClosingEventArgs e) - { - Configuration.Settings.Tools.MergeShortLinesMaxChars = (int)numericUpDownMaxCharacters.Value; - } - - private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = true; - } - } - - private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = !item.Checked; - } - } - } -} +using Nikse.SubtitleEdit.Controls; +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class MergeShortLines : PositionAndSizeForm + { + public int NumberOfMerges { get; private set; } + public Subtitle MergedSubtitle { get; private set; } + + private Subtitle _subtitle; + + public MergeShortLines() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + UiUtil.FixLargeFonts(this, buttonOK); + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds); + SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute); + } + + private void MergeShortLines_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + public void Initialize(Subtitle subtitle) + { + if (subtitle.Paragraphs.Count > 0) + { + subtitle.Renumber(); + } + + Text = Configuration.Settings.Language.MergedShortLines.Title; + labelMaxCharacters.Text = Configuration.Settings.Language.MergedShortLines.MaximumCharacters; + labelMaxMillisecondsBetweenLines.Text = Configuration.Settings.Language.MergedShortLines.MaximumMillisecondsBetween; + + checkBoxOnlyContinuationLines.Text = Configuration.Settings.Language.MergedShortLines.OnlyMergeContinuationLines; + + listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; + listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; + listViewFixes.Columns[2].Text = Configuration.Settings.Language.MergedShortLines.MergedText; + + toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; + toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.AutoSizeAllColumns(this); + NumberOfMerges = 0; + if (Configuration.Settings.Tools.MergeShortLinesMaxChars > numericUpDownMaxCharacters.Maximum) + { + numericUpDownMaxCharacters.Value = numericUpDownMaxCharacters.Maximum; + } + else if (Configuration.Settings.Tools.MergeShortLinesMaxChars < numericUpDownMaxCharacters.Minimum) + { + numericUpDownMaxCharacters.Value = numericUpDownMaxCharacters.Minimum; + } + else + { + numericUpDownMaxCharacters.Value = Configuration.Settings.Tools.MergeShortLinesMaxChars; + } + numericUpDownMaxMillisecondsBetweenLines.Value = Configuration.Settings.Tools.MergeShortLinesMaxGap; + checkBoxOnlyContinuationLines.Checked = Configuration.Settings.Tools.MergeShortLinesOnlyContinuous; + _subtitle = subtitle; + } + + private void AddToListView(Paragraph p, string lineNumbers, string newText) + { + var item = new ListViewItem(string.Empty) { Tag = p, Checked = true }; + item.SubItems.Add(lineNumbers.TrimEnd(',')); + item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); + listViewFixes.Items.Add(item); + } + + private void GeneratePreview() + { + if (_subtitle == null) + { + return; + } + + var mergedIndexes = new List(); + + NumberOfMerges = 0; + SubtitleListview1.Items.Clear(); + SubtitleListview1.BeginUpdate(); + MergedSubtitle = MergeShortLinesInSubtitle(_subtitle, mergedIndexes, out var count, (double)numericUpDownMaxMillisecondsBetweenLines.Value, (int)numericUpDownMaxCharacters.Value, true); + NumberOfMerges = count; + + SubtitleListview1.Fill(_subtitle); + + foreach (var index in mergedIndexes) + { + SubtitleListview1.SetBackgroundColor(index, Color.Green); + } + + SubtitleListview1.EndUpdate(); + groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.MergedShortLines.NumberOfMergesX, NumberOfMerges); + } + + private bool IsFixAllowed(Paragraph p) + { + foreach (ListViewItem item in listViewFixes.Items) + { + string numbers = item.SubItems[1].Text; + foreach (string number in numbers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) + { + if (number == p.Number.ToString(CultureInfo.InvariantCulture)) + { + return item.Checked; + } + } + } + return true; + } + + public Subtitle MergeShortLinesInSubtitle(Subtitle subtitle, List mergedIndexes, out int numberOfMerges, double maxMillisecondsBetweenLines, int maxCharacters, bool clearFixes) + { + listViewFixes.ItemChecked -= listViewFixes_ItemChecked; + if (clearFixes) + { + listViewFixes.Items.Clear(); + } + + numberOfMerges = 0; + string language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); + var mergedSubtitle = new Subtitle(); + bool lastMerged = false; + Paragraph p = null; + var lineNumbers = new StringBuilder(); + bool onlyContinuousLines = checkBoxOnlyContinuationLines.Checked; + for (int i = 1; i < subtitle.Paragraphs.Count; i++) + { + if (!lastMerged) + { + p = new Paragraph(subtitle.GetParagraphOrDefault(i - 1)); + mergedSubtitle.Paragraphs.Add(p); + } + Paragraph next = subtitle.GetParagraphOrDefault(i); + if (next != null) + { + if (Utilities.QualifiesForMerge(p, next, maxMillisecondsBetweenLines, maxCharacters, onlyContinuousLines) && IsFixAllowed(p)) + { + if (MergeShortLinesUtils.GetStartTag(p.Text) == MergeShortLinesUtils.GetStartTag(next.Text) && + MergeShortLinesUtils.GetEndTag(p.Text) == MergeShortLinesUtils.GetEndTag(next.Text)) + { + string s1 = p.Text.Trim(); + s1 = s1.Substring(0, s1.Length - MergeShortLinesUtils.GetEndTag(s1).Length); + string s2 = next.Text.Trim(); + s2 = s2.Substring(MergeShortLinesUtils.GetStartTag(s2).Length); + p.Text = Utilities.AutoBreakLine(s1 + Environment.NewLine + s2, language); + } + else + { + p.Text = Utilities.AutoBreakLine(p.Text + Environment.NewLine + next.Text, language); + } + p.EndTime = next.EndTime; + + if (lastMerged) + { + lineNumbers.Append(next.Number); + lineNumbers.Append(','); + } + else + { + lineNumbers.Append(p.Number); + lineNumbers.Append(','); + lineNumbers.Append(next.Number); + lineNumbers.Append(','); + } + + lastMerged = true; + numberOfMerges++; + if (!mergedIndexes.Contains(i)) + { + mergedIndexes.Add(i); + } + + if (!mergedIndexes.Contains(i - 1)) + { + mergedIndexes.Add(i - 1); + } + } + else + { + lastMerged = false; + } + } + else + { + lastMerged = false; + } + if (!lastMerged && lineNumbers.Length > 0 && clearFixes) + { + AddToListView(p, lineNumbers.ToString(), p.Text); + lineNumbers.Clear(); + } + } + if (!lastMerged) + { + mergedSubtitle.Paragraphs.Add(new Paragraph(subtitle.GetParagraphOrDefault(subtitle.Paragraphs.Count - 1))); + } + + listViewFixes.ItemChecked += listViewFixes_ItemChecked; + return mergedSubtitle; + } + + private void NumericUpDownMaxCharactersValueChanged(object sender, EventArgs e) + { + Cursor = Cursors.WaitCursor; + GeneratePreview(); + Cursor = Cursors.Default; + } + + private void NumericUpDownMaxMillisecondsBetweenLinesValueChanged(object sender, EventArgs e) + { + Cursor = Cursors.WaitCursor; + GeneratePreview(); + Cursor = Cursors.Default; + } + + private void ButtonCancelClick(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void ButtonOkClick(object sender, EventArgs e) + { + Configuration.Settings.Tools.MergeShortLinesMaxGap = (int)numericUpDownMaxMillisecondsBetweenLines.Value; + Configuration.Settings.Tools.MergeShortLinesOnlyContinuous = checkBoxOnlyContinuationLines.Checked; + DialogResult = DialogResult.OK; + } + + private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e) + { + if (listViewFixes.SelectedIndices.Count > 0) + { + int index = listViewFixes.SelectedIndices[0]; + ListViewItem item = listViewFixes.Items[index]; + string[] numbers = item.SubItems[1].Text.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + foreach (string number in numbers) + { + foreach (Paragraph p in _subtitle.Paragraphs) + { + if (p.Number.ToString(CultureInfo.InvariantCulture) == number) + { + index = _subtitle.GetIndex(p); + SubtitleListview1.EnsureVisible(index); + } + } + } + } + } + + private void listViewFixes_ItemChecked(object sender, ItemCheckedEventArgs e) + { + var mergedIndexes = new List(); + + NumberOfMerges = 0; + SubtitleListview1.Items.Clear(); + SubtitleListview1.BeginUpdate(); + int count; + MergedSubtitle = MergeShortLinesInSubtitle(_subtitle, mergedIndexes, out count, (double)numericUpDownMaxMillisecondsBetweenLines.Value, (int)numericUpDownMaxCharacters.Value, false); + NumberOfMerges = count; + SubtitleListview1.Fill(_subtitle); + foreach (var index in mergedIndexes) + { + SubtitleListview1.SetBackgroundColor(index, Color.Green); + } + SubtitleListview1.EndUpdate(); + groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.MergedShortLines.NumberOfMergesX, NumberOfMerges); + } + + private void MergeShortLines_Shown(object sender, EventArgs e) + { + GeneratePreview(); + listViewFixes.Focus(); + if (listViewFixes.Items.Count > 0) + { + listViewFixes.Items[0].Selected = true; + } + } + + private void checkBoxOnlyContinuationLines_CheckedChanged(object sender, EventArgs e) + { + Cursor = Cursors.WaitCursor; + GeneratePreview(); + Cursor = Cursors.Default; + } + + private void MergeShortLines_FormClosing(object sender, FormClosingEventArgs e) + { + Configuration.Settings.Tools.MergeShortLinesMaxChars = (int)numericUpDownMaxCharacters.Value; + } + + private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = true; + } + } + + private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = !item.Checked; + } + } + } +} diff --git a/src/Forms/MergeShortLines.resx b/src/ui/Forms/MergeShortLines.resx similarity index 97% rename from src/Forms/MergeShortLines.resx rename to src/ui/Forms/MergeShortLines.resx index 661dc1126..ad537526f 100644 --- a/src/Forms/MergeShortLines.resx +++ b/src/ui/Forms/MergeShortLines.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/MergeTextWithSameTimeCodes.Designer.cs b/src/ui/Forms/MergeTextWithSameTimeCodes.Designer.cs similarity index 100% rename from src/Forms/MergeTextWithSameTimeCodes.Designer.cs rename to src/ui/Forms/MergeTextWithSameTimeCodes.Designer.cs diff --git a/src/Forms/MergeTextWithSameTimeCodes.cs b/src/ui/Forms/MergeTextWithSameTimeCodes.cs similarity index 100% rename from src/Forms/MergeTextWithSameTimeCodes.cs rename to src/ui/Forms/MergeTextWithSameTimeCodes.cs diff --git a/src/Forms/ApplyDurationLimits.resx b/src/ui/Forms/MergeTextWithSameTimeCodes.resx similarity index 97% rename from src/Forms/ApplyDurationLimits.resx rename to src/ui/Forms/MergeTextWithSameTimeCodes.resx index 661dc1126..ad537526f 100644 --- a/src/Forms/ApplyDurationLimits.resx +++ b/src/ui/Forms/MergeTextWithSameTimeCodes.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/ModifySelection.Designer.cs b/src/ui/Forms/ModifySelection.Designer.cs similarity index 98% rename from src/Forms/ModifySelection.Designer.cs rename to src/ui/Forms/ModifySelection.Designer.cs index ec5350c41..3dec0fcea 100644 --- a/src/Forms/ModifySelection.Designer.cs +++ b/src/ui/Forms/ModifySelection.Designer.cs @@ -1,385 +1,385 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ModifySelection - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.groupBoxWhatToDo = new System.Windows.Forms.GroupBox(); - this.radioButtonIntersect = new System.Windows.Forms.RadioButton(); - this.radioButtonSubtractFromSelection = new System.Windows.Forms.RadioButton(); - this.radioButtonAddToSelection = new System.Windows.Forms.RadioButton(); - this.radioButtonNewSelection = new System.Windows.Forms.RadioButton(); - this.groupBoxRule = new System.Windows.Forms.GroupBox(); - this.numericUpDownDuration = new System.Windows.Forms.NumericUpDown(); - this.checkBoxCaseSensitive = new System.Windows.Forms.CheckBox(); - this.textBoxText = new System.Windows.Forms.TextBox(); - this.comboBoxRule = new System.Windows.Forms.ComboBox(); - this.listViewStyles = new System.Windows.Forms.ListView(); - this.columnHeaderStyleName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonApply = new System.Windows.Forms.Button(); - this.groupBoxPreview = new System.Windows.Forms.GroupBox(); - this.listViewFixes = new System.Windows.Forms.ListView(); - this.columnHeaderApply = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderLine = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderText = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderStyle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.labelInfo = new System.Windows.Forms.Label(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBoxWhatToDo.SuspendLayout(); - this.groupBoxRule.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).BeginInit(); - this.groupBoxPreview.SuspendLayout(); - this.contextMenuStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxWhatToDo - // - this.groupBoxWhatToDo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxWhatToDo.Controls.Add(this.radioButtonIntersect); - this.groupBoxWhatToDo.Controls.Add(this.radioButtonSubtractFromSelection); - this.groupBoxWhatToDo.Controls.Add(this.radioButtonAddToSelection); - this.groupBoxWhatToDo.Controls.Add(this.radioButtonNewSelection); - this.groupBoxWhatToDo.Location = new System.Drawing.Point(380, 12); - this.groupBoxWhatToDo.Name = "groupBoxWhatToDo"; - this.groupBoxWhatToDo.Size = new System.Drawing.Size(411, 135); - this.groupBoxWhatToDo.TabIndex = 1; - this.groupBoxWhatToDo.TabStop = false; - this.groupBoxWhatToDo.Text = "What to do with matches"; - // - // radioButtonIntersect - // - this.radioButtonIntersect.AutoSize = true; - this.radioButtonIntersect.Location = new System.Drawing.Point(7, 89); - this.radioButtonIntersect.Name = "radioButtonIntersect"; - this.radioButtonIntersect.Size = new System.Drawing.Size(172, 17); - this.radioButtonIntersect.TabIndex = 3; - this.radioButtonIntersect.Text = "Intersect with current selection"; - this.radioButtonIntersect.UseVisualStyleBackColor = true; - this.radioButtonIntersect.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged); - // - // radioButtonSubtractFromSelection - // - this.radioButtonSubtractFromSelection.AutoSize = true; - this.radioButtonSubtractFromSelection.Location = new System.Drawing.Point(7, 66); - this.radioButtonSubtractFromSelection.Name = "radioButtonSubtractFromSelection"; - this.radioButtonSubtractFromSelection.Size = new System.Drawing.Size(169, 17); - this.radioButtonSubtractFromSelection.TabIndex = 2; - this.radioButtonSubtractFromSelection.Text = "Subtract from current selection"; - this.radioButtonSubtractFromSelection.UseVisualStyleBackColor = true; - this.radioButtonSubtractFromSelection.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged); - // - // radioButtonAddToSelection - // - this.radioButtonAddToSelection.AutoSize = true; - this.radioButtonAddToSelection.Location = new System.Drawing.Point(7, 43); - this.radioButtonAddToSelection.Name = "radioButtonAddToSelection"; - this.radioButtonAddToSelection.Size = new System.Drawing.Size(137, 17); - this.radioButtonAddToSelection.TabIndex = 1; - this.radioButtonAddToSelection.Text = "Add to current selection"; - this.radioButtonAddToSelection.UseVisualStyleBackColor = true; - this.radioButtonAddToSelection.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged); - // - // radioButtonNewSelection - // - this.radioButtonNewSelection.AutoSize = true; - this.radioButtonNewSelection.Checked = true; - this.radioButtonNewSelection.Location = new System.Drawing.Point(7, 20); - this.radioButtonNewSelection.Name = "radioButtonNewSelection"; - this.radioButtonNewSelection.Size = new System.Drawing.Size(120, 17); - this.radioButtonNewSelection.TabIndex = 0; - this.radioButtonNewSelection.TabStop = true; - this.radioButtonNewSelection.Text = "Make new selection"; - this.radioButtonNewSelection.UseVisualStyleBackColor = true; - this.radioButtonNewSelection.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged); - // - // groupBoxRule - // - this.groupBoxRule.Controls.Add(this.numericUpDownDuration); - this.groupBoxRule.Controls.Add(this.checkBoxCaseSensitive); - this.groupBoxRule.Controls.Add(this.textBoxText); - this.groupBoxRule.Controls.Add(this.comboBoxRule); - this.groupBoxRule.Controls.Add(this.listViewStyles); - this.groupBoxRule.Location = new System.Drawing.Point(12, 12); - this.groupBoxRule.Name = "groupBoxRule"; - this.groupBoxRule.Size = new System.Drawing.Size(362, 135); - this.groupBoxRule.TabIndex = 0; - this.groupBoxRule.TabStop = false; - this.groupBoxRule.Text = "Rule"; - // - // numericUpDownDuration - // - this.numericUpDownDuration.Location = new System.Drawing.Point(198, 22); - this.numericUpDownDuration.Maximum = new decimal(new int[] { - 10000, - 0, - 0, - 0}); - this.numericUpDownDuration.Name = "numericUpDownDuration"; - this.numericUpDownDuration.Size = new System.Drawing.Size(82, 20); - this.numericUpDownDuration.TabIndex = 4; - this.numericUpDownDuration.ValueChanged += new System.EventHandler(this.numericUpDownDuration_ValueChanged); - // - // checkBoxCaseSensitive - // - this.checkBoxCaseSensitive.AutoSize = true; - this.checkBoxCaseSensitive.Location = new System.Drawing.Point(6, 47); - this.checkBoxCaseSensitive.Name = "checkBoxCaseSensitive"; - this.checkBoxCaseSensitive.Size = new System.Drawing.Size(94, 17); - this.checkBoxCaseSensitive.TabIndex = 2; - this.checkBoxCaseSensitive.Text = "Case sensitive"; - this.checkBoxCaseSensitive.UseVisualStyleBackColor = true; - this.checkBoxCaseSensitive.CheckedChanged += new System.EventHandler(this.checkBoxCaseSensitive_CheckedChanged); - // - // textBoxText - // - this.textBoxText.Location = new System.Drawing.Point(198, 21); - this.textBoxText.Name = "textBoxText"; - this.textBoxText.Size = new System.Drawing.Size(158, 20); - this.textBoxText.TabIndex = 1; - this.textBoxText.TextChanged += new System.EventHandler(this.textBox1_TextChanged); - // - // comboBoxRule - // - this.comboBoxRule.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxRule.FormattingEnabled = true; - this.comboBoxRule.Items.AddRange(new object[] { - "Contains", - "Starts with", - "Ends with", - "Not contains", - "RegEx"}); - this.comboBoxRule.Location = new System.Drawing.Point(6, 20); - this.comboBoxRule.Name = "comboBoxRule"; - this.comboBoxRule.Size = new System.Drawing.Size(185, 21); - this.comboBoxRule.TabIndex = 0; - this.comboBoxRule.SelectedIndexChanged += new System.EventHandler(this.comboBoxRule_SelectedIndexChanged); - // - // listViewStyles - // - this.listViewStyles.CheckBoxes = true; - this.listViewStyles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderStyleName}); - this.listViewStyles.FullRowSelect = true; - this.listViewStyles.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; - this.listViewStyles.HideSelection = false; - this.listViewStyles.Location = new System.Drawing.Point(198, 21); - this.listViewStyles.Name = "listViewStyles"; - this.listViewStyles.Size = new System.Drawing.Size(158, 108); - this.listViewStyles.TabIndex = 3; - this.listViewStyles.UseCompatibleStateImageBehavior = false; - this.listViewStyles.View = System.Windows.Forms.View.Details; - this.listViewStyles.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listViewStyles_ItemChecked); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(621, 446); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 6; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(540, 446); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 5; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonApply - // - this.buttonApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonApply.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonApply.Location = new System.Drawing.Point(702, 446); - this.buttonApply.Name = "buttonApply"; - this.buttonApply.Size = new System.Drawing.Size(89, 23); - this.buttonApply.TabIndex = 7; - this.buttonApply.Text = "&Apply"; - this.buttonApply.UseVisualStyleBackColor = true; - this.buttonApply.Click += new System.EventHandler(this.buttonApply_Click); - // - // groupBoxPreview - // - this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxPreview.Controls.Add(this.listViewFixes); - this.groupBoxPreview.Location = new System.Drawing.Point(12, 153); - this.groupBoxPreview.Name = "groupBoxPreview"; - this.groupBoxPreview.Size = new System.Drawing.Size(779, 286); - this.groupBoxPreview.TabIndex = 2; - this.groupBoxPreview.TabStop = false; - this.groupBoxPreview.Text = "Matching lines"; - // - // listViewFixes - // - this.listViewFixes.CheckBoxes = true; - this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderApply, - this.columnHeaderLine, - this.columnHeaderText, - this.columnHeaderStyle}); - this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; - this.listViewFixes.Dock = System.Windows.Forms.DockStyle.Fill; - this.listViewFixes.FullRowSelect = true; - this.listViewFixes.HideSelection = false; - this.listViewFixes.Location = new System.Drawing.Point(3, 16); - this.listViewFixes.Name = "listViewFixes"; - this.listViewFixes.Size = new System.Drawing.Size(773, 267); - this.listViewFixes.TabIndex = 1; - this.listViewFixes.UseCompatibleStateImageBehavior = false; - this.listViewFixes.View = System.Windows.Forms.View.Details; - // - // columnHeaderApply - // - this.columnHeaderApply.Text = "Apply"; - this.columnHeaderApply.Width = 50; - // - // columnHeaderLine - // - this.columnHeaderLine.Text = "Line#"; - this.columnHeaderLine.Width = 122; - // - // columnHeaderText - // - this.columnHeaderText.Text = "Text"; - this.columnHeaderText.Width = 450; - // - // columnHeaderStyle - // - this.columnHeaderStyle.Text = "Style"; - // - // labelInfo - // - this.labelInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelInfo.AutoSize = true; - this.labelInfo.Location = new System.Drawing.Point(12, 446); - this.labelInfo.Name = "labelInfo"; - this.labelInfo.Size = new System.Drawing.Size(47, 13); - this.labelInfo.TabIndex = 3; - this.labelInfo.Text = "labelInfo"; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemSelectAll, - this.toolStripMenuItemInverseSelection}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70); - // - // toolStripMenuItemSelectAll - // - this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; - this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemSelectAll.Text = "Select all"; - this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); - // - // toolStripMenuItemInverseSelection - // - this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; - this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; - this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); - // - // ModifySelection - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(803, 478); - this.Controls.Add(this.labelInfo); - this.Controls.Add(this.groupBoxWhatToDo); - this.Controls.Add(this.groupBoxPreview); - this.Controls.Add(this.buttonApply); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.groupBoxRule); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(700, 400); - this.Name = "ModifySelection"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Create/modify selection"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ModifySelection_KeyDown); - this.Resize += new System.EventHandler(this.ModifySelection_Resize); - this.groupBoxWhatToDo.ResumeLayout(false); - this.groupBoxWhatToDo.PerformLayout(); - this.groupBoxRule.ResumeLayout(false); - this.groupBoxRule.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).EndInit(); - this.groupBoxPreview.ResumeLayout(false); - this.contextMenuStrip1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxWhatToDo; - private System.Windows.Forms.RadioButton radioButtonSubtractFromSelection; - private System.Windows.Forms.RadioButton radioButtonAddToSelection; - private System.Windows.Forms.RadioButton radioButtonNewSelection; - private System.Windows.Forms.GroupBox groupBoxRule; - private System.Windows.Forms.TextBox textBoxText; - private System.Windows.Forms.ComboBox comboBoxRule; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonApply; - private System.Windows.Forms.GroupBox groupBoxPreview; - private System.Windows.Forms.ListView listViewFixes; - private System.Windows.Forms.ColumnHeader columnHeaderApply; - private System.Windows.Forms.ColumnHeader columnHeaderLine; - private System.Windows.Forms.ColumnHeader columnHeaderText; - private System.Windows.Forms.Label labelInfo; - private System.Windows.Forms.CheckBox checkBoxCaseSensitive; - private System.Windows.Forms.RadioButton radioButtonIntersect; - private System.Windows.Forms.ColumnHeader columnHeaderStyle; - private System.Windows.Forms.ListView listViewStyles; - private System.Windows.Forms.ColumnHeader columnHeaderStyleName; - private System.Windows.Forms.NumericUpDown numericUpDownDuration; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ModifySelection + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.groupBoxWhatToDo = new System.Windows.Forms.GroupBox(); + this.radioButtonIntersect = new System.Windows.Forms.RadioButton(); + this.radioButtonSubtractFromSelection = new System.Windows.Forms.RadioButton(); + this.radioButtonAddToSelection = new System.Windows.Forms.RadioButton(); + this.radioButtonNewSelection = new System.Windows.Forms.RadioButton(); + this.groupBoxRule = new System.Windows.Forms.GroupBox(); + this.numericUpDownDuration = new System.Windows.Forms.NumericUpDown(); + this.checkBoxCaseSensitive = new System.Windows.Forms.CheckBox(); + this.textBoxText = new System.Windows.Forms.TextBox(); + this.comboBoxRule = new System.Windows.Forms.ComboBox(); + this.listViewStyles = new System.Windows.Forms.ListView(); + this.columnHeaderStyleName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonApply = new System.Windows.Forms.Button(); + this.groupBoxPreview = new System.Windows.Forms.GroupBox(); + this.listViewFixes = new System.Windows.Forms.ListView(); + this.columnHeaderApply = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderLine = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderText = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderStyle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.labelInfo = new System.Windows.Forms.Label(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBoxWhatToDo.SuspendLayout(); + this.groupBoxRule.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).BeginInit(); + this.groupBoxPreview.SuspendLayout(); + this.contextMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxWhatToDo + // + this.groupBoxWhatToDo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxWhatToDo.Controls.Add(this.radioButtonIntersect); + this.groupBoxWhatToDo.Controls.Add(this.radioButtonSubtractFromSelection); + this.groupBoxWhatToDo.Controls.Add(this.radioButtonAddToSelection); + this.groupBoxWhatToDo.Controls.Add(this.radioButtonNewSelection); + this.groupBoxWhatToDo.Location = new System.Drawing.Point(380, 12); + this.groupBoxWhatToDo.Name = "groupBoxWhatToDo"; + this.groupBoxWhatToDo.Size = new System.Drawing.Size(411, 135); + this.groupBoxWhatToDo.TabIndex = 1; + this.groupBoxWhatToDo.TabStop = false; + this.groupBoxWhatToDo.Text = "What to do with matches"; + // + // radioButtonIntersect + // + this.radioButtonIntersect.AutoSize = true; + this.radioButtonIntersect.Location = new System.Drawing.Point(7, 89); + this.radioButtonIntersect.Name = "radioButtonIntersect"; + this.radioButtonIntersect.Size = new System.Drawing.Size(172, 17); + this.radioButtonIntersect.TabIndex = 3; + this.radioButtonIntersect.Text = "Intersect with current selection"; + this.radioButtonIntersect.UseVisualStyleBackColor = true; + this.radioButtonIntersect.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged); + // + // radioButtonSubtractFromSelection + // + this.radioButtonSubtractFromSelection.AutoSize = true; + this.radioButtonSubtractFromSelection.Location = new System.Drawing.Point(7, 66); + this.radioButtonSubtractFromSelection.Name = "radioButtonSubtractFromSelection"; + this.radioButtonSubtractFromSelection.Size = new System.Drawing.Size(169, 17); + this.radioButtonSubtractFromSelection.TabIndex = 2; + this.radioButtonSubtractFromSelection.Text = "Subtract from current selection"; + this.radioButtonSubtractFromSelection.UseVisualStyleBackColor = true; + this.radioButtonSubtractFromSelection.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged); + // + // radioButtonAddToSelection + // + this.radioButtonAddToSelection.AutoSize = true; + this.radioButtonAddToSelection.Location = new System.Drawing.Point(7, 43); + this.radioButtonAddToSelection.Name = "radioButtonAddToSelection"; + this.radioButtonAddToSelection.Size = new System.Drawing.Size(137, 17); + this.radioButtonAddToSelection.TabIndex = 1; + this.radioButtonAddToSelection.Text = "Add to current selection"; + this.radioButtonAddToSelection.UseVisualStyleBackColor = true; + this.radioButtonAddToSelection.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged); + // + // radioButtonNewSelection + // + this.radioButtonNewSelection.AutoSize = true; + this.radioButtonNewSelection.Checked = true; + this.radioButtonNewSelection.Location = new System.Drawing.Point(7, 20); + this.radioButtonNewSelection.Name = "radioButtonNewSelection"; + this.radioButtonNewSelection.Size = new System.Drawing.Size(120, 17); + this.radioButtonNewSelection.TabIndex = 0; + this.radioButtonNewSelection.TabStop = true; + this.radioButtonNewSelection.Text = "Make new selection"; + this.radioButtonNewSelection.UseVisualStyleBackColor = true; + this.radioButtonNewSelection.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged); + // + // groupBoxRule + // + this.groupBoxRule.Controls.Add(this.numericUpDownDuration); + this.groupBoxRule.Controls.Add(this.checkBoxCaseSensitive); + this.groupBoxRule.Controls.Add(this.textBoxText); + this.groupBoxRule.Controls.Add(this.comboBoxRule); + this.groupBoxRule.Controls.Add(this.listViewStyles); + this.groupBoxRule.Location = new System.Drawing.Point(12, 12); + this.groupBoxRule.Name = "groupBoxRule"; + this.groupBoxRule.Size = new System.Drawing.Size(362, 135); + this.groupBoxRule.TabIndex = 0; + this.groupBoxRule.TabStop = false; + this.groupBoxRule.Text = "Rule"; + // + // numericUpDownDuration + // + this.numericUpDownDuration.Location = new System.Drawing.Point(198, 22); + this.numericUpDownDuration.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.numericUpDownDuration.Name = "numericUpDownDuration"; + this.numericUpDownDuration.Size = new System.Drawing.Size(82, 20); + this.numericUpDownDuration.TabIndex = 4; + this.numericUpDownDuration.ValueChanged += new System.EventHandler(this.numericUpDownDuration_ValueChanged); + // + // checkBoxCaseSensitive + // + this.checkBoxCaseSensitive.AutoSize = true; + this.checkBoxCaseSensitive.Location = new System.Drawing.Point(6, 47); + this.checkBoxCaseSensitive.Name = "checkBoxCaseSensitive"; + this.checkBoxCaseSensitive.Size = new System.Drawing.Size(94, 17); + this.checkBoxCaseSensitive.TabIndex = 2; + this.checkBoxCaseSensitive.Text = "Case sensitive"; + this.checkBoxCaseSensitive.UseVisualStyleBackColor = true; + this.checkBoxCaseSensitive.CheckedChanged += new System.EventHandler(this.checkBoxCaseSensitive_CheckedChanged); + // + // textBoxText + // + this.textBoxText.Location = new System.Drawing.Point(198, 21); + this.textBoxText.Name = "textBoxText"; + this.textBoxText.Size = new System.Drawing.Size(158, 20); + this.textBoxText.TabIndex = 1; + this.textBoxText.TextChanged += new System.EventHandler(this.textBox1_TextChanged); + // + // comboBoxRule + // + this.comboBoxRule.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxRule.FormattingEnabled = true; + this.comboBoxRule.Items.AddRange(new object[] { + "Contains", + "Starts with", + "Ends with", + "Not contains", + "RegEx"}); + this.comboBoxRule.Location = new System.Drawing.Point(6, 20); + this.comboBoxRule.Name = "comboBoxRule"; + this.comboBoxRule.Size = new System.Drawing.Size(185, 21); + this.comboBoxRule.TabIndex = 0; + this.comboBoxRule.SelectedIndexChanged += new System.EventHandler(this.comboBoxRule_SelectedIndexChanged); + // + // listViewStyles + // + this.listViewStyles.CheckBoxes = true; + this.listViewStyles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderStyleName}); + this.listViewStyles.FullRowSelect = true; + this.listViewStyles.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.listViewStyles.HideSelection = false; + this.listViewStyles.Location = new System.Drawing.Point(198, 21); + this.listViewStyles.Name = "listViewStyles"; + this.listViewStyles.Size = new System.Drawing.Size(158, 108); + this.listViewStyles.TabIndex = 3; + this.listViewStyles.UseCompatibleStateImageBehavior = false; + this.listViewStyles.View = System.Windows.Forms.View.Details; + this.listViewStyles.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listViewStyles_ItemChecked); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(621, 446); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(540, 446); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 5; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonApply + // + this.buttonApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonApply.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonApply.Location = new System.Drawing.Point(702, 446); + this.buttonApply.Name = "buttonApply"; + this.buttonApply.Size = new System.Drawing.Size(89, 23); + this.buttonApply.TabIndex = 7; + this.buttonApply.Text = "&Apply"; + this.buttonApply.UseVisualStyleBackColor = true; + this.buttonApply.Click += new System.EventHandler(this.buttonApply_Click); + // + // groupBoxPreview + // + this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxPreview.Controls.Add(this.listViewFixes); + this.groupBoxPreview.Location = new System.Drawing.Point(12, 153); + this.groupBoxPreview.Name = "groupBoxPreview"; + this.groupBoxPreview.Size = new System.Drawing.Size(779, 286); + this.groupBoxPreview.TabIndex = 2; + this.groupBoxPreview.TabStop = false; + this.groupBoxPreview.Text = "Matching lines"; + // + // listViewFixes + // + this.listViewFixes.CheckBoxes = true; + this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderApply, + this.columnHeaderLine, + this.columnHeaderText, + this.columnHeaderStyle}); + this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; + this.listViewFixes.Dock = System.Windows.Forms.DockStyle.Fill; + this.listViewFixes.FullRowSelect = true; + this.listViewFixes.HideSelection = false; + this.listViewFixes.Location = new System.Drawing.Point(3, 16); + this.listViewFixes.Name = "listViewFixes"; + this.listViewFixes.Size = new System.Drawing.Size(773, 267); + this.listViewFixes.TabIndex = 1; + this.listViewFixes.UseCompatibleStateImageBehavior = false; + this.listViewFixes.View = System.Windows.Forms.View.Details; + // + // columnHeaderApply + // + this.columnHeaderApply.Text = "Apply"; + this.columnHeaderApply.Width = 50; + // + // columnHeaderLine + // + this.columnHeaderLine.Text = "Line#"; + this.columnHeaderLine.Width = 122; + // + // columnHeaderText + // + this.columnHeaderText.Text = "Text"; + this.columnHeaderText.Width = 450; + // + // columnHeaderStyle + // + this.columnHeaderStyle.Text = "Style"; + // + // labelInfo + // + this.labelInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelInfo.AutoSize = true; + this.labelInfo.Location = new System.Drawing.Point(12, 446); + this.labelInfo.Name = "labelInfo"; + this.labelInfo.Size = new System.Drawing.Size(47, 13); + this.labelInfo.TabIndex = 3; + this.labelInfo.Text = "labelInfo"; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSelectAll, + this.toolStripMenuItemInverseSelection}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70); + // + // toolStripMenuItemSelectAll + // + this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; + this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemSelectAll.Text = "Select all"; + this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); + // + // toolStripMenuItemInverseSelection + // + this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; + this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; + this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); + // + // ModifySelection + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(803, 478); + this.Controls.Add(this.labelInfo); + this.Controls.Add(this.groupBoxWhatToDo); + this.Controls.Add(this.groupBoxPreview); + this.Controls.Add(this.buttonApply); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.groupBoxRule); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(700, 400); + this.Name = "ModifySelection"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Create/modify selection"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ModifySelection_KeyDown); + this.Resize += new System.EventHandler(this.ModifySelection_Resize); + this.groupBoxWhatToDo.ResumeLayout(false); + this.groupBoxWhatToDo.PerformLayout(); + this.groupBoxRule.ResumeLayout(false); + this.groupBoxRule.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).EndInit(); + this.groupBoxPreview.ResumeLayout(false); + this.contextMenuStrip1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxWhatToDo; + private System.Windows.Forms.RadioButton radioButtonSubtractFromSelection; + private System.Windows.Forms.RadioButton radioButtonAddToSelection; + private System.Windows.Forms.RadioButton radioButtonNewSelection; + private System.Windows.Forms.GroupBox groupBoxRule; + private System.Windows.Forms.TextBox textBoxText; + private System.Windows.Forms.ComboBox comboBoxRule; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonApply; + private System.Windows.Forms.GroupBox groupBoxPreview; + private System.Windows.Forms.ListView listViewFixes; + private System.Windows.Forms.ColumnHeader columnHeaderApply; + private System.Windows.Forms.ColumnHeader columnHeaderLine; + private System.Windows.Forms.ColumnHeader columnHeaderText; + private System.Windows.Forms.Label labelInfo; + private System.Windows.Forms.CheckBox checkBoxCaseSensitive; + private System.Windows.Forms.RadioButton radioButtonIntersect; + private System.Windows.Forms.ColumnHeader columnHeaderStyle; + private System.Windows.Forms.ListView listViewStyles; + private System.Windows.Forms.ColumnHeader columnHeaderStyleName; + private System.Windows.Forms.NumericUpDown numericUpDownDuration; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; + } } \ No newline at end of file diff --git a/src/Forms/ModifySelection.cs b/src/ui/Forms/ModifySelection.cs similarity index 97% rename from src/Forms/ModifySelection.cs rename to src/ui/Forms/ModifySelection.cs index 736e14594..db53a374e 100644 --- a/src/Forms/ModifySelection.cs +++ b/src/ui/Forms/ModifySelection.cs @@ -1,576 +1,576 @@ -using Nikse.SubtitleEdit.Controls; -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; -using Nikse.SubtitleEdit.Core.SubtitleFormats; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ModifySelection : PositionAndSizeForm - { - private readonly SubtitleListView _subtitleListView; - private readonly Subtitle _subtitle; - private readonly SubtitleFormat _format; - private readonly bool _loading; - - private const int FunctionContains = 0; - private const int FunctionStartsWith = 1; - private const int FunctionEndsWith = 2; - private const int FunctionNotContains = 3; - private const int FunctionAlUppercase = 4; - private const int FunctionRegEx = 5; - private const int FunctionUnequal = 6; - private const int FunctionEqual = 7; - private const int FunctionDurationLessThan = 8; - private const int FunctionDurationGreaterThan = 9; - private const int FunctionMoreThanTwoLines = 10; - private const int FunctionStyle = 11; - private const int FunctionActor = 12; - - public ModifySelection(Subtitle subtitle, SubtitleFormat format, SubtitleListView subtitleListView) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _loading = true; - _subtitle = subtitle; - _format = format; - _subtitleListView = subtitleListView; - labelInfo.Text = string.Empty; - comboBoxRule.SelectedIndex = 0; - Text = Configuration.Settings.Language.ModifySelection.Title; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - buttonApply.Text = Configuration.Settings.Language.General.Apply; - groupBoxRule.Text = Configuration.Settings.Language.ModifySelection.Rule; - groupBoxWhatToDo.Text = Configuration.Settings.Language.ModifySelection.DoWithMatches; - checkBoxCaseSensitive.Text = Configuration.Settings.Language.ModifySelection.CaseSensitive; - radioButtonNewSelection.Text = Configuration.Settings.Language.ModifySelection.MakeNewSelection; - radioButtonAddToSelection.Text = Configuration.Settings.Language.ModifySelection.AddToCurrentSelection; - radioButtonSubtractFromSelection.Text = Configuration.Settings.Language.ModifySelection.SubtractFromCurrentSelection; - radioButtonIntersect.Text = Configuration.Settings.Language.ModifySelection.IntersectWithCurrentSelection; - columnHeaderApply.Text = Configuration.Settings.Language.General.Apply; - columnHeaderLine.Text = Configuration.Settings.Language.General.LineNumber; - columnHeaderText.Text = Configuration.Settings.Language.General.Text; - toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; - toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; - - listViewStyles.Visible = false; - - UiUtil.FixLargeFonts(this, buttonOK); - - comboBoxRule.Items.Clear(); - comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.Contains); - comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.StartsWith); - comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.EndsWith); - comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.NoContains); - comboBoxRule.Items.Add(Configuration.Settings.Language.ChangeCasing.AllUppercase); - comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.RegEx); - comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.UnequalLines); - comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.EqualLines); - comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.DurationLessThan); - comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.DurationGreaterThan); - comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.MoreThanTwoLines); - if (_format.HasStyleSupport) - { - comboBoxRule.Items.Add(Configuration.Settings.Language.General.Style); - } - if (_format.HasStyleSupport && (_format.GetType() == typeof(AdvancedSubStationAlpha) || _format.GetType() == typeof(SubStationAlpha))) - { - comboBoxRule.Items.Add(Configuration.Settings.Language.General.Actor); - } - - checkBoxCaseSensitive.Checked = Configuration.Settings.Tools.ModifySelectionCaseSensitive; - textBoxText.Text = Configuration.Settings.Tools.ModifySelectionText; - if (Configuration.Settings.Tools.ModifySelectionRule == "Starts with") - { - comboBoxRule.SelectedIndex = FunctionStartsWith; - } - else if (Configuration.Settings.Tools.ModifySelectionRule == "Ends with") - { - comboBoxRule.SelectedIndex = FunctionEndsWith; - } - else if (Configuration.Settings.Tools.ModifySelectionRule == "Not contains") - { - comboBoxRule.SelectedIndex = FunctionNotContains; - } - else if (Configuration.Settings.Tools.ModifySelectionRule == "AllUppercase") - { - comboBoxRule.SelectedIndex = FunctionAlUppercase; - } - else if (Configuration.Settings.Tools.ModifySelectionRule == "RegEx") - { - comboBoxRule.SelectedIndex = FunctionRegEx; - } - else if (Configuration.Settings.Tools.ModifySelectionRule == "Duration <") - { - comboBoxRule.SelectedIndex = FunctionDurationLessThan; - } - else if (Configuration.Settings.Tools.ModifySelectionRule == "Duration >") - { - comboBoxRule.SelectedIndex = FunctionDurationGreaterThan; - } - else if (Configuration.Settings.Tools.ModifySelectionRule == "More than two lines") - { - comboBoxRule.SelectedIndex = FunctionMoreThanTwoLines; - } - else if (Configuration.Settings.Tools.ModifySelectionRule == "Style" && _format.HasStyleSupport) - { - comboBoxRule.SelectedIndex = FunctionStyle; - } - else if (Configuration.Settings.Tools.ModifySelectionRule == "Actor" && (_format.GetType() == typeof(AdvancedSubStationAlpha) || _format.GetType() == typeof(SubStationAlpha))) - { - comboBoxRule.SelectedIndex = FunctionActor; - } - else - { - comboBoxRule.SelectedIndex = 0; - } - - if (!_format.HasStyleSupport) - { - listViewFixes.Columns.Remove(columnHeaderStyle); - } - ModifySelection_Resize(null, null); - - _loading = false; - Preview(); - } - - private void ModifySelection_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void buttonOK_Click(object sender, EventArgs e) - { - ApplySelection(); - DialogResult = DialogResult.OK; - - Configuration.Settings.Tools.ModifySelectionCaseSensitive = checkBoxCaseSensitive.Checked; - Configuration.Settings.Tools.ModifySelectionText = textBoxText.Text; - if (comboBoxRule.SelectedIndex == FunctionContains) - { - Configuration.Settings.Tools.ModifySelectionRule = "Contains"; - } - else if (comboBoxRule.SelectedIndex == FunctionStartsWith) - { - Configuration.Settings.Tools.ModifySelectionRule = "Starts with"; - } - else if (comboBoxRule.SelectedIndex == FunctionEndsWith) - { - Configuration.Settings.Tools.ModifySelectionRule = "Ends with"; - } - else if (comboBoxRule.SelectedIndex == FunctionNotContains) - { - Configuration.Settings.Tools.ModifySelectionRule = "Not contains"; - } - else if (comboBoxRule.SelectedIndex == FunctionAlUppercase) - { - Configuration.Settings.Tools.ModifySelectionRule = "AllUppercase"; - } - else if (comboBoxRule.SelectedIndex == FunctionRegEx) - { - Configuration.Settings.Tools.ModifySelectionRule = "RegEx"; - } - else if (comboBoxRule.SelectedIndex == FunctionDurationLessThan) - { - Configuration.Settings.Tools.ModifySelectionRule = "Duration <"; - } - else if (comboBoxRule.SelectedIndex == FunctionDurationGreaterThan) - { - Configuration.Settings.Tools.ModifySelectionRule = "Duration >"; - } - else if (comboBoxRule.SelectedIndex == FunctionMoreThanTwoLines) - { - Configuration.Settings.Tools.ModifySelectionRule = "More than two lines"; - } - else if (comboBoxRule.SelectedIndex == FunctionStyle) - { - Configuration.Settings.Tools.ModifySelectionRule = "Style"; - } - else if (comboBoxRule.SelectedIndex == FunctionActor) - { - Configuration.Settings.Tools.ModifySelectionRule = "Actor"; - } - } - - private void buttonApply_Click(object sender, EventArgs e) - { - ApplySelection(); - } - - private ListViewItem MakeListViewItem(Paragraph p, int index) - { - var item = new ListViewItem(string.Empty) { Tag = index, Checked = true }; - item.SubItems.Add(p.Number.ToString()); - item.SubItems.Add(UiUtil.GetListViewTextFromString(p.Text)); - if (_format.HasStyleSupport) - { - item.SubItems.Add(string.IsNullOrEmpty(p.Style) ? p.Extra : p.Style); - } - - return item; - } - - private void Preview() - { - if (_loading) - { - return; - } - - Regex regEx = null; - var listViewItems = new List(); - listViewFixes.BeginUpdate(); - listViewFixes.Items.Clear(); - string text = textBoxText.Text; - if (comboBoxRule.SelectedIndex != FunctionRegEx) - { - text = text.Replace("\\r\\n", Environment.NewLine); - } - - var styles = new List(); - var actors = new List(); - if (comboBoxRule.SelectedIndex == FunctionStyle) // select styles - { - foreach (ListViewItem item in listViewStyles.Items) - { - if (item.Checked) - { - styles.Add(item.Text); - } - } - } - else if (comboBoxRule.SelectedIndex == FunctionActor) // select actors - { - foreach (ListViewItem item in listViewStyles.Items) - { - if (item.Checked) - { - actors.Add(item.Text); - } - } - } - - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - if ((radioButtonSubtractFromSelection.Checked || radioButtonIntersect.Checked) && _subtitleListView.Items[i].Selected || - !radioButtonSubtractFromSelection.Checked && !radioButtonIntersect.Checked) - { - var p = _subtitle.Paragraphs[i]; - if (text.Length > 0) - { - if (comboBoxRule.SelectedIndex == FunctionContains) // Contains - { - if (checkBoxCaseSensitive.Checked && p.Text.Contains(text, StringComparison.Ordinal) || !checkBoxCaseSensitive.Checked && p.Text.Contains(text, StringComparison.OrdinalIgnoreCase)) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - else if (comboBoxRule.SelectedIndex == FunctionStartsWith) // Starts with - { - if (checkBoxCaseSensitive.Checked && p.Text.StartsWith(text, StringComparison.Ordinal) || !checkBoxCaseSensitive.Checked && p.Text.StartsWith(text, StringComparison.OrdinalIgnoreCase)) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - else if (comboBoxRule.SelectedIndex == FunctionEndsWith) // Ends with - { - if (checkBoxCaseSensitive.Checked && p.Text.EndsWith(text, StringComparison.Ordinal) || !checkBoxCaseSensitive.Checked && p.Text.EndsWith(text, StringComparison.OrdinalIgnoreCase)) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - else if (comboBoxRule.SelectedIndex == FunctionNotContains) // Not contains - { - if (checkBoxCaseSensitive.Checked && !p.Text.Contains(text, StringComparison.Ordinal) || !checkBoxCaseSensitive.Checked && !p.Text.Contains(text, StringComparison.OrdinalIgnoreCase)) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - else if (comboBoxRule.SelectedIndex == FunctionRegEx) // RegEx - { - labelInfo.Text = string.Empty; - if (regEx == null) - { - try - { - regEx = new Regex(text, RegexOptions.Compiled); - } - catch (Exception e) - { - labelInfo.Text = e.Message; - break; - } - } - if (regEx.IsMatch(p.Text)) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - } - if (comboBoxRule.SelectedIndex == FunctionUnequal) // select unequal lines - { - if (i % 2 == 0) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - else if (comboBoxRule.SelectedIndex == FunctionEqual) // select equal lines - { - if (i % 2 == 1) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - else if (comboBoxRule.SelectedIndex == FunctionDurationLessThan) // duration less than - { - if (p.Duration.TotalMilliseconds < (double)numericUpDownDuration.Value) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - else if (comboBoxRule.SelectedIndex == FunctionDurationGreaterThan) // duration greater than - { - if (p.Duration.TotalMilliseconds > (double)numericUpDownDuration.Value) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - else if (comboBoxRule.SelectedIndex == FunctionMoreThanTwoLines) - { - if (p.Text.SplitToLines().Count > 2) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - else if (comboBoxRule.SelectedIndex == FunctionAlUppercase) // all uppercase - { - if (HtmlUtil.RemoveHtmlTags(p.Text, true) == HtmlUtil.RemoveHtmlTags(p.Text, true).ToUpperInvariant() && p.Text != p.Text.ToLowerInvariant()) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - else if (comboBoxRule.SelectedIndex == FunctionStyle) // select styles - { - if (styles.Contains(string.IsNullOrEmpty(p.Style) ? p.Extra : p.Style)) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - else if (comboBoxRule.SelectedIndex == FunctionActor) // select actors - { - if (actors.Contains(p.Actor)) - { - listViewItems.Add(MakeListViewItem(p, i)); - } - } - } - } - - listViewFixes.Items.AddRange(listViewItems.ToArray()); - listViewFixes.EndUpdate(); - groupBoxPreview.Text = string.Format(Configuration.Settings.Language.ModifySelection.MatchingLinesX, listViewFixes.Items.Count); - } - - private void ApplySelection() - { - _subtitleListView.BeginUpdate(); - if (radioButtonNewSelection.Checked || radioButtonIntersect.Checked) - { - _subtitleListView.SelectNone(); - } - - if (radioButtonNewSelection.Checked || radioButtonAddToSelection.Checked || radioButtonIntersect.Checked) - { - foreach (ListViewItem item in listViewFixes.Items) - { - if (item.Checked) - { - int index = Convert.ToInt32(item.Tag); - _subtitleListView.Items[index].Selected = true; - } - } - } - else if (radioButtonSubtractFromSelection.Checked) - { - foreach (ListViewItem item in listViewFixes.Items) - { - if (item.Checked) - { - int index = Convert.ToInt32(item.Tag); - _subtitleListView.Items[index].Selected = false; - } - } - } - _subtitleListView.EndUpdate(); - } - - private void textBox1_TextChanged(object sender, EventArgs e) - { - Preview(); - } - - private void comboBoxRule_SelectedIndexChanged(object sender, EventArgs e) - { - textBoxText.Visible = true; - listViewStyles.Visible = false; - numericUpDownDuration.Visible = comboBoxRule.SelectedIndex == FunctionDurationLessThan || comboBoxRule.SelectedIndex == FunctionDurationGreaterThan; - if (comboBoxRule.SelectedIndex == FunctionRegEx) // regex - { - textBoxText.ContextMenu = FindReplaceDialogHelper.GetRegExContextMenu(textBoxText); - checkBoxCaseSensitive.Enabled = false; - } - else if (comboBoxRule.SelectedIndex == FunctionUnequal || comboBoxRule.SelectedIndex == FunctionEqual || comboBoxRule.SelectedIndex == FunctionMoreThanTwoLines) - { - textBoxText.ContextMenuStrip = null; - checkBoxCaseSensitive.Enabled = false; - textBoxText.Visible = false; - } - else if (comboBoxRule.SelectedIndex == FunctionStyle) - { - checkBoxCaseSensitive.Enabled = false; - listViewStyles.Visible = true; - listViewStyles.BringToFront(); - FillStyles(); - } - else if (comboBoxRule.SelectedIndex == FunctionActor) - { - checkBoxCaseSensitive.Enabled = false; - listViewStyles.Visible = true; - listViewStyles.BringToFront(); - FillActors(); - } - else if (comboBoxRule.SelectedIndex == FunctionDurationLessThan || comboBoxRule.SelectedIndex == FunctionDurationGreaterThan || comboBoxRule.SelectedIndex == FunctionAlUppercase) - { - checkBoxCaseSensitive.Enabled = false; - listViewStyles.Visible = false; - textBoxText.Visible = false; - if (comboBoxRule.SelectedIndex == FunctionDurationLessThan) - { - if (numericUpDownDuration.Value == 0 && - Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds >= numericUpDownDuration.Minimum && - Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds <= numericUpDownDuration.Maximum) - { - numericUpDownDuration.Value = Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds; - } - } - else - { - if (numericUpDownDuration.Value == 0 && - Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds >= numericUpDownDuration.Minimum && - Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds <= numericUpDownDuration.Maximum) - { - numericUpDownDuration.Value = Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds; - } - } - } - else - { - textBoxText.ContextMenuStrip = null; - checkBoxCaseSensitive.Enabled = true; - } - - Preview(); - } - - private void FillStyles() - { - listViewStyles.Columns[listViewStyles.Columns.Count - 1].Width = -2; - var styles = new List(); - var formatType = _format.GetType(); - if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha)) - { - styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); - } - else if (formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText)) - { - styles = TimedText10.GetStylesFromHeader(_subtitle.Header); - } - else if (formatType == typeof(Sami) || formatType == typeof(SamiModern)) - { - styles = _subtitle.Header == null ? Sami.GetStylesFromSubtitle(_subtitle) : Sami.GetStylesFromHeader(_subtitle.Header); - } - - listViewStyles.Items.Clear(); - foreach (var style in styles.OrderBy(p => p)) - { - listViewStyles.Items.Add(style); - } - } - - private void FillActors() - { - listViewStyles.Columns[listViewStyles.Columns.Count - 1].Width = -2; - var actors = new List(); - foreach (var paragraph in _subtitle.Paragraphs) - { - if (!string.IsNullOrEmpty(paragraph.Actor) && !actors.Contains(paragraph.Actor)) - { - actors.Add(paragraph.Actor); - } - } - - listViewStyles.Items.Clear(); - foreach (var style in actors.OrderBy(p => p)) - { - listViewStyles.Items.Add(style); - } - } - - private void checkBoxCaseSensitive_CheckedChanged(object sender, EventArgs e) - { - Preview(); - } - - private void radioButton_CheckedChanged(object sender, EventArgs e) - { - Preview(); - } - - private void ModifySelection_Resize(object sender, EventArgs e) - { - listViewFixes.Columns[listViewFixes.Columns.Count - 1].Width = -2; - } - - private void listViewStyles_ItemChecked(object sender, ItemCheckedEventArgs e) - { - Preview(); - } - - private void numericUpDownDuration_ValueChanged(object sender, EventArgs e) - { - Preview(); - } - - private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = true; - } - } - - private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = !item.Checked; - } - } - } -} +using Nikse.SubtitleEdit.Controls; +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Core.SubtitleFormats; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ModifySelection : PositionAndSizeForm + { + private readonly SubtitleListView _subtitleListView; + private readonly Subtitle _subtitle; + private readonly SubtitleFormat _format; + private readonly bool _loading; + + private const int FunctionContains = 0; + private const int FunctionStartsWith = 1; + private const int FunctionEndsWith = 2; + private const int FunctionNotContains = 3; + private const int FunctionAlUppercase = 4; + private const int FunctionRegEx = 5; + private const int FunctionUnequal = 6; + private const int FunctionEqual = 7; + private const int FunctionDurationLessThan = 8; + private const int FunctionDurationGreaterThan = 9; + private const int FunctionMoreThanTwoLines = 10; + private const int FunctionStyle = 11; + private const int FunctionActor = 12; + + public ModifySelection(Subtitle subtitle, SubtitleFormat format, SubtitleListView subtitleListView) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _loading = true; + _subtitle = subtitle; + _format = format; + _subtitleListView = subtitleListView; + labelInfo.Text = string.Empty; + comboBoxRule.SelectedIndex = 0; + Text = Configuration.Settings.Language.ModifySelection.Title; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + buttonApply.Text = Configuration.Settings.Language.General.Apply; + groupBoxRule.Text = Configuration.Settings.Language.ModifySelection.Rule; + groupBoxWhatToDo.Text = Configuration.Settings.Language.ModifySelection.DoWithMatches; + checkBoxCaseSensitive.Text = Configuration.Settings.Language.ModifySelection.CaseSensitive; + radioButtonNewSelection.Text = Configuration.Settings.Language.ModifySelection.MakeNewSelection; + radioButtonAddToSelection.Text = Configuration.Settings.Language.ModifySelection.AddToCurrentSelection; + radioButtonSubtractFromSelection.Text = Configuration.Settings.Language.ModifySelection.SubtractFromCurrentSelection; + radioButtonIntersect.Text = Configuration.Settings.Language.ModifySelection.IntersectWithCurrentSelection; + columnHeaderApply.Text = Configuration.Settings.Language.General.Apply; + columnHeaderLine.Text = Configuration.Settings.Language.General.LineNumber; + columnHeaderText.Text = Configuration.Settings.Language.General.Text; + toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; + toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; + + listViewStyles.Visible = false; + + UiUtil.FixLargeFonts(this, buttonOK); + + comboBoxRule.Items.Clear(); + comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.Contains); + comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.StartsWith); + comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.EndsWith); + comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.NoContains); + comboBoxRule.Items.Add(Configuration.Settings.Language.ChangeCasing.AllUppercase); + comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.RegEx); + comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.UnequalLines); + comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.EqualLines); + comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.DurationLessThan); + comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.DurationGreaterThan); + comboBoxRule.Items.Add(Configuration.Settings.Language.ModifySelection.MoreThanTwoLines); + if (_format.HasStyleSupport) + { + comboBoxRule.Items.Add(Configuration.Settings.Language.General.Style); + } + if (_format.HasStyleSupport && (_format.GetType() == typeof(AdvancedSubStationAlpha) || _format.GetType() == typeof(SubStationAlpha))) + { + comboBoxRule.Items.Add(Configuration.Settings.Language.General.Actor); + } + + checkBoxCaseSensitive.Checked = Configuration.Settings.Tools.ModifySelectionCaseSensitive; + textBoxText.Text = Configuration.Settings.Tools.ModifySelectionText; + if (Configuration.Settings.Tools.ModifySelectionRule == "Starts with") + { + comboBoxRule.SelectedIndex = FunctionStartsWith; + } + else if (Configuration.Settings.Tools.ModifySelectionRule == "Ends with") + { + comboBoxRule.SelectedIndex = FunctionEndsWith; + } + else if (Configuration.Settings.Tools.ModifySelectionRule == "Not contains") + { + comboBoxRule.SelectedIndex = FunctionNotContains; + } + else if (Configuration.Settings.Tools.ModifySelectionRule == "AllUppercase") + { + comboBoxRule.SelectedIndex = FunctionAlUppercase; + } + else if (Configuration.Settings.Tools.ModifySelectionRule == "RegEx") + { + comboBoxRule.SelectedIndex = FunctionRegEx; + } + else if (Configuration.Settings.Tools.ModifySelectionRule == "Duration <") + { + comboBoxRule.SelectedIndex = FunctionDurationLessThan; + } + else if (Configuration.Settings.Tools.ModifySelectionRule == "Duration >") + { + comboBoxRule.SelectedIndex = FunctionDurationGreaterThan; + } + else if (Configuration.Settings.Tools.ModifySelectionRule == "More than two lines") + { + comboBoxRule.SelectedIndex = FunctionMoreThanTwoLines; + } + else if (Configuration.Settings.Tools.ModifySelectionRule == "Style" && _format.HasStyleSupport) + { + comboBoxRule.SelectedIndex = FunctionStyle; + } + else if (Configuration.Settings.Tools.ModifySelectionRule == "Actor" && (_format.GetType() == typeof(AdvancedSubStationAlpha) || _format.GetType() == typeof(SubStationAlpha))) + { + comboBoxRule.SelectedIndex = FunctionActor; + } + else + { + comboBoxRule.SelectedIndex = 0; + } + + if (!_format.HasStyleSupport) + { + listViewFixes.Columns.Remove(columnHeaderStyle); + } + ModifySelection_Resize(null, null); + + _loading = false; + Preview(); + } + + private void ModifySelection_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void buttonOK_Click(object sender, EventArgs e) + { + ApplySelection(); + DialogResult = DialogResult.OK; + + Configuration.Settings.Tools.ModifySelectionCaseSensitive = checkBoxCaseSensitive.Checked; + Configuration.Settings.Tools.ModifySelectionText = textBoxText.Text; + if (comboBoxRule.SelectedIndex == FunctionContains) + { + Configuration.Settings.Tools.ModifySelectionRule = "Contains"; + } + else if (comboBoxRule.SelectedIndex == FunctionStartsWith) + { + Configuration.Settings.Tools.ModifySelectionRule = "Starts with"; + } + else if (comboBoxRule.SelectedIndex == FunctionEndsWith) + { + Configuration.Settings.Tools.ModifySelectionRule = "Ends with"; + } + else if (comboBoxRule.SelectedIndex == FunctionNotContains) + { + Configuration.Settings.Tools.ModifySelectionRule = "Not contains"; + } + else if (comboBoxRule.SelectedIndex == FunctionAlUppercase) + { + Configuration.Settings.Tools.ModifySelectionRule = "AllUppercase"; + } + else if (comboBoxRule.SelectedIndex == FunctionRegEx) + { + Configuration.Settings.Tools.ModifySelectionRule = "RegEx"; + } + else if (comboBoxRule.SelectedIndex == FunctionDurationLessThan) + { + Configuration.Settings.Tools.ModifySelectionRule = "Duration <"; + } + else if (comboBoxRule.SelectedIndex == FunctionDurationGreaterThan) + { + Configuration.Settings.Tools.ModifySelectionRule = "Duration >"; + } + else if (comboBoxRule.SelectedIndex == FunctionMoreThanTwoLines) + { + Configuration.Settings.Tools.ModifySelectionRule = "More than two lines"; + } + else if (comboBoxRule.SelectedIndex == FunctionStyle) + { + Configuration.Settings.Tools.ModifySelectionRule = "Style"; + } + else if (comboBoxRule.SelectedIndex == FunctionActor) + { + Configuration.Settings.Tools.ModifySelectionRule = "Actor"; + } + } + + private void buttonApply_Click(object sender, EventArgs e) + { + ApplySelection(); + } + + private ListViewItem MakeListViewItem(Paragraph p, int index) + { + var item = new ListViewItem(string.Empty) { Tag = index, Checked = true }; + item.SubItems.Add(p.Number.ToString()); + item.SubItems.Add(UiUtil.GetListViewTextFromString(p.Text)); + if (_format.HasStyleSupport) + { + item.SubItems.Add(string.IsNullOrEmpty(p.Style) ? p.Extra : p.Style); + } + + return item; + } + + private void Preview() + { + if (_loading) + { + return; + } + + Regex regEx = null; + var listViewItems = new List(); + listViewFixes.BeginUpdate(); + listViewFixes.Items.Clear(); + string text = textBoxText.Text; + if (comboBoxRule.SelectedIndex != FunctionRegEx) + { + text = text.Replace("\\r\\n", Environment.NewLine); + } + + var styles = new List(); + var actors = new List(); + if (comboBoxRule.SelectedIndex == FunctionStyle) // select styles + { + foreach (ListViewItem item in listViewStyles.Items) + { + if (item.Checked) + { + styles.Add(item.Text); + } + } + } + else if (comboBoxRule.SelectedIndex == FunctionActor) // select actors + { + foreach (ListViewItem item in listViewStyles.Items) + { + if (item.Checked) + { + actors.Add(item.Text); + } + } + } + + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + if ((radioButtonSubtractFromSelection.Checked || radioButtonIntersect.Checked) && _subtitleListView.Items[i].Selected || + !radioButtonSubtractFromSelection.Checked && !radioButtonIntersect.Checked) + { + var p = _subtitle.Paragraphs[i]; + if (text.Length > 0) + { + if (comboBoxRule.SelectedIndex == FunctionContains) // Contains + { + if (checkBoxCaseSensitive.Checked && p.Text.Contains(text, StringComparison.Ordinal) || !checkBoxCaseSensitive.Checked && p.Text.Contains(text, StringComparison.OrdinalIgnoreCase)) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + else if (comboBoxRule.SelectedIndex == FunctionStartsWith) // Starts with + { + if (checkBoxCaseSensitive.Checked && p.Text.StartsWith(text, StringComparison.Ordinal) || !checkBoxCaseSensitive.Checked && p.Text.StartsWith(text, StringComparison.OrdinalIgnoreCase)) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + else if (comboBoxRule.SelectedIndex == FunctionEndsWith) // Ends with + { + if (checkBoxCaseSensitive.Checked && p.Text.EndsWith(text, StringComparison.Ordinal) || !checkBoxCaseSensitive.Checked && p.Text.EndsWith(text, StringComparison.OrdinalIgnoreCase)) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + else if (comboBoxRule.SelectedIndex == FunctionNotContains) // Not contains + { + if (checkBoxCaseSensitive.Checked && !p.Text.Contains(text, StringComparison.Ordinal) || !checkBoxCaseSensitive.Checked && !p.Text.Contains(text, StringComparison.OrdinalIgnoreCase)) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + else if (comboBoxRule.SelectedIndex == FunctionRegEx) // RegEx + { + labelInfo.Text = string.Empty; + if (regEx == null) + { + try + { + regEx = new Regex(text, RegexOptions.Compiled); + } + catch (Exception e) + { + labelInfo.Text = e.Message; + break; + } + } + if (regEx.IsMatch(p.Text)) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + } + if (comboBoxRule.SelectedIndex == FunctionUnequal) // select unequal lines + { + if (i % 2 == 0) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + else if (comboBoxRule.SelectedIndex == FunctionEqual) // select equal lines + { + if (i % 2 == 1) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + else if (comboBoxRule.SelectedIndex == FunctionDurationLessThan) // duration less than + { + if (p.Duration.TotalMilliseconds < (double)numericUpDownDuration.Value) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + else if (comboBoxRule.SelectedIndex == FunctionDurationGreaterThan) // duration greater than + { + if (p.Duration.TotalMilliseconds > (double)numericUpDownDuration.Value) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + else if (comboBoxRule.SelectedIndex == FunctionMoreThanTwoLines) + { + if (p.Text.SplitToLines().Count > 2) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + else if (comboBoxRule.SelectedIndex == FunctionAlUppercase) // all uppercase + { + if (HtmlUtil.RemoveHtmlTags(p.Text, true) == HtmlUtil.RemoveHtmlTags(p.Text, true).ToUpperInvariant() && p.Text != p.Text.ToLowerInvariant()) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + else if (comboBoxRule.SelectedIndex == FunctionStyle) // select styles + { + if (styles.Contains(string.IsNullOrEmpty(p.Style) ? p.Extra : p.Style)) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + else if (comboBoxRule.SelectedIndex == FunctionActor) // select actors + { + if (actors.Contains(p.Actor)) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + } + } + + listViewFixes.Items.AddRange(listViewItems.ToArray()); + listViewFixes.EndUpdate(); + groupBoxPreview.Text = string.Format(Configuration.Settings.Language.ModifySelection.MatchingLinesX, listViewFixes.Items.Count); + } + + private void ApplySelection() + { + _subtitleListView.BeginUpdate(); + if (radioButtonNewSelection.Checked || radioButtonIntersect.Checked) + { + _subtitleListView.SelectNone(); + } + + if (radioButtonNewSelection.Checked || radioButtonAddToSelection.Checked || radioButtonIntersect.Checked) + { + foreach (ListViewItem item in listViewFixes.Items) + { + if (item.Checked) + { + int index = Convert.ToInt32(item.Tag); + _subtitleListView.Items[index].Selected = true; + } + } + } + else if (radioButtonSubtractFromSelection.Checked) + { + foreach (ListViewItem item in listViewFixes.Items) + { + if (item.Checked) + { + int index = Convert.ToInt32(item.Tag); + _subtitleListView.Items[index].Selected = false; + } + } + } + _subtitleListView.EndUpdate(); + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + Preview(); + } + + private void comboBoxRule_SelectedIndexChanged(object sender, EventArgs e) + { + textBoxText.Visible = true; + listViewStyles.Visible = false; + numericUpDownDuration.Visible = comboBoxRule.SelectedIndex == FunctionDurationLessThan || comboBoxRule.SelectedIndex == FunctionDurationGreaterThan; + if (comboBoxRule.SelectedIndex == FunctionRegEx) // regex + { + textBoxText.ContextMenu = FindReplaceDialogHelper.GetRegExContextMenu(textBoxText); + checkBoxCaseSensitive.Enabled = false; + } + else if (comboBoxRule.SelectedIndex == FunctionUnequal || comboBoxRule.SelectedIndex == FunctionEqual || comboBoxRule.SelectedIndex == FunctionMoreThanTwoLines) + { + textBoxText.ContextMenuStrip = null; + checkBoxCaseSensitive.Enabled = false; + textBoxText.Visible = false; + } + else if (comboBoxRule.SelectedIndex == FunctionStyle) + { + checkBoxCaseSensitive.Enabled = false; + listViewStyles.Visible = true; + listViewStyles.BringToFront(); + FillStyles(); + } + else if (comboBoxRule.SelectedIndex == FunctionActor) + { + checkBoxCaseSensitive.Enabled = false; + listViewStyles.Visible = true; + listViewStyles.BringToFront(); + FillActors(); + } + else if (comboBoxRule.SelectedIndex == FunctionDurationLessThan || comboBoxRule.SelectedIndex == FunctionDurationGreaterThan || comboBoxRule.SelectedIndex == FunctionAlUppercase) + { + checkBoxCaseSensitive.Enabled = false; + listViewStyles.Visible = false; + textBoxText.Visible = false; + if (comboBoxRule.SelectedIndex == FunctionDurationLessThan) + { + if (numericUpDownDuration.Value == 0 && + Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds >= numericUpDownDuration.Minimum && + Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds <= numericUpDownDuration.Maximum) + { + numericUpDownDuration.Value = Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds; + } + } + else + { + if (numericUpDownDuration.Value == 0 && + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds >= numericUpDownDuration.Minimum && + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds <= numericUpDownDuration.Maximum) + { + numericUpDownDuration.Value = Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds; + } + } + } + else + { + textBoxText.ContextMenuStrip = null; + checkBoxCaseSensitive.Enabled = true; + } + + Preview(); + } + + private void FillStyles() + { + listViewStyles.Columns[listViewStyles.Columns.Count - 1].Width = -2; + var styles = new List(); + var formatType = _format.GetType(); + if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha)) + { + styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); + } + else if (formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText)) + { + styles = TimedText10.GetStylesFromHeader(_subtitle.Header); + } + else if (formatType == typeof(Sami) || formatType == typeof(SamiModern)) + { + styles = _subtitle.Header == null ? Sami.GetStylesFromSubtitle(_subtitle) : Sami.GetStylesFromHeader(_subtitle.Header); + } + + listViewStyles.Items.Clear(); + foreach (var style in styles.OrderBy(p => p)) + { + listViewStyles.Items.Add(style); + } + } + + private void FillActors() + { + listViewStyles.Columns[listViewStyles.Columns.Count - 1].Width = -2; + var actors = new List(); + foreach (var paragraph in _subtitle.Paragraphs) + { + if (!string.IsNullOrEmpty(paragraph.Actor) && !actors.Contains(paragraph.Actor)) + { + actors.Add(paragraph.Actor); + } + } + + listViewStyles.Items.Clear(); + foreach (var style in actors.OrderBy(p => p)) + { + listViewStyles.Items.Add(style); + } + } + + private void checkBoxCaseSensitive_CheckedChanged(object sender, EventArgs e) + { + Preview(); + } + + private void radioButton_CheckedChanged(object sender, EventArgs e) + { + Preview(); + } + + private void ModifySelection_Resize(object sender, EventArgs e) + { + listViewFixes.Columns[listViewFixes.Columns.Count - 1].Width = -2; + } + + private void listViewStyles_ItemChecked(object sender, ItemCheckedEventArgs e) + { + Preview(); + } + + private void numericUpDownDuration_ValueChanged(object sender, EventArgs e) + { + Preview(); + } + + private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = true; + } + } + + private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = !item.Checked; + } + } + } +} diff --git a/src/Forms/ModifySelection.resx b/src/ui/Forms/ModifySelection.resx similarity index 97% rename from src/Forms/ModifySelection.resx rename to src/ui/Forms/ModifySelection.resx index 661dc1126..ad537526f 100644 --- a/src/Forms/ModifySelection.resx +++ b/src/ui/Forms/ModifySelection.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/MultipleReplace.Designer.cs b/src/ui/Forms/MultipleReplace.Designer.cs similarity index 98% rename from src/Forms/MultipleReplace.Designer.cs rename to src/ui/Forms/MultipleReplace.Designer.cs index a754f6afa..21cc4b29b 100644 --- a/src/Forms/MultipleReplace.Designer.cs +++ b/src/ui/Forms/MultipleReplace.Designer.cs @@ -1,810 +1,810 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class MultipleReplace - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); - this.buttonReplacesInverseSelection = new System.Windows.Forms.Button(); - this.buttonReplacesSelectAll = new System.Windows.Forms.Button(); - this.listViewFixes = new System.Windows.Forms.ListView(); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.groupBoxReplaces = new System.Windows.Forms.GroupBox(); - this.labelDescription = new System.Windows.Forms.Label(); - this.textBoxDescription = new System.Windows.Forms.TextBox(); - this.radioButtonRegEx = new System.Windows.Forms.RadioButton(); - this.radioButtonCaseSensitive = new System.Windows.Forms.RadioButton(); - this.textBoxFind = new System.Windows.Forms.TextBox(); - this.textBoxReplace = new System.Windows.Forms.TextBox(); - this.buttonUpdate = new System.Windows.Forms.Button(); - this.buttonAdd = new System.Windows.Forms.Button(); - this.labelFindWhat = new System.Windows.Forms.Label(); - this.labelReplaceWith = new System.Windows.Forms.Label(); - this.listViewRules = new System.Windows.Forms.ListView(); - this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader9 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.contextMenuStripRules = new System.Windows.Forms.ContextMenuStrip(this.components); - this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemRemoveAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItemMoveRulesToGroup = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); - this.moveUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.moveDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.moveTopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.moveBottomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItemImport = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemExport = new System.Windows.Forms.ToolStripMenuItem(); - this.radioButtonNormal = new System.Windows.Forms.RadioButton(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.groupBoxGroups = new System.Windows.Forms.GroupBox(); - this.buttonExportGroups = new System.Windows.Forms.Button(); - this.buttonImportGroups = new System.Windows.Forms.Button(); - this.buttonNewGroup = new System.Windows.Forms.Button(); - this.listViewGroups = new System.Windows.Forms.ListView(); - this.columnHeaderForName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.contextMenuStripGroups = new System.Windows.Forms.ContextMenuStrip(this.components); - this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemRename = new System.Windows.Forms.ToolStripMenuItem(); - this.deleteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.moveUpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.moveDownToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.moveToTopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.moveToBottomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparatorGroupImportExport = new System.Windows.Forms.ToolStripSeparator(); - this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.buttonApply = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.groupBoxLinesFound.SuspendLayout(); - this.groupBoxReplaces.SuspendLayout(); - this.contextMenuStripRules.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - this.groupBoxGroups.SuspendLayout(); - this.contextMenuStripGroups.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxLinesFound - // - this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxLinesFound.Controls.Add(this.buttonReplacesInverseSelection); - this.groupBoxLinesFound.Controls.Add(this.buttonReplacesSelectAll); - this.groupBoxLinesFound.Controls.Add(this.listViewFixes); - this.groupBoxLinesFound.Location = new System.Drawing.Point(4, 14); - this.groupBoxLinesFound.Name = "groupBoxLinesFound"; - this.groupBoxLinesFound.Size = new System.Drawing.Size(1046, 232); - this.groupBoxLinesFound.TabIndex = 8; - this.groupBoxLinesFound.TabStop = false; - this.groupBoxLinesFound.Text = "Lines found: {0}"; - // - // buttonReplacesInverseSelection - // - this.buttonReplacesInverseSelection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonReplacesInverseSelection.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonReplacesInverseSelection.Location = new System.Drawing.Point(91, 204); - this.buttonReplacesInverseSelection.Name = "buttonReplacesInverseSelection"; - this.buttonReplacesInverseSelection.Size = new System.Drawing.Size(100, 23); - this.buttonReplacesInverseSelection.TabIndex = 12; - this.buttonReplacesInverseSelection.Text = "&Inverse selection"; - this.buttonReplacesInverseSelection.UseVisualStyleBackColor = true; - this.buttonReplacesInverseSelection.Click += new System.EventHandler(this.buttonReplacesInverseSelection_Click); - // - // buttonReplacesSelectAll - // - this.buttonReplacesSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonReplacesSelectAll.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonReplacesSelectAll.Location = new System.Drawing.Point(10, 204); - this.buttonReplacesSelectAll.Name = "buttonReplacesSelectAll"; - this.buttonReplacesSelectAll.Size = new System.Drawing.Size(75, 23); - this.buttonReplacesSelectAll.TabIndex = 11; - this.buttonReplacesSelectAll.Text = "Select &all"; - this.buttonReplacesSelectAll.UseVisualStyleBackColor = true; - this.buttonReplacesSelectAll.Click += new System.EventHandler(this.buttonReplacesSelectAll_Click); - // - // listViewFixes - // - this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewFixes.CheckBoxes = true; - this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader4, - this.columnHeader5, - this.columnHeader7, - this.columnHeader8}); - this.listViewFixes.FullRowSelect = true; - this.listViewFixes.HideSelection = false; - this.listViewFixes.Location = new System.Drawing.Point(10, 21); - this.listViewFixes.Name = "listViewFixes"; - this.listViewFixes.Size = new System.Drawing.Size(1030, 177); - this.listViewFixes.TabIndex = 10; - this.listViewFixes.UseCompatibleStateImageBehavior = false; - this.listViewFixes.View = System.Windows.Forms.View.Details; - this.listViewFixes.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listViewFixes_KeyDown); - // - // columnHeader4 - // - this.columnHeader4.Text = "Apply"; - this.columnHeader4.Width = 48; - // - // columnHeader5 - // - this.columnHeader5.Text = "Line#"; - this.columnHeader5.Width = 61; - // - // columnHeader7 - // - this.columnHeader7.Text = "Before"; - this.columnHeader7.Width = 330; - // - // columnHeader8 - // - this.columnHeader8.Text = "After"; - this.columnHeader8.Width = 440; - // - // groupBoxReplaces - // - this.groupBoxReplaces.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxReplaces.Controls.Add(this.labelDescription); - this.groupBoxReplaces.Controls.Add(this.textBoxDescription); - this.groupBoxReplaces.Controls.Add(this.radioButtonRegEx); - this.groupBoxReplaces.Controls.Add(this.radioButtonCaseSensitive); - this.groupBoxReplaces.Controls.Add(this.textBoxFind); - this.groupBoxReplaces.Controls.Add(this.textBoxReplace); - this.groupBoxReplaces.Controls.Add(this.buttonUpdate); - this.groupBoxReplaces.Controls.Add(this.buttonAdd); - this.groupBoxReplaces.Controls.Add(this.labelFindWhat); - this.groupBoxReplaces.Controls.Add(this.labelReplaceWith); - this.groupBoxReplaces.Controls.Add(this.listViewRules); - this.groupBoxReplaces.Controls.Add(this.radioButtonNormal); - this.groupBoxReplaces.Location = new System.Drawing.Point(235, 3); - this.groupBoxReplaces.Name = "groupBoxReplaces"; - this.groupBoxReplaces.Size = new System.Drawing.Size(809, 257); - this.groupBoxReplaces.TabIndex = 1; - this.groupBoxReplaces.TabStop = false; - this.groupBoxReplaces.Text = "Rules for group \"X\""; - // - // labelDescription - // - this.labelDescription.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelDescription.AutoSize = true; - this.labelDescription.Location = new System.Drawing.Point(400, 184); - this.labelDescription.Name = "labelDescription"; - this.labelDescription.Size = new System.Drawing.Size(64, 13); - this.labelDescription.TabIndex = 11; - this.labelDescription.Text = "Description:"; - // - // textBoxDescription - // - this.textBoxDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxDescription.Location = new System.Drawing.Point(403, 202); - this.textBoxDescription.Name = "textBoxDescription"; - this.textBoxDescription.Size = new System.Drawing.Size(190, 21); - this.textBoxDescription.TabIndex = 5; - // - // radioButtonRegEx - // - this.radioButtonRegEx.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.radioButtonRegEx.AutoSize = true; - this.radioButtonRegEx.Location = new System.Drawing.Point(177, 230); - this.radioButtonRegEx.Name = "radioButtonRegEx"; - this.radioButtonRegEx.Size = new System.Drawing.Size(56, 17); - this.radioButtonRegEx.TabIndex = 12; - this.radioButtonRegEx.Text = "RegEx"; - this.radioButtonRegEx.UseVisualStyleBackColor = true; - this.radioButtonRegEx.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // - // radioButtonCaseSensitive - // - this.radioButtonCaseSensitive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.radioButtonCaseSensitive.AutoSize = true; - this.radioButtonCaseSensitive.Location = new System.Drawing.Point(75, 230); - this.radioButtonCaseSensitive.Name = "radioButtonCaseSensitive"; - this.radioButtonCaseSensitive.Size = new System.Drawing.Size(94, 17); - this.radioButtonCaseSensitive.TabIndex = 11; - this.radioButtonCaseSensitive.Text = "Case sensitive"; - this.radioButtonCaseSensitive.UseVisualStyleBackColor = true; - this.radioButtonCaseSensitive.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // - // textBoxFind - // - this.textBoxFind.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.textBoxFind.Location = new System.Drawing.Point(9, 203); - this.textBoxFind.Name = "textBoxFind"; - this.textBoxFind.Size = new System.Drawing.Size(211, 21); - this.textBoxFind.TabIndex = 2; - // - // textBoxReplace - // - this.textBoxReplace.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.textBoxReplace.Location = new System.Drawing.Point(226, 203); - this.textBoxReplace.Name = "textBoxReplace"; - this.textBoxReplace.Size = new System.Drawing.Size(171, 21); - this.textBoxReplace.TabIndex = 4; - this.textBoxReplace.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxReplaceKeyDown); - // - // buttonUpdate - // - this.buttonUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUpdate.Location = new System.Drawing.Point(704, 201); - this.buttonUpdate.Name = "buttonUpdate"; - this.buttonUpdate.Size = new System.Drawing.Size(99, 23); - this.buttonUpdate.TabIndex = 7; - this.buttonUpdate.Text = "&Update"; - this.buttonUpdate.UseVisualStyleBackColor = true; - this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdateClick); - // - // buttonAdd - // - this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonAdd.Location = new System.Drawing.Point(599, 201); - this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(99, 23); - this.buttonAdd.TabIndex = 6; - this.buttonAdd.Text = "&Add"; - this.buttonAdd.UseVisualStyleBackColor = true; - this.buttonAdd.Click += new System.EventHandler(this.ButtonAddClick); - // - // labelFindWhat - // - this.labelFindWhat.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelFindWhat.AutoSize = true; - this.labelFindWhat.Location = new System.Drawing.Point(6, 184); - this.labelFindWhat.Name = "labelFindWhat"; - this.labelFindWhat.Size = new System.Drawing.Size(58, 13); - this.labelFindWhat.TabIndex = 1; - this.labelFindWhat.Text = "Find what:"; - // - // labelReplaceWith - // - this.labelReplaceWith.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelReplaceWith.AutoSize = true; - this.labelReplaceWith.Location = new System.Drawing.Point(223, 184); - this.labelReplaceWith.Name = "labelReplaceWith"; - this.labelReplaceWith.Size = new System.Drawing.Size(72, 13); - this.labelReplaceWith.TabIndex = 3; - this.labelReplaceWith.Text = "Replace with:"; - // - // listViewRules - // - this.listViewRules.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewRules.CheckBoxes = true; - this.listViewRules.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.columnHeader2, - this.columnHeader3, - this.columnHeader6, - this.columnHeader9}); - this.listViewRules.ContextMenuStrip = this.contextMenuStripRules; - this.listViewRules.FullRowSelect = true; - this.listViewRules.HideSelection = false; - this.listViewRules.Location = new System.Drawing.Point(9, 20); - this.listViewRules.Name = "listViewRules"; - this.listViewRules.Size = new System.Drawing.Size(797, 149); - this.listViewRules.TabIndex = 0; - this.listViewRules.UseCompatibleStateImageBehavior = false; - this.listViewRules.View = System.Windows.Forms.View.Details; - this.listViewRules.SelectedIndexChanged += new System.EventHandler(this.ListViewReplaceListSelectedIndexChanged); - this.listViewRules.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ListViewRulesKeyDown); - // - // columnHeader1 - // - this.columnHeader1.Text = "Enabled"; - this.columnHeader1.Width = 70; - // - // columnHeader2 - // - this.columnHeader2.Text = "Find what"; - this.columnHeader2.Width = 200; - // - // columnHeader3 - // - this.columnHeader3.Text = "Replace with"; - this.columnHeader3.Width = 170; - // - // columnHeader6 - // - this.columnHeader6.Text = "Search type"; - this.columnHeader6.Width = 170; - // - // columnHeader9 - // - this.columnHeader9.Text = "Description"; - this.columnHeader9.Width = 166; - // - // contextMenuStripRules - // - this.contextMenuStripRules.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.deleteToolStripMenuItem, - this.toolStripMenuItemRemoveAll, - this.toolStripSeparator2, - this.toolStripMenuItemMoveRulesToGroup, - this.toolStripSeparator4, - this.moveUpToolStripMenuItem, - this.moveDownToolStripMenuItem, - this.moveTopToolStripMenuItem, - this.moveBottomToolStripMenuItem, - this.toolStripSeparator3, - this.toolStripMenuItemImport, - this.toolStripMenuItemExport}); - this.contextMenuStripRules.Name = "contextMenuStrip1"; - this.contextMenuStripRules.Size = new System.Drawing.Size(228, 220); - this.contextMenuStripRules.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); - // - // deleteToolStripMenuItem - // - this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Delete; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(227, 22); - this.deleteToolStripMenuItem.Text = "Remove"; - this.deleteToolStripMenuItem.Click += new System.EventHandler(this.DeleteToolStripMenuItemClick); - // - // toolStripMenuItemRemoveAll - // - this.toolStripMenuItemRemoveAll.Name = "toolStripMenuItemRemoveAll"; - this.toolStripMenuItemRemoveAll.Size = new System.Drawing.Size(227, 22); - this.toolStripMenuItemRemoveAll.Text = "Remove all"; - this.toolStripMenuItemRemoveAll.Click += new System.EventHandler(this.toolStripMenuItem2_Click); - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(224, 6); - // - // toolStripMenuItemMoveRulesToGroup - // - this.toolStripMenuItemMoveRulesToGroup.Name = "toolStripMenuItemMoveRulesToGroup"; - this.toolStripMenuItemMoveRulesToGroup.Size = new System.Drawing.Size(227, 22); - this.toolStripMenuItemMoveRulesToGroup.Text = "Move selected rules to group"; - // - // toolStripSeparator4 - // - this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(224, 6); - // - // moveUpToolStripMenuItem - // - this.moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem"; - this.moveUpToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Up))); - this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(227, 22); - this.moveUpToolStripMenuItem.Text = "Move up"; - this.moveUpToolStripMenuItem.Click += new System.EventHandler(this.moveUpToolStripMenuItem_Click); - // - // moveDownToolStripMenuItem - // - this.moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem"; - this.moveDownToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Down))); - this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(227, 22); - this.moveDownToolStripMenuItem.Text = "Move down"; - this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click); - // - // moveTopToolStripMenuItem - // - this.moveTopToolStripMenuItem.Name = "moveTopToolStripMenuItem"; - this.moveTopToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Home))); - this.moveTopToolStripMenuItem.Size = new System.Drawing.Size(227, 22); - this.moveTopToolStripMenuItem.Text = "Move to top"; - this.moveTopToolStripMenuItem.Click += new System.EventHandler(this.moveTopToolStripMenuItem_Click); - // - // moveBottomToolStripMenuItem - // - this.moveBottomToolStripMenuItem.Name = "moveBottomToolStripMenuItem"; - this.moveBottomToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.End))); - this.moveBottomToolStripMenuItem.Size = new System.Drawing.Size(227, 22); - this.moveBottomToolStripMenuItem.Text = "Move to bottom"; - this.moveBottomToolStripMenuItem.Click += new System.EventHandler(this.moveBottomToolStripMenuItem_Click); - // - // toolStripSeparator3 - // - this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(224, 6); - // - // toolStripMenuItemImport - // - this.toolStripMenuItemImport.Name = "toolStripMenuItemImport"; - this.toolStripMenuItemImport.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); - this.toolStripMenuItemImport.Size = new System.Drawing.Size(227, 22); - this.toolStripMenuItemImport.Text = "Import..."; - this.toolStripMenuItemImport.Click += new System.EventHandler(this.toolStripMenuItem3_Click); - // - // toolStripMenuItemExport - // - this.toolStripMenuItemExport.Name = "toolStripMenuItemExport"; - this.toolStripMenuItemExport.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E))); - this.toolStripMenuItemExport.Size = new System.Drawing.Size(227, 22); - this.toolStripMenuItemExport.Text = "Export..."; - this.toolStripMenuItemExport.Click += new System.EventHandler(this.toolStripMenuItem4_Click); - // - // radioButtonNormal - // - this.radioButtonNormal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.radioButtonNormal.AutoSize = true; - this.radioButtonNormal.Checked = true; - this.radioButtonNormal.Location = new System.Drawing.Point(11, 230); - this.radioButtonNormal.Name = "radioButtonNormal"; - this.radioButtonNormal.Size = new System.Drawing.Size(58, 17); - this.radioButtonNormal.TabIndex = 10; - this.radioButtonNormal.TabStop = true; - this.radioButtonNormal.Text = "Normal"; - this.radioButtonNormal.UseVisualStyleBackColor = true; - this.radioButtonNormal.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(804, 251); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 14; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(885, 251); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 15; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // splitContainer1 - // - this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.Location = new System.Drawing.Point(0, 0); - this.splitContainer1.Name = "splitContainer1"; - this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.groupBoxGroups); - this.splitContainer1.Panel1.Controls.Add(this.groupBoxReplaces); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.buttonApply); - this.splitContainer1.Panel2.Controls.Add(this.groupBoxLinesFound); - this.splitContainer1.Panel2.Controls.Add(this.buttonOK); - this.splitContainer1.Panel2.Controls.Add(this.buttonCancel); - this.splitContainer1.Size = new System.Drawing.Size(1053, 555); - this.splitContainer1.SplitterDistance = 263; - this.splitContainer1.TabIndex = 0; - // - // groupBoxGroups - // - this.groupBoxGroups.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.groupBoxGroups.Controls.Add(this.buttonExportGroups); - this.groupBoxGroups.Controls.Add(this.buttonImportGroups); - this.groupBoxGroups.Controls.Add(this.buttonNewGroup); - this.groupBoxGroups.Controls.Add(this.listViewGroups); - this.groupBoxGroups.Location = new System.Drawing.Point(6, 3); - this.groupBoxGroups.Name = "groupBoxGroups"; - this.groupBoxGroups.Size = new System.Drawing.Size(223, 257); - this.groupBoxGroups.TabIndex = 0; - this.groupBoxGroups.TabStop = false; - this.groupBoxGroups.Text = "Groups"; - // - // buttonExportGroups - // - this.buttonExportGroups.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonExportGroups.Location = new System.Drawing.Point(118, 230); - this.buttonExportGroups.Name = "buttonExportGroups"; - this.buttonExportGroups.Size = new System.Drawing.Size(99, 23); - this.buttonExportGroups.TabIndex = 3; - this.buttonExportGroups.Text = "Export"; - this.buttonExportGroups.UseVisualStyleBackColor = true; - this.buttonExportGroups.Click += new System.EventHandler(this.buttonExportGroups_Click); - // - // buttonImportGroups - // - this.buttonImportGroups.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonImportGroups.Location = new System.Drawing.Point(8, 230); - this.buttonImportGroups.Name = "buttonImportGroups"; - this.buttonImportGroups.Size = new System.Drawing.Size(104, 23); - this.buttonImportGroups.TabIndex = 2; - this.buttonImportGroups.Text = "Import"; - this.buttonImportGroups.UseVisualStyleBackColor = true; - this.buttonImportGroups.Click += new System.EventHandler(this.buttonImportGroups_Click); - // - // buttonNewGroup - // - this.buttonNewGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonNewGroup.Location = new System.Drawing.Point(8, 203); - this.buttonNewGroup.Name = "buttonNewGroup"; - this.buttonNewGroup.Size = new System.Drawing.Size(209, 23); - this.buttonNewGroup.TabIndex = 1; - this.buttonNewGroup.Text = "New"; - this.buttonNewGroup.UseVisualStyleBackColor = true; - this.buttonNewGroup.Click += new System.EventHandler(this.buttonNewGroup_Click); - // - // listViewGroups - // - this.listViewGroups.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewGroups.CheckBoxes = true; - this.listViewGroups.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderForName}); - this.listViewGroups.ContextMenuStrip = this.contextMenuStripGroups; - this.listViewGroups.FullRowSelect = true; - this.listViewGroups.GridLines = true; - this.listViewGroups.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; - this.listViewGroups.HideSelection = false; - this.listViewGroups.Location = new System.Drawing.Point(8, 20); - this.listViewGroups.MultiSelect = false; - this.listViewGroups.Name = "listViewGroups"; - this.listViewGroups.Size = new System.Drawing.Size(209, 177); - this.listViewGroups.TabIndex = 0; - this.listViewGroups.UseCompatibleStateImageBehavior = false; - this.listViewGroups.View = System.Windows.Forms.View.Details; - // - // columnHeaderForName - // - this.columnHeaderForName.Text = "Active"; - this.columnHeaderForName.Width = 205; - // - // contextMenuStripGroups - // - this.contextMenuStripGroups.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.newToolStripMenuItem, - this.toolStripMenuItemRename, - this.deleteToolStripMenuItem1, - this.toolStripSeparator1, - this.moveUpToolStripMenuItem1, - this.moveDownToolStripMenuItem1, - this.moveToTopToolStripMenuItem, - this.moveToBottomToolStripMenuItem, - this.toolStripSeparatorGroupImportExport, - this.importToolStripMenuItem, - this.exportToolStripMenuItem}); - this.contextMenuStripGroups.Name = "contextMenuStripGroups"; - this.contextMenuStripGroups.Size = new System.Drawing.Size(162, 214); - this.contextMenuStripGroups.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripGroups_Opening); - // - // newToolStripMenuItem - // - this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift | System.Windows.Forms.Keys.N))); - this.newToolStripMenuItem.Size = new System.Drawing.Size(161, 22); - this.newToolStripMenuItem.Text = "New..."; - this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click); - // - // toolStripMenuItemRename - // - this.toolStripMenuItemRename.Name = "toolStripMenuItemRename"; - this.toolStripMenuItemRename.ShortcutKeys = System.Windows.Forms.Keys.F2; - this.toolStripMenuItemRename.Size = new System.Drawing.Size(161, 22); - this.toolStripMenuItemRename.Text = "Rename..."; - this.toolStripMenuItemRename.Click += new System.EventHandler(this.ToolStripMenuItemRenameClick); - // - // deleteToolStripMenuItem1 - // - this.deleteToolStripMenuItem1.Name = "deleteToolStripMenuItem1"; - this.deleteToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.Delete; - this.deleteToolStripMenuItem1.Size = new System.Drawing.Size(161, 22); - this.deleteToolStripMenuItem1.Text = "Delete..."; - this.deleteToolStripMenuItem1.Click += new System.EventHandler(this.deleteToolStripMenuItem1_Click); - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(158, 6); - // - // moveUpToolStripMenuItem1 - // - this.moveUpToolStripMenuItem1.Name = "moveUpToolStripMenuItem1"; - this.moveUpToolStripMenuItem1.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Up))); - this.moveUpToolStripMenuItem1.Size = new System.Drawing.Size(161, 22); - this.moveUpToolStripMenuItem1.Text = "Move up"; - this.moveUpToolStripMenuItem1.Click += new System.EventHandler(this.moveUpToolStripMenuItem1_Click); - // - // moveDownToolStripMenuItem1 - // - this.moveDownToolStripMenuItem1.Name = "moveDownToolStripMenuItem1"; - this.moveDownToolStripMenuItem1.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Down))); - this.moveDownToolStripMenuItem1.Size = new System.Drawing.Size(161, 22); - this.moveDownToolStripMenuItem1.Text = "Move down"; - this.moveDownToolStripMenuItem1.Click += new System.EventHandler(this.moveDownToolStripMenuItem1_Click); - // - // moveToTopToolStripMenuItem - // - this.moveToTopToolStripMenuItem.Name = "moveToTopToolStripMenuItem"; - this.moveToTopToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Home))); - this.moveToTopToolStripMenuItem.Size = new System.Drawing.Size(161, 22); - this.moveToTopToolStripMenuItem.Text = "Move to top"; - this.moveToTopToolStripMenuItem.Click += new System.EventHandler(this.moveToTopToolStripMenuItem_Click); - // - // moveToBottomToolStripMenuItem - // - this.moveToBottomToolStripMenuItem.Name = "moveToBottomToolStripMenuItem"; - this.moveToBottomToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.End))); - this.moveToBottomToolStripMenuItem.Size = new System.Drawing.Size(161, 22); - this.moveToBottomToolStripMenuItem.Text = "Move to bottom"; - this.moveToBottomToolStripMenuItem.Click += new System.EventHandler(this.moveToBottomToolStripMenuItem_Click); - // - // toolStripSeparatorGroupImportExport - // - this.toolStripSeparatorGroupImportExport.Name = "toolStripSeparatorGroupImportExport"; - this.toolStripSeparatorGroupImportExport.Size = new System.Drawing.Size(158, 6); - // - // importToolStripMenuItem - // - this.importToolStripMenuItem.Name = "importToolStripMenuItem"; - this.importToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); - this.importToolStripMenuItem.Size = new System.Drawing.Size(161, 22); - this.importToolStripMenuItem.Text = "Import..."; - this.importToolStripMenuItem.Click += new System.EventHandler(this.importToolStripMenuItem_Click); - // - // exportToolStripMenuItem - // - this.exportToolStripMenuItem.Name = "exportToolStripMenuItem"; - this.exportToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E))); - this.exportToolStripMenuItem.Size = new System.Drawing.Size(161, 22); - this.exportToolStripMenuItem.Text = "Export..."; - this.exportToolStripMenuItem.Click += new System.EventHandler(this.exportToolStripMenuItem_Click); - // - // buttonApply - // - this.buttonApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonApply.Location = new System.Drawing.Point(966, 251); - this.buttonApply.Name = "buttonApply"; - this.buttonApply.Size = new System.Drawing.Size(75, 23); - this.buttonApply.TabIndex = 16; - this.buttonApply.Text = "Apply"; - this.buttonApply.UseVisualStyleBackColor = true; - this.buttonApply.Click += new System.EventHandler(this.buttonApply_Click); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // MultipleReplace - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1053, 555); - this.Controls.Add(this.splitContainer1); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(910, 582); - this.Name = "MultipleReplace"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Multiple replace"; - this.Shown += new System.EventHandler(this.MultipleReplace_Shown); - this.ResizeEnd += new System.EventHandler(this.MultipleReplace_ResizeEnd); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MultipleReplace_KeyDown); - this.groupBoxLinesFound.ResumeLayout(false); - this.groupBoxReplaces.ResumeLayout(false); - this.groupBoxReplaces.PerformLayout(); - this.contextMenuStripRules.ResumeLayout(false); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); - this.groupBoxGroups.ResumeLayout(false); - this.contextMenuStripGroups.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxLinesFound; - private System.Windows.Forms.ListView listViewFixes; - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeader7; - private System.Windows.Forms.ColumnHeader columnHeader8; - private System.Windows.Forms.GroupBox groupBoxReplaces; - private System.Windows.Forms.ListView listViewRules; - private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.ColumnHeader columnHeader2; - private System.Windows.Forms.ColumnHeader columnHeader3; - private System.Windows.Forms.ColumnHeader columnHeader6; - private System.Windows.Forms.Label labelFindWhat; - private System.Windows.Forms.Label labelReplaceWith; - private System.Windows.Forms.TextBox textBoxReplace; - private System.Windows.Forms.RadioButton radioButtonRegEx; - private System.Windows.Forms.RadioButton radioButtonCaseSensitive; - private System.Windows.Forms.RadioButton radioButtonNormal; - private System.Windows.Forms.TextBox textBoxFind; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonAdd; - private System.Windows.Forms.ContextMenuStrip contextMenuStripRules; - private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; - private System.Windows.Forms.Button buttonUpdate; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.Button buttonReplacesSelectAll; - private System.Windows.Forms.Button buttonReplacesInverseSelection; - private System.Windows.Forms.ToolStripMenuItem moveUpToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem moveDownToolStripMenuItem; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; - private System.Windows.Forms.ToolStripMenuItem moveTopToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem moveBottomToolStripMenuItem; - private System.Windows.Forms.GroupBox groupBoxGroups; - private System.Windows.Forms.Button buttonNewGroup; - private System.Windows.Forms.ListView listViewGroups; - private System.Windows.Forms.ColumnHeader columnHeaderForName; - private System.Windows.Forms.ContextMenuStrip contextMenuStripGroups; - private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRename; - private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem1; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripMenuItem moveUpToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem moveDownToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem moveToTopToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem moveToBottomToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRemoveAll; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExport; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImport; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMoveRulesToGroup; - private System.Windows.Forms.Button buttonApply; - private System.Windows.Forms.Label labelDescription; - private System.Windows.Forms.TextBox textBoxDescription; - private System.Windows.Forms.ColumnHeader columnHeader9; - private System.Windows.Forms.ToolStripSeparator toolStripSeparatorGroupImportExport; - private System.Windows.Forms.ToolStripMenuItem exportToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem importToolStripMenuItem; - private System.Windows.Forms.Button buttonExportGroups; - private System.Windows.Forms.Button buttonImportGroups; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class MultipleReplace + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); + this.buttonReplacesInverseSelection = new System.Windows.Forms.Button(); + this.buttonReplacesSelectAll = new System.Windows.Forms.Button(); + this.listViewFixes = new System.Windows.Forms.ListView(); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.groupBoxReplaces = new System.Windows.Forms.GroupBox(); + this.labelDescription = new System.Windows.Forms.Label(); + this.textBoxDescription = new System.Windows.Forms.TextBox(); + this.radioButtonRegEx = new System.Windows.Forms.RadioButton(); + this.radioButtonCaseSensitive = new System.Windows.Forms.RadioButton(); + this.textBoxFind = new System.Windows.Forms.TextBox(); + this.textBoxReplace = new System.Windows.Forms.TextBox(); + this.buttonUpdate = new System.Windows.Forms.Button(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.labelFindWhat = new System.Windows.Forms.Label(); + this.labelReplaceWith = new System.Windows.Forms.Label(); + this.listViewRules = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader9 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contextMenuStripRules = new System.Windows.Forms.ContextMenuStrip(this.components); + this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemRemoveAll = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemMoveRulesToGroup = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.moveUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.moveDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.moveTopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.moveBottomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemImport = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemExport = new System.Windows.Forms.ToolStripMenuItem(); + this.radioButtonNormal = new System.Windows.Forms.RadioButton(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.groupBoxGroups = new System.Windows.Forms.GroupBox(); + this.buttonExportGroups = new System.Windows.Forms.Button(); + this.buttonImportGroups = new System.Windows.Forms.Button(); + this.buttonNewGroup = new System.Windows.Forms.Button(); + this.listViewGroups = new System.Windows.Forms.ListView(); + this.columnHeaderForName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contextMenuStripGroups = new System.Windows.Forms.ContextMenuStrip(this.components); + this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemRename = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.moveUpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.moveDownToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.moveToTopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.moveToBottomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparatorGroupImportExport = new System.Windows.Forms.ToolStripSeparator(); + this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.buttonApply = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.groupBoxLinesFound.SuspendLayout(); + this.groupBoxReplaces.SuspendLayout(); + this.contextMenuStripRules.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.groupBoxGroups.SuspendLayout(); + this.contextMenuStripGroups.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxLinesFound + // + this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxLinesFound.Controls.Add(this.buttonReplacesInverseSelection); + this.groupBoxLinesFound.Controls.Add(this.buttonReplacesSelectAll); + this.groupBoxLinesFound.Controls.Add(this.listViewFixes); + this.groupBoxLinesFound.Location = new System.Drawing.Point(4, 14); + this.groupBoxLinesFound.Name = "groupBoxLinesFound"; + this.groupBoxLinesFound.Size = new System.Drawing.Size(1046, 232); + this.groupBoxLinesFound.TabIndex = 8; + this.groupBoxLinesFound.TabStop = false; + this.groupBoxLinesFound.Text = "Lines found: {0}"; + // + // buttonReplacesInverseSelection + // + this.buttonReplacesInverseSelection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonReplacesInverseSelection.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonReplacesInverseSelection.Location = new System.Drawing.Point(91, 204); + this.buttonReplacesInverseSelection.Name = "buttonReplacesInverseSelection"; + this.buttonReplacesInverseSelection.Size = new System.Drawing.Size(100, 23); + this.buttonReplacesInverseSelection.TabIndex = 12; + this.buttonReplacesInverseSelection.Text = "&Inverse selection"; + this.buttonReplacesInverseSelection.UseVisualStyleBackColor = true; + this.buttonReplacesInverseSelection.Click += new System.EventHandler(this.buttonReplacesInverseSelection_Click); + // + // buttonReplacesSelectAll + // + this.buttonReplacesSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonReplacesSelectAll.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonReplacesSelectAll.Location = new System.Drawing.Point(10, 204); + this.buttonReplacesSelectAll.Name = "buttonReplacesSelectAll"; + this.buttonReplacesSelectAll.Size = new System.Drawing.Size(75, 23); + this.buttonReplacesSelectAll.TabIndex = 11; + this.buttonReplacesSelectAll.Text = "Select &all"; + this.buttonReplacesSelectAll.UseVisualStyleBackColor = true; + this.buttonReplacesSelectAll.Click += new System.EventHandler(this.buttonReplacesSelectAll_Click); + // + // listViewFixes + // + this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewFixes.CheckBoxes = true; + this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader4, + this.columnHeader5, + this.columnHeader7, + this.columnHeader8}); + this.listViewFixes.FullRowSelect = true; + this.listViewFixes.HideSelection = false; + this.listViewFixes.Location = new System.Drawing.Point(10, 21); + this.listViewFixes.Name = "listViewFixes"; + this.listViewFixes.Size = new System.Drawing.Size(1030, 177); + this.listViewFixes.TabIndex = 10; + this.listViewFixes.UseCompatibleStateImageBehavior = false; + this.listViewFixes.View = System.Windows.Forms.View.Details; + this.listViewFixes.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listViewFixes_KeyDown); + // + // columnHeader4 + // + this.columnHeader4.Text = "Apply"; + this.columnHeader4.Width = 48; + // + // columnHeader5 + // + this.columnHeader5.Text = "Line#"; + this.columnHeader5.Width = 61; + // + // columnHeader7 + // + this.columnHeader7.Text = "Before"; + this.columnHeader7.Width = 330; + // + // columnHeader8 + // + this.columnHeader8.Text = "After"; + this.columnHeader8.Width = 440; + // + // groupBoxReplaces + // + this.groupBoxReplaces.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxReplaces.Controls.Add(this.labelDescription); + this.groupBoxReplaces.Controls.Add(this.textBoxDescription); + this.groupBoxReplaces.Controls.Add(this.radioButtonRegEx); + this.groupBoxReplaces.Controls.Add(this.radioButtonCaseSensitive); + this.groupBoxReplaces.Controls.Add(this.textBoxFind); + this.groupBoxReplaces.Controls.Add(this.textBoxReplace); + this.groupBoxReplaces.Controls.Add(this.buttonUpdate); + this.groupBoxReplaces.Controls.Add(this.buttonAdd); + this.groupBoxReplaces.Controls.Add(this.labelFindWhat); + this.groupBoxReplaces.Controls.Add(this.labelReplaceWith); + this.groupBoxReplaces.Controls.Add(this.listViewRules); + this.groupBoxReplaces.Controls.Add(this.radioButtonNormal); + this.groupBoxReplaces.Location = new System.Drawing.Point(235, 3); + this.groupBoxReplaces.Name = "groupBoxReplaces"; + this.groupBoxReplaces.Size = new System.Drawing.Size(809, 257); + this.groupBoxReplaces.TabIndex = 1; + this.groupBoxReplaces.TabStop = false; + this.groupBoxReplaces.Text = "Rules for group \"X\""; + // + // labelDescription + // + this.labelDescription.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelDescription.AutoSize = true; + this.labelDescription.Location = new System.Drawing.Point(400, 184); + this.labelDescription.Name = "labelDescription"; + this.labelDescription.Size = new System.Drawing.Size(64, 13); + this.labelDescription.TabIndex = 11; + this.labelDescription.Text = "Description:"; + // + // textBoxDescription + // + this.textBoxDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxDescription.Location = new System.Drawing.Point(403, 202); + this.textBoxDescription.Name = "textBoxDescription"; + this.textBoxDescription.Size = new System.Drawing.Size(190, 21); + this.textBoxDescription.TabIndex = 5; + // + // radioButtonRegEx + // + this.radioButtonRegEx.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.radioButtonRegEx.AutoSize = true; + this.radioButtonRegEx.Location = new System.Drawing.Point(177, 230); + this.radioButtonRegEx.Name = "radioButtonRegEx"; + this.radioButtonRegEx.Size = new System.Drawing.Size(56, 17); + this.radioButtonRegEx.TabIndex = 12; + this.radioButtonRegEx.Text = "RegEx"; + this.radioButtonRegEx.UseVisualStyleBackColor = true; + this.radioButtonRegEx.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); + // + // radioButtonCaseSensitive + // + this.radioButtonCaseSensitive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.radioButtonCaseSensitive.AutoSize = true; + this.radioButtonCaseSensitive.Location = new System.Drawing.Point(75, 230); + this.radioButtonCaseSensitive.Name = "radioButtonCaseSensitive"; + this.radioButtonCaseSensitive.Size = new System.Drawing.Size(94, 17); + this.radioButtonCaseSensitive.TabIndex = 11; + this.radioButtonCaseSensitive.Text = "Case sensitive"; + this.radioButtonCaseSensitive.UseVisualStyleBackColor = true; + this.radioButtonCaseSensitive.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); + // + // textBoxFind + // + this.textBoxFind.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.textBoxFind.Location = new System.Drawing.Point(9, 203); + this.textBoxFind.Name = "textBoxFind"; + this.textBoxFind.Size = new System.Drawing.Size(211, 21); + this.textBoxFind.TabIndex = 2; + // + // textBoxReplace + // + this.textBoxReplace.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.textBoxReplace.Location = new System.Drawing.Point(226, 203); + this.textBoxReplace.Name = "textBoxReplace"; + this.textBoxReplace.Size = new System.Drawing.Size(171, 21); + this.textBoxReplace.TabIndex = 4; + this.textBoxReplace.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxReplaceKeyDown); + // + // buttonUpdate + // + this.buttonUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUpdate.Location = new System.Drawing.Point(704, 201); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(99, 23); + this.buttonUpdate.TabIndex = 7; + this.buttonUpdate.Text = "&Update"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdateClick); + // + // buttonAdd + // + this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAdd.Location = new System.Drawing.Point(599, 201); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(99, 23); + this.buttonAdd.TabIndex = 6; + this.buttonAdd.Text = "&Add"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAddClick); + // + // labelFindWhat + // + this.labelFindWhat.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelFindWhat.AutoSize = true; + this.labelFindWhat.Location = new System.Drawing.Point(6, 184); + this.labelFindWhat.Name = "labelFindWhat"; + this.labelFindWhat.Size = new System.Drawing.Size(58, 13); + this.labelFindWhat.TabIndex = 1; + this.labelFindWhat.Text = "Find what:"; + // + // labelReplaceWith + // + this.labelReplaceWith.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelReplaceWith.AutoSize = true; + this.labelReplaceWith.Location = new System.Drawing.Point(223, 184); + this.labelReplaceWith.Name = "labelReplaceWith"; + this.labelReplaceWith.Size = new System.Drawing.Size(72, 13); + this.labelReplaceWith.TabIndex = 3; + this.labelReplaceWith.Text = "Replace with:"; + // + // listViewRules + // + this.listViewRules.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewRules.CheckBoxes = true; + this.listViewRules.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2, + this.columnHeader3, + this.columnHeader6, + this.columnHeader9}); + this.listViewRules.ContextMenuStrip = this.contextMenuStripRules; + this.listViewRules.FullRowSelect = true; + this.listViewRules.HideSelection = false; + this.listViewRules.Location = new System.Drawing.Point(9, 20); + this.listViewRules.Name = "listViewRules"; + this.listViewRules.Size = new System.Drawing.Size(797, 149); + this.listViewRules.TabIndex = 0; + this.listViewRules.UseCompatibleStateImageBehavior = false; + this.listViewRules.View = System.Windows.Forms.View.Details; + this.listViewRules.SelectedIndexChanged += new System.EventHandler(this.ListViewReplaceListSelectedIndexChanged); + this.listViewRules.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ListViewRulesKeyDown); + // + // columnHeader1 + // + this.columnHeader1.Text = "Enabled"; + this.columnHeader1.Width = 70; + // + // columnHeader2 + // + this.columnHeader2.Text = "Find what"; + this.columnHeader2.Width = 200; + // + // columnHeader3 + // + this.columnHeader3.Text = "Replace with"; + this.columnHeader3.Width = 170; + // + // columnHeader6 + // + this.columnHeader6.Text = "Search type"; + this.columnHeader6.Width = 170; + // + // columnHeader9 + // + this.columnHeader9.Text = "Description"; + this.columnHeader9.Width = 166; + // + // contextMenuStripRules + // + this.contextMenuStripRules.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.deleteToolStripMenuItem, + this.toolStripMenuItemRemoveAll, + this.toolStripSeparator2, + this.toolStripMenuItemMoveRulesToGroup, + this.toolStripSeparator4, + this.moveUpToolStripMenuItem, + this.moveDownToolStripMenuItem, + this.moveTopToolStripMenuItem, + this.moveBottomToolStripMenuItem, + this.toolStripSeparator3, + this.toolStripMenuItemImport, + this.toolStripMenuItemExport}); + this.contextMenuStripRules.Name = "contextMenuStrip1"; + this.contextMenuStripRules.Size = new System.Drawing.Size(228, 220); + this.contextMenuStripRules.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); + // + // deleteToolStripMenuItem + // + this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; + this.deleteToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Delete; + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(227, 22); + this.deleteToolStripMenuItem.Text = "Remove"; + this.deleteToolStripMenuItem.Click += new System.EventHandler(this.DeleteToolStripMenuItemClick); + // + // toolStripMenuItemRemoveAll + // + this.toolStripMenuItemRemoveAll.Name = "toolStripMenuItemRemoveAll"; + this.toolStripMenuItemRemoveAll.Size = new System.Drawing.Size(227, 22); + this.toolStripMenuItemRemoveAll.Text = "Remove all"; + this.toolStripMenuItemRemoveAll.Click += new System.EventHandler(this.toolStripMenuItem2_Click); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(224, 6); + // + // toolStripMenuItemMoveRulesToGroup + // + this.toolStripMenuItemMoveRulesToGroup.Name = "toolStripMenuItemMoveRulesToGroup"; + this.toolStripMenuItemMoveRulesToGroup.Size = new System.Drawing.Size(227, 22); + this.toolStripMenuItemMoveRulesToGroup.Text = "Move selected rules to group"; + // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(224, 6); + // + // moveUpToolStripMenuItem + // + this.moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem"; + this.moveUpToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Up))); + this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(227, 22); + this.moveUpToolStripMenuItem.Text = "Move up"; + this.moveUpToolStripMenuItem.Click += new System.EventHandler(this.moveUpToolStripMenuItem_Click); + // + // moveDownToolStripMenuItem + // + this.moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem"; + this.moveDownToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Down))); + this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(227, 22); + this.moveDownToolStripMenuItem.Text = "Move down"; + this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click); + // + // moveTopToolStripMenuItem + // + this.moveTopToolStripMenuItem.Name = "moveTopToolStripMenuItem"; + this.moveTopToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Home))); + this.moveTopToolStripMenuItem.Size = new System.Drawing.Size(227, 22); + this.moveTopToolStripMenuItem.Text = "Move to top"; + this.moveTopToolStripMenuItem.Click += new System.EventHandler(this.moveTopToolStripMenuItem_Click); + // + // moveBottomToolStripMenuItem + // + this.moveBottomToolStripMenuItem.Name = "moveBottomToolStripMenuItem"; + this.moveBottomToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.End))); + this.moveBottomToolStripMenuItem.Size = new System.Drawing.Size(227, 22); + this.moveBottomToolStripMenuItem.Text = "Move to bottom"; + this.moveBottomToolStripMenuItem.Click += new System.EventHandler(this.moveBottomToolStripMenuItem_Click); + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(224, 6); + // + // toolStripMenuItemImport + // + this.toolStripMenuItemImport.Name = "toolStripMenuItemImport"; + this.toolStripMenuItemImport.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); + this.toolStripMenuItemImport.Size = new System.Drawing.Size(227, 22); + this.toolStripMenuItemImport.Text = "Import..."; + this.toolStripMenuItemImport.Click += new System.EventHandler(this.toolStripMenuItem3_Click); + // + // toolStripMenuItemExport + // + this.toolStripMenuItemExport.Name = "toolStripMenuItemExport"; + this.toolStripMenuItemExport.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E))); + this.toolStripMenuItemExport.Size = new System.Drawing.Size(227, 22); + this.toolStripMenuItemExport.Text = "Export..."; + this.toolStripMenuItemExport.Click += new System.EventHandler(this.toolStripMenuItem4_Click); + // + // radioButtonNormal + // + this.radioButtonNormal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.radioButtonNormal.AutoSize = true; + this.radioButtonNormal.Checked = true; + this.radioButtonNormal.Location = new System.Drawing.Point(11, 230); + this.radioButtonNormal.Name = "radioButtonNormal"; + this.radioButtonNormal.Size = new System.Drawing.Size(58, 17); + this.radioButtonNormal.TabIndex = 10; + this.radioButtonNormal.TabStop = true; + this.radioButtonNormal.Text = "Normal"; + this.radioButtonNormal.UseVisualStyleBackColor = true; + this.radioButtonNormal.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(804, 251); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 14; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(885, 251); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 15; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.groupBoxGroups); + this.splitContainer1.Panel1.Controls.Add(this.groupBoxReplaces); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.buttonApply); + this.splitContainer1.Panel2.Controls.Add(this.groupBoxLinesFound); + this.splitContainer1.Panel2.Controls.Add(this.buttonOK); + this.splitContainer1.Panel2.Controls.Add(this.buttonCancel); + this.splitContainer1.Size = new System.Drawing.Size(1053, 555); + this.splitContainer1.SplitterDistance = 263; + this.splitContainer1.TabIndex = 0; + // + // groupBoxGroups + // + this.groupBoxGroups.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.groupBoxGroups.Controls.Add(this.buttonExportGroups); + this.groupBoxGroups.Controls.Add(this.buttonImportGroups); + this.groupBoxGroups.Controls.Add(this.buttonNewGroup); + this.groupBoxGroups.Controls.Add(this.listViewGroups); + this.groupBoxGroups.Location = new System.Drawing.Point(6, 3); + this.groupBoxGroups.Name = "groupBoxGroups"; + this.groupBoxGroups.Size = new System.Drawing.Size(223, 257); + this.groupBoxGroups.TabIndex = 0; + this.groupBoxGroups.TabStop = false; + this.groupBoxGroups.Text = "Groups"; + // + // buttonExportGroups + // + this.buttonExportGroups.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonExportGroups.Location = new System.Drawing.Point(118, 230); + this.buttonExportGroups.Name = "buttonExportGroups"; + this.buttonExportGroups.Size = new System.Drawing.Size(99, 23); + this.buttonExportGroups.TabIndex = 3; + this.buttonExportGroups.Text = "Export"; + this.buttonExportGroups.UseVisualStyleBackColor = true; + this.buttonExportGroups.Click += new System.EventHandler(this.buttonExportGroups_Click); + // + // buttonImportGroups + // + this.buttonImportGroups.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonImportGroups.Location = new System.Drawing.Point(8, 230); + this.buttonImportGroups.Name = "buttonImportGroups"; + this.buttonImportGroups.Size = new System.Drawing.Size(104, 23); + this.buttonImportGroups.TabIndex = 2; + this.buttonImportGroups.Text = "Import"; + this.buttonImportGroups.UseVisualStyleBackColor = true; + this.buttonImportGroups.Click += new System.EventHandler(this.buttonImportGroups_Click); + // + // buttonNewGroup + // + this.buttonNewGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonNewGroup.Location = new System.Drawing.Point(8, 203); + this.buttonNewGroup.Name = "buttonNewGroup"; + this.buttonNewGroup.Size = new System.Drawing.Size(209, 23); + this.buttonNewGroup.TabIndex = 1; + this.buttonNewGroup.Text = "New"; + this.buttonNewGroup.UseVisualStyleBackColor = true; + this.buttonNewGroup.Click += new System.EventHandler(this.buttonNewGroup_Click); + // + // listViewGroups + // + this.listViewGroups.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewGroups.CheckBoxes = true; + this.listViewGroups.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderForName}); + this.listViewGroups.ContextMenuStrip = this.contextMenuStripGroups; + this.listViewGroups.FullRowSelect = true; + this.listViewGroups.GridLines = true; + this.listViewGroups.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.listViewGroups.HideSelection = false; + this.listViewGroups.Location = new System.Drawing.Point(8, 20); + this.listViewGroups.MultiSelect = false; + this.listViewGroups.Name = "listViewGroups"; + this.listViewGroups.Size = new System.Drawing.Size(209, 177); + this.listViewGroups.TabIndex = 0; + this.listViewGroups.UseCompatibleStateImageBehavior = false; + this.listViewGroups.View = System.Windows.Forms.View.Details; + // + // columnHeaderForName + // + this.columnHeaderForName.Text = "Active"; + this.columnHeaderForName.Width = 205; + // + // contextMenuStripGroups + // + this.contextMenuStripGroups.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.newToolStripMenuItem, + this.toolStripMenuItemRename, + this.deleteToolStripMenuItem1, + this.toolStripSeparator1, + this.moveUpToolStripMenuItem1, + this.moveDownToolStripMenuItem1, + this.moveToTopToolStripMenuItem, + this.moveToBottomToolStripMenuItem, + this.toolStripSeparatorGroupImportExport, + this.importToolStripMenuItem, + this.exportToolStripMenuItem}); + this.contextMenuStripGroups.Name = "contextMenuStripGroups"; + this.contextMenuStripGroups.Size = new System.Drawing.Size(162, 214); + this.contextMenuStripGroups.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripGroups_Opening); + // + // newToolStripMenuItem + // + this.newToolStripMenuItem.Name = "newToolStripMenuItem"; + this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift | System.Windows.Forms.Keys.N))); + this.newToolStripMenuItem.Size = new System.Drawing.Size(161, 22); + this.newToolStripMenuItem.Text = "New..."; + this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click); + // + // toolStripMenuItemRename + // + this.toolStripMenuItemRename.Name = "toolStripMenuItemRename"; + this.toolStripMenuItemRename.ShortcutKeys = System.Windows.Forms.Keys.F2; + this.toolStripMenuItemRename.Size = new System.Drawing.Size(161, 22); + this.toolStripMenuItemRename.Text = "Rename..."; + this.toolStripMenuItemRename.Click += new System.EventHandler(this.ToolStripMenuItemRenameClick); + // + // deleteToolStripMenuItem1 + // + this.deleteToolStripMenuItem1.Name = "deleteToolStripMenuItem1"; + this.deleteToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.Delete; + this.deleteToolStripMenuItem1.Size = new System.Drawing.Size(161, 22); + this.deleteToolStripMenuItem1.Text = "Delete..."; + this.deleteToolStripMenuItem1.Click += new System.EventHandler(this.deleteToolStripMenuItem1_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(158, 6); + // + // moveUpToolStripMenuItem1 + // + this.moveUpToolStripMenuItem1.Name = "moveUpToolStripMenuItem1"; + this.moveUpToolStripMenuItem1.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Up))); + this.moveUpToolStripMenuItem1.Size = new System.Drawing.Size(161, 22); + this.moveUpToolStripMenuItem1.Text = "Move up"; + this.moveUpToolStripMenuItem1.Click += new System.EventHandler(this.moveUpToolStripMenuItem1_Click); + // + // moveDownToolStripMenuItem1 + // + this.moveDownToolStripMenuItem1.Name = "moveDownToolStripMenuItem1"; + this.moveDownToolStripMenuItem1.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Down))); + this.moveDownToolStripMenuItem1.Size = new System.Drawing.Size(161, 22); + this.moveDownToolStripMenuItem1.Text = "Move down"; + this.moveDownToolStripMenuItem1.Click += new System.EventHandler(this.moveDownToolStripMenuItem1_Click); + // + // moveToTopToolStripMenuItem + // + this.moveToTopToolStripMenuItem.Name = "moveToTopToolStripMenuItem"; + this.moveToTopToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Home))); + this.moveToTopToolStripMenuItem.Size = new System.Drawing.Size(161, 22); + this.moveToTopToolStripMenuItem.Text = "Move to top"; + this.moveToTopToolStripMenuItem.Click += new System.EventHandler(this.moveToTopToolStripMenuItem_Click); + // + // moveToBottomToolStripMenuItem + // + this.moveToBottomToolStripMenuItem.Name = "moveToBottomToolStripMenuItem"; + this.moveToBottomToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.End))); + this.moveToBottomToolStripMenuItem.Size = new System.Drawing.Size(161, 22); + this.moveToBottomToolStripMenuItem.Text = "Move to bottom"; + this.moveToBottomToolStripMenuItem.Click += new System.EventHandler(this.moveToBottomToolStripMenuItem_Click); + // + // toolStripSeparatorGroupImportExport + // + this.toolStripSeparatorGroupImportExport.Name = "toolStripSeparatorGroupImportExport"; + this.toolStripSeparatorGroupImportExport.Size = new System.Drawing.Size(158, 6); + // + // importToolStripMenuItem + // + this.importToolStripMenuItem.Name = "importToolStripMenuItem"; + this.importToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); + this.importToolStripMenuItem.Size = new System.Drawing.Size(161, 22); + this.importToolStripMenuItem.Text = "Import..."; + this.importToolStripMenuItem.Click += new System.EventHandler(this.importToolStripMenuItem_Click); + // + // exportToolStripMenuItem + // + this.exportToolStripMenuItem.Name = "exportToolStripMenuItem"; + this.exportToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E))); + this.exportToolStripMenuItem.Size = new System.Drawing.Size(161, 22); + this.exportToolStripMenuItem.Text = "Export..."; + this.exportToolStripMenuItem.Click += new System.EventHandler(this.exportToolStripMenuItem_Click); + // + // buttonApply + // + this.buttonApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonApply.Location = new System.Drawing.Point(966, 251); + this.buttonApply.Name = "buttonApply"; + this.buttonApply.Size = new System.Drawing.Size(75, 23); + this.buttonApply.TabIndex = 16; + this.buttonApply.Text = "Apply"; + this.buttonApply.UseVisualStyleBackColor = true; + this.buttonApply.Click += new System.EventHandler(this.buttonApply_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // MultipleReplace + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1053, 555); + this.Controls.Add(this.splitContainer1); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(910, 582); + this.Name = "MultipleReplace"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Multiple replace"; + this.Shown += new System.EventHandler(this.MultipleReplace_Shown); + this.ResizeEnd += new System.EventHandler(this.MultipleReplace_ResizeEnd); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MultipleReplace_KeyDown); + this.groupBoxLinesFound.ResumeLayout(false); + this.groupBoxReplaces.ResumeLayout(false); + this.groupBoxReplaces.PerformLayout(); + this.contextMenuStripRules.ResumeLayout(false); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.groupBoxGroups.ResumeLayout(false); + this.contextMenuStripGroups.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxLinesFound; + private System.Windows.Forms.ListView listViewFixes; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.ColumnHeader columnHeader8; + private System.Windows.Forms.GroupBox groupBoxReplaces; + private System.Windows.Forms.ListView listViewRules; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.ColumnHeader columnHeader3; + private System.Windows.Forms.ColumnHeader columnHeader6; + private System.Windows.Forms.Label labelFindWhat; + private System.Windows.Forms.Label labelReplaceWith; + private System.Windows.Forms.TextBox textBoxReplace; + private System.Windows.Forms.RadioButton radioButtonRegEx; + private System.Windows.Forms.RadioButton radioButtonCaseSensitive; + private System.Windows.Forms.RadioButton radioButtonNormal; + private System.Windows.Forms.TextBox textBoxFind; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonAdd; + private System.Windows.Forms.ContextMenuStrip contextMenuStripRules; + private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; + private System.Windows.Forms.Button buttonUpdate; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.Button buttonReplacesSelectAll; + private System.Windows.Forms.Button buttonReplacesInverseSelection; + private System.Windows.Forms.ToolStripMenuItem moveUpToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem moveDownToolStripMenuItem; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.ToolStripMenuItem moveTopToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem moveBottomToolStripMenuItem; + private System.Windows.Forms.GroupBox groupBoxGroups; + private System.Windows.Forms.Button buttonNewGroup; + private System.Windows.Forms.ListView listViewGroups; + private System.Windows.Forms.ColumnHeader columnHeaderForName; + private System.Windows.Forms.ContextMenuStrip contextMenuStripGroups; + private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRename; + private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem1; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem moveUpToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem moveDownToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem moveToTopToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem moveToBottomToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRemoveAll; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExport; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImport; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMoveRulesToGroup; + private System.Windows.Forms.Button buttonApply; + private System.Windows.Forms.Label labelDescription; + private System.Windows.Forms.TextBox textBoxDescription; + private System.Windows.Forms.ColumnHeader columnHeader9; + private System.Windows.Forms.ToolStripSeparator toolStripSeparatorGroupImportExport; + private System.Windows.Forms.ToolStripMenuItem exportToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem importToolStripMenuItem; + private System.Windows.Forms.Button buttonExportGroups; + private System.Windows.Forms.Button buttonImportGroups; + } } \ No newline at end of file diff --git a/src/Forms/MultipleReplace.cs b/src/ui/Forms/MultipleReplace.cs similarity index 97% rename from src/Forms/MultipleReplace.cs rename to src/ui/Forms/MultipleReplace.cs index 0f7613360..dcda934db 100644 --- a/src/Forms/MultipleReplace.cs +++ b/src/ui/Forms/MultipleReplace.cs @@ -1,1309 +1,1309 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class MultipleReplace : PositionAndSizeForm - { - internal const string Group = "Group"; - internal const string GroupName = "Name"; - internal const string GroupEnabled = "Enabled"; - internal const string MultipleSearchAndReplaceItem = "MultipleSearchAndReplaceItem"; - internal const string RuleEnabled = "Enabled"; - internal const string FindWhat = "FindWhat"; - internal const string ReplaceWith = "ReplaceWith"; - internal const string SearchType = "SearchType"; - internal const string Description = "Description"; - - private const string TemplateFilterExtension = "|*.template"; - - private readonly List _oldMultipleSearchAndReplaceGroups = new List(); - private readonly Dictionary _compiledRegExList = new Dictionary(); - private Subtitle _subtitle; - private Subtitle _original; - public Subtitle FixedSubtitle { get; private set; } - public int FixCount { get; private set; } - public List DeleteIndices { get; } - - public void SetDeleteIndices() - { - foreach (ListViewItem item in listViewFixes.Items) - { - if (item.Checked && item.SubItems[3].Text == string.Empty) - { - var index = _subtitle.GetIndex(item.Tag as Paragraph); - if (!DeleteIndices.Contains(index)) - { - DeleteIndices.Add(index); - } - } - } - } - - private MultipleSearchAndReplaceGroup _currentGroup; - - public MultipleReplace() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - DeleteIndices = new List(); - openFileDialog1.FileName = string.Empty; - saveFileDialog1.FileName = string.Empty; - - textBoxReplace.ContextMenu = FindReplaceDialogHelper.GetReplaceTextContextMenu(textBoxReplace); - buttonUpdate.Enabled = false; - - Text = Configuration.Settings.Language.MultipleReplace.Title; - labelFindWhat.Text = Configuration.Settings.Language.MultipleReplace.FindWhat; - labelReplaceWith.Text = Configuration.Settings.Language.MultipleReplace.ReplaceWith; - labelDescription.Text = Configuration.Settings.Language.MultipleReplace.Description; - radioButtonNormal.Text = Configuration.Settings.Language.MultipleReplace.Normal; - radioButtonRegEx.Text = Configuration.Settings.Language.MultipleReplace.RegularExpression; - radioButtonCaseSensitive.Text = Configuration.Settings.Language.MultipleReplace.CaseSensitive; - buttonAdd.Text = Configuration.Settings.Language.MultipleReplace.Add; - buttonUpdate.Text = Configuration.Settings.Language.MultipleReplace.Update; - listViewRules.Columns[0].Text = Configuration.Settings.Language.MultipleReplace.Enabled; - listViewRules.Columns[1].Text = Configuration.Settings.Language.MultipleReplace.FindWhat; - listViewRules.Columns[2].Text = Configuration.Settings.Language.MultipleReplace.ReplaceWith; - listViewRules.Columns[3].Text = Configuration.Settings.Language.MultipleReplace.SearchType; - listViewRules.Columns[4].Text = Configuration.Settings.Language.MultipleReplace.Description; - groupBoxGroups.Text = Configuration.Settings.Language.MultipleReplace.Groups; - groupBoxLinesFound.Text = string.Empty; - listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; - listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; - listViewFixes.Columns[2].Text = Configuration.Settings.Language.General.Before; - listViewFixes.Columns[3].Text = Configuration.Settings.Language.General.After; - deleteToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.Remove; - toolStripMenuItemRemoveAll.Text = Configuration.Settings.Language.MultipleReplace.RemoveAll; - toolStripMenuItemImport.Text = Configuration.Settings.Language.MultipleReplace.Import; - toolStripMenuItemExport.Text = Configuration.Settings.Language.MultipleReplace.Export; - importToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.Import; - exportToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.Export; - buttonImportGroups.Text = Configuration.Settings.Language.MultipleReplace.Import; - buttonExportGroups.Text = Configuration.Settings.Language.MultipleReplace.Export; - buttonNewGroup.Text = Configuration.Settings.Language.MultipleReplace.NewGroup; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - buttonApply.Text = Configuration.Settings.Language.General.Apply; - buttonReplacesSelectAll.Text = Configuration.Settings.Language.FixCommonErrors.SelectAll; - buttonReplacesInverseSelection.Text = Configuration.Settings.Language.FixCommonErrors.InverseSelection; - UiUtil.FixLargeFonts(this, buttonOK); - splitContainer1.Panel1MinSize = 200; - splitContainer1.Panel2MinSize = 200; - - moveUpToolStripMenuItem.Text = Configuration.Settings.Language.DvdSubRip.MoveUp; - moveDownToolStripMenuItem.Text = Configuration.Settings.Language.DvdSubRip.MoveDown; - moveTopToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.MoveToTop; - moveBottomToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.MoveToBottom; - newToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.NewGroup; - - toolStripMenuItemMoveRulesToGroup.Text = Configuration.Settings.Language.MultipleReplace.MoveSelectedRulesToGroup; - moveUpToolStripMenuItem1.Text = Configuration.Settings.Language.DvdSubRip.MoveUp; - moveDownToolStripMenuItem1.Text = Configuration.Settings.Language.DvdSubRip.MoveDown; - moveToTopToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.MoveToTop; - moveToBottomToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.MoveToBottom; - toolStripMenuItemRename.Text = Configuration.Settings.Language.MultipleReplace.RenameGroup; - deleteToolStripMenuItem1.Text = Configuration.Settings.Language.MultipleReplace.Remove; - - radioButtonCaseSensitive.Left = radioButtonNormal.Left + radioButtonNormal.Width + 40; - radioButtonRegEx.Left = radioButtonCaseSensitive.Left + radioButtonCaseSensitive.Width + 40; - } - - public void Initialize(Subtitle subtitle) - { - _subtitle = subtitle ?? throw new ArgumentNullException(nameof(subtitle)); - _original = new Subtitle(_subtitle); - _oldMultipleSearchAndReplaceGroups.Clear(); - - if (Configuration.Settings.MultipleSearchAndReplaceGroups.Count == 0) - { - Configuration.Settings.MultipleSearchAndReplaceGroups.Add(new MultipleSearchAndReplaceGroup { Enabled = true, Name = "Default", Rules = new List() }); - } - - foreach (var group in Configuration.Settings.MultipleSearchAndReplaceGroups) - { - var oldGroup = new MultipleSearchAndReplaceGroup { Name = group.Name, Enabled = group.Enabled, Rules = new List() }; - foreach (var rule in group.Rules) - { - oldGroup.Rules.Add(rule); - } - _oldMultipleSearchAndReplaceGroups.Add(oldGroup); - } - - if (subtitle.Paragraphs == null || subtitle.Paragraphs.Count == 0) - { - groupBoxLinesFound.Enabled = false; - } - - UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, Configuration.Settings.MultipleSearchAndReplaceGroups[0]); - } - - internal void RunFromBatch(Subtitle subtitle) - { - Initialize(subtitle); - GeneratePreview(); - SetDeleteIndices(); - } - - internal void RunFromBatch(Subtitle subtitle, IEnumerable importFileNames) - { - var savedList = Configuration.Settings.MultipleSearchAndReplaceGroups; - try - { - Configuration.Settings.MultipleSearchAndReplaceGroups = new List(); - foreach (var fileName in importFileNames) - { - if (fileName.Equals(".")) - { - Configuration.Settings.MultipleSearchAndReplaceGroups.AddRange(savedList); - } - else - { - Configuration.Settings.MultipleSearchAndReplaceGroups.AddRange(ImportGroupsFile(fileName)); - } - } - RunFromBatch(subtitle); - } - finally - { - Configuration.Settings.MultipleSearchAndReplaceGroups = savedList; - } - } - - private void MultipleReplace_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - buttonCancel_Click(null, null); - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#multiple_replace"); - } - } - - private void RadioButtonCheckedChanged(object sender, EventArgs e) - { - textBoxFind.ContextMenu = sender == radioButtonRegEx ? FindReplaceDialogHelper.GetRegExContextMenu(textBoxFind) : null; - } - - private void ButtonAddClick(object sender, EventArgs e) - { - if (_currentGroup == null) - { - return; - } - - string findText = textBoxFind.Text.RemoveControlCharacters(); - if (findText.Length > 0) - { - string searchType = ReplaceExpression.SearchTypeNormal; - if (radioButtonCaseSensitive.Checked) - { - searchType = ReplaceExpression.SearchTypeCaseSensitive; - } - else if (radioButtonRegEx.Checked) - { - searchType = ReplaceExpression.SearchTypeRegularExpression; - if (!RegexUtils.IsValidRegex(findText)) - { - MessageBox.Show(Configuration.Settings.Language.General.RegularExpressionIsNotValid); - textBoxFind.Select(); - return; - } - } - - var rule = new MultipleSearchAndReplaceSetting { Enabled = true, FindWhat = findText, ReplaceWith = textBoxReplace.Text, SearchType = searchType, Description = textBoxDescription.Text }; - _currentGroup.Rules.Add(rule); - AddToRulesListView(rule); - textBoxFind.Text = string.Empty; - textBoxReplace.Text = string.Empty; - textBoxDescription.Text = string.Empty; - GeneratePreview(); - textBoxFind.Select(); - } - } - - private void GeneratePreview() - { - Cursor = Cursors.WaitCursor; - FixedSubtitle = new Subtitle(_subtitle); - int fixedLines = 0; - listViewFixes.BeginUpdate(); - listViewFixes.Items.Clear(); - var replaceExpressions = new HashSet(); - foreach (var group in Configuration.Settings.MultipleSearchAndReplaceGroups) - { - if (group.Enabled) - { - foreach (var rule in group.Rules) - { - if (rule.Enabled) - { - string findWhat = rule.FindWhat; - if (!string.IsNullOrEmpty(findWhat)) // allow space or spaces - { - string replaceWith = RegexUtils.FixNewLine(rule.ReplaceWith); - findWhat = RegexUtils.FixNewLine(findWhat); - string searchType = rule.SearchType; - var mpi = new ReplaceExpression(findWhat, replaceWith, searchType); - replaceExpressions.Add(mpi); - if (mpi.SearchType == ReplaceExpression.SearchRegEx && !_compiledRegExList.ContainsKey(findWhat)) - { - _compiledRegExList.Add(findWhat, new Regex(findWhat, RegexOptions.Compiled | RegexOptions.Multiline)); - } - } - } - } - } - } - - var fixes = new List(); - for (var i = 0; i < _subtitle.Paragraphs.Count; i++) - { - Paragraph p = _subtitle.Paragraphs[i]; - bool hit = false; - string newText = p.Text; - foreach (ReplaceExpression item in replaceExpressions) - { - if (item.SearchType == ReplaceExpression.SearchCaseSensitive) - { - if (newText.Contains(item.FindWhat)) - { - hit = true; - newText = newText.Replace(item.FindWhat, item.ReplaceWith); - } - } - else if (item.SearchType == ReplaceExpression.SearchRegEx) - { - Regex r = _compiledRegExList[item.FindWhat]; - if (r.IsMatch(newText)) - { - hit = true; - newText = RegexUtils.ReplaceNewLineSafe(r, newText, item.ReplaceWith); - } - } - else - { - int index = newText.IndexOf(item.FindWhat, StringComparison.OrdinalIgnoreCase); - if (index >= 0) - { - hit = true; - do - { - newText = newText.Remove(index, item.FindWhat.Length).Insert(index, item.ReplaceWith); - index = newText.IndexOf(item.FindWhat, index + item.ReplaceWith.Length, StringComparison.OrdinalIgnoreCase); - } while (index >= 0); - } - } - } - - if (hit && newText != p.Text) - { - fixedLines++; - fixes.Add(MakePreviewListItem(p, newText)); - FixedSubtitle.Paragraphs[i].Text = newText; - } - } - - listViewFixes.Items.AddRange(fixes.ToArray()); - listViewFixes.EndUpdate(); - groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.MultipleReplace.LinesFoundX, fixedLines); - Cursor = Cursors.Default; - } - - private void AddToRulesListView(MultipleSearchAndReplaceSetting rule) - { - var item = new ListViewItem(string.Empty) { Checked = rule.Enabled, Tag = rule }; - item.SubItems.Add(rule.FindWhat); - item.SubItems.Add(rule.ReplaceWith); - item.SubItems.Add(EnglishSearchTypeToLocal(rule.SearchType)); - item.SubItems.Add(rule.Description); - listViewRules.Items.Add(item); - } - - private ListViewItem MakePreviewListItem(Paragraph p, string newText) - { - var item = new ListViewItem(string.Empty) { Tag = p, Checked = true }; - item.SubItems.Add(p.Number.ToString(CultureInfo.InvariantCulture)); - item.SubItems.Add(UiUtil.GetListViewTextFromString(p.Text)); - item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); - return item; - } - - private static string LocalSearchTypeToEnglish(string searchType) - { - if (searchType == Configuration.Settings.Language.MultipleReplace.RegularExpression) - { - return ReplaceExpression.SearchTypeRegularExpression; - } - - if (searchType == Configuration.Settings.Language.MultipleReplace.CaseSensitive) - { - return ReplaceExpression.SearchTypeCaseSensitive; - } - - return ReplaceExpression.SearchTypeNormal; - } - - private static string EnglishSearchTypeToLocal(string searchType) - { - if (searchType == ReplaceExpression.SearchTypeRegularExpression) - { - return Configuration.Settings.Language.MultipleReplace.RegularExpression; - } - - if (searchType == ReplaceExpression.SearchTypeCaseSensitive) - { - return Configuration.Settings.Language.MultipleReplace.CaseSensitive; - } - - return Configuration.Settings.Language.MultipleReplace.Normal; - } - - private void buttonOK_Click(object sender, EventArgs e) - { - SetDeleteIndices(); - ResetUncheckLines(); - SetFixCount(); - SaveReplaceList(true); - DialogResult = DialogResult.OK; - } - - public void SetFixCount() - { - for (var index = 0; index < _original.Paragraphs.Count; index++) - { - var p = _original.Paragraphs[index]; - var f = FixedSubtitle.GetParagraphOrDefault(index); - if (f != null && f.Text != p.Text) - { - FixCount++; - } - } - } - - private void SaveReplaceList(bool saveToDisk) - { - if (saveToDisk) - { - Configuration.Settings.Save(); - } - } - - private void ResetUncheckLines() - { - foreach (ListViewItem item in listViewFixes.Items) - { - if (!item.Checked) - { - int index = _subtitle.GetIndex(item.Tag as Paragraph); - FixedSubtitle.Paragraphs[index].Text = _subtitle.Paragraphs[index].Text; - } - } - } - - private void DeleteToolStripMenuItemClick(object sender, EventArgs e) - { - if (listViewRules.Items.Count < 1 || listViewRules.SelectedItems.Count < 1 || _currentGroup == null) - { - return; - } - - listViewRules.BeginUpdate(); - for (int i = listViewRules.Items.Count - 1; i >= 0; i--) - { - ListViewItem item = listViewRules.Items[i]; - if (item.Selected) - { - item.Remove(); - _currentGroup.Rules.Remove(item.Tag as MultipleSearchAndReplaceSetting); - } - } - listViewRules.EndUpdate(); - GeneratePreview(); - } - - private void ListViewRulesKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) - { - listViewRules.SelectAll(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.D && e.Modifiers == Keys.Control) - { - listViewRules.SelectFirstSelectedItemOnly(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.I && e.Modifiers == (Keys.Control | Keys.Shift)) //InverseSelection - { - listViewRules.InverseSelection(); - e.SuppressKeyPress = true; - } - } - - private void ButtonUpdateClick(object sender, EventArgs e) - { - if (listViewRules.SelectedItems.Count != 1 || _currentGroup == null) - { - return; - } - - string findText = textBoxFind.Text.RemoveControlCharacters(); - textBoxFind.Text = findText; - - string replaceText = textBoxReplace.Text.RemoveControlCharacters(); - textBoxReplace.Text = replaceText; - - if (findText.Length > 0) - { - string searchType = ReplaceExpression.SearchTypeNormal; - if (radioButtonCaseSensitive.Checked) - { - searchType = ReplaceExpression.SearchTypeCaseSensitive; - } - else if (radioButtonRegEx.Checked) - { - searchType = ReplaceExpression.SearchTypeRegularExpression; - if (!RegexUtils.IsValidRegex(findText)) - { - MessageBox.Show(Configuration.Settings.Language.General.RegularExpressionIsNotValid); - textBoxFind.Select(); - return; - } - } - - var item = listViewRules.SelectedItems[0]; - item.SubItems[1].Text = findText; - item.SubItems[2].Text = replaceText; - item.SubItems[3].Text = EnglishSearchTypeToLocal(searchType); - item.SubItems[4].Text = textBoxDescription.Text; - - _currentGroup.Rules[item.Index].FindWhat = findText; - _currentGroup.Rules[item.Index].ReplaceWith = replaceText; - _currentGroup.Rules[item.Index].SearchType = searchType; - _currentGroup.Rules[item.Index].Description = textBoxDescription.Text; - - GeneratePreview(); - textBoxFind.Select(); - } - } - - private void ListViewReplaceListSelectedIndexChanged(object sender, EventArgs e) - { - if (listViewRules.SelectedItems.Count == 1) - { - buttonUpdate.Enabled = true; - textBoxFind.Text = listViewRules.SelectedItems[0].SubItems[1].Text; - textBoxReplace.Text = listViewRules.SelectedItems[0].SubItems[2].Text; - string searchType = LocalSearchTypeToEnglish(listViewRules.SelectedItems[0].SubItems[3].Text); - if (searchType == ReplaceExpression.SearchTypeRegularExpression) - { - radioButtonRegEx.Checked = true; - } - else if (searchType == ReplaceExpression.SearchTypeCaseSensitive) - { - radioButtonCaseSensitive.Checked = true; - } - else - { - radioButtonNormal.Checked = true; - } - - textBoxDescription.Text = listViewRules.SelectedItems[0].SubItems[4].Text; - } - else - { - buttonUpdate.Enabled = false; - } - } - - private void TextBoxReplaceKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - ButtonAddClick(null, null); - } - } - - private void buttonReplacesSelectAll_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = true; - } - } - - private void buttonReplacesInverseSelection_Click(object sender, EventArgs e) - { - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = !item.Checked; - } - } - - private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e) - { - bool moreThanOneGroup = Configuration.Settings.MultipleSearchAndReplaceGroups.Count > 1; - bool isVisible = listViewRules.Items.Count > 1 && listViewRules.SelectedItems.Count == 1; - toolStripSeparator3.Visible = isVisible; - moveUpToolStripMenuItem.Visible = isVisible; - moveDownToolStripMenuItem.Visible = isVisible; - moveTopToolStripMenuItem.Visible = isVisible; - moveBottomToolStripMenuItem.Visible = isVisible; - - toolStripMenuItemExport.Visible = listViewRules.Items.Count > 0; - toolStripMenuItemRemoveAll.Visible = listViewRules.Items.Count > 0; - toolStripSeparator2.Visible = listViewRules.Items.Count > 0; - - deleteToolStripMenuItem.Visible = listViewRules.SelectedItems.Count >= 1; - - if (moreThanOneGroup && listViewRules.SelectedItems.Count >= 1) - { - toolStripMenuItemMoveRulesToGroup.Visible = true; - toolStripSeparator4.Visible = true; - toolStripMenuItemMoveRulesToGroup.DropDownItems.Clear(); - foreach (var g in Configuration.Settings.MultipleSearchAndReplaceGroups) - { - if (g != _currentGroup) - { - var menuItem = new ToolStripMenuItem(g.Name) { Tag = g }; - menuItem.Click += (o, args) => { MoveRulesToGroup(g); }; - toolStripMenuItemMoveRulesToGroup.DropDownItems.Add(menuItem); - } - } - } - else - { - toolStripMenuItemMoveRulesToGroup.Visible = false; - toolStripSeparator4.Visible = false; - } - } - - private void MoveRulesToGroup(MultipleSearchAndReplaceGroup newGroup) - { - foreach (ListViewItem item in listViewRules.SelectedItems) - { - var rule = (MultipleSearchAndReplaceSetting)item.Tag; - _currentGroup.Rules.Remove(rule); - newGroup.Rules.Add(rule); - } - UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, _currentGroup); - GeneratePreview(); - } - - private void SwapRules(int index, int index2) - { - if (_currentGroup == null) - { - return; - } - - listViewRules.ItemChecked -= ListViewRulesItemChecked; - - var temp = _currentGroup.Rules[index]; - _currentGroup.Rules[index] = _currentGroup.Rules[index2]; - _currentGroup.Rules[index2] = temp; - - bool enabled = listViewRules.Items[index].Checked; - string findWhat = listViewRules.Items[index].SubItems[1].Text; - string replaceWith = listViewRules.Items[index].SubItems[2].Text; - string searchType = listViewRules.Items[index].SubItems[3].Text; - string description = listViewRules.Items[index].SubItems[4].Text; - - listViewRules.Items[index].Checked = listViewRules.Items[index2].Checked; - listViewRules.Items[index].SubItems[1].Text = listViewRules.Items[index2].SubItems[1].Text; - listViewRules.Items[index].SubItems[2].Text = listViewRules.Items[index2].SubItems[2].Text; - listViewRules.Items[index].SubItems[3].Text = listViewRules.Items[index2].SubItems[3].Text; - listViewRules.Items[index].SubItems[4].Text = listViewRules.Items[index2].SubItems[4].Text; - listViewRules.Items[index].Tag = _currentGroup.Rules[index]; - - listViewRules.Items[index2].Checked = enabled; - listViewRules.Items[index2].SubItems[1].Text = findWhat; - listViewRules.Items[index2].SubItems[2].Text = replaceWith; - listViewRules.Items[index2].SubItems[3].Text = searchType; - listViewRules.Items[index2].SubItems[4].Text = description; - listViewRules.Items[index2].Tag = _currentGroup.Rules[index2]; - - listViewRules.Items[index].Selected = false; - listViewRules.Items[index2].Selected = true; - listViewRules.Items[index2].Focused = true; - listViewRules.EnsureVisible(index2); - GeneratePreview(); - listViewRules.ItemChecked += ListViewRulesItemChecked; - } - - private void moveUpToolStripMenuItem_Click(object sender, EventArgs e) - { - if (listViewRules.SelectedItems.Count != 1 || listViewRules.Items.Count < 2) - { - return; - } - - int index = listViewRules.SelectedIndices[0]; - if (index == 0) - { - return; - } - - SwapRules(index, index - 1); - } - - private void moveDownToolStripMenuItem_Click(object sender, EventArgs e) - { - if (listViewRules.SelectedItems.Count != 1 || listViewRules.Items.Count < 2) - { - return; - } - - int index = listViewRules.SelectedIndices[0]; - if (index == listViewRules.Items.Count - 1) - { - return; - } - - SwapRules(index, index + 1); - } - - private void moveTopToolStripMenuItem_Click(object sender, EventArgs e) - { - if (listViewRules.SelectedItems.Count != 1 || listViewRules.Items.Count < 2) - { - return; - } - - int index = listViewRules.SelectedIndices[0]; - if (index == 0) - { - return; - } - - if (_currentGroup == null) - { - return; - } - - var temp = _currentGroup.Rules[index]; - _currentGroup.Rules.Remove(temp); - _currentGroup.Rules.Insert(0, temp); - listViewGroups_SelectedIndexChanged(null, null); - GeneratePreview(); - } - - private void moveBottomToolStripMenuItem_Click(object sender, EventArgs e) - { - if (listViewRules.SelectedItems.Count != 1 || listViewRules.Items.Count < 2) - { - return; - } - - int index = listViewRules.SelectedIndices[0]; - int bottomIndex = listViewRules.Items.Count - 1; - if (index == bottomIndex) - { - return; - } - - var temp = _currentGroup.Rules[index]; - _currentGroup.Rules.Remove(temp); - _currentGroup.Rules.Add(temp); - listViewGroups_SelectedIndexChanged(null, null); - listViewRules.Items[0].Selected = false; - listViewRules.Items[bottomIndex].Selected = true; - listViewRules.Items[bottomIndex].Focused = true; - listViewRules.EnsureVisible(bottomIndex); - GeneratePreview(); - } - - private void ImportRulesFile(string fileName) - { - if (_currentGroup == null) - { - return; - } - - var doc = new XmlDocument { XmlResolver = null }; - doc.Load(fileName); - - var replaceNodes = doc.DocumentElement?.SelectNodes("//MultipleSearchAndReplaceItem"); - if (replaceNodes == null) - { - return; - } - - foreach (XmlNode listNode in replaceNodes) - { - var item = MakeMultipleSearchAndReplaceSetting(listNode); - AddToRulesListView(item); - _currentGroup.Rules.Add(item); - } - } - - private List ImportGroupsFile(string fileName) - { - var list = new List(); - var doc = new XmlDocument { XmlResolver = null }; - doc.Load(fileName); - var groups = doc.DocumentElement?.SelectNodes("//Group"); - if (groups != null) - { - foreach (XmlNode groupNode in groups) - { - var group = new MultipleSearchAndReplaceGroup(); - var nameNode = groupNode.SelectSingleNode(GroupName); - var enabledNode = groupNode.SelectSingleNode(GroupEnabled); - - group.Name = nameNode != null ? nameNode.InnerText : "Untitled"; - group.Enabled = enabledNode != null ? Convert.ToBoolean(enabledNode.InnerText) : false; - - group.Rules = new List(); - list.Add(group); - - var replaceItems = groupNode.SelectNodes("MultipleSearchAndReplaceItem"); - if (replaceItems != null) - { - foreach (XmlNode listNode in replaceItems) - { - var item = MakeMultipleSearchAndReplaceSetting(listNode); - group.Rules.Add(item); - } - } - } - } - - if (list.Count == 0) - { - // import into "untitled" group if only rules - var group = new MultipleSearchAndReplaceGroup - { - Name = "untitled", - Rules = new List() - }; - var replaceItems = doc.DocumentElement?.SelectNodes("//MultipleSearchAndReplaceItem"); - if (replaceItems != null) - { - foreach (XmlNode listNode in replaceItems) - { - var item = MakeMultipleSearchAndReplaceSetting(listNode); - group.Rules.Add(item); - } - } - - if (group.Rules.Count > 0) - { - list.Add(group); - } - } - - return list; - } - - private static MultipleSearchAndReplaceSetting MakeMultipleSearchAndReplaceSetting(XmlNode listNode) - { - var item = new MultipleSearchAndReplaceSetting(); - var subNode = listNode.SelectSingleNode(RuleEnabled); - if (subNode != null) - { - item.Enabled = Convert.ToBoolean(subNode.InnerText); - } - - subNode = listNode.SelectSingleNode(FindWhat); - if (subNode != null) - { - item.FindWhat = subNode.InnerText; - } - - subNode = listNode.SelectSingleNode(ReplaceWith); - if (subNode != null) - { - item.ReplaceWith = subNode.InnerText; - } - - subNode = listNode.SelectSingleNode(SearchType); - if (subNode != null) - { - item.SearchType = subNode.InnerText; - } - - subNode = listNode.SelectSingleNode(SearchType); - if (subNode != null) - { - item.SearchType = subNode.InnerText; - } - - subNode = listNode.SelectSingleNode(Description); - if (subNode != null) - { - item.Description = subNode.InnerText; - } - - return item; - } - - private void MultipleReplace_Shown(object sender, EventArgs e) - { - GeneratePreview(); - listViewRules.ItemChecked += ListViewRulesItemChecked; - listViewGroups.ItemChecked += listViewGroups_ItemChecked; - listViewGroups.SelectedIndexChanged += listViewGroups_SelectedIndexChanged; - MultipleReplace_ResizeEnd(sender, null); - listViewGroups_SelectedIndexChanged(null, null); - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - Configuration.Settings.MultipleSearchAndReplaceGroups = _oldMultipleSearchAndReplaceGroups; - DialogResult = DialogResult.Cancel; - } - - private void buttonNewGroup_Click(object sender, EventArgs e) - { - newToolStripMenuItem_Click(sender, null); - } - - private void newToolStripMenuItem_Click(object sender, EventArgs e) - { - using (var form = new MultipleReplaceNewGroup(string.Empty)) - { - if (form.ShowDialog(this) == DialogResult.OK && form.GroupName.Length > 0) - { - var newGroup = new MultipleSearchAndReplaceGroup { Enabled = true, Name = form.GroupName, Rules = new List() }; - Configuration.Settings.MultipleSearchAndReplaceGroups.Add(newGroup); - UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, newGroup); - } - } - } - - private void UpdateViewFromModel(List groups, MultipleSearchAndReplaceGroup focusGroup) - { - listViewGroups.BeginUpdate(); - listViewGroups.Items.Clear(); - for (int index = 0; index < groups.Count; index++) - { - var group = groups[index]; - var lvi = new ListViewItem(group.Name) { Checked = group.Enabled, Tag = group }; - listViewGroups.Items.Add(lvi); - if (group == focusGroup) - { - listViewGroups.Items[index].Selected = true; - listViewGroups.Items[index].Focused = true; - listViewGroups.EnsureVisible(index); - } - } - listViewGroups.EndUpdate(); - if (groups.Count == 0) - { - groupBoxReplaces.Text = string.Empty; - textBoxFind.Text = string.Empty; - textBoxReplace.Text = string.Empty; - textBoxDescription.Text = string.Empty; - textBoxDescription.Text = string.Empty; - radioButtonNormal.Checked = true; - } - } - - private void listViewGroups_SelectedIndexChanged(object sender, EventArgs e) - { - if (listViewGroups.SelectedItems.Count < 1) - { - return; - } - - _currentGroup = listViewGroups.SelectedItems[0].Tag as MultipleSearchAndReplaceGroup; - if (_currentGroup == null) - { - return; - } - - listViewRules.ItemChecked -= ListViewRulesItemChecked; - listViewGroups.ItemChecked -= listViewGroups_ItemChecked; - listViewRules.BeginUpdate(); - groupBoxReplaces.Text = string.Format(Configuration.Settings.Language.MultipleReplace.RulesForGroupX, _currentGroup.Name); - listViewRules.Items.Clear(); - foreach (var rule in _currentGroup.Rules) - { - AddToRulesListView(rule); - } - if (_currentGroup.Rules.Count > 0) - { - listViewRules.Items[0].Selected = true; - } - else - { - textBoxFind.Text = string.Empty; - textBoxReplace.Text = string.Empty; - textBoxDescription.Text = string.Empty; - } - listViewRules.EndUpdate(); - listViewRules.ItemChecked += ListViewRulesItemChecked; - listViewGroups.ItemChecked += listViewGroups_ItemChecked; - } - - private void listViewGroups_ItemChecked(object sender, ItemCheckedEventArgs e) - { - var group = e.Item.Tag as MultipleSearchAndReplaceGroup; - if (group == null) - { - return; - } - - group.Enabled = e.Item.Checked; - GeneratePreview(); - } - - private void ListViewRulesItemChecked(object sender, ItemCheckedEventArgs e) - { - if (!(e.Item.Tag is MultipleSearchAndReplaceSetting rule)) - { - return; - } - - rule.Enabled = e.Item.Checked; - GeneratePreview(); - } - - private void toolStripMenuItem2_Click(object sender, EventArgs e) - { - if (_currentGroup == null) - { - return; - } - - _currentGroup.Rules.Clear(); - listViewRules.Items.Clear(); - GeneratePreview(); - } - - private void toolStripMenuItem4_Click(object sender, EventArgs e) - { - if (_currentGroup == null || _currentGroup.Rules.Count == 0) - { - return; - } - - saveFileDialog1.Title = Configuration.Settings.Language.MultipleReplace.ExportRulesTitle; - saveFileDialog1.Filter = Configuration.Settings.Language.MultipleReplace.Rules + TemplateFilterExtension; - if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) - { - var textWriter = new XmlTextWriter(saveFileDialog1.FileName, null) { Formatting = Formatting.Indented }; - textWriter.WriteStartDocument(); - textWriter.WriteStartElement("Settings", string.Empty); - textWriter.WriteStartElement("MultipleSearchAndReplaceList", string.Empty); - textWriter.WriteStartElement(Group, string.Empty); - textWriter.WriteElementString(GroupName, _currentGroup.Name); - foreach (var item in _currentGroup.Rules) - { - textWriter.WriteStartElement(MultipleSearchAndReplaceItem, string.Empty); - textWriter.WriteElementString(RuleEnabled, item.Enabled.ToString()); - textWriter.WriteElementString(FindWhat, item.FindWhat); - textWriter.WriteElementString(ReplaceWith, item.ReplaceWith); - textWriter.WriteElementString(SearchType, item.SearchType); - textWriter.WriteElementString(Description, item.Description); - textWriter.WriteEndElement(); - } - textWriter.WriteEndElement(); - textWriter.WriteEndElement(); - textWriter.WriteEndElement(); - textWriter.WriteEndDocument(); - textWriter.Close(); - } - } - - private void toolStripMenuItem3_Click(object sender, EventArgs e) - { - if (_currentGroup == null) - { - return; - } - - openFileDialog1.Title = Configuration.Settings.Language.MultipleReplace.ImportRulesTitle; - openFileDialog1.Filter = Configuration.Settings.Language.MultipleReplace.Rules + TemplateFilterExtension; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - try - { - ImportRulesFile(openFileDialog1.FileName); - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - return; - } - GeneratePreview(); - } - } - - private void ToolStripMenuItemRenameClick(object sender, EventArgs e) - { - if (_currentGroup == null) - { - return; - } - - using (var form = new MultipleReplaceNewGroup(_currentGroup.Name)) - { - if (form.ShowDialog(this) == DialogResult.OK && form.GroupName.Length > 0) - { - _currentGroup.Name = form.GroupName; - UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, _currentGroup); - } - } - } - - private void deleteToolStripMenuItem1_Click(object sender, EventArgs e) - { - if (_currentGroup == null) - { - return; - } - - var idx = Configuration.Settings.MultipleSearchAndReplaceGroups.IndexOf(_currentGroup); - Configuration.Settings.MultipleSearchAndReplaceGroups.RemoveAt(idx); - if (Configuration.Settings.MultipleSearchAndReplaceGroups.Count > 0) - { - if (idx >= Configuration.Settings.MultipleSearchAndReplaceGroups.Count) - { - idx--; - } - - _currentGroup = Configuration.Settings.MultipleSearchAndReplaceGroups[idx]; - } - else - { - _currentGroup = null; - listViewRules.Items.Clear(); - listViewFixes.Items.Clear(); - } - UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, _currentGroup); - } - - private void SwapGroups(int index, int index2) - { - var temp = Configuration.Settings.MultipleSearchAndReplaceGroups[index]; - Configuration.Settings.MultipleSearchAndReplaceGroups[index] = Configuration.Settings.MultipleSearchAndReplaceGroups[index2]; - Configuration.Settings.MultipleSearchAndReplaceGroups[index2] = temp; - - UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, _currentGroup); - GeneratePreview(); - } - - private void moveUpToolStripMenuItem1_Click(object sender, EventArgs e) - { - if (listViewGroups.Items.Count < 2 || listViewGroups.SelectedItems.Count == 0) - { - return; - } - - int index = listViewGroups.SelectedIndices[0]; - if (index == 0) - { - return; - } - - SwapGroups(index, index - 1); - } - - private void moveDownToolStripMenuItem1_Click(object sender, EventArgs e) - { - if (listViewGroups.Items.Count < 2 || listViewGroups.SelectedItems.Count == 0) - { - return; - } - - int index = listViewGroups.SelectedIndices[0]; - if (index == listViewGroups.Items.Count - 1) - { - return; - } - - SwapGroups(index, index + 1); - } - - private void MultipleReplace_ResizeEnd(object sender, EventArgs e) - { - listViewRules.Columns[listViewRules.Columns.Count - 1].Width = -2; - } - - private void moveToTopToolStripMenuItem_Click(object sender, EventArgs e) - { - if (listViewGroups.Items.Count < 2 || listViewGroups.SelectedItems.Count == 0) - { - return; - } - - int index = listViewGroups.SelectedIndices[0]; - if (index == 0) - { - return; - } - - var temp = Configuration.Settings.MultipleSearchAndReplaceGroups[index]; - Configuration.Settings.MultipleSearchAndReplaceGroups.Remove(temp); - Configuration.Settings.MultipleSearchAndReplaceGroups.Insert(0, temp); - UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, _currentGroup); - GeneratePreview(); - } - - private void moveToBottomToolStripMenuItem_Click(object sender, EventArgs e) - { - if (listViewGroups.Items.Count < 2 || listViewGroups.SelectedItems.Count == 0) - { - return; - } - - int index = listViewGroups.SelectedIndices[0]; - int bottomIndex = listViewGroups.Items.Count - 1; - if (index == bottomIndex) - { - return; - } - - var temp = Configuration.Settings.MultipleSearchAndReplaceGroups[index]; - Configuration.Settings.MultipleSearchAndReplaceGroups.Remove(temp); - Configuration.Settings.MultipleSearchAndReplaceGroups.Insert(bottomIndex, temp); - UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, temp); - GeneratePreview(); - } - - private void contextMenuStripGroups_Opening(object sender, System.ComponentModel.CancelEventArgs e) - { - bool doShow = listViewGroups.SelectedItems.Count > 0; - foreach (ToolStripItem item in contextMenuStripGroups.Items) - { - if (item != newToolStripMenuItem && - item != toolStripSeparatorGroupImportExport && - item != importToolStripMenuItem) - { - item.Visible = doShow; - } - if (item == exportToolStripMenuItem) - { - item.Visible = listViewGroups.Items.Count > 0; - } - } - } - - private void buttonApply_Click(object sender, EventArgs e) - { - SetDeleteIndices(); - ResetUncheckLines(); - _subtitle = new Subtitle(FixedSubtitle); - GeneratePreview(); - } - - private void exportToolStripMenuItem_Click(object sender, EventArgs e) - { - if (listViewGroups.Items.Count == 0) - { - return; - } - - using (var form = new MultipleReplaceExportImport(Configuration.Settings.MultipleSearchAndReplaceGroups, true)) - { - form.ShowDialog(this); - } - } - - private void importToolStripMenuItem_Click(object sender, EventArgs e) - { - openFileDialog1.Title = Configuration.Settings.Language.MultipleReplace.ImportRulesTitle; - openFileDialog1.Filter = Configuration.Settings.Language.MultipleReplace.Rules + TemplateFilterExtension; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - try - { - var importGroups = ImportGroupsFile(openFileDialog1.FileName); - if (importGroups.Count == 0) - { - MessageBox.Show(Configuration.Settings.Language.MultipleReplace.NothingToImport); - return; - } - - using (var form = new MultipleReplaceExportImport(importGroups, false)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - var oldGroupsSelectedIndex = listViewGroups.SelectedIndices.Count == 0 ? -1 : listViewGroups.SelectedIndices[0]; - foreach (var importGroup in importGroups.Where(g => form.ChosenGroups.Contains(g.Name))) - { - importGroup.Name = FixDuplicateName(importGroup.Name, Configuration.Settings.MultipleSearchAndReplaceGroups); - Configuration.Settings.MultipleSearchAndReplaceGroups.Add(importGroup); - } - UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, _currentGroup); - if (oldGroupsSelectedIndex == -1 && listViewGroups.Items.Count > 0) - { - listViewGroups.Items[0].Selected = true; - } - } - } - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - return; - } - GeneratePreview(); - } - } - - private static string FixDuplicateName(string newGroupName, List existinGroups) - { - if (existinGroups.All(p => p.Name != newGroupName)) - { - return newGroupName; - } - - for (int i = 1; i < int.MaxValue; i++) - { - var name = $"{newGroupName}_{i}"; - if (existinGroups.All(p => p.Name != name)) - { - return name; - } - } - - return Guid.NewGuid().ToString(); - } - - private void buttonImportGroups_Click(object sender, EventArgs e) - { - importToolStripMenuItem_Click(sender, e); - } - - private void buttonExportGroups_Click(object sender, EventArgs e) - { - exportToolStripMenuItem_Click(sender, e); - } - - private void listViewFixes_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) - { - listViewFixes.SelectAll(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.D && e.Modifiers == Keys.Control) - { - listViewFixes.SelectFirstSelectedItemOnly(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.I && e.Modifiers == (Keys.Control | Keys.Shift)) //InverseSelection - { - listViewFixes.InverseSelection(); - e.SuppressKeyPress = true; - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class MultipleReplace : PositionAndSizeForm + { + internal const string Group = "Group"; + internal const string GroupName = "Name"; + internal const string GroupEnabled = "Enabled"; + internal const string MultipleSearchAndReplaceItem = "MultipleSearchAndReplaceItem"; + internal const string RuleEnabled = "Enabled"; + internal const string FindWhat = "FindWhat"; + internal const string ReplaceWith = "ReplaceWith"; + internal const string SearchType = "SearchType"; + internal const string Description = "Description"; + + private const string TemplateFilterExtension = "|*.template"; + + private readonly List _oldMultipleSearchAndReplaceGroups = new List(); + private readonly Dictionary _compiledRegExList = new Dictionary(); + private Subtitle _subtitle; + private Subtitle _original; + public Subtitle FixedSubtitle { get; private set; } + public int FixCount { get; private set; } + public List DeleteIndices { get; } + + public void SetDeleteIndices() + { + foreach (ListViewItem item in listViewFixes.Items) + { + if (item.Checked && item.SubItems[3].Text == string.Empty) + { + var index = _subtitle.GetIndex(item.Tag as Paragraph); + if (!DeleteIndices.Contains(index)) + { + DeleteIndices.Add(index); + } + } + } + } + + private MultipleSearchAndReplaceGroup _currentGroup; + + public MultipleReplace() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + DeleteIndices = new List(); + openFileDialog1.FileName = string.Empty; + saveFileDialog1.FileName = string.Empty; + + textBoxReplace.ContextMenu = FindReplaceDialogHelper.GetReplaceTextContextMenu(textBoxReplace); + buttonUpdate.Enabled = false; + + Text = Configuration.Settings.Language.MultipleReplace.Title; + labelFindWhat.Text = Configuration.Settings.Language.MultipleReplace.FindWhat; + labelReplaceWith.Text = Configuration.Settings.Language.MultipleReplace.ReplaceWith; + labelDescription.Text = Configuration.Settings.Language.MultipleReplace.Description; + radioButtonNormal.Text = Configuration.Settings.Language.MultipleReplace.Normal; + radioButtonRegEx.Text = Configuration.Settings.Language.MultipleReplace.RegularExpression; + radioButtonCaseSensitive.Text = Configuration.Settings.Language.MultipleReplace.CaseSensitive; + buttonAdd.Text = Configuration.Settings.Language.MultipleReplace.Add; + buttonUpdate.Text = Configuration.Settings.Language.MultipleReplace.Update; + listViewRules.Columns[0].Text = Configuration.Settings.Language.MultipleReplace.Enabled; + listViewRules.Columns[1].Text = Configuration.Settings.Language.MultipleReplace.FindWhat; + listViewRules.Columns[2].Text = Configuration.Settings.Language.MultipleReplace.ReplaceWith; + listViewRules.Columns[3].Text = Configuration.Settings.Language.MultipleReplace.SearchType; + listViewRules.Columns[4].Text = Configuration.Settings.Language.MultipleReplace.Description; + groupBoxGroups.Text = Configuration.Settings.Language.MultipleReplace.Groups; + groupBoxLinesFound.Text = string.Empty; + listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; + listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; + listViewFixes.Columns[2].Text = Configuration.Settings.Language.General.Before; + listViewFixes.Columns[3].Text = Configuration.Settings.Language.General.After; + deleteToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.Remove; + toolStripMenuItemRemoveAll.Text = Configuration.Settings.Language.MultipleReplace.RemoveAll; + toolStripMenuItemImport.Text = Configuration.Settings.Language.MultipleReplace.Import; + toolStripMenuItemExport.Text = Configuration.Settings.Language.MultipleReplace.Export; + importToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.Import; + exportToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.Export; + buttonImportGroups.Text = Configuration.Settings.Language.MultipleReplace.Import; + buttonExportGroups.Text = Configuration.Settings.Language.MultipleReplace.Export; + buttonNewGroup.Text = Configuration.Settings.Language.MultipleReplace.NewGroup; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + buttonApply.Text = Configuration.Settings.Language.General.Apply; + buttonReplacesSelectAll.Text = Configuration.Settings.Language.FixCommonErrors.SelectAll; + buttonReplacesInverseSelection.Text = Configuration.Settings.Language.FixCommonErrors.InverseSelection; + UiUtil.FixLargeFonts(this, buttonOK); + splitContainer1.Panel1MinSize = 200; + splitContainer1.Panel2MinSize = 200; + + moveUpToolStripMenuItem.Text = Configuration.Settings.Language.DvdSubRip.MoveUp; + moveDownToolStripMenuItem.Text = Configuration.Settings.Language.DvdSubRip.MoveDown; + moveTopToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.MoveToTop; + moveBottomToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.MoveToBottom; + newToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.NewGroup; + + toolStripMenuItemMoveRulesToGroup.Text = Configuration.Settings.Language.MultipleReplace.MoveSelectedRulesToGroup; + moveUpToolStripMenuItem1.Text = Configuration.Settings.Language.DvdSubRip.MoveUp; + moveDownToolStripMenuItem1.Text = Configuration.Settings.Language.DvdSubRip.MoveDown; + moveToTopToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.MoveToTop; + moveToBottomToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.MoveToBottom; + toolStripMenuItemRename.Text = Configuration.Settings.Language.MultipleReplace.RenameGroup; + deleteToolStripMenuItem1.Text = Configuration.Settings.Language.MultipleReplace.Remove; + + radioButtonCaseSensitive.Left = radioButtonNormal.Left + radioButtonNormal.Width + 40; + radioButtonRegEx.Left = radioButtonCaseSensitive.Left + radioButtonCaseSensitive.Width + 40; + } + + public void Initialize(Subtitle subtitle) + { + _subtitle = subtitle ?? throw new ArgumentNullException(nameof(subtitle)); + _original = new Subtitle(_subtitle); + _oldMultipleSearchAndReplaceGroups.Clear(); + + if (Configuration.Settings.MultipleSearchAndReplaceGroups.Count == 0) + { + Configuration.Settings.MultipleSearchAndReplaceGroups.Add(new MultipleSearchAndReplaceGroup { Enabled = true, Name = "Default", Rules = new List() }); + } + + foreach (var group in Configuration.Settings.MultipleSearchAndReplaceGroups) + { + var oldGroup = new MultipleSearchAndReplaceGroup { Name = group.Name, Enabled = group.Enabled, Rules = new List() }; + foreach (var rule in group.Rules) + { + oldGroup.Rules.Add(rule); + } + _oldMultipleSearchAndReplaceGroups.Add(oldGroup); + } + + if (subtitle.Paragraphs == null || subtitle.Paragraphs.Count == 0) + { + groupBoxLinesFound.Enabled = false; + } + + UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, Configuration.Settings.MultipleSearchAndReplaceGroups[0]); + } + + internal void RunFromBatch(Subtitle subtitle) + { + Initialize(subtitle); + GeneratePreview(); + SetDeleteIndices(); + } + + internal void RunFromBatch(Subtitle subtitle, IEnumerable importFileNames) + { + var savedList = Configuration.Settings.MultipleSearchAndReplaceGroups; + try + { + Configuration.Settings.MultipleSearchAndReplaceGroups = new List(); + foreach (var fileName in importFileNames) + { + if (fileName.Equals(".")) + { + Configuration.Settings.MultipleSearchAndReplaceGroups.AddRange(savedList); + } + else + { + Configuration.Settings.MultipleSearchAndReplaceGroups.AddRange(ImportGroupsFile(fileName)); + } + } + RunFromBatch(subtitle); + } + finally + { + Configuration.Settings.MultipleSearchAndReplaceGroups = savedList; + } + } + + private void MultipleReplace_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + buttonCancel_Click(null, null); + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#multiple_replace"); + } + } + + private void RadioButtonCheckedChanged(object sender, EventArgs e) + { + textBoxFind.ContextMenu = sender == radioButtonRegEx ? FindReplaceDialogHelper.GetRegExContextMenu(textBoxFind) : null; + } + + private void ButtonAddClick(object sender, EventArgs e) + { + if (_currentGroup == null) + { + return; + } + + string findText = textBoxFind.Text.RemoveControlCharacters(); + if (findText.Length > 0) + { + string searchType = ReplaceExpression.SearchTypeNormal; + if (radioButtonCaseSensitive.Checked) + { + searchType = ReplaceExpression.SearchTypeCaseSensitive; + } + else if (radioButtonRegEx.Checked) + { + searchType = ReplaceExpression.SearchTypeRegularExpression; + if (!RegexUtils.IsValidRegex(findText)) + { + MessageBox.Show(Configuration.Settings.Language.General.RegularExpressionIsNotValid); + textBoxFind.Select(); + return; + } + } + + var rule = new MultipleSearchAndReplaceSetting { Enabled = true, FindWhat = findText, ReplaceWith = textBoxReplace.Text, SearchType = searchType, Description = textBoxDescription.Text }; + _currentGroup.Rules.Add(rule); + AddToRulesListView(rule); + textBoxFind.Text = string.Empty; + textBoxReplace.Text = string.Empty; + textBoxDescription.Text = string.Empty; + GeneratePreview(); + textBoxFind.Select(); + } + } + + private void GeneratePreview() + { + Cursor = Cursors.WaitCursor; + FixedSubtitle = new Subtitle(_subtitle); + int fixedLines = 0; + listViewFixes.BeginUpdate(); + listViewFixes.Items.Clear(); + var replaceExpressions = new HashSet(); + foreach (var group in Configuration.Settings.MultipleSearchAndReplaceGroups) + { + if (group.Enabled) + { + foreach (var rule in group.Rules) + { + if (rule.Enabled) + { + string findWhat = rule.FindWhat; + if (!string.IsNullOrEmpty(findWhat)) // allow space or spaces + { + string replaceWith = RegexUtils.FixNewLine(rule.ReplaceWith); + findWhat = RegexUtils.FixNewLine(findWhat); + string searchType = rule.SearchType; + var mpi = new ReplaceExpression(findWhat, replaceWith, searchType); + replaceExpressions.Add(mpi); + if (mpi.SearchType == ReplaceExpression.SearchRegEx && !_compiledRegExList.ContainsKey(findWhat)) + { + _compiledRegExList.Add(findWhat, new Regex(findWhat, RegexOptions.Compiled | RegexOptions.Multiline)); + } + } + } + } + } + } + + var fixes = new List(); + for (var i = 0; i < _subtitle.Paragraphs.Count; i++) + { + Paragraph p = _subtitle.Paragraphs[i]; + bool hit = false; + string newText = p.Text; + foreach (ReplaceExpression item in replaceExpressions) + { + if (item.SearchType == ReplaceExpression.SearchCaseSensitive) + { + if (newText.Contains(item.FindWhat)) + { + hit = true; + newText = newText.Replace(item.FindWhat, item.ReplaceWith); + } + } + else if (item.SearchType == ReplaceExpression.SearchRegEx) + { + Regex r = _compiledRegExList[item.FindWhat]; + if (r.IsMatch(newText)) + { + hit = true; + newText = RegexUtils.ReplaceNewLineSafe(r, newText, item.ReplaceWith); + } + } + else + { + int index = newText.IndexOf(item.FindWhat, StringComparison.OrdinalIgnoreCase); + if (index >= 0) + { + hit = true; + do + { + newText = newText.Remove(index, item.FindWhat.Length).Insert(index, item.ReplaceWith); + index = newText.IndexOf(item.FindWhat, index + item.ReplaceWith.Length, StringComparison.OrdinalIgnoreCase); + } while (index >= 0); + } + } + } + + if (hit && newText != p.Text) + { + fixedLines++; + fixes.Add(MakePreviewListItem(p, newText)); + FixedSubtitle.Paragraphs[i].Text = newText; + } + } + + listViewFixes.Items.AddRange(fixes.ToArray()); + listViewFixes.EndUpdate(); + groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.MultipleReplace.LinesFoundX, fixedLines); + Cursor = Cursors.Default; + } + + private void AddToRulesListView(MultipleSearchAndReplaceSetting rule) + { + var item = new ListViewItem(string.Empty) { Checked = rule.Enabled, Tag = rule }; + item.SubItems.Add(rule.FindWhat); + item.SubItems.Add(rule.ReplaceWith); + item.SubItems.Add(EnglishSearchTypeToLocal(rule.SearchType)); + item.SubItems.Add(rule.Description); + listViewRules.Items.Add(item); + } + + private ListViewItem MakePreviewListItem(Paragraph p, string newText) + { + var item = new ListViewItem(string.Empty) { Tag = p, Checked = true }; + item.SubItems.Add(p.Number.ToString(CultureInfo.InvariantCulture)); + item.SubItems.Add(UiUtil.GetListViewTextFromString(p.Text)); + item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); + return item; + } + + private static string LocalSearchTypeToEnglish(string searchType) + { + if (searchType == Configuration.Settings.Language.MultipleReplace.RegularExpression) + { + return ReplaceExpression.SearchTypeRegularExpression; + } + + if (searchType == Configuration.Settings.Language.MultipleReplace.CaseSensitive) + { + return ReplaceExpression.SearchTypeCaseSensitive; + } + + return ReplaceExpression.SearchTypeNormal; + } + + private static string EnglishSearchTypeToLocal(string searchType) + { + if (searchType == ReplaceExpression.SearchTypeRegularExpression) + { + return Configuration.Settings.Language.MultipleReplace.RegularExpression; + } + + if (searchType == ReplaceExpression.SearchTypeCaseSensitive) + { + return Configuration.Settings.Language.MultipleReplace.CaseSensitive; + } + + return Configuration.Settings.Language.MultipleReplace.Normal; + } + + private void buttonOK_Click(object sender, EventArgs e) + { + SetDeleteIndices(); + ResetUncheckLines(); + SetFixCount(); + SaveReplaceList(true); + DialogResult = DialogResult.OK; + } + + public void SetFixCount() + { + for (var index = 0; index < _original.Paragraphs.Count; index++) + { + var p = _original.Paragraphs[index]; + var f = FixedSubtitle.GetParagraphOrDefault(index); + if (f != null && f.Text != p.Text) + { + FixCount++; + } + } + } + + private void SaveReplaceList(bool saveToDisk) + { + if (saveToDisk) + { + Configuration.Settings.Save(); + } + } + + private void ResetUncheckLines() + { + foreach (ListViewItem item in listViewFixes.Items) + { + if (!item.Checked) + { + int index = _subtitle.GetIndex(item.Tag as Paragraph); + FixedSubtitle.Paragraphs[index].Text = _subtitle.Paragraphs[index].Text; + } + } + } + + private void DeleteToolStripMenuItemClick(object sender, EventArgs e) + { + if (listViewRules.Items.Count < 1 || listViewRules.SelectedItems.Count < 1 || _currentGroup == null) + { + return; + } + + listViewRules.BeginUpdate(); + for (int i = listViewRules.Items.Count - 1; i >= 0; i--) + { + ListViewItem item = listViewRules.Items[i]; + if (item.Selected) + { + item.Remove(); + _currentGroup.Rules.Remove(item.Tag as MultipleSearchAndReplaceSetting); + } + } + listViewRules.EndUpdate(); + GeneratePreview(); + } + + private void ListViewRulesKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) + { + listViewRules.SelectAll(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.D && e.Modifiers == Keys.Control) + { + listViewRules.SelectFirstSelectedItemOnly(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.I && e.Modifiers == (Keys.Control | Keys.Shift)) //InverseSelection + { + listViewRules.InverseSelection(); + e.SuppressKeyPress = true; + } + } + + private void ButtonUpdateClick(object sender, EventArgs e) + { + if (listViewRules.SelectedItems.Count != 1 || _currentGroup == null) + { + return; + } + + string findText = textBoxFind.Text.RemoveControlCharacters(); + textBoxFind.Text = findText; + + string replaceText = textBoxReplace.Text.RemoveControlCharacters(); + textBoxReplace.Text = replaceText; + + if (findText.Length > 0) + { + string searchType = ReplaceExpression.SearchTypeNormal; + if (radioButtonCaseSensitive.Checked) + { + searchType = ReplaceExpression.SearchTypeCaseSensitive; + } + else if (radioButtonRegEx.Checked) + { + searchType = ReplaceExpression.SearchTypeRegularExpression; + if (!RegexUtils.IsValidRegex(findText)) + { + MessageBox.Show(Configuration.Settings.Language.General.RegularExpressionIsNotValid); + textBoxFind.Select(); + return; + } + } + + var item = listViewRules.SelectedItems[0]; + item.SubItems[1].Text = findText; + item.SubItems[2].Text = replaceText; + item.SubItems[3].Text = EnglishSearchTypeToLocal(searchType); + item.SubItems[4].Text = textBoxDescription.Text; + + _currentGroup.Rules[item.Index].FindWhat = findText; + _currentGroup.Rules[item.Index].ReplaceWith = replaceText; + _currentGroup.Rules[item.Index].SearchType = searchType; + _currentGroup.Rules[item.Index].Description = textBoxDescription.Text; + + GeneratePreview(); + textBoxFind.Select(); + } + } + + private void ListViewReplaceListSelectedIndexChanged(object sender, EventArgs e) + { + if (listViewRules.SelectedItems.Count == 1) + { + buttonUpdate.Enabled = true; + textBoxFind.Text = listViewRules.SelectedItems[0].SubItems[1].Text; + textBoxReplace.Text = listViewRules.SelectedItems[0].SubItems[2].Text; + string searchType = LocalSearchTypeToEnglish(listViewRules.SelectedItems[0].SubItems[3].Text); + if (searchType == ReplaceExpression.SearchTypeRegularExpression) + { + radioButtonRegEx.Checked = true; + } + else if (searchType == ReplaceExpression.SearchTypeCaseSensitive) + { + radioButtonCaseSensitive.Checked = true; + } + else + { + radioButtonNormal.Checked = true; + } + + textBoxDescription.Text = listViewRules.SelectedItems[0].SubItems[4].Text; + } + else + { + buttonUpdate.Enabled = false; + } + } + + private void TextBoxReplaceKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + ButtonAddClick(null, null); + } + } + + private void buttonReplacesSelectAll_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = true; + } + } + + private void buttonReplacesInverseSelection_Click(object sender, EventArgs e) + { + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = !item.Checked; + } + } + + private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e) + { + bool moreThanOneGroup = Configuration.Settings.MultipleSearchAndReplaceGroups.Count > 1; + bool isVisible = listViewRules.Items.Count > 1 && listViewRules.SelectedItems.Count == 1; + toolStripSeparator3.Visible = isVisible; + moveUpToolStripMenuItem.Visible = isVisible; + moveDownToolStripMenuItem.Visible = isVisible; + moveTopToolStripMenuItem.Visible = isVisible; + moveBottomToolStripMenuItem.Visible = isVisible; + + toolStripMenuItemExport.Visible = listViewRules.Items.Count > 0; + toolStripMenuItemRemoveAll.Visible = listViewRules.Items.Count > 0; + toolStripSeparator2.Visible = listViewRules.Items.Count > 0; + + deleteToolStripMenuItem.Visible = listViewRules.SelectedItems.Count >= 1; + + if (moreThanOneGroup && listViewRules.SelectedItems.Count >= 1) + { + toolStripMenuItemMoveRulesToGroup.Visible = true; + toolStripSeparator4.Visible = true; + toolStripMenuItemMoveRulesToGroup.DropDownItems.Clear(); + foreach (var g in Configuration.Settings.MultipleSearchAndReplaceGroups) + { + if (g != _currentGroup) + { + var menuItem = new ToolStripMenuItem(g.Name) { Tag = g }; + menuItem.Click += (o, args) => { MoveRulesToGroup(g); }; + toolStripMenuItemMoveRulesToGroup.DropDownItems.Add(menuItem); + } + } + } + else + { + toolStripMenuItemMoveRulesToGroup.Visible = false; + toolStripSeparator4.Visible = false; + } + } + + private void MoveRulesToGroup(MultipleSearchAndReplaceGroup newGroup) + { + foreach (ListViewItem item in listViewRules.SelectedItems) + { + var rule = (MultipleSearchAndReplaceSetting)item.Tag; + _currentGroup.Rules.Remove(rule); + newGroup.Rules.Add(rule); + } + UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, _currentGroup); + GeneratePreview(); + } + + private void SwapRules(int index, int index2) + { + if (_currentGroup == null) + { + return; + } + + listViewRules.ItemChecked -= ListViewRulesItemChecked; + + var temp = _currentGroup.Rules[index]; + _currentGroup.Rules[index] = _currentGroup.Rules[index2]; + _currentGroup.Rules[index2] = temp; + + bool enabled = listViewRules.Items[index].Checked; + string findWhat = listViewRules.Items[index].SubItems[1].Text; + string replaceWith = listViewRules.Items[index].SubItems[2].Text; + string searchType = listViewRules.Items[index].SubItems[3].Text; + string description = listViewRules.Items[index].SubItems[4].Text; + + listViewRules.Items[index].Checked = listViewRules.Items[index2].Checked; + listViewRules.Items[index].SubItems[1].Text = listViewRules.Items[index2].SubItems[1].Text; + listViewRules.Items[index].SubItems[2].Text = listViewRules.Items[index2].SubItems[2].Text; + listViewRules.Items[index].SubItems[3].Text = listViewRules.Items[index2].SubItems[3].Text; + listViewRules.Items[index].SubItems[4].Text = listViewRules.Items[index2].SubItems[4].Text; + listViewRules.Items[index].Tag = _currentGroup.Rules[index]; + + listViewRules.Items[index2].Checked = enabled; + listViewRules.Items[index2].SubItems[1].Text = findWhat; + listViewRules.Items[index2].SubItems[2].Text = replaceWith; + listViewRules.Items[index2].SubItems[3].Text = searchType; + listViewRules.Items[index2].SubItems[4].Text = description; + listViewRules.Items[index2].Tag = _currentGroup.Rules[index2]; + + listViewRules.Items[index].Selected = false; + listViewRules.Items[index2].Selected = true; + listViewRules.Items[index2].Focused = true; + listViewRules.EnsureVisible(index2); + GeneratePreview(); + listViewRules.ItemChecked += ListViewRulesItemChecked; + } + + private void moveUpToolStripMenuItem_Click(object sender, EventArgs e) + { + if (listViewRules.SelectedItems.Count != 1 || listViewRules.Items.Count < 2) + { + return; + } + + int index = listViewRules.SelectedIndices[0]; + if (index == 0) + { + return; + } + + SwapRules(index, index - 1); + } + + private void moveDownToolStripMenuItem_Click(object sender, EventArgs e) + { + if (listViewRules.SelectedItems.Count != 1 || listViewRules.Items.Count < 2) + { + return; + } + + int index = listViewRules.SelectedIndices[0]; + if (index == listViewRules.Items.Count - 1) + { + return; + } + + SwapRules(index, index + 1); + } + + private void moveTopToolStripMenuItem_Click(object sender, EventArgs e) + { + if (listViewRules.SelectedItems.Count != 1 || listViewRules.Items.Count < 2) + { + return; + } + + int index = listViewRules.SelectedIndices[0]; + if (index == 0) + { + return; + } + + if (_currentGroup == null) + { + return; + } + + var temp = _currentGroup.Rules[index]; + _currentGroup.Rules.Remove(temp); + _currentGroup.Rules.Insert(0, temp); + listViewGroups_SelectedIndexChanged(null, null); + GeneratePreview(); + } + + private void moveBottomToolStripMenuItem_Click(object sender, EventArgs e) + { + if (listViewRules.SelectedItems.Count != 1 || listViewRules.Items.Count < 2) + { + return; + } + + int index = listViewRules.SelectedIndices[0]; + int bottomIndex = listViewRules.Items.Count - 1; + if (index == bottomIndex) + { + return; + } + + var temp = _currentGroup.Rules[index]; + _currentGroup.Rules.Remove(temp); + _currentGroup.Rules.Add(temp); + listViewGroups_SelectedIndexChanged(null, null); + listViewRules.Items[0].Selected = false; + listViewRules.Items[bottomIndex].Selected = true; + listViewRules.Items[bottomIndex].Focused = true; + listViewRules.EnsureVisible(bottomIndex); + GeneratePreview(); + } + + private void ImportRulesFile(string fileName) + { + if (_currentGroup == null) + { + return; + } + + var doc = new XmlDocument { XmlResolver = null }; + doc.Load(fileName); + + var replaceNodes = doc.DocumentElement?.SelectNodes("//MultipleSearchAndReplaceItem"); + if (replaceNodes == null) + { + return; + } + + foreach (XmlNode listNode in replaceNodes) + { + var item = MakeMultipleSearchAndReplaceSetting(listNode); + AddToRulesListView(item); + _currentGroup.Rules.Add(item); + } + } + + private List ImportGroupsFile(string fileName) + { + var list = new List(); + var doc = new XmlDocument { XmlResolver = null }; + doc.Load(fileName); + var groups = doc.DocumentElement?.SelectNodes("//Group"); + if (groups != null) + { + foreach (XmlNode groupNode in groups) + { + var group = new MultipleSearchAndReplaceGroup(); + var nameNode = groupNode.SelectSingleNode(GroupName); + var enabledNode = groupNode.SelectSingleNode(GroupEnabled); + + group.Name = nameNode != null ? nameNode.InnerText : "Untitled"; + group.Enabled = enabledNode != null ? Convert.ToBoolean(enabledNode.InnerText) : false; + + group.Rules = new List(); + list.Add(group); + + var replaceItems = groupNode.SelectNodes("MultipleSearchAndReplaceItem"); + if (replaceItems != null) + { + foreach (XmlNode listNode in replaceItems) + { + var item = MakeMultipleSearchAndReplaceSetting(listNode); + group.Rules.Add(item); + } + } + } + } + + if (list.Count == 0) + { + // import into "untitled" group if only rules + var group = new MultipleSearchAndReplaceGroup + { + Name = "untitled", + Rules = new List() + }; + var replaceItems = doc.DocumentElement?.SelectNodes("//MultipleSearchAndReplaceItem"); + if (replaceItems != null) + { + foreach (XmlNode listNode in replaceItems) + { + var item = MakeMultipleSearchAndReplaceSetting(listNode); + group.Rules.Add(item); + } + } + + if (group.Rules.Count > 0) + { + list.Add(group); + } + } + + return list; + } + + private static MultipleSearchAndReplaceSetting MakeMultipleSearchAndReplaceSetting(XmlNode listNode) + { + var item = new MultipleSearchAndReplaceSetting(); + var subNode = listNode.SelectSingleNode(RuleEnabled); + if (subNode != null) + { + item.Enabled = Convert.ToBoolean(subNode.InnerText); + } + + subNode = listNode.SelectSingleNode(FindWhat); + if (subNode != null) + { + item.FindWhat = subNode.InnerText; + } + + subNode = listNode.SelectSingleNode(ReplaceWith); + if (subNode != null) + { + item.ReplaceWith = subNode.InnerText; + } + + subNode = listNode.SelectSingleNode(SearchType); + if (subNode != null) + { + item.SearchType = subNode.InnerText; + } + + subNode = listNode.SelectSingleNode(SearchType); + if (subNode != null) + { + item.SearchType = subNode.InnerText; + } + + subNode = listNode.SelectSingleNode(Description); + if (subNode != null) + { + item.Description = subNode.InnerText; + } + + return item; + } + + private void MultipleReplace_Shown(object sender, EventArgs e) + { + GeneratePreview(); + listViewRules.ItemChecked += ListViewRulesItemChecked; + listViewGroups.ItemChecked += listViewGroups_ItemChecked; + listViewGroups.SelectedIndexChanged += listViewGroups_SelectedIndexChanged; + MultipleReplace_ResizeEnd(sender, null); + listViewGroups_SelectedIndexChanged(null, null); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + Configuration.Settings.MultipleSearchAndReplaceGroups = _oldMultipleSearchAndReplaceGroups; + DialogResult = DialogResult.Cancel; + } + + private void buttonNewGroup_Click(object sender, EventArgs e) + { + newToolStripMenuItem_Click(sender, null); + } + + private void newToolStripMenuItem_Click(object sender, EventArgs e) + { + using (var form = new MultipleReplaceNewGroup(string.Empty)) + { + if (form.ShowDialog(this) == DialogResult.OK && form.GroupName.Length > 0) + { + var newGroup = new MultipleSearchAndReplaceGroup { Enabled = true, Name = form.GroupName, Rules = new List() }; + Configuration.Settings.MultipleSearchAndReplaceGroups.Add(newGroup); + UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, newGroup); + } + } + } + + private void UpdateViewFromModel(List groups, MultipleSearchAndReplaceGroup focusGroup) + { + listViewGroups.BeginUpdate(); + listViewGroups.Items.Clear(); + for (int index = 0; index < groups.Count; index++) + { + var group = groups[index]; + var lvi = new ListViewItem(group.Name) { Checked = group.Enabled, Tag = group }; + listViewGroups.Items.Add(lvi); + if (group == focusGroup) + { + listViewGroups.Items[index].Selected = true; + listViewGroups.Items[index].Focused = true; + listViewGroups.EnsureVisible(index); + } + } + listViewGroups.EndUpdate(); + if (groups.Count == 0) + { + groupBoxReplaces.Text = string.Empty; + textBoxFind.Text = string.Empty; + textBoxReplace.Text = string.Empty; + textBoxDescription.Text = string.Empty; + textBoxDescription.Text = string.Empty; + radioButtonNormal.Checked = true; + } + } + + private void listViewGroups_SelectedIndexChanged(object sender, EventArgs e) + { + if (listViewGroups.SelectedItems.Count < 1) + { + return; + } + + _currentGroup = listViewGroups.SelectedItems[0].Tag as MultipleSearchAndReplaceGroup; + if (_currentGroup == null) + { + return; + } + + listViewRules.ItemChecked -= ListViewRulesItemChecked; + listViewGroups.ItemChecked -= listViewGroups_ItemChecked; + listViewRules.BeginUpdate(); + groupBoxReplaces.Text = string.Format(Configuration.Settings.Language.MultipleReplace.RulesForGroupX, _currentGroup.Name); + listViewRules.Items.Clear(); + foreach (var rule in _currentGroup.Rules) + { + AddToRulesListView(rule); + } + if (_currentGroup.Rules.Count > 0) + { + listViewRules.Items[0].Selected = true; + } + else + { + textBoxFind.Text = string.Empty; + textBoxReplace.Text = string.Empty; + textBoxDescription.Text = string.Empty; + } + listViewRules.EndUpdate(); + listViewRules.ItemChecked += ListViewRulesItemChecked; + listViewGroups.ItemChecked += listViewGroups_ItemChecked; + } + + private void listViewGroups_ItemChecked(object sender, ItemCheckedEventArgs e) + { + var group = e.Item.Tag as MultipleSearchAndReplaceGroup; + if (group == null) + { + return; + } + + group.Enabled = e.Item.Checked; + GeneratePreview(); + } + + private void ListViewRulesItemChecked(object sender, ItemCheckedEventArgs e) + { + if (!(e.Item.Tag is MultipleSearchAndReplaceSetting rule)) + { + return; + } + + rule.Enabled = e.Item.Checked; + GeneratePreview(); + } + + private void toolStripMenuItem2_Click(object sender, EventArgs e) + { + if (_currentGroup == null) + { + return; + } + + _currentGroup.Rules.Clear(); + listViewRules.Items.Clear(); + GeneratePreview(); + } + + private void toolStripMenuItem4_Click(object sender, EventArgs e) + { + if (_currentGroup == null || _currentGroup.Rules.Count == 0) + { + return; + } + + saveFileDialog1.Title = Configuration.Settings.Language.MultipleReplace.ExportRulesTitle; + saveFileDialog1.Filter = Configuration.Settings.Language.MultipleReplace.Rules + TemplateFilterExtension; + if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) + { + var textWriter = new XmlTextWriter(saveFileDialog1.FileName, null) { Formatting = Formatting.Indented }; + textWriter.WriteStartDocument(); + textWriter.WriteStartElement("Settings", string.Empty); + textWriter.WriteStartElement("MultipleSearchAndReplaceList", string.Empty); + textWriter.WriteStartElement(Group, string.Empty); + textWriter.WriteElementString(GroupName, _currentGroup.Name); + foreach (var item in _currentGroup.Rules) + { + textWriter.WriteStartElement(MultipleSearchAndReplaceItem, string.Empty); + textWriter.WriteElementString(RuleEnabled, item.Enabled.ToString()); + textWriter.WriteElementString(FindWhat, item.FindWhat); + textWriter.WriteElementString(ReplaceWith, item.ReplaceWith); + textWriter.WriteElementString(SearchType, item.SearchType); + textWriter.WriteElementString(Description, item.Description); + textWriter.WriteEndElement(); + } + textWriter.WriteEndElement(); + textWriter.WriteEndElement(); + textWriter.WriteEndElement(); + textWriter.WriteEndDocument(); + textWriter.Close(); + } + } + + private void toolStripMenuItem3_Click(object sender, EventArgs e) + { + if (_currentGroup == null) + { + return; + } + + openFileDialog1.Title = Configuration.Settings.Language.MultipleReplace.ImportRulesTitle; + openFileDialog1.Filter = Configuration.Settings.Language.MultipleReplace.Rules + TemplateFilterExtension; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + try + { + ImportRulesFile(openFileDialog1.FileName); + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + return; + } + GeneratePreview(); + } + } + + private void ToolStripMenuItemRenameClick(object sender, EventArgs e) + { + if (_currentGroup == null) + { + return; + } + + using (var form = new MultipleReplaceNewGroup(_currentGroup.Name)) + { + if (form.ShowDialog(this) == DialogResult.OK && form.GroupName.Length > 0) + { + _currentGroup.Name = form.GroupName; + UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, _currentGroup); + } + } + } + + private void deleteToolStripMenuItem1_Click(object sender, EventArgs e) + { + if (_currentGroup == null) + { + return; + } + + var idx = Configuration.Settings.MultipleSearchAndReplaceGroups.IndexOf(_currentGroup); + Configuration.Settings.MultipleSearchAndReplaceGroups.RemoveAt(idx); + if (Configuration.Settings.MultipleSearchAndReplaceGroups.Count > 0) + { + if (idx >= Configuration.Settings.MultipleSearchAndReplaceGroups.Count) + { + idx--; + } + + _currentGroup = Configuration.Settings.MultipleSearchAndReplaceGroups[idx]; + } + else + { + _currentGroup = null; + listViewRules.Items.Clear(); + listViewFixes.Items.Clear(); + } + UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, _currentGroup); + } + + private void SwapGroups(int index, int index2) + { + var temp = Configuration.Settings.MultipleSearchAndReplaceGroups[index]; + Configuration.Settings.MultipleSearchAndReplaceGroups[index] = Configuration.Settings.MultipleSearchAndReplaceGroups[index2]; + Configuration.Settings.MultipleSearchAndReplaceGroups[index2] = temp; + + UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, _currentGroup); + GeneratePreview(); + } + + private void moveUpToolStripMenuItem1_Click(object sender, EventArgs e) + { + if (listViewGroups.Items.Count < 2 || listViewGroups.SelectedItems.Count == 0) + { + return; + } + + int index = listViewGroups.SelectedIndices[0]; + if (index == 0) + { + return; + } + + SwapGroups(index, index - 1); + } + + private void moveDownToolStripMenuItem1_Click(object sender, EventArgs e) + { + if (listViewGroups.Items.Count < 2 || listViewGroups.SelectedItems.Count == 0) + { + return; + } + + int index = listViewGroups.SelectedIndices[0]; + if (index == listViewGroups.Items.Count - 1) + { + return; + } + + SwapGroups(index, index + 1); + } + + private void MultipleReplace_ResizeEnd(object sender, EventArgs e) + { + listViewRules.Columns[listViewRules.Columns.Count - 1].Width = -2; + } + + private void moveToTopToolStripMenuItem_Click(object sender, EventArgs e) + { + if (listViewGroups.Items.Count < 2 || listViewGroups.SelectedItems.Count == 0) + { + return; + } + + int index = listViewGroups.SelectedIndices[0]; + if (index == 0) + { + return; + } + + var temp = Configuration.Settings.MultipleSearchAndReplaceGroups[index]; + Configuration.Settings.MultipleSearchAndReplaceGroups.Remove(temp); + Configuration.Settings.MultipleSearchAndReplaceGroups.Insert(0, temp); + UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, _currentGroup); + GeneratePreview(); + } + + private void moveToBottomToolStripMenuItem_Click(object sender, EventArgs e) + { + if (listViewGroups.Items.Count < 2 || listViewGroups.SelectedItems.Count == 0) + { + return; + } + + int index = listViewGroups.SelectedIndices[0]; + int bottomIndex = listViewGroups.Items.Count - 1; + if (index == bottomIndex) + { + return; + } + + var temp = Configuration.Settings.MultipleSearchAndReplaceGroups[index]; + Configuration.Settings.MultipleSearchAndReplaceGroups.Remove(temp); + Configuration.Settings.MultipleSearchAndReplaceGroups.Insert(bottomIndex, temp); + UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, temp); + GeneratePreview(); + } + + private void contextMenuStripGroups_Opening(object sender, System.ComponentModel.CancelEventArgs e) + { + bool doShow = listViewGroups.SelectedItems.Count > 0; + foreach (ToolStripItem item in contextMenuStripGroups.Items) + { + if (item != newToolStripMenuItem && + item != toolStripSeparatorGroupImportExport && + item != importToolStripMenuItem) + { + item.Visible = doShow; + } + if (item == exportToolStripMenuItem) + { + item.Visible = listViewGroups.Items.Count > 0; + } + } + } + + private void buttonApply_Click(object sender, EventArgs e) + { + SetDeleteIndices(); + ResetUncheckLines(); + _subtitle = new Subtitle(FixedSubtitle); + GeneratePreview(); + } + + private void exportToolStripMenuItem_Click(object sender, EventArgs e) + { + if (listViewGroups.Items.Count == 0) + { + return; + } + + using (var form = new MultipleReplaceExportImport(Configuration.Settings.MultipleSearchAndReplaceGroups, true)) + { + form.ShowDialog(this); + } + } + + private void importToolStripMenuItem_Click(object sender, EventArgs e) + { + openFileDialog1.Title = Configuration.Settings.Language.MultipleReplace.ImportRulesTitle; + openFileDialog1.Filter = Configuration.Settings.Language.MultipleReplace.Rules + TemplateFilterExtension; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + try + { + var importGroups = ImportGroupsFile(openFileDialog1.FileName); + if (importGroups.Count == 0) + { + MessageBox.Show(Configuration.Settings.Language.MultipleReplace.NothingToImport); + return; + } + + using (var form = new MultipleReplaceExportImport(importGroups, false)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + var oldGroupsSelectedIndex = listViewGroups.SelectedIndices.Count == 0 ? -1 : listViewGroups.SelectedIndices[0]; + foreach (var importGroup in importGroups.Where(g => form.ChosenGroups.Contains(g.Name))) + { + importGroup.Name = FixDuplicateName(importGroup.Name, Configuration.Settings.MultipleSearchAndReplaceGroups); + Configuration.Settings.MultipleSearchAndReplaceGroups.Add(importGroup); + } + UpdateViewFromModel(Configuration.Settings.MultipleSearchAndReplaceGroups, _currentGroup); + if (oldGroupsSelectedIndex == -1 && listViewGroups.Items.Count > 0) + { + listViewGroups.Items[0].Selected = true; + } + } + } + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + return; + } + GeneratePreview(); + } + } + + private static string FixDuplicateName(string newGroupName, List existinGroups) + { + if (existinGroups.All(p => p.Name != newGroupName)) + { + return newGroupName; + } + + for (int i = 1; i < int.MaxValue; i++) + { + var name = $"{newGroupName}_{i}"; + if (existinGroups.All(p => p.Name != name)) + { + return name; + } + } + + return Guid.NewGuid().ToString(); + } + + private void buttonImportGroups_Click(object sender, EventArgs e) + { + importToolStripMenuItem_Click(sender, e); + } + + private void buttonExportGroups_Click(object sender, EventArgs e) + { + exportToolStripMenuItem_Click(sender, e); + } + + private void listViewFixes_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control) + { + listViewFixes.SelectAll(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.D && e.Modifiers == Keys.Control) + { + listViewFixes.SelectFirstSelectedItemOnly(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.I && e.Modifiers == (Keys.Control | Keys.Shift)) //InverseSelection + { + listViewFixes.InverseSelection(); + e.SuppressKeyPress = true; + } + } + + } +} diff --git a/src/Forms/MultipleReplace.resx b/src/ui/Forms/MultipleReplace.resx similarity index 98% rename from src/Forms/MultipleReplace.resx rename to src/ui/Forms/MultipleReplace.resx index c96da9ab6..8ac43125e 100644 --- a/src/Forms/MultipleReplace.resx +++ b/src/ui/Forms/MultipleReplace.resx @@ -1,132 +1,132 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 448, 17 - - - 172, 17 - - - 312, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 448, 17 + + + 172, 17 + + + 312, 17 + \ No newline at end of file diff --git a/src/Forms/MultipleReplaceExportImport.Designer.cs b/src/ui/Forms/MultipleReplaceExportImport.Designer.cs similarity index 100% rename from src/Forms/MultipleReplaceExportImport.Designer.cs rename to src/ui/Forms/MultipleReplaceExportImport.Designer.cs diff --git a/src/Forms/MultipleReplaceExportImport.cs b/src/ui/Forms/MultipleReplaceExportImport.cs similarity index 100% rename from src/Forms/MultipleReplaceExportImport.cs rename to src/ui/Forms/MultipleReplaceExportImport.cs diff --git a/src/Forms/MultipleReplaceExportImport.resx b/src/ui/Forms/MultipleReplaceExportImport.resx similarity index 100% rename from src/Forms/MultipleReplaceExportImport.resx rename to src/ui/Forms/MultipleReplaceExportImport.resx diff --git a/src/Forms/MultipleReplaceNewGroup.Designer.cs b/src/ui/Forms/MultipleReplaceNewGroup.Designer.cs similarity index 100% rename from src/Forms/MultipleReplaceNewGroup.Designer.cs rename to src/ui/Forms/MultipleReplaceNewGroup.Designer.cs diff --git a/src/Forms/MultipleReplaceNewGroup.cs b/src/ui/Forms/MultipleReplaceNewGroup.cs similarity index 100% rename from src/Forms/MultipleReplaceNewGroup.cs rename to src/ui/Forms/MultipleReplaceNewGroup.cs diff --git a/src/Forms/RubyJapanese.resx b/src/ui/Forms/MultipleReplaceNewGroup.resx similarity index 100% rename from src/Forms/RubyJapanese.resx rename to src/ui/Forms/MultipleReplaceNewGroup.resx diff --git a/src/Forms/NetflixFixErrors.Designer.cs b/src/ui/Forms/NetflixFixErrors.Designer.cs similarity index 100% rename from src/Forms/NetflixFixErrors.Designer.cs rename to src/ui/Forms/NetflixFixErrors.Designer.cs diff --git a/src/Forms/NetflixFixErrors.cs b/src/ui/Forms/NetflixFixErrors.cs similarity index 100% rename from src/Forms/NetflixFixErrors.cs rename to src/ui/Forms/NetflixFixErrors.cs diff --git a/src/Forms/SetVideoOffset.resx b/src/ui/Forms/NetflixFixErrors.resx similarity index 100% rename from src/Forms/SetVideoOffset.resx rename to src/ui/Forms/NetflixFixErrors.resx diff --git a/src/Forms/Networking/NetworkChat.Designer.cs b/src/ui/Forms/Networking/NetworkChat.Designer.cs similarity index 100% rename from src/Forms/Networking/NetworkChat.Designer.cs rename to src/ui/Forms/Networking/NetworkChat.Designer.cs diff --git a/src/Forms/Networking/NetworkChat.cs b/src/ui/Forms/Networking/NetworkChat.cs similarity index 100% rename from src/Forms/Networking/NetworkChat.cs rename to src/ui/Forms/Networking/NetworkChat.cs diff --git a/src/Forms/Networking/NetworkChat.resx b/src/ui/Forms/Networking/NetworkChat.resx similarity index 100% rename from src/Forms/Networking/NetworkChat.resx rename to src/ui/Forms/Networking/NetworkChat.resx diff --git a/src/Forms/Networking/NetworkJoin.Designer.cs b/src/ui/Forms/Networking/NetworkJoin.Designer.cs similarity index 100% rename from src/Forms/Networking/NetworkJoin.Designer.cs rename to src/ui/Forms/Networking/NetworkJoin.Designer.cs diff --git a/src/Forms/Networking/NetworkJoin.cs b/src/ui/Forms/Networking/NetworkJoin.cs similarity index 100% rename from src/Forms/Networking/NetworkJoin.cs rename to src/ui/Forms/Networking/NetworkJoin.cs diff --git a/src/Forms/SettingsFixContinuationStyle.resx b/src/ui/Forms/Networking/NetworkJoin.resx similarity index 100% rename from src/Forms/SettingsFixContinuationStyle.resx rename to src/ui/Forms/Networking/NetworkJoin.resx diff --git a/src/Forms/Networking/NetworkLogAndInfo.Designer.cs b/src/ui/Forms/Networking/NetworkLogAndInfo.Designer.cs similarity index 100% rename from src/Forms/Networking/NetworkLogAndInfo.Designer.cs rename to src/ui/Forms/Networking/NetworkLogAndInfo.Designer.cs diff --git a/src/Forms/Networking/NetworkLogAndInfo.cs b/src/ui/Forms/Networking/NetworkLogAndInfo.cs similarity index 100% rename from src/Forms/Networking/NetworkLogAndInfo.cs rename to src/ui/Forms/Networking/NetworkLogAndInfo.cs diff --git a/src/Forms/SettingsGapChoose.resx b/src/ui/Forms/Networking/NetworkLogAndInfo.resx similarity index 100% rename from src/Forms/SettingsGapChoose.resx rename to src/ui/Forms/Networking/NetworkLogAndInfo.resx diff --git a/src/Forms/Networking/NetworkStart.Designer.cs b/src/ui/Forms/Networking/NetworkStart.Designer.cs similarity index 100% rename from src/Forms/Networking/NetworkStart.Designer.cs rename to src/ui/Forms/Networking/NetworkStart.Designer.cs diff --git a/src/Forms/Networking/NetworkStart.cs b/src/ui/Forms/Networking/NetworkStart.cs similarity index 100% rename from src/Forms/Networking/NetworkStart.cs rename to src/ui/Forms/Networking/NetworkStart.cs diff --git a/src/Forms/SettingsLineWidth.resx b/src/ui/Forms/Networking/NetworkStart.resx similarity index 100% rename from src/Forms/SettingsLineWidth.resx rename to src/ui/Forms/Networking/NetworkStart.resx diff --git a/src/Forms/NuendoProperties.Designer.cs b/src/ui/Forms/NuendoProperties.Designer.cs similarity index 97% rename from src/Forms/NuendoProperties.Designer.cs rename to src/ui/Forms/NuendoProperties.Designer.cs index abc26ac12..6b5bc04fd 100644 --- a/src/Forms/NuendoProperties.Designer.cs +++ b/src/ui/Forms/NuendoProperties.Designer.cs @@ -1,138 +1,138 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class NuendoProperties - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.labelCharacterList = new System.Windows.Forms.Label(); - this.textBoxCharacterFile = new System.Windows.Forms.TextBox(); - this.buttonChooseCharacterFile = new System.Windows.Forms.Button(); - this.labelStatus = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(218, 109); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(299, 109); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // labelCharacterList - // - this.labelCharacterList.AutoSize = true; - this.labelCharacterList.Location = new System.Drawing.Point(13, 25); - this.labelCharacterList.Name = "labelCharacterList"; - this.labelCharacterList.Size = new System.Drawing.Size(104, 13); - this.labelCharacterList.TabIndex = 5; - this.labelCharacterList.Text = "Character list csv file"; - // - // textBoxCharacterFile - // - this.textBoxCharacterFile.Location = new System.Drawing.Point(13, 42); - this.textBoxCharacterFile.Name = "textBoxCharacterFile"; - this.textBoxCharacterFile.Size = new System.Drawing.Size(330, 20); - this.textBoxCharacterFile.TabIndex = 6; - // - // buttonChooseCharacterFile - // - this.buttonChooseCharacterFile.Location = new System.Drawing.Point(349, 42); - this.buttonChooseCharacterFile.Name = "buttonChooseCharacterFile"; - this.buttonChooseCharacterFile.Size = new System.Drawing.Size(24, 21); - this.buttonChooseCharacterFile.TabIndex = 7; - this.buttonChooseCharacterFile.Text = "..."; - this.buttonChooseCharacterFile.UseVisualStyleBackColor = true; - this.buttonChooseCharacterFile.Click += new System.EventHandler(this.ButtonChooseCharacter_Click); - // - // labelStatus - // - this.labelStatus.AutoSize = true; - this.labelStatus.Location = new System.Drawing.Point(13, 65); - this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(59, 13); - this.labelStatus.TabIndex = 8; - this.labelStatus.Text = "labelStatus"; - // - // NuendoProperties - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(386, 142); - this.Controls.Add(this.labelStatus); - this.Controls.Add(this.buttonChooseCharacterFile); - this.Controls.Add(this.textBoxCharacterFile); - this.Controls.Add(this.labelCharacterList); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "NuendoProperties"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Nuendo properties"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Csv2Properties_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Label labelCharacterList; - private System.Windows.Forms.TextBox textBoxCharacterFile; - private System.Windows.Forms.Button buttonChooseCharacterFile; - private System.Windows.Forms.Label labelStatus; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class NuendoProperties + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.labelCharacterList = new System.Windows.Forms.Label(); + this.textBoxCharacterFile = new System.Windows.Forms.TextBox(); + this.buttonChooseCharacterFile = new System.Windows.Forms.Button(); + this.labelStatus = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(218, 109); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(299, 109); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // labelCharacterList + // + this.labelCharacterList.AutoSize = true; + this.labelCharacterList.Location = new System.Drawing.Point(13, 25); + this.labelCharacterList.Name = "labelCharacterList"; + this.labelCharacterList.Size = new System.Drawing.Size(104, 13); + this.labelCharacterList.TabIndex = 5; + this.labelCharacterList.Text = "Character list csv file"; + // + // textBoxCharacterFile + // + this.textBoxCharacterFile.Location = new System.Drawing.Point(13, 42); + this.textBoxCharacterFile.Name = "textBoxCharacterFile"; + this.textBoxCharacterFile.Size = new System.Drawing.Size(330, 20); + this.textBoxCharacterFile.TabIndex = 6; + // + // buttonChooseCharacterFile + // + this.buttonChooseCharacterFile.Location = new System.Drawing.Point(349, 42); + this.buttonChooseCharacterFile.Name = "buttonChooseCharacterFile"; + this.buttonChooseCharacterFile.Size = new System.Drawing.Size(24, 21); + this.buttonChooseCharacterFile.TabIndex = 7; + this.buttonChooseCharacterFile.Text = "..."; + this.buttonChooseCharacterFile.UseVisualStyleBackColor = true; + this.buttonChooseCharacterFile.Click += new System.EventHandler(this.ButtonChooseCharacter_Click); + // + // labelStatus + // + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(13, 65); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(59, 13); + this.labelStatus.TabIndex = 8; + this.labelStatus.Text = "labelStatus"; + // + // NuendoProperties + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(386, 142); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.buttonChooseCharacterFile); + this.Controls.Add(this.textBoxCharacterFile); + this.Controls.Add(this.labelCharacterList); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "NuendoProperties"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Nuendo properties"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Csv2Properties_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Label labelCharacterList; + private System.Windows.Forms.TextBox textBoxCharacterFile; + private System.Windows.Forms.Button buttonChooseCharacterFile; + private System.Windows.Forms.Label labelStatus; + } } \ No newline at end of file diff --git a/src/Forms/NuendoProperties.cs b/src/ui/Forms/NuendoProperties.cs similarity index 97% rename from src/Forms/NuendoProperties.cs rename to src/ui/Forms/NuendoProperties.cs index cd404b561..9c574d39c 100644 --- a/src/Forms/NuendoProperties.cs +++ b/src/ui/Forms/NuendoProperties.cs @@ -1,99 +1,99 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class NuendoProperties : PositionAndSizeForm - { - public string CharacterListFile { get; set; } - - public NuendoProperties() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - labelStatus.Text = string.Empty; - textBoxCharacterFile.Text = Configuration.Settings.SubtitleSettings.NuendoCharacterListFile; - } - - private void ButtonChooseCharacter_Click(object sender, EventArgs e) - { - openFileDialog1.Filter = "Csv files|*.csv"; - openFileDialog1.FileName = string.Empty; - if (openFileDialog1.ShowDialog(this) == DialogResult.OK) - { - textBoxCharacterFile.Text = openFileDialog1.FileName; - - int count = LoadCharacters(openFileDialog1.FileName).Count; - if (count == 0) - { - labelStatus.Text = "No characters found!"; - } - else - { - labelStatus.Text = $"{count} characters found"; - } - } - } - - private void Csv2Properties_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void buttonOK_Click(object sender, EventArgs e) - { - CharacterListFile = textBoxCharacterFile.Text; - DialogResult = DialogResult.OK; - } - - public static List LoadCharacters(string fileName) - { - int lineNumber = 0; - var separator = new[] { ';' }; - List characters = new List(); - foreach (string line in System.IO.File.ReadAllLines(fileName)) - { - string[] parts = line.Split(separator, StringSplitOptions.RemoveEmptyEntries); - if (parts.Length > 0) - { - try - { - string text = Utilities.FixQuotes(parts[0]); - if (!string.IsNullOrWhiteSpace(text) && !characters.Contains(text)) - { - if (parts.Length > 1) - { - text += " [" + Utilities.FixQuotes(parts[1]) + "]"; - } - - if (lineNumber != 0 || (!text.StartsWith("character [", StringComparison.OrdinalIgnoreCase) && !text.Equals("character", StringComparison.OrdinalIgnoreCase))) - { - characters.Add(text); - } - } - } - catch - { - // ignored - } - } - lineNumber++; - } - return characters; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class NuendoProperties : PositionAndSizeForm + { + public string CharacterListFile { get; set; } + + public NuendoProperties() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + labelStatus.Text = string.Empty; + textBoxCharacterFile.Text = Configuration.Settings.SubtitleSettings.NuendoCharacterListFile; + } + + private void ButtonChooseCharacter_Click(object sender, EventArgs e) + { + openFileDialog1.Filter = "Csv files|*.csv"; + openFileDialog1.FileName = string.Empty; + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) + { + textBoxCharacterFile.Text = openFileDialog1.FileName; + + int count = LoadCharacters(openFileDialog1.FileName).Count; + if (count == 0) + { + labelStatus.Text = "No characters found!"; + } + else + { + labelStatus.Text = $"{count} characters found"; + } + } + } + + private void Csv2Properties_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void buttonOK_Click(object sender, EventArgs e) + { + CharacterListFile = textBoxCharacterFile.Text; + DialogResult = DialogResult.OK; + } + + public static List LoadCharacters(string fileName) + { + int lineNumber = 0; + var separator = new[] { ';' }; + List characters = new List(); + foreach (string line in System.IO.File.ReadAllLines(fileName)) + { + string[] parts = line.Split(separator, StringSplitOptions.RemoveEmptyEntries); + if (parts.Length > 0) + { + try + { + string text = Utilities.FixQuotes(parts[0]); + if (!string.IsNullOrWhiteSpace(text) && !characters.Contains(text)) + { + if (parts.Length > 1) + { + text += " [" + Utilities.FixQuotes(parts[1]) + "]"; + } + + if (lineNumber != 0 || (!text.StartsWith("character [", StringComparison.OrdinalIgnoreCase) && !text.Equals("character", StringComparison.OrdinalIgnoreCase))) + { + characters.Add(text); + } + } + } + catch + { + // ignored + } + } + lineNumber++; + } + return characters; + } + + } +} diff --git a/src/Forms/NuendoProperties.resx b/src/ui/Forms/NuendoProperties.resx similarity index 97% rename from src/Forms/NuendoProperties.resx rename to src/ui/Forms/NuendoProperties.resx index 3a7d67153..9bad2f599 100644 --- a/src/Forms/NuendoProperties.resx +++ b/src/ui/Forms/NuendoProperties.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/Ocr/AddBeterMultiMatch.Designer.cs b/src/ui/Forms/Ocr/AddBeterMultiMatch.Designer.cs similarity index 100% rename from src/Forms/Ocr/AddBeterMultiMatch.Designer.cs rename to src/ui/Forms/Ocr/AddBeterMultiMatch.Designer.cs diff --git a/src/Forms/Ocr/AddBeterMultiMatch.cs b/src/ui/Forms/Ocr/AddBeterMultiMatch.cs similarity index 100% rename from src/Forms/Ocr/AddBeterMultiMatch.cs rename to src/ui/Forms/Ocr/AddBeterMultiMatch.cs diff --git a/src/Forms/TextPrompt.resx b/src/ui/Forms/Ocr/AddBeterMultiMatch.resx similarity index 100% rename from src/Forms/TextPrompt.resx rename to src/ui/Forms/Ocr/AddBeterMultiMatch.resx diff --git a/src/Forms/Ocr/AddBetterMultiMatchNOcr.Designer.cs b/src/ui/Forms/Ocr/AddBetterMultiMatchNOcr.Designer.cs similarity index 100% rename from src/Forms/Ocr/AddBetterMultiMatchNOcr.Designer.cs rename to src/ui/Forms/Ocr/AddBetterMultiMatchNOcr.Designer.cs diff --git a/src/Forms/Ocr/AddBetterMultiMatchNOcr.cs b/src/ui/Forms/Ocr/AddBetterMultiMatchNOcr.cs similarity index 100% rename from src/Forms/Ocr/AddBetterMultiMatchNOcr.cs rename to src/ui/Forms/Ocr/AddBetterMultiMatchNOcr.cs diff --git a/src/Forms/TimedTextNewLanguage.resx b/src/ui/Forms/Ocr/AddBetterMultiMatchNOcr.resx similarity index 100% rename from src/Forms/TimedTextNewLanguage.resx rename to src/ui/Forms/Ocr/AddBetterMultiMatchNOcr.resx diff --git a/src/Forms/Ocr/AddToOcrReplaceList.Designer.cs b/src/ui/Forms/Ocr/AddToOcrReplaceList.Designer.cs similarity index 100% rename from src/Forms/Ocr/AddToOcrReplaceList.Designer.cs rename to src/ui/Forms/Ocr/AddToOcrReplaceList.Designer.cs diff --git a/src/Forms/Ocr/AddToOcrReplaceList.cs b/src/ui/Forms/Ocr/AddToOcrReplaceList.cs similarity index 100% rename from src/Forms/Ocr/AddToOcrReplaceList.cs rename to src/ui/Forms/Ocr/AddToOcrReplaceList.cs diff --git a/src/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.resx b/src/ui/Forms/Ocr/AddToOcrReplaceList.resx similarity index 100% rename from src/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.resx rename to src/ui/Forms/Ocr/AddToOcrReplaceList.resx diff --git a/src/Forms/Ocr/BinaryOcrChooseEditDb.Designer.cs b/src/ui/Forms/Ocr/BinaryOcrChooseEditDb.Designer.cs similarity index 100% rename from src/Forms/Ocr/BinaryOcrChooseEditDb.Designer.cs rename to src/ui/Forms/Ocr/BinaryOcrChooseEditDb.Designer.cs diff --git a/src/Forms/Ocr/BinaryOcrChooseEditDb.cs b/src/ui/Forms/Ocr/BinaryOcrChooseEditDb.cs similarity index 100% rename from src/Forms/Ocr/BinaryOcrChooseEditDb.cs rename to src/ui/Forms/Ocr/BinaryOcrChooseEditDb.cs diff --git a/src/Forms/AddToNames.resx b/src/ui/Forms/Ocr/BinaryOcrChooseEditDb.resx similarity index 97% rename from src/Forms/AddToNames.resx rename to src/ui/Forms/Ocr/BinaryOcrChooseEditDb.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/AddToNames.resx +++ b/src/ui/Forms/Ocr/BinaryOcrChooseEditDb.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/Ocr/BinaryOcrTrain.Designer.cs b/src/ui/Forms/Ocr/BinaryOcrTrain.Designer.cs similarity index 100% rename from src/Forms/Ocr/BinaryOcrTrain.Designer.cs rename to src/ui/Forms/Ocr/BinaryOcrTrain.Designer.cs diff --git a/src/Forms/Ocr/BinaryOcrTrain.cs b/src/ui/Forms/Ocr/BinaryOcrTrain.cs similarity index 100% rename from src/Forms/Ocr/BinaryOcrTrain.cs rename to src/ui/Forms/Ocr/BinaryOcrTrain.cs diff --git a/src/Forms/Ocr/BinaryOcrTrain.resx b/src/ui/Forms/Ocr/BinaryOcrTrain.resx similarity index 100% rename from src/Forms/Ocr/BinaryOcrTrain.resx rename to src/ui/Forms/Ocr/BinaryOcrTrain.resx diff --git a/src/Forms/Ocr/DownloadTesseract302.Designer.cs b/src/ui/Forms/Ocr/DownloadTesseract302.Designer.cs similarity index 100% rename from src/Forms/Ocr/DownloadTesseract302.Designer.cs rename to src/ui/Forms/Ocr/DownloadTesseract302.Designer.cs diff --git a/src/Forms/Ocr/DownloadTesseract302.cs b/src/ui/Forms/Ocr/DownloadTesseract302.cs similarity index 100% rename from src/Forms/Ocr/DownloadTesseract302.cs rename to src/ui/Forms/Ocr/DownloadTesseract302.cs diff --git a/src/Forms/AddToUserDic.resx b/src/ui/Forms/Ocr/DownloadTesseract302.resx similarity index 97% rename from src/Forms/AddToUserDic.resx rename to src/ui/Forms/Ocr/DownloadTesseract302.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/AddToUserDic.resx +++ b/src/ui/Forms/Ocr/DownloadTesseract302.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/Ocr/DownloadTesseract4.Designer.cs b/src/ui/Forms/Ocr/DownloadTesseract4.Designer.cs similarity index 100% rename from src/Forms/Ocr/DownloadTesseract4.Designer.cs rename to src/ui/Forms/Ocr/DownloadTesseract4.Designer.cs diff --git a/src/Forms/Ocr/DownloadTesseract4.cs b/src/ui/Forms/Ocr/DownloadTesseract4.cs similarity index 100% rename from src/Forms/Ocr/DownloadTesseract4.cs rename to src/ui/Forms/Ocr/DownloadTesseract4.cs diff --git a/src/Forms/AlignmentPicker.resx b/src/ui/Forms/Ocr/DownloadTesseract4.resx similarity index 97% rename from src/Forms/AlignmentPicker.resx rename to src/ui/Forms/Ocr/DownloadTesseract4.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/AlignmentPicker.resx +++ b/src/ui/Forms/Ocr/DownloadTesseract4.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/Ocr/GetTesseract302Dictionaries.Designer.cs b/src/ui/Forms/Ocr/GetTesseract302Dictionaries.Designer.cs similarity index 100% rename from src/Forms/Ocr/GetTesseract302Dictionaries.Designer.cs rename to src/ui/Forms/Ocr/GetTesseract302Dictionaries.Designer.cs diff --git a/src/Forms/Ocr/GetTesseract302Dictionaries.cs b/src/ui/Forms/Ocr/GetTesseract302Dictionaries.cs similarity index 100% rename from src/Forms/Ocr/GetTesseract302Dictionaries.cs rename to src/ui/Forms/Ocr/GetTesseract302Dictionaries.cs diff --git a/src/Forms/ChangeSpeedInPercent.resx b/src/ui/Forms/Ocr/GetTesseract302Dictionaries.resx similarity index 97% rename from src/Forms/ChangeSpeedInPercent.resx rename to src/ui/Forms/Ocr/GetTesseract302Dictionaries.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/ChangeSpeedInPercent.resx +++ b/src/ui/Forms/Ocr/GetTesseract302Dictionaries.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/Ocr/GetTesseractDictionaries.Designer.cs b/src/ui/Forms/Ocr/GetTesseractDictionaries.Designer.cs similarity index 100% rename from src/Forms/Ocr/GetTesseractDictionaries.Designer.cs rename to src/ui/Forms/Ocr/GetTesseractDictionaries.Designer.cs diff --git a/src/Forms/Ocr/GetTesseractDictionaries.cs b/src/ui/Forms/Ocr/GetTesseractDictionaries.cs similarity index 100% rename from src/Forms/Ocr/GetTesseractDictionaries.cs rename to src/ui/Forms/Ocr/GetTesseractDictionaries.cs diff --git a/src/ui/Forms/Ocr/GetTesseractDictionaries.resx b/src/ui/Forms/Ocr/GetTesseractDictionaries.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/src/ui/Forms/Ocr/GetTesseractDictionaries.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Forms/Ocr/OCRSpellCheck.Designer.cs b/src/ui/Forms/Ocr/OCRSpellCheck.Designer.cs similarity index 100% rename from src/Forms/Ocr/OCRSpellCheck.Designer.cs rename to src/ui/Forms/Ocr/OCRSpellCheck.Designer.cs diff --git a/src/Forms/Ocr/OCRSpellCheck.cs b/src/ui/Forms/Ocr/OCRSpellCheck.cs similarity index 100% rename from src/Forms/Ocr/OCRSpellCheck.cs rename to src/ui/Forms/Ocr/OCRSpellCheck.cs diff --git a/src/Forms/AutoBreakUnbreakLines.resx b/src/ui/Forms/Ocr/OCRSpellCheck.resx similarity index 97% rename from src/Forms/AutoBreakUnbreakLines.resx rename to src/ui/Forms/Ocr/OCRSpellCheck.resx index 98381cccc..15f75b3cd 100644 --- a/src/Forms/AutoBreakUnbreakLines.resx +++ b/src/ui/Forms/Ocr/OCRSpellCheck.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/Ocr/OcrPreprocessingSettings.Designer.cs b/src/ui/Forms/Ocr/OcrPreprocessingSettings.Designer.cs similarity index 100% rename from src/Forms/Ocr/OcrPreprocessingSettings.Designer.cs rename to src/ui/Forms/Ocr/OcrPreprocessingSettings.Designer.cs diff --git a/src/Forms/Ocr/OcrPreprocessingSettings.cs b/src/ui/Forms/Ocr/OcrPreprocessingSettings.cs similarity index 100% rename from src/Forms/Ocr/OcrPreprocessingSettings.cs rename to src/ui/Forms/Ocr/OcrPreprocessingSettings.cs diff --git a/src/Forms/Ocr/OcrPreprocessingSettings.resx b/src/ui/Forms/Ocr/OcrPreprocessingSettings.resx similarity index 100% rename from src/Forms/Ocr/OcrPreprocessingSettings.resx rename to src/ui/Forms/Ocr/OcrPreprocessingSettings.resx diff --git a/src/Forms/Ocr/OcrPreprocessingT4.Designer.cs b/src/ui/Forms/Ocr/OcrPreprocessingT4.Designer.cs similarity index 100% rename from src/Forms/Ocr/OcrPreprocessingT4.Designer.cs rename to src/ui/Forms/Ocr/OcrPreprocessingT4.Designer.cs diff --git a/src/Forms/Ocr/OcrPreprocessingT4.cs b/src/ui/Forms/Ocr/OcrPreprocessingT4.cs similarity index 100% rename from src/Forms/Ocr/OcrPreprocessingT4.cs rename to src/ui/Forms/Ocr/OcrPreprocessingT4.cs diff --git a/src/Forms/Ocr/OcrPreprocessingT4.resx b/src/ui/Forms/Ocr/OcrPreprocessingT4.resx similarity index 100% rename from src/Forms/Ocr/OcrPreprocessingT4.resx rename to src/ui/Forms/Ocr/OcrPreprocessingT4.resx diff --git a/src/Forms/Ocr/VobSubCharactersImport.Designer.cs b/src/ui/Forms/Ocr/VobSubCharactersImport.Designer.cs similarity index 100% rename from src/Forms/Ocr/VobSubCharactersImport.Designer.cs rename to src/ui/Forms/Ocr/VobSubCharactersImport.Designer.cs diff --git a/src/Forms/Ocr/VobSubCharactersImport.cs b/src/ui/Forms/Ocr/VobSubCharactersImport.cs similarity index 100% rename from src/Forms/Ocr/VobSubCharactersImport.cs rename to src/ui/Forms/Ocr/VobSubCharactersImport.cs diff --git a/src/Forms/Ocr/VobSubCharactersImport.resx b/src/ui/Forms/Ocr/VobSubCharactersImport.resx similarity index 100% rename from src/Forms/Ocr/VobSubCharactersImport.resx rename to src/ui/Forms/Ocr/VobSubCharactersImport.resx diff --git a/src/Forms/Ocr/VobSubEditCharacters.Designer.cs b/src/ui/Forms/Ocr/VobSubEditCharacters.Designer.cs similarity index 100% rename from src/Forms/Ocr/VobSubEditCharacters.Designer.cs rename to src/ui/Forms/Ocr/VobSubEditCharacters.Designer.cs diff --git a/src/Forms/Ocr/VobSubEditCharacters.cs b/src/ui/Forms/Ocr/VobSubEditCharacters.cs similarity index 100% rename from src/Forms/Ocr/VobSubEditCharacters.cs rename to src/ui/Forms/Ocr/VobSubEditCharacters.cs diff --git a/src/Forms/Ocr/VobSubEditCharacters.resx b/src/ui/Forms/Ocr/VobSubEditCharacters.resx similarity index 100% rename from src/Forms/Ocr/VobSubEditCharacters.resx rename to src/ui/Forms/Ocr/VobSubEditCharacters.resx diff --git a/src/Forms/Ocr/VobSubNOcrCharacterInspect.Designer.cs b/src/ui/Forms/Ocr/VobSubNOcrCharacterInspect.Designer.cs similarity index 100% rename from src/Forms/Ocr/VobSubNOcrCharacterInspect.Designer.cs rename to src/ui/Forms/Ocr/VobSubNOcrCharacterInspect.Designer.cs diff --git a/src/Forms/Ocr/VobSubNOcrCharacterInspect.cs b/src/ui/Forms/Ocr/VobSubNOcrCharacterInspect.cs similarity index 100% rename from src/Forms/Ocr/VobSubNOcrCharacterInspect.cs rename to src/ui/Forms/Ocr/VobSubNOcrCharacterInspect.cs diff --git a/src/Forms/Ocr/VobSubNOcrCharacterInspect.resx b/src/ui/Forms/Ocr/VobSubNOcrCharacterInspect.resx similarity index 100% rename from src/Forms/Ocr/VobSubNOcrCharacterInspect.resx rename to src/ui/Forms/Ocr/VobSubNOcrCharacterInspect.resx diff --git a/src/Forms/Ocr/VobSubNOcrEdit.Designer.cs b/src/ui/Forms/Ocr/VobSubNOcrEdit.Designer.cs similarity index 100% rename from src/Forms/Ocr/VobSubNOcrEdit.Designer.cs rename to src/ui/Forms/Ocr/VobSubNOcrEdit.Designer.cs diff --git a/src/Forms/Ocr/VobSubNOcrEdit.cs b/src/ui/Forms/Ocr/VobSubNOcrEdit.cs similarity index 100% rename from src/Forms/Ocr/VobSubNOcrEdit.cs rename to src/ui/Forms/Ocr/VobSubNOcrEdit.cs diff --git a/src/Forms/Ocr/VobSubNOcrEdit.resx b/src/ui/Forms/Ocr/VobSubNOcrEdit.resx similarity index 100% rename from src/Forms/Ocr/VobSubNOcrEdit.resx rename to src/ui/Forms/Ocr/VobSubNOcrEdit.resx diff --git a/src/Forms/Ocr/VobSubNOcrTrain.Designer.cs b/src/ui/Forms/Ocr/VobSubNOcrTrain.Designer.cs similarity index 100% rename from src/Forms/Ocr/VobSubNOcrTrain.Designer.cs rename to src/ui/Forms/Ocr/VobSubNOcrTrain.Designer.cs diff --git a/src/Forms/Ocr/VobSubNOcrTrain.cs b/src/ui/Forms/Ocr/VobSubNOcrTrain.cs similarity index 100% rename from src/Forms/Ocr/VobSubNOcrTrain.cs rename to src/ui/Forms/Ocr/VobSubNOcrTrain.cs diff --git a/src/Forms/Ocr/VobSubNOcrTrain.resx b/src/ui/Forms/Ocr/VobSubNOcrTrain.resx similarity index 100% rename from src/Forms/Ocr/VobSubNOcrTrain.resx rename to src/ui/Forms/Ocr/VobSubNOcrTrain.resx diff --git a/src/Forms/Ocr/VobSubOcr.Designer.cs b/src/ui/Forms/Ocr/VobSubOcr.Designer.cs similarity index 100% rename from src/Forms/Ocr/VobSubOcr.Designer.cs rename to src/ui/Forms/Ocr/VobSubOcr.Designer.cs diff --git a/src/Forms/Ocr/VobSubOcr.cs b/src/ui/Forms/Ocr/VobSubOcr.cs similarity index 100% rename from src/Forms/Ocr/VobSubOcr.cs rename to src/ui/Forms/Ocr/VobSubOcr.cs diff --git a/src/Forms/Ocr/VobSubOcr.resx b/src/ui/Forms/Ocr/VobSubOcr.resx similarity index 100% rename from src/Forms/Ocr/VobSubOcr.resx rename to src/ui/Forms/Ocr/VobSubOcr.resx diff --git a/src/Forms/Ocr/VobSubOcrCharacter.Designer.cs b/src/ui/Forms/Ocr/VobSubOcrCharacter.Designer.cs similarity index 100% rename from src/Forms/Ocr/VobSubOcrCharacter.Designer.cs rename to src/ui/Forms/Ocr/VobSubOcrCharacter.Designer.cs diff --git a/src/Forms/Ocr/VobSubOcrCharacter.cs b/src/ui/Forms/Ocr/VobSubOcrCharacter.cs similarity index 100% rename from src/Forms/Ocr/VobSubOcrCharacter.cs rename to src/ui/Forms/Ocr/VobSubOcrCharacter.cs diff --git a/src/Forms/Ocr/VobSubOcrCharacter.resx b/src/ui/Forms/Ocr/VobSubOcrCharacter.resx similarity index 100% rename from src/Forms/Ocr/VobSubOcrCharacter.resx rename to src/ui/Forms/Ocr/VobSubOcrCharacter.resx diff --git a/src/Forms/Ocr/VobSubOcrCharacterInspect.Designer.cs b/src/ui/Forms/Ocr/VobSubOcrCharacterInspect.Designer.cs similarity index 100% rename from src/Forms/Ocr/VobSubOcrCharacterInspect.Designer.cs rename to src/ui/Forms/Ocr/VobSubOcrCharacterInspect.Designer.cs diff --git a/src/Forms/Ocr/VobSubOcrCharacterInspect.cs b/src/ui/Forms/Ocr/VobSubOcrCharacterInspect.cs similarity index 100% rename from src/Forms/Ocr/VobSubOcrCharacterInspect.cs rename to src/ui/Forms/Ocr/VobSubOcrCharacterInspect.cs diff --git a/src/Forms/Ocr/VobSubOcrCharacterInspect.resx b/src/ui/Forms/Ocr/VobSubOcrCharacterInspect.resx similarity index 100% rename from src/Forms/Ocr/VobSubOcrCharacterInspect.resx rename to src/ui/Forms/Ocr/VobSubOcrCharacterInspect.resx diff --git a/src/Forms/Ocr/VobSubOcrNOcrCharacter.Designer.cs b/src/ui/Forms/Ocr/VobSubOcrNOcrCharacter.Designer.cs similarity index 100% rename from src/Forms/Ocr/VobSubOcrNOcrCharacter.Designer.cs rename to src/ui/Forms/Ocr/VobSubOcrNOcrCharacter.Designer.cs diff --git a/src/Forms/Ocr/VobSubOcrNOcrCharacter.cs b/src/ui/Forms/Ocr/VobSubOcrNOcrCharacter.cs similarity index 100% rename from src/Forms/Ocr/VobSubOcrNOcrCharacter.cs rename to src/ui/Forms/Ocr/VobSubOcrNOcrCharacter.cs diff --git a/src/Forms/Ocr/VobSubOcrNOcrCharacter.resx b/src/ui/Forms/Ocr/VobSubOcrNOcrCharacter.resx similarity index 100% rename from src/Forms/Ocr/VobSubOcrNOcrCharacter.resx rename to src/ui/Forms/Ocr/VobSubOcrNOcrCharacter.resx diff --git a/src/Forms/Ocr/VobSubOcrNewFolder.Designer.cs b/src/ui/Forms/Ocr/VobSubOcrNewFolder.Designer.cs similarity index 100% rename from src/Forms/Ocr/VobSubOcrNewFolder.Designer.cs rename to src/ui/Forms/Ocr/VobSubOcrNewFolder.Designer.cs diff --git a/src/Forms/Ocr/VobSubOcrNewFolder.cs b/src/ui/Forms/Ocr/VobSubOcrNewFolder.cs similarity index 100% rename from src/Forms/Ocr/VobSubOcrNewFolder.cs rename to src/ui/Forms/Ocr/VobSubOcrNewFolder.cs diff --git a/src/Controls/TimeUpDown.resx b/src/ui/Forms/Ocr/VobSubOcrNewFolder.resx similarity index 97% rename from src/Controls/TimeUpDown.resx rename to src/ui/Forms/Ocr/VobSubOcrNewFolder.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Controls/TimeUpDown.resx +++ b/src/ui/Forms/Ocr/VobSubOcrNewFolder.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/Ocr/VobSubOcrSetItalicFactor.Designer.cs b/src/ui/Forms/Ocr/VobSubOcrSetItalicFactor.Designer.cs similarity index 100% rename from src/Forms/Ocr/VobSubOcrSetItalicFactor.Designer.cs rename to src/ui/Forms/Ocr/VobSubOcrSetItalicFactor.Designer.cs diff --git a/src/Forms/Ocr/VobSubOcrSetItalicFactor.cs b/src/ui/Forms/Ocr/VobSubOcrSetItalicFactor.cs similarity index 100% rename from src/Forms/Ocr/VobSubOcrSetItalicFactor.cs rename to src/ui/Forms/Ocr/VobSubOcrSetItalicFactor.cs diff --git a/src/Forms/Ocr/VobSubOcrSetItalicFactor.resx b/src/ui/Forms/Ocr/VobSubOcrSetItalicFactor.resx similarity index 100% rename from src/Forms/Ocr/VobSubOcrSetItalicFactor.resx rename to src/ui/Forms/Ocr/VobSubOcrSetItalicFactor.resx diff --git a/src/Forms/OpenVideoDvd.Designer.cs b/src/ui/Forms/OpenVideoDvd.Designer.cs similarity index 98% rename from src/Forms/OpenVideoDvd.Designer.cs rename to src/ui/Forms/OpenVideoDvd.Designer.cs index d7480697d..94ae13f21 100644 --- a/src/Forms/OpenVideoDvd.Designer.cs +++ b/src/ui/Forms/OpenVideoDvd.Designer.cs @@ -1,233 +1,233 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class OpenVideoDvd - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.PanelDrive = new System.Windows.Forms.Panel(); - this.comboBoxDrive = new System.Windows.Forms.ComboBox(); - this.labelChooseDrive = new System.Windows.Forms.Label(); - this.PanelFolder = new System.Windows.Forms.Panel(); - this.buttonChooseFolder = new System.Windows.Forms.Button(); - this.labelChooseFolder = new System.Windows.Forms.Label(); - this.textBoxFolder = new System.Windows.Forms.TextBox(); - this.radioButtonDisc = new System.Windows.Forms.RadioButton(); - this.radioButtonFolder = new System.Windows.Forms.RadioButton(); - this.groupBoxOpenDvdFrom = new System.Windows.Forms.GroupBox(); - this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); - this.PanelDrive.SuspendLayout(); - this.PanelFolder.SuspendLayout(); - this.groupBoxOpenDvdFrom.SuspendLayout(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(374, 133); - this.buttonCancel.Margin = new System.Windows.Forms.Padding(2); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(56, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(314, 133); - this.buttonOK.Margin = new System.Windows.Forms.Padding(2); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(56, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // PanelDrive - // - this.PanelDrive.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.PanelDrive.Controls.Add(this.comboBoxDrive); - this.PanelDrive.Controls.Add(this.labelChooseDrive); - this.PanelDrive.Location = new System.Drawing.Point(82, 31); - this.PanelDrive.Margin = new System.Windows.Forms.Padding(2); - this.PanelDrive.Name = "PanelDrive"; - this.PanelDrive.Size = new System.Drawing.Size(332, 81); - this.PanelDrive.TabIndex = 1; - // - // comboBoxDrive - // - this.comboBoxDrive.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxDrive.FormattingEnabled = true; - this.comboBoxDrive.Location = new System.Drawing.Point(5, 24); - this.comboBoxDrive.Margin = new System.Windows.Forms.Padding(2); - this.comboBoxDrive.Name = "comboBoxDrive"; - this.comboBoxDrive.Size = new System.Drawing.Size(288, 21); - this.comboBoxDrive.TabIndex = 1; - // - // labelChooseDrive - // - this.labelChooseDrive.AutoSize = true; - this.labelChooseDrive.Location = new System.Drawing.Point(3, 8); - this.labelChooseDrive.Name = "labelChooseDrive"; - this.labelChooseDrive.Size = new System.Drawing.Size(69, 13); - this.labelChooseDrive.TabIndex = 0; - this.labelChooseDrive.Text = "Choose drive"; - // - // PanelFolder - // - this.PanelFolder.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.PanelFolder.Controls.Add(this.buttonChooseFolder); - this.PanelFolder.Controls.Add(this.labelChooseFolder); - this.PanelFolder.Controls.Add(this.textBoxFolder); - this.PanelFolder.Location = new System.Drawing.Point(29, 76); - this.PanelFolder.Margin = new System.Windows.Forms.Padding(2); - this.PanelFolder.Name = "PanelFolder"; - this.PanelFolder.Size = new System.Drawing.Size(332, 81); - this.PanelFolder.TabIndex = 2; - // - // buttonChooseFolder - // - this.buttonChooseFolder.Location = new System.Drawing.Point(298, 23); - this.buttonChooseFolder.Name = "buttonChooseFolder"; - this.buttonChooseFolder.Size = new System.Drawing.Size(26, 23); - this.buttonChooseFolder.TabIndex = 2; - this.buttonChooseFolder.Text = "..."; - this.buttonChooseFolder.UseVisualStyleBackColor = true; - this.buttonChooseFolder.Click += new System.EventHandler(this.buttonChooseFolder_Click); - // - // labelChooseFolder - // - this.labelChooseFolder.AutoSize = true; - this.labelChooseFolder.Location = new System.Drawing.Point(3, 8); - this.labelChooseFolder.Name = "labelChooseFolder"; - this.labelChooseFolder.Size = new System.Drawing.Size(72, 13); - this.labelChooseFolder.TabIndex = 0; - this.labelChooseFolder.Text = "Choose folder"; - // - // textBoxFolder - // - this.textBoxFolder.Location = new System.Drawing.Point(5, 25); - this.textBoxFolder.Name = "textBoxFolder"; - this.textBoxFolder.Size = new System.Drawing.Size(288, 20); - this.textBoxFolder.TabIndex = 1; - // - // radioButtonDisc - // - this.radioButtonDisc.AutoSize = true; - this.radioButtonDisc.Checked = true; - this.radioButtonDisc.Location = new System.Drawing.Point(11, 31); - this.radioButtonDisc.Margin = new System.Windows.Forms.Padding(2); - this.radioButtonDisc.Name = "radioButtonDisc"; - this.radioButtonDisc.Size = new System.Drawing.Size(46, 17); - this.radioButtonDisc.TabIndex = 0; - this.radioButtonDisc.TabStop = true; - this.radioButtonDisc.Text = "Disc"; - this.radioButtonDisc.UseVisualStyleBackColor = true; - this.radioButtonDisc.CheckedChanged += new System.EventHandler(this.radioButtonDisc_CheckedChanged); - // - // radioButtonFolder - // - this.radioButtonFolder.AutoSize = true; - this.radioButtonFolder.Location = new System.Drawing.Point(11, 54); - this.radioButtonFolder.Margin = new System.Windows.Forms.Padding(2); - this.radioButtonFolder.Name = "radioButtonFolder"; - this.radioButtonFolder.Size = new System.Drawing.Size(54, 17); - this.radioButtonFolder.TabIndex = 1; - this.radioButtonFolder.Text = "Folder"; - this.radioButtonFolder.UseVisualStyleBackColor = true; - // - // groupBoxOpenDvdFrom - // - this.groupBoxOpenDvdFrom.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxOpenDvdFrom.Controls.Add(this.radioButtonDisc); - this.groupBoxOpenDvdFrom.Controls.Add(this.radioButtonFolder); - this.groupBoxOpenDvdFrom.Controls.Add(this.PanelFolder); - this.groupBoxOpenDvdFrom.Controls.Add(this.PanelDrive); - this.groupBoxOpenDvdFrom.Location = new System.Drawing.Point(9, 10); - this.groupBoxOpenDvdFrom.Margin = new System.Windows.Forms.Padding(2); - this.groupBoxOpenDvdFrom.Name = "groupBoxOpenDvdFrom"; - this.groupBoxOpenDvdFrom.Padding = new System.Windows.Forms.Padding(2); - this.groupBoxOpenDvdFrom.Size = new System.Drawing.Size(422, 118); - this.groupBoxOpenDvdFrom.TabIndex = 0; - this.groupBoxOpenDvdFrom.TabStop = false; - this.groupBoxOpenDvdFrom.Text = "Open DVD from..."; - // - // OpenVideoDvd - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(440, 160); - this.Controls.Add(this.groupBoxOpenDvdFrom); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.Margin = new System.Windows.Forms.Padding(2); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "OpenVideoDvd"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.Text = "OpenVideoDvd"; - this.Shown += new System.EventHandler(this.OpenVideoDvd_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OpenVideoDvd_KeyDown); - this.PanelDrive.ResumeLayout(false); - this.PanelDrive.PerformLayout(); - this.PanelFolder.ResumeLayout(false); - this.PanelFolder.PerformLayout(); - this.groupBoxOpenDvdFrom.ResumeLayout(false); - this.groupBoxOpenDvdFrom.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Panel PanelDrive; - private System.Windows.Forms.Panel PanelFolder; - private System.Windows.Forms.Label labelChooseDrive; - private System.Windows.Forms.Label labelChooseFolder; - private System.Windows.Forms.TextBox textBoxFolder; - private System.Windows.Forms.ComboBox comboBoxDrive; - private System.Windows.Forms.RadioButton radioButtonDisc; - private System.Windows.Forms.RadioButton radioButtonFolder; - private System.Windows.Forms.GroupBox groupBoxOpenDvdFrom; - private System.Windows.Forms.Button buttonChooseFolder; - private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class OpenVideoDvd + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.PanelDrive = new System.Windows.Forms.Panel(); + this.comboBoxDrive = new System.Windows.Forms.ComboBox(); + this.labelChooseDrive = new System.Windows.Forms.Label(); + this.PanelFolder = new System.Windows.Forms.Panel(); + this.buttonChooseFolder = new System.Windows.Forms.Button(); + this.labelChooseFolder = new System.Windows.Forms.Label(); + this.textBoxFolder = new System.Windows.Forms.TextBox(); + this.radioButtonDisc = new System.Windows.Forms.RadioButton(); + this.radioButtonFolder = new System.Windows.Forms.RadioButton(); + this.groupBoxOpenDvdFrom = new System.Windows.Forms.GroupBox(); + this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); + this.PanelDrive.SuspendLayout(); + this.PanelFolder.SuspendLayout(); + this.groupBoxOpenDvdFrom.SuspendLayout(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(374, 133); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(2); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(56, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(314, 133); + this.buttonOK.Margin = new System.Windows.Forms.Padding(2); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(56, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // PanelDrive + // + this.PanelDrive.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.PanelDrive.Controls.Add(this.comboBoxDrive); + this.PanelDrive.Controls.Add(this.labelChooseDrive); + this.PanelDrive.Location = new System.Drawing.Point(82, 31); + this.PanelDrive.Margin = new System.Windows.Forms.Padding(2); + this.PanelDrive.Name = "PanelDrive"; + this.PanelDrive.Size = new System.Drawing.Size(332, 81); + this.PanelDrive.TabIndex = 1; + // + // comboBoxDrive + // + this.comboBoxDrive.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxDrive.FormattingEnabled = true; + this.comboBoxDrive.Location = new System.Drawing.Point(5, 24); + this.comboBoxDrive.Margin = new System.Windows.Forms.Padding(2); + this.comboBoxDrive.Name = "comboBoxDrive"; + this.comboBoxDrive.Size = new System.Drawing.Size(288, 21); + this.comboBoxDrive.TabIndex = 1; + // + // labelChooseDrive + // + this.labelChooseDrive.AutoSize = true; + this.labelChooseDrive.Location = new System.Drawing.Point(3, 8); + this.labelChooseDrive.Name = "labelChooseDrive"; + this.labelChooseDrive.Size = new System.Drawing.Size(69, 13); + this.labelChooseDrive.TabIndex = 0; + this.labelChooseDrive.Text = "Choose drive"; + // + // PanelFolder + // + this.PanelFolder.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.PanelFolder.Controls.Add(this.buttonChooseFolder); + this.PanelFolder.Controls.Add(this.labelChooseFolder); + this.PanelFolder.Controls.Add(this.textBoxFolder); + this.PanelFolder.Location = new System.Drawing.Point(29, 76); + this.PanelFolder.Margin = new System.Windows.Forms.Padding(2); + this.PanelFolder.Name = "PanelFolder"; + this.PanelFolder.Size = new System.Drawing.Size(332, 81); + this.PanelFolder.TabIndex = 2; + // + // buttonChooseFolder + // + this.buttonChooseFolder.Location = new System.Drawing.Point(298, 23); + this.buttonChooseFolder.Name = "buttonChooseFolder"; + this.buttonChooseFolder.Size = new System.Drawing.Size(26, 23); + this.buttonChooseFolder.TabIndex = 2; + this.buttonChooseFolder.Text = "..."; + this.buttonChooseFolder.UseVisualStyleBackColor = true; + this.buttonChooseFolder.Click += new System.EventHandler(this.buttonChooseFolder_Click); + // + // labelChooseFolder + // + this.labelChooseFolder.AutoSize = true; + this.labelChooseFolder.Location = new System.Drawing.Point(3, 8); + this.labelChooseFolder.Name = "labelChooseFolder"; + this.labelChooseFolder.Size = new System.Drawing.Size(72, 13); + this.labelChooseFolder.TabIndex = 0; + this.labelChooseFolder.Text = "Choose folder"; + // + // textBoxFolder + // + this.textBoxFolder.Location = new System.Drawing.Point(5, 25); + this.textBoxFolder.Name = "textBoxFolder"; + this.textBoxFolder.Size = new System.Drawing.Size(288, 20); + this.textBoxFolder.TabIndex = 1; + // + // radioButtonDisc + // + this.radioButtonDisc.AutoSize = true; + this.radioButtonDisc.Checked = true; + this.radioButtonDisc.Location = new System.Drawing.Point(11, 31); + this.radioButtonDisc.Margin = new System.Windows.Forms.Padding(2); + this.radioButtonDisc.Name = "radioButtonDisc"; + this.radioButtonDisc.Size = new System.Drawing.Size(46, 17); + this.radioButtonDisc.TabIndex = 0; + this.radioButtonDisc.TabStop = true; + this.radioButtonDisc.Text = "Disc"; + this.radioButtonDisc.UseVisualStyleBackColor = true; + this.radioButtonDisc.CheckedChanged += new System.EventHandler(this.radioButtonDisc_CheckedChanged); + // + // radioButtonFolder + // + this.radioButtonFolder.AutoSize = true; + this.radioButtonFolder.Location = new System.Drawing.Point(11, 54); + this.radioButtonFolder.Margin = new System.Windows.Forms.Padding(2); + this.radioButtonFolder.Name = "radioButtonFolder"; + this.radioButtonFolder.Size = new System.Drawing.Size(54, 17); + this.radioButtonFolder.TabIndex = 1; + this.radioButtonFolder.Text = "Folder"; + this.radioButtonFolder.UseVisualStyleBackColor = true; + // + // groupBoxOpenDvdFrom + // + this.groupBoxOpenDvdFrom.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxOpenDvdFrom.Controls.Add(this.radioButtonDisc); + this.groupBoxOpenDvdFrom.Controls.Add(this.radioButtonFolder); + this.groupBoxOpenDvdFrom.Controls.Add(this.PanelFolder); + this.groupBoxOpenDvdFrom.Controls.Add(this.PanelDrive); + this.groupBoxOpenDvdFrom.Location = new System.Drawing.Point(9, 10); + this.groupBoxOpenDvdFrom.Margin = new System.Windows.Forms.Padding(2); + this.groupBoxOpenDvdFrom.Name = "groupBoxOpenDvdFrom"; + this.groupBoxOpenDvdFrom.Padding = new System.Windows.Forms.Padding(2); + this.groupBoxOpenDvdFrom.Size = new System.Drawing.Size(422, 118); + this.groupBoxOpenDvdFrom.TabIndex = 0; + this.groupBoxOpenDvdFrom.TabStop = false; + this.groupBoxOpenDvdFrom.Text = "Open DVD from..."; + // + // OpenVideoDvd + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(440, 160); + this.Controls.Add(this.groupBoxOpenDvdFrom); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.Margin = new System.Windows.Forms.Padding(2); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "OpenVideoDvd"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.Text = "OpenVideoDvd"; + this.Shown += new System.EventHandler(this.OpenVideoDvd_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OpenVideoDvd_KeyDown); + this.PanelDrive.ResumeLayout(false); + this.PanelDrive.PerformLayout(); + this.PanelFolder.ResumeLayout(false); + this.PanelFolder.PerformLayout(); + this.groupBoxOpenDvdFrom.ResumeLayout(false); + this.groupBoxOpenDvdFrom.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Panel PanelDrive; + private System.Windows.Forms.Panel PanelFolder; + private System.Windows.Forms.Label labelChooseDrive; + private System.Windows.Forms.Label labelChooseFolder; + private System.Windows.Forms.TextBox textBoxFolder; + private System.Windows.Forms.ComboBox comboBoxDrive; + private System.Windows.Forms.RadioButton radioButtonDisc; + private System.Windows.Forms.RadioButton radioButtonFolder; + private System.Windows.Forms.GroupBox groupBoxOpenDvdFrom; + private System.Windows.Forms.Button buttonChooseFolder; + private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; + } } \ No newline at end of file diff --git a/src/Forms/OpenVideoDvd.cs b/src/ui/Forms/OpenVideoDvd.cs similarity index 97% rename from src/Forms/OpenVideoDvd.cs rename to src/ui/Forms/OpenVideoDvd.cs index 463b6f9a5..3344c1845 100644 --- a/src/Forms/OpenVideoDvd.cs +++ b/src/ui/Forms/OpenVideoDvd.cs @@ -1,117 +1,117 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.IO; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class OpenVideoDvd : PositionAndSizeForm - { - - public string DvdPath { get; set; } - - public OpenVideoDvd() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Text = Configuration.Settings.Language.OpenVideoDvd.Title; - groupBoxOpenDvdFrom.Text = Configuration.Settings.Language.OpenVideoDvd.OpenDvdFrom; - radioButtonDisc.Text = Configuration.Settings.Language.OpenVideoDvd.Disc; - radioButtonFolder.Text = Configuration.Settings.Language.OpenVideoDvd.Folder; - labelChooseDrive.Text = Configuration.Settings.Language.OpenVideoDvd.ChooseDrive; - labelChooseFolder.Text = Configuration.Settings.Language.OpenVideoDvd.ChooseFolder; - PanelDrive.Enabled = false; - UiUtil.FixLargeFonts(this, buttonOK); - radioButtonDisc_CheckedChanged(null, null); - - PanelFolder.Left = PanelDrive.Left; - PanelFolder.Top = PanelDrive.Top; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void buttonOK_Click(object sender, EventArgs e) - { - if (radioButtonDisc.Checked) - { - string s = comboBoxDrive.Items[comboBoxDrive.SelectedIndex].ToString(); - if (s.Contains(' ')) - { - s = s.Substring(0, s.IndexOf(' ')); - } - - DvdPath = s; - } - else - { - DvdPath = textBoxFolder.Text; - } - DialogResult = DialogResult.OK; - } - - private void radioButtonDisc_CheckedChanged(object sender, EventArgs e) - { - PanelDrive.Visible = radioButtonDisc.Checked; - PanelFolder.Visible = radioButtonFolder.Checked; - } - - private void buttonChooseFolder_Click(object sender, EventArgs e) - { - folderBrowserDialog1.ShowNewFolderButton = true; - if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) - { - textBoxFolder.Text = folderBrowserDialog1.SelectedPath; - } - } - - private void OpenVideoDvd_Shown(object sender, EventArgs e) - { - foreach (DriveInfo drive in DriveInfo.GetDrives()) - { - if (drive.DriveType == DriveType.CDRom || drive.DriveType == DriveType.Removable) - { - if (drive.IsReady) - { - try - { - comboBoxDrive.Items.Add(drive + " " + drive.VolumeLabel); - } - catch - { - comboBoxDrive.Items.Add(drive.ToString()); - } - } - else - { - comboBoxDrive.Items.Add(drive.ToString()); - } - } - } - if (comboBoxDrive.Items.Count > 0) - { - comboBoxDrive.SelectedIndex = 0; - } - else - { - radioButtonFolder.Checked = true; - } - - PanelDrive.Enabled = true; - } - - private void OpenVideoDvd_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.IO; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class OpenVideoDvd : PositionAndSizeForm + { + + public string DvdPath { get; set; } + + public OpenVideoDvd() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Text = Configuration.Settings.Language.OpenVideoDvd.Title; + groupBoxOpenDvdFrom.Text = Configuration.Settings.Language.OpenVideoDvd.OpenDvdFrom; + radioButtonDisc.Text = Configuration.Settings.Language.OpenVideoDvd.Disc; + radioButtonFolder.Text = Configuration.Settings.Language.OpenVideoDvd.Folder; + labelChooseDrive.Text = Configuration.Settings.Language.OpenVideoDvd.ChooseDrive; + labelChooseFolder.Text = Configuration.Settings.Language.OpenVideoDvd.ChooseFolder; + PanelDrive.Enabled = false; + UiUtil.FixLargeFonts(this, buttonOK); + radioButtonDisc_CheckedChanged(null, null); + + PanelFolder.Left = PanelDrive.Left; + PanelFolder.Top = PanelDrive.Top; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void buttonOK_Click(object sender, EventArgs e) + { + if (radioButtonDisc.Checked) + { + string s = comboBoxDrive.Items[comboBoxDrive.SelectedIndex].ToString(); + if (s.Contains(' ')) + { + s = s.Substring(0, s.IndexOf(' ')); + } + + DvdPath = s; + } + else + { + DvdPath = textBoxFolder.Text; + } + DialogResult = DialogResult.OK; + } + + private void radioButtonDisc_CheckedChanged(object sender, EventArgs e) + { + PanelDrive.Visible = radioButtonDisc.Checked; + PanelFolder.Visible = radioButtonFolder.Checked; + } + + private void buttonChooseFolder_Click(object sender, EventArgs e) + { + folderBrowserDialog1.ShowNewFolderButton = true; + if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) + { + textBoxFolder.Text = folderBrowserDialog1.SelectedPath; + } + } + + private void OpenVideoDvd_Shown(object sender, EventArgs e) + { + foreach (DriveInfo drive in DriveInfo.GetDrives()) + { + if (drive.DriveType == DriveType.CDRom || drive.DriveType == DriveType.Removable) + { + if (drive.IsReady) + { + try + { + comboBoxDrive.Items.Add(drive + " " + drive.VolumeLabel); + } + catch + { + comboBoxDrive.Items.Add(drive.ToString()); + } + } + else + { + comboBoxDrive.Items.Add(drive.ToString()); + } + } + } + if (comboBoxDrive.Items.Count > 0) + { + comboBoxDrive.SelectedIndex = 0; + } + else + { + radioButtonFolder.Checked = true; + } + + PanelDrive.Enabled = true; + } + + private void OpenVideoDvd_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + } +} diff --git a/src/Forms/OpenVideoDvd.resx b/src/ui/Forms/OpenVideoDvd.resx similarity index 97% rename from src/Forms/OpenVideoDvd.resx rename to src/ui/Forms/OpenVideoDvd.resx index 913dd0dab..69f943da9 100644 --- a/src/Forms/OpenVideoDvd.resx +++ b/src/ui/Forms/OpenVideoDvd.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/PacEncoding.Designer.cs b/src/ui/Forms/PacEncoding.Designer.cs similarity index 97% rename from src/Forms/PacEncoding.Designer.cs rename to src/ui/Forms/PacEncoding.Designer.cs index 400374aaf..d57d70fd8 100644 --- a/src/Forms/PacEncoding.Designer.cs +++ b/src/ui/Forms/PacEncoding.Designer.cs @@ -1,150 +1,150 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class PacEncoding - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.comboBoxCodePage = new System.Windows.Forms.ComboBox(); - this.labelCodePage = new System.Windows.Forms.Label(); - this.labelPreview = new System.Windows.Forms.Label(); - this.textBoxPreview = new System.Windows.Forms.TextBox(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // comboBoxCodePage - // - this.comboBoxCodePage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxCodePage.FormattingEnabled = true; - this.comboBoxCodePage.Items.AddRange(new object[] { - "Latin", - "Greek", - "Latin Czech", - "Arabic", - "Hebrew", - "Thai", - "Cyrillic", - "Chinese Traditional (Big5)", - "Chinese Simplified (gb2312)", - "Korean", - "Japanese"}); - this.comboBoxCodePage.Location = new System.Drawing.Point(12, 37); - this.comboBoxCodePage.Name = "comboBoxCodePage"; - this.comboBoxCodePage.Size = new System.Drawing.Size(203, 21); - this.comboBoxCodePage.TabIndex = 0; - this.comboBoxCodePage.SelectedIndexChanged += new System.EventHandler(this.comboBoxCodePage_SelectedIndexChanged); - // - // labelCodePage - // - this.labelCodePage.AutoSize = true; - this.labelCodePage.Location = new System.Drawing.Point(9, 21); - this.labelCodePage.Name = "labelCodePage"; - this.labelCodePage.Size = new System.Drawing.Size(155, 13); - this.labelCodePage.TabIndex = 1; - this.labelCodePage.Text = "Please choose PAC code page"; - // - // labelPreview - // - this.labelPreview.AutoSize = true; - this.labelPreview.Location = new System.Drawing.Point(9, 73); - this.labelPreview.Name = "labelPreview"; - this.labelPreview.Size = new System.Drawing.Size(122, 13); - this.labelPreview.TabIndex = 2; - this.labelPreview.Text = "PAC code page preview"; - // - // textBoxPreview - // - this.textBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxPreview.Location = new System.Drawing.Point(12, 89); - this.textBoxPreview.Multiline = true; - this.textBoxPreview.Name = "textBoxPreview"; - this.textBoxPreview.ReadOnly = true; - this.textBoxPreview.Size = new System.Drawing.Size(361, 115); - this.textBoxPreview.TabIndex = 3; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(298, 213); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(217, 213); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 4; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // PacEncoding - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(385, 248); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.textBoxPreview); - this.Controls.Add(this.labelPreview); - this.Controls.Add(this.labelCodePage); - this.Controls.Add(this.comboBoxCodePage); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "PacEncoding"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "PacEncoding"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PacEncoding_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ComboBox comboBoxCodePage; - private System.Windows.Forms.Label labelCodePage; - private System.Windows.Forms.Label labelPreview; - private System.Windows.Forms.TextBox textBoxPreview; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class PacEncoding + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.comboBoxCodePage = new System.Windows.Forms.ComboBox(); + this.labelCodePage = new System.Windows.Forms.Label(); + this.labelPreview = new System.Windows.Forms.Label(); + this.textBoxPreview = new System.Windows.Forms.TextBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // comboBoxCodePage + // + this.comboBoxCodePage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxCodePage.FormattingEnabled = true; + this.comboBoxCodePage.Items.AddRange(new object[] { + "Latin", + "Greek", + "Latin Czech", + "Arabic", + "Hebrew", + "Thai", + "Cyrillic", + "Chinese Traditional (Big5)", + "Chinese Simplified (gb2312)", + "Korean", + "Japanese"}); + this.comboBoxCodePage.Location = new System.Drawing.Point(12, 37); + this.comboBoxCodePage.Name = "comboBoxCodePage"; + this.comboBoxCodePage.Size = new System.Drawing.Size(203, 21); + this.comboBoxCodePage.TabIndex = 0; + this.comboBoxCodePage.SelectedIndexChanged += new System.EventHandler(this.comboBoxCodePage_SelectedIndexChanged); + // + // labelCodePage + // + this.labelCodePage.AutoSize = true; + this.labelCodePage.Location = new System.Drawing.Point(9, 21); + this.labelCodePage.Name = "labelCodePage"; + this.labelCodePage.Size = new System.Drawing.Size(155, 13); + this.labelCodePage.TabIndex = 1; + this.labelCodePage.Text = "Please choose PAC code page"; + // + // labelPreview + // + this.labelPreview.AutoSize = true; + this.labelPreview.Location = new System.Drawing.Point(9, 73); + this.labelPreview.Name = "labelPreview"; + this.labelPreview.Size = new System.Drawing.Size(122, 13); + this.labelPreview.TabIndex = 2; + this.labelPreview.Text = "PAC code page preview"; + // + // textBoxPreview + // + this.textBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxPreview.Location = new System.Drawing.Point(12, 89); + this.textBoxPreview.Multiline = true; + this.textBoxPreview.Name = "textBoxPreview"; + this.textBoxPreview.ReadOnly = true; + this.textBoxPreview.Size = new System.Drawing.Size(361, 115); + this.textBoxPreview.TabIndex = 3; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(298, 213); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(217, 213); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 4; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // PacEncoding + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(385, 248); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.textBoxPreview); + this.Controls.Add(this.labelPreview); + this.Controls.Add(this.labelCodePage); + this.Controls.Add(this.comboBoxCodePage); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "PacEncoding"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "PacEncoding"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PacEncoding_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox comboBoxCodePage; + private System.Windows.Forms.Label labelCodePage; + private System.Windows.Forms.Label labelPreview; + private System.Windows.Forms.TextBox textBoxPreview; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + + } } \ No newline at end of file diff --git a/src/Forms/PacEncoding.cs b/src/ui/Forms/PacEncoding.cs similarity index 97% rename from src/Forms/PacEncoding.cs rename to src/ui/Forms/PacEncoding.cs index 47db8205f..80731d818 100644 --- a/src/Forms/PacEncoding.cs +++ b/src/ui/Forms/PacEncoding.cs @@ -1,150 +1,150 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - - public sealed partial class PacEncoding : Form - { - private const string PreviewChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - public int CodePageIndex { get; set; } - - private readonly byte[] _previewBuffer; - - public PacEncoding(byte[] previewBuffer, string fileName) - { - CodePageIndex = Configuration.Settings.General.LastPacCodePage; - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Text = System.IO.Path.GetFileName(fileName); - _previewBuffer = previewBuffer; - if (CodePageIndex >= 0 && CodePageIndex < comboBoxCodePage.Items.Count) - { - comboBoxCodePage.SelectedIndex = CodePageIndex; - } - - if (previewBuffer == null) - { - labelPreview.Visible = false; - textBoxPreview.Visible = false; - Height -= textBoxPreview.Height; - } - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void PacEncoding_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void comboBoxCodePage_SelectedIndexChanged(object sender, EventArgs e) - { - if (comboBoxCodePage.SelectedIndex >= 0) - { - CodePageIndex = comboBoxCodePage.SelectedIndex; - if (_previewBuffer != null) - { - Encoding encoding = Pac.GetEncoding(CodePageIndex); - const int feIndex = 0; - const int endDelimiter = 0x00; - int index; - - var indexOfW16 = Encoding.ASCII.GetString(_previewBuffer).IndexOf("W16", StringComparison.Ordinal); - if (indexOfW16 > 0 && indexOfW16 < _previewBuffer.Length - 5) - { - index = indexOfW16 + 4; - if (CodePageIndex == Pac.CodePageChineseSimplified) - { - textBoxPreview.Text = Encoding.GetEncoding(Pac.EncodingChineseSimplified).GetString(_previewBuffer, index, _previewBuffer.Length - index); - return; - } - else if (CodePageIndex == Pac.CodePageChineseTraditional) - { - textBoxPreview.Text = Encoding.GetEncoding(Pac.EncodingChineseTraditional).GetString(_previewBuffer, index, _previewBuffer.Length - index); - return; - } - else if (CodePageIndex == Pac.CodePageKorean) - { - textBoxPreview.Text = Encoding.GetEncoding(Pac.EncodingKorean).GetString(_previewBuffer, index, _previewBuffer.Length - index); - return; - } - else if (CodePageIndex == Pac.CodePageJapanese) - { - textBoxPreview.Text = Encoding.GetEncoding(Pac.EncodingJapanese).GetString(_previewBuffer, index, _previewBuffer.Length - index); - return; - } - } - - var sb = new StringBuilder(); - index = feIndex + 3; - while (index < _previewBuffer.Length && _previewBuffer[index] != endDelimiter) - { - if (_previewBuffer[index] == 0xFE) - { - sb.AppendLine(); - index += 2; - } - else if (_previewBuffer[index] == 0xFF) - { - sb.Append(' '); - } - else if (CodePageIndex == Pac.CodePageLatin) - { - sb.Append(Pac.GetLatinString(encoding, _previewBuffer, ref index)); - } - else if (CodePageIndex == Pac.CodePageArabic) - { - sb.Append(Pac.GetArabicString(_previewBuffer, ref index)); - } - else if (CodePageIndex == Pac.CodePageHebrew) - { - sb.Append(Pac.GetHebrewString(_previewBuffer, ref index)); - } - else if (CodePageIndex == Pac.CodePageCyrillic) - { - sb.Append(Pac.GetCyrillicString(_previewBuffer, ref index)); - } - else if (CodePageIndex == Pac.CodePageGreek) - { - sb.Append(Pac.GetGreekString(_previewBuffer, ref index)); - } - else - { - sb.Append(encoding.GetString(_previewBuffer, index, 1)); - } - - index++; - } - if (CodePageIndex == Pac.CodePageArabic) - { - textBoxPreview.Text = Utilities.FixEnglishTextInRightToLeftLanguage(sb.ToString(), PreviewChars); - } - else - { - textBoxPreview.Text = sb.ToString(); - } - } - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + + public sealed partial class PacEncoding : Form + { + private const string PreviewChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + public int CodePageIndex { get; set; } + + private readonly byte[] _previewBuffer; + + public PacEncoding(byte[] previewBuffer, string fileName) + { + CodePageIndex = Configuration.Settings.General.LastPacCodePage; + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Text = System.IO.Path.GetFileName(fileName); + _previewBuffer = previewBuffer; + if (CodePageIndex >= 0 && CodePageIndex < comboBoxCodePage.Items.Count) + { + comboBoxCodePage.SelectedIndex = CodePageIndex; + } + + if (previewBuffer == null) + { + labelPreview.Visible = false; + textBoxPreview.Visible = false; + Height -= textBoxPreview.Height; + } + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void PacEncoding_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void comboBoxCodePage_SelectedIndexChanged(object sender, EventArgs e) + { + if (comboBoxCodePage.SelectedIndex >= 0) + { + CodePageIndex = comboBoxCodePage.SelectedIndex; + if (_previewBuffer != null) + { + Encoding encoding = Pac.GetEncoding(CodePageIndex); + const int feIndex = 0; + const int endDelimiter = 0x00; + int index; + + var indexOfW16 = Encoding.ASCII.GetString(_previewBuffer).IndexOf("W16", StringComparison.Ordinal); + if (indexOfW16 > 0 && indexOfW16 < _previewBuffer.Length - 5) + { + index = indexOfW16 + 4; + if (CodePageIndex == Pac.CodePageChineseSimplified) + { + textBoxPreview.Text = Encoding.GetEncoding(Pac.EncodingChineseSimplified).GetString(_previewBuffer, index, _previewBuffer.Length - index); + return; + } + else if (CodePageIndex == Pac.CodePageChineseTraditional) + { + textBoxPreview.Text = Encoding.GetEncoding(Pac.EncodingChineseTraditional).GetString(_previewBuffer, index, _previewBuffer.Length - index); + return; + } + else if (CodePageIndex == Pac.CodePageKorean) + { + textBoxPreview.Text = Encoding.GetEncoding(Pac.EncodingKorean).GetString(_previewBuffer, index, _previewBuffer.Length - index); + return; + } + else if (CodePageIndex == Pac.CodePageJapanese) + { + textBoxPreview.Text = Encoding.GetEncoding(Pac.EncodingJapanese).GetString(_previewBuffer, index, _previewBuffer.Length - index); + return; + } + } + + var sb = new StringBuilder(); + index = feIndex + 3; + while (index < _previewBuffer.Length && _previewBuffer[index] != endDelimiter) + { + if (_previewBuffer[index] == 0xFE) + { + sb.AppendLine(); + index += 2; + } + else if (_previewBuffer[index] == 0xFF) + { + sb.Append(' '); + } + else if (CodePageIndex == Pac.CodePageLatin) + { + sb.Append(Pac.GetLatinString(encoding, _previewBuffer, ref index)); + } + else if (CodePageIndex == Pac.CodePageArabic) + { + sb.Append(Pac.GetArabicString(_previewBuffer, ref index)); + } + else if (CodePageIndex == Pac.CodePageHebrew) + { + sb.Append(Pac.GetHebrewString(_previewBuffer, ref index)); + } + else if (CodePageIndex == Pac.CodePageCyrillic) + { + sb.Append(Pac.GetCyrillicString(_previewBuffer, ref index)); + } + else if (CodePageIndex == Pac.CodePageGreek) + { + sb.Append(Pac.GetGreekString(_previewBuffer, ref index)); + } + else + { + sb.Append(encoding.GetString(_previewBuffer, index, 1)); + } + + index++; + } + if (CodePageIndex == Pac.CodePageArabic) + { + textBoxPreview.Text = Utilities.FixEnglishTextInRightToLeftLanguage(sb.ToString(), PreviewChars); + } + else + { + textBoxPreview.Text = sb.ToString(); + } + } + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + } +} diff --git a/src/Forms/PacEncoding.resx b/src/ui/Forms/PacEncoding.resx similarity index 97% rename from src/Forms/PacEncoding.resx rename to src/ui/Forms/PacEncoding.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/PacEncoding.resx +++ b/src/ui/Forms/PacEncoding.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/PluginsGet.Designer.cs b/src/ui/Forms/PluginsGet.Designer.cs similarity index 98% rename from src/Forms/PluginsGet.Designer.cs rename to src/ui/Forms/PluginsGet.Designer.cs index ca4c177a7..33164a5b4 100644 --- a/src/Forms/PluginsGet.Designer.cs +++ b/src/ui/Forms/PluginsGet.Designer.cs @@ -1,353 +1,353 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class PluginsGet - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.labelClickDownload = new System.Windows.Forms.Label(); - this.buttonDownload = new System.Windows.Forms.Button(); - this.labelDescription1 = new System.Windows.Forms.Label(); - this.linkLabelOpenPluginFolder = new System.Windows.Forms.LinkLabel(); - this.buttonOK = new System.Windows.Forms.Button(); - this.listViewGetPlugins = new System.Windows.Forms.ListView(); - this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderVersion = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderDate = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.tabControlPlugins = new System.Windows.Forms.TabControl(); - this.tabPageInstalledPlugins = new System.Windows.Forms.TabPage(); - this.buttonUpdateAll = new System.Windows.Forms.Button(); - this.buttonRemove = new System.Windows.Forms.Button(); - this.listViewInstalledPlugins = new System.Windows.Forms.ListView(); - this.columnHeaderInsName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderInsDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderInsVersion = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderInsType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.tabPageGetPlugins = new System.Windows.Forms.TabPage(); - this.buttonSearchClear = new System.Windows.Forms.Button(); - this.labelShortcutsSearch = new System.Windows.Forms.Label(); - this.textBoxSearch = new System.Windows.Forms.TextBox(); - this.labelPleaseWait = new System.Windows.Forms.Label(); - this.tabControlPlugins.SuspendLayout(); - this.tabPageInstalledPlugins.SuspendLayout(); - this.tabPageGetPlugins.SuspendLayout(); - this.SuspendLayout(); - // - // labelClickDownload - // - this.labelClickDownload.AutoSize = true; - this.labelClickDownload.Location = new System.Drawing.Point(13, 48); - this.labelClickDownload.Name = "labelClickDownload"; - this.labelClickDownload.Size = new System.Drawing.Size(181, 13); - this.labelClickDownload.TabIndex = 23; - this.labelClickDownload.Text = "Choose plugin and click \"Download\""; - // - // buttonDownload - // - this.buttonDownload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDownload.Location = new System.Drawing.Point(680, 435); - this.buttonDownload.Name = "buttonDownload"; - this.buttonDownload.Size = new System.Drawing.Size(104, 25); - this.buttonDownload.TabIndex = 22; - this.buttonDownload.Text = "&Download"; - this.buttonDownload.UseVisualStyleBackColor = true; - this.buttonDownload.Click += new System.EventHandler(this.buttonDownload_Click); - // - // labelDescription1 - // - this.labelDescription1.AutoSize = true; - this.labelDescription1.Location = new System.Drawing.Point(13, 16); - this.labelDescription1.Name = "labelDescription1"; - this.labelDescription1.Size = new System.Drawing.Size(306, 13); - this.labelDescription1.TabIndex = 21; - this.labelDescription1.Text = "Subtitle Edit plugins must be downloaded to the \"Plugins\" folder"; - // - // linkLabelOpenPluginFolder - // - this.linkLabelOpenPluginFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.linkLabelOpenPluginFolder.AutoSize = true; - this.linkLabelOpenPluginFolder.Location = new System.Drawing.Point(12, 515); - this.linkLabelOpenPluginFolder.Name = "linkLabelOpenPluginFolder"; - this.linkLabelOpenPluginFolder.Size = new System.Drawing.Size(106, 13); - this.linkLabelOpenPluginFolder.TabIndex = 98; - this.linkLabelOpenPluginFolder.TabStop = true; - this.linkLabelOpenPluginFolder.Text = "Open \'Plug-ins\' folder"; - this.linkLabelOpenPluginFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelOpenDictionaryFolder_LinkClicked); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.Location = new System.Drawing.Point(695, 510); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(104, 23); - this.buttonOK.TabIndex = 99; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - // - // listViewGetPlugins - // - this.listViewGetPlugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewGetPlugins.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderName, - this.columnHeaderDescription, - this.columnHeaderVersion, - this.columnHeaderDate}); - this.listViewGetPlugins.FullRowSelect = true; - this.listViewGetPlugins.HideSelection = false; - this.listViewGetPlugins.Location = new System.Drawing.Point(16, 67); - this.listViewGetPlugins.MultiSelect = false; - this.listViewGetPlugins.Name = "listViewGetPlugins"; - this.listViewGetPlugins.Size = new System.Drawing.Size(767, 362); - this.listViewGetPlugins.TabIndex = 15; - this.listViewGetPlugins.UseCompatibleStateImageBehavior = false; - this.listViewGetPlugins.View = System.Windows.Forms.View.Details; - // - // columnHeaderName - // - this.columnHeaderName.Text = "Name"; - this.columnHeaderName.Width = 140; - // - // columnHeaderDescription - // - this.columnHeaderDescription.Text = "Description"; - this.columnHeaderDescription.Width = 420; - // - // columnHeaderVersion - // - this.columnHeaderVersion.Text = "Version"; - this.columnHeaderVersion.Width = 80; - // - // columnHeaderDate - // - this.columnHeaderDate.Text = "Date"; - this.columnHeaderDate.Width = 70; - // - // tabControlPlugins - // - this.tabControlPlugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tabControlPlugins.Controls.Add(this.tabPageInstalledPlugins); - this.tabControlPlugins.Controls.Add(this.tabPageGetPlugins); - this.tabControlPlugins.Location = new System.Drawing.Point(12, 12); - this.tabControlPlugins.Name = "tabControlPlugins"; - this.tabControlPlugins.SelectedIndex = 0; - this.tabControlPlugins.Size = new System.Drawing.Size(798, 492); - this.tabControlPlugins.TabIndex = 28; - // - // tabPageInstalledPlugins - // - this.tabPageInstalledPlugins.Controls.Add(this.buttonUpdateAll); - this.tabPageInstalledPlugins.Controls.Add(this.buttonRemove); - this.tabPageInstalledPlugins.Controls.Add(this.listViewInstalledPlugins); - this.tabPageInstalledPlugins.Location = new System.Drawing.Point(4, 22); - this.tabPageInstalledPlugins.Name = "tabPageInstalledPlugins"; - this.tabPageInstalledPlugins.Padding = new System.Windows.Forms.Padding(3); - this.tabPageInstalledPlugins.Size = new System.Drawing.Size(790, 466); - this.tabPageInstalledPlugins.TabIndex = 0; - this.tabPageInstalledPlugins.Text = "Installed plugins"; - this.tabPageInstalledPlugins.UseVisualStyleBackColor = true; - // - // buttonUpdateAll - // - this.buttonUpdateAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUpdateAll.Location = new System.Drawing.Point(539, 435); - this.buttonUpdateAll.Name = "buttonUpdateAll"; - this.buttonUpdateAll.Size = new System.Drawing.Size(134, 25); - this.buttonUpdateAll.TabIndex = 30; - this.buttonUpdateAll.Text = "Updata all"; - this.buttonUpdateAll.UseVisualStyleBackColor = true; - this.buttonUpdateAll.Click += new System.EventHandler(this.buttonUpdateAll_Click); - // - // buttonRemove - // - this.buttonRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRemove.Location = new System.Drawing.Point(679, 435); - this.buttonRemove.Name = "buttonRemove"; - this.buttonRemove.Size = new System.Drawing.Size(104, 25); - this.buttonRemove.TabIndex = 29; - this.buttonRemove.Text = "&Remove"; - this.buttonRemove.UseVisualStyleBackColor = true; - this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click); - // - // listViewInstalledPlugins - // - this.listViewInstalledPlugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewInstalledPlugins.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderInsName, - this.columnHeaderInsDescription, - this.columnHeaderInsVersion, - this.columnHeaderInsType}); - this.listViewInstalledPlugins.FullRowSelect = true; - this.listViewInstalledPlugins.HideSelection = false; - this.listViewInstalledPlugins.Location = new System.Drawing.Point(6, 6); - this.listViewInstalledPlugins.MultiSelect = false; - this.listViewInstalledPlugins.Name = "listViewInstalledPlugins"; - this.listViewInstalledPlugins.Size = new System.Drawing.Size(777, 423); - this.listViewInstalledPlugins.Sorting = System.Windows.Forms.SortOrder.Ascending; - this.listViewInstalledPlugins.TabIndex = 28; - this.listViewInstalledPlugins.UseCompatibleStateImageBehavior = false; - this.listViewInstalledPlugins.View = System.Windows.Forms.View.Details; - // - // columnHeaderInsName - // - this.columnHeaderInsName.Text = "Name"; - this.columnHeaderInsName.Width = 140; - // - // columnHeaderInsDescription - // - this.columnHeaderInsDescription.Text = "Description"; - this.columnHeaderInsDescription.Width = 420; - // - // columnHeaderInsVersion - // - this.columnHeaderInsVersion.Text = "Version"; - this.columnHeaderInsVersion.Width = 80; - // - // columnHeaderInsType - // - this.columnHeaderInsType.Text = "Date"; - this.columnHeaderInsType.Width = 80; - // - // tabPageGetPlugins - // - this.tabPageGetPlugins.Controls.Add(this.buttonSearchClear); - this.tabPageGetPlugins.Controls.Add(this.labelShortcutsSearch); - this.tabPageGetPlugins.Controls.Add(this.textBoxSearch); - this.tabPageGetPlugins.Controls.Add(this.labelPleaseWait); - this.tabPageGetPlugins.Controls.Add(this.listViewGetPlugins); - this.tabPageGetPlugins.Controls.Add(this.labelDescription1); - this.tabPageGetPlugins.Controls.Add(this.buttonDownload); - this.tabPageGetPlugins.Controls.Add(this.labelClickDownload); - this.tabPageGetPlugins.Location = new System.Drawing.Point(4, 22); - this.tabPageGetPlugins.Name = "tabPageGetPlugins"; - this.tabPageGetPlugins.Padding = new System.Windows.Forms.Padding(3); - this.tabPageGetPlugins.Size = new System.Drawing.Size(790, 466); - this.tabPageGetPlugins.TabIndex = 1; - this.tabPageGetPlugins.Text = "Get plugins"; - this.tabPageGetPlugins.UseVisualStyleBackColor = true; - // - // buttonSearchClear - // - this.buttonSearchClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSearchClear.Enabled = false; - this.buttonSearchClear.Location = new System.Drawing.Point(672, 38); - this.buttonSearchClear.Name = "buttonSearchClear"; - this.buttonSearchClear.Size = new System.Drawing.Size(111, 23); - this.buttonSearchClear.TabIndex = 8; - this.buttonSearchClear.Text = "Clear"; - this.buttonSearchClear.UseVisualStyleBackColor = true; - this.buttonSearchClear.Click += new System.EventHandler(this.buttonSearchClear_Click); - // - // labelShortcutsSearch - // - this.labelShortcutsSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelShortcutsSearch.AutoSize = true; - this.labelShortcutsSearch.Location = new System.Drawing.Point(469, 43); - this.labelShortcutsSearch.Name = "labelShortcutsSearch"; - this.labelShortcutsSearch.Size = new System.Drawing.Size(41, 13); - this.labelShortcutsSearch.TabIndex = 43; - this.labelShortcutsSearch.Text = "Search"; - // - // textBoxSearch - // - this.textBoxSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxSearch.Location = new System.Drawing.Point(515, 40); - this.textBoxSearch.Name = "textBoxSearch"; - this.textBoxSearch.Size = new System.Drawing.Size(151, 20); - this.textBoxSearch.TabIndex = 5; - this.textBoxSearch.TextChanged += new System.EventHandler(this.textBoxSearch_TextChanged); - // - // labelPleaseWait - // - this.labelPleaseWait.AutoSize = true; - this.labelPleaseWait.Location = new System.Drawing.Point(13, 447); - this.labelPleaseWait.Name = "labelPleaseWait"; - this.labelPleaseWait.Size = new System.Drawing.Size(70, 13); - this.labelPleaseWait.TabIndex = 28; - this.labelPleaseWait.Text = "Please wait..."; - // - // PluginsGet - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(811, 542); - this.Controls.Add(this.tabControlPlugins); - this.Controls.Add(this.linkLabelOpenPluginFolder); - this.Controls.Add(this.buttonOK); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(600, 350); - this.Name = "PluginsGet"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Plugins"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PluginsGet_KeyDown); - this.tabControlPlugins.ResumeLayout(false); - this.tabPageInstalledPlugins.ResumeLayout(false); - this.tabPageGetPlugins.ResumeLayout(false); - this.tabPageGetPlugins.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelClickDownload; - private System.Windows.Forms.Button buttonDownload; - private System.Windows.Forms.Label labelDescription1; - private System.Windows.Forms.LinkLabel linkLabelOpenPluginFolder; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.ListView listViewGetPlugins; - private System.Windows.Forms.ColumnHeader columnHeaderName; - private System.Windows.Forms.ColumnHeader columnHeaderVersion; - private System.Windows.Forms.ColumnHeader columnHeaderDescription; - private System.Windows.Forms.ColumnHeader columnHeaderDate; - private System.Windows.Forms.TabControl tabControlPlugins; - private System.Windows.Forms.TabPage tabPageInstalledPlugins; - private System.Windows.Forms.Button buttonRemove; - private System.Windows.Forms.ListView listViewInstalledPlugins; - private System.Windows.Forms.ColumnHeader columnHeaderInsName; - private System.Windows.Forms.ColumnHeader columnHeaderInsDescription; - private System.Windows.Forms.ColumnHeader columnHeaderInsVersion; - private System.Windows.Forms.ColumnHeader columnHeaderInsType; - private System.Windows.Forms.TabPage tabPageGetPlugins; - private System.Windows.Forms.Label labelPleaseWait; - private System.Windows.Forms.Button buttonUpdateAll; - private System.Windows.Forms.Button buttonSearchClear; - private System.Windows.Forms.Label labelShortcutsSearch; - private System.Windows.Forms.TextBox textBoxSearch; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class PluginsGet + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.labelClickDownload = new System.Windows.Forms.Label(); + this.buttonDownload = new System.Windows.Forms.Button(); + this.labelDescription1 = new System.Windows.Forms.Label(); + this.linkLabelOpenPluginFolder = new System.Windows.Forms.LinkLabel(); + this.buttonOK = new System.Windows.Forms.Button(); + this.listViewGetPlugins = new System.Windows.Forms.ListView(); + this.columnHeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderVersion = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderDate = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.tabControlPlugins = new System.Windows.Forms.TabControl(); + this.tabPageInstalledPlugins = new System.Windows.Forms.TabPage(); + this.buttonUpdateAll = new System.Windows.Forms.Button(); + this.buttonRemove = new System.Windows.Forms.Button(); + this.listViewInstalledPlugins = new System.Windows.Forms.ListView(); + this.columnHeaderInsName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderInsDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderInsVersion = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderInsType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.tabPageGetPlugins = new System.Windows.Forms.TabPage(); + this.buttonSearchClear = new System.Windows.Forms.Button(); + this.labelShortcutsSearch = new System.Windows.Forms.Label(); + this.textBoxSearch = new System.Windows.Forms.TextBox(); + this.labelPleaseWait = new System.Windows.Forms.Label(); + this.tabControlPlugins.SuspendLayout(); + this.tabPageInstalledPlugins.SuspendLayout(); + this.tabPageGetPlugins.SuspendLayout(); + this.SuspendLayout(); + // + // labelClickDownload + // + this.labelClickDownload.AutoSize = true; + this.labelClickDownload.Location = new System.Drawing.Point(13, 48); + this.labelClickDownload.Name = "labelClickDownload"; + this.labelClickDownload.Size = new System.Drawing.Size(181, 13); + this.labelClickDownload.TabIndex = 23; + this.labelClickDownload.Text = "Choose plugin and click \"Download\""; + // + // buttonDownload + // + this.buttonDownload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDownload.Location = new System.Drawing.Point(680, 435); + this.buttonDownload.Name = "buttonDownload"; + this.buttonDownload.Size = new System.Drawing.Size(104, 25); + this.buttonDownload.TabIndex = 22; + this.buttonDownload.Text = "&Download"; + this.buttonDownload.UseVisualStyleBackColor = true; + this.buttonDownload.Click += new System.EventHandler(this.buttonDownload_Click); + // + // labelDescription1 + // + this.labelDescription1.AutoSize = true; + this.labelDescription1.Location = new System.Drawing.Point(13, 16); + this.labelDescription1.Name = "labelDescription1"; + this.labelDescription1.Size = new System.Drawing.Size(306, 13); + this.labelDescription1.TabIndex = 21; + this.labelDescription1.Text = "Subtitle Edit plugins must be downloaded to the \"Plugins\" folder"; + // + // linkLabelOpenPluginFolder + // + this.linkLabelOpenPluginFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.linkLabelOpenPluginFolder.AutoSize = true; + this.linkLabelOpenPluginFolder.Location = new System.Drawing.Point(12, 515); + this.linkLabelOpenPluginFolder.Name = "linkLabelOpenPluginFolder"; + this.linkLabelOpenPluginFolder.Size = new System.Drawing.Size(106, 13); + this.linkLabelOpenPluginFolder.TabIndex = 98; + this.linkLabelOpenPluginFolder.TabStop = true; + this.linkLabelOpenPluginFolder.Text = "Open \'Plug-ins\' folder"; + this.linkLabelOpenPluginFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelOpenDictionaryFolder_LinkClicked); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.Location = new System.Drawing.Point(695, 510); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(104, 23); + this.buttonOK.TabIndex = 99; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + // + // listViewGetPlugins + // + this.listViewGetPlugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewGetPlugins.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderName, + this.columnHeaderDescription, + this.columnHeaderVersion, + this.columnHeaderDate}); + this.listViewGetPlugins.FullRowSelect = true; + this.listViewGetPlugins.HideSelection = false; + this.listViewGetPlugins.Location = new System.Drawing.Point(16, 67); + this.listViewGetPlugins.MultiSelect = false; + this.listViewGetPlugins.Name = "listViewGetPlugins"; + this.listViewGetPlugins.Size = new System.Drawing.Size(767, 362); + this.listViewGetPlugins.TabIndex = 15; + this.listViewGetPlugins.UseCompatibleStateImageBehavior = false; + this.listViewGetPlugins.View = System.Windows.Forms.View.Details; + // + // columnHeaderName + // + this.columnHeaderName.Text = "Name"; + this.columnHeaderName.Width = 140; + // + // columnHeaderDescription + // + this.columnHeaderDescription.Text = "Description"; + this.columnHeaderDescription.Width = 420; + // + // columnHeaderVersion + // + this.columnHeaderVersion.Text = "Version"; + this.columnHeaderVersion.Width = 80; + // + // columnHeaderDate + // + this.columnHeaderDate.Text = "Date"; + this.columnHeaderDate.Width = 70; + // + // tabControlPlugins + // + this.tabControlPlugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabControlPlugins.Controls.Add(this.tabPageInstalledPlugins); + this.tabControlPlugins.Controls.Add(this.tabPageGetPlugins); + this.tabControlPlugins.Location = new System.Drawing.Point(12, 12); + this.tabControlPlugins.Name = "tabControlPlugins"; + this.tabControlPlugins.SelectedIndex = 0; + this.tabControlPlugins.Size = new System.Drawing.Size(798, 492); + this.tabControlPlugins.TabIndex = 28; + // + // tabPageInstalledPlugins + // + this.tabPageInstalledPlugins.Controls.Add(this.buttonUpdateAll); + this.tabPageInstalledPlugins.Controls.Add(this.buttonRemove); + this.tabPageInstalledPlugins.Controls.Add(this.listViewInstalledPlugins); + this.tabPageInstalledPlugins.Location = new System.Drawing.Point(4, 22); + this.tabPageInstalledPlugins.Name = "tabPageInstalledPlugins"; + this.tabPageInstalledPlugins.Padding = new System.Windows.Forms.Padding(3); + this.tabPageInstalledPlugins.Size = new System.Drawing.Size(790, 466); + this.tabPageInstalledPlugins.TabIndex = 0; + this.tabPageInstalledPlugins.Text = "Installed plugins"; + this.tabPageInstalledPlugins.UseVisualStyleBackColor = true; + // + // buttonUpdateAll + // + this.buttonUpdateAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUpdateAll.Location = new System.Drawing.Point(539, 435); + this.buttonUpdateAll.Name = "buttonUpdateAll"; + this.buttonUpdateAll.Size = new System.Drawing.Size(134, 25); + this.buttonUpdateAll.TabIndex = 30; + this.buttonUpdateAll.Text = "Updata all"; + this.buttonUpdateAll.UseVisualStyleBackColor = true; + this.buttonUpdateAll.Click += new System.EventHandler(this.buttonUpdateAll_Click); + // + // buttonRemove + // + this.buttonRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRemove.Location = new System.Drawing.Point(679, 435); + this.buttonRemove.Name = "buttonRemove"; + this.buttonRemove.Size = new System.Drawing.Size(104, 25); + this.buttonRemove.TabIndex = 29; + this.buttonRemove.Text = "&Remove"; + this.buttonRemove.UseVisualStyleBackColor = true; + this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click); + // + // listViewInstalledPlugins + // + this.listViewInstalledPlugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewInstalledPlugins.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderInsName, + this.columnHeaderInsDescription, + this.columnHeaderInsVersion, + this.columnHeaderInsType}); + this.listViewInstalledPlugins.FullRowSelect = true; + this.listViewInstalledPlugins.HideSelection = false; + this.listViewInstalledPlugins.Location = new System.Drawing.Point(6, 6); + this.listViewInstalledPlugins.MultiSelect = false; + this.listViewInstalledPlugins.Name = "listViewInstalledPlugins"; + this.listViewInstalledPlugins.Size = new System.Drawing.Size(777, 423); + this.listViewInstalledPlugins.Sorting = System.Windows.Forms.SortOrder.Ascending; + this.listViewInstalledPlugins.TabIndex = 28; + this.listViewInstalledPlugins.UseCompatibleStateImageBehavior = false; + this.listViewInstalledPlugins.View = System.Windows.Forms.View.Details; + // + // columnHeaderInsName + // + this.columnHeaderInsName.Text = "Name"; + this.columnHeaderInsName.Width = 140; + // + // columnHeaderInsDescription + // + this.columnHeaderInsDescription.Text = "Description"; + this.columnHeaderInsDescription.Width = 420; + // + // columnHeaderInsVersion + // + this.columnHeaderInsVersion.Text = "Version"; + this.columnHeaderInsVersion.Width = 80; + // + // columnHeaderInsType + // + this.columnHeaderInsType.Text = "Date"; + this.columnHeaderInsType.Width = 80; + // + // tabPageGetPlugins + // + this.tabPageGetPlugins.Controls.Add(this.buttonSearchClear); + this.tabPageGetPlugins.Controls.Add(this.labelShortcutsSearch); + this.tabPageGetPlugins.Controls.Add(this.textBoxSearch); + this.tabPageGetPlugins.Controls.Add(this.labelPleaseWait); + this.tabPageGetPlugins.Controls.Add(this.listViewGetPlugins); + this.tabPageGetPlugins.Controls.Add(this.labelDescription1); + this.tabPageGetPlugins.Controls.Add(this.buttonDownload); + this.tabPageGetPlugins.Controls.Add(this.labelClickDownload); + this.tabPageGetPlugins.Location = new System.Drawing.Point(4, 22); + this.tabPageGetPlugins.Name = "tabPageGetPlugins"; + this.tabPageGetPlugins.Padding = new System.Windows.Forms.Padding(3); + this.tabPageGetPlugins.Size = new System.Drawing.Size(790, 466); + this.tabPageGetPlugins.TabIndex = 1; + this.tabPageGetPlugins.Text = "Get plugins"; + this.tabPageGetPlugins.UseVisualStyleBackColor = true; + // + // buttonSearchClear + // + this.buttonSearchClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSearchClear.Enabled = false; + this.buttonSearchClear.Location = new System.Drawing.Point(672, 38); + this.buttonSearchClear.Name = "buttonSearchClear"; + this.buttonSearchClear.Size = new System.Drawing.Size(111, 23); + this.buttonSearchClear.TabIndex = 8; + this.buttonSearchClear.Text = "Clear"; + this.buttonSearchClear.UseVisualStyleBackColor = true; + this.buttonSearchClear.Click += new System.EventHandler(this.buttonSearchClear_Click); + // + // labelShortcutsSearch + // + this.labelShortcutsSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelShortcutsSearch.AutoSize = true; + this.labelShortcutsSearch.Location = new System.Drawing.Point(469, 43); + this.labelShortcutsSearch.Name = "labelShortcutsSearch"; + this.labelShortcutsSearch.Size = new System.Drawing.Size(41, 13); + this.labelShortcutsSearch.TabIndex = 43; + this.labelShortcutsSearch.Text = "Search"; + // + // textBoxSearch + // + this.textBoxSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxSearch.Location = new System.Drawing.Point(515, 40); + this.textBoxSearch.Name = "textBoxSearch"; + this.textBoxSearch.Size = new System.Drawing.Size(151, 20); + this.textBoxSearch.TabIndex = 5; + this.textBoxSearch.TextChanged += new System.EventHandler(this.textBoxSearch_TextChanged); + // + // labelPleaseWait + // + this.labelPleaseWait.AutoSize = true; + this.labelPleaseWait.Location = new System.Drawing.Point(13, 447); + this.labelPleaseWait.Name = "labelPleaseWait"; + this.labelPleaseWait.Size = new System.Drawing.Size(70, 13); + this.labelPleaseWait.TabIndex = 28; + this.labelPleaseWait.Text = "Please wait..."; + // + // PluginsGet + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(811, 542); + this.Controls.Add(this.tabControlPlugins); + this.Controls.Add(this.linkLabelOpenPluginFolder); + this.Controls.Add(this.buttonOK); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(600, 350); + this.Name = "PluginsGet"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Plugins"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PluginsGet_KeyDown); + this.tabControlPlugins.ResumeLayout(false); + this.tabPageInstalledPlugins.ResumeLayout(false); + this.tabPageGetPlugins.ResumeLayout(false); + this.tabPageGetPlugins.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelClickDownload; + private System.Windows.Forms.Button buttonDownload; + private System.Windows.Forms.Label labelDescription1; + private System.Windows.Forms.LinkLabel linkLabelOpenPluginFolder; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.ListView listViewGetPlugins; + private System.Windows.Forms.ColumnHeader columnHeaderName; + private System.Windows.Forms.ColumnHeader columnHeaderVersion; + private System.Windows.Forms.ColumnHeader columnHeaderDescription; + private System.Windows.Forms.ColumnHeader columnHeaderDate; + private System.Windows.Forms.TabControl tabControlPlugins; + private System.Windows.Forms.TabPage tabPageInstalledPlugins; + private System.Windows.Forms.Button buttonRemove; + private System.Windows.Forms.ListView listViewInstalledPlugins; + private System.Windows.Forms.ColumnHeader columnHeaderInsName; + private System.Windows.Forms.ColumnHeader columnHeaderInsDescription; + private System.Windows.Forms.ColumnHeader columnHeaderInsVersion; + private System.Windows.Forms.ColumnHeader columnHeaderInsType; + private System.Windows.Forms.TabPage tabPageGetPlugins; + private System.Windows.Forms.Label labelPleaseWait; + private System.Windows.Forms.Button buttonUpdateAll; + private System.Windows.Forms.Button buttonSearchClear; + private System.Windows.Forms.Label labelShortcutsSearch; + private System.Windows.Forms.TextBox textBoxSearch; + } } \ No newline at end of file diff --git a/src/Forms/PluginsGet.cs b/src/ui/Forms/PluginsGet.cs similarity index 97% rename from src/Forms/PluginsGet.cs rename to src/ui/Forms/PluginsGet.cs index 2323d3cad..957fb4c99 100644 --- a/src/Forms/PluginsGet.cs +++ b/src/ui/Forms/PluginsGet.cs @@ -1,484 +1,484 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Net; -using System.Net.Cache; -using System.Windows.Forms; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class PluginsGet : Form - { - - public class PluginInfoItem - { - public string Version { get; set; } - public string Name { get; set; } - public string Description { get; set; } - public string Date { get; set; } - public string Url { get; set; } - } - - private List _downloadList; - - private string _downloadedPluginName; - private readonly LanguageStructure.PluginsGet _language; - private List _updateAllListUrls; - private bool _updatingAllPlugins; - private int _updatingAllPluginsCount; - private bool _fetchingData; - - private static string GetPluginXmlFileUrl() - { - if (Environment.Version.Major < 4) - { - return "https://raw.github.com/SubtitleEdit/plugins/master/Plugins2.xml"; // .net 2-3.5 - } - - return "https://raw.github.com/SubtitleEdit/plugins/master/Plugins4.xml"; // .net 4-? - } - - public PluginsGet() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _language = Configuration.Settings.Language.PluginsGet; - Text = _language.Title; - tabPageInstalledPlugins.Text = _language.InstalledPlugins; - tabPageGetPlugins.Text = _language.GetPlugins; - - buttonDownload.Text = _language.Download; - buttonRemove.Text = _language.Remove; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - linkLabelOpenPluginFolder.Text = _language.OpenPluginsFolder; - labelDescription1.Text = _language.GetPluginsInfo1; - labelClickDownload.Text = _language.GetPluginsInfo2; - - columnHeaderName.Text = Configuration.Settings.Language.General.Name; - columnHeaderDescription.Text = _language.Description; - columnHeaderVersion.Text = _language.Version; - columnHeaderDate.Text = _language.Date; - - columnHeaderInsName.Text = Configuration.Settings.Language.General.Name; - columnHeaderInsDescription.Text = _language.Description; - columnHeaderInsVersion.Text = _language.Version; - columnHeaderInsType.Text = _language.Type; - - labelShortcutsSearch.Text = Configuration.Settings.Language.General.Search; - labelShortcutsSearch.Left = textBoxSearch.Left - labelShortcutsSearch.Width - 9; - buttonSearchClear.Text = Configuration.Settings.Language.DvdSubRip.Clear; - - buttonUpdateAll.Visible = false; - DownloadPluginMetadataInfos(); - } - - private void DownloadPluginMetadataInfos() - { - try - { - labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; - Refresh(); - ShowInstalledPlugins(); - string url = GetPluginXmlFileUrl(); - var wc = new WebClient - { - Proxy = Utilities.GetProxy(), - Encoding = System.Text.Encoding.UTF8, - CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore) - }; - wc.Headers.Add("Accept-Encoding", ""); - wc.DownloadStringCompleted += wc_DownloadStringCompleted; - _fetchingData = true; - wc.DownloadStringAsync(new Uri(url)); - } - catch (Exception exception) - { - ChangeControlsState(true); - MessageBox.Show(exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace); - } - } - - private void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) - { - _fetchingData = false; - labelPleaseWait.Text = string.Empty; - if (e.Error != null) - { - MessageBox.Show(string.Format(_language.UnableToDownloadPluginListX, e.Error.Message)); - if (e.Error.InnerException != null) - { - MessageBox.Show(e.Error.InnerException.Source + ": " + e.Error.InnerException.Message + Environment.NewLine + Environment.NewLine + e.Error.InnerException.StackTrace); - } - return; - } - - var pluginDoc = new XmlDocument(); - _downloadList = new List(); - listViewGetPlugins.BeginUpdate(); - try - { - pluginDoc.LoadXml(e.Result); - string[] arr = pluginDoc.DocumentElement.SelectSingleNode("SubtitleEditVersion").InnerText.Split(new[] { '.', ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); - double requiredVersion = Convert.ToDouble(arr[0] + "." + arr[1], CultureInfo.InvariantCulture); - - string[] versionInfo = Utilities.AssemblyVersion.Split('.'); - double currentVersion = Convert.ToDouble(versionInfo[0] + "." + versionInfo[1], CultureInfo.InvariantCulture); - - if (currentVersion < requiredVersion) - { - MessageBox.Show(_language.NewVersionOfSubtitleEditRequired); - DialogResult = DialogResult.Cancel; - return; - } - - _updateAllListUrls = new List(); - LoadAvailablePlugins(pluginDoc); - ShowAvailablePlugins(); - } - catch (Exception exception) - { - MessageBox.Show(string.Format(_language.UnableToDownloadPluginListX, exception.Source + ": " + exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace)); - } - listViewGetPlugins.EndUpdate(); - - if (_updateAllListUrls.Count > 0) - { - buttonUpdateAll.BackColor = Color.LightGreen; - if (Configuration.Settings.Language.PluginsGet.UpdateAllX != null) - { - buttonUpdateAll.Text = string.Format(Configuration.Settings.Language.PluginsGet.UpdateAllX, _updateAllListUrls.Count); - } - else - { - buttonUpdateAll.Text = Configuration.Settings.Language.PluginsGet.UpdateAll; - } - - buttonUpdateAll.Visible = true; - } - } - - private void LoadAvailablePlugins(XmlDocument doc) - { - foreach (XmlNode node in doc.DocumentElement.SelectNodes("Plugin")) - { - var item = new PluginInfoItem - { - Name = node.SelectSingleNode("Name").InnerText.Trim('.'), - Description = node.SelectSingleNode("Description").InnerText.Trim('.'), - Version = node.SelectSingleNode("Version").InnerText, - Date = node.SelectSingleNode("Date").InnerText, - Url = node.SelectSingleNode("Url").InnerText, - }; - _downloadList.Add(item); - - foreach (ListViewItem installed in listViewInstalledPlugins.Items) - { - var installedVer = Convert.ToDouble(installed.SubItems[2].Text.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), CultureInfo.InvariantCulture); - var currentVer = Convert.ToDouble(node.SelectSingleNode("Version").InnerText.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), CultureInfo.InvariantCulture); - - if (string.Compare(installed.Text, node.SelectSingleNode("Name").InnerText.Trim('.'), StringComparison.OrdinalIgnoreCase) == 0 && installedVer < currentVer) - { - installed.BackColor = Color.LightPink; - installed.SubItems[1].Text = $"{_language.UpdateAvailable} {installed.SubItems[1].Text}"; - buttonUpdateAll.Visible = true; - _updateAllListUrls.Add(item.Url); - } - } - } - } - - private void ShowAvailablePlugins() - { - bool search = textBoxSearch.Text.Length > 1; - string searchText = textBoxSearch.Text; - listViewGetPlugins.BeginUpdate(); - if (listViewGetPlugins.Items.Count > 0) - { - listViewGetPlugins.Items.Clear(); - } - foreach (var plugin in _downloadList) - { - var item = new ListViewItem(plugin.Name) { Tag = plugin }; - item.SubItems.Add(plugin.Description); - item.SubItems.Add(plugin.Version); - item.SubItems.Add(plugin.Date); - - if (!search || - plugin.Name.Contains(searchText, StringComparison.OrdinalIgnoreCase) || - plugin.Description.Contains(searchText, StringComparison.OrdinalIgnoreCase) || - plugin.Version.Contains(searchText, StringComparison.OrdinalIgnoreCase)) - { - listViewGetPlugins.Items.Add(item); - } - } - listViewGetPlugins.EndUpdate(); - } - - private void ShowInstalledPlugins() - { - string path = Configuration.PluginsDirectory; - if (!Directory.Exists(path)) - { - return; - } - - listViewInstalledPlugins.BeginUpdate(); - listViewInstalledPlugins.Items.Clear(); - foreach (string pluginFileName in Directory.GetFiles(path, "*.DLL")) - { - Main.GetPropertiesAndDoAction(pluginFileName, out var name, out _, out var version, out var description, out var actionType, out _, out var mi); - if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(actionType) && mi != null) - { - try - { - var item = new ListViewItem(name.Trim('.')) { Tag = pluginFileName }; - item.SubItems.Add(description); - item.SubItems.Add(version.ToString(CultureInfo.InvariantCulture)); - item.SubItems.Add(actionType); - listViewInstalledPlugins.Items.Add(item); - } - catch (Exception exception) - { - MessageBox.Show($"Error loading plugin \"{pluginFileName}\": {exception.Message}"); - } - } - } - listViewInstalledPlugins.EndUpdate(); - } - - private void buttonDownload_Click(object sender, EventArgs e) - { - if (listViewGetPlugins.SelectedItems.Count == 0) - { - return; - } - - try - { - labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; - ChangeControlsState(false); - Refresh(); - Cursor = Cursors.WaitCursor; - - var plugin = (PluginInfoItem)listViewGetPlugins.SelectedItems[0].Tag; - - string url = plugin.Url; - _downloadedPluginName = plugin.Name; - - var wc = new WebClient { Proxy = Utilities.GetProxy(), CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore) }; - wc.DownloadDataCompleted += wc_DownloadDataCompleted; - wc.DownloadDataAsync(new Uri(url)); - } - catch (Exception exception) - { - ChangeControlsState(true); - Cursor = Cursors.Default; - MessageBox.Show(exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace); - } - } - - private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) - { - labelPleaseWait.Text = string.Empty; - if (e.Error != null) - { - MessageBox.Show(Configuration.Settings.Language.GetTesseractDictionaries.DownloadFailed); - ChangeControlsState(true); - Cursor = Cursors.Default; - DialogResult = DialogResult.Cancel; - return; - } - - string pluginsFolder = Configuration.PluginsDirectory; - if (!Directory.Exists(pluginsFolder)) - { - try - { - Directory.CreateDirectory(pluginsFolder); - } - catch (Exception exception) - { - MessageBox.Show($"Unable to create plugin folder {pluginsFolder}: {exception.Message}"); - ChangeControlsState(true); - Cursor = Cursors.Default; - return; - } - } - - var ms = new MemoryStream(e.Result); - using (ZipExtractor zip = ZipExtractor.Open(ms)) - { - List dir = zip.ReadCentralDir(); - - // Extract dic/aff files in dictionary folder - foreach (ZipExtractor.ZipFileEntry entry in dir) - { - string fileName = Path.GetFileName(entry.FilenameInZip); - string fullPath = Path.Combine(pluginsFolder, fileName); - if (File.Exists(fullPath)) - { - try - { - File.Delete(fullPath); - } - catch - { - MessageBox.Show($"{fullPath} already exists - unable to overwrite it"); - Cursor = Cursors.Default; - ChangeControlsState(true); - return; - } - } - zip.ExtractFile(entry, fullPath); - } - } - Cursor = Cursors.Default; - ChangeControlsState(true); - if (_updatingAllPlugins) - { - _updatingAllPluginsCount++; - if (_updatingAllPluginsCount == _updateAllListUrls.Count) - { - MessageBox.Show(string.Format(_language.XPluginsUpdated, _updatingAllPluginsCount)); - } - } - else - { - MessageBox.Show(string.Format(_language.PluginXDownloaded, _downloadedPluginName)); - } - ShowInstalledPlugins(); - - ((WebClient)sender).Dispose(); - } - - private void ChangeControlsState(bool enable) - { - if (enable) - { - labelPleaseWait.Text = string.Empty; - } - buttonOK.Enabled = enable; - buttonDownload.Enabled = enable; - listViewGetPlugins.Enabled = enable; - } - - private void linkLabelOpenDictionaryFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - string pluginsFolder = Configuration.PluginsDirectory; - if (!Directory.Exists(pluginsFolder)) - { - try - { - Directory.CreateDirectory(pluginsFolder); - } - catch (Exception exception) - { - MessageBox.Show($"Unable to create plugin folder {pluginsFolder}: {exception.Message}"); - return; - } - } - UiUtil.OpenFolder(pluginsFolder); - } - - private void PluginsGet_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#plugins"); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.F5 && !_fetchingData) - { - DownloadPluginMetadataInfos(); - } - } - - private void buttonRemove_Click(object sender, EventArgs e) - { - if (listViewInstalledPlugins.SelectedItems.Count < 1) - { - return; - } - - string fileName = listViewInstalledPlugins.SelectedItems[0].Tag.ToString(); - int index = listViewInstalledPlugins.SelectedItems[0].Index; - if (File.Exists(fileName)) - { - try - { - File.Delete(fileName); - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - return; - } - } - listViewInstalledPlugins.Items.RemoveAt(index); - if (index >= listViewInstalledPlugins.Items.Count) - { - index--; - } - - if (index >= 0) - { - listViewInstalledPlugins.Items[index].Selected = true; - listViewInstalledPlugins.Items[index].Focused = true; - } - buttonUpdateAll.Visible = false; - DownloadPluginMetadataInfos(); - } - - private void buttonUpdateAll_Click(object sender, EventArgs e) - { - buttonUpdateAll.Enabled = false; - buttonUpdateAll.BackColor = DefaultBackColor; - try - { - labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; - ChangeControlsState(false); - Refresh(); - Cursor = Cursors.WaitCursor; - _updatingAllPluginsCount = 0; - _updatingAllPlugins = true; - for (int i = 0; i < _updateAllListUrls.Count; i++) - { - var wc = new WebClient { Proxy = Utilities.GetProxy() }; - wc.DownloadDataCompleted += wc_DownloadDataCompleted; - wc.DownloadDataAsync(new Uri(_updateAllListUrls[i])); - } - } - catch (Exception exception) - { - ChangeControlsState(true); - Cursor = Cursors.Default; - MessageBox.Show(exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace); - } - } - - private void buttonSearchClear_Click(object sender, EventArgs e) - { - textBoxSearch.Text = string.Empty; - } - - private void textBoxSearch_TextChanged(object sender, EventArgs e) - { - listViewGetPlugins.BeginUpdate(); - listViewGetPlugins.Items.Clear(); - ShowAvailablePlugins(); - listViewGetPlugins.EndUpdate(); - buttonSearchClear.Enabled = textBoxSearch.Text.Length > 0; - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Net; +using System.Net.Cache; +using System.Windows.Forms; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class PluginsGet : Form + { + + public class PluginInfoItem + { + public string Version { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public string Date { get; set; } + public string Url { get; set; } + } + + private List _downloadList; + + private string _downloadedPluginName; + private readonly LanguageStructure.PluginsGet _language; + private List _updateAllListUrls; + private bool _updatingAllPlugins; + private int _updatingAllPluginsCount; + private bool _fetchingData; + + private static string GetPluginXmlFileUrl() + { + if (Environment.Version.Major < 4) + { + return "https://raw.github.com/SubtitleEdit/plugins/master/Plugins2.xml"; // .net 2-3.5 + } + + return "https://raw.github.com/SubtitleEdit/plugins/master/Plugins4.xml"; // .net 4-? + } + + public PluginsGet() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _language = Configuration.Settings.Language.PluginsGet; + Text = _language.Title; + tabPageInstalledPlugins.Text = _language.InstalledPlugins; + tabPageGetPlugins.Text = _language.GetPlugins; + + buttonDownload.Text = _language.Download; + buttonRemove.Text = _language.Remove; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + linkLabelOpenPluginFolder.Text = _language.OpenPluginsFolder; + labelDescription1.Text = _language.GetPluginsInfo1; + labelClickDownload.Text = _language.GetPluginsInfo2; + + columnHeaderName.Text = Configuration.Settings.Language.General.Name; + columnHeaderDescription.Text = _language.Description; + columnHeaderVersion.Text = _language.Version; + columnHeaderDate.Text = _language.Date; + + columnHeaderInsName.Text = Configuration.Settings.Language.General.Name; + columnHeaderInsDescription.Text = _language.Description; + columnHeaderInsVersion.Text = _language.Version; + columnHeaderInsType.Text = _language.Type; + + labelShortcutsSearch.Text = Configuration.Settings.Language.General.Search; + labelShortcutsSearch.Left = textBoxSearch.Left - labelShortcutsSearch.Width - 9; + buttonSearchClear.Text = Configuration.Settings.Language.DvdSubRip.Clear; + + buttonUpdateAll.Visible = false; + DownloadPluginMetadataInfos(); + } + + private void DownloadPluginMetadataInfos() + { + try + { + labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; + Refresh(); + ShowInstalledPlugins(); + string url = GetPluginXmlFileUrl(); + var wc = new WebClient + { + Proxy = Utilities.GetProxy(), + Encoding = System.Text.Encoding.UTF8, + CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore) + }; + wc.Headers.Add("Accept-Encoding", ""); + wc.DownloadStringCompleted += wc_DownloadStringCompleted; + _fetchingData = true; + wc.DownloadStringAsync(new Uri(url)); + } + catch (Exception exception) + { + ChangeControlsState(true); + MessageBox.Show(exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace); + } + } + + private void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) + { + _fetchingData = false; + labelPleaseWait.Text = string.Empty; + if (e.Error != null) + { + MessageBox.Show(string.Format(_language.UnableToDownloadPluginListX, e.Error.Message)); + if (e.Error.InnerException != null) + { + MessageBox.Show(e.Error.InnerException.Source + ": " + e.Error.InnerException.Message + Environment.NewLine + Environment.NewLine + e.Error.InnerException.StackTrace); + } + return; + } + + var pluginDoc = new XmlDocument(); + _downloadList = new List(); + listViewGetPlugins.BeginUpdate(); + try + { + pluginDoc.LoadXml(e.Result); + string[] arr = pluginDoc.DocumentElement.SelectSingleNode("SubtitleEditVersion").InnerText.Split(new[] { '.', ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); + double requiredVersion = Convert.ToDouble(arr[0] + "." + arr[1], CultureInfo.InvariantCulture); + + string[] versionInfo = Utilities.AssemblyVersion.Split('.'); + double currentVersion = Convert.ToDouble(versionInfo[0] + "." + versionInfo[1], CultureInfo.InvariantCulture); + + if (currentVersion < requiredVersion) + { + MessageBox.Show(_language.NewVersionOfSubtitleEditRequired); + DialogResult = DialogResult.Cancel; + return; + } + + _updateAllListUrls = new List(); + LoadAvailablePlugins(pluginDoc); + ShowAvailablePlugins(); + } + catch (Exception exception) + { + MessageBox.Show(string.Format(_language.UnableToDownloadPluginListX, exception.Source + ": " + exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace)); + } + listViewGetPlugins.EndUpdate(); + + if (_updateAllListUrls.Count > 0) + { + buttonUpdateAll.BackColor = Color.LightGreen; + if (Configuration.Settings.Language.PluginsGet.UpdateAllX != null) + { + buttonUpdateAll.Text = string.Format(Configuration.Settings.Language.PluginsGet.UpdateAllX, _updateAllListUrls.Count); + } + else + { + buttonUpdateAll.Text = Configuration.Settings.Language.PluginsGet.UpdateAll; + } + + buttonUpdateAll.Visible = true; + } + } + + private void LoadAvailablePlugins(XmlDocument doc) + { + foreach (XmlNode node in doc.DocumentElement.SelectNodes("Plugin")) + { + var item = new PluginInfoItem + { + Name = node.SelectSingleNode("Name").InnerText.Trim('.'), + Description = node.SelectSingleNode("Description").InnerText.Trim('.'), + Version = node.SelectSingleNode("Version").InnerText, + Date = node.SelectSingleNode("Date").InnerText, + Url = node.SelectSingleNode("Url").InnerText, + }; + _downloadList.Add(item); + + foreach (ListViewItem installed in listViewInstalledPlugins.Items) + { + var installedVer = Convert.ToDouble(installed.SubItems[2].Text.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), CultureInfo.InvariantCulture); + var currentVer = Convert.ToDouble(node.SelectSingleNode("Version").InnerText.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), CultureInfo.InvariantCulture); + + if (string.Compare(installed.Text, node.SelectSingleNode("Name").InnerText.Trim('.'), StringComparison.OrdinalIgnoreCase) == 0 && installedVer < currentVer) + { + installed.BackColor = Color.LightPink; + installed.SubItems[1].Text = $"{_language.UpdateAvailable} {installed.SubItems[1].Text}"; + buttonUpdateAll.Visible = true; + _updateAllListUrls.Add(item.Url); + } + } + } + } + + private void ShowAvailablePlugins() + { + bool search = textBoxSearch.Text.Length > 1; + string searchText = textBoxSearch.Text; + listViewGetPlugins.BeginUpdate(); + if (listViewGetPlugins.Items.Count > 0) + { + listViewGetPlugins.Items.Clear(); + } + foreach (var plugin in _downloadList) + { + var item = new ListViewItem(plugin.Name) { Tag = plugin }; + item.SubItems.Add(plugin.Description); + item.SubItems.Add(plugin.Version); + item.SubItems.Add(plugin.Date); + + if (!search || + plugin.Name.Contains(searchText, StringComparison.OrdinalIgnoreCase) || + plugin.Description.Contains(searchText, StringComparison.OrdinalIgnoreCase) || + plugin.Version.Contains(searchText, StringComparison.OrdinalIgnoreCase)) + { + listViewGetPlugins.Items.Add(item); + } + } + listViewGetPlugins.EndUpdate(); + } + + private void ShowInstalledPlugins() + { + string path = Configuration.PluginsDirectory; + if (!Directory.Exists(path)) + { + return; + } + + listViewInstalledPlugins.BeginUpdate(); + listViewInstalledPlugins.Items.Clear(); + foreach (string pluginFileName in Directory.GetFiles(path, "*.DLL")) + { + Main.GetPropertiesAndDoAction(pluginFileName, out var name, out _, out var version, out var description, out var actionType, out _, out var mi); + if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(actionType) && mi != null) + { + try + { + var item = new ListViewItem(name.Trim('.')) { Tag = pluginFileName }; + item.SubItems.Add(description); + item.SubItems.Add(version.ToString(CultureInfo.InvariantCulture)); + item.SubItems.Add(actionType); + listViewInstalledPlugins.Items.Add(item); + } + catch (Exception exception) + { + MessageBox.Show($"Error loading plugin \"{pluginFileName}\": {exception.Message}"); + } + } + } + listViewInstalledPlugins.EndUpdate(); + } + + private void buttonDownload_Click(object sender, EventArgs e) + { + if (listViewGetPlugins.SelectedItems.Count == 0) + { + return; + } + + try + { + labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; + ChangeControlsState(false); + Refresh(); + Cursor = Cursors.WaitCursor; + + var plugin = (PluginInfoItem)listViewGetPlugins.SelectedItems[0].Tag; + + string url = plugin.Url; + _downloadedPluginName = plugin.Name; + + var wc = new WebClient { Proxy = Utilities.GetProxy(), CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore) }; + wc.DownloadDataCompleted += wc_DownloadDataCompleted; + wc.DownloadDataAsync(new Uri(url)); + } + catch (Exception exception) + { + ChangeControlsState(true); + Cursor = Cursors.Default; + MessageBox.Show(exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace); + } + } + + private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) + { + labelPleaseWait.Text = string.Empty; + if (e.Error != null) + { + MessageBox.Show(Configuration.Settings.Language.GetTesseractDictionaries.DownloadFailed); + ChangeControlsState(true); + Cursor = Cursors.Default; + DialogResult = DialogResult.Cancel; + return; + } + + string pluginsFolder = Configuration.PluginsDirectory; + if (!Directory.Exists(pluginsFolder)) + { + try + { + Directory.CreateDirectory(pluginsFolder); + } + catch (Exception exception) + { + MessageBox.Show($"Unable to create plugin folder {pluginsFolder}: {exception.Message}"); + ChangeControlsState(true); + Cursor = Cursors.Default; + return; + } + } + + var ms = new MemoryStream(e.Result); + using (ZipExtractor zip = ZipExtractor.Open(ms)) + { + List dir = zip.ReadCentralDir(); + + // Extract dic/aff files in dictionary folder + foreach (ZipExtractor.ZipFileEntry entry in dir) + { + string fileName = Path.GetFileName(entry.FilenameInZip); + string fullPath = Path.Combine(pluginsFolder, fileName); + if (File.Exists(fullPath)) + { + try + { + File.Delete(fullPath); + } + catch + { + MessageBox.Show($"{fullPath} already exists - unable to overwrite it"); + Cursor = Cursors.Default; + ChangeControlsState(true); + return; + } + } + zip.ExtractFile(entry, fullPath); + } + } + Cursor = Cursors.Default; + ChangeControlsState(true); + if (_updatingAllPlugins) + { + _updatingAllPluginsCount++; + if (_updatingAllPluginsCount == _updateAllListUrls.Count) + { + MessageBox.Show(string.Format(_language.XPluginsUpdated, _updatingAllPluginsCount)); + } + } + else + { + MessageBox.Show(string.Format(_language.PluginXDownloaded, _downloadedPluginName)); + } + ShowInstalledPlugins(); + + ((WebClient)sender).Dispose(); + } + + private void ChangeControlsState(bool enable) + { + if (enable) + { + labelPleaseWait.Text = string.Empty; + } + buttonOK.Enabled = enable; + buttonDownload.Enabled = enable; + listViewGetPlugins.Enabled = enable; + } + + private void linkLabelOpenDictionaryFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + string pluginsFolder = Configuration.PluginsDirectory; + if (!Directory.Exists(pluginsFolder)) + { + try + { + Directory.CreateDirectory(pluginsFolder); + } + catch (Exception exception) + { + MessageBox.Show($"Unable to create plugin folder {pluginsFolder}: {exception.Message}"); + return; + } + } + UiUtil.OpenFolder(pluginsFolder); + } + + private void PluginsGet_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#plugins"); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.F5 && !_fetchingData) + { + DownloadPluginMetadataInfos(); + } + } + + private void buttonRemove_Click(object sender, EventArgs e) + { + if (listViewInstalledPlugins.SelectedItems.Count < 1) + { + return; + } + + string fileName = listViewInstalledPlugins.SelectedItems[0].Tag.ToString(); + int index = listViewInstalledPlugins.SelectedItems[0].Index; + if (File.Exists(fileName)) + { + try + { + File.Delete(fileName); + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + return; + } + } + listViewInstalledPlugins.Items.RemoveAt(index); + if (index >= listViewInstalledPlugins.Items.Count) + { + index--; + } + + if (index >= 0) + { + listViewInstalledPlugins.Items[index].Selected = true; + listViewInstalledPlugins.Items[index].Focused = true; + } + buttonUpdateAll.Visible = false; + DownloadPluginMetadataInfos(); + } + + private void buttonUpdateAll_Click(object sender, EventArgs e) + { + buttonUpdateAll.Enabled = false; + buttonUpdateAll.BackColor = DefaultBackColor; + try + { + labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; + ChangeControlsState(false); + Refresh(); + Cursor = Cursors.WaitCursor; + _updatingAllPluginsCount = 0; + _updatingAllPlugins = true; + for (int i = 0; i < _updateAllListUrls.Count; i++) + { + var wc = new WebClient { Proxy = Utilities.GetProxy() }; + wc.DownloadDataCompleted += wc_DownloadDataCompleted; + wc.DownloadDataAsync(new Uri(_updateAllListUrls[i])); + } + } + catch (Exception exception) + { + ChangeControlsState(true); + Cursor = Cursors.Default; + MessageBox.Show(exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace); + } + } + + private void buttonSearchClear_Click(object sender, EventArgs e) + { + textBoxSearch.Text = string.Empty; + } + + private void textBoxSearch_TextChanged(object sender, EventArgs e) + { + listViewGetPlugins.BeginUpdate(); + listViewGetPlugins.Items.Clear(); + ShowAvailablePlugins(); + listViewGetPlugins.EndUpdate(); + buttonSearchClear.Enabled = textBoxSearch.Text.Length > 0; + } + } +} diff --git a/src/Forms/PluginsGet.resx b/src/ui/Forms/PluginsGet.resx similarity index 97% rename from src/Forms/PluginsGet.resx rename to src/ui/Forms/PluginsGet.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/PluginsGet.resx +++ b/src/ui/Forms/PluginsGet.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/PositionAndSizeForm.cs b/src/ui/Forms/PositionAndSizeForm.cs similarity index 100% rename from src/Forms/PositionAndSizeForm.cs rename to src/ui/Forms/PositionAndSizeForm.cs diff --git a/src/Forms/ProfileChoose.Designer.cs b/src/ui/Forms/ProfileChoose.Designer.cs similarity index 100% rename from src/Forms/ProfileChoose.Designer.cs rename to src/ui/Forms/ProfileChoose.Designer.cs diff --git a/src/Forms/ProfileChoose.cs b/src/ui/Forms/ProfileChoose.cs similarity index 100% rename from src/Forms/ProfileChoose.cs rename to src/ui/Forms/ProfileChoose.cs diff --git a/src/ui/Forms/ProfileChoose.resx b/src/ui/Forms/ProfileChoose.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/src/ui/Forms/ProfileChoose.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Forms/RemoveTextFromHearImpaired.Designer.cs b/src/ui/Forms/RemoveTextFromHearImpaired.Designer.cs similarity index 98% rename from src/Forms/RemoveTextFromHearImpaired.Designer.cs rename to src/ui/Forms/RemoveTextFromHearImpaired.Designer.cs index 46abed379..ed85b5caa 100644 --- a/src/Forms/RemoveTextFromHearImpaired.Designer.cs +++ b/src/ui/Forms/RemoveTextFromHearImpaired.Designer.cs @@ -1,532 +1,532 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class FormRemoveTextForHearImpaired - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); - this.listViewFixes = new System.Windows.Forms.ListView(); - this.columnHeaderApply = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderLine = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderBefore = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderAfter = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemSelAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInvertSel = new System.Windows.Forms.ToolStripMenuItem(); - this.checkBoxRemoveTextBeforeColon = new System.Windows.Forms.CheckBox(); - this.groupBoxRemoveTextConditions = new System.Windows.Forms.GroupBox(); - this.checkBoxInterjectionOnlySeparateLine = new System.Windows.Forms.CheckBox(); - this.checkBoxRemoveIfAllUppercase = new System.Windows.Forms.CheckBox(); - this.checkBoxColonSeparateLine = new System.Windows.Forms.CheckBox(); - this.buttonEditInterjections = new System.Windows.Forms.Button(); - this.checkBoxRemoveInterjections = new System.Windows.Forms.CheckBox(); - this.labelRemoveTextBetween = new System.Windows.Forms.Label(); - this.comboBoxRemoveIfTextContains = new System.Windows.Forms.ComboBox(); - this.checkBoxRemoveWhereContains = new System.Windows.Forms.CheckBox(); - this.comboBoxCustomEnd = new System.Windows.Forms.ComboBox(); - this.comboBoxCustomStart = new System.Windows.Forms.ComboBox(); - this.checkBoxRemoveTextBeforeColonOnlyUppercase = new System.Windows.Forms.CheckBox(); - this.checkBoxOnlyIfInSeparateLine = new System.Windows.Forms.CheckBox(); - this.checkBoxRemoveTextBetweenCustomTags = new System.Windows.Forms.CheckBox(); - this.checkBoxRemoveTextBetweenQuestionMarks = new System.Windows.Forms.CheckBox(); - this.checkBoxRemoveTextBetweenParentheses = new System.Windows.Forms.CheckBox(); - this.checkBoxRemoveTextBetweenBrackets = new System.Windows.Forms.CheckBox(); - this.checkBoxRemoveTextBetweenSquares = new System.Windows.Forms.CheckBox(); - this.labelAnd = new System.Windows.Forms.Label(); - this.buttonApply = new System.Windows.Forms.Button(); - this.textBoxAfterText = new System.Windows.Forms.TextBox(); - this.labelText = new System.Windows.Forms.Label(); - this.groupBoxLinesFound.SuspendLayout(); - this.contextMenuStrip1.SuspendLayout(); - this.groupBoxRemoveTextConditions.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(716, 563); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(797, 563); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // groupBoxLinesFound - // - this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxLinesFound.Controls.Add(this.listViewFixes); - this.groupBoxLinesFound.Location = new System.Drawing.Point(12, 222); - this.groupBoxLinesFound.Name = "groupBoxLinesFound"; - this.groupBoxLinesFound.Size = new System.Drawing.Size(941, 291); - this.groupBoxLinesFound.TabIndex = 1; - this.groupBoxLinesFound.TabStop = false; - this.groupBoxLinesFound.Text = "Lines found"; - // - // listViewFixes - // - this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewFixes.CheckBoxes = true; - this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderApply, - this.columnHeaderLine, - this.columnHeaderBefore, - this.columnHeaderAfter}); - this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; - this.listViewFixes.FullRowSelect = true; - this.listViewFixes.HideSelection = false; - this.listViewFixes.Location = new System.Drawing.Point(6, 17); - this.listViewFixes.Name = "listViewFixes"; - this.listViewFixes.Size = new System.Drawing.Size(929, 268); - this.listViewFixes.TabIndex = 0; - this.listViewFixes.UseCompatibleStateImageBehavior = false; - this.listViewFixes.View = System.Windows.Forms.View.Details; - this.listViewFixes.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listViewFixes_ItemChecked); - this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged); - // - // columnHeaderApply - // - this.columnHeaderApply.Text = "Apply"; - this.columnHeaderApply.Width = 45; - // - // columnHeaderLine - // - this.columnHeaderLine.Text = "Line#"; - this.columnHeaderLine.Width = 61; - // - // columnHeaderBefore - // - this.columnHeaderBefore.Text = "Before"; - this.columnHeaderBefore.Width = 401; - // - // columnHeaderAfter - // - this.columnHeaderAfter.Text = "After"; - this.columnHeaderAfter.Width = 395; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemSelAll, - this.toolStripMenuItemInvertSel}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(155, 48); - // - // toolStripMenuItemSelAll - // - this.toolStripMenuItemSelAll.Name = "toolStripMenuItemSelAll"; - this.toolStripMenuItemSelAll.Size = new System.Drawing.Size(154, 22); - this.toolStripMenuItemSelAll.Text = "Select all"; - this.toolStripMenuItemSelAll.Click += new System.EventHandler(this.toolStripMenuItemSelAll_Click); - // - // toolStripMenuItemInvertSel - // - this.toolStripMenuItemInvertSel.Name = "toolStripMenuItemInvertSel"; - this.toolStripMenuItemInvertSel.Size = new System.Drawing.Size(154, 22); - this.toolStripMenuItemInvertSel.Text = "Invert selection"; - this.toolStripMenuItemInvertSel.Click += new System.EventHandler(this.toolStripMenuItemInvertSel_Click); - // - // checkBoxRemoveTextBeforeColon - // - this.checkBoxRemoveTextBeforeColon.AutoSize = true; - this.checkBoxRemoveTextBeforeColon.Checked = true; - this.checkBoxRemoveTextBeforeColon.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxRemoveTextBeforeColon.Location = new System.Drawing.Point(241, 26); - this.checkBoxRemoveTextBeforeColon.Name = "checkBoxRemoveTextBeforeColon"; - this.checkBoxRemoveTextBeforeColon.Size = new System.Drawing.Size(175, 17); - this.checkBoxRemoveTextBeforeColon.TabIndex = 10; - this.checkBoxRemoveTextBeforeColon.Text = "Remove text before a colon (:)"; - this.checkBoxRemoveTextBeforeColon.UseVisualStyleBackColor = true; - this.checkBoxRemoveTextBeforeColon.CheckedChanged += new System.EventHandler(this.checkBoxRemoveTextBeforeColon_CheckedChanged); - // - // groupBoxRemoveTextConditions - // - this.groupBoxRemoveTextConditions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxInterjectionOnlySeparateLine); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveIfAllUppercase); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxColonSeparateLine); - this.groupBoxRemoveTextConditions.Controls.Add(this.buttonEditInterjections); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveInterjections); - this.groupBoxRemoveTextConditions.Controls.Add(this.labelRemoveTextBetween); - this.groupBoxRemoveTextConditions.Controls.Add(this.comboBoxRemoveIfTextContains); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveWhereContains); - this.groupBoxRemoveTextConditions.Controls.Add(this.comboBoxCustomEnd); - this.groupBoxRemoveTextConditions.Controls.Add(this.comboBoxCustomStart); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBeforeColonOnlyUppercase); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBeforeColon); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxOnlyIfInSeparateLine); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBetweenCustomTags); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBetweenQuestionMarks); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBetweenParentheses); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBetweenBrackets); - this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBetweenSquares); - this.groupBoxRemoveTextConditions.Controls.Add(this.labelAnd); - this.groupBoxRemoveTextConditions.Location = new System.Drawing.Point(12, 12); - this.groupBoxRemoveTextConditions.Name = "groupBoxRemoveTextConditions"; - this.groupBoxRemoveTextConditions.Size = new System.Drawing.Size(941, 204); - this.groupBoxRemoveTextConditions.TabIndex = 0; - this.groupBoxRemoveTextConditions.TabStop = false; - this.groupBoxRemoveTextConditions.Text = "Remove text conditions"; - // - // checkBoxInterjectionOnlySeparateLine - // - this.checkBoxInterjectionOnlySeparateLine.AutoSize = true; - this.checkBoxInterjectionOnlySeparateLine.Location = new System.Drawing.Point(600, 53); - this.checkBoxInterjectionOnlySeparateLine.Name = "checkBoxInterjectionOnlySeparateLine"; - this.checkBoxInterjectionOnlySeparateLine.Size = new System.Drawing.Size(137, 17); - this.checkBoxInterjectionOnlySeparateLine.TabIndex = 18; - this.checkBoxInterjectionOnlySeparateLine.Text = "Only if on separate line"; - this.checkBoxInterjectionOnlySeparateLine.UseVisualStyleBackColor = true; - this.checkBoxInterjectionOnlySeparateLine.CheckedChanged += new System.EventHandler(this.checkBoxInterjectionOnlySeparateLine_CheckedChanged); - // - // checkBoxRemoveIfAllUppercase - // - this.checkBoxRemoveIfAllUppercase.AutoSize = true; - this.checkBoxRemoveIfAllUppercase.Checked = true; - this.checkBoxRemoveIfAllUppercase.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxRemoveIfAllUppercase.Location = new System.Drawing.Point(241, 102); - this.checkBoxRemoveIfAllUppercase.Name = "checkBoxRemoveIfAllUppercase"; - this.checkBoxRemoveIfAllUppercase.Size = new System.Drawing.Size(142, 17); - this.checkBoxRemoveIfAllUppercase.TabIndex = 13; - this.checkBoxRemoveIfAllUppercase.Text = "Remove uppercase lines"; - this.checkBoxRemoveIfAllUppercase.UseVisualStyleBackColor = true; - this.checkBoxRemoveIfAllUppercase.CheckedChanged += new System.EventHandler(this.checkBoxRemoveIfAllUppercase_CheckedChanged); - // - // checkBoxColonSeparateLine - // - this.checkBoxColonSeparateLine.AutoSize = true; - this.checkBoxColonSeparateLine.Location = new System.Drawing.Point(261, 69); - this.checkBoxColonSeparateLine.Name = "checkBoxColonSeparateLine"; - this.checkBoxColonSeparateLine.Size = new System.Drawing.Size(137, 17); - this.checkBoxColonSeparateLine.TabIndex = 12; - this.checkBoxColonSeparateLine.Text = "Only if on separate line"; - this.checkBoxColonSeparateLine.UseVisualStyleBackColor = true; - this.checkBoxColonSeparateLine.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); - // - // buttonEditInterjections - // - this.buttonEditInterjections.Location = new System.Drawing.Point(718, 26); - this.buttonEditInterjections.Name = "buttonEditInterjections"; - this.buttonEditInterjections.Size = new System.Drawing.Size(103, 23); - this.buttonEditInterjections.TabIndex = 17; - this.buttonEditInterjections.Text = "Edit..."; - this.buttonEditInterjections.UseVisualStyleBackColor = true; - this.buttonEditInterjections.Click += new System.EventHandler(this.buttonEditInterjections_Click); - // - // checkBoxRemoveInterjections - // - this.checkBoxRemoveInterjections.AutoSize = true; - this.checkBoxRemoveInterjections.Location = new System.Drawing.Point(582, 30); - this.checkBoxRemoveInterjections.Name = "checkBoxRemoveInterjections"; - this.checkBoxRemoveInterjections.Size = new System.Drawing.Size(130, 17); - this.checkBoxRemoveInterjections.TabIndex = 16; - this.checkBoxRemoveInterjections.Text = "Remove interjections "; - this.checkBoxRemoveInterjections.UseVisualStyleBackColor = true; - this.checkBoxRemoveInterjections.CheckedChanged += new System.EventHandler(this.checkBoxRemoveInterjections_CheckedChanged); - // - // labelRemoveTextBetween - // - this.labelRemoveTextBetween.AutoSize = true; - this.labelRemoveTextBetween.Location = new System.Drawing.Point(8, 26); - this.labelRemoveTextBetween.Name = "labelRemoveTextBetween"; - this.labelRemoveTextBetween.Size = new System.Drawing.Size(114, 13); - this.labelRemoveTextBetween.TabIndex = 0; - this.labelRemoveTextBetween.Text = "Remove text between"; - // - // comboBoxRemoveIfTextContains - // - this.comboBoxRemoveIfTextContains.FormattingEnabled = true; - this.comboBoxRemoveIfTextContains.Items.AddRange(new object[] { - "¶", - "♪", - "♫", - "♪,♫"}); - this.comboBoxRemoveIfTextContains.Location = new System.Drawing.Point(427, 131); - this.comboBoxRemoveIfTextContains.MaxLength = 10; - this.comboBoxRemoveIfTextContains.Name = "comboBoxRemoveIfTextContains"; - this.comboBoxRemoveIfTextContains.Size = new System.Drawing.Size(100, 21); - this.comboBoxRemoveIfTextContains.TabIndex = 15; - this.comboBoxRemoveIfTextContains.Text = "¶"; - this.comboBoxRemoveIfTextContains.TextChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); - // - // checkBoxRemoveWhereContains - // - this.checkBoxRemoveWhereContains.AutoSize = true; - this.checkBoxRemoveWhereContains.Location = new System.Drawing.Point(241, 135); - this.checkBoxRemoveWhereContains.Name = "checkBoxRemoveWhereContains"; - this.checkBoxRemoveWhereContains.Size = new System.Drawing.Size(153, 17); - this.checkBoxRemoveWhereContains.TabIndex = 14; - this.checkBoxRemoveWhereContains.Text = "Remove text if it contains:"; - this.checkBoxRemoveWhereContains.UseVisualStyleBackColor = true; - this.checkBoxRemoveWhereContains.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); - // - // comboBoxCustomEnd - // - this.comboBoxCustomEnd.FormattingEnabled = true; - this.comboBoxCustomEnd.Items.AddRange(new object[] { - "¶", - "♪", - "♫"}); - this.comboBoxCustomEnd.Location = new System.Drawing.Point(116, 135); - this.comboBoxCustomEnd.MaxLength = 2; - this.comboBoxCustomEnd.Name = "comboBoxCustomEnd"; - this.comboBoxCustomEnd.Size = new System.Drawing.Size(38, 21); - this.comboBoxCustomEnd.TabIndex = 8; - this.comboBoxCustomEnd.Text = "¶"; - this.comboBoxCustomEnd.TextChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); - // - // comboBoxCustomStart - // - this.comboBoxCustomStart.FormattingEnabled = true; - this.comboBoxCustomStart.Items.AddRange(new object[] { - "¶", - "♪", - "♫"}); - this.comboBoxCustomStart.Location = new System.Drawing.Point(41, 135); - this.comboBoxCustomStart.MaxLength = 2; - this.comboBoxCustomStart.Name = "comboBoxCustomStart"; - this.comboBoxCustomStart.Size = new System.Drawing.Size(38, 21); - this.comboBoxCustomStart.TabIndex = 6; - this.comboBoxCustomStart.Text = "¶"; - this.comboBoxCustomStart.TextChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); - // - // checkBoxRemoveTextBeforeColonOnlyUppercase - // - this.checkBoxRemoveTextBeforeColonOnlyUppercase.AutoSize = true; - this.checkBoxRemoveTextBeforeColonOnlyUppercase.Location = new System.Drawing.Point(261, 46); - this.checkBoxRemoveTextBeforeColonOnlyUppercase.Name = "checkBoxRemoveTextBeforeColonOnlyUppercase"; - this.checkBoxRemoveTextBeforeColonOnlyUppercase.Size = new System.Drawing.Size(151, 17); - this.checkBoxRemoveTextBeforeColonOnlyUppercase.TabIndex = 11; - this.checkBoxRemoveTextBeforeColonOnlyUppercase.Text = "Only if text is UPPERCASE"; - this.checkBoxRemoveTextBeforeColonOnlyUppercase.UseVisualStyleBackColor = true; - this.checkBoxRemoveTextBeforeColonOnlyUppercase.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); - // - // checkBoxOnlyIfInSeparateLine - // - this.checkBoxOnlyIfInSeparateLine.AutoSize = true; - this.checkBoxOnlyIfInSeparateLine.Location = new System.Drawing.Point(21, 172); - this.checkBoxOnlyIfInSeparateLine.Name = "checkBoxOnlyIfInSeparateLine"; - this.checkBoxOnlyIfInSeparateLine.Size = new System.Drawing.Size(137, 17); - this.checkBoxOnlyIfInSeparateLine.TabIndex = 9; - this.checkBoxOnlyIfInSeparateLine.Text = "Only if on separate line"; - this.checkBoxOnlyIfInSeparateLine.UseVisualStyleBackColor = true; - this.checkBoxOnlyIfInSeparateLine.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); - // - // checkBoxRemoveTextBetweenCustomTags - // - this.checkBoxRemoveTextBetweenCustomTags.AutoSize = true; - this.checkBoxRemoveTextBetweenCustomTags.Checked = true; - this.checkBoxRemoveTextBetweenCustomTags.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxRemoveTextBetweenCustomTags.Location = new System.Drawing.Point(20, 138); - this.checkBoxRemoveTextBetweenCustomTags.Name = "checkBoxRemoveTextBetweenCustomTags"; - this.checkBoxRemoveTextBetweenCustomTags.Size = new System.Drawing.Size(15, 14); - this.checkBoxRemoveTextBetweenCustomTags.TabIndex = 5; - this.checkBoxRemoveTextBetweenCustomTags.UseVisualStyleBackColor = true; - this.checkBoxRemoveTextBetweenCustomTags.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); - // - // checkBoxRemoveTextBetweenQuestionMarks - // - this.checkBoxRemoveTextBetweenQuestionMarks.AutoSize = true; - this.checkBoxRemoveTextBetweenQuestionMarks.Checked = true; - this.checkBoxRemoveTextBetweenQuestionMarks.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxRemoveTextBetweenQuestionMarks.Location = new System.Drawing.Point(20, 115); - this.checkBoxRemoveTextBetweenQuestionMarks.Name = "checkBoxRemoveTextBetweenQuestionMarks"; - this.checkBoxRemoveTextBetweenQuestionMarks.Size = new System.Drawing.Size(76, 17); - this.checkBoxRemoveTextBetweenQuestionMarks.TabIndex = 4; - this.checkBoxRemoveTextBetweenQuestionMarks.Text = "\"?\" and \"?\""; - this.checkBoxRemoveTextBetweenQuestionMarks.UseVisualStyleBackColor = true; - this.checkBoxRemoveTextBetweenQuestionMarks.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); - // - // checkBoxRemoveTextBetweenParentheses - // - this.checkBoxRemoveTextBetweenParentheses.AutoSize = true; - this.checkBoxRemoveTextBetweenParentheses.Checked = true; - this.checkBoxRemoveTextBetweenParentheses.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxRemoveTextBetweenParentheses.Location = new System.Drawing.Point(20, 69); - this.checkBoxRemoveTextBetweenParentheses.Name = "checkBoxRemoveTextBetweenParentheses"; - this.checkBoxRemoveTextBetweenParentheses.Size = new System.Drawing.Size(74, 17); - this.checkBoxRemoveTextBetweenParentheses.TabIndex = 2; - this.checkBoxRemoveTextBetweenParentheses.Text = "\"(\" and \")\""; - this.checkBoxRemoveTextBetweenParentheses.UseVisualStyleBackColor = true; - this.checkBoxRemoveTextBetweenParentheses.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); - // - // checkBoxRemoveTextBetweenBrackets - // - this.checkBoxRemoveTextBetweenBrackets.AutoSize = true; - this.checkBoxRemoveTextBetweenBrackets.Checked = true; - this.checkBoxRemoveTextBetweenBrackets.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxRemoveTextBetweenBrackets.Location = new System.Drawing.Point(20, 92); - this.checkBoxRemoveTextBetweenBrackets.Name = "checkBoxRemoveTextBetweenBrackets"; - this.checkBoxRemoveTextBetweenBrackets.Size = new System.Drawing.Size(76, 17); - this.checkBoxRemoveTextBetweenBrackets.TabIndex = 3; - this.checkBoxRemoveTextBetweenBrackets.Text = "\"{\" and \"}\""; - this.checkBoxRemoveTextBetweenBrackets.UseVisualStyleBackColor = true; - this.checkBoxRemoveTextBetweenBrackets.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); - // - // checkBoxRemoveTextBetweenSquares - // - this.checkBoxRemoveTextBetweenSquares.AutoSize = true; - this.checkBoxRemoveTextBetweenSquares.Checked = true; - this.checkBoxRemoveTextBetweenSquares.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBoxRemoveTextBetweenSquares.Location = new System.Drawing.Point(20, 45); - this.checkBoxRemoveTextBetweenSquares.Name = "checkBoxRemoveTextBetweenSquares"; - this.checkBoxRemoveTextBetweenSquares.Size = new System.Drawing.Size(74, 17); - this.checkBoxRemoveTextBetweenSquares.TabIndex = 1; - this.checkBoxRemoveTextBetweenSquares.Text = "\"[\" and \"]\""; - this.checkBoxRemoveTextBetweenSquares.UseVisualStyleBackColor = true; - this.checkBoxRemoveTextBetweenSquares.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); - // - // labelAnd - // - this.labelAnd.AutoSize = true; - this.labelAnd.Location = new System.Drawing.Point(85, 141); - this.labelAnd.Name = "labelAnd"; - this.labelAnd.Size = new System.Drawing.Size(25, 13); - this.labelAnd.TabIndex = 7; - this.labelAnd.Text = "and"; - // - // buttonApply - // - this.buttonApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonApply.Location = new System.Drawing.Point(878, 563); - this.buttonApply.Name = "buttonApply"; - this.buttonApply.Size = new System.Drawing.Size(75, 23); - this.buttonApply.TabIndex = 5; - this.buttonApply.Text = "Apply"; - this.buttonApply.UseVisualStyleBackColor = true; - this.buttonApply.Click += new System.EventHandler(this.buttonApply_Click); - // - // textBoxAfterText - // - this.textBoxAfterText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.textBoxAfterText.Location = new System.Drawing.Point(12, 543); - this.textBoxAfterText.Multiline = true; - this.textBoxAfterText.Name = "textBoxAfterText"; - this.textBoxAfterText.Size = new System.Drawing.Size(394, 43); - this.textBoxAfterText.TabIndex = 2; - this.textBoxAfterText.TextChanged += new System.EventHandler(this.textBoxAfterText_TextChanged); - // - // labelText - // - this.labelText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelText.AutoSize = true; - this.labelText.Location = new System.Drawing.Point(12, 527); - this.labelText.Name = "labelText"; - this.labelText.Size = new System.Drawing.Size(29, 13); - this.labelText.TabIndex = 6; - this.labelText.Text = "Text"; - // - // FormRemoveTextForHearImpaired - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(965, 598); - this.Controls.Add(this.labelText); - this.Controls.Add(this.textBoxAfterText); - this.Controls.Add(this.buttonApply); - this.Controls.Add(this.groupBoxRemoveTextConditions); - this.Controls.Add(this.groupBoxLinesFound); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(705, 514); - this.Name = "FormRemoveTextForHearImpaired"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Remove text for hearing impaired"; - this.Load += new System.EventHandler(this.FormRemoveTextForHearImpaired_Load); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormRemoveTextForHearImpaired_KeyDown); - this.Resize += new System.EventHandler(this.FormRemoveTextForHearImpaired_Resize); - this.groupBoxLinesFound.ResumeLayout(false); - this.contextMenuStrip1.ResumeLayout(false); - this.groupBoxRemoveTextConditions.ResumeLayout(false); - this.groupBoxRemoveTextConditions.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.GroupBox groupBoxLinesFound; - private System.Windows.Forms.ListView listViewFixes; - private System.Windows.Forms.ColumnHeader columnHeaderApply; - private System.Windows.Forms.ColumnHeader columnHeaderLine; - private System.Windows.Forms.ColumnHeader columnHeaderBefore; - private System.Windows.Forms.ColumnHeader columnHeaderAfter; - private System.Windows.Forms.CheckBox checkBoxRemoveTextBeforeColon; - private System.Windows.Forms.GroupBox groupBoxRemoveTextConditions; - private System.Windows.Forms.CheckBox checkBoxRemoveTextBetweenCustomTags; - private System.Windows.Forms.CheckBox checkBoxRemoveTextBetweenQuestionMarks; - private System.Windows.Forms.CheckBox checkBoxRemoveTextBetweenParentheses; - private System.Windows.Forms.CheckBox checkBoxRemoveTextBetweenBrackets; - private System.Windows.Forms.CheckBox checkBoxRemoveTextBetweenSquares; - private System.Windows.Forms.Label labelAnd; - private System.Windows.Forms.CheckBox checkBoxRemoveTextBeforeColonOnlyUppercase; - private System.Windows.Forms.CheckBox checkBoxOnlyIfInSeparateLine; - private System.Windows.Forms.ComboBox comboBoxCustomStart; - private System.Windows.Forms.ComboBox comboBoxCustomEnd; - private System.Windows.Forms.ComboBox comboBoxRemoveIfTextContains; - private System.Windows.Forms.CheckBox checkBoxRemoveWhereContains; - private System.Windows.Forms.Label labelRemoveTextBetween; - private System.Windows.Forms.CheckBox checkBoxRemoveInterjections; - private System.Windows.Forms.Button buttonEditInterjections; - private System.Windows.Forms.CheckBox checkBoxColonSeparateLine; - private System.Windows.Forms.CheckBox checkBoxRemoveIfAllUppercase; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelAll; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInvertSel; - private System.Windows.Forms.Button buttonApply; - private System.Windows.Forms.CheckBox checkBoxInterjectionOnlySeparateLine; - private System.Windows.Forms.TextBox textBoxAfterText; - private System.Windows.Forms.Label labelText; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class FormRemoveTextForHearImpaired + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); + this.listViewFixes = new System.Windows.Forms.ListView(); + this.columnHeaderApply = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderLine = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderBefore = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderAfter = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemSelAll = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInvertSel = new System.Windows.Forms.ToolStripMenuItem(); + this.checkBoxRemoveTextBeforeColon = new System.Windows.Forms.CheckBox(); + this.groupBoxRemoveTextConditions = new System.Windows.Forms.GroupBox(); + this.checkBoxInterjectionOnlySeparateLine = new System.Windows.Forms.CheckBox(); + this.checkBoxRemoveIfAllUppercase = new System.Windows.Forms.CheckBox(); + this.checkBoxColonSeparateLine = new System.Windows.Forms.CheckBox(); + this.buttonEditInterjections = new System.Windows.Forms.Button(); + this.checkBoxRemoveInterjections = new System.Windows.Forms.CheckBox(); + this.labelRemoveTextBetween = new System.Windows.Forms.Label(); + this.comboBoxRemoveIfTextContains = new System.Windows.Forms.ComboBox(); + this.checkBoxRemoveWhereContains = new System.Windows.Forms.CheckBox(); + this.comboBoxCustomEnd = new System.Windows.Forms.ComboBox(); + this.comboBoxCustomStart = new System.Windows.Forms.ComboBox(); + this.checkBoxRemoveTextBeforeColonOnlyUppercase = new System.Windows.Forms.CheckBox(); + this.checkBoxOnlyIfInSeparateLine = new System.Windows.Forms.CheckBox(); + this.checkBoxRemoveTextBetweenCustomTags = new System.Windows.Forms.CheckBox(); + this.checkBoxRemoveTextBetweenQuestionMarks = new System.Windows.Forms.CheckBox(); + this.checkBoxRemoveTextBetweenParentheses = new System.Windows.Forms.CheckBox(); + this.checkBoxRemoveTextBetweenBrackets = new System.Windows.Forms.CheckBox(); + this.checkBoxRemoveTextBetweenSquares = new System.Windows.Forms.CheckBox(); + this.labelAnd = new System.Windows.Forms.Label(); + this.buttonApply = new System.Windows.Forms.Button(); + this.textBoxAfterText = new System.Windows.Forms.TextBox(); + this.labelText = new System.Windows.Forms.Label(); + this.groupBoxLinesFound.SuspendLayout(); + this.contextMenuStrip1.SuspendLayout(); + this.groupBoxRemoveTextConditions.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(716, 563); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(797, 563); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // groupBoxLinesFound + // + this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxLinesFound.Controls.Add(this.listViewFixes); + this.groupBoxLinesFound.Location = new System.Drawing.Point(12, 222); + this.groupBoxLinesFound.Name = "groupBoxLinesFound"; + this.groupBoxLinesFound.Size = new System.Drawing.Size(941, 291); + this.groupBoxLinesFound.TabIndex = 1; + this.groupBoxLinesFound.TabStop = false; + this.groupBoxLinesFound.Text = "Lines found"; + // + // listViewFixes + // + this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewFixes.CheckBoxes = true; + this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderApply, + this.columnHeaderLine, + this.columnHeaderBefore, + this.columnHeaderAfter}); + this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; + this.listViewFixes.FullRowSelect = true; + this.listViewFixes.HideSelection = false; + this.listViewFixes.Location = new System.Drawing.Point(6, 17); + this.listViewFixes.Name = "listViewFixes"; + this.listViewFixes.Size = new System.Drawing.Size(929, 268); + this.listViewFixes.TabIndex = 0; + this.listViewFixes.UseCompatibleStateImageBehavior = false; + this.listViewFixes.View = System.Windows.Forms.View.Details; + this.listViewFixes.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listViewFixes_ItemChecked); + this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged); + // + // columnHeaderApply + // + this.columnHeaderApply.Text = "Apply"; + this.columnHeaderApply.Width = 45; + // + // columnHeaderLine + // + this.columnHeaderLine.Text = "Line#"; + this.columnHeaderLine.Width = 61; + // + // columnHeaderBefore + // + this.columnHeaderBefore.Text = "Before"; + this.columnHeaderBefore.Width = 401; + // + // columnHeaderAfter + // + this.columnHeaderAfter.Text = "After"; + this.columnHeaderAfter.Width = 395; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSelAll, + this.toolStripMenuItemInvertSel}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(155, 48); + // + // toolStripMenuItemSelAll + // + this.toolStripMenuItemSelAll.Name = "toolStripMenuItemSelAll"; + this.toolStripMenuItemSelAll.Size = new System.Drawing.Size(154, 22); + this.toolStripMenuItemSelAll.Text = "Select all"; + this.toolStripMenuItemSelAll.Click += new System.EventHandler(this.toolStripMenuItemSelAll_Click); + // + // toolStripMenuItemInvertSel + // + this.toolStripMenuItemInvertSel.Name = "toolStripMenuItemInvertSel"; + this.toolStripMenuItemInvertSel.Size = new System.Drawing.Size(154, 22); + this.toolStripMenuItemInvertSel.Text = "Invert selection"; + this.toolStripMenuItemInvertSel.Click += new System.EventHandler(this.toolStripMenuItemInvertSel_Click); + // + // checkBoxRemoveTextBeforeColon + // + this.checkBoxRemoveTextBeforeColon.AutoSize = true; + this.checkBoxRemoveTextBeforeColon.Checked = true; + this.checkBoxRemoveTextBeforeColon.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxRemoveTextBeforeColon.Location = new System.Drawing.Point(241, 26); + this.checkBoxRemoveTextBeforeColon.Name = "checkBoxRemoveTextBeforeColon"; + this.checkBoxRemoveTextBeforeColon.Size = new System.Drawing.Size(175, 17); + this.checkBoxRemoveTextBeforeColon.TabIndex = 10; + this.checkBoxRemoveTextBeforeColon.Text = "Remove text before a colon (:)"; + this.checkBoxRemoveTextBeforeColon.UseVisualStyleBackColor = true; + this.checkBoxRemoveTextBeforeColon.CheckedChanged += new System.EventHandler(this.checkBoxRemoveTextBeforeColon_CheckedChanged); + // + // groupBoxRemoveTextConditions + // + this.groupBoxRemoveTextConditions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxInterjectionOnlySeparateLine); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveIfAllUppercase); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxColonSeparateLine); + this.groupBoxRemoveTextConditions.Controls.Add(this.buttonEditInterjections); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveInterjections); + this.groupBoxRemoveTextConditions.Controls.Add(this.labelRemoveTextBetween); + this.groupBoxRemoveTextConditions.Controls.Add(this.comboBoxRemoveIfTextContains); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveWhereContains); + this.groupBoxRemoveTextConditions.Controls.Add(this.comboBoxCustomEnd); + this.groupBoxRemoveTextConditions.Controls.Add(this.comboBoxCustomStart); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBeforeColonOnlyUppercase); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBeforeColon); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxOnlyIfInSeparateLine); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBetweenCustomTags); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBetweenQuestionMarks); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBetweenParentheses); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBetweenBrackets); + this.groupBoxRemoveTextConditions.Controls.Add(this.checkBoxRemoveTextBetweenSquares); + this.groupBoxRemoveTextConditions.Controls.Add(this.labelAnd); + this.groupBoxRemoveTextConditions.Location = new System.Drawing.Point(12, 12); + this.groupBoxRemoveTextConditions.Name = "groupBoxRemoveTextConditions"; + this.groupBoxRemoveTextConditions.Size = new System.Drawing.Size(941, 204); + this.groupBoxRemoveTextConditions.TabIndex = 0; + this.groupBoxRemoveTextConditions.TabStop = false; + this.groupBoxRemoveTextConditions.Text = "Remove text conditions"; + // + // checkBoxInterjectionOnlySeparateLine + // + this.checkBoxInterjectionOnlySeparateLine.AutoSize = true; + this.checkBoxInterjectionOnlySeparateLine.Location = new System.Drawing.Point(600, 53); + this.checkBoxInterjectionOnlySeparateLine.Name = "checkBoxInterjectionOnlySeparateLine"; + this.checkBoxInterjectionOnlySeparateLine.Size = new System.Drawing.Size(137, 17); + this.checkBoxInterjectionOnlySeparateLine.TabIndex = 18; + this.checkBoxInterjectionOnlySeparateLine.Text = "Only if on separate line"; + this.checkBoxInterjectionOnlySeparateLine.UseVisualStyleBackColor = true; + this.checkBoxInterjectionOnlySeparateLine.CheckedChanged += new System.EventHandler(this.checkBoxInterjectionOnlySeparateLine_CheckedChanged); + // + // checkBoxRemoveIfAllUppercase + // + this.checkBoxRemoveIfAllUppercase.AutoSize = true; + this.checkBoxRemoveIfAllUppercase.Checked = true; + this.checkBoxRemoveIfAllUppercase.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxRemoveIfAllUppercase.Location = new System.Drawing.Point(241, 102); + this.checkBoxRemoveIfAllUppercase.Name = "checkBoxRemoveIfAllUppercase"; + this.checkBoxRemoveIfAllUppercase.Size = new System.Drawing.Size(142, 17); + this.checkBoxRemoveIfAllUppercase.TabIndex = 13; + this.checkBoxRemoveIfAllUppercase.Text = "Remove uppercase lines"; + this.checkBoxRemoveIfAllUppercase.UseVisualStyleBackColor = true; + this.checkBoxRemoveIfAllUppercase.CheckedChanged += new System.EventHandler(this.checkBoxRemoveIfAllUppercase_CheckedChanged); + // + // checkBoxColonSeparateLine + // + this.checkBoxColonSeparateLine.AutoSize = true; + this.checkBoxColonSeparateLine.Location = new System.Drawing.Point(261, 69); + this.checkBoxColonSeparateLine.Name = "checkBoxColonSeparateLine"; + this.checkBoxColonSeparateLine.Size = new System.Drawing.Size(137, 17); + this.checkBoxColonSeparateLine.TabIndex = 12; + this.checkBoxColonSeparateLine.Text = "Only if on separate line"; + this.checkBoxColonSeparateLine.UseVisualStyleBackColor = true; + this.checkBoxColonSeparateLine.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); + // + // buttonEditInterjections + // + this.buttonEditInterjections.Location = new System.Drawing.Point(718, 26); + this.buttonEditInterjections.Name = "buttonEditInterjections"; + this.buttonEditInterjections.Size = new System.Drawing.Size(103, 23); + this.buttonEditInterjections.TabIndex = 17; + this.buttonEditInterjections.Text = "Edit..."; + this.buttonEditInterjections.UseVisualStyleBackColor = true; + this.buttonEditInterjections.Click += new System.EventHandler(this.buttonEditInterjections_Click); + // + // checkBoxRemoveInterjections + // + this.checkBoxRemoveInterjections.AutoSize = true; + this.checkBoxRemoveInterjections.Location = new System.Drawing.Point(582, 30); + this.checkBoxRemoveInterjections.Name = "checkBoxRemoveInterjections"; + this.checkBoxRemoveInterjections.Size = new System.Drawing.Size(130, 17); + this.checkBoxRemoveInterjections.TabIndex = 16; + this.checkBoxRemoveInterjections.Text = "Remove interjections "; + this.checkBoxRemoveInterjections.UseVisualStyleBackColor = true; + this.checkBoxRemoveInterjections.CheckedChanged += new System.EventHandler(this.checkBoxRemoveInterjections_CheckedChanged); + // + // labelRemoveTextBetween + // + this.labelRemoveTextBetween.AutoSize = true; + this.labelRemoveTextBetween.Location = new System.Drawing.Point(8, 26); + this.labelRemoveTextBetween.Name = "labelRemoveTextBetween"; + this.labelRemoveTextBetween.Size = new System.Drawing.Size(114, 13); + this.labelRemoveTextBetween.TabIndex = 0; + this.labelRemoveTextBetween.Text = "Remove text between"; + // + // comboBoxRemoveIfTextContains + // + this.comboBoxRemoveIfTextContains.FormattingEnabled = true; + this.comboBoxRemoveIfTextContains.Items.AddRange(new object[] { + "¶", + "♪", + "♫", + "♪,♫"}); + this.comboBoxRemoveIfTextContains.Location = new System.Drawing.Point(427, 131); + this.comboBoxRemoveIfTextContains.MaxLength = 10; + this.comboBoxRemoveIfTextContains.Name = "comboBoxRemoveIfTextContains"; + this.comboBoxRemoveIfTextContains.Size = new System.Drawing.Size(100, 21); + this.comboBoxRemoveIfTextContains.TabIndex = 15; + this.comboBoxRemoveIfTextContains.Text = "¶"; + this.comboBoxRemoveIfTextContains.TextChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); + // + // checkBoxRemoveWhereContains + // + this.checkBoxRemoveWhereContains.AutoSize = true; + this.checkBoxRemoveWhereContains.Location = new System.Drawing.Point(241, 135); + this.checkBoxRemoveWhereContains.Name = "checkBoxRemoveWhereContains"; + this.checkBoxRemoveWhereContains.Size = new System.Drawing.Size(153, 17); + this.checkBoxRemoveWhereContains.TabIndex = 14; + this.checkBoxRemoveWhereContains.Text = "Remove text if it contains:"; + this.checkBoxRemoveWhereContains.UseVisualStyleBackColor = true; + this.checkBoxRemoveWhereContains.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); + // + // comboBoxCustomEnd + // + this.comboBoxCustomEnd.FormattingEnabled = true; + this.comboBoxCustomEnd.Items.AddRange(new object[] { + "¶", + "♪", + "♫"}); + this.comboBoxCustomEnd.Location = new System.Drawing.Point(116, 135); + this.comboBoxCustomEnd.MaxLength = 2; + this.comboBoxCustomEnd.Name = "comboBoxCustomEnd"; + this.comboBoxCustomEnd.Size = new System.Drawing.Size(38, 21); + this.comboBoxCustomEnd.TabIndex = 8; + this.comboBoxCustomEnd.Text = "¶"; + this.comboBoxCustomEnd.TextChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); + // + // comboBoxCustomStart + // + this.comboBoxCustomStart.FormattingEnabled = true; + this.comboBoxCustomStart.Items.AddRange(new object[] { + "¶", + "♪", + "♫"}); + this.comboBoxCustomStart.Location = new System.Drawing.Point(41, 135); + this.comboBoxCustomStart.MaxLength = 2; + this.comboBoxCustomStart.Name = "comboBoxCustomStart"; + this.comboBoxCustomStart.Size = new System.Drawing.Size(38, 21); + this.comboBoxCustomStart.TabIndex = 6; + this.comboBoxCustomStart.Text = "¶"; + this.comboBoxCustomStart.TextChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); + // + // checkBoxRemoveTextBeforeColonOnlyUppercase + // + this.checkBoxRemoveTextBeforeColonOnlyUppercase.AutoSize = true; + this.checkBoxRemoveTextBeforeColonOnlyUppercase.Location = new System.Drawing.Point(261, 46); + this.checkBoxRemoveTextBeforeColonOnlyUppercase.Name = "checkBoxRemoveTextBeforeColonOnlyUppercase"; + this.checkBoxRemoveTextBeforeColonOnlyUppercase.Size = new System.Drawing.Size(151, 17); + this.checkBoxRemoveTextBeforeColonOnlyUppercase.TabIndex = 11; + this.checkBoxRemoveTextBeforeColonOnlyUppercase.Text = "Only if text is UPPERCASE"; + this.checkBoxRemoveTextBeforeColonOnlyUppercase.UseVisualStyleBackColor = true; + this.checkBoxRemoveTextBeforeColonOnlyUppercase.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); + // + // checkBoxOnlyIfInSeparateLine + // + this.checkBoxOnlyIfInSeparateLine.AutoSize = true; + this.checkBoxOnlyIfInSeparateLine.Location = new System.Drawing.Point(21, 172); + this.checkBoxOnlyIfInSeparateLine.Name = "checkBoxOnlyIfInSeparateLine"; + this.checkBoxOnlyIfInSeparateLine.Size = new System.Drawing.Size(137, 17); + this.checkBoxOnlyIfInSeparateLine.TabIndex = 9; + this.checkBoxOnlyIfInSeparateLine.Text = "Only if on separate line"; + this.checkBoxOnlyIfInSeparateLine.UseVisualStyleBackColor = true; + this.checkBoxOnlyIfInSeparateLine.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); + // + // checkBoxRemoveTextBetweenCustomTags + // + this.checkBoxRemoveTextBetweenCustomTags.AutoSize = true; + this.checkBoxRemoveTextBetweenCustomTags.Checked = true; + this.checkBoxRemoveTextBetweenCustomTags.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxRemoveTextBetweenCustomTags.Location = new System.Drawing.Point(20, 138); + this.checkBoxRemoveTextBetweenCustomTags.Name = "checkBoxRemoveTextBetweenCustomTags"; + this.checkBoxRemoveTextBetweenCustomTags.Size = new System.Drawing.Size(15, 14); + this.checkBoxRemoveTextBetweenCustomTags.TabIndex = 5; + this.checkBoxRemoveTextBetweenCustomTags.UseVisualStyleBackColor = true; + this.checkBoxRemoveTextBetweenCustomTags.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); + // + // checkBoxRemoveTextBetweenQuestionMarks + // + this.checkBoxRemoveTextBetweenQuestionMarks.AutoSize = true; + this.checkBoxRemoveTextBetweenQuestionMarks.Checked = true; + this.checkBoxRemoveTextBetweenQuestionMarks.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxRemoveTextBetweenQuestionMarks.Location = new System.Drawing.Point(20, 115); + this.checkBoxRemoveTextBetweenQuestionMarks.Name = "checkBoxRemoveTextBetweenQuestionMarks"; + this.checkBoxRemoveTextBetweenQuestionMarks.Size = new System.Drawing.Size(76, 17); + this.checkBoxRemoveTextBetweenQuestionMarks.TabIndex = 4; + this.checkBoxRemoveTextBetweenQuestionMarks.Text = "\"?\" and \"?\""; + this.checkBoxRemoveTextBetweenQuestionMarks.UseVisualStyleBackColor = true; + this.checkBoxRemoveTextBetweenQuestionMarks.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); + // + // checkBoxRemoveTextBetweenParentheses + // + this.checkBoxRemoveTextBetweenParentheses.AutoSize = true; + this.checkBoxRemoveTextBetweenParentheses.Checked = true; + this.checkBoxRemoveTextBetweenParentheses.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxRemoveTextBetweenParentheses.Location = new System.Drawing.Point(20, 69); + this.checkBoxRemoveTextBetweenParentheses.Name = "checkBoxRemoveTextBetweenParentheses"; + this.checkBoxRemoveTextBetweenParentheses.Size = new System.Drawing.Size(74, 17); + this.checkBoxRemoveTextBetweenParentheses.TabIndex = 2; + this.checkBoxRemoveTextBetweenParentheses.Text = "\"(\" and \")\""; + this.checkBoxRemoveTextBetweenParentheses.UseVisualStyleBackColor = true; + this.checkBoxRemoveTextBetweenParentheses.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); + // + // checkBoxRemoveTextBetweenBrackets + // + this.checkBoxRemoveTextBetweenBrackets.AutoSize = true; + this.checkBoxRemoveTextBetweenBrackets.Checked = true; + this.checkBoxRemoveTextBetweenBrackets.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxRemoveTextBetweenBrackets.Location = new System.Drawing.Point(20, 92); + this.checkBoxRemoveTextBetweenBrackets.Name = "checkBoxRemoveTextBetweenBrackets"; + this.checkBoxRemoveTextBetweenBrackets.Size = new System.Drawing.Size(76, 17); + this.checkBoxRemoveTextBetweenBrackets.TabIndex = 3; + this.checkBoxRemoveTextBetweenBrackets.Text = "\"{\" and \"}\""; + this.checkBoxRemoveTextBetweenBrackets.UseVisualStyleBackColor = true; + this.checkBoxRemoveTextBetweenBrackets.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); + // + // checkBoxRemoveTextBetweenSquares + // + this.checkBoxRemoveTextBetweenSquares.AutoSize = true; + this.checkBoxRemoveTextBetweenSquares.Checked = true; + this.checkBoxRemoveTextBetweenSquares.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxRemoveTextBetweenSquares.Location = new System.Drawing.Point(20, 45); + this.checkBoxRemoveTextBetweenSquares.Name = "checkBoxRemoveTextBetweenSquares"; + this.checkBoxRemoveTextBetweenSquares.Size = new System.Drawing.Size(74, 17); + this.checkBoxRemoveTextBetweenSquares.TabIndex = 1; + this.checkBoxRemoveTextBetweenSquares.Text = "\"[\" and \"]\""; + this.checkBoxRemoveTextBetweenSquares.UseVisualStyleBackColor = true; + this.checkBoxRemoveTextBetweenSquares.CheckedChanged += new System.EventHandler(this.CheckBoxRemoveTextBetweenCheckedChanged); + // + // labelAnd + // + this.labelAnd.AutoSize = true; + this.labelAnd.Location = new System.Drawing.Point(85, 141); + this.labelAnd.Name = "labelAnd"; + this.labelAnd.Size = new System.Drawing.Size(25, 13); + this.labelAnd.TabIndex = 7; + this.labelAnd.Text = "and"; + // + // buttonApply + // + this.buttonApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonApply.Location = new System.Drawing.Point(878, 563); + this.buttonApply.Name = "buttonApply"; + this.buttonApply.Size = new System.Drawing.Size(75, 23); + this.buttonApply.TabIndex = 5; + this.buttonApply.Text = "Apply"; + this.buttonApply.UseVisualStyleBackColor = true; + this.buttonApply.Click += new System.EventHandler(this.buttonApply_Click); + // + // textBoxAfterText + // + this.textBoxAfterText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.textBoxAfterText.Location = new System.Drawing.Point(12, 543); + this.textBoxAfterText.Multiline = true; + this.textBoxAfterText.Name = "textBoxAfterText"; + this.textBoxAfterText.Size = new System.Drawing.Size(394, 43); + this.textBoxAfterText.TabIndex = 2; + this.textBoxAfterText.TextChanged += new System.EventHandler(this.textBoxAfterText_TextChanged); + // + // labelText + // + this.labelText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelText.AutoSize = true; + this.labelText.Location = new System.Drawing.Point(12, 527); + this.labelText.Name = "labelText"; + this.labelText.Size = new System.Drawing.Size(29, 13); + this.labelText.TabIndex = 6; + this.labelText.Text = "Text"; + // + // FormRemoveTextForHearImpaired + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(965, 598); + this.Controls.Add(this.labelText); + this.Controls.Add(this.textBoxAfterText); + this.Controls.Add(this.buttonApply); + this.Controls.Add(this.groupBoxRemoveTextConditions); + this.Controls.Add(this.groupBoxLinesFound); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(705, 514); + this.Name = "FormRemoveTextForHearImpaired"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Remove text for hearing impaired"; + this.Load += new System.EventHandler(this.FormRemoveTextForHearImpaired_Load); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormRemoveTextForHearImpaired_KeyDown); + this.Resize += new System.EventHandler(this.FormRemoveTextForHearImpaired_Resize); + this.groupBoxLinesFound.ResumeLayout(false); + this.contextMenuStrip1.ResumeLayout(false); + this.groupBoxRemoveTextConditions.ResumeLayout(false); + this.groupBoxRemoveTextConditions.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.GroupBox groupBoxLinesFound; + private System.Windows.Forms.ListView listViewFixes; + private System.Windows.Forms.ColumnHeader columnHeaderApply; + private System.Windows.Forms.ColumnHeader columnHeaderLine; + private System.Windows.Forms.ColumnHeader columnHeaderBefore; + private System.Windows.Forms.ColumnHeader columnHeaderAfter; + private System.Windows.Forms.CheckBox checkBoxRemoveTextBeforeColon; + private System.Windows.Forms.GroupBox groupBoxRemoveTextConditions; + private System.Windows.Forms.CheckBox checkBoxRemoveTextBetweenCustomTags; + private System.Windows.Forms.CheckBox checkBoxRemoveTextBetweenQuestionMarks; + private System.Windows.Forms.CheckBox checkBoxRemoveTextBetweenParentheses; + private System.Windows.Forms.CheckBox checkBoxRemoveTextBetweenBrackets; + private System.Windows.Forms.CheckBox checkBoxRemoveTextBetweenSquares; + private System.Windows.Forms.Label labelAnd; + private System.Windows.Forms.CheckBox checkBoxRemoveTextBeforeColonOnlyUppercase; + private System.Windows.Forms.CheckBox checkBoxOnlyIfInSeparateLine; + private System.Windows.Forms.ComboBox comboBoxCustomStart; + private System.Windows.Forms.ComboBox comboBoxCustomEnd; + private System.Windows.Forms.ComboBox comboBoxRemoveIfTextContains; + private System.Windows.Forms.CheckBox checkBoxRemoveWhereContains; + private System.Windows.Forms.Label labelRemoveTextBetween; + private System.Windows.Forms.CheckBox checkBoxRemoveInterjections; + private System.Windows.Forms.Button buttonEditInterjections; + private System.Windows.Forms.CheckBox checkBoxColonSeparateLine; + private System.Windows.Forms.CheckBox checkBoxRemoveIfAllUppercase; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelAll; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInvertSel; + private System.Windows.Forms.Button buttonApply; + private System.Windows.Forms.CheckBox checkBoxInterjectionOnlySeparateLine; + private System.Windows.Forms.TextBox textBoxAfterText; + private System.Windows.Forms.Label labelText; + } } \ No newline at end of file diff --git a/src/Forms/RemoveTextFromHearImpaired.cs b/src/ui/Forms/RemoveTextFromHearImpaired.cs similarity index 97% rename from src/Forms/RemoveTextFromHearImpaired.cs rename to src/ui/Forms/RemoveTextFromHearImpaired.cs index ba3d81d2f..a1ab12493 100644 --- a/src/Forms/RemoveTextFromHearImpaired.cs +++ b/src/ui/Forms/RemoveTextFromHearImpaired.cs @@ -1,420 +1,420 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Forms; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.Linq; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class FormRemoveTextForHearImpaired : PositionAndSizeForm - { - public Subtitle Subtitle; - public int TotalFixes { get; private set; } - private readonly LanguageStructure.RemoveTextFromHearImpaired _language; - private readonly RemoveTextForHI _removeTextForHiLib; - private Dictionary _fixes; - private readonly Main _mainForm; - private readonly List _unchecked = new List(); - private readonly List _edited = new List(); - private readonly List _editedOld = new List(); - - public FormRemoveTextForHearImpaired(Main main, Subtitle subtitle) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - _mainForm = main; - _removeTextForHiLib = new RemoveTextForHI(GetSettings(subtitle)); - - checkBoxRemoveTextBetweenSquares.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenBrackets; - checkBoxRemoveTextBetweenParentheses.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenParentheses; - checkBoxRemoveTextBetweenBrackets.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCurlyBrackets; - checkBoxRemoveTextBetweenQuestionMarks.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenQuestionMarks; - checkBoxRemoveTextBetweenCustomTags.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustom; - checkBoxOnlyIfInSeparateLine.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenOnlySeparateLines; - checkBoxRemoveTextBeforeColon.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBeforeColon; - checkBoxRemoveTextBeforeColonOnlyUppercase.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBeforeColonOnlyIfUppercase; - checkBoxColonSeparateLine.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBeforeColonOnlyOnSeparateLine; - checkBoxRemoveInterjections.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveInterjections; - checkBoxInterjectionOnlySeparateLine.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveInterjectionsOnlyOnSeparateLine; - checkBoxRemoveWhereContains.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveIfContains; - checkBoxRemoveIfAllUppercase.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveIfAllUppercase; - checkBoxInterjectionOnlySeparateLine.Enabled = checkBoxRemoveInterjections.Checked; - - contextMenuStrip1.Items[0].Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; - contextMenuStrip1.Items[1].Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; - - _language = Configuration.Settings.Language.RemoveTextFromHearImpaired; - Text = _language.Title; - groupBoxRemoveTextConditions.Text = _language.RemoveTextConditions; - labelAnd.Text = _language.And; - labelRemoveTextBetween.Text = _language.RemoveTextBetween; - checkBoxRemoveTextBeforeColon.Text = _language.RemoveTextBeforeColon; - checkBoxRemoveTextBeforeColonOnlyUppercase.Text = _language.OnlyIfTextIsUppercase; - checkBoxOnlyIfInSeparateLine.Text = _language.OnlyIfInSeparateLine; - checkBoxColonSeparateLine.Text = _language.OnlyIfInSeparateLine; - checkBoxRemoveTextBetweenBrackets.Text = _language.Brackets; - checkBoxRemoveTextBetweenParentheses.Text = _language.Parentheses; - checkBoxRemoveTextBetweenQuestionMarks.Text = _language.QuestionMarks; - checkBoxRemoveTextBetweenSquares.Text = _language.SquareBrackets; - checkBoxRemoveWhereContains.Text = _language.RemoveTextIfContains; - checkBoxRemoveIfAllUppercase.Text = _language.RemoveTextIfAllUppercase; - checkBoxRemoveInterjections.Text = _language.RemoveInterjections; - checkBoxInterjectionOnlySeparateLine.Text = _language.OnlyIfInSeparateLine; - buttonEditInterjections.Text = _language.EditInterjections; - buttonEditInterjections.Left = checkBoxRemoveInterjections.Left + checkBoxRemoveInterjections.Width; - listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; - listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; - listViewFixes.Columns[2].Text = Configuration.Settings.Language.General.Before; - listViewFixes.Columns[3].Text = Configuration.Settings.Language.General.After; - labelText.Text = Configuration.Settings.Language.General.Text; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - buttonApply.Text = Configuration.Settings.Language.General.Apply; - UiUtil.FixLargeFonts(this, buttonOK); - listViewFixes_SelectedIndexChanged(null, null); - } - - public void Initialize(Subtitle subtitle) - { - if (Environment.OSVersion.Version.Major < 6) // 6 == Vista/Win2008Server/Win7 - { - const string unicodeFontName = Utilities.WinXP2KUnicodeFontName; - float fontSize = comboBoxCustomStart.Font.Size; - comboBoxCustomStart.Font = new Font(unicodeFontName, fontSize); - comboBoxCustomEnd.Font = new Font(unicodeFontName, fontSize); - comboBoxRemoveIfTextContains.Font = new Font(unicodeFontName, fontSize); - } - comboBoxRemoveIfTextContains.Left = checkBoxRemoveWhereContains.Left + checkBoxRemoveWhereContains.Width; - Subtitle = new Subtitle(subtitle); - GeneratePreview(); - } - - public void InitializeSettingsOnly() - { - comboBoxRemoveIfTextContains.Left = checkBoxRemoveWhereContains.Left + checkBoxRemoveWhereContains.Width; - groupBoxLinesFound.Visible = false; - int h = groupBoxRemoveTextConditions.Top + groupBoxRemoveTextConditions.Height + buttonOK.Height + 50; - MinimumSize = new Size(MinimumSize.Width, h); - Height = h; - } - - private void GeneratePreview() - { - if (Subtitle == null) - { - return; - } - - Cursor.Current = Cursors.WaitCursor; - _removeTextForHiLib.Settings = GetSettings(Subtitle); - _removeTextForHiLib.Warnings = new List(); - listViewFixes.BeginUpdate(); - listViewFixes.Items.Clear(); - int count = 0; - _fixes = new Dictionary(); - for (int index = 0; index < Subtitle.Paragraphs.Count; index++) - { - Paragraph p = Subtitle.Paragraphs[index]; - _removeTextForHiLib.WarningIndex = index - 1; - if (_edited.Contains(p)) - { - count++; - var old = _editedOld.First(x => x.Id == p.Id); - AddToListView(old, p.Text); - _fixes.Add(old, p.Text); - } - else - { - string newText = _removeTextForHiLib.RemoveTextFromHearImpaired(p.Text, Subtitle, index); - if (p.Text.RemoveChar(' ') != newText.RemoveChar(' ')) - { - count++; - AddToListView(p, newText); - _fixes.Add(p, newText); - } - } - - } - listViewFixes.EndUpdate(); - groupBoxLinesFound.Text = string.Format(_language.LinesFoundX, count); - Cursor.Current = Cursors.Default; - } - - private void AddToListView(Paragraph p, string newText) - { - var item = new ListViewItem(string.Empty) { Tag = p, Checked = !_unchecked.Contains(p) }; - if (_removeTextForHiLib.Warnings != null && _removeTextForHiLib.Warnings.Contains(_removeTextForHiLib.WarningIndex)) - { - item.UseItemStyleForSubItems = true; - item.BackColor = Color.PeachPuff; - } - item.SubItems.Add(p.Number.ToString(CultureInfo.InvariantCulture)); - item.SubItems.Add(UiUtil.GetListViewTextFromString(p.Text)); - item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); - listViewFixes.Items.Add(item); - } - - private void FormRemoveTextForHearImpaired_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#remove_text_for_hi"); - } - } - - private void ButtonOkClick(object sender, EventArgs e) - { - Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenBrackets = checkBoxRemoveTextBetweenSquares.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenParentheses = checkBoxRemoveTextBetweenParentheses.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCurlyBrackets = checkBoxRemoveTextBetweenBrackets.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenQuestionMarks = checkBoxRemoveTextBetweenQuestionMarks.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustom = checkBoxRemoveTextBetweenCustomTags.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustomBefore = comboBoxCustomStart.Text; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustomAfter = comboBoxCustomEnd.Text; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenOnlySeparateLines = checkBoxOnlyIfInSeparateLine.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBeforeColon = checkBoxRemoveTextBeforeColon.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBeforeColonOnlyIfUppercase = checkBoxRemoveTextBeforeColonOnlyUppercase.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBeforeColonOnlyOnSeparateLine = checkBoxColonSeparateLine.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveInterjections = checkBoxRemoveInterjections.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveInterjectionsOnlyOnSeparateLine = checkBoxInterjectionOnlySeparateLine.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveIfContains = checkBoxRemoveWhereContains.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveIfAllUppercase = checkBoxRemoveIfAllUppercase.Checked; - Configuration.Settings.RemoveTextForHearingImpaired.RemoveIfContainsText = comboBoxRemoveIfTextContains.Text; - - ApplyChanges(); - DialogResult = DialogResult.OK; - } - - private void buttonApply_Click(object sender, EventArgs e) - { - ApplyChanges(); - GeneratePreview(); - } - - private void ApplyChanges() - { - if (Subtitle == null) - { - return; - } - - int fixes = RemoveTextFromHearImpaired(); - Subtitle.Renumber(); - if (_mainForm != null && fixes > 0) - { - TotalFixes += fixes; - _mainForm.ReloadFromSubtitle(new Subtitle(Subtitle), Configuration.Settings.Language.Main.BeforeRemovalOfTextingForHearingImpaired); - } - } - - public int RemoveTextFromHearImpaired() - { - _unchecked.Clear(); - int fixes = 0; - - for (int i = listViewFixes.Items.Count - 1; i >= 0; i--) - { - var item = listViewFixes.Items[i]; - var p = (Paragraph)item.Tag; - if (item.Checked) - { - string newText = _fixes[p]; - if (string.IsNullOrWhiteSpace(newText)) - { - Subtitle.Paragraphs.Remove(p); - } - else - { - p.Text = newText; - } - fixes++; - } - else - { - _unchecked.Add(p); - } - } - return fixes; - } - - private void CheckBoxRemoveTextBetweenCheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void checkBoxRemoveInterjections_CheckedChanged(object sender, EventArgs e) - { - checkBoxInterjectionOnlySeparateLine.Enabled = checkBoxRemoveInterjections.Checked; - GeneratePreview(); - } - - private void buttonEditInterjections_Click(object sender, EventArgs e) - { - using (var editInterjections = new Interjections()) - { - editInterjections.Initialize(Configuration.Settings.Tools.Interjections); - if (editInterjections.ShowDialog(this) == DialogResult.OK) - { - Configuration.Settings.Tools.Interjections = editInterjections.GetInterjectionsSemiColonSeparatedString(); - _removeTextForHiLib.ReloadInterjection(); - if (checkBoxRemoveInterjections.Checked) - { - GeneratePreview(); - } - } - } - } - - private void FormRemoveTextForHearImpaired_Resize(object sender, EventArgs e) - { - int availableWidth = (listViewFixes.Width - (columnHeaderApply.Width + columnHeaderLine.Width + 20)) / 2; - - columnHeaderBefore.Width = availableWidth; - columnHeaderAfter.Width = availableWidth; - } - - private void checkBoxRemoveTextBeforeColon_CheckedChanged(object sender, EventArgs e) - { - checkBoxRemoveTextBeforeColonOnlyUppercase.Enabled = checkBoxRemoveTextBeforeColon.Checked; - checkBoxColonSeparateLine.Enabled = checkBoxRemoveTextBeforeColon.Checked; - GeneratePreview(); - } - - private void checkBoxRemoveIfAllUppercase_CheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - public RemoveTextForHISettings GetSettings(Subtitle subtitle) - { - var settings = new RemoveTextForHISettings(subtitle) - { - OnlyIfInSeparateLine = checkBoxOnlyIfInSeparateLine.Checked, - RemoveIfAllUppercase = checkBoxRemoveIfAllUppercase.Checked, - RemoveTextBeforeColon = checkBoxRemoveTextBeforeColon.Checked, - RemoveTextBeforeColonOnlyUppercase = checkBoxRemoveTextBeforeColonOnlyUppercase.Checked, - ColonSeparateLine = checkBoxColonSeparateLine.Checked, - RemoveWhereContains = checkBoxRemoveWhereContains.Checked, - RemoveIfTextContains = new List(), - RemoveTextBetweenCustomTags = checkBoxRemoveTextBetweenCustomTags.Checked, - RemoveInterjections = checkBoxRemoveInterjections.Checked, - RemoveInterjectionsOnlySeparateLine = checkBoxRemoveInterjections.Checked && checkBoxInterjectionOnlySeparateLine.Checked, - RemoveTextBetweenSquares = checkBoxRemoveTextBetweenSquares.Checked, - RemoveTextBetweenBrackets = checkBoxRemoveTextBetweenBrackets.Checked, - RemoveTextBetweenQuestionMarks = checkBoxRemoveTextBetweenQuestionMarks.Checked, - RemoveTextBetweenParentheses = checkBoxRemoveTextBetweenParentheses.Checked, - CustomStart = comboBoxCustomStart.Text, - CustomEnd = comboBoxCustomEnd.Text - }; - foreach (string item in comboBoxRemoveIfTextContains.Text.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)) - { - settings.RemoveIfTextContains.Add(item.Trim()); - } - return settings; - } - - private void FormRemoveTextForHearImpaired_Load(object sender, EventArgs e) - { - // only works when used from "Form Load" - comboBoxCustomStart.Text = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustomBefore; - comboBoxCustomEnd.Text = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustomAfter; - comboBoxRemoveIfTextContains.Text = Configuration.Settings.RemoveTextForHearingImpaired.RemoveIfContainsText; - } - - private void toolStripMenuItemSelAll_Click(object sender, EventArgs e) - { - DoSelection(true); - } - - private void toolStripMenuItemInvertSel_Click(object sender, EventArgs e) - { - DoSelection(false); - } - - private void DoSelection(bool selectAll) - { - if (listViewFixes.Items.Count == 0) - { - return; - } - - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = selectAll || !item.Checked; - } - } - - private void listViewFixes_ItemChecked(object sender, ItemCheckedEventArgs e) - { - if (!(e.Item.Tag is Paragraph p)) - { - return; - } - - if (e.Item.Checked) - { - if (_unchecked.Contains(p)) - { - _unchecked.Add(p); - } - } - else - { - if (!_unchecked.Contains(p)) - { - _unchecked.Remove(p); - } - } - } - - private void checkBoxInterjectionOnlySeparateLine_CheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e) - { - var idx = listViewFixes.SelectedIndices.Count == 1 ? listViewFixes.SelectedIndices[0] : -1; - if (idx < 0) - { - textBoxAfterText.Visible = false; - labelText.Visible = false; - return; - } - - textBoxAfterText.TextChanged -= textBoxAfterText_TextChanged; - textBoxAfterText.Visible = true; - labelText.Visible = true; - var item = listViewFixes.Items[idx]; - var p = (Paragraph)item.Tag; - textBoxAfterText.Tag = item; - var text = _fixes[p]; - textBoxAfterText.Text = text; - textBoxAfterText.TextChanged += textBoxAfterText_TextChanged; - } - - private void textBoxAfterText_TextChanged(object sender, EventArgs e) - { - var text = textBoxAfterText.Text.Trim(); - var item = (ListViewItem)textBoxAfterText.Tag; - var p = (Paragraph)item.Tag; - _editedOld.Add(new Paragraph(p, false) { Text = p.Text }); - item.SubItems[3].Text = text; - _fixes[p] = text; - var o = Subtitle.GetParagraphOrDefaultById(p.Id); - o.Text = text; - _edited.Add(p); - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Forms; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.Linq; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class FormRemoveTextForHearImpaired : PositionAndSizeForm + { + public Subtitle Subtitle; + public int TotalFixes { get; private set; } + private readonly LanguageStructure.RemoveTextFromHearImpaired _language; + private readonly RemoveTextForHI _removeTextForHiLib; + private Dictionary _fixes; + private readonly Main _mainForm; + private readonly List _unchecked = new List(); + private readonly List _edited = new List(); + private readonly List _editedOld = new List(); + + public FormRemoveTextForHearImpaired(Main main, Subtitle subtitle) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + _mainForm = main; + _removeTextForHiLib = new RemoveTextForHI(GetSettings(subtitle)); + + checkBoxRemoveTextBetweenSquares.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenBrackets; + checkBoxRemoveTextBetweenParentheses.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenParentheses; + checkBoxRemoveTextBetweenBrackets.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCurlyBrackets; + checkBoxRemoveTextBetweenQuestionMarks.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenQuestionMarks; + checkBoxRemoveTextBetweenCustomTags.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustom; + checkBoxOnlyIfInSeparateLine.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenOnlySeparateLines; + checkBoxRemoveTextBeforeColon.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBeforeColon; + checkBoxRemoveTextBeforeColonOnlyUppercase.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBeforeColonOnlyIfUppercase; + checkBoxColonSeparateLine.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBeforeColonOnlyOnSeparateLine; + checkBoxRemoveInterjections.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveInterjections; + checkBoxInterjectionOnlySeparateLine.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveInterjectionsOnlyOnSeparateLine; + checkBoxRemoveWhereContains.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveIfContains; + checkBoxRemoveIfAllUppercase.Checked = Configuration.Settings.RemoveTextForHearingImpaired.RemoveIfAllUppercase; + checkBoxInterjectionOnlySeparateLine.Enabled = checkBoxRemoveInterjections.Checked; + + contextMenuStrip1.Items[0].Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; + contextMenuStrip1.Items[1].Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; + + _language = Configuration.Settings.Language.RemoveTextFromHearImpaired; + Text = _language.Title; + groupBoxRemoveTextConditions.Text = _language.RemoveTextConditions; + labelAnd.Text = _language.And; + labelRemoveTextBetween.Text = _language.RemoveTextBetween; + checkBoxRemoveTextBeforeColon.Text = _language.RemoveTextBeforeColon; + checkBoxRemoveTextBeforeColonOnlyUppercase.Text = _language.OnlyIfTextIsUppercase; + checkBoxOnlyIfInSeparateLine.Text = _language.OnlyIfInSeparateLine; + checkBoxColonSeparateLine.Text = _language.OnlyIfInSeparateLine; + checkBoxRemoveTextBetweenBrackets.Text = _language.Brackets; + checkBoxRemoveTextBetweenParentheses.Text = _language.Parentheses; + checkBoxRemoveTextBetweenQuestionMarks.Text = _language.QuestionMarks; + checkBoxRemoveTextBetweenSquares.Text = _language.SquareBrackets; + checkBoxRemoveWhereContains.Text = _language.RemoveTextIfContains; + checkBoxRemoveIfAllUppercase.Text = _language.RemoveTextIfAllUppercase; + checkBoxRemoveInterjections.Text = _language.RemoveInterjections; + checkBoxInterjectionOnlySeparateLine.Text = _language.OnlyIfInSeparateLine; + buttonEditInterjections.Text = _language.EditInterjections; + buttonEditInterjections.Left = checkBoxRemoveInterjections.Left + checkBoxRemoveInterjections.Width; + listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; + listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; + listViewFixes.Columns[2].Text = Configuration.Settings.Language.General.Before; + listViewFixes.Columns[3].Text = Configuration.Settings.Language.General.After; + labelText.Text = Configuration.Settings.Language.General.Text; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + buttonApply.Text = Configuration.Settings.Language.General.Apply; + UiUtil.FixLargeFonts(this, buttonOK); + listViewFixes_SelectedIndexChanged(null, null); + } + + public void Initialize(Subtitle subtitle) + { + if (Environment.OSVersion.Version.Major < 6) // 6 == Vista/Win2008Server/Win7 + { + const string unicodeFontName = Utilities.WinXP2KUnicodeFontName; + float fontSize = comboBoxCustomStart.Font.Size; + comboBoxCustomStart.Font = new Font(unicodeFontName, fontSize); + comboBoxCustomEnd.Font = new Font(unicodeFontName, fontSize); + comboBoxRemoveIfTextContains.Font = new Font(unicodeFontName, fontSize); + } + comboBoxRemoveIfTextContains.Left = checkBoxRemoveWhereContains.Left + checkBoxRemoveWhereContains.Width; + Subtitle = new Subtitle(subtitle); + GeneratePreview(); + } + + public void InitializeSettingsOnly() + { + comboBoxRemoveIfTextContains.Left = checkBoxRemoveWhereContains.Left + checkBoxRemoveWhereContains.Width; + groupBoxLinesFound.Visible = false; + int h = groupBoxRemoveTextConditions.Top + groupBoxRemoveTextConditions.Height + buttonOK.Height + 50; + MinimumSize = new Size(MinimumSize.Width, h); + Height = h; + } + + private void GeneratePreview() + { + if (Subtitle == null) + { + return; + } + + Cursor.Current = Cursors.WaitCursor; + _removeTextForHiLib.Settings = GetSettings(Subtitle); + _removeTextForHiLib.Warnings = new List(); + listViewFixes.BeginUpdate(); + listViewFixes.Items.Clear(); + int count = 0; + _fixes = new Dictionary(); + for (int index = 0; index < Subtitle.Paragraphs.Count; index++) + { + Paragraph p = Subtitle.Paragraphs[index]; + _removeTextForHiLib.WarningIndex = index - 1; + if (_edited.Contains(p)) + { + count++; + var old = _editedOld.First(x => x.Id == p.Id); + AddToListView(old, p.Text); + _fixes.Add(old, p.Text); + } + else + { + string newText = _removeTextForHiLib.RemoveTextFromHearImpaired(p.Text, Subtitle, index); + if (p.Text.RemoveChar(' ') != newText.RemoveChar(' ')) + { + count++; + AddToListView(p, newText); + _fixes.Add(p, newText); + } + } + + } + listViewFixes.EndUpdate(); + groupBoxLinesFound.Text = string.Format(_language.LinesFoundX, count); + Cursor.Current = Cursors.Default; + } + + private void AddToListView(Paragraph p, string newText) + { + var item = new ListViewItem(string.Empty) { Tag = p, Checked = !_unchecked.Contains(p) }; + if (_removeTextForHiLib.Warnings != null && _removeTextForHiLib.Warnings.Contains(_removeTextForHiLib.WarningIndex)) + { + item.UseItemStyleForSubItems = true; + item.BackColor = Color.PeachPuff; + } + item.SubItems.Add(p.Number.ToString(CultureInfo.InvariantCulture)); + item.SubItems.Add(UiUtil.GetListViewTextFromString(p.Text)); + item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); + listViewFixes.Items.Add(item); + } + + private void FormRemoveTextForHearImpaired_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#remove_text_for_hi"); + } + } + + private void ButtonOkClick(object sender, EventArgs e) + { + Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenBrackets = checkBoxRemoveTextBetweenSquares.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenParentheses = checkBoxRemoveTextBetweenParentheses.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCurlyBrackets = checkBoxRemoveTextBetweenBrackets.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenQuestionMarks = checkBoxRemoveTextBetweenQuestionMarks.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustom = checkBoxRemoveTextBetweenCustomTags.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustomBefore = comboBoxCustomStart.Text; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustomAfter = comboBoxCustomEnd.Text; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenOnlySeparateLines = checkBoxOnlyIfInSeparateLine.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBeforeColon = checkBoxRemoveTextBeforeColon.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBeforeColonOnlyIfUppercase = checkBoxRemoveTextBeforeColonOnlyUppercase.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBeforeColonOnlyOnSeparateLine = checkBoxColonSeparateLine.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveInterjections = checkBoxRemoveInterjections.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveInterjectionsOnlyOnSeparateLine = checkBoxInterjectionOnlySeparateLine.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveIfContains = checkBoxRemoveWhereContains.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveIfAllUppercase = checkBoxRemoveIfAllUppercase.Checked; + Configuration.Settings.RemoveTextForHearingImpaired.RemoveIfContainsText = comboBoxRemoveIfTextContains.Text; + + ApplyChanges(); + DialogResult = DialogResult.OK; + } + + private void buttonApply_Click(object sender, EventArgs e) + { + ApplyChanges(); + GeneratePreview(); + } + + private void ApplyChanges() + { + if (Subtitle == null) + { + return; + } + + int fixes = RemoveTextFromHearImpaired(); + Subtitle.Renumber(); + if (_mainForm != null && fixes > 0) + { + TotalFixes += fixes; + _mainForm.ReloadFromSubtitle(new Subtitle(Subtitle), Configuration.Settings.Language.Main.BeforeRemovalOfTextingForHearingImpaired); + } + } + + public int RemoveTextFromHearImpaired() + { + _unchecked.Clear(); + int fixes = 0; + + for (int i = listViewFixes.Items.Count - 1; i >= 0; i--) + { + var item = listViewFixes.Items[i]; + var p = (Paragraph)item.Tag; + if (item.Checked) + { + string newText = _fixes[p]; + if (string.IsNullOrWhiteSpace(newText)) + { + Subtitle.Paragraphs.Remove(p); + } + else + { + p.Text = newText; + } + fixes++; + } + else + { + _unchecked.Add(p); + } + } + return fixes; + } + + private void CheckBoxRemoveTextBetweenCheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void checkBoxRemoveInterjections_CheckedChanged(object sender, EventArgs e) + { + checkBoxInterjectionOnlySeparateLine.Enabled = checkBoxRemoveInterjections.Checked; + GeneratePreview(); + } + + private void buttonEditInterjections_Click(object sender, EventArgs e) + { + using (var editInterjections = new Interjections()) + { + editInterjections.Initialize(Configuration.Settings.Tools.Interjections); + if (editInterjections.ShowDialog(this) == DialogResult.OK) + { + Configuration.Settings.Tools.Interjections = editInterjections.GetInterjectionsSemiColonSeparatedString(); + _removeTextForHiLib.ReloadInterjection(); + if (checkBoxRemoveInterjections.Checked) + { + GeneratePreview(); + } + } + } + } + + private void FormRemoveTextForHearImpaired_Resize(object sender, EventArgs e) + { + int availableWidth = (listViewFixes.Width - (columnHeaderApply.Width + columnHeaderLine.Width + 20)) / 2; + + columnHeaderBefore.Width = availableWidth; + columnHeaderAfter.Width = availableWidth; + } + + private void checkBoxRemoveTextBeforeColon_CheckedChanged(object sender, EventArgs e) + { + checkBoxRemoveTextBeforeColonOnlyUppercase.Enabled = checkBoxRemoveTextBeforeColon.Checked; + checkBoxColonSeparateLine.Enabled = checkBoxRemoveTextBeforeColon.Checked; + GeneratePreview(); + } + + private void checkBoxRemoveIfAllUppercase_CheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + public RemoveTextForHISettings GetSettings(Subtitle subtitle) + { + var settings = new RemoveTextForHISettings(subtitle) + { + OnlyIfInSeparateLine = checkBoxOnlyIfInSeparateLine.Checked, + RemoveIfAllUppercase = checkBoxRemoveIfAllUppercase.Checked, + RemoveTextBeforeColon = checkBoxRemoveTextBeforeColon.Checked, + RemoveTextBeforeColonOnlyUppercase = checkBoxRemoveTextBeforeColonOnlyUppercase.Checked, + ColonSeparateLine = checkBoxColonSeparateLine.Checked, + RemoveWhereContains = checkBoxRemoveWhereContains.Checked, + RemoveIfTextContains = new List(), + RemoveTextBetweenCustomTags = checkBoxRemoveTextBetweenCustomTags.Checked, + RemoveInterjections = checkBoxRemoveInterjections.Checked, + RemoveInterjectionsOnlySeparateLine = checkBoxRemoveInterjections.Checked && checkBoxInterjectionOnlySeparateLine.Checked, + RemoveTextBetweenSquares = checkBoxRemoveTextBetweenSquares.Checked, + RemoveTextBetweenBrackets = checkBoxRemoveTextBetweenBrackets.Checked, + RemoveTextBetweenQuestionMarks = checkBoxRemoveTextBetweenQuestionMarks.Checked, + RemoveTextBetweenParentheses = checkBoxRemoveTextBetweenParentheses.Checked, + CustomStart = comboBoxCustomStart.Text, + CustomEnd = comboBoxCustomEnd.Text + }; + foreach (string item in comboBoxRemoveIfTextContains.Text.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)) + { + settings.RemoveIfTextContains.Add(item.Trim()); + } + return settings; + } + + private void FormRemoveTextForHearImpaired_Load(object sender, EventArgs e) + { + // only works when used from "Form Load" + comboBoxCustomStart.Text = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustomBefore; + comboBoxCustomEnd.Text = Configuration.Settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustomAfter; + comboBoxRemoveIfTextContains.Text = Configuration.Settings.RemoveTextForHearingImpaired.RemoveIfContainsText; + } + + private void toolStripMenuItemSelAll_Click(object sender, EventArgs e) + { + DoSelection(true); + } + + private void toolStripMenuItemInvertSel_Click(object sender, EventArgs e) + { + DoSelection(false); + } + + private void DoSelection(bool selectAll) + { + if (listViewFixes.Items.Count == 0) + { + return; + } + + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = selectAll || !item.Checked; + } + } + + private void listViewFixes_ItemChecked(object sender, ItemCheckedEventArgs e) + { + if (!(e.Item.Tag is Paragraph p)) + { + return; + } + + if (e.Item.Checked) + { + if (_unchecked.Contains(p)) + { + _unchecked.Add(p); + } + } + else + { + if (!_unchecked.Contains(p)) + { + _unchecked.Remove(p); + } + } + } + + private void checkBoxInterjectionOnlySeparateLine_CheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e) + { + var idx = listViewFixes.SelectedIndices.Count == 1 ? listViewFixes.SelectedIndices[0] : -1; + if (idx < 0) + { + textBoxAfterText.Visible = false; + labelText.Visible = false; + return; + } + + textBoxAfterText.TextChanged -= textBoxAfterText_TextChanged; + textBoxAfterText.Visible = true; + labelText.Visible = true; + var item = listViewFixes.Items[idx]; + var p = (Paragraph)item.Tag; + textBoxAfterText.Tag = item; + var text = _fixes[p]; + textBoxAfterText.Text = text; + textBoxAfterText.TextChanged += textBoxAfterText_TextChanged; + } + + private void textBoxAfterText_TextChanged(object sender, EventArgs e) + { + var text = textBoxAfterText.Text.Trim(); + var item = (ListViewItem)textBoxAfterText.Tag; + var p = (Paragraph)item.Tag; + _editedOld.Add(new Paragraph(p, false) { Text = p.Text }); + item.SubItems[3].Text = text; + _fixes[p] = text; + var o = Subtitle.GetParagraphOrDefaultById(p.Id); + o.Text = text; + _edited.Add(p); + } + } +} diff --git a/src/Forms/RemoveTextFromHearImpaired.resx b/src/ui/Forms/RemoveTextFromHearImpaired.resx similarity index 97% rename from src/Forms/RemoveTextFromHearImpaired.resx rename to src/ui/Forms/RemoveTextFromHearImpaired.resx index 98381cccc..15f75b3cd 100644 --- a/src/Forms/RemoveTextFromHearImpaired.resx +++ b/src/ui/Forms/RemoveTextFromHearImpaired.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/ReplaceDialog.Designer.cs b/src/ui/Forms/ReplaceDialog.Designer.cs similarity index 98% rename from src/Forms/ReplaceDialog.Designer.cs rename to src/ui/Forms/ReplaceDialog.Designer.cs index 61f07f3a8..fca8430e1 100644 --- a/src/Forms/ReplaceDialog.Designer.cs +++ b/src/ui/Forms/ReplaceDialog.Designer.cs @@ -1,206 +1,206 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ReplaceDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.radioButtonRegEx = new System.Windows.Forms.RadioButton(); - this.radioButtonCaseSensitive = new System.Windows.Forms.RadioButton(); - this.radioButtonNormal = new System.Windows.Forms.RadioButton(); - this.buttonReplace = new System.Windows.Forms.Button(); - this.textBoxFind = new System.Windows.Forms.TextBox(); - this.buttonReplaceAll = new System.Windows.Forms.Button(); - this.textBoxReplace = new System.Windows.Forms.TextBox(); - this.labelReplaceWith = new System.Windows.Forms.Label(); - this.labelFindWhat = new System.Windows.Forms.Label(); - this.buttonFind = new System.Windows.Forms.Button(); - this.checkBoxWholeWord = new System.Windows.Forms.CheckBox(); - this.SuspendLayout(); - // - // radioButtonRegEx - // - this.radioButtonRegEx.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.radioButtonRegEx.AutoSize = true; - this.radioButtonRegEx.Location = new System.Drawing.Point(15, 182); - this.radioButtonRegEx.Name = "radioButtonRegEx"; - this.radioButtonRegEx.Size = new System.Drawing.Size(56, 17); - this.radioButtonRegEx.TabIndex = 5; - this.radioButtonRegEx.Text = "RegEx"; - this.radioButtonRegEx.UseVisualStyleBackColor = true; - this.radioButtonRegEx.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // - // radioButtonCaseSensitive - // - this.radioButtonCaseSensitive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.radioButtonCaseSensitive.AutoSize = true; - this.radioButtonCaseSensitive.Location = new System.Drawing.Point(15, 159); - this.radioButtonCaseSensitive.Name = "radioButtonCaseSensitive"; - this.radioButtonCaseSensitive.Size = new System.Drawing.Size(94, 17); - this.radioButtonCaseSensitive.TabIndex = 4; - this.radioButtonCaseSensitive.Text = "Case sensitive"; - this.radioButtonCaseSensitive.UseVisualStyleBackColor = true; - this.radioButtonCaseSensitive.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // - // radioButtonNormal - // - this.radioButtonNormal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.radioButtonNormal.AutoSize = true; - this.radioButtonNormal.Checked = true; - this.radioButtonNormal.Location = new System.Drawing.Point(15, 136); - this.radioButtonNormal.Name = "radioButtonNormal"; - this.radioButtonNormal.Size = new System.Drawing.Size(58, 17); - this.radioButtonNormal.TabIndex = 3; - this.radioButtonNormal.TabStop = true; - this.radioButtonNormal.Text = "Normal"; - this.radioButtonNormal.UseVisualStyleBackColor = true; - this.radioButtonNormal.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // - // buttonReplace - // - this.buttonReplace.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonReplace.Location = new System.Drawing.Point(93, 206); - this.buttonReplace.Name = "buttonReplace"; - this.buttonReplace.Size = new System.Drawing.Size(75, 23); - this.buttonReplace.TabIndex = 7; - this.buttonReplace.Text = "Replace"; - this.buttonReplace.UseVisualStyleBackColor = true; - this.buttonReplace.Click += new System.EventHandler(this.ButtonReplaceClick); - // - // textBoxFind - // - this.textBoxFind.Location = new System.Drawing.Point(15, 25); - this.textBoxFind.Name = "textBoxFind"; - this.textBoxFind.Size = new System.Drawing.Size(265, 21); - this.textBoxFind.TabIndex = 0; - this.textBoxFind.TextChanged += new System.EventHandler(this.textBoxFind_TextChanged); - this.textBoxFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxFindKeyDown); - // - // buttonReplaceAll - // - this.buttonReplaceAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonReplaceAll.Location = new System.Drawing.Point(174, 206); - this.buttonReplaceAll.Name = "buttonReplaceAll"; - this.buttonReplaceAll.Size = new System.Drawing.Size(103, 23); - this.buttonReplaceAll.TabIndex = 8; - this.buttonReplaceAll.Text = "Replace all"; - this.buttonReplaceAll.UseVisualStyleBackColor = true; - this.buttonReplaceAll.Click += new System.EventHandler(this.ButtonReplaceAllClick); - // - // textBoxReplace - // - this.textBoxReplace.Location = new System.Drawing.Point(15, 71); - this.textBoxReplace.Name = "textBoxReplace"; - this.textBoxReplace.Size = new System.Drawing.Size(265, 21); - this.textBoxReplace.TabIndex = 1; - this.textBoxReplace.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxFindKeyDown); - // - // labelReplaceWith - // - this.labelReplaceWith.AutoSize = true; - this.labelReplaceWith.Location = new System.Drawing.Point(12, 54); - this.labelReplaceWith.Name = "labelReplaceWith"; - this.labelReplaceWith.Size = new System.Drawing.Size(72, 13); - this.labelReplaceWith.TabIndex = 14; - this.labelReplaceWith.Text = "Replace with:"; - // - // labelFindWhat - // - this.labelFindWhat.AutoSize = true; - this.labelFindWhat.Location = new System.Drawing.Point(12, 8); - this.labelFindWhat.Name = "labelFindWhat"; - this.labelFindWhat.Size = new System.Drawing.Size(58, 13); - this.labelFindWhat.TabIndex = 9; - this.labelFindWhat.Text = "Find what:"; - // - // buttonFind - // - this.buttonFind.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonFind.Location = new System.Drawing.Point(12, 206); - this.buttonFind.Name = "buttonFind"; - this.buttonFind.Size = new System.Drawing.Size(75, 23); - this.buttonFind.TabIndex = 6; - this.buttonFind.Text = "Find"; - this.buttonFind.UseVisualStyleBackColor = true; - this.buttonFind.Click += new System.EventHandler(this.ButtonFindClick); - // - // checkBoxWholeWord - // - this.checkBoxWholeWord.AutoSize = true; - this.checkBoxWholeWord.Location = new System.Drawing.Point(15, 114); - this.checkBoxWholeWord.Name = "checkBoxWholeWord"; - this.checkBoxWholeWord.Size = new System.Drawing.Size(83, 17); - this.checkBoxWholeWord.TabIndex = 2; - this.checkBoxWholeWord.Text = "Whole word"; - this.checkBoxWholeWord.UseVisualStyleBackColor = true; - // - // ReplaceDialog - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(330, 241); - this.Controls.Add(this.checkBoxWholeWord); - this.Controls.Add(this.buttonFind); - this.Controls.Add(this.labelFindWhat); - this.Controls.Add(this.labelReplaceWith); - this.Controls.Add(this.textBoxReplace); - this.Controls.Add(this.buttonReplaceAll); - this.Controls.Add(this.radioButtonRegEx); - this.Controls.Add(this.radioButtonCaseSensitive); - this.Controls.Add(this.radioButtonNormal); - this.Controls.Add(this.buttonReplace); - this.Controls.Add(this.textBoxFind); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ReplaceDialog"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Replace"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ReplaceDialog_FormClosing); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormReplaceDialog_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.RadioButton radioButtonRegEx; - private System.Windows.Forms.RadioButton radioButtonCaseSensitive; - private System.Windows.Forms.RadioButton radioButtonNormal; - private System.Windows.Forms.Button buttonReplace; - private System.Windows.Forms.TextBox textBoxFind; - private System.Windows.Forms.Button buttonReplaceAll; - private System.Windows.Forms.TextBox textBoxReplace; - private System.Windows.Forms.Label labelReplaceWith; - private System.Windows.Forms.Label labelFindWhat; - private System.Windows.Forms.Button buttonFind; - private System.Windows.Forms.CheckBox checkBoxWholeWord; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ReplaceDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.radioButtonRegEx = new System.Windows.Forms.RadioButton(); + this.radioButtonCaseSensitive = new System.Windows.Forms.RadioButton(); + this.radioButtonNormal = new System.Windows.Forms.RadioButton(); + this.buttonReplace = new System.Windows.Forms.Button(); + this.textBoxFind = new System.Windows.Forms.TextBox(); + this.buttonReplaceAll = new System.Windows.Forms.Button(); + this.textBoxReplace = new System.Windows.Forms.TextBox(); + this.labelReplaceWith = new System.Windows.Forms.Label(); + this.labelFindWhat = new System.Windows.Forms.Label(); + this.buttonFind = new System.Windows.Forms.Button(); + this.checkBoxWholeWord = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // radioButtonRegEx + // + this.radioButtonRegEx.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.radioButtonRegEx.AutoSize = true; + this.radioButtonRegEx.Location = new System.Drawing.Point(15, 182); + this.radioButtonRegEx.Name = "radioButtonRegEx"; + this.radioButtonRegEx.Size = new System.Drawing.Size(56, 17); + this.radioButtonRegEx.TabIndex = 5; + this.radioButtonRegEx.Text = "RegEx"; + this.radioButtonRegEx.UseVisualStyleBackColor = true; + this.radioButtonRegEx.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); + // + // radioButtonCaseSensitive + // + this.radioButtonCaseSensitive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.radioButtonCaseSensitive.AutoSize = true; + this.radioButtonCaseSensitive.Location = new System.Drawing.Point(15, 159); + this.radioButtonCaseSensitive.Name = "radioButtonCaseSensitive"; + this.radioButtonCaseSensitive.Size = new System.Drawing.Size(94, 17); + this.radioButtonCaseSensitive.TabIndex = 4; + this.radioButtonCaseSensitive.Text = "Case sensitive"; + this.radioButtonCaseSensitive.UseVisualStyleBackColor = true; + this.radioButtonCaseSensitive.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); + // + // radioButtonNormal + // + this.radioButtonNormal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.radioButtonNormal.AutoSize = true; + this.radioButtonNormal.Checked = true; + this.radioButtonNormal.Location = new System.Drawing.Point(15, 136); + this.radioButtonNormal.Name = "radioButtonNormal"; + this.radioButtonNormal.Size = new System.Drawing.Size(58, 17); + this.radioButtonNormal.TabIndex = 3; + this.radioButtonNormal.TabStop = true; + this.radioButtonNormal.Text = "Normal"; + this.radioButtonNormal.UseVisualStyleBackColor = true; + this.radioButtonNormal.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); + // + // buttonReplace + // + this.buttonReplace.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonReplace.Location = new System.Drawing.Point(93, 206); + this.buttonReplace.Name = "buttonReplace"; + this.buttonReplace.Size = new System.Drawing.Size(75, 23); + this.buttonReplace.TabIndex = 7; + this.buttonReplace.Text = "Replace"; + this.buttonReplace.UseVisualStyleBackColor = true; + this.buttonReplace.Click += new System.EventHandler(this.ButtonReplaceClick); + // + // textBoxFind + // + this.textBoxFind.Location = new System.Drawing.Point(15, 25); + this.textBoxFind.Name = "textBoxFind"; + this.textBoxFind.Size = new System.Drawing.Size(265, 21); + this.textBoxFind.TabIndex = 0; + this.textBoxFind.TextChanged += new System.EventHandler(this.textBoxFind_TextChanged); + this.textBoxFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxFindKeyDown); + // + // buttonReplaceAll + // + this.buttonReplaceAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonReplaceAll.Location = new System.Drawing.Point(174, 206); + this.buttonReplaceAll.Name = "buttonReplaceAll"; + this.buttonReplaceAll.Size = new System.Drawing.Size(103, 23); + this.buttonReplaceAll.TabIndex = 8; + this.buttonReplaceAll.Text = "Replace all"; + this.buttonReplaceAll.UseVisualStyleBackColor = true; + this.buttonReplaceAll.Click += new System.EventHandler(this.ButtonReplaceAllClick); + // + // textBoxReplace + // + this.textBoxReplace.Location = new System.Drawing.Point(15, 71); + this.textBoxReplace.Name = "textBoxReplace"; + this.textBoxReplace.Size = new System.Drawing.Size(265, 21); + this.textBoxReplace.TabIndex = 1; + this.textBoxReplace.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxFindKeyDown); + // + // labelReplaceWith + // + this.labelReplaceWith.AutoSize = true; + this.labelReplaceWith.Location = new System.Drawing.Point(12, 54); + this.labelReplaceWith.Name = "labelReplaceWith"; + this.labelReplaceWith.Size = new System.Drawing.Size(72, 13); + this.labelReplaceWith.TabIndex = 14; + this.labelReplaceWith.Text = "Replace with:"; + // + // labelFindWhat + // + this.labelFindWhat.AutoSize = true; + this.labelFindWhat.Location = new System.Drawing.Point(12, 8); + this.labelFindWhat.Name = "labelFindWhat"; + this.labelFindWhat.Size = new System.Drawing.Size(58, 13); + this.labelFindWhat.TabIndex = 9; + this.labelFindWhat.Text = "Find what:"; + // + // buttonFind + // + this.buttonFind.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonFind.Location = new System.Drawing.Point(12, 206); + this.buttonFind.Name = "buttonFind"; + this.buttonFind.Size = new System.Drawing.Size(75, 23); + this.buttonFind.TabIndex = 6; + this.buttonFind.Text = "Find"; + this.buttonFind.UseVisualStyleBackColor = true; + this.buttonFind.Click += new System.EventHandler(this.ButtonFindClick); + // + // checkBoxWholeWord + // + this.checkBoxWholeWord.AutoSize = true; + this.checkBoxWholeWord.Location = new System.Drawing.Point(15, 114); + this.checkBoxWholeWord.Name = "checkBoxWholeWord"; + this.checkBoxWholeWord.Size = new System.Drawing.Size(83, 17); + this.checkBoxWholeWord.TabIndex = 2; + this.checkBoxWholeWord.Text = "Whole word"; + this.checkBoxWholeWord.UseVisualStyleBackColor = true; + // + // ReplaceDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(330, 241); + this.Controls.Add(this.checkBoxWholeWord); + this.Controls.Add(this.buttonFind); + this.Controls.Add(this.labelFindWhat); + this.Controls.Add(this.labelReplaceWith); + this.Controls.Add(this.textBoxReplace); + this.Controls.Add(this.buttonReplaceAll); + this.Controls.Add(this.radioButtonRegEx); + this.Controls.Add(this.radioButtonCaseSensitive); + this.Controls.Add(this.radioButtonNormal); + this.Controls.Add(this.buttonReplace); + this.Controls.Add(this.textBoxFind); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ReplaceDialog"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Replace"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ReplaceDialog_FormClosing); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormReplaceDialog_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.RadioButton radioButtonRegEx; + private System.Windows.Forms.RadioButton radioButtonCaseSensitive; + private System.Windows.Forms.RadioButton radioButtonNormal; + private System.Windows.Forms.Button buttonReplace; + private System.Windows.Forms.TextBox textBoxFind; + private System.Windows.Forms.Button buttonReplaceAll; + private System.Windows.Forms.TextBox textBoxReplace; + private System.Windows.Forms.Label labelReplaceWith; + private System.Windows.Forms.Label labelFindWhat; + private System.Windows.Forms.Button buttonFind; + private System.Windows.Forms.CheckBox checkBoxWholeWord; + } } \ No newline at end of file diff --git a/src/Forms/ReplaceDialog.cs b/src/ui/Forms/ReplaceDialog.cs similarity index 96% rename from src/Forms/ReplaceDialog.cs rename to src/ui/Forms/ReplaceDialog.cs index 491e4c27f..f6e7ab5fa 100644 --- a/src/Forms/ReplaceDialog.cs +++ b/src/ui/Forms/ReplaceDialog.cs @@ -1,217 +1,217 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Enums; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Drawing; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ReplaceDialog : PositionAndSizeForm - { - private Regex _regEx; - private bool _userAction; - private bool _findNext; - private FindReplaceDialogHelper _findHelper; - - public ReplaceDialog() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.ReplaceDialog.Title; - labelFindWhat.Text = Configuration.Settings.Language.ReplaceDialog.FindWhat; - radioButtonNormal.Text = Configuration.Settings.Language.ReplaceDialog.Normal; - radioButtonCaseSensitive.Text = Configuration.Settings.Language.ReplaceDialog.CaseSensitive; - radioButtonRegEx.Text = Configuration.Settings.Language.ReplaceDialog.RegularExpression; - labelReplaceWith.Text = Configuration.Settings.Language.ReplaceDialog.ReplaceWith; - checkBoxWholeWord.Text = Configuration.Settings.Language.FindDialog.WholeWord; - buttonFind.Text = Configuration.Settings.Language.ReplaceDialog.Find; - buttonReplace.Text = Configuration.Settings.Language.ReplaceDialog.Replace; - buttonReplaceAll.Text = Configuration.Settings.Language.ReplaceDialog.ReplaceAll; - - if (Width < radioButtonRegEx.Right + 5) - { - Width = radioButtonRegEx.Right + 5; - } - - UiUtil.FixLargeFonts(this, buttonReplace); - } - - public bool ReplaceAll { get; set; } - public bool FindOnly { get; set; } - - public ReplaceType GetFindType() - { - var result = new ReplaceType(); - if (radioButtonNormal.Checked) - { - result.FindType = FindType.Normal; - } - else if (radioButtonCaseSensitive.Checked) - { - result.FindType = FindType.CaseSensitive; - } - else - { - result.FindType = FindType.RegEx; - } - - result.WholeWord = checkBoxWholeWord.Checked; - return result; - } - - public FindReplaceDialogHelper GetFindDialogHelper(int startLineIndex) - { - return new FindReplaceDialogHelper(GetFindType(), textBoxFind.Text, _regEx, textBoxReplace.Text, startLineIndex); - } - - private void FormReplaceDialog_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - internal void Initialize(string selectedText, FindReplaceDialogHelper findHelper) - { - _findHelper = findHelper; - textBoxFind.Text = selectedText; - if (FindOnly && !string.IsNullOrEmpty(selectedText)) - { - _findNext = true; - } - - //if we are searching for the same thing, then keep the replace text the same. - if (selectedText == findHelper.FindText) - { - textBoxReplace.Text = findHelper.ReplaceText.Replace(Environment.NewLine, "\\n"); - } - textBoxFind.SelectAll(); - if (findHelper.FindReplaceType.FindType == FindType.RegEx) - { - radioButtonRegEx.Checked = true; - } - else if (findHelper.FindReplaceType.FindType == FindType.CaseSensitive) - { - radioButtonCaseSensitive.Checked = true; - } - else - { - radioButtonNormal.Checked = true; - } - - if (findHelper.FindReplaceType.FindType != FindType.RegEx) - { - checkBoxWholeWord.Checked = findHelper.FindReplaceType.WholeWord; - } - } - - private void ButtonReplaceClick(object sender, EventArgs e) - { - ReplaceAll = false; - FindOnly = false; - - Validate(textBoxFind.Text); - } - - private void ButtonReplaceAllClick(object sender, EventArgs e) - { - ReplaceAll = true; - FindOnly = false; - - Validate(textBoxFind.Text); - } - - private void Validate(string searchText) - { - if (searchText.Length == 0) - { - DialogResult = DialogResult.Cancel; - } - else if (radioButtonNormal.Checked) - { - DialogResult = DialogResult.OK; - _userAction = true; - } - else if (radioButtonCaseSensitive.Checked) - { - DialogResult = DialogResult.OK; - _userAction = true; - } - else if (radioButtonRegEx.Checked) - { - try - { - _regEx = new Regex(RegexUtils.FixNewLine(textBoxFind.Text), RegexOptions.Compiled); - DialogResult = DialogResult.OK; - _userAction = true; - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - } - } - } - - private void ButtonFindClick(object sender, EventArgs e) - { - if (_findNext && _findHelper != null) - { - _findHelper.ReplaceFromPosition++; - } - - ReplaceAll = false; - FindOnly = true; - - Validate(textBoxFind.Text); - } - - private void RadioButtonCheckedChanged(object sender, EventArgs e) - { - if (sender == radioButtonRegEx) - { - textBoxFind.ContextMenu = FindReplaceDialogHelper.GetRegExContextMenu(textBoxFind); - } - else - { - textBoxFind.ContextMenu = null; - } - checkBoxWholeWord.Enabled = !radioButtonRegEx.Checked; - } - - private void TextBoxFindKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - ButtonFindClick(null, null); - e.SuppressKeyPress = true; - } - } - - internal void SetIcon(Bitmap bitmap) - { - if (bitmap != null) - { - Icon = Icon.FromHandle(bitmap.GetHicon()); - } - } - - private void ReplaceDialog_FormClosing(object sender, FormClosingEventArgs e) - { - if (!_userAction) - { - DialogResult = DialogResult.Cancel; - } - } - - private void textBoxFind_TextChanged(object sender, EventArgs e) - { - _findNext = false; - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Enums; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Drawing; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ReplaceDialog : PositionAndSizeForm + { + private Regex _regEx; + private bool _userAction; + private bool _findNext; + private FindReplaceDialogHelper _findHelper; + + public ReplaceDialog() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.ReplaceDialog.Title; + labelFindWhat.Text = Configuration.Settings.Language.ReplaceDialog.FindWhat; + radioButtonNormal.Text = Configuration.Settings.Language.ReplaceDialog.Normal; + radioButtonCaseSensitive.Text = Configuration.Settings.Language.ReplaceDialog.CaseSensitive; + radioButtonRegEx.Text = Configuration.Settings.Language.ReplaceDialog.RegularExpression; + labelReplaceWith.Text = Configuration.Settings.Language.ReplaceDialog.ReplaceWith; + checkBoxWholeWord.Text = Configuration.Settings.Language.FindDialog.WholeWord; + buttonFind.Text = Configuration.Settings.Language.ReplaceDialog.Find; + buttonReplace.Text = Configuration.Settings.Language.ReplaceDialog.Replace; + buttonReplaceAll.Text = Configuration.Settings.Language.ReplaceDialog.ReplaceAll; + + if (Width < radioButtonRegEx.Right + 5) + { + Width = radioButtonRegEx.Right + 5; + } + + UiUtil.FixLargeFonts(this, buttonReplace); + } + + public bool ReplaceAll { get; set; } + public bool FindOnly { get; set; } + + public ReplaceType GetFindType() + { + var result = new ReplaceType(); + if (radioButtonNormal.Checked) + { + result.FindType = FindType.Normal; + } + else if (radioButtonCaseSensitive.Checked) + { + result.FindType = FindType.CaseSensitive; + } + else + { + result.FindType = FindType.RegEx; + } + + result.WholeWord = checkBoxWholeWord.Checked; + return result; + } + + public FindReplaceDialogHelper GetFindDialogHelper(int startLineIndex) + { + return new FindReplaceDialogHelper(GetFindType(), textBoxFind.Text, _regEx, textBoxReplace.Text, startLineIndex); + } + + private void FormReplaceDialog_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + internal void Initialize(string selectedText, FindReplaceDialogHelper findHelper) + { + _findHelper = findHelper; + textBoxFind.Text = selectedText; + if (FindOnly && !string.IsNullOrEmpty(selectedText)) + { + _findNext = true; + } + + //if we are searching for the same thing, then keep the replace text the same. + if (selectedText == findHelper.FindText) + { + textBoxReplace.Text = findHelper.ReplaceText.Replace(Environment.NewLine, "\\n"); + } + textBoxFind.SelectAll(); + if (findHelper.FindReplaceType.FindType == FindType.RegEx) + { + radioButtonRegEx.Checked = true; + } + else if (findHelper.FindReplaceType.FindType == FindType.CaseSensitive) + { + radioButtonCaseSensitive.Checked = true; + } + else + { + radioButtonNormal.Checked = true; + } + + if (findHelper.FindReplaceType.FindType != FindType.RegEx) + { + checkBoxWholeWord.Checked = findHelper.FindReplaceType.WholeWord; + } + } + + private void ButtonReplaceClick(object sender, EventArgs e) + { + ReplaceAll = false; + FindOnly = false; + + Validate(textBoxFind.Text); + } + + private void ButtonReplaceAllClick(object sender, EventArgs e) + { + ReplaceAll = true; + FindOnly = false; + + Validate(textBoxFind.Text); + } + + private void Validate(string searchText) + { + if (searchText.Length == 0) + { + DialogResult = DialogResult.Cancel; + } + else if (radioButtonNormal.Checked) + { + DialogResult = DialogResult.OK; + _userAction = true; + } + else if (radioButtonCaseSensitive.Checked) + { + DialogResult = DialogResult.OK; + _userAction = true; + } + else if (radioButtonRegEx.Checked) + { + try + { + _regEx = new Regex(RegexUtils.FixNewLine(textBoxFind.Text), RegexOptions.Compiled); + DialogResult = DialogResult.OK; + _userAction = true; + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + } + } + } + + private void ButtonFindClick(object sender, EventArgs e) + { + if (_findNext && _findHelper != null) + { + _findHelper.ReplaceFromPosition++; + } + + ReplaceAll = false; + FindOnly = true; + + Validate(textBoxFind.Text); + } + + private void RadioButtonCheckedChanged(object sender, EventArgs e) + { + if (sender == radioButtonRegEx) + { + textBoxFind.ContextMenu = FindReplaceDialogHelper.GetRegExContextMenu(textBoxFind); + } + else + { + textBoxFind.ContextMenu = null; + } + checkBoxWholeWord.Enabled = !radioButtonRegEx.Checked; + } + + private void TextBoxFindKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + ButtonFindClick(null, null); + e.SuppressKeyPress = true; + } + } + + internal void SetIcon(Bitmap bitmap) + { + if (bitmap != null) + { + Icon = Icon.FromHandle(bitmap.GetHicon()); + } + } + + private void ReplaceDialog_FormClosing(object sender, FormClosingEventArgs e) + { + if (!_userAction) + { + DialogResult = DialogResult.Cancel; + } + } + + private void textBoxFind_TextChanged(object sender, EventArgs e) + { + _findNext = false; + } + } +} diff --git a/src/Forms/ReplaceDialog.resx b/src/ui/Forms/ReplaceDialog.resx similarity index 97% rename from src/Forms/ReplaceDialog.resx rename to src/ui/Forms/ReplaceDialog.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/ReplaceDialog.resx +++ b/src/ui/Forms/ReplaceDialog.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/RestoreAutoBackup.Designer.cs b/src/ui/Forms/RestoreAutoBackup.Designer.cs similarity index 98% rename from src/Forms/RestoreAutoBackup.Designer.cs rename to src/ui/Forms/RestoreAutoBackup.Designer.cs index 755176840..52f271a75 100644 --- a/src/Forms/RestoreAutoBackup.Designer.cs +++ b/src/ui/Forms/RestoreAutoBackup.Designer.cs @@ -1,180 +1,180 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class RestoreAutoBackup - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.listViewBackups = new System.Windows.Forms.ListView(); - this.columnHeaderDateTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderFileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderExtension = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.labelInfo = new System.Windows.Forms.Label(); - this.linkLabelOpenContainingFolder = new System.Windows.Forms.LinkLabel(); - this.labelStatus = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(552, 383); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(471, 383); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 4; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // listViewBackups - // - this.listViewBackups.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewBackups.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderDateTime, - this.columnHeaderFileName, - this.columnHeaderExtension, - this.columnHeaderSize}); - this.listViewBackups.FullRowSelect = true; - this.listViewBackups.HideSelection = false; - this.listViewBackups.Location = new System.Drawing.Point(12, 37); - this.listViewBackups.MultiSelect = false; - this.listViewBackups.Name = "listViewBackups"; - this.listViewBackups.Size = new System.Drawing.Size(615, 333); - this.listViewBackups.TabIndex = 1; - this.listViewBackups.UseCompatibleStateImageBehavior = false; - this.listViewBackups.View = System.Windows.Forms.View.Details; - this.listViewBackups.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listViewBackups_MouseDoubleClick); - // - // columnHeaderDateTime - // - this.columnHeaderDateTime.Text = "Date and time"; - this.columnHeaderDateTime.Width = 130; - // - // columnHeaderFileName - // - this.columnHeaderFileName.Text = "File name"; - this.columnHeaderFileName.Width = 300; - // - // columnHeaderExtension - // - this.columnHeaderExtension.Text = "Extension"; - this.columnHeaderExtension.Width = 80; - // - // columnHeaderSize - // - this.columnHeaderSize.Text = "Size"; - this.columnHeaderSize.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.columnHeaderSize.Width = 101; - // - // labelInfo - // - this.labelInfo.AutoSize = true; - this.labelInfo.Location = new System.Drawing.Point(13, 13); - this.labelInfo.Name = "labelInfo"; - this.labelInfo.Size = new System.Drawing.Size(122, 13); - this.labelInfo.TabIndex = 0; - this.labelInfo.Text = "Open auto save backup"; - // - // linkLabelOpenContainingFolder - // - this.linkLabelOpenContainingFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.linkLabelOpenContainingFolder.AutoSize = true; - this.linkLabelOpenContainingFolder.Location = new System.Drawing.Point(13, 387); - this.linkLabelOpenContainingFolder.Name = "linkLabelOpenContainingFolder"; - this.linkLabelOpenContainingFolder.Size = new System.Drawing.Size(124, 13); - this.linkLabelOpenContainingFolder.TabIndex = 2; - this.linkLabelOpenContainingFolder.TabStop = true; - this.linkLabelOpenContainingFolder.Text = "Open \'Dictionaries\' folder"; - this.linkLabelOpenContainingFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelOpenContainingFolder_LinkClicked); - // - // labelStatus - // - this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelStatus.AutoSize = true; - this.labelStatus.Location = new System.Drawing.Point(186, 387); - this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(59, 13); - this.labelStatus.TabIndex = 3; - this.labelStatus.Text = "labelStatus"; - // - // RestoreAutoBackup - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(639, 414); - this.Controls.Add(this.labelStatus); - this.Controls.Add(this.linkLabelOpenContainingFolder); - this.Controls.Add(this.labelInfo); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.listViewBackups); - this.KeyPreview = true; - this.MinimumSize = new System.Drawing.Size(500, 400); - this.Name = "RestoreAutoBackup"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Restore auto-backup"; - this.Shown += new System.EventHandler(this.RestoreAutoBackup_Shown); - this.ResizeEnd += new System.EventHandler(this.RestoreAutoBackup_ResizeEnd); - this.SizeChanged += new System.EventHandler(this.RestoreAutoBackup_SizeChanged); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.RestoreAutoBackup_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.ListView listViewBackups; - private System.Windows.Forms.ColumnHeader columnHeaderDateTime; - private System.Windows.Forms.ColumnHeader columnHeaderFileName; - private System.Windows.Forms.ColumnHeader columnHeaderExtension; - private System.Windows.Forms.Label labelInfo; - private System.Windows.Forms.LinkLabel linkLabelOpenContainingFolder; - private System.Windows.Forms.Label labelStatus; - private System.Windows.Forms.ColumnHeader columnHeaderSize; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class RestoreAutoBackup + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.listViewBackups = new System.Windows.Forms.ListView(); + this.columnHeaderDateTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderFileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderExtension = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.labelInfo = new System.Windows.Forms.Label(); + this.linkLabelOpenContainingFolder = new System.Windows.Forms.LinkLabel(); + this.labelStatus = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(552, 383); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(471, 383); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 4; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // listViewBackups + // + this.listViewBackups.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewBackups.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeaderDateTime, + this.columnHeaderFileName, + this.columnHeaderExtension, + this.columnHeaderSize}); + this.listViewBackups.FullRowSelect = true; + this.listViewBackups.HideSelection = false; + this.listViewBackups.Location = new System.Drawing.Point(12, 37); + this.listViewBackups.MultiSelect = false; + this.listViewBackups.Name = "listViewBackups"; + this.listViewBackups.Size = new System.Drawing.Size(615, 333); + this.listViewBackups.TabIndex = 1; + this.listViewBackups.UseCompatibleStateImageBehavior = false; + this.listViewBackups.View = System.Windows.Forms.View.Details; + this.listViewBackups.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listViewBackups_MouseDoubleClick); + // + // columnHeaderDateTime + // + this.columnHeaderDateTime.Text = "Date and time"; + this.columnHeaderDateTime.Width = 130; + // + // columnHeaderFileName + // + this.columnHeaderFileName.Text = "File name"; + this.columnHeaderFileName.Width = 300; + // + // columnHeaderExtension + // + this.columnHeaderExtension.Text = "Extension"; + this.columnHeaderExtension.Width = 80; + // + // columnHeaderSize + // + this.columnHeaderSize.Text = "Size"; + this.columnHeaderSize.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.columnHeaderSize.Width = 101; + // + // labelInfo + // + this.labelInfo.AutoSize = true; + this.labelInfo.Location = new System.Drawing.Point(13, 13); + this.labelInfo.Name = "labelInfo"; + this.labelInfo.Size = new System.Drawing.Size(122, 13); + this.labelInfo.TabIndex = 0; + this.labelInfo.Text = "Open auto save backup"; + // + // linkLabelOpenContainingFolder + // + this.linkLabelOpenContainingFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.linkLabelOpenContainingFolder.AutoSize = true; + this.linkLabelOpenContainingFolder.Location = new System.Drawing.Point(13, 387); + this.linkLabelOpenContainingFolder.Name = "linkLabelOpenContainingFolder"; + this.linkLabelOpenContainingFolder.Size = new System.Drawing.Size(124, 13); + this.linkLabelOpenContainingFolder.TabIndex = 2; + this.linkLabelOpenContainingFolder.TabStop = true; + this.linkLabelOpenContainingFolder.Text = "Open \'Dictionaries\' folder"; + this.linkLabelOpenContainingFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelOpenContainingFolder_LinkClicked); + // + // labelStatus + // + this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(186, 387); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(59, 13); + this.labelStatus.TabIndex = 3; + this.labelStatus.Text = "labelStatus"; + // + // RestoreAutoBackup + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(639, 414); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.linkLabelOpenContainingFolder); + this.Controls.Add(this.labelInfo); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.listViewBackups); + this.KeyPreview = true; + this.MinimumSize = new System.Drawing.Size(500, 400); + this.Name = "RestoreAutoBackup"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Restore auto-backup"; + this.Shown += new System.EventHandler(this.RestoreAutoBackup_Shown); + this.ResizeEnd += new System.EventHandler(this.RestoreAutoBackup_ResizeEnd); + this.SizeChanged += new System.EventHandler(this.RestoreAutoBackup_SizeChanged); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.RestoreAutoBackup_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.ListView listViewBackups; + private System.Windows.Forms.ColumnHeader columnHeaderDateTime; + private System.Windows.Forms.ColumnHeader columnHeaderFileName; + private System.Windows.Forms.ColumnHeader columnHeaderExtension; + private System.Windows.Forms.Label labelInfo; + private System.Windows.Forms.LinkLabel linkLabelOpenContainingFolder; + private System.Windows.Forms.Label labelStatus; + private System.Windows.Forms.ColumnHeader columnHeaderSize; + } } \ No newline at end of file diff --git a/src/Forms/RestoreAutoBackup.cs b/src/ui/Forms/RestoreAutoBackup.cs similarity index 97% rename from src/Forms/RestoreAutoBackup.cs rename to src/ui/Forms/RestoreAutoBackup.cs index 0cc2ef39a..dfc300a82 100644 --- a/src/Forms/RestoreAutoBackup.cs +++ b/src/ui/Forms/RestoreAutoBackup.cs @@ -1,198 +1,198 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Globalization; -using System.IO; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class RestoreAutoBackup : PositionAndSizeForm - { - private static readonly object _locker = new object(); - - //2011-12-13_20-19-18_title - private static readonly Regex RegexFileNamePattern = new Regex(@"^\d\d\d\d-\d\d-\d\d_\d\d-\d\d-\d\d", RegexOptions.Compiled); - private string[] _files; - public string AutoBackupFileName { get; set; } - - public RestoreAutoBackup() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - labelStatus.Text = string.Empty; - - var l = Configuration.Settings.Language.RestoreAutoBackup; - Text = l.Title; - linkLabelOpenContainingFolder.Text = Configuration.Settings.Language.Main.Menu.File.OpenContainingFolder; - listViewBackups.Columns[0].Text = l.DateAndTime; - listViewBackups.Columns[1].Text = l.FileName; - listViewBackups.Columns[2].Text = l.Extension; - listViewBackups.Columns[3].Text = Configuration.Settings.Language.General.Size; - labelInfo.Text = l.Information; - - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - - UiUtil.FixLargeFonts(this, buttonCancel); - } - - private void RestoreAutoBackup_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void RestoreAutoBackup_Shown(object sender, EventArgs e) - { - listViewBackups.Columns[2].Width = -2; - if (Directory.Exists(Configuration.AutoBackupDirectory)) - { - _files = Directory.GetFiles(Configuration.AutoBackupDirectory, "*.*"); - foreach (string fileName in _files) - { - var path = Path.GetFileName(fileName); - if (path != null && RegexFileNamePattern.IsMatch(path)) - { - AddBackupToListView(fileName); - } - } - listViewBackups.Sorting = SortOrder.Descending; - listViewBackups.Sort(); - if (_files.Length > 0) - { - return; - } - } - linkLabelOpenContainingFolder.Visible = false; - labelStatus.Left = linkLabelOpenContainingFolder.Left; - labelStatus.Text = Configuration.Settings.Language.RestoreAutoBackup.NoBackedUpFilesFound; - } - - private void AddBackupToListView(string fileName) - { - var path = Path.GetFileName(fileName); - if (path == null) - { - return; - } - - string displayDate = path.Substring(0, 19).Replace('_', ' '); - displayDate = displayDate.Remove(13, 1).Insert(13, ":"); - displayDate = displayDate.Remove(16, 1).Insert(16, ":"); - - string displayName = path.Remove(0, 20); - if (displayName == "srt") - { - displayName = "Untitled.srt"; - } - - var item = new ListViewItem(displayDate) - { - UseItemStyleForSubItems = false, - Tag = fileName - }; - item.SubItems.Add(Path.GetFileNameWithoutExtension(displayName)); - item.SubItems.Add(Path.GetExtension(fileName)); - - try - { - item.SubItems.Add(new FileInfo(fileName).Length + " bytes"); - } - catch - { - // ignored - } - - listViewBackups.Items.Add(item); - } - - private void SetAutoBackupFileName() - { - AutoBackupFileName = listViewBackups.SelectedItems[0].Tag.ToString(); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - if (listViewBackups.SelectedItems.Count == 1) - { - SetAutoBackupFileName(); - } - - DialogResult = DialogResult.OK; - } - - private void listViewBackups_MouseDoubleClick(object sender, MouseEventArgs e) - { - if (listViewBackups.SelectedItems.Count == 1) - { - SetAutoBackupFileName(); - DialogResult = DialogResult.OK; - } - } - - private void RestoreAutoBackup_ResizeEnd(object sender, EventArgs e) - { - listViewBackups.Columns[2].Width = -2; - } - - private void RestoreAutoBackup_SizeChanged(object sender, EventArgs e) - { - listViewBackups.Columns[2].Width = -2; - } - - private void linkLabelOpenContainingFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - string folderName = Configuration.AutoBackupDirectory; - if (Utilities.IsRunningOnMono()) - { - UiUtil.OpenFolder(folderName); - } - else - { - if (listViewBackups.SelectedItems.Count == 1) - { - string argument = @"/select, " + listViewBackups.SelectedItems[0].Tag; - System.Diagnostics.Process.Start("explorer.exe", argument); - } - else - { - UiUtil.OpenFolder(folderName); - } - } - } - - public static void CleanAutoBackupFolder(string autoBackupFolder, int autoBackupDeleteAfterMonths) - { - lock (_locker) // only allow one thread - { - if (Directory.Exists(autoBackupFolder)) - { - var targetDate = DateTime.Now.AddMonths(-autoBackupDeleteAfterMonths); - var files = Directory.GetFiles(autoBackupFolder, "*.*"); - foreach (string fileName in files) - { - try - { - var name = Path.GetFileName(fileName); - if (RegexFileNamePattern.IsMatch(name) && Convert.ToDateTime(name.Substring(0, 10), CultureInfo.InvariantCulture) <= targetDate) - { - File.Delete(fileName); - } - } - catch - { - // ignore - } - } - } - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Globalization; +using System.IO; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class RestoreAutoBackup : PositionAndSizeForm + { + private static readonly object _locker = new object(); + + //2011-12-13_20-19-18_title + private static readonly Regex RegexFileNamePattern = new Regex(@"^\d\d\d\d-\d\d-\d\d_\d\d-\d\d-\d\d", RegexOptions.Compiled); + private string[] _files; + public string AutoBackupFileName { get; set; } + + public RestoreAutoBackup() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + labelStatus.Text = string.Empty; + + var l = Configuration.Settings.Language.RestoreAutoBackup; + Text = l.Title; + linkLabelOpenContainingFolder.Text = Configuration.Settings.Language.Main.Menu.File.OpenContainingFolder; + listViewBackups.Columns[0].Text = l.DateAndTime; + listViewBackups.Columns[1].Text = l.FileName; + listViewBackups.Columns[2].Text = l.Extension; + listViewBackups.Columns[3].Text = Configuration.Settings.Language.General.Size; + labelInfo.Text = l.Information; + + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + + UiUtil.FixLargeFonts(this, buttonCancel); + } + + private void RestoreAutoBackup_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void RestoreAutoBackup_Shown(object sender, EventArgs e) + { + listViewBackups.Columns[2].Width = -2; + if (Directory.Exists(Configuration.AutoBackupDirectory)) + { + _files = Directory.GetFiles(Configuration.AutoBackupDirectory, "*.*"); + foreach (string fileName in _files) + { + var path = Path.GetFileName(fileName); + if (path != null && RegexFileNamePattern.IsMatch(path)) + { + AddBackupToListView(fileName); + } + } + listViewBackups.Sorting = SortOrder.Descending; + listViewBackups.Sort(); + if (_files.Length > 0) + { + return; + } + } + linkLabelOpenContainingFolder.Visible = false; + labelStatus.Left = linkLabelOpenContainingFolder.Left; + labelStatus.Text = Configuration.Settings.Language.RestoreAutoBackup.NoBackedUpFilesFound; + } + + private void AddBackupToListView(string fileName) + { + var path = Path.GetFileName(fileName); + if (path == null) + { + return; + } + + string displayDate = path.Substring(0, 19).Replace('_', ' '); + displayDate = displayDate.Remove(13, 1).Insert(13, ":"); + displayDate = displayDate.Remove(16, 1).Insert(16, ":"); + + string displayName = path.Remove(0, 20); + if (displayName == "srt") + { + displayName = "Untitled.srt"; + } + + var item = new ListViewItem(displayDate) + { + UseItemStyleForSubItems = false, + Tag = fileName + }; + item.SubItems.Add(Path.GetFileNameWithoutExtension(displayName)); + item.SubItems.Add(Path.GetExtension(fileName)); + + try + { + item.SubItems.Add(new FileInfo(fileName).Length + " bytes"); + } + catch + { + // ignored + } + + listViewBackups.Items.Add(item); + } + + private void SetAutoBackupFileName() + { + AutoBackupFileName = listViewBackups.SelectedItems[0].Tag.ToString(); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + if (listViewBackups.SelectedItems.Count == 1) + { + SetAutoBackupFileName(); + } + + DialogResult = DialogResult.OK; + } + + private void listViewBackups_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (listViewBackups.SelectedItems.Count == 1) + { + SetAutoBackupFileName(); + DialogResult = DialogResult.OK; + } + } + + private void RestoreAutoBackup_ResizeEnd(object sender, EventArgs e) + { + listViewBackups.Columns[2].Width = -2; + } + + private void RestoreAutoBackup_SizeChanged(object sender, EventArgs e) + { + listViewBackups.Columns[2].Width = -2; + } + + private void linkLabelOpenContainingFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + string folderName = Configuration.AutoBackupDirectory; + if (Utilities.IsRunningOnMono()) + { + UiUtil.OpenFolder(folderName); + } + else + { + if (listViewBackups.SelectedItems.Count == 1) + { + string argument = @"/select, " + listViewBackups.SelectedItems[0].Tag; + System.Diagnostics.Process.Start("explorer.exe", argument); + } + else + { + UiUtil.OpenFolder(folderName); + } + } + } + + public static void CleanAutoBackupFolder(string autoBackupFolder, int autoBackupDeleteAfterMonths) + { + lock (_locker) // only allow one thread + { + if (Directory.Exists(autoBackupFolder)) + { + var targetDate = DateTime.Now.AddMonths(-autoBackupDeleteAfterMonths); + var files = Directory.GetFiles(autoBackupFolder, "*.*"); + foreach (string fileName in files) + { + try + { + var name = Path.GetFileName(fileName); + if (RegexFileNamePattern.IsMatch(name) && Convert.ToDateTime(name.Substring(0, 10), CultureInfo.InvariantCulture) <= targetDate) + { + File.Delete(fileName); + } + } + catch + { + // ignore + } + } + } + } + } + + } +} diff --git a/src/Forms/RestoreAutoBackup.resx b/src/ui/Forms/RestoreAutoBackup.resx similarity index 97% rename from src/Forms/RestoreAutoBackup.resx rename to src/ui/Forms/RestoreAutoBackup.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/RestoreAutoBackup.resx +++ b/src/ui/Forms/RestoreAutoBackup.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/RubyJapanese.Designer.cs b/src/ui/Forms/RubyJapanese.Designer.cs similarity index 100% rename from src/Forms/RubyJapanese.Designer.cs rename to src/ui/Forms/RubyJapanese.Designer.cs diff --git a/src/Forms/RubyJapanese.cs b/src/ui/Forms/RubyJapanese.cs similarity index 100% rename from src/Forms/RubyJapanese.cs rename to src/ui/Forms/RubyJapanese.cs diff --git a/src/ui/Forms/RubyJapanese.resx b/src/ui/Forms/RubyJapanese.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/src/ui/Forms/RubyJapanese.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Forms/SeekSilence.Designer.cs b/src/ui/Forms/SeekSilence.Designer.cs similarity index 97% rename from src/Forms/SeekSilence.Designer.cs rename to src/ui/Forms/SeekSilence.Designer.cs index d00f4f2fd..6db5cc5cf 100644 --- a/src/Forms/SeekSilence.Designer.cs +++ b/src/ui/Forms/SeekSilence.Designer.cs @@ -1,211 +1,211 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class SeekSilence - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxSearchDirection = new System.Windows.Forms.GroupBox(); - this.radioButtonBack = new System.Windows.Forms.RadioButton(); - this.radioButtonForward = new System.Windows.Forms.RadioButton(); - this.numericUpDownSeconds = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownVolume = new System.Windows.Forms.NumericUpDown(); - this.labelDuration = new System.Windows.Forms.Label(); - this.labelVolumeBelow = new System.Windows.Forms.Label(); - this.groupBoxSearchDirection.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVolume)).BeginInit(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(247, 152); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(166, 152); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // groupBoxSearchDirection - // - this.groupBoxSearchDirection.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxSearchDirection.Controls.Add(this.radioButtonBack); - this.groupBoxSearchDirection.Controls.Add(this.radioButtonForward); - this.groupBoxSearchDirection.Location = new System.Drawing.Point(12, 12); - this.groupBoxSearchDirection.Name = "groupBoxSearchDirection"; - this.groupBoxSearchDirection.Size = new System.Drawing.Size(310, 73); - this.groupBoxSearchDirection.TabIndex = 5; - this.groupBoxSearchDirection.TabStop = false; - this.groupBoxSearchDirection.Text = "Search direction"; - // - // radioButtonBack - // - this.radioButtonBack.AutoSize = true; - this.radioButtonBack.Location = new System.Drawing.Point(7, 44); - this.radioButtonBack.Name = "radioButtonBack"; - this.radioButtonBack.Size = new System.Drawing.Size(50, 17); - this.radioButtonBack.TabIndex = 1; - this.radioButtonBack.Text = "Back"; - this.radioButtonBack.UseVisualStyleBackColor = true; - // - // radioButtonForward - // - this.radioButtonForward.AutoSize = true; - this.radioButtonForward.Checked = true; - this.radioButtonForward.Location = new System.Drawing.Point(7, 20); - this.radioButtonForward.Name = "radioButtonForward"; - this.radioButtonForward.Size = new System.Drawing.Size(63, 17); - this.radioButtonForward.TabIndex = 0; - this.radioButtonForward.TabStop = true; - this.radioButtonForward.Text = "Forward"; - this.radioButtonForward.UseVisualStyleBackColor = true; - // - // numericUpDownSeconds - // - this.numericUpDownSeconds.DecimalPlaces = 1; - this.numericUpDownSeconds.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownSeconds.Location = new System.Drawing.Point(247, 91); - this.numericUpDownSeconds.Maximum = new decimal(new int[] { - 5, - 0, - 0, - 0}); - this.numericUpDownSeconds.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownSeconds.Name = "numericUpDownSeconds"; - this.numericUpDownSeconds.Size = new System.Drawing.Size(75, 20); - this.numericUpDownSeconds.TabIndex = 6; - this.numericUpDownSeconds.Value = new decimal(new int[] { - 3, - 0, - 0, - 65536}); - // - // numericUpDownVolume - // - this.numericUpDownVolume.DecimalPlaces = 2; - this.numericUpDownVolume.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownVolume.Location = new System.Drawing.Point(247, 117); - this.numericUpDownVolume.Name = "numericUpDownVolume"; - this.numericUpDownVolume.Size = new System.Drawing.Size(75, 20); - this.numericUpDownVolume.TabIndex = 7; - this.numericUpDownVolume.Value = new decimal(new int[] { - 3, - 0, - 0, - 65536}); - // - // labelDuration - // - this.labelDuration.AutoSize = true; - this.labelDuration.Location = new System.Drawing.Point(12, 93); - this.labelDuration.Name = "labelDuration"; - this.labelDuration.Size = new System.Drawing.Size(180, 13); - this.labelDuration.TabIndex = 8; - this.labelDuration.Text = "Silence must be at at least (seconds)"; - // - // labelVolumeBelow - // - this.labelVolumeBelow.AutoSize = true; - this.labelVolumeBelow.Location = new System.Drawing.Point(12, 119); - this.labelVolumeBelow.Name = "labelVolumeBelow"; - this.labelVolumeBelow.Size = new System.Drawing.Size(113, 13); - this.labelVolumeBelow.TabIndex = 9; - this.labelVolumeBelow.Text = "Volume must be below"; - // - // SeekSilence - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(334, 185); - this.Controls.Add(this.labelVolumeBelow); - this.Controls.Add(this.labelDuration); - this.Controls.Add(this.numericUpDownVolume); - this.Controls.Add(this.numericUpDownSeconds); - this.Controls.Add(this.groupBoxSearchDirection); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "SeekSilence"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Seek silence"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SeekSilence_KeyDown); - this.groupBoxSearchDirection.ResumeLayout(false); - this.groupBoxSearchDirection.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVolume)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.GroupBox groupBoxSearchDirection; - private System.Windows.Forms.RadioButton radioButtonBack; - private System.Windows.Forms.RadioButton radioButtonForward; - private System.Windows.Forms.NumericUpDown numericUpDownSeconds; - private System.Windows.Forms.NumericUpDown numericUpDownVolume; - private System.Windows.Forms.Label labelDuration; - private System.Windows.Forms.Label labelVolumeBelow; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class SeekSilence + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxSearchDirection = new System.Windows.Forms.GroupBox(); + this.radioButtonBack = new System.Windows.Forms.RadioButton(); + this.radioButtonForward = new System.Windows.Forms.RadioButton(); + this.numericUpDownSeconds = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownVolume = new System.Windows.Forms.NumericUpDown(); + this.labelDuration = new System.Windows.Forms.Label(); + this.labelVolumeBelow = new System.Windows.Forms.Label(); + this.groupBoxSearchDirection.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVolume)).BeginInit(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(247, 152); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(166, 152); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // groupBoxSearchDirection + // + this.groupBoxSearchDirection.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxSearchDirection.Controls.Add(this.radioButtonBack); + this.groupBoxSearchDirection.Controls.Add(this.radioButtonForward); + this.groupBoxSearchDirection.Location = new System.Drawing.Point(12, 12); + this.groupBoxSearchDirection.Name = "groupBoxSearchDirection"; + this.groupBoxSearchDirection.Size = new System.Drawing.Size(310, 73); + this.groupBoxSearchDirection.TabIndex = 5; + this.groupBoxSearchDirection.TabStop = false; + this.groupBoxSearchDirection.Text = "Search direction"; + // + // radioButtonBack + // + this.radioButtonBack.AutoSize = true; + this.radioButtonBack.Location = new System.Drawing.Point(7, 44); + this.radioButtonBack.Name = "radioButtonBack"; + this.radioButtonBack.Size = new System.Drawing.Size(50, 17); + this.radioButtonBack.TabIndex = 1; + this.radioButtonBack.Text = "Back"; + this.radioButtonBack.UseVisualStyleBackColor = true; + // + // radioButtonForward + // + this.radioButtonForward.AutoSize = true; + this.radioButtonForward.Checked = true; + this.radioButtonForward.Location = new System.Drawing.Point(7, 20); + this.radioButtonForward.Name = "radioButtonForward"; + this.radioButtonForward.Size = new System.Drawing.Size(63, 17); + this.radioButtonForward.TabIndex = 0; + this.radioButtonForward.TabStop = true; + this.radioButtonForward.Text = "Forward"; + this.radioButtonForward.UseVisualStyleBackColor = true; + // + // numericUpDownSeconds + // + this.numericUpDownSeconds.DecimalPlaces = 1; + this.numericUpDownSeconds.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownSeconds.Location = new System.Drawing.Point(247, 91); + this.numericUpDownSeconds.Maximum = new decimal(new int[] { + 5, + 0, + 0, + 0}); + this.numericUpDownSeconds.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownSeconds.Name = "numericUpDownSeconds"; + this.numericUpDownSeconds.Size = new System.Drawing.Size(75, 20); + this.numericUpDownSeconds.TabIndex = 6; + this.numericUpDownSeconds.Value = new decimal(new int[] { + 3, + 0, + 0, + 65536}); + // + // numericUpDownVolume + // + this.numericUpDownVolume.DecimalPlaces = 2; + this.numericUpDownVolume.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownVolume.Location = new System.Drawing.Point(247, 117); + this.numericUpDownVolume.Name = "numericUpDownVolume"; + this.numericUpDownVolume.Size = new System.Drawing.Size(75, 20); + this.numericUpDownVolume.TabIndex = 7; + this.numericUpDownVolume.Value = new decimal(new int[] { + 3, + 0, + 0, + 65536}); + // + // labelDuration + // + this.labelDuration.AutoSize = true; + this.labelDuration.Location = new System.Drawing.Point(12, 93); + this.labelDuration.Name = "labelDuration"; + this.labelDuration.Size = new System.Drawing.Size(180, 13); + this.labelDuration.TabIndex = 8; + this.labelDuration.Text = "Silence must be at at least (seconds)"; + // + // labelVolumeBelow + // + this.labelVolumeBelow.AutoSize = true; + this.labelVolumeBelow.Location = new System.Drawing.Point(12, 119); + this.labelVolumeBelow.Name = "labelVolumeBelow"; + this.labelVolumeBelow.Size = new System.Drawing.Size(113, 13); + this.labelVolumeBelow.TabIndex = 9; + this.labelVolumeBelow.Text = "Volume must be below"; + // + // SeekSilence + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(334, 185); + this.Controls.Add(this.labelVolumeBelow); + this.Controls.Add(this.labelDuration); + this.Controls.Add(this.numericUpDownVolume); + this.Controls.Add(this.numericUpDownSeconds); + this.Controls.Add(this.groupBoxSearchDirection); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SeekSilence"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Seek silence"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SeekSilence_KeyDown); + this.groupBoxSearchDirection.ResumeLayout(false); + this.groupBoxSearchDirection.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSeconds)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVolume)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.GroupBox groupBoxSearchDirection; + private System.Windows.Forms.RadioButton radioButtonBack; + private System.Windows.Forms.RadioButton radioButtonForward; + private System.Windows.Forms.NumericUpDown numericUpDownSeconds; + private System.Windows.Forms.NumericUpDown numericUpDownVolume; + private System.Windows.Forms.Label labelDuration; + private System.Windows.Forms.Label labelVolumeBelow; + } } \ No newline at end of file diff --git a/src/Forms/SeekSilence.cs b/src/ui/Forms/SeekSilence.cs similarity index 97% rename from src/Forms/SeekSilence.cs rename to src/ui/Forms/SeekSilence.cs index 61c30bbaf..02ea65fa8 100644 --- a/src/Forms/SeekSilence.cs +++ b/src/ui/Forms/SeekSilence.cs @@ -1,58 +1,58 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class SeekSilence : Form - { - public bool SeekForward { get; set; } - public double SecondsDuration { get; set; } - public double VolumeBelow { get; set; } - - public SeekSilence() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.SeekSilence.Title; - groupBoxSearchDirection.Text = Configuration.Settings.Language.SeekSilence.SearchDirection; - radioButtonForward.Text = Configuration.Settings.Language.SeekSilence.Forward; - radioButtonBack.Text = Configuration.Settings.Language.SeekSilence.Back; - labelDuration.Text = Configuration.Settings.Language.SeekSilence.LengthInSeconds; - labelVolumeBelow.Text = Configuration.Settings.Language.SeekSilence.MaxVolume; - numericUpDownSeconds.Value = (decimal)Configuration.Settings.VideoControls.WaveformSeeksSilenceDurationSeconds; - numericUpDownVolume.Value = (decimal)Configuration.Settings.VideoControls.WaveformSeeksSilenceMaxVolume; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void SeekSilence_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - SeekForward = radioButtonForward.Checked; - SecondsDuration = (double)numericUpDownSeconds.Value; - VolumeBelow = (double)numericUpDownVolume.Value; - Configuration.Settings.VideoControls.WaveformSeeksSilenceDurationSeconds = SecondsDuration; - Configuration.Settings.VideoControls.WaveformSeeksSilenceMaxVolume = VolumeBelow; - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class SeekSilence : Form + { + public bool SeekForward { get; set; } + public double SecondsDuration { get; set; } + public double VolumeBelow { get; set; } + + public SeekSilence() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.SeekSilence.Title; + groupBoxSearchDirection.Text = Configuration.Settings.Language.SeekSilence.SearchDirection; + radioButtonForward.Text = Configuration.Settings.Language.SeekSilence.Forward; + radioButtonBack.Text = Configuration.Settings.Language.SeekSilence.Back; + labelDuration.Text = Configuration.Settings.Language.SeekSilence.LengthInSeconds; + labelVolumeBelow.Text = Configuration.Settings.Language.SeekSilence.MaxVolume; + numericUpDownSeconds.Value = (decimal)Configuration.Settings.VideoControls.WaveformSeeksSilenceDurationSeconds; + numericUpDownVolume.Value = (decimal)Configuration.Settings.VideoControls.WaveformSeeksSilenceMaxVolume; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void SeekSilence_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + SeekForward = radioButtonForward.Checked; + SecondsDuration = (double)numericUpDownSeconds.Value; + VolumeBelow = (double)numericUpDownVolume.Value; + Configuration.Settings.VideoControls.WaveformSeeksSilenceDurationSeconds = SecondsDuration; + Configuration.Settings.VideoControls.WaveformSeeksSilenceMaxVolume = VolumeBelow; + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + } +} diff --git a/src/Forms/SeekSilence.resx b/src/ui/Forms/SeekSilence.resx similarity index 97% rename from src/Forms/SeekSilence.resx rename to src/ui/Forms/SeekSilence.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/SeekSilence.resx +++ b/src/ui/Forms/SeekSilence.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.Designer.cs b/src/ui/Forms/SetMinimumDisplayTimeBetweenParagraphs.Designer.cs similarity index 98% rename from src/Forms/SetMinimumDisplayTimeBetweenParagraphs.Designer.cs rename to src/ui/Forms/SetMinimumDisplayTimeBetweenParagraphs.Designer.cs index b5fa8d03c..80a59f208 100644 --- a/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.Designer.cs +++ b/src/ui/Forms/SetMinimumDisplayTimeBetweenParagraphs.Designer.cs @@ -1,258 +1,258 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class SetMinimumDisplayTimeBetweenParagraphs - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); - this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.numericUpDownMinMillisecondsBetweenLines = new System.Windows.Forms.NumericUpDown(); - this.labelMaxMillisecondsBetweenLines = new System.Windows.Forms.Label(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.checkBoxShowOnlyChangedLines = new System.Windows.Forms.CheckBox(); - this.comboBoxFrameRate = new System.Windows.Forms.ComboBox(); - this.labelFrames = new System.Windows.Forms.Label(); - this.numericUpDownFrames = new System.Windows.Forms.NumericUpDown(); - this.labelXFrameIsXMS = new System.Windows.Forms.Label(); - this.groupBoxFrameInfo = new System.Windows.Forms.GroupBox(); - this.groupBoxLinesFound.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinMillisecondsBetweenLines)).BeginInit(); - this.groupBoxFrameInfo.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxLinesFound - // - this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxLinesFound.Controls.Add(this.SubtitleListview1); - this.groupBoxLinesFound.Location = new System.Drawing.Point(18, 94); - this.groupBoxLinesFound.Name = "groupBoxLinesFound"; - this.groupBoxLinesFound.Size = new System.Drawing.Size(726, 347); - this.groupBoxLinesFound.TabIndex = 3; - this.groupBoxLinesFound.TabStop = false; - this.groupBoxLinesFound.Text = "Preview"; - // - // SubtitleListview1 - // - this.SubtitleListview1.AllowColumnReorder = true; - this.SubtitleListview1.AllowDrop = true; - this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.SubtitleListview1.FirstVisibleIndex = -1; - this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.SubtitleListview1.FullRowSelect = true; - this.SubtitleListview1.GridLines = true; - this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.SubtitleListview1.HideSelection = false; - this.SubtitleListview1.Location = new System.Drawing.Point(6, 19); - this.SubtitleListview1.Name = "SubtitleListview1"; - this.SubtitleListview1.OwnerDraw = true; - this.SubtitleListview1.Size = new System.Drawing.Size(714, 322); - this.SubtitleListview1.SubtitleFontBold = false; - this.SubtitleListview1.SubtitleFontName = "Tahoma"; - this.SubtitleListview1.SubtitleFontSize = 8; - this.SubtitleListview1.TabIndex = 0; - this.SubtitleListview1.UseCompatibleStateImageBehavior = false; - this.SubtitleListview1.UseSyntaxColoring = true; - this.SubtitleListview1.View = System.Windows.Forms.View.Details; - // - // numericUpDownMinMillisecondsBetweenLines - // - this.numericUpDownMinMillisecondsBetweenLines.Location = new System.Drawing.Point(18, 34); - this.numericUpDownMinMillisecondsBetweenLines.Maximum = new decimal(new int[] { - 1000, - 0, - 0, - 0}); - this.numericUpDownMinMillisecondsBetweenLines.Name = "numericUpDownMinMillisecondsBetweenLines"; - this.numericUpDownMinMillisecondsBetweenLines.Size = new System.Drawing.Size(64, 21); - this.numericUpDownMinMillisecondsBetweenLines.TabIndex = 1; - this.numericUpDownMinMillisecondsBetweenLines.Value = new decimal(new int[] { - 50, - 0, - 0, - 0}); - this.numericUpDownMinMillisecondsBetweenLines.ValueChanged += new System.EventHandler(this.numericUpDownMinMillisecondsBetweenLines_ValueChanged); - this.numericUpDownMinMillisecondsBetweenLines.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDownMinMillisecondsBetweenLines_KeyUp); - // - // labelMaxMillisecondsBetweenLines - // - this.labelMaxMillisecondsBetweenLines.AutoSize = true; - this.labelMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(15, 18); - this.labelMaxMillisecondsBetweenLines.Name = "labelMaxMillisecondsBetweenLines"; - this.labelMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(174, 13); - this.labelMaxMillisecondsBetweenLines.TabIndex = 2; - this.labelMaxMillisecondsBetweenLines.Text = "Minimum milliseconds between lines"; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(595, 447); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 5; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(676, 447); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 6; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // checkBoxShowOnlyChangedLines - // - this.checkBoxShowOnlyChangedLines.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.checkBoxShowOnlyChangedLines.AutoSize = true; - this.checkBoxShowOnlyChangedLines.Location = new System.Drawing.Point(18, 448); - this.checkBoxShowOnlyChangedLines.Name = "checkBoxShowOnlyChangedLines"; - this.checkBoxShowOnlyChangedLines.Size = new System.Drawing.Size(142, 17); - this.checkBoxShowOnlyChangedLines.TabIndex = 4; - this.checkBoxShowOnlyChangedLines.Text = "Show only modified lines"; - this.checkBoxShowOnlyChangedLines.UseVisualStyleBackColor = true; - this.checkBoxShowOnlyChangedLines.CheckedChanged += new System.EventHandler(this.checkBoxShowOnlyChangedLines_CheckedChanged); - // - // comboBoxFrameRate - // - this.comboBoxFrameRate.FormattingEnabled = true; - this.comboBoxFrameRate.Location = new System.Drawing.Point(7, 25); - this.comboBoxFrameRate.Margin = new System.Windows.Forms.Padding(4); - this.comboBoxFrameRate.MaxLength = 10; - this.comboBoxFrameRate.Name = "comboBoxFrameRate"; - this.comboBoxFrameRate.Size = new System.Drawing.Size(160, 21); - this.comboBoxFrameRate.TabIndex = 0; - this.comboBoxFrameRate.SelectedIndexChanged += new System.EventHandler(this.comboBoxFrameRate_SelectedIndexChanged); - this.comboBoxFrameRate.KeyUp += new System.Windows.Forms.KeyEventHandler(this.comboBoxFrameRate_KeyUp); - // - // labelFrames - // - this.labelFrames.AutoSize = true; - this.labelFrames.Location = new System.Drawing.Point(174, 29); - this.labelFrames.Name = "labelFrames"; - this.labelFrames.Size = new System.Drawing.Size(174, 13); - this.labelFrames.TabIndex = 1; - this.labelFrames.Text = "Frames:"; - // - // numericUpDownFrames - // - this.numericUpDownFrames.Location = new System.Drawing.Point(220, 25); - this.numericUpDownFrames.Maximum = new decimal(new int[] { - 25, - 0, - 0, - 0}); - this.numericUpDownFrames.Name = "numericUpDownFrames"; - this.numericUpDownFrames.Size = new System.Drawing.Size(56, 20); - this.numericUpDownFrames.TabIndex = 52; - this.numericUpDownFrames.Value = new decimal(new int[] { - 2, - 0, - 0, - 0}); - this.numericUpDownFrames.ValueChanged += new System.EventHandler(this.numericUpDownFrames_ValueChanged); - // - // labelXFrameIsXMS - // - this.labelXFrameIsXMS.AutoSize = true; - this.labelXFrameIsXMS.Location = new System.Drawing.Point(6, 57); - this.labelXFrameIsXMS.Name = "labelXFrameIsXMS"; - this.labelXFrameIsXMS.Size = new System.Drawing.Size(135, 13); - this.labelXFrameIsXMS.TabIndex = 3; - this.labelXFrameIsXMS.Text = "x frame is y milliseconds"; - // - // groupBoxFrameInfo - // - this.groupBoxFrameInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxFrameInfo.Controls.Add(this.comboBoxFrameRate); - this.groupBoxFrameInfo.Controls.Add(this.labelFrames); - this.groupBoxFrameInfo.Controls.Add(this.numericUpDownFrames); - this.groupBoxFrameInfo.Controls.Add(this.labelXFrameIsXMS); - this.groupBoxFrameInfo.Location = new System.Drawing.Point(355, 12); - this.groupBoxFrameInfo.Name = "groupBoxFrameInfo"; - this.groupBoxFrameInfo.Size = new System.Drawing.Size(383, 76); - this.groupBoxFrameInfo.TabIndex = 2; - this.groupBoxFrameInfo.TabStop = false; - this.groupBoxFrameInfo.Text = "Frame rate info"; - // - // SetMinimumDisplayTimeBetweenParagraphs - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(754, 480); - this.Controls.Add(this.groupBoxFrameInfo); - this.Controls.Add(this.checkBoxShowOnlyChangedLines); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.numericUpDownMinMillisecondsBetweenLines); - this.Controls.Add(this.labelMaxMillisecondsBetweenLines); - this.Controls.Add(this.groupBoxLinesFound); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MinimumSize = new System.Drawing.Size(750, 500); - this.Name = "SetMinimumDisplayTimeBetweenParagraphs"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Set minimum display time between paragraphs"; - this.Shown += new System.EventHandler(this.SetMinimumDisplayTimeBetweenParagraphs_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SetMinimalDisplayTimeDifference_KeyDown); - this.groupBoxLinesFound.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinMillisecondsBetweenLines)).EndInit(); - this.groupBoxFrameInfo.ResumeLayout(false); - this.groupBoxFrameInfo.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxLinesFound; - private System.Windows.Forms.NumericUpDown numericUpDownMinMillisecondsBetweenLines; - private System.Windows.Forms.Label labelMaxMillisecondsBetweenLines; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private Controls.SubtitleListView SubtitleListview1; - private System.Windows.Forms.CheckBox checkBoxShowOnlyChangedLines; - private System.Windows.Forms.ComboBox comboBoxFrameRate; - private System.Windows.Forms.Label labelXFrameIsXMS; - private System.Windows.Forms.Label labelFrames; - private System.Windows.Forms.NumericUpDown numericUpDownFrames; - private System.Windows.Forms.GroupBox groupBoxFrameInfo; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class SetMinimumDisplayTimeBetweenParagraphs + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); + this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.numericUpDownMinMillisecondsBetweenLines = new System.Windows.Forms.NumericUpDown(); + this.labelMaxMillisecondsBetweenLines = new System.Windows.Forms.Label(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.checkBoxShowOnlyChangedLines = new System.Windows.Forms.CheckBox(); + this.comboBoxFrameRate = new System.Windows.Forms.ComboBox(); + this.labelFrames = new System.Windows.Forms.Label(); + this.numericUpDownFrames = new System.Windows.Forms.NumericUpDown(); + this.labelXFrameIsXMS = new System.Windows.Forms.Label(); + this.groupBoxFrameInfo = new System.Windows.Forms.GroupBox(); + this.groupBoxLinesFound.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinMillisecondsBetweenLines)).BeginInit(); + this.groupBoxFrameInfo.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxLinesFound + // + this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxLinesFound.Controls.Add(this.SubtitleListview1); + this.groupBoxLinesFound.Location = new System.Drawing.Point(18, 94); + this.groupBoxLinesFound.Name = "groupBoxLinesFound"; + this.groupBoxLinesFound.Size = new System.Drawing.Size(726, 347); + this.groupBoxLinesFound.TabIndex = 3; + this.groupBoxLinesFound.TabStop = false; + this.groupBoxLinesFound.Text = "Preview"; + // + // SubtitleListview1 + // + this.SubtitleListview1.AllowColumnReorder = true; + this.SubtitleListview1.AllowDrop = true; + this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.SubtitleListview1.FirstVisibleIndex = -1; + this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SubtitleListview1.FullRowSelect = true; + this.SubtitleListview1.GridLines = true; + this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.SubtitleListview1.HideSelection = false; + this.SubtitleListview1.Location = new System.Drawing.Point(6, 19); + this.SubtitleListview1.Name = "SubtitleListview1"; + this.SubtitleListview1.OwnerDraw = true; + this.SubtitleListview1.Size = new System.Drawing.Size(714, 322); + this.SubtitleListview1.SubtitleFontBold = false; + this.SubtitleListview1.SubtitleFontName = "Tahoma"; + this.SubtitleListview1.SubtitleFontSize = 8; + this.SubtitleListview1.TabIndex = 0; + this.SubtitleListview1.UseCompatibleStateImageBehavior = false; + this.SubtitleListview1.UseSyntaxColoring = true; + this.SubtitleListview1.View = System.Windows.Forms.View.Details; + // + // numericUpDownMinMillisecondsBetweenLines + // + this.numericUpDownMinMillisecondsBetweenLines.Location = new System.Drawing.Point(18, 34); + this.numericUpDownMinMillisecondsBetweenLines.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownMinMillisecondsBetweenLines.Name = "numericUpDownMinMillisecondsBetweenLines"; + this.numericUpDownMinMillisecondsBetweenLines.Size = new System.Drawing.Size(64, 21); + this.numericUpDownMinMillisecondsBetweenLines.TabIndex = 1; + this.numericUpDownMinMillisecondsBetweenLines.Value = new decimal(new int[] { + 50, + 0, + 0, + 0}); + this.numericUpDownMinMillisecondsBetweenLines.ValueChanged += new System.EventHandler(this.numericUpDownMinMillisecondsBetweenLines_ValueChanged); + this.numericUpDownMinMillisecondsBetweenLines.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDownMinMillisecondsBetweenLines_KeyUp); + // + // labelMaxMillisecondsBetweenLines + // + this.labelMaxMillisecondsBetweenLines.AutoSize = true; + this.labelMaxMillisecondsBetweenLines.Location = new System.Drawing.Point(15, 18); + this.labelMaxMillisecondsBetweenLines.Name = "labelMaxMillisecondsBetweenLines"; + this.labelMaxMillisecondsBetweenLines.Size = new System.Drawing.Size(174, 13); + this.labelMaxMillisecondsBetweenLines.TabIndex = 2; + this.labelMaxMillisecondsBetweenLines.Text = "Minimum milliseconds between lines"; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(595, 447); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 5; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(676, 447); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 6; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // checkBoxShowOnlyChangedLines + // + this.checkBoxShowOnlyChangedLines.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.checkBoxShowOnlyChangedLines.AutoSize = true; + this.checkBoxShowOnlyChangedLines.Location = new System.Drawing.Point(18, 448); + this.checkBoxShowOnlyChangedLines.Name = "checkBoxShowOnlyChangedLines"; + this.checkBoxShowOnlyChangedLines.Size = new System.Drawing.Size(142, 17); + this.checkBoxShowOnlyChangedLines.TabIndex = 4; + this.checkBoxShowOnlyChangedLines.Text = "Show only modified lines"; + this.checkBoxShowOnlyChangedLines.UseVisualStyleBackColor = true; + this.checkBoxShowOnlyChangedLines.CheckedChanged += new System.EventHandler(this.checkBoxShowOnlyChangedLines_CheckedChanged); + // + // comboBoxFrameRate + // + this.comboBoxFrameRate.FormattingEnabled = true; + this.comboBoxFrameRate.Location = new System.Drawing.Point(7, 25); + this.comboBoxFrameRate.Margin = new System.Windows.Forms.Padding(4); + this.comboBoxFrameRate.MaxLength = 10; + this.comboBoxFrameRate.Name = "comboBoxFrameRate"; + this.comboBoxFrameRate.Size = new System.Drawing.Size(160, 21); + this.comboBoxFrameRate.TabIndex = 0; + this.comboBoxFrameRate.SelectedIndexChanged += new System.EventHandler(this.comboBoxFrameRate_SelectedIndexChanged); + this.comboBoxFrameRate.KeyUp += new System.Windows.Forms.KeyEventHandler(this.comboBoxFrameRate_KeyUp); + // + // labelFrames + // + this.labelFrames.AutoSize = true; + this.labelFrames.Location = new System.Drawing.Point(174, 29); + this.labelFrames.Name = "labelFrames"; + this.labelFrames.Size = new System.Drawing.Size(174, 13); + this.labelFrames.TabIndex = 1; + this.labelFrames.Text = "Frames:"; + // + // numericUpDownFrames + // + this.numericUpDownFrames.Location = new System.Drawing.Point(220, 25); + this.numericUpDownFrames.Maximum = new decimal(new int[] { + 25, + 0, + 0, + 0}); + this.numericUpDownFrames.Name = "numericUpDownFrames"; + this.numericUpDownFrames.Size = new System.Drawing.Size(56, 20); + this.numericUpDownFrames.TabIndex = 52; + this.numericUpDownFrames.Value = new decimal(new int[] { + 2, + 0, + 0, + 0}); + this.numericUpDownFrames.ValueChanged += new System.EventHandler(this.numericUpDownFrames_ValueChanged); + // + // labelXFrameIsXMS + // + this.labelXFrameIsXMS.AutoSize = true; + this.labelXFrameIsXMS.Location = new System.Drawing.Point(6, 57); + this.labelXFrameIsXMS.Name = "labelXFrameIsXMS"; + this.labelXFrameIsXMS.Size = new System.Drawing.Size(135, 13); + this.labelXFrameIsXMS.TabIndex = 3; + this.labelXFrameIsXMS.Text = "x frame is y milliseconds"; + // + // groupBoxFrameInfo + // + this.groupBoxFrameInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFrameInfo.Controls.Add(this.comboBoxFrameRate); + this.groupBoxFrameInfo.Controls.Add(this.labelFrames); + this.groupBoxFrameInfo.Controls.Add(this.numericUpDownFrames); + this.groupBoxFrameInfo.Controls.Add(this.labelXFrameIsXMS); + this.groupBoxFrameInfo.Location = new System.Drawing.Point(355, 12); + this.groupBoxFrameInfo.Name = "groupBoxFrameInfo"; + this.groupBoxFrameInfo.Size = new System.Drawing.Size(383, 76); + this.groupBoxFrameInfo.TabIndex = 2; + this.groupBoxFrameInfo.TabStop = false; + this.groupBoxFrameInfo.Text = "Frame rate info"; + // + // SetMinimumDisplayTimeBetweenParagraphs + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(754, 480); + this.Controls.Add(this.groupBoxFrameInfo); + this.Controls.Add(this.checkBoxShowOnlyChangedLines); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.numericUpDownMinMillisecondsBetweenLines); + this.Controls.Add(this.labelMaxMillisecondsBetweenLines); + this.Controls.Add(this.groupBoxLinesFound); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MinimumSize = new System.Drawing.Size(750, 500); + this.Name = "SetMinimumDisplayTimeBetweenParagraphs"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Set minimum display time between paragraphs"; + this.Shown += new System.EventHandler(this.SetMinimumDisplayTimeBetweenParagraphs_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SetMinimalDisplayTimeDifference_KeyDown); + this.groupBoxLinesFound.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinMillisecondsBetweenLines)).EndInit(); + this.groupBoxFrameInfo.ResumeLayout(false); + this.groupBoxFrameInfo.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxLinesFound; + private System.Windows.Forms.NumericUpDown numericUpDownMinMillisecondsBetweenLines; + private System.Windows.Forms.Label labelMaxMillisecondsBetweenLines; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private Controls.SubtitleListView SubtitleListview1; + private System.Windows.Forms.CheckBox checkBoxShowOnlyChangedLines; + private System.Windows.Forms.ComboBox comboBoxFrameRate; + private System.Windows.Forms.Label labelXFrameIsXMS; + private System.Windows.Forms.Label labelFrames; + private System.Windows.Forms.NumericUpDown numericUpDownFrames; + private System.Windows.Forms.GroupBox groupBoxFrameInfo; + } } \ No newline at end of file diff --git a/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.cs b/src/ui/Forms/SetMinimumDisplayTimeBetweenParagraphs.cs similarity index 97% rename from src/Forms/SetMinimumDisplayTimeBetweenParagraphs.cs rename to src/ui/Forms/SetMinimumDisplayTimeBetweenParagraphs.cs index 7c8b4f152..76cc77e45 100644 --- a/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.cs +++ b/src/ui/Forms/SetMinimumDisplayTimeBetweenParagraphs.cs @@ -1,212 +1,212 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class SetMinimumDisplayTimeBetweenParagraphs : PositionAndSizeForm - { - - private Subtitle _subtitle; - public int FixCount { get; private set; } - public int MinGapMs { get; internal set; } - - public SetMinimumDisplayTimeBetweenParagraphs() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.Title; - labelMaxMillisecondsBetweenLines.Text = Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.MinimumMillisecondsBetweenParagraphs; - checkBoxShowOnlyChangedLines.Text = Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.ShowOnlyModifiedLines; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.AutoSizeAllColumns(this); - UiUtil.FixLargeFonts(this, buttonOK); - - groupBoxFrameInfo.Text = Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.FrameInfo; - comboBoxFrameRate.Items.Add(23.976.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(24.0.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(25.0.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(29.97.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(30.0.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(59.94.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(60.ToString(CultureInfo.CurrentCulture)); - if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 23.976) < 0.1) - { - comboBoxFrameRate.SelectedIndex = 0; - } - else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 24) < 0.1) - { - comboBoxFrameRate.SelectedIndex = 1; - } - else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 25) < 0.1) - { - comboBoxFrameRate.SelectedIndex = 2; - } - else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 29.97) < 0.01) - { - comboBoxFrameRate.SelectedIndex = 3; - } - else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 30) < 0.1) - { - comboBoxFrameRate.SelectedIndex = 4; - } - else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 59.94) < 0.1) - { - comboBoxFrameRate.SelectedIndex = 5; - } - else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 60) < 0.1) - { - comboBoxFrameRate.SelectedIndex = 6; - } - else - { - comboBoxFrameRate.SelectedIndex = 3; - } - } - - public sealed override string Text - { - get => base.Text; - set => base.Text = value; - } - - public Subtitle FixedSubtitle { get; private set; } - - public void Initialize(Subtitle subtitle) - { - _subtitle = subtitle; - numericUpDownMinMillisecondsBetweenLines.Value = Configuration.Settings.General.MinimumMillisecondsBetweenLines != 0 - ? Configuration.Settings.General.MinimumMillisecondsBetweenLines - : 1; - } - - private void GeneratePreview() - { - var fixes = new List(); - if (_subtitle == null) - { - return; - } - - FixedSubtitle = new Subtitle(_subtitle); - var onlyFixedSubtitle = new Subtitle(); - - double minumumMillisecondsBetweenLines = (double)numericUpDownMinMillisecondsBetweenLines.Value; - for (int i = 0; i < FixedSubtitle.Paragraphs.Count - 1; i++) - { - Paragraph p = FixedSubtitle.GetParagraphOrDefault(i); - Paragraph next = FixedSubtitle.GetParagraphOrDefault(i + 1); - if (next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds < minumumMillisecondsBetweenLines) - { - p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - minumumMillisecondsBetweenLines; - fixes.Add(i); - onlyFixedSubtitle.Paragraphs.Add(new Paragraph(p)); - } - } - - SubtitleListview1.BeginUpdate(); - groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.PreviewLinesModifiedX, fixes.Count); - if (checkBoxShowOnlyChangedLines.Checked) - { - SubtitleListview1.Fill(onlyFixedSubtitle); - } - else - { - SubtitleListview1.Fill(FixedSubtitle); - foreach (int index in fixes) - { - SubtitleListview1.SetBackgroundColor(index, Color.Silver); - } - } - SubtitleListview1.EndUpdate(); - FixCount = fixes.Count; - } - - private void CalcMilliseconds() - { - var frameRate = GetFrameRate(); - MinGapMs = (int)Math.Round(1000.0 / frameRate * (double)numericUpDownFrames.Value); - labelXFrameIsXMS.Text = string.Format(Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.XFrameYisZMilliseconds, numericUpDownFrames.Value, frameRate, MinGapMs); - } - - private double GetFrameRate() - { - if (double.TryParse(comboBoxFrameRate.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out var frameRate)) - { - return frameRate; - } - - return Configuration.Settings.General.CurrentFrameRate; - } - - private void buttonOK_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void SetMinimalDisplayTimeDifference_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - e.SuppressKeyPress = true; - } - } - - private void numericUpDownMinMillisecondsBetweenLines_ValueChanged(object sender, EventArgs e) - { - GeneratePreview(); - Configuration.Settings.General.MinimumMillisecondsBetweenLines = (int)numericUpDownMinMillisecondsBetweenLines.Value; - } - - private void checkBoxShowOnlyChangedLines_CheckedChanged(object sender, EventArgs e) - { - GeneratePreview(); - } - - private void numericUpDownMinMillisecondsBetweenLines_KeyUp(object sender, KeyEventArgs e) - { - numericUpDownMinMillisecondsBetweenLines.ValueChanged -= numericUpDownMinMillisecondsBetweenLines_ValueChanged; - GeneratePreview(); - numericUpDownMinMillisecondsBetweenLines.ValueChanged += numericUpDownMinMillisecondsBetweenLines_ValueChanged; - Configuration.Settings.General.MinimumMillisecondsBetweenLines = (int)numericUpDownMinMillisecondsBetweenLines.Value; - } - - private void comboBoxFrameRate_SelectedIndexChanged(object sender, EventArgs e) - { - CalcMilliseconds(); - } - - private void comboBoxFrameRate_KeyUp(object sender, KeyEventArgs e) - { - comboBoxFrameRate_SelectedIndexChanged(sender, e); - } - - private void SetMinimumDisplayTimeBetweenParagraphs_Shown(object sender, EventArgs e) - { - SubtitleListview1.Focus(); - } - - private void numericUpDownFrames_ValueChanged(object sender, EventArgs e) - { - CalcMilliseconds(); - } - - } - -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class SetMinimumDisplayTimeBetweenParagraphs : PositionAndSizeForm + { + + private Subtitle _subtitle; + public int FixCount { get; private set; } + public int MinGapMs { get; internal set; } + + public SetMinimumDisplayTimeBetweenParagraphs() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.Title; + labelMaxMillisecondsBetweenLines.Text = Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.MinimumMillisecondsBetweenParagraphs; + checkBoxShowOnlyChangedLines.Text = Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.ShowOnlyModifiedLines; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.AutoSizeAllColumns(this); + UiUtil.FixLargeFonts(this, buttonOK); + + groupBoxFrameInfo.Text = Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.FrameInfo; + comboBoxFrameRate.Items.Add(23.976.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(24.0.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(25.0.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(29.97.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(30.0.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(59.94.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(60.ToString(CultureInfo.CurrentCulture)); + if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 23.976) < 0.1) + { + comboBoxFrameRate.SelectedIndex = 0; + } + else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 24) < 0.1) + { + comboBoxFrameRate.SelectedIndex = 1; + } + else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 25) < 0.1) + { + comboBoxFrameRate.SelectedIndex = 2; + } + else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 29.97) < 0.01) + { + comboBoxFrameRate.SelectedIndex = 3; + } + else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 30) < 0.1) + { + comboBoxFrameRate.SelectedIndex = 4; + } + else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 59.94) < 0.1) + { + comboBoxFrameRate.SelectedIndex = 5; + } + else if (Math.Abs(Configuration.Settings.General.CurrentFrameRate - 60) < 0.1) + { + comboBoxFrameRate.SelectedIndex = 6; + } + else + { + comboBoxFrameRate.SelectedIndex = 3; + } + } + + public sealed override string Text + { + get => base.Text; + set => base.Text = value; + } + + public Subtitle FixedSubtitle { get; private set; } + + public void Initialize(Subtitle subtitle) + { + _subtitle = subtitle; + numericUpDownMinMillisecondsBetweenLines.Value = Configuration.Settings.General.MinimumMillisecondsBetweenLines != 0 + ? Configuration.Settings.General.MinimumMillisecondsBetweenLines + : 1; + } + + private void GeneratePreview() + { + var fixes = new List(); + if (_subtitle == null) + { + return; + } + + FixedSubtitle = new Subtitle(_subtitle); + var onlyFixedSubtitle = new Subtitle(); + + double minumumMillisecondsBetweenLines = (double)numericUpDownMinMillisecondsBetweenLines.Value; + for (int i = 0; i < FixedSubtitle.Paragraphs.Count - 1; i++) + { + Paragraph p = FixedSubtitle.GetParagraphOrDefault(i); + Paragraph next = FixedSubtitle.GetParagraphOrDefault(i + 1); + if (next.StartTime.TotalMilliseconds - p.EndTime.TotalMilliseconds < minumumMillisecondsBetweenLines) + { + p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - minumumMillisecondsBetweenLines; + fixes.Add(i); + onlyFixedSubtitle.Paragraphs.Add(new Paragraph(p)); + } + } + + SubtitleListview1.BeginUpdate(); + groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.PreviewLinesModifiedX, fixes.Count); + if (checkBoxShowOnlyChangedLines.Checked) + { + SubtitleListview1.Fill(onlyFixedSubtitle); + } + else + { + SubtitleListview1.Fill(FixedSubtitle); + foreach (int index in fixes) + { + SubtitleListview1.SetBackgroundColor(index, Color.Silver); + } + } + SubtitleListview1.EndUpdate(); + FixCount = fixes.Count; + } + + private void CalcMilliseconds() + { + var frameRate = GetFrameRate(); + MinGapMs = (int)Math.Round(1000.0 / frameRate * (double)numericUpDownFrames.Value); + labelXFrameIsXMS.Text = string.Format(Configuration.Settings.Language.SetMinimumDisplayTimeBetweenParagraphs.XFrameYisZMilliseconds, numericUpDownFrames.Value, frameRate, MinGapMs); + } + + private double GetFrameRate() + { + if (double.TryParse(comboBoxFrameRate.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out var frameRate)) + { + return frameRate; + } + + return Configuration.Settings.General.CurrentFrameRate; + } + + private void buttonOK_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void SetMinimalDisplayTimeDifference_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + e.SuppressKeyPress = true; + } + } + + private void numericUpDownMinMillisecondsBetweenLines_ValueChanged(object sender, EventArgs e) + { + GeneratePreview(); + Configuration.Settings.General.MinimumMillisecondsBetweenLines = (int)numericUpDownMinMillisecondsBetweenLines.Value; + } + + private void checkBoxShowOnlyChangedLines_CheckedChanged(object sender, EventArgs e) + { + GeneratePreview(); + } + + private void numericUpDownMinMillisecondsBetweenLines_KeyUp(object sender, KeyEventArgs e) + { + numericUpDownMinMillisecondsBetweenLines.ValueChanged -= numericUpDownMinMillisecondsBetweenLines_ValueChanged; + GeneratePreview(); + numericUpDownMinMillisecondsBetweenLines.ValueChanged += numericUpDownMinMillisecondsBetweenLines_ValueChanged; + Configuration.Settings.General.MinimumMillisecondsBetweenLines = (int)numericUpDownMinMillisecondsBetweenLines.Value; + } + + private void comboBoxFrameRate_SelectedIndexChanged(object sender, EventArgs e) + { + CalcMilliseconds(); + } + + private void comboBoxFrameRate_KeyUp(object sender, KeyEventArgs e) + { + comboBoxFrameRate_SelectedIndexChanged(sender, e); + } + + private void SetMinimumDisplayTimeBetweenParagraphs_Shown(object sender, EventArgs e) + { + SubtitleListview1.Focus(); + } + + private void numericUpDownFrames_ValueChanged(object sender, EventArgs e) + { + CalcMilliseconds(); + } + + } + +} diff --git a/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.resx b/src/ui/Forms/SetMinimumDisplayTimeBetweenParagraphs.resx similarity index 97% rename from src/Forms/SetMinimumDisplayTimeBetweenParagraphs.resx rename to src/ui/Forms/SetMinimumDisplayTimeBetweenParagraphs.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/SetMinimumDisplayTimeBetweenParagraphs.resx +++ b/src/ui/Forms/SetMinimumDisplayTimeBetweenParagraphs.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/SetSyncPoint.Designer.cs b/src/ui/Forms/SetSyncPoint.Designer.cs similarity index 98% rename from src/Forms/SetSyncPoint.Designer.cs rename to src/ui/Forms/SetSyncPoint.Designer.cs index a554c8540..39aa635a2 100644 --- a/src/Forms/SetSyncPoint.Designer.cs +++ b/src/ui/Forms/SetSyncPoint.Designer.cs @@ -1,346 +1,346 @@ -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - partial class SetSyncPoint - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - TimeCode timeCode1 = new TimeCode(); - this.groupBoxSyncPointTimeCode = new System.Windows.Forms.GroupBox(); - this.timeUpDownLine = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonSetSyncPoint = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.buttonOpenMovie = new System.Windows.Forms.Button(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.labelVideoFileName = new System.Windows.Forms.Label(); - this.buttonHalfASecondBack = new System.Windows.Forms.Button(); - this.buttonThreeSecondsBack = new System.Windows.Forms.Button(); - this.buttonThreeSecondsAhead = new System.Windows.Forms.Button(); - this.buttonHalfASecondAhead = new System.Windows.Forms.Button(); - this.buttonVerify = new System.Windows.Forms.Button(); - this.labelSubtitle = new System.Windows.Forms.Label(); - this.videoPlayerContainer1 = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); - this.buttonFindTextEnd = new System.Windows.Forms.Button(); - this.groupBoxSyncPointTimeCode.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxSyncPointTimeCode - // - this.groupBoxSyncPointTimeCode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.groupBoxSyncPointTimeCode.Controls.Add(this.timeUpDownLine); - this.groupBoxSyncPointTimeCode.Location = new System.Drawing.Point(12, 12); - this.groupBoxSyncPointTimeCode.Name = "groupBoxSyncPointTimeCode"; - this.groupBoxSyncPointTimeCode.Size = new System.Drawing.Size(172, 224); - this.groupBoxSyncPointTimeCode.TabIndex = 1; - this.groupBoxSyncPointTimeCode.TabStop = false; - this.groupBoxSyncPointTimeCode.Text = "Sync point time code"; - // - // timeUpDownLine - // - this.timeUpDownLine.AutoSize = true; - this.timeUpDownLine.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownLine.Font = new System.Drawing.Font("Segoe UI", 9F); - this.timeUpDownLine.Location = new System.Drawing.Point(18, 19); - this.timeUpDownLine.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownLine.Name = "timeUpDownLine"; - this.timeUpDownLine.Size = new System.Drawing.Size(111, 27); - this.timeUpDownLine.TabIndex = 1; - timeCode1.Hours = 0; - timeCode1.Milliseconds = 0; - timeCode1.Minutes = 0; - timeCode1.Seconds = 0; - timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode1.TotalMilliseconds = 0D; - timeCode1.TotalSeconds = 0D; - this.timeUpDownLine.TimeCode = timeCode1; - this.timeUpDownLine.UseVideoOffset = false; - this.timeUpDownLine.KeyDown += new System.Windows.Forms.KeyEventHandler(this.timeUpDownLine_KeyDown); - // - // groupBox2 - // - this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox2.Controls.Add(this.subtitleListView1); - this.groupBox2.Location = new System.Drawing.Point(190, 13); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(605, 223); - this.groupBox2.TabIndex = 10; - this.groupBox2.TabStop = false; - // - // subtitleListView1 - // - this.subtitleListView1.AllowColumnReorder = true; - this.subtitleListView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.subtitleListView1.FirstVisibleIndex = -1; - this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.subtitleListView1.FullRowSelect = true; - this.subtitleListView1.GridLines = true; - this.subtitleListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.subtitleListView1.HideSelection = false; - this.subtitleListView1.Location = new System.Drawing.Point(6, 18); - this.subtitleListView1.Name = "subtitleListView1"; - this.subtitleListView1.OwnerDraw = true; - this.subtitleListView1.Size = new System.Drawing.Size(593, 199); - this.subtitleListView1.SubtitleFontBold = false; - this.subtitleListView1.SubtitleFontName = "Tahoma"; - this.subtitleListView1.SubtitleFontSize = 8; - this.subtitleListView1.TabIndex = 11; - this.subtitleListView1.UseCompatibleStateImageBehavior = false; - this.subtitleListView1.UseSyntaxColoring = true; - this.subtitleListView1.View = System.Windows.Forms.View.Details; - this.subtitleListView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListView1MouseDoubleClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(713, 584); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 31; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonSetSyncPoint - // - this.buttonSetSyncPoint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSetSyncPoint.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonSetSyncPoint.Location = new System.Drawing.Point(584, 584); - this.buttonSetSyncPoint.Name = "buttonSetSyncPoint"; - this.buttonSetSyncPoint.Size = new System.Drawing.Size(123, 23); - this.buttonSetSyncPoint.TabIndex = 30; - this.buttonSetSyncPoint.Text = "&Set sync point"; - this.buttonSetSyncPoint.UseVisualStyleBackColor = true; - this.buttonSetSyncPoint.Click += new System.EventHandler(this.buttonOK_Click); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // buttonOpenMovie - // - this.buttonOpenMovie.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOpenMovie.Location = new System.Drawing.Point(682, 241); - this.buttonOpenMovie.Name = "buttonOpenMovie"; - this.buttonOpenMovie.Size = new System.Drawing.Size(109, 23); - this.buttonOpenMovie.TabIndex = 12; - this.buttonOpenMovie.Text = "Open movie..."; - this.buttonOpenMovie.UseVisualStyleBackColor = true; - this.buttonOpenMovie.Click += new System.EventHandler(this.buttonOpenMovie_Click); - // - // timer1 - // - this.timer1.Interval = 50; - this.timer1.Tick += new System.EventHandler(this.timer1_Tick); - // - // labelVideoFileName - // - this.labelVideoFileName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelVideoFileName.AutoSize = true; - this.labelVideoFileName.Location = new System.Drawing.Point(12, 250); - this.labelVideoFileName.Name = "labelVideoFileName"; - this.labelVideoFileName.Size = new System.Drawing.Size(98, 13); - this.labelVideoFileName.TabIndex = 21; - this.labelVideoFileName.Text = "labelVideoFileName"; - // - // buttonHalfASecondBack - // - this.buttonHalfASecondBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonHalfASecondBack.Location = new System.Drawing.Point(12, 560); - this.buttonHalfASecondBack.Name = "buttonHalfASecondBack"; - this.buttonHalfASecondBack.Size = new System.Drawing.Size(77, 23); - this.buttonHalfASecondBack.TabIndex = 20; - this.buttonHalfASecondBack.Text = "&½ second <"; - this.buttonHalfASecondBack.UseVisualStyleBackColor = true; - this.buttonHalfASecondBack.Click += new System.EventHandler(this.buttonStartHalfASecondBack_Click); - // - // buttonThreeSecondsBack - // - this.buttonThreeSecondsBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonThreeSecondsBack.Location = new System.Drawing.Point(95, 560); - this.buttonThreeSecondsBack.Name = "buttonThreeSecondsBack"; - this.buttonThreeSecondsBack.Size = new System.Drawing.Size(77, 23); - this.buttonThreeSecondsBack.TabIndex = 21; - this.buttonThreeSecondsBack.Text = "&3 seconds <"; - this.buttonThreeSecondsBack.UseVisualStyleBackColor = true; - this.buttonThreeSecondsBack.Click += new System.EventHandler(this.buttonStartThreeSecondsBack_Click); - // - // buttonThreeSecondsAhead - // - this.buttonThreeSecondsAhead.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonThreeSecondsAhead.Location = new System.Drawing.Point(303, 560); - this.buttonThreeSecondsAhead.Name = "buttonThreeSecondsAhead"; - this.buttonThreeSecondsAhead.Size = new System.Drawing.Size(77, 23); - this.buttonThreeSecondsAhead.TabIndex = 23; - this.buttonThreeSecondsAhead.Text = "3 seconds >"; - this.buttonThreeSecondsAhead.UseVisualStyleBackColor = true; - this.buttonThreeSecondsAhead.Click += new System.EventHandler(this.buttonStartThreeSecondsAhead_Click); - // - // buttonHalfASecondAhead - // - this.buttonHalfASecondAhead.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonHalfASecondAhead.Location = new System.Drawing.Point(386, 560); - this.buttonHalfASecondAhead.Name = "buttonHalfASecondAhead"; - this.buttonHalfASecondAhead.Size = new System.Drawing.Size(77, 23); - this.buttonHalfASecondAhead.TabIndex = 24; - this.buttonHalfASecondAhead.Text = "½ second >"; - this.buttonHalfASecondAhead.UseVisualStyleBackColor = true; - this.buttonHalfASecondAhead.Click += new System.EventHandler(this.buttonStartHalfASecondAhead_Click); - // - // buttonVerify - // - this.buttonVerify.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonVerify.Location = new System.Drawing.Point(178, 560); - this.buttonVerify.Name = "buttonVerify"; - this.buttonVerify.Size = new System.Drawing.Size(119, 23); - this.buttonVerify.TabIndex = 22; - this.buttonVerify.Text = "Play 2 s and back"; - this.buttonVerify.UseVisualStyleBackColor = true; - this.buttonVerify.Click += new System.EventHandler(this.buttonStartVerify_Click); - // - // labelSubtitle - // - this.labelSubtitle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.labelSubtitle.BackColor = System.Drawing.Color.Black; - this.labelSubtitle.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelSubtitle.ForeColor = System.Drawing.Color.White; - this.labelSubtitle.Location = new System.Drawing.Point(12, 529); - this.labelSubtitle.Name = "labelSubtitle"; - this.labelSubtitle.Size = new System.Drawing.Size(779, 28); - this.labelSubtitle.TabIndex = 27; - this.labelSubtitle.Text = "labelSubtitle"; - this.labelSubtitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // videoPlayerContainer1 - // - this.videoPlayerContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.videoPlayerContainer1.BackColor = System.Drawing.Color.Black; - this.videoPlayerContainer1.CurrentPosition = 0D; - this.videoPlayerContainer1.FontSizeFactor = 1F; - this.videoPlayerContainer1.LastParagraph = null; - this.videoPlayerContainer1.Location = new System.Drawing.Point(12, 267); - this.videoPlayerContainer1.Name = "videoPlayerContainer1"; - this.videoPlayerContainer1.ShowFullscreenButton = true; - this.videoPlayerContainer1.ShowMuteButton = true; - this.videoPlayerContainer1.ShowStopButton = true; - this.videoPlayerContainer1.Size = new System.Drawing.Size(779, 263); - this.videoPlayerContainer1.SmpteMode = false; - this.videoPlayerContainer1.SubtitleText = ""; - this.videoPlayerContainer1.TabIndex = 13; - this.videoPlayerContainer1.TextRightToLeft = System.Windows.Forms.RightToLeft.No; - this.videoPlayerContainer1.VideoHeight = 0; - this.videoPlayerContainer1.VideoPlayer = null; - this.videoPlayerContainer1.VideoWidth = 0; - this.videoPlayerContainer1.Volume = 0D; - // - // buttonFindTextEnd - // - this.buttonFindTextEnd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonFindTextEnd.Location = new System.Drawing.Point(469, 560); - this.buttonFindTextEnd.Name = "buttonFindTextEnd"; - this.buttonFindTextEnd.Size = new System.Drawing.Size(106, 23); - this.buttonFindTextEnd.TabIndex = 25; - this.buttonFindTextEnd.Text = "Find text..."; - this.buttonFindTextEnd.UseVisualStyleBackColor = true; - this.buttonFindTextEnd.Click += new System.EventHandler(this.ButtonFindTextEndClick); - // - // SetSyncPoint - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 609); - this.Controls.Add(this.buttonFindTextEnd); - this.Controls.Add(this.labelSubtitle); - this.Controls.Add(this.buttonVerify); - this.Controls.Add(this.buttonHalfASecondBack); - this.Controls.Add(this.buttonThreeSecondsBack); - this.Controls.Add(this.buttonThreeSecondsAhead); - this.Controls.Add(this.buttonHalfASecondAhead); - this.Controls.Add(this.labelVideoFileName); - this.Controls.Add(this.buttonOpenMovie); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonSetSyncPoint); - this.Controls.Add(this.groupBox2); - this.Controls.Add(this.groupBoxSyncPointTimeCode); - this.Controls.Add(this.videoPlayerContainer1); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(700, 600); - this.Name = "SetSyncPoint"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Set sync point"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GetTime_FormClosing); - this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.GetTime_FormClosed); - this.Load += new System.EventHandler(this.GetTimeLoad); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GetTime_KeyDown); - this.groupBoxSyncPointTimeCode.ResumeLayout(false); - this.groupBoxSyncPointTimeCode.PerformLayout(); - this.groupBox2.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private Controls.VideoPlayerContainer videoPlayerContainer1; - private Controls.TimeUpDown timeUpDownLine; - private System.Windows.Forms.GroupBox groupBoxSyncPointTimeCode; - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonSetSyncPoint; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Button buttonOpenMovie; - private System.Windows.Forms.Timer timer1; - private System.Windows.Forms.Label labelVideoFileName; - private System.Windows.Forms.Button buttonHalfASecondBack; - private System.Windows.Forms.Button buttonThreeSecondsBack; - private System.Windows.Forms.Button buttonThreeSecondsAhead; - private System.Windows.Forms.Button buttonHalfASecondAhead; - private System.Windows.Forms.Button buttonVerify; - private System.Windows.Forms.Label labelSubtitle; - private Controls.SubtitleListView subtitleListView1; - private System.Windows.Forms.Button buttonFindTextEnd; - } +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + partial class SetSyncPoint + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + TimeCode timeCode1 = new TimeCode(); + this.groupBoxSyncPointTimeCode = new System.Windows.Forms.GroupBox(); + this.timeUpDownLine = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSetSyncPoint = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.buttonOpenMovie = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.labelVideoFileName = new System.Windows.Forms.Label(); + this.buttonHalfASecondBack = new System.Windows.Forms.Button(); + this.buttonThreeSecondsBack = new System.Windows.Forms.Button(); + this.buttonThreeSecondsAhead = new System.Windows.Forms.Button(); + this.buttonHalfASecondAhead = new System.Windows.Forms.Button(); + this.buttonVerify = new System.Windows.Forms.Button(); + this.labelSubtitle = new System.Windows.Forms.Label(); + this.videoPlayerContainer1 = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); + this.buttonFindTextEnd = new System.Windows.Forms.Button(); + this.groupBoxSyncPointTimeCode.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxSyncPointTimeCode + // + this.groupBoxSyncPointTimeCode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.groupBoxSyncPointTimeCode.Controls.Add(this.timeUpDownLine); + this.groupBoxSyncPointTimeCode.Location = new System.Drawing.Point(12, 12); + this.groupBoxSyncPointTimeCode.Name = "groupBoxSyncPointTimeCode"; + this.groupBoxSyncPointTimeCode.Size = new System.Drawing.Size(172, 224); + this.groupBoxSyncPointTimeCode.TabIndex = 1; + this.groupBoxSyncPointTimeCode.TabStop = false; + this.groupBoxSyncPointTimeCode.Text = "Sync point time code"; + // + // timeUpDownLine + // + this.timeUpDownLine.AutoSize = true; + this.timeUpDownLine.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownLine.Font = new System.Drawing.Font("Segoe UI", 9F); + this.timeUpDownLine.Location = new System.Drawing.Point(18, 19); + this.timeUpDownLine.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownLine.Name = "timeUpDownLine"; + this.timeUpDownLine.Size = new System.Drawing.Size(111, 27); + this.timeUpDownLine.TabIndex = 1; + timeCode1.Hours = 0; + timeCode1.Milliseconds = 0; + timeCode1.Minutes = 0; + timeCode1.Seconds = 0; + timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode1.TotalMilliseconds = 0D; + timeCode1.TotalSeconds = 0D; + this.timeUpDownLine.TimeCode = timeCode1; + this.timeUpDownLine.UseVideoOffset = false; + this.timeUpDownLine.KeyDown += new System.Windows.Forms.KeyEventHandler(this.timeUpDownLine_KeyDown); + // + // groupBox2 + // + this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox2.Controls.Add(this.subtitleListView1); + this.groupBox2.Location = new System.Drawing.Point(190, 13); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(605, 223); + this.groupBox2.TabIndex = 10; + this.groupBox2.TabStop = false; + // + // subtitleListView1 + // + this.subtitleListView1.AllowColumnReorder = true; + this.subtitleListView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.subtitleListView1.FirstVisibleIndex = -1; + this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.subtitleListView1.FullRowSelect = true; + this.subtitleListView1.GridLines = true; + this.subtitleListView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.subtitleListView1.HideSelection = false; + this.subtitleListView1.Location = new System.Drawing.Point(6, 18); + this.subtitleListView1.Name = "subtitleListView1"; + this.subtitleListView1.OwnerDraw = true; + this.subtitleListView1.Size = new System.Drawing.Size(593, 199); + this.subtitleListView1.SubtitleFontBold = false; + this.subtitleListView1.SubtitleFontName = "Tahoma"; + this.subtitleListView1.SubtitleFontSize = 8; + this.subtitleListView1.TabIndex = 11; + this.subtitleListView1.UseCompatibleStateImageBehavior = false; + this.subtitleListView1.UseSyntaxColoring = true; + this.subtitleListView1.View = System.Windows.Forms.View.Details; + this.subtitleListView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListView1MouseDoubleClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(713, 584); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 31; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonSetSyncPoint + // + this.buttonSetSyncPoint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSetSyncPoint.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonSetSyncPoint.Location = new System.Drawing.Point(584, 584); + this.buttonSetSyncPoint.Name = "buttonSetSyncPoint"; + this.buttonSetSyncPoint.Size = new System.Drawing.Size(123, 23); + this.buttonSetSyncPoint.TabIndex = 30; + this.buttonSetSyncPoint.Text = "&Set sync point"; + this.buttonSetSyncPoint.UseVisualStyleBackColor = true; + this.buttonSetSyncPoint.Click += new System.EventHandler(this.buttonOK_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // buttonOpenMovie + // + this.buttonOpenMovie.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOpenMovie.Location = new System.Drawing.Point(682, 241); + this.buttonOpenMovie.Name = "buttonOpenMovie"; + this.buttonOpenMovie.Size = new System.Drawing.Size(109, 23); + this.buttonOpenMovie.TabIndex = 12; + this.buttonOpenMovie.Text = "Open movie..."; + this.buttonOpenMovie.UseVisualStyleBackColor = true; + this.buttonOpenMovie.Click += new System.EventHandler(this.buttonOpenMovie_Click); + // + // timer1 + // + this.timer1.Interval = 50; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // labelVideoFileName + // + this.labelVideoFileName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelVideoFileName.AutoSize = true; + this.labelVideoFileName.Location = new System.Drawing.Point(12, 250); + this.labelVideoFileName.Name = "labelVideoFileName"; + this.labelVideoFileName.Size = new System.Drawing.Size(98, 13); + this.labelVideoFileName.TabIndex = 21; + this.labelVideoFileName.Text = "labelVideoFileName"; + // + // buttonHalfASecondBack + // + this.buttonHalfASecondBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonHalfASecondBack.Location = new System.Drawing.Point(12, 560); + this.buttonHalfASecondBack.Name = "buttonHalfASecondBack"; + this.buttonHalfASecondBack.Size = new System.Drawing.Size(77, 23); + this.buttonHalfASecondBack.TabIndex = 20; + this.buttonHalfASecondBack.Text = "&½ second <"; + this.buttonHalfASecondBack.UseVisualStyleBackColor = true; + this.buttonHalfASecondBack.Click += new System.EventHandler(this.buttonStartHalfASecondBack_Click); + // + // buttonThreeSecondsBack + // + this.buttonThreeSecondsBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonThreeSecondsBack.Location = new System.Drawing.Point(95, 560); + this.buttonThreeSecondsBack.Name = "buttonThreeSecondsBack"; + this.buttonThreeSecondsBack.Size = new System.Drawing.Size(77, 23); + this.buttonThreeSecondsBack.TabIndex = 21; + this.buttonThreeSecondsBack.Text = "&3 seconds <"; + this.buttonThreeSecondsBack.UseVisualStyleBackColor = true; + this.buttonThreeSecondsBack.Click += new System.EventHandler(this.buttonStartThreeSecondsBack_Click); + // + // buttonThreeSecondsAhead + // + this.buttonThreeSecondsAhead.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonThreeSecondsAhead.Location = new System.Drawing.Point(303, 560); + this.buttonThreeSecondsAhead.Name = "buttonThreeSecondsAhead"; + this.buttonThreeSecondsAhead.Size = new System.Drawing.Size(77, 23); + this.buttonThreeSecondsAhead.TabIndex = 23; + this.buttonThreeSecondsAhead.Text = "3 seconds >"; + this.buttonThreeSecondsAhead.UseVisualStyleBackColor = true; + this.buttonThreeSecondsAhead.Click += new System.EventHandler(this.buttonStartThreeSecondsAhead_Click); + // + // buttonHalfASecondAhead + // + this.buttonHalfASecondAhead.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonHalfASecondAhead.Location = new System.Drawing.Point(386, 560); + this.buttonHalfASecondAhead.Name = "buttonHalfASecondAhead"; + this.buttonHalfASecondAhead.Size = new System.Drawing.Size(77, 23); + this.buttonHalfASecondAhead.TabIndex = 24; + this.buttonHalfASecondAhead.Text = "½ second >"; + this.buttonHalfASecondAhead.UseVisualStyleBackColor = true; + this.buttonHalfASecondAhead.Click += new System.EventHandler(this.buttonStartHalfASecondAhead_Click); + // + // buttonVerify + // + this.buttonVerify.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonVerify.Location = new System.Drawing.Point(178, 560); + this.buttonVerify.Name = "buttonVerify"; + this.buttonVerify.Size = new System.Drawing.Size(119, 23); + this.buttonVerify.TabIndex = 22; + this.buttonVerify.Text = "Play 2 s and back"; + this.buttonVerify.UseVisualStyleBackColor = true; + this.buttonVerify.Click += new System.EventHandler(this.buttonStartVerify_Click); + // + // labelSubtitle + // + this.labelSubtitle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.labelSubtitle.BackColor = System.Drawing.Color.Black; + this.labelSubtitle.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelSubtitle.ForeColor = System.Drawing.Color.White; + this.labelSubtitle.Location = new System.Drawing.Point(12, 529); + this.labelSubtitle.Name = "labelSubtitle"; + this.labelSubtitle.Size = new System.Drawing.Size(779, 28); + this.labelSubtitle.TabIndex = 27; + this.labelSubtitle.Text = "labelSubtitle"; + this.labelSubtitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // videoPlayerContainer1 + // + this.videoPlayerContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.videoPlayerContainer1.BackColor = System.Drawing.Color.Black; + this.videoPlayerContainer1.CurrentPosition = 0D; + this.videoPlayerContainer1.FontSizeFactor = 1F; + this.videoPlayerContainer1.LastParagraph = null; + this.videoPlayerContainer1.Location = new System.Drawing.Point(12, 267); + this.videoPlayerContainer1.Name = "videoPlayerContainer1"; + this.videoPlayerContainer1.ShowFullscreenButton = true; + this.videoPlayerContainer1.ShowMuteButton = true; + this.videoPlayerContainer1.ShowStopButton = true; + this.videoPlayerContainer1.Size = new System.Drawing.Size(779, 263); + this.videoPlayerContainer1.SmpteMode = false; + this.videoPlayerContainer1.SubtitleText = ""; + this.videoPlayerContainer1.TabIndex = 13; + this.videoPlayerContainer1.TextRightToLeft = System.Windows.Forms.RightToLeft.No; + this.videoPlayerContainer1.VideoHeight = 0; + this.videoPlayerContainer1.VideoPlayer = null; + this.videoPlayerContainer1.VideoWidth = 0; + this.videoPlayerContainer1.Volume = 0D; + // + // buttonFindTextEnd + // + this.buttonFindTextEnd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonFindTextEnd.Location = new System.Drawing.Point(469, 560); + this.buttonFindTextEnd.Name = "buttonFindTextEnd"; + this.buttonFindTextEnd.Size = new System.Drawing.Size(106, 23); + this.buttonFindTextEnd.TabIndex = 25; + this.buttonFindTextEnd.Text = "Find text..."; + this.buttonFindTextEnd.UseVisualStyleBackColor = true; + this.buttonFindTextEnd.Click += new System.EventHandler(this.ButtonFindTextEndClick); + // + // SetSyncPoint + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 609); + this.Controls.Add(this.buttonFindTextEnd); + this.Controls.Add(this.labelSubtitle); + this.Controls.Add(this.buttonVerify); + this.Controls.Add(this.buttonHalfASecondBack); + this.Controls.Add(this.buttonThreeSecondsBack); + this.Controls.Add(this.buttonThreeSecondsAhead); + this.Controls.Add(this.buttonHalfASecondAhead); + this.Controls.Add(this.labelVideoFileName); + this.Controls.Add(this.buttonOpenMovie); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSetSyncPoint); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBoxSyncPointTimeCode); + this.Controls.Add(this.videoPlayerContainer1); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(700, 600); + this.Name = "SetSyncPoint"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Set sync point"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GetTime_FormClosing); + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.GetTime_FormClosed); + this.Load += new System.EventHandler(this.GetTimeLoad); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GetTime_KeyDown); + this.groupBoxSyncPointTimeCode.ResumeLayout(false); + this.groupBoxSyncPointTimeCode.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Controls.VideoPlayerContainer videoPlayerContainer1; + private Controls.TimeUpDown timeUpDownLine; + private System.Windows.Forms.GroupBox groupBoxSyncPointTimeCode; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonSetSyncPoint; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Button buttonOpenMovie; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Label labelVideoFileName; + private System.Windows.Forms.Button buttonHalfASecondBack; + private System.Windows.Forms.Button buttonThreeSecondsBack; + private System.Windows.Forms.Button buttonThreeSecondsAhead; + private System.Windows.Forms.Button buttonHalfASecondAhead; + private System.Windows.Forms.Button buttonVerify; + private System.Windows.Forms.Label labelSubtitle; + private Controls.SubtitleListView subtitleListView1; + private System.Windows.Forms.Button buttonFindTextEnd; + } } \ No newline at end of file diff --git a/src/Forms/SetSyncPoint.cs b/src/ui/Forms/SetSyncPoint.cs similarity index 97% rename from src/Forms/SetSyncPoint.cs rename to src/ui/Forms/SetSyncPoint.cs index 449e6bd47..4857ff622 100644 --- a/src/Forms/SetSyncPoint.cs +++ b/src/ui/Forms/SetSyncPoint.cs @@ -1,388 +1,388 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using Nikse.SubtitleEdit.Logic.VideoPlayers; -using System; -using System.IO; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class SetSyncPoint : Form - { - private double _lastPosition; - private TimeSpan _guess; - private double _goBackPosition; - private double _stopPosition = -1.0; - private Subtitle _subtitle; - private int _audioTrackNumber = -1; - private readonly Keys _mainGeneralGoToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle); - private readonly Keys _mainGeneralGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle); - private string _subtitleFileName; - public string VideoFileName { get; private set; } - - public SetSyncPoint() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - groupBoxSyncPointTimeCode.Text = Configuration.Settings.Language.SetSyncPoint.SyncPointTimeCode; - buttonThreeSecondsBack.Text = Configuration.Settings.Language.SetSyncPoint.ThreeSecondsBack; - buttonHalfASecondBack.Text = Configuration.Settings.Language.SetSyncPoint.HalfASecondBack; - buttonVerify.Text = string.Format(Configuration.Settings.Language.VisualSync.PlayXSecondsAndBack, Configuration.Settings.Tools.VerifyPlaySeconds); - buttonHalfASecondAhead.Text = Configuration.Settings.Language.SetSyncPoint.HalfASecondForward; - buttonThreeSecondsAhead.Text = Configuration.Settings.Language.SetSyncPoint.ThreeSecondsForward; - buttonOpenMovie.Text = Configuration.Settings.Language.General.OpenVideoFile; - buttonSetSyncPoint.Text = Configuration.Settings.Language.PointSync.SetSyncPoint; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - subtitleListView1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - UiUtil.InitializeSubtitleFont(subtitleListView1); - subtitleListView1.AutoSizeAllColumns(this); - buttonFindTextEnd.Text = Configuration.Settings.Language.VisualSync.FindText; - UiUtil.FixLargeFonts(this, buttonSetSyncPoint); - } - - public TimeSpan SynchronizationPoint => timeUpDownLine.TimeCode.TimeSpan; - - public void Initialize(Subtitle subtitle, string subtitleFileName, int index, string videoFileName, int audioTrackNumber) - { - _subtitleFileName = subtitleFileName; - _subtitle = subtitle; - _audioTrackNumber = audioTrackNumber; - subtitleListView1.Fill(subtitle); - _guess = subtitle.Paragraphs[index].StartTime.TimeSpan; - subtitleListView1.Items[index].Selected = true; - Text = string.Format(Configuration.Settings.Language.SetSyncPoint.Title, subtitle.Paragraphs[index].Number + ": " + subtitle.Paragraphs[index]); - labelSubtitle.Text = string.Empty; - labelVideoFileName.Text = Configuration.Settings.Language.General.NoVideoLoaded; - - timeUpDownLine.TimeCode = subtitle.Paragraphs[index].StartTime; - - if (!string.IsNullOrEmpty(videoFileName) && File.Exists(videoFileName)) - { - OpenVideo(videoFileName); - } - else if (!string.IsNullOrEmpty(subtitleFileName)) - { - TryToFindAndOpenVideoFile(Path.GetDirectoryName(subtitleFileName) + Path.DirectorySeparatorChar + - Path.GetFileNameWithoutExtension(subtitleFileName)); - } - } - - private void TryToFindAndOpenVideoFile(string fileNameNoExtension) - { - string movieFileName = null; - - foreach (string extension in Utilities.VideoFileExtensions) - { - movieFileName = fileNameNoExtension + extension; - if (File.Exists(movieFileName)) - { - break; - } - } - - if (movieFileName != null && File.Exists(movieFileName)) - { - OpenVideo(movieFileName); - } - else if (fileNameNoExtension.Contains('.')) - { - fileNameNoExtension = fileNameNoExtension.Substring(0, fileNameNoExtension.LastIndexOf('.')); - TryToFindAndOpenVideoFile(fileNameNoExtension); - } - } - - private void buttonOpenMovie_Click(object sender, EventArgs e) - { - openFileDialog1.Title = Configuration.Settings.Language.General.OpenVideoFileTitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = Utilities.GetVideoFileFilter(false); - if (File.Exists(_subtitleFileName)) - { - var videoFileExt = Utilities.GetVideoFileFilter(false); - var folder = Path.GetDirectoryName(_subtitleFileName); - if (folder != null) - { - foreach (var file in Directory.GetFiles(folder)) - { - if (file.EndsWith(".nfo", StringComparison.OrdinalIgnoreCase) - || file.EndsWith(".srt", StringComparison.OrdinalIgnoreCase) - || file.EndsWith(".sub", StringComparison.OrdinalIgnoreCase)) - { - continue; - } - - if (videoFileExt.Contains(Path.GetExtension(file))) - { - openFileDialog1.InitialDirectory = Path.GetDirectoryName(file); - break; - } - } - } - } - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - _audioTrackNumber = -1; - openFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName); - OpenVideo(openFileDialog1.FileName); - } - } - - private void OpenVideo(string fileName) - { - if (File.Exists(fileName)) - { - var fi = new FileInfo(fileName); - if (fi.Length < 1000) - { - return; - } - - labelVideoFileName.Text = fileName; - VideoFileName = fileName; - if (videoPlayerContainer1.VideoPlayer != null) - { - videoPlayerContainer1.Pause(); - videoPlayerContainer1.VideoPlayer.DisposeVideoPlayer(); - } - - VideoInfo videoInfo = UiUtil.GetVideoInfo(fileName); - - UiUtil.InitializeVideoPlayerAndContainer(fileName, videoInfo, videoPlayerContainer1, VideoStartLoaded, VideoStartEnded); - } - } - - private void VideoStartEnded(object sender, EventArgs e) - { - videoPlayerContainer1.Pause(); - } - - private void VideoStartLoaded(object sender, EventArgs e) - { - timer1.Start(); - - videoPlayerContainer1.Pause(); - - if (_guess.TotalMilliseconds > 0 && _guess.TotalMilliseconds / TimeCode.BaseUnit < videoPlayerContainer1.VideoPlayer.Duration) - { - videoPlayerContainer1.VideoPlayer.CurrentPosition = _guess.TotalMilliseconds / TimeCode.BaseUnit; - videoPlayerContainer1.RefreshProgressBar(); - } - - if (_audioTrackNumber >= 0 && videoPlayerContainer1.VideoPlayer is LibVlcDynamic libVlc) - { - libVlc.AudioTrackNumber = _audioTrackNumber; - } - else if (_audioTrackNumber >= 0 && videoPlayerContainer1.VideoPlayer is LibMpvDynamic libMpv) - { - libMpv.AudioTrackNumber = _audioTrackNumber; - } - } - - private void timer1_Tick(object sender, EventArgs e) - { - if (videoPlayerContainer1 != null) - { - double pos; - - if (_stopPosition >= 0 && videoPlayerContainer1.CurrentPosition > _stopPosition) - { - videoPlayerContainer1.Pause(); - videoPlayerContainer1.CurrentPosition = _goBackPosition; - _stopPosition = -1; - } - - if (!videoPlayerContainer1.IsPaused) - { - videoPlayerContainer1.RefreshProgressBar(); - pos = videoPlayerContainer1.CurrentPosition; - } - else - { - pos = videoPlayerContainer1.CurrentPosition; - } - if (Math.Abs(pos - _lastPosition) > 0.01) - { - UiUtil.ShowSubtitle(_subtitle, videoPlayerContainer1); - timeUpDownLine.TimeCode = TimeCode.FromSeconds(pos); - _lastPosition = pos; - } - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void GetTime_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == Keys.S && e.Modifiers == Keys.Control) - { - videoPlayerContainer1.Pause(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.P && e.Control) - { - videoPlayerContainer1.VideoPlayer.Pause(); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Left) - { - GoBackSeconds(0.5, videoPlayerContainer1.VideoPlayer); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Right) - { - GoBackSeconds(-0.5, videoPlayerContainer1.VideoPlayer); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Left) - { - GoBackSeconds(0.1, videoPlayerContainer1.VideoPlayer); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Right) - { - GoBackSeconds(-0.1, videoPlayerContainer1.VideoPlayer); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#sync"); - e.SuppressKeyPress = true; - } - else if (_mainGeneralGoToNextSubtitle == e.KeyData || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)) - { - int selectedIndex = 0; - if (subtitleListView1.SelectedItems.Count > 0) - { - selectedIndex = subtitleListView1.SelectedItems[0].Index; - selectedIndex++; - } - subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex); - e.SuppressKeyPress = true; - } - else if (_mainGeneralGoToPrevSubtitle == e.KeyData || (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt)) - { - int selectedIndex = 0; - if (subtitleListView1.SelectedItems.Count > 0) - { - selectedIndex = subtitleListView1.SelectedItems[0].Index; - selectedIndex--; - } - subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex); - e.SuppressKeyPress = true; - } - } - - private void GetTime_FormClosing(object sender, FormClosingEventArgs e) - { - timer1.Stop(); - videoPlayerContainer1?.Pause(); - } - - private void GetTime_FormClosed(object sender, FormClosedEventArgs e) - { - videoPlayerContainer1.VideoPlayer?.DisposeVideoPlayer(); - } - - private void GoBackSeconds(double seconds, VideoPlayer mediaPlayer) - { - if (mediaPlayer != null) - { - if (mediaPlayer.CurrentPosition > seconds) - { - mediaPlayer.CurrentPosition -= seconds; - } - else - { - mediaPlayer.CurrentPosition = 0; - } - - videoPlayerContainer1.RefreshProgressBar(); - } - } - - private void buttonStartHalfASecondBack_Click(object sender, EventArgs e) - { - GoBackSeconds(0.5, videoPlayerContainer1.VideoPlayer); - } - - private void buttonStartThreeSecondsBack_Click(object sender, EventArgs e) - { - GoBackSeconds(3, videoPlayerContainer1.VideoPlayer); - } - - private void buttonStartThreeSecondsAhead_Click(object sender, EventArgs e) - { - GoBackSeconds(-3.0, videoPlayerContainer1.VideoPlayer); - } - - private void buttonStartHalfASecondAhead_Click(object sender, EventArgs e) - { - GoBackSeconds(-0.5, videoPlayerContainer1.VideoPlayer); - } - - private void buttonStartVerify_Click(object sender, EventArgs e) - { - if (videoPlayerContainer1?.VideoPlayer != null) - { - _goBackPosition = videoPlayerContainer1.CurrentPosition; - _stopPosition = _goBackPosition + Configuration.Settings.Tools.VerifyPlaySeconds; - videoPlayerContainer1.Play(); - } - } - - private void GetTimeLoad(object sender, EventArgs e) - { - if (subtitleListView1.SelectedItems.Count == 1) - { - subtitleListView1.SelectIndexAndEnsureVisible(subtitleListView1.SelectedItems[0].Index); - } - } - - private void SubtitleListView1MouseDoubleClick(object sender, MouseEventArgs e) - { - if (subtitleListView1.SelectedItems.Count == 1) - { - int index = subtitleListView1.SelectedItems[0].Index; - - videoPlayerContainer1.Pause(); - videoPlayerContainer1.CurrentPosition = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds / TimeCode.BaseUnit; - } - } - - private void ButtonFindTextEndClick(object sender, EventArgs e) - { - using (var findSubtitle = new FindSubtitleLine()) - { - findSubtitle.Initialize(_subtitle.Paragraphs, string.Empty); - findSubtitle.ShowDialog(); - if (findSubtitle.SelectedIndex >= 0) - { - subtitleListView1.SelectIndexAndEnsureVisible(findSubtitle.SelectedIndex); - } - } - } - - private void timeUpDownLine_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - buttonOK_Click(sender, e); - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using Nikse.SubtitleEdit.Logic.VideoPlayers; +using System; +using System.IO; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class SetSyncPoint : Form + { + private double _lastPosition; + private TimeSpan _guess; + private double _goBackPosition; + private double _stopPosition = -1.0; + private Subtitle _subtitle; + private int _audioTrackNumber = -1; + private readonly Keys _mainGeneralGoToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle); + private readonly Keys _mainGeneralGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle); + private string _subtitleFileName; + public string VideoFileName { get; private set; } + + public SetSyncPoint() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + groupBoxSyncPointTimeCode.Text = Configuration.Settings.Language.SetSyncPoint.SyncPointTimeCode; + buttonThreeSecondsBack.Text = Configuration.Settings.Language.SetSyncPoint.ThreeSecondsBack; + buttonHalfASecondBack.Text = Configuration.Settings.Language.SetSyncPoint.HalfASecondBack; + buttonVerify.Text = string.Format(Configuration.Settings.Language.VisualSync.PlayXSecondsAndBack, Configuration.Settings.Tools.VerifyPlaySeconds); + buttonHalfASecondAhead.Text = Configuration.Settings.Language.SetSyncPoint.HalfASecondForward; + buttonThreeSecondsAhead.Text = Configuration.Settings.Language.SetSyncPoint.ThreeSecondsForward; + buttonOpenMovie.Text = Configuration.Settings.Language.General.OpenVideoFile; + buttonSetSyncPoint.Text = Configuration.Settings.Language.PointSync.SetSyncPoint; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + subtitleListView1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + UiUtil.InitializeSubtitleFont(subtitleListView1); + subtitleListView1.AutoSizeAllColumns(this); + buttonFindTextEnd.Text = Configuration.Settings.Language.VisualSync.FindText; + UiUtil.FixLargeFonts(this, buttonSetSyncPoint); + } + + public TimeSpan SynchronizationPoint => timeUpDownLine.TimeCode.TimeSpan; + + public void Initialize(Subtitle subtitle, string subtitleFileName, int index, string videoFileName, int audioTrackNumber) + { + _subtitleFileName = subtitleFileName; + _subtitle = subtitle; + _audioTrackNumber = audioTrackNumber; + subtitleListView1.Fill(subtitle); + _guess = subtitle.Paragraphs[index].StartTime.TimeSpan; + subtitleListView1.Items[index].Selected = true; + Text = string.Format(Configuration.Settings.Language.SetSyncPoint.Title, subtitle.Paragraphs[index].Number + ": " + subtitle.Paragraphs[index]); + labelSubtitle.Text = string.Empty; + labelVideoFileName.Text = Configuration.Settings.Language.General.NoVideoLoaded; + + timeUpDownLine.TimeCode = subtitle.Paragraphs[index].StartTime; + + if (!string.IsNullOrEmpty(videoFileName) && File.Exists(videoFileName)) + { + OpenVideo(videoFileName); + } + else if (!string.IsNullOrEmpty(subtitleFileName)) + { + TryToFindAndOpenVideoFile(Path.GetDirectoryName(subtitleFileName) + Path.DirectorySeparatorChar + + Path.GetFileNameWithoutExtension(subtitleFileName)); + } + } + + private void TryToFindAndOpenVideoFile(string fileNameNoExtension) + { + string movieFileName = null; + + foreach (string extension in Utilities.VideoFileExtensions) + { + movieFileName = fileNameNoExtension + extension; + if (File.Exists(movieFileName)) + { + break; + } + } + + if (movieFileName != null && File.Exists(movieFileName)) + { + OpenVideo(movieFileName); + } + else if (fileNameNoExtension.Contains('.')) + { + fileNameNoExtension = fileNameNoExtension.Substring(0, fileNameNoExtension.LastIndexOf('.')); + TryToFindAndOpenVideoFile(fileNameNoExtension); + } + } + + private void buttonOpenMovie_Click(object sender, EventArgs e) + { + openFileDialog1.Title = Configuration.Settings.Language.General.OpenVideoFileTitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = Utilities.GetVideoFileFilter(false); + if (File.Exists(_subtitleFileName)) + { + var videoFileExt = Utilities.GetVideoFileFilter(false); + var folder = Path.GetDirectoryName(_subtitleFileName); + if (folder != null) + { + foreach (var file in Directory.GetFiles(folder)) + { + if (file.EndsWith(".nfo", StringComparison.OrdinalIgnoreCase) + || file.EndsWith(".srt", StringComparison.OrdinalIgnoreCase) + || file.EndsWith(".sub", StringComparison.OrdinalIgnoreCase)) + { + continue; + } + + if (videoFileExt.Contains(Path.GetExtension(file))) + { + openFileDialog1.InitialDirectory = Path.GetDirectoryName(file); + break; + } + } + } + } + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + _audioTrackNumber = -1; + openFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName); + OpenVideo(openFileDialog1.FileName); + } + } + + private void OpenVideo(string fileName) + { + if (File.Exists(fileName)) + { + var fi = new FileInfo(fileName); + if (fi.Length < 1000) + { + return; + } + + labelVideoFileName.Text = fileName; + VideoFileName = fileName; + if (videoPlayerContainer1.VideoPlayer != null) + { + videoPlayerContainer1.Pause(); + videoPlayerContainer1.VideoPlayer.DisposeVideoPlayer(); + } + + VideoInfo videoInfo = UiUtil.GetVideoInfo(fileName); + + UiUtil.InitializeVideoPlayerAndContainer(fileName, videoInfo, videoPlayerContainer1, VideoStartLoaded, VideoStartEnded); + } + } + + private void VideoStartEnded(object sender, EventArgs e) + { + videoPlayerContainer1.Pause(); + } + + private void VideoStartLoaded(object sender, EventArgs e) + { + timer1.Start(); + + videoPlayerContainer1.Pause(); + + if (_guess.TotalMilliseconds > 0 && _guess.TotalMilliseconds / TimeCode.BaseUnit < videoPlayerContainer1.VideoPlayer.Duration) + { + videoPlayerContainer1.VideoPlayer.CurrentPosition = _guess.TotalMilliseconds / TimeCode.BaseUnit; + videoPlayerContainer1.RefreshProgressBar(); + } + + if (_audioTrackNumber >= 0 && videoPlayerContainer1.VideoPlayer is LibVlcDynamic libVlc) + { + libVlc.AudioTrackNumber = _audioTrackNumber; + } + else if (_audioTrackNumber >= 0 && videoPlayerContainer1.VideoPlayer is LibMpvDynamic libMpv) + { + libMpv.AudioTrackNumber = _audioTrackNumber; + } + } + + private void timer1_Tick(object sender, EventArgs e) + { + if (videoPlayerContainer1 != null) + { + double pos; + + if (_stopPosition >= 0 && videoPlayerContainer1.CurrentPosition > _stopPosition) + { + videoPlayerContainer1.Pause(); + videoPlayerContainer1.CurrentPosition = _goBackPosition; + _stopPosition = -1; + } + + if (!videoPlayerContainer1.IsPaused) + { + videoPlayerContainer1.RefreshProgressBar(); + pos = videoPlayerContainer1.CurrentPosition; + } + else + { + pos = videoPlayerContainer1.CurrentPosition; + } + if (Math.Abs(pos - _lastPosition) > 0.01) + { + UiUtil.ShowSubtitle(_subtitle, videoPlayerContainer1); + timeUpDownLine.TimeCode = TimeCode.FromSeconds(pos); + _lastPosition = pos; + } + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void GetTime_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == Keys.S && e.Modifiers == Keys.Control) + { + videoPlayerContainer1.Pause(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.P && e.Control) + { + videoPlayerContainer1.VideoPlayer.Pause(); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Left) + { + GoBackSeconds(0.5, videoPlayerContainer1.VideoPlayer); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Right) + { + GoBackSeconds(-0.5, videoPlayerContainer1.VideoPlayer); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Left) + { + GoBackSeconds(0.1, videoPlayerContainer1.VideoPlayer); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Right) + { + GoBackSeconds(-0.1, videoPlayerContainer1.VideoPlayer); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#sync"); + e.SuppressKeyPress = true; + } + else if (_mainGeneralGoToNextSubtitle == e.KeyData || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)) + { + int selectedIndex = 0; + if (subtitleListView1.SelectedItems.Count > 0) + { + selectedIndex = subtitleListView1.SelectedItems[0].Index; + selectedIndex++; + } + subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex); + e.SuppressKeyPress = true; + } + else if (_mainGeneralGoToPrevSubtitle == e.KeyData || (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt)) + { + int selectedIndex = 0; + if (subtitleListView1.SelectedItems.Count > 0) + { + selectedIndex = subtitleListView1.SelectedItems[0].Index; + selectedIndex--; + } + subtitleListView1.SelectIndexAndEnsureVisible(selectedIndex); + e.SuppressKeyPress = true; + } + } + + private void GetTime_FormClosing(object sender, FormClosingEventArgs e) + { + timer1.Stop(); + videoPlayerContainer1?.Pause(); + } + + private void GetTime_FormClosed(object sender, FormClosedEventArgs e) + { + videoPlayerContainer1.VideoPlayer?.DisposeVideoPlayer(); + } + + private void GoBackSeconds(double seconds, VideoPlayer mediaPlayer) + { + if (mediaPlayer != null) + { + if (mediaPlayer.CurrentPosition > seconds) + { + mediaPlayer.CurrentPosition -= seconds; + } + else + { + mediaPlayer.CurrentPosition = 0; + } + + videoPlayerContainer1.RefreshProgressBar(); + } + } + + private void buttonStartHalfASecondBack_Click(object sender, EventArgs e) + { + GoBackSeconds(0.5, videoPlayerContainer1.VideoPlayer); + } + + private void buttonStartThreeSecondsBack_Click(object sender, EventArgs e) + { + GoBackSeconds(3, videoPlayerContainer1.VideoPlayer); + } + + private void buttonStartThreeSecondsAhead_Click(object sender, EventArgs e) + { + GoBackSeconds(-3.0, videoPlayerContainer1.VideoPlayer); + } + + private void buttonStartHalfASecondAhead_Click(object sender, EventArgs e) + { + GoBackSeconds(-0.5, videoPlayerContainer1.VideoPlayer); + } + + private void buttonStartVerify_Click(object sender, EventArgs e) + { + if (videoPlayerContainer1?.VideoPlayer != null) + { + _goBackPosition = videoPlayerContainer1.CurrentPosition; + _stopPosition = _goBackPosition + Configuration.Settings.Tools.VerifyPlaySeconds; + videoPlayerContainer1.Play(); + } + } + + private void GetTimeLoad(object sender, EventArgs e) + { + if (subtitleListView1.SelectedItems.Count == 1) + { + subtitleListView1.SelectIndexAndEnsureVisible(subtitleListView1.SelectedItems[0].Index); + } + } + + private void SubtitleListView1MouseDoubleClick(object sender, MouseEventArgs e) + { + if (subtitleListView1.SelectedItems.Count == 1) + { + int index = subtitleListView1.SelectedItems[0].Index; + + videoPlayerContainer1.Pause(); + videoPlayerContainer1.CurrentPosition = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds / TimeCode.BaseUnit; + } + } + + private void ButtonFindTextEndClick(object sender, EventArgs e) + { + using (var findSubtitle = new FindSubtitleLine()) + { + findSubtitle.Initialize(_subtitle.Paragraphs, string.Empty); + findSubtitle.ShowDialog(); + if (findSubtitle.SelectedIndex >= 0) + { + subtitleListView1.SelectIndexAndEnsureVisible(findSubtitle.SelectedIndex); + } + } + } + + private void timeUpDownLine_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + buttonOK_Click(sender, e); + } + } + } +} diff --git a/src/Forms/SetSyncPoint.resx b/src/ui/Forms/SetSyncPoint.resx similarity index 97% rename from src/Forms/SetSyncPoint.resx rename to src/ui/Forms/SetSyncPoint.resx index 98176d239..dea6a18d5 100644 --- a/src/Forms/SetSyncPoint.resx +++ b/src/ui/Forms/SetSyncPoint.resx @@ -1,126 +1,126 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 157, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 157, 17 + \ No newline at end of file diff --git a/src/Forms/SetVideoOffset.Designer.cs b/src/ui/Forms/SetVideoOffset.Designer.cs similarity index 98% rename from src/Forms/SetVideoOffset.Designer.cs rename to src/ui/Forms/SetVideoOffset.Designer.cs index e7f8a68ef..8bae16901 100644 --- a/src/Forms/SetVideoOffset.Designer.cs +++ b/src/ui/Forms/SetVideoOffset.Designer.cs @@ -1,165 +1,165 @@ -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class SetVideoOffset - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - TimeCode timeCode1 = new TimeCode(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.labelDescription = new System.Windows.Forms.Label(); - this.checkBoxFromCurrentPosition = new System.Windows.Forms.CheckBox(); - this.timeUpDownVideoPosition = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.buttonReset = new System.Windows.Forms.Button(); - this.checkBoxKeepTimeCodes = new System.Windows.Forms.CheckBox(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(386, 129); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(194, 129); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // labelDescription - // - this.labelDescription.AutoSize = true; - this.labelDescription.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.labelDescription.Location = new System.Drawing.Point(12, 22); - this.labelDescription.Name = "labelDescription"; - this.labelDescription.Size = new System.Drawing.Size(81, 13); - this.labelDescription.TabIndex = 0; - this.labelDescription.Text = "Set video offset"; - // - // checkBoxFromCurrentPosition - // - this.checkBoxFromCurrentPosition.AutoSize = true; - this.checkBoxFromCurrentPosition.Location = new System.Drawing.Point(15, 71); - this.checkBoxFromCurrentPosition.Name = "checkBoxFromCurrentPosition"; - this.checkBoxFromCurrentPosition.Size = new System.Drawing.Size(153, 17); - this.checkBoxFromCurrentPosition.TabIndex = 2; - this.checkBoxFromCurrentPosition.Text = "From current video position"; - this.checkBoxFromCurrentPosition.UseVisualStyleBackColor = true; - // - // timeUpDownVideoPosition - // - this.timeUpDownVideoPosition.AutoSize = true; - this.timeUpDownVideoPosition.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownVideoPosition.Font = new System.Drawing.Font("Segoe UI", 9F); - this.timeUpDownVideoPosition.Location = new System.Drawing.Point(13, 39); - this.timeUpDownVideoPosition.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownVideoPosition.Name = "timeUpDownVideoPosition"; - this.timeUpDownVideoPosition.Size = new System.Drawing.Size(96, 27); - this.timeUpDownVideoPosition.TabIndex = 1; - timeCode1.Hours = 0; - timeCode1.Milliseconds = 0; - timeCode1.Minutes = 0; - timeCode1.Seconds = 0; - timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode1.TotalMilliseconds = 0D; - timeCode1.TotalSeconds = 0D; - this.timeUpDownVideoPosition.TimeCode = timeCode1; - this.timeUpDownVideoPosition.UseVideoOffset = false; - // - // buttonReset - // - this.buttonReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonReset.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonReset.Location = new System.Drawing.Point(275, 129); - this.buttonReset.Name = "buttonReset"; - this.buttonReset.Size = new System.Drawing.Size(105, 23); - this.buttonReset.TabIndex = 4; - this.buttonReset.Text = "Reset"; - this.buttonReset.UseVisualStyleBackColor = true; - this.buttonReset.Click += new System.EventHandler(this.buttonReset_Click); - // - // checkBoxKeepTimeCodes - // - this.checkBoxKeepTimeCodes.AutoSize = true; - this.checkBoxKeepTimeCodes.Location = new System.Drawing.Point(15, 94); - this.checkBoxKeepTimeCodes.Name = "checkBoxKeepTimeCodes"; - this.checkBoxKeepTimeCodes.Size = new System.Drawing.Size(261, 17); - this.checkBoxKeepTimeCodes.TabIndex = 6; - this.checkBoxKeepTimeCodes.Text = "Keep existing time codes (do not add video offset)"; - this.checkBoxKeepTimeCodes.UseVisualStyleBackColor = true; - // - // SetVideoOffset - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(473, 162); - this.Controls.Add(this.checkBoxKeepTimeCodes); - this.Controls.Add(this.buttonReset); - this.Controls.Add(this.checkBoxFromCurrentPosition); - this.Controls.Add(this.timeUpDownVideoPosition); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.labelDescription); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "SetVideoOffset"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "SetVideoOffset"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SetVideoOffset_FormClosing); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Label labelDescription; - private Controls.TimeUpDown timeUpDownVideoPosition; - private System.Windows.Forms.CheckBox checkBoxFromCurrentPosition; - private System.Windows.Forms.Button buttonReset; - private System.Windows.Forms.CheckBox checkBoxKeepTimeCodes; - } +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class SetVideoOffset + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + TimeCode timeCode1 = new TimeCode(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.labelDescription = new System.Windows.Forms.Label(); + this.checkBoxFromCurrentPosition = new System.Windows.Forms.CheckBox(); + this.timeUpDownVideoPosition = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.buttonReset = new System.Windows.Forms.Button(); + this.checkBoxKeepTimeCodes = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(386, 129); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(194, 129); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // labelDescription + // + this.labelDescription.AutoSize = true; + this.labelDescription.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.labelDescription.Location = new System.Drawing.Point(12, 22); + this.labelDescription.Name = "labelDescription"; + this.labelDescription.Size = new System.Drawing.Size(81, 13); + this.labelDescription.TabIndex = 0; + this.labelDescription.Text = "Set video offset"; + // + // checkBoxFromCurrentPosition + // + this.checkBoxFromCurrentPosition.AutoSize = true; + this.checkBoxFromCurrentPosition.Location = new System.Drawing.Point(15, 71); + this.checkBoxFromCurrentPosition.Name = "checkBoxFromCurrentPosition"; + this.checkBoxFromCurrentPosition.Size = new System.Drawing.Size(153, 17); + this.checkBoxFromCurrentPosition.TabIndex = 2; + this.checkBoxFromCurrentPosition.Text = "From current video position"; + this.checkBoxFromCurrentPosition.UseVisualStyleBackColor = true; + // + // timeUpDownVideoPosition + // + this.timeUpDownVideoPosition.AutoSize = true; + this.timeUpDownVideoPosition.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownVideoPosition.Font = new System.Drawing.Font("Segoe UI", 9F); + this.timeUpDownVideoPosition.Location = new System.Drawing.Point(13, 39); + this.timeUpDownVideoPosition.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownVideoPosition.Name = "timeUpDownVideoPosition"; + this.timeUpDownVideoPosition.Size = new System.Drawing.Size(96, 27); + this.timeUpDownVideoPosition.TabIndex = 1; + timeCode1.Hours = 0; + timeCode1.Milliseconds = 0; + timeCode1.Minutes = 0; + timeCode1.Seconds = 0; + timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode1.TotalMilliseconds = 0D; + timeCode1.TotalSeconds = 0D; + this.timeUpDownVideoPosition.TimeCode = timeCode1; + this.timeUpDownVideoPosition.UseVideoOffset = false; + // + // buttonReset + // + this.buttonReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonReset.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonReset.Location = new System.Drawing.Point(275, 129); + this.buttonReset.Name = "buttonReset"; + this.buttonReset.Size = new System.Drawing.Size(105, 23); + this.buttonReset.TabIndex = 4; + this.buttonReset.Text = "Reset"; + this.buttonReset.UseVisualStyleBackColor = true; + this.buttonReset.Click += new System.EventHandler(this.buttonReset_Click); + // + // checkBoxKeepTimeCodes + // + this.checkBoxKeepTimeCodes.AutoSize = true; + this.checkBoxKeepTimeCodes.Location = new System.Drawing.Point(15, 94); + this.checkBoxKeepTimeCodes.Name = "checkBoxKeepTimeCodes"; + this.checkBoxKeepTimeCodes.Size = new System.Drawing.Size(261, 17); + this.checkBoxKeepTimeCodes.TabIndex = 6; + this.checkBoxKeepTimeCodes.Text = "Keep existing time codes (do not add video offset)"; + this.checkBoxKeepTimeCodes.UseVisualStyleBackColor = true; + // + // SetVideoOffset + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(473, 162); + this.Controls.Add(this.checkBoxKeepTimeCodes); + this.Controls.Add(this.buttonReset); + this.Controls.Add(this.checkBoxFromCurrentPosition); + this.Controls.Add(this.timeUpDownVideoPosition); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.labelDescription); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SetVideoOffset"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "SetVideoOffset"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SetVideoOffset_FormClosing); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Label labelDescription; + private Controls.TimeUpDown timeUpDownVideoPosition; + private System.Windows.Forms.CheckBox checkBoxFromCurrentPosition; + private System.Windows.Forms.Button buttonReset; + private System.Windows.Forms.CheckBox checkBoxKeepTimeCodes; + } } \ No newline at end of file diff --git a/src/Forms/SetVideoOffset.cs b/src/ui/Forms/SetVideoOffset.cs similarity index 97% rename from src/Forms/SetVideoOffset.cs rename to src/ui/Forms/SetVideoOffset.cs index 18d487de4..ec747adc6 100644 --- a/src/Forms/SetVideoOffset.cs +++ b/src/ui/Forms/SetVideoOffset.cs @@ -1,70 +1,70 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class SetVideoOffset : PositionAndSizeForm - { - public bool FromCurrentVideoPosition { get; set; } - public bool DoNotaddVideoOffsetToTimeCodes { get; set; } - public bool Reset { get; set; } - - private readonly TimeCode _videoOffset; - - public TimeCode VideoOffset - { - get => _videoOffset; - set - { - _videoOffset.TotalMilliseconds = value.TotalMilliseconds; - timeUpDownVideoPosition.SetTotalMilliseconds(value.TotalMilliseconds); - } - } - - public SetVideoOffset() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _videoOffset = new TimeCode(); - checkBoxKeepTimeCodes.Checked = Configuration.Settings.Tools.VideoOffsetKeepTimeCodes; - Text = Configuration.Settings.Language.SetVideoOffset.Title; - labelDescription.Text = Configuration.Settings.Language.SetVideoOffset.Description; - checkBoxFromCurrentPosition.Text = Configuration.Settings.Language.SetVideoOffset.RelativeToCurrentVideoPosition; - checkBoxKeepTimeCodes.Text = Configuration.Settings.Language.SetVideoOffset.KeepTimeCodes; - buttonReset.Text = Configuration.Settings.Language.SetVideoOffset.Reset; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - VideoOffset = timeUpDownVideoPosition.TimeCode; - FromCurrentVideoPosition = checkBoxFromCurrentPosition.Checked; - DoNotaddVideoOffsetToTimeCodes = checkBoxKeepTimeCodes.Checked; - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void buttonReset_Click(object sender, EventArgs e) - { - VideoOffset = new TimeCode(); - DoNotaddVideoOffsetToTimeCodes = checkBoxKeepTimeCodes.Checked; - Reset = true; - DialogResult = DialogResult.OK; - } - - private void SetVideoOffset_FormClosing(object sender, FormClosingEventArgs e) - { - Configuration.Settings.Tools.VideoOffsetKeepTimeCodes = checkBoxKeepTimeCodes.Checked; - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class SetVideoOffset : PositionAndSizeForm + { + public bool FromCurrentVideoPosition { get; set; } + public bool DoNotaddVideoOffsetToTimeCodes { get; set; } + public bool Reset { get; set; } + + private readonly TimeCode _videoOffset; + + public TimeCode VideoOffset + { + get => _videoOffset; + set + { + _videoOffset.TotalMilliseconds = value.TotalMilliseconds; + timeUpDownVideoPosition.SetTotalMilliseconds(value.TotalMilliseconds); + } + } + + public SetVideoOffset() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _videoOffset = new TimeCode(); + checkBoxKeepTimeCodes.Checked = Configuration.Settings.Tools.VideoOffsetKeepTimeCodes; + Text = Configuration.Settings.Language.SetVideoOffset.Title; + labelDescription.Text = Configuration.Settings.Language.SetVideoOffset.Description; + checkBoxFromCurrentPosition.Text = Configuration.Settings.Language.SetVideoOffset.RelativeToCurrentVideoPosition; + checkBoxKeepTimeCodes.Text = Configuration.Settings.Language.SetVideoOffset.KeepTimeCodes; + buttonReset.Text = Configuration.Settings.Language.SetVideoOffset.Reset; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + VideoOffset = timeUpDownVideoPosition.TimeCode; + FromCurrentVideoPosition = checkBoxFromCurrentPosition.Checked; + DoNotaddVideoOffsetToTimeCodes = checkBoxKeepTimeCodes.Checked; + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void buttonReset_Click(object sender, EventArgs e) + { + VideoOffset = new TimeCode(); + DoNotaddVideoOffsetToTimeCodes = checkBoxKeepTimeCodes.Checked; + Reset = true; + DialogResult = DialogResult.OK; + } + + private void SetVideoOffset_FormClosing(object sender, FormClosingEventArgs e) + { + Configuration.Settings.Tools.VideoOffsetKeepTimeCodes = checkBoxKeepTimeCodes.Checked; + } + } +} diff --git a/src/ui/Forms/SetVideoOffset.resx b/src/ui/Forms/SetVideoOffset.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/src/ui/Forms/SetVideoOffset.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Forms/Settings.Designer.cs b/src/ui/Forms/Settings.Designer.cs similarity index 98% rename from src/Forms/Settings.Designer.cs rename to src/ui/Forms/Settings.Designer.cs index 475355fe9..c6a76972d 100644 --- a/src/Forms/Settings.Designer.cs +++ b/src/ui/Forms/Settings.Designer.cs @@ -1,5283 +1,5283 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class Settings - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.tabControlSettings = new System.Windows.Forms.TabControl(); - this.tabPageGeneral = new System.Windows.Forms.TabPage(); - this.groupBoxMiscellaneous = new System.Windows.Forms.GroupBox(); - this.labelSplitBehavior = new System.Windows.Forms.Label(); - this.comboBoxSplitBehavior = new System.Windows.Forms.ComboBox(); - this.checkBoxAutoSave = new System.Windows.Forms.CheckBox(); - this.comboBoxSaveAsFileNameFrom = new System.Windows.Forms.ComboBox(); - this.labelSaveAsFileNameFrom = new System.Windows.Forms.Label(); - this.groupBoxGeneralRules = new System.Windows.Forms.GroupBox(); - this.buttonGapChoose = new System.Windows.Forms.Button(); - this.comboBoxContinuationStyle = new System.Windows.Forms.ComboBox(); - this.labelContinuationStyle = new System.Windows.Forms.Label(); - this.labelDialogStyle = new System.Windows.Forms.Label(); - this.comboBoxDialogStyle = new System.Windows.Forms.ComboBox(); - this.checkBoxCpsIncludeWhiteSpace = new System.Windows.Forms.CheckBox(); - this.buttonEditProfile = new System.Windows.Forms.Button(); - this.comboBoxRulesProfileName = new System.Windows.Forms.ComboBox(); - this.labelRulesProfileName = new System.Windows.Forms.Label(); - this.labelOptimalCharsPerSecond = new System.Windows.Forms.Label(); - this.numericUpDownOptimalCharsSec = new System.Windows.Forms.NumericUpDown(); - this.labelSubMaxLen = new System.Windows.Forms.Label(); - this.numericUpDownMaxWordsMin = new System.Windows.Forms.NumericUpDown(); - this.labelMergeShortLines = new System.Windows.Forms.Label(); - this.labelMaxWordsPerMin = new System.Windows.Forms.Label(); - this.labelMinDuration = new System.Windows.Forms.Label(); - this.numericUpDownMaxNumberOfLines = new System.Windows.Forms.NumericUpDown(); - this.labelMaxDuration = new System.Windows.Forms.Label(); - this.labelMaxLines = new System.Windows.Forms.Label(); - this.numericUpDownDurationMin = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownDurationMax = new System.Windows.Forms.NumericUpDown(); - this.comboBoxMergeShortLineLength = new System.Windows.Forms.ComboBox(); - this.labelMaxCharsPerSecond = new System.Windows.Forms.Label(); - this.numericUpDownMinGapMs = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownMaxCharsSec = new System.Windows.Forms.NumericUpDown(); - this.labelMinGapMs = new System.Windows.Forms.Label(); - this.numericUpDownSubtitleLineMaximumLength = new System.Windows.Forms.NumericUpDown(); - this.comboBoxAutoBackupDeleteAfter = new System.Windows.Forms.ComboBox(); - this.labelAutoBackupDeleteAfter = new System.Windows.Forms.Label(); - this.checkBoxCheckForUpdates = new System.Windows.Forms.CheckBox(); - this.labelSpellChecker = new System.Windows.Forms.Label(); - this.comboBoxTimeCodeMode = new System.Windows.Forms.ComboBox(); - this.labelTimeCodeMode = new System.Windows.Forms.Label(); - this.comboBoxEncoding = new System.Windows.Forms.ComboBox(); - this.checkBoxAutoDetectAnsiEncoding = new System.Windows.Forms.CheckBox(); - this.textBoxShowLineBreaksAs = new System.Windows.Forms.TextBox(); - this.checkBoxAutoWrapWhileTyping = new System.Windows.Forms.CheckBox(); - this.checkBoxPromptDeleteLines = new System.Windows.Forms.CheckBox(); - this.checkBoxAllowEditOfOriginalSubtitle = new System.Windows.Forms.CheckBox(); - this.comboBoxSpellChecker = new System.Windows.Forms.ComboBox(); - this.comboBoxAutoBackup = new System.Windows.Forms.ComboBox(); - this.labelAutoBackup = new System.Windows.Forms.Label(); - this.checkBoxRememberSelectedLine = new System.Windows.Forms.CheckBox(); - this.checkBoxRemoveBlankLinesWhenOpening = new System.Windows.Forms.CheckBox(); - this.labelAutoDetectAnsiEncoding = new System.Windows.Forms.Label(); - this.comboBoxListViewDoubleClickEvent = new System.Windows.Forms.ComboBox(); - this.labelListViewDoubleClickEvent = new System.Windows.Forms.Label(); - this.labelShowLineBreaksAs = new System.Windows.Forms.Label(); - this.checkBoxRememberWindowPosition = new System.Windows.Forms.CheckBox(); - this.checkBoxStartInSourceView = new System.Windows.Forms.CheckBox(); - this.checkBoxReopenLastOpened = new System.Windows.Forms.CheckBox(); - this.checkBoxRememberRecentFiles = new System.Windows.Forms.CheckBox(); - this.labelDefaultFileEncoding = new System.Windows.Forms.Label(); - this.comboBoxFrameRate = new System.Windows.Forms.ComboBox(); - this.labelDefaultFrameRate = new System.Windows.Forms.Label(); - this.tabPageShortcuts = new System.Windows.Forms.TabPage(); - this.groupBoxShortcuts = new System.Windows.Forms.GroupBox(); - this.buttonShortcutsClear = new System.Windows.Forms.Button(); - this.labelShortcutsSearch = new System.Windows.Forms.Label(); - this.textBoxShortcutSearch = new System.Windows.Forms.TextBox(); - this.buttonClearShortcut = new System.Windows.Forms.Button(); - this.comboBoxShortcutKey = new System.Windows.Forms.ComboBox(); - this.labelShortcutKey = new System.Windows.Forms.Label(); - this.checkBoxShortcutsShift = new System.Windows.Forms.CheckBox(); - this.checkBoxShortcutsAlt = new System.Windows.Forms.CheckBox(); - this.checkBoxShortcutsControl = new System.Windows.Forms.CheckBox(); - this.buttonUpdateShortcut = new System.Windows.Forms.Button(); - this.treeViewShortcuts = new System.Windows.Forms.TreeView(); - this.contextMenuStripShortcuts = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemShortcutsCollapse = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.importShortcutsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.exportShortcutsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.labelShortcut = new System.Windows.Forms.Label(); - this.tabPageSyntaxColoring = new System.Windows.Forms.TabPage(); - this.groupBoxListViewSyntaxColoring = new System.Windows.Forms.GroupBox(); - this.buttonLineWidthSettings = new System.Windows.Forms.Button(); - this.checkBoxSyntaxColorTextTooWide = new System.Windows.Forms.CheckBox(); - this.checkBoxSyntaxColorGapTooSmall = new System.Windows.Forms.CheckBox(); - this.checkBoxSyntaxColorTextMoreThanTwoLines = new System.Windows.Forms.CheckBox(); - this.checkBoxSyntaxOverlap = new System.Windows.Forms.CheckBox(); - this.checkBoxSyntaxColorDurationTooSmall = new System.Windows.Forms.CheckBox(); - this.buttonListViewSyntaxColorError = new System.Windows.Forms.Button(); - this.checkBoxSyntaxColorTextTooLong = new System.Windows.Forms.CheckBox(); - this.checkBoxSyntaxColorDurationTooLarge = new System.Windows.Forms.CheckBox(); - this.panelListViewSyntaxColorError = new System.Windows.Forms.Panel(); - this.tabPageVideoPlayer = new System.Windows.Forms.TabPage(); - this.groupBoxMainWindowVideoControls = new System.Windows.Forms.GroupBox(); - this.labelCustomSearch5 = new System.Windows.Forms.Label(); - this.textBoxCustomSearchUrl5 = new System.Windows.Forms.TextBox(); - this.comboBoxCustomSearch5 = new System.Windows.Forms.ComboBox(); - this.labelCustomSearch4 = new System.Windows.Forms.Label(); - this.textBoxCustomSearchUrl4 = new System.Windows.Forms.TextBox(); - this.comboBoxCustomSearch4 = new System.Windows.Forms.ComboBox(); - this.labelCustomSearch3 = new System.Windows.Forms.Label(); - this.textBoxCustomSearchUrl3 = new System.Windows.Forms.TextBox(); - this.comboBoxCustomSearch3 = new System.Windows.Forms.ComboBox(); - this.labelCustomSearch2 = new System.Windows.Forms.Label(); - this.textBoxCustomSearchUrl2 = new System.Windows.Forms.TextBox(); - this.comboBoxCustomSearch2 = new System.Windows.Forms.ComboBox(); - this.labelCustomSearch1 = new System.Windows.Forms.Label(); - this.textBoxCustomSearchUrl1 = new System.Windows.Forms.TextBox(); - this.labelCustomSearch = new System.Windows.Forms.Label(); - this.comboBoxCustomSearch1 = new System.Windows.Forms.ComboBox(); - this.groupBoxVideoPlayerDefault = new System.Windows.Forms.GroupBox(); - this.checkBoxAllowVolumeBoost = new System.Windows.Forms.CheckBox(); - this.checkBoxVideoAutoOpen = new System.Windows.Forms.CheckBox(); - this.checkBoxVideoPlayerPreviewFontBold = new System.Windows.Forms.CheckBox(); - this.checkBoxVideoPlayerShowFullscreenButton = new System.Windows.Forms.CheckBox(); - this.checkBoxVideoPlayerShowMuteButton = new System.Windows.Forms.CheckBox(); - this.labelVideoPlayerPreviewFontSize = new System.Windows.Forms.Label(); - this.comboBoxlVideoPlayerPreviewFontSize = new System.Windows.Forms.ComboBox(); - this.checkBoxVideoPlayerShowStopButton = new System.Windows.Forms.CheckBox(); - this.groupBoxVideoEngine = new System.Windows.Forms.GroupBox(); - this.checkBoxMpvHandlesPreviewText = new System.Windows.Forms.CheckBox(); - this.labelMpvSettings = new System.Windows.Forms.Label(); - this.buttonMpvSettings = new System.Windows.Forms.Button(); - this.labelPlatform = new System.Windows.Forms.Label(); - this.buttonVlcPathBrowse = new System.Windows.Forms.Button(); - this.textBoxVlcPath = new System.Windows.Forms.TextBox(); - this.labelVlcPath = new System.Windows.Forms.Label(); - this.labelVideoPlayerVLC = new System.Windows.Forms.Label(); - this.radioButtonVideoPlayerVLC = new System.Windows.Forms.RadioButton(); - this.labelVideoPlayerMPlayer = new System.Windows.Forms.Label(); - this.labelDirectShowDescription = new System.Windows.Forms.Label(); - this.labelMpcHcDescription = new System.Windows.Forms.Label(); - this.radioButtonVideoPlayerMPV = new System.Windows.Forms.RadioButton(); - this.radioButtonVideoPlayerDirectShow = new System.Windows.Forms.RadioButton(); - this.radioButtonVideoPlayerMpcHc = new System.Windows.Forms.RadioButton(); - this.tabPageWaveform = new System.Windows.Forms.TabPage(); - this.groupBoxFfmpeg = new System.Windows.Forms.GroupBox(); - this.buttonDownloadFfmpeg = new System.Windows.Forms.Button(); - this.buttonBrowseToFFmpeg = new System.Windows.Forms.Button(); - this.textBoxFFmpegPath = new System.Windows.Forms.TextBox(); - this.labelFFmpegPath = new System.Windows.Forms.Label(); - this.checkBoxUseFFmpeg = new System.Windows.Forms.CheckBox(); - this.groupBoxSpectrogram = new System.Windows.Forms.GroupBox(); - this.labelSpectrogramAppearance = new System.Windows.Forms.Label(); - this.comboBoxSpectrogramAppearance = new System.Windows.Forms.ComboBox(); - this.checkBoxGenerateSpectrogram = new System.Windows.Forms.CheckBox(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.buttonWaveformsFolderEmpty = new System.Windows.Forms.Button(); - this.labelWaveformsFolderInfo = new System.Windows.Forms.Label(); - this.groupBoxWaveformAppearence = new System.Windows.Forms.GroupBox(); - this.panelWaveformCursorColor = new System.Windows.Forms.Panel(); - this.buttonWaveformCursorColor = new System.Windows.Forms.Button(); - this.checkBoxWaveformSnapToSceneChanges = new System.Windows.Forms.CheckBox(); - this.checkBoxWaveformSingleClickSelect = new System.Windows.Forms.CheckBox(); - this.checkBoxWaveformShowWpm = new System.Windows.Forms.CheckBox(); - this.checkBoxWaveformShowCps = new System.Windows.Forms.CheckBox(); - this.checkBoxWaveformSetVideoPosMoveStartEnd = new System.Windows.Forms.CheckBox(); - this.labelWaveformTextSize = new System.Windows.Forms.Label(); - this.checkBoxWaveformTextBold = new System.Windows.Forms.CheckBox(); - this.comboBoxWaveformTextSize = new System.Windows.Forms.ComboBox(); - this.checkBoxListViewMouseEnterFocus = new System.Windows.Forms.CheckBox(); - this.checkBoxWaveformHoverFocus = new System.Windows.Forms.CheckBox(); - this.labelWaveformBorderHitMs2 = new System.Windows.Forms.Label(); - this.numericUpDownWaveformBorderHitMs = new System.Windows.Forms.NumericUpDown(); - this.labelWaveformBorderHitMs1 = new System.Windows.Forms.Label(); - this.checkBoxAllowOverlap = new System.Windows.Forms.CheckBox(); - this.checkBoxReverseMouseWheelScrollDirection = new System.Windows.Forms.CheckBox(); - this.panelWaveformTextColor = new System.Windows.Forms.Panel(); - this.buttonWaveformTextColor = new System.Windows.Forms.Button(); - this.panelWaveformGridColor = new System.Windows.Forms.Panel(); - this.buttonWaveformGridColor = new System.Windows.Forms.Button(); - this.panelWaveformBackgroundColor = new System.Windows.Forms.Panel(); - this.buttonWaveformBackgroundColor = new System.Windows.Forms.Button(); - this.panelWaveformColor = new System.Windows.Forms.Panel(); - this.buttonWaveformColor = new System.Windows.Forms.Button(); - this.panelWaveformSelectedColor = new System.Windows.Forms.Panel(); - this.buttonWaveformSelectedColor = new System.Windows.Forms.Button(); - this.checkBoxWaveformShowGrid = new System.Windows.Forms.CheckBox(); - this.tabPageTools = new System.Windows.Forms.TabPage(); - this.groupBoxGoogleTranslate = new System.Windows.Forms.GroupBox(); - this.labelGoogleTranslateApiKey = new System.Windows.Forms.Label(); - this.textBoxGoogleTransleApiKey = new System.Windows.Forms.TextBox(); - this.linkLabelGoogleTranslateSignUp = new System.Windows.Forms.LinkLabel(); - this.label3 = new System.Windows.Forms.Label(); - this.groupBoxBing = new System.Windows.Forms.GroupBox(); - this.comboBoxBoxBingTokenEndpoint = new System.Windows.Forms.ComboBox(); - this.labelBingTokenEndpoint = new System.Windows.Forms.Label(); - this.labelBingApiKey = new System.Windows.Forms.Label(); - this.textBoxBingClientSecret = new System.Windows.Forms.TextBox(); - this.linkLabelBingSubscribe = new System.Windows.Forms.LinkLabel(); - this.label1 = new System.Windows.Forms.Label(); - this.groupBoxToolsAutoBr = new System.Windows.Forms.GroupBox(); - this.labelToolsBreakBottomHeavyPercent = new System.Windows.Forms.Label(); - this.numericUpDownToolsBreakPreferBottomHeavy = new System.Windows.Forms.NumericUpDown(); - this.checkBoxToolsBreakPreferBottomHeavy = new System.Windows.Forms.CheckBox(); - this.checkBoxToolsBreakByPixelWidth = new System.Windows.Forms.CheckBox(); - this.checkBoxToolsBreakEarlyLineEnding = new System.Windows.Forms.CheckBox(); - this.checkBoxToolsBreakEarlyComma = new System.Windows.Forms.CheckBox(); - this.checkBoxToolsBreakEarlyDash = new System.Windows.Forms.CheckBox(); - this.labelUserBingApiId = new System.Windows.Forms.Label(); - this.buttonEditDoNotBreakAfterList = new System.Windows.Forms.Button(); - this.checkBoxUseDoNotBreakAfterList = new System.Windows.Forms.CheckBox(); - this.groupBoxSpellCheck = new System.Windows.Forms.GroupBox(); - this.checkBoxSpellCheckAutoChangeNamesViaSuggestions = new System.Windows.Forms.CheckBox(); - this.checkBoxUseAlwaysToFile = new System.Windows.Forms.CheckBox(); - this.checkBoxTreatINQuoteAsING = new System.Windows.Forms.CheckBox(); - this.checkBoxSpellCheckOneLetterWords = new System.Windows.Forms.CheckBox(); - this.checkBoxSpellCheckAutoChangeNames = new System.Windows.Forms.CheckBox(); - this.groupBoxFixCommonErrors = new System.Windows.Forms.GroupBox(); - this.buttonFixContinuationStyleSettings = new System.Windows.Forms.Button(); - this.checkBoxFceSkipStep1 = new System.Windows.Forms.CheckBox(); - this.checkBoxFixShortDisplayTimesAllowMoveStartTime = new System.Windows.Forms.CheckBox(); - this.checkBoxFixCommonOcrErrorsUsingHardcodedRules = new System.Windows.Forms.CheckBox(); - this.comboBoxToolsMusicSymbol = new System.Windows.Forms.ComboBox(); - this.textBoxMusicSymbolsToReplace = new System.Windows.Forms.TextBox(); - this.labelToolsMusicSymbolsToReplace = new System.Windows.Forms.Label(); - this.labelToolsMusicSymbol = new System.Windows.Forms.Label(); - this.groupBoxToolsVisualSync = new System.Windows.Forms.GroupBox(); - this.labelToolsEndScene = new System.Windows.Forms.Label(); - this.comboBoxToolsEndSceneIndex = new System.Windows.Forms.ComboBox(); - this.labelToolsStartScene = new System.Windows.Forms.Label(); - this.comboBoxToolsStartSceneIndex = new System.Windows.Forms.ComboBox(); - this.comboBoxToolsVerifySeconds = new System.Windows.Forms.ComboBox(); - this.labelVerifyButton = new System.Windows.Forms.Label(); - this.tabPageWordLists = new System.Windows.Forms.TabPage(); - this.groupBoxWordLists = new System.Windows.Forms.GroupBox(); - this.linkLabelOpenDictionaryFolder = new System.Windows.Forms.LinkLabel(); - this.groupBoxOcrFixList = new System.Windows.Forms.GroupBox(); - this.textBoxOcrFixValue = new System.Windows.Forms.TextBox(); - this.buttonRemoveOcrFix = new System.Windows.Forms.Button(); - this.listBoxOcrFixList = new System.Windows.Forms.ListBox(); - this.textBoxOcrFixKey = new System.Windows.Forms.TextBox(); - this.buttonAddOcrFix = new System.Windows.Forms.Button(); - this.groupBoxUserWordList = new System.Windows.Forms.GroupBox(); - this.buttonRemoveUserWord = new System.Windows.Forms.Button(); - this.listBoxUserWordLists = new System.Windows.Forms.ListBox(); - this.textBoxUserWord = new System.Windows.Forms.TextBox(); - this.buttonAddUserWord = new System.Windows.Forms.Button(); - this.groupBoxWordListLocation = new System.Windows.Forms.GroupBox(); - this.checkBoxNamesOnline = new System.Windows.Forms.CheckBox(); - this.textBoxNamesOnline = new System.Windows.Forms.TextBox(); - this.groupBoxNamesIgonoreLists = new System.Windows.Forms.GroupBox(); - this.buttonRemoveNameEtc = new System.Windows.Forms.Button(); - this.listBoxNames = new System.Windows.Forms.ListBox(); - this.textBoxNameEtc = new System.Windows.Forms.TextBox(); - this.buttonAddNames = new System.Windows.Forms.Button(); - this.labelWordListLanguage = new System.Windows.Forms.Label(); - this.comboBoxWordListLanguage = new System.Windows.Forms.ComboBox(); - this.tabPageToolBar = new System.Windows.Forms.TabPage(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.checkBoxShowFrameRate = new System.Windows.Forms.CheckBox(); - this.groupBoxShowToolBarButtons = new System.Windows.Forms.GroupBox(); - this.labelTBNetflixQualityCheck = new System.Windows.Forms.Label(); - this.pictureBoxNetflixQualityCheck = new System.Windows.Forms.PictureBox(); - this.checkBoxNetflixQualityCheck = new System.Windows.Forms.CheckBox(); - this.labelTBRemoveTextForHi = new System.Windows.Forms.Label(); - this.pictureBoxTBRemoveTextForHi = new System.Windows.Forms.PictureBox(); - this.checkBoxTBRemoveTextForHi = new System.Windows.Forms.CheckBox(); - this.labelTBFixCommonErrors = new System.Windows.Forms.Label(); - this.pictureBoxTBFixCommonErrors = new System.Windows.Forms.PictureBox(); - this.checkBoxTBFixCommonErrors = new System.Windows.Forms.CheckBox(); - this.labelTBHelp = new System.Windows.Forms.Label(); - this.pictureBoxHelp = new System.Windows.Forms.PictureBox(); - this.checkBoxHelp = new System.Windows.Forms.CheckBox(); - this.labelTBSettings = new System.Windows.Forms.Label(); - this.pictureBoxSettings = new System.Windows.Forms.PictureBox(); - this.checkBoxSettings = new System.Windows.Forms.CheckBox(); - this.labelTBSpellCheck = new System.Windows.Forms.Label(); - this.pictureBoxSpellCheck = new System.Windows.Forms.PictureBox(); - this.checkBoxSpellCheck = new System.Windows.Forms.CheckBox(); - this.labelTBVisualSync = new System.Windows.Forms.Label(); - this.pictureBoxVisualSync = new System.Windows.Forms.PictureBox(); - this.checkBoxVisualSync = new System.Windows.Forms.CheckBox(); - this.labelTBReplace = new System.Windows.Forms.Label(); - this.pictureBoxReplace = new System.Windows.Forms.PictureBox(); - this.checkBoxReplace = new System.Windows.Forms.CheckBox(); - this.labelTBFind = new System.Windows.Forms.Label(); - this.pictureBoxFind = new System.Windows.Forms.PictureBox(); - this.checkBoxToolbarFind = new System.Windows.Forms.CheckBox(); - this.labelTBSaveAs = new System.Windows.Forms.Label(); - this.pictureBoxSaveAs = new System.Windows.Forms.PictureBox(); - this.checkBoxToolbarSaveAs = new System.Windows.Forms.CheckBox(); - this.labelTBSave = new System.Windows.Forms.Label(); - this.pictureBoxSave = new System.Windows.Forms.PictureBox(); - this.checkBoxToolbarSave = new System.Windows.Forms.CheckBox(); - this.labelTBOpen = new System.Windows.Forms.Label(); - this.pictureBoxOpen = new System.Windows.Forms.PictureBox(); - this.checkBoxToolbarOpen = new System.Windows.Forms.CheckBox(); - this.labelTBNew = new System.Windows.Forms.Label(); - this.pictureBoxNew = new System.Windows.Forms.PictureBox(); - this.checkBoxToolbarNew = new System.Windows.Forms.CheckBox(); - this.tabPageFont = new System.Windows.Forms.TabPage(); - this.groupBoxFont = new System.Windows.Forms.GroupBox(); - this.labelFontNote = new System.Windows.Forms.Label(); - this.groupBoxFontTextBox = new System.Windows.Forms.GroupBox(); - this.panelTextBoxAssColor = new System.Windows.Forms.Panel(); - this.buttonTextBoxAssColor = new System.Windows.Forms.Button(); - this.panelTextBoxHtmlColor = new System.Windows.Forms.Panel(); - this.buttonTextBoxHtmlColor = new System.Windows.Forms.Button(); - this.checkBoxSubtitleTextBoxSyntaxColor = new System.Windows.Forms.CheckBox(); - this.labelSubtitleFontSize = new System.Windows.Forms.Label(); - this.comboBoxSubtitleFontSize = new System.Windows.Forms.ComboBox(); - this.checkBoxSubtitleFontBold = new System.Windows.Forms.CheckBox(); - this.checkBoxSubtitleCenter = new System.Windows.Forms.CheckBox(); - this.groupBoxFontListViews = new System.Windows.Forms.GroupBox(); - this.labelSubtitleListViewFontSize = new System.Windows.Forms.Label(); - this.comboBoxSubtitleListViewFontSize = new System.Windows.Forms.ComboBox(); - this.checkBoxSubtitleListViewFontBold = new System.Windows.Forms.CheckBox(); - this.groupBoxFontGeneral = new System.Windows.Forms.GroupBox(); - this.comboBoxSubtitleFont = new System.Windows.Forms.ComboBox(); - this.labelSubtitleFont = new System.Windows.Forms.Label(); - this.panelSubtitleFontColor = new System.Windows.Forms.Panel(); - this.labelSubtitleFontColor = new System.Windows.Forms.Label(); - this.panelSubtitleBackgroundColor = new System.Windows.Forms.Panel(); - this.labelSubtitleFontBackgroundColor = new System.Windows.Forms.Label(); - this.tabPageSsaStyle = new System.Windows.Forms.TabPage(); - this.groupBoxSsaStyle = new System.Windows.Forms.GroupBox(); - this.groupBoxSsaBorder = new System.Windows.Forms.GroupBox(); - this.numericUpDownSsaOutline = new System.Windows.Forms.NumericUpDown(); - this.labelSsaShadow = new System.Windows.Forms.Label(); - this.numericUpDownSsaShadow = new System.Windows.Forms.NumericUpDown(); - this.checkBoxSsaOpaqueBox = new System.Windows.Forms.CheckBox(); - this.labelSsaOutline = new System.Windows.Forms.Label(); - this.groupSsaBoxFont = new System.Windows.Forms.GroupBox(); - this.checkBoxSsaFontBold = new System.Windows.Forms.CheckBox(); - this.buttonSsaColor = new System.Windows.Forms.Button(); - this.panelPrimaryColor = new System.Windows.Forms.Panel(); - this.numericUpDownFontSize = new System.Windows.Forms.NumericUpDown(); - this.comboBoxFontName = new System.Windows.Forms.ComboBox(); - this.labelSsaFontSize = new System.Windows.Forms.Label(); - this.labelFontName = new System.Windows.Forms.Label(); - this.groupBoxMargins = new System.Windows.Forms.GroupBox(); - this.numericUpDownSsaMarginVertical = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownSsaMarginRight = new System.Windows.Forms.NumericUpDown(); - this.numericUpDownSsaMarginLeft = new System.Windows.Forms.NumericUpDown(); - this.labelMarginVertical = new System.Windows.Forms.Label(); - this.labelMarginRight = new System.Windows.Forms.Label(); - this.labelMarginLeft = new System.Windows.Forms.Label(); - this.groupBoxPreview = new System.Windows.Forms.GroupBox(); - this.pictureBoxPreview = new System.Windows.Forms.PictureBox(); - this.tabPageNetwork = new System.Windows.Forms.TabPage(); - this.groupBoxNetworkSession = new System.Windows.Forms.GroupBox(); - this.buttonNetworkSessionNewMessageSound = new System.Windows.Forms.Button(); - this.textBoxNetworkSessionNewMessageSound = new System.Windows.Forms.TextBox(); - this.labelNetworkSessionNewMessageSound = new System.Windows.Forms.Label(); - this.groupBoxProxySettings = new System.Windows.Forms.GroupBox(); - this.groupBoxProxyAuthentication = new System.Windows.Forms.GroupBox(); - this.textBoxProxyDomain = new System.Windows.Forms.TextBox(); - this.labelProxyDomain = new System.Windows.Forms.Label(); - this.textBoxProxyUserName = new System.Windows.Forms.TextBox(); - this.labelProxyPassword = new System.Windows.Forms.Label(); - this.labelProxyUserName = new System.Windows.Forms.Label(); - this.textBoxProxyPassword = new System.Windows.Forms.TextBox(); - this.textBoxProxyAddress = new System.Windows.Forms.TextBox(); - this.labelProxyAddress = new System.Windows.Forms.Label(); - this.colorDialogSSAStyle = new System.Windows.Forms.ColorDialog(); - this.labelStatus = new System.Windows.Forms.Label(); - this.openFileDialogFFmpeg = new System.Windows.Forms.OpenFileDialog(); - this.buttonReset = new System.Windows.Forms.Button(); - this.toolTipContinuationPreview = new System.Windows.Forms.ToolTip(this.components); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.tabControlSettings.SuspendLayout(); - this.tabPageGeneral.SuspendLayout(); - this.groupBoxMiscellaneous.SuspendLayout(); - this.groupBoxGeneralRules.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxWordsMin)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxNumberOfLines)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMin)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMax)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinGapMs)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharsSec)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSubtitleLineMaximumLength)).BeginInit(); - this.tabPageShortcuts.SuspendLayout(); - this.groupBoxShortcuts.SuspendLayout(); - this.contextMenuStripShortcuts.SuspendLayout(); - this.tabPageSyntaxColoring.SuspendLayout(); - this.groupBoxListViewSyntaxColoring.SuspendLayout(); - this.tabPageVideoPlayer.SuspendLayout(); - this.groupBoxMainWindowVideoControls.SuspendLayout(); - this.groupBoxVideoPlayerDefault.SuspendLayout(); - this.groupBoxVideoEngine.SuspendLayout(); - this.tabPageWaveform.SuspendLayout(); - this.groupBoxFfmpeg.SuspendLayout(); - this.groupBoxSpectrogram.SuspendLayout(); - this.groupBox1.SuspendLayout(); - this.groupBoxWaveformAppearence.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWaveformBorderHitMs)).BeginInit(); - this.tabPageTools.SuspendLayout(); - this.groupBoxGoogleTranslate.SuspendLayout(); - this.groupBoxBing.SuspendLayout(); - this.groupBoxToolsAutoBr.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownToolsBreakPreferBottomHeavy)).BeginInit(); - this.groupBoxSpellCheck.SuspendLayout(); - this.groupBoxFixCommonErrors.SuspendLayout(); - this.groupBoxToolsVisualSync.SuspendLayout(); - this.tabPageWordLists.SuspendLayout(); - this.groupBoxWordLists.SuspendLayout(); - this.groupBoxOcrFixList.SuspendLayout(); - this.groupBoxUserWordList.SuspendLayout(); - this.groupBoxWordListLocation.SuspendLayout(); - this.groupBoxNamesIgonoreLists.SuspendLayout(); - this.tabPageToolBar.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.groupBoxShowToolBarButtons.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxNetflixQualityCheck)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBRemoveTextForHi)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBFixCommonErrors)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHelp)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSettings)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSpellCheck)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxVisualSync)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxReplace)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxFind)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSaveAs)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSave)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxOpen)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxNew)).BeginInit(); - this.tabPageFont.SuspendLayout(); - this.groupBoxFont.SuspendLayout(); - this.groupBoxFontTextBox.SuspendLayout(); - this.groupBoxFontListViews.SuspendLayout(); - this.groupBoxFontGeneral.SuspendLayout(); - this.tabPageSsaStyle.SuspendLayout(); - this.groupBoxSsaStyle.SuspendLayout(); - this.groupBoxSsaBorder.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaOutline)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaShadow)).BeginInit(); - this.groupSsaBoxFont.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSize)).BeginInit(); - this.groupBoxMargins.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaMarginVertical)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaMarginRight)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaMarginLeft)).BeginInit(); - this.groupBoxPreview.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).BeginInit(); - this.tabPageNetwork.SuspendLayout(); - this.groupBoxNetworkSession.SuspendLayout(); - this.groupBoxProxySettings.SuspendLayout(); - this.groupBoxProxyAuthentication.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.Location = new System.Drawing.Point(506, 563); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 0; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(587, 563); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 1; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // tabControlSettings - // - this.tabControlSettings.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tabControlSettings.Controls.Add(this.tabPageGeneral); - this.tabControlSettings.Controls.Add(this.tabPageShortcuts); - this.tabControlSettings.Controls.Add(this.tabPageSyntaxColoring); - this.tabControlSettings.Controls.Add(this.tabPageVideoPlayer); - this.tabControlSettings.Controls.Add(this.tabPageWaveform); - this.tabControlSettings.Controls.Add(this.tabPageTools); - this.tabControlSettings.Controls.Add(this.tabPageWordLists); - this.tabControlSettings.Controls.Add(this.tabPageToolBar); - this.tabControlSettings.Controls.Add(this.tabPageFont); - this.tabControlSettings.Controls.Add(this.tabPageSsaStyle); - this.tabControlSettings.Controls.Add(this.tabPageNetwork); - this.tabControlSettings.Location = new System.Drawing.Point(13, 13); - this.tabControlSettings.Name = "tabControlSettings"; - this.tabControlSettings.SelectedIndex = 0; - this.tabControlSettings.Size = new System.Drawing.Size(840, 546); - this.tabControlSettings.TabIndex = 2; - this.tabControlSettings.SelectedIndexChanged += new System.EventHandler(this.TabControlSettingsSelectedIndexChanged); - // - // tabPageGeneral - // - this.tabPageGeneral.Controls.Add(this.groupBoxMiscellaneous); - this.tabPageGeneral.Location = new System.Drawing.Point(4, 22); - this.tabPageGeneral.Name = "tabPageGeneral"; - this.tabPageGeneral.Padding = new System.Windows.Forms.Padding(3); - this.tabPageGeneral.Size = new System.Drawing.Size(832, 520); - this.tabPageGeneral.TabIndex = 0; - this.tabPageGeneral.Text = "General"; - this.tabPageGeneral.UseVisualStyleBackColor = true; - // - // groupBoxMiscellaneous - // - this.groupBoxMiscellaneous.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxMiscellaneous.Controls.Add(this.labelSplitBehavior); - this.groupBoxMiscellaneous.Controls.Add(this.comboBoxSplitBehavior); - this.groupBoxMiscellaneous.Controls.Add(this.checkBoxAutoSave); - this.groupBoxMiscellaneous.Controls.Add(this.comboBoxSaveAsFileNameFrom); - this.groupBoxMiscellaneous.Controls.Add(this.labelSaveAsFileNameFrom); - this.groupBoxMiscellaneous.Controls.Add(this.groupBoxGeneralRules); - this.groupBoxMiscellaneous.Controls.Add(this.comboBoxAutoBackupDeleteAfter); - this.groupBoxMiscellaneous.Controls.Add(this.labelAutoBackupDeleteAfter); - this.groupBoxMiscellaneous.Controls.Add(this.checkBoxCheckForUpdates); - this.groupBoxMiscellaneous.Controls.Add(this.labelSpellChecker); - this.groupBoxMiscellaneous.Controls.Add(this.comboBoxTimeCodeMode); - this.groupBoxMiscellaneous.Controls.Add(this.labelTimeCodeMode); - this.groupBoxMiscellaneous.Controls.Add(this.comboBoxEncoding); - this.groupBoxMiscellaneous.Controls.Add(this.checkBoxAutoDetectAnsiEncoding); - this.groupBoxMiscellaneous.Controls.Add(this.textBoxShowLineBreaksAs); - this.groupBoxMiscellaneous.Controls.Add(this.checkBoxAutoWrapWhileTyping); - this.groupBoxMiscellaneous.Controls.Add(this.checkBoxPromptDeleteLines); - this.groupBoxMiscellaneous.Controls.Add(this.checkBoxAllowEditOfOriginalSubtitle); - this.groupBoxMiscellaneous.Controls.Add(this.comboBoxSpellChecker); - this.groupBoxMiscellaneous.Controls.Add(this.comboBoxAutoBackup); - this.groupBoxMiscellaneous.Controls.Add(this.labelAutoBackup); - this.groupBoxMiscellaneous.Controls.Add(this.checkBoxRememberSelectedLine); - this.groupBoxMiscellaneous.Controls.Add(this.checkBoxRemoveBlankLinesWhenOpening); - this.groupBoxMiscellaneous.Controls.Add(this.labelAutoDetectAnsiEncoding); - this.groupBoxMiscellaneous.Controls.Add(this.comboBoxListViewDoubleClickEvent); - this.groupBoxMiscellaneous.Controls.Add(this.labelListViewDoubleClickEvent); - this.groupBoxMiscellaneous.Controls.Add(this.labelShowLineBreaksAs); - this.groupBoxMiscellaneous.Controls.Add(this.checkBoxRememberWindowPosition); - this.groupBoxMiscellaneous.Controls.Add(this.checkBoxStartInSourceView); - this.groupBoxMiscellaneous.Controls.Add(this.checkBoxReopenLastOpened); - this.groupBoxMiscellaneous.Controls.Add(this.checkBoxRememberRecentFiles); - this.groupBoxMiscellaneous.Controls.Add(this.labelDefaultFileEncoding); - this.groupBoxMiscellaneous.Controls.Add(this.comboBoxFrameRate); - this.groupBoxMiscellaneous.Controls.Add(this.labelDefaultFrameRate); - this.groupBoxMiscellaneous.Location = new System.Drawing.Point(6, 6); - this.groupBoxMiscellaneous.Name = "groupBoxMiscellaneous"; - this.groupBoxMiscellaneous.Size = new System.Drawing.Size(819, 508); - this.groupBoxMiscellaneous.TabIndex = 0; - this.groupBoxMiscellaneous.TabStop = false; - this.groupBoxMiscellaneous.Text = "Miscellaneous"; - // - // labelSplitBehavior - // - this.labelSplitBehavior.AutoSize = true; - this.labelSplitBehavior.Location = new System.Drawing.Point(438, 291); - this.labelSplitBehavior.Name = "labelSplitBehavior"; - this.labelSplitBehavior.Size = new System.Drawing.Size(72, 13); - this.labelSplitBehavior.TabIndex = 20; - this.labelSplitBehavior.Text = "Split behavior"; - // - // comboBoxSplitBehavior - // - this.comboBoxSplitBehavior.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSplitBehavior.FormattingEnabled = true; - this.comboBoxSplitBehavior.Location = new System.Drawing.Point(528, 288); - this.comboBoxSplitBehavior.Name = "comboBoxSplitBehavior"; - this.comboBoxSplitBehavior.Size = new System.Drawing.Size(207, 21); - this.comboBoxSplitBehavior.TabIndex = 21; - // - // checkBoxAutoSave - // - this.checkBoxAutoSave.AutoSize = true; - this.checkBoxAutoSave.Location = new System.Drawing.Point(441, 453); - this.checkBoxAutoSave.Name = "checkBoxAutoSave"; - this.checkBoxAutoSave.Size = new System.Drawing.Size(75, 17); - this.checkBoxAutoSave.TabIndex = 30; - this.checkBoxAutoSave.Text = "Auto save"; - this.checkBoxAutoSave.UseVisualStyleBackColor = true; - // - // comboBoxSaveAsFileNameFrom - // - this.comboBoxSaveAsFileNameFrom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSaveAsFileNameFrom.FormattingEnabled = true; - this.comboBoxSaveAsFileNameFrom.Location = new System.Drawing.Point(441, 386); - this.comboBoxSaveAsFileNameFrom.Name = "comboBoxSaveAsFileNameFrom"; - this.comboBoxSaveAsFileNameFrom.Size = new System.Drawing.Size(332, 21); - this.comboBoxSaveAsFileNameFrom.TabIndex = 25; - // - // labelSaveAsFileNameFrom - // - this.labelSaveAsFileNameFrom.AutoSize = true; - this.labelSaveAsFileNameFrom.Location = new System.Drawing.Point(438, 370); - this.labelSaveAsFileNameFrom.Name = "labelSaveAsFileNameFrom"; - this.labelSaveAsFileNameFrom.Size = new System.Drawing.Size(160, 13); - this.labelSaveAsFileNameFrom.TabIndex = 24; - this.labelSaveAsFileNameFrom.Text = "\"Save as...\" will take name from"; - // - // groupBoxGeneralRules - // - this.groupBoxGeneralRules.Controls.Add(this.buttonGapChoose); - this.groupBoxGeneralRules.Controls.Add(this.comboBoxContinuationStyle); - this.groupBoxGeneralRules.Controls.Add(this.labelContinuationStyle); - this.groupBoxGeneralRules.Controls.Add(this.labelDialogStyle); - this.groupBoxGeneralRules.Controls.Add(this.comboBoxDialogStyle); - this.groupBoxGeneralRules.Controls.Add(this.checkBoxCpsIncludeWhiteSpace); - this.groupBoxGeneralRules.Controls.Add(this.buttonEditProfile); - this.groupBoxGeneralRules.Controls.Add(this.comboBoxRulesProfileName); - this.groupBoxGeneralRules.Controls.Add(this.labelRulesProfileName); - this.groupBoxGeneralRules.Controls.Add(this.labelOptimalCharsPerSecond); - this.groupBoxGeneralRules.Controls.Add(this.numericUpDownOptimalCharsSec); - this.groupBoxGeneralRules.Controls.Add(this.labelSubMaxLen); - this.groupBoxGeneralRules.Controls.Add(this.numericUpDownMaxWordsMin); - this.groupBoxGeneralRules.Controls.Add(this.labelMergeShortLines); - this.groupBoxGeneralRules.Controls.Add(this.labelMaxWordsPerMin); - this.groupBoxGeneralRules.Controls.Add(this.labelMinDuration); - this.groupBoxGeneralRules.Controls.Add(this.numericUpDownMaxNumberOfLines); - this.groupBoxGeneralRules.Controls.Add(this.labelMaxDuration); - this.groupBoxGeneralRules.Controls.Add(this.labelMaxLines); - this.groupBoxGeneralRules.Controls.Add(this.numericUpDownDurationMin); - this.groupBoxGeneralRules.Controls.Add(this.numericUpDownDurationMax); - this.groupBoxGeneralRules.Controls.Add(this.comboBoxMergeShortLineLength); - this.groupBoxGeneralRules.Controls.Add(this.labelMaxCharsPerSecond); - this.groupBoxGeneralRules.Controls.Add(this.numericUpDownMinGapMs); - this.groupBoxGeneralRules.Controls.Add(this.numericUpDownMaxCharsSec); - this.groupBoxGeneralRules.Controls.Add(this.labelMinGapMs); - this.groupBoxGeneralRules.Controls.Add(this.numericUpDownSubtitleLineMaximumLength); - this.groupBoxGeneralRules.Location = new System.Drawing.Point(6, 23); - this.groupBoxGeneralRules.Name = "groupBoxGeneralRules"; - this.groupBoxGeneralRules.Size = new System.Drawing.Size(387, 381); - this.groupBoxGeneralRules.TabIndex = 0; - this.groupBoxGeneralRules.TabStop = false; - this.groupBoxGeneralRules.Text = "Rules"; - // - // buttonGapChoose - // - this.buttonGapChoose.Location = new System.Drawing.Point(265, 213); - this.buttonGapChoose.Name = "buttonGapChoose"; - this.buttonGapChoose.Size = new System.Drawing.Size(28, 23); - this.buttonGapChoose.TabIndex = 46; - this.buttonGapChoose.Text = "..."; - this.buttonGapChoose.UseVisualStyleBackColor = true; - this.buttonGapChoose.Click += new System.EventHandler(this.buttonGapChoose_Click); - // - // comboBoxContinuationStyle - // - this.comboBoxContinuationStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxContinuationStyle.DropDownWidth = 170; - this.comboBoxContinuationStyle.FormattingEnabled = true; - this.comboBoxContinuationStyle.Location = new System.Drawing.Point(203, 324); - this.comboBoxContinuationStyle.Name = "comboBoxContinuationStyle"; - this.comboBoxContinuationStyle.Size = new System.Drawing.Size(170, 21); - this.comboBoxContinuationStyle.TabIndex = 58; - this.comboBoxContinuationStyle.SelectedIndexChanged += new System.EventHandler(this.ProfileUiValueChanged); - // - // labelContinuationStyle - // - this.labelContinuationStyle.AutoSize = true; - this.labelContinuationStyle.Location = new System.Drawing.Point(6, 327); - this.labelContinuationStyle.Name = "labelContinuationStyle"; - this.labelContinuationStyle.Size = new System.Drawing.Size(140, 13); - this.labelContinuationStyle.TabIndex = 63; - this.labelContinuationStyle.Text = "Sentence continuation style"; - // - // labelDialogStyle - // - this.labelDialogStyle.AutoSize = true; - this.labelDialogStyle.Location = new System.Drawing.Point(6, 300); - this.labelDialogStyle.Name = "labelDialogStyle"; - this.labelDialogStyle.Size = new System.Drawing.Size(62, 13); - this.labelDialogStyle.TabIndex = 61; - this.labelDialogStyle.Text = "Dialog style"; - // - // comboBoxDialogStyle - // - this.comboBoxDialogStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxDialogStyle.FormattingEnabled = true; - this.comboBoxDialogStyle.Items.AddRange(new object[] { - "Dash both lines with space", - "Dash both lines without space", - "Dash second line with space", - "Dash second line without space"}); - this.comboBoxDialogStyle.Location = new System.Drawing.Point(203, 297); - this.comboBoxDialogStyle.Name = "comboBoxDialogStyle"; - this.comboBoxDialogStyle.Size = new System.Drawing.Size(170, 21); - this.comboBoxDialogStyle.TabIndex = 57; - this.comboBoxDialogStyle.SelectedIndexChanged += new System.EventHandler(this.ProfileUiValueChanged); - // - // checkBoxCpsIncludeWhiteSpace - // - this.checkBoxCpsIncludeWhiteSpace.AutoSize = true; - this.checkBoxCpsIncludeWhiteSpace.Location = new System.Drawing.Point(9, 354); - this.checkBoxCpsIncludeWhiteSpace.Name = "checkBoxCpsIncludeWhiteSpace"; - this.checkBoxCpsIncludeWhiteSpace.Size = new System.Drawing.Size(271, 17); - this.checkBoxCpsIncludeWhiteSpace.TabIndex = 65; - this.checkBoxCpsIncludeWhiteSpace.Text = "Characters per second (CPS) includes white spaces"; - this.checkBoxCpsIncludeWhiteSpace.UseVisualStyleBackColor = true; - this.checkBoxCpsIncludeWhiteSpace.CheckedChanged += new System.EventHandler(this.ProfileUiValueChanged); - // - // buttonEditProfile - // - this.buttonEditProfile.Location = new System.Drawing.Point(322, 19); - this.buttonEditProfile.Name = "buttonEditProfile"; - this.buttonEditProfile.Size = new System.Drawing.Size(28, 23); - this.buttonEditProfile.TabIndex = 10; - this.buttonEditProfile.Text = "..."; - this.buttonEditProfile.UseVisualStyleBackColor = true; - this.buttonEditProfile.Click += new System.EventHandler(this.buttonEditProfile_Click); - // - // comboBoxRulesProfileName - // - this.comboBoxRulesProfileName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxRulesProfileName.FormattingEnabled = true; - this.comboBoxRulesProfileName.Location = new System.Drawing.Point(78, 20); - this.comboBoxRulesProfileName.Name = "comboBoxRulesProfileName"; - this.comboBoxRulesProfileName.Size = new System.Drawing.Size(238, 21); - this.comboBoxRulesProfileName.TabIndex = 5; - this.comboBoxRulesProfileName.SelectedIndexChanged += new System.EventHandler(this.comboBoxRulesProfileName_SelectedIndexChanged); - // - // labelRulesProfileName - // - this.labelRulesProfileName.AutoSize = true; - this.labelRulesProfileName.Location = new System.Drawing.Point(6, 24); - this.labelRulesProfileName.Name = "labelRulesProfileName"; - this.labelRulesProfileName.Size = new System.Drawing.Size(37, 13); - this.labelRulesProfileName.TabIndex = 50; - this.labelRulesProfileName.Text = "Profile"; - // - // labelOptimalCharsPerSecond - // - this.labelOptimalCharsPerSecond.AutoSize = true; - this.labelOptimalCharsPerSecond.Location = new System.Drawing.Point(6, 84); - this.labelOptimalCharsPerSecond.Name = "labelOptimalCharsPerSecond"; - this.labelOptimalCharsPerSecond.Size = new System.Drawing.Size(92, 13); - this.labelOptimalCharsPerSecond.TabIndex = 8; - this.labelOptimalCharsPerSecond.Text = "Optimal chars/sec"; - // - // numericUpDownOptimalCharsSec - // - this.numericUpDownOptimalCharsSec.DecimalPlaces = 1; - this.numericUpDownOptimalCharsSec.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownOptimalCharsSec.Location = new System.Drawing.Point(203, 82); - this.numericUpDownOptimalCharsSec.Minimum = new decimal(new int[] { - 4, - 0, - 0, - 0}); - this.numericUpDownOptimalCharsSec.Name = "numericUpDownOptimalCharsSec"; - this.numericUpDownOptimalCharsSec.Size = new System.Drawing.Size(56, 21); - this.numericUpDownOptimalCharsSec.TabIndex = 20; - this.numericUpDownOptimalCharsSec.Value = new decimal(new int[] { - 11, - 0, - 0, - 0}); - this.numericUpDownOptimalCharsSec.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); - // - // labelSubMaxLen - // - this.labelSubMaxLen.AutoSize = true; - this.labelSubMaxLen.Location = new System.Drawing.Point(6, 57); - this.labelSubMaxLen.Name = "labelSubMaxLen"; - this.labelSubMaxLen.Size = new System.Drawing.Size(103, 13); - this.labelSubMaxLen.TabIndex = 6; - this.labelSubMaxLen.Text = "Subtitle max. length"; - // - // numericUpDownMaxWordsMin - // - this.numericUpDownMaxWordsMin.Location = new System.Drawing.Point(203, 136); - this.numericUpDownMaxWordsMin.Maximum = new decimal(new int[] { - 1000, - 0, - 0, - 0}); - this.numericUpDownMaxWordsMin.Minimum = new decimal(new int[] { - 4, - 0, - 0, - 0}); - this.numericUpDownMaxWordsMin.Name = "numericUpDownMaxWordsMin"; - this.numericUpDownMaxWordsMin.Size = new System.Drawing.Size(56, 21); - this.numericUpDownMaxWordsMin.TabIndex = 30; - this.numericUpDownMaxWordsMin.Value = new decimal(new int[] { - 300, - 0, - 0, - 0}); - this.numericUpDownMaxWordsMin.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); - // - // labelMergeShortLines - // - this.labelMergeShortLines.AutoSize = true; - this.labelMergeShortLines.Location = new System.Drawing.Point(6, 273); - this.labelMergeShortLines.Name = "labelMergeShortLines"; - this.labelMergeShortLines.Size = new System.Drawing.Size(124, 13); - this.labelMergeShortLines.TabIndex = 16; - this.labelMergeShortLines.Text = "Merge lines shorter than"; - // - // labelMaxWordsPerMin - // - this.labelMaxWordsPerMin.AutoSize = true; - this.labelMaxWordsPerMin.Location = new System.Drawing.Point(6, 138); - this.labelMaxWordsPerMin.Name = "labelMaxWordsPerMin"; - this.labelMaxWordsPerMin.Size = new System.Drawing.Size(83, 13); - this.labelMaxWordsPerMin.TabIndex = 49; - this.labelMaxWordsPerMin.Text = "Max. words/min"; - // - // labelMinDuration - // - this.labelMinDuration.AutoSize = true; - this.labelMinDuration.Location = new System.Drawing.Point(6, 165); - this.labelMinDuration.Name = "labelMinDuration"; - this.labelMinDuration.Size = new System.Drawing.Size(132, 13); - this.labelMinDuration.TabIndex = 10; - this.labelMinDuration.Text = "Min. duration, milliseconds"; - // - // numericUpDownMaxNumberOfLines - // - this.numericUpDownMaxNumberOfLines.Location = new System.Drawing.Point(203, 242); - this.numericUpDownMaxNumberOfLines.Maximum = new decimal(new int[] { - 25, - 0, - 0, - 0}); - this.numericUpDownMaxNumberOfLines.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.numericUpDownMaxNumberOfLines.Name = "numericUpDownMaxNumberOfLines"; - this.numericUpDownMaxNumberOfLines.Size = new System.Drawing.Size(56, 21); - this.numericUpDownMaxNumberOfLines.TabIndex = 50; - this.numericUpDownMaxNumberOfLines.Value = new decimal(new int[] { - 2, - 0, - 0, - 0}); - this.numericUpDownMaxNumberOfLines.ValueChanged += new System.EventHandler(this.numericUpDownMaxNumberOfLines_ValueChanged); - // - // labelMaxDuration - // - this.labelMaxDuration.AutoSize = true; - this.labelMaxDuration.Location = new System.Drawing.Point(6, 191); - this.labelMaxDuration.Name = "labelMaxDuration"; - this.labelMaxDuration.Size = new System.Drawing.Size(136, 13); - this.labelMaxDuration.TabIndex = 12; - this.labelMaxDuration.Text = "Max. duration, milliseconds"; - // - // labelMaxLines - // - this.labelMaxLines.AutoSize = true; - this.labelMaxLines.Location = new System.Drawing.Point(6, 244); - this.labelMaxLines.Name = "labelMaxLines"; - this.labelMaxLines.Size = new System.Drawing.Size(107, 13); - this.labelMaxLines.TabIndex = 47; - this.labelMaxLines.Text = "Max. number of lines"; - // - // numericUpDownDurationMin - // - this.numericUpDownDurationMin.Location = new System.Drawing.Point(203, 163); - this.numericUpDownDurationMin.Maximum = new decimal(new int[] { - 3000, - 0, - 0, - 0}); - this.numericUpDownDurationMin.Minimum = new decimal(new int[] { - 100, - 0, - 0, - 0}); - this.numericUpDownDurationMin.Name = "numericUpDownDurationMin"; - this.numericUpDownDurationMin.Size = new System.Drawing.Size(56, 21); - this.numericUpDownDurationMin.TabIndex = 35; - this.numericUpDownDurationMin.Value = new decimal(new int[] { - 100, - 0, - 0, - 0}); - this.numericUpDownDurationMin.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); - // - // numericUpDownDurationMax - // - this.numericUpDownDurationMax.Location = new System.Drawing.Point(203, 189); - this.numericUpDownDurationMax.Maximum = new decimal(new int[] { - 50000, - 0, - 0, - 0}); - this.numericUpDownDurationMax.Minimum = new decimal(new int[] { - 3000, - 0, - 0, - 0}); - this.numericUpDownDurationMax.Name = "numericUpDownDurationMax"; - this.numericUpDownDurationMax.Size = new System.Drawing.Size(56, 21); - this.numericUpDownDurationMax.TabIndex = 40; - this.numericUpDownDurationMax.Value = new decimal(new int[] { - 50000, - 0, - 0, - 0}); - this.numericUpDownDurationMax.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); - // - // comboBoxMergeShortLineLength - // - this.comboBoxMergeShortLineLength.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxMergeShortLineLength.FormattingEnabled = true; - this.comboBoxMergeShortLineLength.Location = new System.Drawing.Point(203, 270); - this.comboBoxMergeShortLineLength.Name = "comboBoxMergeShortLineLength"; - this.comboBoxMergeShortLineLength.Size = new System.Drawing.Size(73, 21); - this.comboBoxMergeShortLineLength.TabIndex = 55; - this.comboBoxMergeShortLineLength.SelectedIndexChanged += new System.EventHandler(this.ProfileUiValueChanged); - // - // labelMaxCharsPerSecond - // - this.labelMaxCharsPerSecond.AutoSize = true; - this.labelMaxCharsPerSecond.Location = new System.Drawing.Point(6, 111); - this.labelMaxCharsPerSecond.Name = "labelMaxCharsPerSecond"; - this.labelMaxCharsPerSecond.Size = new System.Drawing.Size(80, 13); - this.labelMaxCharsPerSecond.TabIndex = 9; - this.labelMaxCharsPerSecond.Text = "Max. chars/sec"; - // - // numericUpDownMinGapMs - // - this.numericUpDownMinGapMs.Location = new System.Drawing.Point(203, 215); - this.numericUpDownMinGapMs.Maximum = new decimal(new int[] { - 1000, - 0, - 0, - 0}); - this.numericUpDownMinGapMs.Name = "numericUpDownMinGapMs"; - this.numericUpDownMinGapMs.Size = new System.Drawing.Size(56, 21); - this.numericUpDownMinGapMs.TabIndex = 45; - this.numericUpDownMinGapMs.Value = new decimal(new int[] { - 25, - 0, - 0, - 0}); - this.numericUpDownMinGapMs.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); - // - // numericUpDownMaxCharsSec - // - this.numericUpDownMaxCharsSec.DecimalPlaces = 1; - this.numericUpDownMaxCharsSec.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownMaxCharsSec.Location = new System.Drawing.Point(203, 109); - this.numericUpDownMaxCharsSec.Minimum = new decimal(new int[] { - 4, - 0, - 0, - 0}); - this.numericUpDownMaxCharsSec.Name = "numericUpDownMaxCharsSec"; - this.numericUpDownMaxCharsSec.Size = new System.Drawing.Size(56, 21); - this.numericUpDownMaxCharsSec.TabIndex = 25; - this.numericUpDownMaxCharsSec.Value = new decimal(new int[] { - 24, - 0, - 0, - 0}); - this.numericUpDownMaxCharsSec.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); - // - // labelMinGapMs - // - this.labelMinGapMs.AutoSize = true; - this.labelMinGapMs.Location = new System.Drawing.Point(6, 217); - this.labelMinGapMs.Name = "labelMinGapMs"; - this.labelMinGapMs.Size = new System.Drawing.Size(136, 13); - this.labelMinGapMs.TabIndex = 14; - this.labelMinGapMs.Text = "Min. gap between subtitles"; - // - // numericUpDownSubtitleLineMaximumLength - // - this.numericUpDownSubtitleLineMaximumLength.Location = new System.Drawing.Point(203, 55); - this.numericUpDownSubtitleLineMaximumLength.Maximum = new decimal(new int[] { - 999, - 0, - 0, - 0}); - this.numericUpDownSubtitleLineMaximumLength.Minimum = new decimal(new int[] { - 10, - 0, - 0, - 0}); - this.numericUpDownSubtitleLineMaximumLength.Name = "numericUpDownSubtitleLineMaximumLength"; - this.numericUpDownSubtitleLineMaximumLength.Size = new System.Drawing.Size(56, 21); - this.numericUpDownSubtitleLineMaximumLength.TabIndex = 15; - this.numericUpDownSubtitleLineMaximumLength.Value = new decimal(new int[] { - 100, - 0, - 0, - 0}); - this.numericUpDownSubtitleLineMaximumLength.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); - // - // comboBoxAutoBackupDeleteAfter - // - this.comboBoxAutoBackupDeleteAfter.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxAutoBackupDeleteAfter.FormattingEnabled = true; - this.comboBoxAutoBackupDeleteAfter.Items.AddRange(new object[] { - "1 month", - "3 months", - "6 months"}); - this.comboBoxAutoBackupDeleteAfter.Location = new System.Drawing.Point(707, 421); - this.comboBoxAutoBackupDeleteAfter.Name = "comboBoxAutoBackupDeleteAfter"; - this.comboBoxAutoBackupDeleteAfter.Size = new System.Drawing.Size(88, 21); - this.comboBoxAutoBackupDeleteAfter.TabIndex = 29; - // - // labelAutoBackupDeleteAfter - // - this.labelAutoBackupDeleteAfter.AutoSize = true; - this.labelAutoBackupDeleteAfter.Location = new System.Drawing.Point(639, 424); - this.labelAutoBackupDeleteAfter.Name = "labelAutoBackupDeleteAfter"; - this.labelAutoBackupDeleteAfter.Size = new System.Drawing.Size(65, 13); - this.labelAutoBackupDeleteAfter.TabIndex = 28; - this.labelAutoBackupDeleteAfter.Text = "Delete after"; - // - // checkBoxCheckForUpdates - // - this.checkBoxCheckForUpdates.AutoSize = true; - this.checkBoxCheckForUpdates.Location = new System.Drawing.Point(522, 453); - this.checkBoxCheckForUpdates.Name = "checkBoxCheckForUpdates"; - this.checkBoxCheckForUpdates.Size = new System.Drawing.Size(114, 17); - this.checkBoxCheckForUpdates.TabIndex = 31; - this.checkBoxCheckForUpdates.Text = "Check for updates"; - this.checkBoxCheckForUpdates.UseVisualStyleBackColor = true; - // - // labelSpellChecker - // - this.labelSpellChecker.AutoSize = true; - this.labelSpellChecker.Location = new System.Drawing.Point(669, 19); - this.labelSpellChecker.Name = "labelSpellChecker"; - this.labelSpellChecker.Size = new System.Drawing.Size(69, 13); - this.labelSpellChecker.TabIndex = 30; - this.labelSpellChecker.Text = "Spell checker"; - this.labelSpellChecker.Visible = false; - // - // comboBoxTimeCodeMode - // - this.comboBoxTimeCodeMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxTimeCodeMode.FormattingEnabled = true; - this.comboBoxTimeCodeMode.Items.AddRange(new object[] { - "HH:MM:SS:MSEC (00:00:00.000)", - "HH:MM:SS:FF (00:00:00.00)"}); - this.comboBoxTimeCodeMode.Location = new System.Drawing.Point(528, 261); - this.comboBoxTimeCodeMode.Name = "comboBoxTimeCodeMode"; - this.comboBoxTimeCodeMode.Size = new System.Drawing.Size(207, 21); - this.comboBoxTimeCodeMode.TabIndex = 19; - // - // labelTimeCodeMode - // - this.labelTimeCodeMode.AutoSize = true; - this.labelTimeCodeMode.Location = new System.Drawing.Point(438, 264); - this.labelTimeCodeMode.Name = "labelTimeCodeMode"; - this.labelTimeCodeMode.Size = new System.Drawing.Size(84, 13); - this.labelTimeCodeMode.TabIndex = 18; - this.labelTimeCodeMode.Text = "Time code mode"; - // - // comboBoxEncoding - // - this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxEncoding.FormattingEnabled = true; - this.comboBoxEncoding.Items.AddRange(new object[] { - "ANSI", - "UTF-7", - "UTF-8", - "Unicode"}); - this.comboBoxEncoding.Location = new System.Drawing.Point(205, 438); - this.comboBoxEncoding.Name = "comboBoxEncoding"; - this.comboBoxEncoding.Size = new System.Drawing.Size(188, 21); - this.comboBoxEncoding.TabIndex = 4; - // - // checkBoxAutoDetectAnsiEncoding - // - this.checkBoxAutoDetectAnsiEncoding.AutoSize = true; - this.checkBoxAutoDetectAnsiEncoding.Location = new System.Drawing.Point(205, 467); - this.checkBoxAutoDetectAnsiEncoding.Name = "checkBoxAutoDetectAnsiEncoding"; - this.checkBoxAutoDetectAnsiEncoding.Size = new System.Drawing.Size(15, 14); - this.checkBoxAutoDetectAnsiEncoding.TabIndex = 6; - this.checkBoxAutoDetectAnsiEncoding.UseVisualStyleBackColor = true; - // - // textBoxShowLineBreaksAs - // - this.textBoxShowLineBreaksAs.Location = new System.Drawing.Point(594, 233); - this.textBoxShowLineBreaksAs.MaxLength = 10; - this.textBoxShowLineBreaksAs.Name = "textBoxShowLineBreaksAs"; - this.textBoxShowLineBreaksAs.Size = new System.Drawing.Size(60, 21); - this.textBoxShowLineBreaksAs.TabIndex = 17; - // - // checkBoxAutoWrapWhileTyping - // - this.checkBoxAutoWrapWhileTyping.AutoSize = true; - this.checkBoxAutoWrapWhileTyping.Location = new System.Drawing.Point(441, 210); - this.checkBoxAutoWrapWhileTyping.Name = "checkBoxAutoWrapWhileTyping"; - this.checkBoxAutoWrapWhileTyping.Size = new System.Drawing.Size(137, 17); - this.checkBoxAutoWrapWhileTyping.TabIndex = 15; - this.checkBoxAutoWrapWhileTyping.Text = "Auto-wrap while typing"; - this.checkBoxAutoWrapWhileTyping.UseVisualStyleBackColor = true; - // - // checkBoxPromptDeleteLines - // - this.checkBoxPromptDeleteLines.AutoSize = true; - this.checkBoxPromptDeleteLines.Location = new System.Drawing.Point(441, 187); - this.checkBoxPromptDeleteLines.Name = "checkBoxPromptDeleteLines"; - this.checkBoxPromptDeleteLines.Size = new System.Drawing.Size(142, 17); - this.checkBoxPromptDeleteLines.TabIndex = 14; - this.checkBoxPromptDeleteLines.Text = "Prompt for deleting lines"; - this.checkBoxPromptDeleteLines.UseVisualStyleBackColor = true; - // - // checkBoxAllowEditOfOriginalSubtitle - // - this.checkBoxAllowEditOfOriginalSubtitle.AutoSize = true; - this.checkBoxAllowEditOfOriginalSubtitle.Location = new System.Drawing.Point(441, 164); - this.checkBoxAllowEditOfOriginalSubtitle.Name = "checkBoxAllowEditOfOriginalSubtitle"; - this.checkBoxAllowEditOfOriginalSubtitle.Size = new System.Drawing.Size(160, 17); - this.checkBoxAllowEditOfOriginalSubtitle.TabIndex = 13; - this.checkBoxAllowEditOfOriginalSubtitle.Text = "Allow edit of original subtitle"; - this.checkBoxAllowEditOfOriginalSubtitle.UseVisualStyleBackColor = true; - // - // comboBoxSpellChecker - // - this.comboBoxSpellChecker.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSpellChecker.FormattingEnabled = true; - this.comboBoxSpellChecker.Items.AddRange(new object[] { - "Hunspell", - "Word"}); - this.comboBoxSpellChecker.Location = new System.Drawing.Point(692, 16); - this.comboBoxSpellChecker.Name = "comboBoxSpellChecker"; - this.comboBoxSpellChecker.Size = new System.Drawing.Size(121, 21); - this.comboBoxSpellChecker.TabIndex = 31; - this.comboBoxSpellChecker.Visible = false; - // - // comboBoxAutoBackup - // - this.comboBoxAutoBackup.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxAutoBackup.FormattingEnabled = true; - this.comboBoxAutoBackup.Items.AddRange(new object[] { - "None", - "Every minute", - "Every 5 minutes", - "Every 15 minutes"}); - this.comboBoxAutoBackup.Location = new System.Drawing.Point(512, 421); - this.comboBoxAutoBackup.Name = "comboBoxAutoBackup"; - this.comboBoxAutoBackup.Size = new System.Drawing.Size(121, 21); - this.comboBoxAutoBackup.TabIndex = 27; - // - // labelAutoBackup - // - this.labelAutoBackup.AutoSize = true; - this.labelAutoBackup.Location = new System.Drawing.Point(438, 424); - this.labelAutoBackup.Name = "labelAutoBackup"; - this.labelAutoBackup.Size = new System.Drawing.Size(68, 13); - this.labelAutoBackup.TabIndex = 26; - this.labelAutoBackup.Text = "Auto-backup"; - // - // checkBoxRememberSelectedLine - // - this.checkBoxRememberSelectedLine.AutoSize = true; - this.checkBoxRememberSelectedLine.Location = new System.Drawing.Point(449, 69); - this.checkBoxRememberSelectedLine.Name = "checkBoxRememberSelectedLine"; - this.checkBoxRememberSelectedLine.Size = new System.Drawing.Size(139, 17); - this.checkBoxRememberSelectedLine.TabIndex = 9; - this.checkBoxRememberSelectedLine.Text = "Remember selected line"; - this.checkBoxRememberSelectedLine.UseVisualStyleBackColor = true; - // - // checkBoxRemoveBlankLinesWhenOpening - // - this.checkBoxRemoveBlankLinesWhenOpening.AutoSize = true; - this.checkBoxRemoveBlankLinesWhenOpening.Location = new System.Drawing.Point(441, 141); - this.checkBoxRemoveBlankLinesWhenOpening.Name = "checkBoxRemoveBlankLinesWhenOpening"; - this.checkBoxRemoveBlankLinesWhenOpening.Size = new System.Drawing.Size(225, 17); - this.checkBoxRemoveBlankLinesWhenOpening.TabIndex = 12; - this.checkBoxRemoveBlankLinesWhenOpening.Text = "Remove blank lines when opening subtitle"; - this.checkBoxRemoveBlankLinesWhenOpening.UseVisualStyleBackColor = true; - // - // labelAutoDetectAnsiEncoding - // - this.labelAutoDetectAnsiEncoding.AutoSize = true; - this.labelAutoDetectAnsiEncoding.Location = new System.Drawing.Point(8, 466); - this.labelAutoDetectAnsiEncoding.Name = "labelAutoDetectAnsiEncoding"; - this.labelAutoDetectAnsiEncoding.Size = new System.Drawing.Size(137, 13); - this.labelAutoDetectAnsiEncoding.TabIndex = 5; - this.labelAutoDetectAnsiEncoding.Text = "Auto detect ANSI encoding"; - // - // comboBoxListViewDoubleClickEvent - // - this.comboBoxListViewDoubleClickEvent.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxListViewDoubleClickEvent.FormattingEnabled = true; - this.comboBoxListViewDoubleClickEvent.Items.AddRange(new object[] { - "ANSI", - "UTF-7", - "UTF-8", - "Unicode"}); - this.comboBoxListViewDoubleClickEvent.Location = new System.Drawing.Point(441, 337); - this.comboBoxListViewDoubleClickEvent.Name = "comboBoxListViewDoubleClickEvent"; - this.comboBoxListViewDoubleClickEvent.Size = new System.Drawing.Size(332, 21); - this.comboBoxListViewDoubleClickEvent.TabIndex = 23; - // - // labelListViewDoubleClickEvent - // - this.labelListViewDoubleClickEvent.AutoSize = true; - this.labelListViewDoubleClickEvent.Location = new System.Drawing.Point(438, 321); - this.labelListViewDoubleClickEvent.Name = "labelListViewDoubleClickEvent"; - this.labelListViewDoubleClickEvent.Size = new System.Drawing.Size(227, 13); - this.labelListViewDoubleClickEvent.TabIndex = 22; - this.labelListViewDoubleClickEvent.Text = "Double-click on line in main window listview will"; - // - // labelShowLineBreaksAs - // - this.labelShowLineBreaksAs.AutoSize = true; - this.labelShowLineBreaksAs.Location = new System.Drawing.Point(438, 236); - this.labelShowLineBreaksAs.Name = "labelShowLineBreaksAs"; - this.labelShowLineBreaksAs.Size = new System.Drawing.Size(150, 13); - this.labelShowLineBreaksAs.TabIndex = 16; - this.labelShowLineBreaksAs.Text = "Show line breaks in listview as"; - // - // checkBoxRememberWindowPosition - // - this.checkBoxRememberWindowPosition.AutoSize = true; - this.checkBoxRememberWindowPosition.Location = new System.Drawing.Point(441, 95); - this.checkBoxRememberWindowPosition.Name = "checkBoxRememberWindowPosition"; - this.checkBoxRememberWindowPosition.Size = new System.Drawing.Size(223, 17); - this.checkBoxRememberWindowPosition.TabIndex = 10; - this.checkBoxRememberWindowPosition.Text = "Remember main window position and size"; - this.checkBoxRememberWindowPosition.UseVisualStyleBackColor = true; - // - // checkBoxStartInSourceView - // - this.checkBoxStartInSourceView.AutoSize = true; - this.checkBoxStartInSourceView.Location = new System.Drawing.Point(441, 118); - this.checkBoxStartInSourceView.Name = "checkBoxStartInSourceView"; - this.checkBoxStartInSourceView.Size = new System.Drawing.Size(121, 17); - this.checkBoxStartInSourceView.TabIndex = 11; - this.checkBoxStartInSourceView.Text = "Start in source view"; - this.checkBoxStartInSourceView.UseVisualStyleBackColor = true; - // - // checkBoxReopenLastOpened - // - this.checkBoxReopenLastOpened.AutoSize = true; - this.checkBoxReopenLastOpened.Location = new System.Drawing.Point(449, 46); - this.checkBoxReopenLastOpened.Name = "checkBoxReopenLastOpened"; - this.checkBoxReopenLastOpened.Size = new System.Drawing.Size(145, 17); - this.checkBoxReopenLastOpened.TabIndex = 8; - this.checkBoxReopenLastOpened.Text = "Start with last file loaded"; - this.checkBoxReopenLastOpened.UseVisualStyleBackColor = true; - // - // checkBoxRememberRecentFiles - // - this.checkBoxRememberRecentFiles.AutoSize = true; - this.checkBoxRememberRecentFiles.Location = new System.Drawing.Point(441, 22); - this.checkBoxRememberRecentFiles.Name = "checkBoxRememberRecentFiles"; - this.checkBoxRememberRecentFiles.Size = new System.Drawing.Size(195, 17); - this.checkBoxRememberRecentFiles.TabIndex = 7; - this.checkBoxRememberRecentFiles.Text = "Remember recent files (for reopen)"; - this.checkBoxRememberRecentFiles.UseVisualStyleBackColor = true; - this.checkBoxRememberRecentFiles.CheckedChanged += new System.EventHandler(this.checkBoxRememberRecentFiles_CheckedChanged); - // - // labelDefaultFileEncoding - // - this.labelDefaultFileEncoding.AutoSize = true; - this.labelDefaultFileEncoding.Location = new System.Drawing.Point(8, 442); - this.labelDefaultFileEncoding.Name = "labelDefaultFileEncoding"; - this.labelDefaultFileEncoding.Size = new System.Drawing.Size(105, 13); - this.labelDefaultFileEncoding.TabIndex = 3; - this.labelDefaultFileEncoding.Text = "Default file encoding"; - // - // comboBoxFrameRate - // - this.comboBoxFrameRate.FormattingEnabled = true; - this.comboBoxFrameRate.Location = new System.Drawing.Point(205, 410); - this.comboBoxFrameRate.Name = "comboBoxFrameRate"; - this.comboBoxFrameRate.Size = new System.Drawing.Size(121, 21); - this.comboBoxFrameRate.TabIndex = 2; - // - // labelDefaultFrameRate - // - this.labelDefaultFrameRate.AutoSize = true; - this.labelDefaultFrameRate.Location = new System.Drawing.Point(8, 415); - this.labelDefaultFrameRate.Name = "labelDefaultFrameRate"; - this.labelDefaultFrameRate.Size = new System.Drawing.Size(96, 13); - this.labelDefaultFrameRate.TabIndex = 1; - this.labelDefaultFrameRate.Text = "Default frame rate"; - // - // tabPageShortcuts - // - this.tabPageShortcuts.Controls.Add(this.groupBoxShortcuts); - this.tabPageShortcuts.Location = new System.Drawing.Point(4, 22); - this.tabPageShortcuts.Name = "tabPageShortcuts"; - this.tabPageShortcuts.Padding = new System.Windows.Forms.Padding(3); - this.tabPageShortcuts.Size = new System.Drawing.Size(832, 520); - this.tabPageShortcuts.TabIndex = 8; - this.tabPageShortcuts.Text = "Shortcuts"; - this.tabPageShortcuts.UseVisualStyleBackColor = true; - // - // groupBoxShortcuts - // - this.groupBoxShortcuts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxShortcuts.Controls.Add(this.buttonShortcutsClear); - this.groupBoxShortcuts.Controls.Add(this.labelShortcutsSearch); - this.groupBoxShortcuts.Controls.Add(this.textBoxShortcutSearch); - this.groupBoxShortcuts.Controls.Add(this.buttonClearShortcut); - this.groupBoxShortcuts.Controls.Add(this.comboBoxShortcutKey); - this.groupBoxShortcuts.Controls.Add(this.labelShortcutKey); - this.groupBoxShortcuts.Controls.Add(this.checkBoxShortcutsShift); - this.groupBoxShortcuts.Controls.Add(this.checkBoxShortcutsAlt); - this.groupBoxShortcuts.Controls.Add(this.checkBoxShortcutsControl); - this.groupBoxShortcuts.Controls.Add(this.buttonUpdateShortcut); - this.groupBoxShortcuts.Controls.Add(this.treeViewShortcuts); - this.groupBoxShortcuts.Controls.Add(this.labelShortcut); - this.groupBoxShortcuts.Location = new System.Drawing.Point(6, 6); - this.groupBoxShortcuts.Name = "groupBoxShortcuts"; - this.groupBoxShortcuts.Size = new System.Drawing.Size(819, 499); - this.groupBoxShortcuts.TabIndex = 2; - this.groupBoxShortcuts.TabStop = false; - this.groupBoxShortcuts.Text = "Shortcuts"; - // - // buttonShortcutsClear - // - this.buttonShortcutsClear.Enabled = false; - this.buttonShortcutsClear.Location = new System.Drawing.Point(221, 18); - this.buttonShortcutsClear.Name = "buttonShortcutsClear"; - this.buttonShortcutsClear.Size = new System.Drawing.Size(111, 23); - this.buttonShortcutsClear.TabIndex = 38; - this.buttonShortcutsClear.Text = "Clear"; - this.buttonShortcutsClear.UseVisualStyleBackColor = true; - this.buttonShortcutsClear.Click += new System.EventHandler(this.buttonShortcutsClear_Click); - // - // labelShortcutsSearch - // - this.labelShortcutsSearch.AutoSize = true; - this.labelShortcutsSearch.Location = new System.Drawing.Point(18, 23); - this.labelShortcutsSearch.Name = "labelShortcutsSearch"; - this.labelShortcutsSearch.Size = new System.Drawing.Size(40, 13); - this.labelShortcutsSearch.TabIndex = 37; - this.labelShortcutsSearch.Text = "Search"; - // - // textBoxShortcutSearch - // - this.textBoxShortcutSearch.Location = new System.Drawing.Point(64, 20); - this.textBoxShortcutSearch.Name = "textBoxShortcutSearch"; - this.textBoxShortcutSearch.Size = new System.Drawing.Size(151, 21); - this.textBoxShortcutSearch.TabIndex = 36; - this.textBoxShortcutSearch.TextChanged += new System.EventHandler(this.textBoxShortcutSearch_TextChanged); - // - // buttonClearShortcut - // - this.buttonClearShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonClearShortcut.Enabled = false; - this.buttonClearShortcut.Location = new System.Drawing.Point(582, 470); - this.buttonClearShortcut.Name = "buttonClearShortcut"; - this.buttonClearShortcut.Size = new System.Drawing.Size(111, 23); - this.buttonClearShortcut.TabIndex = 6; - this.buttonClearShortcut.Text = "&Clear"; - this.buttonClearShortcut.UseVisualStyleBackColor = true; - this.buttonClearShortcut.Click += new System.EventHandler(this.buttonClearShortcut_Click); - // - // comboBoxShortcutKey - // - this.comboBoxShortcutKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.comboBoxShortcutKey.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxShortcutKey.Enabled = false; - this.comboBoxShortcutKey.FormattingEnabled = true; - this.comboBoxShortcutKey.Items.AddRange(new object[] { - "None", - "A", - "B", - "C", - "D", - "E", - "F", - "G", - "H", - "I", - "J", - "K", - "L", - "M", - "N", - "O", - "P", - "Q", - "R", - "S", - "T", - "U", - "V", - "W", - "X", - "Y", - "Z", - "D0", - "D1", - "D2", - "D3", - "D4", - "D5", - "D6", - "D7", - "D8", - "D9", - "F1", - "F2", - "F3", - "F4", - "F5", - "F6", - "F7", - "F8", - "F9", - "F10", - "F11", - "F12", - "Delete", - "Down", - "Home", - "End", - "Escape", - "Insert", - "Left", - "Pause", - "Return", - "Right", - "Space", - "Tab", - "Up", - "Back", - "NumPad0", - "NumPad1", - "NumPad2", - "NumPad3", - "NumPad4", - "NumPad5", - "NumPad6", - "NumPad7", - "NumPad8", - "NumPad9", - "PageDown", - "PageUp", - "Sleep", - "Multiply", - "Add", - "Separator", - "Subtract", - "Decimal", - "Divide", - "CapsLock", - "NumLock", - "Scroll", - "VolumeMute", - "VolumeDown", - "VolumeUp", - "MediaNextTrack", - "MediaPreviousTrack", - "MediaStop", - "MediaPlayPause", - "LaunchMail", - "SelectMedia", - "LaunchApplication1", - "LaunchApplication2", - "Oem1", - "Oemplus", - "Oemcomma", - "OemMinus", - "OemPeriod", - "OemQuestion", - "OemSemicolon", - "Oemtilde", - "OemOpenBrackets", - "Oem5", - "Oem6", - "Oem7", - "Oem8", - "OemBackslash", - "ProcessKey", - "Packet", - "Attn", - "Crsel", - "Exsel", - "EraseEof", - "Play", - "Zoom", - "NoName", - "Pa1", - "OemClear", - "KeyCode", - "F13", - "F14", - "F15", - "F16", - "F17", - "F18", - "F19", - "F20", - "F21", - "F22", - "F23", - "F24"}); - this.comboBoxShortcutKey.Location = new System.Drawing.Point(353, 470); - this.comboBoxShortcutKey.Name = "comboBoxShortcutKey"; - this.comboBoxShortcutKey.Size = new System.Drawing.Size(92, 21); - this.comboBoxShortcutKey.TabIndex = 4; - this.comboBoxShortcutKey.SelectedIndexChanged += new System.EventHandler(this.ValidateShortcut); - this.comboBoxShortcutKey.KeyDown += new System.Windows.Forms.KeyEventHandler(this.comboBoxShortcutKey_KeyDown); - // - // labelShortcutKey - // - this.labelShortcutKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelShortcutKey.AutoSize = true; - this.labelShortcutKey.Location = new System.Drawing.Point(322, 472); - this.labelShortcutKey.Name = "labelShortcutKey"; - this.labelShortcutKey.Size = new System.Drawing.Size(25, 13); - this.labelShortcutKey.TabIndex = 35; - this.labelShortcutKey.Text = "Key"; - // - // checkBoxShortcutsShift - // - this.checkBoxShortcutsShift.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.checkBoxShortcutsShift.AutoSize = true; - this.checkBoxShortcutsShift.Enabled = false; - this.checkBoxShortcutsShift.Location = new System.Drawing.Point(245, 472); - this.checkBoxShortcutsShift.Name = "checkBoxShortcutsShift"; - this.checkBoxShortcutsShift.Size = new System.Drawing.Size(48, 17); - this.checkBoxShortcutsShift.TabIndex = 3; - this.checkBoxShortcutsShift.Text = "Shift"; - this.checkBoxShortcutsShift.UseVisualStyleBackColor = true; - this.checkBoxShortcutsShift.CheckedChanged += new System.EventHandler(this.ValidateShortcut); - // - // checkBoxShortcutsAlt - // - this.checkBoxShortcutsAlt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.checkBoxShortcutsAlt.AutoSize = true; - this.checkBoxShortcutsAlt.Enabled = false; - this.checkBoxShortcutsAlt.Location = new System.Drawing.Point(176, 472); - this.checkBoxShortcutsAlt.Name = "checkBoxShortcutsAlt"; - this.checkBoxShortcutsAlt.Size = new System.Drawing.Size(39, 17); - this.checkBoxShortcutsAlt.TabIndex = 2; - this.checkBoxShortcutsAlt.Text = "Alt"; - this.checkBoxShortcutsAlt.UseVisualStyleBackColor = true; - this.checkBoxShortcutsAlt.CheckedChanged += new System.EventHandler(this.ValidateShortcut); - // - // checkBoxShortcutsControl - // - this.checkBoxShortcutsControl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.checkBoxShortcutsControl.AutoSize = true; - this.checkBoxShortcutsControl.Enabled = false; - this.checkBoxShortcutsControl.Location = new System.Drawing.Point(89, 472); - this.checkBoxShortcutsControl.Name = "checkBoxShortcutsControl"; - this.checkBoxShortcutsControl.Size = new System.Drawing.Size(61, 17); - this.checkBoxShortcutsControl.TabIndex = 1; - this.checkBoxShortcutsControl.Text = "Control"; - this.checkBoxShortcutsControl.UseVisualStyleBackColor = true; - this.checkBoxShortcutsControl.CheckedChanged += new System.EventHandler(this.ValidateShortcut); - // - // buttonUpdateShortcut - // - this.buttonUpdateShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonUpdateShortcut.Enabled = false; - this.buttonUpdateShortcut.Location = new System.Drawing.Point(465, 470); - this.buttonUpdateShortcut.Name = "buttonUpdateShortcut"; - this.buttonUpdateShortcut.Size = new System.Drawing.Size(111, 23); - this.buttonUpdateShortcut.TabIndex = 5; - this.buttonUpdateShortcut.Text = "&Update"; - this.buttonUpdateShortcut.UseVisualStyleBackColor = true; - this.buttonUpdateShortcut.Click += new System.EventHandler(this.buttonUpdateShortcut_Click); - // - // treeViewShortcuts - // - this.treeViewShortcuts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.treeViewShortcuts.ContextMenuStrip = this.contextMenuStripShortcuts; - this.treeViewShortcuts.HideSelection = false; - this.treeViewShortcuts.Location = new System.Drawing.Point(16, 47); - this.treeViewShortcuts.Name = "treeViewShortcuts"; - this.treeViewShortcuts.Size = new System.Drawing.Size(797, 417); - this.treeViewShortcuts.TabIndex = 0; - this.treeViewShortcuts.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewShortcuts_AfterSelect); - // - // contextMenuStripShortcuts - // - this.contextMenuStripShortcuts.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemShortcutsCollapse, - this.toolStripSeparator1, - this.importShortcutsToolStripMenuItem, - this.exportShortcutsToolStripMenuItem}); - this.contextMenuStripShortcuts.Name = "contextMenuStripShortcuts"; - this.contextMenuStripShortcuts.Size = new System.Drawing.Size(120, 76); - // - // toolStripMenuItemShortcutsCollapse - // - this.toolStripMenuItemShortcutsCollapse.Name = "toolStripMenuItemShortcutsCollapse"; - this.toolStripMenuItemShortcutsCollapse.Size = new System.Drawing.Size(119, 22); - this.toolStripMenuItemShortcutsCollapse.Text = "Collapse"; - this.toolStripMenuItemShortcutsCollapse.Click += new System.EventHandler(this.toolStripMenuItemShortcutsCollapse_Click); - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(116, 6); - // - // importShortcutsToolStripMenuItem - // - this.importShortcutsToolStripMenuItem.Name = "importShortcutsToolStripMenuItem"; - this.importShortcutsToolStripMenuItem.Size = new System.Drawing.Size(119, 22); - this.importShortcutsToolStripMenuItem.Text = "Import..."; - this.importShortcutsToolStripMenuItem.Click += new System.EventHandler(this.importShortcutsToolStripMenuItem_Click); - // - // exportShortcutsToolStripMenuItem - // - this.exportShortcutsToolStripMenuItem.Name = "exportShortcutsToolStripMenuItem"; - this.exportShortcutsToolStripMenuItem.Size = new System.Drawing.Size(119, 22); - this.exportShortcutsToolStripMenuItem.Text = "Export..."; - this.exportShortcutsToolStripMenuItem.Click += new System.EventHandler(this.exportShortcutsToolStripMenuItem_Click); - // - // labelShortcut - // - this.labelShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelShortcut.AutoSize = true; - this.labelShortcut.Location = new System.Drawing.Point(15, 472); - this.labelShortcut.Name = "labelShortcut"; - this.labelShortcut.Size = new System.Drawing.Size(52, 13); - this.labelShortcut.TabIndex = 3; - this.labelShortcut.Text = "Shortcut:"; - // - // tabPageSyntaxColoring - // - this.tabPageSyntaxColoring.Controls.Add(this.groupBoxListViewSyntaxColoring); - this.tabPageSyntaxColoring.Location = new System.Drawing.Point(4, 22); - this.tabPageSyntaxColoring.Name = "tabPageSyntaxColoring"; - this.tabPageSyntaxColoring.Padding = new System.Windows.Forms.Padding(3); - this.tabPageSyntaxColoring.Size = new System.Drawing.Size(832, 520); - this.tabPageSyntaxColoring.TabIndex = 9; - this.tabPageSyntaxColoring.Text = "Syntax coloring"; - this.tabPageSyntaxColoring.UseVisualStyleBackColor = true; - // - // groupBoxListViewSyntaxColoring - // - this.groupBoxListViewSyntaxColoring.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxListViewSyntaxColoring.Controls.Add(this.buttonLineWidthSettings); - this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorTextTooWide); - this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorGapTooSmall); - this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorTextMoreThanTwoLines); - this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxOverlap); - this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorDurationTooSmall); - this.groupBoxListViewSyntaxColoring.Controls.Add(this.buttonListViewSyntaxColorError); - this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorTextTooLong); - this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorDurationTooLarge); - this.groupBoxListViewSyntaxColoring.Controls.Add(this.panelListViewSyntaxColorError); - this.groupBoxListViewSyntaxColoring.Location = new System.Drawing.Point(6, 6); - this.groupBoxListViewSyntaxColoring.Name = "groupBoxListViewSyntaxColoring"; - this.groupBoxListViewSyntaxColoring.Size = new System.Drawing.Size(820, 523); - this.groupBoxListViewSyntaxColoring.TabIndex = 0; - this.groupBoxListViewSyntaxColoring.TabStop = false; - this.groupBoxListViewSyntaxColoring.Text = "List view syntax coloring"; - // - // buttonLineWidthSettings - // - this.buttonLineWidthSettings.Location = new System.Drawing.Point(160, 112); - this.buttonLineWidthSettings.Name = "buttonLineWidthSettings"; - this.buttonLineWidthSettings.Size = new System.Drawing.Size(112, 23); - this.buttonLineWidthSettings.TabIndex = 4; - this.buttonLineWidthSettings.Text = "Settings..."; - this.buttonLineWidthSettings.UseVisualStyleBackColor = true; - this.buttonLineWidthSettings.Click += new System.EventHandler(this.buttonLineWidthSettings_Click); - // - // checkBoxSyntaxColorTextTooWide - // - this.checkBoxSyntaxColorTextTooWide.AutoSize = true; - this.checkBoxSyntaxColorTextTooWide.Location = new System.Drawing.Point(20, 116); - this.checkBoxSyntaxColorTextTooWide.Name = "checkBoxSyntaxColorTextTooWide"; - this.checkBoxSyntaxColorTextTooWide.Size = new System.Drawing.Size(134, 17); - this.checkBoxSyntaxColorTextTooWide.TabIndex = 3; - this.checkBoxSyntaxColorTextTooWide.Text = "Text - color if too wide"; - this.checkBoxSyntaxColorTextTooWide.UseVisualStyleBackColor = true; - // - // checkBoxSyntaxColorGapTooSmall - // - this.checkBoxSyntaxColorGapTooSmall.AutoSize = true; - this.checkBoxSyntaxColorGapTooSmall.Location = new System.Drawing.Point(20, 209); - this.checkBoxSyntaxColorGapTooSmall.Name = "checkBoxSyntaxColorGapTooSmall"; - this.checkBoxSyntaxColorGapTooSmall.Size = new System.Drawing.Size(132, 17); - this.checkBoxSyntaxColorGapTooSmall.TabIndex = 7; - this.checkBoxSyntaxColorGapTooSmall.Text = "Gap - color if too small"; - this.checkBoxSyntaxColorGapTooSmall.UseVisualStyleBackColor = true; - // - // checkBoxSyntaxColorTextMoreThanTwoLines - // - this.checkBoxSyntaxColorTextMoreThanTwoLines.AutoSize = true; - this.checkBoxSyntaxColorTextMoreThanTwoLines.Location = new System.Drawing.Point(20, 139); - this.checkBoxSyntaxColorTextMoreThanTwoLines.Name = "checkBoxSyntaxColorTextMoreThanTwoLines"; - this.checkBoxSyntaxColorTextMoreThanTwoLines.Size = new System.Drawing.Size(170, 17); - this.checkBoxSyntaxColorTextMoreThanTwoLines.TabIndex = 5; - this.checkBoxSyntaxColorTextMoreThanTwoLines.Text = "Text - color if more than lines:"; - this.checkBoxSyntaxColorTextMoreThanTwoLines.UseVisualStyleBackColor = true; - // - // checkBoxSyntaxOverlap - // - this.checkBoxSyntaxOverlap.AutoSize = true; - this.checkBoxSyntaxOverlap.Location = new System.Drawing.Point(20, 174); - this.checkBoxSyntaxOverlap.Name = "checkBoxSyntaxOverlap"; - this.checkBoxSyntaxOverlap.Size = new System.Drawing.Size(129, 17); - this.checkBoxSyntaxOverlap.TabIndex = 6; - this.checkBoxSyntaxOverlap.Text = "Time - color if overlap"; - this.checkBoxSyntaxOverlap.UseVisualStyleBackColor = true; - // - // checkBoxSyntaxColorDurationTooSmall - // - this.checkBoxSyntaxColorDurationTooSmall.AutoSize = true; - this.checkBoxSyntaxColorDurationTooSmall.Location = new System.Drawing.Point(20, 35); - this.checkBoxSyntaxColorDurationTooSmall.Name = "checkBoxSyntaxColorDurationTooSmall"; - this.checkBoxSyntaxColorDurationTooSmall.Size = new System.Drawing.Size(154, 17); - this.checkBoxSyntaxColorDurationTooSmall.TabIndex = 0; - this.checkBoxSyntaxColorDurationTooSmall.Text = "Duration - color if too small"; - this.checkBoxSyntaxColorDurationTooSmall.UseVisualStyleBackColor = true; - // - // buttonListViewSyntaxColorError - // - this.buttonListViewSyntaxColorError.Location = new System.Drawing.Point(20, 247); - this.buttonListViewSyntaxColorError.Name = "buttonListViewSyntaxColorError"; - this.buttonListViewSyntaxColorError.Size = new System.Drawing.Size(112, 23); - this.buttonListViewSyntaxColorError.TabIndex = 8; - this.buttonListViewSyntaxColorError.Text = "Error color"; - this.buttonListViewSyntaxColorError.UseVisualStyleBackColor = true; - this.buttonListViewSyntaxColorError.Click += new System.EventHandler(this.buttonListViewSyntaxColorError_Click); - // - // checkBoxSyntaxColorTextTooLong - // - this.checkBoxSyntaxColorTextTooLong.AutoSize = true; - this.checkBoxSyntaxColorTextTooLong.Location = new System.Drawing.Point(20, 93); - this.checkBoxSyntaxColorTextTooLong.Name = "checkBoxSyntaxColorTextTooLong"; - this.checkBoxSyntaxColorTextTooLong.Size = new System.Drawing.Size(132, 17); - this.checkBoxSyntaxColorTextTooLong.TabIndex = 2; - this.checkBoxSyntaxColorTextTooLong.Text = "Text - color if too long"; - this.checkBoxSyntaxColorTextTooLong.UseVisualStyleBackColor = true; - // - // checkBoxSyntaxColorDurationTooLarge - // - this.checkBoxSyntaxColorDurationTooLarge.AutoSize = true; - this.checkBoxSyntaxColorDurationTooLarge.Location = new System.Drawing.Point(20, 58); - this.checkBoxSyntaxColorDurationTooLarge.Name = "checkBoxSyntaxColorDurationTooLarge"; - this.checkBoxSyntaxColorDurationTooLarge.Size = new System.Drawing.Size(155, 17); - this.checkBoxSyntaxColorDurationTooLarge.TabIndex = 1; - this.checkBoxSyntaxColorDurationTooLarge.Text = "Duration - color if too large"; - this.checkBoxSyntaxColorDurationTooLarge.UseVisualStyleBackColor = true; - // - // panelListViewSyntaxColorError - // - this.panelListViewSyntaxColorError.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelListViewSyntaxColorError.Location = new System.Drawing.Point(142, 247); - this.panelListViewSyntaxColorError.Name = "panelListViewSyntaxColorError"; - this.panelListViewSyntaxColorError.Size = new System.Drawing.Size(21, 20); - this.panelListViewSyntaxColorError.TabIndex = 8; - this.panelListViewSyntaxColorError.Click += new System.EventHandler(this.buttonListViewSyntaxColorError_Click); - // - // tabPageVideoPlayer - // - this.tabPageVideoPlayer.Controls.Add(this.groupBoxMainWindowVideoControls); - this.tabPageVideoPlayer.Controls.Add(this.groupBoxVideoPlayerDefault); - this.tabPageVideoPlayer.Controls.Add(this.groupBoxVideoEngine); - this.tabPageVideoPlayer.Location = new System.Drawing.Point(4, 22); - this.tabPageVideoPlayer.Name = "tabPageVideoPlayer"; - this.tabPageVideoPlayer.Padding = new System.Windows.Forms.Padding(3); - this.tabPageVideoPlayer.Size = new System.Drawing.Size(832, 520); - this.tabPageVideoPlayer.TabIndex = 2; - this.tabPageVideoPlayer.Text = "Video player"; - this.tabPageVideoPlayer.UseVisualStyleBackColor = true; - // - // groupBoxMainWindowVideoControls - // - this.groupBoxMainWindowVideoControls.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxMainWindowVideoControls.Controls.Add(this.labelCustomSearch5); - this.groupBoxMainWindowVideoControls.Controls.Add(this.textBoxCustomSearchUrl5); - this.groupBoxMainWindowVideoControls.Controls.Add(this.comboBoxCustomSearch5); - this.groupBoxMainWindowVideoControls.Controls.Add(this.labelCustomSearch4); - this.groupBoxMainWindowVideoControls.Controls.Add(this.textBoxCustomSearchUrl4); - this.groupBoxMainWindowVideoControls.Controls.Add(this.comboBoxCustomSearch4); - this.groupBoxMainWindowVideoControls.Controls.Add(this.labelCustomSearch3); - this.groupBoxMainWindowVideoControls.Controls.Add(this.textBoxCustomSearchUrl3); - this.groupBoxMainWindowVideoControls.Controls.Add(this.comboBoxCustomSearch3); - this.groupBoxMainWindowVideoControls.Controls.Add(this.labelCustomSearch2); - this.groupBoxMainWindowVideoControls.Controls.Add(this.textBoxCustomSearchUrl2); - this.groupBoxMainWindowVideoControls.Controls.Add(this.comboBoxCustomSearch2); - this.groupBoxMainWindowVideoControls.Controls.Add(this.labelCustomSearch1); - this.groupBoxMainWindowVideoControls.Controls.Add(this.textBoxCustomSearchUrl1); - this.groupBoxMainWindowVideoControls.Controls.Add(this.labelCustomSearch); - this.groupBoxMainWindowVideoControls.Controls.Add(this.comboBoxCustomSearch1); - this.groupBoxMainWindowVideoControls.Location = new System.Drawing.Point(7, 281); - this.groupBoxMainWindowVideoControls.Name = "groupBoxMainWindowVideoControls"; - this.groupBoxMainWindowVideoControls.Size = new System.Drawing.Size(819, 233); - this.groupBoxMainWindowVideoControls.TabIndex = 15; - this.groupBoxMainWindowVideoControls.TabStop = false; - this.groupBoxMainWindowVideoControls.Text = "Main window video controls"; - // - // labelCustomSearch5 - // - this.labelCustomSearch5.AutoSize = true; - this.labelCustomSearch5.Location = new System.Drawing.Point(12, 149); - this.labelCustomSearch5.Name = "labelCustomSearch5"; - this.labelCustomSearch5.Size = new System.Drawing.Size(13, 13); - this.labelCustomSearch5.TabIndex = 15; - this.labelCustomSearch5.Text = "5"; - // - // textBoxCustomSearchUrl5 - // - this.textBoxCustomSearchUrl5.Location = new System.Drawing.Point(185, 146); - this.textBoxCustomSearchUrl5.Name = "textBoxCustomSearchUrl5"; - this.textBoxCustomSearchUrl5.Size = new System.Drawing.Size(574, 21); - this.textBoxCustomSearchUrl5.TabIndex = 14; - // - // comboBoxCustomSearch5 - // - this.comboBoxCustomSearch5.FormattingEnabled = true; - this.comboBoxCustomSearch5.Items.AddRange(new object[] { - "Dictionary.com", - "learnersdictionary.com", - "Merriam-Webster", - "The Free Dictionary", - "Thesaurus.com", - "urbandictionary.com", - "VISUWORDS", - "Wikipedia"}); - this.comboBoxCustomSearch5.Location = new System.Drawing.Point(31, 146); - this.comboBoxCustomSearch5.Name = "comboBoxCustomSearch5"; - this.comboBoxCustomSearch5.Size = new System.Drawing.Size(148, 21); - this.comboBoxCustomSearch5.TabIndex = 13; - this.comboBoxCustomSearch5.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustomSearch_SelectedIndexChanged); - // - // labelCustomSearch4 - // - this.labelCustomSearch4.AutoSize = true; - this.labelCustomSearch4.Location = new System.Drawing.Point(12, 122); - this.labelCustomSearch4.Name = "labelCustomSearch4"; - this.labelCustomSearch4.Size = new System.Drawing.Size(13, 13); - this.labelCustomSearch4.TabIndex = 12; - this.labelCustomSearch4.Text = "4"; - // - // textBoxCustomSearchUrl4 - // - this.textBoxCustomSearchUrl4.Location = new System.Drawing.Point(185, 119); - this.textBoxCustomSearchUrl4.Name = "textBoxCustomSearchUrl4"; - this.textBoxCustomSearchUrl4.Size = new System.Drawing.Size(574, 21); - this.textBoxCustomSearchUrl4.TabIndex = 11; - // - // comboBoxCustomSearch4 - // - this.comboBoxCustomSearch4.FormattingEnabled = true; - this.comboBoxCustomSearch4.Items.AddRange(new object[] { - "Dictionary.com", - "learnersdictionary.com", - "Merriam-Webster", - "The Free Dictionary", - "Thesaurus.com", - "urbandictionary.com", - "VISUWORDS", - "Wikipedia"}); - this.comboBoxCustomSearch4.Location = new System.Drawing.Point(31, 119); - this.comboBoxCustomSearch4.Name = "comboBoxCustomSearch4"; - this.comboBoxCustomSearch4.Size = new System.Drawing.Size(148, 21); - this.comboBoxCustomSearch4.TabIndex = 10; - this.comboBoxCustomSearch4.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustomSearch_SelectedIndexChanged); - // - // labelCustomSearch3 - // - this.labelCustomSearch3.AutoSize = true; - this.labelCustomSearch3.Location = new System.Drawing.Point(12, 95); - this.labelCustomSearch3.Name = "labelCustomSearch3"; - this.labelCustomSearch3.Size = new System.Drawing.Size(13, 13); - this.labelCustomSearch3.TabIndex = 9; - this.labelCustomSearch3.Text = "3"; - // - // textBoxCustomSearchUrl3 - // - this.textBoxCustomSearchUrl3.Location = new System.Drawing.Point(185, 92); - this.textBoxCustomSearchUrl3.Name = "textBoxCustomSearchUrl3"; - this.textBoxCustomSearchUrl3.Size = new System.Drawing.Size(574, 21); - this.textBoxCustomSearchUrl3.TabIndex = 8; - // - // comboBoxCustomSearch3 - // - this.comboBoxCustomSearch3.FormattingEnabled = true; - this.comboBoxCustomSearch3.Items.AddRange(new object[] { - "Dictionary.com", - "learnersdictionary.com", - "Merriam-Webster", - "The Free Dictionary", - "Thesaurus.com", - "urbandictionary.com", - "VISUWORDS", - "Wikipedia"}); - this.comboBoxCustomSearch3.Location = new System.Drawing.Point(31, 92); - this.comboBoxCustomSearch3.Name = "comboBoxCustomSearch3"; - this.comboBoxCustomSearch3.Size = new System.Drawing.Size(148, 21); - this.comboBoxCustomSearch3.TabIndex = 7; - this.comboBoxCustomSearch3.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustomSearch_SelectedIndexChanged); - // - // labelCustomSearch2 - // - this.labelCustomSearch2.AutoSize = true; - this.labelCustomSearch2.Location = new System.Drawing.Point(12, 68); - this.labelCustomSearch2.Name = "labelCustomSearch2"; - this.labelCustomSearch2.Size = new System.Drawing.Size(13, 13); - this.labelCustomSearch2.TabIndex = 6; - this.labelCustomSearch2.Text = "2"; - // - // textBoxCustomSearchUrl2 - // - this.textBoxCustomSearchUrl2.Location = new System.Drawing.Point(185, 65); - this.textBoxCustomSearchUrl2.Name = "textBoxCustomSearchUrl2"; - this.textBoxCustomSearchUrl2.Size = new System.Drawing.Size(574, 21); - this.textBoxCustomSearchUrl2.TabIndex = 5; - // - // comboBoxCustomSearch2 - // - this.comboBoxCustomSearch2.FormattingEnabled = true; - this.comboBoxCustomSearch2.Items.AddRange(new object[] { - "Dictionary.com", - "learnersdictionary.com", - "Merriam-Webster", - "The Free Dictionary", - "Thesaurus.com", - "urbandictionary.com", - "VISUWORDS", - "Wikipedia"}); - this.comboBoxCustomSearch2.Location = new System.Drawing.Point(31, 65); - this.comboBoxCustomSearch2.Name = "comboBoxCustomSearch2"; - this.comboBoxCustomSearch2.Size = new System.Drawing.Size(148, 21); - this.comboBoxCustomSearch2.TabIndex = 4; - this.comboBoxCustomSearch2.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustomSearch_SelectedIndexChanged); - // - // labelCustomSearch1 - // - this.labelCustomSearch1.AutoSize = true; - this.labelCustomSearch1.Location = new System.Drawing.Point(12, 41); - this.labelCustomSearch1.Name = "labelCustomSearch1"; - this.labelCustomSearch1.Size = new System.Drawing.Size(13, 13); - this.labelCustomSearch1.TabIndex = 3; - this.labelCustomSearch1.Text = "1"; - // - // textBoxCustomSearchUrl1 - // - this.textBoxCustomSearchUrl1.Location = new System.Drawing.Point(185, 38); - this.textBoxCustomSearchUrl1.Name = "textBoxCustomSearchUrl1"; - this.textBoxCustomSearchUrl1.Size = new System.Drawing.Size(574, 21); - this.textBoxCustomSearchUrl1.TabIndex = 2; - // - // labelCustomSearch - // - this.labelCustomSearch.AutoSize = true; - this.labelCustomSearch.Location = new System.Drawing.Point(12, 20); - this.labelCustomSearch.Name = "labelCustomSearch"; - this.labelCustomSearch.Size = new System.Drawing.Size(144, 13); - this.labelCustomSearch.TabIndex = 1; - this.labelCustomSearch.Text = "Custom search text and URL"; - // - // comboBoxCustomSearch1 - // - this.comboBoxCustomSearch1.FormattingEnabled = true; - this.comboBoxCustomSearch1.Items.AddRange(new object[] { - "Dictionary.com", - "learnersdictionary.com", - "Merriam-Webster", - "The Free Dictionary", - "Thesaurus.com", - "urbandictionary.com", - "VISUWORDS", - "Wikipedia"}); - this.comboBoxCustomSearch1.Location = new System.Drawing.Point(31, 38); - this.comboBoxCustomSearch1.Name = "comboBoxCustomSearch1"; - this.comboBoxCustomSearch1.Size = new System.Drawing.Size(148, 21); - this.comboBoxCustomSearch1.TabIndex = 0; - this.comboBoxCustomSearch1.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustomSearch_SelectedIndexChanged); - // - // groupBoxVideoPlayerDefault - // - this.groupBoxVideoPlayerDefault.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxVideoPlayerDefault.Controls.Add(this.checkBoxAllowVolumeBoost); - this.groupBoxVideoPlayerDefault.Controls.Add(this.checkBoxVideoAutoOpen); - this.groupBoxVideoPlayerDefault.Controls.Add(this.checkBoxVideoPlayerPreviewFontBold); - this.groupBoxVideoPlayerDefault.Controls.Add(this.checkBoxVideoPlayerShowFullscreenButton); - this.groupBoxVideoPlayerDefault.Controls.Add(this.checkBoxVideoPlayerShowMuteButton); - this.groupBoxVideoPlayerDefault.Controls.Add(this.labelVideoPlayerPreviewFontSize); - this.groupBoxVideoPlayerDefault.Controls.Add(this.comboBoxlVideoPlayerPreviewFontSize); - this.groupBoxVideoPlayerDefault.Controls.Add(this.checkBoxVideoPlayerShowStopButton); - this.groupBoxVideoPlayerDefault.Location = new System.Drawing.Point(7, 155); - this.groupBoxVideoPlayerDefault.Name = "groupBoxVideoPlayerDefault"; - this.groupBoxVideoPlayerDefault.Size = new System.Drawing.Size(819, 120); - this.groupBoxVideoPlayerDefault.TabIndex = 14; - this.groupBoxVideoPlayerDefault.TabStop = false; - // - // checkBoxAllowVolumeBoost - // - this.checkBoxAllowVolumeBoost.AutoSize = true; - this.checkBoxAllowVolumeBoost.Location = new System.Drawing.Point(334, 97); - this.checkBoxAllowVolumeBoost.Name = "checkBoxAllowVolumeBoost"; - this.checkBoxAllowVolumeBoost.Size = new System.Drawing.Size(118, 17); - this.checkBoxAllowVolumeBoost.TabIndex = 25; - this.checkBoxAllowVolumeBoost.Text = "Allow volume boost"; - this.checkBoxAllowVolumeBoost.UseVisualStyleBackColor = true; - // - // checkBoxVideoAutoOpen - // - this.checkBoxVideoAutoOpen.AutoSize = true; - this.checkBoxVideoAutoOpen.Location = new System.Drawing.Point(334, 74); - this.checkBoxVideoAutoOpen.Name = "checkBoxVideoAutoOpen"; - this.checkBoxVideoAutoOpen.Size = new System.Drawing.Size(213, 17); - this.checkBoxVideoAutoOpen.TabIndex = 24; - this.checkBoxVideoAutoOpen.Text = "Auto open video when opening subtitle"; - this.checkBoxVideoAutoOpen.UseVisualStyleBackColor = true; - // - // checkBoxVideoPlayerPreviewFontBold - // - this.checkBoxVideoPlayerPreviewFontBold.AutoSize = true; - this.checkBoxVideoPlayerPreviewFontBold.Location = new System.Drawing.Point(465, 45); - this.checkBoxVideoPlayerPreviewFontBold.Name = "checkBoxVideoPlayerPreviewFontBold"; - this.checkBoxVideoPlayerPreviewFontBold.Size = new System.Drawing.Size(46, 17); - this.checkBoxVideoPlayerPreviewFontBold.TabIndex = 23; - this.checkBoxVideoPlayerPreviewFontBold.Text = "Bold"; - this.checkBoxVideoPlayerPreviewFontBold.UseVisualStyleBackColor = true; - // - // checkBoxVideoPlayerShowFullscreenButton - // - this.checkBoxVideoPlayerShowFullscreenButton.AutoSize = true; - this.checkBoxVideoPlayerShowFullscreenButton.Location = new System.Drawing.Point(9, 65); - this.checkBoxVideoPlayerShowFullscreenButton.Name = "checkBoxVideoPlayerShowFullscreenButton"; - this.checkBoxVideoPlayerShowFullscreenButton.Size = new System.Drawing.Size(136, 17); - this.checkBoxVideoPlayerShowFullscreenButton.TabIndex = 12; - this.checkBoxVideoPlayerShowFullscreenButton.Text = "Show fullscreen button"; - this.checkBoxVideoPlayerShowFullscreenButton.UseVisualStyleBackColor = true; - // - // checkBoxVideoPlayerShowMuteButton - // - this.checkBoxVideoPlayerShowMuteButton.AutoSize = true; - this.checkBoxVideoPlayerShowMuteButton.Location = new System.Drawing.Point(9, 42); - this.checkBoxVideoPlayerShowMuteButton.Name = "checkBoxVideoPlayerShowMuteButton"; - this.checkBoxVideoPlayerShowMuteButton.Size = new System.Drawing.Size(114, 17); - this.checkBoxVideoPlayerShowMuteButton.TabIndex = 11; - this.checkBoxVideoPlayerShowMuteButton.Text = "Show mute button"; - this.checkBoxVideoPlayerShowMuteButton.UseVisualStyleBackColor = true; - // - // labelVideoPlayerPreviewFontSize - // - this.labelVideoPlayerPreviewFontSize.AutoSize = true; - this.labelVideoPlayerPreviewFontSize.Location = new System.Drawing.Point(331, 21); - this.labelVideoPlayerPreviewFontSize.Name = "labelVideoPlayerPreviewFontSize"; - this.labelVideoPlayerPreviewFontSize.Size = new System.Drawing.Size(128, 13); - this.labelVideoPlayerPreviewFontSize.TabIndex = 14; - this.labelVideoPlayerPreviewFontSize.Text = "Subtitle preview font size"; - // - // comboBoxlVideoPlayerPreviewFontSize - // - this.comboBoxlVideoPlayerPreviewFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxlVideoPlayerPreviewFontSize.FormattingEnabled = true; - this.comboBoxlVideoPlayerPreviewFontSize.Items.AddRange(new object[] { - "8", - "9", - "10", - "11", - "12", - "13", - "14", - "15", - "16", - "17", - "18", - "19", - "20", - "21", - "22", - "23", - "24", - "25", - "26", - "27", - "28", - "29", - "30"}); - this.comboBoxlVideoPlayerPreviewFontSize.Location = new System.Drawing.Point(465, 18); - this.comboBoxlVideoPlayerPreviewFontSize.Name = "comboBoxlVideoPlayerPreviewFontSize"; - this.comboBoxlVideoPlayerPreviewFontSize.Size = new System.Drawing.Size(121, 21); - this.comboBoxlVideoPlayerPreviewFontSize.TabIndex = 13; - // - // checkBoxVideoPlayerShowStopButton - // - this.checkBoxVideoPlayerShowStopButton.AutoSize = true; - this.checkBoxVideoPlayerShowStopButton.Location = new System.Drawing.Point(9, 19); - this.checkBoxVideoPlayerShowStopButton.Name = "checkBoxVideoPlayerShowStopButton"; - this.checkBoxVideoPlayerShowStopButton.Size = new System.Drawing.Size(111, 17); - this.checkBoxVideoPlayerShowStopButton.TabIndex = 10; - this.checkBoxVideoPlayerShowStopButton.Text = "Show stop button"; - this.checkBoxVideoPlayerShowStopButton.UseVisualStyleBackColor = true; - // - // groupBoxVideoEngine - // - this.groupBoxVideoEngine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxVideoEngine.Controls.Add(this.checkBoxMpvHandlesPreviewText); - this.groupBoxVideoEngine.Controls.Add(this.labelMpvSettings); - this.groupBoxVideoEngine.Controls.Add(this.buttonMpvSettings); - this.groupBoxVideoEngine.Controls.Add(this.labelPlatform); - this.groupBoxVideoEngine.Controls.Add(this.buttonVlcPathBrowse); - this.groupBoxVideoEngine.Controls.Add(this.textBoxVlcPath); - this.groupBoxVideoEngine.Controls.Add(this.labelVlcPath); - this.groupBoxVideoEngine.Controls.Add(this.labelVideoPlayerVLC); - this.groupBoxVideoEngine.Controls.Add(this.radioButtonVideoPlayerVLC); - this.groupBoxVideoEngine.Controls.Add(this.labelVideoPlayerMPlayer); - this.groupBoxVideoEngine.Controls.Add(this.labelDirectShowDescription); - this.groupBoxVideoEngine.Controls.Add(this.labelMpcHcDescription); - this.groupBoxVideoEngine.Controls.Add(this.radioButtonVideoPlayerMPV); - this.groupBoxVideoEngine.Controls.Add(this.radioButtonVideoPlayerDirectShow); - this.groupBoxVideoEngine.Controls.Add(this.radioButtonVideoPlayerMpcHc); - this.groupBoxVideoEngine.Location = new System.Drawing.Point(6, 6); - this.groupBoxVideoEngine.Name = "groupBoxVideoEngine"; - this.groupBoxVideoEngine.Size = new System.Drawing.Size(820, 143); - this.groupBoxVideoEngine.TabIndex = 0; - this.groupBoxVideoEngine.TabStop = false; - this.groupBoxVideoEngine.Text = "Video engine"; - // - // checkBoxMpvHandlesPreviewText - // - this.checkBoxMpvHandlesPreviewText.AutoSize = true; - this.checkBoxMpvHandlesPreviewText.Location = new System.Drawing.Point(169, 111); - this.checkBoxMpvHandlesPreviewText.Name = "checkBoxMpvHandlesPreviewText"; - this.checkBoxMpvHandlesPreviewText.Size = new System.Drawing.Size(150, 17); - this.checkBoxMpvHandlesPreviewText.TabIndex = 31; - this.checkBoxMpvHandlesPreviewText.Text = "mpv handles preview text"; - this.checkBoxMpvHandlesPreviewText.UseVisualStyleBackColor = true; - // - // labelMpvSettings - // - this.labelMpvSettings.AutoSize = true; - this.labelMpvSettings.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelMpvSettings.ForeColor = System.Drawing.Color.Gray; - this.labelMpvSettings.Location = new System.Drawing.Point(709, 93); - this.labelMpvSettings.Name = "labelMpvSettings"; - this.labelMpvSettings.Size = new System.Drawing.Size(40, 13); - this.labelMpvSettings.TabIndex = 30; - this.labelMpvSettings.Text = "--vo=?"; - // - // buttonMpvSettings - // - this.buttonMpvSettings.Location = new System.Drawing.Point(510, 89); - this.buttonMpvSettings.Name = "buttonMpvSettings"; - this.buttonMpvSettings.Size = new System.Drawing.Size(179, 23); - this.buttonMpvSettings.TabIndex = 29; - this.buttonMpvSettings.Text = "Download mpv dll"; - this.buttonMpvSettings.UseVisualStyleBackColor = true; - this.buttonMpvSettings.Click += new System.EventHandler(this.buttonMpvSettings_Click); - // - // labelPlatform - // - this.labelPlatform.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelPlatform.ForeColor = System.Drawing.Color.Gray; - this.labelPlatform.Location = new System.Drawing.Point(724, 13); - this.labelPlatform.Name = "labelPlatform"; - this.labelPlatform.Size = new System.Drawing.Size(83, 11); - this.labelPlatform.TabIndex = 27; - this.labelPlatform.Text = "x-bit"; - this.labelPlatform.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // buttonVlcPathBrowse - // - this.buttonVlcPathBrowse.Location = new System.Drawing.Point(778, 44); - this.buttonVlcPathBrowse.Name = "buttonVlcPathBrowse"; - this.buttonVlcPathBrowse.Size = new System.Drawing.Size(29, 21); - this.buttonVlcPathBrowse.TabIndex = 26; - this.buttonVlcPathBrowse.Text = "..."; - this.buttonVlcPathBrowse.UseVisualStyleBackColor = true; - this.buttonVlcPathBrowse.Click += new System.EventHandler(this.buttonVlcPathBrowse_Click); - // - // textBoxVlcPath - // - this.textBoxVlcPath.Location = new System.Drawing.Point(410, 45); - this.textBoxVlcPath.MaxLength = 1000; - this.textBoxVlcPath.Name = "textBoxVlcPath"; - this.textBoxVlcPath.Size = new System.Drawing.Size(362, 21); - this.textBoxVlcPath.TabIndex = 25; - this.textBoxVlcPath.MouseLeave += new System.EventHandler(this.textBoxVlcPath_MouseLeave); - // - // labelVlcPath - // - this.labelVlcPath.AutoSize = true; - this.labelVlcPath.Location = new System.Drawing.Point(379, 29); - this.labelVlcPath.Name = "labelVlcPath"; - this.labelVlcPath.Size = new System.Drawing.Size(315, 13); - this.labelVlcPath.TabIndex = 24; - this.labelVlcPath.Text = "VLC path (only needed if you using the portable version of VLC)"; - // - // labelVideoPlayerVLC - // - this.labelVideoPlayerVLC.AutoSize = true; - this.labelVideoPlayerVLC.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelVideoPlayerVLC.ForeColor = System.Drawing.Color.Gray; - this.labelVideoPlayerVLC.Location = new System.Drawing.Point(167, 49); - this.labelVideoPlayerVLC.Name = "labelVideoPlayerVLC"; - this.labelVideoPlayerVLC.Size = new System.Drawing.Size(237, 13); - this.labelVideoPlayerVLC.TabIndex = 13; - this.labelVideoPlayerVLC.Text = "libvlc.dll from VLC media player (1.1.0 or newer)"; - // - // radioButtonVideoPlayerVLC - // - this.radioButtonVideoPlayerVLC.AutoSize = true; - this.radioButtonVideoPlayerVLC.Location = new System.Drawing.Point(10, 46); - this.radioButtonVideoPlayerVLC.Name = "radioButtonVideoPlayerVLC"; - this.radioButtonVideoPlayerVLC.Size = new System.Drawing.Size(43, 17); - this.radioButtonVideoPlayerVLC.TabIndex = 4; - this.radioButtonVideoPlayerVLC.TabStop = true; - this.radioButtonVideoPlayerVLC.Text = "VLC"; - this.radioButtonVideoPlayerVLC.UseVisualStyleBackColor = true; - // - // labelVideoPlayerMPlayer - // - this.labelVideoPlayerMPlayer.AutoSize = true; - this.labelVideoPlayerMPlayer.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelVideoPlayerMPlayer.ForeColor = System.Drawing.Color.Gray; - this.labelVideoPlayerMPlayer.Location = new System.Drawing.Point(167, 93); - this.labelVideoPlayerMPlayer.Name = "labelVideoPlayerMPlayer"; - this.labelVideoPlayerMPlayer.Size = new System.Drawing.Size(337, 13); - this.labelVideoPlayerMPlayer.TabIndex = 11; - this.labelVideoPlayerMPlayer.Text = "https://mpv.io/ - free, open source, and cross-platform media player"; - // - // labelDirectShowDescription - // - this.labelDirectShowDescription.AutoSize = true; - this.labelDirectShowDescription.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelDirectShowDescription.ForeColor = System.Drawing.Color.Gray; - this.labelDirectShowDescription.Location = new System.Drawing.Point(167, 26); - this.labelDirectShowDescription.Name = "labelDirectShowDescription"; - this.labelDirectShowDescription.Size = new System.Drawing.Size(114, 13); - this.labelDirectShowDescription.TabIndex = 10; - this.labelDirectShowDescription.Text = "Quartz.dll in system32"; - // - // labelMpcHcDescription - // - this.labelMpcHcDescription.AutoSize = true; - this.labelMpcHcDescription.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelMpcHcDescription.ForeColor = System.Drawing.Color.Gray; - this.labelMpcHcDescription.Location = new System.Drawing.Point(167, 70); - this.labelMpcHcDescription.Name = "labelMpcHcDescription"; - this.labelMpcHcDescription.Size = new System.Drawing.Size(178, 13); - this.labelMpcHcDescription.TabIndex = 9; - this.labelMpcHcDescription.Text = "Media Player Classic - Home Cinema"; - // - // radioButtonVideoPlayerMPV - // - this.radioButtonVideoPlayerMPV.AutoSize = true; - this.radioButtonVideoPlayerMPV.Location = new System.Drawing.Point(10, 89); - this.radioButtonVideoPlayerMPV.Name = "radioButtonVideoPlayerMPV"; - this.radioButtonVideoPlayerMPV.Size = new System.Drawing.Size(45, 17); - this.radioButtonVideoPlayerMPV.TabIndex = 28; - this.radioButtonVideoPlayerMPV.TabStop = true; - this.radioButtonVideoPlayerMPV.Text = "mpv"; - this.radioButtonVideoPlayerMPV.UseVisualStyleBackColor = true; - this.radioButtonVideoPlayerMPV.CheckedChanged += new System.EventHandler(this.radioButtonVideoPlayerMPV_CheckedChanged); - // - // radioButtonVideoPlayerDirectShow - // - this.radioButtonVideoPlayerDirectShow.AutoSize = true; - this.radioButtonVideoPlayerDirectShow.Location = new System.Drawing.Point(10, 23); - this.radioButtonVideoPlayerDirectShow.Name = "radioButtonVideoPlayerDirectShow"; - this.radioButtonVideoPlayerDirectShow.Size = new System.Drawing.Size(82, 17); - this.radioButtonVideoPlayerDirectShow.TabIndex = 1; - this.radioButtonVideoPlayerDirectShow.TabStop = true; - this.radioButtonVideoPlayerDirectShow.Text = "DirectShow "; - this.radioButtonVideoPlayerDirectShow.UseVisualStyleBackColor = true; - // - // radioButtonVideoPlayerMpcHc - // - this.radioButtonVideoPlayerMpcHc.AutoSize = true; - this.radioButtonVideoPlayerMpcHc.Location = new System.Drawing.Point(10, 66); - this.radioButtonVideoPlayerMpcHc.Name = "radioButtonVideoPlayerMpcHc"; - this.radioButtonVideoPlayerMpcHc.Size = new System.Drawing.Size(64, 17); - this.radioButtonVideoPlayerMpcHc.TabIndex = 27; - this.radioButtonVideoPlayerMpcHc.TabStop = true; - this.radioButtonVideoPlayerMpcHc.Text = "MPC-HC"; - this.radioButtonVideoPlayerMpcHc.UseVisualStyleBackColor = true; - // - // tabPageWaveform - // - this.tabPageWaveform.Controls.Add(this.groupBoxFfmpeg); - this.tabPageWaveform.Controls.Add(this.groupBoxSpectrogram); - this.tabPageWaveform.Controls.Add(this.groupBox1); - this.tabPageWaveform.Controls.Add(this.groupBoxWaveformAppearence); - this.tabPageWaveform.Location = new System.Drawing.Point(4, 22); - this.tabPageWaveform.Name = "tabPageWaveform"; - this.tabPageWaveform.Size = new System.Drawing.Size(832, 520); - this.tabPageWaveform.TabIndex = 6; - this.tabPageWaveform.Text = "Waveform/spectrogram"; - this.tabPageWaveform.UseVisualStyleBackColor = true; - // - // groupBoxFfmpeg - // - this.groupBoxFfmpeg.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxFfmpeg.Controls.Add(this.buttonDownloadFfmpeg); - this.groupBoxFfmpeg.Controls.Add(this.buttonBrowseToFFmpeg); - this.groupBoxFfmpeg.Controls.Add(this.textBoxFFmpegPath); - this.groupBoxFfmpeg.Controls.Add(this.labelFFmpegPath); - this.groupBoxFfmpeg.Controls.Add(this.checkBoxUseFFmpeg); - this.groupBoxFfmpeg.Location = new System.Drawing.Point(406, 299); - this.groupBoxFfmpeg.Name = "groupBoxFfmpeg"; - this.groupBoxFfmpeg.Size = new System.Drawing.Size(419, 118); - this.groupBoxFfmpeg.TabIndex = 2; - this.groupBoxFfmpeg.TabStop = false; - this.groupBoxFfmpeg.Text = "FFmpeg"; - // - // buttonDownloadFfmpeg - // - this.buttonDownloadFfmpeg.Location = new System.Drawing.Point(274, 17); - this.buttonDownloadFfmpeg.Name = "buttonDownloadFfmpeg"; - this.buttonDownloadFfmpeg.Size = new System.Drawing.Size(136, 23); - this.buttonDownloadFfmpeg.TabIndex = 2; - this.buttonDownloadFfmpeg.Text = "Download ffmpeg"; - this.buttonDownloadFfmpeg.UseVisualStyleBackColor = true; - this.buttonDownloadFfmpeg.Click += new System.EventHandler(this.buttonDownloadFfmpeg_Click); - // - // buttonBrowseToFFmpeg - // - this.buttonBrowseToFFmpeg.Location = new System.Drawing.Point(381, 65); - this.buttonBrowseToFFmpeg.Name = "buttonBrowseToFFmpeg"; - this.buttonBrowseToFFmpeg.Size = new System.Drawing.Size(29, 21); - this.buttonBrowseToFFmpeg.TabIndex = 23; - this.buttonBrowseToFFmpeg.Text = "..."; - this.buttonBrowseToFFmpeg.UseVisualStyleBackColor = true; - this.buttonBrowseToFFmpeg.Click += new System.EventHandler(this.buttonBrowseToFFmpeg_Click); - // - // textBoxFFmpegPath - // - this.textBoxFFmpegPath.Location = new System.Drawing.Point(9, 65); - this.textBoxFFmpegPath.MaxLength = 1000; - this.textBoxFFmpegPath.Name = "textBoxFFmpegPath"; - this.textBoxFFmpegPath.Size = new System.Drawing.Size(366, 21); - this.textBoxFFmpegPath.TabIndex = 22; - // - // labelFFmpegPath - // - this.labelFFmpegPath.AutoSize = true; - this.labelFFmpegPath.Location = new System.Drawing.Point(6, 49); - this.labelFFmpegPath.Name = "labelFFmpegPath"; - this.labelFFmpegPath.Size = new System.Drawing.Size(70, 13); - this.labelFFmpegPath.TabIndex = 2; - this.labelFFmpegPath.Text = "FFmpeg path"; - // - // checkBoxUseFFmpeg - // - this.checkBoxUseFFmpeg.AutoSize = true; - this.checkBoxUseFFmpeg.Location = new System.Drawing.Point(6, 20); - this.checkBoxUseFFmpeg.Name = "checkBoxUseFFmpeg"; - this.checkBoxUseFFmpeg.Size = new System.Drawing.Size(200, 17); - this.checkBoxUseFFmpeg.TabIndex = 1; - this.checkBoxUseFFmpeg.Text = "Use FFmpeg for wave file extraction"; - this.checkBoxUseFFmpeg.UseVisualStyleBackColor = true; - // - // groupBoxSpectrogram - // - this.groupBoxSpectrogram.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxSpectrogram.Controls.Add(this.labelSpectrogramAppearance); - this.groupBoxSpectrogram.Controls.Add(this.comboBoxSpectrogramAppearance); - this.groupBoxSpectrogram.Controls.Add(this.checkBoxGenerateSpectrogram); - this.groupBoxSpectrogram.Location = new System.Drawing.Point(6, 299); - this.groupBoxSpectrogram.Name = "groupBoxSpectrogram"; - this.groupBoxSpectrogram.Size = new System.Drawing.Size(394, 118); - this.groupBoxSpectrogram.TabIndex = 1; - this.groupBoxSpectrogram.TabStop = false; - this.groupBoxSpectrogram.Text = "Spectrogram"; - // - // labelSpectrogramAppearance - // - this.labelSpectrogramAppearance.AutoSize = true; - this.labelSpectrogramAppearance.Location = new System.Drawing.Point(10, 52); - this.labelSpectrogramAppearance.Name = "labelSpectrogramAppearance"; - this.labelSpectrogramAppearance.Size = new System.Drawing.Size(164, 13); - this.labelSpectrogramAppearance.TabIndex = 1; - this.labelSpectrogramAppearance.Text = "Appearance (at generation time)"; - // - // comboBoxSpectrogramAppearance - // - this.comboBoxSpectrogramAppearance.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSpectrogramAppearance.FormattingEnabled = true; - this.comboBoxSpectrogramAppearance.Items.AddRange(new object[] { - "Classic", - "Use waveform color (one color gradient)"}); - this.comboBoxSpectrogramAppearance.Location = new System.Drawing.Point(10, 70); - this.comboBoxSpectrogramAppearance.Name = "comboBoxSpectrogramAppearance"; - this.comboBoxSpectrogramAppearance.Size = new System.Drawing.Size(325, 21); - this.comboBoxSpectrogramAppearance.TabIndex = 2; - // - // checkBoxGenerateSpectrogram - // - this.checkBoxGenerateSpectrogram.AutoSize = true; - this.checkBoxGenerateSpectrogram.Location = new System.Drawing.Point(10, 20); - this.checkBoxGenerateSpectrogram.Name = "checkBoxGenerateSpectrogram"; - this.checkBoxGenerateSpectrogram.Size = new System.Drawing.Size(134, 17); - this.checkBoxGenerateSpectrogram.TabIndex = 0; - this.checkBoxGenerateSpectrogram.Text = "Generate spectrogram"; - this.checkBoxGenerateSpectrogram.UseVisualStyleBackColor = true; - // - // groupBox1 - // - this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.groupBox1.Controls.Add(this.buttonWaveformsFolderEmpty); - this.groupBox1.Controls.Add(this.labelWaveformsFolderInfo); - this.groupBox1.Location = new System.Drawing.Point(10, 423); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(819, 80); - this.groupBox1.TabIndex = 3; - this.groupBox1.TabStop = false; - // - // buttonWaveformsFolderEmpty - // - this.buttonWaveformsFolderEmpty.Location = new System.Drawing.Point(10, 37); - this.buttonWaveformsFolderEmpty.Name = "buttonWaveformsFolderEmpty"; - this.buttonWaveformsFolderEmpty.Size = new System.Drawing.Size(325, 23); - this.buttonWaveformsFolderEmpty.TabIndex = 1; - this.buttonWaveformsFolderEmpty.Text = "Empty \'Waveforms\' folder"; - this.buttonWaveformsFolderEmpty.UseVisualStyleBackColor = true; - this.buttonWaveformsFolderEmpty.Click += new System.EventHandler(this.buttonWaveformsFolderEmpty_Click); - // - // labelWaveformsFolderInfo - // - this.labelWaveformsFolderInfo.AutoSize = true; - this.labelWaveformsFolderInfo.Location = new System.Drawing.Point(10, 20); - this.labelWaveformsFolderInfo.Name = "labelWaveformsFolderInfo"; - this.labelWaveformsFolderInfo.Size = new System.Drawing.Size(205, 13); - this.labelWaveformsFolderInfo.TabIndex = 0; - this.labelWaveformsFolderInfo.Text = "\'Waveforms\' folder contains x files (x mb)"; - // - // groupBoxWaveformAppearence - // - this.groupBoxWaveformAppearence.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxWaveformAppearence.Controls.Add(this.panelWaveformCursorColor); - this.groupBoxWaveformAppearence.Controls.Add(this.buttonWaveformCursorColor); - this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformSnapToSceneChanges); - this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformSingleClickSelect); - this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformShowWpm); - this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformShowCps); - this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformSetVideoPosMoveStartEnd); - this.groupBoxWaveformAppearence.Controls.Add(this.labelWaveformTextSize); - this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformTextBold); - this.groupBoxWaveformAppearence.Controls.Add(this.comboBoxWaveformTextSize); - this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxListViewMouseEnterFocus); - this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformHoverFocus); - this.groupBoxWaveformAppearence.Controls.Add(this.labelWaveformBorderHitMs2); - this.groupBoxWaveformAppearence.Controls.Add(this.numericUpDownWaveformBorderHitMs); - this.groupBoxWaveformAppearence.Controls.Add(this.labelWaveformBorderHitMs1); - this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxAllowOverlap); - this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxReverseMouseWheelScrollDirection); - this.groupBoxWaveformAppearence.Controls.Add(this.panelWaveformTextColor); - this.groupBoxWaveformAppearence.Controls.Add(this.buttonWaveformTextColor); - this.groupBoxWaveformAppearence.Controls.Add(this.panelWaveformGridColor); - this.groupBoxWaveformAppearence.Controls.Add(this.buttonWaveformGridColor); - this.groupBoxWaveformAppearence.Controls.Add(this.panelWaveformBackgroundColor); - this.groupBoxWaveformAppearence.Controls.Add(this.buttonWaveformBackgroundColor); - this.groupBoxWaveformAppearence.Controls.Add(this.panelWaveformColor); - this.groupBoxWaveformAppearence.Controls.Add(this.buttonWaveformColor); - this.groupBoxWaveformAppearence.Controls.Add(this.panelWaveformSelectedColor); - this.groupBoxWaveformAppearence.Controls.Add(this.buttonWaveformSelectedColor); - this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformShowGrid); - this.groupBoxWaveformAppearence.Location = new System.Drawing.Point(6, 6); - this.groupBoxWaveformAppearence.Name = "groupBoxWaveformAppearence"; - this.groupBoxWaveformAppearence.Size = new System.Drawing.Size(819, 287); - this.groupBoxWaveformAppearence.TabIndex = 0; - this.groupBoxWaveformAppearence.TabStop = false; - this.groupBoxWaveformAppearence.Text = "Waveform appearance"; - // - // panelWaveformCursorColor - // - this.panelWaveformCursorColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelWaveformCursorColor.Location = new System.Drawing.Point(138, 142); - this.panelWaveformCursorColor.Name = "panelWaveformCursorColor"; - this.panelWaveformCursorColor.Size = new System.Drawing.Size(21, 20); - this.panelWaveformCursorColor.TabIndex = 34; - this.panelWaveformCursorColor.Click += new System.EventHandler(this.buttonWaveformCursorColor_Click); - // - // buttonWaveformCursorColor - // - this.buttonWaveformCursorColor.Location = new System.Drawing.Point(14, 141); - this.buttonWaveformCursorColor.Name = "buttonWaveformCursorColor"; - this.buttonWaveformCursorColor.Size = new System.Drawing.Size(112, 23); - this.buttonWaveformCursorColor.TabIndex = 4; - this.buttonWaveformCursorColor.Text = "Cursor color"; - this.buttonWaveformCursorColor.UseVisualStyleBackColor = true; - this.buttonWaveformCursorColor.Click += new System.EventHandler(this.buttonWaveformCursorColor_Click); - // - // checkBoxWaveformSnapToSceneChanges - // - this.checkBoxWaveformSnapToSceneChanges.AutoSize = true; - this.checkBoxWaveformSnapToSceneChanges.Location = new System.Drawing.Point(262, 161); - this.checkBoxWaveformSnapToSceneChanges.Name = "checkBoxWaveformSnapToSceneChanges"; - this.checkBoxWaveformSnapToSceneChanges.Size = new System.Drawing.Size(249, 17); - this.checkBoxWaveformSnapToSceneChanges.TabIndex = 26; - this.checkBoxWaveformSnapToSceneChanges.Text = "Snap to scene changes (hold Shift to override)"; - this.checkBoxWaveformSnapToSceneChanges.UseVisualStyleBackColor = true; - // - // checkBoxWaveformSingleClickSelect - // - this.checkBoxWaveformSingleClickSelect.AutoSize = true; - this.checkBoxWaveformSingleClickSelect.Location = new System.Drawing.Point(262, 138); - this.checkBoxWaveformSingleClickSelect.Name = "checkBoxWaveformSingleClickSelect"; - this.checkBoxWaveformSingleClickSelect.Size = new System.Drawing.Size(178, 17); - this.checkBoxWaveformSingleClickSelect.TabIndex = 25; - this.checkBoxWaveformSingleClickSelect.Text = "Single click to select paragraphs"; - this.checkBoxWaveformSingleClickSelect.UseVisualStyleBackColor = true; - // - // checkBoxWaveformShowWpm - // - this.checkBoxWaveformShowWpm.AutoSize = true; - this.checkBoxWaveformShowWpm.Location = new System.Drawing.Point(16, 256); - this.checkBoxWaveformShowWpm.Name = "checkBoxWaveformShowWpm"; - this.checkBoxWaveformShowWpm.Size = new System.Drawing.Size(104, 17); - this.checkBoxWaveformShowWpm.TabIndex = 8; - this.checkBoxWaveformShowWpm.Text = "Show words/min"; - this.checkBoxWaveformShowWpm.UseVisualStyleBackColor = true; - // - // checkBoxWaveformShowCps - // - this.checkBoxWaveformShowCps.AutoSize = true; - this.checkBoxWaveformShowCps.Location = new System.Drawing.Point(16, 233); - this.checkBoxWaveformShowCps.Name = "checkBoxWaveformShowCps"; - this.checkBoxWaveformShowCps.Size = new System.Drawing.Size(96, 17); - this.checkBoxWaveformShowCps.TabIndex = 7; - this.checkBoxWaveformShowCps.Text = "Show char/sec"; - this.checkBoxWaveformShowCps.UseVisualStyleBackColor = true; - // - // checkBoxWaveformSetVideoPosMoveStartEnd - // - this.checkBoxWaveformSetVideoPosMoveStartEnd.AutoSize = true; - this.checkBoxWaveformSetVideoPosMoveStartEnd.Location = new System.Drawing.Point(262, 73); - this.checkBoxWaveformSetVideoPosMoveStartEnd.Name = "checkBoxWaveformSetVideoPosMoveStartEnd"; - this.checkBoxWaveformSetVideoPosMoveStartEnd.Size = new System.Drawing.Size(225, 17); - this.checkBoxWaveformSetVideoPosMoveStartEnd.TabIndex = 22; - this.checkBoxWaveformSetVideoPosMoveStartEnd.Text = "Set video position when moving start/end"; - this.checkBoxWaveformSetVideoPosMoveStartEnd.UseVisualStyleBackColor = true; - // - // labelWaveformTextSize - // - this.labelWaveformTextSize.AutoSize = true; - this.labelWaveformTextSize.Location = new System.Drawing.Point(259, 194); - this.labelWaveformTextSize.Name = "labelWaveformTextSize"; - this.labelWaveformTextSize.Size = new System.Drawing.Size(73, 13); - this.labelWaveformTextSize.TabIndex = 27; - this.labelWaveformTextSize.Text = "Text font size"; - // - // checkBoxWaveformTextBold - // - this.checkBoxWaveformTextBold.AutoSize = true; - this.checkBoxWaveformTextBold.Location = new System.Drawing.Point(463, 195); - this.checkBoxWaveformTextBold.Name = "checkBoxWaveformTextBold"; - this.checkBoxWaveformTextBold.Size = new System.Drawing.Size(46, 17); - this.checkBoxWaveformTextBold.TabIndex = 29; - this.checkBoxWaveformTextBold.Text = "Bold"; - this.checkBoxWaveformTextBold.UseVisualStyleBackColor = true; - // - // comboBoxWaveformTextSize - // - this.comboBoxWaveformTextSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxWaveformTextSize.FormattingEnabled = true; - this.comboBoxWaveformTextSize.Items.AddRange(new object[] { - "7", - "8", - "9", - "10", - "11", - "12", - "13", - "14", - "15", - "16", - "17", - "18", - "19", - "20"}); - this.comboBoxWaveformTextSize.Location = new System.Drawing.Point(336, 191); - this.comboBoxWaveformTextSize.Name = "comboBoxWaveformTextSize"; - this.comboBoxWaveformTextSize.Size = new System.Drawing.Size(121, 21); - this.comboBoxWaveformTextSize.TabIndex = 28; - // - // checkBoxListViewMouseEnterFocus - // - this.checkBoxListViewMouseEnterFocus.AutoSize = true; - this.checkBoxListViewMouseEnterFocus.Location = new System.Drawing.Point(281, 115); - this.checkBoxListViewMouseEnterFocus.Name = "checkBoxListViewMouseEnterFocus"; - this.checkBoxListViewMouseEnterFocus.Size = new System.Drawing.Size(214, 17); - this.checkBoxListViewMouseEnterFocus.TabIndex = 24; - this.checkBoxListViewMouseEnterFocus.Text = "Focus list view on list view mouse enter"; - this.checkBoxListViewMouseEnterFocus.UseVisualStyleBackColor = true; - // - // checkBoxWaveformHoverFocus - // - this.checkBoxWaveformHoverFocus.AutoSize = true; - this.checkBoxWaveformHoverFocus.Location = new System.Drawing.Point(262, 96); - this.checkBoxWaveformHoverFocus.Name = "checkBoxWaveformHoverFocus"; - this.checkBoxWaveformHoverFocus.Size = new System.Drawing.Size(149, 17); - this.checkBoxWaveformHoverFocus.TabIndex = 23; - this.checkBoxWaveformHoverFocus.Text = "Set focus on mouse enter"; - this.checkBoxWaveformHoverFocus.UseVisualStyleBackColor = true; - this.checkBoxWaveformHoverFocus.CheckedChanged += new System.EventHandler(this.checkBoxWaveformHoverFocus_CheckedChanged); - // - // labelWaveformBorderHitMs2 - // - this.labelWaveformBorderHitMs2.AutoSize = true; - this.labelWaveformBorderHitMs2.Location = new System.Drawing.Point(454, 224); - this.labelWaveformBorderHitMs2.Name = "labelWaveformBorderHitMs2"; - this.labelWaveformBorderHitMs2.Size = new System.Drawing.Size(62, 13); - this.labelWaveformBorderHitMs2.TabIndex = 32; - this.labelWaveformBorderHitMs2.Text = "milliseconds"; - // - // numericUpDownWaveformBorderHitMs - // - this.numericUpDownWaveformBorderHitMs.Location = new System.Drawing.Point(392, 222); - this.numericUpDownWaveformBorderHitMs.Minimum = new decimal(new int[] { - 10, - 0, - 0, - 0}); - this.numericUpDownWaveformBorderHitMs.Name = "numericUpDownWaveformBorderHitMs"; - this.numericUpDownWaveformBorderHitMs.Size = new System.Drawing.Size(44, 21); - this.numericUpDownWaveformBorderHitMs.TabIndex = 31; - this.numericUpDownWaveformBorderHitMs.Value = new decimal(new int[] { - 18, - 0, - 0, - 0}); - // - // labelWaveformBorderHitMs1 - // - this.labelWaveformBorderHitMs1.AutoSize = true; - this.labelWaveformBorderHitMs1.Location = new System.Drawing.Point(259, 224); - this.labelWaveformBorderHitMs1.Name = "labelWaveformBorderHitMs1"; - this.labelWaveformBorderHitMs1.Size = new System.Drawing.Size(127, 13); - this.labelWaveformBorderHitMs1.TabIndex = 30; - this.labelWaveformBorderHitMs1.Text = "Marker hit must be within"; - // - // checkBoxAllowOverlap - // - this.checkBoxAllowOverlap.AutoSize = true; - this.checkBoxAllowOverlap.Location = new System.Drawing.Point(262, 50); - this.checkBoxAllowOverlap.Name = "checkBoxAllowOverlap"; - this.checkBoxAllowOverlap.Size = new System.Drawing.Size(212, 17); - this.checkBoxAllowOverlap.TabIndex = 21; - this.checkBoxAllowOverlap.Text = "Allow overlap (when dragging/resizing)"; - this.checkBoxAllowOverlap.UseVisualStyleBackColor = true; - // - // checkBoxReverseMouseWheelScrollDirection - // - this.checkBoxReverseMouseWheelScrollDirection.AutoSize = true; - this.checkBoxReverseMouseWheelScrollDirection.Location = new System.Drawing.Point(262, 27); - this.checkBoxReverseMouseWheelScrollDirection.Name = "checkBoxReverseMouseWheelScrollDirection"; - this.checkBoxReverseMouseWheelScrollDirection.Size = new System.Drawing.Size(202, 17); - this.checkBoxReverseMouseWheelScrollDirection.TabIndex = 20; - this.checkBoxReverseMouseWheelScrollDirection.Text = "Reverse mouse wheel scroll direction"; - this.checkBoxReverseMouseWheelScrollDirection.UseVisualStyleBackColor = true; - // - // panelWaveformTextColor - // - this.panelWaveformTextColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelWaveformTextColor.Location = new System.Drawing.Point(138, 113); - this.panelWaveformTextColor.Name = "panelWaveformTextColor"; - this.panelWaveformTextColor.Size = new System.Drawing.Size(21, 20); - this.panelWaveformTextColor.TabIndex = 7; - this.panelWaveformTextColor.Click += new System.EventHandler(this.buttonWaveformTextColor_Click); - // - // buttonWaveformTextColor - // - this.buttonWaveformTextColor.Location = new System.Drawing.Point(14, 112); - this.buttonWaveformTextColor.Name = "buttonWaveformTextColor"; - this.buttonWaveformTextColor.Size = new System.Drawing.Size(112, 23); - this.buttonWaveformTextColor.TabIndex = 3; - this.buttonWaveformTextColor.Text = "Text color"; - this.buttonWaveformTextColor.UseVisualStyleBackColor = true; - this.buttonWaveformTextColor.Click += new System.EventHandler(this.buttonWaveformTextColor_Click); - // - // panelWaveformGridColor - // - this.panelWaveformGridColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelWaveformGridColor.Location = new System.Drawing.Point(138, 171); - this.panelWaveformGridColor.Name = "panelWaveformGridColor"; - this.panelWaveformGridColor.Size = new System.Drawing.Size(21, 20); - this.panelWaveformGridColor.TabIndex = 9; - this.panelWaveformGridColor.Click += new System.EventHandler(this.buttonWaveformGridColor_Click); - // - // buttonWaveformGridColor - // - this.buttonWaveformGridColor.Location = new System.Drawing.Point(14, 170); - this.buttonWaveformGridColor.Name = "buttonWaveformGridColor"; - this.buttonWaveformGridColor.Size = new System.Drawing.Size(112, 23); - this.buttonWaveformGridColor.TabIndex = 5; - this.buttonWaveformGridColor.Text = "Grid color"; - this.buttonWaveformGridColor.UseVisualStyleBackColor = true; - this.buttonWaveformGridColor.Click += new System.EventHandler(this.buttonWaveformGridColor_Click); - // - // panelWaveformBackgroundColor - // - this.panelWaveformBackgroundColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelWaveformBackgroundColor.Location = new System.Drawing.Point(138, 84); - this.panelWaveformBackgroundColor.Name = "panelWaveformBackgroundColor"; - this.panelWaveformBackgroundColor.Size = new System.Drawing.Size(21, 20); - this.panelWaveformBackgroundColor.TabIndex = 5; - this.panelWaveformBackgroundColor.Click += new System.EventHandler(this.buttonWaveformBackgroundColor_Click); - // - // buttonWaveformBackgroundColor - // - this.buttonWaveformBackgroundColor.Location = new System.Drawing.Point(14, 83); - this.buttonWaveformBackgroundColor.Name = "buttonWaveformBackgroundColor"; - this.buttonWaveformBackgroundColor.Size = new System.Drawing.Size(112, 23); - this.buttonWaveformBackgroundColor.TabIndex = 2; - this.buttonWaveformBackgroundColor.Text = "Back color"; - this.buttonWaveformBackgroundColor.UseVisualStyleBackColor = true; - this.buttonWaveformBackgroundColor.Click += new System.EventHandler(this.buttonWaveformBackgroundColor_Click); - // - // panelWaveformColor - // - this.panelWaveformColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelWaveformColor.Location = new System.Drawing.Point(138, 55); - this.panelWaveformColor.Name = "panelWaveformColor"; - this.panelWaveformColor.Size = new System.Drawing.Size(21, 20); - this.panelWaveformColor.TabIndex = 3; - this.panelWaveformColor.Click += new System.EventHandler(this.buttonWaveformColor_Click); - // - // buttonWaveformColor - // - this.buttonWaveformColor.Location = new System.Drawing.Point(14, 54); - this.buttonWaveformColor.Name = "buttonWaveformColor"; - this.buttonWaveformColor.Size = new System.Drawing.Size(112, 23); - this.buttonWaveformColor.TabIndex = 1; - this.buttonWaveformColor.Text = "Color"; - this.buttonWaveformColor.UseVisualStyleBackColor = true; - this.buttonWaveformColor.Click += new System.EventHandler(this.buttonWaveformColor_Click); - // - // panelWaveformSelectedColor - // - this.panelWaveformSelectedColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelWaveformSelectedColor.Location = new System.Drawing.Point(138, 26); - this.panelWaveformSelectedColor.Name = "panelWaveformSelectedColor"; - this.panelWaveformSelectedColor.Size = new System.Drawing.Size(21, 20); - this.panelWaveformSelectedColor.TabIndex = 1; - this.panelWaveformSelectedColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.buttonWaveformSelectedColor_Click); - // - // buttonWaveformSelectedColor - // - this.buttonWaveformSelectedColor.Location = new System.Drawing.Point(14, 25); - this.buttonWaveformSelectedColor.Name = "buttonWaveformSelectedColor"; - this.buttonWaveformSelectedColor.Size = new System.Drawing.Size(112, 23); - this.buttonWaveformSelectedColor.TabIndex = 0; - this.buttonWaveformSelectedColor.Text = "Selected color"; - this.buttonWaveformSelectedColor.UseVisualStyleBackColor = true; - this.buttonWaveformSelectedColor.Click += new System.EventHandler(this.buttonWaveformSelectedColor_Click); - // - // checkBoxWaveformShowGrid - // - this.checkBoxWaveformShowGrid.AutoSize = true; - this.checkBoxWaveformShowGrid.Location = new System.Drawing.Point(16, 201); - this.checkBoxWaveformShowGrid.Name = "checkBoxWaveformShowGrid"; - this.checkBoxWaveformShowGrid.Size = new System.Drawing.Size(73, 17); - this.checkBoxWaveformShowGrid.TabIndex = 6; - this.checkBoxWaveformShowGrid.Text = "Show grid"; - this.checkBoxWaveformShowGrid.UseVisualStyleBackColor = true; - // - // tabPageTools - // - this.tabPageTools.Controls.Add(this.groupBoxGoogleTranslate); - this.tabPageTools.Controls.Add(this.groupBoxBing); - this.tabPageTools.Controls.Add(this.groupBoxToolsAutoBr); - this.tabPageTools.Controls.Add(this.groupBoxSpellCheck); - this.tabPageTools.Controls.Add(this.groupBoxFixCommonErrors); - this.tabPageTools.Controls.Add(this.groupBoxToolsVisualSync); - this.tabPageTools.Location = new System.Drawing.Point(4, 22); - this.tabPageTools.Name = "tabPageTools"; - this.tabPageTools.Padding = new System.Windows.Forms.Padding(3); - this.tabPageTools.Size = new System.Drawing.Size(832, 520); - this.tabPageTools.TabIndex = 5; - this.tabPageTools.Text = "Tools"; - this.tabPageTools.UseVisualStyleBackColor = true; - // - // groupBoxGoogleTranslate - // - this.groupBoxGoogleTranslate.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxGoogleTranslate.Controls.Add(this.labelGoogleTranslateApiKey); - this.groupBoxGoogleTranslate.Controls.Add(this.textBoxGoogleTransleApiKey); - this.groupBoxGoogleTranslate.Controls.Add(this.linkLabelGoogleTranslateSignUp); - this.groupBoxGoogleTranslate.Controls.Add(this.label3); - this.groupBoxGoogleTranslate.Location = new System.Drawing.Point(421, 244); - this.groupBoxGoogleTranslate.Name = "groupBoxGoogleTranslate"; - this.groupBoxGoogleTranslate.Size = new System.Drawing.Size(404, 78); - this.groupBoxGoogleTranslate.TabIndex = 31; - this.groupBoxGoogleTranslate.TabStop = false; - this.groupBoxGoogleTranslate.Text = "Google translate"; - // - // labelGoogleTranslateApiKey - // - this.labelGoogleTranslateApiKey.AutoSize = true; - this.labelGoogleTranslateApiKey.Location = new System.Drawing.Point(13, 47); - this.labelGoogleTranslateApiKey.Name = "labelGoogleTranslateApiKey"; - this.labelGoogleTranslateApiKey.Size = new System.Drawing.Size(44, 13); - this.labelGoogleTranslateApiKey.TabIndex = 30; - this.labelGoogleTranslateApiKey.Text = "API key"; - // - // textBoxGoogleTransleApiKey - // - this.textBoxGoogleTransleApiKey.Location = new System.Drawing.Point(94, 47); - this.textBoxGoogleTransleApiKey.Name = "textBoxGoogleTransleApiKey"; - this.textBoxGoogleTransleApiKey.Size = new System.Drawing.Size(290, 21); - this.textBoxGoogleTransleApiKey.TabIndex = 26; - // - // linkLabelGoogleTranslateSignUp - // - this.linkLabelGoogleTranslateSignUp.AutoSize = true; - this.linkLabelGoogleTranslateSignUp.Location = new System.Drawing.Point(306, 19); - this.linkLabelGoogleTranslateSignUp.Name = "linkLabelGoogleTranslateSignUp"; - this.linkLabelGoogleTranslateSignUp.Size = new System.Drawing.Size(78, 13); - this.linkLabelGoogleTranslateSignUp.TabIndex = 24; - this.linkLabelGoogleTranslateSignUp.TabStop = true; - this.linkLabelGoogleTranslateSignUp.Text = "How to sign up"; - this.linkLabelGoogleTranslateSignUp.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelGoogleTranslateSignUp_LinkClicked); - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(16, 106); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(0, 13); - this.label3.TabIndex = 25; - // - // groupBoxBing - // - this.groupBoxBing.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxBing.Controls.Add(this.comboBoxBoxBingTokenEndpoint); - this.groupBoxBing.Controls.Add(this.labelBingTokenEndpoint); - this.groupBoxBing.Controls.Add(this.labelBingApiKey); - this.groupBoxBing.Controls.Add(this.textBoxBingClientSecret); - this.groupBoxBing.Controls.Add(this.linkLabelBingSubscribe); - this.groupBoxBing.Controls.Add(this.label1); - this.groupBoxBing.Location = new System.Drawing.Point(421, 331); - this.groupBoxBing.Name = "groupBoxBing"; - this.groupBoxBing.Size = new System.Drawing.Size(404, 183); - this.groupBoxBing.TabIndex = 32; - this.groupBoxBing.TabStop = false; - this.groupBoxBing.Text = "Bing translator"; - // - // comboBoxBoxBingTokenEndpoint - // - this.comboBoxBoxBingTokenEndpoint.FormattingEnabled = true; - this.comboBoxBoxBingTokenEndpoint.Items.AddRange(new object[] { - "https://api.cognitive.microsoft.com/sts/v1.0/issueToken", - "https://.api.cognitive.microsoft.com/sts/v1.0/issueToken"}); - this.comboBoxBoxBingTokenEndpoint.Location = new System.Drawing.Point(9, 101); - this.comboBoxBoxBingTokenEndpoint.Name = "comboBoxBoxBingTokenEndpoint"; - this.comboBoxBoxBingTokenEndpoint.Size = new System.Drawing.Size(375, 21); - this.comboBoxBoxBingTokenEndpoint.TabIndex = 33; - // - // labelBingTokenEndpoint - // - this.labelBingTokenEndpoint.AutoSize = true; - this.labelBingTokenEndpoint.Location = new System.Drawing.Point(6, 83); - this.labelBingTokenEndpoint.Name = "labelBingTokenEndpoint"; - this.labelBingTokenEndpoint.Size = new System.Drawing.Size(81, 13); - this.labelBingTokenEndpoint.TabIndex = 32; - this.labelBingTokenEndpoint.Text = "Token endpoint"; - // - // labelBingApiKey - // - this.labelBingApiKey.AutoSize = true; - this.labelBingApiKey.Location = new System.Drawing.Point(6, 29); - this.labelBingApiKey.Name = "labelBingApiKey"; - this.labelBingApiKey.Size = new System.Drawing.Size(44, 13); - this.labelBingApiKey.TabIndex = 30; - this.labelBingApiKey.Text = "API key"; - // - // textBoxBingClientSecret - // - this.textBoxBingClientSecret.Location = new System.Drawing.Point(10, 45); - this.textBoxBingClientSecret.Name = "textBoxBingClientSecret"; - this.textBoxBingClientSecret.Size = new System.Drawing.Size(374, 21); - this.textBoxBingClientSecret.TabIndex = 26; - // - // linkLabelBingSubscribe - // - this.linkLabelBingSubscribe.AutoSize = true; - this.linkLabelBingSubscribe.Location = new System.Drawing.Point(306, 17); - this.linkLabelBingSubscribe.Name = "linkLabelBingSubscribe"; - this.linkLabelBingSubscribe.Size = new System.Drawing.Size(78, 13); - this.linkLabelBingSubscribe.TabIndex = 24; - this.linkLabelBingSubscribe.TabStop = true; - this.linkLabelBingSubscribe.Text = "How to sign up"; - this.linkLabelBingSubscribe.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelBingSubscribe_LinkClicked); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(16, 106); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(0, 13); - this.label1.TabIndex = 25; - // - // groupBoxToolsAutoBr - // - this.groupBoxToolsAutoBr.Controls.Add(this.labelToolsBreakBottomHeavyPercent); - this.groupBoxToolsAutoBr.Controls.Add(this.numericUpDownToolsBreakPreferBottomHeavy); - this.groupBoxToolsAutoBr.Controls.Add(this.checkBoxToolsBreakPreferBottomHeavy); - this.groupBoxToolsAutoBr.Controls.Add(this.checkBoxToolsBreakByPixelWidth); - this.groupBoxToolsAutoBr.Controls.Add(this.checkBoxToolsBreakEarlyLineEnding); - this.groupBoxToolsAutoBr.Controls.Add(this.checkBoxToolsBreakEarlyComma); - this.groupBoxToolsAutoBr.Controls.Add(this.checkBoxToolsBreakEarlyDash); - this.groupBoxToolsAutoBr.Controls.Add(this.labelUserBingApiId); - this.groupBoxToolsAutoBr.Controls.Add(this.buttonEditDoNotBreakAfterList); - this.groupBoxToolsAutoBr.Controls.Add(this.checkBoxUseDoNotBreakAfterList); - this.groupBoxToolsAutoBr.Location = new System.Drawing.Point(421, 6); - this.groupBoxToolsAutoBr.Name = "groupBoxToolsAutoBr"; - this.groupBoxToolsAutoBr.Size = new System.Drawing.Size(404, 232); - this.groupBoxToolsAutoBr.TabIndex = 5; - this.groupBoxToolsAutoBr.TabStop = false; - this.groupBoxToolsAutoBr.Text = "Auto br"; - // - // labelToolsBreakBottomHeavyPercent - // - this.labelToolsBreakBottomHeavyPercent.AutoSize = true; - this.labelToolsBreakBottomHeavyPercent.Location = new System.Drawing.Point(226, 142); - this.labelToolsBreakBottomHeavyPercent.Name = "labelToolsBreakBottomHeavyPercent"; - this.labelToolsBreakBottomHeavyPercent.Size = new System.Drawing.Size(18, 13); - this.labelToolsBreakBottomHeavyPercent.TabIndex = 63; - this.labelToolsBreakBottomHeavyPercent.Text = "%"; - // - // numericUpDownToolsBreakPreferBottomHeavy - // - this.numericUpDownToolsBreakPreferBottomHeavy.DecimalPlaces = 1; - this.numericUpDownToolsBreakPreferBottomHeavy.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numericUpDownToolsBreakPreferBottomHeavy.Location = new System.Drawing.Point(164, 140); - this.numericUpDownToolsBreakPreferBottomHeavy.Maximum = new decimal(new int[] { - 50, - 0, - 0, - 0}); - this.numericUpDownToolsBreakPreferBottomHeavy.Name = "numericUpDownToolsBreakPreferBottomHeavy"; - this.numericUpDownToolsBreakPreferBottomHeavy.Size = new System.Drawing.Size(56, 21); - this.numericUpDownToolsBreakPreferBottomHeavy.TabIndex = 62; - this.numericUpDownToolsBreakPreferBottomHeavy.Value = new decimal(new int[] { - 11, - 0, - 0, - 0}); - // - // checkBoxToolsBreakPreferBottomHeavy - // - this.checkBoxToolsBreakPreferBottomHeavy.AutoSize = true; - this.checkBoxToolsBreakPreferBottomHeavy.Location = new System.Drawing.Point(32, 141); - this.checkBoxToolsBreakPreferBottomHeavy.Name = "checkBoxToolsBreakPreferBottomHeavy"; - this.checkBoxToolsBreakPreferBottomHeavy.Size = new System.Drawing.Size(126, 17); - this.checkBoxToolsBreakPreferBottomHeavy.TabIndex = 61; - this.checkBoxToolsBreakPreferBottomHeavy.Text = "Prefer bottom heavy"; - this.checkBoxToolsBreakPreferBottomHeavy.UseVisualStyleBackColor = true; - // - // checkBoxToolsBreakByPixelWidth - // - this.checkBoxToolsBreakByPixelWidth.AutoSize = true; - this.checkBoxToolsBreakByPixelWidth.Location = new System.Drawing.Point(15, 118); - this.checkBoxToolsBreakByPixelWidth.Name = "checkBoxToolsBreakByPixelWidth"; - this.checkBoxToolsBreakByPixelWidth.Size = new System.Drawing.Size(172, 17); - this.checkBoxToolsBreakByPixelWidth.TabIndex = 60; - this.checkBoxToolsBreakByPixelWidth.Text = "Break by estimated pixel width"; - this.checkBoxToolsBreakByPixelWidth.UseVisualStyleBackColor = true; - this.checkBoxToolsBreakByPixelWidth.CheckedChanged += new System.EventHandler(this.checkBoxToolsBreakByPixelWidth_CheckedChanged); - // - // checkBoxToolsBreakEarlyLineEnding - // - this.checkBoxToolsBreakEarlyLineEnding.AutoSize = true; - this.checkBoxToolsBreakEarlyLineEnding.Location = new System.Drawing.Point(15, 72); - this.checkBoxToolsBreakEarlyLineEnding.Name = "checkBoxToolsBreakEarlyLineEnding"; - this.checkBoxToolsBreakEarlyLineEnding.Size = new System.Drawing.Size(175, 17); - this.checkBoxToolsBreakEarlyLineEnding.TabIndex = 40; - this.checkBoxToolsBreakEarlyLineEnding.Text = "Break early for line ending (.!?)"; - this.checkBoxToolsBreakEarlyLineEnding.UseVisualStyleBackColor = true; - // - // checkBoxToolsBreakEarlyComma - // - this.checkBoxToolsBreakEarlyComma.AutoSize = true; - this.checkBoxToolsBreakEarlyComma.Location = new System.Drawing.Point(15, 95); - this.checkBoxToolsBreakEarlyComma.Name = "checkBoxToolsBreakEarlyComma"; - this.checkBoxToolsBreakEarlyComma.Size = new System.Drawing.Size(133, 17); - this.checkBoxToolsBreakEarlyComma.TabIndex = 50; - this.checkBoxToolsBreakEarlyComma.Text = "Break early for comma"; - this.checkBoxToolsBreakEarlyComma.UseVisualStyleBackColor = true; - // - // checkBoxToolsBreakEarlyDash - // - this.checkBoxToolsBreakEarlyDash.AutoSize = true; - this.checkBoxToolsBreakEarlyDash.Location = new System.Drawing.Point(15, 49); - this.checkBoxToolsBreakEarlyDash.Name = "checkBoxToolsBreakEarlyDash"; - this.checkBoxToolsBreakEarlyDash.Size = new System.Drawing.Size(123, 17); - this.checkBoxToolsBreakEarlyDash.TabIndex = 30; - this.checkBoxToolsBreakEarlyDash.Text = "Break early for dash"; - this.checkBoxToolsBreakEarlyDash.UseVisualStyleBackColor = true; - // - // labelUserBingApiId - // - this.labelUserBingApiId.AutoSize = true; - this.labelUserBingApiId.Location = new System.Drawing.Point(16, 106); - this.labelUserBingApiId.Name = "labelUserBingApiId"; - this.labelUserBingApiId.Size = new System.Drawing.Size(0, 13); - this.labelUserBingApiId.TabIndex = 25; - // - // buttonEditDoNotBreakAfterList - // - this.buttonEditDoNotBreakAfterList.Location = new System.Drawing.Point(239, 22); - this.buttonEditDoNotBreakAfterList.Name = "buttonEditDoNotBreakAfterList"; - this.buttonEditDoNotBreakAfterList.Size = new System.Drawing.Size(75, 23); - this.buttonEditDoNotBreakAfterList.TabIndex = 20; - this.buttonEditDoNotBreakAfterList.Text = "Edit"; - this.buttonEditDoNotBreakAfterList.UseVisualStyleBackColor = true; - this.buttonEditDoNotBreakAfterList.Click += new System.EventHandler(this.buttonEditDoNotBreakAfterList_Click); - // - // checkBoxUseDoNotBreakAfterList - // - this.checkBoxUseDoNotBreakAfterList.AutoSize = true; - this.checkBoxUseDoNotBreakAfterList.Location = new System.Drawing.Point(15, 26); - this.checkBoxUseDoNotBreakAfterList.Name = "checkBoxUseDoNotBreakAfterList"; - this.checkBoxUseDoNotBreakAfterList.Size = new System.Drawing.Size(154, 17); - this.checkBoxUseDoNotBreakAfterList.TabIndex = 1; - this.checkBoxUseDoNotBreakAfterList.Text = "Use \'do-not-beak-after\' list"; - this.checkBoxUseDoNotBreakAfterList.UseVisualStyleBackColor = true; - // - // groupBoxSpellCheck - // - this.groupBoxSpellCheck.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxSpellCheck.Controls.Add(this.checkBoxSpellCheckAutoChangeNamesViaSuggestions); - this.groupBoxSpellCheck.Controls.Add(this.checkBoxUseAlwaysToFile); - this.groupBoxSpellCheck.Controls.Add(this.checkBoxTreatINQuoteAsING); - this.groupBoxSpellCheck.Controls.Add(this.checkBoxSpellCheckOneLetterWords); - this.groupBoxSpellCheck.Controls.Add(this.checkBoxSpellCheckAutoChangeNames); - this.groupBoxSpellCheck.Location = new System.Drawing.Point(7, 360); - this.groupBoxSpellCheck.Name = "groupBoxSpellCheck"; - this.groupBoxSpellCheck.Size = new System.Drawing.Size(408, 154); - this.groupBoxSpellCheck.TabIndex = 4; - this.groupBoxSpellCheck.TabStop = false; - this.groupBoxSpellCheck.Text = "Spell check"; - // - // checkBoxSpellCheckAutoChangeNamesViaSuggestions - // - this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.AutoSize = true; - this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.Location = new System.Drawing.Point(30, 43); - this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.Name = "checkBoxSpellCheckAutoChangeNamesViaSuggestions"; - this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.Size = new System.Drawing.Size(184, 17); - this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.TabIndex = 1; - this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.Text = "Also use \'spell check suggestions\'"; - this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.UseVisualStyleBackColor = true; - // - // checkBoxUseAlwaysToFile - // - this.checkBoxUseAlwaysToFile.AutoSize = true; - this.checkBoxUseAlwaysToFile.Location = new System.Drawing.Point(15, 118); - this.checkBoxUseAlwaysToFile.Name = "checkBoxUseAlwaysToFile"; - this.checkBoxUseAlwaysToFile.Size = new System.Drawing.Size(192, 17); - this.checkBoxUseAlwaysToFile.TabIndex = 12; - this.checkBoxUseAlwaysToFile.Text = "Remember \"Use always\" / \"Skip all\""; - this.checkBoxUseAlwaysToFile.UseVisualStyleBackColor = true; - // - // checkBoxTreatINQuoteAsING - // - this.checkBoxTreatINQuoteAsING.AutoSize = true; - this.checkBoxTreatINQuoteAsING.Location = new System.Drawing.Point(15, 95); - this.checkBoxTreatINQuoteAsING.Name = "checkBoxTreatINQuoteAsING"; - this.checkBoxTreatINQuoteAsING.Size = new System.Drawing.Size(253, 17); - this.checkBoxTreatINQuoteAsING.TabIndex = 8; - this.checkBoxTreatINQuoteAsING.Text = "Treat word ending \" in\' \" as \" ing \" (English only)"; - this.checkBoxTreatINQuoteAsING.UseVisualStyleBackColor = true; - // - // checkBoxSpellCheckOneLetterWords - // - this.checkBoxSpellCheckOneLetterWords.AutoSize = true; - this.checkBoxSpellCheckOneLetterWords.Location = new System.Drawing.Point(15, 72); - this.checkBoxSpellCheckOneLetterWords.Name = "checkBoxSpellCheckOneLetterWords"; - this.checkBoxSpellCheckOneLetterWords.Size = new System.Drawing.Size(205, 17); - this.checkBoxSpellCheckOneLetterWords.TabIndex = 4; - this.checkBoxSpellCheckOneLetterWords.Text = "Prompt for unknown one letter words"; - this.checkBoxSpellCheckOneLetterWords.UseVisualStyleBackColor = true; - // - // checkBoxSpellCheckAutoChangeNames - // - this.checkBoxSpellCheckAutoChangeNames.AutoSize = true; - this.checkBoxSpellCheckAutoChangeNames.Location = new System.Drawing.Point(15, 20); - this.checkBoxSpellCheckAutoChangeNames.Name = "checkBoxSpellCheckAutoChangeNames"; - this.checkBoxSpellCheckAutoChangeNames.Size = new System.Drawing.Size(216, 17); - this.checkBoxSpellCheckAutoChangeNames.TabIndex = 0; - this.checkBoxSpellCheckAutoChangeNames.Text = "Auto fix names where only casing differ"; - this.checkBoxSpellCheckAutoChangeNames.UseVisualStyleBackColor = true; - // - // groupBoxFixCommonErrors - // - this.groupBoxFixCommonErrors.Controls.Add(this.buttonFixContinuationStyleSettings); - this.groupBoxFixCommonErrors.Controls.Add(this.checkBoxFceSkipStep1); - this.groupBoxFixCommonErrors.Controls.Add(this.checkBoxFixShortDisplayTimesAllowMoveStartTime); - this.groupBoxFixCommonErrors.Controls.Add(this.checkBoxFixCommonOcrErrorsUsingHardcodedRules); - this.groupBoxFixCommonErrors.Controls.Add(this.comboBoxToolsMusicSymbol); - this.groupBoxFixCommonErrors.Controls.Add(this.textBoxMusicSymbolsToReplace); - this.groupBoxFixCommonErrors.Controls.Add(this.labelToolsMusicSymbolsToReplace); - this.groupBoxFixCommonErrors.Controls.Add(this.labelToolsMusicSymbol); - this.groupBoxFixCommonErrors.Location = new System.Drawing.Point(7, 129); - this.groupBoxFixCommonErrors.Name = "groupBoxFixCommonErrors"; - this.groupBoxFixCommonErrors.Size = new System.Drawing.Size(408, 225); - this.groupBoxFixCommonErrors.TabIndex = 3; - this.groupBoxFixCommonErrors.TabStop = false; - this.groupBoxFixCommonErrors.Text = "Fix common errors"; - // - // buttonFixContinuationStyleSettings - // - this.buttonFixContinuationStyleSettings.Location = new System.Drawing.Point(15, 189); - this.buttonFixContinuationStyleSettings.Name = "buttonFixContinuationStyleSettings"; - this.buttonFixContinuationStyleSettings.Size = new System.Drawing.Size(271, 23); - this.buttonFixContinuationStyleSettings.TabIndex = 37; - this.buttonFixContinuationStyleSettings.Text = "Edit settings for fixing continuation style..."; - this.buttonFixContinuationStyleSettings.UseVisualStyleBackColor = true; - this.buttonFixContinuationStyleSettings.Click += new System.EventHandler(this.buttonFixContinuationStyleSettings_Click); - // - // checkBoxFceSkipStep1 - // - this.checkBoxFceSkipStep1.AutoSize = true; - this.checkBoxFceSkipStep1.Location = new System.Drawing.Point(15, 161); - this.checkBoxFceSkipStep1.Name = "checkBoxFceSkipStep1"; - this.checkBoxFceSkipStep1.Size = new System.Drawing.Size(176, 17); - this.checkBoxFceSkipStep1.TabIndex = 36; - this.checkBoxFceSkipStep1.Text = "Skip step one (choose fix rules)"; - this.checkBoxFceSkipStep1.UseVisualStyleBackColor = true; - // - // checkBoxFixShortDisplayTimesAllowMoveStartTime - // - this.checkBoxFixShortDisplayTimesAllowMoveStartTime.AutoSize = true; - this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Location = new System.Drawing.Point(15, 138); - this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Name = "checkBoxFixShortDisplayTimesAllowMoveStartTime"; - this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Size = new System.Drawing.Size(252, 17); - this.checkBoxFixShortDisplayTimesAllowMoveStartTime.TabIndex = 35; - this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Text = "Fix short display time - allow move of start time"; - this.checkBoxFixShortDisplayTimesAllowMoveStartTime.UseVisualStyleBackColor = true; - // - // checkBoxFixCommonOcrErrorsUsingHardcodedRules - // - this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.AutoSize = true; - this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.Location = new System.Drawing.Point(15, 115); - this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.Name = "checkBoxFixCommonOcrErrorsUsingHardcodedRules"; - this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.Size = new System.Drawing.Size(268, 17); - this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.TabIndex = 2; - this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.Text = "Fix common OCR errors - also use hardcoded rules"; - this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.UseVisualStyleBackColor = true; - // - // comboBoxToolsMusicSymbol - // - this.comboBoxToolsMusicSymbol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxToolsMusicSymbol.FormattingEnabled = true; - this.comboBoxToolsMusicSymbol.Items.AddRange(new object[] { - "♪", - "♪♪", - "*", - "#"}); - this.comboBoxToolsMusicSymbol.Location = new System.Drawing.Point(200, 71); - this.comboBoxToolsMusicSymbol.Name = "comboBoxToolsMusicSymbol"; - this.comboBoxToolsMusicSymbol.Size = new System.Drawing.Size(86, 21); - this.comboBoxToolsMusicSymbol.TabIndex = 1; - // - // textBoxMusicSymbolsToReplace - // - this.textBoxMusicSymbolsToReplace.Location = new System.Drawing.Point(11, 41); - this.textBoxMusicSymbolsToReplace.MaxLength = 100; - this.textBoxMusicSymbolsToReplace.Name = "textBoxMusicSymbolsToReplace"; - this.textBoxMusicSymbolsToReplace.Size = new System.Drawing.Size(274, 21); - this.textBoxMusicSymbolsToReplace.TabIndex = 0; - // - // labelToolsMusicSymbolsToReplace - // - this.labelToolsMusicSymbolsToReplace.AutoSize = true; - this.labelToolsMusicSymbolsToReplace.Location = new System.Drawing.Point(8, 25); - this.labelToolsMusicSymbolsToReplace.Name = "labelToolsMusicSymbolsToReplace"; - this.labelToolsMusicSymbolsToReplace.Size = new System.Drawing.Size(230, 13); - this.labelToolsMusicSymbolsToReplace.TabIndex = 34; - this.labelToolsMusicSymbolsToReplace.Text = "Music symbols to replace (separate by comma)"; - // - // labelToolsMusicSymbol - // - this.labelToolsMusicSymbol.AutoSize = true; - this.labelToolsMusicSymbol.Location = new System.Drawing.Point(8, 74); - this.labelToolsMusicSymbol.Name = "labelToolsMusicSymbol"; - this.labelToolsMusicSymbol.Size = new System.Drawing.Size(69, 13); - this.labelToolsMusicSymbol.TabIndex = 32; - this.labelToolsMusicSymbol.Text = "Music symbol"; - // - // groupBoxToolsVisualSync - // - this.groupBoxToolsVisualSync.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxToolsVisualSync.Controls.Add(this.labelToolsEndScene); - this.groupBoxToolsVisualSync.Controls.Add(this.comboBoxToolsEndSceneIndex); - this.groupBoxToolsVisualSync.Controls.Add(this.labelToolsStartScene); - this.groupBoxToolsVisualSync.Controls.Add(this.comboBoxToolsStartSceneIndex); - this.groupBoxToolsVisualSync.Controls.Add(this.comboBoxToolsVerifySeconds); - this.groupBoxToolsVisualSync.Controls.Add(this.labelVerifyButton); - this.groupBoxToolsVisualSync.Location = new System.Drawing.Point(6, 6); - this.groupBoxToolsVisualSync.Name = "groupBoxToolsVisualSync"; - this.groupBoxToolsVisualSync.Size = new System.Drawing.Size(409, 116); - this.groupBoxToolsVisualSync.TabIndex = 2; - this.groupBoxToolsVisualSync.TabStop = false; - this.groupBoxToolsVisualSync.Text = "Visual sync"; - // - // labelToolsEndScene - // - this.labelToolsEndScene.AutoSize = true; - this.labelToolsEndScene.Location = new System.Drawing.Point(13, 79); - this.labelToolsEndScene.Name = "labelToolsEndScene"; - this.labelToolsEndScene.Size = new System.Drawing.Size(122, 13); - this.labelToolsEndScene.TabIndex = 29; - this.labelToolsEndScene.Text = "End scene paragraph is "; - // - // comboBoxToolsEndSceneIndex - // - this.comboBoxToolsEndSceneIndex.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxToolsEndSceneIndex.FormattingEnabled = true; - this.comboBoxToolsEndSceneIndex.Items.AddRange(new object[] { - "Last", - "Last - 1", - "Last - 2", - "Last - 3"}); - this.comboBoxToolsEndSceneIndex.Location = new System.Drawing.Point(200, 76); - this.comboBoxToolsEndSceneIndex.Name = "comboBoxToolsEndSceneIndex"; - this.comboBoxToolsEndSceneIndex.Size = new System.Drawing.Size(86, 21); - this.comboBoxToolsEndSceneIndex.TabIndex = 2; - // - // labelToolsStartScene - // - this.labelToolsStartScene.AutoSize = true; - this.labelToolsStartScene.Location = new System.Drawing.Point(13, 52); - this.labelToolsStartScene.Name = "labelToolsStartScene"; - this.labelToolsStartScene.Size = new System.Drawing.Size(125, 13); - this.labelToolsStartScene.TabIndex = 27; - this.labelToolsStartScene.Text = "Start scene paragraph is"; - // - // comboBoxToolsStartSceneIndex - // - this.comboBoxToolsStartSceneIndex.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxToolsStartSceneIndex.FormattingEnabled = true; - this.comboBoxToolsStartSceneIndex.Items.AddRange(new object[] { - "First", - "First +1", - "First +2", - "First +3"}); - this.comboBoxToolsStartSceneIndex.Location = new System.Drawing.Point(200, 49); - this.comboBoxToolsStartSceneIndex.Name = "comboBoxToolsStartSceneIndex"; - this.comboBoxToolsStartSceneIndex.Size = new System.Drawing.Size(86, 21); - this.comboBoxToolsStartSceneIndex.TabIndex = 1; - // - // comboBoxToolsVerifySeconds - // - this.comboBoxToolsVerifySeconds.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxToolsVerifySeconds.FormattingEnabled = true; - this.comboBoxToolsVerifySeconds.Items.AddRange(new object[] { - "2", - "3", - "4", - "5"}); - this.comboBoxToolsVerifySeconds.Location = new System.Drawing.Point(200, 22); - this.comboBoxToolsVerifySeconds.Name = "comboBoxToolsVerifySeconds"; - this.comboBoxToolsVerifySeconds.Size = new System.Drawing.Size(86, 21); - this.comboBoxToolsVerifySeconds.TabIndex = 0; - // - // labelVerifyButton - // - this.labelVerifyButton.AutoSize = true; - this.labelVerifyButton.Location = new System.Drawing.Point(13, 25); - this.labelVerifyButton.Name = "labelVerifyButton"; - this.labelVerifyButton.Size = new System.Drawing.Size(147, 13); - this.labelVerifyButton.TabIndex = 3; - this.labelVerifyButton.Text = "Play X seconds and back, X is"; - // - // tabPageWordLists - // - this.tabPageWordLists.Controls.Add(this.groupBoxWordLists); - this.tabPageWordLists.Location = new System.Drawing.Point(4, 22); - this.tabPageWordLists.Name = "tabPageWordLists"; - this.tabPageWordLists.Padding = new System.Windows.Forms.Padding(3); - this.tabPageWordLists.Size = new System.Drawing.Size(832, 520); - this.tabPageWordLists.TabIndex = 3; - this.tabPageWordLists.Text = "Word lists"; - this.tabPageWordLists.UseVisualStyleBackColor = true; - // - // groupBoxWordLists - // - this.groupBoxWordLists.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxWordLists.Controls.Add(this.linkLabelOpenDictionaryFolder); - this.groupBoxWordLists.Controls.Add(this.groupBoxOcrFixList); - this.groupBoxWordLists.Controls.Add(this.groupBoxUserWordList); - this.groupBoxWordLists.Controls.Add(this.groupBoxWordListLocation); - this.groupBoxWordLists.Controls.Add(this.groupBoxNamesIgonoreLists); - this.groupBoxWordLists.Controls.Add(this.labelWordListLanguage); - this.groupBoxWordLists.Controls.Add(this.comboBoxWordListLanguage); - this.groupBoxWordLists.Location = new System.Drawing.Point(6, 6); - this.groupBoxWordLists.Name = "groupBoxWordLists"; - this.groupBoxWordLists.Size = new System.Drawing.Size(819, 503); - this.groupBoxWordLists.TabIndex = 2; - this.groupBoxWordLists.TabStop = false; - this.groupBoxWordLists.Text = "Word lists"; - // - // linkLabelOpenDictionaryFolder - // - this.linkLabelOpenDictionaryFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.linkLabelOpenDictionaryFolder.AutoSize = true; - this.linkLabelOpenDictionaryFolder.Location = new System.Drawing.Point(6, 464); - this.linkLabelOpenDictionaryFolder.Name = "linkLabelOpenDictionaryFolder"; - this.linkLabelOpenDictionaryFolder.Size = new System.Drawing.Size(126, 13); - this.linkLabelOpenDictionaryFolder.TabIndex = 29; - this.linkLabelOpenDictionaryFolder.TabStop = true; - this.linkLabelOpenDictionaryFolder.Text = "Open \'Dictionaries\' folder"; - this.linkLabelOpenDictionaryFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelOpenDictionaryFolder_LinkClicked); - // - // groupBoxOcrFixList - // - this.groupBoxOcrFixList.Controls.Add(this.textBoxOcrFixValue); - this.groupBoxOcrFixList.Controls.Add(this.buttonRemoveOcrFix); - this.groupBoxOcrFixList.Controls.Add(this.listBoxOcrFixList); - this.groupBoxOcrFixList.Controls.Add(this.textBoxOcrFixKey); - this.groupBoxOcrFixList.Controls.Add(this.buttonAddOcrFix); - this.groupBoxOcrFixList.Location = new System.Drawing.Point(510, 43); - this.groupBoxOcrFixList.Name = "groupBoxOcrFixList"; - this.groupBoxOcrFixList.Size = new System.Drawing.Size(293, 279); - this.groupBoxOcrFixList.TabIndex = 6; - this.groupBoxOcrFixList.TabStop = false; - this.groupBoxOcrFixList.Text = "OCR fix list"; - // - // textBoxOcrFixValue - // - this.textBoxOcrFixValue.Location = new System.Drawing.Point(100, 248); - this.textBoxOcrFixValue.Name = "textBoxOcrFixValue"; - this.textBoxOcrFixValue.Size = new System.Drawing.Size(85, 21); - this.textBoxOcrFixValue.TabIndex = 45; - this.textBoxOcrFixValue.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxOcrFixValueKeyDown); - // - // buttonRemoveOcrFix - // - this.buttonRemoveOcrFix.Location = new System.Drawing.Point(191, 16); - this.buttonRemoveOcrFix.Name = "buttonRemoveOcrFix"; - this.buttonRemoveOcrFix.Size = new System.Drawing.Size(75, 23); - this.buttonRemoveOcrFix.TabIndex = 42; - this.buttonRemoveOcrFix.Text = "Remove"; - this.buttonRemoveOcrFix.UseVisualStyleBackColor = true; - this.buttonRemoveOcrFix.Click += new System.EventHandler(this.ButtonRemoveOcrFixClick); - // - // listBoxOcrFixList - // - this.listBoxOcrFixList.FormattingEnabled = true; - this.listBoxOcrFixList.Location = new System.Drawing.Point(6, 16); - this.listBoxOcrFixList.Name = "listBoxOcrFixList"; - this.listBoxOcrFixList.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this.listBoxOcrFixList.Size = new System.Drawing.Size(179, 225); - this.listBoxOcrFixList.TabIndex = 40; - this.listBoxOcrFixList.SelectedIndexChanged += new System.EventHandler(this.ListBoxOcrFixListSelectedIndexChanged); - this.listBoxOcrFixList.DoubleClick += new System.EventHandler(this.listBoxOcrFixList_DoubleClick); - this.listBoxOcrFixList.Enter += new System.EventHandler(this.ListBoxSearchReset); - this.listBoxOcrFixList.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ListBoxKeyDownSearch); - // - // textBoxOcrFixKey - // - this.textBoxOcrFixKey.Location = new System.Drawing.Point(6, 248); - this.textBoxOcrFixKey.Name = "textBoxOcrFixKey"; - this.textBoxOcrFixKey.Size = new System.Drawing.Size(88, 21); - this.textBoxOcrFixKey.TabIndex = 44; - // - // buttonAddOcrFix - // - this.buttonAddOcrFix.Location = new System.Drawing.Point(191, 247); - this.buttonAddOcrFix.Name = "buttonAddOcrFix"; - this.buttonAddOcrFix.Size = new System.Drawing.Size(75, 23); - this.buttonAddOcrFix.TabIndex = 46; - this.buttonAddOcrFix.Text = "Add pair"; - this.buttonAddOcrFix.UseVisualStyleBackColor = true; - this.buttonAddOcrFix.Click += new System.EventHandler(this.ButtonAddOcrFixClick); - // - // groupBoxUserWordList - // - this.groupBoxUserWordList.Controls.Add(this.buttonRemoveUserWord); - this.groupBoxUserWordList.Controls.Add(this.listBoxUserWordLists); - this.groupBoxUserWordList.Controls.Add(this.textBoxUserWord); - this.groupBoxUserWordList.Controls.Add(this.buttonAddUserWord); - this.groupBoxUserWordList.Location = new System.Drawing.Point(259, 43); - this.groupBoxUserWordList.Name = "groupBoxUserWordList"; - this.groupBoxUserWordList.Size = new System.Drawing.Size(241, 279); - this.groupBoxUserWordList.TabIndex = 4; - this.groupBoxUserWordList.TabStop = false; - this.groupBoxUserWordList.Text = "User word list"; - // - // buttonRemoveUserWord - // - this.buttonRemoveUserWord.Location = new System.Drawing.Point(159, 16); - this.buttonRemoveUserWord.Name = "buttonRemoveUserWord"; - this.buttonRemoveUserWord.Size = new System.Drawing.Size(75, 23); - this.buttonRemoveUserWord.TabIndex = 32; - this.buttonRemoveUserWord.Text = "Remove"; - this.buttonRemoveUserWord.UseVisualStyleBackColor = true; - this.buttonRemoveUserWord.Click += new System.EventHandler(this.ButtonRemoveUserWordClick); - // - // listBoxUserWordLists - // - this.listBoxUserWordLists.FormattingEnabled = true; - this.listBoxUserWordLists.Location = new System.Drawing.Point(3, 16); - this.listBoxUserWordLists.Name = "listBoxUserWordLists"; - this.listBoxUserWordLists.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this.listBoxUserWordLists.Size = new System.Drawing.Size(150, 225); - this.listBoxUserWordLists.TabIndex = 30; - this.listBoxUserWordLists.SelectedIndexChanged += new System.EventHandler(this.ListBoxUserWordListsSelectedIndexChanged); - this.listBoxUserWordLists.DoubleClick += new System.EventHandler(this.listBoxUserWordLists_DoubleClick); - this.listBoxUserWordLists.Enter += new System.EventHandler(this.ListBoxSearchReset); - this.listBoxUserWordLists.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ListBoxKeyDownSearch); - // - // textBoxUserWord - // - this.textBoxUserWord.Location = new System.Drawing.Point(3, 248); - this.textBoxUserWord.Name = "textBoxUserWord"; - this.textBoxUserWord.Size = new System.Drawing.Size(150, 21); - this.textBoxUserWord.TabIndex = 34; - this.textBoxUserWord.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxUserWordKeyDown); - // - // buttonAddUserWord - // - this.buttonAddUserWord.Location = new System.Drawing.Point(157, 247); - this.buttonAddUserWord.Name = "buttonAddUserWord"; - this.buttonAddUserWord.Size = new System.Drawing.Size(75, 23); - this.buttonAddUserWord.TabIndex = 36; - this.buttonAddUserWord.Text = "Add word"; - this.buttonAddUserWord.UseVisualStyleBackColor = true; - this.buttonAddUserWord.Click += new System.EventHandler(this.ButtonAddUserWordClick); - // - // groupBoxWordListLocation - // - this.groupBoxWordListLocation.Controls.Add(this.checkBoxNamesOnline); - this.groupBoxWordListLocation.Controls.Add(this.textBoxNamesOnline); - this.groupBoxWordListLocation.Location = new System.Drawing.Point(6, 328); - this.groupBoxWordListLocation.Name = "groupBoxWordListLocation"; - this.groupBoxWordListLocation.Size = new System.Drawing.Size(797, 92); - this.groupBoxWordListLocation.TabIndex = 8; - this.groupBoxWordListLocation.TabStop = false; - this.groupBoxWordListLocation.Text = "Location"; - // - // checkBoxNamesOnline - // - this.checkBoxNamesOnline.AutoSize = true; - this.checkBoxNamesOnline.Location = new System.Drawing.Point(7, 22); - this.checkBoxNamesOnline.Name = "checkBoxNamesOnline"; - this.checkBoxNamesOnline.Size = new System.Drawing.Size(145, 17); - this.checkBoxNamesOnline.TabIndex = 26; - this.checkBoxNamesOnline.Text = "Use online names xml file"; - this.checkBoxNamesOnline.UseVisualStyleBackColor = true; - // - // textBoxNamesOnline - // - this.textBoxNamesOnline.Location = new System.Drawing.Point(6, 45); - this.textBoxNamesOnline.Name = "textBoxNamesOnline"; - this.textBoxNamesOnline.Size = new System.Drawing.Size(764, 21); - this.textBoxNamesOnline.TabIndex = 28; - this.textBoxNamesOnline.Text = "https://raw.githubusercontent.com/SubtitleEdit/subtitleedit/master/Dictionaries/n" + - "ames.xml"; - // - // groupBoxNamesIgonoreLists - // - this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonRemoveNameEtc); - this.groupBoxNamesIgonoreLists.Controls.Add(this.listBoxNames); - this.groupBoxNamesIgonoreLists.Controls.Add(this.textBoxNameEtc); - this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonAddNames); - this.groupBoxNamesIgonoreLists.Location = new System.Drawing.Point(6, 43); - this.groupBoxNamesIgonoreLists.Name = "groupBoxNamesIgonoreLists"; - this.groupBoxNamesIgonoreLists.Size = new System.Drawing.Size(241, 279); - this.groupBoxNamesIgonoreLists.TabIndex = 2; - this.groupBoxNamesIgonoreLists.TabStop = false; - this.groupBoxNamesIgonoreLists.Text = "Names/ignore lists"; - // - // buttonRemoveNameEtc - // - this.buttonRemoveNameEtc.Location = new System.Drawing.Point(159, 16); - this.buttonRemoveNameEtc.Name = "buttonRemoveNameEtc"; - this.buttonRemoveNameEtc.Size = new System.Drawing.Size(75, 23); - this.buttonRemoveNameEtc.TabIndex = 22; - this.buttonRemoveNameEtc.Text = "Remove"; - this.buttonRemoveNameEtc.UseVisualStyleBackColor = true; - this.buttonRemoveNameEtc.Click += new System.EventHandler(this.ButtonRemoveNameEtcClick); - // - // listBoxNames - // - this.listBoxNames.FormattingEnabled = true; - this.listBoxNames.Location = new System.Drawing.Point(3, 16); - this.listBoxNames.Name = "listBoxNames"; - this.listBoxNames.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this.listBoxNames.Size = new System.Drawing.Size(150, 225); - this.listBoxNames.TabIndex = 20; - this.listBoxNames.SelectedIndexChanged += new System.EventHandler(this.ListBoxNamesSelectedIndexChanged); - this.listBoxNames.DoubleClick += new System.EventHandler(this.listBoxNames_DoubleClick); - this.listBoxNames.Enter += new System.EventHandler(this.ListBoxSearchReset); - this.listBoxNames.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ListBoxKeyDownSearch); - // - // textBoxNameEtc - // - this.textBoxNameEtc.Location = new System.Drawing.Point(3, 248); - this.textBoxNameEtc.Name = "textBoxNameEtc"; - this.textBoxNameEtc.Size = new System.Drawing.Size(151, 21); - this.textBoxNameEtc.TabIndex = 24; - this.textBoxNameEtc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxNameEtcKeyDown); - // - // buttonAddNames - // - this.buttonAddNames.Location = new System.Drawing.Point(160, 247); - this.buttonAddNames.Name = "buttonAddNames"; - this.buttonAddNames.Size = new System.Drawing.Size(75, 23); - this.buttonAddNames.TabIndex = 26; - this.buttonAddNames.Text = "Add name"; - this.buttonAddNames.UseVisualStyleBackColor = true; - this.buttonAddNames.Click += new System.EventHandler(this.ButtonAddNamesClick); - // - // labelWordListLanguage - // - this.labelWordListLanguage.AutoSize = true; - this.labelWordListLanguage.Location = new System.Drawing.Point(6, 19); - this.labelWordListLanguage.Name = "labelWordListLanguage"; - this.labelWordListLanguage.Size = new System.Drawing.Size(54, 13); - this.labelWordListLanguage.TabIndex = 1; - this.labelWordListLanguage.Text = "Language"; - // - // comboBoxWordListLanguage - // - this.comboBoxWordListLanguage.FormattingEnabled = true; - this.comboBoxWordListLanguage.Location = new System.Drawing.Point(67, 16); - this.comboBoxWordListLanguage.Name = "comboBoxWordListLanguage"; - this.comboBoxWordListLanguage.Size = new System.Drawing.Size(155, 21); - this.comboBoxWordListLanguage.TabIndex = 0; - this.comboBoxWordListLanguage.SelectedIndexChanged += new System.EventHandler(this.ComboBoxWordListLanguageSelectedIndexChanged); - // - // tabPageToolBar - // - this.tabPageToolBar.Controls.Add(this.groupBox2); - this.tabPageToolBar.Controls.Add(this.groupBoxShowToolBarButtons); - this.tabPageToolBar.Location = new System.Drawing.Point(4, 22); - this.tabPageToolBar.Name = "tabPageToolBar"; - this.tabPageToolBar.Padding = new System.Windows.Forms.Padding(3); - this.tabPageToolBar.Size = new System.Drawing.Size(832, 520); - this.tabPageToolBar.TabIndex = 7; - this.tabPageToolBar.Text = "Toolbar "; - this.tabPageToolBar.UseVisualStyleBackColor = true; - // - // groupBox2 - // - this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox2.Controls.Add(this.checkBoxShowFrameRate); - this.groupBox2.Location = new System.Drawing.Point(7, 248); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(818, 261); - this.groupBox2.TabIndex = 35; - this.groupBox2.TabStop = false; - // - // checkBoxShowFrameRate - // - this.checkBoxShowFrameRate.AutoSize = true; - this.checkBoxShowFrameRate.Location = new System.Drawing.Point(16, 20); - this.checkBoxShowFrameRate.Name = "checkBoxShowFrameRate"; - this.checkBoxShowFrameRate.Size = new System.Drawing.Size(154, 17); - this.checkBoxShowFrameRate.TabIndex = 34; - this.checkBoxShowFrameRate.Text = "Show frame rate in toolbar"; - this.checkBoxShowFrameRate.UseVisualStyleBackColor = true; - // - // groupBoxShowToolBarButtons - // - this.groupBoxShowToolBarButtons.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBNetflixQualityCheck); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxNetflixQualityCheck); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxNetflixQualityCheck); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBRemoveTextForHi); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxTBRemoveTextForHi); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxTBRemoveTextForHi); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBFixCommonErrors); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxTBFixCommonErrors); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxTBFixCommonErrors); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBHelp); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxHelp); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxHelp); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBSettings); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxSettings); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxSettings); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBSpellCheck); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxSpellCheck); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxSpellCheck); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBVisualSync); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxVisualSync); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxVisualSync); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBReplace); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxReplace); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxReplace); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBFind); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxFind); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxToolbarFind); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBSaveAs); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxSaveAs); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxToolbarSaveAs); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBSave); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxSave); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxToolbarSave); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBOpen); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxOpen); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxToolbarOpen); - this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBNew); - this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxNew); - this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxToolbarNew); - this.groupBoxShowToolBarButtons.Location = new System.Drawing.Point(6, 6); - this.groupBoxShowToolBarButtons.Name = "groupBoxShowToolBarButtons"; - this.groupBoxShowToolBarButtons.Size = new System.Drawing.Size(819, 236); - this.groupBoxShowToolBarButtons.TabIndex = 0; - this.groupBoxShowToolBarButtons.TabStop = false; - this.groupBoxShowToolBarButtons.Text = "Show toolbar buttons"; - // - // labelTBNetflixQualityCheck - // - this.labelTBNetflixQualityCheck.AutoSize = true; - this.labelTBNetflixQualityCheck.Location = new System.Drawing.Point(636, 136); - this.labelTBNetflixQualityCheck.Name = "labelTBNetflixQualityCheck"; - this.labelTBNetflixQualityCheck.Size = new System.Drawing.Size(103, 13); - this.labelTBNetflixQualityCheck.TabIndex = 42; - this.labelTBNetflixQualityCheck.Text = "Netflix quality check"; - // - // pictureBoxNetflixQualityCheck - // - this.pictureBoxNetflixQualityCheck.Location = new System.Drawing.Point(649, 155); - this.pictureBoxNetflixQualityCheck.Name = "pictureBoxNetflixQualityCheck"; - this.pictureBoxNetflixQualityCheck.Size = new System.Drawing.Size(32, 32); - this.pictureBoxNetflixQualityCheck.TabIndex = 41; - this.pictureBoxNetflixQualityCheck.TabStop = false; - // - // checkBoxNetflixQualityCheck - // - this.checkBoxNetflixQualityCheck.AutoSize = true; - this.checkBoxNetflixQualityCheck.Location = new System.Drawing.Point(652, 195); - this.checkBoxNetflixQualityCheck.Name = "checkBoxNetflixQualityCheck"; - this.checkBoxNetflixQualityCheck.Size = new System.Drawing.Size(55, 17); - this.checkBoxNetflixQualityCheck.TabIndex = 40; - this.checkBoxNetflixQualityCheck.Text = "Visible"; - this.checkBoxNetflixQualityCheck.UseVisualStyleBackColor = true; - // - // labelTBRemoveTextForHi - // - this.labelTBRemoveTextForHi.AutoSize = true; - this.labelTBRemoveTextForHi.Location = new System.Drawing.Point(124, 136); - this.labelTBRemoveTextForHi.Name = "labelTBRemoveTextForHi"; - this.labelTBRemoveTextForHi.Size = new System.Drawing.Size(100, 13); - this.labelTBRemoveTextForHi.TabIndex = 39; - this.labelTBRemoveTextForHi.Text = "Remove text for HI"; - // - // pictureBoxTBRemoveTextForHi - // - this.pictureBoxTBRemoveTextForHi.Location = new System.Drawing.Point(137, 155); - this.pictureBoxTBRemoveTextForHi.Name = "pictureBoxTBRemoveTextForHi"; - this.pictureBoxTBRemoveTextForHi.Size = new System.Drawing.Size(32, 32); - this.pictureBoxTBRemoveTextForHi.TabIndex = 38; - this.pictureBoxTBRemoveTextForHi.TabStop = false; - // - // checkBoxTBRemoveTextForHi - // - this.checkBoxTBRemoveTextForHi.AutoSize = true; - this.checkBoxTBRemoveTextForHi.Location = new System.Drawing.Point(140, 195); - this.checkBoxTBRemoveTextForHi.Name = "checkBoxTBRemoveTextForHi"; - this.checkBoxTBRemoveTextForHi.Size = new System.Drawing.Size(55, 17); - this.checkBoxTBRemoveTextForHi.TabIndex = 18; - this.checkBoxTBRemoveTextForHi.Text = "Visible"; - this.checkBoxTBRemoveTextForHi.UseVisualStyleBackColor = true; - // - // labelTBFixCommonErrors - // - this.labelTBFixCommonErrors.AutoSize = true; - this.labelTBFixCommonErrors.Location = new System.Drawing.Point(9, 136); - this.labelTBFixCommonErrors.Name = "labelTBFixCommonErrors"; - this.labelTBFixCommonErrors.Size = new System.Drawing.Size(95, 13); - this.labelTBFixCommonErrors.TabIndex = 36; - this.labelTBFixCommonErrors.Text = "Fix common errors"; - // - // pictureBoxTBFixCommonErrors - // - this.pictureBoxTBFixCommonErrors.Location = new System.Drawing.Point(22, 155); - this.pictureBoxTBFixCommonErrors.Name = "pictureBoxTBFixCommonErrors"; - this.pictureBoxTBFixCommonErrors.Size = new System.Drawing.Size(32, 32); - this.pictureBoxTBFixCommonErrors.TabIndex = 35; - this.pictureBoxTBFixCommonErrors.TabStop = false; - // - // checkBoxTBFixCommonErrors - // - this.checkBoxTBFixCommonErrors.AutoSize = true; - this.checkBoxTBFixCommonErrors.Location = new System.Drawing.Point(25, 195); - this.checkBoxTBFixCommonErrors.Name = "checkBoxTBFixCommonErrors"; - this.checkBoxTBFixCommonErrors.Size = new System.Drawing.Size(55, 17); - this.checkBoxTBFixCommonErrors.TabIndex = 17; - this.checkBoxTBFixCommonErrors.Text = "Visible"; - this.checkBoxTBFixCommonErrors.UseVisualStyleBackColor = true; - // - // labelTBHelp - // - this.labelTBHelp.AutoSize = true; - this.labelTBHelp.Location = new System.Drawing.Point(561, 136); - this.labelTBHelp.Name = "labelTBHelp"; - this.labelTBHelp.Size = new System.Drawing.Size(28, 13); - this.labelTBHelp.TabIndex = 33; - this.labelTBHelp.Text = "Help"; - // - // pictureBoxHelp - // - this.pictureBoxHelp.Location = new System.Drawing.Point(560, 155); - this.pictureBoxHelp.Name = "pictureBoxHelp"; - this.pictureBoxHelp.Size = new System.Drawing.Size(32, 32); - this.pictureBoxHelp.TabIndex = 32; - this.pictureBoxHelp.TabStop = false; - // - // checkBoxHelp - // - this.checkBoxHelp.AutoSize = true; - this.checkBoxHelp.Location = new System.Drawing.Point(563, 195); - this.checkBoxHelp.Name = "checkBoxHelp"; - this.checkBoxHelp.Size = new System.Drawing.Size(55, 17); - this.checkBoxHelp.TabIndex = 22; - this.checkBoxHelp.Text = "Visible"; - this.checkBoxHelp.UseVisualStyleBackColor = true; - // - // labelTBSettings - // - this.labelTBSettings.AutoSize = true; - this.labelTBSettings.Location = new System.Drawing.Point(456, 136); - this.labelTBSettings.Name = "labelTBSettings"; - this.labelTBSettings.Size = new System.Drawing.Size(46, 13); - this.labelTBSettings.TabIndex = 30; - this.labelTBSettings.Text = "Settings"; - // - // pictureBoxSettings - // - this.pictureBoxSettings.Location = new System.Drawing.Point(459, 155); - this.pictureBoxSettings.Name = "pictureBoxSettings"; - this.pictureBoxSettings.Size = new System.Drawing.Size(32, 32); - this.pictureBoxSettings.TabIndex = 29; - this.pictureBoxSettings.TabStop = false; - // - // checkBoxSettings - // - this.checkBoxSettings.AutoSize = true; - this.checkBoxSettings.Location = new System.Drawing.Point(462, 195); - this.checkBoxSettings.Name = "checkBoxSettings"; - this.checkBoxSettings.Size = new System.Drawing.Size(55, 17); - this.checkBoxSettings.TabIndex = 21; - this.checkBoxSettings.Text = "Visible"; - this.checkBoxSettings.UseVisualStyleBackColor = true; - // - // labelTBSpellCheck - // - this.labelTBSpellCheck.AutoSize = true; - this.labelTBSpellCheck.Location = new System.Drawing.Point(357, 136); - this.labelTBSpellCheck.Name = "labelTBSpellCheck"; - this.labelTBSpellCheck.Size = new System.Drawing.Size(59, 13); - this.labelTBSpellCheck.TabIndex = 27; - this.labelTBSpellCheck.Text = "Spell check"; - // - // pictureBoxSpellCheck - // - this.pictureBoxSpellCheck.Location = new System.Drawing.Point(361, 155); - this.pictureBoxSpellCheck.Name = "pictureBoxSpellCheck"; - this.pictureBoxSpellCheck.Size = new System.Drawing.Size(32, 32); - this.pictureBoxSpellCheck.TabIndex = 26; - this.pictureBoxSpellCheck.TabStop = false; - // - // checkBoxSpellCheck - // - this.checkBoxSpellCheck.AutoSize = true; - this.checkBoxSpellCheck.Location = new System.Drawing.Point(362, 195); - this.checkBoxSpellCheck.Name = "checkBoxSpellCheck"; - this.checkBoxSpellCheck.Size = new System.Drawing.Size(55, 17); - this.checkBoxSpellCheck.TabIndex = 20; - this.checkBoxSpellCheck.Text = "Visible"; - this.checkBoxSpellCheck.UseVisualStyleBackColor = true; - // - // labelTBVisualSync - // - this.labelTBVisualSync.AutoSize = true; - this.labelTBVisualSync.Location = new System.Drawing.Point(247, 136); - this.labelTBVisualSync.Name = "labelTBVisualSync"; - this.labelTBVisualSync.Size = new System.Drawing.Size(59, 13); - this.labelTBVisualSync.TabIndex = 21; - this.labelTBVisualSync.Text = "Visual sync"; - // - // pictureBoxVisualSync - // - this.pictureBoxVisualSync.Location = new System.Drawing.Point(260, 155); - this.pictureBoxVisualSync.Name = "pictureBoxVisualSync"; - this.pictureBoxVisualSync.Size = new System.Drawing.Size(32, 32); - this.pictureBoxVisualSync.TabIndex = 20; - this.pictureBoxVisualSync.TabStop = false; - // - // checkBoxVisualSync - // - this.checkBoxVisualSync.AutoSize = true; - this.checkBoxVisualSync.Location = new System.Drawing.Point(263, 195); - this.checkBoxVisualSync.Name = "checkBoxVisualSync"; - this.checkBoxVisualSync.Size = new System.Drawing.Size(55, 17); - this.checkBoxVisualSync.TabIndex = 19; - this.checkBoxVisualSync.Text = "Visible"; - this.checkBoxVisualSync.UseVisualStyleBackColor = true; - // - // labelTBReplace - // - this.labelTBReplace.AutoSize = true; - this.labelTBReplace.Location = new System.Drawing.Point(521, 22); - this.labelTBReplace.Name = "labelTBReplace"; - this.labelTBReplace.Size = new System.Drawing.Size(45, 13); - this.labelTBReplace.TabIndex = 18; - this.labelTBReplace.Text = "Replace"; - // - // pictureBoxReplace - // - this.pictureBoxReplace.Location = new System.Drawing.Point(526, 41); - this.pictureBoxReplace.Name = "pictureBoxReplace"; - this.pictureBoxReplace.Size = new System.Drawing.Size(32, 32); - this.pictureBoxReplace.TabIndex = 17; - this.pictureBoxReplace.TabStop = false; - // - // checkBoxReplace - // - this.checkBoxReplace.AutoSize = true; - this.checkBoxReplace.Location = new System.Drawing.Point(529, 81); - this.checkBoxReplace.Name = "checkBoxReplace"; - this.checkBoxReplace.Size = new System.Drawing.Size(55, 17); - this.checkBoxReplace.TabIndex = 16; - this.checkBoxReplace.Text = "Visible"; - this.checkBoxReplace.UseVisualStyleBackColor = true; - // - // labelTBFind - // - this.labelTBFind.AutoSize = true; - this.labelTBFind.Location = new System.Drawing.Point(425, 22); - this.labelTBFind.Name = "labelTBFind"; - this.labelTBFind.Size = new System.Drawing.Size(27, 13); - this.labelTBFind.TabIndex = 15; - this.labelTBFind.Text = "Find"; - // - // pictureBoxFind - // - this.pictureBoxFind.Location = new System.Drawing.Point(423, 41); - this.pictureBoxFind.Name = "pictureBoxFind"; - this.pictureBoxFind.Size = new System.Drawing.Size(32, 32); - this.pictureBoxFind.TabIndex = 14; - this.pictureBoxFind.TabStop = false; - // - // checkBoxToolbarFind - // - this.checkBoxToolbarFind.AutoSize = true; - this.checkBoxToolbarFind.Location = new System.Drawing.Point(426, 81); - this.checkBoxToolbarFind.Name = "checkBoxToolbarFind"; - this.checkBoxToolbarFind.Size = new System.Drawing.Size(55, 17); - this.checkBoxToolbarFind.TabIndex = 13; - this.checkBoxToolbarFind.Text = "Visible"; - this.checkBoxToolbarFind.UseVisualStyleBackColor = true; - // - // labelTBSaveAs - // - this.labelTBSaveAs.AutoSize = true; - this.labelTBSaveAs.Location = new System.Drawing.Point(316, 22); - this.labelTBSaveAs.Name = "labelTBSaveAs"; - this.labelTBSaveAs.Size = new System.Drawing.Size(45, 13); - this.labelTBSaveAs.TabIndex = 12; - this.labelTBSaveAs.Text = "Save as"; - // - // pictureBoxSaveAs - // - this.pictureBoxSaveAs.Location = new System.Drawing.Point(322, 41); - this.pictureBoxSaveAs.Name = "pictureBoxSaveAs"; - this.pictureBoxSaveAs.Size = new System.Drawing.Size(32, 32); - this.pictureBoxSaveAs.TabIndex = 11; - this.pictureBoxSaveAs.TabStop = false; - // - // checkBoxToolbarSaveAs - // - this.checkBoxToolbarSaveAs.AutoSize = true; - this.checkBoxToolbarSaveAs.Location = new System.Drawing.Point(325, 81); - this.checkBoxToolbarSaveAs.Name = "checkBoxToolbarSaveAs"; - this.checkBoxToolbarSaveAs.Size = new System.Drawing.Size(55, 17); - this.checkBoxToolbarSaveAs.TabIndex = 10; - this.checkBoxToolbarSaveAs.Text = "Visible"; - this.checkBoxToolbarSaveAs.UseVisualStyleBackColor = true; - // - // labelTBSave - // - this.labelTBSave.AutoSize = true; - this.labelTBSave.Location = new System.Drawing.Point(225, 22); - this.labelTBSave.Name = "labelTBSave"; - this.labelTBSave.Size = new System.Drawing.Size(31, 13); - this.labelTBSave.TabIndex = 9; - this.labelTBSave.Text = "Save"; - // - // pictureBoxSave - // - this.pictureBoxSave.Location = new System.Drawing.Point(224, 41); - this.pictureBoxSave.Name = "pictureBoxSave"; - this.pictureBoxSave.Size = new System.Drawing.Size(32, 32); - this.pictureBoxSave.TabIndex = 8; - this.pictureBoxSave.TabStop = false; - // - // checkBoxToolbarSave - // - this.checkBoxToolbarSave.AutoSize = true; - this.checkBoxToolbarSave.Location = new System.Drawing.Point(227, 81); - this.checkBoxToolbarSave.Name = "checkBoxToolbarSave"; - this.checkBoxToolbarSave.Size = new System.Drawing.Size(55, 17); - this.checkBoxToolbarSave.TabIndex = 7; - this.checkBoxToolbarSave.Text = "Visible"; - this.checkBoxToolbarSave.UseVisualStyleBackColor = true; - // - // labelTBOpen - // - this.labelTBOpen.AutoSize = true; - this.labelTBOpen.Location = new System.Drawing.Point(124, 22); - this.labelTBOpen.Name = "labelTBOpen"; - this.labelTBOpen.Size = new System.Drawing.Size(33, 13); - this.labelTBOpen.TabIndex = 6; - this.labelTBOpen.Text = "Open"; - // - // pictureBoxOpen - // - this.pictureBoxOpen.Location = new System.Drawing.Point(123, 41); - this.pictureBoxOpen.Name = "pictureBoxOpen"; - this.pictureBoxOpen.Size = new System.Drawing.Size(32, 32); - this.pictureBoxOpen.TabIndex = 5; - this.pictureBoxOpen.TabStop = false; - // - // checkBoxToolbarOpen - // - this.checkBoxToolbarOpen.AutoSize = true; - this.checkBoxToolbarOpen.Location = new System.Drawing.Point(126, 81); - this.checkBoxToolbarOpen.Name = "checkBoxToolbarOpen"; - this.checkBoxToolbarOpen.Size = new System.Drawing.Size(55, 17); - this.checkBoxToolbarOpen.TabIndex = 4; - this.checkBoxToolbarOpen.Text = "Visible"; - this.checkBoxToolbarOpen.UseVisualStyleBackColor = true; - // - // labelTBNew - // - this.labelTBNew.AutoSize = true; - this.labelTBNew.Location = new System.Drawing.Point(24, 22); - this.labelTBNew.Name = "labelTBNew"; - this.labelTBNew.Size = new System.Drawing.Size(28, 13); - this.labelTBNew.TabIndex = 3; - this.labelTBNew.Text = "New"; - // - // pictureBoxNew - // - this.pictureBoxNew.Location = new System.Drawing.Point(22, 41); - this.pictureBoxNew.Name = "pictureBoxNew"; - this.pictureBoxNew.Size = new System.Drawing.Size(32, 32); - this.pictureBoxNew.TabIndex = 2; - this.pictureBoxNew.TabStop = false; - // - // checkBoxToolbarNew - // - this.checkBoxToolbarNew.AutoSize = true; - this.checkBoxToolbarNew.Location = new System.Drawing.Point(25, 81); - this.checkBoxToolbarNew.Name = "checkBoxToolbarNew"; - this.checkBoxToolbarNew.Size = new System.Drawing.Size(55, 17); - this.checkBoxToolbarNew.TabIndex = 1; - this.checkBoxToolbarNew.Text = "Visible"; - this.checkBoxToolbarNew.UseVisualStyleBackColor = true; - // - // tabPageFont - // - this.tabPageFont.Controls.Add(this.groupBoxFont); - this.tabPageFont.Location = new System.Drawing.Point(4, 22); - this.tabPageFont.Name = "tabPageFont"; - this.tabPageFont.Size = new System.Drawing.Size(832, 520); - this.tabPageFont.TabIndex = 10; - this.tabPageFont.Text = "Font"; - this.tabPageFont.UseVisualStyleBackColor = true; - // - // groupBoxFont - // - this.groupBoxFont.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxFont.Controls.Add(this.labelFontNote); - this.groupBoxFont.Controls.Add(this.groupBoxFontTextBox); - this.groupBoxFont.Controls.Add(this.groupBoxFontListViews); - this.groupBoxFont.Controls.Add(this.groupBoxFontGeneral); - this.groupBoxFont.Location = new System.Drawing.Point(3, 3); - this.groupBoxFont.Name = "groupBoxFont"; - this.groupBoxFont.Size = new System.Drawing.Size(826, 509); - this.groupBoxFont.TabIndex = 0; - this.groupBoxFont.TabStop = false; - this.groupBoxFont.Text = "Font in UI"; - // - // labelFontNote - // - this.labelFontNote.AutoSize = true; - this.labelFontNote.Location = new System.Drawing.Point(11, 352); - this.labelFontNote.Name = "labelFontNote"; - this.labelFontNote.Size = new System.Drawing.Size(278, 13); - this.labelFontNote.TabIndex = 41; - this.labelFontNote.Text = "Note: This is only to set the font in the Subtitle Edit UI..."; - // - // groupBoxFontTextBox - // - this.groupBoxFontTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxFontTextBox.Controls.Add(this.panelTextBoxAssColor); - this.groupBoxFontTextBox.Controls.Add(this.buttonTextBoxAssColor); - this.groupBoxFontTextBox.Controls.Add(this.panelTextBoxHtmlColor); - this.groupBoxFontTextBox.Controls.Add(this.buttonTextBoxHtmlColor); - this.groupBoxFontTextBox.Controls.Add(this.checkBoxSubtitleTextBoxSyntaxColor); - this.groupBoxFontTextBox.Controls.Add(this.labelSubtitleFontSize); - this.groupBoxFontTextBox.Controls.Add(this.comboBoxSubtitleFontSize); - this.groupBoxFontTextBox.Controls.Add(this.checkBoxSubtitleFontBold); - this.groupBoxFontTextBox.Controls.Add(this.checkBoxSubtitleCenter); - this.groupBoxFontTextBox.Location = new System.Drawing.Point(14, 228); - this.groupBoxFontTextBox.Name = "groupBoxFontTextBox"; - this.groupBoxFontTextBox.Size = new System.Drawing.Size(806, 116); - this.groupBoxFontTextBox.TabIndex = 40; - this.groupBoxFontTextBox.TabStop = false; - this.groupBoxFontTextBox.Text = "Text box"; - // - // panelTextBoxAssColor - // - this.panelTextBoxAssColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelTextBoxAssColor.Location = new System.Drawing.Point(520, 73); - this.panelTextBoxAssColor.Name = "panelTextBoxAssColor"; - this.panelTextBoxAssColor.Size = new System.Drawing.Size(21, 20); - this.panelTextBoxAssColor.TabIndex = 38; - this.panelTextBoxAssColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelTextBoxAssColor_MouseClick); - // - // buttonTextBoxAssColor - // - this.buttonTextBoxAssColor.Location = new System.Drawing.Point(396, 72); - this.buttonTextBoxAssColor.Name = "buttonTextBoxAssColor"; - this.buttonTextBoxAssColor.Size = new System.Drawing.Size(112, 23); - this.buttonTextBoxAssColor.TabIndex = 36; - this.buttonTextBoxAssColor.Text = "ASSA color"; - this.buttonTextBoxAssColor.UseVisualStyleBackColor = true; - this.buttonTextBoxAssColor.Click += new System.EventHandler(this.buttonTextBoxAssColor_Click); - // - // panelTextBoxHtmlColor - // - this.panelTextBoxHtmlColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelTextBoxHtmlColor.Location = new System.Drawing.Point(520, 44); - this.panelTextBoxHtmlColor.Name = "panelTextBoxHtmlColor"; - this.panelTextBoxHtmlColor.Size = new System.Drawing.Size(21, 20); - this.panelTextBoxHtmlColor.TabIndex = 37; - this.panelTextBoxHtmlColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelTextBoxHtmlColor_MouseClick); - // - // buttonTextBoxHtmlColor - // - this.buttonTextBoxHtmlColor.Location = new System.Drawing.Point(396, 43); - this.buttonTextBoxHtmlColor.Name = "buttonTextBoxHtmlColor"; - this.buttonTextBoxHtmlColor.Size = new System.Drawing.Size(112, 23); - this.buttonTextBoxHtmlColor.TabIndex = 35; - this.buttonTextBoxHtmlColor.Text = "Html color"; - this.buttonTextBoxHtmlColor.UseVisualStyleBackColor = true; - this.buttonTextBoxHtmlColor.Click += new System.EventHandler(this.buttonTextBoxHtmlColor_Click); - // - // checkBoxSubtitleTextBoxSyntaxColor - // - this.checkBoxSubtitleTextBoxSyntaxColor.AutoSize = true; - this.checkBoxSubtitleTextBoxSyntaxColor.Location = new System.Drawing.Point(396, 20); - this.checkBoxSubtitleTextBoxSyntaxColor.Name = "checkBoxSubtitleTextBoxSyntaxColor"; - this.checkBoxSubtitleTextBoxSyntaxColor.Size = new System.Drawing.Size(120, 17); - this.checkBoxSubtitleTextBoxSyntaxColor.TabIndex = 34; - this.checkBoxSubtitleTextBoxSyntaxColor.Text = "Use syntax coloring"; - this.checkBoxSubtitleTextBoxSyntaxColor.UseVisualStyleBackColor = true; - this.checkBoxSubtitleTextBoxSyntaxColor.CheckedChanged += new System.EventHandler(this.checkBoxSubtitleTextBoxSyntaxColor_CheckedChanged); - // - // labelSubtitleFontSize - // - this.labelSubtitleFontSize.AutoSize = true; - this.labelSubtitleFontSize.Location = new System.Drawing.Point(18, 17); - this.labelSubtitleFontSize.Name = "labelSubtitleFontSize"; - this.labelSubtitleFontSize.Size = new System.Drawing.Size(87, 13); - this.labelSubtitleFontSize.TabIndex = 30; - this.labelSubtitleFontSize.Text = "Subtitle font size"; - // - // comboBoxSubtitleFontSize - // - this.comboBoxSubtitleFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSubtitleFontSize.FormattingEnabled = true; - this.comboBoxSubtitleFontSize.Items.AddRange(new object[] { - "7", - "8", - "9", - "10", - "11", - "12", - "13", - "14", - "15", - "16", - "17", - "18", - "19", - "20", - "21", - "22", - "23", - "24", - "25", - "26", - "27", - "28", - "29", - "30"}); - this.comboBoxSubtitleFontSize.Location = new System.Drawing.Point(215, 14); - this.comboBoxSubtitleFontSize.Name = "comboBoxSubtitleFontSize"; - this.comboBoxSubtitleFontSize.Size = new System.Drawing.Size(73, 21); - this.comboBoxSubtitleFontSize.TabIndex = 31; - // - // checkBoxSubtitleFontBold - // - this.checkBoxSubtitleFontBold.AutoSize = true; - this.checkBoxSubtitleFontBold.Location = new System.Drawing.Point(215, 41); - this.checkBoxSubtitleFontBold.Name = "checkBoxSubtitleFontBold"; - this.checkBoxSubtitleFontBold.Size = new System.Drawing.Size(46, 17); - this.checkBoxSubtitleFontBold.TabIndex = 32; - this.checkBoxSubtitleFontBold.Text = "Bold"; - this.checkBoxSubtitleFontBold.UseVisualStyleBackColor = true; - // - // checkBoxSubtitleCenter - // - this.checkBoxSubtitleCenter.AutoSize = true; - this.checkBoxSubtitleCenter.Location = new System.Drawing.Point(215, 64); - this.checkBoxSubtitleCenter.Name = "checkBoxSubtitleCenter"; - this.checkBoxSubtitleCenter.Size = new System.Drawing.Size(59, 17); - this.checkBoxSubtitleCenter.TabIndex = 33; - this.checkBoxSubtitleCenter.Text = "Center"; - this.checkBoxSubtitleCenter.UseVisualStyleBackColor = true; - // - // groupBoxFontListViews - // - this.groupBoxFontListViews.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxFontListViews.Controls.Add(this.labelSubtitleListViewFontSize); - this.groupBoxFontListViews.Controls.Add(this.comboBoxSubtitleListViewFontSize); - this.groupBoxFontListViews.Controls.Add(this.checkBoxSubtitleListViewFontBold); - this.groupBoxFontListViews.Location = new System.Drawing.Point(14, 141); - this.groupBoxFontListViews.Name = "groupBoxFontListViews"; - this.groupBoxFontListViews.Size = new System.Drawing.Size(806, 81); - this.groupBoxFontListViews.TabIndex = 39; - this.groupBoxFontListViews.TabStop = false; - this.groupBoxFontListViews.Text = "List view"; - // - // labelSubtitleListViewFontSize - // - this.labelSubtitleListViewFontSize.AutoSize = true; - this.labelSubtitleListViewFontSize.Location = new System.Drawing.Point(13, 17); - this.labelSubtitleListViewFontSize.Name = "labelSubtitleListViewFontSize"; - this.labelSubtitleListViewFontSize.Size = new System.Drawing.Size(87, 13); - this.labelSubtitleListViewFontSize.TabIndex = 33; - this.labelSubtitleListViewFontSize.Text = "Subtitle font size"; - // - // comboBoxSubtitleListViewFontSize - // - this.comboBoxSubtitleListViewFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSubtitleListViewFontSize.FormattingEnabled = true; - this.comboBoxSubtitleListViewFontSize.Items.AddRange(new object[] { - "7", - "8", - "9", - "10", - "11", - "12", - "13", - "14", - "15", - "16", - "17", - "18", - "19", - "20"}); - this.comboBoxSubtitleListViewFontSize.Location = new System.Drawing.Point(210, 14); - this.comboBoxSubtitleListViewFontSize.Name = "comboBoxSubtitleListViewFontSize"; - this.comboBoxSubtitleListViewFontSize.Size = new System.Drawing.Size(73, 21); - this.comboBoxSubtitleListViewFontSize.TabIndex = 34; - // - // checkBoxSubtitleListViewFontBold - // - this.checkBoxSubtitleListViewFontBold.AutoSize = true; - this.checkBoxSubtitleListViewFontBold.Location = new System.Drawing.Point(210, 41); - this.checkBoxSubtitleListViewFontBold.Name = "checkBoxSubtitleListViewFontBold"; - this.checkBoxSubtitleListViewFontBold.Size = new System.Drawing.Size(46, 17); - this.checkBoxSubtitleListViewFontBold.TabIndex = 35; - this.checkBoxSubtitleListViewFontBold.Text = "Bold"; - this.checkBoxSubtitleListViewFontBold.UseVisualStyleBackColor = true; - // - // groupBoxFontGeneral - // - this.groupBoxFontGeneral.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxFontGeneral.Controls.Add(this.comboBoxSubtitleFont); - this.groupBoxFontGeneral.Controls.Add(this.labelSubtitleFont); - this.groupBoxFontGeneral.Controls.Add(this.panelSubtitleFontColor); - this.groupBoxFontGeneral.Controls.Add(this.labelSubtitleFontColor); - this.groupBoxFontGeneral.Controls.Add(this.panelSubtitleBackgroundColor); - this.groupBoxFontGeneral.Controls.Add(this.labelSubtitleFontBackgroundColor); - this.groupBoxFontGeneral.Location = new System.Drawing.Point(14, 20); - this.groupBoxFontGeneral.Name = "groupBoxFontGeneral"; - this.groupBoxFontGeneral.Size = new System.Drawing.Size(806, 115); - this.groupBoxFontGeneral.TabIndex = 38; - this.groupBoxFontGeneral.TabStop = false; - this.groupBoxFontGeneral.Text = "General"; - // - // comboBoxSubtitleFont - // - this.comboBoxSubtitleFont.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSubtitleFont.FormattingEnabled = true; - this.comboBoxSubtitleFont.Location = new System.Drawing.Point(210, 20); - this.comboBoxSubtitleFont.Name = "comboBoxSubtitleFont"; - this.comboBoxSubtitleFont.Size = new System.Drawing.Size(188, 21); - this.comboBoxSubtitleFont.TabIndex = 29; - // - // labelSubtitleFont - // - this.labelSubtitleFont.AutoSize = true; - this.labelSubtitleFont.Location = new System.Drawing.Point(13, 26); - this.labelSubtitleFont.Name = "labelSubtitleFont"; - this.labelSubtitleFont.Size = new System.Drawing.Size(66, 13); - this.labelSubtitleFont.TabIndex = 28; - this.labelSubtitleFont.Text = "Subtitle font"; - // - // panelSubtitleFontColor - // - this.panelSubtitleFontColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelSubtitleFontColor.Location = new System.Drawing.Point(210, 51); - this.panelSubtitleFontColor.Name = "panelSubtitleFontColor"; - this.panelSubtitleFontColor.Size = new System.Drawing.Size(46, 15); - this.panelSubtitleFontColor.TabIndex = 35; - this.panelSubtitleFontColor.Click += new System.EventHandler(this.panelSubtitleFontColor_Click); - // - // labelSubtitleFontColor - // - this.labelSubtitleFontColor.AutoSize = true; - this.labelSubtitleFontColor.Location = new System.Drawing.Point(13, 50); - this.labelSubtitleFontColor.Name = "labelSubtitleFontColor"; - this.labelSubtitleFontColor.Size = new System.Drawing.Size(92, 13); - this.labelSubtitleFontColor.TabIndex = 34; - this.labelSubtitleFontColor.Text = "Subtitle font color"; - // - // panelSubtitleBackgroundColor - // - this.panelSubtitleBackgroundColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelSubtitleBackgroundColor.Location = new System.Drawing.Point(210, 71); - this.panelSubtitleBackgroundColor.Name = "panelSubtitleBackgroundColor"; - this.panelSubtitleBackgroundColor.Size = new System.Drawing.Size(46, 15); - this.panelSubtitleBackgroundColor.TabIndex = 37; - this.panelSubtitleBackgroundColor.Click += new System.EventHandler(this.panelSubtitleBackgroundColor_Click); - // - // labelSubtitleFontBackgroundColor - // - this.labelSubtitleFontBackgroundColor.AutoSize = true; - this.labelSubtitleFontBackgroundColor.Location = new System.Drawing.Point(13, 70); - this.labelSubtitleFontBackgroundColor.Name = "labelSubtitleFontBackgroundColor"; - this.labelSubtitleFontBackgroundColor.Size = new System.Drawing.Size(151, 13); - this.labelSubtitleFontBackgroundColor.TabIndex = 36; - this.labelSubtitleFontBackgroundColor.Text = "Subtitle font background color"; - // - // tabPageSsaStyle - // - this.tabPageSsaStyle.Controls.Add(this.groupBoxSsaStyle); - this.tabPageSsaStyle.Location = new System.Drawing.Point(4, 22); - this.tabPageSsaStyle.Name = "tabPageSsaStyle"; - this.tabPageSsaStyle.Padding = new System.Windows.Forms.Padding(3); - this.tabPageSsaStyle.Size = new System.Drawing.Size(832, 520); - this.tabPageSsaStyle.TabIndex = 1; - this.tabPageSsaStyle.Text = "SSA style"; - this.tabPageSsaStyle.UseVisualStyleBackColor = true; - // - // groupBoxSsaStyle - // - this.groupBoxSsaStyle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxSsaStyle.Controls.Add(this.groupBoxSsaBorder); - this.groupBoxSsaStyle.Controls.Add(this.groupSsaBoxFont); - this.groupBoxSsaStyle.Controls.Add(this.groupBoxMargins); - this.groupBoxSsaStyle.Controls.Add(this.groupBoxPreview); - this.groupBoxSsaStyle.Location = new System.Drawing.Point(6, 6); - this.groupBoxSsaStyle.Name = "groupBoxSsaStyle"; - this.groupBoxSsaStyle.Size = new System.Drawing.Size(819, 456); - this.groupBoxSsaStyle.TabIndex = 0; - this.groupBoxSsaStyle.TabStop = false; - this.groupBoxSsaStyle.Text = "Sub Station Alpha style"; - // - // groupBoxSsaBorder - // - this.groupBoxSsaBorder.Controls.Add(this.numericUpDownSsaOutline); - this.groupBoxSsaBorder.Controls.Add(this.labelSsaShadow); - this.groupBoxSsaBorder.Controls.Add(this.numericUpDownSsaShadow); - this.groupBoxSsaBorder.Controls.Add(this.checkBoxSsaOpaqueBox); - this.groupBoxSsaBorder.Controls.Add(this.labelSsaOutline); - this.groupBoxSsaBorder.Location = new System.Drawing.Point(329, 21); - this.groupBoxSsaBorder.Name = "groupBoxSsaBorder"; - this.groupBoxSsaBorder.Size = new System.Drawing.Size(185, 96); - this.groupBoxSsaBorder.TabIndex = 8; - this.groupBoxSsaBorder.TabStop = false; - this.groupBoxSsaBorder.Text = "Border"; - // - // numericUpDownSsaOutline - // - this.numericUpDownSsaOutline.Location = new System.Drawing.Point(64, 16); - this.numericUpDownSsaOutline.Maximum = new decimal(new int[] { - 9, - 0, - 0, - 0}); - this.numericUpDownSsaOutline.Name = "numericUpDownSsaOutline"; - this.numericUpDownSsaOutline.Size = new System.Drawing.Size(44, 21); - this.numericUpDownSsaOutline.TabIndex = 5; - this.numericUpDownSsaOutline.ValueChanged += new System.EventHandler(this.numericUpDownSsaOutline_ValueChanged); - // - // labelSsaShadow - // - this.labelSsaShadow.AutoSize = true; - this.labelSsaShadow.Location = new System.Drawing.Point(10, 45); - this.labelSsaShadow.Name = "labelSsaShadow"; - this.labelSsaShadow.Size = new System.Drawing.Size(45, 13); - this.labelSsaShadow.TabIndex = 6; - this.labelSsaShadow.Text = "Shadow"; - // - // numericUpDownSsaShadow - // - this.numericUpDownSsaShadow.Location = new System.Drawing.Point(64, 43); - this.numericUpDownSsaShadow.Maximum = new decimal(new int[] { - 9, - 0, - 0, - 0}); - this.numericUpDownSsaShadow.Name = "numericUpDownSsaShadow"; - this.numericUpDownSsaShadow.Size = new System.Drawing.Size(44, 21); - this.numericUpDownSsaShadow.TabIndex = 7; - this.numericUpDownSsaShadow.ValueChanged += new System.EventHandler(this.numericUpDownSsaShadow_ValueChanged); - // - // checkBoxSsaOpaqueBox - // - this.checkBoxSsaOpaqueBox.AutoSize = true; - this.checkBoxSsaOpaqueBox.Location = new System.Drawing.Point(13, 71); - this.checkBoxSsaOpaqueBox.Name = "checkBoxSsaOpaqueBox"; - this.checkBoxSsaOpaqueBox.Size = new System.Drawing.Size(85, 17); - this.checkBoxSsaOpaqueBox.TabIndex = 8; - this.checkBoxSsaOpaqueBox.Text = "Opaque box"; - this.checkBoxSsaOpaqueBox.UseVisualStyleBackColor = true; - this.checkBoxSsaOpaqueBox.CheckedChanged += new System.EventHandler(this.checkBoxSsaOpaqueBox_CheckedChanged); - // - // labelSsaOutline - // - this.labelSsaOutline.AutoSize = true; - this.labelSsaOutline.Location = new System.Drawing.Point(10, 20); - this.labelSsaOutline.Name = "labelSsaOutline"; - this.labelSsaOutline.Size = new System.Drawing.Size(41, 13); - this.labelSsaOutline.TabIndex = 4; - this.labelSsaOutline.Text = "Outline"; - // - // groupSsaBoxFont - // - this.groupSsaBoxFont.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupSsaBoxFont.Controls.Add(this.checkBoxSsaFontBold); - this.groupSsaBoxFont.Controls.Add(this.buttonSsaColor); - this.groupSsaBoxFont.Controls.Add(this.panelPrimaryColor); - this.groupSsaBoxFont.Controls.Add(this.numericUpDownFontSize); - this.groupSsaBoxFont.Controls.Add(this.comboBoxFontName); - this.groupSsaBoxFont.Controls.Add(this.labelSsaFontSize); - this.groupSsaBoxFont.Controls.Add(this.labelFontName); - this.groupSsaBoxFont.Location = new System.Drawing.Point(6, 20); - this.groupSsaBoxFont.Name = "groupSsaBoxFont"; - this.groupSsaBoxFont.Size = new System.Drawing.Size(323, 97); - this.groupSsaBoxFont.TabIndex = 7; - this.groupSsaBoxFont.TabStop = false; - this.groupSsaBoxFont.Text = "Font"; - // - // checkBoxSsaFontBold - // - this.checkBoxSsaFontBold.AutoSize = true; - this.checkBoxSsaFontBold.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.checkBoxSsaFontBold.Location = new System.Drawing.Point(184, 45); - this.checkBoxSsaFontBold.Name = "checkBoxSsaFontBold"; - this.checkBoxSsaFontBold.Size = new System.Drawing.Size(51, 17); - this.checkBoxSsaFontBold.TabIndex = 7; - this.checkBoxSsaFontBold.Text = "Bold"; - this.checkBoxSsaFontBold.UseVisualStyleBackColor = true; - this.checkBoxSsaFontBold.CheckedChanged += new System.EventHandler(this.checkBoxSsaFontBold_CheckedChanged); - // - // buttonSsaColor - // - this.buttonSsaColor.Location = new System.Drawing.Point(6, 66); - this.buttonSsaColor.Name = "buttonSsaColor"; - this.buttonSsaColor.Size = new System.Drawing.Size(109, 23); - this.buttonSsaColor.TabIndex = 6; - this.buttonSsaColor.Text = "Choose color"; - this.buttonSsaColor.UseVisualStyleBackColor = true; - this.buttonSsaColor.Click += new System.EventHandler(this.buttonSsaColor_Click); - // - // panelPrimaryColor - // - this.panelPrimaryColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelPrimaryColor.Location = new System.Drawing.Point(121, 68); - this.panelPrimaryColor.Name = "panelPrimaryColor"; - this.panelPrimaryColor.Size = new System.Drawing.Size(21, 20); - this.panelPrimaryColor.TabIndex = 4; - this.panelPrimaryColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelPrimaryColor_MouseClick); - // - // numericUpDownFontSize - // - this.numericUpDownFontSize.Location = new System.Drawing.Point(121, 44); - this.numericUpDownFontSize.Maximum = new decimal(new int[] { - 200, - 0, - 0, - 0}); - this.numericUpDownFontSize.Name = "numericUpDownFontSize"; - this.numericUpDownFontSize.Size = new System.Drawing.Size(51, 21); - this.numericUpDownFontSize.TabIndex = 3; - this.numericUpDownFontSize.ValueChanged += new System.EventHandler(this.numericUpDownFontSize_ValueChanged); - // - // comboBoxFontName - // - this.comboBoxFontName.FormattingEnabled = true; - this.comboBoxFontName.Location = new System.Drawing.Point(121, 17); - this.comboBoxFontName.Name = "comboBoxFontName"; - this.comboBoxFontName.Size = new System.Drawing.Size(188, 21); - this.comboBoxFontName.TabIndex = 1; - this.comboBoxFontName.TextChanged += new System.EventHandler(this.comboBoxFontName_TextChanged); - // - // labelSsaFontSize - // - this.labelSsaFontSize.AutoSize = true; - this.labelSsaFontSize.Location = new System.Drawing.Point(10, 46); - this.labelSsaFontSize.Name = "labelSsaFontSize"; - this.labelSsaFontSize.Size = new System.Drawing.Size(50, 13); - this.labelSsaFontSize.TabIndex = 2; - this.labelSsaFontSize.Text = "Font size"; - // - // labelFontName - // - this.labelFontName.AutoSize = true; - this.labelFontName.Location = new System.Drawing.Point(10, 20); - this.labelFontName.Name = "labelFontName"; - this.labelFontName.Size = new System.Drawing.Size(58, 13); - this.labelFontName.TabIndex = 0; - this.labelFontName.Text = "Font name"; - // - // groupBoxMargins - // - this.groupBoxMargins.Controls.Add(this.numericUpDownSsaMarginVertical); - this.groupBoxMargins.Controls.Add(this.numericUpDownSsaMarginRight); - this.groupBoxMargins.Controls.Add(this.numericUpDownSsaMarginLeft); - this.groupBoxMargins.Controls.Add(this.labelMarginVertical); - this.groupBoxMargins.Controls.Add(this.labelMarginRight); - this.groupBoxMargins.Controls.Add(this.labelMarginLeft); - this.groupBoxMargins.Location = new System.Drawing.Point(520, 20); - this.groupBoxMargins.Name = "groupBoxMargins"; - this.groupBoxMargins.Size = new System.Drawing.Size(281, 97); - this.groupBoxMargins.TabIndex = 9; - this.groupBoxMargins.TabStop = false; - this.groupBoxMargins.Text = "Margins"; - // - // numericUpDownSsaMarginVertical - // - this.numericUpDownSsaMarginVertical.Location = new System.Drawing.Point(168, 33); - this.numericUpDownSsaMarginVertical.Maximum = new decimal(new int[] { - 1000, - 0, - 0, - 0}); - this.numericUpDownSsaMarginVertical.Name = "numericUpDownSsaMarginVertical"; - this.numericUpDownSsaMarginVertical.Size = new System.Drawing.Size(44, 21); - this.numericUpDownSsaMarginVertical.TabIndex = 5; - this.numericUpDownSsaMarginVertical.ValueChanged += new System.EventHandler(this.numericUpDownSsaMarginVertical_ValueChanged); - // - // numericUpDownSsaMarginRight - // - this.numericUpDownSsaMarginRight.Location = new System.Drawing.Point(93, 33); - this.numericUpDownSsaMarginRight.Maximum = new decimal(new int[] { - 1000, - 0, - 0, - 0}); - this.numericUpDownSsaMarginRight.Name = "numericUpDownSsaMarginRight"; - this.numericUpDownSsaMarginRight.Size = new System.Drawing.Size(44, 21); - this.numericUpDownSsaMarginRight.TabIndex = 3; - // - // numericUpDownSsaMarginLeft - // - this.numericUpDownSsaMarginLeft.Location = new System.Drawing.Point(16, 33); - this.numericUpDownSsaMarginLeft.Maximum = new decimal(new int[] { - 1000, - 0, - 0, - 0}); - this.numericUpDownSsaMarginLeft.Name = "numericUpDownSsaMarginLeft"; - this.numericUpDownSsaMarginLeft.Size = new System.Drawing.Size(44, 21); - this.numericUpDownSsaMarginLeft.TabIndex = 1; - // - // labelMarginVertical - // - this.labelMarginVertical.AutoSize = true; - this.labelMarginVertical.Location = new System.Drawing.Point(165, 17); - this.labelMarginVertical.Name = "labelMarginVertical"; - this.labelMarginVertical.Size = new System.Drawing.Size(42, 13); - this.labelMarginVertical.TabIndex = 4; - this.labelMarginVertical.Text = "Vertical"; - // - // labelMarginRight - // - this.labelMarginRight.AutoSize = true; - this.labelMarginRight.Location = new System.Drawing.Point(90, 16); - this.labelMarginRight.Name = "labelMarginRight"; - this.labelMarginRight.Size = new System.Drawing.Size(32, 13); - this.labelMarginRight.TabIndex = 2; - this.labelMarginRight.Text = "Right"; - // - // labelMarginLeft - // - this.labelMarginLeft.AutoSize = true; - this.labelMarginLeft.Location = new System.Drawing.Point(13, 16); - this.labelMarginLeft.Name = "labelMarginLeft"; - this.labelMarginLeft.Size = new System.Drawing.Size(26, 13); - this.labelMarginLeft.TabIndex = 0; - this.labelMarginLeft.Text = "Left"; - // - // groupBoxPreview - // - this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxPreview.Controls.Add(this.pictureBoxPreview); - this.groupBoxPreview.Location = new System.Drawing.Point(6, 118); - this.groupBoxPreview.Name = "groupBoxPreview"; - this.groupBoxPreview.Size = new System.Drawing.Size(807, 332); - this.groupBoxPreview.TabIndex = 10; - this.groupBoxPreview.TabStop = false; - this.groupBoxPreview.Text = "Preview"; - // - // pictureBoxPreview - // - this.pictureBoxPreview.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxPreview.Location = new System.Drawing.Point(3, 17); - this.pictureBoxPreview.Name = "pictureBoxPreview"; - this.pictureBoxPreview.Size = new System.Drawing.Size(801, 312); - this.pictureBoxPreview.TabIndex = 0; - this.pictureBoxPreview.TabStop = false; - this.pictureBoxPreview.Click += new System.EventHandler(this.pictureBoxPreview_Click); - // - // tabPageNetwork - // - this.tabPageNetwork.Controls.Add(this.groupBoxNetworkSession); - this.tabPageNetwork.Controls.Add(this.groupBoxProxySettings); - this.tabPageNetwork.Location = new System.Drawing.Point(4, 22); - this.tabPageNetwork.Name = "tabPageNetwork"; - this.tabPageNetwork.Padding = new System.Windows.Forms.Padding(3); - this.tabPageNetwork.Size = new System.Drawing.Size(832, 520); - this.tabPageNetwork.TabIndex = 4; - this.tabPageNetwork.Text = "Network"; - this.tabPageNetwork.UseVisualStyleBackColor = true; - // - // groupBoxNetworkSession - // - this.groupBoxNetworkSession.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxNetworkSession.Controls.Add(this.buttonNetworkSessionNewMessageSound); - this.groupBoxNetworkSession.Controls.Add(this.textBoxNetworkSessionNewMessageSound); - this.groupBoxNetworkSession.Controls.Add(this.labelNetworkSessionNewMessageSound); - this.groupBoxNetworkSession.Location = new System.Drawing.Point(6, 189); - this.groupBoxNetworkSession.Name = "groupBoxNetworkSession"; - this.groupBoxNetworkSession.Size = new System.Drawing.Size(819, 320); - this.groupBoxNetworkSession.TabIndex = 30; - this.groupBoxNetworkSession.TabStop = false; - this.groupBoxNetworkSession.Text = "Network session settings"; - // - // buttonNetworkSessionNewMessageSound - // - this.buttonNetworkSessionNewMessageSound.Location = new System.Drawing.Point(352, 49); - this.buttonNetworkSessionNewMessageSound.Name = "buttonNetworkSessionNewMessageSound"; - this.buttonNetworkSessionNewMessageSound.Size = new System.Drawing.Size(29, 21); - this.buttonNetworkSessionNewMessageSound.TabIndex = 24; - this.buttonNetworkSessionNewMessageSound.Text = "..."; - this.buttonNetworkSessionNewMessageSound.UseVisualStyleBackColor = true; - this.buttonNetworkSessionNewMessageSound.Click += new System.EventHandler(this.buttonNetworkSessionNewMessageSound_Click); - // - // textBoxNetworkSessionNewMessageSound - // - this.textBoxNetworkSessionNewMessageSound.Location = new System.Drawing.Point(28, 50); - this.textBoxNetworkSessionNewMessageSound.Name = "textBoxNetworkSessionNewMessageSound"; - this.textBoxNetworkSessionNewMessageSound.Size = new System.Drawing.Size(318, 21); - this.textBoxNetworkSessionNewMessageSound.TabIndex = 20; - // - // labelNetworkSessionNewMessageSound - // - this.labelNetworkSessionNewMessageSound.AutoSize = true; - this.labelNetworkSessionNewMessageSound.Location = new System.Drawing.Point(25, 34); - this.labelNetworkSessionNewMessageSound.Name = "labelNetworkSessionNewMessageSound"; - this.labelNetworkSessionNewMessageSound.Size = new System.Drawing.Size(209, 13); - this.labelNetworkSessionNewMessageSound.TabIndex = 3; - this.labelNetworkSessionNewMessageSound.Text = "Play sound file when new message arrives"; - // - // groupBoxProxySettings - // - this.groupBoxProxySettings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxProxySettings.Controls.Add(this.groupBoxProxyAuthentication); - this.groupBoxProxySettings.Controls.Add(this.textBoxProxyAddress); - this.groupBoxProxySettings.Controls.Add(this.labelProxyAddress); - this.groupBoxProxySettings.Location = new System.Drawing.Point(6, 6); - this.groupBoxProxySettings.Name = "groupBoxProxySettings"; - this.groupBoxProxySettings.Size = new System.Drawing.Size(819, 177); - this.groupBoxProxySettings.TabIndex = 1; - this.groupBoxProxySettings.TabStop = false; - this.groupBoxProxySettings.Text = "Proxy server settings"; - // - // groupBoxProxyAuthentication - // - this.groupBoxProxyAuthentication.Controls.Add(this.textBoxProxyDomain); - this.groupBoxProxyAuthentication.Controls.Add(this.labelProxyDomain); - this.groupBoxProxyAuthentication.Controls.Add(this.textBoxProxyUserName); - this.groupBoxProxyAuthentication.Controls.Add(this.labelProxyPassword); - this.groupBoxProxyAuthentication.Controls.Add(this.labelProxyUserName); - this.groupBoxProxyAuthentication.Controls.Add(this.textBoxProxyPassword); - this.groupBoxProxyAuthentication.Location = new System.Drawing.Point(28, 60); - this.groupBoxProxyAuthentication.Name = "groupBoxProxyAuthentication"; - this.groupBoxProxyAuthentication.Size = new System.Drawing.Size(318, 101); - this.groupBoxProxyAuthentication.TabIndex = 29; - this.groupBoxProxyAuthentication.TabStop = false; - this.groupBoxProxyAuthentication.Text = "Authentication"; - // - // textBoxProxyDomain - // - this.textBoxProxyDomain.Location = new System.Drawing.Point(106, 71); - this.textBoxProxyDomain.Name = "textBoxProxyDomain"; - this.textBoxProxyDomain.Size = new System.Drawing.Size(192, 21); - this.textBoxProxyDomain.TabIndex = 30; - // - // labelProxyDomain - // - this.labelProxyDomain.AutoSize = true; - this.labelProxyDomain.Location = new System.Drawing.Point(12, 74); - this.labelProxyDomain.Name = "labelProxyDomain"; - this.labelProxyDomain.Size = new System.Drawing.Size(42, 13); - this.labelProxyDomain.TabIndex = 29; - this.labelProxyDomain.Text = "Domain"; - // - // textBoxProxyUserName - // - this.textBoxProxyUserName.Location = new System.Drawing.Point(106, 19); - this.textBoxProxyUserName.Name = "textBoxProxyUserName"; - this.textBoxProxyUserName.Size = new System.Drawing.Size(192, 21); - this.textBoxProxyUserName.TabIndex = 22; - // - // labelProxyPassword - // - this.labelProxyPassword.AutoSize = true; - this.labelProxyPassword.Location = new System.Drawing.Point(12, 48); - this.labelProxyPassword.Name = "labelProxyPassword"; - this.labelProxyPassword.Size = new System.Drawing.Size(53, 13); - this.labelProxyPassword.TabIndex = 28; - this.labelProxyPassword.Text = "Password"; - // - // labelProxyUserName - // - this.labelProxyUserName.AutoSize = true; - this.labelProxyUserName.Location = new System.Drawing.Point(12, 22); - this.labelProxyUserName.Name = "labelProxyUserName"; - this.labelProxyUserName.Size = new System.Drawing.Size(58, 13); - this.labelProxyUserName.TabIndex = 2; - this.labelProxyUserName.Text = "User name"; - // - // textBoxProxyPassword - // - this.textBoxProxyPassword.Location = new System.Drawing.Point(106, 45); - this.textBoxProxyPassword.Name = "textBoxProxyPassword"; - this.textBoxProxyPassword.Size = new System.Drawing.Size(192, 21); - this.textBoxProxyPassword.TabIndex = 24; - this.textBoxProxyPassword.UseSystemPasswordChar = true; - // - // textBoxProxyAddress - // - this.textBoxProxyAddress.Location = new System.Drawing.Point(134, 34); - this.textBoxProxyAddress.Name = "textBoxProxyAddress"; - this.textBoxProxyAddress.Size = new System.Drawing.Size(192, 21); - this.textBoxProxyAddress.TabIndex = 20; - // - // labelProxyAddress - // - this.labelProxyAddress.AutoSize = true; - this.labelProxyAddress.Location = new System.Drawing.Point(25, 34); - this.labelProxyAddress.Name = "labelProxyAddress"; - this.labelProxyAddress.Size = new System.Drawing.Size(76, 13); - this.labelProxyAddress.TabIndex = 3; - this.labelProxyAddress.Text = "Proxy address"; - // - // labelStatus - // - this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelStatus.AutoSize = true; - this.labelStatus.Location = new System.Drawing.Point(12, 573); - this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(60, 13); - this.labelStatus.TabIndex = 3; - this.labelStatus.Text = "labelStatus"; - // - // openFileDialogFFmpeg - // - this.openFileDialogFFmpeg.FileName = "openFileDialog1"; - // - // buttonReset - // - this.buttonReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonReset.Location = new System.Drawing.Point(668, 563); - this.buttonReset.Name = "buttonReset"; - this.buttonReset.Size = new System.Drawing.Size(185, 23); - this.buttonReset.TabIndex = 2; - this.buttonReset.Text = "Restore default settings"; - this.buttonReset.UseVisualStyleBackColor = true; - this.buttonReset.Click += new System.EventHandler(this.buttonReset_Click); - // - // toolTipContinuationPreview - // - this.toolTipContinuationPreview.AutoPopDelay = 60000; - this.toolTipContinuationPreview.InitialDelay = 500; - this.toolTipContinuationPreview.ReshowDelay = 100; - // - // Settings - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(865, 598); - this.Controls.Add(this.buttonReset); - this.Controls.Add(this.labelStatus); - this.Controls.Add(this.tabControlSettings); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "Settings"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Settings"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormSettings_KeyDown); - this.tabControlSettings.ResumeLayout(false); - this.tabPageGeneral.ResumeLayout(false); - this.groupBoxMiscellaneous.ResumeLayout(false); - this.groupBoxMiscellaneous.PerformLayout(); - this.groupBoxGeneralRules.ResumeLayout(false); - this.groupBoxGeneralRules.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxWordsMin)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxNumberOfLines)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMin)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMax)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinGapMs)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharsSec)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSubtitleLineMaximumLength)).EndInit(); - this.tabPageShortcuts.ResumeLayout(false); - this.groupBoxShortcuts.ResumeLayout(false); - this.groupBoxShortcuts.PerformLayout(); - this.contextMenuStripShortcuts.ResumeLayout(false); - this.tabPageSyntaxColoring.ResumeLayout(false); - this.groupBoxListViewSyntaxColoring.ResumeLayout(false); - this.groupBoxListViewSyntaxColoring.PerformLayout(); - this.tabPageVideoPlayer.ResumeLayout(false); - this.groupBoxMainWindowVideoControls.ResumeLayout(false); - this.groupBoxMainWindowVideoControls.PerformLayout(); - this.groupBoxVideoPlayerDefault.ResumeLayout(false); - this.groupBoxVideoPlayerDefault.PerformLayout(); - this.groupBoxVideoEngine.ResumeLayout(false); - this.groupBoxVideoEngine.PerformLayout(); - this.tabPageWaveform.ResumeLayout(false); - this.groupBoxFfmpeg.ResumeLayout(false); - this.groupBoxFfmpeg.PerformLayout(); - this.groupBoxSpectrogram.ResumeLayout(false); - this.groupBoxSpectrogram.PerformLayout(); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.groupBoxWaveformAppearence.ResumeLayout(false); - this.groupBoxWaveformAppearence.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWaveformBorderHitMs)).EndInit(); - this.tabPageTools.ResumeLayout(false); - this.groupBoxGoogleTranslate.ResumeLayout(false); - this.groupBoxGoogleTranslate.PerformLayout(); - this.groupBoxBing.ResumeLayout(false); - this.groupBoxBing.PerformLayout(); - this.groupBoxToolsAutoBr.ResumeLayout(false); - this.groupBoxToolsAutoBr.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownToolsBreakPreferBottomHeavy)).EndInit(); - this.groupBoxSpellCheck.ResumeLayout(false); - this.groupBoxSpellCheck.PerformLayout(); - this.groupBoxFixCommonErrors.ResumeLayout(false); - this.groupBoxFixCommonErrors.PerformLayout(); - this.groupBoxToolsVisualSync.ResumeLayout(false); - this.groupBoxToolsVisualSync.PerformLayout(); - this.tabPageWordLists.ResumeLayout(false); - this.groupBoxWordLists.ResumeLayout(false); - this.groupBoxWordLists.PerformLayout(); - this.groupBoxOcrFixList.ResumeLayout(false); - this.groupBoxOcrFixList.PerformLayout(); - this.groupBoxUserWordList.ResumeLayout(false); - this.groupBoxUserWordList.PerformLayout(); - this.groupBoxWordListLocation.ResumeLayout(false); - this.groupBoxWordListLocation.PerformLayout(); - this.groupBoxNamesIgonoreLists.ResumeLayout(false); - this.groupBoxNamesIgonoreLists.PerformLayout(); - this.tabPageToolBar.ResumeLayout(false); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - this.groupBoxShowToolBarButtons.ResumeLayout(false); - this.groupBoxShowToolBarButtons.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxNetflixQualityCheck)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBRemoveTextForHi)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBFixCommonErrors)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHelp)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSettings)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSpellCheck)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxVisualSync)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxReplace)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxFind)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSaveAs)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSave)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxOpen)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxNew)).EndInit(); - this.tabPageFont.ResumeLayout(false); - this.groupBoxFont.ResumeLayout(false); - this.groupBoxFont.PerformLayout(); - this.groupBoxFontTextBox.ResumeLayout(false); - this.groupBoxFontTextBox.PerformLayout(); - this.groupBoxFontListViews.ResumeLayout(false); - this.groupBoxFontListViews.PerformLayout(); - this.groupBoxFontGeneral.ResumeLayout(false); - this.groupBoxFontGeneral.PerformLayout(); - this.tabPageSsaStyle.ResumeLayout(false); - this.groupBoxSsaStyle.ResumeLayout(false); - this.groupBoxSsaBorder.ResumeLayout(false); - this.groupBoxSsaBorder.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaOutline)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaShadow)).EndInit(); - this.groupSsaBoxFont.ResumeLayout(false); - this.groupSsaBoxFont.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSize)).EndInit(); - this.groupBoxMargins.ResumeLayout(false); - this.groupBoxMargins.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaMarginVertical)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaMarginRight)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaMarginLeft)).EndInit(); - this.groupBoxPreview.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).EndInit(); - this.tabPageNetwork.ResumeLayout(false); - this.groupBoxNetworkSession.ResumeLayout(false); - this.groupBoxNetworkSession.PerformLayout(); - this.groupBoxProxySettings.ResumeLayout(false); - this.groupBoxProxySettings.PerformLayout(); - this.groupBoxProxyAuthentication.ResumeLayout(false); - this.groupBoxProxyAuthentication.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.TabControl tabControlSettings; - private System.Windows.Forms.TabPage tabPageGeneral; - private System.Windows.Forms.TabPage tabPageSsaStyle; - private System.Windows.Forms.GroupBox groupBoxMiscellaneous; - private System.Windows.Forms.GroupBox groupBoxShowToolBarButtons; - private System.Windows.Forms.PictureBox pictureBoxNew; - private System.Windows.Forms.CheckBox checkBoxToolbarNew; - private System.Windows.Forms.Label labelTBSpellCheck; - private System.Windows.Forms.PictureBox pictureBoxSpellCheck; - private System.Windows.Forms.CheckBox checkBoxSpellCheck; - private System.Windows.Forms.Label labelTBVisualSync; - private System.Windows.Forms.PictureBox pictureBoxVisualSync; - private System.Windows.Forms.CheckBox checkBoxVisualSync; - private System.Windows.Forms.Label labelTBReplace; - private System.Windows.Forms.PictureBox pictureBoxReplace; - private System.Windows.Forms.CheckBox checkBoxReplace; - private System.Windows.Forms.Label labelTBFind; - private System.Windows.Forms.PictureBox pictureBoxFind; - private System.Windows.Forms.CheckBox checkBoxToolbarFind; - private System.Windows.Forms.Label labelTBSaveAs; - private System.Windows.Forms.PictureBox pictureBoxSaveAs; - private System.Windows.Forms.CheckBox checkBoxToolbarSaveAs; - private System.Windows.Forms.Label labelTBSave; - private System.Windows.Forms.PictureBox pictureBoxSave; - private System.Windows.Forms.CheckBox checkBoxToolbarSave; - private System.Windows.Forms.Label labelTBOpen; - private System.Windows.Forms.PictureBox pictureBoxOpen; - private System.Windows.Forms.CheckBox checkBoxToolbarOpen; - private System.Windows.Forms.Label labelTBNew; - private System.Windows.Forms.Label labelTBHelp; - private System.Windows.Forms.PictureBox pictureBoxHelp; - private System.Windows.Forms.CheckBox checkBoxHelp; - private System.Windows.Forms.Label labelTBSettings; - private System.Windows.Forms.PictureBox pictureBoxSettings; - private System.Windows.Forms.CheckBox checkBoxSettings; - private System.Windows.Forms.Label labelDefaultFrameRate; - private System.Windows.Forms.Label labelDefaultFileEncoding; - private System.Windows.Forms.ComboBox comboBoxFrameRate; - private System.Windows.Forms.ComboBox comboBoxEncoding; - private System.Windows.Forms.CheckBox checkBoxRememberRecentFiles; - private System.Windows.Forms.GroupBox groupBoxSsaStyle; - private System.Windows.Forms.ColorDialog colorDialogSSAStyle; - private System.Windows.Forms.CheckBox checkBoxStartInSourceView; - private System.Windows.Forms.CheckBox checkBoxReopenLastOpened; - private System.Windows.Forms.Label labelSubMaxLen; - private System.Windows.Forms.TabPage tabPageVideoPlayer; - private System.Windows.Forms.CheckBox checkBoxVideoPlayerShowStopButton; - private System.Windows.Forms.GroupBox groupBoxVideoEngine; - private System.Windows.Forms.Label labelVideoPlayerMPlayer; - private System.Windows.Forms.Label labelDirectShowDescription; - private System.Windows.Forms.Label labelMpcHcDescription; - private System.Windows.Forms.RadioButton radioButtonVideoPlayerMPV; - private System.Windows.Forms.RadioButton radioButtonVideoPlayerDirectShow; - private System.Windows.Forms.RadioButton radioButtonVideoPlayerMpcHc; - private System.Windows.Forms.CheckBox checkBoxRememberWindowPosition; - private System.Windows.Forms.TextBox textBoxShowLineBreaksAs; - private System.Windows.Forms.Label labelShowLineBreaksAs; - private System.Windows.Forms.TabPage tabPageWordLists; - private System.Windows.Forms.GroupBox groupBoxWordLists; - private System.Windows.Forms.GroupBox groupBoxWordListLocation; - private System.Windows.Forms.GroupBox groupBoxOcrFixList; - private System.Windows.Forms.GroupBox groupBoxNamesIgonoreLists; - private System.Windows.Forms.TextBox textBoxNameEtc; - private System.Windows.Forms.Label labelWordListLanguage; - private System.Windows.Forms.Button buttonAddNames; - private System.Windows.Forms.ComboBox comboBoxWordListLanguage; - private System.Windows.Forms.Button buttonRemoveNameEtc; - private System.Windows.Forms.ListBox listBoxNames; - private System.Windows.Forms.Button buttonRemoveOcrFix; - private System.Windows.Forms.ListBox listBoxOcrFixList; - private System.Windows.Forms.TextBox textBoxOcrFixKey; - private System.Windows.Forms.Button buttonAddOcrFix; - private System.Windows.Forms.GroupBox groupBoxUserWordList; - private System.Windows.Forms.Button buttonRemoveUserWord; - private System.Windows.Forms.ListBox listBoxUserWordLists; - private System.Windows.Forms.TextBox textBoxUserWord; - private System.Windows.Forms.Button buttonAddUserWord; - private System.Windows.Forms.TabPage tabPageNetwork; - private System.Windows.Forms.GroupBox groupBoxProxySettings; - private System.Windows.Forms.Label labelProxyPassword; - private System.Windows.Forms.TextBox textBoxProxyAddress; - private System.Windows.Forms.TextBox textBoxProxyUserName; - private System.Windows.Forms.TextBox textBoxProxyPassword; - private System.Windows.Forms.Label labelProxyAddress; - private System.Windows.Forms.Label labelProxyUserName; - private System.Windows.Forms.CheckBox checkBoxNamesOnline; - private System.Windows.Forms.TextBox textBoxNamesOnline; - private System.Windows.Forms.TextBox textBoxOcrFixValue; - private System.Windows.Forms.TabPage tabPageTools; - private System.Windows.Forms.GroupBox groupBoxToolsVisualSync; - private System.Windows.Forms.ComboBox comboBoxToolsVerifySeconds; - private System.Windows.Forms.Label labelVerifyButton; - private System.Windows.Forms.Label labelToolsEndScene; - private System.Windows.Forms.ComboBox comboBoxToolsEndSceneIndex; - private System.Windows.Forms.Label labelToolsStartScene; - private System.Windows.Forms.ComboBox comboBoxToolsStartSceneIndex; - private System.Windows.Forms.GroupBox groupBoxFixCommonErrors; - private System.Windows.Forms.Label labelToolsMusicSymbol; - private System.Windows.Forms.ComboBox comboBoxListViewDoubleClickEvent; - private System.Windows.Forms.Label labelListViewDoubleClickEvent; - private System.Windows.Forms.Label labelStatus; - private System.Windows.Forms.TextBox textBoxMusicSymbolsToReplace; - private System.Windows.Forms.Label labelToolsMusicSymbolsToReplace; - private System.Windows.Forms.ComboBox comboBoxToolsMusicSymbol; - private System.Windows.Forms.GroupBox groupBoxSpellCheck; - private System.Windows.Forms.CheckBox checkBoxSpellCheckAutoChangeNames; - private System.Windows.Forms.GroupBox groupBoxProxyAuthentication; - private System.Windows.Forms.TextBox textBoxProxyDomain; - private System.Windows.Forms.Label labelProxyDomain; - private System.Windows.Forms.CheckBox checkBoxAutoDetectAnsiEncoding; - private System.Windows.Forms.Label labelAutoDetectAnsiEncoding; - private System.Windows.Forms.Label labelVideoPlayerVLC; - private System.Windows.Forms.RadioButton radioButtonVideoPlayerVLC; - private System.Windows.Forms.CheckBox checkBoxRemoveBlankLinesWhenOpening; - private System.Windows.Forms.GroupBox groupBoxMainWindowVideoControls; - private System.Windows.Forms.GroupBox groupBoxVideoPlayerDefault; - private System.Windows.Forms.TextBox textBoxCustomSearchUrl1; - private System.Windows.Forms.Label labelCustomSearch; - private System.Windows.Forms.ComboBox comboBoxCustomSearch1; - private System.Windows.Forms.TabPage tabPageWaveform; - private System.Windows.Forms.GroupBox groupBoxWaveformAppearence; - private System.Windows.Forms.Panel panelWaveformBackgroundColor; - private System.Windows.Forms.Button buttonWaveformBackgroundColor; - private System.Windows.Forms.Panel panelWaveformColor; - private System.Windows.Forms.Button buttonWaveformColor; - private System.Windows.Forms.Panel panelWaveformSelectedColor; - private System.Windows.Forms.Button buttonWaveformSelectedColor; - private System.Windows.Forms.CheckBox checkBoxWaveformShowGrid; - private System.Windows.Forms.Panel panelWaveformGridColor; - private System.Windows.Forms.Button buttonWaveformGridColor; - private System.Windows.Forms.Panel panelWaveformTextColor; - private System.Windows.Forms.Button buttonWaveformTextColor; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.Button buttonWaveformsFolderEmpty; - private System.Windows.Forms.Label labelWaveformsFolderInfo; - private System.Windows.Forms.CheckBox checkBoxRememberSelectedLine; - private System.Windows.Forms.ComboBox comboBoxAutoBackup; - private System.Windows.Forms.Label labelAutoBackup; - private System.Windows.Forms.TabPage tabPageToolBar; - private System.Windows.Forms.CheckBox checkBoxShowFrameRate; - private System.Windows.Forms.ComboBox comboBoxSpellChecker; - private System.Windows.Forms.Label labelSpellChecker; - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.CheckBox checkBoxAllowEditOfOriginalSubtitle; - private System.Windows.Forms.Label labelMergeShortLines; - private System.Windows.Forms.ComboBox comboBoxMergeShortLineLength; - private System.Windows.Forms.CheckBox checkBoxAutoWrapWhileTyping; - private System.Windows.Forms.CheckBox checkBoxFixCommonOcrErrorsUsingHardcodedRules; - private System.Windows.Forms.Label labelVideoPlayerPreviewFontSize; - private System.Windows.Forms.ComboBox comboBoxlVideoPlayerPreviewFontSize; - private System.Windows.Forms.TabPage tabPageShortcuts; - private System.Windows.Forms.GroupBox groupBoxShortcuts; - private System.Windows.Forms.Button buttonUpdateShortcut; - private System.Windows.Forms.TreeView treeViewShortcuts; - private System.Windows.Forms.Label labelShortcut; - private System.Windows.Forms.Label labelShortcutKey; - private System.Windows.Forms.ComboBox comboBoxShortcutKey; - private System.Windows.Forms.CheckBox checkBoxShortcutsShift; - private System.Windows.Forms.CheckBox checkBoxShortcutsAlt; - private System.Windows.Forms.CheckBox checkBoxShortcutsControl; - private System.Windows.Forms.CheckBox checkBoxPromptDeleteLines; - private System.Windows.Forms.GroupBox groupBoxSpectrogram; - private System.Windows.Forms.CheckBox checkBoxGenerateSpectrogram; - private System.Windows.Forms.Label labelSpectrogramAppearance; - private System.Windows.Forms.ComboBox comboBoxSpectrogramAppearance; - private System.Windows.Forms.CheckBox checkBoxReverseMouseWheelScrollDirection; - private System.Windows.Forms.Label labelMaxDuration; - private System.Windows.Forms.Label labelMinDuration; - private System.Windows.Forms.NumericUpDown numericUpDownDurationMax; - private System.Windows.Forms.NumericUpDown numericUpDownDurationMin; - private System.Windows.Forms.ComboBox comboBoxTimeCodeMode; - private System.Windows.Forms.Label labelTimeCodeMode; - private System.Windows.Forms.TabPage tabPageSyntaxColoring; - private System.Windows.Forms.GroupBox groupBoxListViewSyntaxColoring; - private System.Windows.Forms.CheckBox checkBoxSyntaxOverlap; - private System.Windows.Forms.CheckBox checkBoxSyntaxColorTextTooLong; - private System.Windows.Forms.CheckBox checkBoxSyntaxColorDurationTooLarge; - private System.Windows.Forms.CheckBox checkBoxSyntaxColorDurationTooSmall; - private System.Windows.Forms.CheckBox checkBoxSyntaxColorTextMoreThanTwoLines; - private System.Windows.Forms.Button buttonListViewSyntaxColorError; - private System.Windows.Forms.Panel panelListViewSyntaxColorError; - private System.Windows.Forms.Label labelMaxCharsPerSecond; - private System.Windows.Forms.NumericUpDown numericUpDownMaxCharsSec; - private System.Windows.Forms.NumericUpDown numericUpDownSubtitleLineMaximumLength; - private System.Windows.Forms.CheckBox checkBoxVideoPlayerShowFullscreenButton; - private System.Windows.Forms.CheckBox checkBoxVideoPlayerShowMuteButton; - private System.Windows.Forms.Label labelCustomSearch1; - private System.Windows.Forms.Label labelCustomSearch2; - private System.Windows.Forms.TextBox textBoxCustomSearchUrl2; - private System.Windows.Forms.ComboBox comboBoxCustomSearch2; - private System.Windows.Forms.Label labelCustomSearch5; - private System.Windows.Forms.TextBox textBoxCustomSearchUrl5; - private System.Windows.Forms.ComboBox comboBoxCustomSearch5; - private System.Windows.Forms.Label labelCustomSearch4; - private System.Windows.Forms.TextBox textBoxCustomSearchUrl4; - private System.Windows.Forms.ComboBox comboBoxCustomSearch4; - private System.Windows.Forms.Label labelCustomSearch3; - private System.Windows.Forms.TextBox textBoxCustomSearchUrl3; - private System.Windows.Forms.ComboBox comboBoxCustomSearch3; - private System.Windows.Forms.CheckBox checkBoxAllowOverlap; - private System.Windows.Forms.Label labelWaveformBorderHitMs2; - private System.Windows.Forms.NumericUpDown numericUpDownWaveformBorderHitMs; - private System.Windows.Forms.Label labelWaveformBorderHitMs1; - private System.Windows.Forms.Label labelSsaOutline; - private System.Windows.Forms.NumericUpDown numericUpDownSsaShadow; - private System.Windows.Forms.NumericUpDown numericUpDownSsaOutline; - private System.Windows.Forms.Label labelSsaShadow; - private System.Windows.Forms.GroupBox groupBoxPreview; - private System.Windows.Forms.PictureBox pictureBoxPreview; - private System.Windows.Forms.CheckBox checkBoxSsaOpaqueBox; - private System.Windows.Forms.CheckBox checkBoxSpellCheckOneLetterWords; - private System.Windows.Forms.CheckBox checkBoxTreatINQuoteAsING; - private System.Windows.Forms.GroupBox groupBoxFfmpeg; - private System.Windows.Forms.Button buttonBrowseToFFmpeg; - private System.Windows.Forms.TextBox textBoxFFmpegPath; - private System.Windows.Forms.Label labelFFmpegPath; - private System.Windows.Forms.CheckBox checkBoxUseFFmpeg; - private System.Windows.Forms.OpenFileDialog openFileDialogFFmpeg; - private System.Windows.Forms.CheckBox checkBoxWaveformHoverFocus; - private System.Windows.Forms.CheckBox checkBoxListViewMouseEnterFocus; - private System.Windows.Forms.NumericUpDown numericUpDownMinGapMs; - private System.Windows.Forms.Label labelMinGapMs; - private System.Windows.Forms.Label labelTBFixCommonErrors; - private System.Windows.Forms.PictureBox pictureBoxTBFixCommonErrors; - private System.Windows.Forms.CheckBox checkBoxTBFixCommonErrors; - private System.Windows.Forms.CheckBox checkBoxFixShortDisplayTimesAllowMoveStartTime; - private System.Windows.Forms.Button buttonVlcPathBrowse; - private System.Windows.Forms.TextBox textBoxVlcPath; - private System.Windows.Forms.Label labelVlcPath; - private System.Windows.Forms.GroupBox groupBoxToolsAutoBr; - private System.Windows.Forms.CheckBox checkBoxUseDoNotBreakAfterList; - private System.Windows.Forms.Button buttonEditDoNotBreakAfterList; - private System.Windows.Forms.CheckBox checkBoxCheckForUpdates; - private System.Windows.Forms.Label labelPlatform; - private System.Windows.Forms.CheckBox checkBoxVideoPlayerPreviewFontBold; - private System.Windows.Forms.Label labelWaveformTextSize; - private System.Windows.Forms.CheckBox checkBoxWaveformTextBold; - private System.Windows.Forms.ComboBox comboBoxWaveformTextSize; - private System.Windows.Forms.LinkLabel linkLabelOpenDictionaryFolder; - private System.Windows.Forms.GroupBox groupBoxNetworkSession; - private System.Windows.Forms.Button buttonNetworkSessionNewMessageSound; - private System.Windows.Forms.TextBox textBoxNetworkSessionNewMessageSound; - private System.Windows.Forms.Label labelNetworkSessionNewMessageSound; - private System.Windows.Forms.GroupBox groupBoxMargins; - private System.Windows.Forms.NumericUpDown numericUpDownSsaMarginVertical; - private System.Windows.Forms.NumericUpDown numericUpDownSsaMarginRight; - private System.Windows.Forms.NumericUpDown numericUpDownSsaMarginLeft; - private System.Windows.Forms.Label labelMarginVertical; - private System.Windows.Forms.Label labelMarginRight; - private System.Windows.Forms.Label labelMarginLeft; - private System.Windows.Forms.GroupBox groupBoxSsaBorder; - private System.Windows.Forms.GroupBox groupSsaBoxFont; - private System.Windows.Forms.NumericUpDown numericUpDownFontSize; - private System.Windows.Forms.ComboBox comboBoxFontName; - private System.Windows.Forms.Label labelSsaFontSize; - private System.Windows.Forms.Label labelFontName; - private System.Windows.Forms.Panel panelPrimaryColor; - private System.Windows.Forms.Button buttonSsaColor; - private System.Windows.Forms.CheckBox checkBoxSsaFontBold; - private System.Windows.Forms.CheckBox checkBoxFceSkipStep1; - private System.Windows.Forms.Button buttonMpvSettings; - private System.Windows.Forms.Label labelMpvSettings; - private System.Windows.Forms.LinkLabel linkLabelBingSubscribe; - private System.Windows.Forms.Label labelUserBingApiId; - private System.Windows.Forms.GroupBox groupBoxBing; - private System.Windows.Forms.Label labelBingApiKey; - private System.Windows.Forms.TextBox textBoxBingClientSecret; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.ComboBox comboBoxAutoBackupDeleteAfter; - private System.Windows.Forms.Label labelAutoBackupDeleteAfter; - private System.Windows.Forms.Label labelTBRemoveTextForHi; - private System.Windows.Forms.PictureBox pictureBoxTBRemoveTextForHi; - private System.Windows.Forms.CheckBox checkBoxTBRemoveTextForHi; - private System.Windows.Forms.NumericUpDown numericUpDownMaxNumberOfLines; - private System.Windows.Forms.Label labelMaxLines; - private System.Windows.Forms.Label labelTBNetflixQualityCheck; - private System.Windows.Forms.PictureBox pictureBoxNetflixQualityCheck; - private System.Windows.Forms.CheckBox checkBoxNetflixQualityCheck; - private System.Windows.Forms.CheckBox checkBoxWaveformSetVideoPosMoveStartEnd; - private System.Windows.Forms.CheckBox checkBoxWaveformShowWpm; - private System.Windows.Forms.CheckBox checkBoxWaveformShowCps; - private System.Windows.Forms.NumericUpDown numericUpDownMaxWordsMin; - private System.Windows.Forms.Label labelMaxWordsPerMin; - private System.Windows.Forms.CheckBox checkBoxMpvHandlesPreviewText; - private System.Windows.Forms.CheckBox checkBoxVideoAutoOpen; - private System.Windows.Forms.Button buttonClearShortcut; - private System.Windows.Forms.CheckBox checkBoxAllowVolumeBoost; - private System.Windows.Forms.TabPage tabPageFont; - private System.Windows.Forms.GroupBox groupBoxFont; - private System.Windows.Forms.CheckBox checkBoxSubtitleCenter; - private System.Windows.Forms.Panel panelSubtitleFontColor; - private System.Windows.Forms.Panel panelSubtitleBackgroundColor; - private System.Windows.Forms.Label labelSubtitleFontBackgroundColor; - private System.Windows.Forms.Label labelSubtitleFontColor; - private System.Windows.Forms.Label labelSubtitleFontSize; - private System.Windows.Forms.ComboBox comboBoxSubtitleFont; - private System.Windows.Forms.CheckBox checkBoxSubtitleFontBold; - private System.Windows.Forms.ComboBox comboBoxSubtitleFontSize; - private System.Windows.Forms.Label labelSubtitleFont; - private System.Windows.Forms.ComboBox comboBoxSaveAsFileNameFrom; - private System.Windows.Forms.Label labelSaveAsFileNameFrom; - private System.Windows.Forms.GroupBox groupBoxGeneralRules; - private System.Windows.Forms.GroupBox groupBoxFontTextBox; - private System.Windows.Forms.GroupBox groupBoxFontListViews; - private System.Windows.Forms.Label labelSubtitleListViewFontSize; - private System.Windows.Forms.ComboBox comboBoxSubtitleListViewFontSize; - private System.Windows.Forms.CheckBox checkBoxSubtitleListViewFontBold; - private System.Windows.Forms.GroupBox groupBoxFontGeneral; - private System.Windows.Forms.Label labelFontNote; - private System.Windows.Forms.Button buttonDownloadFfmpeg; - private System.Windows.Forms.Button buttonShortcutsClear; - private System.Windows.Forms.Label labelShortcutsSearch; - private System.Windows.Forms.TextBox textBoxShortcutSearch; - private System.Windows.Forms.GroupBox groupBoxGoogleTranslate; - private System.Windows.Forms.Label labelGoogleTranslateApiKey; - private System.Windows.Forms.TextBox textBoxGoogleTransleApiKey; - private System.Windows.Forms.LinkLabel linkLabelGoogleTranslateSignUp; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.CheckBox checkBoxAutoSave; - private System.Windows.Forms.CheckBox checkBoxUseAlwaysToFile; - private System.Windows.Forms.Label labelOptimalCharsPerSecond; - private System.Windows.Forms.NumericUpDown numericUpDownOptimalCharsSec; - private System.Windows.Forms.Button buttonEditProfile; - private System.Windows.Forms.ComboBox comboBoxRulesProfileName; - private System.Windows.Forms.Label labelRulesProfileName; - private System.Windows.Forms.CheckBox checkBoxCpsIncludeWhiteSpace; - private System.Windows.Forms.Label labelBingTokenEndpoint; - private System.Windows.Forms.CheckBox checkBoxToolsBreakEarlyComma; - private System.Windows.Forms.CheckBox checkBoxToolsBreakEarlyDash; - private System.Windows.Forms.CheckBox checkBoxToolsBreakEarlyLineEnding; - private System.Windows.Forms.CheckBox checkBoxToolsBreakByPixelWidth; - private System.Windows.Forms.NumericUpDown numericUpDownToolsBreakPreferBottomHeavy; - private System.Windows.Forms.CheckBox checkBoxToolsBreakPreferBottomHeavy; - private System.Windows.Forms.Label labelToolsBreakBottomHeavyPercent; - private System.Windows.Forms.CheckBox checkBoxSyntaxColorGapTooSmall; - private System.Windows.Forms.Button buttonReset; - private System.Windows.Forms.Label labelDialogStyle; - private System.Windows.Forms.ComboBox comboBoxDialogStyle; - private System.Windows.Forms.ContextMenuStrip contextMenuStripShortcuts; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemShortcutsCollapse; - private System.Windows.Forms.CheckBox checkBoxWaveformSnapToSceneChanges; - private System.Windows.Forms.CheckBox checkBoxWaveformSingleClickSelect; - private System.Windows.Forms.Label labelSplitBehavior; - private System.Windows.Forms.ComboBox comboBoxSplitBehavior; - private System.Windows.Forms.Button buttonLineWidthSettings; - private System.Windows.Forms.CheckBox checkBoxSyntaxColorTextTooWide; - private System.Windows.Forms.Label labelContinuationStyle; - private System.Windows.Forms.Button buttonFixContinuationStyleSettings; - private System.Windows.Forms.ComboBox comboBoxContinuationStyle; - private System.Windows.Forms.ToolTip toolTipContinuationPreview; - private System.Windows.Forms.Panel panelWaveformCursorColor; - private System.Windows.Forms.Button buttonWaveformCursorColor; - private System.Windows.Forms.Button buttonGapChoose; - private System.Windows.Forms.CheckBox checkBoxSpellCheckAutoChangeNamesViaSuggestions; - private System.Windows.Forms.ComboBox comboBoxBoxBingTokenEndpoint; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripMenuItem importShortcutsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem exportShortcutsToolStripMenuItem; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; - private System.Windows.Forms.Panel panelTextBoxAssColor; - private System.Windows.Forms.Button buttonTextBoxAssColor; - private System.Windows.Forms.Panel panelTextBoxHtmlColor; - private System.Windows.Forms.Button buttonTextBoxHtmlColor; - private System.Windows.Forms.CheckBox checkBoxSubtitleTextBoxSyntaxColor; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class Settings + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.tabControlSettings = new System.Windows.Forms.TabControl(); + this.tabPageGeneral = new System.Windows.Forms.TabPage(); + this.groupBoxMiscellaneous = new System.Windows.Forms.GroupBox(); + this.labelSplitBehavior = new System.Windows.Forms.Label(); + this.comboBoxSplitBehavior = new System.Windows.Forms.ComboBox(); + this.checkBoxAutoSave = new System.Windows.Forms.CheckBox(); + this.comboBoxSaveAsFileNameFrom = new System.Windows.Forms.ComboBox(); + this.labelSaveAsFileNameFrom = new System.Windows.Forms.Label(); + this.groupBoxGeneralRules = new System.Windows.Forms.GroupBox(); + this.buttonGapChoose = new System.Windows.Forms.Button(); + this.comboBoxContinuationStyle = new System.Windows.Forms.ComboBox(); + this.labelContinuationStyle = new System.Windows.Forms.Label(); + this.labelDialogStyle = new System.Windows.Forms.Label(); + this.comboBoxDialogStyle = new System.Windows.Forms.ComboBox(); + this.checkBoxCpsIncludeWhiteSpace = new System.Windows.Forms.CheckBox(); + this.buttonEditProfile = new System.Windows.Forms.Button(); + this.comboBoxRulesProfileName = new System.Windows.Forms.ComboBox(); + this.labelRulesProfileName = new System.Windows.Forms.Label(); + this.labelOptimalCharsPerSecond = new System.Windows.Forms.Label(); + this.numericUpDownOptimalCharsSec = new System.Windows.Forms.NumericUpDown(); + this.labelSubMaxLen = new System.Windows.Forms.Label(); + this.numericUpDownMaxWordsMin = new System.Windows.Forms.NumericUpDown(); + this.labelMergeShortLines = new System.Windows.Forms.Label(); + this.labelMaxWordsPerMin = new System.Windows.Forms.Label(); + this.labelMinDuration = new System.Windows.Forms.Label(); + this.numericUpDownMaxNumberOfLines = new System.Windows.Forms.NumericUpDown(); + this.labelMaxDuration = new System.Windows.Forms.Label(); + this.labelMaxLines = new System.Windows.Forms.Label(); + this.numericUpDownDurationMin = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownDurationMax = new System.Windows.Forms.NumericUpDown(); + this.comboBoxMergeShortLineLength = new System.Windows.Forms.ComboBox(); + this.labelMaxCharsPerSecond = new System.Windows.Forms.Label(); + this.numericUpDownMinGapMs = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownMaxCharsSec = new System.Windows.Forms.NumericUpDown(); + this.labelMinGapMs = new System.Windows.Forms.Label(); + this.numericUpDownSubtitleLineMaximumLength = new System.Windows.Forms.NumericUpDown(); + this.comboBoxAutoBackupDeleteAfter = new System.Windows.Forms.ComboBox(); + this.labelAutoBackupDeleteAfter = new System.Windows.Forms.Label(); + this.checkBoxCheckForUpdates = new System.Windows.Forms.CheckBox(); + this.labelSpellChecker = new System.Windows.Forms.Label(); + this.comboBoxTimeCodeMode = new System.Windows.Forms.ComboBox(); + this.labelTimeCodeMode = new System.Windows.Forms.Label(); + this.comboBoxEncoding = new System.Windows.Forms.ComboBox(); + this.checkBoxAutoDetectAnsiEncoding = new System.Windows.Forms.CheckBox(); + this.textBoxShowLineBreaksAs = new System.Windows.Forms.TextBox(); + this.checkBoxAutoWrapWhileTyping = new System.Windows.Forms.CheckBox(); + this.checkBoxPromptDeleteLines = new System.Windows.Forms.CheckBox(); + this.checkBoxAllowEditOfOriginalSubtitle = new System.Windows.Forms.CheckBox(); + this.comboBoxSpellChecker = new System.Windows.Forms.ComboBox(); + this.comboBoxAutoBackup = new System.Windows.Forms.ComboBox(); + this.labelAutoBackup = new System.Windows.Forms.Label(); + this.checkBoxRememberSelectedLine = new System.Windows.Forms.CheckBox(); + this.checkBoxRemoveBlankLinesWhenOpening = new System.Windows.Forms.CheckBox(); + this.labelAutoDetectAnsiEncoding = new System.Windows.Forms.Label(); + this.comboBoxListViewDoubleClickEvent = new System.Windows.Forms.ComboBox(); + this.labelListViewDoubleClickEvent = new System.Windows.Forms.Label(); + this.labelShowLineBreaksAs = new System.Windows.Forms.Label(); + this.checkBoxRememberWindowPosition = new System.Windows.Forms.CheckBox(); + this.checkBoxStartInSourceView = new System.Windows.Forms.CheckBox(); + this.checkBoxReopenLastOpened = new System.Windows.Forms.CheckBox(); + this.checkBoxRememberRecentFiles = new System.Windows.Forms.CheckBox(); + this.labelDefaultFileEncoding = new System.Windows.Forms.Label(); + this.comboBoxFrameRate = new System.Windows.Forms.ComboBox(); + this.labelDefaultFrameRate = new System.Windows.Forms.Label(); + this.tabPageShortcuts = new System.Windows.Forms.TabPage(); + this.groupBoxShortcuts = new System.Windows.Forms.GroupBox(); + this.buttonShortcutsClear = new System.Windows.Forms.Button(); + this.labelShortcutsSearch = new System.Windows.Forms.Label(); + this.textBoxShortcutSearch = new System.Windows.Forms.TextBox(); + this.buttonClearShortcut = new System.Windows.Forms.Button(); + this.comboBoxShortcutKey = new System.Windows.Forms.ComboBox(); + this.labelShortcutKey = new System.Windows.Forms.Label(); + this.checkBoxShortcutsShift = new System.Windows.Forms.CheckBox(); + this.checkBoxShortcutsAlt = new System.Windows.Forms.CheckBox(); + this.checkBoxShortcutsControl = new System.Windows.Forms.CheckBox(); + this.buttonUpdateShortcut = new System.Windows.Forms.Button(); + this.treeViewShortcuts = new System.Windows.Forms.TreeView(); + this.contextMenuStripShortcuts = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemShortcutsCollapse = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.importShortcutsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.exportShortcutsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.labelShortcut = new System.Windows.Forms.Label(); + this.tabPageSyntaxColoring = new System.Windows.Forms.TabPage(); + this.groupBoxListViewSyntaxColoring = new System.Windows.Forms.GroupBox(); + this.buttonLineWidthSettings = new System.Windows.Forms.Button(); + this.checkBoxSyntaxColorTextTooWide = new System.Windows.Forms.CheckBox(); + this.checkBoxSyntaxColorGapTooSmall = new System.Windows.Forms.CheckBox(); + this.checkBoxSyntaxColorTextMoreThanTwoLines = new System.Windows.Forms.CheckBox(); + this.checkBoxSyntaxOverlap = new System.Windows.Forms.CheckBox(); + this.checkBoxSyntaxColorDurationTooSmall = new System.Windows.Forms.CheckBox(); + this.buttonListViewSyntaxColorError = new System.Windows.Forms.Button(); + this.checkBoxSyntaxColorTextTooLong = new System.Windows.Forms.CheckBox(); + this.checkBoxSyntaxColorDurationTooLarge = new System.Windows.Forms.CheckBox(); + this.panelListViewSyntaxColorError = new System.Windows.Forms.Panel(); + this.tabPageVideoPlayer = new System.Windows.Forms.TabPage(); + this.groupBoxMainWindowVideoControls = new System.Windows.Forms.GroupBox(); + this.labelCustomSearch5 = new System.Windows.Forms.Label(); + this.textBoxCustomSearchUrl5 = new System.Windows.Forms.TextBox(); + this.comboBoxCustomSearch5 = new System.Windows.Forms.ComboBox(); + this.labelCustomSearch4 = new System.Windows.Forms.Label(); + this.textBoxCustomSearchUrl4 = new System.Windows.Forms.TextBox(); + this.comboBoxCustomSearch4 = new System.Windows.Forms.ComboBox(); + this.labelCustomSearch3 = new System.Windows.Forms.Label(); + this.textBoxCustomSearchUrl3 = new System.Windows.Forms.TextBox(); + this.comboBoxCustomSearch3 = new System.Windows.Forms.ComboBox(); + this.labelCustomSearch2 = new System.Windows.Forms.Label(); + this.textBoxCustomSearchUrl2 = new System.Windows.Forms.TextBox(); + this.comboBoxCustomSearch2 = new System.Windows.Forms.ComboBox(); + this.labelCustomSearch1 = new System.Windows.Forms.Label(); + this.textBoxCustomSearchUrl1 = new System.Windows.Forms.TextBox(); + this.labelCustomSearch = new System.Windows.Forms.Label(); + this.comboBoxCustomSearch1 = new System.Windows.Forms.ComboBox(); + this.groupBoxVideoPlayerDefault = new System.Windows.Forms.GroupBox(); + this.checkBoxAllowVolumeBoost = new System.Windows.Forms.CheckBox(); + this.checkBoxVideoAutoOpen = new System.Windows.Forms.CheckBox(); + this.checkBoxVideoPlayerPreviewFontBold = new System.Windows.Forms.CheckBox(); + this.checkBoxVideoPlayerShowFullscreenButton = new System.Windows.Forms.CheckBox(); + this.checkBoxVideoPlayerShowMuteButton = new System.Windows.Forms.CheckBox(); + this.labelVideoPlayerPreviewFontSize = new System.Windows.Forms.Label(); + this.comboBoxlVideoPlayerPreviewFontSize = new System.Windows.Forms.ComboBox(); + this.checkBoxVideoPlayerShowStopButton = new System.Windows.Forms.CheckBox(); + this.groupBoxVideoEngine = new System.Windows.Forms.GroupBox(); + this.checkBoxMpvHandlesPreviewText = new System.Windows.Forms.CheckBox(); + this.labelMpvSettings = new System.Windows.Forms.Label(); + this.buttonMpvSettings = new System.Windows.Forms.Button(); + this.labelPlatform = new System.Windows.Forms.Label(); + this.buttonVlcPathBrowse = new System.Windows.Forms.Button(); + this.textBoxVlcPath = new System.Windows.Forms.TextBox(); + this.labelVlcPath = new System.Windows.Forms.Label(); + this.labelVideoPlayerVLC = new System.Windows.Forms.Label(); + this.radioButtonVideoPlayerVLC = new System.Windows.Forms.RadioButton(); + this.labelVideoPlayerMPlayer = new System.Windows.Forms.Label(); + this.labelDirectShowDescription = new System.Windows.Forms.Label(); + this.labelMpcHcDescription = new System.Windows.Forms.Label(); + this.radioButtonVideoPlayerMPV = new System.Windows.Forms.RadioButton(); + this.radioButtonVideoPlayerDirectShow = new System.Windows.Forms.RadioButton(); + this.radioButtonVideoPlayerMpcHc = new System.Windows.Forms.RadioButton(); + this.tabPageWaveform = new System.Windows.Forms.TabPage(); + this.groupBoxFfmpeg = new System.Windows.Forms.GroupBox(); + this.buttonDownloadFfmpeg = new System.Windows.Forms.Button(); + this.buttonBrowseToFFmpeg = new System.Windows.Forms.Button(); + this.textBoxFFmpegPath = new System.Windows.Forms.TextBox(); + this.labelFFmpegPath = new System.Windows.Forms.Label(); + this.checkBoxUseFFmpeg = new System.Windows.Forms.CheckBox(); + this.groupBoxSpectrogram = new System.Windows.Forms.GroupBox(); + this.labelSpectrogramAppearance = new System.Windows.Forms.Label(); + this.comboBoxSpectrogramAppearance = new System.Windows.Forms.ComboBox(); + this.checkBoxGenerateSpectrogram = new System.Windows.Forms.CheckBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.buttonWaveformsFolderEmpty = new System.Windows.Forms.Button(); + this.labelWaveformsFolderInfo = new System.Windows.Forms.Label(); + this.groupBoxWaveformAppearence = new System.Windows.Forms.GroupBox(); + this.panelWaveformCursorColor = new System.Windows.Forms.Panel(); + this.buttonWaveformCursorColor = new System.Windows.Forms.Button(); + this.checkBoxWaveformSnapToSceneChanges = new System.Windows.Forms.CheckBox(); + this.checkBoxWaveformSingleClickSelect = new System.Windows.Forms.CheckBox(); + this.checkBoxWaveformShowWpm = new System.Windows.Forms.CheckBox(); + this.checkBoxWaveformShowCps = new System.Windows.Forms.CheckBox(); + this.checkBoxWaveformSetVideoPosMoveStartEnd = new System.Windows.Forms.CheckBox(); + this.labelWaveformTextSize = new System.Windows.Forms.Label(); + this.checkBoxWaveformTextBold = new System.Windows.Forms.CheckBox(); + this.comboBoxWaveformTextSize = new System.Windows.Forms.ComboBox(); + this.checkBoxListViewMouseEnterFocus = new System.Windows.Forms.CheckBox(); + this.checkBoxWaveformHoverFocus = new System.Windows.Forms.CheckBox(); + this.labelWaveformBorderHitMs2 = new System.Windows.Forms.Label(); + this.numericUpDownWaveformBorderHitMs = new System.Windows.Forms.NumericUpDown(); + this.labelWaveformBorderHitMs1 = new System.Windows.Forms.Label(); + this.checkBoxAllowOverlap = new System.Windows.Forms.CheckBox(); + this.checkBoxReverseMouseWheelScrollDirection = new System.Windows.Forms.CheckBox(); + this.panelWaveformTextColor = new System.Windows.Forms.Panel(); + this.buttonWaveformTextColor = new System.Windows.Forms.Button(); + this.panelWaveformGridColor = new System.Windows.Forms.Panel(); + this.buttonWaveformGridColor = new System.Windows.Forms.Button(); + this.panelWaveformBackgroundColor = new System.Windows.Forms.Panel(); + this.buttonWaveformBackgroundColor = new System.Windows.Forms.Button(); + this.panelWaveformColor = new System.Windows.Forms.Panel(); + this.buttonWaveformColor = new System.Windows.Forms.Button(); + this.panelWaveformSelectedColor = new System.Windows.Forms.Panel(); + this.buttonWaveformSelectedColor = new System.Windows.Forms.Button(); + this.checkBoxWaveformShowGrid = new System.Windows.Forms.CheckBox(); + this.tabPageTools = new System.Windows.Forms.TabPage(); + this.groupBoxGoogleTranslate = new System.Windows.Forms.GroupBox(); + this.labelGoogleTranslateApiKey = new System.Windows.Forms.Label(); + this.textBoxGoogleTransleApiKey = new System.Windows.Forms.TextBox(); + this.linkLabelGoogleTranslateSignUp = new System.Windows.Forms.LinkLabel(); + this.label3 = new System.Windows.Forms.Label(); + this.groupBoxBing = new System.Windows.Forms.GroupBox(); + this.comboBoxBoxBingTokenEndpoint = new System.Windows.Forms.ComboBox(); + this.labelBingTokenEndpoint = new System.Windows.Forms.Label(); + this.labelBingApiKey = new System.Windows.Forms.Label(); + this.textBoxBingClientSecret = new System.Windows.Forms.TextBox(); + this.linkLabelBingSubscribe = new System.Windows.Forms.LinkLabel(); + this.label1 = new System.Windows.Forms.Label(); + this.groupBoxToolsAutoBr = new System.Windows.Forms.GroupBox(); + this.labelToolsBreakBottomHeavyPercent = new System.Windows.Forms.Label(); + this.numericUpDownToolsBreakPreferBottomHeavy = new System.Windows.Forms.NumericUpDown(); + this.checkBoxToolsBreakPreferBottomHeavy = new System.Windows.Forms.CheckBox(); + this.checkBoxToolsBreakByPixelWidth = new System.Windows.Forms.CheckBox(); + this.checkBoxToolsBreakEarlyLineEnding = new System.Windows.Forms.CheckBox(); + this.checkBoxToolsBreakEarlyComma = new System.Windows.Forms.CheckBox(); + this.checkBoxToolsBreakEarlyDash = new System.Windows.Forms.CheckBox(); + this.labelUserBingApiId = new System.Windows.Forms.Label(); + this.buttonEditDoNotBreakAfterList = new System.Windows.Forms.Button(); + this.checkBoxUseDoNotBreakAfterList = new System.Windows.Forms.CheckBox(); + this.groupBoxSpellCheck = new System.Windows.Forms.GroupBox(); + this.checkBoxSpellCheckAutoChangeNamesViaSuggestions = new System.Windows.Forms.CheckBox(); + this.checkBoxUseAlwaysToFile = new System.Windows.Forms.CheckBox(); + this.checkBoxTreatINQuoteAsING = new System.Windows.Forms.CheckBox(); + this.checkBoxSpellCheckOneLetterWords = new System.Windows.Forms.CheckBox(); + this.checkBoxSpellCheckAutoChangeNames = new System.Windows.Forms.CheckBox(); + this.groupBoxFixCommonErrors = new System.Windows.Forms.GroupBox(); + this.buttonFixContinuationStyleSettings = new System.Windows.Forms.Button(); + this.checkBoxFceSkipStep1 = new System.Windows.Forms.CheckBox(); + this.checkBoxFixShortDisplayTimesAllowMoveStartTime = new System.Windows.Forms.CheckBox(); + this.checkBoxFixCommonOcrErrorsUsingHardcodedRules = new System.Windows.Forms.CheckBox(); + this.comboBoxToolsMusicSymbol = new System.Windows.Forms.ComboBox(); + this.textBoxMusicSymbolsToReplace = new System.Windows.Forms.TextBox(); + this.labelToolsMusicSymbolsToReplace = new System.Windows.Forms.Label(); + this.labelToolsMusicSymbol = new System.Windows.Forms.Label(); + this.groupBoxToolsVisualSync = new System.Windows.Forms.GroupBox(); + this.labelToolsEndScene = new System.Windows.Forms.Label(); + this.comboBoxToolsEndSceneIndex = new System.Windows.Forms.ComboBox(); + this.labelToolsStartScene = new System.Windows.Forms.Label(); + this.comboBoxToolsStartSceneIndex = new System.Windows.Forms.ComboBox(); + this.comboBoxToolsVerifySeconds = new System.Windows.Forms.ComboBox(); + this.labelVerifyButton = new System.Windows.Forms.Label(); + this.tabPageWordLists = new System.Windows.Forms.TabPage(); + this.groupBoxWordLists = new System.Windows.Forms.GroupBox(); + this.linkLabelOpenDictionaryFolder = new System.Windows.Forms.LinkLabel(); + this.groupBoxOcrFixList = new System.Windows.Forms.GroupBox(); + this.textBoxOcrFixValue = new System.Windows.Forms.TextBox(); + this.buttonRemoveOcrFix = new System.Windows.Forms.Button(); + this.listBoxOcrFixList = new System.Windows.Forms.ListBox(); + this.textBoxOcrFixKey = new System.Windows.Forms.TextBox(); + this.buttonAddOcrFix = new System.Windows.Forms.Button(); + this.groupBoxUserWordList = new System.Windows.Forms.GroupBox(); + this.buttonRemoveUserWord = new System.Windows.Forms.Button(); + this.listBoxUserWordLists = new System.Windows.Forms.ListBox(); + this.textBoxUserWord = new System.Windows.Forms.TextBox(); + this.buttonAddUserWord = new System.Windows.Forms.Button(); + this.groupBoxWordListLocation = new System.Windows.Forms.GroupBox(); + this.checkBoxNamesOnline = new System.Windows.Forms.CheckBox(); + this.textBoxNamesOnline = new System.Windows.Forms.TextBox(); + this.groupBoxNamesIgonoreLists = new System.Windows.Forms.GroupBox(); + this.buttonRemoveNameEtc = new System.Windows.Forms.Button(); + this.listBoxNames = new System.Windows.Forms.ListBox(); + this.textBoxNameEtc = new System.Windows.Forms.TextBox(); + this.buttonAddNames = new System.Windows.Forms.Button(); + this.labelWordListLanguage = new System.Windows.Forms.Label(); + this.comboBoxWordListLanguage = new System.Windows.Forms.ComboBox(); + this.tabPageToolBar = new System.Windows.Forms.TabPage(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.checkBoxShowFrameRate = new System.Windows.Forms.CheckBox(); + this.groupBoxShowToolBarButtons = new System.Windows.Forms.GroupBox(); + this.labelTBNetflixQualityCheck = new System.Windows.Forms.Label(); + this.pictureBoxNetflixQualityCheck = new System.Windows.Forms.PictureBox(); + this.checkBoxNetflixQualityCheck = new System.Windows.Forms.CheckBox(); + this.labelTBRemoveTextForHi = new System.Windows.Forms.Label(); + this.pictureBoxTBRemoveTextForHi = new System.Windows.Forms.PictureBox(); + this.checkBoxTBRemoveTextForHi = new System.Windows.Forms.CheckBox(); + this.labelTBFixCommonErrors = new System.Windows.Forms.Label(); + this.pictureBoxTBFixCommonErrors = new System.Windows.Forms.PictureBox(); + this.checkBoxTBFixCommonErrors = new System.Windows.Forms.CheckBox(); + this.labelTBHelp = new System.Windows.Forms.Label(); + this.pictureBoxHelp = new System.Windows.Forms.PictureBox(); + this.checkBoxHelp = new System.Windows.Forms.CheckBox(); + this.labelTBSettings = new System.Windows.Forms.Label(); + this.pictureBoxSettings = new System.Windows.Forms.PictureBox(); + this.checkBoxSettings = new System.Windows.Forms.CheckBox(); + this.labelTBSpellCheck = new System.Windows.Forms.Label(); + this.pictureBoxSpellCheck = new System.Windows.Forms.PictureBox(); + this.checkBoxSpellCheck = new System.Windows.Forms.CheckBox(); + this.labelTBVisualSync = new System.Windows.Forms.Label(); + this.pictureBoxVisualSync = new System.Windows.Forms.PictureBox(); + this.checkBoxVisualSync = new System.Windows.Forms.CheckBox(); + this.labelTBReplace = new System.Windows.Forms.Label(); + this.pictureBoxReplace = new System.Windows.Forms.PictureBox(); + this.checkBoxReplace = new System.Windows.Forms.CheckBox(); + this.labelTBFind = new System.Windows.Forms.Label(); + this.pictureBoxFind = new System.Windows.Forms.PictureBox(); + this.checkBoxToolbarFind = new System.Windows.Forms.CheckBox(); + this.labelTBSaveAs = new System.Windows.Forms.Label(); + this.pictureBoxSaveAs = new System.Windows.Forms.PictureBox(); + this.checkBoxToolbarSaveAs = new System.Windows.Forms.CheckBox(); + this.labelTBSave = new System.Windows.Forms.Label(); + this.pictureBoxSave = new System.Windows.Forms.PictureBox(); + this.checkBoxToolbarSave = new System.Windows.Forms.CheckBox(); + this.labelTBOpen = new System.Windows.Forms.Label(); + this.pictureBoxOpen = new System.Windows.Forms.PictureBox(); + this.checkBoxToolbarOpen = new System.Windows.Forms.CheckBox(); + this.labelTBNew = new System.Windows.Forms.Label(); + this.pictureBoxNew = new System.Windows.Forms.PictureBox(); + this.checkBoxToolbarNew = new System.Windows.Forms.CheckBox(); + this.tabPageFont = new System.Windows.Forms.TabPage(); + this.groupBoxFont = new System.Windows.Forms.GroupBox(); + this.labelFontNote = new System.Windows.Forms.Label(); + this.groupBoxFontTextBox = new System.Windows.Forms.GroupBox(); + this.panelTextBoxAssColor = new System.Windows.Forms.Panel(); + this.buttonTextBoxAssColor = new System.Windows.Forms.Button(); + this.panelTextBoxHtmlColor = new System.Windows.Forms.Panel(); + this.buttonTextBoxHtmlColor = new System.Windows.Forms.Button(); + this.checkBoxSubtitleTextBoxSyntaxColor = new System.Windows.Forms.CheckBox(); + this.labelSubtitleFontSize = new System.Windows.Forms.Label(); + this.comboBoxSubtitleFontSize = new System.Windows.Forms.ComboBox(); + this.checkBoxSubtitleFontBold = new System.Windows.Forms.CheckBox(); + this.checkBoxSubtitleCenter = new System.Windows.Forms.CheckBox(); + this.groupBoxFontListViews = new System.Windows.Forms.GroupBox(); + this.labelSubtitleListViewFontSize = new System.Windows.Forms.Label(); + this.comboBoxSubtitleListViewFontSize = new System.Windows.Forms.ComboBox(); + this.checkBoxSubtitleListViewFontBold = new System.Windows.Forms.CheckBox(); + this.groupBoxFontGeneral = new System.Windows.Forms.GroupBox(); + this.comboBoxSubtitleFont = new System.Windows.Forms.ComboBox(); + this.labelSubtitleFont = new System.Windows.Forms.Label(); + this.panelSubtitleFontColor = new System.Windows.Forms.Panel(); + this.labelSubtitleFontColor = new System.Windows.Forms.Label(); + this.panelSubtitleBackgroundColor = new System.Windows.Forms.Panel(); + this.labelSubtitleFontBackgroundColor = new System.Windows.Forms.Label(); + this.tabPageSsaStyle = new System.Windows.Forms.TabPage(); + this.groupBoxSsaStyle = new System.Windows.Forms.GroupBox(); + this.groupBoxSsaBorder = new System.Windows.Forms.GroupBox(); + this.numericUpDownSsaOutline = new System.Windows.Forms.NumericUpDown(); + this.labelSsaShadow = new System.Windows.Forms.Label(); + this.numericUpDownSsaShadow = new System.Windows.Forms.NumericUpDown(); + this.checkBoxSsaOpaqueBox = new System.Windows.Forms.CheckBox(); + this.labelSsaOutline = new System.Windows.Forms.Label(); + this.groupSsaBoxFont = new System.Windows.Forms.GroupBox(); + this.checkBoxSsaFontBold = new System.Windows.Forms.CheckBox(); + this.buttonSsaColor = new System.Windows.Forms.Button(); + this.panelPrimaryColor = new System.Windows.Forms.Panel(); + this.numericUpDownFontSize = new System.Windows.Forms.NumericUpDown(); + this.comboBoxFontName = new System.Windows.Forms.ComboBox(); + this.labelSsaFontSize = new System.Windows.Forms.Label(); + this.labelFontName = new System.Windows.Forms.Label(); + this.groupBoxMargins = new System.Windows.Forms.GroupBox(); + this.numericUpDownSsaMarginVertical = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownSsaMarginRight = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownSsaMarginLeft = new System.Windows.Forms.NumericUpDown(); + this.labelMarginVertical = new System.Windows.Forms.Label(); + this.labelMarginRight = new System.Windows.Forms.Label(); + this.labelMarginLeft = new System.Windows.Forms.Label(); + this.groupBoxPreview = new System.Windows.Forms.GroupBox(); + this.pictureBoxPreview = new System.Windows.Forms.PictureBox(); + this.tabPageNetwork = new System.Windows.Forms.TabPage(); + this.groupBoxNetworkSession = new System.Windows.Forms.GroupBox(); + this.buttonNetworkSessionNewMessageSound = new System.Windows.Forms.Button(); + this.textBoxNetworkSessionNewMessageSound = new System.Windows.Forms.TextBox(); + this.labelNetworkSessionNewMessageSound = new System.Windows.Forms.Label(); + this.groupBoxProxySettings = new System.Windows.Forms.GroupBox(); + this.groupBoxProxyAuthentication = new System.Windows.Forms.GroupBox(); + this.textBoxProxyDomain = new System.Windows.Forms.TextBox(); + this.labelProxyDomain = new System.Windows.Forms.Label(); + this.textBoxProxyUserName = new System.Windows.Forms.TextBox(); + this.labelProxyPassword = new System.Windows.Forms.Label(); + this.labelProxyUserName = new System.Windows.Forms.Label(); + this.textBoxProxyPassword = new System.Windows.Forms.TextBox(); + this.textBoxProxyAddress = new System.Windows.Forms.TextBox(); + this.labelProxyAddress = new System.Windows.Forms.Label(); + this.colorDialogSSAStyle = new System.Windows.Forms.ColorDialog(); + this.labelStatus = new System.Windows.Forms.Label(); + this.openFileDialogFFmpeg = new System.Windows.Forms.OpenFileDialog(); + this.buttonReset = new System.Windows.Forms.Button(); + this.toolTipContinuationPreview = new System.Windows.Forms.ToolTip(this.components); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.tabControlSettings.SuspendLayout(); + this.tabPageGeneral.SuspendLayout(); + this.groupBoxMiscellaneous.SuspendLayout(); + this.groupBoxGeneralRules.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxWordsMin)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxNumberOfLines)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMin)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMax)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinGapMs)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharsSec)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSubtitleLineMaximumLength)).BeginInit(); + this.tabPageShortcuts.SuspendLayout(); + this.groupBoxShortcuts.SuspendLayout(); + this.contextMenuStripShortcuts.SuspendLayout(); + this.tabPageSyntaxColoring.SuspendLayout(); + this.groupBoxListViewSyntaxColoring.SuspendLayout(); + this.tabPageVideoPlayer.SuspendLayout(); + this.groupBoxMainWindowVideoControls.SuspendLayout(); + this.groupBoxVideoPlayerDefault.SuspendLayout(); + this.groupBoxVideoEngine.SuspendLayout(); + this.tabPageWaveform.SuspendLayout(); + this.groupBoxFfmpeg.SuspendLayout(); + this.groupBoxSpectrogram.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.groupBoxWaveformAppearence.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWaveformBorderHitMs)).BeginInit(); + this.tabPageTools.SuspendLayout(); + this.groupBoxGoogleTranslate.SuspendLayout(); + this.groupBoxBing.SuspendLayout(); + this.groupBoxToolsAutoBr.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownToolsBreakPreferBottomHeavy)).BeginInit(); + this.groupBoxSpellCheck.SuspendLayout(); + this.groupBoxFixCommonErrors.SuspendLayout(); + this.groupBoxToolsVisualSync.SuspendLayout(); + this.tabPageWordLists.SuspendLayout(); + this.groupBoxWordLists.SuspendLayout(); + this.groupBoxOcrFixList.SuspendLayout(); + this.groupBoxUserWordList.SuspendLayout(); + this.groupBoxWordListLocation.SuspendLayout(); + this.groupBoxNamesIgonoreLists.SuspendLayout(); + this.tabPageToolBar.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBoxShowToolBarButtons.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxNetflixQualityCheck)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBRemoveTextForHi)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBFixCommonErrors)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHelp)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSettings)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSpellCheck)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxVisualSync)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxReplace)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxFind)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSaveAs)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSave)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxOpen)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxNew)).BeginInit(); + this.tabPageFont.SuspendLayout(); + this.groupBoxFont.SuspendLayout(); + this.groupBoxFontTextBox.SuspendLayout(); + this.groupBoxFontListViews.SuspendLayout(); + this.groupBoxFontGeneral.SuspendLayout(); + this.tabPageSsaStyle.SuspendLayout(); + this.groupBoxSsaStyle.SuspendLayout(); + this.groupBoxSsaBorder.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaOutline)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaShadow)).BeginInit(); + this.groupSsaBoxFont.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSize)).BeginInit(); + this.groupBoxMargins.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaMarginVertical)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaMarginRight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaMarginLeft)).BeginInit(); + this.groupBoxPreview.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).BeginInit(); + this.tabPageNetwork.SuspendLayout(); + this.groupBoxNetworkSession.SuspendLayout(); + this.groupBoxProxySettings.SuspendLayout(); + this.groupBoxProxyAuthentication.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.Location = new System.Drawing.Point(506, 563); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 0; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(587, 563); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 1; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // tabControlSettings + // + this.tabControlSettings.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabControlSettings.Controls.Add(this.tabPageGeneral); + this.tabControlSettings.Controls.Add(this.tabPageShortcuts); + this.tabControlSettings.Controls.Add(this.tabPageSyntaxColoring); + this.tabControlSettings.Controls.Add(this.tabPageVideoPlayer); + this.tabControlSettings.Controls.Add(this.tabPageWaveform); + this.tabControlSettings.Controls.Add(this.tabPageTools); + this.tabControlSettings.Controls.Add(this.tabPageWordLists); + this.tabControlSettings.Controls.Add(this.tabPageToolBar); + this.tabControlSettings.Controls.Add(this.tabPageFont); + this.tabControlSettings.Controls.Add(this.tabPageSsaStyle); + this.tabControlSettings.Controls.Add(this.tabPageNetwork); + this.tabControlSettings.Location = new System.Drawing.Point(13, 13); + this.tabControlSettings.Name = "tabControlSettings"; + this.tabControlSettings.SelectedIndex = 0; + this.tabControlSettings.Size = new System.Drawing.Size(840, 546); + this.tabControlSettings.TabIndex = 2; + this.tabControlSettings.SelectedIndexChanged += new System.EventHandler(this.TabControlSettingsSelectedIndexChanged); + // + // tabPageGeneral + // + this.tabPageGeneral.Controls.Add(this.groupBoxMiscellaneous); + this.tabPageGeneral.Location = new System.Drawing.Point(4, 22); + this.tabPageGeneral.Name = "tabPageGeneral"; + this.tabPageGeneral.Padding = new System.Windows.Forms.Padding(3); + this.tabPageGeneral.Size = new System.Drawing.Size(832, 520); + this.tabPageGeneral.TabIndex = 0; + this.tabPageGeneral.Text = "General"; + this.tabPageGeneral.UseVisualStyleBackColor = true; + // + // groupBoxMiscellaneous + // + this.groupBoxMiscellaneous.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxMiscellaneous.Controls.Add(this.labelSplitBehavior); + this.groupBoxMiscellaneous.Controls.Add(this.comboBoxSplitBehavior); + this.groupBoxMiscellaneous.Controls.Add(this.checkBoxAutoSave); + this.groupBoxMiscellaneous.Controls.Add(this.comboBoxSaveAsFileNameFrom); + this.groupBoxMiscellaneous.Controls.Add(this.labelSaveAsFileNameFrom); + this.groupBoxMiscellaneous.Controls.Add(this.groupBoxGeneralRules); + this.groupBoxMiscellaneous.Controls.Add(this.comboBoxAutoBackupDeleteAfter); + this.groupBoxMiscellaneous.Controls.Add(this.labelAutoBackupDeleteAfter); + this.groupBoxMiscellaneous.Controls.Add(this.checkBoxCheckForUpdates); + this.groupBoxMiscellaneous.Controls.Add(this.labelSpellChecker); + this.groupBoxMiscellaneous.Controls.Add(this.comboBoxTimeCodeMode); + this.groupBoxMiscellaneous.Controls.Add(this.labelTimeCodeMode); + this.groupBoxMiscellaneous.Controls.Add(this.comboBoxEncoding); + this.groupBoxMiscellaneous.Controls.Add(this.checkBoxAutoDetectAnsiEncoding); + this.groupBoxMiscellaneous.Controls.Add(this.textBoxShowLineBreaksAs); + this.groupBoxMiscellaneous.Controls.Add(this.checkBoxAutoWrapWhileTyping); + this.groupBoxMiscellaneous.Controls.Add(this.checkBoxPromptDeleteLines); + this.groupBoxMiscellaneous.Controls.Add(this.checkBoxAllowEditOfOriginalSubtitle); + this.groupBoxMiscellaneous.Controls.Add(this.comboBoxSpellChecker); + this.groupBoxMiscellaneous.Controls.Add(this.comboBoxAutoBackup); + this.groupBoxMiscellaneous.Controls.Add(this.labelAutoBackup); + this.groupBoxMiscellaneous.Controls.Add(this.checkBoxRememberSelectedLine); + this.groupBoxMiscellaneous.Controls.Add(this.checkBoxRemoveBlankLinesWhenOpening); + this.groupBoxMiscellaneous.Controls.Add(this.labelAutoDetectAnsiEncoding); + this.groupBoxMiscellaneous.Controls.Add(this.comboBoxListViewDoubleClickEvent); + this.groupBoxMiscellaneous.Controls.Add(this.labelListViewDoubleClickEvent); + this.groupBoxMiscellaneous.Controls.Add(this.labelShowLineBreaksAs); + this.groupBoxMiscellaneous.Controls.Add(this.checkBoxRememberWindowPosition); + this.groupBoxMiscellaneous.Controls.Add(this.checkBoxStartInSourceView); + this.groupBoxMiscellaneous.Controls.Add(this.checkBoxReopenLastOpened); + this.groupBoxMiscellaneous.Controls.Add(this.checkBoxRememberRecentFiles); + this.groupBoxMiscellaneous.Controls.Add(this.labelDefaultFileEncoding); + this.groupBoxMiscellaneous.Controls.Add(this.comboBoxFrameRate); + this.groupBoxMiscellaneous.Controls.Add(this.labelDefaultFrameRate); + this.groupBoxMiscellaneous.Location = new System.Drawing.Point(6, 6); + this.groupBoxMiscellaneous.Name = "groupBoxMiscellaneous"; + this.groupBoxMiscellaneous.Size = new System.Drawing.Size(819, 508); + this.groupBoxMiscellaneous.TabIndex = 0; + this.groupBoxMiscellaneous.TabStop = false; + this.groupBoxMiscellaneous.Text = "Miscellaneous"; + // + // labelSplitBehavior + // + this.labelSplitBehavior.AutoSize = true; + this.labelSplitBehavior.Location = new System.Drawing.Point(438, 291); + this.labelSplitBehavior.Name = "labelSplitBehavior"; + this.labelSplitBehavior.Size = new System.Drawing.Size(72, 13); + this.labelSplitBehavior.TabIndex = 20; + this.labelSplitBehavior.Text = "Split behavior"; + // + // comboBoxSplitBehavior + // + this.comboBoxSplitBehavior.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSplitBehavior.FormattingEnabled = true; + this.comboBoxSplitBehavior.Location = new System.Drawing.Point(528, 288); + this.comboBoxSplitBehavior.Name = "comboBoxSplitBehavior"; + this.comboBoxSplitBehavior.Size = new System.Drawing.Size(207, 21); + this.comboBoxSplitBehavior.TabIndex = 21; + // + // checkBoxAutoSave + // + this.checkBoxAutoSave.AutoSize = true; + this.checkBoxAutoSave.Location = new System.Drawing.Point(441, 453); + this.checkBoxAutoSave.Name = "checkBoxAutoSave"; + this.checkBoxAutoSave.Size = new System.Drawing.Size(75, 17); + this.checkBoxAutoSave.TabIndex = 30; + this.checkBoxAutoSave.Text = "Auto save"; + this.checkBoxAutoSave.UseVisualStyleBackColor = true; + // + // comboBoxSaveAsFileNameFrom + // + this.comboBoxSaveAsFileNameFrom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSaveAsFileNameFrom.FormattingEnabled = true; + this.comboBoxSaveAsFileNameFrom.Location = new System.Drawing.Point(441, 386); + this.comboBoxSaveAsFileNameFrom.Name = "comboBoxSaveAsFileNameFrom"; + this.comboBoxSaveAsFileNameFrom.Size = new System.Drawing.Size(332, 21); + this.comboBoxSaveAsFileNameFrom.TabIndex = 25; + // + // labelSaveAsFileNameFrom + // + this.labelSaveAsFileNameFrom.AutoSize = true; + this.labelSaveAsFileNameFrom.Location = new System.Drawing.Point(438, 370); + this.labelSaveAsFileNameFrom.Name = "labelSaveAsFileNameFrom"; + this.labelSaveAsFileNameFrom.Size = new System.Drawing.Size(160, 13); + this.labelSaveAsFileNameFrom.TabIndex = 24; + this.labelSaveAsFileNameFrom.Text = "\"Save as...\" will take name from"; + // + // groupBoxGeneralRules + // + this.groupBoxGeneralRules.Controls.Add(this.buttonGapChoose); + this.groupBoxGeneralRules.Controls.Add(this.comboBoxContinuationStyle); + this.groupBoxGeneralRules.Controls.Add(this.labelContinuationStyle); + this.groupBoxGeneralRules.Controls.Add(this.labelDialogStyle); + this.groupBoxGeneralRules.Controls.Add(this.comboBoxDialogStyle); + this.groupBoxGeneralRules.Controls.Add(this.checkBoxCpsIncludeWhiteSpace); + this.groupBoxGeneralRules.Controls.Add(this.buttonEditProfile); + this.groupBoxGeneralRules.Controls.Add(this.comboBoxRulesProfileName); + this.groupBoxGeneralRules.Controls.Add(this.labelRulesProfileName); + this.groupBoxGeneralRules.Controls.Add(this.labelOptimalCharsPerSecond); + this.groupBoxGeneralRules.Controls.Add(this.numericUpDownOptimalCharsSec); + this.groupBoxGeneralRules.Controls.Add(this.labelSubMaxLen); + this.groupBoxGeneralRules.Controls.Add(this.numericUpDownMaxWordsMin); + this.groupBoxGeneralRules.Controls.Add(this.labelMergeShortLines); + this.groupBoxGeneralRules.Controls.Add(this.labelMaxWordsPerMin); + this.groupBoxGeneralRules.Controls.Add(this.labelMinDuration); + this.groupBoxGeneralRules.Controls.Add(this.numericUpDownMaxNumberOfLines); + this.groupBoxGeneralRules.Controls.Add(this.labelMaxDuration); + this.groupBoxGeneralRules.Controls.Add(this.labelMaxLines); + this.groupBoxGeneralRules.Controls.Add(this.numericUpDownDurationMin); + this.groupBoxGeneralRules.Controls.Add(this.numericUpDownDurationMax); + this.groupBoxGeneralRules.Controls.Add(this.comboBoxMergeShortLineLength); + this.groupBoxGeneralRules.Controls.Add(this.labelMaxCharsPerSecond); + this.groupBoxGeneralRules.Controls.Add(this.numericUpDownMinGapMs); + this.groupBoxGeneralRules.Controls.Add(this.numericUpDownMaxCharsSec); + this.groupBoxGeneralRules.Controls.Add(this.labelMinGapMs); + this.groupBoxGeneralRules.Controls.Add(this.numericUpDownSubtitleLineMaximumLength); + this.groupBoxGeneralRules.Location = new System.Drawing.Point(6, 23); + this.groupBoxGeneralRules.Name = "groupBoxGeneralRules"; + this.groupBoxGeneralRules.Size = new System.Drawing.Size(387, 381); + this.groupBoxGeneralRules.TabIndex = 0; + this.groupBoxGeneralRules.TabStop = false; + this.groupBoxGeneralRules.Text = "Rules"; + // + // buttonGapChoose + // + this.buttonGapChoose.Location = new System.Drawing.Point(265, 213); + this.buttonGapChoose.Name = "buttonGapChoose"; + this.buttonGapChoose.Size = new System.Drawing.Size(28, 23); + this.buttonGapChoose.TabIndex = 46; + this.buttonGapChoose.Text = "..."; + this.buttonGapChoose.UseVisualStyleBackColor = true; + this.buttonGapChoose.Click += new System.EventHandler(this.buttonGapChoose_Click); + // + // comboBoxContinuationStyle + // + this.comboBoxContinuationStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxContinuationStyle.DropDownWidth = 170; + this.comboBoxContinuationStyle.FormattingEnabled = true; + this.comboBoxContinuationStyle.Location = new System.Drawing.Point(203, 324); + this.comboBoxContinuationStyle.Name = "comboBoxContinuationStyle"; + this.comboBoxContinuationStyle.Size = new System.Drawing.Size(170, 21); + this.comboBoxContinuationStyle.TabIndex = 58; + this.comboBoxContinuationStyle.SelectedIndexChanged += new System.EventHandler(this.ProfileUiValueChanged); + // + // labelContinuationStyle + // + this.labelContinuationStyle.AutoSize = true; + this.labelContinuationStyle.Location = new System.Drawing.Point(6, 327); + this.labelContinuationStyle.Name = "labelContinuationStyle"; + this.labelContinuationStyle.Size = new System.Drawing.Size(140, 13); + this.labelContinuationStyle.TabIndex = 63; + this.labelContinuationStyle.Text = "Sentence continuation style"; + // + // labelDialogStyle + // + this.labelDialogStyle.AutoSize = true; + this.labelDialogStyle.Location = new System.Drawing.Point(6, 300); + this.labelDialogStyle.Name = "labelDialogStyle"; + this.labelDialogStyle.Size = new System.Drawing.Size(62, 13); + this.labelDialogStyle.TabIndex = 61; + this.labelDialogStyle.Text = "Dialog style"; + // + // comboBoxDialogStyle + // + this.comboBoxDialogStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxDialogStyle.FormattingEnabled = true; + this.comboBoxDialogStyle.Items.AddRange(new object[] { + "Dash both lines with space", + "Dash both lines without space", + "Dash second line with space", + "Dash second line without space"}); + this.comboBoxDialogStyle.Location = new System.Drawing.Point(203, 297); + this.comboBoxDialogStyle.Name = "comboBoxDialogStyle"; + this.comboBoxDialogStyle.Size = new System.Drawing.Size(170, 21); + this.comboBoxDialogStyle.TabIndex = 57; + this.comboBoxDialogStyle.SelectedIndexChanged += new System.EventHandler(this.ProfileUiValueChanged); + // + // checkBoxCpsIncludeWhiteSpace + // + this.checkBoxCpsIncludeWhiteSpace.AutoSize = true; + this.checkBoxCpsIncludeWhiteSpace.Location = new System.Drawing.Point(9, 354); + this.checkBoxCpsIncludeWhiteSpace.Name = "checkBoxCpsIncludeWhiteSpace"; + this.checkBoxCpsIncludeWhiteSpace.Size = new System.Drawing.Size(271, 17); + this.checkBoxCpsIncludeWhiteSpace.TabIndex = 65; + this.checkBoxCpsIncludeWhiteSpace.Text = "Characters per second (CPS) includes white spaces"; + this.checkBoxCpsIncludeWhiteSpace.UseVisualStyleBackColor = true; + this.checkBoxCpsIncludeWhiteSpace.CheckedChanged += new System.EventHandler(this.ProfileUiValueChanged); + // + // buttonEditProfile + // + this.buttonEditProfile.Location = new System.Drawing.Point(322, 19); + this.buttonEditProfile.Name = "buttonEditProfile"; + this.buttonEditProfile.Size = new System.Drawing.Size(28, 23); + this.buttonEditProfile.TabIndex = 10; + this.buttonEditProfile.Text = "..."; + this.buttonEditProfile.UseVisualStyleBackColor = true; + this.buttonEditProfile.Click += new System.EventHandler(this.buttonEditProfile_Click); + // + // comboBoxRulesProfileName + // + this.comboBoxRulesProfileName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxRulesProfileName.FormattingEnabled = true; + this.comboBoxRulesProfileName.Location = new System.Drawing.Point(78, 20); + this.comboBoxRulesProfileName.Name = "comboBoxRulesProfileName"; + this.comboBoxRulesProfileName.Size = new System.Drawing.Size(238, 21); + this.comboBoxRulesProfileName.TabIndex = 5; + this.comboBoxRulesProfileName.SelectedIndexChanged += new System.EventHandler(this.comboBoxRulesProfileName_SelectedIndexChanged); + // + // labelRulesProfileName + // + this.labelRulesProfileName.AutoSize = true; + this.labelRulesProfileName.Location = new System.Drawing.Point(6, 24); + this.labelRulesProfileName.Name = "labelRulesProfileName"; + this.labelRulesProfileName.Size = new System.Drawing.Size(37, 13); + this.labelRulesProfileName.TabIndex = 50; + this.labelRulesProfileName.Text = "Profile"; + // + // labelOptimalCharsPerSecond + // + this.labelOptimalCharsPerSecond.AutoSize = true; + this.labelOptimalCharsPerSecond.Location = new System.Drawing.Point(6, 84); + this.labelOptimalCharsPerSecond.Name = "labelOptimalCharsPerSecond"; + this.labelOptimalCharsPerSecond.Size = new System.Drawing.Size(92, 13); + this.labelOptimalCharsPerSecond.TabIndex = 8; + this.labelOptimalCharsPerSecond.Text = "Optimal chars/sec"; + // + // numericUpDownOptimalCharsSec + // + this.numericUpDownOptimalCharsSec.DecimalPlaces = 1; + this.numericUpDownOptimalCharsSec.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownOptimalCharsSec.Location = new System.Drawing.Point(203, 82); + this.numericUpDownOptimalCharsSec.Minimum = new decimal(new int[] { + 4, + 0, + 0, + 0}); + this.numericUpDownOptimalCharsSec.Name = "numericUpDownOptimalCharsSec"; + this.numericUpDownOptimalCharsSec.Size = new System.Drawing.Size(56, 21); + this.numericUpDownOptimalCharsSec.TabIndex = 20; + this.numericUpDownOptimalCharsSec.Value = new decimal(new int[] { + 11, + 0, + 0, + 0}); + this.numericUpDownOptimalCharsSec.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); + // + // labelSubMaxLen + // + this.labelSubMaxLen.AutoSize = true; + this.labelSubMaxLen.Location = new System.Drawing.Point(6, 57); + this.labelSubMaxLen.Name = "labelSubMaxLen"; + this.labelSubMaxLen.Size = new System.Drawing.Size(103, 13); + this.labelSubMaxLen.TabIndex = 6; + this.labelSubMaxLen.Text = "Subtitle max. length"; + // + // numericUpDownMaxWordsMin + // + this.numericUpDownMaxWordsMin.Location = new System.Drawing.Point(203, 136); + this.numericUpDownMaxWordsMin.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownMaxWordsMin.Minimum = new decimal(new int[] { + 4, + 0, + 0, + 0}); + this.numericUpDownMaxWordsMin.Name = "numericUpDownMaxWordsMin"; + this.numericUpDownMaxWordsMin.Size = new System.Drawing.Size(56, 21); + this.numericUpDownMaxWordsMin.TabIndex = 30; + this.numericUpDownMaxWordsMin.Value = new decimal(new int[] { + 300, + 0, + 0, + 0}); + this.numericUpDownMaxWordsMin.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); + // + // labelMergeShortLines + // + this.labelMergeShortLines.AutoSize = true; + this.labelMergeShortLines.Location = new System.Drawing.Point(6, 273); + this.labelMergeShortLines.Name = "labelMergeShortLines"; + this.labelMergeShortLines.Size = new System.Drawing.Size(124, 13); + this.labelMergeShortLines.TabIndex = 16; + this.labelMergeShortLines.Text = "Merge lines shorter than"; + // + // labelMaxWordsPerMin + // + this.labelMaxWordsPerMin.AutoSize = true; + this.labelMaxWordsPerMin.Location = new System.Drawing.Point(6, 138); + this.labelMaxWordsPerMin.Name = "labelMaxWordsPerMin"; + this.labelMaxWordsPerMin.Size = new System.Drawing.Size(83, 13); + this.labelMaxWordsPerMin.TabIndex = 49; + this.labelMaxWordsPerMin.Text = "Max. words/min"; + // + // labelMinDuration + // + this.labelMinDuration.AutoSize = true; + this.labelMinDuration.Location = new System.Drawing.Point(6, 165); + this.labelMinDuration.Name = "labelMinDuration"; + this.labelMinDuration.Size = new System.Drawing.Size(132, 13); + this.labelMinDuration.TabIndex = 10; + this.labelMinDuration.Text = "Min. duration, milliseconds"; + // + // numericUpDownMaxNumberOfLines + // + this.numericUpDownMaxNumberOfLines.Location = new System.Drawing.Point(203, 242); + this.numericUpDownMaxNumberOfLines.Maximum = new decimal(new int[] { + 25, + 0, + 0, + 0}); + this.numericUpDownMaxNumberOfLines.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numericUpDownMaxNumberOfLines.Name = "numericUpDownMaxNumberOfLines"; + this.numericUpDownMaxNumberOfLines.Size = new System.Drawing.Size(56, 21); + this.numericUpDownMaxNumberOfLines.TabIndex = 50; + this.numericUpDownMaxNumberOfLines.Value = new decimal(new int[] { + 2, + 0, + 0, + 0}); + this.numericUpDownMaxNumberOfLines.ValueChanged += new System.EventHandler(this.numericUpDownMaxNumberOfLines_ValueChanged); + // + // labelMaxDuration + // + this.labelMaxDuration.AutoSize = true; + this.labelMaxDuration.Location = new System.Drawing.Point(6, 191); + this.labelMaxDuration.Name = "labelMaxDuration"; + this.labelMaxDuration.Size = new System.Drawing.Size(136, 13); + this.labelMaxDuration.TabIndex = 12; + this.labelMaxDuration.Text = "Max. duration, milliseconds"; + // + // labelMaxLines + // + this.labelMaxLines.AutoSize = true; + this.labelMaxLines.Location = new System.Drawing.Point(6, 244); + this.labelMaxLines.Name = "labelMaxLines"; + this.labelMaxLines.Size = new System.Drawing.Size(107, 13); + this.labelMaxLines.TabIndex = 47; + this.labelMaxLines.Text = "Max. number of lines"; + // + // numericUpDownDurationMin + // + this.numericUpDownDurationMin.Location = new System.Drawing.Point(203, 163); + this.numericUpDownDurationMin.Maximum = new decimal(new int[] { + 3000, + 0, + 0, + 0}); + this.numericUpDownDurationMin.Minimum = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numericUpDownDurationMin.Name = "numericUpDownDurationMin"; + this.numericUpDownDurationMin.Size = new System.Drawing.Size(56, 21); + this.numericUpDownDurationMin.TabIndex = 35; + this.numericUpDownDurationMin.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numericUpDownDurationMin.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); + // + // numericUpDownDurationMax + // + this.numericUpDownDurationMax.Location = new System.Drawing.Point(203, 189); + this.numericUpDownDurationMax.Maximum = new decimal(new int[] { + 50000, + 0, + 0, + 0}); + this.numericUpDownDurationMax.Minimum = new decimal(new int[] { + 3000, + 0, + 0, + 0}); + this.numericUpDownDurationMax.Name = "numericUpDownDurationMax"; + this.numericUpDownDurationMax.Size = new System.Drawing.Size(56, 21); + this.numericUpDownDurationMax.TabIndex = 40; + this.numericUpDownDurationMax.Value = new decimal(new int[] { + 50000, + 0, + 0, + 0}); + this.numericUpDownDurationMax.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); + // + // comboBoxMergeShortLineLength + // + this.comboBoxMergeShortLineLength.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxMergeShortLineLength.FormattingEnabled = true; + this.comboBoxMergeShortLineLength.Location = new System.Drawing.Point(203, 270); + this.comboBoxMergeShortLineLength.Name = "comboBoxMergeShortLineLength"; + this.comboBoxMergeShortLineLength.Size = new System.Drawing.Size(73, 21); + this.comboBoxMergeShortLineLength.TabIndex = 55; + this.comboBoxMergeShortLineLength.SelectedIndexChanged += new System.EventHandler(this.ProfileUiValueChanged); + // + // labelMaxCharsPerSecond + // + this.labelMaxCharsPerSecond.AutoSize = true; + this.labelMaxCharsPerSecond.Location = new System.Drawing.Point(6, 111); + this.labelMaxCharsPerSecond.Name = "labelMaxCharsPerSecond"; + this.labelMaxCharsPerSecond.Size = new System.Drawing.Size(80, 13); + this.labelMaxCharsPerSecond.TabIndex = 9; + this.labelMaxCharsPerSecond.Text = "Max. chars/sec"; + // + // numericUpDownMinGapMs + // + this.numericUpDownMinGapMs.Location = new System.Drawing.Point(203, 215); + this.numericUpDownMinGapMs.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownMinGapMs.Name = "numericUpDownMinGapMs"; + this.numericUpDownMinGapMs.Size = new System.Drawing.Size(56, 21); + this.numericUpDownMinGapMs.TabIndex = 45; + this.numericUpDownMinGapMs.Value = new decimal(new int[] { + 25, + 0, + 0, + 0}); + this.numericUpDownMinGapMs.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); + // + // numericUpDownMaxCharsSec + // + this.numericUpDownMaxCharsSec.DecimalPlaces = 1; + this.numericUpDownMaxCharsSec.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownMaxCharsSec.Location = new System.Drawing.Point(203, 109); + this.numericUpDownMaxCharsSec.Minimum = new decimal(new int[] { + 4, + 0, + 0, + 0}); + this.numericUpDownMaxCharsSec.Name = "numericUpDownMaxCharsSec"; + this.numericUpDownMaxCharsSec.Size = new System.Drawing.Size(56, 21); + this.numericUpDownMaxCharsSec.TabIndex = 25; + this.numericUpDownMaxCharsSec.Value = new decimal(new int[] { + 24, + 0, + 0, + 0}); + this.numericUpDownMaxCharsSec.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); + // + // labelMinGapMs + // + this.labelMinGapMs.AutoSize = true; + this.labelMinGapMs.Location = new System.Drawing.Point(6, 217); + this.labelMinGapMs.Name = "labelMinGapMs"; + this.labelMinGapMs.Size = new System.Drawing.Size(136, 13); + this.labelMinGapMs.TabIndex = 14; + this.labelMinGapMs.Text = "Min. gap between subtitles"; + // + // numericUpDownSubtitleLineMaximumLength + // + this.numericUpDownSubtitleLineMaximumLength.Location = new System.Drawing.Point(203, 55); + this.numericUpDownSubtitleLineMaximumLength.Maximum = new decimal(new int[] { + 999, + 0, + 0, + 0}); + this.numericUpDownSubtitleLineMaximumLength.Minimum = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDownSubtitleLineMaximumLength.Name = "numericUpDownSubtitleLineMaximumLength"; + this.numericUpDownSubtitleLineMaximumLength.Size = new System.Drawing.Size(56, 21); + this.numericUpDownSubtitleLineMaximumLength.TabIndex = 15; + this.numericUpDownSubtitleLineMaximumLength.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numericUpDownSubtitleLineMaximumLength.ValueChanged += new System.EventHandler(this.ProfileUiValueChanged); + // + // comboBoxAutoBackupDeleteAfter + // + this.comboBoxAutoBackupDeleteAfter.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxAutoBackupDeleteAfter.FormattingEnabled = true; + this.comboBoxAutoBackupDeleteAfter.Items.AddRange(new object[] { + "1 month", + "3 months", + "6 months"}); + this.comboBoxAutoBackupDeleteAfter.Location = new System.Drawing.Point(707, 421); + this.comboBoxAutoBackupDeleteAfter.Name = "comboBoxAutoBackupDeleteAfter"; + this.comboBoxAutoBackupDeleteAfter.Size = new System.Drawing.Size(88, 21); + this.comboBoxAutoBackupDeleteAfter.TabIndex = 29; + // + // labelAutoBackupDeleteAfter + // + this.labelAutoBackupDeleteAfter.AutoSize = true; + this.labelAutoBackupDeleteAfter.Location = new System.Drawing.Point(639, 424); + this.labelAutoBackupDeleteAfter.Name = "labelAutoBackupDeleteAfter"; + this.labelAutoBackupDeleteAfter.Size = new System.Drawing.Size(65, 13); + this.labelAutoBackupDeleteAfter.TabIndex = 28; + this.labelAutoBackupDeleteAfter.Text = "Delete after"; + // + // checkBoxCheckForUpdates + // + this.checkBoxCheckForUpdates.AutoSize = true; + this.checkBoxCheckForUpdates.Location = new System.Drawing.Point(522, 453); + this.checkBoxCheckForUpdates.Name = "checkBoxCheckForUpdates"; + this.checkBoxCheckForUpdates.Size = new System.Drawing.Size(114, 17); + this.checkBoxCheckForUpdates.TabIndex = 31; + this.checkBoxCheckForUpdates.Text = "Check for updates"; + this.checkBoxCheckForUpdates.UseVisualStyleBackColor = true; + // + // labelSpellChecker + // + this.labelSpellChecker.AutoSize = true; + this.labelSpellChecker.Location = new System.Drawing.Point(669, 19); + this.labelSpellChecker.Name = "labelSpellChecker"; + this.labelSpellChecker.Size = new System.Drawing.Size(69, 13); + this.labelSpellChecker.TabIndex = 30; + this.labelSpellChecker.Text = "Spell checker"; + this.labelSpellChecker.Visible = false; + // + // comboBoxTimeCodeMode + // + this.comboBoxTimeCodeMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxTimeCodeMode.FormattingEnabled = true; + this.comboBoxTimeCodeMode.Items.AddRange(new object[] { + "HH:MM:SS:MSEC (00:00:00.000)", + "HH:MM:SS:FF (00:00:00.00)"}); + this.comboBoxTimeCodeMode.Location = new System.Drawing.Point(528, 261); + this.comboBoxTimeCodeMode.Name = "comboBoxTimeCodeMode"; + this.comboBoxTimeCodeMode.Size = new System.Drawing.Size(207, 21); + this.comboBoxTimeCodeMode.TabIndex = 19; + // + // labelTimeCodeMode + // + this.labelTimeCodeMode.AutoSize = true; + this.labelTimeCodeMode.Location = new System.Drawing.Point(438, 264); + this.labelTimeCodeMode.Name = "labelTimeCodeMode"; + this.labelTimeCodeMode.Size = new System.Drawing.Size(84, 13); + this.labelTimeCodeMode.TabIndex = 18; + this.labelTimeCodeMode.Text = "Time code mode"; + // + // comboBoxEncoding + // + this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxEncoding.FormattingEnabled = true; + this.comboBoxEncoding.Items.AddRange(new object[] { + "ANSI", + "UTF-7", + "UTF-8", + "Unicode"}); + this.comboBoxEncoding.Location = new System.Drawing.Point(205, 438); + this.comboBoxEncoding.Name = "comboBoxEncoding"; + this.comboBoxEncoding.Size = new System.Drawing.Size(188, 21); + this.comboBoxEncoding.TabIndex = 4; + // + // checkBoxAutoDetectAnsiEncoding + // + this.checkBoxAutoDetectAnsiEncoding.AutoSize = true; + this.checkBoxAutoDetectAnsiEncoding.Location = new System.Drawing.Point(205, 467); + this.checkBoxAutoDetectAnsiEncoding.Name = "checkBoxAutoDetectAnsiEncoding"; + this.checkBoxAutoDetectAnsiEncoding.Size = new System.Drawing.Size(15, 14); + this.checkBoxAutoDetectAnsiEncoding.TabIndex = 6; + this.checkBoxAutoDetectAnsiEncoding.UseVisualStyleBackColor = true; + // + // textBoxShowLineBreaksAs + // + this.textBoxShowLineBreaksAs.Location = new System.Drawing.Point(594, 233); + this.textBoxShowLineBreaksAs.MaxLength = 10; + this.textBoxShowLineBreaksAs.Name = "textBoxShowLineBreaksAs"; + this.textBoxShowLineBreaksAs.Size = new System.Drawing.Size(60, 21); + this.textBoxShowLineBreaksAs.TabIndex = 17; + // + // checkBoxAutoWrapWhileTyping + // + this.checkBoxAutoWrapWhileTyping.AutoSize = true; + this.checkBoxAutoWrapWhileTyping.Location = new System.Drawing.Point(441, 210); + this.checkBoxAutoWrapWhileTyping.Name = "checkBoxAutoWrapWhileTyping"; + this.checkBoxAutoWrapWhileTyping.Size = new System.Drawing.Size(137, 17); + this.checkBoxAutoWrapWhileTyping.TabIndex = 15; + this.checkBoxAutoWrapWhileTyping.Text = "Auto-wrap while typing"; + this.checkBoxAutoWrapWhileTyping.UseVisualStyleBackColor = true; + // + // checkBoxPromptDeleteLines + // + this.checkBoxPromptDeleteLines.AutoSize = true; + this.checkBoxPromptDeleteLines.Location = new System.Drawing.Point(441, 187); + this.checkBoxPromptDeleteLines.Name = "checkBoxPromptDeleteLines"; + this.checkBoxPromptDeleteLines.Size = new System.Drawing.Size(142, 17); + this.checkBoxPromptDeleteLines.TabIndex = 14; + this.checkBoxPromptDeleteLines.Text = "Prompt for deleting lines"; + this.checkBoxPromptDeleteLines.UseVisualStyleBackColor = true; + // + // checkBoxAllowEditOfOriginalSubtitle + // + this.checkBoxAllowEditOfOriginalSubtitle.AutoSize = true; + this.checkBoxAllowEditOfOriginalSubtitle.Location = new System.Drawing.Point(441, 164); + this.checkBoxAllowEditOfOriginalSubtitle.Name = "checkBoxAllowEditOfOriginalSubtitle"; + this.checkBoxAllowEditOfOriginalSubtitle.Size = new System.Drawing.Size(160, 17); + this.checkBoxAllowEditOfOriginalSubtitle.TabIndex = 13; + this.checkBoxAllowEditOfOriginalSubtitle.Text = "Allow edit of original subtitle"; + this.checkBoxAllowEditOfOriginalSubtitle.UseVisualStyleBackColor = true; + // + // comboBoxSpellChecker + // + this.comboBoxSpellChecker.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSpellChecker.FormattingEnabled = true; + this.comboBoxSpellChecker.Items.AddRange(new object[] { + "Hunspell", + "Word"}); + this.comboBoxSpellChecker.Location = new System.Drawing.Point(692, 16); + this.comboBoxSpellChecker.Name = "comboBoxSpellChecker"; + this.comboBoxSpellChecker.Size = new System.Drawing.Size(121, 21); + this.comboBoxSpellChecker.TabIndex = 31; + this.comboBoxSpellChecker.Visible = false; + // + // comboBoxAutoBackup + // + this.comboBoxAutoBackup.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxAutoBackup.FormattingEnabled = true; + this.comboBoxAutoBackup.Items.AddRange(new object[] { + "None", + "Every minute", + "Every 5 minutes", + "Every 15 minutes"}); + this.comboBoxAutoBackup.Location = new System.Drawing.Point(512, 421); + this.comboBoxAutoBackup.Name = "comboBoxAutoBackup"; + this.comboBoxAutoBackup.Size = new System.Drawing.Size(121, 21); + this.comboBoxAutoBackup.TabIndex = 27; + // + // labelAutoBackup + // + this.labelAutoBackup.AutoSize = true; + this.labelAutoBackup.Location = new System.Drawing.Point(438, 424); + this.labelAutoBackup.Name = "labelAutoBackup"; + this.labelAutoBackup.Size = new System.Drawing.Size(68, 13); + this.labelAutoBackup.TabIndex = 26; + this.labelAutoBackup.Text = "Auto-backup"; + // + // checkBoxRememberSelectedLine + // + this.checkBoxRememberSelectedLine.AutoSize = true; + this.checkBoxRememberSelectedLine.Location = new System.Drawing.Point(449, 69); + this.checkBoxRememberSelectedLine.Name = "checkBoxRememberSelectedLine"; + this.checkBoxRememberSelectedLine.Size = new System.Drawing.Size(139, 17); + this.checkBoxRememberSelectedLine.TabIndex = 9; + this.checkBoxRememberSelectedLine.Text = "Remember selected line"; + this.checkBoxRememberSelectedLine.UseVisualStyleBackColor = true; + // + // checkBoxRemoveBlankLinesWhenOpening + // + this.checkBoxRemoveBlankLinesWhenOpening.AutoSize = true; + this.checkBoxRemoveBlankLinesWhenOpening.Location = new System.Drawing.Point(441, 141); + this.checkBoxRemoveBlankLinesWhenOpening.Name = "checkBoxRemoveBlankLinesWhenOpening"; + this.checkBoxRemoveBlankLinesWhenOpening.Size = new System.Drawing.Size(225, 17); + this.checkBoxRemoveBlankLinesWhenOpening.TabIndex = 12; + this.checkBoxRemoveBlankLinesWhenOpening.Text = "Remove blank lines when opening subtitle"; + this.checkBoxRemoveBlankLinesWhenOpening.UseVisualStyleBackColor = true; + // + // labelAutoDetectAnsiEncoding + // + this.labelAutoDetectAnsiEncoding.AutoSize = true; + this.labelAutoDetectAnsiEncoding.Location = new System.Drawing.Point(8, 466); + this.labelAutoDetectAnsiEncoding.Name = "labelAutoDetectAnsiEncoding"; + this.labelAutoDetectAnsiEncoding.Size = new System.Drawing.Size(137, 13); + this.labelAutoDetectAnsiEncoding.TabIndex = 5; + this.labelAutoDetectAnsiEncoding.Text = "Auto detect ANSI encoding"; + // + // comboBoxListViewDoubleClickEvent + // + this.comboBoxListViewDoubleClickEvent.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxListViewDoubleClickEvent.FormattingEnabled = true; + this.comboBoxListViewDoubleClickEvent.Items.AddRange(new object[] { + "ANSI", + "UTF-7", + "UTF-8", + "Unicode"}); + this.comboBoxListViewDoubleClickEvent.Location = new System.Drawing.Point(441, 337); + this.comboBoxListViewDoubleClickEvent.Name = "comboBoxListViewDoubleClickEvent"; + this.comboBoxListViewDoubleClickEvent.Size = new System.Drawing.Size(332, 21); + this.comboBoxListViewDoubleClickEvent.TabIndex = 23; + // + // labelListViewDoubleClickEvent + // + this.labelListViewDoubleClickEvent.AutoSize = true; + this.labelListViewDoubleClickEvent.Location = new System.Drawing.Point(438, 321); + this.labelListViewDoubleClickEvent.Name = "labelListViewDoubleClickEvent"; + this.labelListViewDoubleClickEvent.Size = new System.Drawing.Size(227, 13); + this.labelListViewDoubleClickEvent.TabIndex = 22; + this.labelListViewDoubleClickEvent.Text = "Double-click on line in main window listview will"; + // + // labelShowLineBreaksAs + // + this.labelShowLineBreaksAs.AutoSize = true; + this.labelShowLineBreaksAs.Location = new System.Drawing.Point(438, 236); + this.labelShowLineBreaksAs.Name = "labelShowLineBreaksAs"; + this.labelShowLineBreaksAs.Size = new System.Drawing.Size(150, 13); + this.labelShowLineBreaksAs.TabIndex = 16; + this.labelShowLineBreaksAs.Text = "Show line breaks in listview as"; + // + // checkBoxRememberWindowPosition + // + this.checkBoxRememberWindowPosition.AutoSize = true; + this.checkBoxRememberWindowPosition.Location = new System.Drawing.Point(441, 95); + this.checkBoxRememberWindowPosition.Name = "checkBoxRememberWindowPosition"; + this.checkBoxRememberWindowPosition.Size = new System.Drawing.Size(223, 17); + this.checkBoxRememberWindowPosition.TabIndex = 10; + this.checkBoxRememberWindowPosition.Text = "Remember main window position and size"; + this.checkBoxRememberWindowPosition.UseVisualStyleBackColor = true; + // + // checkBoxStartInSourceView + // + this.checkBoxStartInSourceView.AutoSize = true; + this.checkBoxStartInSourceView.Location = new System.Drawing.Point(441, 118); + this.checkBoxStartInSourceView.Name = "checkBoxStartInSourceView"; + this.checkBoxStartInSourceView.Size = new System.Drawing.Size(121, 17); + this.checkBoxStartInSourceView.TabIndex = 11; + this.checkBoxStartInSourceView.Text = "Start in source view"; + this.checkBoxStartInSourceView.UseVisualStyleBackColor = true; + // + // checkBoxReopenLastOpened + // + this.checkBoxReopenLastOpened.AutoSize = true; + this.checkBoxReopenLastOpened.Location = new System.Drawing.Point(449, 46); + this.checkBoxReopenLastOpened.Name = "checkBoxReopenLastOpened"; + this.checkBoxReopenLastOpened.Size = new System.Drawing.Size(145, 17); + this.checkBoxReopenLastOpened.TabIndex = 8; + this.checkBoxReopenLastOpened.Text = "Start with last file loaded"; + this.checkBoxReopenLastOpened.UseVisualStyleBackColor = true; + // + // checkBoxRememberRecentFiles + // + this.checkBoxRememberRecentFiles.AutoSize = true; + this.checkBoxRememberRecentFiles.Location = new System.Drawing.Point(441, 22); + this.checkBoxRememberRecentFiles.Name = "checkBoxRememberRecentFiles"; + this.checkBoxRememberRecentFiles.Size = new System.Drawing.Size(195, 17); + this.checkBoxRememberRecentFiles.TabIndex = 7; + this.checkBoxRememberRecentFiles.Text = "Remember recent files (for reopen)"; + this.checkBoxRememberRecentFiles.UseVisualStyleBackColor = true; + this.checkBoxRememberRecentFiles.CheckedChanged += new System.EventHandler(this.checkBoxRememberRecentFiles_CheckedChanged); + // + // labelDefaultFileEncoding + // + this.labelDefaultFileEncoding.AutoSize = true; + this.labelDefaultFileEncoding.Location = new System.Drawing.Point(8, 442); + this.labelDefaultFileEncoding.Name = "labelDefaultFileEncoding"; + this.labelDefaultFileEncoding.Size = new System.Drawing.Size(105, 13); + this.labelDefaultFileEncoding.TabIndex = 3; + this.labelDefaultFileEncoding.Text = "Default file encoding"; + // + // comboBoxFrameRate + // + this.comboBoxFrameRate.FormattingEnabled = true; + this.comboBoxFrameRate.Location = new System.Drawing.Point(205, 410); + this.comboBoxFrameRate.Name = "comboBoxFrameRate"; + this.comboBoxFrameRate.Size = new System.Drawing.Size(121, 21); + this.comboBoxFrameRate.TabIndex = 2; + // + // labelDefaultFrameRate + // + this.labelDefaultFrameRate.AutoSize = true; + this.labelDefaultFrameRate.Location = new System.Drawing.Point(8, 415); + this.labelDefaultFrameRate.Name = "labelDefaultFrameRate"; + this.labelDefaultFrameRate.Size = new System.Drawing.Size(96, 13); + this.labelDefaultFrameRate.TabIndex = 1; + this.labelDefaultFrameRate.Text = "Default frame rate"; + // + // tabPageShortcuts + // + this.tabPageShortcuts.Controls.Add(this.groupBoxShortcuts); + this.tabPageShortcuts.Location = new System.Drawing.Point(4, 22); + this.tabPageShortcuts.Name = "tabPageShortcuts"; + this.tabPageShortcuts.Padding = new System.Windows.Forms.Padding(3); + this.tabPageShortcuts.Size = new System.Drawing.Size(832, 520); + this.tabPageShortcuts.TabIndex = 8; + this.tabPageShortcuts.Text = "Shortcuts"; + this.tabPageShortcuts.UseVisualStyleBackColor = true; + // + // groupBoxShortcuts + // + this.groupBoxShortcuts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxShortcuts.Controls.Add(this.buttonShortcutsClear); + this.groupBoxShortcuts.Controls.Add(this.labelShortcutsSearch); + this.groupBoxShortcuts.Controls.Add(this.textBoxShortcutSearch); + this.groupBoxShortcuts.Controls.Add(this.buttonClearShortcut); + this.groupBoxShortcuts.Controls.Add(this.comboBoxShortcutKey); + this.groupBoxShortcuts.Controls.Add(this.labelShortcutKey); + this.groupBoxShortcuts.Controls.Add(this.checkBoxShortcutsShift); + this.groupBoxShortcuts.Controls.Add(this.checkBoxShortcutsAlt); + this.groupBoxShortcuts.Controls.Add(this.checkBoxShortcutsControl); + this.groupBoxShortcuts.Controls.Add(this.buttonUpdateShortcut); + this.groupBoxShortcuts.Controls.Add(this.treeViewShortcuts); + this.groupBoxShortcuts.Controls.Add(this.labelShortcut); + this.groupBoxShortcuts.Location = new System.Drawing.Point(6, 6); + this.groupBoxShortcuts.Name = "groupBoxShortcuts"; + this.groupBoxShortcuts.Size = new System.Drawing.Size(819, 499); + this.groupBoxShortcuts.TabIndex = 2; + this.groupBoxShortcuts.TabStop = false; + this.groupBoxShortcuts.Text = "Shortcuts"; + // + // buttonShortcutsClear + // + this.buttonShortcutsClear.Enabled = false; + this.buttonShortcutsClear.Location = new System.Drawing.Point(221, 18); + this.buttonShortcutsClear.Name = "buttonShortcutsClear"; + this.buttonShortcutsClear.Size = new System.Drawing.Size(111, 23); + this.buttonShortcutsClear.TabIndex = 38; + this.buttonShortcutsClear.Text = "Clear"; + this.buttonShortcutsClear.UseVisualStyleBackColor = true; + this.buttonShortcutsClear.Click += new System.EventHandler(this.buttonShortcutsClear_Click); + // + // labelShortcutsSearch + // + this.labelShortcutsSearch.AutoSize = true; + this.labelShortcutsSearch.Location = new System.Drawing.Point(18, 23); + this.labelShortcutsSearch.Name = "labelShortcutsSearch"; + this.labelShortcutsSearch.Size = new System.Drawing.Size(40, 13); + this.labelShortcutsSearch.TabIndex = 37; + this.labelShortcutsSearch.Text = "Search"; + // + // textBoxShortcutSearch + // + this.textBoxShortcutSearch.Location = new System.Drawing.Point(64, 20); + this.textBoxShortcutSearch.Name = "textBoxShortcutSearch"; + this.textBoxShortcutSearch.Size = new System.Drawing.Size(151, 21); + this.textBoxShortcutSearch.TabIndex = 36; + this.textBoxShortcutSearch.TextChanged += new System.EventHandler(this.textBoxShortcutSearch_TextChanged); + // + // buttonClearShortcut + // + this.buttonClearShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonClearShortcut.Enabled = false; + this.buttonClearShortcut.Location = new System.Drawing.Point(582, 470); + this.buttonClearShortcut.Name = "buttonClearShortcut"; + this.buttonClearShortcut.Size = new System.Drawing.Size(111, 23); + this.buttonClearShortcut.TabIndex = 6; + this.buttonClearShortcut.Text = "&Clear"; + this.buttonClearShortcut.UseVisualStyleBackColor = true; + this.buttonClearShortcut.Click += new System.EventHandler(this.buttonClearShortcut_Click); + // + // comboBoxShortcutKey + // + this.comboBoxShortcutKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.comboBoxShortcutKey.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxShortcutKey.Enabled = false; + this.comboBoxShortcutKey.FormattingEnabled = true; + this.comboBoxShortcutKey.Items.AddRange(new object[] { + "None", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "D0", + "D1", + "D2", + "D3", + "D4", + "D5", + "D6", + "D7", + "D8", + "D9", + "F1", + "F2", + "F3", + "F4", + "F5", + "F6", + "F7", + "F8", + "F9", + "F10", + "F11", + "F12", + "Delete", + "Down", + "Home", + "End", + "Escape", + "Insert", + "Left", + "Pause", + "Return", + "Right", + "Space", + "Tab", + "Up", + "Back", + "NumPad0", + "NumPad1", + "NumPad2", + "NumPad3", + "NumPad4", + "NumPad5", + "NumPad6", + "NumPad7", + "NumPad8", + "NumPad9", + "PageDown", + "PageUp", + "Sleep", + "Multiply", + "Add", + "Separator", + "Subtract", + "Decimal", + "Divide", + "CapsLock", + "NumLock", + "Scroll", + "VolumeMute", + "VolumeDown", + "VolumeUp", + "MediaNextTrack", + "MediaPreviousTrack", + "MediaStop", + "MediaPlayPause", + "LaunchMail", + "SelectMedia", + "LaunchApplication1", + "LaunchApplication2", + "Oem1", + "Oemplus", + "Oemcomma", + "OemMinus", + "OemPeriod", + "OemQuestion", + "OemSemicolon", + "Oemtilde", + "OemOpenBrackets", + "Oem5", + "Oem6", + "Oem7", + "Oem8", + "OemBackslash", + "ProcessKey", + "Packet", + "Attn", + "Crsel", + "Exsel", + "EraseEof", + "Play", + "Zoom", + "NoName", + "Pa1", + "OemClear", + "KeyCode", + "F13", + "F14", + "F15", + "F16", + "F17", + "F18", + "F19", + "F20", + "F21", + "F22", + "F23", + "F24"}); + this.comboBoxShortcutKey.Location = new System.Drawing.Point(353, 470); + this.comboBoxShortcutKey.Name = "comboBoxShortcutKey"; + this.comboBoxShortcutKey.Size = new System.Drawing.Size(92, 21); + this.comboBoxShortcutKey.TabIndex = 4; + this.comboBoxShortcutKey.SelectedIndexChanged += new System.EventHandler(this.ValidateShortcut); + this.comboBoxShortcutKey.KeyDown += new System.Windows.Forms.KeyEventHandler(this.comboBoxShortcutKey_KeyDown); + // + // labelShortcutKey + // + this.labelShortcutKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelShortcutKey.AutoSize = true; + this.labelShortcutKey.Location = new System.Drawing.Point(322, 472); + this.labelShortcutKey.Name = "labelShortcutKey"; + this.labelShortcutKey.Size = new System.Drawing.Size(25, 13); + this.labelShortcutKey.TabIndex = 35; + this.labelShortcutKey.Text = "Key"; + // + // checkBoxShortcutsShift + // + this.checkBoxShortcutsShift.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.checkBoxShortcutsShift.AutoSize = true; + this.checkBoxShortcutsShift.Enabled = false; + this.checkBoxShortcutsShift.Location = new System.Drawing.Point(245, 472); + this.checkBoxShortcutsShift.Name = "checkBoxShortcutsShift"; + this.checkBoxShortcutsShift.Size = new System.Drawing.Size(48, 17); + this.checkBoxShortcutsShift.TabIndex = 3; + this.checkBoxShortcutsShift.Text = "Shift"; + this.checkBoxShortcutsShift.UseVisualStyleBackColor = true; + this.checkBoxShortcutsShift.CheckedChanged += new System.EventHandler(this.ValidateShortcut); + // + // checkBoxShortcutsAlt + // + this.checkBoxShortcutsAlt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.checkBoxShortcutsAlt.AutoSize = true; + this.checkBoxShortcutsAlt.Enabled = false; + this.checkBoxShortcutsAlt.Location = new System.Drawing.Point(176, 472); + this.checkBoxShortcutsAlt.Name = "checkBoxShortcutsAlt"; + this.checkBoxShortcutsAlt.Size = new System.Drawing.Size(39, 17); + this.checkBoxShortcutsAlt.TabIndex = 2; + this.checkBoxShortcutsAlt.Text = "Alt"; + this.checkBoxShortcutsAlt.UseVisualStyleBackColor = true; + this.checkBoxShortcutsAlt.CheckedChanged += new System.EventHandler(this.ValidateShortcut); + // + // checkBoxShortcutsControl + // + this.checkBoxShortcutsControl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.checkBoxShortcutsControl.AutoSize = true; + this.checkBoxShortcutsControl.Enabled = false; + this.checkBoxShortcutsControl.Location = new System.Drawing.Point(89, 472); + this.checkBoxShortcutsControl.Name = "checkBoxShortcutsControl"; + this.checkBoxShortcutsControl.Size = new System.Drawing.Size(61, 17); + this.checkBoxShortcutsControl.TabIndex = 1; + this.checkBoxShortcutsControl.Text = "Control"; + this.checkBoxShortcutsControl.UseVisualStyleBackColor = true; + this.checkBoxShortcutsControl.CheckedChanged += new System.EventHandler(this.ValidateShortcut); + // + // buttonUpdateShortcut + // + this.buttonUpdateShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonUpdateShortcut.Enabled = false; + this.buttonUpdateShortcut.Location = new System.Drawing.Point(465, 470); + this.buttonUpdateShortcut.Name = "buttonUpdateShortcut"; + this.buttonUpdateShortcut.Size = new System.Drawing.Size(111, 23); + this.buttonUpdateShortcut.TabIndex = 5; + this.buttonUpdateShortcut.Text = "&Update"; + this.buttonUpdateShortcut.UseVisualStyleBackColor = true; + this.buttonUpdateShortcut.Click += new System.EventHandler(this.buttonUpdateShortcut_Click); + // + // treeViewShortcuts + // + this.treeViewShortcuts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.treeViewShortcuts.ContextMenuStrip = this.contextMenuStripShortcuts; + this.treeViewShortcuts.HideSelection = false; + this.treeViewShortcuts.Location = new System.Drawing.Point(16, 47); + this.treeViewShortcuts.Name = "treeViewShortcuts"; + this.treeViewShortcuts.Size = new System.Drawing.Size(797, 417); + this.treeViewShortcuts.TabIndex = 0; + this.treeViewShortcuts.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewShortcuts_AfterSelect); + // + // contextMenuStripShortcuts + // + this.contextMenuStripShortcuts.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemShortcutsCollapse, + this.toolStripSeparator1, + this.importShortcutsToolStripMenuItem, + this.exportShortcutsToolStripMenuItem}); + this.contextMenuStripShortcuts.Name = "contextMenuStripShortcuts"; + this.contextMenuStripShortcuts.Size = new System.Drawing.Size(120, 76); + // + // toolStripMenuItemShortcutsCollapse + // + this.toolStripMenuItemShortcutsCollapse.Name = "toolStripMenuItemShortcutsCollapse"; + this.toolStripMenuItemShortcutsCollapse.Size = new System.Drawing.Size(119, 22); + this.toolStripMenuItemShortcutsCollapse.Text = "Collapse"; + this.toolStripMenuItemShortcutsCollapse.Click += new System.EventHandler(this.toolStripMenuItemShortcutsCollapse_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(116, 6); + // + // importShortcutsToolStripMenuItem + // + this.importShortcutsToolStripMenuItem.Name = "importShortcutsToolStripMenuItem"; + this.importShortcutsToolStripMenuItem.Size = new System.Drawing.Size(119, 22); + this.importShortcutsToolStripMenuItem.Text = "Import..."; + this.importShortcutsToolStripMenuItem.Click += new System.EventHandler(this.importShortcutsToolStripMenuItem_Click); + // + // exportShortcutsToolStripMenuItem + // + this.exportShortcutsToolStripMenuItem.Name = "exportShortcutsToolStripMenuItem"; + this.exportShortcutsToolStripMenuItem.Size = new System.Drawing.Size(119, 22); + this.exportShortcutsToolStripMenuItem.Text = "Export..."; + this.exportShortcutsToolStripMenuItem.Click += new System.EventHandler(this.exportShortcutsToolStripMenuItem_Click); + // + // labelShortcut + // + this.labelShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelShortcut.AutoSize = true; + this.labelShortcut.Location = new System.Drawing.Point(15, 472); + this.labelShortcut.Name = "labelShortcut"; + this.labelShortcut.Size = new System.Drawing.Size(52, 13); + this.labelShortcut.TabIndex = 3; + this.labelShortcut.Text = "Shortcut:"; + // + // tabPageSyntaxColoring + // + this.tabPageSyntaxColoring.Controls.Add(this.groupBoxListViewSyntaxColoring); + this.tabPageSyntaxColoring.Location = new System.Drawing.Point(4, 22); + this.tabPageSyntaxColoring.Name = "tabPageSyntaxColoring"; + this.tabPageSyntaxColoring.Padding = new System.Windows.Forms.Padding(3); + this.tabPageSyntaxColoring.Size = new System.Drawing.Size(832, 520); + this.tabPageSyntaxColoring.TabIndex = 9; + this.tabPageSyntaxColoring.Text = "Syntax coloring"; + this.tabPageSyntaxColoring.UseVisualStyleBackColor = true; + // + // groupBoxListViewSyntaxColoring + // + this.groupBoxListViewSyntaxColoring.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxListViewSyntaxColoring.Controls.Add(this.buttonLineWidthSettings); + this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorTextTooWide); + this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorGapTooSmall); + this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorTextMoreThanTwoLines); + this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxOverlap); + this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorDurationTooSmall); + this.groupBoxListViewSyntaxColoring.Controls.Add(this.buttonListViewSyntaxColorError); + this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorTextTooLong); + this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorDurationTooLarge); + this.groupBoxListViewSyntaxColoring.Controls.Add(this.panelListViewSyntaxColorError); + this.groupBoxListViewSyntaxColoring.Location = new System.Drawing.Point(6, 6); + this.groupBoxListViewSyntaxColoring.Name = "groupBoxListViewSyntaxColoring"; + this.groupBoxListViewSyntaxColoring.Size = new System.Drawing.Size(820, 523); + this.groupBoxListViewSyntaxColoring.TabIndex = 0; + this.groupBoxListViewSyntaxColoring.TabStop = false; + this.groupBoxListViewSyntaxColoring.Text = "List view syntax coloring"; + // + // buttonLineWidthSettings + // + this.buttonLineWidthSettings.Location = new System.Drawing.Point(160, 112); + this.buttonLineWidthSettings.Name = "buttonLineWidthSettings"; + this.buttonLineWidthSettings.Size = new System.Drawing.Size(112, 23); + this.buttonLineWidthSettings.TabIndex = 4; + this.buttonLineWidthSettings.Text = "Settings..."; + this.buttonLineWidthSettings.UseVisualStyleBackColor = true; + this.buttonLineWidthSettings.Click += new System.EventHandler(this.buttonLineWidthSettings_Click); + // + // checkBoxSyntaxColorTextTooWide + // + this.checkBoxSyntaxColorTextTooWide.AutoSize = true; + this.checkBoxSyntaxColorTextTooWide.Location = new System.Drawing.Point(20, 116); + this.checkBoxSyntaxColorTextTooWide.Name = "checkBoxSyntaxColorTextTooWide"; + this.checkBoxSyntaxColorTextTooWide.Size = new System.Drawing.Size(134, 17); + this.checkBoxSyntaxColorTextTooWide.TabIndex = 3; + this.checkBoxSyntaxColorTextTooWide.Text = "Text - color if too wide"; + this.checkBoxSyntaxColorTextTooWide.UseVisualStyleBackColor = true; + // + // checkBoxSyntaxColorGapTooSmall + // + this.checkBoxSyntaxColorGapTooSmall.AutoSize = true; + this.checkBoxSyntaxColorGapTooSmall.Location = new System.Drawing.Point(20, 209); + this.checkBoxSyntaxColorGapTooSmall.Name = "checkBoxSyntaxColorGapTooSmall"; + this.checkBoxSyntaxColorGapTooSmall.Size = new System.Drawing.Size(132, 17); + this.checkBoxSyntaxColorGapTooSmall.TabIndex = 7; + this.checkBoxSyntaxColorGapTooSmall.Text = "Gap - color if too small"; + this.checkBoxSyntaxColorGapTooSmall.UseVisualStyleBackColor = true; + // + // checkBoxSyntaxColorTextMoreThanTwoLines + // + this.checkBoxSyntaxColorTextMoreThanTwoLines.AutoSize = true; + this.checkBoxSyntaxColorTextMoreThanTwoLines.Location = new System.Drawing.Point(20, 139); + this.checkBoxSyntaxColorTextMoreThanTwoLines.Name = "checkBoxSyntaxColorTextMoreThanTwoLines"; + this.checkBoxSyntaxColorTextMoreThanTwoLines.Size = new System.Drawing.Size(170, 17); + this.checkBoxSyntaxColorTextMoreThanTwoLines.TabIndex = 5; + this.checkBoxSyntaxColorTextMoreThanTwoLines.Text = "Text - color if more than lines:"; + this.checkBoxSyntaxColorTextMoreThanTwoLines.UseVisualStyleBackColor = true; + // + // checkBoxSyntaxOverlap + // + this.checkBoxSyntaxOverlap.AutoSize = true; + this.checkBoxSyntaxOverlap.Location = new System.Drawing.Point(20, 174); + this.checkBoxSyntaxOverlap.Name = "checkBoxSyntaxOverlap"; + this.checkBoxSyntaxOverlap.Size = new System.Drawing.Size(129, 17); + this.checkBoxSyntaxOverlap.TabIndex = 6; + this.checkBoxSyntaxOverlap.Text = "Time - color if overlap"; + this.checkBoxSyntaxOverlap.UseVisualStyleBackColor = true; + // + // checkBoxSyntaxColorDurationTooSmall + // + this.checkBoxSyntaxColorDurationTooSmall.AutoSize = true; + this.checkBoxSyntaxColorDurationTooSmall.Location = new System.Drawing.Point(20, 35); + this.checkBoxSyntaxColorDurationTooSmall.Name = "checkBoxSyntaxColorDurationTooSmall"; + this.checkBoxSyntaxColorDurationTooSmall.Size = new System.Drawing.Size(154, 17); + this.checkBoxSyntaxColorDurationTooSmall.TabIndex = 0; + this.checkBoxSyntaxColorDurationTooSmall.Text = "Duration - color if too small"; + this.checkBoxSyntaxColorDurationTooSmall.UseVisualStyleBackColor = true; + // + // buttonListViewSyntaxColorError + // + this.buttonListViewSyntaxColorError.Location = new System.Drawing.Point(20, 247); + this.buttonListViewSyntaxColorError.Name = "buttonListViewSyntaxColorError"; + this.buttonListViewSyntaxColorError.Size = new System.Drawing.Size(112, 23); + this.buttonListViewSyntaxColorError.TabIndex = 8; + this.buttonListViewSyntaxColorError.Text = "Error color"; + this.buttonListViewSyntaxColorError.UseVisualStyleBackColor = true; + this.buttonListViewSyntaxColorError.Click += new System.EventHandler(this.buttonListViewSyntaxColorError_Click); + // + // checkBoxSyntaxColorTextTooLong + // + this.checkBoxSyntaxColorTextTooLong.AutoSize = true; + this.checkBoxSyntaxColorTextTooLong.Location = new System.Drawing.Point(20, 93); + this.checkBoxSyntaxColorTextTooLong.Name = "checkBoxSyntaxColorTextTooLong"; + this.checkBoxSyntaxColorTextTooLong.Size = new System.Drawing.Size(132, 17); + this.checkBoxSyntaxColorTextTooLong.TabIndex = 2; + this.checkBoxSyntaxColorTextTooLong.Text = "Text - color if too long"; + this.checkBoxSyntaxColorTextTooLong.UseVisualStyleBackColor = true; + // + // checkBoxSyntaxColorDurationTooLarge + // + this.checkBoxSyntaxColorDurationTooLarge.AutoSize = true; + this.checkBoxSyntaxColorDurationTooLarge.Location = new System.Drawing.Point(20, 58); + this.checkBoxSyntaxColorDurationTooLarge.Name = "checkBoxSyntaxColorDurationTooLarge"; + this.checkBoxSyntaxColorDurationTooLarge.Size = new System.Drawing.Size(155, 17); + this.checkBoxSyntaxColorDurationTooLarge.TabIndex = 1; + this.checkBoxSyntaxColorDurationTooLarge.Text = "Duration - color if too large"; + this.checkBoxSyntaxColorDurationTooLarge.UseVisualStyleBackColor = true; + // + // panelListViewSyntaxColorError + // + this.panelListViewSyntaxColorError.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelListViewSyntaxColorError.Location = new System.Drawing.Point(142, 247); + this.panelListViewSyntaxColorError.Name = "panelListViewSyntaxColorError"; + this.panelListViewSyntaxColorError.Size = new System.Drawing.Size(21, 20); + this.panelListViewSyntaxColorError.TabIndex = 8; + this.panelListViewSyntaxColorError.Click += new System.EventHandler(this.buttonListViewSyntaxColorError_Click); + // + // tabPageVideoPlayer + // + this.tabPageVideoPlayer.Controls.Add(this.groupBoxMainWindowVideoControls); + this.tabPageVideoPlayer.Controls.Add(this.groupBoxVideoPlayerDefault); + this.tabPageVideoPlayer.Controls.Add(this.groupBoxVideoEngine); + this.tabPageVideoPlayer.Location = new System.Drawing.Point(4, 22); + this.tabPageVideoPlayer.Name = "tabPageVideoPlayer"; + this.tabPageVideoPlayer.Padding = new System.Windows.Forms.Padding(3); + this.tabPageVideoPlayer.Size = new System.Drawing.Size(832, 520); + this.tabPageVideoPlayer.TabIndex = 2; + this.tabPageVideoPlayer.Text = "Video player"; + this.tabPageVideoPlayer.UseVisualStyleBackColor = true; + // + // groupBoxMainWindowVideoControls + // + this.groupBoxMainWindowVideoControls.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxMainWindowVideoControls.Controls.Add(this.labelCustomSearch5); + this.groupBoxMainWindowVideoControls.Controls.Add(this.textBoxCustomSearchUrl5); + this.groupBoxMainWindowVideoControls.Controls.Add(this.comboBoxCustomSearch5); + this.groupBoxMainWindowVideoControls.Controls.Add(this.labelCustomSearch4); + this.groupBoxMainWindowVideoControls.Controls.Add(this.textBoxCustomSearchUrl4); + this.groupBoxMainWindowVideoControls.Controls.Add(this.comboBoxCustomSearch4); + this.groupBoxMainWindowVideoControls.Controls.Add(this.labelCustomSearch3); + this.groupBoxMainWindowVideoControls.Controls.Add(this.textBoxCustomSearchUrl3); + this.groupBoxMainWindowVideoControls.Controls.Add(this.comboBoxCustomSearch3); + this.groupBoxMainWindowVideoControls.Controls.Add(this.labelCustomSearch2); + this.groupBoxMainWindowVideoControls.Controls.Add(this.textBoxCustomSearchUrl2); + this.groupBoxMainWindowVideoControls.Controls.Add(this.comboBoxCustomSearch2); + this.groupBoxMainWindowVideoControls.Controls.Add(this.labelCustomSearch1); + this.groupBoxMainWindowVideoControls.Controls.Add(this.textBoxCustomSearchUrl1); + this.groupBoxMainWindowVideoControls.Controls.Add(this.labelCustomSearch); + this.groupBoxMainWindowVideoControls.Controls.Add(this.comboBoxCustomSearch1); + this.groupBoxMainWindowVideoControls.Location = new System.Drawing.Point(7, 281); + this.groupBoxMainWindowVideoControls.Name = "groupBoxMainWindowVideoControls"; + this.groupBoxMainWindowVideoControls.Size = new System.Drawing.Size(819, 233); + this.groupBoxMainWindowVideoControls.TabIndex = 15; + this.groupBoxMainWindowVideoControls.TabStop = false; + this.groupBoxMainWindowVideoControls.Text = "Main window video controls"; + // + // labelCustomSearch5 + // + this.labelCustomSearch5.AutoSize = true; + this.labelCustomSearch5.Location = new System.Drawing.Point(12, 149); + this.labelCustomSearch5.Name = "labelCustomSearch5"; + this.labelCustomSearch5.Size = new System.Drawing.Size(13, 13); + this.labelCustomSearch5.TabIndex = 15; + this.labelCustomSearch5.Text = "5"; + // + // textBoxCustomSearchUrl5 + // + this.textBoxCustomSearchUrl5.Location = new System.Drawing.Point(185, 146); + this.textBoxCustomSearchUrl5.Name = "textBoxCustomSearchUrl5"; + this.textBoxCustomSearchUrl5.Size = new System.Drawing.Size(574, 21); + this.textBoxCustomSearchUrl5.TabIndex = 14; + // + // comboBoxCustomSearch5 + // + this.comboBoxCustomSearch5.FormattingEnabled = true; + this.comboBoxCustomSearch5.Items.AddRange(new object[] { + "Dictionary.com", + "learnersdictionary.com", + "Merriam-Webster", + "The Free Dictionary", + "Thesaurus.com", + "urbandictionary.com", + "VISUWORDS", + "Wikipedia"}); + this.comboBoxCustomSearch5.Location = new System.Drawing.Point(31, 146); + this.comboBoxCustomSearch5.Name = "comboBoxCustomSearch5"; + this.comboBoxCustomSearch5.Size = new System.Drawing.Size(148, 21); + this.comboBoxCustomSearch5.TabIndex = 13; + this.comboBoxCustomSearch5.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustomSearch_SelectedIndexChanged); + // + // labelCustomSearch4 + // + this.labelCustomSearch4.AutoSize = true; + this.labelCustomSearch4.Location = new System.Drawing.Point(12, 122); + this.labelCustomSearch4.Name = "labelCustomSearch4"; + this.labelCustomSearch4.Size = new System.Drawing.Size(13, 13); + this.labelCustomSearch4.TabIndex = 12; + this.labelCustomSearch4.Text = "4"; + // + // textBoxCustomSearchUrl4 + // + this.textBoxCustomSearchUrl4.Location = new System.Drawing.Point(185, 119); + this.textBoxCustomSearchUrl4.Name = "textBoxCustomSearchUrl4"; + this.textBoxCustomSearchUrl4.Size = new System.Drawing.Size(574, 21); + this.textBoxCustomSearchUrl4.TabIndex = 11; + // + // comboBoxCustomSearch4 + // + this.comboBoxCustomSearch4.FormattingEnabled = true; + this.comboBoxCustomSearch4.Items.AddRange(new object[] { + "Dictionary.com", + "learnersdictionary.com", + "Merriam-Webster", + "The Free Dictionary", + "Thesaurus.com", + "urbandictionary.com", + "VISUWORDS", + "Wikipedia"}); + this.comboBoxCustomSearch4.Location = new System.Drawing.Point(31, 119); + this.comboBoxCustomSearch4.Name = "comboBoxCustomSearch4"; + this.comboBoxCustomSearch4.Size = new System.Drawing.Size(148, 21); + this.comboBoxCustomSearch4.TabIndex = 10; + this.comboBoxCustomSearch4.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustomSearch_SelectedIndexChanged); + // + // labelCustomSearch3 + // + this.labelCustomSearch3.AutoSize = true; + this.labelCustomSearch3.Location = new System.Drawing.Point(12, 95); + this.labelCustomSearch3.Name = "labelCustomSearch3"; + this.labelCustomSearch3.Size = new System.Drawing.Size(13, 13); + this.labelCustomSearch3.TabIndex = 9; + this.labelCustomSearch3.Text = "3"; + // + // textBoxCustomSearchUrl3 + // + this.textBoxCustomSearchUrl3.Location = new System.Drawing.Point(185, 92); + this.textBoxCustomSearchUrl3.Name = "textBoxCustomSearchUrl3"; + this.textBoxCustomSearchUrl3.Size = new System.Drawing.Size(574, 21); + this.textBoxCustomSearchUrl3.TabIndex = 8; + // + // comboBoxCustomSearch3 + // + this.comboBoxCustomSearch3.FormattingEnabled = true; + this.comboBoxCustomSearch3.Items.AddRange(new object[] { + "Dictionary.com", + "learnersdictionary.com", + "Merriam-Webster", + "The Free Dictionary", + "Thesaurus.com", + "urbandictionary.com", + "VISUWORDS", + "Wikipedia"}); + this.comboBoxCustomSearch3.Location = new System.Drawing.Point(31, 92); + this.comboBoxCustomSearch3.Name = "comboBoxCustomSearch3"; + this.comboBoxCustomSearch3.Size = new System.Drawing.Size(148, 21); + this.comboBoxCustomSearch3.TabIndex = 7; + this.comboBoxCustomSearch3.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustomSearch_SelectedIndexChanged); + // + // labelCustomSearch2 + // + this.labelCustomSearch2.AutoSize = true; + this.labelCustomSearch2.Location = new System.Drawing.Point(12, 68); + this.labelCustomSearch2.Name = "labelCustomSearch2"; + this.labelCustomSearch2.Size = new System.Drawing.Size(13, 13); + this.labelCustomSearch2.TabIndex = 6; + this.labelCustomSearch2.Text = "2"; + // + // textBoxCustomSearchUrl2 + // + this.textBoxCustomSearchUrl2.Location = new System.Drawing.Point(185, 65); + this.textBoxCustomSearchUrl2.Name = "textBoxCustomSearchUrl2"; + this.textBoxCustomSearchUrl2.Size = new System.Drawing.Size(574, 21); + this.textBoxCustomSearchUrl2.TabIndex = 5; + // + // comboBoxCustomSearch2 + // + this.comboBoxCustomSearch2.FormattingEnabled = true; + this.comboBoxCustomSearch2.Items.AddRange(new object[] { + "Dictionary.com", + "learnersdictionary.com", + "Merriam-Webster", + "The Free Dictionary", + "Thesaurus.com", + "urbandictionary.com", + "VISUWORDS", + "Wikipedia"}); + this.comboBoxCustomSearch2.Location = new System.Drawing.Point(31, 65); + this.comboBoxCustomSearch2.Name = "comboBoxCustomSearch2"; + this.comboBoxCustomSearch2.Size = new System.Drawing.Size(148, 21); + this.comboBoxCustomSearch2.TabIndex = 4; + this.comboBoxCustomSearch2.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustomSearch_SelectedIndexChanged); + // + // labelCustomSearch1 + // + this.labelCustomSearch1.AutoSize = true; + this.labelCustomSearch1.Location = new System.Drawing.Point(12, 41); + this.labelCustomSearch1.Name = "labelCustomSearch1"; + this.labelCustomSearch1.Size = new System.Drawing.Size(13, 13); + this.labelCustomSearch1.TabIndex = 3; + this.labelCustomSearch1.Text = "1"; + // + // textBoxCustomSearchUrl1 + // + this.textBoxCustomSearchUrl1.Location = new System.Drawing.Point(185, 38); + this.textBoxCustomSearchUrl1.Name = "textBoxCustomSearchUrl1"; + this.textBoxCustomSearchUrl1.Size = new System.Drawing.Size(574, 21); + this.textBoxCustomSearchUrl1.TabIndex = 2; + // + // labelCustomSearch + // + this.labelCustomSearch.AutoSize = true; + this.labelCustomSearch.Location = new System.Drawing.Point(12, 20); + this.labelCustomSearch.Name = "labelCustomSearch"; + this.labelCustomSearch.Size = new System.Drawing.Size(144, 13); + this.labelCustomSearch.TabIndex = 1; + this.labelCustomSearch.Text = "Custom search text and URL"; + // + // comboBoxCustomSearch1 + // + this.comboBoxCustomSearch1.FormattingEnabled = true; + this.comboBoxCustomSearch1.Items.AddRange(new object[] { + "Dictionary.com", + "learnersdictionary.com", + "Merriam-Webster", + "The Free Dictionary", + "Thesaurus.com", + "urbandictionary.com", + "VISUWORDS", + "Wikipedia"}); + this.comboBoxCustomSearch1.Location = new System.Drawing.Point(31, 38); + this.comboBoxCustomSearch1.Name = "comboBoxCustomSearch1"; + this.comboBoxCustomSearch1.Size = new System.Drawing.Size(148, 21); + this.comboBoxCustomSearch1.TabIndex = 0; + this.comboBoxCustomSearch1.SelectedIndexChanged += new System.EventHandler(this.comboBoxCustomSearch_SelectedIndexChanged); + // + // groupBoxVideoPlayerDefault + // + this.groupBoxVideoPlayerDefault.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxVideoPlayerDefault.Controls.Add(this.checkBoxAllowVolumeBoost); + this.groupBoxVideoPlayerDefault.Controls.Add(this.checkBoxVideoAutoOpen); + this.groupBoxVideoPlayerDefault.Controls.Add(this.checkBoxVideoPlayerPreviewFontBold); + this.groupBoxVideoPlayerDefault.Controls.Add(this.checkBoxVideoPlayerShowFullscreenButton); + this.groupBoxVideoPlayerDefault.Controls.Add(this.checkBoxVideoPlayerShowMuteButton); + this.groupBoxVideoPlayerDefault.Controls.Add(this.labelVideoPlayerPreviewFontSize); + this.groupBoxVideoPlayerDefault.Controls.Add(this.comboBoxlVideoPlayerPreviewFontSize); + this.groupBoxVideoPlayerDefault.Controls.Add(this.checkBoxVideoPlayerShowStopButton); + this.groupBoxVideoPlayerDefault.Location = new System.Drawing.Point(7, 155); + this.groupBoxVideoPlayerDefault.Name = "groupBoxVideoPlayerDefault"; + this.groupBoxVideoPlayerDefault.Size = new System.Drawing.Size(819, 120); + this.groupBoxVideoPlayerDefault.TabIndex = 14; + this.groupBoxVideoPlayerDefault.TabStop = false; + // + // checkBoxAllowVolumeBoost + // + this.checkBoxAllowVolumeBoost.AutoSize = true; + this.checkBoxAllowVolumeBoost.Location = new System.Drawing.Point(334, 97); + this.checkBoxAllowVolumeBoost.Name = "checkBoxAllowVolumeBoost"; + this.checkBoxAllowVolumeBoost.Size = new System.Drawing.Size(118, 17); + this.checkBoxAllowVolumeBoost.TabIndex = 25; + this.checkBoxAllowVolumeBoost.Text = "Allow volume boost"; + this.checkBoxAllowVolumeBoost.UseVisualStyleBackColor = true; + // + // checkBoxVideoAutoOpen + // + this.checkBoxVideoAutoOpen.AutoSize = true; + this.checkBoxVideoAutoOpen.Location = new System.Drawing.Point(334, 74); + this.checkBoxVideoAutoOpen.Name = "checkBoxVideoAutoOpen"; + this.checkBoxVideoAutoOpen.Size = new System.Drawing.Size(213, 17); + this.checkBoxVideoAutoOpen.TabIndex = 24; + this.checkBoxVideoAutoOpen.Text = "Auto open video when opening subtitle"; + this.checkBoxVideoAutoOpen.UseVisualStyleBackColor = true; + // + // checkBoxVideoPlayerPreviewFontBold + // + this.checkBoxVideoPlayerPreviewFontBold.AutoSize = true; + this.checkBoxVideoPlayerPreviewFontBold.Location = new System.Drawing.Point(465, 45); + this.checkBoxVideoPlayerPreviewFontBold.Name = "checkBoxVideoPlayerPreviewFontBold"; + this.checkBoxVideoPlayerPreviewFontBold.Size = new System.Drawing.Size(46, 17); + this.checkBoxVideoPlayerPreviewFontBold.TabIndex = 23; + this.checkBoxVideoPlayerPreviewFontBold.Text = "Bold"; + this.checkBoxVideoPlayerPreviewFontBold.UseVisualStyleBackColor = true; + // + // checkBoxVideoPlayerShowFullscreenButton + // + this.checkBoxVideoPlayerShowFullscreenButton.AutoSize = true; + this.checkBoxVideoPlayerShowFullscreenButton.Location = new System.Drawing.Point(9, 65); + this.checkBoxVideoPlayerShowFullscreenButton.Name = "checkBoxVideoPlayerShowFullscreenButton"; + this.checkBoxVideoPlayerShowFullscreenButton.Size = new System.Drawing.Size(136, 17); + this.checkBoxVideoPlayerShowFullscreenButton.TabIndex = 12; + this.checkBoxVideoPlayerShowFullscreenButton.Text = "Show fullscreen button"; + this.checkBoxVideoPlayerShowFullscreenButton.UseVisualStyleBackColor = true; + // + // checkBoxVideoPlayerShowMuteButton + // + this.checkBoxVideoPlayerShowMuteButton.AutoSize = true; + this.checkBoxVideoPlayerShowMuteButton.Location = new System.Drawing.Point(9, 42); + this.checkBoxVideoPlayerShowMuteButton.Name = "checkBoxVideoPlayerShowMuteButton"; + this.checkBoxVideoPlayerShowMuteButton.Size = new System.Drawing.Size(114, 17); + this.checkBoxVideoPlayerShowMuteButton.TabIndex = 11; + this.checkBoxVideoPlayerShowMuteButton.Text = "Show mute button"; + this.checkBoxVideoPlayerShowMuteButton.UseVisualStyleBackColor = true; + // + // labelVideoPlayerPreviewFontSize + // + this.labelVideoPlayerPreviewFontSize.AutoSize = true; + this.labelVideoPlayerPreviewFontSize.Location = new System.Drawing.Point(331, 21); + this.labelVideoPlayerPreviewFontSize.Name = "labelVideoPlayerPreviewFontSize"; + this.labelVideoPlayerPreviewFontSize.Size = new System.Drawing.Size(128, 13); + this.labelVideoPlayerPreviewFontSize.TabIndex = 14; + this.labelVideoPlayerPreviewFontSize.Text = "Subtitle preview font size"; + // + // comboBoxlVideoPlayerPreviewFontSize + // + this.comboBoxlVideoPlayerPreviewFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxlVideoPlayerPreviewFontSize.FormattingEnabled = true; + this.comboBoxlVideoPlayerPreviewFontSize.Items.AddRange(new object[] { + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17", + "18", + "19", + "20", + "21", + "22", + "23", + "24", + "25", + "26", + "27", + "28", + "29", + "30"}); + this.comboBoxlVideoPlayerPreviewFontSize.Location = new System.Drawing.Point(465, 18); + this.comboBoxlVideoPlayerPreviewFontSize.Name = "comboBoxlVideoPlayerPreviewFontSize"; + this.comboBoxlVideoPlayerPreviewFontSize.Size = new System.Drawing.Size(121, 21); + this.comboBoxlVideoPlayerPreviewFontSize.TabIndex = 13; + // + // checkBoxVideoPlayerShowStopButton + // + this.checkBoxVideoPlayerShowStopButton.AutoSize = true; + this.checkBoxVideoPlayerShowStopButton.Location = new System.Drawing.Point(9, 19); + this.checkBoxVideoPlayerShowStopButton.Name = "checkBoxVideoPlayerShowStopButton"; + this.checkBoxVideoPlayerShowStopButton.Size = new System.Drawing.Size(111, 17); + this.checkBoxVideoPlayerShowStopButton.TabIndex = 10; + this.checkBoxVideoPlayerShowStopButton.Text = "Show stop button"; + this.checkBoxVideoPlayerShowStopButton.UseVisualStyleBackColor = true; + // + // groupBoxVideoEngine + // + this.groupBoxVideoEngine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxVideoEngine.Controls.Add(this.checkBoxMpvHandlesPreviewText); + this.groupBoxVideoEngine.Controls.Add(this.labelMpvSettings); + this.groupBoxVideoEngine.Controls.Add(this.buttonMpvSettings); + this.groupBoxVideoEngine.Controls.Add(this.labelPlatform); + this.groupBoxVideoEngine.Controls.Add(this.buttonVlcPathBrowse); + this.groupBoxVideoEngine.Controls.Add(this.textBoxVlcPath); + this.groupBoxVideoEngine.Controls.Add(this.labelVlcPath); + this.groupBoxVideoEngine.Controls.Add(this.labelVideoPlayerVLC); + this.groupBoxVideoEngine.Controls.Add(this.radioButtonVideoPlayerVLC); + this.groupBoxVideoEngine.Controls.Add(this.labelVideoPlayerMPlayer); + this.groupBoxVideoEngine.Controls.Add(this.labelDirectShowDescription); + this.groupBoxVideoEngine.Controls.Add(this.labelMpcHcDescription); + this.groupBoxVideoEngine.Controls.Add(this.radioButtonVideoPlayerMPV); + this.groupBoxVideoEngine.Controls.Add(this.radioButtonVideoPlayerDirectShow); + this.groupBoxVideoEngine.Controls.Add(this.radioButtonVideoPlayerMpcHc); + this.groupBoxVideoEngine.Location = new System.Drawing.Point(6, 6); + this.groupBoxVideoEngine.Name = "groupBoxVideoEngine"; + this.groupBoxVideoEngine.Size = new System.Drawing.Size(820, 143); + this.groupBoxVideoEngine.TabIndex = 0; + this.groupBoxVideoEngine.TabStop = false; + this.groupBoxVideoEngine.Text = "Video engine"; + // + // checkBoxMpvHandlesPreviewText + // + this.checkBoxMpvHandlesPreviewText.AutoSize = true; + this.checkBoxMpvHandlesPreviewText.Location = new System.Drawing.Point(169, 111); + this.checkBoxMpvHandlesPreviewText.Name = "checkBoxMpvHandlesPreviewText"; + this.checkBoxMpvHandlesPreviewText.Size = new System.Drawing.Size(150, 17); + this.checkBoxMpvHandlesPreviewText.TabIndex = 31; + this.checkBoxMpvHandlesPreviewText.Text = "mpv handles preview text"; + this.checkBoxMpvHandlesPreviewText.UseVisualStyleBackColor = true; + // + // labelMpvSettings + // + this.labelMpvSettings.AutoSize = true; + this.labelMpvSettings.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelMpvSettings.ForeColor = System.Drawing.Color.Gray; + this.labelMpvSettings.Location = new System.Drawing.Point(709, 93); + this.labelMpvSettings.Name = "labelMpvSettings"; + this.labelMpvSettings.Size = new System.Drawing.Size(40, 13); + this.labelMpvSettings.TabIndex = 30; + this.labelMpvSettings.Text = "--vo=?"; + // + // buttonMpvSettings + // + this.buttonMpvSettings.Location = new System.Drawing.Point(510, 89); + this.buttonMpvSettings.Name = "buttonMpvSettings"; + this.buttonMpvSettings.Size = new System.Drawing.Size(179, 23); + this.buttonMpvSettings.TabIndex = 29; + this.buttonMpvSettings.Text = "Download mpv dll"; + this.buttonMpvSettings.UseVisualStyleBackColor = true; + this.buttonMpvSettings.Click += new System.EventHandler(this.buttonMpvSettings_Click); + // + // labelPlatform + // + this.labelPlatform.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelPlatform.ForeColor = System.Drawing.Color.Gray; + this.labelPlatform.Location = new System.Drawing.Point(724, 13); + this.labelPlatform.Name = "labelPlatform"; + this.labelPlatform.Size = new System.Drawing.Size(83, 11); + this.labelPlatform.TabIndex = 27; + this.labelPlatform.Text = "x-bit"; + this.labelPlatform.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // buttonVlcPathBrowse + // + this.buttonVlcPathBrowse.Location = new System.Drawing.Point(778, 44); + this.buttonVlcPathBrowse.Name = "buttonVlcPathBrowse"; + this.buttonVlcPathBrowse.Size = new System.Drawing.Size(29, 21); + this.buttonVlcPathBrowse.TabIndex = 26; + this.buttonVlcPathBrowse.Text = "..."; + this.buttonVlcPathBrowse.UseVisualStyleBackColor = true; + this.buttonVlcPathBrowse.Click += new System.EventHandler(this.buttonVlcPathBrowse_Click); + // + // textBoxVlcPath + // + this.textBoxVlcPath.Location = new System.Drawing.Point(410, 45); + this.textBoxVlcPath.MaxLength = 1000; + this.textBoxVlcPath.Name = "textBoxVlcPath"; + this.textBoxVlcPath.Size = new System.Drawing.Size(362, 21); + this.textBoxVlcPath.TabIndex = 25; + this.textBoxVlcPath.MouseLeave += new System.EventHandler(this.textBoxVlcPath_MouseLeave); + // + // labelVlcPath + // + this.labelVlcPath.AutoSize = true; + this.labelVlcPath.Location = new System.Drawing.Point(379, 29); + this.labelVlcPath.Name = "labelVlcPath"; + this.labelVlcPath.Size = new System.Drawing.Size(315, 13); + this.labelVlcPath.TabIndex = 24; + this.labelVlcPath.Text = "VLC path (only needed if you using the portable version of VLC)"; + // + // labelVideoPlayerVLC + // + this.labelVideoPlayerVLC.AutoSize = true; + this.labelVideoPlayerVLC.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelVideoPlayerVLC.ForeColor = System.Drawing.Color.Gray; + this.labelVideoPlayerVLC.Location = new System.Drawing.Point(167, 49); + this.labelVideoPlayerVLC.Name = "labelVideoPlayerVLC"; + this.labelVideoPlayerVLC.Size = new System.Drawing.Size(237, 13); + this.labelVideoPlayerVLC.TabIndex = 13; + this.labelVideoPlayerVLC.Text = "libvlc.dll from VLC media player (1.1.0 or newer)"; + // + // radioButtonVideoPlayerVLC + // + this.radioButtonVideoPlayerVLC.AutoSize = true; + this.radioButtonVideoPlayerVLC.Location = new System.Drawing.Point(10, 46); + this.radioButtonVideoPlayerVLC.Name = "radioButtonVideoPlayerVLC"; + this.radioButtonVideoPlayerVLC.Size = new System.Drawing.Size(43, 17); + this.radioButtonVideoPlayerVLC.TabIndex = 4; + this.radioButtonVideoPlayerVLC.TabStop = true; + this.radioButtonVideoPlayerVLC.Text = "VLC"; + this.radioButtonVideoPlayerVLC.UseVisualStyleBackColor = true; + // + // labelVideoPlayerMPlayer + // + this.labelVideoPlayerMPlayer.AutoSize = true; + this.labelVideoPlayerMPlayer.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelVideoPlayerMPlayer.ForeColor = System.Drawing.Color.Gray; + this.labelVideoPlayerMPlayer.Location = new System.Drawing.Point(167, 93); + this.labelVideoPlayerMPlayer.Name = "labelVideoPlayerMPlayer"; + this.labelVideoPlayerMPlayer.Size = new System.Drawing.Size(337, 13); + this.labelVideoPlayerMPlayer.TabIndex = 11; + this.labelVideoPlayerMPlayer.Text = "https://mpv.io/ - free, open source, and cross-platform media player"; + // + // labelDirectShowDescription + // + this.labelDirectShowDescription.AutoSize = true; + this.labelDirectShowDescription.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelDirectShowDescription.ForeColor = System.Drawing.Color.Gray; + this.labelDirectShowDescription.Location = new System.Drawing.Point(167, 26); + this.labelDirectShowDescription.Name = "labelDirectShowDescription"; + this.labelDirectShowDescription.Size = new System.Drawing.Size(114, 13); + this.labelDirectShowDescription.TabIndex = 10; + this.labelDirectShowDescription.Text = "Quartz.dll in system32"; + // + // labelMpcHcDescription + // + this.labelMpcHcDescription.AutoSize = true; + this.labelMpcHcDescription.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelMpcHcDescription.ForeColor = System.Drawing.Color.Gray; + this.labelMpcHcDescription.Location = new System.Drawing.Point(167, 70); + this.labelMpcHcDescription.Name = "labelMpcHcDescription"; + this.labelMpcHcDescription.Size = new System.Drawing.Size(178, 13); + this.labelMpcHcDescription.TabIndex = 9; + this.labelMpcHcDescription.Text = "Media Player Classic - Home Cinema"; + // + // radioButtonVideoPlayerMPV + // + this.radioButtonVideoPlayerMPV.AutoSize = true; + this.radioButtonVideoPlayerMPV.Location = new System.Drawing.Point(10, 89); + this.radioButtonVideoPlayerMPV.Name = "radioButtonVideoPlayerMPV"; + this.radioButtonVideoPlayerMPV.Size = new System.Drawing.Size(45, 17); + this.radioButtonVideoPlayerMPV.TabIndex = 28; + this.radioButtonVideoPlayerMPV.TabStop = true; + this.radioButtonVideoPlayerMPV.Text = "mpv"; + this.radioButtonVideoPlayerMPV.UseVisualStyleBackColor = true; + this.radioButtonVideoPlayerMPV.CheckedChanged += new System.EventHandler(this.radioButtonVideoPlayerMPV_CheckedChanged); + // + // radioButtonVideoPlayerDirectShow + // + this.radioButtonVideoPlayerDirectShow.AutoSize = true; + this.radioButtonVideoPlayerDirectShow.Location = new System.Drawing.Point(10, 23); + this.radioButtonVideoPlayerDirectShow.Name = "radioButtonVideoPlayerDirectShow"; + this.radioButtonVideoPlayerDirectShow.Size = new System.Drawing.Size(82, 17); + this.radioButtonVideoPlayerDirectShow.TabIndex = 1; + this.radioButtonVideoPlayerDirectShow.TabStop = true; + this.radioButtonVideoPlayerDirectShow.Text = "DirectShow "; + this.radioButtonVideoPlayerDirectShow.UseVisualStyleBackColor = true; + // + // radioButtonVideoPlayerMpcHc + // + this.radioButtonVideoPlayerMpcHc.AutoSize = true; + this.radioButtonVideoPlayerMpcHc.Location = new System.Drawing.Point(10, 66); + this.radioButtonVideoPlayerMpcHc.Name = "radioButtonVideoPlayerMpcHc"; + this.radioButtonVideoPlayerMpcHc.Size = new System.Drawing.Size(64, 17); + this.radioButtonVideoPlayerMpcHc.TabIndex = 27; + this.radioButtonVideoPlayerMpcHc.TabStop = true; + this.radioButtonVideoPlayerMpcHc.Text = "MPC-HC"; + this.radioButtonVideoPlayerMpcHc.UseVisualStyleBackColor = true; + // + // tabPageWaveform + // + this.tabPageWaveform.Controls.Add(this.groupBoxFfmpeg); + this.tabPageWaveform.Controls.Add(this.groupBoxSpectrogram); + this.tabPageWaveform.Controls.Add(this.groupBox1); + this.tabPageWaveform.Controls.Add(this.groupBoxWaveformAppearence); + this.tabPageWaveform.Location = new System.Drawing.Point(4, 22); + this.tabPageWaveform.Name = "tabPageWaveform"; + this.tabPageWaveform.Size = new System.Drawing.Size(832, 520); + this.tabPageWaveform.TabIndex = 6; + this.tabPageWaveform.Text = "Waveform/spectrogram"; + this.tabPageWaveform.UseVisualStyleBackColor = true; + // + // groupBoxFfmpeg + // + this.groupBoxFfmpeg.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFfmpeg.Controls.Add(this.buttonDownloadFfmpeg); + this.groupBoxFfmpeg.Controls.Add(this.buttonBrowseToFFmpeg); + this.groupBoxFfmpeg.Controls.Add(this.textBoxFFmpegPath); + this.groupBoxFfmpeg.Controls.Add(this.labelFFmpegPath); + this.groupBoxFfmpeg.Controls.Add(this.checkBoxUseFFmpeg); + this.groupBoxFfmpeg.Location = new System.Drawing.Point(406, 299); + this.groupBoxFfmpeg.Name = "groupBoxFfmpeg"; + this.groupBoxFfmpeg.Size = new System.Drawing.Size(419, 118); + this.groupBoxFfmpeg.TabIndex = 2; + this.groupBoxFfmpeg.TabStop = false; + this.groupBoxFfmpeg.Text = "FFmpeg"; + // + // buttonDownloadFfmpeg + // + this.buttonDownloadFfmpeg.Location = new System.Drawing.Point(274, 17); + this.buttonDownloadFfmpeg.Name = "buttonDownloadFfmpeg"; + this.buttonDownloadFfmpeg.Size = new System.Drawing.Size(136, 23); + this.buttonDownloadFfmpeg.TabIndex = 2; + this.buttonDownloadFfmpeg.Text = "Download ffmpeg"; + this.buttonDownloadFfmpeg.UseVisualStyleBackColor = true; + this.buttonDownloadFfmpeg.Click += new System.EventHandler(this.buttonDownloadFfmpeg_Click); + // + // buttonBrowseToFFmpeg + // + this.buttonBrowseToFFmpeg.Location = new System.Drawing.Point(381, 65); + this.buttonBrowseToFFmpeg.Name = "buttonBrowseToFFmpeg"; + this.buttonBrowseToFFmpeg.Size = new System.Drawing.Size(29, 21); + this.buttonBrowseToFFmpeg.TabIndex = 23; + this.buttonBrowseToFFmpeg.Text = "..."; + this.buttonBrowseToFFmpeg.UseVisualStyleBackColor = true; + this.buttonBrowseToFFmpeg.Click += new System.EventHandler(this.buttonBrowseToFFmpeg_Click); + // + // textBoxFFmpegPath + // + this.textBoxFFmpegPath.Location = new System.Drawing.Point(9, 65); + this.textBoxFFmpegPath.MaxLength = 1000; + this.textBoxFFmpegPath.Name = "textBoxFFmpegPath"; + this.textBoxFFmpegPath.Size = new System.Drawing.Size(366, 21); + this.textBoxFFmpegPath.TabIndex = 22; + // + // labelFFmpegPath + // + this.labelFFmpegPath.AutoSize = true; + this.labelFFmpegPath.Location = new System.Drawing.Point(6, 49); + this.labelFFmpegPath.Name = "labelFFmpegPath"; + this.labelFFmpegPath.Size = new System.Drawing.Size(70, 13); + this.labelFFmpegPath.TabIndex = 2; + this.labelFFmpegPath.Text = "FFmpeg path"; + // + // checkBoxUseFFmpeg + // + this.checkBoxUseFFmpeg.AutoSize = true; + this.checkBoxUseFFmpeg.Location = new System.Drawing.Point(6, 20); + this.checkBoxUseFFmpeg.Name = "checkBoxUseFFmpeg"; + this.checkBoxUseFFmpeg.Size = new System.Drawing.Size(200, 17); + this.checkBoxUseFFmpeg.TabIndex = 1; + this.checkBoxUseFFmpeg.Text = "Use FFmpeg for wave file extraction"; + this.checkBoxUseFFmpeg.UseVisualStyleBackColor = true; + // + // groupBoxSpectrogram + // + this.groupBoxSpectrogram.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxSpectrogram.Controls.Add(this.labelSpectrogramAppearance); + this.groupBoxSpectrogram.Controls.Add(this.comboBoxSpectrogramAppearance); + this.groupBoxSpectrogram.Controls.Add(this.checkBoxGenerateSpectrogram); + this.groupBoxSpectrogram.Location = new System.Drawing.Point(6, 299); + this.groupBoxSpectrogram.Name = "groupBoxSpectrogram"; + this.groupBoxSpectrogram.Size = new System.Drawing.Size(394, 118); + this.groupBoxSpectrogram.TabIndex = 1; + this.groupBoxSpectrogram.TabStop = false; + this.groupBoxSpectrogram.Text = "Spectrogram"; + // + // labelSpectrogramAppearance + // + this.labelSpectrogramAppearance.AutoSize = true; + this.labelSpectrogramAppearance.Location = new System.Drawing.Point(10, 52); + this.labelSpectrogramAppearance.Name = "labelSpectrogramAppearance"; + this.labelSpectrogramAppearance.Size = new System.Drawing.Size(164, 13); + this.labelSpectrogramAppearance.TabIndex = 1; + this.labelSpectrogramAppearance.Text = "Appearance (at generation time)"; + // + // comboBoxSpectrogramAppearance + // + this.comboBoxSpectrogramAppearance.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSpectrogramAppearance.FormattingEnabled = true; + this.comboBoxSpectrogramAppearance.Items.AddRange(new object[] { + "Classic", + "Use waveform color (one color gradient)"}); + this.comboBoxSpectrogramAppearance.Location = new System.Drawing.Point(10, 70); + this.comboBoxSpectrogramAppearance.Name = "comboBoxSpectrogramAppearance"; + this.comboBoxSpectrogramAppearance.Size = new System.Drawing.Size(325, 21); + this.comboBoxSpectrogramAppearance.TabIndex = 2; + // + // checkBoxGenerateSpectrogram + // + this.checkBoxGenerateSpectrogram.AutoSize = true; + this.checkBoxGenerateSpectrogram.Location = new System.Drawing.Point(10, 20); + this.checkBoxGenerateSpectrogram.Name = "checkBoxGenerateSpectrogram"; + this.checkBoxGenerateSpectrogram.Size = new System.Drawing.Size(134, 17); + this.checkBoxGenerateSpectrogram.TabIndex = 0; + this.checkBoxGenerateSpectrogram.Text = "Generate spectrogram"; + this.checkBoxGenerateSpectrogram.UseVisualStyleBackColor = true; + // + // groupBox1 + // + this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.groupBox1.Controls.Add(this.buttonWaveformsFolderEmpty); + this.groupBox1.Controls.Add(this.labelWaveformsFolderInfo); + this.groupBox1.Location = new System.Drawing.Point(10, 423); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(819, 80); + this.groupBox1.TabIndex = 3; + this.groupBox1.TabStop = false; + // + // buttonWaveformsFolderEmpty + // + this.buttonWaveformsFolderEmpty.Location = new System.Drawing.Point(10, 37); + this.buttonWaveformsFolderEmpty.Name = "buttonWaveformsFolderEmpty"; + this.buttonWaveformsFolderEmpty.Size = new System.Drawing.Size(325, 23); + this.buttonWaveformsFolderEmpty.TabIndex = 1; + this.buttonWaveformsFolderEmpty.Text = "Empty \'Waveforms\' folder"; + this.buttonWaveformsFolderEmpty.UseVisualStyleBackColor = true; + this.buttonWaveformsFolderEmpty.Click += new System.EventHandler(this.buttonWaveformsFolderEmpty_Click); + // + // labelWaveformsFolderInfo + // + this.labelWaveformsFolderInfo.AutoSize = true; + this.labelWaveformsFolderInfo.Location = new System.Drawing.Point(10, 20); + this.labelWaveformsFolderInfo.Name = "labelWaveformsFolderInfo"; + this.labelWaveformsFolderInfo.Size = new System.Drawing.Size(205, 13); + this.labelWaveformsFolderInfo.TabIndex = 0; + this.labelWaveformsFolderInfo.Text = "\'Waveforms\' folder contains x files (x mb)"; + // + // groupBoxWaveformAppearence + // + this.groupBoxWaveformAppearence.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxWaveformAppearence.Controls.Add(this.panelWaveformCursorColor); + this.groupBoxWaveformAppearence.Controls.Add(this.buttonWaveformCursorColor); + this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformSnapToSceneChanges); + this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformSingleClickSelect); + this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformShowWpm); + this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformShowCps); + this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformSetVideoPosMoveStartEnd); + this.groupBoxWaveformAppearence.Controls.Add(this.labelWaveformTextSize); + this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformTextBold); + this.groupBoxWaveformAppearence.Controls.Add(this.comboBoxWaveformTextSize); + this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxListViewMouseEnterFocus); + this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformHoverFocus); + this.groupBoxWaveformAppearence.Controls.Add(this.labelWaveformBorderHitMs2); + this.groupBoxWaveformAppearence.Controls.Add(this.numericUpDownWaveformBorderHitMs); + this.groupBoxWaveformAppearence.Controls.Add(this.labelWaveformBorderHitMs1); + this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxAllowOverlap); + this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxReverseMouseWheelScrollDirection); + this.groupBoxWaveformAppearence.Controls.Add(this.panelWaveformTextColor); + this.groupBoxWaveformAppearence.Controls.Add(this.buttonWaveformTextColor); + this.groupBoxWaveformAppearence.Controls.Add(this.panelWaveformGridColor); + this.groupBoxWaveformAppearence.Controls.Add(this.buttonWaveformGridColor); + this.groupBoxWaveformAppearence.Controls.Add(this.panelWaveformBackgroundColor); + this.groupBoxWaveformAppearence.Controls.Add(this.buttonWaveformBackgroundColor); + this.groupBoxWaveformAppearence.Controls.Add(this.panelWaveformColor); + this.groupBoxWaveformAppearence.Controls.Add(this.buttonWaveformColor); + this.groupBoxWaveformAppearence.Controls.Add(this.panelWaveformSelectedColor); + this.groupBoxWaveformAppearence.Controls.Add(this.buttonWaveformSelectedColor); + this.groupBoxWaveformAppearence.Controls.Add(this.checkBoxWaveformShowGrid); + this.groupBoxWaveformAppearence.Location = new System.Drawing.Point(6, 6); + this.groupBoxWaveformAppearence.Name = "groupBoxWaveformAppearence"; + this.groupBoxWaveformAppearence.Size = new System.Drawing.Size(819, 287); + this.groupBoxWaveformAppearence.TabIndex = 0; + this.groupBoxWaveformAppearence.TabStop = false; + this.groupBoxWaveformAppearence.Text = "Waveform appearance"; + // + // panelWaveformCursorColor + // + this.panelWaveformCursorColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelWaveformCursorColor.Location = new System.Drawing.Point(138, 142); + this.panelWaveformCursorColor.Name = "panelWaveformCursorColor"; + this.panelWaveformCursorColor.Size = new System.Drawing.Size(21, 20); + this.panelWaveformCursorColor.TabIndex = 34; + this.panelWaveformCursorColor.Click += new System.EventHandler(this.buttonWaveformCursorColor_Click); + // + // buttonWaveformCursorColor + // + this.buttonWaveformCursorColor.Location = new System.Drawing.Point(14, 141); + this.buttonWaveformCursorColor.Name = "buttonWaveformCursorColor"; + this.buttonWaveformCursorColor.Size = new System.Drawing.Size(112, 23); + this.buttonWaveformCursorColor.TabIndex = 4; + this.buttonWaveformCursorColor.Text = "Cursor color"; + this.buttonWaveformCursorColor.UseVisualStyleBackColor = true; + this.buttonWaveformCursorColor.Click += new System.EventHandler(this.buttonWaveformCursorColor_Click); + // + // checkBoxWaveformSnapToSceneChanges + // + this.checkBoxWaveformSnapToSceneChanges.AutoSize = true; + this.checkBoxWaveformSnapToSceneChanges.Location = new System.Drawing.Point(262, 161); + this.checkBoxWaveformSnapToSceneChanges.Name = "checkBoxWaveformSnapToSceneChanges"; + this.checkBoxWaveformSnapToSceneChanges.Size = new System.Drawing.Size(249, 17); + this.checkBoxWaveformSnapToSceneChanges.TabIndex = 26; + this.checkBoxWaveformSnapToSceneChanges.Text = "Snap to scene changes (hold Shift to override)"; + this.checkBoxWaveformSnapToSceneChanges.UseVisualStyleBackColor = true; + // + // checkBoxWaveformSingleClickSelect + // + this.checkBoxWaveformSingleClickSelect.AutoSize = true; + this.checkBoxWaveformSingleClickSelect.Location = new System.Drawing.Point(262, 138); + this.checkBoxWaveformSingleClickSelect.Name = "checkBoxWaveformSingleClickSelect"; + this.checkBoxWaveformSingleClickSelect.Size = new System.Drawing.Size(178, 17); + this.checkBoxWaveformSingleClickSelect.TabIndex = 25; + this.checkBoxWaveformSingleClickSelect.Text = "Single click to select paragraphs"; + this.checkBoxWaveformSingleClickSelect.UseVisualStyleBackColor = true; + // + // checkBoxWaveformShowWpm + // + this.checkBoxWaveformShowWpm.AutoSize = true; + this.checkBoxWaveformShowWpm.Location = new System.Drawing.Point(16, 256); + this.checkBoxWaveformShowWpm.Name = "checkBoxWaveformShowWpm"; + this.checkBoxWaveformShowWpm.Size = new System.Drawing.Size(104, 17); + this.checkBoxWaveformShowWpm.TabIndex = 8; + this.checkBoxWaveformShowWpm.Text = "Show words/min"; + this.checkBoxWaveformShowWpm.UseVisualStyleBackColor = true; + // + // checkBoxWaveformShowCps + // + this.checkBoxWaveformShowCps.AutoSize = true; + this.checkBoxWaveformShowCps.Location = new System.Drawing.Point(16, 233); + this.checkBoxWaveformShowCps.Name = "checkBoxWaveformShowCps"; + this.checkBoxWaveformShowCps.Size = new System.Drawing.Size(96, 17); + this.checkBoxWaveformShowCps.TabIndex = 7; + this.checkBoxWaveformShowCps.Text = "Show char/sec"; + this.checkBoxWaveformShowCps.UseVisualStyleBackColor = true; + // + // checkBoxWaveformSetVideoPosMoveStartEnd + // + this.checkBoxWaveformSetVideoPosMoveStartEnd.AutoSize = true; + this.checkBoxWaveformSetVideoPosMoveStartEnd.Location = new System.Drawing.Point(262, 73); + this.checkBoxWaveformSetVideoPosMoveStartEnd.Name = "checkBoxWaveformSetVideoPosMoveStartEnd"; + this.checkBoxWaveformSetVideoPosMoveStartEnd.Size = new System.Drawing.Size(225, 17); + this.checkBoxWaveformSetVideoPosMoveStartEnd.TabIndex = 22; + this.checkBoxWaveformSetVideoPosMoveStartEnd.Text = "Set video position when moving start/end"; + this.checkBoxWaveformSetVideoPosMoveStartEnd.UseVisualStyleBackColor = true; + // + // labelWaveformTextSize + // + this.labelWaveformTextSize.AutoSize = true; + this.labelWaveformTextSize.Location = new System.Drawing.Point(259, 194); + this.labelWaveformTextSize.Name = "labelWaveformTextSize"; + this.labelWaveformTextSize.Size = new System.Drawing.Size(73, 13); + this.labelWaveformTextSize.TabIndex = 27; + this.labelWaveformTextSize.Text = "Text font size"; + // + // checkBoxWaveformTextBold + // + this.checkBoxWaveformTextBold.AutoSize = true; + this.checkBoxWaveformTextBold.Location = new System.Drawing.Point(463, 195); + this.checkBoxWaveformTextBold.Name = "checkBoxWaveformTextBold"; + this.checkBoxWaveformTextBold.Size = new System.Drawing.Size(46, 17); + this.checkBoxWaveformTextBold.TabIndex = 29; + this.checkBoxWaveformTextBold.Text = "Bold"; + this.checkBoxWaveformTextBold.UseVisualStyleBackColor = true; + // + // comboBoxWaveformTextSize + // + this.comboBoxWaveformTextSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxWaveformTextSize.FormattingEnabled = true; + this.comboBoxWaveformTextSize.Items.AddRange(new object[] { + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17", + "18", + "19", + "20"}); + this.comboBoxWaveformTextSize.Location = new System.Drawing.Point(336, 191); + this.comboBoxWaveformTextSize.Name = "comboBoxWaveformTextSize"; + this.comboBoxWaveformTextSize.Size = new System.Drawing.Size(121, 21); + this.comboBoxWaveformTextSize.TabIndex = 28; + // + // checkBoxListViewMouseEnterFocus + // + this.checkBoxListViewMouseEnterFocus.AutoSize = true; + this.checkBoxListViewMouseEnterFocus.Location = new System.Drawing.Point(281, 115); + this.checkBoxListViewMouseEnterFocus.Name = "checkBoxListViewMouseEnterFocus"; + this.checkBoxListViewMouseEnterFocus.Size = new System.Drawing.Size(214, 17); + this.checkBoxListViewMouseEnterFocus.TabIndex = 24; + this.checkBoxListViewMouseEnterFocus.Text = "Focus list view on list view mouse enter"; + this.checkBoxListViewMouseEnterFocus.UseVisualStyleBackColor = true; + // + // checkBoxWaveformHoverFocus + // + this.checkBoxWaveformHoverFocus.AutoSize = true; + this.checkBoxWaveformHoverFocus.Location = new System.Drawing.Point(262, 96); + this.checkBoxWaveformHoverFocus.Name = "checkBoxWaveformHoverFocus"; + this.checkBoxWaveformHoverFocus.Size = new System.Drawing.Size(149, 17); + this.checkBoxWaveformHoverFocus.TabIndex = 23; + this.checkBoxWaveformHoverFocus.Text = "Set focus on mouse enter"; + this.checkBoxWaveformHoverFocus.UseVisualStyleBackColor = true; + this.checkBoxWaveformHoverFocus.CheckedChanged += new System.EventHandler(this.checkBoxWaveformHoverFocus_CheckedChanged); + // + // labelWaveformBorderHitMs2 + // + this.labelWaveformBorderHitMs2.AutoSize = true; + this.labelWaveformBorderHitMs2.Location = new System.Drawing.Point(454, 224); + this.labelWaveformBorderHitMs2.Name = "labelWaveformBorderHitMs2"; + this.labelWaveformBorderHitMs2.Size = new System.Drawing.Size(62, 13); + this.labelWaveformBorderHitMs2.TabIndex = 32; + this.labelWaveformBorderHitMs2.Text = "milliseconds"; + // + // numericUpDownWaveformBorderHitMs + // + this.numericUpDownWaveformBorderHitMs.Location = new System.Drawing.Point(392, 222); + this.numericUpDownWaveformBorderHitMs.Minimum = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDownWaveformBorderHitMs.Name = "numericUpDownWaveformBorderHitMs"; + this.numericUpDownWaveformBorderHitMs.Size = new System.Drawing.Size(44, 21); + this.numericUpDownWaveformBorderHitMs.TabIndex = 31; + this.numericUpDownWaveformBorderHitMs.Value = new decimal(new int[] { + 18, + 0, + 0, + 0}); + // + // labelWaveformBorderHitMs1 + // + this.labelWaveformBorderHitMs1.AutoSize = true; + this.labelWaveformBorderHitMs1.Location = new System.Drawing.Point(259, 224); + this.labelWaveformBorderHitMs1.Name = "labelWaveformBorderHitMs1"; + this.labelWaveformBorderHitMs1.Size = new System.Drawing.Size(127, 13); + this.labelWaveformBorderHitMs1.TabIndex = 30; + this.labelWaveformBorderHitMs1.Text = "Marker hit must be within"; + // + // checkBoxAllowOverlap + // + this.checkBoxAllowOverlap.AutoSize = true; + this.checkBoxAllowOverlap.Location = new System.Drawing.Point(262, 50); + this.checkBoxAllowOverlap.Name = "checkBoxAllowOverlap"; + this.checkBoxAllowOverlap.Size = new System.Drawing.Size(212, 17); + this.checkBoxAllowOverlap.TabIndex = 21; + this.checkBoxAllowOverlap.Text = "Allow overlap (when dragging/resizing)"; + this.checkBoxAllowOverlap.UseVisualStyleBackColor = true; + // + // checkBoxReverseMouseWheelScrollDirection + // + this.checkBoxReverseMouseWheelScrollDirection.AutoSize = true; + this.checkBoxReverseMouseWheelScrollDirection.Location = new System.Drawing.Point(262, 27); + this.checkBoxReverseMouseWheelScrollDirection.Name = "checkBoxReverseMouseWheelScrollDirection"; + this.checkBoxReverseMouseWheelScrollDirection.Size = new System.Drawing.Size(202, 17); + this.checkBoxReverseMouseWheelScrollDirection.TabIndex = 20; + this.checkBoxReverseMouseWheelScrollDirection.Text = "Reverse mouse wheel scroll direction"; + this.checkBoxReverseMouseWheelScrollDirection.UseVisualStyleBackColor = true; + // + // panelWaveformTextColor + // + this.panelWaveformTextColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelWaveformTextColor.Location = new System.Drawing.Point(138, 113); + this.panelWaveformTextColor.Name = "panelWaveformTextColor"; + this.panelWaveformTextColor.Size = new System.Drawing.Size(21, 20); + this.panelWaveformTextColor.TabIndex = 7; + this.panelWaveformTextColor.Click += new System.EventHandler(this.buttonWaveformTextColor_Click); + // + // buttonWaveformTextColor + // + this.buttonWaveformTextColor.Location = new System.Drawing.Point(14, 112); + this.buttonWaveformTextColor.Name = "buttonWaveformTextColor"; + this.buttonWaveformTextColor.Size = new System.Drawing.Size(112, 23); + this.buttonWaveformTextColor.TabIndex = 3; + this.buttonWaveformTextColor.Text = "Text color"; + this.buttonWaveformTextColor.UseVisualStyleBackColor = true; + this.buttonWaveformTextColor.Click += new System.EventHandler(this.buttonWaveformTextColor_Click); + // + // panelWaveformGridColor + // + this.panelWaveformGridColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelWaveformGridColor.Location = new System.Drawing.Point(138, 171); + this.panelWaveformGridColor.Name = "panelWaveformGridColor"; + this.panelWaveformGridColor.Size = new System.Drawing.Size(21, 20); + this.panelWaveformGridColor.TabIndex = 9; + this.panelWaveformGridColor.Click += new System.EventHandler(this.buttonWaveformGridColor_Click); + // + // buttonWaveformGridColor + // + this.buttonWaveformGridColor.Location = new System.Drawing.Point(14, 170); + this.buttonWaveformGridColor.Name = "buttonWaveformGridColor"; + this.buttonWaveformGridColor.Size = new System.Drawing.Size(112, 23); + this.buttonWaveformGridColor.TabIndex = 5; + this.buttonWaveformGridColor.Text = "Grid color"; + this.buttonWaveformGridColor.UseVisualStyleBackColor = true; + this.buttonWaveformGridColor.Click += new System.EventHandler(this.buttonWaveformGridColor_Click); + // + // panelWaveformBackgroundColor + // + this.panelWaveformBackgroundColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelWaveformBackgroundColor.Location = new System.Drawing.Point(138, 84); + this.panelWaveformBackgroundColor.Name = "panelWaveformBackgroundColor"; + this.panelWaveformBackgroundColor.Size = new System.Drawing.Size(21, 20); + this.panelWaveformBackgroundColor.TabIndex = 5; + this.panelWaveformBackgroundColor.Click += new System.EventHandler(this.buttonWaveformBackgroundColor_Click); + // + // buttonWaveformBackgroundColor + // + this.buttonWaveformBackgroundColor.Location = new System.Drawing.Point(14, 83); + this.buttonWaveformBackgroundColor.Name = "buttonWaveformBackgroundColor"; + this.buttonWaveformBackgroundColor.Size = new System.Drawing.Size(112, 23); + this.buttonWaveformBackgroundColor.TabIndex = 2; + this.buttonWaveformBackgroundColor.Text = "Back color"; + this.buttonWaveformBackgroundColor.UseVisualStyleBackColor = true; + this.buttonWaveformBackgroundColor.Click += new System.EventHandler(this.buttonWaveformBackgroundColor_Click); + // + // panelWaveformColor + // + this.panelWaveformColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelWaveformColor.Location = new System.Drawing.Point(138, 55); + this.panelWaveformColor.Name = "panelWaveformColor"; + this.panelWaveformColor.Size = new System.Drawing.Size(21, 20); + this.panelWaveformColor.TabIndex = 3; + this.panelWaveformColor.Click += new System.EventHandler(this.buttonWaveformColor_Click); + // + // buttonWaveformColor + // + this.buttonWaveformColor.Location = new System.Drawing.Point(14, 54); + this.buttonWaveformColor.Name = "buttonWaveformColor"; + this.buttonWaveformColor.Size = new System.Drawing.Size(112, 23); + this.buttonWaveformColor.TabIndex = 1; + this.buttonWaveformColor.Text = "Color"; + this.buttonWaveformColor.UseVisualStyleBackColor = true; + this.buttonWaveformColor.Click += new System.EventHandler(this.buttonWaveformColor_Click); + // + // panelWaveformSelectedColor + // + this.panelWaveformSelectedColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelWaveformSelectedColor.Location = new System.Drawing.Point(138, 26); + this.panelWaveformSelectedColor.Name = "panelWaveformSelectedColor"; + this.panelWaveformSelectedColor.Size = new System.Drawing.Size(21, 20); + this.panelWaveformSelectedColor.TabIndex = 1; + this.panelWaveformSelectedColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.buttonWaveformSelectedColor_Click); + // + // buttonWaveformSelectedColor + // + this.buttonWaveformSelectedColor.Location = new System.Drawing.Point(14, 25); + this.buttonWaveformSelectedColor.Name = "buttonWaveformSelectedColor"; + this.buttonWaveformSelectedColor.Size = new System.Drawing.Size(112, 23); + this.buttonWaveformSelectedColor.TabIndex = 0; + this.buttonWaveformSelectedColor.Text = "Selected color"; + this.buttonWaveformSelectedColor.UseVisualStyleBackColor = true; + this.buttonWaveformSelectedColor.Click += new System.EventHandler(this.buttonWaveformSelectedColor_Click); + // + // checkBoxWaveformShowGrid + // + this.checkBoxWaveformShowGrid.AutoSize = true; + this.checkBoxWaveformShowGrid.Location = new System.Drawing.Point(16, 201); + this.checkBoxWaveformShowGrid.Name = "checkBoxWaveformShowGrid"; + this.checkBoxWaveformShowGrid.Size = new System.Drawing.Size(73, 17); + this.checkBoxWaveformShowGrid.TabIndex = 6; + this.checkBoxWaveformShowGrid.Text = "Show grid"; + this.checkBoxWaveformShowGrid.UseVisualStyleBackColor = true; + // + // tabPageTools + // + this.tabPageTools.Controls.Add(this.groupBoxGoogleTranslate); + this.tabPageTools.Controls.Add(this.groupBoxBing); + this.tabPageTools.Controls.Add(this.groupBoxToolsAutoBr); + this.tabPageTools.Controls.Add(this.groupBoxSpellCheck); + this.tabPageTools.Controls.Add(this.groupBoxFixCommonErrors); + this.tabPageTools.Controls.Add(this.groupBoxToolsVisualSync); + this.tabPageTools.Location = new System.Drawing.Point(4, 22); + this.tabPageTools.Name = "tabPageTools"; + this.tabPageTools.Padding = new System.Windows.Forms.Padding(3); + this.tabPageTools.Size = new System.Drawing.Size(832, 520); + this.tabPageTools.TabIndex = 5; + this.tabPageTools.Text = "Tools"; + this.tabPageTools.UseVisualStyleBackColor = true; + // + // groupBoxGoogleTranslate + // + this.groupBoxGoogleTranslate.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxGoogleTranslate.Controls.Add(this.labelGoogleTranslateApiKey); + this.groupBoxGoogleTranslate.Controls.Add(this.textBoxGoogleTransleApiKey); + this.groupBoxGoogleTranslate.Controls.Add(this.linkLabelGoogleTranslateSignUp); + this.groupBoxGoogleTranslate.Controls.Add(this.label3); + this.groupBoxGoogleTranslate.Location = new System.Drawing.Point(421, 244); + this.groupBoxGoogleTranslate.Name = "groupBoxGoogleTranslate"; + this.groupBoxGoogleTranslate.Size = new System.Drawing.Size(404, 78); + this.groupBoxGoogleTranslate.TabIndex = 31; + this.groupBoxGoogleTranslate.TabStop = false; + this.groupBoxGoogleTranslate.Text = "Google translate"; + // + // labelGoogleTranslateApiKey + // + this.labelGoogleTranslateApiKey.AutoSize = true; + this.labelGoogleTranslateApiKey.Location = new System.Drawing.Point(13, 47); + this.labelGoogleTranslateApiKey.Name = "labelGoogleTranslateApiKey"; + this.labelGoogleTranslateApiKey.Size = new System.Drawing.Size(44, 13); + this.labelGoogleTranslateApiKey.TabIndex = 30; + this.labelGoogleTranslateApiKey.Text = "API key"; + // + // textBoxGoogleTransleApiKey + // + this.textBoxGoogleTransleApiKey.Location = new System.Drawing.Point(94, 47); + this.textBoxGoogleTransleApiKey.Name = "textBoxGoogleTransleApiKey"; + this.textBoxGoogleTransleApiKey.Size = new System.Drawing.Size(290, 21); + this.textBoxGoogleTransleApiKey.TabIndex = 26; + // + // linkLabelGoogleTranslateSignUp + // + this.linkLabelGoogleTranslateSignUp.AutoSize = true; + this.linkLabelGoogleTranslateSignUp.Location = new System.Drawing.Point(306, 19); + this.linkLabelGoogleTranslateSignUp.Name = "linkLabelGoogleTranslateSignUp"; + this.linkLabelGoogleTranslateSignUp.Size = new System.Drawing.Size(78, 13); + this.linkLabelGoogleTranslateSignUp.TabIndex = 24; + this.linkLabelGoogleTranslateSignUp.TabStop = true; + this.linkLabelGoogleTranslateSignUp.Text = "How to sign up"; + this.linkLabelGoogleTranslateSignUp.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelGoogleTranslateSignUp_LinkClicked); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(16, 106); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(0, 13); + this.label3.TabIndex = 25; + // + // groupBoxBing + // + this.groupBoxBing.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxBing.Controls.Add(this.comboBoxBoxBingTokenEndpoint); + this.groupBoxBing.Controls.Add(this.labelBingTokenEndpoint); + this.groupBoxBing.Controls.Add(this.labelBingApiKey); + this.groupBoxBing.Controls.Add(this.textBoxBingClientSecret); + this.groupBoxBing.Controls.Add(this.linkLabelBingSubscribe); + this.groupBoxBing.Controls.Add(this.label1); + this.groupBoxBing.Location = new System.Drawing.Point(421, 331); + this.groupBoxBing.Name = "groupBoxBing"; + this.groupBoxBing.Size = new System.Drawing.Size(404, 183); + this.groupBoxBing.TabIndex = 32; + this.groupBoxBing.TabStop = false; + this.groupBoxBing.Text = "Bing translator"; + // + // comboBoxBoxBingTokenEndpoint + // + this.comboBoxBoxBingTokenEndpoint.FormattingEnabled = true; + this.comboBoxBoxBingTokenEndpoint.Items.AddRange(new object[] { + "https://api.cognitive.microsoft.com/sts/v1.0/issueToken", + "https://.api.cognitive.microsoft.com/sts/v1.0/issueToken"}); + this.comboBoxBoxBingTokenEndpoint.Location = new System.Drawing.Point(9, 101); + this.comboBoxBoxBingTokenEndpoint.Name = "comboBoxBoxBingTokenEndpoint"; + this.comboBoxBoxBingTokenEndpoint.Size = new System.Drawing.Size(375, 21); + this.comboBoxBoxBingTokenEndpoint.TabIndex = 33; + // + // labelBingTokenEndpoint + // + this.labelBingTokenEndpoint.AutoSize = true; + this.labelBingTokenEndpoint.Location = new System.Drawing.Point(6, 83); + this.labelBingTokenEndpoint.Name = "labelBingTokenEndpoint"; + this.labelBingTokenEndpoint.Size = new System.Drawing.Size(81, 13); + this.labelBingTokenEndpoint.TabIndex = 32; + this.labelBingTokenEndpoint.Text = "Token endpoint"; + // + // labelBingApiKey + // + this.labelBingApiKey.AutoSize = true; + this.labelBingApiKey.Location = new System.Drawing.Point(6, 29); + this.labelBingApiKey.Name = "labelBingApiKey"; + this.labelBingApiKey.Size = new System.Drawing.Size(44, 13); + this.labelBingApiKey.TabIndex = 30; + this.labelBingApiKey.Text = "API key"; + // + // textBoxBingClientSecret + // + this.textBoxBingClientSecret.Location = new System.Drawing.Point(10, 45); + this.textBoxBingClientSecret.Name = "textBoxBingClientSecret"; + this.textBoxBingClientSecret.Size = new System.Drawing.Size(374, 21); + this.textBoxBingClientSecret.TabIndex = 26; + // + // linkLabelBingSubscribe + // + this.linkLabelBingSubscribe.AutoSize = true; + this.linkLabelBingSubscribe.Location = new System.Drawing.Point(306, 17); + this.linkLabelBingSubscribe.Name = "linkLabelBingSubscribe"; + this.linkLabelBingSubscribe.Size = new System.Drawing.Size(78, 13); + this.linkLabelBingSubscribe.TabIndex = 24; + this.linkLabelBingSubscribe.TabStop = true; + this.linkLabelBingSubscribe.Text = "How to sign up"; + this.linkLabelBingSubscribe.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelBingSubscribe_LinkClicked); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(16, 106); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(0, 13); + this.label1.TabIndex = 25; + // + // groupBoxToolsAutoBr + // + this.groupBoxToolsAutoBr.Controls.Add(this.labelToolsBreakBottomHeavyPercent); + this.groupBoxToolsAutoBr.Controls.Add(this.numericUpDownToolsBreakPreferBottomHeavy); + this.groupBoxToolsAutoBr.Controls.Add(this.checkBoxToolsBreakPreferBottomHeavy); + this.groupBoxToolsAutoBr.Controls.Add(this.checkBoxToolsBreakByPixelWidth); + this.groupBoxToolsAutoBr.Controls.Add(this.checkBoxToolsBreakEarlyLineEnding); + this.groupBoxToolsAutoBr.Controls.Add(this.checkBoxToolsBreakEarlyComma); + this.groupBoxToolsAutoBr.Controls.Add(this.checkBoxToolsBreakEarlyDash); + this.groupBoxToolsAutoBr.Controls.Add(this.labelUserBingApiId); + this.groupBoxToolsAutoBr.Controls.Add(this.buttonEditDoNotBreakAfterList); + this.groupBoxToolsAutoBr.Controls.Add(this.checkBoxUseDoNotBreakAfterList); + this.groupBoxToolsAutoBr.Location = new System.Drawing.Point(421, 6); + this.groupBoxToolsAutoBr.Name = "groupBoxToolsAutoBr"; + this.groupBoxToolsAutoBr.Size = new System.Drawing.Size(404, 232); + this.groupBoxToolsAutoBr.TabIndex = 5; + this.groupBoxToolsAutoBr.TabStop = false; + this.groupBoxToolsAutoBr.Text = "Auto br"; + // + // labelToolsBreakBottomHeavyPercent + // + this.labelToolsBreakBottomHeavyPercent.AutoSize = true; + this.labelToolsBreakBottomHeavyPercent.Location = new System.Drawing.Point(226, 142); + this.labelToolsBreakBottomHeavyPercent.Name = "labelToolsBreakBottomHeavyPercent"; + this.labelToolsBreakBottomHeavyPercent.Size = new System.Drawing.Size(18, 13); + this.labelToolsBreakBottomHeavyPercent.TabIndex = 63; + this.labelToolsBreakBottomHeavyPercent.Text = "%"; + // + // numericUpDownToolsBreakPreferBottomHeavy + // + this.numericUpDownToolsBreakPreferBottomHeavy.DecimalPlaces = 1; + this.numericUpDownToolsBreakPreferBottomHeavy.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numericUpDownToolsBreakPreferBottomHeavy.Location = new System.Drawing.Point(164, 140); + this.numericUpDownToolsBreakPreferBottomHeavy.Maximum = new decimal(new int[] { + 50, + 0, + 0, + 0}); + this.numericUpDownToolsBreakPreferBottomHeavy.Name = "numericUpDownToolsBreakPreferBottomHeavy"; + this.numericUpDownToolsBreakPreferBottomHeavy.Size = new System.Drawing.Size(56, 21); + this.numericUpDownToolsBreakPreferBottomHeavy.TabIndex = 62; + this.numericUpDownToolsBreakPreferBottomHeavy.Value = new decimal(new int[] { + 11, + 0, + 0, + 0}); + // + // checkBoxToolsBreakPreferBottomHeavy + // + this.checkBoxToolsBreakPreferBottomHeavy.AutoSize = true; + this.checkBoxToolsBreakPreferBottomHeavy.Location = new System.Drawing.Point(32, 141); + this.checkBoxToolsBreakPreferBottomHeavy.Name = "checkBoxToolsBreakPreferBottomHeavy"; + this.checkBoxToolsBreakPreferBottomHeavy.Size = new System.Drawing.Size(126, 17); + this.checkBoxToolsBreakPreferBottomHeavy.TabIndex = 61; + this.checkBoxToolsBreakPreferBottomHeavy.Text = "Prefer bottom heavy"; + this.checkBoxToolsBreakPreferBottomHeavy.UseVisualStyleBackColor = true; + // + // checkBoxToolsBreakByPixelWidth + // + this.checkBoxToolsBreakByPixelWidth.AutoSize = true; + this.checkBoxToolsBreakByPixelWidth.Location = new System.Drawing.Point(15, 118); + this.checkBoxToolsBreakByPixelWidth.Name = "checkBoxToolsBreakByPixelWidth"; + this.checkBoxToolsBreakByPixelWidth.Size = new System.Drawing.Size(172, 17); + this.checkBoxToolsBreakByPixelWidth.TabIndex = 60; + this.checkBoxToolsBreakByPixelWidth.Text = "Break by estimated pixel width"; + this.checkBoxToolsBreakByPixelWidth.UseVisualStyleBackColor = true; + this.checkBoxToolsBreakByPixelWidth.CheckedChanged += new System.EventHandler(this.checkBoxToolsBreakByPixelWidth_CheckedChanged); + // + // checkBoxToolsBreakEarlyLineEnding + // + this.checkBoxToolsBreakEarlyLineEnding.AutoSize = true; + this.checkBoxToolsBreakEarlyLineEnding.Location = new System.Drawing.Point(15, 72); + this.checkBoxToolsBreakEarlyLineEnding.Name = "checkBoxToolsBreakEarlyLineEnding"; + this.checkBoxToolsBreakEarlyLineEnding.Size = new System.Drawing.Size(175, 17); + this.checkBoxToolsBreakEarlyLineEnding.TabIndex = 40; + this.checkBoxToolsBreakEarlyLineEnding.Text = "Break early for line ending (.!?)"; + this.checkBoxToolsBreakEarlyLineEnding.UseVisualStyleBackColor = true; + // + // checkBoxToolsBreakEarlyComma + // + this.checkBoxToolsBreakEarlyComma.AutoSize = true; + this.checkBoxToolsBreakEarlyComma.Location = new System.Drawing.Point(15, 95); + this.checkBoxToolsBreakEarlyComma.Name = "checkBoxToolsBreakEarlyComma"; + this.checkBoxToolsBreakEarlyComma.Size = new System.Drawing.Size(133, 17); + this.checkBoxToolsBreakEarlyComma.TabIndex = 50; + this.checkBoxToolsBreakEarlyComma.Text = "Break early for comma"; + this.checkBoxToolsBreakEarlyComma.UseVisualStyleBackColor = true; + // + // checkBoxToolsBreakEarlyDash + // + this.checkBoxToolsBreakEarlyDash.AutoSize = true; + this.checkBoxToolsBreakEarlyDash.Location = new System.Drawing.Point(15, 49); + this.checkBoxToolsBreakEarlyDash.Name = "checkBoxToolsBreakEarlyDash"; + this.checkBoxToolsBreakEarlyDash.Size = new System.Drawing.Size(123, 17); + this.checkBoxToolsBreakEarlyDash.TabIndex = 30; + this.checkBoxToolsBreakEarlyDash.Text = "Break early for dash"; + this.checkBoxToolsBreakEarlyDash.UseVisualStyleBackColor = true; + // + // labelUserBingApiId + // + this.labelUserBingApiId.AutoSize = true; + this.labelUserBingApiId.Location = new System.Drawing.Point(16, 106); + this.labelUserBingApiId.Name = "labelUserBingApiId"; + this.labelUserBingApiId.Size = new System.Drawing.Size(0, 13); + this.labelUserBingApiId.TabIndex = 25; + // + // buttonEditDoNotBreakAfterList + // + this.buttonEditDoNotBreakAfterList.Location = new System.Drawing.Point(239, 22); + this.buttonEditDoNotBreakAfterList.Name = "buttonEditDoNotBreakAfterList"; + this.buttonEditDoNotBreakAfterList.Size = new System.Drawing.Size(75, 23); + this.buttonEditDoNotBreakAfterList.TabIndex = 20; + this.buttonEditDoNotBreakAfterList.Text = "Edit"; + this.buttonEditDoNotBreakAfterList.UseVisualStyleBackColor = true; + this.buttonEditDoNotBreakAfterList.Click += new System.EventHandler(this.buttonEditDoNotBreakAfterList_Click); + // + // checkBoxUseDoNotBreakAfterList + // + this.checkBoxUseDoNotBreakAfterList.AutoSize = true; + this.checkBoxUseDoNotBreakAfterList.Location = new System.Drawing.Point(15, 26); + this.checkBoxUseDoNotBreakAfterList.Name = "checkBoxUseDoNotBreakAfterList"; + this.checkBoxUseDoNotBreakAfterList.Size = new System.Drawing.Size(154, 17); + this.checkBoxUseDoNotBreakAfterList.TabIndex = 1; + this.checkBoxUseDoNotBreakAfterList.Text = "Use \'do-not-beak-after\' list"; + this.checkBoxUseDoNotBreakAfterList.UseVisualStyleBackColor = true; + // + // groupBoxSpellCheck + // + this.groupBoxSpellCheck.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxSpellCheck.Controls.Add(this.checkBoxSpellCheckAutoChangeNamesViaSuggestions); + this.groupBoxSpellCheck.Controls.Add(this.checkBoxUseAlwaysToFile); + this.groupBoxSpellCheck.Controls.Add(this.checkBoxTreatINQuoteAsING); + this.groupBoxSpellCheck.Controls.Add(this.checkBoxSpellCheckOneLetterWords); + this.groupBoxSpellCheck.Controls.Add(this.checkBoxSpellCheckAutoChangeNames); + this.groupBoxSpellCheck.Location = new System.Drawing.Point(7, 360); + this.groupBoxSpellCheck.Name = "groupBoxSpellCheck"; + this.groupBoxSpellCheck.Size = new System.Drawing.Size(408, 154); + this.groupBoxSpellCheck.TabIndex = 4; + this.groupBoxSpellCheck.TabStop = false; + this.groupBoxSpellCheck.Text = "Spell check"; + // + // checkBoxSpellCheckAutoChangeNamesViaSuggestions + // + this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.AutoSize = true; + this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.Location = new System.Drawing.Point(30, 43); + this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.Name = "checkBoxSpellCheckAutoChangeNamesViaSuggestions"; + this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.Size = new System.Drawing.Size(184, 17); + this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.TabIndex = 1; + this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.Text = "Also use \'spell check suggestions\'"; + this.checkBoxSpellCheckAutoChangeNamesViaSuggestions.UseVisualStyleBackColor = true; + // + // checkBoxUseAlwaysToFile + // + this.checkBoxUseAlwaysToFile.AutoSize = true; + this.checkBoxUseAlwaysToFile.Location = new System.Drawing.Point(15, 118); + this.checkBoxUseAlwaysToFile.Name = "checkBoxUseAlwaysToFile"; + this.checkBoxUseAlwaysToFile.Size = new System.Drawing.Size(192, 17); + this.checkBoxUseAlwaysToFile.TabIndex = 12; + this.checkBoxUseAlwaysToFile.Text = "Remember \"Use always\" / \"Skip all\""; + this.checkBoxUseAlwaysToFile.UseVisualStyleBackColor = true; + // + // checkBoxTreatINQuoteAsING + // + this.checkBoxTreatINQuoteAsING.AutoSize = true; + this.checkBoxTreatINQuoteAsING.Location = new System.Drawing.Point(15, 95); + this.checkBoxTreatINQuoteAsING.Name = "checkBoxTreatINQuoteAsING"; + this.checkBoxTreatINQuoteAsING.Size = new System.Drawing.Size(253, 17); + this.checkBoxTreatINQuoteAsING.TabIndex = 8; + this.checkBoxTreatINQuoteAsING.Text = "Treat word ending \" in\' \" as \" ing \" (English only)"; + this.checkBoxTreatINQuoteAsING.UseVisualStyleBackColor = true; + // + // checkBoxSpellCheckOneLetterWords + // + this.checkBoxSpellCheckOneLetterWords.AutoSize = true; + this.checkBoxSpellCheckOneLetterWords.Location = new System.Drawing.Point(15, 72); + this.checkBoxSpellCheckOneLetterWords.Name = "checkBoxSpellCheckOneLetterWords"; + this.checkBoxSpellCheckOneLetterWords.Size = new System.Drawing.Size(205, 17); + this.checkBoxSpellCheckOneLetterWords.TabIndex = 4; + this.checkBoxSpellCheckOneLetterWords.Text = "Prompt for unknown one letter words"; + this.checkBoxSpellCheckOneLetterWords.UseVisualStyleBackColor = true; + // + // checkBoxSpellCheckAutoChangeNames + // + this.checkBoxSpellCheckAutoChangeNames.AutoSize = true; + this.checkBoxSpellCheckAutoChangeNames.Location = new System.Drawing.Point(15, 20); + this.checkBoxSpellCheckAutoChangeNames.Name = "checkBoxSpellCheckAutoChangeNames"; + this.checkBoxSpellCheckAutoChangeNames.Size = new System.Drawing.Size(216, 17); + this.checkBoxSpellCheckAutoChangeNames.TabIndex = 0; + this.checkBoxSpellCheckAutoChangeNames.Text = "Auto fix names where only casing differ"; + this.checkBoxSpellCheckAutoChangeNames.UseVisualStyleBackColor = true; + // + // groupBoxFixCommonErrors + // + this.groupBoxFixCommonErrors.Controls.Add(this.buttonFixContinuationStyleSettings); + this.groupBoxFixCommonErrors.Controls.Add(this.checkBoxFceSkipStep1); + this.groupBoxFixCommonErrors.Controls.Add(this.checkBoxFixShortDisplayTimesAllowMoveStartTime); + this.groupBoxFixCommonErrors.Controls.Add(this.checkBoxFixCommonOcrErrorsUsingHardcodedRules); + this.groupBoxFixCommonErrors.Controls.Add(this.comboBoxToolsMusicSymbol); + this.groupBoxFixCommonErrors.Controls.Add(this.textBoxMusicSymbolsToReplace); + this.groupBoxFixCommonErrors.Controls.Add(this.labelToolsMusicSymbolsToReplace); + this.groupBoxFixCommonErrors.Controls.Add(this.labelToolsMusicSymbol); + this.groupBoxFixCommonErrors.Location = new System.Drawing.Point(7, 129); + this.groupBoxFixCommonErrors.Name = "groupBoxFixCommonErrors"; + this.groupBoxFixCommonErrors.Size = new System.Drawing.Size(408, 225); + this.groupBoxFixCommonErrors.TabIndex = 3; + this.groupBoxFixCommonErrors.TabStop = false; + this.groupBoxFixCommonErrors.Text = "Fix common errors"; + // + // buttonFixContinuationStyleSettings + // + this.buttonFixContinuationStyleSettings.Location = new System.Drawing.Point(15, 189); + this.buttonFixContinuationStyleSettings.Name = "buttonFixContinuationStyleSettings"; + this.buttonFixContinuationStyleSettings.Size = new System.Drawing.Size(271, 23); + this.buttonFixContinuationStyleSettings.TabIndex = 37; + this.buttonFixContinuationStyleSettings.Text = "Edit settings for fixing continuation style..."; + this.buttonFixContinuationStyleSettings.UseVisualStyleBackColor = true; + this.buttonFixContinuationStyleSettings.Click += new System.EventHandler(this.buttonFixContinuationStyleSettings_Click); + // + // checkBoxFceSkipStep1 + // + this.checkBoxFceSkipStep1.AutoSize = true; + this.checkBoxFceSkipStep1.Location = new System.Drawing.Point(15, 161); + this.checkBoxFceSkipStep1.Name = "checkBoxFceSkipStep1"; + this.checkBoxFceSkipStep1.Size = new System.Drawing.Size(176, 17); + this.checkBoxFceSkipStep1.TabIndex = 36; + this.checkBoxFceSkipStep1.Text = "Skip step one (choose fix rules)"; + this.checkBoxFceSkipStep1.UseVisualStyleBackColor = true; + // + // checkBoxFixShortDisplayTimesAllowMoveStartTime + // + this.checkBoxFixShortDisplayTimesAllowMoveStartTime.AutoSize = true; + this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Location = new System.Drawing.Point(15, 138); + this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Name = "checkBoxFixShortDisplayTimesAllowMoveStartTime"; + this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Size = new System.Drawing.Size(252, 17); + this.checkBoxFixShortDisplayTimesAllowMoveStartTime.TabIndex = 35; + this.checkBoxFixShortDisplayTimesAllowMoveStartTime.Text = "Fix short display time - allow move of start time"; + this.checkBoxFixShortDisplayTimesAllowMoveStartTime.UseVisualStyleBackColor = true; + // + // checkBoxFixCommonOcrErrorsUsingHardcodedRules + // + this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.AutoSize = true; + this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.Location = new System.Drawing.Point(15, 115); + this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.Name = "checkBoxFixCommonOcrErrorsUsingHardcodedRules"; + this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.Size = new System.Drawing.Size(268, 17); + this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.TabIndex = 2; + this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.Text = "Fix common OCR errors - also use hardcoded rules"; + this.checkBoxFixCommonOcrErrorsUsingHardcodedRules.UseVisualStyleBackColor = true; + // + // comboBoxToolsMusicSymbol + // + this.comboBoxToolsMusicSymbol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxToolsMusicSymbol.FormattingEnabled = true; + this.comboBoxToolsMusicSymbol.Items.AddRange(new object[] { + "♪", + "♪♪", + "*", + "#"}); + this.comboBoxToolsMusicSymbol.Location = new System.Drawing.Point(200, 71); + this.comboBoxToolsMusicSymbol.Name = "comboBoxToolsMusicSymbol"; + this.comboBoxToolsMusicSymbol.Size = new System.Drawing.Size(86, 21); + this.comboBoxToolsMusicSymbol.TabIndex = 1; + // + // textBoxMusicSymbolsToReplace + // + this.textBoxMusicSymbolsToReplace.Location = new System.Drawing.Point(11, 41); + this.textBoxMusicSymbolsToReplace.MaxLength = 100; + this.textBoxMusicSymbolsToReplace.Name = "textBoxMusicSymbolsToReplace"; + this.textBoxMusicSymbolsToReplace.Size = new System.Drawing.Size(274, 21); + this.textBoxMusicSymbolsToReplace.TabIndex = 0; + // + // labelToolsMusicSymbolsToReplace + // + this.labelToolsMusicSymbolsToReplace.AutoSize = true; + this.labelToolsMusicSymbolsToReplace.Location = new System.Drawing.Point(8, 25); + this.labelToolsMusicSymbolsToReplace.Name = "labelToolsMusicSymbolsToReplace"; + this.labelToolsMusicSymbolsToReplace.Size = new System.Drawing.Size(230, 13); + this.labelToolsMusicSymbolsToReplace.TabIndex = 34; + this.labelToolsMusicSymbolsToReplace.Text = "Music symbols to replace (separate by comma)"; + // + // labelToolsMusicSymbol + // + this.labelToolsMusicSymbol.AutoSize = true; + this.labelToolsMusicSymbol.Location = new System.Drawing.Point(8, 74); + this.labelToolsMusicSymbol.Name = "labelToolsMusicSymbol"; + this.labelToolsMusicSymbol.Size = new System.Drawing.Size(69, 13); + this.labelToolsMusicSymbol.TabIndex = 32; + this.labelToolsMusicSymbol.Text = "Music symbol"; + // + // groupBoxToolsVisualSync + // + this.groupBoxToolsVisualSync.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxToolsVisualSync.Controls.Add(this.labelToolsEndScene); + this.groupBoxToolsVisualSync.Controls.Add(this.comboBoxToolsEndSceneIndex); + this.groupBoxToolsVisualSync.Controls.Add(this.labelToolsStartScene); + this.groupBoxToolsVisualSync.Controls.Add(this.comboBoxToolsStartSceneIndex); + this.groupBoxToolsVisualSync.Controls.Add(this.comboBoxToolsVerifySeconds); + this.groupBoxToolsVisualSync.Controls.Add(this.labelVerifyButton); + this.groupBoxToolsVisualSync.Location = new System.Drawing.Point(6, 6); + this.groupBoxToolsVisualSync.Name = "groupBoxToolsVisualSync"; + this.groupBoxToolsVisualSync.Size = new System.Drawing.Size(409, 116); + this.groupBoxToolsVisualSync.TabIndex = 2; + this.groupBoxToolsVisualSync.TabStop = false; + this.groupBoxToolsVisualSync.Text = "Visual sync"; + // + // labelToolsEndScene + // + this.labelToolsEndScene.AutoSize = true; + this.labelToolsEndScene.Location = new System.Drawing.Point(13, 79); + this.labelToolsEndScene.Name = "labelToolsEndScene"; + this.labelToolsEndScene.Size = new System.Drawing.Size(122, 13); + this.labelToolsEndScene.TabIndex = 29; + this.labelToolsEndScene.Text = "End scene paragraph is "; + // + // comboBoxToolsEndSceneIndex + // + this.comboBoxToolsEndSceneIndex.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxToolsEndSceneIndex.FormattingEnabled = true; + this.comboBoxToolsEndSceneIndex.Items.AddRange(new object[] { + "Last", + "Last - 1", + "Last - 2", + "Last - 3"}); + this.comboBoxToolsEndSceneIndex.Location = new System.Drawing.Point(200, 76); + this.comboBoxToolsEndSceneIndex.Name = "comboBoxToolsEndSceneIndex"; + this.comboBoxToolsEndSceneIndex.Size = new System.Drawing.Size(86, 21); + this.comboBoxToolsEndSceneIndex.TabIndex = 2; + // + // labelToolsStartScene + // + this.labelToolsStartScene.AutoSize = true; + this.labelToolsStartScene.Location = new System.Drawing.Point(13, 52); + this.labelToolsStartScene.Name = "labelToolsStartScene"; + this.labelToolsStartScene.Size = new System.Drawing.Size(125, 13); + this.labelToolsStartScene.TabIndex = 27; + this.labelToolsStartScene.Text = "Start scene paragraph is"; + // + // comboBoxToolsStartSceneIndex + // + this.comboBoxToolsStartSceneIndex.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxToolsStartSceneIndex.FormattingEnabled = true; + this.comboBoxToolsStartSceneIndex.Items.AddRange(new object[] { + "First", + "First +1", + "First +2", + "First +3"}); + this.comboBoxToolsStartSceneIndex.Location = new System.Drawing.Point(200, 49); + this.comboBoxToolsStartSceneIndex.Name = "comboBoxToolsStartSceneIndex"; + this.comboBoxToolsStartSceneIndex.Size = new System.Drawing.Size(86, 21); + this.comboBoxToolsStartSceneIndex.TabIndex = 1; + // + // comboBoxToolsVerifySeconds + // + this.comboBoxToolsVerifySeconds.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxToolsVerifySeconds.FormattingEnabled = true; + this.comboBoxToolsVerifySeconds.Items.AddRange(new object[] { + "2", + "3", + "4", + "5"}); + this.comboBoxToolsVerifySeconds.Location = new System.Drawing.Point(200, 22); + this.comboBoxToolsVerifySeconds.Name = "comboBoxToolsVerifySeconds"; + this.comboBoxToolsVerifySeconds.Size = new System.Drawing.Size(86, 21); + this.comboBoxToolsVerifySeconds.TabIndex = 0; + // + // labelVerifyButton + // + this.labelVerifyButton.AutoSize = true; + this.labelVerifyButton.Location = new System.Drawing.Point(13, 25); + this.labelVerifyButton.Name = "labelVerifyButton"; + this.labelVerifyButton.Size = new System.Drawing.Size(147, 13); + this.labelVerifyButton.TabIndex = 3; + this.labelVerifyButton.Text = "Play X seconds and back, X is"; + // + // tabPageWordLists + // + this.tabPageWordLists.Controls.Add(this.groupBoxWordLists); + this.tabPageWordLists.Location = new System.Drawing.Point(4, 22); + this.tabPageWordLists.Name = "tabPageWordLists"; + this.tabPageWordLists.Padding = new System.Windows.Forms.Padding(3); + this.tabPageWordLists.Size = new System.Drawing.Size(832, 520); + this.tabPageWordLists.TabIndex = 3; + this.tabPageWordLists.Text = "Word lists"; + this.tabPageWordLists.UseVisualStyleBackColor = true; + // + // groupBoxWordLists + // + this.groupBoxWordLists.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxWordLists.Controls.Add(this.linkLabelOpenDictionaryFolder); + this.groupBoxWordLists.Controls.Add(this.groupBoxOcrFixList); + this.groupBoxWordLists.Controls.Add(this.groupBoxUserWordList); + this.groupBoxWordLists.Controls.Add(this.groupBoxWordListLocation); + this.groupBoxWordLists.Controls.Add(this.groupBoxNamesIgonoreLists); + this.groupBoxWordLists.Controls.Add(this.labelWordListLanguage); + this.groupBoxWordLists.Controls.Add(this.comboBoxWordListLanguage); + this.groupBoxWordLists.Location = new System.Drawing.Point(6, 6); + this.groupBoxWordLists.Name = "groupBoxWordLists"; + this.groupBoxWordLists.Size = new System.Drawing.Size(819, 503); + this.groupBoxWordLists.TabIndex = 2; + this.groupBoxWordLists.TabStop = false; + this.groupBoxWordLists.Text = "Word lists"; + // + // linkLabelOpenDictionaryFolder + // + this.linkLabelOpenDictionaryFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.linkLabelOpenDictionaryFolder.AutoSize = true; + this.linkLabelOpenDictionaryFolder.Location = new System.Drawing.Point(6, 464); + this.linkLabelOpenDictionaryFolder.Name = "linkLabelOpenDictionaryFolder"; + this.linkLabelOpenDictionaryFolder.Size = new System.Drawing.Size(126, 13); + this.linkLabelOpenDictionaryFolder.TabIndex = 29; + this.linkLabelOpenDictionaryFolder.TabStop = true; + this.linkLabelOpenDictionaryFolder.Text = "Open \'Dictionaries\' folder"; + this.linkLabelOpenDictionaryFolder.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelOpenDictionaryFolder_LinkClicked); + // + // groupBoxOcrFixList + // + this.groupBoxOcrFixList.Controls.Add(this.textBoxOcrFixValue); + this.groupBoxOcrFixList.Controls.Add(this.buttonRemoveOcrFix); + this.groupBoxOcrFixList.Controls.Add(this.listBoxOcrFixList); + this.groupBoxOcrFixList.Controls.Add(this.textBoxOcrFixKey); + this.groupBoxOcrFixList.Controls.Add(this.buttonAddOcrFix); + this.groupBoxOcrFixList.Location = new System.Drawing.Point(510, 43); + this.groupBoxOcrFixList.Name = "groupBoxOcrFixList"; + this.groupBoxOcrFixList.Size = new System.Drawing.Size(293, 279); + this.groupBoxOcrFixList.TabIndex = 6; + this.groupBoxOcrFixList.TabStop = false; + this.groupBoxOcrFixList.Text = "OCR fix list"; + // + // textBoxOcrFixValue + // + this.textBoxOcrFixValue.Location = new System.Drawing.Point(100, 248); + this.textBoxOcrFixValue.Name = "textBoxOcrFixValue"; + this.textBoxOcrFixValue.Size = new System.Drawing.Size(85, 21); + this.textBoxOcrFixValue.TabIndex = 45; + this.textBoxOcrFixValue.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxOcrFixValueKeyDown); + // + // buttonRemoveOcrFix + // + this.buttonRemoveOcrFix.Location = new System.Drawing.Point(191, 16); + this.buttonRemoveOcrFix.Name = "buttonRemoveOcrFix"; + this.buttonRemoveOcrFix.Size = new System.Drawing.Size(75, 23); + this.buttonRemoveOcrFix.TabIndex = 42; + this.buttonRemoveOcrFix.Text = "Remove"; + this.buttonRemoveOcrFix.UseVisualStyleBackColor = true; + this.buttonRemoveOcrFix.Click += new System.EventHandler(this.ButtonRemoveOcrFixClick); + // + // listBoxOcrFixList + // + this.listBoxOcrFixList.FormattingEnabled = true; + this.listBoxOcrFixList.Location = new System.Drawing.Point(6, 16); + this.listBoxOcrFixList.Name = "listBoxOcrFixList"; + this.listBoxOcrFixList.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.listBoxOcrFixList.Size = new System.Drawing.Size(179, 225); + this.listBoxOcrFixList.TabIndex = 40; + this.listBoxOcrFixList.SelectedIndexChanged += new System.EventHandler(this.ListBoxOcrFixListSelectedIndexChanged); + this.listBoxOcrFixList.DoubleClick += new System.EventHandler(this.listBoxOcrFixList_DoubleClick); + this.listBoxOcrFixList.Enter += new System.EventHandler(this.ListBoxSearchReset); + this.listBoxOcrFixList.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ListBoxKeyDownSearch); + // + // textBoxOcrFixKey + // + this.textBoxOcrFixKey.Location = new System.Drawing.Point(6, 248); + this.textBoxOcrFixKey.Name = "textBoxOcrFixKey"; + this.textBoxOcrFixKey.Size = new System.Drawing.Size(88, 21); + this.textBoxOcrFixKey.TabIndex = 44; + // + // buttonAddOcrFix + // + this.buttonAddOcrFix.Location = new System.Drawing.Point(191, 247); + this.buttonAddOcrFix.Name = "buttonAddOcrFix"; + this.buttonAddOcrFix.Size = new System.Drawing.Size(75, 23); + this.buttonAddOcrFix.TabIndex = 46; + this.buttonAddOcrFix.Text = "Add pair"; + this.buttonAddOcrFix.UseVisualStyleBackColor = true; + this.buttonAddOcrFix.Click += new System.EventHandler(this.ButtonAddOcrFixClick); + // + // groupBoxUserWordList + // + this.groupBoxUserWordList.Controls.Add(this.buttonRemoveUserWord); + this.groupBoxUserWordList.Controls.Add(this.listBoxUserWordLists); + this.groupBoxUserWordList.Controls.Add(this.textBoxUserWord); + this.groupBoxUserWordList.Controls.Add(this.buttonAddUserWord); + this.groupBoxUserWordList.Location = new System.Drawing.Point(259, 43); + this.groupBoxUserWordList.Name = "groupBoxUserWordList"; + this.groupBoxUserWordList.Size = new System.Drawing.Size(241, 279); + this.groupBoxUserWordList.TabIndex = 4; + this.groupBoxUserWordList.TabStop = false; + this.groupBoxUserWordList.Text = "User word list"; + // + // buttonRemoveUserWord + // + this.buttonRemoveUserWord.Location = new System.Drawing.Point(159, 16); + this.buttonRemoveUserWord.Name = "buttonRemoveUserWord"; + this.buttonRemoveUserWord.Size = new System.Drawing.Size(75, 23); + this.buttonRemoveUserWord.TabIndex = 32; + this.buttonRemoveUserWord.Text = "Remove"; + this.buttonRemoveUserWord.UseVisualStyleBackColor = true; + this.buttonRemoveUserWord.Click += new System.EventHandler(this.ButtonRemoveUserWordClick); + // + // listBoxUserWordLists + // + this.listBoxUserWordLists.FormattingEnabled = true; + this.listBoxUserWordLists.Location = new System.Drawing.Point(3, 16); + this.listBoxUserWordLists.Name = "listBoxUserWordLists"; + this.listBoxUserWordLists.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.listBoxUserWordLists.Size = new System.Drawing.Size(150, 225); + this.listBoxUserWordLists.TabIndex = 30; + this.listBoxUserWordLists.SelectedIndexChanged += new System.EventHandler(this.ListBoxUserWordListsSelectedIndexChanged); + this.listBoxUserWordLists.DoubleClick += new System.EventHandler(this.listBoxUserWordLists_DoubleClick); + this.listBoxUserWordLists.Enter += new System.EventHandler(this.ListBoxSearchReset); + this.listBoxUserWordLists.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ListBoxKeyDownSearch); + // + // textBoxUserWord + // + this.textBoxUserWord.Location = new System.Drawing.Point(3, 248); + this.textBoxUserWord.Name = "textBoxUserWord"; + this.textBoxUserWord.Size = new System.Drawing.Size(150, 21); + this.textBoxUserWord.TabIndex = 34; + this.textBoxUserWord.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxUserWordKeyDown); + // + // buttonAddUserWord + // + this.buttonAddUserWord.Location = new System.Drawing.Point(157, 247); + this.buttonAddUserWord.Name = "buttonAddUserWord"; + this.buttonAddUserWord.Size = new System.Drawing.Size(75, 23); + this.buttonAddUserWord.TabIndex = 36; + this.buttonAddUserWord.Text = "Add word"; + this.buttonAddUserWord.UseVisualStyleBackColor = true; + this.buttonAddUserWord.Click += new System.EventHandler(this.ButtonAddUserWordClick); + // + // groupBoxWordListLocation + // + this.groupBoxWordListLocation.Controls.Add(this.checkBoxNamesOnline); + this.groupBoxWordListLocation.Controls.Add(this.textBoxNamesOnline); + this.groupBoxWordListLocation.Location = new System.Drawing.Point(6, 328); + this.groupBoxWordListLocation.Name = "groupBoxWordListLocation"; + this.groupBoxWordListLocation.Size = new System.Drawing.Size(797, 92); + this.groupBoxWordListLocation.TabIndex = 8; + this.groupBoxWordListLocation.TabStop = false; + this.groupBoxWordListLocation.Text = "Location"; + // + // checkBoxNamesOnline + // + this.checkBoxNamesOnline.AutoSize = true; + this.checkBoxNamesOnline.Location = new System.Drawing.Point(7, 22); + this.checkBoxNamesOnline.Name = "checkBoxNamesOnline"; + this.checkBoxNamesOnline.Size = new System.Drawing.Size(145, 17); + this.checkBoxNamesOnline.TabIndex = 26; + this.checkBoxNamesOnline.Text = "Use online names xml file"; + this.checkBoxNamesOnline.UseVisualStyleBackColor = true; + // + // textBoxNamesOnline + // + this.textBoxNamesOnline.Location = new System.Drawing.Point(6, 45); + this.textBoxNamesOnline.Name = "textBoxNamesOnline"; + this.textBoxNamesOnline.Size = new System.Drawing.Size(764, 21); + this.textBoxNamesOnline.TabIndex = 28; + this.textBoxNamesOnline.Text = "https://raw.githubusercontent.com/SubtitleEdit/subtitleedit/master/Dictionaries/n" + + "ames.xml"; + // + // groupBoxNamesIgonoreLists + // + this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonRemoveNameEtc); + this.groupBoxNamesIgonoreLists.Controls.Add(this.listBoxNames); + this.groupBoxNamesIgonoreLists.Controls.Add(this.textBoxNameEtc); + this.groupBoxNamesIgonoreLists.Controls.Add(this.buttonAddNames); + this.groupBoxNamesIgonoreLists.Location = new System.Drawing.Point(6, 43); + this.groupBoxNamesIgonoreLists.Name = "groupBoxNamesIgonoreLists"; + this.groupBoxNamesIgonoreLists.Size = new System.Drawing.Size(241, 279); + this.groupBoxNamesIgonoreLists.TabIndex = 2; + this.groupBoxNamesIgonoreLists.TabStop = false; + this.groupBoxNamesIgonoreLists.Text = "Names/ignore lists"; + // + // buttonRemoveNameEtc + // + this.buttonRemoveNameEtc.Location = new System.Drawing.Point(159, 16); + this.buttonRemoveNameEtc.Name = "buttonRemoveNameEtc"; + this.buttonRemoveNameEtc.Size = new System.Drawing.Size(75, 23); + this.buttonRemoveNameEtc.TabIndex = 22; + this.buttonRemoveNameEtc.Text = "Remove"; + this.buttonRemoveNameEtc.UseVisualStyleBackColor = true; + this.buttonRemoveNameEtc.Click += new System.EventHandler(this.ButtonRemoveNameEtcClick); + // + // listBoxNames + // + this.listBoxNames.FormattingEnabled = true; + this.listBoxNames.Location = new System.Drawing.Point(3, 16); + this.listBoxNames.Name = "listBoxNames"; + this.listBoxNames.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.listBoxNames.Size = new System.Drawing.Size(150, 225); + this.listBoxNames.TabIndex = 20; + this.listBoxNames.SelectedIndexChanged += new System.EventHandler(this.ListBoxNamesSelectedIndexChanged); + this.listBoxNames.DoubleClick += new System.EventHandler(this.listBoxNames_DoubleClick); + this.listBoxNames.Enter += new System.EventHandler(this.ListBoxSearchReset); + this.listBoxNames.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ListBoxKeyDownSearch); + // + // textBoxNameEtc + // + this.textBoxNameEtc.Location = new System.Drawing.Point(3, 248); + this.textBoxNameEtc.Name = "textBoxNameEtc"; + this.textBoxNameEtc.Size = new System.Drawing.Size(151, 21); + this.textBoxNameEtc.TabIndex = 24; + this.textBoxNameEtc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxNameEtcKeyDown); + // + // buttonAddNames + // + this.buttonAddNames.Location = new System.Drawing.Point(160, 247); + this.buttonAddNames.Name = "buttonAddNames"; + this.buttonAddNames.Size = new System.Drawing.Size(75, 23); + this.buttonAddNames.TabIndex = 26; + this.buttonAddNames.Text = "Add name"; + this.buttonAddNames.UseVisualStyleBackColor = true; + this.buttonAddNames.Click += new System.EventHandler(this.ButtonAddNamesClick); + // + // labelWordListLanguage + // + this.labelWordListLanguage.AutoSize = true; + this.labelWordListLanguage.Location = new System.Drawing.Point(6, 19); + this.labelWordListLanguage.Name = "labelWordListLanguage"; + this.labelWordListLanguage.Size = new System.Drawing.Size(54, 13); + this.labelWordListLanguage.TabIndex = 1; + this.labelWordListLanguage.Text = "Language"; + // + // comboBoxWordListLanguage + // + this.comboBoxWordListLanguage.FormattingEnabled = true; + this.comboBoxWordListLanguage.Location = new System.Drawing.Point(67, 16); + this.comboBoxWordListLanguage.Name = "comboBoxWordListLanguage"; + this.comboBoxWordListLanguage.Size = new System.Drawing.Size(155, 21); + this.comboBoxWordListLanguage.TabIndex = 0; + this.comboBoxWordListLanguage.SelectedIndexChanged += new System.EventHandler(this.ComboBoxWordListLanguageSelectedIndexChanged); + // + // tabPageToolBar + // + this.tabPageToolBar.Controls.Add(this.groupBox2); + this.tabPageToolBar.Controls.Add(this.groupBoxShowToolBarButtons); + this.tabPageToolBar.Location = new System.Drawing.Point(4, 22); + this.tabPageToolBar.Name = "tabPageToolBar"; + this.tabPageToolBar.Padding = new System.Windows.Forms.Padding(3); + this.tabPageToolBar.Size = new System.Drawing.Size(832, 520); + this.tabPageToolBar.TabIndex = 7; + this.tabPageToolBar.Text = "Toolbar "; + this.tabPageToolBar.UseVisualStyleBackColor = true; + // + // groupBox2 + // + this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox2.Controls.Add(this.checkBoxShowFrameRate); + this.groupBox2.Location = new System.Drawing.Point(7, 248); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(818, 261); + this.groupBox2.TabIndex = 35; + this.groupBox2.TabStop = false; + // + // checkBoxShowFrameRate + // + this.checkBoxShowFrameRate.AutoSize = true; + this.checkBoxShowFrameRate.Location = new System.Drawing.Point(16, 20); + this.checkBoxShowFrameRate.Name = "checkBoxShowFrameRate"; + this.checkBoxShowFrameRate.Size = new System.Drawing.Size(154, 17); + this.checkBoxShowFrameRate.TabIndex = 34; + this.checkBoxShowFrameRate.Text = "Show frame rate in toolbar"; + this.checkBoxShowFrameRate.UseVisualStyleBackColor = true; + // + // groupBoxShowToolBarButtons + // + this.groupBoxShowToolBarButtons.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBNetflixQualityCheck); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxNetflixQualityCheck); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxNetflixQualityCheck); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBRemoveTextForHi); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxTBRemoveTextForHi); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxTBRemoveTextForHi); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBFixCommonErrors); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxTBFixCommonErrors); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxTBFixCommonErrors); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBHelp); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxHelp); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxHelp); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBSettings); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxSettings); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxSettings); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBSpellCheck); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxSpellCheck); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxSpellCheck); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBVisualSync); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxVisualSync); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxVisualSync); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBReplace); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxReplace); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxReplace); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBFind); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxFind); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxToolbarFind); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBSaveAs); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxSaveAs); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxToolbarSaveAs); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBSave); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxSave); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxToolbarSave); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBOpen); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxOpen); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxToolbarOpen); + this.groupBoxShowToolBarButtons.Controls.Add(this.labelTBNew); + this.groupBoxShowToolBarButtons.Controls.Add(this.pictureBoxNew); + this.groupBoxShowToolBarButtons.Controls.Add(this.checkBoxToolbarNew); + this.groupBoxShowToolBarButtons.Location = new System.Drawing.Point(6, 6); + this.groupBoxShowToolBarButtons.Name = "groupBoxShowToolBarButtons"; + this.groupBoxShowToolBarButtons.Size = new System.Drawing.Size(819, 236); + this.groupBoxShowToolBarButtons.TabIndex = 0; + this.groupBoxShowToolBarButtons.TabStop = false; + this.groupBoxShowToolBarButtons.Text = "Show toolbar buttons"; + // + // labelTBNetflixQualityCheck + // + this.labelTBNetflixQualityCheck.AutoSize = true; + this.labelTBNetflixQualityCheck.Location = new System.Drawing.Point(636, 136); + this.labelTBNetflixQualityCheck.Name = "labelTBNetflixQualityCheck"; + this.labelTBNetflixQualityCheck.Size = new System.Drawing.Size(103, 13); + this.labelTBNetflixQualityCheck.TabIndex = 42; + this.labelTBNetflixQualityCheck.Text = "Netflix quality check"; + // + // pictureBoxNetflixQualityCheck + // + this.pictureBoxNetflixQualityCheck.Location = new System.Drawing.Point(649, 155); + this.pictureBoxNetflixQualityCheck.Name = "pictureBoxNetflixQualityCheck"; + this.pictureBoxNetflixQualityCheck.Size = new System.Drawing.Size(32, 32); + this.pictureBoxNetflixQualityCheck.TabIndex = 41; + this.pictureBoxNetflixQualityCheck.TabStop = false; + // + // checkBoxNetflixQualityCheck + // + this.checkBoxNetflixQualityCheck.AutoSize = true; + this.checkBoxNetflixQualityCheck.Location = new System.Drawing.Point(652, 195); + this.checkBoxNetflixQualityCheck.Name = "checkBoxNetflixQualityCheck"; + this.checkBoxNetflixQualityCheck.Size = new System.Drawing.Size(55, 17); + this.checkBoxNetflixQualityCheck.TabIndex = 40; + this.checkBoxNetflixQualityCheck.Text = "Visible"; + this.checkBoxNetflixQualityCheck.UseVisualStyleBackColor = true; + // + // labelTBRemoveTextForHi + // + this.labelTBRemoveTextForHi.AutoSize = true; + this.labelTBRemoveTextForHi.Location = new System.Drawing.Point(124, 136); + this.labelTBRemoveTextForHi.Name = "labelTBRemoveTextForHi"; + this.labelTBRemoveTextForHi.Size = new System.Drawing.Size(100, 13); + this.labelTBRemoveTextForHi.TabIndex = 39; + this.labelTBRemoveTextForHi.Text = "Remove text for HI"; + // + // pictureBoxTBRemoveTextForHi + // + this.pictureBoxTBRemoveTextForHi.Location = new System.Drawing.Point(137, 155); + this.pictureBoxTBRemoveTextForHi.Name = "pictureBoxTBRemoveTextForHi"; + this.pictureBoxTBRemoveTextForHi.Size = new System.Drawing.Size(32, 32); + this.pictureBoxTBRemoveTextForHi.TabIndex = 38; + this.pictureBoxTBRemoveTextForHi.TabStop = false; + // + // checkBoxTBRemoveTextForHi + // + this.checkBoxTBRemoveTextForHi.AutoSize = true; + this.checkBoxTBRemoveTextForHi.Location = new System.Drawing.Point(140, 195); + this.checkBoxTBRemoveTextForHi.Name = "checkBoxTBRemoveTextForHi"; + this.checkBoxTBRemoveTextForHi.Size = new System.Drawing.Size(55, 17); + this.checkBoxTBRemoveTextForHi.TabIndex = 18; + this.checkBoxTBRemoveTextForHi.Text = "Visible"; + this.checkBoxTBRemoveTextForHi.UseVisualStyleBackColor = true; + // + // labelTBFixCommonErrors + // + this.labelTBFixCommonErrors.AutoSize = true; + this.labelTBFixCommonErrors.Location = new System.Drawing.Point(9, 136); + this.labelTBFixCommonErrors.Name = "labelTBFixCommonErrors"; + this.labelTBFixCommonErrors.Size = new System.Drawing.Size(95, 13); + this.labelTBFixCommonErrors.TabIndex = 36; + this.labelTBFixCommonErrors.Text = "Fix common errors"; + // + // pictureBoxTBFixCommonErrors + // + this.pictureBoxTBFixCommonErrors.Location = new System.Drawing.Point(22, 155); + this.pictureBoxTBFixCommonErrors.Name = "pictureBoxTBFixCommonErrors"; + this.pictureBoxTBFixCommonErrors.Size = new System.Drawing.Size(32, 32); + this.pictureBoxTBFixCommonErrors.TabIndex = 35; + this.pictureBoxTBFixCommonErrors.TabStop = false; + // + // checkBoxTBFixCommonErrors + // + this.checkBoxTBFixCommonErrors.AutoSize = true; + this.checkBoxTBFixCommonErrors.Location = new System.Drawing.Point(25, 195); + this.checkBoxTBFixCommonErrors.Name = "checkBoxTBFixCommonErrors"; + this.checkBoxTBFixCommonErrors.Size = new System.Drawing.Size(55, 17); + this.checkBoxTBFixCommonErrors.TabIndex = 17; + this.checkBoxTBFixCommonErrors.Text = "Visible"; + this.checkBoxTBFixCommonErrors.UseVisualStyleBackColor = true; + // + // labelTBHelp + // + this.labelTBHelp.AutoSize = true; + this.labelTBHelp.Location = new System.Drawing.Point(561, 136); + this.labelTBHelp.Name = "labelTBHelp"; + this.labelTBHelp.Size = new System.Drawing.Size(28, 13); + this.labelTBHelp.TabIndex = 33; + this.labelTBHelp.Text = "Help"; + // + // pictureBoxHelp + // + this.pictureBoxHelp.Location = new System.Drawing.Point(560, 155); + this.pictureBoxHelp.Name = "pictureBoxHelp"; + this.pictureBoxHelp.Size = new System.Drawing.Size(32, 32); + this.pictureBoxHelp.TabIndex = 32; + this.pictureBoxHelp.TabStop = false; + // + // checkBoxHelp + // + this.checkBoxHelp.AutoSize = true; + this.checkBoxHelp.Location = new System.Drawing.Point(563, 195); + this.checkBoxHelp.Name = "checkBoxHelp"; + this.checkBoxHelp.Size = new System.Drawing.Size(55, 17); + this.checkBoxHelp.TabIndex = 22; + this.checkBoxHelp.Text = "Visible"; + this.checkBoxHelp.UseVisualStyleBackColor = true; + // + // labelTBSettings + // + this.labelTBSettings.AutoSize = true; + this.labelTBSettings.Location = new System.Drawing.Point(456, 136); + this.labelTBSettings.Name = "labelTBSettings"; + this.labelTBSettings.Size = new System.Drawing.Size(46, 13); + this.labelTBSettings.TabIndex = 30; + this.labelTBSettings.Text = "Settings"; + // + // pictureBoxSettings + // + this.pictureBoxSettings.Location = new System.Drawing.Point(459, 155); + this.pictureBoxSettings.Name = "pictureBoxSettings"; + this.pictureBoxSettings.Size = new System.Drawing.Size(32, 32); + this.pictureBoxSettings.TabIndex = 29; + this.pictureBoxSettings.TabStop = false; + // + // checkBoxSettings + // + this.checkBoxSettings.AutoSize = true; + this.checkBoxSettings.Location = new System.Drawing.Point(462, 195); + this.checkBoxSettings.Name = "checkBoxSettings"; + this.checkBoxSettings.Size = new System.Drawing.Size(55, 17); + this.checkBoxSettings.TabIndex = 21; + this.checkBoxSettings.Text = "Visible"; + this.checkBoxSettings.UseVisualStyleBackColor = true; + // + // labelTBSpellCheck + // + this.labelTBSpellCheck.AutoSize = true; + this.labelTBSpellCheck.Location = new System.Drawing.Point(357, 136); + this.labelTBSpellCheck.Name = "labelTBSpellCheck"; + this.labelTBSpellCheck.Size = new System.Drawing.Size(59, 13); + this.labelTBSpellCheck.TabIndex = 27; + this.labelTBSpellCheck.Text = "Spell check"; + // + // pictureBoxSpellCheck + // + this.pictureBoxSpellCheck.Location = new System.Drawing.Point(361, 155); + this.pictureBoxSpellCheck.Name = "pictureBoxSpellCheck"; + this.pictureBoxSpellCheck.Size = new System.Drawing.Size(32, 32); + this.pictureBoxSpellCheck.TabIndex = 26; + this.pictureBoxSpellCheck.TabStop = false; + // + // checkBoxSpellCheck + // + this.checkBoxSpellCheck.AutoSize = true; + this.checkBoxSpellCheck.Location = new System.Drawing.Point(362, 195); + this.checkBoxSpellCheck.Name = "checkBoxSpellCheck"; + this.checkBoxSpellCheck.Size = new System.Drawing.Size(55, 17); + this.checkBoxSpellCheck.TabIndex = 20; + this.checkBoxSpellCheck.Text = "Visible"; + this.checkBoxSpellCheck.UseVisualStyleBackColor = true; + // + // labelTBVisualSync + // + this.labelTBVisualSync.AutoSize = true; + this.labelTBVisualSync.Location = new System.Drawing.Point(247, 136); + this.labelTBVisualSync.Name = "labelTBVisualSync"; + this.labelTBVisualSync.Size = new System.Drawing.Size(59, 13); + this.labelTBVisualSync.TabIndex = 21; + this.labelTBVisualSync.Text = "Visual sync"; + // + // pictureBoxVisualSync + // + this.pictureBoxVisualSync.Location = new System.Drawing.Point(260, 155); + this.pictureBoxVisualSync.Name = "pictureBoxVisualSync"; + this.pictureBoxVisualSync.Size = new System.Drawing.Size(32, 32); + this.pictureBoxVisualSync.TabIndex = 20; + this.pictureBoxVisualSync.TabStop = false; + // + // checkBoxVisualSync + // + this.checkBoxVisualSync.AutoSize = true; + this.checkBoxVisualSync.Location = new System.Drawing.Point(263, 195); + this.checkBoxVisualSync.Name = "checkBoxVisualSync"; + this.checkBoxVisualSync.Size = new System.Drawing.Size(55, 17); + this.checkBoxVisualSync.TabIndex = 19; + this.checkBoxVisualSync.Text = "Visible"; + this.checkBoxVisualSync.UseVisualStyleBackColor = true; + // + // labelTBReplace + // + this.labelTBReplace.AutoSize = true; + this.labelTBReplace.Location = new System.Drawing.Point(521, 22); + this.labelTBReplace.Name = "labelTBReplace"; + this.labelTBReplace.Size = new System.Drawing.Size(45, 13); + this.labelTBReplace.TabIndex = 18; + this.labelTBReplace.Text = "Replace"; + // + // pictureBoxReplace + // + this.pictureBoxReplace.Location = new System.Drawing.Point(526, 41); + this.pictureBoxReplace.Name = "pictureBoxReplace"; + this.pictureBoxReplace.Size = new System.Drawing.Size(32, 32); + this.pictureBoxReplace.TabIndex = 17; + this.pictureBoxReplace.TabStop = false; + // + // checkBoxReplace + // + this.checkBoxReplace.AutoSize = true; + this.checkBoxReplace.Location = new System.Drawing.Point(529, 81); + this.checkBoxReplace.Name = "checkBoxReplace"; + this.checkBoxReplace.Size = new System.Drawing.Size(55, 17); + this.checkBoxReplace.TabIndex = 16; + this.checkBoxReplace.Text = "Visible"; + this.checkBoxReplace.UseVisualStyleBackColor = true; + // + // labelTBFind + // + this.labelTBFind.AutoSize = true; + this.labelTBFind.Location = new System.Drawing.Point(425, 22); + this.labelTBFind.Name = "labelTBFind"; + this.labelTBFind.Size = new System.Drawing.Size(27, 13); + this.labelTBFind.TabIndex = 15; + this.labelTBFind.Text = "Find"; + // + // pictureBoxFind + // + this.pictureBoxFind.Location = new System.Drawing.Point(423, 41); + this.pictureBoxFind.Name = "pictureBoxFind"; + this.pictureBoxFind.Size = new System.Drawing.Size(32, 32); + this.pictureBoxFind.TabIndex = 14; + this.pictureBoxFind.TabStop = false; + // + // checkBoxToolbarFind + // + this.checkBoxToolbarFind.AutoSize = true; + this.checkBoxToolbarFind.Location = new System.Drawing.Point(426, 81); + this.checkBoxToolbarFind.Name = "checkBoxToolbarFind"; + this.checkBoxToolbarFind.Size = new System.Drawing.Size(55, 17); + this.checkBoxToolbarFind.TabIndex = 13; + this.checkBoxToolbarFind.Text = "Visible"; + this.checkBoxToolbarFind.UseVisualStyleBackColor = true; + // + // labelTBSaveAs + // + this.labelTBSaveAs.AutoSize = true; + this.labelTBSaveAs.Location = new System.Drawing.Point(316, 22); + this.labelTBSaveAs.Name = "labelTBSaveAs"; + this.labelTBSaveAs.Size = new System.Drawing.Size(45, 13); + this.labelTBSaveAs.TabIndex = 12; + this.labelTBSaveAs.Text = "Save as"; + // + // pictureBoxSaveAs + // + this.pictureBoxSaveAs.Location = new System.Drawing.Point(322, 41); + this.pictureBoxSaveAs.Name = "pictureBoxSaveAs"; + this.pictureBoxSaveAs.Size = new System.Drawing.Size(32, 32); + this.pictureBoxSaveAs.TabIndex = 11; + this.pictureBoxSaveAs.TabStop = false; + // + // checkBoxToolbarSaveAs + // + this.checkBoxToolbarSaveAs.AutoSize = true; + this.checkBoxToolbarSaveAs.Location = new System.Drawing.Point(325, 81); + this.checkBoxToolbarSaveAs.Name = "checkBoxToolbarSaveAs"; + this.checkBoxToolbarSaveAs.Size = new System.Drawing.Size(55, 17); + this.checkBoxToolbarSaveAs.TabIndex = 10; + this.checkBoxToolbarSaveAs.Text = "Visible"; + this.checkBoxToolbarSaveAs.UseVisualStyleBackColor = true; + // + // labelTBSave + // + this.labelTBSave.AutoSize = true; + this.labelTBSave.Location = new System.Drawing.Point(225, 22); + this.labelTBSave.Name = "labelTBSave"; + this.labelTBSave.Size = new System.Drawing.Size(31, 13); + this.labelTBSave.TabIndex = 9; + this.labelTBSave.Text = "Save"; + // + // pictureBoxSave + // + this.pictureBoxSave.Location = new System.Drawing.Point(224, 41); + this.pictureBoxSave.Name = "pictureBoxSave"; + this.pictureBoxSave.Size = new System.Drawing.Size(32, 32); + this.pictureBoxSave.TabIndex = 8; + this.pictureBoxSave.TabStop = false; + // + // checkBoxToolbarSave + // + this.checkBoxToolbarSave.AutoSize = true; + this.checkBoxToolbarSave.Location = new System.Drawing.Point(227, 81); + this.checkBoxToolbarSave.Name = "checkBoxToolbarSave"; + this.checkBoxToolbarSave.Size = new System.Drawing.Size(55, 17); + this.checkBoxToolbarSave.TabIndex = 7; + this.checkBoxToolbarSave.Text = "Visible"; + this.checkBoxToolbarSave.UseVisualStyleBackColor = true; + // + // labelTBOpen + // + this.labelTBOpen.AutoSize = true; + this.labelTBOpen.Location = new System.Drawing.Point(124, 22); + this.labelTBOpen.Name = "labelTBOpen"; + this.labelTBOpen.Size = new System.Drawing.Size(33, 13); + this.labelTBOpen.TabIndex = 6; + this.labelTBOpen.Text = "Open"; + // + // pictureBoxOpen + // + this.pictureBoxOpen.Location = new System.Drawing.Point(123, 41); + this.pictureBoxOpen.Name = "pictureBoxOpen"; + this.pictureBoxOpen.Size = new System.Drawing.Size(32, 32); + this.pictureBoxOpen.TabIndex = 5; + this.pictureBoxOpen.TabStop = false; + // + // checkBoxToolbarOpen + // + this.checkBoxToolbarOpen.AutoSize = true; + this.checkBoxToolbarOpen.Location = new System.Drawing.Point(126, 81); + this.checkBoxToolbarOpen.Name = "checkBoxToolbarOpen"; + this.checkBoxToolbarOpen.Size = new System.Drawing.Size(55, 17); + this.checkBoxToolbarOpen.TabIndex = 4; + this.checkBoxToolbarOpen.Text = "Visible"; + this.checkBoxToolbarOpen.UseVisualStyleBackColor = true; + // + // labelTBNew + // + this.labelTBNew.AutoSize = true; + this.labelTBNew.Location = new System.Drawing.Point(24, 22); + this.labelTBNew.Name = "labelTBNew"; + this.labelTBNew.Size = new System.Drawing.Size(28, 13); + this.labelTBNew.TabIndex = 3; + this.labelTBNew.Text = "New"; + // + // pictureBoxNew + // + this.pictureBoxNew.Location = new System.Drawing.Point(22, 41); + this.pictureBoxNew.Name = "pictureBoxNew"; + this.pictureBoxNew.Size = new System.Drawing.Size(32, 32); + this.pictureBoxNew.TabIndex = 2; + this.pictureBoxNew.TabStop = false; + // + // checkBoxToolbarNew + // + this.checkBoxToolbarNew.AutoSize = true; + this.checkBoxToolbarNew.Location = new System.Drawing.Point(25, 81); + this.checkBoxToolbarNew.Name = "checkBoxToolbarNew"; + this.checkBoxToolbarNew.Size = new System.Drawing.Size(55, 17); + this.checkBoxToolbarNew.TabIndex = 1; + this.checkBoxToolbarNew.Text = "Visible"; + this.checkBoxToolbarNew.UseVisualStyleBackColor = true; + // + // tabPageFont + // + this.tabPageFont.Controls.Add(this.groupBoxFont); + this.tabPageFont.Location = new System.Drawing.Point(4, 22); + this.tabPageFont.Name = "tabPageFont"; + this.tabPageFont.Size = new System.Drawing.Size(832, 520); + this.tabPageFont.TabIndex = 10; + this.tabPageFont.Text = "Font"; + this.tabPageFont.UseVisualStyleBackColor = true; + // + // groupBoxFont + // + this.groupBoxFont.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFont.Controls.Add(this.labelFontNote); + this.groupBoxFont.Controls.Add(this.groupBoxFontTextBox); + this.groupBoxFont.Controls.Add(this.groupBoxFontListViews); + this.groupBoxFont.Controls.Add(this.groupBoxFontGeneral); + this.groupBoxFont.Location = new System.Drawing.Point(3, 3); + this.groupBoxFont.Name = "groupBoxFont"; + this.groupBoxFont.Size = new System.Drawing.Size(826, 509); + this.groupBoxFont.TabIndex = 0; + this.groupBoxFont.TabStop = false; + this.groupBoxFont.Text = "Font in UI"; + // + // labelFontNote + // + this.labelFontNote.AutoSize = true; + this.labelFontNote.Location = new System.Drawing.Point(11, 352); + this.labelFontNote.Name = "labelFontNote"; + this.labelFontNote.Size = new System.Drawing.Size(278, 13); + this.labelFontNote.TabIndex = 41; + this.labelFontNote.Text = "Note: This is only to set the font in the Subtitle Edit UI..."; + // + // groupBoxFontTextBox + // + this.groupBoxFontTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFontTextBox.Controls.Add(this.panelTextBoxAssColor); + this.groupBoxFontTextBox.Controls.Add(this.buttonTextBoxAssColor); + this.groupBoxFontTextBox.Controls.Add(this.panelTextBoxHtmlColor); + this.groupBoxFontTextBox.Controls.Add(this.buttonTextBoxHtmlColor); + this.groupBoxFontTextBox.Controls.Add(this.checkBoxSubtitleTextBoxSyntaxColor); + this.groupBoxFontTextBox.Controls.Add(this.labelSubtitleFontSize); + this.groupBoxFontTextBox.Controls.Add(this.comboBoxSubtitleFontSize); + this.groupBoxFontTextBox.Controls.Add(this.checkBoxSubtitleFontBold); + this.groupBoxFontTextBox.Controls.Add(this.checkBoxSubtitleCenter); + this.groupBoxFontTextBox.Location = new System.Drawing.Point(14, 228); + this.groupBoxFontTextBox.Name = "groupBoxFontTextBox"; + this.groupBoxFontTextBox.Size = new System.Drawing.Size(806, 116); + this.groupBoxFontTextBox.TabIndex = 40; + this.groupBoxFontTextBox.TabStop = false; + this.groupBoxFontTextBox.Text = "Text box"; + // + // panelTextBoxAssColor + // + this.panelTextBoxAssColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelTextBoxAssColor.Location = new System.Drawing.Point(520, 73); + this.panelTextBoxAssColor.Name = "panelTextBoxAssColor"; + this.panelTextBoxAssColor.Size = new System.Drawing.Size(21, 20); + this.panelTextBoxAssColor.TabIndex = 38; + this.panelTextBoxAssColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelTextBoxAssColor_MouseClick); + // + // buttonTextBoxAssColor + // + this.buttonTextBoxAssColor.Location = new System.Drawing.Point(396, 72); + this.buttonTextBoxAssColor.Name = "buttonTextBoxAssColor"; + this.buttonTextBoxAssColor.Size = new System.Drawing.Size(112, 23); + this.buttonTextBoxAssColor.TabIndex = 36; + this.buttonTextBoxAssColor.Text = "ASSA color"; + this.buttonTextBoxAssColor.UseVisualStyleBackColor = true; + this.buttonTextBoxAssColor.Click += new System.EventHandler(this.buttonTextBoxAssColor_Click); + // + // panelTextBoxHtmlColor + // + this.panelTextBoxHtmlColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelTextBoxHtmlColor.Location = new System.Drawing.Point(520, 44); + this.panelTextBoxHtmlColor.Name = "panelTextBoxHtmlColor"; + this.panelTextBoxHtmlColor.Size = new System.Drawing.Size(21, 20); + this.panelTextBoxHtmlColor.TabIndex = 37; + this.panelTextBoxHtmlColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelTextBoxHtmlColor_MouseClick); + // + // buttonTextBoxHtmlColor + // + this.buttonTextBoxHtmlColor.Location = new System.Drawing.Point(396, 43); + this.buttonTextBoxHtmlColor.Name = "buttonTextBoxHtmlColor"; + this.buttonTextBoxHtmlColor.Size = new System.Drawing.Size(112, 23); + this.buttonTextBoxHtmlColor.TabIndex = 35; + this.buttonTextBoxHtmlColor.Text = "Html color"; + this.buttonTextBoxHtmlColor.UseVisualStyleBackColor = true; + this.buttonTextBoxHtmlColor.Click += new System.EventHandler(this.buttonTextBoxHtmlColor_Click); + // + // checkBoxSubtitleTextBoxSyntaxColor + // + this.checkBoxSubtitleTextBoxSyntaxColor.AutoSize = true; + this.checkBoxSubtitleTextBoxSyntaxColor.Location = new System.Drawing.Point(396, 20); + this.checkBoxSubtitleTextBoxSyntaxColor.Name = "checkBoxSubtitleTextBoxSyntaxColor"; + this.checkBoxSubtitleTextBoxSyntaxColor.Size = new System.Drawing.Size(120, 17); + this.checkBoxSubtitleTextBoxSyntaxColor.TabIndex = 34; + this.checkBoxSubtitleTextBoxSyntaxColor.Text = "Use syntax coloring"; + this.checkBoxSubtitleTextBoxSyntaxColor.UseVisualStyleBackColor = true; + this.checkBoxSubtitleTextBoxSyntaxColor.CheckedChanged += new System.EventHandler(this.checkBoxSubtitleTextBoxSyntaxColor_CheckedChanged); + // + // labelSubtitleFontSize + // + this.labelSubtitleFontSize.AutoSize = true; + this.labelSubtitleFontSize.Location = new System.Drawing.Point(18, 17); + this.labelSubtitleFontSize.Name = "labelSubtitleFontSize"; + this.labelSubtitleFontSize.Size = new System.Drawing.Size(87, 13); + this.labelSubtitleFontSize.TabIndex = 30; + this.labelSubtitleFontSize.Text = "Subtitle font size"; + // + // comboBoxSubtitleFontSize + // + this.comboBoxSubtitleFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSubtitleFontSize.FormattingEnabled = true; + this.comboBoxSubtitleFontSize.Items.AddRange(new object[] { + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17", + "18", + "19", + "20", + "21", + "22", + "23", + "24", + "25", + "26", + "27", + "28", + "29", + "30"}); + this.comboBoxSubtitleFontSize.Location = new System.Drawing.Point(215, 14); + this.comboBoxSubtitleFontSize.Name = "comboBoxSubtitleFontSize"; + this.comboBoxSubtitleFontSize.Size = new System.Drawing.Size(73, 21); + this.comboBoxSubtitleFontSize.TabIndex = 31; + // + // checkBoxSubtitleFontBold + // + this.checkBoxSubtitleFontBold.AutoSize = true; + this.checkBoxSubtitleFontBold.Location = new System.Drawing.Point(215, 41); + this.checkBoxSubtitleFontBold.Name = "checkBoxSubtitleFontBold"; + this.checkBoxSubtitleFontBold.Size = new System.Drawing.Size(46, 17); + this.checkBoxSubtitleFontBold.TabIndex = 32; + this.checkBoxSubtitleFontBold.Text = "Bold"; + this.checkBoxSubtitleFontBold.UseVisualStyleBackColor = true; + // + // checkBoxSubtitleCenter + // + this.checkBoxSubtitleCenter.AutoSize = true; + this.checkBoxSubtitleCenter.Location = new System.Drawing.Point(215, 64); + this.checkBoxSubtitleCenter.Name = "checkBoxSubtitleCenter"; + this.checkBoxSubtitleCenter.Size = new System.Drawing.Size(59, 17); + this.checkBoxSubtitleCenter.TabIndex = 33; + this.checkBoxSubtitleCenter.Text = "Center"; + this.checkBoxSubtitleCenter.UseVisualStyleBackColor = true; + // + // groupBoxFontListViews + // + this.groupBoxFontListViews.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFontListViews.Controls.Add(this.labelSubtitleListViewFontSize); + this.groupBoxFontListViews.Controls.Add(this.comboBoxSubtitleListViewFontSize); + this.groupBoxFontListViews.Controls.Add(this.checkBoxSubtitleListViewFontBold); + this.groupBoxFontListViews.Location = new System.Drawing.Point(14, 141); + this.groupBoxFontListViews.Name = "groupBoxFontListViews"; + this.groupBoxFontListViews.Size = new System.Drawing.Size(806, 81); + this.groupBoxFontListViews.TabIndex = 39; + this.groupBoxFontListViews.TabStop = false; + this.groupBoxFontListViews.Text = "List view"; + // + // labelSubtitleListViewFontSize + // + this.labelSubtitleListViewFontSize.AutoSize = true; + this.labelSubtitleListViewFontSize.Location = new System.Drawing.Point(13, 17); + this.labelSubtitleListViewFontSize.Name = "labelSubtitleListViewFontSize"; + this.labelSubtitleListViewFontSize.Size = new System.Drawing.Size(87, 13); + this.labelSubtitleListViewFontSize.TabIndex = 33; + this.labelSubtitleListViewFontSize.Text = "Subtitle font size"; + // + // comboBoxSubtitleListViewFontSize + // + this.comboBoxSubtitleListViewFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSubtitleListViewFontSize.FormattingEnabled = true; + this.comboBoxSubtitleListViewFontSize.Items.AddRange(new object[] { + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17", + "18", + "19", + "20"}); + this.comboBoxSubtitleListViewFontSize.Location = new System.Drawing.Point(210, 14); + this.comboBoxSubtitleListViewFontSize.Name = "comboBoxSubtitleListViewFontSize"; + this.comboBoxSubtitleListViewFontSize.Size = new System.Drawing.Size(73, 21); + this.comboBoxSubtitleListViewFontSize.TabIndex = 34; + // + // checkBoxSubtitleListViewFontBold + // + this.checkBoxSubtitleListViewFontBold.AutoSize = true; + this.checkBoxSubtitleListViewFontBold.Location = new System.Drawing.Point(210, 41); + this.checkBoxSubtitleListViewFontBold.Name = "checkBoxSubtitleListViewFontBold"; + this.checkBoxSubtitleListViewFontBold.Size = new System.Drawing.Size(46, 17); + this.checkBoxSubtitleListViewFontBold.TabIndex = 35; + this.checkBoxSubtitleListViewFontBold.Text = "Bold"; + this.checkBoxSubtitleListViewFontBold.UseVisualStyleBackColor = true; + // + // groupBoxFontGeneral + // + this.groupBoxFontGeneral.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxFontGeneral.Controls.Add(this.comboBoxSubtitleFont); + this.groupBoxFontGeneral.Controls.Add(this.labelSubtitleFont); + this.groupBoxFontGeneral.Controls.Add(this.panelSubtitleFontColor); + this.groupBoxFontGeneral.Controls.Add(this.labelSubtitleFontColor); + this.groupBoxFontGeneral.Controls.Add(this.panelSubtitleBackgroundColor); + this.groupBoxFontGeneral.Controls.Add(this.labelSubtitleFontBackgroundColor); + this.groupBoxFontGeneral.Location = new System.Drawing.Point(14, 20); + this.groupBoxFontGeneral.Name = "groupBoxFontGeneral"; + this.groupBoxFontGeneral.Size = new System.Drawing.Size(806, 115); + this.groupBoxFontGeneral.TabIndex = 38; + this.groupBoxFontGeneral.TabStop = false; + this.groupBoxFontGeneral.Text = "General"; + // + // comboBoxSubtitleFont + // + this.comboBoxSubtitleFont.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSubtitleFont.FormattingEnabled = true; + this.comboBoxSubtitleFont.Location = new System.Drawing.Point(210, 20); + this.comboBoxSubtitleFont.Name = "comboBoxSubtitleFont"; + this.comboBoxSubtitleFont.Size = new System.Drawing.Size(188, 21); + this.comboBoxSubtitleFont.TabIndex = 29; + // + // labelSubtitleFont + // + this.labelSubtitleFont.AutoSize = true; + this.labelSubtitleFont.Location = new System.Drawing.Point(13, 26); + this.labelSubtitleFont.Name = "labelSubtitleFont"; + this.labelSubtitleFont.Size = new System.Drawing.Size(66, 13); + this.labelSubtitleFont.TabIndex = 28; + this.labelSubtitleFont.Text = "Subtitle font"; + // + // panelSubtitleFontColor + // + this.panelSubtitleFontColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelSubtitleFontColor.Location = new System.Drawing.Point(210, 51); + this.panelSubtitleFontColor.Name = "panelSubtitleFontColor"; + this.panelSubtitleFontColor.Size = new System.Drawing.Size(46, 15); + this.panelSubtitleFontColor.TabIndex = 35; + this.panelSubtitleFontColor.Click += new System.EventHandler(this.panelSubtitleFontColor_Click); + // + // labelSubtitleFontColor + // + this.labelSubtitleFontColor.AutoSize = true; + this.labelSubtitleFontColor.Location = new System.Drawing.Point(13, 50); + this.labelSubtitleFontColor.Name = "labelSubtitleFontColor"; + this.labelSubtitleFontColor.Size = new System.Drawing.Size(92, 13); + this.labelSubtitleFontColor.TabIndex = 34; + this.labelSubtitleFontColor.Text = "Subtitle font color"; + // + // panelSubtitleBackgroundColor + // + this.panelSubtitleBackgroundColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelSubtitleBackgroundColor.Location = new System.Drawing.Point(210, 71); + this.panelSubtitleBackgroundColor.Name = "panelSubtitleBackgroundColor"; + this.panelSubtitleBackgroundColor.Size = new System.Drawing.Size(46, 15); + this.panelSubtitleBackgroundColor.TabIndex = 37; + this.panelSubtitleBackgroundColor.Click += new System.EventHandler(this.panelSubtitleBackgroundColor_Click); + // + // labelSubtitleFontBackgroundColor + // + this.labelSubtitleFontBackgroundColor.AutoSize = true; + this.labelSubtitleFontBackgroundColor.Location = new System.Drawing.Point(13, 70); + this.labelSubtitleFontBackgroundColor.Name = "labelSubtitleFontBackgroundColor"; + this.labelSubtitleFontBackgroundColor.Size = new System.Drawing.Size(151, 13); + this.labelSubtitleFontBackgroundColor.TabIndex = 36; + this.labelSubtitleFontBackgroundColor.Text = "Subtitle font background color"; + // + // tabPageSsaStyle + // + this.tabPageSsaStyle.Controls.Add(this.groupBoxSsaStyle); + this.tabPageSsaStyle.Location = new System.Drawing.Point(4, 22); + this.tabPageSsaStyle.Name = "tabPageSsaStyle"; + this.tabPageSsaStyle.Padding = new System.Windows.Forms.Padding(3); + this.tabPageSsaStyle.Size = new System.Drawing.Size(832, 520); + this.tabPageSsaStyle.TabIndex = 1; + this.tabPageSsaStyle.Text = "SSA style"; + this.tabPageSsaStyle.UseVisualStyleBackColor = true; + // + // groupBoxSsaStyle + // + this.groupBoxSsaStyle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxSsaStyle.Controls.Add(this.groupBoxSsaBorder); + this.groupBoxSsaStyle.Controls.Add(this.groupSsaBoxFont); + this.groupBoxSsaStyle.Controls.Add(this.groupBoxMargins); + this.groupBoxSsaStyle.Controls.Add(this.groupBoxPreview); + this.groupBoxSsaStyle.Location = new System.Drawing.Point(6, 6); + this.groupBoxSsaStyle.Name = "groupBoxSsaStyle"; + this.groupBoxSsaStyle.Size = new System.Drawing.Size(819, 456); + this.groupBoxSsaStyle.TabIndex = 0; + this.groupBoxSsaStyle.TabStop = false; + this.groupBoxSsaStyle.Text = "Sub Station Alpha style"; + // + // groupBoxSsaBorder + // + this.groupBoxSsaBorder.Controls.Add(this.numericUpDownSsaOutline); + this.groupBoxSsaBorder.Controls.Add(this.labelSsaShadow); + this.groupBoxSsaBorder.Controls.Add(this.numericUpDownSsaShadow); + this.groupBoxSsaBorder.Controls.Add(this.checkBoxSsaOpaqueBox); + this.groupBoxSsaBorder.Controls.Add(this.labelSsaOutline); + this.groupBoxSsaBorder.Location = new System.Drawing.Point(329, 21); + this.groupBoxSsaBorder.Name = "groupBoxSsaBorder"; + this.groupBoxSsaBorder.Size = new System.Drawing.Size(185, 96); + this.groupBoxSsaBorder.TabIndex = 8; + this.groupBoxSsaBorder.TabStop = false; + this.groupBoxSsaBorder.Text = "Border"; + // + // numericUpDownSsaOutline + // + this.numericUpDownSsaOutline.Location = new System.Drawing.Point(64, 16); + this.numericUpDownSsaOutline.Maximum = new decimal(new int[] { + 9, + 0, + 0, + 0}); + this.numericUpDownSsaOutline.Name = "numericUpDownSsaOutline"; + this.numericUpDownSsaOutline.Size = new System.Drawing.Size(44, 21); + this.numericUpDownSsaOutline.TabIndex = 5; + this.numericUpDownSsaOutline.ValueChanged += new System.EventHandler(this.numericUpDownSsaOutline_ValueChanged); + // + // labelSsaShadow + // + this.labelSsaShadow.AutoSize = true; + this.labelSsaShadow.Location = new System.Drawing.Point(10, 45); + this.labelSsaShadow.Name = "labelSsaShadow"; + this.labelSsaShadow.Size = new System.Drawing.Size(45, 13); + this.labelSsaShadow.TabIndex = 6; + this.labelSsaShadow.Text = "Shadow"; + // + // numericUpDownSsaShadow + // + this.numericUpDownSsaShadow.Location = new System.Drawing.Point(64, 43); + this.numericUpDownSsaShadow.Maximum = new decimal(new int[] { + 9, + 0, + 0, + 0}); + this.numericUpDownSsaShadow.Name = "numericUpDownSsaShadow"; + this.numericUpDownSsaShadow.Size = new System.Drawing.Size(44, 21); + this.numericUpDownSsaShadow.TabIndex = 7; + this.numericUpDownSsaShadow.ValueChanged += new System.EventHandler(this.numericUpDownSsaShadow_ValueChanged); + // + // checkBoxSsaOpaqueBox + // + this.checkBoxSsaOpaqueBox.AutoSize = true; + this.checkBoxSsaOpaqueBox.Location = new System.Drawing.Point(13, 71); + this.checkBoxSsaOpaqueBox.Name = "checkBoxSsaOpaqueBox"; + this.checkBoxSsaOpaqueBox.Size = new System.Drawing.Size(85, 17); + this.checkBoxSsaOpaqueBox.TabIndex = 8; + this.checkBoxSsaOpaqueBox.Text = "Opaque box"; + this.checkBoxSsaOpaqueBox.UseVisualStyleBackColor = true; + this.checkBoxSsaOpaqueBox.CheckedChanged += new System.EventHandler(this.checkBoxSsaOpaqueBox_CheckedChanged); + // + // labelSsaOutline + // + this.labelSsaOutline.AutoSize = true; + this.labelSsaOutline.Location = new System.Drawing.Point(10, 20); + this.labelSsaOutline.Name = "labelSsaOutline"; + this.labelSsaOutline.Size = new System.Drawing.Size(41, 13); + this.labelSsaOutline.TabIndex = 4; + this.labelSsaOutline.Text = "Outline"; + // + // groupSsaBoxFont + // + this.groupSsaBoxFont.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupSsaBoxFont.Controls.Add(this.checkBoxSsaFontBold); + this.groupSsaBoxFont.Controls.Add(this.buttonSsaColor); + this.groupSsaBoxFont.Controls.Add(this.panelPrimaryColor); + this.groupSsaBoxFont.Controls.Add(this.numericUpDownFontSize); + this.groupSsaBoxFont.Controls.Add(this.comboBoxFontName); + this.groupSsaBoxFont.Controls.Add(this.labelSsaFontSize); + this.groupSsaBoxFont.Controls.Add(this.labelFontName); + this.groupSsaBoxFont.Location = new System.Drawing.Point(6, 20); + this.groupSsaBoxFont.Name = "groupSsaBoxFont"; + this.groupSsaBoxFont.Size = new System.Drawing.Size(323, 97); + this.groupSsaBoxFont.TabIndex = 7; + this.groupSsaBoxFont.TabStop = false; + this.groupSsaBoxFont.Text = "Font"; + // + // checkBoxSsaFontBold + // + this.checkBoxSsaFontBold.AutoSize = true; + this.checkBoxSsaFontBold.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.checkBoxSsaFontBold.Location = new System.Drawing.Point(184, 45); + this.checkBoxSsaFontBold.Name = "checkBoxSsaFontBold"; + this.checkBoxSsaFontBold.Size = new System.Drawing.Size(51, 17); + this.checkBoxSsaFontBold.TabIndex = 7; + this.checkBoxSsaFontBold.Text = "Bold"; + this.checkBoxSsaFontBold.UseVisualStyleBackColor = true; + this.checkBoxSsaFontBold.CheckedChanged += new System.EventHandler(this.checkBoxSsaFontBold_CheckedChanged); + // + // buttonSsaColor + // + this.buttonSsaColor.Location = new System.Drawing.Point(6, 66); + this.buttonSsaColor.Name = "buttonSsaColor"; + this.buttonSsaColor.Size = new System.Drawing.Size(109, 23); + this.buttonSsaColor.TabIndex = 6; + this.buttonSsaColor.Text = "Choose color"; + this.buttonSsaColor.UseVisualStyleBackColor = true; + this.buttonSsaColor.Click += new System.EventHandler(this.buttonSsaColor_Click); + // + // panelPrimaryColor + // + this.panelPrimaryColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelPrimaryColor.Location = new System.Drawing.Point(121, 68); + this.panelPrimaryColor.Name = "panelPrimaryColor"; + this.panelPrimaryColor.Size = new System.Drawing.Size(21, 20); + this.panelPrimaryColor.TabIndex = 4; + this.panelPrimaryColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelPrimaryColor_MouseClick); + // + // numericUpDownFontSize + // + this.numericUpDownFontSize.Location = new System.Drawing.Point(121, 44); + this.numericUpDownFontSize.Maximum = new decimal(new int[] { + 200, + 0, + 0, + 0}); + this.numericUpDownFontSize.Name = "numericUpDownFontSize"; + this.numericUpDownFontSize.Size = new System.Drawing.Size(51, 21); + this.numericUpDownFontSize.TabIndex = 3; + this.numericUpDownFontSize.ValueChanged += new System.EventHandler(this.numericUpDownFontSize_ValueChanged); + // + // comboBoxFontName + // + this.comboBoxFontName.FormattingEnabled = true; + this.comboBoxFontName.Location = new System.Drawing.Point(121, 17); + this.comboBoxFontName.Name = "comboBoxFontName"; + this.comboBoxFontName.Size = new System.Drawing.Size(188, 21); + this.comboBoxFontName.TabIndex = 1; + this.comboBoxFontName.TextChanged += new System.EventHandler(this.comboBoxFontName_TextChanged); + // + // labelSsaFontSize + // + this.labelSsaFontSize.AutoSize = true; + this.labelSsaFontSize.Location = new System.Drawing.Point(10, 46); + this.labelSsaFontSize.Name = "labelSsaFontSize"; + this.labelSsaFontSize.Size = new System.Drawing.Size(50, 13); + this.labelSsaFontSize.TabIndex = 2; + this.labelSsaFontSize.Text = "Font size"; + // + // labelFontName + // + this.labelFontName.AutoSize = true; + this.labelFontName.Location = new System.Drawing.Point(10, 20); + this.labelFontName.Name = "labelFontName"; + this.labelFontName.Size = new System.Drawing.Size(58, 13); + this.labelFontName.TabIndex = 0; + this.labelFontName.Text = "Font name"; + // + // groupBoxMargins + // + this.groupBoxMargins.Controls.Add(this.numericUpDownSsaMarginVertical); + this.groupBoxMargins.Controls.Add(this.numericUpDownSsaMarginRight); + this.groupBoxMargins.Controls.Add(this.numericUpDownSsaMarginLeft); + this.groupBoxMargins.Controls.Add(this.labelMarginVertical); + this.groupBoxMargins.Controls.Add(this.labelMarginRight); + this.groupBoxMargins.Controls.Add(this.labelMarginLeft); + this.groupBoxMargins.Location = new System.Drawing.Point(520, 20); + this.groupBoxMargins.Name = "groupBoxMargins"; + this.groupBoxMargins.Size = new System.Drawing.Size(281, 97); + this.groupBoxMargins.TabIndex = 9; + this.groupBoxMargins.TabStop = false; + this.groupBoxMargins.Text = "Margins"; + // + // numericUpDownSsaMarginVertical + // + this.numericUpDownSsaMarginVertical.Location = new System.Drawing.Point(168, 33); + this.numericUpDownSsaMarginVertical.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownSsaMarginVertical.Name = "numericUpDownSsaMarginVertical"; + this.numericUpDownSsaMarginVertical.Size = new System.Drawing.Size(44, 21); + this.numericUpDownSsaMarginVertical.TabIndex = 5; + this.numericUpDownSsaMarginVertical.ValueChanged += new System.EventHandler(this.numericUpDownSsaMarginVertical_ValueChanged); + // + // numericUpDownSsaMarginRight + // + this.numericUpDownSsaMarginRight.Location = new System.Drawing.Point(93, 33); + this.numericUpDownSsaMarginRight.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownSsaMarginRight.Name = "numericUpDownSsaMarginRight"; + this.numericUpDownSsaMarginRight.Size = new System.Drawing.Size(44, 21); + this.numericUpDownSsaMarginRight.TabIndex = 3; + // + // numericUpDownSsaMarginLeft + // + this.numericUpDownSsaMarginLeft.Location = new System.Drawing.Point(16, 33); + this.numericUpDownSsaMarginLeft.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownSsaMarginLeft.Name = "numericUpDownSsaMarginLeft"; + this.numericUpDownSsaMarginLeft.Size = new System.Drawing.Size(44, 21); + this.numericUpDownSsaMarginLeft.TabIndex = 1; + // + // labelMarginVertical + // + this.labelMarginVertical.AutoSize = true; + this.labelMarginVertical.Location = new System.Drawing.Point(165, 17); + this.labelMarginVertical.Name = "labelMarginVertical"; + this.labelMarginVertical.Size = new System.Drawing.Size(42, 13); + this.labelMarginVertical.TabIndex = 4; + this.labelMarginVertical.Text = "Vertical"; + // + // labelMarginRight + // + this.labelMarginRight.AutoSize = true; + this.labelMarginRight.Location = new System.Drawing.Point(90, 16); + this.labelMarginRight.Name = "labelMarginRight"; + this.labelMarginRight.Size = new System.Drawing.Size(32, 13); + this.labelMarginRight.TabIndex = 2; + this.labelMarginRight.Text = "Right"; + // + // labelMarginLeft + // + this.labelMarginLeft.AutoSize = true; + this.labelMarginLeft.Location = new System.Drawing.Point(13, 16); + this.labelMarginLeft.Name = "labelMarginLeft"; + this.labelMarginLeft.Size = new System.Drawing.Size(26, 13); + this.labelMarginLeft.TabIndex = 0; + this.labelMarginLeft.Text = "Left"; + // + // groupBoxPreview + // + this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxPreview.Controls.Add(this.pictureBoxPreview); + this.groupBoxPreview.Location = new System.Drawing.Point(6, 118); + this.groupBoxPreview.Name = "groupBoxPreview"; + this.groupBoxPreview.Size = new System.Drawing.Size(807, 332); + this.groupBoxPreview.TabIndex = 10; + this.groupBoxPreview.TabStop = false; + this.groupBoxPreview.Text = "Preview"; + // + // pictureBoxPreview + // + this.pictureBoxPreview.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxPreview.Location = new System.Drawing.Point(3, 17); + this.pictureBoxPreview.Name = "pictureBoxPreview"; + this.pictureBoxPreview.Size = new System.Drawing.Size(801, 312); + this.pictureBoxPreview.TabIndex = 0; + this.pictureBoxPreview.TabStop = false; + this.pictureBoxPreview.Click += new System.EventHandler(this.pictureBoxPreview_Click); + // + // tabPageNetwork + // + this.tabPageNetwork.Controls.Add(this.groupBoxNetworkSession); + this.tabPageNetwork.Controls.Add(this.groupBoxProxySettings); + this.tabPageNetwork.Location = new System.Drawing.Point(4, 22); + this.tabPageNetwork.Name = "tabPageNetwork"; + this.tabPageNetwork.Padding = new System.Windows.Forms.Padding(3); + this.tabPageNetwork.Size = new System.Drawing.Size(832, 520); + this.tabPageNetwork.TabIndex = 4; + this.tabPageNetwork.Text = "Network"; + this.tabPageNetwork.UseVisualStyleBackColor = true; + // + // groupBoxNetworkSession + // + this.groupBoxNetworkSession.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxNetworkSession.Controls.Add(this.buttonNetworkSessionNewMessageSound); + this.groupBoxNetworkSession.Controls.Add(this.textBoxNetworkSessionNewMessageSound); + this.groupBoxNetworkSession.Controls.Add(this.labelNetworkSessionNewMessageSound); + this.groupBoxNetworkSession.Location = new System.Drawing.Point(6, 189); + this.groupBoxNetworkSession.Name = "groupBoxNetworkSession"; + this.groupBoxNetworkSession.Size = new System.Drawing.Size(819, 320); + this.groupBoxNetworkSession.TabIndex = 30; + this.groupBoxNetworkSession.TabStop = false; + this.groupBoxNetworkSession.Text = "Network session settings"; + // + // buttonNetworkSessionNewMessageSound + // + this.buttonNetworkSessionNewMessageSound.Location = new System.Drawing.Point(352, 49); + this.buttonNetworkSessionNewMessageSound.Name = "buttonNetworkSessionNewMessageSound"; + this.buttonNetworkSessionNewMessageSound.Size = new System.Drawing.Size(29, 21); + this.buttonNetworkSessionNewMessageSound.TabIndex = 24; + this.buttonNetworkSessionNewMessageSound.Text = "..."; + this.buttonNetworkSessionNewMessageSound.UseVisualStyleBackColor = true; + this.buttonNetworkSessionNewMessageSound.Click += new System.EventHandler(this.buttonNetworkSessionNewMessageSound_Click); + // + // textBoxNetworkSessionNewMessageSound + // + this.textBoxNetworkSessionNewMessageSound.Location = new System.Drawing.Point(28, 50); + this.textBoxNetworkSessionNewMessageSound.Name = "textBoxNetworkSessionNewMessageSound"; + this.textBoxNetworkSessionNewMessageSound.Size = new System.Drawing.Size(318, 21); + this.textBoxNetworkSessionNewMessageSound.TabIndex = 20; + // + // labelNetworkSessionNewMessageSound + // + this.labelNetworkSessionNewMessageSound.AutoSize = true; + this.labelNetworkSessionNewMessageSound.Location = new System.Drawing.Point(25, 34); + this.labelNetworkSessionNewMessageSound.Name = "labelNetworkSessionNewMessageSound"; + this.labelNetworkSessionNewMessageSound.Size = new System.Drawing.Size(209, 13); + this.labelNetworkSessionNewMessageSound.TabIndex = 3; + this.labelNetworkSessionNewMessageSound.Text = "Play sound file when new message arrives"; + // + // groupBoxProxySettings + // + this.groupBoxProxySettings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxProxySettings.Controls.Add(this.groupBoxProxyAuthentication); + this.groupBoxProxySettings.Controls.Add(this.textBoxProxyAddress); + this.groupBoxProxySettings.Controls.Add(this.labelProxyAddress); + this.groupBoxProxySettings.Location = new System.Drawing.Point(6, 6); + this.groupBoxProxySettings.Name = "groupBoxProxySettings"; + this.groupBoxProxySettings.Size = new System.Drawing.Size(819, 177); + this.groupBoxProxySettings.TabIndex = 1; + this.groupBoxProxySettings.TabStop = false; + this.groupBoxProxySettings.Text = "Proxy server settings"; + // + // groupBoxProxyAuthentication + // + this.groupBoxProxyAuthentication.Controls.Add(this.textBoxProxyDomain); + this.groupBoxProxyAuthentication.Controls.Add(this.labelProxyDomain); + this.groupBoxProxyAuthentication.Controls.Add(this.textBoxProxyUserName); + this.groupBoxProxyAuthentication.Controls.Add(this.labelProxyPassword); + this.groupBoxProxyAuthentication.Controls.Add(this.labelProxyUserName); + this.groupBoxProxyAuthentication.Controls.Add(this.textBoxProxyPassword); + this.groupBoxProxyAuthentication.Location = new System.Drawing.Point(28, 60); + this.groupBoxProxyAuthentication.Name = "groupBoxProxyAuthentication"; + this.groupBoxProxyAuthentication.Size = new System.Drawing.Size(318, 101); + this.groupBoxProxyAuthentication.TabIndex = 29; + this.groupBoxProxyAuthentication.TabStop = false; + this.groupBoxProxyAuthentication.Text = "Authentication"; + // + // textBoxProxyDomain + // + this.textBoxProxyDomain.Location = new System.Drawing.Point(106, 71); + this.textBoxProxyDomain.Name = "textBoxProxyDomain"; + this.textBoxProxyDomain.Size = new System.Drawing.Size(192, 21); + this.textBoxProxyDomain.TabIndex = 30; + // + // labelProxyDomain + // + this.labelProxyDomain.AutoSize = true; + this.labelProxyDomain.Location = new System.Drawing.Point(12, 74); + this.labelProxyDomain.Name = "labelProxyDomain"; + this.labelProxyDomain.Size = new System.Drawing.Size(42, 13); + this.labelProxyDomain.TabIndex = 29; + this.labelProxyDomain.Text = "Domain"; + // + // textBoxProxyUserName + // + this.textBoxProxyUserName.Location = new System.Drawing.Point(106, 19); + this.textBoxProxyUserName.Name = "textBoxProxyUserName"; + this.textBoxProxyUserName.Size = new System.Drawing.Size(192, 21); + this.textBoxProxyUserName.TabIndex = 22; + // + // labelProxyPassword + // + this.labelProxyPassword.AutoSize = true; + this.labelProxyPassword.Location = new System.Drawing.Point(12, 48); + this.labelProxyPassword.Name = "labelProxyPassword"; + this.labelProxyPassword.Size = new System.Drawing.Size(53, 13); + this.labelProxyPassword.TabIndex = 28; + this.labelProxyPassword.Text = "Password"; + // + // labelProxyUserName + // + this.labelProxyUserName.AutoSize = true; + this.labelProxyUserName.Location = new System.Drawing.Point(12, 22); + this.labelProxyUserName.Name = "labelProxyUserName"; + this.labelProxyUserName.Size = new System.Drawing.Size(58, 13); + this.labelProxyUserName.TabIndex = 2; + this.labelProxyUserName.Text = "User name"; + // + // textBoxProxyPassword + // + this.textBoxProxyPassword.Location = new System.Drawing.Point(106, 45); + this.textBoxProxyPassword.Name = "textBoxProxyPassword"; + this.textBoxProxyPassword.Size = new System.Drawing.Size(192, 21); + this.textBoxProxyPassword.TabIndex = 24; + this.textBoxProxyPassword.UseSystemPasswordChar = true; + // + // textBoxProxyAddress + // + this.textBoxProxyAddress.Location = new System.Drawing.Point(134, 34); + this.textBoxProxyAddress.Name = "textBoxProxyAddress"; + this.textBoxProxyAddress.Size = new System.Drawing.Size(192, 21); + this.textBoxProxyAddress.TabIndex = 20; + // + // labelProxyAddress + // + this.labelProxyAddress.AutoSize = true; + this.labelProxyAddress.Location = new System.Drawing.Point(25, 34); + this.labelProxyAddress.Name = "labelProxyAddress"; + this.labelProxyAddress.Size = new System.Drawing.Size(76, 13); + this.labelProxyAddress.TabIndex = 3; + this.labelProxyAddress.Text = "Proxy address"; + // + // labelStatus + // + this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(12, 573); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(60, 13); + this.labelStatus.TabIndex = 3; + this.labelStatus.Text = "labelStatus"; + // + // openFileDialogFFmpeg + // + this.openFileDialogFFmpeg.FileName = "openFileDialog1"; + // + // buttonReset + // + this.buttonReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonReset.Location = new System.Drawing.Point(668, 563); + this.buttonReset.Name = "buttonReset"; + this.buttonReset.Size = new System.Drawing.Size(185, 23); + this.buttonReset.TabIndex = 2; + this.buttonReset.Text = "Restore default settings"; + this.buttonReset.UseVisualStyleBackColor = true; + this.buttonReset.Click += new System.EventHandler(this.buttonReset_Click); + // + // toolTipContinuationPreview + // + this.toolTipContinuationPreview.AutoPopDelay = 60000; + this.toolTipContinuationPreview.InitialDelay = 500; + this.toolTipContinuationPreview.ReshowDelay = 100; + // + // Settings + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(865, 598); + this.Controls.Add(this.buttonReset); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.tabControlSettings); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Settings"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Settings"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormSettings_KeyDown); + this.tabControlSettings.ResumeLayout(false); + this.tabPageGeneral.ResumeLayout(false); + this.groupBoxMiscellaneous.ResumeLayout(false); + this.groupBoxMiscellaneous.PerformLayout(); + this.groupBoxGeneralRules.ResumeLayout(false); + this.groupBoxGeneralRules.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownOptimalCharsSec)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxWordsMin)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxNumberOfLines)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMin)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDurationMax)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinGapMs)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxCharsSec)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSubtitleLineMaximumLength)).EndInit(); + this.tabPageShortcuts.ResumeLayout(false); + this.groupBoxShortcuts.ResumeLayout(false); + this.groupBoxShortcuts.PerformLayout(); + this.contextMenuStripShortcuts.ResumeLayout(false); + this.tabPageSyntaxColoring.ResumeLayout(false); + this.groupBoxListViewSyntaxColoring.ResumeLayout(false); + this.groupBoxListViewSyntaxColoring.PerformLayout(); + this.tabPageVideoPlayer.ResumeLayout(false); + this.groupBoxMainWindowVideoControls.ResumeLayout(false); + this.groupBoxMainWindowVideoControls.PerformLayout(); + this.groupBoxVideoPlayerDefault.ResumeLayout(false); + this.groupBoxVideoPlayerDefault.PerformLayout(); + this.groupBoxVideoEngine.ResumeLayout(false); + this.groupBoxVideoEngine.PerformLayout(); + this.tabPageWaveform.ResumeLayout(false); + this.groupBoxFfmpeg.ResumeLayout(false); + this.groupBoxFfmpeg.PerformLayout(); + this.groupBoxSpectrogram.ResumeLayout(false); + this.groupBoxSpectrogram.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBoxWaveformAppearence.ResumeLayout(false); + this.groupBoxWaveformAppearence.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWaveformBorderHitMs)).EndInit(); + this.tabPageTools.ResumeLayout(false); + this.groupBoxGoogleTranslate.ResumeLayout(false); + this.groupBoxGoogleTranslate.PerformLayout(); + this.groupBoxBing.ResumeLayout(false); + this.groupBoxBing.PerformLayout(); + this.groupBoxToolsAutoBr.ResumeLayout(false); + this.groupBoxToolsAutoBr.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownToolsBreakPreferBottomHeavy)).EndInit(); + this.groupBoxSpellCheck.ResumeLayout(false); + this.groupBoxSpellCheck.PerformLayout(); + this.groupBoxFixCommonErrors.ResumeLayout(false); + this.groupBoxFixCommonErrors.PerformLayout(); + this.groupBoxToolsVisualSync.ResumeLayout(false); + this.groupBoxToolsVisualSync.PerformLayout(); + this.tabPageWordLists.ResumeLayout(false); + this.groupBoxWordLists.ResumeLayout(false); + this.groupBoxWordLists.PerformLayout(); + this.groupBoxOcrFixList.ResumeLayout(false); + this.groupBoxOcrFixList.PerformLayout(); + this.groupBoxUserWordList.ResumeLayout(false); + this.groupBoxUserWordList.PerformLayout(); + this.groupBoxWordListLocation.ResumeLayout(false); + this.groupBoxWordListLocation.PerformLayout(); + this.groupBoxNamesIgonoreLists.ResumeLayout(false); + this.groupBoxNamesIgonoreLists.PerformLayout(); + this.tabPageToolBar.ResumeLayout(false); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.groupBoxShowToolBarButtons.ResumeLayout(false); + this.groupBoxShowToolBarButtons.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxNetflixQualityCheck)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBRemoveTextForHi)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTBFixCommonErrors)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHelp)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSettings)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSpellCheck)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxVisualSync)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxReplace)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxFind)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSaveAs)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSave)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxOpen)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxNew)).EndInit(); + this.tabPageFont.ResumeLayout(false); + this.groupBoxFont.ResumeLayout(false); + this.groupBoxFont.PerformLayout(); + this.groupBoxFontTextBox.ResumeLayout(false); + this.groupBoxFontTextBox.PerformLayout(); + this.groupBoxFontListViews.ResumeLayout(false); + this.groupBoxFontListViews.PerformLayout(); + this.groupBoxFontGeneral.ResumeLayout(false); + this.groupBoxFontGeneral.PerformLayout(); + this.tabPageSsaStyle.ResumeLayout(false); + this.groupBoxSsaStyle.ResumeLayout(false); + this.groupBoxSsaBorder.ResumeLayout(false); + this.groupBoxSsaBorder.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaOutline)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaShadow)).EndInit(); + this.groupSsaBoxFont.ResumeLayout(false); + this.groupSsaBoxFont.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSize)).EndInit(); + this.groupBoxMargins.ResumeLayout(false); + this.groupBoxMargins.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaMarginVertical)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaMarginRight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSsaMarginLeft)).EndInit(); + this.groupBoxPreview.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).EndInit(); + this.tabPageNetwork.ResumeLayout(false); + this.groupBoxNetworkSession.ResumeLayout(false); + this.groupBoxNetworkSession.PerformLayout(); + this.groupBoxProxySettings.ResumeLayout(false); + this.groupBoxProxySettings.PerformLayout(); + this.groupBoxProxyAuthentication.ResumeLayout(false); + this.groupBoxProxyAuthentication.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.TabControl tabControlSettings; + private System.Windows.Forms.TabPage tabPageGeneral; + private System.Windows.Forms.TabPage tabPageSsaStyle; + private System.Windows.Forms.GroupBox groupBoxMiscellaneous; + private System.Windows.Forms.GroupBox groupBoxShowToolBarButtons; + private System.Windows.Forms.PictureBox pictureBoxNew; + private System.Windows.Forms.CheckBox checkBoxToolbarNew; + private System.Windows.Forms.Label labelTBSpellCheck; + private System.Windows.Forms.PictureBox pictureBoxSpellCheck; + private System.Windows.Forms.CheckBox checkBoxSpellCheck; + private System.Windows.Forms.Label labelTBVisualSync; + private System.Windows.Forms.PictureBox pictureBoxVisualSync; + private System.Windows.Forms.CheckBox checkBoxVisualSync; + private System.Windows.Forms.Label labelTBReplace; + private System.Windows.Forms.PictureBox pictureBoxReplace; + private System.Windows.Forms.CheckBox checkBoxReplace; + private System.Windows.Forms.Label labelTBFind; + private System.Windows.Forms.PictureBox pictureBoxFind; + private System.Windows.Forms.CheckBox checkBoxToolbarFind; + private System.Windows.Forms.Label labelTBSaveAs; + private System.Windows.Forms.PictureBox pictureBoxSaveAs; + private System.Windows.Forms.CheckBox checkBoxToolbarSaveAs; + private System.Windows.Forms.Label labelTBSave; + private System.Windows.Forms.PictureBox pictureBoxSave; + private System.Windows.Forms.CheckBox checkBoxToolbarSave; + private System.Windows.Forms.Label labelTBOpen; + private System.Windows.Forms.PictureBox pictureBoxOpen; + private System.Windows.Forms.CheckBox checkBoxToolbarOpen; + private System.Windows.Forms.Label labelTBNew; + private System.Windows.Forms.Label labelTBHelp; + private System.Windows.Forms.PictureBox pictureBoxHelp; + private System.Windows.Forms.CheckBox checkBoxHelp; + private System.Windows.Forms.Label labelTBSettings; + private System.Windows.Forms.PictureBox pictureBoxSettings; + private System.Windows.Forms.CheckBox checkBoxSettings; + private System.Windows.Forms.Label labelDefaultFrameRate; + private System.Windows.Forms.Label labelDefaultFileEncoding; + private System.Windows.Forms.ComboBox comboBoxFrameRate; + private System.Windows.Forms.ComboBox comboBoxEncoding; + private System.Windows.Forms.CheckBox checkBoxRememberRecentFiles; + private System.Windows.Forms.GroupBox groupBoxSsaStyle; + private System.Windows.Forms.ColorDialog colorDialogSSAStyle; + private System.Windows.Forms.CheckBox checkBoxStartInSourceView; + private System.Windows.Forms.CheckBox checkBoxReopenLastOpened; + private System.Windows.Forms.Label labelSubMaxLen; + private System.Windows.Forms.TabPage tabPageVideoPlayer; + private System.Windows.Forms.CheckBox checkBoxVideoPlayerShowStopButton; + private System.Windows.Forms.GroupBox groupBoxVideoEngine; + private System.Windows.Forms.Label labelVideoPlayerMPlayer; + private System.Windows.Forms.Label labelDirectShowDescription; + private System.Windows.Forms.Label labelMpcHcDescription; + private System.Windows.Forms.RadioButton radioButtonVideoPlayerMPV; + private System.Windows.Forms.RadioButton radioButtonVideoPlayerDirectShow; + private System.Windows.Forms.RadioButton radioButtonVideoPlayerMpcHc; + private System.Windows.Forms.CheckBox checkBoxRememberWindowPosition; + private System.Windows.Forms.TextBox textBoxShowLineBreaksAs; + private System.Windows.Forms.Label labelShowLineBreaksAs; + private System.Windows.Forms.TabPage tabPageWordLists; + private System.Windows.Forms.GroupBox groupBoxWordLists; + private System.Windows.Forms.GroupBox groupBoxWordListLocation; + private System.Windows.Forms.GroupBox groupBoxOcrFixList; + private System.Windows.Forms.GroupBox groupBoxNamesIgonoreLists; + private System.Windows.Forms.TextBox textBoxNameEtc; + private System.Windows.Forms.Label labelWordListLanguage; + private System.Windows.Forms.Button buttonAddNames; + private System.Windows.Forms.ComboBox comboBoxWordListLanguage; + private System.Windows.Forms.Button buttonRemoveNameEtc; + private System.Windows.Forms.ListBox listBoxNames; + private System.Windows.Forms.Button buttonRemoveOcrFix; + private System.Windows.Forms.ListBox listBoxOcrFixList; + private System.Windows.Forms.TextBox textBoxOcrFixKey; + private System.Windows.Forms.Button buttonAddOcrFix; + private System.Windows.Forms.GroupBox groupBoxUserWordList; + private System.Windows.Forms.Button buttonRemoveUserWord; + private System.Windows.Forms.ListBox listBoxUserWordLists; + private System.Windows.Forms.TextBox textBoxUserWord; + private System.Windows.Forms.Button buttonAddUserWord; + private System.Windows.Forms.TabPage tabPageNetwork; + private System.Windows.Forms.GroupBox groupBoxProxySettings; + private System.Windows.Forms.Label labelProxyPassword; + private System.Windows.Forms.TextBox textBoxProxyAddress; + private System.Windows.Forms.TextBox textBoxProxyUserName; + private System.Windows.Forms.TextBox textBoxProxyPassword; + private System.Windows.Forms.Label labelProxyAddress; + private System.Windows.Forms.Label labelProxyUserName; + private System.Windows.Forms.CheckBox checkBoxNamesOnline; + private System.Windows.Forms.TextBox textBoxNamesOnline; + private System.Windows.Forms.TextBox textBoxOcrFixValue; + private System.Windows.Forms.TabPage tabPageTools; + private System.Windows.Forms.GroupBox groupBoxToolsVisualSync; + private System.Windows.Forms.ComboBox comboBoxToolsVerifySeconds; + private System.Windows.Forms.Label labelVerifyButton; + private System.Windows.Forms.Label labelToolsEndScene; + private System.Windows.Forms.ComboBox comboBoxToolsEndSceneIndex; + private System.Windows.Forms.Label labelToolsStartScene; + private System.Windows.Forms.ComboBox comboBoxToolsStartSceneIndex; + private System.Windows.Forms.GroupBox groupBoxFixCommonErrors; + private System.Windows.Forms.Label labelToolsMusicSymbol; + private System.Windows.Forms.ComboBox comboBoxListViewDoubleClickEvent; + private System.Windows.Forms.Label labelListViewDoubleClickEvent; + private System.Windows.Forms.Label labelStatus; + private System.Windows.Forms.TextBox textBoxMusicSymbolsToReplace; + private System.Windows.Forms.Label labelToolsMusicSymbolsToReplace; + private System.Windows.Forms.ComboBox comboBoxToolsMusicSymbol; + private System.Windows.Forms.GroupBox groupBoxSpellCheck; + private System.Windows.Forms.CheckBox checkBoxSpellCheckAutoChangeNames; + private System.Windows.Forms.GroupBox groupBoxProxyAuthentication; + private System.Windows.Forms.TextBox textBoxProxyDomain; + private System.Windows.Forms.Label labelProxyDomain; + private System.Windows.Forms.CheckBox checkBoxAutoDetectAnsiEncoding; + private System.Windows.Forms.Label labelAutoDetectAnsiEncoding; + private System.Windows.Forms.Label labelVideoPlayerVLC; + private System.Windows.Forms.RadioButton radioButtonVideoPlayerVLC; + private System.Windows.Forms.CheckBox checkBoxRemoveBlankLinesWhenOpening; + private System.Windows.Forms.GroupBox groupBoxMainWindowVideoControls; + private System.Windows.Forms.GroupBox groupBoxVideoPlayerDefault; + private System.Windows.Forms.TextBox textBoxCustomSearchUrl1; + private System.Windows.Forms.Label labelCustomSearch; + private System.Windows.Forms.ComboBox comboBoxCustomSearch1; + private System.Windows.Forms.TabPage tabPageWaveform; + private System.Windows.Forms.GroupBox groupBoxWaveformAppearence; + private System.Windows.Forms.Panel panelWaveformBackgroundColor; + private System.Windows.Forms.Button buttonWaveformBackgroundColor; + private System.Windows.Forms.Panel panelWaveformColor; + private System.Windows.Forms.Button buttonWaveformColor; + private System.Windows.Forms.Panel panelWaveformSelectedColor; + private System.Windows.Forms.Button buttonWaveformSelectedColor; + private System.Windows.Forms.CheckBox checkBoxWaveformShowGrid; + private System.Windows.Forms.Panel panelWaveformGridColor; + private System.Windows.Forms.Button buttonWaveformGridColor; + private System.Windows.Forms.Panel panelWaveformTextColor; + private System.Windows.Forms.Button buttonWaveformTextColor; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Button buttonWaveformsFolderEmpty; + private System.Windows.Forms.Label labelWaveformsFolderInfo; + private System.Windows.Forms.CheckBox checkBoxRememberSelectedLine; + private System.Windows.Forms.ComboBox comboBoxAutoBackup; + private System.Windows.Forms.Label labelAutoBackup; + private System.Windows.Forms.TabPage tabPageToolBar; + private System.Windows.Forms.CheckBox checkBoxShowFrameRate; + private System.Windows.Forms.ComboBox comboBoxSpellChecker; + private System.Windows.Forms.Label labelSpellChecker; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.CheckBox checkBoxAllowEditOfOriginalSubtitle; + private System.Windows.Forms.Label labelMergeShortLines; + private System.Windows.Forms.ComboBox comboBoxMergeShortLineLength; + private System.Windows.Forms.CheckBox checkBoxAutoWrapWhileTyping; + private System.Windows.Forms.CheckBox checkBoxFixCommonOcrErrorsUsingHardcodedRules; + private System.Windows.Forms.Label labelVideoPlayerPreviewFontSize; + private System.Windows.Forms.ComboBox comboBoxlVideoPlayerPreviewFontSize; + private System.Windows.Forms.TabPage tabPageShortcuts; + private System.Windows.Forms.GroupBox groupBoxShortcuts; + private System.Windows.Forms.Button buttonUpdateShortcut; + private System.Windows.Forms.TreeView treeViewShortcuts; + private System.Windows.Forms.Label labelShortcut; + private System.Windows.Forms.Label labelShortcutKey; + private System.Windows.Forms.ComboBox comboBoxShortcutKey; + private System.Windows.Forms.CheckBox checkBoxShortcutsShift; + private System.Windows.Forms.CheckBox checkBoxShortcutsAlt; + private System.Windows.Forms.CheckBox checkBoxShortcutsControl; + private System.Windows.Forms.CheckBox checkBoxPromptDeleteLines; + private System.Windows.Forms.GroupBox groupBoxSpectrogram; + private System.Windows.Forms.CheckBox checkBoxGenerateSpectrogram; + private System.Windows.Forms.Label labelSpectrogramAppearance; + private System.Windows.Forms.ComboBox comboBoxSpectrogramAppearance; + private System.Windows.Forms.CheckBox checkBoxReverseMouseWheelScrollDirection; + private System.Windows.Forms.Label labelMaxDuration; + private System.Windows.Forms.Label labelMinDuration; + private System.Windows.Forms.NumericUpDown numericUpDownDurationMax; + private System.Windows.Forms.NumericUpDown numericUpDownDurationMin; + private System.Windows.Forms.ComboBox comboBoxTimeCodeMode; + private System.Windows.Forms.Label labelTimeCodeMode; + private System.Windows.Forms.TabPage tabPageSyntaxColoring; + private System.Windows.Forms.GroupBox groupBoxListViewSyntaxColoring; + private System.Windows.Forms.CheckBox checkBoxSyntaxOverlap; + private System.Windows.Forms.CheckBox checkBoxSyntaxColorTextTooLong; + private System.Windows.Forms.CheckBox checkBoxSyntaxColorDurationTooLarge; + private System.Windows.Forms.CheckBox checkBoxSyntaxColorDurationTooSmall; + private System.Windows.Forms.CheckBox checkBoxSyntaxColorTextMoreThanTwoLines; + private System.Windows.Forms.Button buttonListViewSyntaxColorError; + private System.Windows.Forms.Panel panelListViewSyntaxColorError; + private System.Windows.Forms.Label labelMaxCharsPerSecond; + private System.Windows.Forms.NumericUpDown numericUpDownMaxCharsSec; + private System.Windows.Forms.NumericUpDown numericUpDownSubtitleLineMaximumLength; + private System.Windows.Forms.CheckBox checkBoxVideoPlayerShowFullscreenButton; + private System.Windows.Forms.CheckBox checkBoxVideoPlayerShowMuteButton; + private System.Windows.Forms.Label labelCustomSearch1; + private System.Windows.Forms.Label labelCustomSearch2; + private System.Windows.Forms.TextBox textBoxCustomSearchUrl2; + private System.Windows.Forms.ComboBox comboBoxCustomSearch2; + private System.Windows.Forms.Label labelCustomSearch5; + private System.Windows.Forms.TextBox textBoxCustomSearchUrl5; + private System.Windows.Forms.ComboBox comboBoxCustomSearch5; + private System.Windows.Forms.Label labelCustomSearch4; + private System.Windows.Forms.TextBox textBoxCustomSearchUrl4; + private System.Windows.Forms.ComboBox comboBoxCustomSearch4; + private System.Windows.Forms.Label labelCustomSearch3; + private System.Windows.Forms.TextBox textBoxCustomSearchUrl3; + private System.Windows.Forms.ComboBox comboBoxCustomSearch3; + private System.Windows.Forms.CheckBox checkBoxAllowOverlap; + private System.Windows.Forms.Label labelWaveformBorderHitMs2; + private System.Windows.Forms.NumericUpDown numericUpDownWaveformBorderHitMs; + private System.Windows.Forms.Label labelWaveformBorderHitMs1; + private System.Windows.Forms.Label labelSsaOutline; + private System.Windows.Forms.NumericUpDown numericUpDownSsaShadow; + private System.Windows.Forms.NumericUpDown numericUpDownSsaOutline; + private System.Windows.Forms.Label labelSsaShadow; + private System.Windows.Forms.GroupBox groupBoxPreview; + private System.Windows.Forms.PictureBox pictureBoxPreview; + private System.Windows.Forms.CheckBox checkBoxSsaOpaqueBox; + private System.Windows.Forms.CheckBox checkBoxSpellCheckOneLetterWords; + private System.Windows.Forms.CheckBox checkBoxTreatINQuoteAsING; + private System.Windows.Forms.GroupBox groupBoxFfmpeg; + private System.Windows.Forms.Button buttonBrowseToFFmpeg; + private System.Windows.Forms.TextBox textBoxFFmpegPath; + private System.Windows.Forms.Label labelFFmpegPath; + private System.Windows.Forms.CheckBox checkBoxUseFFmpeg; + private System.Windows.Forms.OpenFileDialog openFileDialogFFmpeg; + private System.Windows.Forms.CheckBox checkBoxWaveformHoverFocus; + private System.Windows.Forms.CheckBox checkBoxListViewMouseEnterFocus; + private System.Windows.Forms.NumericUpDown numericUpDownMinGapMs; + private System.Windows.Forms.Label labelMinGapMs; + private System.Windows.Forms.Label labelTBFixCommonErrors; + private System.Windows.Forms.PictureBox pictureBoxTBFixCommonErrors; + private System.Windows.Forms.CheckBox checkBoxTBFixCommonErrors; + private System.Windows.Forms.CheckBox checkBoxFixShortDisplayTimesAllowMoveStartTime; + private System.Windows.Forms.Button buttonVlcPathBrowse; + private System.Windows.Forms.TextBox textBoxVlcPath; + private System.Windows.Forms.Label labelVlcPath; + private System.Windows.Forms.GroupBox groupBoxToolsAutoBr; + private System.Windows.Forms.CheckBox checkBoxUseDoNotBreakAfterList; + private System.Windows.Forms.Button buttonEditDoNotBreakAfterList; + private System.Windows.Forms.CheckBox checkBoxCheckForUpdates; + private System.Windows.Forms.Label labelPlatform; + private System.Windows.Forms.CheckBox checkBoxVideoPlayerPreviewFontBold; + private System.Windows.Forms.Label labelWaveformTextSize; + private System.Windows.Forms.CheckBox checkBoxWaveformTextBold; + private System.Windows.Forms.ComboBox comboBoxWaveformTextSize; + private System.Windows.Forms.LinkLabel linkLabelOpenDictionaryFolder; + private System.Windows.Forms.GroupBox groupBoxNetworkSession; + private System.Windows.Forms.Button buttonNetworkSessionNewMessageSound; + private System.Windows.Forms.TextBox textBoxNetworkSessionNewMessageSound; + private System.Windows.Forms.Label labelNetworkSessionNewMessageSound; + private System.Windows.Forms.GroupBox groupBoxMargins; + private System.Windows.Forms.NumericUpDown numericUpDownSsaMarginVertical; + private System.Windows.Forms.NumericUpDown numericUpDownSsaMarginRight; + private System.Windows.Forms.NumericUpDown numericUpDownSsaMarginLeft; + private System.Windows.Forms.Label labelMarginVertical; + private System.Windows.Forms.Label labelMarginRight; + private System.Windows.Forms.Label labelMarginLeft; + private System.Windows.Forms.GroupBox groupBoxSsaBorder; + private System.Windows.Forms.GroupBox groupSsaBoxFont; + private System.Windows.Forms.NumericUpDown numericUpDownFontSize; + private System.Windows.Forms.ComboBox comboBoxFontName; + private System.Windows.Forms.Label labelSsaFontSize; + private System.Windows.Forms.Label labelFontName; + private System.Windows.Forms.Panel panelPrimaryColor; + private System.Windows.Forms.Button buttonSsaColor; + private System.Windows.Forms.CheckBox checkBoxSsaFontBold; + private System.Windows.Forms.CheckBox checkBoxFceSkipStep1; + private System.Windows.Forms.Button buttonMpvSettings; + private System.Windows.Forms.Label labelMpvSettings; + private System.Windows.Forms.LinkLabel linkLabelBingSubscribe; + private System.Windows.Forms.Label labelUserBingApiId; + private System.Windows.Forms.GroupBox groupBoxBing; + private System.Windows.Forms.Label labelBingApiKey; + private System.Windows.Forms.TextBox textBoxBingClientSecret; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox comboBoxAutoBackupDeleteAfter; + private System.Windows.Forms.Label labelAutoBackupDeleteAfter; + private System.Windows.Forms.Label labelTBRemoveTextForHi; + private System.Windows.Forms.PictureBox pictureBoxTBRemoveTextForHi; + private System.Windows.Forms.CheckBox checkBoxTBRemoveTextForHi; + private System.Windows.Forms.NumericUpDown numericUpDownMaxNumberOfLines; + private System.Windows.Forms.Label labelMaxLines; + private System.Windows.Forms.Label labelTBNetflixQualityCheck; + private System.Windows.Forms.PictureBox pictureBoxNetflixQualityCheck; + private System.Windows.Forms.CheckBox checkBoxNetflixQualityCheck; + private System.Windows.Forms.CheckBox checkBoxWaveformSetVideoPosMoveStartEnd; + private System.Windows.Forms.CheckBox checkBoxWaveformShowWpm; + private System.Windows.Forms.CheckBox checkBoxWaveformShowCps; + private System.Windows.Forms.NumericUpDown numericUpDownMaxWordsMin; + private System.Windows.Forms.Label labelMaxWordsPerMin; + private System.Windows.Forms.CheckBox checkBoxMpvHandlesPreviewText; + private System.Windows.Forms.CheckBox checkBoxVideoAutoOpen; + private System.Windows.Forms.Button buttonClearShortcut; + private System.Windows.Forms.CheckBox checkBoxAllowVolumeBoost; + private System.Windows.Forms.TabPage tabPageFont; + private System.Windows.Forms.GroupBox groupBoxFont; + private System.Windows.Forms.CheckBox checkBoxSubtitleCenter; + private System.Windows.Forms.Panel panelSubtitleFontColor; + private System.Windows.Forms.Panel panelSubtitleBackgroundColor; + private System.Windows.Forms.Label labelSubtitleFontBackgroundColor; + private System.Windows.Forms.Label labelSubtitleFontColor; + private System.Windows.Forms.Label labelSubtitleFontSize; + private System.Windows.Forms.ComboBox comboBoxSubtitleFont; + private System.Windows.Forms.CheckBox checkBoxSubtitleFontBold; + private System.Windows.Forms.ComboBox comboBoxSubtitleFontSize; + private System.Windows.Forms.Label labelSubtitleFont; + private System.Windows.Forms.ComboBox comboBoxSaveAsFileNameFrom; + private System.Windows.Forms.Label labelSaveAsFileNameFrom; + private System.Windows.Forms.GroupBox groupBoxGeneralRules; + private System.Windows.Forms.GroupBox groupBoxFontTextBox; + private System.Windows.Forms.GroupBox groupBoxFontListViews; + private System.Windows.Forms.Label labelSubtitleListViewFontSize; + private System.Windows.Forms.ComboBox comboBoxSubtitleListViewFontSize; + private System.Windows.Forms.CheckBox checkBoxSubtitleListViewFontBold; + private System.Windows.Forms.GroupBox groupBoxFontGeneral; + private System.Windows.Forms.Label labelFontNote; + private System.Windows.Forms.Button buttonDownloadFfmpeg; + private System.Windows.Forms.Button buttonShortcutsClear; + private System.Windows.Forms.Label labelShortcutsSearch; + private System.Windows.Forms.TextBox textBoxShortcutSearch; + private System.Windows.Forms.GroupBox groupBoxGoogleTranslate; + private System.Windows.Forms.Label labelGoogleTranslateApiKey; + private System.Windows.Forms.TextBox textBoxGoogleTransleApiKey; + private System.Windows.Forms.LinkLabel linkLabelGoogleTranslateSignUp; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.CheckBox checkBoxAutoSave; + private System.Windows.Forms.CheckBox checkBoxUseAlwaysToFile; + private System.Windows.Forms.Label labelOptimalCharsPerSecond; + private System.Windows.Forms.NumericUpDown numericUpDownOptimalCharsSec; + private System.Windows.Forms.Button buttonEditProfile; + private System.Windows.Forms.ComboBox comboBoxRulesProfileName; + private System.Windows.Forms.Label labelRulesProfileName; + private System.Windows.Forms.CheckBox checkBoxCpsIncludeWhiteSpace; + private System.Windows.Forms.Label labelBingTokenEndpoint; + private System.Windows.Forms.CheckBox checkBoxToolsBreakEarlyComma; + private System.Windows.Forms.CheckBox checkBoxToolsBreakEarlyDash; + private System.Windows.Forms.CheckBox checkBoxToolsBreakEarlyLineEnding; + private System.Windows.Forms.CheckBox checkBoxToolsBreakByPixelWidth; + private System.Windows.Forms.NumericUpDown numericUpDownToolsBreakPreferBottomHeavy; + private System.Windows.Forms.CheckBox checkBoxToolsBreakPreferBottomHeavy; + private System.Windows.Forms.Label labelToolsBreakBottomHeavyPercent; + private System.Windows.Forms.CheckBox checkBoxSyntaxColorGapTooSmall; + private System.Windows.Forms.Button buttonReset; + private System.Windows.Forms.Label labelDialogStyle; + private System.Windows.Forms.ComboBox comboBoxDialogStyle; + private System.Windows.Forms.ContextMenuStrip contextMenuStripShortcuts; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemShortcutsCollapse; + private System.Windows.Forms.CheckBox checkBoxWaveformSnapToSceneChanges; + private System.Windows.Forms.CheckBox checkBoxWaveformSingleClickSelect; + private System.Windows.Forms.Label labelSplitBehavior; + private System.Windows.Forms.ComboBox comboBoxSplitBehavior; + private System.Windows.Forms.Button buttonLineWidthSettings; + private System.Windows.Forms.CheckBox checkBoxSyntaxColorTextTooWide; + private System.Windows.Forms.Label labelContinuationStyle; + private System.Windows.Forms.Button buttonFixContinuationStyleSettings; + private System.Windows.Forms.ComboBox comboBoxContinuationStyle; + private System.Windows.Forms.ToolTip toolTipContinuationPreview; + private System.Windows.Forms.Panel panelWaveformCursorColor; + private System.Windows.Forms.Button buttonWaveformCursorColor; + private System.Windows.Forms.Button buttonGapChoose; + private System.Windows.Forms.CheckBox checkBoxSpellCheckAutoChangeNamesViaSuggestions; + private System.Windows.Forms.ComboBox comboBoxBoxBingTokenEndpoint; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem importShortcutsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem exportShortcutsToolStripMenuItem; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.Panel panelTextBoxAssColor; + private System.Windows.Forms.Button buttonTextBoxAssColor; + private System.Windows.Forms.Panel panelTextBoxHtmlColor; + private System.Windows.Forms.Button buttonTextBoxHtmlColor; + private System.Windows.Forms.CheckBox checkBoxSubtitleTextBoxSyntaxColor; + } } \ No newline at end of file diff --git a/src/Forms/Settings.cs b/src/ui/Forms/Settings.cs similarity index 98% rename from src/Forms/Settings.cs rename to src/ui/Forms/Settings.cs index 4d019a2c7..b7f41df47 100644 --- a/src/Forms/Settings.cs +++ b/src/ui/Forms/Settings.cs @@ -1,3497 +1,3497 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Dictionaries; -using Nikse.SubtitleEdit.Core.Enums; -using Nikse.SubtitleEdit.Core.Translate; -using Nikse.SubtitleEdit.Logic; -using Nikse.SubtitleEdit.Logic.VideoPlayers; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class Settings : PositionAndSizeForm - { - private string _ssaFontName; - private double _ssaFontSize; - private int _ssaFontColor; - private string _listBoxSearchString = string.Empty; - private DateTime _listBoxSearchStringLastUsed = DateTime.Now; - private List _wordListNames = new List(); - private List _userWordList = new List(); - private OcrFixReplaceList _ocrFixReplaceList; - private string _oldVlcLocation; - private string _oldVlcLocationRelative; - private bool _oldListViewShowCps; - private bool _oldListViewShowWpm; - private readonly Dictionary _newShortcuts = new Dictionary(); - private List _rulesProfiles; - private bool _loading = true; - private bool _backgroundImageDark; - - private class ComboBoxLanguage - { - public CultureInfo CultureInfo { get; set; } - public override string ToString() - { - return CultureInfo.NativeName.CapitalizeFirstLetter(); - } - } - - public class ShortcutNode - { - public string Text { get; set; } - public string ShortcutText { get; set; } - public ShortcutHelper Shortcut { get; set; } - public List Nodes { get; set; } - - public ShortcutNode() - { - Nodes = new List(); - } - - public ShortcutNode(string text) - { - Text = text; - Nodes = new List(); - } - } - - public class ShortcutHelper - { - public ShortcutHelper(PropertyInfo shortcut, bool isMenuItem) - { - Shortcut = shortcut; - IsMenuItem = isMenuItem; - } - - public PropertyInfo Shortcut { get; set; } - public bool IsMenuItem { get; set; } - } - - private static string GetRelativePath(string fileName) - { - string folder = Configuration.BaseDirectory; - - if (string.IsNullOrEmpty(fileName) || !fileName.StartsWith(folder.Substring(0, 2), StringComparison.OrdinalIgnoreCase)) - { - return string.Empty; - } - - var pathUri = new Uri(fileName); - if (!folder.EndsWith(Path.DirectorySeparatorChar)) - { - folder += Path.DirectorySeparatorChar; - } - - var folderUri = new Uri(folder); - return Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar)); - } - - public Settings() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - UiUtil.FixLargeFonts(this, buttonOK); - Init(); - } - - public void Init() - { - _loading = true; - labelStatus.Text = string.Empty; - _rulesProfiles = new List(Configuration.Settings.General.Profiles); - var gs = Configuration.Settings.General; - - checkBoxToolbarNew.Checked = gs.ShowToolbarNew; - checkBoxToolbarOpen.Checked = gs.ShowToolbarOpen; - checkBoxToolbarSave.Checked = gs.ShowToolbarSave; - checkBoxToolbarSaveAs.Checked = gs.ShowToolbarSaveAs; - checkBoxToolbarFind.Checked = gs.ShowToolbarFind; - checkBoxReplace.Checked = gs.ShowToolbarReplace; - checkBoxTBFixCommonErrors.Checked = gs.ShowToolbarFixCommonErrors; - checkBoxTBRemoveTextForHi.Checked = gs.ShowToolbarRemoveTextForHi; - checkBoxVisualSync.Checked = gs.ShowToolbarVisualSync; - checkBoxSettings.Checked = gs.ShowToolbarSettings; - checkBoxSpellCheck.Checked = gs.ShowToolbarSpellCheck; - checkBoxNetflixQualityCheck.Checked = gs.ShowToolbarNetflixGlyphCheck; - checkBoxHelp.Checked = gs.ShowToolbarHelp; - - comboBoxFrameRate.Items.Clear(); - comboBoxFrameRate.Items.Add(23.976.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(24.0.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(25.0.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(29.97.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(30.00.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(50.00.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(59.94.ToString(CultureInfo.CurrentCulture)); - comboBoxFrameRate.Items.Add(60.00.ToString(CultureInfo.CurrentCulture)); - - checkBoxShowFrameRate.Checked = gs.ShowFrameRate; - comboBoxFrameRate.Text = gs.DefaultFrameRate.ToString(CultureInfo.CurrentCulture); - - UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding); - - checkBoxAutoDetectAnsiEncoding.Checked = gs.AutoGuessAnsiEncoding; - comboBoxSubtitleFontSize.Text = gs.SubtitleTextBoxFontSize.ToString(CultureInfo.InvariantCulture); - comboBoxSubtitleListViewFontSize.Text = gs.SubtitleListViewFontSize.ToString(CultureInfo.InvariantCulture); - checkBoxSubtitleFontBold.Checked = gs.SubtitleTextBoxFontBold; - checkBoxSubtitleTextBoxSyntaxColor.Checked = gs.SubtitleTextBoxSyntaxColor; - panelTextBoxHtmlColor.BackColor = gs.SubtitleTextBoxHtmlColor; - panelTextBoxAssColor.BackColor = gs.SubtitleTextBoxAssColor; - checkBoxSubtitleListViewFontBold.Checked = gs.SubtitleListViewFontBold; - checkBoxSubtitleCenter.Checked = gs.CenterSubtitleInTextBox; - panelSubtitleFontColor.BackColor = gs.SubtitleFontColor; - panelSubtitleBackgroundColor.BackColor = gs.SubtitleBackgroundColor; - checkBoxRememberRecentFiles.Checked = gs.ShowRecentFiles; - checkBoxRememberRecentFiles_CheckedChanged(null, null); - checkBoxRememberSelectedLine.Checked = gs.RememberSelectedLine; - checkBoxReopenLastOpened.Checked = gs.StartLoadLastFile; - checkBoxStartInSourceView.Checked = gs.StartInSourceView; - checkBoxRemoveBlankLinesWhenOpening.Checked = gs.RemoveBlankLinesWhenOpening; - checkBoxRememberWindowPosition.Checked = gs.StartRememberPositionAndSize; - numericUpDownSubtitleLineMaximumLength.Value = gs.SubtitleLineMaximumLength; - numericUpDownOptimalCharsSec.Value = (decimal)gs.SubtitleOptimalCharactersPerSeconds; - numericUpDownMaxCharsSec.Value = (decimal)gs.SubtitleMaximumCharactersPerSeconds; - numericUpDownMaxWordsMin.Value = (decimal)gs.SubtitleMaximumWordsPerMinute; - checkBoxAutoWrapWhileTyping.Checked = gs.AutoWrapLineWhileTyping; - textBoxShowLineBreaksAs.Text = gs.ListViewLineSeparatorString; - - numericUpDownDurationMin.Value = gs.SubtitleMinimumDisplayMilliseconds; - numericUpDownDurationMax.Value = gs.SubtitleMaximumDisplayMilliseconds; - - if (gs.MinimumMillisecondsBetweenLines >= numericUpDownMinGapMs.Minimum && - gs.MinimumMillisecondsBetweenLines <= numericUpDownMinGapMs.Maximum) - { - numericUpDownMinGapMs.Value = gs.MinimumMillisecondsBetweenLines; - } - - if (gs.VideoPlayer.Trim().Equals("VLC", StringComparison.OrdinalIgnoreCase) && LibVlcDynamic.IsInstalled) - { - radioButtonVideoPlayerVLC.Checked = true; - } - else if (gs.VideoPlayer.Trim().Equals("MPV", StringComparison.OrdinalIgnoreCase) && LibMpvDynamic.IsInstalled) - { - radioButtonVideoPlayerMPV.Checked = true; - } - else if (gs.VideoPlayer.Trim().Equals("MPC-HC", StringComparison.OrdinalIgnoreCase) && UiUtil.IsMpcHcInstalled) - { - radioButtonVideoPlayerMpcHc.Checked = true; - } - else if (UiUtil.IsQuartsDllInstalled) - { - radioButtonVideoPlayerDirectShow.Checked = true; - } - else if (LibMpvDynamic.IsInstalled) - { - radioButtonVideoPlayerMPV.Checked = true; - } - else if (LibVlcDynamic.IsInstalled) - { - radioButtonVideoPlayerVLC.Checked = true; - } - - if (!LibVlcDynamic.IsInstalled) - { - radioButtonVideoPlayerVLC.Enabled = false; - } - - if (!UiUtil.IsQuartsDllInstalled) - { - radioButtonVideoPlayerDirectShow.Enabled = false; - } - - if (Logic.VideoPlayers.MpcHC.MpcHc.GetMpcHcFileName() == null) - { - radioButtonVideoPlayerMpcHc.Enabled = false; - } - - RefreshMpvSettings(); - buttonMpvSettings.Text = Configuration.Settings.Language.SettingsMpv.DownloadMpv; - checkBoxMpvHandlesPreviewText.Checked = gs.MpvHandlesPreviewText; - - textBoxVlcPath.Text = gs.VlcLocation; - textBoxVlcPath.Left = labelVideoPlayerVLC.Left + labelVideoPlayerVLC.Width + 5; - textBoxVlcPath.Width = buttonVlcPathBrowse.Left - textBoxVlcPath.Left - 5; - - labelVlcPath.Text = Configuration.Settings.Language.Settings.VlcBrowseToLabel; - - checkBoxVideoPlayerShowStopButton.Checked = gs.VideoPlayerShowStopButton; - checkBoxVideoPlayerShowMuteButton.Checked = gs.VideoPlayerShowMuteButton; - checkBoxVideoPlayerShowFullscreenButton.Checked = gs.VideoPlayerShowFullscreenButton; - - int videoPlayerPreviewFontSizeIndex = gs.VideoPlayerPreviewFontSize - int.Parse(comboBoxlVideoPlayerPreviewFontSize.Items[0].ToString()); - if (videoPlayerPreviewFontSizeIndex >= 0 && videoPlayerPreviewFontSizeIndex < comboBoxlVideoPlayerPreviewFontSize.Items.Count) - { - comboBoxlVideoPlayerPreviewFontSize.SelectedIndex = videoPlayerPreviewFontSizeIndex; - } - else - { - comboBoxlVideoPlayerPreviewFontSize.SelectedIndex = 3; - } - - checkBoxVideoPlayerPreviewFontBold.Checked = gs.VideoPlayerPreviewFontBold; - - checkBoxVideoAutoOpen.Checked = !gs.DisableVideoAutoLoading; - checkBoxAllowVolumeBoost.Checked = gs.AllowVolumeBoost; - - comboBoxCustomSearch1.Text = Configuration.Settings.VideoControls.CustomSearchText1; - comboBoxCustomSearch2.Text = Configuration.Settings.VideoControls.CustomSearchText2; - comboBoxCustomSearch3.Text = Configuration.Settings.VideoControls.CustomSearchText3; - comboBoxCustomSearch4.Text = Configuration.Settings.VideoControls.CustomSearchText4; - comboBoxCustomSearch5.Text = Configuration.Settings.VideoControls.CustomSearchText5; - textBoxCustomSearchUrl1.Text = Configuration.Settings.VideoControls.CustomSearchUrl1; - textBoxCustomSearchUrl2.Text = Configuration.Settings.VideoControls.CustomSearchUrl2; - textBoxCustomSearchUrl3.Text = Configuration.Settings.VideoControls.CustomSearchUrl3; - textBoxCustomSearchUrl4.Text = Configuration.Settings.VideoControls.CustomSearchUrl4; - textBoxCustomSearchUrl5.Text = Configuration.Settings.VideoControls.CustomSearchUrl5; - - comboBoxFontName.BeginUpdate(); - comboBoxSubtitleFont.BeginUpdate(); - comboBoxFontName.Items.Clear(); - comboBoxSubtitleFont.Items.Clear(); - var comboBoxFontNameList = new List(); - var comboBoxSubtitleFontList = new List(); - var comboBoxSubtitleFontIndex = 0; - foreach (var x in FontFamily.Families.OrderBy(p => p.Name)) - { - comboBoxFontNameList.Add(x.Name); - if (x.IsStyleAvailable(FontStyle.Regular) && x.IsStyleAvailable(FontStyle.Bold)) - { - comboBoxSubtitleFontList.Add(x.Name); - if (x.Name.Equals(gs.SubtitleFontName, StringComparison.OrdinalIgnoreCase)) - { - comboBoxSubtitleFontIndex = comboBoxSubtitleFontList.Count - 1; - } - } - } - comboBoxFontName.Items.AddRange(comboBoxFontNameList.ToArray()); - comboBoxSubtitleFont.Items.AddRange(comboBoxSubtitleFontList.ToArray()); - comboBoxSubtitleFont.SelectedIndex = comboBoxSubtitleFontIndex; - comboBoxFontName.EndUpdate(); - comboBoxSubtitleFont.EndUpdate(); - - var wordListSettings = Configuration.Settings.WordLists; - checkBoxNamesOnline.Checked = wordListSettings.UseOnlineNames; - textBoxNamesOnline.Text = wordListSettings.NamesUrl; - - var ssa = Configuration.Settings.SubtitleSettings; - _ssaFontName = ssa.SsaFontName; - _ssaFontSize = ssa.SsaFontSize; - _ssaFontColor = ssa.SsaFontColorArgb; - if (ssa.SsaOutline >= numericUpDownSsaOutline.Minimum && ssa.SsaOutline <= numericUpDownSsaOutline.Maximum) - { - numericUpDownSsaOutline.Value = ssa.SsaOutline; - } - - if (ssa.SsaShadow >= numericUpDownSsaShadow.Minimum && ssa.SsaShadow <= numericUpDownSsaShadow.Maximum) - { - numericUpDownSsaShadow.Value = ssa.SsaShadow; - } - - numericUpDownSsaMarginLeft.Value = ssa.SsaMarginLeft; - numericUpDownSsaMarginRight.Value = ssa.SsaMarginRight; - numericUpDownSsaMarginVertical.Value = ssa.SsaMarginTopBottom; - checkBoxSsaFontBold.Checked = ssa.SsaFontBold; - checkBoxSsaOpaqueBox.Checked = ssa.SsaOpaqueBox; - numericUpDownFontSize.Value = (decimal)ssa.SsaFontSize; - comboBoxFontName.Text = ssa.SsaFontName; - panelPrimaryColor.BackColor = Color.FromArgb(_ssaFontColor); - - var proxy = Configuration.Settings.Proxy; - textBoxProxyAddress.Text = proxy.ProxyAddress; - textBoxProxyUserName.Text = proxy.UserName; - textBoxProxyPassword.Text = proxy.Password == null ? string.Empty : proxy.DecodePassword(); - textBoxProxyDomain.Text = proxy.Domain; - - textBoxNetworkSessionNewMessageSound.Text = Configuration.Settings.NetworkSettings.NewMessageSound; - - checkBoxSyntaxColorDurationTooSmall.Checked = Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall; - checkBoxSyntaxColorDurationTooLarge.Checked = Configuration.Settings.Tools.ListViewSyntaxColorDurationBig; - checkBoxSyntaxColorTextTooLong.Checked = Configuration.Settings.Tools.ListViewSyntaxColorLongLines; - checkBoxSyntaxColorTextTooWide.Checked = Configuration.Settings.Tools.ListViewSyntaxColorWideLines; - checkBoxSyntaxColorTextMoreThanTwoLines.Checked = Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines; - if (Configuration.Settings.General.MaxNumberOfLines >= numericUpDownMaxNumberOfLines.Minimum && - Configuration.Settings.General.MaxNumberOfLines <= numericUpDownMaxNumberOfLines.Maximum) - { - numericUpDownMaxNumberOfLines.Value = Configuration.Settings.General.MaxNumberOfLines; - } - checkBoxSyntaxOverlap.Checked = Configuration.Settings.Tools.ListViewSyntaxColorOverlap; - checkBoxSyntaxColorGapTooSmall.Checked = Configuration.Settings.Tools.ListViewSyntaxColorGap; - panelListViewSyntaxColorError.BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; - - // Language - var language = Configuration.Settings.Language.Settings; - Text = language.Title; - tabPageGeneral.Text = language.General; - tabPageVideoPlayer.Text = language.VideoPlayer; - tabPageWaveform.Text = language.WaveformAndSpectrogram; - tabPageWordLists.Text = language.WordLists; - tabPageTools.Text = language.Tools; - tabPageSsaStyle.Text = language.SsaStyle; - tabPageNetwork.Text = language.Network; - tabPageToolBar.Text = language.Toolbar; - tabPageFont.Text = Configuration.Settings.Language.DCinemaProperties.Font; - tabPageShortcuts.Text = language.Shortcuts; - tabPageSyntaxColoring.Text = language.SyntaxColoring; - groupBoxShowToolBarButtons.Text = language.ShowToolBarButtons; - labelTBNew.Text = language.New; - labelTBOpen.Text = language.Open; - labelTBSave.Text = language.Save; - labelTBSaveAs.Text = language.SaveAs; - labelTBFind.Text = language.Find; - labelTBReplace.Text = language.Replace; - labelTBFixCommonErrors.Text = language.FixCommonerrors; - labelTBRemoveTextForHi.Text = language.RemoveTextForHi; - labelTBVisualSync.Text = language.VisualSync; - labelTBSpellCheck.Text = language.SpellCheck; - labelTBNetflixQualityCheck.Text = language.NetflixQualityCheck; - labelTBSettings.Text = language.SettingsName; - labelTBHelp.Text = language.Help; - checkBoxToolbarNew.Text = Configuration.Settings.Language.General.Visible; - checkBoxToolbarOpen.Text = Configuration.Settings.Language.General.Visible; - checkBoxToolbarSave.Text = Configuration.Settings.Language.General.Visible; - checkBoxToolbarSaveAs.Text = Configuration.Settings.Language.General.Visible; - checkBoxToolbarFind.Text = Configuration.Settings.Language.General.Visible; - checkBoxReplace.Text = Configuration.Settings.Language.General.Visible; - checkBoxTBFixCommonErrors.Text = Configuration.Settings.Language.General.Visible; - checkBoxTBRemoveTextForHi.Text = Configuration.Settings.Language.General.Visible; - checkBoxVisualSync.Text = Configuration.Settings.Language.General.Visible; - checkBoxSpellCheck.Text = Configuration.Settings.Language.General.Visible; - checkBoxNetflixQualityCheck.Text = Configuration.Settings.Language.General.Visible; - checkBoxSettings.Text = Configuration.Settings.Language.General.Visible; - checkBoxHelp.Text = Configuration.Settings.Language.General.Visible; - - groupBoxMiscellaneous.Text = language.General; - groupBoxGeneralRules.Text = language.Rules; - labelRulesProfileName.Text = language.Profile; - checkBoxShowFrameRate.Text = language.ShowFrameRate; - labelDefaultFrameRate.Text = language.DefaultFrameRate; - labelDefaultFileEncoding.Text = language.DefaultFileEncoding; - labelAutoDetectAnsiEncoding.Text = language.AutoDetectAnsiEncoding; - labelSubMaxLen.Text = language.SubtitleLineMaximumLength; - labelOptimalCharsPerSecond.Text = language.OptimalCharactersPerSecond; - labelMaxCharsPerSecond.Text = language.MaximumCharactersPerSecond; - labelMaxWordsPerMin.Text = language.MaximumWordssPerMinute; - checkBoxAutoWrapWhileTyping.Text = language.AutoWrapWhileTyping; - groupBoxFont.Text = language.FontInUi; - groupBoxFontGeneral.Text = language.General; - groupBoxFontListViews.Text = language.ListView; - groupBoxFontTextBox.Text = language.TextBox; - labelFontNote.Text = language.FontNote; - labelMinDuration.Text = language.DurationMinimumMilliseconds; - labelMaxDuration.Text = language.DurationMaximumMilliseconds; - labelMinGapMs.Text = language.MinimumGapMilliseconds; - buttonGapChoose.Left = numericUpDownMinGapMs.Left + numericUpDownMinGapMs.Width + 5; - labelMaxLines.Text = language.MaximumLines; - if (labelSubMaxLen.Left + labelSubMaxLen.Width > numericUpDownSubtitleLineMaximumLength.Left) - { - numericUpDownSubtitleLineMaximumLength.Left = labelSubMaxLen.Left + labelSubMaxLen.Width + 3; - } - - if (labelMaxCharsPerSecond.Left + labelMaxCharsPerSecond.Width > numericUpDownMaxCharsSec.Left) - { - numericUpDownMaxCharsSec.Left = labelMaxCharsPerSecond.Left + labelMaxCharsPerSecond.Width + 3; - } - - if (labelMaxWordsPerMin.Left + labelMaxWordsPerMin.Width > numericUpDownMaxWordsMin.Left) - { - numericUpDownMaxWordsMin.Left = labelMaxWordsPerMin.Left + labelMaxWordsPerMin.Width + 3; - } - - if (labelMinDuration.Left + labelMinDuration.Width > numericUpDownDurationMin.Left) - { - numericUpDownDurationMin.Left = labelMinDuration.Left + labelMinDuration.Width + 3; - } - - if (labelMaxDuration.Left + labelMaxDuration.Width > numericUpDownDurationMax.Left) - { - numericUpDownDurationMax.Left = labelMaxDuration.Left + labelMaxDuration.Width + 3; - } - - if (labelMinGapMs.Left + labelMinGapMs.Width > numericUpDownMinGapMs.Left) - { - numericUpDownMinGapMs.Left = labelMinGapMs.Left + labelMinGapMs.Width + 3; - } - - if (labelMergeShortLines.Left + labelMergeShortLines.Width > comboBoxMergeShortLineLength.Left) - { - comboBoxMergeShortLineLength.Left = labelMergeShortLines.Left + labelMergeShortLines.Width + 3; - } - - labelSubtitleFont.Text = language.SubtitleFont; - labelSubtitleFontSize.Text = language.SubtitleFontSize; - labelSubtitleListViewFontSize.Text = language.SubtitleFontSize; - checkBoxSubtitleFontBold.Text = language.SubtitleBold; - checkBoxSubtitleTextBoxSyntaxColor.Text = language.UseSyntaxColoring; - buttonTextBoxHtmlColor.Text = language.HtmlColor; - buttonTextBoxAssColor.Text = language.AssaColor; - checkBoxSubtitleListViewFontBold.Text = language.SubtitleBold; - checkBoxSubtitleCenter.Text = language.SubtitleCenter; - checkBoxSubtitleCenter.Left = checkBoxSubtitleFontBold.Left; - labelSubtitleFontColor.Text = language.SubtitleFontColor; - labelSubtitleFontBackgroundColor.Text = language.SubtitleBackgroundColor; - labelSpellChecker.Text = language.SpellChecker; - comboBoxSpellChecker.Left = labelSpellChecker.Left + labelSpellChecker.Width + 4; - checkBoxRememberRecentFiles.Text = language.RememberRecentFiles; - checkBoxReopenLastOpened.Text = language.StartWithLastFileLoaded; - checkBoxRememberSelectedLine.Text = language.RememberSelectedLine; - checkBoxStartInSourceView.Text = language.StartInSourceView; - checkBoxRemoveBlankLinesWhenOpening.Text = language.RemoveBlankLinesWhenOpening; - checkBoxRememberWindowPosition.Text = language.RememberPositionAndSize; - - labelShowLineBreaksAs.Text = language.ShowLineBreaksAs; - textBoxShowLineBreaksAs.Left = labelShowLineBreaksAs.Left + labelShowLineBreaksAs.Width; - labelListViewDoubleClickEvent.Text = language.MainListViewDoubleClickAction; - labelSaveAsFileNameFrom.Text = language.SaveAsFileNameFrom; - labelAutoBackup.Text = language.AutoBackup; - labelAutoBackupDeleteAfter.Text = language.AutoBackupDeleteAfter; - comboBoxAutoBackup.Left = labelAutoBackup.Left + labelAutoBackup.Width + 3; - labelAutoBackupDeleteAfter.Left = comboBoxAutoBackup.Left + comboBoxAutoBackup.Width + 5; - comboBoxAutoBackupDeleteAfter.Left = labelAutoBackupDeleteAfter.Left + labelAutoBackupDeleteAfter.Width + 3; - checkBoxCheckForUpdates.Text = language.CheckForUpdates; - checkBoxAutoSave.Text = language.AutoSave; - checkBoxCheckForUpdates.Left = checkBoxAutoSave.Left + checkBoxAutoSave.Width + 15; - checkBoxAllowEditOfOriginalSubtitle.Text = language.AllowEditOfOriginalSubtitle; - checkBoxPromptDeleteLines.Text = language.PromptDeleteLines; - - comboBoxTimeCodeMode.Items.Clear(); - comboBoxTimeCodeMode.Items.Add(language.TimeCodeModeHHMMSSMS); - comboBoxTimeCodeMode.Items.Add(language.TimeCodeModeHHMMSSFF); - comboBoxTimeCodeMode.SelectedIndex = gs.UseTimeFormatHHMMSSFF ? 1 : 0; - labelTimeCodeMode.Text = language.TimeCodeMode; - comboBoxTimeCodeMode.Left = labelTimeCodeMode.Left + labelTimeCodeMode.Width + 4; - - comboBoxSplitBehavior.Items.Clear(); - comboBoxSplitBehavior.Items.Add(language.SplitBehaviorPrevious); - comboBoxSplitBehavior.Items.Add(language.SplitBehaviorHalf); - comboBoxSplitBehavior.Items.Add(language.SplitBehaviorNext); - comboBoxSplitBehavior.SelectedIndex = gs.SplitBehavior; - labelSplitBehavior.Text = language.SplitBehavior; - comboBoxSplitBehavior.Left = labelTimeCodeMode.Left + labelTimeCodeMode.Width + 4; - if (labelSplitBehavior.Width > labelTimeCodeMode.Width) - { - comboBoxSplitBehavior.Left = labelSplitBehavior.Left + labelSplitBehavior.Width + 4; - } - - var dropDownSplitBehaviorWidth = comboBoxSplitBehavior.Width; - using (var g = Graphics.FromHwnd(IntPtr.Zero)) - { - foreach (var item in comboBoxSplitBehavior.Items) - { - var itemWidth = (int)g.MeasureString((string)item, Font).Width + 5; - dropDownSplitBehaviorWidth = Math.Max(itemWidth, dropDownSplitBehaviorWidth); - } - } - comboBoxSplitBehavior.DropDownWidth = dropDownSplitBehaviorWidth; - - - comboBoxAutoBackup.Items[0] = Configuration.Settings.Language.General.None; - comboBoxAutoBackup.Items[1] = language.AutoBackupEveryMinute; - comboBoxAutoBackup.Items[2] = language.AutoBackupEveryFiveMinutes; - comboBoxAutoBackup.Items[3] = language.AutoBackupEveryFifteenMinutes; - - comboBoxAutoBackupDeleteAfter.Items[0] = language.AutoBackupDeleteAfterOneMonth; - comboBoxAutoBackupDeleteAfter.Items[1] = language.AutoBackupDeleteAfterThreeMonths; - comboBoxAutoBackupDeleteAfter.Items[2] = language.AutoBackupDeleteAfterSixMonths; - - groupBoxVideoEngine.Text = language.VideoEngine; - radioButtonVideoPlayerDirectShow.Text = language.DirectShow; - - labelDirectShowDescription.Text = language.DirectShowDescription; - - radioButtonVideoPlayerMpcHc.Text = language.MpcHc; - labelMpcHcDescription.Text = language.MpcHcDescription; - - radioButtonVideoPlayerMPV.Text = language.MpvPlayer; - labelVideoPlayerMPlayer.Text = language.MpvPlayerDescription; - buttonMpvSettings.Left = labelVideoPlayerMPlayer.Left + labelVideoPlayerMPlayer.Width + 5; - labelMpvSettings.Left = buttonMpvSettings.Left + buttonMpvSettings.Width + 5; - checkBoxMpvHandlesPreviewText.Text = language.MpvHandlesPreviewText; - - radioButtonVideoPlayerVLC.Text = language.VlcMediaPlayer; - labelVideoPlayerVLC.Text = language.VlcMediaPlayerDescription; - gs.VlcLocation = textBoxVlcPath.Text; - - checkBoxVideoPlayerShowStopButton.Text = language.ShowStopButton; - checkBoxVideoPlayerShowMuteButton.Text = language.ShowMuteButton; - checkBoxVideoPlayerShowFullscreenButton.Text = language.ShowFullscreenButton; - - labelVideoPlayerPreviewFontSize.Text = language.PreviewFontSize; - comboBoxlVideoPlayerPreviewFontSize.Left = labelVideoPlayerPreviewFontSize.Left + labelVideoPlayerPreviewFontSize.Width; - checkBoxVideoPlayerPreviewFontBold.Text = language.SubtitleBold; - checkBoxVideoPlayerPreviewFontBold.Left = comboBoxlVideoPlayerPreviewFontSize.Left; - - checkBoxVideoAutoOpen.Text = language.VideoAutoOpen; - checkBoxAllowVolumeBoost.Text = language.AllowVolumeBoost; - - groupBoxMainWindowVideoControls.Text = language.MainWindowVideoControls; - labelCustomSearch.Text = language.CustomSearchTextAndUrl; - - groupBoxWaveformAppearence.Text = language.WaveformAppearance; - checkBoxWaveformShowGrid.Text = language.WaveformShowGridLines; - checkBoxWaveformShowCps.Text = language.WaveformShowCps; - checkBoxWaveformShowWpm.Text = language.WaveformShowWpm; - checkBoxReverseMouseWheelScrollDirection.Text = language.ReverseMouseWheelScrollDirection; - checkBoxAllowOverlap.Text = language.WaveformAllowOverlap; - checkBoxWaveformSetVideoPosMoveStartEnd.Text = language.WaveformSetVideoPosMoveStartEnd; - checkBoxWaveformHoverFocus.Text = language.WaveformFocusMouseEnter; - checkBoxListViewMouseEnterFocus.Text = language.WaveformListViewFocusMouseEnter; - checkBoxWaveformSingleClickSelect.Text = language.WaveformSingleClickSelect; - checkBoxWaveformSnapToSceneChanges.Text = language.WaveformSnapToSceneChanges; - labelWaveformBorderHitMs1.Text = language.WaveformBorderHitMs1; - labelWaveformBorderHitMs2.Text = language.WaveformBorderHitMs2; - numericUpDownWaveformBorderHitMs.Left = labelWaveformBorderHitMs1.Left + labelWaveformBorderHitMs1.Width; - labelWaveformBorderHitMs2.Left = numericUpDownWaveformBorderHitMs.Left + numericUpDownWaveformBorderHitMs.Width + 2; - - buttonWaveformGridColor.Text = language.WaveformGridColor; - buttonWaveformColor.Text = language.WaveformColor; - buttonWaveformSelectedColor.Text = language.WaveformSelectedColor; - buttonWaveformTextColor.Text = language.WaveformTextColor; - buttonWaveformBackgroundColor.Text = language.WaveformBackgroundColor; - buttonWaveformCursorColor.Text = language.WaveformCursorColor; - groupBoxSpectrogram.Text = language.Spectrogram; - checkBoxGenerateSpectrogram.Text = language.GenerateSpectrogram; - labelSpectrogramAppearance.Text = language.SpectrogramAppearance; - comboBoxSpectrogramAppearance.Items.Clear(); - comboBoxSpectrogramAppearance.Items.Add(language.SpectrogramOneColorGradient); - comboBoxSpectrogramAppearance.Items.Add(language.SpectrogramClassic); - labelWaveformTextSize.Text = language.WaveformTextFontSize; - comboBoxWaveformTextSize.Left = labelWaveformTextSize.Left + labelWaveformTextSize.Width + 5; - checkBoxWaveformTextBold.Text = language.SubtitleBold; - checkBoxWaveformTextBold.Left = comboBoxWaveformTextSize.Left + comboBoxWaveformTextSize.Width + 5; - - buttonWaveformsFolderEmpty.Text = language.WaveformAndSpectrogramsFolderEmpty; - InitializeWaveformsAndSpectrogramsFolderEmpty(language); - - checkBoxUseFFmpeg.Text = language.WaveformUseFFmpeg; - buttonDownloadFfmpeg.Text = language.DownloadFFmpeg; - if (!Configuration.IsRunningOnWindows) - { - buttonDownloadFfmpeg.Visible = false; - labelFFmpegPath.Visible = false; - textBoxFFmpegPath.Visible = false; - buttonBrowseToFFmpeg.Visible = false; - - buttonMpvSettings.Visible = false; - radioButtonVideoPlayerDirectShow.Enabled = false; - radioButtonVideoPlayerMpcHc.Enabled = false; - var isLibVlcInstalled = LibVlcDynamic.IsInstalled; - radioButtonVideoPlayerVLC.Enabled = isLibVlcInstalled; - if (gs.VideoPlayer.Trim().Equals("VLC", StringComparison.OrdinalIgnoreCase) && isLibVlcInstalled) - { - radioButtonVideoPlayerVLC.Checked = true; - } - if (LibMpvDynamic.IsInstalled) - { - radioButtonVideoPlayerMPV.Enabled = true; - radioButtonVideoPlayerMPV.Checked = !(gs.VideoPlayer.Trim().Equals("VLC", StringComparison.OrdinalIgnoreCase) && isLibVlcInstalled); - labelMpvSettings.Text = "--vo=" + Configuration.Settings.General.MpvVideoOutputLinux; - } - textBoxVlcPath.Visible = false; - labelVlcPath.Visible = false; - buttonVlcPathBrowse.Visible = false; - } - - labelFFmpegPath.Text = language.WaveformFFmpegPath; - - groupBoxSsaStyle.Text = language.SubStationAlphaStyle; - - var ssaStyles = Configuration.Settings.Language.SubStationAlphaStyles; - labelSsaFontSize.Text = ssaStyles.FontSize; - labelFontName.Text = ssaStyles.FontName; - buttonSsaColor.Text = Configuration.Settings.Language.Settings.ChooseColor; - groupSsaBoxFont.Text = ssaStyles.Font; - groupBoxSsaBorder.Text = ssaStyles.Border; - groupBoxMargins.Text = ssaStyles.Margins; - labelMarginLeft.Text = ssaStyles.MarginLeft; - labelMarginRight.Text = ssaStyles.MarginRight; - labelMarginVertical.Text = ssaStyles.MarginVertical; - labelSsaOutline.Text = language.SsaOutline; - labelSsaShadow.Text = language.SsaShadow; - checkBoxSsaOpaqueBox.Text = language.SsaOpaqueBox; - checkBoxSsaFontBold.Text = Configuration.Settings.Language.General.Bold; - - groupBoxPreview.Text = Configuration.Settings.Language.General.Preview; - - numericUpDownSsaOutline.Left = labelSsaOutline.Left + labelSsaOutline.Width + 4; - numericUpDownSsaShadow.Left = labelSsaShadow.Left + labelSsaShadow.Width + 4; - if (Math.Abs(numericUpDownSsaOutline.Left - numericUpDownSsaShadow.Left) < 9) - { - if (numericUpDownSsaOutline.Left > numericUpDownSsaShadow.Left) - { - numericUpDownSsaShadow.Left = numericUpDownSsaOutline.Left; - } - else - { - numericUpDownSsaOutline.Left = numericUpDownSsaShadow.Left; - } - } - - groupBoxWordLists.Text = language.WordLists; - labelWordListLanguage.Text = language.Language; - comboBoxWordListLanguage.Left = labelWordListLanguage.Left + labelWordListLanguage.Width + 4; - groupBoxNamesIgonoreLists.Text = language.NamesIgnoreLists; - groupBoxUserWordList.Text = language.UserWordList; - groupBoxOcrFixList.Text = language.OcrFixList; - buttonRemoveNameEtc.Text = language.Remove; - buttonRemoveUserWord.Text = language.Remove; - buttonRemoveOcrFix.Text = language.Remove; - buttonAddNames.Text = language.AddName; - buttonAddUserWord.Text = language.AddWord; - buttonAddOcrFix.Text = language.AddPair; - groupBoxWordListLocation.Text = language.Location; - checkBoxNamesOnline.Text = language.UseOnlineNames; - linkLabelOpenDictionaryFolder.Text = Configuration.Settings.Language.GetDictionaries.OpenDictionariesFolder; - - groupBoxProxySettings.Text = language.ProxyServerSettings; - labelProxyAddress.Text = language.ProxyAddress; - groupBoxProxyAuthentication.Text = language.ProxyAuthentication; - labelProxyUserName.Text = language.ProxyUserName; - labelProxyPassword.Text = language.ProxyPassword; - labelProxyDomain.Text = language.ProxyDomain; - - groupBoxNetworkSession.Text = language.NetworkSessionSettings; - labelNetworkSessionNewMessageSound.Text = language.NetworkSessionNewSound; - - groupBoxToolsVisualSync.Text = language.VisualSync; - labelVerifyButton.Text = language.PlayXSecondsAndBack; - labelToolsStartScene.Text = language.StartSceneIndex; - labelToolsEndScene.Text = language.EndSceneIndex; - comboBoxToolsStartSceneIndex.Items.Clear(); - comboBoxToolsStartSceneIndex.Items.Add(string.Format(language.FirstPlusX, 0)); - comboBoxToolsStartSceneIndex.Items.Add(string.Format(language.FirstPlusX, 1)); - comboBoxToolsStartSceneIndex.Items.Add(string.Format(language.FirstPlusX, 2)); - comboBoxToolsStartSceneIndex.Items.Add(string.Format(language.FirstPlusX, 3)); - comboBoxToolsEndSceneIndex.Items.Clear(); - comboBoxToolsEndSceneIndex.Items.Add(string.Format(language.LastMinusX, 0)); - comboBoxToolsEndSceneIndex.Items.Add(string.Format(language.LastMinusX, 1)); - comboBoxToolsEndSceneIndex.Items.Add(string.Format(language.LastMinusX, 2)); - comboBoxToolsEndSceneIndex.Items.Add(string.Format(language.LastMinusX, 3)); - int visAdjustTextMax = Math.Max(labelVerifyButton.Width, labelToolsStartScene.Width); - visAdjustTextMax = Math.Max(visAdjustTextMax, labelToolsEndScene.Width); - comboBoxToolsVerifySeconds.Left = groupBoxToolsVisualSync.Left + visAdjustTextMax + 12; - comboBoxToolsStartSceneIndex.Left = comboBoxToolsVerifySeconds.Left; - comboBoxToolsEndSceneIndex.Left = comboBoxToolsVerifySeconds.Left; - - groupBoxFixCommonErrors.Text = language.FixCommonerrors; - labelMergeShortLines.Text = language.MergeLinesShorterThan; - labelDialogStyle.Text = language.DialogStyle; - labelContinuationStyle.Text = language.ContinuationStyle; - labelToolsMusicSymbol.Text = language.MusicSymbol; - labelToolsMusicSymbolsToReplace.Text = language.MusicSymbolsReplace; - checkBoxFixCommonOcrErrorsUsingHardcodedRules.Text = language.FixCommonOcrErrorsUseHardcodedRules; - checkBoxFixShortDisplayTimesAllowMoveStartTime.Text = language.FixCommonerrorsFixShortDisplayTimesAllowMoveStartTime; - checkBoxFceSkipStep1.Text = language.FixCommonErrorsSkipStepOne; - groupBoxSpellCheck.Text = language.SpellCheck; - checkBoxSpellCheckAutoChangeNames.Text = Configuration.Settings.Language.SpellCheck.AutoFixNames; - checkBoxSpellCheckAutoChangeNamesViaSuggestions.Text = Configuration.Settings.Language.SpellCheck.AutoFixNamesViaSuggestions; - checkBoxSpellCheckOneLetterWords.Text = Configuration.Settings.Language.SpellCheck.CheckOneLetterWords; - checkBoxTreatINQuoteAsING.Text = Configuration.Settings.Language.SpellCheck.TreatINQuoteAsING; - checkBoxUseAlwaysToFile.Text = Configuration.Settings.Language.SpellCheck.RememberUseAlwaysList; - buttonFixContinuationStyleSettings.Text = language.EditFixContinuationStyleSettings; - - groupBoxToolsAutoBr.Text = Configuration.Settings.Language.Main.Controls.AutoBreak.Replace("&", string.Empty); - checkBoxUseDoNotBreakAfterList.Text = language.UseDoNotBreakAfterList; - checkBoxToolsBreakEarlyComma.Text = language.BreakEarlyForComma; - checkBoxToolsBreakEarlyDash.Text = language.BreakEarlyForDashDialog; - checkBoxToolsBreakEarlyLineEnding.Text = language.BreakEarlyForLineEnding; - checkBoxToolsBreakByPixelWidth.Text = language.BreakByPixelWidth; - checkBoxToolsBreakPreferBottomHeavy.Text = language.BreakPreferBottomHeavy; - numericUpDownToolsBreakPreferBottomHeavy.Left = checkBoxToolsBreakPreferBottomHeavy.Left + checkBoxToolsBreakPreferBottomHeavy.Width + 9; - labelToolsBreakBottomHeavyPercent.Left = numericUpDownToolsBreakPreferBottomHeavy.Left + numericUpDownToolsBreakPreferBottomHeavy.Width + 2; - checkBoxCpsIncludeWhiteSpace.Text = language.CpsIncludesSpace; - buttonEditDoNotBreakAfterList.Text = Configuration.Settings.Language.VobSubOcr.Edit; - - groupBoxGoogleTranslate.Text = language.GoogleTranslate; - labelGoogleTranslateApiKey.Text = language.GoogleTranslateApiKey; - linkLabelGoogleTranslateSignUp.Text = language.HowToSignUp; - linkLabelGoogleTranslateSignUp.Left = textBoxGoogleTransleApiKey.Left + textBoxGoogleTransleApiKey.Width - linkLabelGoogleTranslateSignUp.Width; - - groupBoxBing.Text = language.MicrosoftBingTranslator; - labelBingApiKey.Text = language.MicrosoftTranslateApiKey; - labelBingTokenEndpoint.Text = language.MicrosoftTranslateTokenEndpoint; - linkLabelBingSubscribe.Text = language.HowToSignUp; - linkLabelBingSubscribe.Left = textBoxBingClientSecret.Left + textBoxBingClientSecret.Width - linkLabelGoogleTranslateSignUp.Width; - - comboBoxListViewDoubleClickEvent.Items.Clear(); - comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewNothing); - comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewVideoGoToPositionAndPause); - comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewVideoGoToPositionAndPlay); - comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewVideoGoToPositionMinusHalfSecAndPause); - comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewVideoGoToPositionMinus1SecAndPause); - comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewVideoGoToPositionMinus1SecAndPlay); - comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewEditTextAndPause); - comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewEditText); - - comboBoxSaveAsFileNameFrom.Items.Clear(); - comboBoxSaveAsFileNameFrom.Items.Add(language.VideoFileName); - comboBoxSaveAsFileNameFrom.Items.Add(language.ExistingFileName); - - if (gs.ListViewDoubleClickAction >= 0 && gs.ListViewDoubleClickAction < comboBoxListViewDoubleClickEvent.Items.Count) - { - comboBoxListViewDoubleClickEvent.SelectedIndex = gs.ListViewDoubleClickAction; - } - - comboBoxSaveAsFileNameFrom.SelectedIndex = gs.SaveAsUseFileNameFrom.Equals("video", StringComparison.OrdinalIgnoreCase) ? 0 : 1; - - if (gs.AutoBackupSeconds == 60) - { - comboBoxAutoBackup.SelectedIndex = 1; - } - else if (gs.AutoBackupSeconds == 60 * 5) - { - comboBoxAutoBackup.SelectedIndex = 2; - } - else if (gs.AutoBackupSeconds == 60 * 15) - { - comboBoxAutoBackup.SelectedIndex = 3; - } - else - { - comboBoxAutoBackup.SelectedIndex = 0; - } - - if (gs.AutoBackupDeleteAfterMonths == 3) - { - comboBoxAutoBackupDeleteAfter.SelectedIndex = 1; - } - else if (gs.AutoBackupDeleteAfterMonths == 1) - { - comboBoxAutoBackupDeleteAfter.SelectedIndex = 0; - } - else - { - comboBoxAutoBackupDeleteAfter.SelectedIndex = 2; - } - - checkBoxCheckForUpdates.Checked = gs.CheckForUpdates; - checkBoxAutoSave.Checked = gs.AutoSave; - - comboBoxSpellChecker.SelectedIndex = gs.SpellChecker.Contains("word", StringComparison.OrdinalIgnoreCase) ? 1 : 0; - - if (Configuration.IsRunningOnLinux || Configuration.IsRunningOnMac) - { - comboBoxSpellChecker.SelectedIndex = 0; - comboBoxSpellChecker.Enabled = false; - } - - checkBoxAllowEditOfOriginalSubtitle.Checked = gs.AllowEditOfOriginalSubtitle; - checkBoxPromptDeleteLines.Checked = gs.PromptDeleteLines; - - ToolsSettings toolsSettings = Configuration.Settings.Tools; - if (toolsSettings.VerifyPlaySeconds - 2 >= 0 && toolsSettings.VerifyPlaySeconds - 2 < comboBoxToolsVerifySeconds.Items.Count) - { - comboBoxToolsVerifySeconds.SelectedIndex = toolsSettings.VerifyPlaySeconds - 2; - } - else - { - comboBoxToolsVerifySeconds.SelectedIndex = 0; - } - - if (toolsSettings.StartSceneIndex >= 0 && toolsSettings.StartSceneIndex < comboBoxToolsStartSceneIndex.Items.Count) - { - comboBoxToolsStartSceneIndex.SelectedIndex = toolsSettings.StartSceneIndex; - } - else - { - comboBoxToolsStartSceneIndex.SelectedIndex = 0; - } - - if (toolsSettings.EndSceneIndex >= 0 && toolsSettings.EndSceneIndex < comboBoxToolsEndSceneIndex.Items.Count) - { - comboBoxToolsEndSceneIndex.SelectedIndex = toolsSettings.EndSceneIndex; - } - else - { - comboBoxToolsEndSceneIndex.SelectedIndex = 0; - } - - comboBoxMergeShortLineLength.Items.Clear(); - var comboBoxMergeShortLineLengthList = new List(95); - for (int i = 5; i < 100; i++) - { - comboBoxMergeShortLineLengthList.Add(i.ToString(CultureInfo.InvariantCulture)); - } - comboBoxMergeShortLineLength.Items.AddRange(comboBoxMergeShortLineLengthList.ToArray()); - - if (gs.MergeLinesShorterThan >= 5 && gs.MergeLinesShorterThan - 5 < comboBoxMergeShortLineLength.Items.Count) - { - comboBoxMergeShortLineLength.SelectedIndex = gs.MergeLinesShorterThan - 5; - } - else - { - comboBoxMergeShortLineLength.SelectedIndex = 0; - } - - SetDialogStyle(Configuration.Settings.General.DialogStyle); - SetContinuationStyle(Configuration.Settings.General.ContinuationStyle); - - UpdateProfileNames(gs.Profiles); - - // Music notes / music symbols - if (!Utilities.IsRunningOnMono() && Environment.OSVersion.Version.Major < 6) // 6 == Vista/Win2008Server/Win7 - { - float fontSize = comboBoxToolsMusicSymbol.Font.Size; - const string unicodeFontName = Utilities.WinXP2KUnicodeFontName; - listBoxNames.Font = new Font(unicodeFontName, fontSize); - listBoxUserWordLists.Font = new Font(unicodeFontName, fontSize); - listBoxOcrFixList.Font = new Font(unicodeFontName, fontSize); - comboBoxToolsMusicSymbol.Font = new Font(unicodeFontName, fontSize); - textBoxMusicSymbolsToReplace.Font = new Font(unicodeFontName, fontSize); - textBoxNameEtc.Font = new Font(unicodeFontName, fontSize); - textBoxUserWord.Font = new Font(unicodeFontName, fontSize); - textBoxOcrFixKey.Font = new Font(unicodeFontName, fontSize); - textBoxOcrFixValue.Font = new Font(unicodeFontName, fontSize); - } - - comboBoxToolsMusicSymbol.Items.Clear(); - comboBoxToolsMusicSymbol.Items.Add("♪"); - comboBoxToolsMusicSymbol.Items.Add("♫"); - comboBoxToolsMusicSymbol.Items.Add("♪♪"); - comboBoxToolsMusicSymbol.Items.Add("*"); - comboBoxToolsMusicSymbol.Items.Add("#"); - if (toolsSettings.MusicSymbol == "♪") - { - comboBoxToolsMusicSymbol.SelectedIndex = 0; - } - else if (toolsSettings.MusicSymbol == "♫") - { - comboBoxToolsMusicSymbol.SelectedIndex = 1; - } - else if (toolsSettings.MusicSymbol == "♪♪") - { - comboBoxToolsMusicSymbol.SelectedIndex = 2; - } - else if (toolsSettings.MusicSymbol == "*") - { - comboBoxToolsMusicSymbol.SelectedIndex = 3; - } - else if (toolsSettings.MusicSymbol == "#") - { - comboBoxToolsMusicSymbol.SelectedIndex = 4; - } - else - { - comboBoxToolsMusicSymbol.Items.Add(toolsSettings.MusicSymbol); - comboBoxToolsMusicSymbol.SelectedIndex = 5; - } - - textBoxMusicSymbolsToReplace.Text = toolsSettings.MusicSymbolReplace; - checkBoxFixCommonOcrErrorsUsingHardcodedRules.Checked = toolsSettings.OcrFixUseHardcodedRules; - checkBoxFixShortDisplayTimesAllowMoveStartTime.Checked = toolsSettings.FixShortDisplayTimesAllowMoveStartTime; - checkBoxFceSkipStep1.Checked = toolsSettings.FixCommonErrorsSkipStepOne; - checkBoxSpellCheckAutoChangeNames.Checked = toolsSettings.SpellCheckAutoChangeNames; - checkBoxSpellCheckAutoChangeNamesViaSuggestions.Checked = toolsSettings.SpellCheckAutoChangeNamesUseSuggestions; - checkBoxSpellCheckOneLetterWords.Checked = toolsSettings.CheckOneLetterWords; - checkBoxTreatINQuoteAsING.Checked = toolsSettings.SpellCheckEnglishAllowInQuoteAsIng; - checkBoxUseAlwaysToFile.Checked = toolsSettings.RememberUseAlwaysList; - checkBoxUseDoNotBreakAfterList.Checked = toolsSettings.UseNoLineBreakAfter; - checkBoxToolsBreakEarlyComma.Checked = toolsSettings.AutoBreakCommaBreakEarly; - checkBoxToolsBreakEarlyDash.Checked = toolsSettings.AutoBreakDashEarly; - checkBoxToolsBreakEarlyLineEnding.Checked = toolsSettings.AutoBreakLineEndingEarly; - checkBoxToolsBreakByPixelWidth.Checked = toolsSettings.AutoBreakUsePixelWidth; - checkBoxToolsBreakPreferBottomHeavy.Checked = toolsSettings.AutoBreakPreferBottomHeavy; - numericUpDownToolsBreakPreferBottomHeavy.Value = (decimal)toolsSettings.AutoBreakPreferBottomPercent; - checkBoxCpsIncludeWhiteSpace.Checked = !Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace; - - textBoxBingClientSecret.Text = Configuration.Settings.Tools.MicrosoftTranslatorApiKey; - comboBoxBoxBingTokenEndpoint.Text = Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint; - textBoxGoogleTransleApiKey.Text = toolsSettings.GoogleApiV2Key; - - buttonReset.Text = Configuration.Settings.Language.Settings.RestoreDefaultSettings; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - - InitComboBoxWordListLanguages(); - - checkBoxWaveformShowGrid.Checked = Configuration.Settings.VideoControls.WaveformDrawGrid; - checkBoxWaveformShowCps.Checked = Configuration.Settings.VideoControls.WaveformDrawCps; - checkBoxWaveformShowWpm.Checked = Configuration.Settings.VideoControls.WaveformDrawWpm; - panelWaveformGridColor.BackColor = Configuration.Settings.VideoControls.WaveformGridColor; - panelWaveformSelectedColor.BackColor = Configuration.Settings.VideoControls.WaveformSelectedColor; - panelWaveformColor.BackColor = Configuration.Settings.VideoControls.WaveformColor; - panelWaveformBackgroundColor.BackColor = Configuration.Settings.VideoControls.WaveformBackgroundColor; - panelWaveformTextColor.BackColor = Configuration.Settings.VideoControls.WaveformTextColor; - panelWaveformCursorColor.BackColor = Configuration.Settings.VideoControls.WaveformCursorColor; - checkBoxGenerateSpectrogram.Checked = Configuration.Settings.VideoControls.GenerateSpectrogram; - comboBoxSpectrogramAppearance.SelectedIndex = Configuration.Settings.VideoControls.SpectrogramAppearance == "OneColorGradient" ? 0 : 1; - comboBoxWaveformTextSize.Text = Configuration.Settings.VideoControls.WaveformTextSize.ToString(CultureInfo.InvariantCulture); - checkBoxWaveformTextBold.Checked = Configuration.Settings.VideoControls.WaveformTextBold; - checkBoxReverseMouseWheelScrollDirection.Checked = Configuration.Settings.VideoControls.WaveformMouseWheelScrollUpIsForward; - checkBoxAllowOverlap.Checked = Configuration.Settings.VideoControls.WaveformAllowOverlap; - checkBoxWaveformSetVideoPosMoveStartEnd.Checked = Configuration.Settings.VideoControls.WaveformSetVideoPositionOnMoveStartEnd; - checkBoxWaveformHoverFocus.Checked = Configuration.Settings.VideoControls.WaveformFocusOnMouseEnter; - checkBoxListViewMouseEnterFocus.Checked = Configuration.Settings.VideoControls.WaveformListViewFocusOnMouseEnter; - checkBoxWaveformSingleClickSelect.Checked = Configuration.Settings.VideoControls.WaveformSingleClickSelect; - checkBoxWaveformSnapToSceneChanges.Checked = Configuration.Settings.VideoControls.WaveformSnapToSceneChanges; - if (Configuration.Settings.VideoControls.WaveformBorderHitMs >= numericUpDownWaveformBorderHitMs.Minimum && - Configuration.Settings.VideoControls.WaveformBorderHitMs <= numericUpDownWaveformBorderHitMs.Maximum) - { - numericUpDownWaveformBorderHitMs.Value = Configuration.Settings.VideoControls.WaveformBorderHitMs; - } - - checkBoxUseFFmpeg.Checked = gs.UseFFmpegForWaveExtraction; - textBoxFFmpegPath.Text = gs.FFmpegLocation; - if (string.IsNullOrEmpty(textBoxFFmpegPath.Text) && Configuration.IsRunningOnWindows) - { - var guessPath = Path.Combine(Configuration.DataDirectory, "ffmpeg", "ffmpeg.exe"); - if (File.Exists(guessPath)) - { - textBoxFFmpegPath.Text = guessPath; - checkBoxUseFFmpeg.Checked = true; - } - } - - MakeShortcutsTreeView(language); - ShowShortcutsTreeView(); - toolStripMenuItemShortcutsCollapse.Text = Configuration.Settings.Language.General.Collapse; - importShortcutsToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.Import; - exportShortcutsToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.Export; - labelShortcutsSearch.Text = Configuration.Settings.Language.General.Search; - buttonShortcutsClear.Text = Configuration.Settings.Language.DvdSubRip.Clear; - textBoxShortcutSearch.Left = labelShortcutsSearch.Left + labelShortcutsSearch.Width + 5; - buttonShortcutsClear.Left = textBoxShortcutSearch.Left + textBoxShortcutSearch.Width + 5; - - groupBoxShortcuts.Text = language.Shortcuts; - labelShortcut.Text = language.Shortcut; - checkBoxShortcutsControl.Text = language.Control; - checkBoxShortcutsAlt.Text = language.Alt; - checkBoxShortcutsShift.Text = language.Shift; - buttonUpdateShortcut.Text = language.UpdateShortcut; - buttonClearShortcut.Text = Configuration.Settings.Language.DvdSubRip.Clear; - - labelShortcutKey.Text = language.Key; - comboBoxShortcutKey.Left = labelShortcutKey.Left + labelShortcutKey.Width; - comboBoxShortcutKey.Items[0] = Configuration.Settings.Language.General.None; - - groupBoxListViewSyntaxColoring.Text = language.ListViewSyntaxColoring; - checkBoxSyntaxColorDurationTooSmall.Text = language.SyntaxColorDurationIfTooSmall; - checkBoxSyntaxColorDurationTooLarge.Text = language.SyntaxColorDurationIfTooLarge; - checkBoxSyntaxColorTextTooLong.Text = language.SyntaxColorTextIfTooLong; - checkBoxSyntaxColorTextTooWide.Text = language.SyntaxColorTextIfTooWide; - buttonLineWidthSettings.Text = language.SyntaxLineWidthSettings; - checkBoxSyntaxColorTextMoreThanTwoLines.Text = string.Format(language.SyntaxColorTextMoreThanMaxLines, Configuration.Settings.General.MaxNumberOfLines); - checkBoxSyntaxOverlap.Text = language.SyntaxColorOverlap; - checkBoxSyntaxColorGapTooSmall.Text = language.SyntaxColorGap; - buttonListViewSyntaxColorError.Text = language.SyntaxErrorColor; - - UiUtil.FixLargeFonts(this, buttonOK); - - checkBoxShortcutsControl.Left = labelShortcut.Left + labelShortcut.Width + 9; - checkBoxShortcutsAlt.Left = checkBoxShortcutsControl.Left + checkBoxShortcutsControl.Width + 9; - checkBoxShortcutsShift.Left = checkBoxShortcutsAlt.Left + checkBoxShortcutsAlt.Width + 9; - labelShortcutKey.Left = checkBoxShortcutsShift.Left + checkBoxShortcutsShift.Width + 9; - comboBoxShortcutKey.Left = labelShortcutKey.Left + labelShortcutKey.Width + 2; - buttonUpdateShortcut.Left = comboBoxShortcutKey.Left + comboBoxShortcutKey.Width + 15; - buttonClearShortcut.Left = buttonUpdateShortcut.Left + buttonUpdateShortcut.Width + 15; - buttonLineWidthSettings.Left = checkBoxSyntaxColorTextTooWide.Left + checkBoxSyntaxColorTextTooWide.Width + 9; - - _oldVlcLocation = gs.VlcLocation; - _oldVlcLocationRelative = gs.VlcLocationRelative; - - _oldListViewShowCps = Configuration.Settings.Tools.ListViewShowColumnCharsPerSec; - _oldListViewShowWpm = Configuration.Settings.Tools.ListViewShowColumnWordsPerMin; - - labelPlatform.Text = (IntPtr.Size * 8) + "-bit"; - - _loading = false; - UpdateSsaExample(); - } - - private void SetDialogStyle(DialogType dialogStyle) - { - comboBoxDialogStyle.Items.Clear(); - comboBoxDialogStyle.Items.Add(Configuration.Settings.Language.Settings.DialogStyleDashBothLinesWithSpace); - comboBoxDialogStyle.Items.Add(Configuration.Settings.Language.Settings.DialogStyleDashBothLinesWithoutSpace); - comboBoxDialogStyle.Items.Add(Configuration.Settings.Language.Settings.DialogStyleDashSecondLineWithSpace); - comboBoxDialogStyle.Items.Add(Configuration.Settings.Language.Settings.DialogStyleDashSecondLineWithoutSpace); - comboBoxDialogStyle.SelectedIndex = 0; - switch (dialogStyle) - { - case DialogType.DashBothLinesWithSpace: - comboBoxDialogStyle.SelectedIndex = 0; - break; - case DialogType.DashBothLinesWithoutSpace: - comboBoxDialogStyle.SelectedIndex = 1; - break; - case DialogType.DashSecondLineWithSpace: - comboBoxDialogStyle.SelectedIndex = 2; - break; - case DialogType.DashSecondLineWithoutSpace: - comboBoxDialogStyle.SelectedIndex = 3; - break; - } - } - - private void SetContinuationStyle(ContinuationStyle continuationStyle) - { - comboBoxContinuationStyle.Items.Clear(); - comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleNone); - comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleNoneTrailingDots); - comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleNoneLeadingTrailingDots); - comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleOnlyTrailingDots); - comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleLeadingTrailingDots); - comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleLeadingTrailingDash); - comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleLeadingTrailingDashDots); - comboBoxContinuationStyle.SelectedIndex = 0; - toolTipContinuationPreview.RemoveAll(); - toolTipContinuationPreview.SetToolTip(comboBoxContinuationStyle, ContinuationUtilities.GetContinuationStylePreview(continuationStyle)); - comboBoxContinuationStyle.SelectedIndex = ContinuationUtilities.GetIndexFromContinuationStyle(continuationStyle); - - var dropDownContinuationWidth = comboBoxContinuationStyle.Width; - var dropDownDialogStyleWidth = comboBoxDialogStyle.Width; - using (var g = Graphics.FromHwnd(IntPtr.Zero)) - { - foreach (var item in comboBoxContinuationStyle.Items) - { - var itemWidth = (int)g.MeasureString((string)item, Font).Width + 5; - dropDownContinuationWidth = Math.Max(itemWidth, dropDownContinuationWidth); - } - - foreach (var item in comboBoxDialogStyle.Items) - { - var itemWidth = (int)g.MeasureString((string)item, Font).Width + 5; - dropDownDialogStyleWidth = Math.Max(itemWidth, dropDownDialogStyleWidth); - } - } - - comboBoxContinuationStyle.DropDownWidth = dropDownContinuationWidth; - comboBoxDialogStyle.DropDownWidth = dropDownDialogStyleWidth; - } - - private Guid _oldProfileId = Guid.Empty; - private void UpdateProfileNames(List profiles) - { - comboBoxRulesProfileName.BeginUpdate(); - comboBoxRulesProfileName.Items.Clear(); - foreach (var profile in profiles) - { - comboBoxRulesProfileName.Items.Add(profile.Name); - if (_oldProfileId == Guid.Empty && profile.Name == Configuration.Settings.General.CurrentProfile || profile.Id == _oldProfileId) - { - comboBoxRulesProfileName.SelectedIndex = comboBoxRulesProfileName.Items.Count - 1; - _oldProfileId = profile.Id; - } - } - comboBoxRulesProfileName.EndUpdate(); - if (comboBoxRulesProfileName.SelectedIndex < 0 && comboBoxRulesProfileName.Items.Count > 0 && comboBoxRulesProfileName.Items.Count > 0) - { - comboBoxRulesProfileName.SelectedIndex = 0; - } - } - - ShortcutNode _shortcuts = new ShortcutNode("root"); - - private void MakeShortcutsTreeView(LanguageStructure.Settings language) - { - _shortcuts = new ShortcutNode("root"); - - var generalNode = new ShortcutNode(Configuration.Settings.Language.General.GeneralText); - AddNode(generalNode, language.MergeSelectedLines, nameof(Configuration.Settings.Shortcuts.GeneralMergeSelectedLines)); - AddNode(generalNode, language.MergeWithPrevious, nameof(Configuration.Settings.Shortcuts.GeneralMergeWithPrevious)); - AddNode(generalNode, language.MergeWithNext, nameof(Configuration.Settings.Shortcuts.GeneralMergeWithNext)); - AddNode(generalNode, language.MergeSelectedLinesAndAutoBreak, nameof(Configuration.Settings.Shortcuts.GeneralMergeSelectedLinesAndAutoBreak)); - AddNode(generalNode, language.MergeSelectedLinesAndUnbreak, nameof(Configuration.Settings.Shortcuts.GeneralMergeSelectedLinesAndUnbreak)); - AddNode(generalNode, language.MergeSelectedLinesAndUnbreakCjk, nameof(Configuration.Settings.Shortcuts.GeneralMergeSelectedLinesAndUnbreakCjk)); - AddNode(generalNode, language.MergeSelectedLinesOnlyFirstText, nameof(Configuration.Settings.Shortcuts.GeneralMergeSelectedLinesOnlyFirstText)); - AddNode(generalNode, language.MergeSelectedLinesBilingual, nameof(Configuration.Settings.Shortcuts.GeneralMergeSelectedLinesBilingual)); - AddNode(generalNode, language.MergeOriginalAndTranslation, nameof(Configuration.Settings.Shortcuts.GeneralMergeOriginalAndTranslation)); - AddNode(generalNode, language.ToggleTranslationMode, nameof(Configuration.Settings.Shortcuts.GeneralToggleTranslationMode)); - AddNode(generalNode, language.SwitchOriginalAndTranslation, nameof(Configuration.Settings.Shortcuts.GeneralSwitchOriginalAndTranslation)); - AddNode(generalNode, language.WaveformPlayFirstSelectedSubtitle, nameof(Configuration.Settings.Shortcuts.GeneralPlayFirstSelected)); - AddNode(generalNode, language.GoToFirstSelectedLine, nameof(Configuration.Settings.Shortcuts.GeneralGoToFirstSelectedLine)); - AddNode(generalNode, language.GoToNextEmptyLine, nameof(Configuration.Settings.Shortcuts.GeneralGoToNextEmptyLine)); - AddNode(generalNode, language.GoToNext, nameof(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle)); - AddNode(generalNode, language.GoToNextCursorAtEnd, nameof(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitleCursorAtEnd)); - AddNode(generalNode, language.GoToPrevious, nameof(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle)); - AddNode(generalNode, language.GoToCurrentSubtitleStart, nameof(Configuration.Settings.Shortcuts.GeneralGoToStartOfCurrentSubtitle)); - AddNode(generalNode, language.GoToCurrentSubtitleEnd, nameof(Configuration.Settings.Shortcuts.GeneralGoToEndOfCurrentSubtitle)); - AddNode(generalNode, language.GoToPreviousSubtitleAndFocusVideo, nameof(Configuration.Settings.Shortcuts.GeneralGoToPreviousSubtitleAndFocusVideo)); - AddNode(generalNode, language.GoToNextSubtitleAndFocusVideo, nameof(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitleAndFocusVideo)); - AddNode(generalNode, language.GoToPrevSubtitleAndPlay, nameof(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitleAndPlay)); - AddNode(generalNode, language.GoToNextSubtitleAndPlay, nameof(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitleAndPlay)); - AddNode(generalNode, language.Help, nameof(Configuration.Settings.Shortcuts.GeneralHelp), true); - AddNode(generalNode, language.UnbreakNoSpace, nameof(Configuration.Settings.Shortcuts.GeneralUnbrekNoSpace)); - AddNode(generalNode, language.ToggleBookmarks, nameof(Configuration.Settings.Shortcuts.GeneralToggleBookmarks)); - AddNode(generalNode, language.ToggleBookmarksWithComment, nameof(Configuration.Settings.Shortcuts.GeneralToggleBookmarksWithText), true); - AddNode(generalNode, language.ClearBookmarks, nameof(Configuration.Settings.Shortcuts.GeneralClearBookmarks)); - AddNode(generalNode, language.GoToBookmark, nameof(Configuration.Settings.Shortcuts.GeneralGoToBookmark)); - AddNode(generalNode, language.GoToPreviousBookmark, nameof(Configuration.Settings.Shortcuts.GeneralGoToPreviousBookmark)); - AddNode(generalNode, language.GoToNextBookmark, nameof(Configuration.Settings.Shortcuts.GeneralGoToNextBookmark)); - AddNode(generalNode, language.ChooseProfile, nameof(Configuration.Settings.Shortcuts.ChooseProfile)); - AddNode(generalNode, language.DuplicateLine, nameof(Configuration.Settings.Shortcuts.DuplicateLine)); - if (generalNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(generalNode); - } - - var fileNode = new ShortcutNode(Configuration.Settings.Language.Main.Menu.File.Title); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.New, nameof(Configuration.Settings.Shortcuts.MainFileNew), true); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.Open, nameof(Configuration.Settings.Shortcuts.MainFileOpen), true); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.OpenKeepVideo, nameof(Configuration.Settings.Shortcuts.MainFileOpenKeepVideo), true); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.Save, nameof(Configuration.Settings.Shortcuts.MainFileSave), true); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.SaveAs, nameof(Configuration.Settings.Shortcuts.MainFileSaveAs), true); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.SaveOriginal, nameof(Configuration.Settings.Shortcuts.MainFileSaveOriginal), true); - AddNode(fileNode, Configuration.Settings.Language.Main.SaveOriginalSubtitleAs, nameof(Configuration.Settings.Shortcuts.MainFileSaveOriginalAs), true); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.OpenOriginal, nameof(Configuration.Settings.Shortcuts.MainFileOpenOriginal), true); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.CloseOriginal, nameof(Configuration.Settings.Shortcuts.MainFileCloseOriginal), true); - AddNode(fileNode, language.MainFileSaveAll, nameof(Configuration.Settings.Shortcuts.MainFileSaveAll)); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.Compare, nameof(Configuration.Settings.Shortcuts.MainFileCompare), true); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.ImportText, nameof(Configuration.Settings.Shortcuts.MainFileImportPlainText), true); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.ImportTimecodes, nameof(Configuration.Settings.Shortcuts.MainFileImportTimeCodes), true); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.Export + " -> " + Configuration.Settings.Language.Main.Menu.File.ExportEbu, nameof(Configuration.Settings.Shortcuts.MainFileExportEbu), true); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.Export + " -> " + Configuration.Settings.Language.Main.Menu.File.ExportPac, nameof(Configuration.Settings.Shortcuts.MainFileExportPac), true); - AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.Export + " -> " + Configuration.Settings.Language.Main.Menu.File.ExportPlainText, nameof(Configuration.Settings.Shortcuts.MainFileExportPlainText), true); - if (fileNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(fileNode); - } - - var editNode = new ShortcutNode(Configuration.Settings.Language.Main.Menu.Edit.Title); - AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.Undo, nameof(Configuration.Settings.Shortcuts.MainEditUndo), true); - AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.Redo, nameof(Configuration.Settings.Shortcuts.MainEditRedo), true); - AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.Find, nameof(Configuration.Settings.Shortcuts.MainEditFind), true); - AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.FindNext, nameof(Configuration.Settings.Shortcuts.MainEditFindNext), true); - AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.Replace, nameof(Configuration.Settings.Shortcuts.MainEditReplace), true); - AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.MultipleReplace, nameof(Configuration.Settings.Shortcuts.MainEditMultipleReplace), true); - AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.ModifySelection, nameof(Configuration.Settings.Shortcuts.MainEditModifySelection), true); - AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.GoToSubtitleNumber, nameof(Configuration.Settings.Shortcuts.MainEditGoToLineNumber), true); - AddNode(editNode, Configuration.Settings.Language.VobSubOcr.RightToLeft, nameof(Configuration.Settings.Shortcuts.MainEditRightToLeft), true); - AddNode(editNode, language.FixRTLViaUnicodeChars, nameof(Configuration.Settings.Shortcuts.MainEditFixRTLViaUnicodeChars), true); - AddNode(editNode, language.RemoveRTLUnicodeChars, nameof(Configuration.Settings.Shortcuts.MainEditRemoveRTLUnicodeChars), true); - AddNode(editNode, language.ReverseStartAndEndingForRtl, nameof(Configuration.Settings.Shortcuts.MainEditReverseStartAndEndingForRTL), true); - AddNode(editNode, language.ToggleTranslationAndOriginalInPreviews, nameof(Configuration.Settings.Shortcuts.MainEditToggleTranslationOriginalInPreviews), true); - if (editNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(editNode); - } - - var toolsNode = new ShortcutNode(Configuration.Settings.Language.Main.Menu.Tools.Title); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.SubtitlesBridgeGaps, nameof(Configuration.Settings.Shortcuts.MainToolsDurationsBridgeGap), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.MinimumDisplayTimeBetweenParagraphs, nameof(Configuration.Settings.Shortcuts.MainToolsMinimumDisplayTimeBetweenParagraphs), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.FixCommonErrors, nameof(Configuration.Settings.Shortcuts.MainToolsFixCommonErrors), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.StartNumberingFrom, nameof(Configuration.Settings.Shortcuts.MainToolsRenumber), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.RemoveTextForHearingImpaired, nameof(Configuration.Settings.Shortcuts.MainToolsRemoveTextForHI), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.ChangeCasing, nameof(Configuration.Settings.Shortcuts.MainToolsChangeCasing), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.MakeNewEmptyTranslationFromCurrentSubtitle, nameof(Configuration.Settings.Shortcuts.MainToolsMakeEmptyFromCurrent), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.MergeShortLines, nameof(Configuration.Settings.Shortcuts.MainToolsMergeShortLines), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.MergeDuplicateText, nameof(Configuration.Settings.Shortcuts.MainToolsMergeDuplicateText), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.MergeSameTimeCodes, nameof(Configuration.Settings.Shortcuts.MainToolsMergeSameTimeCodes), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.SplitLongLines, nameof(Configuration.Settings.Shortcuts.MainToolsSplitLongLines), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.BatchConvert, nameof(Configuration.Settings.Shortcuts.MainToolsBatchConvert)); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.MeasurementConverter, nameof(Configuration.Settings.Shortcuts.MainToolsMeasurementConverter), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.SplitSubtitle, nameof(Configuration.Settings.Shortcuts.MainToolsSplit), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.AppendSubtitle, nameof(Configuration.Settings.Shortcuts.MainToolsAppend), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.JoinSubtitles, nameof(Configuration.Settings.Shortcuts.MainToolsJoin), true); - AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.ContextMenu.AutoDurationCurrentLine, nameof(Configuration.Settings.Shortcuts.MainToolsAutoDuration)); - AddNode(toolsNode, language.ShowBeamer, nameof(Configuration.Settings.Shortcuts.MainToolsBeamer)); - if (toolsNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(toolsNode); - } - - var videoNode = new ShortcutNode(Configuration.Settings.Language.Main.Menu.Video.Title); - AddNode(videoNode, Configuration.Settings.Language.Main.Menu.Video.OpenVideo, nameof(Configuration.Settings.Shortcuts.MainVideoOpen), true); - AddNode(videoNode, Configuration.Settings.Language.Main.Menu.Video.CloseVideo, nameof(Configuration.Settings.Shortcuts.MainVideoClose), true); - AddNode(videoNode, language.TogglePlayPause, nameof(Configuration.Settings.Shortcuts.MainVideoPlayPauseToggle)); - AddNode(videoNode, language.Pause, nameof(Configuration.Settings.Shortcuts.MainVideoPause)); - AddNode(videoNode, Configuration.Settings.Language.Main.VideoControls.PlayFromJustBeforeText, nameof(Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore)); - AddNode(videoNode, Configuration.Settings.Language.Main.Menu.Video.ShowHideVideo, nameof(Configuration.Settings.Shortcuts.MainVideoShowHideVideo), true); - AddNode(videoNode, language.FoucsSetVideoPosition, nameof(Configuration.Settings.Shortcuts.MainVideoFoucsSetVideoPosition)); - AddNode(videoNode, language.ToggleDockUndockOfVideoControls, nameof(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls), true); - AddNode(videoNode, language.GoBack1Frame, nameof(Configuration.Settings.Shortcuts.MainVideo1FrameLeft)); - AddNode(videoNode, language.GoForward1Frame, nameof(Configuration.Settings.Shortcuts.MainVideo1FrameRight)); - AddNode(videoNode, language.GoBack1FrameWithPlay, nameof(Configuration.Settings.Shortcuts.MainVideo1FrameLeftWithPlay)); - AddNode(videoNode, language.GoForward1FrameWithPlay, nameof(Configuration.Settings.Shortcuts.MainVideo1FrameRightWithPlay)); - AddNode(videoNode, language.GoBack100Milliseconds, nameof(Configuration.Settings.Shortcuts.MainVideo100MsLeft)); - AddNode(videoNode, language.GoForward100Milliseconds, nameof(Configuration.Settings.Shortcuts.MainVideo100MsRight)); - AddNode(videoNode, language.GoBack500Milliseconds, nameof(Configuration.Settings.Shortcuts.MainVideo500MsLeft)); - AddNode(videoNode, language.GoForward500Milliseconds, nameof(Configuration.Settings.Shortcuts.MainVideo500MsRight)); - AddNode(videoNode, language.GoBack1Second, nameof(Configuration.Settings.Shortcuts.MainVideo1000MsLeft)); - AddNode(videoNode, language.GoForward1Second, nameof(Configuration.Settings.Shortcuts.MainVideo1000MsRight)); - AddNode(videoNode, language.GoBack5Seconds, nameof(Configuration.Settings.Shortcuts.MainVideo5000MsLeft)); - AddNode(videoNode, language.GoForward5Seconds, nameof(Configuration.Settings.Shortcuts.MainVideo5000MsRight)); - AddNode(videoNode, language.GoBackXSSeconds, nameof(Configuration.Settings.Shortcuts.MainVideoXSMsLeft)); - AddNode(videoNode, language.GoForwardXSSeconds, nameof(Configuration.Settings.Shortcuts.MainVideoXSMsRight)); - AddNode(videoNode, language.GoBackXLSeconds, nameof(Configuration.Settings.Shortcuts.MainVideoXLMsLeft)); - AddNode(videoNode, language.GoForwardXLSeconds, nameof(Configuration.Settings.Shortcuts.MainVideoXLMsRight)); - AddNode(videoNode, language.GoBack3Second, nameof(Configuration.Settings.Shortcuts.MainVideo3000MsLeft)); - AddNode(videoNode, language.GoToStartCurrent, nameof(Configuration.Settings.Shortcuts.MainVideoGoToStartCurrent)); - AddNode(videoNode, language.ToggleStartEndCurrent, nameof(Configuration.Settings.Shortcuts.MainVideoToggleStartEndCurrent)); - AddNode(videoNode, language.PlayCurrent, nameof(Configuration.Settings.Shortcuts.MainVideoPlayCurrent)); - AddNode(videoNode, language.WaveformGoToPrevSubtitle, nameof(Configuration.Settings.Shortcuts.MainVideoGoToPrevSubtitle)); - AddNode(videoNode, language.WaveformGoToNextSubtitle, nameof(Configuration.Settings.Shortcuts.MainVideoGoToNextSubtitle)); - AddNode(videoNode, language.WaveformGoToPrevChapter, nameof(Configuration.Settings.Shortcuts.MainVideoGoToPrevChapter)); - AddNode(videoNode, language.WaveformGoToNextChapter, nameof(Configuration.Settings.Shortcuts.MainVideoGoToNextChapter)); - AddNode(videoNode, language.WaveformSelectNextSubtitle, nameof(Configuration.Settings.Shortcuts.MainVideoSelectNextSubtitle)); - AddNode(videoNode, language.Fullscreen, nameof(Configuration.Settings.Shortcuts.MainVideoFullscreen)); - AddNode(videoNode, language.PlayRateSlower, nameof(Configuration.Settings.Shortcuts.MainVideoSlower)); - AddNode(videoNode, language.PlayRateFaster, nameof(Configuration.Settings.Shortcuts.MainVideoFaster)); - AddNode(videoNode, language.VideoResetSpeedAndZoom, nameof(Configuration.Settings.Shortcuts.MainVideoReset)); - if (videoNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(videoNode); - } - - var spellCheckNode = new ShortcutNode(Configuration.Settings.Language.Main.Menu.SpellCheck.Title); - AddNode(spellCheckNode, Configuration.Settings.Language.Main.Menu.SpellCheck.Title, nameof(Configuration.Settings.Shortcuts.MainSpellCheck), true); - AddNode(spellCheckNode, Configuration.Settings.Language.Main.Menu.SpellCheck.FindDoubleWords, nameof(Configuration.Settings.Shortcuts.MainSpellCheckFindDoubleWords), true); - AddNode(spellCheckNode, Configuration.Settings.Language.Main.Menu.SpellCheck.AddToNameList, nameof(Configuration.Settings.Shortcuts.MainSpellCheckAddWordToNames), true); - if (spellCheckNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(spellCheckNode); - } - - var syncNode = new ShortcutNode(Configuration.Settings.Language.Main.Menu.Synchronization.Title); - AddNode(syncNode, Configuration.Settings.Language.Main.Menu.Synchronization.AdjustAllTimes, nameof(Configuration.Settings.Shortcuts.MainSynchronizationAdjustTimes), true); - AddNode(syncNode, Configuration.Settings.Language.Main.Menu.Synchronization.VisualSync, nameof(Configuration.Settings.Shortcuts.MainSynchronizationVisualSync), true); - AddNode(syncNode, Configuration.Settings.Language.Main.Menu.Synchronization.PointSync, nameof(Configuration.Settings.Shortcuts.MainSynchronizationPointSync), true); - AddNode(syncNode, Configuration.Settings.Language.Main.Menu.Synchronization.PointSyncViaOtherSubtitle, nameof(Configuration.Settings.Shortcuts.MainSynchronizationPointSyncViaFile), true); - AddNode(syncNode, Configuration.Settings.Language.Main.Menu.Tools.ChangeFrameRate, nameof(Configuration.Settings.Shortcuts.MainSynchronizationChangeFrameRate), true); - if (syncNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(syncNode); - } - - var listViewAndTextBoxNode = new ShortcutNode(language.ListViewAndTextBox); - AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.InsertAfter, nameof(Configuration.Settings.Shortcuts.MainInsertAfter)); - AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.InsertBefore, nameof(Configuration.Settings.Shortcuts.MainInsertBefore)); - AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.General.Italic, nameof(Configuration.Settings.Shortcuts.MainListViewItalic), true); - AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.General.Bold, nameof(Configuration.Settings.Shortcuts.MainListViewBold), true); - AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.General.Underline, nameof(Configuration.Settings.Shortcuts.MainListViewUnderline), true); - AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.Box, nameof(Configuration.Settings.Shortcuts.MainListViewBox), true); - AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.General.SplitLine.Replace("!", string.Empty), nameof(Configuration.Settings.Shortcuts.MainListViewSplit), true); - AddNode(listViewAndTextBoxNode, language.ToggleMusicSymbols, nameof(Configuration.Settings.Shortcuts.MainListViewToggleMusicSymbols), true); - AddNode(listViewAndTextBoxNode, language.AlignmentN1, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN1)); - AddNode(listViewAndTextBoxNode, language.AlignmentN2, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN2)); - AddNode(listViewAndTextBoxNode, language.AlignmentN3, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN3)); - AddNode(listViewAndTextBoxNode, language.AlignmentN4, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN4)); - AddNode(listViewAndTextBoxNode, language.AlignmentN5, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN5)); - AddNode(listViewAndTextBoxNode, language.AlignmentN6, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN6)); - AddNode(listViewAndTextBoxNode, language.AlignmentN7, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN7)); - AddNode(listViewAndTextBoxNode, language.AlignmentN8, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN8)); - AddNode(listViewAndTextBoxNode, language.AlignmentN9, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN9)); - AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.RemoveFormattingAll, nameof(Configuration.Settings.Shortcuts.MainRemoveFormatting), true); - AddNode(listViewAndTextBoxNode, language.RemoveTimeCodes, nameof(Configuration.Settings.Shortcuts.MainListViewRemoveTimeCodes)); - if (listViewAndTextBoxNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(listViewAndTextBoxNode); - } - - var listViewNode = new ShortcutNode(Configuration.Settings.Language.Main.Controls.ListView); - AddNode(listViewNode, language.MergeDialog, nameof(Configuration.Settings.Shortcuts.MainMergeDialog)); - AddNode(listViewNode, language.ToggleFocus, nameof(Configuration.Settings.Shortcuts.MainToggleFocus)); - AddNode(listViewNode, language.ToggleDialogDashes, nameof(Configuration.Settings.Shortcuts.MainListViewToggleDashes)); - AddNode(listViewNode, language.Alignment, nameof(Configuration.Settings.Shortcuts.MainListViewAlignment), true); - AddNode(listViewNode, language.CopyTextOnly, nameof(Configuration.Settings.Shortcuts.MainListViewCopyText)); - AddNode(listViewNode, language.CopyTextOnlyFromOriginalToCurrent, nameof(Configuration.Settings.Shortcuts.MainListViewCopyTextFromOriginalToCurrent), true); - AddNode(listViewNode, language.AutoDurationSelectedLines, nameof(Configuration.Settings.Shortcuts.MainListViewAutoDuration)); - AddNode(listViewNode, language.ListViewColumnDelete, nameof(Configuration.Settings.Shortcuts.MainListViewColumnDeleteText), true); - AddNode(listViewNode, language.ListViewColumnDeleteAndShiftUp, nameof(Configuration.Settings.Shortcuts.MainListViewColumnDeleteTextAndShiftUp), true); - AddNode(listViewNode, language.ListViewColumnInsert, nameof(Configuration.Settings.Shortcuts.MainListViewColumnInsertText), true); - AddNode(listViewNode, language.ListViewColumnPaste, nameof(Configuration.Settings.Shortcuts.MainListViewColumnPaste), true); - AddNode(listViewNode, language.ListViewColumnTextUp, nameof(Configuration.Settings.Shortcuts.MainListViewColumnTextUp), true); - AddNode(listViewNode, language.ListViewColumnTextDown, nameof(Configuration.Settings.Shortcuts.MainListViewColumnTextDown), true); - AddNode(listViewNode, language.ListViewFocusWaveform, nameof(Configuration.Settings.Shortcuts.MainListViewFocusWaveform)); - AddNode(listViewNode, language.ListViewGoToNextError, nameof(Configuration.Settings.Shortcuts.MainListViewGoToNextError)); - if (listViewNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(listViewNode); - } - - var textBoxNode = new ShortcutNode(language.TextBox); - AddNode(textBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.SplitLineAtCursorPosition, nameof(Configuration.Settings.Shortcuts.MainTextBoxSplitAtCursor)); - AddNode(textBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.SplitLineAtCursorAndWaveformPosition, nameof(Configuration.Settings.Shortcuts.MainTextBoxSplitAtCursorAndVideoPos)); - AddNode(textBoxNode, language.SplitSelectedLineBilingual, nameof(Configuration.Settings.Shortcuts.MainTextBoxSplitSelectedLineBilingual)); - AddNode(textBoxNode, language.MainTextBoxMoveLastWordDown, nameof(Configuration.Settings.Shortcuts.MainTextBoxMoveLastWordDown)); - AddNode(textBoxNode, language.MainTextBoxMoveFirstWordFromNextUp, nameof(Configuration.Settings.Shortcuts.MainTextBoxMoveFirstWordFromNextUp)); - AddNode(textBoxNode, language.MainTextBoxMoveLastWordDownCurrent, nameof(Configuration.Settings.Shortcuts.MainTextBoxMoveLastWordDownCurrent)); - AddNode(textBoxNode, language.MainTextBoxMoveFirstWordUpCurrent, nameof(Configuration.Settings.Shortcuts.MainTextBoxMoveFirstWordUpCurrent)); - AddNode(textBoxNode, language.MainTextBoxSelectionToLower, nameof(Configuration.Settings.Shortcuts.MainTextBoxSelectionToLower)); - AddNode(textBoxNode, language.MainTextBoxSelectionToUpper, nameof(Configuration.Settings.Shortcuts.MainTextBoxSelectionToUpper)); - AddNode(textBoxNode, language.MainTextBoxSelectionToggleCasing, nameof(Configuration.Settings.Shortcuts.MainTextBoxSelectionToggleCasing)); - AddNode(textBoxNode, language.MainTextBoxSelectionToRuby, nameof(Configuration.Settings.Shortcuts.MainTextBoxSelectionToRuby), true); - AddNode(textBoxNode, language.MainTextBoxToggleAutoDuration, nameof(Configuration.Settings.Shortcuts.MainTextBoxToggleAutoDuration)); - AddNode(textBoxNode, language.MainTextBoxAutoBreak, nameof(Configuration.Settings.Shortcuts.MainTextBoxAutoBreak)); - AddNode(textBoxNode, language.MainTextBoxAutoBreakFromPos, nameof(Configuration.Settings.Shortcuts.MainTextBoxBreakAtPosition)); - AddNode(textBoxNode, language.MainTextBoxAutoBreakFromPosAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainTextBoxBreakAtPositionAndGoToNext)); - AddNode(textBoxNode, language.MainTextBoxUnbreak, nameof(Configuration.Settings.Shortcuts.MainTextBoxUnbreak)); - if (textBoxNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(textBoxNode); - } - - var translateNode = new ShortcutNode(Configuration.Settings.Language.Main.VideoControls.Translate); - AddNode(translateNode, Configuration.Settings.Language.Main.VideoControls.GoogleIt, nameof(Configuration.Settings.Shortcuts.MainTranslateGoogleIt)); - AddNode(translateNode, Configuration.Settings.Language.Main.VideoControls.GoogleTranslate, nameof(Configuration.Settings.Shortcuts.MainTranslateGoogleTranslate), true); - AddNode(translateNode, language.CustomSearch1, nameof(Configuration.Settings.Shortcuts.MainTranslateCustomSearch1)); - AddNode(translateNode, language.CustomSearch2, nameof(Configuration.Settings.Shortcuts.MainTranslateCustomSearch2)); - AddNode(translateNode, language.CustomSearch3, nameof(Configuration.Settings.Shortcuts.MainTranslateCustomSearch3)); - AddNode(translateNode, language.CustomSearch4, nameof(Configuration.Settings.Shortcuts.MainTranslateCustomSearch4)); - AddNode(translateNode, language.CustomSearch5, nameof(Configuration.Settings.Shortcuts.MainTranslateCustomSearch5)); - if (translateNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(translateNode); - } - - var createAndAdjustNode = new ShortcutNode(Configuration.Settings.Language.Main.VideoControls.CreateAndAdjust); - AddNode(createAndAdjustNode, Configuration.Settings.Language.Main.VideoControls.InsertNewSubtitleAtVideoPosition, nameof(Configuration.Settings.Shortcuts.MainCreateInsertSubAtVideoPos)); - AddNode(createAndAdjustNode, Configuration.Settings.Language.Main.VideoControls.InsertNewSubtitleAtVideoPositionNoTextBoxFocus, nameof(Configuration.Settings.Shortcuts.MainCreateInsertSubAtVideoPosNoTextBoxFocus)); - AddNode(createAndAdjustNode, language.MainCreateStartDownEndUp, nameof(Configuration.Settings.Shortcuts.MainCreateStartDownEndUp)); - AddNode(createAndAdjustNode, Configuration.Settings.Language.Main.VideoControls.SetStartTime, nameof(Configuration.Settings.Shortcuts.MainCreateSetStart)); - AddNode(createAndAdjustNode, language.AdjustSetStartTimeKeepDuration, nameof(Configuration.Settings.Shortcuts.MainAdjustSetStartKeepDuration)); - AddNode(createAndAdjustNode, Configuration.Settings.Language.Main.VideoControls.SetstartTimeAndOffsetOfRest, nameof(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest)); - AddNode(createAndAdjustNode, Configuration.Settings.Language.Main.VideoControls.SetstartTimeAndOffsetOfRest, nameof(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest2)); - AddNode(createAndAdjustNode, language.AdjustSetStartAutoDurationAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustSetStartAutoDurationAndGoToNext)); - AddNode(createAndAdjustNode, language.AdjustStartDownEndUpAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustStartDownEndUpAndGoToNext)); - AddNode(createAndAdjustNode, language.AdjustSetStartAndEndOfPrevious, nameof(Configuration.Settings.Shortcuts.MainAdjustSetStartAndEndOfPrevious)); - AddNode(createAndAdjustNode, language.AdjustSetStartAndEndOfPreviousAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustSetStartAndEndOfPreviousAndGoToNext)); - AddNode(createAndAdjustNode, Configuration.Settings.Language.Main.VideoControls.SetEndTime, nameof(Configuration.Settings.Shortcuts.MainCreateSetEnd)); - AddNode(createAndAdjustNode, language.AdjustSetEndTimeAndPause, nameof(Configuration.Settings.Shortcuts.MainAdjustSetEndAndPause)); - AddNode(createAndAdjustNode, language.CreateSetEndAddNewAndGoToNew, nameof(Configuration.Settings.Shortcuts.MainCreateSetEndAddNewAndGoToNew)); - AddNode(createAndAdjustNode, language.AdjustSetEndTimeAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustSetEndAndGotoNext)); - AddNode(createAndAdjustNode, language.AdjustSetEndAndOffsetTheRest, nameof(Configuration.Settings.Shortcuts.MainAdjustSetEndAndOffsetTheRest)); - AddNode(createAndAdjustNode, language.AdjustSetEndAndOffsetTheRestAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustSetEndAndOffsetTheRestAndGoToNext)); - AddNode(createAndAdjustNode, language.AdjustSetEndNextStartAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustSetEndNextStartAndGoToNext)); - AddNode(createAndAdjustNode, language.AdjustViaEndAutoStart, nameof(Configuration.Settings.Shortcuts.MainAdjustViaEndAutoStart)); - AddNode(createAndAdjustNode, language.AdjustViaEndAutoStartAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustViaEndAutoStartAndGoToNext)); - AddNode(createAndAdjustNode, language.AdjustSelected100MsBack, nameof(Configuration.Settings.Shortcuts.MainAdjustSelected100MsBack)); - AddNode(createAndAdjustNode, language.AdjustSelected100MsForward, nameof(Configuration.Settings.Shortcuts.MainAdjustSelected100MsForward)); - AddNode(createAndAdjustNode, string.Format(language.AdjustStartXMsBack, Configuration.Settings.Tools.MoveStartEndMs), nameof(Configuration.Settings.Shortcuts.MainAdjustStartXMsBack)); - AddNode(createAndAdjustNode, string.Format(language.AdjustStartXMsForward, Configuration.Settings.Tools.MoveStartEndMs), nameof(Configuration.Settings.Shortcuts.MainAdjustStartXMsForward)); - AddNode(createAndAdjustNode, string.Format(language.AdjustEndXMsBack, Configuration.Settings.Tools.MoveStartEndMs), nameof(Configuration.Settings.Shortcuts.MainAdjustEndXMsBack)); - AddNode(createAndAdjustNode, string.Format(language.AdjustEndXMsForward, Configuration.Settings.Tools.MoveStartEndMs), nameof(Configuration.Settings.Shortcuts.MainAdjustEndXMsForward)); - AddNode(createAndAdjustNode, language.AdjustStartOneFrameBack, nameof(Configuration.Settings.Shortcuts.MoveStartOneFrameBack)); - AddNode(createAndAdjustNode, language.AdjustStartOneFrameForward, nameof(Configuration.Settings.Shortcuts.MoveStartOneFrameForward)); - AddNode(createAndAdjustNode, language.AdjustEndOneFrameBack, nameof(Configuration.Settings.Shortcuts.MoveEndOneFrameBack)); - AddNode(createAndAdjustNode, language.AdjustEndOneFrameForward, nameof(Configuration.Settings.Shortcuts.MoveEndOneFrameForward)); - AddNode(createAndAdjustNode, language.AdjustStartOneFrameBackKeepGapPrev, nameof(Configuration.Settings.Shortcuts.MoveStartOneFrameBackKeepGapPrev)); - AddNode(createAndAdjustNode, language.AdjustStartOneFrameForwardKeepGapPrev, nameof(Configuration.Settings.Shortcuts.MoveStartOneFrameForwardKeepGapPrev)); - AddNode(createAndAdjustNode, language.AdjustEndOneFrameBackKeepGapNext, nameof(Configuration.Settings.Shortcuts.MoveEndOneFrameBackKeepGapNext)); - AddNode(createAndAdjustNode, language.AdjustEndOneFrameForwardKeepGapNext, nameof(Configuration.Settings.Shortcuts.MoveEndOneFrameForwardKeepGapNext)); - AddNode(createAndAdjustNode, language.RecalculateDurationOfCurrentSubtitle, nameof(Configuration.Settings.Shortcuts.GeneralAutoCalcCurrentDuration)); - AddNode(createAndAdjustNode, language.AdjustSnapStartToNextSceneChange, nameof(Configuration.Settings.Shortcuts.MainAdjustSnapStartToNextSceneChange)); - AddNode(createAndAdjustNode, language.AdjustSnapStartToNextSceneChangeWithGap, nameof(Configuration.Settings.Shortcuts.MainAdjustSnapStartToNextSceneChangeWithGap)); - AddNode(createAndAdjustNode, language.AdjustSnapEndToPreviousSceneChange, nameof(Configuration.Settings.Shortcuts.MainAdjustSnapEndToPreviousSceneChange)); - AddNode(createAndAdjustNode, language.AdjustSnapEndToPreviousSceneChangeWithGap, nameof(Configuration.Settings.Shortcuts.MainAdjustSnapEndToPreviousSceneChangeWithGap)); - AddNode(createAndAdjustNode, language.AdjustExtendToNextSceneChange, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToNextSceneChange)); - AddNode(createAndAdjustNode, language.AdjustExtendToNextSceneChangeWithGap, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToNextSceneChangeWithGap)); - AddNode(createAndAdjustNode, language.AdjustExtendToPreviousSceneChange, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToPreviousSceneChange)); - AddNode(createAndAdjustNode, language.AdjustExtendToPreviousSceneChangeWithGap, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToPreviousSceneChangeWithGap)); - AddNode(createAndAdjustNode, language.AdjustExtendToNextSubtitle, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToNextSubtitle)); - AddNode(createAndAdjustNode, language.AdjustExtendToPreviousSubtitle, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToPreviousSubtitle)); - AddNode(createAndAdjustNode, language.AdjustExtendCurrentSubtitle, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendCurrentSubtitle)); - AddNode(createAndAdjustNode, language.AdjustExtendPreviousLineEndToCurrentStart, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendPreviousLineEndToCurrentStart)); - AddNode(createAndAdjustNode, language.AdjustExtendNextLineStartToCurrentEnd, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendNextLineStartToCurrentEnd)); - if (createAndAdjustNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(createAndAdjustNode); - } - - var audioVisualizerNode = new ShortcutNode(language.WaveformAndSpectrogram); - AddNode(audioVisualizerNode, Configuration.Settings.Language.Waveform.ClickToAddWaveformAndSpectrogram, nameof(Configuration.Settings.Shortcuts.WaveformAdd)); - AddNode(audioVisualizerNode, Configuration.Settings.Language.Waveform.ZoomIn, nameof(Configuration.Settings.Shortcuts.WaveformZoomIn)); - AddNode(audioVisualizerNode, Configuration.Settings.Language.Waveform.ZoomOut, nameof(Configuration.Settings.Shortcuts.WaveformZoomOut)); - AddNode(audioVisualizerNode, language.VerticalZoom, nameof(Configuration.Settings.Shortcuts.WaveformVerticalZoom)); - AddNode(audioVisualizerNode, language.VerticalZoomOut, nameof(Configuration.Settings.Shortcuts.WaveformVerticalZoomOut)); - AddNode(audioVisualizerNode, Configuration.Settings.Language.Main.Menu.ContextMenu.Split, nameof(Configuration.Settings.Shortcuts.WaveformSplit)); - AddNode(audioVisualizerNode, language.WaveformSeekSilenceForward, nameof(Configuration.Settings.Shortcuts.WaveformSearchSilenceForward)); - AddNode(audioVisualizerNode, language.WaveformSeekSilenceBack, nameof(Configuration.Settings.Shortcuts.WaveformSearchSilenceBack)); - AddNode(audioVisualizerNode, language.WaveformAddTextHere, nameof(Configuration.Settings.Shortcuts.WaveformAddTextHere)); - AddNode(audioVisualizerNode, language.WaveformAddTextHereFromClipboard, nameof(Configuration.Settings.Shortcuts.WaveformAddTextHereFromClipboard)); - AddNode(audioVisualizerNode, language.SetParagraphAsSelection, nameof(Configuration.Settings.Shortcuts.WaveformSetParagraphAsSelection)); - AddNode(audioVisualizerNode, language.WaveformPlayNewSelection, nameof(Configuration.Settings.Shortcuts.WaveformPlaySelection)); - AddNode(audioVisualizerNode, language.WaveformPlayNewSelectionEnd, nameof(Configuration.Settings.Shortcuts.WaveformPlaySelectionEnd)); - AddNode(audioVisualizerNode, Configuration.Settings.Language.Main.VideoControls.InsertNewSubtitleAtVideoPosition, nameof(Configuration.Settings.Shortcuts.MainWaveformInsertAtCurrentPosition)); - AddNode(audioVisualizerNode, language.WaveformFocusListView, nameof(Configuration.Settings.Shortcuts.WaveformFocusListView)); - AddNode(audioVisualizerNode, language.WaveformGoToPreviousSceneChange, nameof(Configuration.Settings.Shortcuts.WaveformGoToPreviousSceneChange)); - AddNode(audioVisualizerNode, language.WaveformGoToNextSceneChange, nameof(Configuration.Settings.Shortcuts.WaveformGoToNextSceneChange)); - AddNode(audioVisualizerNode, language.WaveformToggleSceneChange, nameof(Configuration.Settings.Shortcuts.WaveformToggleSceneChange)); - AddNode(audioVisualizerNode, language.WaveformGuessStart, nameof(Configuration.Settings.Shortcuts.WaveformGuessStart)); - AddNode(audioVisualizerNode, language.GoBack100Milliseconds, nameof(Configuration.Settings.Shortcuts.Waveform100MsLeft)); - AddNode(audioVisualizerNode, language.GoForward100Milliseconds, nameof(Configuration.Settings.Shortcuts.Waveform100MsRight)); - AddNode(audioVisualizerNode, language.GoBack1Second, nameof(Configuration.Settings.Shortcuts.Waveform1000MsLeft)); - AddNode(audioVisualizerNode, language.GoForward1Second, nameof(Configuration.Settings.Shortcuts.Waveform1000MsRight)); - if (audioVisualizerNode.Nodes.Count > 0) - { - _shortcuts.Nodes.Add(audioVisualizerNode); - } - } - - private void ShowShortcutsTreeView() - { - treeViewShortcuts.BeginUpdate(); - treeViewShortcuts.Nodes.Clear(); - - foreach (var parent in _shortcuts.Nodes) - { - var parentNode = new TreeNode(parent.Text); - foreach (ShortcutNode node in parent.Nodes) - { - AddNode(parentNode, node.Text, node.Shortcut); - } - if (parentNode.Nodes.Count > 0) - { - treeViewShortcuts.Nodes.Add(parentNode); - } - } - foreach (TreeNode node in treeViewShortcuts.Nodes) - { - node.Text = node.Text.RemoveChar('&'); - foreach (TreeNode subNode in node.Nodes) - { - subNode.Text = subNode.Text.RemoveChar('&'); - foreach (TreeNode subSubNode in subNode.Nodes) - { - subSubNode.Text = subSubNode.Text.RemoveChar('&'); - } - } - } - - treeViewShortcuts.ExpandAll(); - treeViewShortcuts.EndUpdate(); - if (treeViewShortcuts.Nodes.Count > 0) - { - treeViewShortcuts.SelectedNode = treeViewShortcuts.Nodes[0]; - } - } - - private void AddNode(TreeNode parentNode, string text, ShortcutHelper shortcut) - { - var normalizeAmpersand = text.Replace("&&", "@_____@").Replace("&", string.Empty).Replace("@_____@", "&"); - if (textBoxShortcutSearch.Left < 2 || normalizeAmpersand.Contains(textBoxShortcutSearch.Text, StringComparison.OrdinalIgnoreCase)) - { - parentNode.Nodes.Add(new TreeNode(text) { Tag = shortcut }); - } - } - - private void AddNode(ShortcutNode node, string text, string shortcut, bool isMenuItem = false) - { - var prop = Configuration.Settings.Shortcuts.GetType().GetProperty(shortcut); - if (prop != null) - { - var s = text + GetShortcutText((string)prop.GetValue(Configuration.Settings.Shortcuts, null)); - node.Nodes.Add(new ShortcutNode(s) { Shortcut = new ShortcutHelper(prop, isMenuItem), ShortcutText = shortcut }); - } - } - - private static string GetShortcutText(string shortcut) - { - if (string.IsNullOrEmpty(shortcut)) - { - shortcut = Configuration.Settings.Language.General.None; - } - - return $" [{shortcut}]"; - } - - private void InitializeWaveformsAndSpectrogramsFolderEmpty(LanguageStructure.Settings language) - { - string waveformsFolder = Configuration.WaveformsDirectory.TrimEnd(Path.DirectorySeparatorChar); - string spectrogramsFolder = Configuration.SpectrogramsDirectory.TrimEnd(Path.DirectorySeparatorChar); - long bytes = 0; - int count = 0; - - if (Directory.Exists(waveformsFolder)) - { - var di = new DirectoryInfo(waveformsFolder); - - // waveform data - bytes = 0; - count = 0; - foreach (FileInfo fi in di.GetFiles("*.wav")) - { - bytes += fi.Length; - count++; - } - } - - if (Directory.Exists(spectrogramsFolder)) - { - var di = new DirectoryInfo(spectrogramsFolder); - - // spectrogram data - foreach (var dir in di.GetDirectories()) - { - var spectrogramDir = new DirectoryInfo(dir.FullName); - foreach (var fi in spectrogramDir.GetFiles("*.gif")) - { - bytes += fi.Length; - count++; - } - foreach (var fi in spectrogramDir.GetFiles("*.db")) - { - bytes += fi.Length; - count++; - } - string xmlFileName = Path.Combine(dir.FullName, "Info.xml"); - if (File.Exists(xmlFileName)) - { - var fi = new FileInfo(xmlFileName); - bytes += fi.Length; - count++; - } - } - } - - if (count > 0) - { - buttonWaveformsFolderEmpty.Enabled = true; - labelWaveformsFolderInfo.Text = string.Format(language.WaveformAndSpectrogramsFolderInfo, count, bytes / 1024.0 / 1024.0); - } - else - { - buttonWaveformsFolderEmpty.Enabled = false; - labelWaveformsFolderInfo.Text = string.Format(language.WaveformAndSpectrogramsFolderInfo, 0, 0); - } - } - - public void Initialize(Icon icon, Image newFile, Image openFile, Image saveFile, Image saveFileAs, Image find, Image replace, Image fixCommonErrors, Image removeTextForHi, - Image visualSync, Image spellCheck, Image netflixGlyphCheck, Image settings, Image help) - { - Icon = (Icon)icon.Clone(); - pictureBoxNew.Image = (Image)newFile.Clone(); - pictureBoxOpen.Image = (Image)openFile.Clone(); - pictureBoxSave.Image = (Image)saveFile.Clone(); - pictureBoxSaveAs.Image = (Image)saveFileAs.Clone(); - pictureBoxFind.Image = (Image)find.Clone(); - pictureBoxReplace.Image = (Image)replace.Clone(); - pictureBoxTBFixCommonErrors.Image = (Image)fixCommonErrors.Clone(); - pictureBoxTBRemoveTextForHi.Image = (Image)removeTextForHi.Clone(); - pictureBoxVisualSync.Image = (Image)visualSync.Clone(); - pictureBoxSpellCheck.Image = (Image)spellCheck.Clone(); - pictureBoxNetflixQualityCheck.Image = (Image)netflixGlyphCheck.Clone(); - pictureBoxSettings.Image = (Image)settings.Clone(); - pictureBoxHelp.Image = (Image)help.Clone(); - } - - private void InitComboBoxWordListLanguages() - { - //Examples: da_DK_user.xml, eng_OCRFixReplaceList.xml, en_names.xml - string dir = Utilities.DictionaryFolder; - if (Directory.Exists(dir)) - { - var cultures = new List(); - // Specific culture e.g: en-US, en-GB... - foreach (var culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) - { - if (File.Exists(Path.Combine(dir, culture.Name.Replace('-', '_') + "_user.xml"))) - { - if (!cultures.Contains(culture)) - { - cultures.Add(culture); - } - } - } - // Neutral culture e.g: "en" for all (en-US, en-GB, en-JM...) - foreach (var culture in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) - { - string ocrFixGeneralFile = Path.Combine(dir, culture.GetThreeLetterIsoLanguageName() + "_OCRFixReplaceList.xml"); - string ocrFixUserFile = Path.Combine(dir, culture.GetThreeLetterIsoLanguageName() + "_OCRFixReplaceList_User.xml"); - string namesFile = Path.Combine(dir, culture.TwoLetterISOLanguageName + "_names.xml"); - if (File.Exists(ocrFixGeneralFile) || File.Exists(ocrFixUserFile) || File.Exists(namesFile)) - { - bool alreadyInList = false; - foreach (var ci in cultures) - { - // If culture is already added to the list, it doesn't matter if it's "culture specific" do not re-add. - if (ci.GetThreeLetterIsoLanguageName().Equals(culture.GetThreeLetterIsoLanguageName(), StringComparison.Ordinal)) - { - alreadyInList = true; - break; - } - } - if (!alreadyInList) - { - cultures.Add(culture); - } - } - } - - // English is the default selected language - Configuration.Settings.WordLists.LastLanguage = Configuration.Settings.WordLists.LastLanguage ?? "en-US"; - comboBoxWordListLanguage.BeginUpdate(); - var list = new List(cultures.Count); - var idx = 0; - for (var index = 0; index < cultures.Count; index++) - { - var ci = cultures[index]; - list.Add(new ComboBoxLanguage { CultureInfo = ci }); - if (ci.Name.Equals(Configuration.Settings.WordLists.LastLanguage, StringComparison.Ordinal)) - { - idx = index; - } - } - comboBoxWordListLanguage.Items.AddRange(list.ToArray()); - if (comboBoxWordListLanguage.Items.Count > 0) - { - comboBoxWordListLanguage.SelectedIndex = idx; - } - comboBoxWordListLanguage.EndUpdate(); - } - else - { - groupBoxWordLists.Enabled = false; - } - } - - private void ButtonOkClick(object sender, EventArgs e) - { - var gs = Configuration.Settings.General; - - gs.ShowToolbarNew = checkBoxToolbarNew.Checked; - gs.ShowToolbarOpen = checkBoxToolbarOpen.Checked; - gs.ShowToolbarSave = checkBoxToolbarSave.Checked; - gs.ShowToolbarSaveAs = checkBoxToolbarSaveAs.Checked; - gs.ShowToolbarFind = checkBoxToolbarFind.Checked; - gs.ShowToolbarReplace = checkBoxReplace.Checked; - gs.ShowToolbarFixCommonErrors = checkBoxTBFixCommonErrors.Checked; - gs.ShowToolbarRemoveTextForHi = checkBoxTBRemoveTextForHi.Checked; - gs.ShowToolbarVisualSync = checkBoxVisualSync.Checked; - gs.ShowToolbarSettings = checkBoxSettings.Checked; - gs.ShowToolbarSpellCheck = checkBoxSpellCheck.Checked; - gs.ShowToolbarNetflixGlyphCheck = checkBoxNetflixQualityCheck.Checked; - gs.ShowToolbarHelp = checkBoxHelp.Checked; - - gs.ShowFrameRate = checkBoxShowFrameRate.Checked; - if (double.TryParse(comboBoxFrameRate.Text.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var outFrameRate)) - { - gs.DefaultFrameRate = outFrameRate; - } - - gs.DefaultEncoding = ((TextEncoding)comboBoxEncoding.Items[comboBoxEncoding.SelectedIndex]).ToString(); - - gs.AutoGuessAnsiEncoding = checkBoxAutoDetectAnsiEncoding.Checked; - gs.SubtitleTextBoxFontSize = int.Parse(comboBoxSubtitleFontSize.Text); - gs.SubtitleListViewFontSize = int.Parse(comboBoxSubtitleListViewFontSize.Text); - gs.SubtitleTextBoxFontBold = checkBoxSubtitleFontBold.Checked; - gs.SubtitleTextBoxSyntaxColor = checkBoxSubtitleTextBoxSyntaxColor.Checked; - gs.SubtitleTextBoxHtmlColor = panelTextBoxHtmlColor.BackColor; - gs.SubtitleTextBoxAssColor = panelTextBoxAssColor.BackColor; - gs.SubtitleListViewFontBold = checkBoxSubtitleListViewFontBold.Checked; - gs.CenterSubtitleInTextBox = checkBoxSubtitleCenter.Checked; - gs.SubtitleFontColor = panelSubtitleFontColor.BackColor; - gs.SubtitleBackgroundColor = panelSubtitleBackgroundColor.BackColor; - gs.ShowRecentFiles = checkBoxRememberRecentFiles.Checked; - gs.RememberSelectedLine = checkBoxRememberSelectedLine.Checked; - gs.StartLoadLastFile = checkBoxReopenLastOpened.Checked; - gs.StartRememberPositionAndSize = checkBoxRememberWindowPosition.Checked; - gs.StartInSourceView = checkBoxStartInSourceView.Checked; - gs.RemoveBlankLinesWhenOpening = checkBoxRemoveBlankLinesWhenOpening.Checked; - gs.ListViewLineSeparatorString = textBoxShowLineBreaksAs.Text; - if (string.IsNullOrWhiteSpace(gs.ListViewLineSeparatorString)) - { - gs.ListViewLineSeparatorString = "
"; - } - - gs.ListViewDoubleClickAction = comboBoxListViewDoubleClickEvent.SelectedIndex; - - gs.Profiles = _rulesProfiles; - - gs.SaveAsUseFileNameFrom = comboBoxSaveAsFileNameFrom.SelectedIndex == 0 ? "video" : "file"; - - gs.SubtitleMinimumDisplayMilliseconds = (int)numericUpDownDurationMin.Value; - gs.SubtitleMaximumDisplayMilliseconds = (int)numericUpDownDurationMax.Value; - gs.MinimumMillisecondsBetweenLines = (int)numericUpDownMinGapMs.Value; - gs.CurrentProfile = comboBoxRulesProfileName.Text; - - if (comboBoxAutoBackup.SelectedIndex == 1) - { - gs.AutoBackupSeconds = 60; - } - else if (comboBoxAutoBackup.SelectedIndex == 2) - { - gs.AutoBackupSeconds = 60 * 5; - } - else if (comboBoxAutoBackup.SelectedIndex == 3) - { - gs.AutoBackupSeconds = 60 * 15; - } - else - { - gs.AutoBackupSeconds = 0; - } - - if (comboBoxAutoBackupDeleteAfter.SelectedIndex == 2) - { - gs.AutoBackupDeleteAfterMonths = 6; - } - else if (comboBoxAutoBackupDeleteAfter.SelectedIndex == 1) - { - gs.AutoBackupDeleteAfterMonths = 3; - } - else - { - gs.AutoBackupDeleteAfterMonths = 1; - } - - gs.CheckForUpdates = checkBoxCheckForUpdates.Checked; - gs.AutoSave = checkBoxAutoSave.Checked; - - if (comboBoxTimeCodeMode.Visible) - { - gs.UseTimeFormatHHMMSSFF = comboBoxTimeCodeMode.SelectedIndex == 1; - } - - gs.SplitBehavior = comboBoxSplitBehavior.SelectedIndex; - - gs.SpellChecker = comboBoxSpellChecker.SelectedIndex == 1 ? "word" : "hunspell"; - - gs.AllowEditOfOriginalSubtitle = checkBoxAllowEditOfOriginalSubtitle.Checked; - gs.PromptDeleteLines = checkBoxPromptDeleteLines.Checked; - - if (radioButtonVideoPlayerMPV.Checked) - { - gs.VideoPlayer = "MPV"; - } - else if (radioButtonVideoPlayerMpcHc.Checked) - { - gs.VideoPlayer = "MPC-HC"; - } - else if (radioButtonVideoPlayerVLC.Checked) - { - gs.VideoPlayer = "VLC"; - } - else - { - gs.VideoPlayer = "DirectShow"; - } - - gs.MpvHandlesPreviewText = checkBoxMpvHandlesPreviewText.Checked; - gs.VlcLocation = textBoxVlcPath.Text; - - gs.VideoPlayerShowStopButton = checkBoxVideoPlayerShowStopButton.Checked; - gs.VideoPlayerShowMuteButton = checkBoxVideoPlayerShowMuteButton.Checked; - gs.VideoPlayerShowFullscreenButton = checkBoxVideoPlayerShowFullscreenButton.Checked; - gs.VideoPlayerPreviewFontSize = int.Parse(comboBoxlVideoPlayerPreviewFontSize.Items[0].ToString()) + comboBoxlVideoPlayerPreviewFontSize.SelectedIndex; - gs.VideoPlayerPreviewFontBold = checkBoxVideoPlayerPreviewFontBold.Checked; - gs.DisableVideoAutoLoading = !checkBoxVideoAutoOpen.Checked; - gs.AllowVolumeBoost = checkBoxAllowVolumeBoost.Checked; - - Configuration.Settings.VideoControls.CustomSearchText1 = comboBoxCustomSearch1.Text; - Configuration.Settings.VideoControls.CustomSearchText2 = comboBoxCustomSearch2.Text; - Configuration.Settings.VideoControls.CustomSearchText3 = comboBoxCustomSearch3.Text; - Configuration.Settings.VideoControls.CustomSearchText4 = comboBoxCustomSearch4.Text; - Configuration.Settings.VideoControls.CustomSearchText5 = comboBoxCustomSearch5.Text; - Configuration.Settings.VideoControls.CustomSearchUrl1 = textBoxCustomSearchUrl1.Text; - Configuration.Settings.VideoControls.CustomSearchUrl2 = textBoxCustomSearchUrl2.Text; - Configuration.Settings.VideoControls.CustomSearchUrl3 = textBoxCustomSearchUrl3.Text; - Configuration.Settings.VideoControls.CustomSearchUrl4 = textBoxCustomSearchUrl4.Text; - Configuration.Settings.VideoControls.CustomSearchUrl5 = textBoxCustomSearchUrl5.Text; - - int maxLength = (int)numericUpDownSubtitleLineMaximumLength.Value; - if (maxLength > 9 && maxLength < 1000) - { - gs.SubtitleLineMaximumLength = maxLength; - } - else if (maxLength > 999) - { - gs.SubtitleLineMaximumLength = 999; - } - else - { - gs.SubtitleLineMaximumLength = 45; - } - - gs.SubtitleOptimalCharactersPerSeconds = (double)numericUpDownOptimalCharsSec.Value; - gs.SubtitleMaximumCharactersPerSeconds = (double)numericUpDownMaxCharsSec.Value; - gs.SubtitleMaximumWordsPerMinute = (double)numericUpDownMaxWordsMin.Value; - gs.MaxNumberOfLines = (int)numericUpDownMaxNumberOfLines.Value; - - gs.AutoWrapLineWhileTyping = checkBoxAutoWrapWhileTyping.Checked; - - if (comboBoxSubtitleFont.SelectedItem != null) - { - gs.SubtitleFontName = comboBoxSubtitleFont.SelectedItem.ToString(); - } - - var toolsSettings = Configuration.Settings.Tools; - toolsSettings.VerifyPlaySeconds = comboBoxToolsVerifySeconds.SelectedIndex + 2; - toolsSettings.StartSceneIndex = comboBoxToolsStartSceneIndex.SelectedIndex; - toolsSettings.EndSceneIndex = comboBoxToolsEndSceneIndex.SelectedIndex; - gs.MergeLinesShorterThan = comboBoxMergeShortLineLength.SelectedIndex + 5; - if (gs.MergeLinesShorterThan > gs.SubtitleLineMaximumLength + 1) - { - gs.MergeLinesShorterThan = gs.SubtitleLineMaximumLength; - } - - gs.DialogStyle = DialogSplitMerge.GetDialogStyleFromIndex(comboBoxDialogStyle.SelectedIndex); - gs.ContinuationStyle = ContinuationUtilities.GetContinuationStyleFromIndex(comboBoxContinuationStyle.SelectedIndex); - - toolsSettings.MusicSymbol = comboBoxToolsMusicSymbol.SelectedItem.ToString(); - toolsSettings.MusicSymbolReplace = textBoxMusicSymbolsToReplace.Text; - toolsSettings.SpellCheckAutoChangeNames = checkBoxSpellCheckAutoChangeNames.Checked; - toolsSettings.SpellCheckAutoChangeNamesUseSuggestions = checkBoxSpellCheckAutoChangeNamesViaSuggestions.Checked; - toolsSettings.CheckOneLetterWords = checkBoxSpellCheckOneLetterWords.Checked; - toolsSettings.SpellCheckEnglishAllowInQuoteAsIng = checkBoxTreatINQuoteAsING.Checked; - toolsSettings.RememberUseAlwaysList = checkBoxUseAlwaysToFile.Checked; - toolsSettings.UseNoLineBreakAfter = checkBoxUseDoNotBreakAfterList.Checked; - toolsSettings.AutoBreakCommaBreakEarly = checkBoxToolsBreakEarlyComma.Checked; - toolsSettings.AutoBreakLineEndingEarly = checkBoxToolsBreakEarlyLineEnding.Checked; - toolsSettings.AutoBreakUsePixelWidth = checkBoxToolsBreakByPixelWidth.Checked; - toolsSettings.AutoBreakPreferBottomHeavy = checkBoxToolsBreakPreferBottomHeavy.Checked; - toolsSettings.AutoBreakPreferBottomPercent = (double)numericUpDownToolsBreakPreferBottomHeavy.Value; - toolsSettings.AutoBreakDashEarly = checkBoxToolsBreakEarlyDash.Checked; - - Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace = !checkBoxCpsIncludeWhiteSpace.Checked; - toolsSettings.OcrFixUseHardcodedRules = checkBoxFixCommonOcrErrorsUsingHardcodedRules.Checked; - toolsSettings.FixShortDisplayTimesAllowMoveStartTime = checkBoxFixShortDisplayTimesAllowMoveStartTime.Checked; - toolsSettings.FixCommonErrorsSkipStepOne = checkBoxFceSkipStep1.Checked; - toolsSettings.MicrosoftTranslatorApiKey = textBoxBingClientSecret.Text.Trim(); - toolsSettings.MicrosoftTranslatorTokenEndpoint = comboBoxBoxBingTokenEndpoint.Text.Trim(); - toolsSettings.GoogleApiV2Key = textBoxGoogleTransleApiKey.Text.Trim(); - - var wordListSettings = Configuration.Settings.WordLists; - wordListSettings.UseOnlineNames = checkBoxNamesOnline.Checked; - wordListSettings.NamesUrl = textBoxNamesOnline.Text; - if (comboBoxWordListLanguage.Items.Count > 0 && comboBoxWordListLanguage.SelectedIndex >= 0) - { - if (comboBoxWordListLanguage.Items[comboBoxWordListLanguage.SelectedIndex] is ComboBoxLanguage ci) - { - Configuration.Settings.WordLists.LastLanguage = ci.CultureInfo.Name; - } - } - - var ssa = Configuration.Settings.SubtitleSettings; - ssa.SsaFontName = _ssaFontName; - ssa.SsaFontSize = _ssaFontSize; - ssa.SsaFontColorArgb = _ssaFontColor; - ssa.SsaFontBold = checkBoxSsaFontBold.Checked; - ssa.SsaOutline = (int)numericUpDownSsaOutline.Value; - ssa.SsaShadow = (int)numericUpDownSsaShadow.Value; - ssa.SsaOpaqueBox = checkBoxSsaOpaqueBox.Checked; - ssa.SsaMarginLeft = (int)numericUpDownSsaMarginLeft.Value; - ssa.SsaMarginRight = (int)numericUpDownSsaMarginRight.Value; - ssa.SsaMarginTopBottom = (int)numericUpDownSsaMarginVertical.Value; - - var proxy = Configuration.Settings.Proxy; - proxy.ProxyAddress = textBoxProxyAddress.Text; - proxy.UserName = textBoxProxyUserName.Text; - if (string.IsNullOrWhiteSpace(textBoxProxyPassword.Text)) - { - proxy.Password = null; - } - else - { - proxy.EncodePassword(textBoxProxyPassword.Text); - } - - proxy.Domain = textBoxProxyDomain.Text; - - Configuration.Settings.NetworkSettings.NewMessageSound = textBoxNetworkSessionNewMessageSound.Text; - - Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall = checkBoxSyntaxColorDurationTooSmall.Checked; - Configuration.Settings.Tools.ListViewSyntaxColorDurationBig = checkBoxSyntaxColorDurationTooLarge.Checked; - Configuration.Settings.Tools.ListViewSyntaxColorLongLines = checkBoxSyntaxColorTextTooLong.Checked; - Configuration.Settings.Tools.ListViewSyntaxColorWideLines = checkBoxSyntaxColorTextTooWide.Checked; - Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines = checkBoxSyntaxColorTextMoreThanTwoLines.Checked; - Configuration.Settings.Tools.ListViewSyntaxColorOverlap = checkBoxSyntaxOverlap.Checked; - Configuration.Settings.Tools.ListViewSyntaxColorGap = checkBoxSyntaxColorGapTooSmall.Checked; - Configuration.Settings.Tools.ListViewSyntaxErrorColor = panelListViewSyntaxColorError.BackColor; - - Configuration.Settings.VideoControls.WaveformDrawGrid = checkBoxWaveformShowGrid.Checked; - Configuration.Settings.VideoControls.WaveformDrawCps = checkBoxWaveformShowCps.Checked; - Configuration.Settings.VideoControls.WaveformDrawWpm = checkBoxWaveformShowWpm.Checked; - Configuration.Settings.VideoControls.WaveformGridColor = panelWaveformGridColor.BackColor; - Configuration.Settings.VideoControls.WaveformSelectedColor = panelWaveformSelectedColor.BackColor; - Configuration.Settings.VideoControls.WaveformColor = panelWaveformColor.BackColor; - Configuration.Settings.VideoControls.WaveformBackgroundColor = panelWaveformBackgroundColor.BackColor; - Configuration.Settings.VideoControls.WaveformTextColor = panelWaveformTextColor.BackColor; - Configuration.Settings.VideoControls.WaveformCursorColor = panelWaveformCursorColor.BackColor; - Configuration.Settings.VideoControls.GenerateSpectrogram = checkBoxGenerateSpectrogram.Checked; - Configuration.Settings.VideoControls.SpectrogramAppearance = comboBoxSpectrogramAppearance.SelectedIndex == 0 ? "OneColorGradient" : "Classic"; - - Configuration.Settings.VideoControls.WaveformTextSize = int.Parse(comboBoxWaveformTextSize.Text); - Configuration.Settings.VideoControls.WaveformTextBold = checkBoxWaveformTextBold.Checked; - Configuration.Settings.VideoControls.WaveformMouseWheelScrollUpIsForward = checkBoxReverseMouseWheelScrollDirection.Checked; - Configuration.Settings.VideoControls.WaveformAllowOverlap = checkBoxAllowOverlap.Checked; - Configuration.Settings.VideoControls.WaveformSetVideoPositionOnMoveStartEnd = checkBoxWaveformSetVideoPosMoveStartEnd.Checked; - Configuration.Settings.VideoControls.WaveformFocusOnMouseEnter = checkBoxWaveformHoverFocus.Checked; - Configuration.Settings.VideoControls.WaveformListViewFocusOnMouseEnter = checkBoxListViewMouseEnterFocus.Checked; - Configuration.Settings.VideoControls.WaveformSingleClickSelect = checkBoxWaveformSingleClickSelect.Checked; - Configuration.Settings.VideoControls.WaveformSnapToSceneChanges = checkBoxWaveformSnapToSceneChanges.Checked; - Configuration.Settings.VideoControls.WaveformBorderHitMs = Convert.ToInt32(numericUpDownWaveformBorderHitMs.Value); - gs.UseFFmpegForWaveExtraction = checkBoxUseFFmpeg.Checked; - gs.FFmpegLocation = textBoxFFmpegPath.Text; - - // save shortcuts - foreach (var kvp in _newShortcuts) - { - kvp.Key.Shortcut.SetValue(Configuration.Settings.Shortcuts, kvp.Value, null); - } - - Configuration.Settings.Save(); - } - - private void FormSettings_KeyDown(object sender, KeyEventArgs e) - { - if (comboBoxShortcutKey.Focused) - { - return; - } - - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#Settings"); - e.SuppressKeyPress = true; - } - } - - private void UpdateSsaExample() - { - GeneratePreviewReal(); - } - - private void GeneratePreviewReal() - { - if (_loading) - { - return; - } - - pictureBoxPreview.Image?.Dispose(); - var backgroundImage = TextDesigner.MakeBackgroundImage(pictureBoxPreview.Width, pictureBoxPreview.Height, 9, _backgroundImageDark); - var outlineWidth = (float)numericUpDownSsaOutline.Value; - var shadowWidth = (float)numericUpDownSsaShadow.Value; - var outlineColor = Color.Black; - - Font font; - try - { - font = new Font(comboBoxFontName.Text, (float)numericUpDownFontSize.Value * 1.1f, checkBoxSsaFontBold.Checked ? FontStyle.Bold : FontStyle.Regular); - } - catch - { - font = new Font(Font, FontStyle.Regular); - } - - var measureBmp = TextDesigner.MakeTextBitmapAssa( - Configuration.Settings.General.PreviewAssaText, - 0, - 0, - font, - pictureBoxPreview.Width, - pictureBoxPreview.Height, - outlineWidth, - shadowWidth, - null, - panelPrimaryColor.BackColor, - outlineColor, - Color.FromArgb(100, Color.Black), - checkBoxSsaOpaqueBox.Checked); - var nBmp = new NikseBitmap(measureBmp); - var measuredWidth = nBmp.GetNonTransparentWidth(); - var measuredHeight = nBmp.GetNonTransparentHeight(); - - float left = (pictureBoxPreview.Width - measuredWidth) / 2.0f; - float top = pictureBoxPreview.Height - measuredHeight - (int)numericUpDownSsaMarginVertical.Value; - var designedText = TextDesigner.MakeTextBitmapAssa( - Configuration.Settings.General.PreviewAssaText, - (int)Math.Round(left), - (int)Math.Round(top), - font, - pictureBoxPreview.Width, - pictureBoxPreview.Height, - outlineWidth, - shadowWidth, - backgroundImage, - panelPrimaryColor.BackColor, - Color.Black, - Color.FromArgb(200, Color.Black), - checkBoxSsaOpaqueBox.Checked); - - pictureBoxPreview.Image?.Dispose(); - pictureBoxPreview.Image = designedText; - font.Dispose(); - } - - private void ComboBoxWordListLanguageSelectedIndexChanged(object sender, EventArgs e) - { - buttonRemoveNameEtc.Enabled = false; - buttonAddNames.Enabled = false; - buttonRemoveUserWord.Enabled = false; - buttonAddUserWord.Enabled = false; - buttonRemoveOcrFix.Enabled = false; - buttonAddOcrFix.Enabled = false; - listBoxNames.Items.Clear(); - listBoxUserWordLists.Items.Clear(); - listBoxOcrFixList.Items.Clear(); - if (comboBoxWordListLanguage.Items.Count > 0 && comboBoxWordListLanguage.Items[comboBoxWordListLanguage.SelectedIndex] is ComboBoxLanguage) - { - string language = GetCurrentWordListLanguage(); - - buttonAddNames.Enabled = true; - buttonAddUserWord.Enabled = true; - buttonAddOcrFix.Enabled = true; - - // user word list - LoadUserWords(language, true); - - // OCR fix words - LoadOcrFixList(true); - - LoadNames(language, true); - } - } - - private void LoadOcrFixList(bool reloadListBox) - { - if (comboBoxWordListLanguage.Items.Count == 0 || !(comboBoxWordListLanguage.Items[comboBoxWordListLanguage.SelectedIndex] is ComboBoxLanguage cb)) - { - return; - } - - _ocrFixReplaceList = OcrFixReplaceList.FromLanguageId(cb.CultureInfo.GetThreeLetterIsoLanguageName()); - if (reloadListBox) - { - listBoxOcrFixList.BeginUpdate(); - listBoxOcrFixList.Items.Clear(); - listBoxOcrFixList.Items.AddRange(_ocrFixReplaceList.WordReplaceList.Select(p => p.Key + " --> " + p.Value).ToArray()); - listBoxOcrFixList.Items.AddRange(_ocrFixReplaceList.PartialLineWordBoundaryReplaceList.Select(p => p.Key + " --> " + p.Value).ToArray()); - listBoxOcrFixList.Sorted = true; - listBoxOcrFixList.EndUpdate(); - } - } - - private void LoadUserWords(string language, bool reloadListBox) - { - _userWordList = new List(); - Utilities.LoadUserWordList(_userWordList, language); - _userWordList.Sort(); - - if (reloadListBox) - { - listBoxUserWordLists.Items.Clear(); - listBoxUserWordLists.Items.AddRange(_userWordList.ToArray()); - } - } - - private void LoadNames(string language, bool reloadListBox) - { - var task = Task.Factory.StartNew(() => - { - // names etc - var nameList = new NameList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); - _wordListNames = nameList.GetAllNames(); - _wordListNames.Sort(); - return _wordListNames; - }); - - if (reloadListBox) - { - // reload the listbox on a continuation ui thead - var uiContext = TaskScheduler.FromCurrentSynchronizationContext(); - task.ContinueWith(originalTask => - { - listBoxNames.BeginUpdate(); - listBoxNames.Items.Clear(); - listBoxNames.Items.AddRange(originalTask.Result.ToArray()); - listBoxNames.EndUpdate(); - }, uiContext); - } - } - - private string GetCurrentWordListLanguage() - { - var idx = comboBoxWordListLanguage.SelectedIndex; - if (idx < 0) - { - return null; - } - - var cb = comboBoxWordListLanguage.Items[idx] as ComboBoxLanguage; - return cb?.CultureInfo.Name.Replace('-', '_'); - } - - private void ButtonAddNamesClick(object sender, EventArgs e) - { - var languageIndex = comboBoxWordListLanguage.SelectedIndex; - if (languageIndex < 0) - { - return; - } - - string language = GetCurrentWordListLanguage(); - string text = textBoxNameEtc.Text.RemoveControlCharacters().Trim(); - if (!string.IsNullOrEmpty(language) && text.Length > 1 && !_wordListNames.Contains(text)) - { - var nameList = new NameList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); - nameList.Add(text); - LoadNames(language, true); - labelStatus.Text = string.Format(Configuration.Settings.Language.Settings.WordAddedX, text); - textBoxNameEtc.Text = string.Empty; - textBoxNameEtc.Focus(); - for (int i = 0; i < listBoxNames.Items.Count; i++) - { - if (listBoxNames.Items[i].ToString() == text) - { - listBoxNames.SelectedIndex = i; - int top = i - 5; - if (top < 0) - { - top = 0; - } - - listBoxNames.TopIndex = top; - break; - } - } - } - else - { - MessageBox.Show(Configuration.Settings.Language.Settings.WordAlreadyExists); - } - } - - private void ListBoxNamesSelectedIndexChanged(object sender, EventArgs e) - { - buttonRemoveNameEtc.Enabled = listBoxNames.SelectedIndex >= 0; - } - - private void ButtonRemoveNameEtcClick(object sender, EventArgs e) - { - if (listBoxNames.SelectedIndices.Count == 0) - { - return; - } - - string language = GetCurrentWordListLanguage(); - int index = listBoxNames.SelectedIndex; - string text = listBoxNames.Items[index].ToString(); - int itemsToRemoveCount = listBoxNames.SelectedIndices.Count; - if (!string.IsNullOrEmpty(language) && index >= 0) - { - DialogResult result; - if (itemsToRemoveCount == 1) - { - result = MessageBox.Show(string.Format(Configuration.Settings.Language.Settings.RemoveX, text), "Subtitle Edit", MessageBoxButtons.YesNo); - } - else - { - result = MessageBox.Show(string.Format(Configuration.Settings.Language.Main.DeleteXLinesPrompt, itemsToRemoveCount), "Subtitle Edit", MessageBoxButtons.YesNo); - } - - if (result == DialogResult.Yes) - { - int removeCount = 0; - var namesList = new NameList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); - for (int idx = listBoxNames.SelectedIndices.Count - 1; idx >= 0; idx--) - { - index = listBoxNames.SelectedIndices[idx]; - text = listBoxNames.Items[index].ToString(); - namesList.Remove(text); - removeCount++; - listBoxNames.Items.RemoveAt(index); - } - - if (removeCount > 0) - { - LoadNames(language, true); // reload - - if (index < listBoxNames.Items.Count) - { - listBoxNames.SelectedIndex = index; - } - else if (listBoxNames.Items.Count > 0) - { - listBoxNames.SelectedIndex = index - 1; - } - - listBoxNames.Focus(); - - buttonRemoveNameEtc.Enabled = false; - return; - } - - if (removeCount < itemsToRemoveCount && Configuration.Settings.WordLists.UseOnlineNames && !string.IsNullOrEmpty(Configuration.Settings.WordLists.NamesUrl)) - { - MessageBox.Show(Configuration.Settings.Language.Settings.CannotUpdateNamesOnline); - return; - } - - if (removeCount == 0) - { - MessageBox.Show(Configuration.Settings.Language.Settings.WordNotFound); - } - } - } - } - - private void TextBoxNameEtcKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - e.SuppressKeyPress = true; - ButtonAddNamesClick(null, null); - } - } - - private void ButtonAddUserWordClick(object sender, EventArgs e) - { - var languageIndex = comboBoxWordListLanguage.SelectedIndex; - if (languageIndex < 0) - { - return; - } - - string language = GetCurrentWordListLanguage(); - string text = textBoxUserWord.Text.RemoveControlCharacters().Trim().ToLowerInvariant(); - if (!string.IsNullOrEmpty(language) && text.Length > 0 && !_userWordList.Contains(text)) - { - Utilities.AddToUserDictionary(text, language); - LoadUserWords(language, true); - labelStatus.Text = string.Format(Configuration.Settings.Language.Settings.WordAddedX, text); - textBoxUserWord.Text = string.Empty; - textBoxUserWord.Focus(); - - for (int i = 0; i < listBoxUserWordLists.Items.Count; i++) - { - if (listBoxUserWordLists.Items[i].ToString() == text) - { - listBoxUserWordLists.SelectedIndex = i; - int top = i - 5; - if (top < 0) - { - top = 0; - } - - listBoxUserWordLists.TopIndex = top; - break; - } - } - } - else - { - MessageBox.Show(Configuration.Settings.Language.Settings.WordAlreadyExists); - } - } - - private void TextBoxUserWordKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - e.SuppressKeyPress = true; - ButtonAddUserWordClick(null, null); - } - } - - private void ButtonRemoveUserWordClick(object sender, EventArgs e) - { - if (listBoxUserWordLists.SelectedIndices.Count == 0) - { - return; - } - - string language = GetCurrentWordListLanguage(); - int index = listBoxUserWordLists.SelectedIndex; - int itemsToRemoveCount = listBoxUserWordLists.SelectedIndices.Count; - string text = listBoxUserWordLists.Items[index].ToString(); - if (!string.IsNullOrEmpty(language) && index >= 0) - { - DialogResult result; - if (itemsToRemoveCount == 1) - { - result = MessageBox.Show(string.Format(Configuration.Settings.Language.Settings.RemoveX, text), "Subtitle Edit", MessageBoxButtons.YesNo); - } - else - { - result = MessageBox.Show(string.Format(Configuration.Settings.Language.Main.DeleteXLinesPrompt, itemsToRemoveCount), "Subtitle Edit", MessageBoxButtons.YesNo); - } - - if (result == DialogResult.Yes) - { - int removeCount = 0; - var words = new List(); - string userWordFileName = Utilities.LoadUserWordList(words, language); - - for (int idx = listBoxUserWordLists.SelectedIndices.Count - 1; idx >= 0; idx--) - { - index = listBoxUserWordLists.SelectedIndices[idx]; - text = listBoxUserWordLists.Items[index].ToString(); - - if (words.Contains(text)) - { - words.Remove(text); - removeCount++; - } - listBoxUserWordLists.Items.RemoveAt(index); - } - - if (removeCount > 0) - { - words.Sort(); - var doc = new XmlDocument(); - doc.Load(userWordFileName); - doc.DocumentElement.RemoveAll(); - foreach (string word in words) - { - XmlNode node = doc.CreateElement("word"); - node.InnerText = word; - doc.DocumentElement.AppendChild(node); - } - doc.Save(userWordFileName); - LoadUserWords(language, false); // reload - buttonRemoveUserWord.Enabled = false; - - if (index < listBoxUserWordLists.Items.Count) - { - listBoxUserWordLists.SelectedIndex = index; - } - else if (listBoxUserWordLists.Items.Count > 0) - { - listBoxUserWordLists.SelectedIndex = index - 1; - } - - listBoxUserWordLists.Focus(); - return; - } - - if (removeCount < itemsToRemoveCount) - { - MessageBox.Show(Configuration.Settings.Language.Settings.WordNotFound); - } - } - } - } - - private void ListBoxUserWordListsSelectedIndexChanged(object sender, EventArgs e) - { - buttonRemoveUserWord.Enabled = listBoxUserWordLists.SelectedIndex >= 0; - } - - private void ButtonAddOcrFixClick(object sender, EventArgs e) - { - string key = textBoxOcrFixKey.Text.RemoveControlCharacters().Trim(); - string value = textBoxOcrFixValue.Text.RemoveControlCharacters().Trim(); - if (key.Length == 0 || value.Length == 0 || key == value || Utilities.IsInteger(key)) - { - return; - } - - if (comboBoxWordListLanguage.Items.Count == 0 || !(comboBoxWordListLanguage.Items[comboBoxWordListLanguage.SelectedIndex] is ComboBoxLanguage)) - { - return; - } - - var added = _ocrFixReplaceList.AddWordOrPartial(key, value); - if (!added) - { - MessageBox.Show(Configuration.Settings.Language.Settings.WordAlreadyExists); - return; - } - - LoadOcrFixList(true); - textBoxOcrFixKey.Text = string.Empty; - textBoxOcrFixValue.Text = string.Empty; - textBoxOcrFixKey.Focus(); - - for (int i = 0; i < listBoxOcrFixList.Items.Count; i++) - { - if (listBoxOcrFixList.Items[i].ToString() == key + " --> " + value) - { - listBoxOcrFixList.SelectedIndex = i; - int top = i - 5; - if (top < 0) - { - top = 0; - } - - listBoxOcrFixList.TopIndex = top; - break; - } - } - } - - private void ListBoxOcrFixListSelectedIndexChanged(object sender, EventArgs e) - { - buttonRemoveOcrFix.Enabled = listBoxOcrFixList.SelectedIndex >= 0; - } - - private void ButtonRemoveOcrFixClick(object sender, EventArgs e) - { - var languageIndex = comboBoxWordListLanguage.SelectedIndex; - if (languageIndex < 0) - { - return; - } - - if (!(comboBoxWordListLanguage.Items[languageIndex] is ComboBoxLanguage)) - { - return; - } - - if (listBoxOcrFixList.SelectedIndices.Count == 0) - { - return; - } - - int itemsToRemoveCount = listBoxOcrFixList.SelectedIndices.Count; - - int index = listBoxOcrFixList.SelectedIndex; - string text = listBoxOcrFixList.Items[index].ToString(); - string key = text.Substring(0, text.IndexOf(" --> ", StringComparison.Ordinal)); - - if (_ocrFixReplaceList.WordReplaceList.ContainsKey(key) || _ocrFixReplaceList.PartialLineWordBoundaryReplaceList.ContainsKey(key)) - { - DialogResult result; - if (itemsToRemoveCount == 1) - { - result = MessageBox.Show(string.Format(Configuration.Settings.Language.Settings.RemoveX, text), "Subtitle Edit", MessageBoxButtons.YesNo); - } - else - { - result = MessageBox.Show(string.Format(Configuration.Settings.Language.Main.DeleteXLinesPrompt, itemsToRemoveCount), "Subtitle Edit", MessageBoxButtons.YesNo); - } - - if (result == DialogResult.Yes) - { - listBoxOcrFixList.BeginUpdate(); - for (int idx = listBoxOcrFixList.SelectedIndices.Count - 1; idx >= 0; idx--) - { - index = listBoxOcrFixList.SelectedIndices[idx]; - text = listBoxOcrFixList.Items[index].ToString(); - key = text.Substring(0, text.IndexOf(" --> ", StringComparison.Ordinal)); - - if (_ocrFixReplaceList.WordReplaceList.ContainsKey(key) || _ocrFixReplaceList.PartialLineWordBoundaryReplaceList.ContainsKey(key)) - { - _ocrFixReplaceList.RemoveWordOrPartial(key); - } - listBoxOcrFixList.Items.RemoveAt(index); - } - listBoxOcrFixList.EndUpdate(); - - LoadOcrFixList(false); - buttonRemoveOcrFix.Enabled = false; - - if (index < listBoxOcrFixList.Items.Count) - { - listBoxOcrFixList.SelectedIndex = index; - } - else if (listBoxOcrFixList.Items.Count > 0) - { - listBoxOcrFixList.SelectedIndex = index - 1; - } - - listBoxOcrFixList.Focus(); - } - } - } - - private void TextBoxOcrFixValueKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - e.SuppressKeyPress = true; - ButtonAddOcrFixClick(null, null); - } - } - - private void TabControlSettingsSelectedIndexChanged(object sender, EventArgs e) - { - labelStatus.Text = string.Empty; - } - - private void ListBoxKeyDownSearch(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape || - e.KeyCode == Keys.Tab || - e.KeyCode == Keys.Return || - e.KeyCode == Keys.Enter || - e.KeyCode == Keys.Down || - e.KeyCode == Keys.Up || - e.KeyCode == Keys.PageDown || - e.KeyCode == Keys.PageUp || - e.KeyCode == Keys.None || - e.KeyCode == UiUtil.HelpKeys || - e.KeyCode == Keys.Home || - e.KeyCode == Keys.End) - { - return; - } - - if (TimeSpan.FromTicks(_listBoxSearchStringLastUsed.Ticks).TotalMilliseconds + 1800 < - TimeSpan.FromTicks(DateTime.Now.Ticks).TotalMilliseconds) - { - _listBoxSearchString = string.Empty; - } - - if (e.KeyCode == Keys.Delete) - { - if (_listBoxSearchString.Length > 0) - { - _listBoxSearchString = _listBoxSearchString.Remove(_listBoxSearchString.Length - 1, 1); - } - } - else - { - _listBoxSearchString += e.KeyCode.ToString(); - } - - _listBoxSearchStringLastUsed = DateTime.Now; - FindAndSelectListBoxItem(sender as ListBox); - e.SuppressKeyPress = true; - } - - private void FindAndSelectListBoxItem(ListBox listBox) - { - int i = 0; - foreach (string s in listBox.Items) - { - if (s.StartsWith(_listBoxSearchString, StringComparison.OrdinalIgnoreCase)) - { - listBox.SelectedIndex = i; - break; - } - i++; - } - } - - private void ListBoxSearchReset(object sender, EventArgs e) - { - _listBoxSearchString = string.Empty; - } - - private void comboBoxCustomSearch_SelectedIndexChanged(object sender, EventArgs e) - { - var cb = (ComboBox)sender; - var tb = textBoxCustomSearchUrl1; - if (cb == comboBoxCustomSearch2) - { - tb = textBoxCustomSearchUrl2; - } - else if (cb == comboBoxCustomSearch3) - { - tb = textBoxCustomSearchUrl3; - } - else if (cb == comboBoxCustomSearch4) - { - tb = textBoxCustomSearchUrl4; - } - else if (cb == comboBoxCustomSearch5) - { - tb = textBoxCustomSearchUrl5; - } - - if (cb.SelectedIndex >= 0) - { - if (cb.SelectedIndex == 0) - { - tb.Text = "https://www.dictionary.com/browse/{0}"; - } - else if (cb.SelectedIndex == 1) - { - tb.Text = "http://www.learnersdictionary.com/search/{0}"; - } - else if (cb.SelectedIndex == 2) - { - tb.Text = "https://www.merriam-webster.com/dictionary/{0}"; - } - else if (cb.SelectedIndex == 3) - { - tb.Text = "https://www.thefreedictionary.com/{0}"; - } - else if (cb.SelectedIndex == 4) - { - tb.Text = "https://www.thesaurus.com/browse/{0}"; - } - else if (cb.SelectedIndex == 5) - { - tb.Text = "https://www.urbandictionary.com/define.php?term={0}"; - } - else if (cb.SelectedIndex == 6) - { - tb.Text = "https://visuwords.com/?word={0}"; - } - else if (cb.SelectedIndex == 7) - { - tb.Text = "https://en.wikipedia.org/wiki?search={0}"; - } - } - } - - private void buttonWaveformSelectedColor_Click(object sender, EventArgs e) - { - colorDialogSSAStyle.Color = panelWaveformSelectedColor.BackColor; - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - panelWaveformSelectedColor.BackColor = colorDialogSSAStyle.Color; - } - } - - private void buttonWaveformColor_Click(object sender, EventArgs e) - { - colorDialogSSAStyle.Color = panelWaveformColor.BackColor; - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - panelWaveformColor.BackColor = colorDialogSSAStyle.Color; - } - } - - private void buttonWaveformBackgroundColor_Click(object sender, EventArgs e) - { - colorDialogSSAStyle.Color = panelWaveformBackgroundColor.BackColor; - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - panelWaveformBackgroundColor.BackColor = colorDialogSSAStyle.Color; - } - } - - private void buttonWaveformGridColor_Click(object sender, EventArgs e) - { - colorDialogSSAStyle.Color = panelWaveformGridColor.BackColor; - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - panelWaveformGridColor.BackColor = colorDialogSSAStyle.Color; - } - } - - private void buttonWaveformTextColor_Click(object sender, EventArgs e) - { - colorDialogSSAStyle.Color = panelWaveformTextColor.BackColor; - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - panelWaveformTextColor.BackColor = colorDialogSSAStyle.Color; - } - } - - private void buttonWaveformCursorColor_Click(object sender, EventArgs e) - { - colorDialogSSAStyle.Color = panelWaveformCursorColor.BackColor; - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - panelWaveformCursorColor.BackColor = colorDialogSSAStyle.Color; - } - } - - private void buttonWaveformsFolderEmpty_Click(object sender, EventArgs e) - { - string waveformsFolder = Configuration.WaveformsDirectory.TrimEnd(Path.DirectorySeparatorChar); - if (Directory.Exists(waveformsFolder)) - { - var di = new DirectoryInfo(waveformsFolder); - - foreach (var fileName in di.GetFiles("*.wav")) - { - try - { - File.Delete(fileName.FullName); - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - } - } - } - - string spectrogramsFolder = Configuration.SpectrogramsDirectory.TrimEnd(Path.DirectorySeparatorChar); - if (Directory.Exists(spectrogramsFolder)) - { - var di = new DirectoryInfo(spectrogramsFolder); - - foreach (var dir in di.GetDirectories()) - { - var spectrogramDir = new DirectoryInfo(dir.FullName); - foreach (var fileName in spectrogramDir.GetFiles("*.gif")) - { - File.Delete(fileName.FullName); - } - string imageDbFileName = Path.Combine(dir.FullName, "Images.db"); - if (File.Exists(imageDbFileName)) - { - File.Delete(imageDbFileName); - } - - string xmlFileName = Path.Combine(dir.FullName, "Info.xml"); - if (File.Exists(xmlFileName)) - { - File.Delete(xmlFileName); - } - - Directory.Delete(dir.FullName); - } - } - - InitializeWaveformsAndSpectrogramsFolderEmpty(Configuration.Settings.Language.Settings); - } - - private void checkBoxRememberRecentFiles_CheckedChanged(object sender, EventArgs e) - { - checkBoxReopenLastOpened.Enabled = checkBoxRememberRecentFiles.Checked; - checkBoxRememberSelectedLine.Enabled = checkBoxRememberRecentFiles.Checked; - } - - private void buttonWaveformSelectedColor_Click(object sender, MouseEventArgs e) - { - colorDialogSSAStyle.Color = panelWaveformSelectedColor.BackColor; - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - panelWaveformSelectedColor.BackColor = colorDialogSSAStyle.Color; - } - } - - private void panelSubtitleFontColor_Click(object sender, EventArgs e) - { - colorDialogSSAStyle.Color = panelSubtitleFontColor.BackColor; - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - panelSubtitleFontColor.BackColor = colorDialogSSAStyle.Color; - } - } - - private void panelSubtitleBackgroundColor_Click(object sender, EventArgs e) - { - colorDialogSSAStyle.Color = panelSubtitleBackgroundColor.BackColor; - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - panelSubtitleBackgroundColor.BackColor = colorDialogSSAStyle.Color; - } - } - - private void treeViewShortcuts_AfterSelect(object sender, TreeViewEventArgs e) - { - if (e?.Node?.Nodes.Count == 0) - { - checkBoxShortcutsControl.Checked = false; - checkBoxShortcutsAlt.Checked = false; - checkBoxShortcutsShift.Checked = false; - - checkBoxShortcutsControl.Enabled = true; - checkBoxShortcutsAlt.Enabled = true; - checkBoxShortcutsShift.Enabled = true; - - comboBoxShortcutKey.SelectedIndex = 0; - - comboBoxShortcutKey.Enabled = true; - buttonUpdateShortcut.Enabled = true; - buttonClearShortcut.Enabled = true; - - string shortcut = GetShortcut(e.Node.Text); - - string[] parts = shortcut.ToLowerInvariant().Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries); - foreach (string k in parts) - { - if (k.Equals("CONTROL", StringComparison.OrdinalIgnoreCase)) - { - checkBoxShortcutsControl.Checked = true; - } - else if (k.Equals("ALT", StringComparison.OrdinalIgnoreCase)) - { - checkBoxShortcutsAlt.Checked = true; - } - else if (k.Equals("SHIFT", StringComparison.OrdinalIgnoreCase)) - { - checkBoxShortcutsShift.Checked = true; - } - else - { - int i = 0; - foreach (string value in comboBoxShortcutKey.Items) - { - if (value.Equals(k, StringComparison.OrdinalIgnoreCase)) - { - comboBoxShortcutKey.SelectedIndex = i; - break; - } - i++; - } - } - } - } - } - - private static string GetShortcut(string text) - { - string shortcut = text.Substring(text.IndexOf('[')); - shortcut = shortcut.TrimEnd(']').TrimStart('['); - if (shortcut == Configuration.Settings.Language.General.None) - { - return string.Empty; - } - - return shortcut; - } - - private string GetCurrentShortcutText() - { - var sb = new StringBuilder(@"["); - if (checkBoxShortcutsControl.Checked) - { - sb.Append("Control+"); - } - - if (checkBoxShortcutsAlt.Checked) - { - sb.Append("Alt+"); - } - - if (checkBoxShortcutsShift.Checked) - { - sb.Append("Shift+"); - } - - sb.Append(comboBoxShortcutKey.Items[comboBoxShortcutKey.SelectedIndex]); - sb.Append(']'); - return sb.ToString(); - } - - private void buttonUpdateShortcut_Click(object sender, EventArgs e) - { - if (!IsShortcutValid()) - { - return; - } - - string text = treeViewShortcuts.SelectedNode.Text.Substring(0, treeViewShortcuts.SelectedNode.Text.IndexOf('[')).Trim(); - var shortcutText = GetCurrentShortcutText(); - var existsIn = new StringBuilder(); - var sh = (ShortcutHelper)treeViewShortcuts.SelectedNode.Tag; - foreach (ShortcutNode parent in _shortcuts.Nodes) - { - foreach (ShortcutNode subNode in parent.Nodes) - { - if (sh != null && subNode.Shortcut.Shortcut.Name == sh.Shortcut.Name) - { - subNode.Text = text + " " + shortcutText; - } - else if (subNode.Text.Contains(shortcutText) && treeViewShortcuts.SelectedNode.Text != subNode.Text) - { - existsIn.AppendLine(string.Format(Configuration.Settings.Language.Settings.ShortcutIsAlreadyDefinedX, parent.Text + " -> " + subNode.Text)); - } - } - } - if (existsIn.Length > 0 && comboBoxShortcutKey.SelectedIndex > 0) - { - if (MessageBox.Show(existsIn.ToString(), string.Empty, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) - { - return; - } - } - treeViewShortcuts.SelectedNode.Text = text + " " + shortcutText; - AddToSaveList((ShortcutHelper)treeViewShortcuts.SelectedNode.Tag, shortcutText); - treeViewShortcuts.Focus(); - } - - private void AddToSaveList(ShortcutHelper helper, string shortcutText) - { - if (_newShortcuts.ContainsKey(helper)) - { - _newShortcuts[helper] = GetShortcut(shortcutText); - } - else - { - _newShortcuts.Add(helper, GetShortcut(shortcutText)); - } - } - - private void buttonListViewSyntaxColorError_Click(object sender, EventArgs e) - { - colorDialogSSAStyle.Color = panelListViewSyntaxColorError.BackColor; - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - panelListViewSyntaxColorError.BackColor = colorDialogSSAStyle.Color; - } - } - - private void comboBoxShortcutKey_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Tab || - e.KeyCode == Keys.Down || - e.KeyCode == Keys.Up || - e.KeyCode == Keys.Enter || - e.KeyCode == Keys.None) - { - return; - } - - int i = 0; - foreach (var item in comboBoxShortcutKey.Items) - { - if (item.ToString() == e.KeyCode.ToString()) - { - comboBoxShortcutKey.SelectedIndex = i; - e.SuppressKeyPress = true; - return; - } - i++; - } - } - - private void numericUpDownSsaOutline_ValueChanged(object sender, EventArgs e) - { - UpdateSsaExample(); - } - - private void numericUpDownSsaShadow_ValueChanged(object sender, EventArgs e) - { - UpdateSsaExample(); - } - - private void checkBoxSsaOpaqueBox_CheckedChanged(object sender, EventArgs e) - { - numericUpDownSsaOutline.Enabled = !checkBoxSsaOpaqueBox.Checked; - numericUpDownSsaShadow.Enabled = !checkBoxSsaOpaqueBox.Checked; - UpdateSsaExample(); - } - - private void buttonBrowseToFFmpeg_Click(object sender, EventArgs e) - { - openFileDialogFFmpeg.FileName = string.Empty; - openFileDialogFFmpeg.Title = Configuration.Settings.Language.Settings.WaveformBrowseToFFmpeg; - if (Configuration.IsRunningOnWindows) - { - openFileDialogFFmpeg.Filter = "FFmpeg (ffmpeg.exe)|ffmpeg.exe"; - } - if (openFileDialogFFmpeg.ShowDialog(this) == DialogResult.OK) - { - textBoxFFmpegPath.Text = openFileDialogFFmpeg.FileName; - } - } - - private void checkBoxWaveformHoverFocus_CheckedChanged(object sender, EventArgs e) - { - checkBoxListViewMouseEnterFocus.Enabled = checkBoxWaveformHoverFocus.Checked; - } - - private void buttonVlcPathBrowse_Click(object sender, EventArgs e) - { - openFileDialogFFmpeg.FileName = string.Empty; - openFileDialogFFmpeg.Title = Configuration.Settings.Language.Settings.WaveformBrowseToVLC; - if (Configuration.IsRunningOnWindows) - { - openFileDialogFFmpeg.Filter = $"{Configuration.Settings.Language.Settings.VlcMediaPlayer} (vlc.exe)|vlc.exe"; - } - if (openFileDialogFFmpeg.ShowDialog(this) == DialogResult.OK) - { - EnableVlc(openFileDialogFFmpeg.FileName); - } - } - - private void EnableVlc(string fileName) - { - textBoxVlcPath.Text = Path.GetDirectoryName(fileName); - Configuration.Settings.General.VlcLocation = textBoxVlcPath.Text; - Configuration.Settings.General.VlcLocationRelative = GetRelativePath(textBoxVlcPath.Text); - radioButtonVideoPlayerVLC.Enabled = LibVlcDynamic.IsInstalled; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - Configuration.Settings.General.VlcLocation = _oldVlcLocation; - Configuration.Settings.General.VlcLocationRelative = _oldVlcLocationRelative; - Configuration.Settings.Tools.ListViewShowColumnCharsPerSec = _oldListViewShowCps; - Configuration.Settings.Tools.ListViewShowColumnWordsPerMin = _oldListViewShowWpm; - - DialogResult = DialogResult.Cancel; - } - - private void buttonEditDoNotBreakAfterList_Click(object sender, EventArgs e) - { - using (var form = new DoNotBreakAfterListEdit()) - { - form.ShowDialog(this); - } - } - - private void linkLabelOpenDictionaryFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - string dictionaryFolder = Utilities.DictionaryFolder; - if (!Directory.Exists(dictionaryFolder)) - { - Directory.CreateDirectory(dictionaryFolder); - } - - UiUtil.OpenFolder(dictionaryFolder); - } - - private void textBoxVlcPath_MouseLeave(object sender, EventArgs e) - { - try - { - var path = textBoxVlcPath.Text.Trim('\"'); - if (path.Length > 3 && Path.IsPathRooted(path) && Path.GetFileName(path).Equals("vlc.exe", StringComparison.OrdinalIgnoreCase) && File.Exists(path)) - { - EnableVlc(path); - } - } - catch - { - // ignored - } - } - - private void buttonNetworkSessionNewMessageSound_Click(object sender, EventArgs e) - { - openFileDialogFFmpeg.FileName = string.Empty; - openFileDialogFFmpeg.Title = Configuration.Settings.Language.Settings.WaveformBrowseToFFmpeg; - openFileDialogFFmpeg.Filter = $"{Configuration.Settings.Language.General.AudioFiles} (*.wav)|*.wav"; - if (openFileDialogFFmpeg.ShowDialog(this) == DialogResult.OK) - { - textBoxNetworkSessionNewMessageSound.Text = openFileDialogFFmpeg.FileName; - } - } - - private void panelPrimaryColor_MouseClick(object sender, MouseEventArgs e) - { - colorDialogSSAStyle.Color = Color.FromArgb(_ssaFontColor); - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - _ssaFontColor = colorDialogSSAStyle.Color.ToArgb(); - panelPrimaryColor.BackColor = colorDialogSSAStyle.Color; - UpdateSsaExample(); - } - } - - private void numericUpDownSsaMarginVertical_ValueChanged(object sender, EventArgs e) - { - UpdateSsaExample(); - } - - private void comboBoxFontName_TextChanged(object sender, EventArgs e) - { - _ssaFontName = comboBoxFontName.Text; - UpdateSsaExample(); - } - - private void numericUpDownFontSize_ValueChanged(object sender, EventArgs e) - { - _ssaFontSize = (int)numericUpDownFontSize.Value; - UpdateSsaExample(); - } - - private void buttonSsaColor_Click(object sender, EventArgs e) - { - panelPrimaryColor_MouseClick(sender, null); - } - - private void checkBoxSsaFontBold_CheckedChanged(object sender, EventArgs e) - { - UpdateSsaExample(); - } - - private void buttonMpvSettings_Click(object sender, EventArgs e) - { - using (var form = new SettingsMpv(LibMpvDynamic.IsInstalled)) - { - var oldMpvEnabled = radioButtonVideoPlayerMPV.Enabled; - if (form.ShowDialog(this) == DialogResult.OK) - { - RefreshMpvSettings(); - if (radioButtonVideoPlayerMPV.Enabled && !oldMpvEnabled) - { - radioButtonVideoPlayerMPV.Checked = true; - } - } - else - { - RefreshMpvSettings(); - } - } - } - - private void RefreshMpvSettings() - { - radioButtonVideoPlayerMPV.Enabled = LibMpvDynamic.IsInstalled; - checkBoxMpvHandlesPreviewText.Enabled = radioButtonVideoPlayerMPV.Enabled; - if (!radioButtonVideoPlayerMPV.Enabled) - { - buttonMpvSettings.Font = new Font(buttonMpvSettings.Font.FontFamily, buttonMpvSettings.Font.Size, FontStyle.Bold); - } - - labelMpvSettings.Text = "--vo=" + Configuration.Settings.General.MpvVideoOutputWindows; - } - - private void linkLabelBingSubscribe_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - UiUtil.OpenURL(MicrosoftTranslator.SignUpUrl); - } - - private void ValidateShortcut(object sender, EventArgs e) - { - buttonUpdateShortcut.Enabled = IsShortcutValid(); - } - - private bool IsShortcutValid() - { - if (treeViewShortcuts.SelectedNode == null || !treeViewShortcuts.SelectedNode.Text.Contains('[')) - { - return false; - } - - var shortcutText = GetCurrentShortcutText(); - if (shortcutText == "[CapsLock]" || shortcutText.Length < 3 || shortcutText.EndsWith("+]")) - { - return false; - } - - if (comboBoxShortcutKey.SelectedIndex == 0 && !checkBoxShortcutsControl.Checked && !checkBoxShortcutsAlt.Checked && !checkBoxShortcutsShift.Checked) - { - return true; - } - - var helper = (ShortcutHelper)treeViewShortcuts.SelectedNode.Tag; - if (helper.IsMenuItem) - { - try - { - new ToolStripMenuItem().ShortcutKeys = UiUtil.GetKeys(GetShortcut(shortcutText)); - } - catch (InvalidEnumArgumentException) - { - return false; - } - } - return true; - } - - private void numericUpDownMaxNumberOfLines_ValueChanged(object sender, EventArgs e) - { - checkBoxSyntaxColorTextMoreThanTwoLines.Text = string.Format(Configuration.Settings.Language.Settings.SyntaxColorTextMoreThanMaxLines, numericUpDownMaxNumberOfLines.Value); - ProfileUiValueChanged(sender, e); - } - - private void radioButtonVideoPlayerMPV_CheckedChanged(object sender, EventArgs e) - { - checkBoxMpvHandlesPreviewText.Enabled = radioButtonVideoPlayerMPV.Checked; - } - - private void buttonClearShortcut_Click(object sender, EventArgs e) - { - checkBoxShortcutsControl.Checked = false; - checkBoxShortcutsAlt.Checked = false; - checkBoxShortcutsShift.Checked = false; - comboBoxShortcutKey.SelectedIndex = 0; - buttonUpdateShortcut_Click(null, null); - } - - private void buttonDownloadFfmpeg_Click(object sender, EventArgs e) - { - using (var form = new DownloadFfmpeg()) - { - if (form.ShowDialog(this) == DialogResult.OK && !string.IsNullOrEmpty(form.FFmpegPath)) - { - textBoxFFmpegPath.Text = form.FFmpegPath; - } - } - } - - private void textBoxShortcutSearch_TextChanged(object sender, EventArgs e) - { - var selected = treeViewShortcuts.SelectedNode?.Tag as ShortcutHelper; - var oldControl = checkBoxShortcutsControl.Checked; - var oldAlt = checkBoxShortcutsAlt.Checked; - var oldShift = checkBoxShortcutsShift.Checked; - var oldKeyIndex = comboBoxShortcutKey.SelectedIndex; - ShowShortcutsTreeView(); - buttonShortcutsClear.Enabled = textBoxShortcutSearch.Text.Length > 0; - if (selected != null) - { - foreach (TreeNode parentNode in treeViewShortcuts.Nodes) - { - foreach (TreeNode node in parentNode.Nodes) - { - if (node.Tag is ShortcutHelper sh && sh.Shortcut.Name == selected.Shortcut.Name) - { - treeViewShortcuts.SelectedNode = node; - checkBoxShortcutsControl.Checked = oldControl; - checkBoxShortcutsAlt.Checked = oldAlt; - checkBoxShortcutsShift.Checked = oldShift; - comboBoxShortcutKey.SelectedIndex = oldKeyIndex; - return; - } - } - } - } - comboBoxShortcutKey.Enabled = false; - buttonUpdateShortcut.Enabled = false; - buttonClearShortcut.Enabled = false; - } - - private void buttonShortcutsClear_Click(object sender, EventArgs e) - { - textBoxShortcutSearch.Text = string.Empty; - } - - private void linkLabelGoogleTranslateSignUp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - UiUtil.OpenURL("https://www.google.com/search?q=google+cloud+get+api+key"); - } - - private void buttonEditProfile_Click(object sender, EventArgs e) - { - using (var form = new SettingsProfile(_rulesProfiles, comboBoxRulesProfileName.Text)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - _rulesProfiles = form.RulesProfiles; - UpdateProfileNames(_rulesProfiles); - } - } - } - - private bool _editProfileOn; - private void comboBoxRulesProfileName_SelectedIndexChanged(object sender, EventArgs e) - { - _editProfileOn = true; - var profile = _rulesProfiles.First(p => p.Name == comboBoxRulesProfileName.Text); - numericUpDownSubtitleLineMaximumLength.Value = profile.SubtitleLineMaximumLength; - numericUpDownOptimalCharsSec.Value = profile.SubtitleOptimalCharactersPerSeconds; - numericUpDownMaxCharsSec.Value = profile.SubtitleMaximumCharactersPerSeconds; - numericUpDownMaxWordsMin.Value = profile.SubtitleMaximumWordsPerMinute; - numericUpDownDurationMin.Value = profile.SubtitleMinimumDisplayMilliseconds; - numericUpDownDurationMax.Value = profile.SubtitleMaximumDisplayMilliseconds; - if (profile.MinimumMillisecondsBetweenLines >= numericUpDownMinGapMs.Minimum && - profile.MinimumMillisecondsBetweenLines <= numericUpDownMinGapMs.Maximum) - { - numericUpDownMinGapMs.Value = profile.MinimumMillisecondsBetweenLines; - } - if (profile.MaxNumberOfLines >= numericUpDownMaxNumberOfLines.Minimum && - profile.MaxNumberOfLines <= numericUpDownMaxNumberOfLines.Maximum) - { - numericUpDownMaxNumberOfLines.Value = profile.MaxNumberOfLines; - } - else - { - numericUpDownMaxNumberOfLines.Value = numericUpDownMaxNumberOfLines.Minimum; - } - - if (profile.MergeLinesShorterThan >= 5 && profile.MergeLinesShorterThan - 5 < comboBoxMergeShortLineLength.Items.Count) - { - comboBoxMergeShortLineLength.SelectedIndex = profile.MergeLinesShorterThan - 5; - } - else - { - comboBoxMergeShortLineLength.SelectedIndex = 0; - } - - SetDialogStyle(profile.DialogStyle); - SetContinuationStyle(profile.ContinuationStyle); - - checkBoxCpsIncludeWhiteSpace.Checked = profile.CpsIncludesSpace; - _oldProfileId = profile.Id; - _editProfileOn = false; - } - - private void ProfileUiValueChanged(object sender, EventArgs e) - { - var idx = comboBoxRulesProfileName.SelectedIndex; - if (idx < 0 || _editProfileOn || idx >= _rulesProfiles.Count) - { - return; - } - _rulesProfiles[idx].SubtitleLineMaximumLength = (int)numericUpDownSubtitleLineMaximumLength.Value; - _rulesProfiles[idx].SubtitleOptimalCharactersPerSeconds = numericUpDownOptimalCharsSec.Value; - _rulesProfiles[idx].SubtitleMaximumCharactersPerSeconds = numericUpDownMaxCharsSec.Value; - _rulesProfiles[idx].SubtitleMinimumDisplayMilliseconds = (int)numericUpDownDurationMin.Value; - _rulesProfiles[idx].SubtitleMaximumDisplayMilliseconds = (int)numericUpDownDurationMax.Value; - _rulesProfiles[idx].MinimumMillisecondsBetweenLines = (int)numericUpDownMinGapMs.Value; - _rulesProfiles[idx].MaxNumberOfLines = (int)numericUpDownMaxNumberOfLines.Value; - _rulesProfiles[idx].SubtitleMaximumWordsPerMinute = (int)numericUpDownMaxWordsMin.Value; - _rulesProfiles[idx].CpsIncludesSpace = checkBoxCpsIncludeWhiteSpace.Checked; - _rulesProfiles[idx].MergeLinesShorterThan = comboBoxMergeShortLineLength.SelectedIndex + 5; - _rulesProfiles[idx].DialogStyle = DialogSplitMerge.GetDialogStyleFromIndex(comboBoxDialogStyle.SelectedIndex); - _rulesProfiles[idx].ContinuationStyle = ContinuationUtilities.GetContinuationStyleFromIndex(comboBoxContinuationStyle.SelectedIndex); - - toolTipContinuationPreview.RemoveAll(); - toolTipContinuationPreview.SetToolTip(comboBoxContinuationStyle, ContinuationUtilities.GetContinuationStylePreview(_rulesProfiles[idx].ContinuationStyle)); - } - - private void checkBoxToolsBreakByPixelWidth_CheckedChanged(object sender, EventArgs e) - { - checkBoxToolsBreakPreferBottomHeavy.Enabled = checkBoxToolsBreakByPixelWidth.Checked; - numericUpDownToolsBreakPreferBottomHeavy.Enabled = checkBoxToolsBreakByPixelWidth.Checked; - } - - private void buttonReset_Click(object sender, EventArgs e) - { - var result = MessageBox.Show(Configuration.Settings.Language.Settings.RestoreDefaultSettingsMsg, Configuration.Settings.Language.General.Title, MessageBoxButtons.YesNo); - if (result == DialogResult.Yes) - { - Configuration.Settings.Reset(); - Configuration.Settings.General.VideoPlayer = "MPV"; - Init(); - } - } - - private void toolStripMenuItemShortcutsCollapse_Click(object sender, EventArgs e) - { - treeViewShortcuts.CollapseAll(); - } - - private void listBoxNames_DoubleClick(object sender, EventArgs e) - { - var idx = listBoxNames.SelectedIndex; - if (idx >= 0) - { - textBoxNameEtc.Text = (string)listBoxNames.Items[idx]; - } - } - - private void listBoxUserWordLists_DoubleClick(object sender, EventArgs e) - { - var idx = listBoxUserWordLists.SelectedIndex; - if (idx >= 0) - { - textBoxUserWord.Text = (string)listBoxUserWordLists.Items[idx]; - } - } - - private void listBoxOcrFixList_DoubleClick(object sender, EventArgs e) - { - var idx = listBoxOcrFixList.SelectedIndex; - if (idx >= 0) - { - var text = (string)listBoxOcrFixList.Items[idx]; - var splitIdx = text.IndexOf(" --> ", StringComparison.Ordinal); - if (splitIdx > 0) - { - textBoxOcrFixKey.Text = text.Substring(0, splitIdx); - textBoxOcrFixValue.Text = text.Remove(0, splitIdx + " --> ".Length); - } - } - } - - private void buttonLineWidthSettings_Click(object sender, EventArgs e) - { - using (var form = new SettingsLineWidth()) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - // Saving settings handled by dialog - } - } - } - - private void buttonFixContinuationStyleSettings_Click(object sender, EventArgs e) - { - using (var form = new SettingsFixContinuationStyle()) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - // Saving settings handled by dialog - } - } - } - - private void buttonGapChoose_Click(object sender, EventArgs e) - { - using (var form = new SettingsGapChoose()) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - numericUpDownMinGapMs.Value = form.MinGapMs; - } - } - } - - private void importShortcutsToolStripMenuItem_Click(object sender, EventArgs e) - { - openFileDialogFFmpeg.Title = null; - openFileDialogFFmpeg.Filter = "Xml files|*.xml"; - openFileDialogFFmpeg.FileName = "SE_Shortcuts"; - if (openFileDialogFFmpeg.ShowDialog(this) != DialogResult.OK) - { - return; - } - - try - { - Configuration.Settings.Shortcuts = Shortcuts.Load(openFileDialogFFmpeg.FileName); - textBoxShortcutSearch.Text = string.Empty; - MakeShortcutsTreeView(Configuration.Settings.Language.Settings); - ShowShortcutsTreeView(); - } - catch (Exception exception) - { - MessageBox.Show("Shortcuts not imported!" + Environment.NewLine + Environment.NewLine + - exception.Message + Environment.NewLine + - exception.StackTrace); - SeLogger.Error(exception, "Failed to import shortcuts"); - } - } - - private void exportShortcutsToolStripMenuItem_Click(object sender, EventArgs e) - { - saveFileDialog1.Filter = "Xml files|*.xml"; - saveFileDialog1.FileName = "SE_Shortcuts"; - if (saveFileDialog1.ShowDialog(this) != DialogResult.OK) - { - return; - } - - try - { - var shortcuts = Configuration.Settings.Shortcuts.Clone(); - foreach (var kvp in _newShortcuts) - { - kvp.Key.Shortcut.SetValue(shortcuts, kvp.Value, null); - } - - Shortcuts.Save(saveFileDialog1.FileName, shortcuts); - } - catch (Exception exception) - { - MessageBox.Show(exception.Message + Environment.NewLine + - exception.StackTrace); - SeLogger.Error(exception, "Failed to export shortcuts"); - } - } - - private void pictureBoxPreview_Click(object sender, EventArgs e) - { - _backgroundImageDark = !_backgroundImageDark; - GeneratePreviewReal(); - } - - private void buttonTextBoxHtmlColor_Click(object sender, EventArgs e) - { - colorDialogSSAStyle.Color = panelTextBoxHtmlColor.BackColor; - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - panelTextBoxHtmlColor.BackColor = colorDialogSSAStyle.Color; - } - } - - private void buttonTextBoxAssColor_Click(object sender, EventArgs e) - { - colorDialogSSAStyle.Color = panelTextBoxAssColor.BackColor; - if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) - { - panelTextBoxAssColor.BackColor = colorDialogSSAStyle.Color; - } - } - - private void checkBoxSubtitleTextBoxSyntaxColor_CheckedChanged(object sender, EventArgs e) - { - buttonTextBoxHtmlColor.Enabled = checkBoxSubtitleTextBoxSyntaxColor.Checked; - panelTextBoxHtmlColor.Enabled = checkBoxSubtitleTextBoxSyntaxColor.Checked; - buttonTextBoxAssColor.Enabled = checkBoxSubtitleTextBoxSyntaxColor.Checked; - panelTextBoxAssColor.Enabled = checkBoxSubtitleTextBoxSyntaxColor.Checked; - } - - private void panelTextBoxHtmlColor_MouseClick(object sender, MouseEventArgs e) - { - buttonTextBoxHtmlColor_Click(null, null); - } - - private void panelTextBoxAssColor_MouseClick(object sender, MouseEventArgs e) - { - buttonTextBoxAssColor_Click(null, null); - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Dictionaries; +using Nikse.SubtitleEdit.Core.Enums; +using Nikse.SubtitleEdit.Core.Translate; +using Nikse.SubtitleEdit.Logic; +using Nikse.SubtitleEdit.Logic.VideoPlayers; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class Settings : PositionAndSizeForm + { + private string _ssaFontName; + private double _ssaFontSize; + private int _ssaFontColor; + private string _listBoxSearchString = string.Empty; + private DateTime _listBoxSearchStringLastUsed = DateTime.Now; + private List _wordListNames = new List(); + private List _userWordList = new List(); + private OcrFixReplaceList _ocrFixReplaceList; + private string _oldVlcLocation; + private string _oldVlcLocationRelative; + private bool _oldListViewShowCps; + private bool _oldListViewShowWpm; + private readonly Dictionary _newShortcuts = new Dictionary(); + private List _rulesProfiles; + private bool _loading = true; + private bool _backgroundImageDark; + + private class ComboBoxLanguage + { + public CultureInfo CultureInfo { get; set; } + public override string ToString() + { + return CultureInfo.NativeName.CapitalizeFirstLetter(); + } + } + + public class ShortcutNode + { + public string Text { get; set; } + public string ShortcutText { get; set; } + public ShortcutHelper Shortcut { get; set; } + public List Nodes { get; set; } + + public ShortcutNode() + { + Nodes = new List(); + } + + public ShortcutNode(string text) + { + Text = text; + Nodes = new List(); + } + } + + public class ShortcutHelper + { + public ShortcutHelper(PropertyInfo shortcut, bool isMenuItem) + { + Shortcut = shortcut; + IsMenuItem = isMenuItem; + } + + public PropertyInfo Shortcut { get; set; } + public bool IsMenuItem { get; set; } + } + + private static string GetRelativePath(string fileName) + { + string folder = Configuration.BaseDirectory; + + if (string.IsNullOrEmpty(fileName) || !fileName.StartsWith(folder.Substring(0, 2), StringComparison.OrdinalIgnoreCase)) + { + return string.Empty; + } + + var pathUri = new Uri(fileName); + if (!folder.EndsWith(Path.DirectorySeparatorChar)) + { + folder += Path.DirectorySeparatorChar; + } + + var folderUri = new Uri(folder); + return Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar)); + } + + public Settings() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + UiUtil.FixLargeFonts(this, buttonOK); + Init(); + } + + public void Init() + { + _loading = true; + labelStatus.Text = string.Empty; + _rulesProfiles = new List(Configuration.Settings.General.Profiles); + var gs = Configuration.Settings.General; + + checkBoxToolbarNew.Checked = gs.ShowToolbarNew; + checkBoxToolbarOpen.Checked = gs.ShowToolbarOpen; + checkBoxToolbarSave.Checked = gs.ShowToolbarSave; + checkBoxToolbarSaveAs.Checked = gs.ShowToolbarSaveAs; + checkBoxToolbarFind.Checked = gs.ShowToolbarFind; + checkBoxReplace.Checked = gs.ShowToolbarReplace; + checkBoxTBFixCommonErrors.Checked = gs.ShowToolbarFixCommonErrors; + checkBoxTBRemoveTextForHi.Checked = gs.ShowToolbarRemoveTextForHi; + checkBoxVisualSync.Checked = gs.ShowToolbarVisualSync; + checkBoxSettings.Checked = gs.ShowToolbarSettings; + checkBoxSpellCheck.Checked = gs.ShowToolbarSpellCheck; + checkBoxNetflixQualityCheck.Checked = gs.ShowToolbarNetflixGlyphCheck; + checkBoxHelp.Checked = gs.ShowToolbarHelp; + + comboBoxFrameRate.Items.Clear(); + comboBoxFrameRate.Items.Add(23.976.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(24.0.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(25.0.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(29.97.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(30.00.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(50.00.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(59.94.ToString(CultureInfo.CurrentCulture)); + comboBoxFrameRate.Items.Add(60.00.ToString(CultureInfo.CurrentCulture)); + + checkBoxShowFrameRate.Checked = gs.ShowFrameRate; + comboBoxFrameRate.Text = gs.DefaultFrameRate.ToString(CultureInfo.CurrentCulture); + + UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding); + + checkBoxAutoDetectAnsiEncoding.Checked = gs.AutoGuessAnsiEncoding; + comboBoxSubtitleFontSize.Text = gs.SubtitleTextBoxFontSize.ToString(CultureInfo.InvariantCulture); + comboBoxSubtitleListViewFontSize.Text = gs.SubtitleListViewFontSize.ToString(CultureInfo.InvariantCulture); + checkBoxSubtitleFontBold.Checked = gs.SubtitleTextBoxFontBold; + checkBoxSubtitleTextBoxSyntaxColor.Checked = gs.SubtitleTextBoxSyntaxColor; + panelTextBoxHtmlColor.BackColor = gs.SubtitleTextBoxHtmlColor; + panelTextBoxAssColor.BackColor = gs.SubtitleTextBoxAssColor; + checkBoxSubtitleListViewFontBold.Checked = gs.SubtitleListViewFontBold; + checkBoxSubtitleCenter.Checked = gs.CenterSubtitleInTextBox; + panelSubtitleFontColor.BackColor = gs.SubtitleFontColor; + panelSubtitleBackgroundColor.BackColor = gs.SubtitleBackgroundColor; + checkBoxRememberRecentFiles.Checked = gs.ShowRecentFiles; + checkBoxRememberRecentFiles_CheckedChanged(null, null); + checkBoxRememberSelectedLine.Checked = gs.RememberSelectedLine; + checkBoxReopenLastOpened.Checked = gs.StartLoadLastFile; + checkBoxStartInSourceView.Checked = gs.StartInSourceView; + checkBoxRemoveBlankLinesWhenOpening.Checked = gs.RemoveBlankLinesWhenOpening; + checkBoxRememberWindowPosition.Checked = gs.StartRememberPositionAndSize; + numericUpDownSubtitleLineMaximumLength.Value = gs.SubtitleLineMaximumLength; + numericUpDownOptimalCharsSec.Value = (decimal)gs.SubtitleOptimalCharactersPerSeconds; + numericUpDownMaxCharsSec.Value = (decimal)gs.SubtitleMaximumCharactersPerSeconds; + numericUpDownMaxWordsMin.Value = (decimal)gs.SubtitleMaximumWordsPerMinute; + checkBoxAutoWrapWhileTyping.Checked = gs.AutoWrapLineWhileTyping; + textBoxShowLineBreaksAs.Text = gs.ListViewLineSeparatorString; + + numericUpDownDurationMin.Value = gs.SubtitleMinimumDisplayMilliseconds; + numericUpDownDurationMax.Value = gs.SubtitleMaximumDisplayMilliseconds; + + if (gs.MinimumMillisecondsBetweenLines >= numericUpDownMinGapMs.Minimum && + gs.MinimumMillisecondsBetweenLines <= numericUpDownMinGapMs.Maximum) + { + numericUpDownMinGapMs.Value = gs.MinimumMillisecondsBetweenLines; + } + + if (gs.VideoPlayer.Trim().Equals("VLC", StringComparison.OrdinalIgnoreCase) && LibVlcDynamic.IsInstalled) + { + radioButtonVideoPlayerVLC.Checked = true; + } + else if (gs.VideoPlayer.Trim().Equals("MPV", StringComparison.OrdinalIgnoreCase) && LibMpvDynamic.IsInstalled) + { + radioButtonVideoPlayerMPV.Checked = true; + } + else if (gs.VideoPlayer.Trim().Equals("MPC-HC", StringComparison.OrdinalIgnoreCase) && UiUtil.IsMpcHcInstalled) + { + radioButtonVideoPlayerMpcHc.Checked = true; + } + else if (UiUtil.IsQuartsDllInstalled) + { + radioButtonVideoPlayerDirectShow.Checked = true; + } + else if (LibMpvDynamic.IsInstalled) + { + radioButtonVideoPlayerMPV.Checked = true; + } + else if (LibVlcDynamic.IsInstalled) + { + radioButtonVideoPlayerVLC.Checked = true; + } + + if (!LibVlcDynamic.IsInstalled) + { + radioButtonVideoPlayerVLC.Enabled = false; + } + + if (!UiUtil.IsQuartsDllInstalled) + { + radioButtonVideoPlayerDirectShow.Enabled = false; + } + + if (Logic.VideoPlayers.MpcHC.MpcHc.GetMpcHcFileName() == null) + { + radioButtonVideoPlayerMpcHc.Enabled = false; + } + + RefreshMpvSettings(); + buttonMpvSettings.Text = Configuration.Settings.Language.SettingsMpv.DownloadMpv; + checkBoxMpvHandlesPreviewText.Checked = gs.MpvHandlesPreviewText; + + textBoxVlcPath.Text = gs.VlcLocation; + textBoxVlcPath.Left = labelVideoPlayerVLC.Left + labelVideoPlayerVLC.Width + 5; + textBoxVlcPath.Width = buttonVlcPathBrowse.Left - textBoxVlcPath.Left - 5; + + labelVlcPath.Text = Configuration.Settings.Language.Settings.VlcBrowseToLabel; + + checkBoxVideoPlayerShowStopButton.Checked = gs.VideoPlayerShowStopButton; + checkBoxVideoPlayerShowMuteButton.Checked = gs.VideoPlayerShowMuteButton; + checkBoxVideoPlayerShowFullscreenButton.Checked = gs.VideoPlayerShowFullscreenButton; + + int videoPlayerPreviewFontSizeIndex = gs.VideoPlayerPreviewFontSize - int.Parse(comboBoxlVideoPlayerPreviewFontSize.Items[0].ToString()); + if (videoPlayerPreviewFontSizeIndex >= 0 && videoPlayerPreviewFontSizeIndex < comboBoxlVideoPlayerPreviewFontSize.Items.Count) + { + comboBoxlVideoPlayerPreviewFontSize.SelectedIndex = videoPlayerPreviewFontSizeIndex; + } + else + { + comboBoxlVideoPlayerPreviewFontSize.SelectedIndex = 3; + } + + checkBoxVideoPlayerPreviewFontBold.Checked = gs.VideoPlayerPreviewFontBold; + + checkBoxVideoAutoOpen.Checked = !gs.DisableVideoAutoLoading; + checkBoxAllowVolumeBoost.Checked = gs.AllowVolumeBoost; + + comboBoxCustomSearch1.Text = Configuration.Settings.VideoControls.CustomSearchText1; + comboBoxCustomSearch2.Text = Configuration.Settings.VideoControls.CustomSearchText2; + comboBoxCustomSearch3.Text = Configuration.Settings.VideoControls.CustomSearchText3; + comboBoxCustomSearch4.Text = Configuration.Settings.VideoControls.CustomSearchText4; + comboBoxCustomSearch5.Text = Configuration.Settings.VideoControls.CustomSearchText5; + textBoxCustomSearchUrl1.Text = Configuration.Settings.VideoControls.CustomSearchUrl1; + textBoxCustomSearchUrl2.Text = Configuration.Settings.VideoControls.CustomSearchUrl2; + textBoxCustomSearchUrl3.Text = Configuration.Settings.VideoControls.CustomSearchUrl3; + textBoxCustomSearchUrl4.Text = Configuration.Settings.VideoControls.CustomSearchUrl4; + textBoxCustomSearchUrl5.Text = Configuration.Settings.VideoControls.CustomSearchUrl5; + + comboBoxFontName.BeginUpdate(); + comboBoxSubtitleFont.BeginUpdate(); + comboBoxFontName.Items.Clear(); + comboBoxSubtitleFont.Items.Clear(); + var comboBoxFontNameList = new List(); + var comboBoxSubtitleFontList = new List(); + var comboBoxSubtitleFontIndex = 0; + foreach (var x in FontFamily.Families.OrderBy(p => p.Name)) + { + comboBoxFontNameList.Add(x.Name); + if (x.IsStyleAvailable(FontStyle.Regular) && x.IsStyleAvailable(FontStyle.Bold)) + { + comboBoxSubtitleFontList.Add(x.Name); + if (x.Name.Equals(gs.SubtitleFontName, StringComparison.OrdinalIgnoreCase)) + { + comboBoxSubtitleFontIndex = comboBoxSubtitleFontList.Count - 1; + } + } + } + comboBoxFontName.Items.AddRange(comboBoxFontNameList.ToArray()); + comboBoxSubtitleFont.Items.AddRange(comboBoxSubtitleFontList.ToArray()); + comboBoxSubtitleFont.SelectedIndex = comboBoxSubtitleFontIndex; + comboBoxFontName.EndUpdate(); + comboBoxSubtitleFont.EndUpdate(); + + var wordListSettings = Configuration.Settings.WordLists; + checkBoxNamesOnline.Checked = wordListSettings.UseOnlineNames; + textBoxNamesOnline.Text = wordListSettings.NamesUrl; + + var ssa = Configuration.Settings.SubtitleSettings; + _ssaFontName = ssa.SsaFontName; + _ssaFontSize = ssa.SsaFontSize; + _ssaFontColor = ssa.SsaFontColorArgb; + if (ssa.SsaOutline >= numericUpDownSsaOutline.Minimum && ssa.SsaOutline <= numericUpDownSsaOutline.Maximum) + { + numericUpDownSsaOutline.Value = ssa.SsaOutline; + } + + if (ssa.SsaShadow >= numericUpDownSsaShadow.Minimum && ssa.SsaShadow <= numericUpDownSsaShadow.Maximum) + { + numericUpDownSsaShadow.Value = ssa.SsaShadow; + } + + numericUpDownSsaMarginLeft.Value = ssa.SsaMarginLeft; + numericUpDownSsaMarginRight.Value = ssa.SsaMarginRight; + numericUpDownSsaMarginVertical.Value = ssa.SsaMarginTopBottom; + checkBoxSsaFontBold.Checked = ssa.SsaFontBold; + checkBoxSsaOpaqueBox.Checked = ssa.SsaOpaqueBox; + numericUpDownFontSize.Value = (decimal)ssa.SsaFontSize; + comboBoxFontName.Text = ssa.SsaFontName; + panelPrimaryColor.BackColor = Color.FromArgb(_ssaFontColor); + + var proxy = Configuration.Settings.Proxy; + textBoxProxyAddress.Text = proxy.ProxyAddress; + textBoxProxyUserName.Text = proxy.UserName; + textBoxProxyPassword.Text = proxy.Password == null ? string.Empty : proxy.DecodePassword(); + textBoxProxyDomain.Text = proxy.Domain; + + textBoxNetworkSessionNewMessageSound.Text = Configuration.Settings.NetworkSettings.NewMessageSound; + + checkBoxSyntaxColorDurationTooSmall.Checked = Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall; + checkBoxSyntaxColorDurationTooLarge.Checked = Configuration.Settings.Tools.ListViewSyntaxColorDurationBig; + checkBoxSyntaxColorTextTooLong.Checked = Configuration.Settings.Tools.ListViewSyntaxColorLongLines; + checkBoxSyntaxColorTextTooWide.Checked = Configuration.Settings.Tools.ListViewSyntaxColorWideLines; + checkBoxSyntaxColorTextMoreThanTwoLines.Checked = Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines; + if (Configuration.Settings.General.MaxNumberOfLines >= numericUpDownMaxNumberOfLines.Minimum && + Configuration.Settings.General.MaxNumberOfLines <= numericUpDownMaxNumberOfLines.Maximum) + { + numericUpDownMaxNumberOfLines.Value = Configuration.Settings.General.MaxNumberOfLines; + } + checkBoxSyntaxOverlap.Checked = Configuration.Settings.Tools.ListViewSyntaxColorOverlap; + checkBoxSyntaxColorGapTooSmall.Checked = Configuration.Settings.Tools.ListViewSyntaxColorGap; + panelListViewSyntaxColorError.BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor; + + // Language + var language = Configuration.Settings.Language.Settings; + Text = language.Title; + tabPageGeneral.Text = language.General; + tabPageVideoPlayer.Text = language.VideoPlayer; + tabPageWaveform.Text = language.WaveformAndSpectrogram; + tabPageWordLists.Text = language.WordLists; + tabPageTools.Text = language.Tools; + tabPageSsaStyle.Text = language.SsaStyle; + tabPageNetwork.Text = language.Network; + tabPageToolBar.Text = language.Toolbar; + tabPageFont.Text = Configuration.Settings.Language.DCinemaProperties.Font; + tabPageShortcuts.Text = language.Shortcuts; + tabPageSyntaxColoring.Text = language.SyntaxColoring; + groupBoxShowToolBarButtons.Text = language.ShowToolBarButtons; + labelTBNew.Text = language.New; + labelTBOpen.Text = language.Open; + labelTBSave.Text = language.Save; + labelTBSaveAs.Text = language.SaveAs; + labelTBFind.Text = language.Find; + labelTBReplace.Text = language.Replace; + labelTBFixCommonErrors.Text = language.FixCommonerrors; + labelTBRemoveTextForHi.Text = language.RemoveTextForHi; + labelTBVisualSync.Text = language.VisualSync; + labelTBSpellCheck.Text = language.SpellCheck; + labelTBNetflixQualityCheck.Text = language.NetflixQualityCheck; + labelTBSettings.Text = language.SettingsName; + labelTBHelp.Text = language.Help; + checkBoxToolbarNew.Text = Configuration.Settings.Language.General.Visible; + checkBoxToolbarOpen.Text = Configuration.Settings.Language.General.Visible; + checkBoxToolbarSave.Text = Configuration.Settings.Language.General.Visible; + checkBoxToolbarSaveAs.Text = Configuration.Settings.Language.General.Visible; + checkBoxToolbarFind.Text = Configuration.Settings.Language.General.Visible; + checkBoxReplace.Text = Configuration.Settings.Language.General.Visible; + checkBoxTBFixCommonErrors.Text = Configuration.Settings.Language.General.Visible; + checkBoxTBRemoveTextForHi.Text = Configuration.Settings.Language.General.Visible; + checkBoxVisualSync.Text = Configuration.Settings.Language.General.Visible; + checkBoxSpellCheck.Text = Configuration.Settings.Language.General.Visible; + checkBoxNetflixQualityCheck.Text = Configuration.Settings.Language.General.Visible; + checkBoxSettings.Text = Configuration.Settings.Language.General.Visible; + checkBoxHelp.Text = Configuration.Settings.Language.General.Visible; + + groupBoxMiscellaneous.Text = language.General; + groupBoxGeneralRules.Text = language.Rules; + labelRulesProfileName.Text = language.Profile; + checkBoxShowFrameRate.Text = language.ShowFrameRate; + labelDefaultFrameRate.Text = language.DefaultFrameRate; + labelDefaultFileEncoding.Text = language.DefaultFileEncoding; + labelAutoDetectAnsiEncoding.Text = language.AutoDetectAnsiEncoding; + labelSubMaxLen.Text = language.SubtitleLineMaximumLength; + labelOptimalCharsPerSecond.Text = language.OptimalCharactersPerSecond; + labelMaxCharsPerSecond.Text = language.MaximumCharactersPerSecond; + labelMaxWordsPerMin.Text = language.MaximumWordssPerMinute; + checkBoxAutoWrapWhileTyping.Text = language.AutoWrapWhileTyping; + groupBoxFont.Text = language.FontInUi; + groupBoxFontGeneral.Text = language.General; + groupBoxFontListViews.Text = language.ListView; + groupBoxFontTextBox.Text = language.TextBox; + labelFontNote.Text = language.FontNote; + labelMinDuration.Text = language.DurationMinimumMilliseconds; + labelMaxDuration.Text = language.DurationMaximumMilliseconds; + labelMinGapMs.Text = language.MinimumGapMilliseconds; + buttonGapChoose.Left = numericUpDownMinGapMs.Left + numericUpDownMinGapMs.Width + 5; + labelMaxLines.Text = language.MaximumLines; + if (labelSubMaxLen.Left + labelSubMaxLen.Width > numericUpDownSubtitleLineMaximumLength.Left) + { + numericUpDownSubtitleLineMaximumLength.Left = labelSubMaxLen.Left + labelSubMaxLen.Width + 3; + } + + if (labelMaxCharsPerSecond.Left + labelMaxCharsPerSecond.Width > numericUpDownMaxCharsSec.Left) + { + numericUpDownMaxCharsSec.Left = labelMaxCharsPerSecond.Left + labelMaxCharsPerSecond.Width + 3; + } + + if (labelMaxWordsPerMin.Left + labelMaxWordsPerMin.Width > numericUpDownMaxWordsMin.Left) + { + numericUpDownMaxWordsMin.Left = labelMaxWordsPerMin.Left + labelMaxWordsPerMin.Width + 3; + } + + if (labelMinDuration.Left + labelMinDuration.Width > numericUpDownDurationMin.Left) + { + numericUpDownDurationMin.Left = labelMinDuration.Left + labelMinDuration.Width + 3; + } + + if (labelMaxDuration.Left + labelMaxDuration.Width > numericUpDownDurationMax.Left) + { + numericUpDownDurationMax.Left = labelMaxDuration.Left + labelMaxDuration.Width + 3; + } + + if (labelMinGapMs.Left + labelMinGapMs.Width > numericUpDownMinGapMs.Left) + { + numericUpDownMinGapMs.Left = labelMinGapMs.Left + labelMinGapMs.Width + 3; + } + + if (labelMergeShortLines.Left + labelMergeShortLines.Width > comboBoxMergeShortLineLength.Left) + { + comboBoxMergeShortLineLength.Left = labelMergeShortLines.Left + labelMergeShortLines.Width + 3; + } + + labelSubtitleFont.Text = language.SubtitleFont; + labelSubtitleFontSize.Text = language.SubtitleFontSize; + labelSubtitleListViewFontSize.Text = language.SubtitleFontSize; + checkBoxSubtitleFontBold.Text = language.SubtitleBold; + checkBoxSubtitleTextBoxSyntaxColor.Text = language.UseSyntaxColoring; + buttonTextBoxHtmlColor.Text = language.HtmlColor; + buttonTextBoxAssColor.Text = language.AssaColor; + checkBoxSubtitleListViewFontBold.Text = language.SubtitleBold; + checkBoxSubtitleCenter.Text = language.SubtitleCenter; + checkBoxSubtitleCenter.Left = checkBoxSubtitleFontBold.Left; + labelSubtitleFontColor.Text = language.SubtitleFontColor; + labelSubtitleFontBackgroundColor.Text = language.SubtitleBackgroundColor; + labelSpellChecker.Text = language.SpellChecker; + comboBoxSpellChecker.Left = labelSpellChecker.Left + labelSpellChecker.Width + 4; + checkBoxRememberRecentFiles.Text = language.RememberRecentFiles; + checkBoxReopenLastOpened.Text = language.StartWithLastFileLoaded; + checkBoxRememberSelectedLine.Text = language.RememberSelectedLine; + checkBoxStartInSourceView.Text = language.StartInSourceView; + checkBoxRemoveBlankLinesWhenOpening.Text = language.RemoveBlankLinesWhenOpening; + checkBoxRememberWindowPosition.Text = language.RememberPositionAndSize; + + labelShowLineBreaksAs.Text = language.ShowLineBreaksAs; + textBoxShowLineBreaksAs.Left = labelShowLineBreaksAs.Left + labelShowLineBreaksAs.Width; + labelListViewDoubleClickEvent.Text = language.MainListViewDoubleClickAction; + labelSaveAsFileNameFrom.Text = language.SaveAsFileNameFrom; + labelAutoBackup.Text = language.AutoBackup; + labelAutoBackupDeleteAfter.Text = language.AutoBackupDeleteAfter; + comboBoxAutoBackup.Left = labelAutoBackup.Left + labelAutoBackup.Width + 3; + labelAutoBackupDeleteAfter.Left = comboBoxAutoBackup.Left + comboBoxAutoBackup.Width + 5; + comboBoxAutoBackupDeleteAfter.Left = labelAutoBackupDeleteAfter.Left + labelAutoBackupDeleteAfter.Width + 3; + checkBoxCheckForUpdates.Text = language.CheckForUpdates; + checkBoxAutoSave.Text = language.AutoSave; + checkBoxCheckForUpdates.Left = checkBoxAutoSave.Left + checkBoxAutoSave.Width + 15; + checkBoxAllowEditOfOriginalSubtitle.Text = language.AllowEditOfOriginalSubtitle; + checkBoxPromptDeleteLines.Text = language.PromptDeleteLines; + + comboBoxTimeCodeMode.Items.Clear(); + comboBoxTimeCodeMode.Items.Add(language.TimeCodeModeHHMMSSMS); + comboBoxTimeCodeMode.Items.Add(language.TimeCodeModeHHMMSSFF); + comboBoxTimeCodeMode.SelectedIndex = gs.UseTimeFormatHHMMSSFF ? 1 : 0; + labelTimeCodeMode.Text = language.TimeCodeMode; + comboBoxTimeCodeMode.Left = labelTimeCodeMode.Left + labelTimeCodeMode.Width + 4; + + comboBoxSplitBehavior.Items.Clear(); + comboBoxSplitBehavior.Items.Add(language.SplitBehaviorPrevious); + comboBoxSplitBehavior.Items.Add(language.SplitBehaviorHalf); + comboBoxSplitBehavior.Items.Add(language.SplitBehaviorNext); + comboBoxSplitBehavior.SelectedIndex = gs.SplitBehavior; + labelSplitBehavior.Text = language.SplitBehavior; + comboBoxSplitBehavior.Left = labelTimeCodeMode.Left + labelTimeCodeMode.Width + 4; + if (labelSplitBehavior.Width > labelTimeCodeMode.Width) + { + comboBoxSplitBehavior.Left = labelSplitBehavior.Left + labelSplitBehavior.Width + 4; + } + + var dropDownSplitBehaviorWidth = comboBoxSplitBehavior.Width; + using (var g = Graphics.FromHwnd(IntPtr.Zero)) + { + foreach (var item in comboBoxSplitBehavior.Items) + { + var itemWidth = (int)g.MeasureString((string)item, Font).Width + 5; + dropDownSplitBehaviorWidth = Math.Max(itemWidth, dropDownSplitBehaviorWidth); + } + } + comboBoxSplitBehavior.DropDownWidth = dropDownSplitBehaviorWidth; + + + comboBoxAutoBackup.Items[0] = Configuration.Settings.Language.General.None; + comboBoxAutoBackup.Items[1] = language.AutoBackupEveryMinute; + comboBoxAutoBackup.Items[2] = language.AutoBackupEveryFiveMinutes; + comboBoxAutoBackup.Items[3] = language.AutoBackupEveryFifteenMinutes; + + comboBoxAutoBackupDeleteAfter.Items[0] = language.AutoBackupDeleteAfterOneMonth; + comboBoxAutoBackupDeleteAfter.Items[1] = language.AutoBackupDeleteAfterThreeMonths; + comboBoxAutoBackupDeleteAfter.Items[2] = language.AutoBackupDeleteAfterSixMonths; + + groupBoxVideoEngine.Text = language.VideoEngine; + radioButtonVideoPlayerDirectShow.Text = language.DirectShow; + + labelDirectShowDescription.Text = language.DirectShowDescription; + + radioButtonVideoPlayerMpcHc.Text = language.MpcHc; + labelMpcHcDescription.Text = language.MpcHcDescription; + + radioButtonVideoPlayerMPV.Text = language.MpvPlayer; + labelVideoPlayerMPlayer.Text = language.MpvPlayerDescription; + buttonMpvSettings.Left = labelVideoPlayerMPlayer.Left + labelVideoPlayerMPlayer.Width + 5; + labelMpvSettings.Left = buttonMpvSettings.Left + buttonMpvSettings.Width + 5; + checkBoxMpvHandlesPreviewText.Text = language.MpvHandlesPreviewText; + + radioButtonVideoPlayerVLC.Text = language.VlcMediaPlayer; + labelVideoPlayerVLC.Text = language.VlcMediaPlayerDescription; + gs.VlcLocation = textBoxVlcPath.Text; + + checkBoxVideoPlayerShowStopButton.Text = language.ShowStopButton; + checkBoxVideoPlayerShowMuteButton.Text = language.ShowMuteButton; + checkBoxVideoPlayerShowFullscreenButton.Text = language.ShowFullscreenButton; + + labelVideoPlayerPreviewFontSize.Text = language.PreviewFontSize; + comboBoxlVideoPlayerPreviewFontSize.Left = labelVideoPlayerPreviewFontSize.Left + labelVideoPlayerPreviewFontSize.Width; + checkBoxVideoPlayerPreviewFontBold.Text = language.SubtitleBold; + checkBoxVideoPlayerPreviewFontBold.Left = comboBoxlVideoPlayerPreviewFontSize.Left; + + checkBoxVideoAutoOpen.Text = language.VideoAutoOpen; + checkBoxAllowVolumeBoost.Text = language.AllowVolumeBoost; + + groupBoxMainWindowVideoControls.Text = language.MainWindowVideoControls; + labelCustomSearch.Text = language.CustomSearchTextAndUrl; + + groupBoxWaveformAppearence.Text = language.WaveformAppearance; + checkBoxWaveformShowGrid.Text = language.WaveformShowGridLines; + checkBoxWaveformShowCps.Text = language.WaveformShowCps; + checkBoxWaveformShowWpm.Text = language.WaveformShowWpm; + checkBoxReverseMouseWheelScrollDirection.Text = language.ReverseMouseWheelScrollDirection; + checkBoxAllowOverlap.Text = language.WaveformAllowOverlap; + checkBoxWaveformSetVideoPosMoveStartEnd.Text = language.WaveformSetVideoPosMoveStartEnd; + checkBoxWaveformHoverFocus.Text = language.WaveformFocusMouseEnter; + checkBoxListViewMouseEnterFocus.Text = language.WaveformListViewFocusMouseEnter; + checkBoxWaveformSingleClickSelect.Text = language.WaveformSingleClickSelect; + checkBoxWaveformSnapToSceneChanges.Text = language.WaveformSnapToSceneChanges; + labelWaveformBorderHitMs1.Text = language.WaveformBorderHitMs1; + labelWaveformBorderHitMs2.Text = language.WaveformBorderHitMs2; + numericUpDownWaveformBorderHitMs.Left = labelWaveformBorderHitMs1.Left + labelWaveformBorderHitMs1.Width; + labelWaveformBorderHitMs2.Left = numericUpDownWaveformBorderHitMs.Left + numericUpDownWaveformBorderHitMs.Width + 2; + + buttonWaveformGridColor.Text = language.WaveformGridColor; + buttonWaveformColor.Text = language.WaveformColor; + buttonWaveformSelectedColor.Text = language.WaveformSelectedColor; + buttonWaveformTextColor.Text = language.WaveformTextColor; + buttonWaveformBackgroundColor.Text = language.WaveformBackgroundColor; + buttonWaveformCursorColor.Text = language.WaveformCursorColor; + groupBoxSpectrogram.Text = language.Spectrogram; + checkBoxGenerateSpectrogram.Text = language.GenerateSpectrogram; + labelSpectrogramAppearance.Text = language.SpectrogramAppearance; + comboBoxSpectrogramAppearance.Items.Clear(); + comboBoxSpectrogramAppearance.Items.Add(language.SpectrogramOneColorGradient); + comboBoxSpectrogramAppearance.Items.Add(language.SpectrogramClassic); + labelWaveformTextSize.Text = language.WaveformTextFontSize; + comboBoxWaveformTextSize.Left = labelWaveformTextSize.Left + labelWaveformTextSize.Width + 5; + checkBoxWaveformTextBold.Text = language.SubtitleBold; + checkBoxWaveformTextBold.Left = comboBoxWaveformTextSize.Left + comboBoxWaveformTextSize.Width + 5; + + buttonWaveformsFolderEmpty.Text = language.WaveformAndSpectrogramsFolderEmpty; + InitializeWaveformsAndSpectrogramsFolderEmpty(language); + + checkBoxUseFFmpeg.Text = language.WaveformUseFFmpeg; + buttonDownloadFfmpeg.Text = language.DownloadFFmpeg; + if (!Configuration.IsRunningOnWindows) + { + buttonDownloadFfmpeg.Visible = false; + labelFFmpegPath.Visible = false; + textBoxFFmpegPath.Visible = false; + buttonBrowseToFFmpeg.Visible = false; + + buttonMpvSettings.Visible = false; + radioButtonVideoPlayerDirectShow.Enabled = false; + radioButtonVideoPlayerMpcHc.Enabled = false; + var isLibVlcInstalled = LibVlcDynamic.IsInstalled; + radioButtonVideoPlayerVLC.Enabled = isLibVlcInstalled; + if (gs.VideoPlayer.Trim().Equals("VLC", StringComparison.OrdinalIgnoreCase) && isLibVlcInstalled) + { + radioButtonVideoPlayerVLC.Checked = true; + } + if (LibMpvDynamic.IsInstalled) + { + radioButtonVideoPlayerMPV.Enabled = true; + radioButtonVideoPlayerMPV.Checked = !(gs.VideoPlayer.Trim().Equals("VLC", StringComparison.OrdinalIgnoreCase) && isLibVlcInstalled); + labelMpvSettings.Text = "--vo=" + Configuration.Settings.General.MpvVideoOutputLinux; + } + textBoxVlcPath.Visible = false; + labelVlcPath.Visible = false; + buttonVlcPathBrowse.Visible = false; + } + + labelFFmpegPath.Text = language.WaveformFFmpegPath; + + groupBoxSsaStyle.Text = language.SubStationAlphaStyle; + + var ssaStyles = Configuration.Settings.Language.SubStationAlphaStyles; + labelSsaFontSize.Text = ssaStyles.FontSize; + labelFontName.Text = ssaStyles.FontName; + buttonSsaColor.Text = Configuration.Settings.Language.Settings.ChooseColor; + groupSsaBoxFont.Text = ssaStyles.Font; + groupBoxSsaBorder.Text = ssaStyles.Border; + groupBoxMargins.Text = ssaStyles.Margins; + labelMarginLeft.Text = ssaStyles.MarginLeft; + labelMarginRight.Text = ssaStyles.MarginRight; + labelMarginVertical.Text = ssaStyles.MarginVertical; + labelSsaOutline.Text = language.SsaOutline; + labelSsaShadow.Text = language.SsaShadow; + checkBoxSsaOpaqueBox.Text = language.SsaOpaqueBox; + checkBoxSsaFontBold.Text = Configuration.Settings.Language.General.Bold; + + groupBoxPreview.Text = Configuration.Settings.Language.General.Preview; + + numericUpDownSsaOutline.Left = labelSsaOutline.Left + labelSsaOutline.Width + 4; + numericUpDownSsaShadow.Left = labelSsaShadow.Left + labelSsaShadow.Width + 4; + if (Math.Abs(numericUpDownSsaOutline.Left - numericUpDownSsaShadow.Left) < 9) + { + if (numericUpDownSsaOutline.Left > numericUpDownSsaShadow.Left) + { + numericUpDownSsaShadow.Left = numericUpDownSsaOutline.Left; + } + else + { + numericUpDownSsaOutline.Left = numericUpDownSsaShadow.Left; + } + } + + groupBoxWordLists.Text = language.WordLists; + labelWordListLanguage.Text = language.Language; + comboBoxWordListLanguage.Left = labelWordListLanguage.Left + labelWordListLanguage.Width + 4; + groupBoxNamesIgonoreLists.Text = language.NamesIgnoreLists; + groupBoxUserWordList.Text = language.UserWordList; + groupBoxOcrFixList.Text = language.OcrFixList; + buttonRemoveNameEtc.Text = language.Remove; + buttonRemoveUserWord.Text = language.Remove; + buttonRemoveOcrFix.Text = language.Remove; + buttonAddNames.Text = language.AddName; + buttonAddUserWord.Text = language.AddWord; + buttonAddOcrFix.Text = language.AddPair; + groupBoxWordListLocation.Text = language.Location; + checkBoxNamesOnline.Text = language.UseOnlineNames; + linkLabelOpenDictionaryFolder.Text = Configuration.Settings.Language.GetDictionaries.OpenDictionariesFolder; + + groupBoxProxySettings.Text = language.ProxyServerSettings; + labelProxyAddress.Text = language.ProxyAddress; + groupBoxProxyAuthentication.Text = language.ProxyAuthentication; + labelProxyUserName.Text = language.ProxyUserName; + labelProxyPassword.Text = language.ProxyPassword; + labelProxyDomain.Text = language.ProxyDomain; + + groupBoxNetworkSession.Text = language.NetworkSessionSettings; + labelNetworkSessionNewMessageSound.Text = language.NetworkSessionNewSound; + + groupBoxToolsVisualSync.Text = language.VisualSync; + labelVerifyButton.Text = language.PlayXSecondsAndBack; + labelToolsStartScene.Text = language.StartSceneIndex; + labelToolsEndScene.Text = language.EndSceneIndex; + comboBoxToolsStartSceneIndex.Items.Clear(); + comboBoxToolsStartSceneIndex.Items.Add(string.Format(language.FirstPlusX, 0)); + comboBoxToolsStartSceneIndex.Items.Add(string.Format(language.FirstPlusX, 1)); + comboBoxToolsStartSceneIndex.Items.Add(string.Format(language.FirstPlusX, 2)); + comboBoxToolsStartSceneIndex.Items.Add(string.Format(language.FirstPlusX, 3)); + comboBoxToolsEndSceneIndex.Items.Clear(); + comboBoxToolsEndSceneIndex.Items.Add(string.Format(language.LastMinusX, 0)); + comboBoxToolsEndSceneIndex.Items.Add(string.Format(language.LastMinusX, 1)); + comboBoxToolsEndSceneIndex.Items.Add(string.Format(language.LastMinusX, 2)); + comboBoxToolsEndSceneIndex.Items.Add(string.Format(language.LastMinusX, 3)); + int visAdjustTextMax = Math.Max(labelVerifyButton.Width, labelToolsStartScene.Width); + visAdjustTextMax = Math.Max(visAdjustTextMax, labelToolsEndScene.Width); + comboBoxToolsVerifySeconds.Left = groupBoxToolsVisualSync.Left + visAdjustTextMax + 12; + comboBoxToolsStartSceneIndex.Left = comboBoxToolsVerifySeconds.Left; + comboBoxToolsEndSceneIndex.Left = comboBoxToolsVerifySeconds.Left; + + groupBoxFixCommonErrors.Text = language.FixCommonerrors; + labelMergeShortLines.Text = language.MergeLinesShorterThan; + labelDialogStyle.Text = language.DialogStyle; + labelContinuationStyle.Text = language.ContinuationStyle; + labelToolsMusicSymbol.Text = language.MusicSymbol; + labelToolsMusicSymbolsToReplace.Text = language.MusicSymbolsReplace; + checkBoxFixCommonOcrErrorsUsingHardcodedRules.Text = language.FixCommonOcrErrorsUseHardcodedRules; + checkBoxFixShortDisplayTimesAllowMoveStartTime.Text = language.FixCommonerrorsFixShortDisplayTimesAllowMoveStartTime; + checkBoxFceSkipStep1.Text = language.FixCommonErrorsSkipStepOne; + groupBoxSpellCheck.Text = language.SpellCheck; + checkBoxSpellCheckAutoChangeNames.Text = Configuration.Settings.Language.SpellCheck.AutoFixNames; + checkBoxSpellCheckAutoChangeNamesViaSuggestions.Text = Configuration.Settings.Language.SpellCheck.AutoFixNamesViaSuggestions; + checkBoxSpellCheckOneLetterWords.Text = Configuration.Settings.Language.SpellCheck.CheckOneLetterWords; + checkBoxTreatINQuoteAsING.Text = Configuration.Settings.Language.SpellCheck.TreatINQuoteAsING; + checkBoxUseAlwaysToFile.Text = Configuration.Settings.Language.SpellCheck.RememberUseAlwaysList; + buttonFixContinuationStyleSettings.Text = language.EditFixContinuationStyleSettings; + + groupBoxToolsAutoBr.Text = Configuration.Settings.Language.Main.Controls.AutoBreak.Replace("&", string.Empty); + checkBoxUseDoNotBreakAfterList.Text = language.UseDoNotBreakAfterList; + checkBoxToolsBreakEarlyComma.Text = language.BreakEarlyForComma; + checkBoxToolsBreakEarlyDash.Text = language.BreakEarlyForDashDialog; + checkBoxToolsBreakEarlyLineEnding.Text = language.BreakEarlyForLineEnding; + checkBoxToolsBreakByPixelWidth.Text = language.BreakByPixelWidth; + checkBoxToolsBreakPreferBottomHeavy.Text = language.BreakPreferBottomHeavy; + numericUpDownToolsBreakPreferBottomHeavy.Left = checkBoxToolsBreakPreferBottomHeavy.Left + checkBoxToolsBreakPreferBottomHeavy.Width + 9; + labelToolsBreakBottomHeavyPercent.Left = numericUpDownToolsBreakPreferBottomHeavy.Left + numericUpDownToolsBreakPreferBottomHeavy.Width + 2; + checkBoxCpsIncludeWhiteSpace.Text = language.CpsIncludesSpace; + buttonEditDoNotBreakAfterList.Text = Configuration.Settings.Language.VobSubOcr.Edit; + + groupBoxGoogleTranslate.Text = language.GoogleTranslate; + labelGoogleTranslateApiKey.Text = language.GoogleTranslateApiKey; + linkLabelGoogleTranslateSignUp.Text = language.HowToSignUp; + linkLabelGoogleTranslateSignUp.Left = textBoxGoogleTransleApiKey.Left + textBoxGoogleTransleApiKey.Width - linkLabelGoogleTranslateSignUp.Width; + + groupBoxBing.Text = language.MicrosoftBingTranslator; + labelBingApiKey.Text = language.MicrosoftTranslateApiKey; + labelBingTokenEndpoint.Text = language.MicrosoftTranslateTokenEndpoint; + linkLabelBingSubscribe.Text = language.HowToSignUp; + linkLabelBingSubscribe.Left = textBoxBingClientSecret.Left + textBoxBingClientSecret.Width - linkLabelGoogleTranslateSignUp.Width; + + comboBoxListViewDoubleClickEvent.Items.Clear(); + comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewNothing); + comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewVideoGoToPositionAndPause); + comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewVideoGoToPositionAndPlay); + comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewVideoGoToPositionMinusHalfSecAndPause); + comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewVideoGoToPositionMinus1SecAndPause); + comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewVideoGoToPositionMinus1SecAndPlay); + comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewEditTextAndPause); + comboBoxListViewDoubleClickEvent.Items.Add(language.MainListViewEditText); + + comboBoxSaveAsFileNameFrom.Items.Clear(); + comboBoxSaveAsFileNameFrom.Items.Add(language.VideoFileName); + comboBoxSaveAsFileNameFrom.Items.Add(language.ExistingFileName); + + if (gs.ListViewDoubleClickAction >= 0 && gs.ListViewDoubleClickAction < comboBoxListViewDoubleClickEvent.Items.Count) + { + comboBoxListViewDoubleClickEvent.SelectedIndex = gs.ListViewDoubleClickAction; + } + + comboBoxSaveAsFileNameFrom.SelectedIndex = gs.SaveAsUseFileNameFrom.Equals("video", StringComparison.OrdinalIgnoreCase) ? 0 : 1; + + if (gs.AutoBackupSeconds == 60) + { + comboBoxAutoBackup.SelectedIndex = 1; + } + else if (gs.AutoBackupSeconds == 60 * 5) + { + comboBoxAutoBackup.SelectedIndex = 2; + } + else if (gs.AutoBackupSeconds == 60 * 15) + { + comboBoxAutoBackup.SelectedIndex = 3; + } + else + { + comboBoxAutoBackup.SelectedIndex = 0; + } + + if (gs.AutoBackupDeleteAfterMonths == 3) + { + comboBoxAutoBackupDeleteAfter.SelectedIndex = 1; + } + else if (gs.AutoBackupDeleteAfterMonths == 1) + { + comboBoxAutoBackupDeleteAfter.SelectedIndex = 0; + } + else + { + comboBoxAutoBackupDeleteAfter.SelectedIndex = 2; + } + + checkBoxCheckForUpdates.Checked = gs.CheckForUpdates; + checkBoxAutoSave.Checked = gs.AutoSave; + + comboBoxSpellChecker.SelectedIndex = gs.SpellChecker.Contains("word", StringComparison.OrdinalIgnoreCase) ? 1 : 0; + + if (Configuration.IsRunningOnLinux || Configuration.IsRunningOnMac) + { + comboBoxSpellChecker.SelectedIndex = 0; + comboBoxSpellChecker.Enabled = false; + } + + checkBoxAllowEditOfOriginalSubtitle.Checked = gs.AllowEditOfOriginalSubtitle; + checkBoxPromptDeleteLines.Checked = gs.PromptDeleteLines; + + ToolsSettings toolsSettings = Configuration.Settings.Tools; + if (toolsSettings.VerifyPlaySeconds - 2 >= 0 && toolsSettings.VerifyPlaySeconds - 2 < comboBoxToolsVerifySeconds.Items.Count) + { + comboBoxToolsVerifySeconds.SelectedIndex = toolsSettings.VerifyPlaySeconds - 2; + } + else + { + comboBoxToolsVerifySeconds.SelectedIndex = 0; + } + + if (toolsSettings.StartSceneIndex >= 0 && toolsSettings.StartSceneIndex < comboBoxToolsStartSceneIndex.Items.Count) + { + comboBoxToolsStartSceneIndex.SelectedIndex = toolsSettings.StartSceneIndex; + } + else + { + comboBoxToolsStartSceneIndex.SelectedIndex = 0; + } + + if (toolsSettings.EndSceneIndex >= 0 && toolsSettings.EndSceneIndex < comboBoxToolsEndSceneIndex.Items.Count) + { + comboBoxToolsEndSceneIndex.SelectedIndex = toolsSettings.EndSceneIndex; + } + else + { + comboBoxToolsEndSceneIndex.SelectedIndex = 0; + } + + comboBoxMergeShortLineLength.Items.Clear(); + var comboBoxMergeShortLineLengthList = new List(95); + for (int i = 5; i < 100; i++) + { + comboBoxMergeShortLineLengthList.Add(i.ToString(CultureInfo.InvariantCulture)); + } + comboBoxMergeShortLineLength.Items.AddRange(comboBoxMergeShortLineLengthList.ToArray()); + + if (gs.MergeLinesShorterThan >= 5 && gs.MergeLinesShorterThan - 5 < comboBoxMergeShortLineLength.Items.Count) + { + comboBoxMergeShortLineLength.SelectedIndex = gs.MergeLinesShorterThan - 5; + } + else + { + comboBoxMergeShortLineLength.SelectedIndex = 0; + } + + SetDialogStyle(Configuration.Settings.General.DialogStyle); + SetContinuationStyle(Configuration.Settings.General.ContinuationStyle); + + UpdateProfileNames(gs.Profiles); + + // Music notes / music symbols + if (!Utilities.IsRunningOnMono() && Environment.OSVersion.Version.Major < 6) // 6 == Vista/Win2008Server/Win7 + { + float fontSize = comboBoxToolsMusicSymbol.Font.Size; + const string unicodeFontName = Utilities.WinXP2KUnicodeFontName; + listBoxNames.Font = new Font(unicodeFontName, fontSize); + listBoxUserWordLists.Font = new Font(unicodeFontName, fontSize); + listBoxOcrFixList.Font = new Font(unicodeFontName, fontSize); + comboBoxToolsMusicSymbol.Font = new Font(unicodeFontName, fontSize); + textBoxMusicSymbolsToReplace.Font = new Font(unicodeFontName, fontSize); + textBoxNameEtc.Font = new Font(unicodeFontName, fontSize); + textBoxUserWord.Font = new Font(unicodeFontName, fontSize); + textBoxOcrFixKey.Font = new Font(unicodeFontName, fontSize); + textBoxOcrFixValue.Font = new Font(unicodeFontName, fontSize); + } + + comboBoxToolsMusicSymbol.Items.Clear(); + comboBoxToolsMusicSymbol.Items.Add("♪"); + comboBoxToolsMusicSymbol.Items.Add("♫"); + comboBoxToolsMusicSymbol.Items.Add("♪♪"); + comboBoxToolsMusicSymbol.Items.Add("*"); + comboBoxToolsMusicSymbol.Items.Add("#"); + if (toolsSettings.MusicSymbol == "♪") + { + comboBoxToolsMusicSymbol.SelectedIndex = 0; + } + else if (toolsSettings.MusicSymbol == "♫") + { + comboBoxToolsMusicSymbol.SelectedIndex = 1; + } + else if (toolsSettings.MusicSymbol == "♪♪") + { + comboBoxToolsMusicSymbol.SelectedIndex = 2; + } + else if (toolsSettings.MusicSymbol == "*") + { + comboBoxToolsMusicSymbol.SelectedIndex = 3; + } + else if (toolsSettings.MusicSymbol == "#") + { + comboBoxToolsMusicSymbol.SelectedIndex = 4; + } + else + { + comboBoxToolsMusicSymbol.Items.Add(toolsSettings.MusicSymbol); + comboBoxToolsMusicSymbol.SelectedIndex = 5; + } + + textBoxMusicSymbolsToReplace.Text = toolsSettings.MusicSymbolReplace; + checkBoxFixCommonOcrErrorsUsingHardcodedRules.Checked = toolsSettings.OcrFixUseHardcodedRules; + checkBoxFixShortDisplayTimesAllowMoveStartTime.Checked = toolsSettings.FixShortDisplayTimesAllowMoveStartTime; + checkBoxFceSkipStep1.Checked = toolsSettings.FixCommonErrorsSkipStepOne; + checkBoxSpellCheckAutoChangeNames.Checked = toolsSettings.SpellCheckAutoChangeNames; + checkBoxSpellCheckAutoChangeNamesViaSuggestions.Checked = toolsSettings.SpellCheckAutoChangeNamesUseSuggestions; + checkBoxSpellCheckOneLetterWords.Checked = toolsSettings.CheckOneLetterWords; + checkBoxTreatINQuoteAsING.Checked = toolsSettings.SpellCheckEnglishAllowInQuoteAsIng; + checkBoxUseAlwaysToFile.Checked = toolsSettings.RememberUseAlwaysList; + checkBoxUseDoNotBreakAfterList.Checked = toolsSettings.UseNoLineBreakAfter; + checkBoxToolsBreakEarlyComma.Checked = toolsSettings.AutoBreakCommaBreakEarly; + checkBoxToolsBreakEarlyDash.Checked = toolsSettings.AutoBreakDashEarly; + checkBoxToolsBreakEarlyLineEnding.Checked = toolsSettings.AutoBreakLineEndingEarly; + checkBoxToolsBreakByPixelWidth.Checked = toolsSettings.AutoBreakUsePixelWidth; + checkBoxToolsBreakPreferBottomHeavy.Checked = toolsSettings.AutoBreakPreferBottomHeavy; + numericUpDownToolsBreakPreferBottomHeavy.Value = (decimal)toolsSettings.AutoBreakPreferBottomPercent; + checkBoxCpsIncludeWhiteSpace.Checked = !Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace; + + textBoxBingClientSecret.Text = Configuration.Settings.Tools.MicrosoftTranslatorApiKey; + comboBoxBoxBingTokenEndpoint.Text = Configuration.Settings.Tools.MicrosoftTranslatorTokenEndpoint; + textBoxGoogleTransleApiKey.Text = toolsSettings.GoogleApiV2Key; + + buttonReset.Text = Configuration.Settings.Language.Settings.RestoreDefaultSettings; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + + InitComboBoxWordListLanguages(); + + checkBoxWaveformShowGrid.Checked = Configuration.Settings.VideoControls.WaveformDrawGrid; + checkBoxWaveformShowCps.Checked = Configuration.Settings.VideoControls.WaveformDrawCps; + checkBoxWaveformShowWpm.Checked = Configuration.Settings.VideoControls.WaveformDrawWpm; + panelWaveformGridColor.BackColor = Configuration.Settings.VideoControls.WaveformGridColor; + panelWaveformSelectedColor.BackColor = Configuration.Settings.VideoControls.WaveformSelectedColor; + panelWaveformColor.BackColor = Configuration.Settings.VideoControls.WaveformColor; + panelWaveformBackgroundColor.BackColor = Configuration.Settings.VideoControls.WaveformBackgroundColor; + panelWaveformTextColor.BackColor = Configuration.Settings.VideoControls.WaveformTextColor; + panelWaveformCursorColor.BackColor = Configuration.Settings.VideoControls.WaveformCursorColor; + checkBoxGenerateSpectrogram.Checked = Configuration.Settings.VideoControls.GenerateSpectrogram; + comboBoxSpectrogramAppearance.SelectedIndex = Configuration.Settings.VideoControls.SpectrogramAppearance == "OneColorGradient" ? 0 : 1; + comboBoxWaveformTextSize.Text = Configuration.Settings.VideoControls.WaveformTextSize.ToString(CultureInfo.InvariantCulture); + checkBoxWaveformTextBold.Checked = Configuration.Settings.VideoControls.WaveformTextBold; + checkBoxReverseMouseWheelScrollDirection.Checked = Configuration.Settings.VideoControls.WaveformMouseWheelScrollUpIsForward; + checkBoxAllowOverlap.Checked = Configuration.Settings.VideoControls.WaveformAllowOverlap; + checkBoxWaveformSetVideoPosMoveStartEnd.Checked = Configuration.Settings.VideoControls.WaveformSetVideoPositionOnMoveStartEnd; + checkBoxWaveformHoverFocus.Checked = Configuration.Settings.VideoControls.WaveformFocusOnMouseEnter; + checkBoxListViewMouseEnterFocus.Checked = Configuration.Settings.VideoControls.WaveformListViewFocusOnMouseEnter; + checkBoxWaveformSingleClickSelect.Checked = Configuration.Settings.VideoControls.WaveformSingleClickSelect; + checkBoxWaveformSnapToSceneChanges.Checked = Configuration.Settings.VideoControls.WaveformSnapToSceneChanges; + if (Configuration.Settings.VideoControls.WaveformBorderHitMs >= numericUpDownWaveformBorderHitMs.Minimum && + Configuration.Settings.VideoControls.WaveformBorderHitMs <= numericUpDownWaveformBorderHitMs.Maximum) + { + numericUpDownWaveformBorderHitMs.Value = Configuration.Settings.VideoControls.WaveformBorderHitMs; + } + + checkBoxUseFFmpeg.Checked = gs.UseFFmpegForWaveExtraction; + textBoxFFmpegPath.Text = gs.FFmpegLocation; + if (string.IsNullOrEmpty(textBoxFFmpegPath.Text) && Configuration.IsRunningOnWindows) + { + var guessPath = Path.Combine(Configuration.DataDirectory, "ffmpeg", "ffmpeg.exe"); + if (File.Exists(guessPath)) + { + textBoxFFmpegPath.Text = guessPath; + checkBoxUseFFmpeg.Checked = true; + } + } + + MakeShortcutsTreeView(language); + ShowShortcutsTreeView(); + toolStripMenuItemShortcutsCollapse.Text = Configuration.Settings.Language.General.Collapse; + importShortcutsToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.Import; + exportShortcutsToolStripMenuItem.Text = Configuration.Settings.Language.MultipleReplace.Export; + labelShortcutsSearch.Text = Configuration.Settings.Language.General.Search; + buttonShortcutsClear.Text = Configuration.Settings.Language.DvdSubRip.Clear; + textBoxShortcutSearch.Left = labelShortcutsSearch.Left + labelShortcutsSearch.Width + 5; + buttonShortcutsClear.Left = textBoxShortcutSearch.Left + textBoxShortcutSearch.Width + 5; + + groupBoxShortcuts.Text = language.Shortcuts; + labelShortcut.Text = language.Shortcut; + checkBoxShortcutsControl.Text = language.Control; + checkBoxShortcutsAlt.Text = language.Alt; + checkBoxShortcutsShift.Text = language.Shift; + buttonUpdateShortcut.Text = language.UpdateShortcut; + buttonClearShortcut.Text = Configuration.Settings.Language.DvdSubRip.Clear; + + labelShortcutKey.Text = language.Key; + comboBoxShortcutKey.Left = labelShortcutKey.Left + labelShortcutKey.Width; + comboBoxShortcutKey.Items[0] = Configuration.Settings.Language.General.None; + + groupBoxListViewSyntaxColoring.Text = language.ListViewSyntaxColoring; + checkBoxSyntaxColorDurationTooSmall.Text = language.SyntaxColorDurationIfTooSmall; + checkBoxSyntaxColorDurationTooLarge.Text = language.SyntaxColorDurationIfTooLarge; + checkBoxSyntaxColorTextTooLong.Text = language.SyntaxColorTextIfTooLong; + checkBoxSyntaxColorTextTooWide.Text = language.SyntaxColorTextIfTooWide; + buttonLineWidthSettings.Text = language.SyntaxLineWidthSettings; + checkBoxSyntaxColorTextMoreThanTwoLines.Text = string.Format(language.SyntaxColorTextMoreThanMaxLines, Configuration.Settings.General.MaxNumberOfLines); + checkBoxSyntaxOverlap.Text = language.SyntaxColorOverlap; + checkBoxSyntaxColorGapTooSmall.Text = language.SyntaxColorGap; + buttonListViewSyntaxColorError.Text = language.SyntaxErrorColor; + + UiUtil.FixLargeFonts(this, buttonOK); + + checkBoxShortcutsControl.Left = labelShortcut.Left + labelShortcut.Width + 9; + checkBoxShortcutsAlt.Left = checkBoxShortcutsControl.Left + checkBoxShortcutsControl.Width + 9; + checkBoxShortcutsShift.Left = checkBoxShortcutsAlt.Left + checkBoxShortcutsAlt.Width + 9; + labelShortcutKey.Left = checkBoxShortcutsShift.Left + checkBoxShortcutsShift.Width + 9; + comboBoxShortcutKey.Left = labelShortcutKey.Left + labelShortcutKey.Width + 2; + buttonUpdateShortcut.Left = comboBoxShortcutKey.Left + comboBoxShortcutKey.Width + 15; + buttonClearShortcut.Left = buttonUpdateShortcut.Left + buttonUpdateShortcut.Width + 15; + buttonLineWidthSettings.Left = checkBoxSyntaxColorTextTooWide.Left + checkBoxSyntaxColorTextTooWide.Width + 9; + + _oldVlcLocation = gs.VlcLocation; + _oldVlcLocationRelative = gs.VlcLocationRelative; + + _oldListViewShowCps = Configuration.Settings.Tools.ListViewShowColumnCharsPerSec; + _oldListViewShowWpm = Configuration.Settings.Tools.ListViewShowColumnWordsPerMin; + + labelPlatform.Text = (IntPtr.Size * 8) + "-bit"; + + _loading = false; + UpdateSsaExample(); + } + + private void SetDialogStyle(DialogType dialogStyle) + { + comboBoxDialogStyle.Items.Clear(); + comboBoxDialogStyle.Items.Add(Configuration.Settings.Language.Settings.DialogStyleDashBothLinesWithSpace); + comboBoxDialogStyle.Items.Add(Configuration.Settings.Language.Settings.DialogStyleDashBothLinesWithoutSpace); + comboBoxDialogStyle.Items.Add(Configuration.Settings.Language.Settings.DialogStyleDashSecondLineWithSpace); + comboBoxDialogStyle.Items.Add(Configuration.Settings.Language.Settings.DialogStyleDashSecondLineWithoutSpace); + comboBoxDialogStyle.SelectedIndex = 0; + switch (dialogStyle) + { + case DialogType.DashBothLinesWithSpace: + comboBoxDialogStyle.SelectedIndex = 0; + break; + case DialogType.DashBothLinesWithoutSpace: + comboBoxDialogStyle.SelectedIndex = 1; + break; + case DialogType.DashSecondLineWithSpace: + comboBoxDialogStyle.SelectedIndex = 2; + break; + case DialogType.DashSecondLineWithoutSpace: + comboBoxDialogStyle.SelectedIndex = 3; + break; + } + } + + private void SetContinuationStyle(ContinuationStyle continuationStyle) + { + comboBoxContinuationStyle.Items.Clear(); + comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleNone); + comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleNoneTrailingDots); + comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleNoneLeadingTrailingDots); + comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleOnlyTrailingDots); + comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleLeadingTrailingDots); + comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleLeadingTrailingDash); + comboBoxContinuationStyle.Items.Add(Configuration.Settings.Language.Settings.ContinuationStyleLeadingTrailingDashDots); + comboBoxContinuationStyle.SelectedIndex = 0; + toolTipContinuationPreview.RemoveAll(); + toolTipContinuationPreview.SetToolTip(comboBoxContinuationStyle, ContinuationUtilities.GetContinuationStylePreview(continuationStyle)); + comboBoxContinuationStyle.SelectedIndex = ContinuationUtilities.GetIndexFromContinuationStyle(continuationStyle); + + var dropDownContinuationWidth = comboBoxContinuationStyle.Width; + var dropDownDialogStyleWidth = comboBoxDialogStyle.Width; + using (var g = Graphics.FromHwnd(IntPtr.Zero)) + { + foreach (var item in comboBoxContinuationStyle.Items) + { + var itemWidth = (int)g.MeasureString((string)item, Font).Width + 5; + dropDownContinuationWidth = Math.Max(itemWidth, dropDownContinuationWidth); + } + + foreach (var item in comboBoxDialogStyle.Items) + { + var itemWidth = (int)g.MeasureString((string)item, Font).Width + 5; + dropDownDialogStyleWidth = Math.Max(itemWidth, dropDownDialogStyleWidth); + } + } + + comboBoxContinuationStyle.DropDownWidth = dropDownContinuationWidth; + comboBoxDialogStyle.DropDownWidth = dropDownDialogStyleWidth; + } + + private Guid _oldProfileId = Guid.Empty; + private void UpdateProfileNames(List profiles) + { + comboBoxRulesProfileName.BeginUpdate(); + comboBoxRulesProfileName.Items.Clear(); + foreach (var profile in profiles) + { + comboBoxRulesProfileName.Items.Add(profile.Name); + if (_oldProfileId == Guid.Empty && profile.Name == Configuration.Settings.General.CurrentProfile || profile.Id == _oldProfileId) + { + comboBoxRulesProfileName.SelectedIndex = comboBoxRulesProfileName.Items.Count - 1; + _oldProfileId = profile.Id; + } + } + comboBoxRulesProfileName.EndUpdate(); + if (comboBoxRulesProfileName.SelectedIndex < 0 && comboBoxRulesProfileName.Items.Count > 0 && comboBoxRulesProfileName.Items.Count > 0) + { + comboBoxRulesProfileName.SelectedIndex = 0; + } + } + + ShortcutNode _shortcuts = new ShortcutNode("root"); + + private void MakeShortcutsTreeView(LanguageStructure.Settings language) + { + _shortcuts = new ShortcutNode("root"); + + var generalNode = new ShortcutNode(Configuration.Settings.Language.General.GeneralText); + AddNode(generalNode, language.MergeSelectedLines, nameof(Configuration.Settings.Shortcuts.GeneralMergeSelectedLines)); + AddNode(generalNode, language.MergeWithPrevious, nameof(Configuration.Settings.Shortcuts.GeneralMergeWithPrevious)); + AddNode(generalNode, language.MergeWithNext, nameof(Configuration.Settings.Shortcuts.GeneralMergeWithNext)); + AddNode(generalNode, language.MergeSelectedLinesAndAutoBreak, nameof(Configuration.Settings.Shortcuts.GeneralMergeSelectedLinesAndAutoBreak)); + AddNode(generalNode, language.MergeSelectedLinesAndUnbreak, nameof(Configuration.Settings.Shortcuts.GeneralMergeSelectedLinesAndUnbreak)); + AddNode(generalNode, language.MergeSelectedLinesAndUnbreakCjk, nameof(Configuration.Settings.Shortcuts.GeneralMergeSelectedLinesAndUnbreakCjk)); + AddNode(generalNode, language.MergeSelectedLinesOnlyFirstText, nameof(Configuration.Settings.Shortcuts.GeneralMergeSelectedLinesOnlyFirstText)); + AddNode(generalNode, language.MergeSelectedLinesBilingual, nameof(Configuration.Settings.Shortcuts.GeneralMergeSelectedLinesBilingual)); + AddNode(generalNode, language.MergeOriginalAndTranslation, nameof(Configuration.Settings.Shortcuts.GeneralMergeOriginalAndTranslation)); + AddNode(generalNode, language.ToggleTranslationMode, nameof(Configuration.Settings.Shortcuts.GeneralToggleTranslationMode)); + AddNode(generalNode, language.SwitchOriginalAndTranslation, nameof(Configuration.Settings.Shortcuts.GeneralSwitchOriginalAndTranslation)); + AddNode(generalNode, language.WaveformPlayFirstSelectedSubtitle, nameof(Configuration.Settings.Shortcuts.GeneralPlayFirstSelected)); + AddNode(generalNode, language.GoToFirstSelectedLine, nameof(Configuration.Settings.Shortcuts.GeneralGoToFirstSelectedLine)); + AddNode(generalNode, language.GoToNextEmptyLine, nameof(Configuration.Settings.Shortcuts.GeneralGoToNextEmptyLine)); + AddNode(generalNode, language.GoToNext, nameof(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle)); + AddNode(generalNode, language.GoToNextCursorAtEnd, nameof(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitleCursorAtEnd)); + AddNode(generalNode, language.GoToPrevious, nameof(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle)); + AddNode(generalNode, language.GoToCurrentSubtitleStart, nameof(Configuration.Settings.Shortcuts.GeneralGoToStartOfCurrentSubtitle)); + AddNode(generalNode, language.GoToCurrentSubtitleEnd, nameof(Configuration.Settings.Shortcuts.GeneralGoToEndOfCurrentSubtitle)); + AddNode(generalNode, language.GoToPreviousSubtitleAndFocusVideo, nameof(Configuration.Settings.Shortcuts.GeneralGoToPreviousSubtitleAndFocusVideo)); + AddNode(generalNode, language.GoToNextSubtitleAndFocusVideo, nameof(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitleAndFocusVideo)); + AddNode(generalNode, language.GoToPrevSubtitleAndPlay, nameof(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitleAndPlay)); + AddNode(generalNode, language.GoToNextSubtitleAndPlay, nameof(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitleAndPlay)); + AddNode(generalNode, language.Help, nameof(Configuration.Settings.Shortcuts.GeneralHelp), true); + AddNode(generalNode, language.UnbreakNoSpace, nameof(Configuration.Settings.Shortcuts.GeneralUnbrekNoSpace)); + AddNode(generalNode, language.ToggleBookmarks, nameof(Configuration.Settings.Shortcuts.GeneralToggleBookmarks)); + AddNode(generalNode, language.ToggleBookmarksWithComment, nameof(Configuration.Settings.Shortcuts.GeneralToggleBookmarksWithText), true); + AddNode(generalNode, language.ClearBookmarks, nameof(Configuration.Settings.Shortcuts.GeneralClearBookmarks)); + AddNode(generalNode, language.GoToBookmark, nameof(Configuration.Settings.Shortcuts.GeneralGoToBookmark)); + AddNode(generalNode, language.GoToPreviousBookmark, nameof(Configuration.Settings.Shortcuts.GeneralGoToPreviousBookmark)); + AddNode(generalNode, language.GoToNextBookmark, nameof(Configuration.Settings.Shortcuts.GeneralGoToNextBookmark)); + AddNode(generalNode, language.ChooseProfile, nameof(Configuration.Settings.Shortcuts.ChooseProfile)); + AddNode(generalNode, language.DuplicateLine, nameof(Configuration.Settings.Shortcuts.DuplicateLine)); + if (generalNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(generalNode); + } + + var fileNode = new ShortcutNode(Configuration.Settings.Language.Main.Menu.File.Title); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.New, nameof(Configuration.Settings.Shortcuts.MainFileNew), true); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.Open, nameof(Configuration.Settings.Shortcuts.MainFileOpen), true); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.OpenKeepVideo, nameof(Configuration.Settings.Shortcuts.MainFileOpenKeepVideo), true); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.Save, nameof(Configuration.Settings.Shortcuts.MainFileSave), true); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.SaveAs, nameof(Configuration.Settings.Shortcuts.MainFileSaveAs), true); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.SaveOriginal, nameof(Configuration.Settings.Shortcuts.MainFileSaveOriginal), true); + AddNode(fileNode, Configuration.Settings.Language.Main.SaveOriginalSubtitleAs, nameof(Configuration.Settings.Shortcuts.MainFileSaveOriginalAs), true); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.OpenOriginal, nameof(Configuration.Settings.Shortcuts.MainFileOpenOriginal), true); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.CloseOriginal, nameof(Configuration.Settings.Shortcuts.MainFileCloseOriginal), true); + AddNode(fileNode, language.MainFileSaveAll, nameof(Configuration.Settings.Shortcuts.MainFileSaveAll)); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.Compare, nameof(Configuration.Settings.Shortcuts.MainFileCompare), true); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.ImportText, nameof(Configuration.Settings.Shortcuts.MainFileImportPlainText), true); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.ImportTimecodes, nameof(Configuration.Settings.Shortcuts.MainFileImportTimeCodes), true); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.Export + " -> " + Configuration.Settings.Language.Main.Menu.File.ExportEbu, nameof(Configuration.Settings.Shortcuts.MainFileExportEbu), true); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.Export + " -> " + Configuration.Settings.Language.Main.Menu.File.ExportPac, nameof(Configuration.Settings.Shortcuts.MainFileExportPac), true); + AddNode(fileNode, Configuration.Settings.Language.Main.Menu.File.Export + " -> " + Configuration.Settings.Language.Main.Menu.File.ExportPlainText, nameof(Configuration.Settings.Shortcuts.MainFileExportPlainText), true); + if (fileNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(fileNode); + } + + var editNode = new ShortcutNode(Configuration.Settings.Language.Main.Menu.Edit.Title); + AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.Undo, nameof(Configuration.Settings.Shortcuts.MainEditUndo), true); + AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.Redo, nameof(Configuration.Settings.Shortcuts.MainEditRedo), true); + AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.Find, nameof(Configuration.Settings.Shortcuts.MainEditFind), true); + AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.FindNext, nameof(Configuration.Settings.Shortcuts.MainEditFindNext), true); + AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.Replace, nameof(Configuration.Settings.Shortcuts.MainEditReplace), true); + AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.MultipleReplace, nameof(Configuration.Settings.Shortcuts.MainEditMultipleReplace), true); + AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.ModifySelection, nameof(Configuration.Settings.Shortcuts.MainEditModifySelection), true); + AddNode(editNode, Configuration.Settings.Language.Main.Menu.Edit.GoToSubtitleNumber, nameof(Configuration.Settings.Shortcuts.MainEditGoToLineNumber), true); + AddNode(editNode, Configuration.Settings.Language.VobSubOcr.RightToLeft, nameof(Configuration.Settings.Shortcuts.MainEditRightToLeft), true); + AddNode(editNode, language.FixRTLViaUnicodeChars, nameof(Configuration.Settings.Shortcuts.MainEditFixRTLViaUnicodeChars), true); + AddNode(editNode, language.RemoveRTLUnicodeChars, nameof(Configuration.Settings.Shortcuts.MainEditRemoveRTLUnicodeChars), true); + AddNode(editNode, language.ReverseStartAndEndingForRtl, nameof(Configuration.Settings.Shortcuts.MainEditReverseStartAndEndingForRTL), true); + AddNode(editNode, language.ToggleTranslationAndOriginalInPreviews, nameof(Configuration.Settings.Shortcuts.MainEditToggleTranslationOriginalInPreviews), true); + if (editNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(editNode); + } + + var toolsNode = new ShortcutNode(Configuration.Settings.Language.Main.Menu.Tools.Title); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.SubtitlesBridgeGaps, nameof(Configuration.Settings.Shortcuts.MainToolsDurationsBridgeGap), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.MinimumDisplayTimeBetweenParagraphs, nameof(Configuration.Settings.Shortcuts.MainToolsMinimumDisplayTimeBetweenParagraphs), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.FixCommonErrors, nameof(Configuration.Settings.Shortcuts.MainToolsFixCommonErrors), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.StartNumberingFrom, nameof(Configuration.Settings.Shortcuts.MainToolsRenumber), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.RemoveTextForHearingImpaired, nameof(Configuration.Settings.Shortcuts.MainToolsRemoveTextForHI), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.ChangeCasing, nameof(Configuration.Settings.Shortcuts.MainToolsChangeCasing), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.MakeNewEmptyTranslationFromCurrentSubtitle, nameof(Configuration.Settings.Shortcuts.MainToolsMakeEmptyFromCurrent), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.MergeShortLines, nameof(Configuration.Settings.Shortcuts.MainToolsMergeShortLines), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.MergeDuplicateText, nameof(Configuration.Settings.Shortcuts.MainToolsMergeDuplicateText), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.MergeSameTimeCodes, nameof(Configuration.Settings.Shortcuts.MainToolsMergeSameTimeCodes), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.SplitLongLines, nameof(Configuration.Settings.Shortcuts.MainToolsSplitLongLines), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.BatchConvert, nameof(Configuration.Settings.Shortcuts.MainToolsBatchConvert)); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.MeasurementConverter, nameof(Configuration.Settings.Shortcuts.MainToolsMeasurementConverter), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.SplitSubtitle, nameof(Configuration.Settings.Shortcuts.MainToolsSplit), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.AppendSubtitle, nameof(Configuration.Settings.Shortcuts.MainToolsAppend), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.Tools.JoinSubtitles, nameof(Configuration.Settings.Shortcuts.MainToolsJoin), true); + AddNode(toolsNode, Configuration.Settings.Language.Main.Menu.ContextMenu.AutoDurationCurrentLine, nameof(Configuration.Settings.Shortcuts.MainToolsAutoDuration)); + AddNode(toolsNode, language.ShowBeamer, nameof(Configuration.Settings.Shortcuts.MainToolsBeamer)); + if (toolsNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(toolsNode); + } + + var videoNode = new ShortcutNode(Configuration.Settings.Language.Main.Menu.Video.Title); + AddNode(videoNode, Configuration.Settings.Language.Main.Menu.Video.OpenVideo, nameof(Configuration.Settings.Shortcuts.MainVideoOpen), true); + AddNode(videoNode, Configuration.Settings.Language.Main.Menu.Video.CloseVideo, nameof(Configuration.Settings.Shortcuts.MainVideoClose), true); + AddNode(videoNode, language.TogglePlayPause, nameof(Configuration.Settings.Shortcuts.MainVideoPlayPauseToggle)); + AddNode(videoNode, language.Pause, nameof(Configuration.Settings.Shortcuts.MainVideoPause)); + AddNode(videoNode, Configuration.Settings.Language.Main.VideoControls.PlayFromJustBeforeText, nameof(Configuration.Settings.Shortcuts.MainVideoPlayFromJustBefore)); + AddNode(videoNode, Configuration.Settings.Language.Main.Menu.Video.ShowHideVideo, nameof(Configuration.Settings.Shortcuts.MainVideoShowHideVideo), true); + AddNode(videoNode, language.FoucsSetVideoPosition, nameof(Configuration.Settings.Shortcuts.MainVideoFoucsSetVideoPosition)); + AddNode(videoNode, language.ToggleDockUndockOfVideoControls, nameof(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls), true); + AddNode(videoNode, language.GoBack1Frame, nameof(Configuration.Settings.Shortcuts.MainVideo1FrameLeft)); + AddNode(videoNode, language.GoForward1Frame, nameof(Configuration.Settings.Shortcuts.MainVideo1FrameRight)); + AddNode(videoNode, language.GoBack1FrameWithPlay, nameof(Configuration.Settings.Shortcuts.MainVideo1FrameLeftWithPlay)); + AddNode(videoNode, language.GoForward1FrameWithPlay, nameof(Configuration.Settings.Shortcuts.MainVideo1FrameRightWithPlay)); + AddNode(videoNode, language.GoBack100Milliseconds, nameof(Configuration.Settings.Shortcuts.MainVideo100MsLeft)); + AddNode(videoNode, language.GoForward100Milliseconds, nameof(Configuration.Settings.Shortcuts.MainVideo100MsRight)); + AddNode(videoNode, language.GoBack500Milliseconds, nameof(Configuration.Settings.Shortcuts.MainVideo500MsLeft)); + AddNode(videoNode, language.GoForward500Milliseconds, nameof(Configuration.Settings.Shortcuts.MainVideo500MsRight)); + AddNode(videoNode, language.GoBack1Second, nameof(Configuration.Settings.Shortcuts.MainVideo1000MsLeft)); + AddNode(videoNode, language.GoForward1Second, nameof(Configuration.Settings.Shortcuts.MainVideo1000MsRight)); + AddNode(videoNode, language.GoBack5Seconds, nameof(Configuration.Settings.Shortcuts.MainVideo5000MsLeft)); + AddNode(videoNode, language.GoForward5Seconds, nameof(Configuration.Settings.Shortcuts.MainVideo5000MsRight)); + AddNode(videoNode, language.GoBackXSSeconds, nameof(Configuration.Settings.Shortcuts.MainVideoXSMsLeft)); + AddNode(videoNode, language.GoForwardXSSeconds, nameof(Configuration.Settings.Shortcuts.MainVideoXSMsRight)); + AddNode(videoNode, language.GoBackXLSeconds, nameof(Configuration.Settings.Shortcuts.MainVideoXLMsLeft)); + AddNode(videoNode, language.GoForwardXLSeconds, nameof(Configuration.Settings.Shortcuts.MainVideoXLMsRight)); + AddNode(videoNode, language.GoBack3Second, nameof(Configuration.Settings.Shortcuts.MainVideo3000MsLeft)); + AddNode(videoNode, language.GoToStartCurrent, nameof(Configuration.Settings.Shortcuts.MainVideoGoToStartCurrent)); + AddNode(videoNode, language.ToggleStartEndCurrent, nameof(Configuration.Settings.Shortcuts.MainVideoToggleStartEndCurrent)); + AddNode(videoNode, language.PlayCurrent, nameof(Configuration.Settings.Shortcuts.MainVideoPlayCurrent)); + AddNode(videoNode, language.WaveformGoToPrevSubtitle, nameof(Configuration.Settings.Shortcuts.MainVideoGoToPrevSubtitle)); + AddNode(videoNode, language.WaveformGoToNextSubtitle, nameof(Configuration.Settings.Shortcuts.MainVideoGoToNextSubtitle)); + AddNode(videoNode, language.WaveformGoToPrevChapter, nameof(Configuration.Settings.Shortcuts.MainVideoGoToPrevChapter)); + AddNode(videoNode, language.WaveformGoToNextChapter, nameof(Configuration.Settings.Shortcuts.MainVideoGoToNextChapter)); + AddNode(videoNode, language.WaveformSelectNextSubtitle, nameof(Configuration.Settings.Shortcuts.MainVideoSelectNextSubtitle)); + AddNode(videoNode, language.Fullscreen, nameof(Configuration.Settings.Shortcuts.MainVideoFullscreen)); + AddNode(videoNode, language.PlayRateSlower, nameof(Configuration.Settings.Shortcuts.MainVideoSlower)); + AddNode(videoNode, language.PlayRateFaster, nameof(Configuration.Settings.Shortcuts.MainVideoFaster)); + AddNode(videoNode, language.VideoResetSpeedAndZoom, nameof(Configuration.Settings.Shortcuts.MainVideoReset)); + if (videoNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(videoNode); + } + + var spellCheckNode = new ShortcutNode(Configuration.Settings.Language.Main.Menu.SpellCheck.Title); + AddNode(spellCheckNode, Configuration.Settings.Language.Main.Menu.SpellCheck.Title, nameof(Configuration.Settings.Shortcuts.MainSpellCheck), true); + AddNode(spellCheckNode, Configuration.Settings.Language.Main.Menu.SpellCheck.FindDoubleWords, nameof(Configuration.Settings.Shortcuts.MainSpellCheckFindDoubleWords), true); + AddNode(spellCheckNode, Configuration.Settings.Language.Main.Menu.SpellCheck.AddToNameList, nameof(Configuration.Settings.Shortcuts.MainSpellCheckAddWordToNames), true); + if (spellCheckNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(spellCheckNode); + } + + var syncNode = new ShortcutNode(Configuration.Settings.Language.Main.Menu.Synchronization.Title); + AddNode(syncNode, Configuration.Settings.Language.Main.Menu.Synchronization.AdjustAllTimes, nameof(Configuration.Settings.Shortcuts.MainSynchronizationAdjustTimes), true); + AddNode(syncNode, Configuration.Settings.Language.Main.Menu.Synchronization.VisualSync, nameof(Configuration.Settings.Shortcuts.MainSynchronizationVisualSync), true); + AddNode(syncNode, Configuration.Settings.Language.Main.Menu.Synchronization.PointSync, nameof(Configuration.Settings.Shortcuts.MainSynchronizationPointSync), true); + AddNode(syncNode, Configuration.Settings.Language.Main.Menu.Synchronization.PointSyncViaOtherSubtitle, nameof(Configuration.Settings.Shortcuts.MainSynchronizationPointSyncViaFile), true); + AddNode(syncNode, Configuration.Settings.Language.Main.Menu.Tools.ChangeFrameRate, nameof(Configuration.Settings.Shortcuts.MainSynchronizationChangeFrameRate), true); + if (syncNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(syncNode); + } + + var listViewAndTextBoxNode = new ShortcutNode(language.ListViewAndTextBox); + AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.InsertAfter, nameof(Configuration.Settings.Shortcuts.MainInsertAfter)); + AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.InsertBefore, nameof(Configuration.Settings.Shortcuts.MainInsertBefore)); + AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.General.Italic, nameof(Configuration.Settings.Shortcuts.MainListViewItalic), true); + AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.General.Bold, nameof(Configuration.Settings.Shortcuts.MainListViewBold), true); + AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.General.Underline, nameof(Configuration.Settings.Shortcuts.MainListViewUnderline), true); + AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.Box, nameof(Configuration.Settings.Shortcuts.MainListViewBox), true); + AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.General.SplitLine.Replace("!", string.Empty), nameof(Configuration.Settings.Shortcuts.MainListViewSplit), true); + AddNode(listViewAndTextBoxNode, language.ToggleMusicSymbols, nameof(Configuration.Settings.Shortcuts.MainListViewToggleMusicSymbols), true); + AddNode(listViewAndTextBoxNode, language.AlignmentN1, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN1)); + AddNode(listViewAndTextBoxNode, language.AlignmentN2, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN2)); + AddNode(listViewAndTextBoxNode, language.AlignmentN3, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN3)); + AddNode(listViewAndTextBoxNode, language.AlignmentN4, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN4)); + AddNode(listViewAndTextBoxNode, language.AlignmentN5, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN5)); + AddNode(listViewAndTextBoxNode, language.AlignmentN6, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN6)); + AddNode(listViewAndTextBoxNode, language.AlignmentN7, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN7)); + AddNode(listViewAndTextBoxNode, language.AlignmentN8, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN8)); + AddNode(listViewAndTextBoxNode, language.AlignmentN9, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN9)); + AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.RemoveFormattingAll, nameof(Configuration.Settings.Shortcuts.MainRemoveFormatting), true); + AddNode(listViewAndTextBoxNode, language.RemoveTimeCodes, nameof(Configuration.Settings.Shortcuts.MainListViewRemoveTimeCodes)); + if (listViewAndTextBoxNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(listViewAndTextBoxNode); + } + + var listViewNode = new ShortcutNode(Configuration.Settings.Language.Main.Controls.ListView); + AddNode(listViewNode, language.MergeDialog, nameof(Configuration.Settings.Shortcuts.MainMergeDialog)); + AddNode(listViewNode, language.ToggleFocus, nameof(Configuration.Settings.Shortcuts.MainToggleFocus)); + AddNode(listViewNode, language.ToggleDialogDashes, nameof(Configuration.Settings.Shortcuts.MainListViewToggleDashes)); + AddNode(listViewNode, language.Alignment, nameof(Configuration.Settings.Shortcuts.MainListViewAlignment), true); + AddNode(listViewNode, language.CopyTextOnly, nameof(Configuration.Settings.Shortcuts.MainListViewCopyText)); + AddNode(listViewNode, language.CopyTextOnlyFromOriginalToCurrent, nameof(Configuration.Settings.Shortcuts.MainListViewCopyTextFromOriginalToCurrent), true); + AddNode(listViewNode, language.AutoDurationSelectedLines, nameof(Configuration.Settings.Shortcuts.MainListViewAutoDuration)); + AddNode(listViewNode, language.ListViewColumnDelete, nameof(Configuration.Settings.Shortcuts.MainListViewColumnDeleteText), true); + AddNode(listViewNode, language.ListViewColumnDeleteAndShiftUp, nameof(Configuration.Settings.Shortcuts.MainListViewColumnDeleteTextAndShiftUp), true); + AddNode(listViewNode, language.ListViewColumnInsert, nameof(Configuration.Settings.Shortcuts.MainListViewColumnInsertText), true); + AddNode(listViewNode, language.ListViewColumnPaste, nameof(Configuration.Settings.Shortcuts.MainListViewColumnPaste), true); + AddNode(listViewNode, language.ListViewColumnTextUp, nameof(Configuration.Settings.Shortcuts.MainListViewColumnTextUp), true); + AddNode(listViewNode, language.ListViewColumnTextDown, nameof(Configuration.Settings.Shortcuts.MainListViewColumnTextDown), true); + AddNode(listViewNode, language.ListViewFocusWaveform, nameof(Configuration.Settings.Shortcuts.MainListViewFocusWaveform)); + AddNode(listViewNode, language.ListViewGoToNextError, nameof(Configuration.Settings.Shortcuts.MainListViewGoToNextError)); + if (listViewNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(listViewNode); + } + + var textBoxNode = new ShortcutNode(language.TextBox); + AddNode(textBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.SplitLineAtCursorPosition, nameof(Configuration.Settings.Shortcuts.MainTextBoxSplitAtCursor)); + AddNode(textBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.SplitLineAtCursorAndWaveformPosition, nameof(Configuration.Settings.Shortcuts.MainTextBoxSplitAtCursorAndVideoPos)); + AddNode(textBoxNode, language.SplitSelectedLineBilingual, nameof(Configuration.Settings.Shortcuts.MainTextBoxSplitSelectedLineBilingual)); + AddNode(textBoxNode, language.MainTextBoxMoveLastWordDown, nameof(Configuration.Settings.Shortcuts.MainTextBoxMoveLastWordDown)); + AddNode(textBoxNode, language.MainTextBoxMoveFirstWordFromNextUp, nameof(Configuration.Settings.Shortcuts.MainTextBoxMoveFirstWordFromNextUp)); + AddNode(textBoxNode, language.MainTextBoxMoveLastWordDownCurrent, nameof(Configuration.Settings.Shortcuts.MainTextBoxMoveLastWordDownCurrent)); + AddNode(textBoxNode, language.MainTextBoxMoveFirstWordUpCurrent, nameof(Configuration.Settings.Shortcuts.MainTextBoxMoveFirstWordUpCurrent)); + AddNode(textBoxNode, language.MainTextBoxSelectionToLower, nameof(Configuration.Settings.Shortcuts.MainTextBoxSelectionToLower)); + AddNode(textBoxNode, language.MainTextBoxSelectionToUpper, nameof(Configuration.Settings.Shortcuts.MainTextBoxSelectionToUpper)); + AddNode(textBoxNode, language.MainTextBoxSelectionToggleCasing, nameof(Configuration.Settings.Shortcuts.MainTextBoxSelectionToggleCasing)); + AddNode(textBoxNode, language.MainTextBoxSelectionToRuby, nameof(Configuration.Settings.Shortcuts.MainTextBoxSelectionToRuby), true); + AddNode(textBoxNode, language.MainTextBoxToggleAutoDuration, nameof(Configuration.Settings.Shortcuts.MainTextBoxToggleAutoDuration)); + AddNode(textBoxNode, language.MainTextBoxAutoBreak, nameof(Configuration.Settings.Shortcuts.MainTextBoxAutoBreak)); + AddNode(textBoxNode, language.MainTextBoxAutoBreakFromPos, nameof(Configuration.Settings.Shortcuts.MainTextBoxBreakAtPosition)); + AddNode(textBoxNode, language.MainTextBoxAutoBreakFromPosAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainTextBoxBreakAtPositionAndGoToNext)); + AddNode(textBoxNode, language.MainTextBoxUnbreak, nameof(Configuration.Settings.Shortcuts.MainTextBoxUnbreak)); + if (textBoxNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(textBoxNode); + } + + var translateNode = new ShortcutNode(Configuration.Settings.Language.Main.VideoControls.Translate); + AddNode(translateNode, Configuration.Settings.Language.Main.VideoControls.GoogleIt, nameof(Configuration.Settings.Shortcuts.MainTranslateGoogleIt)); + AddNode(translateNode, Configuration.Settings.Language.Main.VideoControls.GoogleTranslate, nameof(Configuration.Settings.Shortcuts.MainTranslateGoogleTranslate), true); + AddNode(translateNode, language.CustomSearch1, nameof(Configuration.Settings.Shortcuts.MainTranslateCustomSearch1)); + AddNode(translateNode, language.CustomSearch2, nameof(Configuration.Settings.Shortcuts.MainTranslateCustomSearch2)); + AddNode(translateNode, language.CustomSearch3, nameof(Configuration.Settings.Shortcuts.MainTranslateCustomSearch3)); + AddNode(translateNode, language.CustomSearch4, nameof(Configuration.Settings.Shortcuts.MainTranslateCustomSearch4)); + AddNode(translateNode, language.CustomSearch5, nameof(Configuration.Settings.Shortcuts.MainTranslateCustomSearch5)); + if (translateNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(translateNode); + } + + var createAndAdjustNode = new ShortcutNode(Configuration.Settings.Language.Main.VideoControls.CreateAndAdjust); + AddNode(createAndAdjustNode, Configuration.Settings.Language.Main.VideoControls.InsertNewSubtitleAtVideoPosition, nameof(Configuration.Settings.Shortcuts.MainCreateInsertSubAtVideoPos)); + AddNode(createAndAdjustNode, Configuration.Settings.Language.Main.VideoControls.InsertNewSubtitleAtVideoPositionNoTextBoxFocus, nameof(Configuration.Settings.Shortcuts.MainCreateInsertSubAtVideoPosNoTextBoxFocus)); + AddNode(createAndAdjustNode, language.MainCreateStartDownEndUp, nameof(Configuration.Settings.Shortcuts.MainCreateStartDownEndUp)); + AddNode(createAndAdjustNode, Configuration.Settings.Language.Main.VideoControls.SetStartTime, nameof(Configuration.Settings.Shortcuts.MainCreateSetStart)); + AddNode(createAndAdjustNode, language.AdjustSetStartTimeKeepDuration, nameof(Configuration.Settings.Shortcuts.MainAdjustSetStartKeepDuration)); + AddNode(createAndAdjustNode, Configuration.Settings.Language.Main.VideoControls.SetstartTimeAndOffsetOfRest, nameof(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest)); + AddNode(createAndAdjustNode, Configuration.Settings.Language.Main.VideoControls.SetstartTimeAndOffsetOfRest, nameof(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest2)); + AddNode(createAndAdjustNode, language.AdjustSetStartAutoDurationAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustSetStartAutoDurationAndGoToNext)); + AddNode(createAndAdjustNode, language.AdjustStartDownEndUpAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustStartDownEndUpAndGoToNext)); + AddNode(createAndAdjustNode, language.AdjustSetStartAndEndOfPrevious, nameof(Configuration.Settings.Shortcuts.MainAdjustSetStartAndEndOfPrevious)); + AddNode(createAndAdjustNode, language.AdjustSetStartAndEndOfPreviousAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustSetStartAndEndOfPreviousAndGoToNext)); + AddNode(createAndAdjustNode, Configuration.Settings.Language.Main.VideoControls.SetEndTime, nameof(Configuration.Settings.Shortcuts.MainCreateSetEnd)); + AddNode(createAndAdjustNode, language.AdjustSetEndTimeAndPause, nameof(Configuration.Settings.Shortcuts.MainAdjustSetEndAndPause)); + AddNode(createAndAdjustNode, language.CreateSetEndAddNewAndGoToNew, nameof(Configuration.Settings.Shortcuts.MainCreateSetEndAddNewAndGoToNew)); + AddNode(createAndAdjustNode, language.AdjustSetEndTimeAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustSetEndAndGotoNext)); + AddNode(createAndAdjustNode, language.AdjustSetEndAndOffsetTheRest, nameof(Configuration.Settings.Shortcuts.MainAdjustSetEndAndOffsetTheRest)); + AddNode(createAndAdjustNode, language.AdjustSetEndAndOffsetTheRestAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustSetEndAndOffsetTheRestAndGoToNext)); + AddNode(createAndAdjustNode, language.AdjustSetEndNextStartAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustSetEndNextStartAndGoToNext)); + AddNode(createAndAdjustNode, language.AdjustViaEndAutoStart, nameof(Configuration.Settings.Shortcuts.MainAdjustViaEndAutoStart)); + AddNode(createAndAdjustNode, language.AdjustViaEndAutoStartAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustViaEndAutoStartAndGoToNext)); + AddNode(createAndAdjustNode, language.AdjustSelected100MsBack, nameof(Configuration.Settings.Shortcuts.MainAdjustSelected100MsBack)); + AddNode(createAndAdjustNode, language.AdjustSelected100MsForward, nameof(Configuration.Settings.Shortcuts.MainAdjustSelected100MsForward)); + AddNode(createAndAdjustNode, string.Format(language.AdjustStartXMsBack, Configuration.Settings.Tools.MoveStartEndMs), nameof(Configuration.Settings.Shortcuts.MainAdjustStartXMsBack)); + AddNode(createAndAdjustNode, string.Format(language.AdjustStartXMsForward, Configuration.Settings.Tools.MoveStartEndMs), nameof(Configuration.Settings.Shortcuts.MainAdjustStartXMsForward)); + AddNode(createAndAdjustNode, string.Format(language.AdjustEndXMsBack, Configuration.Settings.Tools.MoveStartEndMs), nameof(Configuration.Settings.Shortcuts.MainAdjustEndXMsBack)); + AddNode(createAndAdjustNode, string.Format(language.AdjustEndXMsForward, Configuration.Settings.Tools.MoveStartEndMs), nameof(Configuration.Settings.Shortcuts.MainAdjustEndXMsForward)); + AddNode(createAndAdjustNode, language.AdjustStartOneFrameBack, nameof(Configuration.Settings.Shortcuts.MoveStartOneFrameBack)); + AddNode(createAndAdjustNode, language.AdjustStartOneFrameForward, nameof(Configuration.Settings.Shortcuts.MoveStartOneFrameForward)); + AddNode(createAndAdjustNode, language.AdjustEndOneFrameBack, nameof(Configuration.Settings.Shortcuts.MoveEndOneFrameBack)); + AddNode(createAndAdjustNode, language.AdjustEndOneFrameForward, nameof(Configuration.Settings.Shortcuts.MoveEndOneFrameForward)); + AddNode(createAndAdjustNode, language.AdjustStartOneFrameBackKeepGapPrev, nameof(Configuration.Settings.Shortcuts.MoveStartOneFrameBackKeepGapPrev)); + AddNode(createAndAdjustNode, language.AdjustStartOneFrameForwardKeepGapPrev, nameof(Configuration.Settings.Shortcuts.MoveStartOneFrameForwardKeepGapPrev)); + AddNode(createAndAdjustNode, language.AdjustEndOneFrameBackKeepGapNext, nameof(Configuration.Settings.Shortcuts.MoveEndOneFrameBackKeepGapNext)); + AddNode(createAndAdjustNode, language.AdjustEndOneFrameForwardKeepGapNext, nameof(Configuration.Settings.Shortcuts.MoveEndOneFrameForwardKeepGapNext)); + AddNode(createAndAdjustNode, language.RecalculateDurationOfCurrentSubtitle, nameof(Configuration.Settings.Shortcuts.GeneralAutoCalcCurrentDuration)); + AddNode(createAndAdjustNode, language.AdjustSnapStartToNextSceneChange, nameof(Configuration.Settings.Shortcuts.MainAdjustSnapStartToNextSceneChange)); + AddNode(createAndAdjustNode, language.AdjustSnapStartToNextSceneChangeWithGap, nameof(Configuration.Settings.Shortcuts.MainAdjustSnapStartToNextSceneChangeWithGap)); + AddNode(createAndAdjustNode, language.AdjustSnapEndToPreviousSceneChange, nameof(Configuration.Settings.Shortcuts.MainAdjustSnapEndToPreviousSceneChange)); + AddNode(createAndAdjustNode, language.AdjustSnapEndToPreviousSceneChangeWithGap, nameof(Configuration.Settings.Shortcuts.MainAdjustSnapEndToPreviousSceneChangeWithGap)); + AddNode(createAndAdjustNode, language.AdjustExtendToNextSceneChange, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToNextSceneChange)); + AddNode(createAndAdjustNode, language.AdjustExtendToNextSceneChangeWithGap, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToNextSceneChangeWithGap)); + AddNode(createAndAdjustNode, language.AdjustExtendToPreviousSceneChange, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToPreviousSceneChange)); + AddNode(createAndAdjustNode, language.AdjustExtendToPreviousSceneChangeWithGap, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToPreviousSceneChangeWithGap)); + AddNode(createAndAdjustNode, language.AdjustExtendToNextSubtitle, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToNextSubtitle)); + AddNode(createAndAdjustNode, language.AdjustExtendToPreviousSubtitle, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToPreviousSubtitle)); + AddNode(createAndAdjustNode, language.AdjustExtendCurrentSubtitle, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendCurrentSubtitle)); + AddNode(createAndAdjustNode, language.AdjustExtendPreviousLineEndToCurrentStart, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendPreviousLineEndToCurrentStart)); + AddNode(createAndAdjustNode, language.AdjustExtendNextLineStartToCurrentEnd, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendNextLineStartToCurrentEnd)); + if (createAndAdjustNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(createAndAdjustNode); + } + + var audioVisualizerNode = new ShortcutNode(language.WaveformAndSpectrogram); + AddNode(audioVisualizerNode, Configuration.Settings.Language.Waveform.ClickToAddWaveformAndSpectrogram, nameof(Configuration.Settings.Shortcuts.WaveformAdd)); + AddNode(audioVisualizerNode, Configuration.Settings.Language.Waveform.ZoomIn, nameof(Configuration.Settings.Shortcuts.WaveformZoomIn)); + AddNode(audioVisualizerNode, Configuration.Settings.Language.Waveform.ZoomOut, nameof(Configuration.Settings.Shortcuts.WaveformZoomOut)); + AddNode(audioVisualizerNode, language.VerticalZoom, nameof(Configuration.Settings.Shortcuts.WaveformVerticalZoom)); + AddNode(audioVisualizerNode, language.VerticalZoomOut, nameof(Configuration.Settings.Shortcuts.WaveformVerticalZoomOut)); + AddNode(audioVisualizerNode, Configuration.Settings.Language.Main.Menu.ContextMenu.Split, nameof(Configuration.Settings.Shortcuts.WaveformSplit)); + AddNode(audioVisualizerNode, language.WaveformSeekSilenceForward, nameof(Configuration.Settings.Shortcuts.WaveformSearchSilenceForward)); + AddNode(audioVisualizerNode, language.WaveformSeekSilenceBack, nameof(Configuration.Settings.Shortcuts.WaveformSearchSilenceBack)); + AddNode(audioVisualizerNode, language.WaveformAddTextHere, nameof(Configuration.Settings.Shortcuts.WaveformAddTextHere)); + AddNode(audioVisualizerNode, language.WaveformAddTextHereFromClipboard, nameof(Configuration.Settings.Shortcuts.WaveformAddTextHereFromClipboard)); + AddNode(audioVisualizerNode, language.SetParagraphAsSelection, nameof(Configuration.Settings.Shortcuts.WaveformSetParagraphAsSelection)); + AddNode(audioVisualizerNode, language.WaveformPlayNewSelection, nameof(Configuration.Settings.Shortcuts.WaveformPlaySelection)); + AddNode(audioVisualizerNode, language.WaveformPlayNewSelectionEnd, nameof(Configuration.Settings.Shortcuts.WaveformPlaySelectionEnd)); + AddNode(audioVisualizerNode, Configuration.Settings.Language.Main.VideoControls.InsertNewSubtitleAtVideoPosition, nameof(Configuration.Settings.Shortcuts.MainWaveformInsertAtCurrentPosition)); + AddNode(audioVisualizerNode, language.WaveformFocusListView, nameof(Configuration.Settings.Shortcuts.WaveformFocusListView)); + AddNode(audioVisualizerNode, language.WaveformGoToPreviousSceneChange, nameof(Configuration.Settings.Shortcuts.WaveformGoToPreviousSceneChange)); + AddNode(audioVisualizerNode, language.WaveformGoToNextSceneChange, nameof(Configuration.Settings.Shortcuts.WaveformGoToNextSceneChange)); + AddNode(audioVisualizerNode, language.WaveformToggleSceneChange, nameof(Configuration.Settings.Shortcuts.WaveformToggleSceneChange)); + AddNode(audioVisualizerNode, language.WaveformGuessStart, nameof(Configuration.Settings.Shortcuts.WaveformGuessStart)); + AddNode(audioVisualizerNode, language.GoBack100Milliseconds, nameof(Configuration.Settings.Shortcuts.Waveform100MsLeft)); + AddNode(audioVisualizerNode, language.GoForward100Milliseconds, nameof(Configuration.Settings.Shortcuts.Waveform100MsRight)); + AddNode(audioVisualizerNode, language.GoBack1Second, nameof(Configuration.Settings.Shortcuts.Waveform1000MsLeft)); + AddNode(audioVisualizerNode, language.GoForward1Second, nameof(Configuration.Settings.Shortcuts.Waveform1000MsRight)); + if (audioVisualizerNode.Nodes.Count > 0) + { + _shortcuts.Nodes.Add(audioVisualizerNode); + } + } + + private void ShowShortcutsTreeView() + { + treeViewShortcuts.BeginUpdate(); + treeViewShortcuts.Nodes.Clear(); + + foreach (var parent in _shortcuts.Nodes) + { + var parentNode = new TreeNode(parent.Text); + foreach (ShortcutNode node in parent.Nodes) + { + AddNode(parentNode, node.Text, node.Shortcut); + } + if (parentNode.Nodes.Count > 0) + { + treeViewShortcuts.Nodes.Add(parentNode); + } + } + foreach (TreeNode node in treeViewShortcuts.Nodes) + { + node.Text = node.Text.RemoveChar('&'); + foreach (TreeNode subNode in node.Nodes) + { + subNode.Text = subNode.Text.RemoveChar('&'); + foreach (TreeNode subSubNode in subNode.Nodes) + { + subSubNode.Text = subSubNode.Text.RemoveChar('&'); + } + } + } + + treeViewShortcuts.ExpandAll(); + treeViewShortcuts.EndUpdate(); + if (treeViewShortcuts.Nodes.Count > 0) + { + treeViewShortcuts.SelectedNode = treeViewShortcuts.Nodes[0]; + } + } + + private void AddNode(TreeNode parentNode, string text, ShortcutHelper shortcut) + { + var normalizeAmpersand = text.Replace("&&", "@_____@").Replace("&", string.Empty).Replace("@_____@", "&"); + if (textBoxShortcutSearch.Left < 2 || normalizeAmpersand.Contains(textBoxShortcutSearch.Text, StringComparison.OrdinalIgnoreCase)) + { + parentNode.Nodes.Add(new TreeNode(text) { Tag = shortcut }); + } + } + + private void AddNode(ShortcutNode node, string text, string shortcut, bool isMenuItem = false) + { + var prop = Configuration.Settings.Shortcuts.GetType().GetProperty(shortcut); + if (prop != null) + { + var s = text + GetShortcutText((string)prop.GetValue(Configuration.Settings.Shortcuts, null)); + node.Nodes.Add(new ShortcutNode(s) { Shortcut = new ShortcutHelper(prop, isMenuItem), ShortcutText = shortcut }); + } + } + + private static string GetShortcutText(string shortcut) + { + if (string.IsNullOrEmpty(shortcut)) + { + shortcut = Configuration.Settings.Language.General.None; + } + + return $" [{shortcut}]"; + } + + private void InitializeWaveformsAndSpectrogramsFolderEmpty(LanguageStructure.Settings language) + { + string waveformsFolder = Configuration.WaveformsDirectory.TrimEnd(Path.DirectorySeparatorChar); + string spectrogramsFolder = Configuration.SpectrogramsDirectory.TrimEnd(Path.DirectorySeparatorChar); + long bytes = 0; + int count = 0; + + if (Directory.Exists(waveformsFolder)) + { + var di = new DirectoryInfo(waveformsFolder); + + // waveform data + bytes = 0; + count = 0; + foreach (FileInfo fi in di.GetFiles("*.wav")) + { + bytes += fi.Length; + count++; + } + } + + if (Directory.Exists(spectrogramsFolder)) + { + var di = new DirectoryInfo(spectrogramsFolder); + + // spectrogram data + foreach (var dir in di.GetDirectories()) + { + var spectrogramDir = new DirectoryInfo(dir.FullName); + foreach (var fi in spectrogramDir.GetFiles("*.gif")) + { + bytes += fi.Length; + count++; + } + foreach (var fi in spectrogramDir.GetFiles("*.db")) + { + bytes += fi.Length; + count++; + } + string xmlFileName = Path.Combine(dir.FullName, "Info.xml"); + if (File.Exists(xmlFileName)) + { + var fi = new FileInfo(xmlFileName); + bytes += fi.Length; + count++; + } + } + } + + if (count > 0) + { + buttonWaveformsFolderEmpty.Enabled = true; + labelWaveformsFolderInfo.Text = string.Format(language.WaveformAndSpectrogramsFolderInfo, count, bytes / 1024.0 / 1024.0); + } + else + { + buttonWaveformsFolderEmpty.Enabled = false; + labelWaveformsFolderInfo.Text = string.Format(language.WaveformAndSpectrogramsFolderInfo, 0, 0); + } + } + + public void Initialize(Icon icon, Image newFile, Image openFile, Image saveFile, Image saveFileAs, Image find, Image replace, Image fixCommonErrors, Image removeTextForHi, + Image visualSync, Image spellCheck, Image netflixGlyphCheck, Image settings, Image help) + { + Icon = (Icon)icon.Clone(); + pictureBoxNew.Image = (Image)newFile.Clone(); + pictureBoxOpen.Image = (Image)openFile.Clone(); + pictureBoxSave.Image = (Image)saveFile.Clone(); + pictureBoxSaveAs.Image = (Image)saveFileAs.Clone(); + pictureBoxFind.Image = (Image)find.Clone(); + pictureBoxReplace.Image = (Image)replace.Clone(); + pictureBoxTBFixCommonErrors.Image = (Image)fixCommonErrors.Clone(); + pictureBoxTBRemoveTextForHi.Image = (Image)removeTextForHi.Clone(); + pictureBoxVisualSync.Image = (Image)visualSync.Clone(); + pictureBoxSpellCheck.Image = (Image)spellCheck.Clone(); + pictureBoxNetflixQualityCheck.Image = (Image)netflixGlyphCheck.Clone(); + pictureBoxSettings.Image = (Image)settings.Clone(); + pictureBoxHelp.Image = (Image)help.Clone(); + } + + private void InitComboBoxWordListLanguages() + { + //Examples: da_DK_user.xml, eng_OCRFixReplaceList.xml, en_names.xml + string dir = Utilities.DictionaryFolder; + if (Directory.Exists(dir)) + { + var cultures = new List(); + // Specific culture e.g: en-US, en-GB... + foreach (var culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) + { + if (File.Exists(Path.Combine(dir, culture.Name.Replace('-', '_') + "_user.xml"))) + { + if (!cultures.Contains(culture)) + { + cultures.Add(culture); + } + } + } + // Neutral culture e.g: "en" for all (en-US, en-GB, en-JM...) + foreach (var culture in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) + { + string ocrFixGeneralFile = Path.Combine(dir, culture.GetThreeLetterIsoLanguageName() + "_OCRFixReplaceList.xml"); + string ocrFixUserFile = Path.Combine(dir, culture.GetThreeLetterIsoLanguageName() + "_OCRFixReplaceList_User.xml"); + string namesFile = Path.Combine(dir, culture.TwoLetterISOLanguageName + "_names.xml"); + if (File.Exists(ocrFixGeneralFile) || File.Exists(ocrFixUserFile) || File.Exists(namesFile)) + { + bool alreadyInList = false; + foreach (var ci in cultures) + { + // If culture is already added to the list, it doesn't matter if it's "culture specific" do not re-add. + if (ci.GetThreeLetterIsoLanguageName().Equals(culture.GetThreeLetterIsoLanguageName(), StringComparison.Ordinal)) + { + alreadyInList = true; + break; + } + } + if (!alreadyInList) + { + cultures.Add(culture); + } + } + } + + // English is the default selected language + Configuration.Settings.WordLists.LastLanguage = Configuration.Settings.WordLists.LastLanguage ?? "en-US"; + comboBoxWordListLanguage.BeginUpdate(); + var list = new List(cultures.Count); + var idx = 0; + for (var index = 0; index < cultures.Count; index++) + { + var ci = cultures[index]; + list.Add(new ComboBoxLanguage { CultureInfo = ci }); + if (ci.Name.Equals(Configuration.Settings.WordLists.LastLanguage, StringComparison.Ordinal)) + { + idx = index; + } + } + comboBoxWordListLanguage.Items.AddRange(list.ToArray()); + if (comboBoxWordListLanguage.Items.Count > 0) + { + comboBoxWordListLanguage.SelectedIndex = idx; + } + comboBoxWordListLanguage.EndUpdate(); + } + else + { + groupBoxWordLists.Enabled = false; + } + } + + private void ButtonOkClick(object sender, EventArgs e) + { + var gs = Configuration.Settings.General; + + gs.ShowToolbarNew = checkBoxToolbarNew.Checked; + gs.ShowToolbarOpen = checkBoxToolbarOpen.Checked; + gs.ShowToolbarSave = checkBoxToolbarSave.Checked; + gs.ShowToolbarSaveAs = checkBoxToolbarSaveAs.Checked; + gs.ShowToolbarFind = checkBoxToolbarFind.Checked; + gs.ShowToolbarReplace = checkBoxReplace.Checked; + gs.ShowToolbarFixCommonErrors = checkBoxTBFixCommonErrors.Checked; + gs.ShowToolbarRemoveTextForHi = checkBoxTBRemoveTextForHi.Checked; + gs.ShowToolbarVisualSync = checkBoxVisualSync.Checked; + gs.ShowToolbarSettings = checkBoxSettings.Checked; + gs.ShowToolbarSpellCheck = checkBoxSpellCheck.Checked; + gs.ShowToolbarNetflixGlyphCheck = checkBoxNetflixQualityCheck.Checked; + gs.ShowToolbarHelp = checkBoxHelp.Checked; + + gs.ShowFrameRate = checkBoxShowFrameRate.Checked; + if (double.TryParse(comboBoxFrameRate.Text.Replace(',', '.').Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var outFrameRate)) + { + gs.DefaultFrameRate = outFrameRate; + } + + gs.DefaultEncoding = ((TextEncoding)comboBoxEncoding.Items[comboBoxEncoding.SelectedIndex]).ToString(); + + gs.AutoGuessAnsiEncoding = checkBoxAutoDetectAnsiEncoding.Checked; + gs.SubtitleTextBoxFontSize = int.Parse(comboBoxSubtitleFontSize.Text); + gs.SubtitleListViewFontSize = int.Parse(comboBoxSubtitleListViewFontSize.Text); + gs.SubtitleTextBoxFontBold = checkBoxSubtitleFontBold.Checked; + gs.SubtitleTextBoxSyntaxColor = checkBoxSubtitleTextBoxSyntaxColor.Checked; + gs.SubtitleTextBoxHtmlColor = panelTextBoxHtmlColor.BackColor; + gs.SubtitleTextBoxAssColor = panelTextBoxAssColor.BackColor; + gs.SubtitleListViewFontBold = checkBoxSubtitleListViewFontBold.Checked; + gs.CenterSubtitleInTextBox = checkBoxSubtitleCenter.Checked; + gs.SubtitleFontColor = panelSubtitleFontColor.BackColor; + gs.SubtitleBackgroundColor = panelSubtitleBackgroundColor.BackColor; + gs.ShowRecentFiles = checkBoxRememberRecentFiles.Checked; + gs.RememberSelectedLine = checkBoxRememberSelectedLine.Checked; + gs.StartLoadLastFile = checkBoxReopenLastOpened.Checked; + gs.StartRememberPositionAndSize = checkBoxRememberWindowPosition.Checked; + gs.StartInSourceView = checkBoxStartInSourceView.Checked; + gs.RemoveBlankLinesWhenOpening = checkBoxRemoveBlankLinesWhenOpening.Checked; + gs.ListViewLineSeparatorString = textBoxShowLineBreaksAs.Text; + if (string.IsNullOrWhiteSpace(gs.ListViewLineSeparatorString)) + { + gs.ListViewLineSeparatorString = "
"; + } + + gs.ListViewDoubleClickAction = comboBoxListViewDoubleClickEvent.SelectedIndex; + + gs.Profiles = _rulesProfiles; + + gs.SaveAsUseFileNameFrom = comboBoxSaveAsFileNameFrom.SelectedIndex == 0 ? "video" : "file"; + + gs.SubtitleMinimumDisplayMilliseconds = (int)numericUpDownDurationMin.Value; + gs.SubtitleMaximumDisplayMilliseconds = (int)numericUpDownDurationMax.Value; + gs.MinimumMillisecondsBetweenLines = (int)numericUpDownMinGapMs.Value; + gs.CurrentProfile = comboBoxRulesProfileName.Text; + + if (comboBoxAutoBackup.SelectedIndex == 1) + { + gs.AutoBackupSeconds = 60; + } + else if (comboBoxAutoBackup.SelectedIndex == 2) + { + gs.AutoBackupSeconds = 60 * 5; + } + else if (comboBoxAutoBackup.SelectedIndex == 3) + { + gs.AutoBackupSeconds = 60 * 15; + } + else + { + gs.AutoBackupSeconds = 0; + } + + if (comboBoxAutoBackupDeleteAfter.SelectedIndex == 2) + { + gs.AutoBackupDeleteAfterMonths = 6; + } + else if (comboBoxAutoBackupDeleteAfter.SelectedIndex == 1) + { + gs.AutoBackupDeleteAfterMonths = 3; + } + else + { + gs.AutoBackupDeleteAfterMonths = 1; + } + + gs.CheckForUpdates = checkBoxCheckForUpdates.Checked; + gs.AutoSave = checkBoxAutoSave.Checked; + + if (comboBoxTimeCodeMode.Visible) + { + gs.UseTimeFormatHHMMSSFF = comboBoxTimeCodeMode.SelectedIndex == 1; + } + + gs.SplitBehavior = comboBoxSplitBehavior.SelectedIndex; + + gs.SpellChecker = comboBoxSpellChecker.SelectedIndex == 1 ? "word" : "hunspell"; + + gs.AllowEditOfOriginalSubtitle = checkBoxAllowEditOfOriginalSubtitle.Checked; + gs.PromptDeleteLines = checkBoxPromptDeleteLines.Checked; + + if (radioButtonVideoPlayerMPV.Checked) + { + gs.VideoPlayer = "MPV"; + } + else if (radioButtonVideoPlayerMpcHc.Checked) + { + gs.VideoPlayer = "MPC-HC"; + } + else if (radioButtonVideoPlayerVLC.Checked) + { + gs.VideoPlayer = "VLC"; + } + else + { + gs.VideoPlayer = "DirectShow"; + } + + gs.MpvHandlesPreviewText = checkBoxMpvHandlesPreviewText.Checked; + gs.VlcLocation = textBoxVlcPath.Text; + + gs.VideoPlayerShowStopButton = checkBoxVideoPlayerShowStopButton.Checked; + gs.VideoPlayerShowMuteButton = checkBoxVideoPlayerShowMuteButton.Checked; + gs.VideoPlayerShowFullscreenButton = checkBoxVideoPlayerShowFullscreenButton.Checked; + gs.VideoPlayerPreviewFontSize = int.Parse(comboBoxlVideoPlayerPreviewFontSize.Items[0].ToString()) + comboBoxlVideoPlayerPreviewFontSize.SelectedIndex; + gs.VideoPlayerPreviewFontBold = checkBoxVideoPlayerPreviewFontBold.Checked; + gs.DisableVideoAutoLoading = !checkBoxVideoAutoOpen.Checked; + gs.AllowVolumeBoost = checkBoxAllowVolumeBoost.Checked; + + Configuration.Settings.VideoControls.CustomSearchText1 = comboBoxCustomSearch1.Text; + Configuration.Settings.VideoControls.CustomSearchText2 = comboBoxCustomSearch2.Text; + Configuration.Settings.VideoControls.CustomSearchText3 = comboBoxCustomSearch3.Text; + Configuration.Settings.VideoControls.CustomSearchText4 = comboBoxCustomSearch4.Text; + Configuration.Settings.VideoControls.CustomSearchText5 = comboBoxCustomSearch5.Text; + Configuration.Settings.VideoControls.CustomSearchUrl1 = textBoxCustomSearchUrl1.Text; + Configuration.Settings.VideoControls.CustomSearchUrl2 = textBoxCustomSearchUrl2.Text; + Configuration.Settings.VideoControls.CustomSearchUrl3 = textBoxCustomSearchUrl3.Text; + Configuration.Settings.VideoControls.CustomSearchUrl4 = textBoxCustomSearchUrl4.Text; + Configuration.Settings.VideoControls.CustomSearchUrl5 = textBoxCustomSearchUrl5.Text; + + int maxLength = (int)numericUpDownSubtitleLineMaximumLength.Value; + if (maxLength > 9 && maxLength < 1000) + { + gs.SubtitleLineMaximumLength = maxLength; + } + else if (maxLength > 999) + { + gs.SubtitleLineMaximumLength = 999; + } + else + { + gs.SubtitleLineMaximumLength = 45; + } + + gs.SubtitleOptimalCharactersPerSeconds = (double)numericUpDownOptimalCharsSec.Value; + gs.SubtitleMaximumCharactersPerSeconds = (double)numericUpDownMaxCharsSec.Value; + gs.SubtitleMaximumWordsPerMinute = (double)numericUpDownMaxWordsMin.Value; + gs.MaxNumberOfLines = (int)numericUpDownMaxNumberOfLines.Value; + + gs.AutoWrapLineWhileTyping = checkBoxAutoWrapWhileTyping.Checked; + + if (comboBoxSubtitleFont.SelectedItem != null) + { + gs.SubtitleFontName = comboBoxSubtitleFont.SelectedItem.ToString(); + } + + var toolsSettings = Configuration.Settings.Tools; + toolsSettings.VerifyPlaySeconds = comboBoxToolsVerifySeconds.SelectedIndex + 2; + toolsSettings.StartSceneIndex = comboBoxToolsStartSceneIndex.SelectedIndex; + toolsSettings.EndSceneIndex = comboBoxToolsEndSceneIndex.SelectedIndex; + gs.MergeLinesShorterThan = comboBoxMergeShortLineLength.SelectedIndex + 5; + if (gs.MergeLinesShorterThan > gs.SubtitleLineMaximumLength + 1) + { + gs.MergeLinesShorterThan = gs.SubtitleLineMaximumLength; + } + + gs.DialogStyle = DialogSplitMerge.GetDialogStyleFromIndex(comboBoxDialogStyle.SelectedIndex); + gs.ContinuationStyle = ContinuationUtilities.GetContinuationStyleFromIndex(comboBoxContinuationStyle.SelectedIndex); + + toolsSettings.MusicSymbol = comboBoxToolsMusicSymbol.SelectedItem.ToString(); + toolsSettings.MusicSymbolReplace = textBoxMusicSymbolsToReplace.Text; + toolsSettings.SpellCheckAutoChangeNames = checkBoxSpellCheckAutoChangeNames.Checked; + toolsSettings.SpellCheckAutoChangeNamesUseSuggestions = checkBoxSpellCheckAutoChangeNamesViaSuggestions.Checked; + toolsSettings.CheckOneLetterWords = checkBoxSpellCheckOneLetterWords.Checked; + toolsSettings.SpellCheckEnglishAllowInQuoteAsIng = checkBoxTreatINQuoteAsING.Checked; + toolsSettings.RememberUseAlwaysList = checkBoxUseAlwaysToFile.Checked; + toolsSettings.UseNoLineBreakAfter = checkBoxUseDoNotBreakAfterList.Checked; + toolsSettings.AutoBreakCommaBreakEarly = checkBoxToolsBreakEarlyComma.Checked; + toolsSettings.AutoBreakLineEndingEarly = checkBoxToolsBreakEarlyLineEnding.Checked; + toolsSettings.AutoBreakUsePixelWidth = checkBoxToolsBreakByPixelWidth.Checked; + toolsSettings.AutoBreakPreferBottomHeavy = checkBoxToolsBreakPreferBottomHeavy.Checked; + toolsSettings.AutoBreakPreferBottomPercent = (double)numericUpDownToolsBreakPreferBottomHeavy.Value; + toolsSettings.AutoBreakDashEarly = checkBoxToolsBreakEarlyDash.Checked; + + Configuration.Settings.General.CharactersPerSecondsIgnoreWhiteSpace = !checkBoxCpsIncludeWhiteSpace.Checked; + toolsSettings.OcrFixUseHardcodedRules = checkBoxFixCommonOcrErrorsUsingHardcodedRules.Checked; + toolsSettings.FixShortDisplayTimesAllowMoveStartTime = checkBoxFixShortDisplayTimesAllowMoveStartTime.Checked; + toolsSettings.FixCommonErrorsSkipStepOne = checkBoxFceSkipStep1.Checked; + toolsSettings.MicrosoftTranslatorApiKey = textBoxBingClientSecret.Text.Trim(); + toolsSettings.MicrosoftTranslatorTokenEndpoint = comboBoxBoxBingTokenEndpoint.Text.Trim(); + toolsSettings.GoogleApiV2Key = textBoxGoogleTransleApiKey.Text.Trim(); + + var wordListSettings = Configuration.Settings.WordLists; + wordListSettings.UseOnlineNames = checkBoxNamesOnline.Checked; + wordListSettings.NamesUrl = textBoxNamesOnline.Text; + if (comboBoxWordListLanguage.Items.Count > 0 && comboBoxWordListLanguage.SelectedIndex >= 0) + { + if (comboBoxWordListLanguage.Items[comboBoxWordListLanguage.SelectedIndex] is ComboBoxLanguage ci) + { + Configuration.Settings.WordLists.LastLanguage = ci.CultureInfo.Name; + } + } + + var ssa = Configuration.Settings.SubtitleSettings; + ssa.SsaFontName = _ssaFontName; + ssa.SsaFontSize = _ssaFontSize; + ssa.SsaFontColorArgb = _ssaFontColor; + ssa.SsaFontBold = checkBoxSsaFontBold.Checked; + ssa.SsaOutline = (int)numericUpDownSsaOutline.Value; + ssa.SsaShadow = (int)numericUpDownSsaShadow.Value; + ssa.SsaOpaqueBox = checkBoxSsaOpaqueBox.Checked; + ssa.SsaMarginLeft = (int)numericUpDownSsaMarginLeft.Value; + ssa.SsaMarginRight = (int)numericUpDownSsaMarginRight.Value; + ssa.SsaMarginTopBottom = (int)numericUpDownSsaMarginVertical.Value; + + var proxy = Configuration.Settings.Proxy; + proxy.ProxyAddress = textBoxProxyAddress.Text; + proxy.UserName = textBoxProxyUserName.Text; + if (string.IsNullOrWhiteSpace(textBoxProxyPassword.Text)) + { + proxy.Password = null; + } + else + { + proxy.EncodePassword(textBoxProxyPassword.Text); + } + + proxy.Domain = textBoxProxyDomain.Text; + + Configuration.Settings.NetworkSettings.NewMessageSound = textBoxNetworkSessionNewMessageSound.Text; + + Configuration.Settings.Tools.ListViewSyntaxColorDurationSmall = checkBoxSyntaxColorDurationTooSmall.Checked; + Configuration.Settings.Tools.ListViewSyntaxColorDurationBig = checkBoxSyntaxColorDurationTooLarge.Checked; + Configuration.Settings.Tools.ListViewSyntaxColorLongLines = checkBoxSyntaxColorTextTooLong.Checked; + Configuration.Settings.Tools.ListViewSyntaxColorWideLines = checkBoxSyntaxColorTextTooWide.Checked; + Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines = checkBoxSyntaxColorTextMoreThanTwoLines.Checked; + Configuration.Settings.Tools.ListViewSyntaxColorOverlap = checkBoxSyntaxOverlap.Checked; + Configuration.Settings.Tools.ListViewSyntaxColorGap = checkBoxSyntaxColorGapTooSmall.Checked; + Configuration.Settings.Tools.ListViewSyntaxErrorColor = panelListViewSyntaxColorError.BackColor; + + Configuration.Settings.VideoControls.WaveformDrawGrid = checkBoxWaveformShowGrid.Checked; + Configuration.Settings.VideoControls.WaveformDrawCps = checkBoxWaveformShowCps.Checked; + Configuration.Settings.VideoControls.WaveformDrawWpm = checkBoxWaveformShowWpm.Checked; + Configuration.Settings.VideoControls.WaveformGridColor = panelWaveformGridColor.BackColor; + Configuration.Settings.VideoControls.WaveformSelectedColor = panelWaveformSelectedColor.BackColor; + Configuration.Settings.VideoControls.WaveformColor = panelWaveformColor.BackColor; + Configuration.Settings.VideoControls.WaveformBackgroundColor = panelWaveformBackgroundColor.BackColor; + Configuration.Settings.VideoControls.WaveformTextColor = panelWaveformTextColor.BackColor; + Configuration.Settings.VideoControls.WaveformCursorColor = panelWaveformCursorColor.BackColor; + Configuration.Settings.VideoControls.GenerateSpectrogram = checkBoxGenerateSpectrogram.Checked; + Configuration.Settings.VideoControls.SpectrogramAppearance = comboBoxSpectrogramAppearance.SelectedIndex == 0 ? "OneColorGradient" : "Classic"; + + Configuration.Settings.VideoControls.WaveformTextSize = int.Parse(comboBoxWaveformTextSize.Text); + Configuration.Settings.VideoControls.WaveformTextBold = checkBoxWaveformTextBold.Checked; + Configuration.Settings.VideoControls.WaveformMouseWheelScrollUpIsForward = checkBoxReverseMouseWheelScrollDirection.Checked; + Configuration.Settings.VideoControls.WaveformAllowOverlap = checkBoxAllowOverlap.Checked; + Configuration.Settings.VideoControls.WaveformSetVideoPositionOnMoveStartEnd = checkBoxWaveformSetVideoPosMoveStartEnd.Checked; + Configuration.Settings.VideoControls.WaveformFocusOnMouseEnter = checkBoxWaveformHoverFocus.Checked; + Configuration.Settings.VideoControls.WaveformListViewFocusOnMouseEnter = checkBoxListViewMouseEnterFocus.Checked; + Configuration.Settings.VideoControls.WaveformSingleClickSelect = checkBoxWaveformSingleClickSelect.Checked; + Configuration.Settings.VideoControls.WaveformSnapToSceneChanges = checkBoxWaveformSnapToSceneChanges.Checked; + Configuration.Settings.VideoControls.WaveformBorderHitMs = Convert.ToInt32(numericUpDownWaveformBorderHitMs.Value); + gs.UseFFmpegForWaveExtraction = checkBoxUseFFmpeg.Checked; + gs.FFmpegLocation = textBoxFFmpegPath.Text; + + // save shortcuts + foreach (var kvp in _newShortcuts) + { + kvp.Key.Shortcut.SetValue(Configuration.Settings.Shortcuts, kvp.Value, null); + } + + Configuration.Settings.Save(); + } + + private void FormSettings_KeyDown(object sender, KeyEventArgs e) + { + if (comboBoxShortcutKey.Focused) + { + return; + } + + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#Settings"); + e.SuppressKeyPress = true; + } + } + + private void UpdateSsaExample() + { + GeneratePreviewReal(); + } + + private void GeneratePreviewReal() + { + if (_loading) + { + return; + } + + pictureBoxPreview.Image?.Dispose(); + var backgroundImage = TextDesigner.MakeBackgroundImage(pictureBoxPreview.Width, pictureBoxPreview.Height, 9, _backgroundImageDark); + var outlineWidth = (float)numericUpDownSsaOutline.Value; + var shadowWidth = (float)numericUpDownSsaShadow.Value; + var outlineColor = Color.Black; + + Font font; + try + { + font = new Font(comboBoxFontName.Text, (float)numericUpDownFontSize.Value * 1.1f, checkBoxSsaFontBold.Checked ? FontStyle.Bold : FontStyle.Regular); + } + catch + { + font = new Font(Font, FontStyle.Regular); + } + + var measureBmp = TextDesigner.MakeTextBitmapAssa( + Configuration.Settings.General.PreviewAssaText, + 0, + 0, + font, + pictureBoxPreview.Width, + pictureBoxPreview.Height, + outlineWidth, + shadowWidth, + null, + panelPrimaryColor.BackColor, + outlineColor, + Color.FromArgb(100, Color.Black), + checkBoxSsaOpaqueBox.Checked); + var nBmp = new NikseBitmap(measureBmp); + var measuredWidth = nBmp.GetNonTransparentWidth(); + var measuredHeight = nBmp.GetNonTransparentHeight(); + + float left = (pictureBoxPreview.Width - measuredWidth) / 2.0f; + float top = pictureBoxPreview.Height - measuredHeight - (int)numericUpDownSsaMarginVertical.Value; + var designedText = TextDesigner.MakeTextBitmapAssa( + Configuration.Settings.General.PreviewAssaText, + (int)Math.Round(left), + (int)Math.Round(top), + font, + pictureBoxPreview.Width, + pictureBoxPreview.Height, + outlineWidth, + shadowWidth, + backgroundImage, + panelPrimaryColor.BackColor, + Color.Black, + Color.FromArgb(200, Color.Black), + checkBoxSsaOpaqueBox.Checked); + + pictureBoxPreview.Image?.Dispose(); + pictureBoxPreview.Image = designedText; + font.Dispose(); + } + + private void ComboBoxWordListLanguageSelectedIndexChanged(object sender, EventArgs e) + { + buttonRemoveNameEtc.Enabled = false; + buttonAddNames.Enabled = false; + buttonRemoveUserWord.Enabled = false; + buttonAddUserWord.Enabled = false; + buttonRemoveOcrFix.Enabled = false; + buttonAddOcrFix.Enabled = false; + listBoxNames.Items.Clear(); + listBoxUserWordLists.Items.Clear(); + listBoxOcrFixList.Items.Clear(); + if (comboBoxWordListLanguage.Items.Count > 0 && comboBoxWordListLanguage.Items[comboBoxWordListLanguage.SelectedIndex] is ComboBoxLanguage) + { + string language = GetCurrentWordListLanguage(); + + buttonAddNames.Enabled = true; + buttonAddUserWord.Enabled = true; + buttonAddOcrFix.Enabled = true; + + // user word list + LoadUserWords(language, true); + + // OCR fix words + LoadOcrFixList(true); + + LoadNames(language, true); + } + } + + private void LoadOcrFixList(bool reloadListBox) + { + if (comboBoxWordListLanguage.Items.Count == 0 || !(comboBoxWordListLanguage.Items[comboBoxWordListLanguage.SelectedIndex] is ComboBoxLanguage cb)) + { + return; + } + + _ocrFixReplaceList = OcrFixReplaceList.FromLanguageId(cb.CultureInfo.GetThreeLetterIsoLanguageName()); + if (reloadListBox) + { + listBoxOcrFixList.BeginUpdate(); + listBoxOcrFixList.Items.Clear(); + listBoxOcrFixList.Items.AddRange(_ocrFixReplaceList.WordReplaceList.Select(p => p.Key + " --> " + p.Value).ToArray()); + listBoxOcrFixList.Items.AddRange(_ocrFixReplaceList.PartialLineWordBoundaryReplaceList.Select(p => p.Key + " --> " + p.Value).ToArray()); + listBoxOcrFixList.Sorted = true; + listBoxOcrFixList.EndUpdate(); + } + } + + private void LoadUserWords(string language, bool reloadListBox) + { + _userWordList = new List(); + Utilities.LoadUserWordList(_userWordList, language); + _userWordList.Sort(); + + if (reloadListBox) + { + listBoxUserWordLists.Items.Clear(); + listBoxUserWordLists.Items.AddRange(_userWordList.ToArray()); + } + } + + private void LoadNames(string language, bool reloadListBox) + { + var task = Task.Factory.StartNew(() => + { + // names etc + var nameList = new NameList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); + _wordListNames = nameList.GetAllNames(); + _wordListNames.Sort(); + return _wordListNames; + }); + + if (reloadListBox) + { + // reload the listbox on a continuation ui thead + var uiContext = TaskScheduler.FromCurrentSynchronizationContext(); + task.ContinueWith(originalTask => + { + listBoxNames.BeginUpdate(); + listBoxNames.Items.Clear(); + listBoxNames.Items.AddRange(originalTask.Result.ToArray()); + listBoxNames.EndUpdate(); + }, uiContext); + } + } + + private string GetCurrentWordListLanguage() + { + var idx = comboBoxWordListLanguage.SelectedIndex; + if (idx < 0) + { + return null; + } + + var cb = comboBoxWordListLanguage.Items[idx] as ComboBoxLanguage; + return cb?.CultureInfo.Name.Replace('-', '_'); + } + + private void ButtonAddNamesClick(object sender, EventArgs e) + { + var languageIndex = comboBoxWordListLanguage.SelectedIndex; + if (languageIndex < 0) + { + return; + } + + string language = GetCurrentWordListLanguage(); + string text = textBoxNameEtc.Text.RemoveControlCharacters().Trim(); + if (!string.IsNullOrEmpty(language) && text.Length > 1 && !_wordListNames.Contains(text)) + { + var nameList = new NameList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); + nameList.Add(text); + LoadNames(language, true); + labelStatus.Text = string.Format(Configuration.Settings.Language.Settings.WordAddedX, text); + textBoxNameEtc.Text = string.Empty; + textBoxNameEtc.Focus(); + for (int i = 0; i < listBoxNames.Items.Count; i++) + { + if (listBoxNames.Items[i].ToString() == text) + { + listBoxNames.SelectedIndex = i; + int top = i - 5; + if (top < 0) + { + top = 0; + } + + listBoxNames.TopIndex = top; + break; + } + } + } + else + { + MessageBox.Show(Configuration.Settings.Language.Settings.WordAlreadyExists); + } + } + + private void ListBoxNamesSelectedIndexChanged(object sender, EventArgs e) + { + buttonRemoveNameEtc.Enabled = listBoxNames.SelectedIndex >= 0; + } + + private void ButtonRemoveNameEtcClick(object sender, EventArgs e) + { + if (listBoxNames.SelectedIndices.Count == 0) + { + return; + } + + string language = GetCurrentWordListLanguage(); + int index = listBoxNames.SelectedIndex; + string text = listBoxNames.Items[index].ToString(); + int itemsToRemoveCount = listBoxNames.SelectedIndices.Count; + if (!string.IsNullOrEmpty(language) && index >= 0) + { + DialogResult result; + if (itemsToRemoveCount == 1) + { + result = MessageBox.Show(string.Format(Configuration.Settings.Language.Settings.RemoveX, text), "Subtitle Edit", MessageBoxButtons.YesNo); + } + else + { + result = MessageBox.Show(string.Format(Configuration.Settings.Language.Main.DeleteXLinesPrompt, itemsToRemoveCount), "Subtitle Edit", MessageBoxButtons.YesNo); + } + + if (result == DialogResult.Yes) + { + int removeCount = 0; + var namesList = new NameList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); + for (int idx = listBoxNames.SelectedIndices.Count - 1; idx >= 0; idx--) + { + index = listBoxNames.SelectedIndices[idx]; + text = listBoxNames.Items[index].ToString(); + namesList.Remove(text); + removeCount++; + listBoxNames.Items.RemoveAt(index); + } + + if (removeCount > 0) + { + LoadNames(language, true); // reload + + if (index < listBoxNames.Items.Count) + { + listBoxNames.SelectedIndex = index; + } + else if (listBoxNames.Items.Count > 0) + { + listBoxNames.SelectedIndex = index - 1; + } + + listBoxNames.Focus(); + + buttonRemoveNameEtc.Enabled = false; + return; + } + + if (removeCount < itemsToRemoveCount && Configuration.Settings.WordLists.UseOnlineNames && !string.IsNullOrEmpty(Configuration.Settings.WordLists.NamesUrl)) + { + MessageBox.Show(Configuration.Settings.Language.Settings.CannotUpdateNamesOnline); + return; + } + + if (removeCount == 0) + { + MessageBox.Show(Configuration.Settings.Language.Settings.WordNotFound); + } + } + } + } + + private void TextBoxNameEtcKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + e.SuppressKeyPress = true; + ButtonAddNamesClick(null, null); + } + } + + private void ButtonAddUserWordClick(object sender, EventArgs e) + { + var languageIndex = comboBoxWordListLanguage.SelectedIndex; + if (languageIndex < 0) + { + return; + } + + string language = GetCurrentWordListLanguage(); + string text = textBoxUserWord.Text.RemoveControlCharacters().Trim().ToLowerInvariant(); + if (!string.IsNullOrEmpty(language) && text.Length > 0 && !_userWordList.Contains(text)) + { + Utilities.AddToUserDictionary(text, language); + LoadUserWords(language, true); + labelStatus.Text = string.Format(Configuration.Settings.Language.Settings.WordAddedX, text); + textBoxUserWord.Text = string.Empty; + textBoxUserWord.Focus(); + + for (int i = 0; i < listBoxUserWordLists.Items.Count; i++) + { + if (listBoxUserWordLists.Items[i].ToString() == text) + { + listBoxUserWordLists.SelectedIndex = i; + int top = i - 5; + if (top < 0) + { + top = 0; + } + + listBoxUserWordLists.TopIndex = top; + break; + } + } + } + else + { + MessageBox.Show(Configuration.Settings.Language.Settings.WordAlreadyExists); + } + } + + private void TextBoxUserWordKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + e.SuppressKeyPress = true; + ButtonAddUserWordClick(null, null); + } + } + + private void ButtonRemoveUserWordClick(object sender, EventArgs e) + { + if (listBoxUserWordLists.SelectedIndices.Count == 0) + { + return; + } + + string language = GetCurrentWordListLanguage(); + int index = listBoxUserWordLists.SelectedIndex; + int itemsToRemoveCount = listBoxUserWordLists.SelectedIndices.Count; + string text = listBoxUserWordLists.Items[index].ToString(); + if (!string.IsNullOrEmpty(language) && index >= 0) + { + DialogResult result; + if (itemsToRemoveCount == 1) + { + result = MessageBox.Show(string.Format(Configuration.Settings.Language.Settings.RemoveX, text), "Subtitle Edit", MessageBoxButtons.YesNo); + } + else + { + result = MessageBox.Show(string.Format(Configuration.Settings.Language.Main.DeleteXLinesPrompt, itemsToRemoveCount), "Subtitle Edit", MessageBoxButtons.YesNo); + } + + if (result == DialogResult.Yes) + { + int removeCount = 0; + var words = new List(); + string userWordFileName = Utilities.LoadUserWordList(words, language); + + for (int idx = listBoxUserWordLists.SelectedIndices.Count - 1; idx >= 0; idx--) + { + index = listBoxUserWordLists.SelectedIndices[idx]; + text = listBoxUserWordLists.Items[index].ToString(); + + if (words.Contains(text)) + { + words.Remove(text); + removeCount++; + } + listBoxUserWordLists.Items.RemoveAt(index); + } + + if (removeCount > 0) + { + words.Sort(); + var doc = new XmlDocument(); + doc.Load(userWordFileName); + doc.DocumentElement.RemoveAll(); + foreach (string word in words) + { + XmlNode node = doc.CreateElement("word"); + node.InnerText = word; + doc.DocumentElement.AppendChild(node); + } + doc.Save(userWordFileName); + LoadUserWords(language, false); // reload + buttonRemoveUserWord.Enabled = false; + + if (index < listBoxUserWordLists.Items.Count) + { + listBoxUserWordLists.SelectedIndex = index; + } + else if (listBoxUserWordLists.Items.Count > 0) + { + listBoxUserWordLists.SelectedIndex = index - 1; + } + + listBoxUserWordLists.Focus(); + return; + } + + if (removeCount < itemsToRemoveCount) + { + MessageBox.Show(Configuration.Settings.Language.Settings.WordNotFound); + } + } + } + } + + private void ListBoxUserWordListsSelectedIndexChanged(object sender, EventArgs e) + { + buttonRemoveUserWord.Enabled = listBoxUserWordLists.SelectedIndex >= 0; + } + + private void ButtonAddOcrFixClick(object sender, EventArgs e) + { + string key = textBoxOcrFixKey.Text.RemoveControlCharacters().Trim(); + string value = textBoxOcrFixValue.Text.RemoveControlCharacters().Trim(); + if (key.Length == 0 || value.Length == 0 || key == value || Utilities.IsInteger(key)) + { + return; + } + + if (comboBoxWordListLanguage.Items.Count == 0 || !(comboBoxWordListLanguage.Items[comboBoxWordListLanguage.SelectedIndex] is ComboBoxLanguage)) + { + return; + } + + var added = _ocrFixReplaceList.AddWordOrPartial(key, value); + if (!added) + { + MessageBox.Show(Configuration.Settings.Language.Settings.WordAlreadyExists); + return; + } + + LoadOcrFixList(true); + textBoxOcrFixKey.Text = string.Empty; + textBoxOcrFixValue.Text = string.Empty; + textBoxOcrFixKey.Focus(); + + for (int i = 0; i < listBoxOcrFixList.Items.Count; i++) + { + if (listBoxOcrFixList.Items[i].ToString() == key + " --> " + value) + { + listBoxOcrFixList.SelectedIndex = i; + int top = i - 5; + if (top < 0) + { + top = 0; + } + + listBoxOcrFixList.TopIndex = top; + break; + } + } + } + + private void ListBoxOcrFixListSelectedIndexChanged(object sender, EventArgs e) + { + buttonRemoveOcrFix.Enabled = listBoxOcrFixList.SelectedIndex >= 0; + } + + private void ButtonRemoveOcrFixClick(object sender, EventArgs e) + { + var languageIndex = comboBoxWordListLanguage.SelectedIndex; + if (languageIndex < 0) + { + return; + } + + if (!(comboBoxWordListLanguage.Items[languageIndex] is ComboBoxLanguage)) + { + return; + } + + if (listBoxOcrFixList.SelectedIndices.Count == 0) + { + return; + } + + int itemsToRemoveCount = listBoxOcrFixList.SelectedIndices.Count; + + int index = listBoxOcrFixList.SelectedIndex; + string text = listBoxOcrFixList.Items[index].ToString(); + string key = text.Substring(0, text.IndexOf(" --> ", StringComparison.Ordinal)); + + if (_ocrFixReplaceList.WordReplaceList.ContainsKey(key) || _ocrFixReplaceList.PartialLineWordBoundaryReplaceList.ContainsKey(key)) + { + DialogResult result; + if (itemsToRemoveCount == 1) + { + result = MessageBox.Show(string.Format(Configuration.Settings.Language.Settings.RemoveX, text), "Subtitle Edit", MessageBoxButtons.YesNo); + } + else + { + result = MessageBox.Show(string.Format(Configuration.Settings.Language.Main.DeleteXLinesPrompt, itemsToRemoveCount), "Subtitle Edit", MessageBoxButtons.YesNo); + } + + if (result == DialogResult.Yes) + { + listBoxOcrFixList.BeginUpdate(); + for (int idx = listBoxOcrFixList.SelectedIndices.Count - 1; idx >= 0; idx--) + { + index = listBoxOcrFixList.SelectedIndices[idx]; + text = listBoxOcrFixList.Items[index].ToString(); + key = text.Substring(0, text.IndexOf(" --> ", StringComparison.Ordinal)); + + if (_ocrFixReplaceList.WordReplaceList.ContainsKey(key) || _ocrFixReplaceList.PartialLineWordBoundaryReplaceList.ContainsKey(key)) + { + _ocrFixReplaceList.RemoveWordOrPartial(key); + } + listBoxOcrFixList.Items.RemoveAt(index); + } + listBoxOcrFixList.EndUpdate(); + + LoadOcrFixList(false); + buttonRemoveOcrFix.Enabled = false; + + if (index < listBoxOcrFixList.Items.Count) + { + listBoxOcrFixList.SelectedIndex = index; + } + else if (listBoxOcrFixList.Items.Count > 0) + { + listBoxOcrFixList.SelectedIndex = index - 1; + } + + listBoxOcrFixList.Focus(); + } + } + } + + private void TextBoxOcrFixValueKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + e.SuppressKeyPress = true; + ButtonAddOcrFixClick(null, null); + } + } + + private void TabControlSettingsSelectedIndexChanged(object sender, EventArgs e) + { + labelStatus.Text = string.Empty; + } + + private void ListBoxKeyDownSearch(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape || + e.KeyCode == Keys.Tab || + e.KeyCode == Keys.Return || + e.KeyCode == Keys.Enter || + e.KeyCode == Keys.Down || + e.KeyCode == Keys.Up || + e.KeyCode == Keys.PageDown || + e.KeyCode == Keys.PageUp || + e.KeyCode == Keys.None || + e.KeyCode == UiUtil.HelpKeys || + e.KeyCode == Keys.Home || + e.KeyCode == Keys.End) + { + return; + } + + if (TimeSpan.FromTicks(_listBoxSearchStringLastUsed.Ticks).TotalMilliseconds + 1800 < + TimeSpan.FromTicks(DateTime.Now.Ticks).TotalMilliseconds) + { + _listBoxSearchString = string.Empty; + } + + if (e.KeyCode == Keys.Delete) + { + if (_listBoxSearchString.Length > 0) + { + _listBoxSearchString = _listBoxSearchString.Remove(_listBoxSearchString.Length - 1, 1); + } + } + else + { + _listBoxSearchString += e.KeyCode.ToString(); + } + + _listBoxSearchStringLastUsed = DateTime.Now; + FindAndSelectListBoxItem(sender as ListBox); + e.SuppressKeyPress = true; + } + + private void FindAndSelectListBoxItem(ListBox listBox) + { + int i = 0; + foreach (string s in listBox.Items) + { + if (s.StartsWith(_listBoxSearchString, StringComparison.OrdinalIgnoreCase)) + { + listBox.SelectedIndex = i; + break; + } + i++; + } + } + + private void ListBoxSearchReset(object sender, EventArgs e) + { + _listBoxSearchString = string.Empty; + } + + private void comboBoxCustomSearch_SelectedIndexChanged(object sender, EventArgs e) + { + var cb = (ComboBox)sender; + var tb = textBoxCustomSearchUrl1; + if (cb == comboBoxCustomSearch2) + { + tb = textBoxCustomSearchUrl2; + } + else if (cb == comboBoxCustomSearch3) + { + tb = textBoxCustomSearchUrl3; + } + else if (cb == comboBoxCustomSearch4) + { + tb = textBoxCustomSearchUrl4; + } + else if (cb == comboBoxCustomSearch5) + { + tb = textBoxCustomSearchUrl5; + } + + if (cb.SelectedIndex >= 0) + { + if (cb.SelectedIndex == 0) + { + tb.Text = "https://www.dictionary.com/browse/{0}"; + } + else if (cb.SelectedIndex == 1) + { + tb.Text = "http://www.learnersdictionary.com/search/{0}"; + } + else if (cb.SelectedIndex == 2) + { + tb.Text = "https://www.merriam-webster.com/dictionary/{0}"; + } + else if (cb.SelectedIndex == 3) + { + tb.Text = "https://www.thefreedictionary.com/{0}"; + } + else if (cb.SelectedIndex == 4) + { + tb.Text = "https://www.thesaurus.com/browse/{0}"; + } + else if (cb.SelectedIndex == 5) + { + tb.Text = "https://www.urbandictionary.com/define.php?term={0}"; + } + else if (cb.SelectedIndex == 6) + { + tb.Text = "https://visuwords.com/?word={0}"; + } + else if (cb.SelectedIndex == 7) + { + tb.Text = "https://en.wikipedia.org/wiki?search={0}"; + } + } + } + + private void buttonWaveformSelectedColor_Click(object sender, EventArgs e) + { + colorDialogSSAStyle.Color = panelWaveformSelectedColor.BackColor; + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + panelWaveformSelectedColor.BackColor = colorDialogSSAStyle.Color; + } + } + + private void buttonWaveformColor_Click(object sender, EventArgs e) + { + colorDialogSSAStyle.Color = panelWaveformColor.BackColor; + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + panelWaveformColor.BackColor = colorDialogSSAStyle.Color; + } + } + + private void buttonWaveformBackgroundColor_Click(object sender, EventArgs e) + { + colorDialogSSAStyle.Color = panelWaveformBackgroundColor.BackColor; + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + panelWaveformBackgroundColor.BackColor = colorDialogSSAStyle.Color; + } + } + + private void buttonWaveformGridColor_Click(object sender, EventArgs e) + { + colorDialogSSAStyle.Color = panelWaveformGridColor.BackColor; + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + panelWaveformGridColor.BackColor = colorDialogSSAStyle.Color; + } + } + + private void buttonWaveformTextColor_Click(object sender, EventArgs e) + { + colorDialogSSAStyle.Color = panelWaveformTextColor.BackColor; + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + panelWaveformTextColor.BackColor = colorDialogSSAStyle.Color; + } + } + + private void buttonWaveformCursorColor_Click(object sender, EventArgs e) + { + colorDialogSSAStyle.Color = panelWaveformCursorColor.BackColor; + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + panelWaveformCursorColor.BackColor = colorDialogSSAStyle.Color; + } + } + + private void buttonWaveformsFolderEmpty_Click(object sender, EventArgs e) + { + string waveformsFolder = Configuration.WaveformsDirectory.TrimEnd(Path.DirectorySeparatorChar); + if (Directory.Exists(waveformsFolder)) + { + var di = new DirectoryInfo(waveformsFolder); + + foreach (var fileName in di.GetFiles("*.wav")) + { + try + { + File.Delete(fileName.FullName); + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + } + } + } + + string spectrogramsFolder = Configuration.SpectrogramsDirectory.TrimEnd(Path.DirectorySeparatorChar); + if (Directory.Exists(spectrogramsFolder)) + { + var di = new DirectoryInfo(spectrogramsFolder); + + foreach (var dir in di.GetDirectories()) + { + var spectrogramDir = new DirectoryInfo(dir.FullName); + foreach (var fileName in spectrogramDir.GetFiles("*.gif")) + { + File.Delete(fileName.FullName); + } + string imageDbFileName = Path.Combine(dir.FullName, "Images.db"); + if (File.Exists(imageDbFileName)) + { + File.Delete(imageDbFileName); + } + + string xmlFileName = Path.Combine(dir.FullName, "Info.xml"); + if (File.Exists(xmlFileName)) + { + File.Delete(xmlFileName); + } + + Directory.Delete(dir.FullName); + } + } + + InitializeWaveformsAndSpectrogramsFolderEmpty(Configuration.Settings.Language.Settings); + } + + private void checkBoxRememberRecentFiles_CheckedChanged(object sender, EventArgs e) + { + checkBoxReopenLastOpened.Enabled = checkBoxRememberRecentFiles.Checked; + checkBoxRememberSelectedLine.Enabled = checkBoxRememberRecentFiles.Checked; + } + + private void buttonWaveformSelectedColor_Click(object sender, MouseEventArgs e) + { + colorDialogSSAStyle.Color = panelWaveformSelectedColor.BackColor; + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + panelWaveformSelectedColor.BackColor = colorDialogSSAStyle.Color; + } + } + + private void panelSubtitleFontColor_Click(object sender, EventArgs e) + { + colorDialogSSAStyle.Color = panelSubtitleFontColor.BackColor; + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + panelSubtitleFontColor.BackColor = colorDialogSSAStyle.Color; + } + } + + private void panelSubtitleBackgroundColor_Click(object sender, EventArgs e) + { + colorDialogSSAStyle.Color = panelSubtitleBackgroundColor.BackColor; + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + panelSubtitleBackgroundColor.BackColor = colorDialogSSAStyle.Color; + } + } + + private void treeViewShortcuts_AfterSelect(object sender, TreeViewEventArgs e) + { + if (e?.Node?.Nodes.Count == 0) + { + checkBoxShortcutsControl.Checked = false; + checkBoxShortcutsAlt.Checked = false; + checkBoxShortcutsShift.Checked = false; + + checkBoxShortcutsControl.Enabled = true; + checkBoxShortcutsAlt.Enabled = true; + checkBoxShortcutsShift.Enabled = true; + + comboBoxShortcutKey.SelectedIndex = 0; + + comboBoxShortcutKey.Enabled = true; + buttonUpdateShortcut.Enabled = true; + buttonClearShortcut.Enabled = true; + + string shortcut = GetShortcut(e.Node.Text); + + string[] parts = shortcut.ToLowerInvariant().Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries); + foreach (string k in parts) + { + if (k.Equals("CONTROL", StringComparison.OrdinalIgnoreCase)) + { + checkBoxShortcutsControl.Checked = true; + } + else if (k.Equals("ALT", StringComparison.OrdinalIgnoreCase)) + { + checkBoxShortcutsAlt.Checked = true; + } + else if (k.Equals("SHIFT", StringComparison.OrdinalIgnoreCase)) + { + checkBoxShortcutsShift.Checked = true; + } + else + { + int i = 0; + foreach (string value in comboBoxShortcutKey.Items) + { + if (value.Equals(k, StringComparison.OrdinalIgnoreCase)) + { + comboBoxShortcutKey.SelectedIndex = i; + break; + } + i++; + } + } + } + } + } + + private static string GetShortcut(string text) + { + string shortcut = text.Substring(text.IndexOf('[')); + shortcut = shortcut.TrimEnd(']').TrimStart('['); + if (shortcut == Configuration.Settings.Language.General.None) + { + return string.Empty; + } + + return shortcut; + } + + private string GetCurrentShortcutText() + { + var sb = new StringBuilder(@"["); + if (checkBoxShortcutsControl.Checked) + { + sb.Append("Control+"); + } + + if (checkBoxShortcutsAlt.Checked) + { + sb.Append("Alt+"); + } + + if (checkBoxShortcutsShift.Checked) + { + sb.Append("Shift+"); + } + + sb.Append(comboBoxShortcutKey.Items[comboBoxShortcutKey.SelectedIndex]); + sb.Append(']'); + return sb.ToString(); + } + + private void buttonUpdateShortcut_Click(object sender, EventArgs e) + { + if (!IsShortcutValid()) + { + return; + } + + string text = treeViewShortcuts.SelectedNode.Text.Substring(0, treeViewShortcuts.SelectedNode.Text.IndexOf('[')).Trim(); + var shortcutText = GetCurrentShortcutText(); + var existsIn = new StringBuilder(); + var sh = (ShortcutHelper)treeViewShortcuts.SelectedNode.Tag; + foreach (ShortcutNode parent in _shortcuts.Nodes) + { + foreach (ShortcutNode subNode in parent.Nodes) + { + if (sh != null && subNode.Shortcut.Shortcut.Name == sh.Shortcut.Name) + { + subNode.Text = text + " " + shortcutText; + } + else if (subNode.Text.Contains(shortcutText) && treeViewShortcuts.SelectedNode.Text != subNode.Text) + { + existsIn.AppendLine(string.Format(Configuration.Settings.Language.Settings.ShortcutIsAlreadyDefinedX, parent.Text + " -> " + subNode.Text)); + } + } + } + if (existsIn.Length > 0 && comboBoxShortcutKey.SelectedIndex > 0) + { + if (MessageBox.Show(existsIn.ToString(), string.Empty, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) + { + return; + } + } + treeViewShortcuts.SelectedNode.Text = text + " " + shortcutText; + AddToSaveList((ShortcutHelper)treeViewShortcuts.SelectedNode.Tag, shortcutText); + treeViewShortcuts.Focus(); + } + + private void AddToSaveList(ShortcutHelper helper, string shortcutText) + { + if (_newShortcuts.ContainsKey(helper)) + { + _newShortcuts[helper] = GetShortcut(shortcutText); + } + else + { + _newShortcuts.Add(helper, GetShortcut(shortcutText)); + } + } + + private void buttonListViewSyntaxColorError_Click(object sender, EventArgs e) + { + colorDialogSSAStyle.Color = panelListViewSyntaxColorError.BackColor; + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + panelListViewSyntaxColorError.BackColor = colorDialogSSAStyle.Color; + } + } + + private void comboBoxShortcutKey_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Tab || + e.KeyCode == Keys.Down || + e.KeyCode == Keys.Up || + e.KeyCode == Keys.Enter || + e.KeyCode == Keys.None) + { + return; + } + + int i = 0; + foreach (var item in comboBoxShortcutKey.Items) + { + if (item.ToString() == e.KeyCode.ToString()) + { + comboBoxShortcutKey.SelectedIndex = i; + e.SuppressKeyPress = true; + return; + } + i++; + } + } + + private void numericUpDownSsaOutline_ValueChanged(object sender, EventArgs e) + { + UpdateSsaExample(); + } + + private void numericUpDownSsaShadow_ValueChanged(object sender, EventArgs e) + { + UpdateSsaExample(); + } + + private void checkBoxSsaOpaqueBox_CheckedChanged(object sender, EventArgs e) + { + numericUpDownSsaOutline.Enabled = !checkBoxSsaOpaqueBox.Checked; + numericUpDownSsaShadow.Enabled = !checkBoxSsaOpaqueBox.Checked; + UpdateSsaExample(); + } + + private void buttonBrowseToFFmpeg_Click(object sender, EventArgs e) + { + openFileDialogFFmpeg.FileName = string.Empty; + openFileDialogFFmpeg.Title = Configuration.Settings.Language.Settings.WaveformBrowseToFFmpeg; + if (Configuration.IsRunningOnWindows) + { + openFileDialogFFmpeg.Filter = "FFmpeg (ffmpeg.exe)|ffmpeg.exe"; + } + if (openFileDialogFFmpeg.ShowDialog(this) == DialogResult.OK) + { + textBoxFFmpegPath.Text = openFileDialogFFmpeg.FileName; + } + } + + private void checkBoxWaveformHoverFocus_CheckedChanged(object sender, EventArgs e) + { + checkBoxListViewMouseEnterFocus.Enabled = checkBoxWaveformHoverFocus.Checked; + } + + private void buttonVlcPathBrowse_Click(object sender, EventArgs e) + { + openFileDialogFFmpeg.FileName = string.Empty; + openFileDialogFFmpeg.Title = Configuration.Settings.Language.Settings.WaveformBrowseToVLC; + if (Configuration.IsRunningOnWindows) + { + openFileDialogFFmpeg.Filter = $"{Configuration.Settings.Language.Settings.VlcMediaPlayer} (vlc.exe)|vlc.exe"; + } + if (openFileDialogFFmpeg.ShowDialog(this) == DialogResult.OK) + { + EnableVlc(openFileDialogFFmpeg.FileName); + } + } + + private void EnableVlc(string fileName) + { + textBoxVlcPath.Text = Path.GetDirectoryName(fileName); + Configuration.Settings.General.VlcLocation = textBoxVlcPath.Text; + Configuration.Settings.General.VlcLocationRelative = GetRelativePath(textBoxVlcPath.Text); + radioButtonVideoPlayerVLC.Enabled = LibVlcDynamic.IsInstalled; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + Configuration.Settings.General.VlcLocation = _oldVlcLocation; + Configuration.Settings.General.VlcLocationRelative = _oldVlcLocationRelative; + Configuration.Settings.Tools.ListViewShowColumnCharsPerSec = _oldListViewShowCps; + Configuration.Settings.Tools.ListViewShowColumnWordsPerMin = _oldListViewShowWpm; + + DialogResult = DialogResult.Cancel; + } + + private void buttonEditDoNotBreakAfterList_Click(object sender, EventArgs e) + { + using (var form = new DoNotBreakAfterListEdit()) + { + form.ShowDialog(this); + } + } + + private void linkLabelOpenDictionaryFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + string dictionaryFolder = Utilities.DictionaryFolder; + if (!Directory.Exists(dictionaryFolder)) + { + Directory.CreateDirectory(dictionaryFolder); + } + + UiUtil.OpenFolder(dictionaryFolder); + } + + private void textBoxVlcPath_MouseLeave(object sender, EventArgs e) + { + try + { + var path = textBoxVlcPath.Text.Trim('\"'); + if (path.Length > 3 && Path.IsPathRooted(path) && Path.GetFileName(path).Equals("vlc.exe", StringComparison.OrdinalIgnoreCase) && File.Exists(path)) + { + EnableVlc(path); + } + } + catch + { + // ignored + } + } + + private void buttonNetworkSessionNewMessageSound_Click(object sender, EventArgs e) + { + openFileDialogFFmpeg.FileName = string.Empty; + openFileDialogFFmpeg.Title = Configuration.Settings.Language.Settings.WaveformBrowseToFFmpeg; + openFileDialogFFmpeg.Filter = $"{Configuration.Settings.Language.General.AudioFiles} (*.wav)|*.wav"; + if (openFileDialogFFmpeg.ShowDialog(this) == DialogResult.OK) + { + textBoxNetworkSessionNewMessageSound.Text = openFileDialogFFmpeg.FileName; + } + } + + private void panelPrimaryColor_MouseClick(object sender, MouseEventArgs e) + { + colorDialogSSAStyle.Color = Color.FromArgb(_ssaFontColor); + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + _ssaFontColor = colorDialogSSAStyle.Color.ToArgb(); + panelPrimaryColor.BackColor = colorDialogSSAStyle.Color; + UpdateSsaExample(); + } + } + + private void numericUpDownSsaMarginVertical_ValueChanged(object sender, EventArgs e) + { + UpdateSsaExample(); + } + + private void comboBoxFontName_TextChanged(object sender, EventArgs e) + { + _ssaFontName = comboBoxFontName.Text; + UpdateSsaExample(); + } + + private void numericUpDownFontSize_ValueChanged(object sender, EventArgs e) + { + _ssaFontSize = (int)numericUpDownFontSize.Value; + UpdateSsaExample(); + } + + private void buttonSsaColor_Click(object sender, EventArgs e) + { + panelPrimaryColor_MouseClick(sender, null); + } + + private void checkBoxSsaFontBold_CheckedChanged(object sender, EventArgs e) + { + UpdateSsaExample(); + } + + private void buttonMpvSettings_Click(object sender, EventArgs e) + { + using (var form = new SettingsMpv(LibMpvDynamic.IsInstalled)) + { + var oldMpvEnabled = radioButtonVideoPlayerMPV.Enabled; + if (form.ShowDialog(this) == DialogResult.OK) + { + RefreshMpvSettings(); + if (radioButtonVideoPlayerMPV.Enabled && !oldMpvEnabled) + { + radioButtonVideoPlayerMPV.Checked = true; + } + } + else + { + RefreshMpvSettings(); + } + } + } + + private void RefreshMpvSettings() + { + radioButtonVideoPlayerMPV.Enabled = LibMpvDynamic.IsInstalled; + checkBoxMpvHandlesPreviewText.Enabled = radioButtonVideoPlayerMPV.Enabled; + if (!radioButtonVideoPlayerMPV.Enabled) + { + buttonMpvSettings.Font = new Font(buttonMpvSettings.Font.FontFamily, buttonMpvSettings.Font.Size, FontStyle.Bold); + } + + labelMpvSettings.Text = "--vo=" + Configuration.Settings.General.MpvVideoOutputWindows; + } + + private void linkLabelBingSubscribe_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + UiUtil.OpenURL(MicrosoftTranslator.SignUpUrl); + } + + private void ValidateShortcut(object sender, EventArgs e) + { + buttonUpdateShortcut.Enabled = IsShortcutValid(); + } + + private bool IsShortcutValid() + { + if (treeViewShortcuts.SelectedNode == null || !treeViewShortcuts.SelectedNode.Text.Contains('[')) + { + return false; + } + + var shortcutText = GetCurrentShortcutText(); + if (shortcutText == "[CapsLock]" || shortcutText.Length < 3 || shortcutText.EndsWith("+]")) + { + return false; + } + + if (comboBoxShortcutKey.SelectedIndex == 0 && !checkBoxShortcutsControl.Checked && !checkBoxShortcutsAlt.Checked && !checkBoxShortcutsShift.Checked) + { + return true; + } + + var helper = (ShortcutHelper)treeViewShortcuts.SelectedNode.Tag; + if (helper.IsMenuItem) + { + try + { + new ToolStripMenuItem().ShortcutKeys = UiUtil.GetKeys(GetShortcut(shortcutText)); + } + catch (InvalidEnumArgumentException) + { + return false; + } + } + return true; + } + + private void numericUpDownMaxNumberOfLines_ValueChanged(object sender, EventArgs e) + { + checkBoxSyntaxColorTextMoreThanTwoLines.Text = string.Format(Configuration.Settings.Language.Settings.SyntaxColorTextMoreThanMaxLines, numericUpDownMaxNumberOfLines.Value); + ProfileUiValueChanged(sender, e); + } + + private void radioButtonVideoPlayerMPV_CheckedChanged(object sender, EventArgs e) + { + checkBoxMpvHandlesPreviewText.Enabled = radioButtonVideoPlayerMPV.Checked; + } + + private void buttonClearShortcut_Click(object sender, EventArgs e) + { + checkBoxShortcutsControl.Checked = false; + checkBoxShortcutsAlt.Checked = false; + checkBoxShortcutsShift.Checked = false; + comboBoxShortcutKey.SelectedIndex = 0; + buttonUpdateShortcut_Click(null, null); + } + + private void buttonDownloadFfmpeg_Click(object sender, EventArgs e) + { + using (var form = new DownloadFfmpeg()) + { + if (form.ShowDialog(this) == DialogResult.OK && !string.IsNullOrEmpty(form.FFmpegPath)) + { + textBoxFFmpegPath.Text = form.FFmpegPath; + } + } + } + + private void textBoxShortcutSearch_TextChanged(object sender, EventArgs e) + { + var selected = treeViewShortcuts.SelectedNode?.Tag as ShortcutHelper; + var oldControl = checkBoxShortcutsControl.Checked; + var oldAlt = checkBoxShortcutsAlt.Checked; + var oldShift = checkBoxShortcutsShift.Checked; + var oldKeyIndex = comboBoxShortcutKey.SelectedIndex; + ShowShortcutsTreeView(); + buttonShortcutsClear.Enabled = textBoxShortcutSearch.Text.Length > 0; + if (selected != null) + { + foreach (TreeNode parentNode in treeViewShortcuts.Nodes) + { + foreach (TreeNode node in parentNode.Nodes) + { + if (node.Tag is ShortcutHelper sh && sh.Shortcut.Name == selected.Shortcut.Name) + { + treeViewShortcuts.SelectedNode = node; + checkBoxShortcutsControl.Checked = oldControl; + checkBoxShortcutsAlt.Checked = oldAlt; + checkBoxShortcutsShift.Checked = oldShift; + comboBoxShortcutKey.SelectedIndex = oldKeyIndex; + return; + } + } + } + } + comboBoxShortcutKey.Enabled = false; + buttonUpdateShortcut.Enabled = false; + buttonClearShortcut.Enabled = false; + } + + private void buttonShortcutsClear_Click(object sender, EventArgs e) + { + textBoxShortcutSearch.Text = string.Empty; + } + + private void linkLabelGoogleTranslateSignUp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + UiUtil.OpenURL("https://www.google.com/search?q=google+cloud+get+api+key"); + } + + private void buttonEditProfile_Click(object sender, EventArgs e) + { + using (var form = new SettingsProfile(_rulesProfiles, comboBoxRulesProfileName.Text)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + _rulesProfiles = form.RulesProfiles; + UpdateProfileNames(_rulesProfiles); + } + } + } + + private bool _editProfileOn; + private void comboBoxRulesProfileName_SelectedIndexChanged(object sender, EventArgs e) + { + _editProfileOn = true; + var profile = _rulesProfiles.First(p => p.Name == comboBoxRulesProfileName.Text); + numericUpDownSubtitleLineMaximumLength.Value = profile.SubtitleLineMaximumLength; + numericUpDownOptimalCharsSec.Value = profile.SubtitleOptimalCharactersPerSeconds; + numericUpDownMaxCharsSec.Value = profile.SubtitleMaximumCharactersPerSeconds; + numericUpDownMaxWordsMin.Value = profile.SubtitleMaximumWordsPerMinute; + numericUpDownDurationMin.Value = profile.SubtitleMinimumDisplayMilliseconds; + numericUpDownDurationMax.Value = profile.SubtitleMaximumDisplayMilliseconds; + if (profile.MinimumMillisecondsBetweenLines >= numericUpDownMinGapMs.Minimum && + profile.MinimumMillisecondsBetweenLines <= numericUpDownMinGapMs.Maximum) + { + numericUpDownMinGapMs.Value = profile.MinimumMillisecondsBetweenLines; + } + if (profile.MaxNumberOfLines >= numericUpDownMaxNumberOfLines.Minimum && + profile.MaxNumberOfLines <= numericUpDownMaxNumberOfLines.Maximum) + { + numericUpDownMaxNumberOfLines.Value = profile.MaxNumberOfLines; + } + else + { + numericUpDownMaxNumberOfLines.Value = numericUpDownMaxNumberOfLines.Minimum; + } + + if (profile.MergeLinesShorterThan >= 5 && profile.MergeLinesShorterThan - 5 < comboBoxMergeShortLineLength.Items.Count) + { + comboBoxMergeShortLineLength.SelectedIndex = profile.MergeLinesShorterThan - 5; + } + else + { + comboBoxMergeShortLineLength.SelectedIndex = 0; + } + + SetDialogStyle(profile.DialogStyle); + SetContinuationStyle(profile.ContinuationStyle); + + checkBoxCpsIncludeWhiteSpace.Checked = profile.CpsIncludesSpace; + _oldProfileId = profile.Id; + _editProfileOn = false; + } + + private void ProfileUiValueChanged(object sender, EventArgs e) + { + var idx = comboBoxRulesProfileName.SelectedIndex; + if (idx < 0 || _editProfileOn || idx >= _rulesProfiles.Count) + { + return; + } + _rulesProfiles[idx].SubtitleLineMaximumLength = (int)numericUpDownSubtitleLineMaximumLength.Value; + _rulesProfiles[idx].SubtitleOptimalCharactersPerSeconds = numericUpDownOptimalCharsSec.Value; + _rulesProfiles[idx].SubtitleMaximumCharactersPerSeconds = numericUpDownMaxCharsSec.Value; + _rulesProfiles[idx].SubtitleMinimumDisplayMilliseconds = (int)numericUpDownDurationMin.Value; + _rulesProfiles[idx].SubtitleMaximumDisplayMilliseconds = (int)numericUpDownDurationMax.Value; + _rulesProfiles[idx].MinimumMillisecondsBetweenLines = (int)numericUpDownMinGapMs.Value; + _rulesProfiles[idx].MaxNumberOfLines = (int)numericUpDownMaxNumberOfLines.Value; + _rulesProfiles[idx].SubtitleMaximumWordsPerMinute = (int)numericUpDownMaxWordsMin.Value; + _rulesProfiles[idx].CpsIncludesSpace = checkBoxCpsIncludeWhiteSpace.Checked; + _rulesProfiles[idx].MergeLinesShorterThan = comboBoxMergeShortLineLength.SelectedIndex + 5; + _rulesProfiles[idx].DialogStyle = DialogSplitMerge.GetDialogStyleFromIndex(comboBoxDialogStyle.SelectedIndex); + _rulesProfiles[idx].ContinuationStyle = ContinuationUtilities.GetContinuationStyleFromIndex(comboBoxContinuationStyle.SelectedIndex); + + toolTipContinuationPreview.RemoveAll(); + toolTipContinuationPreview.SetToolTip(comboBoxContinuationStyle, ContinuationUtilities.GetContinuationStylePreview(_rulesProfiles[idx].ContinuationStyle)); + } + + private void checkBoxToolsBreakByPixelWidth_CheckedChanged(object sender, EventArgs e) + { + checkBoxToolsBreakPreferBottomHeavy.Enabled = checkBoxToolsBreakByPixelWidth.Checked; + numericUpDownToolsBreakPreferBottomHeavy.Enabled = checkBoxToolsBreakByPixelWidth.Checked; + } + + private void buttonReset_Click(object sender, EventArgs e) + { + var result = MessageBox.Show(Configuration.Settings.Language.Settings.RestoreDefaultSettingsMsg, Configuration.Settings.Language.General.Title, MessageBoxButtons.YesNo); + if (result == DialogResult.Yes) + { + Configuration.Settings.Reset(); + Configuration.Settings.General.VideoPlayer = "MPV"; + Init(); + } + } + + private void toolStripMenuItemShortcutsCollapse_Click(object sender, EventArgs e) + { + treeViewShortcuts.CollapseAll(); + } + + private void listBoxNames_DoubleClick(object sender, EventArgs e) + { + var idx = listBoxNames.SelectedIndex; + if (idx >= 0) + { + textBoxNameEtc.Text = (string)listBoxNames.Items[idx]; + } + } + + private void listBoxUserWordLists_DoubleClick(object sender, EventArgs e) + { + var idx = listBoxUserWordLists.SelectedIndex; + if (idx >= 0) + { + textBoxUserWord.Text = (string)listBoxUserWordLists.Items[idx]; + } + } + + private void listBoxOcrFixList_DoubleClick(object sender, EventArgs e) + { + var idx = listBoxOcrFixList.SelectedIndex; + if (idx >= 0) + { + var text = (string)listBoxOcrFixList.Items[idx]; + var splitIdx = text.IndexOf(" --> ", StringComparison.Ordinal); + if (splitIdx > 0) + { + textBoxOcrFixKey.Text = text.Substring(0, splitIdx); + textBoxOcrFixValue.Text = text.Remove(0, splitIdx + " --> ".Length); + } + } + } + + private void buttonLineWidthSettings_Click(object sender, EventArgs e) + { + using (var form = new SettingsLineWidth()) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + // Saving settings handled by dialog + } + } + } + + private void buttonFixContinuationStyleSettings_Click(object sender, EventArgs e) + { + using (var form = new SettingsFixContinuationStyle()) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + // Saving settings handled by dialog + } + } + } + + private void buttonGapChoose_Click(object sender, EventArgs e) + { + using (var form = new SettingsGapChoose()) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + numericUpDownMinGapMs.Value = form.MinGapMs; + } + } + } + + private void importShortcutsToolStripMenuItem_Click(object sender, EventArgs e) + { + openFileDialogFFmpeg.Title = null; + openFileDialogFFmpeg.Filter = "Xml files|*.xml"; + openFileDialogFFmpeg.FileName = "SE_Shortcuts"; + if (openFileDialogFFmpeg.ShowDialog(this) != DialogResult.OK) + { + return; + } + + try + { + Configuration.Settings.Shortcuts = Shortcuts.Load(openFileDialogFFmpeg.FileName); + textBoxShortcutSearch.Text = string.Empty; + MakeShortcutsTreeView(Configuration.Settings.Language.Settings); + ShowShortcutsTreeView(); + } + catch (Exception exception) + { + MessageBox.Show("Shortcuts not imported!" + Environment.NewLine + Environment.NewLine + + exception.Message + Environment.NewLine + + exception.StackTrace); + SeLogger.Error(exception, "Failed to import shortcuts"); + } + } + + private void exportShortcutsToolStripMenuItem_Click(object sender, EventArgs e) + { + saveFileDialog1.Filter = "Xml files|*.xml"; + saveFileDialog1.FileName = "SE_Shortcuts"; + if (saveFileDialog1.ShowDialog(this) != DialogResult.OK) + { + return; + } + + try + { + var shortcuts = Configuration.Settings.Shortcuts.Clone(); + foreach (var kvp in _newShortcuts) + { + kvp.Key.Shortcut.SetValue(shortcuts, kvp.Value, null); + } + + Shortcuts.Save(saveFileDialog1.FileName, shortcuts); + } + catch (Exception exception) + { + MessageBox.Show(exception.Message + Environment.NewLine + + exception.StackTrace); + SeLogger.Error(exception, "Failed to export shortcuts"); + } + } + + private void pictureBoxPreview_Click(object sender, EventArgs e) + { + _backgroundImageDark = !_backgroundImageDark; + GeneratePreviewReal(); + } + + private void buttonTextBoxHtmlColor_Click(object sender, EventArgs e) + { + colorDialogSSAStyle.Color = panelTextBoxHtmlColor.BackColor; + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + panelTextBoxHtmlColor.BackColor = colorDialogSSAStyle.Color; + } + } + + private void buttonTextBoxAssColor_Click(object sender, EventArgs e) + { + colorDialogSSAStyle.Color = panelTextBoxAssColor.BackColor; + if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) + { + panelTextBoxAssColor.BackColor = colorDialogSSAStyle.Color; + } + } + + private void checkBoxSubtitleTextBoxSyntaxColor_CheckedChanged(object sender, EventArgs e) + { + buttonTextBoxHtmlColor.Enabled = checkBoxSubtitleTextBoxSyntaxColor.Checked; + panelTextBoxHtmlColor.Enabled = checkBoxSubtitleTextBoxSyntaxColor.Checked; + buttonTextBoxAssColor.Enabled = checkBoxSubtitleTextBoxSyntaxColor.Checked; + panelTextBoxAssColor.Enabled = checkBoxSubtitleTextBoxSyntaxColor.Checked; + } + + private void panelTextBoxHtmlColor_MouseClick(object sender, MouseEventArgs e) + { + buttonTextBoxHtmlColor_Click(null, null); + } + + private void panelTextBoxAssColor_MouseClick(object sender, MouseEventArgs e) + { + buttonTextBoxAssColor_Click(null, null); + } + } +} diff --git a/src/Forms/Settings.resx b/src/ui/Forms/Settings.resx similarity index 98% rename from src/Forms/Settings.resx rename to src/ui/Forms/Settings.resx index dac0a5333..683a8b0b8 100644 --- a/src/Forms/Settings.resx +++ b/src/ui/Forms/Settings.resx @@ -1,135 +1,135 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 464, 17 - - - 17, 17 - - - 287, 17 - - - 664, 17 - - - 867, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 464, 17 + + + 17, 17 + + + 287, 17 + + + 664, 17 + + + 867, 17 + \ No newline at end of file diff --git a/src/Forms/SettingsFixContinuationStyle.Designer.cs b/src/ui/Forms/SettingsFixContinuationStyle.Designer.cs similarity index 100% rename from src/Forms/SettingsFixContinuationStyle.Designer.cs rename to src/ui/Forms/SettingsFixContinuationStyle.Designer.cs diff --git a/src/Forms/SettingsFixContinuationStyle.cs b/src/ui/Forms/SettingsFixContinuationStyle.cs similarity index 100% rename from src/Forms/SettingsFixContinuationStyle.cs rename to src/ui/Forms/SettingsFixContinuationStyle.cs diff --git a/src/ui/Forms/SettingsFixContinuationStyle.resx b/src/ui/Forms/SettingsFixContinuationStyle.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/src/ui/Forms/SettingsFixContinuationStyle.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Forms/SettingsGapChoose.Designer.cs b/src/ui/Forms/SettingsGapChoose.Designer.cs similarity index 100% rename from src/Forms/SettingsGapChoose.Designer.cs rename to src/ui/Forms/SettingsGapChoose.Designer.cs diff --git a/src/Forms/SettingsGapChoose.cs b/src/ui/Forms/SettingsGapChoose.cs similarity index 100% rename from src/Forms/SettingsGapChoose.cs rename to src/ui/Forms/SettingsGapChoose.cs diff --git a/src/ui/Forms/SettingsGapChoose.resx b/src/ui/Forms/SettingsGapChoose.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/src/ui/Forms/SettingsGapChoose.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Forms/SettingsLineWidth.Designer.cs b/src/ui/Forms/SettingsLineWidth.Designer.cs similarity index 100% rename from src/Forms/SettingsLineWidth.Designer.cs rename to src/ui/Forms/SettingsLineWidth.Designer.cs diff --git a/src/Forms/SettingsLineWidth.cs b/src/ui/Forms/SettingsLineWidth.cs similarity index 100% rename from src/Forms/SettingsLineWidth.cs rename to src/ui/Forms/SettingsLineWidth.cs diff --git a/src/ui/Forms/SettingsLineWidth.resx b/src/ui/Forms/SettingsLineWidth.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/src/ui/Forms/SettingsLineWidth.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Forms/SettingsMpv.Designer.cs b/src/ui/Forms/SettingsMpv.Designer.cs similarity index 97% rename from src/Forms/SettingsMpv.Designer.cs rename to src/ui/Forms/SettingsMpv.Designer.cs index 40ed1c8e0..fddb961f0 100644 --- a/src/Forms/SettingsMpv.Designer.cs +++ b/src/ui/Forms/SettingsMpv.Designer.cs @@ -1,144 +1,144 @@ -namespace Nikse.SubtitleEdit.Forms -{ - using Nikse.SubtitleEdit.Core; - - sealed partial class SettingsMpv - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonDownload = new System.Windows.Forms.Button(); - this.comboBoxVideoOutput = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.labelPleaseWait = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // buttonDownload - // - this.buttonDownload.Location = new System.Drawing.Point(12, 24); - this.buttonDownload.Name = "buttonDownload"; - this.buttonDownload.Size = new System.Drawing.Size(186, 23); - this.buttonDownload.TabIndex = 0; - this.buttonDownload.Text = "Download mpv dll"; - this.buttonDownload.UseVisualStyleBackColor = true; - this.buttonDownload.Click += new System.EventHandler(this.ButtonDownloadClick); - // - // comboBoxVideoOutput - // - this.comboBoxVideoOutput.FormattingEnabled = true; - this.comboBoxVideoOutput.Items.AddRange(new object[] { - "gpu", - "direct3d", - "opengl", - "sdl", - "vaapi", - "vdpau"}); - this.comboBoxVideoOutput.Location = new System.Drawing.Point(12, 109); - this.comboBoxVideoOutput.Name = "comboBoxVideoOutput"; - this.comboBoxVideoOutput.Size = new System.Drawing.Size(186, 21); - this.comboBoxVideoOutput.TabIndex = 1; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 93); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(67, 13); - this.label1.TabIndex = 2; - this.label1.Text = "Video output"; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(129, 163); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 4; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(210, 163); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // labelPleaseWait - // - this.labelPleaseWait.AutoSize = true; - this.labelPleaseWait.Location = new System.Drawing.Point(12, 50); - this.labelPleaseWait.Name = "labelPleaseWait"; - this.labelPleaseWait.Size = new System.Drawing.Size(70, 13); - this.labelPleaseWait.TabIndex = 13; - this.labelPleaseWait.Text = "Please wait..."; - // - // SettingsMpv - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(297, 198); - this.Controls.Add(this.labelPleaseWait); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.label1); - this.Controls.Add(this.comboBoxVideoOutput); - this.Controls.Add(this.buttonDownload); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "SettingsMpv"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Settings for mpv"; - this.Load += new System.EventHandler(this.SettingsMpv_Load); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonDownload; - private System.Windows.Forms.ComboBox comboBoxVideoOutput; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Label labelPleaseWait; - } +namespace Nikse.SubtitleEdit.Forms +{ + using Nikse.SubtitleEdit.Core; + + sealed partial class SettingsMpv + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonDownload = new System.Windows.Forms.Button(); + this.comboBoxVideoOutput = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.labelPleaseWait = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonDownload + // + this.buttonDownload.Location = new System.Drawing.Point(12, 24); + this.buttonDownload.Name = "buttonDownload"; + this.buttonDownload.Size = new System.Drawing.Size(186, 23); + this.buttonDownload.TabIndex = 0; + this.buttonDownload.Text = "Download mpv dll"; + this.buttonDownload.UseVisualStyleBackColor = true; + this.buttonDownload.Click += new System.EventHandler(this.ButtonDownloadClick); + // + // comboBoxVideoOutput + // + this.comboBoxVideoOutput.FormattingEnabled = true; + this.comboBoxVideoOutput.Items.AddRange(new object[] { + "gpu", + "direct3d", + "opengl", + "sdl", + "vaapi", + "vdpau"}); + this.comboBoxVideoOutput.Location = new System.Drawing.Point(12, 109); + this.comboBoxVideoOutput.Name = "comboBoxVideoOutput"; + this.comboBoxVideoOutput.Size = new System.Drawing.Size(186, 21); + this.comboBoxVideoOutput.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 93); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(67, 13); + this.label1.TabIndex = 2; + this.label1.Text = "Video output"; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(129, 163); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 4; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(210, 163); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // labelPleaseWait + // + this.labelPleaseWait.AutoSize = true; + this.labelPleaseWait.Location = new System.Drawing.Point(12, 50); + this.labelPleaseWait.Name = "labelPleaseWait"; + this.labelPleaseWait.Size = new System.Drawing.Size(70, 13); + this.labelPleaseWait.TabIndex = 13; + this.labelPleaseWait.Text = "Please wait..."; + // + // SettingsMpv + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(297, 198); + this.Controls.Add(this.labelPleaseWait); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.label1); + this.Controls.Add(this.comboBoxVideoOutput); + this.Controls.Add(this.buttonDownload); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SettingsMpv"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Settings for mpv"; + this.Load += new System.EventHandler(this.SettingsMpv_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonDownload; + private System.Windows.Forms.ComboBox comboBoxVideoOutput; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Label labelPleaseWait; + } } \ No newline at end of file diff --git a/src/Forms/SettingsMpv.cs b/src/ui/Forms/SettingsMpv.cs similarity index 97% rename from src/Forms/SettingsMpv.cs rename to src/ui/Forms/SettingsMpv.cs index 444e9d391..fda5a917c 100644 --- a/src/Forms/SettingsMpv.cs +++ b/src/ui/Forms/SettingsMpv.cs @@ -1,163 +1,163 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; -using Nikse.SubtitleEdit.Logic.VideoPlayers; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class SettingsMpv : Form - { - - private readonly bool _justDownload; - private string _downloadUrl; - - public SettingsMpv(bool justDownload) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _justDownload = justDownload; - labelPleaseWait.Text = string.Empty; - if (Configuration.IsRunningOnLinux) - { - comboBoxVideoOutput.Text = Configuration.Settings.General.MpvVideoOutputLinux; - } - else - { - comboBoxVideoOutput.Text = Configuration.Settings.General.MpvVideoOutputWindows; - } - - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - Text = Configuration.Settings.Language.SettingsMpv.Title; - if (!Configuration.IsRunningOnLinux) - { - buttonDownload.Text = Configuration.Settings.Language.SettingsMpv.DownloadMpv; - } - - if (Configuration.IsRunningOnLinux) - { - comboBoxVideoOutput.Items.Clear(); - comboBoxVideoOutput.Items.AddRange(new object[] { "vaapi", "opengl", "sdl", "vdpau" }); - Controls.Remove(buttonDownload); - } - UiUtil.FixLargeFonts(this, buttonOK); - - if (justDownload) - { - comboBoxVideoOutput.Enabled = false; - } - } - - private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) - { - if (e.Error != null) - { - MessageBox.Show(Configuration.Settings.Language.SettingsMpv.DownloadMpvFailed + Environment.NewLine + - Environment.NewLine + - $"Manual action: Download \"{_downloadUrl}\" and unpack to \"{Configuration.DataDirectory}\"." + Environment.NewLine + - Environment.NewLine + - e.Error.Message); - labelPleaseWait.Text = string.Empty; - buttonOK.Enabled = true; - buttonDownload.Enabled = !Configuration.IsRunningOnLinux; - Cursor = Cursors.Default; - return; - } - - string dictionaryFolder = Configuration.DataDirectory; - using (var ms = new MemoryStream(e.Result)) - using (ZipExtractor zip = ZipExtractor.Open(ms)) - { - List dir = zip.ReadCentralDir(); - foreach (ZipExtractor.ZipFileEntry entry in dir) - { - if (entry.FilenameInZip.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) - { - string fileName = Path.GetFileName(entry.FilenameInZip); - string path = Path.Combine(dictionaryFolder, fileName); - - try - { - zip.ExtractFile(entry, path); - } - catch - { - path = Path.Combine(dictionaryFolder, fileName + ".new-mpv"); - zip.ExtractFile(entry, path); - } - } - } - } - - Cursor = Cursors.Default; - labelPleaseWait.Text = string.Empty; - buttonOK.Enabled = true; - buttonDownload.Enabled = !Configuration.IsRunningOnLinux; - - MessageBox.Show(Configuration.Settings.Language.SettingsMpv.DownloadMpvOk); - if (_justDownload) - { - DialogResult = DialogResult.OK; - } - } - - - private void ButtonDownloadClick(object sender, EventArgs e) - { - try - { - labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; - buttonOK.Enabled = false; - buttonDownload.Enabled = false; - Refresh(); - Cursor = Cursors.WaitCursor; - _downloadUrl = "https://github.com/SubtitleEdit/support-files/blob/master/mpv/libmpv" + IntPtr.Size * 8 + ".zip?raw=true"; - var wc = new WebClient { Proxy = Utilities.GetProxy() }; - - wc.DownloadDataCompleted += wc_DownloadDataCompleted; - wc.DownloadProgressChanged += (o, args) => - { - labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait + " " + args.ProgressPercentage + "%"; - }; - wc.DownloadDataAsync(new Uri(_downloadUrl)); - } - catch (Exception exception) - { - labelPleaseWait.Text = string.Empty; - buttonOK.Enabled = true; - buttonDownload.Enabled = !Configuration.IsRunningOnLinux; - Cursor = Cursors.Default; - MessageBox.Show(exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace); - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - if (!string.IsNullOrWhiteSpace(comboBoxVideoOutput.Text)) - { - Configuration.Settings.General.MpvVideoOutputWindows = comboBoxVideoOutput.Text; - } - - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void SettingsMpv_Load(object sender, EventArgs e) - { - if (Configuration.IsRunningOnWindows && !LibMpvDynamic.IsInstalled) - { - ButtonDownloadClick(null, null); - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Logic.VideoPlayers; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class SettingsMpv : Form + { + + private readonly bool _justDownload; + private string _downloadUrl; + + public SettingsMpv(bool justDownload) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _justDownload = justDownload; + labelPleaseWait.Text = string.Empty; + if (Configuration.IsRunningOnLinux) + { + comboBoxVideoOutput.Text = Configuration.Settings.General.MpvVideoOutputLinux; + } + else + { + comboBoxVideoOutput.Text = Configuration.Settings.General.MpvVideoOutputWindows; + } + + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + Text = Configuration.Settings.Language.SettingsMpv.Title; + if (!Configuration.IsRunningOnLinux) + { + buttonDownload.Text = Configuration.Settings.Language.SettingsMpv.DownloadMpv; + } + + if (Configuration.IsRunningOnLinux) + { + comboBoxVideoOutput.Items.Clear(); + comboBoxVideoOutput.Items.AddRange(new object[] { "vaapi", "opengl", "sdl", "vdpau" }); + Controls.Remove(buttonDownload); + } + UiUtil.FixLargeFonts(this, buttonOK); + + if (justDownload) + { + comboBoxVideoOutput.Enabled = false; + } + } + + private void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) + { + if (e.Error != null) + { + MessageBox.Show(Configuration.Settings.Language.SettingsMpv.DownloadMpvFailed + Environment.NewLine + + Environment.NewLine + + $"Manual action: Download \"{_downloadUrl}\" and unpack to \"{Configuration.DataDirectory}\"." + Environment.NewLine + + Environment.NewLine + + e.Error.Message); + labelPleaseWait.Text = string.Empty; + buttonOK.Enabled = true; + buttonDownload.Enabled = !Configuration.IsRunningOnLinux; + Cursor = Cursors.Default; + return; + } + + string dictionaryFolder = Configuration.DataDirectory; + using (var ms = new MemoryStream(e.Result)) + using (ZipExtractor zip = ZipExtractor.Open(ms)) + { + List dir = zip.ReadCentralDir(); + foreach (ZipExtractor.ZipFileEntry entry in dir) + { + if (entry.FilenameInZip.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) + { + string fileName = Path.GetFileName(entry.FilenameInZip); + string path = Path.Combine(dictionaryFolder, fileName); + + try + { + zip.ExtractFile(entry, path); + } + catch + { + path = Path.Combine(dictionaryFolder, fileName + ".new-mpv"); + zip.ExtractFile(entry, path); + } + } + } + } + + Cursor = Cursors.Default; + labelPleaseWait.Text = string.Empty; + buttonOK.Enabled = true; + buttonDownload.Enabled = !Configuration.IsRunningOnLinux; + + MessageBox.Show(Configuration.Settings.Language.SettingsMpv.DownloadMpvOk); + if (_justDownload) + { + DialogResult = DialogResult.OK; + } + } + + + private void ButtonDownloadClick(object sender, EventArgs e) + { + try + { + labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; + buttonOK.Enabled = false; + buttonDownload.Enabled = false; + Refresh(); + Cursor = Cursors.WaitCursor; + _downloadUrl = "https://github.com/SubtitleEdit/support-files/blob/master/mpv/libmpv" + IntPtr.Size * 8 + ".zip?raw=true"; + var wc = new WebClient { Proxy = Utilities.GetProxy() }; + + wc.DownloadDataCompleted += wc_DownloadDataCompleted; + wc.DownloadProgressChanged += (o, args) => + { + labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait + " " + args.ProgressPercentage + "%"; + }; + wc.DownloadDataAsync(new Uri(_downloadUrl)); + } + catch (Exception exception) + { + labelPleaseWait.Text = string.Empty; + buttonOK.Enabled = true; + buttonDownload.Enabled = !Configuration.IsRunningOnLinux; + Cursor = Cursors.Default; + MessageBox.Show(exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace); + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + if (!string.IsNullOrWhiteSpace(comboBoxVideoOutput.Text)) + { + Configuration.Settings.General.MpvVideoOutputWindows = comboBoxVideoOutput.Text; + } + + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void SettingsMpv_Load(object sender, EventArgs e) + { + if (Configuration.IsRunningOnWindows && !LibMpvDynamic.IsInstalled) + { + ButtonDownloadClick(null, null); + } + } + } +} diff --git a/src/Forms/SettingsMpv.resx b/src/ui/Forms/SettingsMpv.resx similarity index 97% rename from src/Forms/SettingsMpv.resx rename to src/ui/Forms/SettingsMpv.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/SettingsMpv.resx +++ b/src/ui/Forms/SettingsMpv.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/SettingsProfile.Designer.cs b/src/ui/Forms/SettingsProfile.Designer.cs similarity index 100% rename from src/Forms/SettingsProfile.Designer.cs rename to src/ui/Forms/SettingsProfile.Designer.cs diff --git a/src/Forms/SettingsProfile.cs b/src/ui/Forms/SettingsProfile.cs similarity index 100% rename from src/Forms/SettingsProfile.cs rename to src/ui/Forms/SettingsProfile.cs diff --git a/src/Forms/SettingsProfile.resx b/src/ui/Forms/SettingsProfile.resx similarity index 100% rename from src/Forms/SettingsProfile.resx rename to src/ui/Forms/SettingsProfile.resx diff --git a/src/Forms/SettingsProfileExport.Designer.cs b/src/ui/Forms/SettingsProfileExport.Designer.cs similarity index 100% rename from src/Forms/SettingsProfileExport.Designer.cs rename to src/ui/Forms/SettingsProfileExport.Designer.cs diff --git a/src/Forms/SettingsProfileExport.cs b/src/ui/Forms/SettingsProfileExport.cs similarity index 100% rename from src/Forms/SettingsProfileExport.cs rename to src/ui/Forms/SettingsProfileExport.cs diff --git a/src/Forms/SettingsProfileExport.resx b/src/ui/Forms/SettingsProfileExport.resx similarity index 100% rename from src/Forms/SettingsProfileExport.resx rename to src/ui/Forms/SettingsProfileExport.resx diff --git a/src/Forms/ShowEarlierLater.Designer.cs b/src/ui/Forms/ShowEarlierLater.Designer.cs similarity index 98% rename from src/Forms/ShowEarlierLater.Designer.cs rename to src/ui/Forms/ShowEarlierLater.Designer.cs index 20193cc14..40733f66e 100644 --- a/src/Forms/ShowEarlierLater.Designer.cs +++ b/src/ui/Forms/ShowEarlierLater.Designer.cs @@ -1,185 +1,185 @@ -using Nikse.SubtitleEdit.Controls; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ShowEarlierLater - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - TimeCode timeCode1 = new TimeCode(); - this.labelHourMinSecMilliSecond = new System.Windows.Forms.Label(); - this.buttonShowLater = new System.Windows.Forms.Button(); - this.buttonShowEarlier = new System.Windows.Forms.Button(); - this.labelTotalAdjustment = new System.Windows.Forms.Label(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.radioButtonAllLines = new System.Windows.Forms.RadioButton(); - this.radioButtonSelectedLinesOnly = new System.Windows.Forms.RadioButton(); - this.timeUpDownAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.radioButtonSelectedLineAndForward = new System.Windows.Forms.RadioButton(); - this.SuspendLayout(); - // - // labelHourMinSecMilliSecond - // - this.labelHourMinSecMilliSecond.AutoSize = true; - this.labelHourMinSecMilliSecond.Location = new System.Drawing.Point(11, 6); - this.labelHourMinSecMilliSecond.Name = "labelHourMinSecMilliSecond"; - this.labelHourMinSecMilliSecond.Size = new System.Drawing.Size(108, 13); - this.labelHourMinSecMilliSecond.TabIndex = 18; - this.labelHourMinSecMilliSecond.Text = "Hours:min:sec.msecs"; - // - // buttonShowLater - // - this.buttonShowLater.Location = new System.Drawing.Point(145, 55); - this.buttonShowLater.Name = "buttonShowLater"; - this.buttonShowLater.Size = new System.Drawing.Size(119, 23); - this.buttonShowLater.TabIndex = 20; - this.buttonShowLater.Text = "Show later"; - this.buttonShowLater.UseVisualStyleBackColor = true; - this.buttonShowLater.Click += new System.EventHandler(this.ButtonShowLaterClick); - // - // buttonShowEarlier - // - this.buttonShowEarlier.Location = new System.Drawing.Point(145, 26); - this.buttonShowEarlier.Name = "buttonShowEarlier"; - this.buttonShowEarlier.Size = new System.Drawing.Size(120, 23); - this.buttonShowEarlier.TabIndex = 19; - this.buttonShowEarlier.Text = "Show earlier"; - this.buttonShowEarlier.UseVisualStyleBackColor = true; - this.buttonShowEarlier.Click += new System.EventHandler(this.ButtonShowEarlierClick); - // - // labelTotalAdjustment - // - this.labelTotalAdjustment.AutoSize = true; - this.labelTotalAdjustment.Location = new System.Drawing.Point(9, 148); - this.labelTotalAdjustment.Name = "labelTotalAdjustment"; - this.labelTotalAdjustment.Size = new System.Drawing.Size(108, 13); - this.labelTotalAdjustment.TabIndex = 38; - this.labelTotalAdjustment.Text = "labelTotalAdjustment"; - // - // timer1 - // - this.timer1.Interval = 250; - // - // radioButtonAllLines - // - this.radioButtonAllLines.AutoSize = true; - this.radioButtonAllLines.Location = new System.Drawing.Point(14, 70); - this.radioButtonAllLines.Name = "radioButtonAllLines"; - this.radioButtonAllLines.Size = new System.Drawing.Size(60, 17); - this.radioButtonAllLines.TabIndex = 39; - this.radioButtonAllLines.TabStop = true; - this.radioButtonAllLines.Text = "All lines"; - this.radioButtonAllLines.UseVisualStyleBackColor = true; - this.radioButtonAllLines.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // - // radioButtonSelectedLinesOnly - // - this.radioButtonSelectedLinesOnly.AutoSize = true; - this.radioButtonSelectedLinesOnly.Location = new System.Drawing.Point(14, 93); - this.radioButtonSelectedLinesOnly.Name = "radioButtonSelectedLinesOnly"; - this.radioButtonSelectedLinesOnly.Size = new System.Drawing.Size(113, 17); - this.radioButtonSelectedLinesOnly.TabIndex = 40; - this.radioButtonSelectedLinesOnly.TabStop = true; - this.radioButtonSelectedLinesOnly.Text = "Selected lines only"; - this.radioButtonSelectedLinesOnly.UseVisualStyleBackColor = true; - this.radioButtonSelectedLinesOnly.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // - // timeUpDownAdjust - // - this.timeUpDownAdjust.AutoSize = true; - this.timeUpDownAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownAdjust.Font = new System.Drawing.Font("Segoe UI", 9F); - this.timeUpDownAdjust.Location = new System.Drawing.Point(12, 23); - this.timeUpDownAdjust.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownAdjust.Name = "timeUpDownAdjust"; - this.timeUpDownAdjust.Size = new System.Drawing.Size(96, 27); - this.timeUpDownAdjust.TabIndex = 21; - timeCode1.Hours = 0; - timeCode1.Milliseconds = 0; - timeCode1.Minutes = 0; - timeCode1.Seconds = 0; - timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode1.TotalMilliseconds = 0D; - timeCode1.TotalSeconds = 0D; - this.timeUpDownAdjust.TimeCode = timeCode1; - this.timeUpDownAdjust.UseVideoOffset = false; - // - // radioButtonSelectedLineAndForward - // - this.radioButtonSelectedLineAndForward.AutoSize = true; - this.radioButtonSelectedLineAndForward.Location = new System.Drawing.Point(14, 116); - this.radioButtonSelectedLineAndForward.Name = "radioButtonSelectedLineAndForward"; - this.radioButtonSelectedLineAndForward.Size = new System.Drawing.Size(160, 17); - this.radioButtonSelectedLineAndForward.TabIndex = 41; - this.radioButtonSelectedLineAndForward.TabStop = true; - this.radioButtonSelectedLineAndForward.Text = "Selected line(s) and forward"; - this.radioButtonSelectedLineAndForward.UseVisualStyleBackColor = true; - this.radioButtonSelectedLineAndForward.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // - // ShowEarlierLater - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(301, 170); - this.Controls.Add(this.radioButtonSelectedLineAndForward); - this.Controls.Add(this.radioButtonSelectedLinesOnly); - this.Controls.Add(this.radioButtonAllLines); - this.Controls.Add(this.buttonShowLater); - this.Controls.Add(this.buttonShowEarlier); - this.Controls.Add(this.labelTotalAdjustment); - this.Controls.Add(this.timeUpDownAdjust); - this.Controls.Add(this.labelHourMinSecMilliSecond); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ShowEarlierLater"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Show selected lines earlier/later"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ShowEarlierLater_FormClosing); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ShowEarlierLater_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private Nikse.SubtitleEdit.Controls.TimeUpDown timeUpDownAdjust; - private System.Windows.Forms.Label labelHourMinSecMilliSecond; - private System.Windows.Forms.Button buttonShowLater; - private System.Windows.Forms.Button buttonShowEarlier; - private System.Windows.Forms.Label labelTotalAdjustment; - private System.Windows.Forms.Timer timer1; - private System.Windows.Forms.RadioButton radioButtonAllLines; - private System.Windows.Forms.RadioButton radioButtonSelectedLinesOnly; - private System.Windows.Forms.RadioButton radioButtonSelectedLineAndForward; - } +using Nikse.SubtitleEdit.Controls; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ShowEarlierLater + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + TimeCode timeCode1 = new TimeCode(); + this.labelHourMinSecMilliSecond = new System.Windows.Forms.Label(); + this.buttonShowLater = new System.Windows.Forms.Button(); + this.buttonShowEarlier = new System.Windows.Forms.Button(); + this.labelTotalAdjustment = new System.Windows.Forms.Label(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.radioButtonAllLines = new System.Windows.Forms.RadioButton(); + this.radioButtonSelectedLinesOnly = new System.Windows.Forms.RadioButton(); + this.timeUpDownAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.radioButtonSelectedLineAndForward = new System.Windows.Forms.RadioButton(); + this.SuspendLayout(); + // + // labelHourMinSecMilliSecond + // + this.labelHourMinSecMilliSecond.AutoSize = true; + this.labelHourMinSecMilliSecond.Location = new System.Drawing.Point(11, 6); + this.labelHourMinSecMilliSecond.Name = "labelHourMinSecMilliSecond"; + this.labelHourMinSecMilliSecond.Size = new System.Drawing.Size(108, 13); + this.labelHourMinSecMilliSecond.TabIndex = 18; + this.labelHourMinSecMilliSecond.Text = "Hours:min:sec.msecs"; + // + // buttonShowLater + // + this.buttonShowLater.Location = new System.Drawing.Point(145, 55); + this.buttonShowLater.Name = "buttonShowLater"; + this.buttonShowLater.Size = new System.Drawing.Size(119, 23); + this.buttonShowLater.TabIndex = 20; + this.buttonShowLater.Text = "Show later"; + this.buttonShowLater.UseVisualStyleBackColor = true; + this.buttonShowLater.Click += new System.EventHandler(this.ButtonShowLaterClick); + // + // buttonShowEarlier + // + this.buttonShowEarlier.Location = new System.Drawing.Point(145, 26); + this.buttonShowEarlier.Name = "buttonShowEarlier"; + this.buttonShowEarlier.Size = new System.Drawing.Size(120, 23); + this.buttonShowEarlier.TabIndex = 19; + this.buttonShowEarlier.Text = "Show earlier"; + this.buttonShowEarlier.UseVisualStyleBackColor = true; + this.buttonShowEarlier.Click += new System.EventHandler(this.ButtonShowEarlierClick); + // + // labelTotalAdjustment + // + this.labelTotalAdjustment.AutoSize = true; + this.labelTotalAdjustment.Location = new System.Drawing.Point(9, 148); + this.labelTotalAdjustment.Name = "labelTotalAdjustment"; + this.labelTotalAdjustment.Size = new System.Drawing.Size(108, 13); + this.labelTotalAdjustment.TabIndex = 38; + this.labelTotalAdjustment.Text = "labelTotalAdjustment"; + // + // timer1 + // + this.timer1.Interval = 250; + // + // radioButtonAllLines + // + this.radioButtonAllLines.AutoSize = true; + this.radioButtonAllLines.Location = new System.Drawing.Point(14, 70); + this.radioButtonAllLines.Name = "radioButtonAllLines"; + this.radioButtonAllLines.Size = new System.Drawing.Size(60, 17); + this.radioButtonAllLines.TabIndex = 39; + this.radioButtonAllLines.TabStop = true; + this.radioButtonAllLines.Text = "All lines"; + this.radioButtonAllLines.UseVisualStyleBackColor = true; + this.radioButtonAllLines.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); + // + // radioButtonSelectedLinesOnly + // + this.radioButtonSelectedLinesOnly.AutoSize = true; + this.radioButtonSelectedLinesOnly.Location = new System.Drawing.Point(14, 93); + this.radioButtonSelectedLinesOnly.Name = "radioButtonSelectedLinesOnly"; + this.radioButtonSelectedLinesOnly.Size = new System.Drawing.Size(113, 17); + this.radioButtonSelectedLinesOnly.TabIndex = 40; + this.radioButtonSelectedLinesOnly.TabStop = true; + this.radioButtonSelectedLinesOnly.Text = "Selected lines only"; + this.radioButtonSelectedLinesOnly.UseVisualStyleBackColor = true; + this.radioButtonSelectedLinesOnly.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); + // + // timeUpDownAdjust + // + this.timeUpDownAdjust.AutoSize = true; + this.timeUpDownAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownAdjust.Font = new System.Drawing.Font("Segoe UI", 9F); + this.timeUpDownAdjust.Location = new System.Drawing.Point(12, 23); + this.timeUpDownAdjust.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownAdjust.Name = "timeUpDownAdjust"; + this.timeUpDownAdjust.Size = new System.Drawing.Size(96, 27); + this.timeUpDownAdjust.TabIndex = 21; + timeCode1.Hours = 0; + timeCode1.Milliseconds = 0; + timeCode1.Minutes = 0; + timeCode1.Seconds = 0; + timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode1.TotalMilliseconds = 0D; + timeCode1.TotalSeconds = 0D; + this.timeUpDownAdjust.TimeCode = timeCode1; + this.timeUpDownAdjust.UseVideoOffset = false; + // + // radioButtonSelectedLineAndForward + // + this.radioButtonSelectedLineAndForward.AutoSize = true; + this.radioButtonSelectedLineAndForward.Location = new System.Drawing.Point(14, 116); + this.radioButtonSelectedLineAndForward.Name = "radioButtonSelectedLineAndForward"; + this.radioButtonSelectedLineAndForward.Size = new System.Drawing.Size(160, 17); + this.radioButtonSelectedLineAndForward.TabIndex = 41; + this.radioButtonSelectedLineAndForward.TabStop = true; + this.radioButtonSelectedLineAndForward.Text = "Selected line(s) and forward"; + this.radioButtonSelectedLineAndForward.UseVisualStyleBackColor = true; + this.radioButtonSelectedLineAndForward.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); + // + // ShowEarlierLater + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(301, 170); + this.Controls.Add(this.radioButtonSelectedLineAndForward); + this.Controls.Add(this.radioButtonSelectedLinesOnly); + this.Controls.Add(this.radioButtonAllLines); + this.Controls.Add(this.buttonShowLater); + this.Controls.Add(this.buttonShowEarlier); + this.Controls.Add(this.labelTotalAdjustment); + this.Controls.Add(this.timeUpDownAdjust); + this.Controls.Add(this.labelHourMinSecMilliSecond); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ShowEarlierLater"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Show selected lines earlier/later"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ShowEarlierLater_FormClosing); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ShowEarlierLater_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Nikse.SubtitleEdit.Controls.TimeUpDown timeUpDownAdjust; + private System.Windows.Forms.Label labelHourMinSecMilliSecond; + private System.Windows.Forms.Button buttonShowLater; + private System.Windows.Forms.Button buttonShowEarlier; + private System.Windows.Forms.Label labelTotalAdjustment; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.RadioButton radioButtonAllLines; + private System.Windows.Forms.RadioButton radioButtonSelectedLinesOnly; + private System.Windows.Forms.RadioButton radioButtonSelectedLineAndForward; + } } \ No newline at end of file diff --git a/src/Forms/ShowEarlierLater.cs b/src/ui/Forms/ShowEarlierLater.cs similarity index 97% rename from src/Forms/ShowEarlierLater.cs rename to src/ui/Forms/ShowEarlierLater.cs index 28cd2703a..e4d350720 100644 --- a/src/Forms/ShowEarlierLater.cs +++ b/src/ui/Forms/ShowEarlierLater.cs @@ -1,140 +1,140 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Enums; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ShowEarlierLater : PositionAndSizeForm - { - public delegate void AdjustEventHandler(double adjustMilliseconds, SelectionChoice selection); - - private TimeSpan _totalAdjustment; - private AdjustEventHandler _adjustCallback; - - public ShowEarlierLater() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - ResetTotalAdjustment(); - timeUpDownAdjust.MaskedTextBox.Text = "000000000"; - Text = Configuration.Settings.Language.ShowEarlierLater.Title.RemoveChar('&'); - labelHourMinSecMilliSecond.Text = Configuration.Settings.General.UseTimeFormatHHMMSSFF ? Configuration.Settings.Language.General.HourMinutesSecondsFrames : Configuration.Settings.Language.General.HourMinutesSecondsMilliseconds; - buttonShowEarlier.Text = Configuration.Settings.Language.ShowEarlierLater.ShowEarlier; - buttonShowLater.Text = Configuration.Settings.Language.ShowEarlierLater.ShowLater; - radioButtonAllLines.Text = Configuration.Settings.Language.ShowEarlierLater.AllLines; - radioButtonSelectedLinesOnly.Text = Configuration.Settings.Language.ShowEarlierLater.SelectedLinesOnly; - radioButtonSelectedLineAndForward.Text = Configuration.Settings.Language.ShowEarlierLater.SelectedLinesAndForward; - UiUtil.FixLargeFonts(this, buttonShowEarlier); - - timeUpDownAdjust.MaskedTextBox.TextChanged += (sender, args) => - { - if (timeUpDownAdjust.GetTotalMilliseconds() < 0) - { - timeUpDownAdjust.SetTotalMilliseconds(0); - System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(10), () => - { - timeUpDownAdjust.SetTotalMilliseconds(0); - }); - } - }; - } - - public void ResetTotalAdjustment() - { - _totalAdjustment = TimeSpan.FromMilliseconds(0); - labelTotalAdjustment.Text = string.Empty; - } - - private void ShowEarlierLater_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - Close(); - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#sync"); - e.SuppressKeyPress = true; - } - } - - internal void Initialize(AdjustEventHandler adjustCallback, bool onlySelected) - { - if (onlySelected) - { - radioButtonSelectedLinesOnly.Checked = true; - } - else if (Configuration.Settings.Tools.LastShowEarlierOrLaterSelection == SelectionChoice.SelectionAndForward.ToString()) - { - radioButtonSelectedLineAndForward.Checked = true; - } - else - { - radioButtonAllLines.Checked = true; - } - - _adjustCallback = adjustCallback; - timeUpDownAdjust.TimeCode = new TimeCode(Configuration.Settings.General.DefaultAdjustMilliseconds); - } - - private SelectionChoice GetSelectionChoice() - { - if (radioButtonSelectedLinesOnly.Checked) - { - return SelectionChoice.SelectionOnly; - } - - if (radioButtonSelectedLineAndForward.Checked) - { - return SelectionChoice.SelectionAndForward; - } - - return SelectionChoice.AllLines; - } - - private void ButtonShowEarlierClick(object sender, EventArgs e) - { - TimeCode tc = timeUpDownAdjust.TimeCode; - if (tc != null && tc.TotalMilliseconds > 0) - { - _adjustCallback.Invoke(-tc.TotalMilliseconds, GetSelectionChoice()); - _totalAdjustment = TimeSpan.FromMilliseconds(_totalAdjustment.TotalMilliseconds - tc.TotalMilliseconds); - ShowTotalAdjustMent(); - Configuration.Settings.General.DefaultAdjustMilliseconds = (int)tc.TotalMilliseconds; - } - } - - private void ShowTotalAdjustMent() - { - TimeCode tc = new TimeCode(_totalAdjustment); - labelTotalAdjustment.Text = string.Format(Configuration.Settings.Language.ShowEarlierLater.TotalAdjustmentX, tc.ToShortString()); - } - - private void ButtonShowLaterClick(object sender, EventArgs e) - { - TimeCode tc = timeUpDownAdjust.TimeCode; - if (tc != null && tc.TotalMilliseconds > 0) - { - _adjustCallback.Invoke(tc.TotalMilliseconds, GetSelectionChoice()); - _totalAdjustment = TimeSpan.FromMilliseconds(_totalAdjustment.TotalMilliseconds + tc.TotalMilliseconds); - ShowTotalAdjustMent(); - Configuration.Settings.General.DefaultAdjustMilliseconds = (int)tc.TotalMilliseconds; - } - } - - private void RadioButtonCheckedChanged(object sender, EventArgs e) - { - Text = ((RadioButton)sender).Text.RemoveChar('&'); - } - - private void ShowEarlierLater_FormClosing(object sender, FormClosingEventArgs e) - { - Configuration.Settings.Tools.LastShowEarlierOrLaterSelection = GetSelectionChoice().ToString(); - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Enums; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ShowEarlierLater : PositionAndSizeForm + { + public delegate void AdjustEventHandler(double adjustMilliseconds, SelectionChoice selection); + + private TimeSpan _totalAdjustment; + private AdjustEventHandler _adjustCallback; + + public ShowEarlierLater() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + ResetTotalAdjustment(); + timeUpDownAdjust.MaskedTextBox.Text = "000000000"; + Text = Configuration.Settings.Language.ShowEarlierLater.Title.RemoveChar('&'); + labelHourMinSecMilliSecond.Text = Configuration.Settings.General.UseTimeFormatHHMMSSFF ? Configuration.Settings.Language.General.HourMinutesSecondsFrames : Configuration.Settings.Language.General.HourMinutesSecondsMilliseconds; + buttonShowEarlier.Text = Configuration.Settings.Language.ShowEarlierLater.ShowEarlier; + buttonShowLater.Text = Configuration.Settings.Language.ShowEarlierLater.ShowLater; + radioButtonAllLines.Text = Configuration.Settings.Language.ShowEarlierLater.AllLines; + radioButtonSelectedLinesOnly.Text = Configuration.Settings.Language.ShowEarlierLater.SelectedLinesOnly; + radioButtonSelectedLineAndForward.Text = Configuration.Settings.Language.ShowEarlierLater.SelectedLinesAndForward; + UiUtil.FixLargeFonts(this, buttonShowEarlier); + + timeUpDownAdjust.MaskedTextBox.TextChanged += (sender, args) => + { + if (timeUpDownAdjust.GetTotalMilliseconds() < 0) + { + timeUpDownAdjust.SetTotalMilliseconds(0); + System.Threading.SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(10), () => + { + timeUpDownAdjust.SetTotalMilliseconds(0); + }); + } + }; + } + + public void ResetTotalAdjustment() + { + _totalAdjustment = TimeSpan.FromMilliseconds(0); + labelTotalAdjustment.Text = string.Empty; + } + + private void ShowEarlierLater_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + Close(); + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#sync"); + e.SuppressKeyPress = true; + } + } + + internal void Initialize(AdjustEventHandler adjustCallback, bool onlySelected) + { + if (onlySelected) + { + radioButtonSelectedLinesOnly.Checked = true; + } + else if (Configuration.Settings.Tools.LastShowEarlierOrLaterSelection == SelectionChoice.SelectionAndForward.ToString()) + { + radioButtonSelectedLineAndForward.Checked = true; + } + else + { + radioButtonAllLines.Checked = true; + } + + _adjustCallback = adjustCallback; + timeUpDownAdjust.TimeCode = new TimeCode(Configuration.Settings.General.DefaultAdjustMilliseconds); + } + + private SelectionChoice GetSelectionChoice() + { + if (radioButtonSelectedLinesOnly.Checked) + { + return SelectionChoice.SelectionOnly; + } + + if (radioButtonSelectedLineAndForward.Checked) + { + return SelectionChoice.SelectionAndForward; + } + + return SelectionChoice.AllLines; + } + + private void ButtonShowEarlierClick(object sender, EventArgs e) + { + TimeCode tc = timeUpDownAdjust.TimeCode; + if (tc != null && tc.TotalMilliseconds > 0) + { + _adjustCallback.Invoke(-tc.TotalMilliseconds, GetSelectionChoice()); + _totalAdjustment = TimeSpan.FromMilliseconds(_totalAdjustment.TotalMilliseconds - tc.TotalMilliseconds); + ShowTotalAdjustMent(); + Configuration.Settings.General.DefaultAdjustMilliseconds = (int)tc.TotalMilliseconds; + } + } + + private void ShowTotalAdjustMent() + { + TimeCode tc = new TimeCode(_totalAdjustment); + labelTotalAdjustment.Text = string.Format(Configuration.Settings.Language.ShowEarlierLater.TotalAdjustmentX, tc.ToShortString()); + } + + private void ButtonShowLaterClick(object sender, EventArgs e) + { + TimeCode tc = timeUpDownAdjust.TimeCode; + if (tc != null && tc.TotalMilliseconds > 0) + { + _adjustCallback.Invoke(tc.TotalMilliseconds, GetSelectionChoice()); + _totalAdjustment = TimeSpan.FromMilliseconds(_totalAdjustment.TotalMilliseconds + tc.TotalMilliseconds); + ShowTotalAdjustMent(); + Configuration.Settings.General.DefaultAdjustMilliseconds = (int)tc.TotalMilliseconds; + } + } + + private void RadioButtonCheckedChanged(object sender, EventArgs e) + { + Text = ((RadioButton)sender).Text.RemoveChar('&'); + } + + private void ShowEarlierLater_FormClosing(object sender, FormClosingEventArgs e) + { + Configuration.Settings.Tools.LastShowEarlierOrLaterSelection = GetSelectionChoice().ToString(); + } + + } +} diff --git a/src/Forms/ShowEarlierLater.resx b/src/ui/Forms/ShowEarlierLater.resx similarity index 97% rename from src/Forms/ShowEarlierLater.resx rename to src/ui/Forms/ShowEarlierLater.resx index bb3c53021..d55421f05 100644 --- a/src/Forms/ShowEarlierLater.resx +++ b/src/ui/Forms/ShowEarlierLater.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/ShowHistory.Designer.cs b/src/ui/Forms/ShowHistory.Designer.cs similarity index 97% rename from src/Forms/ShowHistory.Designer.cs rename to src/ui/Forms/ShowHistory.Designer.cs index 42ef31be5..8deddac71 100644 --- a/src/Forms/ShowHistory.Designer.cs +++ b/src/ui/Forms/ShowHistory.Designer.cs @@ -1,158 +1,158 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class ShowHistory - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.listViewHistory = new System.Windows.Forms.ListView(); - this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.buttonRollback = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.buttonCompare = new System.Windows.Forms.Button(); - this.buttonCompareHistory = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // listViewHistory - // - this.listViewHistory.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.columnHeader2}); - this.listViewHistory.FullRowSelect = true; - this.listViewHistory.HideSelection = false; - this.listViewHistory.Location = new System.Drawing.Point(12, 37); - this.listViewHistory.Name = "listViewHistory"; - this.listViewHistory.Size = new System.Drawing.Size(472, 324); - this.listViewHistory.TabIndex = 0; - this.listViewHistory.UseCompatibleStateImageBehavior = false; - this.listViewHistory.View = System.Windows.Forms.View.Details; - this.listViewHistory.SelectedIndexChanged += new System.EventHandler(this.ListViewHistorySelectedIndexChanged); - // - // columnHeader1 - // - this.columnHeader1.Text = "Time"; - this.columnHeader1.Width = 80; - // - // columnHeader2 - // - this.columnHeader2.Text = "Description"; - this.columnHeader2.Width = 365; - // - // buttonRollback - // - this.buttonRollback.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonRollback.Location = new System.Drawing.Point(489, 338); - this.buttonRollback.Name = "buttonRollback"; - this.buttonRollback.Size = new System.Drawing.Size(98, 23); - this.buttonRollback.TabIndex = 6; - this.buttonRollback.Text = "&Rollback"; - this.buttonRollback.UseVisualStyleBackColor = true; - this.buttonRollback.Click += new System.EventHandler(this.ButtonOkClick); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(594, 338); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 8; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 18); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(171, 13); - this.label1.TabIndex = 10; - this.label1.Text = "Select time/description for rollback"; - // - // buttonCompare - // - this.buttonCompare.Enabled = false; - this.buttonCompare.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCompare.Location = new System.Drawing.Point(489, 200); - this.buttonCompare.Name = "buttonCompare"; - this.buttonCompare.Size = new System.Drawing.Size(179, 23); - this.buttonCompare.TabIndex = 4; - this.buttonCompare.Text = "&Compare with current"; - this.buttonCompare.UseVisualStyleBackColor = true; - this.buttonCompare.Click += new System.EventHandler(this.ButtonCompareClick); - // - // buttonCompareHistory - // - this.buttonCompareHistory.Enabled = false; - this.buttonCompareHistory.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCompareHistory.Location = new System.Drawing.Point(490, 171); - this.buttonCompareHistory.Name = "buttonCompareHistory"; - this.buttonCompareHistory.Size = new System.Drawing.Size(179, 23); - this.buttonCompareHistory.TabIndex = 2; - this.buttonCompareHistory.Text = "&Compare history items"; - this.buttonCompareHistory.UseVisualStyleBackColor = true; - this.buttonCompareHistory.Click += new System.EventHandler(this.ButtonCompareHistoryClick); - // - // ShowHistory - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(680, 373); - this.Controls.Add(this.buttonCompareHistory); - this.Controls.Add(this.buttonCompare); - this.Controls.Add(this.label1); - this.Controls.Add(this.buttonRollback); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.listViewHistory); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "ShowHistory"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "History (for undo)"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormShowHistory_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ListView listViewHistory; - private System.Windows.Forms.ColumnHeader columnHeader1; - private System.Windows.Forms.ColumnHeader columnHeader2; - private System.Windows.Forms.Button buttonRollback; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button buttonCompare; - private System.Windows.Forms.Button buttonCompareHistory; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class ShowHistory + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.listViewHistory = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.buttonRollback = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.buttonCompare = new System.Windows.Forms.Button(); + this.buttonCompareHistory = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // listViewHistory + // + this.listViewHistory.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2}); + this.listViewHistory.FullRowSelect = true; + this.listViewHistory.HideSelection = false; + this.listViewHistory.Location = new System.Drawing.Point(12, 37); + this.listViewHistory.Name = "listViewHistory"; + this.listViewHistory.Size = new System.Drawing.Size(472, 324); + this.listViewHistory.TabIndex = 0; + this.listViewHistory.UseCompatibleStateImageBehavior = false; + this.listViewHistory.View = System.Windows.Forms.View.Details; + this.listViewHistory.SelectedIndexChanged += new System.EventHandler(this.ListViewHistorySelectedIndexChanged); + // + // columnHeader1 + // + this.columnHeader1.Text = "Time"; + this.columnHeader1.Width = 80; + // + // columnHeader2 + // + this.columnHeader2.Text = "Description"; + this.columnHeader2.Width = 365; + // + // buttonRollback + // + this.buttonRollback.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonRollback.Location = new System.Drawing.Point(489, 338); + this.buttonRollback.Name = "buttonRollback"; + this.buttonRollback.Size = new System.Drawing.Size(98, 23); + this.buttonRollback.TabIndex = 6; + this.buttonRollback.Text = "&Rollback"; + this.buttonRollback.UseVisualStyleBackColor = true; + this.buttonRollback.Click += new System.EventHandler(this.ButtonOkClick); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(594, 338); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 8; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 18); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(171, 13); + this.label1.TabIndex = 10; + this.label1.Text = "Select time/description for rollback"; + // + // buttonCompare + // + this.buttonCompare.Enabled = false; + this.buttonCompare.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCompare.Location = new System.Drawing.Point(489, 200); + this.buttonCompare.Name = "buttonCompare"; + this.buttonCompare.Size = new System.Drawing.Size(179, 23); + this.buttonCompare.TabIndex = 4; + this.buttonCompare.Text = "&Compare with current"; + this.buttonCompare.UseVisualStyleBackColor = true; + this.buttonCompare.Click += new System.EventHandler(this.ButtonCompareClick); + // + // buttonCompareHistory + // + this.buttonCompareHistory.Enabled = false; + this.buttonCompareHistory.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCompareHistory.Location = new System.Drawing.Point(490, 171); + this.buttonCompareHistory.Name = "buttonCompareHistory"; + this.buttonCompareHistory.Size = new System.Drawing.Size(179, 23); + this.buttonCompareHistory.TabIndex = 2; + this.buttonCompareHistory.Text = "&Compare history items"; + this.buttonCompareHistory.UseVisualStyleBackColor = true; + this.buttonCompareHistory.Click += new System.EventHandler(this.ButtonCompareHistoryClick); + // + // ShowHistory + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(680, 373); + this.Controls.Add(this.buttonCompareHistory); + this.Controls.Add(this.buttonCompare); + this.Controls.Add(this.label1); + this.Controls.Add(this.buttonRollback); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.listViewHistory); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ShowHistory"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "History (for undo)"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormShowHistory_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ListView listViewHistory; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.Button buttonRollback; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button buttonCompare; + private System.Windows.Forms.Button buttonCompareHistory; + } } \ No newline at end of file diff --git a/src/Forms/ShowHistory.cs b/src/ui/Forms/ShowHistory.cs similarity index 97% rename from src/Forms/ShowHistory.cs rename to src/ui/Forms/ShowHistory.cs index 12bba9a3f..2202dec28 100644 --- a/src/Forms/ShowHistory.cs +++ b/src/ui/Forms/ShowHistory.cs @@ -1,128 +1,128 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Drawing; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class ShowHistory : Form - { - private int _selectedIndex = -1; - private Subtitle _subtitle; - private int _undoIndex; - - public ShowHistory() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.ShowHistory.Title; - label1.Text = Configuration.Settings.Language.ShowHistory.SelectRollbackPoint; - listViewHistory.Columns[0].Text = Configuration.Settings.Language.ShowHistory.Time; - listViewHistory.Columns[1].Text = Configuration.Settings.Language.ShowHistory.Description; - buttonCompare.Text = Configuration.Settings.Language.ShowHistory.CompareWithCurrent; - buttonCompareHistory.Text = Configuration.Settings.Language.ShowHistory.CompareHistoryItems; - buttonRollback.Text = Configuration.Settings.Language.ShowHistory.Rollback; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonRollback); - } - - public int SelectedIndex => _selectedIndex; - - public void Initialize(Subtitle subtitle, int undoIndex) - { - _subtitle = subtitle; - _undoIndex = undoIndex; - int i = 0; - foreach (HistoryItem item in subtitle.HistoryItems) - { - AddHistoryItemToListView(item, i++); - } - ListViewHistorySelectedIndexChanged(null, null); - if (listViewHistory.Items.Count > 0 && _undoIndex >= 0 && _undoIndex < listViewHistory.Items.Count) - { - listViewHistory.Items[_undoIndex].Selected = true; - } - } - - private void AddHistoryItemToListView(HistoryItem hi, int index) - { - var item = new ListViewItem(string.Empty) - { - Tag = hi, - Text = hi.ToHHMMSS() - }; - - if (index > _undoIndex) - { - item.UseItemStyleForSubItems = true; - item.Font = new Font(item.Font.FontFamily, item.Font.SizeInPoints, FontStyle.Italic); - item.ForeColor = Color.Gray; - } - item.SubItems.Add(hi.Description); - listViewHistory.Items.Add(item); - } - - private void FormShowHistory_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void ButtonOkClick(object sender, EventArgs e) - { - if (listViewHistory.SelectedItems.Count > 0) - { - _selectedIndex = listViewHistory.SelectedItems[0].Index; - DialogResult = DialogResult.OK; - } - else - { - DialogResult = DialogResult.Cancel; - } - } - - private void ButtonCompareClick(object sender, EventArgs e) - { - if (listViewHistory.SelectedItems.Count == 1) - { - HistoryItem h2 = _subtitle.HistoryItems[listViewHistory.SelectedItems[0].Index]; - string descr2 = h2.ToHHMMSS() + " - " + h2.Description; - using (var compareForm = new Compare()) - { - compareForm.Initialize(_subtitle, Configuration.Settings.Language.General.CurrentSubtitle, h2.Subtitle, descr2); - compareForm.ShowDialog(this); - } - } - } - - private void ListViewHistorySelectedIndexChanged(object sender, EventArgs e) - { - buttonCompare.Enabled = listViewHistory.SelectedItems.Count == 1; - buttonCompareHistory.Enabled = listViewHistory.SelectedItems.Count == 2; - buttonRollback.Enabled = listViewHistory.SelectedItems.Count == 1 && listViewHistory.SelectedItems[0].Index <= _undoIndex; - } - - private void ButtonCompareHistoryClick(object sender, EventArgs e) - { - if (listViewHistory.SelectedItems.Count == 2) - { - HistoryItem h1 = _subtitle.HistoryItems[listViewHistory.SelectedItems[0].Index]; - HistoryItem h2 = _subtitle.HistoryItems[listViewHistory.SelectedItems[1].Index]; - string descr1 = h1.ToHHMMSS() + " - " + h1.Description; - string descr2 = h2.ToHHMMSS() + " - " + h2.Description; - using (var compareForm = new Compare()) - { - compareForm.Initialize(h1.Subtitle, descr1, h2.Subtitle, descr2); - compareForm.ShowDialog(this); - } - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Drawing; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ShowHistory : Form + { + private int _selectedIndex = -1; + private Subtitle _subtitle; + private int _undoIndex; + + public ShowHistory() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.ShowHistory.Title; + label1.Text = Configuration.Settings.Language.ShowHistory.SelectRollbackPoint; + listViewHistory.Columns[0].Text = Configuration.Settings.Language.ShowHistory.Time; + listViewHistory.Columns[1].Text = Configuration.Settings.Language.ShowHistory.Description; + buttonCompare.Text = Configuration.Settings.Language.ShowHistory.CompareWithCurrent; + buttonCompareHistory.Text = Configuration.Settings.Language.ShowHistory.CompareHistoryItems; + buttonRollback.Text = Configuration.Settings.Language.ShowHistory.Rollback; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonRollback); + } + + public int SelectedIndex => _selectedIndex; + + public void Initialize(Subtitle subtitle, int undoIndex) + { + _subtitle = subtitle; + _undoIndex = undoIndex; + int i = 0; + foreach (HistoryItem item in subtitle.HistoryItems) + { + AddHistoryItemToListView(item, i++); + } + ListViewHistorySelectedIndexChanged(null, null); + if (listViewHistory.Items.Count > 0 && _undoIndex >= 0 && _undoIndex < listViewHistory.Items.Count) + { + listViewHistory.Items[_undoIndex].Selected = true; + } + } + + private void AddHistoryItemToListView(HistoryItem hi, int index) + { + var item = new ListViewItem(string.Empty) + { + Tag = hi, + Text = hi.ToHHMMSS() + }; + + if (index > _undoIndex) + { + item.UseItemStyleForSubItems = true; + item.Font = new Font(item.Font.FontFamily, item.Font.SizeInPoints, FontStyle.Italic); + item.ForeColor = Color.Gray; + } + item.SubItems.Add(hi.Description); + listViewHistory.Items.Add(item); + } + + private void FormShowHistory_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void ButtonOkClick(object sender, EventArgs e) + { + if (listViewHistory.SelectedItems.Count > 0) + { + _selectedIndex = listViewHistory.SelectedItems[0].Index; + DialogResult = DialogResult.OK; + } + else + { + DialogResult = DialogResult.Cancel; + } + } + + private void ButtonCompareClick(object sender, EventArgs e) + { + if (listViewHistory.SelectedItems.Count == 1) + { + HistoryItem h2 = _subtitle.HistoryItems[listViewHistory.SelectedItems[0].Index]; + string descr2 = h2.ToHHMMSS() + " - " + h2.Description; + using (var compareForm = new Compare()) + { + compareForm.Initialize(_subtitle, Configuration.Settings.Language.General.CurrentSubtitle, h2.Subtitle, descr2); + compareForm.ShowDialog(this); + } + } + } + + private void ListViewHistorySelectedIndexChanged(object sender, EventArgs e) + { + buttonCompare.Enabled = listViewHistory.SelectedItems.Count == 1; + buttonCompareHistory.Enabled = listViewHistory.SelectedItems.Count == 2; + buttonRollback.Enabled = listViewHistory.SelectedItems.Count == 1 && listViewHistory.SelectedItems[0].Index <= _undoIndex; + } + + private void ButtonCompareHistoryClick(object sender, EventArgs e) + { + if (listViewHistory.SelectedItems.Count == 2) + { + HistoryItem h1 = _subtitle.HistoryItems[listViewHistory.SelectedItems[0].Index]; + HistoryItem h2 = _subtitle.HistoryItems[listViewHistory.SelectedItems[1].Index]; + string descr1 = h1.ToHHMMSS() + " - " + h1.Description; + string descr2 = h2.ToHHMMSS() + " - " + h2.Description; + using (var compareForm = new Compare()) + { + compareForm.Initialize(h1.Subtitle, descr1, h2.Subtitle, descr2); + compareForm.ShowDialog(this); + } + } + } + + } +} diff --git a/src/Forms/ShowHistory.resx b/src/ui/Forms/ShowHistory.resx similarity index 97% rename from src/Forms/ShowHistory.resx rename to src/ui/Forms/ShowHistory.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/ShowHistory.resx +++ b/src/ui/Forms/ShowHistory.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/SpellCheck.Designer.cs b/src/ui/Forms/SpellCheck.Designer.cs similarity index 98% rename from src/Forms/SpellCheck.Designer.cs rename to src/ui/Forms/SpellCheck.Designer.cs index d895f55dc..97a870bfe 100644 --- a/src/Forms/SpellCheck.Designer.cs +++ b/src/ui/Forms/SpellCheck.Designer.cs @@ -1,469 +1,469 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class SpellCheck - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.buttonAddToDictionary = new System.Windows.Forms.Button(); - this.buttonSkipOnce = new System.Windows.Forms.Button(); - this.comboBoxDictionaries = new System.Windows.Forms.ComboBox(); - this.labelLanguage = new System.Windows.Forms.Label(); - this.richTextBoxParagraph = new System.Windows.Forms.RichTextBox(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.addXToNamesnoiseListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.addXToUserDictionaryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.listBoxSuggestions = new System.Windows.Forms.ListBox(); - this.labelFullText = new System.Windows.Forms.Label(); - this.textBoxWord = new System.Windows.Forms.TextBox(); - this.buttonAbort = new System.Windows.Forms.Button(); - this.buttonSkipAll = new System.Windows.Forms.Button(); - this.buttonChange = new System.Windows.Forms.Button(); - this.buttonUseSuggestion = new System.Windows.Forms.Button(); - this.buttonChangeAll = new System.Windows.Forms.Button(); - this.buttonUseSuggestionAlways = new System.Windows.Forms.Button(); - this.buttonAddToNames = new System.Windows.Forms.Button(); - this.groupBoxWordNotFound = new System.Windows.Forms.GroupBox(); - this.buttonGoogleIt = new System.Windows.Forms.Button(); - this.buttonUndo = new System.Windows.Forms.Button(); - this.groupBoxSuggestions = new System.Windows.Forms.GroupBox(); - this.checkBoxAutoChangeNames = new System.Windows.Forms.CheckBox(); - this.buttonEditWholeText = new System.Windows.Forms.Button(); - this.groupBoxEditWholeText = new System.Windows.Forms.GroupBox(); - this.buttonSkipText = new System.Windows.Forms.Button(); - this.buttonChangeWholeText = new System.Windows.Forms.Button(); - this.textBoxWholeText = new System.Windows.Forms.TextBox(); - this.labelActionInfo = new System.Windows.Forms.Label(); - this.buttonSpellCheckDownload = new System.Windows.Forms.Button(); - this.contextMenuStrip1.SuspendLayout(); - this.groupBoxWordNotFound.SuspendLayout(); - this.groupBoxSuggestions.SuspendLayout(); - this.groupBoxEditWholeText.SuspendLayout(); - this.SuspendLayout(); - // - // buttonAddToDictionary - // - this.buttonAddToDictionary.Location = new System.Drawing.Point(6, 134); - this.buttonAddToDictionary.Name = "buttonAddToDictionary"; - this.buttonAddToDictionary.Size = new System.Drawing.Size(280, 23); - this.buttonAddToDictionary.TabIndex = 6; - this.buttonAddToDictionary.Text = "Add to user dictionary (not case sensitive)"; - this.buttonAddToDictionary.UseVisualStyleBackColor = true; - this.buttonAddToDictionary.Click += new System.EventHandler(this.ButtonAddToDictionaryClick); - this.buttonAddToDictionary.MouseEnter += new System.EventHandler(this.buttonAddToDictionary_MouseEnter); - this.buttonAddToDictionary.MouseLeave += new System.EventHandler(this.buttonAddToDictionary_MouseLeave); - // - // buttonSkipOnce - // - this.buttonSkipOnce.Location = new System.Drawing.Point(6, 76); - this.buttonSkipOnce.Name = "buttonSkipOnce"; - this.buttonSkipOnce.Size = new System.Drawing.Size(136, 23); - this.buttonSkipOnce.TabIndex = 3; - this.buttonSkipOnce.Text = "Skip &once"; - this.buttonSkipOnce.UseVisualStyleBackColor = true; - this.buttonSkipOnce.Click += new System.EventHandler(this.ButtonSkipOnceClick); - this.buttonSkipOnce.MouseEnter += new System.EventHandler(this.buttonSkipOnce_MouseEnter); - this.buttonSkipOnce.MouseLeave += new System.EventHandler(this.buttonSkipOnce_MouseLeave); - // - // comboBoxDictionaries - // - this.comboBoxDictionaries.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxDictionaries.FormattingEnabled = true; - this.comboBoxDictionaries.Location = new System.Drawing.Point(317, 33); - this.comboBoxDictionaries.Name = "comboBoxDictionaries"; - this.comboBoxDictionaries.Size = new System.Drawing.Size(237, 21); - this.comboBoxDictionaries.TabIndex = 8; - this.comboBoxDictionaries.SelectedIndexChanged += new System.EventHandler(this.ComboBoxDictionariesSelectedIndexChanged); - // - // labelLanguage - // - this.labelLanguage.AutoSize = true; - this.labelLanguage.Location = new System.Drawing.Point(314, 14); - this.labelLanguage.Name = "labelLanguage"; - this.labelLanguage.Size = new System.Drawing.Size(54, 13); - this.labelLanguage.TabIndex = 7; - this.labelLanguage.Text = "Language"; - // - // richTextBoxParagraph - // - this.richTextBoxParagraph.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.richTextBoxParagraph.ContextMenuStrip = this.contextMenuStrip1; - this.richTextBoxParagraph.Location = new System.Drawing.Point(11, 33); - this.richTextBoxParagraph.Name = "richTextBoxParagraph"; - this.richTextBoxParagraph.ReadOnly = true; - this.richTextBoxParagraph.Size = new System.Drawing.Size(292, 54); - this.richTextBoxParagraph.TabIndex = 5; - this.richTextBoxParagraph.Text = ""; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.addXToNamesnoiseListToolStripMenuItem, - this.addXToUserDictionaryToolStripMenuItem, - this.toolStripSeparator1, - this.deleteToolStripMenuItem}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(209, 76); - this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStrip1Opening); - // - // addXToNamesnoiseListToolStripMenuItem - // - this.addXToNamesnoiseListToolStripMenuItem.Name = "addXToNamesnoiseListToolStripMenuItem"; - this.addXToNamesnoiseListToolStripMenuItem.Size = new System.Drawing.Size(208, 22); - this.addXToNamesnoiseListToolStripMenuItem.Text = "Add x to names/noise list"; - this.addXToNamesnoiseListToolStripMenuItem.Click += new System.EventHandler(this.AddXToNamesnoiseListToolStripMenuItemClick); - // - // addXToUserDictionaryToolStripMenuItem - // - this.addXToUserDictionaryToolStripMenuItem.Name = "addXToUserDictionaryToolStripMenuItem"; - this.addXToUserDictionaryToolStripMenuItem.Size = new System.Drawing.Size(208, 22); - this.addXToUserDictionaryToolStripMenuItem.Text = "Add x to user dictionary"; - this.addXToUserDictionaryToolStripMenuItem.Click += new System.EventHandler(this.AddXToUserDictionaryToolStripMenuItem_Click); - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(205, 6); - // - // deleteToolStripMenuItem - // - this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(208, 22); - this.deleteToolStripMenuItem.Text = "Delete..."; - this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); - // - // listBoxSuggestions - // - this.listBoxSuggestions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.listBoxSuggestions.FormattingEnabled = true; - this.listBoxSuggestions.Location = new System.Drawing.Point(8, 47); - this.listBoxSuggestions.Name = "listBoxSuggestions"; - this.listBoxSuggestions.Size = new System.Drawing.Size(272, 121); - this.listBoxSuggestions.TabIndex = 2; - this.listBoxSuggestions.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.ListBoxSuggestionsMouseDoubleClick); - // - // labelFullText - // - this.labelFullText.AutoSize = true; - this.labelFullText.Location = new System.Drawing.Point(8, 14); - this.labelFullText.Name = "labelFullText"; - this.labelFullText.Size = new System.Drawing.Size(46, 13); - this.labelFullText.TabIndex = 4; - this.labelFullText.Text = "Full text"; - // - // textBoxWord - // - this.textBoxWord.Location = new System.Drawing.Point(6, 20); - this.textBoxWord.Name = "textBoxWord"; - this.textBoxWord.Size = new System.Drawing.Size(280, 21); - this.textBoxWord.TabIndex = 0; - this.textBoxWord.TextChanged += new System.EventHandler(this.textBoxWord_TextChanged); - // - // buttonAbort - // - this.buttonAbort.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonAbort.Location = new System.Drawing.Point(515, 351); - this.buttonAbort.Name = "buttonAbort"; - this.buttonAbort.Size = new System.Drawing.Size(85, 23); - this.buttonAbort.TabIndex = 3; - this.buttonAbort.Text = "Abort"; - this.buttonAbort.UseVisualStyleBackColor = true; - this.buttonAbort.Click += new System.EventHandler(this.ButtonAbortClick); - // - // buttonSkipAll - // - this.buttonSkipAll.Location = new System.Drawing.Point(147, 76); - this.buttonSkipAll.Name = "buttonSkipAll"; - this.buttonSkipAll.Size = new System.Drawing.Size(138, 23); - this.buttonSkipAll.TabIndex = 4; - this.buttonSkipAll.Text = "&Skip all"; - this.buttonSkipAll.UseVisualStyleBackColor = true; - this.buttonSkipAll.Click += new System.EventHandler(this.ButtonSkipAllClick); - this.buttonSkipAll.MouseEnter += new System.EventHandler(this.buttonSkipAll_MouseEnter); - this.buttonSkipAll.MouseLeave += new System.EventHandler(this.buttonSkipAll_MouseLeave); - // - // buttonChange - // - this.buttonChange.Location = new System.Drawing.Point(6, 47); - this.buttonChange.Name = "buttonChange"; - this.buttonChange.Size = new System.Drawing.Size(136, 23); - this.buttonChange.TabIndex = 1; - this.buttonChange.Text = "Change"; - this.buttonChange.UseVisualStyleBackColor = true; - this.buttonChange.Click += new System.EventHandler(this.ButtonChangeClick); - this.buttonChange.MouseEnter += new System.EventHandler(this.buttonChange_MouseEnter); - this.buttonChange.MouseLeave += new System.EventHandler(this.buttonChange_MouseLeave); - // - // buttonUseSuggestion - // - this.buttonUseSuggestion.Location = new System.Drawing.Point(68, 17); - this.buttonUseSuggestion.Name = "buttonUseSuggestion"; - this.buttonUseSuggestion.Size = new System.Drawing.Size(90, 23); - this.buttonUseSuggestion.TabIndex = 0; - this.buttonUseSuggestion.Text = "Use"; - this.buttonUseSuggestion.UseVisualStyleBackColor = true; - this.buttonUseSuggestion.Click += new System.EventHandler(this.ButtonUseSuggestionClick); - // - // buttonChangeAll - // - this.buttonChangeAll.Location = new System.Drawing.Point(148, 47); - this.buttonChangeAll.Name = "buttonChangeAll"; - this.buttonChangeAll.Size = new System.Drawing.Size(138, 23); - this.buttonChangeAll.TabIndex = 2; - this.buttonChangeAll.Text = "Change all"; - this.buttonChangeAll.UseVisualStyleBackColor = true; - this.buttonChangeAll.Click += new System.EventHandler(this.ButtonChangeAllClick); - this.buttonChangeAll.MouseEnter += new System.EventHandler(this.buttonChangeAll_MouseEnter); - this.buttonChangeAll.MouseLeave += new System.EventHandler(this.buttonChangeAll_MouseLeave); - // - // buttonUseSuggestionAlways - // - this.buttonUseSuggestionAlways.Location = new System.Drawing.Point(164, 17); - this.buttonUseSuggestionAlways.Name = "buttonUseSuggestionAlways"; - this.buttonUseSuggestionAlways.Size = new System.Drawing.Size(115, 23); - this.buttonUseSuggestionAlways.TabIndex = 1; - this.buttonUseSuggestionAlways.Text = "Use always"; - this.buttonUseSuggestionAlways.UseVisualStyleBackColor = true; - this.buttonUseSuggestionAlways.Click += new System.EventHandler(this.ButtonUseSuggestionAlwaysClick); - // - // buttonAddToNames - // - this.buttonAddToNames.Location = new System.Drawing.Point(5, 105); - this.buttonAddToNames.Name = "buttonAddToNames"; - this.buttonAddToNames.Size = new System.Drawing.Size(280, 23); - this.buttonAddToNames.TabIndex = 5; - this.buttonAddToNames.Text = "Add to names/noise list (case sensitive)"; - this.buttonAddToNames.UseVisualStyleBackColor = true; - this.buttonAddToNames.Click += new System.EventHandler(this.ButtonAddToNamesClick); - this.buttonAddToNames.MouseEnter += new System.EventHandler(this.buttonAddToNames_MouseEnter); - this.buttonAddToNames.MouseLeave += new System.EventHandler(this.buttonAddToNames_MouseLeave); - // - // groupBoxWordNotFound - // - this.groupBoxWordNotFound.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.groupBoxWordNotFound.Controls.Add(this.buttonGoogleIt); - this.groupBoxWordNotFound.Controls.Add(this.buttonUndo); - this.groupBoxWordNotFound.Controls.Add(this.buttonAddToNames); - this.groupBoxWordNotFound.Controls.Add(this.buttonAddToDictionary); - this.groupBoxWordNotFound.Controls.Add(this.buttonSkipOnce); - this.groupBoxWordNotFound.Controls.Add(this.buttonChangeAll); - this.groupBoxWordNotFound.Controls.Add(this.textBoxWord); - this.groupBoxWordNotFound.Controls.Add(this.buttonSkipAll); - this.groupBoxWordNotFound.Controls.Add(this.buttonChange); - this.groupBoxWordNotFound.Location = new System.Drawing.Point(11, 120); - this.groupBoxWordNotFound.Name = "groupBoxWordNotFound"; - this.groupBoxWordNotFound.Size = new System.Drawing.Size(292, 225); - this.groupBoxWordNotFound.TabIndex = 0; - this.groupBoxWordNotFound.TabStop = false; - this.groupBoxWordNotFound.Text = "Word not found"; - // - // buttonGoogleIt - // - this.buttonGoogleIt.Location = new System.Drawing.Point(6, 163); - this.buttonGoogleIt.Name = "buttonGoogleIt"; - this.buttonGoogleIt.Size = new System.Drawing.Size(280, 23); - this.buttonGoogleIt.TabIndex = 7; - this.buttonGoogleIt.Text = "&Google it"; - this.buttonGoogleIt.UseVisualStyleBackColor = true; - this.buttonGoogleIt.Click += new System.EventHandler(this.buttonGoogleIt_Click); - // - // buttonUndo - // - this.buttonUndo.Location = new System.Drawing.Point(6, 192); - this.buttonUndo.Name = "buttonUndo"; - this.buttonUndo.Size = new System.Drawing.Size(280, 23); - this.buttonUndo.TabIndex = 8; - this.buttonUndo.Text = "Undo: skip all \'A\'"; - this.buttonUndo.UseVisualStyleBackColor = true; - this.buttonUndo.Visible = false; - this.buttonUndo.Click += new System.EventHandler(this.buttonUndo_Click); - // - // groupBoxSuggestions - // - this.groupBoxSuggestions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxSuggestions.Controls.Add(this.buttonUseSuggestion); - this.groupBoxSuggestions.Controls.Add(this.buttonUseSuggestionAlways); - this.groupBoxSuggestions.Controls.Add(this.checkBoxAutoChangeNames); - this.groupBoxSuggestions.Controls.Add(this.listBoxSuggestions); - this.groupBoxSuggestions.Location = new System.Drawing.Point(309, 120); - this.groupBoxSuggestions.Name = "groupBoxSuggestions"; - this.groupBoxSuggestions.Size = new System.Drawing.Size(291, 225); - this.groupBoxSuggestions.TabIndex = 1; - this.groupBoxSuggestions.TabStop = false; - this.groupBoxSuggestions.Text = "Suggestions"; - // - // checkBoxAutoChangeNames - // - this.checkBoxAutoChangeNames.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.checkBoxAutoChangeNames.AutoSize = true; - this.checkBoxAutoChangeNames.Location = new System.Drawing.Point(8, 201); - this.checkBoxAutoChangeNames.Name = "checkBoxAutoChangeNames"; - this.checkBoxAutoChangeNames.Size = new System.Drawing.Size(216, 17); - this.checkBoxAutoChangeNames.TabIndex = 3; - this.checkBoxAutoChangeNames.Text = "Auto fix names where only casing differ"; - this.checkBoxAutoChangeNames.UseVisualStyleBackColor = true; - this.checkBoxAutoChangeNames.CheckedChanged += new System.EventHandler(this.CheckBoxAutoChangeNamesCheckedChanged); - // - // buttonEditWholeText - // - this.buttonEditWholeText.Location = new System.Drawing.Point(175, 91); - this.buttonEditWholeText.Name = "buttonEditWholeText"; - this.buttonEditWholeText.Size = new System.Drawing.Size(128, 23); - this.buttonEditWholeText.TabIndex = 6; - this.buttonEditWholeText.Text = "Edit whole text"; - this.buttonEditWholeText.UseVisualStyleBackColor = true; - this.buttonEditWholeText.Click += new System.EventHandler(this.ButtonEditWholeTextClick); - // - // groupBoxEditWholeText - // - this.groupBoxEditWholeText.Controls.Add(this.buttonSkipText); - this.groupBoxEditWholeText.Controls.Add(this.buttonChangeWholeText); - this.groupBoxEditWholeText.Controls.Add(this.textBoxWholeText); - this.groupBoxEditWholeText.Location = new System.Drawing.Point(11, 120); - this.groupBoxEditWholeText.Name = "groupBoxEditWholeText"; - this.groupBoxEditWholeText.Size = new System.Drawing.Size(292, 192); - this.groupBoxEditWholeText.TabIndex = 40; - this.groupBoxEditWholeText.TabStop = false; - this.groupBoxEditWholeText.Text = "Edit whole text"; - // - // buttonSkipText - // - this.buttonSkipText.Location = new System.Drawing.Point(151, 88); - this.buttonSkipText.Name = "buttonSkipText"; - this.buttonSkipText.Size = new System.Drawing.Size(135, 21); - this.buttonSkipText.TabIndex = 35; - this.buttonSkipText.Text = "Skip once"; - this.buttonSkipText.UseVisualStyleBackColor = true; - this.buttonSkipText.Click += new System.EventHandler(this.ButtonSkipTextClick); - // - // buttonChangeWholeText - // - this.buttonChangeWholeText.Location = new System.Drawing.Point(6, 88); - this.buttonChangeWholeText.Name = "buttonChangeWholeText"; - this.buttonChangeWholeText.Size = new System.Drawing.Size(135, 21); - this.buttonChangeWholeText.TabIndex = 0; - this.buttonChangeWholeText.Text = "Change"; - this.buttonChangeWholeText.UseVisualStyleBackColor = true; - this.buttonChangeWholeText.Click += new System.EventHandler(this.ButtonChangeWholeTextClick); - // - // textBoxWholeText - // - this.textBoxWholeText.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBoxWholeText.Location = new System.Drawing.Point(6, 19); - this.textBoxWholeText.Multiline = true; - this.textBoxWholeText.Name = "textBoxWholeText"; - this.textBoxWholeText.Size = new System.Drawing.Size(280, 63); - this.textBoxWholeText.TabIndex = 31; - // - // labelActionInfo - // - this.labelActionInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelActionInfo.AutoSize = true; - this.labelActionInfo.Location = new System.Drawing.Point(12, 364); - this.labelActionInfo.Name = "labelActionInfo"; - this.labelActionInfo.Size = new System.Drawing.Size(79, 13); - this.labelActionInfo.TabIndex = 2; - this.labelActionInfo.Text = "labelActionInfo"; - // - // buttonSpellCheckDownload - // - this.buttonSpellCheckDownload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSpellCheckDownload.Location = new System.Drawing.Point(560, 32); - this.buttonSpellCheckDownload.Name = "buttonSpellCheckDownload"; - this.buttonSpellCheckDownload.Size = new System.Drawing.Size(28, 23); - this.buttonSpellCheckDownload.TabIndex = 9; - this.buttonSpellCheckDownload.Text = "..."; - this.buttonSpellCheckDownload.UseVisualStyleBackColor = true; - this.buttonSpellCheckDownload.Click += new System.EventHandler(this.buttonSpellCheckDownload_Click); - // - // SpellCheck - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(612, 386); - this.Controls.Add(this.buttonSpellCheckDownload); - this.Controls.Add(this.labelActionInfo); - this.Controls.Add(this.richTextBoxParagraph); - this.Controls.Add(this.comboBoxDictionaries); - this.Controls.Add(this.buttonEditWholeText); - this.Controls.Add(this.groupBoxSuggestions); - this.Controls.Add(this.labelFullText); - this.Controls.Add(this.buttonAbort); - this.Controls.Add(this.labelLanguage); - this.Controls.Add(this.groupBoxWordNotFound); - this.Controls.Add(this.groupBoxEditWholeText); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "SpellCheck"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Spell check"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SpellCheck_FormClosing); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormSpellCheck_KeyDown); - this.contextMenuStrip1.ResumeLayout(false); - this.groupBoxWordNotFound.ResumeLayout(false); - this.groupBoxWordNotFound.PerformLayout(); - this.groupBoxSuggestions.ResumeLayout(false); - this.groupBoxSuggestions.PerformLayout(); - this.groupBoxEditWholeText.ResumeLayout(false); - this.groupBoxEditWholeText.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonAddToDictionary; - private System.Windows.Forms.Button buttonSkipOnce; - private System.Windows.Forms.ComboBox comboBoxDictionaries; - private System.Windows.Forms.Label labelLanguage; - private System.Windows.Forms.RichTextBox richTextBoxParagraph; - private System.Windows.Forms.ListBox listBoxSuggestions; - private System.Windows.Forms.Label labelFullText; - private System.Windows.Forms.TextBox textBoxWord; - private System.Windows.Forms.Button buttonAbort; - private System.Windows.Forms.Button buttonSkipAll; - private System.Windows.Forms.Button buttonChange; - private System.Windows.Forms.Button buttonUseSuggestion; - private System.Windows.Forms.Button buttonChangeAll; - private System.Windows.Forms.Button buttonUseSuggestionAlways; - private System.Windows.Forms.Button buttonAddToNames; - private System.Windows.Forms.GroupBox groupBoxWordNotFound; - private System.Windows.Forms.GroupBox groupBoxSuggestions; - private System.Windows.Forms.Button buttonEditWholeText; - private System.Windows.Forms.GroupBox groupBoxEditWholeText; - private System.Windows.Forms.Button buttonSkipText; - private System.Windows.Forms.Button buttonChangeWholeText; - private System.Windows.Forms.TextBox textBoxWholeText; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem addXToNamesnoiseListToolStripMenuItem; - private System.Windows.Forms.CheckBox checkBoxAutoChangeNames; - private System.Windows.Forms.Label labelActionInfo; - private System.Windows.Forms.Button buttonSpellCheckDownload; - private System.Windows.Forms.Button buttonUndo; - private System.Windows.Forms.Button buttonGoogleIt; - private System.Windows.Forms.ToolStripMenuItem addXToUserDictionaryToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class SpellCheck + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonAddToDictionary = new System.Windows.Forms.Button(); + this.buttonSkipOnce = new System.Windows.Forms.Button(); + this.comboBoxDictionaries = new System.Windows.Forms.ComboBox(); + this.labelLanguage = new System.Windows.Forms.Label(); + this.richTextBoxParagraph = new System.Windows.Forms.RichTextBox(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.addXToNamesnoiseListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addXToUserDictionaryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.listBoxSuggestions = new System.Windows.Forms.ListBox(); + this.labelFullText = new System.Windows.Forms.Label(); + this.textBoxWord = new System.Windows.Forms.TextBox(); + this.buttonAbort = new System.Windows.Forms.Button(); + this.buttonSkipAll = new System.Windows.Forms.Button(); + this.buttonChange = new System.Windows.Forms.Button(); + this.buttonUseSuggestion = new System.Windows.Forms.Button(); + this.buttonChangeAll = new System.Windows.Forms.Button(); + this.buttonUseSuggestionAlways = new System.Windows.Forms.Button(); + this.buttonAddToNames = new System.Windows.Forms.Button(); + this.groupBoxWordNotFound = new System.Windows.Forms.GroupBox(); + this.buttonGoogleIt = new System.Windows.Forms.Button(); + this.buttonUndo = new System.Windows.Forms.Button(); + this.groupBoxSuggestions = new System.Windows.Forms.GroupBox(); + this.checkBoxAutoChangeNames = new System.Windows.Forms.CheckBox(); + this.buttonEditWholeText = new System.Windows.Forms.Button(); + this.groupBoxEditWholeText = new System.Windows.Forms.GroupBox(); + this.buttonSkipText = new System.Windows.Forms.Button(); + this.buttonChangeWholeText = new System.Windows.Forms.Button(); + this.textBoxWholeText = new System.Windows.Forms.TextBox(); + this.labelActionInfo = new System.Windows.Forms.Label(); + this.buttonSpellCheckDownload = new System.Windows.Forms.Button(); + this.contextMenuStrip1.SuspendLayout(); + this.groupBoxWordNotFound.SuspendLayout(); + this.groupBoxSuggestions.SuspendLayout(); + this.groupBoxEditWholeText.SuspendLayout(); + this.SuspendLayout(); + // + // buttonAddToDictionary + // + this.buttonAddToDictionary.Location = new System.Drawing.Point(6, 134); + this.buttonAddToDictionary.Name = "buttonAddToDictionary"; + this.buttonAddToDictionary.Size = new System.Drawing.Size(280, 23); + this.buttonAddToDictionary.TabIndex = 6; + this.buttonAddToDictionary.Text = "Add to user dictionary (not case sensitive)"; + this.buttonAddToDictionary.UseVisualStyleBackColor = true; + this.buttonAddToDictionary.Click += new System.EventHandler(this.ButtonAddToDictionaryClick); + this.buttonAddToDictionary.MouseEnter += new System.EventHandler(this.buttonAddToDictionary_MouseEnter); + this.buttonAddToDictionary.MouseLeave += new System.EventHandler(this.buttonAddToDictionary_MouseLeave); + // + // buttonSkipOnce + // + this.buttonSkipOnce.Location = new System.Drawing.Point(6, 76); + this.buttonSkipOnce.Name = "buttonSkipOnce"; + this.buttonSkipOnce.Size = new System.Drawing.Size(136, 23); + this.buttonSkipOnce.TabIndex = 3; + this.buttonSkipOnce.Text = "Skip &once"; + this.buttonSkipOnce.UseVisualStyleBackColor = true; + this.buttonSkipOnce.Click += new System.EventHandler(this.ButtonSkipOnceClick); + this.buttonSkipOnce.MouseEnter += new System.EventHandler(this.buttonSkipOnce_MouseEnter); + this.buttonSkipOnce.MouseLeave += new System.EventHandler(this.buttonSkipOnce_MouseLeave); + // + // comboBoxDictionaries + // + this.comboBoxDictionaries.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxDictionaries.FormattingEnabled = true; + this.comboBoxDictionaries.Location = new System.Drawing.Point(317, 33); + this.comboBoxDictionaries.Name = "comboBoxDictionaries"; + this.comboBoxDictionaries.Size = new System.Drawing.Size(237, 21); + this.comboBoxDictionaries.TabIndex = 8; + this.comboBoxDictionaries.SelectedIndexChanged += new System.EventHandler(this.ComboBoxDictionariesSelectedIndexChanged); + // + // labelLanguage + // + this.labelLanguage.AutoSize = true; + this.labelLanguage.Location = new System.Drawing.Point(314, 14); + this.labelLanguage.Name = "labelLanguage"; + this.labelLanguage.Size = new System.Drawing.Size(54, 13); + this.labelLanguage.TabIndex = 7; + this.labelLanguage.Text = "Language"; + // + // richTextBoxParagraph + // + this.richTextBoxParagraph.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.richTextBoxParagraph.ContextMenuStrip = this.contextMenuStrip1; + this.richTextBoxParagraph.Location = new System.Drawing.Point(11, 33); + this.richTextBoxParagraph.Name = "richTextBoxParagraph"; + this.richTextBoxParagraph.ReadOnly = true; + this.richTextBoxParagraph.Size = new System.Drawing.Size(292, 54); + this.richTextBoxParagraph.TabIndex = 5; + this.richTextBoxParagraph.Text = ""; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addXToNamesnoiseListToolStripMenuItem, + this.addXToUserDictionaryToolStripMenuItem, + this.toolStripSeparator1, + this.deleteToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(209, 76); + this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStrip1Opening); + // + // addXToNamesnoiseListToolStripMenuItem + // + this.addXToNamesnoiseListToolStripMenuItem.Name = "addXToNamesnoiseListToolStripMenuItem"; + this.addXToNamesnoiseListToolStripMenuItem.Size = new System.Drawing.Size(208, 22); + this.addXToNamesnoiseListToolStripMenuItem.Text = "Add x to names/noise list"; + this.addXToNamesnoiseListToolStripMenuItem.Click += new System.EventHandler(this.AddXToNamesnoiseListToolStripMenuItemClick); + // + // addXToUserDictionaryToolStripMenuItem + // + this.addXToUserDictionaryToolStripMenuItem.Name = "addXToUserDictionaryToolStripMenuItem"; + this.addXToUserDictionaryToolStripMenuItem.Size = new System.Drawing.Size(208, 22); + this.addXToUserDictionaryToolStripMenuItem.Text = "Add x to user dictionary"; + this.addXToUserDictionaryToolStripMenuItem.Click += new System.EventHandler(this.AddXToUserDictionaryToolStripMenuItem_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(205, 6); + // + // deleteToolStripMenuItem + // + this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(208, 22); + this.deleteToolStripMenuItem.Text = "Delete..."; + this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); + // + // listBoxSuggestions + // + this.listBoxSuggestions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.listBoxSuggestions.FormattingEnabled = true; + this.listBoxSuggestions.Location = new System.Drawing.Point(8, 47); + this.listBoxSuggestions.Name = "listBoxSuggestions"; + this.listBoxSuggestions.Size = new System.Drawing.Size(272, 121); + this.listBoxSuggestions.TabIndex = 2; + this.listBoxSuggestions.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.ListBoxSuggestionsMouseDoubleClick); + // + // labelFullText + // + this.labelFullText.AutoSize = true; + this.labelFullText.Location = new System.Drawing.Point(8, 14); + this.labelFullText.Name = "labelFullText"; + this.labelFullText.Size = new System.Drawing.Size(46, 13); + this.labelFullText.TabIndex = 4; + this.labelFullText.Text = "Full text"; + // + // textBoxWord + // + this.textBoxWord.Location = new System.Drawing.Point(6, 20); + this.textBoxWord.Name = "textBoxWord"; + this.textBoxWord.Size = new System.Drawing.Size(280, 21); + this.textBoxWord.TabIndex = 0; + this.textBoxWord.TextChanged += new System.EventHandler(this.textBoxWord_TextChanged); + // + // buttonAbort + // + this.buttonAbort.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAbort.Location = new System.Drawing.Point(515, 351); + this.buttonAbort.Name = "buttonAbort"; + this.buttonAbort.Size = new System.Drawing.Size(85, 23); + this.buttonAbort.TabIndex = 3; + this.buttonAbort.Text = "Abort"; + this.buttonAbort.UseVisualStyleBackColor = true; + this.buttonAbort.Click += new System.EventHandler(this.ButtonAbortClick); + // + // buttonSkipAll + // + this.buttonSkipAll.Location = new System.Drawing.Point(147, 76); + this.buttonSkipAll.Name = "buttonSkipAll"; + this.buttonSkipAll.Size = new System.Drawing.Size(138, 23); + this.buttonSkipAll.TabIndex = 4; + this.buttonSkipAll.Text = "&Skip all"; + this.buttonSkipAll.UseVisualStyleBackColor = true; + this.buttonSkipAll.Click += new System.EventHandler(this.ButtonSkipAllClick); + this.buttonSkipAll.MouseEnter += new System.EventHandler(this.buttonSkipAll_MouseEnter); + this.buttonSkipAll.MouseLeave += new System.EventHandler(this.buttonSkipAll_MouseLeave); + // + // buttonChange + // + this.buttonChange.Location = new System.Drawing.Point(6, 47); + this.buttonChange.Name = "buttonChange"; + this.buttonChange.Size = new System.Drawing.Size(136, 23); + this.buttonChange.TabIndex = 1; + this.buttonChange.Text = "Change"; + this.buttonChange.UseVisualStyleBackColor = true; + this.buttonChange.Click += new System.EventHandler(this.ButtonChangeClick); + this.buttonChange.MouseEnter += new System.EventHandler(this.buttonChange_MouseEnter); + this.buttonChange.MouseLeave += new System.EventHandler(this.buttonChange_MouseLeave); + // + // buttonUseSuggestion + // + this.buttonUseSuggestion.Location = new System.Drawing.Point(68, 17); + this.buttonUseSuggestion.Name = "buttonUseSuggestion"; + this.buttonUseSuggestion.Size = new System.Drawing.Size(90, 23); + this.buttonUseSuggestion.TabIndex = 0; + this.buttonUseSuggestion.Text = "Use"; + this.buttonUseSuggestion.UseVisualStyleBackColor = true; + this.buttonUseSuggestion.Click += new System.EventHandler(this.ButtonUseSuggestionClick); + // + // buttonChangeAll + // + this.buttonChangeAll.Location = new System.Drawing.Point(148, 47); + this.buttonChangeAll.Name = "buttonChangeAll"; + this.buttonChangeAll.Size = new System.Drawing.Size(138, 23); + this.buttonChangeAll.TabIndex = 2; + this.buttonChangeAll.Text = "Change all"; + this.buttonChangeAll.UseVisualStyleBackColor = true; + this.buttonChangeAll.Click += new System.EventHandler(this.ButtonChangeAllClick); + this.buttonChangeAll.MouseEnter += new System.EventHandler(this.buttonChangeAll_MouseEnter); + this.buttonChangeAll.MouseLeave += new System.EventHandler(this.buttonChangeAll_MouseLeave); + // + // buttonUseSuggestionAlways + // + this.buttonUseSuggestionAlways.Location = new System.Drawing.Point(164, 17); + this.buttonUseSuggestionAlways.Name = "buttonUseSuggestionAlways"; + this.buttonUseSuggestionAlways.Size = new System.Drawing.Size(115, 23); + this.buttonUseSuggestionAlways.TabIndex = 1; + this.buttonUseSuggestionAlways.Text = "Use always"; + this.buttonUseSuggestionAlways.UseVisualStyleBackColor = true; + this.buttonUseSuggestionAlways.Click += new System.EventHandler(this.ButtonUseSuggestionAlwaysClick); + // + // buttonAddToNames + // + this.buttonAddToNames.Location = new System.Drawing.Point(5, 105); + this.buttonAddToNames.Name = "buttonAddToNames"; + this.buttonAddToNames.Size = new System.Drawing.Size(280, 23); + this.buttonAddToNames.TabIndex = 5; + this.buttonAddToNames.Text = "Add to names/noise list (case sensitive)"; + this.buttonAddToNames.UseVisualStyleBackColor = true; + this.buttonAddToNames.Click += new System.EventHandler(this.ButtonAddToNamesClick); + this.buttonAddToNames.MouseEnter += new System.EventHandler(this.buttonAddToNames_MouseEnter); + this.buttonAddToNames.MouseLeave += new System.EventHandler(this.buttonAddToNames_MouseLeave); + // + // groupBoxWordNotFound + // + this.groupBoxWordNotFound.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.groupBoxWordNotFound.Controls.Add(this.buttonGoogleIt); + this.groupBoxWordNotFound.Controls.Add(this.buttonUndo); + this.groupBoxWordNotFound.Controls.Add(this.buttonAddToNames); + this.groupBoxWordNotFound.Controls.Add(this.buttonAddToDictionary); + this.groupBoxWordNotFound.Controls.Add(this.buttonSkipOnce); + this.groupBoxWordNotFound.Controls.Add(this.buttonChangeAll); + this.groupBoxWordNotFound.Controls.Add(this.textBoxWord); + this.groupBoxWordNotFound.Controls.Add(this.buttonSkipAll); + this.groupBoxWordNotFound.Controls.Add(this.buttonChange); + this.groupBoxWordNotFound.Location = new System.Drawing.Point(11, 120); + this.groupBoxWordNotFound.Name = "groupBoxWordNotFound"; + this.groupBoxWordNotFound.Size = new System.Drawing.Size(292, 225); + this.groupBoxWordNotFound.TabIndex = 0; + this.groupBoxWordNotFound.TabStop = false; + this.groupBoxWordNotFound.Text = "Word not found"; + // + // buttonGoogleIt + // + this.buttonGoogleIt.Location = new System.Drawing.Point(6, 163); + this.buttonGoogleIt.Name = "buttonGoogleIt"; + this.buttonGoogleIt.Size = new System.Drawing.Size(280, 23); + this.buttonGoogleIt.TabIndex = 7; + this.buttonGoogleIt.Text = "&Google it"; + this.buttonGoogleIt.UseVisualStyleBackColor = true; + this.buttonGoogleIt.Click += new System.EventHandler(this.buttonGoogleIt_Click); + // + // buttonUndo + // + this.buttonUndo.Location = new System.Drawing.Point(6, 192); + this.buttonUndo.Name = "buttonUndo"; + this.buttonUndo.Size = new System.Drawing.Size(280, 23); + this.buttonUndo.TabIndex = 8; + this.buttonUndo.Text = "Undo: skip all \'A\'"; + this.buttonUndo.UseVisualStyleBackColor = true; + this.buttonUndo.Visible = false; + this.buttonUndo.Click += new System.EventHandler(this.buttonUndo_Click); + // + // groupBoxSuggestions + // + this.groupBoxSuggestions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxSuggestions.Controls.Add(this.buttonUseSuggestion); + this.groupBoxSuggestions.Controls.Add(this.buttonUseSuggestionAlways); + this.groupBoxSuggestions.Controls.Add(this.checkBoxAutoChangeNames); + this.groupBoxSuggestions.Controls.Add(this.listBoxSuggestions); + this.groupBoxSuggestions.Location = new System.Drawing.Point(309, 120); + this.groupBoxSuggestions.Name = "groupBoxSuggestions"; + this.groupBoxSuggestions.Size = new System.Drawing.Size(291, 225); + this.groupBoxSuggestions.TabIndex = 1; + this.groupBoxSuggestions.TabStop = false; + this.groupBoxSuggestions.Text = "Suggestions"; + // + // checkBoxAutoChangeNames + // + this.checkBoxAutoChangeNames.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.checkBoxAutoChangeNames.AutoSize = true; + this.checkBoxAutoChangeNames.Location = new System.Drawing.Point(8, 201); + this.checkBoxAutoChangeNames.Name = "checkBoxAutoChangeNames"; + this.checkBoxAutoChangeNames.Size = new System.Drawing.Size(216, 17); + this.checkBoxAutoChangeNames.TabIndex = 3; + this.checkBoxAutoChangeNames.Text = "Auto fix names where only casing differ"; + this.checkBoxAutoChangeNames.UseVisualStyleBackColor = true; + this.checkBoxAutoChangeNames.CheckedChanged += new System.EventHandler(this.CheckBoxAutoChangeNamesCheckedChanged); + // + // buttonEditWholeText + // + this.buttonEditWholeText.Location = new System.Drawing.Point(175, 91); + this.buttonEditWholeText.Name = "buttonEditWholeText"; + this.buttonEditWholeText.Size = new System.Drawing.Size(128, 23); + this.buttonEditWholeText.TabIndex = 6; + this.buttonEditWholeText.Text = "Edit whole text"; + this.buttonEditWholeText.UseVisualStyleBackColor = true; + this.buttonEditWholeText.Click += new System.EventHandler(this.ButtonEditWholeTextClick); + // + // groupBoxEditWholeText + // + this.groupBoxEditWholeText.Controls.Add(this.buttonSkipText); + this.groupBoxEditWholeText.Controls.Add(this.buttonChangeWholeText); + this.groupBoxEditWholeText.Controls.Add(this.textBoxWholeText); + this.groupBoxEditWholeText.Location = new System.Drawing.Point(11, 120); + this.groupBoxEditWholeText.Name = "groupBoxEditWholeText"; + this.groupBoxEditWholeText.Size = new System.Drawing.Size(292, 192); + this.groupBoxEditWholeText.TabIndex = 40; + this.groupBoxEditWholeText.TabStop = false; + this.groupBoxEditWholeText.Text = "Edit whole text"; + // + // buttonSkipText + // + this.buttonSkipText.Location = new System.Drawing.Point(151, 88); + this.buttonSkipText.Name = "buttonSkipText"; + this.buttonSkipText.Size = new System.Drawing.Size(135, 21); + this.buttonSkipText.TabIndex = 35; + this.buttonSkipText.Text = "Skip once"; + this.buttonSkipText.UseVisualStyleBackColor = true; + this.buttonSkipText.Click += new System.EventHandler(this.ButtonSkipTextClick); + // + // buttonChangeWholeText + // + this.buttonChangeWholeText.Location = new System.Drawing.Point(6, 88); + this.buttonChangeWholeText.Name = "buttonChangeWholeText"; + this.buttonChangeWholeText.Size = new System.Drawing.Size(135, 21); + this.buttonChangeWholeText.TabIndex = 0; + this.buttonChangeWholeText.Text = "Change"; + this.buttonChangeWholeText.UseVisualStyleBackColor = true; + this.buttonChangeWholeText.Click += new System.EventHandler(this.ButtonChangeWholeTextClick); + // + // textBoxWholeText + // + this.textBoxWholeText.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textBoxWholeText.Location = new System.Drawing.Point(6, 19); + this.textBoxWholeText.Multiline = true; + this.textBoxWholeText.Name = "textBoxWholeText"; + this.textBoxWholeText.Size = new System.Drawing.Size(280, 63); + this.textBoxWholeText.TabIndex = 31; + // + // labelActionInfo + // + this.labelActionInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelActionInfo.AutoSize = true; + this.labelActionInfo.Location = new System.Drawing.Point(12, 364); + this.labelActionInfo.Name = "labelActionInfo"; + this.labelActionInfo.Size = new System.Drawing.Size(79, 13); + this.labelActionInfo.TabIndex = 2; + this.labelActionInfo.Text = "labelActionInfo"; + // + // buttonSpellCheckDownload + // + this.buttonSpellCheckDownload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSpellCheckDownload.Location = new System.Drawing.Point(560, 32); + this.buttonSpellCheckDownload.Name = "buttonSpellCheckDownload"; + this.buttonSpellCheckDownload.Size = new System.Drawing.Size(28, 23); + this.buttonSpellCheckDownload.TabIndex = 9; + this.buttonSpellCheckDownload.Text = "..."; + this.buttonSpellCheckDownload.UseVisualStyleBackColor = true; + this.buttonSpellCheckDownload.Click += new System.EventHandler(this.buttonSpellCheckDownload_Click); + // + // SpellCheck + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(612, 386); + this.Controls.Add(this.buttonSpellCheckDownload); + this.Controls.Add(this.labelActionInfo); + this.Controls.Add(this.richTextBoxParagraph); + this.Controls.Add(this.comboBoxDictionaries); + this.Controls.Add(this.buttonEditWholeText); + this.Controls.Add(this.groupBoxSuggestions); + this.Controls.Add(this.labelFullText); + this.Controls.Add(this.buttonAbort); + this.Controls.Add(this.labelLanguage); + this.Controls.Add(this.groupBoxWordNotFound); + this.Controls.Add(this.groupBoxEditWholeText); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SpellCheck"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Spell check"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SpellCheck_FormClosing); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormSpellCheck_KeyDown); + this.contextMenuStrip1.ResumeLayout(false); + this.groupBoxWordNotFound.ResumeLayout(false); + this.groupBoxWordNotFound.PerformLayout(); + this.groupBoxSuggestions.ResumeLayout(false); + this.groupBoxSuggestions.PerformLayout(); + this.groupBoxEditWholeText.ResumeLayout(false); + this.groupBoxEditWholeText.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonAddToDictionary; + private System.Windows.Forms.Button buttonSkipOnce; + private System.Windows.Forms.ComboBox comboBoxDictionaries; + private System.Windows.Forms.Label labelLanguage; + private System.Windows.Forms.RichTextBox richTextBoxParagraph; + private System.Windows.Forms.ListBox listBoxSuggestions; + private System.Windows.Forms.Label labelFullText; + private System.Windows.Forms.TextBox textBoxWord; + private System.Windows.Forms.Button buttonAbort; + private System.Windows.Forms.Button buttonSkipAll; + private System.Windows.Forms.Button buttonChange; + private System.Windows.Forms.Button buttonUseSuggestion; + private System.Windows.Forms.Button buttonChangeAll; + private System.Windows.Forms.Button buttonUseSuggestionAlways; + private System.Windows.Forms.Button buttonAddToNames; + private System.Windows.Forms.GroupBox groupBoxWordNotFound; + private System.Windows.Forms.GroupBox groupBoxSuggestions; + private System.Windows.Forms.Button buttonEditWholeText; + private System.Windows.Forms.GroupBox groupBoxEditWholeText; + private System.Windows.Forms.Button buttonSkipText; + private System.Windows.Forms.Button buttonChangeWholeText; + private System.Windows.Forms.TextBox textBoxWholeText; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem addXToNamesnoiseListToolStripMenuItem; + private System.Windows.Forms.CheckBox checkBoxAutoChangeNames; + private System.Windows.Forms.Label labelActionInfo; + private System.Windows.Forms.Button buttonSpellCheckDownload; + private System.Windows.Forms.Button buttonUndo; + private System.Windows.Forms.Button buttonGoogleIt; + private System.Windows.Forms.ToolStripMenuItem addXToUserDictionaryToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; + } } \ No newline at end of file diff --git a/src/Forms/SpellCheck.cs b/src/ui/Forms/SpellCheck.cs similarity index 97% rename from src/Forms/SpellCheck.cs rename to src/ui/Forms/SpellCheck.cs index c8e930d78..d04b15962 100644 --- a/src/Forms/SpellCheck.cs +++ b/src/ui/Forms/SpellCheck.cs @@ -1,1298 +1,1298 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Enums; -using Nikse.SubtitleEdit.Core.Interfaces; -using Nikse.SubtitleEdit.Core.SpellCheck; -using Nikse.SubtitleEdit.Logic; -using Nikse.SubtitleEdit.Logic.SpellCheck; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class SpellCheck : Form, IDoSpell - { - private List _undoList = new List(); - private List _suggestions; - private string _currentAction; - public SpellCheckAction Action { get; set; } = SpellCheckAction.Skip; - public string ChangeWord - { - get => textBoxWord.Text; - set => textBoxWord.Text = value; - } - public string ChangeWholeText => textBoxWholeText.Text; - public bool AutoFixNames => checkBoxAutoChangeNames.Checked; - - private SpellCheckWordLists _spellCheckWordLists; - private List _skipAllList = new List(); - private HashSet _skipOneList = new HashSet(); - private Dictionary _changeAllDictionary; - private string _prefix = string.Empty; - private string _postfix = string.Empty; - private Hunspell _hunspell; - private Paragraph _currentParagraph; - private int _currentIndex; - private string _currentWord; - private SpellCheckWord _currentSpellCheckWord; - private List _words; - private int _wordsIndex; - private Subtitle _subtitle; - private string _originalWord; - private int _noOfSkippedWords; - private int _noOfChangedWords; - private int _noOfCorrectWords; - private int _noOfNames; - private int _noOfAddedWords; - private bool _firstChange = true; - private string _languageName; - private Main _mainWindow; - private string _currentDictionary; - - public class SuggestionParameter - { - public string InputWord { get; set; } - public List Suggestions { get; set; } - public Hunspell Hunspell { get; set; } - public bool Success { get; set; } - - public SuggestionParameter(string word, Hunspell hunspell) - { - InputWord = word; - Suggestions = new List(); - Hunspell = hunspell; - Success = false; - } - } - - public string LanguageString - { - get - { - string name = comboBoxDictionaries.SelectedItem.ToString(); - int start = name.LastIndexOf('['); - int end = name.LastIndexOf(']'); - if (start >= 0 && end > start) - { - start++; - name = name.Substring(start, end - start); - return name; - } - return null; - } - } - - public SpellCheck() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - labelActionInfo.Text = string.Empty; - Text = Configuration.Settings.Language.SpellCheck.Title; - labelFullText.Text = Configuration.Settings.Language.SpellCheck.FullText; - labelLanguage.Text = Configuration.Settings.Language.SpellCheck.Language; - groupBoxWordNotFound.Text = Configuration.Settings.Language.SpellCheck.WordNotFound; - buttonAddToDictionary.Text = Configuration.Settings.Language.SpellCheck.AddToUserDictionary; - buttonChange.Text = Configuration.Settings.Language.SpellCheck.Change; - buttonChangeAll.Text = Configuration.Settings.Language.SpellCheck.ChangeAll; - buttonSkipAll.Text = Configuration.Settings.Language.SpellCheck.SkipAll; - buttonSkipOnce.Text = Configuration.Settings.Language.SpellCheck.SkipOnce; - buttonUseSuggestion.Text = Configuration.Settings.Language.SpellCheck.Use; - buttonUseSuggestionAlways.Text = Configuration.Settings.Language.SpellCheck.UseAlways; - buttonAbort.Text = Configuration.Settings.Language.SpellCheck.Abort; - buttonEditWholeText.Text = Configuration.Settings.Language.SpellCheck.EditWholeText; - checkBoxAutoChangeNames.Text = Configuration.Settings.Language.SpellCheck.AutoFixNames; - checkBoxAutoChangeNames.Checked = Configuration.Settings.Tools.SpellCheckAutoChangeNames; - groupBoxEditWholeText.Text = Configuration.Settings.Language.SpellCheck.EditWholeText; - buttonChangeWholeText.Text = Configuration.Settings.Language.SpellCheck.Change; - buttonSkipText.Text = Configuration.Settings.Language.SpellCheck.SkipOnce; - groupBoxSuggestions.Text = Configuration.Settings.Language.SpellCheck.Suggestions; - buttonAddToNames.Text = Configuration.Settings.Language.SpellCheck.AddToNamesAndIgnoreList; - buttonGoogleIt.Text = Configuration.Settings.Language.Main.VideoControls.GoogleIt; - deleteToolStripMenuItem.Text = Configuration.Settings.Language.General.DeleteCurrentLine; - UiUtil.FixLargeFonts(this, buttonAbort); - } - - public void Initialize(string languageName, SpellCheckWord word, List suggestions, string paragraph, string progress) - { - _originalWord = word.Text; - _suggestions = suggestions; - groupBoxWordNotFound.Visible = true; - groupBoxEditWholeText.Visible = false; - buttonEditWholeText.Text = Configuration.Settings.Language.SpellCheck.EditWholeText; - Text = Configuration.Settings.Language.SpellCheck.Title + " [" + languageName + "] - " + progress; - textBoxWord.Text = word.Text; - textBoxWholeText.Text = paragraph; - listBoxSuggestions.Items.Clear(); - foreach (string suggestion in suggestions) - { - listBoxSuggestions.Items.Add(suggestion); - } - if (listBoxSuggestions.Items.Count > 0) - { - listBoxSuggestions.SelectedIndex = 0; - } - - richTextBoxParagraph.Text = paragraph; - - FillSpellCheckDictionaries(languageName); - ShowActiveWordWithColor(word); - Action = SpellCheckAction.Skip; - DialogResult = DialogResult.None; - } - - private void FillSpellCheckDictionaries(string languageName) - { - comboBoxDictionaries.SelectedIndexChanged -= ComboBoxDictionariesSelectedIndexChanged; - comboBoxDictionaries.Items.Clear(); - foreach (string name in Utilities.GetDictionaryLanguages()) - { - comboBoxDictionaries.Items.Add(name); - if (name.Contains("[" + languageName + "]")) - { - comboBoxDictionaries.SelectedIndex = comboBoxDictionaries.Items.Count - 1; - } - } - comboBoxDictionaries.AutoCompleteSource = AutoCompleteSource.ListItems; - comboBoxDictionaries.AutoCompleteMode = AutoCompleteMode.Append; - comboBoxDictionaries.SelectedIndexChanged += ComboBoxDictionariesSelectedIndexChanged; - } - - private void ShowActiveWordWithColor(SpellCheckWord word) - { - richTextBoxParagraph.SelectAll(); - richTextBoxParagraph.SelectionColor = Color.Black; - richTextBoxParagraph.SelectionLength = 0; - - for (int i = 0; i < 10; i++) - { - int idx = word.Index - i; - if (idx >= 0 && idx < richTextBoxParagraph.Text.Length && richTextBoxParagraph.Text.Substring(idx).StartsWith(word.Text, StringComparison.Ordinal)) - { - richTextBoxParagraph.SelectionStart = idx; - richTextBoxParagraph.SelectionLength = word.Text.Length; - richTextBoxParagraph.SelectionColor = Color.Red; - break; - } - idx = word.Index + i; - if (idx >= 0 && idx < richTextBoxParagraph.Text.Length && richTextBoxParagraph.Text.Substring(idx).StartsWith(word.Text, StringComparison.Ordinal)) - { - richTextBoxParagraph.SelectionStart = idx; - richTextBoxParagraph.SelectionLength = word.Text.Length; - richTextBoxParagraph.SelectionColor = Color.Red; - break; - } - } - } - - private void FormSpellCheck_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - Action = SpellCheckAction.Abort; - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#spellcheck"); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.G) - { - e.SuppressKeyPress = true; - UiUtil.OpenURL("https://www.google.com/search?q=" + Utilities.UrlEncode(textBoxWord.Text)); - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Z) - { - if (buttonUndo.Visible) - { - buttonUndo_Click(null, null); - e.SuppressKeyPress = true; - } - } - } - - private void ButtonAbortClick(object sender, EventArgs e) - { - ShowEndStatusMessage(Configuration.Settings.Language.SpellCheck.SpellCheckAborted); - DialogResult = DialogResult.Abort; - } - - private void ButtonChangeClick(object sender, EventArgs e) - { - PushUndo($"{Configuration.Settings.Language.SpellCheck.Change}: {_currentWord + " > " + textBoxWord.Text}", SpellCheckAction.Change); - DoAction(SpellCheckAction.Change); - } - - private void ButtonUseSuggestionClick(object sender, EventArgs e) - { - if (listBoxSuggestions.SelectedIndex >= 0) - { - textBoxWord.Text = listBoxSuggestions.SelectedItem.ToString(); - PushUndo($"{Configuration.Settings.Language.SpellCheck.Change}: {_currentWord + " > " + textBoxWord.Text}", SpellCheckAction.Change); - DoAction(SpellCheckAction.Change); - } - } - - private void ButtonSkipAllClick(object sender, EventArgs e) - { - PushUndo($"{Configuration.Settings.Language.SpellCheck.SkipAll}: {textBoxWord.Text}", SpellCheckAction.SkipAll); - DoAction(SpellCheckAction.SkipAll); - } - - private void ButtonSkipOnceClick(object sender, EventArgs e) - { - PushUndo($"{Configuration.Settings.Language.SpellCheck.SkipOnce}: {textBoxWord.Text}", SpellCheckAction.Skip); - DoAction(SpellCheckAction.Skip); - } - - private void ButtonAddToDictionaryClick(object sender, EventArgs e) - { - PushUndo($"{Configuration.Settings.Language.SpellCheck.AddToUserDictionary}: {textBoxWord.Text}", SpellCheckAction.AddToDictionary); - DoAction(SpellCheckAction.AddToDictionary); - } - - private void ComboBoxDictionariesSelectedIndexChanged(object sender, EventArgs e) - { - Configuration.Settings.General.SpellCheckLanguage = LanguageString; - Configuration.Settings.Save(); - _languageName = LanguageString; - string dictionary = Utilities.DictionaryFolder + _languageName; - LoadDictionaries(Utilities.DictionaryFolder, dictionary, _languageName); - _wordsIndex--; - PrepareNextWord(); - } - - private void LoadHunspell(string dictionary) - { - _currentDictionary = dictionary; - _hunspell?.Dispose(); - _hunspell = Hunspell.GetHunspell(dictionary); - } - - public bool DoSpell(string word) - { - return _hunspell.Spell(word); - } - - public List DoSuggest(string word) - { - var parameter = new SuggestionParameter(word, _hunspell); - var suggestThread = new System.Threading.Thread(DoWork); - suggestThread.Start(parameter); - suggestThread.Join(3000); // wait max 3 seconds - suggestThread.Abort(); - if (!parameter.Success) - { - LoadHunspell(_currentDictionary); - } - - return parameter.Suggestions; - } - - public static void DoWork(object data) - { - var parameter = (SuggestionParameter)data; - parameter.Suggestions = parameter.Hunspell.Suggest(parameter.InputWord); - parameter.Success = true; - } - - private void ButtonChangeAllClick(object sender, EventArgs e) - { - PushUndo($"{Configuration.Settings.Language.SpellCheck.ChangeAll}: {_currentWord + " > " + textBoxWord.Text}", SpellCheckAction.ChangeAll); - DoAction(SpellCheckAction.ChangeAll); - } - - private void ButtonUseSuggestionAlwaysClick(object sender, EventArgs e) - { - if (listBoxSuggestions.SelectedIndex >= 0) - { - textBoxWord.Text = listBoxSuggestions.SelectedItem.ToString(); - PushUndo($"{Configuration.Settings.Language.SpellCheck.ChangeAll}: {_currentWord + " > " + textBoxWord.Text}", SpellCheckAction.ChangeAll); - DoAction(SpellCheckAction.ChangeAll); - } - } - - private void SpellCheck_FormClosing(object sender, FormClosingEventArgs e) - { - Configuration.Settings.Tools.SpellCheckAutoChangeNames = AutoFixNames; - if (e.CloseReason == CloseReason.UserClosing) - { - DialogResult = DialogResult.Abort; - } - } - - private void ButtonAddToNamesClick(object sender, EventArgs e) - { - PushUndo($"{Configuration.Settings.Language.SpellCheck.AddToNamesAndIgnoreList}: {textBoxWord.Text}", SpellCheckAction.AddToNames); - DoAction(SpellCheckAction.AddToNames); - } - - private void ButtonEditWholeTextClick(object sender, EventArgs e) - { - if (groupBoxWordNotFound.Visible) - { - groupBoxWordNotFound.Visible = false; - groupBoxEditWholeText.Visible = true; - buttonEditWholeText.Text = Configuration.Settings.Language.SpellCheck.EditWordOnly; - textBoxWholeText.Focus(); - } - else - { - groupBoxWordNotFound.Visible = true; - groupBoxEditWholeText.Visible = false; - buttonEditWholeText.Text = Configuration.Settings.Language.SpellCheck.EditWholeText; - textBoxWord.Focus(); - } - } - - private void ButtonSkipTextClick(object sender, EventArgs e) - { - PushUndo($"{Configuration.Settings.Language.SpellCheck.SkipOnce}", SpellCheckAction.Skip); - DoAction(SpellCheckAction.SkipWholeLine); - } - - private void ButtonChangeWholeTextClick(object sender, EventArgs e) - { - PushUndo($"{Configuration.Settings.Language.SpellCheck.EditWholeText}", SpellCheckAction.ChangeWholeText); - DoAction(SpellCheckAction.ChangeWholeText); - } - - private void ContextMenuStrip1Opening(object sender, System.ComponentModel.CancelEventArgs e) - { - bool showAddItems = false; - if (!string.IsNullOrWhiteSpace(richTextBoxParagraph.SelectedText)) - { - string word = richTextBoxParagraph.SelectedText.Trim(); - addXToNamesnoiseListToolStripMenuItem.Text = string.Format(Configuration.Settings.Language.SpellCheck.AddXToNames, word); - addXToUserDictionaryToolStripMenuItem.Text = string.Format(Configuration.Settings.Language.SpellCheck.AddXToUserDictionary, word); - showAddItems = true; - } - addXToNamesnoiseListToolStripMenuItem.Visible = showAddItems; - addXToUserDictionaryToolStripMenuItem.Visible = showAddItems; - toolStripSeparator1.Visible = showAddItems; - } - - private void AddXToNamesnoiseListToolStripMenuItemClick(object sender, EventArgs e) - { - if (!string.IsNullOrWhiteSpace(richTextBoxParagraph.SelectedText)) - { - ChangeWord = richTextBoxParagraph.SelectedText.Trim(); - DoAction(SpellCheckAction.AddToNamesOnly); - } - } - - private void AddXToUserDictionaryToolStripMenuItem_Click(object sender, EventArgs e) - { - if (!string.IsNullOrWhiteSpace(richTextBoxParagraph.SelectedText)) - { - ChangeWord = richTextBoxParagraph.SelectedText.Trim(); - DoAction(SpellCheckAction.AddToDictionary); - } - } - - private void CheckBoxAutoChangeNamesCheckedChanged(object sender, EventArgs e) - { - if (textBoxWord.Text.Length < 2) - { - return; - } - - DoAutoFixNames(textBoxWord.Text, _suggestions); - } - - private void ListBoxSuggestionsMouseDoubleClick(object sender, MouseEventArgs e) - { - ButtonUseSuggestionAlwaysClick(null, null); - } - - public void DoAction(SpellCheckAction action) - { - switch (action) - { - case SpellCheckAction.Change: - _noOfChangedWords++; - _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange, _wordsIndex); - break; - case SpellCheckAction.ChangeAll: - _noOfChangedWords++; - if (!_changeAllDictionary.ContainsKey(_currentWord)) - { - _changeAllDictionary.Add(_currentWord, ChangeWord); - _spellCheckWordLists.UseAlwaysListAdd(_currentWord, ChangeWord); - } - _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange, -1); - break; - case SpellCheckAction.Skip: - _noOfSkippedWords++; - string key = _currentIndex + "-" + _wordsIndex + "-" + _currentWord; - if (!_skipOneList.Contains(key)) - { - _skipOneList.Add(key); - } - - break; - case SpellCheckAction.SkipWholeLine: - _wordsIndex = int.MaxValue - 1; // Go to next line - break; - case SpellCheckAction.SkipAll: - _noOfSkippedWords++; - _skipAllList.Add(ChangeWord.ToUpperInvariant()); - if (ChangeWord.EndsWith('\'') || ChangeWord.StartsWith('\'')) - { - _skipAllList.Add(ChangeWord.ToUpperInvariant().Trim('\'')); - } - - break; - case SpellCheckAction.AddToDictionary: - if (_spellCheckWordLists.AddUserWord(ChangeWord)) - { - _noOfAddedWords++; - } - - break; - case SpellCheckAction.AddToNames: - _spellCheckWordLists.AddName(ChangeWord); - if (string.Compare(ChangeWord, _currentWord, StringComparison.OrdinalIgnoreCase) != 0) - { - return; // don't prepare next word if change was more than just casing - } - - if (ChangeWord != _currentWord) - { - _changeAllDictionary.Add(_currentWord, ChangeWord); - _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange, -1); - } - break; - case SpellCheckAction.AddToNamesOnly: - _spellCheckWordLists.AddName(ChangeWord); - SetWords(_currentParagraph.Text); - break; - case SpellCheckAction.ChangeWholeText: - _mainWindow.ShowStatus(string.Format(Configuration.Settings.Language.Main.SpellCheckChangedXToY, _currentParagraph.Text.Replace(Environment.NewLine, " "), ChangeWholeText.Replace(Environment.NewLine, " "))); - _currentParagraph.Text = ChangeWholeText; - _mainWindow.ChangeWholeTextMainPart(ref _noOfChangedWords, ref _firstChange, _currentIndex, _currentParagraph); - _currentIndex--; // re-spellcheck current line - _wordsIndex = int.MaxValue - 1; - break; - case SpellCheckAction.DeleteLine: - _mainWindow.DeleteLine(); - _currentIndex--; // re-spellcheck current line - _wordsIndex = int.MaxValue - 1; - break; - } - labelActionInfo.Text = string.Empty; - PrepareNextWord(); - CheckActions(); - } - - private void CheckActions() - { - if (string.IsNullOrEmpty(_currentAction)) - { - return; - } - - if (_currentAction == Configuration.Settings.Language.SpellCheck.Change) - { - ShowActionInfo(_currentAction, _currentWord + " > " + textBoxWord.Text); - } - else if (_currentAction == Configuration.Settings.Language.SpellCheck.ChangeAll) - { - ShowActionInfo(_currentAction, _currentWord + " > " + textBoxWord.Text); - } - else - { - ShowActionInfo(_currentAction, textBoxWord.Text); - } - } - - private void PrepareNextWord() - { - while (true) - { - if (_wordsIndex + 1 < _words.Count) - { - _wordsIndex++; - _currentWord = _words[_wordsIndex].Text; - _currentSpellCheckWord = _words[_wordsIndex]; - } - else - { - if (_wordsIndex != int.MaxValue - 1 && _skipOneList.Count > 0) - { - _skipOneList = new HashSet(); - } - - if (_currentIndex + 1 < _subtitle.Paragraphs.Count) - { - _currentIndex++; - _currentParagraph = _subtitle.Paragraphs[_currentIndex]; - SetWords(_currentParagraph.Text); - _wordsIndex = 0; - if (_words.Count == 0) - { - _currentWord = string.Empty; - } - else - { - _currentWord = _words[_wordsIndex].Text; - _currentSpellCheckWord = _words[_wordsIndex]; - } - } - else - { - ShowEndStatusMessage(Configuration.Settings.Language.SpellCheck.SpellCheckCompleted); - DialogResult = DialogResult.OK; - return; - } - } - - int minLength = 2; - if (Configuration.Settings.Tools.CheckOneLetterWords) - { - minLength = 1; - } - - if (_currentWord.RemoveControlCharacters().Trim().Length >= minLength) - { - _prefix = string.Empty; - _postfix = string.Empty; - if (_currentWord.Length > 0) - { - var trimChars = "'`*#\u200E\u200F\u202A\u202B\u202C\u202D\u202E\u200B\uFEFF"; - var charHit = true; - while (charHit) - { - charHit = false; - foreach (char c in trimChars) - { - if (_currentWord.StartsWith(c)) - { - _prefix += c; - _currentWord = _currentWord.Substring(1); - charHit = true; - } - if (_currentWord.EndsWith(c)) - { - _postfix = c + _postfix; - _currentWord = _currentWord.Remove(_currentWord.Length - 1); - charHit = true; - } - } - } - } - string key = _currentIndex + "-" + _wordsIndex + "-" + _currentWord; - if (_currentWord.Length < minLength || _currentWord == "&") - { - // ignore short/empty words and special chars - } - else if (_spellCheckWordLists.HasName(_currentWord)) - { - _noOfNames++; - } - else if (_skipAllList.Contains(_currentWord.ToUpperInvariant()) - || (_currentWord.StartsWith('\'') || _currentWord.EndsWith('\'')) && _skipAllList.Contains(_currentWord.Trim('\'').ToUpperInvariant())) - { - _noOfSkippedWords++; - } - else if (_skipOneList.Contains(key)) - { - // "skip one" again (after change whole text) - } - else if (IsNumber(_currentWord)) - { - _noOfSkippedWords++; - } - else if (_spellCheckWordLists.HasUserWord(_currentWord)) - { - _noOfCorrectWords++; - } - else if (_changeAllDictionary.ContainsKey(_currentWord)) - { - _noOfChangedWords++; - _mainWindow.CorrectWord(_changeAllDictionary[_currentWord], _currentParagraph, _currentWord, ref _firstChange, -1); - } - else if (_changeAllDictionary.ContainsKey(_currentWord.Trim('\''))) - { - _noOfChangedWords++; - _mainWindow.CorrectWord(_changeAllDictionary[_currentWord.Trim('\'')], _currentParagraph, _currentWord.Trim('\''), ref _firstChange, -1); - } - else if (_spellCheckWordLists.HasNameExtended(_currentWord, _currentParagraph.Text)) // TODO: Verify this! - { - _noOfNames++; - } - else if (_spellCheckWordLists.IsWordInUserPhrases(_wordsIndex, _words)) - { - _noOfCorrectWords++; - } - else - { - bool correct; - - if (_prefix == "'" && _currentWord.Length >= 1 && (DoSpell(_prefix + _currentWord) || _spellCheckWordLists.HasUserWord(_prefix + _currentWord))) - { - correct = true; - } - else if (_currentWord.Length > 1) - { - correct = DoSpell(_currentWord); - if (!correct && "`'".Contains(_currentWord[_currentWord.Length - 1])) - { - correct = DoSpell(_currentWord.TrimEnd('\'').TrimEnd('`')); - } - - if (!correct && _currentWord.EndsWith("'s", StringComparison.Ordinal) && _currentWord.Length > 4) - { - correct = DoSpell(_currentWord.TrimEnd('s').TrimEnd('\'')); - } - - if (!correct && _currentWord.EndsWith('\'') && DoSpell(_currentWord.TrimEnd('\''))) - { - _currentWord = _currentWord.TrimEnd('\''); - correct = true; - } - - if (!correct) - { - string removeUnicode = _currentWord.Replace("\u200b", string.Empty); // zero width space - removeUnicode = removeUnicode.Replace("\u2060", string.Empty); // word joiner - removeUnicode = removeUnicode.Replace("\ufeff", string.Empty); // zero width no-break space - correct = DoSpell(removeUnicode); - } - - if (!correct && _wordsIndex > 1 && _words.Count > _wordsIndex && - _words[_wordsIndex - 1].Text.ToLowerInvariant() == "www" && - (_words[_wordsIndex + 1].Text.ToLowerInvariant() == "com" || - _words[_wordsIndex + 1].Text.ToLowerInvariant() == "org" || - _words[_wordsIndex + 1].Text.ToLowerInvariant() == "net") && - _currentParagraph.Text.IndexOf(_words[_wordsIndex - 1].Text + "." + - _currentWord + "." + - _words[_wordsIndex + 1].Text, StringComparison.OrdinalIgnoreCase) >= 0) - { - correct = true; // do not spell check urls - } - - if (!correct && (_languageName.StartsWith("ar_", StringComparison.Ordinal) || _languageName == "ar")) - { - var trimmed = _currentWord.Trim('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', ',', '،'); - if (trimmed != _currentWord) - { - if (_spellCheckWordLists.HasName(trimmed)) - { - _noOfNames++; - correct = true; - } - - if (!correct && (_skipAllList.Contains(trimmed.ToUpperInvariant()) || _spellCheckWordLists.HasUserWord(trimmed) || DoSpell(trimmed))) - { - correct = true; - } - } - } - - // check if dash concatenated word with previous or next word is in spell check dictionary - if (!correct && _wordsIndex > 0 && (_currentParagraph.Text[_currentSpellCheckWord.Index - 1] == '-' || _currentParagraph.Text[_currentSpellCheckWord.Index - 1] == '‑')) - { - var wordWithDash = _words[_wordsIndex - 1].Text + "-" + _currentWord; - correct = DoSpell(wordWithDash); - if (!correct) - { - wordWithDash = _words[_wordsIndex - 1].Text + "‑" + _currentWord; // non break hyphen - correct = DoSpell(wordWithDash); - } - if (!correct) - { - correct = _spellCheckWordLists.HasUserWord(wordWithDash); - } - if (!correct) - { - correct = _spellCheckWordLists.HasUserWord(wordWithDash.Replace("‑", "-")); - } - - if (!correct && _spellCheckWordLists.HasUserWord("-" + _currentWord)) - { - correct = true; - } - } - if (!correct && _wordsIndex < _words.Count - 1 && _words[_wordsIndex + 1].Index - 1 < _currentParagraph.Text.Length && - (_currentParagraph.Text[_words[_wordsIndex + 1].Index - 1] == '-' || _currentParagraph.Text[_words[_wordsIndex + 1].Index - 1] == '‑')) - { - var wordWithDash = _currentWord + "-" + _words[_wordsIndex + 1].Text; - correct = DoSpell(wordWithDash); - if (!correct) - { - wordWithDash = _currentWord + "‑" + _words[_wordsIndex + 1].Text; // non break hyphen - correct = DoSpell(wordWithDash); - } - if (!correct) - { - correct = _spellCheckWordLists.HasUserWord(wordWithDash); - } - if (!correct) - { - correct = _spellCheckWordLists.HasUserWord(wordWithDash.Replace("‑", "-")); - } - } - } - else - { - correct = false; - if (_currentWord == "'") - { - correct = true; - } - else if (_languageName.StartsWith("en_", StringComparison.Ordinal) && (_currentWord.Equals("a", StringComparison.OrdinalIgnoreCase) || _currentWord == "I")) - { - correct = true; - } - else if (_languageName.StartsWith("da_", StringComparison.Ordinal) && _currentWord.Equals("i", StringComparison.OrdinalIgnoreCase)) - { - correct = true; - } - } - - if (!correct && Configuration.Settings.Tools.SpellCheckEnglishAllowInQuoteAsIng && - _languageName.StartsWith("en_", StringComparison.Ordinal) && _words[_wordsIndex].Text.EndsWith("in'", StringComparison.OrdinalIgnoreCase)) - { - correct = DoSpell(_currentWord.TrimEnd('\'') + "g"); - } - - if (correct) - { - _noOfCorrectWords++; - } - else - { - _mainWindow.FocusParagraph(_currentIndex); - - var suggestions = new List(); - - if ((_currentWord == "Lt's" || _currentWord == "Lt'S") && _languageName.StartsWith("en_", StringComparison.Ordinal)) - { - suggestions.Add("It's"); - } - else - { - if (_currentWord.ToUpperInvariant() != "LT'S" && _currentWord.ToUpperInvariant() != "SOX'S" && !_currentWord.ToUpperInvariant().StartsWith("HTTP", StringComparison.Ordinal)) // TODO: Get fixed nhunspell - { - suggestions = DoSuggest(_currentWord); // TODO: 0.9.6 fails on "Lt'S" - } - - if (_languageName.StartsWith("fr_", StringComparison.Ordinal) && (_currentWord.StartsWith("I'", StringComparison.Ordinal) || _currentWord.StartsWith("I’", StringComparison.Ordinal))) - { - if (_currentWord.Length > 3 && char.IsLower(_currentWord[2]) && _currentSpellCheckWord.Index > 3) - { - string ending = _currentParagraph.Text.Substring(0, _currentSpellCheckWord.Index - 1).Trim(); - if (ending.Length > 1 && !".!?".Contains(ending[ending.Length - 1])) - { - for (int i = 0; i < suggestions.Count; i++) - { - if (suggestions[i].StartsWith("L'", StringComparison.Ordinal) || suggestions[i].StartsWith("L’", StringComparison.Ordinal)) - { - suggestions[i] = @"l" + suggestions[i].Substring(1); - } - } - } - } - } - } - - suggestions.Remove(_currentWord); - if (_currentWord.Length == 1 && _currentWord == "L" && _languageName.StartsWith("en_", StringComparison.Ordinal)) - { - suggestions.Remove("I"); - suggestions.Insert(0, "I"); - } - - if (DoAutoFixNames(_currentWord, suggestions)) - { - return; - } - - if (_prefix != null && _prefix == "''" && _currentWord.EndsWith("''", StringComparison.Ordinal)) - { - _prefix = string.Empty; - _currentSpellCheckWord.Index += 2; - _currentWord = _currentWord.Trim('\''); - } - if (_prefix != null && _prefix == "'" && _currentWord.EndsWith('\'')) - { - _prefix = string.Empty; - _currentSpellCheckWord.Index++; - _currentWord = _currentWord.Trim('\''); - } - - if (_postfix != null && _postfix == "'") - { - _currentSpellCheckWord.Text = _currentWord + _postfix; - Initialize(_languageName, _currentSpellCheckWord, suggestions, _currentParagraph.Text, string.Format(Configuration.Settings.Language.Main.LineXOfY, (_currentIndex + 1), _subtitle.Paragraphs.Count)); - } - else - { - _currentSpellCheckWord.Text = _currentWord; - Initialize(_languageName, _currentSpellCheckWord, suggestions, _currentParagraph.Text, string.Format(Configuration.Settings.Language.Main.LineXOfY, (_currentIndex + 1), _subtitle.Paragraphs.Count)); - } - if (!Visible) - { - ShowDialog(_mainWindow); - } - - return; // wait for user input - } - } - } - } - } - - private bool DoAutoFixNames(string word, List suggestions) - { - if (AutoFixNames && word.Length > 3) - { - if (Configuration.Settings.Tools.SpellCheckAutoChangeNamesUseSuggestions) - { - if (suggestions.Contains(word.ToUpperInvariant())) - { // does not work well with two letter words like "da" and "de" which get auto-corrected to "DA" and "DE" - ChangeWord = word.ToUpperInvariant(); - DoAction(SpellCheckAction.ChangeAll); - return true; - } - - if (suggestions.Contains(char.ToUpperInvariant(word[0]) + word.Substring(1))) - { - ChangeWord = char.ToUpperInvariant(word[0]) + word.Substring(1); - DoAction(SpellCheckAction.ChangeAll); - return true; - } - } - - if (_spellCheckWordLists.HasName(char.ToUpper(word[0]) + word.Substring(1))) - { - ChangeWord = char.ToUpper(word[0]) + word.Substring(1); - DoAction(SpellCheckAction.ChangeAll); - return true; - } - - if (word.StartsWith("mc", StringComparison.InvariantCultureIgnoreCase) && _spellCheckWordLists.HasName(char.ToUpper(word[0]) + word.Substring(1, 1) + char.ToUpper(word[2]) + word.Remove(0, 3))) - { - ChangeWord = char.ToUpper(word[0]) + word.Substring(1, 1) + char.ToUpper(word[2]) + word.Remove(0, 3); - DoAction(SpellCheckAction.ChangeAll); - return true; - } - - if (_spellCheckWordLists.HasName(word.ToUpperInvariant())) - { - ChangeWord = word.ToUpperInvariant(); - DoAction(SpellCheckAction.ChangeAll); - return true; - } - } - return false; - } - - private static readonly Regex RegexIsNumber = new Regex("^\\d+$", RegexOptions.Compiled); - private static readonly Regex RegexIsEpisodeNumber = new Regex("^\\d+x\\d+$", RegexOptions.Compiled); // e.g. 12x02 - private static bool IsNumber(string s) - { - s = s.Trim('$', '£', '%', '*'); - if (RegexIsNumber.IsMatch(s)) - { - return true; - } - - if (RegexIsEpisodeNumber.IsMatch(s)) - { - return true; - } - - return false; - } - - private void SetWords(string s) - { - s = _spellCheckWordLists.ReplaceHtmlTagsWithBlanks(s); - s = _spellCheckWordLists.ReplaceAssTagsWithBlanks(s); - s = _spellCheckWordLists.ReplaceKnownWordsOrNamesWithBlanks(s); - _words = SpellCheckWordLists.Split(s); - } - - private void ShowEndStatusMessage(string completedMessage) - { - LanguageStructure.Main mainLanguage = Configuration.Settings.Language.Main; - if (_noOfChangedWords > 0 || _noOfAddedWords > 0 || _noOfSkippedWords > 0 || completedMessage == Configuration.Settings.Language.SpellCheck.SpellCheckCompleted) - { - Hide(); - if (Configuration.Settings.Tools.SpellCheckShowCompletedMessage) - { - var form = new DialogDoNotShowAgain(_mainWindow.Title + " - " + mainLanguage.SpellCheck, - completedMessage + Environment.NewLine + - Environment.NewLine + - string.Format(mainLanguage.NumberOfCorrectedWords, _noOfChangedWords) + Environment.NewLine + - string.Format(mainLanguage.NumberOfSkippedWords, _noOfSkippedWords) + Environment.NewLine + - string.Format(mainLanguage.NumberOfCorrectWords, _noOfCorrectWords) + Environment.NewLine + - string.Format(mainLanguage.NumberOfWordsAddedToDictionary, _noOfAddedWords) + Environment.NewLine + - string.Format(mainLanguage.NumberOfNameHits, _noOfNames)); - form.ShowDialog(_mainWindow); - Configuration.Settings.Tools.SpellCheckShowCompletedMessage = !form.DoNoDisplayAgain; - form.Dispose(); - } - else - { - if (_noOfChangedWords > 0) - { - _mainWindow.ShowStatus(completedMessage + " " + string.Format(mainLanguage.NumberOfCorrectedWords, _noOfChangedWords)); - } - else - { - _mainWindow.ShowStatus(completedMessage); - } - } - } - } - - public void ContinueSpellCheck(Subtitle subtitle) - { - _subtitle = subtitle; - - buttonUndo.Visible = false; - _undoList = new List(); - - if (_currentIndex >= subtitle.Paragraphs.Count) - { - _currentIndex = 0; - } - - _currentParagraph = _subtitle.GetParagraphOrDefault(_currentIndex); - if (_currentParagraph == null) - { - return; - } - - SetWords(_currentParagraph.Text); - _wordsIndex = -1; - - PrepareNextWord(); - } - - public void DoSpellCheck(bool autoDetect, Subtitle subtitle, string dictionaryFolder, Main mainWindow, int startLine) - { - _subtitle = subtitle; - LanguageStructure.Main mainLanguage = Configuration.Settings.Language.Main; - _mainWindow = mainWindow; - - _skipAllList = new List(); - - _noOfSkippedWords = 0; - _noOfChangedWords = 0; - _noOfCorrectWords = 0; - _noOfNames = 0; - _noOfAddedWords = 0; - _firstChange = true; - - if (!string.IsNullOrEmpty(Configuration.Settings.General.SpellCheckLanguage) && File.Exists(Path.Combine(dictionaryFolder, Configuration.Settings.General.SpellCheckLanguage + ".dic"))) - { - _languageName = Configuration.Settings.General.SpellCheckLanguage; - } - else - { - string name = Utilities.GetDictionaryLanguages()[0]; - int start = name.LastIndexOf('['); - int end = name.LastIndexOf(']'); - if (start > 0 && end > start) - { - start++; - name = name.Substring(start, end - start); - _languageName = name; - } - else - { - MessageBox.Show(string.Format(mainLanguage.InvalidLanguageNameX, name)); - return; - } - } - if (autoDetect || string.IsNullOrEmpty(_languageName)) - { - _languageName = LanguageAutoDetect.AutoDetectLanguageName(_languageName, subtitle); - if (_languageName != null && _languageName.Length > 3) - { - string start = _languageName.Substring(0, 2); - if (_languageName.StartsWith(start, StringComparison.Ordinal) && Configuration.Settings.General.SpellCheckLanguage != null && - Configuration.Settings.General.SpellCheckLanguage.StartsWith(start, StringComparison.Ordinal) && _languageName != Configuration.Settings.General.SpellCheckLanguage) - { - foreach (var dictionaryName in Utilities.GetDictionaryLanguages()) - { - if (dictionaryName.Contains(Configuration.Settings.General.SpellCheckLanguage)) - { - _languageName = Configuration.Settings.General.SpellCheckLanguage; - break; - } - } - } - } - } - string dictionary = Utilities.DictionaryFolder + _languageName; - - LoadDictionaries(dictionaryFolder, dictionary, _languageName); - - _currentIndex = 0; - if (startLine >= 0 && startLine < _subtitle.Paragraphs.Count) - { - _currentIndex = startLine; - } - - _currentParagraph = _subtitle.Paragraphs[_currentIndex]; - SetWords(_currentParagraph.Text); - _wordsIndex = -1; - - PrepareNextWord(); - } - - private void LoadDictionaries(string dictionaryFolder, string dictionary, string languageName) - { - _skipAllList = new List(); - _spellCheckWordLists = new SpellCheckWordLists(dictionaryFolder, languageName, this); - _changeAllDictionary = _spellCheckWordLists.GetUseAlwaysList(); - LoadHunspell(dictionary); - } - - private void textBoxWord_TextChanged(object sender, EventArgs e) - { - buttonChange.Enabled = textBoxWord.Text != _originalWord; - buttonChangeAll.Enabled = buttonChange.Enabled; - } - - private void buttonAddToDictionary_MouseEnter(object sender, EventArgs e) - { - ShowActionInfo(Configuration.Settings.Language.SpellCheck.AddToUserDictionary, textBoxWord.Text); - } - - private void ShowActionInfo(string label, string text) - { - labelActionInfo.Text = $"{label}: {text.Trim()}"; - _currentAction = label; - } - - private void buttonAddToDictionary_MouseLeave(object sender, EventArgs e) - { - labelActionInfo.Text = string.Empty; - _currentAction = null; - } - - private void buttonAddToNames_MouseEnter(object sender, EventArgs e) - { - ShowActionInfo(Configuration.Settings.Language.SpellCheck.AddToNamesAndIgnoreList, textBoxWord.Text); - } - - private void buttonAddToNames_MouseLeave(object sender, EventArgs e) - { - labelActionInfo.Text = string.Empty; - _currentAction = null; - } - - private void buttonSkipOnce_MouseEnter(object sender, EventArgs e) - { - ShowActionInfo(Configuration.Settings.Language.SpellCheck.SkipOnce, textBoxWord.Text); - } - - private void buttonSkipOnce_MouseLeave(object sender, EventArgs e) - { - labelActionInfo.Text = string.Empty; - _currentAction = null; - } - - private void buttonSkipAll_MouseEnter(object sender, EventArgs e) - { - ShowActionInfo(Configuration.Settings.Language.SpellCheck.SkipAll, textBoxWord.Text); - } - - private void buttonSkipAll_MouseLeave(object sender, EventArgs e) - { - labelActionInfo.Text = string.Empty; - _currentAction = null; - } - - private void buttonChange_MouseEnter(object sender, EventArgs e) - { - ShowActionInfo(Configuration.Settings.Language.SpellCheck.Change, _currentWord + " > " + textBoxWord.Text); - } - - private void buttonChange_MouseLeave(object sender, EventArgs e) - { - labelActionInfo.Text = string.Empty; - _currentAction = null; - } - - private void buttonChangeAll_MouseEnter(object sender, EventArgs e) - { - ShowActionInfo(Configuration.Settings.Language.SpellCheck.ChangeAll, _currentWord + " > " + textBoxWord.Text); - } - - private void buttonChangeAll_MouseLeave(object sender, EventArgs e) - { - labelActionInfo.Text = string.Empty; - _currentAction = null; - } - - private void buttonSpellCheckDownload_Click(object sender, EventArgs e) - { - using (var gd = new GetDictionaries()) - { - gd.ShowDialog(this); - - FillSpellCheckDictionaries(LanguageAutoDetect.AutoDetectLanguageName(null, _subtitle)); - if (gd.LastDownload != null && gd.LastDownload.Length > 3 && comboBoxDictionaries.Items.Count > 0) - { - var lc = Path.GetFileNameWithoutExtension(gd.LastDownload.Substring(0, 4).Replace('_', '-')); - for (int i = 0; i < comboBoxDictionaries.Items.Count; i++) - { - string item = (string)comboBoxDictionaries.Items[i]; - if (item.Contains("[" + lc) || item.Contains(gd.SelectedEnglishName)) - { - comboBoxDictionaries.SelectedIndex = i; - break; - } - } - } - if (comboBoxDictionaries.Items.Count > 0 && comboBoxDictionaries.SelectedIndex < 0) - { - comboBoxDictionaries.SelectedIndex = 0; - } - ComboBoxDictionariesSelectedIndexChanged(null, null); - } - } - - private void PushUndo(string text, SpellCheckAction action) - { - if (string.IsNullOrWhiteSpace(text)) - { - return; - } - - if (action == SpellCheckAction.ChangeAll && _changeAllDictionary.ContainsKey(_currentWord)) - { - return; - } - - string format = Configuration.Settings.Language.SpellCheck.UndoX; - if (string.IsNullOrEmpty(format)) - { - format = "Undo: {0}"; - } - - string undoText = string.Format(format, text); - - _undoList.Add(new UndoObject - { - CurrentIndex = _currentIndex, - UndoText = undoText, - UndoWord = textBoxWord.Text.Trim(), - Action = action, - CurrentWord = _currentWord, - Subtitle = new Subtitle(_subtitle), - NoOfSkippedWords = _noOfSkippedWords, - NoOfChangedWords = _noOfChangedWords, - NoOfCorrectWords = _noOfCorrectWords, - NoOfNames = _noOfNames, - NoOfAddedWords = _noOfAddedWords, - }); - buttonUndo.Text = undoText; - buttonUndo.Visible = true; - } - - private void buttonUndo_Click(object sender, EventArgs e) - { - if (_undoList.Count > 0) - { - var undo = _undoList[_undoList.Count - 1]; - _currentIndex = undo.CurrentIndex - 1; - _wordsIndex = int.MaxValue - 1; - _noOfSkippedWords = undo.NoOfSkippedWords; - _noOfChangedWords = undo.NoOfChangedWords; - _noOfCorrectWords = undo.NoOfCorrectWords; - _noOfNames = undo.NoOfNames; - _noOfAddedWords = undo.NoOfAddedWords; - - switch (undo.Action) - { - case SpellCheckAction.Change: - _subtitle = _mainWindow.UndoFromSpellCheck(undo.Subtitle); - break; - case SpellCheckAction.ChangeAll: - _subtitle = _mainWindow.UndoFromSpellCheck(undo.Subtitle); - _changeAllDictionary.Remove(undo.CurrentWord); - _spellCheckWordLists.UseAlwaysListRemove(undo.CurrentWord); - break; - case SpellCheckAction.Skip: - break; - case SpellCheckAction.SkipAll: - _skipAllList.Remove(undo.UndoWord.ToUpperInvariant()); - if (undo.UndoWord.EndsWith('\'') || undo.UndoWord.StartsWith('\'')) - { - _skipAllList.Remove(undo.UndoWord.ToUpperInvariant().Trim('\'')); - } - - break; - case SpellCheckAction.AddToDictionary: - _spellCheckWordLists.RemoveUserWord(undo.UndoWord); - break; - case SpellCheckAction.AddToNames: - _spellCheckWordLists.RemoveName(undo.UndoWord); - break; - case SpellCheckAction.ChangeWholeText: - _subtitle = _mainWindow.UndoFromSpellCheck(undo.Subtitle); - break; - } - - _undoList.RemoveAt(_undoList.Count - 1); - if (_undoList.Count > 0) - { - buttonUndo.Text = _undoList[_undoList.Count - 1].UndoText; - } - else - { - buttonUndo.Visible = false; - } - } - PrepareNextWord(); - } - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - if (_hunspell != null) - { - _hunspell.Dispose(); - _hunspell = null; - } - components.Dispose(); - } - base.Dispose(disposing); - } - - private void buttonGoogleIt_Click(object sender, EventArgs e) - { - string text = textBoxWord.Text.Trim(); - if (!string.IsNullOrWhiteSpace(text)) - { - UiUtil.OpenURL("https://www.google.com/search?q=" + Utilities.UrlEncode(text)); - } - } - - private void deleteToolStripMenuItem_Click(object sender, EventArgs e) - { - if (!Configuration.Settings.General.PromptDeleteLines || MessageBox.Show(Configuration.Settings.Language.Main.DeleteOneLinePrompt, Configuration.Settings.Language.SpellCheck.Title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) - { - DoAction(SpellCheckAction.DeleteLine); - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Enums; +using Nikse.SubtitleEdit.Core.Interfaces; +using Nikse.SubtitleEdit.Core.SpellCheck; +using Nikse.SubtitleEdit.Logic; +using Nikse.SubtitleEdit.Logic.SpellCheck; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class SpellCheck : Form, IDoSpell + { + private List _undoList = new List(); + private List _suggestions; + private string _currentAction; + public SpellCheckAction Action { get; set; } = SpellCheckAction.Skip; + public string ChangeWord + { + get => textBoxWord.Text; + set => textBoxWord.Text = value; + } + public string ChangeWholeText => textBoxWholeText.Text; + public bool AutoFixNames => checkBoxAutoChangeNames.Checked; + + private SpellCheckWordLists _spellCheckWordLists; + private List _skipAllList = new List(); + private HashSet _skipOneList = new HashSet(); + private Dictionary _changeAllDictionary; + private string _prefix = string.Empty; + private string _postfix = string.Empty; + private Hunspell _hunspell; + private Paragraph _currentParagraph; + private int _currentIndex; + private string _currentWord; + private SpellCheckWord _currentSpellCheckWord; + private List _words; + private int _wordsIndex; + private Subtitle _subtitle; + private string _originalWord; + private int _noOfSkippedWords; + private int _noOfChangedWords; + private int _noOfCorrectWords; + private int _noOfNames; + private int _noOfAddedWords; + private bool _firstChange = true; + private string _languageName; + private Main _mainWindow; + private string _currentDictionary; + + public class SuggestionParameter + { + public string InputWord { get; set; } + public List Suggestions { get; set; } + public Hunspell Hunspell { get; set; } + public bool Success { get; set; } + + public SuggestionParameter(string word, Hunspell hunspell) + { + InputWord = word; + Suggestions = new List(); + Hunspell = hunspell; + Success = false; + } + } + + public string LanguageString + { + get + { + string name = comboBoxDictionaries.SelectedItem.ToString(); + int start = name.LastIndexOf('['); + int end = name.LastIndexOf(']'); + if (start >= 0 && end > start) + { + start++; + name = name.Substring(start, end - start); + return name; + } + return null; + } + } + + public SpellCheck() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + labelActionInfo.Text = string.Empty; + Text = Configuration.Settings.Language.SpellCheck.Title; + labelFullText.Text = Configuration.Settings.Language.SpellCheck.FullText; + labelLanguage.Text = Configuration.Settings.Language.SpellCheck.Language; + groupBoxWordNotFound.Text = Configuration.Settings.Language.SpellCheck.WordNotFound; + buttonAddToDictionary.Text = Configuration.Settings.Language.SpellCheck.AddToUserDictionary; + buttonChange.Text = Configuration.Settings.Language.SpellCheck.Change; + buttonChangeAll.Text = Configuration.Settings.Language.SpellCheck.ChangeAll; + buttonSkipAll.Text = Configuration.Settings.Language.SpellCheck.SkipAll; + buttonSkipOnce.Text = Configuration.Settings.Language.SpellCheck.SkipOnce; + buttonUseSuggestion.Text = Configuration.Settings.Language.SpellCheck.Use; + buttonUseSuggestionAlways.Text = Configuration.Settings.Language.SpellCheck.UseAlways; + buttonAbort.Text = Configuration.Settings.Language.SpellCheck.Abort; + buttonEditWholeText.Text = Configuration.Settings.Language.SpellCheck.EditWholeText; + checkBoxAutoChangeNames.Text = Configuration.Settings.Language.SpellCheck.AutoFixNames; + checkBoxAutoChangeNames.Checked = Configuration.Settings.Tools.SpellCheckAutoChangeNames; + groupBoxEditWholeText.Text = Configuration.Settings.Language.SpellCheck.EditWholeText; + buttonChangeWholeText.Text = Configuration.Settings.Language.SpellCheck.Change; + buttonSkipText.Text = Configuration.Settings.Language.SpellCheck.SkipOnce; + groupBoxSuggestions.Text = Configuration.Settings.Language.SpellCheck.Suggestions; + buttonAddToNames.Text = Configuration.Settings.Language.SpellCheck.AddToNamesAndIgnoreList; + buttonGoogleIt.Text = Configuration.Settings.Language.Main.VideoControls.GoogleIt; + deleteToolStripMenuItem.Text = Configuration.Settings.Language.General.DeleteCurrentLine; + UiUtil.FixLargeFonts(this, buttonAbort); + } + + public void Initialize(string languageName, SpellCheckWord word, List suggestions, string paragraph, string progress) + { + _originalWord = word.Text; + _suggestions = suggestions; + groupBoxWordNotFound.Visible = true; + groupBoxEditWholeText.Visible = false; + buttonEditWholeText.Text = Configuration.Settings.Language.SpellCheck.EditWholeText; + Text = Configuration.Settings.Language.SpellCheck.Title + " [" + languageName + "] - " + progress; + textBoxWord.Text = word.Text; + textBoxWholeText.Text = paragraph; + listBoxSuggestions.Items.Clear(); + foreach (string suggestion in suggestions) + { + listBoxSuggestions.Items.Add(suggestion); + } + if (listBoxSuggestions.Items.Count > 0) + { + listBoxSuggestions.SelectedIndex = 0; + } + + richTextBoxParagraph.Text = paragraph; + + FillSpellCheckDictionaries(languageName); + ShowActiveWordWithColor(word); + Action = SpellCheckAction.Skip; + DialogResult = DialogResult.None; + } + + private void FillSpellCheckDictionaries(string languageName) + { + comboBoxDictionaries.SelectedIndexChanged -= ComboBoxDictionariesSelectedIndexChanged; + comboBoxDictionaries.Items.Clear(); + foreach (string name in Utilities.GetDictionaryLanguages()) + { + comboBoxDictionaries.Items.Add(name); + if (name.Contains("[" + languageName + "]")) + { + comboBoxDictionaries.SelectedIndex = comboBoxDictionaries.Items.Count - 1; + } + } + comboBoxDictionaries.AutoCompleteSource = AutoCompleteSource.ListItems; + comboBoxDictionaries.AutoCompleteMode = AutoCompleteMode.Append; + comboBoxDictionaries.SelectedIndexChanged += ComboBoxDictionariesSelectedIndexChanged; + } + + private void ShowActiveWordWithColor(SpellCheckWord word) + { + richTextBoxParagraph.SelectAll(); + richTextBoxParagraph.SelectionColor = Color.Black; + richTextBoxParagraph.SelectionLength = 0; + + for (int i = 0; i < 10; i++) + { + int idx = word.Index - i; + if (idx >= 0 && idx < richTextBoxParagraph.Text.Length && richTextBoxParagraph.Text.Substring(idx).StartsWith(word.Text, StringComparison.Ordinal)) + { + richTextBoxParagraph.SelectionStart = idx; + richTextBoxParagraph.SelectionLength = word.Text.Length; + richTextBoxParagraph.SelectionColor = Color.Red; + break; + } + idx = word.Index + i; + if (idx >= 0 && idx < richTextBoxParagraph.Text.Length && richTextBoxParagraph.Text.Substring(idx).StartsWith(word.Text, StringComparison.Ordinal)) + { + richTextBoxParagraph.SelectionStart = idx; + richTextBoxParagraph.SelectionLength = word.Text.Length; + richTextBoxParagraph.SelectionColor = Color.Red; + break; + } + } + } + + private void FormSpellCheck_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + Action = SpellCheckAction.Abort; + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#spellcheck"); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.G) + { + e.SuppressKeyPress = true; + UiUtil.OpenURL("https://www.google.com/search?q=" + Utilities.UrlEncode(textBoxWord.Text)); + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Z) + { + if (buttonUndo.Visible) + { + buttonUndo_Click(null, null); + e.SuppressKeyPress = true; + } + } + } + + private void ButtonAbortClick(object sender, EventArgs e) + { + ShowEndStatusMessage(Configuration.Settings.Language.SpellCheck.SpellCheckAborted); + DialogResult = DialogResult.Abort; + } + + private void ButtonChangeClick(object sender, EventArgs e) + { + PushUndo($"{Configuration.Settings.Language.SpellCheck.Change}: {_currentWord + " > " + textBoxWord.Text}", SpellCheckAction.Change); + DoAction(SpellCheckAction.Change); + } + + private void ButtonUseSuggestionClick(object sender, EventArgs e) + { + if (listBoxSuggestions.SelectedIndex >= 0) + { + textBoxWord.Text = listBoxSuggestions.SelectedItem.ToString(); + PushUndo($"{Configuration.Settings.Language.SpellCheck.Change}: {_currentWord + " > " + textBoxWord.Text}", SpellCheckAction.Change); + DoAction(SpellCheckAction.Change); + } + } + + private void ButtonSkipAllClick(object sender, EventArgs e) + { + PushUndo($"{Configuration.Settings.Language.SpellCheck.SkipAll}: {textBoxWord.Text}", SpellCheckAction.SkipAll); + DoAction(SpellCheckAction.SkipAll); + } + + private void ButtonSkipOnceClick(object sender, EventArgs e) + { + PushUndo($"{Configuration.Settings.Language.SpellCheck.SkipOnce}: {textBoxWord.Text}", SpellCheckAction.Skip); + DoAction(SpellCheckAction.Skip); + } + + private void ButtonAddToDictionaryClick(object sender, EventArgs e) + { + PushUndo($"{Configuration.Settings.Language.SpellCheck.AddToUserDictionary}: {textBoxWord.Text}", SpellCheckAction.AddToDictionary); + DoAction(SpellCheckAction.AddToDictionary); + } + + private void ComboBoxDictionariesSelectedIndexChanged(object sender, EventArgs e) + { + Configuration.Settings.General.SpellCheckLanguage = LanguageString; + Configuration.Settings.Save(); + _languageName = LanguageString; + string dictionary = Utilities.DictionaryFolder + _languageName; + LoadDictionaries(Utilities.DictionaryFolder, dictionary, _languageName); + _wordsIndex--; + PrepareNextWord(); + } + + private void LoadHunspell(string dictionary) + { + _currentDictionary = dictionary; + _hunspell?.Dispose(); + _hunspell = Hunspell.GetHunspell(dictionary); + } + + public bool DoSpell(string word) + { + return _hunspell.Spell(word); + } + + public List DoSuggest(string word) + { + var parameter = new SuggestionParameter(word, _hunspell); + var suggestThread = new System.Threading.Thread(DoWork); + suggestThread.Start(parameter); + suggestThread.Join(3000); // wait max 3 seconds + suggestThread.Abort(); + if (!parameter.Success) + { + LoadHunspell(_currentDictionary); + } + + return parameter.Suggestions; + } + + public static void DoWork(object data) + { + var parameter = (SuggestionParameter)data; + parameter.Suggestions = parameter.Hunspell.Suggest(parameter.InputWord); + parameter.Success = true; + } + + private void ButtonChangeAllClick(object sender, EventArgs e) + { + PushUndo($"{Configuration.Settings.Language.SpellCheck.ChangeAll}: {_currentWord + " > " + textBoxWord.Text}", SpellCheckAction.ChangeAll); + DoAction(SpellCheckAction.ChangeAll); + } + + private void ButtonUseSuggestionAlwaysClick(object sender, EventArgs e) + { + if (listBoxSuggestions.SelectedIndex >= 0) + { + textBoxWord.Text = listBoxSuggestions.SelectedItem.ToString(); + PushUndo($"{Configuration.Settings.Language.SpellCheck.ChangeAll}: {_currentWord + " > " + textBoxWord.Text}", SpellCheckAction.ChangeAll); + DoAction(SpellCheckAction.ChangeAll); + } + } + + private void SpellCheck_FormClosing(object sender, FormClosingEventArgs e) + { + Configuration.Settings.Tools.SpellCheckAutoChangeNames = AutoFixNames; + if (e.CloseReason == CloseReason.UserClosing) + { + DialogResult = DialogResult.Abort; + } + } + + private void ButtonAddToNamesClick(object sender, EventArgs e) + { + PushUndo($"{Configuration.Settings.Language.SpellCheck.AddToNamesAndIgnoreList}: {textBoxWord.Text}", SpellCheckAction.AddToNames); + DoAction(SpellCheckAction.AddToNames); + } + + private void ButtonEditWholeTextClick(object sender, EventArgs e) + { + if (groupBoxWordNotFound.Visible) + { + groupBoxWordNotFound.Visible = false; + groupBoxEditWholeText.Visible = true; + buttonEditWholeText.Text = Configuration.Settings.Language.SpellCheck.EditWordOnly; + textBoxWholeText.Focus(); + } + else + { + groupBoxWordNotFound.Visible = true; + groupBoxEditWholeText.Visible = false; + buttonEditWholeText.Text = Configuration.Settings.Language.SpellCheck.EditWholeText; + textBoxWord.Focus(); + } + } + + private void ButtonSkipTextClick(object sender, EventArgs e) + { + PushUndo($"{Configuration.Settings.Language.SpellCheck.SkipOnce}", SpellCheckAction.Skip); + DoAction(SpellCheckAction.SkipWholeLine); + } + + private void ButtonChangeWholeTextClick(object sender, EventArgs e) + { + PushUndo($"{Configuration.Settings.Language.SpellCheck.EditWholeText}", SpellCheckAction.ChangeWholeText); + DoAction(SpellCheckAction.ChangeWholeText); + } + + private void ContextMenuStrip1Opening(object sender, System.ComponentModel.CancelEventArgs e) + { + bool showAddItems = false; + if (!string.IsNullOrWhiteSpace(richTextBoxParagraph.SelectedText)) + { + string word = richTextBoxParagraph.SelectedText.Trim(); + addXToNamesnoiseListToolStripMenuItem.Text = string.Format(Configuration.Settings.Language.SpellCheck.AddXToNames, word); + addXToUserDictionaryToolStripMenuItem.Text = string.Format(Configuration.Settings.Language.SpellCheck.AddXToUserDictionary, word); + showAddItems = true; + } + addXToNamesnoiseListToolStripMenuItem.Visible = showAddItems; + addXToUserDictionaryToolStripMenuItem.Visible = showAddItems; + toolStripSeparator1.Visible = showAddItems; + } + + private void AddXToNamesnoiseListToolStripMenuItemClick(object sender, EventArgs e) + { + if (!string.IsNullOrWhiteSpace(richTextBoxParagraph.SelectedText)) + { + ChangeWord = richTextBoxParagraph.SelectedText.Trim(); + DoAction(SpellCheckAction.AddToNamesOnly); + } + } + + private void AddXToUserDictionaryToolStripMenuItem_Click(object sender, EventArgs e) + { + if (!string.IsNullOrWhiteSpace(richTextBoxParagraph.SelectedText)) + { + ChangeWord = richTextBoxParagraph.SelectedText.Trim(); + DoAction(SpellCheckAction.AddToDictionary); + } + } + + private void CheckBoxAutoChangeNamesCheckedChanged(object sender, EventArgs e) + { + if (textBoxWord.Text.Length < 2) + { + return; + } + + DoAutoFixNames(textBoxWord.Text, _suggestions); + } + + private void ListBoxSuggestionsMouseDoubleClick(object sender, MouseEventArgs e) + { + ButtonUseSuggestionAlwaysClick(null, null); + } + + public void DoAction(SpellCheckAction action) + { + switch (action) + { + case SpellCheckAction.Change: + _noOfChangedWords++; + _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange, _wordsIndex); + break; + case SpellCheckAction.ChangeAll: + _noOfChangedWords++; + if (!_changeAllDictionary.ContainsKey(_currentWord)) + { + _changeAllDictionary.Add(_currentWord, ChangeWord); + _spellCheckWordLists.UseAlwaysListAdd(_currentWord, ChangeWord); + } + _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange, -1); + break; + case SpellCheckAction.Skip: + _noOfSkippedWords++; + string key = _currentIndex + "-" + _wordsIndex + "-" + _currentWord; + if (!_skipOneList.Contains(key)) + { + _skipOneList.Add(key); + } + + break; + case SpellCheckAction.SkipWholeLine: + _wordsIndex = int.MaxValue - 1; // Go to next line + break; + case SpellCheckAction.SkipAll: + _noOfSkippedWords++; + _skipAllList.Add(ChangeWord.ToUpperInvariant()); + if (ChangeWord.EndsWith('\'') || ChangeWord.StartsWith('\'')) + { + _skipAllList.Add(ChangeWord.ToUpperInvariant().Trim('\'')); + } + + break; + case SpellCheckAction.AddToDictionary: + if (_spellCheckWordLists.AddUserWord(ChangeWord)) + { + _noOfAddedWords++; + } + + break; + case SpellCheckAction.AddToNames: + _spellCheckWordLists.AddName(ChangeWord); + if (string.Compare(ChangeWord, _currentWord, StringComparison.OrdinalIgnoreCase) != 0) + { + return; // don't prepare next word if change was more than just casing + } + + if (ChangeWord != _currentWord) + { + _changeAllDictionary.Add(_currentWord, ChangeWord); + _mainWindow.CorrectWord(_prefix + ChangeWord + _postfix, _currentParagraph, _prefix + _currentWord + _postfix, ref _firstChange, -1); + } + break; + case SpellCheckAction.AddToNamesOnly: + _spellCheckWordLists.AddName(ChangeWord); + SetWords(_currentParagraph.Text); + break; + case SpellCheckAction.ChangeWholeText: + _mainWindow.ShowStatus(string.Format(Configuration.Settings.Language.Main.SpellCheckChangedXToY, _currentParagraph.Text.Replace(Environment.NewLine, " "), ChangeWholeText.Replace(Environment.NewLine, " "))); + _currentParagraph.Text = ChangeWholeText; + _mainWindow.ChangeWholeTextMainPart(ref _noOfChangedWords, ref _firstChange, _currentIndex, _currentParagraph); + _currentIndex--; // re-spellcheck current line + _wordsIndex = int.MaxValue - 1; + break; + case SpellCheckAction.DeleteLine: + _mainWindow.DeleteLine(); + _currentIndex--; // re-spellcheck current line + _wordsIndex = int.MaxValue - 1; + break; + } + labelActionInfo.Text = string.Empty; + PrepareNextWord(); + CheckActions(); + } + + private void CheckActions() + { + if (string.IsNullOrEmpty(_currentAction)) + { + return; + } + + if (_currentAction == Configuration.Settings.Language.SpellCheck.Change) + { + ShowActionInfo(_currentAction, _currentWord + " > " + textBoxWord.Text); + } + else if (_currentAction == Configuration.Settings.Language.SpellCheck.ChangeAll) + { + ShowActionInfo(_currentAction, _currentWord + " > " + textBoxWord.Text); + } + else + { + ShowActionInfo(_currentAction, textBoxWord.Text); + } + } + + private void PrepareNextWord() + { + while (true) + { + if (_wordsIndex + 1 < _words.Count) + { + _wordsIndex++; + _currentWord = _words[_wordsIndex].Text; + _currentSpellCheckWord = _words[_wordsIndex]; + } + else + { + if (_wordsIndex != int.MaxValue - 1 && _skipOneList.Count > 0) + { + _skipOneList = new HashSet(); + } + + if (_currentIndex + 1 < _subtitle.Paragraphs.Count) + { + _currentIndex++; + _currentParagraph = _subtitle.Paragraphs[_currentIndex]; + SetWords(_currentParagraph.Text); + _wordsIndex = 0; + if (_words.Count == 0) + { + _currentWord = string.Empty; + } + else + { + _currentWord = _words[_wordsIndex].Text; + _currentSpellCheckWord = _words[_wordsIndex]; + } + } + else + { + ShowEndStatusMessage(Configuration.Settings.Language.SpellCheck.SpellCheckCompleted); + DialogResult = DialogResult.OK; + return; + } + } + + int minLength = 2; + if (Configuration.Settings.Tools.CheckOneLetterWords) + { + minLength = 1; + } + + if (_currentWord.RemoveControlCharacters().Trim().Length >= minLength) + { + _prefix = string.Empty; + _postfix = string.Empty; + if (_currentWord.Length > 0) + { + var trimChars = "'`*#\u200E\u200F\u202A\u202B\u202C\u202D\u202E\u200B\uFEFF"; + var charHit = true; + while (charHit) + { + charHit = false; + foreach (char c in trimChars) + { + if (_currentWord.StartsWith(c)) + { + _prefix += c; + _currentWord = _currentWord.Substring(1); + charHit = true; + } + if (_currentWord.EndsWith(c)) + { + _postfix = c + _postfix; + _currentWord = _currentWord.Remove(_currentWord.Length - 1); + charHit = true; + } + } + } + } + string key = _currentIndex + "-" + _wordsIndex + "-" + _currentWord; + if (_currentWord.Length < minLength || _currentWord == "&") + { + // ignore short/empty words and special chars + } + else if (_spellCheckWordLists.HasName(_currentWord)) + { + _noOfNames++; + } + else if (_skipAllList.Contains(_currentWord.ToUpperInvariant()) + || (_currentWord.StartsWith('\'') || _currentWord.EndsWith('\'')) && _skipAllList.Contains(_currentWord.Trim('\'').ToUpperInvariant())) + { + _noOfSkippedWords++; + } + else if (_skipOneList.Contains(key)) + { + // "skip one" again (after change whole text) + } + else if (IsNumber(_currentWord)) + { + _noOfSkippedWords++; + } + else if (_spellCheckWordLists.HasUserWord(_currentWord)) + { + _noOfCorrectWords++; + } + else if (_changeAllDictionary.ContainsKey(_currentWord)) + { + _noOfChangedWords++; + _mainWindow.CorrectWord(_changeAllDictionary[_currentWord], _currentParagraph, _currentWord, ref _firstChange, -1); + } + else if (_changeAllDictionary.ContainsKey(_currentWord.Trim('\''))) + { + _noOfChangedWords++; + _mainWindow.CorrectWord(_changeAllDictionary[_currentWord.Trim('\'')], _currentParagraph, _currentWord.Trim('\''), ref _firstChange, -1); + } + else if (_spellCheckWordLists.HasNameExtended(_currentWord, _currentParagraph.Text)) // TODO: Verify this! + { + _noOfNames++; + } + else if (_spellCheckWordLists.IsWordInUserPhrases(_wordsIndex, _words)) + { + _noOfCorrectWords++; + } + else + { + bool correct; + + if (_prefix == "'" && _currentWord.Length >= 1 && (DoSpell(_prefix + _currentWord) || _spellCheckWordLists.HasUserWord(_prefix + _currentWord))) + { + correct = true; + } + else if (_currentWord.Length > 1) + { + correct = DoSpell(_currentWord); + if (!correct && "`'".Contains(_currentWord[_currentWord.Length - 1])) + { + correct = DoSpell(_currentWord.TrimEnd('\'').TrimEnd('`')); + } + + if (!correct && _currentWord.EndsWith("'s", StringComparison.Ordinal) && _currentWord.Length > 4) + { + correct = DoSpell(_currentWord.TrimEnd('s').TrimEnd('\'')); + } + + if (!correct && _currentWord.EndsWith('\'') && DoSpell(_currentWord.TrimEnd('\''))) + { + _currentWord = _currentWord.TrimEnd('\''); + correct = true; + } + + if (!correct) + { + string removeUnicode = _currentWord.Replace("\u200b", string.Empty); // zero width space + removeUnicode = removeUnicode.Replace("\u2060", string.Empty); // word joiner + removeUnicode = removeUnicode.Replace("\ufeff", string.Empty); // zero width no-break space + correct = DoSpell(removeUnicode); + } + + if (!correct && _wordsIndex > 1 && _words.Count > _wordsIndex && + _words[_wordsIndex - 1].Text.ToLowerInvariant() == "www" && + (_words[_wordsIndex + 1].Text.ToLowerInvariant() == "com" || + _words[_wordsIndex + 1].Text.ToLowerInvariant() == "org" || + _words[_wordsIndex + 1].Text.ToLowerInvariant() == "net") && + _currentParagraph.Text.IndexOf(_words[_wordsIndex - 1].Text + "." + + _currentWord + "." + + _words[_wordsIndex + 1].Text, StringComparison.OrdinalIgnoreCase) >= 0) + { + correct = true; // do not spell check urls + } + + if (!correct && (_languageName.StartsWith("ar_", StringComparison.Ordinal) || _languageName == "ar")) + { + var trimmed = _currentWord.Trim('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', ',', '،'); + if (trimmed != _currentWord) + { + if (_spellCheckWordLists.HasName(trimmed)) + { + _noOfNames++; + correct = true; + } + + if (!correct && (_skipAllList.Contains(trimmed.ToUpperInvariant()) || _spellCheckWordLists.HasUserWord(trimmed) || DoSpell(trimmed))) + { + correct = true; + } + } + } + + // check if dash concatenated word with previous or next word is in spell check dictionary + if (!correct && _wordsIndex > 0 && (_currentParagraph.Text[_currentSpellCheckWord.Index - 1] == '-' || _currentParagraph.Text[_currentSpellCheckWord.Index - 1] == '‑')) + { + var wordWithDash = _words[_wordsIndex - 1].Text + "-" + _currentWord; + correct = DoSpell(wordWithDash); + if (!correct) + { + wordWithDash = _words[_wordsIndex - 1].Text + "‑" + _currentWord; // non break hyphen + correct = DoSpell(wordWithDash); + } + if (!correct) + { + correct = _spellCheckWordLists.HasUserWord(wordWithDash); + } + if (!correct) + { + correct = _spellCheckWordLists.HasUserWord(wordWithDash.Replace("‑", "-")); + } + + if (!correct && _spellCheckWordLists.HasUserWord("-" + _currentWord)) + { + correct = true; + } + } + if (!correct && _wordsIndex < _words.Count - 1 && _words[_wordsIndex + 1].Index - 1 < _currentParagraph.Text.Length && + (_currentParagraph.Text[_words[_wordsIndex + 1].Index - 1] == '-' || _currentParagraph.Text[_words[_wordsIndex + 1].Index - 1] == '‑')) + { + var wordWithDash = _currentWord + "-" + _words[_wordsIndex + 1].Text; + correct = DoSpell(wordWithDash); + if (!correct) + { + wordWithDash = _currentWord + "‑" + _words[_wordsIndex + 1].Text; // non break hyphen + correct = DoSpell(wordWithDash); + } + if (!correct) + { + correct = _spellCheckWordLists.HasUserWord(wordWithDash); + } + if (!correct) + { + correct = _spellCheckWordLists.HasUserWord(wordWithDash.Replace("‑", "-")); + } + } + } + else + { + correct = false; + if (_currentWord == "'") + { + correct = true; + } + else if (_languageName.StartsWith("en_", StringComparison.Ordinal) && (_currentWord.Equals("a", StringComparison.OrdinalIgnoreCase) || _currentWord == "I")) + { + correct = true; + } + else if (_languageName.StartsWith("da_", StringComparison.Ordinal) && _currentWord.Equals("i", StringComparison.OrdinalIgnoreCase)) + { + correct = true; + } + } + + if (!correct && Configuration.Settings.Tools.SpellCheckEnglishAllowInQuoteAsIng && + _languageName.StartsWith("en_", StringComparison.Ordinal) && _words[_wordsIndex].Text.EndsWith("in'", StringComparison.OrdinalIgnoreCase)) + { + correct = DoSpell(_currentWord.TrimEnd('\'') + "g"); + } + + if (correct) + { + _noOfCorrectWords++; + } + else + { + _mainWindow.FocusParagraph(_currentIndex); + + var suggestions = new List(); + + if ((_currentWord == "Lt's" || _currentWord == "Lt'S") && _languageName.StartsWith("en_", StringComparison.Ordinal)) + { + suggestions.Add("It's"); + } + else + { + if (_currentWord.ToUpperInvariant() != "LT'S" && _currentWord.ToUpperInvariant() != "SOX'S" && !_currentWord.ToUpperInvariant().StartsWith("HTTP", StringComparison.Ordinal)) // TODO: Get fixed nhunspell + { + suggestions = DoSuggest(_currentWord); // TODO: 0.9.6 fails on "Lt'S" + } + + if (_languageName.StartsWith("fr_", StringComparison.Ordinal) && (_currentWord.StartsWith("I'", StringComparison.Ordinal) || _currentWord.StartsWith("I’", StringComparison.Ordinal))) + { + if (_currentWord.Length > 3 && char.IsLower(_currentWord[2]) && _currentSpellCheckWord.Index > 3) + { + string ending = _currentParagraph.Text.Substring(0, _currentSpellCheckWord.Index - 1).Trim(); + if (ending.Length > 1 && !".!?".Contains(ending[ending.Length - 1])) + { + for (int i = 0; i < suggestions.Count; i++) + { + if (suggestions[i].StartsWith("L'", StringComparison.Ordinal) || suggestions[i].StartsWith("L’", StringComparison.Ordinal)) + { + suggestions[i] = @"l" + suggestions[i].Substring(1); + } + } + } + } + } + } + + suggestions.Remove(_currentWord); + if (_currentWord.Length == 1 && _currentWord == "L" && _languageName.StartsWith("en_", StringComparison.Ordinal)) + { + suggestions.Remove("I"); + suggestions.Insert(0, "I"); + } + + if (DoAutoFixNames(_currentWord, suggestions)) + { + return; + } + + if (_prefix != null && _prefix == "''" && _currentWord.EndsWith("''", StringComparison.Ordinal)) + { + _prefix = string.Empty; + _currentSpellCheckWord.Index += 2; + _currentWord = _currentWord.Trim('\''); + } + if (_prefix != null && _prefix == "'" && _currentWord.EndsWith('\'')) + { + _prefix = string.Empty; + _currentSpellCheckWord.Index++; + _currentWord = _currentWord.Trim('\''); + } + + if (_postfix != null && _postfix == "'") + { + _currentSpellCheckWord.Text = _currentWord + _postfix; + Initialize(_languageName, _currentSpellCheckWord, suggestions, _currentParagraph.Text, string.Format(Configuration.Settings.Language.Main.LineXOfY, (_currentIndex + 1), _subtitle.Paragraphs.Count)); + } + else + { + _currentSpellCheckWord.Text = _currentWord; + Initialize(_languageName, _currentSpellCheckWord, suggestions, _currentParagraph.Text, string.Format(Configuration.Settings.Language.Main.LineXOfY, (_currentIndex + 1), _subtitle.Paragraphs.Count)); + } + if (!Visible) + { + ShowDialog(_mainWindow); + } + + return; // wait for user input + } + } + } + } + } + + private bool DoAutoFixNames(string word, List suggestions) + { + if (AutoFixNames && word.Length > 3) + { + if (Configuration.Settings.Tools.SpellCheckAutoChangeNamesUseSuggestions) + { + if (suggestions.Contains(word.ToUpperInvariant())) + { // does not work well with two letter words like "da" and "de" which get auto-corrected to "DA" and "DE" + ChangeWord = word.ToUpperInvariant(); + DoAction(SpellCheckAction.ChangeAll); + return true; + } + + if (suggestions.Contains(char.ToUpperInvariant(word[0]) + word.Substring(1))) + { + ChangeWord = char.ToUpperInvariant(word[0]) + word.Substring(1); + DoAction(SpellCheckAction.ChangeAll); + return true; + } + } + + if (_spellCheckWordLists.HasName(char.ToUpper(word[0]) + word.Substring(1))) + { + ChangeWord = char.ToUpper(word[0]) + word.Substring(1); + DoAction(SpellCheckAction.ChangeAll); + return true; + } + + if (word.StartsWith("mc", StringComparison.InvariantCultureIgnoreCase) && _spellCheckWordLists.HasName(char.ToUpper(word[0]) + word.Substring(1, 1) + char.ToUpper(word[2]) + word.Remove(0, 3))) + { + ChangeWord = char.ToUpper(word[0]) + word.Substring(1, 1) + char.ToUpper(word[2]) + word.Remove(0, 3); + DoAction(SpellCheckAction.ChangeAll); + return true; + } + + if (_spellCheckWordLists.HasName(word.ToUpperInvariant())) + { + ChangeWord = word.ToUpperInvariant(); + DoAction(SpellCheckAction.ChangeAll); + return true; + } + } + return false; + } + + private static readonly Regex RegexIsNumber = new Regex("^\\d+$", RegexOptions.Compiled); + private static readonly Regex RegexIsEpisodeNumber = new Regex("^\\d+x\\d+$", RegexOptions.Compiled); // e.g. 12x02 + private static bool IsNumber(string s) + { + s = s.Trim('$', '£', '%', '*'); + if (RegexIsNumber.IsMatch(s)) + { + return true; + } + + if (RegexIsEpisodeNumber.IsMatch(s)) + { + return true; + } + + return false; + } + + private void SetWords(string s) + { + s = _spellCheckWordLists.ReplaceHtmlTagsWithBlanks(s); + s = _spellCheckWordLists.ReplaceAssTagsWithBlanks(s); + s = _spellCheckWordLists.ReplaceKnownWordsOrNamesWithBlanks(s); + _words = SpellCheckWordLists.Split(s); + } + + private void ShowEndStatusMessage(string completedMessage) + { + LanguageStructure.Main mainLanguage = Configuration.Settings.Language.Main; + if (_noOfChangedWords > 0 || _noOfAddedWords > 0 || _noOfSkippedWords > 0 || completedMessage == Configuration.Settings.Language.SpellCheck.SpellCheckCompleted) + { + Hide(); + if (Configuration.Settings.Tools.SpellCheckShowCompletedMessage) + { + var form = new DialogDoNotShowAgain(_mainWindow.Title + " - " + mainLanguage.SpellCheck, + completedMessage + Environment.NewLine + + Environment.NewLine + + string.Format(mainLanguage.NumberOfCorrectedWords, _noOfChangedWords) + Environment.NewLine + + string.Format(mainLanguage.NumberOfSkippedWords, _noOfSkippedWords) + Environment.NewLine + + string.Format(mainLanguage.NumberOfCorrectWords, _noOfCorrectWords) + Environment.NewLine + + string.Format(mainLanguage.NumberOfWordsAddedToDictionary, _noOfAddedWords) + Environment.NewLine + + string.Format(mainLanguage.NumberOfNameHits, _noOfNames)); + form.ShowDialog(_mainWindow); + Configuration.Settings.Tools.SpellCheckShowCompletedMessage = !form.DoNoDisplayAgain; + form.Dispose(); + } + else + { + if (_noOfChangedWords > 0) + { + _mainWindow.ShowStatus(completedMessage + " " + string.Format(mainLanguage.NumberOfCorrectedWords, _noOfChangedWords)); + } + else + { + _mainWindow.ShowStatus(completedMessage); + } + } + } + } + + public void ContinueSpellCheck(Subtitle subtitle) + { + _subtitle = subtitle; + + buttonUndo.Visible = false; + _undoList = new List(); + + if (_currentIndex >= subtitle.Paragraphs.Count) + { + _currentIndex = 0; + } + + _currentParagraph = _subtitle.GetParagraphOrDefault(_currentIndex); + if (_currentParagraph == null) + { + return; + } + + SetWords(_currentParagraph.Text); + _wordsIndex = -1; + + PrepareNextWord(); + } + + public void DoSpellCheck(bool autoDetect, Subtitle subtitle, string dictionaryFolder, Main mainWindow, int startLine) + { + _subtitle = subtitle; + LanguageStructure.Main mainLanguage = Configuration.Settings.Language.Main; + _mainWindow = mainWindow; + + _skipAllList = new List(); + + _noOfSkippedWords = 0; + _noOfChangedWords = 0; + _noOfCorrectWords = 0; + _noOfNames = 0; + _noOfAddedWords = 0; + _firstChange = true; + + if (!string.IsNullOrEmpty(Configuration.Settings.General.SpellCheckLanguage) && File.Exists(Path.Combine(dictionaryFolder, Configuration.Settings.General.SpellCheckLanguage + ".dic"))) + { + _languageName = Configuration.Settings.General.SpellCheckLanguage; + } + else + { + string name = Utilities.GetDictionaryLanguages()[0]; + int start = name.LastIndexOf('['); + int end = name.LastIndexOf(']'); + if (start > 0 && end > start) + { + start++; + name = name.Substring(start, end - start); + _languageName = name; + } + else + { + MessageBox.Show(string.Format(mainLanguage.InvalidLanguageNameX, name)); + return; + } + } + if (autoDetect || string.IsNullOrEmpty(_languageName)) + { + _languageName = LanguageAutoDetect.AutoDetectLanguageName(_languageName, subtitle); + if (_languageName != null && _languageName.Length > 3) + { + string start = _languageName.Substring(0, 2); + if (_languageName.StartsWith(start, StringComparison.Ordinal) && Configuration.Settings.General.SpellCheckLanguage != null && + Configuration.Settings.General.SpellCheckLanguage.StartsWith(start, StringComparison.Ordinal) && _languageName != Configuration.Settings.General.SpellCheckLanguage) + { + foreach (var dictionaryName in Utilities.GetDictionaryLanguages()) + { + if (dictionaryName.Contains(Configuration.Settings.General.SpellCheckLanguage)) + { + _languageName = Configuration.Settings.General.SpellCheckLanguage; + break; + } + } + } + } + } + string dictionary = Utilities.DictionaryFolder + _languageName; + + LoadDictionaries(dictionaryFolder, dictionary, _languageName); + + _currentIndex = 0; + if (startLine >= 0 && startLine < _subtitle.Paragraphs.Count) + { + _currentIndex = startLine; + } + + _currentParagraph = _subtitle.Paragraphs[_currentIndex]; + SetWords(_currentParagraph.Text); + _wordsIndex = -1; + + PrepareNextWord(); + } + + private void LoadDictionaries(string dictionaryFolder, string dictionary, string languageName) + { + _skipAllList = new List(); + _spellCheckWordLists = new SpellCheckWordLists(dictionaryFolder, languageName, this); + _changeAllDictionary = _spellCheckWordLists.GetUseAlwaysList(); + LoadHunspell(dictionary); + } + + private void textBoxWord_TextChanged(object sender, EventArgs e) + { + buttonChange.Enabled = textBoxWord.Text != _originalWord; + buttonChangeAll.Enabled = buttonChange.Enabled; + } + + private void buttonAddToDictionary_MouseEnter(object sender, EventArgs e) + { + ShowActionInfo(Configuration.Settings.Language.SpellCheck.AddToUserDictionary, textBoxWord.Text); + } + + private void ShowActionInfo(string label, string text) + { + labelActionInfo.Text = $"{label}: {text.Trim()}"; + _currentAction = label; + } + + private void buttonAddToDictionary_MouseLeave(object sender, EventArgs e) + { + labelActionInfo.Text = string.Empty; + _currentAction = null; + } + + private void buttonAddToNames_MouseEnter(object sender, EventArgs e) + { + ShowActionInfo(Configuration.Settings.Language.SpellCheck.AddToNamesAndIgnoreList, textBoxWord.Text); + } + + private void buttonAddToNames_MouseLeave(object sender, EventArgs e) + { + labelActionInfo.Text = string.Empty; + _currentAction = null; + } + + private void buttonSkipOnce_MouseEnter(object sender, EventArgs e) + { + ShowActionInfo(Configuration.Settings.Language.SpellCheck.SkipOnce, textBoxWord.Text); + } + + private void buttonSkipOnce_MouseLeave(object sender, EventArgs e) + { + labelActionInfo.Text = string.Empty; + _currentAction = null; + } + + private void buttonSkipAll_MouseEnter(object sender, EventArgs e) + { + ShowActionInfo(Configuration.Settings.Language.SpellCheck.SkipAll, textBoxWord.Text); + } + + private void buttonSkipAll_MouseLeave(object sender, EventArgs e) + { + labelActionInfo.Text = string.Empty; + _currentAction = null; + } + + private void buttonChange_MouseEnter(object sender, EventArgs e) + { + ShowActionInfo(Configuration.Settings.Language.SpellCheck.Change, _currentWord + " > " + textBoxWord.Text); + } + + private void buttonChange_MouseLeave(object sender, EventArgs e) + { + labelActionInfo.Text = string.Empty; + _currentAction = null; + } + + private void buttonChangeAll_MouseEnter(object sender, EventArgs e) + { + ShowActionInfo(Configuration.Settings.Language.SpellCheck.ChangeAll, _currentWord + " > " + textBoxWord.Text); + } + + private void buttonChangeAll_MouseLeave(object sender, EventArgs e) + { + labelActionInfo.Text = string.Empty; + _currentAction = null; + } + + private void buttonSpellCheckDownload_Click(object sender, EventArgs e) + { + using (var gd = new GetDictionaries()) + { + gd.ShowDialog(this); + + FillSpellCheckDictionaries(LanguageAutoDetect.AutoDetectLanguageName(null, _subtitle)); + if (gd.LastDownload != null && gd.LastDownload.Length > 3 && comboBoxDictionaries.Items.Count > 0) + { + var lc = Path.GetFileNameWithoutExtension(gd.LastDownload.Substring(0, 4).Replace('_', '-')); + for (int i = 0; i < comboBoxDictionaries.Items.Count; i++) + { + string item = (string)comboBoxDictionaries.Items[i]; + if (item.Contains("[" + lc) || item.Contains(gd.SelectedEnglishName)) + { + comboBoxDictionaries.SelectedIndex = i; + break; + } + } + } + if (comboBoxDictionaries.Items.Count > 0 && comboBoxDictionaries.SelectedIndex < 0) + { + comboBoxDictionaries.SelectedIndex = 0; + } + ComboBoxDictionariesSelectedIndexChanged(null, null); + } + } + + private void PushUndo(string text, SpellCheckAction action) + { + if (string.IsNullOrWhiteSpace(text)) + { + return; + } + + if (action == SpellCheckAction.ChangeAll && _changeAllDictionary.ContainsKey(_currentWord)) + { + return; + } + + string format = Configuration.Settings.Language.SpellCheck.UndoX; + if (string.IsNullOrEmpty(format)) + { + format = "Undo: {0}"; + } + + string undoText = string.Format(format, text); + + _undoList.Add(new UndoObject + { + CurrentIndex = _currentIndex, + UndoText = undoText, + UndoWord = textBoxWord.Text.Trim(), + Action = action, + CurrentWord = _currentWord, + Subtitle = new Subtitle(_subtitle), + NoOfSkippedWords = _noOfSkippedWords, + NoOfChangedWords = _noOfChangedWords, + NoOfCorrectWords = _noOfCorrectWords, + NoOfNames = _noOfNames, + NoOfAddedWords = _noOfAddedWords, + }); + buttonUndo.Text = undoText; + buttonUndo.Visible = true; + } + + private void buttonUndo_Click(object sender, EventArgs e) + { + if (_undoList.Count > 0) + { + var undo = _undoList[_undoList.Count - 1]; + _currentIndex = undo.CurrentIndex - 1; + _wordsIndex = int.MaxValue - 1; + _noOfSkippedWords = undo.NoOfSkippedWords; + _noOfChangedWords = undo.NoOfChangedWords; + _noOfCorrectWords = undo.NoOfCorrectWords; + _noOfNames = undo.NoOfNames; + _noOfAddedWords = undo.NoOfAddedWords; + + switch (undo.Action) + { + case SpellCheckAction.Change: + _subtitle = _mainWindow.UndoFromSpellCheck(undo.Subtitle); + break; + case SpellCheckAction.ChangeAll: + _subtitle = _mainWindow.UndoFromSpellCheck(undo.Subtitle); + _changeAllDictionary.Remove(undo.CurrentWord); + _spellCheckWordLists.UseAlwaysListRemove(undo.CurrentWord); + break; + case SpellCheckAction.Skip: + break; + case SpellCheckAction.SkipAll: + _skipAllList.Remove(undo.UndoWord.ToUpperInvariant()); + if (undo.UndoWord.EndsWith('\'') || undo.UndoWord.StartsWith('\'')) + { + _skipAllList.Remove(undo.UndoWord.ToUpperInvariant().Trim('\'')); + } + + break; + case SpellCheckAction.AddToDictionary: + _spellCheckWordLists.RemoveUserWord(undo.UndoWord); + break; + case SpellCheckAction.AddToNames: + _spellCheckWordLists.RemoveName(undo.UndoWord); + break; + case SpellCheckAction.ChangeWholeText: + _subtitle = _mainWindow.UndoFromSpellCheck(undo.Subtitle); + break; + } + + _undoList.RemoveAt(_undoList.Count - 1); + if (_undoList.Count > 0) + { + buttonUndo.Text = _undoList[_undoList.Count - 1].UndoText; + } + else + { + buttonUndo.Visible = false; + } + } + PrepareNextWord(); + } + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + if (_hunspell != null) + { + _hunspell.Dispose(); + _hunspell = null; + } + components.Dispose(); + } + base.Dispose(disposing); + } + + private void buttonGoogleIt_Click(object sender, EventArgs e) + { + string text = textBoxWord.Text.Trim(); + if (!string.IsNullOrWhiteSpace(text)) + { + UiUtil.OpenURL("https://www.google.com/search?q=" + Utilities.UrlEncode(text)); + } + } + + private void deleteToolStripMenuItem_Click(object sender, EventArgs e) + { + if (!Configuration.Settings.General.PromptDeleteLines || MessageBox.Show(Configuration.Settings.Language.Main.DeleteOneLinePrompt, Configuration.Settings.Language.SpellCheck.Title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) + { + DoAction(SpellCheckAction.DeleteLine); + } + } + } +} diff --git a/src/Forms/SpellCheck.resx b/src/ui/Forms/SpellCheck.resx similarity index 97% rename from src/Forms/SpellCheck.resx rename to src/ui/Forms/SpellCheck.resx index 98381cccc..15f75b3cd 100644 --- a/src/Forms/SpellCheck.resx +++ b/src/ui/Forms/SpellCheck.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/Split.Designer.cs b/src/ui/Forms/Split.Designer.cs similarity index 98% rename from src/Forms/Split.Designer.cs rename to src/ui/Forms/Split.Designer.cs index ae5e3bfb1..29442abbf 100644 --- a/src/Forms/Split.Designer.cs +++ b/src/ui/Forms/Split.Designer.cs @@ -1,423 +1,423 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class Split - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBoxSplitOptions = new System.Windows.Forms.GroupBox(); - this.groupBoxSubtitleInfo = new System.Windows.Forms.GroupBox(); - this.labelCharacters = new System.Windows.Forms.Label(); - this.labelLines = new System.Windows.Forms.Label(); - this.labelNumberOfParts = new System.Windows.Forms.Label(); - this.numericUpDownParts = new System.Windows.Forms.NumericUpDown(); - this.radioButtonCharacters = new System.Windows.Forms.RadioButton(); - this.RadioButtonLines = new System.Windows.Forms.RadioButton(); - this.groupBoxOutput = new System.Windows.Forms.GroupBox(); - this.buttonOpenOutputFolder = new System.Windows.Forms.Button(); - this.labelFileName = new System.Windows.Forms.Label(); - this.textBoxFileName = new System.Windows.Forms.TextBox(); - this.comboBoxSubtitleFormats = new System.Windows.Forms.ComboBox(); - this.labelEncoding = new System.Windows.Forms.Label(); - this.comboBoxEncoding = new System.Windows.Forms.ComboBox(); - this.labelOutputFormat = new System.Windows.Forms.Label(); - this.labelChooseOutputFolder = new System.Windows.Forms.Label(); - this.buttonChooseFolder = new System.Windows.Forms.Button(); - this.textBoxOutputFolder = new System.Windows.Forms.TextBox(); - this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); - this.groupBoxPreview = new System.Windows.Forms.GroupBox(); - this.listViewParts = new System.Windows.Forms.ListView(); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeaderFileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonSplit = new System.Windows.Forms.Button(); - this.buttonBasic = new System.Windows.Forms.Button(); - this.groupBoxSplitOptions.SuspendLayout(); - this.groupBoxSubtitleInfo.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownParts)).BeginInit(); - this.groupBoxOutput.SuspendLayout(); - this.groupBoxPreview.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxSplitOptions - // - this.groupBoxSplitOptions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxSplitOptions.Controls.Add(this.groupBoxSubtitleInfo); - this.groupBoxSplitOptions.Controls.Add(this.labelNumberOfParts); - this.groupBoxSplitOptions.Controls.Add(this.numericUpDownParts); - this.groupBoxSplitOptions.Controls.Add(this.radioButtonCharacters); - this.groupBoxSplitOptions.Controls.Add(this.RadioButtonLines); - this.groupBoxSplitOptions.Location = new System.Drawing.Point(13, 13); - this.groupBoxSplitOptions.Name = "groupBoxSplitOptions"; - this.groupBoxSplitOptions.Size = new System.Drawing.Size(684, 86); - this.groupBoxSplitOptions.TabIndex = 0; - this.groupBoxSplitOptions.TabStop = false; - this.groupBoxSplitOptions.Text = "Split options"; - // - // groupBoxSubtitleInfo - // - this.groupBoxSubtitleInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxSubtitleInfo.Controls.Add(this.labelCharacters); - this.groupBoxSubtitleInfo.Controls.Add(this.labelLines); - this.groupBoxSubtitleInfo.Location = new System.Drawing.Point(311, 13); - this.groupBoxSubtitleInfo.Name = "groupBoxSubtitleInfo"; - this.groupBoxSubtitleInfo.Size = new System.Drawing.Size(367, 67); - this.groupBoxSubtitleInfo.TabIndex = 2; - this.groupBoxSubtitleInfo.TabStop = false; - this.groupBoxSubtitleInfo.Text = "Subtitle info"; - // - // labelCharacters - // - this.labelCharacters.AutoSize = true; - this.labelCharacters.Location = new System.Drawing.Point(7, 46); - this.labelCharacters.Name = "labelCharacters"; - this.labelCharacters.Size = new System.Drawing.Size(122, 13); - this.labelCharacters.TabIndex = 1; - this.labelCharacters.Text = "Number of characters: X"; - // - // labelLines - // - this.labelLines.AutoSize = true; - this.labelLines.Location = new System.Drawing.Point(7, 27); - this.labelLines.Name = "labelLines"; - this.labelLines.Size = new System.Drawing.Size(93, 13); - this.labelLines.TabIndex = 0; - this.labelLines.Text = "Number of lines: X"; - // - // labelNumberOfParts - // - this.labelNumberOfParts.AutoSize = true; - this.labelNumberOfParts.Location = new System.Drawing.Point(148, 22); - this.labelNumberOfParts.Name = "labelNumberOfParts"; - this.labelNumberOfParts.Size = new System.Drawing.Size(111, 13); - this.labelNumberOfParts.TabIndex = 3; - this.labelNumberOfParts.Text = "Number of equal parts"; - // - // numericUpDownParts - // - this.numericUpDownParts.Location = new System.Drawing.Point(151, 38); - this.numericUpDownParts.Minimum = new decimal(new int[] { - 2, - 0, - 0, - 0}); - this.numericUpDownParts.Name = "numericUpDownParts"; - this.numericUpDownParts.Size = new System.Drawing.Size(50, 20); - this.numericUpDownParts.TabIndex = 1; - this.numericUpDownParts.Value = new decimal(new int[] { - 2, - 0, - 0, - 0}); - this.numericUpDownParts.ValueChanged += new System.EventHandler(this.numericUpDownParts_ValueChanged); - // - // radioButtonCharacters - // - this.radioButtonCharacters.AutoSize = true; - this.radioButtonCharacters.Location = new System.Drawing.Point(15, 43); - this.radioButtonCharacters.Name = "radioButtonCharacters"; - this.radioButtonCharacters.Size = new System.Drawing.Size(76, 17); - this.radioButtonCharacters.TabIndex = 0; - this.radioButtonCharacters.Text = "Characters"; - this.radioButtonCharacters.UseVisualStyleBackColor = true; - this.radioButtonCharacters.CheckedChanged += new System.EventHandler(this.radioButtonCharacters_CheckedChanged); - // - // RadioButtonLines - // - this.RadioButtonLines.AutoSize = true; - this.RadioButtonLines.Checked = true; - this.RadioButtonLines.Location = new System.Drawing.Point(15, 20); - this.RadioButtonLines.Name = "RadioButtonLines"; - this.RadioButtonLines.Size = new System.Drawing.Size(50, 17); - this.RadioButtonLines.TabIndex = 0; - this.RadioButtonLines.TabStop = true; - this.RadioButtonLines.Text = "Lines"; - this.RadioButtonLines.UseVisualStyleBackColor = true; - this.RadioButtonLines.CheckedChanged += new System.EventHandler(this.RadioButtonLines_CheckedChanged); - // - // groupBoxOutput - // - this.groupBoxOutput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxOutput.Controls.Add(this.buttonOpenOutputFolder); - this.groupBoxOutput.Controls.Add(this.labelFileName); - this.groupBoxOutput.Controls.Add(this.textBoxFileName); - this.groupBoxOutput.Controls.Add(this.comboBoxSubtitleFormats); - this.groupBoxOutput.Controls.Add(this.labelEncoding); - this.groupBoxOutput.Controls.Add(this.comboBoxEncoding); - this.groupBoxOutput.Controls.Add(this.labelOutputFormat); - this.groupBoxOutput.Controls.Add(this.labelChooseOutputFolder); - this.groupBoxOutput.Controls.Add(this.buttonChooseFolder); - this.groupBoxOutput.Controls.Add(this.textBoxOutputFolder); - this.groupBoxOutput.Location = new System.Drawing.Point(12, 105); - this.groupBoxOutput.Name = "groupBoxOutput"; - this.groupBoxOutput.Size = new System.Drawing.Size(688, 143); - this.groupBoxOutput.TabIndex = 1; - this.groupBoxOutput.TabStop = false; - this.groupBoxOutput.Text = "Output"; - // - // buttonOpenOutputFolder - // - this.buttonOpenOutputFolder.Location = new System.Drawing.Point(574, 75); - this.buttonOpenOutputFolder.Name = "buttonOpenOutputFolder"; - this.buttonOpenOutputFolder.Size = new System.Drawing.Size(81, 23); - this.buttonOpenOutputFolder.TabIndex = 5; - this.buttonOpenOutputFolder.Text = "Open..."; - this.buttonOpenOutputFolder.UseVisualStyleBackColor = true; - this.buttonOpenOutputFolder.Click += new System.EventHandler(this.buttonOpenOutputFolder_Click); - // - // labelFileName - // - this.labelFileName.AutoSize = true; - this.labelFileName.Location = new System.Drawing.Point(6, 16); - this.labelFileName.Name = "labelFileName"; - this.labelFileName.Size = new System.Drawing.Size(52, 13); - this.labelFileName.TabIndex = 0; - this.labelFileName.Text = "File name"; - // - // textBoxFileName - // - this.textBoxFileName.Location = new System.Drawing.Point(7, 32); - this.textBoxFileName.Name = "textBoxFileName"; - this.textBoxFileName.Size = new System.Drawing.Size(529, 20); - this.textBoxFileName.TabIndex = 1; - this.textBoxFileName.TextChanged += new System.EventHandler(this.textBoxFileName_TextChanged); - // - // comboBoxSubtitleFormats - // - this.comboBoxSubtitleFormats.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSubtitleFormats.FormattingEnabled = true; - this.comboBoxSubtitleFormats.Location = new System.Drawing.Point(51, 107); - this.comboBoxSubtitleFormats.Name = "comboBoxSubtitleFormats"; - this.comboBoxSubtitleFormats.Size = new System.Drawing.Size(225, 21); - this.comboBoxSubtitleFormats.TabIndex = 7; - this.comboBoxSubtitleFormats.SelectedIndexChanged += new System.EventHandler(this.comboBoxSubtitleFormats_SelectedIndexChanged); - // - // labelEncoding - // - this.labelEncoding.AutoSize = true; - this.labelEncoding.Location = new System.Drawing.Point(336, 110); - this.labelEncoding.Name = "labelEncoding"; - this.labelEncoding.Size = new System.Drawing.Size(52, 13); - this.labelEncoding.TabIndex = 8; - this.labelEncoding.Text = "Encoding"; - // - // comboBoxEncoding - // - this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxEncoding.FormattingEnabled = true; - this.comboBoxEncoding.Location = new System.Drawing.Point(394, 107); - this.comboBoxEncoding.Name = "comboBoxEncoding"; - this.comboBoxEncoding.Size = new System.Drawing.Size(221, 21); - this.comboBoxEncoding.TabIndex = 9; - // - // labelOutputFormat - // - this.labelOutputFormat.AutoSize = true; - this.labelOutputFormat.Location = new System.Drawing.Point(6, 110); - this.labelOutputFormat.Name = "labelOutputFormat"; - this.labelOutputFormat.Size = new System.Drawing.Size(39, 13); - this.labelOutputFormat.TabIndex = 6; - this.labelOutputFormat.Text = "Format"; - // - // labelChooseOutputFolder - // - this.labelChooseOutputFolder.AutoSize = true; - this.labelChooseOutputFolder.Location = new System.Drawing.Point(6, 61); - this.labelChooseOutputFolder.Name = "labelChooseOutputFolder"; - this.labelChooseOutputFolder.Size = new System.Drawing.Size(105, 13); - this.labelChooseOutputFolder.TabIndex = 2; - this.labelChooseOutputFolder.Text = "Choose output folder"; - // - // buttonChooseFolder - // - this.buttonChooseFolder.Location = new System.Drawing.Point(542, 75); - this.buttonChooseFolder.Name = "buttonChooseFolder"; - this.buttonChooseFolder.Size = new System.Drawing.Size(26, 23); - this.buttonChooseFolder.TabIndex = 4; - this.buttonChooseFolder.Text = "..."; - this.buttonChooseFolder.UseVisualStyleBackColor = true; - this.buttonChooseFolder.Click += new System.EventHandler(this.buttonChooseFolder_Click); - // - // textBoxOutputFolder - // - this.textBoxOutputFolder.Location = new System.Drawing.Point(7, 77); - this.textBoxOutputFolder.Name = "textBoxOutputFolder"; - this.textBoxOutputFolder.Size = new System.Drawing.Size(529, 20); - this.textBoxOutputFolder.TabIndex = 3; - this.textBoxOutputFolder.TextChanged += new System.EventHandler(this.textBoxOutputFolder_TextChanged); - // - // groupBoxPreview - // - this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxPreview.Controls.Add(this.listViewParts); - this.groupBoxPreview.Location = new System.Drawing.Point(12, 254); - this.groupBoxPreview.Name = "groupBoxPreview"; - this.groupBoxPreview.Size = new System.Drawing.Size(688, 245); - this.groupBoxPreview.TabIndex = 2; - this.groupBoxPreview.TabStop = false; - this.groupBoxPreview.Text = "Preview"; - // - // listViewParts - // - this.listViewParts.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader5, - this.columnHeader6, - this.columnHeaderFileName}); - this.listViewParts.Dock = System.Windows.Forms.DockStyle.Fill; - this.listViewParts.FullRowSelect = true; - this.listViewParts.HideSelection = false; - this.listViewParts.Location = new System.Drawing.Point(3, 16); - this.listViewParts.Name = "listViewParts"; - this.listViewParts.Size = new System.Drawing.Size(682, 226); - this.listViewParts.TabIndex = 0; - this.listViewParts.UseCompatibleStateImageBehavior = false; - this.listViewParts.View = System.Windows.Forms.View.Details; - // - // columnHeader5 - // - this.columnHeader5.Text = "#Lines"; - this.columnHeader5.Width = 61; - // - // columnHeader6 - // - this.columnHeader6.Text = "#Characters"; - this.columnHeader6.Width = 75; - // - // columnHeaderFileName - // - this.columnHeaderFileName.Text = "File name"; - this.columnHeaderFileName.Width = 463; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(625, 505); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonSplit - // - this.buttonSplit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonSplit.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonSplit.Location = new System.Drawing.Point(544, 505); - this.buttonSplit.Name = "buttonSplit"; - this.buttonSplit.Size = new System.Drawing.Size(75, 23); - this.buttonSplit.TabIndex = 4; - this.buttonSplit.Text = "&Split"; - this.buttonSplit.UseVisualStyleBackColor = true; - this.buttonSplit.Click += new System.EventHandler(this.buttonSplit_Click); - // - // buttonBasic - // - this.buttonBasic.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonBasic.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonBasic.Location = new System.Drawing.Point(440, 505); - this.buttonBasic.Name = "buttonBasic"; - this.buttonBasic.Size = new System.Drawing.Size(98, 23); - this.buttonBasic.TabIndex = 3; - this.buttonBasic.Text = "&Basic"; - this.buttonBasic.UseVisualStyleBackColor = true; - this.buttonBasic.Click += new System.EventHandler(this.buttonBasic_Click); - // - // Split - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(712, 537); - this.Controls.Add(this.buttonBasic); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonSplit); - this.Controls.Add(this.groupBoxPreview); - this.Controls.Add(this.groupBoxOutput); - this.Controls.Add(this.groupBoxSplitOptions); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(640, 420); - this.Name = "Split"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Split"; - this.Shown += new System.EventHandler(this.Split_Shown); - this.ResizeEnd += new System.EventHandler(this.Split_ResizeEnd); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Split_KeyDown); - this.Resize += new System.EventHandler(this.Split_Resize); - this.groupBoxSplitOptions.ResumeLayout(false); - this.groupBoxSplitOptions.PerformLayout(); - this.groupBoxSubtitleInfo.ResumeLayout(false); - this.groupBoxSubtitleInfo.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownParts)).EndInit(); - this.groupBoxOutput.ResumeLayout(false); - this.groupBoxOutput.PerformLayout(); - this.groupBoxPreview.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxSplitOptions; - private System.Windows.Forms.Label labelNumberOfParts; - private System.Windows.Forms.NumericUpDown numericUpDownParts; - private System.Windows.Forms.RadioButton radioButtonCharacters; - private System.Windows.Forms.RadioButton RadioButtonLines; - private System.Windows.Forms.GroupBox groupBoxOutput; - private System.Windows.Forms.ComboBox comboBoxEncoding; - private System.Windows.Forms.Label labelOutputFormat; - private System.Windows.Forms.Label labelChooseOutputFolder; - private System.Windows.Forms.Button buttonChooseFolder; - private System.Windows.Forms.TextBox textBoxOutputFolder; - private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; - private System.Windows.Forms.GroupBox groupBoxPreview; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonSplit; - private System.Windows.Forms.ListView listViewParts; - private System.Windows.Forms.ColumnHeader columnHeaderFileName; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeader6; - private System.Windows.Forms.Button buttonBasic; - private System.Windows.Forms.GroupBox groupBoxSubtitleInfo; - private System.Windows.Forms.Label labelCharacters; - private System.Windows.Forms.Label labelLines; - private System.Windows.Forms.ComboBox comboBoxSubtitleFormats; - private System.Windows.Forms.Label labelEncoding; - private System.Windows.Forms.Label labelFileName; - private System.Windows.Forms.TextBox textBoxFileName; - private System.Windows.Forms.Button buttonOpenOutputFolder; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class Split + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBoxSplitOptions = new System.Windows.Forms.GroupBox(); + this.groupBoxSubtitleInfo = new System.Windows.Forms.GroupBox(); + this.labelCharacters = new System.Windows.Forms.Label(); + this.labelLines = new System.Windows.Forms.Label(); + this.labelNumberOfParts = new System.Windows.Forms.Label(); + this.numericUpDownParts = new System.Windows.Forms.NumericUpDown(); + this.radioButtonCharacters = new System.Windows.Forms.RadioButton(); + this.RadioButtonLines = new System.Windows.Forms.RadioButton(); + this.groupBoxOutput = new System.Windows.Forms.GroupBox(); + this.buttonOpenOutputFolder = new System.Windows.Forms.Button(); + this.labelFileName = new System.Windows.Forms.Label(); + this.textBoxFileName = new System.Windows.Forms.TextBox(); + this.comboBoxSubtitleFormats = new System.Windows.Forms.ComboBox(); + this.labelEncoding = new System.Windows.Forms.Label(); + this.comboBoxEncoding = new System.Windows.Forms.ComboBox(); + this.labelOutputFormat = new System.Windows.Forms.Label(); + this.labelChooseOutputFolder = new System.Windows.Forms.Label(); + this.buttonChooseFolder = new System.Windows.Forms.Button(); + this.textBoxOutputFolder = new System.Windows.Forms.TextBox(); + this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); + this.groupBoxPreview = new System.Windows.Forms.GroupBox(); + this.listViewParts = new System.Windows.Forms.ListView(); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeaderFileName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonSplit = new System.Windows.Forms.Button(); + this.buttonBasic = new System.Windows.Forms.Button(); + this.groupBoxSplitOptions.SuspendLayout(); + this.groupBoxSubtitleInfo.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownParts)).BeginInit(); + this.groupBoxOutput.SuspendLayout(); + this.groupBoxPreview.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxSplitOptions + // + this.groupBoxSplitOptions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxSplitOptions.Controls.Add(this.groupBoxSubtitleInfo); + this.groupBoxSplitOptions.Controls.Add(this.labelNumberOfParts); + this.groupBoxSplitOptions.Controls.Add(this.numericUpDownParts); + this.groupBoxSplitOptions.Controls.Add(this.radioButtonCharacters); + this.groupBoxSplitOptions.Controls.Add(this.RadioButtonLines); + this.groupBoxSplitOptions.Location = new System.Drawing.Point(13, 13); + this.groupBoxSplitOptions.Name = "groupBoxSplitOptions"; + this.groupBoxSplitOptions.Size = new System.Drawing.Size(684, 86); + this.groupBoxSplitOptions.TabIndex = 0; + this.groupBoxSplitOptions.TabStop = false; + this.groupBoxSplitOptions.Text = "Split options"; + // + // groupBoxSubtitleInfo + // + this.groupBoxSubtitleInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxSubtitleInfo.Controls.Add(this.labelCharacters); + this.groupBoxSubtitleInfo.Controls.Add(this.labelLines); + this.groupBoxSubtitleInfo.Location = new System.Drawing.Point(311, 13); + this.groupBoxSubtitleInfo.Name = "groupBoxSubtitleInfo"; + this.groupBoxSubtitleInfo.Size = new System.Drawing.Size(367, 67); + this.groupBoxSubtitleInfo.TabIndex = 2; + this.groupBoxSubtitleInfo.TabStop = false; + this.groupBoxSubtitleInfo.Text = "Subtitle info"; + // + // labelCharacters + // + this.labelCharacters.AutoSize = true; + this.labelCharacters.Location = new System.Drawing.Point(7, 46); + this.labelCharacters.Name = "labelCharacters"; + this.labelCharacters.Size = new System.Drawing.Size(122, 13); + this.labelCharacters.TabIndex = 1; + this.labelCharacters.Text = "Number of characters: X"; + // + // labelLines + // + this.labelLines.AutoSize = true; + this.labelLines.Location = new System.Drawing.Point(7, 27); + this.labelLines.Name = "labelLines"; + this.labelLines.Size = new System.Drawing.Size(93, 13); + this.labelLines.TabIndex = 0; + this.labelLines.Text = "Number of lines: X"; + // + // labelNumberOfParts + // + this.labelNumberOfParts.AutoSize = true; + this.labelNumberOfParts.Location = new System.Drawing.Point(148, 22); + this.labelNumberOfParts.Name = "labelNumberOfParts"; + this.labelNumberOfParts.Size = new System.Drawing.Size(111, 13); + this.labelNumberOfParts.TabIndex = 3; + this.labelNumberOfParts.Text = "Number of equal parts"; + // + // numericUpDownParts + // + this.numericUpDownParts.Location = new System.Drawing.Point(151, 38); + this.numericUpDownParts.Minimum = new decimal(new int[] { + 2, + 0, + 0, + 0}); + this.numericUpDownParts.Name = "numericUpDownParts"; + this.numericUpDownParts.Size = new System.Drawing.Size(50, 20); + this.numericUpDownParts.TabIndex = 1; + this.numericUpDownParts.Value = new decimal(new int[] { + 2, + 0, + 0, + 0}); + this.numericUpDownParts.ValueChanged += new System.EventHandler(this.numericUpDownParts_ValueChanged); + // + // radioButtonCharacters + // + this.radioButtonCharacters.AutoSize = true; + this.radioButtonCharacters.Location = new System.Drawing.Point(15, 43); + this.radioButtonCharacters.Name = "radioButtonCharacters"; + this.radioButtonCharacters.Size = new System.Drawing.Size(76, 17); + this.radioButtonCharacters.TabIndex = 0; + this.radioButtonCharacters.Text = "Characters"; + this.radioButtonCharacters.UseVisualStyleBackColor = true; + this.radioButtonCharacters.CheckedChanged += new System.EventHandler(this.radioButtonCharacters_CheckedChanged); + // + // RadioButtonLines + // + this.RadioButtonLines.AutoSize = true; + this.RadioButtonLines.Checked = true; + this.RadioButtonLines.Location = new System.Drawing.Point(15, 20); + this.RadioButtonLines.Name = "RadioButtonLines"; + this.RadioButtonLines.Size = new System.Drawing.Size(50, 17); + this.RadioButtonLines.TabIndex = 0; + this.RadioButtonLines.TabStop = true; + this.RadioButtonLines.Text = "Lines"; + this.RadioButtonLines.UseVisualStyleBackColor = true; + this.RadioButtonLines.CheckedChanged += new System.EventHandler(this.RadioButtonLines_CheckedChanged); + // + // groupBoxOutput + // + this.groupBoxOutput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxOutput.Controls.Add(this.buttonOpenOutputFolder); + this.groupBoxOutput.Controls.Add(this.labelFileName); + this.groupBoxOutput.Controls.Add(this.textBoxFileName); + this.groupBoxOutput.Controls.Add(this.comboBoxSubtitleFormats); + this.groupBoxOutput.Controls.Add(this.labelEncoding); + this.groupBoxOutput.Controls.Add(this.comboBoxEncoding); + this.groupBoxOutput.Controls.Add(this.labelOutputFormat); + this.groupBoxOutput.Controls.Add(this.labelChooseOutputFolder); + this.groupBoxOutput.Controls.Add(this.buttonChooseFolder); + this.groupBoxOutput.Controls.Add(this.textBoxOutputFolder); + this.groupBoxOutput.Location = new System.Drawing.Point(12, 105); + this.groupBoxOutput.Name = "groupBoxOutput"; + this.groupBoxOutput.Size = new System.Drawing.Size(688, 143); + this.groupBoxOutput.TabIndex = 1; + this.groupBoxOutput.TabStop = false; + this.groupBoxOutput.Text = "Output"; + // + // buttonOpenOutputFolder + // + this.buttonOpenOutputFolder.Location = new System.Drawing.Point(574, 75); + this.buttonOpenOutputFolder.Name = "buttonOpenOutputFolder"; + this.buttonOpenOutputFolder.Size = new System.Drawing.Size(81, 23); + this.buttonOpenOutputFolder.TabIndex = 5; + this.buttonOpenOutputFolder.Text = "Open..."; + this.buttonOpenOutputFolder.UseVisualStyleBackColor = true; + this.buttonOpenOutputFolder.Click += new System.EventHandler(this.buttonOpenOutputFolder_Click); + // + // labelFileName + // + this.labelFileName.AutoSize = true; + this.labelFileName.Location = new System.Drawing.Point(6, 16); + this.labelFileName.Name = "labelFileName"; + this.labelFileName.Size = new System.Drawing.Size(52, 13); + this.labelFileName.TabIndex = 0; + this.labelFileName.Text = "File name"; + // + // textBoxFileName + // + this.textBoxFileName.Location = new System.Drawing.Point(7, 32); + this.textBoxFileName.Name = "textBoxFileName"; + this.textBoxFileName.Size = new System.Drawing.Size(529, 20); + this.textBoxFileName.TabIndex = 1; + this.textBoxFileName.TextChanged += new System.EventHandler(this.textBoxFileName_TextChanged); + // + // comboBoxSubtitleFormats + // + this.comboBoxSubtitleFormats.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSubtitleFormats.FormattingEnabled = true; + this.comboBoxSubtitleFormats.Location = new System.Drawing.Point(51, 107); + this.comboBoxSubtitleFormats.Name = "comboBoxSubtitleFormats"; + this.comboBoxSubtitleFormats.Size = new System.Drawing.Size(225, 21); + this.comboBoxSubtitleFormats.TabIndex = 7; + this.comboBoxSubtitleFormats.SelectedIndexChanged += new System.EventHandler(this.comboBoxSubtitleFormats_SelectedIndexChanged); + // + // labelEncoding + // + this.labelEncoding.AutoSize = true; + this.labelEncoding.Location = new System.Drawing.Point(336, 110); + this.labelEncoding.Name = "labelEncoding"; + this.labelEncoding.Size = new System.Drawing.Size(52, 13); + this.labelEncoding.TabIndex = 8; + this.labelEncoding.Text = "Encoding"; + // + // comboBoxEncoding + // + this.comboBoxEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxEncoding.FormattingEnabled = true; + this.comboBoxEncoding.Location = new System.Drawing.Point(394, 107); + this.comboBoxEncoding.Name = "comboBoxEncoding"; + this.comboBoxEncoding.Size = new System.Drawing.Size(221, 21); + this.comboBoxEncoding.TabIndex = 9; + // + // labelOutputFormat + // + this.labelOutputFormat.AutoSize = true; + this.labelOutputFormat.Location = new System.Drawing.Point(6, 110); + this.labelOutputFormat.Name = "labelOutputFormat"; + this.labelOutputFormat.Size = new System.Drawing.Size(39, 13); + this.labelOutputFormat.TabIndex = 6; + this.labelOutputFormat.Text = "Format"; + // + // labelChooseOutputFolder + // + this.labelChooseOutputFolder.AutoSize = true; + this.labelChooseOutputFolder.Location = new System.Drawing.Point(6, 61); + this.labelChooseOutputFolder.Name = "labelChooseOutputFolder"; + this.labelChooseOutputFolder.Size = new System.Drawing.Size(105, 13); + this.labelChooseOutputFolder.TabIndex = 2; + this.labelChooseOutputFolder.Text = "Choose output folder"; + // + // buttonChooseFolder + // + this.buttonChooseFolder.Location = new System.Drawing.Point(542, 75); + this.buttonChooseFolder.Name = "buttonChooseFolder"; + this.buttonChooseFolder.Size = new System.Drawing.Size(26, 23); + this.buttonChooseFolder.TabIndex = 4; + this.buttonChooseFolder.Text = "..."; + this.buttonChooseFolder.UseVisualStyleBackColor = true; + this.buttonChooseFolder.Click += new System.EventHandler(this.buttonChooseFolder_Click); + // + // textBoxOutputFolder + // + this.textBoxOutputFolder.Location = new System.Drawing.Point(7, 77); + this.textBoxOutputFolder.Name = "textBoxOutputFolder"; + this.textBoxOutputFolder.Size = new System.Drawing.Size(529, 20); + this.textBoxOutputFolder.TabIndex = 3; + this.textBoxOutputFolder.TextChanged += new System.EventHandler(this.textBoxOutputFolder_TextChanged); + // + // groupBoxPreview + // + this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxPreview.Controls.Add(this.listViewParts); + this.groupBoxPreview.Location = new System.Drawing.Point(12, 254); + this.groupBoxPreview.Name = "groupBoxPreview"; + this.groupBoxPreview.Size = new System.Drawing.Size(688, 245); + this.groupBoxPreview.TabIndex = 2; + this.groupBoxPreview.TabStop = false; + this.groupBoxPreview.Text = "Preview"; + // + // listViewParts + // + this.listViewParts.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader5, + this.columnHeader6, + this.columnHeaderFileName}); + this.listViewParts.Dock = System.Windows.Forms.DockStyle.Fill; + this.listViewParts.FullRowSelect = true; + this.listViewParts.HideSelection = false; + this.listViewParts.Location = new System.Drawing.Point(3, 16); + this.listViewParts.Name = "listViewParts"; + this.listViewParts.Size = new System.Drawing.Size(682, 226); + this.listViewParts.TabIndex = 0; + this.listViewParts.UseCompatibleStateImageBehavior = false; + this.listViewParts.View = System.Windows.Forms.View.Details; + // + // columnHeader5 + // + this.columnHeader5.Text = "#Lines"; + this.columnHeader5.Width = 61; + // + // columnHeader6 + // + this.columnHeader6.Text = "#Characters"; + this.columnHeader6.Width = 75; + // + // columnHeaderFileName + // + this.columnHeaderFileName.Text = "File name"; + this.columnHeaderFileName.Width = 463; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(625, 505); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonSplit + // + this.buttonSplit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSplit.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonSplit.Location = new System.Drawing.Point(544, 505); + this.buttonSplit.Name = "buttonSplit"; + this.buttonSplit.Size = new System.Drawing.Size(75, 23); + this.buttonSplit.TabIndex = 4; + this.buttonSplit.Text = "&Split"; + this.buttonSplit.UseVisualStyleBackColor = true; + this.buttonSplit.Click += new System.EventHandler(this.buttonSplit_Click); + // + // buttonBasic + // + this.buttonBasic.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonBasic.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonBasic.Location = new System.Drawing.Point(440, 505); + this.buttonBasic.Name = "buttonBasic"; + this.buttonBasic.Size = new System.Drawing.Size(98, 23); + this.buttonBasic.TabIndex = 3; + this.buttonBasic.Text = "&Basic"; + this.buttonBasic.UseVisualStyleBackColor = true; + this.buttonBasic.Click += new System.EventHandler(this.buttonBasic_Click); + // + // Split + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(712, 537); + this.Controls.Add(this.buttonBasic); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonSplit); + this.Controls.Add(this.groupBoxPreview); + this.Controls.Add(this.groupBoxOutput); + this.Controls.Add(this.groupBoxSplitOptions); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(640, 420); + this.Name = "Split"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Split"; + this.Shown += new System.EventHandler(this.Split_Shown); + this.ResizeEnd += new System.EventHandler(this.Split_ResizeEnd); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Split_KeyDown); + this.Resize += new System.EventHandler(this.Split_Resize); + this.groupBoxSplitOptions.ResumeLayout(false); + this.groupBoxSplitOptions.PerformLayout(); + this.groupBoxSubtitleInfo.ResumeLayout(false); + this.groupBoxSubtitleInfo.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownParts)).EndInit(); + this.groupBoxOutput.ResumeLayout(false); + this.groupBoxOutput.PerformLayout(); + this.groupBoxPreview.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxSplitOptions; + private System.Windows.Forms.Label labelNumberOfParts; + private System.Windows.Forms.NumericUpDown numericUpDownParts; + private System.Windows.Forms.RadioButton radioButtonCharacters; + private System.Windows.Forms.RadioButton RadioButtonLines; + private System.Windows.Forms.GroupBox groupBoxOutput; + private System.Windows.Forms.ComboBox comboBoxEncoding; + private System.Windows.Forms.Label labelOutputFormat; + private System.Windows.Forms.Label labelChooseOutputFolder; + private System.Windows.Forms.Button buttonChooseFolder; + private System.Windows.Forms.TextBox textBoxOutputFolder; + private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; + private System.Windows.Forms.GroupBox groupBoxPreview; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonSplit; + private System.Windows.Forms.ListView listViewParts; + private System.Windows.Forms.ColumnHeader columnHeaderFileName; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader6; + private System.Windows.Forms.Button buttonBasic; + private System.Windows.Forms.GroupBox groupBoxSubtitleInfo; + private System.Windows.Forms.Label labelCharacters; + private System.Windows.Forms.Label labelLines; + private System.Windows.Forms.ComboBox comboBoxSubtitleFormats; + private System.Windows.Forms.Label labelEncoding; + private System.Windows.Forms.Label labelFileName; + private System.Windows.Forms.TextBox textBoxFileName; + private System.Windows.Forms.Button buttonOpenOutputFolder; + } } \ No newline at end of file diff --git a/src/Forms/Split.cs b/src/ui/Forms/Split.cs similarity index 97% rename from src/Forms/Split.cs rename to src/ui/Forms/Split.cs index 5995f0682..ffdce784e 100644 --- a/src/Forms/Split.cs +++ b/src/ui/Forms/Split.cs @@ -1,353 +1,353 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.IO; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class Split : Form - { - private Subtitle _subtitle; - public bool ShowBasic { get; private set; } - private int _totalNumberOfCharacters; - private bool _loading = true; - private List _parts; - private string _fileName; - - public Split() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - var l = Configuration.Settings.Language.Split; - Text = l.Title; - groupBoxSplitOptions.Text = l.SplitOptions; - RadioButtonLines.Text = l.Lines; - radioButtonCharacters.Text = l.Characters; - labelNumberOfParts.Text = l.NumberOfEqualParts; - groupBoxSubtitleInfo.Text = l.SubtitleInfo; - groupBoxOutput.Text = l.Output; - labelFileName.Text = l.FileName; - labelChooseOutputFolder.Text = l.OutputFolder; - labelOutputFormat.Text = Configuration.Settings.Language.Main.Controls.SubtitleFormat; - labelEncoding.Text = Configuration.Settings.Language.Main.Controls.FileEncoding; - groupBoxPreview.Text = Configuration.Settings.Language.General.Preview; - buttonOpenOutputFolder.Text = Configuration.Settings.Language.Main.Menu.File.Open; - - listViewParts.Columns[0].Text = l.Lines; - listViewParts.Columns[1].Text = l.Characters; - listViewParts.Columns[2].Text = l.FileName; - - buttonSplit.Text = l.DoSplit; - buttonBasic.Text = l.Basic; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - - comboBoxSubtitleFormats.Left = labelOutputFormat.Left + labelOutputFormat.Width + 3; - comboBoxEncoding.Left = labelEncoding.Left + labelEncoding.Width + 3; - - UiUtil.FixLargeFonts(this, buttonSplit); - } - - public void Initialize(Subtitle subtitle, string fileName, SubtitleFormat format) - { - ShowBasic = false; - _subtitle = subtitle; - if (string.IsNullOrEmpty(fileName)) - { - textBoxFileName.Text = Configuration.Settings.Language.SplitSubtitle.Untitled; - } - else - { - textBoxFileName.Text = fileName; - } - - _fileName = fileName; - foreach (Paragraph p in _subtitle.Paragraphs) - { - _totalNumberOfCharacters += HtmlUtil.RemoveHtmlTags(p.Text, true).Length; - } - - labelLines.Text = string.Format(Configuration.Settings.Language.Split.NumberOfLinesX, _subtitle.Paragraphs.Count); - labelCharacters.Text = string.Format(Configuration.Settings.Language.Split.NumberOfCharactersX, _totalNumberOfCharacters); - - try - { - numericUpDownParts.Value = Configuration.Settings.Tools.SplitNumberOfParts; - } - catch - { - // ignored - } - - if (Configuration.Settings.Tools.SplitVia.Trim().Equals("lines", StringComparison.OrdinalIgnoreCase)) - { - RadioButtonLines.Checked = true; - } - else - { - radioButtonCharacters.Checked = true; - } - - UiUtil.InitializeSubtitleFormatComboBox(comboBoxSubtitleFormats, format.FriendlyName); - - UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding); - - if (numericUpDownParts.Maximum > _subtitle.Paragraphs.Count) - { - numericUpDownParts.Maximum = (int)Math.Round(_subtitle.Paragraphs.Count / 2.0); - } - - if (!string.IsNullOrEmpty(_fileName)) - { - textBoxOutputFolder.Text = Path.GetDirectoryName(_fileName); - } - else if (string.IsNullOrEmpty(Configuration.Settings.Tools.SplitOutputFolder) || !Directory.Exists(Configuration.Settings.Tools.SplitOutputFolder)) - { - textBoxOutputFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); - } - else - { - textBoxOutputFolder.Text = Configuration.Settings.Tools.SplitOutputFolder; - } - } - - private void CalculateParts() - { - if (_loading) - { - return; - } - - _loading = true; - _parts = new List(); - if (string.IsNullOrEmpty(textBoxOutputFolder.Text) || !Directory.Exists(textBoxOutputFolder.Text)) - { - textBoxOutputFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); - } - - var format = Utilities.GetSubtitleFormatByFriendlyName(comboBoxSubtitleFormats.SelectedItem.ToString()); - string fileNameNoExt = Path.GetFileNameWithoutExtension(textBoxFileName.Text); - if (string.IsNullOrWhiteSpace(fileNameNoExt)) - { - fileNameNoExt = Configuration.Settings.Language.SplitSubtitle.Untitled; - } - - if (numericUpDownParts.Value == 0) - { - buttonSplit.Enabled = false; - return; - } - - listViewParts.Items.Clear(); - int startNumber = 0; - if (RadioButtonLines.Checked) - { - int partSize = (int)(_subtitle.Paragraphs.Count / numericUpDownParts.Value); - for (int i = 0; i < numericUpDownParts.Value; i++) - { - int noOfLines = partSize; - if (i == numericUpDownParts.Value - 1) - { - noOfLines = (int)(_subtitle.Paragraphs.Count - (numericUpDownParts.Value - 1) * partSize); - } - - var temp = new Subtitle { Header = _subtitle.Header }; - int size = 0; - for (int number = 0; number < noOfLines; number++) - { - Paragraph p = _subtitle.Paragraphs[startNumber + number]; - temp.Paragraphs.Add(new Paragraph(p)); - size += HtmlUtil.RemoveHtmlTags(p.Text, true).Length; - } - startNumber += noOfLines; - _parts.Add(temp); - - var lvi = new ListViewItem($"{noOfLines:#,###,###}"); - lvi.SubItems.Add($"{size:#,###,###}"); - lvi.SubItems.Add(fileNameNoExt + ".Part" + (i + 1) + format.Extension); - listViewParts.Items.Add(lvi); - } - } - else if (radioButtonCharacters.Checked) - { - int partSize = (int)(_totalNumberOfCharacters / numericUpDownParts.Value); - int nextLimit = partSize; - int currentSize = 0; - Subtitle temp = new Subtitle { Header = _subtitle.Header }; - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - Paragraph p = _subtitle.Paragraphs[i]; - int size = HtmlUtil.RemoveHtmlTags(p.Text, true).Length; - if (currentSize + size > nextLimit + 4 && _parts.Count < numericUpDownParts.Value - 1) - { - _parts.Add(temp); - var lvi = new ListViewItem($"{temp.Paragraphs.Count:#,###,###}"); - lvi.SubItems.Add($"{currentSize:#,###,###}"); - lvi.SubItems.Add(fileNameNoExt + ".Part" + _parts.Count + format.Extension); - listViewParts.Items.Add(lvi); - currentSize = size; - temp = new Subtitle { Header = _subtitle.Header }; - temp.Paragraphs.Add(new Paragraph(p)); - } - else - { - currentSize += size; - temp.Paragraphs.Add(new Paragraph(p)); - } - } - _parts.Add(temp); - var lvi2 = new ListViewItem($"{temp.Paragraphs.Count:#,###,###}"); - lvi2.SubItems.Add($"{currentSize:#,###,###}"); - lvi2.SubItems.Add(fileNameNoExt + ".Part" + numericUpDownParts.Value + ".srt"); - listViewParts.Items.Add(lvi2); - } - _loading = false; - } - - private void buttonBasic_Click(object sender, EventArgs e) - { - ShowBasic = true; - DialogResult = DialogResult.Cancel; - } - - private void buttonSplit_Click(object sender, EventArgs e) - { - bool overwrite = false; - var format = Utilities.GetSubtitleFormatByFriendlyName(comboBoxSubtitleFormats.SelectedItem.ToString()); - string fileNameNoExt = Path.GetFileNameWithoutExtension(textBoxFileName.Text); - if (string.IsNullOrWhiteSpace(fileNameNoExt)) - { - fileNameNoExt = Configuration.Settings.Language.SplitSubtitle.Untitled; - } - - int number = 1; - try - { - foreach (Subtitle sub in _parts) - { - string fileName = Path.Combine(textBoxOutputFolder.Text, fileNameNoExt + ".Part" + number + format.Extension); - string allText = sub.ToText(format); - if (File.Exists(fileName) && !overwrite) - { - if (MessageBox.Show(Configuration.Settings.Language.SplitSubtitle.OverwriteExistingFiles, "", MessageBoxButtons.YesNo) == DialogResult.No) - { - return; - } - - overwrite = true; - } - FileUtil.WriteAllText(fileName, allText, GetCurrentEncoding()); - number++; - } - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - return; - } - - Configuration.Settings.Tools.SplitNumberOfParts = (int)numericUpDownParts.Value; - Configuration.Settings.Tools.SplitOutputFolder = textBoxOutputFolder.Text; - if (RadioButtonLines.Checked) - { - Configuration.Settings.Tools.SplitVia = "Lines"; - } - else - { - Configuration.Settings.Tools.SplitVia = "Characters"; - } - - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void numericUpDownParts_ValueChanged(object sender, EventArgs e) - { - CalculateParts(); - } - - private void radioButtonCharacters_CheckedChanged(object sender, EventArgs e) - { - CalculateParts(); - } - - private void RadioButtonLines_CheckedChanged(object sender, EventArgs e) - { - CalculateParts(); - } - - private void textBoxOutputFolder_TextChanged(object sender, EventArgs e) - { - CalculateParts(); - } - - private void Split_ResizeEnd(object sender, EventArgs e) - { - columnHeaderFileName.Width = -2; - } - - private void buttonChooseFolder_Click(object sender, EventArgs e) - { - if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) - { - textBoxOutputFolder.Text = folderBrowserDialog1.SelectedPath; - } - } - - private TextEncoding GetCurrentEncoding() - { - return UiUtil.GetTextEncodingComboBoxCurrentEncoding(comboBoxEncoding); - } - - private void Split_Shown(object sender, EventArgs e) - { - _loading = false; - CalculateParts(); - } - - private void Split_Resize(object sender, EventArgs e) - { - columnHeaderFileName.Width = -2; - } - - private void Split_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void textBoxFileName_TextChanged(object sender, EventArgs e) - { - CalculateParts(); - } - - private void comboBoxSubtitleFormats_SelectedIndexChanged(object sender, EventArgs e) - { - CalculateParts(); - } - - private void buttonOpenOutputFolder_Click(object sender, EventArgs e) - { - if (Directory.Exists(textBoxOutputFolder.Text)) - { - UiUtil.OpenFolder(textBoxOutputFolder.Text); - } - else - { - MessageBox.Show(string.Format(Configuration.Settings.Language.SplitSubtitle.FolderNotFoundX, textBoxOutputFolder.Text)); - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.IO; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class Split : Form + { + private Subtitle _subtitle; + public bool ShowBasic { get; private set; } + private int _totalNumberOfCharacters; + private bool _loading = true; + private List _parts; + private string _fileName; + + public Split() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + var l = Configuration.Settings.Language.Split; + Text = l.Title; + groupBoxSplitOptions.Text = l.SplitOptions; + RadioButtonLines.Text = l.Lines; + radioButtonCharacters.Text = l.Characters; + labelNumberOfParts.Text = l.NumberOfEqualParts; + groupBoxSubtitleInfo.Text = l.SubtitleInfo; + groupBoxOutput.Text = l.Output; + labelFileName.Text = l.FileName; + labelChooseOutputFolder.Text = l.OutputFolder; + labelOutputFormat.Text = Configuration.Settings.Language.Main.Controls.SubtitleFormat; + labelEncoding.Text = Configuration.Settings.Language.Main.Controls.FileEncoding; + groupBoxPreview.Text = Configuration.Settings.Language.General.Preview; + buttonOpenOutputFolder.Text = Configuration.Settings.Language.Main.Menu.File.Open; + + listViewParts.Columns[0].Text = l.Lines; + listViewParts.Columns[1].Text = l.Characters; + listViewParts.Columns[2].Text = l.FileName; + + buttonSplit.Text = l.DoSplit; + buttonBasic.Text = l.Basic; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + + comboBoxSubtitleFormats.Left = labelOutputFormat.Left + labelOutputFormat.Width + 3; + comboBoxEncoding.Left = labelEncoding.Left + labelEncoding.Width + 3; + + UiUtil.FixLargeFonts(this, buttonSplit); + } + + public void Initialize(Subtitle subtitle, string fileName, SubtitleFormat format) + { + ShowBasic = false; + _subtitle = subtitle; + if (string.IsNullOrEmpty(fileName)) + { + textBoxFileName.Text = Configuration.Settings.Language.SplitSubtitle.Untitled; + } + else + { + textBoxFileName.Text = fileName; + } + + _fileName = fileName; + foreach (Paragraph p in _subtitle.Paragraphs) + { + _totalNumberOfCharacters += HtmlUtil.RemoveHtmlTags(p.Text, true).Length; + } + + labelLines.Text = string.Format(Configuration.Settings.Language.Split.NumberOfLinesX, _subtitle.Paragraphs.Count); + labelCharacters.Text = string.Format(Configuration.Settings.Language.Split.NumberOfCharactersX, _totalNumberOfCharacters); + + try + { + numericUpDownParts.Value = Configuration.Settings.Tools.SplitNumberOfParts; + } + catch + { + // ignored + } + + if (Configuration.Settings.Tools.SplitVia.Trim().Equals("lines", StringComparison.OrdinalIgnoreCase)) + { + RadioButtonLines.Checked = true; + } + else + { + radioButtonCharacters.Checked = true; + } + + UiUtil.InitializeSubtitleFormatComboBox(comboBoxSubtitleFormats, format.FriendlyName); + + UiUtil.InitializeTextEncodingComboBox(comboBoxEncoding); + + if (numericUpDownParts.Maximum > _subtitle.Paragraphs.Count) + { + numericUpDownParts.Maximum = (int)Math.Round(_subtitle.Paragraphs.Count / 2.0); + } + + if (!string.IsNullOrEmpty(_fileName)) + { + textBoxOutputFolder.Text = Path.GetDirectoryName(_fileName); + } + else if (string.IsNullOrEmpty(Configuration.Settings.Tools.SplitOutputFolder) || !Directory.Exists(Configuration.Settings.Tools.SplitOutputFolder)) + { + textBoxOutputFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + } + else + { + textBoxOutputFolder.Text = Configuration.Settings.Tools.SplitOutputFolder; + } + } + + private void CalculateParts() + { + if (_loading) + { + return; + } + + _loading = true; + _parts = new List(); + if (string.IsNullOrEmpty(textBoxOutputFolder.Text) || !Directory.Exists(textBoxOutputFolder.Text)) + { + textBoxOutputFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + } + + var format = Utilities.GetSubtitleFormatByFriendlyName(comboBoxSubtitleFormats.SelectedItem.ToString()); + string fileNameNoExt = Path.GetFileNameWithoutExtension(textBoxFileName.Text); + if (string.IsNullOrWhiteSpace(fileNameNoExt)) + { + fileNameNoExt = Configuration.Settings.Language.SplitSubtitle.Untitled; + } + + if (numericUpDownParts.Value == 0) + { + buttonSplit.Enabled = false; + return; + } + + listViewParts.Items.Clear(); + int startNumber = 0; + if (RadioButtonLines.Checked) + { + int partSize = (int)(_subtitle.Paragraphs.Count / numericUpDownParts.Value); + for (int i = 0; i < numericUpDownParts.Value; i++) + { + int noOfLines = partSize; + if (i == numericUpDownParts.Value - 1) + { + noOfLines = (int)(_subtitle.Paragraphs.Count - (numericUpDownParts.Value - 1) * partSize); + } + + var temp = new Subtitle { Header = _subtitle.Header }; + int size = 0; + for (int number = 0; number < noOfLines; number++) + { + Paragraph p = _subtitle.Paragraphs[startNumber + number]; + temp.Paragraphs.Add(new Paragraph(p)); + size += HtmlUtil.RemoveHtmlTags(p.Text, true).Length; + } + startNumber += noOfLines; + _parts.Add(temp); + + var lvi = new ListViewItem($"{noOfLines:#,###,###}"); + lvi.SubItems.Add($"{size:#,###,###}"); + lvi.SubItems.Add(fileNameNoExt + ".Part" + (i + 1) + format.Extension); + listViewParts.Items.Add(lvi); + } + } + else if (radioButtonCharacters.Checked) + { + int partSize = (int)(_totalNumberOfCharacters / numericUpDownParts.Value); + int nextLimit = partSize; + int currentSize = 0; + Subtitle temp = new Subtitle { Header = _subtitle.Header }; + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + Paragraph p = _subtitle.Paragraphs[i]; + int size = HtmlUtil.RemoveHtmlTags(p.Text, true).Length; + if (currentSize + size > nextLimit + 4 && _parts.Count < numericUpDownParts.Value - 1) + { + _parts.Add(temp); + var lvi = new ListViewItem($"{temp.Paragraphs.Count:#,###,###}"); + lvi.SubItems.Add($"{currentSize:#,###,###}"); + lvi.SubItems.Add(fileNameNoExt + ".Part" + _parts.Count + format.Extension); + listViewParts.Items.Add(lvi); + currentSize = size; + temp = new Subtitle { Header = _subtitle.Header }; + temp.Paragraphs.Add(new Paragraph(p)); + } + else + { + currentSize += size; + temp.Paragraphs.Add(new Paragraph(p)); + } + } + _parts.Add(temp); + var lvi2 = new ListViewItem($"{temp.Paragraphs.Count:#,###,###}"); + lvi2.SubItems.Add($"{currentSize:#,###,###}"); + lvi2.SubItems.Add(fileNameNoExt + ".Part" + numericUpDownParts.Value + ".srt"); + listViewParts.Items.Add(lvi2); + } + _loading = false; + } + + private void buttonBasic_Click(object sender, EventArgs e) + { + ShowBasic = true; + DialogResult = DialogResult.Cancel; + } + + private void buttonSplit_Click(object sender, EventArgs e) + { + bool overwrite = false; + var format = Utilities.GetSubtitleFormatByFriendlyName(comboBoxSubtitleFormats.SelectedItem.ToString()); + string fileNameNoExt = Path.GetFileNameWithoutExtension(textBoxFileName.Text); + if (string.IsNullOrWhiteSpace(fileNameNoExt)) + { + fileNameNoExt = Configuration.Settings.Language.SplitSubtitle.Untitled; + } + + int number = 1; + try + { + foreach (Subtitle sub in _parts) + { + string fileName = Path.Combine(textBoxOutputFolder.Text, fileNameNoExt + ".Part" + number + format.Extension); + string allText = sub.ToText(format); + if (File.Exists(fileName) && !overwrite) + { + if (MessageBox.Show(Configuration.Settings.Language.SplitSubtitle.OverwriteExistingFiles, "", MessageBoxButtons.YesNo) == DialogResult.No) + { + return; + } + + overwrite = true; + } + FileUtil.WriteAllText(fileName, allText, GetCurrentEncoding()); + number++; + } + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + return; + } + + Configuration.Settings.Tools.SplitNumberOfParts = (int)numericUpDownParts.Value; + Configuration.Settings.Tools.SplitOutputFolder = textBoxOutputFolder.Text; + if (RadioButtonLines.Checked) + { + Configuration.Settings.Tools.SplitVia = "Lines"; + } + else + { + Configuration.Settings.Tools.SplitVia = "Characters"; + } + + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void numericUpDownParts_ValueChanged(object sender, EventArgs e) + { + CalculateParts(); + } + + private void radioButtonCharacters_CheckedChanged(object sender, EventArgs e) + { + CalculateParts(); + } + + private void RadioButtonLines_CheckedChanged(object sender, EventArgs e) + { + CalculateParts(); + } + + private void textBoxOutputFolder_TextChanged(object sender, EventArgs e) + { + CalculateParts(); + } + + private void Split_ResizeEnd(object sender, EventArgs e) + { + columnHeaderFileName.Width = -2; + } + + private void buttonChooseFolder_Click(object sender, EventArgs e) + { + if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) + { + textBoxOutputFolder.Text = folderBrowserDialog1.SelectedPath; + } + } + + private TextEncoding GetCurrentEncoding() + { + return UiUtil.GetTextEncodingComboBoxCurrentEncoding(comboBoxEncoding); + } + + private void Split_Shown(object sender, EventArgs e) + { + _loading = false; + CalculateParts(); + } + + private void Split_Resize(object sender, EventArgs e) + { + columnHeaderFileName.Width = -2; + } + + private void Split_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void textBoxFileName_TextChanged(object sender, EventArgs e) + { + CalculateParts(); + } + + private void comboBoxSubtitleFormats_SelectedIndexChanged(object sender, EventArgs e) + { + CalculateParts(); + } + + private void buttonOpenOutputFolder_Click(object sender, EventArgs e) + { + if (Directory.Exists(textBoxOutputFolder.Text)) + { + UiUtil.OpenFolder(textBoxOutputFolder.Text); + } + else + { + MessageBox.Show(string.Format(Configuration.Settings.Language.SplitSubtitle.FolderNotFoundX, textBoxOutputFolder.Text)); + } + } + + } +} diff --git a/src/Forms/Split.resx b/src/ui/Forms/Split.resx similarity index 97% rename from src/Forms/Split.resx rename to src/ui/Forms/Split.resx index 913dd0dab..69f943da9 100644 --- a/src/Forms/Split.resx +++ b/src/ui/Forms/Split.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/SplitLongLines.Designer.cs b/src/ui/Forms/SplitLongLines.Designer.cs similarity index 98% rename from src/Forms/SplitLongLines.Designer.cs rename to src/ui/Forms/SplitLongLines.Designer.cs index c028bee8d..1beca80d1 100644 --- a/src/Forms/SplitLongLines.Designer.cs +++ b/src/ui/Forms/SplitLongLines.Designer.cs @@ -1,359 +1,359 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class SplitLongLines - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); - this.listViewFixes = new System.Windows.Forms.ListView(); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.numericUpDownSingleLineMaxCharacters = new System.Windows.Forms.NumericUpDown(); - this.labelLineMaxLength = new System.Windows.Forms.Label(); - this.labelSingleLineMaxLength = new System.Windows.Forms.Label(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.numericUpDownLineMaxCharacters = new System.Windows.Forms.NumericUpDown(); - this.labelMaxSingleLineLengthIs = new System.Windows.Forms.Label(); - this.labelMaxLineLengthIs = new System.Windows.Forms.Label(); - this.comboBoxLineContinuationBegin = new System.Windows.Forms.ComboBox(); - this.labelLineContinuationBeginEnd = new System.Windows.Forms.Label(); - this.comboBoxLineContinuationEnd = new System.Windows.Forms.ComboBox(); - this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBoxLinesFound.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSingleLineMaxCharacters)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownLineMaxCharacters)).BeginInit(); - this.contextMenuStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxLinesFound - // - this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxLinesFound.Controls.Add(this.listViewFixes); - this.groupBoxLinesFound.Location = new System.Drawing.Point(12, 64); - this.groupBoxLinesFound.Name = "groupBoxLinesFound"; - this.groupBoxLinesFound.Size = new System.Drawing.Size(750, 200); - this.groupBoxLinesFound.TabIndex = 4; - this.groupBoxLinesFound.TabStop = false; - this.groupBoxLinesFound.Text = "Lines that will be split"; - // - // listViewFixes - // - this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewFixes.CheckBoxes = true; - this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader4, - this.columnHeader5, - this.columnHeader7}); - this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; - this.listViewFixes.FullRowSelect = true; - this.listViewFixes.HideSelection = false; - this.listViewFixes.Location = new System.Drawing.Point(6, 23); - this.listViewFixes.Name = "listViewFixes"; - this.listViewFixes.Size = new System.Drawing.Size(738, 171); - this.listViewFixes.TabIndex = 0; - this.listViewFixes.UseCompatibleStateImageBehavior = false; - this.listViewFixes.View = System.Windows.Forms.View.Details; - this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged); - // - // columnHeader4 - // - this.columnHeader4.Text = "Apply"; - this.columnHeader4.Width = 45; - // - // columnHeader5 - // - this.columnHeader5.Text = "Line#"; - this.columnHeader5.Width = 122; - // - // columnHeader7 - // - this.columnHeader7.Text = "New text"; - this.columnHeader7.Width = 500; - // - // numericUpDownSingleLineMaxCharacters - // - this.numericUpDownSingleLineMaxCharacters.Location = new System.Drawing.Point(28, 33); - this.numericUpDownSingleLineMaxCharacters.Maximum = new decimal(new int[] { - 200, - 0, - 0, - 0}); - this.numericUpDownSingleLineMaxCharacters.Minimum = new decimal(new int[] { - 10, - 0, - 0, - 0}); - this.numericUpDownSingleLineMaxCharacters.Name = "numericUpDownSingleLineMaxCharacters"; - this.numericUpDownSingleLineMaxCharacters.Size = new System.Drawing.Size(64, 20); - this.numericUpDownSingleLineMaxCharacters.TabIndex = 0; - this.numericUpDownSingleLineMaxCharacters.Value = new decimal(new int[] { - 50, - 0, - 0, - 0}); - this.numericUpDownSingleLineMaxCharacters.ValueChanged += new System.EventHandler(this.NumericUpDownMaxCharactersValueChanged); - // - // labelLineMaxLength - // - this.labelLineMaxLength.AutoSize = true; - this.labelLineMaxLength.Location = new System.Drawing.Point(240, 16); - this.labelLineMaxLength.Name = "labelLineMaxLength"; - this.labelLineMaxLength.Size = new System.Drawing.Size(105, 13); - this.labelLineMaxLength.TabIndex = 43; - this.labelLineMaxLength.Text = "Line maximum length"; - // - // labelSingleLineMaxLength - // - this.labelSingleLineMaxLength.AutoSize = true; - this.labelSingleLineMaxLength.Location = new System.Drawing.Point(25, 16); - this.labelSingleLineMaxLength.Name = "labelSingleLineMaxLength"; - this.labelSingleLineMaxLength.Size = new System.Drawing.Size(133, 13); - this.labelSingleLineMaxLength.TabIndex = 42; - this.labelSingleLineMaxLength.Text = "Single line maximum length"; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(606, 581); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 6; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(687, 581); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 7; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // numericUpDownLineMaxCharacters - // - this.numericUpDownLineMaxCharacters.Location = new System.Drawing.Point(243, 33); - this.numericUpDownLineMaxCharacters.Maximum = new decimal(new int[] { - 200, - 0, - 0, - 0}); - this.numericUpDownLineMaxCharacters.Minimum = new decimal(new int[] { - 10, - 0, - 0, - 0}); - this.numericUpDownLineMaxCharacters.Name = "numericUpDownLineMaxCharacters"; - this.numericUpDownLineMaxCharacters.Size = new System.Drawing.Size(64, 20); - this.numericUpDownLineMaxCharacters.TabIndex = 1; - this.numericUpDownLineMaxCharacters.Value = new decimal(new int[] { - 90, - 0, - 0, - 0}); - this.numericUpDownLineMaxCharacters.ValueChanged += new System.EventHandler(this.NumericUpDownMaxCharactersValueChanged); - // - // labelMaxSingleLineLengthIs - // - this.labelMaxSingleLineLengthIs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelMaxSingleLineLengthIs.AutoSize = true; - this.labelMaxSingleLineLengthIs.Cursor = System.Windows.Forms.Cursors.Hand; - this.labelMaxSingleLineLengthIs.Location = new System.Drawing.Point(9, 579); - this.labelMaxSingleLineLengthIs.Name = "labelMaxSingleLineLengthIs"; - this.labelMaxSingleLineLengthIs.Size = new System.Drawing.Size(133, 13); - this.labelMaxSingleLineLengthIs.TabIndex = 45; - this.labelMaxSingleLineLengthIs.Text = "Single line maximum length"; - this.labelMaxSingleLineLengthIs.Click += new System.EventHandler(this.labelMaxSingleLineLengthIs_Click); - // - // labelMaxLineLengthIs - // - this.labelMaxLineLengthIs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelMaxLineLengthIs.AutoSize = true; - this.labelMaxLineLengthIs.Cursor = System.Windows.Forms.Cursors.Hand; - this.labelMaxLineLengthIs.Location = new System.Drawing.Point(9, 597); - this.labelMaxLineLengthIs.Name = "labelMaxLineLengthIs"; - this.labelMaxLineLengthIs.Size = new System.Drawing.Size(83, 13); - this.labelMaxLineLengthIs.TabIndex = 46; - this.labelMaxLineLengthIs.Text = "Maximum length"; - this.labelMaxLineLengthIs.Click += new System.EventHandler(this.labelMaxLineLengthIs_Click); - // - // comboBoxLineContinuationBegin - // - this.comboBoxLineContinuationBegin.FormattingEnabled = true; - this.comboBoxLineContinuationBegin.Items.AddRange(new object[] { - "", - "- ", - "..."}); - this.comboBoxLineContinuationBegin.Location = new System.Drawing.Point(478, 33); - this.comboBoxLineContinuationBegin.Name = "comboBoxLineContinuationBegin"; - this.comboBoxLineContinuationBegin.Size = new System.Drawing.Size(80, 21); - this.comboBoxLineContinuationBegin.TabIndex = 2; - this.comboBoxLineContinuationBegin.SelectedIndexChanged += new System.EventHandler(this.ContinuationBeginEndChanged); - // - // labelLineContinuationBeginEnd - // - this.labelLineContinuationBeginEnd.AutoSize = true; - this.labelLineContinuationBeginEnd.Location = new System.Drawing.Point(475, 16); - this.labelLineContinuationBeginEnd.Name = "labelLineContinuationBeginEnd"; - this.labelLineContinuationBeginEnd.Size = new System.Drawing.Size(173, 13); - this.labelLineContinuationBeginEnd.TabIndex = 48; - this.labelLineContinuationBeginEnd.Text = "Line continuation begin/end strings"; - // - // comboBoxLineContinuationEnd - // - this.comboBoxLineContinuationEnd.FormattingEnabled = true; - this.comboBoxLineContinuationEnd.Items.AddRange(new object[] { - "", - " -", - "..."}); - this.comboBoxLineContinuationEnd.Location = new System.Drawing.Point(564, 33); - this.comboBoxLineContinuationEnd.Name = "comboBoxLineContinuationEnd"; - this.comboBoxLineContinuationEnd.Size = new System.Drawing.Size(80, 21); - this.comboBoxLineContinuationEnd.TabIndex = 3; - this.comboBoxLineContinuationEnd.SelectedIndexChanged += new System.EventHandler(this.ContinuationBeginEndChanged); - // - // SubtitleListview1 - // - this.SubtitleListview1.AllowColumnReorder = true; - this.SubtitleListview1.AllowDrop = true; - this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.SubtitleListview1.FirstVisibleIndex = -1; - this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.SubtitleListview1.FullRowSelect = true; - this.SubtitleListview1.GridLines = true; - this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.SubtitleListview1.HideSelection = false; - this.SubtitleListview1.Location = new System.Drawing.Point(12, 270); - this.SubtitleListview1.Name = "SubtitleListview1"; - this.SubtitleListview1.OwnerDraw = true; - this.SubtitleListview1.Size = new System.Drawing.Size(750, 301); - this.SubtitleListview1.SubtitleFontBold = false; - this.SubtitleListview1.SubtitleFontName = "Tahoma"; - this.SubtitleListview1.SubtitleFontSize = 8; - this.SubtitleListview1.TabIndex = 5; - this.SubtitleListview1.UseCompatibleStateImageBehavior = false; - this.SubtitleListview1.UseSyntaxColoring = true; - this.SubtitleListview1.View = System.Windows.Forms.View.Details; - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemSelectAll, - this.toolStripMenuItemInverseSelection}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70); - // - // toolStripMenuItemSelectAll - // - this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; - this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemSelectAll.Text = "Select all"; - this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); - // - // toolStripMenuItemInverseSelection - // - this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; - this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(180, 22); - this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; - this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); - // - // SplitLongLines - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(774, 614); - this.Controls.Add(this.comboBoxLineContinuationEnd); - this.Controls.Add(this.labelLineContinuationBeginEnd); - this.Controls.Add(this.comboBoxLineContinuationBegin); - this.Controls.Add(this.labelMaxLineLengthIs); - this.Controls.Add(this.labelMaxSingleLineLengthIs); - this.Controls.Add(this.numericUpDownLineMaxCharacters); - this.Controls.Add(this.groupBoxLinesFound); - this.Controls.Add(this.numericUpDownSingleLineMaxCharacters); - this.Controls.Add(this.labelLineMaxLength); - this.Controls.Add(this.labelSingleLineMaxLength); - this.Controls.Add(this.SubtitleListview1); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.KeyPreview = true; - this.MinimumSize = new System.Drawing.Size(780, 500); - this.Name = "SplitLongLines"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Split long lines"; - this.Shown += new System.EventHandler(this.SplitLongLines_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SplitLongLines_KeyDown); - this.groupBoxLinesFound.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSingleLineMaxCharacters)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownLineMaxCharacters)).EndInit(); - this.contextMenuStrip1.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxLinesFound; - private System.Windows.Forms.ListView listViewFixes; - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeader7; - private System.Windows.Forms.NumericUpDown numericUpDownSingleLineMaxCharacters; - private System.Windows.Forms.Label labelLineMaxLength; - private System.Windows.Forms.Label labelSingleLineMaxLength; - private Controls.SubtitleListView SubtitleListview1; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.NumericUpDown numericUpDownLineMaxCharacters; - private System.Windows.Forms.Label labelMaxSingleLineLengthIs; - private System.Windows.Forms.Label labelMaxLineLengthIs; - private System.Windows.Forms.ComboBox comboBoxLineContinuationBegin; - private System.Windows.Forms.Label labelLineContinuationBeginEnd; - private System.Windows.Forms.ComboBox comboBoxLineContinuationEnd; - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class SplitLongLines + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.groupBoxLinesFound = new System.Windows.Forms.GroupBox(); + this.listViewFixes = new System.Windows.Forms.ListView(); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.numericUpDownSingleLineMaxCharacters = new System.Windows.Forms.NumericUpDown(); + this.labelLineMaxLength = new System.Windows.Forms.Label(); + this.labelSingleLineMaxLength = new System.Windows.Forms.Label(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.numericUpDownLineMaxCharacters = new System.Windows.Forms.NumericUpDown(); + this.labelMaxSingleLineLengthIs = new System.Windows.Forms.Label(); + this.labelMaxLineLengthIs = new System.Windows.Forms.Label(); + this.comboBoxLineContinuationBegin = new System.Windows.Forms.ComboBox(); + this.labelLineContinuationBeginEnd = new System.Windows.Forms.Label(); + this.comboBoxLineContinuationEnd = new System.Windows.Forms.ComboBox(); + this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemInverseSelection = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBoxLinesFound.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSingleLineMaxCharacters)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownLineMaxCharacters)).BeginInit(); + this.contextMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxLinesFound + // + this.groupBoxLinesFound.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxLinesFound.Controls.Add(this.listViewFixes); + this.groupBoxLinesFound.Location = new System.Drawing.Point(12, 64); + this.groupBoxLinesFound.Name = "groupBoxLinesFound"; + this.groupBoxLinesFound.Size = new System.Drawing.Size(750, 200); + this.groupBoxLinesFound.TabIndex = 4; + this.groupBoxLinesFound.TabStop = false; + this.groupBoxLinesFound.Text = "Lines that will be split"; + // + // listViewFixes + // + this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewFixes.CheckBoxes = true; + this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader4, + this.columnHeader5, + this.columnHeader7}); + this.listViewFixes.ContextMenuStrip = this.contextMenuStrip1; + this.listViewFixes.FullRowSelect = true; + this.listViewFixes.HideSelection = false; + this.listViewFixes.Location = new System.Drawing.Point(6, 23); + this.listViewFixes.Name = "listViewFixes"; + this.listViewFixes.Size = new System.Drawing.Size(738, 171); + this.listViewFixes.TabIndex = 0; + this.listViewFixes.UseCompatibleStateImageBehavior = false; + this.listViewFixes.View = System.Windows.Forms.View.Details; + this.listViewFixes.SelectedIndexChanged += new System.EventHandler(this.listViewFixes_SelectedIndexChanged); + // + // columnHeader4 + // + this.columnHeader4.Text = "Apply"; + this.columnHeader4.Width = 45; + // + // columnHeader5 + // + this.columnHeader5.Text = "Line#"; + this.columnHeader5.Width = 122; + // + // columnHeader7 + // + this.columnHeader7.Text = "New text"; + this.columnHeader7.Width = 500; + // + // numericUpDownSingleLineMaxCharacters + // + this.numericUpDownSingleLineMaxCharacters.Location = new System.Drawing.Point(28, 33); + this.numericUpDownSingleLineMaxCharacters.Maximum = new decimal(new int[] { + 200, + 0, + 0, + 0}); + this.numericUpDownSingleLineMaxCharacters.Minimum = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDownSingleLineMaxCharacters.Name = "numericUpDownSingleLineMaxCharacters"; + this.numericUpDownSingleLineMaxCharacters.Size = new System.Drawing.Size(64, 20); + this.numericUpDownSingleLineMaxCharacters.TabIndex = 0; + this.numericUpDownSingleLineMaxCharacters.Value = new decimal(new int[] { + 50, + 0, + 0, + 0}); + this.numericUpDownSingleLineMaxCharacters.ValueChanged += new System.EventHandler(this.NumericUpDownMaxCharactersValueChanged); + // + // labelLineMaxLength + // + this.labelLineMaxLength.AutoSize = true; + this.labelLineMaxLength.Location = new System.Drawing.Point(240, 16); + this.labelLineMaxLength.Name = "labelLineMaxLength"; + this.labelLineMaxLength.Size = new System.Drawing.Size(105, 13); + this.labelLineMaxLength.TabIndex = 43; + this.labelLineMaxLength.Text = "Line maximum length"; + // + // labelSingleLineMaxLength + // + this.labelSingleLineMaxLength.AutoSize = true; + this.labelSingleLineMaxLength.Location = new System.Drawing.Point(25, 16); + this.labelSingleLineMaxLength.Name = "labelSingleLineMaxLength"; + this.labelSingleLineMaxLength.Size = new System.Drawing.Size(133, 13); + this.labelSingleLineMaxLength.TabIndex = 42; + this.labelSingleLineMaxLength.Text = "Single line maximum length"; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(606, 581); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 6; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(687, 581); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 7; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // numericUpDownLineMaxCharacters + // + this.numericUpDownLineMaxCharacters.Location = new System.Drawing.Point(243, 33); + this.numericUpDownLineMaxCharacters.Maximum = new decimal(new int[] { + 200, + 0, + 0, + 0}); + this.numericUpDownLineMaxCharacters.Minimum = new decimal(new int[] { + 10, + 0, + 0, + 0}); + this.numericUpDownLineMaxCharacters.Name = "numericUpDownLineMaxCharacters"; + this.numericUpDownLineMaxCharacters.Size = new System.Drawing.Size(64, 20); + this.numericUpDownLineMaxCharacters.TabIndex = 1; + this.numericUpDownLineMaxCharacters.Value = new decimal(new int[] { + 90, + 0, + 0, + 0}); + this.numericUpDownLineMaxCharacters.ValueChanged += new System.EventHandler(this.NumericUpDownMaxCharactersValueChanged); + // + // labelMaxSingleLineLengthIs + // + this.labelMaxSingleLineLengthIs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelMaxSingleLineLengthIs.AutoSize = true; + this.labelMaxSingleLineLengthIs.Cursor = System.Windows.Forms.Cursors.Hand; + this.labelMaxSingleLineLengthIs.Location = new System.Drawing.Point(9, 579); + this.labelMaxSingleLineLengthIs.Name = "labelMaxSingleLineLengthIs"; + this.labelMaxSingleLineLengthIs.Size = new System.Drawing.Size(133, 13); + this.labelMaxSingleLineLengthIs.TabIndex = 45; + this.labelMaxSingleLineLengthIs.Text = "Single line maximum length"; + this.labelMaxSingleLineLengthIs.Click += new System.EventHandler(this.labelMaxSingleLineLengthIs_Click); + // + // labelMaxLineLengthIs + // + this.labelMaxLineLengthIs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelMaxLineLengthIs.AutoSize = true; + this.labelMaxLineLengthIs.Cursor = System.Windows.Forms.Cursors.Hand; + this.labelMaxLineLengthIs.Location = new System.Drawing.Point(9, 597); + this.labelMaxLineLengthIs.Name = "labelMaxLineLengthIs"; + this.labelMaxLineLengthIs.Size = new System.Drawing.Size(83, 13); + this.labelMaxLineLengthIs.TabIndex = 46; + this.labelMaxLineLengthIs.Text = "Maximum length"; + this.labelMaxLineLengthIs.Click += new System.EventHandler(this.labelMaxLineLengthIs_Click); + // + // comboBoxLineContinuationBegin + // + this.comboBoxLineContinuationBegin.FormattingEnabled = true; + this.comboBoxLineContinuationBegin.Items.AddRange(new object[] { + "", + "- ", + "..."}); + this.comboBoxLineContinuationBegin.Location = new System.Drawing.Point(478, 33); + this.comboBoxLineContinuationBegin.Name = "comboBoxLineContinuationBegin"; + this.comboBoxLineContinuationBegin.Size = new System.Drawing.Size(80, 21); + this.comboBoxLineContinuationBegin.TabIndex = 2; + this.comboBoxLineContinuationBegin.SelectedIndexChanged += new System.EventHandler(this.ContinuationBeginEndChanged); + // + // labelLineContinuationBeginEnd + // + this.labelLineContinuationBeginEnd.AutoSize = true; + this.labelLineContinuationBeginEnd.Location = new System.Drawing.Point(475, 16); + this.labelLineContinuationBeginEnd.Name = "labelLineContinuationBeginEnd"; + this.labelLineContinuationBeginEnd.Size = new System.Drawing.Size(173, 13); + this.labelLineContinuationBeginEnd.TabIndex = 48; + this.labelLineContinuationBeginEnd.Text = "Line continuation begin/end strings"; + // + // comboBoxLineContinuationEnd + // + this.comboBoxLineContinuationEnd.FormattingEnabled = true; + this.comboBoxLineContinuationEnd.Items.AddRange(new object[] { + "", + " -", + "..."}); + this.comboBoxLineContinuationEnd.Location = new System.Drawing.Point(564, 33); + this.comboBoxLineContinuationEnd.Name = "comboBoxLineContinuationEnd"; + this.comboBoxLineContinuationEnd.Size = new System.Drawing.Size(80, 21); + this.comboBoxLineContinuationEnd.TabIndex = 3; + this.comboBoxLineContinuationEnd.SelectedIndexChanged += new System.EventHandler(this.ContinuationBeginEndChanged); + // + // SubtitleListview1 + // + this.SubtitleListview1.AllowColumnReorder = true; + this.SubtitleListview1.AllowDrop = true; + this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.SubtitleListview1.FirstVisibleIndex = -1; + this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SubtitleListview1.FullRowSelect = true; + this.SubtitleListview1.GridLines = true; + this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.SubtitleListview1.HideSelection = false; + this.SubtitleListview1.Location = new System.Drawing.Point(12, 270); + this.SubtitleListview1.Name = "SubtitleListview1"; + this.SubtitleListview1.OwnerDraw = true; + this.SubtitleListview1.Size = new System.Drawing.Size(750, 301); + this.SubtitleListview1.SubtitleFontBold = false; + this.SubtitleListview1.SubtitleFontName = "Tahoma"; + this.SubtitleListview1.SubtitleFontSize = 8; + this.SubtitleListview1.TabIndex = 5; + this.SubtitleListview1.UseCompatibleStateImageBehavior = false; + this.SubtitleListview1.UseSyntaxColoring = true; + this.SubtitleListview1.View = System.Windows.Forms.View.Details; + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemSelectAll, + this.toolStripMenuItemInverseSelection}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70); + // + // toolStripMenuItemSelectAll + // + this.toolStripMenuItemSelectAll.Name = "toolStripMenuItemSelectAll"; + this.toolStripMenuItemSelectAll.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemSelectAll.Text = "Select all"; + this.toolStripMenuItemSelectAll.Click += new System.EventHandler(this.toolStripMenuItemSelectAll_Click); + // + // toolStripMenuItemInverseSelection + // + this.toolStripMenuItemInverseSelection.Name = "toolStripMenuItemInverseSelection"; + this.toolStripMenuItemInverseSelection.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItemInverseSelection.Text = "Inverse selection"; + this.toolStripMenuItemInverseSelection.Click += new System.EventHandler(this.toolStripMenuItemInverseSelection_Click); + // + // SplitLongLines + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(774, 614); + this.Controls.Add(this.comboBoxLineContinuationEnd); + this.Controls.Add(this.labelLineContinuationBeginEnd); + this.Controls.Add(this.comboBoxLineContinuationBegin); + this.Controls.Add(this.labelMaxLineLengthIs); + this.Controls.Add(this.labelMaxSingleLineLengthIs); + this.Controls.Add(this.numericUpDownLineMaxCharacters); + this.Controls.Add(this.groupBoxLinesFound); + this.Controls.Add(this.numericUpDownSingleLineMaxCharacters); + this.Controls.Add(this.labelLineMaxLength); + this.Controls.Add(this.labelSingleLineMaxLength); + this.Controls.Add(this.SubtitleListview1); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.KeyPreview = true; + this.MinimumSize = new System.Drawing.Size(780, 500); + this.Name = "SplitLongLines"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Split long lines"; + this.Shown += new System.EventHandler(this.SplitLongLines_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SplitLongLines_KeyDown); + this.groupBoxLinesFound.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSingleLineMaxCharacters)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownLineMaxCharacters)).EndInit(); + this.contextMenuStrip1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxLinesFound; + private System.Windows.Forms.ListView listViewFixes; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.NumericUpDown numericUpDownSingleLineMaxCharacters; + private System.Windows.Forms.Label labelLineMaxLength; + private System.Windows.Forms.Label labelSingleLineMaxLength; + private Controls.SubtitleListView SubtitleListview1; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.NumericUpDown numericUpDownLineMaxCharacters; + private System.Windows.Forms.Label labelMaxSingleLineLengthIs; + private System.Windows.Forms.Label labelMaxLineLengthIs; + private System.Windows.Forms.ComboBox comboBoxLineContinuationBegin; + private System.Windows.Forms.Label labelLineContinuationBeginEnd; + private System.Windows.Forms.ComboBox comboBoxLineContinuationEnd; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectAll; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInverseSelection; + } } \ No newline at end of file diff --git a/src/Forms/SplitLongLines.cs b/src/ui/Forms/SplitLongLines.cs similarity index 97% rename from src/Forms/SplitLongLines.cs rename to src/ui/Forms/SplitLongLines.cs index 5f43064c6..b3834579a 100644 --- a/src/Forms/SplitLongLines.cs +++ b/src/ui/Forms/SplitLongLines.cs @@ -1,424 +1,424 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Forms; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class SplitLongLines : PositionAndSizeForm - { - private Subtitle _subtitle; - - public int NumberOfSplits { get; private set; } - - public Subtitle SplitSubtitle { get; private set; } - - public SplitLongLines() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void SplitLongLines_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - public void Initialize(Subtitle subtitle) - { - if (subtitle.Paragraphs.Count > 0) - { - subtitle.Renumber(subtitle.Paragraphs[0].Number); - } - - Text = Configuration.Settings.Language.SplitLongLines.Title; - labelSingleLineMaxLength.Text = Configuration.Settings.Language.SplitLongLines.SingleLineMaximumLength; - labelLineMaxLength.Text = Configuration.Settings.Language.SplitLongLines.LineMaximumLength; - labelLineContinuationBeginEnd.Text = Configuration.Settings.Language.SplitLongLines.LineContinuationBeginEndStrings; - - listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; - listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; - listViewFixes.Columns[2].Text = Configuration.Settings.Language.General.Text; - - var continuationProfile = ContinuationUtilities.GetContinuationProfile(Configuration.Settings.General.ContinuationStyle); - comboBoxLineContinuationBegin.Text = continuationProfile.Prefix; - comboBoxLineContinuationEnd.Text = continuationProfile.Suffix; - - toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; - toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - SubtitleListview1.AutoSizeAllColumns(this); - NumberOfSplits = 0; - numericUpDownSingleLineMaxCharacters.Value = Configuration.Settings.General.SubtitleLineMaximumLength; - _subtitle = subtitle; - } - - private void AddToListView(Paragraph p, string lineNumbers, string newText) - { - var item = new ListViewItem(string.Empty) { Tag = p, Checked = true }; - item.SubItems.Add(lineNumbers); - item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); - listViewFixes.Items.Add(item); - } - - private void listViewFixes_ItemChecked(object sender, ItemCheckedEventArgs e) - { - GeneratePreview(false); - } - - private void GeneratePreview(bool clearFixes) - { - if (_subtitle == null) - { - return; - } - - var splitIndexes = new List(); - var autoBreakIndexes = new List(); - - NumberOfSplits = 0; - SubtitleListview1.Items.Clear(); - SubtitleListview1.BeginUpdate(); - SplitSubtitle = SplitLongLinesInSubtitle(_subtitle, splitIndexes, autoBreakIndexes, out var count, (int)numericUpDownLineMaxCharacters.Value, (int)numericUpDownSingleLineMaxCharacters.Value, clearFixes); - NumberOfSplits = count; - - SubtitleListview1.Fill(SplitSubtitle); - - foreach (var index in splitIndexes) - { - SubtitleListview1.SetBackgroundColor(index, Color.Green); - } - - foreach (var index in autoBreakIndexes) - { - SubtitleListview1.SetBackgroundColor(index, Color.LightGreen); - } - - SubtitleListview1.EndUpdate(); - groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.SplitLongLines.NumberOfSplits, NumberOfSplits); - UpdateLongestLinesInfo(SplitSubtitle); - } - - private void UpdateLongestLinesInfo(Subtitle subtitle) - { - int maxLength = -1; - int maxLengthIndex = -1; - int singleLineMaxLength = -1; - int singleLineMaxLengthIndex = -1; - int i = 0; - foreach (var p in subtitle.Paragraphs) - { - string s = HtmlUtil.RemoveHtmlTags(p.Text, true); - if (s.Length > maxLength) - { - maxLength = s.Length; - maxLengthIndex = i; - } - var arr = s.SplitToLines(); - foreach (string line in arr) - { - if (line.Length > singleLineMaxLengthIndex) - { - singleLineMaxLength = line.Length; - singleLineMaxLengthIndex = i; - } - } - i++; - } - labelMaxSingleLineLengthIs.Text = string.Format(Configuration.Settings.Language.SplitLongLines.LongestSingleLineIsXAtY, singleLineMaxLength, singleLineMaxLengthIndex + 1); - labelMaxSingleLineLengthIs.Tag = singleLineMaxLengthIndex.ToString(CultureInfo.InvariantCulture); - labelMaxLineLengthIs.Text = string.Format(Configuration.Settings.Language.SplitLongLines.LongestLineIsXAtY, maxLength, maxLengthIndex + 1); - labelMaxLineLengthIs.Tag = maxLengthIndex.ToString(CultureInfo.InvariantCulture); - } - - private bool IsFixAllowed(Paragraph p) - { - foreach (ListViewItem item in listViewFixes.Items) - { - if (item.Tag as Paragraph == p) - { - return item.Checked; - } - } - return true; - } - - public Subtitle SplitLongLinesInSubtitle(Subtitle subtitle, List splitIndexes, List autoBreakIndexes, out int numberOfSplits, int totalLineMaxCharacters, int singleLineMaxCharacters, bool clearFixes) - { - listViewFixes.ItemChecked -= listViewFixes_ItemChecked; - if (clearFixes) - { - listViewFixes.Items.Clear(); - } - - numberOfSplits = 0; - string language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); - var splitSubtitle = new Subtitle(); - string[] expectedPunctuations = { ". -", "! -", "? -" }; - for (int i = 0; i < subtitle.Paragraphs.Count; i++) - { - bool added = false; - var p = subtitle.Paragraphs[i]; - if (p?.Text != null) - { - if (SplitLongLinesHelper.QualifiesForSplit(p.Text, singleLineMaxCharacters, totalLineMaxCharacters) && IsFixAllowed(p)) - { - string oldText = HtmlUtil.RemoveHtmlTags(p.Text); - bool isDialog = false; - string dialogText = string.Empty; - if (p.Text.Contains('-')) - { - dialogText = Utilities.AutoBreakLine(p.Text, 5, 1, language); - - var tempText = p.Text.Replace(Environment.NewLine, " ").Replace(" ", " "); - if (Utilities.CountTagInText(tempText, '-') == 2 && (p.Text.StartsWith('-') || p.Text.StartsWith("-", StringComparison.Ordinal))) - { - int idx = tempText.IndexOfAny(expectedPunctuations, StringComparison.Ordinal); - if (idx > 1) - { - dialogText = tempText.Remove(idx + 1, 1).Insert(idx + 1, Environment.NewLine); - } - } - - var dialogHelper = new DialogSplitMerge(); - if (dialogHelper.IsDialog(dialogText.SplitToLines())) - { - isDialog = true; - } - } - - if (!isDialog && !SplitLongLinesHelper.QualifiesForSplit(Utilities.AutoBreakLine(p.Text, language), singleLineMaxCharacters, totalLineMaxCharacters)) - { - var newParagraph = new Paragraph(p) { Text = Utilities.AutoBreakLine(p.Text, language) }; - if (clearFixes) - { - AddToListView(p, (splitSubtitle.Paragraphs.Count + 1).ToString(CultureInfo.InvariantCulture), oldText); - } - - autoBreakIndexes.Add(splitSubtitle.Paragraphs.Count); - splitSubtitle.Paragraphs.Add(newParagraph); - added = true; - numberOfSplits++; - } - else - { - string text = Utilities.AutoBreakLine(p.Text, language); - if (isDialog) - { - text = dialogText; - } - - if (isDialog || text.Contains(Environment.NewLine)) - { - var arr = text.SplitToLines(); - if (arr.Count == 2) - { - int spacing1 = Configuration.Settings.General.MinimumMillisecondsBetweenLines / 2; - int spacing2 = Configuration.Settings.General.MinimumMillisecondsBetweenLines / 2; - if (Configuration.Settings.General.MinimumMillisecondsBetweenLines % 2 == 1) - { - spacing2++; - } - - var newParagraph1 = new Paragraph(p); - var newParagraph2 = new Paragraph(p); - newParagraph1.Text = Utilities.AutoBreakLine(arr[0], language); - - double middle = p.StartTime.TotalMilliseconds + p.Duration.TotalMilliseconds / 2; - if (!string.IsNullOrWhiteSpace(oldText)) - { - var startFactor = (double)HtmlUtil.RemoveHtmlTags(newParagraph1.Text).Length / oldText.Length; - if (startFactor < 0.25) - { - startFactor = 0.25; - } - - if (startFactor > 0.75) - { - startFactor = 0.75; - } - - middle = p.StartTime.TotalMilliseconds + p.Duration.TotalMilliseconds * startFactor; - } - - newParagraph1.EndTime.TotalMilliseconds = middle - spacing1; - newParagraph2.Text = Utilities.AutoBreakLine(arr[1], language); - newParagraph2.StartTime.TotalMilliseconds = newParagraph1.EndTime.TotalMilliseconds + spacing2; - - if (Configuration.Settings.General.SplitRemovesDashes && isDialog) - { - newParagraph1.Text = DialogSplitMerge.RemoveStartDash(newParagraph1.Text); - newParagraph2.Text = DialogSplitMerge.RemoveStartDash(newParagraph2.Text); - } - - if (clearFixes) - { - AddToListView(p, (splitSubtitle.Paragraphs.Count + 1).ToString(CultureInfo.InvariantCulture), oldText); - } - - splitIndexes.Add(splitSubtitle.Paragraphs.Count); - splitIndexes.Add(splitSubtitle.Paragraphs.Count + 1); - - string p1 = HtmlUtil.RemoveHtmlTags(newParagraph1.Text).TrimEnd(); - if (!p1.EndsWith('.') && !p1.EndsWith('!') && !p1.EndsWith('?') && !p1.EndsWith(':') && !p1.EndsWith(')') && !p1.EndsWith(']') && !p1.EndsWith('♪')) - { - bool endsWithComma = newParagraph1.Text.EndsWith(',') || newParagraph1.Text.EndsWith(",", StringComparison.Ordinal); - - string post = string.Empty; - if (newParagraph1.Text.EndsWith("", StringComparison.Ordinal)) - { - post = ""; - newParagraph1.Text = newParagraph1.Text.Remove(newParagraph1.Text.Length - post.Length); - } - - if (endsWithComma) - { - newParagraph1.Text += post; - } - else - { - newParagraph1.Text += comboBoxLineContinuationEnd.Text.TrimEnd() + post; - } - - string pre = string.Empty; - if (newParagraph2.Text.StartsWith("", StringComparison.Ordinal)) - { - pre = ""; - newParagraph2.Text = newParagraph2.Text.Remove(0, pre.Length); - } - - if (endsWithComma) - { - newParagraph2.Text = pre + newParagraph2.Text; - } - else - { - newParagraph2.Text = pre + comboBoxLineContinuationBegin.Text + newParagraph2.Text; - } - } - - var italicStart1 = newParagraph1.Text.IndexOf("", StringComparison.Ordinal); - if (italicStart1 >= 0 && italicStart1 < 10 && newParagraph1.Text.IndexOf("", StringComparison.Ordinal) < 0 && - newParagraph2.Text.Contains("") && newParagraph2.Text.IndexOf("", StringComparison.Ordinal) < 0) - { - newParagraph1.Text += ""; - newParagraph2.Text = "" + newParagraph2.Text; - } - - splitSubtitle.Paragraphs.Add(newParagraph1); - splitSubtitle.Paragraphs.Add(newParagraph2); - added = true; - numberOfSplits++; - } - } - } - } - if (!added) - { - splitSubtitle.Paragraphs.Add(new Paragraph(p)); - } - } - } - listViewFixes.ItemChecked += listViewFixes_ItemChecked; - splitSubtitle.Renumber(); - return splitSubtitle; - } - - private void NumericUpDownMaxCharactersValueChanged(object sender, EventArgs e) - { - Cursor = Cursors.WaitCursor; - GeneratePreview(true); - Cursor = Cursors.Default; - } - - private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e) - { - if (listViewFixes.SelectedIndices.Count > 0) - { - int index = listViewFixes.SelectedIndices[0]; - ListViewItem item = listViewFixes.Items[index]; - index = int.Parse(item.SubItems[1].Text) - 1; - SubtitleListview1.SelectIndexAndEnsureVisible(index); - } - } - - private void SplitLongLines_Shown(object sender, EventArgs e) - { - GeneratePreview(true); - listViewFixes.Focus(); - if (listViewFixes.Items.Count > 0) - { - listViewFixes.Items[0].Selected = true; - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void labelMaxSingleLineLengthIs_Click(object sender, EventArgs e) - { - int index = int.Parse(labelMaxSingleLineLengthIs.Tag.ToString()); - SubtitleListview1.SelectIndexAndEnsureVisible(index); - } - - private void labelMaxLineLengthIs_Click(object sender, EventArgs e) - { - int index = int.Parse(labelMaxLineLengthIs.Tag.ToString()); - SubtitleListview1.SelectIndexAndEnsureVisible(index); - } - - private void ContinuationBeginEndChanged(object sender, EventArgs e) - { - Cursor = Cursors.WaitCursor; - if (listViewFixes.SelectedItems.Count > 0) - { - var index = listViewFixes.SelectedItems[0].Index; - listViewFixes.Items[index].Selected = true; - } - GeneratePreview(true); - Cursor = Cursors.Default; - } - - private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) - { - listViewFixes.ItemChecked -= listViewFixes_ItemChecked; - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = true; - } - listViewFixes.ItemChecked += listViewFixes_ItemChecked; - GeneratePreview(false); - } - - private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) - { - listViewFixes.ItemChecked -= listViewFixes_ItemChecked; - foreach (ListViewItem item in listViewFixes.Items) - { - item.Checked = !item.Checked; - } - listViewFixes.ItemChecked += listViewFixes_ItemChecked; - GeneratePreview(false); - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Forms; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class SplitLongLines : PositionAndSizeForm + { + private Subtitle _subtitle; + + public int NumberOfSplits { get; private set; } + + public Subtitle SplitSubtitle { get; private set; } + + public SplitLongLines() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void SplitLongLines_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + public void Initialize(Subtitle subtitle) + { + if (subtitle.Paragraphs.Count > 0) + { + subtitle.Renumber(subtitle.Paragraphs[0].Number); + } + + Text = Configuration.Settings.Language.SplitLongLines.Title; + labelSingleLineMaxLength.Text = Configuration.Settings.Language.SplitLongLines.SingleLineMaximumLength; + labelLineMaxLength.Text = Configuration.Settings.Language.SplitLongLines.LineMaximumLength; + labelLineContinuationBeginEnd.Text = Configuration.Settings.Language.SplitLongLines.LineContinuationBeginEndStrings; + + listViewFixes.Columns[0].Text = Configuration.Settings.Language.General.Apply; + listViewFixes.Columns[1].Text = Configuration.Settings.Language.General.LineNumber; + listViewFixes.Columns[2].Text = Configuration.Settings.Language.General.Text; + + var continuationProfile = ContinuationUtilities.GetContinuationProfile(Configuration.Settings.General.ContinuationStyle); + comboBoxLineContinuationBegin.Text = continuationProfile.Prefix; + comboBoxLineContinuationEnd.Text = continuationProfile.Suffix; + + toolStripMenuItemInverseSelection.Text = Configuration.Settings.Language.Main.Menu.Edit.InverseSelection; + toolStripMenuItemSelectAll.Text = Configuration.Settings.Language.Main.Menu.ContextMenu.SelectAll; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + SubtitleListview1.AutoSizeAllColumns(this); + NumberOfSplits = 0; + numericUpDownSingleLineMaxCharacters.Value = Configuration.Settings.General.SubtitleLineMaximumLength; + _subtitle = subtitle; + } + + private void AddToListView(Paragraph p, string lineNumbers, string newText) + { + var item = new ListViewItem(string.Empty) { Tag = p, Checked = true }; + item.SubItems.Add(lineNumbers); + item.SubItems.Add(UiUtil.GetListViewTextFromString(newText)); + listViewFixes.Items.Add(item); + } + + private void listViewFixes_ItemChecked(object sender, ItemCheckedEventArgs e) + { + GeneratePreview(false); + } + + private void GeneratePreview(bool clearFixes) + { + if (_subtitle == null) + { + return; + } + + var splitIndexes = new List(); + var autoBreakIndexes = new List(); + + NumberOfSplits = 0; + SubtitleListview1.Items.Clear(); + SubtitleListview1.BeginUpdate(); + SplitSubtitle = SplitLongLinesInSubtitle(_subtitle, splitIndexes, autoBreakIndexes, out var count, (int)numericUpDownLineMaxCharacters.Value, (int)numericUpDownSingleLineMaxCharacters.Value, clearFixes); + NumberOfSplits = count; + + SubtitleListview1.Fill(SplitSubtitle); + + foreach (var index in splitIndexes) + { + SubtitleListview1.SetBackgroundColor(index, Color.Green); + } + + foreach (var index in autoBreakIndexes) + { + SubtitleListview1.SetBackgroundColor(index, Color.LightGreen); + } + + SubtitleListview1.EndUpdate(); + groupBoxLinesFound.Text = string.Format(Configuration.Settings.Language.SplitLongLines.NumberOfSplits, NumberOfSplits); + UpdateLongestLinesInfo(SplitSubtitle); + } + + private void UpdateLongestLinesInfo(Subtitle subtitle) + { + int maxLength = -1; + int maxLengthIndex = -1; + int singleLineMaxLength = -1; + int singleLineMaxLengthIndex = -1; + int i = 0; + foreach (var p in subtitle.Paragraphs) + { + string s = HtmlUtil.RemoveHtmlTags(p.Text, true); + if (s.Length > maxLength) + { + maxLength = s.Length; + maxLengthIndex = i; + } + var arr = s.SplitToLines(); + foreach (string line in arr) + { + if (line.Length > singleLineMaxLengthIndex) + { + singleLineMaxLength = line.Length; + singleLineMaxLengthIndex = i; + } + } + i++; + } + labelMaxSingleLineLengthIs.Text = string.Format(Configuration.Settings.Language.SplitLongLines.LongestSingleLineIsXAtY, singleLineMaxLength, singleLineMaxLengthIndex + 1); + labelMaxSingleLineLengthIs.Tag = singleLineMaxLengthIndex.ToString(CultureInfo.InvariantCulture); + labelMaxLineLengthIs.Text = string.Format(Configuration.Settings.Language.SplitLongLines.LongestLineIsXAtY, maxLength, maxLengthIndex + 1); + labelMaxLineLengthIs.Tag = maxLengthIndex.ToString(CultureInfo.InvariantCulture); + } + + private bool IsFixAllowed(Paragraph p) + { + foreach (ListViewItem item in listViewFixes.Items) + { + if (item.Tag as Paragraph == p) + { + return item.Checked; + } + } + return true; + } + + public Subtitle SplitLongLinesInSubtitle(Subtitle subtitle, List splitIndexes, List autoBreakIndexes, out int numberOfSplits, int totalLineMaxCharacters, int singleLineMaxCharacters, bool clearFixes) + { + listViewFixes.ItemChecked -= listViewFixes_ItemChecked; + if (clearFixes) + { + listViewFixes.Items.Clear(); + } + + numberOfSplits = 0; + string language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle); + var splitSubtitle = new Subtitle(); + string[] expectedPunctuations = { ". -", "! -", "? -" }; + for (int i = 0; i < subtitle.Paragraphs.Count; i++) + { + bool added = false; + var p = subtitle.Paragraphs[i]; + if (p?.Text != null) + { + if (SplitLongLinesHelper.QualifiesForSplit(p.Text, singleLineMaxCharacters, totalLineMaxCharacters) && IsFixAllowed(p)) + { + string oldText = HtmlUtil.RemoveHtmlTags(p.Text); + bool isDialog = false; + string dialogText = string.Empty; + if (p.Text.Contains('-')) + { + dialogText = Utilities.AutoBreakLine(p.Text, 5, 1, language); + + var tempText = p.Text.Replace(Environment.NewLine, " ").Replace(" ", " "); + if (Utilities.CountTagInText(tempText, '-') == 2 && (p.Text.StartsWith('-') || p.Text.StartsWith("-", StringComparison.Ordinal))) + { + int idx = tempText.IndexOfAny(expectedPunctuations, StringComparison.Ordinal); + if (idx > 1) + { + dialogText = tempText.Remove(idx + 1, 1).Insert(idx + 1, Environment.NewLine); + } + } + + var dialogHelper = new DialogSplitMerge(); + if (dialogHelper.IsDialog(dialogText.SplitToLines())) + { + isDialog = true; + } + } + + if (!isDialog && !SplitLongLinesHelper.QualifiesForSplit(Utilities.AutoBreakLine(p.Text, language), singleLineMaxCharacters, totalLineMaxCharacters)) + { + var newParagraph = new Paragraph(p) { Text = Utilities.AutoBreakLine(p.Text, language) }; + if (clearFixes) + { + AddToListView(p, (splitSubtitle.Paragraphs.Count + 1).ToString(CultureInfo.InvariantCulture), oldText); + } + + autoBreakIndexes.Add(splitSubtitle.Paragraphs.Count); + splitSubtitle.Paragraphs.Add(newParagraph); + added = true; + numberOfSplits++; + } + else + { + string text = Utilities.AutoBreakLine(p.Text, language); + if (isDialog) + { + text = dialogText; + } + + if (isDialog || text.Contains(Environment.NewLine)) + { + var arr = text.SplitToLines(); + if (arr.Count == 2) + { + int spacing1 = Configuration.Settings.General.MinimumMillisecondsBetweenLines / 2; + int spacing2 = Configuration.Settings.General.MinimumMillisecondsBetweenLines / 2; + if (Configuration.Settings.General.MinimumMillisecondsBetweenLines % 2 == 1) + { + spacing2++; + } + + var newParagraph1 = new Paragraph(p); + var newParagraph2 = new Paragraph(p); + newParagraph1.Text = Utilities.AutoBreakLine(arr[0], language); + + double middle = p.StartTime.TotalMilliseconds + p.Duration.TotalMilliseconds / 2; + if (!string.IsNullOrWhiteSpace(oldText)) + { + var startFactor = (double)HtmlUtil.RemoveHtmlTags(newParagraph1.Text).Length / oldText.Length; + if (startFactor < 0.25) + { + startFactor = 0.25; + } + + if (startFactor > 0.75) + { + startFactor = 0.75; + } + + middle = p.StartTime.TotalMilliseconds + p.Duration.TotalMilliseconds * startFactor; + } + + newParagraph1.EndTime.TotalMilliseconds = middle - spacing1; + newParagraph2.Text = Utilities.AutoBreakLine(arr[1], language); + newParagraph2.StartTime.TotalMilliseconds = newParagraph1.EndTime.TotalMilliseconds + spacing2; + + if (Configuration.Settings.General.SplitRemovesDashes && isDialog) + { + newParagraph1.Text = DialogSplitMerge.RemoveStartDash(newParagraph1.Text); + newParagraph2.Text = DialogSplitMerge.RemoveStartDash(newParagraph2.Text); + } + + if (clearFixes) + { + AddToListView(p, (splitSubtitle.Paragraphs.Count + 1).ToString(CultureInfo.InvariantCulture), oldText); + } + + splitIndexes.Add(splitSubtitle.Paragraphs.Count); + splitIndexes.Add(splitSubtitle.Paragraphs.Count + 1); + + string p1 = HtmlUtil.RemoveHtmlTags(newParagraph1.Text).TrimEnd(); + if (!p1.EndsWith('.') && !p1.EndsWith('!') && !p1.EndsWith('?') && !p1.EndsWith(':') && !p1.EndsWith(')') && !p1.EndsWith(']') && !p1.EndsWith('♪')) + { + bool endsWithComma = newParagraph1.Text.EndsWith(',') || newParagraph1.Text.EndsWith(",", StringComparison.Ordinal); + + string post = string.Empty; + if (newParagraph1.Text.EndsWith("", StringComparison.Ordinal)) + { + post = ""; + newParagraph1.Text = newParagraph1.Text.Remove(newParagraph1.Text.Length - post.Length); + } + + if (endsWithComma) + { + newParagraph1.Text += post; + } + else + { + newParagraph1.Text += comboBoxLineContinuationEnd.Text.TrimEnd() + post; + } + + string pre = string.Empty; + if (newParagraph2.Text.StartsWith("", StringComparison.Ordinal)) + { + pre = ""; + newParagraph2.Text = newParagraph2.Text.Remove(0, pre.Length); + } + + if (endsWithComma) + { + newParagraph2.Text = pre + newParagraph2.Text; + } + else + { + newParagraph2.Text = pre + comboBoxLineContinuationBegin.Text + newParagraph2.Text; + } + } + + var italicStart1 = newParagraph1.Text.IndexOf("", StringComparison.Ordinal); + if (italicStart1 >= 0 && italicStart1 < 10 && newParagraph1.Text.IndexOf("", StringComparison.Ordinal) < 0 && + newParagraph2.Text.Contains("") && newParagraph2.Text.IndexOf("", StringComparison.Ordinal) < 0) + { + newParagraph1.Text += ""; + newParagraph2.Text = "" + newParagraph2.Text; + } + + splitSubtitle.Paragraphs.Add(newParagraph1); + splitSubtitle.Paragraphs.Add(newParagraph2); + added = true; + numberOfSplits++; + } + } + } + } + if (!added) + { + splitSubtitle.Paragraphs.Add(new Paragraph(p)); + } + } + } + listViewFixes.ItemChecked += listViewFixes_ItemChecked; + splitSubtitle.Renumber(); + return splitSubtitle; + } + + private void NumericUpDownMaxCharactersValueChanged(object sender, EventArgs e) + { + Cursor = Cursors.WaitCursor; + GeneratePreview(true); + Cursor = Cursors.Default; + } + + private void listViewFixes_SelectedIndexChanged(object sender, EventArgs e) + { + if (listViewFixes.SelectedIndices.Count > 0) + { + int index = listViewFixes.SelectedIndices[0]; + ListViewItem item = listViewFixes.Items[index]; + index = int.Parse(item.SubItems[1].Text) - 1; + SubtitleListview1.SelectIndexAndEnsureVisible(index); + } + } + + private void SplitLongLines_Shown(object sender, EventArgs e) + { + GeneratePreview(true); + listViewFixes.Focus(); + if (listViewFixes.Items.Count > 0) + { + listViewFixes.Items[0].Selected = true; + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void labelMaxSingleLineLengthIs_Click(object sender, EventArgs e) + { + int index = int.Parse(labelMaxSingleLineLengthIs.Tag.ToString()); + SubtitleListview1.SelectIndexAndEnsureVisible(index); + } + + private void labelMaxLineLengthIs_Click(object sender, EventArgs e) + { + int index = int.Parse(labelMaxLineLengthIs.Tag.ToString()); + SubtitleListview1.SelectIndexAndEnsureVisible(index); + } + + private void ContinuationBeginEndChanged(object sender, EventArgs e) + { + Cursor = Cursors.WaitCursor; + if (listViewFixes.SelectedItems.Count > 0) + { + var index = listViewFixes.SelectedItems[0].Index; + listViewFixes.Items[index].Selected = true; + } + GeneratePreview(true); + Cursor = Cursors.Default; + } + + private void toolStripMenuItemSelectAll_Click(object sender, EventArgs e) + { + listViewFixes.ItemChecked -= listViewFixes_ItemChecked; + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = true; + } + listViewFixes.ItemChecked += listViewFixes_ItemChecked; + GeneratePreview(false); + } + + private void toolStripMenuItemInverseSelection_Click(object sender, EventArgs e) + { + listViewFixes.ItemChecked -= listViewFixes_ItemChecked; + foreach (ListViewItem item in listViewFixes.Items) + { + item.Checked = !item.Checked; + } + listViewFixes.ItemChecked += listViewFixes_ItemChecked; + GeneratePreview(false); + } + } +} diff --git a/src/Forms/SplitLongLines.resx b/src/ui/Forms/SplitLongLines.resx similarity index 97% rename from src/Forms/SplitLongLines.resx rename to src/ui/Forms/SplitLongLines.resx index 661dc1126..ad537526f 100644 --- a/src/Forms/SplitLongLines.resx +++ b/src/ui/Forms/SplitLongLines.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/SplitSubtitle.Designer.cs b/src/ui/Forms/SplitSubtitle.Designer.cs similarity index 97% rename from src/Forms/SplitSubtitle.Designer.cs rename to src/ui/Forms/SplitSubtitle.Designer.cs index a01d6ed37..a88e3454f 100644 --- a/src/Forms/SplitSubtitle.Designer.cs +++ b/src/ui/Forms/SplitSubtitle.Designer.cs @@ -1,181 +1,181 @@ -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class SplitSubtitle - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - TimeCode timeCode1 = new TimeCode(); - this.buttonGetFrameRate = new System.Windows.Forms.Button(); - this.buttonDone = new System.Windows.Forms.Button(); - this.buttonSplit = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.labelHourMinSecMilliSecond = new System.Windows.Forms.Label(); - this.splitTimeUpDownAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.buttonAdvanced = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // buttonGetFrameRate - // - this.buttonGetFrameRate.Location = new System.Drawing.Point(137, 69); - this.buttonGetFrameRate.Name = "buttonGetFrameRate"; - this.buttonGetFrameRate.Size = new System.Drawing.Size(25, 23); - this.buttonGetFrameRate.TabIndex = 8; - this.buttonGetFrameRate.Text = "..."; - this.buttonGetFrameRate.UseVisualStyleBackColor = true; - this.buttonGetFrameRate.Click += new System.EventHandler(this.buttonGetFrameRate_Click); - // - // buttonDone - // - this.buttonDone.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonDone.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonDone.Location = new System.Drawing.Point(239, 109); - this.buttonDone.Name = "buttonDone"; - this.buttonDone.Size = new System.Drawing.Size(75, 23); - this.buttonDone.TabIndex = 18; - this.buttonDone.Text = "&Done"; - this.buttonDone.UseVisualStyleBackColor = true; - // - // buttonSplit - // - this.buttonSplit.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonSplit.Location = new System.Drawing.Point(158, 109); - this.buttonSplit.Name = "buttonSplit"; - this.buttonSplit.Size = new System.Drawing.Size(75, 23); - this.buttonSplit.TabIndex = 17; - this.buttonSplit.Text = "&Split"; - this.buttonSplit.UseVisualStyleBackColor = true; - this.buttonSplit.Click += new System.EventHandler(this.ButtonSplitClick); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(16, 12); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(217, 13); - this.label1.TabIndex = 19; - this.label1.Text = "Enter length of first part of video or browse"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(16, 29); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(152, 13); - this.label2.TabIndex = 20; - this.label2.Text = "and get length from video file:"; - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // labelHourMinSecMilliSecond - // - this.labelHourMinSecMilliSecond.AutoSize = true; - this.labelHourMinSecMilliSecond.Location = new System.Drawing.Point(26, 52); - this.labelHourMinSecMilliSecond.Name = "labelHourMinSecMilliSecond"; - this.labelHourMinSecMilliSecond.Size = new System.Drawing.Size(108, 13); - this.labelHourMinSecMilliSecond.TabIndex = 22; - this.labelHourMinSecMilliSecond.Text = "Hours:min:sec.msecs"; - // - // splitTimeUpDownAdjust - // - this.splitTimeUpDownAdjust.AutoSize = true; - this.splitTimeUpDownAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.splitTimeUpDownAdjust.Font = new System.Drawing.Font("Segoe UI", 9F); - this.splitTimeUpDownAdjust.Location = new System.Drawing.Point(29, 69); - this.splitTimeUpDownAdjust.Margin = new System.Windows.Forms.Padding(4); - this.splitTimeUpDownAdjust.Name = "splitTimeUpDownAdjust"; - this.splitTimeUpDownAdjust.Size = new System.Drawing.Size(96, 27); - this.splitTimeUpDownAdjust.TabIndex = 21; - timeCode1.Hours = 0; - timeCode1.Milliseconds = 0; - timeCode1.Minutes = 0; - timeCode1.Seconds = 0; - timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); - timeCode1.TotalMilliseconds = 0D; - timeCode1.TotalSeconds = 0D; - this.splitTimeUpDownAdjust.TimeCode = timeCode1; - this.splitTimeUpDownAdjust.UseVideoOffset = false; - // - // buttonAdvanced - // - this.buttonAdvanced.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonAdvanced.Location = new System.Drawing.Point(54, 109); - this.buttonAdvanced.Name = "buttonAdvanced"; - this.buttonAdvanced.Size = new System.Drawing.Size(98, 23); - this.buttonAdvanced.TabIndex = 23; - this.buttonAdvanced.Text = "&Advanced"; - this.buttonAdvanced.UseVisualStyleBackColor = true; - this.buttonAdvanced.Click += new System.EventHandler(this.buttonAdvanced_Click); - // - // SplitSubtitle - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(325, 140); - this.Controls.Add(this.buttonAdvanced); - this.Controls.Add(this.buttonGetFrameRate); - this.Controls.Add(this.splitTimeUpDownAdjust); - this.Controls.Add(this.labelHourMinSecMilliSecond); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Controls.Add(this.buttonDone); - this.Controls.Add(this.buttonSplit); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "SplitSubtitle"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Split subtitle"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormSplitSubtitle_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonGetFrameRate; - private System.Windows.Forms.Button buttonDone; - private System.Windows.Forms.Button buttonSplit; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; - private Nikse.SubtitleEdit.Controls.TimeUpDown splitTimeUpDownAdjust; - private System.Windows.Forms.Label labelHourMinSecMilliSecond; - private System.Windows.Forms.Button buttonAdvanced; - } +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class SplitSubtitle + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + TimeCode timeCode1 = new TimeCode(); + this.buttonGetFrameRate = new System.Windows.Forms.Button(); + this.buttonDone = new System.Windows.Forms.Button(); + this.buttonSplit = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.labelHourMinSecMilliSecond = new System.Windows.Forms.Label(); + this.splitTimeUpDownAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); + this.buttonAdvanced = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // buttonGetFrameRate + // + this.buttonGetFrameRate.Location = new System.Drawing.Point(137, 69); + this.buttonGetFrameRate.Name = "buttonGetFrameRate"; + this.buttonGetFrameRate.Size = new System.Drawing.Size(25, 23); + this.buttonGetFrameRate.TabIndex = 8; + this.buttonGetFrameRate.Text = "..."; + this.buttonGetFrameRate.UseVisualStyleBackColor = true; + this.buttonGetFrameRate.Click += new System.EventHandler(this.buttonGetFrameRate_Click); + // + // buttonDone + // + this.buttonDone.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonDone.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonDone.Location = new System.Drawing.Point(239, 109); + this.buttonDone.Name = "buttonDone"; + this.buttonDone.Size = new System.Drawing.Size(75, 23); + this.buttonDone.TabIndex = 18; + this.buttonDone.Text = "&Done"; + this.buttonDone.UseVisualStyleBackColor = true; + // + // buttonSplit + // + this.buttonSplit.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonSplit.Location = new System.Drawing.Point(158, 109); + this.buttonSplit.Name = "buttonSplit"; + this.buttonSplit.Size = new System.Drawing.Size(75, 23); + this.buttonSplit.TabIndex = 17; + this.buttonSplit.Text = "&Split"; + this.buttonSplit.UseVisualStyleBackColor = true; + this.buttonSplit.Click += new System.EventHandler(this.ButtonSplitClick); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(16, 12); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(217, 13); + this.label1.TabIndex = 19; + this.label1.Text = "Enter length of first part of video or browse"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(16, 29); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(152, 13); + this.label2.TabIndex = 20; + this.label2.Text = "and get length from video file:"; + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // labelHourMinSecMilliSecond + // + this.labelHourMinSecMilliSecond.AutoSize = true; + this.labelHourMinSecMilliSecond.Location = new System.Drawing.Point(26, 52); + this.labelHourMinSecMilliSecond.Name = "labelHourMinSecMilliSecond"; + this.labelHourMinSecMilliSecond.Size = new System.Drawing.Size(108, 13); + this.labelHourMinSecMilliSecond.TabIndex = 22; + this.labelHourMinSecMilliSecond.Text = "Hours:min:sec.msecs"; + // + // splitTimeUpDownAdjust + // + this.splitTimeUpDownAdjust.AutoSize = true; + this.splitTimeUpDownAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.splitTimeUpDownAdjust.Font = new System.Drawing.Font("Segoe UI", 9F); + this.splitTimeUpDownAdjust.Location = new System.Drawing.Point(29, 69); + this.splitTimeUpDownAdjust.Margin = new System.Windows.Forms.Padding(4); + this.splitTimeUpDownAdjust.Name = "splitTimeUpDownAdjust"; + this.splitTimeUpDownAdjust.Size = new System.Drawing.Size(96, 27); + this.splitTimeUpDownAdjust.TabIndex = 21; + timeCode1.Hours = 0; + timeCode1.Milliseconds = 0; + timeCode1.Minutes = 0; + timeCode1.Seconds = 0; + timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode1.TotalMilliseconds = 0D; + timeCode1.TotalSeconds = 0D; + this.splitTimeUpDownAdjust.TimeCode = timeCode1; + this.splitTimeUpDownAdjust.UseVideoOffset = false; + // + // buttonAdvanced + // + this.buttonAdvanced.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonAdvanced.Location = new System.Drawing.Point(54, 109); + this.buttonAdvanced.Name = "buttonAdvanced"; + this.buttonAdvanced.Size = new System.Drawing.Size(98, 23); + this.buttonAdvanced.TabIndex = 23; + this.buttonAdvanced.Text = "&Advanced"; + this.buttonAdvanced.UseVisualStyleBackColor = true; + this.buttonAdvanced.Click += new System.EventHandler(this.buttonAdvanced_Click); + // + // SplitSubtitle + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(325, 140); + this.Controls.Add(this.buttonAdvanced); + this.Controls.Add(this.buttonGetFrameRate); + this.Controls.Add(this.splitTimeUpDownAdjust); + this.Controls.Add(this.labelHourMinSecMilliSecond); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.buttonDone); + this.Controls.Add(this.buttonSplit); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SplitSubtitle"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Split subtitle"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormSplitSubtitle_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonGetFrameRate; + private System.Windows.Forms.Button buttonDone; + private System.Windows.Forms.Button buttonSplit; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private Nikse.SubtitleEdit.Controls.TimeUpDown splitTimeUpDownAdjust; + private System.Windows.Forms.Label labelHourMinSecMilliSecond; + private System.Windows.Forms.Button buttonAdvanced; + } } \ No newline at end of file diff --git a/src/Forms/SplitSubtitle.cs b/src/ui/Forms/SplitSubtitle.cs similarity index 97% rename from src/Forms/SplitSubtitle.cs rename to src/ui/Forms/SplitSubtitle.cs index 647dccd3b..61e4b4427 100644 --- a/src/Forms/SplitSubtitle.cs +++ b/src/ui/Forms/SplitSubtitle.cs @@ -1,171 +1,171 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.IO; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class SplitSubtitle : Form - { - private Subtitle _subtitle; - private SubtitleFormat _format; - private Encoding _encoding; - private string _fileName; - public bool ShowAdvanced { get; private set; } - - public SplitSubtitle() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.SplitSubtitle.Title; - label1.Text = Configuration.Settings.Language.SplitSubtitle.Description1; - label2.Text = Configuration.Settings.Language.SplitSubtitle.Description2; - buttonSplit.Text = Configuration.Settings.Language.SplitSubtitle.Split; - buttonDone.Text = Configuration.Settings.Language.SplitSubtitle.Done; - buttonAdvanced.Text = Configuration.Settings.Language.General.Advanced; - labelHourMinSecMilliSecond.Text = Configuration.Settings.General.UseTimeFormatHHMMSSFF ? Configuration.Settings.Language.General.HourMinutesSecondsFrames : Configuration.Settings.Language.General.HourMinutesSecondsMilliseconds; - buttonGetFrameRate.Left = splitTimeUpDownAdjust.Left + splitTimeUpDownAdjust.Width; - - label2.Top = label1.Bottom; - if (Width < label1.Right + 5) - { - Width = label1.Right + 5; - } - - UiUtil.FixLargeFonts(this, buttonSplit); - } - - public void Initialize(Subtitle subtitle, string fileName, SubtitleFormat format, Encoding encoding, double lengthInSeconds) - { - ShowAdvanced = false; - _subtitle = subtitle; - _fileName = fileName; - _format = format; - _encoding = encoding; - splitTimeUpDownAdjust.TimeCode = TimeCode.FromSeconds(lengthInSeconds); - } - - private void FormSplitSubtitle_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void ButtonSplitClick(object sender, EventArgs e) - { - var splitTimeTotalMilliseconds = splitTimeUpDownAdjust.TimeCode.TotalMilliseconds; - if (splitTimeTotalMilliseconds > 0) - { - var part1 = new Subtitle(); - var part2 = new Subtitle(); - part1.Header = _subtitle.Header; - part1.Footer = _subtitle.Footer; - part2.Header = _subtitle.Header; - part2.Footer = _subtitle.Footer; - - foreach (Paragraph p in _subtitle.Paragraphs) - { - if (p.StartTime.TotalMilliseconds < splitTimeTotalMilliseconds) - { - part1.Paragraphs.Add(new Paragraph(p)); - } - - if (p.StartTime.TotalMilliseconds >= splitTimeTotalMilliseconds) - { - part2.Paragraphs.Add(new Paragraph(p)); - } - else if (p.EndTime.TotalMilliseconds > splitTimeTotalMilliseconds) - { - part1.Paragraphs[part1.Paragraphs.Count - 1].EndTime = new TimeCode(splitTimeTotalMilliseconds); - part2.Paragraphs.Add(new Paragraph(p) { StartTime = new TimeCode(splitTimeTotalMilliseconds) }); - } - } - if (part1.Paragraphs.Count > 0 && part2.Paragraphs.Count > 0) - { - SavePart(part1, Configuration.Settings.Language.SplitSubtitle.SavePartOneAs, Configuration.Settings.Language.SplitSubtitle.Part1); - - part2.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-splitTimeTotalMilliseconds)); - part2.Renumber(); - SavePart(part2, Configuration.Settings.Language.SplitSubtitle.SavePartTwoAs, Configuration.Settings.Language.SplitSubtitle.Part2); - - DialogResult = DialogResult.OK; - return; - } - MessageBox.Show(Configuration.Settings.Language.SplitSubtitle.NothingToSplit); - } - DialogResult = DialogResult.Cancel; - } - - private void SavePart(Subtitle part, string title, string name) - { - saveFileDialog1.Title = title; - saveFileDialog1.FileName = name; - UiUtil.SetSaveDialogFilter(saveFileDialog1, _format); - saveFileDialog1.DefaultExt = "*" + _format.Extension; - saveFileDialog1.AddExtension = true; - - if (saveFileDialog1.ShowDialog() == DialogResult.OK) - { - string fileName = saveFileDialog1.FileName; - - try - { - if (File.Exists(fileName)) - { - File.Delete(fileName); - } - - int index = 0; - foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) - { - if (saveFileDialog1.FilterIndex == index + 1) - { - File.WriteAllText(fileName, part.ToText(format), _encoding); - } - index++; - } - } - catch - { - MessageBox.Show(string.Format(Configuration.Settings.Language.SplitSubtitle.UnableToSaveFileX, fileName)); - } - } - } - - private void buttonGetFrameRate_Click(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(openFileDialog1.InitialDirectory) && !string.IsNullOrEmpty(_fileName)) - { - openFileDialog1.InitialDirectory = Path.GetDirectoryName(_fileName); - } - - openFileDialog1.Title = Configuration.Settings.Language.General.OpenVideoFileTitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = Utilities.GetVideoFileFilter(true); - openFileDialog1.FileName = string.Empty; - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - VideoInfo info = UiUtil.GetVideoInfo(openFileDialog1.FileName); - if (info != null && info.Success) - { - splitTimeUpDownAdjust.TimeCode = new TimeCode(info.TotalMilliseconds); - } - } - } - - private void buttonAdvanced_Click(object sender, EventArgs e) - { - ShowAdvanced = true; - DialogResult = DialogResult.Cancel; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System; +using System.IO; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class SplitSubtitle : Form + { + private Subtitle _subtitle; + private SubtitleFormat _format; + private Encoding _encoding; + private string _fileName; + public bool ShowAdvanced { get; private set; } + + public SplitSubtitle() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.SplitSubtitle.Title; + label1.Text = Configuration.Settings.Language.SplitSubtitle.Description1; + label2.Text = Configuration.Settings.Language.SplitSubtitle.Description2; + buttonSplit.Text = Configuration.Settings.Language.SplitSubtitle.Split; + buttonDone.Text = Configuration.Settings.Language.SplitSubtitle.Done; + buttonAdvanced.Text = Configuration.Settings.Language.General.Advanced; + labelHourMinSecMilliSecond.Text = Configuration.Settings.General.UseTimeFormatHHMMSSFF ? Configuration.Settings.Language.General.HourMinutesSecondsFrames : Configuration.Settings.Language.General.HourMinutesSecondsMilliseconds; + buttonGetFrameRate.Left = splitTimeUpDownAdjust.Left + splitTimeUpDownAdjust.Width; + + label2.Top = label1.Bottom; + if (Width < label1.Right + 5) + { + Width = label1.Right + 5; + } + + UiUtil.FixLargeFonts(this, buttonSplit); + } + + public void Initialize(Subtitle subtitle, string fileName, SubtitleFormat format, Encoding encoding, double lengthInSeconds) + { + ShowAdvanced = false; + _subtitle = subtitle; + _fileName = fileName; + _format = format; + _encoding = encoding; + splitTimeUpDownAdjust.TimeCode = TimeCode.FromSeconds(lengthInSeconds); + } + + private void FormSplitSubtitle_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void ButtonSplitClick(object sender, EventArgs e) + { + var splitTimeTotalMilliseconds = splitTimeUpDownAdjust.TimeCode.TotalMilliseconds; + if (splitTimeTotalMilliseconds > 0) + { + var part1 = new Subtitle(); + var part2 = new Subtitle(); + part1.Header = _subtitle.Header; + part1.Footer = _subtitle.Footer; + part2.Header = _subtitle.Header; + part2.Footer = _subtitle.Footer; + + foreach (Paragraph p in _subtitle.Paragraphs) + { + if (p.StartTime.TotalMilliseconds < splitTimeTotalMilliseconds) + { + part1.Paragraphs.Add(new Paragraph(p)); + } + + if (p.StartTime.TotalMilliseconds >= splitTimeTotalMilliseconds) + { + part2.Paragraphs.Add(new Paragraph(p)); + } + else if (p.EndTime.TotalMilliseconds > splitTimeTotalMilliseconds) + { + part1.Paragraphs[part1.Paragraphs.Count - 1].EndTime = new TimeCode(splitTimeTotalMilliseconds); + part2.Paragraphs.Add(new Paragraph(p) { StartTime = new TimeCode(splitTimeTotalMilliseconds) }); + } + } + if (part1.Paragraphs.Count > 0 && part2.Paragraphs.Count > 0) + { + SavePart(part1, Configuration.Settings.Language.SplitSubtitle.SavePartOneAs, Configuration.Settings.Language.SplitSubtitle.Part1); + + part2.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(-splitTimeTotalMilliseconds)); + part2.Renumber(); + SavePart(part2, Configuration.Settings.Language.SplitSubtitle.SavePartTwoAs, Configuration.Settings.Language.SplitSubtitle.Part2); + + DialogResult = DialogResult.OK; + return; + } + MessageBox.Show(Configuration.Settings.Language.SplitSubtitle.NothingToSplit); + } + DialogResult = DialogResult.Cancel; + } + + private void SavePart(Subtitle part, string title, string name) + { + saveFileDialog1.Title = title; + saveFileDialog1.FileName = name; + UiUtil.SetSaveDialogFilter(saveFileDialog1, _format); + saveFileDialog1.DefaultExt = "*" + _format.Extension; + saveFileDialog1.AddExtension = true; + + if (saveFileDialog1.ShowDialog() == DialogResult.OK) + { + string fileName = saveFileDialog1.FileName; + + try + { + if (File.Exists(fileName)) + { + File.Delete(fileName); + } + + int index = 0; + foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) + { + if (saveFileDialog1.FilterIndex == index + 1) + { + File.WriteAllText(fileName, part.ToText(format), _encoding); + } + index++; + } + } + catch + { + MessageBox.Show(string.Format(Configuration.Settings.Language.SplitSubtitle.UnableToSaveFileX, fileName)); + } + } + } + + private void buttonGetFrameRate_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(openFileDialog1.InitialDirectory) && !string.IsNullOrEmpty(_fileName)) + { + openFileDialog1.InitialDirectory = Path.GetDirectoryName(_fileName); + } + + openFileDialog1.Title = Configuration.Settings.Language.General.OpenVideoFileTitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = Utilities.GetVideoFileFilter(true); + openFileDialog1.FileName = string.Empty; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + VideoInfo info = UiUtil.GetVideoInfo(openFileDialog1.FileName); + if (info != null && info.Success) + { + splitTimeUpDownAdjust.TimeCode = new TimeCode(info.TotalMilliseconds); + } + } + } + + private void buttonAdvanced_Click(object sender, EventArgs e) + { + ShowAdvanced = true; + DialogResult = DialogResult.Cancel; + } + + } +} diff --git a/src/Forms/SplitSubtitle.resx b/src/ui/Forms/SplitSubtitle.resx similarity index 97% rename from src/Forms/SplitSubtitle.resx rename to src/ui/Forms/SplitSubtitle.resx index dadfc1c4b..c19168183 100644 --- a/src/Forms/SplitSubtitle.resx +++ b/src/ui/Forms/SplitSubtitle.resx @@ -1,126 +1,126 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 147, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 147, 17 + \ No newline at end of file diff --git a/src/Forms/StartNumberingFrom.Designer.cs b/src/ui/Forms/StartNumberingFrom.Designer.cs similarity index 97% rename from src/Forms/StartNumberingFrom.Designer.cs rename to src/ui/Forms/StartNumberingFrom.Designer.cs index 0f23e0766..b6d201588 100644 --- a/src/Forms/StartNumberingFrom.Designer.cs +++ b/src/ui/Forms/StartNumberingFrom.Designer.cs @@ -1,106 +1,106 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class StartNumberingFrom - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.label1 = new System.Windows.Forms.Label(); - this.textBox1 = new System.Windows.Forms.TextBox(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(24, 23); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(99, 13); - this.label1.TabIndex = 1; - this.label1.Text = "Start from number:"; - // - // textBox1 - // - this.textBox1.Location = new System.Drawing.Point(27, 41); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(104, 21); - this.textBox1.TabIndex = 0; - this.textBox1.Text = "1"; - this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBox1KeyDown); - // - // buttonCancel - // - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(113, 78); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 2; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOK - // - this.buttonOK.Location = new System.Drawing.Point(31, 78); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 1; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); - // - // StartNumberingFrom - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(261, 113); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.textBox1); - this.Controls.Add(this.label1); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "StartNumberingFrom"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Start numbering from..."; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormStartNumberingFrom_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox textBox1; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class StartNumberingFrom + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(24, 23); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(99, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Start from number:"; + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(27, 41); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(104, 21); + this.textBox1.TabIndex = 0; + this.textBox1.Text = "1"; + this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBox1KeyDown); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(113, 78); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 2; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOK + // + this.buttonOK.Location = new System.Drawing.Point(31, 78); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 1; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.ButtonOkClick); + // + // StartNumberingFrom + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(261, 113); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.label1); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "StartNumberingFrom"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Start numbering from..."; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormStartNumberingFrom_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + } } \ No newline at end of file diff --git a/src/Forms/StartNumberingFrom.cs b/src/ui/Forms/StartNumberingFrom.cs similarity index 97% rename from src/Forms/StartNumberingFrom.cs rename to src/ui/Forms/StartNumberingFrom.cs index 70c9edef8..d686e9ab1 100644 --- a/src/Forms/StartNumberingFrom.cs +++ b/src/ui/Forms/StartNumberingFrom.cs @@ -1,76 +1,76 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class StartNumberingFrom : PositionAndSizeForm - { - private int _startFromNumber; - - public StartNumberingFrom() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.StartNumberingFrom.Title; - label1.Text = Configuration.Settings.Language.StartNumberingFrom.StartFromNumber; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void FormStartNumberingFrom_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void TextBox1KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - ButtonOkClick(null, null); - } - else - { - if (e.KeyCode != Keys.D0 && e.KeyCode != Keys.D1 && e.KeyCode != Keys.D2 && e.KeyCode != Keys.D3 && e.KeyCode != Keys.D4 && e.KeyCode != Keys.D5 && e.KeyCode != Keys.D6 && e.KeyCode != Keys.D7 && e.KeyCode != Keys.D8 && e.KeyCode != Keys.D9 && e.KeyCode != Keys.Delete && e.KeyCode != Keys.Left && e.KeyCode != Keys.Right && e.KeyCode != Keys.Back && e.KeyCode != Keys.Home && e.KeyCode != Keys.End && (e.KeyValue < 96 || e.KeyValue > 105)) - { - if (e.KeyData == (Keys.Control | Keys.V) && Clipboard.GetText(TextDataFormat.UnicodeText).Length > 0) - { - var p = Clipboard.GetText(TextDataFormat.UnicodeText); - if (!int.TryParse(p, out _)) - { - e.SuppressKeyPress = true; - } - } - else if (e.Modifiers != Keys.Control && e.Modifiers != Keys.Alt) - { - e.SuppressKeyPress = true; - } - } - } - } - - private void ButtonOkClick(object sender, EventArgs e) - { - if (int.TryParse(textBox1.Text, out _startFromNumber)) - { - DialogResult = DialogResult.OK; - } - else - { - MessageBox.Show(Configuration.Settings.Language.StartNumberingFrom.PleaseEnterAValidNumber); - textBox1.Focus(); - textBox1.SelectAll(); - } - } - - public int StartFromNumber => _startFromNumber; - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class StartNumberingFrom : PositionAndSizeForm + { + private int _startFromNumber; + + public StartNumberingFrom() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.StartNumberingFrom.Title; + label1.Text = Configuration.Settings.Language.StartNumberingFrom.StartFromNumber; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void FormStartNumberingFrom_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void TextBox1KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + ButtonOkClick(null, null); + } + else + { + if (e.KeyCode != Keys.D0 && e.KeyCode != Keys.D1 && e.KeyCode != Keys.D2 && e.KeyCode != Keys.D3 && e.KeyCode != Keys.D4 && e.KeyCode != Keys.D5 && e.KeyCode != Keys.D6 && e.KeyCode != Keys.D7 && e.KeyCode != Keys.D8 && e.KeyCode != Keys.D9 && e.KeyCode != Keys.Delete && e.KeyCode != Keys.Left && e.KeyCode != Keys.Right && e.KeyCode != Keys.Back && e.KeyCode != Keys.Home && e.KeyCode != Keys.End && (e.KeyValue < 96 || e.KeyValue > 105)) + { + if (e.KeyData == (Keys.Control | Keys.V) && Clipboard.GetText(TextDataFormat.UnicodeText).Length > 0) + { + var p = Clipboard.GetText(TextDataFormat.UnicodeText); + if (!int.TryParse(p, out _)) + { + e.SuppressKeyPress = true; + } + } + else if (e.Modifiers != Keys.Control && e.Modifiers != Keys.Alt) + { + e.SuppressKeyPress = true; + } + } + } + } + + private void ButtonOkClick(object sender, EventArgs e) + { + if (int.TryParse(textBox1.Text, out _startFromNumber)) + { + DialogResult = DialogResult.OK; + } + else + { + MessageBox.Show(Configuration.Settings.Language.StartNumberingFrom.PleaseEnterAValidNumber); + textBox1.Focus(); + textBox1.SelectAll(); + } + } + + public int StartFromNumber => _startFromNumber; + } +} diff --git a/src/Forms/StartNumberingFrom.resx b/src/ui/Forms/StartNumberingFrom.resx similarity index 97% rename from src/Forms/StartNumberingFrom.resx rename to src/ui/Forms/StartNumberingFrom.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/StartNumberingFrom.resx +++ b/src/ui/Forms/StartNumberingFrom.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/Statistics.Designer.cs b/src/ui/Forms/Statistics.Designer.cs similarity index 98% rename from src/Forms/Statistics.Designer.cs rename to src/ui/Forms/Statistics.Designer.cs index 7d88c9281..6b125faa3 100644 --- a/src/Forms/Statistics.Designer.cs +++ b/src/ui/Forms/Statistics.Designer.cs @@ -1,190 +1,190 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class Statistics - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxGeneral = new System.Windows.Forms.GroupBox(); - this.textBoxGeneral = new System.Windows.Forms.TextBox(); - this.groupBoxMostUsed = new System.Windows.Forms.GroupBox(); - this.labelMostUsedLines = new System.Windows.Forms.Label(); - this.labelMostUsedWords = new System.Windows.Forms.Label(); - this.textBoxMostUsedLines = new System.Windows.Forms.TextBox(); - this.textBoxMostUsedWords = new System.Windows.Forms.TextBox(); - this.buttonExport = new System.Windows.Forms.Button(); - this.groupBoxGeneral.SuspendLayout(); - this.groupBoxMostUsed.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(642, 632); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // groupBoxGeneral - // - this.groupBoxGeneral.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxGeneral.Controls.Add(this.textBoxGeneral); - this.groupBoxGeneral.Location = new System.Drawing.Point(15, 12); - this.groupBoxGeneral.Name = "groupBoxGeneral"; - this.groupBoxGeneral.Size = new System.Drawing.Size(705, 376); - this.groupBoxGeneral.TabIndex = 0; - this.groupBoxGeneral.TabStop = false; - this.groupBoxGeneral.Text = "General statistics"; - // - // textBoxGeneral - // - this.textBoxGeneral.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxGeneral.Location = new System.Drawing.Point(6, 19); - this.textBoxGeneral.Multiline = true; - this.textBoxGeneral.Name = "textBoxGeneral"; - this.textBoxGeneral.ReadOnly = true; - this.textBoxGeneral.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxGeneral.Size = new System.Drawing.Size(694, 351); - this.textBoxGeneral.TabIndex = 0; - // - // groupBoxMostUsed - // - this.groupBoxMostUsed.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxMostUsed.Controls.Add(this.labelMostUsedLines); - this.groupBoxMostUsed.Controls.Add(this.labelMostUsedWords); - this.groupBoxMostUsed.Controls.Add(this.textBoxMostUsedLines); - this.groupBoxMostUsed.Controls.Add(this.textBoxMostUsedWords); - this.groupBoxMostUsed.Location = new System.Drawing.Point(12, 394); - this.groupBoxMostUsed.Name = "groupBoxMostUsed"; - this.groupBoxMostUsed.Size = new System.Drawing.Size(705, 232); - this.groupBoxMostUsed.TabIndex = 1; - this.groupBoxMostUsed.TabStop = false; - this.groupBoxMostUsed.Text = "Most used"; - // - // labelMostUsedLines - // - this.labelMostUsedLines.AutoSize = true; - this.labelMostUsedLines.Location = new System.Drawing.Point(329, 27); - this.labelMostUsedLines.Name = "labelMostUsedLines"; - this.labelMostUsedLines.Size = new System.Drawing.Size(80, 13); - this.labelMostUsedLines.TabIndex = 2; - this.labelMostUsedLines.Text = "Most used lines"; - // - // labelMostUsedWords - // - this.labelMostUsedWords.AutoSize = true; - this.labelMostUsedWords.Location = new System.Drawing.Point(6, 27); - this.labelMostUsedWords.Name = "labelMostUsedWords"; - this.labelMostUsedWords.Size = new System.Drawing.Size(87, 13); - this.labelMostUsedWords.TabIndex = 0; - this.labelMostUsedWords.Text = "Most used words"; - // - // textBoxMostUsedLines - // - this.textBoxMostUsedLines.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxMostUsedLines.Location = new System.Drawing.Point(332, 43); - this.textBoxMostUsedLines.Multiline = true; - this.textBoxMostUsedLines.Name = "textBoxMostUsedLines"; - this.textBoxMostUsedLines.ReadOnly = true; - this.textBoxMostUsedLines.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxMostUsedLines.Size = new System.Drawing.Size(371, 183); - this.textBoxMostUsedLines.TabIndex = 3; - // - // textBoxMostUsedWords - // - this.textBoxMostUsedWords.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.textBoxMostUsedWords.Location = new System.Drawing.Point(9, 43); - this.textBoxMostUsedWords.Multiline = true; - this.textBoxMostUsedWords.Name = "textBoxMostUsedWords"; - this.textBoxMostUsedWords.ReadOnly = true; - this.textBoxMostUsedWords.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxMostUsedWords.Size = new System.Drawing.Size(320, 183); - this.textBoxMostUsedWords.TabIndex = 1; - // - // buttonExport - // - this.buttonExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonExport.Location = new System.Drawing.Point(532, 632); - this.buttonExport.Name = "buttonExport"; - this.buttonExport.Size = new System.Drawing.Size(104, 23); - this.buttonExport.TabIndex = 2; - this.buttonExport.Text = "Export"; - this.buttonExport.UseVisualStyleBackColor = true; - this.buttonExport.Click += new System.EventHandler(this.buttonExport_Click); - // - // Statistics - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(732, 665); - this.Controls.Add(this.buttonExport); - this.Controls.Add(this.groupBoxMostUsed); - this.Controls.Add(this.groupBoxGeneral); - this.Controls.Add(this.buttonOK); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(700, 600); - this.Name = "Statistics"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Statistics"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Statistics_KeyDown); - this.groupBoxGeneral.ResumeLayout(false); - this.groupBoxGeneral.PerformLayout(); - this.groupBoxMostUsed.ResumeLayout(false); - this.groupBoxMostUsed.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.GroupBox groupBoxGeneral; - private System.Windows.Forms.TextBox textBoxGeneral; - private System.Windows.Forms.GroupBox groupBoxMostUsed; - private System.Windows.Forms.TextBox textBoxMostUsedWords; - private System.Windows.Forms.TextBox textBoxMostUsedLines; - private System.Windows.Forms.Label labelMostUsedLines; - private System.Windows.Forms.Label labelMostUsedWords; - private System.Windows.Forms.Button buttonExport; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class Statistics + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxGeneral = new System.Windows.Forms.GroupBox(); + this.textBoxGeneral = new System.Windows.Forms.TextBox(); + this.groupBoxMostUsed = new System.Windows.Forms.GroupBox(); + this.labelMostUsedLines = new System.Windows.Forms.Label(); + this.labelMostUsedWords = new System.Windows.Forms.Label(); + this.textBoxMostUsedLines = new System.Windows.Forms.TextBox(); + this.textBoxMostUsedWords = new System.Windows.Forms.TextBox(); + this.buttonExport = new System.Windows.Forms.Button(); + this.groupBoxGeneral.SuspendLayout(); + this.groupBoxMostUsed.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(642, 632); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // groupBoxGeneral + // + this.groupBoxGeneral.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxGeneral.Controls.Add(this.textBoxGeneral); + this.groupBoxGeneral.Location = new System.Drawing.Point(15, 12); + this.groupBoxGeneral.Name = "groupBoxGeneral"; + this.groupBoxGeneral.Size = new System.Drawing.Size(705, 376); + this.groupBoxGeneral.TabIndex = 0; + this.groupBoxGeneral.TabStop = false; + this.groupBoxGeneral.Text = "General statistics"; + // + // textBoxGeneral + // + this.textBoxGeneral.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxGeneral.Location = new System.Drawing.Point(6, 19); + this.textBoxGeneral.Multiline = true; + this.textBoxGeneral.Name = "textBoxGeneral"; + this.textBoxGeneral.ReadOnly = true; + this.textBoxGeneral.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBoxGeneral.Size = new System.Drawing.Size(694, 351); + this.textBoxGeneral.TabIndex = 0; + // + // groupBoxMostUsed + // + this.groupBoxMostUsed.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxMostUsed.Controls.Add(this.labelMostUsedLines); + this.groupBoxMostUsed.Controls.Add(this.labelMostUsedWords); + this.groupBoxMostUsed.Controls.Add(this.textBoxMostUsedLines); + this.groupBoxMostUsed.Controls.Add(this.textBoxMostUsedWords); + this.groupBoxMostUsed.Location = new System.Drawing.Point(12, 394); + this.groupBoxMostUsed.Name = "groupBoxMostUsed"; + this.groupBoxMostUsed.Size = new System.Drawing.Size(705, 232); + this.groupBoxMostUsed.TabIndex = 1; + this.groupBoxMostUsed.TabStop = false; + this.groupBoxMostUsed.Text = "Most used"; + // + // labelMostUsedLines + // + this.labelMostUsedLines.AutoSize = true; + this.labelMostUsedLines.Location = new System.Drawing.Point(329, 27); + this.labelMostUsedLines.Name = "labelMostUsedLines"; + this.labelMostUsedLines.Size = new System.Drawing.Size(80, 13); + this.labelMostUsedLines.TabIndex = 2; + this.labelMostUsedLines.Text = "Most used lines"; + // + // labelMostUsedWords + // + this.labelMostUsedWords.AutoSize = true; + this.labelMostUsedWords.Location = new System.Drawing.Point(6, 27); + this.labelMostUsedWords.Name = "labelMostUsedWords"; + this.labelMostUsedWords.Size = new System.Drawing.Size(87, 13); + this.labelMostUsedWords.TabIndex = 0; + this.labelMostUsedWords.Text = "Most used words"; + // + // textBoxMostUsedLines + // + this.textBoxMostUsedLines.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxMostUsedLines.Location = new System.Drawing.Point(332, 43); + this.textBoxMostUsedLines.Multiline = true; + this.textBoxMostUsedLines.Name = "textBoxMostUsedLines"; + this.textBoxMostUsedLines.ReadOnly = true; + this.textBoxMostUsedLines.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBoxMostUsedLines.Size = new System.Drawing.Size(371, 183); + this.textBoxMostUsedLines.TabIndex = 3; + // + // textBoxMostUsedWords + // + this.textBoxMostUsedWords.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.textBoxMostUsedWords.Location = new System.Drawing.Point(9, 43); + this.textBoxMostUsedWords.Multiline = true; + this.textBoxMostUsedWords.Name = "textBoxMostUsedWords"; + this.textBoxMostUsedWords.ReadOnly = true; + this.textBoxMostUsedWords.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBoxMostUsedWords.Size = new System.Drawing.Size(320, 183); + this.textBoxMostUsedWords.TabIndex = 1; + // + // buttonExport + // + this.buttonExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonExport.Location = new System.Drawing.Point(532, 632); + this.buttonExport.Name = "buttonExport"; + this.buttonExport.Size = new System.Drawing.Size(104, 23); + this.buttonExport.TabIndex = 2; + this.buttonExport.Text = "Export"; + this.buttonExport.UseVisualStyleBackColor = true; + this.buttonExport.Click += new System.EventHandler(this.buttonExport_Click); + // + // Statistics + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(732, 665); + this.Controls.Add(this.buttonExport); + this.Controls.Add(this.groupBoxMostUsed); + this.Controls.Add(this.groupBoxGeneral); + this.Controls.Add(this.buttonOK); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(700, 600); + this.Name = "Statistics"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Statistics"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Statistics_KeyDown); + this.groupBoxGeneral.ResumeLayout(false); + this.groupBoxGeneral.PerformLayout(); + this.groupBoxMostUsed.ResumeLayout(false); + this.groupBoxMostUsed.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.GroupBox groupBoxGeneral; + private System.Windows.Forms.TextBox textBoxGeneral; + private System.Windows.Forms.GroupBox groupBoxMostUsed; + private System.Windows.Forms.TextBox textBoxMostUsedWords; + private System.Windows.Forms.TextBox textBoxMostUsedLines; + private System.Windows.Forms.Label labelMostUsedLines; + private System.Windows.Forms.Label labelMostUsedWords; + private System.Windows.Forms.Button buttonExport; + } } \ No newline at end of file diff --git a/src/Forms/Statistics.cs b/src/ui/Forms/Statistics.cs similarity index 97% rename from src/Forms/Statistics.cs rename to src/ui/Forms/Statistics.cs index 415d3379f..e3e95beff 100644 --- a/src/Forms/Statistics.cs +++ b/src/ui/Forms/Statistics.cs @@ -1,516 +1,516 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class Statistics : PositionAndSizeForm - { - - public class StingOrdinalComparer : IEqualityComparer, IComparer - { - public bool Equals(string x, string y) - { - if (x == null) - { - return y == null; - } - - return x.Equals(y, StringComparison.Ordinal); - } - - public int GetHashCode(string x) - { - return x.GetHashCode(); - } - - public int Compare(string x, string y) - { - return string.CompareOrdinal(x, y); - } - } - - private readonly Subtitle _subtitle; - private readonly SubtitleFormat _format; - private readonly LanguageStructure.Statistics _l; - private string _mostUsedLines; - private string _general; - private int _totalWords; - private string _mostUsedWords; - private const string WriteFormat = @"File generated by: Subtitle Edit -https://www.nikse.dk/subtitleedit/ -https://github.com/SubtitleEdit/subtitleedit -============================= General ============================= -{0} -============================= Most Used Words ============================= -{1} -============================= Most Used Lines ============================= -{2}"; - private readonly string _fileName; - - private static readonly char[] ExpectedChars = { '♪', '♫', '"', '(', ')', '[', ']', ' ', ',', '!', '?', '.', ':', ';', '-', '_', '@', '<', '>', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '،', '؟', '؛' }; - - public Statistics(Subtitle subtitle, string fileName, SubtitleFormat format) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - _subtitle = subtitle; - _format = format; - _fileName = fileName; - - _l = Configuration.Settings.Language.Statistics; - Text = string.IsNullOrEmpty(fileName) ? _l.Title : string.Format(_l.TitleWithFileName, fileName); - groupBoxGeneral.Text = _l.GeneralStatistics; - groupBoxMostUsed.Text = _l.MostUsed; - labelMostUsedWords.Text = _l.MostUsedWords; - labelMostUsedLines.Text = _l.MostUsedLines; - buttonExport.Text = _l.Export; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - UiUtil.FixLargeFonts(this, buttonOK); - - CalculateWordStatistics(); - CalculateGeneralStatistics(); - textBoxGeneral.Text = _general; - textBoxGeneral.SelectionStart = 0; - textBoxGeneral.SelectionLength = 0; - textBoxGeneral.ScrollToCaret(); - textBoxMostUsedWords.Text = _mostUsedWords; - - CalculateMostUsedLines(); - textBoxMostUsedLines.Text = _mostUsedLines; - } - - private void CalculateGeneralStatistics() - { - if (_subtitle == null || _subtitle.Paragraphs.Count == 0) - { - textBoxGeneral.Text = _l.NothingFound; - return; - } - - var allText = new StringBuilder(); - int minimumLineLength = 99999999; - int maximumLineLength = 0; - long totalLineLength = 0; - int minimumSingleLineLength = 99999999; - int maximumSingleLineLength = 0; - long totalSingleLineLength = 0; - long totalSingleLines = 0; - int minimumSingleLineWidth = 99999999; - int maximumSingleLineWidth = 0; - long totalSingleLineWidth = 0; - double minimumDuration = 100000000; - double maximumDuration = 0; - double totalDuration = 0; - double minimumCharsSec = 100000000; - double maximumCharsSec = 0; - double totalCharsSec = 0; - foreach (Paragraph p in _subtitle.Paragraphs) - { - allText.Append(p.Text); - - int len = GetLineLength(p); - minimumLineLength = Math.Min(minimumLineLength, len); - maximumLineLength = Math.Max(len, maximumLineLength); - totalLineLength += len; - - double duration = p.Duration.TotalMilliseconds; - minimumDuration = Math.Min(duration, minimumDuration); - maximumDuration = Math.Max(duration, maximumDuration); - totalDuration += duration; - - var charsSec = Utilities.GetCharactersPerSecond(p); - minimumCharsSec = Math.Min(charsSec, minimumCharsSec); - maximumCharsSec = Math.Max(charsSec, maximumCharsSec); - totalCharsSec += charsSec; - - foreach (string line in p.Text.SplitToLines()) - { - var l = GetSingleLineLength(line); - minimumSingleLineLength = Math.Min(l, minimumSingleLineLength); - maximumSingleLineLength = Math.Max(l, maximumSingleLineLength); - totalSingleLineLength += l; - - if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) - { - var w = GetSingleLineWidth(line); - minimumSingleLineWidth = Math.Min(w, minimumSingleLineWidth); - maximumSingleLineWidth = Math.Max(w, maximumSingleLineWidth); - totalSingleLineWidth += w; - } - - totalSingleLines++; - } - } - - var sb = new StringBuilder(); - int sourceLength = _subtitle.ToText(_format).Length; - var allTextToLower = allText.ToString().ToLowerInvariant(); - - sb.AppendLine(string.Format(_l.NumberOfLinesX, _subtitle.Paragraphs.Count)); - sb.AppendLine(string.Format(_l.LengthInFormatXinCharactersY, _format.FriendlyName, sourceLength)); - sb.AppendLine(string.Format(_l.NumberOfCharactersInTextOnly, allText.ToString().CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics))); - sb.AppendLine(string.Format(_l.TotalDuration, new TimeCode(totalDuration).ToDisplayString())); - sb.AppendLine(string.Format(_l.TotalCharsPerSecond, allText.ToString().CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) / (totalDuration / TimeCode.BaseUnit))); - sb.AppendLine(string.Format(_l.TotalWords, _totalWords)); - sb.AppendLine(string.Format(_l.NumberOfItalicTags, Utilities.CountTagInText(allTextToLower, ""))); - sb.AppendLine(string.Format(_l.NumberOfBoldTags, Utilities.CountTagInText(allTextToLower, ""))); - sb.AppendLine(string.Format(_l.NumberOfUnderlineTags, Utilities.CountTagInText(allTextToLower, ""))); - sb.AppendLine(string.Format(_l.NumberOfFontTags, Utilities.CountTagInText(allTextToLower, "(); - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - var p = _subtitle.Paragraphs[i]; - if (Math.Abs(p.Duration.TotalMilliseconds - duration) < 0.01) - { - if (indices.Count >= NumberOfLinesToShow) - { - indices.Add("..."); - break; - } - indices.Add("#" + (i + 1).ToString(CultureInfo.InvariantCulture)); - } - } - return string.Join(", ", indices); - } - - private string GetIndicesWithCps(double cps) - { - var indices = new List(); - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - var p = _subtitle.Paragraphs[i]; - if (Math.Abs(Utilities.GetCharactersPerSecond(p) - cps) < 0.01) - { - if (indices.Count >= NumberOfLinesToShow) - { - indices.Add("..."); - break; - } - indices.Add("#" + (i + 1).ToString(CultureInfo.InvariantCulture)); - } - } - return string.Join(", ", indices); - } - - private string GetIndicesWithLength(int length) - { - var indices = new List(); - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - var p = _subtitle.Paragraphs[i]; - if (GetLineLength(p) == length) - { - if (indices.Count >= NumberOfLinesToShow) - { - indices.Add("..."); - break; - } - indices.Add("#" + (i + 1).ToString(CultureInfo.InvariantCulture)); - } - } - return string.Join(", ", indices); - } - - private string GetIndicesWithSingleLineLength(int length) - { - var indices = new List(); - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - var p = _subtitle.Paragraphs[i]; - foreach (var line in p.Text.SplitToLines()) - { - if (GetSingleLineLength(line) == length) - { - if (indices.Count >= NumberOfLinesToShow) - { - indices.Add("..."); - return string.Join(", ", indices); - } - indices.Add("#" + (i + 1).ToString(CultureInfo.InvariantCulture)); - break; - } - } - } - return string.Join(", ", indices); - } - - private string GetIndicesWithSingleLineWidth(int width) - { - var indices = new List(); - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) - { - var p = _subtitle.Paragraphs[i]; - foreach (var line in p.Text.SplitToLines()) - { - if (GetSingleLineWidth(line) == width) - { - if (indices.Count >= NumberOfLinesToShow) - { - indices.Add("..."); - return string.Join(", ", indices); - } - indices.Add("#" + (i + 1).ToString(CultureInfo.InvariantCulture)); - break; - } - } - } - return string.Join(", ", indices); - } - - private void Statistics_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyData == (Keys.Control | Keys.C)) - { - Clipboard.SetText(string.Format(WriteFormat, _general, _mostUsedWords, _mostUsedLines), TextDataFormat.UnicodeText); - } - } - - private void MostUsedWordsAdd(Dictionary hashtable, string input) - { - var text = input; - if (text.Contains("< ")) - { - text = HtmlUtil.FixInvalidItalicTags(text); - } - - text = StripHtmlTags(text); - - var idx = text.IndexOf("= 0) - { - var endIdx = text.IndexOf('>', idx + 5); - if (endIdx < idx) - { - error = true; - break; - } - endIdx++; - text = text.Remove(idx, endIdx - idx); - idx = text.IndexOf("", "."); - } - - foreach (var word in Utilities.RemoveSsaTags(text).Split(ExpectedChars, StringSplitOptions.RemoveEmptyEntries)) - { - var s = word.Trim(); - if (s.Length > 1 && hashtable.ContainsKey(s)) - { - hashtable[s]++; - } - else if (s.Length > 1) - { - hashtable.Add(s, 1); - } - } - } - - private static void MostUsedLinesAdd(Dictionary hashtable, string input) - { - var text = StripHtmlTags(input) - .Replace('!', '.') - .Replace('?', '.') - .Replace("...", ".") - .Replace("..", ".") - .Replace('-', ' ') - .FixExtraSpaces(); - - text = Utilities.RemoveSsaTags(text); - - foreach (string line in text.Split('.')) - { - var s = line.Trim(); - if (hashtable.ContainsKey(s)) - { - hashtable[s]++; - } - else if (s.Length > 0 && s.Contains(' ')) - { - hashtable.Add(s, 1); - } - } - } - - private static string StripHtmlTags(string input) - { - var text = input.Trim('\'').Replace("\"", string.Empty); - - if (text.Length < 8) - { - return text; - } - - text = text.Replace("", string.Empty); - text = text.Replace("", "."); - text = text.Replace("", string.Empty); - text = text.Replace("", "."); - text = text.Replace("", string.Empty); - text = text.Replace("", "."); - text = text.Replace("", string.Empty); - text = text.Replace("", "."); - text = text.Replace("", string.Empty); - text = text.Replace("", "."); - text = text.Replace("", string.Empty); - text = text.Replace("", "."); - return text; - } - - private void CalculateWordStatistics() - { - var hashtable = new Dictionary(new StingOrdinalComparer()); - - foreach (Paragraph p in _subtitle.Paragraphs) - { - MostUsedWordsAdd(hashtable, p.Text); - _totalWords += p.Text.CountWords(); - } - - var sortedTable = new SortedDictionary(new StingOrdinalComparer()); - foreach (KeyValuePair item in hashtable) - { - if (item.Value > 1) - { - sortedTable.Add($"{item.Value:0000}" + "_" + item.Key, item.Value + ": " + item.Key); - } - } - - var sb = new StringBuilder(); - if (sortedTable.Count > 0) - { - var temp = string.Empty; - foreach (KeyValuePair item in sortedTable) - { - temp = item.Value + Environment.NewLine + temp; - } - sb.AppendLine(temp); - } - else - { - sb.AppendLine(_l.NothingFound); - } - _mostUsedWords = sb.ToString(); - } - - private void CalculateMostUsedLines() - { - var hashtable = new Dictionary(); - - foreach (Paragraph p in _subtitle.Paragraphs) - { - MostUsedLinesAdd(hashtable, p.Text.Replace(Environment.NewLine, " ").Replace(" ", " ")); - } - - var sortedTable = new SortedDictionary(new StingOrdinalComparer()); - foreach (KeyValuePair item in hashtable) - { - if (item.Value > 1) - { - sortedTable.Add($"{item.Value:0000}" + "_" + item.Key, item.Value + ": " + item.Key); - } - } - - var sb = new StringBuilder(); - if (sortedTable.Count > 0) - { - var temp = string.Empty; - foreach (KeyValuePair item in sortedTable) - { - temp = item.Value + Environment.NewLine + temp; - } - sb.AppendLine(temp); - } - else - { - sb.AppendLine(_l.NothingFound); - } - _mostUsedLines = sb.ToString(); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void buttonExport_Click(object sender, EventArgs e) - { - string preViewFileName = Path.GetFileNameWithoutExtension(_fileName) + ".Stats"; - using (var saveDialog = new SaveFileDialog { FileName = preViewFileName, Filter = Configuration.Settings.Language.Main.TextFiles + " (*.txt)|*.txt|NFO files (*.nfo)|*.nfo" }) - { - if (saveDialog.ShowDialog(this) == DialogResult.OK) - { - string fileName = saveDialog.FileName; - var statistic = string.Format(WriteFormat, _general, _mostUsedWords, _mostUsedLines); - File.WriteAllText(fileName, statistic); - } - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class Statistics : PositionAndSizeForm + { + + public class StingOrdinalComparer : IEqualityComparer, IComparer + { + public bool Equals(string x, string y) + { + if (x == null) + { + return y == null; + } + + return x.Equals(y, StringComparison.Ordinal); + } + + public int GetHashCode(string x) + { + return x.GetHashCode(); + } + + public int Compare(string x, string y) + { + return string.CompareOrdinal(x, y); + } + } + + private readonly Subtitle _subtitle; + private readonly SubtitleFormat _format; + private readonly LanguageStructure.Statistics _l; + private string _mostUsedLines; + private string _general; + private int _totalWords; + private string _mostUsedWords; + private const string WriteFormat = @"File generated by: Subtitle Edit +https://www.nikse.dk/subtitleedit/ +https://github.com/SubtitleEdit/subtitleedit +============================= General ============================= +{0} +============================= Most Used Words ============================= +{1} +============================= Most Used Lines ============================= +{2}"; + private readonly string _fileName; + + private static readonly char[] ExpectedChars = { '♪', '♫', '"', '(', ')', '[', ']', ' ', ',', '!', '?', '.', ':', ';', '-', '_', '@', '<', '>', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '،', '؟', '؛' }; + + public Statistics(Subtitle subtitle, string fileName, SubtitleFormat format) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + _subtitle = subtitle; + _format = format; + _fileName = fileName; + + _l = Configuration.Settings.Language.Statistics; + Text = string.IsNullOrEmpty(fileName) ? _l.Title : string.Format(_l.TitleWithFileName, fileName); + groupBoxGeneral.Text = _l.GeneralStatistics; + groupBoxMostUsed.Text = _l.MostUsed; + labelMostUsedWords.Text = _l.MostUsedWords; + labelMostUsedLines.Text = _l.MostUsedLines; + buttonExport.Text = _l.Export; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + UiUtil.FixLargeFonts(this, buttonOK); + + CalculateWordStatistics(); + CalculateGeneralStatistics(); + textBoxGeneral.Text = _general; + textBoxGeneral.SelectionStart = 0; + textBoxGeneral.SelectionLength = 0; + textBoxGeneral.ScrollToCaret(); + textBoxMostUsedWords.Text = _mostUsedWords; + + CalculateMostUsedLines(); + textBoxMostUsedLines.Text = _mostUsedLines; + } + + private void CalculateGeneralStatistics() + { + if (_subtitle == null || _subtitle.Paragraphs.Count == 0) + { + textBoxGeneral.Text = _l.NothingFound; + return; + } + + var allText = new StringBuilder(); + int minimumLineLength = 99999999; + int maximumLineLength = 0; + long totalLineLength = 0; + int minimumSingleLineLength = 99999999; + int maximumSingleLineLength = 0; + long totalSingleLineLength = 0; + long totalSingleLines = 0; + int minimumSingleLineWidth = 99999999; + int maximumSingleLineWidth = 0; + long totalSingleLineWidth = 0; + double minimumDuration = 100000000; + double maximumDuration = 0; + double totalDuration = 0; + double minimumCharsSec = 100000000; + double maximumCharsSec = 0; + double totalCharsSec = 0; + foreach (Paragraph p in _subtitle.Paragraphs) + { + allText.Append(p.Text); + + int len = GetLineLength(p); + minimumLineLength = Math.Min(minimumLineLength, len); + maximumLineLength = Math.Max(len, maximumLineLength); + totalLineLength += len; + + double duration = p.Duration.TotalMilliseconds; + minimumDuration = Math.Min(duration, minimumDuration); + maximumDuration = Math.Max(duration, maximumDuration); + totalDuration += duration; + + var charsSec = Utilities.GetCharactersPerSecond(p); + minimumCharsSec = Math.Min(charsSec, minimumCharsSec); + maximumCharsSec = Math.Max(charsSec, maximumCharsSec); + totalCharsSec += charsSec; + + foreach (string line in p.Text.SplitToLines()) + { + var l = GetSingleLineLength(line); + minimumSingleLineLength = Math.Min(l, minimumSingleLineLength); + maximumSingleLineLength = Math.Max(l, maximumSingleLineLength); + totalSingleLineLength += l; + + if (Configuration.Settings.Tools.ListViewSyntaxColorWideLines) + { + var w = GetSingleLineWidth(line); + minimumSingleLineWidth = Math.Min(w, minimumSingleLineWidth); + maximumSingleLineWidth = Math.Max(w, maximumSingleLineWidth); + totalSingleLineWidth += w; + } + + totalSingleLines++; + } + } + + var sb = new StringBuilder(); + int sourceLength = _subtitle.ToText(_format).Length; + var allTextToLower = allText.ToString().ToLowerInvariant(); + + sb.AppendLine(string.Format(_l.NumberOfLinesX, _subtitle.Paragraphs.Count)); + sb.AppendLine(string.Format(_l.LengthInFormatXinCharactersY, _format.FriendlyName, sourceLength)); + sb.AppendLine(string.Format(_l.NumberOfCharactersInTextOnly, allText.ToString().CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics))); + sb.AppendLine(string.Format(_l.TotalDuration, new TimeCode(totalDuration).ToDisplayString())); + sb.AppendLine(string.Format(_l.TotalCharsPerSecond, allText.ToString().CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) / (totalDuration / TimeCode.BaseUnit))); + sb.AppendLine(string.Format(_l.TotalWords, _totalWords)); + sb.AppendLine(string.Format(_l.NumberOfItalicTags, Utilities.CountTagInText(allTextToLower, ""))); + sb.AppendLine(string.Format(_l.NumberOfBoldTags, Utilities.CountTagInText(allTextToLower, ""))); + sb.AppendLine(string.Format(_l.NumberOfUnderlineTags, Utilities.CountTagInText(allTextToLower, ""))); + sb.AppendLine(string.Format(_l.NumberOfFontTags, Utilities.CountTagInText(allTextToLower, "(); + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + var p = _subtitle.Paragraphs[i]; + if (Math.Abs(p.Duration.TotalMilliseconds - duration) < 0.01) + { + if (indices.Count >= NumberOfLinesToShow) + { + indices.Add("..."); + break; + } + indices.Add("#" + (i + 1).ToString(CultureInfo.InvariantCulture)); + } + } + return string.Join(", ", indices); + } + + private string GetIndicesWithCps(double cps) + { + var indices = new List(); + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + var p = _subtitle.Paragraphs[i]; + if (Math.Abs(Utilities.GetCharactersPerSecond(p) - cps) < 0.01) + { + if (indices.Count >= NumberOfLinesToShow) + { + indices.Add("..."); + break; + } + indices.Add("#" + (i + 1).ToString(CultureInfo.InvariantCulture)); + } + } + return string.Join(", ", indices); + } + + private string GetIndicesWithLength(int length) + { + var indices = new List(); + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + var p = _subtitle.Paragraphs[i]; + if (GetLineLength(p) == length) + { + if (indices.Count >= NumberOfLinesToShow) + { + indices.Add("..."); + break; + } + indices.Add("#" + (i + 1).ToString(CultureInfo.InvariantCulture)); + } + } + return string.Join(", ", indices); + } + + private string GetIndicesWithSingleLineLength(int length) + { + var indices = new List(); + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + var p = _subtitle.Paragraphs[i]; + foreach (var line in p.Text.SplitToLines()) + { + if (GetSingleLineLength(line) == length) + { + if (indices.Count >= NumberOfLinesToShow) + { + indices.Add("..."); + return string.Join(", ", indices); + } + indices.Add("#" + (i + 1).ToString(CultureInfo.InvariantCulture)); + break; + } + } + } + return string.Join(", ", indices); + } + + private string GetIndicesWithSingleLineWidth(int width) + { + var indices = new List(); + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + var p = _subtitle.Paragraphs[i]; + foreach (var line in p.Text.SplitToLines()) + { + if (GetSingleLineWidth(line) == width) + { + if (indices.Count >= NumberOfLinesToShow) + { + indices.Add("..."); + return string.Join(", ", indices); + } + indices.Add("#" + (i + 1).ToString(CultureInfo.InvariantCulture)); + break; + } + } + } + return string.Join(", ", indices); + } + + private void Statistics_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyData == (Keys.Control | Keys.C)) + { + Clipboard.SetText(string.Format(WriteFormat, _general, _mostUsedWords, _mostUsedLines), TextDataFormat.UnicodeText); + } + } + + private void MostUsedWordsAdd(Dictionary hashtable, string input) + { + var text = input; + if (text.Contains("< ")) + { + text = HtmlUtil.FixInvalidItalicTags(text); + } + + text = StripHtmlTags(text); + + var idx = text.IndexOf("= 0) + { + var endIdx = text.IndexOf('>', idx + 5); + if (endIdx < idx) + { + error = true; + break; + } + endIdx++; + text = text.Remove(idx, endIdx - idx); + idx = text.IndexOf("", "."); + } + + foreach (var word in Utilities.RemoveSsaTags(text).Split(ExpectedChars, StringSplitOptions.RemoveEmptyEntries)) + { + var s = word.Trim(); + if (s.Length > 1 && hashtable.ContainsKey(s)) + { + hashtable[s]++; + } + else if (s.Length > 1) + { + hashtable.Add(s, 1); + } + } + } + + private static void MostUsedLinesAdd(Dictionary hashtable, string input) + { + var text = StripHtmlTags(input) + .Replace('!', '.') + .Replace('?', '.') + .Replace("...", ".") + .Replace("..", ".") + .Replace('-', ' ') + .FixExtraSpaces(); + + text = Utilities.RemoveSsaTags(text); + + foreach (string line in text.Split('.')) + { + var s = line.Trim(); + if (hashtable.ContainsKey(s)) + { + hashtable[s]++; + } + else if (s.Length > 0 && s.Contains(' ')) + { + hashtable.Add(s, 1); + } + } + } + + private static string StripHtmlTags(string input) + { + var text = input.Trim('\'').Replace("\"", string.Empty); + + if (text.Length < 8) + { + return text; + } + + text = text.Replace("", string.Empty); + text = text.Replace("", "."); + text = text.Replace("", string.Empty); + text = text.Replace("", "."); + text = text.Replace("", string.Empty); + text = text.Replace("", "."); + text = text.Replace("", string.Empty); + text = text.Replace("", "."); + text = text.Replace("", string.Empty); + text = text.Replace("", "."); + text = text.Replace("", string.Empty); + text = text.Replace("", "."); + return text; + } + + private void CalculateWordStatistics() + { + var hashtable = new Dictionary(new StingOrdinalComparer()); + + foreach (Paragraph p in _subtitle.Paragraphs) + { + MostUsedWordsAdd(hashtable, p.Text); + _totalWords += p.Text.CountWords(); + } + + var sortedTable = new SortedDictionary(new StingOrdinalComparer()); + foreach (KeyValuePair item in hashtable) + { + if (item.Value > 1) + { + sortedTable.Add($"{item.Value:0000}" + "_" + item.Key, item.Value + ": " + item.Key); + } + } + + var sb = new StringBuilder(); + if (sortedTable.Count > 0) + { + var temp = string.Empty; + foreach (KeyValuePair item in sortedTable) + { + temp = item.Value + Environment.NewLine + temp; + } + sb.AppendLine(temp); + } + else + { + sb.AppendLine(_l.NothingFound); + } + _mostUsedWords = sb.ToString(); + } + + private void CalculateMostUsedLines() + { + var hashtable = new Dictionary(); + + foreach (Paragraph p in _subtitle.Paragraphs) + { + MostUsedLinesAdd(hashtable, p.Text.Replace(Environment.NewLine, " ").Replace(" ", " ")); + } + + var sortedTable = new SortedDictionary(new StingOrdinalComparer()); + foreach (KeyValuePair item in hashtable) + { + if (item.Value > 1) + { + sortedTable.Add($"{item.Value:0000}" + "_" + item.Key, item.Value + ": " + item.Key); + } + } + + var sb = new StringBuilder(); + if (sortedTable.Count > 0) + { + var temp = string.Empty; + foreach (KeyValuePair item in sortedTable) + { + temp = item.Value + Environment.NewLine + temp; + } + sb.AppendLine(temp); + } + else + { + sb.AppendLine(_l.NothingFound); + } + _mostUsedLines = sb.ToString(); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void buttonExport_Click(object sender, EventArgs e) + { + string preViewFileName = Path.GetFileNameWithoutExtension(_fileName) + ".Stats"; + using (var saveDialog = new SaveFileDialog { FileName = preViewFileName, Filter = Configuration.Settings.Language.Main.TextFiles + " (*.txt)|*.txt|NFO files (*.nfo)|*.nfo" }) + { + if (saveDialog.ShowDialog(this) == DialogResult.OK) + { + string fileName = saveDialog.FileName; + var statistic = string.Format(WriteFormat, _general, _mostUsedWords, _mostUsedLines); + File.WriteAllText(fileName, statistic); + } + } + } + + } +} diff --git a/src/Forms/Statistics.resx b/src/ui/Forms/Statistics.resx similarity index 97% rename from src/Forms/Statistics.resx rename to src/ui/Forms/Statistics.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/Statistics.resx +++ b/src/ui/Forms/Statistics.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/StatusLog.Designer.cs b/src/ui/Forms/StatusLog.Designer.cs similarity index 97% rename from src/Forms/StatusLog.Designer.cs rename to src/ui/Forms/StatusLog.Designer.cs index 506b7c5d7..a2f63afb1 100644 --- a/src/Forms/StatusLog.Designer.cs +++ b/src/ui/Forms/StatusLog.Designer.cs @@ -1,95 +1,95 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class StatusLog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.buttonOK = new System.Windows.Forms.Button(); - this.textBoxStatusLog = new System.Windows.Forms.TextBox(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.Location = new System.Drawing.Point(877, 407); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 1; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // textBoxStatusLog - // - this.textBoxStatusLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxStatusLog.Location = new System.Drawing.Point(13, 13); - this.textBoxStatusLog.Multiline = true; - this.textBoxStatusLog.Name = "textBoxStatusLog"; - this.textBoxStatusLog.ReadOnly = true; - this.textBoxStatusLog.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBoxStatusLog.Size = new System.Drawing.Size(939, 388); - this.textBoxStatusLog.TabIndex = 2; - // - // timer1 - // - this.timer1.Interval = 1000; - this.timer1.Tick += new System.EventHandler(this.timer1_Tick); - // - // StatusLog - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(964, 440); - this.Controls.Add(this.textBoxStatusLog); - this.Controls.Add(this.buttonOK); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(400, 200); - this.Name = "StatusLog"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Status messages"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.StatusLog_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.TextBox textBoxStatusLog; - private System.Windows.Forms.Timer timer1; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class StatusLog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonOK = new System.Windows.Forms.Button(); + this.textBoxStatusLog = new System.Windows.Forms.TextBox(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.Location = new System.Drawing.Point(877, 407); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 1; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // textBoxStatusLog + // + this.textBoxStatusLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxStatusLog.Location = new System.Drawing.Point(13, 13); + this.textBoxStatusLog.Multiline = true; + this.textBoxStatusLog.Name = "textBoxStatusLog"; + this.textBoxStatusLog.ReadOnly = true; + this.textBoxStatusLog.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBoxStatusLog.Size = new System.Drawing.Size(939, 388); + this.textBoxStatusLog.TabIndex = 2; + // + // timer1 + // + this.timer1.Interval = 1000; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // StatusLog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(964, 440); + this.Controls.Add(this.textBoxStatusLog); + this.Controls.Add(this.buttonOK); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(400, 200); + this.Name = "StatusLog"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Status messages"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.StatusLog_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.TextBox textBoxStatusLog; + private System.Windows.Forms.Timer timer1; + } } \ No newline at end of file diff --git a/src/Forms/StatusLog.cs b/src/ui/Forms/StatusLog.cs similarity index 96% rename from src/Forms/StatusLog.cs rename to src/ui/Forms/StatusLog.cs index 56cfc973f..5c561aba0 100644 --- a/src/Forms/StatusLog.cs +++ b/src/ui/Forms/StatusLog.cs @@ -1,60 +1,60 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class StatusLog : PositionAndSizeForm - { - private readonly List _log; - private int _logCount = -1; - - public StatusLog(List log) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Text = Configuration.Settings.Language.Main.StatusLog; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - _log = log; - timer1_Tick(null, null); - } - - private void StatusLog_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - buttonOK_Click(null, null); - } - else if (e.KeyCode == Keys.Delete && e.Modifiers == Keys.Control) - { - _log.Clear(); - timer1_Tick(null, null); - } - } - - private void timer1_Tick(object sender, System.EventArgs e) - { - timer1.Stop(); - if (_logCount != _log.Count) - { - _logCount = _log.Count; - var sb = new StringBuilder(); - for (int i = _logCount - 1; i >= 0; i--) - { - sb.AppendLine(_log[i]); - } - textBoxStatusLog.Text = sb.ToString(); - } - timer1.Start(); - } - - private void buttonOK_Click(object sender, System.EventArgs e) - { - Close(); - } - } +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class StatusLog : PositionAndSizeForm + { + private readonly List _log; + private int _logCount = -1; + + public StatusLog(List log) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Text = Configuration.Settings.Language.Main.StatusLog; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + _log = log; + timer1_Tick(null, null); + } + + private void StatusLog_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + buttonOK_Click(null, null); + } + else if (e.KeyCode == Keys.Delete && e.Modifiers == Keys.Control) + { + _log.Clear(); + timer1_Tick(null, null); + } + } + + private void timer1_Tick(object sender, System.EventArgs e) + { + timer1.Stop(); + if (_logCount != _log.Count) + { + _logCount = _log.Count; + var sb = new StringBuilder(); + for (int i = _logCount - 1; i >= 0; i--) + { + sb.AppendLine(_log[i]); + } + textBoxStatusLog.Text = sb.ToString(); + } + timer1.Start(); + } + + private void buttonOK_Click(object sender, System.EventArgs e) + { + Close(); + } + } } \ No newline at end of file diff --git a/src/Forms/StatusLog.resx b/src/ui/Forms/StatusLog.resx similarity index 97% rename from src/Forms/StatusLog.resx rename to src/ui/Forms/StatusLog.resx index aac33d5a2..1f666f268 100644 --- a/src/Forms/StatusLog.resx +++ b/src/ui/Forms/StatusLog.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/Styles/StylesForm.cs b/src/ui/Forms/Styles/StylesForm.cs similarity index 100% rename from src/Forms/Styles/StylesForm.cs rename to src/ui/Forms/Styles/StylesForm.cs diff --git a/src/Forms/Styles/SubStationAlphaStyles.Designer.cs b/src/ui/Forms/Styles/SubStationAlphaStyles.Designer.cs similarity index 100% rename from src/Forms/Styles/SubStationAlphaStyles.Designer.cs rename to src/ui/Forms/Styles/SubStationAlphaStyles.Designer.cs diff --git a/src/Forms/Styles/SubStationAlphaStyles.cs b/src/ui/Forms/Styles/SubStationAlphaStyles.cs similarity index 100% rename from src/Forms/Styles/SubStationAlphaStyles.cs rename to src/ui/Forms/Styles/SubStationAlphaStyles.cs diff --git a/src/Forms/Styles/SubStationAlphaStyles.resx b/src/ui/Forms/Styles/SubStationAlphaStyles.resx similarity index 100% rename from src/Forms/Styles/SubStationAlphaStyles.resx rename to src/ui/Forms/Styles/SubStationAlphaStyles.resx diff --git a/src/Forms/Styles/SubStationAlphaStylesBatchConvert.Designer.cs b/src/ui/Forms/Styles/SubStationAlphaStylesBatchConvert.Designer.cs similarity index 100% rename from src/Forms/Styles/SubStationAlphaStylesBatchConvert.Designer.cs rename to src/ui/Forms/Styles/SubStationAlphaStylesBatchConvert.Designer.cs diff --git a/src/Forms/Styles/SubStationAlphaStylesBatchConvert.cs b/src/ui/Forms/Styles/SubStationAlphaStylesBatchConvert.cs similarity index 100% rename from src/Forms/Styles/SubStationAlphaStylesBatchConvert.cs rename to src/ui/Forms/Styles/SubStationAlphaStylesBatchConvert.cs diff --git a/src/Forms/Styles/SubStationAlphaStylesBatchConvert.resx b/src/ui/Forms/Styles/SubStationAlphaStylesBatchConvert.resx similarity index 100% rename from src/Forms/Styles/SubStationAlphaStylesBatchConvert.resx rename to src/ui/Forms/Styles/SubStationAlphaStylesBatchConvert.resx diff --git a/src/Forms/Styles/SubStationAlphaStylesExport.Designer.cs b/src/ui/Forms/Styles/SubStationAlphaStylesExport.Designer.cs similarity index 100% rename from src/Forms/Styles/SubStationAlphaStylesExport.Designer.cs rename to src/ui/Forms/Styles/SubStationAlphaStylesExport.Designer.cs diff --git a/src/Forms/Styles/SubStationAlphaStylesExport.cs b/src/ui/Forms/Styles/SubStationAlphaStylesExport.cs similarity index 100% rename from src/Forms/Styles/SubStationAlphaStylesExport.cs rename to src/ui/Forms/Styles/SubStationAlphaStylesExport.cs diff --git a/src/Forms/Styles/SubStationAlphaStylesExport.resx b/src/ui/Forms/Styles/SubStationAlphaStylesExport.resx similarity index 100% rename from src/Forms/Styles/SubStationAlphaStylesExport.resx rename to src/ui/Forms/Styles/SubStationAlphaStylesExport.resx diff --git a/src/Forms/Styles/TimedTextStyles.Designer.cs b/src/ui/Forms/Styles/TimedTextStyles.Designer.cs similarity index 100% rename from src/Forms/Styles/TimedTextStyles.Designer.cs rename to src/ui/Forms/Styles/TimedTextStyles.Designer.cs diff --git a/src/Forms/Styles/TimedTextStyles.cs b/src/ui/Forms/Styles/TimedTextStyles.cs similarity index 100% rename from src/Forms/Styles/TimedTextStyles.cs rename to src/ui/Forms/Styles/TimedTextStyles.cs diff --git a/src/Forms/Styles/TimedTextStyles.resx b/src/ui/Forms/Styles/TimedTextStyles.resx similarity index 100% rename from src/Forms/Styles/TimedTextStyles.resx rename to src/ui/Forms/Styles/TimedTextStyles.resx diff --git a/src/Forms/SubStationAlphaProperties.Designer.cs b/src/ui/Forms/SubStationAlphaProperties.Designer.cs similarity index 98% rename from src/Forms/SubStationAlphaProperties.Designer.cs rename to src/ui/Forms/SubStationAlphaProperties.Designer.cs index 8ef1391a9..8c2a8a0e2 100644 --- a/src/Forms/SubStationAlphaProperties.Designer.cs +++ b/src/ui/Forms/SubStationAlphaProperties.Designer.cs @@ -1,455 +1,455 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class SubStationAlphaProperties - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBoxScript = new System.Windows.Forms.GroupBox(); - this.labelUpdateDetails = new System.Windows.Forms.Label(); - this.labelUpdatedBy = new System.Windows.Forms.Label(); - this.textBoxSyncPoint = new System.Windows.Forms.TextBox(); - this.textBoxUpdatedBy = new System.Windows.Forms.TextBox(); - this.textBoxUpdateDetails = new System.Windows.Forms.TextBox(); - this.labelSyncPoint = new System.Windows.Forms.Label(); - this.labelTiming = new System.Windows.Forms.Label(); - this.labelEditing = new System.Windows.Forms.Label(); - this.labelTranslation = new System.Windows.Forms.Label(); - this.textBoxTranslation = new System.Windows.Forms.TextBox(); - this.textBoxEditing = new System.Windows.Forms.TextBox(); - this.textBoxTiming = new System.Windows.Forms.TextBox(); - this.textBoxOriginalScript = new System.Windows.Forms.TextBox(); - this.labelOriginalScript = new System.Windows.Forms.Label(); - this.textBoxTitle = new System.Windows.Forms.TextBox(); - this.labelTitle = new System.Windows.Forms.Label(); - this.groupBoxOptions = new System.Windows.Forms.GroupBox(); - this.checkBoxScaleBorderAndShadow = new System.Windows.Forms.CheckBox(); - this.comboBoxCollision = new System.Windows.Forms.ComboBox(); - this.labelCollision = new System.Windows.Forms.Label(); - this.comboBoxWrapStyle = new System.Windows.Forms.ComboBox(); - this.labelWrapStyle = new System.Windows.Forms.Label(); - this.groupBoxResolution = new System.Windows.Forms.GroupBox(); - this.labelVideoResolution = new System.Windows.Forms.Label(); - this.numericUpDownVideoHeight = new System.Windows.Forms.NumericUpDown(); - this.buttonGetResolutionFromVideo = new System.Windows.Forms.Button(); - this.labelX = new System.Windows.Forms.Label(); - this.numericUpDownVideoWidth = new System.Windows.Forms.NumericUpDown(); - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.groupBoxScript.SuspendLayout(); - this.groupBoxOptions.SuspendLayout(); - this.groupBoxResolution.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoHeight)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoWidth)).BeginInit(); - this.SuspendLayout(); - // - // groupBoxScript - // - this.groupBoxScript.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxScript.Controls.Add(this.labelUpdateDetails); - this.groupBoxScript.Controls.Add(this.labelUpdatedBy); - this.groupBoxScript.Controls.Add(this.textBoxSyncPoint); - this.groupBoxScript.Controls.Add(this.textBoxUpdatedBy); - this.groupBoxScript.Controls.Add(this.textBoxUpdateDetails); - this.groupBoxScript.Controls.Add(this.labelSyncPoint); - this.groupBoxScript.Controls.Add(this.labelTiming); - this.groupBoxScript.Controls.Add(this.labelEditing); - this.groupBoxScript.Controls.Add(this.labelTranslation); - this.groupBoxScript.Controls.Add(this.textBoxTranslation); - this.groupBoxScript.Controls.Add(this.textBoxEditing); - this.groupBoxScript.Controls.Add(this.textBoxTiming); - this.groupBoxScript.Controls.Add(this.textBoxOriginalScript); - this.groupBoxScript.Controls.Add(this.labelOriginalScript); - this.groupBoxScript.Controls.Add(this.textBoxTitle); - this.groupBoxScript.Controls.Add(this.labelTitle); - this.groupBoxScript.Location = new System.Drawing.Point(12, 12); - this.groupBoxScript.Name = "groupBoxScript"; - this.groupBoxScript.Size = new System.Drawing.Size(471, 233); - this.groupBoxScript.TabIndex = 0; - this.groupBoxScript.TabStop = false; - this.groupBoxScript.Text = "Script"; - // - // labelUpdateDetails - // - this.labelUpdateDetails.AutoSize = true; - this.labelUpdateDetails.Location = new System.Drawing.Point(7, 205); - this.labelUpdateDetails.Name = "labelUpdateDetails"; - this.labelUpdateDetails.Size = new System.Drawing.Size(75, 13); - this.labelUpdateDetails.TabIndex = 15; - this.labelUpdateDetails.Text = "Update details"; - // - // labelUpdatedBy - // - this.labelUpdatedBy.AutoSize = true; - this.labelUpdatedBy.Location = new System.Drawing.Point(6, 179); - this.labelUpdatedBy.Name = "labelUpdatedBy"; - this.labelUpdatedBy.Size = new System.Drawing.Size(62, 13); - this.labelUpdatedBy.TabIndex = 14; - this.labelUpdatedBy.Text = "Updated by"; - // - // textBoxSyncPoint - // - this.textBoxSyncPoint.Location = new System.Drawing.Point(191, 150); - this.textBoxSyncPoint.Name = "textBoxSyncPoint"; - this.textBoxSyncPoint.Size = new System.Drawing.Size(263, 20); - this.textBoxSyncPoint.TabIndex = 5; - // - // textBoxUpdatedBy - // - this.textBoxUpdatedBy.Location = new System.Drawing.Point(191, 176); - this.textBoxUpdatedBy.Name = "textBoxUpdatedBy"; - this.textBoxUpdatedBy.Size = new System.Drawing.Size(263, 20); - this.textBoxUpdatedBy.TabIndex = 6; - // - // textBoxUpdateDetails - // - this.textBoxUpdateDetails.Location = new System.Drawing.Point(191, 202); - this.textBoxUpdateDetails.Name = "textBoxUpdateDetails"; - this.textBoxUpdateDetails.Size = new System.Drawing.Size(263, 20); - this.textBoxUpdateDetails.TabIndex = 7; - // - // labelSyncPoint - // - this.labelSyncPoint.AutoSize = true; - this.labelSyncPoint.Location = new System.Drawing.Point(6, 153); - this.labelSyncPoint.Name = "labelSyncPoint"; - this.labelSyncPoint.Size = new System.Drawing.Size(63, 13); - this.labelSyncPoint.TabIndex = 10; - this.labelSyncPoint.Text = "Synch point"; - // - // labelTiming - // - this.labelTiming.AutoSize = true; - this.labelTiming.Location = new System.Drawing.Point(6, 127); - this.labelTiming.Name = "labelTiming"; - this.labelTiming.Size = new System.Drawing.Size(38, 13); - this.labelTiming.TabIndex = 9; - this.labelTiming.Text = "Timing"; - // - // labelEditing - // - this.labelEditing.AutoSize = true; - this.labelEditing.Location = new System.Drawing.Point(6, 101); - this.labelEditing.Name = "labelEditing"; - this.labelEditing.Size = new System.Drawing.Size(39, 13); - this.labelEditing.TabIndex = 8; - this.labelEditing.Text = "Editing"; - // - // labelTranslation - // - this.labelTranslation.AutoSize = true; - this.labelTranslation.Location = new System.Drawing.Point(6, 75); - this.labelTranslation.Name = "labelTranslation"; - this.labelTranslation.Size = new System.Drawing.Size(59, 13); - this.labelTranslation.TabIndex = 7; - this.labelTranslation.Text = "Translation"; - // - // textBoxTranslation - // - this.textBoxTranslation.Location = new System.Drawing.Point(191, 72); - this.textBoxTranslation.Name = "textBoxTranslation"; - this.textBoxTranslation.Size = new System.Drawing.Size(263, 20); - this.textBoxTranslation.TabIndex = 2; - // - // textBoxEditing - // - this.textBoxEditing.Location = new System.Drawing.Point(191, 98); - this.textBoxEditing.Name = "textBoxEditing"; - this.textBoxEditing.Size = new System.Drawing.Size(263, 20); - this.textBoxEditing.TabIndex = 3; - // - // textBoxTiming - // - this.textBoxTiming.Location = new System.Drawing.Point(191, 124); - this.textBoxTiming.Name = "textBoxTiming"; - this.textBoxTiming.Size = new System.Drawing.Size(263, 20); - this.textBoxTiming.TabIndex = 4; - // - // textBoxOriginalScript - // - this.textBoxOriginalScript.Location = new System.Drawing.Point(191, 46); - this.textBoxOriginalScript.Name = "textBoxOriginalScript"; - this.textBoxOriginalScript.Size = new System.Drawing.Size(263, 20); - this.textBoxOriginalScript.TabIndex = 1; - // - // labelOriginalScript - // - this.labelOriginalScript.AutoSize = true; - this.labelOriginalScript.Location = new System.Drawing.Point(6, 49); - this.labelOriginalScript.Name = "labelOriginalScript"; - this.labelOriginalScript.Size = new System.Drawing.Size(70, 13); - this.labelOriginalScript.TabIndex = 2; - this.labelOriginalScript.Text = "Original script"; - // - // textBoxTitle - // - this.textBoxTitle.Location = new System.Drawing.Point(191, 20); - this.textBoxTitle.Name = "textBoxTitle"; - this.textBoxTitle.Size = new System.Drawing.Size(263, 20); - this.textBoxTitle.TabIndex = 0; - // - // labelTitle - // - this.labelTitle.AutoSize = true; - this.labelTitle.Location = new System.Drawing.Point(6, 23); - this.labelTitle.Name = "labelTitle"; - this.labelTitle.Size = new System.Drawing.Size(27, 13); - this.labelTitle.TabIndex = 0; - this.labelTitle.Text = "Title"; - // - // groupBoxOptions - // - this.groupBoxOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxOptions.Controls.Add(this.checkBoxScaleBorderAndShadow); - this.groupBoxOptions.Controls.Add(this.comboBoxCollision); - this.groupBoxOptions.Controls.Add(this.labelCollision); - this.groupBoxOptions.Controls.Add(this.comboBoxWrapStyle); - this.groupBoxOptions.Controls.Add(this.labelWrapStyle); - this.groupBoxOptions.Location = new System.Drawing.Point(12, 314); - this.groupBoxOptions.Name = "groupBoxOptions"; - this.groupBoxOptions.Size = new System.Drawing.Size(471, 100); - this.groupBoxOptions.TabIndex = 2; - this.groupBoxOptions.TabStop = false; - this.groupBoxOptions.Text = "Options"; - // - // checkBoxScaleBorderAndShadow - // - this.checkBoxScaleBorderAndShadow.AutoSize = true; - this.checkBoxScaleBorderAndShadow.Location = new System.Drawing.Point(191, 70); - this.checkBoxScaleBorderAndShadow.Name = "checkBoxScaleBorderAndShadow"; - this.checkBoxScaleBorderAndShadow.Size = new System.Drawing.Size(147, 17); - this.checkBoxScaleBorderAndShadow.TabIndex = 2; - this.checkBoxScaleBorderAndShadow.Text = "Scale border and shadow"; - this.checkBoxScaleBorderAndShadow.UseVisualStyleBackColor = true; - // - // comboBoxCollision - // - this.comboBoxCollision.FormattingEnabled = true; - this.comboBoxCollision.Items.AddRange(new object[] { - "Normal", - "Reverse"}); - this.comboBoxCollision.Location = new System.Drawing.Point(191, 16); - this.comboBoxCollision.Name = "comboBoxCollision"; - this.comboBoxCollision.Size = new System.Drawing.Size(263, 21); - this.comboBoxCollision.TabIndex = 0; - // - // labelCollision - // - this.labelCollision.AutoSize = true; - this.labelCollision.Location = new System.Drawing.Point(6, 19); - this.labelCollision.Name = "labelCollision"; - this.labelCollision.Size = new System.Drawing.Size(45, 13); - this.labelCollision.TabIndex = 3; - this.labelCollision.Text = "Collision"; - // - // comboBoxWrapStyle - // - this.comboBoxWrapStyle.FormattingEnabled = true; - this.comboBoxWrapStyle.Items.AddRange(new object[] { - "0: Smart wrapping, top line is wider", - "1: End-of-line word wrapping, only \\N breaks", - "2: No word wrapping, both \\n and \\N break", - "3: Smart wrapping, bottom line is wider"}); - this.comboBoxWrapStyle.Location = new System.Drawing.Point(191, 43); - this.comboBoxWrapStyle.Name = "comboBoxWrapStyle"; - this.comboBoxWrapStyle.Size = new System.Drawing.Size(263, 21); - this.comboBoxWrapStyle.TabIndex = 1; - // - // labelWrapStyle - // - this.labelWrapStyle.AutoSize = true; - this.labelWrapStyle.Location = new System.Drawing.Point(6, 46); - this.labelWrapStyle.Name = "labelWrapStyle"; - this.labelWrapStyle.Size = new System.Drawing.Size(57, 13); - this.labelWrapStyle.TabIndex = 1; - this.labelWrapStyle.Text = "Wrap style"; - // - // groupBoxResolution - // - this.groupBoxResolution.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxResolution.Controls.Add(this.labelVideoResolution); - this.groupBoxResolution.Controls.Add(this.numericUpDownVideoHeight); - this.groupBoxResolution.Controls.Add(this.buttonGetResolutionFromVideo); - this.groupBoxResolution.Controls.Add(this.labelX); - this.groupBoxResolution.Controls.Add(this.numericUpDownVideoWidth); - this.groupBoxResolution.Location = new System.Drawing.Point(12, 251); - this.groupBoxResolution.Name = "groupBoxResolution"; - this.groupBoxResolution.Size = new System.Drawing.Size(471, 57); - this.groupBoxResolution.TabIndex = 1; - this.groupBoxResolution.TabStop = false; - this.groupBoxResolution.Text = "Resolution"; - // - // labelVideoResolution - // - this.labelVideoResolution.AutoSize = true; - this.labelVideoResolution.Location = new System.Drawing.Point(7, 21); - this.labelVideoResolution.Name = "labelVideoResolution"; - this.labelVideoResolution.Size = new System.Drawing.Size(82, 13); - this.labelVideoResolution.TabIndex = 16; - this.labelVideoResolution.Text = "Video resolution"; - // - // numericUpDownVideoHeight - // - this.numericUpDownVideoHeight.Location = new System.Drawing.Point(264, 19); - this.numericUpDownVideoHeight.Maximum = new decimal(new int[] { - 10000, - 0, - 0, - 0}); - this.numericUpDownVideoHeight.Name = "numericUpDownVideoHeight"; - this.numericUpDownVideoHeight.Size = new System.Drawing.Size(47, 20); - this.numericUpDownVideoHeight.TabIndex = 1; - // - // buttonGetResolutionFromVideo - // - this.buttonGetResolutionFromVideo.Location = new System.Drawing.Point(317, 17); - this.buttonGetResolutionFromVideo.Name = "buttonGetResolutionFromVideo"; - this.buttonGetResolutionFromVideo.Size = new System.Drawing.Size(27, 23); - this.buttonGetResolutionFromVideo.TabIndex = 2; - this.buttonGetResolutionFromVideo.Text = "..."; - this.buttonGetResolutionFromVideo.UseVisualStyleBackColor = true; - this.buttonGetResolutionFromVideo.Click += new System.EventHandler(this.buttonGetResolutionFromVideo_Click); - // - // labelX - // - this.labelX.AutoSize = true; - this.labelX.Location = new System.Drawing.Point(244, 21); - this.labelX.Name = "labelX"; - this.labelX.Size = new System.Drawing.Size(14, 13); - this.labelX.TabIndex = 2; - this.labelX.Text = "X"; - // - // numericUpDownVideoWidth - // - this.numericUpDownVideoWidth.Location = new System.Drawing.Point(191, 19); - this.numericUpDownVideoWidth.Maximum = new decimal(new int[] { - 10000, - 0, - 0, - 0}); - this.numericUpDownVideoWidth.Name = "numericUpDownVideoWidth"; - this.numericUpDownVideoWidth.Size = new System.Drawing.Size(47, 20); - this.numericUpDownVideoWidth.TabIndex = 0; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(327, 427); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(409, 427); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // SubStationAlphaProperties - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(498, 460); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.groupBoxResolution); - this.Controls.Add(this.groupBoxOptions); - this.Controls.Add(this.groupBoxScript); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.Name = "SubStationAlphaProperties"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Sub Station Alpha properties"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SubStationAlphaProperties_KeyDown); - this.groupBoxScript.ResumeLayout(false); - this.groupBoxScript.PerformLayout(); - this.groupBoxOptions.ResumeLayout(false); - this.groupBoxOptions.PerformLayout(); - this.groupBoxResolution.ResumeLayout(false); - this.groupBoxResolution.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoHeight)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoWidth)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxScript; - private System.Windows.Forms.GroupBox groupBoxOptions; - private System.Windows.Forms.Label labelUpdateDetails; - private System.Windows.Forms.Label labelUpdatedBy; - private System.Windows.Forms.TextBox textBoxSyncPoint; - private System.Windows.Forms.TextBox textBoxUpdatedBy; - private System.Windows.Forms.TextBox textBoxUpdateDetails; - private System.Windows.Forms.Label labelSyncPoint; - private System.Windows.Forms.Label labelTiming; - private System.Windows.Forms.Label labelEditing; - private System.Windows.Forms.Label labelTranslation; - private System.Windows.Forms.TextBox textBoxTranslation; - private System.Windows.Forms.TextBox textBoxEditing; - private System.Windows.Forms.TextBox textBoxTiming; - private System.Windows.Forms.TextBox textBoxOriginalScript; - private System.Windows.Forms.Label labelOriginalScript; - private System.Windows.Forms.TextBox textBoxTitle; - private System.Windows.Forms.Label labelTitle; - private System.Windows.Forms.CheckBox checkBoxScaleBorderAndShadow; - private System.Windows.Forms.ComboBox comboBoxCollision; - private System.Windows.Forms.Label labelCollision; - private System.Windows.Forms.ComboBox comboBoxWrapStyle; - private System.Windows.Forms.Label labelWrapStyle; - private System.Windows.Forms.GroupBox groupBoxResolution; - private System.Windows.Forms.Label labelVideoResolution; - private System.Windows.Forms.NumericUpDown numericUpDownVideoHeight; - private System.Windows.Forms.Button buttonGetResolutionFromVideo; - private System.Windows.Forms.Label labelX; - private System.Windows.Forms.NumericUpDown numericUpDownVideoWidth; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class SubStationAlphaProperties + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBoxScript = new System.Windows.Forms.GroupBox(); + this.labelUpdateDetails = new System.Windows.Forms.Label(); + this.labelUpdatedBy = new System.Windows.Forms.Label(); + this.textBoxSyncPoint = new System.Windows.Forms.TextBox(); + this.textBoxUpdatedBy = new System.Windows.Forms.TextBox(); + this.textBoxUpdateDetails = new System.Windows.Forms.TextBox(); + this.labelSyncPoint = new System.Windows.Forms.Label(); + this.labelTiming = new System.Windows.Forms.Label(); + this.labelEditing = new System.Windows.Forms.Label(); + this.labelTranslation = new System.Windows.Forms.Label(); + this.textBoxTranslation = new System.Windows.Forms.TextBox(); + this.textBoxEditing = new System.Windows.Forms.TextBox(); + this.textBoxTiming = new System.Windows.Forms.TextBox(); + this.textBoxOriginalScript = new System.Windows.Forms.TextBox(); + this.labelOriginalScript = new System.Windows.Forms.Label(); + this.textBoxTitle = new System.Windows.Forms.TextBox(); + this.labelTitle = new System.Windows.Forms.Label(); + this.groupBoxOptions = new System.Windows.Forms.GroupBox(); + this.checkBoxScaleBorderAndShadow = new System.Windows.Forms.CheckBox(); + this.comboBoxCollision = new System.Windows.Forms.ComboBox(); + this.labelCollision = new System.Windows.Forms.Label(); + this.comboBoxWrapStyle = new System.Windows.Forms.ComboBox(); + this.labelWrapStyle = new System.Windows.Forms.Label(); + this.groupBoxResolution = new System.Windows.Forms.GroupBox(); + this.labelVideoResolution = new System.Windows.Forms.Label(); + this.numericUpDownVideoHeight = new System.Windows.Forms.NumericUpDown(); + this.buttonGetResolutionFromVideo = new System.Windows.Forms.Button(); + this.labelX = new System.Windows.Forms.Label(); + this.numericUpDownVideoWidth = new System.Windows.Forms.NumericUpDown(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.groupBoxScript.SuspendLayout(); + this.groupBoxOptions.SuspendLayout(); + this.groupBoxResolution.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoHeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoWidth)).BeginInit(); + this.SuspendLayout(); + // + // groupBoxScript + // + this.groupBoxScript.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxScript.Controls.Add(this.labelUpdateDetails); + this.groupBoxScript.Controls.Add(this.labelUpdatedBy); + this.groupBoxScript.Controls.Add(this.textBoxSyncPoint); + this.groupBoxScript.Controls.Add(this.textBoxUpdatedBy); + this.groupBoxScript.Controls.Add(this.textBoxUpdateDetails); + this.groupBoxScript.Controls.Add(this.labelSyncPoint); + this.groupBoxScript.Controls.Add(this.labelTiming); + this.groupBoxScript.Controls.Add(this.labelEditing); + this.groupBoxScript.Controls.Add(this.labelTranslation); + this.groupBoxScript.Controls.Add(this.textBoxTranslation); + this.groupBoxScript.Controls.Add(this.textBoxEditing); + this.groupBoxScript.Controls.Add(this.textBoxTiming); + this.groupBoxScript.Controls.Add(this.textBoxOriginalScript); + this.groupBoxScript.Controls.Add(this.labelOriginalScript); + this.groupBoxScript.Controls.Add(this.textBoxTitle); + this.groupBoxScript.Controls.Add(this.labelTitle); + this.groupBoxScript.Location = new System.Drawing.Point(12, 12); + this.groupBoxScript.Name = "groupBoxScript"; + this.groupBoxScript.Size = new System.Drawing.Size(471, 233); + this.groupBoxScript.TabIndex = 0; + this.groupBoxScript.TabStop = false; + this.groupBoxScript.Text = "Script"; + // + // labelUpdateDetails + // + this.labelUpdateDetails.AutoSize = true; + this.labelUpdateDetails.Location = new System.Drawing.Point(7, 205); + this.labelUpdateDetails.Name = "labelUpdateDetails"; + this.labelUpdateDetails.Size = new System.Drawing.Size(75, 13); + this.labelUpdateDetails.TabIndex = 15; + this.labelUpdateDetails.Text = "Update details"; + // + // labelUpdatedBy + // + this.labelUpdatedBy.AutoSize = true; + this.labelUpdatedBy.Location = new System.Drawing.Point(6, 179); + this.labelUpdatedBy.Name = "labelUpdatedBy"; + this.labelUpdatedBy.Size = new System.Drawing.Size(62, 13); + this.labelUpdatedBy.TabIndex = 14; + this.labelUpdatedBy.Text = "Updated by"; + // + // textBoxSyncPoint + // + this.textBoxSyncPoint.Location = new System.Drawing.Point(191, 150); + this.textBoxSyncPoint.Name = "textBoxSyncPoint"; + this.textBoxSyncPoint.Size = new System.Drawing.Size(263, 20); + this.textBoxSyncPoint.TabIndex = 5; + // + // textBoxUpdatedBy + // + this.textBoxUpdatedBy.Location = new System.Drawing.Point(191, 176); + this.textBoxUpdatedBy.Name = "textBoxUpdatedBy"; + this.textBoxUpdatedBy.Size = new System.Drawing.Size(263, 20); + this.textBoxUpdatedBy.TabIndex = 6; + // + // textBoxUpdateDetails + // + this.textBoxUpdateDetails.Location = new System.Drawing.Point(191, 202); + this.textBoxUpdateDetails.Name = "textBoxUpdateDetails"; + this.textBoxUpdateDetails.Size = new System.Drawing.Size(263, 20); + this.textBoxUpdateDetails.TabIndex = 7; + // + // labelSyncPoint + // + this.labelSyncPoint.AutoSize = true; + this.labelSyncPoint.Location = new System.Drawing.Point(6, 153); + this.labelSyncPoint.Name = "labelSyncPoint"; + this.labelSyncPoint.Size = new System.Drawing.Size(63, 13); + this.labelSyncPoint.TabIndex = 10; + this.labelSyncPoint.Text = "Synch point"; + // + // labelTiming + // + this.labelTiming.AutoSize = true; + this.labelTiming.Location = new System.Drawing.Point(6, 127); + this.labelTiming.Name = "labelTiming"; + this.labelTiming.Size = new System.Drawing.Size(38, 13); + this.labelTiming.TabIndex = 9; + this.labelTiming.Text = "Timing"; + // + // labelEditing + // + this.labelEditing.AutoSize = true; + this.labelEditing.Location = new System.Drawing.Point(6, 101); + this.labelEditing.Name = "labelEditing"; + this.labelEditing.Size = new System.Drawing.Size(39, 13); + this.labelEditing.TabIndex = 8; + this.labelEditing.Text = "Editing"; + // + // labelTranslation + // + this.labelTranslation.AutoSize = true; + this.labelTranslation.Location = new System.Drawing.Point(6, 75); + this.labelTranslation.Name = "labelTranslation"; + this.labelTranslation.Size = new System.Drawing.Size(59, 13); + this.labelTranslation.TabIndex = 7; + this.labelTranslation.Text = "Translation"; + // + // textBoxTranslation + // + this.textBoxTranslation.Location = new System.Drawing.Point(191, 72); + this.textBoxTranslation.Name = "textBoxTranslation"; + this.textBoxTranslation.Size = new System.Drawing.Size(263, 20); + this.textBoxTranslation.TabIndex = 2; + // + // textBoxEditing + // + this.textBoxEditing.Location = new System.Drawing.Point(191, 98); + this.textBoxEditing.Name = "textBoxEditing"; + this.textBoxEditing.Size = new System.Drawing.Size(263, 20); + this.textBoxEditing.TabIndex = 3; + // + // textBoxTiming + // + this.textBoxTiming.Location = new System.Drawing.Point(191, 124); + this.textBoxTiming.Name = "textBoxTiming"; + this.textBoxTiming.Size = new System.Drawing.Size(263, 20); + this.textBoxTiming.TabIndex = 4; + // + // textBoxOriginalScript + // + this.textBoxOriginalScript.Location = new System.Drawing.Point(191, 46); + this.textBoxOriginalScript.Name = "textBoxOriginalScript"; + this.textBoxOriginalScript.Size = new System.Drawing.Size(263, 20); + this.textBoxOriginalScript.TabIndex = 1; + // + // labelOriginalScript + // + this.labelOriginalScript.AutoSize = true; + this.labelOriginalScript.Location = new System.Drawing.Point(6, 49); + this.labelOriginalScript.Name = "labelOriginalScript"; + this.labelOriginalScript.Size = new System.Drawing.Size(70, 13); + this.labelOriginalScript.TabIndex = 2; + this.labelOriginalScript.Text = "Original script"; + // + // textBoxTitle + // + this.textBoxTitle.Location = new System.Drawing.Point(191, 20); + this.textBoxTitle.Name = "textBoxTitle"; + this.textBoxTitle.Size = new System.Drawing.Size(263, 20); + this.textBoxTitle.TabIndex = 0; + // + // labelTitle + // + this.labelTitle.AutoSize = true; + this.labelTitle.Location = new System.Drawing.Point(6, 23); + this.labelTitle.Name = "labelTitle"; + this.labelTitle.Size = new System.Drawing.Size(27, 13); + this.labelTitle.TabIndex = 0; + this.labelTitle.Text = "Title"; + // + // groupBoxOptions + // + this.groupBoxOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxOptions.Controls.Add(this.checkBoxScaleBorderAndShadow); + this.groupBoxOptions.Controls.Add(this.comboBoxCollision); + this.groupBoxOptions.Controls.Add(this.labelCollision); + this.groupBoxOptions.Controls.Add(this.comboBoxWrapStyle); + this.groupBoxOptions.Controls.Add(this.labelWrapStyle); + this.groupBoxOptions.Location = new System.Drawing.Point(12, 314); + this.groupBoxOptions.Name = "groupBoxOptions"; + this.groupBoxOptions.Size = new System.Drawing.Size(471, 100); + this.groupBoxOptions.TabIndex = 2; + this.groupBoxOptions.TabStop = false; + this.groupBoxOptions.Text = "Options"; + // + // checkBoxScaleBorderAndShadow + // + this.checkBoxScaleBorderAndShadow.AutoSize = true; + this.checkBoxScaleBorderAndShadow.Location = new System.Drawing.Point(191, 70); + this.checkBoxScaleBorderAndShadow.Name = "checkBoxScaleBorderAndShadow"; + this.checkBoxScaleBorderAndShadow.Size = new System.Drawing.Size(147, 17); + this.checkBoxScaleBorderAndShadow.TabIndex = 2; + this.checkBoxScaleBorderAndShadow.Text = "Scale border and shadow"; + this.checkBoxScaleBorderAndShadow.UseVisualStyleBackColor = true; + // + // comboBoxCollision + // + this.comboBoxCollision.FormattingEnabled = true; + this.comboBoxCollision.Items.AddRange(new object[] { + "Normal", + "Reverse"}); + this.comboBoxCollision.Location = new System.Drawing.Point(191, 16); + this.comboBoxCollision.Name = "comboBoxCollision"; + this.comboBoxCollision.Size = new System.Drawing.Size(263, 21); + this.comboBoxCollision.TabIndex = 0; + // + // labelCollision + // + this.labelCollision.AutoSize = true; + this.labelCollision.Location = new System.Drawing.Point(6, 19); + this.labelCollision.Name = "labelCollision"; + this.labelCollision.Size = new System.Drawing.Size(45, 13); + this.labelCollision.TabIndex = 3; + this.labelCollision.Text = "Collision"; + // + // comboBoxWrapStyle + // + this.comboBoxWrapStyle.FormattingEnabled = true; + this.comboBoxWrapStyle.Items.AddRange(new object[] { + "0: Smart wrapping, top line is wider", + "1: End-of-line word wrapping, only \\N breaks", + "2: No word wrapping, both \\n and \\N break", + "3: Smart wrapping, bottom line is wider"}); + this.comboBoxWrapStyle.Location = new System.Drawing.Point(191, 43); + this.comboBoxWrapStyle.Name = "comboBoxWrapStyle"; + this.comboBoxWrapStyle.Size = new System.Drawing.Size(263, 21); + this.comboBoxWrapStyle.TabIndex = 1; + // + // labelWrapStyle + // + this.labelWrapStyle.AutoSize = true; + this.labelWrapStyle.Location = new System.Drawing.Point(6, 46); + this.labelWrapStyle.Name = "labelWrapStyle"; + this.labelWrapStyle.Size = new System.Drawing.Size(57, 13); + this.labelWrapStyle.TabIndex = 1; + this.labelWrapStyle.Text = "Wrap style"; + // + // groupBoxResolution + // + this.groupBoxResolution.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxResolution.Controls.Add(this.labelVideoResolution); + this.groupBoxResolution.Controls.Add(this.numericUpDownVideoHeight); + this.groupBoxResolution.Controls.Add(this.buttonGetResolutionFromVideo); + this.groupBoxResolution.Controls.Add(this.labelX); + this.groupBoxResolution.Controls.Add(this.numericUpDownVideoWidth); + this.groupBoxResolution.Location = new System.Drawing.Point(12, 251); + this.groupBoxResolution.Name = "groupBoxResolution"; + this.groupBoxResolution.Size = new System.Drawing.Size(471, 57); + this.groupBoxResolution.TabIndex = 1; + this.groupBoxResolution.TabStop = false; + this.groupBoxResolution.Text = "Resolution"; + // + // labelVideoResolution + // + this.labelVideoResolution.AutoSize = true; + this.labelVideoResolution.Location = new System.Drawing.Point(7, 21); + this.labelVideoResolution.Name = "labelVideoResolution"; + this.labelVideoResolution.Size = new System.Drawing.Size(82, 13); + this.labelVideoResolution.TabIndex = 16; + this.labelVideoResolution.Text = "Video resolution"; + // + // numericUpDownVideoHeight + // + this.numericUpDownVideoHeight.Location = new System.Drawing.Point(264, 19); + this.numericUpDownVideoHeight.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.numericUpDownVideoHeight.Name = "numericUpDownVideoHeight"; + this.numericUpDownVideoHeight.Size = new System.Drawing.Size(47, 20); + this.numericUpDownVideoHeight.TabIndex = 1; + // + // buttonGetResolutionFromVideo + // + this.buttonGetResolutionFromVideo.Location = new System.Drawing.Point(317, 17); + this.buttonGetResolutionFromVideo.Name = "buttonGetResolutionFromVideo"; + this.buttonGetResolutionFromVideo.Size = new System.Drawing.Size(27, 23); + this.buttonGetResolutionFromVideo.TabIndex = 2; + this.buttonGetResolutionFromVideo.Text = "..."; + this.buttonGetResolutionFromVideo.UseVisualStyleBackColor = true; + this.buttonGetResolutionFromVideo.Click += new System.EventHandler(this.buttonGetResolutionFromVideo_Click); + // + // labelX + // + this.labelX.AutoSize = true; + this.labelX.Location = new System.Drawing.Point(244, 21); + this.labelX.Name = "labelX"; + this.labelX.Size = new System.Drawing.Size(14, 13); + this.labelX.TabIndex = 2; + this.labelX.Text = "X"; + // + // numericUpDownVideoWidth + // + this.numericUpDownVideoWidth.Location = new System.Drawing.Point(191, 19); + this.numericUpDownVideoWidth.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.numericUpDownVideoWidth.Name = "numericUpDownVideoWidth"; + this.numericUpDownVideoWidth.Size = new System.Drawing.Size(47, 20); + this.numericUpDownVideoWidth.TabIndex = 0; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(327, 427); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(409, 427); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // SubStationAlphaProperties + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(498, 460); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.groupBoxResolution); + this.Controls.Add(this.groupBoxOptions); + this.Controls.Add(this.groupBoxScript); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.Name = "SubStationAlphaProperties"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Sub Station Alpha properties"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SubStationAlphaProperties_KeyDown); + this.groupBoxScript.ResumeLayout(false); + this.groupBoxScript.PerformLayout(); + this.groupBoxOptions.ResumeLayout(false); + this.groupBoxOptions.PerformLayout(); + this.groupBoxResolution.ResumeLayout(false); + this.groupBoxResolution.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoHeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownVideoWidth)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxScript; + private System.Windows.Forms.GroupBox groupBoxOptions; + private System.Windows.Forms.Label labelUpdateDetails; + private System.Windows.Forms.Label labelUpdatedBy; + private System.Windows.Forms.TextBox textBoxSyncPoint; + private System.Windows.Forms.TextBox textBoxUpdatedBy; + private System.Windows.Forms.TextBox textBoxUpdateDetails; + private System.Windows.Forms.Label labelSyncPoint; + private System.Windows.Forms.Label labelTiming; + private System.Windows.Forms.Label labelEditing; + private System.Windows.Forms.Label labelTranslation; + private System.Windows.Forms.TextBox textBoxTranslation; + private System.Windows.Forms.TextBox textBoxEditing; + private System.Windows.Forms.TextBox textBoxTiming; + private System.Windows.Forms.TextBox textBoxOriginalScript; + private System.Windows.Forms.Label labelOriginalScript; + private System.Windows.Forms.TextBox textBoxTitle; + private System.Windows.Forms.Label labelTitle; + private System.Windows.Forms.CheckBox checkBoxScaleBorderAndShadow; + private System.Windows.Forms.ComboBox comboBoxCollision; + private System.Windows.Forms.Label labelCollision; + private System.Windows.Forms.ComboBox comboBoxWrapStyle; + private System.Windows.Forms.Label labelWrapStyle; + private System.Windows.Forms.GroupBox groupBoxResolution; + private System.Windows.Forms.Label labelVideoResolution; + private System.Windows.Forms.NumericUpDown numericUpDownVideoHeight; + private System.Windows.Forms.Button buttonGetResolutionFromVideo; + private System.Windows.Forms.Label labelX; + private System.Windows.Forms.NumericUpDown numericUpDownVideoWidth; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + } } \ No newline at end of file diff --git a/src/Forms/SubStationAlphaProperties.cs b/src/ui/Forms/SubStationAlphaProperties.cs similarity index 97% rename from src/Forms/SubStationAlphaProperties.cs rename to src/ui/Forms/SubStationAlphaProperties.cs index c4dd4e8be..de7cb910c 100644 --- a/src/Forms/SubStationAlphaProperties.cs +++ b/src/ui/Forms/SubStationAlphaProperties.cs @@ -1,309 +1,309 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Globalization; -using System.IO; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class SubStationAlphaProperties : PositionAndSizeForm - { - private readonly Subtitle _subtitle; - private readonly bool _isSubStationAlpha; - private readonly string _videoFileName; - - public SubStationAlphaProperties(Subtitle subtitle, SubtitleFormat format, string videoFileName, string subtitleFileName) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _subtitle = subtitle; - _isSubStationAlpha = format.Name == SubStationAlpha.NameOfFormat; - _videoFileName = videoFileName; - - var l = Configuration.Settings.Language.SubStationAlphaProperties; - if (_isSubStationAlpha) - { - Text = l.TitleSubstationAlpha; - labelWrapStyle.Visible = false; - comboBoxWrapStyle.Visible = false; - checkBoxScaleBorderAndShadow.Visible = false; - Height = Height - (comboBoxWrapStyle.Height + checkBoxScaleBorderAndShadow.Height + 8); - } - else - { - Text = l.Title; - } - - comboBoxWrapStyle.SelectedIndex = 2; - comboBoxCollision.SelectedIndex = 0; - - string header = subtitle.Header; - if (subtitle.Header == null) - { - var ssa = new SubStationAlpha(); - var sub = new Subtitle(); - var lines = subtitle.ToText(ssa).SplitToLines(); - string title = "Untitled"; - if (!string.IsNullOrEmpty(subtitleFileName)) - { - title = Path.GetFileNameWithoutExtension(subtitleFileName); - } - else if (!string.IsNullOrEmpty(videoFileName)) - { - title = Path.GetFileNameWithoutExtension(videoFileName); - } - - ssa.LoadSubtitle(sub, lines, title); - header = sub.Header; - } - - if (header != null) - { - foreach (string line in header.SplitToLines()) - { - string s = line.ToLowerInvariant().Trim(); - if (s.StartsWith("title:", StringComparison.Ordinal)) - { - textBoxTitle.Text = s.Remove(0, 6).Trim(); - } - else if (s.StartsWith("original script:", StringComparison.Ordinal)) - { - textBoxOriginalScript.Text = s.Remove(0, 16).Trim(); - } - else if (s.StartsWith("original translation:", StringComparison.Ordinal)) - { - textBoxTranslation.Text = s.Remove(0, 21).Trim(); - } - else if (s.StartsWith("original editing:", StringComparison.Ordinal)) - { - textBoxEditing.Text = s.Remove(0, 17).Trim(); - } - else if (s.StartsWith("original timing:", StringComparison.Ordinal)) - { - textBoxTiming.Text = s.Remove(0, 16).Trim(); - } - else if (s.StartsWith("synch point:", StringComparison.Ordinal)) - { - textBoxSyncPoint.Text = s.Remove(0, 12).Trim(); - } - else if (s.StartsWith("script updated by:", StringComparison.Ordinal)) - { - textBoxUpdatedBy.Text = s.Remove(0, 18).Trim(); - } - else if (s.StartsWith("update details:", StringComparison.Ordinal)) - { - textBoxUpdateDetails.Text = s.Remove(0, 15).Trim(); - } - else if (s.StartsWith("collisions:", StringComparison.Ordinal)) - { - if (s.Remove(0, 11).Trim() == "reverse") - { - comboBoxCollision.SelectedIndex = 1; - } - } - else if (s.StartsWith("playresx:", StringComparison.Ordinal)) - { - if (int.TryParse(s.Remove(0, 9).Trim(), out var number)) - { - numericUpDownVideoWidth.Value = number; - } - } - else if (s.StartsWith("playresy:", StringComparison.Ordinal)) - { - if (int.TryParse(s.Remove(0, 9).Trim(), out var number)) - { - numericUpDownVideoHeight.Value = number; - } - } - else if (s.StartsWith("scaledborderandshadow:", StringComparison.Ordinal)) - { - checkBoxScaleBorderAndShadow.Checked = s.Remove(0, 22).Trim().ToLowerInvariant().Equals("yes"); - } - else if (s.StartsWith("wrapstyle:", StringComparison.Ordinal)) - { - var wrapStyle = s.Remove(0, 10).Trim(); - for (int i = 0; i < comboBoxWrapStyle.Items.Count; i++) - { - if (i.ToString(CultureInfo.InvariantCulture) == wrapStyle) - { - comboBoxWrapStyle.SelectedIndex = i; - } - } - } - } - } - - groupBoxScript.Text = l.Script; - labelTitle.Text = l.ScriptTitle; - labelOriginalScript.Text = l.OriginalScript; - labelTranslation.Text = l.Translation; - labelEditing.Text = l.Editing; - labelTiming.Text = l.Timing; - labelSyncPoint.Text = l.SyncPoint; - labelUpdatedBy.Text = l.UpdatedBy; - labelUpdateDetails.Text = l.UpdateDetails; - groupBoxResolution.Text = l.Resolution; - labelVideoResolution.Text = l.VideoResolution; - groupBoxOptions.Text = l.Options; - labelCollision.Text = l.Collision; - labelWrapStyle.Text = l.WrapStyle; - checkBoxScaleBorderAndShadow.Text = l.ScaleBorderAndShadow; - - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - - UiUtil.FixLargeFonts(this, buttonCancel); - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private string GetDefaultHeader() - { - SubtitleFormat format; - if (_isSubStationAlpha) - { - format = new SubStationAlpha(); - } - else - { - format = new AdvancedSubStationAlpha(); - } - - var sub = new Subtitle(); - string text = format.ToText(sub, string.Empty); - var lines = text.SplitToLines(); - format.LoadSubtitle(sub, lines, string.Empty); - return sub.Header.Trim(); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - if (_subtitle.Header == null || !_subtitle.Header.Contains("[script info]", StringComparison.OrdinalIgnoreCase)) - { - _subtitle.Header = GetDefaultHeader(); - } - - string title = textBoxTitle.Text; - if (string.IsNullOrWhiteSpace(title)) - { - title = "untitled"; - } - - UpdateTag("Title", title, false); - UpdateTag("Original Script", textBoxOriginalScript.Text, string.IsNullOrWhiteSpace(textBoxOriginalScript.Text)); - UpdateTag("Original Translation", textBoxTranslation.Text, string.IsNullOrWhiteSpace(textBoxTranslation.Text)); - UpdateTag("Original Editing", textBoxEditing.Text, string.IsNullOrWhiteSpace(textBoxEditing.Text)); - UpdateTag("Original Timing", textBoxTiming.Text, string.IsNullOrWhiteSpace(textBoxTiming.Text)); - UpdateTag("Synch Point", textBoxSyncPoint.Text, string.IsNullOrWhiteSpace(textBoxSyncPoint.Text)); - UpdateTag("Script Updated By", textBoxUpdatedBy.Text, string.IsNullOrWhiteSpace(textBoxUpdatedBy.Text)); - UpdateTag("Update Details", textBoxUpdateDetails.Text, string.IsNullOrWhiteSpace(textBoxUpdateDetails.Text)); - UpdateTag("PlayResX", numericUpDownVideoWidth.Value.ToString(CultureInfo.InvariantCulture), numericUpDownVideoWidth.Value == 0); - UpdateTag("PlayResY", numericUpDownVideoHeight.Value.ToString(CultureInfo.InvariantCulture), numericUpDownVideoHeight.Value == 0); - if (comboBoxCollision.SelectedIndex == 0) - { - UpdateTag("collisions", "Normal", false); // normal - } - else - { - UpdateTag("collisions", "Reverse", false); // reverse - } - - if (!_isSubStationAlpha) - { - UpdateTag("WrapStyle", comboBoxWrapStyle.SelectedIndex.ToString(CultureInfo.InvariantCulture), false); - if (checkBoxScaleBorderAndShadow.Checked) - { - UpdateTag("ScaledBorderAndShadow", "Yes", false); - } - else - { - UpdateTag("ScaledBorderAndShadow", "No", false); - } - } - - DialogResult = DialogResult.OK; - } - - private void UpdateTag(string tag, string text, bool remove) - { - bool scriptInfoOn = false; - var sb = new StringBuilder(); - bool found = false; - foreach (string line in _subtitle.Header.SplitToLines()) - { - if (line.StartsWith("[script info]", StringComparison.OrdinalIgnoreCase)) - { - scriptInfoOn = true; - } - else if (line.StartsWith('[')) - { - if (!found && scriptInfoOn && !remove) - { - sb = new StringBuilder(sb.ToString().Trim() + Environment.NewLine); - sb.AppendLine(tag + ": " + text); - } - sb = new StringBuilder(sb.ToString().TrimEnd()); - sb.AppendLine(); - sb.AppendLine(); - scriptInfoOn = false; - } - - string s = line.ToLowerInvariant(); - if (s.StartsWith(tag.ToLowerInvariant() + ":", StringComparison.Ordinal)) - { - if (!remove) - { - sb.AppendLine(line.Substring(0, tag.Length) + ": " + text); - } - - found = true; - } - else - { - sb.AppendLine(line); - } - } - _subtitle.Header = sb.ToString().Trim(); - } - - private void SubStationAlphaProperties_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void buttonGetResolutionFromVideo_Click(object sender, EventArgs e) - { - openFileDialog1.Title = Configuration.Settings.Language.General.OpenVideoFileTitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = Utilities.GetVideoFileFilter(false); - openFileDialog1.FileName = string.Empty; - if (string.IsNullOrEmpty(openFileDialog1.InitialDirectory) && !string.IsNullOrEmpty(_videoFileName)) - { - openFileDialog1.InitialDirectory = Path.GetDirectoryName(_videoFileName); - openFileDialog1.FileName = Path.GetFileName(_videoFileName); - } - - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - VideoInfo info = UiUtil.GetVideoInfo(openFileDialog1.FileName); - if (info != null && info.Success) - { - numericUpDownVideoWidth.Value = info.Width; - numericUpDownVideoHeight.Value = info.Height; - } - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Globalization; +using System.IO; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class SubStationAlphaProperties : PositionAndSizeForm + { + private readonly Subtitle _subtitle; + private readonly bool _isSubStationAlpha; + private readonly string _videoFileName; + + public SubStationAlphaProperties(Subtitle subtitle, SubtitleFormat format, string videoFileName, string subtitleFileName) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _subtitle = subtitle; + _isSubStationAlpha = format.Name == SubStationAlpha.NameOfFormat; + _videoFileName = videoFileName; + + var l = Configuration.Settings.Language.SubStationAlphaProperties; + if (_isSubStationAlpha) + { + Text = l.TitleSubstationAlpha; + labelWrapStyle.Visible = false; + comboBoxWrapStyle.Visible = false; + checkBoxScaleBorderAndShadow.Visible = false; + Height = Height - (comboBoxWrapStyle.Height + checkBoxScaleBorderAndShadow.Height + 8); + } + else + { + Text = l.Title; + } + + comboBoxWrapStyle.SelectedIndex = 2; + comboBoxCollision.SelectedIndex = 0; + + string header = subtitle.Header; + if (subtitle.Header == null) + { + var ssa = new SubStationAlpha(); + var sub = new Subtitle(); + var lines = subtitle.ToText(ssa).SplitToLines(); + string title = "Untitled"; + if (!string.IsNullOrEmpty(subtitleFileName)) + { + title = Path.GetFileNameWithoutExtension(subtitleFileName); + } + else if (!string.IsNullOrEmpty(videoFileName)) + { + title = Path.GetFileNameWithoutExtension(videoFileName); + } + + ssa.LoadSubtitle(sub, lines, title); + header = sub.Header; + } + + if (header != null) + { + foreach (string line in header.SplitToLines()) + { + string s = line.ToLowerInvariant().Trim(); + if (s.StartsWith("title:", StringComparison.Ordinal)) + { + textBoxTitle.Text = s.Remove(0, 6).Trim(); + } + else if (s.StartsWith("original script:", StringComparison.Ordinal)) + { + textBoxOriginalScript.Text = s.Remove(0, 16).Trim(); + } + else if (s.StartsWith("original translation:", StringComparison.Ordinal)) + { + textBoxTranslation.Text = s.Remove(0, 21).Trim(); + } + else if (s.StartsWith("original editing:", StringComparison.Ordinal)) + { + textBoxEditing.Text = s.Remove(0, 17).Trim(); + } + else if (s.StartsWith("original timing:", StringComparison.Ordinal)) + { + textBoxTiming.Text = s.Remove(0, 16).Trim(); + } + else if (s.StartsWith("synch point:", StringComparison.Ordinal)) + { + textBoxSyncPoint.Text = s.Remove(0, 12).Trim(); + } + else if (s.StartsWith("script updated by:", StringComparison.Ordinal)) + { + textBoxUpdatedBy.Text = s.Remove(0, 18).Trim(); + } + else if (s.StartsWith("update details:", StringComparison.Ordinal)) + { + textBoxUpdateDetails.Text = s.Remove(0, 15).Trim(); + } + else if (s.StartsWith("collisions:", StringComparison.Ordinal)) + { + if (s.Remove(0, 11).Trim() == "reverse") + { + comboBoxCollision.SelectedIndex = 1; + } + } + else if (s.StartsWith("playresx:", StringComparison.Ordinal)) + { + if (int.TryParse(s.Remove(0, 9).Trim(), out var number)) + { + numericUpDownVideoWidth.Value = number; + } + } + else if (s.StartsWith("playresy:", StringComparison.Ordinal)) + { + if (int.TryParse(s.Remove(0, 9).Trim(), out var number)) + { + numericUpDownVideoHeight.Value = number; + } + } + else if (s.StartsWith("scaledborderandshadow:", StringComparison.Ordinal)) + { + checkBoxScaleBorderAndShadow.Checked = s.Remove(0, 22).Trim().ToLowerInvariant().Equals("yes"); + } + else if (s.StartsWith("wrapstyle:", StringComparison.Ordinal)) + { + var wrapStyle = s.Remove(0, 10).Trim(); + for (int i = 0; i < comboBoxWrapStyle.Items.Count; i++) + { + if (i.ToString(CultureInfo.InvariantCulture) == wrapStyle) + { + comboBoxWrapStyle.SelectedIndex = i; + } + } + } + } + } + + groupBoxScript.Text = l.Script; + labelTitle.Text = l.ScriptTitle; + labelOriginalScript.Text = l.OriginalScript; + labelTranslation.Text = l.Translation; + labelEditing.Text = l.Editing; + labelTiming.Text = l.Timing; + labelSyncPoint.Text = l.SyncPoint; + labelUpdatedBy.Text = l.UpdatedBy; + labelUpdateDetails.Text = l.UpdateDetails; + groupBoxResolution.Text = l.Resolution; + labelVideoResolution.Text = l.VideoResolution; + groupBoxOptions.Text = l.Options; + labelCollision.Text = l.Collision; + labelWrapStyle.Text = l.WrapStyle; + checkBoxScaleBorderAndShadow.Text = l.ScaleBorderAndShadow; + + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + + UiUtil.FixLargeFonts(this, buttonCancel); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private string GetDefaultHeader() + { + SubtitleFormat format; + if (_isSubStationAlpha) + { + format = new SubStationAlpha(); + } + else + { + format = new AdvancedSubStationAlpha(); + } + + var sub = new Subtitle(); + string text = format.ToText(sub, string.Empty); + var lines = text.SplitToLines(); + format.LoadSubtitle(sub, lines, string.Empty); + return sub.Header.Trim(); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + if (_subtitle.Header == null || !_subtitle.Header.Contains("[script info]", StringComparison.OrdinalIgnoreCase)) + { + _subtitle.Header = GetDefaultHeader(); + } + + string title = textBoxTitle.Text; + if (string.IsNullOrWhiteSpace(title)) + { + title = "untitled"; + } + + UpdateTag("Title", title, false); + UpdateTag("Original Script", textBoxOriginalScript.Text, string.IsNullOrWhiteSpace(textBoxOriginalScript.Text)); + UpdateTag("Original Translation", textBoxTranslation.Text, string.IsNullOrWhiteSpace(textBoxTranslation.Text)); + UpdateTag("Original Editing", textBoxEditing.Text, string.IsNullOrWhiteSpace(textBoxEditing.Text)); + UpdateTag("Original Timing", textBoxTiming.Text, string.IsNullOrWhiteSpace(textBoxTiming.Text)); + UpdateTag("Synch Point", textBoxSyncPoint.Text, string.IsNullOrWhiteSpace(textBoxSyncPoint.Text)); + UpdateTag("Script Updated By", textBoxUpdatedBy.Text, string.IsNullOrWhiteSpace(textBoxUpdatedBy.Text)); + UpdateTag("Update Details", textBoxUpdateDetails.Text, string.IsNullOrWhiteSpace(textBoxUpdateDetails.Text)); + UpdateTag("PlayResX", numericUpDownVideoWidth.Value.ToString(CultureInfo.InvariantCulture), numericUpDownVideoWidth.Value == 0); + UpdateTag("PlayResY", numericUpDownVideoHeight.Value.ToString(CultureInfo.InvariantCulture), numericUpDownVideoHeight.Value == 0); + if (comboBoxCollision.SelectedIndex == 0) + { + UpdateTag("collisions", "Normal", false); // normal + } + else + { + UpdateTag("collisions", "Reverse", false); // reverse + } + + if (!_isSubStationAlpha) + { + UpdateTag("WrapStyle", comboBoxWrapStyle.SelectedIndex.ToString(CultureInfo.InvariantCulture), false); + if (checkBoxScaleBorderAndShadow.Checked) + { + UpdateTag("ScaledBorderAndShadow", "Yes", false); + } + else + { + UpdateTag("ScaledBorderAndShadow", "No", false); + } + } + + DialogResult = DialogResult.OK; + } + + private void UpdateTag(string tag, string text, bool remove) + { + bool scriptInfoOn = false; + var sb = new StringBuilder(); + bool found = false; + foreach (string line in _subtitle.Header.SplitToLines()) + { + if (line.StartsWith("[script info]", StringComparison.OrdinalIgnoreCase)) + { + scriptInfoOn = true; + } + else if (line.StartsWith('[')) + { + if (!found && scriptInfoOn && !remove) + { + sb = new StringBuilder(sb.ToString().Trim() + Environment.NewLine); + sb.AppendLine(tag + ": " + text); + } + sb = new StringBuilder(sb.ToString().TrimEnd()); + sb.AppendLine(); + sb.AppendLine(); + scriptInfoOn = false; + } + + string s = line.ToLowerInvariant(); + if (s.StartsWith(tag.ToLowerInvariant() + ":", StringComparison.Ordinal)) + { + if (!remove) + { + sb.AppendLine(line.Substring(0, tag.Length) + ": " + text); + } + + found = true; + } + else + { + sb.AppendLine(line); + } + } + _subtitle.Header = sb.ToString().Trim(); + } + + private void SubStationAlphaProperties_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void buttonGetResolutionFromVideo_Click(object sender, EventArgs e) + { + openFileDialog1.Title = Configuration.Settings.Language.General.OpenVideoFileTitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = Utilities.GetVideoFileFilter(false); + openFileDialog1.FileName = string.Empty; + if (string.IsNullOrEmpty(openFileDialog1.InitialDirectory) && !string.IsNullOrEmpty(_videoFileName)) + { + openFileDialog1.InitialDirectory = Path.GetDirectoryName(_videoFileName); + openFileDialog1.FileName = Path.GetFileName(_videoFileName); + } + + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + VideoInfo info = UiUtil.GetVideoInfo(openFileDialog1.FileName); + if (info != null && info.Success) + { + numericUpDownVideoWidth.Value = info.Width; + numericUpDownVideoHeight.Value = info.Height; + } + } + } + + } +} diff --git a/src/Forms/SubStationAlphaProperties.resx b/src/ui/Forms/SubStationAlphaProperties.resx similarity index 97% rename from src/Forms/SubStationAlphaProperties.resx rename to src/ui/Forms/SubStationAlphaProperties.resx index 3a7d67153..9bad2f599 100644 --- a/src/Forms/SubStationAlphaProperties.resx +++ b/src/ui/Forms/SubStationAlphaProperties.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/SyncPointsSync.Designer.cs b/src/ui/Forms/SyncPointsSync.Designer.cs similarity index 98% rename from src/Forms/SyncPointsSync.Designer.cs rename to src/ui/Forms/SyncPointsSync.Designer.cs index 5a709883b..b071d4e29 100644 --- a/src/Forms/SyncPointsSync.Designer.cs +++ b/src/ui/Forms/SyncPointsSync.Designer.cs @@ -1,310 +1,310 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class SyncPointsSync - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBoxImportResult = new System.Windows.Forms.GroupBox(); - this.labelAdjustFactor = new System.Windows.Forms.Label(); - this.buttonFindTextOther = new System.Windows.Forms.Button(); - this.buttonFindText = new System.Windows.Forms.Button(); - this.labelOtherSubtitleFileName = new System.Windows.Forms.Label(); - this.labelSubtitleFileName = new System.Windows.Forms.Label(); - this.subtitleListView2 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.listBoxSyncPoints = new System.Windows.Forms.ListBox(); - this.labelNoOfSyncPoints = new System.Windows.Forms.Label(); - this.buttonRemoveSyncPoint = new System.Windows.Forms.Button(); - this.buttonSetSyncPoint = new System.Windows.Forms.Button(); - this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.labelSyncInfo = new System.Windows.Forms.Label(); - this.buttonApplySync = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxImportResult.SuspendLayout(); - this.SuspendLayout(); - // - // groupBoxImportResult - // - this.groupBoxImportResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxImportResult.Controls.Add(this.labelAdjustFactor); - this.groupBoxImportResult.Controls.Add(this.buttonFindTextOther); - this.groupBoxImportResult.Controls.Add(this.buttonFindText); - this.groupBoxImportResult.Controls.Add(this.labelOtherSubtitleFileName); - this.groupBoxImportResult.Controls.Add(this.labelSubtitleFileName); - this.groupBoxImportResult.Controls.Add(this.subtitleListView2); - this.groupBoxImportResult.Controls.Add(this.listBoxSyncPoints); - this.groupBoxImportResult.Controls.Add(this.labelNoOfSyncPoints); - this.groupBoxImportResult.Controls.Add(this.buttonRemoveSyncPoint); - this.groupBoxImportResult.Controls.Add(this.buttonSetSyncPoint); - this.groupBoxImportResult.Controls.Add(this.SubtitleListview1); - this.groupBoxImportResult.Location = new System.Drawing.Point(12, 12); - this.groupBoxImportResult.Name = "groupBoxImportResult"; - this.groupBoxImportResult.Size = new System.Drawing.Size(1096, 434); - this.groupBoxImportResult.TabIndex = 16; - this.groupBoxImportResult.TabStop = false; - // - // labelAdjustFactor - // - this.labelAdjustFactor.AutoSize = true; - this.labelAdjustFactor.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelAdjustFactor.ForeColor = System.Drawing.Color.Gray; - this.labelAdjustFactor.Location = new System.Drawing.Point(482, 299); - this.labelAdjustFactor.Name = "labelAdjustFactor"; - this.labelAdjustFactor.Size = new System.Drawing.Size(58, 11); - this.labelAdjustFactor.TabIndex = 35; - this.labelAdjustFactor.Text = "AdjustFactor"; - // - // buttonFindTextOther - // - this.buttonFindTextOther.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonFindTextOther.Location = new System.Drawing.Point(976, 407); - this.buttonFindTextOther.Name = "buttonFindTextOther"; - this.buttonFindTextOther.Size = new System.Drawing.Size(106, 23); - this.buttonFindTextOther.TabIndex = 34; - this.buttonFindTextOther.Text = "Find text..."; - this.buttonFindTextOther.UseVisualStyleBackColor = true; - this.buttonFindTextOther.Click += new System.EventHandler(this.ButtonFindTextOtherClick); - // - // buttonFindText - // - this.buttonFindText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonFindText.Location = new System.Drawing.Point(369, 407); - this.buttonFindText.Name = "buttonFindText"; - this.buttonFindText.Size = new System.Drawing.Size(106, 23); - this.buttonFindText.TabIndex = 33; - this.buttonFindText.Text = "Find text..."; - this.buttonFindText.UseVisualStyleBackColor = true; - this.buttonFindText.Click += new System.EventHandler(this.ButtonFindTextClick); - // - // labelOtherSubtitleFileName - // - this.labelOtherSubtitleFileName.AutoSize = true; - this.labelOtherSubtitleFileName.Location = new System.Drawing.Point(626, 15); - this.labelOtherSubtitleFileName.Name = "labelOtherSubtitleFileName"; - this.labelOtherSubtitleFileName.Size = new System.Drawing.Size(136, 13); - this.labelOtherSubtitleFileName.TabIndex = 21; - this.labelOtherSubtitleFileName.Text = "labelOtherSubtitleFileName"; - // - // labelSubtitleFileName - // - this.labelSubtitleFileName.AutoSize = true; - this.labelSubtitleFileName.Location = new System.Drawing.Point(6, 15); - this.labelSubtitleFileName.Name = "labelSubtitleFileName"; - this.labelSubtitleFileName.Size = new System.Drawing.Size(108, 13); - this.labelSubtitleFileName.TabIndex = 20; - this.labelSubtitleFileName.Text = "labelSubtitleFileName"; - // - // subtitleListView2 - // - this.subtitleListView2.AllowColumnReorder = true; - this.subtitleListView2.AllowDrop = true; - this.subtitleListView2.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.subtitleListView2.FirstVisibleIndex = -1; - this.subtitleListView2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.subtitleListView2.FullRowSelect = true; - this.subtitleListView2.GridLines = true; - this.subtitleListView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.subtitleListView2.HideSelection = false; - this.subtitleListView2.Location = new System.Drawing.Point(629, 33); - this.subtitleListView2.MultiSelect = false; - this.subtitleListView2.Name = "subtitleListView2"; - this.subtitleListView2.OwnerDraw = true; - this.subtitleListView2.Size = new System.Drawing.Size(453, 368); - this.subtitleListView2.SubtitleFontBold = false; - this.subtitleListView2.SubtitleFontName = "Tahoma"; - this.subtitleListView2.SubtitleFontSize = 8; - this.subtitleListView2.TabIndex = 19; - this.subtitleListView2.UseCompatibleStateImageBehavior = false; - this.subtitleListView2.UseSyntaxColoring = true; - this.subtitleListView2.View = System.Windows.Forms.View.Details; - // - // listBoxSyncPoints - // - this.listBoxSyncPoints.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.listBoxSyncPoints.FormattingEnabled = true; - this.listBoxSyncPoints.Location = new System.Drawing.Point(482, 214); - this.listBoxSyncPoints.Name = "listBoxSyncPoints"; - this.listBoxSyncPoints.Size = new System.Drawing.Size(140, 82); - this.listBoxSyncPoints.TabIndex = 18; - this.listBoxSyncPoints.SelectedIndexChanged += new System.EventHandler(this.listBoxSyncPoints_SelectedIndexChanged); - // - // labelNoOfSyncPoints - // - this.labelNoOfSyncPoints.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.labelNoOfSyncPoints.AutoSize = true; - this.labelNoOfSyncPoints.Location = new System.Drawing.Point(481, 196); - this.labelNoOfSyncPoints.Name = "labelNoOfSyncPoints"; - this.labelNoOfSyncPoints.Size = new System.Drawing.Size(75, 13); - this.labelNoOfSyncPoints.TabIndex = 16; - this.labelNoOfSyncPoints.Text = "Sync points: 0"; - // - // buttonRemoveSyncPoint - // - this.buttonRemoveSyncPoint.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.buttonRemoveSyncPoint.Location = new System.Drawing.Point(484, 170); - this.buttonRemoveSyncPoint.Name = "buttonRemoveSyncPoint"; - this.buttonRemoveSyncPoint.Size = new System.Drawing.Size(138, 23); - this.buttonRemoveSyncPoint.TabIndex = 14; - this.buttonRemoveSyncPoint.Text = "Remove sync point"; - this.buttonRemoveSyncPoint.UseVisualStyleBackColor = true; - this.buttonRemoveSyncPoint.Click += new System.EventHandler(this.buttonRemoveSyncPoint_Click); - // - // buttonSetSyncPoint - // - this.buttonSetSyncPoint.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.buttonSetSyncPoint.Location = new System.Drawing.Point(484, 141); - this.buttonSetSyncPoint.Name = "buttonSetSyncPoint"; - this.buttonSetSyncPoint.Size = new System.Drawing.Size(138, 23); - this.buttonSetSyncPoint.TabIndex = 13; - this.buttonSetSyncPoint.Text = "Set sync point"; - this.buttonSetSyncPoint.UseVisualStyleBackColor = true; - this.buttonSetSyncPoint.Click += new System.EventHandler(this.buttonSetSyncPoint_Click); - // - // SubtitleListview1 - // - this.SubtitleListview1.AllowColumnReorder = true; - this.SubtitleListview1.AllowDrop = true; - this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.SubtitleListview1.FirstVisibleIndex = -1; - this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.SubtitleListview1.FullRowSelect = true; - this.SubtitleListview1.GridLines = true; - this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.SubtitleListview1.HideSelection = false; - this.SubtitleListview1.Location = new System.Drawing.Point(9, 33); - this.SubtitleListview1.MultiSelect = false; - this.SubtitleListview1.Name = "SubtitleListview1"; - this.SubtitleListview1.OwnerDraw = true; - this.SubtitleListview1.Size = new System.Drawing.Size(466, 368); - this.SubtitleListview1.SubtitleFontBold = false; - this.SubtitleListview1.SubtitleFontName = "Tahoma"; - this.SubtitleListview1.SubtitleFontSize = 8; - this.SubtitleListview1.TabIndex = 12; - this.SubtitleListview1.UseCompatibleStateImageBehavior = false; - this.SubtitleListview1.UseSyntaxColoring = true; - this.SubtitleListview1.View = System.Windows.Forms.View.Details; - this.SubtitleListview1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListview1_MouseDoubleClick); - // - // labelSyncInfo - // - this.labelSyncInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelSyncInfo.AutoSize = true; - this.labelSyncInfo.Location = new System.Drawing.Point(18, 456); - this.labelSyncInfo.Name = "labelSyncInfo"; - this.labelSyncInfo.Size = new System.Drawing.Size(290, 13); - this.labelSyncInfo.TabIndex = 17; - this.labelSyncInfo.Text = "Set at least two sync points to make rough synchronization"; - // - // buttonApplySync - // - this.buttonApplySync.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonApplySync.Enabled = false; - this.buttonApplySync.Location = new System.Drawing.Point(1029, 452); - this.buttonApplySync.Name = "buttonApplySync"; - this.buttonApplySync.Size = new System.Drawing.Size(80, 23); - this.buttonApplySync.TabIndex = 15; - this.buttonApplySync.Text = "Apply"; - this.buttonApplySync.UseVisualStyleBackColor = true; - this.buttonApplySync.Click += new System.EventHandler(this.buttonSync_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(948, 452); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 19; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(867, 452); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 18; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // SyncPointsSync - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1120, 485); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonApplySync); - this.Controls.Add(this.groupBoxImportResult); - this.Controls.Add(this.labelSyncInfo); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(600, 400); - this.Name = "SyncPointsSync"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "SyncPointsSync"; - this.Shown += new System.EventHandler(this.SyncPointsSyncShown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SyncPointsSync_KeyDown); - this.Resize += new System.EventHandler(this.SyncPointsSyncResize); - this.groupBoxImportResult.ResumeLayout(false); - this.groupBoxImportResult.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBoxImportResult; - private System.Windows.Forms.Label labelSyncInfo; - private System.Windows.Forms.Label labelNoOfSyncPoints; - private System.Windows.Forms.Button buttonSetSyncPoint; - private System.Windows.Forms.Button buttonApplySync; - private System.Windows.Forms.Button buttonRemoveSyncPoint; - private Controls.SubtitleListView SubtitleListview1; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.ListBox listBoxSyncPoints; - private System.Windows.Forms.Label labelOtherSubtitleFileName; - private System.Windows.Forms.Label labelSubtitleFileName; - private Controls.SubtitleListView subtitleListView2; - private System.Windows.Forms.Button buttonFindText; - private System.Windows.Forms.Button buttonFindTextOther; - private System.Windows.Forms.Label labelAdjustFactor; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class SyncPointsSync + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBoxImportResult = new System.Windows.Forms.GroupBox(); + this.labelAdjustFactor = new System.Windows.Forms.Label(); + this.buttonFindTextOther = new System.Windows.Forms.Button(); + this.buttonFindText = new System.Windows.Forms.Button(); + this.labelOtherSubtitleFileName = new System.Windows.Forms.Label(); + this.labelSubtitleFileName = new System.Windows.Forms.Label(); + this.subtitleListView2 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.listBoxSyncPoints = new System.Windows.Forms.ListBox(); + this.labelNoOfSyncPoints = new System.Windows.Forms.Label(); + this.buttonRemoveSyncPoint = new System.Windows.Forms.Button(); + this.buttonSetSyncPoint = new System.Windows.Forms.Button(); + this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + this.labelSyncInfo = new System.Windows.Forms.Label(); + this.buttonApplySync = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxImportResult.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxImportResult + // + this.groupBoxImportResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImportResult.Controls.Add(this.labelAdjustFactor); + this.groupBoxImportResult.Controls.Add(this.buttonFindTextOther); + this.groupBoxImportResult.Controls.Add(this.buttonFindText); + this.groupBoxImportResult.Controls.Add(this.labelOtherSubtitleFileName); + this.groupBoxImportResult.Controls.Add(this.labelSubtitleFileName); + this.groupBoxImportResult.Controls.Add(this.subtitleListView2); + this.groupBoxImportResult.Controls.Add(this.listBoxSyncPoints); + this.groupBoxImportResult.Controls.Add(this.labelNoOfSyncPoints); + this.groupBoxImportResult.Controls.Add(this.buttonRemoveSyncPoint); + this.groupBoxImportResult.Controls.Add(this.buttonSetSyncPoint); + this.groupBoxImportResult.Controls.Add(this.SubtitleListview1); + this.groupBoxImportResult.Location = new System.Drawing.Point(12, 12); + this.groupBoxImportResult.Name = "groupBoxImportResult"; + this.groupBoxImportResult.Size = new System.Drawing.Size(1096, 434); + this.groupBoxImportResult.TabIndex = 16; + this.groupBoxImportResult.TabStop = false; + // + // labelAdjustFactor + // + this.labelAdjustFactor.AutoSize = true; + this.labelAdjustFactor.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelAdjustFactor.ForeColor = System.Drawing.Color.Gray; + this.labelAdjustFactor.Location = new System.Drawing.Point(482, 299); + this.labelAdjustFactor.Name = "labelAdjustFactor"; + this.labelAdjustFactor.Size = new System.Drawing.Size(58, 11); + this.labelAdjustFactor.TabIndex = 35; + this.labelAdjustFactor.Text = "AdjustFactor"; + // + // buttonFindTextOther + // + this.buttonFindTextOther.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonFindTextOther.Location = new System.Drawing.Point(976, 407); + this.buttonFindTextOther.Name = "buttonFindTextOther"; + this.buttonFindTextOther.Size = new System.Drawing.Size(106, 23); + this.buttonFindTextOther.TabIndex = 34; + this.buttonFindTextOther.Text = "Find text..."; + this.buttonFindTextOther.UseVisualStyleBackColor = true; + this.buttonFindTextOther.Click += new System.EventHandler(this.ButtonFindTextOtherClick); + // + // buttonFindText + // + this.buttonFindText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonFindText.Location = new System.Drawing.Point(369, 407); + this.buttonFindText.Name = "buttonFindText"; + this.buttonFindText.Size = new System.Drawing.Size(106, 23); + this.buttonFindText.TabIndex = 33; + this.buttonFindText.Text = "Find text..."; + this.buttonFindText.UseVisualStyleBackColor = true; + this.buttonFindText.Click += new System.EventHandler(this.ButtonFindTextClick); + // + // labelOtherSubtitleFileName + // + this.labelOtherSubtitleFileName.AutoSize = true; + this.labelOtherSubtitleFileName.Location = new System.Drawing.Point(626, 15); + this.labelOtherSubtitleFileName.Name = "labelOtherSubtitleFileName"; + this.labelOtherSubtitleFileName.Size = new System.Drawing.Size(136, 13); + this.labelOtherSubtitleFileName.TabIndex = 21; + this.labelOtherSubtitleFileName.Text = "labelOtherSubtitleFileName"; + // + // labelSubtitleFileName + // + this.labelSubtitleFileName.AutoSize = true; + this.labelSubtitleFileName.Location = new System.Drawing.Point(6, 15); + this.labelSubtitleFileName.Name = "labelSubtitleFileName"; + this.labelSubtitleFileName.Size = new System.Drawing.Size(108, 13); + this.labelSubtitleFileName.TabIndex = 20; + this.labelSubtitleFileName.Text = "labelSubtitleFileName"; + // + // subtitleListView2 + // + this.subtitleListView2.AllowColumnReorder = true; + this.subtitleListView2.AllowDrop = true; + this.subtitleListView2.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.subtitleListView2.FirstVisibleIndex = -1; + this.subtitleListView2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.subtitleListView2.FullRowSelect = true; + this.subtitleListView2.GridLines = true; + this.subtitleListView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.subtitleListView2.HideSelection = false; + this.subtitleListView2.Location = new System.Drawing.Point(629, 33); + this.subtitleListView2.MultiSelect = false; + this.subtitleListView2.Name = "subtitleListView2"; + this.subtitleListView2.OwnerDraw = true; + this.subtitleListView2.Size = new System.Drawing.Size(453, 368); + this.subtitleListView2.SubtitleFontBold = false; + this.subtitleListView2.SubtitleFontName = "Tahoma"; + this.subtitleListView2.SubtitleFontSize = 8; + this.subtitleListView2.TabIndex = 19; + this.subtitleListView2.UseCompatibleStateImageBehavior = false; + this.subtitleListView2.UseSyntaxColoring = true; + this.subtitleListView2.View = System.Windows.Forms.View.Details; + // + // listBoxSyncPoints + // + this.listBoxSyncPoints.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.listBoxSyncPoints.FormattingEnabled = true; + this.listBoxSyncPoints.Location = new System.Drawing.Point(482, 214); + this.listBoxSyncPoints.Name = "listBoxSyncPoints"; + this.listBoxSyncPoints.Size = new System.Drawing.Size(140, 82); + this.listBoxSyncPoints.TabIndex = 18; + this.listBoxSyncPoints.SelectedIndexChanged += new System.EventHandler(this.listBoxSyncPoints_SelectedIndexChanged); + // + // labelNoOfSyncPoints + // + this.labelNoOfSyncPoints.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.labelNoOfSyncPoints.AutoSize = true; + this.labelNoOfSyncPoints.Location = new System.Drawing.Point(481, 196); + this.labelNoOfSyncPoints.Name = "labelNoOfSyncPoints"; + this.labelNoOfSyncPoints.Size = new System.Drawing.Size(75, 13); + this.labelNoOfSyncPoints.TabIndex = 16; + this.labelNoOfSyncPoints.Text = "Sync points: 0"; + // + // buttonRemoveSyncPoint + // + this.buttonRemoveSyncPoint.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.buttonRemoveSyncPoint.Location = new System.Drawing.Point(484, 170); + this.buttonRemoveSyncPoint.Name = "buttonRemoveSyncPoint"; + this.buttonRemoveSyncPoint.Size = new System.Drawing.Size(138, 23); + this.buttonRemoveSyncPoint.TabIndex = 14; + this.buttonRemoveSyncPoint.Text = "Remove sync point"; + this.buttonRemoveSyncPoint.UseVisualStyleBackColor = true; + this.buttonRemoveSyncPoint.Click += new System.EventHandler(this.buttonRemoveSyncPoint_Click); + // + // buttonSetSyncPoint + // + this.buttonSetSyncPoint.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.buttonSetSyncPoint.Location = new System.Drawing.Point(484, 141); + this.buttonSetSyncPoint.Name = "buttonSetSyncPoint"; + this.buttonSetSyncPoint.Size = new System.Drawing.Size(138, 23); + this.buttonSetSyncPoint.TabIndex = 13; + this.buttonSetSyncPoint.Text = "Set sync point"; + this.buttonSetSyncPoint.UseVisualStyleBackColor = true; + this.buttonSetSyncPoint.Click += new System.EventHandler(this.buttonSetSyncPoint_Click); + // + // SubtitleListview1 + // + this.SubtitleListview1.AllowColumnReorder = true; + this.SubtitleListview1.AllowDrop = true; + this.SubtitleListview1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.SubtitleListview1.FirstVisibleIndex = -1; + this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SubtitleListview1.FullRowSelect = true; + this.SubtitleListview1.GridLines = true; + this.SubtitleListview1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.SubtitleListview1.HideSelection = false; + this.SubtitleListview1.Location = new System.Drawing.Point(9, 33); + this.SubtitleListview1.MultiSelect = false; + this.SubtitleListview1.Name = "SubtitleListview1"; + this.SubtitleListview1.OwnerDraw = true; + this.SubtitleListview1.Size = new System.Drawing.Size(466, 368); + this.SubtitleListview1.SubtitleFontBold = false; + this.SubtitleListview1.SubtitleFontName = "Tahoma"; + this.SubtitleListview1.SubtitleFontSize = 8; + this.SubtitleListview1.TabIndex = 12; + this.SubtitleListview1.UseCompatibleStateImageBehavior = false; + this.SubtitleListview1.UseSyntaxColoring = true; + this.SubtitleListview1.View = System.Windows.Forms.View.Details; + this.SubtitleListview1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListview1_MouseDoubleClick); + // + // labelSyncInfo + // + this.labelSyncInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelSyncInfo.AutoSize = true; + this.labelSyncInfo.Location = new System.Drawing.Point(18, 456); + this.labelSyncInfo.Name = "labelSyncInfo"; + this.labelSyncInfo.Size = new System.Drawing.Size(290, 13); + this.labelSyncInfo.TabIndex = 17; + this.labelSyncInfo.Text = "Set at least two sync points to make rough synchronization"; + // + // buttonApplySync + // + this.buttonApplySync.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonApplySync.Enabled = false; + this.buttonApplySync.Location = new System.Drawing.Point(1029, 452); + this.buttonApplySync.Name = "buttonApplySync"; + this.buttonApplySync.Size = new System.Drawing.Size(80, 23); + this.buttonApplySync.TabIndex = 15; + this.buttonApplySync.Text = "Apply"; + this.buttonApplySync.UseVisualStyleBackColor = true; + this.buttonApplySync.Click += new System.EventHandler(this.buttonSync_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(948, 452); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 19; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(867, 452); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 18; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // SyncPointsSync + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1120, 485); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonApplySync); + this.Controls.Add(this.groupBoxImportResult); + this.Controls.Add(this.labelSyncInfo); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(600, 400); + this.Name = "SyncPointsSync"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "SyncPointsSync"; + this.Shown += new System.EventHandler(this.SyncPointsSyncShown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SyncPointsSync_KeyDown); + this.Resize += new System.EventHandler(this.SyncPointsSyncResize); + this.groupBoxImportResult.ResumeLayout(false); + this.groupBoxImportResult.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBoxImportResult; + private System.Windows.Forms.Label labelSyncInfo; + private System.Windows.Forms.Label labelNoOfSyncPoints; + private System.Windows.Forms.Button buttonSetSyncPoint; + private System.Windows.Forms.Button buttonApplySync; + private System.Windows.Forms.Button buttonRemoveSyncPoint; + private Controls.SubtitleListView SubtitleListview1; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.ListBox listBoxSyncPoints; + private System.Windows.Forms.Label labelOtherSubtitleFileName; + private System.Windows.Forms.Label labelSubtitleFileName; + private Controls.SubtitleListView subtitleListView2; + private System.Windows.Forms.Button buttonFindText; + private System.Windows.Forms.Button buttonFindTextOther; + private System.Windows.Forms.Label labelAdjustFactor; + } } \ No newline at end of file diff --git a/src/Forms/SyncPointsSync.cs b/src/ui/Forms/SyncPointsSync.cs similarity index 97% rename from src/Forms/SyncPointsSync.cs rename to src/ui/Forms/SyncPointsSync.cs index 4c42529a8..b7eacd7bb 100644 --- a/src/Forms/SyncPointsSync.cs +++ b/src/ui/Forms/SyncPointsSync.cs @@ -1,506 +1,506 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.Linq; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class SyncPointsSync : PositionAndSizeForm - { - public class ListBoxSyncPoint - { - public int Index { get; set; } - public string Text { get; set; } - - public override string ToString() - { - return Text; - } - } - - private string _subtitleFileName; - private int _audioTrackNumber; - private Subtitle _subtitle; - private Subtitle _originalSubtitle; - private Subtitle _otherSubtitle; - private SortedDictionary _synchronizationPoints = new SortedDictionary(); - private readonly Keys _mainGeneralGoToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle); - private readonly Keys _mainGeneralGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle); - - public string VideoFileName { get; private set; } - - public Subtitle FixedSubtitle => _subtitle; - - public SyncPointsSync() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - buttonSetSyncPoint.Text = Configuration.Settings.Language.PointSync.SetSyncPoint; - buttonRemoveSyncPoint.Text = Configuration.Settings.Language.PointSync.RemoveSyncPoint; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonApplySync.Text = Configuration.Settings.Language.PointSync.ApplySync; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - labelNoOfSyncPoints.Text = string.Format(Configuration.Settings.Language.PointSync.SyncPointsX, 0); - labelSyncInfo.Text = Configuration.Settings.Language.PointSync.Info; - buttonFindText.Text = Configuration.Settings.Language.VisualSync.FindText; - buttonFindTextOther.Text = Configuration.Settings.Language.VisualSync.FindText; - SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - subtitleListView2.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); - SubtitleListview1.InitializeTimestampColumnWidths(this); - subtitleListView2.InitializeTimestampColumnWidths(this); - UiUtil.InitializeSubtitleFont(SubtitleListview1); - UiUtil.InitializeSubtitleFont(subtitleListView2); - SubtitleListview1.AutoSizeAllColumns(this); - subtitleListView2.AutoSizeAllColumns(this); - UiUtil.FixLargeFonts(this, buttonOK); - labelAdjustFactor.Text = string.Empty; - } - - public void Initialize(Subtitle subtitle, string subtitleFileName, string videoFileName, int audioTrackNumber) - { - Text = Configuration.Settings.Language.PointSync.Title; - labelSubtitleFileName.Text = subtitleFileName; - _subtitle = new Subtitle(subtitle); - _originalSubtitle = subtitle; - _subtitleFileName = subtitleFileName; - VideoFileName = videoFileName; - _audioTrackNumber = audioTrackNumber; - SubtitleListview1.Fill(subtitle); - if (SubtitleListview1.Items.Count > 0) - { - SubtitleListview1.Items[0].Selected = true; - } - - SubtitleListview1.Anchor = AnchorStyles.Left; - buttonSetSyncPoint.Anchor = AnchorStyles.Left; - buttonRemoveSyncPoint.Anchor = AnchorStyles.Left; - labelNoOfSyncPoints.Anchor = AnchorStyles.Left; - listBoxSyncPoints.Anchor = AnchorStyles.Left; - groupBoxImportResult.Anchor = AnchorStyles.Left; - labelOtherSubtitleFileName.Visible = false; - subtitleListView2.Visible = false; - buttonFindTextOther.Visible = false; - groupBoxImportResult.Width = listBoxSyncPoints.Left + listBoxSyncPoints.Width + 20; - Width = groupBoxImportResult.Left + groupBoxImportResult.Width + 15; - SubtitleListview1.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right; - buttonSetSyncPoint.Anchor = AnchorStyles.Right; - buttonRemoveSyncPoint.Anchor = AnchorStyles.Right; - labelNoOfSyncPoints.Anchor = AnchorStyles.Right; - listBoxSyncPoints.Anchor = AnchorStyles.Right; - groupBoxImportResult.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right; - buttonFindText.Left = SubtitleListview1.Left + SubtitleListview1.Width - buttonFindText.Width; - Width = 900; - groupBoxImportResult.Width = Width - groupBoxImportResult.Left * 3; - labelAdjustFactor.Left = listBoxSyncPoints.Left; - labelAdjustFactor.Anchor = listBoxSyncPoints.Anchor; - MinimumSize = new Size(Width - 50, MinimumSize.Height); - } - - public void Initialize(Subtitle subtitle, string subtitleFileName, string videoFileName, int audioTrackNumber, string otherSubtitleFileName, Subtitle otherSubtitle) - { - Text = Configuration.Settings.Language.PointSync.TitleViaOtherSubtitle; - labelSubtitleFileName.Text = subtitleFileName; - _subtitle = new Subtitle(subtitle); - _otherSubtitle = otherSubtitle; - _originalSubtitle = subtitle; - _subtitleFileName = subtitleFileName; - VideoFileName = videoFileName; - _audioTrackNumber = audioTrackNumber; - SubtitleListview1.Fill(subtitle); - if (SubtitleListview1.Items.Count > 0) - { - SubtitleListview1.Items[0].Selected = true; - } - - labelOtherSubtitleFileName.Text = otherSubtitleFileName; - subtitleListView2.Fill(otherSubtitle); - - SubtitleListview1.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; - subtitleListView2.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; - buttonSetSyncPoint.Anchor = AnchorStyles.Left; - buttonRemoveSyncPoint.Anchor = AnchorStyles.Left; - labelNoOfSyncPoints.Anchor = AnchorStyles.Left; - listBoxSyncPoints.Anchor = AnchorStyles.Left; - labelAdjustFactor.Anchor = listBoxSyncPoints.Anchor; - labelOtherSubtitleFileName.Visible = true; - subtitleListView2.Visible = true; - buttonFindTextOther.Visible = true; - Width = subtitleListView2.Width * 2 + 250; - MinimumSize = new Size(Width - 50, MinimumSize.Height); - } - - private void RefreshSynchronizationPointsUi() - { - buttonApplySync.Enabled = _synchronizationPoints.Count > 0; - labelNoOfSyncPoints.Text = string.Format(Configuration.Settings.Language.PointSync.SyncPointsX, _synchronizationPoints.Count); - - listBoxSyncPoints.Items.Clear(); - - for (int i = 0; i < SubtitleListview1.Items.Count; i++) - { - if (_synchronizationPoints.ContainsKey(i)) - { - var p = new Paragraph { StartTime = { TotalMilliseconds = _synchronizationPoints[i].TotalMilliseconds } }; - p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + _subtitle.Paragraphs[i].Duration.TotalMilliseconds; - SubtitleListview1.SetStartTimeAndDuration(i, p, _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1)); - - var item = new ListBoxSyncPoint { Index = i, Text = _subtitle.Paragraphs[i].Number + " - " + p.StartTime }; - listBoxSyncPoints.Items.Add(item); - SubtitleListview1.SetBackgroundColor(i, Color.Green); - SubtitleListview1.SetNumber(_subtitle.Paragraphs[i].Number, "* * * *"); - } - else - { - SubtitleListview1.SetBackgroundColor(i, SubtitleListview1.BackColor); - SubtitleListview1.SetNumber(i, _subtitle.Paragraphs[i].Number.ToString(CultureInfo.InvariantCulture)); - SubtitleListview1.SetStartTimeAndDuration(i, _subtitle.Paragraphs[i], _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1)); - } - } - } - - private void buttonSetSyncPoint_Click(object sender, EventArgs e) - { - if (subtitleListView2.Visible) - { - SetSyncPointViaOthersubtitle(); - } - else - { - if (SubtitleListview1.SelectedItems.Count == 1 && _subtitle != null) - { - using (var getTime = new SetSyncPoint()) - { - int index = SubtitleListview1.SelectedItems[0].Index; - getTime.Initialize(_subtitle, _subtitleFileName, index, VideoFileName, _audioTrackNumber); - if (getTime.ShowDialog(this) == DialogResult.OK) - { - if (_synchronizationPoints.ContainsKey(index)) - { - _synchronizationPoints[index] = getTime.SynchronizationPoint; - } - else - { - _synchronizationPoints.Add(index, getTime.SynchronizationPoint); - } - - RefreshSynchronizationPointsUi(); - VideoFileName = getTime.VideoFileName; - } - Activate(); - VideoFileName = getTime.VideoFileName; - } - } - } - SetSyncFactorLabel(); - } - - private void SetSyncPointViaOthersubtitle() - { - if (_otherSubtitle != null && subtitleListView2.SelectedItems.Count == 1) - { - int index = SubtitleListview1.SelectedItems[0].Index; - int indexOther = subtitleListView2.SelectedItems[0].Index; - - if (_synchronizationPoints.ContainsKey(index)) - { - _synchronizationPoints[index] = TimeSpan.FromMilliseconds(_otherSubtitle.Paragraphs[indexOther].StartTime.TotalMilliseconds); - } - else - { - _synchronizationPoints.Add(index, TimeSpan.FromMilliseconds(_otherSubtitle.Paragraphs[indexOther].StartTime.TotalMilliseconds)); - } - - RefreshSynchronizationPointsUi(); - } - SetSyncFactorLabel(); - } - - private void buttonRemoveSyncPoint_Click(object sender, EventArgs e) - { - if (SubtitleListview1.SelectedItems.Count == 1 && _subtitle != null) - { - int index = SubtitleListview1.SelectedItems[0].Index; - if (_synchronizationPoints.ContainsKey(index)) - { - _synchronizationPoints.Remove(index); - } - - RefreshSynchronizationPointsUi(); - } - SetSyncFactorLabel(); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - if (buttonApplySync.Enabled) - { - buttonSync_Click(null, null); - } - - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void SyncPointsSync_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#sync"); - e.SuppressKeyPress = true; - } - else if (_mainGeneralGoToNextSubtitle == e.KeyData || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)) - { - int selectedIndex = 0; - if (SubtitleListview1.SelectedItems.Count > 0) - { - selectedIndex = SubtitleListview1.SelectedItems[0].Index; - selectedIndex++; - } - SubtitleListview1.SelectIndexAndEnsureVisible(selectedIndex); - e.SuppressKeyPress = true; - } - else if (_mainGeneralGoToPrevSubtitle == e.KeyData || (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt)) - { - int selectedIndex = 0; - if (SubtitleListview1.SelectedItems.Count > 0) - { - selectedIndex = SubtitleListview1.SelectedItems[0].Index; - selectedIndex--; - } - SubtitleListview1.SelectIndexAndEnsureVisible(selectedIndex); - e.SuppressKeyPress = true; - } - else if (e.KeyData == (Keys.Control | Keys.G)) - { - var subView = SubtitleListview1; - if (subtitleListView2 != null && subtitleListView2.Visible && !SubtitleListview1.Focused) - { - var x = PointToClient(MousePosition).X; - if (x >= subtitleListView2.Left && x <= subtitleListView2.Left + subtitleListView2.Width) - { - subView = subtitleListView2; - } - } - using (var gotoForm = new GoToLine()) - { - gotoForm.Initialize(1, subView.Items.Count); - if (gotoForm.ShowDialog() == DialogResult.OK) - { - subView.SelectIndexAndEnsureVisible(gotoForm.LineNumber - 1, true); - } - } - } - } - - private void SetSyncFactorLabel() - { - labelAdjustFactor.Text = string.Empty; - if (_synchronizationPoints.Count == 1) - { - double startPos = _synchronizationPoints.First().Value.TotalMilliseconds / TimeCode.BaseUnit; - double subStart = _originalSubtitle.Paragraphs[_synchronizationPoints.First().Key].StartTime.TotalMilliseconds / TimeCode.BaseUnit; - - var adjustment = startPos - subStart; - labelAdjustFactor.Text = $"{adjustment:+0.000;-0.000}"; - } - else if (_synchronizationPoints.Count == 2) - { - double startPos = _synchronizationPoints.First().Value.TotalMilliseconds / TimeCode.BaseUnit; - double endPos = _synchronizationPoints.Last().Value.TotalMilliseconds / TimeCode.BaseUnit; - - double subStart = _originalSubtitle.Paragraphs[_synchronizationPoints.First().Key].StartTime.TotalMilliseconds / TimeCode.BaseUnit; - double subEnd = _originalSubtitle.Paragraphs[_synchronizationPoints.Last().Key].StartTime.TotalMilliseconds / TimeCode.BaseUnit; - - double subDiff = subEnd - subStart; - double realDiff = endPos - startPos; - - // speed factor - double factor = realDiff / subDiff; - - // adjust to starting position - double adjust = startPos - subStart * factor; - - labelAdjustFactor.Text = $"*{factor:0.000}, {adjust:+0.000;-0.000}"; - } - } - - private void Sync(int startIndex, int endIndex, int minIndex, int maxIndex, double startPos, double endPos) - { - if (endPos > startPos) - { - double subStart = _originalSubtitle.Paragraphs[startIndex].StartTime.TotalMilliseconds / TimeCode.BaseUnit; - double subEnd = _originalSubtitle.Paragraphs[endIndex].StartTime.TotalMilliseconds / TimeCode.BaseUnit; - - double subDiff = subEnd - subStart; - double realDiff = endPos - startPos; - - // speed factor - double factor = Math.Abs(subDiff) < 0.001 ? 1 : realDiff / subDiff; - - // adjust to starting position - double adjust = startPos - subStart * factor; - - for (int i = minIndex; i < _subtitle.Paragraphs.Count; i++) - { - if (i <= maxIndex) - { - Paragraph p = _subtitle.Paragraphs[i]; - p.StartTime.TotalMilliseconds = _originalSubtitle.Paragraphs[i].StartTime.TotalMilliseconds; - p.EndTime.TotalMilliseconds = _originalSubtitle.Paragraphs[i].EndTime.TotalMilliseconds; - p.Adjust(factor, adjust); - } - } - } - } - - private void buttonSync_Click(object sender, EventArgs e) - { - if (_synchronizationPoints.Count == 1) - { - foreach (KeyValuePair kvp in _synchronizationPoints) - { - AdjustViaShowEarlierLater(kvp.Key, kvp.Value.TotalMilliseconds); - } - - _synchronizationPoints = new SortedDictionary(); - SubtitleListview1.Fill(_subtitle); - RefreshSynchronizationPointsUi(); - return; - } - - int endIndex = -1; - int minIndex = 0; - var syncIndices = new List(); - foreach (var kvp in _synchronizationPoints) - { - syncIndices.Add(kvp.Key); - } - - for (int i = 0; i < syncIndices.Count; i++) - { - if (i == 0) - { - endIndex = syncIndices[i]; - } - else - { - var startIndex = endIndex; - endIndex = syncIndices[i]; - - int maxIndex; - if (i == syncIndices.Count - 1) - { - maxIndex = _subtitle.Paragraphs.Count; - } - else - { - maxIndex = syncIndices[i]; - } - - Sync(startIndex, endIndex, minIndex, maxIndex, _synchronizationPoints[startIndex].TotalMilliseconds / TimeCode.BaseUnit, _synchronizationPoints[endIndex].TotalMilliseconds / TimeCode.BaseUnit); - - minIndex = endIndex; - } - } - SubtitleListview1.Fill(_subtitle); - RefreshSynchronizationPointsUi(); - } - - private void AdjustViaShowEarlierLater(int index, double newTotalMilliseconds) - { - var oldTotalMilliseconds = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds; - var diff = newTotalMilliseconds - oldTotalMilliseconds; - _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(diff)); - } - - private void listBoxSyncPoints_SelectedIndexChanged(object sender, EventArgs e) - { - if (listBoxSyncPoints.SelectedIndex >= 0) - { - var item = (ListBoxSyncPoint)listBoxSyncPoints.Items[listBoxSyncPoints.SelectedIndex]; - SubtitleListview1.SelectIndexAndEnsureVisible(item.Index); - } - } - - private void SubtitleListview1_MouseDoubleClick(object sender, MouseEventArgs e) - { - if (SubtitleListview1.SelectedItems.Count == 1) - { - int index = SubtitleListview1.SelectedItems[0].Index; - if (_synchronizationPoints.ContainsKey(index)) - { - buttonRemoveSyncPoint_Click(null, null); - } - else - { - buttonSetSyncPoint_Click(null, null); - } - } - } - - private void SyncPointsSyncResize(object sender, EventArgs e) - { - if (subtitleListView2.Visible) - { - int widthInMiddle = listBoxSyncPoints.Width; - SubtitleListview1.Width = (groupBoxImportResult.Width - widthInMiddle) / 2 - 12; - subtitleListView2.Width = SubtitleListview1.Width; - subtitleListView2.Left = SubtitleListview1.Left + SubtitleListview1.Width + widthInMiddle + 10; - listBoxSyncPoints.Left = SubtitleListview1.Left + SubtitleListview1.Width + 5; - buttonSetSyncPoint.Left = listBoxSyncPoints.Left; - buttonRemoveSyncPoint.Left = listBoxSyncPoints.Left; - labelAdjustFactor.Left = listBoxSyncPoints.Left; - labelNoOfSyncPoints.Left = listBoxSyncPoints.Left; - labelOtherSubtitleFileName.Left = subtitleListView2.Left; - buttonFindText.Left = SubtitleListview1.Left + SubtitleListview1.Width - buttonFindText.Width; - } - } - - private void SyncPointsSyncShown(object sender, EventArgs e) - { - SyncPointsSyncResize(null, null); - } - - private void ButtonFindTextClick(object sender, EventArgs e) - { - using (var findSubtitle = new FindSubtitleLine()) - { - findSubtitle.Initialize(_subtitle.Paragraphs, string.Empty); - findSubtitle.ShowDialog(); - if (findSubtitle.SelectedIndex >= 0) - { - SubtitleListview1.SelectIndexAndEnsureVisible(findSubtitle.SelectedIndex); - } - } - } - - private void ButtonFindTextOtherClick(object sender, EventArgs e) - { - using (var findSubtitle = new FindSubtitleLine()) - { - findSubtitle.Initialize(_otherSubtitle.Paragraphs, string.Empty); - findSubtitle.ShowDialog(); - if (findSubtitle.SelectedIndex >= 0) - { - subtitleListView2.SelectIndexAndEnsureVisible(findSubtitle.SelectedIndex); - } - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.Linq; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class SyncPointsSync : PositionAndSizeForm + { + public class ListBoxSyncPoint + { + public int Index { get; set; } + public string Text { get; set; } + + public override string ToString() + { + return Text; + } + } + + private string _subtitleFileName; + private int _audioTrackNumber; + private Subtitle _subtitle; + private Subtitle _originalSubtitle; + private Subtitle _otherSubtitle; + private SortedDictionary _synchronizationPoints = new SortedDictionary(); + private readonly Keys _mainGeneralGoToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle); + private readonly Keys _mainGeneralGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitle); + + public string VideoFileName { get; private set; } + + public Subtitle FixedSubtitle => _subtitle; + + public SyncPointsSync() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + buttonSetSyncPoint.Text = Configuration.Settings.Language.PointSync.SetSyncPoint; + buttonRemoveSyncPoint.Text = Configuration.Settings.Language.PointSync.RemoveSyncPoint; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonApplySync.Text = Configuration.Settings.Language.PointSync.ApplySync; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + labelNoOfSyncPoints.Text = string.Format(Configuration.Settings.Language.PointSync.SyncPointsX, 0); + labelSyncInfo.Text = Configuration.Settings.Language.PointSync.Info; + buttonFindText.Text = Configuration.Settings.Language.VisualSync.FindText; + buttonFindTextOther.Text = Configuration.Settings.Language.VisualSync.FindText; + SubtitleListview1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + subtitleListView2.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + SubtitleListview1.InitializeTimestampColumnWidths(this); + subtitleListView2.InitializeTimestampColumnWidths(this); + UiUtil.InitializeSubtitleFont(SubtitleListview1); + UiUtil.InitializeSubtitleFont(subtitleListView2); + SubtitleListview1.AutoSizeAllColumns(this); + subtitleListView2.AutoSizeAllColumns(this); + UiUtil.FixLargeFonts(this, buttonOK); + labelAdjustFactor.Text = string.Empty; + } + + public void Initialize(Subtitle subtitle, string subtitleFileName, string videoFileName, int audioTrackNumber) + { + Text = Configuration.Settings.Language.PointSync.Title; + labelSubtitleFileName.Text = subtitleFileName; + _subtitle = new Subtitle(subtitle); + _originalSubtitle = subtitle; + _subtitleFileName = subtitleFileName; + VideoFileName = videoFileName; + _audioTrackNumber = audioTrackNumber; + SubtitleListview1.Fill(subtitle); + if (SubtitleListview1.Items.Count > 0) + { + SubtitleListview1.Items[0].Selected = true; + } + + SubtitleListview1.Anchor = AnchorStyles.Left; + buttonSetSyncPoint.Anchor = AnchorStyles.Left; + buttonRemoveSyncPoint.Anchor = AnchorStyles.Left; + labelNoOfSyncPoints.Anchor = AnchorStyles.Left; + listBoxSyncPoints.Anchor = AnchorStyles.Left; + groupBoxImportResult.Anchor = AnchorStyles.Left; + labelOtherSubtitleFileName.Visible = false; + subtitleListView2.Visible = false; + buttonFindTextOther.Visible = false; + groupBoxImportResult.Width = listBoxSyncPoints.Left + listBoxSyncPoints.Width + 20; + Width = groupBoxImportResult.Left + groupBoxImportResult.Width + 15; + SubtitleListview1.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right; + buttonSetSyncPoint.Anchor = AnchorStyles.Right; + buttonRemoveSyncPoint.Anchor = AnchorStyles.Right; + labelNoOfSyncPoints.Anchor = AnchorStyles.Right; + listBoxSyncPoints.Anchor = AnchorStyles.Right; + groupBoxImportResult.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right; + buttonFindText.Left = SubtitleListview1.Left + SubtitleListview1.Width - buttonFindText.Width; + Width = 900; + groupBoxImportResult.Width = Width - groupBoxImportResult.Left * 3; + labelAdjustFactor.Left = listBoxSyncPoints.Left; + labelAdjustFactor.Anchor = listBoxSyncPoints.Anchor; + MinimumSize = new Size(Width - 50, MinimumSize.Height); + } + + public void Initialize(Subtitle subtitle, string subtitleFileName, string videoFileName, int audioTrackNumber, string otherSubtitleFileName, Subtitle otherSubtitle) + { + Text = Configuration.Settings.Language.PointSync.TitleViaOtherSubtitle; + labelSubtitleFileName.Text = subtitleFileName; + _subtitle = new Subtitle(subtitle); + _otherSubtitle = otherSubtitle; + _originalSubtitle = subtitle; + _subtitleFileName = subtitleFileName; + VideoFileName = videoFileName; + _audioTrackNumber = audioTrackNumber; + SubtitleListview1.Fill(subtitle); + if (SubtitleListview1.Items.Count > 0) + { + SubtitleListview1.Items[0].Selected = true; + } + + labelOtherSubtitleFileName.Text = otherSubtitleFileName; + subtitleListView2.Fill(otherSubtitle); + + SubtitleListview1.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; + subtitleListView2.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom; + buttonSetSyncPoint.Anchor = AnchorStyles.Left; + buttonRemoveSyncPoint.Anchor = AnchorStyles.Left; + labelNoOfSyncPoints.Anchor = AnchorStyles.Left; + listBoxSyncPoints.Anchor = AnchorStyles.Left; + labelAdjustFactor.Anchor = listBoxSyncPoints.Anchor; + labelOtherSubtitleFileName.Visible = true; + subtitleListView2.Visible = true; + buttonFindTextOther.Visible = true; + Width = subtitleListView2.Width * 2 + 250; + MinimumSize = new Size(Width - 50, MinimumSize.Height); + } + + private void RefreshSynchronizationPointsUi() + { + buttonApplySync.Enabled = _synchronizationPoints.Count > 0; + labelNoOfSyncPoints.Text = string.Format(Configuration.Settings.Language.PointSync.SyncPointsX, _synchronizationPoints.Count); + + listBoxSyncPoints.Items.Clear(); + + for (int i = 0; i < SubtitleListview1.Items.Count; i++) + { + if (_synchronizationPoints.ContainsKey(i)) + { + var p = new Paragraph { StartTime = { TotalMilliseconds = _synchronizationPoints[i].TotalMilliseconds } }; + p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + _subtitle.Paragraphs[i].Duration.TotalMilliseconds; + SubtitleListview1.SetStartTimeAndDuration(i, p, _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1)); + + var item = new ListBoxSyncPoint { Index = i, Text = _subtitle.Paragraphs[i].Number + " - " + p.StartTime }; + listBoxSyncPoints.Items.Add(item); + SubtitleListview1.SetBackgroundColor(i, Color.Green); + SubtitleListview1.SetNumber(_subtitle.Paragraphs[i].Number, "* * * *"); + } + else + { + SubtitleListview1.SetBackgroundColor(i, SubtitleListview1.BackColor); + SubtitleListview1.SetNumber(i, _subtitle.Paragraphs[i].Number.ToString(CultureInfo.InvariantCulture)); + SubtitleListview1.SetStartTimeAndDuration(i, _subtitle.Paragraphs[i], _subtitle.GetParagraphOrDefault(i + 1), _subtitle.GetParagraphOrDefault(i - 1)); + } + } + } + + private void buttonSetSyncPoint_Click(object sender, EventArgs e) + { + if (subtitleListView2.Visible) + { + SetSyncPointViaOthersubtitle(); + } + else + { + if (SubtitleListview1.SelectedItems.Count == 1 && _subtitle != null) + { + using (var getTime = new SetSyncPoint()) + { + int index = SubtitleListview1.SelectedItems[0].Index; + getTime.Initialize(_subtitle, _subtitleFileName, index, VideoFileName, _audioTrackNumber); + if (getTime.ShowDialog(this) == DialogResult.OK) + { + if (_synchronizationPoints.ContainsKey(index)) + { + _synchronizationPoints[index] = getTime.SynchronizationPoint; + } + else + { + _synchronizationPoints.Add(index, getTime.SynchronizationPoint); + } + + RefreshSynchronizationPointsUi(); + VideoFileName = getTime.VideoFileName; + } + Activate(); + VideoFileName = getTime.VideoFileName; + } + } + } + SetSyncFactorLabel(); + } + + private void SetSyncPointViaOthersubtitle() + { + if (_otherSubtitle != null && subtitleListView2.SelectedItems.Count == 1) + { + int index = SubtitleListview1.SelectedItems[0].Index; + int indexOther = subtitleListView2.SelectedItems[0].Index; + + if (_synchronizationPoints.ContainsKey(index)) + { + _synchronizationPoints[index] = TimeSpan.FromMilliseconds(_otherSubtitle.Paragraphs[indexOther].StartTime.TotalMilliseconds); + } + else + { + _synchronizationPoints.Add(index, TimeSpan.FromMilliseconds(_otherSubtitle.Paragraphs[indexOther].StartTime.TotalMilliseconds)); + } + + RefreshSynchronizationPointsUi(); + } + SetSyncFactorLabel(); + } + + private void buttonRemoveSyncPoint_Click(object sender, EventArgs e) + { + if (SubtitleListview1.SelectedItems.Count == 1 && _subtitle != null) + { + int index = SubtitleListview1.SelectedItems[0].Index; + if (_synchronizationPoints.ContainsKey(index)) + { + _synchronizationPoints.Remove(index); + } + + RefreshSynchronizationPointsUi(); + } + SetSyncFactorLabel(); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + if (buttonApplySync.Enabled) + { + buttonSync_Click(null, null); + } + + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void SyncPointsSync_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#sync"); + e.SuppressKeyPress = true; + } + else if (_mainGeneralGoToNextSubtitle == e.KeyData || (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)) + { + int selectedIndex = 0; + if (SubtitleListview1.SelectedItems.Count > 0) + { + selectedIndex = SubtitleListview1.SelectedItems[0].Index; + selectedIndex++; + } + SubtitleListview1.SelectIndexAndEnsureVisible(selectedIndex); + e.SuppressKeyPress = true; + } + else if (_mainGeneralGoToPrevSubtitle == e.KeyData || (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt)) + { + int selectedIndex = 0; + if (SubtitleListview1.SelectedItems.Count > 0) + { + selectedIndex = SubtitleListview1.SelectedItems[0].Index; + selectedIndex--; + } + SubtitleListview1.SelectIndexAndEnsureVisible(selectedIndex); + e.SuppressKeyPress = true; + } + else if (e.KeyData == (Keys.Control | Keys.G)) + { + var subView = SubtitleListview1; + if (subtitleListView2 != null && subtitleListView2.Visible && !SubtitleListview1.Focused) + { + var x = PointToClient(MousePosition).X; + if (x >= subtitleListView2.Left && x <= subtitleListView2.Left + subtitleListView2.Width) + { + subView = subtitleListView2; + } + } + using (var gotoForm = new GoToLine()) + { + gotoForm.Initialize(1, subView.Items.Count); + if (gotoForm.ShowDialog() == DialogResult.OK) + { + subView.SelectIndexAndEnsureVisible(gotoForm.LineNumber - 1, true); + } + } + } + } + + private void SetSyncFactorLabel() + { + labelAdjustFactor.Text = string.Empty; + if (_synchronizationPoints.Count == 1) + { + double startPos = _synchronizationPoints.First().Value.TotalMilliseconds / TimeCode.BaseUnit; + double subStart = _originalSubtitle.Paragraphs[_synchronizationPoints.First().Key].StartTime.TotalMilliseconds / TimeCode.BaseUnit; + + var adjustment = startPos - subStart; + labelAdjustFactor.Text = $"{adjustment:+0.000;-0.000}"; + } + else if (_synchronizationPoints.Count == 2) + { + double startPos = _synchronizationPoints.First().Value.TotalMilliseconds / TimeCode.BaseUnit; + double endPos = _synchronizationPoints.Last().Value.TotalMilliseconds / TimeCode.BaseUnit; + + double subStart = _originalSubtitle.Paragraphs[_synchronizationPoints.First().Key].StartTime.TotalMilliseconds / TimeCode.BaseUnit; + double subEnd = _originalSubtitle.Paragraphs[_synchronizationPoints.Last().Key].StartTime.TotalMilliseconds / TimeCode.BaseUnit; + + double subDiff = subEnd - subStart; + double realDiff = endPos - startPos; + + // speed factor + double factor = realDiff / subDiff; + + // adjust to starting position + double adjust = startPos - subStart * factor; + + labelAdjustFactor.Text = $"*{factor:0.000}, {adjust:+0.000;-0.000}"; + } + } + + private void Sync(int startIndex, int endIndex, int minIndex, int maxIndex, double startPos, double endPos) + { + if (endPos > startPos) + { + double subStart = _originalSubtitle.Paragraphs[startIndex].StartTime.TotalMilliseconds / TimeCode.BaseUnit; + double subEnd = _originalSubtitle.Paragraphs[endIndex].StartTime.TotalMilliseconds / TimeCode.BaseUnit; + + double subDiff = subEnd - subStart; + double realDiff = endPos - startPos; + + // speed factor + double factor = Math.Abs(subDiff) < 0.001 ? 1 : realDiff / subDiff; + + // adjust to starting position + double adjust = startPos - subStart * factor; + + for (int i = minIndex; i < _subtitle.Paragraphs.Count; i++) + { + if (i <= maxIndex) + { + Paragraph p = _subtitle.Paragraphs[i]; + p.StartTime.TotalMilliseconds = _originalSubtitle.Paragraphs[i].StartTime.TotalMilliseconds; + p.EndTime.TotalMilliseconds = _originalSubtitle.Paragraphs[i].EndTime.TotalMilliseconds; + p.Adjust(factor, adjust); + } + } + } + } + + private void buttonSync_Click(object sender, EventArgs e) + { + if (_synchronizationPoints.Count == 1) + { + foreach (KeyValuePair kvp in _synchronizationPoints) + { + AdjustViaShowEarlierLater(kvp.Key, kvp.Value.TotalMilliseconds); + } + + _synchronizationPoints = new SortedDictionary(); + SubtitleListview1.Fill(_subtitle); + RefreshSynchronizationPointsUi(); + return; + } + + int endIndex = -1; + int minIndex = 0; + var syncIndices = new List(); + foreach (var kvp in _synchronizationPoints) + { + syncIndices.Add(kvp.Key); + } + + for (int i = 0; i < syncIndices.Count; i++) + { + if (i == 0) + { + endIndex = syncIndices[i]; + } + else + { + var startIndex = endIndex; + endIndex = syncIndices[i]; + + int maxIndex; + if (i == syncIndices.Count - 1) + { + maxIndex = _subtitle.Paragraphs.Count; + } + else + { + maxIndex = syncIndices[i]; + } + + Sync(startIndex, endIndex, minIndex, maxIndex, _synchronizationPoints[startIndex].TotalMilliseconds / TimeCode.BaseUnit, _synchronizationPoints[endIndex].TotalMilliseconds / TimeCode.BaseUnit); + + minIndex = endIndex; + } + } + SubtitleListview1.Fill(_subtitle); + RefreshSynchronizationPointsUi(); + } + + private void AdjustViaShowEarlierLater(int index, double newTotalMilliseconds) + { + var oldTotalMilliseconds = _subtitle.Paragraphs[index].StartTime.TotalMilliseconds; + var diff = newTotalMilliseconds - oldTotalMilliseconds; + _subtitle.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(diff)); + } + + private void listBoxSyncPoints_SelectedIndexChanged(object sender, EventArgs e) + { + if (listBoxSyncPoints.SelectedIndex >= 0) + { + var item = (ListBoxSyncPoint)listBoxSyncPoints.Items[listBoxSyncPoints.SelectedIndex]; + SubtitleListview1.SelectIndexAndEnsureVisible(item.Index); + } + } + + private void SubtitleListview1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (SubtitleListview1.SelectedItems.Count == 1) + { + int index = SubtitleListview1.SelectedItems[0].Index; + if (_synchronizationPoints.ContainsKey(index)) + { + buttonRemoveSyncPoint_Click(null, null); + } + else + { + buttonSetSyncPoint_Click(null, null); + } + } + } + + private void SyncPointsSyncResize(object sender, EventArgs e) + { + if (subtitleListView2.Visible) + { + int widthInMiddle = listBoxSyncPoints.Width; + SubtitleListview1.Width = (groupBoxImportResult.Width - widthInMiddle) / 2 - 12; + subtitleListView2.Width = SubtitleListview1.Width; + subtitleListView2.Left = SubtitleListview1.Left + SubtitleListview1.Width + widthInMiddle + 10; + listBoxSyncPoints.Left = SubtitleListview1.Left + SubtitleListview1.Width + 5; + buttonSetSyncPoint.Left = listBoxSyncPoints.Left; + buttonRemoveSyncPoint.Left = listBoxSyncPoints.Left; + labelAdjustFactor.Left = listBoxSyncPoints.Left; + labelNoOfSyncPoints.Left = listBoxSyncPoints.Left; + labelOtherSubtitleFileName.Left = subtitleListView2.Left; + buttonFindText.Left = SubtitleListview1.Left + SubtitleListview1.Width - buttonFindText.Width; + } + } + + private void SyncPointsSyncShown(object sender, EventArgs e) + { + SyncPointsSyncResize(null, null); + } + + private void ButtonFindTextClick(object sender, EventArgs e) + { + using (var findSubtitle = new FindSubtitleLine()) + { + findSubtitle.Initialize(_subtitle.Paragraphs, string.Empty); + findSubtitle.ShowDialog(); + if (findSubtitle.SelectedIndex >= 0) + { + SubtitleListview1.SelectIndexAndEnsureVisible(findSubtitle.SelectedIndex); + } + } + } + + private void ButtonFindTextOtherClick(object sender, EventArgs e) + { + using (var findSubtitle = new FindSubtitleLine()) + { + findSubtitle.Initialize(_otherSubtitle.Paragraphs, string.Empty); + findSubtitle.ShowDialog(); + if (findSubtitle.SelectedIndex >= 0) + { + subtitleListView2.SelectIndexAndEnsureVisible(findSubtitle.SelectedIndex); + } + } + } + + } +} diff --git a/src/Forms/SyncPointsSync.resx b/src/ui/Forms/SyncPointsSync.resx similarity index 97% rename from src/Forms/SyncPointsSync.resx rename to src/ui/Forms/SyncPointsSync.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/SyncPointsSync.resx +++ b/src/ui/Forms/SyncPointsSync.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/TextPrompt.Designer.cs b/src/ui/Forms/TextPrompt.Designer.cs similarity index 100% rename from src/Forms/TextPrompt.Designer.cs rename to src/ui/Forms/TextPrompt.Designer.cs diff --git a/src/Forms/TextPrompt.cs b/src/ui/Forms/TextPrompt.cs similarity index 100% rename from src/Forms/TextPrompt.cs rename to src/ui/Forms/TextPrompt.cs diff --git a/src/ui/Forms/TextPrompt.resx b/src/ui/Forms/TextPrompt.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/src/ui/Forms/TextPrompt.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Forms/TimedTextNewLanguage.Designer.cs b/src/ui/Forms/TimedTextNewLanguage.Designer.cs similarity index 100% rename from src/Forms/TimedTextNewLanguage.Designer.cs rename to src/ui/Forms/TimedTextNewLanguage.Designer.cs diff --git a/src/Forms/TimedTextNewLanguage.cs b/src/ui/Forms/TimedTextNewLanguage.cs similarity index 100% rename from src/Forms/TimedTextNewLanguage.cs rename to src/ui/Forms/TimedTextNewLanguage.cs diff --git a/src/ui/Forms/TimedTextNewLanguage.resx b/src/ui/Forms/TimedTextNewLanguage.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/src/ui/Forms/TimedTextNewLanguage.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Forms/TimedTextProperties.Designer.cs b/src/ui/Forms/TimedTextProperties.Designer.cs similarity index 98% rename from src/Forms/TimedTextProperties.Designer.cs rename to src/ui/Forms/TimedTextProperties.Designer.cs index 36916131b..efa7d25cd 100644 --- a/src/Forms/TimedTextProperties.Designer.cs +++ b/src/ui/Forms/TimedTextProperties.Designer.cs @@ -1,384 +1,384 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class TimedTextProperties - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.groupBoxOptions = new System.Windows.Forms.GroupBox(); - this.comboBoxTimeCodeFormat = new System.Windows.Forms.ComboBox(); - this.labelTimeCode = new System.Windows.Forms.Label(); - this.comboBoxFrameRateMultiplier = new System.Windows.Forms.ComboBox(); - this.textBoxDescription = new System.Windows.Forms.TextBox(); - this.label7 = new System.Windows.Forms.Label(); - this.textBoxTitle = new System.Windows.Forms.TextBox(); - this.label6 = new System.Windows.Forms.Label(); - this.comboBoxDefaultRegion = new System.Windows.Forms.ComboBox(); - this.labelDefaultRegion = new System.Windows.Forms.Label(); - this.comboBoxDropMode = new System.Windows.Forms.ComboBox(); - this.label4 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.comboBoxFrameRate = new System.Windows.Forms.ComboBox(); - this.label2 = new System.Windows.Forms.Label(); - this.comboBoxTimeBase = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); - this.comboBoxLanguage = new System.Windows.Forms.ComboBox(); - this.labelCollision = new System.Windows.Forms.Label(); - this.comboBoxDefaultStyle = new System.Windows.Forms.ComboBox(); - this.labelWrapStyle = new System.Windows.Forms.Label(); - this.comboBoxFileExtensions = new System.Windows.Forms.ComboBox(); - this.labelFileExtension = new System.Windows.Forms.Label(); - this.groupBoxOptions.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(335, 401); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 1; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(416, 401); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 2; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // groupBoxOptions - // - this.groupBoxOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxOptions.Controls.Add(this.comboBoxFileExtensions); - this.groupBoxOptions.Controls.Add(this.labelFileExtension); - this.groupBoxOptions.Controls.Add(this.comboBoxTimeCodeFormat); - this.groupBoxOptions.Controls.Add(this.labelTimeCode); - this.groupBoxOptions.Controls.Add(this.comboBoxFrameRateMultiplier); - this.groupBoxOptions.Controls.Add(this.textBoxDescription); - this.groupBoxOptions.Controls.Add(this.label7); - this.groupBoxOptions.Controls.Add(this.textBoxTitle); - this.groupBoxOptions.Controls.Add(this.label6); - this.groupBoxOptions.Controls.Add(this.comboBoxDefaultRegion); - this.groupBoxOptions.Controls.Add(this.labelDefaultRegion); - this.groupBoxOptions.Controls.Add(this.comboBoxDropMode); - this.groupBoxOptions.Controls.Add(this.label4); - this.groupBoxOptions.Controls.Add(this.label3); - this.groupBoxOptions.Controls.Add(this.comboBoxFrameRate); - this.groupBoxOptions.Controls.Add(this.label2); - this.groupBoxOptions.Controls.Add(this.comboBoxTimeBase); - this.groupBoxOptions.Controls.Add(this.label1); - this.groupBoxOptions.Controls.Add(this.comboBoxLanguage); - this.groupBoxOptions.Controls.Add(this.labelCollision); - this.groupBoxOptions.Controls.Add(this.comboBoxDefaultStyle); - this.groupBoxOptions.Controls.Add(this.labelWrapStyle); - this.groupBoxOptions.Location = new System.Drawing.Point(12, 12); - this.groupBoxOptions.Name = "groupBoxOptions"; - this.groupBoxOptions.Size = new System.Drawing.Size(479, 383); - this.groupBoxOptions.TabIndex = 0; - this.groupBoxOptions.TabStop = false; - // - // comboBoxTimeCodeFormat - // - this.comboBoxTimeCodeFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxTimeCodeFormat.FormattingEnabled = true; - this.comboBoxTimeCodeFormat.Items.AddRange(new object[] { - "Source", - "Seconds", - "Milliseconds", - "Ticks", - "hh:mm:ss:ff", - "hh:mm:ss.ms", - "hh:mm:ss.ms-two-digits", - "hh:mm:ss,ms"}); - this.comboBoxTimeCodeFormat.Location = new System.Drawing.Point(191, 309); - this.comboBoxTimeCodeFormat.Name = "comboBoxTimeCodeFormat"; - this.comboBoxTimeCodeFormat.Size = new System.Drawing.Size(263, 21); - this.comboBoxTimeCodeFormat.TabIndex = 19; - // - // labelTimeCode - // - this.labelTimeCode.AutoSize = true; - this.labelTimeCode.Location = new System.Drawing.Point(6, 312); - this.labelTimeCode.Name = "labelTimeCode"; - this.labelTimeCode.Size = new System.Drawing.Size(89, 13); - this.labelTimeCode.TabIndex = 20; - this.labelTimeCode.Text = "Time code format"; - // - // comboBoxFrameRateMultiplier - // - this.comboBoxFrameRateMultiplier.FormattingEnabled = true; - this.comboBoxFrameRateMultiplier.Items.AddRange(new object[] { - "999 1000", - "1 1", - "1000 1001"}); - this.comboBoxFrameRateMultiplier.Location = new System.Drawing.Point(191, 176); - this.comboBoxFrameRateMultiplier.Name = "comboBoxFrameRateMultiplier"; - this.comboBoxFrameRateMultiplier.Size = new System.Drawing.Size(263, 21); - this.comboBoxFrameRateMultiplier.TabIndex = 18; - // - // textBoxDescription - // - this.textBoxDescription.Location = new System.Drawing.Point(191, 56); - this.textBoxDescription.Name = "textBoxDescription"; - this.textBoxDescription.Size = new System.Drawing.Size(263, 20); - this.textBoxDescription.TabIndex = 1; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(6, 58); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(60, 13); - this.label7.TabIndex = 17; - this.label7.Text = "Description"; - // - // textBoxTitle - // - this.textBoxTitle.Location = new System.Drawing.Point(191, 30); - this.textBoxTitle.Name = "textBoxTitle"; - this.textBoxTitle.Size = new System.Drawing.Size(263, 20); - this.textBoxTitle.TabIndex = 0; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(6, 32); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(27, 13); - this.label6.TabIndex = 15; - this.label6.Text = "Title"; - // - // comboBoxDefaultRegion - // - this.comboBoxDefaultRegion.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxDefaultRegion.FormattingEnabled = true; - this.comboBoxDefaultRegion.Location = new System.Drawing.Point(191, 270); - this.comboBoxDefaultRegion.Name = "comboBoxDefaultRegion"; - this.comboBoxDefaultRegion.Size = new System.Drawing.Size(263, 21); - this.comboBoxDefaultRegion.TabIndex = 8; - // - // labelDefaultRegion - // - this.labelDefaultRegion.AutoSize = true; - this.labelDefaultRegion.Location = new System.Drawing.Point(6, 273); - this.labelDefaultRegion.Name = "labelDefaultRegion"; - this.labelDefaultRegion.Size = new System.Drawing.Size(73, 13); - this.labelDefaultRegion.TabIndex = 12; - this.labelDefaultRegion.Text = "Default region"; - // - // comboBoxDropMode - // - this.comboBoxDropMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxDropMode.FormattingEnabled = true; - this.comboBoxDropMode.Items.AddRange(new object[] { - "[N/A]", - "dropNTSC", - "dropPAL", - "nonDrop"}); - this.comboBoxDropMode.Location = new System.Drawing.Point(191, 203); - this.comboBoxDropMode.Name = "comboBoxDropMode"; - this.comboBoxDropMode.Size = new System.Drawing.Size(263, 21); - this.comboBoxDropMode.TabIndex = 6; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(6, 206); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(59, 13); - this.label4.TabIndex = 10; - this.label4.Text = "Drop mode"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(6, 179); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(100, 13); - this.label3.TabIndex = 8; - this.label3.Text = "Frame rate multiplier"; - // - // comboBoxFrameRate - // - this.comboBoxFrameRate.FormattingEnabled = true; - this.comboBoxFrameRate.Location = new System.Drawing.Point(191, 149); - this.comboBoxFrameRate.Name = "comboBoxFrameRate"; - this.comboBoxFrameRate.Size = new System.Drawing.Size(263, 21); - this.comboBoxFrameRate.TabIndex = 4; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(6, 152); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(57, 13); - this.label2.TabIndex = 6; - this.label2.Text = "Frame rate"; - // - // comboBoxTimeBase - // - this.comboBoxTimeBase.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxTimeBase.FormattingEnabled = true; - this.comboBoxTimeBase.Items.AddRange(new object[] { - "[N/A]", - "media", - "smpte", - "clock"}); - this.comboBoxTimeBase.Location = new System.Drawing.Point(191, 122); - this.comboBoxTimeBase.Name = "comboBoxTimeBase"; - this.comboBoxTimeBase.Size = new System.Drawing.Size(263, 21); - this.comboBoxTimeBase.TabIndex = 3; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(6, 125); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(56, 13); - this.label1.TabIndex = 4; - this.label1.Text = "Time base"; - // - // comboBoxLanguage - // - this.comboBoxLanguage.FormattingEnabled = true; - this.comboBoxLanguage.Location = new System.Drawing.Point(191, 95); - this.comboBoxLanguage.Name = "comboBoxLanguage"; - this.comboBoxLanguage.Size = new System.Drawing.Size(263, 21); - this.comboBoxLanguage.TabIndex = 2; - // - // labelCollision - // - this.labelCollision.AutoSize = true; - this.labelCollision.Location = new System.Drawing.Point(6, 98); - this.labelCollision.Name = "labelCollision"; - this.labelCollision.Size = new System.Drawing.Size(55, 13); - this.labelCollision.TabIndex = 3; - this.labelCollision.Text = "Language"; - // - // comboBoxDefaultStyle - // - this.comboBoxDefaultStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxDefaultStyle.FormattingEnabled = true; - this.comboBoxDefaultStyle.Location = new System.Drawing.Point(191, 243); - this.comboBoxDefaultStyle.Name = "comboBoxDefaultStyle"; - this.comboBoxDefaultStyle.Size = new System.Drawing.Size(263, 21); - this.comboBoxDefaultStyle.TabIndex = 7; - // - // labelWrapStyle - // - this.labelWrapStyle.AutoSize = true; - this.labelWrapStyle.Location = new System.Drawing.Point(6, 246); - this.labelWrapStyle.Name = "labelWrapStyle"; - this.labelWrapStyle.Size = new System.Drawing.Size(65, 13); - this.labelWrapStyle.TabIndex = 1; - this.labelWrapStyle.Text = "Default style"; - // - // comboBoxFileExtensions - // - this.comboBoxFileExtensions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxFileExtensions.FormattingEnabled = true; - this.comboBoxFileExtensions.Items.AddRange(new object[] { - ".xml", - ".ttml", - ".dfxp"}); - this.comboBoxFileExtensions.Location = new System.Drawing.Point(191, 346); - this.comboBoxFileExtensions.Name = "comboBoxFileExtensions"; - this.comboBoxFileExtensions.Size = new System.Drawing.Size(263, 21); - this.comboBoxFileExtensions.TabIndex = 21; - // - // labelFileExtension - // - this.labelFileExtension.AutoSize = true; - this.labelFileExtension.Location = new System.Drawing.Point(6, 349); - this.labelFileExtension.Name = "labelFileExtension"; - this.labelFileExtension.Size = new System.Drawing.Size(71, 13); - this.labelFileExtension.TabIndex = 22; - this.labelFileExtension.Text = "File extension"; - // - // TimedTextProperties - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(503, 434); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.groupBoxOptions); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "TimedTextProperties"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Timed Text properties"; - this.groupBoxOptions.ResumeLayout(false); - this.groupBoxOptions.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.GroupBox groupBoxOptions; - private System.Windows.Forms.ComboBox comboBoxDropMode; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.ComboBox comboBoxFrameRate; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.ComboBox comboBoxTimeBase; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.ComboBox comboBoxLanguage; - private System.Windows.Forms.Label labelCollision; - private System.Windows.Forms.ComboBox comboBoxDefaultStyle; - private System.Windows.Forms.Label labelWrapStyle; - private System.Windows.Forms.ComboBox comboBoxDefaultRegion; - private System.Windows.Forms.Label labelDefaultRegion; - private System.Windows.Forms.TextBox textBoxDescription; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.TextBox textBoxTitle; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.ComboBox comboBoxFrameRateMultiplier; - private System.Windows.Forms.ComboBox comboBoxTimeCodeFormat; - private System.Windows.Forms.Label labelTimeCode; - private System.Windows.Forms.ComboBox comboBoxFileExtensions; - private System.Windows.Forms.Label labelFileExtension; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class TimedTextProperties + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxOptions = new System.Windows.Forms.GroupBox(); + this.comboBoxTimeCodeFormat = new System.Windows.Forms.ComboBox(); + this.labelTimeCode = new System.Windows.Forms.Label(); + this.comboBoxFrameRateMultiplier = new System.Windows.Forms.ComboBox(); + this.textBoxDescription = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.textBoxTitle = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.comboBoxDefaultRegion = new System.Windows.Forms.ComboBox(); + this.labelDefaultRegion = new System.Windows.Forms.Label(); + this.comboBoxDropMode = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.comboBoxFrameRate = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.comboBoxTimeBase = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.comboBoxLanguage = new System.Windows.Forms.ComboBox(); + this.labelCollision = new System.Windows.Forms.Label(); + this.comboBoxDefaultStyle = new System.Windows.Forms.ComboBox(); + this.labelWrapStyle = new System.Windows.Forms.Label(); + this.comboBoxFileExtensions = new System.Windows.Forms.ComboBox(); + this.labelFileExtension = new System.Windows.Forms.Label(); + this.groupBoxOptions.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(335, 401); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 1; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(416, 401); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 2; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // groupBoxOptions + // + this.groupBoxOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxOptions.Controls.Add(this.comboBoxFileExtensions); + this.groupBoxOptions.Controls.Add(this.labelFileExtension); + this.groupBoxOptions.Controls.Add(this.comboBoxTimeCodeFormat); + this.groupBoxOptions.Controls.Add(this.labelTimeCode); + this.groupBoxOptions.Controls.Add(this.comboBoxFrameRateMultiplier); + this.groupBoxOptions.Controls.Add(this.textBoxDescription); + this.groupBoxOptions.Controls.Add(this.label7); + this.groupBoxOptions.Controls.Add(this.textBoxTitle); + this.groupBoxOptions.Controls.Add(this.label6); + this.groupBoxOptions.Controls.Add(this.comboBoxDefaultRegion); + this.groupBoxOptions.Controls.Add(this.labelDefaultRegion); + this.groupBoxOptions.Controls.Add(this.comboBoxDropMode); + this.groupBoxOptions.Controls.Add(this.label4); + this.groupBoxOptions.Controls.Add(this.label3); + this.groupBoxOptions.Controls.Add(this.comboBoxFrameRate); + this.groupBoxOptions.Controls.Add(this.label2); + this.groupBoxOptions.Controls.Add(this.comboBoxTimeBase); + this.groupBoxOptions.Controls.Add(this.label1); + this.groupBoxOptions.Controls.Add(this.comboBoxLanguage); + this.groupBoxOptions.Controls.Add(this.labelCollision); + this.groupBoxOptions.Controls.Add(this.comboBoxDefaultStyle); + this.groupBoxOptions.Controls.Add(this.labelWrapStyle); + this.groupBoxOptions.Location = new System.Drawing.Point(12, 12); + this.groupBoxOptions.Name = "groupBoxOptions"; + this.groupBoxOptions.Size = new System.Drawing.Size(479, 383); + this.groupBoxOptions.TabIndex = 0; + this.groupBoxOptions.TabStop = false; + // + // comboBoxTimeCodeFormat + // + this.comboBoxTimeCodeFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxTimeCodeFormat.FormattingEnabled = true; + this.comboBoxTimeCodeFormat.Items.AddRange(new object[] { + "Source", + "Seconds", + "Milliseconds", + "Ticks", + "hh:mm:ss:ff", + "hh:mm:ss.ms", + "hh:mm:ss.ms-two-digits", + "hh:mm:ss,ms"}); + this.comboBoxTimeCodeFormat.Location = new System.Drawing.Point(191, 309); + this.comboBoxTimeCodeFormat.Name = "comboBoxTimeCodeFormat"; + this.comboBoxTimeCodeFormat.Size = new System.Drawing.Size(263, 21); + this.comboBoxTimeCodeFormat.TabIndex = 19; + // + // labelTimeCode + // + this.labelTimeCode.AutoSize = true; + this.labelTimeCode.Location = new System.Drawing.Point(6, 312); + this.labelTimeCode.Name = "labelTimeCode"; + this.labelTimeCode.Size = new System.Drawing.Size(89, 13); + this.labelTimeCode.TabIndex = 20; + this.labelTimeCode.Text = "Time code format"; + // + // comboBoxFrameRateMultiplier + // + this.comboBoxFrameRateMultiplier.FormattingEnabled = true; + this.comboBoxFrameRateMultiplier.Items.AddRange(new object[] { + "999 1000", + "1 1", + "1000 1001"}); + this.comboBoxFrameRateMultiplier.Location = new System.Drawing.Point(191, 176); + this.comboBoxFrameRateMultiplier.Name = "comboBoxFrameRateMultiplier"; + this.comboBoxFrameRateMultiplier.Size = new System.Drawing.Size(263, 21); + this.comboBoxFrameRateMultiplier.TabIndex = 18; + // + // textBoxDescription + // + this.textBoxDescription.Location = new System.Drawing.Point(191, 56); + this.textBoxDescription.Name = "textBoxDescription"; + this.textBoxDescription.Size = new System.Drawing.Size(263, 20); + this.textBoxDescription.TabIndex = 1; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(6, 58); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(60, 13); + this.label7.TabIndex = 17; + this.label7.Text = "Description"; + // + // textBoxTitle + // + this.textBoxTitle.Location = new System.Drawing.Point(191, 30); + this.textBoxTitle.Name = "textBoxTitle"; + this.textBoxTitle.Size = new System.Drawing.Size(263, 20); + this.textBoxTitle.TabIndex = 0; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(6, 32); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(27, 13); + this.label6.TabIndex = 15; + this.label6.Text = "Title"; + // + // comboBoxDefaultRegion + // + this.comboBoxDefaultRegion.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxDefaultRegion.FormattingEnabled = true; + this.comboBoxDefaultRegion.Location = new System.Drawing.Point(191, 270); + this.comboBoxDefaultRegion.Name = "comboBoxDefaultRegion"; + this.comboBoxDefaultRegion.Size = new System.Drawing.Size(263, 21); + this.comboBoxDefaultRegion.TabIndex = 8; + // + // labelDefaultRegion + // + this.labelDefaultRegion.AutoSize = true; + this.labelDefaultRegion.Location = new System.Drawing.Point(6, 273); + this.labelDefaultRegion.Name = "labelDefaultRegion"; + this.labelDefaultRegion.Size = new System.Drawing.Size(73, 13); + this.labelDefaultRegion.TabIndex = 12; + this.labelDefaultRegion.Text = "Default region"; + // + // comboBoxDropMode + // + this.comboBoxDropMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxDropMode.FormattingEnabled = true; + this.comboBoxDropMode.Items.AddRange(new object[] { + "[N/A]", + "dropNTSC", + "dropPAL", + "nonDrop"}); + this.comboBoxDropMode.Location = new System.Drawing.Point(191, 203); + this.comboBoxDropMode.Name = "comboBoxDropMode"; + this.comboBoxDropMode.Size = new System.Drawing.Size(263, 21); + this.comboBoxDropMode.TabIndex = 6; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(6, 206); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(59, 13); + this.label4.TabIndex = 10; + this.label4.Text = "Drop mode"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(6, 179); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(100, 13); + this.label3.TabIndex = 8; + this.label3.Text = "Frame rate multiplier"; + // + // comboBoxFrameRate + // + this.comboBoxFrameRate.FormattingEnabled = true; + this.comboBoxFrameRate.Location = new System.Drawing.Point(191, 149); + this.comboBoxFrameRate.Name = "comboBoxFrameRate"; + this.comboBoxFrameRate.Size = new System.Drawing.Size(263, 21); + this.comboBoxFrameRate.TabIndex = 4; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 152); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(57, 13); + this.label2.TabIndex = 6; + this.label2.Text = "Frame rate"; + // + // comboBoxTimeBase + // + this.comboBoxTimeBase.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxTimeBase.FormattingEnabled = true; + this.comboBoxTimeBase.Items.AddRange(new object[] { + "[N/A]", + "media", + "smpte", + "clock"}); + this.comboBoxTimeBase.Location = new System.Drawing.Point(191, 122); + this.comboBoxTimeBase.Name = "comboBoxTimeBase"; + this.comboBoxTimeBase.Size = new System.Drawing.Size(263, 21); + this.comboBoxTimeBase.TabIndex = 3; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 125); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(56, 13); + this.label1.TabIndex = 4; + this.label1.Text = "Time base"; + // + // comboBoxLanguage + // + this.comboBoxLanguage.FormattingEnabled = true; + this.comboBoxLanguage.Location = new System.Drawing.Point(191, 95); + this.comboBoxLanguage.Name = "comboBoxLanguage"; + this.comboBoxLanguage.Size = new System.Drawing.Size(263, 21); + this.comboBoxLanguage.TabIndex = 2; + // + // labelCollision + // + this.labelCollision.AutoSize = true; + this.labelCollision.Location = new System.Drawing.Point(6, 98); + this.labelCollision.Name = "labelCollision"; + this.labelCollision.Size = new System.Drawing.Size(55, 13); + this.labelCollision.TabIndex = 3; + this.labelCollision.Text = "Language"; + // + // comboBoxDefaultStyle + // + this.comboBoxDefaultStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxDefaultStyle.FormattingEnabled = true; + this.comboBoxDefaultStyle.Location = new System.Drawing.Point(191, 243); + this.comboBoxDefaultStyle.Name = "comboBoxDefaultStyle"; + this.comboBoxDefaultStyle.Size = new System.Drawing.Size(263, 21); + this.comboBoxDefaultStyle.TabIndex = 7; + // + // labelWrapStyle + // + this.labelWrapStyle.AutoSize = true; + this.labelWrapStyle.Location = new System.Drawing.Point(6, 246); + this.labelWrapStyle.Name = "labelWrapStyle"; + this.labelWrapStyle.Size = new System.Drawing.Size(65, 13); + this.labelWrapStyle.TabIndex = 1; + this.labelWrapStyle.Text = "Default style"; + // + // comboBoxFileExtensions + // + this.comboBoxFileExtensions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxFileExtensions.FormattingEnabled = true; + this.comboBoxFileExtensions.Items.AddRange(new object[] { + ".xml", + ".ttml", + ".dfxp"}); + this.comboBoxFileExtensions.Location = new System.Drawing.Point(191, 346); + this.comboBoxFileExtensions.Name = "comboBoxFileExtensions"; + this.comboBoxFileExtensions.Size = new System.Drawing.Size(263, 21); + this.comboBoxFileExtensions.TabIndex = 21; + // + // labelFileExtension + // + this.labelFileExtension.AutoSize = true; + this.labelFileExtension.Location = new System.Drawing.Point(6, 349); + this.labelFileExtension.Name = "labelFileExtension"; + this.labelFileExtension.Size = new System.Drawing.Size(71, 13); + this.labelFileExtension.TabIndex = 22; + this.labelFileExtension.Text = "File extension"; + // + // TimedTextProperties + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(503, 434); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.groupBoxOptions); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TimedTextProperties"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Timed Text properties"; + this.groupBoxOptions.ResumeLayout(false); + this.groupBoxOptions.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.GroupBox groupBoxOptions; + private System.Windows.Forms.ComboBox comboBoxDropMode; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ComboBox comboBoxFrameRate; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.ComboBox comboBoxTimeBase; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox comboBoxLanguage; + private System.Windows.Forms.Label labelCollision; + private System.Windows.Forms.ComboBox comboBoxDefaultStyle; + private System.Windows.Forms.Label labelWrapStyle; + private System.Windows.Forms.ComboBox comboBoxDefaultRegion; + private System.Windows.Forms.Label labelDefaultRegion; + private System.Windows.Forms.TextBox textBoxDescription; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox textBoxTitle; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.ComboBox comboBoxFrameRateMultiplier; + private System.Windows.Forms.ComboBox comboBoxTimeCodeFormat; + private System.Windows.Forms.Label labelTimeCode; + private System.Windows.Forms.ComboBox comboBoxFileExtensions; + private System.Windows.Forms.Label labelFileExtension; + } } \ No newline at end of file diff --git a/src/Forms/TimedTextProperties.cs b/src/ui/Forms/TimedTextProperties.cs similarity index 97% rename from src/Forms/TimedTextProperties.cs rename to src/ui/Forms/TimedTextProperties.cs index 0bb4dbb66..9a58d06af 100644 --- a/src/Forms/TimedTextProperties.cs +++ b/src/ui/Forms/TimedTextProperties.cs @@ -1,320 +1,320 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Globalization; -using System.Windows.Forms; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class TimedTextProperties : PositionAndSizeForm - { - private Subtitle _subtitle; - private XmlDocument _xml; - private XmlNamespaceManager _nsmgr; - private string _NA; - - public TimedTextProperties(Subtitle subtitle) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - Application.DoEvents(); - - _subtitle = subtitle; - _NA = "[" + Configuration.Settings.Language.General.NotAvailable + "]"; - comboBoxDropMode.Items[0] = _NA; - comboBoxTimeBase.Items[0] = _NA; - comboBoxDefaultStyle.Items.Add(_NA); - comboBoxDefaultRegion.Items.Add(_NA); - - _xml = new XmlDocument(); - try - { - _xml.LoadXml(subtitle.Header); - } - catch - { - subtitle.Header = new TimedText10().ToText(new Subtitle(), "tt"); - _xml.LoadXml(subtitle.Header); // load default xml - } - _nsmgr = new XmlNamespaceManager(_xml.NameTable); - _nsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml"); - - XmlNode node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:title", _nsmgr); - if (node != null) - { - textBoxTitle.Text = node.InnerText; - } - - node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:desc", _nsmgr); - if (node != null) - { - textBoxDescription.Text = node.InnerText; - } - - foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) - { - comboBoxLanguage.Items.Add(ci.Name); - } - XmlAttribute attr = _xml.DocumentElement.Attributes["xml:lang"]; - if (attr != null) - { - comboBoxLanguage.Text = attr.InnerText; - } - - attr = _xml.DocumentElement.Attributes["ttp:timeBase"]; - if (attr != null) - { - comboBoxTimeBase.Text = attr.InnerText; - } - - comboBoxFrameRate.Items.Add("23.976"); - comboBoxFrameRate.Items.Add("24.0"); - comboBoxFrameRate.Items.Add("25.0"); - comboBoxFrameRate.Items.Add("29.97"); - comboBoxFrameRate.Items.Add("30.0"); - attr = _xml.DocumentElement.Attributes["ttp:frameRate"]; - if (attr != null) - { - comboBoxFrameRate.Text = attr.InnerText; - } - - attr = _xml.DocumentElement.Attributes["ttp:frameRateMultiplier"]; - if (attr != null) - { - comboBoxFrameRateMultiplier.Text = attr.InnerText; - } - - attr = _xml.DocumentElement.Attributes["ttp:dropMode"]; - if (attr != null) - { - comboBoxDropMode.Text = attr.InnerText; - } - - foreach (string style in TimedText10.GetStylesFromHeader(_subtitle.Header)) - { - comboBoxDefaultStyle.Items.Add(style); - node = _xml.DocumentElement.SelectSingleNode("ttml:body", _nsmgr); - if (node?.Attributes?["style"] != null && style == node.Attributes["style"].Value) - { - comboBoxDefaultStyle.SelectedIndex = comboBoxDefaultStyle.Items.Count - 1; - } - } - foreach (string region in TimedText10.GetRegionsFromHeader(_subtitle.Header)) - { - comboBoxDefaultRegion.Items.Add(region); - node = _xml.DocumentElement.SelectSingleNode("ttml:body", _nsmgr); - if (node?.Attributes?["region"] != null && region == node.Attributes["region"].Value) - { - comboBoxDefaultRegion.SelectedIndex = comboBoxDefaultRegion.Items.Count - 1; - } - } - - var timeCodeFormat = Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormat.Trim().ToLowerInvariant(); - comboBoxTimeCodeFormat.SelectedIndex = 0; - for (int index = 0; index < comboBoxTimeCodeFormat.Items.Count; index++) - { - var item = comboBoxTimeCodeFormat.Items[index]; - if (item.ToString().ToLowerInvariant() == timeCodeFormat) - { - comboBoxTimeCodeFormat.SelectedIndex = index; - break; - } - } - - var ext = Configuration.Settings.SubtitleSettings.TimedText10FileExtension; - comboBoxFileExtensions.SelectedIndex = 0; - for (var index = 0; index < comboBoxFileExtensions.Items.Count; index++) - { - var item = comboBoxFileExtensions.Items[index]; - if (item.ToString() == ext) - { - comboBoxFileExtensions.SelectedIndex = index; - break; - } - } - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void buttonOK_Click(object sender, EventArgs e) - { - XmlNode node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:title", _nsmgr); - if (node != null) - { - if (string.IsNullOrWhiteSpace(textBoxTitle.Text) && string.IsNullOrWhiteSpace(textBoxDescription.Text)) - { - _xml.DocumentElement.SelectSingleNode("ttml:head", _nsmgr).RemoveChild(_xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata", _nsmgr)); - } - else - { - node.InnerText = textBoxTitle.Text; - } - } - else if (!string.IsNullOrWhiteSpace(textBoxTitle.Text)) - { - var head = _xml.DocumentElement.SelectSingleNode("ttml:head", _nsmgr); - if (head == null) - { - head = _xml.CreateElement("ttml", "head", _nsmgr.LookupNamespace("ttml")); - _xml.DocumentElement.PrependChild(head); - } - - var metadata = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata", _nsmgr); - if (metadata == null) - { - metadata = _xml.CreateElement("ttml", "metadata", _nsmgr.LookupNamespace("ttml")); - head.PrependChild(metadata); - } - - var title = _xml.CreateElement("ttml", "title", _nsmgr.LookupNamespace("ttml")); - metadata.InnerText = textBoxTitle.Text; - metadata.AppendChild(title); - } - - node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:desc", _nsmgr); - if (node != null) - { - node.InnerText = textBoxDescription.Text; - } - else if (!string.IsNullOrWhiteSpace(textBoxDescription.Text)) - { - var head = _xml.DocumentElement.SelectSingleNode("ttml:head", _nsmgr); - if (head == null) - { - head = _xml.CreateElement("ttml", "head", _nsmgr.LookupNamespace("ttml")); - _xml.DocumentElement.PrependChild(head); - } - - var metadata = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata", _nsmgr); - if (metadata == null) - { - metadata = _xml.CreateElement("ttml", "metadata", _nsmgr.LookupNamespace("ttml")); - head.PrependChild(metadata); - } - - var desc = _xml.CreateElement("ttml", "desc", _nsmgr.LookupNamespace("ttml")); - desc.InnerText = textBoxDescription.Text; - metadata.AppendChild(desc); - } - - XmlAttribute attr = _xml.DocumentElement.Attributes["xml:lang"]; - if (attr != null) - { - attr.Value = comboBoxLanguage.Text; - if (attr.Value.Length == 0) - { - _xml.DocumentElement.Attributes.Remove(attr); - } - } - else if (comboBoxLanguage.Text.Length > 0) - { - attr = _xml.CreateAttribute("xml", "lang", _nsmgr.LookupNamespace("xml")); - attr.Value = comboBoxLanguage.Text; - _xml.DocumentElement.Attributes.Prepend(attr); - } - - attr = _xml.DocumentElement.Attributes["ttp:timeBase"]; - if (attr != null) - { - attr.InnerText = comboBoxTimeBase.Text; - if (attr.Value.Length == 0) - { - _xml.DocumentElement.Attributes.Remove(attr); - } - } - else if (comboBoxTimeBase.Text.Length > 0) - { - attr = _xml.CreateAttribute("ttp", "timeBase", _nsmgr.LookupNamespace("ttp")); - attr.Value = comboBoxTimeBase.Text; - _xml.DocumentElement.Attributes.Append(attr); - } - - attr = _xml.DocumentElement.Attributes["ttp:frameRate"]; - if (attr != null) - { - attr.InnerText = comboBoxFrameRate.Text; - if (attr.Value.Length == 0) - { - _xml.DocumentElement.Attributes.Remove(attr); - } - } - else if (comboBoxFrameRate.Text.Length > 0) - { - attr = _xml.CreateAttribute("ttp", "frameRate", _nsmgr.LookupNamespace("ttp")); - attr.Value = comboBoxFrameRate.Text; - _xml.DocumentElement.Attributes.Append(attr); - } - - attr = _xml.DocumentElement.Attributes["ttp:frameRateMultiplier"]; - if (attr != null) - { - attr.InnerText = comboBoxFrameRateMultiplier.Text; - if (attr.Value.Length == 0) - { - _xml.DocumentElement.Attributes.Remove(attr); - } - } - else if (comboBoxFrameRateMultiplier.Text.Length > 0) - { - attr = _xml.CreateAttribute("ttp", "frameRateMultiplier", _nsmgr.LookupNamespace("ttp")); - attr.Value = comboBoxFrameRateMultiplier.Text; - _xml.DocumentElement.Attributes.Append(attr); - } - - attr = _xml.DocumentElement.Attributes["ttp:dropMode"]; - if (attr != null) - { - attr.InnerText = comboBoxDropMode.Text; - if (attr.Value.Length == 0) - { - _xml.DocumentElement.Attributes.Remove(attr); - } - } - else if (comboBoxDropMode.Text.Length > 0) - { - attr = _xml.CreateAttribute("ttp", "dropMode", _nsmgr.LookupNamespace("ttp")); - attr.Value = comboBoxDropMode.Text; - _xml.DocumentElement.Attributes.Append(attr); - } - - node = _xml.DocumentElement.SelectSingleNode("ttml:body", _nsmgr); - if (node != null && node.Attributes["style"] != null) - { - node.Attributes["style"].Value = comboBoxDefaultStyle.Text; - } - else if (comboBoxDefaultStyle.Text.Length > 0 && node != null) - { - attr = _xml.CreateAttribute("style"); - attr.Value = comboBoxDefaultStyle.Text; - node.Attributes.Append(attr); - } - - node = _xml.DocumentElement.SelectSingleNode("ttml:body", _nsmgr); - if (node != null && node.Attributes["region"] != null) - { - node.Attributes["region"].Value = comboBoxDefaultRegion.Text; - } - else if (comboBoxDefaultRegion.Text.Length > 0 && node != null) - { - attr = _xml.CreateAttribute("region"); - attr.Value = comboBoxDefaultRegion.Text; - node.Attributes.Append(attr); - } - - _subtitle.Header = _xml.OuterXml; - - Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormat = comboBoxTimeCodeFormat.SelectedItem.ToString(); - Configuration.Settings.SubtitleSettings.TimedText10FileExtension= comboBoxFileExtensions.SelectedItem.ToString(); - - DialogResult = DialogResult.OK; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Globalization; +using System.Windows.Forms; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class TimedTextProperties : PositionAndSizeForm + { + private Subtitle _subtitle; + private XmlDocument _xml; + private XmlNamespaceManager _nsmgr; + private string _NA; + + public TimedTextProperties(Subtitle subtitle) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + Application.DoEvents(); + + _subtitle = subtitle; + _NA = "[" + Configuration.Settings.Language.General.NotAvailable + "]"; + comboBoxDropMode.Items[0] = _NA; + comboBoxTimeBase.Items[0] = _NA; + comboBoxDefaultStyle.Items.Add(_NA); + comboBoxDefaultRegion.Items.Add(_NA); + + _xml = new XmlDocument(); + try + { + _xml.LoadXml(subtitle.Header); + } + catch + { + subtitle.Header = new TimedText10().ToText(new Subtitle(), "tt"); + _xml.LoadXml(subtitle.Header); // load default xml + } + _nsmgr = new XmlNamespaceManager(_xml.NameTable); + _nsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml"); + + XmlNode node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:title", _nsmgr); + if (node != null) + { + textBoxTitle.Text = node.InnerText; + } + + node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:desc", _nsmgr); + if (node != null) + { + textBoxDescription.Text = node.InnerText; + } + + foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) + { + comboBoxLanguage.Items.Add(ci.Name); + } + XmlAttribute attr = _xml.DocumentElement.Attributes["xml:lang"]; + if (attr != null) + { + comboBoxLanguage.Text = attr.InnerText; + } + + attr = _xml.DocumentElement.Attributes["ttp:timeBase"]; + if (attr != null) + { + comboBoxTimeBase.Text = attr.InnerText; + } + + comboBoxFrameRate.Items.Add("23.976"); + comboBoxFrameRate.Items.Add("24.0"); + comboBoxFrameRate.Items.Add("25.0"); + comboBoxFrameRate.Items.Add("29.97"); + comboBoxFrameRate.Items.Add("30.0"); + attr = _xml.DocumentElement.Attributes["ttp:frameRate"]; + if (attr != null) + { + comboBoxFrameRate.Text = attr.InnerText; + } + + attr = _xml.DocumentElement.Attributes["ttp:frameRateMultiplier"]; + if (attr != null) + { + comboBoxFrameRateMultiplier.Text = attr.InnerText; + } + + attr = _xml.DocumentElement.Attributes["ttp:dropMode"]; + if (attr != null) + { + comboBoxDropMode.Text = attr.InnerText; + } + + foreach (string style in TimedText10.GetStylesFromHeader(_subtitle.Header)) + { + comboBoxDefaultStyle.Items.Add(style); + node = _xml.DocumentElement.SelectSingleNode("ttml:body", _nsmgr); + if (node?.Attributes?["style"] != null && style == node.Attributes["style"].Value) + { + comboBoxDefaultStyle.SelectedIndex = comboBoxDefaultStyle.Items.Count - 1; + } + } + foreach (string region in TimedText10.GetRegionsFromHeader(_subtitle.Header)) + { + comboBoxDefaultRegion.Items.Add(region); + node = _xml.DocumentElement.SelectSingleNode("ttml:body", _nsmgr); + if (node?.Attributes?["region"] != null && region == node.Attributes["region"].Value) + { + comboBoxDefaultRegion.SelectedIndex = comboBoxDefaultRegion.Items.Count - 1; + } + } + + var timeCodeFormat = Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormat.Trim().ToLowerInvariant(); + comboBoxTimeCodeFormat.SelectedIndex = 0; + for (int index = 0; index < comboBoxTimeCodeFormat.Items.Count; index++) + { + var item = comboBoxTimeCodeFormat.Items[index]; + if (item.ToString().ToLowerInvariant() == timeCodeFormat) + { + comboBoxTimeCodeFormat.SelectedIndex = index; + break; + } + } + + var ext = Configuration.Settings.SubtitleSettings.TimedText10FileExtension; + comboBoxFileExtensions.SelectedIndex = 0; + for (var index = 0; index < comboBoxFileExtensions.Items.Count; index++) + { + var item = comboBoxFileExtensions.Items[index]; + if (item.ToString() == ext) + { + comboBoxFileExtensions.SelectedIndex = index; + break; + } + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void buttonOK_Click(object sender, EventArgs e) + { + XmlNode node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:title", _nsmgr); + if (node != null) + { + if (string.IsNullOrWhiteSpace(textBoxTitle.Text) && string.IsNullOrWhiteSpace(textBoxDescription.Text)) + { + _xml.DocumentElement.SelectSingleNode("ttml:head", _nsmgr).RemoveChild(_xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata", _nsmgr)); + } + else + { + node.InnerText = textBoxTitle.Text; + } + } + else if (!string.IsNullOrWhiteSpace(textBoxTitle.Text)) + { + var head = _xml.DocumentElement.SelectSingleNode("ttml:head", _nsmgr); + if (head == null) + { + head = _xml.CreateElement("ttml", "head", _nsmgr.LookupNamespace("ttml")); + _xml.DocumentElement.PrependChild(head); + } + + var metadata = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata", _nsmgr); + if (metadata == null) + { + metadata = _xml.CreateElement("ttml", "metadata", _nsmgr.LookupNamespace("ttml")); + head.PrependChild(metadata); + } + + var title = _xml.CreateElement("ttml", "title", _nsmgr.LookupNamespace("ttml")); + metadata.InnerText = textBoxTitle.Text; + metadata.AppendChild(title); + } + + node = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata/ttml:desc", _nsmgr); + if (node != null) + { + node.InnerText = textBoxDescription.Text; + } + else if (!string.IsNullOrWhiteSpace(textBoxDescription.Text)) + { + var head = _xml.DocumentElement.SelectSingleNode("ttml:head", _nsmgr); + if (head == null) + { + head = _xml.CreateElement("ttml", "head", _nsmgr.LookupNamespace("ttml")); + _xml.DocumentElement.PrependChild(head); + } + + var metadata = _xml.DocumentElement.SelectSingleNode("ttml:head/ttml:metadata", _nsmgr); + if (metadata == null) + { + metadata = _xml.CreateElement("ttml", "metadata", _nsmgr.LookupNamespace("ttml")); + head.PrependChild(metadata); + } + + var desc = _xml.CreateElement("ttml", "desc", _nsmgr.LookupNamespace("ttml")); + desc.InnerText = textBoxDescription.Text; + metadata.AppendChild(desc); + } + + XmlAttribute attr = _xml.DocumentElement.Attributes["xml:lang"]; + if (attr != null) + { + attr.Value = comboBoxLanguage.Text; + if (attr.Value.Length == 0) + { + _xml.DocumentElement.Attributes.Remove(attr); + } + } + else if (comboBoxLanguage.Text.Length > 0) + { + attr = _xml.CreateAttribute("xml", "lang", _nsmgr.LookupNamespace("xml")); + attr.Value = comboBoxLanguage.Text; + _xml.DocumentElement.Attributes.Prepend(attr); + } + + attr = _xml.DocumentElement.Attributes["ttp:timeBase"]; + if (attr != null) + { + attr.InnerText = comboBoxTimeBase.Text; + if (attr.Value.Length == 0) + { + _xml.DocumentElement.Attributes.Remove(attr); + } + } + else if (comboBoxTimeBase.Text.Length > 0) + { + attr = _xml.CreateAttribute("ttp", "timeBase", _nsmgr.LookupNamespace("ttp")); + attr.Value = comboBoxTimeBase.Text; + _xml.DocumentElement.Attributes.Append(attr); + } + + attr = _xml.DocumentElement.Attributes["ttp:frameRate"]; + if (attr != null) + { + attr.InnerText = comboBoxFrameRate.Text; + if (attr.Value.Length == 0) + { + _xml.DocumentElement.Attributes.Remove(attr); + } + } + else if (comboBoxFrameRate.Text.Length > 0) + { + attr = _xml.CreateAttribute("ttp", "frameRate", _nsmgr.LookupNamespace("ttp")); + attr.Value = comboBoxFrameRate.Text; + _xml.DocumentElement.Attributes.Append(attr); + } + + attr = _xml.DocumentElement.Attributes["ttp:frameRateMultiplier"]; + if (attr != null) + { + attr.InnerText = comboBoxFrameRateMultiplier.Text; + if (attr.Value.Length == 0) + { + _xml.DocumentElement.Attributes.Remove(attr); + } + } + else if (comboBoxFrameRateMultiplier.Text.Length > 0) + { + attr = _xml.CreateAttribute("ttp", "frameRateMultiplier", _nsmgr.LookupNamespace("ttp")); + attr.Value = comboBoxFrameRateMultiplier.Text; + _xml.DocumentElement.Attributes.Append(attr); + } + + attr = _xml.DocumentElement.Attributes["ttp:dropMode"]; + if (attr != null) + { + attr.InnerText = comboBoxDropMode.Text; + if (attr.Value.Length == 0) + { + _xml.DocumentElement.Attributes.Remove(attr); + } + } + else if (comboBoxDropMode.Text.Length > 0) + { + attr = _xml.CreateAttribute("ttp", "dropMode", _nsmgr.LookupNamespace("ttp")); + attr.Value = comboBoxDropMode.Text; + _xml.DocumentElement.Attributes.Append(attr); + } + + node = _xml.DocumentElement.SelectSingleNode("ttml:body", _nsmgr); + if (node != null && node.Attributes["style"] != null) + { + node.Attributes["style"].Value = comboBoxDefaultStyle.Text; + } + else if (comboBoxDefaultStyle.Text.Length > 0 && node != null) + { + attr = _xml.CreateAttribute("style"); + attr.Value = comboBoxDefaultStyle.Text; + node.Attributes.Append(attr); + } + + node = _xml.DocumentElement.SelectSingleNode("ttml:body", _nsmgr); + if (node != null && node.Attributes["region"] != null) + { + node.Attributes["region"].Value = comboBoxDefaultRegion.Text; + } + else if (comboBoxDefaultRegion.Text.Length > 0 && node != null) + { + attr = _xml.CreateAttribute("region"); + attr.Value = comboBoxDefaultRegion.Text; + node.Attributes.Append(attr); + } + + _subtitle.Header = _xml.OuterXml; + + Configuration.Settings.SubtitleSettings.TimedText10TimeCodeFormat = comboBoxTimeCodeFormat.SelectedItem.ToString(); + Configuration.Settings.SubtitleSettings.TimedText10FileExtension= comboBoxFileExtensions.SelectedItem.ToString(); + + DialogResult = DialogResult.OK; + } + + } +} diff --git a/src/Forms/TimedTextProperties.resx b/src/ui/Forms/TimedTextProperties.resx similarity index 97% rename from src/Forms/TimedTextProperties.resx rename to src/ui/Forms/TimedTextProperties.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/TimedTextProperties.resx +++ b/src/ui/Forms/TimedTextProperties.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/TransportStreamSubtitleChooser.Designer.cs b/src/ui/Forms/TransportStreamSubtitleChooser.Designer.cs similarity index 98% rename from src/Forms/TransportStreamSubtitleChooser.Designer.cs rename to src/ui/Forms/TransportStreamSubtitleChooser.Designer.cs index 2e1a65189..82c88c3bf 100644 --- a/src/Forms/TransportStreamSubtitleChooser.Designer.cs +++ b/src/ui/Forms/TransportStreamSubtitleChooser.Designer.cs @@ -1,244 +1,244 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class TransportStreamSubtitleChooser - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.labelChoose = new System.Windows.Forms.Label(); - this.listBoxTracks = new System.Windows.Forms.ListBox(); - this.contextMenuStripListview = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemExport = new System.Windows.Forms.ToolStripMenuItem(); - this.bDNXMLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.bluraySupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.vobSubToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.dOSTToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveAllImagesWithHtmlIndexViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveSubtitleAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.listBoxSubtitles = new System.Windows.Forms.ListBox(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.textBoxTeletext = new System.Windows.Forms.TextBox(); - this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); - this.contextMenuStripListview.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.SuspendLayout(); - // - // labelChoose - // - this.labelChoose.AutoSize = true; - this.labelChoose.Location = new System.Drawing.Point(9, 15); - this.labelChoose.Name = "labelChoose"; - this.labelChoose.Size = new System.Drawing.Size(220, 13); - this.labelChoose.TabIndex = 52; - this.labelChoose.Text = "More than one subtitle found - please choose"; - // - // listBoxTracks - // - this.listBoxTracks.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listBoxTracks.ContextMenuStrip = this.contextMenuStripListview; - this.listBoxTracks.FormattingEnabled = true; - this.listBoxTracks.Location = new System.Drawing.Point(13, 31); - this.listBoxTracks.Name = "listBoxTracks"; - this.listBoxTracks.Size = new System.Drawing.Size(589, 134); - this.listBoxTracks.TabIndex = 51; - this.listBoxTracks.SelectedIndexChanged += new System.EventHandler(this.listBoxTracks_SelectedIndexChanged); - // - // contextMenuStripListview - // - this.contextMenuStripListview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItemExport, - this.saveAllImagesWithHtmlIndexViewToolStripMenuItem, - this.saveSubtitleAsToolStripMenuItem}); - this.contextMenuStripListview.Name = "contextMenuStripListview"; - this.contextMenuStripListview.Size = new System.Drawing.Size(284, 70); - this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripListview_Opening); - // - // toolStripMenuItemExport - // - this.toolStripMenuItemExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.bDNXMLToolStripMenuItem, - this.bluraySupToolStripMenuItem, - this.vobSubToolStripMenuItem, - this.dOSTToolStripMenuItem}); - this.toolStripMenuItemExport.Name = "toolStripMenuItemExport"; - this.toolStripMenuItemExport.Size = new System.Drawing.Size(283, 22); - this.toolStripMenuItemExport.Text = "Export all images as..."; - // - // bDNXMLToolStripMenuItem - // - this.bDNXMLToolStripMenuItem.Name = "bDNXMLToolStripMenuItem"; - this.bDNXMLToolStripMenuItem.Size = new System.Drawing.Size(143, 22); - this.bDNXMLToolStripMenuItem.Text = "BDN XML..."; - this.bDNXMLToolStripMenuItem.Click += new System.EventHandler(this.BDNXMLToolStripMenuItem_Click); - // - // bluraySupToolStripMenuItem - // - this.bluraySupToolStripMenuItem.Name = "bluraySupToolStripMenuItem"; - this.bluraySupToolStripMenuItem.Size = new System.Drawing.Size(143, 22); - this.bluraySupToolStripMenuItem.Text = "Blu-ray sup..."; - this.bluraySupToolStripMenuItem.Click += new System.EventHandler(this.BluraySupToolStripMenuItem_Click); - // - // vobSubToolStripMenuItem - // - this.vobSubToolStripMenuItem.Name = "vobSubToolStripMenuItem"; - this.vobSubToolStripMenuItem.Size = new System.Drawing.Size(143, 22); - this.vobSubToolStripMenuItem.Text = "VobSub..."; - this.vobSubToolStripMenuItem.Click += new System.EventHandler(this.VobSubToolStripMenuItem_Click); - // - // dOSTToolStripMenuItem - // - this.dOSTToolStripMenuItem.Name = "dOSTToolStripMenuItem"; - this.dOSTToolStripMenuItem.Size = new System.Drawing.Size(143, 22); - this.dOSTToolStripMenuItem.Text = "DOST..."; - this.dOSTToolStripMenuItem.Click += new System.EventHandler(this.DOSTToolStripMenuItem_Click); - // - // saveAllImagesWithHtmlIndexViewToolStripMenuItem - // - this.saveAllImagesWithHtmlIndexViewToolStripMenuItem.Name = "saveAllImagesWithHtmlIndexViewToolStripMenuItem"; - this.saveAllImagesWithHtmlIndexViewToolStripMenuItem.Size = new System.Drawing.Size(283, 22); - this.saveAllImagesWithHtmlIndexViewToolStripMenuItem.Text = "Save all images with HTML index view..."; - this.saveAllImagesWithHtmlIndexViewToolStripMenuItem.Click += new System.EventHandler(this.SaveAllImagesWithHtmlIndexViewToolStripMenuItem_Click); - // - // saveSubtitleAsToolStripMenuItem - // - this.saveSubtitleAsToolStripMenuItem.Name = "saveSubtitleAsToolStripMenuItem"; - this.saveSubtitleAsToolStripMenuItem.Size = new System.Drawing.Size(283, 22); - this.saveSubtitleAsToolStripMenuItem.Text = "Save subtitle as..."; - this.saveSubtitleAsToolStripMenuItem.Click += new System.EventHandler(this.saveSubtitleAsToolStripMenuItem_Click); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.BackColor = System.Drawing.SystemColors.Control; - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(526, 450); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 60; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = false; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(445, 450); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 54; - this.buttonOK.Text = "OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // listBoxSubtitles - // - this.listBoxSubtitles.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listBoxSubtitles.FormattingEnabled = true; - this.listBoxSubtitles.Location = new System.Drawing.Point(12, 171); - this.listBoxSubtitles.Name = "listBoxSubtitles"; - this.listBoxSubtitles.Size = new System.Drawing.Size(589, 147); - this.listBoxSubtitles.TabIndex = 53; - this.listBoxSubtitles.SelectedIndexChanged += new System.EventHandler(this.listBoxSubtitles_SelectedIndexChanged); - // - // pictureBox1 - // - this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.pictureBox1.Location = new System.Drawing.Point(13, 324); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(588, 116); - this.pictureBox1.TabIndex = 54; - this.pictureBox1.TabStop = false; - // - // textBoxTeletext - // - this.textBoxTeletext.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxTeletext.Location = new System.Drawing.Point(12, 167); - this.textBoxTeletext.Multiline = true; - this.textBoxTeletext.Name = "textBoxTeletext"; - this.textBoxTeletext.ReadOnly = true; - this.textBoxTeletext.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxTeletext.Size = new System.Drawing.Size(589, 273); - this.textBoxTeletext.TabIndex = 61; - // - // TransportStreamSubtitleChooser - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(613, 483); - this.Controls.Add(this.textBoxTeletext); - this.Controls.Add(this.pictureBox1); - this.Controls.Add(this.listBoxSubtitles); - this.Controls.Add(this.labelChoose); - this.Controls.Add(this.listBoxTracks); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(600, 510); - this.Name = "TransportStreamSubtitleChooser"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Transport stream subtitle chooser"; - this.Shown += new System.EventHandler(this.TransportStreamSubtitleChooser_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TransportStreamSubtitleChooser_KeyDown); - this.contextMenuStripListview.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelChoose; - private System.Windows.Forms.ListBox listBoxTracks; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.ListBox listBoxSubtitles; - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.ContextMenuStrip contextMenuStripListview; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExport; - private System.Windows.Forms.ToolStripMenuItem bDNXMLToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem bluraySupToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem vobSubToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem dOSTToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveAllImagesWithHtmlIndexViewToolStripMenuItem; - private System.Windows.Forms.TextBox textBoxTeletext; - private System.Windows.Forms.ToolStripMenuItem saveSubtitleAsToolStripMenuItem; - private System.Windows.Forms.SaveFileDialog saveFileDialog1; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class TransportStreamSubtitleChooser + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.labelChoose = new System.Windows.Forms.Label(); + this.listBoxTracks = new System.Windows.Forms.ListBox(); + this.contextMenuStripListview = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItemExport = new System.Windows.Forms.ToolStripMenuItem(); + this.bDNXMLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.bluraySupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.vobSubToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.dOSTToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveAllImagesWithHtmlIndexViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveSubtitleAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.listBoxSubtitles = new System.Windows.Forms.ListBox(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.textBoxTeletext = new System.Windows.Forms.TextBox(); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.contextMenuStripListview.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // labelChoose + // + this.labelChoose.AutoSize = true; + this.labelChoose.Location = new System.Drawing.Point(9, 15); + this.labelChoose.Name = "labelChoose"; + this.labelChoose.Size = new System.Drawing.Size(220, 13); + this.labelChoose.TabIndex = 52; + this.labelChoose.Text = "More than one subtitle found - please choose"; + // + // listBoxTracks + // + this.listBoxTracks.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listBoxTracks.ContextMenuStrip = this.contextMenuStripListview; + this.listBoxTracks.FormattingEnabled = true; + this.listBoxTracks.Location = new System.Drawing.Point(13, 31); + this.listBoxTracks.Name = "listBoxTracks"; + this.listBoxTracks.Size = new System.Drawing.Size(589, 134); + this.listBoxTracks.TabIndex = 51; + this.listBoxTracks.SelectedIndexChanged += new System.EventHandler(this.listBoxTracks_SelectedIndexChanged); + // + // contextMenuStripListview + // + this.contextMenuStripListview.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemExport, + this.saveAllImagesWithHtmlIndexViewToolStripMenuItem, + this.saveSubtitleAsToolStripMenuItem}); + this.contextMenuStripListview.Name = "contextMenuStripListview"; + this.contextMenuStripListview.Size = new System.Drawing.Size(284, 70); + this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripListview_Opening); + // + // toolStripMenuItemExport + // + this.toolStripMenuItemExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.bDNXMLToolStripMenuItem, + this.bluraySupToolStripMenuItem, + this.vobSubToolStripMenuItem, + this.dOSTToolStripMenuItem}); + this.toolStripMenuItemExport.Name = "toolStripMenuItemExport"; + this.toolStripMenuItemExport.Size = new System.Drawing.Size(283, 22); + this.toolStripMenuItemExport.Text = "Export all images as..."; + // + // bDNXMLToolStripMenuItem + // + this.bDNXMLToolStripMenuItem.Name = "bDNXMLToolStripMenuItem"; + this.bDNXMLToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.bDNXMLToolStripMenuItem.Text = "BDN XML..."; + this.bDNXMLToolStripMenuItem.Click += new System.EventHandler(this.BDNXMLToolStripMenuItem_Click); + // + // bluraySupToolStripMenuItem + // + this.bluraySupToolStripMenuItem.Name = "bluraySupToolStripMenuItem"; + this.bluraySupToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.bluraySupToolStripMenuItem.Text = "Blu-ray sup..."; + this.bluraySupToolStripMenuItem.Click += new System.EventHandler(this.BluraySupToolStripMenuItem_Click); + // + // vobSubToolStripMenuItem + // + this.vobSubToolStripMenuItem.Name = "vobSubToolStripMenuItem"; + this.vobSubToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.vobSubToolStripMenuItem.Text = "VobSub..."; + this.vobSubToolStripMenuItem.Click += new System.EventHandler(this.VobSubToolStripMenuItem_Click); + // + // dOSTToolStripMenuItem + // + this.dOSTToolStripMenuItem.Name = "dOSTToolStripMenuItem"; + this.dOSTToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.dOSTToolStripMenuItem.Text = "DOST..."; + this.dOSTToolStripMenuItem.Click += new System.EventHandler(this.DOSTToolStripMenuItem_Click); + // + // saveAllImagesWithHtmlIndexViewToolStripMenuItem + // + this.saveAllImagesWithHtmlIndexViewToolStripMenuItem.Name = "saveAllImagesWithHtmlIndexViewToolStripMenuItem"; + this.saveAllImagesWithHtmlIndexViewToolStripMenuItem.Size = new System.Drawing.Size(283, 22); + this.saveAllImagesWithHtmlIndexViewToolStripMenuItem.Text = "Save all images with HTML index view..."; + this.saveAllImagesWithHtmlIndexViewToolStripMenuItem.Click += new System.EventHandler(this.SaveAllImagesWithHtmlIndexViewToolStripMenuItem_Click); + // + // saveSubtitleAsToolStripMenuItem + // + this.saveSubtitleAsToolStripMenuItem.Name = "saveSubtitleAsToolStripMenuItem"; + this.saveSubtitleAsToolStripMenuItem.Size = new System.Drawing.Size(283, 22); + this.saveSubtitleAsToolStripMenuItem.Text = "Save subtitle as..."; + this.saveSubtitleAsToolStripMenuItem.Click += new System.EventHandler(this.saveSubtitleAsToolStripMenuItem_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.BackColor = System.Drawing.SystemColors.Control; + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(526, 450); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 60; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = false; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(445, 450); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 54; + this.buttonOK.Text = "OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // listBoxSubtitles + // + this.listBoxSubtitles.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listBoxSubtitles.FormattingEnabled = true; + this.listBoxSubtitles.Location = new System.Drawing.Point(12, 171); + this.listBoxSubtitles.Name = "listBoxSubtitles"; + this.listBoxSubtitles.Size = new System.Drawing.Size(589, 147); + this.listBoxSubtitles.TabIndex = 53; + this.listBoxSubtitles.SelectedIndexChanged += new System.EventHandler(this.listBoxSubtitles_SelectedIndexChanged); + // + // pictureBox1 + // + this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pictureBox1.Location = new System.Drawing.Point(13, 324); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(588, 116); + this.pictureBox1.TabIndex = 54; + this.pictureBox1.TabStop = false; + // + // textBoxTeletext + // + this.textBoxTeletext.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxTeletext.Location = new System.Drawing.Point(12, 167); + this.textBoxTeletext.Multiline = true; + this.textBoxTeletext.Name = "textBoxTeletext"; + this.textBoxTeletext.ReadOnly = true; + this.textBoxTeletext.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxTeletext.Size = new System.Drawing.Size(589, 273); + this.textBoxTeletext.TabIndex = 61; + // + // TransportStreamSubtitleChooser + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(613, 483); + this.Controls.Add(this.textBoxTeletext); + this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.listBoxSubtitles); + this.Controls.Add(this.labelChoose); + this.Controls.Add(this.listBoxTracks); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(600, 510); + this.Name = "TransportStreamSubtitleChooser"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Transport stream subtitle chooser"; + this.Shown += new System.EventHandler(this.TransportStreamSubtitleChooser_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TransportStreamSubtitleChooser_KeyDown); + this.contextMenuStripListview.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelChoose; + private System.Windows.Forms.ListBox listBoxTracks; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.ListBox listBoxSubtitles; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.ContextMenuStrip contextMenuStripListview; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExport; + private System.Windows.Forms.ToolStripMenuItem bDNXMLToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem bluraySupToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem vobSubToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem dOSTToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveAllImagesWithHtmlIndexViewToolStripMenuItem; + private System.Windows.Forms.TextBox textBoxTeletext; + private System.Windows.Forms.ToolStripMenuItem saveSubtitleAsToolStripMenuItem; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + } } \ No newline at end of file diff --git a/src/Forms/TransportStreamSubtitleChooser.cs b/src/ui/Forms/TransportStreamSubtitleChooser.cs similarity index 97% rename from src/Forms/TransportStreamSubtitleChooser.cs rename to src/ui/Forms/TransportStreamSubtitleChooser.cs index 8fbe3f803..87d8715cf 100644 --- a/src/Forms/TransportStreamSubtitleChooser.cs +++ b/src/ui/Forms/TransportStreamSubtitleChooser.cs @@ -1,345 +1,345 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Forms.Ocr; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; -using Nikse.SubtitleEdit.Core.ContainerFormats.TransportStream; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class TransportStreamSubtitleChooser : PositionAndSizeForm - { - public int SelectedIndex => listBoxTracks.SelectedIndex; - public bool IsTeletext { get; private set; } - public string Srt { get; private set; } - - public class StreamTrackItem - { - public string Text { get; set; } - public bool IsTeletext { get; set; } - public string Srt { get; set; } - public int Pid { get; set; } - public int PageNumber { get; set; } - public string Language { get; set; } - - public override string ToString() - { - return Text; - } - } - - private TransportStreamParser _tsParser; - private string _fileName; - private ProgramMapTableParser _programMapTableParser; - - public TransportStreamSubtitleChooser() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - labelChoose.Text = Configuration.Settings.Language.MatroskaSubtitleChooser.PleaseChoose; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - toolStripMenuItemExport.Text = Configuration.Settings.Language.Main.Menu.File.Export; - vobSubToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.File.ExportVobSub; - bDNXMLToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.File.ExportBdnXml; - bluraySupToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.File.ExportBluRaySup; - saveAllImagesWithHtmlIndexViewToolStripMenuItem.Text = Configuration.Settings.Language.VobSubOcr.SaveAllSubtitleImagesWithHtml; - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - private void TransportStreamSubtitleChooser_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - internal void Initialize(TransportStreamParser tsParser, string fileName) - { - _programMapTableParser = new ProgramMapTableParser(); - _programMapTableParser.Parse(fileName); // get languages - _tsParser = tsParser; - _fileName = fileName; - Text = string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.Title, fileName); - - foreach (int id in tsParser.SubtitlePacketIds) - { - var language = _programMapTableParser.GetSubtitleLanguage(id); - if (string.IsNullOrEmpty(language)) - { - language = "unknown"; - } - - listBoxTracks.Items.Add(new StreamTrackItem - { - Text = string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.PidLineImage, id, language, tsParser.GetDvbSubtitles(id).Count), - IsTeletext = false, - Pid = id, - Language = language - }); - } - - foreach (var program in tsParser.TeletextSubtitlesLookup) - { - var language = _programMapTableParser.GetSubtitleLanguage(program.Key); - if (string.IsNullOrEmpty(language)) - { - language = "unknown"; - } - - foreach (var kvp in program.Value) - { - var subtitle = new Subtitle(kvp.Value); - subtitle.Renumber(); - listBoxTracks.Items.Add(new StreamTrackItem - { - Text = string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.PidLineTeletext, kvp.Key, program.Key, language, kvp.Value.Count), - IsTeletext = true, - Pid = program.Key, - PageNumber = kvp.Key, - Srt = new SubRip().ToText(subtitle, null) - }); - } - } - - listBoxTracks.SelectedIndex = 0; - } - - private void listBoxTracks_SelectedIndexChanged(object sender, EventArgs e) - { - int idx = listBoxTracks.SelectedIndex; - if (idx < 0) - { - return; - } - - var item = (StreamTrackItem)listBoxTracks.SelectedItem; - if (item.IsTeletext) - { - textBoxTeletext.Visible = true; - textBoxTeletext.Text = item.Srt; - IsTeletext = true; - Srt = item.Srt; - return; - } - - IsTeletext = false; - Srt = string.Empty; - textBoxTeletext.Visible = false; - listBoxSubtitles.Items.Clear(); - int pid = _tsParser.SubtitlePacketIds[idx]; - var list = _tsParser.GetDvbSubtitles(pid); - int i = 0; - foreach (var sub in list) - { - i++; - var start = new TimeCode(sub.StartMilliseconds); - var end = new TimeCode(sub.EndMilliseconds); - listBoxSubtitles.Items.Add(string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.SubLine, i, start, end, sub.NumberOfImages)); - } - if (list.Count > 0) - { - listBoxSubtitles.SelectedIndex = 0; - } - } - - private void listBoxSubtitles_SelectedIndexChanged(object sender, EventArgs e) - { - int idx = listBoxSubtitles.SelectedIndex; - if (idx < 0) - { - return; - } - - int pid = _tsParser.SubtitlePacketIds[listBoxTracks.SelectedIndex]; - var list = _tsParser.GetDvbSubtitles(pid); - - var dvbBmp = list[idx].GetBitmap(); - var nDvbBmp = new NikseBitmap(dvbBmp); - nDvbBmp.CropTopTransparent(2); - nDvbBmp.CropTransparentSidesAndBottom(2, true); - dvbBmp.Dispose(); - var oldImage = pictureBox1.Image; - pictureBox1.Image = nDvbBmp.GetBitmap(); - oldImage?.Dispose(); - } - - private List GetSelectedSubtitles() - { - int idx = listBoxSubtitles.SelectedIndex; - if (idx < 0) - { - return null; - } - - int pid = _tsParser.SubtitlePacketIds[listBoxTracks.SelectedIndex]; - return _tsParser.GetDvbSubtitles(pid); - } - - private string GetSelectedLanguage() - { - int idx = listBoxSubtitles.SelectedIndex; - if (idx < 0) - { - return null; - } - - int pid = _tsParser.SubtitlePacketIds[listBoxTracks.SelectedIndex]; - return _programMapTableParser.GetSubtitleLanguage(pid); - } - - private void BluraySupToolStripMenuItem_Click(object sender, EventArgs e) - { - ExportTo(ExportPngXml.ExportFormats.BluraySup); - } - - private void BDNXMLToolStripMenuItem_Click(object sender, EventArgs e) - { - ExportTo(ExportPngXml.ExportFormats.BdnXml); - } - - private void VobSubToolStripMenuItem_Click(object sender, EventArgs e) - { - ExportTo(ExportPngXml.ExportFormats.VobSub); - } - - private void DOSTToolStripMenuItem_Click(object sender, EventArgs e) - { - ExportTo(ExportPngXml.ExportFormats.Dost); - } - - private Point GetResolution() - { - int idx = listBoxTracks.SelectedIndex; - if (idx < 0) - { - return new Point(DvbSubPes.DefaultScreenWidth, DvbSubPes.DefaultScreenHeight); - } - - int pid = _tsParser.SubtitlePacketIds[idx]; - var list = _tsParser.GetDvbSubtitles(pid); - if (list.Count > 0) - { - using (var bmp = list[0].GetBitmap()) - { - return new Point(bmp.Width, bmp.Height); - } - } - return new Point(DvbSubPes.DefaultScreenWidth, DvbSubPes.DefaultScreenHeight); - } - - private void ExportTo(string exportType) - { - var subtitles = GetSelectedSubtitles(); - if (subtitles == null) - { - return; - } - - using (var formSubOcr = new VobSubOcr()) - { - formSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, _fileName, GetSelectedLanguage(), true); - using (var exportBdnXmlPng = new ExportPngXml()) - { - exportBdnXmlPng.InitializeFromVobSubOcr(formSubOcr.SubtitleFromOcr, new SubRip(), exportType, _fileName, formSubOcr, GetSelectedLanguage()); - exportBdnXmlPng.SetResolution(GetResolution()); - exportBdnXmlPng.ShowDialog(this); - } - } - } - - private void SaveAllImagesWithHtmlIndexViewToolStripMenuItem_Click(object sender, EventArgs e) - { - var subtitles = GetSelectedSubtitles(); - if (subtitles == null) - { - return; - } - - using (var formSubOcr = new VobSubOcr()) - { - formSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, _fileName, GetSelectedLanguage()); - formSubOcr.SaveAllImagesWithHtmlIndexViewToolStripMenuItem_Click(sender, e); - } - } - - private void TransportStreamSubtitleChooser_Shown(object sender, EventArgs e) - { - BringToFront(); - } - - private void contextMenuStripListview_Opening(object sender, System.ComponentModel.CancelEventArgs e) - { - int idx = listBoxTracks.SelectedIndex; - if (idx < 0) - { - e.Cancel = true; - return; - } - - var item = (StreamTrackItem)listBoxTracks.SelectedItem; - if (item.IsTeletext) - { - toolStripMenuItemExport.Visible = false; - saveAllImagesWithHtmlIndexViewToolStripMenuItem.Visible = false; - saveSubtitleAsToolStripMenuItem.Visible = true; - } - else - { - toolStripMenuItemExport.Visible = true; - saveAllImagesWithHtmlIndexViewToolStripMenuItem.Visible = true; - saveSubtitleAsToolStripMenuItem.Visible = false; - } - } - - private void saveSubtitleAsToolStripMenuItem_Click(object sender, EventArgs e) - { - int idx = listBoxTracks.SelectedIndex; - if (idx < 0) - { - return; - } - - var item = (StreamTrackItem)listBoxTracks.SelectedItem; - if (item.IsTeletext) - { - saveFileDialog1.Title = Configuration.Settings.Language.ExportCustomText.SaveSubtitleAs; - var fileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); - if (item.PageNumber > 0) - { - fileName += "." + item.PageNumber.ToString(CultureInfo.InvariantCulture); - } - if (!string.IsNullOrEmpty(item.Language)) - { - fileName += "." + _programMapTableParser.GetSubtitleLanguageTwoLetter(item.Pid); - } - saveFileDialog1.InitialDirectory = Path.GetDirectoryName(fileName); - saveFileDialog1.FileName = Path.GetFileName(fileName) + ".srt"; - - if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) - { - File.WriteAllText(saveFileDialog1.FileName, item.Srt); - } - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Forms.Ocr; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Core.ContainerFormats.TransportStream; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class TransportStreamSubtitleChooser : PositionAndSizeForm + { + public int SelectedIndex => listBoxTracks.SelectedIndex; + public bool IsTeletext { get; private set; } + public string Srt { get; private set; } + + public class StreamTrackItem + { + public string Text { get; set; } + public bool IsTeletext { get; set; } + public string Srt { get; set; } + public int Pid { get; set; } + public int PageNumber { get; set; } + public string Language { get; set; } + + public override string ToString() + { + return Text; + } + } + + private TransportStreamParser _tsParser; + private string _fileName; + private ProgramMapTableParser _programMapTableParser; + + public TransportStreamSubtitleChooser() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + labelChoose.Text = Configuration.Settings.Language.MatroskaSubtitleChooser.PleaseChoose; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + toolStripMenuItemExport.Text = Configuration.Settings.Language.Main.Menu.File.Export; + vobSubToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.File.ExportVobSub; + bDNXMLToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.File.ExportBdnXml; + bluraySupToolStripMenuItem.Text = Configuration.Settings.Language.Main.Menu.File.ExportBluRaySup; + saveAllImagesWithHtmlIndexViewToolStripMenuItem.Text = Configuration.Settings.Language.VobSubOcr.SaveAllSubtitleImagesWithHtml; + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void TransportStreamSubtitleChooser_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + internal void Initialize(TransportStreamParser tsParser, string fileName) + { + _programMapTableParser = new ProgramMapTableParser(); + _programMapTableParser.Parse(fileName); // get languages + _tsParser = tsParser; + _fileName = fileName; + Text = string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.Title, fileName); + + foreach (int id in tsParser.SubtitlePacketIds) + { + var language = _programMapTableParser.GetSubtitleLanguage(id); + if (string.IsNullOrEmpty(language)) + { + language = "unknown"; + } + + listBoxTracks.Items.Add(new StreamTrackItem + { + Text = string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.PidLineImage, id, language, tsParser.GetDvbSubtitles(id).Count), + IsTeletext = false, + Pid = id, + Language = language + }); + } + + foreach (var program in tsParser.TeletextSubtitlesLookup) + { + var language = _programMapTableParser.GetSubtitleLanguage(program.Key); + if (string.IsNullOrEmpty(language)) + { + language = "unknown"; + } + + foreach (var kvp in program.Value) + { + var subtitle = new Subtitle(kvp.Value); + subtitle.Renumber(); + listBoxTracks.Items.Add(new StreamTrackItem + { + Text = string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.PidLineTeletext, kvp.Key, program.Key, language, kvp.Value.Count), + IsTeletext = true, + Pid = program.Key, + PageNumber = kvp.Key, + Srt = new SubRip().ToText(subtitle, null) + }); + } + } + + listBoxTracks.SelectedIndex = 0; + } + + private void listBoxTracks_SelectedIndexChanged(object sender, EventArgs e) + { + int idx = listBoxTracks.SelectedIndex; + if (idx < 0) + { + return; + } + + var item = (StreamTrackItem)listBoxTracks.SelectedItem; + if (item.IsTeletext) + { + textBoxTeletext.Visible = true; + textBoxTeletext.Text = item.Srt; + IsTeletext = true; + Srt = item.Srt; + return; + } + + IsTeletext = false; + Srt = string.Empty; + textBoxTeletext.Visible = false; + listBoxSubtitles.Items.Clear(); + int pid = _tsParser.SubtitlePacketIds[idx]; + var list = _tsParser.GetDvbSubtitles(pid); + int i = 0; + foreach (var sub in list) + { + i++; + var start = new TimeCode(sub.StartMilliseconds); + var end = new TimeCode(sub.EndMilliseconds); + listBoxSubtitles.Items.Add(string.Format(Configuration.Settings.Language.TransportStreamSubtitleChooser.SubLine, i, start, end, sub.NumberOfImages)); + } + if (list.Count > 0) + { + listBoxSubtitles.SelectedIndex = 0; + } + } + + private void listBoxSubtitles_SelectedIndexChanged(object sender, EventArgs e) + { + int idx = listBoxSubtitles.SelectedIndex; + if (idx < 0) + { + return; + } + + int pid = _tsParser.SubtitlePacketIds[listBoxTracks.SelectedIndex]; + var list = _tsParser.GetDvbSubtitles(pid); + + var dvbBmp = list[idx].GetBitmap(); + var nDvbBmp = new NikseBitmap(dvbBmp); + nDvbBmp.CropTopTransparent(2); + nDvbBmp.CropTransparentSidesAndBottom(2, true); + dvbBmp.Dispose(); + var oldImage = pictureBox1.Image; + pictureBox1.Image = nDvbBmp.GetBitmap(); + oldImage?.Dispose(); + } + + private List GetSelectedSubtitles() + { + int idx = listBoxSubtitles.SelectedIndex; + if (idx < 0) + { + return null; + } + + int pid = _tsParser.SubtitlePacketIds[listBoxTracks.SelectedIndex]; + return _tsParser.GetDvbSubtitles(pid); + } + + private string GetSelectedLanguage() + { + int idx = listBoxSubtitles.SelectedIndex; + if (idx < 0) + { + return null; + } + + int pid = _tsParser.SubtitlePacketIds[listBoxTracks.SelectedIndex]; + return _programMapTableParser.GetSubtitleLanguage(pid); + } + + private void BluraySupToolStripMenuItem_Click(object sender, EventArgs e) + { + ExportTo(ExportPngXml.ExportFormats.BluraySup); + } + + private void BDNXMLToolStripMenuItem_Click(object sender, EventArgs e) + { + ExportTo(ExportPngXml.ExportFormats.BdnXml); + } + + private void VobSubToolStripMenuItem_Click(object sender, EventArgs e) + { + ExportTo(ExportPngXml.ExportFormats.VobSub); + } + + private void DOSTToolStripMenuItem_Click(object sender, EventArgs e) + { + ExportTo(ExportPngXml.ExportFormats.Dost); + } + + private Point GetResolution() + { + int idx = listBoxTracks.SelectedIndex; + if (idx < 0) + { + return new Point(DvbSubPes.DefaultScreenWidth, DvbSubPes.DefaultScreenHeight); + } + + int pid = _tsParser.SubtitlePacketIds[idx]; + var list = _tsParser.GetDvbSubtitles(pid); + if (list.Count > 0) + { + using (var bmp = list[0].GetBitmap()) + { + return new Point(bmp.Width, bmp.Height); + } + } + return new Point(DvbSubPes.DefaultScreenWidth, DvbSubPes.DefaultScreenHeight); + } + + private void ExportTo(string exportType) + { + var subtitles = GetSelectedSubtitles(); + if (subtitles == null) + { + return; + } + + using (var formSubOcr = new VobSubOcr()) + { + formSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, _fileName, GetSelectedLanguage(), true); + using (var exportBdnXmlPng = new ExportPngXml()) + { + exportBdnXmlPng.InitializeFromVobSubOcr(formSubOcr.SubtitleFromOcr, new SubRip(), exportType, _fileName, formSubOcr, GetSelectedLanguage()); + exportBdnXmlPng.SetResolution(GetResolution()); + exportBdnXmlPng.ShowDialog(this); + } + } + } + + private void SaveAllImagesWithHtmlIndexViewToolStripMenuItem_Click(object sender, EventArgs e) + { + var subtitles = GetSelectedSubtitles(); + if (subtitles == null) + { + return; + } + + using (var formSubOcr = new VobSubOcr()) + { + formSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, _fileName, GetSelectedLanguage()); + formSubOcr.SaveAllImagesWithHtmlIndexViewToolStripMenuItem_Click(sender, e); + } + } + + private void TransportStreamSubtitleChooser_Shown(object sender, EventArgs e) + { + BringToFront(); + } + + private void contextMenuStripListview_Opening(object sender, System.ComponentModel.CancelEventArgs e) + { + int idx = listBoxTracks.SelectedIndex; + if (idx < 0) + { + e.Cancel = true; + return; + } + + var item = (StreamTrackItem)listBoxTracks.SelectedItem; + if (item.IsTeletext) + { + toolStripMenuItemExport.Visible = false; + saveAllImagesWithHtmlIndexViewToolStripMenuItem.Visible = false; + saveSubtitleAsToolStripMenuItem.Visible = true; + } + else + { + toolStripMenuItemExport.Visible = true; + saveAllImagesWithHtmlIndexViewToolStripMenuItem.Visible = true; + saveSubtitleAsToolStripMenuItem.Visible = false; + } + } + + private void saveSubtitleAsToolStripMenuItem_Click(object sender, EventArgs e) + { + int idx = listBoxTracks.SelectedIndex; + if (idx < 0) + { + return; + } + + var item = (StreamTrackItem)listBoxTracks.SelectedItem; + if (item.IsTeletext) + { + saveFileDialog1.Title = Configuration.Settings.Language.ExportCustomText.SaveSubtitleAs; + var fileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); + if (item.PageNumber > 0) + { + fileName += "." + item.PageNumber.ToString(CultureInfo.InvariantCulture); + } + if (!string.IsNullOrEmpty(item.Language)) + { + fileName += "." + _programMapTableParser.GetSubtitleLanguageTwoLetter(item.Pid); + } + saveFileDialog1.InitialDirectory = Path.GetDirectoryName(fileName); + saveFileDialog1.FileName = Path.GetFileName(fileName) + ".srt"; + + if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) + { + File.WriteAllText(saveFileDialog1.FileName, item.Srt); + } + } + } + + } +} diff --git a/src/Forms/TransportStreamSubtitleChooser.resx b/src/ui/Forms/TransportStreamSubtitleChooser.resx similarity index 97% rename from src/Forms/TransportStreamSubtitleChooser.resx rename to src/ui/Forms/TransportStreamSubtitleChooser.resx index 1d7897027..3227d2eca 100644 --- a/src/Forms/TransportStreamSubtitleChooser.resx +++ b/src/ui/Forms/TransportStreamSubtitleChooser.resx @@ -1,126 +1,126 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 208, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 208, 17 + \ No newline at end of file diff --git a/src/Forms/UnknownSubtitle.Designer.cs b/src/ui/Forms/UnknownSubtitle.Designer.cs similarity index 98% rename from src/Forms/UnknownSubtitle.Designer.cs rename to src/ui/Forms/UnknownSubtitle.Designer.cs index 9df2fb3f9..a82b24da1 100644 --- a/src/Forms/UnknownSubtitle.Designer.cs +++ b/src/ui/Forms/UnknownSubtitle.Designer.cs @@ -1,146 +1,146 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class UnknownSubtitle - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.labelTitle = new System.Windows.Forms.Label(); - this.buttonOK = new System.Windows.Forms.Button(); - this.richTextBoxMessage = new System.Windows.Forms.RichTextBox(); - this.buttonImportPlainText = new System.Windows.Forms.Button(); - this.LabelPreview = new System.Windows.Forms.Label(); - this.textBoxPreview = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // labelTitle - // - this.labelTitle.AutoSize = true; - this.labelTitle.Location = new System.Drawing.Point(15, 25); - this.labelTitle.Name = "labelTitle"; - this.labelTitle.Size = new System.Drawing.Size(114, 13); - this.labelTitle.TabIndex = 0; - this.labelTitle.Text = "Unknown subtitle type"; - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(457, 272); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(100, 27); - this.buttonOK.TabIndex = 8; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - // - // richTextBoxMessage - // - this.richTextBoxMessage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.richTextBoxMessage.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.richTextBoxMessage.Location = new System.Drawing.Point(18, 54); - this.richTextBoxMessage.Name = "richTextBoxMessage"; - this.richTextBoxMessage.ReadOnly = true; - this.richTextBoxMessage.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; - this.richTextBoxMessage.Size = new System.Drawing.Size(539, 47); - this.richTextBoxMessage.TabIndex = 41; - this.richTextBoxMessage.TabStop = false; - this.richTextBoxMessage.Text = "If you want this fixed please send an email to mailto:niksedk@gmail.com and inclu" + - "de a copy of the subtitle."; - // - // buttonImportPlainText - // - this.buttonImportPlainText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonImportPlainText.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonImportPlainText.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonImportPlainText.Location = new System.Drawing.Point(260, 272); - this.buttonImportPlainText.Name = "buttonImportPlainText"; - this.buttonImportPlainText.Size = new System.Drawing.Size(191, 27); - this.buttonImportPlainText.TabIndex = 4; - this.buttonImportPlainText.Text = "Import plain text..."; - this.buttonImportPlainText.UseVisualStyleBackColor = true; - this.buttonImportPlainText.Click += new System.EventHandler(this.buttonImportPlainText_Click); - // - // LabelPreview - // - this.LabelPreview.AutoSize = true; - this.LabelPreview.Location = new System.Drawing.Point(17, 101); - this.LabelPreview.Name = "LabelPreview"; - this.LabelPreview.Size = new System.Drawing.Size(45, 13); - this.LabelPreview.TabIndex = 44; - this.LabelPreview.Text = "Preview"; - // - // textBoxPreview - // - this.textBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxPreview.Location = new System.Drawing.Point(18, 118); - this.textBoxPreview.Multiline = true; - this.textBoxPreview.Name = "textBoxPreview"; - this.textBoxPreview.ReadOnly = true; - this.textBoxPreview.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxPreview.Size = new System.Drawing.Size(539, 141); - this.textBoxPreview.TabIndex = 2; - // - // UnknownSubtitle - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(569, 311); - this.Controls.Add(this.LabelPreview); - this.Controls.Add(this.textBoxPreview); - this.Controls.Add(this.buttonImportPlainText); - this.Controls.Add(this.richTextBoxMessage); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.labelTitle); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "UnknownSubtitle"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Unknown subtitle"; - this.Shown += new System.EventHandler(this.UnknownSubtitle_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormUnknownSubtitle_KeyDown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelTitle; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.RichTextBox richTextBoxMessage; - private System.Windows.Forms.Button buttonImportPlainText; - private System.Windows.Forms.Label LabelPreview; - private System.Windows.Forms.TextBox textBoxPreview; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class UnknownSubtitle + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.labelTitle = new System.Windows.Forms.Label(); + this.buttonOK = new System.Windows.Forms.Button(); + this.richTextBoxMessage = new System.Windows.Forms.RichTextBox(); + this.buttonImportPlainText = new System.Windows.Forms.Button(); + this.LabelPreview = new System.Windows.Forms.Label(); + this.textBoxPreview = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // labelTitle + // + this.labelTitle.AutoSize = true; + this.labelTitle.Location = new System.Drawing.Point(15, 25); + this.labelTitle.Name = "labelTitle"; + this.labelTitle.Size = new System.Drawing.Size(114, 13); + this.labelTitle.TabIndex = 0; + this.labelTitle.Text = "Unknown subtitle type"; + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(457, 272); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(100, 27); + this.buttonOK.TabIndex = 8; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + // + // richTextBoxMessage + // + this.richTextBoxMessage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.richTextBoxMessage.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.richTextBoxMessage.Location = new System.Drawing.Point(18, 54); + this.richTextBoxMessage.Name = "richTextBoxMessage"; + this.richTextBoxMessage.ReadOnly = true; + this.richTextBoxMessage.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; + this.richTextBoxMessage.Size = new System.Drawing.Size(539, 47); + this.richTextBoxMessage.TabIndex = 41; + this.richTextBoxMessage.TabStop = false; + this.richTextBoxMessage.Text = "If you want this fixed please send an email to mailto:niksedk@gmail.com and inclu" + + "de a copy of the subtitle."; + // + // buttonImportPlainText + // + this.buttonImportPlainText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonImportPlainText.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonImportPlainText.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonImportPlainText.Location = new System.Drawing.Point(260, 272); + this.buttonImportPlainText.Name = "buttonImportPlainText"; + this.buttonImportPlainText.Size = new System.Drawing.Size(191, 27); + this.buttonImportPlainText.TabIndex = 4; + this.buttonImportPlainText.Text = "Import plain text..."; + this.buttonImportPlainText.UseVisualStyleBackColor = true; + this.buttonImportPlainText.Click += new System.EventHandler(this.buttonImportPlainText_Click); + // + // LabelPreview + // + this.LabelPreview.AutoSize = true; + this.LabelPreview.Location = new System.Drawing.Point(17, 101); + this.LabelPreview.Name = "LabelPreview"; + this.LabelPreview.Size = new System.Drawing.Size(45, 13); + this.LabelPreview.TabIndex = 44; + this.LabelPreview.Text = "Preview"; + // + // textBoxPreview + // + this.textBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxPreview.Location = new System.Drawing.Point(18, 118); + this.textBoxPreview.Multiline = true; + this.textBoxPreview.Name = "textBoxPreview"; + this.textBoxPreview.ReadOnly = true; + this.textBoxPreview.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxPreview.Size = new System.Drawing.Size(539, 141); + this.textBoxPreview.TabIndex = 2; + // + // UnknownSubtitle + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(569, 311); + this.Controls.Add(this.LabelPreview); + this.Controls.Add(this.textBoxPreview); + this.Controls.Add(this.buttonImportPlainText); + this.Controls.Add(this.richTextBoxMessage); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.labelTitle); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "UnknownSubtitle"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Unknown subtitle"; + this.Shown += new System.EventHandler(this.UnknownSubtitle_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormUnknownSubtitle_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelTitle; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.RichTextBox richTextBoxMessage; + private System.Windows.Forms.Button buttonImportPlainText; + private System.Windows.Forms.Label LabelPreview; + private System.Windows.Forms.TextBox textBoxPreview; + } } \ No newline at end of file diff --git a/src/Forms/UnknownSubtitle.cs b/src/ui/Forms/UnknownSubtitle.cs similarity index 97% rename from src/Forms/UnknownSubtitle.cs rename to src/ui/Forms/UnknownSubtitle.cs index 88a190375..b2a91a9d5 100644 --- a/src/Forms/UnknownSubtitle.cs +++ b/src/ui/Forms/UnknownSubtitle.cs @@ -1,75 +1,75 @@ -using System.IO; -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class UnknownSubtitle : Form - { - public bool ImportPlainText { get; set; } - - public UnknownSubtitle() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = Configuration.Settings.Language.UnknownSubtitle.Title; - labelTitle.Text = Configuration.Settings.Language.UnknownSubtitle.Title; - richTextBoxMessage.Text = Configuration.Settings.Language.UnknownSubtitle.Message; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonImportPlainText.Text = Configuration.Settings.Language.UnknownSubtitle.ImportAsPlainText; - UiUtil.FixLargeFonts(this, buttonOK); - } - - public void Initialize(string title, string fileName, bool allowImportPlainText) - { - Text = title; - try - { - var file = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - - int length = (int)file.Length; - if (length > 100000) - { - length = 100000; - } - - file.Position = 0; - var fileBuffer = new byte[length]; - file.Read(fileBuffer, 0, length); - file.Close(); - - var encoding = LanguageAutoDetect.DetectAnsiEncoding(fileBuffer); - LabelPreview.Text = Configuration.Settings.Language.General.Preview + " - " + fileName; - textBoxPreview.Text = encoding.GetString(fileBuffer).Replace("\0", " "); - buttonImportPlainText.Visible = allowImportPlainText && !string.IsNullOrWhiteSpace(textBoxPreview.Text); - } - catch - { - // ignored - } - } - - private void FormUnknownSubtitle_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void buttonImportPlainText_Click(object sender, System.EventArgs e) - { - ImportPlainText = true; - DialogResult = DialogResult.OK; - } - - private void UnknownSubtitle_Shown(object sender, System.EventArgs e) - { - buttonOK.Focus(); - } - } -} +using System.IO; +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class UnknownSubtitle : Form + { + public bool ImportPlainText { get; set; } + + public UnknownSubtitle() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = Configuration.Settings.Language.UnknownSubtitle.Title; + labelTitle.Text = Configuration.Settings.Language.UnknownSubtitle.Title; + richTextBoxMessage.Text = Configuration.Settings.Language.UnknownSubtitle.Message; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonImportPlainText.Text = Configuration.Settings.Language.UnknownSubtitle.ImportAsPlainText; + UiUtil.FixLargeFonts(this, buttonOK); + } + + public void Initialize(string title, string fileName, bool allowImportPlainText) + { + Text = title; + try + { + var file = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + + int length = (int)file.Length; + if (length > 100000) + { + length = 100000; + } + + file.Position = 0; + var fileBuffer = new byte[length]; + file.Read(fileBuffer, 0, length); + file.Close(); + + var encoding = LanguageAutoDetect.DetectAnsiEncoding(fileBuffer); + LabelPreview.Text = Configuration.Settings.Language.General.Preview + " - " + fileName; + textBoxPreview.Text = encoding.GetString(fileBuffer).Replace("\0", " "); + buttonImportPlainText.Visible = allowImportPlainText && !string.IsNullOrWhiteSpace(textBoxPreview.Text); + } + catch + { + // ignored + } + } + + private void FormUnknownSubtitle_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void buttonImportPlainText_Click(object sender, System.EventArgs e) + { + ImportPlainText = true; + DialogResult = DialogResult.OK; + } + + private void UnknownSubtitle_Shown(object sender, System.EventArgs e) + { + buttonOK.Focus(); + } + } +} diff --git a/src/Forms/UnknownSubtitle.resx b/src/ui/Forms/UnknownSubtitle.resx similarity index 97% rename from src/Forms/UnknownSubtitle.resx rename to src/ui/Forms/UnknownSubtitle.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/UnknownSubtitle.resx +++ b/src/ui/Forms/UnknownSubtitle.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/VideoControlsUndocked.Designer.cs b/src/ui/Forms/VideoControlsUndocked.Designer.cs similarity index 97% rename from src/Forms/VideoControlsUndocked.Designer.cs rename to src/ui/Forms/VideoControlsUndocked.Designer.cs index 8c45fe41a..cf6006cd5 100644 --- a/src/Forms/VideoControlsUndocked.Designer.cs +++ b/src/ui/Forms/VideoControlsUndocked.Designer.cs @@ -1,62 +1,62 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class VideoControlsUndocked - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.panelContainer = new System.Windows.Forms.Panel(); - this.SuspendLayout(); - // - // panelContainer - // - this.panelContainer.Dock = System.Windows.Forms.DockStyle.Fill; - this.panelContainer.Location = new System.Drawing.Point(0, 0); - this.panelContainer.Name = "panelContainer"; - this.panelContainer.Size = new System.Drawing.Size(458, 311); - this.panelContainer.TabIndex = 2; - // - // VideoControlsUndocked - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(458, 311); - this.Controls.Add(this.panelContainer); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; - this.KeyPreview = true; - this.Name = "VideoControlsUndocked"; - this.Text = "VideoControlsUndocked"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.VideoControlsUndocked_FormClosing); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VideoControlsUndocked_KeyDown); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel panelContainer; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class VideoControlsUndocked + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panelContainer = new System.Windows.Forms.Panel(); + this.SuspendLayout(); + // + // panelContainer + // + this.panelContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.panelContainer.Location = new System.Drawing.Point(0, 0); + this.panelContainer.Name = "panelContainer"; + this.panelContainer.Size = new System.Drawing.Size(458, 311); + this.panelContainer.TabIndex = 2; + // + // VideoControlsUndocked + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(458, 311); + this.Controls.Add(this.panelContainer); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; + this.KeyPreview = true; + this.Name = "VideoControlsUndocked"; + this.Text = "VideoControlsUndocked"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.VideoControlsUndocked_FormClosing); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VideoControlsUndocked_KeyDown); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panelContainer; + } } \ No newline at end of file diff --git a/src/Forms/VideoControlsUndocked.cs b/src/ui/Forms/VideoControlsUndocked.cs similarity index 96% rename from src/Forms/VideoControlsUndocked.cs rename to src/ui/Forms/VideoControlsUndocked.cs index 6b71cd4e4..1143721db 100644 --- a/src/Forms/VideoControlsUndocked.cs +++ b/src/ui/Forms/VideoControlsUndocked.cs @@ -1,57 +1,57 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System.Drawing; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class VideoControlsUndocked : PositionAndSizeForm - { - private readonly Main _mainForm; - private readonly Keys _redockKeys; - - public Panel PanelContainer => panelContainer; - - public VideoControlsUndocked(Main mainForm) - { - AutoScaleMode = AutoScaleMode.Dpi; - InitializeComponent(); - _mainForm = mainForm; - Icon = (Icon)mainForm.Icon.Clone(); - _redockKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls); - } - - public VideoControlsUndocked() - { - } - - private void VideoControlsUndocked_FormClosing(object sender, FormClosingEventArgs e) - { - if (e.CloseReason == CloseReason.UserClosing && panelContainer.Controls.Count > 0) - { - ReDock(); - } - } - - private void ReDock() - { - var control = panelContainer.Controls[0]; - var controlCheckBox = panelContainer.Controls[1]; - panelContainer.Controls.Clear(); - _mainForm.ReDockVideoButtons(control, controlCheckBox); - } - - private void VideoControlsUndocked_KeyDown(object sender, KeyEventArgs e) - { - if (_redockKeys == e.KeyData) - { - _mainForm.RedockVideoControlsToolStripMenuItemClick(null, null); - } - else - { - _mainForm.MainKeyDown(sender, e); - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System.Drawing; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class VideoControlsUndocked : PositionAndSizeForm + { + private readonly Main _mainForm; + private readonly Keys _redockKeys; + + public Panel PanelContainer => panelContainer; + + public VideoControlsUndocked(Main mainForm) + { + AutoScaleMode = AutoScaleMode.Dpi; + InitializeComponent(); + _mainForm = mainForm; + Icon = (Icon)mainForm.Icon.Clone(); + _redockKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls); + } + + public VideoControlsUndocked() + { + } + + private void VideoControlsUndocked_FormClosing(object sender, FormClosingEventArgs e) + { + if (e.CloseReason == CloseReason.UserClosing && panelContainer.Controls.Count > 0) + { + ReDock(); + } + } + + private void ReDock() + { + var control = panelContainer.Controls[0]; + var controlCheckBox = panelContainer.Controls[1]; + panelContainer.Controls.Clear(); + _mainForm.ReDockVideoButtons(control, controlCheckBox); + } + + private void VideoControlsUndocked_KeyDown(object sender, KeyEventArgs e) + { + if (_redockKeys == e.KeyData) + { + _mainForm.RedockVideoControlsToolStripMenuItemClick(null, null); + } + else + { + _mainForm.MainKeyDown(sender, e); + } + } + } +} diff --git a/src/Forms/VideoControlsUndocked.resx b/src/ui/Forms/VideoControlsUndocked.resx similarity index 97% rename from src/Forms/VideoControlsUndocked.resx rename to src/ui/Forms/VideoControlsUndocked.resx index 4f24d55cd..8b2ff64a1 100644 --- a/src/Forms/VideoControlsUndocked.resx +++ b/src/ui/Forms/VideoControlsUndocked.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/VideoError.Designer.cs b/src/ui/Forms/VideoError.Designer.cs similarity index 98% rename from src/Forms/VideoError.Designer.cs rename to src/ui/Forms/VideoError.Designer.cs index d4f1e4873..ae76792b1 100644 --- a/src/Forms/VideoError.Designer.cs +++ b/src/ui/Forms/VideoError.Designer.cs @@ -1,147 +1,147 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class VideoError - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.textBoxError = new System.Windows.Forms.TextBox(); - this.richTextBoxMessage = new System.Windows.Forms.RichTextBox(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonMpvSettings = new System.Windows.Forms.Button(); - this.labelMpvInfo = new System.Windows.Forms.Label(); - this.groupBox1.SuspendLayout(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox1.Controls.Add(this.textBoxError); - this.groupBox1.Location = new System.Drawing.Point(12, 180); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(674, 142); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Error message"; - // - // textBoxError - // - this.textBoxError.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxError.Location = new System.Drawing.Point(7, 20); - this.textBoxError.Multiline = true; - this.textBoxError.Name = "textBoxError"; - this.textBoxError.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxError.Size = new System.Drawing.Size(661, 116); - this.textBoxError.TabIndex = 0; - // - // richTextBoxMessage - // - this.richTextBoxMessage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.richTextBoxMessage.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.richTextBoxMessage.Location = new System.Drawing.Point(13, 23); - this.richTextBoxMessage.Name = "richTextBoxMessage"; - this.richTextBoxMessage.ReadOnly = true; - this.richTextBoxMessage.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; - this.richTextBoxMessage.Size = new System.Drawing.Size(674, 87); - this.richTextBoxMessage.TabIndex = 1; - this.richTextBoxMessage.Text = ""; - this.richTextBoxMessage.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.richTextBoxMessage_LinkClicked); - // - // buttonCancel - // - this.buttonCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(612, 328); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 11; - this.buttonCancel.Text = "&OK"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonMpvSettings - // - this.buttonMpvSettings.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.buttonMpvSettings.Location = new System.Drawing.Point(20, 134); - this.buttonMpvSettings.Name = "buttonMpvSettings"; - this.buttonMpvSettings.Size = new System.Drawing.Size(272, 23); - this.buttonMpvSettings.TabIndex = 30; - this.buttonMpvSettings.Text = "Download and use \"mpv\" as video player"; - this.buttonMpvSettings.UseVisualStyleBackColor = true; - this.buttonMpvSettings.Click += new System.EventHandler(this.buttonMpvSettings_Click); - // - // labelMpvInfo - // - this.labelMpvInfo.AutoSize = true; - this.labelMpvInfo.Location = new System.Drawing.Point(17, 118); - this.labelMpvInfo.Name = "labelMpvInfo"; - this.labelMpvInfo.Size = new System.Drawing.Size(69, 13); - this.labelMpvInfo.TabIndex = 31; - this.labelMpvInfo.Text = "labelMpvInfo"; - // - // VideoError - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(699, 361); - this.Controls.Add(this.labelMpvInfo); - this.Controls.Add(this.buttonMpvSettings); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.richTextBoxMessage); - this.Controls.Add(this.groupBox1); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(700, 350); - this.Name = "VideoError"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Error playing video file - "; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VideoError_KeyDown); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.TextBox textBoxError; - private System.Windows.Forms.RichTextBox richTextBoxMessage; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonMpvSettings; - private System.Windows.Forms.Label labelMpvInfo; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class VideoError + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.textBoxError = new System.Windows.Forms.TextBox(); + this.richTextBoxMessage = new System.Windows.Forms.RichTextBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonMpvSettings = new System.Windows.Forms.Button(); + this.labelMpvInfo = new System.Windows.Forms.Label(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox1.Controls.Add(this.textBoxError); + this.groupBox1.Location = new System.Drawing.Point(12, 180); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(674, 142); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Error message"; + // + // textBoxError + // + this.textBoxError.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxError.Location = new System.Drawing.Point(7, 20); + this.textBoxError.Multiline = true; + this.textBoxError.Name = "textBoxError"; + this.textBoxError.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxError.Size = new System.Drawing.Size(661, 116); + this.textBoxError.TabIndex = 0; + // + // richTextBoxMessage + // + this.richTextBoxMessage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.richTextBoxMessage.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.richTextBoxMessage.Location = new System.Drawing.Point(13, 23); + this.richTextBoxMessage.Name = "richTextBoxMessage"; + this.richTextBoxMessage.ReadOnly = true; + this.richTextBoxMessage.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; + this.richTextBoxMessage.Size = new System.Drawing.Size(674, 87); + this.richTextBoxMessage.TabIndex = 1; + this.richTextBoxMessage.Text = ""; + this.richTextBoxMessage.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.richTextBoxMessage_LinkClicked); + // + // buttonCancel + // + this.buttonCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(612, 328); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 11; + this.buttonCancel.Text = "&OK"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonMpvSettings + // + this.buttonMpvSettings.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.buttonMpvSettings.Location = new System.Drawing.Point(20, 134); + this.buttonMpvSettings.Name = "buttonMpvSettings"; + this.buttonMpvSettings.Size = new System.Drawing.Size(272, 23); + this.buttonMpvSettings.TabIndex = 30; + this.buttonMpvSettings.Text = "Download and use \"mpv\" as video player"; + this.buttonMpvSettings.UseVisualStyleBackColor = true; + this.buttonMpvSettings.Click += new System.EventHandler(this.buttonMpvSettings_Click); + // + // labelMpvInfo + // + this.labelMpvInfo.AutoSize = true; + this.labelMpvInfo.Location = new System.Drawing.Point(17, 118); + this.labelMpvInfo.Name = "labelMpvInfo"; + this.labelMpvInfo.Size = new System.Drawing.Size(69, 13); + this.labelMpvInfo.TabIndex = 31; + this.labelMpvInfo.Text = "labelMpvInfo"; + // + // VideoError + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(699, 361); + this.Controls.Add(this.labelMpvInfo); + this.Controls.Add(this.buttonMpvSettings); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.richTextBoxMessage); + this.Controls.Add(this.groupBox1); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(700, 350); + this.Name = "VideoError"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Error playing video file - "; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VideoError_KeyDown); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.TextBox textBoxError; + private System.Windows.Forms.RichTextBox richTextBoxMessage; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonMpvSettings; + private System.Windows.Forms.Label labelMpvInfo; + } } \ No newline at end of file diff --git a/src/Forms/VideoError.cs b/src/ui/Forms/VideoError.cs similarity index 97% rename from src/Forms/VideoError.cs rename to src/ui/Forms/VideoError.cs index 3ef6b125c..072f947c9 100644 --- a/src/Forms/VideoError.cs +++ b/src/ui/Forms/VideoError.cs @@ -1,126 +1,126 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using Nikse.SubtitleEdit.Logic.VideoPlayers; -using System; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class VideoError : Form - { - public VideoError() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - UiUtil.FixLargeFonts(this, buttonCancel); - } - - public void Initialize(string fileName, Exception exception) - { - var sb = new StringBuilder(); - sb.AppendLine("There seems to be missing a codec (or file is not a valid video/audio file)!"); - sb.AppendLine(); - - var currentVideoPlayer = Configuration.Settings.General.VideoPlayer; - - var isLibMpvInstalled = LibMpvDynamic.IsInstalled; - if (currentVideoPlayer == "MPV" && !isLibMpvInstalled) - { - currentVideoPlayer = "DirectShow"; - } - - if (currentVideoPlayer == "VLC" && !LibVlcDynamic.IsInstalled) - { - currentVideoPlayer = "DirectShow"; - } - - if (Configuration.IsRunningOnLinux) - { - sb.AppendLine("Try installing latest version of libmpv and libvlc!"); - sb.Append("Read more about Subtitle Edit on Linux here: https://nikse.dk/SubtitleEdit/Help#linux"); - } - else if (currentVideoPlayer == "DirectShow") - { - sb.AppendLine("Try installing/updating \"LAV Filters - DirectShow Media Splitter and Decoders\": https://github.com/Nevcairiel/LAVFilters/releases"); - sb.Append("Note that Subtitle Edit is a " + IntPtr.Size * 8 + "-bit program, and hence requires " + IntPtr.Size * 8 + "-bit codecs!"); - sb.AppendLine(); - } - else if (currentVideoPlayer == "VLC") - { - sb.AppendLine("VLC media player was unable to play this file (perhaps it's not a valid video/audio file) - you can change video player via Options -> Settings -> Video Player"); - sb.AppendLine("Latest version of VLC is available here: http://www.videolan.org/vlc/ (get the " + IntPtr.Size * 8 + "-bit version!)"); - sb.AppendLine(); - } - else if (currentVideoPlayer == "MPV" && Configuration.IsRunningOnWindows) - { - sb.AppendLine("You can re-download mpv or change video player via Options -> Settings -> Video Player"); - sb.AppendLine(); - } - richTextBoxMessage.Text = sb.ToString(); - - if (!Configuration.IsRunningOnWindows || currentVideoPlayer == "MPV") - { - buttonMpvSettings.Visible = false; - labelMpvInfo.Visible = false; - } - else if (currentVideoPlayer != "MPV") - { - labelMpvInfo.Text = $"You could also switch video player from \"{currentVideoPlayer}\" to \"mpv\"."; - if (isLibMpvInstalled) - { - buttonMpvSettings.Text = "Use \"mpv\" as video player"; - } - } - - if (exception != null) - { - var source = string.Empty; - if (!string.IsNullOrEmpty(exception.Source)) - { - source = "Source: " + exception.Source.Trim() + Environment.NewLine + Environment.NewLine; - } - - textBoxError.Text = "Message: " + exception.Message.Trim() + Environment.NewLine + - source + - "Stack Trace: " + Environment.NewLine + - exception.StackTrace.Trim(); - } - Text += fileName; - } - - private void VideoError_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - - private void richTextBoxMessage_LinkClicked(object sender, LinkClickedEventArgs e) - { - UiUtil.OpenURL(e.LinkText); - } - - private void buttonMpvSettings_Click(object sender, EventArgs e) - { - if (LibMpvDynamic.IsInstalled) - { - Configuration.Settings.General.VideoPlayer = "MPV"; - DialogResult = DialogResult.OK; - return; - } - - using (var form = new SettingsMpv(true)) - { - if (form.ShowDialog(this) == DialogResult.OK) - { - Configuration.Settings.General.VideoPlayer = "MPV"; - DialogResult = DialogResult.OK; - } - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using Nikse.SubtitleEdit.Logic.VideoPlayers; +using System; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class VideoError : Form + { + public VideoError() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + UiUtil.FixLargeFonts(this, buttonCancel); + } + + public void Initialize(string fileName, Exception exception) + { + var sb = new StringBuilder(); + sb.AppendLine("There seems to be missing a codec (or file is not a valid video/audio file)!"); + sb.AppendLine(); + + var currentVideoPlayer = Configuration.Settings.General.VideoPlayer; + + var isLibMpvInstalled = LibMpvDynamic.IsInstalled; + if (currentVideoPlayer == "MPV" && !isLibMpvInstalled) + { + currentVideoPlayer = "DirectShow"; + } + + if (currentVideoPlayer == "VLC" && !LibVlcDynamic.IsInstalled) + { + currentVideoPlayer = "DirectShow"; + } + + if (Configuration.IsRunningOnLinux) + { + sb.AppendLine("Try installing latest version of libmpv and libvlc!"); + sb.Append("Read more about Subtitle Edit on Linux here: https://nikse.dk/SubtitleEdit/Help#linux"); + } + else if (currentVideoPlayer == "DirectShow") + { + sb.AppendLine("Try installing/updating \"LAV Filters - DirectShow Media Splitter and Decoders\": https://github.com/Nevcairiel/LAVFilters/releases"); + sb.Append("Note that Subtitle Edit is a " + IntPtr.Size * 8 + "-bit program, and hence requires " + IntPtr.Size * 8 + "-bit codecs!"); + sb.AppendLine(); + } + else if (currentVideoPlayer == "VLC") + { + sb.AppendLine("VLC media player was unable to play this file (perhaps it's not a valid video/audio file) - you can change video player via Options -> Settings -> Video Player"); + sb.AppendLine("Latest version of VLC is available here: http://www.videolan.org/vlc/ (get the " + IntPtr.Size * 8 + "-bit version!)"); + sb.AppendLine(); + } + else if (currentVideoPlayer == "MPV" && Configuration.IsRunningOnWindows) + { + sb.AppendLine("You can re-download mpv or change video player via Options -> Settings -> Video Player"); + sb.AppendLine(); + } + richTextBoxMessage.Text = sb.ToString(); + + if (!Configuration.IsRunningOnWindows || currentVideoPlayer == "MPV") + { + buttonMpvSettings.Visible = false; + labelMpvInfo.Visible = false; + } + else if (currentVideoPlayer != "MPV") + { + labelMpvInfo.Text = $"You could also switch video player from \"{currentVideoPlayer}\" to \"mpv\"."; + if (isLibMpvInstalled) + { + buttonMpvSettings.Text = "Use \"mpv\" as video player"; + } + } + + if (exception != null) + { + var source = string.Empty; + if (!string.IsNullOrEmpty(exception.Source)) + { + source = "Source: " + exception.Source.Trim() + Environment.NewLine + Environment.NewLine; + } + + textBoxError.Text = "Message: " + exception.Message.Trim() + Environment.NewLine + + source + + "Stack Trace: " + Environment.NewLine + + exception.StackTrace.Trim(); + } + Text += fileName; + } + + private void VideoError_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + + private void richTextBoxMessage_LinkClicked(object sender, LinkClickedEventArgs e) + { + UiUtil.OpenURL(e.LinkText); + } + + private void buttonMpvSettings_Click(object sender, EventArgs e) + { + if (LibMpvDynamic.IsInstalled) + { + Configuration.Settings.General.VideoPlayer = "MPV"; + DialogResult = DialogResult.OK; + return; + } + + using (var form = new SettingsMpv(true)) + { + if (form.ShowDialog(this) == DialogResult.OK) + { + Configuration.Settings.General.VideoPlayer = "MPV"; + DialogResult = DialogResult.OK; + } + } + } + } +} diff --git a/src/Forms/VideoError.resx b/src/ui/Forms/VideoError.resx similarity index 97% rename from src/Forms/VideoError.resx rename to src/ui/Forms/VideoError.resx index c7e0d4bdf..d58980a38 100644 --- a/src/Forms/VideoError.resx +++ b/src/ui/Forms/VideoError.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/VideoPlayerUndocked.Designer.cs b/src/ui/Forms/VideoPlayerUndocked.Designer.cs similarity index 97% rename from src/Forms/VideoPlayerUndocked.Designer.cs rename to src/ui/Forms/VideoPlayerUndocked.Designer.cs index d38cd8473..7cbafb3af 100644 --- a/src/Forms/VideoPlayerUndocked.Designer.cs +++ b/src/ui/Forms/VideoPlayerUndocked.Designer.cs @@ -1,74 +1,74 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class VideoPlayerUndocked - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.panelContainer = new System.Windows.Forms.Panel(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.SuspendLayout(); - // - // panelContainer - // - this.panelContainer.BackColor = System.Drawing.Color.Black; - this.panelContainer.Dock = System.Windows.Forms.DockStyle.Fill; - this.panelContainer.Location = new System.Drawing.Point(0, 0); - this.panelContainer.Margin = new System.Windows.Forms.Padding(0); - this.panelContainer.Name = "panelContainer"; - this.panelContainer.Size = new System.Drawing.Size(614, 323); - this.panelContainer.TabIndex = 0; - // - // timer1 - // - this.timer1.Interval = 3000; - this.timer1.Tick += new System.EventHandler(this.timer1_Tick); - // - // VideoPlayerUndocked - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(614, 323); - this.Controls.Add(this.panelContainer); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; - this.KeyPreview = true; - this.Name = "VideoPlayerUndocked"; - this.Text = "VideoPlayerUndocked"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.VideoPlayerUndocked_FormClosing); - this.Shown += new System.EventHandler(this.VideoPlayerUndocked_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VideoPlayerUndocked_KeyDown); - this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.VideoPlayerUndocked_MouseMove); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel panelContainer; - private System.Windows.Forms.Timer timer1; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class VideoPlayerUndocked + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.panelContainer = new System.Windows.Forms.Panel(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.SuspendLayout(); + // + // panelContainer + // + this.panelContainer.BackColor = System.Drawing.Color.Black; + this.panelContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.panelContainer.Location = new System.Drawing.Point(0, 0); + this.panelContainer.Margin = new System.Windows.Forms.Padding(0); + this.panelContainer.Name = "panelContainer"; + this.panelContainer.Size = new System.Drawing.Size(614, 323); + this.panelContainer.TabIndex = 0; + // + // timer1 + // + this.timer1.Interval = 3000; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // VideoPlayerUndocked + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(614, 323); + this.Controls.Add(this.panelContainer); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; + this.KeyPreview = true; + this.Name = "VideoPlayerUndocked"; + this.Text = "VideoPlayerUndocked"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.VideoPlayerUndocked_FormClosing); + this.Shown += new System.EventHandler(this.VideoPlayerUndocked_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VideoPlayerUndocked_KeyDown); + this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.VideoPlayerUndocked_MouseMove); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panelContainer; + private System.Windows.Forms.Timer timer1; + } } \ No newline at end of file diff --git a/src/Forms/VideoPlayerUndocked.cs b/src/ui/Forms/VideoPlayerUndocked.cs similarity index 97% rename from src/Forms/VideoPlayerUndocked.cs rename to src/ui/Forms/VideoPlayerUndocked.cs index 23713e3ce..db096923b 100644 --- a/src/Forms/VideoPlayerUndocked.cs +++ b/src/ui/Forms/VideoPlayerUndocked.cs @@ -1,173 +1,173 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Drawing; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class VideoPlayerUndocked : PositionAndSizeForm - { - private readonly Main _mainForm; - private readonly Controls.VideoPlayerContainer _videoPlayerContainer; - private readonly Keys _redockKeys; - - public bool RedockOnFullscreenEnd { get; set; } - - public Panel PanelContainer => panelContainer; - - public VideoPlayerUndocked(Main main, Controls.VideoPlayerContainer videoPlayerContainer) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _mainForm = main; - Icon = (Icon)_mainForm.Icon.Clone(); - _videoPlayerContainer = videoPlayerContainer; - _redockKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls); - RedockOnFullscreenEnd = false; - videoPlayerContainer.TextBox.MouseMove += VideoPlayerUndocked_MouseMove; - } - - public VideoPlayerUndocked() - { - } - - private void VideoPlayerUndocked_FormClosing(object sender, FormClosingEventArgs e) - { - _videoPlayerContainer.ShowCursor(); - if (RedockOnFullscreenEnd) - { - _mainForm.RedockVideoControlsToolStripMenuItemClick(null, null); - } - else if (e.CloseReason == CloseReason.UserClosing && panelContainer.Controls.Count > 0) - { - var control = panelContainer.Controls[0]; - if (control is Panel) - { - panelContainer.Controls.Clear(); - _mainForm.ReDockVideoPlayer(control); - _mainForm.SetVideoPlayerToggleOff(); - } - } - } - - private void VideoPlayerUndocked_KeyDown(object sender, KeyEventArgs e) - { - VideoPlayerUndocked_MouseMove(null, null); - - if (e.Modifiers == Keys.None && e.KeyCode == Keys.Space) - { - _videoPlayerContainer.TogglePlayPause(); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Enter) - { - if (IsFullscreen) - { - e.SuppressKeyPress = true; - NoFullscreen(); - } - else if (WindowState == FormWindowState.Normal) - { - GoFullscreen(); - } - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Escape && IsFullscreen) - { - e.SuppressKeyPress = true; - NoFullscreen(); - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.A) - { - if (_videoPlayerContainer.VideoWidth > 0 && _videoPlayerContainer.VideoHeight > 0) - { - int wDiff = _videoPlayerContainer.VideoWidth - _videoPlayerContainer.PanelPlayer.Width; - int hDiff = _videoPlayerContainer.VideoHeight - _videoPlayerContainer.PanelPlayer.Height; - Width += wDiff; - Height += hDiff; - e.SuppressKeyPress = true; - } - } - else if (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt && IsFullscreen) - { - _mainForm.GotoPrevSubPosFromvideoPos(); - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Down && IsFullscreen) - { - _mainForm.GotoNextSubPosFromVideoPos(); - e.SuppressKeyPress = true; - } - else if (_redockKeys == e.KeyData) - { - _mainForm.RedockVideoControlsToolStripMenuItemClick(null, null); - e.SuppressKeyPress = true; - } - else - { - _mainForm.MainKeyDown(sender, e); - } - } - - private void VideoPlayerUndocked_MouseMove(object sender, MouseEventArgs e) - { - if (timer1.Enabled) - { - timer1.Stop(); - } - - _videoPlayerContainer.ShowControls(); - timer1.Start(); - } - - private void timer1_Tick(object sender, EventArgs e) - { - timer1.Stop(); - if (IsFullscreen) - { - var videoScreen = Screen.FromControl(_videoPlayerContainer); - var mainScreen = Screen.FromControl(_mainForm); - _videoPlayerContainer.HideControls(videoScreen.DeviceName == mainScreen.DeviceName); - } - } - - internal void GoFullscreen() - { - IsFullscreen = true; - FormBorderStyle = FormBorderStyle.None; - WindowState = FormWindowState.Maximized; - _videoPlayerContainer.FontSizeFactor = 1.5F; - _videoPlayerContainer.SetSubtitleFont(); - _videoPlayerContainer.SubtitleText = string.Empty; - _videoPlayerContainer.ShowFullScreenControls(); - timer1.Start(); - } - - internal bool IsFullscreen { get; set; } - - internal void NoFullscreen() - { - IsFullscreen = false; - FormBorderStyle = FormBorderStyle.SizableToolWindow; - WindowState = FormWindowState.Normal; - _videoPlayerContainer.FontSizeFactor = 1.0F; - _videoPlayerContainer.SetSubtitleFont(); - _videoPlayerContainer.SubtitleText = string.Empty; - _videoPlayerContainer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton; - _videoPlayerContainer.ShowNonFullScreenControls(); - if (RedockOnFullscreenEnd) - { - Close(); - } - } - - private void VideoPlayerUndocked_Shown(object sender, EventArgs e) - { - Refresh(); - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Drawing; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class VideoPlayerUndocked : PositionAndSizeForm + { + private readonly Main _mainForm; + private readonly Controls.VideoPlayerContainer _videoPlayerContainer; + private readonly Keys _redockKeys; + + public bool RedockOnFullscreenEnd { get; set; } + + public Panel PanelContainer => panelContainer; + + public VideoPlayerUndocked(Main main, Controls.VideoPlayerContainer videoPlayerContainer) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _mainForm = main; + Icon = (Icon)_mainForm.Icon.Clone(); + _videoPlayerContainer = videoPlayerContainer; + _redockKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls); + RedockOnFullscreenEnd = false; + videoPlayerContainer.TextBox.MouseMove += VideoPlayerUndocked_MouseMove; + } + + public VideoPlayerUndocked() + { + } + + private void VideoPlayerUndocked_FormClosing(object sender, FormClosingEventArgs e) + { + _videoPlayerContainer.ShowCursor(); + if (RedockOnFullscreenEnd) + { + _mainForm.RedockVideoControlsToolStripMenuItemClick(null, null); + } + else if (e.CloseReason == CloseReason.UserClosing && panelContainer.Controls.Count > 0) + { + var control = panelContainer.Controls[0]; + if (control is Panel) + { + panelContainer.Controls.Clear(); + _mainForm.ReDockVideoPlayer(control); + _mainForm.SetVideoPlayerToggleOff(); + } + } + } + + private void VideoPlayerUndocked_KeyDown(object sender, KeyEventArgs e) + { + VideoPlayerUndocked_MouseMove(null, null); + + if (e.Modifiers == Keys.None && e.KeyCode == Keys.Space) + { + _videoPlayerContainer.TogglePlayPause(); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Enter) + { + if (IsFullscreen) + { + e.SuppressKeyPress = true; + NoFullscreen(); + } + else if (WindowState == FormWindowState.Normal) + { + GoFullscreen(); + } + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Escape && IsFullscreen) + { + e.SuppressKeyPress = true; + NoFullscreen(); + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.A) + { + if (_videoPlayerContainer.VideoWidth > 0 && _videoPlayerContainer.VideoHeight > 0) + { + int wDiff = _videoPlayerContainer.VideoWidth - _videoPlayerContainer.PanelPlayer.Width; + int hDiff = _videoPlayerContainer.VideoHeight - _videoPlayerContainer.PanelPlayer.Height; + Width += wDiff; + Height += hDiff; + e.SuppressKeyPress = true; + } + } + else if (e.KeyCode == Keys.Up && e.Modifiers == Keys.Alt && IsFullscreen) + { + _mainForm.GotoPrevSubPosFromvideoPos(); + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Down && IsFullscreen) + { + _mainForm.GotoNextSubPosFromVideoPos(); + e.SuppressKeyPress = true; + } + else if (_redockKeys == e.KeyData) + { + _mainForm.RedockVideoControlsToolStripMenuItemClick(null, null); + e.SuppressKeyPress = true; + } + else + { + _mainForm.MainKeyDown(sender, e); + } + } + + private void VideoPlayerUndocked_MouseMove(object sender, MouseEventArgs e) + { + if (timer1.Enabled) + { + timer1.Stop(); + } + + _videoPlayerContainer.ShowControls(); + timer1.Start(); + } + + private void timer1_Tick(object sender, EventArgs e) + { + timer1.Stop(); + if (IsFullscreen) + { + var videoScreen = Screen.FromControl(_videoPlayerContainer); + var mainScreen = Screen.FromControl(_mainForm); + _videoPlayerContainer.HideControls(videoScreen.DeviceName == mainScreen.DeviceName); + } + } + + internal void GoFullscreen() + { + IsFullscreen = true; + FormBorderStyle = FormBorderStyle.None; + WindowState = FormWindowState.Maximized; + _videoPlayerContainer.FontSizeFactor = 1.5F; + _videoPlayerContainer.SetSubtitleFont(); + _videoPlayerContainer.SubtitleText = string.Empty; + _videoPlayerContainer.ShowFullScreenControls(); + timer1.Start(); + } + + internal bool IsFullscreen { get; set; } + + internal void NoFullscreen() + { + IsFullscreen = false; + FormBorderStyle = FormBorderStyle.SizableToolWindow; + WindowState = FormWindowState.Normal; + _videoPlayerContainer.FontSizeFactor = 1.0F; + _videoPlayerContainer.SetSubtitleFont(); + _videoPlayerContainer.SubtitleText = string.Empty; + _videoPlayerContainer.ShowFullscreenButton = Configuration.Settings.General.VideoPlayerShowFullscreenButton; + _videoPlayerContainer.ShowNonFullScreenControls(); + if (RedockOnFullscreenEnd) + { + Close(); + } + } + + private void VideoPlayerUndocked_Shown(object sender, EventArgs e) + { + Refresh(); + } + + } +} diff --git a/src/Forms/VideoPlayerUndocked.resx b/src/ui/Forms/VideoPlayerUndocked.resx similarity index 97% rename from src/Forms/VideoPlayerUndocked.resx rename to src/ui/Forms/VideoPlayerUndocked.resx index aac33d5a2..1f666f268 100644 --- a/src/Forms/VideoPlayerUndocked.resx +++ b/src/ui/Forms/VideoPlayerUndocked.resx @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + \ No newline at end of file diff --git a/src/Forms/VisualSync.Designer.cs b/src/ui/Forms/VisualSync.Designer.cs similarity index 98% rename from src/Forms/VisualSync.Designer.cs rename to src/ui/Forms/VisualSync.Designer.cs index 7863520c1..d89e77db4 100644 --- a/src/Forms/VisualSync.Designer.cs +++ b/src/ui/Forms/VisualSync.Designer.cs @@ -1,457 +1,457 @@ -using Nikse.SubtitleEdit.Logic; -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class VisualSync - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.buttonOpenMovie = new System.Windows.Forms.Button(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxStartScene = new System.Windows.Forms.GroupBox(); - this.MediaPlayerStart = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); - this.panelControlsStart = new System.Windows.Forms.Panel(); - this.buttonStartVerify = new System.Windows.Forms.Button(); - this.buttonGotoStartSubtitlePosition = new System.Windows.Forms.Button(); - this.buttonFindTextStart = new System.Windows.Forms.Button(); - this.buttonStartThreeSecondsBack = new System.Windows.Forms.Button(); - this.buttonStartHalfASecondBack = new System.Windows.Forms.Button(); - this.comboBoxStartTexts = new System.Windows.Forms.ComboBox(); - this.groupBoxEndScene = new System.Windows.Forms.GroupBox(); - this.MediaPlayerEnd = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); - this.panelControlsEnd = new System.Windows.Forms.Panel(); - this.buttonEndVerify = new System.Windows.Forms.Button(); - this.buttonGotoEndSubtitlePosition = new System.Windows.Forms.Button(); - this.buttonFindTextEnd = new System.Windows.Forms.Button(); - this.buttonThreeSecondsBack = new System.Windows.Forms.Button(); - this.buttonEndHalfASecondBack = new System.Windows.Forms.Button(); - this.comboBoxEndTexts = new System.Windows.Forms.ComboBox(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.labelVideoInfo = new System.Windows.Forms.Label(); - this.groupBoxMovieInfo = new System.Windows.Forms.GroupBox(); - this.buttonSync = new System.Windows.Forms.Button(); - this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); - this.labelTip = new System.Windows.Forms.Label(); - this.timerProgressBarRefresh = new System.Windows.Forms.Timer(this.components); - this.labelSyncDone = new System.Windows.Forms.Label(); - this.groupBoxStartScene.SuspendLayout(); - this.panelControlsStart.SuspendLayout(); - this.groupBoxEndScene.SuspendLayout(); - this.panelControlsEnd.SuspendLayout(); - this.groupBoxMovieInfo.SuspendLayout(); - this.SuspendLayout(); - // - // buttonOpenMovie - // - this.buttonOpenMovie.Location = new System.Drawing.Point(12, 12); - this.buttonOpenMovie.Name = "buttonOpenMovie"; - this.buttonOpenMovie.Size = new System.Drawing.Size(100, 23); - this.buttonOpenMovie.TabIndex = 5; - this.buttonOpenMovie.Text = "Open movie..."; - this.buttonOpenMovie.UseVisualStyleBackColor = true; - this.buttonOpenMovie.Click += new System.EventHandler(this.ButtonOpenMovieClick); - // - // timer1 - // - this.timer1.Interval = 50; - this.timer1.Tick += new System.EventHandler(this.Timer1Tick); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.Location = new System.Drawing.Point(754, 490); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // groupBoxStartScene - // - this.groupBoxStartScene.Controls.Add(this.MediaPlayerStart); - this.groupBoxStartScene.Controls.Add(this.panelControlsStart); - this.groupBoxStartScene.Location = new System.Drawing.Point(12, 65); - this.groupBoxStartScene.Name = "groupBoxStartScene"; - this.groupBoxStartScene.Size = new System.Drawing.Size(450, 399); - this.groupBoxStartScene.TabIndex = 0; - this.groupBoxStartScene.TabStop = false; - this.groupBoxStartScene.Text = "Start scene"; - this.groupBoxStartScene.Enter += new System.EventHandler(this.GroupBoxStartSceneEnter); - // - // MediaPlayerStart - // - this.MediaPlayerStart.BackColor = System.Drawing.Color.Black; - this.MediaPlayerStart.CurrentPosition = 0D; - this.MediaPlayerStart.FontSizeFactor = 1F; - this.MediaPlayerStart.LastParagraph = null; - this.MediaPlayerStart.Location = new System.Drawing.Point(6, 34); - this.MediaPlayerStart.Name = "MediaPlayerStart"; - this.MediaPlayerStart.ShowFullscreenButton = true; - this.MediaPlayerStart.ShowMuteButton = true; - this.MediaPlayerStart.ShowStopButton = true; - this.MediaPlayerStart.Size = new System.Drawing.Size(450, 287); - this.MediaPlayerStart.SmpteMode = false; - this.MediaPlayerStart.SubtitleText = ""; - this.MediaPlayerStart.TabIndex = 13; - this.MediaPlayerStart.TextRightToLeft = System.Windows.Forms.RightToLeft.No; - this.MediaPlayerStart.VideoHeight = 0; - this.MediaPlayerStart.VideoPlayer = null; - this.MediaPlayerStart.VideoWidth = 0; - this.MediaPlayerStart.Volume = 0D; - this.MediaPlayerStart.OnButtonClicked += new System.EventHandler(this.MediaPlayerStart_OnButtonClicked); - // - // panelControlsStart - // - this.panelControlsStart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.panelControlsStart.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelControlsStart.Controls.Add(this.buttonStartVerify); - this.panelControlsStart.Controls.Add(this.buttonGotoStartSubtitlePosition); - this.panelControlsStart.Controls.Add(this.buttonFindTextStart); - this.panelControlsStart.Controls.Add(this.buttonStartThreeSecondsBack); - this.panelControlsStart.Controls.Add(this.buttonStartHalfASecondBack); - this.panelControlsStart.Controls.Add(this.comboBoxStartTexts); - this.panelControlsStart.Location = new System.Drawing.Point(6, 327); - this.panelControlsStart.Name = "panelControlsStart"; - this.panelControlsStart.Size = new System.Drawing.Size(438, 68); - this.panelControlsStart.TabIndex = 1; - // - // buttonStartVerify - // - this.buttonStartVerify.Location = new System.Drawing.Point(138, 37); - this.buttonStartVerify.Name = "buttonStartVerify"; - this.buttonStartVerify.Size = new System.Drawing.Size(119, 23); - this.buttonStartVerify.TabIndex = 3; - this.buttonStartVerify.Text = "Play 2 s and back"; - this.buttonStartVerify.UseVisualStyleBackColor = true; - this.buttonStartVerify.Click += new System.EventHandler(this.ButtonStartVerifyClick); - // - // buttonGotoStartSubtitlePosition - // - this.buttonGotoStartSubtitlePosition.Location = new System.Drawing.Point(263, 37); - this.buttonGotoStartSubtitlePosition.Name = "buttonGotoStartSubtitlePosition"; - this.buttonGotoStartSubtitlePosition.Size = new System.Drawing.Size(90, 23); - this.buttonGotoStartSubtitlePosition.TabIndex = 4; - this.buttonGotoStartSubtitlePosition.Text = "Goto sub Position"; - this.buttonGotoStartSubtitlePosition.UseVisualStyleBackColor = true; - this.buttonGotoStartSubtitlePosition.Click += new System.EventHandler(this.ButtonGotoStartSubtitlePositionClick); - // - // buttonFindTextStart - // - this.buttonFindTextStart.Location = new System.Drawing.Point(359, 37); - this.buttonFindTextStart.Name = "buttonFindTextStart"; - this.buttonFindTextStart.Size = new System.Drawing.Size(70, 23); - this.buttonFindTextStart.TabIndex = 5; - this.buttonFindTextStart.Text = "Find text..."; - this.buttonFindTextStart.UseVisualStyleBackColor = true; - this.buttonFindTextStart.Click += new System.EventHandler(this.ButtonFindTextStartClick); - // - // buttonStartThreeSecondsBack - // - this.buttonStartThreeSecondsBack.Location = new System.Drawing.Point(6, 37); - this.buttonStartThreeSecondsBack.Name = "buttonStartThreeSecondsBack"; - this.buttonStartThreeSecondsBack.Size = new System.Drawing.Size(60, 23); - this.buttonStartThreeSecondsBack.TabIndex = 1; - this.buttonStartThreeSecondsBack.Text = "< 3 s"; - this.buttonStartThreeSecondsBack.UseVisualStyleBackColor = true; - this.buttonStartThreeSecondsBack.Click += new System.EventHandler(this.ButtonStartThreeSecondsBackClick); - // - // buttonStartHalfASecondBack - // - this.buttonStartHalfASecondBack.Location = new System.Drawing.Point(72, 37); - this.buttonStartHalfASecondBack.Name = "buttonStartHalfASecondBack"; - this.buttonStartHalfASecondBack.Size = new System.Drawing.Size(60, 23); - this.buttonStartHalfASecondBack.TabIndex = 2; - this.buttonStartHalfASecondBack.Text = "< ½ s"; - this.buttonStartHalfASecondBack.UseVisualStyleBackColor = true; - this.buttonStartHalfASecondBack.Click += new System.EventHandler(this.ButtonStartHalfASecondBackClick); - // - // comboBoxStartTexts - // - this.comboBoxStartTexts.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxStartTexts.FormattingEnabled = true; - this.comboBoxStartTexts.Location = new System.Drawing.Point(7, 10); - this.comboBoxStartTexts.Name = "comboBoxStartTexts"; - this.comboBoxStartTexts.Size = new System.Drawing.Size(422, 21); - this.comboBoxStartTexts.TabIndex = 0; - // - // groupBoxEndScene - // - this.groupBoxEndScene.Controls.Add(this.MediaPlayerEnd); - this.groupBoxEndScene.Controls.Add(this.panelControlsEnd); - this.groupBoxEndScene.Location = new System.Drawing.Point(468, 65); - this.groupBoxEndScene.Name = "groupBoxEndScene"; - this.groupBoxEndScene.Size = new System.Drawing.Size(450, 399); - this.groupBoxEndScene.TabIndex = 1; - this.groupBoxEndScene.TabStop = false; - this.groupBoxEndScene.Text = "End scene"; - this.groupBoxEndScene.Enter += new System.EventHandler(this.GroupBoxEndSceneEnter); - // - // MediaPlayerEnd - // - this.MediaPlayerEnd.BackColor = System.Drawing.Color.Black; - this.MediaPlayerEnd.CurrentPosition = 0D; - this.MediaPlayerEnd.FontSizeFactor = 1F; - this.MediaPlayerEnd.LastParagraph = null; - this.MediaPlayerEnd.Location = new System.Drawing.Point(6, 34); - this.MediaPlayerEnd.Name = "MediaPlayerEnd"; - this.MediaPlayerEnd.ShowFullscreenButton = true; - this.MediaPlayerEnd.ShowMuteButton = true; - this.MediaPlayerEnd.ShowStopButton = true; - this.MediaPlayerEnd.Size = new System.Drawing.Size(438, 287); - this.MediaPlayerEnd.SmpteMode = false; - this.MediaPlayerEnd.SubtitleText = ""; - this.MediaPlayerEnd.TabIndex = 14; - this.MediaPlayerEnd.TextRightToLeft = System.Windows.Forms.RightToLeft.No; - this.MediaPlayerEnd.VideoHeight = 0; - this.MediaPlayerEnd.VideoPlayer = null; - this.MediaPlayerEnd.VideoWidth = 0; - this.MediaPlayerEnd.Volume = 0D; - this.MediaPlayerEnd.OnButtonClicked += new System.EventHandler(this.MediaPlayerEnd_OnButtonClicked); - // - // panelControlsEnd - // - this.panelControlsEnd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.panelControlsEnd.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panelControlsEnd.Controls.Add(this.buttonEndVerify); - this.panelControlsEnd.Controls.Add(this.buttonGotoEndSubtitlePosition); - this.panelControlsEnd.Controls.Add(this.buttonFindTextEnd); - this.panelControlsEnd.Controls.Add(this.buttonThreeSecondsBack); - this.panelControlsEnd.Controls.Add(this.buttonEndHalfASecondBack); - this.panelControlsEnd.Controls.Add(this.comboBoxEndTexts); - this.panelControlsEnd.Location = new System.Drawing.Point(7, 327); - this.panelControlsEnd.Name = "panelControlsEnd"; - this.panelControlsEnd.Size = new System.Drawing.Size(438, 68); - this.panelControlsEnd.TabIndex = 1; - // - // buttonEndVerify - // - this.buttonEndVerify.Location = new System.Drawing.Point(139, 37); - this.buttonEndVerify.Name = "buttonEndVerify"; - this.buttonEndVerify.Size = new System.Drawing.Size(118, 23); - this.buttonEndVerify.TabIndex = 3; - this.buttonEndVerify.Text = "Play 2 s and back"; - this.buttonEndVerify.UseVisualStyleBackColor = true; - this.buttonEndVerify.Click += new System.EventHandler(this.ButtonEndVerifyClick); - // - // buttonGotoEndSubtitlePosition - // - this.buttonGotoEndSubtitlePosition.Location = new System.Drawing.Point(263, 37); - this.buttonGotoEndSubtitlePosition.Name = "buttonGotoEndSubtitlePosition"; - this.buttonGotoEndSubtitlePosition.Size = new System.Drawing.Size(90, 23); - this.buttonGotoEndSubtitlePosition.TabIndex = 4; - this.buttonGotoEndSubtitlePosition.Text = "Goto sub Position"; - this.buttonGotoEndSubtitlePosition.UseVisualStyleBackColor = true; - this.buttonGotoEndSubtitlePosition.Click += new System.EventHandler(this.ButtonGotoEndSubtitlePositionClick); - // - // buttonFindTextEnd - // - this.buttonFindTextEnd.Location = new System.Drawing.Point(359, 37); - this.buttonFindTextEnd.Name = "buttonFindTextEnd"; - this.buttonFindTextEnd.Size = new System.Drawing.Size(70, 23); - this.buttonFindTextEnd.TabIndex = 5; - this.buttonFindTextEnd.Text = "Find text..."; - this.buttonFindTextEnd.UseVisualStyleBackColor = true; - this.buttonFindTextEnd.Click += new System.EventHandler(this.ButtonFindTextEndClick); - // - // buttonThreeSecondsBack - // - this.buttonThreeSecondsBack.Location = new System.Drawing.Point(7, 37); - this.buttonThreeSecondsBack.Name = "buttonThreeSecondsBack"; - this.buttonThreeSecondsBack.Size = new System.Drawing.Size(60, 23); - this.buttonThreeSecondsBack.TabIndex = 1; - this.buttonThreeSecondsBack.Text = "< 3 s"; - this.buttonThreeSecondsBack.UseVisualStyleBackColor = true; - this.buttonThreeSecondsBack.Click += new System.EventHandler(this.ButtonThreeSecondsBackClick); - // - // buttonEndHalfASecondBack - // - this.buttonEndHalfASecondBack.Location = new System.Drawing.Point(73, 37); - this.buttonEndHalfASecondBack.Name = "buttonEndHalfASecondBack"; - this.buttonEndHalfASecondBack.Size = new System.Drawing.Size(60, 23); - this.buttonEndHalfASecondBack.TabIndex = 2; - this.buttonEndHalfASecondBack.Text = "< ½ s"; - this.buttonEndHalfASecondBack.UseVisualStyleBackColor = true; - this.buttonEndHalfASecondBack.Click += new System.EventHandler(this.ButtonEndHalfASecondBackClick); - // - // comboBoxEndTexts - // - this.comboBoxEndTexts.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxEndTexts.FormattingEnabled = true; - this.comboBoxEndTexts.Location = new System.Drawing.Point(7, 10); - this.comboBoxEndTexts.Name = "comboBoxEndTexts"; - this.comboBoxEndTexts.Size = new System.Drawing.Size(422, 21); - this.comboBoxEndTexts.TabIndex = 0; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(835, 490); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // labelVideoInfo - // - this.labelVideoInfo.AutoSize = true; - this.labelVideoInfo.Location = new System.Drawing.Point(6, 16); - this.labelVideoInfo.Name = "labelVideoInfo"; - this.labelVideoInfo.Size = new System.Drawing.Size(84, 13); - this.labelVideoInfo.TabIndex = 13; - this.labelVideoInfo.Text = "No video loaded"; - // - // groupBoxMovieInfo - // - this.groupBoxMovieInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxMovieInfo.Controls.Add(this.labelVideoInfo); - this.groupBoxMovieInfo.Location = new System.Drawing.Point(132, 8); - this.groupBoxMovieInfo.Name = "groupBoxMovieInfo"; - this.groupBoxMovieInfo.Size = new System.Drawing.Size(786, 53); - this.groupBoxMovieInfo.TabIndex = 14; - this.groupBoxMovieInfo.TabStop = false; - this.groupBoxMovieInfo.Text = "Movie info"; - // - // buttonSync - // - this.buttonSync.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.buttonSync.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.buttonSync.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.buttonSync.Location = new System.Drawing.Point(395, 488); - this.buttonSync.Name = "buttonSync"; - this.buttonSync.Size = new System.Drawing.Size(148, 31); - this.buttonSync.TabIndex = 2; - this.buttonSync.Text = "Sync!"; - this.buttonSync.UseVisualStyleBackColor = true; - this.buttonSync.Click += new System.EventHandler(this.ButtonSyncClick); - // - // openFileDialog1 - // - this.openFileDialog1.FileName = "openFileDialog1"; - // - // labelTip - // - this.labelTip.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelTip.AutoSize = true; - this.labelTip.ForeColor = System.Drawing.Color.Gray; - this.labelTip.Location = new System.Drawing.Point(12, 473); - this.labelTip.Name = "labelTip"; - this.labelTip.Size = new System.Drawing.Size(332, 13); - this.labelTip.TabIndex = 15; - this.labelTip.Text = "Tip: Use keys to move 100 ms back/forward"; - // - // timerProgressBarRefresh - // - this.timerProgressBarRefresh.Tick += new System.EventHandler(this.timerProgressBarRefresh_Tick); - // - // labelSyncDone - // - this.labelSyncDone.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.labelSyncDone.AutoSize = true; - this.labelSyncDone.ForeColor = System.Drawing.Color.Gray; - this.labelSyncDone.Location = new System.Drawing.Point(546, 502); - this.labelSyncDone.Name = "labelSyncDone"; - this.labelSyncDone.Size = new System.Drawing.Size(77, 13); - this.labelSyncDone.TabIndex = 16; - this.labelSyncDone.Text = "labelSyncDone"; - // - // VisualSync - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(927, 525); - this.Controls.Add(this.labelSyncDone); - this.Controls.Add(this.buttonSync); - this.Controls.Add(this.labelTip); - this.Controls.Add(this.groupBoxMovieInfo); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.groupBoxEndScene); - this.Controls.Add(this.groupBoxStartScene); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonOpenMovie); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.KeyPreview = true; - this.MinimumSize = new System.Drawing.Size(935, 540); - this.Name = "VisualSync"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Visual Sync"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormVisualSync_FormClosing); - this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.VisualSync_FormClosed); - this.Load += new System.EventHandler(this.VisualSync_Load); - this.Shown += new System.EventHandler(this.VisualSync_Shown); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VisualSync_KeyDown); - this.Resize += new System.EventHandler(this.FormVisualSync_Resize); - this.groupBoxStartScene.ResumeLayout(false); - this.panelControlsStart.ResumeLayout(false); - this.groupBoxEndScene.ResumeLayout(false); - this.panelControlsEnd.ResumeLayout(false); - this.groupBoxMovieInfo.ResumeLayout(false); - this.groupBoxMovieInfo.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button buttonOpenMovie; - private System.Windows.Forms.Timer timer1; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.GroupBox groupBoxStartScene; - private System.Windows.Forms.GroupBox groupBoxEndScene; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Panel panelControlsStart; - private System.Windows.Forms.ComboBox comboBoxStartTexts; - private System.Windows.Forms.Button buttonGotoStartSubtitlePosition; - private System.Windows.Forms.Button buttonFindTextStart; - private System.Windows.Forms.Button buttonStartThreeSecondsBack; - private System.Windows.Forms.Button buttonStartHalfASecondBack; - private System.Windows.Forms.Label labelVideoInfo; - private System.Windows.Forms.GroupBox groupBoxMovieInfo; - private System.Windows.Forms.Panel panelControlsEnd; - private System.Windows.Forms.Button buttonGotoEndSubtitlePosition; - private System.Windows.Forms.Button buttonFindTextEnd; - private System.Windows.Forms.Button buttonThreeSecondsBack; - private System.Windows.Forms.Button buttonEndHalfASecondBack; - private System.Windows.Forms.ComboBox comboBoxEndTexts; - private System.Windows.Forms.Button buttonSync; - private System.Windows.Forms.OpenFileDialog openFileDialog1; - private System.Windows.Forms.Button buttonStartVerify; - private System.Windows.Forms.Button buttonEndVerify; - private Nikse.SubtitleEdit.Controls.VideoPlayerContainer MediaPlayerStart; - private Nikse.SubtitleEdit.Controls.VideoPlayerContainer MediaPlayerEnd; - private System.Windows.Forms.Label labelTip; - private System.Windows.Forms.Timer timerProgressBarRefresh; - private System.Windows.Forms.Label labelSyncDone; - } +using Nikse.SubtitleEdit.Logic; +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class VisualSync + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonOpenMovie = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxStartScene = new System.Windows.Forms.GroupBox(); + this.MediaPlayerStart = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); + this.panelControlsStart = new System.Windows.Forms.Panel(); + this.buttonStartVerify = new System.Windows.Forms.Button(); + this.buttonGotoStartSubtitlePosition = new System.Windows.Forms.Button(); + this.buttonFindTextStart = new System.Windows.Forms.Button(); + this.buttonStartThreeSecondsBack = new System.Windows.Forms.Button(); + this.buttonStartHalfASecondBack = new System.Windows.Forms.Button(); + this.comboBoxStartTexts = new System.Windows.Forms.ComboBox(); + this.groupBoxEndScene = new System.Windows.Forms.GroupBox(); + this.MediaPlayerEnd = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); + this.panelControlsEnd = new System.Windows.Forms.Panel(); + this.buttonEndVerify = new System.Windows.Forms.Button(); + this.buttonGotoEndSubtitlePosition = new System.Windows.Forms.Button(); + this.buttonFindTextEnd = new System.Windows.Forms.Button(); + this.buttonThreeSecondsBack = new System.Windows.Forms.Button(); + this.buttonEndHalfASecondBack = new System.Windows.Forms.Button(); + this.comboBoxEndTexts = new System.Windows.Forms.ComboBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.labelVideoInfo = new System.Windows.Forms.Label(); + this.groupBoxMovieInfo = new System.Windows.Forms.GroupBox(); + this.buttonSync = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.labelTip = new System.Windows.Forms.Label(); + this.timerProgressBarRefresh = new System.Windows.Forms.Timer(this.components); + this.labelSyncDone = new System.Windows.Forms.Label(); + this.groupBoxStartScene.SuspendLayout(); + this.panelControlsStart.SuspendLayout(); + this.groupBoxEndScene.SuspendLayout(); + this.panelControlsEnd.SuspendLayout(); + this.groupBoxMovieInfo.SuspendLayout(); + this.SuspendLayout(); + // + // buttonOpenMovie + // + this.buttonOpenMovie.Location = new System.Drawing.Point(12, 12); + this.buttonOpenMovie.Name = "buttonOpenMovie"; + this.buttonOpenMovie.Size = new System.Drawing.Size(100, 23); + this.buttonOpenMovie.TabIndex = 5; + this.buttonOpenMovie.Text = "Open movie..."; + this.buttonOpenMovie.UseVisualStyleBackColor = true; + this.buttonOpenMovie.Click += new System.EventHandler(this.ButtonOpenMovieClick); + // + // timer1 + // + this.timer1.Interval = 50; + this.timer1.Tick += new System.EventHandler(this.Timer1Tick); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.Location = new System.Drawing.Point(754, 490); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // groupBoxStartScene + // + this.groupBoxStartScene.Controls.Add(this.MediaPlayerStart); + this.groupBoxStartScene.Controls.Add(this.panelControlsStart); + this.groupBoxStartScene.Location = new System.Drawing.Point(12, 65); + this.groupBoxStartScene.Name = "groupBoxStartScene"; + this.groupBoxStartScene.Size = new System.Drawing.Size(450, 399); + this.groupBoxStartScene.TabIndex = 0; + this.groupBoxStartScene.TabStop = false; + this.groupBoxStartScene.Text = "Start scene"; + this.groupBoxStartScene.Enter += new System.EventHandler(this.GroupBoxStartSceneEnter); + // + // MediaPlayerStart + // + this.MediaPlayerStart.BackColor = System.Drawing.Color.Black; + this.MediaPlayerStart.CurrentPosition = 0D; + this.MediaPlayerStart.FontSizeFactor = 1F; + this.MediaPlayerStart.LastParagraph = null; + this.MediaPlayerStart.Location = new System.Drawing.Point(6, 34); + this.MediaPlayerStart.Name = "MediaPlayerStart"; + this.MediaPlayerStart.ShowFullscreenButton = true; + this.MediaPlayerStart.ShowMuteButton = true; + this.MediaPlayerStart.ShowStopButton = true; + this.MediaPlayerStart.Size = new System.Drawing.Size(450, 287); + this.MediaPlayerStart.SmpteMode = false; + this.MediaPlayerStart.SubtitleText = ""; + this.MediaPlayerStart.TabIndex = 13; + this.MediaPlayerStart.TextRightToLeft = System.Windows.Forms.RightToLeft.No; + this.MediaPlayerStart.VideoHeight = 0; + this.MediaPlayerStart.VideoPlayer = null; + this.MediaPlayerStart.VideoWidth = 0; + this.MediaPlayerStart.Volume = 0D; + this.MediaPlayerStart.OnButtonClicked += new System.EventHandler(this.MediaPlayerStart_OnButtonClicked); + // + // panelControlsStart + // + this.panelControlsStart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.panelControlsStart.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelControlsStart.Controls.Add(this.buttonStartVerify); + this.panelControlsStart.Controls.Add(this.buttonGotoStartSubtitlePosition); + this.panelControlsStart.Controls.Add(this.buttonFindTextStart); + this.panelControlsStart.Controls.Add(this.buttonStartThreeSecondsBack); + this.panelControlsStart.Controls.Add(this.buttonStartHalfASecondBack); + this.panelControlsStart.Controls.Add(this.comboBoxStartTexts); + this.panelControlsStart.Location = new System.Drawing.Point(6, 327); + this.panelControlsStart.Name = "panelControlsStart"; + this.panelControlsStart.Size = new System.Drawing.Size(438, 68); + this.panelControlsStart.TabIndex = 1; + // + // buttonStartVerify + // + this.buttonStartVerify.Location = new System.Drawing.Point(138, 37); + this.buttonStartVerify.Name = "buttonStartVerify"; + this.buttonStartVerify.Size = new System.Drawing.Size(119, 23); + this.buttonStartVerify.TabIndex = 3; + this.buttonStartVerify.Text = "Play 2 s and back"; + this.buttonStartVerify.UseVisualStyleBackColor = true; + this.buttonStartVerify.Click += new System.EventHandler(this.ButtonStartVerifyClick); + // + // buttonGotoStartSubtitlePosition + // + this.buttonGotoStartSubtitlePosition.Location = new System.Drawing.Point(263, 37); + this.buttonGotoStartSubtitlePosition.Name = "buttonGotoStartSubtitlePosition"; + this.buttonGotoStartSubtitlePosition.Size = new System.Drawing.Size(90, 23); + this.buttonGotoStartSubtitlePosition.TabIndex = 4; + this.buttonGotoStartSubtitlePosition.Text = "Goto sub Position"; + this.buttonGotoStartSubtitlePosition.UseVisualStyleBackColor = true; + this.buttonGotoStartSubtitlePosition.Click += new System.EventHandler(this.ButtonGotoStartSubtitlePositionClick); + // + // buttonFindTextStart + // + this.buttonFindTextStart.Location = new System.Drawing.Point(359, 37); + this.buttonFindTextStart.Name = "buttonFindTextStart"; + this.buttonFindTextStart.Size = new System.Drawing.Size(70, 23); + this.buttonFindTextStart.TabIndex = 5; + this.buttonFindTextStart.Text = "Find text..."; + this.buttonFindTextStart.UseVisualStyleBackColor = true; + this.buttonFindTextStart.Click += new System.EventHandler(this.ButtonFindTextStartClick); + // + // buttonStartThreeSecondsBack + // + this.buttonStartThreeSecondsBack.Location = new System.Drawing.Point(6, 37); + this.buttonStartThreeSecondsBack.Name = "buttonStartThreeSecondsBack"; + this.buttonStartThreeSecondsBack.Size = new System.Drawing.Size(60, 23); + this.buttonStartThreeSecondsBack.TabIndex = 1; + this.buttonStartThreeSecondsBack.Text = "< 3 s"; + this.buttonStartThreeSecondsBack.UseVisualStyleBackColor = true; + this.buttonStartThreeSecondsBack.Click += new System.EventHandler(this.ButtonStartThreeSecondsBackClick); + // + // buttonStartHalfASecondBack + // + this.buttonStartHalfASecondBack.Location = new System.Drawing.Point(72, 37); + this.buttonStartHalfASecondBack.Name = "buttonStartHalfASecondBack"; + this.buttonStartHalfASecondBack.Size = new System.Drawing.Size(60, 23); + this.buttonStartHalfASecondBack.TabIndex = 2; + this.buttonStartHalfASecondBack.Text = "< ½ s"; + this.buttonStartHalfASecondBack.UseVisualStyleBackColor = true; + this.buttonStartHalfASecondBack.Click += new System.EventHandler(this.ButtonStartHalfASecondBackClick); + // + // comboBoxStartTexts + // + this.comboBoxStartTexts.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxStartTexts.FormattingEnabled = true; + this.comboBoxStartTexts.Location = new System.Drawing.Point(7, 10); + this.comboBoxStartTexts.Name = "comboBoxStartTexts"; + this.comboBoxStartTexts.Size = new System.Drawing.Size(422, 21); + this.comboBoxStartTexts.TabIndex = 0; + // + // groupBoxEndScene + // + this.groupBoxEndScene.Controls.Add(this.MediaPlayerEnd); + this.groupBoxEndScene.Controls.Add(this.panelControlsEnd); + this.groupBoxEndScene.Location = new System.Drawing.Point(468, 65); + this.groupBoxEndScene.Name = "groupBoxEndScene"; + this.groupBoxEndScene.Size = new System.Drawing.Size(450, 399); + this.groupBoxEndScene.TabIndex = 1; + this.groupBoxEndScene.TabStop = false; + this.groupBoxEndScene.Text = "End scene"; + this.groupBoxEndScene.Enter += new System.EventHandler(this.GroupBoxEndSceneEnter); + // + // MediaPlayerEnd + // + this.MediaPlayerEnd.BackColor = System.Drawing.Color.Black; + this.MediaPlayerEnd.CurrentPosition = 0D; + this.MediaPlayerEnd.FontSizeFactor = 1F; + this.MediaPlayerEnd.LastParagraph = null; + this.MediaPlayerEnd.Location = new System.Drawing.Point(6, 34); + this.MediaPlayerEnd.Name = "MediaPlayerEnd"; + this.MediaPlayerEnd.ShowFullscreenButton = true; + this.MediaPlayerEnd.ShowMuteButton = true; + this.MediaPlayerEnd.ShowStopButton = true; + this.MediaPlayerEnd.Size = new System.Drawing.Size(438, 287); + this.MediaPlayerEnd.SmpteMode = false; + this.MediaPlayerEnd.SubtitleText = ""; + this.MediaPlayerEnd.TabIndex = 14; + this.MediaPlayerEnd.TextRightToLeft = System.Windows.Forms.RightToLeft.No; + this.MediaPlayerEnd.VideoHeight = 0; + this.MediaPlayerEnd.VideoPlayer = null; + this.MediaPlayerEnd.VideoWidth = 0; + this.MediaPlayerEnd.Volume = 0D; + this.MediaPlayerEnd.OnButtonClicked += new System.EventHandler(this.MediaPlayerEnd_OnButtonClicked); + // + // panelControlsEnd + // + this.panelControlsEnd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.panelControlsEnd.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelControlsEnd.Controls.Add(this.buttonEndVerify); + this.panelControlsEnd.Controls.Add(this.buttonGotoEndSubtitlePosition); + this.panelControlsEnd.Controls.Add(this.buttonFindTextEnd); + this.panelControlsEnd.Controls.Add(this.buttonThreeSecondsBack); + this.panelControlsEnd.Controls.Add(this.buttonEndHalfASecondBack); + this.panelControlsEnd.Controls.Add(this.comboBoxEndTexts); + this.panelControlsEnd.Location = new System.Drawing.Point(7, 327); + this.panelControlsEnd.Name = "panelControlsEnd"; + this.panelControlsEnd.Size = new System.Drawing.Size(438, 68); + this.panelControlsEnd.TabIndex = 1; + // + // buttonEndVerify + // + this.buttonEndVerify.Location = new System.Drawing.Point(139, 37); + this.buttonEndVerify.Name = "buttonEndVerify"; + this.buttonEndVerify.Size = new System.Drawing.Size(118, 23); + this.buttonEndVerify.TabIndex = 3; + this.buttonEndVerify.Text = "Play 2 s and back"; + this.buttonEndVerify.UseVisualStyleBackColor = true; + this.buttonEndVerify.Click += new System.EventHandler(this.ButtonEndVerifyClick); + // + // buttonGotoEndSubtitlePosition + // + this.buttonGotoEndSubtitlePosition.Location = new System.Drawing.Point(263, 37); + this.buttonGotoEndSubtitlePosition.Name = "buttonGotoEndSubtitlePosition"; + this.buttonGotoEndSubtitlePosition.Size = new System.Drawing.Size(90, 23); + this.buttonGotoEndSubtitlePosition.TabIndex = 4; + this.buttonGotoEndSubtitlePosition.Text = "Goto sub Position"; + this.buttonGotoEndSubtitlePosition.UseVisualStyleBackColor = true; + this.buttonGotoEndSubtitlePosition.Click += new System.EventHandler(this.ButtonGotoEndSubtitlePositionClick); + // + // buttonFindTextEnd + // + this.buttonFindTextEnd.Location = new System.Drawing.Point(359, 37); + this.buttonFindTextEnd.Name = "buttonFindTextEnd"; + this.buttonFindTextEnd.Size = new System.Drawing.Size(70, 23); + this.buttonFindTextEnd.TabIndex = 5; + this.buttonFindTextEnd.Text = "Find text..."; + this.buttonFindTextEnd.UseVisualStyleBackColor = true; + this.buttonFindTextEnd.Click += new System.EventHandler(this.ButtonFindTextEndClick); + // + // buttonThreeSecondsBack + // + this.buttonThreeSecondsBack.Location = new System.Drawing.Point(7, 37); + this.buttonThreeSecondsBack.Name = "buttonThreeSecondsBack"; + this.buttonThreeSecondsBack.Size = new System.Drawing.Size(60, 23); + this.buttonThreeSecondsBack.TabIndex = 1; + this.buttonThreeSecondsBack.Text = "< 3 s"; + this.buttonThreeSecondsBack.UseVisualStyleBackColor = true; + this.buttonThreeSecondsBack.Click += new System.EventHandler(this.ButtonThreeSecondsBackClick); + // + // buttonEndHalfASecondBack + // + this.buttonEndHalfASecondBack.Location = new System.Drawing.Point(73, 37); + this.buttonEndHalfASecondBack.Name = "buttonEndHalfASecondBack"; + this.buttonEndHalfASecondBack.Size = new System.Drawing.Size(60, 23); + this.buttonEndHalfASecondBack.TabIndex = 2; + this.buttonEndHalfASecondBack.Text = "< ½ s"; + this.buttonEndHalfASecondBack.UseVisualStyleBackColor = true; + this.buttonEndHalfASecondBack.Click += new System.EventHandler(this.ButtonEndHalfASecondBackClick); + // + // comboBoxEndTexts + // + this.comboBoxEndTexts.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxEndTexts.FormattingEnabled = true; + this.comboBoxEndTexts.Location = new System.Drawing.Point(7, 10); + this.comboBoxEndTexts.Name = "comboBoxEndTexts"; + this.comboBoxEndTexts.Size = new System.Drawing.Size(422, 21); + this.comboBoxEndTexts.TabIndex = 0; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(835, 490); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // labelVideoInfo + // + this.labelVideoInfo.AutoSize = true; + this.labelVideoInfo.Location = new System.Drawing.Point(6, 16); + this.labelVideoInfo.Name = "labelVideoInfo"; + this.labelVideoInfo.Size = new System.Drawing.Size(84, 13); + this.labelVideoInfo.TabIndex = 13; + this.labelVideoInfo.Text = "No video loaded"; + // + // groupBoxMovieInfo + // + this.groupBoxMovieInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxMovieInfo.Controls.Add(this.labelVideoInfo); + this.groupBoxMovieInfo.Location = new System.Drawing.Point(132, 8); + this.groupBoxMovieInfo.Name = "groupBoxMovieInfo"; + this.groupBoxMovieInfo.Size = new System.Drawing.Size(786, 53); + this.groupBoxMovieInfo.TabIndex = 14; + this.groupBoxMovieInfo.TabStop = false; + this.groupBoxMovieInfo.Text = "Movie info"; + // + // buttonSync + // + this.buttonSync.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.buttonSync.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.buttonSync.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.buttonSync.Location = new System.Drawing.Point(395, 488); + this.buttonSync.Name = "buttonSync"; + this.buttonSync.Size = new System.Drawing.Size(148, 31); + this.buttonSync.TabIndex = 2; + this.buttonSync.Text = "Sync!"; + this.buttonSync.UseVisualStyleBackColor = true; + this.buttonSync.Click += new System.EventHandler(this.ButtonSyncClick); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // labelTip + // + this.labelTip.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.labelTip.AutoSize = true; + this.labelTip.ForeColor = System.Drawing.Color.Gray; + this.labelTip.Location = new System.Drawing.Point(12, 473); + this.labelTip.Name = "labelTip"; + this.labelTip.Size = new System.Drawing.Size(332, 13); + this.labelTip.TabIndex = 15; + this.labelTip.Text = "Tip: Use keys to move 100 ms back/forward"; + // + // timerProgressBarRefresh + // + this.timerProgressBarRefresh.Tick += new System.EventHandler(this.timerProgressBarRefresh_Tick); + // + // labelSyncDone + // + this.labelSyncDone.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.labelSyncDone.AutoSize = true; + this.labelSyncDone.ForeColor = System.Drawing.Color.Gray; + this.labelSyncDone.Location = new System.Drawing.Point(546, 502); + this.labelSyncDone.Name = "labelSyncDone"; + this.labelSyncDone.Size = new System.Drawing.Size(77, 13); + this.labelSyncDone.TabIndex = 16; + this.labelSyncDone.Text = "labelSyncDone"; + // + // VisualSync + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(927, 525); + this.Controls.Add(this.labelSyncDone); + this.Controls.Add(this.buttonSync); + this.Controls.Add(this.labelTip); + this.Controls.Add(this.groupBoxMovieInfo); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.groupBoxEndScene); + this.Controls.Add(this.groupBoxStartScene); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonOpenMovie); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.KeyPreview = true; + this.MinimumSize = new System.Drawing.Size(935, 540); + this.Name = "VisualSync"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Visual Sync"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormVisualSync_FormClosing); + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.VisualSync_FormClosed); + this.Load += new System.EventHandler(this.VisualSync_Load); + this.Shown += new System.EventHandler(this.VisualSync_Shown); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VisualSync_KeyDown); + this.Resize += new System.EventHandler(this.FormVisualSync_Resize); + this.groupBoxStartScene.ResumeLayout(false); + this.panelControlsStart.ResumeLayout(false); + this.groupBoxEndScene.ResumeLayout(false); + this.panelControlsEnd.ResumeLayout(false); + this.groupBoxMovieInfo.ResumeLayout(false); + this.groupBoxMovieInfo.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOpenMovie; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.GroupBox groupBoxStartScene; + private System.Windows.Forms.GroupBox groupBoxEndScene; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Panel panelControlsStart; + private System.Windows.Forms.ComboBox comboBoxStartTexts; + private System.Windows.Forms.Button buttonGotoStartSubtitlePosition; + private System.Windows.Forms.Button buttonFindTextStart; + private System.Windows.Forms.Button buttonStartThreeSecondsBack; + private System.Windows.Forms.Button buttonStartHalfASecondBack; + private System.Windows.Forms.Label labelVideoInfo; + private System.Windows.Forms.GroupBox groupBoxMovieInfo; + private System.Windows.Forms.Panel panelControlsEnd; + private System.Windows.Forms.Button buttonGotoEndSubtitlePosition; + private System.Windows.Forms.Button buttonFindTextEnd; + private System.Windows.Forms.Button buttonThreeSecondsBack; + private System.Windows.Forms.Button buttonEndHalfASecondBack; + private System.Windows.Forms.ComboBox comboBoxEndTexts; + private System.Windows.Forms.Button buttonSync; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Button buttonStartVerify; + private System.Windows.Forms.Button buttonEndVerify; + private Nikse.SubtitleEdit.Controls.VideoPlayerContainer MediaPlayerStart; + private Nikse.SubtitleEdit.Controls.VideoPlayerContainer MediaPlayerEnd; + private System.Windows.Forms.Label labelTip; + private System.Windows.Forms.Timer timerProgressBarRefresh; + private System.Windows.Forms.Label labelSyncDone; + } } \ No newline at end of file diff --git a/src/Forms/VisualSync.cs b/src/ui/Forms/VisualSync.cs similarity index 97% rename from src/Forms/VisualSync.cs rename to src/ui/Forms/VisualSync.cs index 8f74bdfad..ec64ac075 100644 --- a/src/Forms/VisualSync.cs +++ b/src/ui/Forms/VisualSync.cs @@ -1,898 +1,898 @@ -using Nikse.SubtitleEdit.Controls; -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Forms.FixCommonErrors; -using Nikse.SubtitleEdit.Logic; -using Nikse.SubtitleEdit.Logic.VideoPlayers; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class VisualSync : PositionAndSizeForm - { - private List _paragraphs; - private List _paragraphsAlternate; - private VideoInfo _videoInfo; - private string _subtitleFileName; - private Subtitle _inputSubtitle; - private Subtitle _inputAlternateSubtitle; - private double _oldFrameRate; - private bool _isStartSceneActive; - private double _startGoBackPosition; - private double _startStopPosition = -1.0; - private double _endGoBackPosition; - private double _endStopPosition = -1.0; - private readonly LanguageStructure.VisualSync _language; - private readonly LanguageStructure.General _languageGeneral; - private readonly Timer _timerHideSyncLabel = new Timer(); - private string _adjustInfo = string.Empty; - - public string VideoFileName { get; set; } - public int AudioTrackNumber { get; set; } - - public bool OkPressed { get; set; } - - public bool FrameRateChanged { get; private set; } - - public double FrameRate => _videoInfo?.FramesPerSecond ?? 0; - - public List Paragraphs => _paragraphs; - - public List ParagraphsAlternate => _paragraphsAlternate; - - public VisualSync() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - openFileDialog1.InitialDirectory = string.Empty; - - MediaPlayerStart.InitializeVolume(Configuration.Settings.General.VideoPlayerDefaultVolume); - MediaPlayerEnd.InitializeVolume(Configuration.Settings.General.VideoPlayerDefaultVolume); - - labelSyncDone.Text = string.Empty; - _language = Configuration.Settings.Language.VisualSync; - _languageGeneral = Configuration.Settings.Language.General; - Text = _language.Title; - buttonOpenMovie.Text = _languageGeneral.OpenVideoFile; - groupBoxMovieInfo.Text = _languageGeneral.VideoInformation; - labelVideoInfo.Text = _languageGeneral.NoVideoLoaded; - groupBoxStartScene.Text = _language.StartScene; - groupBoxEndScene.Text = _language.EndScene; - buttonStartThreeSecondsBack.Text = _language.ThreeSecondsBack; - buttonThreeSecondsBack.Text = _language.ThreeSecondsBack; - buttonStartHalfASecondBack.Text = _language.HalfASecondBack; - buttonEndHalfASecondBack.Text = _language.HalfASecondBack; - buttonStartVerify.Text = string.Format(_language.PlayXSecondsAndBack, Configuration.Settings.Tools.VerifyPlaySeconds); - buttonEndVerify.Text = buttonStartVerify.Text; - buttonGotoStartSubtitlePosition.Text = _language.GoToSubPosition; - buttonGotoEndSubtitlePosition.Text = _language.GoToSubPosition; - buttonFindTextStart.Text = _language.FindText; - buttonFindTextEnd.Text = _language.FindText; - buttonSync.Text = _language.Synchronize; - buttonOK.Text = _languageGeneral.Ok; - buttonCancel.Text = _languageGeneral.Cancel; - labelTip.Text = _language.Tip; - UiUtil.FixLargeFonts(this, buttonCancel); - _timerHideSyncLabel.Tick += timerHideSyncLabel_Tick; - _timerHideSyncLabel.Interval = 1000; - } - - private void timerHideSyncLabel_Tick(object sender, EventArgs e) - { - labelSyncDone.Text = _adjustInfo; - } - - private void GotoSubtitlePosition(VideoPlayerContainer mediaPlayer) - { - int index; - if (mediaPlayer == MediaPlayerStart) - { - index = comboBoxStartTexts.SelectedIndex; - } - else - { - index = comboBoxEndTexts.SelectedIndex; - } - - mediaPlayer.Pause(); - if (index != -1) - { - double indexPositionInSeconds = _paragraphs[index].StartTime.TotalMilliseconds / TimeCode.BaseUnit; - - if (indexPositionInSeconds > mediaPlayer.Duration) - { - indexPositionInSeconds = mediaPlayer.Duration - (2 * 60); - } - - if (indexPositionInSeconds < 0) - { - indexPositionInSeconds = 0; - } - - mediaPlayer.CurrentPosition = indexPositionInSeconds; - mediaPlayer.RefreshProgressBar(); - } - } - - private void OpenVideo(string fileName) - { - if (File.Exists(fileName)) - { - timer1.Stop(); - timerProgressBarRefresh.Stop(); - - VideoFileName = fileName; - - var fi = new FileInfo(fileName); - if (fi.Length < 1000) - { - return; - } - - if (MediaPlayerStart.VideoPlayer != null) - { - MediaPlayerStart.Pause(); - MediaPlayerStart.VideoPlayer.DisposeVideoPlayer(); - } - if (MediaPlayerEnd.VideoPlayer != null) - { - MediaPlayerEnd.Pause(); - MediaPlayerEnd.VideoPlayer.DisposeVideoPlayer(); - } - - VideoInfo videoInfo = ShowVideoInfo(fileName); - UiUtil.InitializeVideoPlayerAndContainer(fileName, videoInfo, MediaPlayerStart, VideoStartLoaded, VideoStartEnded); - } - } - - private void VideoStartEnded(object sender, EventArgs e) - { - MediaPlayerStart.Pause(); - } - - private void VideoStartLoaded(object sender, EventArgs e) - { - MediaPlayerStart.Pause(); - GotoSubtitlePosition(MediaPlayerStart); - - _startGoBackPosition = MediaPlayerStart.CurrentPosition; - _startStopPosition = _startGoBackPosition + 0.1; - MediaPlayerStart.Play(); - - if (MediaPlayerStart.VideoPlayer.GetType() == typeof(LibVlcDynamic)) - { - MediaPlayerEnd.VideoPlayer = (MediaPlayerStart.VideoPlayer as LibVlcDynamic).MakeSecondMediaPlayer(MediaPlayerEnd.PanelPlayer, VideoFileName, VideoEndLoaded, VideoEndEnded); - } - else - { - UiUtil.InitializeVideoPlayerAndContainer(VideoFileName, _videoInfo, MediaPlayerEnd, VideoEndLoaded, VideoEndEnded); - } - timer1.Start(); - timerProgressBarRefresh.Start(); - - if (AudioTrackNumber >= 0 && MediaPlayerStart.VideoPlayer is LibVlcDynamic) - { - var libVlc = (LibVlcDynamic)MediaPlayerStart.VideoPlayer; - libVlc.AudioTrackNumber = AudioTrackNumber; - } - else if (AudioTrackNumber >= 0 && MediaPlayerStart.VideoPlayer is LibMpvDynamic) - { - var libMpv = (LibMpvDynamic)MediaPlayerStart.VideoPlayer; - libMpv.AudioTrackNumber = AudioTrackNumber; - } - } - - private void VideoEndEnded(object sender, EventArgs e) - { - MediaPlayerEnd.Pause(); - } - - private void VideoEndLoaded(object sender, EventArgs e) - { - MediaPlayerEnd.Pause(); - GotoSubtitlePosition(MediaPlayerEnd); - - _endGoBackPosition = MediaPlayerEnd.CurrentPosition; - _endStopPosition = _endGoBackPosition + 0.1; - MediaPlayerEnd.Play(); - - if (AudioTrackNumber >= 0 && MediaPlayerEnd.VideoPlayer is LibVlcDynamic) - { - var libVlc = (LibVlcDynamic)MediaPlayerEnd.VideoPlayer; - libVlc.AudioTrackNumber = AudioTrackNumber; - } - else if (AudioTrackNumber >= 0 && MediaPlayerEnd.VideoPlayer is LibMpvDynamic) - { - var libMpv = (LibMpvDynamic)MediaPlayerEnd.VideoPlayer; - libMpv.AudioTrackNumber = AudioTrackNumber; - } - } - - private VideoInfo ShowVideoInfo(string fileName) - { - _videoInfo = UiUtil.GetVideoInfo(fileName); - var info = new FileInfo(fileName); - long fileSizeInBytes = info.Length; - - labelVideoInfo.Text = string.Format(_languageGeneral.FileNameXAndSize, fileName, Utilities.FormatBytesToDisplayFileSize(fileSizeInBytes)) + Environment.NewLine + - string.Format(_languageGeneral.ResolutionX, +_videoInfo.Width + "x" + _videoInfo.Height) + " "; - if (_videoInfo.FramesPerSecond > 5 && _videoInfo.FramesPerSecond < 200) - { - labelVideoInfo.Text += string.Format(_languageGeneral.FrameRateX + " ", _videoInfo.FramesPerSecond); - } - - if (_videoInfo.TotalFrames > 10) - { - labelVideoInfo.Text += string.Format(_languageGeneral.TotalFramesX + " ", (int)_videoInfo.TotalFrames); - } - - if (!string.IsNullOrEmpty(_videoInfo.VideoCodec)) - { - labelVideoInfo.Text += string.Format(_languageGeneral.VideoEncodingX, _videoInfo.VideoCodec) + " "; - } - - return _videoInfo; - } - - private void Timer1Tick(object sender, EventArgs e) - { - if (MediaPlayerStart != null) - { - if (!MediaPlayerStart.IsPaused) - { - MediaPlayerStart.RefreshProgressBar(); - if (_startStopPosition >= 0 && MediaPlayerStart.CurrentPosition > _startStopPosition) - { - MediaPlayerStart.Pause(); - MediaPlayerStart.CurrentPosition = _startGoBackPosition; - _startStopPosition = -1; - } - UiUtil.ShowSubtitle(new Subtitle(_paragraphs), MediaPlayerStart); - } - if (!MediaPlayerEnd.IsPaused) - { - MediaPlayerEnd.RefreshProgressBar(); - if (_endStopPosition >= 0 && MediaPlayerEnd.CurrentPosition > _endStopPosition) - { - MediaPlayerEnd.Pause(); - MediaPlayerEnd.CurrentPosition = _endGoBackPosition; - _endStopPosition = -1; - } - UiUtil.ShowSubtitle(new Subtitle(_paragraphs), MediaPlayerEnd); - } - } - } - - private void FormVisualSync_FormClosing(object sender, FormClosingEventArgs e) - { - _timerHideSyncLabel.Stop(); - labelSyncDone.Text = string.Empty; - timer1.Stop(); - timerProgressBarRefresh.Stop(); - MediaPlayerStart?.Pause(); - MediaPlayerEnd?.Pause(); - - bool change = false; - for (int i = 0; i < _paragraphs.Count; i++) - { - if (_paragraphs[i].ToString() != _inputSubtitle.Paragraphs[i].ToString()) - { - change = true; - break; - } - } - - if (!change) - { - DialogResult = DialogResult.Cancel; - return; - } - - DialogResult dr; - if (DialogResult == DialogResult.OK) - { - dr = DialogResult.Yes; - } - else - { - dr = MessageBox.Show(_language.KeepChangesMessage, _language.KeepChangesTitle, MessageBoxButtons.YesNoCancel); - } - - if (dr == DialogResult.Cancel) - { - e.Cancel = true; - timer1.Start(); - timerProgressBarRefresh.Start(); - } - else if (dr == DialogResult.Yes) - { - DialogResult = DialogResult.OK; - } - else - { - DialogResult = DialogResult.Cancel; - } - } - - internal void Initialize(Bitmap bitmap, Subtitle subtitle, Subtitle alternate, string fileName, string title, double frameRate) - { - if (bitmap != null) - { - IntPtr iconHandle = bitmap.GetHicon(); - Icon = Icon.FromHandle(iconHandle); - } - - _inputSubtitle = subtitle; - _inputAlternateSubtitle = alternate; - _oldFrameRate = frameRate; - _subtitleFileName = fileName; - Text = title; - } - - private void LoadAndShowOriginalSubtitle() - { - _paragraphs = new List(); - foreach (Paragraph p in _inputSubtitle.Paragraphs) - { - _paragraphs.Add(new Paragraph(p)); - } - - if (_inputAlternateSubtitle != null) - { - _paragraphsAlternate = new List(); - foreach (Paragraph p in _inputAlternateSubtitle.Paragraphs) - { - _paragraphsAlternate.Add(new Paragraph(p)); - } - } - - FillStartAndEndTexts(); - - if (comboBoxStartTexts.Items.Count > Configuration.Settings.Tools.StartSceneIndex) - { - comboBoxStartTexts.SelectedIndex = Configuration.Settings.Tools.StartSceneIndex; - } - else - { - comboBoxStartTexts.SelectedIndex = 0; - } - - if (comboBoxEndTexts.Items.Count > Configuration.Settings.Tools.EndSceneIndex) - { - comboBoxEndTexts.SelectedIndex = comboBoxEndTexts.Items.Count - (Configuration.Settings.Tools.EndSceneIndex + 1); - } - else - { - comboBoxEndTexts.SelectedIndex = comboBoxEndTexts.Items.Count - 1; - } - } - - private void FillStartAndEndTexts() - { - comboBoxStartTexts.BeginUpdate(); - comboBoxEndTexts.BeginUpdate(); - comboBoxStartTexts.Items.Clear(); - comboBoxEndTexts.Items.Clear(); - foreach (Paragraph p in _paragraphs) - { - string s = p.StartTime + " - " + UiUtil.GetListViewTextFromString(p.Text); - comboBoxStartTexts.Items.Add(s); - comboBoxEndTexts.Items.Add(s); - } - comboBoxStartTexts.EndUpdate(); - comboBoxEndTexts.EndUpdate(); - } - - private void TryToFindAndOpenMovieFile(string fileNameNoExtension) - { - string movieFileName = null; - - foreach (string extension in Utilities.VideoFileExtensions) - { - movieFileName = fileNameNoExtension + extension; - if (File.Exists(movieFileName)) - { - break; - } - } - - if (movieFileName != null && File.Exists(movieFileName)) - { - OpenVideo(movieFileName); - } - else if (fileNameNoExtension.Contains('.')) - { - fileNameNoExtension = fileNameNoExtension.Substring(0, fileNameNoExtension.LastIndexOf('.')); - TryToFindAndOpenMovieFile(fileNameNoExtension); - } - } - - private void ButtonGotoStartSubtitlePositionClick(object sender, EventArgs e) - { - GotoSubtitlePosition(MediaPlayerStart); - } - - private void ButtonGotoEndSubtitlePositionClick(object sender, EventArgs e) - { - GotoSubtitlePosition(MediaPlayerEnd); - } - - private void ButtonSyncClick(object sender, EventArgs e) - { - // Video player current start and end position. - double videoPlayerCurrentStartPos = MediaPlayerStart.CurrentPosition; - double videoPlayerCurrentEndPos = MediaPlayerEnd.CurrentPosition; - - // Subtitle start and end time in seconds. - double subStart = _paragraphs[comboBoxStartTexts.SelectedIndex].StartTime.TotalMilliseconds / TimeCode.BaseUnit; - double subEnd = _paragraphs[comboBoxEndTexts.SelectedIndex].StartTime.TotalMilliseconds / TimeCode.BaseUnit; - - // Both end times must be greater than start time. - if (!(videoPlayerCurrentEndPos > videoPlayerCurrentStartPos && subEnd > videoPlayerCurrentStartPos)) - { - MessageBox.Show(_language.StartSceneMustComeBeforeEndScene, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - return; - } - - SetSyncFactorLabel(videoPlayerCurrentStartPos, videoPlayerCurrentEndPos); - - double subDiff = subEnd - subStart; - double realDiff = videoPlayerCurrentEndPos - videoPlayerCurrentStartPos; - - // speed factor - double factor = realDiff / subDiff; - - // adjust to starting position - double adjust = videoPlayerCurrentStartPos - subStart * factor; - - foreach (Paragraph p in _paragraphs) - { - p.Adjust(factor, adjust); - } - if (_inputAlternateSubtitle != null) - { - foreach (Paragraph p in _paragraphsAlternate) - { - p.Adjust(factor, adjust); - } - } - - // fix overlapping time codes - var tmpSubtitle = new Subtitle(); - foreach (Paragraph p in _paragraphs) - { - tmpSubtitle.Paragraphs.Add(new Paragraph(p)); - } - - new FixOverlappingDisplayTimes().Fix(tmpSubtitle, new EmptyFixCallback()); - _paragraphs = tmpSubtitle.Paragraphs; - - // fix overlapping time codes for alternate subtitle (translation) - if (_inputAlternateSubtitle != null) - { - tmpSubtitle = new Subtitle(); - foreach (Paragraph p in _paragraphsAlternate) - { - tmpSubtitle.Paragraphs.Add(new Paragraph(p)); - } - - new FixOverlappingDisplayTimes().Fix(tmpSubtitle, new EmptyFixCallback()); - _paragraphsAlternate = tmpSubtitle.Paragraphs; - } - - // update comboboxes - int startSaveIdx = comboBoxStartTexts.SelectedIndex; - int endSaveIdx = comboBoxEndTexts.SelectedIndex; - FillStartAndEndTexts(); - comboBoxStartTexts.SelectedIndex = startSaveIdx; - comboBoxEndTexts.SelectedIndex = endSaveIdx; - - labelSyncDone.Text = _language.SynchronizationDone; - _timerHideSyncLabel.Start(); - } - - private void GoBackSeconds(double seconds, VideoPlayerContainer mediaPlayer) - { - if (mediaPlayer.CurrentPosition > seconds) - { - mediaPlayer.CurrentPosition -= seconds; - } - else - { - mediaPlayer.CurrentPosition = 0; - } - - UiUtil.ShowSubtitle(new Subtitle(_paragraphs), mediaPlayer); - } - - private void ButtonStartHalfASecondBackClick(object sender, EventArgs e) - { - GoBackSeconds(0.5, MediaPlayerStart); - } - - private void ButtonStartThreeSecondsBackClick(object sender, EventArgs e) - { - GoBackSeconds(3.0, MediaPlayerStart); - } - - private void ButtonEndHalfASecondBackClick(object sender, EventArgs e) - { - GoBackSeconds(0.5, MediaPlayerEnd); - } - - private void ButtonThreeSecondsBackClick(object sender, EventArgs e) - { - GoBackSeconds(3.0, MediaPlayerEnd); - } - - private void ButtonOpenMovieClick(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(openFileDialog1.InitialDirectory) && !string.IsNullOrEmpty(_subtitleFileName)) - { - openFileDialog1.InitialDirectory = Path.GetDirectoryName(_subtitleFileName); - } - - openFileDialog1.Title = _languageGeneral.OpenVideoFileTitle; - openFileDialog1.FileName = string.Empty; - openFileDialog1.Filter = Utilities.GetVideoFileFilter(true); - openFileDialog1.FileName = string.Empty; - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - AudioTrackNumber = -1; - openFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName); - OpenVideo(openFileDialog1.FileName); - } - } - - private void SizeWmp() - { - MediaPlayerStart.Height = panelControlsStart.Top - (MediaPlayerStart.Top + 2); - MediaPlayerEnd.Height = MediaPlayerStart.Height; - MediaPlayerEnd.RefreshProgressBar(); - } - - private void FormVisualSync_Resize(object sender, EventArgs e) - { - int halfWidth = Width / 2; - groupBoxStartScene.Width = halfWidth - 18; - MediaPlayerStart.Width = groupBoxStartScene.Width - 12; - panelControlsStart.Width = MediaPlayerStart.Width; - groupBoxEndScene.Left = halfWidth + 3; - groupBoxEndScene.Width = halfWidth - 18; - MediaPlayerEnd.Width = groupBoxEndScene.Width - 12; - SizeWmp(); - panelControlsEnd.Width = MediaPlayerEnd.Width; - groupBoxStartScene.Height = Height - groupBoxEndScene.Top - 90; - groupBoxEndScene.Height = Height - groupBoxEndScene.Top - 90; - SizeWmp(); - } - - private void ButtonFindTextStartClick(object sender, EventArgs e) - { - using (var findSubtitle = new FindSubtitleLine()) - { - findSubtitle.Initialize(_paragraphs, " " + "(" + _language.StartScene.ToLowerInvariant() + ")"); - findSubtitle.ShowDialog(); - if (findSubtitle.SelectedIndex >= 0) - { - comboBoxStartTexts.SelectedIndex = findSubtitle.SelectedIndex; - } - } - } - - private void ButtonFindTextEndClick(object sender, EventArgs e) - { - using (var findSubtitle = new FindSubtitleLine()) - { - findSubtitle.Initialize(_paragraphs, " " + "(" + _language.EndScene.ToLowerInvariant() + ")"); - findSubtitle.ShowDialog(); - if (findSubtitle.SelectedIndex >= 0) - { - comboBoxEndTexts.SelectedIndex = findSubtitle.SelectedIndex; - } - } - } - - private void HighlightStartScene() - { - _isStartSceneActive = true; - panelControlsStart.BorderStyle = BorderStyle.FixedSingle; - panelControlsEnd.BorderStyle = BorderStyle.None; - } - - private void HighlightEndScene() - { - _isStartSceneActive = false; - panelControlsEnd.BorderStyle = BorderStyle.FixedSingle; - panelControlsStart.BorderStyle = BorderStyle.None; - } - - private void GroupBoxStartSceneEnter(object sender, EventArgs e) - { - HighlightStartScene(); - } - - private void GroupBoxEndSceneEnter(object sender, EventArgs e) - { - HighlightEndScene(); - } - - private void VisualSync_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - else if (e.KeyCode == UiUtil.HelpKeys) - { - Utilities.ShowHelp("#visual_sync"); - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.O) - { - ButtonOpenMovieClick(null, null); - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.F) - { - if (_isStartSceneActive) - { - ButtonFindTextStartClick(null, null); - } - else - { - ButtonFindTextEndClick(null, null); - } - } - else if (MediaPlayerStart != null && MediaPlayerEnd != null) - { - if (e.Modifiers == Keys.Control && e.KeyCode == Keys.S) - { - if (_isStartSceneActive) - { - _startStopPosition = -1; - if (!MediaPlayerStart.IsPaused) - { - MediaPlayerStart.Pause(); - } - } - else - { - _endStopPosition = -1; - if (!MediaPlayerEnd.IsPaused) - { - MediaPlayerEnd.Pause(); - } - } - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.P) - { - if (_isStartSceneActive) - { - _startStopPosition = -1; - MediaPlayerStart.TogglePlayPause(); - } - else - { - _endStopPosition = -1; - MediaPlayerStart.TogglePlayPause(); - } - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Left) - { - if (_isStartSceneActive) - { - GoBackSeconds(0.5, MediaPlayerStart); - } - else - { - GoBackSeconds(0.5, MediaPlayerEnd); - } - - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Right) - { - if (_isStartSceneActive) - { - GoBackSeconds(-0.5, MediaPlayerStart); - } - else - { - GoBackSeconds(-0.5, MediaPlayerEnd); - } - - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Left) - { - if (_isStartSceneActive) - { - GoBackSeconds(0.1, MediaPlayerStart); - } - else - { - GoBackSeconds(0.1, MediaPlayerEnd); - } - - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Right) - { - if (_isStartSceneActive) - { - GoBackSeconds(-0.1, MediaPlayerStart); - } - else - { - GoBackSeconds(-0.1, MediaPlayerEnd); - } - - e.SuppressKeyPress = true; - } - else if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.Right) - { - if (_isStartSceneActive) - { - GoBackSeconds(1.0, MediaPlayerStart); - } - else - { - GoBackSeconds(1.0, MediaPlayerEnd); - } - - e.SuppressKeyPress = true; - } - else if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.Left) - { - if (_isStartSceneActive) - { - GoBackSeconds(-1.0, MediaPlayerStart); - } - else - { - GoBackSeconds(-1.0, MediaPlayerEnd); - } - - e.SuppressKeyPress = true; - } - else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Space) - { - if (_isStartSceneActive) - { - MediaPlayerStart.TogglePlayPause(); - } - else - { - MediaPlayerEnd.TogglePlayPause(); - } - - e.SuppressKeyPress = true; - } - } - } - - private void VisualSync_Shown(object sender, EventArgs e) - { - comboBoxStartTexts.Focus(); - } - - private void ButtonStartVerifyClick(object sender, EventArgs e) - { - if (MediaPlayerStart != null && MediaPlayerStart.VideoPlayer != null) - { - _startGoBackPosition = MediaPlayerStart.CurrentPosition; - _startStopPosition = _startGoBackPosition + Configuration.Settings.Tools.VerifyPlaySeconds; - MediaPlayerStart.Play(); - } - } - - private void ButtonEndVerifyClick(object sender, EventArgs e) - { - if (MediaPlayerEnd != null && MediaPlayerEnd.VideoPlayer != null) - { - _endGoBackPosition = MediaPlayerEnd.CurrentPosition; - _endStopPosition = _endGoBackPosition + Configuration.Settings.Tools.VerifyPlaySeconds; - MediaPlayerEnd.Play(); - } - } - - private void VisualSync_Load(object sender, EventArgs e) - { - LoadAndShowOriginalSubtitle(); - if (!string.IsNullOrEmpty(VideoFileName) && File.Exists(VideoFileName)) - { - OpenVideo(VideoFileName); - } - else if (!string.IsNullOrEmpty(_subtitleFileName)) - { - TryToFindAndOpenMovieFile(Path.GetDirectoryName(_subtitleFileName) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(_subtitleFileName)); - } - - FormVisualSync_Resize(null, null); - } - - private void MediaPlayerStart_OnButtonClicked(object sender, EventArgs e) - { - if (!_isStartSceneActive) - { - HighlightStartScene(); - } - } - - private void MediaPlayerEnd_OnButtonClicked(object sender, EventArgs e) - { - if (_isStartSceneActive) - { - HighlightEndScene(); - } - } - - private void VisualSync_FormClosed(object sender, FormClosedEventArgs e) - { - if (MediaPlayerStart.VideoPlayer != null) // && MediaPlayerStart.VideoPlayer.GetType() == typeof(QuartsPlayer)) - { - MediaPlayerStart.VideoPlayer.Pause(); - MediaPlayerStart.VideoPlayer.DisposeVideoPlayer(); - } - if (MediaPlayerEnd.VideoPlayer != null) // && MediaPlayerEnd.VideoPlayer.GetType() == typeof(QuartsPlayer)) - { - MediaPlayerEnd.VideoPlayer.Pause(); - MediaPlayerEnd.VideoPlayer.DisposeVideoPlayer(); - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - OkPressed = true; - } - - private void timerProgressBarRefresh_Tick(object sender, EventArgs e) - { - timerProgressBarRefresh.Stop(); - if (MediaPlayerStart.VideoPlayer != null) // && MediaPlayerStart.VideoPlayer.GetType() == typeof(QuartsPlayer)) - { - MediaPlayerStart.RefreshProgressBar(); - } - if (MediaPlayerEnd.VideoPlayer != null) // && MediaPlayerEnd.VideoPlayer.GetType() == typeof(QuartsPlayer)) - { - MediaPlayerEnd.RefreshProgressBar(); - } - timerProgressBarRefresh.Start(); - } - - private void SetSyncFactorLabel(double videoPlayerCurrentStartPos, double videoPlayerCurrentEndPos) - { - if (string.IsNullOrWhiteSpace(VideoFileName)) - { - return; - } - - _adjustInfo = string.Empty; - if (videoPlayerCurrentEndPos > videoPlayerCurrentStartPos) - { - double subStart = _paragraphs[comboBoxStartTexts.SelectedIndex].StartTime.TotalMilliseconds / TimeCode.BaseUnit; - double subEnd = _paragraphs[comboBoxEndTexts.SelectedIndex].StartTime.TotalMilliseconds / TimeCode.BaseUnit; - - double subDiff = subEnd - subStart; - double realDiff = videoPlayerCurrentEndPos - videoPlayerCurrentStartPos; - - // speed factor - double factor = realDiff / subDiff; - - // adjust to starting position - double adjust = videoPlayerCurrentStartPos - subStart * factor; - - if (Math.Abs(adjust) > 0.001 || (Math.Abs(1 - factor)) > 0.001) - { - _adjustInfo = string.Format("*{0:0.000}, {1:+0.000;-0.000}", factor, adjust); - } - } - } - - } -} +using Nikse.SubtitleEdit.Controls; +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Forms.FixCommonErrors; +using Nikse.SubtitleEdit.Logic; +using Nikse.SubtitleEdit.Logic.VideoPlayers; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class VisualSync : PositionAndSizeForm + { + private List _paragraphs; + private List _paragraphsAlternate; + private VideoInfo _videoInfo; + private string _subtitleFileName; + private Subtitle _inputSubtitle; + private Subtitle _inputAlternateSubtitle; + private double _oldFrameRate; + private bool _isStartSceneActive; + private double _startGoBackPosition; + private double _startStopPosition = -1.0; + private double _endGoBackPosition; + private double _endStopPosition = -1.0; + private readonly LanguageStructure.VisualSync _language; + private readonly LanguageStructure.General _languageGeneral; + private readonly Timer _timerHideSyncLabel = new Timer(); + private string _adjustInfo = string.Empty; + + public string VideoFileName { get; set; } + public int AudioTrackNumber { get; set; } + + public bool OkPressed { get; set; } + + public bool FrameRateChanged { get; private set; } + + public double FrameRate => _videoInfo?.FramesPerSecond ?? 0; + + public List Paragraphs => _paragraphs; + + public List ParagraphsAlternate => _paragraphsAlternate; + + public VisualSync() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + openFileDialog1.InitialDirectory = string.Empty; + + MediaPlayerStart.InitializeVolume(Configuration.Settings.General.VideoPlayerDefaultVolume); + MediaPlayerEnd.InitializeVolume(Configuration.Settings.General.VideoPlayerDefaultVolume); + + labelSyncDone.Text = string.Empty; + _language = Configuration.Settings.Language.VisualSync; + _languageGeneral = Configuration.Settings.Language.General; + Text = _language.Title; + buttonOpenMovie.Text = _languageGeneral.OpenVideoFile; + groupBoxMovieInfo.Text = _languageGeneral.VideoInformation; + labelVideoInfo.Text = _languageGeneral.NoVideoLoaded; + groupBoxStartScene.Text = _language.StartScene; + groupBoxEndScene.Text = _language.EndScene; + buttonStartThreeSecondsBack.Text = _language.ThreeSecondsBack; + buttonThreeSecondsBack.Text = _language.ThreeSecondsBack; + buttonStartHalfASecondBack.Text = _language.HalfASecondBack; + buttonEndHalfASecondBack.Text = _language.HalfASecondBack; + buttonStartVerify.Text = string.Format(_language.PlayXSecondsAndBack, Configuration.Settings.Tools.VerifyPlaySeconds); + buttonEndVerify.Text = buttonStartVerify.Text; + buttonGotoStartSubtitlePosition.Text = _language.GoToSubPosition; + buttonGotoEndSubtitlePosition.Text = _language.GoToSubPosition; + buttonFindTextStart.Text = _language.FindText; + buttonFindTextEnd.Text = _language.FindText; + buttonSync.Text = _language.Synchronize; + buttonOK.Text = _languageGeneral.Ok; + buttonCancel.Text = _languageGeneral.Cancel; + labelTip.Text = _language.Tip; + UiUtil.FixLargeFonts(this, buttonCancel); + _timerHideSyncLabel.Tick += timerHideSyncLabel_Tick; + _timerHideSyncLabel.Interval = 1000; + } + + private void timerHideSyncLabel_Tick(object sender, EventArgs e) + { + labelSyncDone.Text = _adjustInfo; + } + + private void GotoSubtitlePosition(VideoPlayerContainer mediaPlayer) + { + int index; + if (mediaPlayer == MediaPlayerStart) + { + index = comboBoxStartTexts.SelectedIndex; + } + else + { + index = comboBoxEndTexts.SelectedIndex; + } + + mediaPlayer.Pause(); + if (index != -1) + { + double indexPositionInSeconds = _paragraphs[index].StartTime.TotalMilliseconds / TimeCode.BaseUnit; + + if (indexPositionInSeconds > mediaPlayer.Duration) + { + indexPositionInSeconds = mediaPlayer.Duration - (2 * 60); + } + + if (indexPositionInSeconds < 0) + { + indexPositionInSeconds = 0; + } + + mediaPlayer.CurrentPosition = indexPositionInSeconds; + mediaPlayer.RefreshProgressBar(); + } + } + + private void OpenVideo(string fileName) + { + if (File.Exists(fileName)) + { + timer1.Stop(); + timerProgressBarRefresh.Stop(); + + VideoFileName = fileName; + + var fi = new FileInfo(fileName); + if (fi.Length < 1000) + { + return; + } + + if (MediaPlayerStart.VideoPlayer != null) + { + MediaPlayerStart.Pause(); + MediaPlayerStart.VideoPlayer.DisposeVideoPlayer(); + } + if (MediaPlayerEnd.VideoPlayer != null) + { + MediaPlayerEnd.Pause(); + MediaPlayerEnd.VideoPlayer.DisposeVideoPlayer(); + } + + VideoInfo videoInfo = ShowVideoInfo(fileName); + UiUtil.InitializeVideoPlayerAndContainer(fileName, videoInfo, MediaPlayerStart, VideoStartLoaded, VideoStartEnded); + } + } + + private void VideoStartEnded(object sender, EventArgs e) + { + MediaPlayerStart.Pause(); + } + + private void VideoStartLoaded(object sender, EventArgs e) + { + MediaPlayerStart.Pause(); + GotoSubtitlePosition(MediaPlayerStart); + + _startGoBackPosition = MediaPlayerStart.CurrentPosition; + _startStopPosition = _startGoBackPosition + 0.1; + MediaPlayerStart.Play(); + + if (MediaPlayerStart.VideoPlayer.GetType() == typeof(LibVlcDynamic)) + { + MediaPlayerEnd.VideoPlayer = (MediaPlayerStart.VideoPlayer as LibVlcDynamic).MakeSecondMediaPlayer(MediaPlayerEnd.PanelPlayer, VideoFileName, VideoEndLoaded, VideoEndEnded); + } + else + { + UiUtil.InitializeVideoPlayerAndContainer(VideoFileName, _videoInfo, MediaPlayerEnd, VideoEndLoaded, VideoEndEnded); + } + timer1.Start(); + timerProgressBarRefresh.Start(); + + if (AudioTrackNumber >= 0 && MediaPlayerStart.VideoPlayer is LibVlcDynamic) + { + var libVlc = (LibVlcDynamic)MediaPlayerStart.VideoPlayer; + libVlc.AudioTrackNumber = AudioTrackNumber; + } + else if (AudioTrackNumber >= 0 && MediaPlayerStart.VideoPlayer is LibMpvDynamic) + { + var libMpv = (LibMpvDynamic)MediaPlayerStart.VideoPlayer; + libMpv.AudioTrackNumber = AudioTrackNumber; + } + } + + private void VideoEndEnded(object sender, EventArgs e) + { + MediaPlayerEnd.Pause(); + } + + private void VideoEndLoaded(object sender, EventArgs e) + { + MediaPlayerEnd.Pause(); + GotoSubtitlePosition(MediaPlayerEnd); + + _endGoBackPosition = MediaPlayerEnd.CurrentPosition; + _endStopPosition = _endGoBackPosition + 0.1; + MediaPlayerEnd.Play(); + + if (AudioTrackNumber >= 0 && MediaPlayerEnd.VideoPlayer is LibVlcDynamic) + { + var libVlc = (LibVlcDynamic)MediaPlayerEnd.VideoPlayer; + libVlc.AudioTrackNumber = AudioTrackNumber; + } + else if (AudioTrackNumber >= 0 && MediaPlayerEnd.VideoPlayer is LibMpvDynamic) + { + var libMpv = (LibMpvDynamic)MediaPlayerEnd.VideoPlayer; + libMpv.AudioTrackNumber = AudioTrackNumber; + } + } + + private VideoInfo ShowVideoInfo(string fileName) + { + _videoInfo = UiUtil.GetVideoInfo(fileName); + var info = new FileInfo(fileName); + long fileSizeInBytes = info.Length; + + labelVideoInfo.Text = string.Format(_languageGeneral.FileNameXAndSize, fileName, Utilities.FormatBytesToDisplayFileSize(fileSizeInBytes)) + Environment.NewLine + + string.Format(_languageGeneral.ResolutionX, +_videoInfo.Width + "x" + _videoInfo.Height) + " "; + if (_videoInfo.FramesPerSecond > 5 && _videoInfo.FramesPerSecond < 200) + { + labelVideoInfo.Text += string.Format(_languageGeneral.FrameRateX + " ", _videoInfo.FramesPerSecond); + } + + if (_videoInfo.TotalFrames > 10) + { + labelVideoInfo.Text += string.Format(_languageGeneral.TotalFramesX + " ", (int)_videoInfo.TotalFrames); + } + + if (!string.IsNullOrEmpty(_videoInfo.VideoCodec)) + { + labelVideoInfo.Text += string.Format(_languageGeneral.VideoEncodingX, _videoInfo.VideoCodec) + " "; + } + + return _videoInfo; + } + + private void Timer1Tick(object sender, EventArgs e) + { + if (MediaPlayerStart != null) + { + if (!MediaPlayerStart.IsPaused) + { + MediaPlayerStart.RefreshProgressBar(); + if (_startStopPosition >= 0 && MediaPlayerStart.CurrentPosition > _startStopPosition) + { + MediaPlayerStart.Pause(); + MediaPlayerStart.CurrentPosition = _startGoBackPosition; + _startStopPosition = -1; + } + UiUtil.ShowSubtitle(new Subtitle(_paragraphs), MediaPlayerStart); + } + if (!MediaPlayerEnd.IsPaused) + { + MediaPlayerEnd.RefreshProgressBar(); + if (_endStopPosition >= 0 && MediaPlayerEnd.CurrentPosition > _endStopPosition) + { + MediaPlayerEnd.Pause(); + MediaPlayerEnd.CurrentPosition = _endGoBackPosition; + _endStopPosition = -1; + } + UiUtil.ShowSubtitle(new Subtitle(_paragraphs), MediaPlayerEnd); + } + } + } + + private void FormVisualSync_FormClosing(object sender, FormClosingEventArgs e) + { + _timerHideSyncLabel.Stop(); + labelSyncDone.Text = string.Empty; + timer1.Stop(); + timerProgressBarRefresh.Stop(); + MediaPlayerStart?.Pause(); + MediaPlayerEnd?.Pause(); + + bool change = false; + for (int i = 0; i < _paragraphs.Count; i++) + { + if (_paragraphs[i].ToString() != _inputSubtitle.Paragraphs[i].ToString()) + { + change = true; + break; + } + } + + if (!change) + { + DialogResult = DialogResult.Cancel; + return; + } + + DialogResult dr; + if (DialogResult == DialogResult.OK) + { + dr = DialogResult.Yes; + } + else + { + dr = MessageBox.Show(_language.KeepChangesMessage, _language.KeepChangesTitle, MessageBoxButtons.YesNoCancel); + } + + if (dr == DialogResult.Cancel) + { + e.Cancel = true; + timer1.Start(); + timerProgressBarRefresh.Start(); + } + else if (dr == DialogResult.Yes) + { + DialogResult = DialogResult.OK; + } + else + { + DialogResult = DialogResult.Cancel; + } + } + + internal void Initialize(Bitmap bitmap, Subtitle subtitle, Subtitle alternate, string fileName, string title, double frameRate) + { + if (bitmap != null) + { + IntPtr iconHandle = bitmap.GetHicon(); + Icon = Icon.FromHandle(iconHandle); + } + + _inputSubtitle = subtitle; + _inputAlternateSubtitle = alternate; + _oldFrameRate = frameRate; + _subtitleFileName = fileName; + Text = title; + } + + private void LoadAndShowOriginalSubtitle() + { + _paragraphs = new List(); + foreach (Paragraph p in _inputSubtitle.Paragraphs) + { + _paragraphs.Add(new Paragraph(p)); + } + + if (_inputAlternateSubtitle != null) + { + _paragraphsAlternate = new List(); + foreach (Paragraph p in _inputAlternateSubtitle.Paragraphs) + { + _paragraphsAlternate.Add(new Paragraph(p)); + } + } + + FillStartAndEndTexts(); + + if (comboBoxStartTexts.Items.Count > Configuration.Settings.Tools.StartSceneIndex) + { + comboBoxStartTexts.SelectedIndex = Configuration.Settings.Tools.StartSceneIndex; + } + else + { + comboBoxStartTexts.SelectedIndex = 0; + } + + if (comboBoxEndTexts.Items.Count > Configuration.Settings.Tools.EndSceneIndex) + { + comboBoxEndTexts.SelectedIndex = comboBoxEndTexts.Items.Count - (Configuration.Settings.Tools.EndSceneIndex + 1); + } + else + { + comboBoxEndTexts.SelectedIndex = comboBoxEndTexts.Items.Count - 1; + } + } + + private void FillStartAndEndTexts() + { + comboBoxStartTexts.BeginUpdate(); + comboBoxEndTexts.BeginUpdate(); + comboBoxStartTexts.Items.Clear(); + comboBoxEndTexts.Items.Clear(); + foreach (Paragraph p in _paragraphs) + { + string s = p.StartTime + " - " + UiUtil.GetListViewTextFromString(p.Text); + comboBoxStartTexts.Items.Add(s); + comboBoxEndTexts.Items.Add(s); + } + comboBoxStartTexts.EndUpdate(); + comboBoxEndTexts.EndUpdate(); + } + + private void TryToFindAndOpenMovieFile(string fileNameNoExtension) + { + string movieFileName = null; + + foreach (string extension in Utilities.VideoFileExtensions) + { + movieFileName = fileNameNoExtension + extension; + if (File.Exists(movieFileName)) + { + break; + } + } + + if (movieFileName != null && File.Exists(movieFileName)) + { + OpenVideo(movieFileName); + } + else if (fileNameNoExtension.Contains('.')) + { + fileNameNoExtension = fileNameNoExtension.Substring(0, fileNameNoExtension.LastIndexOf('.')); + TryToFindAndOpenMovieFile(fileNameNoExtension); + } + } + + private void ButtonGotoStartSubtitlePositionClick(object sender, EventArgs e) + { + GotoSubtitlePosition(MediaPlayerStart); + } + + private void ButtonGotoEndSubtitlePositionClick(object sender, EventArgs e) + { + GotoSubtitlePosition(MediaPlayerEnd); + } + + private void ButtonSyncClick(object sender, EventArgs e) + { + // Video player current start and end position. + double videoPlayerCurrentStartPos = MediaPlayerStart.CurrentPosition; + double videoPlayerCurrentEndPos = MediaPlayerEnd.CurrentPosition; + + // Subtitle start and end time in seconds. + double subStart = _paragraphs[comboBoxStartTexts.SelectedIndex].StartTime.TotalMilliseconds / TimeCode.BaseUnit; + double subEnd = _paragraphs[comboBoxEndTexts.SelectedIndex].StartTime.TotalMilliseconds / TimeCode.BaseUnit; + + // Both end times must be greater than start time. + if (!(videoPlayerCurrentEndPos > videoPlayerCurrentStartPos && subEnd > videoPlayerCurrentStartPos)) + { + MessageBox.Show(_language.StartSceneMustComeBeforeEndScene, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + SetSyncFactorLabel(videoPlayerCurrentStartPos, videoPlayerCurrentEndPos); + + double subDiff = subEnd - subStart; + double realDiff = videoPlayerCurrentEndPos - videoPlayerCurrentStartPos; + + // speed factor + double factor = realDiff / subDiff; + + // adjust to starting position + double adjust = videoPlayerCurrentStartPos - subStart * factor; + + foreach (Paragraph p in _paragraphs) + { + p.Adjust(factor, adjust); + } + if (_inputAlternateSubtitle != null) + { + foreach (Paragraph p in _paragraphsAlternate) + { + p.Adjust(factor, adjust); + } + } + + // fix overlapping time codes + var tmpSubtitle = new Subtitle(); + foreach (Paragraph p in _paragraphs) + { + tmpSubtitle.Paragraphs.Add(new Paragraph(p)); + } + + new FixOverlappingDisplayTimes().Fix(tmpSubtitle, new EmptyFixCallback()); + _paragraphs = tmpSubtitle.Paragraphs; + + // fix overlapping time codes for alternate subtitle (translation) + if (_inputAlternateSubtitle != null) + { + tmpSubtitle = new Subtitle(); + foreach (Paragraph p in _paragraphsAlternate) + { + tmpSubtitle.Paragraphs.Add(new Paragraph(p)); + } + + new FixOverlappingDisplayTimes().Fix(tmpSubtitle, new EmptyFixCallback()); + _paragraphsAlternate = tmpSubtitle.Paragraphs; + } + + // update comboboxes + int startSaveIdx = comboBoxStartTexts.SelectedIndex; + int endSaveIdx = comboBoxEndTexts.SelectedIndex; + FillStartAndEndTexts(); + comboBoxStartTexts.SelectedIndex = startSaveIdx; + comboBoxEndTexts.SelectedIndex = endSaveIdx; + + labelSyncDone.Text = _language.SynchronizationDone; + _timerHideSyncLabel.Start(); + } + + private void GoBackSeconds(double seconds, VideoPlayerContainer mediaPlayer) + { + if (mediaPlayer.CurrentPosition > seconds) + { + mediaPlayer.CurrentPosition -= seconds; + } + else + { + mediaPlayer.CurrentPosition = 0; + } + + UiUtil.ShowSubtitle(new Subtitle(_paragraphs), mediaPlayer); + } + + private void ButtonStartHalfASecondBackClick(object sender, EventArgs e) + { + GoBackSeconds(0.5, MediaPlayerStart); + } + + private void ButtonStartThreeSecondsBackClick(object sender, EventArgs e) + { + GoBackSeconds(3.0, MediaPlayerStart); + } + + private void ButtonEndHalfASecondBackClick(object sender, EventArgs e) + { + GoBackSeconds(0.5, MediaPlayerEnd); + } + + private void ButtonThreeSecondsBackClick(object sender, EventArgs e) + { + GoBackSeconds(3.0, MediaPlayerEnd); + } + + private void ButtonOpenMovieClick(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(openFileDialog1.InitialDirectory) && !string.IsNullOrEmpty(_subtitleFileName)) + { + openFileDialog1.InitialDirectory = Path.GetDirectoryName(_subtitleFileName); + } + + openFileDialog1.Title = _languageGeneral.OpenVideoFileTitle; + openFileDialog1.FileName = string.Empty; + openFileDialog1.Filter = Utilities.GetVideoFileFilter(true); + openFileDialog1.FileName = string.Empty; + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + AudioTrackNumber = -1; + openFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName); + OpenVideo(openFileDialog1.FileName); + } + } + + private void SizeWmp() + { + MediaPlayerStart.Height = panelControlsStart.Top - (MediaPlayerStart.Top + 2); + MediaPlayerEnd.Height = MediaPlayerStart.Height; + MediaPlayerEnd.RefreshProgressBar(); + } + + private void FormVisualSync_Resize(object sender, EventArgs e) + { + int halfWidth = Width / 2; + groupBoxStartScene.Width = halfWidth - 18; + MediaPlayerStart.Width = groupBoxStartScene.Width - 12; + panelControlsStart.Width = MediaPlayerStart.Width; + groupBoxEndScene.Left = halfWidth + 3; + groupBoxEndScene.Width = halfWidth - 18; + MediaPlayerEnd.Width = groupBoxEndScene.Width - 12; + SizeWmp(); + panelControlsEnd.Width = MediaPlayerEnd.Width; + groupBoxStartScene.Height = Height - groupBoxEndScene.Top - 90; + groupBoxEndScene.Height = Height - groupBoxEndScene.Top - 90; + SizeWmp(); + } + + private void ButtonFindTextStartClick(object sender, EventArgs e) + { + using (var findSubtitle = new FindSubtitleLine()) + { + findSubtitle.Initialize(_paragraphs, " " + "(" + _language.StartScene.ToLowerInvariant() + ")"); + findSubtitle.ShowDialog(); + if (findSubtitle.SelectedIndex >= 0) + { + comboBoxStartTexts.SelectedIndex = findSubtitle.SelectedIndex; + } + } + } + + private void ButtonFindTextEndClick(object sender, EventArgs e) + { + using (var findSubtitle = new FindSubtitleLine()) + { + findSubtitle.Initialize(_paragraphs, " " + "(" + _language.EndScene.ToLowerInvariant() + ")"); + findSubtitle.ShowDialog(); + if (findSubtitle.SelectedIndex >= 0) + { + comboBoxEndTexts.SelectedIndex = findSubtitle.SelectedIndex; + } + } + } + + private void HighlightStartScene() + { + _isStartSceneActive = true; + panelControlsStart.BorderStyle = BorderStyle.FixedSingle; + panelControlsEnd.BorderStyle = BorderStyle.None; + } + + private void HighlightEndScene() + { + _isStartSceneActive = false; + panelControlsEnd.BorderStyle = BorderStyle.FixedSingle; + panelControlsStart.BorderStyle = BorderStyle.None; + } + + private void GroupBoxStartSceneEnter(object sender, EventArgs e) + { + HighlightStartScene(); + } + + private void GroupBoxEndSceneEnter(object sender, EventArgs e) + { + HighlightEndScene(); + } + + private void VisualSync_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == UiUtil.HelpKeys) + { + Utilities.ShowHelp("#visual_sync"); + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.O) + { + ButtonOpenMovieClick(null, null); + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.F) + { + if (_isStartSceneActive) + { + ButtonFindTextStartClick(null, null); + } + else + { + ButtonFindTextEndClick(null, null); + } + } + else if (MediaPlayerStart != null && MediaPlayerEnd != null) + { + if (e.Modifiers == Keys.Control && e.KeyCode == Keys.S) + { + if (_isStartSceneActive) + { + _startStopPosition = -1; + if (!MediaPlayerStart.IsPaused) + { + MediaPlayerStart.Pause(); + } + } + else + { + _endStopPosition = -1; + if (!MediaPlayerEnd.IsPaused) + { + MediaPlayerEnd.Pause(); + } + } + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.P) + { + if (_isStartSceneActive) + { + _startStopPosition = -1; + MediaPlayerStart.TogglePlayPause(); + } + else + { + _endStopPosition = -1; + MediaPlayerStart.TogglePlayPause(); + } + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Left) + { + if (_isStartSceneActive) + { + GoBackSeconds(0.5, MediaPlayerStart); + } + else + { + GoBackSeconds(0.5, MediaPlayerEnd); + } + + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Right) + { + if (_isStartSceneActive) + { + GoBackSeconds(-0.5, MediaPlayerStart); + } + else + { + GoBackSeconds(-0.5, MediaPlayerEnd); + } + + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Left) + { + if (_isStartSceneActive) + { + GoBackSeconds(0.1, MediaPlayerStart); + } + else + { + GoBackSeconds(0.1, MediaPlayerEnd); + } + + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Right) + { + if (_isStartSceneActive) + { + GoBackSeconds(-0.1, MediaPlayerStart); + } + else + { + GoBackSeconds(-0.1, MediaPlayerEnd); + } + + e.SuppressKeyPress = true; + } + else if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.Right) + { + if (_isStartSceneActive) + { + GoBackSeconds(1.0, MediaPlayerStart); + } + else + { + GoBackSeconds(1.0, MediaPlayerEnd); + } + + e.SuppressKeyPress = true; + } + else if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.Left) + { + if (_isStartSceneActive) + { + GoBackSeconds(-1.0, MediaPlayerStart); + } + else + { + GoBackSeconds(-1.0, MediaPlayerEnd); + } + + e.SuppressKeyPress = true; + } + else if (e.Modifiers == Keys.None && e.KeyCode == Keys.Space) + { + if (_isStartSceneActive) + { + MediaPlayerStart.TogglePlayPause(); + } + else + { + MediaPlayerEnd.TogglePlayPause(); + } + + e.SuppressKeyPress = true; + } + } + } + + private void VisualSync_Shown(object sender, EventArgs e) + { + comboBoxStartTexts.Focus(); + } + + private void ButtonStartVerifyClick(object sender, EventArgs e) + { + if (MediaPlayerStart != null && MediaPlayerStart.VideoPlayer != null) + { + _startGoBackPosition = MediaPlayerStart.CurrentPosition; + _startStopPosition = _startGoBackPosition + Configuration.Settings.Tools.VerifyPlaySeconds; + MediaPlayerStart.Play(); + } + } + + private void ButtonEndVerifyClick(object sender, EventArgs e) + { + if (MediaPlayerEnd != null && MediaPlayerEnd.VideoPlayer != null) + { + _endGoBackPosition = MediaPlayerEnd.CurrentPosition; + _endStopPosition = _endGoBackPosition + Configuration.Settings.Tools.VerifyPlaySeconds; + MediaPlayerEnd.Play(); + } + } + + private void VisualSync_Load(object sender, EventArgs e) + { + LoadAndShowOriginalSubtitle(); + if (!string.IsNullOrEmpty(VideoFileName) && File.Exists(VideoFileName)) + { + OpenVideo(VideoFileName); + } + else if (!string.IsNullOrEmpty(_subtitleFileName)) + { + TryToFindAndOpenMovieFile(Path.GetDirectoryName(_subtitleFileName) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(_subtitleFileName)); + } + + FormVisualSync_Resize(null, null); + } + + private void MediaPlayerStart_OnButtonClicked(object sender, EventArgs e) + { + if (!_isStartSceneActive) + { + HighlightStartScene(); + } + } + + private void MediaPlayerEnd_OnButtonClicked(object sender, EventArgs e) + { + if (_isStartSceneActive) + { + HighlightEndScene(); + } + } + + private void VisualSync_FormClosed(object sender, FormClosedEventArgs e) + { + if (MediaPlayerStart.VideoPlayer != null) // && MediaPlayerStart.VideoPlayer.GetType() == typeof(QuartsPlayer)) + { + MediaPlayerStart.VideoPlayer.Pause(); + MediaPlayerStart.VideoPlayer.DisposeVideoPlayer(); + } + if (MediaPlayerEnd.VideoPlayer != null) // && MediaPlayerEnd.VideoPlayer.GetType() == typeof(QuartsPlayer)) + { + MediaPlayerEnd.VideoPlayer.Pause(); + MediaPlayerEnd.VideoPlayer.DisposeVideoPlayer(); + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + OkPressed = true; + } + + private void timerProgressBarRefresh_Tick(object sender, EventArgs e) + { + timerProgressBarRefresh.Stop(); + if (MediaPlayerStart.VideoPlayer != null) // && MediaPlayerStart.VideoPlayer.GetType() == typeof(QuartsPlayer)) + { + MediaPlayerStart.RefreshProgressBar(); + } + if (MediaPlayerEnd.VideoPlayer != null) // && MediaPlayerEnd.VideoPlayer.GetType() == typeof(QuartsPlayer)) + { + MediaPlayerEnd.RefreshProgressBar(); + } + timerProgressBarRefresh.Start(); + } + + private void SetSyncFactorLabel(double videoPlayerCurrentStartPos, double videoPlayerCurrentEndPos) + { + if (string.IsNullOrWhiteSpace(VideoFileName)) + { + return; + } + + _adjustInfo = string.Empty; + if (videoPlayerCurrentEndPos > videoPlayerCurrentStartPos) + { + double subStart = _paragraphs[comboBoxStartTexts.SelectedIndex].StartTime.TotalMilliseconds / TimeCode.BaseUnit; + double subEnd = _paragraphs[comboBoxEndTexts.SelectedIndex].StartTime.TotalMilliseconds / TimeCode.BaseUnit; + + double subDiff = subEnd - subStart; + double realDiff = videoPlayerCurrentEndPos - videoPlayerCurrentStartPos; + + // speed factor + double factor = realDiff / subDiff; + + // adjust to starting position + double adjust = videoPlayerCurrentStartPos - subStart * factor; + + if (Math.Abs(adjust) > 0.001 || (Math.Abs(1 - factor)) > 0.001) + { + _adjustInfo = string.Format("*{0:0.000}, {1:+0.000;-0.000}", factor, adjust); + } + } + } + + } +} diff --git a/src/Forms/VisualSync.resx b/src/ui/Forms/VisualSync.resx similarity index 98% rename from src/Forms/VisualSync.resx rename to src/ui/Forms/VisualSync.resx index 085cb3321..4405cc98f 100644 --- a/src/Forms/VisualSync.resx +++ b/src/ui/Forms/VisualSync.resx @@ -1,129 +1,129 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 100, 17 - - - 327, 17 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 100, 17 + + + 327, 17 + \ No newline at end of file diff --git a/src/Forms/Watermark.Designer.cs b/src/ui/Forms/Watermark.Designer.cs similarity index 97% rename from src/Forms/Watermark.Designer.cs rename to src/ui/Forms/Watermark.Designer.cs index 1f33b8eb7..d7ad25312 100644 --- a/src/Forms/Watermark.Designer.cs +++ b/src/ui/Forms/Watermark.Designer.cs @@ -1,160 +1,160 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class Watermark - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.labelWatermark = new System.Windows.Forms.Label(); - this.groupBoxGenerate = new System.Windows.Forms.GroupBox(); - this.textBoxWatermark = new System.Windows.Forms.TextBox(); - this.radioButtonSpread = new System.Windows.Forms.RadioButton(); - this.radioButtonCurrentLine = new System.Windows.Forms.RadioButton(); - this.buttonGenerate = new System.Windows.Forms.Button(); - this.buttonRemove = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxGenerate.SuspendLayout(); - this.SuspendLayout(); - // - // labelWatermark - // - this.labelWatermark.AutoSize = true; - this.labelWatermark.Location = new System.Drawing.Point(4, 19); - this.labelWatermark.Name = "labelWatermark"; - this.labelWatermark.Size = new System.Drawing.Size(62, 13); - this.labelWatermark.TabIndex = 0; - this.labelWatermark.Text = "Watermark:"; - // - // groupBoxGenerate - // - this.groupBoxGenerate.Controls.Add(this.textBoxWatermark); - this.groupBoxGenerate.Controls.Add(this.radioButtonSpread); - this.groupBoxGenerate.Controls.Add(this.radioButtonCurrentLine); - this.groupBoxGenerate.Controls.Add(this.buttonGenerate); - this.groupBoxGenerate.Location = new System.Drawing.Point(7, 69); - this.groupBoxGenerate.Name = "groupBoxGenerate"; - this.groupBoxGenerate.Size = new System.Drawing.Size(344, 100); - this.groupBoxGenerate.TabIndex = 1; - this.groupBoxGenerate.TabStop = false; - this.groupBoxGenerate.Text = "Generate watermark"; - // - // textBoxWatermark - // - this.textBoxWatermark.Location = new System.Drawing.Point(87, 68); - this.textBoxWatermark.MaxLength = 50; - this.textBoxWatermark.Name = "textBoxWatermark"; - this.textBoxWatermark.Size = new System.Drawing.Size(195, 20); - this.textBoxWatermark.TabIndex = 1; - // - // radioButtonSpread - // - this.radioButtonSpread.AutoSize = true; - this.radioButtonSpread.Checked = true; - this.radioButtonSpread.Location = new System.Drawing.Point(6, 19); - this.radioButtonSpread.Name = "radioButtonSpread"; - this.radioButtonSpread.Size = new System.Drawing.Size(148, 17); - this.radioButtonSpread.TabIndex = 2; - this.radioButtonSpread.TabStop = true; - this.radioButtonSpread.Text = "Spread over entire subtitle"; - this.radioButtonSpread.UseVisualStyleBackColor = true; - // - // radioButtonCurrentLine - // - this.radioButtonCurrentLine.AutoSize = true; - this.radioButtonCurrentLine.Location = new System.Drawing.Point(6, 42); - this.radioButtonCurrentLine.Name = "radioButtonCurrentLine"; - this.radioButtonCurrentLine.Size = new System.Drawing.Size(119, 17); - this.radioButtonCurrentLine.TabIndex = 1; - this.radioButtonCurrentLine.Text = "Only on current line:"; - this.radioButtonCurrentLine.UseVisualStyleBackColor = true; - // - // buttonGenerate - // - this.buttonGenerate.Location = new System.Drawing.Point(6, 65); - this.buttonGenerate.Name = "buttonGenerate"; - this.buttonGenerate.Size = new System.Drawing.Size(75, 23); - this.buttonGenerate.TabIndex = 0; - this.buttonGenerate.Text = "Generate"; - this.buttonGenerate.UseVisualStyleBackColor = true; - this.buttonGenerate.Click += new System.EventHandler(this.buttonGenerate_Click); - // - // buttonRemove - // - this.buttonRemove.Location = new System.Drawing.Point(7, 38); - this.buttonRemove.Name = "buttonRemove"; - this.buttonRemove.Size = new System.Drawing.Size(75, 23); - this.buttonRemove.TabIndex = 0; - this.buttonRemove.Text = "Remove"; - this.buttonRemove.UseVisualStyleBackColor = true; - this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click); - // - // buttonOK - // - this.buttonOK.Location = new System.Drawing.Point(276, 175); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 1; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // Watermark - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(356, 202); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonRemove); - this.Controls.Add(this.groupBoxGenerate); - this.Controls.Add(this.labelWatermark); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "Watermark"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Watermark"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Watermark_KeyDown); - this.groupBoxGenerate.ResumeLayout(false); - this.groupBoxGenerate.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label labelWatermark; - private System.Windows.Forms.GroupBox groupBoxGenerate; - private System.Windows.Forms.RadioButton radioButtonSpread; - private System.Windows.Forms.RadioButton radioButtonCurrentLine; - private System.Windows.Forms.Button buttonGenerate; - private System.Windows.Forms.Button buttonRemove; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.TextBox textBoxWatermark; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class Watermark + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.labelWatermark = new System.Windows.Forms.Label(); + this.groupBoxGenerate = new System.Windows.Forms.GroupBox(); + this.textBoxWatermark = new System.Windows.Forms.TextBox(); + this.radioButtonSpread = new System.Windows.Forms.RadioButton(); + this.radioButtonCurrentLine = new System.Windows.Forms.RadioButton(); + this.buttonGenerate = new System.Windows.Forms.Button(); + this.buttonRemove = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxGenerate.SuspendLayout(); + this.SuspendLayout(); + // + // labelWatermark + // + this.labelWatermark.AutoSize = true; + this.labelWatermark.Location = new System.Drawing.Point(4, 19); + this.labelWatermark.Name = "labelWatermark"; + this.labelWatermark.Size = new System.Drawing.Size(62, 13); + this.labelWatermark.TabIndex = 0; + this.labelWatermark.Text = "Watermark:"; + // + // groupBoxGenerate + // + this.groupBoxGenerate.Controls.Add(this.textBoxWatermark); + this.groupBoxGenerate.Controls.Add(this.radioButtonSpread); + this.groupBoxGenerate.Controls.Add(this.radioButtonCurrentLine); + this.groupBoxGenerate.Controls.Add(this.buttonGenerate); + this.groupBoxGenerate.Location = new System.Drawing.Point(7, 69); + this.groupBoxGenerate.Name = "groupBoxGenerate"; + this.groupBoxGenerate.Size = new System.Drawing.Size(344, 100); + this.groupBoxGenerate.TabIndex = 1; + this.groupBoxGenerate.TabStop = false; + this.groupBoxGenerate.Text = "Generate watermark"; + // + // textBoxWatermark + // + this.textBoxWatermark.Location = new System.Drawing.Point(87, 68); + this.textBoxWatermark.MaxLength = 50; + this.textBoxWatermark.Name = "textBoxWatermark"; + this.textBoxWatermark.Size = new System.Drawing.Size(195, 20); + this.textBoxWatermark.TabIndex = 1; + // + // radioButtonSpread + // + this.radioButtonSpread.AutoSize = true; + this.radioButtonSpread.Checked = true; + this.radioButtonSpread.Location = new System.Drawing.Point(6, 19); + this.radioButtonSpread.Name = "radioButtonSpread"; + this.radioButtonSpread.Size = new System.Drawing.Size(148, 17); + this.radioButtonSpread.TabIndex = 2; + this.radioButtonSpread.TabStop = true; + this.radioButtonSpread.Text = "Spread over entire subtitle"; + this.radioButtonSpread.UseVisualStyleBackColor = true; + // + // radioButtonCurrentLine + // + this.radioButtonCurrentLine.AutoSize = true; + this.radioButtonCurrentLine.Location = new System.Drawing.Point(6, 42); + this.radioButtonCurrentLine.Name = "radioButtonCurrentLine"; + this.radioButtonCurrentLine.Size = new System.Drawing.Size(119, 17); + this.radioButtonCurrentLine.TabIndex = 1; + this.radioButtonCurrentLine.Text = "Only on current line:"; + this.radioButtonCurrentLine.UseVisualStyleBackColor = true; + // + // buttonGenerate + // + this.buttonGenerate.Location = new System.Drawing.Point(6, 65); + this.buttonGenerate.Name = "buttonGenerate"; + this.buttonGenerate.Size = new System.Drawing.Size(75, 23); + this.buttonGenerate.TabIndex = 0; + this.buttonGenerate.Text = "Generate"; + this.buttonGenerate.UseVisualStyleBackColor = true; + this.buttonGenerate.Click += new System.EventHandler(this.buttonGenerate_Click); + // + // buttonRemove + // + this.buttonRemove.Location = new System.Drawing.Point(7, 38); + this.buttonRemove.Name = "buttonRemove"; + this.buttonRemove.Size = new System.Drawing.Size(75, 23); + this.buttonRemove.TabIndex = 0; + this.buttonRemove.Text = "Remove"; + this.buttonRemove.UseVisualStyleBackColor = true; + this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click); + // + // buttonOK + // + this.buttonOK.Location = new System.Drawing.Point(276, 175); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 1; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // Watermark + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(356, 202); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonRemove); + this.Controls.Add(this.groupBoxGenerate); + this.Controls.Add(this.labelWatermark); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Watermark"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Watermark"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Watermark_KeyDown); + this.groupBoxGenerate.ResumeLayout(false); + this.groupBoxGenerate.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelWatermark; + private System.Windows.Forms.GroupBox groupBoxGenerate; + private System.Windows.Forms.RadioButton radioButtonSpread; + private System.Windows.Forms.RadioButton radioButtonCurrentLine; + private System.Windows.Forms.Button buttonGenerate; + private System.Windows.Forms.Button buttonRemove; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.TextBox textBoxWatermark; + } } \ No newline at end of file diff --git a/src/Forms/Watermark.cs b/src/ui/Forms/Watermark.cs similarity index 96% rename from src/Forms/Watermark.cs rename to src/ui/Forms/Watermark.cs index af43475d4..d5b16f41f 100644 --- a/src/Forms/Watermark.cs +++ b/src/ui/Forms/Watermark.cs @@ -1,233 +1,233 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class Watermark : Form - { - private const char ZeroWidthSpace = '\u200B'; - private const char ZeroWidthNoBreakSpace = '\uFEFF'; - - private readonly LanguageStructure.Watermark _language; - - private int _firstSelectedIndex; - - public Watermark() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - _language = Configuration.Settings.Language.Watermark; - Text = _language.Title; - groupBoxGenerate.Text = _language.GenerateWatermarkTitle; - radioButtonSpread.Text = _language.SpreadOverEntireSubtitle; - buttonGenerate.Text = _language.Generate; - buttonRemove.Text = _language.Remove; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - - UiUtil.FixLargeFonts(this, buttonOK); - } - - internal void Initialize(Subtitle subtitle, int firstSelectedIndex) - { - var watermark = ReadWaterMark(subtitle.GetAllTexts().Trim()); - labelWatermark.Text = string.Format(_language.WatermarkX, watermark); - if (watermark.Length == 0) - { - buttonRemove.Enabled = false; - textBoxWatermark.Focus(); - } - else - { - groupBoxGenerate.Enabled = false; - buttonOK.Focus(); - } - - _firstSelectedIndex = firstSelectedIndex; - var current = subtitle.GetParagraphOrDefault(_firstSelectedIndex); - if (current != null) - { - radioButtonCurrentLine.Text = string.Format(_language.CurrentLineOnlyX, UiUtil.GetListViewTextFromString(current.Text)); - } - else - { - radioButtonCurrentLine.Text = string.Format(_language.CurrentLineOnlyX, string.Empty); - radioButtonCurrentLine.Enabled = false; - } - } - - private static string ReadWaterMark(string input) - { - if (!input.Contains(ZeroWidthSpace)) - { - return string.Empty; - } - - int i = 0; - var sb = new StringBuilder(); - bool letterOn = false; - int letter = 0; - while (i < input.Length) - { - var c = input[i]; - if (c == ZeroWidthSpace) - { - if (letter > 0) - { - sb.Append(Encoding.ASCII.GetString(new[] { (byte)letter })); - } - - letterOn = true; - letter = 0; - } - else if (c == ZeroWidthNoBreakSpace && letterOn) - { - letter++; - } - else - { - if (letter > 0) - { - sb.Append(Encoding.ASCII.GetString(new[] { (byte)letter })); - } - - letterOn = false; - letter = 0; - } - i++; - } - return sb.ToString(); - } - - private void AddWaterMark(Subtitle subtitle, string input) - { - if (subtitle == null || subtitle.Paragraphs.Count == 0) - { - return; - } - - byte[] buffer = Encoding.ASCII.GetBytes(input); - - if (radioButtonCurrentLine.Checked) - { - StringBuilder sb = new StringBuilder(); - foreach (byte b in buffer) - { - sb.Append(ZeroWidthSpace); - for (int i = 0; i < b; i++) - { - sb.Append(ZeroWidthNoBreakSpace); - } - } - Paragraph p = subtitle.GetParagraphOrDefault(_firstSelectedIndex); - if (p != null) - { - if (p.Text.Length > 1) - { - p.Text = p.Text.Insert(p.Text.Length / 2, sb.ToString()); - } - else - { - p.Text = sb + p.Text; - } - } - } - else - { - Random r = new Random(); - List indices = new List(); - foreach (byte b in buffer) - { - int number = r.Next(subtitle.Paragraphs.Count - 1); - if (indices.Contains(number)) - { - number = r.Next(subtitle.Paragraphs.Count - 1); - } - - if (indices.Contains(number)) - { - number = r.Next(subtitle.Paragraphs.Count - 1); - } - - indices.Add(number); - } - - indices.Sort(); - int j = 0; - foreach (byte b in buffer) - { - StringBuilder sb = new StringBuilder(); - Paragraph p = subtitle.Paragraphs[indices[j]]; - sb.Append(ZeroWidthSpace); - for (int i = 0; i < b; i++) - { - sb.Append(ZeroWidthNoBreakSpace); - } - - if (p.Text.Length > 1) - { - p.Text = p.Text.Insert(p.Text.Length / 2, sb.ToString()); - } - else - { - p.Text = sb + p.Text; - } - - j++; - } - } - } - - private void buttonOK_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - internal void AddOrRemove(Subtitle subtitle) - { - if (groupBoxGenerate.Enabled) - { - AddWaterMark(subtitle, textBoxWatermark.Text); - } - else - { - RemoveWaterMark(subtitle); - } - } - - private static void RemoveWaterMark(Subtitle subtitle) - { - var zws = ZeroWidthSpace.ToString(CultureInfo.InvariantCulture); - var zwnbs = ZeroWidthNoBreakSpace.ToString(CultureInfo.InvariantCulture); - foreach (Paragraph p in subtitle.Paragraphs) - { - p.Text = p.Text.Replace(zws, string.Empty).Replace(zwnbs, string.Empty); - } - } - - private void buttonGenerate_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void buttonRemove_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - } - - private void Watermark_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class Watermark : Form + { + private const char ZeroWidthSpace = '\u200B'; + private const char ZeroWidthNoBreakSpace = '\uFEFF'; + + private readonly LanguageStructure.Watermark _language; + + private int _firstSelectedIndex; + + public Watermark() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + _language = Configuration.Settings.Language.Watermark; + Text = _language.Title; + groupBoxGenerate.Text = _language.GenerateWatermarkTitle; + radioButtonSpread.Text = _language.SpreadOverEntireSubtitle; + buttonGenerate.Text = _language.Generate; + buttonRemove.Text = _language.Remove; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + + UiUtil.FixLargeFonts(this, buttonOK); + } + + internal void Initialize(Subtitle subtitle, int firstSelectedIndex) + { + var watermark = ReadWaterMark(subtitle.GetAllTexts().Trim()); + labelWatermark.Text = string.Format(_language.WatermarkX, watermark); + if (watermark.Length == 0) + { + buttonRemove.Enabled = false; + textBoxWatermark.Focus(); + } + else + { + groupBoxGenerate.Enabled = false; + buttonOK.Focus(); + } + + _firstSelectedIndex = firstSelectedIndex; + var current = subtitle.GetParagraphOrDefault(_firstSelectedIndex); + if (current != null) + { + radioButtonCurrentLine.Text = string.Format(_language.CurrentLineOnlyX, UiUtil.GetListViewTextFromString(current.Text)); + } + else + { + radioButtonCurrentLine.Text = string.Format(_language.CurrentLineOnlyX, string.Empty); + radioButtonCurrentLine.Enabled = false; + } + } + + private static string ReadWaterMark(string input) + { + if (!input.Contains(ZeroWidthSpace)) + { + return string.Empty; + } + + int i = 0; + var sb = new StringBuilder(); + bool letterOn = false; + int letter = 0; + while (i < input.Length) + { + var c = input[i]; + if (c == ZeroWidthSpace) + { + if (letter > 0) + { + sb.Append(Encoding.ASCII.GetString(new[] { (byte)letter })); + } + + letterOn = true; + letter = 0; + } + else if (c == ZeroWidthNoBreakSpace && letterOn) + { + letter++; + } + else + { + if (letter > 0) + { + sb.Append(Encoding.ASCII.GetString(new[] { (byte)letter })); + } + + letterOn = false; + letter = 0; + } + i++; + } + return sb.ToString(); + } + + private void AddWaterMark(Subtitle subtitle, string input) + { + if (subtitle == null || subtitle.Paragraphs.Count == 0) + { + return; + } + + byte[] buffer = Encoding.ASCII.GetBytes(input); + + if (radioButtonCurrentLine.Checked) + { + StringBuilder sb = new StringBuilder(); + foreach (byte b in buffer) + { + sb.Append(ZeroWidthSpace); + for (int i = 0; i < b; i++) + { + sb.Append(ZeroWidthNoBreakSpace); + } + } + Paragraph p = subtitle.GetParagraphOrDefault(_firstSelectedIndex); + if (p != null) + { + if (p.Text.Length > 1) + { + p.Text = p.Text.Insert(p.Text.Length / 2, sb.ToString()); + } + else + { + p.Text = sb + p.Text; + } + } + } + else + { + Random r = new Random(); + List indices = new List(); + foreach (byte b in buffer) + { + int number = r.Next(subtitle.Paragraphs.Count - 1); + if (indices.Contains(number)) + { + number = r.Next(subtitle.Paragraphs.Count - 1); + } + + if (indices.Contains(number)) + { + number = r.Next(subtitle.Paragraphs.Count - 1); + } + + indices.Add(number); + } + + indices.Sort(); + int j = 0; + foreach (byte b in buffer) + { + StringBuilder sb = new StringBuilder(); + Paragraph p = subtitle.Paragraphs[indices[j]]; + sb.Append(ZeroWidthSpace); + for (int i = 0; i < b; i++) + { + sb.Append(ZeroWidthNoBreakSpace); + } + + if (p.Text.Length > 1) + { + p.Text = p.Text.Insert(p.Text.Length / 2, sb.ToString()); + } + else + { + p.Text = sb + p.Text; + } + + j++; + } + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + internal void AddOrRemove(Subtitle subtitle) + { + if (groupBoxGenerate.Enabled) + { + AddWaterMark(subtitle, textBoxWatermark.Text); + } + else + { + RemoveWaterMark(subtitle); + } + } + + private static void RemoveWaterMark(Subtitle subtitle) + { + var zws = ZeroWidthSpace.ToString(CultureInfo.InvariantCulture); + var zwnbs = ZeroWidthNoBreakSpace.ToString(CultureInfo.InvariantCulture); + foreach (Paragraph p in subtitle.Paragraphs) + { + p.Text = p.Text.Replace(zws, string.Empty).Replace(zwnbs, string.Empty); + } + } + + private void buttonGenerate_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void buttonRemove_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + } + + private void Watermark_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + } +} diff --git a/src/Forms/Watermark.resx b/src/ui/Forms/Watermark.resx similarity index 97% rename from src/Forms/Watermark.resx rename to src/ui/Forms/Watermark.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/Watermark.resx +++ b/src/ui/Forms/Watermark.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/WaveformGenerateTimeCodes.Designer.cs b/src/ui/Forms/WaveformGenerateTimeCodes.Designer.cs similarity index 98% rename from src/Forms/WaveformGenerateTimeCodes.Designer.cs rename to src/ui/Forms/WaveformGenerateTimeCodes.Designer.cs index e2f87cc7c..59d35e685 100644 --- a/src/Forms/WaveformGenerateTimeCodes.Designer.cs +++ b/src/ui/Forms/WaveformGenerateTimeCodes.Designer.cs @@ -1,400 +1,400 @@ -namespace Nikse.SubtitleEdit.Forms -{ - sealed partial class WaveformGenerateTimeCodes - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOK = new System.Windows.Forms.Button(); - this.groupBoxStartFrom = new System.Windows.Forms.GroupBox(); - this.radioButtonStartFromPos = new System.Windows.Forms.RadioButton(); - this.radioButtonStartFromStart = new System.Windows.Forms.RadioButton(); - this.labelAbove1 = new System.Windows.Forms.Label(); - this.numericUpDownMinVol = new System.Windows.Forms.NumericUpDown(); - this.groupBoxDeleteLines = new System.Windows.Forms.GroupBox(); - this.radioButtonDeleteNone = new System.Windows.Forms.RadioButton(); - this.radioButtonForward = new System.Windows.Forms.RadioButton(); - this.radioButtonDeleteAll = new System.Windows.Forms.RadioButton(); - this.groupBoxDetectOptions = new System.Windows.Forms.GroupBox(); - this.labelBelow2 = new System.Windows.Forms.Label(); - this.labelAbove2 = new System.Windows.Forms.Label(); - this.numericUpDownBlockSize = new System.Windows.Forms.NumericUpDown(); - this.labelScanBlocksMs = new System.Windows.Forms.Label(); - this.labelBelow1 = new System.Windows.Forms.Label(); - this.numericUpDownMaxVol = new System.Windows.Forms.NumericUpDown(); - this.groupBoxOther = new System.Windows.Forms.GroupBox(); - this.labelSplit2 = new System.Windows.Forms.Label(); - this.labelSplit1 = new System.Windows.Forms.Label(); - this.numericUpDownDefaultMilliseconds = new System.Windows.Forms.NumericUpDown(); - this.groupBoxStartFrom.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinVol)).BeginInit(); - this.groupBoxDeleteLines.SuspendLayout(); - this.groupBoxDetectOptions.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownBlockSize)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxVol)).BeginInit(); - this.groupBoxOther.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDefaultMilliseconds)).BeginInit(); - this.SuspendLayout(); - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonCancel.Location = new System.Drawing.Point(598, 389); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonOK.Location = new System.Drawing.Point(517, 389); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); - // - // groupBoxStartFrom - // - this.groupBoxStartFrom.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxStartFrom.Controls.Add(this.radioButtonStartFromPos); - this.groupBoxStartFrom.Controls.Add(this.radioButtonStartFromStart); - this.groupBoxStartFrom.Location = new System.Drawing.Point(12, 12); - this.groupBoxStartFrom.Name = "groupBoxStartFrom"; - this.groupBoxStartFrom.Size = new System.Drawing.Size(661, 76); - this.groupBoxStartFrom.TabIndex = 5; - this.groupBoxStartFrom.TabStop = false; - this.groupBoxStartFrom.Text = "Start from"; - // - // radioButtonStartFromPos - // - this.radioButtonStartFromPos.AutoSize = true; - this.radioButtonStartFromPos.Checked = true; - this.radioButtonStartFromPos.Location = new System.Drawing.Point(10, 24); - this.radioButtonStartFromPos.Name = "radioButtonStartFromPos"; - this.radioButtonStartFromPos.Size = new System.Drawing.Size(127, 17); - this.radioButtonStartFromPos.TabIndex = 2; - this.radioButtonStartFromPos.TabStop = true; - this.radioButtonStartFromPos.Text = "Current video position"; - this.radioButtonStartFromPos.UseVisualStyleBackColor = true; - // - // radioButtonStartFromStart - // - this.radioButtonStartFromStart.AutoSize = true; - this.radioButtonStartFromStart.Location = new System.Drawing.Point(10, 47); - this.radioButtonStartFromStart.Name = "radioButtonStartFromStart"; - this.radioButtonStartFromStart.Size = new System.Drawing.Size(47, 17); - this.radioButtonStartFromStart.TabIndex = 0; - this.radioButtonStartFromStart.Text = "Start"; - this.radioButtonStartFromStart.UseVisualStyleBackColor = true; - // - // labelAbove1 - // - this.labelAbove1.AutoSize = true; - this.labelAbove1.Location = new System.Drawing.Point(6, 62); - this.labelAbove1.Name = "labelAbove1"; - this.labelAbove1.Size = new System.Drawing.Size(186, 13); - this.labelAbove1.TabIndex = 6; - this.labelAbove1.Text = "Block average volume must be above"; - // - // numericUpDownMinVol - // - this.numericUpDownMinVol.Location = new System.Drawing.Point(208, 60); - this.numericUpDownMinVol.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.numericUpDownMinVol.Name = "numericUpDownMinVol"; - this.numericUpDownMinVol.Size = new System.Drawing.Size(51, 20); - this.numericUpDownMinVol.TabIndex = 7; - this.numericUpDownMinVol.Value = new decimal(new int[] { - 35, - 0, - 0, - 0}); - // - // groupBoxDeleteLines - // - this.groupBoxDeleteLines.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxDeleteLines.Controls.Add(this.radioButtonDeleteNone); - this.groupBoxDeleteLines.Controls.Add(this.radioButtonForward); - this.groupBoxDeleteLines.Controls.Add(this.radioButtonDeleteAll); - this.groupBoxDeleteLines.Location = new System.Drawing.Point(12, 94); - this.groupBoxDeleteLines.Name = "groupBoxDeleteLines"; - this.groupBoxDeleteLines.Size = new System.Drawing.Size(661, 99); - this.groupBoxDeleteLines.TabIndex = 6; - this.groupBoxDeleteLines.TabStop = false; - this.groupBoxDeleteLines.Text = "Delete lines"; - // - // radioButtonDeleteNone - // - this.radioButtonDeleteNone.AutoSize = true; - this.radioButtonDeleteNone.Location = new System.Drawing.Point(10, 47); - this.radioButtonDeleteNone.Name = "radioButtonDeleteNone"; - this.radioButtonDeleteNone.Size = new System.Drawing.Size(51, 17); - this.radioButtonDeleteNone.TabIndex = 2; - this.radioButtonDeleteNone.Text = "None"; - this.radioButtonDeleteNone.UseVisualStyleBackColor = true; - // - // radioButtonForward - // - this.radioButtonForward.AutoSize = true; - this.radioButtonForward.Checked = true; - this.radioButtonForward.Location = new System.Drawing.Point(10, 70); - this.radioButtonForward.Name = "radioButtonForward"; - this.radioButtonForward.Size = new System.Drawing.Size(152, 17); - this.radioButtonForward.TabIndex = 1; - this.radioButtonForward.TabStop = true; - this.radioButtonForward.Text = "From current video position"; - this.radioButtonForward.UseVisualStyleBackColor = true; - // - // radioButtonDeleteAll - // - this.radioButtonDeleteAll.AutoSize = true; - this.radioButtonDeleteAll.Location = new System.Drawing.Point(10, 24); - this.radioButtonDeleteAll.Name = "radioButtonDeleteAll"; - this.radioButtonDeleteAll.Size = new System.Drawing.Size(36, 17); - this.radioButtonDeleteAll.TabIndex = 0; - this.radioButtonDeleteAll.Text = "All"; - this.radioButtonDeleteAll.UseVisualStyleBackColor = true; - // - // groupBoxDetectOptions - // - this.groupBoxDetectOptions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxDetectOptions.Controls.Add(this.labelBelow2); - this.groupBoxDetectOptions.Controls.Add(this.labelAbove2); - this.groupBoxDetectOptions.Controls.Add(this.numericUpDownBlockSize); - this.groupBoxDetectOptions.Controls.Add(this.labelScanBlocksMs); - this.groupBoxDetectOptions.Controls.Add(this.labelBelow1); - this.groupBoxDetectOptions.Controls.Add(this.numericUpDownMaxVol); - this.groupBoxDetectOptions.Controls.Add(this.labelAbove1); - this.groupBoxDetectOptions.Controls.Add(this.numericUpDownMinVol); - this.groupBoxDetectOptions.Location = new System.Drawing.Point(12, 199); - this.groupBoxDetectOptions.Name = "groupBoxDetectOptions"; - this.groupBoxDetectOptions.Size = new System.Drawing.Size(661, 121); - this.groupBoxDetectOptions.TabIndex = 6; - this.groupBoxDetectOptions.TabStop = false; - this.groupBoxDetectOptions.Text = "Detect options"; - // - // labelBelow2 - // - this.labelBelow2.AutoSize = true; - this.labelBelow2.Location = new System.Drawing.Point(265, 91); - this.labelBelow2.Name = "labelBelow2"; - this.labelBelow2.Size = new System.Drawing.Size(109, 13); - this.labelBelow2.TabIndex = 15; - this.labelBelow2.Text = "% of total max volume"; - // - // labelAbove2 - // - this.labelAbove2.AutoSize = true; - this.labelAbove2.Location = new System.Drawing.Point(265, 62); - this.labelAbove2.Name = "labelAbove2"; - this.labelAbove2.Size = new System.Drawing.Size(129, 13); - this.labelAbove2.TabIndex = 14; - this.labelAbove2.Text = "% of total average volume"; - // - // numericUpDownBlockSize - // - this.numericUpDownBlockSize.Location = new System.Drawing.Point(149, 24); - this.numericUpDownBlockSize.Maximum = new decimal(new int[] { - 300, - 0, - 0, - 0}); - this.numericUpDownBlockSize.Minimum = new decimal(new int[] { - 50, - 0, - 0, - 0}); - this.numericUpDownBlockSize.Name = "numericUpDownBlockSize"; - this.numericUpDownBlockSize.Size = new System.Drawing.Size(51, 20); - this.numericUpDownBlockSize.TabIndex = 13; - this.numericUpDownBlockSize.Value = new decimal(new int[] { - 100, - 0, - 0, - 0}); - // - // labelScanBlocksMs - // - this.labelScanBlocksMs.AutoSize = true; - this.labelScanBlocksMs.Location = new System.Drawing.Point(6, 26); - this.labelScanBlocksMs.Name = "labelScanBlocksMs"; - this.labelScanBlocksMs.Size = new System.Drawing.Size(137, 13); - this.labelScanBlocksMs.TabIndex = 12; - this.labelScanBlocksMs.Text = "Scan blocks of milliseconds"; - // - // labelBelow1 - // - this.labelBelow1.AutoSize = true; - this.labelBelow1.Location = new System.Drawing.Point(7, 89); - this.labelBelow1.Name = "labelBelow1"; - this.labelBelow1.Size = new System.Drawing.Size(184, 13); - this.labelBelow1.TabIndex = 9; - this.labelBelow1.Text = "Block average volume must be below"; - // - // numericUpDownMaxVol - // - this.numericUpDownMaxVol.Location = new System.Drawing.Point(208, 89); - this.numericUpDownMaxVol.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.numericUpDownMaxVol.Name = "numericUpDownMaxVol"; - this.numericUpDownMaxVol.Size = new System.Drawing.Size(51, 20); - this.numericUpDownMaxVol.TabIndex = 10; - this.numericUpDownMaxVol.Value = new decimal(new int[] { - 70, - 0, - 0, - 0}); - // - // groupBoxOther - // - this.groupBoxOther.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxOther.Controls.Add(this.labelSplit2); - this.groupBoxOther.Controls.Add(this.labelSplit1); - this.groupBoxOther.Controls.Add(this.numericUpDownDefaultMilliseconds); - this.groupBoxOther.Location = new System.Drawing.Point(12, 326); - this.groupBoxOther.Name = "groupBoxOther"; - this.groupBoxOther.Size = new System.Drawing.Size(661, 57); - this.groupBoxOther.TabIndex = 7; - this.groupBoxOther.TabStop = false; - this.groupBoxOther.Text = "Other"; - // - // labelSplit2 - // - this.labelSplit2.AutoSize = true; - this.labelSplit2.Location = new System.Drawing.Point(185, 28); - this.labelSplit2.Name = "labelSplit2"; - this.labelSplit2.Size = new System.Drawing.Size(63, 13); - this.labelSplit2.TabIndex = 13; - this.labelSplit2.Text = "milliseconds"; - // - // labelSplit1 - // - this.labelSplit1.AutoSize = true; - this.labelSplit1.Location = new System.Drawing.Point(6, 28); - this.labelSplit1.Name = "labelSplit1"; - this.labelSplit1.Size = new System.Drawing.Size(103, 13); - this.labelSplit1.TabIndex = 12; - this.labelSplit1.Text = "Split long subtitles at"; - // - // numericUpDownDefaultMilliseconds - // - this.numericUpDownDefaultMilliseconds.Location = new System.Drawing.Point(111, 26); - this.numericUpDownDefaultMilliseconds.Maximum = new decimal(new int[] { - 99999, - 0, - 0, - 0}); - this.numericUpDownDefaultMilliseconds.Minimum = new decimal(new int[] { - 2000, - 0, - 0, - 0}); - this.numericUpDownDefaultMilliseconds.Name = "numericUpDownDefaultMilliseconds"; - this.numericUpDownDefaultMilliseconds.Size = new System.Drawing.Size(51, 20); - this.numericUpDownDefaultMilliseconds.TabIndex = 11; - this.numericUpDownDefaultMilliseconds.Value = new decimal(new int[] { - 3500, - 0, - 0, - 0}); - // - // WaveformGenerateTimeCodes - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(685, 422); - this.Controls.Add(this.groupBoxOther); - this.Controls.Add(this.groupBoxDetectOptions); - this.Controls.Add(this.groupBoxDeleteLines); - this.Controls.Add(this.groupBoxStartFrom); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOK); - this.KeyPreview = true; - this.Name = "WaveformGenerateTimeCodes"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Guess time codes"; - this.groupBoxStartFrom.ResumeLayout(false); - this.groupBoxStartFrom.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinVol)).EndInit(); - this.groupBoxDeleteLines.ResumeLayout(false); - this.groupBoxDeleteLines.PerformLayout(); - this.groupBoxDetectOptions.ResumeLayout(false); - this.groupBoxDetectOptions.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownBlockSize)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxVol)).EndInit(); - this.groupBoxOther.ResumeLayout(false); - this.groupBoxOther.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDefaultMilliseconds)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.GroupBox groupBoxStartFrom; - private System.Windows.Forms.RadioButton radioButtonStartFromStart; - private System.Windows.Forms.Label labelAbove1; - private System.Windows.Forms.NumericUpDown numericUpDownMinVol; - private System.Windows.Forms.RadioButton radioButtonStartFromPos; - private System.Windows.Forms.GroupBox groupBoxDeleteLines; - private System.Windows.Forms.RadioButton radioButtonDeleteNone; - private System.Windows.Forms.RadioButton radioButtonForward; - private System.Windows.Forms.RadioButton radioButtonDeleteAll; - private System.Windows.Forms.GroupBox groupBoxDetectOptions; - private System.Windows.Forms.Label labelBelow1; - private System.Windows.Forms.NumericUpDown numericUpDownMaxVol; - private System.Windows.Forms.NumericUpDown numericUpDownBlockSize; - private System.Windows.Forms.Label labelScanBlocksMs; - private System.Windows.Forms.Label labelBelow2; - private System.Windows.Forms.Label labelAbove2; - private System.Windows.Forms.GroupBox groupBoxOther; - private System.Windows.Forms.Label labelSplit1; - private System.Windows.Forms.NumericUpDown numericUpDownDefaultMilliseconds; - private System.Windows.Forms.Label labelSplit2; - } +namespace Nikse.SubtitleEdit.Forms +{ + sealed partial class WaveformGenerateTimeCodes + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxStartFrom = new System.Windows.Forms.GroupBox(); + this.radioButtonStartFromPos = new System.Windows.Forms.RadioButton(); + this.radioButtonStartFromStart = new System.Windows.Forms.RadioButton(); + this.labelAbove1 = new System.Windows.Forms.Label(); + this.numericUpDownMinVol = new System.Windows.Forms.NumericUpDown(); + this.groupBoxDeleteLines = new System.Windows.Forms.GroupBox(); + this.radioButtonDeleteNone = new System.Windows.Forms.RadioButton(); + this.radioButtonForward = new System.Windows.Forms.RadioButton(); + this.radioButtonDeleteAll = new System.Windows.Forms.RadioButton(); + this.groupBoxDetectOptions = new System.Windows.Forms.GroupBox(); + this.labelBelow2 = new System.Windows.Forms.Label(); + this.labelAbove2 = new System.Windows.Forms.Label(); + this.numericUpDownBlockSize = new System.Windows.Forms.NumericUpDown(); + this.labelScanBlocksMs = new System.Windows.Forms.Label(); + this.labelBelow1 = new System.Windows.Forms.Label(); + this.numericUpDownMaxVol = new System.Windows.Forms.NumericUpDown(); + this.groupBoxOther = new System.Windows.Forms.GroupBox(); + this.labelSplit2 = new System.Windows.Forms.Label(); + this.labelSplit1 = new System.Windows.Forms.Label(); + this.numericUpDownDefaultMilliseconds = new System.Windows.Forms.NumericUpDown(); + this.groupBoxStartFrom.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinVol)).BeginInit(); + this.groupBoxDeleteLines.SuspendLayout(); + this.groupBoxDetectOptions.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownBlockSize)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxVol)).BeginInit(); + this.groupBoxOther.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDefaultMilliseconds)).BeginInit(); + this.SuspendLayout(); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonCancel.Location = new System.Drawing.Point(598, 389); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonOK.Location = new System.Drawing.Point(517, 389); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // groupBoxStartFrom + // + this.groupBoxStartFrom.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxStartFrom.Controls.Add(this.radioButtonStartFromPos); + this.groupBoxStartFrom.Controls.Add(this.radioButtonStartFromStart); + this.groupBoxStartFrom.Location = new System.Drawing.Point(12, 12); + this.groupBoxStartFrom.Name = "groupBoxStartFrom"; + this.groupBoxStartFrom.Size = new System.Drawing.Size(661, 76); + this.groupBoxStartFrom.TabIndex = 5; + this.groupBoxStartFrom.TabStop = false; + this.groupBoxStartFrom.Text = "Start from"; + // + // radioButtonStartFromPos + // + this.radioButtonStartFromPos.AutoSize = true; + this.radioButtonStartFromPos.Checked = true; + this.radioButtonStartFromPos.Location = new System.Drawing.Point(10, 24); + this.radioButtonStartFromPos.Name = "radioButtonStartFromPos"; + this.radioButtonStartFromPos.Size = new System.Drawing.Size(127, 17); + this.radioButtonStartFromPos.TabIndex = 2; + this.radioButtonStartFromPos.TabStop = true; + this.radioButtonStartFromPos.Text = "Current video position"; + this.radioButtonStartFromPos.UseVisualStyleBackColor = true; + // + // radioButtonStartFromStart + // + this.radioButtonStartFromStart.AutoSize = true; + this.radioButtonStartFromStart.Location = new System.Drawing.Point(10, 47); + this.radioButtonStartFromStart.Name = "radioButtonStartFromStart"; + this.radioButtonStartFromStart.Size = new System.Drawing.Size(47, 17); + this.radioButtonStartFromStart.TabIndex = 0; + this.radioButtonStartFromStart.Text = "Start"; + this.radioButtonStartFromStart.UseVisualStyleBackColor = true; + // + // labelAbove1 + // + this.labelAbove1.AutoSize = true; + this.labelAbove1.Location = new System.Drawing.Point(6, 62); + this.labelAbove1.Name = "labelAbove1"; + this.labelAbove1.Size = new System.Drawing.Size(186, 13); + this.labelAbove1.TabIndex = 6; + this.labelAbove1.Text = "Block average volume must be above"; + // + // numericUpDownMinVol + // + this.numericUpDownMinVol.Location = new System.Drawing.Point(208, 60); + this.numericUpDownMinVol.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numericUpDownMinVol.Name = "numericUpDownMinVol"; + this.numericUpDownMinVol.Size = new System.Drawing.Size(51, 20); + this.numericUpDownMinVol.TabIndex = 7; + this.numericUpDownMinVol.Value = new decimal(new int[] { + 35, + 0, + 0, + 0}); + // + // groupBoxDeleteLines + // + this.groupBoxDeleteLines.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxDeleteLines.Controls.Add(this.radioButtonDeleteNone); + this.groupBoxDeleteLines.Controls.Add(this.radioButtonForward); + this.groupBoxDeleteLines.Controls.Add(this.radioButtonDeleteAll); + this.groupBoxDeleteLines.Location = new System.Drawing.Point(12, 94); + this.groupBoxDeleteLines.Name = "groupBoxDeleteLines"; + this.groupBoxDeleteLines.Size = new System.Drawing.Size(661, 99); + this.groupBoxDeleteLines.TabIndex = 6; + this.groupBoxDeleteLines.TabStop = false; + this.groupBoxDeleteLines.Text = "Delete lines"; + // + // radioButtonDeleteNone + // + this.radioButtonDeleteNone.AutoSize = true; + this.radioButtonDeleteNone.Location = new System.Drawing.Point(10, 47); + this.radioButtonDeleteNone.Name = "radioButtonDeleteNone"; + this.radioButtonDeleteNone.Size = new System.Drawing.Size(51, 17); + this.radioButtonDeleteNone.TabIndex = 2; + this.radioButtonDeleteNone.Text = "None"; + this.radioButtonDeleteNone.UseVisualStyleBackColor = true; + // + // radioButtonForward + // + this.radioButtonForward.AutoSize = true; + this.radioButtonForward.Checked = true; + this.radioButtonForward.Location = new System.Drawing.Point(10, 70); + this.radioButtonForward.Name = "radioButtonForward"; + this.radioButtonForward.Size = new System.Drawing.Size(152, 17); + this.radioButtonForward.TabIndex = 1; + this.radioButtonForward.TabStop = true; + this.radioButtonForward.Text = "From current video position"; + this.radioButtonForward.UseVisualStyleBackColor = true; + // + // radioButtonDeleteAll + // + this.radioButtonDeleteAll.AutoSize = true; + this.radioButtonDeleteAll.Location = new System.Drawing.Point(10, 24); + this.radioButtonDeleteAll.Name = "radioButtonDeleteAll"; + this.radioButtonDeleteAll.Size = new System.Drawing.Size(36, 17); + this.radioButtonDeleteAll.TabIndex = 0; + this.radioButtonDeleteAll.Text = "All"; + this.radioButtonDeleteAll.UseVisualStyleBackColor = true; + // + // groupBoxDetectOptions + // + this.groupBoxDetectOptions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxDetectOptions.Controls.Add(this.labelBelow2); + this.groupBoxDetectOptions.Controls.Add(this.labelAbove2); + this.groupBoxDetectOptions.Controls.Add(this.numericUpDownBlockSize); + this.groupBoxDetectOptions.Controls.Add(this.labelScanBlocksMs); + this.groupBoxDetectOptions.Controls.Add(this.labelBelow1); + this.groupBoxDetectOptions.Controls.Add(this.numericUpDownMaxVol); + this.groupBoxDetectOptions.Controls.Add(this.labelAbove1); + this.groupBoxDetectOptions.Controls.Add(this.numericUpDownMinVol); + this.groupBoxDetectOptions.Location = new System.Drawing.Point(12, 199); + this.groupBoxDetectOptions.Name = "groupBoxDetectOptions"; + this.groupBoxDetectOptions.Size = new System.Drawing.Size(661, 121); + this.groupBoxDetectOptions.TabIndex = 6; + this.groupBoxDetectOptions.TabStop = false; + this.groupBoxDetectOptions.Text = "Detect options"; + // + // labelBelow2 + // + this.labelBelow2.AutoSize = true; + this.labelBelow2.Location = new System.Drawing.Point(265, 91); + this.labelBelow2.Name = "labelBelow2"; + this.labelBelow2.Size = new System.Drawing.Size(109, 13); + this.labelBelow2.TabIndex = 15; + this.labelBelow2.Text = "% of total max volume"; + // + // labelAbove2 + // + this.labelAbove2.AutoSize = true; + this.labelAbove2.Location = new System.Drawing.Point(265, 62); + this.labelAbove2.Name = "labelAbove2"; + this.labelAbove2.Size = new System.Drawing.Size(129, 13); + this.labelAbove2.TabIndex = 14; + this.labelAbove2.Text = "% of total average volume"; + // + // numericUpDownBlockSize + // + this.numericUpDownBlockSize.Location = new System.Drawing.Point(149, 24); + this.numericUpDownBlockSize.Maximum = new decimal(new int[] { + 300, + 0, + 0, + 0}); + this.numericUpDownBlockSize.Minimum = new decimal(new int[] { + 50, + 0, + 0, + 0}); + this.numericUpDownBlockSize.Name = "numericUpDownBlockSize"; + this.numericUpDownBlockSize.Size = new System.Drawing.Size(51, 20); + this.numericUpDownBlockSize.TabIndex = 13; + this.numericUpDownBlockSize.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // labelScanBlocksMs + // + this.labelScanBlocksMs.AutoSize = true; + this.labelScanBlocksMs.Location = new System.Drawing.Point(6, 26); + this.labelScanBlocksMs.Name = "labelScanBlocksMs"; + this.labelScanBlocksMs.Size = new System.Drawing.Size(137, 13); + this.labelScanBlocksMs.TabIndex = 12; + this.labelScanBlocksMs.Text = "Scan blocks of milliseconds"; + // + // labelBelow1 + // + this.labelBelow1.AutoSize = true; + this.labelBelow1.Location = new System.Drawing.Point(7, 89); + this.labelBelow1.Name = "labelBelow1"; + this.labelBelow1.Size = new System.Drawing.Size(184, 13); + this.labelBelow1.TabIndex = 9; + this.labelBelow1.Text = "Block average volume must be below"; + // + // numericUpDownMaxVol + // + this.numericUpDownMaxVol.Location = new System.Drawing.Point(208, 89); + this.numericUpDownMaxVol.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.numericUpDownMaxVol.Name = "numericUpDownMaxVol"; + this.numericUpDownMaxVol.Size = new System.Drawing.Size(51, 20); + this.numericUpDownMaxVol.TabIndex = 10; + this.numericUpDownMaxVol.Value = new decimal(new int[] { + 70, + 0, + 0, + 0}); + // + // groupBoxOther + // + this.groupBoxOther.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxOther.Controls.Add(this.labelSplit2); + this.groupBoxOther.Controls.Add(this.labelSplit1); + this.groupBoxOther.Controls.Add(this.numericUpDownDefaultMilliseconds); + this.groupBoxOther.Location = new System.Drawing.Point(12, 326); + this.groupBoxOther.Name = "groupBoxOther"; + this.groupBoxOther.Size = new System.Drawing.Size(661, 57); + this.groupBoxOther.TabIndex = 7; + this.groupBoxOther.TabStop = false; + this.groupBoxOther.Text = "Other"; + // + // labelSplit2 + // + this.labelSplit2.AutoSize = true; + this.labelSplit2.Location = new System.Drawing.Point(185, 28); + this.labelSplit2.Name = "labelSplit2"; + this.labelSplit2.Size = new System.Drawing.Size(63, 13); + this.labelSplit2.TabIndex = 13; + this.labelSplit2.Text = "milliseconds"; + // + // labelSplit1 + // + this.labelSplit1.AutoSize = true; + this.labelSplit1.Location = new System.Drawing.Point(6, 28); + this.labelSplit1.Name = "labelSplit1"; + this.labelSplit1.Size = new System.Drawing.Size(103, 13); + this.labelSplit1.TabIndex = 12; + this.labelSplit1.Text = "Split long subtitles at"; + // + // numericUpDownDefaultMilliseconds + // + this.numericUpDownDefaultMilliseconds.Location = new System.Drawing.Point(111, 26); + this.numericUpDownDefaultMilliseconds.Maximum = new decimal(new int[] { + 99999, + 0, + 0, + 0}); + this.numericUpDownDefaultMilliseconds.Minimum = new decimal(new int[] { + 2000, + 0, + 0, + 0}); + this.numericUpDownDefaultMilliseconds.Name = "numericUpDownDefaultMilliseconds"; + this.numericUpDownDefaultMilliseconds.Size = new System.Drawing.Size(51, 20); + this.numericUpDownDefaultMilliseconds.TabIndex = 11; + this.numericUpDownDefaultMilliseconds.Value = new decimal(new int[] { + 3500, + 0, + 0, + 0}); + // + // WaveformGenerateTimeCodes + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(685, 422); + this.Controls.Add(this.groupBoxOther); + this.Controls.Add(this.groupBoxDetectOptions); + this.Controls.Add(this.groupBoxDeleteLines); + this.Controls.Add(this.groupBoxStartFrom); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.KeyPreview = true; + this.Name = "WaveformGenerateTimeCodes"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Guess time codes"; + this.groupBoxStartFrom.ResumeLayout(false); + this.groupBoxStartFrom.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMinVol)).EndInit(); + this.groupBoxDeleteLines.ResumeLayout(false); + this.groupBoxDeleteLines.PerformLayout(); + this.groupBoxDetectOptions.ResumeLayout(false); + this.groupBoxDetectOptions.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownBlockSize)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxVol)).EndInit(); + this.groupBoxOther.ResumeLayout(false); + this.groupBoxOther.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDefaultMilliseconds)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.GroupBox groupBoxStartFrom; + private System.Windows.Forms.RadioButton radioButtonStartFromStart; + private System.Windows.Forms.Label labelAbove1; + private System.Windows.Forms.NumericUpDown numericUpDownMinVol; + private System.Windows.Forms.RadioButton radioButtonStartFromPos; + private System.Windows.Forms.GroupBox groupBoxDeleteLines; + private System.Windows.Forms.RadioButton radioButtonDeleteNone; + private System.Windows.Forms.RadioButton radioButtonForward; + private System.Windows.Forms.RadioButton radioButtonDeleteAll; + private System.Windows.Forms.GroupBox groupBoxDetectOptions; + private System.Windows.Forms.Label labelBelow1; + private System.Windows.Forms.NumericUpDown numericUpDownMaxVol; + private System.Windows.Forms.NumericUpDown numericUpDownBlockSize; + private System.Windows.Forms.Label labelScanBlocksMs; + private System.Windows.Forms.Label labelBelow2; + private System.Windows.Forms.Label labelAbove2; + private System.Windows.Forms.GroupBox groupBoxOther; + private System.Windows.Forms.Label labelSplit1; + private System.Windows.Forms.NumericUpDown numericUpDownDefaultMilliseconds; + private System.Windows.Forms.Label labelSplit2; + } } \ No newline at end of file diff --git a/src/Forms/WaveformGenerateTimeCodes.cs b/src/ui/Forms/WaveformGenerateTimeCodes.cs similarity index 97% rename from src/Forms/WaveformGenerateTimeCodes.cs rename to src/ui/Forms/WaveformGenerateTimeCodes.cs index f78f1854c..14008f769 100644 --- a/src/Forms/WaveformGenerateTimeCodes.cs +++ b/src/ui/Forms/WaveformGenerateTimeCodes.cs @@ -1,75 +1,75 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class WaveformGenerateTimeCodes : Form - { - public bool StartFromVideoPosition { get; set; } - public bool DeleteAll { get; set; } - public bool DeleteForward { get; set; } - public int BlockSize { get; set; } - public int VolumeMinimum { get; set; } - public int VolumeMaximum { get; set; } - public int DefaultMilliseconds { get; set; } - - public WaveformGenerateTimeCodes() - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - var l = Configuration.Settings.Language.WaveformGenerateTimeCodes; - Text = l.Title; - groupBoxStartFrom.Text = l.StartFrom; - radioButtonStartFromPos.Text = l.CurrentVideoPosition; - radioButtonStartFromStart.Text = l.Beginning; - groupBoxDeleteLines.Text = l.DeleteLines; - groupBoxDetectOptions.Text = l.DetectOptions; - labelScanBlocksMs.Text = l.ScanBlocksOfMs; - labelAbove1.Text = l.BlockAverageVolMin1; - labelAbove2.Text = l.BlockAverageVolMin2; - labelBelow1.Text = l.BlockAverageVolMax1; - labelBelow2.Text = l.BlockAverageVolMax2; - groupBoxOther.Text = l.Other; - labelSplit1.Text = l.SplitLongLinesAt1; - labelSplit2.Text = l.SplitLongLinesAt2; - radioButtonDeleteAll.Text = Configuration.Settings.Language.General.All; - radioButtonDeleteNone.Text = Configuration.Settings.Language.General.None; - radioButtonForward.Text = l.FromCurrentVideoPosition; - - numericUpDownBlockSize.Left = labelScanBlocksMs.Left + labelScanBlocksMs.Width + 3; - numericUpDownMinVol.Left = labelAbove1.Left + labelAbove1.Width + 3; - labelAbove2.Left = numericUpDownMinVol.Left + numericUpDownMinVol.Width + 3; - numericUpDownMaxVol.Left = labelBelow1.Left + labelBelow1.Width + 3; - labelBelow2.Left = numericUpDownMaxVol.Left + numericUpDownMaxVol.Width + 3; - numericUpDownDefaultMilliseconds.Left = labelSplit1.Left + labelSplit1.Width + 3; - labelSplit2.Left = numericUpDownDefaultMilliseconds.Left + numericUpDownDefaultMilliseconds.Width + 3; - - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - UiUtil.FixLargeFonts(this, buttonOK); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - StartFromVideoPosition = radioButtonStartFromPos.Checked; - DeleteAll = radioButtonDeleteAll.Checked; - DeleteForward = radioButtonForward.Checked; - BlockSize = (int)numericUpDownBlockSize.Value; - VolumeMinimum = (int)numericUpDownMinVol.Value; - VolumeMaximum = (int)numericUpDownMaxVol.Value; - DefaultMilliseconds = (int)numericUpDownDefaultMilliseconds.Value; - DialogResult = DialogResult.OK; - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class WaveformGenerateTimeCodes : Form + { + public bool StartFromVideoPosition { get; set; } + public bool DeleteAll { get; set; } + public bool DeleteForward { get; set; } + public int BlockSize { get; set; } + public int VolumeMinimum { get; set; } + public int VolumeMaximum { get; set; } + public int DefaultMilliseconds { get; set; } + + public WaveformGenerateTimeCodes() + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + var l = Configuration.Settings.Language.WaveformGenerateTimeCodes; + Text = l.Title; + groupBoxStartFrom.Text = l.StartFrom; + radioButtonStartFromPos.Text = l.CurrentVideoPosition; + radioButtonStartFromStart.Text = l.Beginning; + groupBoxDeleteLines.Text = l.DeleteLines; + groupBoxDetectOptions.Text = l.DetectOptions; + labelScanBlocksMs.Text = l.ScanBlocksOfMs; + labelAbove1.Text = l.BlockAverageVolMin1; + labelAbove2.Text = l.BlockAverageVolMin2; + labelBelow1.Text = l.BlockAverageVolMax1; + labelBelow2.Text = l.BlockAverageVolMax2; + groupBoxOther.Text = l.Other; + labelSplit1.Text = l.SplitLongLinesAt1; + labelSplit2.Text = l.SplitLongLinesAt2; + radioButtonDeleteAll.Text = Configuration.Settings.Language.General.All; + radioButtonDeleteNone.Text = Configuration.Settings.Language.General.None; + radioButtonForward.Text = l.FromCurrentVideoPosition; + + numericUpDownBlockSize.Left = labelScanBlocksMs.Left + labelScanBlocksMs.Width + 3; + numericUpDownMinVol.Left = labelAbove1.Left + labelAbove1.Width + 3; + labelAbove2.Left = numericUpDownMinVol.Left + numericUpDownMinVol.Width + 3; + numericUpDownMaxVol.Left = labelBelow1.Left + labelBelow1.Width + 3; + labelBelow2.Left = numericUpDownMaxVol.Left + numericUpDownMaxVol.Width + 3; + numericUpDownDefaultMilliseconds.Left = labelSplit1.Left + labelSplit1.Width + 3; + labelSplit2.Left = numericUpDownDefaultMilliseconds.Left + numericUpDownDefaultMilliseconds.Width + 3; + + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + UiUtil.FixLargeFonts(this, buttonOK); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + StartFromVideoPosition = radioButtonStartFromPos.Checked; + DeleteAll = radioButtonDeleteAll.Checked; + DeleteForward = radioButtonForward.Checked; + BlockSize = (int)numericUpDownBlockSize.Value; + VolumeMinimum = (int)numericUpDownMinVol.Value; + VolumeMaximum = (int)numericUpDownMaxVol.Value; + DefaultMilliseconds = (int)numericUpDownDefaultMilliseconds.Value; + DialogResult = DialogResult.OK; + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + } +} diff --git a/src/Forms/WaveformGenerateTimeCodes.resx b/src/ui/Forms/WaveformGenerateTimeCodes.resx similarity index 97% rename from src/Forms/WaveformGenerateTimeCodes.resx rename to src/ui/Forms/WaveformGenerateTimeCodes.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/WaveformGenerateTimeCodes.resx +++ b/src/ui/Forms/WaveformGenerateTimeCodes.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/WaveformUndocked.Designer.cs b/src/ui/Forms/WaveformUndocked.Designer.cs similarity index 97% rename from src/Forms/WaveformUndocked.Designer.cs rename to src/ui/Forms/WaveformUndocked.Designer.cs index 3bb8ecc15..f33a5592b 100644 --- a/src/Forms/WaveformUndocked.Designer.cs +++ b/src/ui/Forms/WaveformUndocked.Designer.cs @@ -1,64 +1,64 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class WaveformUndocked - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.panelContainer = new System.Windows.Forms.Panel(); - this.SuspendLayout(); - // - // panelContainer - // - this.panelContainer.Dock = System.Windows.Forms.DockStyle.Fill; - this.panelContainer.Location = new System.Drawing.Point(0, 0); - this.panelContainer.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.panelContainer.Name = "panelContainer"; - this.panelContainer.Size = new System.Drawing.Size(843, 250); - this.panelContainer.TabIndex = 1; - // - // WaveformUndocked - // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(843, 250); - this.Controls.Add(this.panelContainer); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; - this.KeyPreview = true; - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.Name = "WaveformUndocked"; - this.Text = "WaveformUndocked"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.WaveformUndocked_FormClosing); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.WaveformUndocked_KeyDown); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel panelContainer; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class WaveformUndocked + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panelContainer = new System.Windows.Forms.Panel(); + this.SuspendLayout(); + // + // panelContainer + // + this.panelContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.panelContainer.Location = new System.Drawing.Point(0, 0); + this.panelContainer.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.panelContainer.Name = "panelContainer"; + this.panelContainer.Size = new System.Drawing.Size(843, 250); + this.panelContainer.TabIndex = 1; + // + // WaveformUndocked + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(843, 250); + this.Controls.Add(this.panelContainer); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; + this.KeyPreview = true; + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.Name = "WaveformUndocked"; + this.Text = "WaveformUndocked"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.WaveformUndocked_FormClosing); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.WaveformUndocked_KeyDown); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panelContainer; + } } \ No newline at end of file diff --git a/src/Forms/WaveformUndocked.cs b/src/ui/Forms/WaveformUndocked.cs similarity index 97% rename from src/Forms/WaveformUndocked.cs rename to src/ui/Forms/WaveformUndocked.cs index 273c8e37f..503c1f77c 100644 --- a/src/Forms/WaveformUndocked.cs +++ b/src/ui/Forms/WaveformUndocked.cs @@ -1,55 +1,55 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System.Drawing; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public partial class WaveformUndocked : PositionAndSizeForm - { - private readonly Main _mainForm; - private readonly Keys _redockKeys; - - public Panel PanelContainer => panelContainer; - - public WaveformUndocked(Main mainForm) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - _mainForm = mainForm; - Icon = (Icon)mainForm.Icon.Clone(); - _redockKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls); - } - - public WaveformUndocked() - { - } - - private void WaveformUndocked_FormClosing(object sender, FormClosingEventArgs e) - { - if (e.CloseReason == CloseReason.UserClosing && panelContainer.Controls.Count > 0) - { - var controlWaveform = panelContainer.Controls[0]; - var controlButtons = panelContainer.Controls[1]; - var controlTrackBar = panelContainer.Controls[2]; - panelContainer.Controls.Clear(); - _mainForm.ReDockWaveform(controlWaveform, controlButtons, controlTrackBar); - _mainForm.SetWaveformToggleOff(); - } - } - - private void WaveformUndocked_KeyDown(object sender, KeyEventArgs e) - { - if (_redockKeys == e.KeyData) - { - _mainForm.RedockVideoControlsToolStripMenuItemClick(null, null); - } - else - { - _mainForm.MainKeyDown(sender, e); - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System.Drawing; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public partial class WaveformUndocked : PositionAndSizeForm + { + private readonly Main _mainForm; + private readonly Keys _redockKeys; + + public Panel PanelContainer => panelContainer; + + public WaveformUndocked(Main mainForm) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + _mainForm = mainForm; + Icon = (Icon)mainForm.Icon.Clone(); + _redockKeys = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoToggleVideoControls); + } + + public WaveformUndocked() + { + } + + private void WaveformUndocked_FormClosing(object sender, FormClosingEventArgs e) + { + if (e.CloseReason == CloseReason.UserClosing && panelContainer.Controls.Count > 0) + { + var controlWaveform = panelContainer.Controls[0]; + var controlButtons = panelContainer.Controls[1]; + var controlTrackBar = panelContainer.Controls[2]; + panelContainer.Controls.Clear(); + _mainForm.ReDockWaveform(controlWaveform, controlButtons, controlTrackBar); + _mainForm.SetWaveformToggleOff(); + } + } + + private void WaveformUndocked_KeyDown(object sender, KeyEventArgs e) + { + if (_redockKeys == e.KeyData) + { + _mainForm.RedockVideoControlsToolStripMenuItemClick(null, null); + } + else + { + _mainForm.MainKeyDown(sender, e); + } + } + } +} diff --git a/src/Forms/WaveformUndocked.resx b/src/ui/Forms/WaveformUndocked.resx similarity index 97% rename from src/Forms/WaveformUndocked.resx rename to src/ui/Forms/WaveformUndocked.resx index 4f24d55cd..8b2ff64a1 100644 --- a/src/Forms/WaveformUndocked.resx +++ b/src/ui/Forms/WaveformUndocked.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Forms/YouTubeAnnotationsImport.Designer.cs b/src/ui/Forms/YouTubeAnnotationsImport.Designer.cs similarity index 97% rename from src/Forms/YouTubeAnnotationsImport.Designer.cs rename to src/ui/Forms/YouTubeAnnotationsImport.Designer.cs index 2ff3c608e..ccffb65f0 100644 --- a/src/Forms/YouTubeAnnotationsImport.Designer.cs +++ b/src/ui/Forms/YouTubeAnnotationsImport.Designer.cs @@ -1,125 +1,125 @@ -namespace Nikse.SubtitleEdit.Forms -{ - partial class YouTubeAnnotationsImport - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonOK = new System.Windows.Forms.Button(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.listViewFixes = new System.Windows.Forms.ListView(); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.SuspendLayout(); - // - // buttonOK - // - this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; - this.buttonOK.Location = new System.Drawing.Point(360, 259); - this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(75, 23); - this.buttonOK.TabIndex = 3; - this.buttonOK.Text = "&OK"; - this.buttonOK.UseVisualStyleBackColor = true; - // - // buttonCancel - // - this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(442, 259); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 4; - this.buttonCancel.Text = "C&ancel"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // listViewFixes - // - this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewFixes.CheckBoxes = true; - this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader4, - this.columnHeader5, - this.columnHeader7}); - this.listViewFixes.FullRowSelect = true; - this.listViewFixes.HideSelection = false; - this.listViewFixes.Location = new System.Drawing.Point(12, 12); - this.listViewFixes.Name = "listViewFixes"; - this.listViewFixes.Size = new System.Drawing.Size(505, 241); - this.listViewFixes.TabIndex = 5; - this.listViewFixes.UseCompatibleStateImageBehavior = false; - this.listViewFixes.View = System.Windows.Forms.View.Details; - // - // columnHeader4 - // - this.columnHeader4.Text = "Apply"; - this.columnHeader4.Width = 45; - // - // columnHeader5 - // - this.columnHeader5.Text = "Style"; - this.columnHeader5.Width = 150; - // - // columnHeader7 - // - this.columnHeader7.Text = "#"; - this.columnHeader7.Width = 300; - // - // YouTubeAnnotationsImport - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(529, 292); - this.Controls.Add(this.listViewFixes); - this.Controls.Add(this.buttonOK); - this.Controls.Add(this.buttonCancel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.KeyPreview = true; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "YouTubeAnnotationsImport"; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "YouTubeAnnotationsImport"; - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.YouTubeAnnotationsImport_KeyDown); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Button buttonOK; - private System.Windows.Forms.Button buttonCancel; - private System.Windows.Forms.ListView listViewFixes; - private System.Windows.Forms.ColumnHeader columnHeader4; - private System.Windows.Forms.ColumnHeader columnHeader5; - private System.Windows.Forms.ColumnHeader columnHeader7; - } +namespace Nikse.SubtitleEdit.Forms +{ + partial class YouTubeAnnotationsImport + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.listViewFixes = new System.Windows.Forms.ListView(); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.SuspendLayout(); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOK.Location = new System.Drawing.Point(360, 259); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(75, 23); + this.buttonOK.TabIndex = 3; + this.buttonOK.Text = "&OK"; + this.buttonOK.UseVisualStyleBackColor = true; + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(442, 259); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // listViewFixes + // + this.listViewFixes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listViewFixes.CheckBoxes = true; + this.listViewFixes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader4, + this.columnHeader5, + this.columnHeader7}); + this.listViewFixes.FullRowSelect = true; + this.listViewFixes.HideSelection = false; + this.listViewFixes.Location = new System.Drawing.Point(12, 12); + this.listViewFixes.Name = "listViewFixes"; + this.listViewFixes.Size = new System.Drawing.Size(505, 241); + this.listViewFixes.TabIndex = 5; + this.listViewFixes.UseCompatibleStateImageBehavior = false; + this.listViewFixes.View = System.Windows.Forms.View.Details; + // + // columnHeader4 + // + this.columnHeader4.Text = "Apply"; + this.columnHeader4.Width = 45; + // + // columnHeader5 + // + this.columnHeader5.Text = "Style"; + this.columnHeader5.Width = 150; + // + // columnHeader7 + // + this.columnHeader7.Text = "#"; + this.columnHeader7.Width = 300; + // + // YouTubeAnnotationsImport + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(529, 292); + this.Controls.Add(this.listViewFixes); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "YouTubeAnnotationsImport"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "YouTubeAnnotationsImport"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.YouTubeAnnotationsImport_KeyDown); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.ListView listViewFixes; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader7; + } } \ No newline at end of file diff --git a/src/Forms/YouTubeAnnotationsImport.cs b/src/ui/Forms/YouTubeAnnotationsImport.cs similarity index 97% rename from src/Forms/YouTubeAnnotationsImport.cs rename to src/ui/Forms/YouTubeAnnotationsImport.cs index 7104eae7c..a954d5b1b 100644 --- a/src/Forms/YouTubeAnnotationsImport.cs +++ b/src/ui/Forms/YouTubeAnnotationsImport.cs @@ -1,57 +1,57 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Logic; -using System.Collections.Generic; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Forms -{ - public sealed partial class YouTubeAnnotationsImport : Form - { - public YouTubeAnnotationsImport(Dictionary stylesWithCount) - { - UiUtil.PreInitialize(this); - InitializeComponent(); - UiUtil.FixFonts(this); - - Text = "YouTube Annotations"; - buttonOK.Text = Configuration.Settings.Language.General.Ok; - buttonCancel.Text = Configuration.Settings.Language.General.Cancel; - listViewFixes.Columns[1].Text = string.Empty; // style // TODO: Add better text + help text - UiUtil.FixLargeFonts(this, buttonOK); - - foreach (KeyValuePair kvp in stylesWithCount) - { - ListViewItem item = new ListViewItem(); - item.SubItems.Add(kvp.Key); - item.SubItems.Add(kvp.Value.ToString()); - item.Checked = kvp.Key.Trim() == "speech"; - listViewFixes.Items.Add(item); - } - } - - public List SelectedStyles - { - get - { - List styles = new List(); - foreach (ListViewItem item in listViewFixes.Items) - { - if (item.Checked) - { - styles.Add(item.SubItems[1].Text); - } - } - return styles; - } - } - - private void YouTubeAnnotationsImport_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Escape) - { - DialogResult = DialogResult.Cancel; - } - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Logic; +using System.Collections.Generic; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class YouTubeAnnotationsImport : Form + { + public YouTubeAnnotationsImport(Dictionary stylesWithCount) + { + UiUtil.PreInitialize(this); + InitializeComponent(); + UiUtil.FixFonts(this); + + Text = "YouTube Annotations"; + buttonOK.Text = Configuration.Settings.Language.General.Ok; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + listViewFixes.Columns[1].Text = string.Empty; // style // TODO: Add better text + help text + UiUtil.FixLargeFonts(this, buttonOK); + + foreach (KeyValuePair kvp in stylesWithCount) + { + ListViewItem item = new ListViewItem(); + item.SubItems.Add(kvp.Key); + item.SubItems.Add(kvp.Value.ToString()); + item.Checked = kvp.Key.Trim() == "speech"; + listViewFixes.Items.Add(item); + } + } + + public List SelectedStyles + { + get + { + List styles = new List(); + foreach (ListViewItem item in listViewFixes.Items) + { + if (item.Checked) + { + styles.Add(item.SubItems[1].Text); + } + } + return styles; + } + } + + private void YouTubeAnnotationsImport_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + } + } +} diff --git a/src/Forms/YouTubeAnnotationsImport.resx b/src/ui/Forms/YouTubeAnnotationsImport.resx similarity index 97% rename from src/Forms/YouTubeAnnotationsImport.resx rename to src/ui/Forms/YouTubeAnnotationsImport.resx index 29dcb1b3a..1af7de150 100644 --- a/src/Forms/YouTubeAnnotationsImport.resx +++ b/src/ui/Forms/YouTubeAnnotationsImport.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/src/Icons/Donate.png b/src/ui/Icons/Donate.png similarity index 100% rename from src/Icons/Donate.png rename to src/ui/Icons/Donate.png diff --git a/src/Icons/Find.png b/src/ui/Icons/Find.png similarity index 100% rename from src/Icons/Find.png rename to src/ui/Icons/Find.png diff --git a/src/Icons/FixCommonErrors.png b/src/ui/Icons/FixCommonErrors.png similarity index 100% rename from src/Icons/FixCommonErrors.png rename to src/ui/Icons/FixCommonErrors.png diff --git a/src/Icons/Help.png b/src/ui/Icons/Help.png similarity index 100% rename from src/Icons/Help.png rename to src/ui/Icons/Help.png diff --git a/src/Icons/New.png b/src/ui/Icons/New.png similarity index 100% rename from src/Icons/New.png rename to src/ui/Icons/New.png diff --git a/src/Icons/Open.png b/src/ui/Icons/Open.png similarity index 100% rename from src/Icons/Open.png rename to src/ui/Icons/Open.png diff --git a/src/Icons/RemoveTextForHI.png b/src/ui/Icons/RemoveTextForHI.png similarity index 100% rename from src/Icons/RemoveTextForHI.png rename to src/ui/Icons/RemoveTextForHI.png diff --git a/src/Icons/Replace.png b/src/ui/Icons/Replace.png similarity index 100% rename from src/Icons/Replace.png rename to src/ui/Icons/Replace.png diff --git a/src/Icons/SE.ico b/src/ui/Icons/SE.ico similarity index 100% rename from src/Icons/SE.ico rename to src/ui/Icons/SE.ico diff --git a/src/Icons/Save.png b/src/ui/Icons/Save.png similarity index 100% rename from src/Icons/Save.png rename to src/ui/Icons/Save.png diff --git a/src/Icons/SaveAs.png b/src/ui/Icons/SaveAs.png similarity index 100% rename from src/Icons/SaveAs.png rename to src/ui/Icons/SaveAs.png diff --git a/src/Icons/Settings.png b/src/ui/Icons/Settings.png similarity index 100% rename from src/Icons/Settings.png rename to src/ui/Icons/Settings.png diff --git a/src/Icons/SpellCheck.png b/src/ui/Icons/SpellCheck.png similarity index 100% rename from src/Icons/SpellCheck.png rename to src/ui/Icons/SpellCheck.png diff --git a/src/Icons/VideoToggle.png b/src/ui/Icons/VideoToggle.png similarity index 100% rename from src/Icons/VideoToggle.png rename to src/ui/Icons/VideoToggle.png diff --git a/src/Icons/VisualSync.png b/src/ui/Icons/VisualSync.png similarity index 100% rename from src/Icons/VisualSync.png rename to src/ui/Icons/VisualSync.png diff --git a/src/Icons/WaveformToggle.png b/src/ui/Icons/WaveformToggle.png similarity index 100% rename from src/Icons/WaveformToggle.png rename to src/ui/Icons/WaveformToggle.png diff --git a/src/Icons/connect.png b/src/ui/Icons/connect.png similarity index 100% rename from src/Icons/connect.png rename to src/ui/Icons/connect.png diff --git a/src/ui/Languages/XmlContentTranslator.exe b/src/ui/Languages/XmlContentTranslator.exe new file mode 100644 index 000000000..97d259672 Binary files /dev/null and b/src/ui/Languages/XmlContentTranslator.exe differ diff --git a/src/Languages/ar-EG.xml b/src/ui/Languages/ar-EG.xml similarity index 100% rename from src/Languages/ar-EG.xml rename to src/ui/Languages/ar-EG.xml diff --git a/src/Languages/bg-BG.xml b/src/ui/Languages/bg-BG.xml similarity index 100% rename from src/Languages/bg-BG.xml rename to src/ui/Languages/bg-BG.xml diff --git a/src/Languages/br-FR.xml b/src/ui/Languages/br-FR.xml similarity index 100% rename from src/Languages/br-FR.xml rename to src/ui/Languages/br-FR.xml diff --git a/src/Languages/ca-ES.xml b/src/ui/Languages/ca-ES.xml similarity index 100% rename from src/Languages/ca-ES.xml rename to src/ui/Languages/ca-ES.xml diff --git a/src/Languages/cs-CZ.xml b/src/ui/Languages/cs-CZ.xml similarity index 100% rename from src/Languages/cs-CZ.xml rename to src/ui/Languages/cs-CZ.xml diff --git a/src/Languages/da-DK.xml b/src/ui/Languages/da-DK.xml similarity index 100% rename from src/Languages/da-DK.xml rename to src/ui/Languages/da-DK.xml diff --git a/src/Languages/de-DE.xml b/src/ui/Languages/de-DE.xml similarity index 100% rename from src/Languages/de-DE.xml rename to src/ui/Languages/de-DE.xml diff --git a/src/Languages/el-GR.xml b/src/ui/Languages/el-GR.xml similarity index 98% rename from src/Languages/el-GR.xml rename to src/ui/Languages/el-GR.xml index a546f150e..43a26582f 100644 --- a/src/Languages/el-GR.xml +++ b/src/ui/Languages/el-GR.xml @@ -1,2783 +1,2783 @@ - - - - Subtitle Edit - 3.5.18 - Μετάφραση: Παναγιώτης Μητσάκης - el-GR - - &Εντάξει - &Ακύρωση - Εφαρμογή - Κανένα - Όλα - Προεπισκόπηση - Αρχεία υπότιτλου - Όλα τα αρχεία - Αρχεία βίντεο - Αρχεία ήχου - Άνοιγμα υπότιτλου... - Άνοιγμα αρχείου βίντεο... - Άνοιγμα αρχείου βίντεο... - Μη φορτωμένο βίντεο - Πληροφορίες βίντεο - Έναρξη - Λήξη - Διάρκεια - Χαρακτήρες/δευτερόλεπτο - Λέξεις/λεπτό - Ηθοποιός - Κενό - Περιοχή - # - Αριθμός - Κείμενο - Ώρες:λεπτά:δευτ.:χιλ. - Ώρες:λεπτά:δευτ:καρέ - Έντονα - Πλαγιαστά - Υπογραμμισμένα - Ορατό - Ρυθμός καρέ - Όνομα - Όνομα αρχείου: {0} ({1}) - Ανάλυση: {0} - Ρυθμός καρέ: {0:0.0###} - Σύνολο καρέ: {0:#,##0.##} - Κωδικοποίηση βίντεο: {0} - Μήκος ενιαίας γραμμής: - Συνολικό μήκος: {0} - Συνολικό μήκος: {0} (Διαχωρισμός!) - Διαχωρισμός! - Μη διαθέσιμο - Επικάλυψη προηγούμενης ({0:#,##0.###}) - Επικάλυψη ({0:#,##0.###}) - Επικάλυψη επόμενης ({0:#,##0.###}) - Αρνητικό - Η τυπική έκφραση δεν είναι έγκυρη! - Τρέχων υπότιτλος - Αρχικό κείμενο - Άνοιγμα αρχικού αρχείου υπότιτλου... - Παρακαλώ περιμένετε... - Κλειδί συνεδρίας - Όνομα χρήστη - Μη διαθέσιμο όνομα - Διεύθυνση ιστοσελίδας - Διεύθυνση IP - Βίντεο - {0} - Ήχος - {0} - Στοιχεία ελέγχου - {0} - Προηγμένες - - Στυλ/Γλώσσα - Χαρακτήρας - Κατηγορία - Γενικά - Γραμμή# - Προηγούμενη - Επόμενη - Μέγεθος - Αναζήτηση - Διαγραφή επιλεγμένης γραμμής - Πλάτος - Ύψος - Κατάρρευση - Συντόμευση: {0} - Παράδειγμα: {0} - - - Σχετικά με το Subtitle Edit - Το Subtitle Edit είναι ένα δωρεάν λογισμικό -υπό την άδεια δημόσιας χρήσης GNU. -Μπορείτε να το διανείμετε, να το τροποποιείτε -και να το χρησιμοποιείτε ελεύθερα. - -Ο κώδικας C# είναι διαθέσιμος στο https://github.com/SubtitleEdit/subtitleedit - -Επισκεφτείτε το www.nikse.dk για την τελευταία έκδοση. - -Οι προτάσεις σας είναι ευπρόσδεκτες. - -Email: mailto:nikse.dk@gmail.com - - - Προσθήκη στη λίστα ονομάτων - Προσθήκη στη λίστα ονομάτων (διάκριση πεζών-κεφαλαίων) - - - Προσθήκη στη λίστα αντικατάστασης του OCR - Προσθήκη ζεύγους στη λίστα αντικατάστασης του OCR (ευαίσθητο στα πεζά) - - - Προσθήκη στο λεξικό του χρήστη - Προσθήκη λέξης στο λεξικό του χρήστη (όχι ευαίσθητο στα πεζά) - - - Δημιουργία δεδομένων κυματομορφής - Πηγαίο αρχείο βίντεο: - Δημιουργία δεδομένων κυματομορφής - Αυτό μπορεί να πάρει μερικά λεπτά - παρακαλώ περιμένετε - Δεν βρέθηκε το πρόγραμμα VLC media player - Χρήση του VLC media player 1.1.χ ή νεότερο για την εξαγωγή δεδομένων ήχου. - Μετάβαση στην αρχική σελίδα του VLC media player; - Δημιουργία αρχείου αιχμής... - Δημιουργία φασματογραφήματος... - Εξαγωγή ήχου: {0:0.0} δευτερόλεπτα - Εξαγωγή ήχου: {0}.{1:00} λεπτά - Αδυναμία εύρεσης αρχείου κυματομορφής! -Αυτή η λειτουργεία απαιτεί VLC media player 1.1.x ή νεότερο ({ο}-bit). -Γραμμή εντολών: {1} {2} - Το {0} δεν εξήγαγε δεδομένα ήχου στο αρχείο κυματομορφής -Γραμμή εντολών: {1} {2} -Σημείωση: Ελέγξτε τον ελεύθερο χώρο δίσκου. - Μικρός χώρος δίσκου! - {0} ελεύθερου χώρου - Αδυναμία εύρεσης κομματιών ήχου! Δημιουργία κενής κυματομορφής; - - - Μαζική δημιουργία δεδομένων κυματομορφής - Εξαγωγή ήχου... - Υπολογισμός... - Έτοιμο - Σφάλμα - - - Προσαρμογή διαρκειών - Προσαρμογή μέσω - Δευτερολέπτων - Ποσοστού - Επαναϋπολογισμός - Προσθήκη δευτ. - Ορισμός ως ποσοστό διάρκειας - Σημείωση: Ο χρόνος εμφάνισης δεν θα επικαλύπτει την ώρα έναρξης του επόμενου κειμένου - Διορθωμένα - Χιλ. δευτερολέπτου - Μόνο επέκταση - - - Εφαρμογή ορίων διάρκειας - Διαθέσιμες διορθώσεις: {0} - Αδυναμία διόρθωσης: {0} - - - Ήχος σε κείμενο - Εξαγωγή ήχου χρησιμοποιώντας {0}... - Εξαγωγή κειμένου από ήχο χρησιμοποιώντας {0}... - Εξαγωγή κειμένου μέσω {0} πρόοδος: {1}% - Λιγότερα ▲ - Περισσότερα ▼ - - - Αυτόματη ισορροπία γραμμών - Αφαίρεση διασπάσεων από τις γραμμές - Εύρεση γραμμών: {0} - Διάσπαση γραμμών μεγαλύτερες από - Συνένωση γραμμών μεγαλύτερες από - - - Μαζική μετατροπή - Εισαγωγή - Εισαγωγή αρχείων (περιήγηση ή σύρσιμο) - Κατάσταση - Εξαγωγή - Αποθήκευση στον αρχικό φάκελο - Αποθήκευση στον φάκελο εξαγωγής - Αντικατάσταση αρχείων - - Χρήση αρχικού στυλ - Επιλογές μετατροπής - Αφαίρεση ετικετών μορφοποίησης - Αφαίρεση στυλ/ηθοποιού - Αφαίρεση κειμένου για κωφούς - Αντικατάσταση αρχικών αρχείων (νέα επέκταση, για αλλαγμένη μορφή) - Επανάληψη αρχικού γράμματος - Μετατροπή - Τίποτα για μετατροπή! - Παρακαλώ, επιλέξτε τον φάκελο εξαγωγής - Αποτυχία - Μετατράπηκαν - Ρυθμίσεις - Διόρθωση RTL - Διόρθωση RTL μέσω ετικετών Unicode - Αφαίρεση ετικετών Unicode RTL - Αντιστροφή αρχής/τέλους RTL - Διαχωρισμός μεγάλων γραμμών - Αυτόματη ισορροπία γραμμών - Σάρωση φακέλου... - Συμπερίληψη υποφακέλων - Ένωση κενών - Καθαρό κείμενο</PlainText> - <Ocr>OCR...</Ocr> - <Filter>Φίλτρο</Filter> - <FilterSkipped>Παραλείφτηκαν μέσω φίλτρου</FilterSkipped> - <FilterSrtNoUtf8BOM>Αρχεία SubRip (.srt) χωρίς UTF-8 BOM</FilterSrtNoUtf8BOM> - <FilterMoreThanTwoLines>Περισσότερες από δύο γραμμές</FilterMoreThanTwoLines> - <FilterContains>Το κείμενο περιέχει...</FilterContains> - <FilterFileNameContains>Το όνομα αρχείου περιέχει...</FilterFileNameContains> - <MkvLanguageCodeContains>Ο κωδικός γλώσσας Matroska (.mkv) περιέχει...</MkvLanguageCodeContains> - <FixCommonErrorsErrorX>Επιδιόρθωση σφαλμάτων: {0}</FixCommonErrorsErrorX> - <MultipleReplaceErrorX>Πολλαπλή αντικατάσταση: {0}</MultipleReplaceErrorX> - <AutoBalanceErrorX>Αυτόματη ισορρόπηση: {0}</AutoBalanceErrorX> - <OffsetTimeCodes>Αντιστάθμιση κωδικών χρόνου</OffsetTimeCodes> - <TransportStreamSettings>Μεταφορά ρυθμίσεων ροής</TransportStreamSettings> - <TransportStreamOverrideXPosition>Παράκαμψη αρχικής θέσης Χ</TransportStreamOverrideXPosition> - <TransportStreamOverrideYPosition>Παράκαμψη αρχικής θέσης Υ</TransportStreamOverrideYPosition> - <TransportStreamOverrideVideoSize>Παράκαμψη αρχικού μεγέθους βίντεο</TransportStreamOverrideVideoSize> - <TransportStreamFileNameEnding>Κατάληξη ονόματος αρχείου</TransportStreamFileNameEnding> - <TransportStreamSettingsButton>Ρυθμίσεις TS...</TransportStreamSettingsButton> - <RemoveLineBreaks>Αφαίρεση διάσπασης γραμμών</RemoveLineBreaks> - <DeleteLines>Διαγραφή γραμμών</DeleteLines> - <TryToUseSourceEncoding>Προσπάθεια χρήσης αρχικής κωδικοποίησης</TryToUseSourceEncoding> - <DeleteFirstLines>Διαγραφή πρώτων γραμμών</DeleteFirstLines> - <DeleteLastLines>Διαγραφή τελευταίων γραμμών</DeleteLastLines> - <DeleteContaining>Διαγραφή γραμμών που περιέχουν</DeleteContaining> - <MkvLanguageInOutputFileName>"Γλώσσα" στην εξαγωγή ονόματος αρχείου</MkvLanguageInOutputFileName> - <MkvLanguageInOutputFileNameX>Matroska (.mkv) "Γλώσσα" στην εξαγωγή ονόματος αρχείου: {0}</MkvLanguageInOutputFileNameX> - <MkvLanguageStyleTwoLetter>Κώδικες γλωσσών δύο γραμμάτων</MkvLanguageStyleTwoLetter> - <MkvLanguageStyleThreeLetter>Κώδικες γλωσσών τριών γραμμάτων</MkvLanguageStyleThreeLetter> - <MkvLanguageStyleEmpty>Χωρίς κώδικα γλώσσας</MkvLanguageStyleEmpty> - </BatchConvert> - <Beamer> - <Title>Βιντεοπροβολέας</Title> - </Beamer> - <Bookmarks> - <EditBookmark>Επεξεργασία σημείωσης</EditBookmark> - <AddBookmark>Προσθήκη σημείωσης</AddBookmark> - <GoToBookmark>Μετάβαση σε σημείωση</GoToBookmark> - </Bookmarks> - <ChangeCasing> - <Title>Αλλαγή πεζών-κεφαλαίων</Title> - <ChangeCasingTo>Αλλαγή πεζών-κεφαλαίων σε</ChangeCasingTo> - <NormalCasing>Κανονική. Οι προτάσεις ξεκινούν με κεφαλαίο γράμμα.</NormalCasing> - <FixNamesCasing>Διόρθωση ονομάτων (μέσω Dictionaries\NamesEtc.xml)</FixNamesCasing> - <FixOnlyNamesCasing>Διόρθωση μόνο ονομάτων (μέσω Dictionaries\NamesEtc.xml)</FixOnlyNamesCasing> - <OnlyChangeAllUppercaseLines>Αλλαγή μόνο των γραμμών με κεφαλαία.</OnlyChangeAllUppercaseLines> - <AllUppercase>Όλα κεφαλαία</AllUppercase> - <AllLowercase>Όλα πεζά</AllLowercase> - </ChangeCasing> - <ChangeCasingNames> - <Title>Αλλαγή πεζών-κεφαλαίων - Ονόματα</Title> - <NamesFoundInSubtitleX>Εύρεση ονομάτων στον υπότιτλο: {0}</NamesFoundInSubtitleX> - <Enabled>Ενεργοποιημένο</Enabled> - <Name>Όνομα</Name> - <LinesFoundX>Εύρεση γραμμών: {0}</LinesFoundX> - </ChangeCasingNames> - <ChangeFrameRate> - <Title>Αλλαγή ρυθμού καρέ</Title> - <ConvertFrameRateOfSubtitle>Μετατροπή ρυθμού καρέ του υπότιτλου</ConvertFrameRateOfSubtitle> - <FromFrameRate>Από ρυθμό καρέ</FromFrameRate> - <ToFrameRate>Σε ρυθμό καρέ</ToFrameRate> - <FrameRateNotCorrect>Λανθασμένος ρυθμός καρέ</FrameRateNotCorrect> - <FrameRateNotChanged>Ο Ρυθμός καρέ είναι ίδιος - τίποτα για μετατροπή</FrameRateNotChanged> - </ChangeFrameRate> - <ChangeSpeedInPercent> - <Title>Ρύθμιση ταχύτητας σε ποσοστό</Title> - <TitleShort>Ρύθμιση ταχύτητας</TitleShort> - <Info>Αλλαγή ταχύτητας των υποτίτλων σε ποσοστό</Info> - <Custom>Προσαρμοσμένη</Custom> - <ToDropFrame>Ρήξη καρέ</ToDropFrame> - <FromDropFrame>Από ρήξη καρέ</FromDropFrame> - </ChangeSpeedInPercent> - <CheckForUpdates> - <Title>Έλεγχος ενημερώσεων</Title> - <CheckingForUpdates>Έλεγχος για ενημερώσεις...</CheckingForUpdates> - <CheckingForUpdatesFailedX>Αποτυχία ελέγχου ενημέρωσης: {0}</CheckingForUpdatesFailedX> - <CheckingForUpdatesNoneAvailable>Χρήση της τελευταία έκδοσης του Subtitle Edit</CheckingForUpdatesNoneAvailable> - <CheckingForUpdatesNewVersion>Νέα διαθέσιμη έκδοση!</CheckingForUpdatesNewVersion> - <InstallUpdate>Μετάβαση στην ιστοσελίδα λήψης</InstallUpdate> - <NoUpdates>Ακύρωση ενημέρωσης</NoUpdates> - </CheckForUpdates> - <ChooseAudioTrack> - <Title>Επιλογή κομματιού ήχου</Title> - </ChooseAudioTrack> - <ChooseEncoding> - <Title>Επιλογή κωδικοποίησης</Title> - <CodePage>Σελίδα κώδικα</CodePage> - <DisplayName>Εμφάνιση ονόματος</DisplayName> - <PleaseSelectAnEncoding>Παρακαλώ, επιλέξτε μια κωδικοποίηση</PleaseSelectAnEncoding> - </ChooseEncoding> - <ChooseLanguage> - <Title>Επιλογή γλώσσας</Title> - <Language>Γλώσσα</Language> - </ChooseLanguage> - <ColorChooser> - <Title>Επιλογή χρώματος</Title> - <Red>Κόκκινο</Red> - <Green>Πράσινο</Green> - <Blue>Μπλε</Blue> - <Alpha>Άλφα</Alpha> - </ColorChooser> - <ColumnPaste> - <Title>Επικόλληση στηλών</Title> - <ChooseColumn>Επιλογή στηλών</ChooseColumn> - <OverwriteShiftCellsDown>Αντικατάσταση/Μετατόπιση κελιών κάτω</OverwriteShiftCellsDown> - <Overwrite>Αντικατάσταση</Overwrite> - <ShiftCellsDown>Μετατόπιση κελιών κάτω</ShiftCellsDown> - <TimeCodesOnly>Μόνο την κωδικοποίηση χρόνων</TimeCodesOnly> - <TextOnly>Μόνο το κείμενο</TextOnly> - <OriginalTextOnly>Μόνο το αρχικό κείμενο</OriginalTextOnly> - </ColumnPaste> - <CompareSubtitles> - <Title>Σύγκριση υπότιτλων</Title> - <PreviousDifference>&amp;Προηγούμενη διαφορά</PreviousDifference> - <NextDifference>&amp;Επόμενη διαφορά</NextDifference> - <SubtitlesNotAlike>Οι υπότιτλοι δεν έχουν ομοιότητες</SubtitlesNotAlike> - <XNumberOfDifference>Σύνολο διαφορών: {0}</XNumberOfDifference> - <XNumberOfDifferenceAndPercentChanged>Αριθμός διαφορών: {0} ({1:0.##}% αλλαγή των λέξεων)</XNumberOfDifferenceAndPercentChanged> - <XNumberOfDifferenceAndPercentLettersChanged>Αριθμός διαφορών: {0} ({1:0.##}% αλλαγή των γραμμάτων)</XNumberOfDifferenceAndPercentLettersChanged> - <ShowOnlyDifferences>Εμφάνιση μόνο διαφορών</ShowOnlyDifferences> - <IgnoreLineBreaks>Αγνόηση διάσπασης γραμμών</IgnoreLineBreaks> - <IgnoreFormatting>Αγνόηση μορφοποίησης</IgnoreFormatting> - <OnlyLookForDifferencesInText>Αναζήτηση μόνο διαφορών στο κείμενο</OnlyLookForDifferencesInText> - <CannotCompareWithImageBasedSubtitles>Δεν γίνεται σύγκριση με υπότιτλους από εικόνα</CannotCompareWithImageBasedSubtitles> - </CompareSubtitles> - <DCinemaProperties> - <Title>Ιδιότητες D-Cinema (interop)</Title> - <TitleSmpte>Ιδιότητες D-Cinema (SMPTE)</TitleSmpte> - <SubtitleId>Ταυτότητα υποτίτλου</SubtitleId> - <GenerateId>Δημιουργία ταυτότητας</GenerateId> - <MovieTitle>Τίτλος ταινίας</MovieTitle> - <ReelNumber>Αριθμός μπομπίνας</ReelNumber> - <Language>Γλώσσα</Language> - <IssueDate>Ημερομηνία έκδοσης</IssueDate> - <EditRate>Επεξεργασία ρυθμού</EditRate> - <TimeCodeRate>Ρυθμός κώδικα χρόνου</TimeCodeRate> - <StartTime>Έναρξη</StartTime> - <Font>Γραμματοσειρά</Font> - <FontId>Ταυτότητα</FontId> - <FontUri>URI</FontUri> - <FontColor>Χρώμα</FontColor> - <FontEffect>Εφέ</FontEffect> - <FontEffectColor>Χρώμα εφέ</FontEffectColor> - <FontSize>Μέγεθος</FontSize> - <TopBottomMargin>Περιθώριο πάνω/κάτω</TopBottomMargin> - <FadeUpTime>Χρόνος εμφάνισης εφέ</FadeUpTime> - <FadeDownTime>Χρόνος εξαφάνισης εφέ</FadeDownTime> - <ZPosition>Κάθετη θέση</ZPosition> - <ZPositionHelp>Θετικοί αριθμοί μετακινούν το κείμενο μακριά, αρνητικοί αριθμοί μετακινούν το κείμενο κοντά. -Εάν η κάθετη θέση είναι μηδέν, τότε είναι 2D.</ZPositionHelp> - <ChooseColor>Επιλογή χρώματος...</ChooseColor> - <Generate>Δημιουργία</Generate> - </DCinemaProperties> - <DurationsBridgeGaps> - <Title>Ένωση μικρών κενών μεταξύ γραμμών</Title> - <GapsBridgedX>Αριθμός ενωμένων μικρών κενών: {0}</GapsBridgedX> - <GapToNext>Κενό ως το επόμενο σε δευτερόλεπτα</GapToNext> - <GapToNextFrames>Κενό ως το επόμενο σε καρέ</GapToNextFrames> - <BridgeGapsSmallerThanXPart1>Ένωση κενών μικρότερων από</BridgeGapsSmallerThanXPart1> - <BridgeGapsSmallerThanXPart2>χιλιοστά δευτερολέπτου</BridgeGapsSmallerThanXPart2> - <BridgeGapsSmallerThanXPart1Frames>Ένωση κενών μικρότερων από</BridgeGapsSmallerThanXPart1Frames> - <BridgeGapsSmallerThanXPart2Frames>καρέ</BridgeGapsSmallerThanXPart2Frames> - <MinMillisecondsBetweenLines>Ελάχιστα χιλ. δευτερολέπτου μεταξύ των γραμμών</MinMillisecondsBetweenLines> - <MinFramesBetweenLines>Ελάχιστα καρέ μεταξύ γραμμών</MinFramesBetweenLines> - <ProlongEndTime>Το προηγούμενο κείμενο παίρνει όλα τα κενά χρόνου</ProlongEndTime> - <DivideEven>Το κείμενο χωρίζει τα κενά χρόνου</DivideEven> - </DurationsBridgeGaps> - <DvdSubRip> - <Title>Αντιγραφή υποτίτλων από IFO/VOB (DVD)</Title> - <DvdGroupTitle>Αρχεία/Πληροφορίες DVD</DvdGroupTitle> - <IfoFile>Αρχείο IFO</IfoFile> - <IfoFiles>Αρχεία IFO</IfoFiles> - <VobFiles>Αρχεία VOB</VobFiles> - <Add>Προσθήκη</Add> - <Remove>Αφαίρεση</Remove> - <Clear>Καθαρισμός</Clear> - <MoveUp>Μετακίνηση επάνω</MoveUp> - <MoveDown>Μετακίνηση κάτω</MoveDown> - <Languages>Γλώσσες</Languages> - <PalNtsc>PAL/NTSC</PalNtsc> - <Pal>PAL (25 fps)</Pal> - <Ntsc>NTSC (29.9 fps)</Ntsc> - <StartRipping>Εκκίνηση αντιγραφής</StartRipping> - <Abort>Ματαίωση</Abort> - <AbortedByUser>Ματαιώθηκε από τον χρήστη</AbortedByUser> - <ReadingSubtitleData>Ανάγνωση δεδομένων υποτίτλου...</ReadingSubtitleData> - <RippingVobFileXofYZ>Αντιγραφή αρχείων vob {1} από {2}: {0}</RippingVobFileXofYZ> - <WrongIfoType>Ο τύπος IFO είναι '{0}' και όχι 'DVDVIDEO-VTS'.{1}Προσπαθείστε με ένα άλλο αρχείο εκτός του {2}</WrongIfoType> - </DvdSubRip> - <DvdSubRipChooseLanguage> - <Title>Επιλογή γλώσσας</Title> - <ChooseLanguageStreamId>Επιλογή γλώσσας (id-ροής)</ChooseLanguageStreamId> - <UnknownLanguage>Άγνωστη γλώσσα</UnknownLanguage> - <SubtitleImageXofYAndWidthXHeight>Εικόνα υπότιτλου {0}/{1} - {2}x{3}</SubtitleImageXofYAndWidthXHeight> - <SubtitleImage>Εικόνα υπότιτλου</SubtitleImage> - </DvdSubRipChooseLanguage> - <EbuSaveOptions> - <Title>Επιλογές αποθήκευσης τύπου EBU</Title> - <GeneralSubtitleInformation>Γενικές πληροφορίες υπότιτλου</GeneralSubtitleInformation> - <CodePageNumber>Αριθμός σελίδας κώδικα</CodePageNumber> - <DiskFormatCode>Κωδικός μορφής δίσκου</DiskFormatCode> - <DisplayStandardCode>Προβολή τυπικού κώδικα</DisplayStandardCode> - <ColorRequiresTeletext>Τα χρώματα απαιτούν τηλεκείμενο!</ColorRequiresTeletext> - <AlignmentRequiresTeletext>Η στοίχιση απαιτεί τηλεκείμενο!</AlignmentRequiresTeletext> - <TeletextCharsShouldBe38>Οι μέγιστοι χαρακτήρες τηλεκειμένου ανά σειρά θα πρέπει να είναι 38!</TeletextCharsShouldBe38> - <CharacterCodeTable>Πίνακας χαρακτήρων</CharacterCodeTable> - <LanguageCode>Κωδικός γλώσσας</LanguageCode> - <OriginalProgramTitle>Πρωτότυπος τίτλος προγράμματος</OriginalProgramTitle> - <OriginalEpisodeTitle>Πρωτότυπος τίτλος επεισόδιου</OriginalEpisodeTitle> - <TranslatedProgramTitle>Μεταφρασμένος τίτλος προγράμματος</TranslatedProgramTitle> - <TranslatedEpisodeTitle>Μεταφρασμένος τίτλος επεισοδίου</TranslatedEpisodeTitle> - <TranslatorsName>Όνομα του μεταφραστή</TranslatorsName> - <SubtitleListReferenceCode>Κωδικός αναφοράς της λίστας υπότιτλων</SubtitleListReferenceCode> - <CountryOfOrigin>Χώρα καταγωγής</CountryOfOrigin> - <TimeCodeStatus>Κατάσταση χρόνου κώδικα</TimeCodeStatus> - <TimeCodeStartOfProgramme>Χρόνος κώδικα: Έναρξη προγράμματος</TimeCodeStartOfProgramme> - <RevisionNumber>Αριθμός αναθεώρησης</RevisionNumber> - <MaxNoOfDisplayableChars>Μέγιστος αριθμός χαρακτήρων ανά σειρά</MaxNoOfDisplayableChars> - <MaxNumberOfDisplayableRows>Μέγιστος αριθμός γραμμών</MaxNumberOfDisplayableRows> - <DiskSequenceNumber>Αύξων αριθμός δίσκου</DiskSequenceNumber> - <TotalNumberOfDisks>Συνολικός αριθμός δίσκων</TotalNumberOfDisks> - <Import>Εισαγωγή...</Import> - <TextAndTimingInformation>Πληροφορίες κειμένου και χρονισμού</TextAndTimingInformation> - <JustificationCode>Κωδικός αιτιολόγησης</JustificationCode> - <VerticalPosition>Κάθετη θέση</VerticalPosition> - <MarginTop>Άνω περιθώριο (για άνω στοιχισμένους υπότιτλους)</MarginTop> - <MarginBottom>Κάτω περιθώριο (για κάτω στοιχισμένους υπότιτλους)</MarginBottom> - <NewLineRows>Αριθμός προσθήκης σειρών μετά από νέα σειρά</NewLineRows> - <Teletext>Τηλεκείμενο</Teletext> - <UseBox>Χρήση πλαισίου για το κείμενο</UseBox> - <DoubleHeight>Χρήση διπλού ύψους για το κείμενο</DoubleHeight> - <Errors>Λάθη</Errors> - <ErrorsX>Λάθη: {0}</ErrorsX> - <MaxLengthError>Η Γραμμή {0} υπερβαίνει το μέγιστο μήκος ({1}) κατά {2}: {3}</MaxLengthError> - <TextUnchangedPresentation>Αμετάβλητη παρουσίαση</TextUnchangedPresentation> - <TextLeftJustifiedText>Αριστερά στοιχισμένο κείμενο</TextLeftJustifiedText> - <TextCenteredText>Κεντραρισμένο κείμενο</TextCenteredText> - <TextRightJustifiedText>Δεξιά στοιχισμένο κείμενο</TextRightJustifiedText> - <UseBoxForOneNewLine>Επιλογή 'Χρήση πλαισίου κειμένου' μόνο για μία νέα γραμμή</UseBoxForOneNewLine> - </EbuSaveOptions> - <EffectKaraoke> - <Title>Εφέ καραόκε</Title> - <ChooseColor>Επιλογή χρώματος:</ChooseColor> - <TotalMilliseconds>Συνολικά χιλ. δευτερολέπτου:</TotalMilliseconds> - <EndDelayInMilliseconds>Καθυστέρηση λήξης σε χιλ. δευτερολέπτου:</EndDelayInMilliseconds> - </EffectKaraoke> - <EffectTypewriter> - <Title>Εφέ γραφομηχανής</Title> - <TotalMilliseconds>Συνολικά χιλ. δευτερολέπτου:</TotalMilliseconds> - <EndDelayInMilliseconds>Καθυστέρηση λήξης σε χιλ. δευτερολέπτου:</EndDelayInMilliseconds> - </EffectTypewriter> - <ExportCustomText> - <Title>Εξαγωγή προσαρμοσμένης μορφής κειμένου</Title> - <Formats>Μορφές</Formats> - <New>Νέο</New> - <Edit>Επεξεργασία</Edit> - <Delete>Διαγραφή</Delete> - <SaveAs>Α&amp;ποθήκευση ως...</SaveAs> - <SaveSubtitleAs>Αποθήκευση υπότιτλου ως...</SaveSubtitleAs> - <SubtitleExportedInCustomFormatToX>Οι υπότιτλοι εξάγωνται σε προσαρμοσμένη μορφή στο: {0}</SubtitleExportedInCustomFormatToX> - </ExportCustomText> - <ExportCustomTextFormat> - <Title>Πρότυπο προσαρμοσμένης μορφής κειμένου</Title> - <Template>Πρότυπο</Template> - <Header>Επικεφαλίδα</Header> - <TextLine>Γραμμή κειμένου (παράγραφος)</TextLine> - <TimeCode>Κωδικός χρόνου</TimeCode> - <NewLine>Νέα γραμμή</NewLine> - <Footer>Υποσέλιδο</Footer> - <DoNotModify>[Χωρίς επεξεργασία]</DoNotModify> - </ExportCustomTextFormat> - <ExportFcpXmlAdvanced> - <Title>Εξαγωγή Final Cut Pro XML advanced</Title> - <FontName>Όνομα γραμματοσειράς</FontName> - <FontSize>Μέγεθος γραμματοσειράς</FontSize> - <FontFace>Όψη γραμματοσειράς</FontFace> - <FontFaceRegular>Κλασική</FontFaceRegular> - <Alignment>Ευθυγράμμιση</Alignment> - <Baseline>Κανονική</Baseline> - </ExportFcpXmlAdvanced> - <ExportPngXml> - <Title>Εξαγωγή XML/PNG</Title> - <ImageSettings>Ρυθμίσεις εικόνας</ImageSettings> - <FontFamily>Οικογένεια γραμματοσειράς</FontFamily> - <FontSize>Μέγεθος γραμματοσειράς</FontSize> - <FontColor>Χρώμα γραμματοσειράς</FontColor> - <BorderColor>Χρώμα περιγράμματος</BorderColor> - <BorderWidth>Πλάτος περιγράμματος</BorderWidth> - <BorderStyle>Στυλ περιγράμματος</BorderStyle> - <BorderStyleOneBox>Ένα πλαίσιο</BorderStyleOneBox> - <BorderStyleBoxForEachLine>Πλαίσιο για κάθε γραμμή</BorderStyleBoxForEachLine> - <BorderStyleNormalWidthX>Κανονικό, πάχος={0}</BorderStyleNormalWidthX> - <ShadowColor>Χρώμα σκιάς</ShadowColor> - <ShadowWidth>Πάχος σκιάς</ShadowWidth> - <Transparency>Αρχική</Transparency> - <ImageFormat>Μορφή εικόνας</ImageFormat> - <FullFrameImage>Εικόνα πλήρης απεικόνισης</FullFrameImage> - <SimpleRendering>Απλή απεικόνιση</SimpleRendering> - <AntiAliasingWithTransparency>Διαφανής εξομάλυνση</AntiAliasingWithTransparency> - <Text3D>3D</Text3D> - <SideBySide3D>Κέντρο - Δεξιά - Αριστερά</SideBySide3D> - <HalfTopBottom3D>Κέντρο - Πάνω/Κάτω</HalfTopBottom3D> - <Depth>Βάθος</Depth> - <ExportAllLines>Εξαγωγή όλων των γραμμών...</ExportAllLines> - <XImagesSavedInY>{0} εικόνες αποθηκεύτηκαν στον φάκελο {1}</XImagesSavedInY> - <VideoResolution>Ανάλυση βίντεο</VideoResolution> - <Align>Στοίχιση</Align> - <Left>Αριστερά</Left> - <Right>Δεξιά</Right> - <Center>Κέντρο</Center> - <CenterLeftJustify>Κέντρο, στοίχιση αριστερά</CenterLeftJustify> - <CenterLeftJustifyDialogs>Κέντρο, αριστερή στοίχιση διαλόγου</CenterLeftJustifyDialogs> - <CenterTopJustify>Κέντρο, άνω στοίχιση</CenterTopJustify> - <CenterRightJustify>Κέντρο, δεξιά στοίχιση</CenterRightJustify> - <BottomMargin>Κάτω περιθώριο</BottomMargin> - <LeftRightMargin>Αριστερό/δεξί περιθώριο</LeftRightMargin> - <SaveBluRraySupAs>Επιλογή ονόματος αρχείου Blu-ray sup</SaveBluRraySupAs> - <SaveVobSubAs>Επιλογή ονόματος αρχείου VobSub</SaveVobSubAs> - <SaveFabImageScriptAs>Επιλογή ονόματος αρχείου Blu-ray sup</SaveFabImageScriptAs> - <SaveDvdStudioProStlAs>Επιλογή ονόματος αρχείου DVD Studio Pro STL</SaveDvdStudioProStlAs> - <SaveDigitalCinemaInteropAs>Επιλογή ονόματος αρχείου Digital Cinema Interop</SaveDigitalCinemaInteropAs> - <SaveDigitalCinemaSmpte2014>Επιλογή ονόματος αρχείου Digital SMPTE 2014</SaveDigitalCinemaSmpte2014> - <SavePremiereEdlAs>Επιλογή ονόματος αρχείου Premiere EDL</SavePremiereEdlAs> - <SaveFcpAs>Επιλογή ονόματος αρχείου Final Cut Pro xml</SaveFcpAs> - <SaveDostAs>Επιλογή ονόματος αρχείου DoStudio dost</SaveDostAs> - <SomeLinesWereTooLongX>Μερικές πολύ μεγάλες γραμμές:{0}</SomeLinesWereTooLongX> - <LineHeight>Ύψος γραμμής</LineHeight> - <BoxSingleLine>Πλαίσιο - ενιαία γραμμή</BoxSingleLine> - <BoxMultiLine>Πλαίσιο - πολλαπλή γραμμή</BoxMultiLine> - <Forced>Επιβολή</Forced> - <ChooseBackgroundColor>Επιλογή χρώματος φόντου</ChooseBackgroundColor> - <SaveImageAs>Αποθήκευση εικόνας ως...</SaveImageAs> - <FcpUseFullPathUrl>Χρήση πλήρης διεύθυνσης url εικόνας για FCP xml</FcpUseFullPathUrl> - </ExportPngXml> - <ExportText> - <Title>Εξαγωγή κειμένου</Title> - <Preview>Προεπισκόπηση</Preview> - <ExportOptions>Εξαγωγή επιλογών</ExportOptions> - <FormatText>Μορφοποίηση κειμένου</FormatText> - <None>Κανένα</None> - <MergeAllLines>Συγχώνευση όλων των γραμμών</MergeAllLines> - <UnbreakLines>Συνένωση γραμμών</UnbreakLines> - <RemoveStyling>Αφαίρεση ύφους</RemoveStyling> - <ShowLineNumbers>Προβολή αριθμών γραμμής</ShowLineNumbers> - <AddNewLineAfterLineNumber>Προσθήκη νέας γραμμής μετά από τον αριθμό γραμμής</AddNewLineAfterLineNumber> - <ShowTimeCode>Εμφάνιση κωδικοποίησης χρόνου</ShowTimeCode> - <AddNewLineAfterTimeCode>Προσθήκη νέας γραμμής μετά την κωδικοποίηση χρόνου</AddNewLineAfterTimeCode> - <AddNewLineAfterTexts>Προσθήκη νέας γραμμής μετά το κείμενο</AddNewLineAfterTexts> - <AddNewLineBetweenSubtitles>Προσθήκη νέας γραμμής μεταξύ των υποτίτλων</AddNewLineBetweenSubtitles> - <TimeCodeFormat>Μορφή κώδικοποίησης χρόνου</TimeCodeFormat> - <Srt>.srt</Srt> - <Milliseconds>Χιλιοστά δευτερολέπτου</Milliseconds> - <HHMMSSFF>ΩΩ:ΛΛ:ΔΔ:ΚΚ</HHMMSSFF> - <TimeCodeSeparator>Διαχωρισμός κωδικοποίησης χρόνου</TimeCodeSeparator> - </ExportText> - <ExtractDateTimeInfo> - <Title>Δημιουργία χρόνου ως κείμενο</Title> - <OpenVideoFile>Επιλογή αρχείου βίντεο από όπου θα εξαχθούν οι πληροφορίες ημέρας/χρόνου</OpenVideoFile> - <StartFrom>Έναρξη από</StartFrom> - <DateTimeFormat>Μορφή ημέρας/χρόνου</DateTimeFormat> - <Example>Παράδειγμα</Example> - <GenerateSubtitle>&amp;Δημιουργία υποτίτλων</GenerateSubtitle> - </ExtractDateTimeInfo> - <FindDialog> - <Title>Εύρεση</Title> - <Find>Εύρεση</Find> - <Normal>&amp;Κανονική</Normal> - <CaseSensitive>&amp;Διάκριση πεζών-κεφαλαίων</CaseSensitive> - <RegularExpression>Τυπική έκφραση</RegularExpression> - <WholeWord>Ολόκληρη τη λέξη</WholeWord> - <Count>Μέτρηση</Count> - <XNumberOfMatches>{0:#,##0} αντιστοιχίες</XNumberOfMatches> - <OneMatch>Μία αντιστοιχία</OneMatch> - </FindDialog> - <FindSubtitleLine> - <Title>Εύρεση γραμμής υπότιτλου</Title> - <Find>&amp;Εύρεση</Find> - <FindNext>Εύρεση ε&amp;πόμενου</FindNext> - </FindSubtitleLine> - <FixCommonErrors> - <Title>Επιδιόρθωση σφαλμάτων</Title> - <Step1>Βήμα 1/2 - Επιλογή σφαλμάτων</Step1> - <WhatToFix>Προς διόρθωση</WhatToFix> - <Example>Παράδειγμα</Example> - <SelectAll>Όλα</SelectAll> - <InverseSelection>Αντιστροφή</InverseSelection> - <Back>&lt; &amp;Πίσω</Back> - <Next>&amp;Επόμενο &gt;</Next> - <Step2>Βήμα 2/2 - Επαλήθευση διορθώσεων</Step2> - <Fixes>Επιδιορθώσεις</Fixes> - <Log>Αρχείο καταγραφής</Log> - <Function>Συνάρτηση</Function> - <RemovedEmptyLine>Αφαίρεση κενής γραμμής</RemovedEmptyLine> - <RemovedEmptyLineAtTop>Αφαίρεση κενής γραμμής στην κορυφή</RemovedEmptyLineAtTop> - <RemovedEmptyLineAtBottom>Αφαίρεση κενής γραμμής στο τέλος</RemovedEmptyLineAtBottom> - <RemovedEmptyLineInMiddle>Αφαίρεση κενής γραμμής στο κέντρο</RemovedEmptyLineInMiddle> - <RemovedEmptyLinesUnsedLineBreaks>Αφαίρεση κενών γραμμών/άχρηστες αλλαγές γραμμής</RemovedEmptyLinesUnsedLineBreaks> - <EmptyLinesRemovedX>Αφαιρεμένες κενές γραμμές: {0}</EmptyLinesRemovedX> - <FixOverlappingDisplayTimes>Επιδιόρθωση επικαλυπτόμενων χρόνων εμφάνισης</FixOverlappingDisplayTimes> - <FixShortDisplayTimes>Επιδιόρθωση σύντομων χρόνων εμφάνισης</FixShortDisplayTimes> - <FixLongDisplayTimes>Επιδιόρθωση μεγάλων χρόνων εμφάνισης</FixLongDisplayTimes> - <FixShortGaps>Επιδιόρθωση μικρών κενών</FixShortGaps> - <FixInvalidItalicTags>Επιδιόρθωση λανθασμένων ετικετών πλαγιαστής γραφής</FixInvalidItalicTags> - <RemoveUnneededSpaces>Αφαίρεση περιττών διαστημάτων</RemoveUnneededSpaces> - <RemoveUnneededPeriods>Αφαίρεση περιττών τελειών</RemoveUnneededPeriods> - <FixCommas>Επιδιόρθωση κομμάτων</FixCommas> - <FixMissingSpaces>Επιδιόρθωση διαστημάτων</FixMissingSpaces> - <BreakLongLines>Διάσπαση μεγάλων γραμμών</BreakLongLines> - <RemoveLineBreaks>Αφαίρεση αλλαγών γραμμής σε μικρά κείμενα με μία μόνο πρόταση</RemoveLineBreaks> - <RemoveLineBreaksAll>Αφαίρεση αλλαγών γραμμής σε μικρά κείμενα (εκτός διαλόγου)</RemoveLineBreaksAll> - <FixUppercaseIInsindeLowercaseWords>Επιδιόρθωση κεφαλαίου 'i' σε πεζές λέξεις (σφάλμα OCR)</FixUppercaseIInsindeLowercaseWords> - <FixDoubleApostrophes>Επιδιόρθωση διπλής αποστρόφου ('') σε εισαγωγικό (")</FixDoubleApostrophes> - <AddPeriods>Προσθήκη τελείας</AddPeriods> - <StartWithUppercaseLetterAfterParagraph>Έναρξη με κεφαλαίο γράμμα μετά από παράγραφο</StartWithUppercaseLetterAfterParagraph> - <StartWithUppercaseLetterAfterPeriodInsideParagraph>Έναρξη με κεφαλαίο γράμμα μετά από τελεία</StartWithUppercaseLetterAfterPeriodInsideParagraph> - <StartWithUppercaseLetterAfterColon>Έναρξη με κεφαλαίο γράμμα μετά από σημεία στίξης</StartWithUppercaseLetterAfterColon> - <FixLowercaseIToUppercaseI>Επιδιόρθωση πεζού 'i' σε 'Ι' (Αγγλικά)</FixLowercaseIToUppercaseI> - <FixCommonOcrErrors>Επιδιόρθωση κοινών σφαλμάτων OCR (με χρήση καταλόγου αντικατάστασης OCR)</FixCommonOcrErrors> - <CommonOcrErrorsFixed>Επιδιορθώσεις κοινών σφαλμάτων OCR (χρήση του αρχείου OcrReplaceList): {0}</CommonOcrErrorsFixed> - <RemoveSpaceBetweenNumber>Αφαίρεση διαστήματος μεταξύ αριθμών</RemoveSpaceBetweenNumber> - <FixDialogsOnOneLine>Επιδιόρθωση διαλόγων</FixDialogsOnOneLine> - <NormalizeStrings>Κανονικοποίηση συμβολοσειρών</NormalizeStrings> - <RemoveSpaceBetweenNumbersFixed>Επιδιορθώσεις αφαίρεσης διαστήματος μεταξύ αριθμών: {0}</RemoveSpaceBetweenNumbersFixed> - <FixTurkishAnsi>Επιδιόρθωση Τουρκικών ANSI (Ισλανδικών) γραμμάτων σε Unicode</FixTurkishAnsi> - <FixDanishLetterI>Επιδιόρθωση δανικού γράμματος 'i'</FixDanishLetterI> - <FixSpanishInvertedQuestionAndExclamationMarks>Επιδιόρθωση ισπανικών αντεστραμμένων σημείων στίξης</FixSpanishInvertedQuestionAndExclamationMarks> - <AddMissingQuote>Προσθήκη εισαγωγικού (")</AddMissingQuote> - <AddMissingQuotes>Προσθήκη εισαγωγικών (")</AddMissingQuotes> - <RemoveHyphensSingleLine>Αφαίρεση παύλας σε ενιαίες γραμμές</RemoveHyphensSingleLine> - <XHyphensSingleLineRemoved>Αφαίρεση παυλών: {0}</XHyphensSingleLineRemoved> - <FixHyphensInDialogs>Επιδιόρθωση παυλών μέσω στυλ διαλόγου: {0}</FixHyphensInDialogs> - <XHyphensInDialogsFixed>Επιδιόρθωση παυλών: {0}</XHyphensInDialogsFixed> - <AddMissingQuotesExample>"Πώς είσαι; -&gt; "Πώς είσαι;"</AddMissingQuotesExample> - <XMissingQuotesAdded>Προσθήκη εισαγωγικών: {0}</XMissingQuotesAdded> - <Fix3PlusLines>Επιδιόρθωση υποτίτλων με περισσότερες από δύο γραμμές</Fix3PlusLines> - <Fix3PlusLine>Επιδιόρθωση υπότιτλου με περισσότερες από δύο γραμμές</Fix3PlusLine> - <X3PlusLinesFixed>Επιδιόρθωση υποτίτλων με περισσότερες από δύο γραμμές: {0}</X3PlusLinesFixed> - <Analysing>Ανάλυση...</Analysing> - <NothingToFix>Τίποτα για επιδιόρθωση</NothingToFix> - <FixesFoundX>Εύρεση επιδιορθώσεων: {0}</FixesFoundX> - <XFixesApplied>Εφαρμοσμένες επιδιορθώσεις: {0}</XFixesApplied> - <NothingFixableBut>Τίποτα για αυτόματη επιδιόρθωση. Ο υπότιτλος περιέχει σφάλμα(τα) - προβολή αρχείου καταγραφής</NothingFixableBut> - <XFixedBut>Επιδιόρθωση {0} θέματος(ων), αλλά υπάρχουν ακόμη σφάλματα - προβολή αρχείου καταγραφής</XFixedBut> - <XCouldBeFixedBut>Επιδιόρθωση {0} θέματος(ων), αλλά θα υπάρχουν ακόμη σφάλματα - προβολή αρχείου καταγραφής</XCouldBeFixedBut> - <UncheckedFixLowercaseIToUppercaseI>Αποεπιλογή "Επιδιόρθωση μονού πεζού 'i' σε 'Ι' (Αγγλικά)"</UncheckedFixLowercaseIToUppercaseI> - <XIsChangedToUppercase>{0} άλλαγή(ές) σε κεφαλαία</XIsChangedToUppercase> - <FixFirstLetterToUppercaseAfterParagraph>Επιδιόρθωση αρχικού γράμματος σε κεφαλαίο μετά από παράγραφο</FixFirstLetterToUppercaseAfterParagraph> - <MergeShortLine>Συγχώνευση γραμμών</MergeShortLine> - <MergeShortLineAll>Συγχώνευση γραμμών (εκτός διαλόγου)</MergeShortLineAll> - <XLineBreaksAdded>Προσθήκη {0} αλλαγής(ών) γραμμής</XLineBreaksAdded> - <BreakLongLine>Διάσπαση γραμμής</BreakLongLine> - <FixLongDisplayTime>Επιδιόρθωση μεγάλου χρόνου</FixLongDisplayTime> - <FixInvalidItalicTag>Επιδιόρθωση ετικέτας πλαγιαστής γραφής</FixInvalidItalicTag> - <FixShortDisplayTime>Επιδιόρθωση σύντομου χρόνου</FixShortDisplayTime> - <FixOverlappingDisplayTime>Επιδιόρθωση επικαλυπτόμενου χρόνου</FixOverlappingDisplayTime> - <FixShortGap>Επιδιόρθωση μικρών κενών</FixShortGap> - <FixInvalidItalicTagsExample>&lt;i&gt;Δεν με ενδιαφέρει.&lt;i&gt; -&gt; &lt;i&gt;Δεν με ενδιαφέρει.&lt;/i&gt;</FixInvalidItalicTagsExample> - <RemoveUnneededSpacesExample>Εσύ , εκεί. -&gt; Εσύ, εκεί.</RemoveUnneededSpacesExample> - <RemoveUnneededPeriodsExample>Εσύ!. -&gt; Εσύ!</RemoveUnneededPeriodsExample> - <FixMissingSpacesExample>Έι.Εσύ. -&gt; Έι. Εσύ.</FixMissingSpacesExample> - <FixUppercaseIInsindeLowercaseWordsExample>The Earth is fIat. -&gt; The Earth is flat.</FixUppercaseIInsindeLowercaseWordsExample> - <FixLowercaseIToUppercaseIExample>What do i care. -&gt; What do I care.</FixLowercaseIToUppercaseIExample> - <StartTimeLaterThanEndTime>Κείμενο με αριθμό {0}: Έναρξη αργότερα από λήξη: {4}{1} -&gt; {2} {3}</StartTimeLaterThanEndTime> - <UnableToFixStartTimeLaterThanEndTime>Αδυναμία επιδιόρθωσης του κειμένου με αριθμό {0}: Έναρξη αργότερα από λήξη: {1}</UnableToFixStartTimeLaterThanEndTime> - <XFixedToYZ>Επιδιόρθωση {0} σε: {1}{2}</XFixedToYZ> - <UnableToFixTextXY>Αδυναμία επιδιόρθωσης του κειμένου με αριθμό {0}: {1}</UnableToFixTextXY> - <XOverlappingTimestampsFixed>Επιδιόρθωση {0} επικαλυπτόμενου(ων) χρόνου(ων)</XOverlappingTimestampsFixed> - <XDisplayTimesProlonged>Επέκταση {0} χρόνου(ων) εμφάνισης</XDisplayTimesProlonged> - <XInvalidHtmlTagsFixed>Επιδιόρθωση {0} λανθασμένης(ων) ετικέτας(ών) HTML</XInvalidHtmlTagsFixed> - <XDisplayTimesShortned>Σμίκρυνση {0} χρόνου(ων) εμφάνισης</XDisplayTimesShortned> - <XGapsFixed>Επιδιόρθωση {0} μικρού(ών) κενού(ών)</XGapsFixed> - <XLinesUnbreaked>Συνένωση {0} γραμμής(ών)</XLinesUnbreaked> - <UnneededSpace>Αχρείαστο διάστημα</UnneededSpace> - <XUnneededSpacesRemoved>Αφαίρεση {0} αχρείαστου(ων) διαστήματος(ων)</XUnneededSpacesRemoved> - <UnneededPeriod>Αχρείαστη τελεία</UnneededPeriod> - <XUnneededPeriodsRemoved>Αφαίρεση {0} αχρείαστης(ων) τελείας(ών)</XUnneededPeriodsRemoved> - <FixMissingSpace>Επιδιόρθωση διαστήματος</FixMissingSpace> - <XMissingSpacesAdded>Προσθήκη {0} διαστήματος(ων)</XMissingSpacesAdded> - <FixUppercaseIInsideLowercaseWord>Επιδιόρθωση κεφαλαίου 'i' μέσα σε λέξη</FixUppercaseIInsideLowercaseWord> - <XPeriodsAdded>Προσθήκη {0} τελείας(ών)</XPeriodsAdded> - <FixMissingPeriodAtEndOfLine>Προσθήκη τελείας στο τέλος πρότασης</FixMissingPeriodAtEndOfLine> - <XDoubleApostrophesFixed>Επιδιόρθωση {0} διπλών αποστρόφων</XDoubleApostrophesFixed> - <XUppercaseIsFoundInsideLowercaseWords>Εύρεση {0} κεφαλαίου(ων) 'i' μέσα σε λέξη(εις)</XUppercaseIsFoundInsideLowercaseWords> - <RefreshFixes>Ανανέωση</RefreshFixes> - <ApplyFixes>Εφαρμογή</ApplyFixes> - <AutoBreak>&amp;Διάσπαση</AutoBreak> - <Unbreak>&amp;Συνένωση</Unbreak> - <FixDoubleDash>Επιδιόρθωση '--' -&gt; '...'</FixDoubleDash> - <FixDoubleGreaterThan>Αφαίρεση '&gt;&gt;'</FixDoubleGreaterThan> - <FixEllipsesStart>Αφαίρεση αρχικού '...'</FixEllipsesStart> - <FixMissingOpenBracket>Επιδιόρθωση ελλιπής [</FixMissingOpenBracket> - <FixMusicNotation>Αντικατάσταση μουσικού συμβόλου (π.χ. âTª)</FixMusicNotation> - <XFixDoubleDash>Επιδιόρθωση {0} '--'</XFixDoubleDash> - <XFixDoubleGreaterThan>Αφαίρεση {0} &gt;&gt;</XFixDoubleGreaterThan> - <XFixEllipsesStart>Αφαίρεση {0} '...' από αρχή γραμμής</XFixEllipsesStart> - <XFixMissingOpenBracket>Επιδιόρθωση {0} ελλιπούςς(ών) [</XFixMissingOpenBracket> - <XFixMusicNotation>Αντικατάσταση {0} μουσικού(ών) συμβόλου(ων)</XFixMusicNotation> - <FixDoubleDashExample>'Τι-- αα ναι!' -&gt; 'Τι... αα ναι!'</FixDoubleDashExample> - <FixDoubleGreaterThanExample>'&gt;&gt; Ρόμπερτ: Τι τρέχει;' -&gt; 'Ρόμπερτ: Τι τρέχει;'</FixDoubleGreaterThanExample> - <FixEllipsesStartExample>'... και τότε εμείς' -&gt; 'και τότε εμείς'</FixEllipsesStartExample> - <FixMissingOpenBracketExample>'κλανκ] Πρόσεξε!' -&gt; '[κλανκ] Πρόσεξε!'</FixMissingOpenBracketExample> - <FixMusicNotationExample>'âTª sweet dreams are' -&gt; '♫ sweet dreams are'</FixMusicNotationExample> - <NumberOfImportantLogMessages>{0} σημαντικό(ά) μήνυμα(τα) του αρχείου καταγραφής</NumberOfImportantLogMessages> - <FixedOkXY>Επιδιορθωμένα και εντάξει - '{0}': {1}</FixedOkXY> - <FixOcrErrorExample>D0n't -&gt; Don't</FixOcrErrorExample> - <FixSpaceBetweenNumbersExample>1 100 -&gt; 1100</FixSpaceBetweenNumbersExample> - <FixDialogsOneLineExample>Γεια, Τζον. - Γεια, Άιντα. -&gt; Γεια, Τζον.&lt;br/&gt; - Γεια, Άιντα.</FixDialogsOneLineExample> - <SelectDefault>Προεπιλεγμένα</SelectDefault> - <SetDefault>Ορισμός προεπιλεγμένων</SetDefault> - <FixContinuationStyleX>Επιδιόρθωση στυλ συνέχισης: {0}</FixContinuationStyleX> - <XFixContinuationStyle>Επιδιόρθωση {0} στυλ συνέχισης</XFixContinuationStyle> - <FixUnnecessaryLeadingDots>Αφαίρεση αρχικών αποσιωπητικών</FixUnnecessaryLeadingDots> - <XFixUnnecessaryLeadingDots>Αφαίρεση {0} αρχικών αποσιωπητικών</XFixUnnecessaryLeadingDots> - </FixCommonErrors> - <GetDictionaries> - <Title>Χρειάζεστε λεξικά;</Title> - <DescriptionLine1>Ο ορθογραφικός έλεγχος του Subtitle Edit βασίζεται στη μηχανή NHunspell</DescriptionLine1> - <DescriptionLine2>που χρησιμοποιεί τα λεξικά ορθογραφικού ελέγχου του LibreOffice.</DescriptionLine2> - <ChooseLanguageAndClickDownload>Επιλογή γλώσσας και πατήστε λήψη</ChooseLanguageAndClickDownload> - <OpenDictionariesFolder>Άνοιγμα του φακέλου 'Dictionaries'</OpenDictionariesFolder> - <Download>Λήψη</Download> - <XDownloaded>Λήψη και εγκατάσταση {0}</XDownloaded> - </GetDictionaries> - <GetTesseractDictionaries> - <Title>Χρήση λεξικών;</Title> - <DescriptionLine1>Βρείτε λεξικά Tesseract OCR από το διαδίκτυο</DescriptionLine1> - <DownloadFailed>Αποτυχία λήψης!</DownloadFailed> - <GetDictionariesHere>Εύρεση λεξικών εδώ:</GetDictionariesHere> - <ChooseLanguageAndClickDownload>Επιλογή γλώσσας και λήψη</ChooseLanguageAndClickDownload> - <OpenDictionariesFolder>Άνοιγμα φακέλου 'Dictionaries'</OpenDictionariesFolder> - <Download>Λήψη</Download> - <XDownloaded>Λήψη και εγκατάσταση {0}</XDownloaded> - </GetTesseractDictionaries> - <GoogleTranslate> - <Title>Μετάφραση Google</Title> - <From>Από:</From> - <To>Σε:</To> - <Translate>Μετάφραση</Translate> - <PleaseWait>Παρακαλώ περιμένετε... αυτό μπορεί να αργήσει λίγο</PleaseWait> - <PoweredByGoogleTranslate>Τροφοδοτείται από τη Μετάφραση Google</PoweredByGoogleTranslate> - <PoweredByMicrosoftTranslate>Τροφοδοτείται από τη Μετάφραση Microsoft</PoweredByMicrosoftTranslate> - <MsClientSecretNeeded>Συγγνώμη, χρειάζεστε ένα γνωστικό κλειδί εξυπηρέτησης 'μετάφρασης κειμένου' από τη Microsoft για τη χρήση του. -Μετάβαση σε "Επιλογές -&gt; Ρυθμίσεις -&gt; Εργαλεία" για την εισαγωγή κλειδιού.</MsClientSecretNeeded> - <GoogleApiKeyNeeded>Συγγνώμη, χρειάζεστε ένα κλειδί API από τη Google για τη χρήση του. -Μετάβαση σε "Επιλογές -&gt; Ρυθμίσεις -&gt; Εργαλεία" για την εισαγωγή κλειδιού.</GoogleApiKeyNeeded> - <GoogleNoApiKeyWarning>Μετάφραση χωρίς κλειδί API... (αργά και περιορισμένα δεδομένα)</GoogleNoApiKeyWarning> - </GoogleTranslate> - <GoogleOrMicrosoftTranslate> - <Title>Μετάφραση Google vs Bing</Title> - <From>Από:</From> - <To>Έως:</To> - <Translate>Μετάφραση</Translate> - <SourceText>Αρχικό κείμενο</SourceText> - <GoogleTranslate>Μετάφραση Google</GoogleTranslate> - <MicrosoftTranslate>Μετάφραση Bing</MicrosoftTranslate> - </GoogleOrMicrosoftTranslate> - <GoToLine> - <Title>Μετάβαση σε υπότιτλο με αριθμό</Title> - <XIsNotAValidNumber>Το {0} δεν είναι έγκυρος αριθμός</XIsNotAValidNumber> - </GoToLine> - <ImportImages> - <Title>Εισαγωγή εικόνων</Title> - <ImageFiles>Αρχεία εικόνας</ImageFiles> - <Input>Εισαγωγή</Input> - <InputDescription>Επιλογή αρχείων για εισαγωγή (περιήγηση ή σύρσιμο)</InputDescription> - <Remove>Αφαίρεση</Remove> - <RemoveAll>Αφαίρεση όλων</RemoveAll> - </ImportImages> - <ImportSceneChanges> - <Title>Δημιουργία/εισαγωγή αλλαγών σκηνών</Title> - <OpenTextFile>Άνοιγμα αρχείου κειμένου...</OpenTextFile> - <Generate>Δημιουργία αλλαγών σκηνών</Generate> - <Import>Εισαγωγή αλλαγών σκηνών</Import> - <TextFiles>Αρχεία κειμένου</TextFiles> - <TimeCodes>Κώδικες χρόνων</TimeCodes> - <Frames>Καρέ</Frames> - <Seconds>Δευτερόλεπτα</Seconds> - <Milliseconds>Χιλιοστά δευτερολέπτου</Milliseconds> - <GetSceneChangesWithFfmpeg>Δημιουργία αλλαγών σκηνών με FFmpeg</GetSceneChangesWithFfmpeg> - <Sensitivity>Ευαισθησία</Sensitivity> - <SensitivityDescription>Μικρότερη τιμή δίνει περισσότερες αλλαγές σκηνών</SensitivityDescription> - <NoSceneChangesFound>Αδυναμία εύρεσης αλλαγών σκηνών.</NoSceneChangesFound> - </ImportSceneChanges> - <ImportText> - <Title>Εισαγωγή απλού κειμένου</Title> - <OneSubtitleIsOneFile>Πολλαπλά αρχεία - κάθε αρχείο είναι ένας υπότιτλος</OneSubtitleIsOneFile> - <OpenTextFile>Άνοιγμα αρχείου κειμένου...</OpenTextFile> - <OpenTextFiles>Άνοιγμα αρχείων κειμένου...</OpenTextFiles> - <ImportOptions>Επιλογές εισαγωγής</ImportOptions> - <Splitting>Διαχωρισμός</Splitting> - <AutoSplitText>Αυτόματος διαχωρισμός κειμένου</AutoSplitText> - <OneLineIsOneSubtitle>Μία γραμμή είναι ένας υπότιτλος</OneLineIsOneSubtitle> - <TwoLinesAreOneSubtitle>Δύο γραμμές είναι ένας υπότιτλος</TwoLinesAreOneSubtitle> - <LineBreak>Αλλαγή γραμμής</LineBreak> - <SplitAtBlankLines>Διαχωρισμός σε κενές γραμμές</SplitAtBlankLines> - <MergeShortLines>Συγχώνευση σύντομων γραμμών με συνέχιση</MergeShortLines> - <RemoveEmptyLines>Αφαίρεση κενών γραμμών</RemoveEmptyLines> - <RemoveLinesWithoutLetters>Αφαίρεση γραμμών χωρίς γράμματα</RemoveLinesWithoutLetters> - <GenerateTimeCodes>Δημιουργία κωδικών χρόνου</GenerateTimeCodes> - <TakeTimeFromFileName>Μεταφορά χρόνου από όνομα αρχείου</TakeTimeFromFileName> - <GapBetweenSubtitles>Κενό μεταξύ υποτίτλων (χιλ. δευτερολέπτου)</GapBetweenSubtitles> - <Auto>Αυτόματο</Auto> - <Fixed>Σταθερό</Fixed> - <Refresh>&amp;Ανανέωση</Refresh> - <TextFiles>Αρχεία κειμένου</TextFiles> - <PreviewLinesModifiedX>Προεπισκόπηση - τροποποιημένοι υπότιτλοι: {0}</PreviewLinesModifiedX> - <TimeCodes>Κώδικες χρόνων</TimeCodes> - <SplitAtEndChars>Διαχωρισμός στο τέλος χαρακτήρων</SplitAtEndChars> - </ImportText> - <Interjections> - <Title>Παρεμβολές</Title> - </Interjections> - <JoinSubtitles> - <Title>Ένωση υποτίτλων</Title> - <Information>Προσθήκη υποτίτλων για ένωση (η απόθεση υποστηρίζεται)</Information> - <NumberOfLines>#Γραμμές</NumberOfLines> - <StartTime>Έναρξη</StartTime> - <EndTime>Λήξη</EndTime> - <FileName>Όνομα αρχείου</FileName> - <Join>Ένωση</Join> - <TotalNumberOfLinesX>Συνολικός αριθμός γραμμών: {0:#,###,###}</TotalNumberOfLinesX> - <AlreadyCorrectTimeCodes>Τα αρχεία έχουν σωστούς κώδικες χρόνων</AlreadyCorrectTimeCodes> - <AppendTimeCodes>Προσθήκη χρόνου λήξης από προηγούμενο αρχείο</AppendTimeCodes> - <AddMs>Προσθήκη χιλ. δευτερολέπτου μετά από κάθε αρχείο</AddMs> - </JoinSubtitles> - <LanguageNames> - <NotSpecified>Αόριστο</NotSpecified> - <UnknownCodeX>Άγνωστο ({0})</UnknownCodeX> - <aaName>Αφάρ</aaName> - <abName>Αμπχαζικά</abName> - <afName>Αφρικάανς</afName> - <amName>Αμαρικά</amName> - <arName>Αραβικά</arName> - <asName>Ασαμεζικά</asName> - <ayName>Αϊμάρα</ayName> - <azName>Αζερμπαϊτζανικά</azName> - <baName>Μπασκίρ</baName> - <beName>Λευκορωσικά</beName> - <bgName>Βουλγαρικά</bgName> - <bhName>Ινδικά Μπιχάρ</bhName> - <biName>Μπισλάμα</biName> - <bnName>Μπενγκάλι</bnName> - <boName>Θιβετιανά</boName> - <brName>Βρετονικά</brName> - <caName>Καταλανικά</caName> - <coName>Κορσικανικά</coName> - <csName>Τσεχικά</csName> - <cyName>Ουαλικά</cyName> - <daName>Δανικά</daName> - <deName>Γερμανικά</deName> - <dzName>Ντζόνγκχα</dzName> - <elName>Ελληνικά</elName> - <enName>Αγγλικά</enName> - <eoName>Εσπεράντο</eoName> - <esName>Ισπανικά</esName> - <etName>Εσθονικά</etName> - <euName>Βασκικά</euName> - <faName>Περσικά</faName> - <fiName>Φινλανδικά</fiName> - <fjName>Φίτζι</fjName> - <foName>Φαρόε</foName> - <frName>Γαλλικά</frName> - <fyName>Δυτικά Φριζιανά</fyName> - <gaName>Ιρλανδικά</gaName> - <gdName>Σκωτικά Κελτικά</gdName> - <glName>Γαλικιακά</glName> - <gnName>Γκουαρανί</gnName> - <guName>Γκουγιαράτι</guName> - <haName>Χάουσα</haName> - <heName>Εβραϊκά</heName> - <hiName>Χίντι</hiName> - <hrName>Κροατικά</hrName> - <huName>Ουγγρικά</huName> - <hyName>Αρμενικά</hyName> - <iaName>Ιντερλίνγκουα</iaName> - <idName>Ινδονησιακά</idName> - <ieName>Ιντερλίνγκουε</ieName> - <ikName>Ινουπιάκ</ikName> - <isName>Ισλανδικά</isName> - <itName>Ιταλικά</itName> - <iuName>Ινουκτιτούτ</iuName> - <jaName>Ιαπωνικά</jaName> - <jvName>Ιαβανεζικά</jvName> - <kaName>Γεωργιανά</kaName> - <kkName>Καζακικά</kkName> - <klName>Καλαάλισουτ</klName> - <kmName>Καμποτζιανά</kmName> - <knName>Κανάντα</knName> - <koName>Κορεατικά</koName> - <ksName>Κασμίρι</ksName> - <kuName>Κουρδικά</kuName> - <kyName>Κυργιζικά</kyName> - <laName>Λατινικά</laName> - <lbName>Λουξεμβουργιανά</lbName> - <lnName>Λινγκάλα</lnName> - <loName>Λαοθιανά</loName> - <ltName>Λιθουανικά</ltName> - <lvName>Λετονικά</lvName> - <mgName>Μαλαγάσι</mgName> - <miName>Μάορι</miName> - <mkName>Σλαβομακεδονικά</mkName> - <mlName>Μαλαγιαλάμ</mlName> - <mnName>Μογγολικά</mnName> - <moName>Ρουμανικά Μολδαβίας</moName> - <mrName>Μαράθι</mrName> - <msName>Μαλάι</msName> - <mtName>Μαλτεζικά</mtName> - <myName>Βιρμανικά</myName> - <naName>Ναούρου</naName> - <neName>Νεπάλι</neName> - <nlName>Ολλανδικά</nlName> - <noName>Νορβηγικά</noName> - <ocName>Οκσιτανικά</ocName> - <omName>Ορόμο</omName> - <orName>Ορίγια</orName> - <paName>Παντζαπικά</paName> - <plName>Πολωνικά</plName> - <psName>Πάστο</psName> - <ptName>Πορτογαλικά</ptName> - <quName>Κετσούα</quName> - <rmName>Ρομανικά</rmName> - <rnName>Ρούντι</rnName> - <roName>Ρουμανικά</roName> - <ruName>Ρωσικά</ruName> - <rwName>Κινιαρβάντα</rwName> - <saName>Σανσκριτικά</saName> - <sdName>Σίντι</sdName> - <sgName>Σάνγκο</sgName> - <shName>Σερβοκροατικά</shName> - <siName>Σινχαλεζικά</siName> - <skName>Σλοβακικά</skName> - <slName>Σλοβενικά</slName> - <smName>Σαμόαν</smName> - <snName>Σχόνα</snName> - <soName>Σομάλι</soName> - <sqName>Αλβανικά</sqName> - <srName>Σερβικά</srName> - <ssName>Σουάτι</ssName> - <stName>Νότια Σόθο</stName> - <suName>Σουνδανικά</suName> - <svName>Σουηδικά</svName> - <swName>Σουαχίλι</swName> - <taName>Ταμίλ</taName> - <teName>Τελούγκου</teName> - <tgName>Τατζίκ</tgName> - <thName>Ταϊλανδικά</thName> - <tiName>Τιγκρίνυα</tiName> - <tkName>Τουρκμενικά</tkName> - <tlName>Ταγκαλόγκ</tlName> - <tnName>Τσιγουάνα</tnName> - <toName>Τονγκανικά</toName> - <trName>Τουρκικά</trName> - <tsName>Τσόνγκα</tsName> - <ttName>Τατάρ</ttName> - <twName>Τούι</twName> - <ugName>Ουιγουρικά</ugName> - <ukName>Ουκρανικά</ukName> - <urName>Ουρντού</urName> - <uzName>Ουζμπεκικά</uzName> - <viName>Βιετναμικά</viName> - <voName>Βόλαπικ</voName> - <woName>Γουόλοφ</woName> - <xhName>Ζόσα</xhName> - <yiName>Γίντις</yiName> - <yoName>Γιορούμπα</yoName> - <zaName>Ζουάνγκ</zaName> - <zhName>Κινεζικά</zhName> - <zuName>Ζουλού</zuName> - </LanguageNames> - <Main> - <Menu> - <File> - <Title>&amp;Αρχείο</Title> - <New>&amp;Νέο</New> - <Open>Ά&amp;νοιγμα</Open> - <OpenKeepVideo>Άνοιγμα (κράτηση βίντεο)</OpenKeepVideo> - <Reopen>Άνοιγμα &amp;ξανά</Reopen> - <Save>Α&amp;ποθήκευση</Save> - <SaveAs>Αποθήκευση &amp;ως...</SaveAs> - <RestoreAutoBackup>Επαναφορά αυτόματου αντίγραφου ασφαλείας</RestoreAutoBackup> - <AdvancedSubStationAlphaProperties>Προηγμένες ιδιότητες Sub Station Alpha...</AdvancedSubStationAlphaProperties> - <SubStationAlphaProperties>Ιδιότητες Sub Station Alpha...</SubStationAlphaProperties> - <EbuProperties>Ιδιότητες EBU STL...</EbuProperties> - <DvdStuioProProperties>Ιδιότητες DVD Studio Pro...</DvdStuioProProperties> - <TimedTextProperties>Ιδιότητες Timed Text...</TimedTextProperties> - <PacProperties>Ιδιότητες PAC...</PacProperties> - <OpenOriginal>Άνοιγμα αρχικού υπότιτλου (λειτουργία μετάφρασης)...</OpenOriginal> - <SaveOriginal>Αποθήκευση αρχικού υπότιτλου</SaveOriginal> - <CloseOriginal>Κλείσιμο αρχικού υπότιτλου</CloseOriginal> - <OpenContainingFolder>Άνοιγμα περιέχοντα φακέλου</OpenContainingFolder> - <Compare>&amp;Σύγκριση...</Compare> - <Statistics>Στατιστι&amp;κά...</Statistics> - <Plugins>Πρόσθετα...</Plugins> - <ImportOcrFromDvd>Εισαγωγή/OCR υπότιτλου από VOB/IFO (DVD)...</ImportOcrFromDvd> - <ImportOcrVobSubSubtitle>Εισαγωγή/OCR υπότιτλου VobSub (sub/idx)...</ImportOcrVobSubSubtitle> - <ImportBluRaySupFile>Εισαγωγή/OCR αρχείου Blu-ray sup...</ImportBluRaySupFile> - <ImportXSub>Εισαγωγή/OCR XSub από DivX/avi...</ImportXSub> - <ImportSubtitleFromMatroskaFile>Εισαγωγή/OCR υπότιτλου από αρχείο Matroska...</ImportSubtitleFromMatroskaFile> - <ImportSubtitleWithManualChosenEncoding>Εισαγωγή υπότιτλου με επιλογή κωδικοποίησης...</ImportSubtitleWithManualChosenEncoding> - <ImportText>Εισαγωγή απλού κειμένου...</ImportText> - <ImportImages>Εισαγωγή εικόνων...</ImportImages> - <ImportTimecodes>Εισαγωγή κωδικών χρόνου...</ImportTimecodes> - <Export>Εξαγωγή</Export> - <ExportBdnXml>BDN xml/png...</ExportBdnXml> - <ExportBluRaySup>Blu-ray sup...</ExportBluRaySup> - <ExportVobSub>VobSub (sub/idx)...</ExportVobSub> - <ExportCavena890>Cavena 890...</ExportCavena890> - <ExportEbu>EBU STL...</ExportEbu> - <ExportPac>PAC (Ηλεκτρονικά οθόνης)...</ExportPac> - <ExportPlainText>Απλό κείμενο...</ExportPlainText> - <ExportAdobeEncoreFabImageScript>Εικόνα κειμένου Adobe Encore FAB...</ExportAdobeEncoreFabImageScript> - <ExportKoreanAtsFilePair>Ζεύγος αρχείων Korean ATS...</ExportKoreanAtsFilePair> - <ExportAvidStl>Avid STL...</ExportAvidStl> - <ExportDvdStudioProStl>DVD Studio Pro STL...</ExportDvdStudioProStl> - <ExportCapMakerPlus>CapMaker Plus...</ExportCapMakerPlus> - <ExportCaptionsInc>Captions Inc...</ExportCaptionsInc> - <ExportCheetahCap>Cheetah CAP...</ExportCheetahCap> - <ExportUltech130>Λεζάντα Ultech...</ExportUltech130> - <ExportCustomTextFormat>Εξαγωγή προσαρμοσμένης μορφής κειμένου...</ExportCustomTextFormat> - <Exit>Έ&amp;ξοδος</Exit> - </File> - <Edit> - <Title>Επεξεργασία</Title> - <Undo>Αναίρεση</Undo> - <Redo>Επανάληψη</Redo> - <ShowUndoHistory>Εμφάνιση ιστορικού (αναίρεσης)</ShowUndoHistory> - <InsertUnicodeSymbol>Εισαγωγή συμβόλου Unicode</InsertUnicodeSymbol> - <InsertUnicodeControlCharacters>Εισαγωγή χαρακτήρων ελέγχου Unicode</InsertUnicodeControlCharacters> - <InsertUnicodeControlCharactersLRM>Σημείο αριστερά προς δεξιά</InsertUnicodeControlCharactersLRM> - <InsertUnicodeControlCharactersRLM>Σημείο δεξιά προς αριστερά</InsertUnicodeControlCharactersRLM> - <InsertUnicodeControlCharactersLRE>Έναρξη ενσωμάτωσης από αριστερά προς δεξιά</InsertUnicodeControlCharactersLRE> - <InsertUnicodeControlCharactersRLE>Έναρξη ενσωμάτωσης από δεξιά προς αριστερά</InsertUnicodeControlCharactersRLE> - <InsertUnicodeControlCharactersLRO>Έναρξη παράκαμψης από αριστερά προς δεξιά</InsertUnicodeControlCharactersLRO> - <InsertUnicodeControlCharactersRLO>Έναρξη παράκαμψης από δεξιά προς αριστερά</InsertUnicodeControlCharactersRLO> - <Find>Εύ&amp;ρεση</Find> - <FindNext>Εύρεση &amp;επόμενου</FindNext> - <Replace>Α&amp;ντικατάσταση</Replace> - <MultipleReplace>&amp;Πολλαπλή αντικατάστση...</MultipleReplace> - <GoToSubtitleNumber>&amp;Μετάβαση σε αριθμό υπότιτλου...</GoToSubtitleNumber> - <RightToLeftMode>Λειτουργία από δεξιά προς αριστερά</RightToLeftMode> - <FixRtlViaUnicodeControlCharacters>Επιδιόρθωση RTL μέσω χαρακτήρων ελέγχου Unicode (επιλεγμένων γραμμών)</FixRtlViaUnicodeControlCharacters> - <RemoveUnicodeControlCharacters>Αφαίρεση χαρακτήρων ελέγχου Unicode (επιλεγμένων γραμμών)</RemoveUnicodeControlCharacters> - <ReverseRightToLeftStartEnd>Αντιστροφή έναρξης/λήξης του RTL (επιλεγμένες γραμμές)</ReverseRightToLeftStartEnd> - <ShowOriginalTextInAudioAndVideoPreview>Προβολή αρχικού κειμένου στις προεπισκόπήσεις ήχου/βίντεο</ShowOriginalTextInAudioAndVideoPreview> - <ModifySelection>Επεξεργασία επιλογής...</ModifySelection> - <InverseSelection>Αντιστροφή</InverseSelection> - </Edit> - <Tools> - <Title>Εργαλεία</Title> - <AdjustDisplayDuration>&amp;Προσαρμογή διαρκειών...</AdjustDisplayDuration> - <ApplyDurationLimits>Εφαρμογή ορίων διάρκειας...</ApplyDurationLimits> - <SubtitlesBridgeGaps>Ένωση κενών στις διάρκειες...</SubtitlesBridgeGaps> - <FixCommonErrors>&amp;Επιδιόρθωση σφαλμάτων...</FixCommonErrors> - <StartNumberingFrom>Επαναρίθμηση...</StartNumberingFrom> - <RemoveTextForHearingImpaired>Αφαίρεση κειμένου για κωφούς...</RemoveTextForHearingImpaired> - <ChangeCasing>Αλλαγή πεζών-κεφαλαίων...</ChangeCasing> - <ChangeFrameRate>Αλλαγή ρυθμού καρέ...</ChangeFrameRate> - <ChangeSpeedInPercent>Αλλαγή ταχύτητας (επί τοις εκατό)...</ChangeSpeedInPercent> - <MergeShortLines>Συγχώνευση σύντομων γραμμών...</MergeShortLines> - <MergeDuplicateText>Συγχώνευση γραμμών με ίδιο κείμενο...</MergeDuplicateText> - <MergeSameTimeCodes>Συγχώνευση γραμμών με ίδιο χρόνο...</MergeSameTimeCodes> - <SplitLongLines>Διαχωρισμός μεγάλων γραμμών...</SplitLongLines> - <MinimumDisplayTimeBetweenParagraphs>Ελάχιστος χρόνος εμφάνισης μεταξύ παραγράφων...</MinimumDisplayTimeBetweenParagraphs> - <SortBy>Ταξινόμηση</SortBy> - <NetflixQualityCheck>Έλεγχος ποιότητας Netflix...</NetflixQualityCheck> - <Number>Αριθμός</Number> - <StartTime>Έναρξη</StartTime> - <EndTime>Λήξη</EndTime> - <Duration>Διάρκεια</Duration> - <TextAlphabetically>Κείμενο - αλφαβητικά</TextAlphabetically> - <TextSingleLineMaximumLength>Κείμενο - μέγιστο μήκος γραμμής</TextSingleLineMaximumLength> - <TextTotalLength>Κείμενο - συνολικό μήκος</TextTotalLength> - <TextNumberOfLines>Κείμενο - σύνολο γραμμών</TextNumberOfLines> - <TextNumberOfCharactersPerSeconds>Κείμενο - σύνολο χαρακτήρων/δευτ.</TextNumberOfCharactersPerSeconds> - <WordsPerMinute>Κείμενο - λέξεις ανά λεπτό (λαλ)</WordsPerMinute> - <Style>Στυλ</Style> - <Ascending>Αύξουσα</Ascending> - <Descending>Φθίνουσα</Descending> - <MakeNewEmptyTranslationFromCurrentSubtitle>Δημιουργία νέας κενής μετάφρασης</MakeNewEmptyTranslationFromCurrentSubtitle> - <BatchConvert>Μαζική μετατροπή...</BatchConvert> - <GenerateTimeAsText>Παραγωγή χρόνου ως κείμενο...</GenerateTimeAsText> - <MeasurementConverter>Μετατροπέας μονάδων μέτρησης...</MeasurementConverter> - <SplitSubtitle>Διάσπαση υπότιτλου...</SplitSubtitle> - <AppendSubtitle>Προσάρτηση υπότιτλου...</AppendSubtitle> - <JoinSubtitles>Ένωση υποτίτλων...</JoinSubtitles> - </Tools> - <Video> - <Title>Βίντεο</Title> - <OpenVideo>Άνοιγμα αρχείου βίντεο...</OpenVideo> - <OpenVideoFromUrl>Άνοιγμα βίντεο από διεύθυνση url...</OpenVideoFromUrl> - <OpenDvd>Άνοιγμα DVD...</OpenDvd> - <ChooseAudioTrack>Επιλέξτε κομματιού ήχου</ChooseAudioTrack> - <CloseVideo>Κλείσιμο βίντεο</CloseVideo> - <OpenSecondSubtitle>Άνοιγμα δεύτερου υποτίτλου...</OpenSecondSubtitle> - <SetVideoOffset>Αντιστάθμιση έναρξης βίντεο...</SetVideoOffset> - <SmptTimeMode>Χρονισμός SMPTE (ρήξη καρέ)</SmptTimeMode> - <GenerateTextFromVideo>Δημιουργία κειμένου από βίντεο...</GenerateTextFromVideo> - <ImportChaptersFromVideo>Εισαγωγή κεφαλαίων από βίντεο</ImportChaptersFromVideo> - <GenerateImportSceneChanges>Δημιουργία/εισαγωγή αλλαγών σκηνών...</GenerateImportSceneChanges> - <RemoveSceneChanges>Αφαίρεση σκηνών αλλαγής</RemoveSceneChanges> - <WaveformBatchGenerate>Μαζική δημιουργία κυματομορφών...</WaveformBatchGenerate> - <ShowHideVideo>Εμφάνιση/απόκρυψη βίντεο</ShowHideVideo> - <ShowHideWaveform>Εμφάνιση/απόκρυψη κυματομορφής</ShowHideWaveform> - <ShowHideWaveformAndSpectrogram>Εμφάνιση/απόκρυψη κυματομορφής και φασματογράμματος</ShowHideWaveformAndSpectrogram> - <UnDockVideoControls>Απαγκύρωση στοιχείων ελέγχου βίντεο</UnDockVideoControls> - <ReDockVideoControls>Επαναγκύρωση στοιχείων ελέγχου βίντεο</ReDockVideoControls> - </Video> - <SpellCheck> - <Title>Ορθογραφικός έλεγχος</Title> - <SpellCheck>&amp;Ορθογραφικός έλεγχος...</SpellCheck> - <SpellCheckFromCurrentLine>Ορθογραφικός έλεγχος από τρέχουσα γραμμή...</SpellCheckFromCurrentLine> - <FindDoubleWords>Εύρεση διπλών λέξεων</FindDoubleWords> - <FindDoubleLines>Εύρεση διπλών γραμμών</FindDoubleLines> - <GetDictionaries>Λήψη λεξικών...</GetDictionaries> - <AddToNameList>Προσθήκη λέξης στη λίστα ονομάτων</AddToNameList> - </SpellCheck> - <Synchronization> - <Title>Συγχρονισμός</Title> - <AdjustAllTimes>Προσαρμογή όλων των χρόνων (εμφάνιση νωρίτερα/αργότερα)...</AdjustAllTimes> - <VisualSync>&amp;Οπτικός συγχρονισμός...</VisualSync> - <PointSync>Συγχρονισμός σημείων...</PointSync> - <PointSyncViaOtherSubtitle>Συγχρονισμός σημείων μέσω υπότιτλου...</PointSyncViaOtherSubtitle> - </Synchronization> - <AutoTranslate> - <Title>Αυτόματη μετάφραση</Title> - <TranslatePoweredByGoogle>Μετάφραση Google...</TranslatePoweredByGoogle> - <TranslatePoweredByMicrosoft>Μετάφραση Bing...</TranslatePoweredByMicrosoft> - <TranslateFromSwedishToDanish>Μετάφραση από Σουηδικά σε Δανικά (τροφοδοτείται από nikse.dk)...</TranslateFromSwedishToDanish> - </AutoTranslate> - <Options> - <Title>Επιλογές</Title> - <Settings>&amp;Ρυθμίσεις...</Settings> - <ChooseLanguage>&amp;Επιλογή γλώσσας...</ChooseLanguage> - </Options> - <Networking> - <Title>Δίκτυο</Title> - <StartNewSession>Έναρξη νέας συνεδρίας</StartNewSession> - <JoinSession>Συμμετοχή</JoinSession> - <ShowSessionInfoAndLog>Προβολή πληροφοριών και αρχείου καταγραφής</ShowSessionInfoAndLog> - <Chat>Συνομιλία</Chat> - <LeaveSession>Έξοδος</LeaveSession> - </Networking> - <Help> - <CheckForUpdates>Έλεγχος ενημερώσεων...</CheckForUpdates> - <Title>Βοήθεια</Title> - <Help>&amp;Βοήθεια</Help> - <About>&amp;Πληροφορίες</About> - </Help> - <ToolBar> - <New>Νέο</New> - <Open>Άνοιγμα</Open> - <Save>Αποθήκευση</Save> - <SaveAs>Αποθήκευση ως</SaveAs> - <Find>Εύρεση</Find> - <Replace>Αντικατάσταση</Replace> - <FixCommonErrors>Διόρθωση συνηθισμένων σφαλμάτων</FixCommonErrors> - <RemoveTextForHi>Αφαίρεση κειμένου για κωφούς</RemoveTextForHi> - <VisualSync>Οπτικός συγχρονισμός</VisualSync> - <SpellCheck>Ορθογραφικός έλεγχος</SpellCheck> - <NetflixQualityCheck>Έλεγχος ποιότητας Netflix</NetflixQualityCheck> - <Settings>Ρυθμίσεις</Settings> - <Help>Βοήθεια</Help> - <ShowHideWaveform>Εμφάνιση/απόκρυψη κυματομορφής</ShowHideWaveform> - <ShowHideVideo>Εμφάνιση/απόκρυψη βίντεο</ShowHideVideo> - </ToolBar> - <ContextMenu> - <SizeAllColumnsToFit>Αλλαγή μεγέθους στηλών για να χωρούν</SizeAllColumnsToFit> - <AdvancedSubStationAlphaSetStyle>Προηγμένο Sub Station Alpha - ορισμός στυλ</AdvancedSubStationAlphaSetStyle> - <SubStationAlphaSetStyle>Sub Station Alpha - Ορισμός στυλ</SubStationAlphaSetStyle> - <SetActor>Ορισμός παράγοντα</SetActor> - <SubStationAlphaStyles>Στυλ Sub Station Alpha...</SubStationAlphaStyles> - <AdvancedSubStationAlphaStyles>Προηγμένο στυλ Sub Station Alpha...</AdvancedSubStationAlphaStyles> - <TimedTextSetRegion>Timed Text - ορισμός περιοχής</TimedTextSetRegion> - <TimedTextSetStyle>Timed Text - ορισμός στυλ</TimedTextSetStyle> - <TimedTextStyles>Στυλ Timed Text...</TimedTextStyles> - <TimedTextSetLanguage>Timed Text - ορισμός γλώσσας</TimedTextSetLanguage> - <SamiSetStyle>Sami - ορισμός κλάσης</SamiSetStyle> - <NuendoSetStyle>Nuendo - ορισμός χαρακτήρα</NuendoSetStyle> - <Cut>Αποκοπή</Cut> - <Copy>Αντιγραφή</Copy> - <Paste>Επικόλληση</Paste> - <Delete>Διαγραφή</Delete> - <SplitLineAtCursorPosition>Διαχωρισμός γραμμής στην θέση του δείκτη</SplitLineAtCursorPosition> - <SplitLineAtCursorAndWaveformPosition>Διαχωρισμός γραμμής στη θέση δείκτη/βίντεο</SplitLineAtCursorAndWaveformPosition> - <AutoDurationCurrentLine>Αυτόματη διάρκεια (τρέχουσα γραμμή)</AutoDurationCurrentLine> - <SelectAll>Επιλογή όλων</SelectAll> - <InsertFirstLine>Εισαγωγή γραμμής</InsertFirstLine> - <InsertBefore>Εισαγωγή πριν</InsertBefore> - <InsertAfter>Εισαγωγή μετά</InsertAfter> - <InsertSubtitleAfter>Εισαγωγή υπότιτλου έπειτα της γραμμής...</InsertSubtitleAfter> - <CopyToClipboard>Αντιγραφή κειμένου στο πρόχειρο</CopyToClipboard> - <Column>Στήλη</Column> - <ColumnDeleteText>Διαγραφή κειμένου</ColumnDeleteText> - <ColumnDeleteTextAndShiftCellsUp>Διαγραφή κειμένου και ανέβασμα κελιών</ColumnDeleteTextAndShiftCellsUp> - <ColumnInsertEmptyTextAndShiftCellsDown>Εισαγωγή κενού κειμένου και κατέβασμα κελιών</ColumnInsertEmptyTextAndShiftCellsDown> - <ColumnInsertTextFromSubtitle>Εισαγωγή κειμένου από υπότιτλο...</ColumnInsertTextFromSubtitle> - <ColumnImportTextAndShiftCellsDown>Εισαγωγή κειμένου και κατέβασμα κελιών</ColumnImportTextAndShiftCellsDown> - <ColumnPasteFromClipboard>Επικόλληση από το πρόχειρο...</ColumnPasteFromClipboard> - <ColumnTextUp>Κείμενο πάνω</ColumnTextUp> - <ColumnTextDown>Κείμενο κάτω</ColumnTextDown> - <ColumnCopyOriginalTextToCurrent>Αντιγραφή κειμένου από το αρχικό στο τρέχων</ColumnCopyOriginalTextToCurrent> - <Split>Διαχωρισμός</Split> - <MergeSelectedLines>Συγχώνευση γραμμών</MergeSelectedLines> - <MergeSelectedLinesAsDialog>Συγχώνευση γραμμών ως διάλογο</MergeSelectedLinesAsDialog> - <MergeWithLineBefore>Συγχώνευση με τη γραμμή πριν</MergeWithLineBefore> - <MergeWithLineAfter>Συγχώνευση με τη γραμμή μετά</MergeWithLineAfter> - <ExtendToLineBefore>Επέκταση στην προηγούμενη γραμμή</ExtendToLineBefore> - <ExtendToLineAfter>Επέκταση στην επόμενη γραμμή</ExtendToLineAfter> - <RemoveFormatting>Αφαίρεση μορφοποίησης</RemoveFormatting> - <RemoveFormattingAll>Αφαίρεση όλης της μορφοποίησης</RemoveFormattingAll> - <RemoveFormattingBold>Αφαίρεση έντονων</RemoveFormattingBold> - <RemoveFormattingItalic>Αφαίρεση πλαγιαστών</RemoveFormattingItalic> - <RemoveFormattingUnderline>Αφαίρεση υπογράμμισης</RemoveFormattingUnderline> - <RemoveFormattingColor>Αφαίρεση χρώματος</RemoveFormattingColor> - <RemoveFormattingFontName>Αφαίρεση ονόματος γραμματοσειράς</RemoveFormattingFontName> - <RemoveFormattingAlignment>Αφαίρεση στοίχισης</RemoveFormattingAlignment> - <Underline>Υπογράμμιση</Underline> - <Box>Πλαίσιο</Box> - <Color>Χρώμα...</Color> - <FontName>Όνομα γραμματοσειράς...</FontName> - <Superscript>Εκθέτης</Superscript> - <Subscript>Δείκτης</Subscript> - <Alignment>Στοίχιση...</Alignment> - <AutoBalanceSelectedLines>Αυτόματη ισορρόπηση γραμμών...</AutoBalanceSelectedLines> - <RemoveLineBreaksFromSelectedLines>Αφαίρεση αλλαγών γραμμής από γραμμές...</RemoveLineBreaksFromSelectedLines> - <TypewriterEffect>Εφέ γραφομηχανής...</TypewriterEffect> - <KaraokeEffect>Εφέ καραόκε...</KaraokeEffect> - <ShowSelectedLinesEarlierLater>Εμφάνιση γραμμών νωρίτερα/αργότερα...</ShowSelectedLinesEarlierLater> - <VisualSyncSelectedLines>Οπτικός συγχρονισμός γραμμών...</VisualSyncSelectedLines> - <GoogleAndMicrosoftTranslateSelectedLine>Μετάφραση αρχικής γραμμής μέσω Google/Microsoft</GoogleAndMicrosoftTranslateSelectedLine> - <TranslateSelectedLines>Μετάφραση γραμμών...</TranslateSelectedLines> - <AdjustDisplayDurationForSelectedLines>Προσαρμογή διαρκειών γραμμών...</AdjustDisplayDurationForSelectedLines> - <FixCommonErrorsInSelectedLines>Επιδιόρθωση κοινών σφαλμάτων στις γραμμές...</FixCommonErrorsInSelectedLines> - <ChangeCasingForSelectedLines>Αλλαγή πεζών-κεφαλαίων στις γραμμές...</ChangeCasingForSelectedLines> - <SaveSelectedLines>Αποθήκευση γραμμών ως...</SaveSelectedLines> - <WebVTTSetNewVoice>Καθορισμός νέας φωνής...</WebVTTSetNewVoice> - <WebVTTRemoveVoices>Αφαίρεση φωνών</WebVTTRemoveVoices> - <NewActor>Νέος ηθοποιός...</NewActor> - <RemoveActors>Αφαίρεση ηθοποιών</RemoveActors> - <EditBookmark>Επεξεργασία σημείωσης</EditBookmark> - <RemoveBookmark>Αφαίρεση σημείωσης</RemoveBookmark> - </ContextMenu> - </Menu> - <Controls> - <SubtitleFormat>Μορφή</SubtitleFormat> - <FileEncoding>Κωδικοποίηση</FileEncoding> - <ListView>Προβολή λίστας</ListView> - <SourceView>Προβολή πηγής</SourceView> - <UndoChangesInEditPanel>Αναίρεση αλλαγών στον πίνακα επεξεργασίας</UndoChangesInEditPanel> - <Previous>&lt; Προηγούμενο</Previous> - <Next>Επόμενο &gt;</Next> - <AutoBreak>&amp;Διάσπαση</AutoBreak> - <Unbreak>Συνένωση</Unbreak> - </Controls> - <VideoControls> - <Translate>Μετάφραση</Translate> - <CreateAndAdjust>Δημιουργία/προσαρμογή</CreateAndAdjust> - <Create>Δημιουργία</Create> - <Adjust>Προσαρμογή</Adjust> - <SelectCurrentElementWhilePlaying>Επιλογή τρέχοντος υπότιτλου κατά την αναπαραγωγή</SelectCurrentElementWhilePlaying> - <AutoRepeat>Αυτόματη επανάληψη</AutoRepeat> - <AutoRepeatOn>Ενεργοποίηση αυτόματης επανάληψης</AutoRepeatOn> - <AutoRepeatCount>Μετρητής επαναλήψεων (φορές)</AutoRepeatCount> - <AutoContinue>Αυτόματη συνέχιση</AutoContinue> - <AutoContinueOn>Ενεργοποίηση αυτόματης συνέχισης</AutoContinueOn> - <DelayInSeconds>Καθυστέρηση (δευτ.)</DelayInSeconds> - <OriginalText>Αρχικό κείμενο</OriginalText> - <Previous>&lt; &amp;Προηγούμενο</Previous> - <Stop>&amp;Διακοπή</Stop> - <PlayCurrent>&amp;Αναπαραγωγή τρέχοντος</PlayCurrent> - <Next>&amp;Επόμενο &gt;</Next> - <Playing>Σε αναπαραγωγή...</Playing> - <RepeatingLastTime>Επανάληψη... τελευταία φορά</RepeatingLastTime> - <RepeatingXTimesLeft>Επανάληψη... {0} φορές που απέμειναν</RepeatingXTimesLeft> - <AutoContinueInOneSecond>Αυτόματη συνέχιση σε ένα δευτ.</AutoContinueInOneSecond> - <AutoContinueInXSeconds>Αυτόματη συνέχιση σε {0} δευτ.</AutoContinueInXSeconds> - <StillTypingAutoContinueStopped>Πληκτρολόγηση σε εξέλιξη... διακοπή αυτόματης συνέχισης</StillTypingAutoContinueStopped> - <InsertNewSubtitleAtVideoPosition>&amp;Εισαγωγή νέου υποτίτλου</InsertNewSubtitleAtVideoPosition> - <InsertNewSubtitleAtVideoPositionNoTextBoxFocus>Εισαγωγή υποτίτλου στη θέση βίντεο (μη εστίαση πλαισίου)</InsertNewSubtitleAtVideoPositionNoTextBoxFocus> - <Auto>Αυτόματη</Auto> - <PlayFromJustBeforeText>Αναπαραγωγή &amp;πριν από</PlayFromJustBeforeText> - <Pause>Παύση</Pause> - <GoToSubtitlePositionAndPause>Μετάβαση και παύση</GoToSubtitlePositionAndPause> - <SetStartTime>Ορισμός έ&amp;ναρξης</SetStartTime> - <SetEndTimeAndGoToNext>Ο&amp;ρισμός λήξης &amp;&amp; μετάβαση</SetEndTimeAndGoToNext> - <AdjustedViaEndTime>Προσάρμοση μέσω χρόνου λήξης {0}</AdjustedViaEndTime> - <SetEndTime>Ορισμός λή&amp;ξης</SetEndTime> - <SetstartTimeAndOffsetOfRest>Έναρ&amp;ξη και αντιστάθμιση</SetstartTimeAndOffsetOfRest> - <SearchTextOnline>Αναζήτηση κειμένου διαδικτυακά</SearchTextOnline> - <GoogleTranslate>Μετάφραση Google</GoogleTranslate> - <GoogleIt>Αναζήτηση</GoogleIt> - <SecondsBackShort>&lt;&lt;</SecondsBackShort> - <SecondsForwardShort>&gt;&gt;</SecondsForwardShort> - <VideoPosition>Θέση βίντεο:</VideoPosition> - <TranslateTip>Συμβουλή: Χρησιμοποιήστε &lt;alt+βέλη πάνω/κάτω&gt; για μετάβαση σε προηγούμενο/επόμενο υπότιτλο</TranslateTip> - <BeforeChangingTimeInWaveformX>Πριν την αλλαγή χρόνου στην κυματομορφή: {0}</BeforeChangingTimeInWaveformX> - <NewTextInsertAtX>Νέο κείμενο εισήχθει στο {0}</NewTextInsertAtX> - <Center>Κέντρο</Center> - <PlayRate>Ρυθμός αναπαραγωγής (ταχύτητα)</PlayRate> - </VideoControls> - <SaveChangesToUntitled>Αποθήκευση αλλαγών στο άτιτλο;</SaveChangesToUntitled> - <SaveChangesToX>Αποθήκευση αλλαγών στο {0};</SaveChangesToX> - <SaveChangesToUntitledOriginal>Αποθήκευση αλλαγών στον αρχικό άτιτλο;</SaveChangesToUntitledOriginal> - <SaveChangesToOriginalX>Αποθήκευση αλλαγών στον αρχικό {0};</SaveChangesToOriginalX> - <SaveSubtitleAs>Αποθήκευση υποτίτλου ως...</SaveSubtitleAs> - <SaveOriginalSubtitleAs>Αποθήκευση αρχικού υποτίτλου ως...</SaveOriginalSubtitleAs> - <NoSubtitleLoaded>Μη φορτωμένος υπότιτλος</NoSubtitleLoaded> - <VisualSyncSelectedLines>Οπτικός συγχρονισμός - επιλεγμένες γραμμές</VisualSyncSelectedLines> - <VisualSyncTitle>Οπτικός συγχρονισμός</VisualSyncTitle> - <BeforeVisualSync>Πριν οπτικού συγχρονισμού</BeforeVisualSync> - <VisualSyncPerformedOnSelectedLines>Εκτελέστηκε οπτικός συγχρονισμός στις επιλεγμένες γραμμές</VisualSyncPerformedOnSelectedLines> - <VisualSyncPerformed>Εκτελέστηκε οπτικός συγχρονισμός</VisualSyncPerformed> - <FileXIsLargerThan10MB>Το αρχείο {0} είναι μεγαλύτερο από 10 MB</FileXIsLargerThan10MB> - <ContinueAnyway>Συνέχιση;</ContinueAnyway> - <BeforeLoadOf>Πριν τη φόρτωση του {0}</BeforeLoadOf> - <LoadedSubtitleX>Φόρτωση υποτίτλου {0}</LoadedSubtitleX> - <LoadedEmptyOrShort>Φόρτωση κενού ή σύντομου υποτίτλου {0}</LoadedEmptyOrShort> - <FileIsEmptyOrShort>Το αρχείο είναι κενό ή μικρό!</FileIsEmptyOrShort> - <FileNotFound>Αδυναμία εύρεσης αρχείου: {0}</FileNotFound> - <SavedSubtitleX>Αποθήκευση υποτίτλου {0}</SavedSubtitleX> - <SavedOriginalSubtitleX>Αποθήκευση αρχικού υποτίτλου {0}</SavedOriginalSubtitleX> - <FileOnDiskModified>Τροποποίηση αρχείου δίσκου</FileOnDiskModified> - <OverwriteModifiedFile>Αντικατάσταση του αρχείου {0} που τροποποιήθηκε στο {1} {2}{3} με το τρέχον αρχείο που φορτώθηκε από το δίσκο στο {4} {5};</OverwriteModifiedFile> - <FileXIsReadOnly>Αδυναμία αποθήκευσης {0} -Το αρχείο είναι μόνο για ανάγνωση!</FileXIsReadOnly> - <UnableToSaveSubtitleX>Αδυναμία αποθήκευσης του αρχείου υπότιτλων {0} -Ο υπότιτλος μοιάζει να είναι άδειος - προσπαθήστε να τον ξανασώσεται, εάν δουλεύεται σε έγκυρο αρχείο</UnableToSaveSubtitleX> - <FormatXShouldUseUft8>Να χρησιμοποιείται η κωδικοποίηση UTF-8 κατά την αποθήκευση {0} αρχείων!</FormatXShouldUseUft8> - <BeforeNew>Πριν από νέο</BeforeNew> - <New>Νέο</New> - <BeforeConvertingToX>Πριν από μετατροπή σε {0}</BeforeConvertingToX> - <ConvertedToX>Μετατράπηκε σε {0}</ConvertedToX> - <BeforeShowEarlier>Πριν από εμφάνιση νωρίτερα</BeforeShowEarlier> - <BeforeShowLater>Πριν από εμφάνιση αργότερα</BeforeShowLater> - <LineNumberX>Γραμμή με αριθμό: {0:#,##0.##}</LineNumberX> - <OpenVideoFile>Άνοιγμα βίντεο...</OpenVideoFile> - <NewFrameRateUsedToCalculateTimeCodes>Ο νέος ρυθμός καρέ ({0}) χρησιμοποιήθηκε για τον υπολογισμό των κωδικών χρόνου έναρξης/λήξης</NewFrameRateUsedToCalculateTimeCodes> - <NewFrameRateUsedToCalculateFrameNumbers>Ο νέος ρυθμός καρέ ({0}) χρησιμοποιήθηκε για τον υπολογισμό των αριθμών καρέ έναρξης/λήξης</NewFrameRateUsedToCalculateFrameNumbers> - <FindContinue>Αδυναμία εύρεσης στοιχείου. -Επανάληψη αναζήτησης από την αρχή;</FindContinue> - <FindContinueTitle>Συνέχιση εύρεσης;</FindContinueTitle> - <ReplaceContinueNotFound>Αδυναμία εύρεσης στοιχείου. -Επανάληψη αναζήτησης και αντικατάστασης από την αρχή;</ReplaceContinueNotFound> - <ReplaceXContinue>Εύρεση και αντικατάσταση στοιχείου {0} φορά(ες). -Επανάληψη αναζήτησης και αντικατάστασης από την αρχή;</ReplaceXContinue> - <ReplaceContinueTitle>Συνέχιση 'αντικατάστασης';</ReplaceContinueTitle> - <SearchingForXFromLineY>Αναζήτηση για '{0}' από αριθμό γραμμής {1}...</SearchingForXFromLineY> - <XFoundAtLineNumberY>Εύρεση '{0}' στη γραμμή με αριθμό {1}</XFoundAtLineNumberY> - <XNotFound>Αδυναμία εύρεσης '{0}'</XNotFound> - <BeforeReplace>Πριν από αντικατάσταση: {0}</BeforeReplace> - <MatchFoundX>Εύρεση αντιστοιχίας: {0}</MatchFoundX> - <NoMatchFoundX>Αδυναμία εύρεσης αντιστοιχίας: {0}</NoMatchFoundX> - <FoundNothingToReplace>Αδυναμία εύρεσης για αντικατάσταση</FoundNothingToReplace> - <ReplaceCountX>Αριθμός αντικαταστάσεων: {0}</ReplaceCountX> - <NoXFoundAtLineY>Εύρεση αντιστοιχίας στη γραμμή {0}: {1}</NoXFoundAtLineY> - <OneReplacementMade>Αντικατάσταση ενός.</OneReplacementMade> - <BeforeChangesMadeInSourceView>Πριν των αλλαγν στην προβολή πηγής</BeforeChangesMadeInSourceView> - <UnableToParseSourceView>Αδυναμία ανάλυσης κειμένου στην προβολή πηγής!</UnableToParseSourceView> - <GoToLineNumberX>Μετάβαση στη γραμμή με αριθμό {0}</GoToLineNumberX> - <CreateAdjustChangesApplied>Δημιουργία/προσαρμογή γραμμών εφαρμοσμένων αλλαγών</CreateAdjustChangesApplied> - <SelectedLines>επιλεγμένες γραμμές</SelectedLines> - <BeforeDisplayTimeAdjustment>Πριν από προσαρμογή χρόνου εμφάνισης</BeforeDisplayTimeAdjustment> - <DisplayTimeAdjustedX>Προσαρμοσμένος χρόνος εμφάνισης: {0}</DisplayTimeAdjustedX> - <DisplayTimesAdjustedX>Προσαρμοσμένοι χρόνοι εμφάνισης: {0}</DisplayTimesAdjustedX> - <StarTimeAdjustedX>Προσαρμοσμένος χρόνος έναρξης: {0}</StarTimeAdjustedX> - <BeforeCommonErrorFixes>Πριν από επιδιορθώσεις κοινών σφαλμάτων</BeforeCommonErrorFixes> - <CommonErrorsFixedInSelectedLines>Επιδιορθώσεις κοινών σφαλμάτων σε επιλεγμένες γραμμές</CommonErrorsFixedInSelectedLines> - <CommonErrorsFixed>Επιδιόρθωση κοινών σφαλμάτων</CommonErrorsFixed> - <BeforeRenumbering>Πριν επαναρίθμησης</BeforeRenumbering> - <RenumberedStartingFromX>Έναρξη επαναρίθμησης από: {0}</RenumberedStartingFromX> - <BeforeRemovalOfTextingForHearingImpaired>Πριν από αφαίρεση κειμένου για κωφούς</BeforeRemovalOfTextingForHearingImpaired> - <TextingForHearingImpairedRemovedOneLine>Αφαίρεση κειμένου για κωφούς: Μία γραμμή</TextingForHearingImpairedRemovedOneLine> - <TextingForHearingImpairedRemovedXLines>Αφαίρεση κειμένου για κωφούς: {0} γραμμή(ές)</TextingForHearingImpairedRemovedXLines> - <SubtitleSplitted>Διαχώριση υποτίτλου</SubtitleSplitted> - <SubtitleAppendPrompt>Προσάρτηση υποτίτλου στον φορτωμένο υπότιτλο που ίσως -είναι ήδη συγχρονισμένος με το αρχείο βίντεο. Συνέχιση;</SubtitleAppendPrompt> - <SubtitleAppendPromptTitle>Προσάρτηση υπότιτλου</SubtitleAppendPromptTitle> - <OpenSubtitleToAppend>Άνοιγμα υπότιτλου για προσάρτηση...</OpenSubtitleToAppend> - <AppendViaVisualSyncTitle>Οπτικός συγχρονισμός - προσάρτηση δεύτερου μέρους υπότιτλου</AppendViaVisualSyncTitle> - <AppendSynchronizedSubtitlePrompt>Προσάρτηση του συγχρονισμένου υπότιτλου;</AppendSynchronizedSubtitlePrompt> - <BeforeAppend>Πριν από προσάρτηση</BeforeAppend> - <SubtitleAppendedX>Προσάρτηση υποτίτλου: {0}</SubtitleAppendedX> - <SubtitleNotAppended>Μη προσάρτηση υποτίτλου!</SubtitleNotAppended> - <GoogleTranslate>Μετάφραση Google</GoogleTranslate> - <MicrosoftTranslate>Μετάφραση Bing</MicrosoftTranslate> - <BeforeGoogleTranslation>Πριν από μετάφραση Google</BeforeGoogleTranslation> - <SelectedLinesTranslated>Μετάφραση επιλεγμένων γρραμμών</SelectedLinesTranslated> - <SubtitleTranslated>Μετάφραση υποτίτλου</SubtitleTranslated> - <TranslateSwedishToDanish>Μετάφραση φορτωμένου σουηδικού υποτίτλου σε Δανικά</TranslateSwedishToDanish> - <TranslateSwedishToDanishWarning>Μετάφραση φορτωμένου σουηδικού (σίγουρα είναι σουηδικός;) υπότιτλου σε Δανικά;</TranslateSwedishToDanishWarning> - <TranslatingViaNikseDkMt>Μετάφραση μέσω www.nikse.dk/mt...</TranslatingViaNikseDkMt> - <BeforeSwedishToDanishTranslation>Πριν από μετάφραση Σουηδικών σε Δανικά</BeforeSwedishToDanishTranslation> - <TranslationFromSwedishToDanishComplete>Ολοκλήρωση μετάφρασης Σουηδικών σε Δανικά</TranslationFromSwedishToDanishComplete> - <TranslationFromSwedishToDanishFailed>Αποτυχία μετάφρασης Σουηδικών σε Δανικά</TranslationFromSwedishToDanishFailed> - <UndoPerformed>Εκτέλεση αναίρεσης</UndoPerformed> - <RedoPerformed>Εκτέλεση επανάληψης</RedoPerformed> - <NothingToUndo>Τίποτα για αναίρεση</NothingToUndo> - <InvalidLanguageNameX>Μη έγκυρο όνομα γλώσσας: {0}</InvalidLanguageNameX> - <DoNotDisplayMessageAgain>Απόκρυψη μηνύματος</DoNotDisplayMessageAgain> - <NumberOfCorrectedWords>Σύνολο διορθωμένων λέξεων: {0}</NumberOfCorrectedWords> - <NumberOfSkippedWords>Σύνολο παραλειπόμενων λέξεων: {0}</NumberOfSkippedWords> - <NumberOfCorrectWords>Σύνολο σωστών λέξεων: {0}</NumberOfCorrectWords> - <NumberOfWordsAddedToDictionary>Σύνολο πρόσθετων λέξεων στο λεξικό: {0}</NumberOfWordsAddedToDictionary> - <NumberOfNameHits>Σύνολο ευρέσεων ονομάτων: {0}</NumberOfNameHits> - <SpellCheck>Ορθογραφικός έλεγχος</SpellCheck> - <BeforeSpellCheck>Πριν από ορθογραφικό έλεγχο</BeforeSpellCheck> - <SpellCheckChangedXToY>Ορθογραφικός έλεγχος: Αλλαγή του '{0}' σε '{1}'</SpellCheckChangedXToY> - <BeforeAddingTagX>Πριν από προσθήκη ετικετών &lt;{0}&gt;</BeforeAddingTagX> - <TagXAdded>Προσθήκη &lt;{0}&gt; ετικέτας(ών)</TagXAdded> - <LineXOfY>γραμμή {0} από {1}</LineXOfY> - <XLinesSavedAsY>Αποθήκευση {0} γραμμής(ών) ως {1}</XLinesSavedAsY> - <XLinesDeleted>Διαγραφή {0} γραμμής(ών)</XLinesDeleted> - <BeforeDeletingXLines>Πριν από διαγραφή {0} γραμμών</BeforeDeletingXLines> - <DeleteXLinesPrompt>Διαγραφή {0:#,##0} γραμμών;</DeleteXLinesPrompt> - <OneLineDeleted>Διαγραφή μίας γραμμής</OneLineDeleted> - <BeforeDeletingOneLine>Πριν από διαγραφή μίας γραμμής</BeforeDeletingOneLine> - <DeleteOneLinePrompt>Διαγραφή μίας γραμμής;</DeleteOneLinePrompt> - <BeforeInsertLine>Πριν από εισαγωγή γραμμής</BeforeInsertLine> - <LineInserted>Εισαγωγή γραμμής</LineInserted> - <BeforeLineUpdatedInListView>Πριν από ενημέρωση γραμμής σε προβολή λίστας</BeforeLineUpdatedInListView> - <BeforeSplitLine>Πριν από διαχωρισμό γραμμής</BeforeSplitLine> - <LineSplitted>Διαχώριση γραμμής</LineSplitted> - <BeforeMergeLines>Πριν από συγχώνευση γραμμών</BeforeMergeLines> - <LinesMerged>Συγχώνευση γραμμών</LinesMerged> - <BeforeSettingColor>Πριν από ρύθμιση χρώματος</BeforeSettingColor> - <BeforeSettingFontName>Πριν από ρύθμιση ονόματος γραμματοσειράς</BeforeSettingFontName> - <BeforeTypeWriterEffect>Πριν από εφέ γραφομηχανής</BeforeTypeWriterEffect> - <BeforeKaraokeEffect>Πριν από εφέ καραόκε</BeforeKaraokeEffect> - <BeforeImportingDvdSubtitle>Πριν από εισαγωγή υποτίτλων από DVD</BeforeImportingDvdSubtitle> - <OpenMatroskaFile>Άνοιγμα αρχείου Matroska...</OpenMatroskaFile> - <MatroskaFiles>Αρχεία Matroska</MatroskaFiles> - <NoSubtitlesFound>Αδυναμία εύρεσης υποτίτλων</NoSubtitlesFound> - <NotAValidMatroskaFileX>Μη έγκυρο αρχείο Matroska: {0}</NotAValidMatroskaFileX> - <BlurayNotSubtitlesFound>Το αρχείο Blu-ray .sup δεν περιέχει υπότιτλους ή περιέχει σφάλματα - προσπαθήστε ξανά</BlurayNotSubtitlesFound> - <ImportingChapters>Εισαγωγή κεφαλαίων...</ImportingChapters> - <XChaptersImported>{0} εισαγωγή κεφαλαίου(ων)</XChaptersImported> - <ParsingMatroskaFile>Ανάλυση αρχείου Matroska. Παρακαλώ, περιμένετε...</ParsingMatroskaFile> - <ParsingTransportStreamFile>Ανάλυση αρχείου Trasport Stream. Παρακαλώ, περιμένετε...</ParsingTransportStreamFile> - <BeforeImportFromMatroskaFile>Πριν από εισαγωγή υπότιτλου από αρχείο Matroska</BeforeImportFromMatroskaFile> - <SubtitleImportedFromMatroskaFile>Εισαγωγή υποτίτλου από αρχείο Matroska</SubtitleImportedFromMatroskaFile> - <DropFileXNotAccepted>Απόρριψη συρμένου αρχείου '{0}' - το αρχείο είναι πολύ μεγάλο</DropFileXNotAccepted> - <DropOnlyOneFile>Μπορείτε να σύρετε μόνο ένα αρχείο</DropOnlyOneFile> - <OpenAnsiSubtitle>Άνοιγμα υπότιτλου...</OpenAnsiSubtitle> - <BeforeChangeCasing>Πριν από αλλαγή πεζών-κεφαλαίων</BeforeChangeCasing> - <CasingCompleteMessageNoNames>Σύνολο γραμμών με αλλαγή πεζών-κεφαλαίων: {0}/{1}</CasingCompleteMessageNoNames> - <CasingCompleteMessageOnlyNames>Σύνολο γραμμών με αλλαγή πεζών-κεφαλαίων με ονόματα: {0}/{1}</CasingCompleteMessageOnlyNames> - <CasingCompleteMessage>Σύνολο γραμμών με αλλαγή πεζών-κεφαλαίων: {0}/{1}, αλλαγή πεζών-κεφαλαίων με ονόματα: {2}</CasingCompleteMessage> - <BeforeChangeFrameRate>Πριν από αλλαγή ρυθμού καρέ</BeforeChangeFrameRate> - <BeforeAdjustSpeedInPercent>Πριν ρύθμισης της ταχύτητας σε ποσοστό</BeforeAdjustSpeedInPercent> - <FrameRateChangedFromXToY>Αλλαγή ρυθμού καρέ από {0} σε {1}</FrameRateChangedFromXToY> - <IdxFileNotFoundWarning>Αδυναμία εύρεσης {0}! Εισαγωγή αρχείου VobSub;</IdxFileNotFoundWarning> - <InvalidVobSubHeader>Μη έγκυρη κεφαλίδα του αρχείου VobSub: {0}</InvalidVobSubHeader> - <OpenVobSubFile>Άνοιγμα υπότιτλου VobSub (sub/idx)...</OpenVobSubFile> - <VobSubFiles>Αρχεία υποτίτλων VobSub</VobSubFiles> - <OpenBluRaySupFile>Άνοιγμα αρχείου Blu-ray .sup...</OpenBluRaySupFile> - <BluRaySupFiles>Αρχεία Blu-ray .sup</BluRaySupFiles> - <OpenXSubFiles>Άνοιγμα αρχείου XSub...</OpenXSubFiles> - <XSubFiles>Αρχεία XSub</XSubFiles> - <BeforeImportingVobSubFile>Πριν από εισαγωγή αρχείου VobSub</BeforeImportingVobSubFile> - <BeforeImportingBluRaySupFile>Πριν από εισαγωγή αρχείου Blu-ray sup</BeforeImportingBluRaySupFile> - <BeforeImportingBdnXml>Πριν από εισαγωγή αρχείου BDN xml</BeforeImportingBdnXml> - <BeforeShowSelectedLinesEarlierLater>Πριν από εμφάνιση γραμμών νωρίτερα/αργότερα</BeforeShowSelectedLinesEarlierLater> - <ShowAllLinesXSecondsLinesEarlier>Εμφάνιση όλων των γραμμών {0:0.0##} δευτερόλεπτα νωρίτερα</ShowAllLinesXSecondsLinesEarlier> - <ShowAllLinesXSecondsLinesLater>Εμφάνιση όλων των γραμμών {0:0.0##} δευτερόλεπτα αργότερα</ShowAllLinesXSecondsLinesLater> - <ShowSelectedLinesXSecondsLinesEarlier>Εμφάνιση γραμμών {0:0.0##} δευτερόλεπτα νωρίτερα</ShowSelectedLinesXSecondsLinesEarlier> - <ShowSelectedLinesXSecondsLinesLater>Εμφάνιση γραμμών {0:0.0##} δευτερόλεπτα αργότερα</ShowSelectedLinesXSecondsLinesLater> - <ShowSelectionAndForwardXSecondsLinesEarlier>Εμφάνιση επιλογής και προώθηση {0:0.0##} δευτερόλεπτα νωρίτερα</ShowSelectionAndForwardXSecondsLinesEarlier> - <ShowSelectionAndForwardXSecondsLinesLater>Εμφάνιση επιλογής και προώθηση {0:0.0##} δευτερόλεπτα αργότερα</ShowSelectionAndForwardXSecondsLinesLater> - <DoubleWordsViaRegEx>Διπλές λέξεις μέσω τυπικής έκφρασης {0}</DoubleWordsViaRegEx> - <BeforeSortX>Πριν από ταξινόμηση: {0}</BeforeSortX> - <SortedByX>Ταξινόμηση κατά: {0}</SortedByX> - <BeforeAutoBalanceSelectedLines>Πριν από αυτόματη ισορρόπιση γραμμών</BeforeAutoBalanceSelectedLines> - <NumberOfLinesAutoBalancedX>Σύνολο αυτόματων ισορροπημένων γραμμών: {0}</NumberOfLinesAutoBalancedX> - <BeforeRemoveLineBreaksInSelectedLines>Πριν από αφαίρεση διάσπασης επιλεγμένων γραμμών</BeforeRemoveLineBreaksInSelectedLines> - <NumberOfWithRemovedLineBreakX>Σύνολο γραμμών που αφαιρέθηκαν διασπάσεις γραμμής: {0}</NumberOfWithRemovedLineBreakX> - <BeforeMultipleReplace>Πριν από πολλαπλή αντικατάσταση</BeforeMultipleReplace> - <NumberOfLinesReplacedX>Σύνολο γραμμών αντικατεστημένου κειμένου: {0}</NumberOfLinesReplacedX> - <NameXAddedToNameList>Προσθήκη ονόματος '{0}' στη λίστα ονομάτων</NameXAddedToNameList> - <NameXNotAddedToNameList>Μη προσθήκη ονόματος '{0}' στη λίστα ονομάτων</NameXNotAddedToNameList> - <WordXAddedToUserDic>Προσθήκη λέξης '{0}' στο λεξικό χρήστη</WordXAddedToUserDic> - <WordXNotAddedToUserDic>Μη προσθήκη λέξης '{0}' στο λεξικό χρήστη</WordXNotAddedToUserDic> - <OcrReplacePairXAdded>Τα ζεύγη των λιστών αντικατάστασης του OCR '{0} -&gt; {1}' προστέθηκαν στις λίστες αντικατάστασης του OCR</OcrReplacePairXAdded> - <OcrReplacePairXNotAdded>Τα ζεύγη των λιστών αντικατάστασης του OCR '{0} -&gt; {1}' δεν προστέθηκαν στις λίστες αντικατάστασης του OCR</OcrReplacePairXNotAdded> - <XLinesSelected>Επιλογή {0} γραμμής(ών)</XLinesSelected> - <UnicodeMusicSymbolsAnsiWarning>Ο υπότιτλος περιέχει unicode μουσικές νότες. Αν αποθηκευτεί χρησιμοποιώντας κωδικοποίηση ANSI θα χαθούν. Συνέχιση αποθήκευσης;</UnicodeMusicSymbolsAnsiWarning> - <NegativeTimeWarning>Ο υπότιτλος περιέχει αρνητικούς κωδικούς χρόνου. Συνέχιση αποθήκευσης;</NegativeTimeWarning> - <BeforeMergeShortLines>Πριν από συγχώνευση μικρών γραμμών</BeforeMergeShortLines> - <MergedShortLinesX>Σύνολο συγχωνευμένων γραμμών: {0}</MergedShortLinesX> - <BeforeSplitLongLines>Πριν από διαχωρισμό μεγάλων γραμμών</BeforeSplitLongLines> - <LongLinesSplitX>Σύνολο διαχωρισμένων γραμμών: {0}</LongLinesSplitX> - <BeforeDurationsBridgeGap>Πριν την ένωση μικρών κενών</BeforeDurationsBridgeGap> - <BeforeSetMinimumDisplayTimeBetweenParagraphs>Πριν από ορισμό ελάχιστου χρόνου εμφάνισης μεταξύ υποτίτλων</BeforeSetMinimumDisplayTimeBetweenParagraphs> - <XMinimumDisplayTimeBetweenParagraphsChanged>Σύνολο γραμμών αλλαγής ελάχιστου χρόνου εμφάνισης μεταξύ υποτίτλων: {0}</XMinimumDisplayTimeBetweenParagraphsChanged> - <BeforeImportText>Πριν από εισαγωγή απλού κειμένου</BeforeImportText> - <TextImported>Εισαγωγή κειμένου</TextImported> - <BeforePointSynchronization>Πριν από συγχρονισμό σημείων</BeforePointSynchronization> - <PointSynchronizationDone>Ολοκλήρωση συγχρονισμού σημείων</PointSynchronizationDone> - <BeforeTimeCodeImport>Πριν από εισαγωγή κωδικών χρόνου</BeforeTimeCodeImport> - <TimeCodeImportedFromXY>Εισαγωγή κωδικών χρόνων από {0}: {1}</TimeCodeImportedFromXY> - <BeforeInsertSubtitleAtVideoPosition>Πριν από εισαγωγή υπότιτλου στη θέση βίντεο</BeforeInsertSubtitleAtVideoPosition> - <BeforeSetStartTimeAndOffsetTheRest>Πριν ορισμού χρόνου έναρξης και αντιστάθμισης</BeforeSetStartTimeAndOffsetTheRest> - <BeforeSetEndTimeAndOffsetTheRest>Πριν ορισμού χρόνου λήξης και αντιστάθμισης</BeforeSetEndTimeAndOffsetTheRest> - <BeforeSetEndAndVideoPosition>Πριν ορισμού χρόνου λήξης στη θέση βίντεο και αυτόματος υπολογισμός έναρξης</BeforeSetEndAndVideoPosition> - <ContinueWithCurrentSpellCheck>Συνέχιση τρέχοντος ορθογραφικού ελέγχου;</ContinueWithCurrentSpellCheck> - <CharactersPerSecond>Χαρακτήρες/δευτ.: {0:0.00}</CharactersPerSecond> - <GetFrameRateFromVideoFile>Λήψη ρυθμού καρέ από αρχείο βίντεο</GetFrameRateFromVideoFile> - <NetworkMessage>Νέο μήνυμα: {0} ({1}): {2}</NetworkMessage> - <NetworkUpdate>Ενημέρωση γραμμής: {0} ({1}): Δείκτης={2}, Κείμενο={3}</NetworkUpdate> - <NetworkInsert>Εισαγωγή γραμμής: {0} ({1}): Δείκτης={2}, Κείμενο={3}</NetworkInsert> - <NetworkDelete>Διαγραφή γραμμής: {0} ({1}): Δείκτης={2}</NetworkDelete> - <NetworkNewUser>Νέος χρήστης: {0} ({1})</NetworkNewUser> - <NetworkByeUser>Αντίο {0} ({1})</NetworkByeUser> - <NetworkUnableToConnectToServer>Αδυναμία σύνδεσης με τον διακομιστή: {0}</NetworkUnableToConnectToServer> - <UserAndAction>Χρήστης/ενέργεια</UserAndAction> - <NetworkMode>Λειτουργία δικτύου</NetworkMode> - <XStartedSessionYAtZ>{0}: Έναρξη συνεδρίας {1} στο {2}</XStartedSessionYAtZ> - <OpenOtherSubtitle>Άνοιγμα άλλου υπότιτλου</OpenOtherSubtitle> - <BeforeToggleDialogDashes>Πριν την εναλλαγή παυλών διαλόγου</BeforeToggleDialogDashes> - <ExportPlainTextAs>Εξαγωγή απλού αρχείου κειμένου ως</ExportPlainTextAs> - <TextFiles>Αρχεία κειμένου</TextFiles> - <SubtitleExported>Εξαγωγή υποτίτλου</SubtitleExported> - <LineNumberXErrorReadingFromSourceLineY>Γραμμή {0} - σφάλμα ανάγνωσης: {1}</LineNumberXErrorReadingFromSourceLineY> - <LineNumberXErrorReadingTimeCodeFromSourceLineY>Γραμμή {0} - σφάλμα ανάγνωσης κώδικα χρόνου: {1}</LineNumberXErrorReadingTimeCodeFromSourceLineY> - <LineNumberXExpectedNumberFromSourceLineY>Γραμμή {0} - αναμενόμενος αριθμός υποτίτλου: {1}</LineNumberXExpectedNumberFromSourceLineY> - <LineNumberXExpectedEmptyLine>Γραμμή {0} - αναμενόμενη κενή γραμμή, αλλά βρέθηκε αριθμός + κώδικας χρόνου (παραλειπόμενος αριθμός): {1}</LineNumberXExpectedEmptyLine> - <BeforeGuessingTimeCodes>Πριν τον υπολογισμό κωδικών χρόνου</BeforeGuessingTimeCodes> - <BeforeAutoDuration>Πριν την αυτόματη διάρκεια επιλεγμένων γραμμών</BeforeAutoDuration> - <BeforeColumnPaste>Πριν την επικόλληση στήλης</BeforeColumnPaste> - <BeforeColumnDelete>Πριν την διαγραφή στήλης</BeforeColumnDelete> - <BeforeColumnImportText>Πριν την εισαγωγή κειμένου στήλης</BeforeColumnImportText> - <BeforeColumnShiftCellsDown>Πριν την μετατόπιση των κελιών στήλης προς τα κάτω</BeforeColumnShiftCellsDown> - <BeforeX>Πριν: {0}</BeforeX> - <LinesUpdatedX>Ενημερωμένες γραμμές: {0}</LinesUpdatedX> - <ErrorLoadingPluginXErrorY>Σφάλμα φόρτωσης πρόσθετου: {0}: {1}</ErrorLoadingPluginXErrorY> - <BeforeRunningPluginXVersionY>Πριν την εκτέλεση πρόσθετου: {0}: {1}</BeforeRunningPluginXVersionY> - <UnableToReadPluginResult>Αδυναμία ανάγνωσης αποτελέσματος υποτίτλου από το πρόσθετο!</UnableToReadPluginResult> - <UnableToCreateBackupDirectory>Αδυναμία δημιουργίας φακέλου αντίγραφου ασφαλείας {0}: {1}</UnableToCreateBackupDirectory> - <BeforeDisplaySubtitleJoin>Πριν την ένωση υποτίτλων</BeforeDisplaySubtitleJoin> - <SubtitlesJoined>Ένωση υποτίτλων</SubtitlesJoined> - <StatusLog>Κατάσταση αρχείου καταγραφής</StatusLog> - <XSceneChangesImported>Εισαγωγή {0} αλλαγής(ών) σκηνής</XSceneChangesImported> - <PluginXExecuted>Εκτέλεση πρόσθετου '{0}'.</PluginXExecuted> - <NotAValidXSubFile>Μη έγκυρο αρχείο XSub!</NotAValidXSubFile> - <BeforeMergeLinesWithSameText>Πριν από συγχώνευση γραμμών ίδιου κειμένου</BeforeMergeLinesWithSameText> - <ImportTimeCodesDifferentNumberOfLinesWarning>Ο υπότιτλος με τους κώδικες χρόνου έχει διαφορετικό αριθμό γραμμών ({0}) από τον τρέχων υπότιτλο ({1}) - Συνέχιση;</ImportTimeCodesDifferentNumberOfLinesWarning> - <ParsingTransportStream>Ανάλυση αρχείου TS - παρακαλώ, περιμένετε...</ParsingTransportStream> - <XPercentCompleted>{0}%</XPercentCompleted> - <NextX>Επόμενο: {0}</NextX> - <PromptInsertSubtitleOverlap>Η εισαγωγή υπότιτλου στη θέση κυματομορφής θα προκαλέσει επικάλυψη! -Συνέχιση;</PromptInsertSubtitleOverlap> - <SubtitleContainsNegativeDurationsX>Εύρεση αρνητικής διάρκειας γραμμής(ών): {0}</SubtitleContainsNegativeDurationsX> - <SetPlayRateX>Ορισμός ρυθμού αναπαραγωγής σε {0}%</SetPlayRateX> - <ErrorLoadIdx>Αδυναμία ανάγνωσης/επεξεργασίας αρχείων .idx. Τα αρχεία .idx είναι μέλη από τα ζεύγη idx/sub αρχείων (γνωστά ως VobSub) και ο Subtitle Edit δεν μπορεί να ανοίξει αρχείο .sub.</ErrorLoadIdx> - <ErrorLoadRar>Πιθανό συμπιεσμένο αρχείο .rar. Το Subtitle Edit δεν μπορεί να ανοίξει συμπιεσμένα αρχεία.</ErrorLoadRar> - <ErrorLoadZip>Πιθανό συμπιεσμένο αρχείο .zip. Το Subtitle Edit δεν μπορεί να ανοίξει συμπιεσμένα αρχεία.</ErrorLoadZip> - <ErrorLoad7Zip>Πιθανό συμπιεσμένο αρχείο 7-Zip. Το Subtitle Edit δεν μπορεί να ανοίξει συμπιεσμένα αρχεία.</ErrorLoad7Zip> - <ErrorLoadPng>Πιθανό αρχείο εικόνας PNG. Το Subtitle Edit δεν μπορεί να ανοίξει αρχεία PNG.</ErrorLoadPng> - <ErrorLoadJpg>Πιθανό αρχείο εικόνας JPG. Το Subtitle Edit δεν μπορεί να ανοίξει αρχεία JPG.</ErrorLoadJpg> - <ErrorLoadSrr>Πιθανό αρχείο .srr - όχι αρχείο υπότιτλου.</ErrorLoadSrr> - <ErrorLoadTorrent>Πιθανό αρχείο BitTorrent - όχι αρχείο υπότιτλου.</ErrorLoadTorrent> - <ErrorLoadBinaryZeroes>Συγγνώμη, το αρχείο περιέχει μόνο δυαδικά μηδενικά! -Αν είναι επεξεργασμένο με το Subtitle Edit, ίσως βρείτε αντίγραφο ασφαλείας μέσω της επιλογής Αρχείο -&gt; Επαναφορά αντίγραφου ασφαλείας...</ErrorLoadBinaryZeroes> - <ErrorDirectoryDropNotAllowed>Το σύρσιμο φακέλων δεν υποστηρίζεται.</ErrorDirectoryDropNotAllowed> - <NoSupportEncryptedVobSub>Το κρυπτογραφημένο περιεχόμενο VobSub δεν υποστηρίζεται.</NoSupportEncryptedVobSub> - <NoSupportHereBluRaySup>Τα αρχεία Blu-ray sup δεν υποστηρίζονται.</NoSupportHereBluRaySup> - <NoSupportHereDvdSup>Τα αρχεία DVD sup δεν υποστηρίζονται.</NoSupportHereDvdSup> - <NoSupportHereVobSub>Τα αρχεία VoSub δεν υποστηρίζονται.</NoSupportHereVobSub> - <NoSupportHereDivx>Τα αρχεία Divx δεν υποστηρίζονται.</NoSupportHereDivx> - <NoChapters>Αδυναμία εύρεσης κεφαλαίων βίντεο.</NoChapters> - </Main> - <MatroskaSubtitleChooser> - <Title>Επιλογή υπότιτλου από αρχείο Matroska</Title> - <TitleMp4>Επιλογή υπότιτλου από αρχείο MP4</TitleMp4> - <PleaseChoose>Βρέθηκαν περισσότεροι από έναν υπότιτλο - παρακαλώ, επιλέξτε</PleaseChoose> - <TrackXLanguageYTypeZ>Κομμάτι {0} - γλώσσα: {1} - τύπος: {2}</TrackXLanguageYTypeZ> - </MatroskaSubtitleChooser> - <MeasurementConverter> - <Title>Μετατροπέας μονάδων μέτρησης</Title> - <ConvertFrom>Μετατροπή από</ConvertFrom> - <ConvertTo>Μετατροπή σε</ConvertTo> - <CopyToClipboard>Αντιγραφή στο πρόχειρο</CopyToClipboard> - <Length>Μήκος</Length> - <Mass>Μάζα</Mass> - <Volume>Όγκος</Volume> - <Area>Έκταση</Area> - <Time>Χρόνος</Time> - <Temperature>Θερμοκρασία</Temperature> - <Velocity>Ταχύτητα</Velocity> - <Force>Ισχύς</Force> - <Energy>Ενέργεια</Energy> - <Power>Ρεύμα</Power> - <Pressure>Πίεση</Pressure> - <Kilometers>Χιλιόμετρα</Kilometers> - <Meters>Μέτρα</Meters> - <Centimeters>Εκατοστά</Centimeters> - <Millimeters>Χιλιοστά</Millimeters> - <Micrometers>Μικρόμετρα</Micrometers> - <Nanometers>Νανόμετρα</Nanometers> - <Angstroms>Άνγκστρομα</Angstroms> - <MilesTerrestial>Μίλια</MilesTerrestial> - <MilesNautical>Ναυτικά μίλια</MilesNautical> - <Yards>Γιάρδες</Yards> - <Feet>Πόδια</Feet> - <Inches>Ίντσες</Inches> - <Chains>Τσέιν (μήκος)</Chains> - <Fathoms>Οργιές</Fathoms> - <Hands>Δείκτες</Hands> - <Rods>Ράβδοι</Rods> - <Spans>Ανοίγματα</Spans> - <LongTonnes>Τόνοι (ΗΒ)</LongTonnes> - <ShortTonnes>Τόνοι (ΗΠΑ)</ShortTonnes> - <Tonnes>Τόνοι</Tonnes> - <Kilos>Κιλά</Kilos> - <Grams>Γραμμάρια</Grams> - <Milligrams>Χιλιόγραμμα</Milligrams> - <Micrograms>Μικρογραμμάρια</Micrograms> - <Pounds>Λίβρες</Pounds> - <Ounces>Ουγγιές</Ounces> - <Carats>Καράτια</Carats> - <Drams>Δράμια</Drams> - <Grains>Κόκοι</Grains> - <Stones>Κιλά (βάρος σώματος)</Stones> - <CubicKilometers>Κυβικά χιλιόμετρα</CubicKilometers> - <CubicMeters>Κυβικά μέτρα</CubicMeters> - <Litres>Λίτρα</Litres> - <CubicCentimeters>Κυβικά εκατοστά</CubicCentimeters> - <CubicMillimeters>Κυβικά χιλιοστά</CubicMillimeters> - <CubicMiles>Κυβικά μίλια</CubicMiles> - <CubicYards>Κυβικές γιάρδες</CubicYards> - <CubicFTs>Κυβικά πόδια</CubicFTs> - <CubicInches>Κυβικές ίντσες</CubicInches> - <OilBarrels>Βαρέλια πετρελαίου</OilBarrels> - <GallonUS>Γαλόνι (ΗΠΑ)</GallonUS> - <QuartsUS>Λίτρα (ΗΠΑ)</QuartsUS> - <PintsUS>Πίντες (ΗΠΑ)</PintsUS> - <FluidOuncesUS>Ουγγιές υγρών (ΗΠΑ)</FluidOuncesUS> - <Bushels>Μόδια</Bushels> - <Pecks>Πεκς (μονάδα μέτρησης στερεών)</Pecks> - <GallonsUK>Γαλόνια (ΗΒ)</GallonsUK> - <QuartsUK>Λίτρα (ΗΒ)</QuartsUK> - <PintsUK>Πίντες (ΗΒ)</PintsUK> - <FluidOuncesUK>Ουγγιές υγρών (ΗΒ)</FluidOuncesUK> - <SquareKilometers>Τετραγωνικά χιλιόμετρα</SquareKilometers> - <SquareMeters>Τετραγωνικά μέτρα</SquareMeters> - <SquareCentimeters>Τετραγωνικά εκατοστά</SquareCentimeters> - <SquareMillimeters>Τετραγωνικά χιλιοστά</SquareMillimeters> - <SquareMiles>Τετραγωνικά μίλια</SquareMiles> - <SquareYards>Τετραγωνικές γιάρδες</SquareYards> - <SquareFTs>Τετραγωνικά πόδια</SquareFTs> - <SquareInches>Τετραγωνικές ίντσες</SquareInches> - <Hectares>Εκτάρια</Hectares> - <Acres>Στρέμματα</Acres> - <Ares>Άρια</Ares> - <Hours>¨Ωρες</Hours> - <Minutes>Λεπτά</Minutes> - <Seconds>Δευτερόλεπτα</Seconds> - <Milliseconds>Χιλιοστά δευτερολέπτου</Milliseconds> - <Microseconds>Μικροδευτερόλεπτα</Microseconds> - <Fahrenheit>Φαρενάιτ</Fahrenheit> - <Celsius>Κελσίου</Celsius> - <Kelvin>Κέλβιν</Kelvin> - <KilometersPerHour>Χλμ/ώρα</KilometersPerHour> - <MetersPerSecond>Μέτρα/δευτερόλεπτο</MetersPerSecond> - <MilesPerHour>Μίλια/ώρα</MilesPerHour> - <YardsPerMinute>Γιάρδες/λεπτό</YardsPerMinute> - <FTsPerSecond>Πόδια/δευτερόλεπτο</FTsPerSecond> - <Knots>Κόμβοι</Knots> - <PoundsForce>Λίβρες ισχύος</PoundsForce> - <Newtons>Νιούτον</Newtons> - <KilosForce>Κιλά ισχύος</KilosForce> - <Jouls>Τζάουλ</Jouls> - <Calories>Θερμίδες</Calories> - <Ergs>Έργια</Ergs> - <ElectronVolts>Ηλεκτρονιοβόλτ</ElectronVolts> - <Btus>BTU</Btus> - <Watts>Βατ</Watts> - <Horsepower>Ιπποδύναμη</Horsepower> - <Atmospheres>Ατμόσφαιρες</Atmospheres> - <Bars>Μπαρ</Bars> - <Pascals>Πασκάλ</Pascals> - <MillimetersOfMercury>Χιλιοστά υδραργύρου (πίεση)</MillimetersOfMercury> - <PoundPerSquareInch>Λίβρες ισχύος ανά τετραγωνική ίντσα</PoundPerSquareInch> - <KilogramPerSquareCentimeter>Κιλά ισχύος ανά τετραγωνικό εκατοστό</KilogramPerSquareCentimeter> - <KiloPascals>Κιλοπασκάλ</KiloPascals> - </MeasurementConverter> - <MergeDoubleLines> - <Title>Συγχώνευση γραμμών με ίδιο κείμενο</Title> - <MaxMillisecondsBetweenLines>Μέγιστα χιλ. δευτερολέπτου μεταξύ των γραμμών</MaxMillisecondsBetweenLines> - <IncludeIncrementing>Συμπερίληψη προσαυξημένων γραμμών</IncludeIncrementing> - </MergeDoubleLines> - <MergedShortLines> - <Title>Συγχώνευση μικρών γραμμών</Title> - <MaximumCharacters>Μέγιστος αριθμός χαρακτήρων ανα παράγραφο</MaximumCharacters> - <MaximumMillisecondsBetween>Μέγιστος αριθμός χιλ. δευτερολέπτου μεταξύ των γραμμών</MaximumMillisecondsBetween> - <NumberOfMergesX>Σύνολο συγχωνεύσεων: {0}</NumberOfMergesX> - <MergedText>Συγχωνευμένο κείμενο</MergedText> - <OnlyMergeContinuationLines>Συγχώνευση μόνο συνεχόμενων γραμμών</OnlyMergeContinuationLines> - </MergedShortLines> - <MergeTextWithSameTimeCodes> - <Title>Συγχώνευση γραμμών με ίδιους κωδικούς χρόνου</Title> - <MaxDifferenceMilliseconds>Μέγιστη διαφορά χιλιοστών δευτερολέπτου</MaxDifferenceMilliseconds> - <ReBreakLines>Επαναδιάσπαση γραμμών</ReBreakLines> - <NumberOfMergesX>Αριθμός συγχωνεύσεων: {0}</NumberOfMergesX> - <MergedText>Συγχωνευμένο κείμενο</MergedText> - </MergeTextWithSameTimeCodes> - <ModifySelection> - <Title>Επεξεργασία επιλογής</Title> - <Rule>Κανόνας</Rule> - <CaseSensitive>Διάκριση πεζών</CaseSensitive> - <DoWithMatches>Ενέργεια με τις αντιστοιχίες</DoWithMatches> - <MakeNewSelection>Δημιουργία νέας επιλογής</MakeNewSelection> - <AddToCurrentSelection>Προσθήκη στην τρέχουσα επιλογή</AddToCurrentSelection> - <SubtractFromCurrentSelection>Αφαίρεση από την τρέχουσα επιλογή</SubtractFromCurrentSelection> - <IntersectWithCurrentSelection>Διασταύρωση με την τρέχουσα επιλογή</IntersectWithCurrentSelection> - <MatchingLinesX>Γραμμές που ταιριάζουν: {0}</MatchingLinesX> - <Contains>Περιέχει</Contains> - <StartsWith>Ξεκινά με</StartsWith> - <EndsWith>Τελειώνει με</EndsWith> - <NoContains>Δεν περιέχει</NoContains> - <RegEx>Τυπική έκφραση</RegEx> - <UnequalLines>Άνισες γραμμές</UnequalLines> - <EqualLines>Ίσες γραμμές</EqualLines> - <DurationLessThan>Διάρκεια μικρότερη από</DurationLessThan> - <DurationGreaterThan>Διάρκεια μεγαλύτερη από</DurationGreaterThan> - <MoreThanTwoLines>Πάνω από δύο γραμμές</MoreThanTwoLines> - </ModifySelection> - <MultipleReplace> - <Title>Πολλαπλή αντικατάσταση</Title> - <FindWhat>Εύρεση του</FindWhat> - <ReplaceWith>Αντικατάσταση με</ReplaceWith> - <Normal>Κανονική</Normal> - <CaseSensitive>Διάκριση πεζών-κεφαλαίων</CaseSensitive> - <RegularExpression>Τυπική έκφραση</RegularExpression> - <Description>Περιγραφή</Description> - <LinesFoundX>Γραμμές που βρέθηκαν: {0}</LinesFoundX> - <Remove>Αφαίρεση</Remove> - <Add>Προσθήκη</Add> - <Update>&amp;Ενημέρωση</Update> - <Enabled>Ενεργοποίηση</Enabled> - <SearchType>Τύπος αναζήτησης</SearchType> - <RemoveAll>Αφαίρεση όλων</RemoveAll> - <Import>Εισαγωγή...</Import> - <Export>Εξαγωγή...</Export> - <ImportRulesTitle>Εισαγωγή κανόνων αντικατάστασης από...</ImportRulesTitle> - <ExportRulesTitle>Εξαγωγή κανόνων αντικατάστασης σε...</ExportRulesTitle> - <ChooseGroupsToImport>Επιλογή ομάδων εισαγωγής</ChooseGroupsToImport> - <ChooseGroupsToExport>Επιλογή ομάδων εξαγωγής</ChooseGroupsToExport> - <Rules>Εξαγωγή κανόνων</Rules> - <MoveToTop>Νετακίνηση στην κορυφή</MoveToTop> - <MoveToBottom>Μετακίνηση στο τέλος</MoveToBottom> - <MoveSelectedRulesToGroup>Μετακίνηση επιλεγμένων κανόνων στην ομάδα</MoveSelectedRulesToGroup> - <Groups>Ομάδες</Groups> - <RulesForGroupX>Κανόνες ομάδας "{0}"</RulesForGroupX> - <GroupName>Όνομα ομάδας</GroupName> - <RenameGroup>Μετονομασία ομάδας...</RenameGroup> - <NewGroup>Νέα ομάδα...</NewGroup> - <NothingToImport>Τίποτα προς εισαγωγή</NothingToImport> - </MultipleReplace> - <NetworkChat> - <Title>Συνομιλία</Title> - <Send>Αποστολή</Send> - </NetworkChat> - <NetworkJoin> - <Title>Συμμετοχή σε δικτυακή συνεδρία</Title> - <Information>Συμμετοχή σε υπάρχουσα συνεδρία όπου πολλά άτομα -μπορούν να επεξεργαστούν το ίδιο αρχείο υπότιτλου (συνεργασία)</Information> - <Join>Συμμετοχή</Join> - </NetworkJoin> - <NetworkLogAndInfo> - <Title>Πληροφορίες και καταγραφή συνεδρίας</Title> - <Log>Αρχείο καταγραφής:</Log> - </NetworkLogAndInfo> - <NetworkStart> - <Title>Έναρξη δικτυακής συνεδρίας</Title> - <ConnectionTo>Σύνδεση με {0}...</ConnectionTo> - <Information>Έναρξη νέας συνεδρίας όπου πολλά άτομα -μπορούν να επεξεργαστούν το ίδιο αρχείο υπότιτλου (συνεργασία)</Information> - <Start>Έναρξη</Start> - </NetworkStart> - <OpenVideoDvd> - <Title>Άνοιγμα DVD με το VLC</Title> - <OpenDvdFrom>Άνοιγμα DVD με...</OpenDvdFrom> - <Disc>Δίσκος</Disc> - <Folder>Φάκελος</Folder> - <ChooseDrive>Επιλογή οδηγού</ChooseDrive> - <ChooseFolder>Επιλογή φακέλου</ChooseFolder> - </OpenVideoDvd> - <PluginsGet> - <Title>Πρόσθετα</Title> - <InstalledPlugins>Εγκαταστημένα πρόσθετα</InstalledPlugins> - <GetPlugins>Λήψη πρόσθετων</GetPlugins> - <Description>Περιγραφή</Description> - <Version>Έκδοση</Version> - <Date>Ημερομηνία</Date> - <Type>Τύπος</Type> - <OpenPluginsFolder>Άνοιγμα φακέλου 'Plugins'</OpenPluginsFolder> - <GetPluginsInfo1>Λήψη πρόσθετων του Subtitle Edit στον φάκελο 'Plugins'</GetPluginsInfo1> - <GetPluginsInfo2>Επιλογή πρόσθετου και κάντε κλικ στο 'Λήψη'</GetPluginsInfo2> - <PluginXDownloaded>Λήψη πρόσθετου {0}</PluginXDownloaded> - <Download>&amp;Λήψη</Download> - <Remove>&amp;Αφαίρεση</Remove> - <UpdateAllX>Ενημέρωση όλων ({0})</UpdateAllX> - <UnableToDownloadPluginListX>Αδυναμία λήψης λίστας πρόσθετων: {0}</UnableToDownloadPluginListX> - <NewVersionOfSubtitleEditRequired>Απαιτείται νεότερη έκδοση του Subtitle Edit!</NewVersionOfSubtitleEditRequired> - <UpdateAvailable>[Διαθέσιμη ενημέρωση!]</UpdateAvailable> - <UpdateAll>Ενημέρωση όλων</UpdateAll> - <XPluginsUpdated>{0} πρόσθετο/α ενημερώθηκαν</XPluginsUpdated> - </PluginsGet> - <RegularExpressionContextMenu> - <WordBoundary>Όριο λέξης (\b)</WordBoundary> - <NonWordBoundary>Δίχως όριο λέξης (\B)</NonWordBoundary> - <NewLine>Νέα γραμμή (\r\n)</NewLine> - <NewLineShort>Νέα γραμμή (\n)</NewLineShort> - <AnyDigit>Οποιοδήποτε ψηφίο (\d)</AnyDigit> - <NonDigit>Μη ψηφίο (\D)</NonDigit> - <AnyCharacter>Οποιοσδήποτε χαρακτήρας (.)</AnyCharacter> - <AnyWhitespace>Οποιοδήποτε κενό (\s)</AnyWhitespace> - <NonSpaceCharacter>Μη χαρακτήρας κενού (\S)</NonSpaceCharacter> - <ZeroOrMore>Μηδέν ή περισσότερα (*)</ZeroOrMore> - <OneOrMore>Ένα ή περισσότερα (+)</OneOrMore> - <InCharacterGroup>Στο σύνολο χαρακτήρων ([δοκιμή])</InCharacterGroup> - <NotInCharacterGroup>Όχι στο σύνολο χαρακτήρων ([^δοκιμή])</NotInCharacterGroup> - </RegularExpressionContextMenu> - <RemoveTextFromHearImpaired> - <Title>Αφαίρεση κειμένου για κωφούς</Title> - <RemoveTextConditions>Αφαίρεση συνθηκών κειμένου</RemoveTextConditions> - <RemoveTextBetween>Αφαίρεση κειμένου μεταξύ</RemoveTextBetween> - <SquareBrackets>'[' και ']'</SquareBrackets> - <Brackets>'{' και '}'</Brackets> - <Parentheses>'(' και ')'</Parentheses> - <QuestionMarks>'?' και '?'</QuestionMarks> - <And>και</And> - <RemoveTextBeforeColon>Αφαίρεση κειμένου πριν άνω και κάτω τελείας (':')</RemoveTextBeforeColon> - <OnlyIfTextIsUppercase>Μόνο κείμενο σε κεφαλαία</OnlyIfTextIsUppercase> - <OnlyIfInSeparateLine>Μόνο σε ξεχωριστή γραμμή</OnlyIfInSeparateLine> - <LinesFoundX>Εύρεση γραμμής(ών): {0}</LinesFoundX> - <RemoveTextIfContains>Αφαίρεση κειμένου εάν περιέχει:</RemoveTextIfContains> - <RemoveTextIfAllUppercase>Αφαίρεση γραμμής με κεφαλαία</RemoveTextIfAllUppercase> - <RemoveInterjections>Αφαίρεση επιφωνημάτων</RemoveInterjections> - <EditInterjections>Επεξεργασία...</EditInterjections> - </RemoveTextFromHearImpaired> - <ReplaceDialog> - <Title>Αντικατάσταση</Title> - <FindWhat>Εύρεση του:</FindWhat> - <Normal>Κανονική</Normal> - <CaseSensitive>Διάκριση πεζών-κεφαλαίων</CaseSensitive> - <RegularExpression>Τυπική έκφραση</RegularExpression> - <ReplaceWith>Αντικατάσταση με</ReplaceWith> - <Find>&amp;Εύρεση</Find> - <Replace>&amp;Αντικατάσταση</Replace> - <ReplaceAll>Αντικατάσταση ό&amp;λων</ReplaceAll> - </ReplaceDialog> - <RestoreAutoBackup> - <Title>Επαναφορά αντιγράφων ασφαλείας</Title> - <Information>Άνοιγμα αντιγράφων ασφαλείας</Information> - <DateAndTime>Ημερομηνία</DateAndTime> - <FileName>Όνομα αρχείου</FileName> - <Extension>Επέκταση</Extension> - <NoBackedUpFilesFound>Αδυναμία εύρεσης αντιγράφων ασφαλείας!</NoBackedUpFilesFound> - </RestoreAutoBackup> - <SeekSilence> - <Title>Αναζήτηση σιωπής</Title> - <SearchDirection>Κατεύθυνση αναζήτησης</SearchDirection> - <Forward>Εμπρός</Forward> - <Back>Πίσω</Back> - <LengthInSeconds>Ελάχιστη σιωπή (δευτερόλεπτα)</LengthInSeconds> - <MaxVolume>Ένταση ήχου κάτω από</MaxVolume> - </SeekSilence> - <SetMinimumDisplayTimeBetweenParagraphs> - <Title>Ορισμός ελάχιστου κενού υπότίτλων</Title> - <PreviewLinesModifiedX>Προεπισκόπηση - τροποποιημένοι υπότιτλοι: {0}</PreviewLinesModifiedX> - <ShowOnlyModifiedLines>Εμφάνιση μόνο τροποποιημένων γραμμών</ShowOnlyModifiedLines> - <MinimumMillisecondsBetweenParagraphs>Ελάχιστα χιλ. δευτερολέπτου μεταξύ γραμμών</MinimumMillisecondsBetweenParagraphs> - <FrameInfo>Πληροφορίες ρυθμού καρέ</FrameInfo> - <Frames>Καρέ</Frames> - <XFrameYisZMilliseconds>{0} καρέ στα {1} καρέ/δευτερόλεπτο είναι {2} χιλ. του δευτερολέπτου</XFrameYisZMilliseconds> - </SetMinimumDisplayTimeBetweenParagraphs> - <SetSyncPoint> - <Title>Ορισμός σημείου συγχρονισμού για τη γραμμή {0}</Title> - <SyncPointTimeCode>Κωδικός χρόνου σημείου συγχρονισμού</SyncPointTimeCode> - <ThreeSecondsBack>&lt;&lt; 3 δευτ.</ThreeSecondsBack> - <HalfASecondBack>&lt;&lt; ½ δευτ.</HalfASecondBack> - <HalfASecondForward>½ δευτ. &gt;&gt;</HalfASecondForward> - <ThreeSecondsForward>3 δευτ. &gt;&gt;</ThreeSecondsForward> - </SetSyncPoint> - <Settings> - <Title>Ρυθμίσεις</Title> - <General>Γενικά</General> - <Toolbar>Γραμμή εργαλείων</Toolbar> - <VideoPlayer>Πρόγραμμα αναπαραγωγής</VideoPlayer> - <WaveformAndSpectrogram>Κυματομορφή/φασματογράφημα</WaveformAndSpectrogram> - <Tools>Εργαλεία</Tools> - <WordLists>Λίστες λέξεων</WordLists> - <SsaStyle>Στυλ ASS/SSA</SsaStyle> - <Network>Δίκτυο</Network> - <Rules>Κανόνες</Rules> - <ShowToolBarButtons>Εμφάνιση κουμπιών της γραμμής εργαλείων</ShowToolBarButtons> - <New>Νέο</New> - <Open>Άνοιγμα</Open> - <Save>Αποθήκευση</Save> - <SaveAs>Αποθήκευση ως</SaveAs> - <Find>Εύρεση</Find> - <Replace>Αντικατάσταση</Replace> - <VisualSync>Οπτικός συγχρονισμός</VisualSync> - <SpellCheck>Ορθογραφικός έλεγχος</SpellCheck> - <NetflixQualityCheck>Έλεγχος ποιότητας Netflix</NetflixQualityCheck> - <SettingsName>Ρυθμίσεις</SettingsName> - <Help>Βοήθεια</Help> - <UnbreakNoSpace>Συνένωση χωρίς κενό (CJK)</UnbreakNoSpace> - <ToggleBookmarks>Εναλλαγή σημειώσεων</ToggleBookmarks> - <ToggleBookmarksWithComment>Εναλλαγή σημειώσεων - προσθήκη σχόλιου</ToggleBookmarksWithComment> - <ClearBookmarks>Καθαρισμός σημειώσεων</ClearBookmarks> - <GoToBookmark>Μετάβαση σε σημείωση</GoToBookmark> - <GoToPreviousBookmark>Προηγούμενη σημείωση</GoToPreviousBookmark> - <GoToNextBookmark>Επόμενη σημείωση</GoToNextBookmark> - <ChooseProfile>Επιλογή προφίλ</ChooseProfile> - <DuplicateLine>Αντιγραφή γραμμής</DuplicateLine> - <FontInUi>Γραμματοσειρά γραφικού περιβάλλοντος</FontInUi> - <ShowFrameRate>Εμφάνιση ρυθμού καρέ στη γραμμή εργαλείων</ShowFrameRate> - <DefaultFrameRate>Προεπιλεγμένος ρυθμός καρέ</DefaultFrameRate> - <DefaultFileEncoding>Προεπιλεγμένη κωδικοποίηση</DefaultFileEncoding> - <AutoDetectAnsiEncoding>Ανίχνευση κωδικοποίησης ANSI</AutoDetectAnsiEncoding> - <Profile>Προφίλ</Profile> - <Profiles>Προφίλ</Profiles> - <ImportProfiles>Εισαγωγή</ImportProfiles> - <ExportProfiles>Εξαγωγή</ExportProfiles> - <SubtitleLineMaximumLength>Μέγιστο μήκος γραμμής</SubtitleLineMaximumLength> - <OptimalCharactersPerSecond>Βέλτιστοι χαρακτήρες/δευτερόλεπτο</OptimalCharactersPerSecond> - <MaximumCharactersPerSecond>Μέγιστοι χαρακτήρες/δευτερόλεπτο</MaximumCharactersPerSecond> - <MaximumWordssPerMinute>Μέγιστος αριθμός λέξεων/λεπτό</MaximumWordssPerMinute> - <AutoWrapWhileTyping>Αυτόματη διάσπαση</AutoWrapWhileTyping> - <DurationMinimumMilliseconds>Ελάχιστη διάρκεια, χιλ. δευτερολέπτου</DurationMinimumMilliseconds> - <DurationMaximumMilliseconds>Μέγιστη διάρκεια, χιλ. δευτερολέπτου</DurationMaximumMilliseconds> - <MinimumGapMilliseconds>Ελάχιστο κενό σε χιλ. δευτ.</MinimumGapMilliseconds> - <MaximumLines>Μέγιστος αριθμός γραμμών</MaximumLines> - <SubtitleFont>Γραμματοσειρά υποτίτλου</SubtitleFont> - <SubtitleFontSize>Μέγεθος γραμματοσειράς</SubtitleFontSize> - <SubtitleBold>Έντονα</SubtitleBold> - <VideoAutoOpen>Αυτόματο άνοιγμα βίντεο με υπότιτλο</VideoAutoOpen> - <AllowVolumeBoost>Ώθηση ήχου</AllowVolumeBoost> - <SubtitleCenter>Κέντρο</SubtitleCenter> - <SubtitleFontColor>Χρώμα γραμματοσειράς υποτίτλου</SubtitleFontColor> - <SubtitleBackgroundColor>Χρώμα φόντου υποτίτλου</SubtitleBackgroundColor> - <SpellChecker>Ορθογραφικός έλεγκτής</SpellChecker> - <RememberRecentFiles>Εμφάνιση πρόσφατων αρχείων</RememberRecentFiles> - <StartWithLastFileLoaded>Έναρξη με φόρτωση τελευταίου αρχείου</StartWithLastFileLoaded> - <RememberSelectedLine>Απομνημόνευση γραμμής</RememberSelectedLine> - <RememberPositionAndSize>Απομνημόνευση θέσης και μεγέθους κύριου παραθύρου</RememberPositionAndSize> - <StartInSourceView>Έναρξη σε προβολή πηγής</StartInSourceView> - <RemoveBlankLinesWhenOpening>Αφαίρεση κενών γραμμών κατά το άνοιγμα</RemoveBlankLinesWhenOpening> - <ShowLineBreaksAs>Εμφάνιση διασπάσεων σε προβολή λίστας ως</ShowLineBreaksAs> - <SaveAsFileNameFrom>Η "Αποθήκευση ως..." έχει το όνομα από</SaveAsFileNameFrom> - <MainListViewDoubleClickAction>Ενέργεια διπλού κλικ σε γραμμή στο κύριο παράθυρο προβολής λίστας</MainListViewDoubleClickAction> - <MainListViewColumnsInfo>Επιλογή ορατής λίστας προβολής στηλών</MainListViewColumnsInfo> - <MainListViewNothing>Τίποτα</MainListViewNothing> - <MainListViewVideoGoToPositionAndPause>Μετάβαση σε θέση βίντεο και παύση</MainListViewVideoGoToPositionAndPause> - <MainListViewVideoGoToPositionAndPlay>Μετάβαση σε θέση βίντεο και αναπαραγωγή</MainListViewVideoGoToPositionAndPlay> - <MainListViewEditText>Μετάβαση στο πλαίσιο επεξεργασίας κειμένου</MainListViewEditText> - <MainListViewVideoGoToPositionMinus1SecAndPause>Πήγαινε στη θέση βίντεο - 1 δευτ. και παύση</MainListViewVideoGoToPositionMinus1SecAndPause> - <MainListViewVideoGoToPositionMinusHalfSecAndPause>Πήγαινε στη θέση βίντεο - 0.5 δευτ. και παύση</MainListViewVideoGoToPositionMinusHalfSecAndPause> - <MainListViewVideoGoToPositionMinus1SecAndPlay>Πήγαινε στη θέση βίντεο - 1 δευτ. και αναπαραγωγή</MainListViewVideoGoToPositionMinus1SecAndPlay> - <MainListViewEditTextAndPause>Μετάβαση σε επεξαργασία πλαίσιου κειμένου και παύση στη θέση</MainListViewEditTextAndPause> - <VideoFileName>Όνομα αρχείου βίντεο</VideoFileName> - <ExistingFileName>Υπάρχον όνομα</ExistingFileName> - <AutoBackup>Aντίγραφα ασφαλείας</AutoBackup> - <AutoBackupEveryMinute>Κάθε 1 λεπτό</AutoBackupEveryMinute> - <AutoBackupEveryFiveMinutes>Κάθε 5 λεπτά</AutoBackupEveryFiveMinutes> - <AutoBackupEveryFifteenMinutes>Κάθε 15 λεπτά</AutoBackupEveryFifteenMinutes> - <AutoBackupDeleteAfter>Διαγραφή σε</AutoBackupDeleteAfter> - <AutoBackupDeleteAfterOneMonth>1 μήνα</AutoBackupDeleteAfterOneMonth> - <AutoBackupDeleteAfterThreeMonths>3 μήνες</AutoBackupDeleteAfterThreeMonths> - <AutoBackupDeleteAfterSixMonths>6 μήνες</AutoBackupDeleteAfterSixMonths> - <CheckForUpdates>Έλεγχος ενημερώσεων</CheckForUpdates> - <AutoSave>Αυτόματη αποθήκευση</AutoSave> - <AllowEditOfOriginalSubtitle>Να επιτρέπεται η επεξεργασία του αρχικού υπότιτλου</AllowEditOfOriginalSubtitle> - <PromptDeleteLines>Ερώτηση για διαγραφή γραμμών</PromptDeleteLines> - <TimeCodeMode>Ύφος κωδικοποίησης χρόνου</TimeCodeMode> - <TimeCodeModeHHMMSSMS>ΩΩ:ΛΛ:ΔΔ.ΧΔ (00:00:01.500)</TimeCodeModeHHMMSSMS> - <TimeCodeModeHHMMSSFF>ΩΩ:ΛΛ:ΔΔ:ΚΚ (00:00:01:12)</TimeCodeModeHHMMSSFF> - <SplitBehavior>Συμπεριφορά διαχωρισμού</SplitBehavior> - <SplitBehaviorPrevious>Προσθήκη κενού αριστερά του σημείου διαχωρισμού</SplitBehaviorPrevious> - <SplitBehaviorHalf>Προσθήκη κενού κεντρικά του σημείου διαχωρισμού</SplitBehaviorHalf> - <SplitBehaviorNext>Προσθήκη κενού δεξιά του σημείου διαχωρισμού</SplitBehaviorNext> - <VideoEngine>Μηχανισμός απόδοσης βίντεο</VideoEngine> - <DirectShow>DirectShow</DirectShow> - <DirectShowDescription>quartz.dll στον φάκελο system32</DirectShowDescription> - <MpcHc>MPC-HC</MpcHc> - <MpcHcDescription>Media Player Classic - Home Cinema</MpcHcDescription> - <MpvPlayer>mpv</MpvPlayer> - <MpvPlayerDescription>https://mpv.io</MpvPlayerDescription> - <MpvHandlesPreviewText>Προεπισκόπηση κειμένου από mpv</MpvHandlesPreviewText> - <VlcMediaPlayer>VLC media player</VlcMediaPlayer> - <VlcMediaPlayerDescription>libvlc.dll από VLC media player 1.1.0 ή νεότερο</VlcMediaPlayerDescription> - <VlcBrowseToLabel>Διαδρομή του VLC (μόνο για τη φορητή έκδοση VLC)</VlcBrowseToLabel> - <ShowStopButton>Εμφάνιση κουμπιού διακοπής</ShowStopButton> - <ShowMuteButton>Εμφάνιση κουμπιού σίγασης</ShowMuteButton> - <ShowFullscreenButton>Εμφάνιση κουμπιού πλήρους οθόνης</ShowFullscreenButton> - <PreviewFontSize>Μέγεθος γραμματοσειράς προεπισκόπησης υπότιτλου</PreviewFontSize> - <MainWindowVideoControls>Στοιχεία ελέγχου βίντεο κύριου παραθύρου</MainWindowVideoControls> - <CustomSearchTextAndUrl>Προσαρμοσμένη αναζήτηση κειμένου και διεύθυνσης URL</CustomSearchTextAndUrl> - <WaveformAppearance>Όψη κυματομορφής</WaveformAppearance> - <WaveformGridColor>Χρώμα πλέγματος</WaveformGridColor> - <WaveformShowGridLines>Εμφάνιση γραμμών πλέγματος</WaveformShowGridLines> - <WaveformShowCps>Εμφάνιση χαρ/δευτ</WaveformShowCps> - <WaveformShowWpm>Εμφάνιση λέξεων/λεπτό</WaveformShowWpm> - <ReverseMouseWheelScrollDirection>Εναλλαγή κατεύθυνσης κύλισης με τη ρόδα του ποντικιού</ReverseMouseWheelScrollDirection> - <WaveformAllowOverlap>Να επιτρέπεται η επικάλυψη (κατά τη μετακίνηση/αλλαγή μεγέθους)</WaveformAllowOverlap> - <WaveformSetVideoPosMoveStartEnd>Καθορισμός θέσης βίντεο κατά τη μετακίνηση αρχής/λήξης</WaveformSetVideoPosMoveStartEnd> - <WaveformFocusMouseEnter>Καθορισμός εστίασης όταν το ποντίκι εισέρχεται</WaveformFocusMouseEnter> - <WaveformListViewFocusMouseEnter>Επίσης καθορίστε την εστίαση στην προβολή λίστας, όταν το ποντίκι εισέρχεται στην προβολή λίστας</WaveformListViewFocusMouseEnter> - <WaveformSingleClickSelect>Μονό κλικ επιλογής υπότιτλου</WaveformSingleClickSelect> - <WaveformSnapToSceneChanges>Εικόνα για την αλλαγή σκηνών (κράτημα Shift για παράκαμψη)</WaveformSnapToSceneChanges> - <WaveformBorderHitMs1>Το χτύπημα του πλαισίου σήμανσης πρέπει να βρίσκεται μεταξύ</WaveformBorderHitMs1> - <WaveformBorderHitMs2>χιλιοστά δευτερολέπτου</WaveformBorderHitMs2> - <WaveformColor>Χρώμα</WaveformColor> - <WaveformSelectedColor>Επιλεγμένο χρώμα</WaveformSelectedColor> - <WaveformBackgroundColor>Χρώμα φόντου</WaveformBackgroundColor> - <WaveformCursorColor>Χρώμα δείκτη</WaveformCursorColor> - <WaveformTextColor>Χρώμα κειμένου</WaveformTextColor> - <WaveformTextFontSize>Μέγεθος γραμματοσειράς κειμένου</WaveformTextFontSize> - <WaveformAndSpectrogramsFolderEmpty>Άδειασμα φακέλων 'Spectrograms' και 'Waveforms'</WaveformAndSpectrogramsFolderEmpty> - <WaveformAndSpectrogramsFolderInfo>Οι φάκελοι 'Waveforms' και 'Spectrograms' περιέχουν {0} αρχεία ({1:0.00} MB)</WaveformAndSpectrogramsFolderInfo> - <Spectrogram>Φασματογράφημα</Spectrogram> - <GenerateSpectrogram>Δημιουργία φασματογράμματος</GenerateSpectrogram> - <SpectrogramAppearance>Όψη φασματογράμματος</SpectrogramAppearance> - <SpectrogramOneColorGradient>Διαβάθμιση ενός χρώματος</SpectrogramOneColorGradient> - <SpectrogramClassic>Κλασικό</SpectrogramClassic> - <WaveformUseFFmpeg>Χρήση FFmpeg για εξαγωγή κυματομορφής</WaveformUseFFmpeg> - <DownloadFFmpeg>Λήψη FFmpeg</DownloadFFmpeg> - <WaveformFFmpegPath>Διαδρομή του FFmpeg</WaveformFFmpegPath> - <WaveformBrowseToFFmpeg>Περιήγηση για FFmpeg</WaveformBrowseToFFmpeg> - <WaveformBrowseToVLC>Περιήγηση για φορητό VLC</WaveformBrowseToVLC> - <SubStationAlphaStyle>Στυλ Sub Station Alpha</SubStationAlphaStyle> - <ChooseColor>Επιλογή χρώματος</ChooseColor> - <SsaOutline>Περίγραμμα</SsaOutline> - <SsaShadow>Σκιά</SsaShadow> - <SsaOpaqueBox>Αδιαφανές κουτί</SsaOpaqueBox> - <Testing123>Δοκιμή 123...</Testing123> - <Language>Γλώσσα</Language> - <NamesIgnoreLists>Λίστα ονομάτων/παραλείψεων (διάκριση πεζών-κεφαλαίων)</NamesIgnoreLists> - <AddName>Προσθήκη ονόματος</AddName> - <AddWord>Προσθήκη λέξης</AddWord> - <Remove>Αφαίρεση</Remove> - <AddPair>Προσθήκη ζευγαριού</AddPair> - <UserWordList>Λίστα λέξεων χρήστη</UserWordList> - <OcrFixList>Λίστα επιδιορθώσεων OCR</OcrFixList> - <Location>Τοποθεσία</Location> - <UseOnlineNames>Χρήση διαδικτυακού αρχείου xml ονομάτων</UseOnlineNames> - <WordAddedX>Λέξη προστέθηκε: {0}</WordAddedX> - <WordAlreadyExists>Υπάρχουσα λέξη!</WordAlreadyExists> - <WordNotFound>Η λέξη δεν βρέθηκε</WordNotFound> - <RemoveX>Αφαίρεση του {0};</RemoveX> - <CannotUpdateNamesOnline>Αδυναμία ενημέρωσης του διαδικτυακού xml ονομάτων!</CannotUpdateNamesOnline> - <ProxyServerSettings>Ρυθμίσεις διακομιστή μεσολάβησης</ProxyServerSettings> - <ProxyAddress>Διεύθυνση διακομιστή μεσολάβησης</ProxyAddress> - <ProxyAuthentication>Επικύρωση</ProxyAuthentication> - <ProxyUserName>Όνομα χρήστη</ProxyUserName> - <ProxyPassword>Κωδικός</ProxyPassword> - <ProxyDomain>Τομέας</ProxyDomain> - <NetworkSessionSettings>Ρυθμίσεις συνεδρίας δικτύου</NetworkSessionSettings> - <NetworkSessionNewSound>Αναπαραγωγή ήχου νέων μηνυμάτων</NetworkSessionNewSound> - <PlayXSecondsAndBack>Αναπαραγωγή Χ δευτερολέπτων και πίσω, το Χ είναι</PlayXSecondsAndBack> - <StartSceneIndex>Η αρχική παράγραφος σκηνής είναι</StartSceneIndex> - <EndSceneIndex>Η τελική παράγραφος σκηνής είναι</EndSceneIndex> - <FirstPlusX>Αρχή + {0}</FirstPlusX> - <LastMinusX>Τέλος - {0}</LastMinusX> - <FixCommonerrors>Επιδιόρθωση κοινών σφαλμάτων</FixCommonerrors> - <RemoveTextForHi>Αφαίρεση κειμένου για κωφούς</RemoveTextForHi> - <MergeLinesShorterThan>Συνένωση γραμμών μικρότερες από</MergeLinesShorterThan> - <DialogStyle>Στυλ διαλόγου</DialogStyle> - <DialogStyleDashBothLinesWithSpace>Παύλες με κενό</DialogStyleDashBothLinesWithSpace> - <DialogStyleDashBothLinesWithoutSpace>Παύλες χωρίς κενό</DialogStyleDashBothLinesWithoutSpace> - <DialogStyleDashSecondLineWithSpace>Μία παύλα με κενό</DialogStyleDashSecondLineWithSpace> - <DialogStyleDashSecondLineWithoutSpace>Δεύτερη γραμμή χωρίς κενό</DialogStyleDashSecondLineWithoutSpace> - <ContinuationStyle>Στυλ συνέχισης</ContinuationStyle> - <ContinuationStyleNone>Χωρίς</ContinuationStyleNone> - <ContinuationStyleNoneTrailingDots>Χωρίς, αποσιωπητικά για παύσεις (μόνο συνέχιση)</ContinuationStyleNoneTrailingDots> - <ContinuationStyleNoneLeadingTrailingDots>Χωρίς, αποσιωπητικά για παύσεις</ContinuationStyleNoneLeadingTrailingDots> - <ContinuationStyleOnlyTrailingDots>Αποσιωπητικά (μόνο συνέχιση)</ContinuationStyleOnlyTrailingDots> - <ContinuationStyleLeadingTrailingDots>Αποσιωπητικά</ContinuationStyleLeadingTrailingDots> - <ContinuationStyleLeadingTrailingDash>Παύλα</ContinuationStyleLeadingTrailingDash> - <ContinuationStyleLeadingTrailingDashDots>Παύλα, αποσιωπητικά για παύσεις</ContinuationStyleLeadingTrailingDashDots> - <MusicSymbol>Μουσικό σύμβολο</MusicSymbol> - <MusicSymbolsReplace>Αντικατάσταση μουσικών συμβόλων (χωρισμένα με κόμμα)</MusicSymbolsReplace> - <FixCommonOcrErrorsUseHardcodedRules>Επιδιόρθωση κοινών σφαλμάτων OCR - χρήση ενσωματωμένων κανόνων</FixCommonOcrErrorsUseHardcodedRules> - <FixCommonerrorsFixShortDisplayTimesAllowMoveStartTime>Επιδιόρθωση του σύντομου χρόνου εμφάνισης - αλλαγή χρόνου έναρξης</FixCommonerrorsFixShortDisplayTimesAllowMoveStartTime> - <FixCommonErrorsSkipStepOne>Παράβλεψη πρώτου βήματος (προκαθορισμένες επιλογές)</FixCommonErrorsSkipStepOne> - <Shortcuts>Συντομεύσεις</Shortcuts> - <Shortcut>Συντόμευση</Shortcut> - <Control>Ctrl</Control> - <Alt>Alt</Alt> - <Shift>Shift</Shift> - <Key>Πλήκτρο</Key> - <ListViewAndTextBox>Προβολή λίστας και πλαισίου κειμένου</ListViewAndTextBox> - <ListView>Προβολή λίστας</ListView> - <TextBox>Πλαίσιο κειμένου</TextBox> - <UseSyntaxColoring>Χρήση χρωματισμού σύνταξης</UseSyntaxColoring> - <HtmlColor>Χρώμα HTML</HtmlColor> - <AssaColor>Χρώμα ASSA</AssaColor> - <UpdateShortcut>Ενημέρωση</UpdateShortcut> - <FoucsSetVideoPosition>Εστίαση ορισμού θέσης βίντεο</FoucsSetVideoPosition> - <ToggleDockUndockOfVideoControls>Εναλλαγή αγκύστρωσης/απαγκύστρωσης των στοιχείων ελέγχου βίντεο</ToggleDockUndockOfVideoControls> - <CreateSetEndAddNewAndGoToNew>Ορισμός τέλους, προσθήκη νέου και μετάβαση</CreateSetEndAddNewAndGoToNew> - <AdjustViaEndAutoStart>Προσαρμογή μέσω τελικής θέσης</AdjustViaEndAutoStart> - <AdjustViaEndAutoStartAndGoToNext>Προσαρμογή μέσω τελικής θέσης και επόμενο</AdjustViaEndAutoStartAndGoToNext> - <AdjustSetEndTimeAndGoToNext>Ορισμός λήξης και επόμενο</AdjustSetEndTimeAndGoToNext> - <AdjustSetEndTimeAndPause>Ορισμός λήξης και παύση</AdjustSetEndTimeAndPause> - <AdjustSetStartAutoDurationAndGoToNext>Προσαρμογή μέσω αρχικής θέσης και επόμενο</AdjustSetStartAutoDurationAndGoToNext> - <AdjustSetEndNextStartAndGoToNext>Ορισμός λήξης, έναρξη επομένου εκκίνηση και επόμενο</AdjustSetEndNextStartAndGoToNext> - <AdjustStartDownEndUpAndGoToNext>Κάτω βέλος = ορισμός έναρξης, Πάνω βέλος = ορισμός λήξης και μετάβαση σε επόμενο</AdjustStartDownEndUpAndGoToNext> - <AdjustSetStartAndEndOfPrevious>Ορισμός έναρξης και λήξης προηγούμενου (πλην ελάχιστο κενό)</AdjustSetStartAndEndOfPrevious> - <AdjustSetStartAndEndOfPreviousAndGoToNext>Ορισμός έναρξης και λήξης προηγούμενου και μετάβαση σε επόμενο (πλην ελάχιστο κενό)</AdjustSetStartAndEndOfPreviousAndGoToNext> - <AdjustSelected100MsForward>Μετακίνηση γραμμών 100 χιλ. δ. εμπρός</AdjustSelected100MsForward> - <AdjustSelected100MsBack>Μετακίνηση γραμμών 100 χιλ. δ. πίσω</AdjustSelected100MsBack> - <AdjustStartXMsBack>Μετακίνηση αρχής {0} χιλ. δ. πίσω</AdjustStartXMsBack> - <AdjustStartXMsForward>Μετακίνηση αρχής {0} χιλ. δ. εμπρός</AdjustStartXMsForward> - <AdjustEndXMsBack>Μετακίνηση λήξης {0} χιλ. δ. πίσω</AdjustEndXMsBack> - <AdjustEndXMsForward>Μετακίνηση λήξης {0} χιλ. δ. εμπρός</AdjustEndXMsForward> - <AdjustStartOneFrameBack>Μετακίνηση αρχής 1 καρέ πίσω</AdjustStartOneFrameBack> - <AdjustStartOneFrameForward>Μετακίνηση αρχής 1 καρέ εμπρός</AdjustStartOneFrameForward> - <AdjustEndOneFrameBack>Μετακίνηση λήξης 1 καρέ πίσω</AdjustEndOneFrameBack> - <AdjustEndOneFrameForward>Μετακίνηση λήξης 1 καρέ εμπρός</AdjustEndOneFrameForward> - <AdjustStartOneFrameBackKeepGapPrev>Μετακίνηση αρχής 1 καρέ πίσω (κράτημα κενού στο προηγούμενο)</AdjustStartOneFrameBackKeepGapPrev> - <AdjustStartOneFrameForwardKeepGapPrev>Μετακίνηση αρχής 1 καρέ εμπρός (κράτημα κενού στο προηγούμενο)</AdjustStartOneFrameForwardKeepGapPrev> - <AdjustEndOneFrameBackKeepGapNext>Μετακίνηση λήξης 1 καρέ πίσω (κράτημα κενού στο επόμενο)</AdjustEndOneFrameBackKeepGapNext> - <AdjustEndOneFrameForwardKeepGapNext>Μετακίνηση λήξης 1 καρέ εμπρός (κράτημα κενού στο επόμενο)</AdjustEndOneFrameForwardKeepGapNext> - <AdjustSetStartTimeKeepDuration>Ορισμός έναρξης, διατήρηση διάρκειας</AdjustSetStartTimeKeepDuration> - <AdjustSetEndAndOffsetTheRest>Ορισμός τέλους, αντιστάθμιση υπολοίπων</AdjustSetEndAndOffsetTheRest> - <AdjustSetEndAndOffsetTheRestAndGoToNext>Ορισμός τέλους, αντιστάθμιση υπολοίπων και μετάβαση σε επόμενο</AdjustSetEndAndOffsetTheRestAndGoToNext> - <AdjustSnapStartToNextSceneChange>Σπάσιμο έναρξης γραμμής σε επόμενη αλλαγή σκηνής</AdjustSnapStartToNextSceneChange> - <AdjustSnapStartToNextSceneChangeWithGap>Σπάσιμο έναρξης γραμμής σε επόμενη αλλαγή σκηνής με ελάχιστο κενό</AdjustSnapStartToNextSceneChangeWithGap> - <AdjustSnapEndToPreviousSceneChange>Σπάσιμο έναρξης γραμμής σε προηγούμενη αλλαγή σκηνής</AdjustSnapEndToPreviousSceneChange> - <AdjustSnapEndToPreviousSceneChangeWithGap>Σπάσιμο έναρξης γραμμής σε προηγούμενη αλλαγή σκηνής με ελάχιστο κενό</AdjustSnapEndToPreviousSceneChangeWithGap> - <AdjustExtendToNextSceneChange>Επέκταση γραμμών μέχρι την επόμενη αλλαγή σκηνής (ή επόμενο υπότιτλο)</AdjustExtendToNextSceneChange> - <AdjustExtendToNextSceneChangeWithGap>Επέκταση γραμμών σε επόμενη αλλαγή σκηνής με ελάχιστο κενό (ή επόμενο υπότιτλο)</AdjustExtendToNextSceneChangeWithGap> - <AdjustExtendToPreviousSceneChange>Επέκταση γραμμών μέχρι την προηγούμενη αλλαγή σκηνής (ή προηγούμενο υπότιτλο)</AdjustExtendToPreviousSceneChange> - <AdjustExtendToPreviousSceneChangeWithGap>Επέκταση γραμμών σε προηγούμενη αλλαγή σκηνής με ελάχιστο κενό (ή προηγούμενο υπότιτλο)</AdjustExtendToPreviousSceneChangeWithGap> - <AdjustExtendToNextSubtitle>Επέκταση γραμμών μέχρι τον επόμενο υπότιτλο</AdjustExtendToNextSubtitle> - <AdjustExtendToPreviousSubtitle>Επέκταση γραμμών μέχρι τον προηγούμενο υπότιλο</AdjustExtendToPreviousSubtitle> - <AdjustExtendCurrentSubtitle>Επέκταση γραμμής μέχρι τον επόμενο υπότιτλο ή μέγιστη διάρκεια</AdjustExtendCurrentSubtitle> - <AdjustExtendPreviousLineEndToCurrentStart>Επέκταση λήξης προηγούμενης γραμμής σε έναρξη τρέχουσας</AdjustExtendPreviousLineEndToCurrentStart> - <AdjustExtendNextLineStartToCurrentEnd>Επέκταση έναρξης επόμενης γραμμής σε λήξη τρέχουσας</AdjustExtendNextLineStartToCurrentEnd> - <RecalculateDurationOfCurrentSubtitle>Επαναϋπολογισμός διάρκειας υπότιτλου</RecalculateDurationOfCurrentSubtitle> - <MainCreateStartDownEndUp>Δημιουργία νέου στο πάτημα του κάτω βέλους, ορισμός χρόνου λήξης στο πάτημα του πάνω βέλους</MainCreateStartDownEndUp> - <MergeDialog>Συγχώνευση διαλόγου (εισαγωγή παυλών)</MergeDialog> - <GoToNext>Μετάβαση σε επόμενη γραμμή</GoToNext> - <GoToNextCursorAtEnd>Μετάβαση σε επόμενη γραμμή και ορισμός δείκτη στη λήξη</GoToNextCursorAtEnd> - <GoToPrevious>Μετάβαση σε προηγούμενη γραμμή</GoToPrevious> - <GoToCurrentSubtitleStart>Μετάβαση στην αρχή της τρέχουσας γραμμής</GoToCurrentSubtitleStart> - <GoToCurrentSubtitleEnd>Μετάβαση στο τέλος της τρέχουσας γραμμής</GoToCurrentSubtitleEnd> - <GoToPreviousSubtitleAndFocusVideo>Μετάβαση σε προηγούμενη γραμμή και ορισμός θέσης βίντεο</GoToPreviousSubtitleAndFocusVideo> - <GoToNextSubtitleAndFocusVideo>Μετάβαση σε επόμενη γραμμή και ορισμός θέσης βίντεο</GoToNextSubtitleAndFocusVideo> - <GoToPrevSubtitleAndPlay>Μετάβαση σε προηγούμενη γραμμή και αναπαραγωγή</GoToPrevSubtitleAndPlay> - <GoToNextSubtitleAndPlay>Μετάβαση σε επόμενη γραμμή και αναπαραγωγή</GoToNextSubtitleAndPlay> - <ToggleFocus>Εναλλαγή εστίασης υποτίτλου μεταξύ προβολής λίστας και πλαισίου κειμένου</ToggleFocus> - <ToggleDialogDashes>Εναλλαγή γραμμών διαλόγου</ToggleDialogDashes> - <ToggleMusicSymbols>Εναλλαγή μουσικών συμβόλων</ToggleMusicSymbols> - <Alignment>Στοίχιση (επιλεγμένες γραμμές)</Alignment> - <AlignmentN1>Στοίχιση κάτω αριστερά - {\an1}</AlignmentN1> - <AlignmentN2>Στοίχιση κάτω κεντρικά - {\an2}</AlignmentN2> - <AlignmentN3>Στοίχιση κάτω δεξιά - {\an1}</AlignmentN3> - <AlignmentN4>Στοίχιση μέση αριστερά - {\an4}</AlignmentN4> - <AlignmentN5>Στοίχιση μέση κέντρο - {\an5}</AlignmentN5> - <AlignmentN6>Στοίχιση μέση δεξιά - {\an6}</AlignmentN6> - <AlignmentN7>Στοίχιση πάνω αριστερά - {\an7}</AlignmentN7> - <AlignmentN8>Στοίχιση πάνω κεντρικά - {\an8}</AlignmentN8> - <AlignmentN9>Στοίχιση πάνω δεξιά - {\an9}</AlignmentN9> - <CopyTextOnly>Αντιγραφή μόνο του κειμένου στο πρόχειρο (επιλεγμένες γραμμές)</CopyTextOnly> - <CopyTextOnlyFromOriginalToCurrent>Αντιγραφή κειμένου από αρχικό στον τρέχων</CopyTextOnlyFromOriginalToCurrent> - <AutoDurationSelectedLines>Αυτόματη διάρκεια (επιλεγμένες γραμμές)</AutoDurationSelectedLines> - <FixRTLViaUnicodeChars>Επιδιόρθωση RTL μέσω χαρακτήρων ελέγχου Unicode</FixRTLViaUnicodeChars> - <RemoveRTLUnicodeChars>Αφαίρεση χαρακτήρων ελέγχου Unicode</RemoveRTLUnicodeChars> - <ReverseStartAndEndingForRtl>Αντιστροφή έναρξης/λήξης RTL</ReverseStartAndEndingForRtl> - <VerticalZoom>Κάθετη μεγέθυνση</VerticalZoom> - <VerticalZoomOut>Κάθετη σμίκρυνση</VerticalZoomOut> - <WaveformSeekSilenceForward>Αναζήτηση σιωπής εμπρός</WaveformSeekSilenceForward> - <WaveformSeekSilenceBack>Αναζήτηση σιωπής πίσω</WaveformSeekSilenceBack> - <WaveformAddTextHere>Προσθήκη κειμένου (για νέα επιλογή)</WaveformAddTextHere> - <WaveformAddTextHereFromClipboard>Προσθήκη κειμένου (για νέα επιλογή από πρόχειρο)</WaveformAddTextHereFromClipboard> - <SetParagraphAsSelection>Ορισμός επιλεγμένου ως νέα επιλογή</SetParagraphAsSelection> - <WaveformPlayNewSelection>Αναπαραγωγή επιλεγμένου</WaveformPlayNewSelection> - <WaveformPlayNewSelectionEnd>Αναπαραγωγή λήξης επιλεγμένου</WaveformPlayNewSelectionEnd> - <WaveformPlayFirstSelectedSubtitle>Αναπαραγωγή του πρώτου υπότιτλου</WaveformPlayFirstSelectedSubtitle> - <WaveformFocusListView>Εστίαση σε προβολή λίστας</WaveformFocusListView> - <WaveformGoToPreviousSceneChange>Μετάβαση σε προηγούμενη αλλαγή σκηνής</WaveformGoToPreviousSceneChange> - <WaveformGoToNextSceneChange>Μετάβαση σε επόμενη αλλαγή σκηνής</WaveformGoToNextSceneChange> - <WaveformToggleSceneChange>Εναλλαγή αλλαγή σκηνής</WaveformToggleSceneChange> - <WaveformGuessStart>Αυτόματη προσαρμογή έναρξης μέσω έντασης/αλλαγή σκηνής</WaveformGuessStart> - <GoBack1Frame>Πίσω ένα καρέ</GoBack1Frame> - <GoForward1Frame>Μπροστά ένα καρέ</GoForward1Frame> - <GoBack1FrameWithPlay>Πίσω ένα καρέ (με αναπαραγωγή)</GoBack1FrameWithPlay> - <GoForward1FrameWithPlay>Μπροστά ένα καρέ (με αναπαραγωγή)</GoForward1FrameWithPlay> - <GoBack100Milliseconds>Πίσω 100 χιλ. δ.</GoBack100Milliseconds> - <GoForward100Milliseconds>Μπροστά 100 χιλ. δ.</GoForward100Milliseconds> - <GoBack500Milliseconds>Πίσω 500 χιλ. δ.</GoBack500Milliseconds> - <GoForward500Milliseconds>Μπροστά 500 χιλ. δ.</GoForward500Milliseconds> - <GoBack1Second>Πίσω 1 δευτερόλεπτο</GoBack1Second> - <GoForward1Second>Μπροστά 1 δευτερόλεπτο</GoForward1Second> - <GoBack5Seconds>Πίσω 5 δευτερόλεπτα</GoBack5Seconds> - <GoForward5Seconds>Μπροστά 5 δευτερόλεπτα</GoForward5Seconds> - <GoBackXSSeconds>Μικρή προώθηση χρόνου πίσω</GoBackXSSeconds> - <GoForwardXSSeconds>Μικρή προώθηση χρόνου εμπρός</GoForwardXSSeconds> - <GoBackXLSeconds>Μεγάλη προώθηση χρόνου πίσω</GoBackXLSeconds> - <GoForwardXLSeconds>Μεγάλη προώθηση χρόνου εμπρός</GoForwardXLSeconds> - <GoBack3Second>Πίσω 3 δευτερόλεπτα</GoBack3Second> - <GoToStartCurrent>Ορισμός θέσης βίντεο στην έναρξη του τρέχοντος υπότιτλου</GoToStartCurrent> - <ToggleStartEndCurrent>Εναλλαγή θέσης βίντεο μεταξύ έναρξης/λήξης τρέχοντος υπότιτλου</ToggleStartEndCurrent> - <PlayCurrent>Αναπαραγωγή τρέχοντος υπότιτλου</PlayCurrent> - <WaveformGoToPrevSubtitle>Μετάβαση σε προηγούμενο υπότιτλο (από θέση βίντεο)</WaveformGoToPrevSubtitle> - <WaveformGoToNextSubtitle>Μετάβαση σε επόμενο υπότιτλο (από θέση βίντεο)</WaveformGoToNextSubtitle> - <WaveformGoToPrevChapter>Μετάβαση σε προηγούμενο κεφάλαιο</WaveformGoToPrevChapter> - <WaveformGoToNextChapter>Μετάβαση σε επόμενο κεφάλαιο</WaveformGoToNextChapter> - <WaveformSelectNextSubtitle>Επιλογή επόμενου υπότιτλου (από θέση βίντεο, χωρίς αλλαγή)</WaveformSelectNextSubtitle> - <TogglePlayPause>Εναλλαγή αναπαραγωγής/παύσης</TogglePlayPause> - <Pause>Παύση</Pause> - <Fullscreen>Πλήρη οθόνη</Fullscreen> - <PlayRateSlower>Πιο αργός ρυθμός αναπαραγωγής</PlayRateSlower> - <PlayRateFaster>Ταχύτερος ρυθμός αναπαραγωγής</PlayRateFaster> - <VideoResetSpeedAndZoom>Επαναφορά ταχύτητας/μεγένθυσης</VideoResetSpeedAndZoom> - <CustomSearch1>Μετάφραση, προσαρμοσμένη αναζήτηση 1</CustomSearch1> - <CustomSearch2>Μετάφραση, προσαρμοσμένη αναζήτηση 2</CustomSearch2> - <CustomSearch3>Μετάφραση, προσαρμοσμένη αναζήτηση 3</CustomSearch3> - <CustomSearch4>Μετάφραση, προσαρμοσμένη αναζήτηση 4</CustomSearch4> - <CustomSearch5>Μετάφραση, προσαρμοσμένη αναζήτηση 5</CustomSearch5> - <SyntaxColoring>Χρωματισμός σύνταξης</SyntaxColoring> - <ListViewSyntaxColoring>Χρωματισμός σύνταξης στην προβολή λίστας</ListViewSyntaxColoring> - <SyntaxColorDurationIfTooSmall>Χρώμα διάρκειας εάν είναι πολύ μικρός</SyntaxColorDurationIfTooSmall> - <SyntaxColorDurationIfTooLarge>Χρώμα διάρκειας εάν είναι πολύ μεγάλος</SyntaxColorDurationIfTooLarge> - <SyntaxColorTextIfTooLong>Χρώμα κειμένου εάν είναι πολύ μακρύ</SyntaxColorTextIfTooLong> - <SyntaxColorTextIfTooWide>Χρώμα κειμένου αν είναι ευρύ (εικονοστοιχεία)</SyntaxColorTextIfTooWide> - <SyntaxColorTextMoreThanMaxLines>Χρώμα κειμένου αν είναι περισσότερες από {0} γραμμές</SyntaxColorTextMoreThanMaxLines> - <SyntaxColorOverlap>Χρώμα κωδικών χρόνου που επικαλύπτονται</SyntaxColorOverlap> - <SyntaxColorGap>Χρώμα κενού αν είναι μικρότερο</SyntaxColorGap> - <SyntaxErrorColor>Χρώμα σφάλματος</SyntaxErrorColor> - <SyntaxLineWidthSettings>Ρυθμίσεις...</SyntaxLineWidthSettings> - <LineWidthSettings>Ρυθμίσεις εύρους γραμμής</LineWidthSettings> - <MaximumLineWidth>Μέγιστο εύρος γραμμής:</MaximumLineWidth> - <Pixels>εικονοστοιχεία</Pixels> - <MeasureFont>Μέτρηση γραμματοσειράς:</MeasureFont> - <GoToFirstSelectedLine>Μετάβαση σε πρώτη επιλεγμένη γραμμή</GoToFirstSelectedLine> - <GoToNextEmptyLine>Μετάβαση σε επόμενη κενή γραμμή</GoToNextEmptyLine> - <MergeSelectedLines>Συγχώνευση γραμμών</MergeSelectedLines> - <MergeSelectedLinesAndAutoBreak>Συγχώνευση γραμμών και αυτόματη διάσπαση</MergeSelectedLinesAndAutoBreak> - <MergeSelectedLinesAndUnbreak>Συγχώνευση γραμμών και συνένωση</MergeSelectedLinesAndUnbreak> - <MergeSelectedLinesAndUnbreakCjk>Συγχώνευση γραμμών και συνένωση χωρίς κενό</MergeSelectedLinesAndUnbreakCjk> - <MergeSelectedLinesOnlyFirstText>Συγχώνευση γραμμών, κράτημα μόνο του πρώτου κειμένου</MergeSelectedLinesOnlyFirstText> - <MergeSelectedLinesBilingual>Συγχώνευση γραμμών δίγλωσσα</MergeSelectedLinesBilingual> - <SplitSelectedLineBilingual>Διαχωρισμός γραμμής δίγλωσσα</SplitSelectedLineBilingual> - <ToggleTranslationMode>Εναλλαγή τρόπου μετάφρασης</ToggleTranslationMode> - <SwitchOriginalAndTranslation>Εναλλαγή αρχικού και μετάφρασης</SwitchOriginalAndTranslation> - <MergeOriginalAndTranslation>Συγχώνευση αρχικού και μετάφρασης</MergeOriginalAndTranslation> - <MergeWithNext>Συγχώνευση με επόμενη</MergeWithNext> - <MergeWithPrevious>Συγχώνευση με προηγούμενη</MergeWithPrevious> - <ShortcutIsAlreadyDefinedX>Ορισμένη συντόμευση: {0}</ShortcutIsAlreadyDefinedX> - <ToggleTranslationAndOriginalInPreviews>Εναλλαγή μετάφρασης και αρχικού στην προεπισκόπηση βίντεο/ήχου</ToggleTranslationAndOriginalInPreviews> - <ListViewColumnDelete>Στήλη, διαγραφή κειμένου</ListViewColumnDelete> - <ListViewColumnDeleteAndShiftUp>Στήλη, διαγραφή κειμένου και άνω μετατόπιση</ListViewColumnDeleteAndShiftUp> - <ListViewColumnInsert>Στήλη, εισαγωγή κειμένου</ListViewColumnInsert> - <ListViewColumnPaste>Στήλη, επικόλληση</ListViewColumnPaste> - <ListViewColumnTextUp>Στήλη, κείμενο προς τα πάνω</ListViewColumnTextUp> - <ListViewColumnTextDown>Στήλη, κείμενο προς τα κάτω</ListViewColumnTextDown> - <ListViewFocusWaveform>Εστίαση κυματομορφής/φασματογραφήματος</ListViewFocusWaveform> - <ListViewGoToNextError>Μετάβαση σε επόμενο σφάλμα</ListViewGoToNextError> - <ShowBeamer>Ξεκινήστε υπότιτλο σε πλήρη οθόνη βιντεοπροβολέα</ShowBeamer> - <MainTextBoxMoveLastWordDown>Μετακίνηση τελευταίας λέξης στην επόμενη γραμμή</MainTextBoxMoveLastWordDown> - <MainTextBoxMoveFirstWordFromNextUp>Μετακίνηση πρώτης λέξης από την επόμενη γραμμή επάνω</MainTextBoxMoveFirstWordFromNextUp> - <MainTextBoxMoveFirstWordUpCurrent>Μετακίνηση πρώτης λέξης της κάτω γραμμής πάνω</MainTextBoxMoveFirstWordUpCurrent> - <MainTextBoxMoveLastWordDownCurrent>Μετακίνηση τελευταίας λέξης της άνω γραμμής κάτω</MainTextBoxMoveLastWordDownCurrent> - <MainTextBoxSelectionToLower>Επιλογή σε μικρά</MainTextBoxSelectionToLower> - <MainTextBoxSelectionToUpper>Επιλογή σε κεφαλαία</MainTextBoxSelectionToUpper> - <MainTextBoxSelectionToggleCasing>Εναλλαγή πεζών-κεφαλαίων επιλογής (κανονικά/κεφαλαία/πεζά)</MainTextBoxSelectionToggleCasing> - <MainTextBoxSelectionToRuby>Επιλογή σε Ruby (Ιαπωνικά)</MainTextBoxSelectionToRuby> - <MainTextBoxToggleAutoDuration>Εναλλαγή αυτόματης διάρκειας</MainTextBoxToggleAutoDuration> - <MainTextBoxAutoBreak>Αυτόματη διάσπαση κειμένου</MainTextBoxAutoBreak> - <MainTextBoxAutoBreakFromPos>Διάσπαση σε κενό από τη θέση δείκτη</MainTextBoxAutoBreakFromPos> - <MainTextBoxAutoBreakFromPosAndGoToNext>Διάσπαση σε κενό από τη θέση δείκτη και μετάβαση σε επόμενο</MainTextBoxAutoBreakFromPosAndGoToNext> - <MainTextBoxUnbreak>Συνένωση κειμένου</MainTextBoxUnbreak> - <MainFileSaveAll>Αποθήκευση όλων</MainFileSaveAll> - <Miscellaneous>Διάφορα</Miscellaneous> - <CpsIncludesSpace>Συμπερίληψη κενών στους χαρακτήρες/δευτερόλεπτο</CpsIncludesSpace> - <UseDoNotBreakAfterList>Χρήση της λίστας μη διάσπασης μετά από</UseDoNotBreakAfterList> - <BreakEarlyForLineEnding>Διάσπαση σε σημεία στίξης</BreakEarlyForLineEnding> - <BreakByPixelWidth>Διάσπαση βάσει εύρους εικονοστοιχείων</BreakByPixelWidth> - <BreakPreferBottomHeavy>Προτίμηση μεγαλύτερης κάτω γραμμής</BreakPreferBottomHeavy> - <BreakEarlyForDashDialog>Διάσπαση σε παύλα διάλογου</BreakEarlyForDashDialog> - <BreakEarlyForComma>Διάσπαση σε κόμμα</BreakEarlyForComma> - <GoogleTranslate>Μετάφραση Google</GoogleTranslate> - <GoogleTranslateApiKey>Κλειδί API</GoogleTranslateApiKey> - <MicrosoftBingTranslator>Μετάφραση Microsoft</MicrosoftBingTranslator> - <HowToSignUp>Βοήθεια εγγραφής</HowToSignUp> - <MicrosoftTranslateApiKey>Κλειδί</MicrosoftTranslateApiKey> - <MicrosoftTranslateTokenEndpoint>Δείγμα τελειώματος</MicrosoftTranslateTokenEndpoint> - <FontNote>Σημείωση: Οι ρυθμίσεις γραμματοσειράς αφορούν μόνο το περιβάλλον χρήση του Subtitle Edit.</FontNote> - <RestoreDefaultSettings>Επαναφορά ρυθμίσεων</RestoreDefaultSettings> - <RestoreDefaultSettingsMsg>Επαναφορά ρυθμίσεων σε προεπιλεγμένες τιμές. -Συνέχιση;</RestoreDefaultSettingsMsg> - <RemoveTimeCodes>Αφαίρεση κωδικών χρόνου</RemoveTimeCodes> - <EditFixContinuationStyleSettings>Επεξεργασία ρυθμίσεων για διόρθωση στυλ συνέχισης...</EditFixContinuationStyleSettings> - <FixContinuationStyleSettings>Ρυθμίσεις διόρθωσης στυλ συνέχισης</FixContinuationStyleSettings> - <UncheckInsertsAllCaps>Εντοπισμός και αποεπιλογή κεφαλαίων τίτλων μίας γραμμής</UncheckInsertsAllCaps> - <UncheckInsertsItalic>Εντοπισμός και αποεπιλογή τίτλων ή στίχων σε πλαγιαστά</UncheckInsertsItalic> - <UncheckInsertsLowercase>Εντοπισμός και αποεπιλογή πεζών τίτλων ή στίχων μίας γραμμής</UncheckInsertsLowercase> - <HideContinuationCandidatesWithoutName>Απόκρυψη απίθανων προτάσεων συνέχισης</HideContinuationCandidatesWithoutName> - <IgnoreLyrics>Αγνόηση στίχων μεταξύ μουσικών συμβόλων</IgnoreLyrics> - <MinFrameGap>Ελάχιστο κενό σε καρέ</MinFrameGap> - <XFramesAtYFrameRateGivesZMs>{0} καρέ ανά {1} καρέ είναι {2} χιλ. δευτερολέπτου.</XFramesAtYFrameRateGivesZMs> - <UseXAsNewGap>Χρήση "{0}" χιλ. δευτερολέπτου ως ελάχιστο κενό;</UseXAsNewGap> - </Settings> - <SettingsMpv> - <Title>Ρυθμίσεις mpv</Title> - <DownloadMpv>Λήψη mpv lib</DownloadMpv> - <DownloadMpvFailed>Αδυναμία λήψης mpv - παρακαλώ, προσπαθήστε αργότερα!</DownloadMpvFailed> - <DownloadMpvOk>Ολοκλήρωση λήψης mpv lib και έτοιμο προς χρήση.</DownloadMpvOk> - </SettingsMpv> - <SettingsFfmpeg> - <Title>Λήψη FFmpeg</Title> - <XDownloadFailed>Αδυναμία λήψης {0} - παρακαλώ, προσπαθήστε αργότερα!</XDownloadFailed> - <XDownloadOk>Λήψη {0} και έτοιμο προς χρήση.</XDownloadOk> - </SettingsFfmpeg> - <SetVideoOffset> - <Title>Ορισμός έναρξης βίντεο</Title> - <Description>Ορισμός έναρξης βίντεο (μη ακουλούθηση πραγματικού χρόνου βίντεο)</Description> - <RelativeToCurrentVideoPosition>Σχετικά με την τρέχουσα θέση βίντεο</RelativeToCurrentVideoPosition> - <KeepTimeCodes>Κράτημα υπαρχόντων κωδικών χρόνου (μη προσθήκη έναρξης βίντεο)</KeepTimeCodes> - <Reset>Επαναφορά</Reset> - </SetVideoOffset> - <ShowEarlierLater> - <Title>Εμφάνιση γραμμών νωρίτερα/αργότερα</Title> - <TitleAll>Εμφάνιση όλων των γραμμών νωρίτερα/αργότερα</TitleAll> - <ShowEarlier>Εμφάνιση νωρίτερα</ShowEarlier> - <ShowLater>Εμφάνιση αργότερα</ShowLater> - <TotalAdjustmentX>Συνολική προσαρμογή: {0}</TotalAdjustmentX> - <AllLines>Όλες οι γραμμές</AllLines> - <SelectedLinesOnly>Μόνο τις επιλεγμένες γραμμές</SelectedLinesOnly> - <SelectedLinesAndForward>Επιλογή από τη(ις) γραμμή(ές) και εμπρός</SelectedLinesAndForward> - </ShowEarlierLater> - <ShowHistory> - <Title>Ιστορικό (για αναίρεση)</Title> - <SelectRollbackPoint>Επιλέξτε χρόνο/περιγραφή για επαναφορά</SelectRollbackPoint> - <Time>Χρόνος</Time> - <Description>Περιγραφή</Description> - <CompareHistoryItems>Σύγκριση στοιχείων ιστορικού</CompareHistoryItems> - <CompareWithCurrent>Σύγκριση με τρέχον</CompareWithCurrent> - <Rollback>Επαναφορά</Rollback> - </ShowHistory> - <SpellCheck> - <Title>Ορθογραφικός έλεγχος</Title> - <FullText>Πλήρους κειμένου</FullText> - <WordNotFound>Λέξη δεν βρέθηκε</WordNotFound> - <Language>Γλώσσα</Language> - <Change>Αλλαγή</Change> - <ChangeAll>Αλλαγή όλων</ChangeAll> - <SkipOnce>Παράλειψη &amp;ενός</SkipOnce> - <SkipAll>&amp;Παράλειψη όλων</SkipAll> - <AddToUserDictionary>Προσθήκη στο λεξικό του χρήστη</AddToUserDictionary> - <AddToNamesAndIgnoreList>Προσθήκη στη λίστα ονομάτων/παραλείψεων (διάκριση πεζών-κεφαλαίων)</AddToNamesAndIgnoreList> - <AddToOcrReplaceList>Προσθήκη ζεύγους στη λίστα αντικατάστασης του OCR</AddToOcrReplaceList> - <Abort>Ματαίωση</Abort> - <Use>Χρήση</Use> - <UseAlways>&amp;Χρήση πάντα</UseAlways> - <Suggestions>Προτάσεις</Suggestions> - <SpellCheckProgress>Ορθογραφικός έλεγχος [{0}] - {1}</SpellCheckProgress> - <EditWholeText>Επεξεργασία ολόκληρου κειμένου</EditWholeText> - <EditWordOnly>Επεξεργασία λέξης</EditWordOnly> - <AddXToNames>Προσθήκη '{0}' στη λίστα ονομάτων</AddXToNames> - <AddXToUserDictionary>Προσθήκη {0} στο λεξικό χρήστη</AddXToUserDictionary> - <AutoFixNames>Αυτόματη επιδιόρθωση ονομάτων μόνο για διαφορά πεζών-κεφαλαίων</AutoFixNames> - <AutoFixNamesViaSuggestions>Διόρθωση ονομάτων μέσω 'προτάσεων ορθογραφικού ελέγχου'</AutoFixNamesViaSuggestions> - <CheckOneLetterWords>Ερώτηση για άγνωστες λέξεις ένός γράμματος</CheckOneLetterWords> - <TreatINQuoteAsING>Αντιμετώπιση κατάληξης " in' " ως " ing " (Μόνο Αγγλικά)</TreatINQuoteAsING> - <RememberUseAlwaysList>Απομνημόνευση λίστας "Χρήση πάντα"</RememberUseAlwaysList> - <ImageText>Κείμενο εικόνας</ImageText> - <SpellCheckCompleted>Ολοκλήρωση ορθογραφικού ελέγχου</SpellCheckCompleted> - <SpellCheckAborted>Ματαίωση ορθογραφικού ελέγχου</SpellCheckAborted> - <SpacesNotAllowed>Απαγορεύονται τα κενά σε λέξη!</SpacesNotAllowed> - <UndoX>Αναιρέθηκαν: {0}</UndoX> - </SpellCheck> - <NetflixQualityCheck> - <GlyphCheckReport>Μη έγκυρος χαρακτήρας {0} στη στήλη {1}</GlyphCheckReport> - <WhiteSpaceCheckReport>Μη έγκυρο κενό στη στήλη {0}</WhiteSpaceCheckReport> - <ReportPrompt>Δείτε την αναφορά εδώ: {0}.</ReportPrompt> - <OpenReportInFolder>Άνοιγμα φακέλου αναφοράς</OpenReportInFolder> - <FoundXIssues>Ο έλεγχος ποιότητας Netflix εντόπισε {0:#,###} προβλήματα.</FoundXIssues> - <CheckOk>Χωρίς προβλήματα</CheckOk> - <MaximumXCharsPerSecond>Μέγιστοι {0} χαρακτήρες/ δευτ (εξαίρεση κενών)</MaximumXCharsPerSecond> - <MaximumLineLength>Μέγιστο μήκος γραμμής ({0})</MaximumLineLength> - <MinimumDuration>Ελάχιστη διάρκεια: 5/6 δευτερολέπτου (833 χ.δ.)</MinimumDuration> - </NetflixQualityCheck> - <Split> - <Title>Διαχωρισμός</Title> - <SplitOptions>Επιλογές διαχωρισμού</SplitOptions> - <Lines>Γραμμές</Lines> - <Characters>Χαρακτήρες</Characters> - <NumberOfEqualParts>Αριθμός ίσων κομματιών</NumberOfEqualParts> - <SubtitleInfo>Πληροφορίες υπότιτλου</SubtitleInfo> - <NumberOfLinesX>Αριθμός γραμμών: {0:#,###}</NumberOfLinesX> - <NumberOfCharactersX>Αριθμός χαρακτήρων: {0:#,###,###}</NumberOfCharactersX> - <Output>Εξαγωγή</Output> - <FileName>Όνομα αρχείου</FileName> - <OutputFolder>Φάκελος εξαγωγής</OutputFolder> - <DoSplit>Διαχωρισμός</DoSplit> - <Basic>Βασικός</Basic> - </Split> - <SplitLongLines> - <Title>Διάσπαση/διαχωρισμός μεγάλων γραμμών</Title> - <SingleLineMaximumLength>Μέγιστο μήκος μονής γραμμής</SingleLineMaximumLength> - <LineMaximumLength>Μέγιστο μήκος γραμμής</LineMaximumLength> - <LineContinuationBeginEndStrings>Συμβολοσειρές έναρξης/λήξης συνέχισης της γραμμής</LineContinuationBeginEndStrings> - <NumberOfSplits>Σύνολο διαχωρισμών: {0}</NumberOfSplits> - <LongestSingleLineIsXAtY>Το μεγαλύτερο μήκος μονής γραμμής είναι {0} στη γραμμή {1}</LongestSingleLineIsXAtY> - <LongestLineIsXAtY>Το μεγαλύτερο μήκος μήκος ολικής γραμμής είναι {0} στη γραμμή {1}</LongestLineIsXAtY> - </SplitLongLines> - <SplitSubtitle> - <Title>Διαχωρισμός υπότιτλου</Title> - <Description1>Εισαγωγή μήκους πρώτου μέρους βίντεο ή περιήγηση</Description1> - <Description2>και πάρτε το μήκος από αρχείο βίντεο:</Description2> - <Split>&amp;Διαχωρισμός</Split> - <Done>&amp;Ολοκληρώθηκε</Done> - <NothingToSplit>Τίποτα για διαχωρισμό !</NothingToSplit> - <SavePartOneAs>Αποθήκευση μέρους 1 ως...</SavePartOneAs> - <SavePartTwoAs>Αποθήκευση μέρους 2 ως...</SavePartTwoAs> - <Part1>Μέρος1</Part1> - <Part2>Μέρος2</Part2> - <UnableToSaveFileX>Αδυναμία αποθήκευσης {0}</UnableToSaveFileX> - <OverwriteExistingFiles>Αντικατάσταση υπαρχόντων αρχείων;</OverwriteExistingFiles> - <FolderNotFoundX>Ο φάκελος δεν βρέθηκε: {0}</FolderNotFoundX> - <Untitled>Χωρίς τίτλο</Untitled> - </SplitSubtitle> - <StartNumberingFrom> - <Title>Επαναρίθμησης από...</Title> - <StartFromNumber>Έναρξη από τον αριθμό:</StartFromNumber> - <PleaseEnterAValidNumber>Εισαγωγή έγκυρου αριθμού</PleaseEnterAValidNumber> - </StartNumberingFrom> - <Statistics> - <Title>Στατιστικά</Title> - <TitleWithFileName>Στατιστικά - {0}</TitleWithFileName> - <GeneralStatistics>Γενικά στατιστικά</GeneralStatistics> - <MostUsed>Περισσότερη χρήση...</MostUsed> - <MostUsedLines>Οι περισσότερες χρησιμοποιούμενες γραμμές</MostUsedLines> - <MostUsedWords>Οι περισσότερες χρησιμοποιούμενες λέξεις</MostUsedWords> - <NothingFound>Δεν βρέθηκε τίποτα</NothingFound> - <NumberOfLinesX>Αριθμός γραμμών υποτίτλου: {0:#,###}</NumberOfLinesX> - <LengthInFormatXinCharactersY>Αριθμός χαρακτήρων όπως {0}: {1:#,###,##0}</LengthInFormatXinCharactersY> - <NumberOfCharactersInTextOnly>Αριθμός χαρακτήρων μόνο στο κείμενο: {0:#,###,##0}</NumberOfCharactersInTextOnly> - <TotalDuration>Συνολική διάρκεια των υποτίτλων: {0:#,##0}</TotalDuration> - <TotalCharsPerSecond>Σύνολο χαρακτήρων/δευτερόλεπτο: {0:0.0} δευτερόλεπτα</TotalCharsPerSecond> - <TotalWords>Σύνολο λέξεων: {0:#,##0}</TotalWords> - <NumberOfItalicTags>Αριθμός ετικετών πλάγιας γραφής: {0}</NumberOfItalicTags> - <NumberOfBoldTags>Αριθμός ετικετών έντονης γραφής: {0}</NumberOfBoldTags> - <NumberOfUnderlineTags>Αριθμός ετικετών υπογραμμισμένης γραφής: {0}</NumberOfUnderlineTags> - <NumberOfFontTags>Αριθμός ετικετών γραμματοσειράς: {0}</NumberOfFontTags> - <NumberOfAlignmentTags>Αριθμός ετικετών στοίχισης: {0}</NumberOfAlignmentTags> - <LineLengthMinimum>Μήκος υποτίτλου - ελάχιστο: {0}</LineLengthMinimum> - <LineLengthMaximum>Μήκος υποτίτλου - μέγιστο: {0}</LineLengthMaximum> - <LineLengthAverage>Μήκος υποτίτλου - μέσο: {0}</LineLengthAverage> - <LinesPerSubtitleAverage>Αριθμός γραμμών υποτίτλων - μέσος: {0:0.0}</LinesPerSubtitleAverage> - <SingleLineLengthMinimum>Μήκος μονής γραμμής - ελάχιστο: {0}</SingleLineLengthMinimum> - <SingleLineLengthMaximum>Μήκος μονής γραμμής - μέγιστο: {0}</SingleLineLengthMaximum> - <SingleLineLengthAverage>Μήκος μονής γραμμής - μέσο: {0}</SingleLineLengthAverage> - <SingleLineWidthMinimum>Εύρος μονής γραμμής - ελάχιστο: {0} εικονοστοιχεία</SingleLineWidthMinimum> - <SingleLineWidthMaximum>Εύρος μονής γραμμής - μέγιστο: {0} εικονοστοιχεία</SingleLineWidthMaximum> - <SingleLineWidthAverage>Εύρος μονής γραμμής - μέσο: {0} εικονοστοιχεία</SingleLineWidthAverage> - <DurationMinimum>Διάρκεια - ελάχιστη: {0:0.000} δευτερόλεπτα</DurationMinimum> - <DurationMaximum>Διάρκεια - μέγιστη: {0:0.000} δευτερόλεπτα</DurationMaximum> - <DurationAverage>Διάρκεια - μέση: {0:0.000} δευτερόλεπτα</DurationAverage> - <CharactersPerSecondMinimum>Χαρακτήρες/ δευτ - ελάχιστοι: {0:0.000}</CharactersPerSecondMinimum> - <CharactersPerSecondMaximum>Χαρακτήρες/ δευτ - μέγιστοι: {0:0.000}</CharactersPerSecondMaximum> - <CharactersPerSecondAverage>Χαρακτήρες/ δευτ - μέσοι: {0:0.000}</CharactersPerSecondAverage> - <Export>Εξαγωγή...</Export> - </Statistics> - <SubStationAlphaProperties> - <Title>Προχωρημένες ιδιότητες Sub Station Alpha</Title> - <TitleSubstationAlpha>Ιδιότητες Sub Station Alpha</TitleSubstationAlpha> - <Script>Σενάριο</Script> - <ScriptTitle>Τίτλος</ScriptTitle> - <OriginalScript>Αρχικό σενάριο</OriginalScript> - <Translation>Μετάφραση</Translation> - <Editing>Επιμέλεια</Editing> - <Timing>Χρονισμός</Timing> - <SyncPoint>Σημείο συγχρονισμού</SyncPoint> - <UpdatedBy>Ενημερωμένο από</UpdatedBy> - <UpdateDetails>Λεπτομέρειες ενημέρωσης</UpdateDetails> - <Resolution>Ανάλυση</Resolution> - <VideoResolution>Ανάλυση βίντεοVideo resolution</VideoResolution> - <Options>Επιλογές</Options> - <WrapStyle>Στυλ αναδίπλωσης</WrapStyle> - <Collision>Σύγκρουση</Collision> - <ScaleBorderAndShadow>Κλίμακα ορίων και σκιάς</ScaleBorderAndShadow> - </SubStationAlphaProperties> - <SubStationAlphaStyles> - <Title>Προχωρημένα στυλ Sub Station Alpha</Title> - <TitleSubstationAlpha>Στυλ Sub Station Alpha</TitleSubstationAlpha> - <Styles>Στυλ</Styles> - <Properties>Ιδιότητες</Properties> - <Name>Όνομα</Name> - <Font>Γραμματοσειρά</Font> - <FontName>Όνομα γραμματοσειράς</FontName> - <FontSize>Μέγεθος γραμματοσειράς</FontSize> - <UseCount>Χρησιμοποιημένα</UseCount> - <Primary>Πρωτογενής</Primary> - <Secondary>Δευτερογενής</Secondary> - <Tertiary>Τριτογενής</Tertiary> - <Outline>Περίγραμμα</Outline> - <Shadow>Σκιά</Shadow> - <Back>Πίσω</Back> - <Alignment>Στοίχιση</Alignment> - <TopLeft>Επάνω/αριστερά</TopLeft> - <TopCenter>Επάνω/κέντρο</TopCenter> - <TopRight>Επάνω/δεξιά</TopRight> - <MiddleLeft>Μέση/αριστερά</MiddleLeft> - <MiddleCenter>Μέση/κέντρο</MiddleCenter> - <MiddleRight>Μέση/δεξιά</MiddleRight> - <BottomLeft>Κάτω/αριστερά</BottomLeft> - <BottomCenter>Κάτω/κέντρο</BottomCenter> - <BottomRight>Κάτω/δεξιά</BottomRight> - <Colors>Χρώματα</Colors> - <Margins>Περιθώρια</Margins> - <MarginLeft>Περιθώριο αριστερά</MarginLeft> - <MarginRight>Περιθώριο δεξιά</MarginRight> - <MarginVertical>Περιθώριο κάθετα</MarginVertical> - <Border>Όριο</Border> - <PlusShadow>+ Σκιά</PlusShadow> - <OpaqueBox>Αδιαφανές πλαίσιο (χρήση χρώματος περιγράμματος)</OpaqueBox> - <Import>Εισαγωγή...</Import> - <Export>Εξαγωγή...</Export> - <Copy>Αντιγραφή</Copy> - <CopyOfY>Αντιγραφή από {0}</CopyOfY> - <CopyXOfY>Αντιγραφή {0} από {1}</CopyXOfY> - <New>Νέο</New> - <Remove>Αφαίρεση</Remove> - <RemoveAll>Αφ. όλων</RemoveAll> - <ImportStyleFromFile>Εισαγωγή στυλ από αρχείο...</ImportStyleFromFile> - <ExportStyleToFile>Εξαγωγή στυλ σε αρχείο... (προσθήκη σε περίπτωση υπάρχοντος στυλ)</ExportStyleToFile> - <ChooseStyle>Επιλογή στυλ για εισαγωγή</ChooseStyle> - <StyleAlreadyExits>Υπάρχον στυλ: {0}</StyleAlreadyExits> - <StyleXExportedToFileY>Το στυλ '{0}' έχει εξαχθεί στο αρχείο '{1}'</StyleXExportedToFileY> - <StyleXImportedFromFileY>Το στυλ '{0}' έχει εισαχθεί από το αρχείο '{1}'</StyleXImportedFromFileY> - </SubStationAlphaStyles> - <PointSync> - <Title>Συγχρονισμός σημείων</Title> - <TitleViaOtherSubtitle>Συγχρονισμός σημείων μέσω άλλου υπότιτλου</TitleViaOtherSubtitle> - <SyncHelp>Ορισμός δύο σημείων συγχρονισμού για πρόχειρο συγχρονισμό</SyncHelp> - <SetSyncPoint>Ορισμός σημείου συγχρονισμού</SetSyncPoint> - <RemoveSyncPoint>Αφαίρεση σημείου συγχρονισμού</RemoveSyncPoint> - <SyncPointsX>Σημείο συγχρονισμού: {0}</SyncPointsX> - <Info>Ένα σημείο συγχρονισμού θα προσαρμόσει τη θέση, δύο ή περισσότερα θα προσαρμόσουν τη θέση και την ταχύτητα</Info> - <ApplySync>Εφαρμογή</ApplySync> - </PointSync> - <TransportStreamSubtitleChooser> - <Title>Επιλογέας ροής μεταφοράς υποτίτλου - {0}</Title> - <PidLineImage>Εικόνες - Αναγνωριστικό πακέτου μεταφοράς = {0}, γλώσσα = {1}, αριθμός υποτίτλων = {2}</PidLineImage> - <PidLineTeletext>Τηλεκίμενο - Αναγνωριστικό πακέτου μεταφοράς = {1}, σελίδα = {0}, γλώσσα = {2}, αριθμός υποτίτλων = {3}</PidLineTeletext> - <SubLine>{0}: {1} -&gt; {2}, {3} εικόνα(ες)</SubLine> - </TransportStreamSubtitleChooser> - <UnknownSubtitle> - <Title>Άγνωστος τύπος υπότιτλου</Title> - <Message>Αν θέλετε αυτό να φτιαχτεί παρακαλώ στείλτε email στο mailto:niksedk@gmail.com και συμπεριλάβετε ένα αντίγραφο του υπότιτλου.</Message> - <ImportAsPlainText>Εισαγωγή ως απλό κείμενο...</ImportAsPlainText> - </UnknownSubtitle> - <VisualSync> - <Title>Οπτικός συγχρονισμός</Title> - <StartScene>Αρχική σκηνή</StartScene> - <EndScene>Τελική σκηνή</EndScene> - <Synchronize>Συγχρονισμός</Synchronize> - <HalfASecondBack>&lt; ½ δευτ.</HalfASecondBack> - <ThreeSecondsBack>&lt; 3 δευτ.</ThreeSecondsBack> - <PlayXSecondsAndBack>Αναπαραγωγή {0} δευτ. και πίσω</PlayXSecondsAndBack> - <FindText>Εύρεση κειμένου</FindText> - <GoToSubPosition>Μετάβαση στη θέση του υπότιτλου</GoToSubPosition> - <KeepChangesTitle>Διατήρηση αλλαγών;</KeepChangesTitle> - <KeepChangesMessage>Έχουν γίνει αλλαγές στον υπότιτλο μέσω 'Οπτικού συγχρονισμού'. -Διατήρηση αλλαγών;</KeepChangesMessage> - <SynchronizationDone>Ο συγχρονισμός ολοκληρώθηκε!</SynchronizationDone> - <StartSceneMustComeBeforeEndScene>Η αρχική σκηνή πρέπει να είναι πριν από την τελική!</StartSceneMustComeBeforeEndScene> - <Tip>Συμβουλή: Χρησιμοποιήστε &lt;ctrl+βέλη αριστερά/δεξιά&gt; για να μετακινηθείτε 100 χιλ. δευτ. πίσω/εμπρός</Tip> - </VisualSync> - <VobSubEditCharacters> - <Title>Επεξεργασία βάσης δεδομένων σύγκρισης εικόνων</Title> - <ChooseCharacter>Επιλογή χαρακτήρα(ων)</ChooseCharacter> - <ImageCompareFiles>Αρχεία σύγκρισης εικόνων</ImageCompareFiles> - <CurrentCompareImage>Τρέχουσα εικόνα σύγκρισης</CurrentCompareImage> - <TextAssociatedWithImage>Κείμενο που σχετίζεται με την εικόνα</TextAssociatedWithImage> - <IsItalic>Είναι &amp;πλαγιαστό</IsItalic> - <Update>&amp;Ενημέρωση</Update> - <Delete>&amp;Διαγραφή</Delete> - <ImageDoubleSize>Διπλό μέγεθος εικόνας</ImageDoubleSize> - <ImageFileNotFound>Το αρχείο εικόνας δεν βρέθηκε</ImageFileNotFound> - <Image>Εικόνα</Image> - </VobSubEditCharacters> - <VobSubOcr> - <Title>Εισαγωγή/OCR υπότιτλου VobSub (sub/idx)</Title> - <TitleBluRay>Εισαγωγή/OCR υπότιτλου Blu-ray (.sup)</TitleBluRay> - <OcrMethod>Μέθοδος OCR</OcrMethod> - <OcrViaTesseractVersionX>Tesseract {0}</OcrViaTesseractVersionX> - <OcrViaImageCompare>OCR μέσω σύγκρισης εικόνων</OcrViaImageCompare> - <OcrViaModi>OCR μέσω Microsoft Office Document Imaging (MODI). Προϋποθέτει Microsoft Office</OcrViaModi> - <OcrViaNOCR>OCR μέσω nOCR</OcrViaNOCR> - <TesseractEngineMode>Λειτουργία μηχανής</TesseractEngineMode> - <TesseractEngineModeLegacy>Αρχικό Tesseract (ανίχνευση πλαγιαστών)</TesseractEngineModeLegacy> - <TesseractEngineModeNeural>Δίκτυα LSTM</TesseractEngineModeNeural> - <TesseractEngineModeBoth>Tesseract + LSTM</TesseractEngineModeBoth> - <TesseractEngineModeDefault>Προεπιλεγμένο, βάσει διαθέσιμων</TesseractEngineModeDefault> - <Language>Γλώσσα</Language> - <ImageDatabase>Βάση δεδομένων εικόνων</ImageDatabase> - <NoOfPixelsIsSpace>Σύνολο εικονοστοιχείων διαστημάτων</NoOfPixelsIsSpace> - <MaxErrorPercent>Μέγιστο σφάλμα%</MaxErrorPercent> - <New>Νέο</New> - <Edit>Επεξεργασία</Edit> - <StartOcr>Έναρξη OCR</StartOcr> - <Stop>Διακοπή</Stop> - <StartOcrFrom>Έναρξη OCR από τον αριθμό υπότιτλου:</StartOcrFrom> - <LoadingVobSubImages>Φόρτωση εικόνων VobSub...</LoadingVobSubImages> - <LoadingImageCompareDatabase>Φόρτωση βάσης δεδομένων εικόνων σύγκρισης...</LoadingImageCompareDatabase> - <ConvertingImageCompareDatabase>Μετατροπή βάσης δεδομένων εικόνων σύγκρισης σε νέο τύπο (images.db/images.xml)...</ConvertingImageCompareDatabase> - <SubtitleImage>Εικόνα υπότιτλου</SubtitleImage> - <SubtitleText>Κείμενο υπότιτλου</SubtitleText> - <UnableToCreateCharacterDatabaseFolder>Αδυναμία δημιουργίας φακέλου 'Character Database Folder': {0}</UnableToCreateCharacterDatabaseFolder> - <SubtitleImageXofY>Εικόνα υπότιτλου {0} από {1}</SubtitleImageXofY> - <ImagePalette>Παλέτα εικόνας</ImagePalette> - <UseCustomColors>Χρήση προσαρμοσμένων χρωμάτων</UseCustomColors> - <Transparent>Χωρίς φόντο</Transparent> - <TransparentMinAlpha>Ελάχιστη τιμή άλφα (0=διαφανές, 255=πλήρως ορατό)</TransparentMinAlpha> - <TransportStream>Ροή μεταφοράς</TransportStream> - <TransportStreamGrayscale>Κλίμακα του γκρι</TransportStreamGrayscale> - <TransportStreamGetColor>Χρήση χρώματος (θα συμπεριληφθούν μερικές σπασμένες γραμμές)</TransportStreamGetColor> - <PromptForUnknownWords>Ερώτηση για άγνωστες λέξεις</PromptForUnknownWords> - <TryToGuessUnkownWords>Προσπάθεια μαντέματος άγνωστων λέξεων</TryToGuessUnkownWords> - <AutoBreakSubtitleIfMoreThanTwoLines>Αυτόματος διαχορισμός παραγράφου εάν έχει περισσότερες από δύο γραμμές</AutoBreakSubtitleIfMoreThanTwoLines> - <AllFixes>Όλες οι επιδιορθώσεις</AllFixes> - <GuessesUsed>Μαντεψιές</GuessesUsed> - <UnknownWords>Άγνωστες λέξεις</UnknownWords> - <UnknownWordToGuessInLine>{0} {1} μέσω λίστας διόρθωσης/αντικατάστασης OCR στη γραμμή: {2}</UnknownWordToGuessInLine> - <OcrAutoCorrectionSpellChecking>Αυτόματη διόρθωση/ορθογραφικός έλεγχος OCR</OcrAutoCorrectionSpellChecking> - <FixOcrErrors>Επιδιόρθωση σφαλμάτων OCR</FixOcrErrors> - <ImportTextWithMatchingTimeCodes>Εισαγωγή κειμένου με αντιστοιχία κωδικών χρόνου...</ImportTextWithMatchingTimeCodes> - <ImportNewTimeCodes>Εισαγωγή νέων κωδικών χρόνου</ImportNewTimeCodes> - <SaveSubtitleImageAs>Αποθήκευση εικόνας υπότιτλου ως...</SaveSubtitleImageAs> - <SaveAllSubtitleImagesAsBdnXml>Αποθήκευση όλων των εικόνων (png/bdn xml)...</SaveAllSubtitleImagesAsBdnXml> - <SaveAllSubtitleImagesWithHtml>Αποθήκευση όλων των εικόνων με HTML...</SaveAllSubtitleImagesWithHtml> - <XImagesSavedInY>{0} εικόνες αποθηκεύτηκαν στο {1}</XImagesSavedInY> - <DictionaryX>Λεξικό: {0}</DictionaryX> - <RightToLeft>Δεξιά προς αριστερά</RightToLeft> - <ShowOnlyForcedSubtitles>Εμφάνιση μόνο υποχρεωτικών υποτίτλων</ShowOnlyForcedSubtitles> - <UseTimeCodesFromIdx>Χρήση κωδικών χρόνου από αρχείο .idx</UseTimeCodesFromIdx> - <NoMatch>&lt;Καμία αντιστοιχία&gt;</NoMatch> - <AutoTransparentBackground>Αυτόματη διαφάνεια φόντου</AutoTransparentBackground> - <CaptureTopAlign>Λήψη άνω στοίχισης</CaptureTopAlign> - <InspectCompareMatchesForCurrentImage>Έλεγχος αντιστοιχιών σύγκρισης για την τρέχουσα εικόνα...</InspectCompareMatchesForCurrentImage> - <EditLastAdditions>Επεξεργασία προσθηκών της τελευταίας σύγκρισης εικόνας...</EditLastAdditions> - <SetItalicAngle>Ορισμός κλίσης πλαγιαστών...</SetItalicAngle> - <ItalicAngle>Κλίση πλαγιαστών</ItalicAngle> - <DiscardTitle>Απόρριψη αλλαγών του OCR;</DiscardTitle> - <DiscardText>Απόρριψη αλλαγών του OCR στην τρέχουσα συνεδρία;</DiscardText> - <MinLineSplitHeight>Ελάχιστο ύψος γραμμής (διαχωρισμός)</MinLineSplitHeight> - <FallbackToX>Επαναφορά σε {0}</FallbackToX> - <ImagePreProcessing>Προ-επεξεργασία εικόνας...</ImagePreProcessing> - <EditImageDb>Επεξεργασία βάσης δεδομένων εικόνας</EditImageDb> - <OcrTraining>Εκμάθηση OCR...</OcrTraining> - <SubtitleTrainingFile>Εκμάθηση με αρχείο υπότιτλου</SubtitleTrainingFile> - <LetterCombinations>Συνδυασμοί γράμματος που είναι χωρισμένο ως μία εικόνα</LetterCombinations> - <TrainingOptions>Επιλογές εκμάθησης</TrainingOptions> - <NumberOfSegments>Αριθμός τμημάτων ανά γράμμα</NumberOfSegments> - <AlsoTrainItalic>Εκμάθηση πλαγιαστών</AlsoTrainItalic> - <AlsoTrainBold>Εκμάθηση έντονων</AlsoTrainBold> - <StartTraining>Έναρξη εκμάθησης</StartTraining> - <NowTraining>Εκμάθηση γραμματοσειράς '{1}. Σύνολο χαρακτήρων που μαθεύτηκαν: {0:#,###,##0}, {2:#,###,##0} γνωστά</NowTraining> - </VobSubOcr> - <VobSubOcrCharacter> - <Title>OCR - Εικόνα σε κείμενο χειροκίνητα</Title> - <ShrinkSelection>Σμίκρυνση επιλογής</ShrinkSelection> - <ExpandSelection>Επέκταση επιλογής</ExpandSelection> - <SubtitleImage>Εικόνα υπότιτλου</SubtitleImage> - <Characters>Χαρακτήρας(ες)</Characters> - <CharactersAsText>Χαρακτήρας(ες) ως κείμενο</CharactersAsText> - <Italic>&amp;Πλαγιστά</Italic> - <Abort>&amp;Ματαίωση</Abort> - <Skip>Π&amp;αράβλεψη</Skip> - <Nordic>Σκανδιναβικά</Nordic> - <Spanish>Ισπανικά</Spanish> - <German>Γερμανικά</German> - <AutoSubmitOnFirstChar>Αυτόματη αποστολή στον &amp;πρώτο χαρακτήρα</AutoSubmitOnFirstChar> - <EditLastX>Επεξεργασία τελευταίου: {0}</EditLastX> - </VobSubOcrCharacter> - <VobSubOcrCharacterInspect> - <Title>Έλεγχος αντιστοιχιών σύγκρισης για την τρέχουσα εικόνα</Title> - <InspectItems>Έλεγχος στοιχείων</InspectItems> - <AddBetterMatch>Προσθήκη καλύτερης αντιστοιχίας</AddBetterMatch> - <Add>Προσθήκη</Add> - </VobSubOcrCharacterInspect> - <VobSubOcrNewFolder> - <Title>Νέος φάκελος</Title> - <Message>Όνομα νέου φακέλου βάσης δεδομένων χαρακτήρων</Message> - </VobSubOcrNewFolder> - <VobSubOcrSetItalicAngle> - <Title>Ορισμός κλίσης πλαγιαστών</Title> - <Description>Προσαρμογή τιμής μέχρι το στυλ κειμένου να είναι κανονικό. Το αρχικό κείμενο έχει πλαγιαστό στυλ.</Description> - </VobSubOcrSetItalicAngle> - <OcrPreprocessing> - <Title>Προ-επεξεργασία εικόνας με OCR</Title> - <Colors>Χρώματα</Colors> - <AdjustAlpha>Προσαρμογή τιμής μέχρι το κείμενο να είναι ορατό (εύρος τιμών μεταξύ 200 έως 300)</AdjustAlpha> - <OriginalImage>Αρχική εικόνα</OriginalImage> - <PostImage>Εικόνα μετά την προ-επεξεργασία</PostImage> - <BinaryThreshold>Όριο σύγκρισης δυαδικής εικόνας</BinaryThreshold> - <InvertColors>Αντιστροφή χρωμάτων</InvertColors> - <YellowToWhite>Κίτρινο σε άσπρο</YellowToWhite> - <ColorToWhite>Χρώμα σε άσπρο</ColorToWhite> - <ColorToRemove>Αφαίρεση χρώματος</ColorToRemove> - <Cropping>Κόψιμο</Cropping> - <CropTransparentColors>Κόψιμο διαφανών χρωμάτων</CropTransparentColors> - </OcrPreprocessing> - <Watermark> - <Title>Υδατόσημο</Title> - <WatermarkX>Υδατόσημο: {0}</WatermarkX> - <GenerateWatermarkTitle>Δημιουργία υδατόσημου</GenerateWatermarkTitle> - <SpreadOverEntireSubtitle>Εξάπλωση σε όλον τον υπότιτλο</SpreadOverEntireSubtitle> - <CurrentLineOnlyX>Μόνο σε τρέχουσα γραμμή: {0}</CurrentLineOnlyX> - <Generate>Δημιουργία</Generate> - <Remove>Αφαίρεση</Remove> - <BeforeWatermark>Πριν του υδατόσημου</BeforeWatermark> - <ErrorUnicodeEncodingOnly>Το υδατόσημολειτουργεί μόνο με κωδικοποίηση αρχείου unicode.</ErrorUnicodeEncodingOnly> - </Watermark> - <Waveform> - <ClickToAddWaveform>Κάντε κλικ για προσθήκη κυματομορφής</ClickToAddWaveform> - <ClickToAddWaveformAndSpectrogram>Κάντε κλικ για προσθήκη κυματομορφής/φασματογράμματος</ClickToAddWaveformAndSpectrogram> - <Seconds>δευτ.</Seconds> - <ZoomIn>Μεγέθυνση</ZoomIn> - <ZoomOut>Σμίκρυνση</ZoomOut> - <AddParagraphHere>Προσθήκη κειμένου</AddParagraphHere> - <AddParagraphHereAndPasteText>Προσθήκη κειμένου από το πρόχειρο</AddParagraphHereAndPasteText> - <SetParagraphAsSelection>Καθορισμός ως νέας επιλογής</SetParagraphAsSelection> - <FocusTextBox>Εστίαση πλαισίου κειμένου</FocusTextBox> - <GoToPrevious>Μετάβαση στον προηγούμενο υπότιτλο</GoToPrevious> - <GoToNext>Μετάβαση στον επόμενο υπότιτλο</GoToNext> - <DeleteParagraph>Διαγραφή κειμένου</DeleteParagraph> - <Split>Διαχωρισμός</Split> - <SplitAtCursor>Διαχωρισμός στη θέση του δείκτη</SplitAtCursor> - <MergeWithPrevious>Συγχώνευση με προηγούμενο</MergeWithPrevious> - <MergeWithNext>Συγχώνευση με επόμενο</MergeWithNext> - <ExtendToPrevious>Επέκταση μέχρι το προηγούμενο</ExtendToPrevious> - <ExtendToNext>Επέκταση μέχρι το επόμενο</ExtendToNext> - <PlaySelection>Αναπαραγωγή επιλογής</PlaySelection> - <ShowWaveformAndSpectrogram>Εμφάνιση κυματομορφής και φασματογράμματος</ShowWaveformAndSpectrogram> - <ShowWaveformOnly>Εμφάνιση μόνο κυματομορφής</ShowWaveformOnly> - <ShowSpectrogramOnly>Εμφάνιση μόνο φασματογράμματος</ShowSpectrogramOnly> - <AddSceneChange>Προσθήκη αλλαγής σκηνής</AddSceneChange> - <RemoveSceneChange>Αφαίρεση αλλαγής σκηνής</RemoveSceneChange> - <GuessTimeCodes>Μάντεψε τους κώδικες χρόνου...</GuessTimeCodes> - <SeekSilence>Αναζήτηση σιωπής...</SeekSilence> - <InsertSubtitleHere>Εισαγωγή υπότιτλου εδώ...</InsertSubtitleHere> - <CharsSecX>Χαρ/δευτ: {0:0.00}</CharsSecX> - <WordsMinX>Λέξεις/λεπτό: {0:0.00}</WordsMinX> - </Waveform> - <WaveformGenerateTimeCodes> - <Title>Εικασία κωδικών χρόνου</Title> - <StartFrom>Έναρξη από</StartFrom> - <CurrentVideoPosition>Τρέχουσα θέση βίντεο</CurrentVideoPosition> - <Beginning>Έναρξη</Beginning> - <DeleteLines>Διαγραφή γραμμών</DeleteLines> - <FromCurrentVideoPosition>Από την τρέχουσα θέση βίντεο</FromCurrentVideoPosition> - <DetectOptions>Εντοπισμός επιλογών</DetectOptions> - <ScanBlocksOfMs>Σάρωση των μπλοκ χιλιοστών του δευτερολέπτου</ScanBlocksOfMs> - <BlockAverageVolMin1>Η μέση τιμή των μπλοκ έντασης πρέπει να είναι πάνω από</BlockAverageVolMin1> - <BlockAverageVolMin2>% από τη μέση συνολική ένταση</BlockAverageVolMin2> - <BlockAverageVolMax1>Η μέση τιμή των μπλοκ έντασης πρέπει να είναι κάτω από</BlockAverageVolMax1> - <BlockAverageVolMax2>% από την μέγιστη συνολική ένταση</BlockAverageVolMax2> - <SplitLongLinesAt1>Διαχωρισμός μεγάλων υποτίτλων σε</SplitLongLinesAt1> - <SplitLongLinesAt2>χιλιοστά δευτερολέπτου</SplitLongLinesAt2> - <Other>Άλλο</Other> - </WaveformGenerateTimeCodes> - <WebVttNewVoice> - <Title>WebVTT - καθορισμός νέας φωνής</Title> - <VoiceName>Όνομα φωνής</VoiceName> - </WebVttNewVoice> +<?xml version="1.0" encoding="utf-8"?> +<Language Name="Ελληνικά"> + <General> + <Title>Subtitle Edit</Title> + <Version>3.5.18</Version> + <TranslatedBy>Μετάφραση: Παναγιώτης Μητσάκης</TranslatedBy> + <CultureName>el-GR</CultureName> + <HelpFile /> + <Ok>&amp;Εντάξει</Ok> + <Cancel>&amp;Ακύρωση</Cancel> + <Apply>Εφαρμογή</Apply> + <None>Κανένα</None> + <All>Όλα</All> + <Preview>Προεπισκόπηση</Preview> + <SubtitleFiles>Αρχεία υπότιτλου</SubtitleFiles> + <AllFiles>Όλα τα αρχεία</AllFiles> + <VideoFiles>Αρχεία βίντεο</VideoFiles> + <AudioFiles>Αρχεία ήχου</AudioFiles> + <OpenSubtitle>Άνοιγμα υπότιτλου...</OpenSubtitle> + <OpenVideoFile>Άνοιγμα αρχείου βίντεο...</OpenVideoFile> + <OpenVideoFileTitle>Άνοιγμα αρχείου βίντεο...</OpenVideoFileTitle> + <NoVideoLoaded>Μη φορτωμένο βίντεο</NoVideoLoaded> + <VideoInformation>Πληροφορίες βίντεο</VideoInformation> + <StartTime>Έναρξη</StartTime> + <EndTime>Λήξη</EndTime> + <Duration>Διάρκεια</Duration> + <CharsPerSec>Χαρακτήρες/δευτερόλεπτο</CharsPerSec> + <WordsPerMin>Λέξεις/λεπτό</WordsPerMin> + <Actor>Ηθοποιός</Actor> + <Gap>Κενό</Gap> + <Region>Περιοχή</Region> + <NumberSymbol>#</NumberSymbol> + <Number>Αριθμός</Number> + <Text>Κείμενο</Text> + <HourMinutesSecondsMilliseconds>Ώρες:λεπτά:δευτ.:χιλ.</HourMinutesSecondsMilliseconds> + <HourMinutesSecondsFrames>Ώρες:λεπτά:δευτ:καρέ</HourMinutesSecondsFrames> + <Bold>Έντονα</Bold> + <Italic>Πλαγιαστά</Italic> + <Underline>Υπογραμμισμένα</Underline> + <Visible>Ορατό</Visible> + <FrameRate>Ρυθμός καρέ</FrameRate> + <Name>Όνομα</Name> + <FileNameXAndSize>Όνομα αρχείου: {0} ({1})</FileNameXAndSize> + <ResolutionX>Ανάλυση: {0}</ResolutionX> + <FrameRateX>Ρυθμός καρέ: {0:0.0###}</FrameRateX> + <TotalFramesX>Σύνολο καρέ: {0:#,##0.##}</TotalFramesX> + <VideoEncodingX>Κωδικοποίηση βίντεο: {0}</VideoEncodingX> + <SingleLineLengths>Μήκος ενιαίας γραμμής:</SingleLineLengths> + <TotalLengthX>Συνολικό μήκος: {0}</TotalLengthX> + <TotalLengthXSplitLine>Συνολικό μήκος: {0} (Διαχωρισμός!)</TotalLengthXSplitLine> + <SplitLine>Διαχωρισμός!</SplitLine> + <NotAvailable>Μη διαθέσιμο</NotAvailable> + <OverlapPreviousLineX>Επικάλυψη προηγούμενης ({0:#,##0.###})</OverlapPreviousLineX> + <OverlapX>Επικάλυψη ({0:#,##0.###})</OverlapX> + <OverlapNextX>Επικάλυψη επόμενης ({0:#,##0.###})</OverlapNextX> + <Negative>Αρνητικό</Negative> + <RegularExpressionIsNotValid>Η τυπική έκφραση δεν είναι έγκυρη!</RegularExpressionIsNotValid> + <CurrentSubtitle>Τρέχων υπότιτλος</CurrentSubtitle> + <OriginalText>Αρχικό κείμενο</OriginalText> + <OpenOriginalSubtitleFile>Άνοιγμα αρχικού αρχείου υπότιτλου...</OpenOriginalSubtitleFile> + <PleaseWait>Παρακαλώ περιμένετε...</PleaseWait> + <SessionKey>Κλειδί συνεδρίας</SessionKey> + <UserName>Όνομα χρήστη</UserName> + <UserNameAlreadyInUse>Μη διαθέσιμο όνομα</UserNameAlreadyInUse> + <WebServiceUrl>Διεύθυνση ιστοσελίδας</WebServiceUrl> + <IP>Διεύθυνση IP</IP> + <VideoWindowTitle>Βίντεο - {0}</VideoWindowTitle> + <AudioWindowTitle>Ήχος - {0}</AudioWindowTitle> + <ControlsWindowTitle>Στοιχεία ελέγχου - {0}</ControlsWindowTitle> + <Advanced>Προηγμένες</Advanced> + <Style>Στυλ</Style> + <StyleLanguage>Στυλ/Γλώσσα</StyleLanguage> + <Character>Χαρακτήρας</Character> + <Class>Κατηγορία</Class> + <GeneralText>Γενικά</GeneralText> + <LineNumber>Γραμμή#</LineNumber> + <Before>Προηγούμενη</Before> + <After>Επόμενη</After> + <Size>Μέγεθος</Size> + <Search>Αναζήτηση</Search> + <DeleteCurrentLine>Διαγραφή επιλεγμένης γραμμής</DeleteCurrentLine> + <Width>Πλάτος</Width> + <Height>Ύψος</Height> + <Collapse>Κατάρρευση</Collapse> + <ShortcutX>Συντόμευση: {0}</ShortcutX> + <ExampleX>Παράδειγμα: {0}</ExampleX> + </General> + <About> + <Title>Σχετικά με το Subtitle Edit</Title> + <AboutText1>Το Subtitle Edit είναι ένα δωρεάν λογισμικό +υπό την άδεια δημόσιας χρήσης GNU. +Μπορείτε να το διανείμετε, να το τροποποιείτε +και να το χρησιμοποιείτε ελεύθερα. + +Ο κώδικας C# είναι διαθέσιμος στο https://github.com/SubtitleEdit/subtitleedit + +Επισκεφτείτε το www.nikse.dk για την τελευταία έκδοση. + +Οι προτάσεις σας είναι ευπρόσδεκτες. + +Email: mailto:nikse.dk@gmail.com</AboutText1> + </About> + <AddToNames> + <Title>Προσθήκη στη λίστα ονομάτων</Title> + <Description>Προσθήκη στη λίστα ονομάτων (διάκριση πεζών-κεφαλαίων)</Description> + </AddToNames> + <AddToOcrReplaceList> + <Title>Προσθήκη στη λίστα αντικατάστασης του OCR</Title> + <Description>Προσθήκη ζεύγους στη λίστα αντικατάστασης του OCR (ευαίσθητο στα πεζά)</Description> + </AddToOcrReplaceList> + <AddToUserDictionary> + <Title>Προσθήκη στο λεξικό του χρήστη</Title> + <Description>Προσθήκη λέξης στο λεξικό του χρήστη (όχι ευαίσθητο στα πεζά)</Description> + </AddToUserDictionary> + <AddWaveform> + <Title>Δημιουργία δεδομένων κυματομορφής</Title> + <SourceVideoFile>Πηγαίο αρχείο βίντεο:</SourceVideoFile> + <GenerateWaveformData>Δημιουργία δεδομένων κυματομορφής</GenerateWaveformData> + <PleaseWait>Αυτό μπορεί να πάρει μερικά λεπτά - παρακαλώ περιμένετε</PleaseWait> + <VlcMediaPlayerNotFoundTitle>Δεν βρέθηκε το πρόγραμμα VLC media player</VlcMediaPlayerNotFoundTitle> + <VlcMediaPlayerNotFound>Χρήση του VLC media player 1.1.χ ή νεότερο για την εξαγωγή δεδομένων ήχου.</VlcMediaPlayerNotFound> + <GoToVlcMediaPlayerHomePage>Μετάβαση στην αρχική σελίδα του VLC media player;</GoToVlcMediaPlayerHomePage> + <GeneratingPeakFile>Δημιουργία αρχείου αιχμής...</GeneratingPeakFile> + <GeneratingSpectrogram>Δημιουργία φασματογραφήματος...</GeneratingSpectrogram> + <ExtractingSeconds>Εξαγωγή ήχου: {0:0.0} δευτερόλεπτα</ExtractingSeconds> + <ExtractingMinutes>Εξαγωγή ήχου: {0}.{1:00} λεπτά</ExtractingMinutes> + <WaveFileNotFound>Αδυναμία εύρεσης αρχείου κυματομορφής! +Αυτή η λειτουργεία απαιτεί VLC media player 1.1.x ή νεότερο ({ο}-bit). +Γραμμή εντολών: {1} {2}</WaveFileNotFound> + <WaveFileMalformed>Το {0} δεν εξήγαγε δεδομένα ήχου στο αρχείο κυματομορφής +Γραμμή εντολών: {1} {2} +Σημείωση: Ελέγξτε τον ελεύθερο χώρο δίσκου.</WaveFileMalformed> + <LowDiskSpace>Μικρός χώρος δίσκου!</LowDiskSpace> + <FreeDiskSpace>{0} ελεύθερου χώρου</FreeDiskSpace> + <NoAudioTracksFoundGenerateEmptyWaveform>Αδυναμία εύρεσης κομματιών ήχου! Δημιουργία κενής κυματομορφής;</NoAudioTracksFoundGenerateEmptyWaveform> + </AddWaveform> + <AddWaveformBatch> + <Title>Μαζική δημιουργία δεδομένων κυματομορφής</Title> + <ExtractingAudio>Εξαγωγή ήχου...</ExtractingAudio> + <Calculating>Υπολογισμός...</Calculating> + <Done>Έτοιμο</Done> + <Error>Σφάλμα</Error> + </AddWaveformBatch> + <AdjustDisplayDuration> + <Title>Προσαρμογή διαρκειών</Title> + <AdjustVia>Προσαρμογή μέσω</AdjustVia> + <Seconds>Δευτερολέπτων</Seconds> + <Percent>Ποσοστού</Percent> + <Recalculate>Επαναϋπολογισμός</Recalculate> + <AddSeconds>Προσθήκη δευτ.</AddSeconds> + <SetAsPercent>Ορισμός ως ποσοστό διάρκειας</SetAsPercent> + <Note>Σημείωση: Ο χρόνος εμφάνισης δεν θα επικαλύπτει την ώρα έναρξης του επόμενου κειμένου</Note> + <Fixed>Διορθωμένα</Fixed> + <Milliseconds>Χιλ. δευτερολέπτου</Milliseconds> + <ExtendOnly>Μόνο επέκταση</ExtendOnly> + </AdjustDisplayDuration> + <ApplyDurationLimits> + <Title>Εφαρμογή ορίων διάρκειας</Title> + <FixesAvailable>Διαθέσιμες διορθώσεις: {0}</FixesAvailable> + <UnableToFix>Αδυναμία διόρθωσης: {0}</UnableToFix> + </ApplyDurationLimits> + <AudioToText> + <Title>Ήχος σε κείμενο</Title> + <ExtractingAudioUsingX>Εξαγωγή ήχου χρησιμοποιώντας {0}...</ExtractingAudioUsingX> + <ExtractingTextUsingX>Εξαγωγή κειμένου από ήχο χρησιμοποιώντας {0}...</ExtractingTextUsingX> + <ProgessViaXy>Εξαγωγή κειμένου μέσω {0} πρόοδος: {1}%</ProgessViaXy> + <ShowLess>Λιγότερα ▲</ShowLess> + <ShowMore>Περισσότερα ▼</ShowMore> + </AudioToText> + <AutoBreakUnbreakLines> + <TitleAutoBreak>Αυτόματη ισορροπία γραμμών</TitleAutoBreak> + <TitleUnbreak>Αφαίρεση διασπάσεων από τις γραμμές</TitleUnbreak> + <LinesFoundX>Εύρεση γραμμών: {0}</LinesFoundX> + <OnlyBreakLinesLongerThan>Διάσπαση γραμμών μεγαλύτερες από</OnlyBreakLinesLongerThan> + <OnlyUnbreakLinesLongerThan>Συνένωση γραμμών μεγαλύτερες από</OnlyUnbreakLinesLongerThan> + </AutoBreakUnbreakLines> + <BatchConvert> + <Title>Μαζική μετατροπή</Title> + <Input>Εισαγωγή</Input> + <InputDescription>Εισαγωγή αρχείων (περιήγηση ή σύρσιμο)</InputDescription> + <Status>Κατάσταση</Status> + <Output>Εξαγωγή</Output> + <SaveInSourceFolder>Αποθήκευση στον αρχικό φάκελο</SaveInSourceFolder> + <SaveInOutputFolder>Αποθήκευση στον φάκελο εξαγωγής</SaveInOutputFolder> + <OverwriteFiles>Αντικατάσταση αρχείων</OverwriteFiles> + <Style>Στυλ...</Style> + <UseStyleFromSource>Χρήση αρχικού στυλ</UseStyleFromSource> + <ConvertOptions>Επιλογές μετατροπής</ConvertOptions> + <RemoveFormatting>Αφαίρεση ετικετών μορφοποίησης</RemoveFormatting> + <RemoveStyleActor>Αφαίρεση στυλ/ηθοποιού</RemoveStyleActor> + <RemoveTextForHI>Αφαίρεση κειμένου για κωφούς</RemoveTextForHI> + <OverwriteOriginalFiles>Αντικατάσταση αρχικών αρχείων (νέα επέκταση, για αλλαγμένη μορφή)</OverwriteOriginalFiles> + <RedoCasing>Επανάληψη αρχικού γράμματος</RedoCasing> + <Convert>Μετατροπή</Convert> + <NothingToConvert>Τίποτα για μετατροπή!</NothingToConvert> + <PleaseChooseOutputFolder>Παρακαλώ, επιλέξτε τον φάκελο εξαγωγής</PleaseChooseOutputFolder> + <NotConverted>Αποτυχία</NotConverted> + <Converted>Μετατράπηκαν</Converted> + <Settings>Ρυθμίσεις</Settings> + <FixRtl>Διόρθωση RTL</FixRtl> + <FixRtlAddUnicode>Διόρθωση RTL μέσω ετικετών Unicode</FixRtlAddUnicode> + <FixRtlRemoveUnicode>Αφαίρεση ετικετών Unicode RTL</FixRtlRemoveUnicode> + <FixRtlReverseStartEnd>Αντιστροφή αρχής/τέλους RTL</FixRtlReverseStartEnd> + <SplitLongLines>Διαχωρισμός μεγάλων γραμμών</SplitLongLines> + <AutoBalance>Αυτόματη ισορροπία γραμμών</AutoBalance> + <ScanFolder>Σάρωση φακέλου...</ScanFolder> + <Recursive>Συμπερίληψη υποφακέλων</Recursive> + <BridgeGaps>Ένωση κενών</BridgeGaps> + <PlainText>Καθαρό κείμενο</PlainText> + <Ocr>OCR...</Ocr> + <Filter>Φίλτρο</Filter> + <FilterSkipped>Παραλείφτηκαν μέσω φίλτρου</FilterSkipped> + <FilterSrtNoUtf8BOM>Αρχεία SubRip (.srt) χωρίς UTF-8 BOM</FilterSrtNoUtf8BOM> + <FilterMoreThanTwoLines>Περισσότερες από δύο γραμμές</FilterMoreThanTwoLines> + <FilterContains>Το κείμενο περιέχει...</FilterContains> + <FilterFileNameContains>Το όνομα αρχείου περιέχει...</FilterFileNameContains> + <MkvLanguageCodeContains>Ο κωδικός γλώσσας Matroska (.mkv) περιέχει...</MkvLanguageCodeContains> + <FixCommonErrorsErrorX>Επιδιόρθωση σφαλμάτων: {0}</FixCommonErrorsErrorX> + <MultipleReplaceErrorX>Πολλαπλή αντικατάσταση: {0}</MultipleReplaceErrorX> + <AutoBalanceErrorX>Αυτόματη ισορρόπηση: {0}</AutoBalanceErrorX> + <OffsetTimeCodes>Αντιστάθμιση κωδικών χρόνου</OffsetTimeCodes> + <TransportStreamSettings>Μεταφορά ρυθμίσεων ροής</TransportStreamSettings> + <TransportStreamOverrideXPosition>Παράκαμψη αρχικής θέσης Χ</TransportStreamOverrideXPosition> + <TransportStreamOverrideYPosition>Παράκαμψη αρχικής θέσης Υ</TransportStreamOverrideYPosition> + <TransportStreamOverrideVideoSize>Παράκαμψη αρχικού μεγέθους βίντεο</TransportStreamOverrideVideoSize> + <TransportStreamFileNameEnding>Κατάληξη ονόματος αρχείου</TransportStreamFileNameEnding> + <TransportStreamSettingsButton>Ρυθμίσεις TS...</TransportStreamSettingsButton> + <RemoveLineBreaks>Αφαίρεση διάσπασης γραμμών</RemoveLineBreaks> + <DeleteLines>Διαγραφή γραμμών</DeleteLines> + <TryToUseSourceEncoding>Προσπάθεια χρήσης αρχικής κωδικοποίησης</TryToUseSourceEncoding> + <DeleteFirstLines>Διαγραφή πρώτων γραμμών</DeleteFirstLines> + <DeleteLastLines>Διαγραφή τελευταίων γραμμών</DeleteLastLines> + <DeleteContaining>Διαγραφή γραμμών που περιέχουν</DeleteContaining> + <MkvLanguageInOutputFileName>"Γλώσσα" στην εξαγωγή ονόματος αρχείου</MkvLanguageInOutputFileName> + <MkvLanguageInOutputFileNameX>Matroska (.mkv) "Γλώσσα" στην εξαγωγή ονόματος αρχείου: {0}</MkvLanguageInOutputFileNameX> + <MkvLanguageStyleTwoLetter>Κώδικες γλωσσών δύο γραμμάτων</MkvLanguageStyleTwoLetter> + <MkvLanguageStyleThreeLetter>Κώδικες γλωσσών τριών γραμμάτων</MkvLanguageStyleThreeLetter> + <MkvLanguageStyleEmpty>Χωρίς κώδικα γλώσσας</MkvLanguageStyleEmpty> + </BatchConvert> + <Beamer> + <Title>Βιντεοπροβολέας</Title> + </Beamer> + <Bookmarks> + <EditBookmark>Επεξεργασία σημείωσης</EditBookmark> + <AddBookmark>Προσθήκη σημείωσης</AddBookmark> + <GoToBookmark>Μετάβαση σε σημείωση</GoToBookmark> + </Bookmarks> + <ChangeCasing> + <Title>Αλλαγή πεζών-κεφαλαίων</Title> + <ChangeCasingTo>Αλλαγή πεζών-κεφαλαίων σε</ChangeCasingTo> + <NormalCasing>Κανονική. Οι προτάσεις ξεκινούν με κεφαλαίο γράμμα.</NormalCasing> + <FixNamesCasing>Διόρθωση ονομάτων (μέσω Dictionaries\NamesEtc.xml)</FixNamesCasing> + <FixOnlyNamesCasing>Διόρθωση μόνο ονομάτων (μέσω Dictionaries\NamesEtc.xml)</FixOnlyNamesCasing> + <OnlyChangeAllUppercaseLines>Αλλαγή μόνο των γραμμών με κεφαλαία.</OnlyChangeAllUppercaseLines> + <AllUppercase>Όλα κεφαλαία</AllUppercase> + <AllLowercase>Όλα πεζά</AllLowercase> + </ChangeCasing> + <ChangeCasingNames> + <Title>Αλλαγή πεζών-κεφαλαίων - Ονόματα</Title> + <NamesFoundInSubtitleX>Εύρεση ονομάτων στον υπότιτλο: {0}</NamesFoundInSubtitleX> + <Enabled>Ενεργοποιημένο</Enabled> + <Name>Όνομα</Name> + <LinesFoundX>Εύρεση γραμμών: {0}</LinesFoundX> + </ChangeCasingNames> + <ChangeFrameRate> + <Title>Αλλαγή ρυθμού καρέ</Title> + <ConvertFrameRateOfSubtitle>Μετατροπή ρυθμού καρέ του υπότιτλου</ConvertFrameRateOfSubtitle> + <FromFrameRate>Από ρυθμό καρέ</FromFrameRate> + <ToFrameRate>Σε ρυθμό καρέ</ToFrameRate> + <FrameRateNotCorrect>Λανθασμένος ρυθμός καρέ</FrameRateNotCorrect> + <FrameRateNotChanged>Ο Ρυθμός καρέ είναι ίδιος - τίποτα για μετατροπή</FrameRateNotChanged> + </ChangeFrameRate> + <ChangeSpeedInPercent> + <Title>Ρύθμιση ταχύτητας σε ποσοστό</Title> + <TitleShort>Ρύθμιση ταχύτητας</TitleShort> + <Info>Αλλαγή ταχύτητας των υποτίτλων σε ποσοστό</Info> + <Custom>Προσαρμοσμένη</Custom> + <ToDropFrame>Ρήξη καρέ</ToDropFrame> + <FromDropFrame>Από ρήξη καρέ</FromDropFrame> + </ChangeSpeedInPercent> + <CheckForUpdates> + <Title>Έλεγχος ενημερώσεων</Title> + <CheckingForUpdates>Έλεγχος για ενημερώσεις...</CheckingForUpdates> + <CheckingForUpdatesFailedX>Αποτυχία ελέγχου ενημέρωσης: {0}</CheckingForUpdatesFailedX> + <CheckingForUpdatesNoneAvailable>Χρήση της τελευταία έκδοσης του Subtitle Edit</CheckingForUpdatesNoneAvailable> + <CheckingForUpdatesNewVersion>Νέα διαθέσιμη έκδοση!</CheckingForUpdatesNewVersion> + <InstallUpdate>Μετάβαση στην ιστοσελίδα λήψης</InstallUpdate> + <NoUpdates>Ακύρωση ενημέρωσης</NoUpdates> + </CheckForUpdates> + <ChooseAudioTrack> + <Title>Επιλογή κομματιού ήχου</Title> + </ChooseAudioTrack> + <ChooseEncoding> + <Title>Επιλογή κωδικοποίησης</Title> + <CodePage>Σελίδα κώδικα</CodePage> + <DisplayName>Εμφάνιση ονόματος</DisplayName> + <PleaseSelectAnEncoding>Παρακαλώ, επιλέξτε μια κωδικοποίηση</PleaseSelectAnEncoding> + </ChooseEncoding> + <ChooseLanguage> + <Title>Επιλογή γλώσσας</Title> + <Language>Γλώσσα</Language> + </ChooseLanguage> + <ColorChooser> + <Title>Επιλογή χρώματος</Title> + <Red>Κόκκινο</Red> + <Green>Πράσινο</Green> + <Blue>Μπλε</Blue> + <Alpha>Άλφα</Alpha> + </ColorChooser> + <ColumnPaste> + <Title>Επικόλληση στηλών</Title> + <ChooseColumn>Επιλογή στηλών</ChooseColumn> + <OverwriteShiftCellsDown>Αντικατάσταση/Μετατόπιση κελιών κάτω</OverwriteShiftCellsDown> + <Overwrite>Αντικατάσταση</Overwrite> + <ShiftCellsDown>Μετατόπιση κελιών κάτω</ShiftCellsDown> + <TimeCodesOnly>Μόνο την κωδικοποίηση χρόνων</TimeCodesOnly> + <TextOnly>Μόνο το κείμενο</TextOnly> + <OriginalTextOnly>Μόνο το αρχικό κείμενο</OriginalTextOnly> + </ColumnPaste> + <CompareSubtitles> + <Title>Σύγκριση υπότιτλων</Title> + <PreviousDifference>&amp;Προηγούμενη διαφορά</PreviousDifference> + <NextDifference>&amp;Επόμενη διαφορά</NextDifference> + <SubtitlesNotAlike>Οι υπότιτλοι δεν έχουν ομοιότητες</SubtitlesNotAlike> + <XNumberOfDifference>Σύνολο διαφορών: {0}</XNumberOfDifference> + <XNumberOfDifferenceAndPercentChanged>Αριθμός διαφορών: {0} ({1:0.##}% αλλαγή των λέξεων)</XNumberOfDifferenceAndPercentChanged> + <XNumberOfDifferenceAndPercentLettersChanged>Αριθμός διαφορών: {0} ({1:0.##}% αλλαγή των γραμμάτων)</XNumberOfDifferenceAndPercentLettersChanged> + <ShowOnlyDifferences>Εμφάνιση μόνο διαφορών</ShowOnlyDifferences> + <IgnoreLineBreaks>Αγνόηση διάσπασης γραμμών</IgnoreLineBreaks> + <IgnoreFormatting>Αγνόηση μορφοποίησης</IgnoreFormatting> + <OnlyLookForDifferencesInText>Αναζήτηση μόνο διαφορών στο κείμενο</OnlyLookForDifferencesInText> + <CannotCompareWithImageBasedSubtitles>Δεν γίνεται σύγκριση με υπότιτλους από εικόνα</CannotCompareWithImageBasedSubtitles> + </CompareSubtitles> + <DCinemaProperties> + <Title>Ιδιότητες D-Cinema (interop)</Title> + <TitleSmpte>Ιδιότητες D-Cinema (SMPTE)</TitleSmpte> + <SubtitleId>Ταυτότητα υποτίτλου</SubtitleId> + <GenerateId>Δημιουργία ταυτότητας</GenerateId> + <MovieTitle>Τίτλος ταινίας</MovieTitle> + <ReelNumber>Αριθμός μπομπίνας</ReelNumber> + <Language>Γλώσσα</Language> + <IssueDate>Ημερομηνία έκδοσης</IssueDate> + <EditRate>Επεξεργασία ρυθμού</EditRate> + <TimeCodeRate>Ρυθμός κώδικα χρόνου</TimeCodeRate> + <StartTime>Έναρξη</StartTime> + <Font>Γραμματοσειρά</Font> + <FontId>Ταυτότητα</FontId> + <FontUri>URI</FontUri> + <FontColor>Χρώμα</FontColor> + <FontEffect>Εφέ</FontEffect> + <FontEffectColor>Χρώμα εφέ</FontEffectColor> + <FontSize>Μέγεθος</FontSize> + <TopBottomMargin>Περιθώριο πάνω/κάτω</TopBottomMargin> + <FadeUpTime>Χρόνος εμφάνισης εφέ</FadeUpTime> + <FadeDownTime>Χρόνος εξαφάνισης εφέ</FadeDownTime> + <ZPosition>Κάθετη θέση</ZPosition> + <ZPositionHelp>Θετικοί αριθμοί μετακινούν το κείμενο μακριά, αρνητικοί αριθμοί μετακινούν το κείμενο κοντά. +Εάν η κάθετη θέση είναι μηδέν, τότε είναι 2D.</ZPositionHelp> + <ChooseColor>Επιλογή χρώματος...</ChooseColor> + <Generate>Δημιουργία</Generate> + </DCinemaProperties> + <DurationsBridgeGaps> + <Title>Ένωση μικρών κενών μεταξύ γραμμών</Title> + <GapsBridgedX>Αριθμός ενωμένων μικρών κενών: {0}</GapsBridgedX> + <GapToNext>Κενό ως το επόμενο σε δευτερόλεπτα</GapToNext> + <GapToNextFrames>Κενό ως το επόμενο σε καρέ</GapToNextFrames> + <BridgeGapsSmallerThanXPart1>Ένωση κενών μικρότερων από</BridgeGapsSmallerThanXPart1> + <BridgeGapsSmallerThanXPart2>χιλιοστά δευτερολέπτου</BridgeGapsSmallerThanXPart2> + <BridgeGapsSmallerThanXPart1Frames>Ένωση κενών μικρότερων από</BridgeGapsSmallerThanXPart1Frames> + <BridgeGapsSmallerThanXPart2Frames>καρέ</BridgeGapsSmallerThanXPart2Frames> + <MinMillisecondsBetweenLines>Ελάχιστα χιλ. δευτερολέπτου μεταξύ των γραμμών</MinMillisecondsBetweenLines> + <MinFramesBetweenLines>Ελάχιστα καρέ μεταξύ γραμμών</MinFramesBetweenLines> + <ProlongEndTime>Το προηγούμενο κείμενο παίρνει όλα τα κενά χρόνου</ProlongEndTime> + <DivideEven>Το κείμενο χωρίζει τα κενά χρόνου</DivideEven> + </DurationsBridgeGaps> + <DvdSubRip> + <Title>Αντιγραφή υποτίτλων από IFO/VOB (DVD)</Title> + <DvdGroupTitle>Αρχεία/Πληροφορίες DVD</DvdGroupTitle> + <IfoFile>Αρχείο IFO</IfoFile> + <IfoFiles>Αρχεία IFO</IfoFiles> + <VobFiles>Αρχεία VOB</VobFiles> + <Add>Προσθήκη</Add> + <Remove>Αφαίρεση</Remove> + <Clear>Καθαρισμός</Clear> + <MoveUp>Μετακίνηση επάνω</MoveUp> + <MoveDown>Μετακίνηση κάτω</MoveDown> + <Languages>Γλώσσες</Languages> + <PalNtsc>PAL/NTSC</PalNtsc> + <Pal>PAL (25 fps)</Pal> + <Ntsc>NTSC (29.9 fps)</Ntsc> + <StartRipping>Εκκίνηση αντιγραφής</StartRipping> + <Abort>Ματαίωση</Abort> + <AbortedByUser>Ματαιώθηκε από τον χρήστη</AbortedByUser> + <ReadingSubtitleData>Ανάγνωση δεδομένων υποτίτλου...</ReadingSubtitleData> + <RippingVobFileXofYZ>Αντιγραφή αρχείων vob {1} από {2}: {0}</RippingVobFileXofYZ> + <WrongIfoType>Ο τύπος IFO είναι '{0}' και όχι 'DVDVIDEO-VTS'.{1}Προσπαθείστε με ένα άλλο αρχείο εκτός του {2}</WrongIfoType> + </DvdSubRip> + <DvdSubRipChooseLanguage> + <Title>Επιλογή γλώσσας</Title> + <ChooseLanguageStreamId>Επιλογή γλώσσας (id-ροής)</ChooseLanguageStreamId> + <UnknownLanguage>Άγνωστη γλώσσα</UnknownLanguage> + <SubtitleImageXofYAndWidthXHeight>Εικόνα υπότιτλου {0}/{1} - {2}x{3}</SubtitleImageXofYAndWidthXHeight> + <SubtitleImage>Εικόνα υπότιτλου</SubtitleImage> + </DvdSubRipChooseLanguage> + <EbuSaveOptions> + <Title>Επιλογές αποθήκευσης τύπου EBU</Title> + <GeneralSubtitleInformation>Γενικές πληροφορίες υπότιτλου</GeneralSubtitleInformation> + <CodePageNumber>Αριθμός σελίδας κώδικα</CodePageNumber> + <DiskFormatCode>Κωδικός μορφής δίσκου</DiskFormatCode> + <DisplayStandardCode>Προβολή τυπικού κώδικα</DisplayStandardCode> + <ColorRequiresTeletext>Τα χρώματα απαιτούν τηλεκείμενο!</ColorRequiresTeletext> + <AlignmentRequiresTeletext>Η στοίχιση απαιτεί τηλεκείμενο!</AlignmentRequiresTeletext> + <TeletextCharsShouldBe38>Οι μέγιστοι χαρακτήρες τηλεκειμένου ανά σειρά θα πρέπει να είναι 38!</TeletextCharsShouldBe38> + <CharacterCodeTable>Πίνακας χαρακτήρων</CharacterCodeTable> + <LanguageCode>Κωδικός γλώσσας</LanguageCode> + <OriginalProgramTitle>Πρωτότυπος τίτλος προγράμματος</OriginalProgramTitle> + <OriginalEpisodeTitle>Πρωτότυπος τίτλος επεισόδιου</OriginalEpisodeTitle> + <TranslatedProgramTitle>Μεταφρασμένος τίτλος προγράμματος</TranslatedProgramTitle> + <TranslatedEpisodeTitle>Μεταφρασμένος τίτλος επεισοδίου</TranslatedEpisodeTitle> + <TranslatorsName>Όνομα του μεταφραστή</TranslatorsName> + <SubtitleListReferenceCode>Κωδικός αναφοράς της λίστας υπότιτλων</SubtitleListReferenceCode> + <CountryOfOrigin>Χώρα καταγωγής</CountryOfOrigin> + <TimeCodeStatus>Κατάσταση χρόνου κώδικα</TimeCodeStatus> + <TimeCodeStartOfProgramme>Χρόνος κώδικα: Έναρξη προγράμματος</TimeCodeStartOfProgramme> + <RevisionNumber>Αριθμός αναθεώρησης</RevisionNumber> + <MaxNoOfDisplayableChars>Μέγιστος αριθμός χαρακτήρων ανά σειρά</MaxNoOfDisplayableChars> + <MaxNumberOfDisplayableRows>Μέγιστος αριθμός γραμμών</MaxNumberOfDisplayableRows> + <DiskSequenceNumber>Αύξων αριθμός δίσκου</DiskSequenceNumber> + <TotalNumberOfDisks>Συνολικός αριθμός δίσκων</TotalNumberOfDisks> + <Import>Εισαγωγή...</Import> + <TextAndTimingInformation>Πληροφορίες κειμένου και χρονισμού</TextAndTimingInformation> + <JustificationCode>Κωδικός αιτιολόγησης</JustificationCode> + <VerticalPosition>Κάθετη θέση</VerticalPosition> + <MarginTop>Άνω περιθώριο (για άνω στοιχισμένους υπότιτλους)</MarginTop> + <MarginBottom>Κάτω περιθώριο (για κάτω στοιχισμένους υπότιτλους)</MarginBottom> + <NewLineRows>Αριθμός προσθήκης σειρών μετά από νέα σειρά</NewLineRows> + <Teletext>Τηλεκείμενο</Teletext> + <UseBox>Χρήση πλαισίου για το κείμενο</UseBox> + <DoubleHeight>Χρήση διπλού ύψους για το κείμενο</DoubleHeight> + <Errors>Λάθη</Errors> + <ErrorsX>Λάθη: {0}</ErrorsX> + <MaxLengthError>Η Γραμμή {0} υπερβαίνει το μέγιστο μήκος ({1}) κατά {2}: {3}</MaxLengthError> + <TextUnchangedPresentation>Αμετάβλητη παρουσίαση</TextUnchangedPresentation> + <TextLeftJustifiedText>Αριστερά στοιχισμένο κείμενο</TextLeftJustifiedText> + <TextCenteredText>Κεντραρισμένο κείμενο</TextCenteredText> + <TextRightJustifiedText>Δεξιά στοιχισμένο κείμενο</TextRightJustifiedText> + <UseBoxForOneNewLine>Επιλογή 'Χρήση πλαισίου κειμένου' μόνο για μία νέα γραμμή</UseBoxForOneNewLine> + </EbuSaveOptions> + <EffectKaraoke> + <Title>Εφέ καραόκε</Title> + <ChooseColor>Επιλογή χρώματος:</ChooseColor> + <TotalMilliseconds>Συνολικά χιλ. δευτερολέπτου:</TotalMilliseconds> + <EndDelayInMilliseconds>Καθυστέρηση λήξης σε χιλ. δευτερολέπτου:</EndDelayInMilliseconds> + </EffectKaraoke> + <EffectTypewriter> + <Title>Εφέ γραφομηχανής</Title> + <TotalMilliseconds>Συνολικά χιλ. δευτερολέπτου:</TotalMilliseconds> + <EndDelayInMilliseconds>Καθυστέρηση λήξης σε χιλ. δευτερολέπτου:</EndDelayInMilliseconds> + </EffectTypewriter> + <ExportCustomText> + <Title>Εξαγωγή προσαρμοσμένης μορφής κειμένου</Title> + <Formats>Μορφές</Formats> + <New>Νέο</New> + <Edit>Επεξεργασία</Edit> + <Delete>Διαγραφή</Delete> + <SaveAs>Α&amp;ποθήκευση ως...</SaveAs> + <SaveSubtitleAs>Αποθήκευση υπότιτλου ως...</SaveSubtitleAs> + <SubtitleExportedInCustomFormatToX>Οι υπότιτλοι εξάγωνται σε προσαρμοσμένη μορφή στο: {0}</SubtitleExportedInCustomFormatToX> + </ExportCustomText> + <ExportCustomTextFormat> + <Title>Πρότυπο προσαρμοσμένης μορφής κειμένου</Title> + <Template>Πρότυπο</Template> + <Header>Επικεφαλίδα</Header> + <TextLine>Γραμμή κειμένου (παράγραφος)</TextLine> + <TimeCode>Κωδικός χρόνου</TimeCode> + <NewLine>Νέα γραμμή</NewLine> + <Footer>Υποσέλιδο</Footer> + <DoNotModify>[Χωρίς επεξεργασία]</DoNotModify> + </ExportCustomTextFormat> + <ExportFcpXmlAdvanced> + <Title>Εξαγωγή Final Cut Pro XML advanced</Title> + <FontName>Όνομα γραμματοσειράς</FontName> + <FontSize>Μέγεθος γραμματοσειράς</FontSize> + <FontFace>Όψη γραμματοσειράς</FontFace> + <FontFaceRegular>Κλασική</FontFaceRegular> + <Alignment>Ευθυγράμμιση</Alignment> + <Baseline>Κανονική</Baseline> + </ExportFcpXmlAdvanced> + <ExportPngXml> + <Title>Εξαγωγή XML/PNG</Title> + <ImageSettings>Ρυθμίσεις εικόνας</ImageSettings> + <FontFamily>Οικογένεια γραμματοσειράς</FontFamily> + <FontSize>Μέγεθος γραμματοσειράς</FontSize> + <FontColor>Χρώμα γραμματοσειράς</FontColor> + <BorderColor>Χρώμα περιγράμματος</BorderColor> + <BorderWidth>Πλάτος περιγράμματος</BorderWidth> + <BorderStyle>Στυλ περιγράμματος</BorderStyle> + <BorderStyleOneBox>Ένα πλαίσιο</BorderStyleOneBox> + <BorderStyleBoxForEachLine>Πλαίσιο για κάθε γραμμή</BorderStyleBoxForEachLine> + <BorderStyleNormalWidthX>Κανονικό, πάχος={0}</BorderStyleNormalWidthX> + <ShadowColor>Χρώμα σκιάς</ShadowColor> + <ShadowWidth>Πάχος σκιάς</ShadowWidth> + <Transparency>Αρχική</Transparency> + <ImageFormat>Μορφή εικόνας</ImageFormat> + <FullFrameImage>Εικόνα πλήρης απεικόνισης</FullFrameImage> + <SimpleRendering>Απλή απεικόνιση</SimpleRendering> + <AntiAliasingWithTransparency>Διαφανής εξομάλυνση</AntiAliasingWithTransparency> + <Text3D>3D</Text3D> + <SideBySide3D>Κέντρο - Δεξιά - Αριστερά</SideBySide3D> + <HalfTopBottom3D>Κέντρο - Πάνω/Κάτω</HalfTopBottom3D> + <Depth>Βάθος</Depth> + <ExportAllLines>Εξαγωγή όλων των γραμμών...</ExportAllLines> + <XImagesSavedInY>{0} εικόνες αποθηκεύτηκαν στον φάκελο {1}</XImagesSavedInY> + <VideoResolution>Ανάλυση βίντεο</VideoResolution> + <Align>Στοίχιση</Align> + <Left>Αριστερά</Left> + <Right>Δεξιά</Right> + <Center>Κέντρο</Center> + <CenterLeftJustify>Κέντρο, στοίχιση αριστερά</CenterLeftJustify> + <CenterLeftJustifyDialogs>Κέντρο, αριστερή στοίχιση διαλόγου</CenterLeftJustifyDialogs> + <CenterTopJustify>Κέντρο, άνω στοίχιση</CenterTopJustify> + <CenterRightJustify>Κέντρο, δεξιά στοίχιση</CenterRightJustify> + <BottomMargin>Κάτω περιθώριο</BottomMargin> + <LeftRightMargin>Αριστερό/δεξί περιθώριο</LeftRightMargin> + <SaveBluRraySupAs>Επιλογή ονόματος αρχείου Blu-ray sup</SaveBluRraySupAs> + <SaveVobSubAs>Επιλογή ονόματος αρχείου VobSub</SaveVobSubAs> + <SaveFabImageScriptAs>Επιλογή ονόματος αρχείου Blu-ray sup</SaveFabImageScriptAs> + <SaveDvdStudioProStlAs>Επιλογή ονόματος αρχείου DVD Studio Pro STL</SaveDvdStudioProStlAs> + <SaveDigitalCinemaInteropAs>Επιλογή ονόματος αρχείου Digital Cinema Interop</SaveDigitalCinemaInteropAs> + <SaveDigitalCinemaSmpte2014>Επιλογή ονόματος αρχείου Digital SMPTE 2014</SaveDigitalCinemaSmpte2014> + <SavePremiereEdlAs>Επιλογή ονόματος αρχείου Premiere EDL</SavePremiereEdlAs> + <SaveFcpAs>Επιλογή ονόματος αρχείου Final Cut Pro xml</SaveFcpAs> + <SaveDostAs>Επιλογή ονόματος αρχείου DoStudio dost</SaveDostAs> + <SomeLinesWereTooLongX>Μερικές πολύ μεγάλες γραμμές:{0}</SomeLinesWereTooLongX> + <LineHeight>Ύψος γραμμής</LineHeight> + <BoxSingleLine>Πλαίσιο - ενιαία γραμμή</BoxSingleLine> + <BoxMultiLine>Πλαίσιο - πολλαπλή γραμμή</BoxMultiLine> + <Forced>Επιβολή</Forced> + <ChooseBackgroundColor>Επιλογή χρώματος φόντου</ChooseBackgroundColor> + <SaveImageAs>Αποθήκευση εικόνας ως...</SaveImageAs> + <FcpUseFullPathUrl>Χρήση πλήρης διεύθυνσης url εικόνας για FCP xml</FcpUseFullPathUrl> + </ExportPngXml> + <ExportText> + <Title>Εξαγωγή κειμένου</Title> + <Preview>Προεπισκόπηση</Preview> + <ExportOptions>Εξαγωγή επιλογών</ExportOptions> + <FormatText>Μορφοποίηση κειμένου</FormatText> + <None>Κανένα</None> + <MergeAllLines>Συγχώνευση όλων των γραμμών</MergeAllLines> + <UnbreakLines>Συνένωση γραμμών</UnbreakLines> + <RemoveStyling>Αφαίρεση ύφους</RemoveStyling> + <ShowLineNumbers>Προβολή αριθμών γραμμής</ShowLineNumbers> + <AddNewLineAfterLineNumber>Προσθήκη νέας γραμμής μετά από τον αριθμό γραμμής</AddNewLineAfterLineNumber> + <ShowTimeCode>Εμφάνιση κωδικοποίησης χρόνου</ShowTimeCode> + <AddNewLineAfterTimeCode>Προσθήκη νέας γραμμής μετά την κωδικοποίηση χρόνου</AddNewLineAfterTimeCode> + <AddNewLineAfterTexts>Προσθήκη νέας γραμμής μετά το κείμενο</AddNewLineAfterTexts> + <AddNewLineBetweenSubtitles>Προσθήκη νέας γραμμής μεταξύ των υποτίτλων</AddNewLineBetweenSubtitles> + <TimeCodeFormat>Μορφή κώδικοποίησης χρόνου</TimeCodeFormat> + <Srt>.srt</Srt> + <Milliseconds>Χιλιοστά δευτερολέπτου</Milliseconds> + <HHMMSSFF>ΩΩ:ΛΛ:ΔΔ:ΚΚ</HHMMSSFF> + <TimeCodeSeparator>Διαχωρισμός κωδικοποίησης χρόνου</TimeCodeSeparator> + </ExportText> + <ExtractDateTimeInfo> + <Title>Δημιουργία χρόνου ως κείμενο</Title> + <OpenVideoFile>Επιλογή αρχείου βίντεο από όπου θα εξαχθούν οι πληροφορίες ημέρας/χρόνου</OpenVideoFile> + <StartFrom>Έναρξη από</StartFrom> + <DateTimeFormat>Μορφή ημέρας/χρόνου</DateTimeFormat> + <Example>Παράδειγμα</Example> + <GenerateSubtitle>&amp;Δημιουργία υποτίτλων</GenerateSubtitle> + </ExtractDateTimeInfo> + <FindDialog> + <Title>Εύρεση</Title> + <Find>Εύρεση</Find> + <Normal>&amp;Κανονική</Normal> + <CaseSensitive>&amp;Διάκριση πεζών-κεφαλαίων</CaseSensitive> + <RegularExpression>Τυπική έκφραση</RegularExpression> + <WholeWord>Ολόκληρη τη λέξη</WholeWord> + <Count>Μέτρηση</Count> + <XNumberOfMatches>{0:#,##0} αντιστοιχίες</XNumberOfMatches> + <OneMatch>Μία αντιστοιχία</OneMatch> + </FindDialog> + <FindSubtitleLine> + <Title>Εύρεση γραμμής υπότιτλου</Title> + <Find>&amp;Εύρεση</Find> + <FindNext>Εύρεση ε&amp;πόμενου</FindNext> + </FindSubtitleLine> + <FixCommonErrors> + <Title>Επιδιόρθωση σφαλμάτων</Title> + <Step1>Βήμα 1/2 - Επιλογή σφαλμάτων</Step1> + <WhatToFix>Προς διόρθωση</WhatToFix> + <Example>Παράδειγμα</Example> + <SelectAll>Όλα</SelectAll> + <InverseSelection>Αντιστροφή</InverseSelection> + <Back>&lt; &amp;Πίσω</Back> + <Next>&amp;Επόμενο &gt;</Next> + <Step2>Βήμα 2/2 - Επαλήθευση διορθώσεων</Step2> + <Fixes>Επιδιορθώσεις</Fixes> + <Log>Αρχείο καταγραφής</Log> + <Function>Συνάρτηση</Function> + <RemovedEmptyLine>Αφαίρεση κενής γραμμής</RemovedEmptyLine> + <RemovedEmptyLineAtTop>Αφαίρεση κενής γραμμής στην κορυφή</RemovedEmptyLineAtTop> + <RemovedEmptyLineAtBottom>Αφαίρεση κενής γραμμής στο τέλος</RemovedEmptyLineAtBottom> + <RemovedEmptyLineInMiddle>Αφαίρεση κενής γραμμής στο κέντρο</RemovedEmptyLineInMiddle> + <RemovedEmptyLinesUnsedLineBreaks>Αφαίρεση κενών γραμμών/άχρηστες αλλαγές γραμμής</RemovedEmptyLinesUnsedLineBreaks> + <EmptyLinesRemovedX>Αφαιρεμένες κενές γραμμές: {0}</EmptyLinesRemovedX> + <FixOverlappingDisplayTimes>Επιδιόρθωση επικαλυπτόμενων χρόνων εμφάνισης</FixOverlappingDisplayTimes> + <FixShortDisplayTimes>Επιδιόρθωση σύντομων χρόνων εμφάνισης</FixShortDisplayTimes> + <FixLongDisplayTimes>Επιδιόρθωση μεγάλων χρόνων εμφάνισης</FixLongDisplayTimes> + <FixShortGaps>Επιδιόρθωση μικρών κενών</FixShortGaps> + <FixInvalidItalicTags>Επιδιόρθωση λανθασμένων ετικετών πλαγιαστής γραφής</FixInvalidItalicTags> + <RemoveUnneededSpaces>Αφαίρεση περιττών διαστημάτων</RemoveUnneededSpaces> + <RemoveUnneededPeriods>Αφαίρεση περιττών τελειών</RemoveUnneededPeriods> + <FixCommas>Επιδιόρθωση κομμάτων</FixCommas> + <FixMissingSpaces>Επιδιόρθωση διαστημάτων</FixMissingSpaces> + <BreakLongLines>Διάσπαση μεγάλων γραμμών</BreakLongLines> + <RemoveLineBreaks>Αφαίρεση αλλαγών γραμμής σε μικρά κείμενα με μία μόνο πρόταση</RemoveLineBreaks> + <RemoveLineBreaksAll>Αφαίρεση αλλαγών γραμμής σε μικρά κείμενα (εκτός διαλόγου)</RemoveLineBreaksAll> + <FixUppercaseIInsindeLowercaseWords>Επιδιόρθωση κεφαλαίου 'i' σε πεζές λέξεις (σφάλμα OCR)</FixUppercaseIInsindeLowercaseWords> + <FixDoubleApostrophes>Επιδιόρθωση διπλής αποστρόφου ('') σε εισαγωγικό (")</FixDoubleApostrophes> + <AddPeriods>Προσθήκη τελείας</AddPeriods> + <StartWithUppercaseLetterAfterParagraph>Έναρξη με κεφαλαίο γράμμα μετά από παράγραφο</StartWithUppercaseLetterAfterParagraph> + <StartWithUppercaseLetterAfterPeriodInsideParagraph>Έναρξη με κεφαλαίο γράμμα μετά από τελεία</StartWithUppercaseLetterAfterPeriodInsideParagraph> + <StartWithUppercaseLetterAfterColon>Έναρξη με κεφαλαίο γράμμα μετά από σημεία στίξης</StartWithUppercaseLetterAfterColon> + <FixLowercaseIToUppercaseI>Επιδιόρθωση πεζού 'i' σε 'Ι' (Αγγλικά)</FixLowercaseIToUppercaseI> + <FixCommonOcrErrors>Επιδιόρθωση κοινών σφαλμάτων OCR (με χρήση καταλόγου αντικατάστασης OCR)</FixCommonOcrErrors> + <CommonOcrErrorsFixed>Επιδιορθώσεις κοινών σφαλμάτων OCR (χρήση του αρχείου OcrReplaceList): {0}</CommonOcrErrorsFixed> + <RemoveSpaceBetweenNumber>Αφαίρεση διαστήματος μεταξύ αριθμών</RemoveSpaceBetweenNumber> + <FixDialogsOnOneLine>Επιδιόρθωση διαλόγων</FixDialogsOnOneLine> + <NormalizeStrings>Κανονικοποίηση συμβολοσειρών</NormalizeStrings> + <RemoveSpaceBetweenNumbersFixed>Επιδιορθώσεις αφαίρεσης διαστήματος μεταξύ αριθμών: {0}</RemoveSpaceBetweenNumbersFixed> + <FixTurkishAnsi>Επιδιόρθωση Τουρκικών ANSI (Ισλανδικών) γραμμάτων σε Unicode</FixTurkishAnsi> + <FixDanishLetterI>Επιδιόρθωση δανικού γράμματος 'i'</FixDanishLetterI> + <FixSpanishInvertedQuestionAndExclamationMarks>Επιδιόρθωση ισπανικών αντεστραμμένων σημείων στίξης</FixSpanishInvertedQuestionAndExclamationMarks> + <AddMissingQuote>Προσθήκη εισαγωγικού (")</AddMissingQuote> + <AddMissingQuotes>Προσθήκη εισαγωγικών (")</AddMissingQuotes> + <RemoveHyphensSingleLine>Αφαίρεση παύλας σε ενιαίες γραμμές</RemoveHyphensSingleLine> + <XHyphensSingleLineRemoved>Αφαίρεση παυλών: {0}</XHyphensSingleLineRemoved> + <FixHyphensInDialogs>Επιδιόρθωση παυλών μέσω στυλ διαλόγου: {0}</FixHyphensInDialogs> + <XHyphensInDialogsFixed>Επιδιόρθωση παυλών: {0}</XHyphensInDialogsFixed> + <AddMissingQuotesExample>"Πώς είσαι; -&gt; "Πώς είσαι;"</AddMissingQuotesExample> + <XMissingQuotesAdded>Προσθήκη εισαγωγικών: {0}</XMissingQuotesAdded> + <Fix3PlusLines>Επιδιόρθωση υποτίτλων με περισσότερες από δύο γραμμές</Fix3PlusLines> + <Fix3PlusLine>Επιδιόρθωση υπότιτλου με περισσότερες από δύο γραμμές</Fix3PlusLine> + <X3PlusLinesFixed>Επιδιόρθωση υποτίτλων με περισσότερες από δύο γραμμές: {0}</X3PlusLinesFixed> + <Analysing>Ανάλυση...</Analysing> + <NothingToFix>Τίποτα για επιδιόρθωση</NothingToFix> + <FixesFoundX>Εύρεση επιδιορθώσεων: {0}</FixesFoundX> + <XFixesApplied>Εφαρμοσμένες επιδιορθώσεις: {0}</XFixesApplied> + <NothingFixableBut>Τίποτα για αυτόματη επιδιόρθωση. Ο υπότιτλος περιέχει σφάλμα(τα) - προβολή αρχείου καταγραφής</NothingFixableBut> + <XFixedBut>Επιδιόρθωση {0} θέματος(ων), αλλά υπάρχουν ακόμη σφάλματα - προβολή αρχείου καταγραφής</XFixedBut> + <XCouldBeFixedBut>Επιδιόρθωση {0} θέματος(ων), αλλά θα υπάρχουν ακόμη σφάλματα - προβολή αρχείου καταγραφής</XCouldBeFixedBut> + <UncheckedFixLowercaseIToUppercaseI>Αποεπιλογή "Επιδιόρθωση μονού πεζού 'i' σε 'Ι' (Αγγλικά)"</UncheckedFixLowercaseIToUppercaseI> + <XIsChangedToUppercase>{0} άλλαγή(ές) σε κεφαλαία</XIsChangedToUppercase> + <FixFirstLetterToUppercaseAfterParagraph>Επιδιόρθωση αρχικού γράμματος σε κεφαλαίο μετά από παράγραφο</FixFirstLetterToUppercaseAfterParagraph> + <MergeShortLine>Συγχώνευση γραμμών</MergeShortLine> + <MergeShortLineAll>Συγχώνευση γραμμών (εκτός διαλόγου)</MergeShortLineAll> + <XLineBreaksAdded>Προσθήκη {0} αλλαγής(ών) γραμμής</XLineBreaksAdded> + <BreakLongLine>Διάσπαση γραμμής</BreakLongLine> + <FixLongDisplayTime>Επιδιόρθωση μεγάλου χρόνου</FixLongDisplayTime> + <FixInvalidItalicTag>Επιδιόρθωση ετικέτας πλαγιαστής γραφής</FixInvalidItalicTag> + <FixShortDisplayTime>Επιδιόρθωση σύντομου χρόνου</FixShortDisplayTime> + <FixOverlappingDisplayTime>Επιδιόρθωση επικαλυπτόμενου χρόνου</FixOverlappingDisplayTime> + <FixShortGap>Επιδιόρθωση μικρών κενών</FixShortGap> + <FixInvalidItalicTagsExample>&lt;i&gt;Δεν με ενδιαφέρει.&lt;i&gt; -&gt; &lt;i&gt;Δεν με ενδιαφέρει.&lt;/i&gt;</FixInvalidItalicTagsExample> + <RemoveUnneededSpacesExample>Εσύ , εκεί. -&gt; Εσύ, εκεί.</RemoveUnneededSpacesExample> + <RemoveUnneededPeriodsExample>Εσύ!. -&gt; Εσύ!</RemoveUnneededPeriodsExample> + <FixMissingSpacesExample>Έι.Εσύ. -&gt; Έι. Εσύ.</FixMissingSpacesExample> + <FixUppercaseIInsindeLowercaseWordsExample>The Earth is fIat. -&gt; The Earth is flat.</FixUppercaseIInsindeLowercaseWordsExample> + <FixLowercaseIToUppercaseIExample>What do i care. -&gt; What do I care.</FixLowercaseIToUppercaseIExample> + <StartTimeLaterThanEndTime>Κείμενο με αριθμό {0}: Έναρξη αργότερα από λήξη: {4}{1} -&gt; {2} {3}</StartTimeLaterThanEndTime> + <UnableToFixStartTimeLaterThanEndTime>Αδυναμία επιδιόρθωσης του κειμένου με αριθμό {0}: Έναρξη αργότερα από λήξη: {1}</UnableToFixStartTimeLaterThanEndTime> + <XFixedToYZ>Επιδιόρθωση {0} σε: {1}{2}</XFixedToYZ> + <UnableToFixTextXY>Αδυναμία επιδιόρθωσης του κειμένου με αριθμό {0}: {1}</UnableToFixTextXY> + <XOverlappingTimestampsFixed>Επιδιόρθωση {0} επικαλυπτόμενου(ων) χρόνου(ων)</XOverlappingTimestampsFixed> + <XDisplayTimesProlonged>Επέκταση {0} χρόνου(ων) εμφάνισης</XDisplayTimesProlonged> + <XInvalidHtmlTagsFixed>Επιδιόρθωση {0} λανθασμένης(ων) ετικέτας(ών) HTML</XInvalidHtmlTagsFixed> + <XDisplayTimesShortned>Σμίκρυνση {0} χρόνου(ων) εμφάνισης</XDisplayTimesShortned> + <XGapsFixed>Επιδιόρθωση {0} μικρού(ών) κενού(ών)</XGapsFixed> + <XLinesUnbreaked>Συνένωση {0} γραμμής(ών)</XLinesUnbreaked> + <UnneededSpace>Αχρείαστο διάστημα</UnneededSpace> + <XUnneededSpacesRemoved>Αφαίρεση {0} αχρείαστου(ων) διαστήματος(ων)</XUnneededSpacesRemoved> + <UnneededPeriod>Αχρείαστη τελεία</UnneededPeriod> + <XUnneededPeriodsRemoved>Αφαίρεση {0} αχρείαστης(ων) τελείας(ών)</XUnneededPeriodsRemoved> + <FixMissingSpace>Επιδιόρθωση διαστήματος</FixMissingSpace> + <XMissingSpacesAdded>Προσθήκη {0} διαστήματος(ων)</XMissingSpacesAdded> + <FixUppercaseIInsideLowercaseWord>Επιδιόρθωση κεφαλαίου 'i' μέσα σε λέξη</FixUppercaseIInsideLowercaseWord> + <XPeriodsAdded>Προσθήκη {0} τελείας(ών)</XPeriodsAdded> + <FixMissingPeriodAtEndOfLine>Προσθήκη τελείας στο τέλος πρότασης</FixMissingPeriodAtEndOfLine> + <XDoubleApostrophesFixed>Επιδιόρθωση {0} διπλών αποστρόφων</XDoubleApostrophesFixed> + <XUppercaseIsFoundInsideLowercaseWords>Εύρεση {0} κεφαλαίου(ων) 'i' μέσα σε λέξη(εις)</XUppercaseIsFoundInsideLowercaseWords> + <RefreshFixes>Ανανέωση</RefreshFixes> + <ApplyFixes>Εφαρμογή</ApplyFixes> + <AutoBreak>&amp;Διάσπαση</AutoBreak> + <Unbreak>&amp;Συνένωση</Unbreak> + <FixDoubleDash>Επιδιόρθωση '--' -&gt; '...'</FixDoubleDash> + <FixDoubleGreaterThan>Αφαίρεση '&gt;&gt;'</FixDoubleGreaterThan> + <FixEllipsesStart>Αφαίρεση αρχικού '...'</FixEllipsesStart> + <FixMissingOpenBracket>Επιδιόρθωση ελλιπής [</FixMissingOpenBracket> + <FixMusicNotation>Αντικατάσταση μουσικού συμβόλου (π.χ. âTª)</FixMusicNotation> + <XFixDoubleDash>Επιδιόρθωση {0} '--'</XFixDoubleDash> + <XFixDoubleGreaterThan>Αφαίρεση {0} &gt;&gt;</XFixDoubleGreaterThan> + <XFixEllipsesStart>Αφαίρεση {0} '...' από αρχή γραμμής</XFixEllipsesStart> + <XFixMissingOpenBracket>Επιδιόρθωση {0} ελλιπούςς(ών) [</XFixMissingOpenBracket> + <XFixMusicNotation>Αντικατάσταση {0} μουσικού(ών) συμβόλου(ων)</XFixMusicNotation> + <FixDoubleDashExample>'Τι-- αα ναι!' -&gt; 'Τι... αα ναι!'</FixDoubleDashExample> + <FixDoubleGreaterThanExample>'&gt;&gt; Ρόμπερτ: Τι τρέχει;' -&gt; 'Ρόμπερτ: Τι τρέχει;'</FixDoubleGreaterThanExample> + <FixEllipsesStartExample>'... και τότε εμείς' -&gt; 'και τότε εμείς'</FixEllipsesStartExample> + <FixMissingOpenBracketExample>'κλανκ] Πρόσεξε!' -&gt; '[κλανκ] Πρόσεξε!'</FixMissingOpenBracketExample> + <FixMusicNotationExample>'âTª sweet dreams are' -&gt; '♫ sweet dreams are'</FixMusicNotationExample> + <NumberOfImportantLogMessages>{0} σημαντικό(ά) μήνυμα(τα) του αρχείου καταγραφής</NumberOfImportantLogMessages> + <FixedOkXY>Επιδιορθωμένα και εντάξει - '{0}': {1}</FixedOkXY> + <FixOcrErrorExample>D0n't -&gt; Don't</FixOcrErrorExample> + <FixSpaceBetweenNumbersExample>1 100 -&gt; 1100</FixSpaceBetweenNumbersExample> + <FixDialogsOneLineExample>Γεια, Τζον. - Γεια, Άιντα. -&gt; Γεια, Τζον.&lt;br/&gt; - Γεια, Άιντα.</FixDialogsOneLineExample> + <SelectDefault>Προεπιλεγμένα</SelectDefault> + <SetDefault>Ορισμός προεπιλεγμένων</SetDefault> + <FixContinuationStyleX>Επιδιόρθωση στυλ συνέχισης: {0}</FixContinuationStyleX> + <XFixContinuationStyle>Επιδιόρθωση {0} στυλ συνέχισης</XFixContinuationStyle> + <FixUnnecessaryLeadingDots>Αφαίρεση αρχικών αποσιωπητικών</FixUnnecessaryLeadingDots> + <XFixUnnecessaryLeadingDots>Αφαίρεση {0} αρχικών αποσιωπητικών</XFixUnnecessaryLeadingDots> + </FixCommonErrors> + <GetDictionaries> + <Title>Χρειάζεστε λεξικά;</Title> + <DescriptionLine1>Ο ορθογραφικός έλεγχος του Subtitle Edit βασίζεται στη μηχανή NHunspell</DescriptionLine1> + <DescriptionLine2>που χρησιμοποιεί τα λεξικά ορθογραφικού ελέγχου του LibreOffice.</DescriptionLine2> + <ChooseLanguageAndClickDownload>Επιλογή γλώσσας και πατήστε λήψη</ChooseLanguageAndClickDownload> + <OpenDictionariesFolder>Άνοιγμα του φακέλου 'Dictionaries'</OpenDictionariesFolder> + <Download>Λήψη</Download> + <XDownloaded>Λήψη και εγκατάσταση {0}</XDownloaded> + </GetDictionaries> + <GetTesseractDictionaries> + <Title>Χρήση λεξικών;</Title> + <DescriptionLine1>Βρείτε λεξικά Tesseract OCR από το διαδίκτυο</DescriptionLine1> + <DownloadFailed>Αποτυχία λήψης!</DownloadFailed> + <GetDictionariesHere>Εύρεση λεξικών εδώ:</GetDictionariesHere> + <ChooseLanguageAndClickDownload>Επιλογή γλώσσας και λήψη</ChooseLanguageAndClickDownload> + <OpenDictionariesFolder>Άνοιγμα φακέλου 'Dictionaries'</OpenDictionariesFolder> + <Download>Λήψη</Download> + <XDownloaded>Λήψη και εγκατάσταση {0}</XDownloaded> + </GetTesseractDictionaries> + <GoogleTranslate> + <Title>Μετάφραση Google</Title> + <From>Από:</From> + <To>Σε:</To> + <Translate>Μετάφραση</Translate> + <PleaseWait>Παρακαλώ περιμένετε... αυτό μπορεί να αργήσει λίγο</PleaseWait> + <PoweredByGoogleTranslate>Τροφοδοτείται από τη Μετάφραση Google</PoweredByGoogleTranslate> + <PoweredByMicrosoftTranslate>Τροφοδοτείται από τη Μετάφραση Microsoft</PoweredByMicrosoftTranslate> + <MsClientSecretNeeded>Συγγνώμη, χρειάζεστε ένα γνωστικό κλειδί εξυπηρέτησης 'μετάφρασης κειμένου' από τη Microsoft για τη χρήση του. +Μετάβαση σε "Επιλογές -&gt; Ρυθμίσεις -&gt; Εργαλεία" για την εισαγωγή κλειδιού.</MsClientSecretNeeded> + <GoogleApiKeyNeeded>Συγγνώμη, χρειάζεστε ένα κλειδί API από τη Google για τη χρήση του. +Μετάβαση σε "Επιλογές -&gt; Ρυθμίσεις -&gt; Εργαλεία" για την εισαγωγή κλειδιού.</GoogleApiKeyNeeded> + <GoogleNoApiKeyWarning>Μετάφραση χωρίς κλειδί API... (αργά και περιορισμένα δεδομένα)</GoogleNoApiKeyWarning> + </GoogleTranslate> + <GoogleOrMicrosoftTranslate> + <Title>Μετάφραση Google vs Bing</Title> + <From>Από:</From> + <To>Έως:</To> + <Translate>Μετάφραση</Translate> + <SourceText>Αρχικό κείμενο</SourceText> + <GoogleTranslate>Μετάφραση Google</GoogleTranslate> + <MicrosoftTranslate>Μετάφραση Bing</MicrosoftTranslate> + </GoogleOrMicrosoftTranslate> + <GoToLine> + <Title>Μετάβαση σε υπότιτλο με αριθμό</Title> + <XIsNotAValidNumber>Το {0} δεν είναι έγκυρος αριθμός</XIsNotAValidNumber> + </GoToLine> + <ImportImages> + <Title>Εισαγωγή εικόνων</Title> + <ImageFiles>Αρχεία εικόνας</ImageFiles> + <Input>Εισαγωγή</Input> + <InputDescription>Επιλογή αρχείων για εισαγωγή (περιήγηση ή σύρσιμο)</InputDescription> + <Remove>Αφαίρεση</Remove> + <RemoveAll>Αφαίρεση όλων</RemoveAll> + </ImportImages> + <ImportSceneChanges> + <Title>Δημιουργία/εισαγωγή αλλαγών σκηνών</Title> + <OpenTextFile>Άνοιγμα αρχείου κειμένου...</OpenTextFile> + <Generate>Δημιουργία αλλαγών σκηνών</Generate> + <Import>Εισαγωγή αλλαγών σκηνών</Import> + <TextFiles>Αρχεία κειμένου</TextFiles> + <TimeCodes>Κώδικες χρόνων</TimeCodes> + <Frames>Καρέ</Frames> + <Seconds>Δευτερόλεπτα</Seconds> + <Milliseconds>Χιλιοστά δευτερολέπτου</Milliseconds> + <GetSceneChangesWithFfmpeg>Δημιουργία αλλαγών σκηνών με FFmpeg</GetSceneChangesWithFfmpeg> + <Sensitivity>Ευαισθησία</Sensitivity> + <SensitivityDescription>Μικρότερη τιμή δίνει περισσότερες αλλαγές σκηνών</SensitivityDescription> + <NoSceneChangesFound>Αδυναμία εύρεσης αλλαγών σκηνών.</NoSceneChangesFound> + </ImportSceneChanges> + <ImportText> + <Title>Εισαγωγή απλού κειμένου</Title> + <OneSubtitleIsOneFile>Πολλαπλά αρχεία - κάθε αρχείο είναι ένας υπότιτλος</OneSubtitleIsOneFile> + <OpenTextFile>Άνοιγμα αρχείου κειμένου...</OpenTextFile> + <OpenTextFiles>Άνοιγμα αρχείων κειμένου...</OpenTextFiles> + <ImportOptions>Επιλογές εισαγωγής</ImportOptions> + <Splitting>Διαχωρισμός</Splitting> + <AutoSplitText>Αυτόματος διαχωρισμός κειμένου</AutoSplitText> + <OneLineIsOneSubtitle>Μία γραμμή είναι ένας υπότιτλος</OneLineIsOneSubtitle> + <TwoLinesAreOneSubtitle>Δύο γραμμές είναι ένας υπότιτλος</TwoLinesAreOneSubtitle> + <LineBreak>Αλλαγή γραμμής</LineBreak> + <SplitAtBlankLines>Διαχωρισμός σε κενές γραμμές</SplitAtBlankLines> + <MergeShortLines>Συγχώνευση σύντομων γραμμών με συνέχιση</MergeShortLines> + <RemoveEmptyLines>Αφαίρεση κενών γραμμών</RemoveEmptyLines> + <RemoveLinesWithoutLetters>Αφαίρεση γραμμών χωρίς γράμματα</RemoveLinesWithoutLetters> + <GenerateTimeCodes>Δημιουργία κωδικών χρόνου</GenerateTimeCodes> + <TakeTimeFromFileName>Μεταφορά χρόνου από όνομα αρχείου</TakeTimeFromFileName> + <GapBetweenSubtitles>Κενό μεταξύ υποτίτλων (χιλ. δευτερολέπτου)</GapBetweenSubtitles> + <Auto>Αυτόματο</Auto> + <Fixed>Σταθερό</Fixed> + <Refresh>&amp;Ανανέωση</Refresh> + <TextFiles>Αρχεία κειμένου</TextFiles> + <PreviewLinesModifiedX>Προεπισκόπηση - τροποποιημένοι υπότιτλοι: {0}</PreviewLinesModifiedX> + <TimeCodes>Κώδικες χρόνων</TimeCodes> + <SplitAtEndChars>Διαχωρισμός στο τέλος χαρακτήρων</SplitAtEndChars> + </ImportText> + <Interjections> + <Title>Παρεμβολές</Title> + </Interjections> + <JoinSubtitles> + <Title>Ένωση υποτίτλων</Title> + <Information>Προσθήκη υποτίτλων για ένωση (η απόθεση υποστηρίζεται)</Information> + <NumberOfLines>#Γραμμές</NumberOfLines> + <StartTime>Έναρξη</StartTime> + <EndTime>Λήξη</EndTime> + <FileName>Όνομα αρχείου</FileName> + <Join>Ένωση</Join> + <TotalNumberOfLinesX>Συνολικός αριθμός γραμμών: {0:#,###,###}</TotalNumberOfLinesX> + <AlreadyCorrectTimeCodes>Τα αρχεία έχουν σωστούς κώδικες χρόνων</AlreadyCorrectTimeCodes> + <AppendTimeCodes>Προσθήκη χρόνου λήξης από προηγούμενο αρχείο</AppendTimeCodes> + <AddMs>Προσθήκη χιλ. δευτερολέπτου μετά από κάθε αρχείο</AddMs> + </JoinSubtitles> + <LanguageNames> + <NotSpecified>Αόριστο</NotSpecified> + <UnknownCodeX>Άγνωστο ({0})</UnknownCodeX> + <aaName>Αφάρ</aaName> + <abName>Αμπχαζικά</abName> + <afName>Αφρικάανς</afName> + <amName>Αμαρικά</amName> + <arName>Αραβικά</arName> + <asName>Ασαμεζικά</asName> + <ayName>Αϊμάρα</ayName> + <azName>Αζερμπαϊτζανικά</azName> + <baName>Μπασκίρ</baName> + <beName>Λευκορωσικά</beName> + <bgName>Βουλγαρικά</bgName> + <bhName>Ινδικά Μπιχάρ</bhName> + <biName>Μπισλάμα</biName> + <bnName>Μπενγκάλι</bnName> + <boName>Θιβετιανά</boName> + <brName>Βρετονικά</brName> + <caName>Καταλανικά</caName> + <coName>Κορσικανικά</coName> + <csName>Τσεχικά</csName> + <cyName>Ουαλικά</cyName> + <daName>Δανικά</daName> + <deName>Γερμανικά</deName> + <dzName>Ντζόνγκχα</dzName> + <elName>Ελληνικά</elName> + <enName>Αγγλικά</enName> + <eoName>Εσπεράντο</eoName> + <esName>Ισπανικά</esName> + <etName>Εσθονικά</etName> + <euName>Βασκικά</euName> + <faName>Περσικά</faName> + <fiName>Φινλανδικά</fiName> + <fjName>Φίτζι</fjName> + <foName>Φαρόε</foName> + <frName>Γαλλικά</frName> + <fyName>Δυτικά Φριζιανά</fyName> + <gaName>Ιρλανδικά</gaName> + <gdName>Σκωτικά Κελτικά</gdName> + <glName>Γαλικιακά</glName> + <gnName>Γκουαρανί</gnName> + <guName>Γκουγιαράτι</guName> + <haName>Χάουσα</haName> + <heName>Εβραϊκά</heName> + <hiName>Χίντι</hiName> + <hrName>Κροατικά</hrName> + <huName>Ουγγρικά</huName> + <hyName>Αρμενικά</hyName> + <iaName>Ιντερλίνγκουα</iaName> + <idName>Ινδονησιακά</idName> + <ieName>Ιντερλίνγκουε</ieName> + <ikName>Ινουπιάκ</ikName> + <isName>Ισλανδικά</isName> + <itName>Ιταλικά</itName> + <iuName>Ινουκτιτούτ</iuName> + <jaName>Ιαπωνικά</jaName> + <jvName>Ιαβανεζικά</jvName> + <kaName>Γεωργιανά</kaName> + <kkName>Καζακικά</kkName> + <klName>Καλαάλισουτ</klName> + <kmName>Καμποτζιανά</kmName> + <knName>Κανάντα</knName> + <koName>Κορεατικά</koName> + <ksName>Κασμίρι</ksName> + <kuName>Κουρδικά</kuName> + <kyName>Κυργιζικά</kyName> + <laName>Λατινικά</laName> + <lbName>Λουξεμβουργιανά</lbName> + <lnName>Λινγκάλα</lnName> + <loName>Λαοθιανά</loName> + <ltName>Λιθουανικά</ltName> + <lvName>Λετονικά</lvName> + <mgName>Μαλαγάσι</mgName> + <miName>Μάορι</miName> + <mkName>Σλαβομακεδονικά</mkName> + <mlName>Μαλαγιαλάμ</mlName> + <mnName>Μογγολικά</mnName> + <moName>Ρουμανικά Μολδαβίας</moName> + <mrName>Μαράθι</mrName> + <msName>Μαλάι</msName> + <mtName>Μαλτεζικά</mtName> + <myName>Βιρμανικά</myName> + <naName>Ναούρου</naName> + <neName>Νεπάλι</neName> + <nlName>Ολλανδικά</nlName> + <noName>Νορβηγικά</noName> + <ocName>Οκσιτανικά</ocName> + <omName>Ορόμο</omName> + <orName>Ορίγια</orName> + <paName>Παντζαπικά</paName> + <plName>Πολωνικά</plName> + <psName>Πάστο</psName> + <ptName>Πορτογαλικά</ptName> + <quName>Κετσούα</quName> + <rmName>Ρομανικά</rmName> + <rnName>Ρούντι</rnName> + <roName>Ρουμανικά</roName> + <ruName>Ρωσικά</ruName> + <rwName>Κινιαρβάντα</rwName> + <saName>Σανσκριτικά</saName> + <sdName>Σίντι</sdName> + <sgName>Σάνγκο</sgName> + <shName>Σερβοκροατικά</shName> + <siName>Σινχαλεζικά</siName> + <skName>Σλοβακικά</skName> + <slName>Σλοβενικά</slName> + <smName>Σαμόαν</smName> + <snName>Σχόνα</snName> + <soName>Σομάλι</soName> + <sqName>Αλβανικά</sqName> + <srName>Σερβικά</srName> + <ssName>Σουάτι</ssName> + <stName>Νότια Σόθο</stName> + <suName>Σουνδανικά</suName> + <svName>Σουηδικά</svName> + <swName>Σουαχίλι</swName> + <taName>Ταμίλ</taName> + <teName>Τελούγκου</teName> + <tgName>Τατζίκ</tgName> + <thName>Ταϊλανδικά</thName> + <tiName>Τιγκρίνυα</tiName> + <tkName>Τουρκμενικά</tkName> + <tlName>Ταγκαλόγκ</tlName> + <tnName>Τσιγουάνα</tnName> + <toName>Τονγκανικά</toName> + <trName>Τουρκικά</trName> + <tsName>Τσόνγκα</tsName> + <ttName>Τατάρ</ttName> + <twName>Τούι</twName> + <ugName>Ουιγουρικά</ugName> + <ukName>Ουκρανικά</ukName> + <urName>Ουρντού</urName> + <uzName>Ουζμπεκικά</uzName> + <viName>Βιετναμικά</viName> + <voName>Βόλαπικ</voName> + <woName>Γουόλοφ</woName> + <xhName>Ζόσα</xhName> + <yiName>Γίντις</yiName> + <yoName>Γιορούμπα</yoName> + <zaName>Ζουάνγκ</zaName> + <zhName>Κινεζικά</zhName> + <zuName>Ζουλού</zuName> + </LanguageNames> + <Main> + <Menu> + <File> + <Title>&amp;Αρχείο</Title> + <New>&amp;Νέο</New> + <Open>Ά&amp;νοιγμα</Open> + <OpenKeepVideo>Άνοιγμα (κράτηση βίντεο)</OpenKeepVideo> + <Reopen>Άνοιγμα &amp;ξανά</Reopen> + <Save>Α&amp;ποθήκευση</Save> + <SaveAs>Αποθήκευση &amp;ως...</SaveAs> + <RestoreAutoBackup>Επαναφορά αυτόματου αντίγραφου ασφαλείας</RestoreAutoBackup> + <AdvancedSubStationAlphaProperties>Προηγμένες ιδιότητες Sub Station Alpha...</AdvancedSubStationAlphaProperties> + <SubStationAlphaProperties>Ιδιότητες Sub Station Alpha...</SubStationAlphaProperties> + <EbuProperties>Ιδιότητες EBU STL...</EbuProperties> + <DvdStuioProProperties>Ιδιότητες DVD Studio Pro...</DvdStuioProProperties> + <TimedTextProperties>Ιδιότητες Timed Text...</TimedTextProperties> + <PacProperties>Ιδιότητες PAC...</PacProperties> + <OpenOriginal>Άνοιγμα αρχικού υπότιτλου (λειτουργία μετάφρασης)...</OpenOriginal> + <SaveOriginal>Αποθήκευση αρχικού υπότιτλου</SaveOriginal> + <CloseOriginal>Κλείσιμο αρχικού υπότιτλου</CloseOriginal> + <OpenContainingFolder>Άνοιγμα περιέχοντα φακέλου</OpenContainingFolder> + <Compare>&amp;Σύγκριση...</Compare> + <Statistics>Στατιστι&amp;κά...</Statistics> + <Plugins>Πρόσθετα...</Plugins> + <ImportOcrFromDvd>Εισαγωγή/OCR υπότιτλου από VOB/IFO (DVD)...</ImportOcrFromDvd> + <ImportOcrVobSubSubtitle>Εισαγωγή/OCR υπότιτλου VobSub (sub/idx)...</ImportOcrVobSubSubtitle> + <ImportBluRaySupFile>Εισαγωγή/OCR αρχείου Blu-ray sup...</ImportBluRaySupFile> + <ImportXSub>Εισαγωγή/OCR XSub από DivX/avi...</ImportXSub> + <ImportSubtitleFromMatroskaFile>Εισαγωγή/OCR υπότιτλου από αρχείο Matroska...</ImportSubtitleFromMatroskaFile> + <ImportSubtitleWithManualChosenEncoding>Εισαγωγή υπότιτλου με επιλογή κωδικοποίησης...</ImportSubtitleWithManualChosenEncoding> + <ImportText>Εισαγωγή απλού κειμένου...</ImportText> + <ImportImages>Εισαγωγή εικόνων...</ImportImages> + <ImportTimecodes>Εισαγωγή κωδικών χρόνου...</ImportTimecodes> + <Export>Εξαγωγή</Export> + <ExportBdnXml>BDN xml/png...</ExportBdnXml> + <ExportBluRaySup>Blu-ray sup...</ExportBluRaySup> + <ExportVobSub>VobSub (sub/idx)...</ExportVobSub> + <ExportCavena890>Cavena 890...</ExportCavena890> + <ExportEbu>EBU STL...</ExportEbu> + <ExportPac>PAC (Ηλεκτρονικά οθόνης)...</ExportPac> + <ExportPlainText>Απλό κείμενο...</ExportPlainText> + <ExportAdobeEncoreFabImageScript>Εικόνα κειμένου Adobe Encore FAB...</ExportAdobeEncoreFabImageScript> + <ExportKoreanAtsFilePair>Ζεύγος αρχείων Korean ATS...</ExportKoreanAtsFilePair> + <ExportAvidStl>Avid STL...</ExportAvidStl> + <ExportDvdStudioProStl>DVD Studio Pro STL...</ExportDvdStudioProStl> + <ExportCapMakerPlus>CapMaker Plus...</ExportCapMakerPlus> + <ExportCaptionsInc>Captions Inc...</ExportCaptionsInc> + <ExportCheetahCap>Cheetah CAP...</ExportCheetahCap> + <ExportUltech130>Λεζάντα Ultech...</ExportUltech130> + <ExportCustomTextFormat>Εξαγωγή προσαρμοσμένης μορφής κειμένου...</ExportCustomTextFormat> + <Exit>Έ&amp;ξοδος</Exit> + </File> + <Edit> + <Title>Επεξεργασία</Title> + <Undo>Αναίρεση</Undo> + <Redo>Επανάληψη</Redo> + <ShowUndoHistory>Εμφάνιση ιστορικού (αναίρεσης)</ShowUndoHistory> + <InsertUnicodeSymbol>Εισαγωγή συμβόλου Unicode</InsertUnicodeSymbol> + <InsertUnicodeControlCharacters>Εισαγωγή χαρακτήρων ελέγχου Unicode</InsertUnicodeControlCharacters> + <InsertUnicodeControlCharactersLRM>Σημείο αριστερά προς δεξιά</InsertUnicodeControlCharactersLRM> + <InsertUnicodeControlCharactersRLM>Σημείο δεξιά προς αριστερά</InsertUnicodeControlCharactersRLM> + <InsertUnicodeControlCharactersLRE>Έναρξη ενσωμάτωσης από αριστερά προς δεξιά</InsertUnicodeControlCharactersLRE> + <InsertUnicodeControlCharactersRLE>Έναρξη ενσωμάτωσης από δεξιά προς αριστερά</InsertUnicodeControlCharactersRLE> + <InsertUnicodeControlCharactersLRO>Έναρξη παράκαμψης από αριστερά προς δεξιά</InsertUnicodeControlCharactersLRO> + <InsertUnicodeControlCharactersRLO>Έναρξη παράκαμψης από δεξιά προς αριστερά</InsertUnicodeControlCharactersRLO> + <Find>Εύ&amp;ρεση</Find> + <FindNext>Εύρεση &amp;επόμενου</FindNext> + <Replace>Α&amp;ντικατάσταση</Replace> + <MultipleReplace>&amp;Πολλαπλή αντικατάστση...</MultipleReplace> + <GoToSubtitleNumber>&amp;Μετάβαση σε αριθμό υπότιτλου...</GoToSubtitleNumber> + <RightToLeftMode>Λειτουργία από δεξιά προς αριστερά</RightToLeftMode> + <FixRtlViaUnicodeControlCharacters>Επιδιόρθωση RTL μέσω χαρακτήρων ελέγχου Unicode (επιλεγμένων γραμμών)</FixRtlViaUnicodeControlCharacters> + <RemoveUnicodeControlCharacters>Αφαίρεση χαρακτήρων ελέγχου Unicode (επιλεγμένων γραμμών)</RemoveUnicodeControlCharacters> + <ReverseRightToLeftStartEnd>Αντιστροφή έναρξης/λήξης του RTL (επιλεγμένες γραμμές)</ReverseRightToLeftStartEnd> + <ShowOriginalTextInAudioAndVideoPreview>Προβολή αρχικού κειμένου στις προεπισκόπήσεις ήχου/βίντεο</ShowOriginalTextInAudioAndVideoPreview> + <ModifySelection>Επεξεργασία επιλογής...</ModifySelection> + <InverseSelection>Αντιστροφή</InverseSelection> + </Edit> + <Tools> + <Title>Εργαλεία</Title> + <AdjustDisplayDuration>&amp;Προσαρμογή διαρκειών...</AdjustDisplayDuration> + <ApplyDurationLimits>Εφαρμογή ορίων διάρκειας...</ApplyDurationLimits> + <SubtitlesBridgeGaps>Ένωση κενών στις διάρκειες...</SubtitlesBridgeGaps> + <FixCommonErrors>&amp;Επιδιόρθωση σφαλμάτων...</FixCommonErrors> + <StartNumberingFrom>Επαναρίθμηση...</StartNumberingFrom> + <RemoveTextForHearingImpaired>Αφαίρεση κειμένου για κωφούς...</RemoveTextForHearingImpaired> + <ChangeCasing>Αλλαγή πεζών-κεφαλαίων...</ChangeCasing> + <ChangeFrameRate>Αλλαγή ρυθμού καρέ...</ChangeFrameRate> + <ChangeSpeedInPercent>Αλλαγή ταχύτητας (επί τοις εκατό)...</ChangeSpeedInPercent> + <MergeShortLines>Συγχώνευση σύντομων γραμμών...</MergeShortLines> + <MergeDuplicateText>Συγχώνευση γραμμών με ίδιο κείμενο...</MergeDuplicateText> + <MergeSameTimeCodes>Συγχώνευση γραμμών με ίδιο χρόνο...</MergeSameTimeCodes> + <SplitLongLines>Διαχωρισμός μεγάλων γραμμών...</SplitLongLines> + <MinimumDisplayTimeBetweenParagraphs>Ελάχιστος χρόνος εμφάνισης μεταξύ παραγράφων...</MinimumDisplayTimeBetweenParagraphs> + <SortBy>Ταξινόμηση</SortBy> + <NetflixQualityCheck>Έλεγχος ποιότητας Netflix...</NetflixQualityCheck> + <Number>Αριθμός</Number> + <StartTime>Έναρξη</StartTime> + <EndTime>Λήξη</EndTime> + <Duration>Διάρκεια</Duration> + <TextAlphabetically>Κείμενο - αλφαβητικά</TextAlphabetically> + <TextSingleLineMaximumLength>Κείμενο - μέγιστο μήκος γραμμής</TextSingleLineMaximumLength> + <TextTotalLength>Κείμενο - συνολικό μήκος</TextTotalLength> + <TextNumberOfLines>Κείμενο - σύνολο γραμμών</TextNumberOfLines> + <TextNumberOfCharactersPerSeconds>Κείμενο - σύνολο χαρακτήρων/δευτ.</TextNumberOfCharactersPerSeconds> + <WordsPerMinute>Κείμενο - λέξεις ανά λεπτό (λαλ)</WordsPerMinute> + <Style>Στυλ</Style> + <Ascending>Αύξουσα</Ascending> + <Descending>Φθίνουσα</Descending> + <MakeNewEmptyTranslationFromCurrentSubtitle>Δημιουργία νέας κενής μετάφρασης</MakeNewEmptyTranslationFromCurrentSubtitle> + <BatchConvert>Μαζική μετατροπή...</BatchConvert> + <GenerateTimeAsText>Παραγωγή χρόνου ως κείμενο...</GenerateTimeAsText> + <MeasurementConverter>Μετατροπέας μονάδων μέτρησης...</MeasurementConverter> + <SplitSubtitle>Διάσπαση υπότιτλου...</SplitSubtitle> + <AppendSubtitle>Προσάρτηση υπότιτλου...</AppendSubtitle> + <JoinSubtitles>Ένωση υποτίτλων...</JoinSubtitles> + </Tools> + <Video> + <Title>Βίντεο</Title> + <OpenVideo>Άνοιγμα αρχείου βίντεο...</OpenVideo> + <OpenVideoFromUrl>Άνοιγμα βίντεο από διεύθυνση url...</OpenVideoFromUrl> + <OpenDvd>Άνοιγμα DVD...</OpenDvd> + <ChooseAudioTrack>Επιλέξτε κομματιού ήχου</ChooseAudioTrack> + <CloseVideo>Κλείσιμο βίντεο</CloseVideo> + <OpenSecondSubtitle>Άνοιγμα δεύτερου υποτίτλου...</OpenSecondSubtitle> + <SetVideoOffset>Αντιστάθμιση έναρξης βίντεο...</SetVideoOffset> + <SmptTimeMode>Χρονισμός SMPTE (ρήξη καρέ)</SmptTimeMode> + <GenerateTextFromVideo>Δημιουργία κειμένου από βίντεο...</GenerateTextFromVideo> + <ImportChaptersFromVideo>Εισαγωγή κεφαλαίων από βίντεο</ImportChaptersFromVideo> + <GenerateImportSceneChanges>Δημιουργία/εισαγωγή αλλαγών σκηνών...</GenerateImportSceneChanges> + <RemoveSceneChanges>Αφαίρεση σκηνών αλλαγής</RemoveSceneChanges> + <WaveformBatchGenerate>Μαζική δημιουργία κυματομορφών...</WaveformBatchGenerate> + <ShowHideVideo>Εμφάνιση/απόκρυψη βίντεο</ShowHideVideo> + <ShowHideWaveform>Εμφάνιση/απόκρυψη κυματομορφής</ShowHideWaveform> + <ShowHideWaveformAndSpectrogram>Εμφάνιση/απόκρυψη κυματομορφής και φασματογράμματος</ShowHideWaveformAndSpectrogram> + <UnDockVideoControls>Απαγκύρωση στοιχείων ελέγχου βίντεο</UnDockVideoControls> + <ReDockVideoControls>Επαναγκύρωση στοιχείων ελέγχου βίντεο</ReDockVideoControls> + </Video> + <SpellCheck> + <Title>Ορθογραφικός έλεγχος</Title> + <SpellCheck>&amp;Ορθογραφικός έλεγχος...</SpellCheck> + <SpellCheckFromCurrentLine>Ορθογραφικός έλεγχος από τρέχουσα γραμμή...</SpellCheckFromCurrentLine> + <FindDoubleWords>Εύρεση διπλών λέξεων</FindDoubleWords> + <FindDoubleLines>Εύρεση διπλών γραμμών</FindDoubleLines> + <GetDictionaries>Λήψη λεξικών...</GetDictionaries> + <AddToNameList>Προσθήκη λέξης στη λίστα ονομάτων</AddToNameList> + </SpellCheck> + <Synchronization> + <Title>Συγχρονισμός</Title> + <AdjustAllTimes>Προσαρμογή όλων των χρόνων (εμφάνιση νωρίτερα/αργότερα)...</AdjustAllTimes> + <VisualSync>&amp;Οπτικός συγχρονισμός...</VisualSync> + <PointSync>Συγχρονισμός σημείων...</PointSync> + <PointSyncViaOtherSubtitle>Συγχρονισμός σημείων μέσω υπότιτλου...</PointSyncViaOtherSubtitle> + </Synchronization> + <AutoTranslate> + <Title>Αυτόματη μετάφραση</Title> + <TranslatePoweredByGoogle>Μετάφραση Google...</TranslatePoweredByGoogle> + <TranslatePoweredByMicrosoft>Μετάφραση Bing...</TranslatePoweredByMicrosoft> + <TranslateFromSwedishToDanish>Μετάφραση από Σουηδικά σε Δανικά (τροφοδοτείται από nikse.dk)...</TranslateFromSwedishToDanish> + </AutoTranslate> + <Options> + <Title>Επιλογές</Title> + <Settings>&amp;Ρυθμίσεις...</Settings> + <ChooseLanguage>&amp;Επιλογή γλώσσας...</ChooseLanguage> + </Options> + <Networking> + <Title>Δίκτυο</Title> + <StartNewSession>Έναρξη νέας συνεδρίας</StartNewSession> + <JoinSession>Συμμετοχή</JoinSession> + <ShowSessionInfoAndLog>Προβολή πληροφοριών και αρχείου καταγραφής</ShowSessionInfoAndLog> + <Chat>Συνομιλία</Chat> + <LeaveSession>Έξοδος</LeaveSession> + </Networking> + <Help> + <CheckForUpdates>Έλεγχος ενημερώσεων...</CheckForUpdates> + <Title>Βοήθεια</Title> + <Help>&amp;Βοήθεια</Help> + <About>&amp;Πληροφορίες</About> + </Help> + <ToolBar> + <New>Νέο</New> + <Open>Άνοιγμα</Open> + <Save>Αποθήκευση</Save> + <SaveAs>Αποθήκευση ως</SaveAs> + <Find>Εύρεση</Find> + <Replace>Αντικατάσταση</Replace> + <FixCommonErrors>Διόρθωση συνηθισμένων σφαλμάτων</FixCommonErrors> + <RemoveTextForHi>Αφαίρεση κειμένου για κωφούς</RemoveTextForHi> + <VisualSync>Οπτικός συγχρονισμός</VisualSync> + <SpellCheck>Ορθογραφικός έλεγχος</SpellCheck> + <NetflixQualityCheck>Έλεγχος ποιότητας Netflix</NetflixQualityCheck> + <Settings>Ρυθμίσεις</Settings> + <Help>Βοήθεια</Help> + <ShowHideWaveform>Εμφάνιση/απόκρυψη κυματομορφής</ShowHideWaveform> + <ShowHideVideo>Εμφάνιση/απόκρυψη βίντεο</ShowHideVideo> + </ToolBar> + <ContextMenu> + <SizeAllColumnsToFit>Αλλαγή μεγέθους στηλών για να χωρούν</SizeAllColumnsToFit> + <AdvancedSubStationAlphaSetStyle>Προηγμένο Sub Station Alpha - ορισμός στυλ</AdvancedSubStationAlphaSetStyle> + <SubStationAlphaSetStyle>Sub Station Alpha - Ορισμός στυλ</SubStationAlphaSetStyle> + <SetActor>Ορισμός παράγοντα</SetActor> + <SubStationAlphaStyles>Στυλ Sub Station Alpha...</SubStationAlphaStyles> + <AdvancedSubStationAlphaStyles>Προηγμένο στυλ Sub Station Alpha...</AdvancedSubStationAlphaStyles> + <TimedTextSetRegion>Timed Text - ορισμός περιοχής</TimedTextSetRegion> + <TimedTextSetStyle>Timed Text - ορισμός στυλ</TimedTextSetStyle> + <TimedTextStyles>Στυλ Timed Text...</TimedTextStyles> + <TimedTextSetLanguage>Timed Text - ορισμός γλώσσας</TimedTextSetLanguage> + <SamiSetStyle>Sami - ορισμός κλάσης</SamiSetStyle> + <NuendoSetStyle>Nuendo - ορισμός χαρακτήρα</NuendoSetStyle> + <Cut>Αποκοπή</Cut> + <Copy>Αντιγραφή</Copy> + <Paste>Επικόλληση</Paste> + <Delete>Διαγραφή</Delete> + <SplitLineAtCursorPosition>Διαχωρισμός γραμμής στην θέση του δείκτη</SplitLineAtCursorPosition> + <SplitLineAtCursorAndWaveformPosition>Διαχωρισμός γραμμής στη θέση δείκτη/βίντεο</SplitLineAtCursorAndWaveformPosition> + <AutoDurationCurrentLine>Αυτόματη διάρκεια (τρέχουσα γραμμή)</AutoDurationCurrentLine> + <SelectAll>Επιλογή όλων</SelectAll> + <InsertFirstLine>Εισαγωγή γραμμής</InsertFirstLine> + <InsertBefore>Εισαγωγή πριν</InsertBefore> + <InsertAfter>Εισαγωγή μετά</InsertAfter> + <InsertSubtitleAfter>Εισαγωγή υπότιτλου έπειτα της γραμμής...</InsertSubtitleAfter> + <CopyToClipboard>Αντιγραφή κειμένου στο πρόχειρο</CopyToClipboard> + <Column>Στήλη</Column> + <ColumnDeleteText>Διαγραφή κειμένου</ColumnDeleteText> + <ColumnDeleteTextAndShiftCellsUp>Διαγραφή κειμένου και ανέβασμα κελιών</ColumnDeleteTextAndShiftCellsUp> + <ColumnInsertEmptyTextAndShiftCellsDown>Εισαγωγή κενού κειμένου και κατέβασμα κελιών</ColumnInsertEmptyTextAndShiftCellsDown> + <ColumnInsertTextFromSubtitle>Εισαγωγή κειμένου από υπότιτλο...</ColumnInsertTextFromSubtitle> + <ColumnImportTextAndShiftCellsDown>Εισαγωγή κειμένου και κατέβασμα κελιών</ColumnImportTextAndShiftCellsDown> + <ColumnPasteFromClipboard>Επικόλληση από το πρόχειρο...</ColumnPasteFromClipboard> + <ColumnTextUp>Κείμενο πάνω</ColumnTextUp> + <ColumnTextDown>Κείμενο κάτω</ColumnTextDown> + <ColumnCopyOriginalTextToCurrent>Αντιγραφή κειμένου από το αρχικό στο τρέχων</ColumnCopyOriginalTextToCurrent> + <Split>Διαχωρισμός</Split> + <MergeSelectedLines>Συγχώνευση γραμμών</MergeSelectedLines> + <MergeSelectedLinesAsDialog>Συγχώνευση γραμμών ως διάλογο</MergeSelectedLinesAsDialog> + <MergeWithLineBefore>Συγχώνευση με τη γραμμή πριν</MergeWithLineBefore> + <MergeWithLineAfter>Συγχώνευση με τη γραμμή μετά</MergeWithLineAfter> + <ExtendToLineBefore>Επέκταση στην προηγούμενη γραμμή</ExtendToLineBefore> + <ExtendToLineAfter>Επέκταση στην επόμενη γραμμή</ExtendToLineAfter> + <RemoveFormatting>Αφαίρεση μορφοποίησης</RemoveFormatting> + <RemoveFormattingAll>Αφαίρεση όλης της μορφοποίησης</RemoveFormattingAll> + <RemoveFormattingBold>Αφαίρεση έντονων</RemoveFormattingBold> + <RemoveFormattingItalic>Αφαίρεση πλαγιαστών</RemoveFormattingItalic> + <RemoveFormattingUnderline>Αφαίρεση υπογράμμισης</RemoveFormattingUnderline> + <RemoveFormattingColor>Αφαίρεση χρώματος</RemoveFormattingColor> + <RemoveFormattingFontName>Αφαίρεση ονόματος γραμματοσειράς</RemoveFormattingFontName> + <RemoveFormattingAlignment>Αφαίρεση στοίχισης</RemoveFormattingAlignment> + <Underline>Υπογράμμιση</Underline> + <Box>Πλαίσιο</Box> + <Color>Χρώμα...</Color> + <FontName>Όνομα γραμματοσειράς...</FontName> + <Superscript>Εκθέτης</Superscript> + <Subscript>Δείκτης</Subscript> + <Alignment>Στοίχιση...</Alignment> + <AutoBalanceSelectedLines>Αυτόματη ισορρόπηση γραμμών...</AutoBalanceSelectedLines> + <RemoveLineBreaksFromSelectedLines>Αφαίρεση αλλαγών γραμμής από γραμμές...</RemoveLineBreaksFromSelectedLines> + <TypewriterEffect>Εφέ γραφομηχανής...</TypewriterEffect> + <KaraokeEffect>Εφέ καραόκε...</KaraokeEffect> + <ShowSelectedLinesEarlierLater>Εμφάνιση γραμμών νωρίτερα/αργότερα...</ShowSelectedLinesEarlierLater> + <VisualSyncSelectedLines>Οπτικός συγχρονισμός γραμμών...</VisualSyncSelectedLines> + <GoogleAndMicrosoftTranslateSelectedLine>Μετάφραση αρχικής γραμμής μέσω Google/Microsoft</GoogleAndMicrosoftTranslateSelectedLine> + <TranslateSelectedLines>Μετάφραση γραμμών...</TranslateSelectedLines> + <AdjustDisplayDurationForSelectedLines>Προσαρμογή διαρκειών γραμμών...</AdjustDisplayDurationForSelectedLines> + <FixCommonErrorsInSelectedLines>Επιδιόρθωση κοινών σφαλμάτων στις γραμμές...</FixCommonErrorsInSelectedLines> + <ChangeCasingForSelectedLines>Αλλαγή πεζών-κεφαλαίων στις γραμμές...</ChangeCasingForSelectedLines> + <SaveSelectedLines>Αποθήκευση γραμμών ως...</SaveSelectedLines> + <WebVTTSetNewVoice>Καθορισμός νέας φωνής...</WebVTTSetNewVoice> + <WebVTTRemoveVoices>Αφαίρεση φωνών</WebVTTRemoveVoices> + <NewActor>Νέος ηθοποιός...</NewActor> + <RemoveActors>Αφαίρεση ηθοποιών</RemoveActors> + <EditBookmark>Επεξεργασία σημείωσης</EditBookmark> + <RemoveBookmark>Αφαίρεση σημείωσης</RemoveBookmark> + </ContextMenu> + </Menu> + <Controls> + <SubtitleFormat>Μορφή</SubtitleFormat> + <FileEncoding>Κωδικοποίηση</FileEncoding> + <ListView>Προβολή λίστας</ListView> + <SourceView>Προβολή πηγής</SourceView> + <UndoChangesInEditPanel>Αναίρεση αλλαγών στον πίνακα επεξεργασίας</UndoChangesInEditPanel> + <Previous>&lt; Προηγούμενο</Previous> + <Next>Επόμενο &gt;</Next> + <AutoBreak>&amp;Διάσπαση</AutoBreak> + <Unbreak>Συνένωση</Unbreak> + </Controls> + <VideoControls> + <Translate>Μετάφραση</Translate> + <CreateAndAdjust>Δημιουργία/προσαρμογή</CreateAndAdjust> + <Create>Δημιουργία</Create> + <Adjust>Προσαρμογή</Adjust> + <SelectCurrentElementWhilePlaying>Επιλογή τρέχοντος υπότιτλου κατά την αναπαραγωγή</SelectCurrentElementWhilePlaying> + <AutoRepeat>Αυτόματη επανάληψη</AutoRepeat> + <AutoRepeatOn>Ενεργοποίηση αυτόματης επανάληψης</AutoRepeatOn> + <AutoRepeatCount>Μετρητής επαναλήψεων (φορές)</AutoRepeatCount> + <AutoContinue>Αυτόματη συνέχιση</AutoContinue> + <AutoContinueOn>Ενεργοποίηση αυτόματης συνέχισης</AutoContinueOn> + <DelayInSeconds>Καθυστέρηση (δευτ.)</DelayInSeconds> + <OriginalText>Αρχικό κείμενο</OriginalText> + <Previous>&lt; &amp;Προηγούμενο</Previous> + <Stop>&amp;Διακοπή</Stop> + <PlayCurrent>&amp;Αναπαραγωγή τρέχοντος</PlayCurrent> + <Next>&amp;Επόμενο &gt;</Next> + <Playing>Σε αναπαραγωγή...</Playing> + <RepeatingLastTime>Επανάληψη... τελευταία φορά</RepeatingLastTime> + <RepeatingXTimesLeft>Επανάληψη... {0} φορές που απέμειναν</RepeatingXTimesLeft> + <AutoContinueInOneSecond>Αυτόματη συνέχιση σε ένα δευτ.</AutoContinueInOneSecond> + <AutoContinueInXSeconds>Αυτόματη συνέχιση σε {0} δευτ.</AutoContinueInXSeconds> + <StillTypingAutoContinueStopped>Πληκτρολόγηση σε εξέλιξη... διακοπή αυτόματης συνέχισης</StillTypingAutoContinueStopped> + <InsertNewSubtitleAtVideoPosition>&amp;Εισαγωγή νέου υποτίτλου</InsertNewSubtitleAtVideoPosition> + <InsertNewSubtitleAtVideoPositionNoTextBoxFocus>Εισαγωγή υποτίτλου στη θέση βίντεο (μη εστίαση πλαισίου)</InsertNewSubtitleAtVideoPositionNoTextBoxFocus> + <Auto>Αυτόματη</Auto> + <PlayFromJustBeforeText>Αναπαραγωγή &amp;πριν από</PlayFromJustBeforeText> + <Pause>Παύση</Pause> + <GoToSubtitlePositionAndPause>Μετάβαση και παύση</GoToSubtitlePositionAndPause> + <SetStartTime>Ορισμός έ&amp;ναρξης</SetStartTime> + <SetEndTimeAndGoToNext>Ο&amp;ρισμός λήξης &amp;&amp; μετάβαση</SetEndTimeAndGoToNext> + <AdjustedViaEndTime>Προσάρμοση μέσω χρόνου λήξης {0}</AdjustedViaEndTime> + <SetEndTime>Ορισμός λή&amp;ξης</SetEndTime> + <SetstartTimeAndOffsetOfRest>Έναρ&amp;ξη και αντιστάθμιση</SetstartTimeAndOffsetOfRest> + <SearchTextOnline>Αναζήτηση κειμένου διαδικτυακά</SearchTextOnline> + <GoogleTranslate>Μετάφραση Google</GoogleTranslate> + <GoogleIt>Αναζήτηση</GoogleIt> + <SecondsBackShort>&lt;&lt;</SecondsBackShort> + <SecondsForwardShort>&gt;&gt;</SecondsForwardShort> + <VideoPosition>Θέση βίντεο:</VideoPosition> + <TranslateTip>Συμβουλή: Χρησιμοποιήστε &lt;alt+βέλη πάνω/κάτω&gt; για μετάβαση σε προηγούμενο/επόμενο υπότιτλο</TranslateTip> + <BeforeChangingTimeInWaveformX>Πριν την αλλαγή χρόνου στην κυματομορφή: {0}</BeforeChangingTimeInWaveformX> + <NewTextInsertAtX>Νέο κείμενο εισήχθει στο {0}</NewTextInsertAtX> + <Center>Κέντρο</Center> + <PlayRate>Ρυθμός αναπαραγωγής (ταχύτητα)</PlayRate> + </VideoControls> + <SaveChangesToUntitled>Αποθήκευση αλλαγών στο άτιτλο;</SaveChangesToUntitled> + <SaveChangesToX>Αποθήκευση αλλαγών στο {0};</SaveChangesToX> + <SaveChangesToUntitledOriginal>Αποθήκευση αλλαγών στον αρχικό άτιτλο;</SaveChangesToUntitledOriginal> + <SaveChangesToOriginalX>Αποθήκευση αλλαγών στον αρχικό {0};</SaveChangesToOriginalX> + <SaveSubtitleAs>Αποθήκευση υποτίτλου ως...</SaveSubtitleAs> + <SaveOriginalSubtitleAs>Αποθήκευση αρχικού υποτίτλου ως...</SaveOriginalSubtitleAs> + <NoSubtitleLoaded>Μη φορτωμένος υπότιτλος</NoSubtitleLoaded> + <VisualSyncSelectedLines>Οπτικός συγχρονισμός - επιλεγμένες γραμμές</VisualSyncSelectedLines> + <VisualSyncTitle>Οπτικός συγχρονισμός</VisualSyncTitle> + <BeforeVisualSync>Πριν οπτικού συγχρονισμού</BeforeVisualSync> + <VisualSyncPerformedOnSelectedLines>Εκτελέστηκε οπτικός συγχρονισμός στις επιλεγμένες γραμμές</VisualSyncPerformedOnSelectedLines> + <VisualSyncPerformed>Εκτελέστηκε οπτικός συγχρονισμός</VisualSyncPerformed> + <FileXIsLargerThan10MB>Το αρχείο {0} είναι μεγαλύτερο από 10 MB</FileXIsLargerThan10MB> + <ContinueAnyway>Συνέχιση;</ContinueAnyway> + <BeforeLoadOf>Πριν τη φόρτωση του {0}</BeforeLoadOf> + <LoadedSubtitleX>Φόρτωση υποτίτλου {0}</LoadedSubtitleX> + <LoadedEmptyOrShort>Φόρτωση κενού ή σύντομου υποτίτλου {0}</LoadedEmptyOrShort> + <FileIsEmptyOrShort>Το αρχείο είναι κενό ή μικρό!</FileIsEmptyOrShort> + <FileNotFound>Αδυναμία εύρεσης αρχείου: {0}</FileNotFound> + <SavedSubtitleX>Αποθήκευση υποτίτλου {0}</SavedSubtitleX> + <SavedOriginalSubtitleX>Αποθήκευση αρχικού υποτίτλου {0}</SavedOriginalSubtitleX> + <FileOnDiskModified>Τροποποίηση αρχείου δίσκου</FileOnDiskModified> + <OverwriteModifiedFile>Αντικατάσταση του αρχείου {0} που τροποποιήθηκε στο {1} {2}{3} με το τρέχον αρχείο που φορτώθηκε από το δίσκο στο {4} {5};</OverwriteModifiedFile> + <FileXIsReadOnly>Αδυναμία αποθήκευσης {0} +Το αρχείο είναι μόνο για ανάγνωση!</FileXIsReadOnly> + <UnableToSaveSubtitleX>Αδυναμία αποθήκευσης του αρχείου υπότιτλων {0} +Ο υπότιτλος μοιάζει να είναι άδειος - προσπαθήστε να τον ξανασώσεται, εάν δουλεύεται σε έγκυρο αρχείο</UnableToSaveSubtitleX> + <FormatXShouldUseUft8>Να χρησιμοποιείται η κωδικοποίηση UTF-8 κατά την αποθήκευση {0} αρχείων!</FormatXShouldUseUft8> + <BeforeNew>Πριν από νέο</BeforeNew> + <New>Νέο</New> + <BeforeConvertingToX>Πριν από μετατροπή σε {0}</BeforeConvertingToX> + <ConvertedToX>Μετατράπηκε σε {0}</ConvertedToX> + <BeforeShowEarlier>Πριν από εμφάνιση νωρίτερα</BeforeShowEarlier> + <BeforeShowLater>Πριν από εμφάνιση αργότερα</BeforeShowLater> + <LineNumberX>Γραμμή με αριθμό: {0:#,##0.##}</LineNumberX> + <OpenVideoFile>Άνοιγμα βίντεο...</OpenVideoFile> + <NewFrameRateUsedToCalculateTimeCodes>Ο νέος ρυθμός καρέ ({0}) χρησιμοποιήθηκε για τον υπολογισμό των κωδικών χρόνου έναρξης/λήξης</NewFrameRateUsedToCalculateTimeCodes> + <NewFrameRateUsedToCalculateFrameNumbers>Ο νέος ρυθμός καρέ ({0}) χρησιμοποιήθηκε για τον υπολογισμό των αριθμών καρέ έναρξης/λήξης</NewFrameRateUsedToCalculateFrameNumbers> + <FindContinue>Αδυναμία εύρεσης στοιχείου. +Επανάληψη αναζήτησης από την αρχή;</FindContinue> + <FindContinueTitle>Συνέχιση εύρεσης;</FindContinueTitle> + <ReplaceContinueNotFound>Αδυναμία εύρεσης στοιχείου. +Επανάληψη αναζήτησης και αντικατάστασης από την αρχή;</ReplaceContinueNotFound> + <ReplaceXContinue>Εύρεση και αντικατάσταση στοιχείου {0} φορά(ες). +Επανάληψη αναζήτησης και αντικατάστασης από την αρχή;</ReplaceXContinue> + <ReplaceContinueTitle>Συνέχιση 'αντικατάστασης';</ReplaceContinueTitle> + <SearchingForXFromLineY>Αναζήτηση για '{0}' από αριθμό γραμμής {1}...</SearchingForXFromLineY> + <XFoundAtLineNumberY>Εύρεση '{0}' στη γραμμή με αριθμό {1}</XFoundAtLineNumberY> + <XNotFound>Αδυναμία εύρεσης '{0}'</XNotFound> + <BeforeReplace>Πριν από αντικατάσταση: {0}</BeforeReplace> + <MatchFoundX>Εύρεση αντιστοιχίας: {0}</MatchFoundX> + <NoMatchFoundX>Αδυναμία εύρεσης αντιστοιχίας: {0}</NoMatchFoundX> + <FoundNothingToReplace>Αδυναμία εύρεσης για αντικατάσταση</FoundNothingToReplace> + <ReplaceCountX>Αριθμός αντικαταστάσεων: {0}</ReplaceCountX> + <NoXFoundAtLineY>Εύρεση αντιστοιχίας στη γραμμή {0}: {1}</NoXFoundAtLineY> + <OneReplacementMade>Αντικατάσταση ενός.</OneReplacementMade> + <BeforeChangesMadeInSourceView>Πριν των αλλαγν στην προβολή πηγής</BeforeChangesMadeInSourceView> + <UnableToParseSourceView>Αδυναμία ανάλυσης κειμένου στην προβολή πηγής!</UnableToParseSourceView> + <GoToLineNumberX>Μετάβαση στη γραμμή με αριθμό {0}</GoToLineNumberX> + <CreateAdjustChangesApplied>Δημιουργία/προσαρμογή γραμμών εφαρμοσμένων αλλαγών</CreateAdjustChangesApplied> + <SelectedLines>επιλεγμένες γραμμές</SelectedLines> + <BeforeDisplayTimeAdjustment>Πριν από προσαρμογή χρόνου εμφάνισης</BeforeDisplayTimeAdjustment> + <DisplayTimeAdjustedX>Προσαρμοσμένος χρόνος εμφάνισης: {0}</DisplayTimeAdjustedX> + <DisplayTimesAdjustedX>Προσαρμοσμένοι χρόνοι εμφάνισης: {0}</DisplayTimesAdjustedX> + <StarTimeAdjustedX>Προσαρμοσμένος χρόνος έναρξης: {0}</StarTimeAdjustedX> + <BeforeCommonErrorFixes>Πριν από επιδιορθώσεις κοινών σφαλμάτων</BeforeCommonErrorFixes> + <CommonErrorsFixedInSelectedLines>Επιδιορθώσεις κοινών σφαλμάτων σε επιλεγμένες γραμμές</CommonErrorsFixedInSelectedLines> + <CommonErrorsFixed>Επιδιόρθωση κοινών σφαλμάτων</CommonErrorsFixed> + <BeforeRenumbering>Πριν επαναρίθμησης</BeforeRenumbering> + <RenumberedStartingFromX>Έναρξη επαναρίθμησης από: {0}</RenumberedStartingFromX> + <BeforeRemovalOfTextingForHearingImpaired>Πριν από αφαίρεση κειμένου για κωφούς</BeforeRemovalOfTextingForHearingImpaired> + <TextingForHearingImpairedRemovedOneLine>Αφαίρεση κειμένου για κωφούς: Μία γραμμή</TextingForHearingImpairedRemovedOneLine> + <TextingForHearingImpairedRemovedXLines>Αφαίρεση κειμένου για κωφούς: {0} γραμμή(ές)</TextingForHearingImpairedRemovedXLines> + <SubtitleSplitted>Διαχώριση υποτίτλου</SubtitleSplitted> + <SubtitleAppendPrompt>Προσάρτηση υποτίτλου στον φορτωμένο υπότιτλο που ίσως +είναι ήδη συγχρονισμένος με το αρχείο βίντεο. Συνέχιση;</SubtitleAppendPrompt> + <SubtitleAppendPromptTitle>Προσάρτηση υπότιτλου</SubtitleAppendPromptTitle> + <OpenSubtitleToAppend>Άνοιγμα υπότιτλου για προσάρτηση...</OpenSubtitleToAppend> + <AppendViaVisualSyncTitle>Οπτικός συγχρονισμός - προσάρτηση δεύτερου μέρους υπότιτλου</AppendViaVisualSyncTitle> + <AppendSynchronizedSubtitlePrompt>Προσάρτηση του συγχρονισμένου υπότιτλου;</AppendSynchronizedSubtitlePrompt> + <BeforeAppend>Πριν από προσάρτηση</BeforeAppend> + <SubtitleAppendedX>Προσάρτηση υποτίτλου: {0}</SubtitleAppendedX> + <SubtitleNotAppended>Μη προσάρτηση υποτίτλου!</SubtitleNotAppended> + <GoogleTranslate>Μετάφραση Google</GoogleTranslate> + <MicrosoftTranslate>Μετάφραση Bing</MicrosoftTranslate> + <BeforeGoogleTranslation>Πριν από μετάφραση Google</BeforeGoogleTranslation> + <SelectedLinesTranslated>Μετάφραση επιλεγμένων γρραμμών</SelectedLinesTranslated> + <SubtitleTranslated>Μετάφραση υποτίτλου</SubtitleTranslated> + <TranslateSwedishToDanish>Μετάφραση φορτωμένου σουηδικού υποτίτλου σε Δανικά</TranslateSwedishToDanish> + <TranslateSwedishToDanishWarning>Μετάφραση φορτωμένου σουηδικού (σίγουρα είναι σουηδικός;) υπότιτλου σε Δανικά;</TranslateSwedishToDanishWarning> + <TranslatingViaNikseDkMt>Μετάφραση μέσω www.nikse.dk/mt...</TranslatingViaNikseDkMt> + <BeforeSwedishToDanishTranslation>Πριν από μετάφραση Σουηδικών σε Δανικά</BeforeSwedishToDanishTranslation> + <TranslationFromSwedishToDanishComplete>Ολοκλήρωση μετάφρασης Σουηδικών σε Δανικά</TranslationFromSwedishToDanishComplete> + <TranslationFromSwedishToDanishFailed>Αποτυχία μετάφρασης Σουηδικών σε Δανικά</TranslationFromSwedishToDanishFailed> + <UndoPerformed>Εκτέλεση αναίρεσης</UndoPerformed> + <RedoPerformed>Εκτέλεση επανάληψης</RedoPerformed> + <NothingToUndo>Τίποτα για αναίρεση</NothingToUndo> + <InvalidLanguageNameX>Μη έγκυρο όνομα γλώσσας: {0}</InvalidLanguageNameX> + <DoNotDisplayMessageAgain>Απόκρυψη μηνύματος</DoNotDisplayMessageAgain> + <NumberOfCorrectedWords>Σύνολο διορθωμένων λέξεων: {0}</NumberOfCorrectedWords> + <NumberOfSkippedWords>Σύνολο παραλειπόμενων λέξεων: {0}</NumberOfSkippedWords> + <NumberOfCorrectWords>Σύνολο σωστών λέξεων: {0}</NumberOfCorrectWords> + <NumberOfWordsAddedToDictionary>Σύνολο πρόσθετων λέξεων στο λεξικό: {0}</NumberOfWordsAddedToDictionary> + <NumberOfNameHits>Σύνολο ευρέσεων ονομάτων: {0}</NumberOfNameHits> + <SpellCheck>Ορθογραφικός έλεγχος</SpellCheck> + <BeforeSpellCheck>Πριν από ορθογραφικό έλεγχο</BeforeSpellCheck> + <SpellCheckChangedXToY>Ορθογραφικός έλεγχος: Αλλαγή του '{0}' σε '{1}'</SpellCheckChangedXToY> + <BeforeAddingTagX>Πριν από προσθήκη ετικετών &lt;{0}&gt;</BeforeAddingTagX> + <TagXAdded>Προσθήκη &lt;{0}&gt; ετικέτας(ών)</TagXAdded> + <LineXOfY>γραμμή {0} από {1}</LineXOfY> + <XLinesSavedAsY>Αποθήκευση {0} γραμμής(ών) ως {1}</XLinesSavedAsY> + <XLinesDeleted>Διαγραφή {0} γραμμής(ών)</XLinesDeleted> + <BeforeDeletingXLines>Πριν από διαγραφή {0} γραμμών</BeforeDeletingXLines> + <DeleteXLinesPrompt>Διαγραφή {0:#,##0} γραμμών;</DeleteXLinesPrompt> + <OneLineDeleted>Διαγραφή μίας γραμμής</OneLineDeleted> + <BeforeDeletingOneLine>Πριν από διαγραφή μίας γραμμής</BeforeDeletingOneLine> + <DeleteOneLinePrompt>Διαγραφή μίας γραμμής;</DeleteOneLinePrompt> + <BeforeInsertLine>Πριν από εισαγωγή γραμμής</BeforeInsertLine> + <LineInserted>Εισαγωγή γραμμής</LineInserted> + <BeforeLineUpdatedInListView>Πριν από ενημέρωση γραμμής σε προβολή λίστας</BeforeLineUpdatedInListView> + <BeforeSplitLine>Πριν από διαχωρισμό γραμμής</BeforeSplitLine> + <LineSplitted>Διαχώριση γραμμής</LineSplitted> + <BeforeMergeLines>Πριν από συγχώνευση γραμμών</BeforeMergeLines> + <LinesMerged>Συγχώνευση γραμμών</LinesMerged> + <BeforeSettingColor>Πριν από ρύθμιση χρώματος</BeforeSettingColor> + <BeforeSettingFontName>Πριν από ρύθμιση ονόματος γραμματοσειράς</BeforeSettingFontName> + <BeforeTypeWriterEffect>Πριν από εφέ γραφομηχανής</BeforeTypeWriterEffect> + <BeforeKaraokeEffect>Πριν από εφέ καραόκε</BeforeKaraokeEffect> + <BeforeImportingDvdSubtitle>Πριν από εισαγωγή υποτίτλων από DVD</BeforeImportingDvdSubtitle> + <OpenMatroskaFile>Άνοιγμα αρχείου Matroska...</OpenMatroskaFile> + <MatroskaFiles>Αρχεία Matroska</MatroskaFiles> + <NoSubtitlesFound>Αδυναμία εύρεσης υποτίτλων</NoSubtitlesFound> + <NotAValidMatroskaFileX>Μη έγκυρο αρχείο Matroska: {0}</NotAValidMatroskaFileX> + <BlurayNotSubtitlesFound>Το αρχείο Blu-ray .sup δεν περιέχει υπότιτλους ή περιέχει σφάλματα - προσπαθήστε ξανά</BlurayNotSubtitlesFound> + <ImportingChapters>Εισαγωγή κεφαλαίων...</ImportingChapters> + <XChaptersImported>{0} εισαγωγή κεφαλαίου(ων)</XChaptersImported> + <ParsingMatroskaFile>Ανάλυση αρχείου Matroska. Παρακαλώ, περιμένετε...</ParsingMatroskaFile> + <ParsingTransportStreamFile>Ανάλυση αρχείου Trasport Stream. Παρακαλώ, περιμένετε...</ParsingTransportStreamFile> + <BeforeImportFromMatroskaFile>Πριν από εισαγωγή υπότιτλου από αρχείο Matroska</BeforeImportFromMatroskaFile> + <SubtitleImportedFromMatroskaFile>Εισαγωγή υποτίτλου από αρχείο Matroska</SubtitleImportedFromMatroskaFile> + <DropFileXNotAccepted>Απόρριψη συρμένου αρχείου '{0}' - το αρχείο είναι πολύ μεγάλο</DropFileXNotAccepted> + <DropOnlyOneFile>Μπορείτε να σύρετε μόνο ένα αρχείο</DropOnlyOneFile> + <OpenAnsiSubtitle>Άνοιγμα υπότιτλου...</OpenAnsiSubtitle> + <BeforeChangeCasing>Πριν από αλλαγή πεζών-κεφαλαίων</BeforeChangeCasing> + <CasingCompleteMessageNoNames>Σύνολο γραμμών με αλλαγή πεζών-κεφαλαίων: {0}/{1}</CasingCompleteMessageNoNames> + <CasingCompleteMessageOnlyNames>Σύνολο γραμμών με αλλαγή πεζών-κεφαλαίων με ονόματα: {0}/{1}</CasingCompleteMessageOnlyNames> + <CasingCompleteMessage>Σύνολο γραμμών με αλλαγή πεζών-κεφαλαίων: {0}/{1}, αλλαγή πεζών-κεφαλαίων με ονόματα: {2}</CasingCompleteMessage> + <BeforeChangeFrameRate>Πριν από αλλαγή ρυθμού καρέ</BeforeChangeFrameRate> + <BeforeAdjustSpeedInPercent>Πριν ρύθμισης της ταχύτητας σε ποσοστό</BeforeAdjustSpeedInPercent> + <FrameRateChangedFromXToY>Αλλαγή ρυθμού καρέ από {0} σε {1}</FrameRateChangedFromXToY> + <IdxFileNotFoundWarning>Αδυναμία εύρεσης {0}! Εισαγωγή αρχείου VobSub;</IdxFileNotFoundWarning> + <InvalidVobSubHeader>Μη έγκυρη κεφαλίδα του αρχείου VobSub: {0}</InvalidVobSubHeader> + <OpenVobSubFile>Άνοιγμα υπότιτλου VobSub (sub/idx)...</OpenVobSubFile> + <VobSubFiles>Αρχεία υποτίτλων VobSub</VobSubFiles> + <OpenBluRaySupFile>Άνοιγμα αρχείου Blu-ray .sup...</OpenBluRaySupFile> + <BluRaySupFiles>Αρχεία Blu-ray .sup</BluRaySupFiles> + <OpenXSubFiles>Άνοιγμα αρχείου XSub...</OpenXSubFiles> + <XSubFiles>Αρχεία XSub</XSubFiles> + <BeforeImportingVobSubFile>Πριν από εισαγωγή αρχείου VobSub</BeforeImportingVobSubFile> + <BeforeImportingBluRaySupFile>Πριν από εισαγωγή αρχείου Blu-ray sup</BeforeImportingBluRaySupFile> + <BeforeImportingBdnXml>Πριν από εισαγωγή αρχείου BDN xml</BeforeImportingBdnXml> + <BeforeShowSelectedLinesEarlierLater>Πριν από εμφάνιση γραμμών νωρίτερα/αργότερα</BeforeShowSelectedLinesEarlierLater> + <ShowAllLinesXSecondsLinesEarlier>Εμφάνιση όλων των γραμμών {0:0.0##} δευτερόλεπτα νωρίτερα</ShowAllLinesXSecondsLinesEarlier> + <ShowAllLinesXSecondsLinesLater>Εμφάνιση όλων των γραμμών {0:0.0##} δευτερόλεπτα αργότερα</ShowAllLinesXSecondsLinesLater> + <ShowSelectedLinesXSecondsLinesEarlier>Εμφάνιση γραμμών {0:0.0##} δευτερόλεπτα νωρίτερα</ShowSelectedLinesXSecondsLinesEarlier> + <ShowSelectedLinesXSecondsLinesLater>Εμφάνιση γραμμών {0:0.0##} δευτερόλεπτα αργότερα</ShowSelectedLinesXSecondsLinesLater> + <ShowSelectionAndForwardXSecondsLinesEarlier>Εμφάνιση επιλογής και προώθηση {0:0.0##} δευτερόλεπτα νωρίτερα</ShowSelectionAndForwardXSecondsLinesEarlier> + <ShowSelectionAndForwardXSecondsLinesLater>Εμφάνιση επιλογής και προώθηση {0:0.0##} δευτερόλεπτα αργότερα</ShowSelectionAndForwardXSecondsLinesLater> + <DoubleWordsViaRegEx>Διπλές λέξεις μέσω τυπικής έκφρασης {0}</DoubleWordsViaRegEx> + <BeforeSortX>Πριν από ταξινόμηση: {0}</BeforeSortX> + <SortedByX>Ταξινόμηση κατά: {0}</SortedByX> + <BeforeAutoBalanceSelectedLines>Πριν από αυτόματη ισορρόπιση γραμμών</BeforeAutoBalanceSelectedLines> + <NumberOfLinesAutoBalancedX>Σύνολο αυτόματων ισορροπημένων γραμμών: {0}</NumberOfLinesAutoBalancedX> + <BeforeRemoveLineBreaksInSelectedLines>Πριν από αφαίρεση διάσπασης επιλεγμένων γραμμών</BeforeRemoveLineBreaksInSelectedLines> + <NumberOfWithRemovedLineBreakX>Σύνολο γραμμών που αφαιρέθηκαν διασπάσεις γραμμής: {0}</NumberOfWithRemovedLineBreakX> + <BeforeMultipleReplace>Πριν από πολλαπλή αντικατάσταση</BeforeMultipleReplace> + <NumberOfLinesReplacedX>Σύνολο γραμμών αντικατεστημένου κειμένου: {0}</NumberOfLinesReplacedX> + <NameXAddedToNameList>Προσθήκη ονόματος '{0}' στη λίστα ονομάτων</NameXAddedToNameList> + <NameXNotAddedToNameList>Μη προσθήκη ονόματος '{0}' στη λίστα ονομάτων</NameXNotAddedToNameList> + <WordXAddedToUserDic>Προσθήκη λέξης '{0}' στο λεξικό χρήστη</WordXAddedToUserDic> + <WordXNotAddedToUserDic>Μη προσθήκη λέξης '{0}' στο λεξικό χρήστη</WordXNotAddedToUserDic> + <OcrReplacePairXAdded>Τα ζεύγη των λιστών αντικατάστασης του OCR '{0} -&gt; {1}' προστέθηκαν στις λίστες αντικατάστασης του OCR</OcrReplacePairXAdded> + <OcrReplacePairXNotAdded>Τα ζεύγη των λιστών αντικατάστασης του OCR '{0} -&gt; {1}' δεν προστέθηκαν στις λίστες αντικατάστασης του OCR</OcrReplacePairXNotAdded> + <XLinesSelected>Επιλογή {0} γραμμής(ών)</XLinesSelected> + <UnicodeMusicSymbolsAnsiWarning>Ο υπότιτλος περιέχει unicode μουσικές νότες. Αν αποθηκευτεί χρησιμοποιώντας κωδικοποίηση ANSI θα χαθούν. Συνέχιση αποθήκευσης;</UnicodeMusicSymbolsAnsiWarning> + <NegativeTimeWarning>Ο υπότιτλος περιέχει αρνητικούς κωδικούς χρόνου. Συνέχιση αποθήκευσης;</NegativeTimeWarning> + <BeforeMergeShortLines>Πριν από συγχώνευση μικρών γραμμών</BeforeMergeShortLines> + <MergedShortLinesX>Σύνολο συγχωνευμένων γραμμών: {0}</MergedShortLinesX> + <BeforeSplitLongLines>Πριν από διαχωρισμό μεγάλων γραμμών</BeforeSplitLongLines> + <LongLinesSplitX>Σύνολο διαχωρισμένων γραμμών: {0}</LongLinesSplitX> + <BeforeDurationsBridgeGap>Πριν την ένωση μικρών κενών</BeforeDurationsBridgeGap> + <BeforeSetMinimumDisplayTimeBetweenParagraphs>Πριν από ορισμό ελάχιστου χρόνου εμφάνισης μεταξύ υποτίτλων</BeforeSetMinimumDisplayTimeBetweenParagraphs> + <XMinimumDisplayTimeBetweenParagraphsChanged>Σύνολο γραμμών αλλαγής ελάχιστου χρόνου εμφάνισης μεταξύ υποτίτλων: {0}</XMinimumDisplayTimeBetweenParagraphsChanged> + <BeforeImportText>Πριν από εισαγωγή απλού κειμένου</BeforeImportText> + <TextImported>Εισαγωγή κειμένου</TextImported> + <BeforePointSynchronization>Πριν από συγχρονισμό σημείων</BeforePointSynchronization> + <PointSynchronizationDone>Ολοκλήρωση συγχρονισμού σημείων</PointSynchronizationDone> + <BeforeTimeCodeImport>Πριν από εισαγωγή κωδικών χρόνου</BeforeTimeCodeImport> + <TimeCodeImportedFromXY>Εισαγωγή κωδικών χρόνων από {0}: {1}</TimeCodeImportedFromXY> + <BeforeInsertSubtitleAtVideoPosition>Πριν από εισαγωγή υπότιτλου στη θέση βίντεο</BeforeInsertSubtitleAtVideoPosition> + <BeforeSetStartTimeAndOffsetTheRest>Πριν ορισμού χρόνου έναρξης και αντιστάθμισης</BeforeSetStartTimeAndOffsetTheRest> + <BeforeSetEndTimeAndOffsetTheRest>Πριν ορισμού χρόνου λήξης και αντιστάθμισης</BeforeSetEndTimeAndOffsetTheRest> + <BeforeSetEndAndVideoPosition>Πριν ορισμού χρόνου λήξης στη θέση βίντεο και αυτόματος υπολογισμός έναρξης</BeforeSetEndAndVideoPosition> + <ContinueWithCurrentSpellCheck>Συνέχιση τρέχοντος ορθογραφικού ελέγχου;</ContinueWithCurrentSpellCheck> + <CharactersPerSecond>Χαρακτήρες/δευτ.: {0:0.00}</CharactersPerSecond> + <GetFrameRateFromVideoFile>Λήψη ρυθμού καρέ από αρχείο βίντεο</GetFrameRateFromVideoFile> + <NetworkMessage>Νέο μήνυμα: {0} ({1}): {2}</NetworkMessage> + <NetworkUpdate>Ενημέρωση γραμμής: {0} ({1}): Δείκτης={2}, Κείμενο={3}</NetworkUpdate> + <NetworkInsert>Εισαγωγή γραμμής: {0} ({1}): Δείκτης={2}, Κείμενο={3}</NetworkInsert> + <NetworkDelete>Διαγραφή γραμμής: {0} ({1}): Δείκτης={2}</NetworkDelete> + <NetworkNewUser>Νέος χρήστης: {0} ({1})</NetworkNewUser> + <NetworkByeUser>Αντίο {0} ({1})</NetworkByeUser> + <NetworkUnableToConnectToServer>Αδυναμία σύνδεσης με τον διακομιστή: {0}</NetworkUnableToConnectToServer> + <UserAndAction>Χρήστης/ενέργεια</UserAndAction> + <NetworkMode>Λειτουργία δικτύου</NetworkMode> + <XStartedSessionYAtZ>{0}: Έναρξη συνεδρίας {1} στο {2}</XStartedSessionYAtZ> + <OpenOtherSubtitle>Άνοιγμα άλλου υπότιτλου</OpenOtherSubtitle> + <BeforeToggleDialogDashes>Πριν την εναλλαγή παυλών διαλόγου</BeforeToggleDialogDashes> + <ExportPlainTextAs>Εξαγωγή απλού αρχείου κειμένου ως</ExportPlainTextAs> + <TextFiles>Αρχεία κειμένου</TextFiles> + <SubtitleExported>Εξαγωγή υποτίτλου</SubtitleExported> + <LineNumberXErrorReadingFromSourceLineY>Γραμμή {0} - σφάλμα ανάγνωσης: {1}</LineNumberXErrorReadingFromSourceLineY> + <LineNumberXErrorReadingTimeCodeFromSourceLineY>Γραμμή {0} - σφάλμα ανάγνωσης κώδικα χρόνου: {1}</LineNumberXErrorReadingTimeCodeFromSourceLineY> + <LineNumberXExpectedNumberFromSourceLineY>Γραμμή {0} - αναμενόμενος αριθμός υποτίτλου: {1}</LineNumberXExpectedNumberFromSourceLineY> + <LineNumberXExpectedEmptyLine>Γραμμή {0} - αναμενόμενη κενή γραμμή, αλλά βρέθηκε αριθμός + κώδικας χρόνου (παραλειπόμενος αριθμός): {1}</LineNumberXExpectedEmptyLine> + <BeforeGuessingTimeCodes>Πριν τον υπολογισμό κωδικών χρόνου</BeforeGuessingTimeCodes> + <BeforeAutoDuration>Πριν την αυτόματη διάρκεια επιλεγμένων γραμμών</BeforeAutoDuration> + <BeforeColumnPaste>Πριν την επικόλληση στήλης</BeforeColumnPaste> + <BeforeColumnDelete>Πριν την διαγραφή στήλης</BeforeColumnDelete> + <BeforeColumnImportText>Πριν την εισαγωγή κειμένου στήλης</BeforeColumnImportText> + <BeforeColumnShiftCellsDown>Πριν την μετατόπιση των κελιών στήλης προς τα κάτω</BeforeColumnShiftCellsDown> + <BeforeX>Πριν: {0}</BeforeX> + <LinesUpdatedX>Ενημερωμένες γραμμές: {0}</LinesUpdatedX> + <ErrorLoadingPluginXErrorY>Σφάλμα φόρτωσης πρόσθετου: {0}: {1}</ErrorLoadingPluginXErrorY> + <BeforeRunningPluginXVersionY>Πριν την εκτέλεση πρόσθετου: {0}: {1}</BeforeRunningPluginXVersionY> + <UnableToReadPluginResult>Αδυναμία ανάγνωσης αποτελέσματος υποτίτλου από το πρόσθετο!</UnableToReadPluginResult> + <UnableToCreateBackupDirectory>Αδυναμία δημιουργίας φακέλου αντίγραφου ασφαλείας {0}: {1}</UnableToCreateBackupDirectory> + <BeforeDisplaySubtitleJoin>Πριν την ένωση υποτίτλων</BeforeDisplaySubtitleJoin> + <SubtitlesJoined>Ένωση υποτίτλων</SubtitlesJoined> + <StatusLog>Κατάσταση αρχείου καταγραφής</StatusLog> + <XSceneChangesImported>Εισαγωγή {0} αλλαγής(ών) σκηνής</XSceneChangesImported> + <PluginXExecuted>Εκτέλεση πρόσθετου '{0}'.</PluginXExecuted> + <NotAValidXSubFile>Μη έγκυρο αρχείο XSub!</NotAValidXSubFile> + <BeforeMergeLinesWithSameText>Πριν από συγχώνευση γραμμών ίδιου κειμένου</BeforeMergeLinesWithSameText> + <ImportTimeCodesDifferentNumberOfLinesWarning>Ο υπότιτλος με τους κώδικες χρόνου έχει διαφορετικό αριθμό γραμμών ({0}) από τον τρέχων υπότιτλο ({1}) - Συνέχιση;</ImportTimeCodesDifferentNumberOfLinesWarning> + <ParsingTransportStream>Ανάλυση αρχείου TS - παρακαλώ, περιμένετε...</ParsingTransportStream> + <XPercentCompleted>{0}%</XPercentCompleted> + <NextX>Επόμενο: {0}</NextX> + <PromptInsertSubtitleOverlap>Η εισαγωγή υπότιτλου στη θέση κυματομορφής θα προκαλέσει επικάλυψη! +Συνέχιση;</PromptInsertSubtitleOverlap> + <SubtitleContainsNegativeDurationsX>Εύρεση αρνητικής διάρκειας γραμμής(ών): {0}</SubtitleContainsNegativeDurationsX> + <SetPlayRateX>Ορισμός ρυθμού αναπαραγωγής σε {0}%</SetPlayRateX> + <ErrorLoadIdx>Αδυναμία ανάγνωσης/επεξεργασίας αρχείων .idx. Τα αρχεία .idx είναι μέλη από τα ζεύγη idx/sub αρχείων (γνωστά ως VobSub) και ο Subtitle Edit δεν μπορεί να ανοίξει αρχείο .sub.</ErrorLoadIdx> + <ErrorLoadRar>Πιθανό συμπιεσμένο αρχείο .rar. Το Subtitle Edit δεν μπορεί να ανοίξει συμπιεσμένα αρχεία.</ErrorLoadRar> + <ErrorLoadZip>Πιθανό συμπιεσμένο αρχείο .zip. Το Subtitle Edit δεν μπορεί να ανοίξει συμπιεσμένα αρχεία.</ErrorLoadZip> + <ErrorLoad7Zip>Πιθανό συμπιεσμένο αρχείο 7-Zip. Το Subtitle Edit δεν μπορεί να ανοίξει συμπιεσμένα αρχεία.</ErrorLoad7Zip> + <ErrorLoadPng>Πιθανό αρχείο εικόνας PNG. Το Subtitle Edit δεν μπορεί να ανοίξει αρχεία PNG.</ErrorLoadPng> + <ErrorLoadJpg>Πιθανό αρχείο εικόνας JPG. Το Subtitle Edit δεν μπορεί να ανοίξει αρχεία JPG.</ErrorLoadJpg> + <ErrorLoadSrr>Πιθανό αρχείο .srr - όχι αρχείο υπότιτλου.</ErrorLoadSrr> + <ErrorLoadTorrent>Πιθανό αρχείο BitTorrent - όχι αρχείο υπότιτλου.</ErrorLoadTorrent> + <ErrorLoadBinaryZeroes>Συγγνώμη, το αρχείο περιέχει μόνο δυαδικά μηδενικά! +Αν είναι επεξεργασμένο με το Subtitle Edit, ίσως βρείτε αντίγραφο ασφαλείας μέσω της επιλογής Αρχείο -&gt; Επαναφορά αντίγραφου ασφαλείας...</ErrorLoadBinaryZeroes> + <ErrorDirectoryDropNotAllowed>Το σύρσιμο φακέλων δεν υποστηρίζεται.</ErrorDirectoryDropNotAllowed> + <NoSupportEncryptedVobSub>Το κρυπτογραφημένο περιεχόμενο VobSub δεν υποστηρίζεται.</NoSupportEncryptedVobSub> + <NoSupportHereBluRaySup>Τα αρχεία Blu-ray sup δεν υποστηρίζονται.</NoSupportHereBluRaySup> + <NoSupportHereDvdSup>Τα αρχεία DVD sup δεν υποστηρίζονται.</NoSupportHereDvdSup> + <NoSupportHereVobSub>Τα αρχεία VoSub δεν υποστηρίζονται.</NoSupportHereVobSub> + <NoSupportHereDivx>Τα αρχεία Divx δεν υποστηρίζονται.</NoSupportHereDivx> + <NoChapters>Αδυναμία εύρεσης κεφαλαίων βίντεο.</NoChapters> + </Main> + <MatroskaSubtitleChooser> + <Title>Επιλογή υπότιτλου από αρχείο Matroska</Title> + <TitleMp4>Επιλογή υπότιτλου από αρχείο MP4</TitleMp4> + <PleaseChoose>Βρέθηκαν περισσότεροι από έναν υπότιτλο - παρακαλώ, επιλέξτε</PleaseChoose> + <TrackXLanguageYTypeZ>Κομμάτι {0} - γλώσσα: {1} - τύπος: {2}</TrackXLanguageYTypeZ> + </MatroskaSubtitleChooser> + <MeasurementConverter> + <Title>Μετατροπέας μονάδων μέτρησης</Title> + <ConvertFrom>Μετατροπή από</ConvertFrom> + <ConvertTo>Μετατροπή σε</ConvertTo> + <CopyToClipboard>Αντιγραφή στο πρόχειρο</CopyToClipboard> + <Length>Μήκος</Length> + <Mass>Μάζα</Mass> + <Volume>Όγκος</Volume> + <Area>Έκταση</Area> + <Time>Χρόνος</Time> + <Temperature>Θερμοκρασία</Temperature> + <Velocity>Ταχύτητα</Velocity> + <Force>Ισχύς</Force> + <Energy>Ενέργεια</Energy> + <Power>Ρεύμα</Power> + <Pressure>Πίεση</Pressure> + <Kilometers>Χιλιόμετρα</Kilometers> + <Meters>Μέτρα</Meters> + <Centimeters>Εκατοστά</Centimeters> + <Millimeters>Χιλιοστά</Millimeters> + <Micrometers>Μικρόμετρα</Micrometers> + <Nanometers>Νανόμετρα</Nanometers> + <Angstroms>Άνγκστρομα</Angstroms> + <MilesTerrestial>Μίλια</MilesTerrestial> + <MilesNautical>Ναυτικά μίλια</MilesNautical> + <Yards>Γιάρδες</Yards> + <Feet>Πόδια</Feet> + <Inches>Ίντσες</Inches> + <Chains>Τσέιν (μήκος)</Chains> + <Fathoms>Οργιές</Fathoms> + <Hands>Δείκτες</Hands> + <Rods>Ράβδοι</Rods> + <Spans>Ανοίγματα</Spans> + <LongTonnes>Τόνοι (ΗΒ)</LongTonnes> + <ShortTonnes>Τόνοι (ΗΠΑ)</ShortTonnes> + <Tonnes>Τόνοι</Tonnes> + <Kilos>Κιλά</Kilos> + <Grams>Γραμμάρια</Grams> + <Milligrams>Χιλιόγραμμα</Milligrams> + <Micrograms>Μικρογραμμάρια</Micrograms> + <Pounds>Λίβρες</Pounds> + <Ounces>Ουγγιές</Ounces> + <Carats>Καράτια</Carats> + <Drams>Δράμια</Drams> + <Grains>Κόκοι</Grains> + <Stones>Κιλά (βάρος σώματος)</Stones> + <CubicKilometers>Κυβικά χιλιόμετρα</CubicKilometers> + <CubicMeters>Κυβικά μέτρα</CubicMeters> + <Litres>Λίτρα</Litres> + <CubicCentimeters>Κυβικά εκατοστά</CubicCentimeters> + <CubicMillimeters>Κυβικά χιλιοστά</CubicMillimeters> + <CubicMiles>Κυβικά μίλια</CubicMiles> + <CubicYards>Κυβικές γιάρδες</CubicYards> + <CubicFTs>Κυβικά πόδια</CubicFTs> + <CubicInches>Κυβικές ίντσες</CubicInches> + <OilBarrels>Βαρέλια πετρελαίου</OilBarrels> + <GallonUS>Γαλόνι (ΗΠΑ)</GallonUS> + <QuartsUS>Λίτρα (ΗΠΑ)</QuartsUS> + <PintsUS>Πίντες (ΗΠΑ)</PintsUS> + <FluidOuncesUS>Ουγγιές υγρών (ΗΠΑ)</FluidOuncesUS> + <Bushels>Μόδια</Bushels> + <Pecks>Πεκς (μονάδα μέτρησης στερεών)</Pecks> + <GallonsUK>Γαλόνια (ΗΒ)</GallonsUK> + <QuartsUK>Λίτρα (ΗΒ)</QuartsUK> + <PintsUK>Πίντες (ΗΒ)</PintsUK> + <FluidOuncesUK>Ουγγιές υγρών (ΗΒ)</FluidOuncesUK> + <SquareKilometers>Τετραγωνικά χιλιόμετρα</SquareKilometers> + <SquareMeters>Τετραγωνικά μέτρα</SquareMeters> + <SquareCentimeters>Τετραγωνικά εκατοστά</SquareCentimeters> + <SquareMillimeters>Τετραγωνικά χιλιοστά</SquareMillimeters> + <SquareMiles>Τετραγωνικά μίλια</SquareMiles> + <SquareYards>Τετραγωνικές γιάρδες</SquareYards> + <SquareFTs>Τετραγωνικά πόδια</SquareFTs> + <SquareInches>Τετραγωνικές ίντσες</SquareInches> + <Hectares>Εκτάρια</Hectares> + <Acres>Στρέμματα</Acres> + <Ares>Άρια</Ares> + <Hours>¨Ωρες</Hours> + <Minutes>Λεπτά</Minutes> + <Seconds>Δευτερόλεπτα</Seconds> + <Milliseconds>Χιλιοστά δευτερολέπτου</Milliseconds> + <Microseconds>Μικροδευτερόλεπτα</Microseconds> + <Fahrenheit>Φαρενάιτ</Fahrenheit> + <Celsius>Κελσίου</Celsius> + <Kelvin>Κέλβιν</Kelvin> + <KilometersPerHour>Χλμ/ώρα</KilometersPerHour> + <MetersPerSecond>Μέτρα/δευτερόλεπτο</MetersPerSecond> + <MilesPerHour>Μίλια/ώρα</MilesPerHour> + <YardsPerMinute>Γιάρδες/λεπτό</YardsPerMinute> + <FTsPerSecond>Πόδια/δευτερόλεπτο</FTsPerSecond> + <Knots>Κόμβοι</Knots> + <PoundsForce>Λίβρες ισχύος</PoundsForce> + <Newtons>Νιούτον</Newtons> + <KilosForce>Κιλά ισχύος</KilosForce> + <Jouls>Τζάουλ</Jouls> + <Calories>Θερμίδες</Calories> + <Ergs>Έργια</Ergs> + <ElectronVolts>Ηλεκτρονιοβόλτ</ElectronVolts> + <Btus>BTU</Btus> + <Watts>Βατ</Watts> + <Horsepower>Ιπποδύναμη</Horsepower> + <Atmospheres>Ατμόσφαιρες</Atmospheres> + <Bars>Μπαρ</Bars> + <Pascals>Πασκάλ</Pascals> + <MillimetersOfMercury>Χιλιοστά υδραργύρου (πίεση)</MillimetersOfMercury> + <PoundPerSquareInch>Λίβρες ισχύος ανά τετραγωνική ίντσα</PoundPerSquareInch> + <KilogramPerSquareCentimeter>Κιλά ισχύος ανά τετραγωνικό εκατοστό</KilogramPerSquareCentimeter> + <KiloPascals>Κιλοπασκάλ</KiloPascals> + </MeasurementConverter> + <MergeDoubleLines> + <Title>Συγχώνευση γραμμών με ίδιο κείμενο</Title> + <MaxMillisecondsBetweenLines>Μέγιστα χιλ. δευτερολέπτου μεταξύ των γραμμών</MaxMillisecondsBetweenLines> + <IncludeIncrementing>Συμπερίληψη προσαυξημένων γραμμών</IncludeIncrementing> + </MergeDoubleLines> + <MergedShortLines> + <Title>Συγχώνευση μικρών γραμμών</Title> + <MaximumCharacters>Μέγιστος αριθμός χαρακτήρων ανα παράγραφο</MaximumCharacters> + <MaximumMillisecondsBetween>Μέγιστος αριθμός χιλ. δευτερολέπτου μεταξύ των γραμμών</MaximumMillisecondsBetween> + <NumberOfMergesX>Σύνολο συγχωνεύσεων: {0}</NumberOfMergesX> + <MergedText>Συγχωνευμένο κείμενο</MergedText> + <OnlyMergeContinuationLines>Συγχώνευση μόνο συνεχόμενων γραμμών</OnlyMergeContinuationLines> + </MergedShortLines> + <MergeTextWithSameTimeCodes> + <Title>Συγχώνευση γραμμών με ίδιους κωδικούς χρόνου</Title> + <MaxDifferenceMilliseconds>Μέγιστη διαφορά χιλιοστών δευτερολέπτου</MaxDifferenceMilliseconds> + <ReBreakLines>Επαναδιάσπαση γραμμών</ReBreakLines> + <NumberOfMergesX>Αριθμός συγχωνεύσεων: {0}</NumberOfMergesX> + <MergedText>Συγχωνευμένο κείμενο</MergedText> + </MergeTextWithSameTimeCodes> + <ModifySelection> + <Title>Επεξεργασία επιλογής</Title> + <Rule>Κανόνας</Rule> + <CaseSensitive>Διάκριση πεζών</CaseSensitive> + <DoWithMatches>Ενέργεια με τις αντιστοιχίες</DoWithMatches> + <MakeNewSelection>Δημιουργία νέας επιλογής</MakeNewSelection> + <AddToCurrentSelection>Προσθήκη στην τρέχουσα επιλογή</AddToCurrentSelection> + <SubtractFromCurrentSelection>Αφαίρεση από την τρέχουσα επιλογή</SubtractFromCurrentSelection> + <IntersectWithCurrentSelection>Διασταύρωση με την τρέχουσα επιλογή</IntersectWithCurrentSelection> + <MatchingLinesX>Γραμμές που ταιριάζουν: {0}</MatchingLinesX> + <Contains>Περιέχει</Contains> + <StartsWith>Ξεκινά με</StartsWith> + <EndsWith>Τελειώνει με</EndsWith> + <NoContains>Δεν περιέχει</NoContains> + <RegEx>Τυπική έκφραση</RegEx> + <UnequalLines>Άνισες γραμμές</UnequalLines> + <EqualLines>Ίσες γραμμές</EqualLines> + <DurationLessThan>Διάρκεια μικρότερη από</DurationLessThan> + <DurationGreaterThan>Διάρκεια μεγαλύτερη από</DurationGreaterThan> + <MoreThanTwoLines>Πάνω από δύο γραμμές</MoreThanTwoLines> + </ModifySelection> + <MultipleReplace> + <Title>Πολλαπλή αντικατάσταση</Title> + <FindWhat>Εύρεση του</FindWhat> + <ReplaceWith>Αντικατάσταση με</ReplaceWith> + <Normal>Κανονική</Normal> + <CaseSensitive>Διάκριση πεζών-κεφαλαίων</CaseSensitive> + <RegularExpression>Τυπική έκφραση</RegularExpression> + <Description>Περιγραφή</Description> + <LinesFoundX>Γραμμές που βρέθηκαν: {0}</LinesFoundX> + <Remove>Αφαίρεση</Remove> + <Add>Προσθήκη</Add> + <Update>&amp;Ενημέρωση</Update> + <Enabled>Ενεργοποίηση</Enabled> + <SearchType>Τύπος αναζήτησης</SearchType> + <RemoveAll>Αφαίρεση όλων</RemoveAll> + <Import>Εισαγωγή...</Import> + <Export>Εξαγωγή...</Export> + <ImportRulesTitle>Εισαγωγή κανόνων αντικατάστασης από...</ImportRulesTitle> + <ExportRulesTitle>Εξαγωγή κανόνων αντικατάστασης σε...</ExportRulesTitle> + <ChooseGroupsToImport>Επιλογή ομάδων εισαγωγής</ChooseGroupsToImport> + <ChooseGroupsToExport>Επιλογή ομάδων εξαγωγής</ChooseGroupsToExport> + <Rules>Εξαγωγή κανόνων</Rules> + <MoveToTop>Νετακίνηση στην κορυφή</MoveToTop> + <MoveToBottom>Μετακίνηση στο τέλος</MoveToBottom> + <MoveSelectedRulesToGroup>Μετακίνηση επιλεγμένων κανόνων στην ομάδα</MoveSelectedRulesToGroup> + <Groups>Ομάδες</Groups> + <RulesForGroupX>Κανόνες ομάδας "{0}"</RulesForGroupX> + <GroupName>Όνομα ομάδας</GroupName> + <RenameGroup>Μετονομασία ομάδας...</RenameGroup> + <NewGroup>Νέα ομάδα...</NewGroup> + <NothingToImport>Τίποτα προς εισαγωγή</NothingToImport> + </MultipleReplace> + <NetworkChat> + <Title>Συνομιλία</Title> + <Send>Αποστολή</Send> + </NetworkChat> + <NetworkJoin> + <Title>Συμμετοχή σε δικτυακή συνεδρία</Title> + <Information>Συμμετοχή σε υπάρχουσα συνεδρία όπου πολλά άτομα +μπορούν να επεξεργαστούν το ίδιο αρχείο υπότιτλου (συνεργασία)</Information> + <Join>Συμμετοχή</Join> + </NetworkJoin> + <NetworkLogAndInfo> + <Title>Πληροφορίες και καταγραφή συνεδρίας</Title> + <Log>Αρχείο καταγραφής:</Log> + </NetworkLogAndInfo> + <NetworkStart> + <Title>Έναρξη δικτυακής συνεδρίας</Title> + <ConnectionTo>Σύνδεση με {0}...</ConnectionTo> + <Information>Έναρξη νέας συνεδρίας όπου πολλά άτομα +μπορούν να επεξεργαστούν το ίδιο αρχείο υπότιτλου (συνεργασία)</Information> + <Start>Έναρξη</Start> + </NetworkStart> + <OpenVideoDvd> + <Title>Άνοιγμα DVD με το VLC</Title> + <OpenDvdFrom>Άνοιγμα DVD με...</OpenDvdFrom> + <Disc>Δίσκος</Disc> + <Folder>Φάκελος</Folder> + <ChooseDrive>Επιλογή οδηγού</ChooseDrive> + <ChooseFolder>Επιλογή φακέλου</ChooseFolder> + </OpenVideoDvd> + <PluginsGet> + <Title>Πρόσθετα</Title> + <InstalledPlugins>Εγκαταστημένα πρόσθετα</InstalledPlugins> + <GetPlugins>Λήψη πρόσθετων</GetPlugins> + <Description>Περιγραφή</Description> + <Version>Έκδοση</Version> + <Date>Ημερομηνία</Date> + <Type>Τύπος</Type> + <OpenPluginsFolder>Άνοιγμα φακέλου 'Plugins'</OpenPluginsFolder> + <GetPluginsInfo1>Λήψη πρόσθετων του Subtitle Edit στον φάκελο 'Plugins'</GetPluginsInfo1> + <GetPluginsInfo2>Επιλογή πρόσθετου και κάντε κλικ στο 'Λήψη'</GetPluginsInfo2> + <PluginXDownloaded>Λήψη πρόσθετου {0}</PluginXDownloaded> + <Download>&amp;Λήψη</Download> + <Remove>&amp;Αφαίρεση</Remove> + <UpdateAllX>Ενημέρωση όλων ({0})</UpdateAllX> + <UnableToDownloadPluginListX>Αδυναμία λήψης λίστας πρόσθετων: {0}</UnableToDownloadPluginListX> + <NewVersionOfSubtitleEditRequired>Απαιτείται νεότερη έκδοση του Subtitle Edit!</NewVersionOfSubtitleEditRequired> + <UpdateAvailable>[Διαθέσιμη ενημέρωση!]</UpdateAvailable> + <UpdateAll>Ενημέρωση όλων</UpdateAll> + <XPluginsUpdated>{0} πρόσθετο/α ενημερώθηκαν</XPluginsUpdated> + </PluginsGet> + <RegularExpressionContextMenu> + <WordBoundary>Όριο λέξης (\b)</WordBoundary> + <NonWordBoundary>Δίχως όριο λέξης (\B)</NonWordBoundary> + <NewLine>Νέα γραμμή (\r\n)</NewLine> + <NewLineShort>Νέα γραμμή (\n)</NewLineShort> + <AnyDigit>Οποιοδήποτε ψηφίο (\d)</AnyDigit> + <NonDigit>Μη ψηφίο (\D)</NonDigit> + <AnyCharacter>Οποιοσδήποτε χαρακτήρας (.)</AnyCharacter> + <AnyWhitespace>Οποιοδήποτε κενό (\s)</AnyWhitespace> + <NonSpaceCharacter>Μη χαρακτήρας κενού (\S)</NonSpaceCharacter> + <ZeroOrMore>Μηδέν ή περισσότερα (*)</ZeroOrMore> + <OneOrMore>Ένα ή περισσότερα (+)</OneOrMore> + <InCharacterGroup>Στο σύνολο χαρακτήρων ([δοκιμή])</InCharacterGroup> + <NotInCharacterGroup>Όχι στο σύνολο χαρακτήρων ([^δοκιμή])</NotInCharacterGroup> + </RegularExpressionContextMenu> + <RemoveTextFromHearImpaired> + <Title>Αφαίρεση κειμένου για κωφούς</Title> + <RemoveTextConditions>Αφαίρεση συνθηκών κειμένου</RemoveTextConditions> + <RemoveTextBetween>Αφαίρεση κειμένου μεταξύ</RemoveTextBetween> + <SquareBrackets>'[' και ']'</SquareBrackets> + <Brackets>'{' και '}'</Brackets> + <Parentheses>'(' και ')'</Parentheses> + <QuestionMarks>'?' και '?'</QuestionMarks> + <And>και</And> + <RemoveTextBeforeColon>Αφαίρεση κειμένου πριν άνω και κάτω τελείας (':')</RemoveTextBeforeColon> + <OnlyIfTextIsUppercase>Μόνο κείμενο σε κεφαλαία</OnlyIfTextIsUppercase> + <OnlyIfInSeparateLine>Μόνο σε ξεχωριστή γραμμή</OnlyIfInSeparateLine> + <LinesFoundX>Εύρεση γραμμής(ών): {0}</LinesFoundX> + <RemoveTextIfContains>Αφαίρεση κειμένου εάν περιέχει:</RemoveTextIfContains> + <RemoveTextIfAllUppercase>Αφαίρεση γραμμής με κεφαλαία</RemoveTextIfAllUppercase> + <RemoveInterjections>Αφαίρεση επιφωνημάτων</RemoveInterjections> + <EditInterjections>Επεξεργασία...</EditInterjections> + </RemoveTextFromHearImpaired> + <ReplaceDialog> + <Title>Αντικατάσταση</Title> + <FindWhat>Εύρεση του:</FindWhat> + <Normal>Κανονική</Normal> + <CaseSensitive>Διάκριση πεζών-κεφαλαίων</CaseSensitive> + <RegularExpression>Τυπική έκφραση</RegularExpression> + <ReplaceWith>Αντικατάσταση με</ReplaceWith> + <Find>&amp;Εύρεση</Find> + <Replace>&amp;Αντικατάσταση</Replace> + <ReplaceAll>Αντικατάσταση ό&amp;λων</ReplaceAll> + </ReplaceDialog> + <RestoreAutoBackup> + <Title>Επαναφορά αντιγράφων ασφαλείας</Title> + <Information>Άνοιγμα αντιγράφων ασφαλείας</Information> + <DateAndTime>Ημερομηνία</DateAndTime> + <FileName>Όνομα αρχείου</FileName> + <Extension>Επέκταση</Extension> + <NoBackedUpFilesFound>Αδυναμία εύρεσης αντιγράφων ασφαλείας!</NoBackedUpFilesFound> + </RestoreAutoBackup> + <SeekSilence> + <Title>Αναζήτηση σιωπής</Title> + <SearchDirection>Κατεύθυνση αναζήτησης</SearchDirection> + <Forward>Εμπρός</Forward> + <Back>Πίσω</Back> + <LengthInSeconds>Ελάχιστη σιωπή (δευτερόλεπτα)</LengthInSeconds> + <MaxVolume>Ένταση ήχου κάτω από</MaxVolume> + </SeekSilence> + <SetMinimumDisplayTimeBetweenParagraphs> + <Title>Ορισμός ελάχιστου κενού υπότίτλων</Title> + <PreviewLinesModifiedX>Προεπισκόπηση - τροποποιημένοι υπότιτλοι: {0}</PreviewLinesModifiedX> + <ShowOnlyModifiedLines>Εμφάνιση μόνο τροποποιημένων γραμμών</ShowOnlyModifiedLines> + <MinimumMillisecondsBetweenParagraphs>Ελάχιστα χιλ. δευτερολέπτου μεταξύ γραμμών</MinimumMillisecondsBetweenParagraphs> + <FrameInfo>Πληροφορίες ρυθμού καρέ</FrameInfo> + <Frames>Καρέ</Frames> + <XFrameYisZMilliseconds>{0} καρέ στα {1} καρέ/δευτερόλεπτο είναι {2} χιλ. του δευτερολέπτου</XFrameYisZMilliseconds> + </SetMinimumDisplayTimeBetweenParagraphs> + <SetSyncPoint> + <Title>Ορισμός σημείου συγχρονισμού για τη γραμμή {0}</Title> + <SyncPointTimeCode>Κωδικός χρόνου σημείου συγχρονισμού</SyncPointTimeCode> + <ThreeSecondsBack>&lt;&lt; 3 δευτ.</ThreeSecondsBack> + <HalfASecondBack>&lt;&lt; ½ δευτ.</HalfASecondBack> + <HalfASecondForward>½ δευτ. &gt;&gt;</HalfASecondForward> + <ThreeSecondsForward>3 δευτ. &gt;&gt;</ThreeSecondsForward> + </SetSyncPoint> + <Settings> + <Title>Ρυθμίσεις</Title> + <General>Γενικά</General> + <Toolbar>Γραμμή εργαλείων</Toolbar> + <VideoPlayer>Πρόγραμμα αναπαραγωγής</VideoPlayer> + <WaveformAndSpectrogram>Κυματομορφή/φασματογράφημα</WaveformAndSpectrogram> + <Tools>Εργαλεία</Tools> + <WordLists>Λίστες λέξεων</WordLists> + <SsaStyle>Στυλ ASS/SSA</SsaStyle> + <Network>Δίκτυο</Network> + <Rules>Κανόνες</Rules> + <ShowToolBarButtons>Εμφάνιση κουμπιών της γραμμής εργαλείων</ShowToolBarButtons> + <New>Νέο</New> + <Open>Άνοιγμα</Open> + <Save>Αποθήκευση</Save> + <SaveAs>Αποθήκευση ως</SaveAs> + <Find>Εύρεση</Find> + <Replace>Αντικατάσταση</Replace> + <VisualSync>Οπτικός συγχρονισμός</VisualSync> + <SpellCheck>Ορθογραφικός έλεγχος</SpellCheck> + <NetflixQualityCheck>Έλεγχος ποιότητας Netflix</NetflixQualityCheck> + <SettingsName>Ρυθμίσεις</SettingsName> + <Help>Βοήθεια</Help> + <UnbreakNoSpace>Συνένωση χωρίς κενό (CJK)</UnbreakNoSpace> + <ToggleBookmarks>Εναλλαγή σημειώσεων</ToggleBookmarks> + <ToggleBookmarksWithComment>Εναλλαγή σημειώσεων - προσθήκη σχόλιου</ToggleBookmarksWithComment> + <ClearBookmarks>Καθαρισμός σημειώσεων</ClearBookmarks> + <GoToBookmark>Μετάβαση σε σημείωση</GoToBookmark> + <GoToPreviousBookmark>Προηγούμενη σημείωση</GoToPreviousBookmark> + <GoToNextBookmark>Επόμενη σημείωση</GoToNextBookmark> + <ChooseProfile>Επιλογή προφίλ</ChooseProfile> + <DuplicateLine>Αντιγραφή γραμμής</DuplicateLine> + <FontInUi>Γραμματοσειρά γραφικού περιβάλλοντος</FontInUi> + <ShowFrameRate>Εμφάνιση ρυθμού καρέ στη γραμμή εργαλείων</ShowFrameRate> + <DefaultFrameRate>Προεπιλεγμένος ρυθμός καρέ</DefaultFrameRate> + <DefaultFileEncoding>Προεπιλεγμένη κωδικοποίηση</DefaultFileEncoding> + <AutoDetectAnsiEncoding>Ανίχνευση κωδικοποίησης ANSI</AutoDetectAnsiEncoding> + <Profile>Προφίλ</Profile> + <Profiles>Προφίλ</Profiles> + <ImportProfiles>Εισαγωγή</ImportProfiles> + <ExportProfiles>Εξαγωγή</ExportProfiles> + <SubtitleLineMaximumLength>Μέγιστο μήκος γραμμής</SubtitleLineMaximumLength> + <OptimalCharactersPerSecond>Βέλτιστοι χαρακτήρες/δευτερόλεπτο</OptimalCharactersPerSecond> + <MaximumCharactersPerSecond>Μέγιστοι χαρακτήρες/δευτερόλεπτο</MaximumCharactersPerSecond> + <MaximumWordssPerMinute>Μέγιστος αριθμός λέξεων/λεπτό</MaximumWordssPerMinute> + <AutoWrapWhileTyping>Αυτόματη διάσπαση</AutoWrapWhileTyping> + <DurationMinimumMilliseconds>Ελάχιστη διάρκεια, χιλ. δευτερολέπτου</DurationMinimumMilliseconds> + <DurationMaximumMilliseconds>Μέγιστη διάρκεια, χιλ. δευτερολέπτου</DurationMaximumMilliseconds> + <MinimumGapMilliseconds>Ελάχιστο κενό σε χιλ. δευτ.</MinimumGapMilliseconds> + <MaximumLines>Μέγιστος αριθμός γραμμών</MaximumLines> + <SubtitleFont>Γραμματοσειρά υποτίτλου</SubtitleFont> + <SubtitleFontSize>Μέγεθος γραμματοσειράς</SubtitleFontSize> + <SubtitleBold>Έντονα</SubtitleBold> + <VideoAutoOpen>Αυτόματο άνοιγμα βίντεο με υπότιτλο</VideoAutoOpen> + <AllowVolumeBoost>Ώθηση ήχου</AllowVolumeBoost> + <SubtitleCenter>Κέντρο</SubtitleCenter> + <SubtitleFontColor>Χρώμα γραμματοσειράς υποτίτλου</SubtitleFontColor> + <SubtitleBackgroundColor>Χρώμα φόντου υποτίτλου</SubtitleBackgroundColor> + <SpellChecker>Ορθογραφικός έλεγκτής</SpellChecker> + <RememberRecentFiles>Εμφάνιση πρόσφατων αρχείων</RememberRecentFiles> + <StartWithLastFileLoaded>Έναρξη με φόρτωση τελευταίου αρχείου</StartWithLastFileLoaded> + <RememberSelectedLine>Απομνημόνευση γραμμής</RememberSelectedLine> + <RememberPositionAndSize>Απομνημόνευση θέσης και μεγέθους κύριου παραθύρου</RememberPositionAndSize> + <StartInSourceView>Έναρξη σε προβολή πηγής</StartInSourceView> + <RemoveBlankLinesWhenOpening>Αφαίρεση κενών γραμμών κατά το άνοιγμα</RemoveBlankLinesWhenOpening> + <ShowLineBreaksAs>Εμφάνιση διασπάσεων σε προβολή λίστας ως</ShowLineBreaksAs> + <SaveAsFileNameFrom>Η "Αποθήκευση ως..." έχει το όνομα από</SaveAsFileNameFrom> + <MainListViewDoubleClickAction>Ενέργεια διπλού κλικ σε γραμμή στο κύριο παράθυρο προβολής λίστας</MainListViewDoubleClickAction> + <MainListViewColumnsInfo>Επιλογή ορατής λίστας προβολής στηλών</MainListViewColumnsInfo> + <MainListViewNothing>Τίποτα</MainListViewNothing> + <MainListViewVideoGoToPositionAndPause>Μετάβαση σε θέση βίντεο και παύση</MainListViewVideoGoToPositionAndPause> + <MainListViewVideoGoToPositionAndPlay>Μετάβαση σε θέση βίντεο και αναπαραγωγή</MainListViewVideoGoToPositionAndPlay> + <MainListViewEditText>Μετάβαση στο πλαίσιο επεξεργασίας κειμένου</MainListViewEditText> + <MainListViewVideoGoToPositionMinus1SecAndPause>Πήγαινε στη θέση βίντεο - 1 δευτ. και παύση</MainListViewVideoGoToPositionMinus1SecAndPause> + <MainListViewVideoGoToPositionMinusHalfSecAndPause>Πήγαινε στη θέση βίντεο - 0.5 δευτ. και παύση</MainListViewVideoGoToPositionMinusHalfSecAndPause> + <MainListViewVideoGoToPositionMinus1SecAndPlay>Πήγαινε στη θέση βίντεο - 1 δευτ. και αναπαραγωγή</MainListViewVideoGoToPositionMinus1SecAndPlay> + <MainListViewEditTextAndPause>Μετάβαση σε επεξαργασία πλαίσιου κειμένου και παύση στη θέση</MainListViewEditTextAndPause> + <VideoFileName>Όνομα αρχείου βίντεο</VideoFileName> + <ExistingFileName>Υπάρχον όνομα</ExistingFileName> + <AutoBackup>Aντίγραφα ασφαλείας</AutoBackup> + <AutoBackupEveryMinute>Κάθε 1 λεπτό</AutoBackupEveryMinute> + <AutoBackupEveryFiveMinutes>Κάθε 5 λεπτά</AutoBackupEveryFiveMinutes> + <AutoBackupEveryFifteenMinutes>Κάθε 15 λεπτά</AutoBackupEveryFifteenMinutes> + <AutoBackupDeleteAfter>Διαγραφή σε</AutoBackupDeleteAfter> + <AutoBackupDeleteAfterOneMonth>1 μήνα</AutoBackupDeleteAfterOneMonth> + <AutoBackupDeleteAfterThreeMonths>3 μήνες</AutoBackupDeleteAfterThreeMonths> + <AutoBackupDeleteAfterSixMonths>6 μήνες</AutoBackupDeleteAfterSixMonths> + <CheckForUpdates>Έλεγχος ενημερώσεων</CheckForUpdates> + <AutoSave>Αυτόματη αποθήκευση</AutoSave> + <AllowEditOfOriginalSubtitle>Να επιτρέπεται η επεξεργασία του αρχικού υπότιτλου</AllowEditOfOriginalSubtitle> + <PromptDeleteLines>Ερώτηση για διαγραφή γραμμών</PromptDeleteLines> + <TimeCodeMode>Ύφος κωδικοποίησης χρόνου</TimeCodeMode> + <TimeCodeModeHHMMSSMS>ΩΩ:ΛΛ:ΔΔ.ΧΔ (00:00:01.500)</TimeCodeModeHHMMSSMS> + <TimeCodeModeHHMMSSFF>ΩΩ:ΛΛ:ΔΔ:ΚΚ (00:00:01:12)</TimeCodeModeHHMMSSFF> + <SplitBehavior>Συμπεριφορά διαχωρισμού</SplitBehavior> + <SplitBehaviorPrevious>Προσθήκη κενού αριστερά του σημείου διαχωρισμού</SplitBehaviorPrevious> + <SplitBehaviorHalf>Προσθήκη κενού κεντρικά του σημείου διαχωρισμού</SplitBehaviorHalf> + <SplitBehaviorNext>Προσθήκη κενού δεξιά του σημείου διαχωρισμού</SplitBehaviorNext> + <VideoEngine>Μηχανισμός απόδοσης βίντεο</VideoEngine> + <DirectShow>DirectShow</DirectShow> + <DirectShowDescription>quartz.dll στον φάκελο system32</DirectShowDescription> + <MpcHc>MPC-HC</MpcHc> + <MpcHcDescription>Media Player Classic - Home Cinema</MpcHcDescription> + <MpvPlayer>mpv</MpvPlayer> + <MpvPlayerDescription>https://mpv.io</MpvPlayerDescription> + <MpvHandlesPreviewText>Προεπισκόπηση κειμένου από mpv</MpvHandlesPreviewText> + <VlcMediaPlayer>VLC media player</VlcMediaPlayer> + <VlcMediaPlayerDescription>libvlc.dll από VLC media player 1.1.0 ή νεότερο</VlcMediaPlayerDescription> + <VlcBrowseToLabel>Διαδρομή του VLC (μόνο για τη φορητή έκδοση VLC)</VlcBrowseToLabel> + <ShowStopButton>Εμφάνιση κουμπιού διακοπής</ShowStopButton> + <ShowMuteButton>Εμφάνιση κουμπιού σίγασης</ShowMuteButton> + <ShowFullscreenButton>Εμφάνιση κουμπιού πλήρους οθόνης</ShowFullscreenButton> + <PreviewFontSize>Μέγεθος γραμματοσειράς προεπισκόπησης υπότιτλου</PreviewFontSize> + <MainWindowVideoControls>Στοιχεία ελέγχου βίντεο κύριου παραθύρου</MainWindowVideoControls> + <CustomSearchTextAndUrl>Προσαρμοσμένη αναζήτηση κειμένου και διεύθυνσης URL</CustomSearchTextAndUrl> + <WaveformAppearance>Όψη κυματομορφής</WaveformAppearance> + <WaveformGridColor>Χρώμα πλέγματος</WaveformGridColor> + <WaveformShowGridLines>Εμφάνιση γραμμών πλέγματος</WaveformShowGridLines> + <WaveformShowCps>Εμφάνιση χαρ/δευτ</WaveformShowCps> + <WaveformShowWpm>Εμφάνιση λέξεων/λεπτό</WaveformShowWpm> + <ReverseMouseWheelScrollDirection>Εναλλαγή κατεύθυνσης κύλισης με τη ρόδα του ποντικιού</ReverseMouseWheelScrollDirection> + <WaveformAllowOverlap>Να επιτρέπεται η επικάλυψη (κατά τη μετακίνηση/αλλαγή μεγέθους)</WaveformAllowOverlap> + <WaveformSetVideoPosMoveStartEnd>Καθορισμός θέσης βίντεο κατά τη μετακίνηση αρχής/λήξης</WaveformSetVideoPosMoveStartEnd> + <WaveformFocusMouseEnter>Καθορισμός εστίασης όταν το ποντίκι εισέρχεται</WaveformFocusMouseEnter> + <WaveformListViewFocusMouseEnter>Επίσης καθορίστε την εστίαση στην προβολή λίστας, όταν το ποντίκι εισέρχεται στην προβολή λίστας</WaveformListViewFocusMouseEnter> + <WaveformSingleClickSelect>Μονό κλικ επιλογής υπότιτλου</WaveformSingleClickSelect> + <WaveformSnapToSceneChanges>Εικόνα για την αλλαγή σκηνών (κράτημα Shift για παράκαμψη)</WaveformSnapToSceneChanges> + <WaveformBorderHitMs1>Το χτύπημα του πλαισίου σήμανσης πρέπει να βρίσκεται μεταξύ</WaveformBorderHitMs1> + <WaveformBorderHitMs2>χιλιοστά δευτερολέπτου</WaveformBorderHitMs2> + <WaveformColor>Χρώμα</WaveformColor> + <WaveformSelectedColor>Επιλεγμένο χρώμα</WaveformSelectedColor> + <WaveformBackgroundColor>Χρώμα φόντου</WaveformBackgroundColor> + <WaveformCursorColor>Χρώμα δείκτη</WaveformCursorColor> + <WaveformTextColor>Χρώμα κειμένου</WaveformTextColor> + <WaveformTextFontSize>Μέγεθος γραμματοσειράς κειμένου</WaveformTextFontSize> + <WaveformAndSpectrogramsFolderEmpty>Άδειασμα φακέλων 'Spectrograms' και 'Waveforms'</WaveformAndSpectrogramsFolderEmpty> + <WaveformAndSpectrogramsFolderInfo>Οι φάκελοι 'Waveforms' και 'Spectrograms' περιέχουν {0} αρχεία ({1:0.00} MB)</WaveformAndSpectrogramsFolderInfo> + <Spectrogram>Φασματογράφημα</Spectrogram> + <GenerateSpectrogram>Δημιουργία φασματογράμματος</GenerateSpectrogram> + <SpectrogramAppearance>Όψη φασματογράμματος</SpectrogramAppearance> + <SpectrogramOneColorGradient>Διαβάθμιση ενός χρώματος</SpectrogramOneColorGradient> + <SpectrogramClassic>Κλασικό</SpectrogramClassic> + <WaveformUseFFmpeg>Χρήση FFmpeg για εξαγωγή κυματομορφής</WaveformUseFFmpeg> + <DownloadFFmpeg>Λήψη FFmpeg</DownloadFFmpeg> + <WaveformFFmpegPath>Διαδρομή του FFmpeg</WaveformFFmpegPath> + <WaveformBrowseToFFmpeg>Περιήγηση για FFmpeg</WaveformBrowseToFFmpeg> + <WaveformBrowseToVLC>Περιήγηση για φορητό VLC</WaveformBrowseToVLC> + <SubStationAlphaStyle>Στυλ Sub Station Alpha</SubStationAlphaStyle> + <ChooseColor>Επιλογή χρώματος</ChooseColor> + <SsaOutline>Περίγραμμα</SsaOutline> + <SsaShadow>Σκιά</SsaShadow> + <SsaOpaqueBox>Αδιαφανές κουτί</SsaOpaqueBox> + <Testing123>Δοκιμή 123...</Testing123> + <Language>Γλώσσα</Language> + <NamesIgnoreLists>Λίστα ονομάτων/παραλείψεων (διάκριση πεζών-κεφαλαίων)</NamesIgnoreLists> + <AddName>Προσθήκη ονόματος</AddName> + <AddWord>Προσθήκη λέξης</AddWord> + <Remove>Αφαίρεση</Remove> + <AddPair>Προσθήκη ζευγαριού</AddPair> + <UserWordList>Λίστα λέξεων χρήστη</UserWordList> + <OcrFixList>Λίστα επιδιορθώσεων OCR</OcrFixList> + <Location>Τοποθεσία</Location> + <UseOnlineNames>Χρήση διαδικτυακού αρχείου xml ονομάτων</UseOnlineNames> + <WordAddedX>Λέξη προστέθηκε: {0}</WordAddedX> + <WordAlreadyExists>Υπάρχουσα λέξη!</WordAlreadyExists> + <WordNotFound>Η λέξη δεν βρέθηκε</WordNotFound> + <RemoveX>Αφαίρεση του {0};</RemoveX> + <CannotUpdateNamesOnline>Αδυναμία ενημέρωσης του διαδικτυακού xml ονομάτων!</CannotUpdateNamesOnline> + <ProxyServerSettings>Ρυθμίσεις διακομιστή μεσολάβησης</ProxyServerSettings> + <ProxyAddress>Διεύθυνση διακομιστή μεσολάβησης</ProxyAddress> + <ProxyAuthentication>Επικύρωση</ProxyAuthentication> + <ProxyUserName>Όνομα χρήστη</ProxyUserName> + <ProxyPassword>Κωδικός</ProxyPassword> + <ProxyDomain>Τομέας</ProxyDomain> + <NetworkSessionSettings>Ρυθμίσεις συνεδρίας δικτύου</NetworkSessionSettings> + <NetworkSessionNewSound>Αναπαραγωγή ήχου νέων μηνυμάτων</NetworkSessionNewSound> + <PlayXSecondsAndBack>Αναπαραγωγή Χ δευτερολέπτων και πίσω, το Χ είναι</PlayXSecondsAndBack> + <StartSceneIndex>Η αρχική παράγραφος σκηνής είναι</StartSceneIndex> + <EndSceneIndex>Η τελική παράγραφος σκηνής είναι</EndSceneIndex> + <FirstPlusX>Αρχή + {0}</FirstPlusX> + <LastMinusX>Τέλος - {0}</LastMinusX> + <FixCommonerrors>Επιδιόρθωση κοινών σφαλμάτων</FixCommonerrors> + <RemoveTextForHi>Αφαίρεση κειμένου για κωφούς</RemoveTextForHi> + <MergeLinesShorterThan>Συνένωση γραμμών μικρότερες από</MergeLinesShorterThan> + <DialogStyle>Στυλ διαλόγου</DialogStyle> + <DialogStyleDashBothLinesWithSpace>Παύλες με κενό</DialogStyleDashBothLinesWithSpace> + <DialogStyleDashBothLinesWithoutSpace>Παύλες χωρίς κενό</DialogStyleDashBothLinesWithoutSpace> + <DialogStyleDashSecondLineWithSpace>Μία παύλα με κενό</DialogStyleDashSecondLineWithSpace> + <DialogStyleDashSecondLineWithoutSpace>Δεύτερη γραμμή χωρίς κενό</DialogStyleDashSecondLineWithoutSpace> + <ContinuationStyle>Στυλ συνέχισης</ContinuationStyle> + <ContinuationStyleNone>Χωρίς</ContinuationStyleNone> + <ContinuationStyleNoneTrailingDots>Χωρίς, αποσιωπητικά για παύσεις (μόνο συνέχιση)</ContinuationStyleNoneTrailingDots> + <ContinuationStyleNoneLeadingTrailingDots>Χωρίς, αποσιωπητικά για παύσεις</ContinuationStyleNoneLeadingTrailingDots> + <ContinuationStyleOnlyTrailingDots>Αποσιωπητικά (μόνο συνέχιση)</ContinuationStyleOnlyTrailingDots> + <ContinuationStyleLeadingTrailingDots>Αποσιωπητικά</ContinuationStyleLeadingTrailingDots> + <ContinuationStyleLeadingTrailingDash>Παύλα</ContinuationStyleLeadingTrailingDash> + <ContinuationStyleLeadingTrailingDashDots>Παύλα, αποσιωπητικά για παύσεις</ContinuationStyleLeadingTrailingDashDots> + <MusicSymbol>Μουσικό σύμβολο</MusicSymbol> + <MusicSymbolsReplace>Αντικατάσταση μουσικών συμβόλων (χωρισμένα με κόμμα)</MusicSymbolsReplace> + <FixCommonOcrErrorsUseHardcodedRules>Επιδιόρθωση κοινών σφαλμάτων OCR - χρήση ενσωματωμένων κανόνων</FixCommonOcrErrorsUseHardcodedRules> + <FixCommonerrorsFixShortDisplayTimesAllowMoveStartTime>Επιδιόρθωση του σύντομου χρόνου εμφάνισης - αλλαγή χρόνου έναρξης</FixCommonerrorsFixShortDisplayTimesAllowMoveStartTime> + <FixCommonErrorsSkipStepOne>Παράβλεψη πρώτου βήματος (προκαθορισμένες επιλογές)</FixCommonErrorsSkipStepOne> + <Shortcuts>Συντομεύσεις</Shortcuts> + <Shortcut>Συντόμευση</Shortcut> + <Control>Ctrl</Control> + <Alt>Alt</Alt> + <Shift>Shift</Shift> + <Key>Πλήκτρο</Key> + <ListViewAndTextBox>Προβολή λίστας και πλαισίου κειμένου</ListViewAndTextBox> + <ListView>Προβολή λίστας</ListView> + <TextBox>Πλαίσιο κειμένου</TextBox> + <UseSyntaxColoring>Χρήση χρωματισμού σύνταξης</UseSyntaxColoring> + <HtmlColor>Χρώμα HTML</HtmlColor> + <AssaColor>Χρώμα ASSA</AssaColor> + <UpdateShortcut>Ενημέρωση</UpdateShortcut> + <FoucsSetVideoPosition>Εστίαση ορισμού θέσης βίντεο</FoucsSetVideoPosition> + <ToggleDockUndockOfVideoControls>Εναλλαγή αγκύστρωσης/απαγκύστρωσης των στοιχείων ελέγχου βίντεο</ToggleDockUndockOfVideoControls> + <CreateSetEndAddNewAndGoToNew>Ορισμός τέλους, προσθήκη νέου και μετάβαση</CreateSetEndAddNewAndGoToNew> + <AdjustViaEndAutoStart>Προσαρμογή μέσω τελικής θέσης</AdjustViaEndAutoStart> + <AdjustViaEndAutoStartAndGoToNext>Προσαρμογή μέσω τελικής θέσης και επόμενο</AdjustViaEndAutoStartAndGoToNext> + <AdjustSetEndTimeAndGoToNext>Ορισμός λήξης και επόμενο</AdjustSetEndTimeAndGoToNext> + <AdjustSetEndTimeAndPause>Ορισμός λήξης και παύση</AdjustSetEndTimeAndPause> + <AdjustSetStartAutoDurationAndGoToNext>Προσαρμογή μέσω αρχικής θέσης και επόμενο</AdjustSetStartAutoDurationAndGoToNext> + <AdjustSetEndNextStartAndGoToNext>Ορισμός λήξης, έναρξη επομένου εκκίνηση και επόμενο</AdjustSetEndNextStartAndGoToNext> + <AdjustStartDownEndUpAndGoToNext>Κάτω βέλος = ορισμός έναρξης, Πάνω βέλος = ορισμός λήξης και μετάβαση σε επόμενο</AdjustStartDownEndUpAndGoToNext> + <AdjustSetStartAndEndOfPrevious>Ορισμός έναρξης και λήξης προηγούμενου (πλην ελάχιστο κενό)</AdjustSetStartAndEndOfPrevious> + <AdjustSetStartAndEndOfPreviousAndGoToNext>Ορισμός έναρξης και λήξης προηγούμενου και μετάβαση σε επόμενο (πλην ελάχιστο κενό)</AdjustSetStartAndEndOfPreviousAndGoToNext> + <AdjustSelected100MsForward>Μετακίνηση γραμμών 100 χιλ. δ. εμπρός</AdjustSelected100MsForward> + <AdjustSelected100MsBack>Μετακίνηση γραμμών 100 χιλ. δ. πίσω</AdjustSelected100MsBack> + <AdjustStartXMsBack>Μετακίνηση αρχής {0} χιλ. δ. πίσω</AdjustStartXMsBack> + <AdjustStartXMsForward>Μετακίνηση αρχής {0} χιλ. δ. εμπρός</AdjustStartXMsForward> + <AdjustEndXMsBack>Μετακίνηση λήξης {0} χιλ. δ. πίσω</AdjustEndXMsBack> + <AdjustEndXMsForward>Μετακίνηση λήξης {0} χιλ. δ. εμπρός</AdjustEndXMsForward> + <AdjustStartOneFrameBack>Μετακίνηση αρχής 1 καρέ πίσω</AdjustStartOneFrameBack> + <AdjustStartOneFrameForward>Μετακίνηση αρχής 1 καρέ εμπρός</AdjustStartOneFrameForward> + <AdjustEndOneFrameBack>Μετακίνηση λήξης 1 καρέ πίσω</AdjustEndOneFrameBack> + <AdjustEndOneFrameForward>Μετακίνηση λήξης 1 καρέ εμπρός</AdjustEndOneFrameForward> + <AdjustStartOneFrameBackKeepGapPrev>Μετακίνηση αρχής 1 καρέ πίσω (κράτημα κενού στο προηγούμενο)</AdjustStartOneFrameBackKeepGapPrev> + <AdjustStartOneFrameForwardKeepGapPrev>Μετακίνηση αρχής 1 καρέ εμπρός (κράτημα κενού στο προηγούμενο)</AdjustStartOneFrameForwardKeepGapPrev> + <AdjustEndOneFrameBackKeepGapNext>Μετακίνηση λήξης 1 καρέ πίσω (κράτημα κενού στο επόμενο)</AdjustEndOneFrameBackKeepGapNext> + <AdjustEndOneFrameForwardKeepGapNext>Μετακίνηση λήξης 1 καρέ εμπρός (κράτημα κενού στο επόμενο)</AdjustEndOneFrameForwardKeepGapNext> + <AdjustSetStartTimeKeepDuration>Ορισμός έναρξης, διατήρηση διάρκειας</AdjustSetStartTimeKeepDuration> + <AdjustSetEndAndOffsetTheRest>Ορισμός τέλους, αντιστάθμιση υπολοίπων</AdjustSetEndAndOffsetTheRest> + <AdjustSetEndAndOffsetTheRestAndGoToNext>Ορισμός τέλους, αντιστάθμιση υπολοίπων και μετάβαση σε επόμενο</AdjustSetEndAndOffsetTheRestAndGoToNext> + <AdjustSnapStartToNextSceneChange>Σπάσιμο έναρξης γραμμής σε επόμενη αλλαγή σκηνής</AdjustSnapStartToNextSceneChange> + <AdjustSnapStartToNextSceneChangeWithGap>Σπάσιμο έναρξης γραμμής σε επόμενη αλλαγή σκηνής με ελάχιστο κενό</AdjustSnapStartToNextSceneChangeWithGap> + <AdjustSnapEndToPreviousSceneChange>Σπάσιμο έναρξης γραμμής σε προηγούμενη αλλαγή σκηνής</AdjustSnapEndToPreviousSceneChange> + <AdjustSnapEndToPreviousSceneChangeWithGap>Σπάσιμο έναρξης γραμμής σε προηγούμενη αλλαγή σκηνής με ελάχιστο κενό</AdjustSnapEndToPreviousSceneChangeWithGap> + <AdjustExtendToNextSceneChange>Επέκταση γραμμών μέχρι την επόμενη αλλαγή σκηνής (ή επόμενο υπότιτλο)</AdjustExtendToNextSceneChange> + <AdjustExtendToNextSceneChangeWithGap>Επέκταση γραμμών σε επόμενη αλλαγή σκηνής με ελάχιστο κενό (ή επόμενο υπότιτλο)</AdjustExtendToNextSceneChangeWithGap> + <AdjustExtendToPreviousSceneChange>Επέκταση γραμμών μέχρι την προηγούμενη αλλαγή σκηνής (ή προηγούμενο υπότιτλο)</AdjustExtendToPreviousSceneChange> + <AdjustExtendToPreviousSceneChangeWithGap>Επέκταση γραμμών σε προηγούμενη αλλαγή σκηνής με ελάχιστο κενό (ή προηγούμενο υπότιτλο)</AdjustExtendToPreviousSceneChangeWithGap> + <AdjustExtendToNextSubtitle>Επέκταση γραμμών μέχρι τον επόμενο υπότιτλο</AdjustExtendToNextSubtitle> + <AdjustExtendToPreviousSubtitle>Επέκταση γραμμών μέχρι τον προηγούμενο υπότιλο</AdjustExtendToPreviousSubtitle> + <AdjustExtendCurrentSubtitle>Επέκταση γραμμής μέχρι τον επόμενο υπότιτλο ή μέγιστη διάρκεια</AdjustExtendCurrentSubtitle> + <AdjustExtendPreviousLineEndToCurrentStart>Επέκταση λήξης προηγούμενης γραμμής σε έναρξη τρέχουσας</AdjustExtendPreviousLineEndToCurrentStart> + <AdjustExtendNextLineStartToCurrentEnd>Επέκταση έναρξης επόμενης γραμμής σε λήξη τρέχουσας</AdjustExtendNextLineStartToCurrentEnd> + <RecalculateDurationOfCurrentSubtitle>Επαναϋπολογισμός διάρκειας υπότιτλου</RecalculateDurationOfCurrentSubtitle> + <MainCreateStartDownEndUp>Δημιουργία νέου στο πάτημα του κάτω βέλους, ορισμός χρόνου λήξης στο πάτημα του πάνω βέλους</MainCreateStartDownEndUp> + <MergeDialog>Συγχώνευση διαλόγου (εισαγωγή παυλών)</MergeDialog> + <GoToNext>Μετάβαση σε επόμενη γραμμή</GoToNext> + <GoToNextCursorAtEnd>Μετάβαση σε επόμενη γραμμή και ορισμός δείκτη στη λήξη</GoToNextCursorAtEnd> + <GoToPrevious>Μετάβαση σε προηγούμενη γραμμή</GoToPrevious> + <GoToCurrentSubtitleStart>Μετάβαση στην αρχή της τρέχουσας γραμμής</GoToCurrentSubtitleStart> + <GoToCurrentSubtitleEnd>Μετάβαση στο τέλος της τρέχουσας γραμμής</GoToCurrentSubtitleEnd> + <GoToPreviousSubtitleAndFocusVideo>Μετάβαση σε προηγούμενη γραμμή και ορισμός θέσης βίντεο</GoToPreviousSubtitleAndFocusVideo> + <GoToNextSubtitleAndFocusVideo>Μετάβαση σε επόμενη γραμμή και ορισμός θέσης βίντεο</GoToNextSubtitleAndFocusVideo> + <GoToPrevSubtitleAndPlay>Μετάβαση σε προηγούμενη γραμμή και αναπαραγωγή</GoToPrevSubtitleAndPlay> + <GoToNextSubtitleAndPlay>Μετάβαση σε επόμενη γραμμή και αναπαραγωγή</GoToNextSubtitleAndPlay> + <ToggleFocus>Εναλλαγή εστίασης υποτίτλου μεταξύ προβολής λίστας και πλαισίου κειμένου</ToggleFocus> + <ToggleDialogDashes>Εναλλαγή γραμμών διαλόγου</ToggleDialogDashes> + <ToggleMusicSymbols>Εναλλαγή μουσικών συμβόλων</ToggleMusicSymbols> + <Alignment>Στοίχιση (επιλεγμένες γραμμές)</Alignment> + <AlignmentN1>Στοίχιση κάτω αριστερά - {\an1}</AlignmentN1> + <AlignmentN2>Στοίχιση κάτω κεντρικά - {\an2}</AlignmentN2> + <AlignmentN3>Στοίχιση κάτω δεξιά - {\an1}</AlignmentN3> + <AlignmentN4>Στοίχιση μέση αριστερά - {\an4}</AlignmentN4> + <AlignmentN5>Στοίχιση μέση κέντρο - {\an5}</AlignmentN5> + <AlignmentN6>Στοίχιση μέση δεξιά - {\an6}</AlignmentN6> + <AlignmentN7>Στοίχιση πάνω αριστερά - {\an7}</AlignmentN7> + <AlignmentN8>Στοίχιση πάνω κεντρικά - {\an8}</AlignmentN8> + <AlignmentN9>Στοίχιση πάνω δεξιά - {\an9}</AlignmentN9> + <CopyTextOnly>Αντιγραφή μόνο του κειμένου στο πρόχειρο (επιλεγμένες γραμμές)</CopyTextOnly> + <CopyTextOnlyFromOriginalToCurrent>Αντιγραφή κειμένου από αρχικό στον τρέχων</CopyTextOnlyFromOriginalToCurrent> + <AutoDurationSelectedLines>Αυτόματη διάρκεια (επιλεγμένες γραμμές)</AutoDurationSelectedLines> + <FixRTLViaUnicodeChars>Επιδιόρθωση RTL μέσω χαρακτήρων ελέγχου Unicode</FixRTLViaUnicodeChars> + <RemoveRTLUnicodeChars>Αφαίρεση χαρακτήρων ελέγχου Unicode</RemoveRTLUnicodeChars> + <ReverseStartAndEndingForRtl>Αντιστροφή έναρξης/λήξης RTL</ReverseStartAndEndingForRtl> + <VerticalZoom>Κάθετη μεγέθυνση</VerticalZoom> + <VerticalZoomOut>Κάθετη σμίκρυνση</VerticalZoomOut> + <WaveformSeekSilenceForward>Αναζήτηση σιωπής εμπρός</WaveformSeekSilenceForward> + <WaveformSeekSilenceBack>Αναζήτηση σιωπής πίσω</WaveformSeekSilenceBack> + <WaveformAddTextHere>Προσθήκη κειμένου (για νέα επιλογή)</WaveformAddTextHere> + <WaveformAddTextHereFromClipboard>Προσθήκη κειμένου (για νέα επιλογή από πρόχειρο)</WaveformAddTextHereFromClipboard> + <SetParagraphAsSelection>Ορισμός επιλεγμένου ως νέα επιλογή</SetParagraphAsSelection> + <WaveformPlayNewSelection>Αναπαραγωγή επιλεγμένου</WaveformPlayNewSelection> + <WaveformPlayNewSelectionEnd>Αναπαραγωγή λήξης επιλεγμένου</WaveformPlayNewSelectionEnd> + <WaveformPlayFirstSelectedSubtitle>Αναπαραγωγή του πρώτου υπότιτλου</WaveformPlayFirstSelectedSubtitle> + <WaveformFocusListView>Εστίαση σε προβολή λίστας</WaveformFocusListView> + <WaveformGoToPreviousSceneChange>Μετάβαση σε προηγούμενη αλλαγή σκηνής</WaveformGoToPreviousSceneChange> + <WaveformGoToNextSceneChange>Μετάβαση σε επόμενη αλλαγή σκηνής</WaveformGoToNextSceneChange> + <WaveformToggleSceneChange>Εναλλαγή αλλαγή σκηνής</WaveformToggleSceneChange> + <WaveformGuessStart>Αυτόματη προσαρμογή έναρξης μέσω έντασης/αλλαγή σκηνής</WaveformGuessStart> + <GoBack1Frame>Πίσω ένα καρέ</GoBack1Frame> + <GoForward1Frame>Μπροστά ένα καρέ</GoForward1Frame> + <GoBack1FrameWithPlay>Πίσω ένα καρέ (με αναπαραγωγή)</GoBack1FrameWithPlay> + <GoForward1FrameWithPlay>Μπροστά ένα καρέ (με αναπαραγωγή)</GoForward1FrameWithPlay> + <GoBack100Milliseconds>Πίσω 100 χιλ. δ.</GoBack100Milliseconds> + <GoForward100Milliseconds>Μπροστά 100 χιλ. δ.</GoForward100Milliseconds> + <GoBack500Milliseconds>Πίσω 500 χιλ. δ.</GoBack500Milliseconds> + <GoForward500Milliseconds>Μπροστά 500 χιλ. δ.</GoForward500Milliseconds> + <GoBack1Second>Πίσω 1 δευτερόλεπτο</GoBack1Second> + <GoForward1Second>Μπροστά 1 δευτερόλεπτο</GoForward1Second> + <GoBack5Seconds>Πίσω 5 δευτερόλεπτα</GoBack5Seconds> + <GoForward5Seconds>Μπροστά 5 δευτερόλεπτα</GoForward5Seconds> + <GoBackXSSeconds>Μικρή προώθηση χρόνου πίσω</GoBackXSSeconds> + <GoForwardXSSeconds>Μικρή προώθηση χρόνου εμπρός</GoForwardXSSeconds> + <GoBackXLSeconds>Μεγάλη προώθηση χρόνου πίσω</GoBackXLSeconds> + <GoForwardXLSeconds>Μεγάλη προώθηση χρόνου εμπρός</GoForwardXLSeconds> + <GoBack3Second>Πίσω 3 δευτερόλεπτα</GoBack3Second> + <GoToStartCurrent>Ορισμός θέσης βίντεο στην έναρξη του τρέχοντος υπότιτλου</GoToStartCurrent> + <ToggleStartEndCurrent>Εναλλαγή θέσης βίντεο μεταξύ έναρξης/λήξης τρέχοντος υπότιτλου</ToggleStartEndCurrent> + <PlayCurrent>Αναπαραγωγή τρέχοντος υπότιτλου</PlayCurrent> + <WaveformGoToPrevSubtitle>Μετάβαση σε προηγούμενο υπότιτλο (από θέση βίντεο)</WaveformGoToPrevSubtitle> + <WaveformGoToNextSubtitle>Μετάβαση σε επόμενο υπότιτλο (από θέση βίντεο)</WaveformGoToNextSubtitle> + <WaveformGoToPrevChapter>Μετάβαση σε προηγούμενο κεφάλαιο</WaveformGoToPrevChapter> + <WaveformGoToNextChapter>Μετάβαση σε επόμενο κεφάλαιο</WaveformGoToNextChapter> + <WaveformSelectNextSubtitle>Επιλογή επόμενου υπότιτλου (από θέση βίντεο, χωρίς αλλαγή)</WaveformSelectNextSubtitle> + <TogglePlayPause>Εναλλαγή αναπαραγωγής/παύσης</TogglePlayPause> + <Pause>Παύση</Pause> + <Fullscreen>Πλήρη οθόνη</Fullscreen> + <PlayRateSlower>Πιο αργός ρυθμός αναπαραγωγής</PlayRateSlower> + <PlayRateFaster>Ταχύτερος ρυθμός αναπαραγωγής</PlayRateFaster> + <VideoResetSpeedAndZoom>Επαναφορά ταχύτητας/μεγένθυσης</VideoResetSpeedAndZoom> + <CustomSearch1>Μετάφραση, προσαρμοσμένη αναζήτηση 1</CustomSearch1> + <CustomSearch2>Μετάφραση, προσαρμοσμένη αναζήτηση 2</CustomSearch2> + <CustomSearch3>Μετάφραση, προσαρμοσμένη αναζήτηση 3</CustomSearch3> + <CustomSearch4>Μετάφραση, προσαρμοσμένη αναζήτηση 4</CustomSearch4> + <CustomSearch5>Μετάφραση, προσαρμοσμένη αναζήτηση 5</CustomSearch5> + <SyntaxColoring>Χρωματισμός σύνταξης</SyntaxColoring> + <ListViewSyntaxColoring>Χρωματισμός σύνταξης στην προβολή λίστας</ListViewSyntaxColoring> + <SyntaxColorDurationIfTooSmall>Χρώμα διάρκειας εάν είναι πολύ μικρός</SyntaxColorDurationIfTooSmall> + <SyntaxColorDurationIfTooLarge>Χρώμα διάρκειας εάν είναι πολύ μεγάλος</SyntaxColorDurationIfTooLarge> + <SyntaxColorTextIfTooLong>Χρώμα κειμένου εάν είναι πολύ μακρύ</SyntaxColorTextIfTooLong> + <SyntaxColorTextIfTooWide>Χρώμα κειμένου αν είναι ευρύ (εικονοστοιχεία)</SyntaxColorTextIfTooWide> + <SyntaxColorTextMoreThanMaxLines>Χρώμα κειμένου αν είναι περισσότερες από {0} γραμμές</SyntaxColorTextMoreThanMaxLines> + <SyntaxColorOverlap>Χρώμα κωδικών χρόνου που επικαλύπτονται</SyntaxColorOverlap> + <SyntaxColorGap>Χρώμα κενού αν είναι μικρότερο</SyntaxColorGap> + <SyntaxErrorColor>Χρώμα σφάλματος</SyntaxErrorColor> + <SyntaxLineWidthSettings>Ρυθμίσεις...</SyntaxLineWidthSettings> + <LineWidthSettings>Ρυθμίσεις εύρους γραμμής</LineWidthSettings> + <MaximumLineWidth>Μέγιστο εύρος γραμμής:</MaximumLineWidth> + <Pixels>εικονοστοιχεία</Pixels> + <MeasureFont>Μέτρηση γραμματοσειράς:</MeasureFont> + <GoToFirstSelectedLine>Μετάβαση σε πρώτη επιλεγμένη γραμμή</GoToFirstSelectedLine> + <GoToNextEmptyLine>Μετάβαση σε επόμενη κενή γραμμή</GoToNextEmptyLine> + <MergeSelectedLines>Συγχώνευση γραμμών</MergeSelectedLines> + <MergeSelectedLinesAndAutoBreak>Συγχώνευση γραμμών και αυτόματη διάσπαση</MergeSelectedLinesAndAutoBreak> + <MergeSelectedLinesAndUnbreak>Συγχώνευση γραμμών και συνένωση</MergeSelectedLinesAndUnbreak> + <MergeSelectedLinesAndUnbreakCjk>Συγχώνευση γραμμών και συνένωση χωρίς κενό</MergeSelectedLinesAndUnbreakCjk> + <MergeSelectedLinesOnlyFirstText>Συγχώνευση γραμμών, κράτημα μόνο του πρώτου κειμένου</MergeSelectedLinesOnlyFirstText> + <MergeSelectedLinesBilingual>Συγχώνευση γραμμών δίγλωσσα</MergeSelectedLinesBilingual> + <SplitSelectedLineBilingual>Διαχωρισμός γραμμής δίγλωσσα</SplitSelectedLineBilingual> + <ToggleTranslationMode>Εναλλαγή τρόπου μετάφρασης</ToggleTranslationMode> + <SwitchOriginalAndTranslation>Εναλλαγή αρχικού και μετάφρασης</SwitchOriginalAndTranslation> + <MergeOriginalAndTranslation>Συγχώνευση αρχικού και μετάφρασης</MergeOriginalAndTranslation> + <MergeWithNext>Συγχώνευση με επόμενη</MergeWithNext> + <MergeWithPrevious>Συγχώνευση με προηγούμενη</MergeWithPrevious> + <ShortcutIsAlreadyDefinedX>Ορισμένη συντόμευση: {0}</ShortcutIsAlreadyDefinedX> + <ToggleTranslationAndOriginalInPreviews>Εναλλαγή μετάφρασης και αρχικού στην προεπισκόπηση βίντεο/ήχου</ToggleTranslationAndOriginalInPreviews> + <ListViewColumnDelete>Στήλη, διαγραφή κειμένου</ListViewColumnDelete> + <ListViewColumnDeleteAndShiftUp>Στήλη, διαγραφή κειμένου και άνω μετατόπιση</ListViewColumnDeleteAndShiftUp> + <ListViewColumnInsert>Στήλη, εισαγωγή κειμένου</ListViewColumnInsert> + <ListViewColumnPaste>Στήλη, επικόλληση</ListViewColumnPaste> + <ListViewColumnTextUp>Στήλη, κείμενο προς τα πάνω</ListViewColumnTextUp> + <ListViewColumnTextDown>Στήλη, κείμενο προς τα κάτω</ListViewColumnTextDown> + <ListViewFocusWaveform>Εστίαση κυματομορφής/φασματογραφήματος</ListViewFocusWaveform> + <ListViewGoToNextError>Μετάβαση σε επόμενο σφάλμα</ListViewGoToNextError> + <ShowBeamer>Ξεκινήστε υπότιτλο σε πλήρη οθόνη βιντεοπροβολέα</ShowBeamer> + <MainTextBoxMoveLastWordDown>Μετακίνηση τελευταίας λέξης στην επόμενη γραμμή</MainTextBoxMoveLastWordDown> + <MainTextBoxMoveFirstWordFromNextUp>Μετακίνηση πρώτης λέξης από την επόμενη γραμμή επάνω</MainTextBoxMoveFirstWordFromNextUp> + <MainTextBoxMoveFirstWordUpCurrent>Μετακίνηση πρώτης λέξης της κάτω γραμμής πάνω</MainTextBoxMoveFirstWordUpCurrent> + <MainTextBoxMoveLastWordDownCurrent>Μετακίνηση τελευταίας λέξης της άνω γραμμής κάτω</MainTextBoxMoveLastWordDownCurrent> + <MainTextBoxSelectionToLower>Επιλογή σε μικρά</MainTextBoxSelectionToLower> + <MainTextBoxSelectionToUpper>Επιλογή σε κεφαλαία</MainTextBoxSelectionToUpper> + <MainTextBoxSelectionToggleCasing>Εναλλαγή πεζών-κεφαλαίων επιλογής (κανονικά/κεφαλαία/πεζά)</MainTextBoxSelectionToggleCasing> + <MainTextBoxSelectionToRuby>Επιλογή σε Ruby (Ιαπωνικά)</MainTextBoxSelectionToRuby> + <MainTextBoxToggleAutoDuration>Εναλλαγή αυτόματης διάρκειας</MainTextBoxToggleAutoDuration> + <MainTextBoxAutoBreak>Αυτόματη διάσπαση κειμένου</MainTextBoxAutoBreak> + <MainTextBoxAutoBreakFromPos>Διάσπαση σε κενό από τη θέση δείκτη</MainTextBoxAutoBreakFromPos> + <MainTextBoxAutoBreakFromPosAndGoToNext>Διάσπαση σε κενό από τη θέση δείκτη και μετάβαση σε επόμενο</MainTextBoxAutoBreakFromPosAndGoToNext> + <MainTextBoxUnbreak>Συνένωση κειμένου</MainTextBoxUnbreak> + <MainFileSaveAll>Αποθήκευση όλων</MainFileSaveAll> + <Miscellaneous>Διάφορα</Miscellaneous> + <CpsIncludesSpace>Συμπερίληψη κενών στους χαρακτήρες/δευτερόλεπτο</CpsIncludesSpace> + <UseDoNotBreakAfterList>Χρήση της λίστας μη διάσπασης μετά από</UseDoNotBreakAfterList> + <BreakEarlyForLineEnding>Διάσπαση σε σημεία στίξης</BreakEarlyForLineEnding> + <BreakByPixelWidth>Διάσπαση βάσει εύρους εικονοστοιχείων</BreakByPixelWidth> + <BreakPreferBottomHeavy>Προτίμηση μεγαλύτερης κάτω γραμμής</BreakPreferBottomHeavy> + <BreakEarlyForDashDialog>Διάσπαση σε παύλα διάλογου</BreakEarlyForDashDialog> + <BreakEarlyForComma>Διάσπαση σε κόμμα</BreakEarlyForComma> + <GoogleTranslate>Μετάφραση Google</GoogleTranslate> + <GoogleTranslateApiKey>Κλειδί API</GoogleTranslateApiKey> + <MicrosoftBingTranslator>Μετάφραση Microsoft</MicrosoftBingTranslator> + <HowToSignUp>Βοήθεια εγγραφής</HowToSignUp> + <MicrosoftTranslateApiKey>Κλειδί</MicrosoftTranslateApiKey> + <MicrosoftTranslateTokenEndpoint>Δείγμα τελειώματος</MicrosoftTranslateTokenEndpoint> + <FontNote>Σημείωση: Οι ρυθμίσεις γραμματοσειράς αφορούν μόνο το περιβάλλον χρήση του Subtitle Edit.</FontNote> + <RestoreDefaultSettings>Επαναφορά ρυθμίσεων</RestoreDefaultSettings> + <RestoreDefaultSettingsMsg>Επαναφορά ρυθμίσεων σε προεπιλεγμένες τιμές. +Συνέχιση;</RestoreDefaultSettingsMsg> + <RemoveTimeCodes>Αφαίρεση κωδικών χρόνου</RemoveTimeCodes> + <EditFixContinuationStyleSettings>Επεξεργασία ρυθμίσεων για διόρθωση στυλ συνέχισης...</EditFixContinuationStyleSettings> + <FixContinuationStyleSettings>Ρυθμίσεις διόρθωσης στυλ συνέχισης</FixContinuationStyleSettings> + <UncheckInsertsAllCaps>Εντοπισμός και αποεπιλογή κεφαλαίων τίτλων μίας γραμμής</UncheckInsertsAllCaps> + <UncheckInsertsItalic>Εντοπισμός και αποεπιλογή τίτλων ή στίχων σε πλαγιαστά</UncheckInsertsItalic> + <UncheckInsertsLowercase>Εντοπισμός και αποεπιλογή πεζών τίτλων ή στίχων μίας γραμμής</UncheckInsertsLowercase> + <HideContinuationCandidatesWithoutName>Απόκρυψη απίθανων προτάσεων συνέχισης</HideContinuationCandidatesWithoutName> + <IgnoreLyrics>Αγνόηση στίχων μεταξύ μουσικών συμβόλων</IgnoreLyrics> + <MinFrameGap>Ελάχιστο κενό σε καρέ</MinFrameGap> + <XFramesAtYFrameRateGivesZMs>{0} καρέ ανά {1} καρέ είναι {2} χιλ. δευτερολέπτου.</XFramesAtYFrameRateGivesZMs> + <UseXAsNewGap>Χρήση "{0}" χιλ. δευτερολέπτου ως ελάχιστο κενό;</UseXAsNewGap> + </Settings> + <SettingsMpv> + <Title>Ρυθμίσεις mpv</Title> + <DownloadMpv>Λήψη mpv lib</DownloadMpv> + <DownloadMpvFailed>Αδυναμία λήψης mpv - παρακαλώ, προσπαθήστε αργότερα!</DownloadMpvFailed> + <DownloadMpvOk>Ολοκλήρωση λήψης mpv lib και έτοιμο προς χρήση.</DownloadMpvOk> + </SettingsMpv> + <SettingsFfmpeg> + <Title>Λήψη FFmpeg</Title> + <XDownloadFailed>Αδυναμία λήψης {0} - παρακαλώ, προσπαθήστε αργότερα!</XDownloadFailed> + <XDownloadOk>Λήψη {0} και έτοιμο προς χρήση.</XDownloadOk> + </SettingsFfmpeg> + <SetVideoOffset> + <Title>Ορισμός έναρξης βίντεο</Title> + <Description>Ορισμός έναρξης βίντεο (μη ακουλούθηση πραγματικού χρόνου βίντεο)</Description> + <RelativeToCurrentVideoPosition>Σχετικά με την τρέχουσα θέση βίντεο</RelativeToCurrentVideoPosition> + <KeepTimeCodes>Κράτημα υπαρχόντων κωδικών χρόνου (μη προσθήκη έναρξης βίντεο)</KeepTimeCodes> + <Reset>Επαναφορά</Reset> + </SetVideoOffset> + <ShowEarlierLater> + <Title>Εμφάνιση γραμμών νωρίτερα/αργότερα</Title> + <TitleAll>Εμφάνιση όλων των γραμμών νωρίτερα/αργότερα</TitleAll> + <ShowEarlier>Εμφάνιση νωρίτερα</ShowEarlier> + <ShowLater>Εμφάνιση αργότερα</ShowLater> + <TotalAdjustmentX>Συνολική προσαρμογή: {0}</TotalAdjustmentX> + <AllLines>Όλες οι γραμμές</AllLines> + <SelectedLinesOnly>Μόνο τις επιλεγμένες γραμμές</SelectedLinesOnly> + <SelectedLinesAndForward>Επιλογή από τη(ις) γραμμή(ές) και εμπρός</SelectedLinesAndForward> + </ShowEarlierLater> + <ShowHistory> + <Title>Ιστορικό (για αναίρεση)</Title> + <SelectRollbackPoint>Επιλέξτε χρόνο/περιγραφή για επαναφορά</SelectRollbackPoint> + <Time>Χρόνος</Time> + <Description>Περιγραφή</Description> + <CompareHistoryItems>Σύγκριση στοιχείων ιστορικού</CompareHistoryItems> + <CompareWithCurrent>Σύγκριση με τρέχον</CompareWithCurrent> + <Rollback>Επαναφορά</Rollback> + </ShowHistory> + <SpellCheck> + <Title>Ορθογραφικός έλεγχος</Title> + <FullText>Πλήρους κειμένου</FullText> + <WordNotFound>Λέξη δεν βρέθηκε</WordNotFound> + <Language>Γλώσσα</Language> + <Change>Αλλαγή</Change> + <ChangeAll>Αλλαγή όλων</ChangeAll> + <SkipOnce>Παράλειψη &amp;ενός</SkipOnce> + <SkipAll>&amp;Παράλειψη όλων</SkipAll> + <AddToUserDictionary>Προσθήκη στο λεξικό του χρήστη</AddToUserDictionary> + <AddToNamesAndIgnoreList>Προσθήκη στη λίστα ονομάτων/παραλείψεων (διάκριση πεζών-κεφαλαίων)</AddToNamesAndIgnoreList> + <AddToOcrReplaceList>Προσθήκη ζεύγους στη λίστα αντικατάστασης του OCR</AddToOcrReplaceList> + <Abort>Ματαίωση</Abort> + <Use>Χρήση</Use> + <UseAlways>&amp;Χρήση πάντα</UseAlways> + <Suggestions>Προτάσεις</Suggestions> + <SpellCheckProgress>Ορθογραφικός έλεγχος [{0}] - {1}</SpellCheckProgress> + <EditWholeText>Επεξεργασία ολόκληρου κειμένου</EditWholeText> + <EditWordOnly>Επεξεργασία λέξης</EditWordOnly> + <AddXToNames>Προσθήκη '{0}' στη λίστα ονομάτων</AddXToNames> + <AddXToUserDictionary>Προσθήκη {0} στο λεξικό χρήστη</AddXToUserDictionary> + <AutoFixNames>Αυτόματη επιδιόρθωση ονομάτων μόνο για διαφορά πεζών-κεφαλαίων</AutoFixNames> + <AutoFixNamesViaSuggestions>Διόρθωση ονομάτων μέσω 'προτάσεων ορθογραφικού ελέγχου'</AutoFixNamesViaSuggestions> + <CheckOneLetterWords>Ερώτηση για άγνωστες λέξεις ένός γράμματος</CheckOneLetterWords> + <TreatINQuoteAsING>Αντιμετώπιση κατάληξης " in' " ως " ing " (Μόνο Αγγλικά)</TreatINQuoteAsING> + <RememberUseAlwaysList>Απομνημόνευση λίστας "Χρήση πάντα"</RememberUseAlwaysList> + <ImageText>Κείμενο εικόνας</ImageText> + <SpellCheckCompleted>Ολοκλήρωση ορθογραφικού ελέγχου</SpellCheckCompleted> + <SpellCheckAborted>Ματαίωση ορθογραφικού ελέγχου</SpellCheckAborted> + <SpacesNotAllowed>Απαγορεύονται τα κενά σε λέξη!</SpacesNotAllowed> + <UndoX>Αναιρέθηκαν: {0}</UndoX> + </SpellCheck> + <NetflixQualityCheck> + <GlyphCheckReport>Μη έγκυρος χαρακτήρας {0} στη στήλη {1}</GlyphCheckReport> + <WhiteSpaceCheckReport>Μη έγκυρο κενό στη στήλη {0}</WhiteSpaceCheckReport> + <ReportPrompt>Δείτε την αναφορά εδώ: {0}.</ReportPrompt> + <OpenReportInFolder>Άνοιγμα φακέλου αναφοράς</OpenReportInFolder> + <FoundXIssues>Ο έλεγχος ποιότητας Netflix εντόπισε {0:#,###} προβλήματα.</FoundXIssues> + <CheckOk>Χωρίς προβλήματα</CheckOk> + <MaximumXCharsPerSecond>Μέγιστοι {0} χαρακτήρες/ δευτ (εξαίρεση κενών)</MaximumXCharsPerSecond> + <MaximumLineLength>Μέγιστο μήκος γραμμής ({0})</MaximumLineLength> + <MinimumDuration>Ελάχιστη διάρκεια: 5/6 δευτερολέπτου (833 χ.δ.)</MinimumDuration> + </NetflixQualityCheck> + <Split> + <Title>Διαχωρισμός</Title> + <SplitOptions>Επιλογές διαχωρισμού</SplitOptions> + <Lines>Γραμμές</Lines> + <Characters>Χαρακτήρες</Characters> + <NumberOfEqualParts>Αριθμός ίσων κομματιών</NumberOfEqualParts> + <SubtitleInfo>Πληροφορίες υπότιτλου</SubtitleInfo> + <NumberOfLinesX>Αριθμός γραμμών: {0:#,###}</NumberOfLinesX> + <NumberOfCharactersX>Αριθμός χαρακτήρων: {0:#,###,###}</NumberOfCharactersX> + <Output>Εξαγωγή</Output> + <FileName>Όνομα αρχείου</FileName> + <OutputFolder>Φάκελος εξαγωγής</OutputFolder> + <DoSplit>Διαχωρισμός</DoSplit> + <Basic>Βασικός</Basic> + </Split> + <SplitLongLines> + <Title>Διάσπαση/διαχωρισμός μεγάλων γραμμών</Title> + <SingleLineMaximumLength>Μέγιστο μήκος μονής γραμμής</SingleLineMaximumLength> + <LineMaximumLength>Μέγιστο μήκος γραμμής</LineMaximumLength> + <LineContinuationBeginEndStrings>Συμβολοσειρές έναρξης/λήξης συνέχισης της γραμμής</LineContinuationBeginEndStrings> + <NumberOfSplits>Σύνολο διαχωρισμών: {0}</NumberOfSplits> + <LongestSingleLineIsXAtY>Το μεγαλύτερο μήκος μονής γραμμής είναι {0} στη γραμμή {1}</LongestSingleLineIsXAtY> + <LongestLineIsXAtY>Το μεγαλύτερο μήκος μήκος ολικής γραμμής είναι {0} στη γραμμή {1}</LongestLineIsXAtY> + </SplitLongLines> + <SplitSubtitle> + <Title>Διαχωρισμός υπότιτλου</Title> + <Description1>Εισαγωγή μήκους πρώτου μέρους βίντεο ή περιήγηση</Description1> + <Description2>και πάρτε το μήκος από αρχείο βίντεο:</Description2> + <Split>&amp;Διαχωρισμός</Split> + <Done>&amp;Ολοκληρώθηκε</Done> + <NothingToSplit>Τίποτα για διαχωρισμό !</NothingToSplit> + <SavePartOneAs>Αποθήκευση μέρους 1 ως...</SavePartOneAs> + <SavePartTwoAs>Αποθήκευση μέρους 2 ως...</SavePartTwoAs> + <Part1>Μέρος1</Part1> + <Part2>Μέρος2</Part2> + <UnableToSaveFileX>Αδυναμία αποθήκευσης {0}</UnableToSaveFileX> + <OverwriteExistingFiles>Αντικατάσταση υπαρχόντων αρχείων;</OverwriteExistingFiles> + <FolderNotFoundX>Ο φάκελος δεν βρέθηκε: {0}</FolderNotFoundX> + <Untitled>Χωρίς τίτλο</Untitled> + </SplitSubtitle> + <StartNumberingFrom> + <Title>Επαναρίθμησης από...</Title> + <StartFromNumber>Έναρξη από τον αριθμό:</StartFromNumber> + <PleaseEnterAValidNumber>Εισαγωγή έγκυρου αριθμού</PleaseEnterAValidNumber> + </StartNumberingFrom> + <Statistics> + <Title>Στατιστικά</Title> + <TitleWithFileName>Στατιστικά - {0}</TitleWithFileName> + <GeneralStatistics>Γενικά στατιστικά</GeneralStatistics> + <MostUsed>Περισσότερη χρήση...</MostUsed> + <MostUsedLines>Οι περισσότερες χρησιμοποιούμενες γραμμές</MostUsedLines> + <MostUsedWords>Οι περισσότερες χρησιμοποιούμενες λέξεις</MostUsedWords> + <NothingFound>Δεν βρέθηκε τίποτα</NothingFound> + <NumberOfLinesX>Αριθμός γραμμών υποτίτλου: {0:#,###}</NumberOfLinesX> + <LengthInFormatXinCharactersY>Αριθμός χαρακτήρων όπως {0}: {1:#,###,##0}</LengthInFormatXinCharactersY> + <NumberOfCharactersInTextOnly>Αριθμός χαρακτήρων μόνο στο κείμενο: {0:#,###,##0}</NumberOfCharactersInTextOnly> + <TotalDuration>Συνολική διάρκεια των υποτίτλων: {0:#,##0}</TotalDuration> + <TotalCharsPerSecond>Σύνολο χαρακτήρων/δευτερόλεπτο: {0:0.0} δευτερόλεπτα</TotalCharsPerSecond> + <TotalWords>Σύνολο λέξεων: {0:#,##0}</TotalWords> + <NumberOfItalicTags>Αριθμός ετικετών πλάγιας γραφής: {0}</NumberOfItalicTags> + <NumberOfBoldTags>Αριθμός ετικετών έντονης γραφής: {0}</NumberOfBoldTags> + <NumberOfUnderlineTags>Αριθμός ετικετών υπογραμμισμένης γραφής: {0}</NumberOfUnderlineTags> + <NumberOfFontTags>Αριθμός ετικετών γραμματοσειράς: {0}</NumberOfFontTags> + <NumberOfAlignmentTags>Αριθμός ετικετών στοίχισης: {0}</NumberOfAlignmentTags> + <LineLengthMinimum>Μήκος υποτίτλου - ελάχιστο: {0}</LineLengthMinimum> + <LineLengthMaximum>Μήκος υποτίτλου - μέγιστο: {0}</LineLengthMaximum> + <LineLengthAverage>Μήκος υποτίτλου - μέσο: {0}</LineLengthAverage> + <LinesPerSubtitleAverage>Αριθμός γραμμών υποτίτλων - μέσος: {0:0.0}</LinesPerSubtitleAverage> + <SingleLineLengthMinimum>Μήκος μονής γραμμής - ελάχιστο: {0}</SingleLineLengthMinimum> + <SingleLineLengthMaximum>Μήκος μονής γραμμής - μέγιστο: {0}</SingleLineLengthMaximum> + <SingleLineLengthAverage>Μήκος μονής γραμμής - μέσο: {0}</SingleLineLengthAverage> + <SingleLineWidthMinimum>Εύρος μονής γραμμής - ελάχιστο: {0} εικονοστοιχεία</SingleLineWidthMinimum> + <SingleLineWidthMaximum>Εύρος μονής γραμμής - μέγιστο: {0} εικονοστοιχεία</SingleLineWidthMaximum> + <SingleLineWidthAverage>Εύρος μονής γραμμής - μέσο: {0} εικονοστοιχεία</SingleLineWidthAverage> + <DurationMinimum>Διάρκεια - ελάχιστη: {0:0.000} δευτερόλεπτα</DurationMinimum> + <DurationMaximum>Διάρκεια - μέγιστη: {0:0.000} δευτερόλεπτα</DurationMaximum> + <DurationAverage>Διάρκεια - μέση: {0:0.000} δευτερόλεπτα</DurationAverage> + <CharactersPerSecondMinimum>Χαρακτήρες/ δευτ - ελάχιστοι: {0:0.000}</CharactersPerSecondMinimum> + <CharactersPerSecondMaximum>Χαρακτήρες/ δευτ - μέγιστοι: {0:0.000}</CharactersPerSecondMaximum> + <CharactersPerSecondAverage>Χαρακτήρες/ δευτ - μέσοι: {0:0.000}</CharactersPerSecondAverage> + <Export>Εξαγωγή...</Export> + </Statistics> + <SubStationAlphaProperties> + <Title>Προχωρημένες ιδιότητες Sub Station Alpha</Title> + <TitleSubstationAlpha>Ιδιότητες Sub Station Alpha</TitleSubstationAlpha> + <Script>Σενάριο</Script> + <ScriptTitle>Τίτλος</ScriptTitle> + <OriginalScript>Αρχικό σενάριο</OriginalScript> + <Translation>Μετάφραση</Translation> + <Editing>Επιμέλεια</Editing> + <Timing>Χρονισμός</Timing> + <SyncPoint>Σημείο συγχρονισμού</SyncPoint> + <UpdatedBy>Ενημερωμένο από</UpdatedBy> + <UpdateDetails>Λεπτομέρειες ενημέρωσης</UpdateDetails> + <Resolution>Ανάλυση</Resolution> + <VideoResolution>Ανάλυση βίντεοVideo resolution</VideoResolution> + <Options>Επιλογές</Options> + <WrapStyle>Στυλ αναδίπλωσης</WrapStyle> + <Collision>Σύγκρουση</Collision> + <ScaleBorderAndShadow>Κλίμακα ορίων και σκιάς</ScaleBorderAndShadow> + </SubStationAlphaProperties> + <SubStationAlphaStyles> + <Title>Προχωρημένα στυλ Sub Station Alpha</Title> + <TitleSubstationAlpha>Στυλ Sub Station Alpha</TitleSubstationAlpha> + <Styles>Στυλ</Styles> + <Properties>Ιδιότητες</Properties> + <Name>Όνομα</Name> + <Font>Γραμματοσειρά</Font> + <FontName>Όνομα γραμματοσειράς</FontName> + <FontSize>Μέγεθος γραμματοσειράς</FontSize> + <UseCount>Χρησιμοποιημένα</UseCount> + <Primary>Πρωτογενής</Primary> + <Secondary>Δευτερογενής</Secondary> + <Tertiary>Τριτογενής</Tertiary> + <Outline>Περίγραμμα</Outline> + <Shadow>Σκιά</Shadow> + <Back>Πίσω</Back> + <Alignment>Στοίχιση</Alignment> + <TopLeft>Επάνω/αριστερά</TopLeft> + <TopCenter>Επάνω/κέντρο</TopCenter> + <TopRight>Επάνω/δεξιά</TopRight> + <MiddleLeft>Μέση/αριστερά</MiddleLeft> + <MiddleCenter>Μέση/κέντρο</MiddleCenter> + <MiddleRight>Μέση/δεξιά</MiddleRight> + <BottomLeft>Κάτω/αριστερά</BottomLeft> + <BottomCenter>Κάτω/κέντρο</BottomCenter> + <BottomRight>Κάτω/δεξιά</BottomRight> + <Colors>Χρώματα</Colors> + <Margins>Περιθώρια</Margins> + <MarginLeft>Περιθώριο αριστερά</MarginLeft> + <MarginRight>Περιθώριο δεξιά</MarginRight> + <MarginVertical>Περιθώριο κάθετα</MarginVertical> + <Border>Όριο</Border> + <PlusShadow>+ Σκιά</PlusShadow> + <OpaqueBox>Αδιαφανές πλαίσιο (χρήση χρώματος περιγράμματος)</OpaqueBox> + <Import>Εισαγωγή...</Import> + <Export>Εξαγωγή...</Export> + <Copy>Αντιγραφή</Copy> + <CopyOfY>Αντιγραφή από {0}</CopyOfY> + <CopyXOfY>Αντιγραφή {0} από {1}</CopyXOfY> + <New>Νέο</New> + <Remove>Αφαίρεση</Remove> + <RemoveAll>Αφ. όλων</RemoveAll> + <ImportStyleFromFile>Εισαγωγή στυλ από αρχείο...</ImportStyleFromFile> + <ExportStyleToFile>Εξαγωγή στυλ σε αρχείο... (προσθήκη σε περίπτωση υπάρχοντος στυλ)</ExportStyleToFile> + <ChooseStyle>Επιλογή στυλ για εισαγωγή</ChooseStyle> + <StyleAlreadyExits>Υπάρχον στυλ: {0}</StyleAlreadyExits> + <StyleXExportedToFileY>Το στυλ '{0}' έχει εξαχθεί στο αρχείο '{1}'</StyleXExportedToFileY> + <StyleXImportedFromFileY>Το στυλ '{0}' έχει εισαχθεί από το αρχείο '{1}'</StyleXImportedFromFileY> + </SubStationAlphaStyles> + <PointSync> + <Title>Συγχρονισμός σημείων</Title> + <TitleViaOtherSubtitle>Συγχρονισμός σημείων μέσω άλλου υπότιτλου</TitleViaOtherSubtitle> + <SyncHelp>Ορισμός δύο σημείων συγχρονισμού για πρόχειρο συγχρονισμό</SyncHelp> + <SetSyncPoint>Ορισμός σημείου συγχρονισμού</SetSyncPoint> + <RemoveSyncPoint>Αφαίρεση σημείου συγχρονισμού</RemoveSyncPoint> + <SyncPointsX>Σημείο συγχρονισμού: {0}</SyncPointsX> + <Info>Ένα σημείο συγχρονισμού θα προσαρμόσει τη θέση, δύο ή περισσότερα θα προσαρμόσουν τη θέση και την ταχύτητα</Info> + <ApplySync>Εφαρμογή</ApplySync> + </PointSync> + <TransportStreamSubtitleChooser> + <Title>Επιλογέας ροής μεταφοράς υποτίτλου - {0}</Title> + <PidLineImage>Εικόνες - Αναγνωριστικό πακέτου μεταφοράς = {0}, γλώσσα = {1}, αριθμός υποτίτλων = {2}</PidLineImage> + <PidLineTeletext>Τηλεκίμενο - Αναγνωριστικό πακέτου μεταφοράς = {1}, σελίδα = {0}, γλώσσα = {2}, αριθμός υποτίτλων = {3}</PidLineTeletext> + <SubLine>{0}: {1} -&gt; {2}, {3} εικόνα(ες)</SubLine> + </TransportStreamSubtitleChooser> + <UnknownSubtitle> + <Title>Άγνωστος τύπος υπότιτλου</Title> + <Message>Αν θέλετε αυτό να φτιαχτεί παρακαλώ στείλτε email στο mailto:niksedk@gmail.com και συμπεριλάβετε ένα αντίγραφο του υπότιτλου.</Message> + <ImportAsPlainText>Εισαγωγή ως απλό κείμενο...</ImportAsPlainText> + </UnknownSubtitle> + <VisualSync> + <Title>Οπτικός συγχρονισμός</Title> + <StartScene>Αρχική σκηνή</StartScene> + <EndScene>Τελική σκηνή</EndScene> + <Synchronize>Συγχρονισμός</Synchronize> + <HalfASecondBack>&lt; ½ δευτ.</HalfASecondBack> + <ThreeSecondsBack>&lt; 3 δευτ.</ThreeSecondsBack> + <PlayXSecondsAndBack>Αναπαραγωγή {0} δευτ. και πίσω</PlayXSecondsAndBack> + <FindText>Εύρεση κειμένου</FindText> + <GoToSubPosition>Μετάβαση στη θέση του υπότιτλου</GoToSubPosition> + <KeepChangesTitle>Διατήρηση αλλαγών;</KeepChangesTitle> + <KeepChangesMessage>Έχουν γίνει αλλαγές στον υπότιτλο μέσω 'Οπτικού συγχρονισμού'. +Διατήρηση αλλαγών;</KeepChangesMessage> + <SynchronizationDone>Ο συγχρονισμός ολοκληρώθηκε!</SynchronizationDone> + <StartSceneMustComeBeforeEndScene>Η αρχική σκηνή πρέπει να είναι πριν από την τελική!</StartSceneMustComeBeforeEndScene> + <Tip>Συμβουλή: Χρησιμοποιήστε &lt;ctrl+βέλη αριστερά/δεξιά&gt; για να μετακινηθείτε 100 χιλ. δευτ. πίσω/εμπρός</Tip> + </VisualSync> + <VobSubEditCharacters> + <Title>Επεξεργασία βάσης δεδομένων σύγκρισης εικόνων</Title> + <ChooseCharacter>Επιλογή χαρακτήρα(ων)</ChooseCharacter> + <ImageCompareFiles>Αρχεία σύγκρισης εικόνων</ImageCompareFiles> + <CurrentCompareImage>Τρέχουσα εικόνα σύγκρισης</CurrentCompareImage> + <TextAssociatedWithImage>Κείμενο που σχετίζεται με την εικόνα</TextAssociatedWithImage> + <IsItalic>Είναι &amp;πλαγιαστό</IsItalic> + <Update>&amp;Ενημέρωση</Update> + <Delete>&amp;Διαγραφή</Delete> + <ImageDoubleSize>Διπλό μέγεθος εικόνας</ImageDoubleSize> + <ImageFileNotFound>Το αρχείο εικόνας δεν βρέθηκε</ImageFileNotFound> + <Image>Εικόνα</Image> + </VobSubEditCharacters> + <VobSubOcr> + <Title>Εισαγωγή/OCR υπότιτλου VobSub (sub/idx)</Title> + <TitleBluRay>Εισαγωγή/OCR υπότιτλου Blu-ray (.sup)</TitleBluRay> + <OcrMethod>Μέθοδος OCR</OcrMethod> + <OcrViaTesseractVersionX>Tesseract {0}</OcrViaTesseractVersionX> + <OcrViaImageCompare>OCR μέσω σύγκρισης εικόνων</OcrViaImageCompare> + <OcrViaModi>OCR μέσω Microsoft Office Document Imaging (MODI). Προϋποθέτει Microsoft Office</OcrViaModi> + <OcrViaNOCR>OCR μέσω nOCR</OcrViaNOCR> + <TesseractEngineMode>Λειτουργία μηχανής</TesseractEngineMode> + <TesseractEngineModeLegacy>Αρχικό Tesseract (ανίχνευση πλαγιαστών)</TesseractEngineModeLegacy> + <TesseractEngineModeNeural>Δίκτυα LSTM</TesseractEngineModeNeural> + <TesseractEngineModeBoth>Tesseract + LSTM</TesseractEngineModeBoth> + <TesseractEngineModeDefault>Προεπιλεγμένο, βάσει διαθέσιμων</TesseractEngineModeDefault> + <Language>Γλώσσα</Language> + <ImageDatabase>Βάση δεδομένων εικόνων</ImageDatabase> + <NoOfPixelsIsSpace>Σύνολο εικονοστοιχείων διαστημάτων</NoOfPixelsIsSpace> + <MaxErrorPercent>Μέγιστο σφάλμα%</MaxErrorPercent> + <New>Νέο</New> + <Edit>Επεξεργασία</Edit> + <StartOcr>Έναρξη OCR</StartOcr> + <Stop>Διακοπή</Stop> + <StartOcrFrom>Έναρξη OCR από τον αριθμό υπότιτλου:</StartOcrFrom> + <LoadingVobSubImages>Φόρτωση εικόνων VobSub...</LoadingVobSubImages> + <LoadingImageCompareDatabase>Φόρτωση βάσης δεδομένων εικόνων σύγκρισης...</LoadingImageCompareDatabase> + <ConvertingImageCompareDatabase>Μετατροπή βάσης δεδομένων εικόνων σύγκρισης σε νέο τύπο (images.db/images.xml)...</ConvertingImageCompareDatabase> + <SubtitleImage>Εικόνα υπότιτλου</SubtitleImage> + <SubtitleText>Κείμενο υπότιτλου</SubtitleText> + <UnableToCreateCharacterDatabaseFolder>Αδυναμία δημιουργίας φακέλου 'Character Database Folder': {0}</UnableToCreateCharacterDatabaseFolder> + <SubtitleImageXofY>Εικόνα υπότιτλου {0} από {1}</SubtitleImageXofY> + <ImagePalette>Παλέτα εικόνας</ImagePalette> + <UseCustomColors>Χρήση προσαρμοσμένων χρωμάτων</UseCustomColors> + <Transparent>Χωρίς φόντο</Transparent> + <TransparentMinAlpha>Ελάχιστη τιμή άλφα (0=διαφανές, 255=πλήρως ορατό)</TransparentMinAlpha> + <TransportStream>Ροή μεταφοράς</TransportStream> + <TransportStreamGrayscale>Κλίμακα του γκρι</TransportStreamGrayscale> + <TransportStreamGetColor>Χρήση χρώματος (θα συμπεριληφθούν μερικές σπασμένες γραμμές)</TransportStreamGetColor> + <PromptForUnknownWords>Ερώτηση για άγνωστες λέξεις</PromptForUnknownWords> + <TryToGuessUnkownWords>Προσπάθεια μαντέματος άγνωστων λέξεων</TryToGuessUnkownWords> + <AutoBreakSubtitleIfMoreThanTwoLines>Αυτόματος διαχορισμός παραγράφου εάν έχει περισσότερες από δύο γραμμές</AutoBreakSubtitleIfMoreThanTwoLines> + <AllFixes>Όλες οι επιδιορθώσεις</AllFixes> + <GuessesUsed>Μαντεψιές</GuessesUsed> + <UnknownWords>Άγνωστες λέξεις</UnknownWords> + <UnknownWordToGuessInLine>{0} {1} μέσω λίστας διόρθωσης/αντικατάστασης OCR στη γραμμή: {2}</UnknownWordToGuessInLine> + <OcrAutoCorrectionSpellChecking>Αυτόματη διόρθωση/ορθογραφικός έλεγχος OCR</OcrAutoCorrectionSpellChecking> + <FixOcrErrors>Επιδιόρθωση σφαλμάτων OCR</FixOcrErrors> + <ImportTextWithMatchingTimeCodes>Εισαγωγή κειμένου με αντιστοιχία κωδικών χρόνου...</ImportTextWithMatchingTimeCodes> + <ImportNewTimeCodes>Εισαγωγή νέων κωδικών χρόνου</ImportNewTimeCodes> + <SaveSubtitleImageAs>Αποθήκευση εικόνας υπότιτλου ως...</SaveSubtitleImageAs> + <SaveAllSubtitleImagesAsBdnXml>Αποθήκευση όλων των εικόνων (png/bdn xml)...</SaveAllSubtitleImagesAsBdnXml> + <SaveAllSubtitleImagesWithHtml>Αποθήκευση όλων των εικόνων με HTML...</SaveAllSubtitleImagesWithHtml> + <XImagesSavedInY>{0} εικόνες αποθηκεύτηκαν στο {1}</XImagesSavedInY> + <DictionaryX>Λεξικό: {0}</DictionaryX> + <RightToLeft>Δεξιά προς αριστερά</RightToLeft> + <ShowOnlyForcedSubtitles>Εμφάνιση μόνο υποχρεωτικών υποτίτλων</ShowOnlyForcedSubtitles> + <UseTimeCodesFromIdx>Χρήση κωδικών χρόνου από αρχείο .idx</UseTimeCodesFromIdx> + <NoMatch>&lt;Καμία αντιστοιχία&gt;</NoMatch> + <AutoTransparentBackground>Αυτόματη διαφάνεια φόντου</AutoTransparentBackground> + <CaptureTopAlign>Λήψη άνω στοίχισης</CaptureTopAlign> + <InspectCompareMatchesForCurrentImage>Έλεγχος αντιστοιχιών σύγκρισης για την τρέχουσα εικόνα...</InspectCompareMatchesForCurrentImage> + <EditLastAdditions>Επεξεργασία προσθηκών της τελευταίας σύγκρισης εικόνας...</EditLastAdditions> + <SetItalicAngle>Ορισμός κλίσης πλαγιαστών...</SetItalicAngle> + <ItalicAngle>Κλίση πλαγιαστών</ItalicAngle> + <DiscardTitle>Απόρριψη αλλαγών του OCR;</DiscardTitle> + <DiscardText>Απόρριψη αλλαγών του OCR στην τρέχουσα συνεδρία;</DiscardText> + <MinLineSplitHeight>Ελάχιστο ύψος γραμμής (διαχωρισμός)</MinLineSplitHeight> + <FallbackToX>Επαναφορά σε {0}</FallbackToX> + <ImagePreProcessing>Προ-επεξεργασία εικόνας...</ImagePreProcessing> + <EditImageDb>Επεξεργασία βάσης δεδομένων εικόνας</EditImageDb> + <OcrTraining>Εκμάθηση OCR...</OcrTraining> + <SubtitleTrainingFile>Εκμάθηση με αρχείο υπότιτλου</SubtitleTrainingFile> + <LetterCombinations>Συνδυασμοί γράμματος που είναι χωρισμένο ως μία εικόνα</LetterCombinations> + <TrainingOptions>Επιλογές εκμάθησης</TrainingOptions> + <NumberOfSegments>Αριθμός τμημάτων ανά γράμμα</NumberOfSegments> + <AlsoTrainItalic>Εκμάθηση πλαγιαστών</AlsoTrainItalic> + <AlsoTrainBold>Εκμάθηση έντονων</AlsoTrainBold> + <StartTraining>Έναρξη εκμάθησης</StartTraining> + <NowTraining>Εκμάθηση γραμματοσειράς '{1}. Σύνολο χαρακτήρων που μαθεύτηκαν: {0:#,###,##0}, {2:#,###,##0} γνωστά</NowTraining> + </VobSubOcr> + <VobSubOcrCharacter> + <Title>OCR - Εικόνα σε κείμενο χειροκίνητα</Title> + <ShrinkSelection>Σμίκρυνση επιλογής</ShrinkSelection> + <ExpandSelection>Επέκταση επιλογής</ExpandSelection> + <SubtitleImage>Εικόνα υπότιτλου</SubtitleImage> + <Characters>Χαρακτήρας(ες)</Characters> + <CharactersAsText>Χαρακτήρας(ες) ως κείμενο</CharactersAsText> + <Italic>&amp;Πλαγιστά</Italic> + <Abort>&amp;Ματαίωση</Abort> + <Skip>Π&amp;αράβλεψη</Skip> + <Nordic>Σκανδιναβικά</Nordic> + <Spanish>Ισπανικά</Spanish> + <German>Γερμανικά</German> + <AutoSubmitOnFirstChar>Αυτόματη αποστολή στον &amp;πρώτο χαρακτήρα</AutoSubmitOnFirstChar> + <EditLastX>Επεξεργασία τελευταίου: {0}</EditLastX> + </VobSubOcrCharacter> + <VobSubOcrCharacterInspect> + <Title>Έλεγχος αντιστοιχιών σύγκρισης για την τρέχουσα εικόνα</Title> + <InspectItems>Έλεγχος στοιχείων</InspectItems> + <AddBetterMatch>Προσθήκη καλύτερης αντιστοιχίας</AddBetterMatch> + <Add>Προσθήκη</Add> + </VobSubOcrCharacterInspect> + <VobSubOcrNewFolder> + <Title>Νέος φάκελος</Title> + <Message>Όνομα νέου φακέλου βάσης δεδομένων χαρακτήρων</Message> + </VobSubOcrNewFolder> + <VobSubOcrSetItalicAngle> + <Title>Ορισμός κλίσης πλαγιαστών</Title> + <Description>Προσαρμογή τιμής μέχρι το στυλ κειμένου να είναι κανονικό. Το αρχικό κείμενο έχει πλαγιαστό στυλ.</Description> + </VobSubOcrSetItalicAngle> + <OcrPreprocessing> + <Title>Προ-επεξεργασία εικόνας με OCR</Title> + <Colors>Χρώματα</Colors> + <AdjustAlpha>Προσαρμογή τιμής μέχρι το κείμενο να είναι ορατό (εύρος τιμών μεταξύ 200 έως 300)</AdjustAlpha> + <OriginalImage>Αρχική εικόνα</OriginalImage> + <PostImage>Εικόνα μετά την προ-επεξεργασία</PostImage> + <BinaryThreshold>Όριο σύγκρισης δυαδικής εικόνας</BinaryThreshold> + <InvertColors>Αντιστροφή χρωμάτων</InvertColors> + <YellowToWhite>Κίτρινο σε άσπρο</YellowToWhite> + <ColorToWhite>Χρώμα σε άσπρο</ColorToWhite> + <ColorToRemove>Αφαίρεση χρώματος</ColorToRemove> + <Cropping>Κόψιμο</Cropping> + <CropTransparentColors>Κόψιμο διαφανών χρωμάτων</CropTransparentColors> + </OcrPreprocessing> + <Watermark> + <Title>Υδατόσημο</Title> + <WatermarkX>Υδατόσημο: {0}</WatermarkX> + <GenerateWatermarkTitle>Δημιουργία υδατόσημου</GenerateWatermarkTitle> + <SpreadOverEntireSubtitle>Εξάπλωση σε όλον τον υπότιτλο</SpreadOverEntireSubtitle> + <CurrentLineOnlyX>Μόνο σε τρέχουσα γραμμή: {0}</CurrentLineOnlyX> + <Generate>Δημιουργία</Generate> + <Remove>Αφαίρεση</Remove> + <BeforeWatermark>Πριν του υδατόσημου</BeforeWatermark> + <ErrorUnicodeEncodingOnly>Το υδατόσημολειτουργεί μόνο με κωδικοποίηση αρχείου unicode.</ErrorUnicodeEncodingOnly> + </Watermark> + <Waveform> + <ClickToAddWaveform>Κάντε κλικ για προσθήκη κυματομορφής</ClickToAddWaveform> + <ClickToAddWaveformAndSpectrogram>Κάντε κλικ για προσθήκη κυματομορφής/φασματογράμματος</ClickToAddWaveformAndSpectrogram> + <Seconds>δευτ.</Seconds> + <ZoomIn>Μεγέθυνση</ZoomIn> + <ZoomOut>Σμίκρυνση</ZoomOut> + <AddParagraphHere>Προσθήκη κειμένου</AddParagraphHere> + <AddParagraphHereAndPasteText>Προσθήκη κειμένου από το πρόχειρο</AddParagraphHereAndPasteText> + <SetParagraphAsSelection>Καθορισμός ως νέας επιλογής</SetParagraphAsSelection> + <FocusTextBox>Εστίαση πλαισίου κειμένου</FocusTextBox> + <GoToPrevious>Μετάβαση στον προηγούμενο υπότιτλο</GoToPrevious> + <GoToNext>Μετάβαση στον επόμενο υπότιτλο</GoToNext> + <DeleteParagraph>Διαγραφή κειμένου</DeleteParagraph> + <Split>Διαχωρισμός</Split> + <SplitAtCursor>Διαχωρισμός στη θέση του δείκτη</SplitAtCursor> + <MergeWithPrevious>Συγχώνευση με προηγούμενο</MergeWithPrevious> + <MergeWithNext>Συγχώνευση με επόμενο</MergeWithNext> + <ExtendToPrevious>Επέκταση μέχρι το προηγούμενο</ExtendToPrevious> + <ExtendToNext>Επέκταση μέχρι το επόμενο</ExtendToNext> + <PlaySelection>Αναπαραγωγή επιλογής</PlaySelection> + <ShowWaveformAndSpectrogram>Εμφάνιση κυματομορφής και φασματογράμματος</ShowWaveformAndSpectrogram> + <ShowWaveformOnly>Εμφάνιση μόνο κυματομορφής</ShowWaveformOnly> + <ShowSpectrogramOnly>Εμφάνιση μόνο φασματογράμματος</ShowSpectrogramOnly> + <AddSceneChange>Προσθήκη αλλαγής σκηνής</AddSceneChange> + <RemoveSceneChange>Αφαίρεση αλλαγής σκηνής</RemoveSceneChange> + <GuessTimeCodes>Μάντεψε τους κώδικες χρόνου...</GuessTimeCodes> + <SeekSilence>Αναζήτηση σιωπής...</SeekSilence> + <InsertSubtitleHere>Εισαγωγή υπότιτλου εδώ...</InsertSubtitleHere> + <CharsSecX>Χαρ/δευτ: {0:0.00}</CharsSecX> + <WordsMinX>Λέξεις/λεπτό: {0:0.00}</WordsMinX> + </Waveform> + <WaveformGenerateTimeCodes> + <Title>Εικασία κωδικών χρόνου</Title> + <StartFrom>Έναρξη από</StartFrom> + <CurrentVideoPosition>Τρέχουσα θέση βίντεο</CurrentVideoPosition> + <Beginning>Έναρξη</Beginning> + <DeleteLines>Διαγραφή γραμμών</DeleteLines> + <FromCurrentVideoPosition>Από την τρέχουσα θέση βίντεο</FromCurrentVideoPosition> + <DetectOptions>Εντοπισμός επιλογών</DetectOptions> + <ScanBlocksOfMs>Σάρωση των μπλοκ χιλιοστών του δευτερολέπτου</ScanBlocksOfMs> + <BlockAverageVolMin1>Η μέση τιμή των μπλοκ έντασης πρέπει να είναι πάνω από</BlockAverageVolMin1> + <BlockAverageVolMin2>% από τη μέση συνολική ένταση</BlockAverageVolMin2> + <BlockAverageVolMax1>Η μέση τιμή των μπλοκ έντασης πρέπει να είναι κάτω από</BlockAverageVolMax1> + <BlockAverageVolMax2>% από την μέγιστη συνολική ένταση</BlockAverageVolMax2> + <SplitLongLinesAt1>Διαχωρισμός μεγάλων υποτίτλων σε</SplitLongLinesAt1> + <SplitLongLinesAt2>χιλιοστά δευτερολέπτου</SplitLongLinesAt2> + <Other>Άλλο</Other> + </WaveformGenerateTimeCodes> + <WebVttNewVoice> + <Title>WebVTT - καθορισμός νέας φωνής</Title> + <VoiceName>Όνομα φωνής</VoiceName> + </WebVttNewVoice> </Language> \ No newline at end of file diff --git a/src/Languages/es-AR.xml b/src/ui/Languages/es-AR.xml similarity index 100% rename from src/Languages/es-AR.xml rename to src/ui/Languages/es-AR.xml diff --git a/src/Languages/es-ES.xml b/src/ui/Languages/es-ES.xml similarity index 100% rename from src/Languages/es-ES.xml rename to src/ui/Languages/es-ES.xml diff --git a/src/Languages/es-MX.xml b/src/ui/Languages/es-MX.xml similarity index 100% rename from src/Languages/es-MX.xml rename to src/ui/Languages/es-MX.xml diff --git a/src/Languages/eu-ES.xml b/src/ui/Languages/eu-ES.xml similarity index 100% rename from src/Languages/eu-ES.xml rename to src/ui/Languages/eu-ES.xml diff --git a/src/Languages/fa-IR.xml b/src/ui/Languages/fa-IR.xml similarity index 100% rename from src/Languages/fa-IR.xml rename to src/ui/Languages/fa-IR.xml diff --git a/src/Languages/fi-FI.xml b/src/ui/Languages/fi-FI.xml similarity index 100% rename from src/Languages/fi-FI.xml rename to src/ui/Languages/fi-FI.xml diff --git a/src/Languages/fr-BE.xml b/src/ui/Languages/fr-BE.xml similarity index 100% rename from src/Languages/fr-BE.xml rename to src/ui/Languages/fr-BE.xml diff --git a/src/Languages/fr-FR.xml b/src/ui/Languages/fr-FR.xml similarity index 100% rename from src/Languages/fr-FR.xml rename to src/ui/Languages/fr-FR.xml diff --git a/src/Languages/hr-HR.xml b/src/ui/Languages/hr-HR.xml similarity index 100% rename from src/Languages/hr-HR.xml rename to src/ui/Languages/hr-HR.xml diff --git a/src/Languages/hu-HU.xml b/src/ui/Languages/hu-HU.xml similarity index 100% rename from src/Languages/hu-HU.xml rename to src/ui/Languages/hu-HU.xml diff --git a/src/Languages/id-ID.xml b/src/ui/Languages/id-ID.xml similarity index 100% rename from src/Languages/id-ID.xml rename to src/ui/Languages/id-ID.xml diff --git a/src/Languages/it-IT.xml b/src/ui/Languages/it-IT.xml similarity index 100% rename from src/Languages/it-IT.xml rename to src/ui/Languages/it-IT.xml diff --git a/src/Languages/ja-JP.xml b/src/ui/Languages/ja-JP.xml similarity index 100% rename from src/Languages/ja-JP.xml rename to src/ui/Languages/ja-JP.xml diff --git a/src/Languages/ko-KR.xml b/src/ui/Languages/ko-KR.xml similarity index 100% rename from src/Languages/ko-KR.xml rename to src/ui/Languages/ko-KR.xml diff --git a/src/Languages/mk-MK.xml b/src/ui/Languages/mk-MK.xml similarity index 100% rename from src/Languages/mk-MK.xml rename to src/ui/Languages/mk-MK.xml diff --git a/src/Languages/nb-NO.xml b/src/ui/Languages/nb-NO.xml similarity index 100% rename from src/Languages/nb-NO.xml rename to src/ui/Languages/nb-NO.xml diff --git a/src/Languages/nl-NL.xml b/src/ui/Languages/nl-NL.xml similarity index 100% rename from src/Languages/nl-NL.xml rename to src/ui/Languages/nl-NL.xml diff --git a/src/Languages/pl-PL.xml b/src/ui/Languages/pl-PL.xml similarity index 100% rename from src/Languages/pl-PL.xml rename to src/ui/Languages/pl-PL.xml diff --git a/src/Languages/pt-BR.xml b/src/ui/Languages/pt-BR.xml similarity index 100% rename from src/Languages/pt-BR.xml rename to src/ui/Languages/pt-BR.xml diff --git a/src/Languages/pt-PT.xml b/src/ui/Languages/pt-PT.xml similarity index 100% rename from src/Languages/pt-PT.xml rename to src/ui/Languages/pt-PT.xml diff --git a/src/Languages/ro-RO.xml b/src/ui/Languages/ro-RO.xml similarity index 100% rename from src/Languages/ro-RO.xml rename to src/ui/Languages/ro-RO.xml diff --git a/src/Languages/ru-RU.xml b/src/ui/Languages/ru-RU.xml similarity index 100% rename from src/Languages/ru-RU.xml rename to src/ui/Languages/ru-RU.xml diff --git a/src/Languages/sl-SI.xml b/src/ui/Languages/sl-SI.xml similarity index 100% rename from src/Languages/sl-SI.xml rename to src/ui/Languages/sl-SI.xml diff --git a/src/Languages/sr-Cyrl-RS.xml b/src/ui/Languages/sr-Cyrl-RS.xml similarity index 100% rename from src/Languages/sr-Cyrl-RS.xml rename to src/ui/Languages/sr-Cyrl-RS.xml diff --git a/src/Languages/sr-Latn-RS.xml b/src/ui/Languages/sr-Latn-RS.xml similarity index 100% rename from src/Languages/sr-Latn-RS.xml rename to src/ui/Languages/sr-Latn-RS.xml diff --git a/src/Languages/sv-SE.xml b/src/ui/Languages/sv-SE.xml similarity index 100% rename from src/Languages/sv-SE.xml rename to src/ui/Languages/sv-SE.xml diff --git a/src/Languages/th-TH.xml b/src/ui/Languages/th-TH.xml similarity index 100% rename from src/Languages/th-TH.xml rename to src/ui/Languages/th-TH.xml diff --git a/src/Languages/tr-TR.xml b/src/ui/Languages/tr-TR.xml similarity index 100% rename from src/Languages/tr-TR.xml rename to src/ui/Languages/tr-TR.xml diff --git a/src/Languages/uk-UA.xml b/src/ui/Languages/uk-UA.xml similarity index 100% rename from src/Languages/uk-UA.xml rename to src/ui/Languages/uk-UA.xml diff --git a/src/Languages/vi-VN.xml b/src/ui/Languages/vi-VN.xml similarity index 100% rename from src/Languages/vi-VN.xml rename to src/ui/Languages/vi-VN.xml diff --git a/src/Languages/zh-Hans.xml b/src/ui/Languages/zh-Hans.xml similarity index 100% rename from src/Languages/zh-Hans.xml rename to src/ui/Languages/zh-Hans.xml diff --git a/src/Languages/zh-TW.xml b/src/ui/Languages/zh-TW.xml similarity index 100% rename from src/Languages/zh-TW.xml rename to src/ui/Languages/zh-TW.xml diff --git a/src/Logic/ColorChooser/ColorChangedEventArgs.cs b/src/ui/Logic/ColorChooser/ColorChangedEventArgs.cs similarity index 100% rename from src/Logic/ColorChooser/ColorChangedEventArgs.cs rename to src/ui/Logic/ColorChooser/ColorChangedEventArgs.cs diff --git a/src/Logic/ColorChooser/ColorHandler.cs b/src/ui/Logic/ColorChooser/ColorHandler.cs similarity index 100% rename from src/Logic/ColorChooser/ColorHandler.cs rename to src/ui/Logic/ColorChooser/ColorHandler.cs diff --git a/src/Logic/ColorChooser/ColorWheel.cs b/src/ui/Logic/ColorChooser/ColorWheel.cs similarity index 100% rename from src/Logic/ColorChooser/ColorWheel.cs rename to src/ui/Logic/ColorChooser/ColorWheel.cs diff --git a/src/Logic/CommandLineConvert/BluRaySupToBluRaySup.cs b/src/ui/Logic/CommandLineConvert/BluRaySupToBluRaySup.cs similarity index 100% rename from src/Logic/CommandLineConvert/BluRaySupToBluRaySup.cs rename to src/ui/Logic/CommandLineConvert/BluRaySupToBluRaySup.cs diff --git a/src/Logic/CommandLineConvert/CommandLineConverter.cs b/src/ui/Logic/CommandLineConvert/CommandLineConverter.cs similarity index 100% rename from src/Logic/CommandLineConvert/CommandLineConverter.cs rename to src/ui/Logic/CommandLineConvert/CommandLineConverter.cs diff --git a/src/Logic/CommandLineConvert/TsConvert.cs b/src/ui/Logic/CommandLineConvert/TsConvert.cs similarity index 100% rename from src/Logic/CommandLineConvert/TsConvert.cs rename to src/ui/Logic/CommandLineConvert/TsConvert.cs diff --git a/src/Logic/CommandLineConvert/TsToBdnXml.cs b/src/ui/Logic/CommandLineConvert/TsToBdnXml.cs similarity index 100% rename from src/Logic/CommandLineConvert/TsToBdnXml.cs rename to src/ui/Logic/CommandLineConvert/TsToBdnXml.cs diff --git a/src/Logic/CommandLineConvert/TsToBluRaySup.cs b/src/ui/Logic/CommandLineConvert/TsToBluRaySup.cs similarity index 100% rename from src/Logic/CommandLineConvert/TsToBluRaySup.cs rename to src/ui/Logic/CommandLineConvert/TsToBluRaySup.cs diff --git a/src/Logic/DarkTheme.cs b/src/ui/Logic/DarkTheme.cs similarity index 100% rename from src/Logic/DarkTheme.cs rename to src/ui/Logic/DarkTheme.cs diff --git a/src/Logic/FindReplaceDialogHelper.cs b/src/ui/Logic/FindReplaceDialogHelper.cs similarity index 97% rename from src/Logic/FindReplaceDialogHelper.cs rename to src/ui/Logic/FindReplaceDialogHelper.cs index 91144b4a3..2a9d5b446 100644 --- a/src/Logic/FindReplaceDialogHelper.cs +++ b/src/ui/Logic/FindReplaceDialogHelper.cs @@ -1,445 +1,445 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Enums; -using System; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic -{ - public class FindReplaceDialogHelper - { - private const string SeparatorChars = " #><-\"„”“[]'‘`´¶(){}♪,.!?:;¿¡.…—،؟\r\n\u2028"; - private Regex _regEx; - - public bool Success { get; set; } - public ReplaceType FindReplaceType { get; set; } - public int SelectedIndex { get; set; } - public int SelectedPosition { get; set; } - public int ReplaceFromPosition { get; set; } - public int StartLineIndex { get; set; } - public bool MatchInOriginal { get; set; } - public bool InProgress { get; set; } - - public int FindTextLength { get; private set; } - - public string FindText { get; } - - public string ReplaceText { get; } - - public FindReplaceDialogHelper(ReplaceType findType, string findText, Regex regEx, string replaceText, int startLineIndex) - { - ReplaceText = string.Empty; - FindReplaceType = findType; - FindText = findText; - - ReplaceText = replaceText; - if (ReplaceText != null) - { - ReplaceText = RegexUtils.FixNewLine(ReplaceText); - } - - _regEx = regEx; - FindTextLength = findText.Length; - StartLineIndex = startLineIndex; - MatchInOriginal = false; - } - - public bool Find(Subtitle subtitle, Subtitle originalSubtitle, int startIndex, int startPosition = 0) - { - return FindNext(subtitle, originalSubtitle, startIndex, startPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle); - } - - public bool Find(TextBox textBox, int startIndex) - { - return FindNext(textBox.Text, startIndex); - } - - private int FindPositionInText(string text, int startIndex) - { - if (startIndex >= text.Length && !(FindReplaceType.FindType == FindType.RegEx && startIndex == 0)) - { - return -1; - } - - if (FindReplaceType.FindType == FindType.CaseSensitive || FindReplaceType.FindType == FindType.Normal) - { - var comparison = GetComparison(); - var idx = text.IndexOf(FindText, startIndex, comparison); - while (idx >= 0) - { - if (FindReplaceType.WholeWord) - { - var startOk = idx == 0 || SeparatorChars.Contains(text[idx - 1]); - var endOk = idx + FindText.Length == text.Length || SeparatorChars.Contains(text[idx + FindText.Length]); - if (startOk && endOk) - { - return idx; - } - } - else - { - return idx; - } - idx = text.IndexOf(FindText, idx + FindText.Length, comparison); - } - return -1; - } - - var match = _regEx.Match(text, startIndex); - if (match.Success) - { - string groupName = RegexUtils.GetRegExGroup(FindText); - if (groupName != null && match.Groups[groupName] != null && match.Groups[groupName].Success) - { - FindTextLength = match.Groups[groupName].Length; - return match.Groups[groupName].Index; - } - FindTextLength = match.Length; - return match.Index; - } - return -1; - } - - public bool FindNext(Subtitle subtitle, Subtitle originalSubtitle, int startIndex, int position, bool allowEditOfOriginalSubtitle) - { - Success = false; - int index = 0; - if (position < 0) - { - position = 0; - } - - bool first = true; - foreach (Paragraph p in subtitle.Paragraphs) - { - if (index >= startIndex) - { - if (!first) - { - position = 0; - } - - int pos; - if (!MatchInOriginal) - { - pos = FindPositionInText(p.Text, position); - if (pos >= 0) - { - MatchInOriginal = false; - SelectedIndex = index; - SelectedPosition = pos; - ReplaceFromPosition = pos; - Success = true; - return true; - } - position = 0; - } - if (index < subtitle.Paragraphs.Count - 1) - { - MatchInOriginal = false; - } - - if (originalSubtitle != null && allowEditOfOriginalSubtitle) - { - Paragraph o = Utilities.GetOriginalParagraph(index, p, originalSubtitle.Paragraphs); - if (o != null) - { - pos = FindPositionInText(o.Text, position); - if (pos >= 0) - { - MatchInOriginal = true; - SelectedIndex = index; - SelectedPosition = pos; - ReplaceFromPosition = pos; - Success = true; - return true; - } - } - } - first = false; - } - index++; - } - return false; - } - - public bool FindPrevious(Subtitle subtitle, Subtitle originalSubtitle, int startIndex, int position, bool allowEditOfOriginalSubtitle) - { - Success = false; - int index = startIndex; - bool first = true; - for (var i = startIndex; i >= 0; i--) - { - Paragraph p = subtitle.Paragraphs[i]; - - if (originalSubtitle != null && allowEditOfOriginalSubtitle) - { - if (!first || MatchInOriginal) - { - Paragraph o = Utilities.GetOriginalParagraph(index, p, originalSubtitle.Paragraphs); - if (o != null) - { - if (!first) - { - position = o.Text.Length - 1; - } - - for (var j = 0; j <= position; j++) - { - if (position - j >= 0 && position - j + j < o.Text.Length) - { - var t = o.Text.Substring(position - j, j); - int pos = FindPositionInText(t, 0); - if (pos >= 0) - { - pos += position - j; - MatchInOriginal = true; - SelectedIndex = index; - SelectedPosition = pos; - ReplaceFromPosition = pos; - Success = true; - return true; - } - } - } - } - position = p.Text.Length - 1; - } - } - - MatchInOriginal = false; - if (!first) - { - position = p.Text.Length - 1; - } - - for (var j = 0; j <= position; j++) - { - if (position - j >= 0 && position < p.Text.Length) - { - var t = p.Text.Substring(position - j, j + 1); - int pos = FindPositionInText(t, 0); - if (pos >= 0) - { - pos += position - j; - MatchInOriginal = false; - SelectedIndex = index; - SelectedPosition = pos; - ReplaceFromPosition = pos; - Success = true; - return true; - } - } - } - position = 0; - first = false; - index--; - } - return false; - } - - public static ContextMenu GetRegExContextMenu(TextBox textBox) - { - var cm = new ContextMenu(); - var l = Configuration.Settings.Language.RegularExpressionContextMenu; - cm.MenuItems.Add(l.WordBoundary, delegate { textBox.SelectedText = "\\b"; }); - cm.MenuItems.Add(l.NonWordBoundary, delegate { textBox.SelectedText = "\\B"; }); - cm.MenuItems.Add(l.NewLine, delegate { textBox.SelectedText = "\\r\\n"; }); - cm.MenuItems.Add(l.AnyDigit, delegate { textBox.SelectedText = "\\d"; }); - cm.MenuItems.Add(l.NonDigit, delegate { textBox.SelectedText = "\\D"; }); - cm.MenuItems.Add(l.AnyCharacter, delegate { textBox.SelectedText = "."; }); - cm.MenuItems.Add(l.AnyWhitespace, delegate { textBox.SelectedText = "\\s"; }); - cm.MenuItems.Add(l.NonSpaceCharacter, delegate { textBox.SelectedText = "\\S"; }); - cm.MenuItems.Add(l.ZeroOrMore, delegate { textBox.SelectedText = "*"; }); - cm.MenuItems.Add(l.OneOrMore, delegate { textBox.SelectedText = "+"; }); - cm.MenuItems.Add(l.InCharacterGroup, delegate { textBox.SelectedText = "[test]"; }); - cm.MenuItems.Add(l.NotInCharacterGroup, delegate { textBox.SelectedText = "[^test]"; }); - return cm; - } - - public static ContextMenu GetRegExContextMenu(ComboBox comboBox) - { - var cm = new ContextMenu(); - var l = Configuration.Settings.Language.RegularExpressionContextMenu; - cm.MenuItems.Add(l.WordBoundary, delegate { comboBox.SelectedText = "\\b"; }); - cm.MenuItems.Add(l.NonWordBoundary, delegate { comboBox.SelectedText = "\\B"; }); - cm.MenuItems.Add(l.NewLine, delegate { comboBox.SelectedText = "\\r\\n"; }); - cm.MenuItems.Add(l.AnyDigit, delegate { comboBox.SelectedText = "\\d"; }); - cm.MenuItems.Add(l.NonDigit, delegate { comboBox.SelectedText = "\\D"; }); - cm.MenuItems.Add(l.AnyCharacter, delegate { comboBox.SelectedText = "."; }); - cm.MenuItems.Add(l.AnyWhitespace, delegate { comboBox.SelectedText = "\\s"; }); - cm.MenuItems.Add(l.NonSpaceCharacter, delegate { comboBox.SelectedText = "\\S"; }); - cm.MenuItems.Add(l.ZeroOrMore, delegate { comboBox.SelectedText = "*"; }); - cm.MenuItems.Add(l.OneOrMore, delegate { comboBox.SelectedText = "+"; }); - cm.MenuItems.Add(l.InCharacterGroup, delegate { comboBox.SelectedText = "[test]"; }); - cm.MenuItems.Add(l.NotInCharacterGroup, delegate { comboBox.SelectedText = "[^test]"; }); - return cm; - } - - public static ContextMenu GetReplaceTextContextMenu(TextBox textBox) - { - var cm = new ContextMenu(); - cm.MenuItems.Add(Configuration.Settings.Language.RegularExpressionContextMenu.NewLineShort, delegate { textBox.SelectedText = "\\n"; }); - return cm; - } - - public bool FindNext(string text, int startIndex) - { - Success = false; - startIndex++; - if (startIndex < text.Length) - { - if (FindReplaceType.FindType == FindType.RegEx) - { - Match match = _regEx.Match(text, startIndex); - if (match.Success) - { - string groupName = RegexUtils.GetRegExGroup(FindText); - if (groupName != null && match.Groups[groupName] != null && match.Groups[groupName].Success) - { - FindTextLength = match.Groups[groupName].Length; - SelectedIndex = match.Groups[groupName].Index; - } - else - { - FindTextLength = match.Length; - SelectedIndex = match.Index; - } - Success = true; - } - return match.Success; - } - string searchText = text.Substring(startIndex); - int pos = FindPositionInText(searchText, 0); - if (pos >= 0) - { - SelectedIndex = pos + startIndex; - return true; - } - } - return false; - } - - public bool FindPrevious(string text, int startIndex) - { - Success = false; - startIndex--; - if (startIndex < text.Length) - { - if (FindReplaceType.FindType == FindType.RegEx) - { - var matches = _regEx.Matches(text.Substring(0, startIndex)); - if (matches.Count > 0) - { - string groupName = RegexUtils.GetRegExGroup(FindText); - var last = matches[matches.Count - 1]; - if (groupName != null && last.Groups[groupName] != null && last.Groups[groupName].Success) - { - FindTextLength = last.Groups[groupName].Length; - SelectedIndex = last.Groups[groupName].Index; - } - else - { - FindTextLength = last.Length; - SelectedIndex = last.Index; - } - Success = true; - } - return Success; - } - string searchText = text.Substring(0, startIndex); - int pos = -1; - var comparison = GetComparison(); - var idx = searchText.LastIndexOf(FindText, startIndex, comparison); - while (idx >= 0) - { - if (FindReplaceType.WholeWord) - { - var startOk = idx == 0 || SeparatorChars.Contains(searchText[idx - 1]); - var endOk = idx + FindText.Length == searchText.Length || SeparatorChars.Contains(searchText[idx + FindText.Length]); - if (startOk && endOk) - { - pos = idx; - break; - } - } - else - { - pos = idx; - break; - } - searchText = text.Substring(0, idx); - idx = searchText.LastIndexOf(FindText, comparison); - } - if (pos >= 0) - { - SelectedIndex = pos; - return true; - } - } - return false; - } - - - public int FindCount(Subtitle subtitle, bool wholeWord) - { - var count = 0; - // validate pattern if find type is regex - if (FindReplaceType.FindType == FindType.RegEx) - { - var findText = RegexUtils.FixNewLine(FindText); - if (!RegexUtils.IsValidRegex(findText)) - { - MessageBox.Show(Configuration.Settings.Language.General.RegularExpressionIsNotValid); - return count; - } - _regEx = new Regex(findText); - } - var comparison = GetComparison(); - foreach (var p in subtitle.Paragraphs) - { - if (FindReplaceType.FindType == FindType.RegEx) - { - count += _regEx.Matches(p.Text).Count; - } - else - { - if (p.Text.Length < FindText.Length) - { - continue; - } - count += GetWordCount(p.Text, FindText, wholeWord, comparison); - } - } - return count; - } - - private int GetWordCount(string text, string pattern, bool matchWholeWord, StringComparison comparison) - { - var idx = text.IndexOf(pattern, comparison); - var count = 0; - while (idx >= 0) - { - if (matchWholeWord) - { - var startOk = (idx == 0) || (SeparatorChars.Contains(text[idx - 1])); - var endOk = (idx + pattern.Length == text.Length) || (SeparatorChars.Contains(text[idx + pattern.Length])); - if (startOk && endOk) - { - count++; - } - } - else - { - count++; - } - idx = text.IndexOf(pattern, idx + pattern.Length, comparison); - } - return count; - } - - private StringComparison GetComparison() => FindReplaceType.FindType == FindType.Normal ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Enums; +using System; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic +{ + public class FindReplaceDialogHelper + { + private const string SeparatorChars = " #><-\"„”“[]'‘`´¶(){}♪,.!?:;¿¡.…—،؟\r\n\u2028"; + private Regex _regEx; + + public bool Success { get; set; } + public ReplaceType FindReplaceType { get; set; } + public int SelectedIndex { get; set; } + public int SelectedPosition { get; set; } + public int ReplaceFromPosition { get; set; } + public int StartLineIndex { get; set; } + public bool MatchInOriginal { get; set; } + public bool InProgress { get; set; } + + public int FindTextLength { get; private set; } + + public string FindText { get; } + + public string ReplaceText { get; } + + public FindReplaceDialogHelper(ReplaceType findType, string findText, Regex regEx, string replaceText, int startLineIndex) + { + ReplaceText = string.Empty; + FindReplaceType = findType; + FindText = findText; + + ReplaceText = replaceText; + if (ReplaceText != null) + { + ReplaceText = RegexUtils.FixNewLine(ReplaceText); + } + + _regEx = regEx; + FindTextLength = findText.Length; + StartLineIndex = startLineIndex; + MatchInOriginal = false; + } + + public bool Find(Subtitle subtitle, Subtitle originalSubtitle, int startIndex, int startPosition = 0) + { + return FindNext(subtitle, originalSubtitle, startIndex, startPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle); + } + + public bool Find(TextBox textBox, int startIndex) + { + return FindNext(textBox.Text, startIndex); + } + + private int FindPositionInText(string text, int startIndex) + { + if (startIndex >= text.Length && !(FindReplaceType.FindType == FindType.RegEx && startIndex == 0)) + { + return -1; + } + + if (FindReplaceType.FindType == FindType.CaseSensitive || FindReplaceType.FindType == FindType.Normal) + { + var comparison = GetComparison(); + var idx = text.IndexOf(FindText, startIndex, comparison); + while (idx >= 0) + { + if (FindReplaceType.WholeWord) + { + var startOk = idx == 0 || SeparatorChars.Contains(text[idx - 1]); + var endOk = idx + FindText.Length == text.Length || SeparatorChars.Contains(text[idx + FindText.Length]); + if (startOk && endOk) + { + return idx; + } + } + else + { + return idx; + } + idx = text.IndexOf(FindText, idx + FindText.Length, comparison); + } + return -1; + } + + var match = _regEx.Match(text, startIndex); + if (match.Success) + { + string groupName = RegexUtils.GetRegExGroup(FindText); + if (groupName != null && match.Groups[groupName] != null && match.Groups[groupName].Success) + { + FindTextLength = match.Groups[groupName].Length; + return match.Groups[groupName].Index; + } + FindTextLength = match.Length; + return match.Index; + } + return -1; + } + + public bool FindNext(Subtitle subtitle, Subtitle originalSubtitle, int startIndex, int position, bool allowEditOfOriginalSubtitle) + { + Success = false; + int index = 0; + if (position < 0) + { + position = 0; + } + + bool first = true; + foreach (Paragraph p in subtitle.Paragraphs) + { + if (index >= startIndex) + { + if (!first) + { + position = 0; + } + + int pos; + if (!MatchInOriginal) + { + pos = FindPositionInText(p.Text, position); + if (pos >= 0) + { + MatchInOriginal = false; + SelectedIndex = index; + SelectedPosition = pos; + ReplaceFromPosition = pos; + Success = true; + return true; + } + position = 0; + } + if (index < subtitle.Paragraphs.Count - 1) + { + MatchInOriginal = false; + } + + if (originalSubtitle != null && allowEditOfOriginalSubtitle) + { + Paragraph o = Utilities.GetOriginalParagraph(index, p, originalSubtitle.Paragraphs); + if (o != null) + { + pos = FindPositionInText(o.Text, position); + if (pos >= 0) + { + MatchInOriginal = true; + SelectedIndex = index; + SelectedPosition = pos; + ReplaceFromPosition = pos; + Success = true; + return true; + } + } + } + first = false; + } + index++; + } + return false; + } + + public bool FindPrevious(Subtitle subtitle, Subtitle originalSubtitle, int startIndex, int position, bool allowEditOfOriginalSubtitle) + { + Success = false; + int index = startIndex; + bool first = true; + for (var i = startIndex; i >= 0; i--) + { + Paragraph p = subtitle.Paragraphs[i]; + + if (originalSubtitle != null && allowEditOfOriginalSubtitle) + { + if (!first || MatchInOriginal) + { + Paragraph o = Utilities.GetOriginalParagraph(index, p, originalSubtitle.Paragraphs); + if (o != null) + { + if (!first) + { + position = o.Text.Length - 1; + } + + for (var j = 0; j <= position; j++) + { + if (position - j >= 0 && position - j + j < o.Text.Length) + { + var t = o.Text.Substring(position - j, j); + int pos = FindPositionInText(t, 0); + if (pos >= 0) + { + pos += position - j; + MatchInOriginal = true; + SelectedIndex = index; + SelectedPosition = pos; + ReplaceFromPosition = pos; + Success = true; + return true; + } + } + } + } + position = p.Text.Length - 1; + } + } + + MatchInOriginal = false; + if (!first) + { + position = p.Text.Length - 1; + } + + for (var j = 0; j <= position; j++) + { + if (position - j >= 0 && position < p.Text.Length) + { + var t = p.Text.Substring(position - j, j + 1); + int pos = FindPositionInText(t, 0); + if (pos >= 0) + { + pos += position - j; + MatchInOriginal = false; + SelectedIndex = index; + SelectedPosition = pos; + ReplaceFromPosition = pos; + Success = true; + return true; + } + } + } + position = 0; + first = false; + index--; + } + return false; + } + + public static ContextMenu GetRegExContextMenu(TextBox textBox) + { + var cm = new ContextMenu(); + var l = Configuration.Settings.Language.RegularExpressionContextMenu; + cm.MenuItems.Add(l.WordBoundary, delegate { textBox.SelectedText = "\\b"; }); + cm.MenuItems.Add(l.NonWordBoundary, delegate { textBox.SelectedText = "\\B"; }); + cm.MenuItems.Add(l.NewLine, delegate { textBox.SelectedText = "\\r\\n"; }); + cm.MenuItems.Add(l.AnyDigit, delegate { textBox.SelectedText = "\\d"; }); + cm.MenuItems.Add(l.NonDigit, delegate { textBox.SelectedText = "\\D"; }); + cm.MenuItems.Add(l.AnyCharacter, delegate { textBox.SelectedText = "."; }); + cm.MenuItems.Add(l.AnyWhitespace, delegate { textBox.SelectedText = "\\s"; }); + cm.MenuItems.Add(l.NonSpaceCharacter, delegate { textBox.SelectedText = "\\S"; }); + cm.MenuItems.Add(l.ZeroOrMore, delegate { textBox.SelectedText = "*"; }); + cm.MenuItems.Add(l.OneOrMore, delegate { textBox.SelectedText = "+"; }); + cm.MenuItems.Add(l.InCharacterGroup, delegate { textBox.SelectedText = "[test]"; }); + cm.MenuItems.Add(l.NotInCharacterGroup, delegate { textBox.SelectedText = "[^test]"; }); + return cm; + } + + public static ContextMenu GetRegExContextMenu(ComboBox comboBox) + { + var cm = new ContextMenu(); + var l = Configuration.Settings.Language.RegularExpressionContextMenu; + cm.MenuItems.Add(l.WordBoundary, delegate { comboBox.SelectedText = "\\b"; }); + cm.MenuItems.Add(l.NonWordBoundary, delegate { comboBox.SelectedText = "\\B"; }); + cm.MenuItems.Add(l.NewLine, delegate { comboBox.SelectedText = "\\r\\n"; }); + cm.MenuItems.Add(l.AnyDigit, delegate { comboBox.SelectedText = "\\d"; }); + cm.MenuItems.Add(l.NonDigit, delegate { comboBox.SelectedText = "\\D"; }); + cm.MenuItems.Add(l.AnyCharacter, delegate { comboBox.SelectedText = "."; }); + cm.MenuItems.Add(l.AnyWhitespace, delegate { comboBox.SelectedText = "\\s"; }); + cm.MenuItems.Add(l.NonSpaceCharacter, delegate { comboBox.SelectedText = "\\S"; }); + cm.MenuItems.Add(l.ZeroOrMore, delegate { comboBox.SelectedText = "*"; }); + cm.MenuItems.Add(l.OneOrMore, delegate { comboBox.SelectedText = "+"; }); + cm.MenuItems.Add(l.InCharacterGroup, delegate { comboBox.SelectedText = "[test]"; }); + cm.MenuItems.Add(l.NotInCharacterGroup, delegate { comboBox.SelectedText = "[^test]"; }); + return cm; + } + + public static ContextMenu GetReplaceTextContextMenu(TextBox textBox) + { + var cm = new ContextMenu(); + cm.MenuItems.Add(Configuration.Settings.Language.RegularExpressionContextMenu.NewLineShort, delegate { textBox.SelectedText = "\\n"; }); + return cm; + } + + public bool FindNext(string text, int startIndex) + { + Success = false; + startIndex++; + if (startIndex < text.Length) + { + if (FindReplaceType.FindType == FindType.RegEx) + { + Match match = _regEx.Match(text, startIndex); + if (match.Success) + { + string groupName = RegexUtils.GetRegExGroup(FindText); + if (groupName != null && match.Groups[groupName] != null && match.Groups[groupName].Success) + { + FindTextLength = match.Groups[groupName].Length; + SelectedIndex = match.Groups[groupName].Index; + } + else + { + FindTextLength = match.Length; + SelectedIndex = match.Index; + } + Success = true; + } + return match.Success; + } + string searchText = text.Substring(startIndex); + int pos = FindPositionInText(searchText, 0); + if (pos >= 0) + { + SelectedIndex = pos + startIndex; + return true; + } + } + return false; + } + + public bool FindPrevious(string text, int startIndex) + { + Success = false; + startIndex--; + if (startIndex < text.Length) + { + if (FindReplaceType.FindType == FindType.RegEx) + { + var matches = _regEx.Matches(text.Substring(0, startIndex)); + if (matches.Count > 0) + { + string groupName = RegexUtils.GetRegExGroup(FindText); + var last = matches[matches.Count - 1]; + if (groupName != null && last.Groups[groupName] != null && last.Groups[groupName].Success) + { + FindTextLength = last.Groups[groupName].Length; + SelectedIndex = last.Groups[groupName].Index; + } + else + { + FindTextLength = last.Length; + SelectedIndex = last.Index; + } + Success = true; + } + return Success; + } + string searchText = text.Substring(0, startIndex); + int pos = -1; + var comparison = GetComparison(); + var idx = searchText.LastIndexOf(FindText, startIndex, comparison); + while (idx >= 0) + { + if (FindReplaceType.WholeWord) + { + var startOk = idx == 0 || SeparatorChars.Contains(searchText[idx - 1]); + var endOk = idx + FindText.Length == searchText.Length || SeparatorChars.Contains(searchText[idx + FindText.Length]); + if (startOk && endOk) + { + pos = idx; + break; + } + } + else + { + pos = idx; + break; + } + searchText = text.Substring(0, idx); + idx = searchText.LastIndexOf(FindText, comparison); + } + if (pos >= 0) + { + SelectedIndex = pos; + return true; + } + } + return false; + } + + + public int FindCount(Subtitle subtitle, bool wholeWord) + { + var count = 0; + // validate pattern if find type is regex + if (FindReplaceType.FindType == FindType.RegEx) + { + var findText = RegexUtils.FixNewLine(FindText); + if (!RegexUtils.IsValidRegex(findText)) + { + MessageBox.Show(Configuration.Settings.Language.General.RegularExpressionIsNotValid); + return count; + } + _regEx = new Regex(findText); + } + var comparison = GetComparison(); + foreach (var p in subtitle.Paragraphs) + { + if (FindReplaceType.FindType == FindType.RegEx) + { + count += _regEx.Matches(p.Text).Count; + } + else + { + if (p.Text.Length < FindText.Length) + { + continue; + } + count += GetWordCount(p.Text, FindText, wholeWord, comparison); + } + } + return count; + } + + private int GetWordCount(string text, string pattern, bool matchWholeWord, StringComparison comparison) + { + var idx = text.IndexOf(pattern, comparison); + var count = 0; + while (idx >= 0) + { + if (matchWholeWord) + { + var startOk = (idx == 0) || (SeparatorChars.Contains(text[idx - 1])); + var endOk = (idx + pattern.Length == text.Length) || (SeparatorChars.Contains(text[idx + pattern.Length])); + if (startOk && endOk) + { + count++; + } + } + else + { + count++; + } + idx = text.IndexOf(pattern, idx + pattern.Length, comparison); + } + return count; + } + + private StringComparison GetComparison() => FindReplaceType.FindType == FindType.Normal ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; + + } +} diff --git a/src/Logic/ListViewSorter.cs b/src/ui/Logic/ListViewSorter.cs similarity index 100% rename from src/Logic/ListViewSorter.cs rename to src/ui/Logic/ListViewSorter.cs diff --git a/src/Logic/MainShortcuts.cs b/src/ui/Logic/MainShortcuts.cs similarity index 100% rename from src/Logic/MainShortcuts.cs rename to src/ui/Logic/MainShortcuts.cs diff --git a/src/Logic/NativeMethods.cs b/src/ui/Logic/NativeMethods.cs similarity index 100% rename from src/Logic/NativeMethods.cs rename to src/ui/Logic/NativeMethods.cs diff --git a/src/Logic/Networking/NikseWebServiceSession.cs b/src/ui/Logic/Networking/NikseWebServiceSession.cs similarity index 97% rename from src/Logic/Networking/NikseWebServiceSession.cs rename to src/ui/Logic/Networking/NikseWebServiceSession.cs index c5112cb22..24b9cb30e 100644 --- a/src/Logic/Networking/NikseWebServiceSession.cs +++ b/src/ui/Logic/Networking/NikseWebServiceSession.cs @@ -1,411 +1,411 @@ -using Nikse.SubtitleEdit.Core; -using System; -using System.Collections.Generic; -using System.Net; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic.Networking -{ - public class NikseWebServiceSession : IDisposable - { - public class ChatEntry - { - public SeNetworkService.SeUser User { get; set; } - public string Message { get; set; } - } - - public event EventHandler OnUpdateTimerTick; - public event EventHandler OnUpdateUserLogEntries; - - private System.Windows.Forms.Timer _timerWebService; - public List<UpdateLogEntry> UpdateLog { get; } = new List<UpdateLogEntry>(); - public List<ChatEntry> ChatLog { get; } = new List<ChatEntry>(); - private SeNetworkService.SeService _seWs; - private DateTime _seWsLastUpdate = DateTime.Now.AddYears(-1); - public SeNetworkService.SeUser CurrentUser { get; set; } - public Subtitle LastSubtitle { get; set; } - public Subtitle Subtitle { get; private set; } - public Subtitle OriginalSubtitle { get; private set; } - public string SessionId { get; private set; } - private string _userName; - private string _fileName; - public List<SeNetworkService.SeUser> Users { get; private set; } - public StringBuilder Log { get; } - - public string WebServiceUrl => _seWs.Url; - - public NikseWebServiceSession(Subtitle subtitle, Subtitle originalSubtitle, EventHandler onUpdateTimerTick, EventHandler onUpdateUserLogEntries) - { - Subtitle = subtitle; - OriginalSubtitle = originalSubtitle; - _timerWebService = new System.Windows.Forms.Timer(); - if (Configuration.Settings.NetworkSettings.PollIntervalSeconds < 1) - { - Configuration.Settings.NetworkSettings.PollIntervalSeconds = 1; - } - - _timerWebService.Interval = Configuration.Settings.NetworkSettings.PollIntervalSeconds * 1000; - _timerWebService.Tick += TimerWebServiceTick; - Log = new StringBuilder(); - OnUpdateTimerTick = onUpdateTimerTick; - OnUpdateUserLogEntries = onUpdateUserLogEntries; - } - - public void StartServer(string webServiceUrl, string sessionKey, string userName, string fileName, out string message) - { - SessionId = sessionKey; - _userName = userName; - _fileName = fileName; - var list = new List<SeNetworkService.SeSequence>(); - foreach (Paragraph p in Subtitle.Paragraphs) - { - list.Add(new SeNetworkService.SeSequence - { - StartMilliseconds = (int)p.StartTime.TotalMilliseconds, - EndMilliseconds = (int)p.EndTime.TotalMilliseconds, - Text = WebUtility.HtmlEncode(p.Text.Replace(Environment.NewLine, "<br />")) - }); - } - - var originalSubtitle = new List<SeNetworkService.SeSequence>(); - if (OriginalSubtitle != null) - { - foreach (Paragraph p in OriginalSubtitle.Paragraphs) - { - originalSubtitle.Add(new SeNetworkService.SeSequence - { - StartMilliseconds = (int)p.StartTime.TotalMilliseconds, - EndMilliseconds = (int)p.EndTime.TotalMilliseconds, - Text = WebUtility.HtmlEncode(p.Text.Replace(Environment.NewLine, "<br />")) - }); - } - } - - _seWs = new SeNetworkService.SeService - { - Url = webServiceUrl, - Proxy = Utilities.GetProxy() - }; - var user = _seWs.Start(sessionKey, userName, list.ToArray(), originalSubtitle.ToArray(), fileName, out message); - CurrentUser = user; - Users = new List<SeNetworkService.SeUser> { user }; - if (message == "OK") - { - _timerWebService.Start(); - } - } - - public bool Join(string webServiceUrl, string userName, string sessionKey, out string message) - { - SessionId = sessionKey; - _seWs = new SeNetworkService.SeService - { - Url = webServiceUrl, - Proxy = Utilities.GetProxy() - }; - Users = new List<SeNetworkService.SeUser>(); - var users = _seWs.Join(sessionKey, userName, out message); - if (message != "OK") - { - return false; - } - - string tempFileName; - Subtitle = new Subtitle(); - foreach (var sequence in _seWs.GetSubtitle(sessionKey, out tempFileName, out _)) - { - Subtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds)); - } - - _fileName = tempFileName; - - OriginalSubtitle = new Subtitle(); - var sequences = _seWs.GetOriginalSubtitle(sessionKey); - if (sequences != null) - { - foreach (var sequence in sequences) - { - OriginalSubtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds)); - } - } - - SessionId = sessionKey; - CurrentUser = users[users.Length - 1]; // me - foreach (var user in users) - { - Users.Add(user); - } - - ReloadFromWs(); - _timerWebService.Start(); - return true; - } - - private void TimerWebServiceTick(object sender, EventArgs e) - { - OnUpdateTimerTick?.Invoke(sender, e); - } - - public void TimerStop() - { - _timerWebService.Stop(); - } - - public void TimerStart() - { - _timerWebService.Start(); - } - - public List<SeNetworkService.SeUpdate> GetUpdates(out string message, out int numberOfLines) - { - List<SeNetworkService.SeUpdate> list = new List<SeNetworkService.SeUpdate>(); - var updates = _seWs.GetUpdates(SessionId, CurrentUser.UserName, _seWsLastUpdate, out message, out var newUpdateTime, out numberOfLines); - if (updates != null) - { - foreach (var update in updates) - { - list.Add(update); - } - } - _seWsLastUpdate = newUpdateTime; - return list; - } - - public Subtitle ReloadSubtitle() - { - Subtitle.Paragraphs.Clear(); - var sequences = _seWs.GetSubtitle(SessionId, out var tempFileName, out var updateTime); - _fileName = tempFileName; - _seWsLastUpdate = updateTime; - if (sequences != null) - { - foreach (var sequence in sequences) - { - Subtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds)); - } - } - return Subtitle; - } - - private void ReloadFromWs() - { - if (_seWs != null) - { - Subtitle = new Subtitle(); - var sequences = _seWs.GetSubtitle(SessionId, out _fileName, out _seWsLastUpdate); - foreach (var sequence in sequences) - { - var p = new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds); - Subtitle.Paragraphs.Add(p); - } - Subtitle.Renumber(); - LastSubtitle = new Subtitle(Subtitle); - } - } - - public void AppendToLog(string text) - { - string timestamp = DateTime.Now.ToLongTimeString(); - Log.AppendLine(timestamp + ": " + UiUtil.GetListViewTextFromString(text.TrimEnd())); - } - - public string GetLog() - { - return Log.ToString(); - } - - public void SendChatMessage(string message) - { - _seWs.SendMessage(SessionId, WebUtility.HtmlEncode(message.Replace(Environment.NewLine, "<br />")), CurrentUser); - } - - internal void UpdateLine(int index, Paragraph paragraph) - { - _seWs.UpdateLine(SessionId, index, new SeNetworkService.SeSequence - { - StartMilliseconds = (int)paragraph.StartTime.TotalMilliseconds, - EndMilliseconds = (int)paragraph.EndTime.TotalMilliseconds, - Text = WebUtility.HtmlEncode(paragraph.Text.Replace(Environment.NewLine, "<br />")) - }, CurrentUser); - AddToWsUserLog(CurrentUser, index, "UPD", true); - } - - public void CheckForAndSubmitUpdates() - { - // check for changes in text/time codes (not insert/delete) - if (LastSubtitle != null) - { - for (int i = 0; i < Subtitle.Paragraphs.Count; i++) - { - var last = LastSubtitle.GetParagraphOrDefault(i); - var current = Subtitle.GetParagraphOrDefault(i); - if (last != null && current != null) - { - if (Math.Abs(last.StartTime.TotalMilliseconds - current.StartTime.TotalMilliseconds) > 0.01 || - Math.Abs(last.EndTime.TotalMilliseconds - current.EndTime.TotalMilliseconds) > 0.01 || - last.Text != current.Text) - { - UpdateLine(i, current); - } - } - } - } - } - - public void AddToWsUserLog(SeNetworkService.SeUser user, int pos, string action, bool updateUi) - { - for (int i = 0; i < UpdateLog.Count; i++) - { - if (UpdateLog[i].Index == pos) - { - UpdateLog.RemoveAt(i); - break; - } - } - - UpdateLog.Add(new UpdateLogEntry(0, user.UserName, pos, action)); - if (updateUi) - { - OnUpdateUserLogEntries?.Invoke(null, null); - } - } - - internal void Leave() - { - try - { - _seWs.Leave(SessionId, CurrentUser.UserName); - } - catch - { - // ignored - } - } - - internal void DeleteLines(List<int> indices) - { - _seWs.DeleteLines(SessionId, indices.ToArray(), CurrentUser); - foreach (int index in indices) - { - AdjustUpdateLogToDelete(index); - AppendToLog(string.Format(Configuration.Settings.Language.Main.NetworkDelete, CurrentUser.UserName, CurrentUser.Ip, index)); - } - } - - internal void InsertLine(int index, Paragraph newParagraph) - { - _seWs.InsertLine(SessionId, index, (int)newParagraph.StartTime.TotalMilliseconds, (int)newParagraph.EndTime.TotalMilliseconds, newParagraph.Text, CurrentUser); - AppendToLog(string.Format(Configuration.Settings.Language.Main.NetworkInsert, CurrentUser.UserName, CurrentUser.Ip, index, UiUtil.GetListViewTextFromString(newParagraph.Text))); - } - - internal void AdjustUpdateLogToInsert(int index) - { - foreach (var logEntry in UpdateLog) - { - if (logEntry.Index >= index) - { - logEntry.Index++; - } - } - } - - internal void AdjustUpdateLogToDelete(int index) - { - UpdateLogEntry removeThis = null; - foreach (var logEntry in UpdateLog) - { - if (logEntry.Index == index) - { - removeThis = logEntry; - } - else if (logEntry.Index > index) - { - logEntry.Index--; - } - } - if (removeThis != null) - { - UpdateLog.Remove(removeThis); - } - } - - internal string Restart() - { - string message = string.Empty; - int retries = 0; - const int maxRetries = 10; - while (retries < maxRetries) - { - try - { - System.Threading.Thread.Sleep(200); - StartServer(_seWs.Url, SessionId, _userName, _fileName, out message); - retries = maxRetries; - } - catch - { - System.Threading.Thread.Sleep(200); - retries++; - } - } - - if (message == "Session is already running") - { - return ReJoin(); - } - return message; - } - - internal string ReJoin() - { - string message = string.Empty; - int retries = 0; - const int maxRetries = 10; - while (retries < maxRetries) - { - try - { - System.Threading.Thread.Sleep(200); - if (Join(_seWs.Url, _userName, SessionId, out message)) - { - message = "Reload"; - } - - retries = maxRetries; - } - catch - { - System.Threading.Thread.Sleep(200); - retries++; - } - } - - return message; - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - if (_timerWebService != null) - { - _timerWebService.Dispose(); - _timerWebService = null; - } - if (_seWs != null) - { - _seWs.Dispose(); - _seWs = null; - } - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using System; +using System.Collections.Generic; +using System.Net; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic.Networking +{ + public class NikseWebServiceSession : IDisposable + { + public class ChatEntry + { + public SeNetworkService.SeUser User { get; set; } + public string Message { get; set; } + } + + public event EventHandler OnUpdateTimerTick; + public event EventHandler OnUpdateUserLogEntries; + + private System.Windows.Forms.Timer _timerWebService; + public List<UpdateLogEntry> UpdateLog { get; } = new List<UpdateLogEntry>(); + public List<ChatEntry> ChatLog { get; } = new List<ChatEntry>(); + private SeNetworkService.SeService _seWs; + private DateTime _seWsLastUpdate = DateTime.Now.AddYears(-1); + public SeNetworkService.SeUser CurrentUser { get; set; } + public Subtitle LastSubtitle { get; set; } + public Subtitle Subtitle { get; private set; } + public Subtitle OriginalSubtitle { get; private set; } + public string SessionId { get; private set; } + private string _userName; + private string _fileName; + public List<SeNetworkService.SeUser> Users { get; private set; } + public StringBuilder Log { get; } + + public string WebServiceUrl => _seWs.Url; + + public NikseWebServiceSession(Subtitle subtitle, Subtitle originalSubtitle, EventHandler onUpdateTimerTick, EventHandler onUpdateUserLogEntries) + { + Subtitle = subtitle; + OriginalSubtitle = originalSubtitle; + _timerWebService = new System.Windows.Forms.Timer(); + if (Configuration.Settings.NetworkSettings.PollIntervalSeconds < 1) + { + Configuration.Settings.NetworkSettings.PollIntervalSeconds = 1; + } + + _timerWebService.Interval = Configuration.Settings.NetworkSettings.PollIntervalSeconds * 1000; + _timerWebService.Tick += TimerWebServiceTick; + Log = new StringBuilder(); + OnUpdateTimerTick = onUpdateTimerTick; + OnUpdateUserLogEntries = onUpdateUserLogEntries; + } + + public void StartServer(string webServiceUrl, string sessionKey, string userName, string fileName, out string message) + { + SessionId = sessionKey; + _userName = userName; + _fileName = fileName; + var list = new List<SeNetworkService.SeSequence>(); + foreach (Paragraph p in Subtitle.Paragraphs) + { + list.Add(new SeNetworkService.SeSequence + { + StartMilliseconds = (int)p.StartTime.TotalMilliseconds, + EndMilliseconds = (int)p.EndTime.TotalMilliseconds, + Text = WebUtility.HtmlEncode(p.Text.Replace(Environment.NewLine, "<br />")) + }); + } + + var originalSubtitle = new List<SeNetworkService.SeSequence>(); + if (OriginalSubtitle != null) + { + foreach (Paragraph p in OriginalSubtitle.Paragraphs) + { + originalSubtitle.Add(new SeNetworkService.SeSequence + { + StartMilliseconds = (int)p.StartTime.TotalMilliseconds, + EndMilliseconds = (int)p.EndTime.TotalMilliseconds, + Text = WebUtility.HtmlEncode(p.Text.Replace(Environment.NewLine, "<br />")) + }); + } + } + + _seWs = new SeNetworkService.SeService + { + Url = webServiceUrl, + Proxy = Utilities.GetProxy() + }; + var user = _seWs.Start(sessionKey, userName, list.ToArray(), originalSubtitle.ToArray(), fileName, out message); + CurrentUser = user; + Users = new List<SeNetworkService.SeUser> { user }; + if (message == "OK") + { + _timerWebService.Start(); + } + } + + public bool Join(string webServiceUrl, string userName, string sessionKey, out string message) + { + SessionId = sessionKey; + _seWs = new SeNetworkService.SeService + { + Url = webServiceUrl, + Proxy = Utilities.GetProxy() + }; + Users = new List<SeNetworkService.SeUser>(); + var users = _seWs.Join(sessionKey, userName, out message); + if (message != "OK") + { + return false; + } + + string tempFileName; + Subtitle = new Subtitle(); + foreach (var sequence in _seWs.GetSubtitle(sessionKey, out tempFileName, out _)) + { + Subtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds)); + } + + _fileName = tempFileName; + + OriginalSubtitle = new Subtitle(); + var sequences = _seWs.GetOriginalSubtitle(sessionKey); + if (sequences != null) + { + foreach (var sequence in sequences) + { + OriginalSubtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds)); + } + } + + SessionId = sessionKey; + CurrentUser = users[users.Length - 1]; // me + foreach (var user in users) + { + Users.Add(user); + } + + ReloadFromWs(); + _timerWebService.Start(); + return true; + } + + private void TimerWebServiceTick(object sender, EventArgs e) + { + OnUpdateTimerTick?.Invoke(sender, e); + } + + public void TimerStop() + { + _timerWebService.Stop(); + } + + public void TimerStart() + { + _timerWebService.Start(); + } + + public List<SeNetworkService.SeUpdate> GetUpdates(out string message, out int numberOfLines) + { + List<SeNetworkService.SeUpdate> list = new List<SeNetworkService.SeUpdate>(); + var updates = _seWs.GetUpdates(SessionId, CurrentUser.UserName, _seWsLastUpdate, out message, out var newUpdateTime, out numberOfLines); + if (updates != null) + { + foreach (var update in updates) + { + list.Add(update); + } + } + _seWsLastUpdate = newUpdateTime; + return list; + } + + public Subtitle ReloadSubtitle() + { + Subtitle.Paragraphs.Clear(); + var sequences = _seWs.GetSubtitle(SessionId, out var tempFileName, out var updateTime); + _fileName = tempFileName; + _seWsLastUpdate = updateTime; + if (sequences != null) + { + foreach (var sequence in sequences) + { + Subtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds)); + } + } + return Subtitle; + } + + private void ReloadFromWs() + { + if (_seWs != null) + { + Subtitle = new Subtitle(); + var sequences = _seWs.GetSubtitle(SessionId, out _fileName, out _seWsLastUpdate); + foreach (var sequence in sequences) + { + var p = new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds); + Subtitle.Paragraphs.Add(p); + } + Subtitle.Renumber(); + LastSubtitle = new Subtitle(Subtitle); + } + } + + public void AppendToLog(string text) + { + string timestamp = DateTime.Now.ToLongTimeString(); + Log.AppendLine(timestamp + ": " + UiUtil.GetListViewTextFromString(text.TrimEnd())); + } + + public string GetLog() + { + return Log.ToString(); + } + + public void SendChatMessage(string message) + { + _seWs.SendMessage(SessionId, WebUtility.HtmlEncode(message.Replace(Environment.NewLine, "<br />")), CurrentUser); + } + + internal void UpdateLine(int index, Paragraph paragraph) + { + _seWs.UpdateLine(SessionId, index, new SeNetworkService.SeSequence + { + StartMilliseconds = (int)paragraph.StartTime.TotalMilliseconds, + EndMilliseconds = (int)paragraph.EndTime.TotalMilliseconds, + Text = WebUtility.HtmlEncode(paragraph.Text.Replace(Environment.NewLine, "<br />")) + }, CurrentUser); + AddToWsUserLog(CurrentUser, index, "UPD", true); + } + + public void CheckForAndSubmitUpdates() + { + // check for changes in text/time codes (not insert/delete) + if (LastSubtitle != null) + { + for (int i = 0; i < Subtitle.Paragraphs.Count; i++) + { + var last = LastSubtitle.GetParagraphOrDefault(i); + var current = Subtitle.GetParagraphOrDefault(i); + if (last != null && current != null) + { + if (Math.Abs(last.StartTime.TotalMilliseconds - current.StartTime.TotalMilliseconds) > 0.01 || + Math.Abs(last.EndTime.TotalMilliseconds - current.EndTime.TotalMilliseconds) > 0.01 || + last.Text != current.Text) + { + UpdateLine(i, current); + } + } + } + } + } + + public void AddToWsUserLog(SeNetworkService.SeUser user, int pos, string action, bool updateUi) + { + for (int i = 0; i < UpdateLog.Count; i++) + { + if (UpdateLog[i].Index == pos) + { + UpdateLog.RemoveAt(i); + break; + } + } + + UpdateLog.Add(new UpdateLogEntry(0, user.UserName, pos, action)); + if (updateUi) + { + OnUpdateUserLogEntries?.Invoke(null, null); + } + } + + internal void Leave() + { + try + { + _seWs.Leave(SessionId, CurrentUser.UserName); + } + catch + { + // ignored + } + } + + internal void DeleteLines(List<int> indices) + { + _seWs.DeleteLines(SessionId, indices.ToArray(), CurrentUser); + foreach (int index in indices) + { + AdjustUpdateLogToDelete(index); + AppendToLog(string.Format(Configuration.Settings.Language.Main.NetworkDelete, CurrentUser.UserName, CurrentUser.Ip, index)); + } + } + + internal void InsertLine(int index, Paragraph newParagraph) + { + _seWs.InsertLine(SessionId, index, (int)newParagraph.StartTime.TotalMilliseconds, (int)newParagraph.EndTime.TotalMilliseconds, newParagraph.Text, CurrentUser); + AppendToLog(string.Format(Configuration.Settings.Language.Main.NetworkInsert, CurrentUser.UserName, CurrentUser.Ip, index, UiUtil.GetListViewTextFromString(newParagraph.Text))); + } + + internal void AdjustUpdateLogToInsert(int index) + { + foreach (var logEntry in UpdateLog) + { + if (logEntry.Index >= index) + { + logEntry.Index++; + } + } + } + + internal void AdjustUpdateLogToDelete(int index) + { + UpdateLogEntry removeThis = null; + foreach (var logEntry in UpdateLog) + { + if (logEntry.Index == index) + { + removeThis = logEntry; + } + else if (logEntry.Index > index) + { + logEntry.Index--; + } + } + if (removeThis != null) + { + UpdateLog.Remove(removeThis); + } + } + + internal string Restart() + { + string message = string.Empty; + int retries = 0; + const int maxRetries = 10; + while (retries < maxRetries) + { + try + { + System.Threading.Thread.Sleep(200); + StartServer(_seWs.Url, SessionId, _userName, _fileName, out message); + retries = maxRetries; + } + catch + { + System.Threading.Thread.Sleep(200); + retries++; + } + } + + if (message == "Session is already running") + { + return ReJoin(); + } + return message; + } + + internal string ReJoin() + { + string message = string.Empty; + int retries = 0; + const int maxRetries = 10; + while (retries < maxRetries) + { + try + { + System.Threading.Thread.Sleep(200); + if (Join(_seWs.Url, _userName, SessionId, out message)) + { + message = "Reload"; + } + + retries = maxRetries; + } + catch + { + System.Threading.Thread.Sleep(200); + retries++; + } + } + + return message; + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + if (_timerWebService != null) + { + _timerWebService.Dispose(); + _timerWebService = null; + } + if (_seWs != null) + { + _seWs.Dispose(); + _seWs = null; + } + } + } + + } +} diff --git a/src/Logic/Networking/UpdateLogEntry.cs b/src/ui/Logic/Networking/UpdateLogEntry.cs similarity index 96% rename from src/Logic/Networking/UpdateLogEntry.cs rename to src/ui/Logic/Networking/UpdateLogEntry.cs index 4c800f81c..77b2614a2 100644 --- a/src/Logic/Networking/UpdateLogEntry.cs +++ b/src/ui/Logic/Networking/UpdateLogEntry.cs @@ -1,28 +1,28 @@ -using System; - -namespace Nikse.SubtitleEdit.Logic.Networking -{ - public class UpdateLogEntry - { - public int Id { get; set; } - public string UserName { get; set; } - public int Index { get; set; } - public DateTime OccuredAt { get; set; } - public string Action { get; set; } - - public UpdateLogEntry(int id, string userName, int index, string action) - { - Id = id; - UserName = userName; - Index = index; - OccuredAt = DateTime.Now; - Action = action; - } - - public override string ToString() - { - return $"{OccuredAt.Hour:00}:{OccuredAt.Minute:00}:{OccuredAt.Second:00} {UserName}: {Action}"; - } - - } -} +using System; + +namespace Nikse.SubtitleEdit.Logic.Networking +{ + public class UpdateLogEntry + { + public int Id { get; set; } + public string UserName { get; set; } + public int Index { get; set; } + public DateTime OccuredAt { get; set; } + public string Action { get; set; } + + public UpdateLogEntry(int id, string userName, int index, string action) + { + Id = id; + UserName = userName; + Index = index; + OccuredAt = DateTime.Now; + Action = action; + } + + public override string ToString() + { + return $"{OccuredAt.Hour:00}:{OccuredAt.Minute:00}:{OccuredAt.Second:00} {UserName}: {Action}"; + } + + } +} diff --git a/src/Logic/NikseBitmapImageSplitter.cs b/src/ui/Logic/NikseBitmapImageSplitter.cs similarity index 97% rename from src/Logic/NikseBitmapImageSplitter.cs rename to src/ui/Logic/NikseBitmapImageSplitter.cs index 6d77ab422..763bd6ada 100644 --- a/src/Logic/NikseBitmapImageSplitter.cs +++ b/src/ui/Logic/NikseBitmapImageSplitter.cs @@ -1,1153 +1,1153 @@ -using Nikse.SubtitleEdit.Core; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic -{ - public class NikseBitmapImageSplitter - { - public static bool IsColorClose(Color a, Color b, int tolerance) - { - if (a.A < 120 && b.A < 120) - { - return true; // transparent - } - - var alphaDiff = Math.Abs(a.A - b.A); - if (alphaDiff > 50) - { - return false; // different alpha levels - } - - if (a.A > 250 && a.R > 90 && a.G > 90 && a.B > 90 && - b.A > 250 && b.R > 90 && b.G > 90 && b.B > 90) - { - return true; // dark, non transparent - } - - int diff = (a.R + a.G + a.B) - (b.R + b.G + b.B); - return diff < tolerance && diff > -tolerance; - } - - public static bool IsColorClose(byte aa, byte ar, byte ag, byte ab, Color b, int tolerance) - { - if (aa < 120 && b.A < 120) - { - return true; // transparent - } - - if (aa > 250 && ar > 90 && ag > 90 && ab > 90 && - b.A > 250 && b.R > 90 && b.G > 90 && b.B > 90) - { - return true; // dark, non transparent - } - - int diff = (ar + ag + ab) - (b.R + b.G + b.B); - return diff < tolerance && diff > -tolerance; - } - - public static NikseBitmap CropTopAndBottom(NikseBitmap bmp, out int topCropping) - { - int startTop = 0; - int maxTop = bmp.Height - 2; - if (maxTop > bmp.Height) - { - maxTop = bmp.Height; - } - - for (int y = 0; y < maxTop; y++) - { - bool allTransparent = true; - for (int x = 0; x < bmp.Width; x++) - { - int a = bmp.GetAlpha(x, y); - if (a != 0) - { - allTransparent = false; - break; - } - } - if (!allTransparent) - { - break; - } - - startTop++; - } - topCropping = startTop; - - int h = bmp.Height; - bool bottomCroppingDone = false; - for (int y = bmp.Height - 1; y > 3; y--) - { - for (int x = 0; x < bmp.Width; x++) - { - int a = bmp.GetAlpha(x, y); - if (a != 0) - { - bottomCroppingDone = true; - break; - } - } - h = y; - if (bottomCroppingDone) - { - break; - } - } - if (h - startTop + 1 <= 0) - { - return new NikseBitmap(0, 0); - } - - return bmp.CopyRectangle(new Rectangle(0, startTop, bmp.Width, h - startTop + 1)); - } - - public static NikseBitmap CropTopAndBottom(NikseBitmap bmp, out int topCropping, int maxDifferentPixelsOnLine) - { - int startTop = 0; - int maxTop = bmp.Height - 2; - if (maxTop > bmp.Height) - { - maxTop = bmp.Height; - } - - for (int y = 0; y < maxTop; y++) - { - int difference = 0; - bool allTransparent = true; - for (int x = 1; x < bmp.Width - 1; x++) - { - int a = bmp.GetAlpha(x, y); - if (a != 0) - { - difference++; - if (difference >= maxDifferentPixelsOnLine) - { - allTransparent = false; - break; - } - } - } - if (!allTransparent) - { - break; - } - - startTop++; - } - if (startTop > 9) - { - startTop -= 5; // if top space > 9, then always leave blank 5 pixels on top (so . is not confused with '). - } - - topCropping = startTop; - - for (int y = bmp.Height - 1; y > 3; y--) - { - int difference = 0; - bool allTransparent = true; - for (int x = 1; x < bmp.Width - 1; x++) - { - int a = bmp.GetAlpha(x, y); - if (a != 0) - { - difference++; - if (difference >= maxDifferentPixelsOnLine) - { - allTransparent = false; - break; - } - } - } - if (allTransparent == false) - { - return bmp.CopyRectangle(new Rectangle(0, startTop, bmp.Width - 1, y - startTop + 1)); - } - } - return bmp; - } - - public static List<ImageSplitterItem> SplitToLinesTransparentOrBlack(NikseBitmap bmp) - { - int startY = 0; - int size = 0; - var parts = new List<ImageSplitterItem>(); - for (int y = 0; y < bmp.Height; y++) - { - bool allTransparent = true; - for (int x = 0; x < bmp.Width; x++) - { - var c = bmp.GetPixel(x, y); - if (c.A > 20 && c.R + c.G + c.B > 20) - { - allTransparent = false; - break; - } - } - if (allTransparent) - { - if (size > 2 && size <= 15) - { - size++; // at least 15 pixels, like top of 'i' or top of 'È' - } - else - { - if (size > 8) - { - var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)); - parts.Add(new ImageSplitterItem(0, startY, part)); - } - size = 0; - startY = y; - } - } - else - { - size++; - } - } - if (size > 2) - { - parts.Add(size == bmp.Height ? new ImageSplitterItem(0, startY, bmp) : new ImageSplitterItem(0, startY, bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)))); - } - return parts; - } - - /// <summary> - /// split into lines - /// </summary> - public static List<ImageSplitterItem> SplitToLines(NikseBitmap bmp, int minLineHeight, double averageLineHeight = -1) - { - int startY = 0; - int size = 0; - var parts = new List<ImageSplitterItem>(); - for (int y = 0; y < bmp.Height; y++) - { - if (bmp.IsLineTransparent(y)) - { - - // check for appendix below text - bool appendix = y >= bmp.Height - minLineHeight; - if (!appendix && y < bmp.Height - 10 && size > minLineHeight && minLineHeight > 15) - { - bool yp1 = bmp.IsLineTransparent(y + 1); - bool yp2 = bmp.IsLineTransparent(y + 2); - bool yp3 = bmp.IsLineTransparent(y + 3); - bool yp4 = bmp.IsLineTransparent(y + 4); - bool yp5 = bmp.IsLineTransparent(y + 5); - if (!yp1 || !yp2 || !yp3 || !yp4 || !yp5) - { - bool yp6 = bmp.IsLineTransparent(y + 6); - bool yp7 = bmp.IsLineTransparent(y + 7); - bool yp8 = bmp.IsLineTransparent(y + 8); - bool yp9 = bmp.IsLineTransparent(y + 9); - if (yp6 && yp7 && yp8 && yp9) - { - appendix = true; - } - } - } - - if (appendix || size > 1 && size <= minLineHeight) - { - size++; // at least 'lineMinHeight' pixels, like top of 'i' - } - else - { - if (size > 1) - { - var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)); - parts.Add(new ImageSplitterItem(0, startY, part)); - } - size = 0; - startY = y; - } - } - else - { - size++; - } - } - if (size > 1) - { - if (size == bmp.Height) - { - if (size > 100) - { - return SplitToLinesTransparentOrBlack(bmp); - } - - parts.Add(new ImageSplitterItem(0, startY, bmp)); - } - else - { - parts.Add(new ImageSplitterItem(0, startY, bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)))); - } - } - if (parts.Count == 1 && averageLineHeight > 5 && bmp.Height > averageLineHeight * 3) - { - return SplitToLinesAggressive(bmp, minLineHeight, averageLineHeight); - } - return parts; - } - - private static List<ImageSplitterItem> SplitToLinesAggressive(NikseBitmap bmp, int minLineHeight, double averageLineHeight) - { - int startY = 0; - int size = 0; - var parts = new List<ImageSplitterItem>(); - for (int y = 0; y < bmp.Height; y++) - { - int a; - bool allTransparent = bmp.IsLineTransparent(y); - - if (size > 5 && size >= minLineHeight && size > averageLineHeight && !allTransparent && bmp.Width > 50 && y < bmp.Height - 5) - { - var leftX = 0; - while (leftX < bmp.Width) - { - a = bmp.GetAlpha(leftX, y); - if (a != 0) - { - break; - } - leftX++; - } - var rightX = bmp.Width; - while (rightX > 0) - { - a = bmp.GetAlpha(rightX, y - 1); - if (a != 0) - { - break; - } - rightX--; - } - if (leftX >= rightX) - { - allTransparent = true; - } - - leftX = 0; - while (leftX < bmp.Width) - { - a = bmp.GetAlpha(leftX, y - 1); - if (a != 0) - { - break; - } - leftX++; - } - rightX = bmp.Width; - while (rightX > 0) - { - a = bmp.GetAlpha(rightX, y); - if (a != 0) - { - break; - } - rightX--; - } - if (leftX >= rightX) - { - allTransparent = true; - } - } - - if (allTransparent) - { - if (size > 2 && size <= minLineHeight) - { - size++; // at least 'lineMinHeight' pixels, like top of 'i' - } - else - { - if (size > 2) - { - var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)); - parts.Add(new ImageSplitterItem(0, startY, part)); - } - size = 0; - startY = y; - } - } - else - { - size++; - } - } - if (size > 2) - { - if (size == bmp.Height) - { - if (size > 100) - { - return SplitToLinesTransparentOrBlack(bmp); - } - - parts.Add(new ImageSplitterItem(0, startY, bmp)); - } - else - { - parts.Add(new ImageSplitterItem(0, startY, bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)))); - } - } - if (parts.Count == 1 && averageLineHeight > 5 && bmp.Height > averageLineHeight * 3) - { - return parts; - } - return parts; - } - - public static int IsBitmapsAlike(NikseBitmap bmp1, Bitmap bmp2) - { - int different = 0; - int maxDiff = bmp1.Width * bmp1.Height / 5; - for (int y = 0; y < bmp1.Height; y++) - { - for (int x = 0; x < bmp1.Width; x++) - { - if (!IsColorClose(bmp1.GetPixel(x, y), bmp2.GetPixel(x, y), 20)) - { - different++; - } - } - } - if (different > maxDiff) - { - return different + 10; - } - - return different; - } - - public static List<ImageSplitterItem> SplitBitmapToLines(NikseBitmap bmp, int xOrMorePixelsMakesSpace, bool rightToLeft, bool topToBottom, int minLineHeight, bool autoHeight, double averageLineHeight = -1) - { - var list = new List<ImageSplitterItem>(); - - // split into separate lines - var splitOld = SplitToLines(bmp, minLineHeight, averageLineHeight); - if (!autoHeight) - { - return splitOld; - } - - // fast horizontal split by x number of whole lines (3-4) - var splitThreeBlankLines = SplitToLinesByMinTransparentHorizontalLines(bmp, minLineHeight, 3); - var splitFourBlankLines = SplitToLinesByMinTransparentHorizontalLines(bmp, minLineHeight, 4); - var splitBlankLines = splitThreeBlankLines.Count == splitFourBlankLines.Count ? splitFourBlankLines : splitThreeBlankLines; - - var lineBitmaps = splitOld.Count > splitBlankLines.Count ? splitOld : splitBlankLines; - - if (lineBitmaps.Count == 1 && lineBitmaps[0].NikseBitmap?.Height > minLineHeight * 2.2) - { - lineBitmaps = SplitToLinesNew(lineBitmaps[0], minLineHeight, averageLineHeight); // more advanced split (allows for up/down) - } - - return lineBitmaps; - } - - public static List<ImageSplitterItem> SplitBitmapToLettersNew(NikseBitmap bmp, int xOrMorePixelsMakesSpace, bool rightToLeft, bool topToBottom, int minLineHeight, bool autoHeight, double averageLineHeight = -1) - { - var list = new List<ImageSplitterItem>(); - - // split into separate lines - var splitOld = SplitToLines(bmp, minLineHeight, averageLineHeight); - - List<ImageSplitterItem> lineBitmaps; - if (autoHeight) - { - // fast horizontal split by x number of whole lines (3-4) - var splitThreeBlankLines = SplitToLinesByMinTransparentHorizontalLines(bmp, minLineHeight, 3); - var splitFourBlankLines = SplitToLinesByMinTransparentHorizontalLines(bmp, minLineHeight, 4); - var splitBlankLines = splitThreeBlankLines.Count == splitFourBlankLines.Count ? splitFourBlankLines : splitThreeBlankLines; - - lineBitmaps = splitOld.Count > splitBlankLines.Count ? splitOld : splitBlankLines; - - if (lineBitmaps.Count == 1 && lineBitmaps[0].NikseBitmap?.Height > minLineHeight * 2.2) - { - lineBitmaps = SplitToLinesNew(lineBitmaps[0], minLineHeight, averageLineHeight); // more advanced split (allows for up/down) - } - } - else - { - lineBitmaps = splitOld; - } - - //foreach (var bitmap in tempBitmaps) - //{ - // // var height = bitmap.NikseBitmap.GetNonTransparentHeight(); - // var bitmaps = SplitToLinesNew(bitmap, minLineHeight, averageLineHeight); // more advanced split (allows for up/down) - // lineBitmaps.AddRange(bitmaps); - //} - - if (!topToBottom) - { - lineBitmaps.Reverse(); - } - - // split into letters - for (int index = 0; index < lineBitmaps.Count; index++) - { - var b = lineBitmaps[index]; - if (index > 0) - { - list.Add(new ImageSplitterItem(Environment.NewLine)); - } - - var line = new List<ImageSplitterItem>(); - foreach (var item in SplitHorizontalNew(b, xOrMorePixelsMakesSpace)) - { - item.Top = index > 0 ? item.Y - b.Y : item.Y; - item.ParentY = item.Y; - line.Add(item); - } - if (rightToLeft) - { - line.Reverse(); - } - - list.AddRange(line); - } - return list; - } - - - /// <summary> - /// split into lines - /// </summary> - public static List<ImageSplitterItem> SplitToLinesByMinTransparentHorizontalLines(NikseBitmap bmp, int minLineHeight, int minTransparentLines) - { - var parts = new List<ImageSplitterItem>(); - var startY = 0; - var lastTransparentY = -1; - var keysInSequence = 0; - for (int y = minLineHeight; y < bmp.Height - minLineHeight; y++) - { - var isLineTransparent = bmp.IsLineTransparent(y); - if (startY == y && isLineTransparent) - { - startY++; - continue; // skip start - } - - if (isLineTransparent) - { - if (lastTransparentY == y - 1) - { - if (keysInSequence == 0) - { - keysInSequence++; - } - - keysInSequence++; - } - - if (keysInSequence > 2 && lastTransparentY - startY > minLineHeight) - { - var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, lastTransparentY - startY - 1)); - if (!part.IsImageOnlyTransparent() && part.GetNonTransparentHeight() >= minLineHeight) - { - var croppedTop = part.CropTopTransparent(0); - parts.Add(new ImageSplitterItem(0, startY + croppedTop, part)); - startY = lastTransparentY + 1; - } - } - lastTransparentY = y; - } - else - { - keysInSequence = 0; - lastTransparentY = -1; - } - } - - if (bmp.Height - startY > 1) - { - var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, bmp.Height - startY)); - if (!part.IsImageOnlyTransparent()) - { - var croppedTop = part.CropTopTransparent(0); - parts.Add(new ImageSplitterItem(0, startY + croppedTop, part)); - } - } - - return parts; - } - - - /// <summary> - /// split into lines - /// </summary> - public static List<ImageSplitterItem> SplitToLinesNew(ImageSplitterItem item, int minLineHeight, double averageLineHeight = -1) - { - var bmp = new NikseBitmap(item.NikseBitmap); - var parts = new List<ImageSplitterItem>(); - bool started = false; - var splitLines = new Dictionary<int, List<Point>>(); - var startY = 0; - for (int y = minLineHeight; y < bmp.Height - minLineHeight; y++) - { - if (startY == y && bmp.IsLineTransparent(y)) - { - startY++; - continue; - } - - var points = new List<Point>(); - var yChange = 0; - var completed = false; - var backJump = 0; - int x = 0; - var maxUp = Math.Min(10, minLineHeight / 2); - while (x < bmp.Width) - { - var a1 = bmp.GetAlpha(x, y + yChange); - var a2 = bmp.GetAlpha(x, y + 1 + yChange); - if (a1 > 150 || a2 > 150) - { - if (x > 1 && yChange < 8 && - bmp.GetAlpha(x - 1, y + yChange) < 150 && bmp.GetAlpha(x - 1, y + yChange) < 150 && - bmp.GetAlpha(x - 1, y + 1 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 2 + yChange) < 150 && - bmp.GetAlpha(x - 1, y + 2 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 3 + yChange) < 150 && - bmp.GetAlpha(x, y + 2 + yChange) < 150 && bmp.GetAlpha(x, y + 3 + yChange) < 150) - { - yChange += 2; - } - - else if (x > 1 && yChange < 8 && - bmp.GetAlpha(x - 1, y + yChange) < 150 && bmp.GetAlpha(x - 1, y + yChange) < 150 && - bmp.GetAlpha(x - 1, y + 1 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 2 + yChange) < 150 && - bmp.GetAlpha(x - 1, y + 2 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 3 + yChange) < 150 && - bmp.GetAlpha(x - 1, y + 3 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 4 + yChange) < 150 && - bmp.GetAlpha(x, y + 3 + yChange) < 150 && bmp.GetAlpha(x, y + 4 + yChange) < 150) - { - yChange += 3; - } - - else if (x > 1 && yChange < 7 && - bmp.GetAlpha(x - 1, y + yChange) < 150 && bmp.GetAlpha(x - 1, y + yChange) < 150 && - bmp.GetAlpha(x - 1, y + 1 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 2 + yChange) < 150 && - bmp.GetAlpha(x - 1, y + 2 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 3 + yChange) < 150 && - bmp.GetAlpha(x - 1, y + 3 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 4 + yChange) < 150 && - bmp.GetAlpha(x - 1, y + 4 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 5 + yChange) < 150 && - bmp.GetAlpha(x, y + 4 + yChange) < 150 && bmp.GetAlpha(x, y + 5 + yChange) < 150) - { - yChange += 4; - } - - else if (x > 1 && yChange > -7 && - bmp.GetAlpha(x - 1, y + yChange) < 150 && bmp.GetAlpha(x - 1, y + yChange) < 150 && - bmp.GetAlpha(x - 1, y - 1 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 2 + yChange) < 150 && - bmp.GetAlpha(x - 1, y - 2 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 3 + yChange) < 150 && - bmp.GetAlpha(x, y - 2 + yChange) < 150 && bmp.GetAlpha(x, y - 3 + yChange) < 150) - { - yChange -= 2; - } - - else if (x > 1 && yChange > -7 && - bmp.GetAlpha(x - 1, y + yChange) < 150 && bmp.GetAlpha(x - 1, y + yChange) < 150 && - bmp.GetAlpha(x - 1, y - 1 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 2 + yChange) < 150 && - bmp.GetAlpha(x - 1, y - 2 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 3 + yChange) < 150 && - bmp.GetAlpha(x - 1, y - 3 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 4 + yChange) < 150 && - bmp.GetAlpha(x, y - 3 + yChange) < 150 && bmp.GetAlpha(x, y - 4 + yChange) < 150) - { - yChange -= 3; - } - - else if (x > 1 && yChange > -7 && - bmp.GetAlpha(x - 1, y + yChange) < 150 && bmp.GetAlpha(x - 1, y + yChange) < 150 && - bmp.GetAlpha(x - 1, y - 1 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 2 + yChange) < 150 && - bmp.GetAlpha(x - 1, y - 2 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 3 + yChange) < 150 && - bmp.GetAlpha(x - 1, y - 3 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 4 + yChange) < 150 && - bmp.GetAlpha(x - 1, y - 4 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 5 + yChange) < 150 && - bmp.GetAlpha(x, y - 4 + yChange) < 150 && bmp.GetAlpha(x, y - 5 + yChange) < 150) - { - yChange -= 4; - } - - else if (x > 10 && backJump < 3 && x > 5 && yChange > -7) // go left + up + check 12 pixels right - { - var done = false; - for (int i = 1; i < maxUp; i++) - { - for (int k = 1; k < 9; k++) - { - if (CanGoUpAndRight(bmp, i, 12, x - k, y + yChange, minLineHeight)) - { - backJump++; - x -= k; - points.RemoveAll(p => p.X > x); - done = true; - yChange -= (i + 1); - break; - } - } - - if (done) - { - break; - } - } - - if (!done) - { - started = true; - break; - } - } - - else - { - started = true; - break; - } - } - - if (started) - { - points.Add(new Point(x, y + yChange)); - } - - completed = x == bmp.Width - 1; - x++; - } - - if (completed) - { - splitLines.Add(y, points); - } - - } - - var transparentColor = Color.FromArgb(0, 0, 0, 0); - foreach (var line in splitLines) - { - var key = line.Key; - if (key - startY > minLineHeight && line.Value.Count > 0) - { - var maxY = line.Value.Max(p => p.Y); - var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, maxY - startY)); - //part.GetBitmap().Save(@"j:\temp\split_" + parts.Count + "_before.bmp"); - - foreach (var point in line.Value) - { - // delete down - for (var y = point.Y - 1; y < startY + part.Height; y++) - { - part.SetPixel(point.X, y - startY, transparentColor); - } - } - //part.GetBitmap().Save(@"j:\temp\split_" + parts.Count + "_after.bmp"); - - if (!part.IsImageOnlyTransparent() && part.GetNonTransparentHeight() >= minLineHeight) - { - var minY = line.Value.Min(p => p.Y); - // bmp.GetBitmap().Save(@"j:\temp\main_" + parts.Count + "_before.bmp"); - foreach (var point in line.Value) - { - // delete up - for (var y = point.Y; y >= minY; y--) - { - bmp.SetPixel(point.X, y, transparentColor); - } - } - // bmp.GetBitmap().Save(@"j:\temp\main_" + parts.Count + "_after.bmp"); - - // part.GetBitmap().Save(@"j:\temp\split_" + parts.Count + "_after.bmp"); - var croppedTop = part.CropTopTransparent(0); - parts.Add(new ImageSplitterItem(0 + item.X, startY + croppedTop + item.Y, part)); - - startY = key + 1; - } - - } - } - - if (bmp.Height - startY > 1 && parts.Count > 0) - { - var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, bmp.Height - startY)); - if (!part.IsImageOnlyTransparent()) - { - //part.GetBitmap().Save(@"j:\temp\split_" + parts.Count + ".bmp"); - var croppedTop = part.CropTopTransparent(0); - parts.Add(new ImageSplitterItem(0 + item.X, startY + croppedTop + item.Y, part)); - } - } - - if (parts.Count <= 1) - { - return new List<ImageSplitterItem> { item }; - } - - return parts; - } - - private static bool CanGoUpAndRight(NikseBitmap bmp, int up, int right, int x, int y, int minLineHeight) - { - if (y - up < 0 || x + right >= bmp.Width || y + minLineHeight > bmp.Height) - { - return false; - } - - for (int myY = y; myY > y - up && myY > 1; myY--) - { - var a = bmp.GetAlpha(x, myY); - if (a > 150) - { - return false; - } - } - - for (int myX = x; x < x + right && myX < bmp.Width; myX++) - { - var a = bmp.GetAlpha(myX, y - up); - if (a > 150) - { - return false; - } - } - - return true; - } - - - private static IEnumerable<ImageSplitterItem> SplitHorizontalNew(ImageSplitterItem lineSplitterItem, int xOrMorePixelsMakesSpace) - { - var bmp = new NikseBitmap(lineSplitterItem.NikseBitmap); - bmp.AddTransparentLineRight(); - var parts = new List<ImageSplitterItem>(); - int startX = 0; - int width = 0; - int spacePixels = 0; - int subtractSpacePixels = 0; - for (int x = 0; x < bmp.Width; x++) - { - bool right; - bool clean; - List<Point> points = IsVerticalLineTransparetNew(bmp, x, out right, out clean); - - if (points != null && clean) - { - spacePixels++; - } - - if (right && points != null) - { - int add = FindMaxX(points, x) - x; - width += add; - subtractSpacePixels = add; - } - - var newStartX = points != null ? FindMinX(points, x) : 0; - if (points == null) - { - width++; - } - else if (width > 0 && newStartX > startX + 1) - { - var bmp0 = new NikseBitmap(bmp); - // remove pixels after current; - for (int index = 0; index < points.Count; index++) - { - var p = points[index]; - bmp0.MakeVerticalLinePartTransparent(p.X, p.X + index, p.Y); - } - width = FindMaxX(points, x) - startX; - width--; - startX++; - var b1 = bmp0.CopyRectangle(new Rectangle(startX, 0, width, bmp.Height)); - - int addY; - b1 = CropTopAndBottom(b1, out addY); - - if (spacePixels >= xOrMorePixelsMakesSpace && parts.Count > 0) - { - parts.Add(new ImageSplitterItem(" ") { Y = addY + lineSplitterItem.Y }); - } - - if (b1.Width > 0 && b1.Height > 0) - { - parts.Add(new ImageSplitterItem(startX + lineSplitterItem.X, addY + lineSplitterItem.Y, b1)); //y is what? - } - - // remove pixels before next letter; - const int begin = 0; - foreach (var p in points) - { - bmp.MakeVerticalLinePartTransparent(begin, p.X, p.Y); - } - width = 1; - startX = FindMinX(points, x); - spacePixels = -subtractSpacePixels; - subtractSpacePixels = 0; - } - else if (clean) - { - width = 1; - startX = newStartX; - } - } - return parts; - } - - private static int FindMinX(List<Point> points, int x) - { - for (int index = 0; index < points.Count; index++) - { - var p = points[index]; - if (p.X < x) - { - x = p.X; - } - } - return x; - } - - private static int FindMaxX(List<Point> points, int x) - { - for (int index = 0; index < points.Count; index++) - { - var p = points[index]; - if (p.X > x) - { - x = p.X; - } - } - return x; - } - - private static List<Point> IsVerticalLineTransparetNew(NikseBitmap bmp, int x, out bool right, out bool clean) - { - right = false; - bool left = false; - int leftCount = 0; - int rightCount = 0; - clean = true; - var points = new List<Point>(); - int y = 0; - int maxSlide = bmp.Height / 4; - - while (y < bmp.Height) - { - if (bmp.GetAlpha(x, y) > 100) - { - clean = false; - if (x == 0) - { - return null; - } - - if (x < bmp.Width - 1 && y < bmp.Height - 1 && bmp.GetAlpha(x + 1, y) == 0 && bmp.GetAlpha(x + 1, y + 1) == 0) - { - //if pixels to the left - move right? - if (bmp.GetAlpha(x - 1, y) > 0) - { - x++; //(requires search for min/max x in points - right = true; - } - else if (x > 0 && bmp.GetAlpha(x - 1, y) == 0) - { - x--; //(requires search for min/max x in points - left = true; - } - else - { - return null; - } - } - else if (x < bmp.Width - 1 && y == bmp.Height - 1 && bmp.GetAlpha(x + 1, y) == 0 && bmp.GetAlpha(x + 1, y - 1) == 0) - { - //if pixels to the left - move right? - if (bmp.GetAlpha(x - 1, y) > 0) - { - x++; //(requires search for min/max x in points - } - else - { - return null; - } - right = true; - } - else if (bmp.GetAlpha(x - 1, y) == 0) - { - x--; - left = true; - } - else if (y > 5 && bmp.GetAlpha(x - 1, y - 1) == 0) - { - x--; - y--; - left = true; - while (points.Count > 0 && points[points.Count - 1].Y > y) - { - points.RemoveAt(points.Count - 1); - } - } - else if (y > 5 && bmp.GetAlpha(x - 1, y - 2) == 0) - { - x--; - y -= 2; - left = true; - while (points.Count > 0 && points[points.Count - 1].Y > y) - { - points.RemoveAt(points.Count - 1); - } - } - else - { - return null; - } - - if (left) - { - leftCount++; - } - - if (right) - { - rightCount++; - } - - if (leftCount > maxSlide || rightCount > maxSlide) - { - return null; - } - } - else - { - points.Add(new Point(x, y)); - y++; - } - } - return points; - } - - internal static int IsBitmapsAlike(ManagedBitmap bmp1, NikseBitmap bmp2) - { - int different = 0; - int maxDiff = bmp1.Width * bmp1.Height / 5; - - for (int x = 1; x < bmp1.Width; x++) - { - for (int y = 1; y < bmp1.Height; y++) - { - if (!IsColorClose(bmp1.GetPixel(x, y), bmp2.GetPixel(x, y), 20)) - { - different++; - } - } - if (different > maxDiff) - { - return different + 10; - } - } - return different; - } - - internal static int IsBitmapsAlike(NikseBitmap bmp1, ManagedBitmap bmp2) - { - int different = 0; - int maxDiff = bmp1.Width * bmp1.Height / 5; - - for (int x = 1; x < bmp1.Width; x++) - { - for (int y = 1; y < bmp1.Height; y++) - { - if (!IsColorClose(bmp1.GetPixel(x, y), bmp2.GetPixel(x, y), 20)) - { - different++; - } - } - if (different > maxDiff) - { - return different + 10; - } - } - return different; - } - - internal static int IsBitmapsAlike(Ocr.Binary.BinaryOcrBitmap bmp1, NikseBitmap bmp2) - { - int different = 0; - int maxDiff = bmp1.Width * bmp1.Height / 5; - int w4 = bmp2.Width * 4; - for (int y = 0; y < bmp1.Height; y++) - { - var alpha = y * w4 + 3; - var pixel = y * bmp1.Width; - for (int x = 0; x < bmp1.Width; x++) - { - if (bmp1.GetPixel(pixel) > 0 && bmp2.GetAlpha(alpha) < 100) - { - different++; - } - - pixel++; - alpha += 4; - } - if (different > maxDiff) - { - return different + 10; - } - } - return different; - } - - internal static int IsBitmapsAlike(Ocr.Binary.BinaryOcrBitmap bmp1, Ocr.Binary.BinaryOcrBitmap bmp2) - { - int different = 0; - int maxDiff = bmp1.Width * bmp1.Height / 5; - for (int y = 0; y < bmp1.Height; y++) - { - var pixel = y * bmp1.Width; - for (int x = 0; x < bmp1.Width; x++) - { - if (bmp1.GetPixel(pixel) != bmp2.GetPixel(pixel)) - { - different++; - } - - pixel++; - } - if (different > maxDiff) - { - return different + 10; - } - } - return different; - } - - internal static int IsBitmapsAlike(NikseBitmap bmp1, Ocr.Binary.BinaryOcrBitmap bmp2) - { - int different = 0; - int maxDiff = bmp1.Width * bmp1.Height / 5; - int w4 = bmp1.Width * 4; - for (int y = 1; y < bmp1.Height; y++) - { - var alpha = y * w4 + 7; - var pixel = y * bmp2.Width + 1; - for (int x = 1; x < bmp1.Width; x++) - { - if (bmp1.GetAlpha(alpha) < 100 && bmp2.GetPixel(pixel) > 0) - { - different++; - } - - pixel++; - alpha += 4; - } - if (different > maxDiff) - { - return different + 10; - } - } - return different; - } - - } -} +using Nikse.SubtitleEdit.Core; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic +{ + public class NikseBitmapImageSplitter + { + public static bool IsColorClose(Color a, Color b, int tolerance) + { + if (a.A < 120 && b.A < 120) + { + return true; // transparent + } + + var alphaDiff = Math.Abs(a.A - b.A); + if (alphaDiff > 50) + { + return false; // different alpha levels + } + + if (a.A > 250 && a.R > 90 && a.G > 90 && a.B > 90 && + b.A > 250 && b.R > 90 && b.G > 90 && b.B > 90) + { + return true; // dark, non transparent + } + + int diff = (a.R + a.G + a.B) - (b.R + b.G + b.B); + return diff < tolerance && diff > -tolerance; + } + + public static bool IsColorClose(byte aa, byte ar, byte ag, byte ab, Color b, int tolerance) + { + if (aa < 120 && b.A < 120) + { + return true; // transparent + } + + if (aa > 250 && ar > 90 && ag > 90 && ab > 90 && + b.A > 250 && b.R > 90 && b.G > 90 && b.B > 90) + { + return true; // dark, non transparent + } + + int diff = (ar + ag + ab) - (b.R + b.G + b.B); + return diff < tolerance && diff > -tolerance; + } + + public static NikseBitmap CropTopAndBottom(NikseBitmap bmp, out int topCropping) + { + int startTop = 0; + int maxTop = bmp.Height - 2; + if (maxTop > bmp.Height) + { + maxTop = bmp.Height; + } + + for (int y = 0; y < maxTop; y++) + { + bool allTransparent = true; + for (int x = 0; x < bmp.Width; x++) + { + int a = bmp.GetAlpha(x, y); + if (a != 0) + { + allTransparent = false; + break; + } + } + if (!allTransparent) + { + break; + } + + startTop++; + } + topCropping = startTop; + + int h = bmp.Height; + bool bottomCroppingDone = false; + for (int y = bmp.Height - 1; y > 3; y--) + { + for (int x = 0; x < bmp.Width; x++) + { + int a = bmp.GetAlpha(x, y); + if (a != 0) + { + bottomCroppingDone = true; + break; + } + } + h = y; + if (bottomCroppingDone) + { + break; + } + } + if (h - startTop + 1 <= 0) + { + return new NikseBitmap(0, 0); + } + + return bmp.CopyRectangle(new Rectangle(0, startTop, bmp.Width, h - startTop + 1)); + } + + public static NikseBitmap CropTopAndBottom(NikseBitmap bmp, out int topCropping, int maxDifferentPixelsOnLine) + { + int startTop = 0; + int maxTop = bmp.Height - 2; + if (maxTop > bmp.Height) + { + maxTop = bmp.Height; + } + + for (int y = 0; y < maxTop; y++) + { + int difference = 0; + bool allTransparent = true; + for (int x = 1; x < bmp.Width - 1; x++) + { + int a = bmp.GetAlpha(x, y); + if (a != 0) + { + difference++; + if (difference >= maxDifferentPixelsOnLine) + { + allTransparent = false; + break; + } + } + } + if (!allTransparent) + { + break; + } + + startTop++; + } + if (startTop > 9) + { + startTop -= 5; // if top space > 9, then always leave blank 5 pixels on top (so . is not confused with '). + } + + topCropping = startTop; + + for (int y = bmp.Height - 1; y > 3; y--) + { + int difference = 0; + bool allTransparent = true; + for (int x = 1; x < bmp.Width - 1; x++) + { + int a = bmp.GetAlpha(x, y); + if (a != 0) + { + difference++; + if (difference >= maxDifferentPixelsOnLine) + { + allTransparent = false; + break; + } + } + } + if (allTransparent == false) + { + return bmp.CopyRectangle(new Rectangle(0, startTop, bmp.Width - 1, y - startTop + 1)); + } + } + return bmp; + } + + public static List<ImageSplitterItem> SplitToLinesTransparentOrBlack(NikseBitmap bmp) + { + int startY = 0; + int size = 0; + var parts = new List<ImageSplitterItem>(); + for (int y = 0; y < bmp.Height; y++) + { + bool allTransparent = true; + for (int x = 0; x < bmp.Width; x++) + { + var c = bmp.GetPixel(x, y); + if (c.A > 20 && c.R + c.G + c.B > 20) + { + allTransparent = false; + break; + } + } + if (allTransparent) + { + if (size > 2 && size <= 15) + { + size++; // at least 15 pixels, like top of 'i' or top of 'È' + } + else + { + if (size > 8) + { + var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)); + parts.Add(new ImageSplitterItem(0, startY, part)); + } + size = 0; + startY = y; + } + } + else + { + size++; + } + } + if (size > 2) + { + parts.Add(size == bmp.Height ? new ImageSplitterItem(0, startY, bmp) : new ImageSplitterItem(0, startY, bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)))); + } + return parts; + } + + /// <summary> + /// split into lines + /// </summary> + public static List<ImageSplitterItem> SplitToLines(NikseBitmap bmp, int minLineHeight, double averageLineHeight = -1) + { + int startY = 0; + int size = 0; + var parts = new List<ImageSplitterItem>(); + for (int y = 0; y < bmp.Height; y++) + { + if (bmp.IsLineTransparent(y)) + { + + // check for appendix below text + bool appendix = y >= bmp.Height - minLineHeight; + if (!appendix && y < bmp.Height - 10 && size > minLineHeight && minLineHeight > 15) + { + bool yp1 = bmp.IsLineTransparent(y + 1); + bool yp2 = bmp.IsLineTransparent(y + 2); + bool yp3 = bmp.IsLineTransparent(y + 3); + bool yp4 = bmp.IsLineTransparent(y + 4); + bool yp5 = bmp.IsLineTransparent(y + 5); + if (!yp1 || !yp2 || !yp3 || !yp4 || !yp5) + { + bool yp6 = bmp.IsLineTransparent(y + 6); + bool yp7 = bmp.IsLineTransparent(y + 7); + bool yp8 = bmp.IsLineTransparent(y + 8); + bool yp9 = bmp.IsLineTransparent(y + 9); + if (yp6 && yp7 && yp8 && yp9) + { + appendix = true; + } + } + } + + if (appendix || size > 1 && size <= minLineHeight) + { + size++; // at least 'lineMinHeight' pixels, like top of 'i' + } + else + { + if (size > 1) + { + var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)); + parts.Add(new ImageSplitterItem(0, startY, part)); + } + size = 0; + startY = y; + } + } + else + { + size++; + } + } + if (size > 1) + { + if (size == bmp.Height) + { + if (size > 100) + { + return SplitToLinesTransparentOrBlack(bmp); + } + + parts.Add(new ImageSplitterItem(0, startY, bmp)); + } + else + { + parts.Add(new ImageSplitterItem(0, startY, bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)))); + } + } + if (parts.Count == 1 && averageLineHeight > 5 && bmp.Height > averageLineHeight * 3) + { + return SplitToLinesAggressive(bmp, minLineHeight, averageLineHeight); + } + return parts; + } + + private static List<ImageSplitterItem> SplitToLinesAggressive(NikseBitmap bmp, int minLineHeight, double averageLineHeight) + { + int startY = 0; + int size = 0; + var parts = new List<ImageSplitterItem>(); + for (int y = 0; y < bmp.Height; y++) + { + int a; + bool allTransparent = bmp.IsLineTransparent(y); + + if (size > 5 && size >= minLineHeight && size > averageLineHeight && !allTransparent && bmp.Width > 50 && y < bmp.Height - 5) + { + var leftX = 0; + while (leftX < bmp.Width) + { + a = bmp.GetAlpha(leftX, y); + if (a != 0) + { + break; + } + leftX++; + } + var rightX = bmp.Width; + while (rightX > 0) + { + a = bmp.GetAlpha(rightX, y - 1); + if (a != 0) + { + break; + } + rightX--; + } + if (leftX >= rightX) + { + allTransparent = true; + } + + leftX = 0; + while (leftX < bmp.Width) + { + a = bmp.GetAlpha(leftX, y - 1); + if (a != 0) + { + break; + } + leftX++; + } + rightX = bmp.Width; + while (rightX > 0) + { + a = bmp.GetAlpha(rightX, y); + if (a != 0) + { + break; + } + rightX--; + } + if (leftX >= rightX) + { + allTransparent = true; + } + } + + if (allTransparent) + { + if (size > 2 && size <= minLineHeight) + { + size++; // at least 'lineMinHeight' pixels, like top of 'i' + } + else + { + if (size > 2) + { + var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)); + parts.Add(new ImageSplitterItem(0, startY, part)); + } + size = 0; + startY = y; + } + } + else + { + size++; + } + } + if (size > 2) + { + if (size == bmp.Height) + { + if (size > 100) + { + return SplitToLinesTransparentOrBlack(bmp); + } + + parts.Add(new ImageSplitterItem(0, startY, bmp)); + } + else + { + parts.Add(new ImageSplitterItem(0, startY, bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)))); + } + } + if (parts.Count == 1 && averageLineHeight > 5 && bmp.Height > averageLineHeight * 3) + { + return parts; + } + return parts; + } + + public static int IsBitmapsAlike(NikseBitmap bmp1, Bitmap bmp2) + { + int different = 0; + int maxDiff = bmp1.Width * bmp1.Height / 5; + for (int y = 0; y < bmp1.Height; y++) + { + for (int x = 0; x < bmp1.Width; x++) + { + if (!IsColorClose(bmp1.GetPixel(x, y), bmp2.GetPixel(x, y), 20)) + { + different++; + } + } + } + if (different > maxDiff) + { + return different + 10; + } + + return different; + } + + public static List<ImageSplitterItem> SplitBitmapToLines(NikseBitmap bmp, int xOrMorePixelsMakesSpace, bool rightToLeft, bool topToBottom, int minLineHeight, bool autoHeight, double averageLineHeight = -1) + { + var list = new List<ImageSplitterItem>(); + + // split into separate lines + var splitOld = SplitToLines(bmp, minLineHeight, averageLineHeight); + if (!autoHeight) + { + return splitOld; + } + + // fast horizontal split by x number of whole lines (3-4) + var splitThreeBlankLines = SplitToLinesByMinTransparentHorizontalLines(bmp, minLineHeight, 3); + var splitFourBlankLines = SplitToLinesByMinTransparentHorizontalLines(bmp, minLineHeight, 4); + var splitBlankLines = splitThreeBlankLines.Count == splitFourBlankLines.Count ? splitFourBlankLines : splitThreeBlankLines; + + var lineBitmaps = splitOld.Count > splitBlankLines.Count ? splitOld : splitBlankLines; + + if (lineBitmaps.Count == 1 && lineBitmaps[0].NikseBitmap?.Height > minLineHeight * 2.2) + { + lineBitmaps = SplitToLinesNew(lineBitmaps[0], minLineHeight, averageLineHeight); // more advanced split (allows for up/down) + } + + return lineBitmaps; + } + + public static List<ImageSplitterItem> SplitBitmapToLettersNew(NikseBitmap bmp, int xOrMorePixelsMakesSpace, bool rightToLeft, bool topToBottom, int minLineHeight, bool autoHeight, double averageLineHeight = -1) + { + var list = new List<ImageSplitterItem>(); + + // split into separate lines + var splitOld = SplitToLines(bmp, minLineHeight, averageLineHeight); + + List<ImageSplitterItem> lineBitmaps; + if (autoHeight) + { + // fast horizontal split by x number of whole lines (3-4) + var splitThreeBlankLines = SplitToLinesByMinTransparentHorizontalLines(bmp, minLineHeight, 3); + var splitFourBlankLines = SplitToLinesByMinTransparentHorizontalLines(bmp, minLineHeight, 4); + var splitBlankLines = splitThreeBlankLines.Count == splitFourBlankLines.Count ? splitFourBlankLines : splitThreeBlankLines; + + lineBitmaps = splitOld.Count > splitBlankLines.Count ? splitOld : splitBlankLines; + + if (lineBitmaps.Count == 1 && lineBitmaps[0].NikseBitmap?.Height > minLineHeight * 2.2) + { + lineBitmaps = SplitToLinesNew(lineBitmaps[0], minLineHeight, averageLineHeight); // more advanced split (allows for up/down) + } + } + else + { + lineBitmaps = splitOld; + } + + //foreach (var bitmap in tempBitmaps) + //{ + // // var height = bitmap.NikseBitmap.GetNonTransparentHeight(); + // var bitmaps = SplitToLinesNew(bitmap, minLineHeight, averageLineHeight); // more advanced split (allows for up/down) + // lineBitmaps.AddRange(bitmaps); + //} + + if (!topToBottom) + { + lineBitmaps.Reverse(); + } + + // split into letters + for (int index = 0; index < lineBitmaps.Count; index++) + { + var b = lineBitmaps[index]; + if (index > 0) + { + list.Add(new ImageSplitterItem(Environment.NewLine)); + } + + var line = new List<ImageSplitterItem>(); + foreach (var item in SplitHorizontalNew(b, xOrMorePixelsMakesSpace)) + { + item.Top = index > 0 ? item.Y - b.Y : item.Y; + item.ParentY = item.Y; + line.Add(item); + } + if (rightToLeft) + { + line.Reverse(); + } + + list.AddRange(line); + } + return list; + } + + + /// <summary> + /// split into lines + /// </summary> + public static List<ImageSplitterItem> SplitToLinesByMinTransparentHorizontalLines(NikseBitmap bmp, int minLineHeight, int minTransparentLines) + { + var parts = new List<ImageSplitterItem>(); + var startY = 0; + var lastTransparentY = -1; + var keysInSequence = 0; + for (int y = minLineHeight; y < bmp.Height - minLineHeight; y++) + { + var isLineTransparent = bmp.IsLineTransparent(y); + if (startY == y && isLineTransparent) + { + startY++; + continue; // skip start + } + + if (isLineTransparent) + { + if (lastTransparentY == y - 1) + { + if (keysInSequence == 0) + { + keysInSequence++; + } + + keysInSequence++; + } + + if (keysInSequence > 2 && lastTransparentY - startY > minLineHeight) + { + var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, lastTransparentY - startY - 1)); + if (!part.IsImageOnlyTransparent() && part.GetNonTransparentHeight() >= minLineHeight) + { + var croppedTop = part.CropTopTransparent(0); + parts.Add(new ImageSplitterItem(0, startY + croppedTop, part)); + startY = lastTransparentY + 1; + } + } + lastTransparentY = y; + } + else + { + keysInSequence = 0; + lastTransparentY = -1; + } + } + + if (bmp.Height - startY > 1) + { + var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, bmp.Height - startY)); + if (!part.IsImageOnlyTransparent()) + { + var croppedTop = part.CropTopTransparent(0); + parts.Add(new ImageSplitterItem(0, startY + croppedTop, part)); + } + } + + return parts; + } + + + /// <summary> + /// split into lines + /// </summary> + public static List<ImageSplitterItem> SplitToLinesNew(ImageSplitterItem item, int minLineHeight, double averageLineHeight = -1) + { + var bmp = new NikseBitmap(item.NikseBitmap); + var parts = new List<ImageSplitterItem>(); + bool started = false; + var splitLines = new Dictionary<int, List<Point>>(); + var startY = 0; + for (int y = minLineHeight; y < bmp.Height - minLineHeight; y++) + { + if (startY == y && bmp.IsLineTransparent(y)) + { + startY++; + continue; + } + + var points = new List<Point>(); + var yChange = 0; + var completed = false; + var backJump = 0; + int x = 0; + var maxUp = Math.Min(10, minLineHeight / 2); + while (x < bmp.Width) + { + var a1 = bmp.GetAlpha(x, y + yChange); + var a2 = bmp.GetAlpha(x, y + 1 + yChange); + if (a1 > 150 || a2 > 150) + { + if (x > 1 && yChange < 8 && + bmp.GetAlpha(x - 1, y + yChange) < 150 && bmp.GetAlpha(x - 1, y + yChange) < 150 && + bmp.GetAlpha(x - 1, y + 1 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 2 + yChange) < 150 && + bmp.GetAlpha(x - 1, y + 2 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 3 + yChange) < 150 && + bmp.GetAlpha(x, y + 2 + yChange) < 150 && bmp.GetAlpha(x, y + 3 + yChange) < 150) + { + yChange += 2; + } + + else if (x > 1 && yChange < 8 && + bmp.GetAlpha(x - 1, y + yChange) < 150 && bmp.GetAlpha(x - 1, y + yChange) < 150 && + bmp.GetAlpha(x - 1, y + 1 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 2 + yChange) < 150 && + bmp.GetAlpha(x - 1, y + 2 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 3 + yChange) < 150 && + bmp.GetAlpha(x - 1, y + 3 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 4 + yChange) < 150 && + bmp.GetAlpha(x, y + 3 + yChange) < 150 && bmp.GetAlpha(x, y + 4 + yChange) < 150) + { + yChange += 3; + } + + else if (x > 1 && yChange < 7 && + bmp.GetAlpha(x - 1, y + yChange) < 150 && bmp.GetAlpha(x - 1, y + yChange) < 150 && + bmp.GetAlpha(x - 1, y + 1 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 2 + yChange) < 150 && + bmp.GetAlpha(x - 1, y + 2 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 3 + yChange) < 150 && + bmp.GetAlpha(x - 1, y + 3 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 4 + yChange) < 150 && + bmp.GetAlpha(x - 1, y + 4 + yChange) < 150 && bmp.GetAlpha(x - 1, y + 5 + yChange) < 150 && + bmp.GetAlpha(x, y + 4 + yChange) < 150 && bmp.GetAlpha(x, y + 5 + yChange) < 150) + { + yChange += 4; + } + + else if (x > 1 && yChange > -7 && + bmp.GetAlpha(x - 1, y + yChange) < 150 && bmp.GetAlpha(x - 1, y + yChange) < 150 && + bmp.GetAlpha(x - 1, y - 1 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 2 + yChange) < 150 && + bmp.GetAlpha(x - 1, y - 2 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 3 + yChange) < 150 && + bmp.GetAlpha(x, y - 2 + yChange) < 150 && bmp.GetAlpha(x, y - 3 + yChange) < 150) + { + yChange -= 2; + } + + else if (x > 1 && yChange > -7 && + bmp.GetAlpha(x - 1, y + yChange) < 150 && bmp.GetAlpha(x - 1, y + yChange) < 150 && + bmp.GetAlpha(x - 1, y - 1 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 2 + yChange) < 150 && + bmp.GetAlpha(x - 1, y - 2 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 3 + yChange) < 150 && + bmp.GetAlpha(x - 1, y - 3 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 4 + yChange) < 150 && + bmp.GetAlpha(x, y - 3 + yChange) < 150 && bmp.GetAlpha(x, y - 4 + yChange) < 150) + { + yChange -= 3; + } + + else if (x > 1 && yChange > -7 && + bmp.GetAlpha(x - 1, y + yChange) < 150 && bmp.GetAlpha(x - 1, y + yChange) < 150 && + bmp.GetAlpha(x - 1, y - 1 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 2 + yChange) < 150 && + bmp.GetAlpha(x - 1, y - 2 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 3 + yChange) < 150 && + bmp.GetAlpha(x - 1, y - 3 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 4 + yChange) < 150 && + bmp.GetAlpha(x - 1, y - 4 + yChange) < 150 && bmp.GetAlpha(x - 1, y - 5 + yChange) < 150 && + bmp.GetAlpha(x, y - 4 + yChange) < 150 && bmp.GetAlpha(x, y - 5 + yChange) < 150) + { + yChange -= 4; + } + + else if (x > 10 && backJump < 3 && x > 5 && yChange > -7) // go left + up + check 12 pixels right + { + var done = false; + for (int i = 1; i < maxUp; i++) + { + for (int k = 1; k < 9; k++) + { + if (CanGoUpAndRight(bmp, i, 12, x - k, y + yChange, minLineHeight)) + { + backJump++; + x -= k; + points.RemoveAll(p => p.X > x); + done = true; + yChange -= (i + 1); + break; + } + } + + if (done) + { + break; + } + } + + if (!done) + { + started = true; + break; + } + } + + else + { + started = true; + break; + } + } + + if (started) + { + points.Add(new Point(x, y + yChange)); + } + + completed = x == bmp.Width - 1; + x++; + } + + if (completed) + { + splitLines.Add(y, points); + } + + } + + var transparentColor = Color.FromArgb(0, 0, 0, 0); + foreach (var line in splitLines) + { + var key = line.Key; + if (key - startY > minLineHeight && line.Value.Count > 0) + { + var maxY = line.Value.Max(p => p.Y); + var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, maxY - startY)); + //part.GetBitmap().Save(@"j:\temp\split_" + parts.Count + "_before.bmp"); + + foreach (var point in line.Value) + { + // delete down + for (var y = point.Y - 1; y < startY + part.Height; y++) + { + part.SetPixel(point.X, y - startY, transparentColor); + } + } + //part.GetBitmap().Save(@"j:\temp\split_" + parts.Count + "_after.bmp"); + + if (!part.IsImageOnlyTransparent() && part.GetNonTransparentHeight() >= minLineHeight) + { + var minY = line.Value.Min(p => p.Y); + // bmp.GetBitmap().Save(@"j:\temp\main_" + parts.Count + "_before.bmp"); + foreach (var point in line.Value) + { + // delete up + for (var y = point.Y; y >= minY; y--) + { + bmp.SetPixel(point.X, y, transparentColor); + } + } + // bmp.GetBitmap().Save(@"j:\temp\main_" + parts.Count + "_after.bmp"); + + // part.GetBitmap().Save(@"j:\temp\split_" + parts.Count + "_after.bmp"); + var croppedTop = part.CropTopTransparent(0); + parts.Add(new ImageSplitterItem(0 + item.X, startY + croppedTop + item.Y, part)); + + startY = key + 1; + } + + } + } + + if (bmp.Height - startY > 1 && parts.Count > 0) + { + var part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, bmp.Height - startY)); + if (!part.IsImageOnlyTransparent()) + { + //part.GetBitmap().Save(@"j:\temp\split_" + parts.Count + ".bmp"); + var croppedTop = part.CropTopTransparent(0); + parts.Add(new ImageSplitterItem(0 + item.X, startY + croppedTop + item.Y, part)); + } + } + + if (parts.Count <= 1) + { + return new List<ImageSplitterItem> { item }; + } + + return parts; + } + + private static bool CanGoUpAndRight(NikseBitmap bmp, int up, int right, int x, int y, int minLineHeight) + { + if (y - up < 0 || x + right >= bmp.Width || y + minLineHeight > bmp.Height) + { + return false; + } + + for (int myY = y; myY > y - up && myY > 1; myY--) + { + var a = bmp.GetAlpha(x, myY); + if (a > 150) + { + return false; + } + } + + for (int myX = x; x < x + right && myX < bmp.Width; myX++) + { + var a = bmp.GetAlpha(myX, y - up); + if (a > 150) + { + return false; + } + } + + return true; + } + + + private static IEnumerable<ImageSplitterItem> SplitHorizontalNew(ImageSplitterItem lineSplitterItem, int xOrMorePixelsMakesSpace) + { + var bmp = new NikseBitmap(lineSplitterItem.NikseBitmap); + bmp.AddTransparentLineRight(); + var parts = new List<ImageSplitterItem>(); + int startX = 0; + int width = 0; + int spacePixels = 0; + int subtractSpacePixels = 0; + for (int x = 0; x < bmp.Width; x++) + { + bool right; + bool clean; + List<Point> points = IsVerticalLineTransparetNew(bmp, x, out right, out clean); + + if (points != null && clean) + { + spacePixels++; + } + + if (right && points != null) + { + int add = FindMaxX(points, x) - x; + width += add; + subtractSpacePixels = add; + } + + var newStartX = points != null ? FindMinX(points, x) : 0; + if (points == null) + { + width++; + } + else if (width > 0 && newStartX > startX + 1) + { + var bmp0 = new NikseBitmap(bmp); + // remove pixels after current; + for (int index = 0; index < points.Count; index++) + { + var p = points[index]; + bmp0.MakeVerticalLinePartTransparent(p.X, p.X + index, p.Y); + } + width = FindMaxX(points, x) - startX; + width--; + startX++; + var b1 = bmp0.CopyRectangle(new Rectangle(startX, 0, width, bmp.Height)); + + int addY; + b1 = CropTopAndBottom(b1, out addY); + + if (spacePixels >= xOrMorePixelsMakesSpace && parts.Count > 0) + { + parts.Add(new ImageSplitterItem(" ") { Y = addY + lineSplitterItem.Y }); + } + + if (b1.Width > 0 && b1.Height > 0) + { + parts.Add(new ImageSplitterItem(startX + lineSplitterItem.X, addY + lineSplitterItem.Y, b1)); //y is what? + } + + // remove pixels before next letter; + const int begin = 0; + foreach (var p in points) + { + bmp.MakeVerticalLinePartTransparent(begin, p.X, p.Y); + } + width = 1; + startX = FindMinX(points, x); + spacePixels = -subtractSpacePixels; + subtractSpacePixels = 0; + } + else if (clean) + { + width = 1; + startX = newStartX; + } + } + return parts; + } + + private static int FindMinX(List<Point> points, int x) + { + for (int index = 0; index < points.Count; index++) + { + var p = points[index]; + if (p.X < x) + { + x = p.X; + } + } + return x; + } + + private static int FindMaxX(List<Point> points, int x) + { + for (int index = 0; index < points.Count; index++) + { + var p = points[index]; + if (p.X > x) + { + x = p.X; + } + } + return x; + } + + private static List<Point> IsVerticalLineTransparetNew(NikseBitmap bmp, int x, out bool right, out bool clean) + { + right = false; + bool left = false; + int leftCount = 0; + int rightCount = 0; + clean = true; + var points = new List<Point>(); + int y = 0; + int maxSlide = bmp.Height / 4; + + while (y < bmp.Height) + { + if (bmp.GetAlpha(x, y) > 100) + { + clean = false; + if (x == 0) + { + return null; + } + + if (x < bmp.Width - 1 && y < bmp.Height - 1 && bmp.GetAlpha(x + 1, y) == 0 && bmp.GetAlpha(x + 1, y + 1) == 0) + { + //if pixels to the left - move right? + if (bmp.GetAlpha(x - 1, y) > 0) + { + x++; //(requires search for min/max x in points + right = true; + } + else if (x > 0 && bmp.GetAlpha(x - 1, y) == 0) + { + x--; //(requires search for min/max x in points + left = true; + } + else + { + return null; + } + } + else if (x < bmp.Width - 1 && y == bmp.Height - 1 && bmp.GetAlpha(x + 1, y) == 0 && bmp.GetAlpha(x + 1, y - 1) == 0) + { + //if pixels to the left - move right? + if (bmp.GetAlpha(x - 1, y) > 0) + { + x++; //(requires search for min/max x in points + } + else + { + return null; + } + right = true; + } + else if (bmp.GetAlpha(x - 1, y) == 0) + { + x--; + left = true; + } + else if (y > 5 && bmp.GetAlpha(x - 1, y - 1) == 0) + { + x--; + y--; + left = true; + while (points.Count > 0 && points[points.Count - 1].Y > y) + { + points.RemoveAt(points.Count - 1); + } + } + else if (y > 5 && bmp.GetAlpha(x - 1, y - 2) == 0) + { + x--; + y -= 2; + left = true; + while (points.Count > 0 && points[points.Count - 1].Y > y) + { + points.RemoveAt(points.Count - 1); + } + } + else + { + return null; + } + + if (left) + { + leftCount++; + } + + if (right) + { + rightCount++; + } + + if (leftCount > maxSlide || rightCount > maxSlide) + { + return null; + } + } + else + { + points.Add(new Point(x, y)); + y++; + } + } + return points; + } + + internal static int IsBitmapsAlike(ManagedBitmap bmp1, NikseBitmap bmp2) + { + int different = 0; + int maxDiff = bmp1.Width * bmp1.Height / 5; + + for (int x = 1; x < bmp1.Width; x++) + { + for (int y = 1; y < bmp1.Height; y++) + { + if (!IsColorClose(bmp1.GetPixel(x, y), bmp2.GetPixel(x, y), 20)) + { + different++; + } + } + if (different > maxDiff) + { + return different + 10; + } + } + return different; + } + + internal static int IsBitmapsAlike(NikseBitmap bmp1, ManagedBitmap bmp2) + { + int different = 0; + int maxDiff = bmp1.Width * bmp1.Height / 5; + + for (int x = 1; x < bmp1.Width; x++) + { + for (int y = 1; y < bmp1.Height; y++) + { + if (!IsColorClose(bmp1.GetPixel(x, y), bmp2.GetPixel(x, y), 20)) + { + different++; + } + } + if (different > maxDiff) + { + return different + 10; + } + } + return different; + } + + internal static int IsBitmapsAlike(Ocr.Binary.BinaryOcrBitmap bmp1, NikseBitmap bmp2) + { + int different = 0; + int maxDiff = bmp1.Width * bmp1.Height / 5; + int w4 = bmp2.Width * 4; + for (int y = 0; y < bmp1.Height; y++) + { + var alpha = y * w4 + 3; + var pixel = y * bmp1.Width; + for (int x = 0; x < bmp1.Width; x++) + { + if (bmp1.GetPixel(pixel) > 0 && bmp2.GetAlpha(alpha) < 100) + { + different++; + } + + pixel++; + alpha += 4; + } + if (different > maxDiff) + { + return different + 10; + } + } + return different; + } + + internal static int IsBitmapsAlike(Ocr.Binary.BinaryOcrBitmap bmp1, Ocr.Binary.BinaryOcrBitmap bmp2) + { + int different = 0; + int maxDiff = bmp1.Width * bmp1.Height / 5; + for (int y = 0; y < bmp1.Height; y++) + { + var pixel = y * bmp1.Width; + for (int x = 0; x < bmp1.Width; x++) + { + if (bmp1.GetPixel(pixel) != bmp2.GetPixel(pixel)) + { + different++; + } + + pixel++; + } + if (different > maxDiff) + { + return different + 10; + } + } + return different; + } + + internal static int IsBitmapsAlike(NikseBitmap bmp1, Ocr.Binary.BinaryOcrBitmap bmp2) + { + int different = 0; + int maxDiff = bmp1.Width * bmp1.Height / 5; + int w4 = bmp1.Width * 4; + for (int y = 1; y < bmp1.Height; y++) + { + var alpha = y * w4 + 7; + var pixel = y * bmp2.Width + 1; + for (int x = 1; x < bmp1.Width; x++) + { + if (bmp1.GetAlpha(alpha) < 100 && bmp2.GetPixel(pixel) > 0) + { + different++; + } + + pixel++; + alpha += 4; + } + if (different > maxDiff) + { + return different + 10; + } + } + return different; + } + + } +} diff --git a/src/Logic/Ocr/Binary/BinaryOcrBitmap.cs b/src/ui/Logic/Ocr/Binary/BinaryOcrBitmap.cs similarity index 96% rename from src/Logic/Ocr/Binary/BinaryOcrBitmap.cs rename to src/ui/Logic/Ocr/Binary/BinaryOcrBitmap.cs index c1d27677b..3622bac53 100644 --- a/src/Logic/Ocr/Binary/BinaryOcrBitmap.cs +++ b/src/ui/Logic/Ocr/Binary/BinaryOcrBitmap.cs @@ -1,911 +1,911 @@ -using Nikse.SubtitleEdit.Core; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic.Ocr.Binary -{ - public class BinaryOcrBitmap - { - //File format: - //------------- - //2bytes=width - //2bytes=height - //2bytes=x - //2bytes=y - //2bytes=numberOfColoredPixels - //1byte=flags (1 bit = italic, next 7 bits = ExpandCount) - //4bytes=hash - //1bytes=text len - //text len bytes=text (UTF-8) - //w*h bytes / 8=pixels as bits(byte aligned) - - public int Width { get; private set; } - public int Height { get; private set; } - public int X { get; set; } - public int Y { get; set; } - public int NumberOfColoredPixels { get; private set; } - public uint Hash { get; private set; } - private byte[] _colors; - public bool Italic { get; set; } - public int ExpandCount { get; set; } - public bool LoadedOk { get; } - public string Text { get; set; } - public List<BinaryOcrBitmap> ExpandedList { get; set; } - - public string Key => Text + "|#|" + Hash + "_" + Width + "x" + Height + "_" + NumberOfColoredPixels; - - public override string ToString() - { - if (Italic) - { - return Text + " (" + Width + "x" + Height + ", italic)"; - } - - return Text + " (" + Width + "x" + Height + ")"; - } - - public BinaryOcrBitmap(int width, int height) - { - Width = width; - Height = height; - _colors = new byte[Width * Height]; - Hash = MurMurHash3.Hash(_colors); - NumberOfColoredPixels = 0; - } - - public BinaryOcrBitmap(Stream stream) - { - try - { - var buffer = new byte[16]; - int read = stream.Read(buffer, 0, buffer.Length); - if (read < buffer.Length) - { - LoadedOk = false; - return; - } - Width = buffer[0] << 8 | buffer[1]; - Height = buffer[2] << 8 | buffer[3]; - X = buffer[4] << 8 | buffer[5]; - Y = buffer[6] << 8 | buffer[7]; - NumberOfColoredPixels = buffer[8] << 8 | buffer[9]; - Italic = (buffer[10] & 0b10000000) > 0; - ExpandCount = buffer[10] & 0b01111111; - Hash = (uint)(buffer[11] << 24 | buffer[12] << 16 | buffer[13] << 8 | buffer[14]); - int textLen = buffer[15]; - if (textLen > 0) - { - buffer = new byte[textLen]; - stream.Read(buffer, 0, buffer.Length); - Text = System.Text.Encoding.UTF8.GetString(buffer); - } - - _colors = new byte[Width * Height]; - stream.Read(_colors, 0, _colors.Length); - LoadedOk = true; - } - catch - { - LoadedOk = false; - } - } - - public BinaryOcrBitmap(NikseBitmap nbmp) - { - InitializeViaNikseBmp(nbmp); - } - - public BinaryOcrBitmap(NikseBitmap nbmp, bool italic, int expandCount, string text, int x, int y) - { - InitializeViaNikseBmp(nbmp); - Italic = italic; - ExpandCount = expandCount; - Text = text; - X = x; - Y = y; - } - - private void InitializeViaNikseBmp(NikseBitmap nbmp) - { - Width = nbmp.Width; - Height = nbmp.Height; - _colors = new byte[Width * Height]; - var numberOfColoredPixels = 0; - for (int y = 0; y < Height; y++) - { - for (int x = 0; x < Width; x++) - { - var alpha = nbmp.GetAlpha(x, y); - if (alpha < 100) - { - _colors[Width * y + x] = 0; - } - else - { - _colors[Width * y + x] = 1; - numberOfColoredPixels++; - } - } - } - NumberOfColoredPixels = numberOfColoredPixels; - Hash = MurMurHash3.Hash(_colors); - } - - public bool AreColorsEqual(BinaryOcrBitmap other) - { - if (_colors.Length != other._colors.Length) - { - return false; - } - - for (int i = 0; i < _colors.Length; i++) - { - if (_colors[i] != other._colors[i]) - { - return false; - } - } - - return true; - } - - public void Save(Stream stream) - { - WriteInt16(stream, (ushort)Width); - WriteInt16(stream, (ushort)Height); - - WriteInt16(stream, (ushort)X); - WriteInt16(stream, (ushort)Y); - - WriteInt16(stream, (ushort)NumberOfColoredPixels); - - byte flags = (byte)(ExpandCount & 0b01111111); - if (Italic) - { - flags = (byte)(flags + 0b10000000); - } - - stream.WriteByte(flags); - - WriteInt32(stream, Hash); - - if (Text == null) - { - stream.WriteByte(0); - } - else - { - var textBuffer = System.Text.Encoding.UTF8.GetBytes(Text); - stream.WriteByte((byte)textBuffer.Length); - stream.Write(textBuffer, 0, textBuffer.Length); - } - - stream.Write(_colors, 0, _colors.Length); - } - - private static void WriteInt16(Stream stream, ushort val) - { - var buffer = new byte[2]; - buffer[0] = (byte)((val & 0xFF00) >> 8); - buffer[1] = (byte)(val & 0x00FF); - stream.Write(buffer, 0, buffer.Length); - } - - private static void WriteInt32(Stream stream, UInt32 val) - { - var buffer = new byte[4]; - buffer[0] = (byte)((val & 0xFF000000) >> 24); - buffer[1] = (byte)((val & 0xFF0000) >> 16); - buffer[2] = (byte)((val & 0xFF00) >> 8); - buffer[3] = (byte)(val & 0xFF); - stream.Write(buffer, 0, buffer.Length); - } - - public int GetPixel(int x, int y) - { - return _colors[Width * y + x]; - } - - public int GetPixel(int index) - { - return _colors[index]; - } - - public void SetPixel(int x, int y) - { - _colors[Width * y + x] = 1; - } - - /// <summary> - /// Copies a rectangle from the bitmap to a new bitmap - /// </summary> - /// <param name="section">Source rectangle</param> - /// <returns>Rectangle from current image as new bitmap</returns> - public ManagedBitmap GetRectangle(Rectangle section) - { - var newRectangle = new ManagedBitmap(section.Width, section.Height); - - int recty = 0; - for (int y = section.Top; y < section.Top + section.Height; y++) - { - int rectx = 0; - for (int x = section.Left; x < section.Left + section.Width; x++) - { - Color c = Color.Transparent; - if (GetPixel(x, y) > 0) - { - c = Color.White; - } - - newRectangle.SetPixel(rectx, recty, c); - rectx++; - } - recty++; - } - return newRectangle; - } - - public Bitmap ToOldBitmap() - { - return ToOldBitmap(Color.White); - } - - public Bitmap ToOldBitmap(Color color) - { - if (ExpandedList != null && ExpandedList.Count > 0) - { - int minX = X; - int minY = Y; - int maxX = X + Width; - int maxY = Y + Height; - var list = new List<BinaryOcrBitmap> { this }; - foreach (BinaryOcrBitmap bob in ExpandedList) - { - if (bob.X < minX) - { - minX = bob.X; - } - - if (bob.Y < minY) - { - minY = bob.Y; - } - - if (bob.X + bob.Width > maxX) - { - maxX = bob.X + bob.Width; - } - - if (bob.Y + bob.Height > maxY) - { - maxY = bob.Y + bob.Height; - } - - list.Add(bob); - } - var nbmp = new BinaryOcrBitmap(maxX - minX, maxY - minY); - foreach (BinaryOcrBitmap bob in list) - { - for (int y = 0; y < bob.Height; y++) - { - for (int x = 0; x < bob.Width; x++) - { - int c = bob.GetPixel(x, y); - if (c > 0) - { - nbmp.SetPixel(bob.X - minX + x, bob.Y - minY + y); - } - } - } - } - - return nbmp.ToOldBitmap(color); // Recursive - } - else - { - var nbmp = new NikseBitmap(Width, Height); - for (int y = 0; y < Height; y++) - { - for (int x = 0; x < Width; x++) - { - Color c = Color.Transparent; - if (GetPixel(x, y) > 0) - { - c = color; - } - - nbmp.SetPixel(x, y, c); - } - } - return nbmp.GetBitmap(); - } - } - - - public bool IsPeriod() - { - if (ExpandCount > 0 || Y < 20) - { - return false; - } - - if (Width == 4 && Height == 5 && NumberOfColoredPixels == 20) - { - return true; - } - - if (Width == 5 && Height == 6 && NumberOfColoredPixels >= 28) - { - return true; - } - - if (Width == 6 && Height == 7 && NumberOfColoredPixels >= 40) - { - return true; - } - - if (Width < Height || Width < 5 || Width > 10 || Height < 3 || Height > 9) - { - return false; - } - - return true; - } - - public bool IsPeriodAtTop(int lowercaseHeight) - { - if (ExpandCount > 0 || Y > lowercaseHeight * 0.7) - { - return false; - } - - if (Width == 4 && Height == 5 && NumberOfColoredPixels == 20) - { - return true; - } - - if (Width == 5 && Height == 6 && NumberOfColoredPixels >= 28) - { - return true; - } - - if (Width == 6 && Height == 7 && NumberOfColoredPixels >= 40) - { - return true; - } - - if (Width < Height || Width < 5 || Width > 10 || Height < 3 || Height > 9) - { - return false; - } - - return true; - } - - public bool IsComma() - { - if (ExpandCount > 0 || Y < 20 || Height < Width || Width < 4 || Width > 12 || Height < 8 || Height > 15) - { - return false; - } - - return true; - } - - public bool IsApostrophe() - { - if (ExpandCount > 0 || Y > 10 || Height < Width - 2 || Width < 4 || Width > 12 || Height < 8 || Height > 16) - { - return false; - } - if ((double)Width * Height / NumberOfColoredPixels > 1.2) - { - return false; - } - if ((double)Height / Width < 2) // aspect ratio - { - return false; - } - - return true; - } - - public bool IsLowercaseI(out bool italic) - { - italic = false; - if (ExpandCount > 0 || Y > 20 || Height < Width + 10 || Width < 3 || Width > 20 || Height < 21 || Height > 60) - { - return false; - } - if ((double)Height / Width < 2.2) // aspect ratio - { - return false; - } - - if (Width > Height / 4) - { - if (GetPixel(1, 1) == 0 && GetPixel(2, 2) == 0 && GetPixel(Width - 1, Height - 1) == 0 && GetPixel(Width - 2, Height - 2) == 0) - { - italic = true; - } - if (Height > 40 && (GetPixel(3, 3) == 1 || GetPixel(Width - 3, Height - 3) == 1)) - { - italic = false; - } - } - - var transparentHorLines = new bool[Height]; - for (int y = 0; y < Height; y++) - { - transparentHorLines[y] = true; - for (int x = 0; x < Width; x++) - { - if (GetPixel(x, y) != 0) - { - transparentHorLines[y] = false; - break; - } - } - } - if (transparentHorLines[0] || transparentHorLines[1]) - { - return false; - } - - for (int i = 0; i < Height / 2; i++) - { - if (transparentHorLines[Height - i - 1]) - { - return false; - } - } - var top = Height / 7; - for (int i = 0; i < 6; i++) - { - if (transparentHorLines[top + i]) - { - return true; - } - } - - return false; - } - - /// <summary> - /// Detects a lowercase non-italic 'j' - /// </summary> - /// <returns>true if image is 'j'</returns> - public bool IsLowercaseJ() - { - if (ExpandCount > 0 || Y > 20 || Height < Width * 2 || Width < 5 || Width > 25 || Height < 21 || Height > 70) - { - return false; - } - - var transparentHorLines = new bool[Height]; - for (int y = 0; y < Height; y++) - { - transparentHorLines[y] = true; - for (int x = 0; x < Width; x++) - { - if (GetPixel(x, y) != 0) - { - transparentHorLines[y] = false; - break; - } - } - } - - // top should be filled - if (transparentHorLines[0] || transparentHorLines[1]) - { - return false; - } - - // bottom half should be filled - for (int i = 0; i < Height / 2; i++) - { - if (transparentHorLines[Height - i - 1]) - { - return false; - } - } - - var top = Height / 7; - for (int i = 0; i < 6; i++) - { - if (transparentHorLines[top + i]) - { - top = top + i; - - // top left area should be free - int freeXPixels = 0; - for (int x = 0; x < Width; x++) - { - if (GetPixel(x, Height / 2) != 0) - { - break; - } - freeXPixels++; - } - if (freeXPixels < 3 || freeXPixels > Width * 0.67) - { - return false; - } - for (int y = top; y < Height * 0.67; y++) - { - for (int x = 0; x < freeXPixels; x++) - { - if (GetPixel(x, y) != 0) - { - return false; - } - } - } - return true; - } - } - - return false; - } - - public bool IsColon() - { - if (ExpandCount > 0 || Y < 5 || Y > 45 || Width > Height / 2 || Width < 3 || Width > 18 || Height < 14 || Height > 45) - { - return false; - } - - if (NumberOfColoredPixels * 2 > Width * Height) - { - return false; - } - - var transparentHorLines = new bool[Height]; - for (int y = 0; y < Height; y++) - { - transparentHorLines[y] = true; - for (int x = 0; x < Width; x++) - { - if (GetPixel(x, y) != 0) - { - transparentHorLines[y] = false; - break; - } - } - } - if (transparentHorLines[0] || transparentHorLines[1] || transparentHorLines[2]) - { - return false; - } - - if (transparentHorLines[Height - 1] || transparentHorLines[Height - 2] || transparentHorLines[Height - 3]) - { - return false; - } - - int startY = Height / 4; - int endY = startY * 3; - startY++; - endY--; - for (int y = startY; y < endY; y++) - { - if (!transparentHorLines[y]) - { - return false; - } - } - - return true; - } - - public bool IsDash() - { - if (ExpandCount > 0 || Y < 13 || Height * 2.3 > Width || Width < 10 || Width > 25 || Height < 3 || Height > 7) - { - return false; - } - - if (NumberOfColoredPixels + 7 < Width * Height) - { - return false; - } - - var transparentHorLines = new bool[Height]; - for (int y = 0; y < Height; y++) - { - transparentHorLines[y] = true; - for (int x = 0; x < Width; x++) - { - if (GetPixel(x, y) != 0) - { - transparentHorLines[y] = false; - break; - } - } - } - for (int i = 0; i < transparentHorLines.Length; i++) - { - if (transparentHorLines[i]) - { - return false; - } - } - - var transparentVerLines = new bool[Width]; - for (int x = 0; x < Width; x++) - { - transparentVerLines[x] = true; - for (int y = 0; y < Height; y++) - { - if (GetPixel(x, y) != 0) - { - transparentVerLines[x] = false; - break; - } - } - } - for (int i = 0; i < transparentVerLines.Length; i++) - { - if (transparentVerLines[i]) - { - return false; - } - } - - return true; - } - - public bool IsExclamationMark() - { - if (ExpandCount > 0 || Y > 20 || Height < Width + 10 || Width < 3 || Width > 17 || Height < 21 || Height > 50) - { - return false; - } - - if ((double)Height / Width < 2.3) // aspect ratio - { - return false; - } - - var transparentHorLines = new bool[Height]; - for (int y = 0; y < Height; y++) - { - transparentHorLines[y] = true; - for (int x = 0; x < Width; x++) - { - if (GetPixel(x, y) != 0) - { - transparentHorLines[y] = false; - break; - } - } - } - if (transparentHorLines[Height - 1] || transparentHorLines[Height - 2]) - { - return false; - } - - for (int i = 0; i < Height / 2; i++) - { - if (transparentHorLines[i]) - { - return false; - } - } - var bottom = Height - Height / 7; - for (int i = 0; i < 6; i++) - { - if (transparentHorLines[bottom - i]) - { - return true; - } - } - - return false; - } - - public bool IsLowercaseL() - { - if (ExpandCount > 0 || Y > 20 || Height < Width + 10 || Width < 4 || Width > 17 || Height < 21 || Height > 50) - { - return false; - } - - var transparentHorLines = new bool[Height]; - for (int y = 0; y < Height; y++) - { - transparentHorLines[y] = true; - for (int x = 0; x < Width; x++) - { - if (GetPixel(x, y) != 0) - { - transparentHorLines[y] = false; - break; - } - } - } - for (int i = 0; i < transparentHorLines.Length; i++) - { - if (transparentHorLines[i]) - { - return false; - } - } - - return true; - } - - public bool IsC() - { - if (ExpandCount > 0 || Y > 20 || Height < Width + 1 || Width < 12 || Width > 49 || Height < 15 || Height > 55) - { - return false; - } - - if (GetPixel(1, 1) != 0) - { - return false; - } - - if (GetPixel(1, Height - 1) != 0) - { - return false; - } - - if (GetPixel(Width - 1, 0) != 0) - { - return false; - } - - if (GetPixel(Width - 2, Height - 2) != 0) - { - return false; - } - - var transparentHorLines = new bool[Height]; - for (int y = 0; y < Height; y++) - { - transparentHorLines[y] = true; - for (int x = 0; x < Width; x++) - { - if (GetPixel(x, y) != 0) - { - transparentHorLines[y] = false; - break; - } - } - } - for (int i = 0; i < transparentHorLines.Length; i++) - { - if (transparentHorLines[i]) - { - return false; - } - } - - var transparentVerLines = new bool[Width]; - for (int x = 0; x < Width; x++) - { - transparentVerLines[x] = true; - for (int y = 0; y < Height; y++) - { - if (GetPixel(x, y) != 0) - { - transparentVerLines[x] = false; - break; - } - } - } - for (int i = 0; i < transparentVerLines.Length; i++) - { - if (transparentVerLines[i]) - { - return false; - } - } - - int halfWidth = Width / 2 - 1; - int halfHeight = Height / 2; - int halfHeightM1 = halfHeight--; - for (int x = halfWidth; x < Width; x++) - { - if (GetPixel(x, halfHeight) != 0 || GetPixel(x, halfHeightM1) != 0) - { - return false; - } - } - - return true; - } - - public bool IsO() - { - if (ExpandCount > 0 || Y > 20 || Math.Abs(Height - Width) > (int)Math.Round(Height / 6.0) || Width < 12 || Width > 49 || Height < 15 || Height > 55) - { - return false; - } - - if (GetPixel(1, 1) != 0) - { - return false; - } - - if (GetPixel(1, Height - 1) != 0) - { - return false; - } - - if (GetPixel(Width - 1, 0) != 0) - { - return false; - } - - if (GetPixel(Width - 2, Height - 2) != 0) - { - return false; - } - - var transparentHorLines = new bool[Height]; - for (int y = 0; y < Height; y++) - { - transparentHorLines[y] = true; - for (int x = 0; x < Width; x++) - { - if (GetPixel(x, y) != 0) - { - transparentHorLines[y] = false; - break; - } - } - } - for (int i = 0; i < transparentHorLines.Length; i++) - { - if (transparentHorLines[i]) - { - return false; - } - } - - var transparentVerLines = new bool[Width]; - for (int x = 0; x < Width; x++) - { - transparentVerLines[x] = true; - for (int y = 0; y < Height; y++) - { - if (GetPixel(x, y) != 0) - { - transparentVerLines[x] = false; - break; - } - } - } - for (int i = 0; i < transparentVerLines.Length; i++) - { - if (transparentVerLines[i]) - { - return false; - } - } - - int halfWidth = Width / 2 - 1; - int halfHeight = Height / 2; - int runLength = Width / 6; - for (int x = halfWidth - runLength; x < halfWidth + runLength; x++) - { - if (GetPixel(x, halfHeight - 1) != 0 || - GetPixel(x, halfHeight + 0) != 0 || - GetPixel(x, halfHeight + 1) != 0) - { - return false; - } - } - - return true; - } - - } -} +using Nikse.SubtitleEdit.Core; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic.Ocr.Binary +{ + public class BinaryOcrBitmap + { + //File format: + //------------- + //2bytes=width + //2bytes=height + //2bytes=x + //2bytes=y + //2bytes=numberOfColoredPixels + //1byte=flags (1 bit = italic, next 7 bits = ExpandCount) + //4bytes=hash + //1bytes=text len + //text len bytes=text (UTF-8) + //w*h bytes / 8=pixels as bits(byte aligned) + + public int Width { get; private set; } + public int Height { get; private set; } + public int X { get; set; } + public int Y { get; set; } + public int NumberOfColoredPixels { get; private set; } + public uint Hash { get; private set; } + private byte[] _colors; + public bool Italic { get; set; } + public int ExpandCount { get; set; } + public bool LoadedOk { get; } + public string Text { get; set; } + public List<BinaryOcrBitmap> ExpandedList { get; set; } + + public string Key => Text + "|#|" + Hash + "_" + Width + "x" + Height + "_" + NumberOfColoredPixels; + + public override string ToString() + { + if (Italic) + { + return Text + " (" + Width + "x" + Height + ", italic)"; + } + + return Text + " (" + Width + "x" + Height + ")"; + } + + public BinaryOcrBitmap(int width, int height) + { + Width = width; + Height = height; + _colors = new byte[Width * Height]; + Hash = MurMurHash3.Hash(_colors); + NumberOfColoredPixels = 0; + } + + public BinaryOcrBitmap(Stream stream) + { + try + { + var buffer = new byte[16]; + int read = stream.Read(buffer, 0, buffer.Length); + if (read < buffer.Length) + { + LoadedOk = false; + return; + } + Width = buffer[0] << 8 | buffer[1]; + Height = buffer[2] << 8 | buffer[3]; + X = buffer[4] << 8 | buffer[5]; + Y = buffer[6] << 8 | buffer[7]; + NumberOfColoredPixels = buffer[8] << 8 | buffer[9]; + Italic = (buffer[10] & 0b10000000) > 0; + ExpandCount = buffer[10] & 0b01111111; + Hash = (uint)(buffer[11] << 24 | buffer[12] << 16 | buffer[13] << 8 | buffer[14]); + int textLen = buffer[15]; + if (textLen > 0) + { + buffer = new byte[textLen]; + stream.Read(buffer, 0, buffer.Length); + Text = System.Text.Encoding.UTF8.GetString(buffer); + } + + _colors = new byte[Width * Height]; + stream.Read(_colors, 0, _colors.Length); + LoadedOk = true; + } + catch + { + LoadedOk = false; + } + } + + public BinaryOcrBitmap(NikseBitmap nbmp) + { + InitializeViaNikseBmp(nbmp); + } + + public BinaryOcrBitmap(NikseBitmap nbmp, bool italic, int expandCount, string text, int x, int y) + { + InitializeViaNikseBmp(nbmp); + Italic = italic; + ExpandCount = expandCount; + Text = text; + X = x; + Y = y; + } + + private void InitializeViaNikseBmp(NikseBitmap nbmp) + { + Width = nbmp.Width; + Height = nbmp.Height; + _colors = new byte[Width * Height]; + var numberOfColoredPixels = 0; + for (int y = 0; y < Height; y++) + { + for (int x = 0; x < Width; x++) + { + var alpha = nbmp.GetAlpha(x, y); + if (alpha < 100) + { + _colors[Width * y + x] = 0; + } + else + { + _colors[Width * y + x] = 1; + numberOfColoredPixels++; + } + } + } + NumberOfColoredPixels = numberOfColoredPixels; + Hash = MurMurHash3.Hash(_colors); + } + + public bool AreColorsEqual(BinaryOcrBitmap other) + { + if (_colors.Length != other._colors.Length) + { + return false; + } + + for (int i = 0; i < _colors.Length; i++) + { + if (_colors[i] != other._colors[i]) + { + return false; + } + } + + return true; + } + + public void Save(Stream stream) + { + WriteInt16(stream, (ushort)Width); + WriteInt16(stream, (ushort)Height); + + WriteInt16(stream, (ushort)X); + WriteInt16(stream, (ushort)Y); + + WriteInt16(stream, (ushort)NumberOfColoredPixels); + + byte flags = (byte)(ExpandCount & 0b01111111); + if (Italic) + { + flags = (byte)(flags + 0b10000000); + } + + stream.WriteByte(flags); + + WriteInt32(stream, Hash); + + if (Text == null) + { + stream.WriteByte(0); + } + else + { + var textBuffer = System.Text.Encoding.UTF8.GetBytes(Text); + stream.WriteByte((byte)textBuffer.Length); + stream.Write(textBuffer, 0, textBuffer.Length); + } + + stream.Write(_colors, 0, _colors.Length); + } + + private static void WriteInt16(Stream stream, ushort val) + { + var buffer = new byte[2]; + buffer[0] = (byte)((val & 0xFF00) >> 8); + buffer[1] = (byte)(val & 0x00FF); + stream.Write(buffer, 0, buffer.Length); + } + + private static void WriteInt32(Stream stream, UInt32 val) + { + var buffer = new byte[4]; + buffer[0] = (byte)((val & 0xFF000000) >> 24); + buffer[1] = (byte)((val & 0xFF0000) >> 16); + buffer[2] = (byte)((val & 0xFF00) >> 8); + buffer[3] = (byte)(val & 0xFF); + stream.Write(buffer, 0, buffer.Length); + } + + public int GetPixel(int x, int y) + { + return _colors[Width * y + x]; + } + + public int GetPixel(int index) + { + return _colors[index]; + } + + public void SetPixel(int x, int y) + { + _colors[Width * y + x] = 1; + } + + /// <summary> + /// Copies a rectangle from the bitmap to a new bitmap + /// </summary> + /// <param name="section">Source rectangle</param> + /// <returns>Rectangle from current image as new bitmap</returns> + public ManagedBitmap GetRectangle(Rectangle section) + { + var newRectangle = new ManagedBitmap(section.Width, section.Height); + + int recty = 0; + for (int y = section.Top; y < section.Top + section.Height; y++) + { + int rectx = 0; + for (int x = section.Left; x < section.Left + section.Width; x++) + { + Color c = Color.Transparent; + if (GetPixel(x, y) > 0) + { + c = Color.White; + } + + newRectangle.SetPixel(rectx, recty, c); + rectx++; + } + recty++; + } + return newRectangle; + } + + public Bitmap ToOldBitmap() + { + return ToOldBitmap(Color.White); + } + + public Bitmap ToOldBitmap(Color color) + { + if (ExpandedList != null && ExpandedList.Count > 0) + { + int minX = X; + int minY = Y; + int maxX = X + Width; + int maxY = Y + Height; + var list = new List<BinaryOcrBitmap> { this }; + foreach (BinaryOcrBitmap bob in ExpandedList) + { + if (bob.X < minX) + { + minX = bob.X; + } + + if (bob.Y < minY) + { + minY = bob.Y; + } + + if (bob.X + bob.Width > maxX) + { + maxX = bob.X + bob.Width; + } + + if (bob.Y + bob.Height > maxY) + { + maxY = bob.Y + bob.Height; + } + + list.Add(bob); + } + var nbmp = new BinaryOcrBitmap(maxX - minX, maxY - minY); + foreach (BinaryOcrBitmap bob in list) + { + for (int y = 0; y < bob.Height; y++) + { + for (int x = 0; x < bob.Width; x++) + { + int c = bob.GetPixel(x, y); + if (c > 0) + { + nbmp.SetPixel(bob.X - minX + x, bob.Y - minY + y); + } + } + } + } + + return nbmp.ToOldBitmap(color); // Recursive + } + else + { + var nbmp = new NikseBitmap(Width, Height); + for (int y = 0; y < Height; y++) + { + for (int x = 0; x < Width; x++) + { + Color c = Color.Transparent; + if (GetPixel(x, y) > 0) + { + c = color; + } + + nbmp.SetPixel(x, y, c); + } + } + return nbmp.GetBitmap(); + } + } + + + public bool IsPeriod() + { + if (ExpandCount > 0 || Y < 20) + { + return false; + } + + if (Width == 4 && Height == 5 && NumberOfColoredPixels == 20) + { + return true; + } + + if (Width == 5 && Height == 6 && NumberOfColoredPixels >= 28) + { + return true; + } + + if (Width == 6 && Height == 7 && NumberOfColoredPixels >= 40) + { + return true; + } + + if (Width < Height || Width < 5 || Width > 10 || Height < 3 || Height > 9) + { + return false; + } + + return true; + } + + public bool IsPeriodAtTop(int lowercaseHeight) + { + if (ExpandCount > 0 || Y > lowercaseHeight * 0.7) + { + return false; + } + + if (Width == 4 && Height == 5 && NumberOfColoredPixels == 20) + { + return true; + } + + if (Width == 5 && Height == 6 && NumberOfColoredPixels >= 28) + { + return true; + } + + if (Width == 6 && Height == 7 && NumberOfColoredPixels >= 40) + { + return true; + } + + if (Width < Height || Width < 5 || Width > 10 || Height < 3 || Height > 9) + { + return false; + } + + return true; + } + + public bool IsComma() + { + if (ExpandCount > 0 || Y < 20 || Height < Width || Width < 4 || Width > 12 || Height < 8 || Height > 15) + { + return false; + } + + return true; + } + + public bool IsApostrophe() + { + if (ExpandCount > 0 || Y > 10 || Height < Width - 2 || Width < 4 || Width > 12 || Height < 8 || Height > 16) + { + return false; + } + if ((double)Width * Height / NumberOfColoredPixels > 1.2) + { + return false; + } + if ((double)Height / Width < 2) // aspect ratio + { + return false; + } + + return true; + } + + public bool IsLowercaseI(out bool italic) + { + italic = false; + if (ExpandCount > 0 || Y > 20 || Height < Width + 10 || Width < 3 || Width > 20 || Height < 21 || Height > 60) + { + return false; + } + if ((double)Height / Width < 2.2) // aspect ratio + { + return false; + } + + if (Width > Height / 4) + { + if (GetPixel(1, 1) == 0 && GetPixel(2, 2) == 0 && GetPixel(Width - 1, Height - 1) == 0 && GetPixel(Width - 2, Height - 2) == 0) + { + italic = true; + } + if (Height > 40 && (GetPixel(3, 3) == 1 || GetPixel(Width - 3, Height - 3) == 1)) + { + italic = false; + } + } + + var transparentHorLines = new bool[Height]; + for (int y = 0; y < Height; y++) + { + transparentHorLines[y] = true; + for (int x = 0; x < Width; x++) + { + if (GetPixel(x, y) != 0) + { + transparentHorLines[y] = false; + break; + } + } + } + if (transparentHorLines[0] || transparentHorLines[1]) + { + return false; + } + + for (int i = 0; i < Height / 2; i++) + { + if (transparentHorLines[Height - i - 1]) + { + return false; + } + } + var top = Height / 7; + for (int i = 0; i < 6; i++) + { + if (transparentHorLines[top + i]) + { + return true; + } + } + + return false; + } + + /// <summary> + /// Detects a lowercase non-italic 'j' + /// </summary> + /// <returns>true if image is 'j'</returns> + public bool IsLowercaseJ() + { + if (ExpandCount > 0 || Y > 20 || Height < Width * 2 || Width < 5 || Width > 25 || Height < 21 || Height > 70) + { + return false; + } + + var transparentHorLines = new bool[Height]; + for (int y = 0; y < Height; y++) + { + transparentHorLines[y] = true; + for (int x = 0; x < Width; x++) + { + if (GetPixel(x, y) != 0) + { + transparentHorLines[y] = false; + break; + } + } + } + + // top should be filled + if (transparentHorLines[0] || transparentHorLines[1]) + { + return false; + } + + // bottom half should be filled + for (int i = 0; i < Height / 2; i++) + { + if (transparentHorLines[Height - i - 1]) + { + return false; + } + } + + var top = Height / 7; + for (int i = 0; i < 6; i++) + { + if (transparentHorLines[top + i]) + { + top = top + i; + + // top left area should be free + int freeXPixels = 0; + for (int x = 0; x < Width; x++) + { + if (GetPixel(x, Height / 2) != 0) + { + break; + } + freeXPixels++; + } + if (freeXPixels < 3 || freeXPixels > Width * 0.67) + { + return false; + } + for (int y = top; y < Height * 0.67; y++) + { + for (int x = 0; x < freeXPixels; x++) + { + if (GetPixel(x, y) != 0) + { + return false; + } + } + } + return true; + } + } + + return false; + } + + public bool IsColon() + { + if (ExpandCount > 0 || Y < 5 || Y > 45 || Width > Height / 2 || Width < 3 || Width > 18 || Height < 14 || Height > 45) + { + return false; + } + + if (NumberOfColoredPixels * 2 > Width * Height) + { + return false; + } + + var transparentHorLines = new bool[Height]; + for (int y = 0; y < Height; y++) + { + transparentHorLines[y] = true; + for (int x = 0; x < Width; x++) + { + if (GetPixel(x, y) != 0) + { + transparentHorLines[y] = false; + break; + } + } + } + if (transparentHorLines[0] || transparentHorLines[1] || transparentHorLines[2]) + { + return false; + } + + if (transparentHorLines[Height - 1] || transparentHorLines[Height - 2] || transparentHorLines[Height - 3]) + { + return false; + } + + int startY = Height / 4; + int endY = startY * 3; + startY++; + endY--; + for (int y = startY; y < endY; y++) + { + if (!transparentHorLines[y]) + { + return false; + } + } + + return true; + } + + public bool IsDash() + { + if (ExpandCount > 0 || Y < 13 || Height * 2.3 > Width || Width < 10 || Width > 25 || Height < 3 || Height > 7) + { + return false; + } + + if (NumberOfColoredPixels + 7 < Width * Height) + { + return false; + } + + var transparentHorLines = new bool[Height]; + for (int y = 0; y < Height; y++) + { + transparentHorLines[y] = true; + for (int x = 0; x < Width; x++) + { + if (GetPixel(x, y) != 0) + { + transparentHorLines[y] = false; + break; + } + } + } + for (int i = 0; i < transparentHorLines.Length; i++) + { + if (transparentHorLines[i]) + { + return false; + } + } + + var transparentVerLines = new bool[Width]; + for (int x = 0; x < Width; x++) + { + transparentVerLines[x] = true; + for (int y = 0; y < Height; y++) + { + if (GetPixel(x, y) != 0) + { + transparentVerLines[x] = false; + break; + } + } + } + for (int i = 0; i < transparentVerLines.Length; i++) + { + if (transparentVerLines[i]) + { + return false; + } + } + + return true; + } + + public bool IsExclamationMark() + { + if (ExpandCount > 0 || Y > 20 || Height < Width + 10 || Width < 3 || Width > 17 || Height < 21 || Height > 50) + { + return false; + } + + if ((double)Height / Width < 2.3) // aspect ratio + { + return false; + } + + var transparentHorLines = new bool[Height]; + for (int y = 0; y < Height; y++) + { + transparentHorLines[y] = true; + for (int x = 0; x < Width; x++) + { + if (GetPixel(x, y) != 0) + { + transparentHorLines[y] = false; + break; + } + } + } + if (transparentHorLines[Height - 1] || transparentHorLines[Height - 2]) + { + return false; + } + + for (int i = 0; i < Height / 2; i++) + { + if (transparentHorLines[i]) + { + return false; + } + } + var bottom = Height - Height / 7; + for (int i = 0; i < 6; i++) + { + if (transparentHorLines[bottom - i]) + { + return true; + } + } + + return false; + } + + public bool IsLowercaseL() + { + if (ExpandCount > 0 || Y > 20 || Height < Width + 10 || Width < 4 || Width > 17 || Height < 21 || Height > 50) + { + return false; + } + + var transparentHorLines = new bool[Height]; + for (int y = 0; y < Height; y++) + { + transparentHorLines[y] = true; + for (int x = 0; x < Width; x++) + { + if (GetPixel(x, y) != 0) + { + transparentHorLines[y] = false; + break; + } + } + } + for (int i = 0; i < transparentHorLines.Length; i++) + { + if (transparentHorLines[i]) + { + return false; + } + } + + return true; + } + + public bool IsC() + { + if (ExpandCount > 0 || Y > 20 || Height < Width + 1 || Width < 12 || Width > 49 || Height < 15 || Height > 55) + { + return false; + } + + if (GetPixel(1, 1) != 0) + { + return false; + } + + if (GetPixel(1, Height - 1) != 0) + { + return false; + } + + if (GetPixel(Width - 1, 0) != 0) + { + return false; + } + + if (GetPixel(Width - 2, Height - 2) != 0) + { + return false; + } + + var transparentHorLines = new bool[Height]; + for (int y = 0; y < Height; y++) + { + transparentHorLines[y] = true; + for (int x = 0; x < Width; x++) + { + if (GetPixel(x, y) != 0) + { + transparentHorLines[y] = false; + break; + } + } + } + for (int i = 0; i < transparentHorLines.Length; i++) + { + if (transparentHorLines[i]) + { + return false; + } + } + + var transparentVerLines = new bool[Width]; + for (int x = 0; x < Width; x++) + { + transparentVerLines[x] = true; + for (int y = 0; y < Height; y++) + { + if (GetPixel(x, y) != 0) + { + transparentVerLines[x] = false; + break; + } + } + } + for (int i = 0; i < transparentVerLines.Length; i++) + { + if (transparentVerLines[i]) + { + return false; + } + } + + int halfWidth = Width / 2 - 1; + int halfHeight = Height / 2; + int halfHeightM1 = halfHeight--; + for (int x = halfWidth; x < Width; x++) + { + if (GetPixel(x, halfHeight) != 0 || GetPixel(x, halfHeightM1) != 0) + { + return false; + } + } + + return true; + } + + public bool IsO() + { + if (ExpandCount > 0 || Y > 20 || Math.Abs(Height - Width) > (int)Math.Round(Height / 6.0) || Width < 12 || Width > 49 || Height < 15 || Height > 55) + { + return false; + } + + if (GetPixel(1, 1) != 0) + { + return false; + } + + if (GetPixel(1, Height - 1) != 0) + { + return false; + } + + if (GetPixel(Width - 1, 0) != 0) + { + return false; + } + + if (GetPixel(Width - 2, Height - 2) != 0) + { + return false; + } + + var transparentHorLines = new bool[Height]; + for (int y = 0; y < Height; y++) + { + transparentHorLines[y] = true; + for (int x = 0; x < Width; x++) + { + if (GetPixel(x, y) != 0) + { + transparentHorLines[y] = false; + break; + } + } + } + for (int i = 0; i < transparentHorLines.Length; i++) + { + if (transparentHorLines[i]) + { + return false; + } + } + + var transparentVerLines = new bool[Width]; + for (int x = 0; x < Width; x++) + { + transparentVerLines[x] = true; + for (int y = 0; y < Height; y++) + { + if (GetPixel(x, y) != 0) + { + transparentVerLines[x] = false; + break; + } + } + } + for (int i = 0; i < transparentVerLines.Length; i++) + { + if (transparentVerLines[i]) + { + return false; + } + } + + int halfWidth = Width / 2 - 1; + int halfHeight = Height / 2; + int runLength = Width / 6; + for (int x = halfWidth - runLength; x < halfWidth + runLength; x++) + { + if (GetPixel(x, halfHeight - 1) != 0 || + GetPixel(x, halfHeight + 0) != 0 || + GetPixel(x, halfHeight + 1) != 0) + { + return false; + } + } + + return true; + } + + } +} diff --git a/src/Logic/Ocr/Binary/BinaryOcrDb.cs b/src/ui/Logic/Ocr/Binary/BinaryOcrDb.cs similarity index 97% rename from src/Logic/Ocr/Binary/BinaryOcrDb.cs rename to src/ui/Logic/Ocr/Binary/BinaryOcrDb.cs index 151d530af..f0b142483 100644 --- a/src/Logic/Ocr/Binary/BinaryOcrDb.cs +++ b/src/ui/Logic/Ocr/Binary/BinaryOcrDb.cs @@ -1,254 +1,254 @@ -using Nikse.SubtitleEdit.Core; -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Linq; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic.Ocr.Binary -{ - public class BinaryOcrDb - { - public string FileName { get; } - public List<BinaryOcrBitmap> CompareImages = new List<BinaryOcrBitmap>(); - public List<BinaryOcrBitmap> CompareImagesExpanded = new List<BinaryOcrBitmap>(); - - public BinaryOcrDb(string fileName) - { - FileName = fileName; - } - - public BinaryOcrDb(string fileName, bool loadCompareImages) - { - FileName = fileName; - if (loadCompareImages) - { - LoadCompareImages(); - } - } - - public void Save() - { - using (Stream gz = new GZipStream(File.OpenWrite(FileName), CompressionMode.Compress)) - { - foreach (var bob in CompareImages) - { - if (bob.ExpandCount > 0) - { - System.Windows.Forms.MessageBox.Show("Ups, expand image in CompareImages!"); - } - - bob.Save(gz); - } - foreach (var bob in CompareImagesExpanded) - { - if (bob.ExpandCount == 0) - { - System.Windows.Forms.MessageBox.Show("Ups, not expanded image in CompareImagesExpanded!"); - } - - bob.Save(gz); - if (bob.ExpandedList.Count != bob.ExpandCount - 1) - { - throw new Exception("BinaryOcrDb.Save: Expanded image should have " + (bob.ExpandCount - 1) + " sub images"); - } - foreach (var expandedBob in bob.ExpandedList) - { - if (expandedBob.Text != null) - { - throw new Exception("BinaryOcrDb.Save: sub image should have null text"); - } - - expandedBob.Save(gz); - } - } - } - } - - public void LoadCompareImages() - { - var list = new List<BinaryOcrBitmap>(); - var expandList = new List<BinaryOcrBitmap>(); - - if (!File.Exists(FileName)) - { - CompareImages = list; - return; - } - - using (Stream gz = new GZipStream(File.OpenRead(FileName), CompressionMode.Decompress)) - { - bool done = false; - while (!done) - { - var bob = new BinaryOcrBitmap(gz); - if (bob.LoadedOk) - { - if (bob.ExpandCount > 0) - { - expandList.Add(bob); - bob.ExpandedList = new List<BinaryOcrBitmap>(); - for (int i = 1; i < bob.ExpandCount; i++) - { - var expandedBob = new BinaryOcrBitmap(gz); - if (expandedBob.LoadedOk) - { - if (expandedBob.Text != null) - { - throw new Exception("BinaryOcrDb.LoadCompareImages: sub image should have null text"); - } - - bob.ExpandedList.Add(expandedBob); - } - else - { - break; - } - } - } - else - { - list.Add(bob); - } - } - else - { - done = true; - } - } - } - CompareImages = list; - CompareImagesExpanded = expandList; - } - - private static int MaxCommaQuoteTopDiff = 15; - - public static bool AllowEqual(BinaryOcrBitmap match, BinaryOcrBitmap newBob) - { - if (match.Text != null && (match.Text == "," || match.Text == "'") && - Math.Abs(match.Y - newBob.Y) > MaxCommaQuoteTopDiff) - { - return false; - } - return true; - } - - public int FindExactMatch(BinaryOcrBitmap bob) - { - var bobHash = bob.Hash; - for (int i = 0; i < CompareImages.Count; i++) - { - var b = CompareImages[i]; - if (bobHash == b.Hash && bob.Width == b.Width && bob.Height == b.Height && bob.NumberOfColoredPixels == b.NumberOfColoredPixels) - { - if (AllowEqual(b, bob)) - { - return i; - } - } - } - return -1; - } - - public int FindExactMatchExpanded(BinaryOcrBitmap bob) - { - for (int i = 0; i < CompareImagesExpanded.Count; i++) - { - var b = CompareImagesExpanded[i]; - if (bob.Hash == b.Hash && - bob.Width == b.Width && - bob.Height == b.Height && - bob.NumberOfColoredPixels == b.NumberOfColoredPixels && - bob.ExpandCount == b.ExpandCount && - bob.AreColorsEqual(b)) - { - bool ok = true; - for (int k = 0; k < b.ExpandedList.Count; k++) - { - if (bob.ExpandedList[k].Hash != b.ExpandedList[k].Hash || - !bob.ExpandedList[k].AreColorsEqual(b.ExpandedList[k])) // expanded images - { - ok = false; - } - } - if (ok) - { - return i; - } - } - - } - return -1; - } - - public int Add(BinaryOcrBitmap bob) - { - int index; - if (bob.ExpandCount > 0) - { - if (bob.ExpandedList == null || bob.ExpandCount - 1 != bob.ExpandedList.Count) - { - throw new Exception("BinaryOcrDb.Add: There should be " + (bob.ExpandCount - 1) + " sub image(s)"); - } - - if (bob.ExpandedList[0].Text != null) - { - throw new Exception("BinaryOcrDb.Add: sub image should have null text"); - } - - index = FindExactMatchExpanded(bob); - if (index == -1 || CompareImagesExpanded[index].ExpandCount != bob.ExpandCount) - { - CompareImagesExpanded.Add(bob); - } - else - { - bool allAlike = true; - for (int i = 0; i < bob.ExpandCount - 1; i++) - { - if (bob.ExpandedList[i].Hash != CompareImagesExpanded[index].ExpandedList[i].Hash) - { - allAlike = false; - } - - if (bob.ExpandedList[i].Text != null) - { - throw new Exception("BinaryOcrDb.Add: sub image should have null text"); - } - } - if (!allAlike) - { - CompareImagesExpanded.Add(bob); - } - else - { - throw new Exception("BinaryOcrDb.Add: Expanded image already in db!"); - } - } - } - else - { - index = FindExactMatch(bob); - if (index == -1) - { - CompareImages.Add(bob); - } - else - { - throw new Exception("BinaryOcrDb.Add: Image already in db!"); - } - } - return index; - } - - public static List<string> GetDatabases() - { - return Directory - .GetFiles(Configuration.OcrDirectory.TrimEnd(Path.DirectorySeparatorChar), "*.db") - .Select(Path.GetFileNameWithoutExtension) - .OrderBy(p => p) - .ToList(); - } - } -} +using Nikse.SubtitleEdit.Core; +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Linq; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic.Ocr.Binary +{ + public class BinaryOcrDb + { + public string FileName { get; } + public List<BinaryOcrBitmap> CompareImages = new List<BinaryOcrBitmap>(); + public List<BinaryOcrBitmap> CompareImagesExpanded = new List<BinaryOcrBitmap>(); + + public BinaryOcrDb(string fileName) + { + FileName = fileName; + } + + public BinaryOcrDb(string fileName, bool loadCompareImages) + { + FileName = fileName; + if (loadCompareImages) + { + LoadCompareImages(); + } + } + + public void Save() + { + using (Stream gz = new GZipStream(File.OpenWrite(FileName), CompressionMode.Compress)) + { + foreach (var bob in CompareImages) + { + if (bob.ExpandCount > 0) + { + System.Windows.Forms.MessageBox.Show("Ups, expand image in CompareImages!"); + } + + bob.Save(gz); + } + foreach (var bob in CompareImagesExpanded) + { + if (bob.ExpandCount == 0) + { + System.Windows.Forms.MessageBox.Show("Ups, not expanded image in CompareImagesExpanded!"); + } + + bob.Save(gz); + if (bob.ExpandedList.Count != bob.ExpandCount - 1) + { + throw new Exception("BinaryOcrDb.Save: Expanded image should have " + (bob.ExpandCount - 1) + " sub images"); + } + foreach (var expandedBob in bob.ExpandedList) + { + if (expandedBob.Text != null) + { + throw new Exception("BinaryOcrDb.Save: sub image should have null text"); + } + + expandedBob.Save(gz); + } + } + } + } + + public void LoadCompareImages() + { + var list = new List<BinaryOcrBitmap>(); + var expandList = new List<BinaryOcrBitmap>(); + + if (!File.Exists(FileName)) + { + CompareImages = list; + return; + } + + using (Stream gz = new GZipStream(File.OpenRead(FileName), CompressionMode.Decompress)) + { + bool done = false; + while (!done) + { + var bob = new BinaryOcrBitmap(gz); + if (bob.LoadedOk) + { + if (bob.ExpandCount > 0) + { + expandList.Add(bob); + bob.ExpandedList = new List<BinaryOcrBitmap>(); + for (int i = 1; i < bob.ExpandCount; i++) + { + var expandedBob = new BinaryOcrBitmap(gz); + if (expandedBob.LoadedOk) + { + if (expandedBob.Text != null) + { + throw new Exception("BinaryOcrDb.LoadCompareImages: sub image should have null text"); + } + + bob.ExpandedList.Add(expandedBob); + } + else + { + break; + } + } + } + else + { + list.Add(bob); + } + } + else + { + done = true; + } + } + } + CompareImages = list; + CompareImagesExpanded = expandList; + } + + private static int MaxCommaQuoteTopDiff = 15; + + public static bool AllowEqual(BinaryOcrBitmap match, BinaryOcrBitmap newBob) + { + if (match.Text != null && (match.Text == "," || match.Text == "'") && + Math.Abs(match.Y - newBob.Y) > MaxCommaQuoteTopDiff) + { + return false; + } + return true; + } + + public int FindExactMatch(BinaryOcrBitmap bob) + { + var bobHash = bob.Hash; + for (int i = 0; i < CompareImages.Count; i++) + { + var b = CompareImages[i]; + if (bobHash == b.Hash && bob.Width == b.Width && bob.Height == b.Height && bob.NumberOfColoredPixels == b.NumberOfColoredPixels) + { + if (AllowEqual(b, bob)) + { + return i; + } + } + } + return -1; + } + + public int FindExactMatchExpanded(BinaryOcrBitmap bob) + { + for (int i = 0; i < CompareImagesExpanded.Count; i++) + { + var b = CompareImagesExpanded[i]; + if (bob.Hash == b.Hash && + bob.Width == b.Width && + bob.Height == b.Height && + bob.NumberOfColoredPixels == b.NumberOfColoredPixels && + bob.ExpandCount == b.ExpandCount && + bob.AreColorsEqual(b)) + { + bool ok = true; + for (int k = 0; k < b.ExpandedList.Count; k++) + { + if (bob.ExpandedList[k].Hash != b.ExpandedList[k].Hash || + !bob.ExpandedList[k].AreColorsEqual(b.ExpandedList[k])) // expanded images + { + ok = false; + } + } + if (ok) + { + return i; + } + } + + } + return -1; + } + + public int Add(BinaryOcrBitmap bob) + { + int index; + if (bob.ExpandCount > 0) + { + if (bob.ExpandedList == null || bob.ExpandCount - 1 != bob.ExpandedList.Count) + { + throw new Exception("BinaryOcrDb.Add: There should be " + (bob.ExpandCount - 1) + " sub image(s)"); + } + + if (bob.ExpandedList[0].Text != null) + { + throw new Exception("BinaryOcrDb.Add: sub image should have null text"); + } + + index = FindExactMatchExpanded(bob); + if (index == -1 || CompareImagesExpanded[index].ExpandCount != bob.ExpandCount) + { + CompareImagesExpanded.Add(bob); + } + else + { + bool allAlike = true; + for (int i = 0; i < bob.ExpandCount - 1; i++) + { + if (bob.ExpandedList[i].Hash != CompareImagesExpanded[index].ExpandedList[i].Hash) + { + allAlike = false; + } + + if (bob.ExpandedList[i].Text != null) + { + throw new Exception("BinaryOcrDb.Add: sub image should have null text"); + } + } + if (!allAlike) + { + CompareImagesExpanded.Add(bob); + } + else + { + throw new Exception("BinaryOcrDb.Add: Expanded image already in db!"); + } + } + } + else + { + index = FindExactMatch(bob); + if (index == -1) + { + CompareImages.Add(bob); + } + else + { + throw new Exception("BinaryOcrDb.Add: Image already in db!"); + } + } + return index; + } + + public static List<string> GetDatabases() + { + return Directory + .GetFiles(Configuration.OcrDirectory.TrimEnd(Path.DirectorySeparatorChar), "*.db") + .Select(Path.GetFileNameWithoutExtension) + .OrderBy(p => p) + .ToList(); + } + } +} diff --git a/src/Logic/Ocr/MatchesToItalicStringConverter.cs b/src/ui/Logic/Ocr/MatchesToItalicStringConverter.cs similarity index 100% rename from src/Logic/Ocr/MatchesToItalicStringConverter.cs rename to src/ui/Logic/Ocr/MatchesToItalicStringConverter.cs diff --git a/src/Logic/Ocr/ModiLanguage.cs b/src/ui/Logic/Ocr/ModiLanguage.cs similarity index 97% rename from src/Logic/Ocr/ModiLanguage.cs rename to src/ui/Logic/Ocr/ModiLanguage.cs index 44cef0997..f21a35be4 100644 --- a/src/Logic/Ocr/ModiLanguage.cs +++ b/src/ui/Logic/Ocr/ModiLanguage.cs @@ -1,50 +1,50 @@ -using System.Collections.Generic; - -namespace Nikse.SubtitleEdit.Logic.Ocr -{ - public class ModiLanguage - { - public int Id { get; set; } - public string Text { get; set; } - - public override string ToString() - { - return Text; - } - - public const int DefaultLanguageId = 2048; - - public static IEnumerable<ModiLanguage> AllLanguages - { - get - { - var list = new List<ModiLanguage> - { - new ModiLanguage { Id = DefaultLanguageId, Text = "Default" }, - new ModiLanguage { Id = 2052, Text = "Chinese simplified" }, - new ModiLanguage { Id = 1028, Text = "Chinese traditional" }, - new ModiLanguage { Id = 5, Text = "Chech" }, - new ModiLanguage { Id = 6, Text = "Danish" }, - new ModiLanguage { Id = 19, Text = "Dutch" }, - new ModiLanguage { Id = 9, Text = "English" }, - new ModiLanguage { Id = 11, Text = "Finnish" }, - new ModiLanguage { Id = 12, Text = "French" }, - new ModiLanguage { Id = 7, Text = "German" }, - new ModiLanguage { Id = 8, Text = "Greek" }, - new ModiLanguage { Id = 14, Text = "Hungarian" }, - new ModiLanguage { Id = 16, Text = "Italian" }, - new ModiLanguage { Id = 17, Text = "Japanese" }, - new ModiLanguage { Id = 18, Text = "Korean" }, - new ModiLanguage { Id = 20, Text = "Norweigian" }, - new ModiLanguage { Id = 21, Text = "Polish" }, - new ModiLanguage { Id = 22, Text = "Portuguese" }, - new ModiLanguage { Id = 25, Text = "Russian" }, - new ModiLanguage { Id = 10, Text = "Spanish" }, - new ModiLanguage { Id = 29, Text = "Swedish" }, - new ModiLanguage { Id = 31, Text = "Turkish" } - }; - return list; - } - } - } -} +using System.Collections.Generic; + +namespace Nikse.SubtitleEdit.Logic.Ocr +{ + public class ModiLanguage + { + public int Id { get; set; } + public string Text { get; set; } + + public override string ToString() + { + return Text; + } + + public const int DefaultLanguageId = 2048; + + public static IEnumerable<ModiLanguage> AllLanguages + { + get + { + var list = new List<ModiLanguage> + { + new ModiLanguage { Id = DefaultLanguageId, Text = "Default" }, + new ModiLanguage { Id = 2052, Text = "Chinese simplified" }, + new ModiLanguage { Id = 1028, Text = "Chinese traditional" }, + new ModiLanguage { Id = 5, Text = "Chech" }, + new ModiLanguage { Id = 6, Text = "Danish" }, + new ModiLanguage { Id = 19, Text = "Dutch" }, + new ModiLanguage { Id = 9, Text = "English" }, + new ModiLanguage { Id = 11, Text = "Finnish" }, + new ModiLanguage { Id = 12, Text = "French" }, + new ModiLanguage { Id = 7, Text = "German" }, + new ModiLanguage { Id = 8, Text = "Greek" }, + new ModiLanguage { Id = 14, Text = "Hungarian" }, + new ModiLanguage { Id = 16, Text = "Italian" }, + new ModiLanguage { Id = 17, Text = "Japanese" }, + new ModiLanguage { Id = 18, Text = "Korean" }, + new ModiLanguage { Id = 20, Text = "Norweigian" }, + new ModiLanguage { Id = 21, Text = "Polish" }, + new ModiLanguage { Id = 22, Text = "Portuguese" }, + new ModiLanguage { Id = 25, Text = "Russian" }, + new ModiLanguage { Id = 10, Text = "Spanish" }, + new ModiLanguage { Id = 29, Text = "Swedish" }, + new ModiLanguage { Id = 31, Text = "Turkish" } + }; + return list; + } + } + } +} diff --git a/src/Logic/Ocr/NOcrChar.cs b/src/ui/Logic/Ocr/NOcrChar.cs similarity index 97% rename from src/Logic/Ocr/NOcrChar.cs rename to src/ui/Logic/Ocr/NOcrChar.cs index e6f614363..1122a08a7 100644 --- a/src/Logic/Ocr/NOcrChar.cs +++ b/src/ui/Logic/Ocr/NOcrChar.cs @@ -1,318 +1,318 @@ -using System.Collections.Generic; -using System.Drawing; -using System.IO; - -namespace Nikse.SubtitleEdit.Logic.Ocr -{ - public class NOcrChar - { - public string Text { get; set; } - public int Width { get; set; } - public int Height { get; set; } - public int MarginTop { get; set; } - public bool Italic { get; set; } - public List<NOcrPoint> LinesForeground { get; } - public List<NOcrPoint> LinesBackground { get; } - public int ExpandCount { get; set; } - public bool LoadedOk { get; } - - public double WidthPercent => Height * 100.0 / Width; - - public NOcrChar() - { - LinesForeground = new List<NOcrPoint>(); - LinesBackground = new List<NOcrPoint>(); - Text = string.Empty; - } - - public NOcrChar(NOcrChar old) - { - LinesForeground = new List<NOcrPoint>(); - LinesBackground = new List<NOcrPoint>(); - Text = old.Text; - Width = old.Width; - Height = old.Height; - MarginTop = old.MarginTop; - Italic = old.Italic; - foreach (var p in old.LinesForeground) - { - LinesForeground.Add(new NOcrPoint(new Point(p.Start.X, p.Start.Y), new Point(p.End.X, p.End.Y))); - } - - foreach (var p in old.LinesBackground) - { - LinesBackground.Add(new NOcrPoint(new Point(p.Start.X, p.Start.Y), new Point(p.End.X, p.End.Y))); - } - } - - public NOcrChar(string text) - : this() - { - Text = text; - } - - public override string ToString() - { - return Text; - } - - public bool IsSensitive => Text == "O" || Text == "o" || Text == "0" || Text == "'" || Text == "-" || Text == ":" || Text == "\""; - - public NOcrChar(Stream stream, bool isVersion2) - { - try - { - if (isVersion2) - { - var buffer = new byte[4]; - int read = stream.Read(buffer, 0, buffer.Length); - if (read < buffer.Length) - { - LoadedOk = false; - return; - } - - var isShort = (buffer[0] & 0b0001_0000) > 0; - Italic = (buffer[0] & 0b0010_0000) > 0; - - if (isShort) - { - ExpandCount = buffer[0] & 0b0000_1111; - Width = buffer[1]; - Height = buffer[2]; - MarginTop = buffer[3]; - } - else - { - ExpandCount = stream.ReadByte(); - Width = stream.ReadByte() << 8 | stream.ReadByte(); - Height = stream.ReadByte() << 8 | stream.ReadByte(); - MarginTop = stream.ReadByte() << 8 | stream.ReadByte(); - } - - int textLen = stream.ReadByte(); - if (textLen > 0) - { - buffer = new byte[textLen]; - stream.Read(buffer, 0, buffer.Length); - Text = System.Text.Encoding.UTF8.GetString(buffer); - } - - if (isShort) - { - LinesForeground = ReadPointsBytes(stream); - LinesBackground = ReadPointsBytes(stream); - } - else - { - LinesForeground = ReadPoints(stream); - LinesBackground = ReadPoints(stream); - } - - LoadedOk = true; - } - else - { - var buffer = new byte[9]; - int read = stream.Read(buffer, 0, buffer.Length); - if (read < buffer.Length) - { - LoadedOk = false; - return; - } - - Width = buffer[0] << 8 | buffer[1]; - Height = buffer[2] << 8 | buffer[3]; - - MarginTop = buffer[4] << 8 | buffer[5]; - - Italic = buffer[6] != 0; - - ExpandCount = buffer[7]; - - int textLen = buffer[8]; - if (textLen > 0) - { - buffer = new byte[textLen]; - stream.Read(buffer, 0, buffer.Length); - Text = System.Text.Encoding.UTF8.GetString(buffer); - } - LinesForeground = ReadPoints(stream); - LinesBackground = ReadPoints(stream); - - LoadedOk = true; - } - } - catch - { - LoadedOk = false; - } - } - - private static List<NOcrPoint> ReadPoints(Stream stream) - { - int length = stream.ReadByte() << 8 | stream.ReadByte(); - var list = new List<NOcrPoint>(length); - var buffer = new byte[8]; - for (int i = 0; i < length; i++) - { - stream.Read(buffer, 0, buffer.Length); - var point = new NOcrPoint - { - Start = new Point(buffer[0] << 8 | buffer[1], buffer[2] << 8 | buffer[3]), - End = new Point(buffer[4] << 8 | buffer[5], buffer[6] << 8 | buffer[7]) - }; - list.Add(point); - } - return list; - } - - private static List<NOcrPoint> ReadPointsBytes(Stream stream) - { - int length = stream.ReadByte(); - var list = new List<NOcrPoint>(length); - var buffer = new byte[4]; - for (int i = 0; i < length; i++) - { - stream.Read(buffer, 0, buffer.Length); - var point = new NOcrPoint - { - Start = new Point(buffer[0], buffer[1]), - End = new Point(buffer[2], buffer[3]) - }; - list.Add(point); - } - return list; - } - - internal void Save(Stream stream) - { - if (IsAllByteValues()) - { - SaveOneBytes(stream); - } - else - { - SaveTwoBytes(stream); - } - } - - private bool IsAllByteValues() - { - return Width <= byte.MaxValue && Height <= byte.MaxValue && ExpandCount < 16 && - LinesBackground.Count <= byte.MaxValue && LinesForeground.Count <= byte.MaxValue && - IsAllPointByteValues(LinesForeground) && IsAllPointByteValues(LinesForeground); - } - - private static bool IsAllPointByteValues(List<NOcrPoint> lines) - { - for (var index = 0; index < lines.Count; index++) - { - var point = lines[index]; - if (point.Start.X > byte.MaxValue || point.Start.Y > byte.MaxValue || - point.End.X > byte.MaxValue || point.End.Y > byte.MaxValue) - { - return false; - } - } - - return true; - } - - private void SaveOneBytes(Stream stream) - { - var flags = 0b0001_0000; - - if (Italic) - { - flags |= 0b0010_0000; - } - - if (ExpandCount > 0) - { - flags |= (byte)ExpandCount; - } - - stream.WriteByte((byte)flags); - - stream.WriteByte((byte)Width); - stream.WriteByte((byte)Height); - stream.WriteByte((byte)MarginTop); - - if (Text == null) - { - stream.WriteByte(0); - } - else - { - var textBuffer = System.Text.Encoding.UTF8.GetBytes(Text); - stream.WriteByte((byte)textBuffer.Length); - stream.Write(textBuffer, 0, textBuffer.Length); - } - WritePointsAsOneByte(stream, LinesForeground); - WritePointsAsOneByte(stream, LinesBackground); - } - - private void SaveTwoBytes(Stream stream) - { - var flags = 0b0000_0000; - - if (Italic) - { - flags |= 0b0010_0000; - } - - stream.WriteByte((byte)flags); - stream.WriteByte((byte)ExpandCount); - - WriteInt16(stream, (ushort)Width); - WriteInt16(stream, (ushort)Height); - WriteInt16(stream, (ushort)MarginTop); - - if (Text == null) - { - stream.WriteByte(0); - } - else - { - var textBuffer = System.Text.Encoding.UTF8.GetBytes(Text); - stream.WriteByte((byte)textBuffer.Length); - stream.Write(textBuffer, 0, textBuffer.Length); - } - WritePoints(stream, LinesForeground); - WritePoints(stream, LinesBackground); - } - - private static void WritePointsAsOneByte(Stream stream, List<NOcrPoint> points) - { - stream.WriteByte((byte)points.Count); - foreach (var nOcrPoint in points) - { - stream.WriteByte((byte)nOcrPoint.Start.X); - stream.WriteByte((byte)nOcrPoint.Start.Y); - stream.WriteByte((byte)nOcrPoint.End.X); - stream.WriteByte((byte)nOcrPoint.End.Y); - } - } - - private static void WritePoints(Stream stream, List<NOcrPoint> points) - { - WriteInt16(stream, (ushort)points.Count); - foreach (var nOcrPoint in points) - { - WriteInt16(stream, (ushort)nOcrPoint.Start.X); - WriteInt16(stream, (ushort)nOcrPoint.Start.Y); - WriteInt16(stream, (ushort)nOcrPoint.End.X); - WriteInt16(stream, (ushort)nOcrPoint.End.Y); - } - } - - private static void WriteInt16(Stream stream, ushort val) - { - var buffer = new byte[2]; - buffer[0] = (byte)((val & 0xFF00) >> 8); - buffer[1] = (byte)(val & 0x00FF); - stream.Write(buffer, 0, buffer.Length); - } - } -} +using System.Collections.Generic; +using System.Drawing; +using System.IO; + +namespace Nikse.SubtitleEdit.Logic.Ocr +{ + public class NOcrChar + { + public string Text { get; set; } + public int Width { get; set; } + public int Height { get; set; } + public int MarginTop { get; set; } + public bool Italic { get; set; } + public List<NOcrPoint> LinesForeground { get; } + public List<NOcrPoint> LinesBackground { get; } + public int ExpandCount { get; set; } + public bool LoadedOk { get; } + + public double WidthPercent => Height * 100.0 / Width; + + public NOcrChar() + { + LinesForeground = new List<NOcrPoint>(); + LinesBackground = new List<NOcrPoint>(); + Text = string.Empty; + } + + public NOcrChar(NOcrChar old) + { + LinesForeground = new List<NOcrPoint>(); + LinesBackground = new List<NOcrPoint>(); + Text = old.Text; + Width = old.Width; + Height = old.Height; + MarginTop = old.MarginTop; + Italic = old.Italic; + foreach (var p in old.LinesForeground) + { + LinesForeground.Add(new NOcrPoint(new Point(p.Start.X, p.Start.Y), new Point(p.End.X, p.End.Y))); + } + + foreach (var p in old.LinesBackground) + { + LinesBackground.Add(new NOcrPoint(new Point(p.Start.X, p.Start.Y), new Point(p.End.X, p.End.Y))); + } + } + + public NOcrChar(string text) + : this() + { + Text = text; + } + + public override string ToString() + { + return Text; + } + + public bool IsSensitive => Text == "O" || Text == "o" || Text == "0" || Text == "'" || Text == "-" || Text == ":" || Text == "\""; + + public NOcrChar(Stream stream, bool isVersion2) + { + try + { + if (isVersion2) + { + var buffer = new byte[4]; + int read = stream.Read(buffer, 0, buffer.Length); + if (read < buffer.Length) + { + LoadedOk = false; + return; + } + + var isShort = (buffer[0] & 0b0001_0000) > 0; + Italic = (buffer[0] & 0b0010_0000) > 0; + + if (isShort) + { + ExpandCount = buffer[0] & 0b0000_1111; + Width = buffer[1]; + Height = buffer[2]; + MarginTop = buffer[3]; + } + else + { + ExpandCount = stream.ReadByte(); + Width = stream.ReadByte() << 8 | stream.ReadByte(); + Height = stream.ReadByte() << 8 | stream.ReadByte(); + MarginTop = stream.ReadByte() << 8 | stream.ReadByte(); + } + + int textLen = stream.ReadByte(); + if (textLen > 0) + { + buffer = new byte[textLen]; + stream.Read(buffer, 0, buffer.Length); + Text = System.Text.Encoding.UTF8.GetString(buffer); + } + + if (isShort) + { + LinesForeground = ReadPointsBytes(stream); + LinesBackground = ReadPointsBytes(stream); + } + else + { + LinesForeground = ReadPoints(stream); + LinesBackground = ReadPoints(stream); + } + + LoadedOk = true; + } + else + { + var buffer = new byte[9]; + int read = stream.Read(buffer, 0, buffer.Length); + if (read < buffer.Length) + { + LoadedOk = false; + return; + } + + Width = buffer[0] << 8 | buffer[1]; + Height = buffer[2] << 8 | buffer[3]; + + MarginTop = buffer[4] << 8 | buffer[5]; + + Italic = buffer[6] != 0; + + ExpandCount = buffer[7]; + + int textLen = buffer[8]; + if (textLen > 0) + { + buffer = new byte[textLen]; + stream.Read(buffer, 0, buffer.Length); + Text = System.Text.Encoding.UTF8.GetString(buffer); + } + LinesForeground = ReadPoints(stream); + LinesBackground = ReadPoints(stream); + + LoadedOk = true; + } + } + catch + { + LoadedOk = false; + } + } + + private static List<NOcrPoint> ReadPoints(Stream stream) + { + int length = stream.ReadByte() << 8 | stream.ReadByte(); + var list = new List<NOcrPoint>(length); + var buffer = new byte[8]; + for (int i = 0; i < length; i++) + { + stream.Read(buffer, 0, buffer.Length); + var point = new NOcrPoint + { + Start = new Point(buffer[0] << 8 | buffer[1], buffer[2] << 8 | buffer[3]), + End = new Point(buffer[4] << 8 | buffer[5], buffer[6] << 8 | buffer[7]) + }; + list.Add(point); + } + return list; + } + + private static List<NOcrPoint> ReadPointsBytes(Stream stream) + { + int length = stream.ReadByte(); + var list = new List<NOcrPoint>(length); + var buffer = new byte[4]; + for (int i = 0; i < length; i++) + { + stream.Read(buffer, 0, buffer.Length); + var point = new NOcrPoint + { + Start = new Point(buffer[0], buffer[1]), + End = new Point(buffer[2], buffer[3]) + }; + list.Add(point); + } + return list; + } + + internal void Save(Stream stream) + { + if (IsAllByteValues()) + { + SaveOneBytes(stream); + } + else + { + SaveTwoBytes(stream); + } + } + + private bool IsAllByteValues() + { + return Width <= byte.MaxValue && Height <= byte.MaxValue && ExpandCount < 16 && + LinesBackground.Count <= byte.MaxValue && LinesForeground.Count <= byte.MaxValue && + IsAllPointByteValues(LinesForeground) && IsAllPointByteValues(LinesForeground); + } + + private static bool IsAllPointByteValues(List<NOcrPoint> lines) + { + for (var index = 0; index < lines.Count; index++) + { + var point = lines[index]; + if (point.Start.X > byte.MaxValue || point.Start.Y > byte.MaxValue || + point.End.X > byte.MaxValue || point.End.Y > byte.MaxValue) + { + return false; + } + } + + return true; + } + + private void SaveOneBytes(Stream stream) + { + var flags = 0b0001_0000; + + if (Italic) + { + flags |= 0b0010_0000; + } + + if (ExpandCount > 0) + { + flags |= (byte)ExpandCount; + } + + stream.WriteByte((byte)flags); + + stream.WriteByte((byte)Width); + stream.WriteByte((byte)Height); + stream.WriteByte((byte)MarginTop); + + if (Text == null) + { + stream.WriteByte(0); + } + else + { + var textBuffer = System.Text.Encoding.UTF8.GetBytes(Text); + stream.WriteByte((byte)textBuffer.Length); + stream.Write(textBuffer, 0, textBuffer.Length); + } + WritePointsAsOneByte(stream, LinesForeground); + WritePointsAsOneByte(stream, LinesBackground); + } + + private void SaveTwoBytes(Stream stream) + { + var flags = 0b0000_0000; + + if (Italic) + { + flags |= 0b0010_0000; + } + + stream.WriteByte((byte)flags); + stream.WriteByte((byte)ExpandCount); + + WriteInt16(stream, (ushort)Width); + WriteInt16(stream, (ushort)Height); + WriteInt16(stream, (ushort)MarginTop); + + if (Text == null) + { + stream.WriteByte(0); + } + else + { + var textBuffer = System.Text.Encoding.UTF8.GetBytes(Text); + stream.WriteByte((byte)textBuffer.Length); + stream.Write(textBuffer, 0, textBuffer.Length); + } + WritePoints(stream, LinesForeground); + WritePoints(stream, LinesBackground); + } + + private static void WritePointsAsOneByte(Stream stream, List<NOcrPoint> points) + { + stream.WriteByte((byte)points.Count); + foreach (var nOcrPoint in points) + { + stream.WriteByte((byte)nOcrPoint.Start.X); + stream.WriteByte((byte)nOcrPoint.Start.Y); + stream.WriteByte((byte)nOcrPoint.End.X); + stream.WriteByte((byte)nOcrPoint.End.Y); + } + } + + private static void WritePoints(Stream stream, List<NOcrPoint> points) + { + WriteInt16(stream, (ushort)points.Count); + foreach (var nOcrPoint in points) + { + WriteInt16(stream, (ushort)nOcrPoint.Start.X); + WriteInt16(stream, (ushort)nOcrPoint.Start.Y); + WriteInt16(stream, (ushort)nOcrPoint.End.X); + WriteInt16(stream, (ushort)nOcrPoint.End.Y); + } + } + + private static void WriteInt16(Stream stream, ushort val) + { + var buffer = new byte[2]; + buffer[0] = (byte)((val & 0xFF00) >> 8); + buffer[1] = (byte)(val & 0x00FF); + stream.Write(buffer, 0, buffer.Length); + } + } +} diff --git a/src/Logic/Ocr/NOcrDb.cs b/src/ui/Logic/Ocr/NOcrDb.cs similarity index 100% rename from src/Logic/Ocr/NOcrDb.cs rename to src/ui/Logic/Ocr/NOcrDb.cs diff --git a/src/Logic/Ocr/NOcrPoint.cs b/src/ui/Logic/Ocr/NOcrPoint.cs similarity index 96% rename from src/Logic/Ocr/NOcrPoint.cs rename to src/ui/Logic/Ocr/NOcrPoint.cs index 178116f52..4c60fa63c 100644 --- a/src/Logic/Ocr/NOcrPoint.cs +++ b/src/ui/Logic/Ocr/NOcrPoint.cs @@ -1,110 +1,110 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; - -namespace Nikse.SubtitleEdit.Logic.Ocr -{ - public class NOcrPoint - { - public Point Start { get; set; } - public Point End { get; set; } - - public NOcrPoint() - { - Start = new Point(); - End = new Point(); - } - - public NOcrPoint(Point start, Point end) - { - Start = new Point(start.X, start.Y); - End = new Point(end.X, end.Y); - } - - public static PointF PointPixelsToPercent(Point p, int pixelWidth, int pixelHeight) - { - return new PointF((float)(p.X * 100.0 / pixelWidth), (float)(p.Y * 100.0 / pixelHeight)); - } - - public static Point PointPercentToPixels(PointF p, int pixelWidth, int pixelHeight) - { - return new Point((int)Math.Round(p.X / 100.0 * pixelWidth), (int)Math.Round(p.Y / 100.0 * pixelHeight)); - } - - public override string ToString() - { - return string.Format(CultureInfo.InvariantCulture, "{0},{1} -> {2},{3} ", Start.X, Start.Y, End.X, End.Y); - } - - public PointF GetStartPercent(int width, int height) - { - return PointPixelsToPercent(Start, width, height); - } - - public PointF GetEnd(int width, int height) - { - return PointPixelsToPercent(End, width, height); - } - - public List<Point> GetPoints() - { - return GetPoints(Start, End); - } - - public List<Point> ScaledGetPoints(NOcrChar nOcrChar, int width, int height) - { - return GetPoints(GetScaledStart(nOcrChar, width, height), GetScaledEnd(nOcrChar, width, height)); - } - - public static List<Point> GetPoints(Point start, Point end) - { - var list = new List<Point>(); - int x1 = start.X; - int x2 = end.X; - int y1 = start.Y; - int y2 = end.Y; - if (Math.Abs(start.X - end.X) > Math.Abs(start.Y - end.Y)) - { - if (x1 > x2) - { - x2 = start.X; - x1 = end.X; - y2 = start.Y; - y1 = end.Y; - } - double factor = (double)(y2 - y1) / (x2 - x1); - for (int i = x1; i <= x2; i++) - { - list.Add(new Point(i, (int)Math.Round(y1 + factor * (i - x1)))); - } - } - else - { - if (y1 > y2) - { - x2 = start.X; - x1 = end.X; - y2 = start.Y; - y1 = end.Y; - } - double factor = (double)(x2 - x1) / (y2 - y1); - for (int i = y1; i <= y2; i++) - { - list.Add(new Point((int)Math.Round(x1 + factor * (i - y1)), i)); - } - } - return list; - } - - internal Point GetScaledStart(NOcrChar ocrChar, int width, int height) - { - return new Point((int)Math.Round(Start.X * 100.0 / ocrChar.Width * width / 100.0), (int)Math.Round(Start.Y * 100.0 / ocrChar.Height * height / 100.0)); - } - - internal Point GetScaledEnd(NOcrChar ocrChar, int width, int height) - { - return new Point((int)Math.Round(End.X * 100.0 / ocrChar.Width * width / 100.0), (int)Math.Round(End.Y * 100.0 / ocrChar.Height * height / 100.0)); - } - } -} +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; + +namespace Nikse.SubtitleEdit.Logic.Ocr +{ + public class NOcrPoint + { + public Point Start { get; set; } + public Point End { get; set; } + + public NOcrPoint() + { + Start = new Point(); + End = new Point(); + } + + public NOcrPoint(Point start, Point end) + { + Start = new Point(start.X, start.Y); + End = new Point(end.X, end.Y); + } + + public static PointF PointPixelsToPercent(Point p, int pixelWidth, int pixelHeight) + { + return new PointF((float)(p.X * 100.0 / pixelWidth), (float)(p.Y * 100.0 / pixelHeight)); + } + + public static Point PointPercentToPixels(PointF p, int pixelWidth, int pixelHeight) + { + return new Point((int)Math.Round(p.X / 100.0 * pixelWidth), (int)Math.Round(p.Y / 100.0 * pixelHeight)); + } + + public override string ToString() + { + return string.Format(CultureInfo.InvariantCulture, "{0},{1} -> {2},{3} ", Start.X, Start.Y, End.X, End.Y); + } + + public PointF GetStartPercent(int width, int height) + { + return PointPixelsToPercent(Start, width, height); + } + + public PointF GetEnd(int width, int height) + { + return PointPixelsToPercent(End, width, height); + } + + public List<Point> GetPoints() + { + return GetPoints(Start, End); + } + + public List<Point> ScaledGetPoints(NOcrChar nOcrChar, int width, int height) + { + return GetPoints(GetScaledStart(nOcrChar, width, height), GetScaledEnd(nOcrChar, width, height)); + } + + public static List<Point> GetPoints(Point start, Point end) + { + var list = new List<Point>(); + int x1 = start.X; + int x2 = end.X; + int y1 = start.Y; + int y2 = end.Y; + if (Math.Abs(start.X - end.X) > Math.Abs(start.Y - end.Y)) + { + if (x1 > x2) + { + x2 = start.X; + x1 = end.X; + y2 = start.Y; + y1 = end.Y; + } + double factor = (double)(y2 - y1) / (x2 - x1); + for (int i = x1; i <= x2; i++) + { + list.Add(new Point(i, (int)Math.Round(y1 + factor * (i - x1)))); + } + } + else + { + if (y1 > y2) + { + x2 = start.X; + x1 = end.X; + y2 = start.Y; + y1 = end.Y; + } + double factor = (double)(x2 - x1) / (y2 - y1); + for (int i = y1; i <= y2; i++) + { + list.Add(new Point((int)Math.Round(x1 + factor * (i - y1)), i)); + } + } + return list; + } + + internal Point GetScaledStart(NOcrChar ocrChar, int width, int height) + { + return new Point((int)Math.Round(Start.X * 100.0 / ocrChar.Width * width / 100.0), (int)Math.Round(Start.Y * 100.0 / ocrChar.Height * height / 100.0)); + } + + internal Point GetScaledEnd(NOcrChar ocrChar, int width, int height) + { + return new Point((int)Math.Round(End.X * 100.0 / ocrChar.Width * width / 100.0), (int)Math.Round(End.Y * 100.0 / ocrChar.Height * height / 100.0)); + } + } +} diff --git a/src/Logic/Ocr/OcrAlphabet.cs b/src/ui/Logic/Ocr/OcrAlphabet.cs similarity index 96% rename from src/Logic/Ocr/OcrAlphabet.cs rename to src/ui/Logic/Ocr/OcrAlphabet.cs index 63711a0d3..e288fda54 100644 --- a/src/Logic/Ocr/OcrAlphabet.cs +++ b/src/ui/Logic/Ocr/OcrAlphabet.cs @@ -1,51 +1,51 @@ -using System.Collections.Generic; - -namespace Nikse.SubtitleEdit.Logic.Ocr -{ - public class OcrAlphabet - { - public OcrAlphabet() - { - OcrCharacters = new List<OcrCharacter>(); - } - - public List<OcrCharacter> OcrCharacters { get; } - - public int CalculateMaximumSize() - { - int max = 0; - foreach (OcrCharacter c in OcrCharacters) - { - foreach (OcrImage img in c.OcrImages) - { - int size = img.Bmp.Width * img.Bmp.Height; - if (size > max) - { - max = size; - } - } - } - return max; - } - - public OcrCharacter GetOcrCharacter(string text, bool addIfNotExists) - { - foreach (var ocrCharacter in OcrCharacters) - { - if (ocrCharacter.Text == text) - { - return ocrCharacter; - } - } - - if (addIfNotExists) - { - var ch = new OcrCharacter(text); - OcrCharacters.Add(ch); - return ch; - } - return null; - } - - } -} +using System.Collections.Generic; + +namespace Nikse.SubtitleEdit.Logic.Ocr +{ + public class OcrAlphabet + { + public OcrAlphabet() + { + OcrCharacters = new List<OcrCharacter>(); + } + + public List<OcrCharacter> OcrCharacters { get; } + + public int CalculateMaximumSize() + { + int max = 0; + foreach (OcrCharacter c in OcrCharacters) + { + foreach (OcrImage img in c.OcrImages) + { + int size = img.Bmp.Width * img.Bmp.Height; + if (size > max) + { + max = size; + } + } + } + return max; + } + + public OcrCharacter GetOcrCharacter(string text, bool addIfNotExists) + { + foreach (var ocrCharacter in OcrCharacters) + { + if (ocrCharacter.Text == text) + { + return ocrCharacter; + } + } + + if (addIfNotExists) + { + var ch = new OcrCharacter(text); + OcrCharacters.Add(ch); + return ch; + } + return null; + } + + } +} diff --git a/src/Logic/Ocr/OcrCharacter.cs b/src/ui/Logic/Ocr/OcrCharacter.cs similarity index 95% rename from src/Logic/Ocr/OcrCharacter.cs rename to src/ui/Logic/Ocr/OcrCharacter.cs index 4b08d91f1..d51f6bde9 100644 --- a/src/Logic/Ocr/OcrCharacter.cs +++ b/src/ui/Logic/Ocr/OcrCharacter.cs @@ -1,16 +1,16 @@ -using System.Collections.Generic; - -namespace Nikse.SubtitleEdit.Logic.Ocr -{ - public class OcrCharacter - { - public string Text { get; } - public List<OcrImage> OcrImages { get; set; } - - public OcrCharacter(string text) - { - Text = text; - OcrImages = new List<OcrImage>(); - } - } -} +using System.Collections.Generic; + +namespace Nikse.SubtitleEdit.Logic.Ocr +{ + public class OcrCharacter + { + public string Text { get; } + public List<OcrImage> OcrImages { get; set; } + + public OcrCharacter(string text) + { + Text = text; + OcrImages = new List<OcrImage>(); + } + } +} diff --git a/src/Logic/Ocr/OcrFixEngine.cs b/src/ui/Logic/Ocr/OcrFixEngine.cs similarity index 97% rename from src/Logic/Ocr/OcrFixEngine.cs rename to src/ui/Logic/Ocr/OcrFixEngine.cs index 103e1692b..019864de9 100644 --- a/src/Logic/Ocr/OcrFixEngine.cs +++ b/src/ui/Logic/Ocr/OcrFixEngine.cs @@ -1,2098 +1,2098 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.Dictionaries; -using Nikse.SubtitleEdit.Core.Forms.FixCommonErrors; -using Nikse.SubtitleEdit.Core.Interfaces; -using Nikse.SubtitleEdit.Core.SpellCheck; -using Nikse.SubtitleEdit.Forms; -using Nikse.SubtitleEdit.Forms.Ocr; -using Nikse.SubtitleEdit.Logic.SpellCheck; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using System.Xml; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic.Ocr -{ - public class OcrFixEngine : IDisposable, IDoSpell - { - public abstract class LogItem - { - public int Line { get; set; } - public string Text { get; } - - protected LogItem(int line, string text) - { - Line = line; - Text = text.Trim(); - } - - public override string ToString() - { - return $"#{Line}: {Text}"; - } - } - - private class AutoGuess : LogItem - { - public AutoGuess(int index, string word, string guess, string line) - : base(index + 1, string.Format(Configuration.Settings.Language.VobSubOcr.UnknownWordToGuessInLine, word, guess, line.Replace(Environment.NewLine, " "))) - { - } - } - - private class UnknownWord : LogItem - { - public UnknownWord(int index, string word) - : base(index + 1, word) - { - } - } - - public enum AutoGuessLevel - { - None, - Cautious, - Aggressive - } - - private string _userWordListXmlFileName; - private string _fiveLetterWordListLanguageName; - - private readonly OcrFixReplaceList _ocrFixReplaceList; - private NameList _nameListObj; - private HashSet<string> _nameList = new HashSet<string>(); - private HashSet<string> _nameListUppercase = new HashSet<string>(); - private HashSet<string> _nameListWithApostrophe = new HashSet<string>(); - private HashSet<string> _nameMultiWordList = new HashSet<string>(); // case sensitive phrases - private List<string> _nameMultiWordListAndWordsWithPeriods; - private HashSet<string> _abbreviationList; - private HashSet<string> _userWordList = new HashSet<string>(); - private HashSet<string> _wordSkipList = new HashSet<string>(); - private readonly HashSet<string> _wordSpellOkList = new HashSet<string>(); - private Hunspell _hunspell; - private Dictionary<string, string> _changeAllDictionary; - private SpellCheckWordLists _spellCheckWordLists; - private OcrSpellCheck _spellCheck; - private readonly Form _parentForm; - private string _spellCheckDictionaryName; - private readonly string _threeLetterIsoLanguageName; - - private static readonly Regex RegexAloneIasL = new Regex(@"\bl\b", RegexOptions.Compiled); - private static readonly Regex RegexLowercaseL = new Regex("[A-ZÆØÅÄÖÉÈÀÙÂÊÎÔÛËÏ]l[A-ZÆØÅÄÖÉÈÀÙÂÊÎÔÛËÏ]", RegexOptions.Compiled); - private static readonly Regex RegexUppercaseI = new Regex("[a-zæøåöääöéèàùâêîôûëï]I.", RegexOptions.Compiled); - private static readonly Regex RegexNumber1 = new Regex(@"(?<=\d) 1(?!/\d)", RegexOptions.Compiled); - - public bool Abort { get; set; } - public OcrSpellCheck.Action LastAction { get; set; } = OcrSpellCheck.Action.Abort; - public bool IsBinaryImageCompareOrNOcr { get; set; } - public List<LogItem> AutoGuessesUsed { get; set; } - public List<LogItem> UnknownWordsFound { get; set; } - public bool IsDictionaryLoaded { get; private set; } - - private readonly HashSet<char> _expectedChars = new HashSet<char> { ' ', '¡', '¿', ',', '.', '!', '?', ':', ';', '(', ')', '[', ']', '{', '}', '+', '-', '£', '\\', '"', '”', '„', '“', '«', '»', '#', '&', '%', '\r', '\n', '؟' }; // removed $ - private readonly HashSet<char> _expectedCharsNoComma = new HashSet<char> { ' ', '¡', '¿', '.', '!', '?', ':', ';', '(', ')', '[', ']', '{', '}', '+', '-', '£', '\\', '"', '”', '„', '“', '«', '»', '#', '&', '%', '\r', '\n', '؟' }; // removed $ + comma - - /// <summary> - /// Advanced OCR fixing via replace/spelling dictionaries + some hardcoded rules - /// </summary> - /// <param name="threeLetterIsoLanguageName">E.g. eng for English</param> - /// <param name="hunspellName">Name of hunspell dictionary</param> - /// <param name="parentForm">Used for centering/show spell check dialog</param> - /// <param name="isBinaryImageCompare">Calling from OCR via "Image compare"</param> - public OcrFixEngine(string threeLetterIsoLanguageName, string hunspellName, Form parentForm, bool isBinaryImageCompareOrNOcr = false) - { - if (string.IsNullOrEmpty(threeLetterIsoLanguageName)) - { - if (hunspellName != null && hunspellName.Length >= 2) - { - threeLetterIsoLanguageName = Iso639Dash2LanguageCode.GetThreeLetterCodeFromTwoLetterCode(hunspellName.Substring(0, 2)); - } - else - { - threeLetterIsoLanguageName = string.Empty; - } - } - - IsBinaryImageCompareOrNOcr = isBinaryImageCompareOrNOcr; - if (threeLetterIsoLanguageName == "per") - { - threeLetterIsoLanguageName = "fas"; - } - - _threeLetterIsoLanguageName = threeLetterIsoLanguageName; - _parentForm = parentForm; - - if (parentForm.GetType() != typeof(FixCommonErrors)) - { - _spellCheck = new OcrSpellCheck(_parentForm) { StartPosition = FormStartPosition.Manual, IsBinaryImageCompareOrNOcr = isBinaryImageCompareOrNOcr }; - _spellCheck.Location = new Point(parentForm.Left + (parentForm.Width / 2 - _spellCheck.Width / 2), - parentForm.Top + (parentForm.Height / 2 - _spellCheck.Height / 2)); - } - - _ocrFixReplaceList = OcrFixReplaceList.FromLanguageId(threeLetterIsoLanguageName); - if (!string.IsNullOrEmpty(threeLetterIsoLanguageName) || !string.IsNullOrEmpty(hunspellName)) - { - LoadSpellingDictionaries(threeLetterIsoLanguageName, hunspellName); // Hunspell etc. - } - - AutoGuessesUsed = new List<LogItem>(); - UnknownWordsFound = new List<LogItem>(); - } - - private void LoadSpellingDictionaries(string threeLetterIsoLanguageName, string hunspellName) - { - string dictionaryFolder = Utilities.DictionaryFolder; - if (!Directory.Exists(dictionaryFolder)) - { - return; - } - - if (!string.IsNullOrEmpty(hunspellName)) - { - var directDicFile = Path.Combine(dictionaryFolder, hunspellName + ".dic"); - if (File.Exists(directDicFile)) - { - LoadSpellingDictionariesViaDictionaryFileName(threeLetterIsoLanguageName, directDicFile, true); - return; - } - } - - if (!string.IsNullOrEmpty(hunspellName) && threeLetterIsoLanguageName == "eng" && hunspellName.Equals("en_gb", StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(dictionaryFolder, "en_GB.dic"))) - { - LoadSpellingDictionariesViaDictionaryFileName("eng", "en_GB.dic", true); - return; - } - if (!string.IsNullOrEmpty(hunspellName) && threeLetterIsoLanguageName == "eng" && hunspellName.Equals("en-gb", StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(dictionaryFolder, "en-GB.dic"))) - { - LoadSpellingDictionariesViaDictionaryFileName("eng", "en-GB.dic", true); - return; - } - if (!string.IsNullOrEmpty(hunspellName) && threeLetterIsoLanguageName == "eng" && hunspellName.Equals("en_ca", StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(dictionaryFolder, "en_CA.dic"))) - { - LoadSpellingDictionariesViaDictionaryFileName("eng", "en_CA.dic", true); - return; - } - if (!string.IsNullOrEmpty(hunspellName) && threeLetterIsoLanguageName == "eng" && hunspellName.Equals("en_au", StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(dictionaryFolder, "en_AU.dic"))) - { - LoadSpellingDictionariesViaDictionaryFileName("eng", "en_AU.dic", true); - return; - } - if (!string.IsNullOrEmpty(hunspellName) && threeLetterIsoLanguageName == "eng" && hunspellName.Equals("en_za", StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(dictionaryFolder, "en_ZA.dic"))) - { - LoadSpellingDictionariesViaDictionaryFileName("eng", "en_ZA.dic", true); - return; - } - if (threeLetterIsoLanguageName == "eng" && File.Exists(Path.Combine(dictionaryFolder, "en_US.dic"))) - { - LoadSpellingDictionariesViaDictionaryFileName("eng", "en_US.dic", true); - return; - } - - foreach (var culture in Iso639Dash2LanguageCode.List) - { - if (culture.ThreeLetterCode == threeLetterIsoLanguageName) - { - string dictionaryFileName = null; - if (!string.IsNullOrEmpty(hunspellName) && hunspellName.StartsWith(culture.TwoLetterCode, StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(dictionaryFolder, hunspellName + ".dic"))) - { - dictionaryFileName = Path.Combine(dictionaryFolder, hunspellName + ".dic"); - LoadSpellingDictionariesViaDictionaryFileName(threeLetterIsoLanguageName, dictionaryFileName, true); - return; - } - foreach (string dic in Directory.GetFiles(dictionaryFolder, "*.dic")) - { - string name = Path.GetFileNameWithoutExtension(dic); - if (!string.IsNullOrEmpty(name) && !name.StartsWith("hyph", StringComparison.Ordinal)) - { - try - { - name = name.Replace('_', '-'); - if (name.Length > 5) - { - name = name.Substring(0, 5); - } - - var ci = CultureInfo.GetCultureInfo(name); - if (ci.GetThreeLetterIsoLanguageName() == threeLetterIsoLanguageName || - ci.GetThreeLetterIsoLanguageName().Equals(threeLetterIsoLanguageName, StringComparison.OrdinalIgnoreCase)) - { - dictionaryFileName = dic; - break; - } - } - catch (Exception exception) - { - System.Diagnostics.Debug.WriteLine(exception.Message); - } - } - } - - if (dictionaryFileName == null) - { - return; - } - - LoadSpellingDictionariesViaDictionaryFileName(threeLetterIsoLanguageName, dictionaryFileName, true); - return; - } - } - - string dicFileName = null; - foreach (string dic in Directory.GetFiles(dictionaryFolder, "*.dic")) - { - string name = Path.GetFileNameWithoutExtension(dic); - if (!string.IsNullOrEmpty(name) && !name.StartsWith("hyph", StringComparison.Ordinal)) - { - try - { - name = name.Replace('_', '-'); - if (name.Length > 5) - { - name = name.Substring(0, 5); - } - - var ci = CultureInfo.GetCultureInfo(name); - if (ci.GetThreeLetterIsoLanguageName() == threeLetterIsoLanguageName || - ci.GetThreeLetterIsoLanguageName().Equals(threeLetterIsoLanguageName, StringComparison.OrdinalIgnoreCase)) - { - dicFileName = dic; - break; - } - } - catch (Exception exception) - { - System.Diagnostics.Debug.WriteLine(exception.Message); - } - } - } - - if (dicFileName == null) - { - return; - } - - LoadSpellingDictionariesViaDictionaryFileName(threeLetterIsoLanguageName, dicFileName, true); - } - - private void LoadSpellingDictionariesViaDictionaryFileName(string threeLetterIsoLanguageName, string dictionaryFileName, bool resetSkipList) - { - _fiveLetterWordListLanguageName = Path.GetFileNameWithoutExtension(dictionaryFileName); - if (_fiveLetterWordListLanguageName != null && _fiveLetterWordListLanguageName.Length > 5) - { - _fiveLetterWordListLanguageName = _fiveLetterWordListLanguageName.Substring(0, 5); - } - - string dictionary = Utilities.DictionaryFolder + _fiveLetterWordListLanguageName; - if (resetSkipList) - { - _wordSkipList = new HashSet<string> { Configuration.Settings.Tools.MusicSymbol, "*", "%", "#", "+", "$" }; - } - - // Load names etc list (names/noise words) - _nameListObj = new NameList(Configuration.DictionariesDirectory, _fiveLetterWordListLanguageName, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); - _nameList = _nameListObj.GetNames(); - _nameMultiWordList = _nameListObj.GetMultiNames(); - _nameListUppercase = new HashSet<string>(); - _nameListWithApostrophe = new HashSet<string>(); - var nameListWithPeriods = new List<string>(); - _abbreviationList = new HashSet<string>(); - - bool isEnglish = threeLetterIsoLanguageName.Equals("eng", StringComparison.OrdinalIgnoreCase); - foreach (string name in _nameList) - { - _nameListUppercase.Add(name.ToUpperInvariant()); - if (isEnglish) - { - if (!name.EndsWith('s')) - { - _nameListWithApostrophe.Add(name + "'s"); - } - else - { - _nameListWithApostrophe.Add(name + "'"); - } - } - - // Abbreviations. - if (name.EndsWith('.')) - { - _abbreviationList.Add(name); - } - - if (name.Contains(".", StringComparison.Ordinal)) - { - nameListWithPeriods.Add(name); - } - } - - _nameMultiWordListAndWordsWithPeriods = new List<string>(_nameMultiWordList.Concat(nameListWithPeriods)); - if (isEnglish) - { - if (!_abbreviationList.Contains("a.m.")) - { - _abbreviationList.Add("a.m."); - } - - if (!_abbreviationList.Contains("p.m.")) - { - _abbreviationList.Add("p.m."); - } - - if (!_abbreviationList.Contains("o.r.")) - { - _abbreviationList.Add("o.r."); - } - } - - // Load user words - _userWordList = new HashSet<string>(); - _userWordListXmlFileName = Utilities.LoadUserWordList(_userWordList, _fiveLetterWordListLanguageName); - foreach (string name in _userWordList) - { - if (name.EndsWith('.')) - { - _abbreviationList.Add(name); - } - } - - // Load Hunspell spell checker - try - { - if (dictionaryFileName.EndsWith(".dic", StringComparison.OrdinalIgnoreCase) && File.Exists(dictionaryFileName)) - { - dictionary = dictionaryFileName.Substring(0, dictionaryFileName.Length - 4); - } - else if (dictionaryFileName.EndsWith(".dic", StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(Utilities.DictionaryFolder, dictionaryFileName))) - { - var f = Path.Combine(Utilities.DictionaryFolder, dictionaryFileName); - dictionary = f.Substring(0, f.Length - 4); - } - else if (!File.Exists(dictionary + ".dic")) - { - var fileMatches = Directory.GetFiles(Utilities.DictionaryFolder, _fiveLetterWordListLanguageName + "*.dic"); - if (fileMatches.Length > 0) - { - dictionary = fileMatches[0].Substring(0, fileMatches[0].Length - 4); - } - } - _hunspell?.Dispose(); - _hunspell = Hunspell.GetHunspell(dictionary); - IsDictionaryLoaded = true; - _spellCheckDictionaryName = dictionary; - } - catch - { - IsDictionaryLoaded = false; - } - - // load spell check "change all" list - if (_hunspell != null) - { - var languageName = Path.GetFileName(_spellCheckDictionaryName); - if (!string.IsNullOrEmpty(languageName)) - { - _spellCheckWordLists = new SpellCheckWordLists(Utilities.DictionaryFolder, languageName, this); - _changeAllDictionary = _spellCheckWordLists.GetUseAlwaysList(); - } - } - } - - public string SpellCheckDictionaryName - { - get - { - string[] parts = _spellCheckDictionaryName?.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); - if (parts?.Length > 0) - { - return parts[parts.Length - 1]; - } - - return string.Empty; - } - } - - internal static Dictionary<string, string> LoadReplaceList(XmlDocument doc, string name) - { - var list = new Dictionary<string, string>(); - XmlNode node = doc.DocumentElement?.SelectSingleNode(name); - if (node != null) - { - foreach (XmlNode item in node.ChildNodes) - { - if (item.Attributes?["to"] != null && item.Attributes["from"] != null) - { - string to = item.Attributes["to"].InnerText; - string from = item.Attributes["from"].InnerText; - if (!list.ContainsKey(from)) - { - list.Add(from, to); - } - } - } - } - return list; - } - - internal static Dictionary<string, string> LoadRegExList(XmlDocument doc, string name) - { - var list = new Dictionary<string, string>(); - XmlNode node = doc.DocumentElement?.SelectSingleNode(name); - if (node != null) - { - foreach (XmlNode item in node.ChildNodes) - { - if (item.Attributes?["replaceWith"] != null && item.Attributes["find"] != null) - { - string to = item.Attributes["replaceWith"].InnerText; - string from = item.Attributes["find"].InnerText; - if (!list.ContainsKey(from)) - { - list.Add(from, to); - } - } - } - } - return list; - } - - public string FixOcrErrors(string input, int index, string lastLine, bool logSuggestions, AutoGuessLevel autoGuess) - { - var text = input; - while (text.Contains(Environment.NewLine + " ", StringComparison.Ordinal)) - { - text = text.Replace(Environment.NewLine + " ", Environment.NewLine); - } - - while (text.Contains(" " + Environment.NewLine, StringComparison.Ordinal)) - { - text = text.Replace(" " + Environment.NewLine, Environment.NewLine); - } - - while (text.Contains(Environment.NewLine + Environment.NewLine, StringComparison.Ordinal)) - { - text = text.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); - } - - text = text.Trim(); - - // Try to prevent resizing when fixing Ocr-hardcoded. - var sb = new StringBuilder(text.Length + 2); - - if (Configuration.Settings.Tools.OcrFixUseHardcodedRules) - { - if (text.Length > 3 && text.StartsWith(". .") && char.IsLetter(text[3])) - { - text = text.Remove(1, 1).Insert(1, "."); - } - else if (text.Length > 3 && text.StartsWith(".. ") && char.IsLetter(text[3])) - { - text = text.Remove(2, 1).Insert(2, "."); - } - else if (text.Length > 3 && text.StartsWith("..") && char.IsLetter(text[2])) - { - text = "." + text; - } - - text = text.Replace("<i>-</i>", "-"); - text = text.Replace("<i>- </i>", "- "); - text = text.Replace("<i> - </i>", "- "); - text = text.Replace("<i> -</i>", "- "); - text = text.Replace("- ", "- "); - text = text.Replace("<i>a</i>", "a"); - text = text.Replace("<i>.</i>", "."); - text = text.TrimStart(); - - int len = text.Length; - for (int i = 0; i < len; i++) - { - char ch = text[i]; - switch (ch) - { - case 'fi': - sb.Append("fi"); - break; - case 'fl': // fb02 - sb.Append("fl"); - break; - case 'ν': // NOTE: Special unicode character! (Greek character!) - if (_threeLetterIsoLanguageName == "ell" || _threeLetterIsoLanguageName == "gre") - { - sb.Append(ch); // Keep Greek 'ν' - } - else - { - sb.Append('v'); - } - break; - case '‚': // #x201A (SINGLE LOW-9 QUOTATION MARK) to plain old comma - sb.Append(','); - break; - default: - sb.Append(ch); - break; - } - } - text = sb.ToString(); - sb.Clear(); - } - - text = ReplaceWordsBeforeLineFixes(text); - - text = FixCommonOcrLineErrors(text, lastLine); - - // check words split by only space and new line (as other split chars might by a part of from-replace-string, like "\/\/e're" contains slash) - sb = new StringBuilder(); - var word = new StringBuilder(); - string lastWord = null; - for (int i = 0; i < text.Length; i++) - { - if (text[i] != '.' && "\r\n ".Contains(text[i])) - { - if (word.Length > 0) - { - var fixedWord = FixOcrErrorsWord(lastWord, word, sb); - lastWord = fixedWord; - word.Clear(); - } - sb.Append(text[i]); - } - else - { - word.Append(text[i]); - } - } - if (word.Length > 0) // last word - { - FixOcrErrorsWord(lastWord, word, sb); - } - - // check words split by many chars like "()/-" etc. - text = sb.ToString(); - sb = new StringBuilder(); - word = new StringBuilder(); - lastWord = null; - for (int i = 0; i < text.Length; i++) - { - if (text[i] != '.' && _expectedChars.Contains(text[i])) - { - if (word.Length > 0) - { - var fixedWord = FixOcrErrorsWord(lastWord, word, sb); - lastWord = fixedWord; - word.Clear(); - } - sb.Append(text[i]); - } - else - { - word.Append(text[i]); - } - } - if (word.Length > 0) // last word - { - FixOcrErrorsWord(lastWord, word, sb); - } - - text = FixCommonOcrLineErrors(sb.ToString(), lastLine); - if (Configuration.Settings.Tools.OcrFixUseHardcodedRules) - { - text = FixLowercaseIToUppercaseI(text, lastLine); - if (SpellCheckDictionaryName.StartsWith("en_", StringComparison.Ordinal) || _threeLetterIsoLanguageName == "eng") - { - string oldText = text; - text = FixAloneLowercaseIToUppercaseI.FixAloneLowercaseIToUppercaseLine(RegexUtils.LittleIRegex, oldText, text, 'i'); - text = FixAloneLowercaseIToUppercaseI.FixAloneLowercaseIToUppercaseLine(RegexAloneIasL, oldText, text, 'l'); - } - else if (_threeLetterIsoLanguageName == "fra") - { - text = FixFrenchLApostrophe(text, " I'", lastLine); - text = FixFrenchLApostrophe(text, " L'", lastLine); - text = FixFrenchLApostrophe(text, " l'", lastLine); - text = FixFrenchLApostrophe(text, " I’", lastLine); - text = FixFrenchLApostrophe(text, " L’", lastLine); - text = FixFrenchLApostrophe(text, " l’", lastLine); - } - - text = Utilities.RemoveSpaceBetweenNumbers(text); - } - - // must be last - counts/logs unknown words - text = FixUnknownWordsViaGuessOrPrompt(out _, text, index, null, true, false, logSuggestions, autoGuess); - - return text; - } - - private string FixOcrErrorsWord(string lastWord, StringBuilder word, StringBuilder sb) - { - string fixedWord; - if (lastWord != null && lastWord.Contains("COLOR=", StringComparison.OrdinalIgnoreCase)) - { - fixedWord = word.ToString(); - } - else - { - var doFixWord = !(word.Length == 1 && sb.Length > 1 && sb.EndsWith('-')); - if (doFixWord) - { - fixedWord = word.ToString(); - - var post = string.Empty; - if (fixedWord.EndsWith('.') && fixedWord.IndexOf('.') == fixedWord.Length - 1) - { - post = "."; - fixedWord = fixedWord.Substring(0, fixedWord.Length - 1); - } - else if (fixedWord.EndsWith("...", StringComparison.Ordinal)) - { - post = "..."; - fixedWord = fixedWord.Substring(0, fixedWord.Length - 3); - } - - fixedWord = FixWordViaReplaceList(fixedWord); - fixedWord = _ocrFixReplaceList.FixCommonWordErrors(fixedWord); - - // Try using word lists for uppercase i inside words, e.g. "NIkolaj" to "Nikolaj" - if (fixedWord.Contains('I')) - { - var temp = fixedWord.Replace('I', 'i'); - if (temp != fixedWord.ToUpperInvariant()) - { - if (_nameList.Contains(temp)) - { - fixedWord = temp; - } - } - } - fixedWord += post; - } - else - { - fixedWord = word.ToString(); - } - } - - sb.Append(fixedWord); - return fixedWord; - } - - private string FixWordViaReplaceList(string word) - { - if (_changeAllDictionary != null && _changeAllDictionary.ContainsKey(word)) - { - return _changeAllDictionary[word]; - } - return word; - } - - internal static string FixFrenchLApostrophe(string input, string tag, string lastLine) - { - var text = input; - bool endingBeforeThis = string.IsNullOrEmpty(lastLine) || lastLine.EndsWith('.') || lastLine.EndsWith('!') || lastLine.EndsWith('?') || - lastLine.EndsWith(".</i>", StringComparison.Ordinal) || lastLine.EndsWith("!</i>", StringComparison.Ordinal) || lastLine.EndsWith("?</i>", StringComparison.Ordinal) || - lastLine.EndsWith(".</font>", StringComparison.Ordinal) || lastLine.EndsWith("!</font>", StringComparison.Ordinal) || lastLine.EndsWith("?</font>", StringComparison.Ordinal); - if (text.StartsWith(tag.TrimStart(), StringComparison.Ordinal) && text.Length > 3) - { - if (endingBeforeThis || char.IsUpper(text[2])) - { - text = @"L" + text.Substring(1); - } - else if (char.IsLower(text[2])) - { - text = @"l" + text.Substring(1); - } - } - else if (text.StartsWith("<i>" + tag.TrimStart(), StringComparison.Ordinal) && text.Length > 6) - { - if (endingBeforeThis || char.IsUpper(text[5])) - { - text = text.Remove(3, 1).Insert(3, "L"); - } - else if (char.IsLower(text[5])) - { - text = text.Remove(3, 1).Insert(3, "l"); - } - } - - int start = text.IndexOf(tag, StringComparison.Ordinal); - while (start > 0) - { - lastLine = HtmlUtil.RemoveHtmlTags(text.Substring(0, start)).TrimEnd().TrimEnd('-').TrimEnd(); - endingBeforeThis = string.IsNullOrEmpty(lastLine) || lastLine.EndsWith('.') || lastLine.EndsWith('!') || lastLine.EndsWith('?'); - if (start < text.Length - 4) - { - if (start == 1 && text.StartsWith('-')) - { - endingBeforeThis = true; - } - - if (start > 1) - { - string beforeThis = HtmlUtil.RemoveHtmlTags(text.Substring(0, start)); - endingBeforeThis = beforeThis.EndsWith('.') || beforeThis.EndsWith('!') || beforeThis.EndsWith('?'); - } - - if (endingBeforeThis) - { - text = text.Remove(start + 1, 1).Insert(start + 1, "L"); - } - else - { - text = text.Remove(start + 1, 1).Insert(start + 1, "l"); - } - } - start = text.IndexOf(tag, start + 1, StringComparison.Ordinal); - } - - tag = Environment.NewLine + tag.Trim(); - start = text.IndexOf(tag, StringComparison.Ordinal); - while (start > 0) - { - lastLine = HtmlUtil.RemoveHtmlTags(text.Substring(0, start)).TrimEnd().TrimEnd('-').TrimEnd(); - endingBeforeThis = string.IsNullOrEmpty(lastLine) || lastLine.EndsWith('.') || lastLine.EndsWith('!') || lastLine.EndsWith('?') || lastLine.EndsWith(".</i>", StringComparison.Ordinal); - if (start < text.Length - 5) - { - if (start > 1) - { - string beforeThis = HtmlUtil.RemoveHtmlTags(text.Substring(0, start)); - endingBeforeThis = beforeThis.EndsWith('.') || beforeThis.EndsWith('!') || beforeThis.EndsWith('?'); - } - - if (endingBeforeThis) - { - text = text.Remove(start + Environment.NewLine.Length, 1).Insert(start + Environment.NewLine.Length, "L"); - } - else - { - text = text.Remove(start + Environment.NewLine.Length, 1).Insert(start + Environment.NewLine.Length, "l"); - } - } - start = text.IndexOf(tag, start + 1, StringComparison.Ordinal); - } - - tag = Environment.NewLine + "<i>" + tag.Trim(); - start = text.IndexOf(tag, StringComparison.Ordinal); - while (start > 0) - { - lastLine = HtmlUtil.RemoveHtmlTags(text.Substring(0, start)).TrimEnd().TrimEnd('-').TrimEnd(); - endingBeforeThis = string.IsNullOrEmpty(lastLine) || lastLine.EndsWith('.') || lastLine.EndsWith('!') || lastLine.EndsWith('?') || lastLine.EndsWith(".</i>", StringComparison.Ordinal); - if (start < text.Length - 8) - { - if (endingBeforeThis || char.IsUpper(text[start + 5 + Environment.NewLine.Length])) - { - text = text.Remove(start + Environment.NewLine.Length + 3, 1).Insert(start + Environment.NewLine.Length + 3, "L"); - } - else if (char.IsLower(text[start + 5 + Environment.NewLine.Length])) - { - text = text.Remove(start + Environment.NewLine.Length + 3, 1).Insert(start + Environment.NewLine.Length + 3, "l"); - } - } - start = text.IndexOf(tag, start + 1, StringComparison.Ordinal); - } - return text; - } - - private string ReplaceWordsBeforeLineFixes(string text) - { - string lastWord = null; - var sb = new StringBuilder(); - var word = new StringBuilder(); - for (int i = 0; i < text.Length; i++) - { - if (_expectedCharsNoComma.Contains(text[i])) // fix e.g. "don,t" - { - if (word.Length > 0) - { - string fixedWord; - if (lastWord != null && lastWord.Contains("COLOR=", StringComparison.OrdinalIgnoreCase)) - { - fixedWord = word.ToString(); - } - else if (!word.ToString().Contains(',')) - { - fixedWord = word.ToString(); - } - else - { - fixedWord = _ocrFixReplaceList.FixCommonWordErrorsQuick(word.ToString()); - } - - sb.Append(fixedWord); - lastWord = fixedWord; - word.Clear(); - } - sb.Append(text[i]); - } - else - { - word.Append(text[i]); - } - } - if (word.Length > 0) // last word - { - string fixedWord; - if (lastWord != null && lastWord.Contains("COLOR=", StringComparison.OrdinalIgnoreCase)) - { - fixedWord = word.ToString(); - } - else if (!word.ToString().Contains(',')) - { - fixedWord = word.ToString(); - } - else - { - fixedWord = _ocrFixReplaceList.FixCommonWordErrorsQuick(word.ToString()); - } - - sb.Append(fixedWord); - } - - lastWord = null; - text = sb.ToString(); - sb = new StringBuilder(); - word = new StringBuilder(); - for (int i = 0; i < text.Length; i++) - { - if (_expectedChars.Contains(text[i])) // removed $ - { - if (word.Length > 0) - { - string fixedWord; - if (lastWord != null && lastWord.Contains("COLOR=", StringComparison.OrdinalIgnoreCase)) - { - fixedWord = word.ToString(); - } - else - { - fixedWord = _ocrFixReplaceList.FixCommonWordErrorsQuick(word.ToString()); - } - - sb.Append(fixedWord); - lastWord = fixedWord; - word.Clear(); - } - sb.Append(text[i]); - } - else - { - word.Append(text[i]); - } - } - if (word.Length > 0) // last word - { - string fixedWord = _ocrFixReplaceList.FixCommonWordErrorsQuick(word.ToString()); - sb.Append(fixedWord); - } - return sb.ToString(); - } - - private string FixCommonOcrLineErrors(string input, string lastLine) - { - var text = input; - text = FixOcrErrorViaLineReplaceList(text); - text = FixOcrErrorsViaHardcodedRules(text, lastLine, _abbreviationList); - text = FixOcrErrorViaLineReplaceList(text); - - if (Configuration.Settings.Tools.OcrFixUseHardcodedRules) - { - if (text.StartsWith('~')) - { - text = ("- " + text.Remove(0, 1)).Replace(" ", " "); - } - - text = text.Replace(Environment.NewLine + "~", Environment.NewLine + "- ").Replace(" ", " "); - - if (text.Length < 10 && text.Length > 4 && !text.Contains(Environment.NewLine, StringComparison.Ordinal) && text.StartsWith("II", StringComparison.Ordinal) && text.EndsWith("II", StringComparison.Ordinal)) - { - text = "\"" + text.Substring(2, text.Length - 4) + "\""; - } - - // e.g. "selectionsu." -> "selections..." - if (text.EndsWith("u.", StringComparison.Ordinal) && _hunspell != null) - { - string[] words = text.Split(new[] { ' ', '.' }, StringSplitOptions.RemoveEmptyEntries); - if (words.Length > 0) - { - string lastWord = words[words.Length - 1].Trim(); - if (lastWord.Length > 2 && - char.IsLower(lastWord[0]) && - !IsWordOrWordsCorrect(lastWord) && - IsWordOrWordsCorrect(lastWord.Substring(0, lastWord.Length - 1))) - { - text = text.Substring(0, text.Length - 2) + "..."; - } - } - } - - // music notes - if (text.StartsWith(".'", StringComparison.Ordinal) && text.EndsWith(".'", StringComparison.Ordinal)) - { - text = text.Replace(".'", Configuration.Settings.Tools.MusicSymbol); - } - } - - return text; - } - - private string FixLowercaseIToUppercaseI(string input, string lastLine) - { - var sb = new StringBuilder(); - var lines = input.SplitToLines(); - for (int i = 0; i < lines.Count; i++) - { - string l = lines[i]; - - if (i > 0) - { - lastLine = lines[i - 1]; - } - - lastLine = HtmlUtil.RemoveHtmlTags(lastLine); - - if (string.IsNullOrEmpty(lastLine) || - lastLine.EndsWith('.') || - lastLine.EndsWith('!') || - lastLine.EndsWith('?')) - { - var st = new StrippableText(l); - if (st.StrippedText.StartsWith('i') && !st.Pre.EndsWith('[') && !st.Pre.EndsWith('(') && !st.Pre.EndsWith("...", StringComparison.Ordinal)) - { - if (string.IsNullOrEmpty(lastLine) || (!lastLine.EndsWith("...", StringComparison.Ordinal) && !EndsWithAbbreviation(lastLine, _abbreviationList))) - { - l = st.Pre + "I" + st.StrippedText.Remove(0, 1) + st.Post; - } - } - } - sb.AppendLine(l); - } - return sb.ToString().TrimEnd('\r', '\n'); - } - - private static bool EndsWithAbbreviation(string line, HashSet<string> abbreviationList) - { - if (string.IsNullOrEmpty(line)) - { - return false; - } - if (line.Length > 5 && line[line.Length - 3] == '.' && char.IsLetter(line[line.Length - 2])) - { - return true; - } - if (abbreviationList != null) - { - foreach (string abbreviation in abbreviationList) - { - if (line.EndsWith(" " + abbreviation, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - } - } - return false; - } - - public string FixOcrErrorsViaHardcodedRules(string input, string lastLine, HashSet<string> abbreviationList) - { - var text = input; - if (!Configuration.Settings.Tools.OcrFixUseHardcodedRules) - { - return text; - } - - text = text.Replace(",...", "..."); - - if (text.StartsWith("..", StringComparison.Ordinal) && !text.StartsWith("...", StringComparison.Ordinal)) - { - text = "." + text; - } - - string pre = string.Empty; - if (text.StartsWith("- ", StringComparison.Ordinal)) - { - pre = "- "; - text = text.Remove(0, 2); - } - else if (text.StartsWith('-')) - { - pre = "-"; - text = text.Remove(0, 1); - } - - bool hasDotDot = text.Contains("..", StringComparison.Ordinal) || text.Contains(". .", StringComparison.Ordinal); - if (hasDotDot) - { - if (text.Length > 5 && text.StartsWith("..", StringComparison.Ordinal) && Utilities.AllLettersAndNumbers.Contains(text[2])) - { - text = "..." + text.Remove(0, 2); - } - - if (text.Length > 7 && text.StartsWith("<i>..", StringComparison.Ordinal) && Utilities.AllLettersAndNumbers.Contains(text[5])) - { - text = "<i>..." + text.Remove(0, 5); - } - - if (text.Length > 5 && text.StartsWith(".. ", StringComparison.Ordinal) && Utilities.AllLettersAndNumbers.Contains(text[3])) - { - text = "..." + text.Remove(0, 3); - } - - if (text.Length > 7 && text.StartsWith("<i>.. ", StringComparison.Ordinal) && Utilities.AllLettersAndNumbers.Contains(text[6])) - { - text = "<i>..." + text.Remove(0, 6); - } - - if (text.Contains(Environment.NewLine + ".. ", StringComparison.Ordinal)) - { - text = text.Replace(Environment.NewLine + ".. ", Environment.NewLine + "..."); - } - - if (text.Contains(Environment.NewLine + "<i>.. ", StringComparison.Ordinal)) - { - text = text.Replace(Environment.NewLine + "<i>.. ", Environment.NewLine + "<i>..."); - } - - if (text.StartsWith(". ..", StringComparison.Ordinal)) - { - text = "..." + text.Remove(0, 4); - } - - if (text.StartsWith(".. .", StringComparison.Ordinal)) - { - text = "..." + text.Remove(0, 4); - } - - if (text.StartsWith(". . .", StringComparison.Ordinal)) - { - text = "..." + text.Remove(0, 5); - } - - if (text.StartsWith("... ", StringComparison.Ordinal)) - { - text = text.Remove(3, 1); - } - } - - text = pre + text; - - if (hasDotDot) - { - if (text.StartsWith("<i>. ..", StringComparison.Ordinal)) - { - text = "<i>..." + text.Remove(0, 7); - } - - if (text.StartsWith("<i>.. .", StringComparison.Ordinal)) - { - text = "<i>..." + text.Remove(0, 7); - } - - if (text.StartsWith("<i>. . .", StringComparison.Ordinal)) - { - text = "<i>..." + text.Remove(0, 8); - } - - if (text.StartsWith("<i>... ", StringComparison.Ordinal)) - { - text = text.Remove(6, 1); - } - - if (text.StartsWith(". . <i>.", StringComparison.Ordinal)) - { - text = "<i>..." + text.Remove(0, 8); - } - - if (text.StartsWith("...<i>", StringComparison.Ordinal) && (text.IndexOf("</i>", StringComparison.Ordinal) > text.IndexOf(' '))) - { - text = "<i>..." + text.Remove(0, 6); - } - - if (text.EndsWith(". ..", StringComparison.Ordinal)) - { - text = text.Remove(text.Length - 4, 4) + "..."; - } - - if (text.EndsWith(".. .", StringComparison.Ordinal)) - { - text = text.Remove(text.Length - 4, 4) + "..."; - } - - if (text.EndsWith(". . .", StringComparison.Ordinal)) - { - text = text.Remove(text.Length - 5, 5) + "..."; - } - - if (text.EndsWith(". ...", StringComparison.Ordinal)) - { - text = text.Remove(text.Length - 5, 5) + "..."; - } - - if (text.EndsWith(". ..</i>", StringComparison.Ordinal)) - { - text = text.Remove(text.Length - 8, 8) + "...</i>"; - } - - if (text.EndsWith(".. .</i>", StringComparison.Ordinal)) - { - text = text.Remove(text.Length - 8, 8) + "...</i>"; - } - - if (text.EndsWith(". . .</i>", StringComparison.Ordinal)) - { - text = text.Remove(text.Length - 9, 9) + "...</i>"; - } - - if (text.EndsWith(". ...</i>", StringComparison.Ordinal)) - { - text = text.Remove(text.Length - 9, 9) + "...</i>"; - } - - if (text.EndsWith(".</i> . .", StringComparison.Ordinal)) - { - text = text.Remove(text.Length - 9, 9) + "...</i>"; - } - - if (text.EndsWith(".</i>..", StringComparison.Ordinal)) - { - text = text.Remove(text.Length - 7, 7) + "...</i>"; - } - - text = text.Replace(".</i> . ." + Environment.NewLine, "...</i>" + Environment.NewLine); - - text = text.Replace(".. ?", "..?"); - text = text.Replace("..?", "...?"); - text = text.Replace("....?", "...?"); - - text = text.Replace(".. !", "..!"); - text = text.Replace("..!", "...!"); - text = text.Replace("....!", "...!"); - - text = text.Replace("... ?", "...?"); - text = text.Replace("... !", "...!"); - - text = text.Replace("....", "..."); - text = text.Replace("....", "..."); - - if (text.StartsWith("- ...", StringComparison.Ordinal) && lastLine != null && lastLine.EndsWith("...", StringComparison.Ordinal) && !text.Contains(Environment.NewLine + "-", StringComparison.Ordinal)) - { - text = text.Remove(0, 2); - } - - if (text.StartsWith("-...", StringComparison.Ordinal) && lastLine != null && lastLine.EndsWith("...", StringComparison.Ordinal) && !text.Contains(Environment.NewLine + "-", StringComparison.Ordinal)) - { - text = text.Remove(0, 1); - } - } - - var lastLineNoTags = lastLine; - if (!string.IsNullOrEmpty(lastLineNoTags)) - { - lastLineNoTags = HtmlUtil.RemoveHtmlTags(lastLineNoTags); - lastLineNoTags = lastLineNoTags.Trim('♪', '♫', ' ', '"'); - if (lastLine.EndsWith(']') && lastLineNoTags.IndexOf('[') > 0 && - Utilities.CountTagInText(lastLineNoTags, '[') == 1 && Utilities.CountTagInText(lastLineNoTags, ']') == 1) - { - lastLineNoTags = lastLineNoTags.Substring(0, lastLineNoTags.IndexOf('[')).Trim(); - } - } - - if (string.IsNullOrEmpty(lastLine) || lastLineNoTags.HasSentenceEnding(Iso639Dash2LanguageCode.GetTwoLetterCodeFromThreeLetterCode(_threeLetterIsoLanguageName))) - { - lastLine = HtmlUtil.RemoveHtmlTags(lastLine); - var st = new StrippableText(text); - if (lastLine == null || !lastLine.EndsWith("...", StringComparison.Ordinal) && !EndsWithAbbreviation(lastLine, abbreviationList)) - { - if (st.StrippedText.Length > 0 && !char.IsUpper(st.StrippedText[0]) && !st.Pre.EndsWith('[') && !st.Pre.EndsWith('(') && - !st.Pre.Contains("...", StringComparison.Ordinal) && - !st.Pre.Contains('…')) - { - if (!HtmlUtil.StartsWithUrl(st.StrippedText)) - { - var uppercaseLetter = char.ToUpper(st.StrippedText[0]); - if (st.StrippedText.Length > 1 && uppercaseLetter == 'L' && (st.StrippedText[1] == ' ' || char.IsLower(st.StrippedText[1]))) - { - uppercaseLetter = 'I'; - } - if (st.StrippedText.Length == 1 && uppercaseLetter == 'L') - { - uppercaseLetter = 'I'; - } - - if ((st.StrippedText.StartsWith("lo ", StringComparison.Ordinal) || st.StrippedText.Equals("lo.", StringComparison.Ordinal)) && _threeLetterIsoLanguageName.Equals("ita", StringComparison.Ordinal)) - { - uppercaseLetter = 'I'; - } - - if ((st.StrippedText.StartsWith("k ", StringComparison.Ordinal) || st.StrippedText.StartsWith("m ", StringComparison.Ordinal) || st.StrippedText.StartsWith("n ", StringComparison.Ordinal) || st.StrippedText.StartsWith("r ", StringComparison.Ordinal) || st.StrippedText.StartsWith("s ", StringComparison.Ordinal) || st.StrippedText.StartsWith("t ", StringComparison.Ordinal)) && - st.Pre.EndsWith('\'') && _threeLetterIsoLanguageName.Equals("nld", StringComparison.Ordinal)) - { - uppercaseLetter = st.StrippedText[0]; - } - - if ((st.StrippedText.StartsWith("l-I'll ", StringComparison.Ordinal) || st.StrippedText.StartsWith("l-l'll ", StringComparison.Ordinal)) && _threeLetterIsoLanguageName.Equals("eng", StringComparison.Ordinal)) - { - uppercaseLetter = 'I'; - st.StrippedText = "I-I" + st.StrippedText.Remove(0, 3); - } - - st.StrippedText = uppercaseLetter + st.StrippedText.Substring(1); - text = st.Pre + st.StrippedText + st.Post; - } - } - } - } - - // lines ending with ". should often end at ... (of no other quotes exists near by) - if ((lastLine == null || !lastLine.Contains('"')) && - text.EndsWith("\".", StringComparison.Ordinal) && text.IndexOf('"') == text.LastIndexOf('"') && text.Length > 3) - { - var lastChar = text[text.Length - 3]; - if (!char.IsDigit(lastChar)) - { - int position = text.Length - 2; - text = text.Remove(position).Insert(position, "..."); - } - } - - // change '<number><space>1' to '<number>1' - if (text.Contains('1')) - { - var match = RegexNumber1.Match(text); - while (match.Success) - { - text = text.Remove(match.Index, 1); - match = RegexNumber1.Match(text, match.Index); - } - } - - // change '' to " - text = text.Replace("''", "\""); - - // change 'sequeI of' to 'sequel of' - if (text.Contains('I')) - { - var match = RegexUppercaseI.Match(text); - while (match.Success) - { - bool doFix = !(match.Index >= 1 && text.Substring(match.Index - 1).StartsWith("Mc", StringComparison.Ordinal)); - if (match.Index >= 2 && text.Substring(match.Index - 2).StartsWith("Mac", StringComparison.Ordinal)) - { - doFix = false; - } - - if (doFix) - { - text = text.Substring(0, match.Index + 1) + "l" + text.Substring(match.Index + 2); - } - - if (match.Index + 1 < text.Length) - { - match = RegexUppercaseI.Match(text, match.Index + 1); - } - else - { - break; // end while - } - } - } - - // change 'NlCE' to 'NICE' - if (text.Contains('l')) - { - var match = RegexLowercaseL.Match(text); - while (match.Success) - { - text = text.Substring(0, match.Index + 1) + "I" + text.Substring(match.Index + 2); - match = RegexLowercaseL.Match(text); - } - } - - if (text.EndsWith(". \"</i>", StringComparison.Ordinal)) - { - text = text.Remove(text.Length - 6, 1); - } - - if (text.Contains(". \"</i>" + Environment.NewLine, StringComparison.Ordinal)) - { - var idx = text.IndexOf(". \"</i>" + Environment.NewLine, StringComparison.Ordinal); - if (idx > 0) - { - text = text.Remove(idx + 1, 1); - } - } - - return text; - } - - public string FixOcrErrorViaLineReplaceList(string input) - { - return _ocrFixReplaceList.FixOcrErrorViaLineReplaceList(input); - } - - public string FixUnknownWordsViaGuessOrPrompt(out int wordsNotFound, string line, int index, Bitmap bitmap, bool autoFix, bool promptForFixingErrors, bool log, AutoGuessLevel autoGuess) - { - var localIgnoreWords = new List<string>(); - wordsNotFound = 0; - - if (promptForFixingErrors && line.Length == 1 && !IsWordKnownOrNumber(line, line)) - { - SpellCheckOcrTextResult res = SpellCheckOcrText(line, bitmap, line, localIgnoreWords); - if (res.FixedWholeLine || res.Fixed) - { - return res.Line; - } - - wordsNotFound++; - return line; - } - - if (_hunspell == null) - { - return line; - } - - string tempLine = line; - const string p = " ¡¿,.!?:;()[]{}+-$£\"„”“#&%…—♪\r\n"; - var trimChars = p.ToArray(); - bool hasAllUpperWord = false; - foreach (var w in HtmlUtil.RemoveHtmlTags(line, true).Split(' ', '\r', '\n')) - { - var word = w.Trim(trimChars); - if (word.Length > 1 && word == word.ToUpperInvariant()) - { - hasAllUpperWord = true; - break; - } - } - - foreach (string name in _nameMultiWordListAndWordsWithPeriods) - { - int start = tempLine.FastIndexOf(name); - if (start < 0 && hasAllUpperWord) - { - start = tempLine.FastIndexOf(name.ToUpperInvariant()); - } - if (start == 0 || (start > 0 && p.Contains(tempLine[start - 1]))) - { - int end = start + name.Length; - if (end == tempLine.Length || p.Contains(tempLine[end])) - { - tempLine = tempLine.Remove(start, name.Length); - } - } - } - - int minLength = 2; - if (Configuration.Settings.Tools.CheckOneLetterWords) - { - minLength = 1; - } - - var words = new List<string>(); - var splitChars = SpellCheckWordLists.SplitChars.Where(ch => ch != '/' && ch != '|').ToArray(); - foreach (var w in tempLine - .Replace("<i>", string.Empty).Replace("</i>", string.Empty) - .Replace("<b>", string.Empty).Replace("</b>", string.Empty) - .Replace("<u>", string.Empty).Replace("</u>", string.Empty) - .Split(splitChars)) - { - words.Add(w.Trim(trimChars)); - } - - for (int i = 0; i < words.Count && i < 1000; i++) - { - string word = words[i].TrimStart('\''); - string wordNotEndTrimmed = word; - word = word.TrimEnd('\''); - if (!IsWordKnownOrNumber(word, line) && !localIgnoreWords.Contains(word)) - { - var correct = false; - if (word.Length > 1) - { - if (_wordSpellOkList.Contains(word)) - { - correct = true; - } - else if (DoSpell(word)) - { - correct = true; - _wordSpellOkList.Add(word); - } - - if (!correct) - { - correct = word.Length > minLength + 1 && DoSpell(word.Trim('\'')); - } - - if (!correct && word.Length > 3 && !word.EndsWith("ss", StringComparison.Ordinal) && !string.IsNullOrEmpty(_threeLetterIsoLanguageName) && - (_threeLetterIsoLanguageName == "eng" || _threeLetterIsoLanguageName == "dan" || _threeLetterIsoLanguageName == "swe" || _threeLetterIsoLanguageName == "nld")) - { - correct = DoSpell(word.TrimEnd('s')); - } - } - else - { - correct = !Configuration.Settings.Tools.CheckOneLetterWords; // hunspell allows too many single letter words - } - - if (!correct && _userWordList.Contains(word)) - { - correct = true; - } - - if (!correct && !line.Contains(word, StringComparison.Ordinal)) - { - correct = true; // already fixed - } - - if (!correct && Configuration.Settings.Tools.SpellCheckEnglishAllowInQuoteAsIng && wordNotEndTrimmed.EndsWith('\'') && - SpellCheckDictionaryName.StartsWith("en_", StringComparison.Ordinal) && word.EndsWith("in", StringComparison.OrdinalIgnoreCase)) - { - correct = DoSpell(word + "g"); - } - - if (_threeLetterIsoLanguageName == "eng" && (word.Equals("a", StringComparison.OrdinalIgnoreCase) || word == "I")) - { - correct = true; - } - else if (_threeLetterIsoLanguageName == "dan" && word.Equals("i", StringComparison.OrdinalIgnoreCase)) - { - correct = true; - } - - if (!correct && _threeLetterIsoLanguageName.Equals("ara", StringComparison.Ordinal)) - { - var trimmed = word.Trim('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', ',', '،', '؟', '»'); - if (trimmed != word) - { - if (_userWordList.Contains(trimmed)) - { - correct = true; - } - else - { - correct = DoSpell(trimmed); - } - } - } - - if (!correct) - { - //look for match via dash'ed word, e.g. sci-fi - string dashedWord = GetDashedWordBefore(word, line, words, i); - if (!string.IsNullOrEmpty(dashedWord)) - { - correct = IsWordKnownOrNumber(dashedWord, line); - if (!correct) - { - correct = DoSpell(dashedWord); - } - } - if (!correct) - { - dashedWord = GetDashedWordAfter(word, line, words, i); - if (!string.IsNullOrEmpty(dashedWord)) - { - correct = IsWordKnownOrNumber(dashedWord, line); - if (!correct) - { - correct = DoSpell(dashedWord); - } - } - } - - if (!correct && _spellCheckWordLists.HasUserWord("-" + word)) - { - correct = true; - } - } - - if (!correct && word.Contains('/') && !word.Contains("//", StringComparison.Ordinal)) - { - correct = word.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries) - .All(w => w.Length > 2 && (DoSpell(w) || IsWordKnownOrNumber(word, line))); - } - - if (!correct && word.Length == 1 && i < words.Count - 1 && words[i + 1].Length == 1) - { - var abbreviation = word + "." + words[i + 1] + "."; - if (_abbreviationList.Contains(abbreviation) && line.Contains(abbreviation, StringComparison.Ordinal)) - { - correct = true; - words[i + 1] = string.Empty; - } - else if (i < words.Count - 2 && words[i + 2].Length == 1) - { - abbreviation = word + "." + words[i + 1] + "." + words[i + 2] + "."; - if (_abbreviationList.Contains(abbreviation) && line.Contains(abbreviation, StringComparison.Ordinal)) - { - correct = true; - words[i + 1] = string.Empty; - words[i + 2] = string.Empty; - } - } - } - - if (word.Length == 0) - { - correct = true; - } - - if (!correct) - { - wordsNotFound++; - if (log) - { - string nf = word; - if (nf.StartsWith("<i>", StringComparison.Ordinal)) - { - nf = nf.Remove(0, 3); - } - - if (nf.Trim().Length > 0) - { - UnknownWordsFound.Add(new UnknownWord(index, nf)); - } - } - - if (autoFix && autoGuess != AutoGuessLevel.None) - { - var guesses = new List<string>(); - - // Name starting with "l" instead of 'I' - if (word.StartsWith('l') && word.Length > 3 && !_nameList.Contains(word)) - { - var w = "I" + word.Substring(1); - if (_nameList.Contains(w)) - { - guesses.Add(w); - } - } - - if (!correct && autoFix && word.Length > 3 && char.IsUpper(word[0]) && !_nameList.Contains(word)) - { - var rest = word.Substring(1); - if (rest != rest.ToUpperInvariant()) - { - var newWord = word[0] + rest.ToLowerInvariant(); - if (_nameList.Contains(newWord)) - { - guesses.Add(newWord); - } - } - } - - var wordWithVerticalLine = word.Replace("|", "l"); - if (word.Length > 3 && DoSpell(wordWithVerticalLine)) - { - if (word == word.ToUpperInvariant()) - { - wordWithVerticalLine = wordWithVerticalLine.ToUpperInvariant(); - } - - guesses.Add(wordWithVerticalLine); - } - - if (word.Length > 4 && autoGuess == AutoGuessLevel.Aggressive) - { - guesses.AddRange((List<string>)_ocrFixReplaceList.CreateGuessesFromLetters(word)); - - if (word[0] == 'L') - { - guesses.Add("I" + word.Substring(1)); - } - - if (word.Contains('$')) - { - guesses.Add(word.Replace("$", "s")); - } - - if (word.Contains('l') && word.RemoveChar('l').Length > 3) - { - var lowerLToUpperI = word.Replace('l', 'I'); - if (lowerLToUpperI == lowerLToUpperI.ToUpperInvariant()) - { - guesses.Add(lowerLToUpperI); - } - } - - string wordWithCasingChanged = GetWordWithDominatedCasing(word); - if (DoSpell(word.ToLowerInvariant())) - { - guesses.Insert(0, wordWithCasingChanged); - } - } - else if (Configuration.Settings.Tools.OcrFixUseHardcodedRules) - { - if (word.Length > 2 && word[0] == 'L') - { - guesses.Add("I" + word.Substring(1)); - } - - if (word.Length > 2 && word[0] == 'I' && char.IsLower(word[1])) - { - guesses.Add("l" + word.Substring(1)); - } - - if (i == 0) - { - guesses.Add(word.Replace(@"\/", "V")); - } - else - { - guesses.Add(word.Replace(@"\/", "v")); - } - - guesses.Add(word.Replace("fi", "fi")); - guesses.Add(word.Replace("fi", "fj")); - guesses.Add(word.Replace("fl", "fl")); - if (word.Contains('$')) - { - guesses.Add(word.Replace("$", "s")); - } - - if (!word.EndsWith('€') && !word.StartsWith('€')) - { - guesses.Add(word.Replace("€", "e")); - } - - guesses.Add(word.Replace("/", "l")); - guesses.Add(word.Replace(")/", "y")); - } - foreach (string guess in guesses) - { - if (!(guess.Length == 2 && guess[1] == ' ') && IsWordOrWordsCorrect(guess)) - { - string replacedLine = OcrFixReplaceList.ReplaceWord(line, word, guess); - if (replacedLine != line) - { - if (log) - { - AutoGuessesUsed.Add(new AutoGuess(index, word, guess, line)); - } - - line = replacedLine; - wordsNotFound--; - if (log && UnknownWordsFound.Count > 0) - { - UnknownWordsFound.RemoveAt(UnknownWordsFound.Count - 1); - } - - correct = true; - break; - } - } - } - } - if (!correct && promptForFixingErrors) - { - var suggestions = new List<string>(); - - if ((word == "Lt's" || word == "Lt'S") && SpellCheckDictionaryName.StartsWith("en_", StringComparison.Ordinal)) - { - suggestions.Add("It's"); - } - else - { - if (word.ToUpperInvariant() != "LT'S" && word.ToUpperInvariant() != "SOX'S") // TODO: Get fixed nhunspell - { - suggestions = DoSuggest(word); // 0.9.6 fails on "Lt'S" - } - } - - if (word.StartsWith("<i>", StringComparison.Ordinal)) - { - word = word.Remove(0, 3); - } - - if (word.EndsWith("</i>", StringComparison.Ordinal)) - { - word = word.Remove(word.Length - 4, 4); - } - - SpellCheckOcrTextResult res = SpellCheckOcrText(line, bitmap, word, suggestions); - if (Abort) - { - return null; - } - if (res.FixedWholeLine) - { - return res.Line; - } - if (res.Fixed) - { - localIgnoreWords.Add(word); - line = res.Line; - wordsNotFound--; - } - } - } - } - } - return line; - } - - private static string GetDashedWordBefore(string word, string line, List<string> words, int index) - { - if (index > 0 && line.Contains(words[index - 1] + "-" + word, StringComparison.Ordinal)) - { - return HtmlUtil.RemoveOpenCloseTags(words[index - 1] + "-" + word, HtmlUtil.TagItalic); - } - - return null; - } - - private static string GetDashedWordAfter(string word, string line, List<string> words, int index) - { - if (index < words.Count - 1 && line.Contains(word + "-" + words[index + 1].Replace("</i>", string.Empty), StringComparison.Ordinal)) - { - return HtmlUtil.RemoveOpenCloseTags(word + "-" + words[index + 1], HtmlUtil.TagItalic); - } - - return null; - } - - private static string GetWordWithDominatedCasing(string word) - { - int lowercase = 0; - int uppercase = 0; - for (int i = 0; i < word.Length; i++) - { - var ch = word[i]; - if (char.IsLower(ch)) - { - lowercase++; - } - else if (char.IsUpper(ch)) - { - uppercase++; - } - } - if (uppercase > lowercase) - { - return word.ToUpperInvariant(); - } - - return word.ToLowerInvariant(); - } - - /// <summary> - /// SpellCheck for OCR - /// </summary> - /// <returns>True, if word is fixed</returns> - private SpellCheckOcrTextResult SpellCheckOcrText(string line, Bitmap bitmap, string word, List<string> suggestions) - { - var result = new SpellCheckOcrTextResult { Fixed = false, FixedWholeLine = false, Line = null, Word = null }; - _spellCheck.Initialize(word, suggestions, line, bitmap, IsBinaryImageCompareOrNOcr); - _spellCheck.ShowDialog(_parentForm); - LastAction = _spellCheck.ActionResult; - switch (_spellCheck.ActionResult) - { - case OcrSpellCheck.Action.Abort: - Abort = true; - break; - case OcrSpellCheck.Action.AddToUserDictionary: - if (_userWordListXmlFileName != null) - { - Utilities.AddToUserDictionary(_spellCheck.Word.Trim().ToLowerInvariant(), _fiveLetterWordListLanguageName); - _userWordList.Add(_spellCheck.Word.Trim().ToLowerInvariant()); - } - result.Word = _spellCheck.Word; - result.Fixed = true; - result.Line = line; - if (word == result.Word) - { - return result; - } - - break; - case OcrSpellCheck.Action.AddToNames: - case OcrSpellCheck.Action.AddToNamesOnly: - result.Word = _spellCheck.Word; - result.Fixed = true; - try - { - string s = _spellCheck.Word.Trim(); - _nameListObj?.Add(s); - if (s.Contains(' ')) - { - _nameMultiWordList.Add(s); - } - else - { - _nameList.Add(s); - _nameListUppercase.Add(s.ToUpperInvariant()); - if (_fiveLetterWordListLanguageName.StartsWith("en", StringComparison.Ordinal)) - { - if (!s.EndsWith('s')) - { - _nameListWithApostrophe.Add(s + "'s"); - } - else - { - _nameListWithApostrophe.Add(s + "'"); - } - } - } - } - catch - { - _wordSkipList.Add(_spellCheck.Word); - } - result.Line = line; - if (word == result.Word || _spellCheck.ActionResult == OcrSpellCheck.Action.AddToNamesOnly) - { - return result; - } - - break; - case OcrSpellCheck.Action.AlwaysUseSuggestion: - try - { - _ocrFixReplaceList.AddWordOrPartial(word, _spellCheck.Word); - if (!word.Contains(' ')) - { - _spellCheckWordLists?.UseAlwaysListAdd(word, _spellCheck.Word); - } - } - catch (Exception exception) - { - MessageBox.Show(exception + Environment.NewLine + exception.StackTrace); - _wordSkipList.Add(word); - } - result.Fixed = true; - result.Word = _spellCheck.Word; - break; - case OcrSpellCheck.Action.ChangeAndSave: - try - { - _ocrFixReplaceList.AddWordOrPartial(word, _spellCheck.Word); - } - catch (Exception exception) - { - MessageBox.Show(exception + Environment.NewLine + exception.StackTrace); - _wordSkipList.Add(word); - } - result.Fixed = true; - result.Word = _spellCheck.Word; - break; - case OcrSpellCheck.Action.ChangeOnce: - result.Fixed = true; - result.Word = _spellCheck.Word; - break; - case OcrSpellCheck.Action.ChangeWholeText: - result.Line = _spellCheck.Paragraph; - result.FixedWholeLine = true; - break; - case OcrSpellCheck.Action.ChangeAllWholeText: - _ocrFixReplaceList.AddToWholeLineList(_spellCheck.OriginalWholeText, _spellCheck.Paragraph); - result.Line = _spellCheck.Paragraph; - result.FixedWholeLine = true; - break; - case OcrSpellCheck.Action.SkipAll: - _wordSkipList.Add(_spellCheck.Word); - _wordSkipList.Add(_spellCheck.Word.ToUpperInvariant()); - if (_spellCheck.Word.Length > 1) - { - _wordSkipList.Add(char.ToUpper(_spellCheck.Word[0]) + _spellCheck.Word.Substring(1)); - } - - break; - case OcrSpellCheck.Action.SkipOnce: - break; - case OcrSpellCheck.Action.SkipWholeText: - result.Line = line; - result.FixedWholeLine = true; - break; - case OcrSpellCheck.Action.UseSuggestion: - result.Word = _spellCheck.Word; - result.Fixed = true; - break; - case OcrSpellCheck.Action.InspectCompareMatches: - Abort = true; - break; - } - if (result.Fixed) - { - result.Line = OcrFixReplaceList.ReplaceWord(line, word, result.Word); - } - return result; - } - - public bool DoSpell(string word) - { - return _hunspell.Spell(word); - } - - public List<string> DoSuggest(string word) - { - return _hunspell.Suggest(word); - } - - public bool IsWordOrWordsCorrect(string word) - { - foreach (string s in word.Split(' ')) - { - if (!DoSpell(s)) - { - if (IsWordKnownOrNumber(word, word)) - { - return true; - } - - if (s.Length > 10 && s.Contains('/')) - { - string[] ar = s.Split('/'); - if (ar.Length == 2) - { - if (ar[0].Length > 3 && ar[1].Length > 3) - { - string a = ar[0]; - if (a == a.ToUpperInvariant()) - { - a = a[0] + a.Substring(1).ToLowerInvariant(); - } - - string b = ar[0]; - if (b == b.ToUpperInvariant()) - { - b = b[0] + b.Substring(1).ToLowerInvariant(); - } - - if ((DoSpell(a) || IsWordKnownOrNumber(a, word)) && - (DoSpell(b) || IsWordKnownOrNumber(b, word))) - { - return true; - } - } - } - } - return false; - } - } - return true; - } - - public bool IsWordKnownOrNumber(string word, string line) - { - if (double.TryParse(word.TrimStart('\'').Replace("$", string.Empty).Replace("£", string.Empty).Replace("¢", string.Empty), out _)) - { - return true; - } - - if (_wordSkipList.Contains(word)) - { - return true; - } - - if (_nameList.Contains(word.Trim('\''))) - { - return true; - } - - if (_nameListUppercase.Contains(word.Trim('\''))) - { - return true; - } - - if (_userWordList.Contains(word.ToLowerInvariant())) - { - return true; - } - - if (_userWordList.Contains(word.Trim('\'').ToLowerInvariant())) - { - return true; - } - - if (word.Length > 2 && _nameListUppercase.Contains(word)) - { - return true; - } - - if (word.Length > 2 && _nameListWithApostrophe.Contains(word)) - { - return true; - } - - if (_nameListObj != null && _nameListObj.IsInNamesMultiWordList(line, word)) - { - return true; - } - - return false; - } - - public int CountUnknownWordsViaDictionary(string line, out int numberOfCorrectWords) - { - numberOfCorrectWords = 0; - if (_hunspell == null) - { - return 0; - } - - int minLength = 2; - if (Configuration.Settings.Tools.CheckOneLetterWords) - { - minLength = 1; - } - - int wordsNotFound = 0; - var words = HtmlUtil.RemoveOpenCloseTags(line, HtmlUtil.TagItalic).Split(" \r\n\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - for (int i = 0; i < words.Length; i++) - { - string word = words[i].Trim(SpellCheckWordLists.SplitChars.ToArray()); - if (word.Length >= minLength) - { - if (!IsWordKnownOrNumber(word, line)) - { - bool correct = word.Length > 1 && _hunspell.Spell(word); - if (!correct) - { - correct = word.Length > 2 && _hunspell.Spell(word.Trim('\'')); - } - - if (!correct && word.Length == 1 && _threeLetterIsoLanguageName == "eng" && (word == "I" || word == "A" || word == "a")) - { - correct = true; - } - - if (correct) - { - numberOfCorrectWords++; - } - else - { - wordsNotFound++; - } - } - else if (word.Length > 3) - { - numberOfCorrectWords++; - } - } - } - return wordsNotFound; - } - - public void Dispose() - { - if (_hunspell != null) - { - _hunspell.Dispose(); - _hunspell = null; - } - if (_spellCheck != null) - { - _spellCheck.Dispose(); - _spellCheck = null; - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.Dictionaries; +using Nikse.SubtitleEdit.Core.Forms.FixCommonErrors; +using Nikse.SubtitleEdit.Core.Interfaces; +using Nikse.SubtitleEdit.Core.SpellCheck; +using Nikse.SubtitleEdit.Forms; +using Nikse.SubtitleEdit.Forms.Ocr; +using Nikse.SubtitleEdit.Logic.SpellCheck; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using System.Xml; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic.Ocr +{ + public class OcrFixEngine : IDisposable, IDoSpell + { + public abstract class LogItem + { + public int Line { get; set; } + public string Text { get; } + + protected LogItem(int line, string text) + { + Line = line; + Text = text.Trim(); + } + + public override string ToString() + { + return $"#{Line}: {Text}"; + } + } + + private class AutoGuess : LogItem + { + public AutoGuess(int index, string word, string guess, string line) + : base(index + 1, string.Format(Configuration.Settings.Language.VobSubOcr.UnknownWordToGuessInLine, word, guess, line.Replace(Environment.NewLine, " "))) + { + } + } + + private class UnknownWord : LogItem + { + public UnknownWord(int index, string word) + : base(index + 1, word) + { + } + } + + public enum AutoGuessLevel + { + None, + Cautious, + Aggressive + } + + private string _userWordListXmlFileName; + private string _fiveLetterWordListLanguageName; + + private readonly OcrFixReplaceList _ocrFixReplaceList; + private NameList _nameListObj; + private HashSet<string> _nameList = new HashSet<string>(); + private HashSet<string> _nameListUppercase = new HashSet<string>(); + private HashSet<string> _nameListWithApostrophe = new HashSet<string>(); + private HashSet<string> _nameMultiWordList = new HashSet<string>(); // case sensitive phrases + private List<string> _nameMultiWordListAndWordsWithPeriods; + private HashSet<string> _abbreviationList; + private HashSet<string> _userWordList = new HashSet<string>(); + private HashSet<string> _wordSkipList = new HashSet<string>(); + private readonly HashSet<string> _wordSpellOkList = new HashSet<string>(); + private Hunspell _hunspell; + private Dictionary<string, string> _changeAllDictionary; + private SpellCheckWordLists _spellCheckWordLists; + private OcrSpellCheck _spellCheck; + private readonly Form _parentForm; + private string _spellCheckDictionaryName; + private readonly string _threeLetterIsoLanguageName; + + private static readonly Regex RegexAloneIasL = new Regex(@"\bl\b", RegexOptions.Compiled); + private static readonly Regex RegexLowercaseL = new Regex("[A-ZÆØÅÄÖÉÈÀÙÂÊÎÔÛËÏ]l[A-ZÆØÅÄÖÉÈÀÙÂÊÎÔÛËÏ]", RegexOptions.Compiled); + private static readonly Regex RegexUppercaseI = new Regex("[a-zæøåöääöéèàùâêîôûëï]I.", RegexOptions.Compiled); + private static readonly Regex RegexNumber1 = new Regex(@"(?<=\d) 1(?!/\d)", RegexOptions.Compiled); + + public bool Abort { get; set; } + public OcrSpellCheck.Action LastAction { get; set; } = OcrSpellCheck.Action.Abort; + public bool IsBinaryImageCompareOrNOcr { get; set; } + public List<LogItem> AutoGuessesUsed { get; set; } + public List<LogItem> UnknownWordsFound { get; set; } + public bool IsDictionaryLoaded { get; private set; } + + private readonly HashSet<char> _expectedChars = new HashSet<char> { ' ', '¡', '¿', ',', '.', '!', '?', ':', ';', '(', ')', '[', ']', '{', '}', '+', '-', '£', '\\', '"', '”', '„', '“', '«', '»', '#', '&', '%', '\r', '\n', '؟' }; // removed $ + private readonly HashSet<char> _expectedCharsNoComma = new HashSet<char> { ' ', '¡', '¿', '.', '!', '?', ':', ';', '(', ')', '[', ']', '{', '}', '+', '-', '£', '\\', '"', '”', '„', '“', '«', '»', '#', '&', '%', '\r', '\n', '؟' }; // removed $ + comma + + /// <summary> + /// Advanced OCR fixing via replace/spelling dictionaries + some hardcoded rules + /// </summary> + /// <param name="threeLetterIsoLanguageName">E.g. eng for English</param> + /// <param name="hunspellName">Name of hunspell dictionary</param> + /// <param name="parentForm">Used for centering/show spell check dialog</param> + /// <param name="isBinaryImageCompare">Calling from OCR via "Image compare"</param> + public OcrFixEngine(string threeLetterIsoLanguageName, string hunspellName, Form parentForm, bool isBinaryImageCompareOrNOcr = false) + { + if (string.IsNullOrEmpty(threeLetterIsoLanguageName)) + { + if (hunspellName != null && hunspellName.Length >= 2) + { + threeLetterIsoLanguageName = Iso639Dash2LanguageCode.GetThreeLetterCodeFromTwoLetterCode(hunspellName.Substring(0, 2)); + } + else + { + threeLetterIsoLanguageName = string.Empty; + } + } + + IsBinaryImageCompareOrNOcr = isBinaryImageCompareOrNOcr; + if (threeLetterIsoLanguageName == "per") + { + threeLetterIsoLanguageName = "fas"; + } + + _threeLetterIsoLanguageName = threeLetterIsoLanguageName; + _parentForm = parentForm; + + if (parentForm.GetType() != typeof(FixCommonErrors)) + { + _spellCheck = new OcrSpellCheck(_parentForm) { StartPosition = FormStartPosition.Manual, IsBinaryImageCompareOrNOcr = isBinaryImageCompareOrNOcr }; + _spellCheck.Location = new Point(parentForm.Left + (parentForm.Width / 2 - _spellCheck.Width / 2), + parentForm.Top + (parentForm.Height / 2 - _spellCheck.Height / 2)); + } + + _ocrFixReplaceList = OcrFixReplaceList.FromLanguageId(threeLetterIsoLanguageName); + if (!string.IsNullOrEmpty(threeLetterIsoLanguageName) || !string.IsNullOrEmpty(hunspellName)) + { + LoadSpellingDictionaries(threeLetterIsoLanguageName, hunspellName); // Hunspell etc. + } + + AutoGuessesUsed = new List<LogItem>(); + UnknownWordsFound = new List<LogItem>(); + } + + private void LoadSpellingDictionaries(string threeLetterIsoLanguageName, string hunspellName) + { + string dictionaryFolder = Utilities.DictionaryFolder; + if (!Directory.Exists(dictionaryFolder)) + { + return; + } + + if (!string.IsNullOrEmpty(hunspellName)) + { + var directDicFile = Path.Combine(dictionaryFolder, hunspellName + ".dic"); + if (File.Exists(directDicFile)) + { + LoadSpellingDictionariesViaDictionaryFileName(threeLetterIsoLanguageName, directDicFile, true); + return; + } + } + + if (!string.IsNullOrEmpty(hunspellName) && threeLetterIsoLanguageName == "eng" && hunspellName.Equals("en_gb", StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(dictionaryFolder, "en_GB.dic"))) + { + LoadSpellingDictionariesViaDictionaryFileName("eng", "en_GB.dic", true); + return; + } + if (!string.IsNullOrEmpty(hunspellName) && threeLetterIsoLanguageName == "eng" && hunspellName.Equals("en-gb", StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(dictionaryFolder, "en-GB.dic"))) + { + LoadSpellingDictionariesViaDictionaryFileName("eng", "en-GB.dic", true); + return; + } + if (!string.IsNullOrEmpty(hunspellName) && threeLetterIsoLanguageName == "eng" && hunspellName.Equals("en_ca", StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(dictionaryFolder, "en_CA.dic"))) + { + LoadSpellingDictionariesViaDictionaryFileName("eng", "en_CA.dic", true); + return; + } + if (!string.IsNullOrEmpty(hunspellName) && threeLetterIsoLanguageName == "eng" && hunspellName.Equals("en_au", StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(dictionaryFolder, "en_AU.dic"))) + { + LoadSpellingDictionariesViaDictionaryFileName("eng", "en_AU.dic", true); + return; + } + if (!string.IsNullOrEmpty(hunspellName) && threeLetterIsoLanguageName == "eng" && hunspellName.Equals("en_za", StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(dictionaryFolder, "en_ZA.dic"))) + { + LoadSpellingDictionariesViaDictionaryFileName("eng", "en_ZA.dic", true); + return; + } + if (threeLetterIsoLanguageName == "eng" && File.Exists(Path.Combine(dictionaryFolder, "en_US.dic"))) + { + LoadSpellingDictionariesViaDictionaryFileName("eng", "en_US.dic", true); + return; + } + + foreach (var culture in Iso639Dash2LanguageCode.List) + { + if (culture.ThreeLetterCode == threeLetterIsoLanguageName) + { + string dictionaryFileName = null; + if (!string.IsNullOrEmpty(hunspellName) && hunspellName.StartsWith(culture.TwoLetterCode, StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(dictionaryFolder, hunspellName + ".dic"))) + { + dictionaryFileName = Path.Combine(dictionaryFolder, hunspellName + ".dic"); + LoadSpellingDictionariesViaDictionaryFileName(threeLetterIsoLanguageName, dictionaryFileName, true); + return; + } + foreach (string dic in Directory.GetFiles(dictionaryFolder, "*.dic")) + { + string name = Path.GetFileNameWithoutExtension(dic); + if (!string.IsNullOrEmpty(name) && !name.StartsWith("hyph", StringComparison.Ordinal)) + { + try + { + name = name.Replace('_', '-'); + if (name.Length > 5) + { + name = name.Substring(0, 5); + } + + var ci = CultureInfo.GetCultureInfo(name); + if (ci.GetThreeLetterIsoLanguageName() == threeLetterIsoLanguageName || + ci.GetThreeLetterIsoLanguageName().Equals(threeLetterIsoLanguageName, StringComparison.OrdinalIgnoreCase)) + { + dictionaryFileName = dic; + break; + } + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception.Message); + } + } + } + + if (dictionaryFileName == null) + { + return; + } + + LoadSpellingDictionariesViaDictionaryFileName(threeLetterIsoLanguageName, dictionaryFileName, true); + return; + } + } + + string dicFileName = null; + foreach (string dic in Directory.GetFiles(dictionaryFolder, "*.dic")) + { + string name = Path.GetFileNameWithoutExtension(dic); + if (!string.IsNullOrEmpty(name) && !name.StartsWith("hyph", StringComparison.Ordinal)) + { + try + { + name = name.Replace('_', '-'); + if (name.Length > 5) + { + name = name.Substring(0, 5); + } + + var ci = CultureInfo.GetCultureInfo(name); + if (ci.GetThreeLetterIsoLanguageName() == threeLetterIsoLanguageName || + ci.GetThreeLetterIsoLanguageName().Equals(threeLetterIsoLanguageName, StringComparison.OrdinalIgnoreCase)) + { + dicFileName = dic; + break; + } + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception.Message); + } + } + } + + if (dicFileName == null) + { + return; + } + + LoadSpellingDictionariesViaDictionaryFileName(threeLetterIsoLanguageName, dicFileName, true); + } + + private void LoadSpellingDictionariesViaDictionaryFileName(string threeLetterIsoLanguageName, string dictionaryFileName, bool resetSkipList) + { + _fiveLetterWordListLanguageName = Path.GetFileNameWithoutExtension(dictionaryFileName); + if (_fiveLetterWordListLanguageName != null && _fiveLetterWordListLanguageName.Length > 5) + { + _fiveLetterWordListLanguageName = _fiveLetterWordListLanguageName.Substring(0, 5); + } + + string dictionary = Utilities.DictionaryFolder + _fiveLetterWordListLanguageName; + if (resetSkipList) + { + _wordSkipList = new HashSet<string> { Configuration.Settings.Tools.MusicSymbol, "*", "%", "#", "+", "$" }; + } + + // Load names etc list (names/noise words) + _nameListObj = new NameList(Configuration.DictionariesDirectory, _fiveLetterWordListLanguageName, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl); + _nameList = _nameListObj.GetNames(); + _nameMultiWordList = _nameListObj.GetMultiNames(); + _nameListUppercase = new HashSet<string>(); + _nameListWithApostrophe = new HashSet<string>(); + var nameListWithPeriods = new List<string>(); + _abbreviationList = new HashSet<string>(); + + bool isEnglish = threeLetterIsoLanguageName.Equals("eng", StringComparison.OrdinalIgnoreCase); + foreach (string name in _nameList) + { + _nameListUppercase.Add(name.ToUpperInvariant()); + if (isEnglish) + { + if (!name.EndsWith('s')) + { + _nameListWithApostrophe.Add(name + "'s"); + } + else + { + _nameListWithApostrophe.Add(name + "'"); + } + } + + // Abbreviations. + if (name.EndsWith('.')) + { + _abbreviationList.Add(name); + } + + if (name.Contains(".", StringComparison.Ordinal)) + { + nameListWithPeriods.Add(name); + } + } + + _nameMultiWordListAndWordsWithPeriods = new List<string>(_nameMultiWordList.Concat(nameListWithPeriods)); + if (isEnglish) + { + if (!_abbreviationList.Contains("a.m.")) + { + _abbreviationList.Add("a.m."); + } + + if (!_abbreviationList.Contains("p.m.")) + { + _abbreviationList.Add("p.m."); + } + + if (!_abbreviationList.Contains("o.r.")) + { + _abbreviationList.Add("o.r."); + } + } + + // Load user words + _userWordList = new HashSet<string>(); + _userWordListXmlFileName = Utilities.LoadUserWordList(_userWordList, _fiveLetterWordListLanguageName); + foreach (string name in _userWordList) + { + if (name.EndsWith('.')) + { + _abbreviationList.Add(name); + } + } + + // Load Hunspell spell checker + try + { + if (dictionaryFileName.EndsWith(".dic", StringComparison.OrdinalIgnoreCase) && File.Exists(dictionaryFileName)) + { + dictionary = dictionaryFileName.Substring(0, dictionaryFileName.Length - 4); + } + else if (dictionaryFileName.EndsWith(".dic", StringComparison.OrdinalIgnoreCase) && File.Exists(Path.Combine(Utilities.DictionaryFolder, dictionaryFileName))) + { + var f = Path.Combine(Utilities.DictionaryFolder, dictionaryFileName); + dictionary = f.Substring(0, f.Length - 4); + } + else if (!File.Exists(dictionary + ".dic")) + { + var fileMatches = Directory.GetFiles(Utilities.DictionaryFolder, _fiveLetterWordListLanguageName + "*.dic"); + if (fileMatches.Length > 0) + { + dictionary = fileMatches[0].Substring(0, fileMatches[0].Length - 4); + } + } + _hunspell?.Dispose(); + _hunspell = Hunspell.GetHunspell(dictionary); + IsDictionaryLoaded = true; + _spellCheckDictionaryName = dictionary; + } + catch + { + IsDictionaryLoaded = false; + } + + // load spell check "change all" list + if (_hunspell != null) + { + var languageName = Path.GetFileName(_spellCheckDictionaryName); + if (!string.IsNullOrEmpty(languageName)) + { + _spellCheckWordLists = new SpellCheckWordLists(Utilities.DictionaryFolder, languageName, this); + _changeAllDictionary = _spellCheckWordLists.GetUseAlwaysList(); + } + } + } + + public string SpellCheckDictionaryName + { + get + { + string[] parts = _spellCheckDictionaryName?.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); + if (parts?.Length > 0) + { + return parts[parts.Length - 1]; + } + + return string.Empty; + } + } + + internal static Dictionary<string, string> LoadReplaceList(XmlDocument doc, string name) + { + var list = new Dictionary<string, string>(); + XmlNode node = doc.DocumentElement?.SelectSingleNode(name); + if (node != null) + { + foreach (XmlNode item in node.ChildNodes) + { + if (item.Attributes?["to"] != null && item.Attributes["from"] != null) + { + string to = item.Attributes["to"].InnerText; + string from = item.Attributes["from"].InnerText; + if (!list.ContainsKey(from)) + { + list.Add(from, to); + } + } + } + } + return list; + } + + internal static Dictionary<string, string> LoadRegExList(XmlDocument doc, string name) + { + var list = new Dictionary<string, string>(); + XmlNode node = doc.DocumentElement?.SelectSingleNode(name); + if (node != null) + { + foreach (XmlNode item in node.ChildNodes) + { + if (item.Attributes?["replaceWith"] != null && item.Attributes["find"] != null) + { + string to = item.Attributes["replaceWith"].InnerText; + string from = item.Attributes["find"].InnerText; + if (!list.ContainsKey(from)) + { + list.Add(from, to); + } + } + } + } + return list; + } + + public string FixOcrErrors(string input, int index, string lastLine, bool logSuggestions, AutoGuessLevel autoGuess) + { + var text = input; + while (text.Contains(Environment.NewLine + " ", StringComparison.Ordinal)) + { + text = text.Replace(Environment.NewLine + " ", Environment.NewLine); + } + + while (text.Contains(" " + Environment.NewLine, StringComparison.Ordinal)) + { + text = text.Replace(" " + Environment.NewLine, Environment.NewLine); + } + + while (text.Contains(Environment.NewLine + Environment.NewLine, StringComparison.Ordinal)) + { + text = text.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); + } + + text = text.Trim(); + + // Try to prevent resizing when fixing Ocr-hardcoded. + var sb = new StringBuilder(text.Length + 2); + + if (Configuration.Settings.Tools.OcrFixUseHardcodedRules) + { + if (text.Length > 3 && text.StartsWith(". .") && char.IsLetter(text[3])) + { + text = text.Remove(1, 1).Insert(1, "."); + } + else if (text.Length > 3 && text.StartsWith(".. ") && char.IsLetter(text[3])) + { + text = text.Remove(2, 1).Insert(2, "."); + } + else if (text.Length > 3 && text.StartsWith("..") && char.IsLetter(text[2])) + { + text = "." + text; + } + + text = text.Replace("<i>-</i>", "-"); + text = text.Replace("<i>- </i>", "- "); + text = text.Replace("<i> - </i>", "- "); + text = text.Replace("<i> -</i>", "- "); + text = text.Replace("- ", "- "); + text = text.Replace("<i>a</i>", "a"); + text = text.Replace("<i>.</i>", "."); + text = text.TrimStart(); + + int len = text.Length; + for (int i = 0; i < len; i++) + { + char ch = text[i]; + switch (ch) + { + case 'fi': + sb.Append("fi"); + break; + case 'fl': // fb02 + sb.Append("fl"); + break; + case 'ν': // NOTE: Special unicode character! (Greek character!) + if (_threeLetterIsoLanguageName == "ell" || _threeLetterIsoLanguageName == "gre") + { + sb.Append(ch); // Keep Greek 'ν' + } + else + { + sb.Append('v'); + } + break; + case '‚': // #x201A (SINGLE LOW-9 QUOTATION MARK) to plain old comma + sb.Append(','); + break; + default: + sb.Append(ch); + break; + } + } + text = sb.ToString(); + sb.Clear(); + } + + text = ReplaceWordsBeforeLineFixes(text); + + text = FixCommonOcrLineErrors(text, lastLine); + + // check words split by only space and new line (as other split chars might by a part of from-replace-string, like "\/\/e're" contains slash) + sb = new StringBuilder(); + var word = new StringBuilder(); + string lastWord = null; + for (int i = 0; i < text.Length; i++) + { + if (text[i] != '.' && "\r\n ".Contains(text[i])) + { + if (word.Length > 0) + { + var fixedWord = FixOcrErrorsWord(lastWord, word, sb); + lastWord = fixedWord; + word.Clear(); + } + sb.Append(text[i]); + } + else + { + word.Append(text[i]); + } + } + if (word.Length > 0) // last word + { + FixOcrErrorsWord(lastWord, word, sb); + } + + // check words split by many chars like "()/-" etc. + text = sb.ToString(); + sb = new StringBuilder(); + word = new StringBuilder(); + lastWord = null; + for (int i = 0; i < text.Length; i++) + { + if (text[i] != '.' && _expectedChars.Contains(text[i])) + { + if (word.Length > 0) + { + var fixedWord = FixOcrErrorsWord(lastWord, word, sb); + lastWord = fixedWord; + word.Clear(); + } + sb.Append(text[i]); + } + else + { + word.Append(text[i]); + } + } + if (word.Length > 0) // last word + { + FixOcrErrorsWord(lastWord, word, sb); + } + + text = FixCommonOcrLineErrors(sb.ToString(), lastLine); + if (Configuration.Settings.Tools.OcrFixUseHardcodedRules) + { + text = FixLowercaseIToUppercaseI(text, lastLine); + if (SpellCheckDictionaryName.StartsWith("en_", StringComparison.Ordinal) || _threeLetterIsoLanguageName == "eng") + { + string oldText = text; + text = FixAloneLowercaseIToUppercaseI.FixAloneLowercaseIToUppercaseLine(RegexUtils.LittleIRegex, oldText, text, 'i'); + text = FixAloneLowercaseIToUppercaseI.FixAloneLowercaseIToUppercaseLine(RegexAloneIasL, oldText, text, 'l'); + } + else if (_threeLetterIsoLanguageName == "fra") + { + text = FixFrenchLApostrophe(text, " I'", lastLine); + text = FixFrenchLApostrophe(text, " L'", lastLine); + text = FixFrenchLApostrophe(text, " l'", lastLine); + text = FixFrenchLApostrophe(text, " I’", lastLine); + text = FixFrenchLApostrophe(text, " L’", lastLine); + text = FixFrenchLApostrophe(text, " l’", lastLine); + } + + text = Utilities.RemoveSpaceBetweenNumbers(text); + } + + // must be last - counts/logs unknown words + text = FixUnknownWordsViaGuessOrPrompt(out _, text, index, null, true, false, logSuggestions, autoGuess); + + return text; + } + + private string FixOcrErrorsWord(string lastWord, StringBuilder word, StringBuilder sb) + { + string fixedWord; + if (lastWord != null && lastWord.Contains("COLOR=", StringComparison.OrdinalIgnoreCase)) + { + fixedWord = word.ToString(); + } + else + { + var doFixWord = !(word.Length == 1 && sb.Length > 1 && sb.EndsWith('-')); + if (doFixWord) + { + fixedWord = word.ToString(); + + var post = string.Empty; + if (fixedWord.EndsWith('.') && fixedWord.IndexOf('.') == fixedWord.Length - 1) + { + post = "."; + fixedWord = fixedWord.Substring(0, fixedWord.Length - 1); + } + else if (fixedWord.EndsWith("...", StringComparison.Ordinal)) + { + post = "..."; + fixedWord = fixedWord.Substring(0, fixedWord.Length - 3); + } + + fixedWord = FixWordViaReplaceList(fixedWord); + fixedWord = _ocrFixReplaceList.FixCommonWordErrors(fixedWord); + + // Try using word lists for uppercase i inside words, e.g. "NIkolaj" to "Nikolaj" + if (fixedWord.Contains('I')) + { + var temp = fixedWord.Replace('I', 'i'); + if (temp != fixedWord.ToUpperInvariant()) + { + if (_nameList.Contains(temp)) + { + fixedWord = temp; + } + } + } + fixedWord += post; + } + else + { + fixedWord = word.ToString(); + } + } + + sb.Append(fixedWord); + return fixedWord; + } + + private string FixWordViaReplaceList(string word) + { + if (_changeAllDictionary != null && _changeAllDictionary.ContainsKey(word)) + { + return _changeAllDictionary[word]; + } + return word; + } + + internal static string FixFrenchLApostrophe(string input, string tag, string lastLine) + { + var text = input; + bool endingBeforeThis = string.IsNullOrEmpty(lastLine) || lastLine.EndsWith('.') || lastLine.EndsWith('!') || lastLine.EndsWith('?') || + lastLine.EndsWith(".</i>", StringComparison.Ordinal) || lastLine.EndsWith("!</i>", StringComparison.Ordinal) || lastLine.EndsWith("?</i>", StringComparison.Ordinal) || + lastLine.EndsWith(".</font>", StringComparison.Ordinal) || lastLine.EndsWith("!</font>", StringComparison.Ordinal) || lastLine.EndsWith("?</font>", StringComparison.Ordinal); + if (text.StartsWith(tag.TrimStart(), StringComparison.Ordinal) && text.Length > 3) + { + if (endingBeforeThis || char.IsUpper(text[2])) + { + text = @"L" + text.Substring(1); + } + else if (char.IsLower(text[2])) + { + text = @"l" + text.Substring(1); + } + } + else if (text.StartsWith("<i>" + tag.TrimStart(), StringComparison.Ordinal) && text.Length > 6) + { + if (endingBeforeThis || char.IsUpper(text[5])) + { + text = text.Remove(3, 1).Insert(3, "L"); + } + else if (char.IsLower(text[5])) + { + text = text.Remove(3, 1).Insert(3, "l"); + } + } + + int start = text.IndexOf(tag, StringComparison.Ordinal); + while (start > 0) + { + lastLine = HtmlUtil.RemoveHtmlTags(text.Substring(0, start)).TrimEnd().TrimEnd('-').TrimEnd(); + endingBeforeThis = string.IsNullOrEmpty(lastLine) || lastLine.EndsWith('.') || lastLine.EndsWith('!') || lastLine.EndsWith('?'); + if (start < text.Length - 4) + { + if (start == 1 && text.StartsWith('-')) + { + endingBeforeThis = true; + } + + if (start > 1) + { + string beforeThis = HtmlUtil.RemoveHtmlTags(text.Substring(0, start)); + endingBeforeThis = beforeThis.EndsWith('.') || beforeThis.EndsWith('!') || beforeThis.EndsWith('?'); + } + + if (endingBeforeThis) + { + text = text.Remove(start + 1, 1).Insert(start + 1, "L"); + } + else + { + text = text.Remove(start + 1, 1).Insert(start + 1, "l"); + } + } + start = text.IndexOf(tag, start + 1, StringComparison.Ordinal); + } + + tag = Environment.NewLine + tag.Trim(); + start = text.IndexOf(tag, StringComparison.Ordinal); + while (start > 0) + { + lastLine = HtmlUtil.RemoveHtmlTags(text.Substring(0, start)).TrimEnd().TrimEnd('-').TrimEnd(); + endingBeforeThis = string.IsNullOrEmpty(lastLine) || lastLine.EndsWith('.') || lastLine.EndsWith('!') || lastLine.EndsWith('?') || lastLine.EndsWith(".</i>", StringComparison.Ordinal); + if (start < text.Length - 5) + { + if (start > 1) + { + string beforeThis = HtmlUtil.RemoveHtmlTags(text.Substring(0, start)); + endingBeforeThis = beforeThis.EndsWith('.') || beforeThis.EndsWith('!') || beforeThis.EndsWith('?'); + } + + if (endingBeforeThis) + { + text = text.Remove(start + Environment.NewLine.Length, 1).Insert(start + Environment.NewLine.Length, "L"); + } + else + { + text = text.Remove(start + Environment.NewLine.Length, 1).Insert(start + Environment.NewLine.Length, "l"); + } + } + start = text.IndexOf(tag, start + 1, StringComparison.Ordinal); + } + + tag = Environment.NewLine + "<i>" + tag.Trim(); + start = text.IndexOf(tag, StringComparison.Ordinal); + while (start > 0) + { + lastLine = HtmlUtil.RemoveHtmlTags(text.Substring(0, start)).TrimEnd().TrimEnd('-').TrimEnd(); + endingBeforeThis = string.IsNullOrEmpty(lastLine) || lastLine.EndsWith('.') || lastLine.EndsWith('!') || lastLine.EndsWith('?') || lastLine.EndsWith(".</i>", StringComparison.Ordinal); + if (start < text.Length - 8) + { + if (endingBeforeThis || char.IsUpper(text[start + 5 + Environment.NewLine.Length])) + { + text = text.Remove(start + Environment.NewLine.Length + 3, 1).Insert(start + Environment.NewLine.Length + 3, "L"); + } + else if (char.IsLower(text[start + 5 + Environment.NewLine.Length])) + { + text = text.Remove(start + Environment.NewLine.Length + 3, 1).Insert(start + Environment.NewLine.Length + 3, "l"); + } + } + start = text.IndexOf(tag, start + 1, StringComparison.Ordinal); + } + return text; + } + + private string ReplaceWordsBeforeLineFixes(string text) + { + string lastWord = null; + var sb = new StringBuilder(); + var word = new StringBuilder(); + for (int i = 0; i < text.Length; i++) + { + if (_expectedCharsNoComma.Contains(text[i])) // fix e.g. "don,t" + { + if (word.Length > 0) + { + string fixedWord; + if (lastWord != null && lastWord.Contains("COLOR=", StringComparison.OrdinalIgnoreCase)) + { + fixedWord = word.ToString(); + } + else if (!word.ToString().Contains(',')) + { + fixedWord = word.ToString(); + } + else + { + fixedWord = _ocrFixReplaceList.FixCommonWordErrorsQuick(word.ToString()); + } + + sb.Append(fixedWord); + lastWord = fixedWord; + word.Clear(); + } + sb.Append(text[i]); + } + else + { + word.Append(text[i]); + } + } + if (word.Length > 0) // last word + { + string fixedWord; + if (lastWord != null && lastWord.Contains("COLOR=", StringComparison.OrdinalIgnoreCase)) + { + fixedWord = word.ToString(); + } + else if (!word.ToString().Contains(',')) + { + fixedWord = word.ToString(); + } + else + { + fixedWord = _ocrFixReplaceList.FixCommonWordErrorsQuick(word.ToString()); + } + + sb.Append(fixedWord); + } + + lastWord = null; + text = sb.ToString(); + sb = new StringBuilder(); + word = new StringBuilder(); + for (int i = 0; i < text.Length; i++) + { + if (_expectedChars.Contains(text[i])) // removed $ + { + if (word.Length > 0) + { + string fixedWord; + if (lastWord != null && lastWord.Contains("COLOR=", StringComparison.OrdinalIgnoreCase)) + { + fixedWord = word.ToString(); + } + else + { + fixedWord = _ocrFixReplaceList.FixCommonWordErrorsQuick(word.ToString()); + } + + sb.Append(fixedWord); + lastWord = fixedWord; + word.Clear(); + } + sb.Append(text[i]); + } + else + { + word.Append(text[i]); + } + } + if (word.Length > 0) // last word + { + string fixedWord = _ocrFixReplaceList.FixCommonWordErrorsQuick(word.ToString()); + sb.Append(fixedWord); + } + return sb.ToString(); + } + + private string FixCommonOcrLineErrors(string input, string lastLine) + { + var text = input; + text = FixOcrErrorViaLineReplaceList(text); + text = FixOcrErrorsViaHardcodedRules(text, lastLine, _abbreviationList); + text = FixOcrErrorViaLineReplaceList(text); + + if (Configuration.Settings.Tools.OcrFixUseHardcodedRules) + { + if (text.StartsWith('~')) + { + text = ("- " + text.Remove(0, 1)).Replace(" ", " "); + } + + text = text.Replace(Environment.NewLine + "~", Environment.NewLine + "- ").Replace(" ", " "); + + if (text.Length < 10 && text.Length > 4 && !text.Contains(Environment.NewLine, StringComparison.Ordinal) && text.StartsWith("II", StringComparison.Ordinal) && text.EndsWith("II", StringComparison.Ordinal)) + { + text = "\"" + text.Substring(2, text.Length - 4) + "\""; + } + + // e.g. "selectionsu." -> "selections..." + if (text.EndsWith("u.", StringComparison.Ordinal) && _hunspell != null) + { + string[] words = text.Split(new[] { ' ', '.' }, StringSplitOptions.RemoveEmptyEntries); + if (words.Length > 0) + { + string lastWord = words[words.Length - 1].Trim(); + if (lastWord.Length > 2 && + char.IsLower(lastWord[0]) && + !IsWordOrWordsCorrect(lastWord) && + IsWordOrWordsCorrect(lastWord.Substring(0, lastWord.Length - 1))) + { + text = text.Substring(0, text.Length - 2) + "..."; + } + } + } + + // music notes + if (text.StartsWith(".'", StringComparison.Ordinal) && text.EndsWith(".'", StringComparison.Ordinal)) + { + text = text.Replace(".'", Configuration.Settings.Tools.MusicSymbol); + } + } + + return text; + } + + private string FixLowercaseIToUppercaseI(string input, string lastLine) + { + var sb = new StringBuilder(); + var lines = input.SplitToLines(); + for (int i = 0; i < lines.Count; i++) + { + string l = lines[i]; + + if (i > 0) + { + lastLine = lines[i - 1]; + } + + lastLine = HtmlUtil.RemoveHtmlTags(lastLine); + + if (string.IsNullOrEmpty(lastLine) || + lastLine.EndsWith('.') || + lastLine.EndsWith('!') || + lastLine.EndsWith('?')) + { + var st = new StrippableText(l); + if (st.StrippedText.StartsWith('i') && !st.Pre.EndsWith('[') && !st.Pre.EndsWith('(') && !st.Pre.EndsWith("...", StringComparison.Ordinal)) + { + if (string.IsNullOrEmpty(lastLine) || (!lastLine.EndsWith("...", StringComparison.Ordinal) && !EndsWithAbbreviation(lastLine, _abbreviationList))) + { + l = st.Pre + "I" + st.StrippedText.Remove(0, 1) + st.Post; + } + } + } + sb.AppendLine(l); + } + return sb.ToString().TrimEnd('\r', '\n'); + } + + private static bool EndsWithAbbreviation(string line, HashSet<string> abbreviationList) + { + if (string.IsNullOrEmpty(line)) + { + return false; + } + if (line.Length > 5 && line[line.Length - 3] == '.' && char.IsLetter(line[line.Length - 2])) + { + return true; + } + if (abbreviationList != null) + { + foreach (string abbreviation in abbreviationList) + { + if (line.EndsWith(" " + abbreviation, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + } + return false; + } + + public string FixOcrErrorsViaHardcodedRules(string input, string lastLine, HashSet<string> abbreviationList) + { + var text = input; + if (!Configuration.Settings.Tools.OcrFixUseHardcodedRules) + { + return text; + } + + text = text.Replace(",...", "..."); + + if (text.StartsWith("..", StringComparison.Ordinal) && !text.StartsWith("...", StringComparison.Ordinal)) + { + text = "." + text; + } + + string pre = string.Empty; + if (text.StartsWith("- ", StringComparison.Ordinal)) + { + pre = "- "; + text = text.Remove(0, 2); + } + else if (text.StartsWith('-')) + { + pre = "-"; + text = text.Remove(0, 1); + } + + bool hasDotDot = text.Contains("..", StringComparison.Ordinal) || text.Contains(". .", StringComparison.Ordinal); + if (hasDotDot) + { + if (text.Length > 5 && text.StartsWith("..", StringComparison.Ordinal) && Utilities.AllLettersAndNumbers.Contains(text[2])) + { + text = "..." + text.Remove(0, 2); + } + + if (text.Length > 7 && text.StartsWith("<i>..", StringComparison.Ordinal) && Utilities.AllLettersAndNumbers.Contains(text[5])) + { + text = "<i>..." + text.Remove(0, 5); + } + + if (text.Length > 5 && text.StartsWith(".. ", StringComparison.Ordinal) && Utilities.AllLettersAndNumbers.Contains(text[3])) + { + text = "..." + text.Remove(0, 3); + } + + if (text.Length > 7 && text.StartsWith("<i>.. ", StringComparison.Ordinal) && Utilities.AllLettersAndNumbers.Contains(text[6])) + { + text = "<i>..." + text.Remove(0, 6); + } + + if (text.Contains(Environment.NewLine + ".. ", StringComparison.Ordinal)) + { + text = text.Replace(Environment.NewLine + ".. ", Environment.NewLine + "..."); + } + + if (text.Contains(Environment.NewLine + "<i>.. ", StringComparison.Ordinal)) + { + text = text.Replace(Environment.NewLine + "<i>.. ", Environment.NewLine + "<i>..."); + } + + if (text.StartsWith(". ..", StringComparison.Ordinal)) + { + text = "..." + text.Remove(0, 4); + } + + if (text.StartsWith(".. .", StringComparison.Ordinal)) + { + text = "..." + text.Remove(0, 4); + } + + if (text.StartsWith(". . .", StringComparison.Ordinal)) + { + text = "..." + text.Remove(0, 5); + } + + if (text.StartsWith("... ", StringComparison.Ordinal)) + { + text = text.Remove(3, 1); + } + } + + text = pre + text; + + if (hasDotDot) + { + if (text.StartsWith("<i>. ..", StringComparison.Ordinal)) + { + text = "<i>..." + text.Remove(0, 7); + } + + if (text.StartsWith("<i>.. .", StringComparison.Ordinal)) + { + text = "<i>..." + text.Remove(0, 7); + } + + if (text.StartsWith("<i>. . .", StringComparison.Ordinal)) + { + text = "<i>..." + text.Remove(0, 8); + } + + if (text.StartsWith("<i>... ", StringComparison.Ordinal)) + { + text = text.Remove(6, 1); + } + + if (text.StartsWith(". . <i>.", StringComparison.Ordinal)) + { + text = "<i>..." + text.Remove(0, 8); + } + + if (text.StartsWith("...<i>", StringComparison.Ordinal) && (text.IndexOf("</i>", StringComparison.Ordinal) > text.IndexOf(' '))) + { + text = "<i>..." + text.Remove(0, 6); + } + + if (text.EndsWith(". ..", StringComparison.Ordinal)) + { + text = text.Remove(text.Length - 4, 4) + "..."; + } + + if (text.EndsWith(".. .", StringComparison.Ordinal)) + { + text = text.Remove(text.Length - 4, 4) + "..."; + } + + if (text.EndsWith(". . .", StringComparison.Ordinal)) + { + text = text.Remove(text.Length - 5, 5) + "..."; + } + + if (text.EndsWith(". ...", StringComparison.Ordinal)) + { + text = text.Remove(text.Length - 5, 5) + "..."; + } + + if (text.EndsWith(". ..</i>", StringComparison.Ordinal)) + { + text = text.Remove(text.Length - 8, 8) + "...</i>"; + } + + if (text.EndsWith(".. .</i>", StringComparison.Ordinal)) + { + text = text.Remove(text.Length - 8, 8) + "...</i>"; + } + + if (text.EndsWith(". . .</i>", StringComparison.Ordinal)) + { + text = text.Remove(text.Length - 9, 9) + "...</i>"; + } + + if (text.EndsWith(". ...</i>", StringComparison.Ordinal)) + { + text = text.Remove(text.Length - 9, 9) + "...</i>"; + } + + if (text.EndsWith(".</i> . .", StringComparison.Ordinal)) + { + text = text.Remove(text.Length - 9, 9) + "...</i>"; + } + + if (text.EndsWith(".</i>..", StringComparison.Ordinal)) + { + text = text.Remove(text.Length - 7, 7) + "...</i>"; + } + + text = text.Replace(".</i> . ." + Environment.NewLine, "...</i>" + Environment.NewLine); + + text = text.Replace(".. ?", "..?"); + text = text.Replace("..?", "...?"); + text = text.Replace("....?", "...?"); + + text = text.Replace(".. !", "..!"); + text = text.Replace("..!", "...!"); + text = text.Replace("....!", "...!"); + + text = text.Replace("... ?", "...?"); + text = text.Replace("... !", "...!"); + + text = text.Replace("....", "..."); + text = text.Replace("....", "..."); + + if (text.StartsWith("- ...", StringComparison.Ordinal) && lastLine != null && lastLine.EndsWith("...", StringComparison.Ordinal) && !text.Contains(Environment.NewLine + "-", StringComparison.Ordinal)) + { + text = text.Remove(0, 2); + } + + if (text.StartsWith("-...", StringComparison.Ordinal) && lastLine != null && lastLine.EndsWith("...", StringComparison.Ordinal) && !text.Contains(Environment.NewLine + "-", StringComparison.Ordinal)) + { + text = text.Remove(0, 1); + } + } + + var lastLineNoTags = lastLine; + if (!string.IsNullOrEmpty(lastLineNoTags)) + { + lastLineNoTags = HtmlUtil.RemoveHtmlTags(lastLineNoTags); + lastLineNoTags = lastLineNoTags.Trim('♪', '♫', ' ', '"'); + if (lastLine.EndsWith(']') && lastLineNoTags.IndexOf('[') > 0 && + Utilities.CountTagInText(lastLineNoTags, '[') == 1 && Utilities.CountTagInText(lastLineNoTags, ']') == 1) + { + lastLineNoTags = lastLineNoTags.Substring(0, lastLineNoTags.IndexOf('[')).Trim(); + } + } + + if (string.IsNullOrEmpty(lastLine) || lastLineNoTags.HasSentenceEnding(Iso639Dash2LanguageCode.GetTwoLetterCodeFromThreeLetterCode(_threeLetterIsoLanguageName))) + { + lastLine = HtmlUtil.RemoveHtmlTags(lastLine); + var st = new StrippableText(text); + if (lastLine == null || !lastLine.EndsWith("...", StringComparison.Ordinal) && !EndsWithAbbreviation(lastLine, abbreviationList)) + { + if (st.StrippedText.Length > 0 && !char.IsUpper(st.StrippedText[0]) && !st.Pre.EndsWith('[') && !st.Pre.EndsWith('(') && + !st.Pre.Contains("...", StringComparison.Ordinal) && + !st.Pre.Contains('…')) + { + if (!HtmlUtil.StartsWithUrl(st.StrippedText)) + { + var uppercaseLetter = char.ToUpper(st.StrippedText[0]); + if (st.StrippedText.Length > 1 && uppercaseLetter == 'L' && (st.StrippedText[1] == ' ' || char.IsLower(st.StrippedText[1]))) + { + uppercaseLetter = 'I'; + } + if (st.StrippedText.Length == 1 && uppercaseLetter == 'L') + { + uppercaseLetter = 'I'; + } + + if ((st.StrippedText.StartsWith("lo ", StringComparison.Ordinal) || st.StrippedText.Equals("lo.", StringComparison.Ordinal)) && _threeLetterIsoLanguageName.Equals("ita", StringComparison.Ordinal)) + { + uppercaseLetter = 'I'; + } + + if ((st.StrippedText.StartsWith("k ", StringComparison.Ordinal) || st.StrippedText.StartsWith("m ", StringComparison.Ordinal) || st.StrippedText.StartsWith("n ", StringComparison.Ordinal) || st.StrippedText.StartsWith("r ", StringComparison.Ordinal) || st.StrippedText.StartsWith("s ", StringComparison.Ordinal) || st.StrippedText.StartsWith("t ", StringComparison.Ordinal)) && + st.Pre.EndsWith('\'') && _threeLetterIsoLanguageName.Equals("nld", StringComparison.Ordinal)) + { + uppercaseLetter = st.StrippedText[0]; + } + + if ((st.StrippedText.StartsWith("l-I'll ", StringComparison.Ordinal) || st.StrippedText.StartsWith("l-l'll ", StringComparison.Ordinal)) && _threeLetterIsoLanguageName.Equals("eng", StringComparison.Ordinal)) + { + uppercaseLetter = 'I'; + st.StrippedText = "I-I" + st.StrippedText.Remove(0, 3); + } + + st.StrippedText = uppercaseLetter + st.StrippedText.Substring(1); + text = st.Pre + st.StrippedText + st.Post; + } + } + } + } + + // lines ending with ". should often end at ... (of no other quotes exists near by) + if ((lastLine == null || !lastLine.Contains('"')) && + text.EndsWith("\".", StringComparison.Ordinal) && text.IndexOf('"') == text.LastIndexOf('"') && text.Length > 3) + { + var lastChar = text[text.Length - 3]; + if (!char.IsDigit(lastChar)) + { + int position = text.Length - 2; + text = text.Remove(position).Insert(position, "..."); + } + } + + // change '<number><space>1' to '<number>1' + if (text.Contains('1')) + { + var match = RegexNumber1.Match(text); + while (match.Success) + { + text = text.Remove(match.Index, 1); + match = RegexNumber1.Match(text, match.Index); + } + } + + // change '' to " + text = text.Replace("''", "\""); + + // change 'sequeI of' to 'sequel of' + if (text.Contains('I')) + { + var match = RegexUppercaseI.Match(text); + while (match.Success) + { + bool doFix = !(match.Index >= 1 && text.Substring(match.Index - 1).StartsWith("Mc", StringComparison.Ordinal)); + if (match.Index >= 2 && text.Substring(match.Index - 2).StartsWith("Mac", StringComparison.Ordinal)) + { + doFix = false; + } + + if (doFix) + { + text = text.Substring(0, match.Index + 1) + "l" + text.Substring(match.Index + 2); + } + + if (match.Index + 1 < text.Length) + { + match = RegexUppercaseI.Match(text, match.Index + 1); + } + else + { + break; // end while + } + } + } + + // change 'NlCE' to 'NICE' + if (text.Contains('l')) + { + var match = RegexLowercaseL.Match(text); + while (match.Success) + { + text = text.Substring(0, match.Index + 1) + "I" + text.Substring(match.Index + 2); + match = RegexLowercaseL.Match(text); + } + } + + if (text.EndsWith(". \"</i>", StringComparison.Ordinal)) + { + text = text.Remove(text.Length - 6, 1); + } + + if (text.Contains(". \"</i>" + Environment.NewLine, StringComparison.Ordinal)) + { + var idx = text.IndexOf(". \"</i>" + Environment.NewLine, StringComparison.Ordinal); + if (idx > 0) + { + text = text.Remove(idx + 1, 1); + } + } + + return text; + } + + public string FixOcrErrorViaLineReplaceList(string input) + { + return _ocrFixReplaceList.FixOcrErrorViaLineReplaceList(input); + } + + public string FixUnknownWordsViaGuessOrPrompt(out int wordsNotFound, string line, int index, Bitmap bitmap, bool autoFix, bool promptForFixingErrors, bool log, AutoGuessLevel autoGuess) + { + var localIgnoreWords = new List<string>(); + wordsNotFound = 0; + + if (promptForFixingErrors && line.Length == 1 && !IsWordKnownOrNumber(line, line)) + { + SpellCheckOcrTextResult res = SpellCheckOcrText(line, bitmap, line, localIgnoreWords); + if (res.FixedWholeLine || res.Fixed) + { + return res.Line; + } + + wordsNotFound++; + return line; + } + + if (_hunspell == null) + { + return line; + } + + string tempLine = line; + const string p = " ¡¿,.!?:;()[]{}+-$£\"„”“#&%…—♪\r\n"; + var trimChars = p.ToArray(); + bool hasAllUpperWord = false; + foreach (var w in HtmlUtil.RemoveHtmlTags(line, true).Split(' ', '\r', '\n')) + { + var word = w.Trim(trimChars); + if (word.Length > 1 && word == word.ToUpperInvariant()) + { + hasAllUpperWord = true; + break; + } + } + + foreach (string name in _nameMultiWordListAndWordsWithPeriods) + { + int start = tempLine.FastIndexOf(name); + if (start < 0 && hasAllUpperWord) + { + start = tempLine.FastIndexOf(name.ToUpperInvariant()); + } + if (start == 0 || (start > 0 && p.Contains(tempLine[start - 1]))) + { + int end = start + name.Length; + if (end == tempLine.Length || p.Contains(tempLine[end])) + { + tempLine = tempLine.Remove(start, name.Length); + } + } + } + + int minLength = 2; + if (Configuration.Settings.Tools.CheckOneLetterWords) + { + minLength = 1; + } + + var words = new List<string>(); + var splitChars = SpellCheckWordLists.SplitChars.Where(ch => ch != '/' && ch != '|').ToArray(); + foreach (var w in tempLine + .Replace("<i>", string.Empty).Replace("</i>", string.Empty) + .Replace("<b>", string.Empty).Replace("</b>", string.Empty) + .Replace("<u>", string.Empty).Replace("</u>", string.Empty) + .Split(splitChars)) + { + words.Add(w.Trim(trimChars)); + } + + for (int i = 0; i < words.Count && i < 1000; i++) + { + string word = words[i].TrimStart('\''); + string wordNotEndTrimmed = word; + word = word.TrimEnd('\''); + if (!IsWordKnownOrNumber(word, line) && !localIgnoreWords.Contains(word)) + { + var correct = false; + if (word.Length > 1) + { + if (_wordSpellOkList.Contains(word)) + { + correct = true; + } + else if (DoSpell(word)) + { + correct = true; + _wordSpellOkList.Add(word); + } + + if (!correct) + { + correct = word.Length > minLength + 1 && DoSpell(word.Trim('\'')); + } + + if (!correct && word.Length > 3 && !word.EndsWith("ss", StringComparison.Ordinal) && !string.IsNullOrEmpty(_threeLetterIsoLanguageName) && + (_threeLetterIsoLanguageName == "eng" || _threeLetterIsoLanguageName == "dan" || _threeLetterIsoLanguageName == "swe" || _threeLetterIsoLanguageName == "nld")) + { + correct = DoSpell(word.TrimEnd('s')); + } + } + else + { + correct = !Configuration.Settings.Tools.CheckOneLetterWords; // hunspell allows too many single letter words + } + + if (!correct && _userWordList.Contains(word)) + { + correct = true; + } + + if (!correct && !line.Contains(word, StringComparison.Ordinal)) + { + correct = true; // already fixed + } + + if (!correct && Configuration.Settings.Tools.SpellCheckEnglishAllowInQuoteAsIng && wordNotEndTrimmed.EndsWith('\'') && + SpellCheckDictionaryName.StartsWith("en_", StringComparison.Ordinal) && word.EndsWith("in", StringComparison.OrdinalIgnoreCase)) + { + correct = DoSpell(word + "g"); + } + + if (_threeLetterIsoLanguageName == "eng" && (word.Equals("a", StringComparison.OrdinalIgnoreCase) || word == "I")) + { + correct = true; + } + else if (_threeLetterIsoLanguageName == "dan" && word.Equals("i", StringComparison.OrdinalIgnoreCase)) + { + correct = true; + } + + if (!correct && _threeLetterIsoLanguageName.Equals("ara", StringComparison.Ordinal)) + { + var trimmed = word.Trim('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', ',', '،', '؟', '»'); + if (trimmed != word) + { + if (_userWordList.Contains(trimmed)) + { + correct = true; + } + else + { + correct = DoSpell(trimmed); + } + } + } + + if (!correct) + { + //look for match via dash'ed word, e.g. sci-fi + string dashedWord = GetDashedWordBefore(word, line, words, i); + if (!string.IsNullOrEmpty(dashedWord)) + { + correct = IsWordKnownOrNumber(dashedWord, line); + if (!correct) + { + correct = DoSpell(dashedWord); + } + } + if (!correct) + { + dashedWord = GetDashedWordAfter(word, line, words, i); + if (!string.IsNullOrEmpty(dashedWord)) + { + correct = IsWordKnownOrNumber(dashedWord, line); + if (!correct) + { + correct = DoSpell(dashedWord); + } + } + } + + if (!correct && _spellCheckWordLists.HasUserWord("-" + word)) + { + correct = true; + } + } + + if (!correct && word.Contains('/') && !word.Contains("//", StringComparison.Ordinal)) + { + correct = word.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries) + .All(w => w.Length > 2 && (DoSpell(w) || IsWordKnownOrNumber(word, line))); + } + + if (!correct && word.Length == 1 && i < words.Count - 1 && words[i + 1].Length == 1) + { + var abbreviation = word + "." + words[i + 1] + "."; + if (_abbreviationList.Contains(abbreviation) && line.Contains(abbreviation, StringComparison.Ordinal)) + { + correct = true; + words[i + 1] = string.Empty; + } + else if (i < words.Count - 2 && words[i + 2].Length == 1) + { + abbreviation = word + "." + words[i + 1] + "." + words[i + 2] + "."; + if (_abbreviationList.Contains(abbreviation) && line.Contains(abbreviation, StringComparison.Ordinal)) + { + correct = true; + words[i + 1] = string.Empty; + words[i + 2] = string.Empty; + } + } + } + + if (word.Length == 0) + { + correct = true; + } + + if (!correct) + { + wordsNotFound++; + if (log) + { + string nf = word; + if (nf.StartsWith("<i>", StringComparison.Ordinal)) + { + nf = nf.Remove(0, 3); + } + + if (nf.Trim().Length > 0) + { + UnknownWordsFound.Add(new UnknownWord(index, nf)); + } + } + + if (autoFix && autoGuess != AutoGuessLevel.None) + { + var guesses = new List<string>(); + + // Name starting with "l" instead of 'I' + if (word.StartsWith('l') && word.Length > 3 && !_nameList.Contains(word)) + { + var w = "I" + word.Substring(1); + if (_nameList.Contains(w)) + { + guesses.Add(w); + } + } + + if (!correct && autoFix && word.Length > 3 && char.IsUpper(word[0]) && !_nameList.Contains(word)) + { + var rest = word.Substring(1); + if (rest != rest.ToUpperInvariant()) + { + var newWord = word[0] + rest.ToLowerInvariant(); + if (_nameList.Contains(newWord)) + { + guesses.Add(newWord); + } + } + } + + var wordWithVerticalLine = word.Replace("|", "l"); + if (word.Length > 3 && DoSpell(wordWithVerticalLine)) + { + if (word == word.ToUpperInvariant()) + { + wordWithVerticalLine = wordWithVerticalLine.ToUpperInvariant(); + } + + guesses.Add(wordWithVerticalLine); + } + + if (word.Length > 4 && autoGuess == AutoGuessLevel.Aggressive) + { + guesses.AddRange((List<string>)_ocrFixReplaceList.CreateGuessesFromLetters(word)); + + if (word[0] == 'L') + { + guesses.Add("I" + word.Substring(1)); + } + + if (word.Contains('$')) + { + guesses.Add(word.Replace("$", "s")); + } + + if (word.Contains('l') && word.RemoveChar('l').Length > 3) + { + var lowerLToUpperI = word.Replace('l', 'I'); + if (lowerLToUpperI == lowerLToUpperI.ToUpperInvariant()) + { + guesses.Add(lowerLToUpperI); + } + } + + string wordWithCasingChanged = GetWordWithDominatedCasing(word); + if (DoSpell(word.ToLowerInvariant())) + { + guesses.Insert(0, wordWithCasingChanged); + } + } + else if (Configuration.Settings.Tools.OcrFixUseHardcodedRules) + { + if (word.Length > 2 && word[0] == 'L') + { + guesses.Add("I" + word.Substring(1)); + } + + if (word.Length > 2 && word[0] == 'I' && char.IsLower(word[1])) + { + guesses.Add("l" + word.Substring(1)); + } + + if (i == 0) + { + guesses.Add(word.Replace(@"\/", "V")); + } + else + { + guesses.Add(word.Replace(@"\/", "v")); + } + + guesses.Add(word.Replace("fi", "fi")); + guesses.Add(word.Replace("fi", "fj")); + guesses.Add(word.Replace("fl", "fl")); + if (word.Contains('$')) + { + guesses.Add(word.Replace("$", "s")); + } + + if (!word.EndsWith('€') && !word.StartsWith('€')) + { + guesses.Add(word.Replace("€", "e")); + } + + guesses.Add(word.Replace("/", "l")); + guesses.Add(word.Replace(")/", "y")); + } + foreach (string guess in guesses) + { + if (!(guess.Length == 2 && guess[1] == ' ') && IsWordOrWordsCorrect(guess)) + { + string replacedLine = OcrFixReplaceList.ReplaceWord(line, word, guess); + if (replacedLine != line) + { + if (log) + { + AutoGuessesUsed.Add(new AutoGuess(index, word, guess, line)); + } + + line = replacedLine; + wordsNotFound--; + if (log && UnknownWordsFound.Count > 0) + { + UnknownWordsFound.RemoveAt(UnknownWordsFound.Count - 1); + } + + correct = true; + break; + } + } + } + } + if (!correct && promptForFixingErrors) + { + var suggestions = new List<string>(); + + if ((word == "Lt's" || word == "Lt'S") && SpellCheckDictionaryName.StartsWith("en_", StringComparison.Ordinal)) + { + suggestions.Add("It's"); + } + else + { + if (word.ToUpperInvariant() != "LT'S" && word.ToUpperInvariant() != "SOX'S") // TODO: Get fixed nhunspell + { + suggestions = DoSuggest(word); // 0.9.6 fails on "Lt'S" + } + } + + if (word.StartsWith("<i>", StringComparison.Ordinal)) + { + word = word.Remove(0, 3); + } + + if (word.EndsWith("</i>", StringComparison.Ordinal)) + { + word = word.Remove(word.Length - 4, 4); + } + + SpellCheckOcrTextResult res = SpellCheckOcrText(line, bitmap, word, suggestions); + if (Abort) + { + return null; + } + if (res.FixedWholeLine) + { + return res.Line; + } + if (res.Fixed) + { + localIgnoreWords.Add(word); + line = res.Line; + wordsNotFound--; + } + } + } + } + } + return line; + } + + private static string GetDashedWordBefore(string word, string line, List<string> words, int index) + { + if (index > 0 && line.Contains(words[index - 1] + "-" + word, StringComparison.Ordinal)) + { + return HtmlUtil.RemoveOpenCloseTags(words[index - 1] + "-" + word, HtmlUtil.TagItalic); + } + + return null; + } + + private static string GetDashedWordAfter(string word, string line, List<string> words, int index) + { + if (index < words.Count - 1 && line.Contains(word + "-" + words[index + 1].Replace("</i>", string.Empty), StringComparison.Ordinal)) + { + return HtmlUtil.RemoveOpenCloseTags(word + "-" + words[index + 1], HtmlUtil.TagItalic); + } + + return null; + } + + private static string GetWordWithDominatedCasing(string word) + { + int lowercase = 0; + int uppercase = 0; + for (int i = 0; i < word.Length; i++) + { + var ch = word[i]; + if (char.IsLower(ch)) + { + lowercase++; + } + else if (char.IsUpper(ch)) + { + uppercase++; + } + } + if (uppercase > lowercase) + { + return word.ToUpperInvariant(); + } + + return word.ToLowerInvariant(); + } + + /// <summary> + /// SpellCheck for OCR + /// </summary> + /// <returns>True, if word is fixed</returns> + private SpellCheckOcrTextResult SpellCheckOcrText(string line, Bitmap bitmap, string word, List<string> suggestions) + { + var result = new SpellCheckOcrTextResult { Fixed = false, FixedWholeLine = false, Line = null, Word = null }; + _spellCheck.Initialize(word, suggestions, line, bitmap, IsBinaryImageCompareOrNOcr); + _spellCheck.ShowDialog(_parentForm); + LastAction = _spellCheck.ActionResult; + switch (_spellCheck.ActionResult) + { + case OcrSpellCheck.Action.Abort: + Abort = true; + break; + case OcrSpellCheck.Action.AddToUserDictionary: + if (_userWordListXmlFileName != null) + { + Utilities.AddToUserDictionary(_spellCheck.Word.Trim().ToLowerInvariant(), _fiveLetterWordListLanguageName); + _userWordList.Add(_spellCheck.Word.Trim().ToLowerInvariant()); + } + result.Word = _spellCheck.Word; + result.Fixed = true; + result.Line = line; + if (word == result.Word) + { + return result; + } + + break; + case OcrSpellCheck.Action.AddToNames: + case OcrSpellCheck.Action.AddToNamesOnly: + result.Word = _spellCheck.Word; + result.Fixed = true; + try + { + string s = _spellCheck.Word.Trim(); + _nameListObj?.Add(s); + if (s.Contains(' ')) + { + _nameMultiWordList.Add(s); + } + else + { + _nameList.Add(s); + _nameListUppercase.Add(s.ToUpperInvariant()); + if (_fiveLetterWordListLanguageName.StartsWith("en", StringComparison.Ordinal)) + { + if (!s.EndsWith('s')) + { + _nameListWithApostrophe.Add(s + "'s"); + } + else + { + _nameListWithApostrophe.Add(s + "'"); + } + } + } + } + catch + { + _wordSkipList.Add(_spellCheck.Word); + } + result.Line = line; + if (word == result.Word || _spellCheck.ActionResult == OcrSpellCheck.Action.AddToNamesOnly) + { + return result; + } + + break; + case OcrSpellCheck.Action.AlwaysUseSuggestion: + try + { + _ocrFixReplaceList.AddWordOrPartial(word, _spellCheck.Word); + if (!word.Contains(' ')) + { + _spellCheckWordLists?.UseAlwaysListAdd(word, _spellCheck.Word); + } + } + catch (Exception exception) + { + MessageBox.Show(exception + Environment.NewLine + exception.StackTrace); + _wordSkipList.Add(word); + } + result.Fixed = true; + result.Word = _spellCheck.Word; + break; + case OcrSpellCheck.Action.ChangeAndSave: + try + { + _ocrFixReplaceList.AddWordOrPartial(word, _spellCheck.Word); + } + catch (Exception exception) + { + MessageBox.Show(exception + Environment.NewLine + exception.StackTrace); + _wordSkipList.Add(word); + } + result.Fixed = true; + result.Word = _spellCheck.Word; + break; + case OcrSpellCheck.Action.ChangeOnce: + result.Fixed = true; + result.Word = _spellCheck.Word; + break; + case OcrSpellCheck.Action.ChangeWholeText: + result.Line = _spellCheck.Paragraph; + result.FixedWholeLine = true; + break; + case OcrSpellCheck.Action.ChangeAllWholeText: + _ocrFixReplaceList.AddToWholeLineList(_spellCheck.OriginalWholeText, _spellCheck.Paragraph); + result.Line = _spellCheck.Paragraph; + result.FixedWholeLine = true; + break; + case OcrSpellCheck.Action.SkipAll: + _wordSkipList.Add(_spellCheck.Word); + _wordSkipList.Add(_spellCheck.Word.ToUpperInvariant()); + if (_spellCheck.Word.Length > 1) + { + _wordSkipList.Add(char.ToUpper(_spellCheck.Word[0]) + _spellCheck.Word.Substring(1)); + } + + break; + case OcrSpellCheck.Action.SkipOnce: + break; + case OcrSpellCheck.Action.SkipWholeText: + result.Line = line; + result.FixedWholeLine = true; + break; + case OcrSpellCheck.Action.UseSuggestion: + result.Word = _spellCheck.Word; + result.Fixed = true; + break; + case OcrSpellCheck.Action.InspectCompareMatches: + Abort = true; + break; + } + if (result.Fixed) + { + result.Line = OcrFixReplaceList.ReplaceWord(line, word, result.Word); + } + return result; + } + + public bool DoSpell(string word) + { + return _hunspell.Spell(word); + } + + public List<string> DoSuggest(string word) + { + return _hunspell.Suggest(word); + } + + public bool IsWordOrWordsCorrect(string word) + { + foreach (string s in word.Split(' ')) + { + if (!DoSpell(s)) + { + if (IsWordKnownOrNumber(word, word)) + { + return true; + } + + if (s.Length > 10 && s.Contains('/')) + { + string[] ar = s.Split('/'); + if (ar.Length == 2) + { + if (ar[0].Length > 3 && ar[1].Length > 3) + { + string a = ar[0]; + if (a == a.ToUpperInvariant()) + { + a = a[0] + a.Substring(1).ToLowerInvariant(); + } + + string b = ar[0]; + if (b == b.ToUpperInvariant()) + { + b = b[0] + b.Substring(1).ToLowerInvariant(); + } + + if ((DoSpell(a) || IsWordKnownOrNumber(a, word)) && + (DoSpell(b) || IsWordKnownOrNumber(b, word))) + { + return true; + } + } + } + } + return false; + } + } + return true; + } + + public bool IsWordKnownOrNumber(string word, string line) + { + if (double.TryParse(word.TrimStart('\'').Replace("$", string.Empty).Replace("£", string.Empty).Replace("¢", string.Empty), out _)) + { + return true; + } + + if (_wordSkipList.Contains(word)) + { + return true; + } + + if (_nameList.Contains(word.Trim('\''))) + { + return true; + } + + if (_nameListUppercase.Contains(word.Trim('\''))) + { + return true; + } + + if (_userWordList.Contains(word.ToLowerInvariant())) + { + return true; + } + + if (_userWordList.Contains(word.Trim('\'').ToLowerInvariant())) + { + return true; + } + + if (word.Length > 2 && _nameListUppercase.Contains(word)) + { + return true; + } + + if (word.Length > 2 && _nameListWithApostrophe.Contains(word)) + { + return true; + } + + if (_nameListObj != null && _nameListObj.IsInNamesMultiWordList(line, word)) + { + return true; + } + + return false; + } + + public int CountUnknownWordsViaDictionary(string line, out int numberOfCorrectWords) + { + numberOfCorrectWords = 0; + if (_hunspell == null) + { + return 0; + } + + int minLength = 2; + if (Configuration.Settings.Tools.CheckOneLetterWords) + { + minLength = 1; + } + + int wordsNotFound = 0; + var words = HtmlUtil.RemoveOpenCloseTags(line, HtmlUtil.TagItalic).Split(" \r\n\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < words.Length; i++) + { + string word = words[i].Trim(SpellCheckWordLists.SplitChars.ToArray()); + if (word.Length >= minLength) + { + if (!IsWordKnownOrNumber(word, line)) + { + bool correct = word.Length > 1 && _hunspell.Spell(word); + if (!correct) + { + correct = word.Length > 2 && _hunspell.Spell(word.Trim('\'')); + } + + if (!correct && word.Length == 1 && _threeLetterIsoLanguageName == "eng" && (word == "I" || word == "A" || word == "a")) + { + correct = true; + } + + if (correct) + { + numberOfCorrectWords++; + } + else + { + wordsNotFound++; + } + } + else if (word.Length > 3) + { + numberOfCorrectWords++; + } + } + } + return wordsNotFound; + } + + public void Dispose() + { + if (_hunspell != null) + { + _hunspell.Dispose(); + _hunspell = null; + } + if (_spellCheck != null) + { + _spellCheck.Dispose(); + _spellCheck = null; + } + } + + } +} diff --git a/src/Logic/Ocr/OcrImage.cs b/src/ui/Logic/Ocr/OcrImage.cs similarity index 96% rename from src/Logic/Ocr/OcrImage.cs rename to src/ui/Logic/Ocr/OcrImage.cs index 6df23a5da..97eed1552 100644 --- a/src/Logic/Ocr/OcrImage.cs +++ b/src/ui/Logic/Ocr/OcrImage.cs @@ -1,37 +1,37 @@ -using System.Drawing; - -namespace Nikse.SubtitleEdit.Logic.Ocr -{ - public class OcrImage - { - public bool Italic { get; set; } - public Bitmap Bmp { get; set; } - - public double[] GetTrainingData(int size) - { - int i = 0; - var data = new double[size]; - for (int y = 0; y < Bmp.Height; y++) - { - for (int x = 0; x < Bmp.Width; x++) - { - Color c = Bmp.GetPixel(x, y); - if (i < size) - { - if (c == Color.Transparent) - { - data[i] = -0.5; - } - else - { - int value = c.R + c.R + c.B; - data[i] = value / 766.0; - } - } - i++; - } - } - return data; - } - } -} +using System.Drawing; + +namespace Nikse.SubtitleEdit.Logic.Ocr +{ + public class OcrImage + { + public bool Italic { get; set; } + public Bitmap Bmp { get; set; } + + public double[] GetTrainingData(int size) + { + int i = 0; + var data = new double[size]; + for (int y = 0; y < Bmp.Height; y++) + { + for (int x = 0; x < Bmp.Width; x++) + { + Color c = Bmp.GetPixel(x, y); + if (i < size) + { + if (c == Color.Transparent) + { + data[i] = -0.5; + } + else + { + int value = c.R + c.R + c.B; + data[i] = value / 766.0; + } + } + i++; + } + } + return data; + } + } +} diff --git a/src/Logic/Ocr/PreprocessingSettings.cs b/src/ui/Logic/Ocr/PreprocessingSettings.cs similarity index 100% rename from src/Logic/Ocr/PreprocessingSettings.cs rename to src/ui/Logic/Ocr/PreprocessingSettings.cs diff --git a/src/Logic/Ocr/SpellCheckOcrTextResult.cs b/src/ui/Logic/Ocr/SpellCheckOcrTextResult.cs similarity index 96% rename from src/Logic/Ocr/SpellCheckOcrTextResult.cs rename to src/ui/Logic/Ocr/SpellCheckOcrTextResult.cs index 6f91e3bb2..0c0e6d726 100644 --- a/src/Logic/Ocr/SpellCheckOcrTextResult.cs +++ b/src/ui/Logic/Ocr/SpellCheckOcrTextResult.cs @@ -1,10 +1,10 @@ -namespace Nikse.SubtitleEdit.Logic.Ocr -{ - public class SpellCheckOcrTextResult - { - public bool Fixed { get; set; } - public bool FixedWholeLine { get; set; } - public string Word { get; set; } - public string Line { get; set; } - } -} +namespace Nikse.SubtitleEdit.Logic.Ocr +{ + public class SpellCheckOcrTextResult + { + public bool Fixed { get; set; } + public bool FixedWholeLine { get; set; } + public string Word { get; set; } + public string Line { get; set; } + } +} diff --git a/src/Logic/Ocr/Tesseract/TesseractMultiRunner.cs b/src/ui/Logic/Ocr/Tesseract/TesseractMultiRunner.cs similarity index 100% rename from src/Logic/Ocr/Tesseract/TesseractMultiRunner.cs rename to src/ui/Logic/Ocr/Tesseract/TesseractMultiRunner.cs diff --git a/src/Logic/Ocr/Tesseract/TesseractMultiThreadRunner.cs b/src/ui/Logic/Ocr/Tesseract/TesseractMultiThreadRunner.cs similarity index 100% rename from src/Logic/Ocr/Tesseract/TesseractMultiThreadRunner.cs rename to src/ui/Logic/Ocr/Tesseract/TesseractMultiThreadRunner.cs diff --git a/src/Logic/Ocr/Tesseract/TesseractRunner.cs b/src/ui/Logic/Ocr/Tesseract/TesseractRunner.cs similarity index 100% rename from src/Logic/Ocr/Tesseract/TesseractRunner.cs rename to src/ui/Logic/Ocr/Tesseract/TesseractRunner.cs diff --git a/src/Logic/Ocr/Tesseract/TesseractThreadRunner.cs b/src/ui/Logic/Ocr/Tesseract/TesseractThreadRunner.cs similarity index 100% rename from src/Logic/Ocr/Tesseract/TesseractThreadRunner.cs rename to src/ui/Logic/Ocr/Tesseract/TesseractThreadRunner.cs diff --git a/src/Logic/RtfTextConverterRichTextBox.cs b/src/ui/Logic/RtfTextConverterRichTextBox.cs similarity index 100% rename from src/Logic/RtfTextConverterRichTextBox.cs rename to src/ui/Logic/RtfTextConverterRichTextBox.cs diff --git a/src/Logic/SceneChangesGenerator.cs b/src/ui/Logic/SceneChangesGenerator.cs similarity index 100% rename from src/Logic/SceneChangesGenerator.cs rename to src/ui/Logic/SceneChangesGenerator.cs diff --git a/src/Logic/SpellCheck/Hunspell.cs b/src/ui/Logic/SpellCheck/Hunspell.cs similarity index 96% rename from src/Logic/SpellCheck/Hunspell.cs rename to src/ui/Logic/SpellCheck/Hunspell.cs index 3ce25b979..cf965e0ae 100644 --- a/src/Logic/SpellCheck/Hunspell.cs +++ b/src/ui/Logic/SpellCheck/Hunspell.cs @@ -1,53 +1,53 @@ -using Nikse.SubtitleEdit.Core; -using System; -using System.Collections.Generic; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic.SpellCheck -{ - public abstract class Hunspell : IDisposable - { - public static Hunspell GetHunspell(string dictionary) - { - // Finnish uses Voikko (not available via hunspell) - if (dictionary.EndsWith("fi_fi", StringComparison.OrdinalIgnoreCase)) - { - return new VoikkoSpellCheck(Configuration.BaseDirectory, Configuration.DictionariesDirectory); - } - - if (Configuration.IsRunningOnLinux) - { - return new LinuxHunspell(dictionary + ".aff", dictionary + ".dic"); - } - - if (Configuration.IsRunningOnMac) - { - return new MacHunspell(dictionary + ".aff", dictionary + ".dic"); - } - - return new WindowsHunspell(dictionary + ".aff", dictionary + ".dic"); - } - - public abstract bool Spell(string word); - public abstract List<string> Suggest(string word); - - public virtual void Dispose() - { - } - - protected void AddIShouldBeLowercaseLSuggestion(List<string> suggestions, string word) - { - if (suggestions == null) - { - return; - } - - // "I" can often be an ocr bug - should really be "l" - if (word.Length > 1 && word.StartsWith('I') && !suggestions.Contains("l" + word.Substring(1)) && Spell("l" + word.Substring(1))) - { - suggestions.Add("l" + word.Substring(1)); - } - } - - } -} +using Nikse.SubtitleEdit.Core; +using System; +using System.Collections.Generic; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic.SpellCheck +{ + public abstract class Hunspell : IDisposable + { + public static Hunspell GetHunspell(string dictionary) + { + // Finnish uses Voikko (not available via hunspell) + if (dictionary.EndsWith("fi_fi", StringComparison.OrdinalIgnoreCase)) + { + return new VoikkoSpellCheck(Configuration.BaseDirectory, Configuration.DictionariesDirectory); + } + + if (Configuration.IsRunningOnLinux) + { + return new LinuxHunspell(dictionary + ".aff", dictionary + ".dic"); + } + + if (Configuration.IsRunningOnMac) + { + return new MacHunspell(dictionary + ".aff", dictionary + ".dic"); + } + + return new WindowsHunspell(dictionary + ".aff", dictionary + ".dic"); + } + + public abstract bool Spell(string word); + public abstract List<string> Suggest(string word); + + public virtual void Dispose() + { + } + + protected void AddIShouldBeLowercaseLSuggestion(List<string> suggestions, string word) + { + if (suggestions == null) + { + return; + } + + // "I" can often be an ocr bug - should really be "l" + if (word.Length > 1 && word.StartsWith('I') && !suggestions.Contains("l" + word.Substring(1)) && Spell("l" + word.Substring(1))) + { + suggestions.Add("l" + word.Substring(1)); + } + } + + } +} diff --git a/src/Logic/SpellCheck/LinuxHunspell.cs b/src/ui/Logic/SpellCheck/LinuxHunspell.cs similarity index 97% rename from src/Logic/SpellCheck/LinuxHunspell.cs rename to src/ui/Logic/SpellCheck/LinuxHunspell.cs index c4cdc7257..84bd22851 100644 --- a/src/Logic/SpellCheck/LinuxHunspell.cs +++ b/src/ui/Logic/SpellCheck/LinuxHunspell.cs @@ -1,82 +1,82 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; - -namespace Nikse.SubtitleEdit.Logic.SpellCheck -{ - public class LinuxHunspell : Hunspell - { - private IntPtr _hunspellHandle = IntPtr.Zero; - - public LinuxHunspell(string affDirectory, string dicDictory) - { - //Also search - /usr/share/hunspell - try - { - _hunspellHandle = NativeMethods.Hunspell_create(affDirectory, dicDictory); - } - catch - { - System.Windows.Forms.MessageBox.Show("Unable to start hunspell spell checker - make sure hunspell is installed!" + Environment.NewLine + - "E.g. install package 'libhunspell-dev' for Ubuntu, 'hunspell-devel' for Red Hat"); - throw; - } - } - - public override bool Spell(string word) - { - return NativeMethods.Hunspell_spell(_hunspellHandle, word) != 0; - } - - public override List<string> Suggest(string word) - { - IntPtr pointerToAddressStringArray = Marshal.AllocHGlobal(IntPtr.Size); - int resultCount = NativeMethods.Hunspell_suggest(_hunspellHandle, pointerToAddressStringArray, word); - IntPtr addressStringArray = Marshal.ReadIntPtr(pointerToAddressStringArray); - List<string> results = new List<string>(); - for (int i = 0; i < resultCount; i++) - { - IntPtr addressCharArray = Marshal.ReadIntPtr(addressStringArray, i * IntPtr.Size); - string suggestion = Marshal.PtrToStringAuto(addressCharArray); - if (!string.IsNullOrEmpty(suggestion)) - { - results.Add(suggestion); - } - } - NativeMethods.Hunspell_free_list(_hunspellHandle, pointerToAddressStringArray, resultCount); - Marshal.FreeHGlobal(pointerToAddressStringArray); - - return results; - } - - ~LinuxHunspell() - { - Dispose(false); - } - - private void ReleaseUnmanagedResources() - { - if (_hunspellHandle != IntPtr.Zero) - { - NativeMethods.Hunspell_destroy(_hunspellHandle); - _hunspellHandle = IntPtr.Zero; - } - } - - public override void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - //ReleaseManagedResources(); - } - ReleaseUnmanagedResources(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Nikse.SubtitleEdit.Logic.SpellCheck +{ + public class LinuxHunspell : Hunspell + { + private IntPtr _hunspellHandle = IntPtr.Zero; + + public LinuxHunspell(string affDirectory, string dicDictory) + { + //Also search - /usr/share/hunspell + try + { + _hunspellHandle = NativeMethods.Hunspell_create(affDirectory, dicDictory); + } + catch + { + System.Windows.Forms.MessageBox.Show("Unable to start hunspell spell checker - make sure hunspell is installed!" + Environment.NewLine + + "E.g. install package 'libhunspell-dev' for Ubuntu, 'hunspell-devel' for Red Hat"); + throw; + } + } + + public override bool Spell(string word) + { + return NativeMethods.Hunspell_spell(_hunspellHandle, word) != 0; + } + + public override List<string> Suggest(string word) + { + IntPtr pointerToAddressStringArray = Marshal.AllocHGlobal(IntPtr.Size); + int resultCount = NativeMethods.Hunspell_suggest(_hunspellHandle, pointerToAddressStringArray, word); + IntPtr addressStringArray = Marshal.ReadIntPtr(pointerToAddressStringArray); + List<string> results = new List<string>(); + for (int i = 0; i < resultCount; i++) + { + IntPtr addressCharArray = Marshal.ReadIntPtr(addressStringArray, i * IntPtr.Size); + string suggestion = Marshal.PtrToStringAuto(addressCharArray); + if (!string.IsNullOrEmpty(suggestion)) + { + results.Add(suggestion); + } + } + NativeMethods.Hunspell_free_list(_hunspellHandle, pointerToAddressStringArray, resultCount); + Marshal.FreeHGlobal(pointerToAddressStringArray); + + return results; + } + + ~LinuxHunspell() + { + Dispose(false); + } + + private void ReleaseUnmanagedResources() + { + if (_hunspellHandle != IntPtr.Zero) + { + NativeMethods.Hunspell_destroy(_hunspellHandle); + _hunspellHandle = IntPtr.Zero; + } + } + + public override void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + //ReleaseManagedResources(); + } + ReleaseUnmanagedResources(); + } + + } +} diff --git a/src/Logic/SpellCheck/MacHunspell.cs b/src/ui/Logic/SpellCheck/MacHunspell.cs similarity index 96% rename from src/Logic/SpellCheck/MacHunspell.cs rename to src/ui/Logic/SpellCheck/MacHunspell.cs index c390cbff6..5c0288225 100644 --- a/src/Logic/SpellCheck/MacHunspell.cs +++ b/src/ui/Logic/SpellCheck/MacHunspell.cs @@ -1,74 +1,74 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; - -namespace Nikse.SubtitleEdit.Logic.SpellCheck -{ - public class MacHunspell : Hunspell - { - - private IntPtr _hunspellHandle; - - public MacHunspell(string affDirectory, string dicDictory) - { - //Also search - /usr/share/hunspell - _hunspellHandle = NativeMethods.Hunspell_create(affDirectory, dicDictory); - } - - public override bool Spell(string word) - { - return NativeMethods.Hunspell_spell(_hunspellHandle, word) != 0; - } - - public override List<string> Suggest(string word) - { - IntPtr pointerToAddressStringArray = Marshal.AllocHGlobal(IntPtr.Size); - int resultCount = NativeMethods.Hunspell_suggest(_hunspellHandle, pointerToAddressStringArray, word); - IntPtr addressStringArray = Marshal.ReadIntPtr(pointerToAddressStringArray); - List<string> results = new List<string>(); - for (int i = 0; i < resultCount; i++) - { - IntPtr addressCharArray = Marshal.ReadIntPtr(addressStringArray, i * IntPtr.Size); - string suggestion = Marshal.PtrToStringAuto(addressCharArray); - if (string.IsNullOrEmpty(suggestion)) - { - results.Add(suggestion); - } - } - NativeMethods.Hunspell_free_list(_hunspellHandle, pointerToAddressStringArray, resultCount); - Marshal.FreeHGlobal(pointerToAddressStringArray); - - return results; - } - - ~MacHunspell() - { - Dispose(false); - } - - private void ReleaseUnmanagedResources() - { - if (_hunspellHandle != IntPtr.Zero) - { - NativeMethods.Hunspell_destroy(_hunspellHandle); - _hunspellHandle = IntPtr.Zero; - } - } - - public override void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - //ReleaseManagedResources(); - } - ReleaseUnmanagedResources(); - } - - } -} +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Nikse.SubtitleEdit.Logic.SpellCheck +{ + public class MacHunspell : Hunspell + { + + private IntPtr _hunspellHandle; + + public MacHunspell(string affDirectory, string dicDictory) + { + //Also search - /usr/share/hunspell + _hunspellHandle = NativeMethods.Hunspell_create(affDirectory, dicDictory); + } + + public override bool Spell(string word) + { + return NativeMethods.Hunspell_spell(_hunspellHandle, word) != 0; + } + + public override List<string> Suggest(string word) + { + IntPtr pointerToAddressStringArray = Marshal.AllocHGlobal(IntPtr.Size); + int resultCount = NativeMethods.Hunspell_suggest(_hunspellHandle, pointerToAddressStringArray, word); + IntPtr addressStringArray = Marshal.ReadIntPtr(pointerToAddressStringArray); + List<string> results = new List<string>(); + for (int i = 0; i < resultCount; i++) + { + IntPtr addressCharArray = Marshal.ReadIntPtr(addressStringArray, i * IntPtr.Size); + string suggestion = Marshal.PtrToStringAuto(addressCharArray); + if (string.IsNullOrEmpty(suggestion)) + { + results.Add(suggestion); + } + } + NativeMethods.Hunspell_free_list(_hunspellHandle, pointerToAddressStringArray, resultCount); + Marshal.FreeHGlobal(pointerToAddressStringArray); + + return results; + } + + ~MacHunspell() + { + Dispose(false); + } + + private void ReleaseUnmanagedResources() + { + if (_hunspellHandle != IntPtr.Zero) + { + NativeMethods.Hunspell_destroy(_hunspellHandle); + _hunspellHandle = IntPtr.Zero; + } + } + + public override void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + //ReleaseManagedResources(); + } + ReleaseUnmanagedResources(); + } + + } +} diff --git a/src/Logic/SpellCheck/VoikkoSpellCheck.cs b/src/ui/Logic/SpellCheck/VoikkoSpellCheck.cs similarity index 96% rename from src/Logic/SpellCheck/VoikkoSpellCheck.cs rename to src/ui/Logic/SpellCheck/VoikkoSpellCheck.cs index 0f341e74e..2cb63a974 100644 --- a/src/Logic/SpellCheck/VoikkoSpellCheck.cs +++ b/src/ui/Logic/SpellCheck/VoikkoSpellCheck.cs @@ -1,214 +1,214 @@ -using Nikse.SubtitleEdit.Core; -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic.SpellCheck -{ - public class VoikkoSpellCheck : Hunspell - { - - // Voikko functions in dll - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr VoikkoInit(ref IntPtr error, byte[] languageCode, byte[] path); - private VoikkoInit _voikkoInit; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void VoikkoTerminate(IntPtr libVlc); - private VoikkoTerminate _voikkoTerminate; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate Int32 VoikkoSpell(IntPtr handle, byte[] word); - private VoikkoSpell _voikkoSpell; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr VoikkoSuggest(IntPtr handle, byte[] word); - private VoikkoSuggest _voikkoSuggest; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr VoikkoFreeCstrArray(IntPtr array); - private VoikkoFreeCstrArray _voikkoFreeCstrArray; - - private IntPtr _libDll = IntPtr.Zero; - private IntPtr _libVoikko; - - private static string N2S(IntPtr ptr) - { - if (ptr == IntPtr.Zero) - { - return null; - } - - var bytes = new List<byte>(); - unsafe - { - for (byte* p = (byte*)ptr; *p != 0; p++) - { - bytes.Add(*p); - } - } - return N2S(bytes.ToArray()); - } - - private static string N2S(byte[] bytes) - { - return bytes == null ? null : Encoding.UTF8.GetString(bytes); - } - - private static byte[] S2N(string str) - { - return S2Encoding(str, Encoding.UTF8); - } - - private static byte[] S2Ansi(string str) - { - return S2Encoding(str, Encoding.Default); - } - - private static byte[] S2Encoding(string str, Encoding encoding) - { - return str == null ? null : encoding.GetBytes(str + '\0'); - } - - private object GetDllType(Type type, string name) - { - var address = NativeMethods.CrossGetProcAddress(_libDll, name); - return address != IntPtr.Zero ? Marshal.GetDelegateForFunctionPointer(address, type) : null; - } - - /// <summary> - /// Load dll dynamic + set pointers to needed methods - /// </summary> - /// <param name="baseFolder"></param> - private void LoadLibVoikkoDynamic(string baseFolder) - { - var dllFile = Path.Combine(baseFolder, "Voikkox86.dll"); - if (Configuration.IsRunningOnWindows) - { - if (IntPtr.Size == 8) - { - dllFile = Path.Combine(baseFolder, "Voikkox64.dll"); - } - - if (!File.Exists(dllFile)) - { - throw new FileNotFoundException(dllFile); - } - } - else - { - dllFile = Path.Combine(baseFolder, "libvoikko.so"); - } - - _libDll = NativeMethods.CrossLoadLibrary(dllFile); - - if (_libDll == IntPtr.Zero) - { - throw new FileLoadException("Unable to load " + dllFile); - } - - _voikkoInit = (VoikkoInit)GetDllType(typeof(VoikkoInit), "voikkoInit"); - _voikkoTerminate = (VoikkoTerminate)GetDllType(typeof(VoikkoTerminate), "voikkoTerminate"); - _voikkoSpell = (VoikkoSpell)GetDllType(typeof(VoikkoSpell), "voikkoSpellCstr"); - _voikkoSuggest = (VoikkoSuggest)GetDllType(typeof(VoikkoSuggest), "voikkoSuggestCstr"); - _voikkoFreeCstrArray = (VoikkoFreeCstrArray)GetDllType(typeof(VoikkoFreeCstrArray), "voikkoFreeCstrArray"); - - if (_voikkoInit == null || _voikkoTerminate == null || _voikkoSpell == null || _voikkoSuggest == null || _voikkoFreeCstrArray == null) - { - throw new FileLoadException("Not all methods in lib Voikko could be found!"); - } - } - - public override bool Spell(string word) - { - if (string.IsNullOrEmpty(word)) - { - return false; - } - - return Convert.ToBoolean(_voikkoSpell(_libVoikko, S2N(word))); - } - - public override List<string> Suggest(string word) - { - var suggestions = new List<string>(); - if (string.IsNullOrEmpty(word)) - { - return suggestions; - } - - var voikkoSuggestCstr = _voikkoSuggest(_libVoikko, S2N(word)); - if (voikkoSuggestCstr == IntPtr.Zero) - { - return suggestions; - } - - unsafe - { - for (byte** cStr = (byte**)voikkoSuggestCstr; *cStr != (byte*)0; cStr++) - { - suggestions.Add(N2S(new IntPtr(*cStr))); - } - } - _voikkoFreeCstrArray(voikkoSuggestCstr); - return suggestions; - } - - public VoikkoSpellCheck(string baseFolder, string dictionaryFolder) - { - LoadLibVoikkoDynamic(baseFolder); - - var error = new IntPtr(); - _libVoikko = _voikkoInit(ref error, S2N("fi"), S2Ansi(dictionaryFolder)); - if (_libVoikko == IntPtr.Zero && error != IntPtr.Zero) - { - throw new Exception(N2S(error)); - } - } - - ~VoikkoSpellCheck() - { - Dispose(false); - } - - private void ReleaseUnmanagedResources() - { - try - { - if (_libVoikko != IntPtr.Zero) - { - _voikkoTerminate(_libVoikko); - _libVoikko = IntPtr.Zero; - } - - if (_libDll != IntPtr.Zero) - { - NativeMethods.CrossFreeLibrary(_libDll); - _libDll = IntPtr.Zero; - } - } - catch - { - // ignored - } - } - - public override void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - //ReleaseManagedResources(); - } - ReleaseUnmanagedResources(); - } - } -} +using Nikse.SubtitleEdit.Core; +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic.SpellCheck +{ + public class VoikkoSpellCheck : Hunspell + { + + // Voikko functions in dll + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr VoikkoInit(ref IntPtr error, byte[] languageCode, byte[] path); + private VoikkoInit _voikkoInit; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void VoikkoTerminate(IntPtr libVlc); + private VoikkoTerminate _voikkoTerminate; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate Int32 VoikkoSpell(IntPtr handle, byte[] word); + private VoikkoSpell _voikkoSpell; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr VoikkoSuggest(IntPtr handle, byte[] word); + private VoikkoSuggest _voikkoSuggest; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr VoikkoFreeCstrArray(IntPtr array); + private VoikkoFreeCstrArray _voikkoFreeCstrArray; + + private IntPtr _libDll = IntPtr.Zero; + private IntPtr _libVoikko; + + private static string N2S(IntPtr ptr) + { + if (ptr == IntPtr.Zero) + { + return null; + } + + var bytes = new List<byte>(); + unsafe + { + for (byte* p = (byte*)ptr; *p != 0; p++) + { + bytes.Add(*p); + } + } + return N2S(bytes.ToArray()); + } + + private static string N2S(byte[] bytes) + { + return bytes == null ? null : Encoding.UTF8.GetString(bytes); + } + + private static byte[] S2N(string str) + { + return S2Encoding(str, Encoding.UTF8); + } + + private static byte[] S2Ansi(string str) + { + return S2Encoding(str, Encoding.Default); + } + + private static byte[] S2Encoding(string str, Encoding encoding) + { + return str == null ? null : encoding.GetBytes(str + '\0'); + } + + private object GetDllType(Type type, string name) + { + var address = NativeMethods.CrossGetProcAddress(_libDll, name); + return address != IntPtr.Zero ? Marshal.GetDelegateForFunctionPointer(address, type) : null; + } + + /// <summary> + /// Load dll dynamic + set pointers to needed methods + /// </summary> + /// <param name="baseFolder"></param> + private void LoadLibVoikkoDynamic(string baseFolder) + { + var dllFile = Path.Combine(baseFolder, "Voikkox86.dll"); + if (Configuration.IsRunningOnWindows) + { + if (IntPtr.Size == 8) + { + dllFile = Path.Combine(baseFolder, "Voikkox64.dll"); + } + + if (!File.Exists(dllFile)) + { + throw new FileNotFoundException(dllFile); + } + } + else + { + dllFile = Path.Combine(baseFolder, "libvoikko.so"); + } + + _libDll = NativeMethods.CrossLoadLibrary(dllFile); + + if (_libDll == IntPtr.Zero) + { + throw new FileLoadException("Unable to load " + dllFile); + } + + _voikkoInit = (VoikkoInit)GetDllType(typeof(VoikkoInit), "voikkoInit"); + _voikkoTerminate = (VoikkoTerminate)GetDllType(typeof(VoikkoTerminate), "voikkoTerminate"); + _voikkoSpell = (VoikkoSpell)GetDllType(typeof(VoikkoSpell), "voikkoSpellCstr"); + _voikkoSuggest = (VoikkoSuggest)GetDllType(typeof(VoikkoSuggest), "voikkoSuggestCstr"); + _voikkoFreeCstrArray = (VoikkoFreeCstrArray)GetDllType(typeof(VoikkoFreeCstrArray), "voikkoFreeCstrArray"); + + if (_voikkoInit == null || _voikkoTerminate == null || _voikkoSpell == null || _voikkoSuggest == null || _voikkoFreeCstrArray == null) + { + throw new FileLoadException("Not all methods in lib Voikko could be found!"); + } + } + + public override bool Spell(string word) + { + if (string.IsNullOrEmpty(word)) + { + return false; + } + + return Convert.ToBoolean(_voikkoSpell(_libVoikko, S2N(word))); + } + + public override List<string> Suggest(string word) + { + var suggestions = new List<string>(); + if (string.IsNullOrEmpty(word)) + { + return suggestions; + } + + var voikkoSuggestCstr = _voikkoSuggest(_libVoikko, S2N(word)); + if (voikkoSuggestCstr == IntPtr.Zero) + { + return suggestions; + } + + unsafe + { + for (byte** cStr = (byte**)voikkoSuggestCstr; *cStr != (byte*)0; cStr++) + { + suggestions.Add(N2S(new IntPtr(*cStr))); + } + } + _voikkoFreeCstrArray(voikkoSuggestCstr); + return suggestions; + } + + public VoikkoSpellCheck(string baseFolder, string dictionaryFolder) + { + LoadLibVoikkoDynamic(baseFolder); + + var error = new IntPtr(); + _libVoikko = _voikkoInit(ref error, S2N("fi"), S2Ansi(dictionaryFolder)); + if (_libVoikko == IntPtr.Zero && error != IntPtr.Zero) + { + throw new Exception(N2S(error)); + } + } + + ~VoikkoSpellCheck() + { + Dispose(false); + } + + private void ReleaseUnmanagedResources() + { + try + { + if (_libVoikko != IntPtr.Zero) + { + _voikkoTerminate(_libVoikko); + _libVoikko = IntPtr.Zero; + } + + if (_libDll != IntPtr.Zero) + { + NativeMethods.CrossFreeLibrary(_libDll); + _libDll = IntPtr.Zero; + } + } + catch + { + // ignored + } + } + + public override void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + //ReleaseManagedResources(); + } + ReleaseUnmanagedResources(); + } + } +} diff --git a/src/Logic/SpellCheck/WindowsHunspell.cs b/src/ui/Logic/SpellCheck/WindowsHunspell.cs similarity index 96% rename from src/Logic/SpellCheck/WindowsHunspell.cs rename to src/ui/Logic/SpellCheck/WindowsHunspell.cs index b55856336..6bae9a51d 100644 --- a/src/Logic/SpellCheck/WindowsHunspell.cs +++ b/src/ui/Logic/SpellCheck/WindowsHunspell.cs @@ -1,46 +1,46 @@ -using System; -using System.Collections.Generic; - -namespace Nikse.SubtitleEdit.Logic.SpellCheck -{ - public class WindowsHunspell : Hunspell - { - private NHunspell.Hunspell _hunspell; - - public WindowsHunspell(string affDictionary, string dicDictionary) - { - _hunspell = new NHunspell.Hunspell(affDictionary, dicDictionary); - } - - public override bool Spell(string word) - { - return _hunspell.Spell(word); - } - - public override List<string> Suggest(string word) - { - var list = _hunspell.Suggest(word); - AddIShouldBeLowercaseLSuggestion(list, word); - return list; - } - - public override void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - if (_hunspell != null && !_hunspell.IsDisposed) - { - _hunspell.Dispose(); - } - _hunspell = null; - } - } - - } -} +using System; +using System.Collections.Generic; + +namespace Nikse.SubtitleEdit.Logic.SpellCheck +{ + public class WindowsHunspell : Hunspell + { + private NHunspell.Hunspell _hunspell; + + public WindowsHunspell(string affDictionary, string dicDictionary) + { + _hunspell = new NHunspell.Hunspell(affDictionary, dicDictionary); + } + + public override bool Spell(string word) + { + return _hunspell.Spell(word); + } + + public override List<string> Suggest(string word) + { + var list = _hunspell.Suggest(word); + AddIShouldBeLowercaseLSuggestion(list, word); + return list; + } + + public override void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + if (_hunspell != null && !_hunspell.IsDisposed) + { + _hunspell.Dispose(); + } + _hunspell = null; + } + } + + } +} diff --git a/src/Logic/SyncContextExtensions.cs b/src/ui/Logic/SyncContextExtensions.cs similarity index 100% rename from src/Logic/SyncContextExtensions.cs rename to src/ui/Logic/SyncContextExtensions.cs diff --git a/src/Logic/TaskbarList.cs b/src/ui/Logic/TaskbarList.cs similarity index 100% rename from src/Logic/TaskbarList.cs rename to src/ui/Logic/TaskbarList.cs diff --git a/src/Logic/TextDesigner.cs b/src/ui/Logic/TextDesigner.cs similarity index 100% rename from src/Logic/TextDesigner.cs rename to src/ui/Logic/TextDesigner.cs diff --git a/src/Logic/TextWidth.cs b/src/ui/Logic/TextWidth.cs similarity index 100% rename from src/Logic/TextWidth.cs rename to src/ui/Logic/TextWidth.cs diff --git a/src/Logic/UiEbuSaveHelper.cs b/src/ui/Logic/UiEbuSaveHelper.cs similarity index 100% rename from src/Logic/UiEbuSaveHelper.cs rename to src/ui/Logic/UiEbuSaveHelper.cs diff --git a/src/Logic/UiGetPacEncoding.cs b/src/ui/Logic/UiGetPacEncoding.cs similarity index 100% rename from src/Logic/UiGetPacEncoding.cs rename to src/ui/Logic/UiGetPacEncoding.cs diff --git a/src/Logic/UiGetYouTubeAnnotationStyles.cs b/src/ui/Logic/UiGetYouTubeAnnotationStyles.cs similarity index 100% rename from src/Logic/UiGetYouTubeAnnotationStyles.cs rename to src/ui/Logic/UiGetYouTubeAnnotationStyles.cs diff --git a/src/Logic/UiUtil.cs b/src/ui/Logic/UiUtil.cs similarity index 97% rename from src/Logic/UiUtil.cs rename to src/ui/Logic/UiUtil.cs index 176cd268a..104f24e64 100644 --- a/src/Logic/UiUtil.cs +++ b/src/ui/Logic/UiUtil.cs @@ -1,1209 +1,1209 @@ -using Nikse.SubtitleEdit.Controls; -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using Nikse.SubtitleEdit.Forms; -using Nikse.SubtitleEdit.Logic.VideoPlayers; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic -{ - internal static class UiUtil - { - public static readonly Lazy<string> SubtitleExtensionFilter = new Lazy<string>(GetOpenDialogFilter); - - public static VideoInfo GetVideoInfo(string fileName) - { - var info = FileUtil.TryReadVideoInfoViaAviHeader(fileName); - if (info.Success) - { - return info; - } - - info = FileUtil.TryReadVideoInfoViaMatroskaHeader(fileName); - if (info.Success) - { - return info; - } - - info = FileUtil.TryReadVideoInfoViaMp4(fileName); - if (info.Success) - { - return info; - } - - info = TryReadVideoInfoViaDirectShow(fileName); - if (info.Success) - { - return info; - } - - return new VideoInfo { VideoCodec = "Unknown" }; - } - - private static VideoInfo TryReadVideoInfoViaDirectShow(string fileName) - { - return QuartsPlayer.GetVideoInfo(fileName); - } - - private static long _lastShowSubTicks = DateTime.UtcNow.Ticks; - private static int _lastShowSubHash; - - public static int ShowSubtitle(Subtitle subtitle, VideoPlayerContainer videoPlayerContainer) - { - if (videoPlayerContainer.VideoPlayer == null) - { - return -1; - } - - double positionInMilliseconds = videoPlayerContainer.CurrentPosition * TimeCode.BaseUnit; - var max = subtitle.Paragraphs.Count; - for (int i = 0; i < max; i++) - { - var p = subtitle.Paragraphs[i]; - if (p.StartTime.TotalMilliseconds <= positionInMilliseconds + 0.01 && p.EndTime.TotalMilliseconds >= positionInMilliseconds - 0.01) - { - string text = p.Text.Replace("|", Environment.NewLine); - bool isInfo = p == subtitle.Paragraphs[0] && (Math.Abs(p.StartTime.TotalMilliseconds) < 0.01 && Math.Abs(p.Duration.TotalMilliseconds) < 0.01 || Math.Abs(p.StartTime.TotalMilliseconds - Pac.PacNullTime.TotalMilliseconds) < 0.01); - if (!isInfo) - { - if (videoPlayerContainer.LastParagraph != p) - { - videoPlayerContainer.SetSubtitleText(text, p, subtitle); - } - else if (videoPlayerContainer.SubtitleText != text) - { - videoPlayerContainer.SetSubtitleText(text, p, subtitle); - } - TimeOutRefresh(subtitle, videoPlayerContainer, p); - return i; - } - } - } - - if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText)) - { - videoPlayerContainer.SetSubtitleText(string.Empty, null, subtitle); - } - else - { - TimeOutRefresh(subtitle, videoPlayerContainer); - } - return -1; - } - - private static void TimeOutRefresh(Subtitle subtitle, VideoPlayerContainer videoPlayerContainer, Paragraph p = null) - { - if (DateTime.UtcNow.Ticks - _lastShowSubTicks > 10000 * 1000) // more than 1+ seconds ago - { - var newHash = subtitle.GetFastHashCode(string.Empty); - if (newHash != _lastShowSubHash) - { - videoPlayerContainer.SetSubtitleText(p == null ? string.Empty : p.Text, p, subtitle); - _lastShowSubHash = newHash; - } - - _lastShowSubTicks = DateTime.UtcNow.Ticks; - } - } - - public static int ShowSubtitle(Subtitle subtitle, Subtitle original, VideoPlayerContainer videoPlayerContainer) - { - if (videoPlayerContainer.VideoPlayer == null) - { - return -1; - } - - double positionInMilliseconds = (videoPlayerContainer.VideoPlayer.CurrentPosition * TimeCode.BaseUnit) + 15; - var max = subtitle.Paragraphs.Count; - for (int i = 0; i < max; i++) - { - var p = subtitle.Paragraphs[i]; - if (p.StartTime.TotalMilliseconds <= positionInMilliseconds && p.EndTime.TotalMilliseconds > positionInMilliseconds) - { - var op = Utilities.GetOriginalParagraph(0, p, original.Paragraphs); - string text = p.Text.Replace("|", Environment.NewLine); - if (op != null) - { - text = text + Environment.NewLine + Environment.NewLine + op.Text.Replace("|", Environment.NewLine); - } - - bool isInfo = p == subtitle.Paragraphs[0] && Math.Abs(p.StartTime.TotalMilliseconds) < 0.01 && positionInMilliseconds > 3000; - if (!isInfo) - { - if (videoPlayerContainer.LastParagraph != p || videoPlayerContainer.SubtitleText != text) - { - videoPlayerContainer.SetSubtitleText(text, p, subtitle); - } - return i; - } - } - } - if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText)) - { - videoPlayerContainer.SetSubtitleText(string.Empty, null, subtitle); - } - return -1; - } - - public static bool IsQuartsDllInstalled - { - get - { - if (Utilities.IsRunningOnMono()) - { - return false; - } - - string quartzFileName = Environment.GetFolderPath(Environment.SpecialFolder.System).TrimEnd('\\') + @"\quartz.dll"; - return File.Exists(quartzFileName); - } - } - - public static bool IsMpcHcInstalled - { - get - { - if (Utilities.IsRunningOnMono()) - { - return false; - } - - try - { - return VideoPlayers.MpcHC.MpcHc.GetMpcHcFileName() != null; - } - catch (FileNotFoundException) - { - return false; - } - } - } - - public static VideoPlayer GetVideoPlayer() - { - var gs = Configuration.Settings.General; - - if (Configuration.IsRunningOnLinux) - { - if (gs.VideoPlayer == "VLC" && LibVlcDynamic.IsInstalled) - { - return new LibVlcDynamic(); - } - if (LibMpvDynamic.IsInstalled) - { - return new LibMpvDynamic(); - } - throw new NotSupportedException("You need 'libmpv-dev' or 'libvlc-dev' (on Ubuntu) and X11 to use the video player on Linux!"); - } - // Mono on OS X is 32 bit and thus requires 32 bit VLC. Place VLC in the same - // folder as Subtitle Edit and add this to the app.config inside the - // "configuration" element: - // <dllmap dll="libvlc" target="VLC.app/Contents/MacOS/lib/libvlc.dylib" /> - if (Configuration.IsRunningOnMac) - { - return new LibVlcMono(); - } - - if (gs.VideoPlayer == "VLC" && LibVlcDynamic.IsInstalled) - { - return new LibVlcDynamic(); - } - - if (gs.VideoPlayer == "MPV" && LibMpvDynamic.IsInstalled) - { - return new LibMpvDynamic(); - } - - if (gs.VideoPlayer == "MPC-HC" && VideoPlayers.MpcHC.MpcHc.IsInstalled) - { - return new VideoPlayers.MpcHC.MpcHc(); - } - - if (IsQuartsDllInstalled) - { - return new QuartsPlayer(); - } - - throw new NotSupportedException("You need DirectX, or mpv media player, or VLC media player installed as well as Subtitle Edit dll files in order to use the video player!"); - } - - public static bool InitializeVideoPlayerAndContainer(string fileName, VideoInfo videoInfo, VideoPlayerContainer videoPlayerContainer, EventHandler onVideoLoaded, EventHandler onVideoEnded) - { - try - { - videoPlayerContainer.VideoPlayer = GetVideoPlayer(); - videoPlayerContainer.VideoPlayer.Initialize(videoPlayerContainer.PanelPlayer, fileName, onVideoLoaded, onVideoEnded); - videoPlayerContainer.ShowStopButton = Configuration.Settings.General.VideoPlayerShowStopButton; - videoPlayerContainer.ShowFullscreenButton = false; - videoPlayerContainer.ShowMuteButton = Configuration.Settings.General.VideoPlayerShowMuteButton; - videoPlayerContainer.Volume = Configuration.Settings.General.VideoPlayerDefaultVolume; - videoPlayerContainer.EnableMouseWheelStep(); - if (fileName != null && (fileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase) || fileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase))) - { - // we don't have videoInfo for streams... - } - else - { - videoPlayerContainer.VideoWidth = videoInfo.Width; - videoPlayerContainer.VideoHeight = videoInfo.Height; - videoPlayerContainer.VideoPlayer.Resize(videoPlayerContainer.PanelPlayer.Width, videoPlayerContainer.PanelPlayer.Height); - } - - return true; - } - catch (Exception exception) - { - videoPlayerContainer.VideoPlayer = null; - var videoError = new VideoError(); - videoError.Initialize(fileName, exception); - videoError.ShowDialog(); - SeLogger.Error(exception, "InitializeVideoPlayerAndContainer failed to load video player"); - return false; - } - } - - public static void CheckAutoWrap(TextBox textBox, KeyEventArgs e, int numberOfNewLines) - { - // Do not auto-break lines more than 1 line. - if (numberOfNewLines != 1 || !Configuration.Settings.General.AutoWrapLineWhileTyping) - { - return; - } - - int length = HtmlUtil.RemoveHtmlTags(textBox.Text, true).Length; - if (e.Modifiers == Keys.None && e.KeyCode != Keys.Enter && length > Configuration.Settings.General.SubtitleLineMaximumLength) - { - string newText; - if (length > Configuration.Settings.General.SubtitleLineMaximumLength + 30) - { - newText = Utilities.AutoBreakLine(textBox.Text); - } - else - { - int lastSpace = textBox.Text.LastIndexOf(' '); - if (lastSpace > 0) - { - newText = textBox.Text.Remove(lastSpace, 1).Insert(lastSpace, Environment.NewLine); - } - else - { - newText = textBox.Text; - } - } - - int autoBreakIndex = newText.IndexOf(Environment.NewLine, StringComparison.Ordinal); - if (autoBreakIndex > 0) - { - int selectionStart = textBox.SelectionStart; - textBox.Text = newText; - if (selectionStart > autoBreakIndex) - { - selectionStart += Environment.NewLine.Length - 1; - } - if (selectionStart >= 0) - { - textBox.SelectionStart = selectionStart; - } - } - } - } - - public static void CheckAutoWrap(SETextBox textBox, KeyEventArgs e, int numberOfNewLines) - { - // Do not auto-break lines more than 1 line. - if (numberOfNewLines != 1 || !Configuration.Settings.General.AutoWrapLineWhileTyping) - { - return; - } - - int length = HtmlUtil.RemoveHtmlTags(textBox.Text, true).Length; - if (e.Modifiers == Keys.None && e.KeyCode != Keys.Enter && length > Configuration.Settings.General.SubtitleLineMaximumLength) - { - string newText; - if (length > Configuration.Settings.General.SubtitleLineMaximumLength + 30) - { - newText = Utilities.AutoBreakLine(textBox.Text); - } - else - { - int lastSpace = textBox.Text.LastIndexOf(' '); - if (lastSpace > 0) - { - newText = textBox.Text.Remove(lastSpace, 1).Insert(lastSpace, Environment.NewLine); - } - else - { - newText = textBox.Text; - } - } - - int autoBreakIndex = newText.IndexOf(Environment.NewLine, StringComparison.Ordinal); - if (autoBreakIndex > 0) - { - int selectionStart = textBox.SelectionStart; - textBox.Text = newText; - if (selectionStart > autoBreakIndex) - { - selectionStart += Environment.NewLine.Length - 1; - } - if (selectionStart >= 0) - { - textBox.SelectionStart = selectionStart; - } - } - } - } - - private static readonly Dictionary<string, Keys> AllKeys = new Dictionary<string, Keys>(); - private static Keys _helpKeys; - - public static Keys GetKeys(string keysInString) - { - if (string.IsNullOrEmpty(keysInString)) - { - return Keys.None; - } - - if (AllKeys.Count == 0) - { - foreach (Keys val in Enum.GetValues(typeof(Keys))) - { - string k = val.ToString().ToLowerInvariant(); - if (!AllKeys.ContainsKey(k)) - { - AllKeys.Add(k, val); - } - } - if (!AllKeys.ContainsKey("pagedown")) - { - AllKeys.Add("pagedown", Keys.RButton | Keys.Space); - } - - if (!AllKeys.ContainsKey("home")) - { - AllKeys.Add("home", Keys.MButton | Keys.Space); - } - - if (!AllKeys.ContainsKey("capslock")) - { - AllKeys.Add("capslock", Keys.CapsLock); - } - } - - string[] parts = keysInString.ToLowerInvariant().Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries); - var resultKeys = Keys.None; - foreach (string k in parts) - { - if (AllKeys.ContainsKey(k)) - { - resultKeys = resultKeys | AllKeys[k]; - } - } - return resultKeys; - } - - public static Keys HelpKeys - { - get - { - if (_helpKeys == Keys.None) - { - _helpKeys = GetKeys(Configuration.Settings.Shortcuts.GeneralHelp); - } - return _helpKeys; - } - set => _helpKeys = value; - } - - public static void SetButtonHeight(Control control, int newHeight, int level) - { - if (level > 6) - { - return; - } - - if (control.HasChildren) - { - foreach (Control subControl in control.Controls) - { - if (subControl.HasChildren) - { - SetButtonHeight(subControl, newHeight, level + 1); - } - else if (subControl is Button) - { - subControl.Height = newHeight; - } - } - } - else if (control is Button) - { - control.Height = newHeight; - } - } - - public static void InitializeSubtitleFont(Control control) - { - var gs = Configuration.Settings.General; - - if (string.IsNullOrEmpty(gs.SubtitleFontName)) - { - gs.SubtitleFontName = DefaultSystemFont.Name; - } - - try - { - if (control is ListView) - { - if (gs.SubtitleListViewFontBold) - { - control.Font = new Font(gs.SubtitleFontName, gs.SubtitleListViewFontSize, FontStyle.Bold); - } - else - { - control.Font = new Font(gs.SubtitleFontName, gs.SubtitleListViewFontSize); - } - } - else if (control is SETextBox || control is TextBox) - { - if (gs.SubtitleTextBoxFontBold) - { - control.Font = new Font(gs.SubtitleFontName, gs.SubtitleTextBoxFontSize, FontStyle.Bold); - } - else - { - control.Font = new Font(gs.SubtitleFontName, gs.SubtitleTextBoxFontSize); - } - } - - control.BackColor = gs.SubtitleBackgroundColor; - control.ForeColor = gs.SubtitleFontColor; - } - catch - { - // ignored - } - } - - private static Font _defaultSystemFont; - private static Font DefaultSystemFont - { - get - { - if (_defaultSystemFont != null) - { - return _defaultSystemFont; - } - - var font = SystemFonts.MessageBoxFont; - if (Configuration.IsRunningOnLinux && IsFontPresent(Configuration.DefaultLinuxFontName)) - { - font = new Font(Configuration.DefaultLinuxFontName, 8F); - } - - _defaultSystemFont = IsFontPresent(font.Name) ? font : SystemFonts.DefaultFont; - return _defaultSystemFont; - } - } - - private static bool IsFontPresent(string fontName) - { - try - { - // Bold + italic + regular must be present - _ = new Font(fontName, 9, FontStyle.Bold); - _ = new Font(fontName, 9, FontStyle.Italic); - _ = new Font(fontName, 9, FontStyle.Regular); - return true; - } - catch - { - // ignore - } - - return false; - } - - public static Font GetDefaultFont() - { - var gs = Configuration.Settings.General; - if (string.IsNullOrEmpty(gs.SystemSubtitleFontNameOverride) || gs.SystemSubtitleFontSizeOverride < 5) - { - return DefaultSystemFont; - } - - try - { - return new Font(gs.SystemSubtitleFontNameOverride, gs.SystemSubtitleFontSizeOverride); - } - catch - { - return DefaultSystemFont; - } - } - - internal static void PreInitialize(Form form) - { - form.AutoScaleMode = AutoScaleMode.Dpi; - form.Font = GetDefaultFont(); - } - - public static void FixFonts(Control form, int iterations = 5) - { - FixFontsInner(form, iterations); - if (Configuration.Settings.General.UseDarkTheme) - { - DarkTheme.SetDarkTheme(form, 1500); - } - } - - internal static void FixFonts(ToolStripItem item) - { - item.Font = GetDefaultFont(); - if (Configuration.Settings.General.UseDarkTheme) - { - DarkTheme.SetDarkTheme(item); - } - } - - internal static void FixFonts(ToolStripComboBox item) - { - item.Font = GetDefaultFont(); - if (Configuration.Settings.General.UseDarkTheme) - { - DarkTheme.SetDarkTheme(item); - } - } - - private static void FixFontsInner(Control form, int iterations = 5) - { - if (iterations < 1 || form is SETextBox) - { - return; - } - - if (form is ContextMenuStrip cms) - { - foreach (var item in cms.Items) - { - if (item is ToolStripMenuItem tsmi) - { - tsmi.Font = GetDefaultFont(); - if (tsmi.HasDropDownItems) - { - foreach (var innerItem in tsmi.DropDownItems) - { - if (innerItem is ToolStripMenuItem innerTsmi) - { - innerTsmi.Font = GetDefaultFont(); - } - } - } - } - } - } - - if (form is TimeUpDown timeUpDown) - { - using (var g = Graphics.FromHwnd(IntPtr.Zero)) - { - var width = g.MeasureString("00:00:00.000", form.Font).Width; - if (timeUpDown.MaskedTextBox.Width < width - 3) - { - timeUpDown.MaskedTextBox.Font = new Font(timeUpDown.MaskedTextBox.Font.FontFamily, timeUpDown.MaskedTextBox.Font.Size - 1); - } - width = g.MeasureString("00:00:00.000", form.Font).Width; - if (timeUpDown.MaskedTextBox.Width < width - 3) - { - timeUpDown.MaskedTextBox.Font = new Font(timeUpDown.MaskedTextBox.Font.FontFamily, timeUpDown.MaskedTextBox.Font.Size - 1); - } - } - } - - foreach (Control c in form.Controls) - { - if (!c.Font.Name.Equals("Tahoma", StringComparison.Ordinal)) - { - c.Font = GetDefaultFont(); - } - - foreach (Control inner in c.Controls) - { - FixFontsInner(inner, iterations - 1); - } - } - } - - public static void FixLargeFonts(Control mainCtrl, Control ctrl) - { - using (Graphics graphics = mainCtrl.CreateGraphics()) - { - SizeF textSize = graphics.MeasureString(ctrl.Text, ctrl.Font); - if (textSize.Height > ctrl.Height - 4) - { - SetButtonHeight(mainCtrl, (int)Math.Round(textSize.Height + 7.5), 1); - } - } - } - - public static void SetSaveDialogFilter(SaveFileDialog saveFileDialog, SubtitleFormat currentFormat) - { - var sb = new StringBuilder(); - int index = 0; - foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) - { - sb.Append(format.Name + "|*" + format.Extension + "|"); - if (currentFormat.Name == format.Name) - { - saveFileDialog.FilterIndex = index + 1; - } - index++; - } - saveFileDialog.Filter = sb.ToString().TrimEnd('|'); - } - - public static void GetLineLengths(Label label, string text) - { - label.ForeColor = ForeColor; - var lines = text.SplitToLines(); - const int max = 3; - var sb = new StringBuilder(); - for (int i = 0; i < lines.Count; i++) - { - string line = lines[i]; - if (i > 0) - { - sb.Append('/'); - } - - if (i > max) - { - sb.Append("..."); - label.Text = sb.ToString(); - return; - } - - sb.Append(line.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics)); - if (line.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength || i >= Configuration.Settings.General.MaxNumberOfLines) - { - label.ForeColor = Color.Red; - } - } - label.Text = sb.ToString(); - } - - public static void GetLinePixelWidths(Label label, string text) - { - label.ForeColor = ForeColor; - var lines = text.SplitToLines(); - const int max = 3; - var sb = new StringBuilder(); - for (int i = 0; i < lines.Count; i++) - { - string line = lines[i]; - if (i > 0) - { - sb.Append('/'); - } - - if (i > max) - { - sb.Append("..."); - label.Text = sb.ToString(); - return; - } - - int lineWidth = TextWidth.CalcPixelWidth(line); - sb.Append(lineWidth); - if (lineWidth > Configuration.Settings.General.SubtitleLineMaximumPixelWidth) - { - label.ForeColor = Color.Red; - } - } - label.Text = sb.ToString(); - } - - public static void InitializeSubtitleFormatComboBox(ToolStripComboBox comboBox, SubtitleFormat format) - { - InitializeSubtitleFormatComboBox(comboBox.ComboBox, format); - comboBox.DropDownWidth += 5; // .Net quirk? - } - - public static void InitializeSubtitleFormatComboBox(ComboBox comboBox, SubtitleFormat format) - { - InitializeSubtitleFormatComboBox(comboBox, new List<string> { format.FriendlyName }, format.FriendlyName); - } - - public static void InitializeSubtitleFormatComboBox(ToolStripComboBox comboBox, string selectedName) - { - InitializeSubtitleFormatComboBox(comboBox.ComboBox, selectedName); - comboBox.DropDownWidth += 5; // .Net quirk? - } - - public static void InitializeSubtitleFormatComboBox(ComboBox comboBox, string selectedName) - { - var formatNames = SubtitleFormat.AllSubtitleFormats.Where(format => !format.IsVobSubIndexFile).Select(format => format.FriendlyName); - InitializeSubtitleFormatComboBox(comboBox, formatNames.ToList(), selectedName); - } - - public static void InitializeSubtitleFormatComboBox(ComboBox comboBox, List<string> formatNames, string selectedName) - { - var selectedIndex = 0; - using (var graphics = comboBox.CreateGraphics()) - { - var maxWidth = (float)comboBox.DropDownWidth; - var max = formatNames.Count; - for (var index = 0; index < max; index++) - { - var name = formatNames[index]; - if (name.Equals(selectedName, StringComparison.OrdinalIgnoreCase)) - { - selectedIndex = index; - } - if (name.Length > 30) - { - var width = graphics.MeasureString(name, comboBox.Font).Width; - if (width > maxWidth) - { - maxWidth = width; - } - } - } - comboBox.DropDownWidth = (int)Math.Round(maxWidth + 7.5); - } - comboBox.BeginUpdate(); - comboBox.Items.Clear(); - comboBox.Items.AddRange(formatNames.ToArray<object>()); - comboBox.SelectedIndex = selectedIndex; - comboBox.EndUpdate(); - } - - public static void InitializeTextEncodingComboBox(ComboBox comboBox) - { - var defaultEncoding = Configuration.Settings.General.DefaultEncoding; - var selectedItem = (TextEncoding)null; - comboBox.BeginUpdate(); - comboBox.Items.Clear(); - var encList = new List<TextEncoding>(); - using (var graphics = comboBox.CreateGraphics()) - { - var maxWidth = 0.0F; - foreach (var encoding in Configuration.AvailableEncodings) - { - if (encoding.CodePage >= 874 && !encoding.IsEbcdic()) - { - var item = new TextEncoding(encoding, null); - if (selectedItem == null && item.Equals(defaultEncoding)) - { - selectedItem = item; - } - var width = graphics.MeasureString(item.DisplayName, comboBox.Font).Width; - if (width > maxWidth) - { - maxWidth = width; - } - if (encoding.CodePage.Equals(Encoding.UTF8.CodePage)) - { - item = new TextEncoding(Encoding.UTF8, TextEncoding.Utf8WithBom); - encList.Insert(TextEncoding.Utf8WithBomIndex, item); - if (item.Equals(defaultEncoding)) - { - selectedItem = item; - } - - item = new TextEncoding(Encoding.UTF8, TextEncoding.Utf8WithoutBom); - encList.Insert(TextEncoding.Utf8WithoutBomIndex, item); - if (item.Equals(defaultEncoding)) - { - selectedItem = item; - } - } - else - { - encList.Add(item); - } - } - } - comboBox.DropDownWidth = (int)Math.Round(maxWidth + 7.5); - } - comboBox.Items.AddRange(encList.ToArray<object>()); - if (selectedItem == null) - { - comboBox.SelectedIndex = TextEncoding.Utf8WithBomIndex; // UTF-8 if DefaultEncoding is not found - } - else if (selectedItem.DisplayName == TextEncoding.Utf8WithoutBom) - { - comboBox.SelectedIndex = TextEncoding.Utf8WithoutBomIndex; - } - else - { - comboBox.SelectedItem = selectedItem; - } - comboBox.EndUpdate(); - if (comboBox.SelectedItem is TextEncoding textEncodingListItem) - { - Configuration.Settings.General.DefaultEncoding = textEncodingListItem.DisplayName; - } - comboBox.AutoCompleteSource = AutoCompleteSource.ListItems; - comboBox.AutoCompleteMode = AutoCompleteMode.Append; - } - - public static TextEncoding GetTextEncodingComboBoxCurrentEncoding(ComboBox comboBox) - { - if (comboBox.SelectedIndex > 0 && comboBox.SelectedItem is TextEncoding textEncodingListItem) - { - return textEncodingListItem; - } - return new TextEncoding(Encoding.UTF8, TextEncoding.Utf8WithBom); - } - - public static void SetTextEncoding(ToolStripComboBox comboBoxEncoding, string encodingName) - { - if (encodingName == TextEncoding.Utf8WithBom) - { - comboBoxEncoding.SelectedIndex = TextEncoding.Utf8WithBomIndex; - return; - } - - if (encodingName == TextEncoding.Utf8WithoutBom) - { - comboBoxEncoding.SelectedIndex = TextEncoding.Utf8WithoutBomIndex; - return; - } - - foreach (TextEncoding item in comboBoxEncoding.Items) - { - if (item.Equals(encodingName)) - { - comboBoxEncoding.SelectedItem = item; - return; - } - } - - comboBoxEncoding.SelectedIndex = TextEncoding.Utf8WithBomIndex; // UTF-8 with BOM - } - - - - private const string BreakChars = "\",:;.¡!¿?()[]{}<>♪♫-–—/#*|؟،"; - - public static void ApplyControlBackspace(TextBox textBox) - { - if (textBox.SelectionLength == 0) - { - var text = textBox.Text; - var deleteUpTo = textBox.SelectionStart; - if (deleteUpTo > 0 && deleteUpTo <= text.Length) - { - text = text.Substring(0, deleteUpTo); - var textElementIndices = StringInfo.ParseCombiningCharacters(text); - var index = textElementIndices.Length; - var textIndex = deleteUpTo; - var deleteFrom = -1; - while (index > 0) - { - index--; - textIndex = textElementIndices[index]; - if (!IsSpaceCategory(CharUnicodeInfo.GetUnicodeCategory(text, textIndex))) - { - break; - } - } - if (index > 0) // HTML tag? - { - if (text[textIndex] == '>') - { - var openingBracketIndex = text.LastIndexOf('<', textIndex - 1); - if (openingBracketIndex >= 0 && text.IndexOf('>', openingBracketIndex + 1) == textIndex) - { - deleteFrom = openingBracketIndex; // delete whole tag - } - } - else if (text[textIndex] == '}') - { - var startIdx = text.LastIndexOf(@"{\", textIndex - 1, StringComparison.Ordinal); - if (startIdx >= 0 && text.IndexOf('}', startIdx + 1) == textIndex) - { - deleteFrom = startIdx; - } - } - } - if (deleteFrom < 0) - { - if (BreakChars.Contains(text[textIndex])) - { - deleteFrom = -2; - } - - while (index > 0) - { - index--; - textIndex = textElementIndices[index]; - if (IsSpaceCategory(CharUnicodeInfo.GetUnicodeCategory(text, textIndex))) - { - if (deleteFrom > -2) - { - if (deleteFrom < 0) - { - deleteFrom = textElementIndices[index + 1]; - } - break; - } - deleteFrom = textElementIndices[index + 1]; - if (!":!?".Contains(text[deleteFrom])) - { - break; - } - } - else if (BreakChars.Contains(text[textIndex])) - { - if (deleteFrom > -2) - { - if (deleteFrom < 0) - { - deleteFrom = textElementIndices[index + 1]; - } - break; - } - } - else - { - deleteFrom = -1; - } - } - } - if (deleteFrom < deleteUpTo) - { - if (deleteFrom < 0) - { - deleteFrom = 0; - } - textBox.Select(deleteFrom, deleteUpTo - deleteFrom); - textBox.Paste(string.Empty); - } - } - } - } - - public static void SelectWordAtCaret(SETextBox textBox) - { - var text = textBox.Text; - var endIndex = textBox.SelectionStart; - var startIndex = endIndex; - - while (startIndex > 0 && !IsSpaceCategory(CharUnicodeInfo.GetUnicodeCategory(text[startIndex - 1])) && !BreakChars.Contains(text[startIndex - 1])) - { - startIndex--; - } - textBox.SelectionStart = startIndex; - - while (endIndex < text.Length && !IsSpaceCategory(CharUnicodeInfo.GetUnicodeCategory(text[endIndex])) && !BreakChars.Contains(text[endIndex])) - { - endIndex++; - } - textBox.SelectionLength = endIndex - startIndex; - } - - private static bool IsSpaceCategory(UnicodeCategory c) - { - return c == UnicodeCategory.SpaceSeparator || c == UnicodeCategory.Control || c == UnicodeCategory.LineSeparator || c == UnicodeCategory.ParagraphSeparator; - } - - private static void AddExtension(StringBuilder sb, string extension) - { - if (!sb.ToString().Contains("*" + extension + ";", StringComparison.OrdinalIgnoreCase)) - { - sb.Append('*'); - sb.Append(extension.TrimStart('*')); - sb.Append(';'); - } - } - - private static string GetOpenDialogFilter() - { - var sb = new StringBuilder(); - sb.Append(Configuration.Settings.Language.General.SubtitleFiles + "|"); - foreach (SubtitleFormat s in SubtitleFormat.AllSubtitleFormats) - { - AddExtension(sb, s.Extension); - foreach (string ext in s.AlternateExtensions) - { - AddExtension(sb, ext); - } - } - AddExtension(sb, new Pac().Extension); - AddExtension(sb, new Cavena890().Extension); - AddExtension(sb, new Spt().Extension); - AddExtension(sb, new Sptx().Extension); - AddExtension(sb, new Wsb().Extension); - AddExtension(sb, new CheetahCaption().Extension); - AddExtension(sb, ".chk"); - AddExtension(sb, new CaptionsInc().Extension); - AddExtension(sb, new Ultech130().Extension); - AddExtension(sb, new ELRStudioClosedCaption().Extension); - AddExtension(sb, ".uld"); // Ultech drop frame - AddExtension(sb, new SonicScenaristBitmaps().Extension); - AddExtension(sb, ".mks"); - AddExtension(sb, ".mxf"); - AddExtension(sb, ".sup"); - AddExtension(sb, ".dost"); - AddExtension(sb, new FinalDraftTemplate2().Extension); - AddExtension(sb, new Ayato().Extension); - AddExtension(sb, new PacUnicode().Extension); - AddExtension(sb, new WinCaps32().Extension); - AddExtension(sb, new IsmtDfxp().Extension); - AddExtension(sb, new PlayCaptionsFreeEditor().Extension); - AddExtension(sb, ".cdg"); // karaoke - - if (!string.IsNullOrEmpty(Configuration.Settings.General.OpenSubtitleExtraExtensions)) - { - var extraExtensions = Configuration.Settings.General.OpenSubtitleExtraExtensions.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); - foreach (string ext in extraExtensions) - { - if (ext.StartsWith("*.", StringComparison.Ordinal) && !sb.ToString().Contains(ext, StringComparison.OrdinalIgnoreCase)) - { - AddExtension(sb, ext); - } - } - } - AddExtension(sb, ".son"); - AddExtension(sb, ".mts"); - AddExtension(sb, ".m2ts"); - - sb.Append('|'); - sb.Append(Configuration.Settings.Language.General.AllFiles); - sb.Append("|*.*"); - return sb.ToString(); - } - - public static string GetListViewTextFromString(string s) => s.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString); - - public static string GetStringFromListViewText(string lviText) => lviText.Replace(Configuration.Settings.General.ListViewLineSeparatorString, Environment.NewLine); - - public static void SelectAll(this ListView lv) - { - lv.BeginUpdate(); - foreach (ListViewItem item in lv.Items) - { - item.Selected = true; - } - lv.EndUpdate(); - } - - public static void SelectFirstSelectedItemOnly(this ListView lv) - { - int itemsCount = lv.SelectedItems.Count - 1; - if (itemsCount > 0) - { - lv.BeginUpdate(); - do - { - lv.SelectedItems[itemsCount--].Selected = false; - } - while (itemsCount > 0); - if (lv.SelectedItems.Count > 0) - { - lv.EnsureVisible(lv.SelectedItems[0].Index); - lv.FocusedItem = lv.SelectedItems[0]; - } - else if (lv.Items.Count > 0) - { - lv.EnsureVisible(0); - lv.FocusedItem = lv.Items[0]; - } - lv.EndUpdate(); - } - } - - public static void InverseSelection(this ListView lv) - { - lv.BeginUpdate(); - foreach (ListViewItem item in lv.Items) - { - item.Selected = !item.Selected; - } - lv.EndUpdate(); - } - - internal static void CleanUpMenuItemPlugin(ToolStripMenuItem tsmi) - { - if (tsmi == null) - { - return; - } - for (int k = tsmi.DropDownItems.Count - 1; k > 0; k--) - { - ToolStripItem x = tsmi.DropDownItems[k]; - var fileName = (string)x.Tag; - if (!string.IsNullOrEmpty(fileName) && fileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) - { - tsmi.DropDownItems.Remove(x); - } - } - } - - public static Color BackColor => Configuration.Settings.General.UseDarkTheme ? DarkTheme.BackColor : Control.DefaultBackColor; - - public static Color ForeColor => Configuration.Settings.General.UseDarkTheme ? DarkTheme.ForeColor : Control.DefaultForeColor; - - public static void OpenFolderFromFileName(string fileName) - { - string folderName = Path.GetDirectoryName(fileName); - if (Configuration.IsRunningOnWindows) - { - string argument = @"/select, " + fileName; - System.Diagnostics.Process.Start("explorer.exe", argument); - } - else - { - UiUtil.OpenFolder(folderName); - } - } - - public static void OpenFolder(string folder) - { - OpenItem(folder, "folder"); - } - - public static void OpenURL(string url) - { - OpenItem(url, "url"); - } - - public static void OpenFile(string file) - { - OpenItem(file, "file"); - } - - public static void OpenItem(string item, string type) - { - try - { - if (Configuration.IsRunningOnWindows || Configuration.IsRunningOnMac) - { - System.Diagnostics.Process.Start(item); - } - else if (Configuration.IsRunningOnLinux) - { - System.Diagnostics.Process process = new System.Diagnostics.Process(); - process.EnableRaisingEvents = false; - process.StartInfo.FileName = "xdg-open"; - process.StartInfo.Arguments = item; - process.Start(); - } - } - catch (Exception exception) - { - MessageBox.Show($"Cannot open {type}: {item}{Environment.NewLine}{Environment.NewLine}{exception.Source}: {exception.Message}", "Error opening URL", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } -} +using Nikse.SubtitleEdit.Controls; +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using Nikse.SubtitleEdit.Forms; +using Nikse.SubtitleEdit.Logic.VideoPlayers; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic +{ + internal static class UiUtil + { + public static readonly Lazy<string> SubtitleExtensionFilter = new Lazy<string>(GetOpenDialogFilter); + + public static VideoInfo GetVideoInfo(string fileName) + { + var info = FileUtil.TryReadVideoInfoViaAviHeader(fileName); + if (info.Success) + { + return info; + } + + info = FileUtil.TryReadVideoInfoViaMatroskaHeader(fileName); + if (info.Success) + { + return info; + } + + info = FileUtil.TryReadVideoInfoViaMp4(fileName); + if (info.Success) + { + return info; + } + + info = TryReadVideoInfoViaDirectShow(fileName); + if (info.Success) + { + return info; + } + + return new VideoInfo { VideoCodec = "Unknown" }; + } + + private static VideoInfo TryReadVideoInfoViaDirectShow(string fileName) + { + return QuartsPlayer.GetVideoInfo(fileName); + } + + private static long _lastShowSubTicks = DateTime.UtcNow.Ticks; + private static int _lastShowSubHash; + + public static int ShowSubtitle(Subtitle subtitle, VideoPlayerContainer videoPlayerContainer) + { + if (videoPlayerContainer.VideoPlayer == null) + { + return -1; + } + + double positionInMilliseconds = videoPlayerContainer.CurrentPosition * TimeCode.BaseUnit; + var max = subtitle.Paragraphs.Count; + for (int i = 0; i < max; i++) + { + var p = subtitle.Paragraphs[i]; + if (p.StartTime.TotalMilliseconds <= positionInMilliseconds + 0.01 && p.EndTime.TotalMilliseconds >= positionInMilliseconds - 0.01) + { + string text = p.Text.Replace("|", Environment.NewLine); + bool isInfo = p == subtitle.Paragraphs[0] && (Math.Abs(p.StartTime.TotalMilliseconds) < 0.01 && Math.Abs(p.Duration.TotalMilliseconds) < 0.01 || Math.Abs(p.StartTime.TotalMilliseconds - Pac.PacNullTime.TotalMilliseconds) < 0.01); + if (!isInfo) + { + if (videoPlayerContainer.LastParagraph != p) + { + videoPlayerContainer.SetSubtitleText(text, p, subtitle); + } + else if (videoPlayerContainer.SubtitleText != text) + { + videoPlayerContainer.SetSubtitleText(text, p, subtitle); + } + TimeOutRefresh(subtitle, videoPlayerContainer, p); + return i; + } + } + } + + if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText)) + { + videoPlayerContainer.SetSubtitleText(string.Empty, null, subtitle); + } + else + { + TimeOutRefresh(subtitle, videoPlayerContainer); + } + return -1; + } + + private static void TimeOutRefresh(Subtitle subtitle, VideoPlayerContainer videoPlayerContainer, Paragraph p = null) + { + if (DateTime.UtcNow.Ticks - _lastShowSubTicks > 10000 * 1000) // more than 1+ seconds ago + { + var newHash = subtitle.GetFastHashCode(string.Empty); + if (newHash != _lastShowSubHash) + { + videoPlayerContainer.SetSubtitleText(p == null ? string.Empty : p.Text, p, subtitle); + _lastShowSubHash = newHash; + } + + _lastShowSubTicks = DateTime.UtcNow.Ticks; + } + } + + public static int ShowSubtitle(Subtitle subtitle, Subtitle original, VideoPlayerContainer videoPlayerContainer) + { + if (videoPlayerContainer.VideoPlayer == null) + { + return -1; + } + + double positionInMilliseconds = (videoPlayerContainer.VideoPlayer.CurrentPosition * TimeCode.BaseUnit) + 15; + var max = subtitle.Paragraphs.Count; + for (int i = 0; i < max; i++) + { + var p = subtitle.Paragraphs[i]; + if (p.StartTime.TotalMilliseconds <= positionInMilliseconds && p.EndTime.TotalMilliseconds > positionInMilliseconds) + { + var op = Utilities.GetOriginalParagraph(0, p, original.Paragraphs); + string text = p.Text.Replace("|", Environment.NewLine); + if (op != null) + { + text = text + Environment.NewLine + Environment.NewLine + op.Text.Replace("|", Environment.NewLine); + } + + bool isInfo = p == subtitle.Paragraphs[0] && Math.Abs(p.StartTime.TotalMilliseconds) < 0.01 && positionInMilliseconds > 3000; + if (!isInfo) + { + if (videoPlayerContainer.LastParagraph != p || videoPlayerContainer.SubtitleText != text) + { + videoPlayerContainer.SetSubtitleText(text, p, subtitle); + } + return i; + } + } + } + if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText)) + { + videoPlayerContainer.SetSubtitleText(string.Empty, null, subtitle); + } + return -1; + } + + public static bool IsQuartsDllInstalled + { + get + { + if (Utilities.IsRunningOnMono()) + { + return false; + } + + string quartzFileName = Environment.GetFolderPath(Environment.SpecialFolder.System).TrimEnd('\\') + @"\quartz.dll"; + return File.Exists(quartzFileName); + } + } + + public static bool IsMpcHcInstalled + { + get + { + if (Utilities.IsRunningOnMono()) + { + return false; + } + + try + { + return VideoPlayers.MpcHC.MpcHc.GetMpcHcFileName() != null; + } + catch (FileNotFoundException) + { + return false; + } + } + } + + public static VideoPlayer GetVideoPlayer() + { + var gs = Configuration.Settings.General; + + if (Configuration.IsRunningOnLinux) + { + if (gs.VideoPlayer == "VLC" && LibVlcDynamic.IsInstalled) + { + return new LibVlcDynamic(); + } + if (LibMpvDynamic.IsInstalled) + { + return new LibMpvDynamic(); + } + throw new NotSupportedException("You need 'libmpv-dev' or 'libvlc-dev' (on Ubuntu) and X11 to use the video player on Linux!"); + } + // Mono on OS X is 32 bit and thus requires 32 bit VLC. Place VLC in the same + // folder as Subtitle Edit and add this to the app.config inside the + // "configuration" element: + // <dllmap dll="libvlc" target="VLC.app/Contents/MacOS/lib/libvlc.dylib" /> + if (Configuration.IsRunningOnMac) + { + return new LibVlcMono(); + } + + if (gs.VideoPlayer == "VLC" && LibVlcDynamic.IsInstalled) + { + return new LibVlcDynamic(); + } + + if (gs.VideoPlayer == "MPV" && LibMpvDynamic.IsInstalled) + { + return new LibMpvDynamic(); + } + + if (gs.VideoPlayer == "MPC-HC" && VideoPlayers.MpcHC.MpcHc.IsInstalled) + { + return new VideoPlayers.MpcHC.MpcHc(); + } + + if (IsQuartsDllInstalled) + { + return new QuartsPlayer(); + } + + throw new NotSupportedException("You need DirectX, or mpv media player, or VLC media player installed as well as Subtitle Edit dll files in order to use the video player!"); + } + + public static bool InitializeVideoPlayerAndContainer(string fileName, VideoInfo videoInfo, VideoPlayerContainer videoPlayerContainer, EventHandler onVideoLoaded, EventHandler onVideoEnded) + { + try + { + videoPlayerContainer.VideoPlayer = GetVideoPlayer(); + videoPlayerContainer.VideoPlayer.Initialize(videoPlayerContainer.PanelPlayer, fileName, onVideoLoaded, onVideoEnded); + videoPlayerContainer.ShowStopButton = Configuration.Settings.General.VideoPlayerShowStopButton; + videoPlayerContainer.ShowFullscreenButton = false; + videoPlayerContainer.ShowMuteButton = Configuration.Settings.General.VideoPlayerShowMuteButton; + videoPlayerContainer.Volume = Configuration.Settings.General.VideoPlayerDefaultVolume; + videoPlayerContainer.EnableMouseWheelStep(); + if (fileName != null && (fileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase) || fileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase))) + { + // we don't have videoInfo for streams... + } + else + { + videoPlayerContainer.VideoWidth = videoInfo.Width; + videoPlayerContainer.VideoHeight = videoInfo.Height; + videoPlayerContainer.VideoPlayer.Resize(videoPlayerContainer.PanelPlayer.Width, videoPlayerContainer.PanelPlayer.Height); + } + + return true; + } + catch (Exception exception) + { + videoPlayerContainer.VideoPlayer = null; + var videoError = new VideoError(); + videoError.Initialize(fileName, exception); + videoError.ShowDialog(); + SeLogger.Error(exception, "InitializeVideoPlayerAndContainer failed to load video player"); + return false; + } + } + + public static void CheckAutoWrap(TextBox textBox, KeyEventArgs e, int numberOfNewLines) + { + // Do not auto-break lines more than 1 line. + if (numberOfNewLines != 1 || !Configuration.Settings.General.AutoWrapLineWhileTyping) + { + return; + } + + int length = HtmlUtil.RemoveHtmlTags(textBox.Text, true).Length; + if (e.Modifiers == Keys.None && e.KeyCode != Keys.Enter && length > Configuration.Settings.General.SubtitleLineMaximumLength) + { + string newText; + if (length > Configuration.Settings.General.SubtitleLineMaximumLength + 30) + { + newText = Utilities.AutoBreakLine(textBox.Text); + } + else + { + int lastSpace = textBox.Text.LastIndexOf(' '); + if (lastSpace > 0) + { + newText = textBox.Text.Remove(lastSpace, 1).Insert(lastSpace, Environment.NewLine); + } + else + { + newText = textBox.Text; + } + } + + int autoBreakIndex = newText.IndexOf(Environment.NewLine, StringComparison.Ordinal); + if (autoBreakIndex > 0) + { + int selectionStart = textBox.SelectionStart; + textBox.Text = newText; + if (selectionStart > autoBreakIndex) + { + selectionStart += Environment.NewLine.Length - 1; + } + if (selectionStart >= 0) + { + textBox.SelectionStart = selectionStart; + } + } + } + } + + public static void CheckAutoWrap(SETextBox textBox, KeyEventArgs e, int numberOfNewLines) + { + // Do not auto-break lines more than 1 line. + if (numberOfNewLines != 1 || !Configuration.Settings.General.AutoWrapLineWhileTyping) + { + return; + } + + int length = HtmlUtil.RemoveHtmlTags(textBox.Text, true).Length; + if (e.Modifiers == Keys.None && e.KeyCode != Keys.Enter && length > Configuration.Settings.General.SubtitleLineMaximumLength) + { + string newText; + if (length > Configuration.Settings.General.SubtitleLineMaximumLength + 30) + { + newText = Utilities.AutoBreakLine(textBox.Text); + } + else + { + int lastSpace = textBox.Text.LastIndexOf(' '); + if (lastSpace > 0) + { + newText = textBox.Text.Remove(lastSpace, 1).Insert(lastSpace, Environment.NewLine); + } + else + { + newText = textBox.Text; + } + } + + int autoBreakIndex = newText.IndexOf(Environment.NewLine, StringComparison.Ordinal); + if (autoBreakIndex > 0) + { + int selectionStart = textBox.SelectionStart; + textBox.Text = newText; + if (selectionStart > autoBreakIndex) + { + selectionStart += Environment.NewLine.Length - 1; + } + if (selectionStart >= 0) + { + textBox.SelectionStart = selectionStart; + } + } + } + } + + private static readonly Dictionary<string, Keys> AllKeys = new Dictionary<string, Keys>(); + private static Keys _helpKeys; + + public static Keys GetKeys(string keysInString) + { + if (string.IsNullOrEmpty(keysInString)) + { + return Keys.None; + } + + if (AllKeys.Count == 0) + { + foreach (Keys val in Enum.GetValues(typeof(Keys))) + { + string k = val.ToString().ToLowerInvariant(); + if (!AllKeys.ContainsKey(k)) + { + AllKeys.Add(k, val); + } + } + if (!AllKeys.ContainsKey("pagedown")) + { + AllKeys.Add("pagedown", Keys.RButton | Keys.Space); + } + + if (!AllKeys.ContainsKey("home")) + { + AllKeys.Add("home", Keys.MButton | Keys.Space); + } + + if (!AllKeys.ContainsKey("capslock")) + { + AllKeys.Add("capslock", Keys.CapsLock); + } + } + + string[] parts = keysInString.ToLowerInvariant().Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries); + var resultKeys = Keys.None; + foreach (string k in parts) + { + if (AllKeys.ContainsKey(k)) + { + resultKeys = resultKeys | AllKeys[k]; + } + } + return resultKeys; + } + + public static Keys HelpKeys + { + get + { + if (_helpKeys == Keys.None) + { + _helpKeys = GetKeys(Configuration.Settings.Shortcuts.GeneralHelp); + } + return _helpKeys; + } + set => _helpKeys = value; + } + + public static void SetButtonHeight(Control control, int newHeight, int level) + { + if (level > 6) + { + return; + } + + if (control.HasChildren) + { + foreach (Control subControl in control.Controls) + { + if (subControl.HasChildren) + { + SetButtonHeight(subControl, newHeight, level + 1); + } + else if (subControl is Button) + { + subControl.Height = newHeight; + } + } + } + else if (control is Button) + { + control.Height = newHeight; + } + } + + public static void InitializeSubtitleFont(Control control) + { + var gs = Configuration.Settings.General; + + if (string.IsNullOrEmpty(gs.SubtitleFontName)) + { + gs.SubtitleFontName = DefaultSystemFont.Name; + } + + try + { + if (control is ListView) + { + if (gs.SubtitleListViewFontBold) + { + control.Font = new Font(gs.SubtitleFontName, gs.SubtitleListViewFontSize, FontStyle.Bold); + } + else + { + control.Font = new Font(gs.SubtitleFontName, gs.SubtitleListViewFontSize); + } + } + else if (control is SETextBox || control is TextBox) + { + if (gs.SubtitleTextBoxFontBold) + { + control.Font = new Font(gs.SubtitleFontName, gs.SubtitleTextBoxFontSize, FontStyle.Bold); + } + else + { + control.Font = new Font(gs.SubtitleFontName, gs.SubtitleTextBoxFontSize); + } + } + + control.BackColor = gs.SubtitleBackgroundColor; + control.ForeColor = gs.SubtitleFontColor; + } + catch + { + // ignored + } + } + + private static Font _defaultSystemFont; + private static Font DefaultSystemFont + { + get + { + if (_defaultSystemFont != null) + { + return _defaultSystemFont; + } + + var font = SystemFonts.MessageBoxFont; + if (Configuration.IsRunningOnLinux && IsFontPresent(Configuration.DefaultLinuxFontName)) + { + font = new Font(Configuration.DefaultLinuxFontName, 8F); + } + + _defaultSystemFont = IsFontPresent(font.Name) ? font : SystemFonts.DefaultFont; + return _defaultSystemFont; + } + } + + private static bool IsFontPresent(string fontName) + { + try + { + // Bold + italic + regular must be present + _ = new Font(fontName, 9, FontStyle.Bold); + _ = new Font(fontName, 9, FontStyle.Italic); + _ = new Font(fontName, 9, FontStyle.Regular); + return true; + } + catch + { + // ignore + } + + return false; + } + + public static Font GetDefaultFont() + { + var gs = Configuration.Settings.General; + if (string.IsNullOrEmpty(gs.SystemSubtitleFontNameOverride) || gs.SystemSubtitleFontSizeOverride < 5) + { + return DefaultSystemFont; + } + + try + { + return new Font(gs.SystemSubtitleFontNameOverride, gs.SystemSubtitleFontSizeOverride); + } + catch + { + return DefaultSystemFont; + } + } + + internal static void PreInitialize(Form form) + { + form.AutoScaleMode = AutoScaleMode.Dpi; + form.Font = GetDefaultFont(); + } + + public static void FixFonts(Control form, int iterations = 5) + { + FixFontsInner(form, iterations); + if (Configuration.Settings.General.UseDarkTheme) + { + DarkTheme.SetDarkTheme(form, 1500); + } + } + + internal static void FixFonts(ToolStripItem item) + { + item.Font = GetDefaultFont(); + if (Configuration.Settings.General.UseDarkTheme) + { + DarkTheme.SetDarkTheme(item); + } + } + + internal static void FixFonts(ToolStripComboBox item) + { + item.Font = GetDefaultFont(); + if (Configuration.Settings.General.UseDarkTheme) + { + DarkTheme.SetDarkTheme(item); + } + } + + private static void FixFontsInner(Control form, int iterations = 5) + { + if (iterations < 1 || form is SETextBox) + { + return; + } + + if (form is ContextMenuStrip cms) + { + foreach (var item in cms.Items) + { + if (item is ToolStripMenuItem tsmi) + { + tsmi.Font = GetDefaultFont(); + if (tsmi.HasDropDownItems) + { + foreach (var innerItem in tsmi.DropDownItems) + { + if (innerItem is ToolStripMenuItem innerTsmi) + { + innerTsmi.Font = GetDefaultFont(); + } + } + } + } + } + } + + if (form is TimeUpDown timeUpDown) + { + using (var g = Graphics.FromHwnd(IntPtr.Zero)) + { + var width = g.MeasureString("00:00:00.000", form.Font).Width; + if (timeUpDown.MaskedTextBox.Width < width - 3) + { + timeUpDown.MaskedTextBox.Font = new Font(timeUpDown.MaskedTextBox.Font.FontFamily, timeUpDown.MaskedTextBox.Font.Size - 1); + } + width = g.MeasureString("00:00:00.000", form.Font).Width; + if (timeUpDown.MaskedTextBox.Width < width - 3) + { + timeUpDown.MaskedTextBox.Font = new Font(timeUpDown.MaskedTextBox.Font.FontFamily, timeUpDown.MaskedTextBox.Font.Size - 1); + } + } + } + + foreach (Control c in form.Controls) + { + if (!c.Font.Name.Equals("Tahoma", StringComparison.Ordinal)) + { + c.Font = GetDefaultFont(); + } + + foreach (Control inner in c.Controls) + { + FixFontsInner(inner, iterations - 1); + } + } + } + + public static void FixLargeFonts(Control mainCtrl, Control ctrl) + { + using (Graphics graphics = mainCtrl.CreateGraphics()) + { + SizeF textSize = graphics.MeasureString(ctrl.Text, ctrl.Font); + if (textSize.Height > ctrl.Height - 4) + { + SetButtonHeight(mainCtrl, (int)Math.Round(textSize.Height + 7.5), 1); + } + } + } + + public static void SetSaveDialogFilter(SaveFileDialog saveFileDialog, SubtitleFormat currentFormat) + { + var sb = new StringBuilder(); + int index = 0; + foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats) + { + sb.Append(format.Name + "|*" + format.Extension + "|"); + if (currentFormat.Name == format.Name) + { + saveFileDialog.FilterIndex = index + 1; + } + index++; + } + saveFileDialog.Filter = sb.ToString().TrimEnd('|'); + } + + public static void GetLineLengths(Label label, string text) + { + label.ForeColor = ForeColor; + var lines = text.SplitToLines(); + const int max = 3; + var sb = new StringBuilder(); + for (int i = 0; i < lines.Count; i++) + { + string line = lines[i]; + if (i > 0) + { + sb.Append('/'); + } + + if (i > max) + { + sb.Append("..."); + label.Text = sb.ToString(); + return; + } + + sb.Append(line.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics)); + if (line.CountCharacters(false, Configuration.Settings.General.IgnoreArabicDiacritics) > Configuration.Settings.General.SubtitleLineMaximumLength || i >= Configuration.Settings.General.MaxNumberOfLines) + { + label.ForeColor = Color.Red; + } + } + label.Text = sb.ToString(); + } + + public static void GetLinePixelWidths(Label label, string text) + { + label.ForeColor = ForeColor; + var lines = text.SplitToLines(); + const int max = 3; + var sb = new StringBuilder(); + for (int i = 0; i < lines.Count; i++) + { + string line = lines[i]; + if (i > 0) + { + sb.Append('/'); + } + + if (i > max) + { + sb.Append("..."); + label.Text = sb.ToString(); + return; + } + + int lineWidth = TextWidth.CalcPixelWidth(line); + sb.Append(lineWidth); + if (lineWidth > Configuration.Settings.General.SubtitleLineMaximumPixelWidth) + { + label.ForeColor = Color.Red; + } + } + label.Text = sb.ToString(); + } + + public static void InitializeSubtitleFormatComboBox(ToolStripComboBox comboBox, SubtitleFormat format) + { + InitializeSubtitleFormatComboBox(comboBox.ComboBox, format); + comboBox.DropDownWidth += 5; // .Net quirk? + } + + public static void InitializeSubtitleFormatComboBox(ComboBox comboBox, SubtitleFormat format) + { + InitializeSubtitleFormatComboBox(comboBox, new List<string> { format.FriendlyName }, format.FriendlyName); + } + + public static void InitializeSubtitleFormatComboBox(ToolStripComboBox comboBox, string selectedName) + { + InitializeSubtitleFormatComboBox(comboBox.ComboBox, selectedName); + comboBox.DropDownWidth += 5; // .Net quirk? + } + + public static void InitializeSubtitleFormatComboBox(ComboBox comboBox, string selectedName) + { + var formatNames = SubtitleFormat.AllSubtitleFormats.Where(format => !format.IsVobSubIndexFile).Select(format => format.FriendlyName); + InitializeSubtitleFormatComboBox(comboBox, formatNames.ToList(), selectedName); + } + + public static void InitializeSubtitleFormatComboBox(ComboBox comboBox, List<string> formatNames, string selectedName) + { + var selectedIndex = 0; + using (var graphics = comboBox.CreateGraphics()) + { + var maxWidth = (float)comboBox.DropDownWidth; + var max = formatNames.Count; + for (var index = 0; index < max; index++) + { + var name = formatNames[index]; + if (name.Equals(selectedName, StringComparison.OrdinalIgnoreCase)) + { + selectedIndex = index; + } + if (name.Length > 30) + { + var width = graphics.MeasureString(name, comboBox.Font).Width; + if (width > maxWidth) + { + maxWidth = width; + } + } + } + comboBox.DropDownWidth = (int)Math.Round(maxWidth + 7.5); + } + comboBox.BeginUpdate(); + comboBox.Items.Clear(); + comboBox.Items.AddRange(formatNames.ToArray<object>()); + comboBox.SelectedIndex = selectedIndex; + comboBox.EndUpdate(); + } + + public static void InitializeTextEncodingComboBox(ComboBox comboBox) + { + var defaultEncoding = Configuration.Settings.General.DefaultEncoding; + var selectedItem = (TextEncoding)null; + comboBox.BeginUpdate(); + comboBox.Items.Clear(); + var encList = new List<TextEncoding>(); + using (var graphics = comboBox.CreateGraphics()) + { + var maxWidth = 0.0F; + foreach (var encoding in Configuration.AvailableEncodings) + { + if (encoding.CodePage >= 874 && !encoding.IsEbcdic()) + { + var item = new TextEncoding(encoding, null); + if (selectedItem == null && item.Equals(defaultEncoding)) + { + selectedItem = item; + } + var width = graphics.MeasureString(item.DisplayName, comboBox.Font).Width; + if (width > maxWidth) + { + maxWidth = width; + } + if (encoding.CodePage.Equals(Encoding.UTF8.CodePage)) + { + item = new TextEncoding(Encoding.UTF8, TextEncoding.Utf8WithBom); + encList.Insert(TextEncoding.Utf8WithBomIndex, item); + if (item.Equals(defaultEncoding)) + { + selectedItem = item; + } + + item = new TextEncoding(Encoding.UTF8, TextEncoding.Utf8WithoutBom); + encList.Insert(TextEncoding.Utf8WithoutBomIndex, item); + if (item.Equals(defaultEncoding)) + { + selectedItem = item; + } + } + else + { + encList.Add(item); + } + } + } + comboBox.DropDownWidth = (int)Math.Round(maxWidth + 7.5); + } + comboBox.Items.AddRange(encList.ToArray<object>()); + if (selectedItem == null) + { + comboBox.SelectedIndex = TextEncoding.Utf8WithBomIndex; // UTF-8 if DefaultEncoding is not found + } + else if (selectedItem.DisplayName == TextEncoding.Utf8WithoutBom) + { + comboBox.SelectedIndex = TextEncoding.Utf8WithoutBomIndex; + } + else + { + comboBox.SelectedItem = selectedItem; + } + comboBox.EndUpdate(); + if (comboBox.SelectedItem is TextEncoding textEncodingListItem) + { + Configuration.Settings.General.DefaultEncoding = textEncodingListItem.DisplayName; + } + comboBox.AutoCompleteSource = AutoCompleteSource.ListItems; + comboBox.AutoCompleteMode = AutoCompleteMode.Append; + } + + public static TextEncoding GetTextEncodingComboBoxCurrentEncoding(ComboBox comboBox) + { + if (comboBox.SelectedIndex > 0 && comboBox.SelectedItem is TextEncoding textEncodingListItem) + { + return textEncodingListItem; + } + return new TextEncoding(Encoding.UTF8, TextEncoding.Utf8WithBom); + } + + public static void SetTextEncoding(ToolStripComboBox comboBoxEncoding, string encodingName) + { + if (encodingName == TextEncoding.Utf8WithBom) + { + comboBoxEncoding.SelectedIndex = TextEncoding.Utf8WithBomIndex; + return; + } + + if (encodingName == TextEncoding.Utf8WithoutBom) + { + comboBoxEncoding.SelectedIndex = TextEncoding.Utf8WithoutBomIndex; + return; + } + + foreach (TextEncoding item in comboBoxEncoding.Items) + { + if (item.Equals(encodingName)) + { + comboBoxEncoding.SelectedItem = item; + return; + } + } + + comboBoxEncoding.SelectedIndex = TextEncoding.Utf8WithBomIndex; // UTF-8 with BOM + } + + + + private const string BreakChars = "\",:;.¡!¿?()[]{}<>♪♫-–—/#*|؟،"; + + public static void ApplyControlBackspace(TextBox textBox) + { + if (textBox.SelectionLength == 0) + { + var text = textBox.Text; + var deleteUpTo = textBox.SelectionStart; + if (deleteUpTo > 0 && deleteUpTo <= text.Length) + { + text = text.Substring(0, deleteUpTo); + var textElementIndices = StringInfo.ParseCombiningCharacters(text); + var index = textElementIndices.Length; + var textIndex = deleteUpTo; + var deleteFrom = -1; + while (index > 0) + { + index--; + textIndex = textElementIndices[index]; + if (!IsSpaceCategory(CharUnicodeInfo.GetUnicodeCategory(text, textIndex))) + { + break; + } + } + if (index > 0) // HTML tag? + { + if (text[textIndex] == '>') + { + var openingBracketIndex = text.LastIndexOf('<', textIndex - 1); + if (openingBracketIndex >= 0 && text.IndexOf('>', openingBracketIndex + 1) == textIndex) + { + deleteFrom = openingBracketIndex; // delete whole tag + } + } + else if (text[textIndex] == '}') + { + var startIdx = text.LastIndexOf(@"{\", textIndex - 1, StringComparison.Ordinal); + if (startIdx >= 0 && text.IndexOf('}', startIdx + 1) == textIndex) + { + deleteFrom = startIdx; + } + } + } + if (deleteFrom < 0) + { + if (BreakChars.Contains(text[textIndex])) + { + deleteFrom = -2; + } + + while (index > 0) + { + index--; + textIndex = textElementIndices[index]; + if (IsSpaceCategory(CharUnicodeInfo.GetUnicodeCategory(text, textIndex))) + { + if (deleteFrom > -2) + { + if (deleteFrom < 0) + { + deleteFrom = textElementIndices[index + 1]; + } + break; + } + deleteFrom = textElementIndices[index + 1]; + if (!":!?".Contains(text[deleteFrom])) + { + break; + } + } + else if (BreakChars.Contains(text[textIndex])) + { + if (deleteFrom > -2) + { + if (deleteFrom < 0) + { + deleteFrom = textElementIndices[index + 1]; + } + break; + } + } + else + { + deleteFrom = -1; + } + } + } + if (deleteFrom < deleteUpTo) + { + if (deleteFrom < 0) + { + deleteFrom = 0; + } + textBox.Select(deleteFrom, deleteUpTo - deleteFrom); + textBox.Paste(string.Empty); + } + } + } + } + + public static void SelectWordAtCaret(SETextBox textBox) + { + var text = textBox.Text; + var endIndex = textBox.SelectionStart; + var startIndex = endIndex; + + while (startIndex > 0 && !IsSpaceCategory(CharUnicodeInfo.GetUnicodeCategory(text[startIndex - 1])) && !BreakChars.Contains(text[startIndex - 1])) + { + startIndex--; + } + textBox.SelectionStart = startIndex; + + while (endIndex < text.Length && !IsSpaceCategory(CharUnicodeInfo.GetUnicodeCategory(text[endIndex])) && !BreakChars.Contains(text[endIndex])) + { + endIndex++; + } + textBox.SelectionLength = endIndex - startIndex; + } + + private static bool IsSpaceCategory(UnicodeCategory c) + { + return c == UnicodeCategory.SpaceSeparator || c == UnicodeCategory.Control || c == UnicodeCategory.LineSeparator || c == UnicodeCategory.ParagraphSeparator; + } + + private static void AddExtension(StringBuilder sb, string extension) + { + if (!sb.ToString().Contains("*" + extension + ";", StringComparison.OrdinalIgnoreCase)) + { + sb.Append('*'); + sb.Append(extension.TrimStart('*')); + sb.Append(';'); + } + } + + private static string GetOpenDialogFilter() + { + var sb = new StringBuilder(); + sb.Append(Configuration.Settings.Language.General.SubtitleFiles + "|"); + foreach (SubtitleFormat s in SubtitleFormat.AllSubtitleFormats) + { + AddExtension(sb, s.Extension); + foreach (string ext in s.AlternateExtensions) + { + AddExtension(sb, ext); + } + } + AddExtension(sb, new Pac().Extension); + AddExtension(sb, new Cavena890().Extension); + AddExtension(sb, new Spt().Extension); + AddExtension(sb, new Sptx().Extension); + AddExtension(sb, new Wsb().Extension); + AddExtension(sb, new CheetahCaption().Extension); + AddExtension(sb, ".chk"); + AddExtension(sb, new CaptionsInc().Extension); + AddExtension(sb, new Ultech130().Extension); + AddExtension(sb, new ELRStudioClosedCaption().Extension); + AddExtension(sb, ".uld"); // Ultech drop frame + AddExtension(sb, new SonicScenaristBitmaps().Extension); + AddExtension(sb, ".mks"); + AddExtension(sb, ".mxf"); + AddExtension(sb, ".sup"); + AddExtension(sb, ".dost"); + AddExtension(sb, new FinalDraftTemplate2().Extension); + AddExtension(sb, new Ayato().Extension); + AddExtension(sb, new PacUnicode().Extension); + AddExtension(sb, new WinCaps32().Extension); + AddExtension(sb, new IsmtDfxp().Extension); + AddExtension(sb, new PlayCaptionsFreeEditor().Extension); + AddExtension(sb, ".cdg"); // karaoke + + if (!string.IsNullOrEmpty(Configuration.Settings.General.OpenSubtitleExtraExtensions)) + { + var extraExtensions = Configuration.Settings.General.OpenSubtitleExtraExtensions.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + foreach (string ext in extraExtensions) + { + if (ext.StartsWith("*.", StringComparison.Ordinal) && !sb.ToString().Contains(ext, StringComparison.OrdinalIgnoreCase)) + { + AddExtension(sb, ext); + } + } + } + AddExtension(sb, ".son"); + AddExtension(sb, ".mts"); + AddExtension(sb, ".m2ts"); + + sb.Append('|'); + sb.Append(Configuration.Settings.Language.General.AllFiles); + sb.Append("|*.*"); + return sb.ToString(); + } + + public static string GetListViewTextFromString(string s) => s.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString); + + public static string GetStringFromListViewText(string lviText) => lviText.Replace(Configuration.Settings.General.ListViewLineSeparatorString, Environment.NewLine); + + public static void SelectAll(this ListView lv) + { + lv.BeginUpdate(); + foreach (ListViewItem item in lv.Items) + { + item.Selected = true; + } + lv.EndUpdate(); + } + + public static void SelectFirstSelectedItemOnly(this ListView lv) + { + int itemsCount = lv.SelectedItems.Count - 1; + if (itemsCount > 0) + { + lv.BeginUpdate(); + do + { + lv.SelectedItems[itemsCount--].Selected = false; + } + while (itemsCount > 0); + if (lv.SelectedItems.Count > 0) + { + lv.EnsureVisible(lv.SelectedItems[0].Index); + lv.FocusedItem = lv.SelectedItems[0]; + } + else if (lv.Items.Count > 0) + { + lv.EnsureVisible(0); + lv.FocusedItem = lv.Items[0]; + } + lv.EndUpdate(); + } + } + + public static void InverseSelection(this ListView lv) + { + lv.BeginUpdate(); + foreach (ListViewItem item in lv.Items) + { + item.Selected = !item.Selected; + } + lv.EndUpdate(); + } + + internal static void CleanUpMenuItemPlugin(ToolStripMenuItem tsmi) + { + if (tsmi == null) + { + return; + } + for (int k = tsmi.DropDownItems.Count - 1; k > 0; k--) + { + ToolStripItem x = tsmi.DropDownItems[k]; + var fileName = (string)x.Tag; + if (!string.IsNullOrEmpty(fileName) && fileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) + { + tsmi.DropDownItems.Remove(x); + } + } + } + + public static Color BackColor => Configuration.Settings.General.UseDarkTheme ? DarkTheme.BackColor : Control.DefaultBackColor; + + public static Color ForeColor => Configuration.Settings.General.UseDarkTheme ? DarkTheme.ForeColor : Control.DefaultForeColor; + + public static void OpenFolderFromFileName(string fileName) + { + string folderName = Path.GetDirectoryName(fileName); + if (Configuration.IsRunningOnWindows) + { + string argument = @"/select, " + fileName; + System.Diagnostics.Process.Start("explorer.exe", argument); + } + else + { + UiUtil.OpenFolder(folderName); + } + } + + public static void OpenFolder(string folder) + { + OpenItem(folder, "folder"); + } + + public static void OpenURL(string url) + { + OpenItem(url, "url"); + } + + public static void OpenFile(string file) + { + OpenItem(file, "file"); + } + + public static void OpenItem(string item, string type) + { + try + { + if (Configuration.IsRunningOnWindows || Configuration.IsRunningOnMac) + { + System.Diagnostics.Process.Start(item); + } + else if (Configuration.IsRunningOnLinux) + { + System.Diagnostics.Process process = new System.Diagnostics.Process(); + process.EnableRaisingEvents = false; + process.StartInfo.FileName = "xdg-open"; + process.StartInfo.Arguments = item; + process.Start(); + } + } + catch (Exception exception) + { + MessageBox.Show($"Cannot open {type}: {item}{Environment.NewLine}{Environment.NewLine}{exception.Source}: {exception.Message}", "Error opening URL", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/src/Logic/VideoPlayers/DirectShowLib2005.cs b/src/ui/Logic/VideoPlayers/DirectShowLib2005.cs similarity index 100% rename from src/Logic/VideoPlayers/DirectShowLib2005.cs rename to src/ui/Logic/VideoPlayers/DirectShowLib2005.cs diff --git a/src/Logic/VideoPlayers/LibMpvDynamic.cs b/src/ui/Logic/VideoPlayers/LibMpvDynamic.cs similarity index 97% rename from src/Logic/VideoPlayers/LibMpvDynamic.cs rename to src/ui/Logic/VideoPlayers/LibMpvDynamic.cs index fcae35a10..5da61fe4f 100644 --- a/src/Logic/VideoPlayers/LibMpvDynamic.cs +++ b/src/ui/Logic/VideoPlayers/LibMpvDynamic.cs @@ -1,705 +1,705 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Core.SubtitleFormats; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic.VideoPlayers -{ - public class LibMpvDynamic : VideoPlayer, IDisposable - { - - #region mpv dll methods - see https://github.com/mpv-player/mpv/blob/master/libmpv/client.h - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr MpvCreate(); - private MpvCreate _mpvCreate; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int MpvInitialize(IntPtr mpvHandle); - private MpvInitialize _mpvInitialize; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int MpvCommand(IntPtr mpvHandle, IntPtr utf8Strings); - private MpvCommand _mpvCommand; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr MpvWaitEvent(IntPtr mpvHandle, double wait); - private MpvWaitEvent _mpvWaitEvent; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int MpvSetOption(IntPtr mpvHandle, byte[] name, int format, ref long data); - private MpvSetOption _mpvSetOption; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int MpvSetOptionString(IntPtr mpvHandle, byte[] name, byte[] value); - private MpvSetOptionString _mpvSetOptionString; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int MpvGetPropertystring(IntPtr mpvHandle, byte[] name, int format, ref IntPtr data); - private MpvGetPropertystring _mpvGetPropertyString; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int MpvGetPropertyDouble(IntPtr mpvHandle, byte[] name, int format, ref double data); - private MpvGetPropertyDouble _mpvGetPropertyDouble; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int MpvSetProperty(IntPtr mpvHandle, byte[] name, int format, ref byte[] data); - private MpvSetProperty _mpvSetProperty; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void MpvFree(IntPtr data); - private MpvFree _mpvFree; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate ulong MpvClientApiVersion(); - private MpvClientApiVersion _mpvClientApiVersion; - - #endregion - - private static IntPtr _libMpvDll = IntPtr.Zero; - private IntPtr _mpvHandle; - private Timer _videoLoadedTimer; - private double? _pausePosition; // Hack to hold precise seeking when paused - private string _secondSubtitleFileName; - - public override event EventHandler OnVideoLoaded; - public override event EventHandler OnVideoEnded; - - private const int MpvFormatString = 1; - - private object GetDllType(Type type, string name) - { - var address = NativeMethods.CrossGetProcAddress(_libMpvDll, name); - return address != IntPtr.Zero ? Marshal.GetDelegateForFunctionPointer(address, type) : null; - } - - private void LoadLibMpvDynamic() - { - _mpvCreate = (MpvCreate)GetDllType(typeof(MpvCreate), "mpv_create"); - _mpvInitialize = (MpvInitialize)GetDllType(typeof(MpvInitialize), "mpv_initialize"); - _mpvWaitEvent = (MpvWaitEvent)GetDllType(typeof(MpvWaitEvent), "mpv_wait_event"); - _mpvCommand = (MpvCommand)GetDllType(typeof(MpvCommand), "mpv_command"); - _mpvSetOption = (MpvSetOption)GetDllType(typeof(MpvSetOption), "mpv_set_option"); - _mpvSetOptionString = (MpvSetOptionString)GetDllType(typeof(MpvSetOptionString), "mpv_set_option_string"); - _mpvGetPropertyString = (MpvGetPropertystring)GetDllType(typeof(MpvGetPropertystring), "mpv_get_property"); - _mpvGetPropertyDouble = (MpvGetPropertyDouble)GetDllType(typeof(MpvGetPropertyDouble), "mpv_get_property"); - _mpvSetProperty = (MpvSetProperty)GetDllType(typeof(MpvSetProperty), "mpv_set_property"); - _mpvFree = (MpvFree)GetDllType(typeof(MpvFree), "mpv_free"); - _mpvClientApiVersion = (MpvClientApiVersion)GetDllType(typeof(MpvClientApiVersion), "mpv_client_api_version"); - } - - private bool IsAllMethodsLoaded() - { - return _mpvCreate != null && - _mpvInitialize != null && - _mpvWaitEvent != null && - _mpvCommand != null && - _mpvSetOption != null && - _mpvSetOptionString != null && - _mpvGetPropertyString != null && - _mpvGetPropertyDouble != null && - _mpvSetProperty != null && - _mpvFree != null; - } - - private static byte[] GetUtf8Bytes(string s) - { - return Encoding.UTF8.GetBytes(s + "\0"); - } - - public static IntPtr AllocateUtf8IntPtrArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers) - { - int numberOfStrings = arr.Length + 1; // add extra element for extra null pointer last (sentinel) - byteArrayPointers = new IntPtr[numberOfStrings]; - IntPtr rootPointer = Marshal.AllocCoTaskMem(IntPtr.Size * numberOfStrings); - for (int index = 0; index < arr.Length; index++) - { - var bytes = GetUtf8Bytes(arr[index]); - IntPtr unmanagedPointer = Marshal.AllocHGlobal(bytes.Length); - Marshal.Copy(bytes, 0, unmanagedPointer, bytes.Length); - byteArrayPointers[index] = unmanagedPointer; - } - Marshal.Copy(byteArrayPointers, 0, rootPointer, numberOfStrings); - return rootPointer; - } - - private void DoMpvCommand(params string[] args) - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - var mainPtr = AllocateUtf8IntPtrArrayWithSentinel(args, out var byteArrayPointers); - _mpvCommand(_mpvHandle, mainPtr); - foreach (var ptr in byteArrayPointers) - { - Marshal.FreeHGlobal(ptr); - } - Marshal.FreeHGlobal(mainPtr); - } - - public override string PlayerName => "libmpv " + VersionNumber; - - private int _volume = 75; - public override int Volume - { - get => _volume; - set - { - var v = Configuration.Settings.General.AllowVolumeBoost ? (int)Math.Round(value * 1.5) : value; - DoMpvCommand("set", "volume", v.ToString(CultureInfo.InvariantCulture)); - _volume = value; - } - } - - public override double Duration - { - get - { - lock (_lockObj) - { - if (_mpvHandle == IntPtr.Zero) - { - return 0; - } - - int mpvFormatDouble = 5; - double d = 0; - _mpvGetPropertyDouble(_mpvHandle, GetUtf8Bytes("duration"), mpvFormatDouble, ref d); - return d; - } - } - } - - public override double CurrentPosition - { - get - { - lock (_lockObj) - { - if (_mpvHandle == IntPtr.Zero) - { - return 0; - } - - if (_pausePosition != null) - { - if (_pausePosition < 0) - { - return 0; - } - - return _pausePosition.Value; - } - - int mpvFormatDouble = 5; - double d = 0; - _mpvGetPropertyDouble(_mpvHandle, GetUtf8Bytes("time-pos"), mpvFormatDouble, ref d); - return d; - } - } - set - { - lock (_lockObj) - { - - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - if (IsPaused && value <= Duration) - { - _pausePosition = value; - } - - DoMpvCommand("seek", value.ToString(CultureInfo.InvariantCulture), "absolute"); - } - } - } - - private double _playRate = 1.0; - public override double PlayRate - { - get => _playRate; - set - { - DoMpvCommand("set", "speed", value.ToString(CultureInfo.InvariantCulture)); - _playRate = value; - } - } - - public void GetNextFrame() - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - DoMpvCommand("frame-step"); - _pausePosition = null; - } - - public void GetPreviousFrame() - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - DoMpvCommand("frame-back-step"); - _pausePosition = null; - } - - public override void Play() - { - lock (_lockObj) - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - _pausePosition = null; - - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - var bytes = GetUtf8Bytes("no"); - _mpvSetProperty(_mpvHandle, GetUtf8Bytes("pause"), MpvFormatString, ref bytes); - } - } - - public override void Pause() - { - lock (_lockObj) - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - var bytes = GetUtf8Bytes("yes"); - _mpvSetProperty(_mpvHandle, GetUtf8Bytes("pause"), MpvFormatString, ref bytes); - } - } - - public override void Stop() - { - lock (_lockObj) - { - - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - Pause(); - _pausePosition = null; - CurrentPosition = 0; - } - } - - public override bool IsPaused - { - get - { - if (_mpvHandle == IntPtr.Zero) - { - return true; - } - - var lpBuffer = IntPtr.Zero; - _mpvGetPropertyString(_mpvHandle, GetUtf8Bytes("pause"), MpvFormatString, ref lpBuffer); - var isPaused = Marshal.PtrToStringAnsi(lpBuffer) == "yes"; - _mpvFree(lpBuffer); - return isPaused; - } - } - - public override bool IsPlaying => !IsPaused; - - private List<KeyValuePair<int, string>> _audioTrackIds; - public List<KeyValuePair<int, string>> AudioTracks - { - get - { - if (_audioTrackIds == null) - { - _audioTrackIds = new List<KeyValuePair<int, string>>(); - var lpBuffer = IntPtr.Zero; - _mpvGetPropertyString(_mpvHandle, GetUtf8Bytes("track-list"), MpvFormatString, ref lpBuffer); - string trackListJson = Marshal.PtrToStringAnsi(lpBuffer); - foreach (var json in Json.ReadObjectArray(trackListJson)) - { - string trackType = Json.ReadTag(json, "type"); - int id = int.Parse(Json.ReadTag(json, "id")); - if (trackType == "audio") - { - string lang = Json.ReadTag(json, "lang"); - _audioTrackIds.Add(new KeyValuePair<int, string>(id, lang)); - } - } - _mpvFree(lpBuffer); - } - return _audioTrackIds; - } - } - - public int AudioTrackNumber - { - get - { - var lpBuffer = IntPtr.Zero; - _mpvGetPropertyString(_mpvHandle, GetUtf8Bytes("aid"), MpvFormatString, ref lpBuffer); - var numberString = Marshal.PtrToStringAnsi(lpBuffer); - if (string.IsNullOrEmpty(numberString)) - { - return 0; - } - - var id = int.Parse(numberString); - var idx = _audioTrackIds.FindIndex(x => x.Key == id); - var number = AudioTracks.Count > 1 && idx != -1 ? idx : 0; - _mpvFree(lpBuffer); - return number; - } - set - { - string id = "1"; - if (AudioTracks.Count > 1 && value >= 0 && value < _audioTrackIds.Count) - { - id = _audioTrackIds[value].Key.ToString(); - } - DoMpvCommand("set", "aid", id); - } - } - - public string VersionNumber - { - get - { - if (_mpvHandle == IntPtr.Zero) - { - return string.Empty; - } - - var version = _mpvClientApiVersion(); - var high = version >> 16; - var low = version & 0xff; - return high + "." + low; - } - } - - public void LoadSubtitle(string fileName) - { - DoMpvCommand("sub-add", fileName, "select"); - } - - public void LoadSecondSubtitle(string fileName) - { - _secondSubtitleFileName = fileName; - DoMpvCommand("sub-add", fileName, "select"); - } - - public void RemoveSubtitle() - { - if (!string.IsNullOrEmpty(_secondSubtitleFileName)) - { - return; - } - - DoMpvCommand("sub-remove"); - } - - public void ReloadSubtitle() - { - DoMpvCommand("sub-reload"); - } - - public void HideCursor() - { - _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("cursor-autohide"), GetUtf8Bytes("always")); - } - - public void ShowCursor() - { - _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("cursor-autohide"), GetUtf8Bytes("no")); - } - - public static bool IsInstalled - { - get - { - try - { - if (Configuration.IsRunningOnLinux) - { - return LoadLib(); - } - - var dllFile = GetMpvPath("mpv-1.dll"); - return File.Exists(dllFile); - } - catch (Exception ex) - { - SeLogger.Error(ex, "LibMpvDynamic.IsInstalled failed"); - return false; - } - } - } - - public static string GetMpvPath(string fileName) - { - if (Configuration.IsRunningOnWindows) - { - var path = Path.Combine(Configuration.DataDirectory, fileName); - if (File.Exists(path)) - { - return path; - } - } - - return null; - } - - private static bool LoadLib() - { - if (_libMpvDll == IntPtr.Zero) - { - if (Configuration.IsRunningOnWindows) - { - _libMpvDll = NativeMethods.CrossLoadLibrary(GetMpvPath("mpv-1.dll")); - } - else - { - _libMpvDll = NativeMethods.CrossLoadLibrary("libmpv.so"); - if (_libMpvDll == IntPtr.Zero) - { - _libMpvDll = NativeMethods.CrossLoadLibrary("libmpv.so.1"); - } - - int i = 107; - while (_libMpvDll == IntPtr.Zero && i < 120) - { - _libMpvDll = NativeMethods.CrossLoadLibrary($"libmpv.so.1.{i}.0"); - i++; - } - } - } - - return _libMpvDll != IntPtr.Zero; - } - - public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) - { - _secondSubtitleFileName = null; - if (LoadLib()) - { - LoadLibMpvDynamic(); - if (!IsAllMethodsLoaded()) - { - throw new Exception("MPV - not all needed methods found in dll file"); - } - _mpvHandle = _mpvCreate.Invoke(); - - if (Configuration.Settings.General.MpvLogging) - { - var logFileName = Path.Combine(Configuration.DataDirectory, "mpv-log-" + Guid.NewGuid() + ".txt"); - _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("log-file"), GetUtf8Bytes(logFileName)); - } - } - else if (!Directory.Exists(videoFileName)) - { - return; - } - - OnVideoLoaded = onVideoLoaded; - OnVideoEnded = onVideoEnded; - - if (!string.IsNullOrEmpty(videoFileName)) - { - _mpvInitialize.Invoke(_mpvHandle); - SetVideoOwner(ownerControl); - - string videoOutput = string.Empty; - if (Configuration.IsRunningOnLinux) - { - videoOutput = Configuration.Settings.General.MpvVideoOutputLinux; - } - else if (!string.IsNullOrWhiteSpace(Configuration.Settings.General.MpvVideoOutputWindows)) - { - videoOutput = Configuration.Settings.General.MpvVideoOutputWindows; - } - - if (!string.IsNullOrEmpty(videoOutput)) - { - _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("vo"), GetUtf8Bytes(videoOutput)); - } - - _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("keep-open"), GetUtf8Bytes("always")); // don't auto close video - _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("no-sub"), GetUtf8Bytes("")); // don't load subtitles - if (videoFileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || - videoFileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) - { - _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("ytdl"), GetUtf8Bytes("yes")); - } - - if (!string.IsNullOrEmpty(Configuration.Settings.General.MpvExtraOption)) - { - var parts = Configuration.Settings.General.MpvExtraOption.Split('='); - if (parts.Length == 2) - { - _mpvSetOptionString(_mpvHandle, GetUtf8Bytes(parts[0]), GetUtf8Bytes(parts[1])); - } - else - { - _mpvSetOptionString(_mpvHandle, GetUtf8Bytes(Configuration.Settings.General.MpvExtraOption), GetUtf8Bytes("")); - } - } - - DoMpvCommand("loadfile", videoFileName); - - System.Threading.Thread.Sleep(100); - SetVideoOwner(ownerControl); - - _videoLoadedTimer = new Timer { Interval = 50 }; - _videoLoadedTimer.Tick += VideoLoadedTimer_Tick; - _videoLoadedTimer.Start(); - - SetVideoOwner(ownerControl); - } - } - - private void SetVideoOwner(Control ownerControl) - { - if (ownerControl != null) - { - int iterations = 25; - int returnCode = -1; - int mpvFormatInt64 = 4; - if (ownerControl.IsDisposed) - { - return; - } - var windowId = ownerControl.Handle.ToInt64(); - while (returnCode != 0 && iterations > 0) - { - Application.DoEvents(); - - lock (_lockObj) - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - returnCode = _mpvSetOption(_mpvHandle, GetUtf8Bytes("wid"), mpvFormatInt64, ref windowId); - if (returnCode != 0) - { - iterations--; - System.Threading.Thread.Sleep(100); - } - } - } - } - Pause(); - } - - private void VideoLoadedTimer_Tick(object sender, EventArgs e) - { - _videoLoadedTimer.Stop(); - const int mpvEventFileLoaded = 8; - int l = 0; - while (l < 10000) - { - Application.DoEvents(); - try - { - lock (_lockObj) - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - var eventIdHandle = _mpvWaitEvent(_mpvHandle, 0); - var eventId = Convert.ToInt64(Marshal.PtrToStructure(eventIdHandle, typeof(int))); - if (eventId == mpvEventFileLoaded) - { - break; - } - } - l++; - } - catch - { - return; - } - } - Application.DoEvents(); - OnVideoLoaded?.Invoke(this, null); - Application.DoEvents(); - Pause(); - } - - public override void DisposeVideoPlayer() - { - Dispose(); - } - - private readonly object _lockObj = new object(); - private void ReleaseUnmanagedResources() - { - try - { - lock (_lockObj) - { - if (_mpvHandle != IntPtr.Zero) - { - HardDispose(); - } - } - } - catch - { - // ignored - } - } - - ~LibMpvDynamic() - { - Dispose(false); - } - - public void Dispose() - { - Dispose(true); - } - - public void HardDispose() - { - DoMpvCommand("stop"); - System.Threading.Thread.Sleep(150); - Application.DoEvents(); - DoMpvCommand("quit"); - _mpvHandle = IntPtr.Zero; - System.Threading.Thread.Sleep(150); - Application.DoEvents(); - System.Threading.Thread.Sleep(50); - Application.DoEvents(); - } - - protected virtual void Dispose(bool disposing) - { - ReleaseUnmanagedResources(); - } - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Core.SubtitleFormats; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic.VideoPlayers +{ + public class LibMpvDynamic : VideoPlayer, IDisposable + { + + #region mpv dll methods - see https://github.com/mpv-player/mpv/blob/master/libmpv/client.h + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr MpvCreate(); + private MpvCreate _mpvCreate; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int MpvInitialize(IntPtr mpvHandle); + private MpvInitialize _mpvInitialize; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int MpvCommand(IntPtr mpvHandle, IntPtr utf8Strings); + private MpvCommand _mpvCommand; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr MpvWaitEvent(IntPtr mpvHandle, double wait); + private MpvWaitEvent _mpvWaitEvent; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int MpvSetOption(IntPtr mpvHandle, byte[] name, int format, ref long data); + private MpvSetOption _mpvSetOption; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int MpvSetOptionString(IntPtr mpvHandle, byte[] name, byte[] value); + private MpvSetOptionString _mpvSetOptionString; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int MpvGetPropertystring(IntPtr mpvHandle, byte[] name, int format, ref IntPtr data); + private MpvGetPropertystring _mpvGetPropertyString; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int MpvGetPropertyDouble(IntPtr mpvHandle, byte[] name, int format, ref double data); + private MpvGetPropertyDouble _mpvGetPropertyDouble; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int MpvSetProperty(IntPtr mpvHandle, byte[] name, int format, ref byte[] data); + private MpvSetProperty _mpvSetProperty; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void MpvFree(IntPtr data); + private MpvFree _mpvFree; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate ulong MpvClientApiVersion(); + private MpvClientApiVersion _mpvClientApiVersion; + + #endregion + + private static IntPtr _libMpvDll = IntPtr.Zero; + private IntPtr _mpvHandle; + private Timer _videoLoadedTimer; + private double? _pausePosition; // Hack to hold precise seeking when paused + private string _secondSubtitleFileName; + + public override event EventHandler OnVideoLoaded; + public override event EventHandler OnVideoEnded; + + private const int MpvFormatString = 1; + + private object GetDllType(Type type, string name) + { + var address = NativeMethods.CrossGetProcAddress(_libMpvDll, name); + return address != IntPtr.Zero ? Marshal.GetDelegateForFunctionPointer(address, type) : null; + } + + private void LoadLibMpvDynamic() + { + _mpvCreate = (MpvCreate)GetDllType(typeof(MpvCreate), "mpv_create"); + _mpvInitialize = (MpvInitialize)GetDllType(typeof(MpvInitialize), "mpv_initialize"); + _mpvWaitEvent = (MpvWaitEvent)GetDllType(typeof(MpvWaitEvent), "mpv_wait_event"); + _mpvCommand = (MpvCommand)GetDllType(typeof(MpvCommand), "mpv_command"); + _mpvSetOption = (MpvSetOption)GetDllType(typeof(MpvSetOption), "mpv_set_option"); + _mpvSetOptionString = (MpvSetOptionString)GetDllType(typeof(MpvSetOptionString), "mpv_set_option_string"); + _mpvGetPropertyString = (MpvGetPropertystring)GetDllType(typeof(MpvGetPropertystring), "mpv_get_property"); + _mpvGetPropertyDouble = (MpvGetPropertyDouble)GetDllType(typeof(MpvGetPropertyDouble), "mpv_get_property"); + _mpvSetProperty = (MpvSetProperty)GetDllType(typeof(MpvSetProperty), "mpv_set_property"); + _mpvFree = (MpvFree)GetDllType(typeof(MpvFree), "mpv_free"); + _mpvClientApiVersion = (MpvClientApiVersion)GetDllType(typeof(MpvClientApiVersion), "mpv_client_api_version"); + } + + private bool IsAllMethodsLoaded() + { + return _mpvCreate != null && + _mpvInitialize != null && + _mpvWaitEvent != null && + _mpvCommand != null && + _mpvSetOption != null && + _mpvSetOptionString != null && + _mpvGetPropertyString != null && + _mpvGetPropertyDouble != null && + _mpvSetProperty != null && + _mpvFree != null; + } + + private static byte[] GetUtf8Bytes(string s) + { + return Encoding.UTF8.GetBytes(s + "\0"); + } + + public static IntPtr AllocateUtf8IntPtrArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers) + { + int numberOfStrings = arr.Length + 1; // add extra element for extra null pointer last (sentinel) + byteArrayPointers = new IntPtr[numberOfStrings]; + IntPtr rootPointer = Marshal.AllocCoTaskMem(IntPtr.Size * numberOfStrings); + for (int index = 0; index < arr.Length; index++) + { + var bytes = GetUtf8Bytes(arr[index]); + IntPtr unmanagedPointer = Marshal.AllocHGlobal(bytes.Length); + Marshal.Copy(bytes, 0, unmanagedPointer, bytes.Length); + byteArrayPointers[index] = unmanagedPointer; + } + Marshal.Copy(byteArrayPointers, 0, rootPointer, numberOfStrings); + return rootPointer; + } + + private void DoMpvCommand(params string[] args) + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + var mainPtr = AllocateUtf8IntPtrArrayWithSentinel(args, out var byteArrayPointers); + _mpvCommand(_mpvHandle, mainPtr); + foreach (var ptr in byteArrayPointers) + { + Marshal.FreeHGlobal(ptr); + } + Marshal.FreeHGlobal(mainPtr); + } + + public override string PlayerName => "libmpv " + VersionNumber; + + private int _volume = 75; + public override int Volume + { + get => _volume; + set + { + var v = Configuration.Settings.General.AllowVolumeBoost ? (int)Math.Round(value * 1.5) : value; + DoMpvCommand("set", "volume", v.ToString(CultureInfo.InvariantCulture)); + _volume = value; + } + } + + public override double Duration + { + get + { + lock (_lockObj) + { + if (_mpvHandle == IntPtr.Zero) + { + return 0; + } + + int mpvFormatDouble = 5; + double d = 0; + _mpvGetPropertyDouble(_mpvHandle, GetUtf8Bytes("duration"), mpvFormatDouble, ref d); + return d; + } + } + } + + public override double CurrentPosition + { + get + { + lock (_lockObj) + { + if (_mpvHandle == IntPtr.Zero) + { + return 0; + } + + if (_pausePosition != null) + { + if (_pausePosition < 0) + { + return 0; + } + + return _pausePosition.Value; + } + + int mpvFormatDouble = 5; + double d = 0; + _mpvGetPropertyDouble(_mpvHandle, GetUtf8Bytes("time-pos"), mpvFormatDouble, ref d); + return d; + } + } + set + { + lock (_lockObj) + { + + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + if (IsPaused && value <= Duration) + { + _pausePosition = value; + } + + DoMpvCommand("seek", value.ToString(CultureInfo.InvariantCulture), "absolute"); + } + } + } + + private double _playRate = 1.0; + public override double PlayRate + { + get => _playRate; + set + { + DoMpvCommand("set", "speed", value.ToString(CultureInfo.InvariantCulture)); + _playRate = value; + } + } + + public void GetNextFrame() + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + DoMpvCommand("frame-step"); + _pausePosition = null; + } + + public void GetPreviousFrame() + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + DoMpvCommand("frame-back-step"); + _pausePosition = null; + } + + public override void Play() + { + lock (_lockObj) + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + _pausePosition = null; + + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + var bytes = GetUtf8Bytes("no"); + _mpvSetProperty(_mpvHandle, GetUtf8Bytes("pause"), MpvFormatString, ref bytes); + } + } + + public override void Pause() + { + lock (_lockObj) + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + var bytes = GetUtf8Bytes("yes"); + _mpvSetProperty(_mpvHandle, GetUtf8Bytes("pause"), MpvFormatString, ref bytes); + } + } + + public override void Stop() + { + lock (_lockObj) + { + + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + Pause(); + _pausePosition = null; + CurrentPosition = 0; + } + } + + public override bool IsPaused + { + get + { + if (_mpvHandle == IntPtr.Zero) + { + return true; + } + + var lpBuffer = IntPtr.Zero; + _mpvGetPropertyString(_mpvHandle, GetUtf8Bytes("pause"), MpvFormatString, ref lpBuffer); + var isPaused = Marshal.PtrToStringAnsi(lpBuffer) == "yes"; + _mpvFree(lpBuffer); + return isPaused; + } + } + + public override bool IsPlaying => !IsPaused; + + private List<KeyValuePair<int, string>> _audioTrackIds; + public List<KeyValuePair<int, string>> AudioTracks + { + get + { + if (_audioTrackIds == null) + { + _audioTrackIds = new List<KeyValuePair<int, string>>(); + var lpBuffer = IntPtr.Zero; + _mpvGetPropertyString(_mpvHandle, GetUtf8Bytes("track-list"), MpvFormatString, ref lpBuffer); + string trackListJson = Marshal.PtrToStringAnsi(lpBuffer); + foreach (var json in Json.ReadObjectArray(trackListJson)) + { + string trackType = Json.ReadTag(json, "type"); + int id = int.Parse(Json.ReadTag(json, "id")); + if (trackType == "audio") + { + string lang = Json.ReadTag(json, "lang"); + _audioTrackIds.Add(new KeyValuePair<int, string>(id, lang)); + } + } + _mpvFree(lpBuffer); + } + return _audioTrackIds; + } + } + + public int AudioTrackNumber + { + get + { + var lpBuffer = IntPtr.Zero; + _mpvGetPropertyString(_mpvHandle, GetUtf8Bytes("aid"), MpvFormatString, ref lpBuffer); + var numberString = Marshal.PtrToStringAnsi(lpBuffer); + if (string.IsNullOrEmpty(numberString)) + { + return 0; + } + + var id = int.Parse(numberString); + var idx = _audioTrackIds.FindIndex(x => x.Key == id); + var number = AudioTracks.Count > 1 && idx != -1 ? idx : 0; + _mpvFree(lpBuffer); + return number; + } + set + { + string id = "1"; + if (AudioTracks.Count > 1 && value >= 0 && value < _audioTrackIds.Count) + { + id = _audioTrackIds[value].Key.ToString(); + } + DoMpvCommand("set", "aid", id); + } + } + + public string VersionNumber + { + get + { + if (_mpvHandle == IntPtr.Zero) + { + return string.Empty; + } + + var version = _mpvClientApiVersion(); + var high = version >> 16; + var low = version & 0xff; + return high + "." + low; + } + } + + public void LoadSubtitle(string fileName) + { + DoMpvCommand("sub-add", fileName, "select"); + } + + public void LoadSecondSubtitle(string fileName) + { + _secondSubtitleFileName = fileName; + DoMpvCommand("sub-add", fileName, "select"); + } + + public void RemoveSubtitle() + { + if (!string.IsNullOrEmpty(_secondSubtitleFileName)) + { + return; + } + + DoMpvCommand("sub-remove"); + } + + public void ReloadSubtitle() + { + DoMpvCommand("sub-reload"); + } + + public void HideCursor() + { + _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("cursor-autohide"), GetUtf8Bytes("always")); + } + + public void ShowCursor() + { + _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("cursor-autohide"), GetUtf8Bytes("no")); + } + + public static bool IsInstalled + { + get + { + try + { + if (Configuration.IsRunningOnLinux) + { + return LoadLib(); + } + + var dllFile = GetMpvPath("mpv-1.dll"); + return File.Exists(dllFile); + } + catch (Exception ex) + { + SeLogger.Error(ex, "LibMpvDynamic.IsInstalled failed"); + return false; + } + } + } + + public static string GetMpvPath(string fileName) + { + if (Configuration.IsRunningOnWindows) + { + var path = Path.Combine(Configuration.DataDirectory, fileName); + if (File.Exists(path)) + { + return path; + } + } + + return null; + } + + private static bool LoadLib() + { + if (_libMpvDll == IntPtr.Zero) + { + if (Configuration.IsRunningOnWindows) + { + _libMpvDll = NativeMethods.CrossLoadLibrary(GetMpvPath("mpv-1.dll")); + } + else + { + _libMpvDll = NativeMethods.CrossLoadLibrary("libmpv.so"); + if (_libMpvDll == IntPtr.Zero) + { + _libMpvDll = NativeMethods.CrossLoadLibrary("libmpv.so.1"); + } + + int i = 107; + while (_libMpvDll == IntPtr.Zero && i < 120) + { + _libMpvDll = NativeMethods.CrossLoadLibrary($"libmpv.so.1.{i}.0"); + i++; + } + } + } + + return _libMpvDll != IntPtr.Zero; + } + + public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) + { + _secondSubtitleFileName = null; + if (LoadLib()) + { + LoadLibMpvDynamic(); + if (!IsAllMethodsLoaded()) + { + throw new Exception("MPV - not all needed methods found in dll file"); + } + _mpvHandle = _mpvCreate.Invoke(); + + if (Configuration.Settings.General.MpvLogging) + { + var logFileName = Path.Combine(Configuration.DataDirectory, "mpv-log-" + Guid.NewGuid() + ".txt"); + _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("log-file"), GetUtf8Bytes(logFileName)); + } + } + else if (!Directory.Exists(videoFileName)) + { + return; + } + + OnVideoLoaded = onVideoLoaded; + OnVideoEnded = onVideoEnded; + + if (!string.IsNullOrEmpty(videoFileName)) + { + _mpvInitialize.Invoke(_mpvHandle); + SetVideoOwner(ownerControl); + + string videoOutput = string.Empty; + if (Configuration.IsRunningOnLinux) + { + videoOutput = Configuration.Settings.General.MpvVideoOutputLinux; + } + else if (!string.IsNullOrWhiteSpace(Configuration.Settings.General.MpvVideoOutputWindows)) + { + videoOutput = Configuration.Settings.General.MpvVideoOutputWindows; + } + + if (!string.IsNullOrEmpty(videoOutput)) + { + _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("vo"), GetUtf8Bytes(videoOutput)); + } + + _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("keep-open"), GetUtf8Bytes("always")); // don't auto close video + _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("no-sub"), GetUtf8Bytes("")); // don't load subtitles + if (videoFileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || + videoFileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) + { + _mpvSetOptionString(_mpvHandle, GetUtf8Bytes("ytdl"), GetUtf8Bytes("yes")); + } + + if (!string.IsNullOrEmpty(Configuration.Settings.General.MpvExtraOption)) + { + var parts = Configuration.Settings.General.MpvExtraOption.Split('='); + if (parts.Length == 2) + { + _mpvSetOptionString(_mpvHandle, GetUtf8Bytes(parts[0]), GetUtf8Bytes(parts[1])); + } + else + { + _mpvSetOptionString(_mpvHandle, GetUtf8Bytes(Configuration.Settings.General.MpvExtraOption), GetUtf8Bytes("")); + } + } + + DoMpvCommand("loadfile", videoFileName); + + System.Threading.Thread.Sleep(100); + SetVideoOwner(ownerControl); + + _videoLoadedTimer = new Timer { Interval = 50 }; + _videoLoadedTimer.Tick += VideoLoadedTimer_Tick; + _videoLoadedTimer.Start(); + + SetVideoOwner(ownerControl); + } + } + + private void SetVideoOwner(Control ownerControl) + { + if (ownerControl != null) + { + int iterations = 25; + int returnCode = -1; + int mpvFormatInt64 = 4; + if (ownerControl.IsDisposed) + { + return; + } + var windowId = ownerControl.Handle.ToInt64(); + while (returnCode != 0 && iterations > 0) + { + Application.DoEvents(); + + lock (_lockObj) + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + returnCode = _mpvSetOption(_mpvHandle, GetUtf8Bytes("wid"), mpvFormatInt64, ref windowId); + if (returnCode != 0) + { + iterations--; + System.Threading.Thread.Sleep(100); + } + } + } + } + Pause(); + } + + private void VideoLoadedTimer_Tick(object sender, EventArgs e) + { + _videoLoadedTimer.Stop(); + const int mpvEventFileLoaded = 8; + int l = 0; + while (l < 10000) + { + Application.DoEvents(); + try + { + lock (_lockObj) + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + var eventIdHandle = _mpvWaitEvent(_mpvHandle, 0); + var eventId = Convert.ToInt64(Marshal.PtrToStructure(eventIdHandle, typeof(int))); + if (eventId == mpvEventFileLoaded) + { + break; + } + } + l++; + } + catch + { + return; + } + } + Application.DoEvents(); + OnVideoLoaded?.Invoke(this, null); + Application.DoEvents(); + Pause(); + } + + public override void DisposeVideoPlayer() + { + Dispose(); + } + + private readonly object _lockObj = new object(); + private void ReleaseUnmanagedResources() + { + try + { + lock (_lockObj) + { + if (_mpvHandle != IntPtr.Zero) + { + HardDispose(); + } + } + } + catch + { + // ignored + } + } + + ~LibMpvDynamic() + { + Dispose(false); + } + + public void Dispose() + { + Dispose(true); + } + + public void HardDispose() + { + DoMpvCommand("stop"); + System.Threading.Thread.Sleep(150); + Application.DoEvents(); + DoMpvCommand("quit"); + _mpvHandle = IntPtr.Zero; + System.Threading.Thread.Sleep(150); + Application.DoEvents(); + System.Threading.Thread.Sleep(50); + Application.DoEvents(); + } + + protected virtual void Dispose(bool disposing) + { + ReleaseUnmanagedResources(); + } + } +} diff --git a/src/Logic/VideoPlayers/LibMpvMono.cs b/src/ui/Logic/VideoPlayers/LibMpvMono.cs similarity index 96% rename from src/Logic/VideoPlayers/LibMpvMono.cs rename to src/ui/Logic/VideoPlayers/LibMpvMono.cs index 6939c9d97..935d15b66 100644 --- a/src/Logic/VideoPlayers/LibMpvMono.cs +++ b/src/ui/Logic/VideoPlayers/LibMpvMono.cs @@ -1,382 +1,382 @@ -using Nikse.SubtitleEdit.Core; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; -using Nikse.SubtitleEdit.Core.SubtitleFormats; - - -namespace Nikse.SubtitleEdit.Logic.VideoPlayers -{ - public class LibMpvMono : VideoPlayer, IDisposable - { - - private IntPtr _libMpvDll; - private IntPtr _mpvHandle; - private Timer _videoLoadedTimer; - // private Timer _videoEndedTimer; - - public override event EventHandler OnVideoLoaded; - public override event EventHandler OnVideoEnded; - - private const int MpvFormatString = 1; - - - private static byte[] GetUtf8Bytes(string s) - { - return Encoding.UTF8.GetBytes(s + "\0"); - } - - public static IntPtr AllocateUtf8IntPtrArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers) - { - int numberOfStrings = arr.Length + 1; // add extra element for extra null pointer last (sentinel) - byteArrayPointers = new IntPtr[numberOfStrings]; - IntPtr rootPointer = Marshal.AllocCoTaskMem(IntPtr.Size * numberOfStrings); - for (int index = 0; index < arr.Length; index++) - { - var bytes = GetUtf8Bytes(arr[index]); - IntPtr unmanagedPointer = Marshal.AllocHGlobal(bytes.Length); - Marshal.Copy(bytes, 0, unmanagedPointer, bytes.Length); - byteArrayPointers[index] = unmanagedPointer; - } - Marshal.Copy(byteArrayPointers, 0, rootPointer, numberOfStrings); - return rootPointer; - } - - private void DoMpvCommand(params string[] args) - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - var mainPtr = AllocateUtf8IntPtrArrayWithSentinel(args, out var byteArrayPointers); - NativeMethods.mpv_command(_mpvHandle, mainPtr); - foreach (var ptr in byteArrayPointers) - { - Marshal.FreeHGlobal(ptr); - } - Marshal.FreeHGlobal(mainPtr); - } - - public override string PlayerName => "MPV Player"; - - private int _volume = 75; - public override int Volume - { - get => _volume; - set - { - DoMpvCommand("set", "volume", value.ToString()); - _volume = value; - } - } - - public override double Duration - { - get - { - if (_mpvHandle == IntPtr.Zero) - { - return 0; - } - - int mpvFormatDouble = 5; - double d = 0; - NativeMethods.mpv_get_property(_mpvHandle, GetUtf8Bytes("duration"), mpvFormatDouble, ref d); - return d; - } - } - - public override double CurrentPosition - { - get - { - if (_mpvHandle == IntPtr.Zero) - { - return 0; - } - - int mpvFormatDouble = 5; - double d = 0; - NativeMethods.mpv_get_property(_mpvHandle, GetUtf8Bytes("time-pos"), mpvFormatDouble, ref d); - return d; - } - set - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - DoMpvCommand("seek", value.ToString(CultureInfo.InvariantCulture), "absolute"); - } - } - - private double _playRate = 2.0; - public override double PlayRate - { - get => _playRate; - set - { - DoMpvCommand("set", "speed", value.ToString(CultureInfo.InvariantCulture)); - _playRate = value; - } - } - - public void GetNextFrame() - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - DoMpvCommand("frame-step"); - } - - public void GetPreviousFrame() - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - DoMpvCommand("frame-back-step"); - } - - public override void Play() - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - var bytes = GetUtf8Bytes("no"); - NativeMethods.mpv_set_property(_mpvHandle, GetUtf8Bytes("pause"), MpvFormatString, ref bytes); - } - - public override void Pause() - { - if (_mpvHandle == IntPtr.Zero) - { - return; - } - - var bytes = GetUtf8Bytes("yes"); - NativeMethods.mpv_set_property(_mpvHandle, GetUtf8Bytes("pause"), MpvFormatString, ref bytes); - } - - public override void Stop() - { - Pause(); - CurrentPosition = 0; - } - - public override bool IsPaused - { - get - { - if (_mpvHandle == IntPtr.Zero) - { - return true; - } - - var lpBuffer = NativeMethods.mpv_get_property_string(_mpvHandle, GetUtf8Bytes("pause")); - string s = Marshal.PtrToStringAnsi(lpBuffer); - bool isPaused = s == "yes"; - NativeMethods.mpv_free(lpBuffer); - return isPaused; - } - } - - public override bool IsPlaying => !IsPaused; - - private List<KeyValuePair<int, string>> _audioTrackIds; - public List<KeyValuePair<int, string>> AudioTracks - { - get - { - if (_audioTrackIds == null) - { - _audioTrackIds = new List<KeyValuePair<int, string>>(); - var lpBuffer = NativeMethods.mpv_get_property_string(_mpvHandle, GetUtf8Bytes("track-list")); - string trackListJson = Marshal.PtrToStringAnsi(lpBuffer); - foreach (var json in Json.ReadObjectArray(trackListJson)) - { - string trackType = Json.ReadTag(json, "type"); - int id = int.Parse(Json.ReadTag(json, "id")); - if (trackType == "audio") - { - string lang = Json.ReadTag(json, "lang"); - _audioTrackIds.Add(new KeyValuePair<int, string>(id, lang)); - } - } - NativeMethods.mpv_free(lpBuffer); - } - return _audioTrackIds; - } - } - - public int AudioTrackNumber - { - get - { - var lpBuffer = NativeMethods.mpv_get_property_string(_mpvHandle, GetUtf8Bytes("aid")); - int id = int.Parse(Marshal.PtrToStringAnsi(lpBuffer)); - int idx = _audioTrackIds.FindIndex(x => x.Key == id); - int number = AudioTracks.Count > 1 && idx != -1 ? idx : 0; - NativeMethods.mpv_free(lpBuffer); - return number; - } - set - { - string id = "1"; - if (AudioTracks.Count > 1 && value >= 0 && value < _audioTrackIds.Count) - { - id = _audioTrackIds[value].Key.ToString(); - } - DoMpvCommand("set", "aid", id); - } - } - - public static bool IsInstalled => true; - - public static string GetMpvPath(string fileName) - { - var path = Path.Combine(Configuration.DataDirectory, fileName); - if (File.Exists(path)) - { - return path; - } - - return null; - } - - public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) - { - _mpvHandle = NativeMethods.mpv_create(); - OnVideoLoaded = onVideoLoaded; - OnVideoEnded = onVideoEnded; - - if (!string.IsNullOrEmpty(videoFileName)) - { - //Mono.Unix. - NativeMethods.mpv_initialize(_mpvHandle); - - string videoOutput = "gpu"; - if (!string.IsNullOrWhiteSpace(Configuration.Settings.General.MpvVideoOutputWindows)) - { - videoOutput = Configuration.Settings.General.MpvVideoOutputWindows; - } - - NativeMethods.mpv_set_option_string(_mpvHandle, GetUtf8Bytes("vo"), GetUtf8Bytes(videoOutput)); // "direct3d_shaders" is default, "direct3d" could be used for compabality with old systems - - NativeMethods.mpv_set_option_string(_mpvHandle, GetUtf8Bytes("keep-open"), GetUtf8Bytes("always")); // don't auto close video - NativeMethods.mpv_set_option_string(_mpvHandle, GetUtf8Bytes("no-sub"), GetUtf8Bytes("")); // don't load subtitles - if (ownerControl != null) - { - int mpvFormatInt64 = 4; - var windowId = ownerControl.Handle.ToInt64(); - NativeMethods.mpv_set_option(_mpvHandle, GetUtf8Bytes("wid"), mpvFormatInt64, ref windowId); - } - DoMpvCommand("loadfile", videoFileName); - - _videoLoadedTimer = new Timer { Interval = 50 }; - _videoLoadedTimer.Tick += VideoLoadedTimer_Tick; - _videoLoadedTimer.Start(); - } - } - - private void VideoLoadedTimer_Tick(object sender, EventArgs e) - { - _videoLoadedTimer.Stop(); - const int mpvEventFileLoaded = 8; - int l = 0; - while (l < 10000) - { - Application.DoEvents(); - try - { - if (_mpvHandle != IntPtr.Zero) - { - var eventIdHandle = NativeMethods.mpv_wait_event(_mpvHandle, 0); - var eventId = Convert.ToInt64(Marshal.PtrToStructure(eventIdHandle, typeof(int))); - if (eventId == mpvEventFileLoaded) - { - break; - } - } - l++; - } - catch - { - return; - } - } - Application.DoEvents(); - OnVideoLoaded?.Invoke(this, null); - - Application.DoEvents(); - Pause(); - } - - - public override void DisposeVideoPlayer() - { - Dispose(); - } - - private readonly object _lockObj = new object(); - - private void ReleaseUnmanagedResources() - { - try - { - lock (_lockObj) - { - if (_mpvHandle != IntPtr.Zero) - { - NativeMethods.mpv_terminate_destroy(_mpvHandle); - _mpvHandle = IntPtr.Zero; - } - - if (_libMpvDll != IntPtr.Zero) - { - NativeMethods.FreeLibrary(_libMpvDll); - _libMpvDll = IntPtr.Zero; - } - } - } - catch - { - // ignored - } - } - - ~LibMpvMono() - { - Dispose(false); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (_mpvHandle != IntPtr.Zero) - { - DoMpvCommand("quit"); - } - - ReleaseUnmanagedResources(); - } - - } -} +using Nikse.SubtitleEdit.Core; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Core.SubtitleFormats; + + +namespace Nikse.SubtitleEdit.Logic.VideoPlayers +{ + public class LibMpvMono : VideoPlayer, IDisposable + { + + private IntPtr _libMpvDll; + private IntPtr _mpvHandle; + private Timer _videoLoadedTimer; + // private Timer _videoEndedTimer; + + public override event EventHandler OnVideoLoaded; + public override event EventHandler OnVideoEnded; + + private const int MpvFormatString = 1; + + + private static byte[] GetUtf8Bytes(string s) + { + return Encoding.UTF8.GetBytes(s + "\0"); + } + + public static IntPtr AllocateUtf8IntPtrArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers) + { + int numberOfStrings = arr.Length + 1; // add extra element for extra null pointer last (sentinel) + byteArrayPointers = new IntPtr[numberOfStrings]; + IntPtr rootPointer = Marshal.AllocCoTaskMem(IntPtr.Size * numberOfStrings); + for (int index = 0; index < arr.Length; index++) + { + var bytes = GetUtf8Bytes(arr[index]); + IntPtr unmanagedPointer = Marshal.AllocHGlobal(bytes.Length); + Marshal.Copy(bytes, 0, unmanagedPointer, bytes.Length); + byteArrayPointers[index] = unmanagedPointer; + } + Marshal.Copy(byteArrayPointers, 0, rootPointer, numberOfStrings); + return rootPointer; + } + + private void DoMpvCommand(params string[] args) + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + var mainPtr = AllocateUtf8IntPtrArrayWithSentinel(args, out var byteArrayPointers); + NativeMethods.mpv_command(_mpvHandle, mainPtr); + foreach (var ptr in byteArrayPointers) + { + Marshal.FreeHGlobal(ptr); + } + Marshal.FreeHGlobal(mainPtr); + } + + public override string PlayerName => "MPV Player"; + + private int _volume = 75; + public override int Volume + { + get => _volume; + set + { + DoMpvCommand("set", "volume", value.ToString()); + _volume = value; + } + } + + public override double Duration + { + get + { + if (_mpvHandle == IntPtr.Zero) + { + return 0; + } + + int mpvFormatDouble = 5; + double d = 0; + NativeMethods.mpv_get_property(_mpvHandle, GetUtf8Bytes("duration"), mpvFormatDouble, ref d); + return d; + } + } + + public override double CurrentPosition + { + get + { + if (_mpvHandle == IntPtr.Zero) + { + return 0; + } + + int mpvFormatDouble = 5; + double d = 0; + NativeMethods.mpv_get_property(_mpvHandle, GetUtf8Bytes("time-pos"), mpvFormatDouble, ref d); + return d; + } + set + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + DoMpvCommand("seek", value.ToString(CultureInfo.InvariantCulture), "absolute"); + } + } + + private double _playRate = 2.0; + public override double PlayRate + { + get => _playRate; + set + { + DoMpvCommand("set", "speed", value.ToString(CultureInfo.InvariantCulture)); + _playRate = value; + } + } + + public void GetNextFrame() + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + DoMpvCommand("frame-step"); + } + + public void GetPreviousFrame() + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + DoMpvCommand("frame-back-step"); + } + + public override void Play() + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + var bytes = GetUtf8Bytes("no"); + NativeMethods.mpv_set_property(_mpvHandle, GetUtf8Bytes("pause"), MpvFormatString, ref bytes); + } + + public override void Pause() + { + if (_mpvHandle == IntPtr.Zero) + { + return; + } + + var bytes = GetUtf8Bytes("yes"); + NativeMethods.mpv_set_property(_mpvHandle, GetUtf8Bytes("pause"), MpvFormatString, ref bytes); + } + + public override void Stop() + { + Pause(); + CurrentPosition = 0; + } + + public override bool IsPaused + { + get + { + if (_mpvHandle == IntPtr.Zero) + { + return true; + } + + var lpBuffer = NativeMethods.mpv_get_property_string(_mpvHandle, GetUtf8Bytes("pause")); + string s = Marshal.PtrToStringAnsi(lpBuffer); + bool isPaused = s == "yes"; + NativeMethods.mpv_free(lpBuffer); + return isPaused; + } + } + + public override bool IsPlaying => !IsPaused; + + private List<KeyValuePair<int, string>> _audioTrackIds; + public List<KeyValuePair<int, string>> AudioTracks + { + get + { + if (_audioTrackIds == null) + { + _audioTrackIds = new List<KeyValuePair<int, string>>(); + var lpBuffer = NativeMethods.mpv_get_property_string(_mpvHandle, GetUtf8Bytes("track-list")); + string trackListJson = Marshal.PtrToStringAnsi(lpBuffer); + foreach (var json in Json.ReadObjectArray(trackListJson)) + { + string trackType = Json.ReadTag(json, "type"); + int id = int.Parse(Json.ReadTag(json, "id")); + if (trackType == "audio") + { + string lang = Json.ReadTag(json, "lang"); + _audioTrackIds.Add(new KeyValuePair<int, string>(id, lang)); + } + } + NativeMethods.mpv_free(lpBuffer); + } + return _audioTrackIds; + } + } + + public int AudioTrackNumber + { + get + { + var lpBuffer = NativeMethods.mpv_get_property_string(_mpvHandle, GetUtf8Bytes("aid")); + int id = int.Parse(Marshal.PtrToStringAnsi(lpBuffer)); + int idx = _audioTrackIds.FindIndex(x => x.Key == id); + int number = AudioTracks.Count > 1 && idx != -1 ? idx : 0; + NativeMethods.mpv_free(lpBuffer); + return number; + } + set + { + string id = "1"; + if (AudioTracks.Count > 1 && value >= 0 && value < _audioTrackIds.Count) + { + id = _audioTrackIds[value].Key.ToString(); + } + DoMpvCommand("set", "aid", id); + } + } + + public static bool IsInstalled => true; + + public static string GetMpvPath(string fileName) + { + var path = Path.Combine(Configuration.DataDirectory, fileName); + if (File.Exists(path)) + { + return path; + } + + return null; + } + + public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) + { + _mpvHandle = NativeMethods.mpv_create(); + OnVideoLoaded = onVideoLoaded; + OnVideoEnded = onVideoEnded; + + if (!string.IsNullOrEmpty(videoFileName)) + { + //Mono.Unix. + NativeMethods.mpv_initialize(_mpvHandle); + + string videoOutput = "gpu"; + if (!string.IsNullOrWhiteSpace(Configuration.Settings.General.MpvVideoOutputWindows)) + { + videoOutput = Configuration.Settings.General.MpvVideoOutputWindows; + } + + NativeMethods.mpv_set_option_string(_mpvHandle, GetUtf8Bytes("vo"), GetUtf8Bytes(videoOutput)); // "direct3d_shaders" is default, "direct3d" could be used for compabality with old systems + + NativeMethods.mpv_set_option_string(_mpvHandle, GetUtf8Bytes("keep-open"), GetUtf8Bytes("always")); // don't auto close video + NativeMethods.mpv_set_option_string(_mpvHandle, GetUtf8Bytes("no-sub"), GetUtf8Bytes("")); // don't load subtitles + if (ownerControl != null) + { + int mpvFormatInt64 = 4; + var windowId = ownerControl.Handle.ToInt64(); + NativeMethods.mpv_set_option(_mpvHandle, GetUtf8Bytes("wid"), mpvFormatInt64, ref windowId); + } + DoMpvCommand("loadfile", videoFileName); + + _videoLoadedTimer = new Timer { Interval = 50 }; + _videoLoadedTimer.Tick += VideoLoadedTimer_Tick; + _videoLoadedTimer.Start(); + } + } + + private void VideoLoadedTimer_Tick(object sender, EventArgs e) + { + _videoLoadedTimer.Stop(); + const int mpvEventFileLoaded = 8; + int l = 0; + while (l < 10000) + { + Application.DoEvents(); + try + { + if (_mpvHandle != IntPtr.Zero) + { + var eventIdHandle = NativeMethods.mpv_wait_event(_mpvHandle, 0); + var eventId = Convert.ToInt64(Marshal.PtrToStructure(eventIdHandle, typeof(int))); + if (eventId == mpvEventFileLoaded) + { + break; + } + } + l++; + } + catch + { + return; + } + } + Application.DoEvents(); + OnVideoLoaded?.Invoke(this, null); + + Application.DoEvents(); + Pause(); + } + + + public override void DisposeVideoPlayer() + { + Dispose(); + } + + private readonly object _lockObj = new object(); + + private void ReleaseUnmanagedResources() + { + try + { + lock (_lockObj) + { + if (_mpvHandle != IntPtr.Zero) + { + NativeMethods.mpv_terminate_destroy(_mpvHandle); + _mpvHandle = IntPtr.Zero; + } + + if (_libMpvDll != IntPtr.Zero) + { + NativeMethods.FreeLibrary(_libMpvDll); + _libMpvDll = IntPtr.Zero; + } + } + } + catch + { + // ignored + } + } + + ~LibMpvMono() + { + Dispose(false); + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (_mpvHandle != IntPtr.Zero) + { + DoMpvCommand("quit"); + } + + ReleaseUnmanagedResources(); + } + + } +} diff --git a/src/Logic/VideoPlayers/LibVlcDynamic.cs b/src/ui/Logic/VideoPlayers/LibVlcDynamic.cs similarity index 97% rename from src/Logic/VideoPlayers/LibVlcDynamic.cs rename to src/ui/Logic/VideoPlayers/LibVlcDynamic.cs index c54af9e1a..c944d0726 100644 --- a/src/Logic/VideoPlayers/LibVlcDynamic.cs +++ b/src/ui/Logic/VideoPlayers/LibVlcDynamic.cs @@ -1,1045 +1,1045 @@ -using Nikse.SubtitleEdit.Core; -using Nikse.SubtitleEdit.Forms; -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic.VideoPlayers -{ - public class LibVlcDynamic : VideoPlayer, IDisposable - { - private Timer _videoLoadedTimer; - private Timer _videoEndTimer; - private Timer _mouseTimer; - - private IntPtr _libVlcDll; - private IntPtr _libVlc; - private IntPtr _mediaPlayer; - private Control _ownerControl; - private Form _parentForm; - private double? _pausePosition; // Hack to hold precise seeking when paused - private int _volume = -1; - private static readonly object DisposeLock = new object(); - - // LibVLC Core - http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__core.html - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr libvlc_new(int argc, [MarshalAs(UnmanagedType.LPArray)] string[] argv); - private libvlc_new _libvlc_new; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr libvlc_get_version(); - private libvlc_get_version _libvlc_get_version; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void libvlc_release(IntPtr libVlc); - private libvlc_release _libvlc_release; - - // LibVLC Media - http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__media.html - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr libvlc_media_new_path(IntPtr instance, byte[] input); - private libvlc_media_new_path _libvlc_media_new_path; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void libvlc_media_release(IntPtr media); - private libvlc_media_release _libvlc_media_release; - - // LibVLC Video Controls - http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__video.html#g8f55326b8b51aecb59d8b8a446c3f118 - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void libvlc_video_get_size(IntPtr mediaPlayer, UInt32 number, out UInt32 x, out UInt32 y); - private libvlc_video_get_size _libvlc_video_get_size; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int libvlc_video_take_snapshot(IntPtr mediaPlayer, byte num, byte[] filePath, UInt32 width, UInt32 height); - private libvlc_video_take_snapshot _libvlc_video_take_snapshot; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void libvlc_video_set_callbacks(IntPtr playerInstance, LockCallbackDelegate @lock, UnlockCallbackDelegate unlock, DisplayCallbackDelegate display, IntPtr opaque); - private libvlc_video_set_callbacks _libvlc_video_set_callbacks; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int libvlc_video_set_format(IntPtr mediaPlayer, string chroma, UInt32 width, UInt32 height, UInt32 pitch); - private libvlc_video_set_format _libvlc_video_set_format; - - // LibVLC Audio Controls - http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__audio.html - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int libvlc_audio_get_volume(IntPtr mediaPlayer); - private libvlc_audio_get_volume _libvlc_audio_get_volume; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void libvlc_audio_set_volume(IntPtr mediaPlayer, int volume); - private libvlc_audio_set_volume _libvlc_audio_set_volume; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int libvlc_audio_get_track_count(IntPtr mediaPlayer); - private libvlc_audio_get_track_count _libvlc_audio_get_track_count; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr libvlc_audio_get_track_description(IntPtr mediaPlayer); - private libvlc_audio_get_track_description _libvlc_audio_get_track_description; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void libvlc_track_description_release(IntPtr mediaPlayer); - private libvlc_track_description_release _libvlc_track_description_release; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int libvlc_audio_get_track(IntPtr mediaPlayer); - private libvlc_audio_get_track _libvlc_audio_get_track; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int libvlc_audio_set_track(IntPtr mediaPlayer, int trackNumber); - private libvlc_audio_set_track _libvlc_audio_set_track; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate Int64 libvlc_audio_get_delay(IntPtr mediaPlayer); - private libvlc_audio_get_delay _libvlc_audio_get_delay; - - // LibVLC media player - http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__media__player.html - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr libvlc_media_player_new_from_media(IntPtr media); - private libvlc_media_player_new_from_media _libvlc_media_player_new_from_media; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void libvlc_media_player_play(IntPtr mediaPlayer); - private libvlc_media_player_play _libvlc_media_player_play; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void libvlc_media_player_stop(IntPtr mediaPlayer); - private libvlc_media_player_stop _libvlc_media_player_stop; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void libvlc_media_player_set_hwnd(IntPtr mediaPlayer, IntPtr windowsHandle); - private libvlc_media_player_set_hwnd _libvlc_media_player_set_hwnd; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void libvlc_media_player_set_xwindow(IntPtr mediaPlayer, IntPtr windowsHandle); - private libvlc_media_player_set_xwindow _libvlc_media_player_set_xwindow; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int libvlc_media_player_is_playing(IntPtr mediaPlayer); - private libvlc_media_player_is_playing _libvlc_media_player_is_playing; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int libvlc_media_player_set_pause(IntPtr mediaPlayer, int doPause); - private libvlc_media_player_set_pause _libvlc_media_player_set_pause; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate Int64 libvlc_media_player_get_time(IntPtr mediaPlayer); - private libvlc_media_player_get_time _libvlc_media_player_get_time; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void libvlc_media_player_set_time(IntPtr mediaPlayer, Int64 position); - private libvlc_media_player_set_time _libvlc_media_player_set_time; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate byte libvlc_media_player_get_state(IntPtr mediaPlayer); - private libvlc_media_player_get_state _libvlc_media_player_get_state; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate Int64 libvlc_media_player_get_length(IntPtr mediaPlayer); - private libvlc_media_player_get_length _libvlc_media_player_get_length; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void libvlc_media_player_release(IntPtr mediaPlayer); - private libvlc_media_player_release _libvlc_media_player_release; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate float libvlc_media_player_get_rate(IntPtr mediaPlayer); - private libvlc_media_player_get_rate _libvlc_media_player_get_rate; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int libvlc_media_player_set_rate(IntPtr mediaPlayer, float rate); - private libvlc_media_player_set_rate _libvlc_media_player_set_rate; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int libvlc_media_player_next_frame(IntPtr mediaPlayer); - private libvlc_media_player_next_frame _libvlc_media_player_next_frame; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int libvlc_media_player_add_slave(IntPtr media, int type, byte[] filePath, bool select); - private libvlc_media_player_add_slave _libvlc_media_player_add_slave; - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate int libvlc_video_set_spu(IntPtr mediaPlayer, int trackNumber); - private libvlc_video_set_spu _libvlc_video_set_spu; - - /// <summary> - /// Callback prototype to allocate and lock a picture buffer. Whenever a new video frame needs to be decoded, the lock callback is invoked. Depending on the video chroma, one or three pixel planes of adequate dimensions must be returned via the second parameter. Those planes must be aligned on 32-bytes boundaries. - /// </summary> - /// <param name="opaque">Private pointer as passed to SetCallbacks()</param> - /// <param name="planes">Planes start address of the pixel planes (LibVLC allocates the array of void pointers, this callback must initialize the array)</param> - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void LockCallbackDelegate(IntPtr opaque, ref IntPtr planes); - - /// <summary> - /// Callback prototype to unlock a picture buffer. When the video frame decoding is complete, the unlock callback is invoked. This callback might not be needed at all. It is only an indication that the application can now read the pixel values if it needs to. - /// </summary> - /// <param name="opaque">Private pointer as passed to SetCallbacks()</param> - /// <param name="picture">Private pointer returned from the LockCallback callback</param> - /// <param name="planes">Pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience)</param> - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void UnlockCallbackDelegate(IntPtr opaque, IntPtr picture, ref IntPtr planes); - - /// <summary> - /// Callback prototype to display a picture. When the video frame needs to be shown, as determined by the media playback clock, the display callback is invoked. - /// </summary> - /// <param name="opaque">Private pointer as passed to SetCallbacks()</param> - /// <param name="picture">Private pointer returned from the LockCallback callback</param> - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void DisplayCallbackDelegate(IntPtr opaque, IntPtr picture); - - private object GetDllType(Type type, string name) - { - var address = NativeMethods.CrossGetProcAddress(_libVlcDll, name); - if (address != IntPtr.Zero) - { - return Marshal.GetDelegateForFunctionPointer(address, type); - } - return null; - } - - private void LoadLibVlcDynamic() - { - _libvlc_new = (libvlc_new)GetDllType(typeof(libvlc_new), "libvlc_new"); - _libvlc_get_version = (libvlc_get_version)GetDllType(typeof(libvlc_get_version), "libvlc_get_version"); - _libvlc_release = (libvlc_release)GetDllType(typeof(libvlc_release), "libvlc_release"); - - _libvlc_media_new_path = (libvlc_media_new_path)GetDllType(typeof(libvlc_media_new_path), "libvlc_media_new_path"); - _libvlc_media_player_new_from_media = (libvlc_media_player_new_from_media)GetDllType(typeof(libvlc_media_player_new_from_media), "libvlc_media_player_new_from_media"); - _libvlc_media_release = (libvlc_media_release)GetDllType(typeof(libvlc_media_release), "libvlc_media_release"); - - _libvlc_video_get_size = (libvlc_video_get_size)GetDllType(typeof(libvlc_video_get_size), "libvlc_video_get_size"); - _libvlc_video_set_spu = (libvlc_video_set_spu)GetDllType(typeof(libvlc_video_set_spu), "libvlc_video_set_spu"); - _libvlc_video_set_callbacks = (libvlc_video_set_callbacks)GetDllType(typeof(libvlc_video_set_callbacks), "libvlc_video_set_callbacks"); - _libvlc_video_set_format = (libvlc_video_set_format)GetDllType(typeof(libvlc_video_set_format), "libvlc_video_set_format"); - _libvlc_video_take_snapshot = (libvlc_video_take_snapshot)GetDllType(typeof(libvlc_video_take_snapshot), "libvlc_video_take_snapshot"); - - _libvlc_audio_get_track_count = (libvlc_audio_get_track_count)GetDllType(typeof(libvlc_audio_get_track_count), "libvlc_audio_get_track_count"); - _libvlc_audio_get_track_description = (libvlc_audio_get_track_description)GetDllType(typeof(libvlc_audio_get_track_description), "libvlc_audio_get_track_description"); - _libvlc_audio_get_track = (libvlc_audio_get_track)GetDllType(typeof(libvlc_audio_get_track), "libvlc_audio_get_track"); - _libvlc_audio_set_track = (libvlc_audio_set_track)GetDllType(typeof(libvlc_audio_set_track), "libvlc_audio_set_track"); - _libvlc_audio_get_delay = (libvlc_audio_get_delay)GetDllType(typeof(libvlc_audio_get_delay), "libvlc_audio_get_delay"); - _libvlc_audio_get_volume = (libvlc_audio_get_volume)GetDllType(typeof(libvlc_audio_get_volume), "libvlc_audio_get_volume"); - _libvlc_audio_set_volume = (libvlc_audio_set_volume)GetDllType(typeof(libvlc_audio_set_volume), "libvlc_audio_set_volume"); - - _libvlc_track_description_release = (libvlc_track_description_release)GetDllType(typeof(libvlc_track_description_release), "libvlc_track_description_release"); - if (_libvlc_track_description_release == null) - { //TODO: libvlc 4 beta... check when final version is out - _libvlc_track_description_release = (libvlc_track_description_release)GetDllType(typeof(libvlc_track_description_release), "libvlc_track_description_list_release"); - } - - _libvlc_media_player_play = (libvlc_media_player_play)GetDllType(typeof(libvlc_media_player_play), "libvlc_media_player_play"); - _libvlc_media_player_set_hwnd = (libvlc_media_player_set_hwnd)GetDllType(typeof(libvlc_media_player_set_hwnd), "libvlc_media_player_set_hwnd"); - _libvlc_media_player_set_xwindow = (libvlc_media_player_set_xwindow)GetDllType(typeof(libvlc_media_player_set_xwindow), "libvlc_media_player_set_xwindow"); - _libvlc_media_player_is_playing = (libvlc_media_player_is_playing)GetDllType(typeof(libvlc_media_player_is_playing), "libvlc_media_player_is_playing"); - _libvlc_media_player_set_pause = (libvlc_media_player_set_pause)GetDllType(typeof(libvlc_media_player_set_pause), "libvlc_media_player_set_pause"); - _libvlc_media_player_get_time = (libvlc_media_player_get_time)GetDllType(typeof(libvlc_media_player_get_time), "libvlc_media_player_get_time"); - _libvlc_media_player_set_time = (libvlc_media_player_set_time)GetDllType(typeof(libvlc_media_player_set_time), "libvlc_media_player_set_time"); - _libvlc_media_player_get_state = (libvlc_media_player_get_state)GetDllType(typeof(libvlc_media_player_get_state), "libvlc_media_player_get_state"); - _libvlc_media_player_get_length = (libvlc_media_player_get_length)GetDllType(typeof(libvlc_media_player_get_length), "libvlc_media_player_get_length"); - _libvlc_media_player_release = (libvlc_media_player_release)GetDllType(typeof(libvlc_media_player_release), "libvlc_media_player_release"); - _libvlc_media_player_get_rate = (libvlc_media_player_get_rate)GetDllType(typeof(libvlc_media_player_get_rate), "libvlc_media_player_get_rate"); - _libvlc_media_player_set_rate = (libvlc_media_player_set_rate)GetDllType(typeof(libvlc_media_player_set_rate), "libvlc_media_player_set_rate"); - _libvlc_media_player_next_frame = (libvlc_media_player_next_frame)GetDllType(typeof(libvlc_media_player_next_frame), "libvlc_media_player_next_frame"); - _libvlc_media_player_add_slave = (libvlc_media_player_add_slave)GetDllType(typeof(libvlc_media_player_add_slave), "libvlc_media_player_add_slave"); - _libvlc_media_player_stop = (libvlc_media_player_stop)GetDllType(typeof(libvlc_media_player_stop), "libvlc_media_player_stop"); - if (_libvlc_media_player_stop == null) - { //TODO: libvlc 4 beta... check when final version is out - _libvlc_media_player_stop = (libvlc_media_player_stop)GetDllType(typeof(libvlc_media_player_stop), "libvlc_media_player_stop_async"); - } - } - - private bool IsAllMethodsLoaded() - { - return _libvlc_new != null && - _libvlc_release != null && - _libvlc_media_new_path != null && - _libvlc_media_player_new_from_media != null && - _libvlc_media_release != null && - _libvlc_video_get_size != null && - _libvlc_audio_get_volume != null && - _libvlc_audio_set_volume != null && - _libvlc_media_player_play != null && - _libvlc_media_player_stop != null && - _libvlc_media_player_is_playing != null && - _libvlc_media_player_get_time != null && - _libvlc_media_player_set_time != null && - _libvlc_media_player_get_state != null && - _libvlc_media_player_get_length != null && - _libvlc_media_player_release != null && - _libvlc_media_player_get_rate != null && - _libvlc_media_player_set_rate != null; - } - - public static bool IsInstalled - { - get - { - try - { - using (var vlc = new LibVlcDynamic()) - { - vlc.Initialize(null, null, null, null); - var allMethodsLoaded = vlc.IsAllMethodsLoaded(); - if (!allMethodsLoaded) - { - SeLogger.Error("Not all required methods was found in libvlc"); - } - return allMethodsLoaded; - } - } - catch (Exception ex) - { - SeLogger.Error(ex, "LibVlcDynamic.IsInstalled"); - return false; - } - } - } - - public override string PlayerName - { - get - { - if (_libVlcDll == IntPtr.Zero || _libvlc_get_version == null) - { - return "VLC"; - } - - var versionPointer = _libvlc_get_version(); - var libVlcVersionIncludingCodeName = Marshal.PtrToStringAnsi(versionPointer); - return $"VLC {libVlcVersionIncludingCodeName}"; - } - } - - public override int Volume - { - get - { - if (_volume != -1) - { - return _volume; - } - - if (Configuration.Settings.General.AllowVolumeBoost) - { - var result = (int)Math.Round(_libvlc_audio_get_volume(_mediaPlayer) / 5.0); - return result > 100 ? 100 : result; - } - var v = _libvlc_audio_get_volume(_mediaPlayer); - return v > 100 ? 100 : v; - } - set - { - _volume = value; - if (Configuration.Settings.General.AllowVolumeBoost) - { - _libvlc_audio_set_volume(_mediaPlayer, value * 5); - } - else - { - _libvlc_audio_set_volume(_mediaPlayer, value); - } - } - } - - public override double Duration => _libvlc_media_player_get_length(_mediaPlayer) / TimeCode.BaseUnit; - - public override double CurrentPosition - { - get - { - if (_pausePosition != null) - { - return _pausePosition < 0 ? 0 : _pausePosition.Value; - } - return _libvlc_media_player_get_time(_mediaPlayer) / TimeCode.BaseUnit; - } - set - { - if (IsPaused && value <= Duration) - { - _pausePosition = value; - } - - _libvlc_media_player_set_time(_mediaPlayer, (long)(value * TimeCode.BaseUnit + 0.5)); - } - } - - public override double PlayRate - { - get => _libvlc_media_player_get_rate(_mediaPlayer); - set - { - if (value >= 0 && value <= 2.0) - { - _libvlc_media_player_set_rate(_mediaPlayer, (float)value); - } - } - } - - public void GetNextFrame() - { - _libvlc_media_player_next_frame(_mediaPlayer); - } - - public int VlcState => _libvlc_media_player_get_state(_mediaPlayer); - - public override void Play() - { - _libvlc_media_player_play(_mediaPlayer); - _pausePosition = null; - } - - public override void Pause() - { - if (_mediaPlayer == IntPtr.Zero) - { - return; - } - - _libvlc_media_player_set_pause(_mediaPlayer, 1); - WaitUntilReady(); - _libvlc_media_player_set_pause(_mediaPlayer, 1); - } - - private void WaitUntilReady() - { - int state = VlcState; - int i = 0; - while (state != 4 && i < 50) - { - System.Threading.Thread.Sleep(10); - Application.DoEvents(); - state = VlcState; - i++; - } - } - - public override void Stop() - { - _libvlc_media_player_stop(_mediaPlayer); - _pausePosition = null; - } - - public override bool IsPaused - { - get - { - const int paused = 4; - int state = _libvlc_media_player_get_state(_mediaPlayer); - return state == paused; - } - } - - public override bool IsPlaying - { - get - { - const int playing = 3; - int state = _libvlc_media_player_get_state(_mediaPlayer); - return state == playing; - } - } - - private struct TrackDescription - { - public int Id { get; set; } - public IntPtr Name { get; set; } - public IntPtr PNext { get; set; } - } - - public List<KeyValuePair<int, string>> GetAudioTracks() - { - int count = _libvlc_audio_get_track_count(_mediaPlayer); - var trackDescriptionsPointer = _libvlc_audio_get_track_description(_mediaPlayer); - var trackDescriptionList = new List<KeyValuePair<int, string>>(); - IntPtr trackDescriptionPointer = trackDescriptionsPointer; - while (trackDescriptionPointer != IntPtr.Zero) - { - var trackDescription = (TrackDescription)Marshal.PtrToStructure(trackDescriptionPointer, typeof(TrackDescription)); - string s = Marshal.PtrToStringAnsi(trackDescription.Name); - if (trackDescription.Id != -1) // not disable - { - trackDescriptionList.Add(new KeyValuePair<int, string>(trackDescription.Id, s)); - } - trackDescriptionPointer = trackDescription.PNext; - } - if (trackDescriptionsPointer != IntPtr.Zero) - { - _libvlc_track_description_release(trackDescriptionsPointer); - } - return trackDescriptionList; - } - - public int AudioTrackCount - { - get - { - var x = _libvlc_audio_get_track_count(_mediaPlayer) - 1; - return x; - } - } - - public int AudioTrackNumber - { - get - { - var x = _libvlc_audio_get_track(_mediaPlayer); - return x; - } - set => _libvlc_audio_set_track(_mediaPlayer, value); - } - - /// <summary> - /// Audio delay in milliseconds - /// </summary> - public Int64 AudioDelay => _libvlc_audio_get_delay(_mediaPlayer) / 1000; - - public bool TakeSnapshot(string fileName, UInt32 width, UInt32 height) - { - return _libvlc_video_take_snapshot?.Invoke(_mediaPlayer, 0, Encoding.UTF8.GetBytes(fileName + "\0"), width, height) == 1; - } - - public bool LoadSecondSubtitle(string fileName) - { - if (_libvlc_media_player_add_slave == null) - { - return false; - } - - var uri = new Uri(fileName); - return 0 == _libvlc_media_player_add_slave(_mediaPlayer, 0, Encoding.UTF8.GetBytes(uri.AbsoluteUri + "\0"), true); - } - - public LibVlcDynamic MakeSecondMediaPlayer(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) - { - var newVlc = new LibVlcDynamic { _libVlc = _libVlc, _libVlcDll = _libVlcDll, _ownerControl = ownerControl }; - if (ownerControl != null) - { - newVlc._parentForm = ownerControl.FindForm(); - } - - newVlc.LoadLibVlcDynamic(); - - newVlc.OnVideoLoaded = onVideoLoaded; - newVlc.OnVideoEnded = onVideoEnded; - - if (!string.IsNullOrEmpty(videoFileName)) - { - var media = _libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0")); - newVlc._mediaPlayer = _libvlc_media_player_new_from_media(media); - _libvlc_media_release(media); - - if (ownerControl != null) - { - SetDrawableHandle(newVlc._mediaPlayer, ownerControl); - } - - if (onVideoEnded != null) - { - newVlc._videoEndTimer = new Timer { Interval = 500 }; - newVlc._videoEndTimer.Tick += VideoEndTimerTick; - newVlc._videoEndTimer.Start(); - } - - _libvlc_media_player_play(newVlc._mediaPlayer); - newVlc._videoLoadedTimer = new Timer { Interval = 100 }; - newVlc._videoLoadedTimer.Tick += newVlc.VideoLoadedTimer_Tick; - newVlc._videoLoadedTimer.Start(); - - newVlc._mouseTimer = new Timer { Interval = 25 }; - newVlc._mouseTimer.Tick += newVlc.MouseTimerTick; - newVlc._mouseTimer.Start(); - } - return newVlc; - } - - private void VideoLoadedTimer_Tick(object sender, EventArgs e) - { - _videoLoadedTimer.Stop(); - int i = 0; - while (!IsPlaying && i < 50) - { - System.Threading.Thread.Sleep(100); - i++; - } - Pause(); - _libvlc_video_set_spu?.Invoke(_mediaPlayer, -1); // turn of embedded subtitles - OnVideoLoaded?.Invoke(_mediaPlayer, new EventArgs()); - } - - public static string GetVlcPath(string fileName) - { - if (Configuration.IsRunningOnWindows) - { - var path = Path.Combine(Configuration.BaseDirectory, "VLC", fileName); - if (File.Exists(path)) - { - return path; - } - - if (!string.IsNullOrEmpty(Configuration.Settings.General.VlcLocation)) - { - try - { - if (Configuration.Settings.General.VlcLocation.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) - { - Configuration.Settings.General.VlcLocation = Path.GetDirectoryName(Configuration.Settings.General.VlcLocation); - } - - if (!string.IsNullOrEmpty(Configuration.Settings.General.VlcLocation)) - { - path = Path.Combine(Configuration.Settings.General.VlcLocation, fileName); - if (File.Exists(path)) - { - return path; - } - } - } - catch - { - // ignored - } - } - - if (!string.IsNullOrEmpty(Configuration.Settings.General.VlcLocationRelative)) - { - try - { - path = Configuration.Settings.General.VlcLocationRelative; - if (path.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) - { - path = Path.GetDirectoryName(path); - } - - if (path != null) - { - path = Path.Combine(path, fileName); - var fullPath = Path.GetFullPath(path); - if (File.Exists(fullPath)) - { - return fullPath; - } - - while (path.StartsWith("..", StringComparison.Ordinal)) - { - path = path.Remove(0, 3); - fullPath = Path.GetFullPath(path); - if (File.Exists(fullPath)) - { - return fullPath; - } - } - } - } - catch - { - // ignored - } - } - - // XP via registry path - path = RegistryUtil.GetValue(@"SOFTWARE\VideoLAN\VLC", "InstallDir"); - if (path != null && Directory.Exists(path)) - { - path = Path.Combine(path, fileName); - } - - if (File.Exists(path)) - { - return path; - } - - // Windows 7 via registry path - path = RegistryUtil.GetValue(@"SOFTWARE\Wow6432Node\VideoLAN\VLC", "InstallDir"); - if (path != null && Directory.Exists(path)) - { - path = Path.Combine(path, fileName); - } - - if (File.Exists(path)) - { - return path; - } - - path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86); - if (!string.IsNullOrEmpty(path)) - { - var p = Path.Combine(path, "VideoLAN", "VLC", fileName); - if (File.Exists(p)) - { - return p; - } - - p = Path.Combine(path, "VLC", fileName); - if (File.Exists(p)) - { - return p; - } - } - - path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); - if (!string.IsNullOrEmpty(path)) - { - var p = Path.Combine(path, "VideoLAN", "VLC", fileName); - if (File.Exists(p)) - { - return p; - } - - p = Path.Combine(path, "VLC", fileName); - if (File.Exists(p)) - { - return p; - } - } - - path = Path.Combine(@"C:\Program Files (x86)\VideoLAN\VLC", fileName); - if (File.Exists(path)) - { - return path; - } - - path = Path.Combine(@"C:\Program Files\VideoLAN\VLC", fileName); - if (File.Exists(path)) - { - return path; - } - - path = Path.Combine(@"C:\Program Files (x86)\VLC", fileName); - if (File.Exists(path)) - { - return path; - } - - path = Path.Combine(@"C:\Program Files\VLC", fileName); - if (File.Exists(path)) - { - return path; - } - } - - return null; - } - - public bool InitializeAndStartFrameGrabbing(string videoFileName, - UInt32 width, UInt32 height, - LockCallbackDelegate @lock, - UnlockCallbackDelegate unlock, - DisplayCallbackDelegate display, - IntPtr opaque) - { - string dllFile = GetVlcPath("libvlc.dll"); - if (!File.Exists(dllFile) || string.IsNullOrEmpty(videoFileName)) - { - return false; - } - - var dir = Path.GetDirectoryName(dllFile); - if (dir != null) - { - Directory.SetCurrentDirectory(dir); - } - - _libVlcDll = NativeMethods.CrossLoadLibrary(dllFile); - LoadLibVlcDynamic(); - string[] initParameters = { "--no-skip-frames" }; - _libVlc = _libvlc_new(initParameters.Length, initParameters); - IntPtr media = _libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0")); - _mediaPlayer = _libvlc_media_player_new_from_media(media); - _libvlc_media_release(media); - _libvlc_video_set_format(_mediaPlayer, "RV24", width, height, 3 * width); - _libvlc_video_set_callbacks(_mediaPlayer, @lock, unlock, display, opaque); - _libvlc_audio_set_volume(_mediaPlayer, 0); - _libvlc_media_player_set_rate(_mediaPlayer, 9f); - return true; - } - - public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) - { - _ownerControl = ownerControl; - if (ownerControl != null) - { - _parentForm = ownerControl.FindForm(); - } - - var dllFile = "libvlc.so"; - if (Configuration.IsRunningOnWindows) - { - dllFile = GetVlcPath("libvlc.dll"); - if (File.Exists(dllFile)) - { - var dir = Path.GetDirectoryName(dllFile); - if (dir != null) - { - Directory.SetCurrentDirectory(dir); - } - } - } - - try - { - _libVlcDll = NativeMethods.CrossLoadLibrary(dllFile); - } - catch (Exception exception) - { - SeLogger.Error(exception, $"Unable to load '{dllFile}' (also check libc.so.6 + libdl.so.2)"); - } - - try - { - if (_libVlcDll == IntPtr.Zero && Configuration.IsRunningOnLinux) - { - for (int i = 4; i < 20; i++) - { - if (_libVlcDll == IntPtr.Zero) - { - dllFile = $"libvlc.so.{i}"; - _libVlcDll = NativeMethods.CrossLoadLibrary(dllFile); - } - } - - if (_libVlcDll == IntPtr.Zero) - { - foreach (var fileName in Directory.GetFiles("/usr/lib/x86_64-linux-gnu", "libvlc.so.?")) - { - if (_libVlcDll == IntPtr.Zero) - { - dllFile = fileName; - _libVlcDll = NativeMethods.CrossLoadLibrary(dllFile); - } - } - } - } - } - catch - { - // ignore - } - - if (_libVlcDll == IntPtr.Zero) - { - SeLogger.Error($"Unable to load '{dllFile}' (also check libc.so.6 + libdl.so.2)"); - return; - } - LoadLibVlcDynamic(); - - OnVideoLoaded = onVideoLoaded; - OnVideoEnded = onVideoEnded; - - if (!string.IsNullOrEmpty(videoFileName)) - { - string[] initParameters = { "--no-sub-autodetect-file" }; // , "--ffmpeg-hw" }; //, "--no-video-title-show" }; // TODO: Put in options/config file - _libVlc = _libvlc_new(initParameters.Length, initParameters); - var media = _libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0")); - _mediaPlayer = _libvlc_media_player_new_from_media(media); - _libvlc_media_release(media); - - // Linux: libvlc_media_player_set_xdrawable (_mediaPlayer, xdrawable); - // Mac: libvlc_media_player_set_nsobject (_mediaPlayer, view); - - if (ownerControl != null) - { - SetDrawableHandle(_mediaPlayer, ownerControl); - } - - if (onVideoEnded != null) - { - _videoEndTimer = new Timer { Interval = 500 }; - _videoEndTimer.Tick += VideoEndTimerTick; - _videoEndTimer.Start(); - } - - _libvlc_media_player_play(_mediaPlayer); - _videoLoadedTimer = new Timer { Interval = 100 }; - _videoLoadedTimer.Tick += VideoLoadedTimer_Tick; - _videoLoadedTimer.Start(); - - _mouseTimer = new Timer { Interval = 25 }; - _mouseTimer.Tick += MouseTimerTick; - _mouseTimer.Start(); - } - } - - private void SetDrawableHandle(IntPtr mediaPlayer, Control ownerControl) - { - if (Configuration.IsRunningOnWindows) - { - _libvlc_media_player_set_hwnd(mediaPlayer, ownerControl.Handle); // windows - - //hack: sometimes vlc opens in it's own windows - this code seems to prevent this - for (int j = 0; j < 50; j++) - { - System.Threading.Thread.Sleep(10); - Application.DoEvents(); - } - - _libvlc_media_player_set_hwnd(mediaPlayer, ownerControl.Handle); // windows - } - else - { - _libvlc_media_player_set_xwindow(mediaPlayer, ownerControl.Handle); // linux - } - } - - public static bool IsLeftMouseButtonDown() - { - if (Configuration.IsRunningOnWindows) - { - const int KEY_PRESSED = 0x8000; - const int VK_LBUTTON = 0x1; - return Convert.ToBoolean(NativeMethods.GetKeyState(VK_LBUTTON) & KEY_PRESSED); - } - return false; - } - - private void MouseTimerTick(object sender, EventArgs e) - { - if (_mouseTimer == null) - { - return; - } - - _mouseTimer.Stop(); - - if (!(_parentForm is Main mainForm) || !mainForm.IsMenuOpen) - { - if (_parentForm != null && _ownerControl != null && _ownerControl.Visible && _parentForm.ContainsFocus && IsLeftMouseButtonDown()) - { - var p = _ownerControl.PointToClient(Control.MousePosition); - if (p.X > 0 && p.X < _ownerControl.Width && p.Y > 0 && p.Y < _ownerControl.Height) - { - if (IsPlaying) - { - Pause(); - } - else - { - Play(); - } - - int i = 0; - while (IsLeftMouseButtonDown() && i < 200) - { - System.Threading.Thread.Sleep(2); - Application.DoEvents(); - i++; - } - } - } - } - - _mouseTimer?.Start(); - } - - private void VideoEndTimerTick(object sender, EventArgs e) - { - lock (DisposeLock) - { - if (_mediaPlayer == IntPtr.Zero) - { - return; - } - - const int ended = 6; - int state = _libvlc_media_player_get_state(_mediaPlayer); - if (state != ended) - { - return; - } - - // hack to make sure VLC is in ready state - Stop(); - Play(); - Pause(); - OnVideoEnded?.Invoke(_mediaPlayer, new EventArgs()); - } - } - - public override void DisposeVideoPlayer() - { - Dispose(); - } - - public override event EventHandler OnVideoLoaded; - - public override event EventHandler OnVideoEnded; - - private void ReleaseUnmanagedResources() - { - try - { - lock (DisposeLock) - { - if (_mediaPlayer != IntPtr.Zero) - { - _libvlc_media_player_stop(_mediaPlayer); - WaitUntilReady(); - _libvlc_media_player_release(_mediaPlayer); // CRASHES in visual sync / point sync? - _mediaPlayer = IntPtr.Zero; - } - - if (_parentForm is Main) - { - if (_libvlc_release != null && _libVlc != IntPtr.Zero) - { - _libvlc_release(_libVlc); // CRASHES in visual sync / point sync? - _libVlc = IntPtr.Zero; - } - - if (_libVlcDll != IntPtr.Zero) - { - NativeMethods.CrossFreeLibrary(_libVlcDll); // CRASHES in visual sync / point sync? - _libVlcDll = IntPtr.Zero; - } - } - } - } - catch - { - // ignored - } - } - - ~LibVlcDynamic() - { - Dispose(false); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - if (_videoLoadedTimer != null) - { - _videoLoadedTimer.Stop(); - _videoLoadedTimer.Dispose(); - _videoLoadedTimer = null; - } - if (_videoEndTimer != null) - { - _videoEndTimer.Stop(); - _videoEndTimer.Dispose(); - _videoEndTimer = null; - } - if (_mouseTimer != null) - { - _mouseTimer.Dispose(); - _mouseTimer = null; - } - Application.DoEvents(); - } - ReleaseUnmanagedResources(); - } - - } -} +using Nikse.SubtitleEdit.Core; +using Nikse.SubtitleEdit.Forms; +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic.VideoPlayers +{ + public class LibVlcDynamic : VideoPlayer, IDisposable + { + private Timer _videoLoadedTimer; + private Timer _videoEndTimer; + private Timer _mouseTimer; + + private IntPtr _libVlcDll; + private IntPtr _libVlc; + private IntPtr _mediaPlayer; + private Control _ownerControl; + private Form _parentForm; + private double? _pausePosition; // Hack to hold precise seeking when paused + private int _volume = -1; + private static readonly object DisposeLock = new object(); + + // LibVLC Core - http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__core.html + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr libvlc_new(int argc, [MarshalAs(UnmanagedType.LPArray)] string[] argv); + private libvlc_new _libvlc_new; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr libvlc_get_version(); + private libvlc_get_version _libvlc_get_version; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void libvlc_release(IntPtr libVlc); + private libvlc_release _libvlc_release; + + // LibVLC Media - http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__media.html + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr libvlc_media_new_path(IntPtr instance, byte[] input); + private libvlc_media_new_path _libvlc_media_new_path; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void libvlc_media_release(IntPtr media); + private libvlc_media_release _libvlc_media_release; + + // LibVLC Video Controls - http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__video.html#g8f55326b8b51aecb59d8b8a446c3f118 + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void libvlc_video_get_size(IntPtr mediaPlayer, UInt32 number, out UInt32 x, out UInt32 y); + private libvlc_video_get_size _libvlc_video_get_size; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int libvlc_video_take_snapshot(IntPtr mediaPlayer, byte num, byte[] filePath, UInt32 width, UInt32 height); + private libvlc_video_take_snapshot _libvlc_video_take_snapshot; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void libvlc_video_set_callbacks(IntPtr playerInstance, LockCallbackDelegate @lock, UnlockCallbackDelegate unlock, DisplayCallbackDelegate display, IntPtr opaque); + private libvlc_video_set_callbacks _libvlc_video_set_callbacks; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int libvlc_video_set_format(IntPtr mediaPlayer, string chroma, UInt32 width, UInt32 height, UInt32 pitch); + private libvlc_video_set_format _libvlc_video_set_format; + + // LibVLC Audio Controls - http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__audio.html + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int libvlc_audio_get_volume(IntPtr mediaPlayer); + private libvlc_audio_get_volume _libvlc_audio_get_volume; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void libvlc_audio_set_volume(IntPtr mediaPlayer, int volume); + private libvlc_audio_set_volume _libvlc_audio_set_volume; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int libvlc_audio_get_track_count(IntPtr mediaPlayer); + private libvlc_audio_get_track_count _libvlc_audio_get_track_count; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr libvlc_audio_get_track_description(IntPtr mediaPlayer); + private libvlc_audio_get_track_description _libvlc_audio_get_track_description; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void libvlc_track_description_release(IntPtr mediaPlayer); + private libvlc_track_description_release _libvlc_track_description_release; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int libvlc_audio_get_track(IntPtr mediaPlayer); + private libvlc_audio_get_track _libvlc_audio_get_track; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int libvlc_audio_set_track(IntPtr mediaPlayer, int trackNumber); + private libvlc_audio_set_track _libvlc_audio_set_track; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate Int64 libvlc_audio_get_delay(IntPtr mediaPlayer); + private libvlc_audio_get_delay _libvlc_audio_get_delay; + + // LibVLC media player - http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__media__player.html + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr libvlc_media_player_new_from_media(IntPtr media); + private libvlc_media_player_new_from_media _libvlc_media_player_new_from_media; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void libvlc_media_player_play(IntPtr mediaPlayer); + private libvlc_media_player_play _libvlc_media_player_play; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void libvlc_media_player_stop(IntPtr mediaPlayer); + private libvlc_media_player_stop _libvlc_media_player_stop; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void libvlc_media_player_set_hwnd(IntPtr mediaPlayer, IntPtr windowsHandle); + private libvlc_media_player_set_hwnd _libvlc_media_player_set_hwnd; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void libvlc_media_player_set_xwindow(IntPtr mediaPlayer, IntPtr windowsHandle); + private libvlc_media_player_set_xwindow _libvlc_media_player_set_xwindow; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int libvlc_media_player_is_playing(IntPtr mediaPlayer); + private libvlc_media_player_is_playing _libvlc_media_player_is_playing; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int libvlc_media_player_set_pause(IntPtr mediaPlayer, int doPause); + private libvlc_media_player_set_pause _libvlc_media_player_set_pause; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate Int64 libvlc_media_player_get_time(IntPtr mediaPlayer); + private libvlc_media_player_get_time _libvlc_media_player_get_time; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void libvlc_media_player_set_time(IntPtr mediaPlayer, Int64 position); + private libvlc_media_player_set_time _libvlc_media_player_set_time; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate byte libvlc_media_player_get_state(IntPtr mediaPlayer); + private libvlc_media_player_get_state _libvlc_media_player_get_state; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate Int64 libvlc_media_player_get_length(IntPtr mediaPlayer); + private libvlc_media_player_get_length _libvlc_media_player_get_length; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void libvlc_media_player_release(IntPtr mediaPlayer); + private libvlc_media_player_release _libvlc_media_player_release; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate float libvlc_media_player_get_rate(IntPtr mediaPlayer); + private libvlc_media_player_get_rate _libvlc_media_player_get_rate; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int libvlc_media_player_set_rate(IntPtr mediaPlayer, float rate); + private libvlc_media_player_set_rate _libvlc_media_player_set_rate; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int libvlc_media_player_next_frame(IntPtr mediaPlayer); + private libvlc_media_player_next_frame _libvlc_media_player_next_frame; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int libvlc_media_player_add_slave(IntPtr media, int type, byte[] filePath, bool select); + private libvlc_media_player_add_slave _libvlc_media_player_add_slave; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int libvlc_video_set_spu(IntPtr mediaPlayer, int trackNumber); + private libvlc_video_set_spu _libvlc_video_set_spu; + + /// <summary> + /// Callback prototype to allocate and lock a picture buffer. Whenever a new video frame needs to be decoded, the lock callback is invoked. Depending on the video chroma, one or three pixel planes of adequate dimensions must be returned via the second parameter. Those planes must be aligned on 32-bytes boundaries. + /// </summary> + /// <param name="opaque">Private pointer as passed to SetCallbacks()</param> + /// <param name="planes">Planes start address of the pixel planes (LibVLC allocates the array of void pointers, this callback must initialize the array)</param> + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void LockCallbackDelegate(IntPtr opaque, ref IntPtr planes); + + /// <summary> + /// Callback prototype to unlock a picture buffer. When the video frame decoding is complete, the unlock callback is invoked. This callback might not be needed at all. It is only an indication that the application can now read the pixel values if it needs to. + /// </summary> + /// <param name="opaque">Private pointer as passed to SetCallbacks()</param> + /// <param name="picture">Private pointer returned from the LockCallback callback</param> + /// <param name="planes">Pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience)</param> + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void UnlockCallbackDelegate(IntPtr opaque, IntPtr picture, ref IntPtr planes); + + /// <summary> + /// Callback prototype to display a picture. When the video frame needs to be shown, as determined by the media playback clock, the display callback is invoked. + /// </summary> + /// <param name="opaque">Private pointer as passed to SetCallbacks()</param> + /// <param name="picture">Private pointer returned from the LockCallback callback</param> + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void DisplayCallbackDelegate(IntPtr opaque, IntPtr picture); + + private object GetDllType(Type type, string name) + { + var address = NativeMethods.CrossGetProcAddress(_libVlcDll, name); + if (address != IntPtr.Zero) + { + return Marshal.GetDelegateForFunctionPointer(address, type); + } + return null; + } + + private void LoadLibVlcDynamic() + { + _libvlc_new = (libvlc_new)GetDllType(typeof(libvlc_new), "libvlc_new"); + _libvlc_get_version = (libvlc_get_version)GetDllType(typeof(libvlc_get_version), "libvlc_get_version"); + _libvlc_release = (libvlc_release)GetDllType(typeof(libvlc_release), "libvlc_release"); + + _libvlc_media_new_path = (libvlc_media_new_path)GetDllType(typeof(libvlc_media_new_path), "libvlc_media_new_path"); + _libvlc_media_player_new_from_media = (libvlc_media_player_new_from_media)GetDllType(typeof(libvlc_media_player_new_from_media), "libvlc_media_player_new_from_media"); + _libvlc_media_release = (libvlc_media_release)GetDllType(typeof(libvlc_media_release), "libvlc_media_release"); + + _libvlc_video_get_size = (libvlc_video_get_size)GetDllType(typeof(libvlc_video_get_size), "libvlc_video_get_size"); + _libvlc_video_set_spu = (libvlc_video_set_spu)GetDllType(typeof(libvlc_video_set_spu), "libvlc_video_set_spu"); + _libvlc_video_set_callbacks = (libvlc_video_set_callbacks)GetDllType(typeof(libvlc_video_set_callbacks), "libvlc_video_set_callbacks"); + _libvlc_video_set_format = (libvlc_video_set_format)GetDllType(typeof(libvlc_video_set_format), "libvlc_video_set_format"); + _libvlc_video_take_snapshot = (libvlc_video_take_snapshot)GetDllType(typeof(libvlc_video_take_snapshot), "libvlc_video_take_snapshot"); + + _libvlc_audio_get_track_count = (libvlc_audio_get_track_count)GetDllType(typeof(libvlc_audio_get_track_count), "libvlc_audio_get_track_count"); + _libvlc_audio_get_track_description = (libvlc_audio_get_track_description)GetDllType(typeof(libvlc_audio_get_track_description), "libvlc_audio_get_track_description"); + _libvlc_audio_get_track = (libvlc_audio_get_track)GetDllType(typeof(libvlc_audio_get_track), "libvlc_audio_get_track"); + _libvlc_audio_set_track = (libvlc_audio_set_track)GetDllType(typeof(libvlc_audio_set_track), "libvlc_audio_set_track"); + _libvlc_audio_get_delay = (libvlc_audio_get_delay)GetDllType(typeof(libvlc_audio_get_delay), "libvlc_audio_get_delay"); + _libvlc_audio_get_volume = (libvlc_audio_get_volume)GetDllType(typeof(libvlc_audio_get_volume), "libvlc_audio_get_volume"); + _libvlc_audio_set_volume = (libvlc_audio_set_volume)GetDllType(typeof(libvlc_audio_set_volume), "libvlc_audio_set_volume"); + + _libvlc_track_description_release = (libvlc_track_description_release)GetDllType(typeof(libvlc_track_description_release), "libvlc_track_description_release"); + if (_libvlc_track_description_release == null) + { //TODO: libvlc 4 beta... check when final version is out + _libvlc_track_description_release = (libvlc_track_description_release)GetDllType(typeof(libvlc_track_description_release), "libvlc_track_description_list_release"); + } + + _libvlc_media_player_play = (libvlc_media_player_play)GetDllType(typeof(libvlc_media_player_play), "libvlc_media_player_play"); + _libvlc_media_player_set_hwnd = (libvlc_media_player_set_hwnd)GetDllType(typeof(libvlc_media_player_set_hwnd), "libvlc_media_player_set_hwnd"); + _libvlc_media_player_set_xwindow = (libvlc_media_player_set_xwindow)GetDllType(typeof(libvlc_media_player_set_xwindow), "libvlc_media_player_set_xwindow"); + _libvlc_media_player_is_playing = (libvlc_media_player_is_playing)GetDllType(typeof(libvlc_media_player_is_playing), "libvlc_media_player_is_playing"); + _libvlc_media_player_set_pause = (libvlc_media_player_set_pause)GetDllType(typeof(libvlc_media_player_set_pause), "libvlc_media_player_set_pause"); + _libvlc_media_player_get_time = (libvlc_media_player_get_time)GetDllType(typeof(libvlc_media_player_get_time), "libvlc_media_player_get_time"); + _libvlc_media_player_set_time = (libvlc_media_player_set_time)GetDllType(typeof(libvlc_media_player_set_time), "libvlc_media_player_set_time"); + _libvlc_media_player_get_state = (libvlc_media_player_get_state)GetDllType(typeof(libvlc_media_player_get_state), "libvlc_media_player_get_state"); + _libvlc_media_player_get_length = (libvlc_media_player_get_length)GetDllType(typeof(libvlc_media_player_get_length), "libvlc_media_player_get_length"); + _libvlc_media_player_release = (libvlc_media_player_release)GetDllType(typeof(libvlc_media_player_release), "libvlc_media_player_release"); + _libvlc_media_player_get_rate = (libvlc_media_player_get_rate)GetDllType(typeof(libvlc_media_player_get_rate), "libvlc_media_player_get_rate"); + _libvlc_media_player_set_rate = (libvlc_media_player_set_rate)GetDllType(typeof(libvlc_media_player_set_rate), "libvlc_media_player_set_rate"); + _libvlc_media_player_next_frame = (libvlc_media_player_next_frame)GetDllType(typeof(libvlc_media_player_next_frame), "libvlc_media_player_next_frame"); + _libvlc_media_player_add_slave = (libvlc_media_player_add_slave)GetDllType(typeof(libvlc_media_player_add_slave), "libvlc_media_player_add_slave"); + _libvlc_media_player_stop = (libvlc_media_player_stop)GetDllType(typeof(libvlc_media_player_stop), "libvlc_media_player_stop"); + if (_libvlc_media_player_stop == null) + { //TODO: libvlc 4 beta... check when final version is out + _libvlc_media_player_stop = (libvlc_media_player_stop)GetDllType(typeof(libvlc_media_player_stop), "libvlc_media_player_stop_async"); + } + } + + private bool IsAllMethodsLoaded() + { + return _libvlc_new != null && + _libvlc_release != null && + _libvlc_media_new_path != null && + _libvlc_media_player_new_from_media != null && + _libvlc_media_release != null && + _libvlc_video_get_size != null && + _libvlc_audio_get_volume != null && + _libvlc_audio_set_volume != null && + _libvlc_media_player_play != null && + _libvlc_media_player_stop != null && + _libvlc_media_player_is_playing != null && + _libvlc_media_player_get_time != null && + _libvlc_media_player_set_time != null && + _libvlc_media_player_get_state != null && + _libvlc_media_player_get_length != null && + _libvlc_media_player_release != null && + _libvlc_media_player_get_rate != null && + _libvlc_media_player_set_rate != null; + } + + public static bool IsInstalled + { + get + { + try + { + using (var vlc = new LibVlcDynamic()) + { + vlc.Initialize(null, null, null, null); + var allMethodsLoaded = vlc.IsAllMethodsLoaded(); + if (!allMethodsLoaded) + { + SeLogger.Error("Not all required methods was found in libvlc"); + } + return allMethodsLoaded; + } + } + catch (Exception ex) + { + SeLogger.Error(ex, "LibVlcDynamic.IsInstalled"); + return false; + } + } + } + + public override string PlayerName + { + get + { + if (_libVlcDll == IntPtr.Zero || _libvlc_get_version == null) + { + return "VLC"; + } + + var versionPointer = _libvlc_get_version(); + var libVlcVersionIncludingCodeName = Marshal.PtrToStringAnsi(versionPointer); + return $"VLC {libVlcVersionIncludingCodeName}"; + } + } + + public override int Volume + { + get + { + if (_volume != -1) + { + return _volume; + } + + if (Configuration.Settings.General.AllowVolumeBoost) + { + var result = (int)Math.Round(_libvlc_audio_get_volume(_mediaPlayer) / 5.0); + return result > 100 ? 100 : result; + } + var v = _libvlc_audio_get_volume(_mediaPlayer); + return v > 100 ? 100 : v; + } + set + { + _volume = value; + if (Configuration.Settings.General.AllowVolumeBoost) + { + _libvlc_audio_set_volume(_mediaPlayer, value * 5); + } + else + { + _libvlc_audio_set_volume(_mediaPlayer, value); + } + } + } + + public override double Duration => _libvlc_media_player_get_length(_mediaPlayer) / TimeCode.BaseUnit; + + public override double CurrentPosition + { + get + { + if (_pausePosition != null) + { + return _pausePosition < 0 ? 0 : _pausePosition.Value; + } + return _libvlc_media_player_get_time(_mediaPlayer) / TimeCode.BaseUnit; + } + set + { + if (IsPaused && value <= Duration) + { + _pausePosition = value; + } + + _libvlc_media_player_set_time(_mediaPlayer, (long)(value * TimeCode.BaseUnit + 0.5)); + } + } + + public override double PlayRate + { + get => _libvlc_media_player_get_rate(_mediaPlayer); + set + { + if (value >= 0 && value <= 2.0) + { + _libvlc_media_player_set_rate(_mediaPlayer, (float)value); + } + } + } + + public void GetNextFrame() + { + _libvlc_media_player_next_frame(_mediaPlayer); + } + + public int VlcState => _libvlc_media_player_get_state(_mediaPlayer); + + public override void Play() + { + _libvlc_media_player_play(_mediaPlayer); + _pausePosition = null; + } + + public override void Pause() + { + if (_mediaPlayer == IntPtr.Zero) + { + return; + } + + _libvlc_media_player_set_pause(_mediaPlayer, 1); + WaitUntilReady(); + _libvlc_media_player_set_pause(_mediaPlayer, 1); + } + + private void WaitUntilReady() + { + int state = VlcState; + int i = 0; + while (state != 4 && i < 50) + { + System.Threading.Thread.Sleep(10); + Application.DoEvents(); + state = VlcState; + i++; + } + } + + public override void Stop() + { + _libvlc_media_player_stop(_mediaPlayer); + _pausePosition = null; + } + + public override bool IsPaused + { + get + { + const int paused = 4; + int state = _libvlc_media_player_get_state(_mediaPlayer); + return state == paused; + } + } + + public override bool IsPlaying + { + get + { + const int playing = 3; + int state = _libvlc_media_player_get_state(_mediaPlayer); + return state == playing; + } + } + + private struct TrackDescription + { + public int Id { get; set; } + public IntPtr Name { get; set; } + public IntPtr PNext { get; set; } + } + + public List<KeyValuePair<int, string>> GetAudioTracks() + { + int count = _libvlc_audio_get_track_count(_mediaPlayer); + var trackDescriptionsPointer = _libvlc_audio_get_track_description(_mediaPlayer); + var trackDescriptionList = new List<KeyValuePair<int, string>>(); + IntPtr trackDescriptionPointer = trackDescriptionsPointer; + while (trackDescriptionPointer != IntPtr.Zero) + { + var trackDescription = (TrackDescription)Marshal.PtrToStructure(trackDescriptionPointer, typeof(TrackDescription)); + string s = Marshal.PtrToStringAnsi(trackDescription.Name); + if (trackDescription.Id != -1) // not disable + { + trackDescriptionList.Add(new KeyValuePair<int, string>(trackDescription.Id, s)); + } + trackDescriptionPointer = trackDescription.PNext; + } + if (trackDescriptionsPointer != IntPtr.Zero) + { + _libvlc_track_description_release(trackDescriptionsPointer); + } + return trackDescriptionList; + } + + public int AudioTrackCount + { + get + { + var x = _libvlc_audio_get_track_count(_mediaPlayer) - 1; + return x; + } + } + + public int AudioTrackNumber + { + get + { + var x = _libvlc_audio_get_track(_mediaPlayer); + return x; + } + set => _libvlc_audio_set_track(_mediaPlayer, value); + } + + /// <summary> + /// Audio delay in milliseconds + /// </summary> + public Int64 AudioDelay => _libvlc_audio_get_delay(_mediaPlayer) / 1000; + + public bool TakeSnapshot(string fileName, UInt32 width, UInt32 height) + { + return _libvlc_video_take_snapshot?.Invoke(_mediaPlayer, 0, Encoding.UTF8.GetBytes(fileName + "\0"), width, height) == 1; + } + + public bool LoadSecondSubtitle(string fileName) + { + if (_libvlc_media_player_add_slave == null) + { + return false; + } + + var uri = new Uri(fileName); + return 0 == _libvlc_media_player_add_slave(_mediaPlayer, 0, Encoding.UTF8.GetBytes(uri.AbsoluteUri + "\0"), true); + } + + public LibVlcDynamic MakeSecondMediaPlayer(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) + { + var newVlc = new LibVlcDynamic { _libVlc = _libVlc, _libVlcDll = _libVlcDll, _ownerControl = ownerControl }; + if (ownerControl != null) + { + newVlc._parentForm = ownerControl.FindForm(); + } + + newVlc.LoadLibVlcDynamic(); + + newVlc.OnVideoLoaded = onVideoLoaded; + newVlc.OnVideoEnded = onVideoEnded; + + if (!string.IsNullOrEmpty(videoFileName)) + { + var media = _libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0")); + newVlc._mediaPlayer = _libvlc_media_player_new_from_media(media); + _libvlc_media_release(media); + + if (ownerControl != null) + { + SetDrawableHandle(newVlc._mediaPlayer, ownerControl); + } + + if (onVideoEnded != null) + { + newVlc._videoEndTimer = new Timer { Interval = 500 }; + newVlc._videoEndTimer.Tick += VideoEndTimerTick; + newVlc._videoEndTimer.Start(); + } + + _libvlc_media_player_play(newVlc._mediaPlayer); + newVlc._videoLoadedTimer = new Timer { Interval = 100 }; + newVlc._videoLoadedTimer.Tick += newVlc.VideoLoadedTimer_Tick; + newVlc._videoLoadedTimer.Start(); + + newVlc._mouseTimer = new Timer { Interval = 25 }; + newVlc._mouseTimer.Tick += newVlc.MouseTimerTick; + newVlc._mouseTimer.Start(); + } + return newVlc; + } + + private void VideoLoadedTimer_Tick(object sender, EventArgs e) + { + _videoLoadedTimer.Stop(); + int i = 0; + while (!IsPlaying && i < 50) + { + System.Threading.Thread.Sleep(100); + i++; + } + Pause(); + _libvlc_video_set_spu?.Invoke(_mediaPlayer, -1); // turn of embedded subtitles + OnVideoLoaded?.Invoke(_mediaPlayer, new EventArgs()); + } + + public static string GetVlcPath(string fileName) + { + if (Configuration.IsRunningOnWindows) + { + var path = Path.Combine(Configuration.BaseDirectory, "VLC", fileName); + if (File.Exists(path)) + { + return path; + } + + if (!string.IsNullOrEmpty(Configuration.Settings.General.VlcLocation)) + { + try + { + if (Configuration.Settings.General.VlcLocation.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) + { + Configuration.Settings.General.VlcLocation = Path.GetDirectoryName(Configuration.Settings.General.VlcLocation); + } + + if (!string.IsNullOrEmpty(Configuration.Settings.General.VlcLocation)) + { + path = Path.Combine(Configuration.Settings.General.VlcLocation, fileName); + if (File.Exists(path)) + { + return path; + } + } + } + catch + { + // ignored + } + } + + if (!string.IsNullOrEmpty(Configuration.Settings.General.VlcLocationRelative)) + { + try + { + path = Configuration.Settings.General.VlcLocationRelative; + if (path.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) + { + path = Path.GetDirectoryName(path); + } + + if (path != null) + { + path = Path.Combine(path, fileName); + var fullPath = Path.GetFullPath(path); + if (File.Exists(fullPath)) + { + return fullPath; + } + + while (path.StartsWith("..", StringComparison.Ordinal)) + { + path = path.Remove(0, 3); + fullPath = Path.GetFullPath(path); + if (File.Exists(fullPath)) + { + return fullPath; + } + } + } + } + catch + { + // ignored + } + } + + // XP via registry path + path = RegistryUtil.GetValue(@"SOFTWARE\VideoLAN\VLC", "InstallDir"); + if (path != null && Directory.Exists(path)) + { + path = Path.Combine(path, fileName); + } + + if (File.Exists(path)) + { + return path; + } + + // Windows 7 via registry path + path = RegistryUtil.GetValue(@"SOFTWARE\Wow6432Node\VideoLAN\VLC", "InstallDir"); + if (path != null && Directory.Exists(path)) + { + path = Path.Combine(path, fileName); + } + + if (File.Exists(path)) + { + return path; + } + + path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86); + if (!string.IsNullOrEmpty(path)) + { + var p = Path.Combine(path, "VideoLAN", "VLC", fileName); + if (File.Exists(p)) + { + return p; + } + + p = Path.Combine(path, "VLC", fileName); + if (File.Exists(p)) + { + return p; + } + } + + path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); + if (!string.IsNullOrEmpty(path)) + { + var p = Path.Combine(path, "VideoLAN", "VLC", fileName); + if (File.Exists(p)) + { + return p; + } + + p = Path.Combine(path, "VLC", fileName); + if (File.Exists(p)) + { + return p; + } + } + + path = Path.Combine(@"C:\Program Files (x86)\VideoLAN\VLC", fileName); + if (File.Exists(path)) + { + return path; + } + + path = Path.Combine(@"C:\Program Files\VideoLAN\VLC", fileName); + if (File.Exists(path)) + { + return path; + } + + path = Path.Combine(@"C:\Program Files (x86)\VLC", fileName); + if (File.Exists(path)) + { + return path; + } + + path = Path.Combine(@"C:\Program Files\VLC", fileName); + if (File.Exists(path)) + { + return path; + } + } + + return null; + } + + public bool InitializeAndStartFrameGrabbing(string videoFileName, + UInt32 width, UInt32 height, + LockCallbackDelegate @lock, + UnlockCallbackDelegate unlock, + DisplayCallbackDelegate display, + IntPtr opaque) + { + string dllFile = GetVlcPath("libvlc.dll"); + if (!File.Exists(dllFile) || string.IsNullOrEmpty(videoFileName)) + { + return false; + } + + var dir = Path.GetDirectoryName(dllFile); + if (dir != null) + { + Directory.SetCurrentDirectory(dir); + } + + _libVlcDll = NativeMethods.CrossLoadLibrary(dllFile); + LoadLibVlcDynamic(); + string[] initParameters = { "--no-skip-frames" }; + _libVlc = _libvlc_new(initParameters.Length, initParameters); + IntPtr media = _libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0")); + _mediaPlayer = _libvlc_media_player_new_from_media(media); + _libvlc_media_release(media); + _libvlc_video_set_format(_mediaPlayer, "RV24", width, height, 3 * width); + _libvlc_video_set_callbacks(_mediaPlayer, @lock, unlock, display, opaque); + _libvlc_audio_set_volume(_mediaPlayer, 0); + _libvlc_media_player_set_rate(_mediaPlayer, 9f); + return true; + } + + public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) + { + _ownerControl = ownerControl; + if (ownerControl != null) + { + _parentForm = ownerControl.FindForm(); + } + + var dllFile = "libvlc.so"; + if (Configuration.IsRunningOnWindows) + { + dllFile = GetVlcPath("libvlc.dll"); + if (File.Exists(dllFile)) + { + var dir = Path.GetDirectoryName(dllFile); + if (dir != null) + { + Directory.SetCurrentDirectory(dir); + } + } + } + + try + { + _libVlcDll = NativeMethods.CrossLoadLibrary(dllFile); + } + catch (Exception exception) + { + SeLogger.Error(exception, $"Unable to load '{dllFile}' (also check libc.so.6 + libdl.so.2)"); + } + + try + { + if (_libVlcDll == IntPtr.Zero && Configuration.IsRunningOnLinux) + { + for (int i = 4; i < 20; i++) + { + if (_libVlcDll == IntPtr.Zero) + { + dllFile = $"libvlc.so.{i}"; + _libVlcDll = NativeMethods.CrossLoadLibrary(dllFile); + } + } + + if (_libVlcDll == IntPtr.Zero) + { + foreach (var fileName in Directory.GetFiles("/usr/lib/x86_64-linux-gnu", "libvlc.so.?")) + { + if (_libVlcDll == IntPtr.Zero) + { + dllFile = fileName; + _libVlcDll = NativeMethods.CrossLoadLibrary(dllFile); + } + } + } + } + } + catch + { + // ignore + } + + if (_libVlcDll == IntPtr.Zero) + { + SeLogger.Error($"Unable to load '{dllFile}' (also check libc.so.6 + libdl.so.2)"); + return; + } + LoadLibVlcDynamic(); + + OnVideoLoaded = onVideoLoaded; + OnVideoEnded = onVideoEnded; + + if (!string.IsNullOrEmpty(videoFileName)) + { + string[] initParameters = { "--no-sub-autodetect-file" }; // , "--ffmpeg-hw" }; //, "--no-video-title-show" }; // TODO: Put in options/config file + _libVlc = _libvlc_new(initParameters.Length, initParameters); + var media = _libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0")); + _mediaPlayer = _libvlc_media_player_new_from_media(media); + _libvlc_media_release(media); + + // Linux: libvlc_media_player_set_xdrawable (_mediaPlayer, xdrawable); + // Mac: libvlc_media_player_set_nsobject (_mediaPlayer, view); + + if (ownerControl != null) + { + SetDrawableHandle(_mediaPlayer, ownerControl); + } + + if (onVideoEnded != null) + { + _videoEndTimer = new Timer { Interval = 500 }; + _videoEndTimer.Tick += VideoEndTimerTick; + _videoEndTimer.Start(); + } + + _libvlc_media_player_play(_mediaPlayer); + _videoLoadedTimer = new Timer { Interval = 100 }; + _videoLoadedTimer.Tick += VideoLoadedTimer_Tick; + _videoLoadedTimer.Start(); + + _mouseTimer = new Timer { Interval = 25 }; + _mouseTimer.Tick += MouseTimerTick; + _mouseTimer.Start(); + } + } + + private void SetDrawableHandle(IntPtr mediaPlayer, Control ownerControl) + { + if (Configuration.IsRunningOnWindows) + { + _libvlc_media_player_set_hwnd(mediaPlayer, ownerControl.Handle); // windows + + //hack: sometimes vlc opens in it's own windows - this code seems to prevent this + for (int j = 0; j < 50; j++) + { + System.Threading.Thread.Sleep(10); + Application.DoEvents(); + } + + _libvlc_media_player_set_hwnd(mediaPlayer, ownerControl.Handle); // windows + } + else + { + _libvlc_media_player_set_xwindow(mediaPlayer, ownerControl.Handle); // linux + } + } + + public static bool IsLeftMouseButtonDown() + { + if (Configuration.IsRunningOnWindows) + { + const int KEY_PRESSED = 0x8000; + const int VK_LBUTTON = 0x1; + return Convert.ToBoolean(NativeMethods.GetKeyState(VK_LBUTTON) & KEY_PRESSED); + } + return false; + } + + private void MouseTimerTick(object sender, EventArgs e) + { + if (_mouseTimer == null) + { + return; + } + + _mouseTimer.Stop(); + + if (!(_parentForm is Main mainForm) || !mainForm.IsMenuOpen) + { + if (_parentForm != null && _ownerControl != null && _ownerControl.Visible && _parentForm.ContainsFocus && IsLeftMouseButtonDown()) + { + var p = _ownerControl.PointToClient(Control.MousePosition); + if (p.X > 0 && p.X < _ownerControl.Width && p.Y > 0 && p.Y < _ownerControl.Height) + { + if (IsPlaying) + { + Pause(); + } + else + { + Play(); + } + + int i = 0; + while (IsLeftMouseButtonDown() && i < 200) + { + System.Threading.Thread.Sleep(2); + Application.DoEvents(); + i++; + } + } + } + } + + _mouseTimer?.Start(); + } + + private void VideoEndTimerTick(object sender, EventArgs e) + { + lock (DisposeLock) + { + if (_mediaPlayer == IntPtr.Zero) + { + return; + } + + const int ended = 6; + int state = _libvlc_media_player_get_state(_mediaPlayer); + if (state != ended) + { + return; + } + + // hack to make sure VLC is in ready state + Stop(); + Play(); + Pause(); + OnVideoEnded?.Invoke(_mediaPlayer, new EventArgs()); + } + } + + public override void DisposeVideoPlayer() + { + Dispose(); + } + + public override event EventHandler OnVideoLoaded; + + public override event EventHandler OnVideoEnded; + + private void ReleaseUnmanagedResources() + { + try + { + lock (DisposeLock) + { + if (_mediaPlayer != IntPtr.Zero) + { + _libvlc_media_player_stop(_mediaPlayer); + WaitUntilReady(); + _libvlc_media_player_release(_mediaPlayer); // CRASHES in visual sync / point sync? + _mediaPlayer = IntPtr.Zero; + } + + if (_parentForm is Main) + { + if (_libvlc_release != null && _libVlc != IntPtr.Zero) + { + _libvlc_release(_libVlc); // CRASHES in visual sync / point sync? + _libVlc = IntPtr.Zero; + } + + if (_libVlcDll != IntPtr.Zero) + { + NativeMethods.CrossFreeLibrary(_libVlcDll); // CRASHES in visual sync / point sync? + _libVlcDll = IntPtr.Zero; + } + } + } + } + catch + { + // ignored + } + } + + ~LibVlcDynamic() + { + Dispose(false); + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + if (_videoLoadedTimer != null) + { + _videoLoadedTimer.Stop(); + _videoLoadedTimer.Dispose(); + _videoLoadedTimer = null; + } + if (_videoEndTimer != null) + { + _videoEndTimer.Stop(); + _videoEndTimer.Dispose(); + _videoEndTimer = null; + } + if (_mouseTimer != null) + { + _mouseTimer.Dispose(); + _mouseTimer = null; + } + Application.DoEvents(); + } + ReleaseUnmanagedResources(); + } + + } +} diff --git a/src/Logic/VideoPlayers/LibVlcMono.cs b/src/ui/Logic/VideoPlayers/LibVlcMono.cs similarity index 97% rename from src/Logic/VideoPlayers/LibVlcMono.cs rename to src/ui/Logic/VideoPlayers/LibVlcMono.cs index 843e32b03..0374c8166 100644 --- a/src/Logic/VideoPlayers/LibVlcMono.cs +++ b/src/ui/Logic/VideoPlayers/LibVlcMono.cs @@ -1,270 +1,270 @@ -using Nikse.SubtitleEdit.Core; -using System; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic.VideoPlayers -{ - internal class LibVlcMono : VideoPlayer, IDisposable - { - private Timer _videoLoadedTimer; - private Timer _videoEndTimer; - private IntPtr _libVlcDLL; - private IntPtr _libVlc; - private IntPtr _mediaPlayer; - private Control _ownerControl; - private Form _parentForm; - - public override string PlayerName => "VLC Lib Mono"; - - public override int Volume - { - get => NativeMethods.libvlc_audio_get_volume(_mediaPlayer); - set => NativeMethods.libvlc_audio_set_volume(_mediaPlayer, value); - } - - public override double Duration => NativeMethods.libvlc_media_player_get_length(_mediaPlayer) / TimeCode.BaseUnit; - - public override double CurrentPosition - { - get => NativeMethods.libvlc_media_player_get_time(_mediaPlayer) / TimeCode.BaseUnit; - set => NativeMethods.libvlc_media_player_set_time(_mediaPlayer, (long)(value * TimeCode.BaseUnit)); - } - - public override double PlayRate - { - get => NativeMethods.libvlc_media_player_get_rate(_mediaPlayer); - set - { - if (value >= 0 && value <= 2.0) - { - NativeMethods.libvlc_media_player_set_rate(_mediaPlayer, (float)value); - } - } - } - - public override void Play() - { - NativeMethods.libvlc_media_player_play(_mediaPlayer); - } - - public override void Pause() - { - if (!IsPaused) - { - NativeMethods.libvlc_media_player_pause(_mediaPlayer); - } - } - - public override void Stop() - { - NativeMethods.libvlc_media_player_stop(_mediaPlayer); - } - - public override bool IsPaused - { - get - { - const int paused = 4; - int state = NativeMethods.libvlc_media_player_get_state(_mediaPlayer); - return state == paused; - } - } - - public override bool IsPlaying - { - get - { - const int playing = 3; - int state = NativeMethods.libvlc_media_player_get_state(_mediaPlayer); - return state == playing; - } - } - - public int AudioTrackCount => NativeMethods.libvlc_audio_get_track_count(_mediaPlayer) - 1; - - public int AudioTrackNumber - { - get => NativeMethods.libvlc_audio_get_track(_mediaPlayer) - 1; - set => NativeMethods.libvlc_audio_set_track(_mediaPlayer, value + 1); - } - - public LibVlcMono MakeSecondMediaPlayer(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) - { - LibVlcMono newVlc = new LibVlcMono - { - _libVlc = _libVlc, - _libVlcDLL = _libVlcDLL, - _ownerControl = ownerControl - }; - if (ownerControl != null) - { - newVlc._parentForm = ownerControl.FindForm(); - } - - newVlc.OnVideoLoaded = onVideoLoaded; - newVlc.OnVideoEnded = onVideoEnded; - - if (!string.IsNullOrEmpty(videoFileName)) - { - IntPtr media = NativeMethods.libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0")); - newVlc._mediaPlayer = NativeMethods.libvlc_media_player_new_from_media(media); - NativeMethods.libvlc_media_release(media); - - // Linux: libvlc_media_player_set_xdrawable (_mediaPlayer, xdrawable); - // Mac: libvlc_media_player_set_nsobject (_mediaPlayer, view); - var ownerHandle = ownerControl == null ? IntPtr.Zero : ownerControl.Handle; - NativeMethods.libvlc_media_player_set_hwnd(newVlc._mediaPlayer, ownerHandle); // windows - - if (onVideoEnded != null) - { - newVlc._videoEndTimer = new Timer { Interval = 500 }; - newVlc._videoEndTimer.Tick += VideoEndTimerTick; - newVlc._videoEndTimer.Start(); - } - - NativeMethods.libvlc_media_player_play(newVlc._mediaPlayer); - newVlc._videoLoadedTimer = new Timer { Interval = 500 }; - newVlc._videoLoadedTimer.Tick += newVlc.VideoLoadedTimer_Tick; - newVlc._videoLoadedTimer.Start(); - } - return newVlc; - } - - private void VideoLoadedTimer_Tick(object sender, EventArgs e) - { - int i = 0; - while (!IsPlaying && i < 50) - { - System.Threading.Thread.Sleep(100); - i++; - } - NativeMethods.libvlc_media_player_pause(_mediaPlayer); - _videoLoadedTimer.Stop(); - - OnVideoLoaded?.Invoke(_mediaPlayer, new EventArgs()); - } - - public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) - { - _ownerControl = ownerControl; - if (ownerControl != null) - { - _parentForm = ownerControl.FindForm(); - } - - OnVideoLoaded = onVideoLoaded; - OnVideoEnded = onVideoEnded; - - if (!string.IsNullOrEmpty(videoFileName)) - { - string[] initParameters = { "--no-sub-autodetect-file" }; //, "--no-video-title-show" }; // TODO: Put in options/config file - _libVlc = NativeMethods.libvlc_new(initParameters.Length, initParameters); - IntPtr media = NativeMethods.libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0")); - _mediaPlayer = NativeMethods.libvlc_media_player_new_from_media(media); - NativeMethods.libvlc_media_release(media); - - // Linux: libvlc_media_player_set_xdrawable (_mediaPlayer, xdrawable); - // Mac: libvlc_media_player_set_nsobject (_mediaPlayer, view); - var ownerHandle = ownerControl == null ? IntPtr.Zero : ownerControl.Handle; - NativeMethods.libvlc_media_player_set_hwnd(_mediaPlayer, ownerHandle); // windows - - if (onVideoEnded != null) - { - _videoEndTimer = new Timer { Interval = 500 }; - _videoEndTimer.Tick += VideoEndTimerTick; - _videoEndTimer.Start(); - } - - NativeMethods.libvlc_media_player_play(_mediaPlayer); - _videoLoadedTimer = new Timer { Interval = 500 }; - _videoLoadedTimer.Tick += VideoLoadedTimer_Tick; - _videoLoadedTimer.Start(); - } - } - - private void VideoEndTimerTick(object sender, EventArgs e) - { - const int Ended = 6; - int state = NativeMethods.libvlc_media_player_get_state(_mediaPlayer); - if (state == Ended) - { - // hack to make sure VLC is in ready state - Stop(); - Play(); - Pause(); - OnVideoEnded.Invoke(_mediaPlayer, new EventArgs()); - } - } - - public override void DisposeVideoPlayer() - { - _videoLoadedTimer?.Stop(); - _videoEndTimer?.Stop(); - System.Threading.ThreadPool.QueueUserWorkItem(DisposeVLC, this); - } - - private void DisposeVLC(object player) - { - ReleaseUnmanagedResources(); - } - - public override event EventHandler OnVideoLoaded; - - public override event EventHandler OnVideoEnded; - - ~LibVlcMono() - { - Dispose(false); - } - - private void ReleaseUnmanagedResources() - { - try - { - if (_mediaPlayer != IntPtr.Zero) - { - NativeMethods.libvlc_media_player_stop(_mediaPlayer); - NativeMethods.libvlc_media_list_player_release(_mediaPlayer); - _mediaPlayer = IntPtr.Zero; - } - - if (_libVlc != IntPtr.Zero) - { - NativeMethods.libvlc_release(_libVlc); - _libVlc = IntPtr.Zero; - } - } - catch - { - // ignored - } - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - if (_videoLoadedTimer != null) - { - _videoLoadedTimer.Dispose(); - _videoLoadedTimer = null; - } - if (_videoEndTimer != null) - { - _videoEndTimer.Dispose(); - _videoEndTimer = null; - } - } - ReleaseUnmanagedResources(); - } - - } -} +using Nikse.SubtitleEdit.Core; +using System; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic.VideoPlayers +{ + internal class LibVlcMono : VideoPlayer, IDisposable + { + private Timer _videoLoadedTimer; + private Timer _videoEndTimer; + private IntPtr _libVlcDLL; + private IntPtr _libVlc; + private IntPtr _mediaPlayer; + private Control _ownerControl; + private Form _parentForm; + + public override string PlayerName => "VLC Lib Mono"; + + public override int Volume + { + get => NativeMethods.libvlc_audio_get_volume(_mediaPlayer); + set => NativeMethods.libvlc_audio_set_volume(_mediaPlayer, value); + } + + public override double Duration => NativeMethods.libvlc_media_player_get_length(_mediaPlayer) / TimeCode.BaseUnit; + + public override double CurrentPosition + { + get => NativeMethods.libvlc_media_player_get_time(_mediaPlayer) / TimeCode.BaseUnit; + set => NativeMethods.libvlc_media_player_set_time(_mediaPlayer, (long)(value * TimeCode.BaseUnit)); + } + + public override double PlayRate + { + get => NativeMethods.libvlc_media_player_get_rate(_mediaPlayer); + set + { + if (value >= 0 && value <= 2.0) + { + NativeMethods.libvlc_media_player_set_rate(_mediaPlayer, (float)value); + } + } + } + + public override void Play() + { + NativeMethods.libvlc_media_player_play(_mediaPlayer); + } + + public override void Pause() + { + if (!IsPaused) + { + NativeMethods.libvlc_media_player_pause(_mediaPlayer); + } + } + + public override void Stop() + { + NativeMethods.libvlc_media_player_stop(_mediaPlayer); + } + + public override bool IsPaused + { + get + { + const int paused = 4; + int state = NativeMethods.libvlc_media_player_get_state(_mediaPlayer); + return state == paused; + } + } + + public override bool IsPlaying + { + get + { + const int playing = 3; + int state = NativeMethods.libvlc_media_player_get_state(_mediaPlayer); + return state == playing; + } + } + + public int AudioTrackCount => NativeMethods.libvlc_audio_get_track_count(_mediaPlayer) - 1; + + public int AudioTrackNumber + { + get => NativeMethods.libvlc_audio_get_track(_mediaPlayer) - 1; + set => NativeMethods.libvlc_audio_set_track(_mediaPlayer, value + 1); + } + + public LibVlcMono MakeSecondMediaPlayer(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) + { + LibVlcMono newVlc = new LibVlcMono + { + _libVlc = _libVlc, + _libVlcDLL = _libVlcDLL, + _ownerControl = ownerControl + }; + if (ownerControl != null) + { + newVlc._parentForm = ownerControl.FindForm(); + } + + newVlc.OnVideoLoaded = onVideoLoaded; + newVlc.OnVideoEnded = onVideoEnded; + + if (!string.IsNullOrEmpty(videoFileName)) + { + IntPtr media = NativeMethods.libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0")); + newVlc._mediaPlayer = NativeMethods.libvlc_media_player_new_from_media(media); + NativeMethods.libvlc_media_release(media); + + // Linux: libvlc_media_player_set_xdrawable (_mediaPlayer, xdrawable); + // Mac: libvlc_media_player_set_nsobject (_mediaPlayer, view); + var ownerHandle = ownerControl == null ? IntPtr.Zero : ownerControl.Handle; + NativeMethods.libvlc_media_player_set_hwnd(newVlc._mediaPlayer, ownerHandle); // windows + + if (onVideoEnded != null) + { + newVlc._videoEndTimer = new Timer { Interval = 500 }; + newVlc._videoEndTimer.Tick += VideoEndTimerTick; + newVlc._videoEndTimer.Start(); + } + + NativeMethods.libvlc_media_player_play(newVlc._mediaPlayer); + newVlc._videoLoadedTimer = new Timer { Interval = 500 }; + newVlc._videoLoadedTimer.Tick += newVlc.VideoLoadedTimer_Tick; + newVlc._videoLoadedTimer.Start(); + } + return newVlc; + } + + private void VideoLoadedTimer_Tick(object sender, EventArgs e) + { + int i = 0; + while (!IsPlaying && i < 50) + { + System.Threading.Thread.Sleep(100); + i++; + } + NativeMethods.libvlc_media_player_pause(_mediaPlayer); + _videoLoadedTimer.Stop(); + + OnVideoLoaded?.Invoke(_mediaPlayer, new EventArgs()); + } + + public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) + { + _ownerControl = ownerControl; + if (ownerControl != null) + { + _parentForm = ownerControl.FindForm(); + } + + OnVideoLoaded = onVideoLoaded; + OnVideoEnded = onVideoEnded; + + if (!string.IsNullOrEmpty(videoFileName)) + { + string[] initParameters = { "--no-sub-autodetect-file" }; //, "--no-video-title-show" }; // TODO: Put in options/config file + _libVlc = NativeMethods.libvlc_new(initParameters.Length, initParameters); + IntPtr media = NativeMethods.libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0")); + _mediaPlayer = NativeMethods.libvlc_media_player_new_from_media(media); + NativeMethods.libvlc_media_release(media); + + // Linux: libvlc_media_player_set_xdrawable (_mediaPlayer, xdrawable); + // Mac: libvlc_media_player_set_nsobject (_mediaPlayer, view); + var ownerHandle = ownerControl == null ? IntPtr.Zero : ownerControl.Handle; + NativeMethods.libvlc_media_player_set_hwnd(_mediaPlayer, ownerHandle); // windows + + if (onVideoEnded != null) + { + _videoEndTimer = new Timer { Interval = 500 }; + _videoEndTimer.Tick += VideoEndTimerTick; + _videoEndTimer.Start(); + } + + NativeMethods.libvlc_media_player_play(_mediaPlayer); + _videoLoadedTimer = new Timer { Interval = 500 }; + _videoLoadedTimer.Tick += VideoLoadedTimer_Tick; + _videoLoadedTimer.Start(); + } + } + + private void VideoEndTimerTick(object sender, EventArgs e) + { + const int Ended = 6; + int state = NativeMethods.libvlc_media_player_get_state(_mediaPlayer); + if (state == Ended) + { + // hack to make sure VLC is in ready state + Stop(); + Play(); + Pause(); + OnVideoEnded.Invoke(_mediaPlayer, new EventArgs()); + } + } + + public override void DisposeVideoPlayer() + { + _videoLoadedTimer?.Stop(); + _videoEndTimer?.Stop(); + System.Threading.ThreadPool.QueueUserWorkItem(DisposeVLC, this); + } + + private void DisposeVLC(object player) + { + ReleaseUnmanagedResources(); + } + + public override event EventHandler OnVideoLoaded; + + public override event EventHandler OnVideoEnded; + + ~LibVlcMono() + { + Dispose(false); + } + + private void ReleaseUnmanagedResources() + { + try + { + if (_mediaPlayer != IntPtr.Zero) + { + NativeMethods.libvlc_media_player_stop(_mediaPlayer); + NativeMethods.libvlc_media_list_player_release(_mediaPlayer); + _mediaPlayer = IntPtr.Zero; + } + + if (_libVlc != IntPtr.Zero) + { + NativeMethods.libvlc_release(_libVlc); + _libVlc = IntPtr.Zero; + } + } + catch + { + // ignored + } + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + if (_videoLoadedTimer != null) + { + _videoLoadedTimer.Dispose(); + _videoLoadedTimer = null; + } + if (_videoEndTimer != null) + { + _videoEndTimer.Dispose(); + _videoEndTimer = null; + } + } + ReleaseUnmanagedResources(); + } + + } +} diff --git a/src/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.Designer.cs b/src/ui/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.Designer.cs similarity index 100% rename from src/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.Designer.cs rename to src/ui/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.Designer.cs diff --git a/src/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.cs b/src/ui/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.cs similarity index 100% rename from src/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.cs rename to src/ui/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.cs diff --git a/src/ui/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.resx b/src/ui/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/src/ui/Logic/VideoPlayers/MpcHC/MessageHandlerWindow.resx @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file diff --git a/src/Logic/VideoPlayers/MpcHC/MpcHc.cs b/src/ui/Logic/VideoPlayers/MpcHC/MpcHc.cs similarity index 97% rename from src/Logic/VideoPlayers/MpcHC/MpcHc.cs rename to src/ui/Logic/VideoPlayers/MpcHC/MpcHc.cs index 634adae60..1b1f76852 100644 --- a/src/Logic/VideoPlayers/MpcHC/MpcHc.cs +++ b/src/ui/Logic/VideoPlayers/MpcHC/MpcHc.cs @@ -1,541 +1,541 @@ -using Nikse.SubtitleEdit.Core; -using System; -using System.Collections; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -namespace Nikse.SubtitleEdit.Logic.VideoPlayers.MpcHC -{ - public class MpcHc : VideoPlayer, IDisposable - { - private readonly object _locker = new object(); - - private const string ModePlay = "0"; - private const string ModePause = "1"; - private string _playMode = string.Empty; - private int _loaded; - private IntPtr _mpcHandle = IntPtr.Zero; - private IntPtr _videoHandle = IntPtr.Zero; - private IntPtr _videoPanelHandle = IntPtr.Zero; - private ProcessStartInfo _startInfo; - private Process _process; - private IntPtr _messageHandlerHandle = IntPtr.Zero; - private string _videoFileName; - private Timer _positionTimer; - private double _positionInSeconds; - private double _durationInSeconds; - private MessageHandlerWindow _form; - private int _initialWidth; - private int _initialHeight; - private Timer _hideMpcTimer = new Timer(); - private int _hideMpcTimerCount; - - public override string PlayerName => "MPC-HC"; - - private int _volume = 75; - - public override int Volume - { - get => _volume; - set - { - // MPC-HC moves from 0-100 in steps of 5 - for (int i = 0; i < 100; i += 5) - { - SendMpcMessage(MpcHcCommand.DecreaseVolume); - } - - for (_volume = 0; _volume < value; _volume += 5) - { - SendMpcMessage(MpcHcCommand.IncreaseVolume); - } - } - } - - public override double Duration => _durationInSeconds; - - public override double CurrentPosition - { - get => _positionInSeconds; - set => SendMpcMessage(MpcHcCommand.SetPosition, string.Format(CultureInfo.InvariantCulture, "{0:0.000}", value)); - } - - public override void Play() - { - _playMode = ModePlay; - SendMpcMessage(MpcHcCommand.Play); - } - - public override void Pause() - { - _playMode = ModePause; - SendMpcMessage(MpcHcCommand.Pause); - } - - public override void Stop() - { - SendMpcMessage(MpcHcCommand.Stop); - } - - public override bool IsPaused => _playMode == ModePause; - - public override bool IsPlaying => _playMode == ModePlay; - - public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) - { - if (ownerControl == null) - { - return; - } - - VideoFileName = videoFileName; - OnVideoLoaded = onVideoLoaded; - OnVideoEnded = onVideoEnded; - - _initialWidth = ownerControl.Width; - _initialHeight = ownerControl.Height; - _form = new MessageHandlerWindow(); - _form.OnCopyData += OnCopyData; - _form.Show(); - _form.Hide(); - _videoPanelHandle = ownerControl.Handle; - _messageHandlerHandle = _form.Handle; - _videoFileName = videoFileName; - _startInfo = new ProcessStartInfo - { - FileName = GetMpcHcFileName(), - Arguments = "/new /minimized /slave " + _messageHandlerHandle - }; - _process = Process.Start(_startInfo); - _process?.WaitForInputIdle(); - - _positionTimer = new Timer { Interval = 100 }; - _positionTimer.Tick += PositionTimerTick; - } - - private void PositionTimerTick(object sender, EventArgs e) - { - SendMpcMessage(MpcHcCommand.GetCurrentPosition); - } - - private void OnCopyData(object sender, EventArgs e) - { - var message = (Message)sender; - var cds = (NativeMethods.CopyDataStruct)Marshal.PtrToStructure(message.LParam, typeof(NativeMethods.CopyDataStruct)); - var command = cds.dwData.ToUInt32(); - var param = Marshal.PtrToStringAuto(cds.lpData); - var multiParam = new string[0]; - if (param != null) - { - multiParam = param.Split('|'); - } - - switch (command) - { - case MpcHcCommand.Connect: - _positionTimer.Stop(); - _mpcHandle = (IntPtr)Convert.ToInt64(Marshal.PtrToStringAuto(cds.lpData)); - SendMpcMessage(MpcHcCommand.OpenFile, _videoFileName); - _positionTimer.Start(); - break; - case MpcHcCommand.PlayMode: - _playMode = param; - if (param == ModePlay && _loaded == 0) - { - _loaded = 1; - if (!HijackMpcHc()) - { - Application.DoEvents(); - HijackMpcHc(); - } - } - Application.DoEvents(); - HideMpcPlayerWindow(); - break; - case MpcHcCommand.NowPlaying: - if (_loaded == 1) - { - _loaded = 2; - - _durationInSeconds = 5000; - if (multiParam.Length >= 5 && double.TryParse(multiParam[4].Replace(",", ".").Trim(), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var d)) - { - _durationInSeconds = d; - } - else if (multiParam.Length >= 1 && double.TryParse(multiParam[multiParam.Length - 1].Replace(",", ".").Trim(), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out d)) - { - _durationInSeconds = d; - } - - Pause(); - Resize(_initialWidth, _initialHeight); - OnVideoLoaded?.Invoke(this, new EventArgs()); - - SendMpcMessage(MpcHcCommand.SetSubtitleTrack, "-1"); - - // be sure to hide MPC - _hideMpcTimerCount = 20; - _hideMpcTimer.Interval = 100; - _hideMpcTimer.Tick += (o, args) => - { - _hideMpcTimer.Stop(); - if (_hideMpcTimerCount > 0) - { - Application.DoEvents(); - HideMpcPlayerWindow(); - _hideMpcTimerCount--; - _hideMpcTimer.Start(); - } - }; - _hideMpcTimer.Start(); - } - break; - case MpcHcCommand.NotifyEndOfStream: - OnVideoEnded?.Invoke(this, new EventArgs()); - - break; - case MpcHcCommand.CurrentPosition: - if (!string.IsNullOrWhiteSpace(param)) - { - if (double.TryParse(param.Replace(",", "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var d)) - { - _positionInSeconds = d; - } - } - break; - } - } - - private void HideMpcPlayerWindow() - { - NativeMethods.ShowWindow(_process.MainWindowHandle, NativeMethods.ShowWindowCommands.Hide); - NativeMethods.SetWindowPos(_process.MainWindowHandle, (IntPtr)NativeMethods.SpecialWindowHandles.HWND_TOP, -9999, -9999, 0, 0, NativeMethods.SetWindowPosFlags.SWP_NOACTIVATE); - } - - internal static bool GetWindowHandle(IntPtr windowHandle, ArrayList windowHandles) - { - windowHandles.Add(windowHandle); - return true; - } - - private ArrayList GetChildWindows() - { - var windowHandles = new ArrayList(); - NativeMethods.EnumedWindow callBackPtr = GetWindowHandle; - NativeMethods.EnumChildWindows(_process.MainWindowHandle, callBackPtr, windowHandles); - return windowHandles; - } - - private static bool IsWindowMpcHcVideo(IntPtr hWnd) - { - var className = new StringBuilder(256); - int returnCode = NativeMethods.GetClassName(hWnd, className, className.Capacity); // Get the window class name - if (returnCode != 0) - { - return className.ToString().EndsWith(":b:0000000000010003:0000000000000006:0000000000000000") || // MPC-HC 64-bit video class??? - className.ToString().EndsWith(":b:00010003:00000006:00000000"); // MPC-HC 32-bit video class??? - } - - return false; - } - - private bool HijackMpcHc() - { - IntPtr handle = _process.MainWindowHandle; - var handles = GetChildWindows(); - foreach (var h in handles) - { - if (IsWindowMpcHcVideo((IntPtr)h)) - { - _videoHandle = (IntPtr)h; - NativeMethods.SetParent((IntPtr)h, _videoPanelHandle); - NativeMethods.SetWindowPos(handle, (IntPtr)NativeMethods.SpecialWindowHandles.HWND_TOP, -9999, -9999, 0, 0, NativeMethods.SetWindowPosFlags.SWP_NOACTIVATE); - return true; - } - } - return false; - } - - public override void Resize(int width, int height) - { - if (_process == null || _videoHandle == IntPtr.Zero) - { - return; - } - - NativeMethods.ShowWindow(_process.MainWindowHandle, NativeMethods.ShowWindowCommands.ShowNoActivate); - NativeMethods.SetWindowPos(_videoHandle, (IntPtr)NativeMethods.SpecialWindowHandles.HWND_TOP, 0, 0, width, height, NativeMethods.SetWindowPosFlags.SWP_NOREPOSITION); - HideMpcPlayerWindow(); - } - - public static string GetMpcHcFileName() - { - return GetMpcHcFileName("_nvo") ?? GetMpcHcFileName(string.Empty); - } - - private static string GetMpcHcFileName(string fileNameSuffix) - { - if (!Configuration.IsRunningOnWindows) //short circuit on Linux to resolve issues with read-only filesystems - { - return null; - } - if (IntPtr.Size == 8) // 64-bit - { - var fileName = $"mpc-hc64{fileNameSuffix}.exe"; - var path = Path.Combine(Configuration.BaseDirectory, "MPC-HC", fileName); - if (File.Exists(path)) - { - return path; - } - - if (!string.IsNullOrEmpty(Configuration.Settings.General.MpcHcLocation)) - { - path = Configuration.Settings.General.MpcHcLocation; - if (File.Exists(path) && path.EndsWith(fileName, StringComparison.OrdinalIgnoreCase)) - { - return path; - } - - if (Directory.Exists(Configuration.Settings.General.MpcHcLocation)) - { - path = Path.Combine(Configuration.Settings.General.MpcHcLocation, fileName); - if (File.Exists(path)) - { - return path; - } - - path = Path.Combine(Configuration.Settings.General.MpcHcLocation, "MPC-HC", fileName); - if (File.Exists(path)) - { - return path; - } - } - } - - path = RegistryUtil.GetValue(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2ACBF1FA-F5C3-4B19-A774-B22A31F231B9}_is1", "InstallLocation"); - if (path != null) - { - path = Path.Combine(path, fileName); - if (File.Exists(path)) - { - return path; - } - } - - path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "MPC-HC", fileName); - if (File.Exists(path)) - { - return path; - } - - path = $@"C:\Program Files\MPC-HC\{fileName}"; - if (File.Exists(path)) - { - return path; - } - - path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), $@"K-Lite Codec Pack\MPC-HC\{fileName}"); - if (File.Exists(path)) - { - return path; - } - - path = $@"C:\Program Files (x86)\K-Lite Codec Pack\MPC-HC64\{fileName}"; - if (File.Exists(path)) - { - return path; - } - - path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), $@"K-Lite Codec Pack\MPC-HC64\{fileName}"); - if (File.Exists(path)) - { - return path; - } - - path = $@"C:\Program Files (x86)\MPC-HC\{fileName}"; - if (File.Exists(path)) - { - return path; - } - } - else // 32-bit - { - var fileName = $"mpc-hc{fileNameSuffix}.exe"; - var path = Path.Combine(Configuration.BaseDirectory, "MPC-HC", fileName); - if (File.Exists(path)) - { - return path; - } - - if (!string.IsNullOrEmpty(Configuration.Settings.General.MpcHcLocation)) - { - path = Configuration.Settings.General.MpcHcLocation; - if (File.Exists(path) && path.EndsWith(fileName, StringComparison.OrdinalIgnoreCase)) - { - return path; - } - - if (Directory.Exists(Configuration.Settings.General.MpcHcLocation)) - { - path = Path.Combine(Configuration.Settings.General.MpcHcLocation, fileName); - if (File.Exists(path)) - { - return path; - } - - path = Path.Combine(Configuration.Settings.General.MpcHcLocation, "MPC-HC", fileName); - if (File.Exists(path)) - { - return path; - } - } - } - - path = RegistryUtil.GetValue(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2624B969-7135-4EB1-B0F6-2D8C397B45F7}_is1", "InstallLocation"); - if (path != null) - { - path = Path.Combine(path, fileName); - if (File.Exists(path)) - { - return path; - } - } - - path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "MPC-HC", fileName); - if (File.Exists(path)) - { - return path; - } - - path = $@"C:\Program Files (x86)\MPC-HC\{fileName}"; - if (File.Exists(path)) - { - return path; - } - - path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), $@"K-Lite Codec Pack\MPC-HC\{fileName}"); - if (File.Exists(path)) - { - return path; - } - - path = $@"C:\Program Files\MPC-HC\{fileName}"; - if (File.Exists(path)) - { - return path; - } - } - - return null; - } - - public static bool IsInstalled => true; - - public override void DisposeVideoPlayer() - { - Dispose(); - } - - public override event EventHandler OnVideoLoaded; - - public override event EventHandler OnVideoEnded; - - private void ReleaseUnmanagedResources() - { - try - { - lock (_locker) - { - if (_mpcHandle != IntPtr.Zero) - { - SendMpcMessage(MpcHcCommand.CloseApplication); - _mpcHandle = IntPtr.Zero; - } - } - } - catch - { - // ignored - } - } - - ~MpcHc() - { - Dispose(false); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - try - { - if (disposing) - { - // release managed resources - if (_positionTimer != null) - { - _positionTimer.Stop(); - _positionTimer.Dispose(); - _positionTimer = null; - } - if (_hideMpcTimer != null) - { - _hideMpcTimer.Stop(); - _hideMpcTimer.Dispose(); - _hideMpcTimer = null; - } - - if (_form != null) - { - _form.OnCopyData -= OnCopyData; - //_form.Dispose(); this gives an error when doing File -> Exit... - _form = null; - } - - if (_process != null) - { - _process.Dispose(); - _process = null; - } - _startInfo = null; - } - ReleaseUnmanagedResources(); - } - catch (Exception exception) - { - MessageBox.Show(exception.Message); - } - } - - private void SendMpcMessage(uint command) - { - SendMpcMessage(command, string.Empty); - } - - private void SendMpcMessage(uint command, string parameter) - { - if (_mpcHandle == IntPtr.Zero || _messageHandlerHandle == IntPtr.Zero) - { - return; - } - - parameter += (char)0; - NativeMethods.CopyDataStruct cds; - cds.dwData = (UIntPtr)command; - cds.cbData = parameter.Length * Marshal.SystemDefaultCharSize; - cds.lpData = Marshal.StringToCoTaskMemAuto(parameter); - NativeMethods.SendMessage(_mpcHandle, NativeMethods.WindowsMessageCopyData, _messageHandlerHandle, ref cds); - } - - } -} +using Nikse.SubtitleEdit.Core; +using System; +using System.Collections; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +namespace Nikse.SubtitleEdit.Logic.VideoPlayers.MpcHC +{ + public class MpcHc : VideoPlayer, IDisposable + { + private readonly object _locker = new object(); + + private const string ModePlay = "0"; + private const string ModePause = "1"; + private string _playMode = string.Empty; + private int _loaded; + private IntPtr _mpcHandle = IntPtr.Zero; + private IntPtr _videoHandle = IntPtr.Zero; + private IntPtr _videoPanelHandle = IntPtr.Zero; + private ProcessStartInfo _startInfo; + private Process _process; + private IntPtr _messageHandlerHandle = IntPtr.Zero; + private string _videoFileName; + private Timer _positionTimer; + private double _positionInSeconds; + private double _durationInSeconds; + private MessageHandlerWindow _form; + private int _initialWidth; + private int _initialHeight; + private Timer _hideMpcTimer = new Timer(); + private int _hideMpcTimerCount; + + public override string PlayerName => "MPC-HC"; + + private int _volume = 75; + + public override int Volume + { + get => _volume; + set + { + // MPC-HC moves from 0-100 in steps of 5 + for (int i = 0; i < 100; i += 5) + { + SendMpcMessage(MpcHcCommand.DecreaseVolume); + } + + for (_volume = 0; _volume < value; _volume += 5) + { + SendMpcMessage(MpcHcCommand.IncreaseVolume); + } + } + } + + public override double Duration => _durationInSeconds; + + public override double CurrentPosition + { + get => _positionInSeconds; + set => SendMpcMessage(MpcHcCommand.SetPosition, string.Format(CultureInfo.InvariantCulture, "{0:0.000}", value)); + } + + public override void Play() + { + _playMode = ModePlay; + SendMpcMessage(MpcHcCommand.Play); + } + + public override void Pause() + { + _playMode = ModePause; + SendMpcMessage(MpcHcCommand.Pause); + } + + public override void Stop() + { + SendMpcMessage(MpcHcCommand.Stop); + } + + public override bool IsPaused => _playMode == ModePause; + + public override bool IsPlaying => _playMode == ModePlay; + + public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) + { + if (ownerControl == null) + { + return; + } + + VideoFileName = videoFileName; + OnVideoLoaded = onVideoLoaded; + OnVideoEnded = onVideoEnded; + + _initialWidth = ownerControl.Width; + _initialHeight = ownerControl.Height; + _form = new MessageHandlerWindow(); + _form.OnCopyData += OnCopyData; + _form.Show(); + _form.Hide(); + _videoPanelHandle = ownerControl.Handle; + _messageHandlerHandle = _form.Handle; + _videoFileName = videoFileName; + _startInfo = new ProcessStartInfo + { + FileName = GetMpcHcFileName(), + Arguments = "/new /minimized /slave " + _messageHandlerHandle + }; + _process = Process.Start(_startInfo); + _process?.WaitForInputIdle(); + + _positionTimer = new Timer { Interval = 100 }; + _positionTimer.Tick += PositionTimerTick; + } + + private void PositionTimerTick(object sender, EventArgs e) + { + SendMpcMessage(MpcHcCommand.GetCurrentPosition); + } + + private void OnCopyData(object sender, EventArgs e) + { + var message = (Message)sender; + var cds = (NativeMethods.CopyDataStruct)Marshal.PtrToStructure(message.LParam, typeof(NativeMethods.CopyDataStruct)); + var command = cds.dwData.ToUInt32(); + var param = Marshal.PtrToStringAuto(cds.lpData); + var multiParam = new string[0]; + if (param != null) + { + multiParam = param.Split('|'); + } + + switch (command) + { + case MpcHcCommand.Connect: + _positionTimer.Stop(); + _mpcHandle = (IntPtr)Convert.ToInt64(Marshal.PtrToStringAuto(cds.lpData)); + SendMpcMessage(MpcHcCommand.OpenFile, _videoFileName); + _positionTimer.Start(); + break; + case MpcHcCommand.PlayMode: + _playMode = param; + if (param == ModePlay && _loaded == 0) + { + _loaded = 1; + if (!HijackMpcHc()) + { + Application.DoEvents(); + HijackMpcHc(); + } + } + Application.DoEvents(); + HideMpcPlayerWindow(); + break; + case MpcHcCommand.NowPlaying: + if (_loaded == 1) + { + _loaded = 2; + + _durationInSeconds = 5000; + if (multiParam.Length >= 5 && double.TryParse(multiParam[4].Replace(",", ".").Trim(), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var d)) + { + _durationInSeconds = d; + } + else if (multiParam.Length >= 1 && double.TryParse(multiParam[multiParam.Length - 1].Replace(",", ".").Trim(), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out d)) + { + _durationInSeconds = d; + } + + Pause(); + Resize(_initialWidth, _initialHeight); + OnVideoLoaded?.Invoke(this, new EventArgs()); + + SendMpcMessage(MpcHcCommand.SetSubtitleTrack, "-1"); + + // be sure to hide MPC + _hideMpcTimerCount = 20; + _hideMpcTimer.Interval = 100; + _hideMpcTimer.Tick += (o, args) => + { + _hideMpcTimer.Stop(); + if (_hideMpcTimerCount > 0) + { + Application.DoEvents(); + HideMpcPlayerWindow(); + _hideMpcTimerCount--; + _hideMpcTimer.Start(); + } + }; + _hideMpcTimer.Start(); + } + break; + case MpcHcCommand.NotifyEndOfStream: + OnVideoEnded?.Invoke(this, new EventArgs()); + + break; + case MpcHcCommand.CurrentPosition: + if (!string.IsNullOrWhiteSpace(param)) + { + if (double.TryParse(param.Replace(",", "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var d)) + { + _positionInSeconds = d; + } + } + break; + } + } + + private void HideMpcPlayerWindow() + { + NativeMethods.ShowWindow(_process.MainWindowHandle, NativeMethods.ShowWindowCommands.Hide); + NativeMethods.SetWindowPos(_process.MainWindowHandle, (IntPtr)NativeMethods.SpecialWindowHandles.HWND_TOP, -9999, -9999, 0, 0, NativeMethods.SetWindowPosFlags.SWP_NOACTIVATE); + } + + internal static bool GetWindowHandle(IntPtr windowHandle, ArrayList windowHandles) + { + windowHandles.Add(windowHandle); + return true; + } + + private ArrayList GetChildWindows() + { + var windowHandles = new ArrayList(); + NativeMethods.EnumedWindow callBackPtr = GetWindowHandle; + NativeMethods.EnumChildWindows(_process.MainWindowHandle, callBackPtr, windowHandles); + return windowHandles; + } + + private static bool IsWindowMpcHcVideo(IntPtr hWnd) + { + var className = new StringBuilder(256); + int returnCode = NativeMethods.GetClassName(hWnd, className, className.Capacity); // Get the window class name + if (returnCode != 0) + { + return className.ToString().EndsWith(":b:0000000000010003:0000000000000006:0000000000000000") || // MPC-HC 64-bit video class??? + className.ToString().EndsWith(":b:00010003:00000006:00000000"); // MPC-HC 32-bit video class??? + } + + return false; + } + + private bool HijackMpcHc() + { + IntPtr handle = _process.MainWindowHandle; + var handles = GetChildWindows(); + foreach (var h in handles) + { + if (IsWindowMpcHcVideo((IntPtr)h)) + { + _videoHandle = (IntPtr)h; + NativeMethods.SetParent((IntPtr)h, _videoPanelHandle); + NativeMethods.SetWindowPos(handle, (IntPtr)NativeMethods.SpecialWindowHandles.HWND_TOP, -9999, -9999, 0, 0, NativeMethods.SetWindowPosFlags.SWP_NOACTIVATE); + return true; + } + } + return false; + } + + public override void Resize(int width, int height) + { + if (_process == null || _videoHandle == IntPtr.Zero) + { + return; + } + + NativeMethods.ShowWindow(_process.MainWindowHandle, NativeMethods.ShowWindowCommands.ShowNoActivate); + NativeMethods.SetWindowPos(_videoHandle, (IntPtr)NativeMethods.SpecialWindowHandles.HWND_TOP, 0, 0, width, height, NativeMethods.SetWindowPosFlags.SWP_NOREPOSITION); + HideMpcPlayerWindow(); + } + + public static string GetMpcHcFileName() + { + return GetMpcHcFileName("_nvo") ?? GetMpcHcFileName(string.Empty); + } + + private static string GetMpcHcFileName(string fileNameSuffix) + { + if (!Configuration.IsRunningOnWindows) //short circuit on Linux to resolve issues with read-only filesystems + { + return null; + } + if (IntPtr.Size == 8) // 64-bit + { + var fileName = $"mpc-hc64{fileNameSuffix}.exe"; + var path = Path.Combine(Configuration.BaseDirectory, "MPC-HC", fileName); + if (File.Exists(path)) + { + return path; + } + + if (!string.IsNullOrEmpty(Configuration.Settings.General.MpcHcLocation)) + { + path = Configuration.Settings.General.MpcHcLocation; + if (File.Exists(path) && path.EndsWith(fileName, StringComparison.OrdinalIgnoreCase)) + { + return path; + } + + if (Directory.Exists(Configuration.Settings.General.MpcHcLocation)) + { + path = Path.Combine(Configuration.Settings.General.MpcHcLocation, fileName); + if (File.Exists(path)) + { + return path; + } + + path = Path.Combine(Configuration.Settings.General.MpcHcLocation, "MPC-HC", fileName); + if (File.Exists(path)) + { + return path; + } + } + } + + path = RegistryUtil.GetValue(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2ACBF1FA-F5C3-4B19-A774-B22A31F231B9}_is1", "InstallLocation"); + if (path != null) + { + path = Path.Combine(path, fileName); + if (File.Exists(path)) + { + return path; + } + } + + path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "MPC-HC", fileName); + if (File.Exists(path)) + { + return path; + } + + path = $@"C:\Program Files\MPC-HC\{fileName}"; + if (File.Exists(path)) + { + return path; + } + + path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), $@"K-Lite Codec Pack\MPC-HC\{fileName}"); + if (File.Exists(path)) + { + return path; + } + + path = $@"C:\Program Files (x86)\K-Lite Codec Pack\MPC-HC64\{fileName}"; + if (File.Exists(path)) + { + return path; + } + + path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), $@"K-Lite Codec Pack\MPC-HC64\{fileName}"); + if (File.Exists(path)) + { + return path; + } + + path = $@"C:\Program Files (x86)\MPC-HC\{fileName}"; + if (File.Exists(path)) + { + return path; + } + } + else // 32-bit + { + var fileName = $"mpc-hc{fileNameSuffix}.exe"; + var path = Path.Combine(Configuration.BaseDirectory, "MPC-HC", fileName); + if (File.Exists(path)) + { + return path; + } + + if (!string.IsNullOrEmpty(Configuration.Settings.General.MpcHcLocation)) + { + path = Configuration.Settings.General.MpcHcLocation; + if (File.Exists(path) && path.EndsWith(fileName, StringComparison.OrdinalIgnoreCase)) + { + return path; + } + + if (Directory.Exists(Configuration.Settings.General.MpcHcLocation)) + { + path = Path.Combine(Configuration.Settings.General.MpcHcLocation, fileName); + if (File.Exists(path)) + { + return path; + } + + path = Path.Combine(Configuration.Settings.General.MpcHcLocation, "MPC-HC", fileName); + if (File.Exists(path)) + { + return path; + } + } + } + + path = RegistryUtil.GetValue(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2624B969-7135-4EB1-B0F6-2D8C397B45F7}_is1", "InstallLocation"); + if (path != null) + { + path = Path.Combine(path, fileName); + if (File.Exists(path)) + { + return path; + } + } + + path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "MPC-HC", fileName); + if (File.Exists(path)) + { + return path; + } + + path = $@"C:\Program Files (x86)\MPC-HC\{fileName}"; + if (File.Exists(path)) + { + return path; + } + + path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), $@"K-Lite Codec Pack\MPC-HC\{fileName}"); + if (File.Exists(path)) + { + return path; + } + + path = $@"C:\Program Files\MPC-HC\{fileName}"; + if (File.Exists(path)) + { + return path; + } + } + + return null; + } + + public static bool IsInstalled => true; + + public override void DisposeVideoPlayer() + { + Dispose(); + } + + public override event EventHandler OnVideoLoaded; + + public override event EventHandler OnVideoEnded; + + private void ReleaseUnmanagedResources() + { + try + { + lock (_locker) + { + if (_mpcHandle != IntPtr.Zero) + { + SendMpcMessage(MpcHcCommand.CloseApplication); + _mpcHandle = IntPtr.Zero; + } + } + } + catch + { + // ignored + } + } + + ~MpcHc() + { + Dispose(false); + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + try + { + if (disposing) + { + // release managed resources + if (_positionTimer != null) + { + _positionTimer.Stop(); + _positionTimer.Dispose(); + _positionTimer = null; + } + if (_hideMpcTimer != null) + { + _hideMpcTimer.Stop(); + _hideMpcTimer.Dispose(); + _hideMpcTimer = null; + } + + if (_form != null) + { + _form.OnCopyData -= OnCopyData; + //_form.Dispose(); this gives an error when doing File -> Exit... + _form = null; + } + + if (_process != null) + { + _process.Dispose(); + _process = null; + } + _startInfo = null; + } + ReleaseUnmanagedResources(); + } + catch (Exception exception) + { + MessageBox.Show(exception.Message); + } + } + + private void SendMpcMessage(uint command) + { + SendMpcMessage(command, string.Empty); + } + + private void SendMpcMessage(uint command, string parameter) + { + if (_mpcHandle == IntPtr.Zero || _messageHandlerHandle == IntPtr.Zero) + { + return; + } + + parameter += (char)0; + NativeMethods.CopyDataStruct cds; + cds.dwData = (UIntPtr)command; + cds.cbData = parameter.Length * Marshal.SystemDefaultCharSize; + cds.lpData = Marshal.StringToCoTaskMemAuto(parameter); + NativeMethods.SendMessage(_mpcHandle, NativeMethods.WindowsMessageCopyData, _messageHandlerHandle, ref cds); + } + + } +} diff --git a/src/Logic/VideoPlayers/MpcHC/MpcHcCommand.cs b/src/ui/Logic/VideoPlayers/MpcHC/MpcHcCommand.cs similarity index 100% rename from src/Logic/VideoPlayers/MpcHC/MpcHcCommand.cs rename to src/ui/Logic/VideoPlayers/MpcHC/MpcHcCommand.cs diff --git a/src/Logic/VideoPlayers/MpcHC/NativeMethods.cs b/src/ui/Logic/VideoPlayers/MpcHC/NativeMethods.cs similarity index 100% rename from src/Logic/VideoPlayers/MpcHC/NativeMethods.cs rename to src/ui/Logic/VideoPlayers/MpcHC/NativeMethods.cs diff --git a/src/Logic/VideoPlayers/QuartsPlayer.cs b/src/ui/Logic/VideoPlayers/QuartsPlayer.cs similarity index 96% rename from src/Logic/VideoPlayers/QuartsPlayer.cs rename to src/ui/Logic/VideoPlayers/QuartsPlayer.cs index 3e68238cc..8ea041190 100644 --- a/src/Logic/VideoPlayers/QuartsPlayer.cs +++ b/src/ui/Logic/VideoPlayers/QuartsPlayer.cs @@ -1,373 +1,373 @@ -using Nikse.SubtitleEdit.Core; -using QuartzTypeLib; -using System; -using System.ComponentModel; -using System.Linq; -using System.Runtime.InteropServices; -using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Common; - -//https://docs.microsoft.com/en-us/windows/win32/directshow/directshow -//https://docs.microsoft.com/en-us/previous-versions//dd387928(v=vs.85) - -namespace Nikse.SubtitleEdit.Logic.VideoPlayers -{ - public class QuartsPlayer : VideoPlayer, IDisposable - { - public override event EventHandler OnVideoLoaded; - public override event EventHandler OnVideoEnded; - - private IVideoWindow _quartzVideo; - private FilgraphManager _quartzFilgraphManager; - private IMediaPosition _mediaPosition; - private bool _isPaused; - private Control _owner; - private Timer _videoEndTimer; - private BackgroundWorker _videoLoader; - private int _sourceWidth; - private int _sourceHeight; - - public override string PlayerName => "DirectShow"; - - /// <summary> - /// In DirectX -10000 is silent and 0 is full volume. - /// Also, -3500 to 0 seems to be all you can hear! Not much use for -3500 to -9999... - /// </summary> - public override int Volume - { - get - { - try - { - return ((IBasicAudio)_quartzFilgraphManager).Volume / 35 + 100; - } - catch - { - return 0; - } - } - set - { - try - { - if (value == 0) - { - ((IBasicAudio)_quartzFilgraphManager).Volume = -10000; - } - else - { - ((IBasicAudio)_quartzFilgraphManager).Volume = (value - 100) * 35; - } - } - catch - { - // ignored - } - } - } - - public override double Duration - { - get - { - try - { - return _mediaPosition.Duration; - } - catch - { - return 0; - } - } - } - - public override double CurrentPosition - { - get - { - try - { - return _mediaPosition.CurrentPosition; - } - catch - { - return 0; - } - } - set - { - if (value >= 0 && value <= Duration) - { - _mediaPosition.CurrentPosition = value; - } - } - } - - public override double PlayRate - { - get => _mediaPosition.Rate; - set - { - if (value >= 0 && value <= 2.0) - { - _mediaPosition.Rate = value; - } - } - } - - public override void Play() - { - _quartzFilgraphManager.Run(); - _isPaused = false; - } - - public override void Pause() - { - _quartzFilgraphManager.Pause(); - _isPaused = true; - } - - public override void Stop() - { - _quartzFilgraphManager.Stop(); - _isPaused = true; - } - - public override bool IsPaused => _isPaused; - - public override bool IsPlaying => !IsPaused; - - public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) - { - const int wsChild = 0x40000000; - - string ext = System.IO.Path.GetExtension(videoFileName)?.ToLowerInvariant(); - bool isAudio = Utilities.AudioFileExtensions.Contains(ext); - - OnVideoLoaded = onVideoLoaded; - OnVideoEnded = onVideoEnded; - - VideoFileName = videoFileName; - _owner = ownerControl; - - try - { - // Hack for windows 10... ??? - if (!isAudio && Configuration.Settings.General.DirectShowDoubleLoad) - { - var quartzFilterGraphManager = new FilgraphManager(); - quartzFilterGraphManager.RenderFile(VideoFileName); - var quartzVideo = quartzFilterGraphManager as IVideoWindow; - quartzVideo.Visible = 0; - quartzVideo.Owner = (int)IntPtr.Zero; - } - } - catch - { - // ignore errors - } - - _quartzFilgraphManager = new FilgraphManager(); - _quartzFilgraphManager.RenderFile(VideoFileName); - - if (!isAudio) - { - _quartzVideo = _quartzFilgraphManager as IVideoWindow; - _quartzVideo.Owner = (int)ownerControl.Handle; - _quartzVideo.SetWindowPosition(0, 0, ownerControl.Width, ownerControl.Height); - _quartzVideo.WindowStyle = wsChild; - } - - if (!isAudio) - { - ((IBasicVideo)_quartzFilgraphManager).GetVideoSize(out _sourceWidth, out _sourceHeight); - } - - _owner.Resize += OwnerControlResize; - _mediaPosition = (IMediaPosition)_quartzFilgraphManager; - if (OnVideoLoaded != null) - { - _videoLoader = new BackgroundWorker(); - _videoLoader.RunWorkerCompleted += VideoLoaderRunWorkerCompleted; - _videoLoader.DoWork += VideoLoaderDoWork; - _videoLoader.RunWorkerAsync(); - } - - OwnerControlResize(this, null); - _videoEndTimer = new Timer { Interval = 500 }; - _videoEndTimer.Tick += VideoEndTimerTick; - _videoEndTimer.Start(); - - if (!isAudio) - { - _quartzVideo.MessageDrain = (int)ownerControl.Handle; - } - } - - public static VideoInfo GetVideoInfo(string videoFileName) - { - var info = new VideoInfo { Success = false }; - - try - { - var quartzFilgraphManager = new FilgraphManager(); - quartzFilgraphManager.RenderFile(videoFileName); - ((IBasicVideo)quartzFilgraphManager).GetVideoSize(out var width, out var height); - - info.Width = width; - info.Height = height; - var basicVideo2 = (IBasicVideo2)quartzFilgraphManager; - if (basicVideo2.AvgTimePerFrame > 0) - { - info.FramesPerSecond = 1 / basicVideo2.AvgTimePerFrame; - } - - info.Success = true; - var iMediaPosition = (quartzFilgraphManager as IMediaPosition); - info.TotalMilliseconds = iMediaPosition.Duration * 1000; - info.TotalSeconds = iMediaPosition.Duration; - info.TotalFrames = info.TotalSeconds * info.FramesPerSecond; - info.VideoCodec = string.Empty; // TODO: Get real codec names from quartzFilgraphManager.FilterCollection; - - Marshal.ReleaseComObject(quartzFilgraphManager); - } - catch - { - // ignored - } - - return info; - } - - private void VideoLoaderDoWork(object sender, DoWorkEventArgs e) - { - Application.DoEvents(); - } - - private void VideoLoaderRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) - { - if (OnVideoLoaded != null) - { - try - { - OnVideoLoaded.Invoke(_quartzFilgraphManager, new EventArgs()); - } - catch - { - // ignored - } - } - _videoEndTimer = null; - } - - private void VideoEndTimerTick(object sender, EventArgs e) - { - if (_isPaused == false && _quartzFilgraphManager != null && CurrentPosition >= Duration) - { - _isPaused = true; - if (OnVideoEnded != null && _quartzFilgraphManager != null) - { - OnVideoEnded.Invoke(_quartzFilgraphManager, new EventArgs()); - } - } - } - - private void OwnerControlResize(object sender, EventArgs e) - { - if (_quartzVideo == null) - { - return; - } - - try - { - // calc new scaled size with correct aspect ratio - float factorX = _owner.Width / (float)_sourceWidth; - float factorY = _owner.Height / (float)_sourceHeight; - - if (factorX > factorY) - { - _quartzVideo.Width = (int)(_sourceWidth * factorY); - _quartzVideo.Height = (int)(_sourceHeight * factorY); - } - else - { - _quartzVideo.Width = (int)(_sourceWidth * factorX); - _quartzVideo.Height = (int)(_sourceHeight * factorX); - } - - _quartzVideo.Left = (_owner.Width - _quartzVideo.Width) / 2; - _quartzVideo.Top = (_owner.Height - _quartzVideo.Height) / 2; - } - catch - { - // ignored - } - } - - public override void DisposeVideoPlayer() - { - System.Threading.ThreadPool.QueueUserWorkItem(DisposeQuarts, _quartzFilgraphManager); - } - - private void DisposeQuarts(object player) - { - Dispose(); - } - - private void ReleaseUnmanagedResources() - { - try - { - if (_quartzVideo != null) - { - _quartzVideo.Owner = -1; - } - } - catch - { - // ignored - } - - if (_quartzFilgraphManager != null) - { - try - { - _quartzFilgraphManager.Stop(); - Marshal.ReleaseComObject(_quartzFilgraphManager); - _quartzFilgraphManager = null; - } - catch - { - // ignored - } - } - _quartzVideo = null; - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - if (_videoEndTimer != null) - { - _videoEndTimer.Dispose(); - _videoEndTimer = null; - } - if (_videoLoader != null) - { - _videoLoader.Dispose(); - _videoLoader = null; - } - } - ReleaseUnmanagedResources(); - } - - } -} +using Nikse.SubtitleEdit.Core; +using QuartzTypeLib; +using System; +using System.ComponentModel; +using System.Linq; +using System.Runtime.InteropServices; +using System.Windows.Forms; +using Nikse.SubtitleEdit.Core.Common; + +//https://docs.microsoft.com/en-us/windows/win32/directshow/directshow +//https://docs.microsoft.com/en-us/previous-versions//dd387928(v=vs.85) + +namespace Nikse.SubtitleEdit.Logic.VideoPlayers +{ + public class QuartsPlayer : VideoPlayer, IDisposable + { + public override event EventHandler OnVideoLoaded; + public override event EventHandler OnVideoEnded; + + private IVideoWindow _quartzVideo; + private FilgraphManager _quartzFilgraphManager; + private IMediaPosition _mediaPosition; + private bool _isPaused; + private Control _owner; + private Timer _videoEndTimer; + private BackgroundWorker _videoLoader; + private int _sourceWidth; + private int _sourceHeight; + + public override string PlayerName => "DirectShow"; + + /// <summary> + /// In DirectX -10000 is silent and 0 is full volume. + /// Also, -3500 to 0 seems to be all you can hear! Not much use for -3500 to -9999... + /// </summary> + public override int Volume + { + get + { + try + { + return ((IBasicAudio)_quartzFilgraphManager).Volume / 35 + 100; + } + catch + { + return 0; + } + } + set + { + try + { + if (value == 0) + { + ((IBasicAudio)_quartzFilgraphManager).Volume = -10000; + } + else + { + ((IBasicAudio)_quartzFilgraphManager).Volume = (value - 100) * 35; + } + } + catch + { + // ignored + } + } + } + + public override double Duration + { + get + { + try + { + return _mediaPosition.Duration; + } + catch + { + return 0; + } + } + } + + public override double CurrentPosition + { + get + { + try + { + return _mediaPosition.CurrentPosition; + } + catch + { + return 0; + } + } + set + { + if (value >= 0 && value <= Duration) + { + _mediaPosition.CurrentPosition = value; + } + } + } + + public override double PlayRate + { + get => _mediaPosition.Rate; + set + { + if (value >= 0 && value <= 2.0) + { + _mediaPosition.Rate = value; + } + } + } + + public override void Play() + { + _quartzFilgraphManager.Run(); + _isPaused = false; + } + + public override void Pause() + { + _quartzFilgraphManager.Pause(); + _isPaused = true; + } + + public override void Stop() + { + _quartzFilgraphManager.Stop(); + _isPaused = true; + } + + public override bool IsPaused => _isPaused; + + public override bool IsPlaying => !IsPaused; + + public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) + { + const int wsChild = 0x40000000; + + string ext = System.IO.Path.GetExtension(videoFileName)?.ToLowerInvariant(); + bool isAudio = Utilities.AudioFileExtensions.Contains(ext); + + OnVideoLoaded = onVideoLoaded; + OnVideoEnded = onVideoEnded; + + VideoFileName = videoFileName; + _owner = ownerControl; + + try + { + // Hack for windows 10... ??? + if (!isAudio && Configuration.Settings.General.DirectShowDoubleLoad) + { + var quartzFilterGraphManager = new FilgraphManager(); + quartzFilterGraphManager.RenderFile(VideoFileName); + var quartzVideo = quartzFilterGraphManager as IVideoWindow; + quartzVideo.Visible = 0; + quartzVideo.Owner = (int)IntPtr.Zero; + } + } + catch + { + // ignore errors + } + + _quartzFilgraphManager = new FilgraphManager(); + _quartzFilgraphManager.RenderFile(VideoFileName); + + if (!isAudio) + { + _quartzVideo = _quartzFilgraphManager as IVideoWindow; + _quartzVideo.Owner = (int)ownerControl.Handle; + _quartzVideo.SetWindowPosition(0, 0, ownerControl.Width, ownerControl.Height); + _quartzVideo.WindowStyle = wsChild; + } + + if (!isAudio) + { + ((IBasicVideo)_quartzFilgraphManager).GetVideoSize(out _sourceWidth, out _sourceHeight); + } + + _owner.Resize += OwnerControlResize; + _mediaPosition = (IMediaPosition)_quartzFilgraphManager; + if (OnVideoLoaded != null) + { + _videoLoader = new BackgroundWorker(); + _videoLoader.RunWorkerCompleted += VideoLoaderRunWorkerCompleted; + _videoLoader.DoWork += VideoLoaderDoWork; + _videoLoader.RunWorkerAsync(); + } + + OwnerControlResize(this, null); + _videoEndTimer = new Timer { Interval = 500 }; + _videoEndTimer.Tick += VideoEndTimerTick; + _videoEndTimer.Start(); + + if (!isAudio) + { + _quartzVideo.MessageDrain = (int)ownerControl.Handle; + } + } + + public static VideoInfo GetVideoInfo(string videoFileName) + { + var info = new VideoInfo { Success = false }; + + try + { + var quartzFilgraphManager = new FilgraphManager(); + quartzFilgraphManager.RenderFile(videoFileName); + ((IBasicVideo)quartzFilgraphManager).GetVideoSize(out var width, out var height); + + info.Width = width; + info.Height = height; + var basicVideo2 = (IBasicVideo2)quartzFilgraphManager; + if (basicVideo2.AvgTimePerFrame > 0) + { + info.FramesPerSecond = 1 / basicVideo2.AvgTimePerFrame; + } + + info.Success = true; + var iMediaPosition = (quartzFilgraphManager as IMediaPosition); + info.TotalMilliseconds = iMediaPosition.Duration * 1000; + info.TotalSeconds = iMediaPosition.Duration; + info.TotalFrames = info.TotalSeconds * info.FramesPerSecond; + info.VideoCodec = string.Empty; // TODO: Get real codec names from quartzFilgraphManager.FilterCollection; + + Marshal.ReleaseComObject(quartzFilgraphManager); + } + catch + { + // ignored + } + + return info; + } + + private void VideoLoaderDoWork(object sender, DoWorkEventArgs e) + { + Application.DoEvents(); + } + + private void VideoLoaderRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + { + if (OnVideoLoaded != null) + { + try + { + OnVideoLoaded.Invoke(_quartzFilgraphManager, new EventArgs()); + } + catch + { + // ignored + } + } + _videoEndTimer = null; + } + + private void VideoEndTimerTick(object sender, EventArgs e) + { + if (_isPaused == false && _quartzFilgraphManager != null && CurrentPosition >= Duration) + { + _isPaused = true; + if (OnVideoEnded != null && _quartzFilgraphManager != null) + { + OnVideoEnded.Invoke(_quartzFilgraphManager, new EventArgs()); + } + } + } + + private void OwnerControlResize(object sender, EventArgs e) + { + if (_quartzVideo == null) + { + return; + } + + try + { + // calc new scaled size with correct aspect ratio + float factorX = _owner.Width / (float)_sourceWidth; + float factorY = _owner.Height / (float)_sourceHeight; + + if (factorX > factorY) + { + _quartzVideo.Width = (int)(_sourceWidth * factorY); + _quartzVideo.Height = (int)(_sourceHeight * factorY); + } + else + { + _quartzVideo.Width = (int)(_sourceWidth * factorX); + _quartzVideo.Height = (int)(_sourceHeight * factorX); + } + + _quartzVideo.Left = (_owner.Width - _quartzVideo.Width) / 2; + _quartzVideo.Top = (_owner.Height - _quartzVideo.Height) / 2; + } + catch + { + // ignored + } + } + + public override void DisposeVideoPlayer() + { + System.Threading.ThreadPool.QueueUserWorkItem(DisposeQuarts, _quartzFilgraphManager); + } + + private void DisposeQuarts(object player) + { + Dispose(); + } + + private void ReleaseUnmanagedResources() + { + try + { + if (_quartzVideo != null) + { + _quartzVideo.Owner = -1; + } + } + catch + { + // ignored + } + + if (_quartzFilgraphManager != null) + { + try + { + _quartzFilgraphManager.Stop(); + Marshal.ReleaseComObject(_quartzFilgraphManager); + _quartzFilgraphManager = null; + } + catch + { + // ignored + } + } + _quartzVideo = null; + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + if (_videoEndTimer != null) + { + _videoEndTimer.Dispose(); + _videoEndTimer = null; + } + if (_videoLoader != null) + { + _videoLoader.Dispose(); + _videoLoader = null; + } + } + ReleaseUnmanagedResources(); + } + + } +} diff --git a/src/Logic/VideoPlayers/VideoPlayer.cs b/src/ui/Logic/VideoPlayers/VideoPlayer.cs similarity index 97% rename from src/Logic/VideoPlayers/VideoPlayer.cs rename to src/ui/Logic/VideoPlayers/VideoPlayer.cs index 58d370328..3c3946139 100644 --- a/src/Logic/VideoPlayers/VideoPlayer.cs +++ b/src/ui/Logic/VideoPlayers/VideoPlayer.cs @@ -1,32 +1,32 @@ -using System; -using System.Windows.Forms; - -namespace Nikse.SubtitleEdit.Logic.VideoPlayers -{ - public abstract class VideoPlayer - { - public abstract string PlayerName { get; } - public string VideoFileName { get; protected set; } - public abstract int Volume { get; set; } - public abstract double Duration { get; } - public abstract double CurrentPosition { get; set; } - - /// <summary> - /// 1.0 is normal playback speed, 0.5 is half speed, and 2.0 is twice speed. - /// </summary> - public virtual double PlayRate { get; set; } - - public abstract void Play(); - public abstract void Pause(); - public abstract void Stop(); - public abstract bool IsPaused { get; } - public abstract bool IsPlaying { get; } - public abstract void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded); - public abstract void DisposeVideoPlayer(); - public abstract event EventHandler OnVideoLoaded; - public abstract event EventHandler OnVideoEnded; - public virtual void Resize(int width, int height) - { - } - } -} +using System; +using System.Windows.Forms; + +namespace Nikse.SubtitleEdit.Logic.VideoPlayers +{ + public abstract class VideoPlayer + { + public abstract string PlayerName { get; } + public string VideoFileName { get; protected set; } + public abstract int Volume { get; set; } + public abstract double Duration { get; } + public abstract double CurrentPosition { get; set; } + + /// <summary> + /// 1.0 is normal playback speed, 0.5 is half speed, and 2.0 is twice speed. + /// </summary> + public virtual double PlayRate { get; set; } + + public abstract void Play(); + public abstract void Pause(); + public abstract void Stop(); + public abstract bool IsPaused { get; } + public abstract bool IsPlaying { get; } + public abstract void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded); + public abstract void DisposeVideoPlayer(); + public abstract event EventHandler OnVideoLoaded; + public abstract event EventHandler OnVideoEnded; + public virtual void Resize(int width, int height) + { + } + } +} diff --git a/src/Logic/WordSpellChecker.cs b/src/ui/Logic/WordSpellChecker.cs similarity index 97% rename from src/Logic/WordSpellChecker.cs rename to src/ui/Logic/WordSpellChecker.cs index 650587438..17b2771b0 100644 --- a/src/Logic/WordSpellChecker.cs +++ b/src/ui/Logic/WordSpellChecker.cs @@ -1,146 +1,146 @@ -using Nikse.SubtitleEdit.Forms; -using System; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows.Forms; - -namespace Nikse.SubtitleEdit.Logic -{ - /// <summary> - /// Microsoft Word methods (late bound) for spell checking by Nikse - /// Mostly a bunch of hacks... - /// </summary> - internal class WordSpellChecker - { - private const int HWND_BOTTOM = 1; - - private const int SWP_NOACTIVATE = 0x0010; - private const short SWP_NOMOVE = 0X2; - private const short SWP_NOSIZE = 1; - private const short SWP_NOZORDER = 0X4; - private const int SWP_SHOWWINDOW = 0x0040; - - private const int wdWindowStateNormal = 0; - private const int wdWindowStateMaximize = 1; - private const int wdWindowStateMinimize = 2; - - private object _wordApplication; - private object _wordDocument; - private readonly Type _wordApplicationType; - private Type _wordDocumentType; - private readonly IntPtr _mainHandle; - private int _languageId = 1033; // English - - public WordSpellChecker(Main main, string languageId) - { - _mainHandle = main.Handle; - SetLanguageId(languageId); - - _wordApplicationType = Type.GetTypeFromProgID("Word.Application"); - _wordApplication = Activator.CreateInstance(_wordApplicationType); - - Application.DoEvents(); - _wordApplicationType.InvokeMember("WindowState", BindingFlags.SetProperty, null, _wordApplication, new object[] { wdWindowStateNormal }); - _wordApplicationType.InvokeMember("Top", BindingFlags.SetProperty, null, _wordApplication, new object[] { -5000 }); // hide window - it's a hack - Application.DoEvents(); - } - - private void SetLanguageId(string languageId) - { - try - { - var ci = System.Globalization.CultureInfo.GetCultureInfo(languageId); - _languageId = ci.LCID; - } - catch - { - _languageId = System.Globalization.CultureInfo.CurrentUICulture.LCID; - } - } - - public void NewDocument() - { - _wordDocumentType = Type.GetTypeFromProgID("Word.Document"); - _wordDocument = Activator.CreateInstance(_wordDocumentType); - } - - public void CloseDocument() - { - object saveChanges = false; - object p = Missing.Value; - _wordDocumentType.InvokeMember("Close", BindingFlags.InvokeMethod, null, _wordDocument, new object[] { saveChanges, p, p }); - } - - public string Version - { - get - { - object wordVersion = _wordApplicationType.InvokeMember("Version", BindingFlags.GetProperty, null, _wordApplication, null); - return wordVersion.ToString(); - } - } - - public void Quit() - { - object saveChanges = false; - object originalFormat = Missing.Value; - object routeDocument = Missing.Value; - _wordApplicationType.InvokeMember("Quit", BindingFlags.InvokeMethod, null, _wordApplication, new object[] { saveChanges, originalFormat, routeDocument }); - try - { - Marshal.ReleaseComObject(_wordDocument); - Marshal.ReleaseComObject(_wordApplication); - } - finally - { - _wordDocument = null; - _wordApplication = null; - } - } - - public string CheckSpelling(string text, out int errorsBefore, out int errorsAfter) - { - // insert text - object words = _wordDocumentType.InvokeMember("Words", BindingFlags.GetProperty, null, _wordDocument, null); - object range = words.GetType().InvokeMember("First", BindingFlags.GetProperty, null, words, null); - range.GetType().InvokeMember("InsertBefore", BindingFlags.InvokeMethod, null, range, new Object[] { text }); - - // set language... - range.GetType().InvokeMember("LanguageId", BindingFlags.SetProperty, null, range, new object[] { _languageId }); - - // spell check error count - object spellingErrors = _wordDocumentType.InvokeMember("SpellingErrors", BindingFlags.GetProperty, null, _wordDocument, null); - object spellingErrorsCount = spellingErrors.GetType().InvokeMember("Count", BindingFlags.GetProperty, null, spellingErrors, null); - errorsBefore = int.Parse(spellingErrorsCount.ToString()); - Marshal.ReleaseComObject(spellingErrors); - - // perform spell check - object p = Missing.Value; - if (errorsBefore > 0) - { - _wordApplicationType.InvokeMember("WindowState", BindingFlags.SetProperty, null, _wordApplication, new object[] { wdWindowStateNormal }); - _wordApplicationType.InvokeMember("Top", BindingFlags.SetProperty, null, _wordApplication, new object[] { -10000 }); // hide window - it's a hack - NativeMethods.SetWindowPos(_mainHandle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // make sure c# form is behind spell check dialog - _wordDocumentType.InvokeMember("CheckSpelling", BindingFlags.InvokeMethod, null, _wordDocument, new Object[] { p, p, p, p, p, p, p, p, p, p, p, p }); // 12 parameters - NativeMethods.SetWindowPos(_mainHandle, 0, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // bring c# form to front again - _wordApplicationType.InvokeMember("Top", BindingFlags.SetProperty, null, _wordApplication, new object[] { -10000 }); // hide window - it's a hack - } - - // spell check error count - spellingErrors = _wordDocumentType.InvokeMember("SpellingErrors", BindingFlags.GetProperty, null, _wordDocument, null); - spellingErrorsCount = spellingErrors.GetType().InvokeMember("Count", BindingFlags.GetProperty, null, spellingErrors, null); - errorsAfter = int.Parse(spellingErrorsCount.ToString()); - Marshal.ReleaseComObject(spellingErrors); - - // Get spell check text - object resultText = range.GetType().InvokeMember("Text", BindingFlags.GetProperty, null, range, null); - range.GetType().InvokeMember("Delete", BindingFlags.InvokeMethod, null, range, null); - - Marshal.ReleaseComObject(words); - Marshal.ReleaseComObject(range); - - return resultText.ToString().TrimEnd(); // result needs a trimming at the end - } - - } -} +using Nikse.SubtitleEdit.Forms; +using System; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Windows.Forms; + +namespace Nikse.SubtitleEdit.Logic +{ + /// <summary> + /// Microsoft Word methods (late bound) for spell checking by Nikse + /// Mostly a bunch of hacks... + /// </summary> + internal class WordSpellChecker + { + private const int HWND_BOTTOM = 1; + + private const int SWP_NOACTIVATE = 0x0010; + private const short SWP_NOMOVE = 0X2; + private const short SWP_NOSIZE = 1; + private const short SWP_NOZORDER = 0X4; + private const int SWP_SHOWWINDOW = 0x0040; + + private const int wdWindowStateNormal = 0; + private const int wdWindowStateMaximize = 1; + private const int wdWindowStateMinimize = 2; + + private object _wordApplication; + private object _wordDocument; + private readonly Type _wordApplicationType; + private Type _wordDocumentType; + private readonly IntPtr _mainHandle; + private int _languageId = 1033; // English + + public WordSpellChecker(Main main, string languageId) + { + _mainHandle = main.Handle; + SetLanguageId(languageId); + + _wordApplicationType = Type.GetTypeFromProgID("Word.Application"); + _wordApplication = Activator.CreateInstance(_wordApplicationType); + + Application.DoEvents(); + _wordApplicationType.InvokeMember("WindowState", BindingFlags.SetProperty, null, _wordApplication, new object[] { wdWindowStateNormal }); + _wordApplicationType.InvokeMember("Top", BindingFlags.SetProperty, null, _wordApplication, new object[] { -5000 }); // hide window - it's a hack + Application.DoEvents(); + } + + private void SetLanguageId(string languageId) + { + try + { + var ci = System.Globalization.CultureInfo.GetCultureInfo(languageId); + _languageId = ci.LCID; + } + catch + { + _languageId = System.Globalization.CultureInfo.CurrentUICulture.LCID; + } + } + + public void NewDocument() + { + _wordDocumentType = Type.GetTypeFromProgID("Word.Document"); + _wordDocument = Activator.CreateInstance(_wordDocumentType); + } + + public void CloseDocument() + { + object saveChanges = false; + object p = Missing.Value; + _wordDocumentType.InvokeMember("Close", BindingFlags.InvokeMethod, null, _wordDocument, new object[] { saveChanges, p, p }); + } + + public string Version + { + get + { + object wordVersion = _wordApplicationType.InvokeMember("Version", BindingFlags.GetProperty, null, _wordApplication, null); + return wordVersion.ToString(); + } + } + + public void Quit() + { + object saveChanges = false; + object originalFormat = Missing.Value; + object routeDocument = Missing.Value; + _wordApplicationType.InvokeMember("Quit", BindingFlags.InvokeMethod, null, _wordApplication, new object[] { saveChanges, originalFormat, routeDocument }); + try + { + Marshal.ReleaseComObject(_wordDocument); + Marshal.ReleaseComObject(_wordApplication); + } + finally + { + _wordDocument = null; + _wordApplication = null; + } + } + + public string CheckSpelling(string text, out int errorsBefore, out int errorsAfter) + { + // insert text + object words = _wordDocumentType.InvokeMember("Words", BindingFlags.GetProperty, null, _wordDocument, null); + object range = words.GetType().InvokeMember("First", BindingFlags.GetProperty, null, words, null); + range.GetType().InvokeMember("InsertBefore", BindingFlags.InvokeMethod, null, range, new Object[] { text }); + + // set language... + range.GetType().InvokeMember("LanguageId", BindingFlags.SetProperty, null, range, new object[] { _languageId }); + + // spell check error count + object spellingErrors = _wordDocumentType.InvokeMember("SpellingErrors", BindingFlags.GetProperty, null, _wordDocument, null); + object spellingErrorsCount = spellingErrors.GetType().InvokeMember("Count", BindingFlags.GetProperty, null, spellingErrors, null); + errorsBefore = int.Parse(spellingErrorsCount.ToString()); + Marshal.ReleaseComObject(spellingErrors); + + // perform spell check + object p = Missing.Value; + if (errorsBefore > 0) + { + _wordApplicationType.InvokeMember("WindowState", BindingFlags.SetProperty, null, _wordApplication, new object[] { wdWindowStateNormal }); + _wordApplicationType.InvokeMember("Top", BindingFlags.SetProperty, null, _wordApplication, new object[] { -10000 }); // hide window - it's a hack + NativeMethods.SetWindowPos(_mainHandle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // make sure c# form is behind spell check dialog + _wordDocumentType.InvokeMember("CheckSpelling", BindingFlags.InvokeMethod, null, _wordDocument, new Object[] { p, p, p, p, p, p, p, p, p, p, p, p }); // 12 parameters + NativeMethods.SetWindowPos(_mainHandle, 0, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // bring c# form to front again + _wordApplicationType.InvokeMember("Top", BindingFlags.SetProperty, null, _wordApplication, new object[] { -10000 }); // hide window - it's a hack + } + + // spell check error count + spellingErrors = _wordDocumentType.InvokeMember("SpellingErrors", BindingFlags.GetProperty, null, _wordDocument, null); + spellingErrorsCount = spellingErrors.GetType().InvokeMember("Count", BindingFlags.GetProperty, null, spellingErrors, null); + errorsAfter = int.Parse(spellingErrorsCount.ToString()); + Marshal.ReleaseComObject(spellingErrors); + + // Get spell check text + object resultText = range.GetType().InvokeMember("Text", BindingFlags.GetProperty, null, range, null); + range.GetType().InvokeMember("Delete", BindingFlags.InvokeMethod, null, range, null); + + Marshal.ReleaseComObject(words); + Marshal.ReleaseComObject(range); + + return resultText.ToString().TrimEnd(); // result needs a trimming at the end + } + + } +} diff --git a/src/Program.cs b/src/ui/Program.cs similarity index 97% rename from src/Program.cs rename to src/ui/Program.cs index 9451bfabb..501cc7684 100644 --- a/src/Program.cs +++ b/src/ui/Program.cs @@ -1,115 +1,115 @@ -using Nikse.SubtitleEdit.Forms; -using System; -using System.Diagnostics; -using System.Threading; -using System.Windows.Forms; - -namespace Nikse.SubtitleEdit -{ - internal static class Program - { - /// <summary> - /// The main entry point for the application. - /// </summary> - [STAThread] - private static void Main() - { -#if !DEBUG - // Add the event handler for handling UI thread exceptions to the event. - Application.ThreadException += Application_ThreadException; - - // Set the unhandled exception mode to force all Windows Forms errors to go through our handler. - Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); - - // Add the event handler for handling non-UI thread exceptions to the event. - AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; -#endif - - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Main()); - } - - // Handle the UI exceptions by showing a dialog box, and asking the user whether or not they wish to abort execution. - private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) - { - var exc = e.Exception; - // Ignore CultureNotFoundException to avoid error when changing language (on some computers) - see https://github.com/SubtitleEdit/subtitleedit/issues/719 - if (!(exc is System.Globalization.CultureNotFoundException)) - { - var dr = DialogResult.Abort; - try - { - var cap = "Windows Forms Thread Exception"; - var msg = "An application error occurred in Subtitle Edit " + GetVersion() + ". " + - "\nPlease report at https://github.com/SubtitleEdit/subtitleedit/issues with the following information:" + - "\n\nError Message:\n" + exc.Message + - "\n\nStack Trace:\n" + exc.StackTrace; - dr = MessageBox.Show(msg, cap, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1); - } - catch - { - } - if (dr == DialogResult.Abort) - { - Application.Exit(); - } - } - } - - private static string GetVersion() - { - try - { - return System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(); - } - catch - { - return string.Empty; - } - } - - // Handle the non-UI exceptions by logging the event to the ThreadException event log before - // the system default handler reports the exception to the user and terminates the application. - // NOTE: This exception handler cannot prevent the termination of the application. - private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) - { - try - { - var exc = e.ExceptionObject as Exception; - var msg = "A fatal non-UI error occurred in Subtitle Edit " + GetVersion() + "." + - "\nPlease report at https://github.com/SubtitleEdit/subtitleedit/issues with the following information:" + - "\n\nError Message:\n" + exc.Message + - "\n\nStack Trace:\n" + exc.StackTrace; - - // Since we can't prevent the app from terminating, log this to the event log. - if (!EventLog.SourceExists("ThreadException")) - { - EventLog.CreateEventSource("ThreadException", "Application"); - } - - // Create an EventLog instance and assign its source. - using (var eventLog = new EventLog { Source = "ThreadException" }) - { - eventLog.WriteEntry(msg); - } - } - catch (Exception ex) - { - try - { - var cap = "Non-UI Thread Exception"; - var msg = "A fatal non-UI error occurred in Subtitle Edit " + GetVersion() + "." + - "\nCould not write the error to the event log." + - "\nReason: " + ex.Message; - MessageBox.Show(msg, cap, MessageBoxButtons.OK, MessageBoxIcon.Stop); - } - finally - { - Application.Exit(); - } - } - } - - } -} +using Nikse.SubtitleEdit.Forms; +using System; +using System.Diagnostics; +using System.Threading; +using System.Windows.Forms; + +namespace Nikse.SubtitleEdit +{ + internal static class Program + { + /// <summary> + /// The main entry point for the application. + /// </summary> + [STAThread] + private static void Main() + { +#if !DEBUG + // Add the event handler for handling UI thread exceptions to the event. + Application.ThreadException += Application_ThreadException; + + // Set the unhandled exception mode to force all Windows Forms errors to go through our handler. + Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); + + // Add the event handler for handling non-UI thread exceptions to the event. + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; +#endif + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Main()); + } + + // Handle the UI exceptions by showing a dialog box, and asking the user whether or not they wish to abort execution. + private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) + { + var exc = e.Exception; + // Ignore CultureNotFoundException to avoid error when changing language (on some computers) - see https://github.com/SubtitleEdit/subtitleedit/issues/719 + if (!(exc is System.Globalization.CultureNotFoundException)) + { + var dr = DialogResult.Abort; + try + { + var cap = "Windows Forms Thread Exception"; + var msg = "An application error occurred in Subtitle Edit " + GetVersion() + ". " + + "\nPlease report at https://github.com/SubtitleEdit/subtitleedit/issues with the following information:" + + "\n\nError Message:\n" + exc.Message + + "\n\nStack Trace:\n" + exc.StackTrace; + dr = MessageBox.Show(msg, cap, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1); + } + catch + { + } + if (dr == DialogResult.Abort) + { + Application.Exit(); + } + } + } + + private static string GetVersion() + { + try + { + return System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(); + } + catch + { + return string.Empty; + } + } + + // Handle the non-UI exceptions by logging the event to the ThreadException event log before + // the system default handler reports the exception to the user and terminates the application. + // NOTE: This exception handler cannot prevent the termination of the application. + private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + try + { + var exc = e.ExceptionObject as Exception; + var msg = "A fatal non-UI error occurred in Subtitle Edit " + GetVersion() + "." + + "\nPlease report at https://github.com/SubtitleEdit/subtitleedit/issues with the following information:" + + "\n\nError Message:\n" + exc.Message + + "\n\nStack Trace:\n" + exc.StackTrace; + + // Since we can't prevent the app from terminating, log this to the event log. + if (!EventLog.SourceExists("ThreadException")) + { + EventLog.CreateEventSource("ThreadException", "Application"); + } + + // Create an EventLog instance and assign its source. + using (var eventLog = new EventLog { Source = "ThreadException" }) + { + eventLog.WriteEntry(msg); + } + } + catch (Exception ex) + { + try + { + var cap = "Non-UI Thread Exception"; + var msg = "A fatal non-UI error occurred in Subtitle Edit " + GetVersion() + "." + + "\nCould not write the error to the event log." + + "\nReason: " + ex.Message; + MessageBox.Show(msg, cap, MessageBoxButtons.OK, MessageBoxIcon.Stop); + } + finally + { + Application.Exit(); + } + } + } + + } +} diff --git a/src/ui/Properties/AssemblyInfo.cs b/src/ui/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..968f46738 --- /dev/null +++ b/src/ui/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Subtitle Edit")] +[assembly: AssemblyDescription("bc78b4e0e81bcd902c9ef942194599a51c4e2286")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Nikse")] +[assembly: AssemblyProduct("SubtitleEdit")] +[assembly: AssemblyCopyright("Copyright 2001-2020, Nikse")] +[assembly: AssemblyTrademark("Licensed under the GPL v3")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8cb5792f-cd36-4dfb-b2fd-161e44be216d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("3.5.18.95")] + +// Make the internal types available in our testing assembly. +[assembly: InternalsVisibleTo("Test")] \ No newline at end of file diff --git a/src/Properties/AssemblyInfo.cs.template b/src/ui/Properties/AssemblyInfo.cs.template similarity index 97% rename from src/Properties/AssemblyInfo.cs.template rename to src/ui/Properties/AssemblyInfo.cs.template index ae6e4a951..8e67d9757 100644 --- a/src/Properties/AssemblyInfo.cs.template +++ b/src/ui/Properties/AssemblyInfo.cs.template @@ -1,37 +1,37 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Subtitle Edit")] -[assembly: AssemblyDescription("[GITHASH]")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Nikse")] -[assembly: AssemblyProduct("SubtitleEdit")] -[assembly: AssemblyCopyright("Copyright 2001-2020, Nikse")] -[assembly: AssemblyTrademark("Licensed under the GPL v3")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("8cb5792f-cd36-4dfb-b2fd-161e44be216d")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("3.5.18.[REVNO]")] - -// Make the internal types available in our testing assembly. +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Subtitle Edit")] +[assembly: AssemblyDescription("[GITHASH]")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Nikse")] +[assembly: AssemblyProduct("SubtitleEdit")] +[assembly: AssemblyCopyright("Copyright 2001-2020, Nikse")] +[assembly: AssemblyTrademark("Licensed under the GPL v3")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8cb5792f-cd36-4dfb-b2fd-161e44be216d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("3.5.18.[REVNO]")] + +// Make the internal types available in our testing assembly. [assembly: InternalsVisibleTo("Test")] \ No newline at end of file diff --git a/src/Properties/Resources.Designer.cs b/src/ui/Properties/Resources.Designer.cs similarity index 97% rename from src/Properties/Resources.Designer.cs rename to src/ui/Properties/Resources.Designer.cs index 6c816bca7..cdeeb68ba 100644 --- a/src/Properties/Resources.Designer.cs +++ b/src/ui/Properties/Resources.Designer.cs @@ -1,133 +1,133 @@ -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -namespace Nikse.SubtitleEdit.Properties { - using System; - - - /// <summary> - /// A strongly-typed resource class, for looking up localized strings, etc. - /// </summary> - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// <summary> - /// Returns the cached ResourceManager instance used by this class. - /// </summary> - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Nikse.SubtitleEdit.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// <summary> - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// </summary> - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// <summary> - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// </summary> - public static System.Drawing.Bitmap bookmark22 { - get { - object obj = ResourceManager.GetObject("bookmark22", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// <summary> - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// </summary> - public static System.Drawing.Bitmap connect { - get { - object obj = ResourceManager.GetObject("connect", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// <summary> - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// </summary> - public static System.Drawing.Bitmap Donate { - get { - object obj = ResourceManager.GetObject("Donate", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// <summary> - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// </summary> - public static System.Drawing.Bitmap Help { - get { - object obj = ResourceManager.GetObject("Help", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// <summary> - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// </summary> - public static System.Drawing.Bitmap Settings { - get { - object obj = ResourceManager.GetObject("Settings", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// <summary> - /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). - /// </summary> - public static System.Drawing.Icon SubtitleEditFormIcon { - get { - object obj = ResourceManager.GetObject("SubtitleEditFormIcon", resourceCulture); - return ((System.Drawing.Icon)(obj)); - } - } - - /// <summary> - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// </summary> - public static System.Drawing.Bitmap TransparentBackground { - get { - object obj = ResourceManager.GetObject("TransparentBackground", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - } -} +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace Nikse.SubtitleEdit.Properties { + using System; + + + /// <summary> + /// A strongly-typed resource class, for looking up localized strings, etc. + /// </summary> + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// <summary> + /// Returns the cached ResourceManager instance used by this class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Nikse.SubtitleEdit.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// <summary> + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// <summary> + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// </summary> + public static System.Drawing.Bitmap bookmark22 { + get { + object obj = ResourceManager.GetObject("bookmark22", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// <summary> + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// </summary> + public static System.Drawing.Bitmap connect { + get { + object obj = ResourceManager.GetObject("connect", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// <summary> + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// </summary> + public static System.Drawing.Bitmap Donate { + get { + object obj = ResourceManager.GetObject("Donate", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// <summary> + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// </summary> + public static System.Drawing.Bitmap Help { + get { + object obj = ResourceManager.GetObject("Help", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// <summary> + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// </summary> + public static System.Drawing.Bitmap Settings { + get { + object obj = ResourceManager.GetObject("Settings", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// <summary> + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// </summary> + public static System.Drawing.Icon SubtitleEditFormIcon { + get { + object obj = ResourceManager.GetObject("SubtitleEditFormIcon", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// <summary> + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// </summary> + public static System.Drawing.Bitmap TransparentBackground { + get { + object obj = ResourceManager.GetObject("TransparentBackground", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/src/Properties/Resources.resx b/src/ui/Properties/Resources.resx similarity index 98% rename from src/Properties/Resources.resx rename to src/ui/Properties/Resources.resx index 6d7ee4a60..627480b2c 100644 --- a/src/Properties/Resources.resx +++ b/src/ui/Properties/Resources.resx @@ -1,142 +1,142 @@ -<?xml version="1.0" encoding="utf-8"?> -<root> - <!-- - Microsoft ResX Schema - - Version 2.0 - - The primary goals of this format is to allow a simple XML format - that is mostly human readable. The generation and parsing of the - various data types are done through the TypeConverter classes - associated with the data types. - - Example: - - ... ado.net/XML headers & schema ... - <resheader name="resmimetype">text/microsoft-resx</resheader> - <resheader name="version">2.0</resheader> - <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> - <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> - <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> - <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> - <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> - <value>[base64 mime encoded serialized .NET Framework object]</value> - </data> - <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> - <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> - <comment>This is a comment</comment> - </data> - - There are any number of "resheader" rows that contain simple - name/value pairs. - - Each data row contains a name, and value. The row also contains a - type or mimetype. Type corresponds to a .NET class that support - text/value conversion through the TypeConverter architecture. - Classes that don't support this are serialized and stored with the - mimetype set. - - The mimetype is used for serialized objects, and tells the - ResXResourceReader how to depersist the object. This is currently not - extensible. For a given mimetype the value must be set accordingly: - - Note - application/x-microsoft.net.object.binary.base64 is the format - that the ResXResourceWriter will generate, however the reader can - read any of the formats listed below. - - mimetype: application/x-microsoft.net.object.binary.base64 - value : The object must be serialized with - : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter - : and then encoded with base64 encoding. - - mimetype: application/x-microsoft.net.object.soap.base64 - value : The object must be serialized with - : System.Runtime.Serialization.Formatters.Soap.SoapFormatter - : and then encoded with base64 encoding. - - mimetype: application/x-microsoft.net.object.bytearray.base64 - value : The object must be serialized into a byte array - : using a System.ComponentModel.TypeConverter - : and then encoded with base64 encoding. - --> - <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> - <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> - <xsd:element name="root" msdata:IsDataSet="true"> - <xsd:complexType> - <xsd:choice maxOccurs="unbounded"> - <xsd:element name="metadata"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="value" type="xsd:string" minOccurs="0" /> - </xsd:sequence> - <xsd:attribute name="name" use="required" type="xsd:string" /> - <xsd:attribute name="type" type="xsd:string" /> - <xsd:attribute name="mimetype" type="xsd:string" /> - <xsd:attribute ref="xml:space" /> - </xsd:complexType> - </xsd:element> - <xsd:element name="assembly"> - <xsd:complexType> - <xsd:attribute name="alias" type="xsd:string" /> - <xsd:attribute name="name" type="xsd:string" /> - </xsd:complexType> - </xsd:element> - <xsd:element name="data"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> - <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> - <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> - <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> - <xsd:attribute ref="xml:space" /> - </xsd:complexType> - </xsd:element> - <xsd:element name="resheader"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string" use="required" /> - </xsd:complexType> - </xsd:element> - </xsd:choice> - </xsd:complexType> - </xsd:element> - </xsd:schema> - <resheader name="resmimetype"> - <value>text/microsoft-resx</value> - </resheader> - <resheader name="version"> - <value>2.0</value> - </resheader> - <resheader name="reader"> - <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </resheader> - <resheader name="writer"> - <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </resheader> - <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> - <data name="connect" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Icons\connect.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> - </data> - <data name="bookmark22" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Resources\bookmark22.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> - </data> - <data name="SubtitleEditFormIcon" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Icons\SE.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> - </data> - <data name="TransparentBackground" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Resources\Transparent Background.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> - </data> - <data name="Help" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Icons\Help.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> - </data> - <data name="Donate" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Icons\Donate.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> - </data> - <data name="Settings" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Icons\Settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> - </data> +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <data name="connect" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Icons\connect.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> + <data name="bookmark22" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\bookmark22.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> + <data name="SubtitleEditFormIcon" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Icons\SE.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> + <data name="TransparentBackground" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\Transparent Background.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> + <data name="Help" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Icons\Help.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> + <data name="Donate" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Icons\Donate.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> + <data name="Settings" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Icons\Settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> </root> \ No newline at end of file diff --git a/src/Properties/Settings.Designer.cs b/src/ui/Properties/Settings.Designer.cs similarity index 97% rename from src/Properties/Settings.Designer.cs rename to src/ui/Properties/Settings.Designer.cs index cd2462f49..9b8fa81d0 100644 --- a/src/Properties/Settings.Designer.cs +++ b/src/ui/Properties/Settings.Designer.cs @@ -1,36 +1,36 @@ -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -namespace Nikse.SubtitleEdit.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)] - [global::System.Configuration.DefaultSettingValueAttribute("http://localhost:2782/se/SeService.asmx")] - public string SubtitleEdit_SeNetworkService_SeService { - get { - return ((string)(this["SubtitleEdit_SeNetworkService_SeService"])); - } - } - } -} +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace Nikse.SubtitleEdit.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)] + [global::System.Configuration.DefaultSettingValueAttribute("http://localhost:2782/se/SeService.asmx")] + public string SubtitleEdit_SeNetworkService_SeService { + get { + return ((string)(this["SubtitleEdit_SeNetworkService_SeService"])); + } + } + } +} diff --git a/src/Properties/Settings.settings b/src/ui/Properties/Settings.settings similarity index 98% rename from src/Properties/Settings.settings rename to src/ui/Properties/Settings.settings index 6ebed85b9..a415e6e6f 100644 --- a/src/Properties/Settings.settings +++ b/src/ui/Properties/Settings.settings @@ -1,9 +1,9 @@ -<?xml version='1.0' encoding='utf-8'?> -<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Nikse.SubtitleEdit.Properties" GeneratedClassName="Settings"> - <Profiles /> - <Settings> - <Setting Name="SubtitleEdit_SeNetworkService_SeService" Type="(Web Service URL)" Scope="Application"> - <Value Profile="(Default)">http://localhost:2782/se/SeService.asmx</Value> - </Setting> - </Settings> +<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Nikse.SubtitleEdit.Properties" GeneratedClassName="Settings"> + <Profiles /> + <Settings> + <Setting Name="SubtitleEdit_SeNetworkService_SeService" Type="(Web Service URL)" Scope="Application"> + <Value Profile="(Default)">http://localhost:2782/se/SeService.asmx</Value> + </Setting> + </Settings> </SettingsFile> \ No newline at end of file diff --git a/src/Resources/HunspellBackupDictionaries.xml b/src/ui/Resources/HunspellBackupDictionaries.xml similarity index 100% rename from src/Resources/HunspellBackupDictionaries.xml rename to src/ui/Resources/HunspellBackupDictionaries.xml diff --git a/src/Resources/HunspellBackupDictionaries.xml.gz b/src/ui/Resources/HunspellBackupDictionaries.xml.gz similarity index 100% rename from src/Resources/HunspellBackupDictionaries.xml.gz rename to src/ui/Resources/HunspellBackupDictionaries.xml.gz diff --git a/src/Resources/HunspellDictionaries.xml b/src/ui/Resources/HunspellDictionaries.xml similarity index 98% rename from src/Resources/HunspellDictionaries.xml rename to src/ui/Resources/HunspellDictionaries.xml index 119ee0743..5d88ee3a2 100644 --- a/src/Resources/HunspellDictionaries.xml +++ b/src/ui/Resources/HunspellDictionaries.xml @@ -1,374 +1,374 @@ -<OpenOfficeDictionaries> - <Dictionary> - <EnglishName>Afrikaans</EnglishName> - <NativeName>Afrikaans</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1109/0/dict-af.oxt?r=http%3A%2F%2Fextensions.services.openoffice.org%2Fen%2Fproject%2Fafrikaans-spell-checker&amp;ts=1373917891&amp;use_mirror=kent</DownloadLink> - <Description>Afrikaans spell checker</Description> - </Dictionary> - <Dictionary> - <EnglishName>Albanian</EnglishName> - <NativeName>Shqip</NativeName> - <DownloadLink>https://sourceforge.net/projects/aoo-extensions/files/3393/1/dict-sq.oxt/download</DownloadLink> - <Description>Albanian Spell Checker Dictionary</Description> - </Dictionary> - <Dictionary> - <EnglishName>Arabic</EnglishName> - <NativeName>عربي</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-ar-3-2.oxt</DownloadLink> - <Description>Arabic spell checker 3.2</Description> - </Dictionary> - <Dictionary> - <EnglishName>Basque</EnglishName> - <NativeName>Euskara</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1383/2/xuxen_4_ooo3.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fxuxen-basque-spell-checking-dictionary-40&amp;ts=1435689769&amp;use_mirror=garr</DownloadLink> - <Description>Xuxen: Basque spell checking dictionary - v4.0</Description> - </Dictionary> - <Dictionary> - <EnglishName>Belarusian</EnglishName> - <NativeName>Беларуская мова</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/4611/15/dict-be-0.56.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fbelarusian-spell-checking-dictionary-recent-official-orthography&amp;ts=1373918638&amp;use_mirror=kent</DownloadLink> - <Description>Belarusian dictionary(spelling, hyphenation) - classic orthography</Description> - </Dictionary> - <Dictionary> - <EnglishName>Bosnian</EnglishName> - <NativeName>Bosanski</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-bs.oxt</DownloadLink> - <Description>Spellchecking dictionary for Bosnian language - 1.0 (Jan 24, 2013)</Description> - </Dictionary> - <Dictionary> - <EnglishName>Breton</EnglishName> - <NativeName>Brezhoneg</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-br-0-8.oxt</DownloadLink> - <Description>An Drouizig Breton Spell Checker</Description> - </Dictionary> - <Dictionary> - <EnglishName>Bulgarian</EnglishName> - <NativeName>Български</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/744/8/dictionaries-bg.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fbulgarian-dictionaries-blgarski-rechnici&amp;ts=1435654358&amp;use_mirror=freefr</DownloadLink> - <Description>Bulgarian Dictionaries (български речници) v4.3.2 (22/09/2010)</Description> - </Dictionary> - <Dictionary> - <EnglishName>Catalan</EnglishName> - <NativeName>català</NativeName> - <DownloadLink>https://github.com/Softcatala/catalan-dict-tools/releases/download/v3.0.1/ca-valencia.3.0.1.oxt</DownloadLink> - <Description>Catalan spellchecking dictionaries, July 2015</Description> - </Dictionary> - <Dictionary> - <EnglishName>Catalan</EnglishName> - <NativeName>català-valencià</NativeName> - <DownloadLink>http://softcatala.org/diccionaris/actualitzacions/OOo/avl.oxt</DownloadLink> - <Description>Spelling dictionary for Catalan (Valencian version)</Description> - </Dictionary> - <Dictionary> - <EnglishName>Croatian</EnglishName> - <NativeName>Hrvatski</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1052/2/dict-hr.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fcroatian-dictionary-and-hyphenation-patterns&amp;ts=1373918817&amp;use_mirror=surfnet</DownloadLink> - <Description>Croatian dictionary and hyphenation patterns</Description> - </Dictionary> - <Dictionary> - <EnglishName>Czech</EnglishName> - <NativeName>Čeština</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1078/0/dict-cs-2.0.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fczech-dictionary-pack-%25C4%258Desk%25C3%25A9-slovn%25C3%25ADky&amp;ts=1373918869&amp;use_mirror=freefr</DownloadLink> - <Description>Czech dictionary pack / České slovníky</Description> - </Dictionary> - <Dictionary> - <EnglishName>Danish</EnglishName> - <NativeName>Dansk</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-da-2-4.oxt</DownloadLink> - <Description>Stavekontrolden version 2.2 - 2014-12-22</Description> - </Dictionary> - <Dictionary> - <EnglishName>Dutch</EnglishName> - <NativeName>Nederlands</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1456/6/nl-dict-v2.00g.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fdutch-spelling-and-hyphenation-dictionary&amp;ts=1373918951&amp;use_mirror=garr</DownloadLink> - <Description>Dutch spelling and hyphenation Dictionary</Description> - </Dictionary> - <Dictionary> - <EnglishName>English</EnglishName> - <NativeName></NativeName> - <DownloadLink>https://github.com/marcoagpinto/aoo-mozilla-en-dict/archive/master.zip</DownloadLink> - <Description>All English dictionaries (AU, CA, GB, US, ZA), 2018-04-16+</Description> - </Dictionary> - <Dictionary> - <EnglishName>Estonian</EnglishName> - <NativeName></NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1328/0/dict-et.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Festonian-spellchecking-and-hyphenation&amp;ts=1435689988&amp;use_mirror=freefr</DownloadLink> - <Description>Estonian spellchecking and hyphenation (13 October, 2008)</Description> - </Dictionary> - <Dictionary> - <EnglishName>Farsi (Persian)</EnglishName> - <NativeName>Persian/Farsi</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/2359/1/dict-fa.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fpersian-spellchecker-dictionary-20090707&amp;ts=1435690384&amp;use_mirror=freefr</DownloadLink> - <Description>Persian Spellchecker Dictionary - 2009.07.07</Description> - </Dictionary> - <Dictionary> - <EnglishName>French</EnglishName> - <NativeName>Français</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/lo-oo-ressources-linguistiques-fr-v5-7.oxt</DownloadLink> - <Description>Dictionnaires francais 5.3 (28/02/2015)</Description> - </Dictionary> - <Dictionary> - <EnglishName>German (Austria)</EnglishName> - <NativeName>Deutsch (Österreich)</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-de-at-frami-2017-01-12.oxt</DownloadLink> - <Description>German (de-AT frami) dictionaries 2013.12.06 (08/12/2013)</Description> - </Dictionary> - <Dictionary> - <EnglishName>German (Germany)</EnglishName> - <NativeName>German (de-DE frami) dictionaries - [de] Deutsche (de-DE frami) Rechtschreibung</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-de-de-frami-2017-01-12.oxt</DownloadLink> - <Description>German (de-DE igerman98) dictionaries</Description> - </Dictionary> - <Dictionary> - <EnglishName>Greek</EnglishName> - <NativeName>Ελληνικά</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1411/2/el_gr_v110.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fhellenic-greek-dictionary-spell-check-and-hyphenation-110&amp;ts=1435654652&amp;use_mirror=freefr</DownloadLink> - <Description>Hellenic (Greek) Dictionary (Spell Check and Hyphenation) - v1.1.0</Description> - </Dictionary> - <Dictionary> - <EnglishName>Hebrew</EnglishName> - <NativeName>Hebrew (he) spell check dictionary 2012-08-15</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-he-2012-08-15.oxt</DownloadLink> - <Description>Hebrew (he) spell check dictionary (Aug 15, 2012)</Description> - </Dictionary> - <Dictionary> - <EnglishName>Hindi</EnglishName> - <NativeName>हिंदी</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/2367/1/dict-hi.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fhindi-spellchecker-dictionary&amp;ts=1435678775&amp;use_mirror=garr</DownloadLink> - <Description>Hindi Spellchecker Dictionary</Description> - </Dictionary> - <Dictionary> - <EnglishName>Hungarian</EnglishName> - <NativeName>Magyar</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1283/9/dict-hu.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fhungarian-dictionary-pack-20101019&amp;ts=1435690641&amp;use_mirror=freefr</DownloadLink> - <Description>Hungarian Dictionary Pack - (2010.10.19)</Description> - </Dictionary> - <Dictionary> - <EnglishName>Icelandic</EnglishName> - <NativeName>íslenska</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/hunspell-is-2014-08-18.oxt</DownloadLink> - <Description>Icelandic spelling dictionary &amp; thesaurus 2013.05.11</Description> - </Dictionary> - <Dictionary> - <EnglishName>Indonesian</EnglishName> - <NativeName>Indonesia</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/id-id.oxt</DownloadLink> - <Description>Indonesian dictionary - Kamus Indonesia 1.0</Description> - </Dictionary> - <Dictionary> - <EnglishName>Irish</EnglishName> - <NativeName>Gaeilge</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/focloiri-gaeilge-5-0.oxt</DownloadLink> - <Description>Irish language spell checker, thesaurus, and hyphenation patterns 4.5</Description> - </Dictionary> - <Dictionary> - <EnglishName>Italian</EnglishName> - <NativeName>Italiano</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/874d181c_dict-it.oxt</DownloadLink> - <Description>Italian and Latin spelling dictionaries 2013.03.31</Description> - </Dictionary> - <Dictionary> - <EnglishName>Italian</EnglishName> - <NativeName>Italiano</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1204/13/dict-it.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fitalian-dictionary-thesaurus-hyphenation-patterns-20130905&amp;ts=1435690929&amp;use_mirror=freefr</DownloadLink> - <Description>Italian dictionary, thesaurus, hyphenation patterns - (2013.09.05)</Description> - </Dictionary> - <Dictionary> - <EnglishName>Khmer</EnglishName> - <NativeName>Khmer</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/5067/2/dict-km.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fkhmer-spelling-dictionary&amp;ts=1373998173&amp;use_mirror=netcologne</DownloadLink> - <Description>Khmer spelling dictionary 2011.05.11</Description> - </Dictionary> - <Dictionary> - <EnglishName>Korean</EnglishName> - <NativeName>한글</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/korean-spell-checker-0-7-91-libo.oxt</DownloadLink> - <Description>Korean spellchecker 0.5.6</Description> - </Dictionary> - <Dictionary> - <EnglishName>Latin</EnglishName> - <NativeName>Latina</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-la-2013-03-31.oxt</DownloadLink> - <Description>Latin spelling and hyphenation dictionaries 2013.03.31</Description> - </Dictionary> - <Dictionary> - <EnglishName>Latvian</EnglishName> - <NativeName>Latviešu</NativeName> - <DownloadLink>http://ftp.nluug.nl/office/openoffice/contrib/dictionaries/hyph_lv_LV.zip</DownloadLink> - <Description>Latviešu valodas pareizrakstības pārbaudes modulis 0.9.6</Description> - </Dictionary> - <Dictionary> - <EnglishName>Lithuanian</EnglishName> - <NativeName>Lietuvių</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/openoffice-spellcheck-lt-1-3.oxt</DownloadLink> - <Description>Lithuanian spellcheck and hyphenation dictionaries 1.3</Description> - </Dictionary> - <Dictionary> - <EnglishName>Lower Sorbian</EnglishName> - <NativeName>dolnoserbšćina</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/lower-sorbian-spelling-dictionary-1-5-0.oxt</DownloadLink> - <Description>Lower Sorbian dictionary 1.4.6</Description> - </Dictionary> - <Dictionary> - <EnglishName>Malay</EnglishName> - <NativeName>Malay</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/3904/0/ms_my.oxt</DownloadLink> - <Description>Malay Spell Checker v0.1 - 07/10/04</Description> - </Dictionary> - <Dictionary> - <EnglishName>Malayalam</EnglishName> - <NativeName>Malayalam</NativeName> - <DownloadLink>https://master.dl.sourceforge.net/project/aoo-extensions/2741/3/ml_in_dict-1-1.oxt</DownloadLink> - <Description>Malayalam Spellchecker 1.1.0</Description> - </Dictionary> - <Dictionary> - <EnglishName>Macedonian</EnglishName> - <NativeName>Macedonian</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/3403/0/dict-mk.oxt</DownloadLink> - <Description>Macedonian dictionary was created by Taras Bendik</Description> - </Dictionary> - <Dictionary> - <EnglishName>Norwegian</EnglishName> - <NativeName>Norsk</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dictionary-no-no-1-0.oxt</DownloadLink> - <Description>Norsk stavekontroll (bokmål og nynorsk) 2.0.10</Description> - </Dictionary> - <Dictionary> - <EnglishName>Polish</EnglishName> - <NativeName>polski</NativeName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/hunspell/pl_PL.zip</DownloadLink> - <Description>Polish by https://sjp.pl - 2020-07-18</Description> - </Dictionary> - <Dictionary> - <EnglishName>Portuguese (Brazilian) - Libreoffice</EnglishName> - <NativeName>Português (do Brasil)</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/veroptbrv320aoc.oxt</DownloadLink> - <Description>Brazilian Portuguese Spelling Dictionary V3.2 - Libreoffice</Description> - </Dictionary> - <Dictionary> - <EnglishName>Portuguese (Brazilian) - Firefox</EnglishName> - <NativeName>Português (do Brasil)</NativeName> - <DownloadLink>https://hg.mozilla.org/releases/l10n/mozilla-aurora/pt-BR/archive/81d9d556fa78.zip/extensions/spellcheck/hunspell/</DownloadLink> - <Description>Brazilian Portuguese Spelling Dictionary 2009 José João de Almeida - Firefox</Description> - </Dictionary> - <Dictionary> - <EnglishName>Portuguese (European Portuguese Dictionary)</EnglishName> - <NativeName>Português</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1196/40/oo3x-pt-pt-16.10.1.2.oxt</DownloadLink> - <Description>Corretores Ortográficos para Português de Portugal</Description> - </Dictionary> - <Dictionary> - <EnglishName>Portuguese (European Portuguese Dictionary - PRE AO90)</EnglishName> - <NativeName>Português</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/17990/9/oo3x-pt-pt-preao-16.10.1.2.oxt</DownloadLink> - <Description>Corretores Ortográficos para Português de Portugal</Description> - </Dictionary> - <Dictionary> - <EnglishName>Romanian</EnglishName> - <NativeName>română</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1392/10/dict-ro.1.7.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fromanian-dictionary-pack-spell-checker-hyphenation-thesaurus-17&amp;ts=1435689394&amp;use_mirror=freefr</DownloadLink> - <Description>Romanian Dictionary Pack (spell checker, hyphenation, thesaurus) - v1.7</Description> - </Dictionary> - <Dictionary> - <EnglishName>Russian</EnglishName> - <NativeName>Русский</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-ru-ru-aot-0-4-3.oxt</DownloadLink> - <Description>Russian spellcheck dictionary. Based on works of AOT group. 0.4.0</Description> - </Dictionary> - <Dictionary> - <EnglishName>Serbian</EnglishName> - <NativeName>српски</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/bb01ff21_dict-sr.oxt</DownloadLink> - <Description>Serbian (Cyrillic and Latin) Spelling and Hyphenation, Aug 08, 2019</Description> - </Dictionary> - <Dictionary> - <EnglishName>Sinhala</EnglishName> - <NativeName>Sinhala</NativeName> - <DownloadLink>http://extensions.openoffice.org/en/download/4346</DownloadLink> - <Description>Sinhala by laknath</Description> - </Dictionary> - <Dictionary> - <EnglishName>Slovak</EnglishName> - <NativeName>slovenčina</NativeName> - <DownloadLink>http://www.sk-spell.sk.cx/files/hunspell-sk-20110228.zip</DownloadLink> - <Description>Slovak dictionary package / Slovenské slovníky</Description> - </Dictionary> - <Dictionary> - <EnglishName>Slovenian</EnglishName> - <NativeName>slovenski</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/8b7ba8bb_pack-sl.oxt</DownloadLink> - <Description>Slovenian Dictionary Pack - 2018.01.04</Description> - </Dictionary> - <Dictionary> - <EnglishName>Spanish</EnglishName> - <NativeName>España</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/spanish-dictionary.oxt</DownloadLink> - <Description>Diccionario del idioma español - 1.0 (Dec 28, 2011)</Description> - </Dictionary> - <Dictionary> - <EnglishName>Spanish</EnglishName> - <NativeName>Español Genérico</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/e217baa9_es-any.oxt</DownloadLink> - <Description>Genérico v2.1 (Apr 05, 2016)</Description> - </Dictionary> - <Dictionary> - <EnglishName>Swahili</EnglishName> - <NativeName>Kiswahili</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/swahilidictionary-2013-03-12.oxt</DownloadLink> - <Description>Swahili Dictionary 2013.03.12</Description> - </Dictionary> - <Dictionary> - <EnglishName>Swedish</EnglishName> - <NativeName>Svenska</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/5959/1/dict-sv.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fswedish-dictionaries-apache-openoffice&amp;ts=1375123584&amp;use_mirror=heanet</DownloadLink> - <Description>Swedish 2.16</Description> - </Dictionary> - <Dictionary> - <EnglishName>Thai</EnglishName> - <NativeName>ภาษาไทย</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/2365/0/dict-th.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fthai-spellchecker-dictionary&amp;ts=1373919459&amp;use_mirror=netcologne</DownloadLink> - <Description>Thai Spell Checker Dictionary</Description> - </Dictionary> - <Dictionary> - <EnglishName>Turkish</EnglishName> - <NativeName>Turkish</NativeName> - <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/oo-turkish-dict-v1-2.oxt</DownloadLink> - <Description>Turkish Spellcheck Dictionary - 1.2</Description> - </Dictionary> - <Dictionary> - <EnglishName>Ukrainian</EnglishName> - <NativeName>Українська</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/975/6/dict-uk_ua-1.7.1.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fukrainian-dictionary-171&amp;ts=1435691238&amp;use_mirror=freefr</DownloadLink> - <Description>Ukrainian Dictionary - v1.7.1 (27/03/2014)</Description> - </Dictionary> - <Dictionary> - <EnglishName>Valencian</EnglishName> - <NativeName>valencià</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1475/1/ca-valencia.3.0.0.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fspelling-dictionary-catalan-valencian-version-300&amp;ts=1435691121&amp;use_mirror=freefr</DownloadLink> - <Description>Spelling dictionary for Catalan (Valencian version) - v3.0.0 (25/05/2015)</Description> - </Dictionary> - <Dictionary> - <EnglishName>Vietnamese</EnglishName> - <NativeName>Tiếng Việt</NativeName> - <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/917/3/vi_spellchecker_ooo3.oxt?r=http%3A%2F%2Fextensions.services.openoffice.org%2Fen%2Fproject%2Fvietnamese-spellchecker&amp;ts=1373917708&amp;use_mirror=kent</DownloadLink> - <Description>Vietnamese SpellChecker</Description> - </Dictionary> - <Dictionary> - <EnglishName>Welsh (Wales)</EnglishName> - <NativeName>Welsh (Wales)</NativeName> - <DownloadLink>https://downloads.sourceforge.net/project/aoo-extensions/1583/1/geiriadur-cy.oxt</DownloadLink> - <Description>Xhosa spell checker</Description> - </Dictionary> - <Dictionary> - <EnglishName>Xhosa (South Africa)</EnglishName> - <NativeName>Xhosa (South Africa)</NativeName> - <DownloadLink>https://sourceforge.net/projects/aoo-extensions/files/3133/0/dict-xh_za-2009.10.30.oxt/download</DownloadLink> - <Description>Xhosa spell checker</Description> - </Dictionary> - <Dictionary> - <EnglishName>Zulu</EnglishName> - <NativeName>IsiZulu</NativeName> - <DownloadLink>https://sourceforge.net/projects/aoo-extensions/files/3132/3/dict-zu_za-2010.01.26.oxt/download</DownloadLink> - <Description>Zulu spell checker</Description> - </Dictionary> -</OpenOfficeDictionaries> +<OpenOfficeDictionaries> + <Dictionary> + <EnglishName>Afrikaans</EnglishName> + <NativeName>Afrikaans</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1109/0/dict-af.oxt?r=http%3A%2F%2Fextensions.services.openoffice.org%2Fen%2Fproject%2Fafrikaans-spell-checker&amp;ts=1373917891&amp;use_mirror=kent</DownloadLink> + <Description>Afrikaans spell checker</Description> + </Dictionary> + <Dictionary> + <EnglishName>Albanian</EnglishName> + <NativeName>Shqip</NativeName> + <DownloadLink>https://sourceforge.net/projects/aoo-extensions/files/3393/1/dict-sq.oxt/download</DownloadLink> + <Description>Albanian Spell Checker Dictionary</Description> + </Dictionary> + <Dictionary> + <EnglishName>Arabic</EnglishName> + <NativeName>عربي</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-ar-3-2.oxt</DownloadLink> + <Description>Arabic spell checker 3.2</Description> + </Dictionary> + <Dictionary> + <EnglishName>Basque</EnglishName> + <NativeName>Euskara</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1383/2/xuxen_4_ooo3.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fxuxen-basque-spell-checking-dictionary-40&amp;ts=1435689769&amp;use_mirror=garr</DownloadLink> + <Description>Xuxen: Basque spell checking dictionary - v4.0</Description> + </Dictionary> + <Dictionary> + <EnglishName>Belarusian</EnglishName> + <NativeName>Беларуская мова</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/4611/15/dict-be-0.56.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fbelarusian-spell-checking-dictionary-recent-official-orthography&amp;ts=1373918638&amp;use_mirror=kent</DownloadLink> + <Description>Belarusian dictionary(spelling, hyphenation) - classic orthography</Description> + </Dictionary> + <Dictionary> + <EnglishName>Bosnian</EnglishName> + <NativeName>Bosanski</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-bs.oxt</DownloadLink> + <Description>Spellchecking dictionary for Bosnian language - 1.0 (Jan 24, 2013)</Description> + </Dictionary> + <Dictionary> + <EnglishName>Breton</EnglishName> + <NativeName>Brezhoneg</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-br-0-8.oxt</DownloadLink> + <Description>An Drouizig Breton Spell Checker</Description> + </Dictionary> + <Dictionary> + <EnglishName>Bulgarian</EnglishName> + <NativeName>Български</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/744/8/dictionaries-bg.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fbulgarian-dictionaries-blgarski-rechnici&amp;ts=1435654358&amp;use_mirror=freefr</DownloadLink> + <Description>Bulgarian Dictionaries (български речници) v4.3.2 (22/09/2010)</Description> + </Dictionary> + <Dictionary> + <EnglishName>Catalan</EnglishName> + <NativeName>català</NativeName> + <DownloadLink>https://github.com/Softcatala/catalan-dict-tools/releases/download/v3.0.1/ca-valencia.3.0.1.oxt</DownloadLink> + <Description>Catalan spellchecking dictionaries, July 2015</Description> + </Dictionary> + <Dictionary> + <EnglishName>Catalan</EnglishName> + <NativeName>català-valencià</NativeName> + <DownloadLink>http://softcatala.org/diccionaris/actualitzacions/OOo/avl.oxt</DownloadLink> + <Description>Spelling dictionary for Catalan (Valencian version)</Description> + </Dictionary> + <Dictionary> + <EnglishName>Croatian</EnglishName> + <NativeName>Hrvatski</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1052/2/dict-hr.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fcroatian-dictionary-and-hyphenation-patterns&amp;ts=1373918817&amp;use_mirror=surfnet</DownloadLink> + <Description>Croatian dictionary and hyphenation patterns</Description> + </Dictionary> + <Dictionary> + <EnglishName>Czech</EnglishName> + <NativeName>Čeština</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1078/0/dict-cs-2.0.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fczech-dictionary-pack-%25C4%258Desk%25C3%25A9-slovn%25C3%25ADky&amp;ts=1373918869&amp;use_mirror=freefr</DownloadLink> + <Description>Czech dictionary pack / České slovníky</Description> + </Dictionary> + <Dictionary> + <EnglishName>Danish</EnglishName> + <NativeName>Dansk</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-da-2-4.oxt</DownloadLink> + <Description>Stavekontrolden version 2.2 - 2014-12-22</Description> + </Dictionary> + <Dictionary> + <EnglishName>Dutch</EnglishName> + <NativeName>Nederlands</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1456/6/nl-dict-v2.00g.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fdutch-spelling-and-hyphenation-dictionary&amp;ts=1373918951&amp;use_mirror=garr</DownloadLink> + <Description>Dutch spelling and hyphenation Dictionary</Description> + </Dictionary> + <Dictionary> + <EnglishName>English</EnglishName> + <NativeName></NativeName> + <DownloadLink>https://github.com/marcoagpinto/aoo-mozilla-en-dict/archive/master.zip</DownloadLink> + <Description>All English dictionaries (AU, CA, GB, US, ZA), 2018-04-16+</Description> + </Dictionary> + <Dictionary> + <EnglishName>Estonian</EnglishName> + <NativeName></NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1328/0/dict-et.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Festonian-spellchecking-and-hyphenation&amp;ts=1435689988&amp;use_mirror=freefr</DownloadLink> + <Description>Estonian spellchecking and hyphenation (13 October, 2008)</Description> + </Dictionary> + <Dictionary> + <EnglishName>Farsi (Persian)</EnglishName> + <NativeName>Persian/Farsi</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/2359/1/dict-fa.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fpersian-spellchecker-dictionary-20090707&amp;ts=1435690384&amp;use_mirror=freefr</DownloadLink> + <Description>Persian Spellchecker Dictionary - 2009.07.07</Description> + </Dictionary> + <Dictionary> + <EnglishName>French</EnglishName> + <NativeName>Français</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/lo-oo-ressources-linguistiques-fr-v5-7.oxt</DownloadLink> + <Description>Dictionnaires francais 5.3 (28/02/2015)</Description> + </Dictionary> + <Dictionary> + <EnglishName>German (Austria)</EnglishName> + <NativeName>Deutsch (Österreich)</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-de-at-frami-2017-01-12.oxt</DownloadLink> + <Description>German (de-AT frami) dictionaries 2013.12.06 (08/12/2013)</Description> + </Dictionary> + <Dictionary> + <EnglishName>German (Germany)</EnglishName> + <NativeName>German (de-DE frami) dictionaries - [de] Deutsche (de-DE frami) Rechtschreibung</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-de-de-frami-2017-01-12.oxt</DownloadLink> + <Description>German (de-DE igerman98) dictionaries</Description> + </Dictionary> + <Dictionary> + <EnglishName>Greek</EnglishName> + <NativeName>Ελληνικά</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1411/2/el_gr_v110.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fhellenic-greek-dictionary-spell-check-and-hyphenation-110&amp;ts=1435654652&amp;use_mirror=freefr</DownloadLink> + <Description>Hellenic (Greek) Dictionary (Spell Check and Hyphenation) - v1.1.0</Description> + </Dictionary> + <Dictionary> + <EnglishName>Hebrew</EnglishName> + <NativeName>Hebrew (he) spell check dictionary 2012-08-15</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-he-2012-08-15.oxt</DownloadLink> + <Description>Hebrew (he) spell check dictionary (Aug 15, 2012)</Description> + </Dictionary> + <Dictionary> + <EnglishName>Hindi</EnglishName> + <NativeName>हिंदी</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/2367/1/dict-hi.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fhindi-spellchecker-dictionary&amp;ts=1435678775&amp;use_mirror=garr</DownloadLink> + <Description>Hindi Spellchecker Dictionary</Description> + </Dictionary> + <Dictionary> + <EnglishName>Hungarian</EnglishName> + <NativeName>Magyar</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1283/9/dict-hu.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fhungarian-dictionary-pack-20101019&amp;ts=1435690641&amp;use_mirror=freefr</DownloadLink> + <Description>Hungarian Dictionary Pack - (2010.10.19)</Description> + </Dictionary> + <Dictionary> + <EnglishName>Icelandic</EnglishName> + <NativeName>íslenska</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/hunspell-is-2014-08-18.oxt</DownloadLink> + <Description>Icelandic spelling dictionary &amp; thesaurus 2013.05.11</Description> + </Dictionary> + <Dictionary> + <EnglishName>Indonesian</EnglishName> + <NativeName>Indonesia</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/id-id.oxt</DownloadLink> + <Description>Indonesian dictionary - Kamus Indonesia 1.0</Description> + </Dictionary> + <Dictionary> + <EnglishName>Irish</EnglishName> + <NativeName>Gaeilge</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/focloiri-gaeilge-5-0.oxt</DownloadLink> + <Description>Irish language spell checker, thesaurus, and hyphenation patterns 4.5</Description> + </Dictionary> + <Dictionary> + <EnglishName>Italian</EnglishName> + <NativeName>Italiano</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/874d181c_dict-it.oxt</DownloadLink> + <Description>Italian and Latin spelling dictionaries 2013.03.31</Description> + </Dictionary> + <Dictionary> + <EnglishName>Italian</EnglishName> + <NativeName>Italiano</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1204/13/dict-it.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fitalian-dictionary-thesaurus-hyphenation-patterns-20130905&amp;ts=1435690929&amp;use_mirror=freefr</DownloadLink> + <Description>Italian dictionary, thesaurus, hyphenation patterns - (2013.09.05)</Description> + </Dictionary> + <Dictionary> + <EnglishName>Khmer</EnglishName> + <NativeName>Khmer</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/5067/2/dict-km.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fkhmer-spelling-dictionary&amp;ts=1373998173&amp;use_mirror=netcologne</DownloadLink> + <Description>Khmer spelling dictionary 2011.05.11</Description> + </Dictionary> + <Dictionary> + <EnglishName>Korean</EnglishName> + <NativeName>한글</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/korean-spell-checker-0-7-91-libo.oxt</DownloadLink> + <Description>Korean spellchecker 0.5.6</Description> + </Dictionary> + <Dictionary> + <EnglishName>Latin</EnglishName> + <NativeName>Latina</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-la-2013-03-31.oxt</DownloadLink> + <Description>Latin spelling and hyphenation dictionaries 2013.03.31</Description> + </Dictionary> + <Dictionary> + <EnglishName>Latvian</EnglishName> + <NativeName>Latviešu</NativeName> + <DownloadLink>http://ftp.nluug.nl/office/openoffice/contrib/dictionaries/hyph_lv_LV.zip</DownloadLink> + <Description>Latviešu valodas pareizrakstības pārbaudes modulis 0.9.6</Description> + </Dictionary> + <Dictionary> + <EnglishName>Lithuanian</EnglishName> + <NativeName>Lietuvių</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/openoffice-spellcheck-lt-1-3.oxt</DownloadLink> + <Description>Lithuanian spellcheck and hyphenation dictionaries 1.3</Description> + </Dictionary> + <Dictionary> + <EnglishName>Lower Sorbian</EnglishName> + <NativeName>dolnoserbšćina</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/lower-sorbian-spelling-dictionary-1-5-0.oxt</DownloadLink> + <Description>Lower Sorbian dictionary 1.4.6</Description> + </Dictionary> + <Dictionary> + <EnglishName>Malay</EnglishName> + <NativeName>Malay</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/3904/0/ms_my.oxt</DownloadLink> + <Description>Malay Spell Checker v0.1 - 07/10/04</Description> + </Dictionary> + <Dictionary> + <EnglishName>Malayalam</EnglishName> + <NativeName>Malayalam</NativeName> + <DownloadLink>https://master.dl.sourceforge.net/project/aoo-extensions/2741/3/ml_in_dict-1-1.oxt</DownloadLink> + <Description>Malayalam Spellchecker 1.1.0</Description> + </Dictionary> + <Dictionary> + <EnglishName>Macedonian</EnglishName> + <NativeName>Macedonian</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/3403/0/dict-mk.oxt</DownloadLink> + <Description>Macedonian dictionary was created by Taras Bendik</Description> + </Dictionary> + <Dictionary> + <EnglishName>Norwegian</EnglishName> + <NativeName>Norsk</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dictionary-no-no-1-0.oxt</DownloadLink> + <Description>Norsk stavekontroll (bokmål og nynorsk) 2.0.10</Description> + </Dictionary> + <Dictionary> + <EnglishName>Polish</EnglishName> + <NativeName>polski</NativeName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/hunspell/pl_PL.zip</DownloadLink> + <Description>Polish by https://sjp.pl - 2020-07-18</Description> + </Dictionary> + <Dictionary> + <EnglishName>Portuguese (Brazilian) - Libreoffice</EnglishName> + <NativeName>Português (do Brasil)</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/veroptbrv320aoc.oxt</DownloadLink> + <Description>Brazilian Portuguese Spelling Dictionary V3.2 - Libreoffice</Description> + </Dictionary> + <Dictionary> + <EnglishName>Portuguese (Brazilian) - Firefox</EnglishName> + <NativeName>Português (do Brasil)</NativeName> + <DownloadLink>https://hg.mozilla.org/releases/l10n/mozilla-aurora/pt-BR/archive/81d9d556fa78.zip/extensions/spellcheck/hunspell/</DownloadLink> + <Description>Brazilian Portuguese Spelling Dictionary 2009 José João de Almeida - Firefox</Description> + </Dictionary> + <Dictionary> + <EnglishName>Portuguese (European Portuguese Dictionary)</EnglishName> + <NativeName>Português</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1196/40/oo3x-pt-pt-16.10.1.2.oxt</DownloadLink> + <Description>Corretores Ortográficos para Português de Portugal</Description> + </Dictionary> + <Dictionary> + <EnglishName>Portuguese (European Portuguese Dictionary - PRE AO90)</EnglishName> + <NativeName>Português</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/17990/9/oo3x-pt-pt-preao-16.10.1.2.oxt</DownloadLink> + <Description>Corretores Ortográficos para Português de Portugal</Description> + </Dictionary> + <Dictionary> + <EnglishName>Romanian</EnglishName> + <NativeName>română</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1392/10/dict-ro.1.7.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fromanian-dictionary-pack-spell-checker-hyphenation-thesaurus-17&amp;ts=1435689394&amp;use_mirror=freefr</DownloadLink> + <Description>Romanian Dictionary Pack (spell checker, hyphenation, thesaurus) - v1.7</Description> + </Dictionary> + <Dictionary> + <EnglishName>Russian</EnglishName> + <NativeName>Русский</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/dict-ru-ru-aot-0-4-3.oxt</DownloadLink> + <Description>Russian spellcheck dictionary. Based on works of AOT group. 0.4.0</Description> + </Dictionary> + <Dictionary> + <EnglishName>Serbian</EnglishName> + <NativeName>српски</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/bb01ff21_dict-sr.oxt</DownloadLink> + <Description>Serbian (Cyrillic and Latin) Spelling and Hyphenation, Aug 08, 2019</Description> + </Dictionary> + <Dictionary> + <EnglishName>Sinhala</EnglishName> + <NativeName>Sinhala</NativeName> + <DownloadLink>http://extensions.openoffice.org/en/download/4346</DownloadLink> + <Description>Sinhala by laknath</Description> + </Dictionary> + <Dictionary> + <EnglishName>Slovak</EnglishName> + <NativeName>slovenčina</NativeName> + <DownloadLink>http://www.sk-spell.sk.cx/files/hunspell-sk-20110228.zip</DownloadLink> + <Description>Slovak dictionary package / Slovenské slovníky</Description> + </Dictionary> + <Dictionary> + <EnglishName>Slovenian</EnglishName> + <NativeName>slovenski</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/8b7ba8bb_pack-sl.oxt</DownloadLink> + <Description>Slovenian Dictionary Pack - 2018.01.04</Description> + </Dictionary> + <Dictionary> + <EnglishName>Spanish</EnglishName> + <NativeName>España</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/spanish-dictionary.oxt</DownloadLink> + <Description>Diccionario del idioma español - 1.0 (Dec 28, 2011)</Description> + </Dictionary> + <Dictionary> + <EnglishName>Spanish</EnglishName> + <NativeName>Español Genérico</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/e217baa9_es-any.oxt</DownloadLink> + <Description>Genérico v2.1 (Apr 05, 2016)</Description> + </Dictionary> + <Dictionary> + <EnglishName>Swahili</EnglishName> + <NativeName>Kiswahili</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/swahilidictionary-2013-03-12.oxt</DownloadLink> + <Description>Swahili Dictionary 2013.03.12</Description> + </Dictionary> + <Dictionary> + <EnglishName>Swedish</EnglishName> + <NativeName>Svenska</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/5959/1/dict-sv.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fswedish-dictionaries-apache-openoffice&amp;ts=1375123584&amp;use_mirror=heanet</DownloadLink> + <Description>Swedish 2.16</Description> + </Dictionary> + <Dictionary> + <EnglishName>Thai</EnglishName> + <NativeName>ภาษาไทย</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/2365/0/dict-th.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fproject%2Fthai-spellchecker-dictionary&amp;ts=1373919459&amp;use_mirror=netcologne</DownloadLink> + <Description>Thai Spell Checker Dictionary</Description> + </Dictionary> + <Dictionary> + <EnglishName>Turkish</EnglishName> + <NativeName>Turkish</NativeName> + <DownloadLink>https://extensions.libreoffice.org/assets/downloads/z/oo-turkish-dict-v1-2.oxt</DownloadLink> + <Description>Turkish Spellcheck Dictionary - 1.2</Description> + </Dictionary> + <Dictionary> + <EnglishName>Ukrainian</EnglishName> + <NativeName>Українська</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/975/6/dict-uk_ua-1.7.1.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fukrainian-dictionary-171&amp;ts=1435691238&amp;use_mirror=freefr</DownloadLink> + <Description>Ukrainian Dictionary - v1.7.1 (27/03/2014)</Description> + </Dictionary> + <Dictionary> + <EnglishName>Valencian</EnglishName> + <NativeName>valencià</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/1475/1/ca-valencia.3.0.0.oxt?r=http%3A%2F%2Fextensions.openoffice.org%2Fen%2Fprojectrelease%2Fspelling-dictionary-catalan-valencian-version-300&amp;ts=1435691121&amp;use_mirror=freefr</DownloadLink> + <Description>Spelling dictionary for Catalan (Valencian version) - v3.0.0 (25/05/2015)</Description> + </Dictionary> + <Dictionary> + <EnglishName>Vietnamese</EnglishName> + <NativeName>Tiếng Việt</NativeName> + <DownloadLink>http://downloads.sourceforge.net/project/aoo-extensions/917/3/vi_spellchecker_ooo3.oxt?r=http%3A%2F%2Fextensions.services.openoffice.org%2Fen%2Fproject%2Fvietnamese-spellchecker&amp;ts=1373917708&amp;use_mirror=kent</DownloadLink> + <Description>Vietnamese SpellChecker</Description> + </Dictionary> + <Dictionary> + <EnglishName>Welsh (Wales)</EnglishName> + <NativeName>Welsh (Wales)</NativeName> + <DownloadLink>https://downloads.sourceforge.net/project/aoo-extensions/1583/1/geiriadur-cy.oxt</DownloadLink> + <Description>Xhosa spell checker</Description> + </Dictionary> + <Dictionary> + <EnglishName>Xhosa (South Africa)</EnglishName> + <NativeName>Xhosa (South Africa)</NativeName> + <DownloadLink>https://sourceforge.net/projects/aoo-extensions/files/3133/0/dict-xh_za-2009.10.30.oxt/download</DownloadLink> + <Description>Xhosa spell checker</Description> + </Dictionary> + <Dictionary> + <EnglishName>Zulu</EnglishName> + <NativeName>IsiZulu</NativeName> + <DownloadLink>https://sourceforge.net/projects/aoo-extensions/files/3132/3/dict-zu_za-2010.01.26.oxt/download</DownloadLink> + <Description>Zulu spell checker</Description> + </Dictionary> +</OpenOfficeDictionaries> diff --git a/src/Resources/HunspellDictionaries.xml.gz b/src/ui/Resources/HunspellDictionaries.xml.gz similarity index 100% rename from src/Resources/HunspellDictionaries.xml.gz rename to src/ui/Resources/HunspellDictionaries.xml.gz diff --git a/src/Resources/SMPTE-428-7-2007-DCST.xsd b/src/ui/Resources/SMPTE-428-7-2007-DCST.xsd similarity index 100% rename from src/Resources/SMPTE-428-7-2007-DCST.xsd rename to src/ui/Resources/SMPTE-428-7-2007-DCST.xsd diff --git a/src/Resources/SMPTE-428-7-2007-DCST.xsd.gz b/src/ui/Resources/SMPTE-428-7-2007-DCST.xsd.gz similarity index 100% rename from src/Resources/SMPTE-428-7-2007-DCST.xsd.gz rename to src/ui/Resources/SMPTE-428-7-2007-DCST.xsd.gz diff --git a/src/Resources/SMPTE-428-7-2010-DCST.xsd b/src/ui/Resources/SMPTE-428-7-2010-DCST.xsd similarity index 97% rename from src/Resources/SMPTE-428-7-2010-DCST.xsd rename to src/ui/Resources/SMPTE-428-7-2010-DCST.xsd index 99b21d571..e2ecc19c0 100644 --- a/src/Resources/SMPTE-428-7-2010-DCST.xsd +++ b/src/ui/Resources/SMPTE-428-7-2010-DCST.xsd @@ -1,334 +1,334 @@ -<?xml version="1.0" encoding="UTF-8"?> -<xs:schema - targetNamespace="http://www.smpte-ra.org/schemas/428-7/2010/DCST" - xmlns:dcst="http://www.smpte-ra.org/schemas/428-7/2010/DCST" - xmlns:xs="http://www.w3.org/2001/XMLSchema" - elementFormDefault="qualified" attributeFormDefault="unqualified"> - - <!-- SubtitleReel --> - <xs:element name="SubtitleReel" type="dcst:SubtitleReelType" /> - <xs:complexType name="SubtitleReelType"> - <xs:sequence> - <xs:element name="Id" type="dcst:UUID" /> - <xs:element name="ContentTitleText" type="dcst:UserText" /> - <xs:element name="AnnotationText" type="dcst:UserText" minOccurs="0" /> - <xs:element name="IssueDate" type="xs:dateTime" /> - <xs:element name="ReelNumber" type="xs:positiveInteger" minOccurs="0" /> - <xs:element name="Language" type="xs:language" minOccurs="0" /> - <xs:element name="EditRate" type="dcst:RationalType" /> - <xs:element name="TimeCodeRate" type="xs:positiveInteger" /> - <xs:element name="StartTime" type="dcst:TimeCodeType" minOccurs="0" /> - <xs:element name="DisplayType" type="dcst:scopedTokenType" minOccurs="0" /> - <xs:element name="LoadFont" maxOccurs="unbounded"> - <xs:complexType> - <xs:simpleContent> - <xs:extension base="xs:anyURI"> - <xs:attribute name="ID" type="xs:string" use="optional" /> - </xs:extension> - </xs:simpleContent> - </xs:complexType> - </xs:element> - <xs:element name="SubtitleList"> - <xs:complexType> - <xs:choice maxOccurs="unbounded"> - <xs:element name="Subtitle" type="dcst:SubtitleType" /> - <xs:element name="Font"> - <xs:complexType mixed="true"> - <xs:complexContent mixed="true"> - <xs:extension base="dcst:FontType"> - <xs:sequence> - <xs:element name="Subtitle" type="dcst:SubtitleType" maxOccurs="unbounded" /> - </xs:sequence> - </xs:extension> - </xs:complexContent> - </xs:complexType> - </xs:element> - </xs:choice> - </xs:complexType> - </xs:element> - </xs:sequence> - </xs:complexType> - - <!-- Subtitle --> - <xs:complexType name="SubtitleType"> - <xs:choice maxOccurs="unbounded"> - <xs:element name="Text" type="dcst:TextType" /> - <xs:element name="Image" type="dcst:ImageType" /> - <xs:element name="Font"> - <xs:complexType mixed="true"> - <xs:complexContent mixed="true"> - <xs:extension base="dcst:FontType"> - <xs:sequence> - <xs:element name="Text" type="dcst:TextType" /> - </xs:sequence> - </xs:extension> - </xs:complexContent> - </xs:complexType> - </xs:element> - </xs:choice> - <xs:attribute name="SpotNumber" type="xs:string" use="optional" /> - <xs:attribute name="TimeIn" type="dcst:TimeCodeType" use="required" /> - <xs:attribute name="TimeOut" type="dcst:TimeCodeType" use="required" /> - <xs:attribute name="FadeUpTime" type="dcst:TimeCodeType" use="optional" /> - <xs:attribute name="FadeDownTime" type="dcst:TimeCodeType" use="optional" /> - </xs:complexType> - - <!-- Image --> - <xs:complexType name="ImageType" mixed="false"> - <xs:simpleContent> - <xs:extension base="xs:anyURI"> - <xs:attribute name="Halign" use="optional" default="center"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value="center" /> - <xs:enumeration value="left" /> - <xs:enumeration value="right" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Hposition" use="optional" default="0"> - <xs:simpleType> - <xs:restriction base="xs:decimal"> - <xs:minInclusive value="-100" /> - <xs:maxInclusive value="100" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Valign" use="optional" default="center"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value="center" /> - <xs:enumeration value="bottom" /> - <xs:enumeration value="top" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Vposition" use="optional" default="0"> - <xs:simpleType> - <xs:restriction base="xs:decimal"> - <xs:minInclusive value="-100" /> - <xs:maxInclusive value="100" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - </xs:extension> - </xs:simpleContent> - </xs:complexType> - - <!-- Font --> - <xs:complexType name="FontType" mixed="true"> - <xs:attribute name="Script" use="optional" default="normal"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value="normal" /> - <xs:enumeration value="super" /> - <xs:enumeration value="sub" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Effect" use="optional" default="none"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value="none" /> - <xs:enumeration value="border" /> - <xs:enumeration value="shadow" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Italic" use="optional" default="no"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value="yes" /> - <xs:enumeration value="no" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Underline" use="optional" default="no"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value="yes" /> - <xs:enumeration value="no" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Weight" use="optional" default="normal"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value="bold" /> - <xs:enumeration value="normal" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="ID" type="xs:string" use="optional" /> - <xs:attribute name="Color" use="optional"> - <xs:simpleType> - <xs:restriction base="xs:hexBinary"> - <xs:length value="4" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="EffectColor" use="optional"> - <xs:simpleType> - <xs:restriction base="xs:hexBinary"> - <xs:length value="4" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Size" use="optional" default="42"> - <xs:simpleType> - <xs:restriction base="xs:positiveInteger" /> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="AspectAdjust" use="optional" type="xs:decimal" default="1.0" /> - <xs:attribute name="Spacing" use="optional" type="xs:decimal" default="1.0" /> - </xs:complexType> - - <!-- Text --> - <xs:complexType name="TextType" mixed="true"> - <xs:choice minOccurs="0" maxOccurs="unbounded"> - <xs:element name="Font" type="dcst:FontType" /> - <xs:element name="Ruby" type="dcst:RubyType" /> - <xs:element name="Space" type="dcst:SpaceType" /> - <xs:element name="HGroup" type="xs:string" /> - <xs:element name="Rotate" type="dcst:RotateType" /> - </xs:choice> - <xs:attribute name="Halign" use="optional" default="center"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value="center" /> - <xs:enumeration value="left" /> - <xs:enumeration value="right" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Hposition" use="optional" default="0"> - <xs:simpleType> - <xs:restriction base="xs:decimal"> - <xs:minInclusive value="-100" /> - <xs:maxInclusive value="100" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Valign" use="optional" default="center"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value="center" /> - <xs:enumeration value="bottom" /> - <xs:enumeration value="top" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Vposition" use="optional" default="0"> - <xs:simpleType> - <xs:restriction base="xs:decimal"> - <xs:minInclusive value="-100" /> - <xs:maxInclusive value="100" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Direction" use="optional" default="ltr"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value="ltr" /> - <xs:enumeration value="rtl" /> - <xs:enumeration value="ttb" /> - <xs:enumeration value="btt" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - </xs:complexType> - - <!-- Rational Type --> - <xs:simpleType name="RationalType"> - <xs:restriction> - <xs:simpleType> - <xs:list itemType="xs:long" /> - </xs:simpleType> - <xs:length value="2" /> - </xs:restriction> - </xs:simpleType> - - <!-- TimeCode Type --> - <xs:simpleType name="TimeCodeType"> - <xs:restriction base="xs:string"> - <xs:pattern value="[0-2][0-9]:[0-5][0-9]:[0-5][0-9]:[0-2][0-9]" /> - </xs:restriction> - </xs:simpleType> - - <!-- Ruby Type --> - <xs:complexType name="RubyType"> - <xs:sequence> - <xs:element name="Rb" type="xs:string" /> - <xs:element name="Rt"> - <xs:complexType> - <xs:simpleContent> - <xs:extension base="xs:string"> - <xs:attribute name="Size" type="xs:decimal" use="optional" default="0.5" /> - <xs:attribute name="Position" use="optional" default="before"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value="before" /> - <xs:enumeration value="after" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="Spacing" type="xs:decimal" use="optional" default="0.5" /> - <xs:attribute name="Offset" type="xs:decimal" use="optional" default="0.5" /> - </xs:extension> - </xs:simpleContent> - </xs:complexType> - </xs:element> - </xs:sequence> - </xs:complexType> - - <!-- Rotate Type --> - <xs:complexType name="RotateType"> - <xs:simpleContent> - <xs:extension base="xs:string"> - <xs:attribute name="Direction" use="optional" default="none"> - <xs:simpleType> - <xs:restriction base="xs:string"> - <xs:enumeration value="none" /> - <xs:enumeration value="left" /> - <xs:enumeration value="right" /> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - </xs:extension> - </xs:simpleContent> - </xs:complexType> - - <!-- Space Type --> - <xs:complexType name="SpaceType"> - <xs:simpleContent> - <xs:extension base="xs:string"> - <xs:attribute name="Size" type="xs:decimal" use="optional" default="1.0" /> - </xs:extension> - </xs:simpleContent> - </xs:complexType> - - <!-- UUID Type --> - <xs:simpleType name="UUID"> - <xs:restriction base="xs:anyURI"> - <xs:pattern value="urn:uuid:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" /> - </xs:restriction> - </xs:simpleType> - - <!-- UserText Type --> - <xs:complexType name="UserText"> - <xs:simpleContent> - <xs:extension base="xs:string"> - <xs:attribute name="language" type="xs:language" use="optional" default="en" /> - </xs:extension> - </xs:simpleContent> - </xs:complexType> - - <!-- Scoped Token Type --> - <xs:complexType name="scopedTokenType"> - <xs:simpleContent> - <xs:extension base="xs:token"> - <xs:attribute name="scope" type="xs:anyURI" use="optional" /> - </xs:extension> - </xs:simpleContent> - </xs:complexType> -</xs:schema> +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema + targetNamespace="http://www.smpte-ra.org/schemas/428-7/2010/DCST" + xmlns:dcst="http://www.smpte-ra.org/schemas/428-7/2010/DCST" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + elementFormDefault="qualified" attributeFormDefault="unqualified"> + + <!-- SubtitleReel --> + <xs:element name="SubtitleReel" type="dcst:SubtitleReelType" /> + <xs:complexType name="SubtitleReelType"> + <xs:sequence> + <xs:element name="Id" type="dcst:UUID" /> + <xs:element name="ContentTitleText" type="dcst:UserText" /> + <xs:element name="AnnotationText" type="dcst:UserText" minOccurs="0" /> + <xs:element name="IssueDate" type="xs:dateTime" /> + <xs:element name="ReelNumber" type="xs:positiveInteger" minOccurs="0" /> + <xs:element name="Language" type="xs:language" minOccurs="0" /> + <xs:element name="EditRate" type="dcst:RationalType" /> + <xs:element name="TimeCodeRate" type="xs:positiveInteger" /> + <xs:element name="StartTime" type="dcst:TimeCodeType" minOccurs="0" /> + <xs:element name="DisplayType" type="dcst:scopedTokenType" minOccurs="0" /> + <xs:element name="LoadFont" maxOccurs="unbounded"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:anyURI"> + <xs:attribute name="ID" type="xs:string" use="optional" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="SubtitleList"> + <xs:complexType> + <xs:choice maxOccurs="unbounded"> + <xs:element name="Subtitle" type="dcst:SubtitleType" /> + <xs:element name="Font"> + <xs:complexType mixed="true"> + <xs:complexContent mixed="true"> + <xs:extension base="dcst:FontType"> + <xs:sequence> + <xs:element name="Subtitle" type="dcst:SubtitleType" maxOccurs="unbounded" /> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + </xs:element> + </xs:choice> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + + <!-- Subtitle --> + <xs:complexType name="SubtitleType"> + <xs:choice maxOccurs="unbounded"> + <xs:element name="Text" type="dcst:TextType" /> + <xs:element name="Image" type="dcst:ImageType" /> + <xs:element name="Font"> + <xs:complexType mixed="true"> + <xs:complexContent mixed="true"> + <xs:extension base="dcst:FontType"> + <xs:sequence> + <xs:element name="Text" type="dcst:TextType" /> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + </xs:element> + </xs:choice> + <xs:attribute name="SpotNumber" type="xs:string" use="optional" /> + <xs:attribute name="TimeIn" type="dcst:TimeCodeType" use="required" /> + <xs:attribute name="TimeOut" type="dcst:TimeCodeType" use="required" /> + <xs:attribute name="FadeUpTime" type="dcst:TimeCodeType" use="optional" /> + <xs:attribute name="FadeDownTime" type="dcst:TimeCodeType" use="optional" /> + </xs:complexType> + + <!-- Image --> + <xs:complexType name="ImageType" mixed="false"> + <xs:simpleContent> + <xs:extension base="xs:anyURI"> + <xs:attribute name="Halign" use="optional" default="center"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="center" /> + <xs:enumeration value="left" /> + <xs:enumeration value="right" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Hposition" use="optional" default="0"> + <xs:simpleType> + <xs:restriction base="xs:decimal"> + <xs:minInclusive value="-100" /> + <xs:maxInclusive value="100" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Valign" use="optional" default="center"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="center" /> + <xs:enumeration value="bottom" /> + <xs:enumeration value="top" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Vposition" use="optional" default="0"> + <xs:simpleType> + <xs:restriction base="xs:decimal"> + <xs:minInclusive value="-100" /> + <xs:maxInclusive value="100" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <!-- Font --> + <xs:complexType name="FontType" mixed="true"> + <xs:attribute name="Script" use="optional" default="normal"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="normal" /> + <xs:enumeration value="super" /> + <xs:enumeration value="sub" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Effect" use="optional" default="none"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="none" /> + <xs:enumeration value="border" /> + <xs:enumeration value="shadow" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Italic" use="optional" default="no"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="yes" /> + <xs:enumeration value="no" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Underline" use="optional" default="no"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="yes" /> + <xs:enumeration value="no" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Weight" use="optional" default="normal"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="bold" /> + <xs:enumeration value="normal" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="ID" type="xs:string" use="optional" /> + <xs:attribute name="Color" use="optional"> + <xs:simpleType> + <xs:restriction base="xs:hexBinary"> + <xs:length value="4" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="EffectColor" use="optional"> + <xs:simpleType> + <xs:restriction base="xs:hexBinary"> + <xs:length value="4" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Size" use="optional" default="42"> + <xs:simpleType> + <xs:restriction base="xs:positiveInteger" /> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="AspectAdjust" use="optional" type="xs:decimal" default="1.0" /> + <xs:attribute name="Spacing" use="optional" type="xs:decimal" default="1.0" /> + </xs:complexType> + + <!-- Text --> + <xs:complexType name="TextType" mixed="true"> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="Font" type="dcst:FontType" /> + <xs:element name="Ruby" type="dcst:RubyType" /> + <xs:element name="Space" type="dcst:SpaceType" /> + <xs:element name="HGroup" type="xs:string" /> + <xs:element name="Rotate" type="dcst:RotateType" /> + </xs:choice> + <xs:attribute name="Halign" use="optional" default="center"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="center" /> + <xs:enumeration value="left" /> + <xs:enumeration value="right" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Hposition" use="optional" default="0"> + <xs:simpleType> + <xs:restriction base="xs:decimal"> + <xs:minInclusive value="-100" /> + <xs:maxInclusive value="100" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Valign" use="optional" default="center"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="center" /> + <xs:enumeration value="bottom" /> + <xs:enumeration value="top" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Vposition" use="optional" default="0"> + <xs:simpleType> + <xs:restriction base="xs:decimal"> + <xs:minInclusive value="-100" /> + <xs:maxInclusive value="100" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Direction" use="optional" default="ltr"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="ltr" /> + <xs:enumeration value="rtl" /> + <xs:enumeration value="ttb" /> + <xs:enumeration value="btt" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + </xs:complexType> + + <!-- Rational Type --> + <xs:simpleType name="RationalType"> + <xs:restriction> + <xs:simpleType> + <xs:list itemType="xs:long" /> + </xs:simpleType> + <xs:length value="2" /> + </xs:restriction> + </xs:simpleType> + + <!-- TimeCode Type --> + <xs:simpleType name="TimeCodeType"> + <xs:restriction base="xs:string"> + <xs:pattern value="[0-2][0-9]:[0-5][0-9]:[0-5][0-9]:[0-2][0-9]" /> + </xs:restriction> + </xs:simpleType> + + <!-- Ruby Type --> + <xs:complexType name="RubyType"> + <xs:sequence> + <xs:element name="Rb" type="xs:string" /> + <xs:element name="Rt"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="Size" type="xs:decimal" use="optional" default="0.5" /> + <xs:attribute name="Position" use="optional" default="before"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="before" /> + <xs:enumeration value="after" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="Spacing" type="xs:decimal" use="optional" default="0.5" /> + <xs:attribute name="Offset" type="xs:decimal" use="optional" default="0.5" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + + <!-- Rotate Type --> + <xs:complexType name="RotateType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="Direction" use="optional" default="none"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="none" /> + <xs:enumeration value="left" /> + <xs:enumeration value="right" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <!-- Space Type --> + <xs:complexType name="SpaceType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="Size" type="xs:decimal" use="optional" default="1.0" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <!-- UUID Type --> + <xs:simpleType name="UUID"> + <xs:restriction base="xs:anyURI"> + <xs:pattern value="urn:uuid:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" /> + </xs:restriction> + </xs:simpleType> + + <!-- UserText Type --> + <xs:complexType name="UserText"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="language" type="xs:language" use="optional" default="en" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <!-- Scoped Token Type --> + <xs:complexType name="scopedTokenType"> + <xs:simpleContent> + <xs:extension base="xs:token"> + <xs:attribute name="scope" type="xs:anyURI" use="optional" /> + </xs:extension> + </xs:simpleContent> + </xs:complexType> +</xs:schema> diff --git a/src/Resources/SMPTE-428-7-2010-DCST.xsd.gz b/src/ui/Resources/SMPTE-428-7-2010-DCST.xsd.gz similarity index 100% rename from src/Resources/SMPTE-428-7-2010-DCST.xsd.gz rename to src/ui/Resources/SMPTE-428-7-2010-DCST.xsd.gz diff --git a/src/Resources/SMPTE-428-7-2014-DCST.xsd b/src/ui/Resources/SMPTE-428-7-2014-DCST.xsd similarity index 100% rename from src/Resources/SMPTE-428-7-2014-DCST.xsd rename to src/ui/Resources/SMPTE-428-7-2014-DCST.xsd diff --git a/src/Resources/SMPTE-428-7-2014-DCST.xsd.gz b/src/ui/Resources/SMPTE-428-7-2014-DCST.xsd.gz similarity index 100% rename from src/Resources/SMPTE-428-7-2014-DCST.xsd.gz rename to src/ui/Resources/SMPTE-428-7-2014-DCST.xsd.gz diff --git a/src/Resources/TesseractDictionaries.xml b/src/ui/Resources/TesseractDictionaries.xml similarity index 98% rename from src/Resources/TesseractDictionaries.xml rename to src/ui/Resources/TesseractDictionaries.xml index 8df4e9181..6b822bc71 100644 --- a/src/Resources/TesseractDictionaries.xml +++ b/src/ui/Resources/TesseractDictionaries.xml @@ -1,288 +1,288 @@ -<!-- Alternately from https://sourceforge.net/projects/tesseract-ocr-alt/files/ --> -<TesseractDictionaries> - <Dictionary> - <EnglishName>Afrikaans</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.afr.tar.gz</DownloadLink> - <Description>Afrikaans language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Albanian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.sqi.tar.gz</DownloadLink> - <Description>Albanian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Arabic</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ara.tar.gz</DownloadLink> - <Description>Arabic language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Azerbaijani</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.aze.tar.gz</DownloadLink> - <Description>Azerbaijani language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Basque</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.eus.tar.gz</DownloadLink> - <Description>Basque language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Belarusian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.bel.tar.gz</DownloadLink> - <Description>Belarusian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Bengali</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ben.tar.gz</DownloadLink> - <Description>Bengali language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Bulgarian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.bul.tar.gz</DownloadLink> - <Description>Bulgarian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Catalan</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.cat.tar.gz</DownloadLink> - <Description>Catalan language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Chinese (Simplified)</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.chi_sim.tar.gz</DownloadLink> - <Description>Chinese (Simplified) language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Chinese (Traditional)</EnglishName> - <DownloadLink>https://github.com/tesseract-ocr/tessdata/raw/bf82613055ebc6e63d9e3b438a5c234bfd638c93/chi_tra.traineddata</DownloadLink> - <Description>Chinese (Traditional) language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Cherokee</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.chr.tar.gz</DownloadLink> - <Description>Cherokee language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Croatian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.hrv.tar.gz</DownloadLink> - <Description>Croatian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Czech</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ces.tar.gz</DownloadLink> - <Description>Czech language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Danish</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.dan.tar.gz</DownloadLink> - <Description>Danish language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Dutch</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.nld.tar.gz</DownloadLink> - <Description>Dutch language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>English</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.eng.tar.gz</DownloadLink> - <Description>English language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Estonian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.est.tar.gz</DownloadLink> - <Description>Estonian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Finnish</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.fin.tar.gz</DownloadLink> - <Description>Finnish language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>French</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.fra.tar.gz</DownloadLink> - <Description>French language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Galician</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.glg.tar.gz</DownloadLink> - <Description>Galician language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>German</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.deu.tar.gz</DownloadLink> - <Description>German language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Greek</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ell.tar.gz</DownloadLink> - <Description>Greek language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Hebrew</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.heb.tar.gz</DownloadLink> - <Description>Hebrew language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Hindi</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.hin.tar.gz</DownloadLink> - <Description>Hindi language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Hungarian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.hun.tar.gz</DownloadLink> - <Description>Hungarian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Icelandic</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.isl.tar.gz</DownloadLink> - <Description>Icelandic language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Indonesian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ind.tar.gz</DownloadLink> - <Description>Indonesian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Italian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ita.tar.gz</DownloadLink> - <Description>Italian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Japanese</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.jpn.tar.gz</DownloadLink> - <Description>Japanese language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Kannada</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.kan.tar.gz</DownloadLink> - <Description>Kannada language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Korean</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.kor.tar.gz</DownloadLink> - <Description>Korean language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Latvian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.lav.tar.gz</DownloadLink> - <Description>Latvian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Lithuanian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.lit.tar.gz</DownloadLink> - <Description>Lithuanian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Macedonian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.mkd.tar.gz</DownloadLink> - <Description>Macedonian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Malay</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.msa.tar.gz</DownloadLink> - <Description>Malay language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Malayalam</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.mal.tar.gz</DownloadLink> - <Description>Malayalam language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Maltese</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.mlt.tar.gz</DownloadLink> - <Description>Maltese language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Norwegian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.nor.tar.gz</DownloadLink> - <Description>Norwegian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Persian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.fas.tar.gz</DownloadLink> - <Description>Persian/Farsi language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Polish</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.pol.tar.gz</DownloadLink> - <Description>Polish language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Portuguese</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.por.tar.gz</DownloadLink> - <Description>Portuguese language data for Tesseract 3.02 </Description> - </Dictionary> - <Dictionary> - <EnglishName>Romanian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ron.tar.gz</DownloadLink> - <Description>Romanian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Russian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.rus.tar.gz</DownloadLink> - <Description>Russian Language Data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Serbian (Latin)</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.srp.tar.gz</DownloadLink> - <Description>Serbian (Latin) language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Slovak</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.slk.tar.gz</DownloadLink> - <Description>Slovak language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Slovenian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.slv.tar.gz</DownloadLink> - <Description>Slovenian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Spanish</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.spa.tar.gz</DownloadLink> - <Description>Spanish language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Swahili</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.swa.tar.gz</DownloadLink> - <Description>Swahili language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Swedish</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.swe.tar.gz</DownloadLink> - <Description>Swedish language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Tagalog</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.tgl.tar.gz</DownloadLink> - <Description>Tagalog language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Tamil</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.tam.tar.gz</DownloadLink> - <Description>Tamil language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Thai</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.tha.tar.gz</DownloadLink> - <Description>Thai language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Telugu</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.tel.tar.gz</DownloadLink> - <Description>Telugu language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Turkish</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.tur.tar.gz</DownloadLink> - <Description>Turkish language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Ukrainian</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ukr.tar.gz</DownloadLink> - <Description>Ukrainian language data for Tesseract 3.02</Description> - </Dictionary> - <Dictionary> - <EnglishName>Vietnamese</EnglishName> - <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.vie.tar.gz</DownloadLink> - <Description>Vietnamese Language Data for Tesseract 3.02</Description> - </Dictionary> +<!-- Alternately from https://sourceforge.net/projects/tesseract-ocr-alt/files/ --> +<TesseractDictionaries> + <Dictionary> + <EnglishName>Afrikaans</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.afr.tar.gz</DownloadLink> + <Description>Afrikaans language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Albanian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.sqi.tar.gz</DownloadLink> + <Description>Albanian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Arabic</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ara.tar.gz</DownloadLink> + <Description>Arabic language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Azerbaijani</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.aze.tar.gz</DownloadLink> + <Description>Azerbaijani language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Basque</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.eus.tar.gz</DownloadLink> + <Description>Basque language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Belarusian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.bel.tar.gz</DownloadLink> + <Description>Belarusian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Bengali</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ben.tar.gz</DownloadLink> + <Description>Bengali language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Bulgarian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.bul.tar.gz</DownloadLink> + <Description>Bulgarian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Catalan</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.cat.tar.gz</DownloadLink> + <Description>Catalan language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Chinese (Simplified)</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.chi_sim.tar.gz</DownloadLink> + <Description>Chinese (Simplified) language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Chinese (Traditional)</EnglishName> + <DownloadLink>https://github.com/tesseract-ocr/tessdata/raw/bf82613055ebc6e63d9e3b438a5c234bfd638c93/chi_tra.traineddata</DownloadLink> + <Description>Chinese (Traditional) language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Cherokee</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.chr.tar.gz</DownloadLink> + <Description>Cherokee language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Croatian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.hrv.tar.gz</DownloadLink> + <Description>Croatian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Czech</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ces.tar.gz</DownloadLink> + <Description>Czech language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Danish</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.dan.tar.gz</DownloadLink> + <Description>Danish language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Dutch</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.nld.tar.gz</DownloadLink> + <Description>Dutch language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>English</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.eng.tar.gz</DownloadLink> + <Description>English language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Estonian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.est.tar.gz</DownloadLink> + <Description>Estonian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Finnish</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.fin.tar.gz</DownloadLink> + <Description>Finnish language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>French</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.fra.tar.gz</DownloadLink> + <Description>French language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Galician</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.glg.tar.gz</DownloadLink> + <Description>Galician language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>German</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.deu.tar.gz</DownloadLink> + <Description>German language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Greek</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ell.tar.gz</DownloadLink> + <Description>Greek language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Hebrew</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.heb.tar.gz</DownloadLink> + <Description>Hebrew language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Hindi</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.hin.tar.gz</DownloadLink> + <Description>Hindi language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Hungarian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.hun.tar.gz</DownloadLink> + <Description>Hungarian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Icelandic</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.isl.tar.gz</DownloadLink> + <Description>Icelandic language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Indonesian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ind.tar.gz</DownloadLink> + <Description>Indonesian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Italian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ita.tar.gz</DownloadLink> + <Description>Italian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Japanese</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.jpn.tar.gz</DownloadLink> + <Description>Japanese language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Kannada</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.kan.tar.gz</DownloadLink> + <Description>Kannada language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Korean</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.kor.tar.gz</DownloadLink> + <Description>Korean language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Latvian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.lav.tar.gz</DownloadLink> + <Description>Latvian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Lithuanian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.lit.tar.gz</DownloadLink> + <Description>Lithuanian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Macedonian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.mkd.tar.gz</DownloadLink> + <Description>Macedonian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Malay</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.msa.tar.gz</DownloadLink> + <Description>Malay language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Malayalam</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.mal.tar.gz</DownloadLink> + <Description>Malayalam language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Maltese</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.mlt.tar.gz</DownloadLink> + <Description>Maltese language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Norwegian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.nor.tar.gz</DownloadLink> + <Description>Norwegian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Persian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.fas.tar.gz</DownloadLink> + <Description>Persian/Farsi language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Polish</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.pol.tar.gz</DownloadLink> + <Description>Polish language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Portuguese</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.por.tar.gz</DownloadLink> + <Description>Portuguese language data for Tesseract 3.02 </Description> + </Dictionary> + <Dictionary> + <EnglishName>Romanian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ron.tar.gz</DownloadLink> + <Description>Romanian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Russian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.rus.tar.gz</DownloadLink> + <Description>Russian Language Data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Serbian (Latin)</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.srp.tar.gz</DownloadLink> + <Description>Serbian (Latin) language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Slovak</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.slk.tar.gz</DownloadLink> + <Description>Slovak language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Slovenian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.slv.tar.gz</DownloadLink> + <Description>Slovenian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Spanish</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.spa.tar.gz</DownloadLink> + <Description>Spanish language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Swahili</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.swa.tar.gz</DownloadLink> + <Description>Swahili language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Swedish</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.swe.tar.gz</DownloadLink> + <Description>Swedish language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Tagalog</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.tgl.tar.gz</DownloadLink> + <Description>Tagalog language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Tamil</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.tam.tar.gz</DownloadLink> + <Description>Tamil language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Thai</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.tha.tar.gz</DownloadLink> + <Description>Thai language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Telugu</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.tel.tar.gz</DownloadLink> + <Description>Telugu language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Turkish</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.tur.tar.gz</DownloadLink> + <Description>Turkish language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Ukrainian</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.ukr.tar.gz</DownloadLink> + <Description>Ukrainian language data for Tesseract 3.02</Description> + </Dictionary> + <Dictionary> + <EnglishName>Vietnamese</EnglishName> + <DownloadLink>https://github.com/SubtitleEdit/support-files/raw/master/tessdata/tesseract-ocr-3.02.vie.tar.gz</DownloadLink> + <Description>Vietnamese Language Data for Tesseract 3.02</Description> + </Dictionary> </TesseractDictionaries> \ No newline at end of file diff --git a/src/Resources/TesseractDictionaries.xml.gz b/src/ui/Resources/TesseractDictionaries.xml.gz similarity index 100% rename from src/Resources/TesseractDictionaries.xml.gz rename to src/ui/Resources/TesseractDictionaries.xml.gz diff --git a/src/Resources/Transparent Background.png b/src/ui/Resources/Transparent Background.png similarity index 100% rename from src/Resources/Transparent Background.png rename to src/ui/Resources/Transparent Background.png diff --git a/src/Resources/bookmark22.png b/src/ui/Resources/bookmark22.png similarity index 100% rename from src/Resources/bookmark22.png rename to src/ui/Resources/bookmark22.png diff --git a/src/Resources/nOCR_TesseractHelper.xml.gz b/src/ui/Resources/nOCR_TesseractHelper.xml.gz similarity index 100% rename from src/Resources/nOCR_TesseractHelper.xml.gz rename to src/ui/Resources/nOCR_TesseractHelper.xml.gz diff --git a/src/Resources/pictureBoxFS.Image.png b/src/ui/Resources/pictureBoxFS.Image.png similarity index 100% rename from src/Resources/pictureBoxFS.Image.png rename to src/ui/Resources/pictureBoxFS.Image.png diff --git a/src/Resources/pictureBoxFSDown.Image.png b/src/ui/Resources/pictureBoxFSDown.Image.png similarity index 100% rename from src/Resources/pictureBoxFSDown.Image.png rename to src/ui/Resources/pictureBoxFSDown.Image.png diff --git a/src/Resources/pictureBoxFSOver.Image.png b/src/ui/Resources/pictureBoxFSOver.Image.png similarity index 100% rename from src/Resources/pictureBoxFSOver.Image.png rename to src/ui/Resources/pictureBoxFSOver.Image.png diff --git a/src/Resources/pictureBoxFastForward.Image.png b/src/ui/Resources/pictureBoxFastForward.Image.png similarity index 100% rename from src/Resources/pictureBoxFastForward.Image.png rename to src/ui/Resources/pictureBoxFastForward.Image.png diff --git a/src/Resources/pictureBoxFastForwardMouseDown.Image.png b/src/ui/Resources/pictureBoxFastForwardMouseDown.Image.png similarity index 100% rename from src/Resources/pictureBoxFastForwardMouseDown.Image.png rename to src/ui/Resources/pictureBoxFastForwardMouseDown.Image.png diff --git a/src/Resources/pictureBoxFastForwardMouseOver.Image.png b/src/ui/Resources/pictureBoxFastForwardMouseOver.Image.png similarity index 100% rename from src/Resources/pictureBoxFastForwardMouseOver.Image.png rename to src/ui/Resources/pictureBoxFastForwardMouseOver.Image.png diff --git a/src/Resources/pictureBoxNoFS.Image.png b/src/ui/Resources/pictureBoxNoFS.Image.png similarity index 100% rename from src/Resources/pictureBoxNoFS.Image.png rename to src/ui/Resources/pictureBoxNoFS.Image.png diff --git a/src/Resources/pictureBoxNoFSDown.Image.png b/src/ui/Resources/pictureBoxNoFSDown.Image.png similarity index 100% rename from src/Resources/pictureBoxNoFSDown.Image.png rename to src/ui/Resources/pictureBoxNoFSDown.Image.png diff --git a/src/Resources/pictureBoxNoFSOver.Image.png b/src/ui/Resources/pictureBoxNoFSOver.Image.png similarity index 100% rename from src/Resources/pictureBoxNoFSOver.Image.png rename to src/ui/Resources/pictureBoxNoFSOver.Image.png diff --git a/src/Resources/pictureBoxReverse.Image.png b/src/ui/Resources/pictureBoxReverse.Image.png similarity index 100% rename from src/Resources/pictureBoxReverse.Image.png rename to src/ui/Resources/pictureBoxReverse.Image.png diff --git a/src/Resources/pictureBoxReverseMouseDown.Image.png b/src/ui/Resources/pictureBoxReverseMouseDown.Image.png similarity index 100% rename from src/Resources/pictureBoxReverseMouseDown.Image.png rename to src/ui/Resources/pictureBoxReverseMouseDown.Image.png diff --git a/src/Resources/pictureBoxReverseMouseOver.Image.png b/src/ui/Resources/pictureBoxReverseMouseOver.Image.png similarity index 100% rename from src/Resources/pictureBoxReverseMouseOver.Image.png rename to src/ui/Resources/pictureBoxReverseMouseOver.Image.png diff --git a/src/SubtitleEdit.csproj b/src/ui/SubtitleEdit.csproj similarity index 97% rename from src/SubtitleEdit.csproj rename to src/ui/SubtitleEdit.csproj index d7a15815d..18905bddd 100644 --- a/src/SubtitleEdit.csproj +++ b/src/ui/SubtitleEdit.csproj @@ -1,1955 +1,1955 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="packages\ILRepack.2.0.18\build\ILRepack.props" Condition="Exists('packages\ILRepack.2.0.18\build\ILRepack.props')" /> - <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> - <PropertyGroup> - <AppDesignerFolder>Properties</AppDesignerFolder> - <ApplicationIcon>Icons\SE.ico</ApplicationIcon> - <AssemblyName>SubtitleEdit</AssemblyName> - <BootstrapperEnabled>true</BootstrapperEnabled> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <FileAlignment>512</FileAlignment> - <ManifestCertificateThumbprint>DCCE7922B5E425ADB221E06DC2FB405664CF8F63</ManifestCertificateThumbprint> - <MapFileExtensions>true</MapFileExtensions> - <OutputType>WinExe</OutputType> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{511A5B59-1C35-4719-8536-23B19AF9B21A}</ProjectGuid> - <PublishWizardCompleted>true</PublishWizardCompleted> - <RestorePackages>true</RestorePackages> - <RootNamespace>Nikse.SubtitleEdit</RootNamespace> - <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">.\</SolutionDir> - <TargetFrameworkProfile> - </TargetFrameworkProfile> - <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <DefineConstants>TRACE;DEBUG</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <PlatformTarget>AnyCPU</PlatformTarget> - <UseVSHostingProcess>true</UseVSHostingProcess> - <WarningLevel>4</WarningLevel> - <Prefer32Bit>false</Prefer32Bit> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> - <DebugType>pdbonly</DebugType> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <PlatformTarget>AnyCPU</PlatformTarget> - <UseVSHostingProcess>true</UseVSHostingProcess> - <WarningLevel>4</WarningLevel> - <Prefer32Bit>false</Prefer32Bit> - </PropertyGroup> - <ItemGroup> - <Reference Include="Interop.QuartzTypeLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> - <EmbedInteropTypes>True</EmbedInteropTypes> - <HintPath>DLLs\Interop.QuartzTypeLib.dll</HintPath> - <SpecificVersion>False</SpecificVersion> - </Reference> - <Reference Include="NHunspell, Version=1.2.5554.16953, Culture=neutral, PublicKeyToken=1ac793ea843b4366, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>packages\NHunspell.1.2.5554.16953\lib\net\NHunspell.dll</HintPath> - </Reference> - <Reference Include="System" /> - <Reference Include="System.Data" /> - <Reference Include="System.Drawing" /> - <Reference Include="System.EnterpriseServices" /> - <Reference Include="System.Web.Services" /> - <Reference Include="System.Windows.Forms" /> - <Reference Include="System.Xml" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Controls\SETextBox.cs"> - <SubType>Component</SubType> - </Compile> - <Compile Include="Controls\VideoPlayerContainer.cs"> - <SubType>Component</SubType> - </Compile> - <Compile Include="Controls\TimeUpDown.cs"> - <SubType>UserControl</SubType> - </Compile> - <Compile Include="Controls\TimeUpDown.Designer.cs"> - <DependentUpon>TimeUpDown.cs</DependentUpon> - </Compile> - <Compile Include="Controls\AudioVisualizer.cs"> - <SubType>UserControl</SubType> - </Compile> - <Compile Include="Controls\AudioVisualizer.Designer.cs"> - <DependentUpon>AudioVisualizer.cs</DependentUpon> - </Compile> - <Compile Include="Forms\AlignmentPickerJapanese.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\AlignmentPickerJapanese.Designer.cs"> - <DependentUpon>AlignmentPickerJapanese.cs</DependentUpon> - </Compile> - <Compile Include="Forms\BatchConvertMkvEnding.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\BatchConvertMkvEnding.Designer.cs"> - <DependentUpon>BatchConvertMkvEnding.cs</DependentUpon> - </Compile> - <Compile Include="Forms\BatchConvertTsSettings.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\BatchConvertTsSettings.Designer.cs"> - <DependentUpon>BatchConvertTsSettings.cs</DependentUpon> - </Compile> - <Compile Include="Forms\BookmarkAdd.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\BookmarkAdd.Designer.cs"> - <DependentUpon>BookmarkAdd.cs</DependentUpon> - </Compile> - <Compile Include="Forms\AddWaveformBatch.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\AddWaveformBatch.Designer.cs"> - <DependentUpon>AddWaveformBatch.cs</DependentUpon> - </Compile> - <Compile Include="Forms\AudioToText.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\AudioToText.Designer.cs"> - <DependentUpon>AudioToText.cs</DependentUpon> - </Compile> - <Compile Include="Forms\BookmarksGoTo.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\BookmarksGoTo.Designer.cs"> - <DependentUpon>BookmarksGoTo.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Cavena890SaveOptions.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Cavena890SaveOptions.Designer.cs"> - <DependentUpon>Cavena890SaveOptions.cs</DependentUpon> - </Compile> - <Compile Include="Forms\CheckForUpdates.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\CheckForUpdates.Designer.cs"> - <DependentUpon>CheckForUpdates.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ChooseFontName.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ChooseFontName.Designer.cs"> - <DependentUpon>ChooseFontName.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ColorChooser.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\DCinema\DCinemaPropertiesInterop.cs"> - <SubType>form</SubType> - </Compile> - <Compile Include="Forms\DCinema\DCinemaPropertiesInterop.Designer.cs"> - <DependentUpon>DCinemaPropertiesInterop.cs</DependentUpon> - </Compile> - <Compile Include="Forms\DCinema\DCinemaPropertiesSmpte.cs"> - <SubType>form</SubType> - </Compile> - <Compile Include="Forms\DCinema\DCinemaPropertiesSmpte.Designer.cs"> - <DependentUpon>DCinemaPropertiesSmpte.cs</DependentUpon> - </Compile> - <Compile Include="Forms\DoNotBreakAfterListEdit.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\DoNotBreakAfterListEdit.Designer.cs"> - <DependentUpon>DoNotBreakAfterListEdit.cs</DependentUpon> - </Compile> - <Compile Include="Forms\About.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\About.Designer.cs"> - <DependentUpon>About.cs</DependentUpon> - </Compile> - <Compile Include="Controls\SubtitleListView.cs"> - <SubType>Component</SubType> - </Compile> - <Compile Include="Forms\AddToNames.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\AddToNames.Designer.cs"> - <DependentUpon>AddToNames.cs</DependentUpon> - </Compile> - <Compile Include="Forms\DownloadFfmpeg.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\DownloadFfmpeg.Designer.cs"> - <DependentUpon>DownloadFfmpeg.cs</DependentUpon> - </Compile> - <Compile Include="Forms\DvdStudioProProperties.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\DvdStudioProProperties.Designer.cs"> - <DependentUpon>DvdStudioProProperties.cs</DependentUpon> - </Compile> - <Compile Include="Forms\EbuLanguageCode.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\EbuLanguageCode.Designer.cs"> - <DependentUpon>EbuLanguageCode.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ExportFcpXmlAdvanced.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ExportFcpXmlAdvanced.Designer.cs"> - <DependentUpon>ExportFcpXmlAdvanced.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ExportPngXmlDialogOpenFolder.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ExportPngXmlDialogOpenFolder.Designer.cs"> - <DependentUpon>ExportPngXmlDialogOpenFolder.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ImportCdg.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ImportCdg.Designer.cs"> - <DependentUpon>ImportCdg.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ImportFinalDraft.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ImportFinalDraft.Designer.cs"> - <DependentUpon>ImportFinalDraft.cs</DependentUpon> - </Compile> - <Compile Include="Forms\MultipleReplaceExportImport.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\MultipleReplaceExportImport.Designer.cs"> - <DependentUpon>MultipleReplaceExportImport.cs</DependentUpon> - </Compile> - <Compile Include="Forms\NetflixFixErrors.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\NetflixFixErrors.Designer.cs"> - <DependentUpon>NetflixFixErrors.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\AddBeterMultiMatch.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\AddBeterMultiMatch.Designer.cs"> - <DependentUpon>AddBeterMultiMatch.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\AddBetterMultiMatchNOcr.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\AddBetterMultiMatchNOcr.Designer.cs"> - <DependentUpon>AddBetterMultiMatchNOcr.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\AddToOcrReplaceList.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\AddToOcrReplaceList.Designer.cs"> - <DependentUpon>AddToOcrReplaceList.cs</DependentUpon> - </Compile> - <Compile Include="Forms\AddToUserDic.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\AddToUserDic.Designer.cs"> - <DependentUpon>AddToUserDic.cs</DependentUpon> - </Compile> - <Compile Include="Forms\AddWaveform.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\AddWaveform.Designer.cs"> - <DependentUpon>AddWaveform.cs</DependentUpon> - </Compile> - <Compile Include="Forms\AlignmentPicker.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\AlignmentPicker.Designer.cs"> - <DependentUpon>AlignmentPicker.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ApplyDurationLimits.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ApplyDurationLimits.Designer.cs"> - <DependentUpon>ApplyDurationLimits.cs</DependentUpon> - </Compile> - <Compile Include="Forms\AutoBreakUnbreakLines.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\AutoBreakUnbreakLines.Designer.cs"> - <DependentUpon>AutoBreakUnbreakLines.cs</DependentUpon> - </Compile> - <Compile Include="Forms\BatchConvert.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\BatchConvert.Designer.cs"> - <DependentUpon>BatchConvert.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Beamer.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Beamer.Designer.cs"> - <DependentUpon>Beamer.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ChangeCasing.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ChangeCasing.Designer.cs"> - <DependentUpon>ChangeCasing.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ChangeCasingNames.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ChangeCasingNames.Designer.cs"> - <DependentUpon>ChangeCasingNames.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ChangeFrameRate.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ChangeFrameRate.Designer.cs"> - <DependentUpon>ChangeFrameRate.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ChangeSpeedInPercent.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ChangeSpeedInPercent.Designer.cs"> - <DependentUpon>ChangeSpeedInPercent.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ChooseAudioTrack.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ChooseAudioTrack.Designer.cs"> - <DependentUpon>ChooseAudioTrack.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ChooseLanguage.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ChooseLanguage.Designer.cs"> - <DependentUpon>ChooseLanguage.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ChooseEncoding.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ChooseEncoding.Designer.cs"> - <DependentUpon>ChooseEncoding.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ChooseResolution.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ChooseResolution.Designer.cs"> - <DependentUpon>ChooseResolution.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ChooseStyle.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ChooseStyle.Designer.cs"> - <DependentUpon>ChooseStyle.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Compare.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Compare.Designer.cs"> - <DependentUpon>Compare.cs</DependentUpon> - </Compile> - <Compile Include="Forms\AdjustDisplayDuration.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\AdjustDisplayDuration.Designer.cs"> - <DependentUpon>AdjustDisplayDuration.cs</DependentUpon> - </Compile> - <Compile Include="Forms\DurationsBridgeGaps.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\DurationsBridgeGaps.Designer.cs"> - <DependentUpon>DurationsBridgeGaps.cs</DependentUpon> - </Compile> - <Compile Include="Forms\EbuColorPicker.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\EbuColorPicker.Designer.cs"> - <DependentUpon>EbuColorPicker.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ExportCustomText.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ExportCustomText.Designer.cs"> - <DependentUpon>ExportCustomText.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ExportCustomTextFormat.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ExportCustomTextFormat.Designer.cs"> - <DependentUpon>ExportCustomTextFormat.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ExportPngXmlPreview.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ExportPngXmlPreview.Designer.cs"> - <DependentUpon>ExportPngXmlPreview.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ExportTextST.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ExportTextST.Designer.cs"> - <DependentUpon>ExportTextST.cs</DependentUpon> - </Compile> - <Compile Include="Forms\FcpProperties.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\FcpProperties.Designer.cs"> - <DependentUpon>FcpProperties.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ImportImages.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ImportImages.Designer.cs"> - <DependentUpon>ImportImages.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ImportSceneChanges.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ImportSceneChanges.Designer.cs"> - <DependentUpon>ImportSceneChanges.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ImportUnknownFormat.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ImportUnknownFormat.Designer.cs"> - <DependentUpon>ImportUnknownFormat.cs</DependentUpon> - </Compile> - <Compile Include="Forms\MeasurementConverter.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\MeasurementConverter.Designer.cs"> - <DependentUpon>MeasurementConverter.cs</DependentUpon> - </Compile> - <Compile Include="Forms\MergeTextWithSameTimeCodes.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\MergeTextWithSameTimeCodes.Designer.cs"> - <DependentUpon>MergeTextWithSameTimeCodes.cs</DependentUpon> - </Compile> - <Compile Include="Forms\MultipleReplaceNewGroup.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\MultipleReplaceNewGroup.Designer.cs"> - <DependentUpon>MultipleReplaceNewGroup.cs</DependentUpon> - </Compile> - <Compile Include="Forms\NuendoProperties.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\NuendoProperties.Designer.cs"> - <DependentUpon>NuendoProperties.cs</DependentUpon> - </Compile> - <Compile Include="Forms\EbuSaveOptions.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\EbuSaveOptions.Designer.cs"> - <DependentUpon>EbuSaveOptions.cs</DependentUpon> - </Compile> - <Compile Include="Forms\EffectKaraoke.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\EffectKaraoke.Designer.cs"> - <DependentUpon>EffectKaraoke.cs</DependentUpon> - </Compile> - <Compile Include="Forms\EffectTypewriter.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\EffectTypewriter.Designer.cs"> - <DependentUpon>EffectTypewriter.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ExportPngXml.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ExportPngXml.Designer.cs"> - <DependentUpon>ExportPngXml.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ExportText.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ExportText.Designer.cs"> - <DependentUpon>ExportText.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ExtractDateTimeInfo.cs"> - <SubType>form</SubType> - </Compile> - <Compile Include="Forms\ExtractDateTimeInfo.Designer.cs"> - <DependentUpon>ExtractDateTimeInfo.cs</DependentUpon> - </Compile> - <Compile Include="Forms\FindDialog.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\FindDialog.Designer.cs"> - <DependentUpon>FindDialog.cs</DependentUpon> - </Compile> - <Compile Include="Forms\FindSubtitleLine.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\FindSubtitleLine.Designer.cs"> - <DependentUpon>FindSubtitleLine.cs</DependentUpon> - </Compile> - <Compile Include="Forms\FixCommonErrors.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\FixCommonErrors.Designer.cs"> - <DependentUpon>FixCommonErrors.cs</DependentUpon> - </Compile> - <Compile Include="Forms\DvdSubRip.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\DvdSubRip.Designer.cs"> - <DependentUpon>DvdSubRip.cs</DependentUpon> - </Compile> - <Compile Include="Forms\DvdSubRipChooseLanguage.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\DvdSubRipChooseLanguage.Designer.cs"> - <DependentUpon>DvdSubRipChooseLanguage.cs</DependentUpon> - </Compile> - <Compile Include="Forms\GetDictionaries.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\GetDictionaries.Designer.cs"> - <DependentUpon>GetDictionaries.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\BinaryOcrChooseEditDb.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\BinaryOcrChooseEditDb.Designer.cs"> - <DependentUpon>BinaryOcrChooseEditDb.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\BinaryOcrTrain.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\BinaryOcrTrain.Designer.cs"> - <DependentUpon>BinaryOcrTrain.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\GetTesseractDictionaries.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\GetTesseractDictionaries.Designer.cs"> - <DependentUpon>GetTesseractDictionaries.cs</DependentUpon> - </Compile> - <Compile Include="Forms\HardSubExtract.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\HardSubExtract.Designer.cs"> - <DependentUpon>HardSubExtract.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Interjections.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Interjections.Designer.cs"> - <DependentUpon>Interjections.cs</DependentUpon> - </Compile> - <Compile Include="Forms\JoinSubtitles.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\JoinSubtitles.Designer.cs"> - <DependentUpon>JoinSubtitles.cs</DependentUpon> - </Compile> - <Compile Include="Forms\MergeDoubleLines.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\MergeDoubleLines.Designer.cs"> - <DependentUpon>MergeDoubleLines.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ModifySelection.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ModifySelection.Designer.cs"> - <DependentUpon>ModifySelection.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Networking\NetworkChat.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Networking\NetworkChat.Designer.cs"> - <DependentUpon>NetworkChat.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Networking\NetworkJoin.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Networking\NetworkJoin.Designer.cs"> - <DependentUpon>NetworkJoin.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Networking\NetworkLogAndInfo.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Networking\NetworkLogAndInfo.Designer.cs"> - <DependentUpon>NetworkLogAndInfo.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Networking\NetworkStart.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Networking\NetworkStart.Designer.cs"> - <DependentUpon>NetworkStart.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\DownloadTesseract4.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\DownloadTesseract4.Designer.cs"> - <DependentUpon>DownloadTesseract4.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\DownloadTesseract302.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\DownloadTesseract302.Designer.cs"> - <DependentUpon>DownloadTesseract302.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\GetTesseract302Dictionaries.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\GetTesseract302Dictionaries.Designer.cs"> - <DependentUpon>GetTesseract302Dictionaries.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\OcrPreprocessingT4.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\OcrPreprocessingT4.Designer.cs"> - <DependentUpon>OcrPreprocessingT4.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\OcrPreprocessingSettings.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\OcrPreprocessingSettings.Designer.cs"> - <DependentUpon>OcrPreprocessingSettings.cs</DependentUpon> - </Compile> - <Compile Include="Forms\OpenVideoDvd.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\OpenVideoDvd.Designer.cs"> - <DependentUpon>OpenVideoDvd.cs</DependentUpon> - </Compile> - <Compile Include="Forms\PacEncoding.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\PacEncoding.Designer.cs"> - <DependentUpon>PacEncoding.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ColumnPaste.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ColumnPaste.Designer.cs"> - <DependentUpon>ColumnPaste.cs</DependentUpon> - </Compile> - <Compile Include="Forms\PluginsGet.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\PluginsGet.Designer.cs"> - <DependentUpon>PluginsGet.cs</DependentUpon> - </Compile> - <Compile Include="Forms\PositionAndSizeForm.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ProfileChoose.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ProfileChoose.Designer.cs"> - <DependentUpon>ProfileChoose.cs</DependentUpon> - </Compile> - <Compile Include="Forms\RestoreAutoBackup.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\RestoreAutoBackup.Designer.cs"> - <DependentUpon>RestoreAutoBackup.cs</DependentUpon> - </Compile> - <Compile Include="Forms\RubyJapanese.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\RubyJapanese.Designer.cs"> - <DependentUpon>RubyJapanese.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SeekSilence.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SeekSilence.Designer.cs"> - <DependentUpon>SeekSilence.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SetSyncPoint.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SetSyncPoint.Designer.cs"> - <DependentUpon>SetSyncPoint.cs</DependentUpon> - </Compile> - <Compile Include="Forms\GoogleTranslate.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\GoogleTranslate.Designer.cs"> - <DependentUpon>GoogleTranslate.cs</DependentUpon> - </Compile> - <Compile Include="Forms\GoToLine.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\GoToLine.Designer.cs"> - <DependentUpon>GoToLine.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ImportText.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ImportText.Designer.cs"> - <DependentUpon>ImportText.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Main.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Main.Designer.cs"> - <DependentUpon>Main.cs</DependentUpon> - </Compile> - <Compile Include="Forms\MatroskaSubtitleChooser.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\MatroskaSubtitleChooser.Designer.cs"> - <DependentUpon>MatroskaSubtitleChooser.cs</DependentUpon> - </Compile> - <Compile Include="Forms\MergeShortLines.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\MergeShortLines.Designer.cs"> - <DependentUpon>MergeShortLines.cs</DependentUpon> - </Compile> - <Compile Include="Forms\MultipleReplace.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\MultipleReplace.Designer.cs"> - <DependentUpon>MultipleReplace.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\OCRSpellCheck.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\OCRSpellCheck.Designer.cs"> - <DependentUpon>OCRSpellCheck.cs</DependentUpon> - </Compile> - <Compile Include="Forms\RemoveTextFromHearImpaired.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\RemoveTextFromHearImpaired.Designer.cs"> - <DependentUpon>RemoveTextFromHearImpaired.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ReplaceDialog.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ReplaceDialog.Designer.cs"> - <DependentUpon>ReplaceDialog.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SetMinimumDisplayTimeBetweenParagraphs.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SetMinimumDisplayTimeBetweenParagraphs.Designer.cs"> - <DependentUpon>SetMinimumDisplayTimeBetweenParagraphs.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Settings.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Settings.Designer.cs"> - <DependentUpon>Settings.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SettingsFixContinuationStyle.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SettingsFixContinuationStyle.Designer.cs"> - <DependentUpon>SettingsFixContinuationStyle.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SettingsGapChoose.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SettingsGapChoose.Designer.cs"> - <DependentUpon>SettingsGapChoose.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SettingsLineWidth.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SettingsLineWidth.Designer.cs"> - <DependentUpon>SettingsLineWidth.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SettingsMpv.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SettingsMpv.Designer.cs"> - <DependentUpon>SettingsMpv.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SettingsProfile.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SettingsProfile.Designer.cs"> - <DependentUpon>SettingsProfile.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SettingsProfileExport.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SettingsProfileExport.Designer.cs"> - <DependentUpon>SettingsProfileExport.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SetVideoOffset.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SetVideoOffset.Designer.cs"> - <DependentUpon>SetVideoOffset.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ShowEarlierLater.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ShowEarlierLater.Designer.cs"> - <DependentUpon>ShowEarlierLater.cs</DependentUpon> - </Compile> - <Compile Include="Forms\ShowHistory.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\ShowHistory.Designer.cs"> - <DependentUpon>ShowHistory.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SpellCheck.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SpellCheck.Designer.cs"> - <DependentUpon>SpellCheck.cs</DependentUpon> - </Compile> - <Compile Include="Forms\DialogDoNotShowAgain.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\DialogDoNotShowAgain.Designer.cs"> - <DependentUpon>DialogDoNotShowAgain.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Split.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Split.Designer.cs"> - <DependentUpon>Split.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SplitLongLines.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SplitLongLines.Designer.cs"> - <DependentUpon>SplitLongLines.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SplitSubtitle.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SplitSubtitle.Designer.cs"> - <DependentUpon>SplitSubtitle.cs</DependentUpon> - </Compile> - <Compile Include="Forms\StartNumberingFrom.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\StartNumberingFrom.Designer.cs"> - <DependentUpon>StartNumberingFrom.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Statistics.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Statistics.Designer.cs"> - <DependentUpon>Statistics.cs</DependentUpon> - </Compile> - <Compile Include="Forms\StatusLog.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\StatusLog.Designer.cs"> - <DependentUpon>StatusLog.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Styles\StylesForm.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Styles\SubStationAlphaStylesBatchConvert.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Styles\SubStationAlphaStylesBatchConvert.Designer.cs"> - <DependentUpon>SubStationAlphaStylesBatchConvert.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Styles\SubStationAlphaStylesExport.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Styles\SubStationAlphaStylesExport.Designer.cs"> - <DependentUpon>SubStationAlphaStylesExport.cs</DependentUpon> - </Compile> - <Compile Include="Forms\SubStationAlphaProperties.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SubStationAlphaProperties.Designer.cs"> - <DependentUpon>SubStationAlphaProperties.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Styles\SubStationAlphaStyles.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Styles\SubStationAlphaStyles.Designer.cs"> - <DependentUpon>SubStationAlphaStyles.cs</DependentUpon> - </Compile> - <Compile Include="Forms\TimedTextNewLanguage.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\TimedTextNewLanguage.Designer.cs"> - <DependentUpon>TimedTextNewLanguage.cs</DependentUpon> - </Compile> - <Compile Include="Forms\TimedTextProperties.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\TimedTextProperties.Designer.cs"> - <DependentUpon>TimedTextProperties.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Styles\TimedTextStyles.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Styles\TimedTextStyles.Designer.cs"> - <DependentUpon>TimedTextStyles.cs</DependentUpon> - </Compile> - <Compile Include="Forms\TransportStreamSubtitleChooser.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\TransportStreamSubtitleChooser.Designer.cs"> - <DependentUpon>TransportStreamSubtitleChooser.cs</DependentUpon> - </Compile> - <Compile Include="Forms\UnknownSubtitle.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\UnknownSubtitle.Designer.cs"> - <DependentUpon>UnknownSubtitle.cs</DependentUpon> - </Compile> - <Compile Include="Forms\VideoControlsUndocked.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\VideoControlsUndocked.Designer.cs"> - <DependentUpon>VideoControlsUndocked.cs</DependentUpon> - </Compile> - <Compile Include="Forms\VideoError.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\VideoError.Designer.cs"> - <DependentUpon>VideoError.cs</DependentUpon> - </Compile> - <Compile Include="Forms\VideoPlayerUndocked.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\VideoPlayerUndocked.Designer.cs"> - <DependentUpon>VideoPlayerUndocked.cs</DependentUpon> - </Compile> - <Compile Include="Forms\VisualSync.cs"> - <SubType>form</SubType> - </Compile> - <Compile Include="Forms\VisualSync.Designer.cs"> - <DependentUpon>VisualSync.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\VobSubCharactersImport.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\VobSubCharactersImport.Designer.cs"> - <DependentUpon>VobSubCharactersImport.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\VobSubEditCharacters.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\VobSubEditCharacters.Designer.cs"> - <DependentUpon>VobSubEditCharacters.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\VobSubNOcrCharacterInspect.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\VobSubNOcrCharacterInspect.Designer.cs"> - <DependentUpon>VobSubNOcrCharacterInspect.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\VobSubNOcrEdit.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\VobSubNOcrEdit.Designer.cs"> - <DependentUpon>VobSubNOcrEdit.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\VobSubNOcrTrain.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\VobSubNOcrTrain.Designer.cs"> - <DependentUpon>VobSubNOcrTrain.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\VobSubOcr.cs"> - <SubType>form</SubType> - </Compile> - <Compile Include="Forms\Ocr\VobSubOcr.Designer.cs"> - <DependentUpon>VobSubOcr.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\VobSubOcrCharacter.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\VobSubOcrCharacter.Designer.cs"> - <DependentUpon>VobSubOcrCharacter.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\VobSubOcrCharacterInspect.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\VobSubOcrCharacterInspect.Designer.cs"> - <DependentUpon>VobSubOcrCharacterInspect.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\VobSubOcrNewFolder.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\VobSubOcrNewFolder.Designer.cs"> - <DependentUpon>VobSubOcrNewFolder.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\VobSubOcrNOcrCharacter.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\VobSubOcrNOcrCharacter.Designer.cs"> - <DependentUpon>VobSubOcrNOcrCharacter.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Ocr\VobSubOcrSetItalicFactor.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Ocr\VobSubOcrSetItalicFactor.Designer.cs"> - <DependentUpon>VobSubOcrSetItalicFactor.cs</DependentUpon> - </Compile> - <Compile Include="Forms\Watermark.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\Watermark.Designer.cs"> - <DependentUpon>Watermark.cs</DependentUpon> - </Compile> - <Compile Include="Forms\WaveformGenerateTimeCodes.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\WaveformGenerateTimeCodes.Designer.cs"> - <DependentUpon>WaveformGenerateTimeCodes.cs</DependentUpon> - </Compile> - <Compile Include="Forms\WaveformUndocked.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\WaveformUndocked.Designer.cs"> - <DependentUpon>WaveformUndocked.cs</DependentUpon> - </Compile> - <Compile Include="Forms\GoogleOrMicrosoftTranslate.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\GoogleOrMicrosoftTranslate.Designer.cs"> - <DependentUpon>GoogleOrMicrosoftTranslate.cs</DependentUpon> - </Compile> - <Compile Include="Forms\TextPrompt.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\TextPrompt.Designer.cs"> - <DependentUpon>TextPrompt.cs</DependentUpon> - </Compile> - <Compile Include="Forms\YouTubeAnnotationsImport.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\YouTubeAnnotationsImport.Designer.cs"> - <DependentUpon>YouTubeAnnotationsImport.cs</DependentUpon> - </Compile> - <Compile Include="Logic\ColorChooser\ColorChangedEventArgs.cs" /> - <Compile Include="Logic\ColorChooser\ColorHandler.cs" /> - <Compile Include="Logic\ColorChooser\ColorWheel.cs" /> - <Compile Include="Logic\CommandLineConvert\BluRaySupToBluRaySup.cs" /> - <Compile Include="Logic\CommandLineConvert\CommandLineConverter.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Logic\CommandLineConvert\TsToBdnXml.cs" /> - <Compile Include="Logic\CommandLineConvert\TsConvert.cs" /> - <Compile Include="Logic\CommandLineConvert\TsToBluRaySup.cs" /> - <Compile Include="Logic\DarkTheme.cs" /> - <Compile Include="Logic\FindReplaceDialogHelper.cs" /> - <Compile Include="Logic\SceneChangesGenerator.cs" /> - <Compile Include="Logic\ListViewSorter.cs" /> - <Compile Include="Logic\NativeMethods.cs" /> - <Compile Include="Logic\NikseBitmapImageSplitter.cs" /> - <Compile Include="Logic\Networking\NikseWebServiceSession.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Logic\Networking\UpdateLogEntry.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Logic\Ocr\Binary\BinaryOcrBitmap.cs" /> - <Compile Include="Logic\Ocr\Binary\BinaryOcrDb.cs" /> - <Compile Include="Logic\Ocr\MatchesToItalicStringConverter.cs" /> - <Compile Include="Logic\Ocr\ModiLanguage.cs" /> - <Compile Include="Logic\Ocr\NOcrDb.cs" /> - <Compile Include="Logic\Ocr\OcrAlphabet.cs" /> - <Compile Include="Logic\Ocr\NOcrChar.cs" /> - <Compile Include="Logic\Ocr\OcrCharacter.cs" /> - <Compile Include="Logic\Ocr\OcrFixEngine.cs" /> - <Compile Include="Logic\Ocr\OcrImage.cs" /> - <Compile Include="Logic\Ocr\NOcrPoint.cs" /> - <Compile Include="Logic\Ocr\PreprocessingSettings.cs" /> - <Compile Include="Logic\Ocr\SpellCheckOcrTextResult.cs" /> - <Compile Include="Logic\Ocr\Tesseract\TesseractMultiThreadRunner.cs" /> - <Compile Include="Logic\Ocr\Tesseract\TesseractThreadRunner.cs" /> - <Compile Include="Logic\Ocr\Tesseract\TesseractRunner.cs" /> - <Compile Include="Logic\Ocr\Tesseract\TesseractMultiRunner.cs" /> - <Compile Include="Logic\RtfTextConverterRichTextBox.cs" /> - <Compile Include="Logic\MainShortcuts.cs" /> - <Compile Include="Logic\SpellCheck\Hunspell.cs" /> - <Compile Include="Logic\SpellCheck\LinuxHunspell.cs" /> - <Compile Include="Logic\SpellCheck\MacHunspell.cs" /> - <Compile Include="Logic\SpellCheck\VoikkoSpellCheck.cs" /> - <Compile Include="Logic\SpellCheck\WindowsHunspell.cs" /> - <Compile Include="Logic\SyncContextExtensions.cs" /> - <Compile Include="Logic\TaskbarList.cs" /> - <Compile Include="Logic\TextDesigner.cs" /> - <Compile Include="Logic\TextWidth.cs" /> - <Compile Include="Logic\UiEbuSaveHelper.cs" /> - <Compile Include="Logic\UiGetPacEncoding.cs" /> - <Compile Include="Logic\UiGetYouTubeAnnotationStyles.cs" /> - <Compile Include="Logic\UiUtil.cs" /> - <Compile Include="Logic\VideoPlayers\LibMpvMono.cs" /> - <Compile Include="Logic\VideoPlayers\LibMpvDynamic.cs" /> - <Compile Include="Logic\VideoPlayers\LibVlcDynamic.cs" /> - <Compile Include="Logic\VideoPlayers\LibVlcMono.cs" /> - <Compile Include="Logic\VideoPlayers\MpcHC\MessageHandlerWindow.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Logic\VideoPlayers\MpcHC\MessageHandlerWindow.Designer.cs"> - <DependentUpon>MessageHandlerWindow.cs</DependentUpon> - </Compile> - <Compile Include="Logic\VideoPlayers\MpcHC\MpcHcCommand.cs" /> - <Compile Include="Logic\VideoPlayers\MpcHC\MpcHc.cs" /> - <Compile Include="Logic\VideoPlayers\MpcHC\NativeMethods.cs" /> - <Compile Include="Logic\VideoPlayers\QuartsPlayer.cs" /> - <Compile Include="Logic\VideoPlayers\VideoPlayer.cs" /> - <Compile Include="Logic\WordSpellChecker.cs" /> - <Compile Include="Program.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="Forms\SyncPointsSync.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="Forms\SyncPointsSync.Designer.cs"> - <DependentUpon>SyncPointsSync.cs</DependentUpon> - </Compile> - <Compile Include="Properties\Resources.Designer.cs"> - <AutoGen>True</AutoGen> - <DesignTime>True</DesignTime> - <DependentUpon>Resources.resx</DependentUpon> - </Compile> - <Compile Include="Web References\SeNetworkService\Reference.cs"> - <AutoGen>True</AutoGen> - <DesignTime>True</DesignTime> - <DependentUpon>Reference.map</DependentUpon> - </Compile> - <EmbeddedResource Include="Controls\TimeUpDown.resx"> - <DependentUpon>TimeUpDown.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Controls\AudioVisualizer.resx"> - <DependentUpon>AudioVisualizer.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\AlignmentPickerJapanese.resx"> - <DependentUpon>AlignmentPickerJapanese.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\BatchConvertMkvEnding.resx"> - <DependentUpon>BatchConvertMkvEnding.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\BatchConvertTsSettings.resx"> - <DependentUpon>BatchConvertTsSettings.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\BookmarkAdd.resx"> - <DependentUpon>BookmarkAdd.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\AddWaveformBatch.resx"> - <DependentUpon>AddWaveformBatch.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\AudioToText.resx"> - <DependentUpon>AudioToText.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\BookmarksGoTo.resx"> - <DependentUpon>BookmarksGoTo.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Cavena890SaveOptions.resx"> - <DependentUpon>Cavena890SaveOptions.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\CheckForUpdates.resx"> - <DependentUpon>CheckForUpdates.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ChooseFontName.resx"> - <DependentUpon>ChooseFontName.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ColorChooser.resx"> - <DependentUpon>ColorChooser.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\DCinema\DCinemaPropertiesInterop.resx"> - <DependentUpon>DCinemaPropertiesInterop.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\DCinema\DCinemaPropertiesSmpte.resx"> - <DependentUpon>DCinemaPropertiesSmpte.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\DoNotBreakAfterListEdit.resx"> - <DependentUpon>DoNotBreakAfterListEdit.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\About.resx"> - <DependentUpon>About.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\AddToNames.resx"> - <DependentUpon>AddToNames.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\DownloadFfmpeg.resx"> - <DependentUpon>DownloadFfmpeg.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\DvdStudioProProperties.resx"> - <DependentUpon>DvdStudioProProperties.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\EbuLanguageCode.resx"> - <DependentUpon>EbuLanguageCode.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ExportFcpXmlAdvanced.resx"> - <DependentUpon>ExportFcpXmlAdvanced.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ExportPngXmlDialogOpenFolder.resx"> - <DependentUpon>ExportPngXmlDialogOpenFolder.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ImportCdg.resx"> - <DependentUpon>ImportCdg.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ImportFinalDraft.resx"> - <DependentUpon>ImportFinalDraft.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\MultipleReplaceExportImport.resx"> - <DependentUpon>MultipleReplaceExportImport.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\NetflixFixErrors.resx"> - <DependentUpon>NetflixFixErrors.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\AddBeterMultiMatch.resx"> - <DependentUpon>AddBeterMultiMatch.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\AddBetterMultiMatchNOcr.resx"> - <DependentUpon>AddBetterMultiMatchNOcr.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\AddToOcrReplaceList.resx"> - <DependentUpon>AddToOcrReplaceList.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\AddToUserDic.resx"> - <DependentUpon>AddToUserDic.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\AddWaveform.resx"> - <DependentUpon>AddWaveform.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\AlignmentPicker.resx"> - <DependentUpon>AlignmentPicker.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ApplyDurationLimits.resx"> - <DependentUpon>ApplyDurationLimits.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\BatchConvert.resx"> - <DependentUpon>BatchConvert.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Beamer.resx"> - <DependentUpon>Beamer.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ChangeCasing.resx"> - <DependentUpon>ChangeCasing.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ChangeFrameRate.resx"> - <DependentUpon>ChangeFrameRate.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ChangeSpeedInPercent.resx"> - <DependentUpon>ChangeSpeedInPercent.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ChooseAudioTrack.resx"> - <DependentUpon>ChooseAudioTrack.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ChooseEncoding.resx"> - <DependentUpon>ChooseEncoding.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\AdjustDisplayDuration.resx"> - <DependentUpon>AdjustDisplayDuration.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ChooseResolution.resx"> - <DependentUpon>ChooseResolution.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ChooseStyle.resx"> - <DependentUpon>ChooseStyle.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\DurationsBridgeGaps.resx"> - <DependentUpon>DurationsBridgeGaps.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\EbuColorPicker.resx"> - <DependentUpon>EbuColorPicker.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ExportCustomText.resx"> - <DependentUpon>ExportCustomText.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ExportCustomTextFormat.resx"> - <DependentUpon>ExportCustomTextFormat.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ExportPngXmlPreview.resx"> - <DependentUpon>ExportPngXmlPreview.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ExportTextST.resx"> - <DependentUpon>ExportTextST.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\FcpProperties.resx"> - <DependentUpon>FcpProperties.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ImportImages.resx"> - <DependentUpon>ImportImages.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ImportSceneChanges.resx"> - <DependentUpon>ImportSceneChanges.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ImportUnknownFormat.resx"> - <DependentUpon>ImportUnknownFormat.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\MeasurementConverter.resx"> - <DependentUpon>MeasurementConverter.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\MergeTextWithSameTimeCodes.resx"> - <DependentUpon>MergeTextWithSameTimeCodes.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\MultipleReplaceNewGroup.resx"> - <DependentUpon>MultipleReplaceNewGroup.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\NuendoProperties.resx"> - <DependentUpon>NuendoProperties.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\EbuSaveOptions.resx"> - <DependentUpon>EbuSaveOptions.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\EffectKaraoke.resx"> - <DependentUpon>EffectKaraoke.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\EffectTypewriter.resx"> - <DependentUpon>EffectTypewriter.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ExportPngXml.resx"> - <DependentUpon>ExportPngXml.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ExportText.resx"> - <DependentUpon>ExportText.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ExtractDateTimeInfo.resx"> - <DependentUpon>ExtractDateTimeInfo.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\FindDialog.resx"> - <DependentUpon>FindDialog.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\FindSubtitleLine.resx"> - <DependentUpon>FindSubtitleLine.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\FixCommonErrors.resx"> - <DependentUpon>FixCommonErrors.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\DvdSubRip.resx"> - <DependentUpon>DvdSubRip.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\DvdSubRipChooseLanguage.resx"> - <DependentUpon>DvdSubRipChooseLanguage.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\GetDictionaries.resx"> - <DependentUpon>GetDictionaries.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\BinaryOcrChooseEditDb.resx"> - <DependentUpon>BinaryOcrChooseEditDb.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\BinaryOcrTrain.resx"> - <DependentUpon>BinaryOcrTrain.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\GetTesseractDictionaries.resx"> - <DependentUpon>GetTesseractDictionaries.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\HardSubExtract.resx"> - <DependentUpon>HardSubExtract.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Interjections.resx"> - <DependentUpon>Interjections.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\JoinSubtitles.resx"> - <DependentUpon>JoinSubtitles.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\MergeDoubleLines.resx"> - <DependentUpon>MergeDoubleLines.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ModifySelection.resx"> - <DependentUpon>ModifySelection.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Networking\NetworkChat.resx"> - <DependentUpon>NetworkChat.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Networking\NetworkJoin.resx"> - <DependentUpon>NetworkJoin.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Networking\NetworkLogAndInfo.resx"> - <DependentUpon>NetworkLogAndInfo.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Networking\NetworkStart.resx"> - <DependentUpon>NetworkStart.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\DownloadTesseract4.resx"> - <DependentUpon>DownloadTesseract4.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\DownloadTesseract302.resx"> - <DependentUpon>DownloadTesseract302.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\GetTesseract302Dictionaries.resx"> - <DependentUpon>GetTesseract302Dictionaries.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\OcrPreprocessingT4.resx"> - <DependentUpon>OcrPreprocessingT4.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\OcrPreprocessingSettings.resx"> - <DependentUpon>OcrPreprocessingSettings.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\OpenVideoDvd.resx"> - <DependentUpon>OpenVideoDvd.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\PacEncoding.resx"> - <DependentUpon>PacEncoding.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ColumnPaste.resx"> - <DependentUpon>ColumnPaste.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\PluginsGet.resx"> - <DependentUpon>PluginsGet.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ProfileChoose.resx"> - <DependentUpon>ProfileChoose.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\RestoreAutoBackup.resx"> - <DependentUpon>RestoreAutoBackup.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\RubyJapanese.resx"> - <DependentUpon>RubyJapanese.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SeekSilence.resx"> - <DependentUpon>SeekSilence.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SetSyncPoint.resx"> - <DependentUpon>SetSyncPoint.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\GoogleTranslate.resx"> - <DependentUpon>GoogleTranslate.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\GoToLine.resx"> - <DependentUpon>GoToLine.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ImportText.resx"> - <DependentUpon>ImportText.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\MatroskaSubtitleChooser.resx"> - <DependentUpon>MatroskaSubtitleChooser.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\MergeShortLines.resx"> - <DependentUpon>MergeShortLines.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\RemoveTextFromHearImpaired.resx"> - <DependentUpon>RemoveTextFromHearImpaired.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ReplaceDialog.resx"> - <DependentUpon>ReplaceDialog.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SetMinimumDisplayTimeBetweenParagraphs.resx"> - <DependentUpon>SetMinimumDisplayTimeBetweenParagraphs.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Settings.resx"> - <DependentUpon>Settings.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SettingsFixContinuationStyle.resx"> - <DependentUpon>SettingsFixContinuationStyle.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SettingsGapChoose.resx"> - <DependentUpon>SettingsGapChoose.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SettingsLineWidth.resx"> - <DependentUpon>SettingsLineWidth.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SettingsMpv.resx"> - <DependentUpon>SettingsMpv.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SettingsProfile.resx"> - <DependentUpon>SettingsProfile.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SettingsProfileExport.resx"> - <DependentUpon>SettingsProfileExport.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SetVideoOffset.resx"> - <DependentUpon>SetVideoOffset.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ShowHistory.resx"> - <DependentUpon>ShowHistory.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SpellCheck.resx"> - <DependentUpon>SpellCheck.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\DialogDoNotShowAgain.resx"> - <DependentUpon>DialogDoNotShowAgain.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Split.resx"> - <DependentUpon>Split.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SplitLongLines.resx"> - <DependentUpon>SplitLongLines.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SplitSubtitle.resx"> - <DependentUpon>SplitSubtitle.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\StartNumberingFrom.resx"> - <DependentUpon>StartNumberingFrom.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Statistics.resx"> - <DependentUpon>Statistics.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\StatusLog.resx"> - <DependentUpon>StatusLog.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Styles\SubStationAlphaStylesBatchConvert.resx"> - <DependentUpon>SubStationAlphaStylesBatchConvert.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Styles\SubStationAlphaStylesExport.resx"> - <DependentUpon>SubStationAlphaStylesExport.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SubStationAlphaProperties.resx"> - <DependentUpon>SubStationAlphaProperties.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Styles\SubStationAlphaStyles.resx"> - <DependentUpon>SubStationAlphaStyles.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\TimedTextNewLanguage.resx"> - <DependentUpon>TimedTextNewLanguage.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\TimedTextProperties.resx"> - <DependentUpon>TimedTextProperties.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Styles\TimedTextStyles.resx"> - <DependentUpon>TimedTextStyles.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\TransportStreamSubtitleChooser.resx"> - <DependentUpon>TransportStreamSubtitleChooser.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\UnknownSubtitle.resx"> - <DependentUpon>UnknownSubtitle.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\VideoControlsUndocked.resx"> - <DependentUpon>VideoControlsUndocked.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\VideoPlayerUndocked.resx"> - <DependentUpon>VideoPlayerUndocked.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\VisualSync.resx"> - <DependentUpon>VisualSync.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\VobSubCharactersImport.resx"> - <DependentUpon>VobSubCharactersImport.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\VobSubNOcrCharacterInspect.resx"> - <DependentUpon>VobSubNOcrCharacterInspect.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\VobSubNOcrEdit.resx"> - <DependentUpon>VobSubNOcrEdit.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\VobSubNOcrTrain.resx"> - <DependentUpon>VobSubNOcrTrain.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\VobSubOcr.resx"> - <DependentUpon>VobSubOcr.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\VobSubOcrCharacter.resx"> - <DependentUpon>VobSubOcrCharacter.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\VobSubOcrCharacterInspect.resx"> - <DependentUpon>VobSubOcrCharacterInspect.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\VobSubOcrNewFolder.resx"> - <DependentUpon>VobSubOcrNewFolder.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\VobSubOcrNOcrCharacter.resx"> - <DependentUpon>VobSubOcrNOcrCharacter.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\VobSubOcrSetItalicFactor.resx"> - <DependentUpon>VobSubOcrSetItalicFactor.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Watermark.resx"> - <DependentUpon>Watermark.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\WaveformGenerateTimeCodes.resx"> - <DependentUpon>WaveformGenerateTimeCodes.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\WaveformUndocked.resx"> - <DependentUpon>WaveformUndocked.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\GoogleOrMicrosoftTranslate.resx"> - <DependentUpon>GoogleOrMicrosoftTranslate.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\TextPrompt.resx"> - <DependentUpon>TextPrompt.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Forms\YouTubeAnnotationsImport.resx"> - <DependentUpon>YouTubeAnnotationsImport.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Logic\VideoPlayers\MpcHC\MessageHandlerWindow.resx"> - <DependentUpon>MessageHandlerWindow.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="Properties\Resources.resx"> - <Generator>PublicResXFileCodeGenerator</Generator> - <SubType>Designer</SubType> - <LastGenOutput>Resources.Designer.cs</LastGenOutput> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Main.resx"> - <DependentUpon>Main.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\SyncPointsSync.resx"> - <DependentUpon>SyncPointsSync.cs</DependentUpon> - </EmbeddedResource> - <None Include="app.config" /> - <None Include="packages.config"> - <SubType>Designer</SubType> - </None> - <None Include="Properties\Settings.settings"> - <Generator>SettingsSingleFileGenerator</Generator> - <LastGenOutput>Settings.Designer.cs</LastGenOutput> - </None> - <Compile Include="Properties\Settings.Designer.cs"> - <AutoGen>True</AutoGen> - <DependentUpon>Settings.settings</DependentUpon> - <DesignTimeSharedInput>True</DesignTimeSharedInput> - </Compile> - <EmbeddedResource Include="Resources\HunspellDictionaries.xml.gz" /> - <EmbeddedResource Include="Resources\HunspellBackupDictionaries.xml.gz" /> - <EmbeddedResource Include="Resources\TesseractDictionaries.xml.gz" /> - <None Include="Resources\nOCR_TesseractHelper.xml.gz" /> - <None Include="Resources\SMPTE-428-7-2007-DCST.xsd"> - <SubType>Designer</SubType> - </None> - <EmbeddedResource Include="Resources\SMPTE-428-7-2007-DCST.xsd.gz" /> - <None Include="Resources\SMPTE-428-7-2010-DCST.xsd"> - <SubType>Designer</SubType> - </None> - <EmbeddedResource Include="Resources\SMPTE-428-7-2010-DCST.xsd.gz" /> - <None Include="Resources\SMPTE-428-7-2014-DCST.xsd"> - <SubType>Designer</SubType> - </None> - <EmbeddedResource Include="Resources\SMPTE-428-7-2014-DCST.xsd.gz" /> - <None Include="Web References\SeNetworkService\Reference.map"> - <Generator>MSDiscoCodeGenerator</Generator> - <LastGenOutput>Reference.cs</LastGenOutput> - </None> - <None Include="Web References\SeNetworkService\SeSequence.datasource"> - <DependentUpon>Reference.map</DependentUpon> - </None> - <None Include="Web References\SeNetworkService\SeService.wsdl" /> - <None Include="Web References\SeNetworkService\SeUpdate.datasource"> - <DependentUpon>Reference.map</DependentUpon> - </None> - <None Include="Web References\SeNetworkService\SeUser.datasource"> - <DependentUpon>Reference.map</DependentUpon> - </None> - </ItemGroup> - <ItemGroup> - <Content Include="DLLs\Voikkox64.dll" /> - <Content Include="DLLs\Voikkox86.dll" /> - <Content Include="Languages\ar-EG.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\bg-BG.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\br-FR.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\ca-ES.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\cs-CZ.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\da-DK.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\de-DE.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\el-GR.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\es-AR.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\es-ES.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\es-MX.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\eu-ES.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\fa-IR.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\fi-FI.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\fr-FR.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\hr-HR.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\hu-HU.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\id-ID.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\it-IT.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\ja-JP.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\ko-KR.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\mk-MK.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\nb-NO.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\nl-NL.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\pl-PL.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\pt-BR.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\pt-PT.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\ro-RO.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\ru-RU.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\sl-SI.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\sr-Cyrl-RS.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\sr-Latn-RS.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\sv-SE.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\th-TH.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\tr-TR.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\uk-UA.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\vi-VN.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\zh-Hans.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <Content Include="Languages\zh-TW.xml"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> - </Content> - <None Include="Web References\SeNetworkService\SeService.disco" /> - <None Include="DLLs\Interop.QuartzTypeLib.dll" /> - <Content Include="..\Changelog.txt" /> - <Content Include="..\LICENSE.txt" /> - <EmbeddedResource Include="Controls\VideoPlayerContainer.resx"> - <DependentUpon>VideoPlayerContainer.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\AutoBreakUnbreakLines.resx"> - <DependentUpon>AutoBreakUnbreakLines.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ChangeCasingNames.resx"> - <DependentUpon>ChangeCasingNames.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ChooseLanguage.resx"> - <DependentUpon>ChooseLanguage.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Compare.resx"> - <DependentUpon>Compare.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\MultipleReplace.resx"> - <DependentUpon>MultipleReplace.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\OCRSpellCheck.resx"> - <DependentUpon>OCRSpellCheck.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\ShowEarlierLater.resx"> - <DependentUpon>ShowEarlierLater.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\VideoError.resx"> - <DependentUpon>VideoError.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="Forms\Ocr\VobSubEditCharacters.resx"> - <DependentUpon>VobSubEditCharacters.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <None Include="Icons\connect.png" /> - <None Include="Icons\Donate.png" /> - <Content Include="Icons\SE.ico" /> - <Content Include="Icons\Find.png" /> - <Content Include="Icons\FixCommonErrors.png" /> - <Content Include="Icons\Help.png" /> - <Content Include="Icons\New.png" /> - <Content Include="Icons\Open.png" /> - <Content Include="Icons\RemoveTextForHI.png" /> - <Content Include="Icons\Replace.png" /> - <Content Include="Icons\Save.png" /> - <Content Include="Icons\SaveAs.png" /> - <Content Include="Icons\Settings.png" /> - <Content Include="Icons\SpellCheck.png" /> - <Content Include="Icons\VideoToggle.png" /> - <Content Include="Icons\VisualSync.png" /> - <Content Include="Icons\WaveformToggle.png" /> - <None Include="Resources\bookmark22.png" /> - <None Include="Resources\pictureBoxFS.Image.png" /> - <None Include="Resources\pictureBoxFSDown.Image.png" /> - <None Include="Resources\pictureBoxFSOver.Image.png" /> - <None Include="Resources\pictureBoxFastForward.Image.png" /> - <None Include="Resources\pictureBoxFastForwardMouseDown.Image.png" /> - <None Include="Resources\pictureBoxFastForwardMouseOver.Image.png" /> - <None Include="Resources\pictureBoxNoFS.Image.png" /> - <None Include="Resources\pictureBoxNoFSDown.Image.png" /> - <None Include="Resources\pictureBoxNoFSOver.Image.png" /> - <None Include="Resources\pictureBoxReverse.Image.png" /> - <None Include="Resources\pictureBoxReverseMouseDown.Image.png" /> - <None Include="Resources\pictureBoxReverseMouseOver.Image.png" /> - <None Include="Resources\Transparent Background.png" /> - <Content Include="Resources\TesseractDictionaries.xml"> - <SubType>Designer</SubType> - </Content> - <Content Include="Resources\HunspellBackupDictionaries.xml"> - <SubType>Designer</SubType> - </Content> - <Content Include="Resources\HunspellDictionaries.xml"> - <SubType>Designer</SubType> - </Content> - </ItemGroup> - <ItemGroup> - <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> - <Visible>False</Visible> - <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName> - <Install>false</Install> - </BootstrapperPackage> - <BootstrapperPackage Include="Microsoft.Net.Framework.2.0"> - <Visible>False</Visible> - <ProductName>.NET Framework 2.0 %28x86%29</ProductName> - <Install>true</Install> - </BootstrapperPackage> - <BootstrapperPackage Include="Microsoft.Net.Framework.3.0"> - <Visible>False</Visible> - <ProductName>.NET Framework 3.0 %28x86%29</ProductName> - <Install>false</Install> - </BootstrapperPackage> - <BootstrapperPackage Include="Microsoft.Net.Framework.3.5"> - <Visible>False</Visible> - <ProductName>.NET Framework 3.5</ProductName> - <Install>false</Install> - </BootstrapperPackage> - <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> - <Visible>False</Visible> - <ProductName>.NET Framework 3.5 SP1</ProductName> - <Install>false</Install> - </BootstrapperPackage> - <BootstrapperPackage Include="Microsoft.Visual.C++.10.0.x86"> - <Visible>False</Visible> - <ProductName>Visual C++ 2010 Runtime Libraries %28x86%29</ProductName> - <Install>true</Install> - </BootstrapperPackage> - <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> - <Visible>False</Visible> - <ProductName>Windows Installer 3.1</ProductName> - <Install>true</Install> - </BootstrapperPackage> - </ItemGroup> - <ItemGroup> - <WebReferences Include="Web References\" /> - </ItemGroup> - <ItemGroup> - <WebReferenceUrl Include="http://localhost:2782/se/SeService.asmx"> - <UrlBehavior>Dynamic</UrlBehavior> - <RelPath>Web References\SeNetworkService\</RelPath> - <UpdateFromURL>http://localhost:2782/se/SeService.asmx</UpdateFromURL> - <ServiceLocationURL> - </ServiceLocationURL> - <CachedDynamicPropName> - </CachedDynamicPropName> - <CachedAppSettingsObjectName>Settings</CachedAppSettingsObjectName> - <CachedSettingsPropName>SubtitleEdit_SeNetworkService_SeService</CachedSettingsPropName> - </WebReferenceUrl> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\libse\LibSE.csproj"> - <Project>{3e3cb28f-3a7b-430f-9eb3-0d6c1e53b753}</Project> - <Name>LibSE</Name> - <Private>True</Private> - </ProjectReference> - </ItemGroup> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <ItemGroup> - <HunspellAssemblies Include="Hunspellx64.dll"> - <Visible>false</Visible> - </HunspellAssemblies> - <HunspellAssemblies Include="Hunspellx86.dll"> - <Visible>false</Visible> - </HunspellAssemblies> - </ItemGroup> - <ItemGroup /> - <Target Name="BeforeCompile"> - <XmlPeek XmlInputPath="$(SolutionDir)packages.config" Query="//package[@id='NHunspell']/@version"> - <Output TaskParameter="Result" PropertyName="HunspellVersion" /> - </XmlPeek> - <PropertyGroup> - <HunspellDir>$(SolutionDir)packages\NHunspell.$(HunspellVersion)\content\</HunspellDir> - </PropertyGroup> - <Copy SourceFiles="@(HunspellAssemblies -> '$(HunspellDir)%(Identity)')" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="True" /> - <Exec Command="%22$(SolutionDir)..\build_helpers.bat%22 rev %22$(ConfigurationName)%22" /> - </Target> - <Target Name="BeforeClean"> - <Delete Files="@(HunspellAssemblies -> '$(OutputPath)%(Identity)')" /> - </Target> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> - --> +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="packages\ILRepack.2.0.18\build\ILRepack.props" Condition="Exists('packages\ILRepack.2.0.18\build\ILRepack.props')" /> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <AppDesignerFolder>Properties</AppDesignerFolder> + <ApplicationIcon>Icons\SE.ico</ApplicationIcon> + <AssemblyName>SubtitleEdit</AssemblyName> + <BootstrapperEnabled>true</BootstrapperEnabled> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <FileAlignment>512</FileAlignment> + <ManifestCertificateThumbprint>DCCE7922B5E425ADB221E06DC2FB405664CF8F63</ManifestCertificateThumbprint> + <MapFileExtensions>true</MapFileExtensions> + <OutputType>WinExe</OutputType> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{511A5B59-1C35-4719-8536-23B19AF9B21A}</ProjectGuid> + <PublishWizardCompleted>true</PublishWizardCompleted> + <RestorePackages>true</RestorePackages> + <RootNamespace>Nikse.SubtitleEdit</RootNamespace> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">.\</SolutionDir> + <TargetFrameworkProfile> + </TargetFrameworkProfile> + <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <DefineConstants>TRACE;DEBUG</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <PlatformTarget>AnyCPU</PlatformTarget> + <UseVSHostingProcess>true</UseVSHostingProcess> + <WarningLevel>4</WarningLevel> + <Prefer32Bit>false</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> + <DebugType>pdbonly</DebugType> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <PlatformTarget>AnyCPU</PlatformTarget> + <UseVSHostingProcess>true</UseVSHostingProcess> + <WarningLevel>4</WarningLevel> + <Prefer32Bit>false</Prefer32Bit> + </PropertyGroup> + <ItemGroup> + <Reference Include="Interop.QuartzTypeLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> + <EmbedInteropTypes>True</EmbedInteropTypes> + <HintPath>DLLs\Interop.QuartzTypeLib.dll</HintPath> + <SpecificVersion>False</SpecificVersion> + </Reference> + <Reference Include="NHunspell, Version=1.2.5554.16953, Culture=neutral, PublicKeyToken=1ac793ea843b4366, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>packages\NHunspell.1.2.5554.16953\lib\net\NHunspell.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.EnterpriseServices" /> + <Reference Include="System.Web.Services" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Controls\SETextBox.cs"> + <SubType>Component</SubType> + </Compile> + <Compile Include="Controls\VideoPlayerContainer.cs"> + <SubType>Component</SubType> + </Compile> + <Compile Include="Controls\TimeUpDown.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Controls\TimeUpDown.Designer.cs"> + <DependentUpon>TimeUpDown.cs</DependentUpon> + </Compile> + <Compile Include="Controls\AudioVisualizer.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Controls\AudioVisualizer.Designer.cs"> + <DependentUpon>AudioVisualizer.cs</DependentUpon> + </Compile> + <Compile Include="Forms\AlignmentPickerJapanese.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\AlignmentPickerJapanese.Designer.cs"> + <DependentUpon>AlignmentPickerJapanese.cs</DependentUpon> + </Compile> + <Compile Include="Forms\BatchConvertMkvEnding.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\BatchConvertMkvEnding.Designer.cs"> + <DependentUpon>BatchConvertMkvEnding.cs</DependentUpon> + </Compile> + <Compile Include="Forms\BatchConvertTsSettings.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\BatchConvertTsSettings.Designer.cs"> + <DependentUpon>BatchConvertTsSettings.cs</DependentUpon> + </Compile> + <Compile Include="Forms\BookmarkAdd.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\BookmarkAdd.Designer.cs"> + <DependentUpon>BookmarkAdd.cs</DependentUpon> + </Compile> + <Compile Include="Forms\AddWaveformBatch.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\AddWaveformBatch.Designer.cs"> + <DependentUpon>AddWaveformBatch.cs</DependentUpon> + </Compile> + <Compile Include="Forms\AudioToText.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\AudioToText.Designer.cs"> + <DependentUpon>AudioToText.cs</DependentUpon> + </Compile> + <Compile Include="Forms\BookmarksGoTo.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\BookmarksGoTo.Designer.cs"> + <DependentUpon>BookmarksGoTo.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Cavena890SaveOptions.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Cavena890SaveOptions.Designer.cs"> + <DependentUpon>Cavena890SaveOptions.cs</DependentUpon> + </Compile> + <Compile Include="Forms\CheckForUpdates.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\CheckForUpdates.Designer.cs"> + <DependentUpon>CheckForUpdates.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ChooseFontName.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ChooseFontName.Designer.cs"> + <DependentUpon>ChooseFontName.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ColorChooser.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\DCinema\DCinemaPropertiesInterop.cs"> + <SubType>form</SubType> + </Compile> + <Compile Include="Forms\DCinema\DCinemaPropertiesInterop.Designer.cs"> + <DependentUpon>DCinemaPropertiesInterop.cs</DependentUpon> + </Compile> + <Compile Include="Forms\DCinema\DCinemaPropertiesSmpte.cs"> + <SubType>form</SubType> + </Compile> + <Compile Include="Forms\DCinema\DCinemaPropertiesSmpte.Designer.cs"> + <DependentUpon>DCinemaPropertiesSmpte.cs</DependentUpon> + </Compile> + <Compile Include="Forms\DoNotBreakAfterListEdit.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\DoNotBreakAfterListEdit.Designer.cs"> + <DependentUpon>DoNotBreakAfterListEdit.cs</DependentUpon> + </Compile> + <Compile Include="Forms\About.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\About.Designer.cs"> + <DependentUpon>About.cs</DependentUpon> + </Compile> + <Compile Include="Controls\SubtitleListView.cs"> + <SubType>Component</SubType> + </Compile> + <Compile Include="Forms\AddToNames.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\AddToNames.Designer.cs"> + <DependentUpon>AddToNames.cs</DependentUpon> + </Compile> + <Compile Include="Forms\DownloadFfmpeg.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\DownloadFfmpeg.Designer.cs"> + <DependentUpon>DownloadFfmpeg.cs</DependentUpon> + </Compile> + <Compile Include="Forms\DvdStudioProProperties.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\DvdStudioProProperties.Designer.cs"> + <DependentUpon>DvdStudioProProperties.cs</DependentUpon> + </Compile> + <Compile Include="Forms\EbuLanguageCode.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\EbuLanguageCode.Designer.cs"> + <DependentUpon>EbuLanguageCode.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ExportFcpXmlAdvanced.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ExportFcpXmlAdvanced.Designer.cs"> + <DependentUpon>ExportFcpXmlAdvanced.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ExportPngXmlDialogOpenFolder.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ExportPngXmlDialogOpenFolder.Designer.cs"> + <DependentUpon>ExportPngXmlDialogOpenFolder.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ImportCdg.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ImportCdg.Designer.cs"> + <DependentUpon>ImportCdg.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ImportFinalDraft.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ImportFinalDraft.Designer.cs"> + <DependentUpon>ImportFinalDraft.cs</DependentUpon> + </Compile> + <Compile Include="Forms\MultipleReplaceExportImport.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\MultipleReplaceExportImport.Designer.cs"> + <DependentUpon>MultipleReplaceExportImport.cs</DependentUpon> + </Compile> + <Compile Include="Forms\NetflixFixErrors.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\NetflixFixErrors.Designer.cs"> + <DependentUpon>NetflixFixErrors.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\AddBeterMultiMatch.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\AddBeterMultiMatch.Designer.cs"> + <DependentUpon>AddBeterMultiMatch.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\AddBetterMultiMatchNOcr.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\AddBetterMultiMatchNOcr.Designer.cs"> + <DependentUpon>AddBetterMultiMatchNOcr.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\AddToOcrReplaceList.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\AddToOcrReplaceList.Designer.cs"> + <DependentUpon>AddToOcrReplaceList.cs</DependentUpon> + </Compile> + <Compile Include="Forms\AddToUserDic.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\AddToUserDic.Designer.cs"> + <DependentUpon>AddToUserDic.cs</DependentUpon> + </Compile> + <Compile Include="Forms\AddWaveform.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\AddWaveform.Designer.cs"> + <DependentUpon>AddWaveform.cs</DependentUpon> + </Compile> + <Compile Include="Forms\AlignmentPicker.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\AlignmentPicker.Designer.cs"> + <DependentUpon>AlignmentPicker.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ApplyDurationLimits.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ApplyDurationLimits.Designer.cs"> + <DependentUpon>ApplyDurationLimits.cs</DependentUpon> + </Compile> + <Compile Include="Forms\AutoBreakUnbreakLines.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\AutoBreakUnbreakLines.Designer.cs"> + <DependentUpon>AutoBreakUnbreakLines.cs</DependentUpon> + </Compile> + <Compile Include="Forms\BatchConvert.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\BatchConvert.Designer.cs"> + <DependentUpon>BatchConvert.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Beamer.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Beamer.Designer.cs"> + <DependentUpon>Beamer.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ChangeCasing.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ChangeCasing.Designer.cs"> + <DependentUpon>ChangeCasing.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ChangeCasingNames.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ChangeCasingNames.Designer.cs"> + <DependentUpon>ChangeCasingNames.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ChangeFrameRate.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ChangeFrameRate.Designer.cs"> + <DependentUpon>ChangeFrameRate.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ChangeSpeedInPercent.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ChangeSpeedInPercent.Designer.cs"> + <DependentUpon>ChangeSpeedInPercent.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ChooseAudioTrack.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ChooseAudioTrack.Designer.cs"> + <DependentUpon>ChooseAudioTrack.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ChooseLanguage.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ChooseLanguage.Designer.cs"> + <DependentUpon>ChooseLanguage.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ChooseEncoding.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ChooseEncoding.Designer.cs"> + <DependentUpon>ChooseEncoding.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ChooseResolution.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ChooseResolution.Designer.cs"> + <DependentUpon>ChooseResolution.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ChooseStyle.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ChooseStyle.Designer.cs"> + <DependentUpon>ChooseStyle.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Compare.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Compare.Designer.cs"> + <DependentUpon>Compare.cs</DependentUpon> + </Compile> + <Compile Include="Forms\AdjustDisplayDuration.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\AdjustDisplayDuration.Designer.cs"> + <DependentUpon>AdjustDisplayDuration.cs</DependentUpon> + </Compile> + <Compile Include="Forms\DurationsBridgeGaps.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\DurationsBridgeGaps.Designer.cs"> + <DependentUpon>DurationsBridgeGaps.cs</DependentUpon> + </Compile> + <Compile Include="Forms\EbuColorPicker.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\EbuColorPicker.Designer.cs"> + <DependentUpon>EbuColorPicker.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ExportCustomText.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ExportCustomText.Designer.cs"> + <DependentUpon>ExportCustomText.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ExportCustomTextFormat.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ExportCustomTextFormat.Designer.cs"> + <DependentUpon>ExportCustomTextFormat.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ExportPngXmlPreview.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ExportPngXmlPreview.Designer.cs"> + <DependentUpon>ExportPngXmlPreview.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ExportTextST.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ExportTextST.Designer.cs"> + <DependentUpon>ExportTextST.cs</DependentUpon> + </Compile> + <Compile Include="Forms\FcpProperties.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\FcpProperties.Designer.cs"> + <DependentUpon>FcpProperties.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ImportImages.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ImportImages.Designer.cs"> + <DependentUpon>ImportImages.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ImportSceneChanges.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ImportSceneChanges.Designer.cs"> + <DependentUpon>ImportSceneChanges.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ImportUnknownFormat.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ImportUnknownFormat.Designer.cs"> + <DependentUpon>ImportUnknownFormat.cs</DependentUpon> + </Compile> + <Compile Include="Forms\MeasurementConverter.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\MeasurementConverter.Designer.cs"> + <DependentUpon>MeasurementConverter.cs</DependentUpon> + </Compile> + <Compile Include="Forms\MergeTextWithSameTimeCodes.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\MergeTextWithSameTimeCodes.Designer.cs"> + <DependentUpon>MergeTextWithSameTimeCodes.cs</DependentUpon> + </Compile> + <Compile Include="Forms\MultipleReplaceNewGroup.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\MultipleReplaceNewGroup.Designer.cs"> + <DependentUpon>MultipleReplaceNewGroup.cs</DependentUpon> + </Compile> + <Compile Include="Forms\NuendoProperties.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\NuendoProperties.Designer.cs"> + <DependentUpon>NuendoProperties.cs</DependentUpon> + </Compile> + <Compile Include="Forms\EbuSaveOptions.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\EbuSaveOptions.Designer.cs"> + <DependentUpon>EbuSaveOptions.cs</DependentUpon> + </Compile> + <Compile Include="Forms\EffectKaraoke.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\EffectKaraoke.Designer.cs"> + <DependentUpon>EffectKaraoke.cs</DependentUpon> + </Compile> + <Compile Include="Forms\EffectTypewriter.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\EffectTypewriter.Designer.cs"> + <DependentUpon>EffectTypewriter.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ExportPngXml.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ExportPngXml.Designer.cs"> + <DependentUpon>ExportPngXml.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ExportText.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ExportText.Designer.cs"> + <DependentUpon>ExportText.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ExtractDateTimeInfo.cs"> + <SubType>form</SubType> + </Compile> + <Compile Include="Forms\ExtractDateTimeInfo.Designer.cs"> + <DependentUpon>ExtractDateTimeInfo.cs</DependentUpon> + </Compile> + <Compile Include="Forms\FindDialog.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\FindDialog.Designer.cs"> + <DependentUpon>FindDialog.cs</DependentUpon> + </Compile> + <Compile Include="Forms\FindSubtitleLine.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\FindSubtitleLine.Designer.cs"> + <DependentUpon>FindSubtitleLine.cs</DependentUpon> + </Compile> + <Compile Include="Forms\FixCommonErrors.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\FixCommonErrors.Designer.cs"> + <DependentUpon>FixCommonErrors.cs</DependentUpon> + </Compile> + <Compile Include="Forms\DvdSubRip.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\DvdSubRip.Designer.cs"> + <DependentUpon>DvdSubRip.cs</DependentUpon> + </Compile> + <Compile Include="Forms\DvdSubRipChooseLanguage.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\DvdSubRipChooseLanguage.Designer.cs"> + <DependentUpon>DvdSubRipChooseLanguage.cs</DependentUpon> + </Compile> + <Compile Include="Forms\GetDictionaries.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\GetDictionaries.Designer.cs"> + <DependentUpon>GetDictionaries.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\BinaryOcrChooseEditDb.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\BinaryOcrChooseEditDb.Designer.cs"> + <DependentUpon>BinaryOcrChooseEditDb.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\BinaryOcrTrain.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\BinaryOcrTrain.Designer.cs"> + <DependentUpon>BinaryOcrTrain.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\GetTesseractDictionaries.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\GetTesseractDictionaries.Designer.cs"> + <DependentUpon>GetTesseractDictionaries.cs</DependentUpon> + </Compile> + <Compile Include="Forms\HardSubExtract.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\HardSubExtract.Designer.cs"> + <DependentUpon>HardSubExtract.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Interjections.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Interjections.Designer.cs"> + <DependentUpon>Interjections.cs</DependentUpon> + </Compile> + <Compile Include="Forms\JoinSubtitles.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\JoinSubtitles.Designer.cs"> + <DependentUpon>JoinSubtitles.cs</DependentUpon> + </Compile> + <Compile Include="Forms\MergeDoubleLines.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\MergeDoubleLines.Designer.cs"> + <DependentUpon>MergeDoubleLines.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ModifySelection.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ModifySelection.Designer.cs"> + <DependentUpon>ModifySelection.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Networking\NetworkChat.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Networking\NetworkChat.Designer.cs"> + <DependentUpon>NetworkChat.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Networking\NetworkJoin.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Networking\NetworkJoin.Designer.cs"> + <DependentUpon>NetworkJoin.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Networking\NetworkLogAndInfo.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Networking\NetworkLogAndInfo.Designer.cs"> + <DependentUpon>NetworkLogAndInfo.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Networking\NetworkStart.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Networking\NetworkStart.Designer.cs"> + <DependentUpon>NetworkStart.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\DownloadTesseract4.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\DownloadTesseract4.Designer.cs"> + <DependentUpon>DownloadTesseract4.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\DownloadTesseract302.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\DownloadTesseract302.Designer.cs"> + <DependentUpon>DownloadTesseract302.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\GetTesseract302Dictionaries.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\GetTesseract302Dictionaries.Designer.cs"> + <DependentUpon>GetTesseract302Dictionaries.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\OcrPreprocessingT4.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\OcrPreprocessingT4.Designer.cs"> + <DependentUpon>OcrPreprocessingT4.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\OcrPreprocessingSettings.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\OcrPreprocessingSettings.Designer.cs"> + <DependentUpon>OcrPreprocessingSettings.cs</DependentUpon> + </Compile> + <Compile Include="Forms\OpenVideoDvd.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\OpenVideoDvd.Designer.cs"> + <DependentUpon>OpenVideoDvd.cs</DependentUpon> + </Compile> + <Compile Include="Forms\PacEncoding.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\PacEncoding.Designer.cs"> + <DependentUpon>PacEncoding.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ColumnPaste.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ColumnPaste.Designer.cs"> + <DependentUpon>ColumnPaste.cs</DependentUpon> + </Compile> + <Compile Include="Forms\PluginsGet.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\PluginsGet.Designer.cs"> + <DependentUpon>PluginsGet.cs</DependentUpon> + </Compile> + <Compile Include="Forms\PositionAndSizeForm.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ProfileChoose.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ProfileChoose.Designer.cs"> + <DependentUpon>ProfileChoose.cs</DependentUpon> + </Compile> + <Compile Include="Forms\RestoreAutoBackup.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\RestoreAutoBackup.Designer.cs"> + <DependentUpon>RestoreAutoBackup.cs</DependentUpon> + </Compile> + <Compile Include="Forms\RubyJapanese.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\RubyJapanese.Designer.cs"> + <DependentUpon>RubyJapanese.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SeekSilence.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SeekSilence.Designer.cs"> + <DependentUpon>SeekSilence.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SetSyncPoint.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SetSyncPoint.Designer.cs"> + <DependentUpon>SetSyncPoint.cs</DependentUpon> + </Compile> + <Compile Include="Forms\GoogleTranslate.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\GoogleTranslate.Designer.cs"> + <DependentUpon>GoogleTranslate.cs</DependentUpon> + </Compile> + <Compile Include="Forms\GoToLine.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\GoToLine.Designer.cs"> + <DependentUpon>GoToLine.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ImportText.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ImportText.Designer.cs"> + <DependentUpon>ImportText.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Main.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Main.Designer.cs"> + <DependentUpon>Main.cs</DependentUpon> + </Compile> + <Compile Include="Forms\MatroskaSubtitleChooser.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\MatroskaSubtitleChooser.Designer.cs"> + <DependentUpon>MatroskaSubtitleChooser.cs</DependentUpon> + </Compile> + <Compile Include="Forms\MergeShortLines.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\MergeShortLines.Designer.cs"> + <DependentUpon>MergeShortLines.cs</DependentUpon> + </Compile> + <Compile Include="Forms\MultipleReplace.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\MultipleReplace.Designer.cs"> + <DependentUpon>MultipleReplace.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\OCRSpellCheck.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\OCRSpellCheck.Designer.cs"> + <DependentUpon>OCRSpellCheck.cs</DependentUpon> + </Compile> + <Compile Include="Forms\RemoveTextFromHearImpaired.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\RemoveTextFromHearImpaired.Designer.cs"> + <DependentUpon>RemoveTextFromHearImpaired.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ReplaceDialog.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ReplaceDialog.Designer.cs"> + <DependentUpon>ReplaceDialog.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SetMinimumDisplayTimeBetweenParagraphs.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SetMinimumDisplayTimeBetweenParagraphs.Designer.cs"> + <DependentUpon>SetMinimumDisplayTimeBetweenParagraphs.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Settings.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Settings.Designer.cs"> + <DependentUpon>Settings.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SettingsFixContinuationStyle.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SettingsFixContinuationStyle.Designer.cs"> + <DependentUpon>SettingsFixContinuationStyle.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SettingsGapChoose.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SettingsGapChoose.Designer.cs"> + <DependentUpon>SettingsGapChoose.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SettingsLineWidth.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SettingsLineWidth.Designer.cs"> + <DependentUpon>SettingsLineWidth.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SettingsMpv.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SettingsMpv.Designer.cs"> + <DependentUpon>SettingsMpv.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SettingsProfile.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SettingsProfile.Designer.cs"> + <DependentUpon>SettingsProfile.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SettingsProfileExport.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SettingsProfileExport.Designer.cs"> + <DependentUpon>SettingsProfileExport.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SetVideoOffset.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SetVideoOffset.Designer.cs"> + <DependentUpon>SetVideoOffset.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ShowEarlierLater.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ShowEarlierLater.Designer.cs"> + <DependentUpon>ShowEarlierLater.cs</DependentUpon> + </Compile> + <Compile Include="Forms\ShowHistory.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\ShowHistory.Designer.cs"> + <DependentUpon>ShowHistory.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SpellCheck.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SpellCheck.Designer.cs"> + <DependentUpon>SpellCheck.cs</DependentUpon> + </Compile> + <Compile Include="Forms\DialogDoNotShowAgain.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\DialogDoNotShowAgain.Designer.cs"> + <DependentUpon>DialogDoNotShowAgain.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Split.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Split.Designer.cs"> + <DependentUpon>Split.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SplitLongLines.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SplitLongLines.Designer.cs"> + <DependentUpon>SplitLongLines.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SplitSubtitle.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SplitSubtitle.Designer.cs"> + <DependentUpon>SplitSubtitle.cs</DependentUpon> + </Compile> + <Compile Include="Forms\StartNumberingFrom.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\StartNumberingFrom.Designer.cs"> + <DependentUpon>StartNumberingFrom.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Statistics.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Statistics.Designer.cs"> + <DependentUpon>Statistics.cs</DependentUpon> + </Compile> + <Compile Include="Forms\StatusLog.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\StatusLog.Designer.cs"> + <DependentUpon>StatusLog.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Styles\StylesForm.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Styles\SubStationAlphaStylesBatchConvert.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Styles\SubStationAlphaStylesBatchConvert.Designer.cs"> + <DependentUpon>SubStationAlphaStylesBatchConvert.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Styles\SubStationAlphaStylesExport.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Styles\SubStationAlphaStylesExport.Designer.cs"> + <DependentUpon>SubStationAlphaStylesExport.cs</DependentUpon> + </Compile> + <Compile Include="Forms\SubStationAlphaProperties.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SubStationAlphaProperties.Designer.cs"> + <DependentUpon>SubStationAlphaProperties.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Styles\SubStationAlphaStyles.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Styles\SubStationAlphaStyles.Designer.cs"> + <DependentUpon>SubStationAlphaStyles.cs</DependentUpon> + </Compile> + <Compile Include="Forms\TimedTextNewLanguage.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\TimedTextNewLanguage.Designer.cs"> + <DependentUpon>TimedTextNewLanguage.cs</DependentUpon> + </Compile> + <Compile Include="Forms\TimedTextProperties.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\TimedTextProperties.Designer.cs"> + <DependentUpon>TimedTextProperties.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Styles\TimedTextStyles.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Styles\TimedTextStyles.Designer.cs"> + <DependentUpon>TimedTextStyles.cs</DependentUpon> + </Compile> + <Compile Include="Forms\TransportStreamSubtitleChooser.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\TransportStreamSubtitleChooser.Designer.cs"> + <DependentUpon>TransportStreamSubtitleChooser.cs</DependentUpon> + </Compile> + <Compile Include="Forms\UnknownSubtitle.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\UnknownSubtitle.Designer.cs"> + <DependentUpon>UnknownSubtitle.cs</DependentUpon> + </Compile> + <Compile Include="Forms\VideoControlsUndocked.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\VideoControlsUndocked.Designer.cs"> + <DependentUpon>VideoControlsUndocked.cs</DependentUpon> + </Compile> + <Compile Include="Forms\VideoError.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\VideoError.Designer.cs"> + <DependentUpon>VideoError.cs</DependentUpon> + </Compile> + <Compile Include="Forms\VideoPlayerUndocked.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\VideoPlayerUndocked.Designer.cs"> + <DependentUpon>VideoPlayerUndocked.cs</DependentUpon> + </Compile> + <Compile Include="Forms\VisualSync.cs"> + <SubType>form</SubType> + </Compile> + <Compile Include="Forms\VisualSync.Designer.cs"> + <DependentUpon>VisualSync.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\VobSubCharactersImport.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\VobSubCharactersImport.Designer.cs"> + <DependentUpon>VobSubCharactersImport.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\VobSubEditCharacters.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\VobSubEditCharacters.Designer.cs"> + <DependentUpon>VobSubEditCharacters.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\VobSubNOcrCharacterInspect.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\VobSubNOcrCharacterInspect.Designer.cs"> + <DependentUpon>VobSubNOcrCharacterInspect.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\VobSubNOcrEdit.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\VobSubNOcrEdit.Designer.cs"> + <DependentUpon>VobSubNOcrEdit.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\VobSubNOcrTrain.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\VobSubNOcrTrain.Designer.cs"> + <DependentUpon>VobSubNOcrTrain.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\VobSubOcr.cs"> + <SubType>form</SubType> + </Compile> + <Compile Include="Forms\Ocr\VobSubOcr.Designer.cs"> + <DependentUpon>VobSubOcr.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\VobSubOcrCharacter.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\VobSubOcrCharacter.Designer.cs"> + <DependentUpon>VobSubOcrCharacter.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\VobSubOcrCharacterInspect.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\VobSubOcrCharacterInspect.Designer.cs"> + <DependentUpon>VobSubOcrCharacterInspect.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\VobSubOcrNewFolder.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\VobSubOcrNewFolder.Designer.cs"> + <DependentUpon>VobSubOcrNewFolder.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\VobSubOcrNOcrCharacter.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\VobSubOcrNOcrCharacter.Designer.cs"> + <DependentUpon>VobSubOcrNOcrCharacter.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Ocr\VobSubOcrSetItalicFactor.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Ocr\VobSubOcrSetItalicFactor.Designer.cs"> + <DependentUpon>VobSubOcrSetItalicFactor.cs</DependentUpon> + </Compile> + <Compile Include="Forms\Watermark.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\Watermark.Designer.cs"> + <DependentUpon>Watermark.cs</DependentUpon> + </Compile> + <Compile Include="Forms\WaveformGenerateTimeCodes.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\WaveformGenerateTimeCodes.Designer.cs"> + <DependentUpon>WaveformGenerateTimeCodes.cs</DependentUpon> + </Compile> + <Compile Include="Forms\WaveformUndocked.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\WaveformUndocked.Designer.cs"> + <DependentUpon>WaveformUndocked.cs</DependentUpon> + </Compile> + <Compile Include="Forms\GoogleOrMicrosoftTranslate.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\GoogleOrMicrosoftTranslate.Designer.cs"> + <DependentUpon>GoogleOrMicrosoftTranslate.cs</DependentUpon> + </Compile> + <Compile Include="Forms\TextPrompt.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\TextPrompt.Designer.cs"> + <DependentUpon>TextPrompt.cs</DependentUpon> + </Compile> + <Compile Include="Forms\YouTubeAnnotationsImport.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\YouTubeAnnotationsImport.Designer.cs"> + <DependentUpon>YouTubeAnnotationsImport.cs</DependentUpon> + </Compile> + <Compile Include="Logic\ColorChooser\ColorChangedEventArgs.cs" /> + <Compile Include="Logic\ColorChooser\ColorHandler.cs" /> + <Compile Include="Logic\ColorChooser\ColorWheel.cs" /> + <Compile Include="Logic\CommandLineConvert\BluRaySupToBluRaySup.cs" /> + <Compile Include="Logic\CommandLineConvert\CommandLineConverter.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Logic\CommandLineConvert\TsToBdnXml.cs" /> + <Compile Include="Logic\CommandLineConvert\TsConvert.cs" /> + <Compile Include="Logic\CommandLineConvert\TsToBluRaySup.cs" /> + <Compile Include="Logic\DarkTheme.cs" /> + <Compile Include="Logic\FindReplaceDialogHelper.cs" /> + <Compile Include="Logic\SceneChangesGenerator.cs" /> + <Compile Include="Logic\ListViewSorter.cs" /> + <Compile Include="Logic\NativeMethods.cs" /> + <Compile Include="Logic\NikseBitmapImageSplitter.cs" /> + <Compile Include="Logic\Networking\NikseWebServiceSession.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Logic\Networking\UpdateLogEntry.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Logic\Ocr\Binary\BinaryOcrBitmap.cs" /> + <Compile Include="Logic\Ocr\Binary\BinaryOcrDb.cs" /> + <Compile Include="Logic\Ocr\MatchesToItalicStringConverter.cs" /> + <Compile Include="Logic\Ocr\ModiLanguage.cs" /> + <Compile Include="Logic\Ocr\NOcrDb.cs" /> + <Compile Include="Logic\Ocr\OcrAlphabet.cs" /> + <Compile Include="Logic\Ocr\NOcrChar.cs" /> + <Compile Include="Logic\Ocr\OcrCharacter.cs" /> + <Compile Include="Logic\Ocr\OcrFixEngine.cs" /> + <Compile Include="Logic\Ocr\OcrImage.cs" /> + <Compile Include="Logic\Ocr\NOcrPoint.cs" /> + <Compile Include="Logic\Ocr\PreprocessingSettings.cs" /> + <Compile Include="Logic\Ocr\SpellCheckOcrTextResult.cs" /> + <Compile Include="Logic\Ocr\Tesseract\TesseractMultiThreadRunner.cs" /> + <Compile Include="Logic\Ocr\Tesseract\TesseractThreadRunner.cs" /> + <Compile Include="Logic\Ocr\Tesseract\TesseractRunner.cs" /> + <Compile Include="Logic\Ocr\Tesseract\TesseractMultiRunner.cs" /> + <Compile Include="Logic\RtfTextConverterRichTextBox.cs" /> + <Compile Include="Logic\MainShortcuts.cs" /> + <Compile Include="Logic\SpellCheck\Hunspell.cs" /> + <Compile Include="Logic\SpellCheck\LinuxHunspell.cs" /> + <Compile Include="Logic\SpellCheck\MacHunspell.cs" /> + <Compile Include="Logic\SpellCheck\VoikkoSpellCheck.cs" /> + <Compile Include="Logic\SpellCheck\WindowsHunspell.cs" /> + <Compile Include="Logic\SyncContextExtensions.cs" /> + <Compile Include="Logic\TaskbarList.cs" /> + <Compile Include="Logic\TextDesigner.cs" /> + <Compile Include="Logic\TextWidth.cs" /> + <Compile Include="Logic\UiEbuSaveHelper.cs" /> + <Compile Include="Logic\UiGetPacEncoding.cs" /> + <Compile Include="Logic\UiGetYouTubeAnnotationStyles.cs" /> + <Compile Include="Logic\UiUtil.cs" /> + <Compile Include="Logic\VideoPlayers\LibMpvMono.cs" /> + <Compile Include="Logic\VideoPlayers\LibMpvDynamic.cs" /> + <Compile Include="Logic\VideoPlayers\LibVlcDynamic.cs" /> + <Compile Include="Logic\VideoPlayers\LibVlcMono.cs" /> + <Compile Include="Logic\VideoPlayers\MpcHC\MessageHandlerWindow.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Logic\VideoPlayers\MpcHC\MessageHandlerWindow.Designer.cs"> + <DependentUpon>MessageHandlerWindow.cs</DependentUpon> + </Compile> + <Compile Include="Logic\VideoPlayers\MpcHC\MpcHcCommand.cs" /> + <Compile Include="Logic\VideoPlayers\MpcHC\MpcHc.cs" /> + <Compile Include="Logic\VideoPlayers\MpcHC\NativeMethods.cs" /> + <Compile Include="Logic\VideoPlayers\QuartsPlayer.cs" /> + <Compile Include="Logic\VideoPlayers\VideoPlayer.cs" /> + <Compile Include="Logic\WordSpellChecker.cs" /> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Forms\SyncPointsSync.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\SyncPointsSync.Designer.cs"> + <DependentUpon>SyncPointsSync.cs</DependentUpon> + </Compile> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <Compile Include="Web References\SeNetworkService\Reference.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Reference.map</DependentUpon> + </Compile> + <EmbeddedResource Include="Controls\TimeUpDown.resx"> + <DependentUpon>TimeUpDown.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Controls\AudioVisualizer.resx"> + <DependentUpon>AudioVisualizer.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\AlignmentPickerJapanese.resx"> + <DependentUpon>AlignmentPickerJapanese.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\BatchConvertMkvEnding.resx"> + <DependentUpon>BatchConvertMkvEnding.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\BatchConvertTsSettings.resx"> + <DependentUpon>BatchConvertTsSettings.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\BookmarkAdd.resx"> + <DependentUpon>BookmarkAdd.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\AddWaveformBatch.resx"> + <DependentUpon>AddWaveformBatch.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\AudioToText.resx"> + <DependentUpon>AudioToText.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\BookmarksGoTo.resx"> + <DependentUpon>BookmarksGoTo.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Cavena890SaveOptions.resx"> + <DependentUpon>Cavena890SaveOptions.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\CheckForUpdates.resx"> + <DependentUpon>CheckForUpdates.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ChooseFontName.resx"> + <DependentUpon>ChooseFontName.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ColorChooser.resx"> + <DependentUpon>ColorChooser.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\DCinema\DCinemaPropertiesInterop.resx"> + <DependentUpon>DCinemaPropertiesInterop.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\DCinema\DCinemaPropertiesSmpte.resx"> + <DependentUpon>DCinemaPropertiesSmpte.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\DoNotBreakAfterListEdit.resx"> + <DependentUpon>DoNotBreakAfterListEdit.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\About.resx"> + <DependentUpon>About.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\AddToNames.resx"> + <DependentUpon>AddToNames.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\DownloadFfmpeg.resx"> + <DependentUpon>DownloadFfmpeg.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\DvdStudioProProperties.resx"> + <DependentUpon>DvdStudioProProperties.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\EbuLanguageCode.resx"> + <DependentUpon>EbuLanguageCode.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ExportFcpXmlAdvanced.resx"> + <DependentUpon>ExportFcpXmlAdvanced.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ExportPngXmlDialogOpenFolder.resx"> + <DependentUpon>ExportPngXmlDialogOpenFolder.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ImportCdg.resx"> + <DependentUpon>ImportCdg.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ImportFinalDraft.resx"> + <DependentUpon>ImportFinalDraft.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\MultipleReplaceExportImport.resx"> + <DependentUpon>MultipleReplaceExportImport.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\NetflixFixErrors.resx"> + <DependentUpon>NetflixFixErrors.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\AddBeterMultiMatch.resx"> + <DependentUpon>AddBeterMultiMatch.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\AddBetterMultiMatchNOcr.resx"> + <DependentUpon>AddBetterMultiMatchNOcr.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\AddToOcrReplaceList.resx"> + <DependentUpon>AddToOcrReplaceList.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\AddToUserDic.resx"> + <DependentUpon>AddToUserDic.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\AddWaveform.resx"> + <DependentUpon>AddWaveform.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\AlignmentPicker.resx"> + <DependentUpon>AlignmentPicker.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ApplyDurationLimits.resx"> + <DependentUpon>ApplyDurationLimits.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\BatchConvert.resx"> + <DependentUpon>BatchConvert.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Beamer.resx"> + <DependentUpon>Beamer.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ChangeCasing.resx"> + <DependentUpon>ChangeCasing.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ChangeFrameRate.resx"> + <DependentUpon>ChangeFrameRate.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ChangeSpeedInPercent.resx"> + <DependentUpon>ChangeSpeedInPercent.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ChooseAudioTrack.resx"> + <DependentUpon>ChooseAudioTrack.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ChooseEncoding.resx"> + <DependentUpon>ChooseEncoding.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\AdjustDisplayDuration.resx"> + <DependentUpon>AdjustDisplayDuration.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ChooseResolution.resx"> + <DependentUpon>ChooseResolution.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ChooseStyle.resx"> + <DependentUpon>ChooseStyle.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\DurationsBridgeGaps.resx"> + <DependentUpon>DurationsBridgeGaps.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\EbuColorPicker.resx"> + <DependentUpon>EbuColorPicker.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ExportCustomText.resx"> + <DependentUpon>ExportCustomText.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ExportCustomTextFormat.resx"> + <DependentUpon>ExportCustomTextFormat.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ExportPngXmlPreview.resx"> + <DependentUpon>ExportPngXmlPreview.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ExportTextST.resx"> + <DependentUpon>ExportTextST.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\FcpProperties.resx"> + <DependentUpon>FcpProperties.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ImportImages.resx"> + <DependentUpon>ImportImages.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ImportSceneChanges.resx"> + <DependentUpon>ImportSceneChanges.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ImportUnknownFormat.resx"> + <DependentUpon>ImportUnknownFormat.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\MeasurementConverter.resx"> + <DependentUpon>MeasurementConverter.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\MergeTextWithSameTimeCodes.resx"> + <DependentUpon>MergeTextWithSameTimeCodes.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\MultipleReplaceNewGroup.resx"> + <DependentUpon>MultipleReplaceNewGroup.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\NuendoProperties.resx"> + <DependentUpon>NuendoProperties.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\EbuSaveOptions.resx"> + <DependentUpon>EbuSaveOptions.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\EffectKaraoke.resx"> + <DependentUpon>EffectKaraoke.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\EffectTypewriter.resx"> + <DependentUpon>EffectTypewriter.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ExportPngXml.resx"> + <DependentUpon>ExportPngXml.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ExportText.resx"> + <DependentUpon>ExportText.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ExtractDateTimeInfo.resx"> + <DependentUpon>ExtractDateTimeInfo.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\FindDialog.resx"> + <DependentUpon>FindDialog.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\FindSubtitleLine.resx"> + <DependentUpon>FindSubtitleLine.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\FixCommonErrors.resx"> + <DependentUpon>FixCommonErrors.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\DvdSubRip.resx"> + <DependentUpon>DvdSubRip.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\DvdSubRipChooseLanguage.resx"> + <DependentUpon>DvdSubRipChooseLanguage.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\GetDictionaries.resx"> + <DependentUpon>GetDictionaries.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\BinaryOcrChooseEditDb.resx"> + <DependentUpon>BinaryOcrChooseEditDb.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\BinaryOcrTrain.resx"> + <DependentUpon>BinaryOcrTrain.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\GetTesseractDictionaries.resx"> + <DependentUpon>GetTesseractDictionaries.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\HardSubExtract.resx"> + <DependentUpon>HardSubExtract.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Interjections.resx"> + <DependentUpon>Interjections.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\JoinSubtitles.resx"> + <DependentUpon>JoinSubtitles.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\MergeDoubleLines.resx"> + <DependentUpon>MergeDoubleLines.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ModifySelection.resx"> + <DependentUpon>ModifySelection.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Networking\NetworkChat.resx"> + <DependentUpon>NetworkChat.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Networking\NetworkJoin.resx"> + <DependentUpon>NetworkJoin.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Networking\NetworkLogAndInfo.resx"> + <DependentUpon>NetworkLogAndInfo.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Networking\NetworkStart.resx"> + <DependentUpon>NetworkStart.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\DownloadTesseract4.resx"> + <DependentUpon>DownloadTesseract4.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\DownloadTesseract302.resx"> + <DependentUpon>DownloadTesseract302.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\GetTesseract302Dictionaries.resx"> + <DependentUpon>GetTesseract302Dictionaries.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\OcrPreprocessingT4.resx"> + <DependentUpon>OcrPreprocessingT4.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\OcrPreprocessingSettings.resx"> + <DependentUpon>OcrPreprocessingSettings.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\OpenVideoDvd.resx"> + <DependentUpon>OpenVideoDvd.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\PacEncoding.resx"> + <DependentUpon>PacEncoding.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ColumnPaste.resx"> + <DependentUpon>ColumnPaste.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\PluginsGet.resx"> + <DependentUpon>PluginsGet.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ProfileChoose.resx"> + <DependentUpon>ProfileChoose.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\RestoreAutoBackup.resx"> + <DependentUpon>RestoreAutoBackup.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\RubyJapanese.resx"> + <DependentUpon>RubyJapanese.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SeekSilence.resx"> + <DependentUpon>SeekSilence.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SetSyncPoint.resx"> + <DependentUpon>SetSyncPoint.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\GoogleTranslate.resx"> + <DependentUpon>GoogleTranslate.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\GoToLine.resx"> + <DependentUpon>GoToLine.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ImportText.resx"> + <DependentUpon>ImportText.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\MatroskaSubtitleChooser.resx"> + <DependentUpon>MatroskaSubtitleChooser.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\MergeShortLines.resx"> + <DependentUpon>MergeShortLines.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\RemoveTextFromHearImpaired.resx"> + <DependentUpon>RemoveTextFromHearImpaired.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ReplaceDialog.resx"> + <DependentUpon>ReplaceDialog.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SetMinimumDisplayTimeBetweenParagraphs.resx"> + <DependentUpon>SetMinimumDisplayTimeBetweenParagraphs.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Settings.resx"> + <DependentUpon>Settings.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SettingsFixContinuationStyle.resx"> + <DependentUpon>SettingsFixContinuationStyle.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SettingsGapChoose.resx"> + <DependentUpon>SettingsGapChoose.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SettingsLineWidth.resx"> + <DependentUpon>SettingsLineWidth.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SettingsMpv.resx"> + <DependentUpon>SettingsMpv.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SettingsProfile.resx"> + <DependentUpon>SettingsProfile.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SettingsProfileExport.resx"> + <DependentUpon>SettingsProfileExport.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SetVideoOffset.resx"> + <DependentUpon>SetVideoOffset.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ShowHistory.resx"> + <DependentUpon>ShowHistory.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SpellCheck.resx"> + <DependentUpon>SpellCheck.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\DialogDoNotShowAgain.resx"> + <DependentUpon>DialogDoNotShowAgain.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Split.resx"> + <DependentUpon>Split.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SplitLongLines.resx"> + <DependentUpon>SplitLongLines.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SplitSubtitle.resx"> + <DependentUpon>SplitSubtitle.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\StartNumberingFrom.resx"> + <DependentUpon>StartNumberingFrom.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Statistics.resx"> + <DependentUpon>Statistics.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\StatusLog.resx"> + <DependentUpon>StatusLog.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Styles\SubStationAlphaStylesBatchConvert.resx"> + <DependentUpon>SubStationAlphaStylesBatchConvert.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Styles\SubStationAlphaStylesExport.resx"> + <DependentUpon>SubStationAlphaStylesExport.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SubStationAlphaProperties.resx"> + <DependentUpon>SubStationAlphaProperties.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Styles\SubStationAlphaStyles.resx"> + <DependentUpon>SubStationAlphaStyles.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\TimedTextNewLanguage.resx"> + <DependentUpon>TimedTextNewLanguage.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\TimedTextProperties.resx"> + <DependentUpon>TimedTextProperties.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Styles\TimedTextStyles.resx"> + <DependentUpon>TimedTextStyles.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\TransportStreamSubtitleChooser.resx"> + <DependentUpon>TransportStreamSubtitleChooser.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\UnknownSubtitle.resx"> + <DependentUpon>UnknownSubtitle.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\VideoControlsUndocked.resx"> + <DependentUpon>VideoControlsUndocked.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\VideoPlayerUndocked.resx"> + <DependentUpon>VideoPlayerUndocked.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\VisualSync.resx"> + <DependentUpon>VisualSync.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\VobSubCharactersImport.resx"> + <DependentUpon>VobSubCharactersImport.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\VobSubNOcrCharacterInspect.resx"> + <DependentUpon>VobSubNOcrCharacterInspect.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\VobSubNOcrEdit.resx"> + <DependentUpon>VobSubNOcrEdit.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\VobSubNOcrTrain.resx"> + <DependentUpon>VobSubNOcrTrain.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\VobSubOcr.resx"> + <DependentUpon>VobSubOcr.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\VobSubOcrCharacter.resx"> + <DependentUpon>VobSubOcrCharacter.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\VobSubOcrCharacterInspect.resx"> + <DependentUpon>VobSubOcrCharacterInspect.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\VobSubOcrNewFolder.resx"> + <DependentUpon>VobSubOcrNewFolder.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\VobSubOcrNOcrCharacter.resx"> + <DependentUpon>VobSubOcrNOcrCharacter.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\VobSubOcrSetItalicFactor.resx"> + <DependentUpon>VobSubOcrSetItalicFactor.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Watermark.resx"> + <DependentUpon>Watermark.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\WaveformGenerateTimeCodes.resx"> + <DependentUpon>WaveformGenerateTimeCodes.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\WaveformUndocked.resx"> + <DependentUpon>WaveformUndocked.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\GoogleOrMicrosoftTranslate.resx"> + <DependentUpon>GoogleOrMicrosoftTranslate.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\TextPrompt.resx"> + <DependentUpon>TextPrompt.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Forms\YouTubeAnnotationsImport.resx"> + <DependentUpon>YouTubeAnnotationsImport.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Logic\VideoPlayers\MpcHC\MessageHandlerWindow.resx"> + <DependentUpon>MessageHandlerWindow.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>PublicResXFileCodeGenerator</Generator> + <SubType>Designer</SubType> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Main.resx"> + <DependentUpon>Main.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\SyncPointsSync.resx"> + <DependentUpon>SyncPointsSync.cs</DependentUpon> + </EmbeddedResource> + <None Include="app.config" /> + <None Include="packages.config"> + <SubType>Designer</SubType> + </None> + <None Include="Properties\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> + <Compile Include="Properties\Settings.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + </Compile> + <EmbeddedResource Include="Resources\HunspellDictionaries.xml.gz" /> + <EmbeddedResource Include="Resources\HunspellBackupDictionaries.xml.gz" /> + <EmbeddedResource Include="Resources\TesseractDictionaries.xml.gz" /> + <None Include="Resources\nOCR_TesseractHelper.xml.gz" /> + <None Include="Resources\SMPTE-428-7-2007-DCST.xsd"> + <SubType>Designer</SubType> + </None> + <EmbeddedResource Include="Resources\SMPTE-428-7-2007-DCST.xsd.gz" /> + <None Include="Resources\SMPTE-428-7-2010-DCST.xsd"> + <SubType>Designer</SubType> + </None> + <EmbeddedResource Include="Resources\SMPTE-428-7-2010-DCST.xsd.gz" /> + <None Include="Resources\SMPTE-428-7-2014-DCST.xsd"> + <SubType>Designer</SubType> + </None> + <EmbeddedResource Include="Resources\SMPTE-428-7-2014-DCST.xsd.gz" /> + <None Include="Web References\SeNetworkService\Reference.map"> + <Generator>MSDiscoCodeGenerator</Generator> + <LastGenOutput>Reference.cs</LastGenOutput> + </None> + <None Include="Web References\SeNetworkService\SeSequence.datasource"> + <DependentUpon>Reference.map</DependentUpon> + </None> + <None Include="Web References\SeNetworkService\SeService.wsdl" /> + <None Include="Web References\SeNetworkService\SeUpdate.datasource"> + <DependentUpon>Reference.map</DependentUpon> + </None> + <None Include="Web References\SeNetworkService\SeUser.datasource"> + <DependentUpon>Reference.map</DependentUpon> + </None> + </ItemGroup> + <ItemGroup> + <Content Include="DLLs\Voikkox64.dll" /> + <Content Include="DLLs\Voikkox86.dll" /> + <Content Include="Languages\ar-EG.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\bg-BG.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\br-FR.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\ca-ES.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\cs-CZ.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\da-DK.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\de-DE.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\el-GR.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\es-AR.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\es-ES.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\es-MX.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\eu-ES.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\fa-IR.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\fi-FI.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\fr-FR.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\hr-HR.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\hu-HU.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\id-ID.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\it-IT.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\ja-JP.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\ko-KR.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\mk-MK.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\nb-NO.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\nl-NL.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\pl-PL.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\pt-BR.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\pt-PT.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\ro-RO.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\ru-RU.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\sl-SI.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\sr-Cyrl-RS.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\sr-Latn-RS.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\sv-SE.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\th-TH.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\tr-TR.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\uk-UA.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\vi-VN.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\zh-Hans.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Languages\zh-TW.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <None Include="Web References\SeNetworkService\SeService.disco" /> + <None Include="DLLs\Interop.QuartzTypeLib.dll" /> + <Content Include="..\Changelog.txt" /> + <Content Include="..\LICENSE.txt" /> + <EmbeddedResource Include="Controls\VideoPlayerContainer.resx"> + <DependentUpon>VideoPlayerContainer.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\AutoBreakUnbreakLines.resx"> + <DependentUpon>AutoBreakUnbreakLines.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ChangeCasingNames.resx"> + <DependentUpon>ChangeCasingNames.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ChooseLanguage.resx"> + <DependentUpon>ChooseLanguage.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Compare.resx"> + <DependentUpon>Compare.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\MultipleReplace.resx"> + <DependentUpon>MultipleReplace.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\OCRSpellCheck.resx"> + <DependentUpon>OCRSpellCheck.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\ShowEarlierLater.resx"> + <DependentUpon>ShowEarlierLater.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\VideoError.resx"> + <DependentUpon>VideoError.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Forms\Ocr\VobSubEditCharacters.resx"> + <DependentUpon>VobSubEditCharacters.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <None Include="Icons\connect.png" /> + <None Include="Icons\Donate.png" /> + <Content Include="Icons\SE.ico" /> + <Content Include="Icons\Find.png" /> + <Content Include="Icons\FixCommonErrors.png" /> + <Content Include="Icons\Help.png" /> + <Content Include="Icons\New.png" /> + <Content Include="Icons\Open.png" /> + <Content Include="Icons\RemoveTextForHI.png" /> + <Content Include="Icons\Replace.png" /> + <Content Include="Icons\Save.png" /> + <Content Include="Icons\SaveAs.png" /> + <Content Include="Icons\Settings.png" /> + <Content Include="Icons\SpellCheck.png" /> + <Content Include="Icons\VideoToggle.png" /> + <Content Include="Icons\VisualSync.png" /> + <Content Include="Icons\WaveformToggle.png" /> + <None Include="Resources\bookmark22.png" /> + <None Include="Resources\pictureBoxFS.Image.png" /> + <None Include="Resources\pictureBoxFSDown.Image.png" /> + <None Include="Resources\pictureBoxFSOver.Image.png" /> + <None Include="Resources\pictureBoxFastForward.Image.png" /> + <None Include="Resources\pictureBoxFastForwardMouseDown.Image.png" /> + <None Include="Resources\pictureBoxFastForwardMouseOver.Image.png" /> + <None Include="Resources\pictureBoxNoFS.Image.png" /> + <None Include="Resources\pictureBoxNoFSDown.Image.png" /> + <None Include="Resources\pictureBoxNoFSOver.Image.png" /> + <None Include="Resources\pictureBoxReverse.Image.png" /> + <None Include="Resources\pictureBoxReverseMouseDown.Image.png" /> + <None Include="Resources\pictureBoxReverseMouseOver.Image.png" /> + <None Include="Resources\Transparent Background.png" /> + <Content Include="Resources\TesseractDictionaries.xml"> + <SubType>Designer</SubType> + </Content> + <Content Include="Resources\HunspellBackupDictionaries.xml"> + <SubType>Designer</SubType> + </Content> + <Content Include="Resources\HunspellDictionaries.xml"> + <SubType>Designer</SubType> + </Content> + </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.2.0"> + <Visible>False</Visible> + <ProductName>.NET Framework 2.0 %28x86%29</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.0"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.0 %28x86%29</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Visual.C++.10.0.x86"> + <Visible>False</Visible> + <ProductName>Visual C++ 2010 Runtime Libraries %28x86%29</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> + <Visible>False</Visible> + <ProductName>Windows Installer 3.1</ProductName> + <Install>true</Install> + </BootstrapperPackage> + </ItemGroup> + <ItemGroup> + <WebReferences Include="Web References\" /> + </ItemGroup> + <ItemGroup> + <WebReferenceUrl Include="http://localhost:2782/se/SeService.asmx"> + <UrlBehavior>Dynamic</UrlBehavior> + <RelPath>Web References\SeNetworkService\</RelPath> + <UpdateFromURL>http://localhost:2782/se/SeService.asmx</UpdateFromURL> + <ServiceLocationURL> + </ServiceLocationURL> + <CachedDynamicPropName> + </CachedDynamicPropName> + <CachedAppSettingsObjectName>Settings</CachedAppSettingsObjectName> + <CachedSettingsPropName>SubtitleEdit_SeNetworkService_SeService</CachedSettingsPropName> + </WebReferenceUrl> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\libse\LibSE.csproj"> + <Project>{3e3cb28f-3a7b-430f-9eb3-0d6c1e53b753}</Project> + <Name>LibSE</Name> + <Private>True</Private> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <ItemGroup> + <HunspellAssemblies Include="Hunspellx64.dll"> + <Visible>false</Visible> + </HunspellAssemblies> + <HunspellAssemblies Include="Hunspellx86.dll"> + <Visible>false</Visible> + </HunspellAssemblies> + </ItemGroup> + <ItemGroup /> + <Target Name="BeforeCompile"> + <XmlPeek XmlInputPath="$(SolutionDir)packages.config" Query="//package[@id='NHunspell']/@version"> + <Output TaskParameter="Result" PropertyName="HunspellVersion" /> + </XmlPeek> + <PropertyGroup> + <HunspellDir>$(SolutionDir)packages\NHunspell.$(HunspellVersion)\content\</HunspellDir> + </PropertyGroup> + <Copy SourceFiles="@(HunspellAssemblies -> '$(HunspellDir)%(Identity)')" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="True" /> + <Exec Command="%22$(SolutionDir)\build_helpers.bat%22 rev %22$(ConfigurationName)%22" /> + </Target> + <Target Name="BeforeClean"> + <Delete Files="@(HunspellAssemblies -> '$(OutputPath)%(Identity)')" /> + </Target> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> </Project> \ No newline at end of file diff --git a/src/Web References/SeNetworkService/Reference.cs b/src/ui/Web References/SeNetworkService/Reference.cs similarity index 97% rename from src/Web References/SeNetworkService/Reference.cs rename to src/ui/Web References/SeNetworkService/Reference.cs index 91dfdbc2c..7189aa0ac 100644 --- a/src/Web References/SeNetworkService/Reference.cs +++ b/src/ui/Web References/SeNetworkService/Reference.cs @@ -1,965 +1,965 @@ -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -// -// This source code was auto-generated by Microsoft.VSDesigner, Version 4.0.30319.42000. -// -#pragma warning disable 1591 - -namespace Nikse.SubtitleEdit.SeNetworkService { - using System; - using System.Web.Services; - using System.Diagnostics; - using System.Web.Services.Protocols; - using System.Xml.Serialization; - using System.ComponentModel; - - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Web.Services.WebServiceBindingAttribute(Name="SeServiceSoap", Namespace="http://tempuri.org/")] - public partial class SeService : System.Web.Services.Protocols.SoapHttpClientProtocol { - - private System.Threading.SendOrPostCallback StartOperationCompleted; - - private System.Threading.SendOrPostCallback JoinOperationCompleted; - - private System.Threading.SendOrPostCallback LeaveOperationCompleted; - - private System.Threading.SendOrPostCallback DeleteLinesOperationCompleted; - - private System.Threading.SendOrPostCallback InsertLineOperationCompleted; - - private System.Threading.SendOrPostCallback UpdateLineOperationCompleted; - - private System.Threading.SendOrPostCallback SendMessageOperationCompleted; - - private System.Threading.SendOrPostCallback GetUpdatesOperationCompleted; - - private System.Threading.SendOrPostCallback GetSubtitleOperationCompleted; - - private System.Threading.SendOrPostCallback GetOriginalSubtitleOperationCompleted; - - private bool useDefaultCredentialsSetExplicitly; - - /// <remarks/> - public SeService() { - this.Url = global::Nikse.SubtitleEdit.Properties.Settings.Default.SubtitleEdit_SeNetworkService_SeService; - if ((this.IsLocalFileSystemWebService(this.Url) == true)) { - this.UseDefaultCredentials = true; - this.useDefaultCredentialsSetExplicitly = false; - } - else { - this.useDefaultCredentialsSetExplicitly = true; - } - } - - public new string Url { - get { - return base.Url; - } - set { - if ((((this.IsLocalFileSystemWebService(base.Url) == true) - && (this.useDefaultCredentialsSetExplicitly == false)) - && (this.IsLocalFileSystemWebService(value) == false))) { - base.UseDefaultCredentials = false; - } - base.Url = value; - } - } - - public new bool UseDefaultCredentials { - get { - return base.UseDefaultCredentials; - } - set { - base.UseDefaultCredentials = value; - this.useDefaultCredentialsSetExplicitly = true; - } - } - - /// <remarks/> - public event StartCompletedEventHandler StartCompleted; - - /// <remarks/> - public event JoinCompletedEventHandler JoinCompleted; - - /// <remarks/> - public event LeaveCompletedEventHandler LeaveCompleted; - - /// <remarks/> - public event DeleteLinesCompletedEventHandler DeleteLinesCompleted; - - /// <remarks/> - public event InsertLineCompletedEventHandler InsertLineCompleted; - - /// <remarks/> - public event UpdateLineCompletedEventHandler UpdateLineCompleted; - - /// <remarks/> - public event SendMessageCompletedEventHandler SendMessageCompleted; - - /// <remarks/> - public event GetUpdatesCompletedEventHandler GetUpdatesCompleted; - - /// <remarks/> - public event GetSubtitleCompletedEventHandler GetSubtitleCompleted; - - /// <remarks/> - public event GetOriginalSubtitleCompletedEventHandler GetOriginalSubtitleCompleted; - - /// <remarks/> - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Start", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public SeUser Start(string sessionKey, string userName, SeSequence[] subtitle, SeSequence[] originalSubtitle, string fileName, out string message) { - object[] results = this.Invoke("Start", new object[] { - sessionKey, - userName, - subtitle, - originalSubtitle, - fileName}); - message = ((string)(results[1])); - return ((SeUser)(results[0])); - } - - /// <remarks/> - public void StartAsync(string sessionKey, string userName, SeSequence[] subtitle, SeSequence[] originalSubtitle, string fileName) { - this.StartAsync(sessionKey, userName, subtitle, originalSubtitle, fileName, null); - } - - /// <remarks/> - public void StartAsync(string sessionKey, string userName, SeSequence[] subtitle, SeSequence[] originalSubtitle, string fileName, object userState) { - if ((this.StartOperationCompleted == null)) { - this.StartOperationCompleted = new System.Threading.SendOrPostCallback(this.OnStartOperationCompleted); - } - this.InvokeAsync("Start", new object[] { - sessionKey, - userName, - subtitle, - originalSubtitle, - fileName}, this.StartOperationCompleted, userState); - } - - private void OnStartOperationCompleted(object arg) { - if ((this.StartCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.StartCompleted(this, new StartCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// <remarks/> - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Join", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public SeUser[] Join(string sessionId, string userName, out string message) { - object[] results = this.Invoke("Join", new object[] { - sessionId, - userName}); - message = ((string)(results[1])); - return ((SeUser[])(results[0])); - } - - /// <remarks/> - public void JoinAsync(string sessionId, string userName) { - this.JoinAsync(sessionId, userName, null); - } - - /// <remarks/> - public void JoinAsync(string sessionId, string userName, object userState) { - if ((this.JoinOperationCompleted == null)) { - this.JoinOperationCompleted = new System.Threading.SendOrPostCallback(this.OnJoinOperationCompleted); - } - this.InvokeAsync("Join", new object[] { - sessionId, - userName}, this.JoinOperationCompleted, userState); - } - - private void OnJoinOperationCompleted(object arg) { - if ((this.JoinCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.JoinCompleted(this, new JoinCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// <remarks/> - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Leave", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public void Leave(string sessionId, string userName) { - this.Invoke("Leave", new object[] { - sessionId, - userName}); - } - - /// <remarks/> - public void LeaveAsync(string sessionId, string userName) { - this.LeaveAsync(sessionId, userName, null); - } - - /// <remarks/> - public void LeaveAsync(string sessionId, string userName, object userState) { - if ((this.LeaveOperationCompleted == null)) { - this.LeaveOperationCompleted = new System.Threading.SendOrPostCallback(this.OnLeaveOperationCompleted); - } - this.InvokeAsync("Leave", new object[] { - sessionId, - userName}, this.LeaveOperationCompleted, userState); - } - - private void OnLeaveOperationCompleted(object arg) { - if ((this.LeaveCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.LeaveCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// <remarks/> - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/DeleteLines", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public bool DeleteLines(string sessionId, int[] indices, SeUser user) { - object[] results = this.Invoke("DeleteLines", new object[] { - sessionId, - indices, - user}); - return ((bool)(results[0])); - } - - /// <remarks/> - public void DeleteLinesAsync(string sessionId, int[] indices, SeUser user) { - this.DeleteLinesAsync(sessionId, indices, user, null); - } - - /// <remarks/> - public void DeleteLinesAsync(string sessionId, int[] indices, SeUser user, object userState) { - if ((this.DeleteLinesOperationCompleted == null)) { - this.DeleteLinesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDeleteLinesOperationCompleted); - } - this.InvokeAsync("DeleteLines", new object[] { - sessionId, - indices, - user}, this.DeleteLinesOperationCompleted, userState); - } - - private void OnDeleteLinesOperationCompleted(object arg) { - if ((this.DeleteLinesCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.DeleteLinesCompleted(this, new DeleteLinesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// <remarks/> - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/InsertLine", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public bool InsertLine(string sessionId, int index, int startMilliseconds, int endMilliseconds, string text, SeUser user) { - object[] results = this.Invoke("InsertLine", new object[] { - sessionId, - index, - startMilliseconds, - endMilliseconds, - text, - user}); - return ((bool)(results[0])); - } - - /// <remarks/> - public void InsertLineAsync(string sessionId, int index, int startMilliseconds, int endMilliseconds, string text, SeUser user) { - this.InsertLineAsync(sessionId, index, startMilliseconds, endMilliseconds, text, user, null); - } - - /// <remarks/> - public void InsertLineAsync(string sessionId, int index, int startMilliseconds, int endMilliseconds, string text, SeUser user, object userState) { - if ((this.InsertLineOperationCompleted == null)) { - this.InsertLineOperationCompleted = new System.Threading.SendOrPostCallback(this.OnInsertLineOperationCompleted); - } - this.InvokeAsync("InsertLine", new object[] { - sessionId, - index, - startMilliseconds, - endMilliseconds, - text, - user}, this.InsertLineOperationCompleted, userState); - } - - private void OnInsertLineOperationCompleted(object arg) { - if ((this.InsertLineCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.InsertLineCompleted(this, new InsertLineCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// <remarks/> - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/UpdateLine", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public bool UpdateLine(string sessionId, int index, SeSequence sequence, SeUser user) { - object[] results = this.Invoke("UpdateLine", new object[] { - sessionId, - index, - sequence, - user}); - return ((bool)(results[0])); - } - - /// <remarks/> - public void UpdateLineAsync(string sessionId, int index, SeSequence sequence, SeUser user) { - this.UpdateLineAsync(sessionId, index, sequence, user, null); - } - - /// <remarks/> - public void UpdateLineAsync(string sessionId, int index, SeSequence sequence, SeUser user, object userState) { - if ((this.UpdateLineOperationCompleted == null)) { - this.UpdateLineOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateLineOperationCompleted); - } - this.InvokeAsync("UpdateLine", new object[] { - sessionId, - index, - sequence, - user}, this.UpdateLineOperationCompleted, userState); - } - - private void OnUpdateLineOperationCompleted(object arg) { - if ((this.UpdateLineCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.UpdateLineCompleted(this, new UpdateLineCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// <remarks/> - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SendMessage", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public bool SendMessage(string sessionId, string text, SeUser user) { - object[] results = this.Invoke("SendMessage", new object[] { - sessionId, - text, - user}); - return ((bool)(results[0])); - } - - /// <remarks/> - public void SendMessageAsync(string sessionId, string text, SeUser user) { - this.SendMessageAsync(sessionId, text, user, null); - } - - /// <remarks/> - public void SendMessageAsync(string sessionId, string text, SeUser user, object userState) { - if ((this.SendMessageOperationCompleted == null)) { - this.SendMessageOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSendMessageOperationCompleted); - } - this.InvokeAsync("SendMessage", new object[] { - sessionId, - text, - user}, this.SendMessageOperationCompleted, userState); - } - - private void OnSendMessageOperationCompleted(object arg) { - if ((this.SendMessageCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.SendMessageCompleted(this, new SendMessageCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// <remarks/> - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetUpdates", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public SeUpdate[] GetUpdates(string sessionId, string userName, System.DateTime lastUpdateTime, out string message, out System.DateTime newUpdateTime, out int numberOfLines) { - object[] results = this.Invoke("GetUpdates", new object[] { - sessionId, - userName, - lastUpdateTime}); - message = ((string)(results[1])); - newUpdateTime = ((System.DateTime)(results[2])); - numberOfLines = ((int)(results[3])); - return ((SeUpdate[])(results[0])); - } - - /// <remarks/> - public void GetUpdatesAsync(string sessionId, string userName, System.DateTime lastUpdateTime) { - this.GetUpdatesAsync(sessionId, userName, lastUpdateTime, null); - } - - /// <remarks/> - public void GetUpdatesAsync(string sessionId, string userName, System.DateTime lastUpdateTime, object userState) { - if ((this.GetUpdatesOperationCompleted == null)) { - this.GetUpdatesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetUpdatesOperationCompleted); - } - this.InvokeAsync("GetUpdates", new object[] { - sessionId, - userName, - lastUpdateTime}, this.GetUpdatesOperationCompleted, userState); - } - - private void OnGetUpdatesOperationCompleted(object arg) { - if ((this.GetUpdatesCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.GetUpdatesCompleted(this, new GetUpdatesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// <remarks/> - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetSubtitle", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public SeSequence[] GetSubtitle(string sessionId, out string fileName, out System.DateTime updateTime) { - object[] results = this.Invoke("GetSubtitle", new object[] { - sessionId}); - fileName = ((string)(results[1])); - updateTime = ((System.DateTime)(results[2])); - return ((SeSequence[])(results[0])); - } - - /// <remarks/> - public void GetSubtitleAsync(string sessionId) { - this.GetSubtitleAsync(sessionId, null); - } - - /// <remarks/> - public void GetSubtitleAsync(string sessionId, object userState) { - if ((this.GetSubtitleOperationCompleted == null)) { - this.GetSubtitleOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetSubtitleOperationCompleted); - } - this.InvokeAsync("GetSubtitle", new object[] { - sessionId}, this.GetSubtitleOperationCompleted, userState); - } - - private void OnGetSubtitleOperationCompleted(object arg) { - if ((this.GetSubtitleCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.GetSubtitleCompleted(this, new GetSubtitleCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// <remarks/> - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetOriginalSubtitle", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public SeSequence[] GetOriginalSubtitle(string sessionId) { - object[] results = this.Invoke("GetOriginalSubtitle", new object[] { - sessionId}); - return ((SeSequence[])(results[0])); - } - - /// <remarks/> - public void GetOriginalSubtitleAsync(string sessionId) { - this.GetOriginalSubtitleAsync(sessionId, null); - } - - /// <remarks/> - public void GetOriginalSubtitleAsync(string sessionId, object userState) { - if ((this.GetOriginalSubtitleOperationCompleted == null)) { - this.GetOriginalSubtitleOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetOriginalSubtitleOperationCompleted); - } - this.InvokeAsync("GetOriginalSubtitle", new object[] { - sessionId}, this.GetOriginalSubtitleOperationCompleted, userState); - } - - private void OnGetOriginalSubtitleOperationCompleted(object arg) { - if ((this.GetOriginalSubtitleCompleted != null)) { - System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); - this.GetOriginalSubtitleCompleted(this, new GetOriginalSubtitleCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); - } - } - - /// <remarks/> - public new void CancelAsync(object userState) { - base.CancelAsync(userState); - } - - private bool IsLocalFileSystemWebService(string url) { - if (((url == null) - || (url == string.Empty))) { - return false; - } - System.Uri wsUri = new System.Uri(url); - if (((wsUri.Port >= 1024) - && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) { - return true; - } - return false; - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] - public partial class SeSequence { - - private int indexField; - - private int startMillisecondsField; - - private int endMillisecondsField; - - private string textField; - - /// <remarks/> - public int Index { - get { - return this.indexField; - } - set { - this.indexField = value; - } - } - - /// <remarks/> - public int StartMilliseconds { - get { - return this.startMillisecondsField; - } - set { - this.startMillisecondsField = value; - } - } - - /// <remarks/> - public int EndMilliseconds { - get { - return this.endMillisecondsField; - } - set { - this.endMillisecondsField = value; - } - } - - /// <remarks/> - public string Text { - get { - return this.textField; - } - set { - this.textField = value; - } - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] - public partial class SeUpdate { - - private System.DateTime timeField; - - private SeUser userField; - - private int indexField; - - private int startMillisecondsField; - - private int endMillisecondsField; - - private string textField; - - private string actionField; - - /// <remarks/> - public System.DateTime Time { - get { - return this.timeField; - } - set { - this.timeField = value; - } - } - - /// <remarks/> - public SeUser User { - get { - return this.userField; - } - set { - this.userField = value; - } - } - - /// <remarks/> - public int Index { - get { - return this.indexField; - } - set { - this.indexField = value; - } - } - - /// <remarks/> - public int StartMilliseconds { - get { - return this.startMillisecondsField; - } - set { - this.startMillisecondsField = value; - } - } - - /// <remarks/> - public int EndMilliseconds { - get { - return this.endMillisecondsField; - } - set { - this.endMillisecondsField = value; - } - } - - /// <remarks/> - public string Text { - get { - return this.textField; - } - set { - this.textField = value; - } - } - - /// <remarks/> - public string Action { - get { - return this.actionField; - } - set { - this.actionField = value; - } - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] - public partial class SeUser { - - private string userNameField; - - private string ipField; - - private System.DateTime lastActivityField; - - /// <remarks/> - public string UserName { - get { - return this.userNameField; - } - set { - this.userNameField = value; - } - } - - /// <remarks/> - public string Ip { - get { - return this.ipField; - } - set { - this.ipField = value; - } - } - - /// <remarks/> - public System.DateTime LastActivity { - get { - return this.lastActivityField; - } - set { - this.lastActivityField = value; - } - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - public delegate void StartCompletedEventHandler(object sender, StartCompletedEventArgs e); - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class StartCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - - private object[] results; - - internal StartCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { - this.results = results; - } - - /// <remarks/> - public SeUser Result { - get { - this.RaiseExceptionIfNecessary(); - return ((SeUser)(this.results[0])); - } - } - - /// <remarks/> - public string message { - get { - this.RaiseExceptionIfNecessary(); - return ((string)(this.results[1])); - } - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - public delegate void JoinCompletedEventHandler(object sender, JoinCompletedEventArgs e); - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class JoinCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - - private object[] results; - - internal JoinCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { - this.results = results; - } - - /// <remarks/> - public SeUser[] Result { - get { - this.RaiseExceptionIfNecessary(); - return ((SeUser[])(this.results[0])); - } - } - - /// <remarks/> - public string message { - get { - this.RaiseExceptionIfNecessary(); - return ((string)(this.results[1])); - } - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - public delegate void LeaveCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - public delegate void DeleteLinesCompletedEventHandler(object sender, DeleteLinesCompletedEventArgs e); - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class DeleteLinesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - - private object[] results; - - internal DeleteLinesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { - this.results = results; - } - - /// <remarks/> - public bool Result { - get { - this.RaiseExceptionIfNecessary(); - return ((bool)(this.results[0])); - } - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - public delegate void InsertLineCompletedEventHandler(object sender, InsertLineCompletedEventArgs e); - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class InsertLineCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - - private object[] results; - - internal InsertLineCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { - this.results = results; - } - - /// <remarks/> - public bool Result { - get { - this.RaiseExceptionIfNecessary(); - return ((bool)(this.results[0])); - } - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - public delegate void UpdateLineCompletedEventHandler(object sender, UpdateLineCompletedEventArgs e); - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class UpdateLineCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - - private object[] results; - - internal UpdateLineCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { - this.results = results; - } - - /// <remarks/> - public bool Result { - get { - this.RaiseExceptionIfNecessary(); - return ((bool)(this.results[0])); - } - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - public delegate void SendMessageCompletedEventHandler(object sender, SendMessageCompletedEventArgs e); - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class SendMessageCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - - private object[] results; - - internal SendMessageCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { - this.results = results; - } - - /// <remarks/> - public bool Result { - get { - this.RaiseExceptionIfNecessary(); - return ((bool)(this.results[0])); - } - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - public delegate void GetUpdatesCompletedEventHandler(object sender, GetUpdatesCompletedEventArgs e); - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GetUpdatesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - - private object[] results; - - internal GetUpdatesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { - this.results = results; - } - - /// <remarks/> - public SeUpdate[] Result { - get { - this.RaiseExceptionIfNecessary(); - return ((SeUpdate[])(this.results[0])); - } - } - - /// <remarks/> - public string message { - get { - this.RaiseExceptionIfNecessary(); - return ((string)(this.results[1])); - } - } - - /// <remarks/> - public System.DateTime newUpdateTime { - get { - this.RaiseExceptionIfNecessary(); - return ((System.DateTime)(this.results[2])); - } - } - - /// <remarks/> - public int numberOfLines { - get { - this.RaiseExceptionIfNecessary(); - return ((int)(this.results[3])); - } - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - public delegate void GetSubtitleCompletedEventHandler(object sender, GetSubtitleCompletedEventArgs e); - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GetSubtitleCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - - private object[] results; - - internal GetSubtitleCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { - this.results = results; - } - - /// <remarks/> - public SeSequence[] Result { - get { - this.RaiseExceptionIfNecessary(); - return ((SeSequence[])(this.results[0])); - } - } - - /// <remarks/> - public string fileName { - get { - this.RaiseExceptionIfNecessary(); - return ((string)(this.results[1])); - } - } - - /// <remarks/> - public System.DateTime updateTime { - get { - this.RaiseExceptionIfNecessary(); - return ((System.DateTime)(this.results[2])); - } - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - public delegate void GetOriginalSubtitleCompletedEventHandler(object sender, GetOriginalSubtitleCompletedEventArgs e); - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - public partial class GetOriginalSubtitleCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { - - private object[] results; - - internal GetOriginalSubtitleCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : - base(exception, cancelled, userState) { - this.results = results; - } - - /// <remarks/> - public SeSequence[] Result { - get { - this.RaiseExceptionIfNecessary(); - return ((SeSequence[])(this.results[0])); - } - } - } -} - +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +// +// This source code was auto-generated by Microsoft.VSDesigner, Version 4.0.30319.42000. +// +#pragma warning disable 1591 + +namespace Nikse.SubtitleEdit.SeNetworkService { + using System; + using System.Web.Services; + using System.Diagnostics; + using System.Web.Services.Protocols; + using System.Xml.Serialization; + using System.ComponentModel; + + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Web.Services.WebServiceBindingAttribute(Name="SeServiceSoap", Namespace="http://tempuri.org/")] + public partial class SeService : System.Web.Services.Protocols.SoapHttpClientProtocol { + + private System.Threading.SendOrPostCallback StartOperationCompleted; + + private System.Threading.SendOrPostCallback JoinOperationCompleted; + + private System.Threading.SendOrPostCallback LeaveOperationCompleted; + + private System.Threading.SendOrPostCallback DeleteLinesOperationCompleted; + + private System.Threading.SendOrPostCallback InsertLineOperationCompleted; + + private System.Threading.SendOrPostCallback UpdateLineOperationCompleted; + + private System.Threading.SendOrPostCallback SendMessageOperationCompleted; + + private System.Threading.SendOrPostCallback GetUpdatesOperationCompleted; + + private System.Threading.SendOrPostCallback GetSubtitleOperationCompleted; + + private System.Threading.SendOrPostCallback GetOriginalSubtitleOperationCompleted; + + private bool useDefaultCredentialsSetExplicitly; + + /// <remarks/> + public SeService() { + this.Url = global::Nikse.SubtitleEdit.Properties.Settings.Default.SubtitleEdit_SeNetworkService_SeService; + if ((this.IsLocalFileSystemWebService(this.Url) == true)) { + this.UseDefaultCredentials = true; + this.useDefaultCredentialsSetExplicitly = false; + } + else { + this.useDefaultCredentialsSetExplicitly = true; + } + } + + public new string Url { + get { + return base.Url; + } + set { + if ((((this.IsLocalFileSystemWebService(base.Url) == true) + && (this.useDefaultCredentialsSetExplicitly == false)) + && (this.IsLocalFileSystemWebService(value) == false))) { + base.UseDefaultCredentials = false; + } + base.Url = value; + } + } + + public new bool UseDefaultCredentials { + get { + return base.UseDefaultCredentials; + } + set { + base.UseDefaultCredentials = value; + this.useDefaultCredentialsSetExplicitly = true; + } + } + + /// <remarks/> + public event StartCompletedEventHandler StartCompleted; + + /// <remarks/> + public event JoinCompletedEventHandler JoinCompleted; + + /// <remarks/> + public event LeaveCompletedEventHandler LeaveCompleted; + + /// <remarks/> + public event DeleteLinesCompletedEventHandler DeleteLinesCompleted; + + /// <remarks/> + public event InsertLineCompletedEventHandler InsertLineCompleted; + + /// <remarks/> + public event UpdateLineCompletedEventHandler UpdateLineCompleted; + + /// <remarks/> + public event SendMessageCompletedEventHandler SendMessageCompleted; + + /// <remarks/> + public event GetUpdatesCompletedEventHandler GetUpdatesCompleted; + + /// <remarks/> + public event GetSubtitleCompletedEventHandler GetSubtitleCompleted; + + /// <remarks/> + public event GetOriginalSubtitleCompletedEventHandler GetOriginalSubtitleCompleted; + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Start", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SeUser Start(string sessionKey, string userName, SeSequence[] subtitle, SeSequence[] originalSubtitle, string fileName, out string message) { + object[] results = this.Invoke("Start", new object[] { + sessionKey, + userName, + subtitle, + originalSubtitle, + fileName}); + message = ((string)(results[1])); + return ((SeUser)(results[0])); + } + + /// <remarks/> + public void StartAsync(string sessionKey, string userName, SeSequence[] subtitle, SeSequence[] originalSubtitle, string fileName) { + this.StartAsync(sessionKey, userName, subtitle, originalSubtitle, fileName, null); + } + + /// <remarks/> + public void StartAsync(string sessionKey, string userName, SeSequence[] subtitle, SeSequence[] originalSubtitle, string fileName, object userState) { + if ((this.StartOperationCompleted == null)) { + this.StartOperationCompleted = new System.Threading.SendOrPostCallback(this.OnStartOperationCompleted); + } + this.InvokeAsync("Start", new object[] { + sessionKey, + userName, + subtitle, + originalSubtitle, + fileName}, this.StartOperationCompleted, userState); + } + + private void OnStartOperationCompleted(object arg) { + if ((this.StartCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.StartCompleted(this, new StartCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Join", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SeUser[] Join(string sessionId, string userName, out string message) { + object[] results = this.Invoke("Join", new object[] { + sessionId, + userName}); + message = ((string)(results[1])); + return ((SeUser[])(results[0])); + } + + /// <remarks/> + public void JoinAsync(string sessionId, string userName) { + this.JoinAsync(sessionId, userName, null); + } + + /// <remarks/> + public void JoinAsync(string sessionId, string userName, object userState) { + if ((this.JoinOperationCompleted == null)) { + this.JoinOperationCompleted = new System.Threading.SendOrPostCallback(this.OnJoinOperationCompleted); + } + this.InvokeAsync("Join", new object[] { + sessionId, + userName}, this.JoinOperationCompleted, userState); + } + + private void OnJoinOperationCompleted(object arg) { + if ((this.JoinCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.JoinCompleted(this, new JoinCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Leave", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public void Leave(string sessionId, string userName) { + this.Invoke("Leave", new object[] { + sessionId, + userName}); + } + + /// <remarks/> + public void LeaveAsync(string sessionId, string userName) { + this.LeaveAsync(sessionId, userName, null); + } + + /// <remarks/> + public void LeaveAsync(string sessionId, string userName, object userState) { + if ((this.LeaveOperationCompleted == null)) { + this.LeaveOperationCompleted = new System.Threading.SendOrPostCallback(this.OnLeaveOperationCompleted); + } + this.InvokeAsync("Leave", new object[] { + sessionId, + userName}, this.LeaveOperationCompleted, userState); + } + + private void OnLeaveOperationCompleted(object arg) { + if ((this.LeaveCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.LeaveCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/DeleteLines", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public bool DeleteLines(string sessionId, int[] indices, SeUser user) { + object[] results = this.Invoke("DeleteLines", new object[] { + sessionId, + indices, + user}); + return ((bool)(results[0])); + } + + /// <remarks/> + public void DeleteLinesAsync(string sessionId, int[] indices, SeUser user) { + this.DeleteLinesAsync(sessionId, indices, user, null); + } + + /// <remarks/> + public void DeleteLinesAsync(string sessionId, int[] indices, SeUser user, object userState) { + if ((this.DeleteLinesOperationCompleted == null)) { + this.DeleteLinesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDeleteLinesOperationCompleted); + } + this.InvokeAsync("DeleteLines", new object[] { + sessionId, + indices, + user}, this.DeleteLinesOperationCompleted, userState); + } + + private void OnDeleteLinesOperationCompleted(object arg) { + if ((this.DeleteLinesCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.DeleteLinesCompleted(this, new DeleteLinesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/InsertLine", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public bool InsertLine(string sessionId, int index, int startMilliseconds, int endMilliseconds, string text, SeUser user) { + object[] results = this.Invoke("InsertLine", new object[] { + sessionId, + index, + startMilliseconds, + endMilliseconds, + text, + user}); + return ((bool)(results[0])); + } + + /// <remarks/> + public void InsertLineAsync(string sessionId, int index, int startMilliseconds, int endMilliseconds, string text, SeUser user) { + this.InsertLineAsync(sessionId, index, startMilliseconds, endMilliseconds, text, user, null); + } + + /// <remarks/> + public void InsertLineAsync(string sessionId, int index, int startMilliseconds, int endMilliseconds, string text, SeUser user, object userState) { + if ((this.InsertLineOperationCompleted == null)) { + this.InsertLineOperationCompleted = new System.Threading.SendOrPostCallback(this.OnInsertLineOperationCompleted); + } + this.InvokeAsync("InsertLine", new object[] { + sessionId, + index, + startMilliseconds, + endMilliseconds, + text, + user}, this.InsertLineOperationCompleted, userState); + } + + private void OnInsertLineOperationCompleted(object arg) { + if ((this.InsertLineCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.InsertLineCompleted(this, new InsertLineCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/UpdateLine", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public bool UpdateLine(string sessionId, int index, SeSequence sequence, SeUser user) { + object[] results = this.Invoke("UpdateLine", new object[] { + sessionId, + index, + sequence, + user}); + return ((bool)(results[0])); + } + + /// <remarks/> + public void UpdateLineAsync(string sessionId, int index, SeSequence sequence, SeUser user) { + this.UpdateLineAsync(sessionId, index, sequence, user, null); + } + + /// <remarks/> + public void UpdateLineAsync(string sessionId, int index, SeSequence sequence, SeUser user, object userState) { + if ((this.UpdateLineOperationCompleted == null)) { + this.UpdateLineOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateLineOperationCompleted); + } + this.InvokeAsync("UpdateLine", new object[] { + sessionId, + index, + sequence, + user}, this.UpdateLineOperationCompleted, userState); + } + + private void OnUpdateLineOperationCompleted(object arg) { + if ((this.UpdateLineCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.UpdateLineCompleted(this, new UpdateLineCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SendMessage", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public bool SendMessage(string sessionId, string text, SeUser user) { + object[] results = this.Invoke("SendMessage", new object[] { + sessionId, + text, + user}); + return ((bool)(results[0])); + } + + /// <remarks/> + public void SendMessageAsync(string sessionId, string text, SeUser user) { + this.SendMessageAsync(sessionId, text, user, null); + } + + /// <remarks/> + public void SendMessageAsync(string sessionId, string text, SeUser user, object userState) { + if ((this.SendMessageOperationCompleted == null)) { + this.SendMessageOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSendMessageOperationCompleted); + } + this.InvokeAsync("SendMessage", new object[] { + sessionId, + text, + user}, this.SendMessageOperationCompleted, userState); + } + + private void OnSendMessageOperationCompleted(object arg) { + if ((this.SendMessageCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.SendMessageCompleted(this, new SendMessageCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetUpdates", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SeUpdate[] GetUpdates(string sessionId, string userName, System.DateTime lastUpdateTime, out string message, out System.DateTime newUpdateTime, out int numberOfLines) { + object[] results = this.Invoke("GetUpdates", new object[] { + sessionId, + userName, + lastUpdateTime}); + message = ((string)(results[1])); + newUpdateTime = ((System.DateTime)(results[2])); + numberOfLines = ((int)(results[3])); + return ((SeUpdate[])(results[0])); + } + + /// <remarks/> + public void GetUpdatesAsync(string sessionId, string userName, System.DateTime lastUpdateTime) { + this.GetUpdatesAsync(sessionId, userName, lastUpdateTime, null); + } + + /// <remarks/> + public void GetUpdatesAsync(string sessionId, string userName, System.DateTime lastUpdateTime, object userState) { + if ((this.GetUpdatesOperationCompleted == null)) { + this.GetUpdatesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetUpdatesOperationCompleted); + } + this.InvokeAsync("GetUpdates", new object[] { + sessionId, + userName, + lastUpdateTime}, this.GetUpdatesOperationCompleted, userState); + } + + private void OnGetUpdatesOperationCompleted(object arg) { + if ((this.GetUpdatesCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetUpdatesCompleted(this, new GetUpdatesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetSubtitle", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SeSequence[] GetSubtitle(string sessionId, out string fileName, out System.DateTime updateTime) { + object[] results = this.Invoke("GetSubtitle", new object[] { + sessionId}); + fileName = ((string)(results[1])); + updateTime = ((System.DateTime)(results[2])); + return ((SeSequence[])(results[0])); + } + + /// <remarks/> + public void GetSubtitleAsync(string sessionId) { + this.GetSubtitleAsync(sessionId, null); + } + + /// <remarks/> + public void GetSubtitleAsync(string sessionId, object userState) { + if ((this.GetSubtitleOperationCompleted == null)) { + this.GetSubtitleOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetSubtitleOperationCompleted); + } + this.InvokeAsync("GetSubtitle", new object[] { + sessionId}, this.GetSubtitleOperationCompleted, userState); + } + + private void OnGetSubtitleOperationCompleted(object arg) { + if ((this.GetSubtitleCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetSubtitleCompleted(this, new GetSubtitleCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetOriginalSubtitle", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SeSequence[] GetOriginalSubtitle(string sessionId) { + object[] results = this.Invoke("GetOriginalSubtitle", new object[] { + sessionId}); + return ((SeSequence[])(results[0])); + } + + /// <remarks/> + public void GetOriginalSubtitleAsync(string sessionId) { + this.GetOriginalSubtitleAsync(sessionId, null); + } + + /// <remarks/> + public void GetOriginalSubtitleAsync(string sessionId, object userState) { + if ((this.GetOriginalSubtitleOperationCompleted == null)) { + this.GetOriginalSubtitleOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetOriginalSubtitleOperationCompleted); + } + this.InvokeAsync("GetOriginalSubtitle", new object[] { + sessionId}, this.GetOriginalSubtitleOperationCompleted, userState); + } + + private void OnGetOriginalSubtitleOperationCompleted(object arg) { + if ((this.GetOriginalSubtitleCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetOriginalSubtitleCompleted(this, new GetOriginalSubtitleCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + public new void CancelAsync(object userState) { + base.CancelAsync(userState); + } + + private bool IsLocalFileSystemWebService(string url) { + if (((url == null) + || (url == string.Empty))) { + return false; + } + System.Uri wsUri = new System.Uri(url); + if (((wsUri.Port >= 1024) + && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) { + return true; + } + return false; + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] + public partial class SeSequence { + + private int indexField; + + private int startMillisecondsField; + + private int endMillisecondsField; + + private string textField; + + /// <remarks/> + public int Index { + get { + return this.indexField; + } + set { + this.indexField = value; + } + } + + /// <remarks/> + public int StartMilliseconds { + get { + return this.startMillisecondsField; + } + set { + this.startMillisecondsField = value; + } + } + + /// <remarks/> + public int EndMilliseconds { + get { + return this.endMillisecondsField; + } + set { + this.endMillisecondsField = value; + } + } + + /// <remarks/> + public string Text { + get { + return this.textField; + } + set { + this.textField = value; + } + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] + public partial class SeUpdate { + + private System.DateTime timeField; + + private SeUser userField; + + private int indexField; + + private int startMillisecondsField; + + private int endMillisecondsField; + + private string textField; + + private string actionField; + + /// <remarks/> + public System.DateTime Time { + get { + return this.timeField; + } + set { + this.timeField = value; + } + } + + /// <remarks/> + public SeUser User { + get { + return this.userField; + } + set { + this.userField = value; + } + } + + /// <remarks/> + public int Index { + get { + return this.indexField; + } + set { + this.indexField = value; + } + } + + /// <remarks/> + public int StartMilliseconds { + get { + return this.startMillisecondsField; + } + set { + this.startMillisecondsField = value; + } + } + + /// <remarks/> + public int EndMilliseconds { + get { + return this.endMillisecondsField; + } + set { + this.endMillisecondsField = value; + } + } + + /// <remarks/> + public string Text { + get { + return this.textField; + } + set { + this.textField = value; + } + } + + /// <remarks/> + public string Action { + get { + return this.actionField; + } + set { + this.actionField = value; + } + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] + public partial class SeUser { + + private string userNameField; + + private string ipField; + + private System.DateTime lastActivityField; + + /// <remarks/> + public string UserName { + get { + return this.userNameField; + } + set { + this.userNameField = value; + } + } + + /// <remarks/> + public string Ip { + get { + return this.ipField; + } + set { + this.ipField = value; + } + } + + /// <remarks/> + public System.DateTime LastActivity { + get { + return this.lastActivityField; + } + set { + this.lastActivityField = value; + } + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + public delegate void StartCompletedEventHandler(object sender, StartCompletedEventArgs e); + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class StartCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal StartCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public SeUser Result { + get { + this.RaiseExceptionIfNecessary(); + return ((SeUser)(this.results[0])); + } + } + + /// <remarks/> + public string message { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[1])); + } + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + public delegate void JoinCompletedEventHandler(object sender, JoinCompletedEventArgs e); + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class JoinCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal JoinCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public SeUser[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((SeUser[])(this.results[0])); + } + } + + /// <remarks/> + public string message { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[1])); + } + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + public delegate void LeaveCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e); + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + public delegate void DeleteLinesCompletedEventHandler(object sender, DeleteLinesCompletedEventArgs e); + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class DeleteLinesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal DeleteLinesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + public delegate void InsertLineCompletedEventHandler(object sender, InsertLineCompletedEventArgs e); + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class InsertLineCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal InsertLineCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + public delegate void UpdateLineCompletedEventHandler(object sender, UpdateLineCompletedEventArgs e); + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class UpdateLineCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal UpdateLineCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + public delegate void SendMessageCompletedEventHandler(object sender, SendMessageCompletedEventArgs e); + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class SendMessageCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal SendMessageCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + public delegate void GetUpdatesCompletedEventHandler(object sender, GetUpdatesCompletedEventArgs e); + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetUpdatesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetUpdatesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public SeUpdate[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((SeUpdate[])(this.results[0])); + } + } + + /// <remarks/> + public string message { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[1])); + } + } + + /// <remarks/> + public System.DateTime newUpdateTime { + get { + this.RaiseExceptionIfNecessary(); + return ((System.DateTime)(this.results[2])); + } + } + + /// <remarks/> + public int numberOfLines { + get { + this.RaiseExceptionIfNecessary(); + return ((int)(this.results[3])); + } + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + public delegate void GetSubtitleCompletedEventHandler(object sender, GetSubtitleCompletedEventArgs e); + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetSubtitleCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetSubtitleCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public SeSequence[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((SeSequence[])(this.results[0])); + } + } + + /// <remarks/> + public string fileName { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[1])); + } + } + + /// <remarks/> + public System.DateTime updateTime { + get { + this.RaiseExceptionIfNecessary(); + return ((System.DateTime)(this.results[2])); + } + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + public delegate void GetOriginalSubtitleCompletedEventHandler(object sender, GetOriginalSubtitleCompletedEventArgs e); + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetOriginalSubtitleCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetOriginalSubtitleCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public SeSequence[] Result { + get { + this.RaiseExceptionIfNecessary(); + return ((SeSequence[])(this.results[0])); + } + } + } +} + #pragma warning restore 1591 \ No newline at end of file diff --git a/src/Web References/SeNetworkService/Reference.map b/src/ui/Web References/SeNetworkService/Reference.map similarity index 98% rename from src/Web References/SeNetworkService/Reference.map rename to src/ui/Web References/SeNetworkService/Reference.map index 1e0d2be34..ef75c55b2 100644 --- a/src/Web References/SeNetworkService/Reference.map +++ b/src/ui/Web References/SeNetworkService/Reference.map @@ -1,7 +1,7 @@ -<?xml version="1.0" encoding="utf-8"?> -<DiscoveryClientResultsFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <Results> - <DiscoveryClientResult referenceType="System.Web.Services.Discovery.ContractReference" url="http://localhost:2782/se/SeService.asmx?wsdl" filename="SeService.wsdl" /> - <DiscoveryClientResult referenceType="System.Web.Services.Discovery.DiscoveryDocumentReference" url="http://localhost:2782/se/SeService.asmx?disco" filename="SeService.disco" /> - </Results> +<?xml version="1.0" encoding="utf-8"?> +<DiscoveryClientResultsFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Results> + <DiscoveryClientResult referenceType="System.Web.Services.Discovery.ContractReference" url="http://localhost:2782/se/SeService.asmx?wsdl" filename="SeService.wsdl" /> + <DiscoveryClientResult referenceType="System.Web.Services.Discovery.DiscoveryDocumentReference" url="http://localhost:2782/se/SeService.asmx?disco" filename="SeService.disco" /> + </Results> </DiscoveryClientResultsFile> \ No newline at end of file diff --git a/src/Web References/SeNetworkService/SeSequence.datasource b/src/ui/Web References/SeNetworkService/SeSequence.datasource similarity index 98% rename from src/Web References/SeNetworkService/SeSequence.datasource rename to src/ui/Web References/SeNetworkService/SeSequence.datasource index 9b7dbc5c1..bc52dff83 100644 --- a/src/Web References/SeNetworkService/SeSequence.datasource +++ b/src/ui/Web References/SeNetworkService/SeSequence.datasource @@ -1,10 +1,10 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - This file is automatically generated by Visual Studio .Net. It is - used to store generic object data source configuration information. - Renaming the file extension or editing the content of this file may - cause the file to be unrecognizable by the program. ---> -<GenericObjectDataSource DisplayName="SeSequence" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> - <TypeInfo>Nikse.SubtitleEdit.SeNetworkService.SeSequence, Web References.SeNetworkService.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo> +<?xml version="1.0" encoding="utf-8"?> +<!-- + This file is automatically generated by Visual Studio .Net. It is + used to store generic object data source configuration information. + Renaming the file extension or editing the content of this file may + cause the file to be unrecognizable by the program. +--> +<GenericObjectDataSource DisplayName="SeSequence" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> + <TypeInfo>Nikse.SubtitleEdit.SeNetworkService.SeSequence, Web References.SeNetworkService.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo> </GenericObjectDataSource> \ No newline at end of file diff --git a/src/Web References/SeNetworkService/SeService.disco b/src/ui/Web References/SeNetworkService/SeService.disco similarity index 99% rename from src/Web References/SeNetworkService/SeService.disco rename to src/ui/Web References/SeNetworkService/SeService.disco index 52c06b987..22d263bf1 100644 --- a/src/Web References/SeNetworkService/SeService.disco +++ b/src/ui/Web References/SeNetworkService/SeService.disco @@ -1,6 +1,6 @@ -<?xml version="1.0" encoding="utf-8"?> -<discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/"> - <contractRef ref="http://localhost:2782/se/SeService.asmx?wsdl" docRef="http://localhost:2782/se/SeService.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" /> - <soap address="http://localhost:2782/se/SeService.asmx" xmlns:q1="http://tempuri.org/" binding="q1:SeServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" /> - <soap address="http://localhost:2782/se/SeService.asmx" xmlns:q2="http://tempuri.org/" binding="q2:SeServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" /> +<?xml version="1.0" encoding="utf-8"?> +<discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/"> + <contractRef ref="http://localhost:2782/se/SeService.asmx?wsdl" docRef="http://localhost:2782/se/SeService.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" /> + <soap address="http://localhost:2782/se/SeService.asmx" xmlns:q1="http://tempuri.org/" binding="q1:SeServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" /> + <soap address="http://localhost:2782/se/SeService.asmx" xmlns:q2="http://tempuri.org/" binding="q2:SeServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" /> </discovery> \ No newline at end of file diff --git a/src/Web References/SeNetworkService/SeService.wsdl b/src/ui/Web References/SeNetworkService/SeService.wsdl similarity index 97% rename from src/Web References/SeNetworkService/SeService.wsdl rename to src/ui/Web References/SeNetworkService/SeService.wsdl index 0894d9714..67e94424b 100644 --- a/src/Web References/SeNetworkService/SeService.wsdl +++ b/src/ui/Web References/SeNetworkService/SeService.wsdl @@ -1,512 +1,512 @@ -<?xml version="1.0" encoding="utf-8"?> -<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> - <wsdl:types> - <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/"> - <s:element name="Start"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="sessionKey" type="s:string" /> - <s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string" /> - <s:element minOccurs="0" maxOccurs="1" name="subtitle" type="tns:ArrayOfSeSequence" /> - <s:element minOccurs="0" maxOccurs="1" name="originalSubtitle" type="tns:ArrayOfSeSequence" /> - <s:element minOccurs="0" maxOccurs="1" name="fileName" type="s:string" /> - </s:sequence> - </s:complexType> - </s:element> - <s:complexType name="ArrayOfSeSequence"> - <s:sequence> - <s:element minOccurs="0" maxOccurs="unbounded" name="SeSequence" nillable="true" type="tns:SeSequence" /> - </s:sequence> - </s:complexType> - <s:complexType name="SeSequence"> - <s:sequence> - <s:element minOccurs="1" maxOccurs="1" name="Index" type="s:int" /> - <s:element minOccurs="1" maxOccurs="1" name="StartMilliseconds" type="s:int" /> - <s:element minOccurs="1" maxOccurs="1" name="EndMilliseconds" type="s:int" /> - <s:element minOccurs="0" maxOccurs="1" name="Text" type="s:string" /> - </s:sequence> - </s:complexType> - <s:element name="StartResponse"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="StartResult" type="tns:SeUser" /> - <s:element minOccurs="0" maxOccurs="1" name="message" type="s:string" /> - </s:sequence> - </s:complexType> - </s:element> - <s:complexType name="SeUser"> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string" /> - <s:element minOccurs="0" maxOccurs="1" name="Ip" type="s:string" /> - <s:element minOccurs="1" maxOccurs="1" name="LastActivity" type="s:dateTime" /> - </s:sequence> - </s:complexType> - <s:element name="Join"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> - <s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="JoinResponse"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="JoinResult" type="tns:ArrayOfSeUser" /> - <s:element minOccurs="0" maxOccurs="1" name="message" type="s:string" /> - </s:sequence> - </s:complexType> - </s:element> - <s:complexType name="ArrayOfSeUser"> - <s:sequence> - <s:element minOccurs="0" maxOccurs="unbounded" name="SeUser" nillable="true" type="tns:SeUser" /> - </s:sequence> - </s:complexType> - <s:element name="Leave"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> - <s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="LeaveResponse"> - <s:complexType /> - </s:element> - <s:element name="DeleteLines"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> - <s:element minOccurs="0" maxOccurs="1" name="indices" type="tns:ArrayOfInt" /> - <s:element minOccurs="0" maxOccurs="1" name="user" type="tns:SeUser" /> - </s:sequence> - </s:complexType> - </s:element> - <s:complexType name="ArrayOfInt"> - <s:sequence> - <s:element minOccurs="0" maxOccurs="unbounded" name="int" type="s:int" /> - </s:sequence> - </s:complexType> - <s:element name="DeleteLinesResponse"> - <s:complexType> - <s:sequence> - <s:element minOccurs="1" maxOccurs="1" name="DeleteLinesResult" type="s:boolean" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="InsertLine"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> - <s:element minOccurs="1" maxOccurs="1" name="index" type="s:int" /> - <s:element minOccurs="1" maxOccurs="1" name="startMilliseconds" type="s:int" /> - <s:element minOccurs="1" maxOccurs="1" name="endMilliseconds" type="s:int" /> - <s:element minOccurs="0" maxOccurs="1" name="text" type="s:string" /> - <s:element minOccurs="0" maxOccurs="1" name="user" type="tns:SeUser" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="InsertLineResponse"> - <s:complexType> - <s:sequence> - <s:element minOccurs="1" maxOccurs="1" name="InsertLineResult" type="s:boolean" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="UpdateLine"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> - <s:element minOccurs="1" maxOccurs="1" name="index" type="s:int" /> - <s:element minOccurs="0" maxOccurs="1" name="sequence" type="tns:SeSequence" /> - <s:element minOccurs="0" maxOccurs="1" name="user" type="tns:SeUser" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="UpdateLineResponse"> - <s:complexType> - <s:sequence> - <s:element minOccurs="1" maxOccurs="1" name="UpdateLineResult" type="s:boolean" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="SendMessage"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> - <s:element minOccurs="0" maxOccurs="1" name="text" type="s:string" /> - <s:element minOccurs="0" maxOccurs="1" name="user" type="tns:SeUser" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="SendMessageResponse"> - <s:complexType> - <s:sequence> - <s:element minOccurs="1" maxOccurs="1" name="SendMessageResult" type="s:boolean" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="GetUpdates"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> - <s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string" /> - <s:element minOccurs="1" maxOccurs="1" name="lastUpdateTime" type="s:dateTime" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="GetUpdatesResponse"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="GetUpdatesResult" type="tns:ArrayOfSeUpdate" /> - <s:element minOccurs="0" maxOccurs="1" name="message" type="s:string" /> - <s:element minOccurs="1" maxOccurs="1" name="newUpdateTime" type="s:dateTime" /> - <s:element minOccurs="1" maxOccurs="1" name="numberOfLines" type="s:int" /> - </s:sequence> - </s:complexType> - </s:element> - <s:complexType name="ArrayOfSeUpdate"> - <s:sequence> - <s:element minOccurs="0" maxOccurs="unbounded" name="SeUpdate" nillable="true" type="tns:SeUpdate" /> - </s:sequence> - </s:complexType> - <s:complexType name="SeUpdate"> - <s:sequence> - <s:element minOccurs="1" maxOccurs="1" name="Time" type="s:dateTime" /> - <s:element minOccurs="0" maxOccurs="1" name="User" type="tns:SeUser" /> - <s:element minOccurs="1" maxOccurs="1" name="Index" type="s:int" /> - <s:element minOccurs="1" maxOccurs="1" name="StartMilliseconds" type="s:int" /> - <s:element minOccurs="1" maxOccurs="1" name="EndMilliseconds" type="s:int" /> - <s:element minOccurs="0" maxOccurs="1" name="Text" type="s:string" /> - <s:element minOccurs="0" maxOccurs="1" name="Action" type="s:string" /> - </s:sequence> - </s:complexType> - <s:element name="GetSubtitle"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="GetSubtitleResponse"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="GetSubtitleResult" type="tns:ArrayOfSeSequence" /> - <s:element minOccurs="0" maxOccurs="1" name="fileName" type="s:string" /> - <s:element minOccurs="1" maxOccurs="1" name="updateTime" type="s:dateTime" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="GetOriginalSubtitle"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> - </s:sequence> - </s:complexType> - </s:element> - <s:element name="GetOriginalSubtitleResponse"> - <s:complexType> - <s:sequence> - <s:element minOccurs="0" maxOccurs="1" name="GetOriginalSubtitleResult" type="tns:ArrayOfSeSequence" /> - </s:sequence> - </s:complexType> - </s:element> - </s:schema> - </wsdl:types> - <wsdl:message name="StartSoapIn"> - <wsdl:part name="parameters" element="tns:Start" /> - </wsdl:message> - <wsdl:message name="StartSoapOut"> - <wsdl:part name="parameters" element="tns:StartResponse" /> - </wsdl:message> - <wsdl:message name="JoinSoapIn"> - <wsdl:part name="parameters" element="tns:Join" /> - </wsdl:message> - <wsdl:message name="JoinSoapOut"> - <wsdl:part name="parameters" element="tns:JoinResponse" /> - </wsdl:message> - <wsdl:message name="LeaveSoapIn"> - <wsdl:part name="parameters" element="tns:Leave" /> - </wsdl:message> - <wsdl:message name="LeaveSoapOut"> - <wsdl:part name="parameters" element="tns:LeaveResponse" /> - </wsdl:message> - <wsdl:message name="DeleteLinesSoapIn"> - <wsdl:part name="parameters" element="tns:DeleteLines" /> - </wsdl:message> - <wsdl:message name="DeleteLinesSoapOut"> - <wsdl:part name="parameters" element="tns:DeleteLinesResponse" /> - </wsdl:message> - <wsdl:message name="InsertLineSoapIn"> - <wsdl:part name="parameters" element="tns:InsertLine" /> - </wsdl:message> - <wsdl:message name="InsertLineSoapOut"> - <wsdl:part name="parameters" element="tns:InsertLineResponse" /> - </wsdl:message> - <wsdl:message name="UpdateLineSoapIn"> - <wsdl:part name="parameters" element="tns:UpdateLine" /> - </wsdl:message> - <wsdl:message name="UpdateLineSoapOut"> - <wsdl:part name="parameters" element="tns:UpdateLineResponse" /> - </wsdl:message> - <wsdl:message name="SendMessageSoapIn"> - <wsdl:part name="parameters" element="tns:SendMessage" /> - </wsdl:message> - <wsdl:message name="SendMessageSoapOut"> - <wsdl:part name="parameters" element="tns:SendMessageResponse" /> - </wsdl:message> - <wsdl:message name="GetUpdatesSoapIn"> - <wsdl:part name="parameters" element="tns:GetUpdates" /> - </wsdl:message> - <wsdl:message name="GetUpdatesSoapOut"> - <wsdl:part name="parameters" element="tns:GetUpdatesResponse" /> - </wsdl:message> - <wsdl:message name="GetSubtitleSoapIn"> - <wsdl:part name="parameters" element="tns:GetSubtitle" /> - </wsdl:message> - <wsdl:message name="GetSubtitleSoapOut"> - <wsdl:part name="parameters" element="tns:GetSubtitleResponse" /> - </wsdl:message> - <wsdl:message name="GetOriginalSubtitleSoapIn"> - <wsdl:part name="parameters" element="tns:GetOriginalSubtitle" /> - </wsdl:message> - <wsdl:message name="GetOriginalSubtitleSoapOut"> - <wsdl:part name="parameters" element="tns:GetOriginalSubtitleResponse" /> - </wsdl:message> - <wsdl:portType name="SeServiceSoap"> - <wsdl:operation name="Start"> - <wsdl:input message="tns:StartSoapIn" /> - <wsdl:output message="tns:StartSoapOut" /> - </wsdl:operation> - <wsdl:operation name="Join"> - <wsdl:input message="tns:JoinSoapIn" /> - <wsdl:output message="tns:JoinSoapOut" /> - </wsdl:operation> - <wsdl:operation name="Leave"> - <wsdl:input message="tns:LeaveSoapIn" /> - <wsdl:output message="tns:LeaveSoapOut" /> - </wsdl:operation> - <wsdl:operation name="DeleteLines"> - <wsdl:input message="tns:DeleteLinesSoapIn" /> - <wsdl:output message="tns:DeleteLinesSoapOut" /> - </wsdl:operation> - <wsdl:operation name="InsertLine"> - <wsdl:input message="tns:InsertLineSoapIn" /> - <wsdl:output message="tns:InsertLineSoapOut" /> - </wsdl:operation> - <wsdl:operation name="UpdateLine"> - <wsdl:input message="tns:UpdateLineSoapIn" /> - <wsdl:output message="tns:UpdateLineSoapOut" /> - </wsdl:operation> - <wsdl:operation name="SendMessage"> - <wsdl:input message="tns:SendMessageSoapIn" /> - <wsdl:output message="tns:SendMessageSoapOut" /> - </wsdl:operation> - <wsdl:operation name="GetUpdates"> - <wsdl:input message="tns:GetUpdatesSoapIn" /> - <wsdl:output message="tns:GetUpdatesSoapOut" /> - </wsdl:operation> - <wsdl:operation name="GetSubtitle"> - <wsdl:input message="tns:GetSubtitleSoapIn" /> - <wsdl:output message="tns:GetSubtitleSoapOut" /> - </wsdl:operation> - <wsdl:operation name="GetOriginalSubtitle"> - <wsdl:input message="tns:GetOriginalSubtitleSoapIn" /> - <wsdl:output message="tns:GetOriginalSubtitleSoapOut" /> - </wsdl:operation> - </wsdl:portType> - <wsdl:binding name="SeServiceSoap" type="tns:SeServiceSoap"> - <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> - <wsdl:operation name="Start"> - <soap:operation soapAction="http://tempuri.org/Start" style="document" /> - <wsdl:input> - <soap:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="Join"> - <soap:operation soapAction="http://tempuri.org/Join" style="document" /> - <wsdl:input> - <soap:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="Leave"> - <soap:operation soapAction="http://tempuri.org/Leave" style="document" /> - <wsdl:input> - <soap:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="DeleteLines"> - <soap:operation soapAction="http://tempuri.org/DeleteLines" style="document" /> - <wsdl:input> - <soap:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="InsertLine"> - <soap:operation soapAction="http://tempuri.org/InsertLine" style="document" /> - <wsdl:input> - <soap:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="UpdateLine"> - <soap:operation soapAction="http://tempuri.org/UpdateLine" style="document" /> - <wsdl:input> - <soap:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="SendMessage"> - <soap:operation soapAction="http://tempuri.org/SendMessage" style="document" /> - <wsdl:input> - <soap:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="GetUpdates"> - <soap:operation soapAction="http://tempuri.org/GetUpdates" style="document" /> - <wsdl:input> - <soap:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="GetSubtitle"> - <soap:operation soapAction="http://tempuri.org/GetSubtitle" style="document" /> - <wsdl:input> - <soap:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="GetOriginalSubtitle"> - <soap:operation soapAction="http://tempuri.org/GetOriginalSubtitle" style="document" /> - <wsdl:input> - <soap:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap:body use="literal" /> - </wsdl:output> - </wsdl:operation> - </wsdl:binding> - <wsdl:binding name="SeServiceSoap12" type="tns:SeServiceSoap"> - <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /> - <wsdl:operation name="Start"> - <soap12:operation soapAction="http://tempuri.org/Start" style="document" /> - <wsdl:input> - <soap12:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap12:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="Join"> - <soap12:operation soapAction="http://tempuri.org/Join" style="document" /> - <wsdl:input> - <soap12:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap12:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="Leave"> - <soap12:operation soapAction="http://tempuri.org/Leave" style="document" /> - <wsdl:input> - <soap12:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap12:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="DeleteLines"> - <soap12:operation soapAction="http://tempuri.org/DeleteLines" style="document" /> - <wsdl:input> - <soap12:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap12:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="InsertLine"> - <soap12:operation soapAction="http://tempuri.org/InsertLine" style="document" /> - <wsdl:input> - <soap12:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap12:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="UpdateLine"> - <soap12:operation soapAction="http://tempuri.org/UpdateLine" style="document" /> - <wsdl:input> - <soap12:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap12:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="SendMessage"> - <soap12:operation soapAction="http://tempuri.org/SendMessage" style="document" /> - <wsdl:input> - <soap12:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap12:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="GetUpdates"> - <soap12:operation soapAction="http://tempuri.org/GetUpdates" style="document" /> - <wsdl:input> - <soap12:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap12:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="GetSubtitle"> - <soap12:operation soapAction="http://tempuri.org/GetSubtitle" style="document" /> - <wsdl:input> - <soap12:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap12:body use="literal" /> - </wsdl:output> - </wsdl:operation> - <wsdl:operation name="GetOriginalSubtitle"> - <soap12:operation soapAction="http://tempuri.org/GetOriginalSubtitle" style="document" /> - <wsdl:input> - <soap12:body use="literal" /> - </wsdl:input> - <wsdl:output> - <soap12:body use="literal" /> - </wsdl:output> - </wsdl:operation> - </wsdl:binding> - <wsdl:service name="SeService"> - <wsdl:port name="SeServiceSoap" binding="tns:SeServiceSoap"> - <soap:address location="http://localhost:2782/se/SeService.asmx" /> - </wsdl:port> - <wsdl:port name="SeServiceSoap12" binding="tns:SeServiceSoap12"> - <soap12:address location="http://localhost:2782/se/SeService.asmx" /> - </wsdl:port> - </wsdl:service> -</wsdl:definitions> +<?xml version="1.0" encoding="utf-8"?> +<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> + <wsdl:types> + <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/"> + <s:element name="Start"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="sessionKey" type="s:string" /> + <s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string" /> + <s:element minOccurs="0" maxOccurs="1" name="subtitle" type="tns:ArrayOfSeSequence" /> + <s:element minOccurs="0" maxOccurs="1" name="originalSubtitle" type="tns:ArrayOfSeSequence" /> + <s:element minOccurs="0" maxOccurs="1" name="fileName" type="s:string" /> + </s:sequence> + </s:complexType> + </s:element> + <s:complexType name="ArrayOfSeSequence"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="unbounded" name="SeSequence" nillable="true" type="tns:SeSequence" /> + </s:sequence> + </s:complexType> + <s:complexType name="SeSequence"> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="Index" type="s:int" /> + <s:element minOccurs="1" maxOccurs="1" name="StartMilliseconds" type="s:int" /> + <s:element minOccurs="1" maxOccurs="1" name="EndMilliseconds" type="s:int" /> + <s:element minOccurs="0" maxOccurs="1" name="Text" type="s:string" /> + </s:sequence> + </s:complexType> + <s:element name="StartResponse"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="StartResult" type="tns:SeUser" /> + <s:element minOccurs="0" maxOccurs="1" name="message" type="s:string" /> + </s:sequence> + </s:complexType> + </s:element> + <s:complexType name="SeUser"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string" /> + <s:element minOccurs="0" maxOccurs="1" name="Ip" type="s:string" /> + <s:element minOccurs="1" maxOccurs="1" name="LastActivity" type="s:dateTime" /> + </s:sequence> + </s:complexType> + <s:element name="Join"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> + <s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="JoinResponse"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="JoinResult" type="tns:ArrayOfSeUser" /> + <s:element minOccurs="0" maxOccurs="1" name="message" type="s:string" /> + </s:sequence> + </s:complexType> + </s:element> + <s:complexType name="ArrayOfSeUser"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="unbounded" name="SeUser" nillable="true" type="tns:SeUser" /> + </s:sequence> + </s:complexType> + <s:element name="Leave"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> + <s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="LeaveResponse"> + <s:complexType /> + </s:element> + <s:element name="DeleteLines"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> + <s:element minOccurs="0" maxOccurs="1" name="indices" type="tns:ArrayOfInt" /> + <s:element minOccurs="0" maxOccurs="1" name="user" type="tns:SeUser" /> + </s:sequence> + </s:complexType> + </s:element> + <s:complexType name="ArrayOfInt"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="unbounded" name="int" type="s:int" /> + </s:sequence> + </s:complexType> + <s:element name="DeleteLinesResponse"> + <s:complexType> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="DeleteLinesResult" type="s:boolean" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="InsertLine"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> + <s:element minOccurs="1" maxOccurs="1" name="index" type="s:int" /> + <s:element minOccurs="1" maxOccurs="1" name="startMilliseconds" type="s:int" /> + <s:element minOccurs="1" maxOccurs="1" name="endMilliseconds" type="s:int" /> + <s:element minOccurs="0" maxOccurs="1" name="text" type="s:string" /> + <s:element minOccurs="0" maxOccurs="1" name="user" type="tns:SeUser" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="InsertLineResponse"> + <s:complexType> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="InsertLineResult" type="s:boolean" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="UpdateLine"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> + <s:element minOccurs="1" maxOccurs="1" name="index" type="s:int" /> + <s:element minOccurs="0" maxOccurs="1" name="sequence" type="tns:SeSequence" /> + <s:element minOccurs="0" maxOccurs="1" name="user" type="tns:SeUser" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="UpdateLineResponse"> + <s:complexType> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="UpdateLineResult" type="s:boolean" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="SendMessage"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> + <s:element minOccurs="0" maxOccurs="1" name="text" type="s:string" /> + <s:element minOccurs="0" maxOccurs="1" name="user" type="tns:SeUser" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="SendMessageResponse"> + <s:complexType> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="SendMessageResult" type="s:boolean" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="GetUpdates"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> + <s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string" /> + <s:element minOccurs="1" maxOccurs="1" name="lastUpdateTime" type="s:dateTime" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="GetUpdatesResponse"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="GetUpdatesResult" type="tns:ArrayOfSeUpdate" /> + <s:element minOccurs="0" maxOccurs="1" name="message" type="s:string" /> + <s:element minOccurs="1" maxOccurs="1" name="newUpdateTime" type="s:dateTime" /> + <s:element minOccurs="1" maxOccurs="1" name="numberOfLines" type="s:int" /> + </s:sequence> + </s:complexType> + </s:element> + <s:complexType name="ArrayOfSeUpdate"> + <s:sequence> + <s:element minOccurs="0" maxOccurs="unbounded" name="SeUpdate" nillable="true" type="tns:SeUpdate" /> + </s:sequence> + </s:complexType> + <s:complexType name="SeUpdate"> + <s:sequence> + <s:element minOccurs="1" maxOccurs="1" name="Time" type="s:dateTime" /> + <s:element minOccurs="0" maxOccurs="1" name="User" type="tns:SeUser" /> + <s:element minOccurs="1" maxOccurs="1" name="Index" type="s:int" /> + <s:element minOccurs="1" maxOccurs="1" name="StartMilliseconds" type="s:int" /> + <s:element minOccurs="1" maxOccurs="1" name="EndMilliseconds" type="s:int" /> + <s:element minOccurs="0" maxOccurs="1" name="Text" type="s:string" /> + <s:element minOccurs="0" maxOccurs="1" name="Action" type="s:string" /> + </s:sequence> + </s:complexType> + <s:element name="GetSubtitle"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="GetSubtitleResponse"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="GetSubtitleResult" type="tns:ArrayOfSeSequence" /> + <s:element minOccurs="0" maxOccurs="1" name="fileName" type="s:string" /> + <s:element minOccurs="1" maxOccurs="1" name="updateTime" type="s:dateTime" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="GetOriginalSubtitle"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="sessionId" type="s:string" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="GetOriginalSubtitleResponse"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="GetOriginalSubtitleResult" type="tns:ArrayOfSeSequence" /> + </s:sequence> + </s:complexType> + </s:element> + </s:schema> + </wsdl:types> + <wsdl:message name="StartSoapIn"> + <wsdl:part name="parameters" element="tns:Start" /> + </wsdl:message> + <wsdl:message name="StartSoapOut"> + <wsdl:part name="parameters" element="tns:StartResponse" /> + </wsdl:message> + <wsdl:message name="JoinSoapIn"> + <wsdl:part name="parameters" element="tns:Join" /> + </wsdl:message> + <wsdl:message name="JoinSoapOut"> + <wsdl:part name="parameters" element="tns:JoinResponse" /> + </wsdl:message> + <wsdl:message name="LeaveSoapIn"> + <wsdl:part name="parameters" element="tns:Leave" /> + </wsdl:message> + <wsdl:message name="LeaveSoapOut"> + <wsdl:part name="parameters" element="tns:LeaveResponse" /> + </wsdl:message> + <wsdl:message name="DeleteLinesSoapIn"> + <wsdl:part name="parameters" element="tns:DeleteLines" /> + </wsdl:message> + <wsdl:message name="DeleteLinesSoapOut"> + <wsdl:part name="parameters" element="tns:DeleteLinesResponse" /> + </wsdl:message> + <wsdl:message name="InsertLineSoapIn"> + <wsdl:part name="parameters" element="tns:InsertLine" /> + </wsdl:message> + <wsdl:message name="InsertLineSoapOut"> + <wsdl:part name="parameters" element="tns:InsertLineResponse" /> + </wsdl:message> + <wsdl:message name="UpdateLineSoapIn"> + <wsdl:part name="parameters" element="tns:UpdateLine" /> + </wsdl:message> + <wsdl:message name="UpdateLineSoapOut"> + <wsdl:part name="parameters" element="tns:UpdateLineResponse" /> + </wsdl:message> + <wsdl:message name="SendMessageSoapIn"> + <wsdl:part name="parameters" element="tns:SendMessage" /> + </wsdl:message> + <wsdl:message name="SendMessageSoapOut"> + <wsdl:part name="parameters" element="tns:SendMessageResponse" /> + </wsdl:message> + <wsdl:message name="GetUpdatesSoapIn"> + <wsdl:part name="parameters" element="tns:GetUpdates" /> + </wsdl:message> + <wsdl:message name="GetUpdatesSoapOut"> + <wsdl:part name="parameters" element="tns:GetUpdatesResponse" /> + </wsdl:message> + <wsdl:message name="GetSubtitleSoapIn"> + <wsdl:part name="parameters" element="tns:GetSubtitle" /> + </wsdl:message> + <wsdl:message name="GetSubtitleSoapOut"> + <wsdl:part name="parameters" element="tns:GetSubtitleResponse" /> + </wsdl:message> + <wsdl:message name="GetOriginalSubtitleSoapIn"> + <wsdl:part name="parameters" element="tns:GetOriginalSubtitle" /> + </wsdl:message> + <wsdl:message name="GetOriginalSubtitleSoapOut"> + <wsdl:part name="parameters" element="tns:GetOriginalSubtitleResponse" /> + </wsdl:message> + <wsdl:portType name="SeServiceSoap"> + <wsdl:operation name="Start"> + <wsdl:input message="tns:StartSoapIn" /> + <wsdl:output message="tns:StartSoapOut" /> + </wsdl:operation> + <wsdl:operation name="Join"> + <wsdl:input message="tns:JoinSoapIn" /> + <wsdl:output message="tns:JoinSoapOut" /> + </wsdl:operation> + <wsdl:operation name="Leave"> + <wsdl:input message="tns:LeaveSoapIn" /> + <wsdl:output message="tns:LeaveSoapOut" /> + </wsdl:operation> + <wsdl:operation name="DeleteLines"> + <wsdl:input message="tns:DeleteLinesSoapIn" /> + <wsdl:output message="tns:DeleteLinesSoapOut" /> + </wsdl:operation> + <wsdl:operation name="InsertLine"> + <wsdl:input message="tns:InsertLineSoapIn" /> + <wsdl:output message="tns:InsertLineSoapOut" /> + </wsdl:operation> + <wsdl:operation name="UpdateLine"> + <wsdl:input message="tns:UpdateLineSoapIn" /> + <wsdl:output message="tns:UpdateLineSoapOut" /> + </wsdl:operation> + <wsdl:operation name="SendMessage"> + <wsdl:input message="tns:SendMessageSoapIn" /> + <wsdl:output message="tns:SendMessageSoapOut" /> + </wsdl:operation> + <wsdl:operation name="GetUpdates"> + <wsdl:input message="tns:GetUpdatesSoapIn" /> + <wsdl:output message="tns:GetUpdatesSoapOut" /> + </wsdl:operation> + <wsdl:operation name="GetSubtitle"> + <wsdl:input message="tns:GetSubtitleSoapIn" /> + <wsdl:output message="tns:GetSubtitleSoapOut" /> + </wsdl:operation> + <wsdl:operation name="GetOriginalSubtitle"> + <wsdl:input message="tns:GetOriginalSubtitleSoapIn" /> + <wsdl:output message="tns:GetOriginalSubtitleSoapOut" /> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="SeServiceSoap" type="tns:SeServiceSoap"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> + <wsdl:operation name="Start"> + <soap:operation soapAction="http://tempuri.org/Start" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="Join"> + <soap:operation soapAction="http://tempuri.org/Join" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="Leave"> + <soap:operation soapAction="http://tempuri.org/Leave" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="DeleteLines"> + <soap:operation soapAction="http://tempuri.org/DeleteLines" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="InsertLine"> + <soap:operation soapAction="http://tempuri.org/InsertLine" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="UpdateLine"> + <soap:operation soapAction="http://tempuri.org/UpdateLine" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="SendMessage"> + <soap:operation soapAction="http://tempuri.org/SendMessage" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="GetUpdates"> + <soap:operation soapAction="http://tempuri.org/GetUpdates" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="GetSubtitle"> + <soap:operation soapAction="http://tempuri.org/GetSubtitle" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="GetOriginalSubtitle"> + <soap:operation soapAction="http://tempuri.org/GetOriginalSubtitle" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + <wsdl:binding name="SeServiceSoap12" type="tns:SeServiceSoap"> + <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /> + <wsdl:operation name="Start"> + <soap12:operation soapAction="http://tempuri.org/Start" style="document" /> + <wsdl:input> + <soap12:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap12:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="Join"> + <soap12:operation soapAction="http://tempuri.org/Join" style="document" /> + <wsdl:input> + <soap12:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap12:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="Leave"> + <soap12:operation soapAction="http://tempuri.org/Leave" style="document" /> + <wsdl:input> + <soap12:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap12:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="DeleteLines"> + <soap12:operation soapAction="http://tempuri.org/DeleteLines" style="document" /> + <wsdl:input> + <soap12:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap12:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="InsertLine"> + <soap12:operation soapAction="http://tempuri.org/InsertLine" style="document" /> + <wsdl:input> + <soap12:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap12:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="UpdateLine"> + <soap12:operation soapAction="http://tempuri.org/UpdateLine" style="document" /> + <wsdl:input> + <soap12:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap12:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="SendMessage"> + <soap12:operation soapAction="http://tempuri.org/SendMessage" style="document" /> + <wsdl:input> + <soap12:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap12:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="GetUpdates"> + <soap12:operation soapAction="http://tempuri.org/GetUpdates" style="document" /> + <wsdl:input> + <soap12:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap12:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="GetSubtitle"> + <soap12:operation soapAction="http://tempuri.org/GetSubtitle" style="document" /> + <wsdl:input> + <soap12:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap12:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="GetOriginalSubtitle"> + <soap12:operation soapAction="http://tempuri.org/GetOriginalSubtitle" style="document" /> + <wsdl:input> + <soap12:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap12:body use="literal" /> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="SeService"> + <wsdl:port name="SeServiceSoap" binding="tns:SeServiceSoap"> + <soap:address location="http://localhost:2782/se/SeService.asmx" /> + </wsdl:port> + <wsdl:port name="SeServiceSoap12" binding="tns:SeServiceSoap12"> + <soap12:address location="http://localhost:2782/se/SeService.asmx" /> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> diff --git a/src/Web References/SeNetworkService/SeUpdate.datasource b/src/ui/Web References/SeNetworkService/SeUpdate.datasource similarity index 98% rename from src/Web References/SeNetworkService/SeUpdate.datasource rename to src/ui/Web References/SeNetworkService/SeUpdate.datasource index b5d0b1e97..951b13dd5 100644 --- a/src/Web References/SeNetworkService/SeUpdate.datasource +++ b/src/ui/Web References/SeNetworkService/SeUpdate.datasource @@ -1,10 +1,10 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - This file is automatically generated by Visual Studio .Net. It is - used to store generic object data source configuration information. - Renaming the file extension or editing the content of this file may - cause the file to be unrecognizable by the program. ---> -<GenericObjectDataSource DisplayName="SeUpdate" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> - <TypeInfo>Nikse.SubtitleEdit.SeNetworkService.SeUpdate, Web References.SeNetworkService.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo> +<?xml version="1.0" encoding="utf-8"?> +<!-- + This file is automatically generated by Visual Studio .Net. It is + used to store generic object data source configuration information. + Renaming the file extension or editing the content of this file may + cause the file to be unrecognizable by the program. +--> +<GenericObjectDataSource DisplayName="SeUpdate" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> + <TypeInfo>Nikse.SubtitleEdit.SeNetworkService.SeUpdate, Web References.SeNetworkService.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo> </GenericObjectDataSource> \ No newline at end of file diff --git a/src/Web References/SeNetworkService/SeUser.datasource b/src/ui/Web References/SeNetworkService/SeUser.datasource similarity index 98% rename from src/Web References/SeNetworkService/SeUser.datasource rename to src/ui/Web References/SeNetworkService/SeUser.datasource index 98e1e2eff..f86454535 100644 --- a/src/Web References/SeNetworkService/SeUser.datasource +++ b/src/ui/Web References/SeNetworkService/SeUser.datasource @@ -1,10 +1,10 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - This file is automatically generated by Visual Studio .Net. It is - used to store generic object data source configuration information. - Renaming the file extension or editing the content of this file may - cause the file to be unrecognizable by the program. ---> -<GenericObjectDataSource DisplayName="SeUser" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> - <TypeInfo>Nikse.SubtitleEdit.SeNetworkService.SeUser, Web References.SeNetworkService.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo> +<?xml version="1.0" encoding="utf-8"?> +<!-- + This file is automatically generated by Visual Studio .Net. It is + used to store generic object data source configuration information. + Renaming the file extension or editing the content of this file may + cause the file to be unrecognizable by the program. +--> +<GenericObjectDataSource DisplayName="SeUser" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> + <TypeInfo>Nikse.SubtitleEdit.SeNetworkService.SeUser, Web References.SeNetworkService.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo> </GenericObjectDataSource> \ No newline at end of file diff --git a/src/app.config b/src/ui/app.config similarity index 98% rename from src/app.config rename to src/ui/app.config index f9d9148b9..c3f5c8a30 100644 --- a/src/app.config +++ b/src/ui/app.config @@ -1,18 +1,18 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - <configSections> - <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <section name="Nikse.SubtitleEdit.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> - </sectionGroup> - </configSections> - <applicationSettings> - <Nikse.SubtitleEdit.Properties.Settings> - <setting name="SubtitleEdit_SeNetworkService_SeService" serializeAs="String"> - <value>http://localhost:2782/se/SeService.asmx</value> - </setting> - </Nikse.SubtitleEdit.Properties.Settings> - </applicationSettings> - <startup> - <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/> - </startup> -</configuration> +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <configSections> + <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <section name="Nikse.SubtitleEdit.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> + </sectionGroup> + </configSections> + <applicationSettings> + <Nikse.SubtitleEdit.Properties.Settings> + <setting name="SubtitleEdit_SeNetworkService_SeService" serializeAs="String"> + <value>http://localhost:2782/se/SeService.asmx</value> + </setting> + </Nikse.SubtitleEdit.Properties.Settings> + </applicationSettings> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/> + </startup> +</configuration> diff --git a/src/ui/packages/ILRepack.2.0.18/.signature.p7s b/src/ui/packages/ILRepack.2.0.18/.signature.p7s new file mode 100644 index 000000000..08c3672ca Binary files /dev/null and b/src/ui/packages/ILRepack.2.0.18/.signature.p7s differ diff --git a/src/ui/packages/ILRepack.2.0.18/ILRepack.2.0.18.nupkg b/src/ui/packages/ILRepack.2.0.18/ILRepack.2.0.18.nupkg new file mode 100644 index 000000000..dfaa07d6f Binary files /dev/null and b/src/ui/packages/ILRepack.2.0.18/ILRepack.2.0.18.nupkg differ diff --git a/src/ui/packages/ILRepack.2.0.18/build/ILRepack.props b/src/ui/packages/ILRepack.2.0.18/build/ILRepack.props new file mode 100644 index 000000000..03ff50bf6 --- /dev/null +++ b/src/ui/packages/ILRepack.2.0.18/build/ILRepack.props @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <ILRepack>$(MSBuildThisFileDirectory)..\tools\ILRepack.exe</ILRepack> + </PropertyGroup> +</Project> \ No newline at end of file diff --git a/src/ui/packages/ILRepack.2.0.18/tools/ILRepack.exe b/src/ui/packages/ILRepack.2.0.18/tools/ILRepack.exe new file mode 100644 index 000000000..155b8026f Binary files /dev/null and b/src/ui/packages/ILRepack.2.0.18/tools/ILRepack.exe differ diff --git a/src/ui/packages/NHunspell.1.2.5554.16953/.signature.p7s b/src/ui/packages/NHunspell.1.2.5554.16953/.signature.p7s new file mode 100644 index 000000000..3dceacb0d Binary files /dev/null and b/src/ui/packages/NHunspell.1.2.5554.16953/.signature.p7s differ diff --git a/src/ui/packages/NHunspell.1.2.5554.16953/NHunspell.1.2.5554.16953.nupkg b/src/ui/packages/NHunspell.1.2.5554.16953/NHunspell.1.2.5554.16953.nupkg new file mode 100644 index 000000000..bbc41cf92 Binary files /dev/null and b/src/ui/packages/NHunspell.1.2.5554.16953/NHunspell.1.2.5554.16953.nupkg differ diff --git a/src/ui/packages/NHunspell.1.2.5554.16953/Tools/install.ps1 b/src/ui/packages/NHunspell.1.2.5554.16953/Tools/install.ps1 new file mode 100644 index 000000000..bfd13c31e --- /dev/null +++ b/src/ui/packages/NHunspell.1.2.5554.16953/Tools/install.ps1 @@ -0,0 +1,13 @@ +param($installPath, $toolsPath, $package, $project) + +# Hunspellx86.dll (32 Bit Windows) +$hunspellx86Dll = $project.ProjectItems.Item("Hunspellx86.dll") +$hunspellx86Dll.Properties.Item("BuildAction").Value = 0 # BuildAction = None +$hunspellx86Dll.Properties.Item("CopyToOutputDirectory").Value = 2 # CopyToOutputDirectory = Copy if newer + + +# Hunspellx64.dll (64 Bit Windows) +$hunspellx64Dll = $project.ProjectItems.Item("Hunspellx64.dll") +$hunspellx64Dll.Properties.Item("BuildAction").Value = 0 # BuildAction = None +$hunspellx64Dll.Properties.Item("CopyToOutputDirectory").Value = 2 # CopyToOutputDirectory = Copy if newer + diff --git a/src/ui/packages/NHunspell.1.2.5554.16953/content/Hunspellx64.dll b/src/ui/packages/NHunspell.1.2.5554.16953/content/Hunspellx64.dll new file mode 100644 index 000000000..55a29ec84 Binary files /dev/null and b/src/ui/packages/NHunspell.1.2.5554.16953/content/Hunspellx64.dll differ diff --git a/src/ui/packages/NHunspell.1.2.5554.16953/content/Hunspellx86.dll b/src/ui/packages/NHunspell.1.2.5554.16953/content/Hunspellx86.dll new file mode 100644 index 000000000..7bc6cf222 Binary files /dev/null and b/src/ui/packages/NHunspell.1.2.5554.16953/content/Hunspellx86.dll differ diff --git a/src/ui/packages/NHunspell.1.2.5554.16953/lib/net/NHunspell.dll b/src/ui/packages/NHunspell.1.2.5554.16953/lib/net/NHunspell.dll new file mode 100644 index 000000000..3984517d4 Binary files /dev/null and b/src/ui/packages/NHunspell.1.2.5554.16953/lib/net/NHunspell.dll differ diff --git a/src/ui/packages/NHunspell.1.2.5554.16953/lib/net/NHunspell.pdb b/src/ui/packages/NHunspell.1.2.5554.16953/lib/net/NHunspell.pdb new file mode 100644 index 000000000..bb758683f Binary files /dev/null and b/src/ui/packages/NHunspell.1.2.5554.16953/lib/net/NHunspell.pdb differ diff --git a/www/Help.cshtml b/www/Help.cshtml deleted file mode 100644 index 31f837866..000000000 --- a/www/Help.cshtml +++ /dev/null @@ -1,986 +0,0 @@ -@{ - ViewBag.Title = "Subtitle Edit 3.3 Help"; - ViewBag.Footer = "hOpe iT HelpZ"; - ViewBag.MetaKeywords = "Subtitle Edit help, subtitle tutorial, FAQ, how to synchronize"; - ViewBag.MetaDescription = "Subtitle Edit help page"; - ViewBag.FavIcon = "/favicon.ico"; -} -<h1>@ViewBag.Title</h1> -<hr /> -<br /> -<div style="text-align:right">Help is also available in <a href="/SubtitleEdit/HelpEU">Basque</a> | <a href="/SubtitleEdit/HelpEs">Spanish</a> | <a href="/Content/SubtitleEdit/Help/RU">Russian</a></div> -<h2>Mini FAQ</h2> -Q: When I try to open a video in format x, SE cannot play video or there's no sound. What do I do?<br /> -A: If you use Direct Show as video player be sure to use <a href="#codecs">the correct codecs</a>. I recommend uninstalling codec packs like k-lite and only installing <a href="http://code.google.com/p/lavfilters/downloads/list">LAV filters</a> 32-bit (+64-bit if you want). Another option is to use VLC as video player.<br /> -<br /> -Q: Where is the delay tool?<br /> -A: Use <b>Show earlier/later</b> in the <b>Synchronization</b> menu. Shortcut is <b>Ctrl+Shift+A</b>. It's a tool window, so you can keep it open while working - or checking subtitle preview in video player.<br /> -<br /> -Q: Why can't Subtitle Edit change frame rate?<br /> -A: Well, it can. Check <b>Synchronization -> Change frame rate</b>.<br /> -<br /> -Q: Why can't Subtitle Edit split/append subtitles?<br /> -A: Try <b>Tools -> Split/append</b>.<br /> -<br /> -Q: Can Subtitle Edit offset times - but not from the very beginning?<br /> -A: Yes, you can work with a selection of subtitle lines. Select the lines -in the list view you want to work on (hint: click on the first line, -then shift+click on the last) and -then right-click in the list view (context menu) - now you can adjust -the selected lines in "visual sync selected lines" or just "show -selected lines earlier/later".<br /> -<br /> -Q: Can Subtitle Edit play video fullscreen?<br /> -A: Yes, press ALT+ENTER. Use space for play/pause and ALT+ARROW UP/DOWN for next/previous subtitle.<br /> -<br /> -Q: When translating/editing subtitles, can Subtitle Edit navigate quickly to next line?<br /> -A: Yes, press ALT+ARROW UP/DOWN for next previous subtitle - also textbox will keep focus.<br /> -<br /> -Q: Can Subtitle Edit add the subtitles to the video file?<br /> -A: No, Subtitle Edit cannot do this - but one or more of the 100+ output formats should work. Use either <i>File</i> -> <i>Save as...</i> for text based formats or <i>File</i> -> <i>Export...</i> for binary/image-based formats.<br /> -There are two ways of adding subtitles into the video file - hardcoding (cannot be turned off ever, so this <i>might</i> be a bad idea) or embedding (only for some formats like mkv, mp4).<br /> -Read more about <a href="AddSubtitlesToVideo">adding subtitles to video</a>. -<br /> -<br /> -<hr /> -<br /> -<h2>Help index</h2> -<div style="margin-left: 25px; line-height: 25px;"> - <a href="#main">Subtitle Edit main window</a><br /> - <a href="#main_resize">Subtitle Edit main window - resize/un-dock</a><br /> - <a href="#main_edit_original">Subtitle Edit main window - edit original</a><br /> - <a href="#video_modes">Video/wave form modes</a><br /> - <a href="#waveform">Wave form</a><br /> - <a href="#export">Export</a><br /> - <a href="#sync">Synchronization</a><br /> - <a href="#visual_sync">Visual sync</a><br /> - <a href="#translation">Translation (auto)</a><br /> - <a href="#fixcommonerrors">Fix common errors</a><br /> - <a href="#spellcheck">Spell check</a><br /> - <a href="#importvobsub">Import/OCR image based subtitles - like DVD Sub/idx or Blu-ray sup</a><br /> - <a href="#shortcuts">Shortcuts</a><br /> - <a href="#translate">Translating Subtitle Edit to another language</a><br /> - <a href="#networking">Networking - online collaboration</a><br /> - <a href="#codecs">Video player and codecs</a><br /> - <a href="#commandline">Command line conversion</a><br /> - <a href="#portable">Portable version and VLC</a><br /> - <a href="#plugins">Make your own plugin</a><br /> - <a href="#compile">Compiling Subtitle Edit</a><br /> - <a href="#issues">Known issues</a><br /> -</div> -<br /> -<hr /> -<br /> -<h2><a id="main">Subtitle Edit main window</a></h2> - -<br /> -<h3>Menu in main window</h3> -In the menu you can find many tools like change casing, split, append, spell check, synchronization, change frame rate, Google translate, find, replace, remove text for hearing impaired, and much more!<br /> -You can import subtitles from DVD, vobsub, Blu-ray sup - even vobsub inside Matroska files can be imported.<br /> -<br /> -<img src="/Content/SubtitleEdit/main_menu.png" alt="Menu" /><br /> -<br /> -<small>NOTE: Many tools are also available via right click in the list view.</small> -<br /> -<br /> -<br /> - -<br /> -<h3><a id="formats">Subtitle/file formats</a></h3> -<table> - <tr> - <td> - <img src="/Content/SubtitleEdit/FormatAndEncoding.png" alt="Subtitle format" /> - <br /> - <br /> - In the top menu you can choose format and encoding. The first dropdown list shows subtitle formats. SubRip (extension is ".srt") is - the most widely used format today, so it is recommended to save subtitles in this format.<br /> - Originally SubRip was a text only format, but in recent years html tags have been common. Especially the - italic and font tags are widely used. For a list of SubRip support in players <a href="http://ale5000.altervista.org/subtitles.htm">check this out</a>.<br /> - <br /> - File encoding is auto detected in most cases. ANSI is the old, formerly the most common found format, but it requires your - system to have a specific culture setting. UTF-8 is recommended for new subtitles, as it can handle non English - letters better than ANSI (UTF-8 subtitles will work on all computers no matter what culture settings a computer has), and can display other - symbols like music nodes. The only drawback of using UTF-8 is, that some older programs do not support UFT-8 and WinXP only has a few semi-unicode fonts (Lucida Sans Unicode, Time New Roman, Courier New).<br /> - If you have an ANSI file in another language than the current culture/language (or you have an invalid UTF/Unicode file) then you can use the menu - item: <i>File</i> -> <i>Import subtitle with manual chosen encoding</i>.<br /> - <br /> - <i>Import subtitle with manual chosen encoding</i> with preview:<br /> - <img src="/Content/SubtitleEdit/ChooseEncoding.gif" alt="ChooseEncoding" /> - </td> - </tr> -</table> -<br /> -<br /> - -<h3>Frame rate</h3> -<table> - <tr> - <td> - <img src="/Content/SubtitleEdit/help_framerate.png" alt="Frame rate" /><br /> - <br /> - Frame rate is no longer displayed by default, but you can enable it via the menu <i>Options</i> -> <i>Settings: Toolbar: Show frame rate in toolbar</i>.<br /> - Frame rate is used when converting between subtitle formats based on frames and formats based on time. - SubRip is based on time. MicroDvd (widely used 7-9 years ago, and still widely used in some countries) is based on frames.<br /> - Subtitles based on time is preferred as videos may not have a constant frame rate - which makes - working with subtitles based on frames not very flexible at all.<br /> - To change the frame rate use <i>Synchronization</i> -> <i>Change frame rate</i> - or use one of the other <a href="#sync">synchronizations tools</a>. - </td> - </tr> -</table> -<br /> -<br /> - -<h3>Subtitle view - List view or source view</h3> -<p>There are two ways of looking at a subtitle - list view or source view.</p> -<table> - <tr> - <td> - <img src="/Content/SubtitleEdit/help_sourceview.png" alt="Source view" /> - </td> - <td> - This is how the subtitle file actually looks - different for all formats.<br /> - You can edit text and time codes here, but be careful - it's also easy to mess things - up.<br /> - You can make Subtitle Edit start in Source view under Settings. - </td> - </tr> -</table> -<br /> -<table> - <tr> - <td colspan="2"> - <a id="listview"><img src="/Content/SubtitleEdit/help_listview.png" alt="List view" /></a> - </td> - </tr> - <tr> - <td> - The list view gives an excellent overview of the subtitle - the same for all formats.<br /> - You can edit text and time codes here, delete and insert lines easily.<br /> - <br /> - </td> - </tr> - <tr> - <td colspan="2"> - <br /> - It is also possible to select several lines and use tools like <i>Google translate</i> or - <i>Visual sync</i> on the selected lines.<br /> - <br /> - <a id="listview2"><img src="/Content/SubtitleEdit/help_listview2.png" alt="Listview" /></a> - </td> - </tr> - <td colspan="2"> - <br /> - <br /> - <h3>TextBox</h3> - <p>Above the textbox where you can type the actual subtitle is a label called "Char/sec". - If it's higher than 25 it will be colored orange/red.<br /> - <br /> - </p> - <img src="/Content/SubtitleEdit/TextBox.png" alt="search" /><br /> - <br /> - Below the textbox is a label called "Single line length". First line is 33 characters and second line is 75 characters. - The color referrers to how long current line is compared to Settings -> Options : General : Single line max length - (43 is default). Red means too long, orange means it's close to max. - <br /> - <br /> - </td> - <tr> - </tr> - <tr> - <td colspan="2"> - <br /> - <br /> - <h3>Show video and/or waveform/spectrogram</h3> - <br /> - <a id="main_resize">The main window can show video and/or wave form.</a> Video controls can even be un-docked - nice if you have two monitors!<br /> - The horizontal/vertical red lines shows where you can resize inside the main window (via splitters).<br /> - <br /> - <img src="/Content/SubtitleEdit/main_video1.png" alt="Main window - with video/waveform" /> - </td> - </tr> - <tr> - <td colspan="2"> - <br /> - <br /> - <a id="main_edit_original">It's now possible to edit both new translation and original subtitle at the same time.</a> Default, the original is read-only, but you can change that in Options -> Settings:General:Allow edit of original subtitle.<br /> - Shortcuts: <b>Ctrl+U</b> will toggle original subtitle. <b>Ctrl+Shift+U</b> will switch translated / original subtitle.<br /> - When editing both original and translated subtitle, changing start time/duration/deleting/inserting will affect both subtitles!<br /> - <br /> - <img src="/Content/SubtitleEdit/main_edit_original.jpg" alt="Main window - with video/waveform" /> - </td> - </tr> -</table> - -<br /> -<br /> -<h3>Search</h3> -<p>You can search by pressing Ctrl+F (F3 is find next). Regular expression search is available for nerds ;)</p> -<img src="/Content/SubtitleEdit/help_search.png" alt="search" /><br /> -<br /> -<hr /> -<br /> - -<br /> -<br /> -<h3><a id="multiple_replace">Multiple Replace</a></h3> -<p>In <i>Edit -> Multiple replace</i> you can create your own rules for fixing a subtitle - even advanced rules using <a href="http://en.wikipedia.org/wiki/Regular_expression">regular expressions</a>!</p> -<p>When writing regular expressions grouping and backreferences are very useful. Parts of a regular expression inside parentheses are groups and can be referenced in the replace string where $1 is a reference to the first group and $2 is a reference to the second and so on.<br /> -<div style="padding-left:15px"> -Example 1: <b>^J( .+)</b> + replace string <b>♪ $1</b> - only the starting "J" will be replaced, so if the text is "J Music Playing J" it will become "♪ Music Playing J"<br /> -Example 2: <b>([a-z]+)([0-9]+)</b> + replace string <b>$2$1</b> - two groupings that will be switched, so if the text is "number26" it will become "26number".<br /> -</div> -</p> -<img src="/Content/SubtitleEdit/main_edit_multiple_replace.png" alt="Multiple replace" /><br /> -<br /> -<hr /> -<br /> - -<h2><a id="video_modes">Video/wave form modes</a></h2> -<br /> -When using video and/or wave form three different modes (tabs) are available: Translate, Create, and Adjust. - -<h3>Translate mode</h3> -<img src="/Content/SubtitleEdit/mode_translate.png" alt="Translate mode" /><br /> -<br /> -In translate mode you can translate a subtitle from one language to another manually (or correct a machine -translated subtitle) while watching the video - and hearing the audio.<br /> -If "Auto repeat" is on, then the subtitle will be repeated x-times while you are typing in the correct text.<br /> -Use <i>File</i> -> <i>Open original subtitle (translator mode)</i> to also display the original text.<br /> -Hint: Do use the &lt;alt+arrow up/down&gt; for going to previous/next subtitle.<br /> -<br /> -<br /> - -<h3>Create mode</h3> -<img src="/Content/SubtitleEdit/mode_create.png" alt="Create/adjust lines" /><br /> -<br /> -This is the place to create subtitle lines from scratch or manually adjust existing lines.<br /> -<br /> -To create subtitle lines from scratch, pause the video file where the subtitle line should start and press the button -"Insert new subtitle at video pos". Then enter the text - duration is auto suggested. Now press the button "Play from -just before text" and if the text does not start exactly when the speech starts, then adjust "Start time" via the up/down -arrows until it does. The duration can be set via the button "Set end time" while the video is playing or via the "Duration up/down arrows.<br /> -To insert a subtitle right after the current line, press the Insert button (while the list view is focused).<br /> -<br /> -You can also right click on the audio wave form or in the list view to insert/merge/split/delete lines.<br /> -<br /> -<br /> - -<h3>Adjust mode</h3> -<img src="/Content/SubtitleEdit/mode_adjust.png" alt="Adjust mode" /><br /> -<br /> -This is the place to adjust existing lines.<br /> -<br /> -To adjust subtitle lines manually one by one starting from the top. Use the buttons "Set start and offset the rest" (F9) and "Set end &amp; go to next" (F10). -Fine-tuning of "Start time" and "Duration" should be done by using the up/down arrows.<br /> -<br /> -You can also right click on the audio wave form or in the list view to insert/merge/split/delete lines.<br /> -<br /> -<hr /> -<br /> - -<h2><a id="waveform">Wave form</a></h2> -The wave form control makes it easy to see exactly where speech start/end.<br /> -<img src="/Content/SubtitleEdit/Waveform1.png" alt="Wave form" /><br /> -<br /> -<br /> -With the right click menu, you can split/merge/delete subtitles.<br /> -<img src="/Content/SubtitleEdit/Waveform2.png" alt="Wave form - right click menu"/><br /> -<br /> -<br /> -To create a new paragraph, just select an empty area and right click.<br /> -<img src="/Content/SubtitleEdit/Waveform3.png" alt="Wave form - new selection" /><br /> -<br /> - -<h3>Wave form mouse/keys usage:</h3> -<ul> - <li>Mouse single click: Go to position</li> - <li>Mouse double click on existing subtitle: Select clicked subtitle</li> - <li>Mark area + right click on marked area: Prompt for add new paragraph / play current selection</li> - <li>Mouse drag left/right border of subtitles (adjusting start or end time)</li> - <li>Move/drag on middle of subtitle (adjusting both start and end time - but not duration)</li> - <li>Mouse right click can either add new subtitle or perform delete/split/merge on existing subtitle line</li> - <li>Mouse wheel scrolls waveform forward/back</li> - <li>alt+arrow left/right moves video position</li> - <li>alt+arrow up/down goes previous/next subtitle</li> - <li>Numeric +/- will zoom in/out</li> - <li>Mouse single click+Shift will set start for selected line (not moving end time)</li> - <li>Mouse single click+Ctrl will set end for selected line (not moving start time)</li> - <li>Mouse single click+Alt will set start for selected line (and keep duration)</li> - <li>Mouse double click on non-paragraph - toggle play</li> - <li><b>Mouse single click+Ctrl+Shift will set of start selected line + offset all lines after selected line (keeping durations)</b></li> - <li>Holding down ALT when moving start/end will move nearest subtitle start/end too if it's closer than 500 milliseconds - <a href="/Content/SubtitleEdit/WaveformMoveNextPrev.gif">like this.</a></li> -</ul> - -<br /> -<h3>Wave extraction</h3> -The extracting of wave data is done by <a href="http://www.videolan.org/">VLC media player 2.x (or 1.1.x/)</a>, and then a very small wave file (with a VERY low samplerate) is generated -and saved in the "WaveForms" folder. If VLC for some reason fails to extract a wave file from the video, you can extract the wave file with some other tool and drop -that wave file on the waveform control, which will generate a small wave file (with a VERY low samplerate) in the "WaveForms" folder.<br /> -<br /> -Note: You cannot use waveform without the video (if you only have a wav file and no video, it is possible to load the wave file as video file + drop the wave file on the waveform control). -<br /> -<hr /> -<br /> - - -<br /> -<h2><a id="export">Export</a></h2> -Subtitle Edit can save via "Save as..." in many different text formats, but if you want to save a subtitle in a binary format (like pac or 890) or an image based format (like png or bluray sup) you must use File -> Export.<br /> -Many styles like italic and color from subtitles are preserved when exporting to image based formats.<br /> -<br /> -<hr /> -<br /> - - -<h2><a id="sync">Synchronization</a></h2> -<table> - <tr> - <td> - <img src="/Content/SubtitleEdit/SyncMenu.png" alt="Sync menu" /> - </td> - </tr> - <tr> - <td> - <br /> - Subtitle Edit offers several ways to synchronize subtitles.<br /> - <p>Adjust all times (show earlier/later): This is useful if you for example need to show all texts 3 seconds earlier.</p> - <p><a href="#visual_sync">Visual sync</a>: Sync by matching start/end scene (more below).</p> - <p>Point sync: This allows synchronization by using 2 or more points - sync point time - codes can be entered manually which makes it easy to use time codes from another subtitle already in sync.</p> - <p>Point sync via other subtitle: If you have another subtitle in sync (perhaps in another language - it helps if you can understand it a bit) you can match one of - the first lines, match one of the last lines, sync, and then all lines should be in sync.</p> - <p>Change frame rate: This makes it easy to match text from a video with one frame rate to a video with another frame rate (can also be done by visual sync or point sync).</p> - </td> - </tr> -</table> -<br /> -<br /> -<br /> - - -<h2><a id="visual_sync">Visual sync</a></h2> -<table> - <tr> - <td colspan="2"> - <img src="/Content/SubtitleEdit/vissync.gif" alt="Visual Sync controls" /> - </td> - </tr> - <tr> - <td> - <img src="/Content/SubtitleEdit/help_vs2.png" alt="Synchronize button" /> - </td> - <td> - <br /> - Visual sync is a really easy way to synchronize a subtitle with a video file.<br /> - Match one of the first subtitle lines with the start scene. Then match one of the - last subtitle lines with the end scene. Press "Sync!" - and that's it :)<br /> - There are a few helper buttons which will help find the right place in the video where the - subtitle should start (just about where the first word comes out). The "Play 1 sec and back" button is a test button, - so you can easily very that the current position really is correct. Also check the <a href="#shortcuts">Shortcuts</a>.<br /> - <br /> - In some cases a subtitle is impossible to synchronize because one or more scenes have been removed/added. - In these cases you can select a number of subtitles in the subtitle <a href="#listview">list view</a>, right - click and choose <i>Visual sync selected lines</i>. This way you can adjust the subtitle in smaller parts. - </td> - </tr> -</table><br /> -<br /> -<hr /> -<br /> -<h2><a id="translation">Translation (auto)</a></h2> -Subtitle Edit can translate a subtitle by using <a href="http://www.google.com/translate">Google translation</a> -or <a href="../mt">Multi Translator</a> (only Swedish to Danish).<br /> -Google has translation between a lot of languages! It works fairly well, but translated subtitles will still -need manual correction (hint: use main window <a href="#video_modes">translate mode</a>). -<br /> -<br /> -<img src="/Content/SubtitleEdit/help_googletranslate.png" alt="Create/add lines" /><br /> -<br /> -<hr /> -<br /> -<h2><a id="fixcommonerrors">Fix common errors</a></h2> -<br /> -<img src="/Content/SubtitleEdit/help_fixcommonerrors1.png" alt="Fix common errors" /><br /> -<br /> -Some subtitles have an lot of errors (often these subtitles are created using OCR software).<br /> -"Tools -> Fix common errors" provides an easy way to fix a lot of these errors.<br /> -The first window shows a list of actions to fix, just tick the check boxes you want fixed and click "Next".<br /> -<br /> -<br /> -<img src="/Content/SubtitleEdit/help_fixcommonerrors2.png" alt="Fix common errors" /><br /> -<br /> -Now you can choose which fixes to apply. Default all fixes are selected, so you must un-check the checkbox for fixes -you do not wish to apply.<br /> -The log tab gives an overview of what will be done - and what was not possible to fix.<br /> -The "Apply selected fixes" button applies the fixes.<br /> -<br /> -<hr /> -<br /> -<b><a id="spellcheck">Spell check</a></b> -<br /> -<br /> -Spell check uses <a href="http://hunspell.sourceforge.net/">Hunspell</a> (which is also used by Open/LibraOffice, Firefox, Chrome, and Opera).<br /> -Only English dictionary is included, but you can easily find more dictionaries via the toolbar menu <i>Spell check</i> -> <i>Get dictionaries...</i>!<br /> -If you download <a href="http://extensions.services.openoffice.org/en/dictionaries">Open Office 3.x dictionaries</a> with the extension .oxt, then rename to .zip, and then unpack -the .dic file and the .aff file to the Subtitle Edit <i>Dictionary</i> folder.<br /> -<br /> -The spell check will show this window when it encounters an unknown word:<br /> -<img src="/Content/SubtitleEdit/spell_check.png" alt="spell check" /><br /> -<b><i>Edit whole text</i></b> will enable editing of the whole text (and not only the current word) - for this one sub only.<br /> -<b><i>Change all / Use always</i></b> will change current word in always - also in future works (saved in the OCR Fix Replace list - take a look at Dictionaries/eng_OCRFixReplaceList.xml to learn more about this file).<br /> -<b><i>Change / Use</i></b> will change current word just this once.<br /> -<b><i>Add to names/noise list (case sensitive)</i></b> will remember the name in the edit text box with current casing - also in future works.<br /> -<b><i>Add to user dictionary</i></b> will remember the word in the edit text box and not prompt for it any more - also in future works. User dictionary is not case sensitive.<br /> -<br /> -All buttons in the "Word not found" groupbox will use the word in the "Word not found" textbox.<br /> -<br /> -<hr /> -<br /> -<h2><a id="importvobsub">Import/OCR image based subtitles - like DVD Sub/idx or Blu-ray sup</a></h2> -<br /> -<br /> -If you open an image based subtitle like Blu-ray sup or sub/idx (vobsub) this screen will come up:<br /> -<br /> -<img src="/Content/SubtitleEdit/help_importvobsub.png" alt="Import/ocr image based subtitles" /><br /> -<br /> -<br /> -The list view now contains empty subtitle text lines with only timestamps. You can enter the text manually, but two (or three if you have MODI installed) better options exists: -<ul> - <li>OCR via Tesseract 3 (recommended): <a href="http://code.google.com/p/tesseract-ocr/">Tesseract</a> is an open source OCR engine. <br /> - You can find additional language data files at the <a href="http://code.google.com/p/tesseract-ocr/downloads/list">Tesseract Google code project</a>. These Tesseract - dictionary files need to be unpacked to [Subtitle Edit folder]\Tesseract\tessdata.<br /> - <br /> - If you right-click in the list view, you will get a context menu with these options:<br /> - <img src="/Content/SubtitleEdit/ocr_context_menu.png" alt="OCR list view context menu" /><br /> - <b><i>Import text with matching time codes...</i></b> can be used to continue working on an earlier created subtitle.<br /> - <b><i>Save subtitle image as...</i></b> allows for saving current image as either pgn, gif, bmp, or tiff.<br /> - <b><i>Save all images with html index</i></b> display all subtitles images in an html page - for easy proof reading.<br /> - <br /> - - OCR via Tesseract will work best if you also have <a href="#spellcheck">spell check</a> dictionaries.<br /> - <img src="/Content/SubtitleEdit/ocr_dictionary.png" alt="OCR dictionary" /><br /> - <b><i>prompt for unknown words</i></b> and <b><i>Try to guess unknown words</i></b> will only work if a dictionary is available. <b><i>Fix OCR errors</i></b> will also benefit - from a dictionary.<br /> - <br /> - The <b><i>prompt for unknown words</i></b> will look like this (window is re-sizable):<br /> - <img src="/Content/SubtitleEdit/ocr_spell_check.png" alt="OCR spell check" /><br /> - <b><i>Edit whole text</i></b> will enable editing of the whole text (and not only the current word) - for this one sub only.<br /> - <b><i>Change all / Use always</i></b> will change current word always - also in future works (saved in the OCR Fix Replace list - take a look at Dictionaries/eng_OCRFixReplaceList.xml to learn more about this file).<br /> - <b><i>Change / Use</i></b> will change current word just this once.<br /> - <b><i>Add to names/noise list (case sensitive)</i></b> will remember this name with current casing - also in future works.<br /> - <b><i>Add to user dictionary</i></b> will remember this word and not prompt for it any more - also in future works.<br /> - <br /> - <br /> - </li> - <li>OCR via image compare: This option does not require any third party software installed, but it does require the user to manually - enter letters based on image parts.<br /> - "No of pixels is space" should be decreased if not all translated words are separated (like "<i>wearefine.</i>"), and increased - if there are too many separations (like "<i>w e ar e fi n e.</i>").<br /> - Note: This does not work well with Blu-ray sup files!<br /> - <br /> - </li> - <li>OCR via MODI: MODI is short for <a href="http://en.wikipedia.org/wiki/Microsoft_Office_Document_Imaging">Microsoft Office Document Imaging</a>. It's included with Microsoft Office Tools ("Microsoft Office \ Microsoft Office Tools" folder in the start menu).<br /> - This works a lot like Tesseract, but requires MS Office.<br /> - If you do have Microsoft Office installed but the MODI OCR is not available do try to run the MS Office setup again and make sure that MODI is selected in the setup program. - <br /> - </li> -</ul> -Select one of the OCR methods and click on the button "Start OCR".<br/> -When you are done just click "OK" and do remember that an OCR'ed subtitle most likely contains some errors that need correction.<br /> -If a VobSub subtitle contains more than one language, you will be prompted for language.<br /> -<br /> -<hr /> -<br /> -<br /> -<h2><a id="shortcuts">Shortcuts</a></h2> -<br /> -<table id="tableShortcuts"> - <thead> - <tr> - <th>Window</th> - <th>Control</th> - <th>Shortcuts</th> - <th>Function</th> - </tr> - </thead> - <tbody> - <tr> - <td>Main</td> - <td>*</td> - <td>F1</td> - <td>Show this help file ;)</td> - </tr> - <tr> - <td>Main</td> - <td>*</td> - <td>Ctrl+F</td> - <td>Open the Find dialog</td> - </tr> - <tr> - <td>Main</td> - <td>*</td> - <td>F3</td> - <td>Find next</td> - </tr> - <tr> - <td>Main</td> - <td>*</td> - <td>Ctrl+z</td> - <td>Show history/undo</td> - </tr> - <tr> - <td>Main</td> - <td>*</td> - <td>Ctrl+G</td> - <td>Go to subtitle number dialog</td> - </tr> - <tr> - <td>Main</td> - <td>*</td> - <td>Ctrl+L</td> - <td>Locates (scrolls to) first selected subtitle line in the subtitle list view</td> - </tr> - <tr> - <td>Main</td> - <td>*</td> - <td>Alt+Arrow up</td> - <td>Go one line up in subtitle list view</td> - </tr> - <tr> - <td>Main</td> - <td>*</td> - <td>Alt+Arrow down</td> - <td>Go one line down in subtitle list view</td> - </tr> - <tr> - <td>Main</td> - <td>*</td> - <td>Ctrl+U</td> - <td>Translator mode on/off</td> - </tr> - <tr> - <td>Main</td> - <td>*</td> - <td>Ctrl+Shift+U</td> - <td>Switch current subtitle with original subtitle</td> - </tr> - <tr> - <td>Main</td> - <td>*</td> - <td>Shift+Insert</td> - <td>Insert line before first selected line</td> - </tr> - <tr> - <td>Main</td> - <td>*</td> - <td>Alt+Insert</td> - <td>Insert line after first selected line</td> - </tr> - <tr> - <td>Main</td> - <td>Subtitle text box</td> - <td>Ctrl+I</td> - <td>Make selection italic</td> - </tr> - <tr> - <td>-</td> - <td>-</td> - <td>-</td> - <td>-</td> - </tr> - <tr> - <td>Main</td> - <td>Subtitle list view</td> - <td>Ctrl+A</td> - <td>Select all lines</td> - </tr> - <tr> - <td>Main</td> - <td>Subtitle list view</td> - <td>Ctrl+D</td> - <td>Select only first selected line</td> - </tr> - <tr> - <td>Main</td> - <td>Subtitle list view</td> - <td>Ctrl+Shift+I</td> - <td>Inverse selection</td> - </tr> - <tr> - <td>Main</td> - <td>Subtitle list view</td> - <td>Delete</td> - <td>Delete selected lines</td> - </tr> - <tr> - <td>Main</td> - <td>Subtitle list view</td> - <td>Insert</td> - <td>Insert line after first selected line</td> - </tr> - <tr> - <td>Main</td> - <td>*</td> - <td>Ctrl+Shift+M (or Ctrl+K)</td> - <td>Merge selected lines</td> - </tr> - <tr> - <td>-</td> - <td>-</td> - <td>-</td> - <td>-</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>Alt+Arrow left</td> - <td>Go 0,5 second back in video</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>Alt+Arrow right</td> - <td>Go 0,5 second forward in video</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>Ctrl+Arrow left</td> - <td>Go 0,1 second back in video</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>Ctrl+Arrow right</td> - <td>Go 0,1 second forward in video</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>Ctrl+Alt+P</td> - <td>Pause video</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>Ctrl+P</td> - <td>Toggle play/pause video</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>F4</td> - <td>Toggle position between end/start of current paragraph</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>F5</td> - <td>Play current paragraph and stop right after</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>F6</td> - <td>Go to start of current paragraph</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>F7</td> - <td>Go 3 seconds back</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>F8</td> - <td>Toggle play/pause</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>F9-F12</td> - <td>Depend on mode (translate/create/adjust)</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>Alt+1</td> - <td>Go to start position of current paragraph</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>Alt+2</td> - <td>Go to end position of current paragraph</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>Alt+3</td> - <td>Go to previous paragraph</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform</td> - <td>Alt+4</td> - <td>Go to next paragraph</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform - Adjust mode</td> - <td>Ctrl+Space</td> - <td>Set start and offset the rest</td> - </tr> - <tr> - <td>Main</td> - <td>video player/waveform - Adjust mode</td> - <td>Shift+Space</td> - <td>Set end and go to next</td> - </tr> - <tr> - <td>-</td> - <td>-</td> - <td>-</td> - <td>-</td> - </tr> - <tr> - <td>Undocked video player</td> - <td>-</td> - <td>Alt+A</td> - <td>Resize window so video is aspect ratio 1:1</td> - </tr> - <tr> - <td>Undocked video player</td> - <td>-</td> - <td>Alt+Enter</td> - <td>Toggle maximized/normal window size</td> - </tr> - <tr> - <td>-</td> - <td>-</td> - <td>-</td> - <td>-</td> - </tr> - <tr> - <td>OCR via image compare - Image to text manually</td> - <td>-</td> - <td>Alt+Arrow right</td> - <td>Expand selection</td> - </tr> - <tr> - <td>OCR via image compare - Image to text manually</td> - <td>-</td> - <td>Alt+Arrow left</td> - <td>Shrink selection</td> - </tr> - <tr> - <td>OCR via image compare - Image to text manually</td> - <td>-</td> - <td>Alt+i (depends on translation)</td> - <td>Toggle italic</td> - </tr> - <tr> - <td>OCR via image compare - Image to text manually</td> - <td>-</td> - <td>Alt+f (depends on translation)</td> - <td>Toggle auto-submit (automatically continues after first pressed letter)</td> - </tr> - </tbody> -</table> -<br /> -<br /> -Note - many of the shortcuts are configurable via <i>Options -> Settings -> Shortcuts</i> (let me know if you need more):<br /> -<br /> -<img src="/Content/SubtitleEdit/shortcuts.png" alt="Configurable shortcuts" /><br /> -<br /> -<br /> -<br /> -<hr /> -<br /> -<br /> - -<h2><a id="translate">Translating Subtitle Edit to another language</a></h2> -<br /> -To translate Subtitle Edit first download <a href="/Content/SubtitleEdit/Language.xml">the English xml language file</a> and save it to your -"Subtitle Edit\Languages" folder. Translate the content of all tags with an xml editor or just notepad. You can also use -<a href="/XmlContentTranslator">Xml Content Translator</a>!<br /> -Save your edited xml file as 'CultureName'.xml ('CultureName' must be an <a href="http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo%28v=vs.80%29.aspx">existing culture name</a> - and also a tag in the xml file) in the SubtitleEdit\Languages folder. In Options > Choose language, -you can now test your translation by choosing your language as language.<br /> -Please do send any translations to me, so I can include them in Subtitle Edit - thx :)<br /> -Tip: <a href="http://winmerge.org">WinMerge </a> is an excellent tool for comparing files.<br /> -<br /> -The installer can localized by translating <a href="http://subtitleedit.googlecode.com/svn/trunk/installer/Custom_Messages.iss">this file</a>. -<br /> -<br /> -<hr /> -<br /> - - -<h2><a id="networking">Networking - online collaboration</a></h2> -<br /> -If you and a few friends want to translate the same subtitle at the same time over the internet, then do try the "Networking" feature.<br /> -First load the subtitle you want translated (and optionally the original subtitle). Then choose "Start new session" in the "Networking" menu:<br /> -<br /> -<img src="/Content/SubtitleEdit/NetworkingStart.png" alt="Start network session" /> -<br /> -<br /> -The "session key" is your subtitle id (can be any text you like) - other people need this in order to join (via menu Networking -> Join session) your session.<br /> -The "username" will be displayed when updating/inserting/deleting lines and in the chat window<br /> -The "webservice url" points to a small server program hosting the session (I initially developed this via direct p2p, but decided to use a webservice -instead, as it works much better with stuff like firewalls). <a href="/Content/SubtitleEdit/SENetworkingService.zip">Source code for this webservice is available</a> and should -make it easy to use your own server for hosting the networking session.<br /> -<br /> -<br /> -Subtitle Edit running in networking mode below. In the "User/action" column in the list view you can follow the translation progress - this might sparkle some synergistic effect!<br /> -<br /> -<img src="/Content/SubtitleEdit/networking.jpg" alt="Subtitle Edit running in networking mode" /> -<br /> -<br /> -<hr /> -<br /> - - -<h2><a id="codecs">Video player and codecs</a></h2> -<br /> -Subtitle Edit can use VLC media player inside Subtitle Edit instead of DirectShow - go to <i>Options -> Settings -> Video player</i>. If the VLC option is grayed out, then you probably -need to install VLC version 2.x or 1.1.x!<br /> -Yet another video option is to use <a href="http://www.mplayer2.org/">mplayer2</a>. Save "mplayer.exe" in your Subtitle Edit folder and in Subtitle Edit go to <i>Options -> Settings -> Video player</i> and choose "MPlayer".<br /> -Note: VLC and MPlayer come with their own codecs, so you don't need to install <a href="http://code.google.com/p/lavfilters/">LAV Filters</a> or ffdshow/Hali Matroska Splitter.<br /> -<br /> -<img src="/Content/SubtitleEdit/OptionsVideoPlayer.png" alt="Choose video player" /> -<br /> -<br /> -Often problems with the DirectShow video player in Subtitle Edit are caused by bad/conflicting/missing/old codecs (Codec packs are EVIL!).<br/> -The error might be something like System.Runtime.InteropServices.InvalidComObjectException and might mention QuartzTypeLib/QuartzPlayer.<br /> -<br /> -My recommendation is to uninstall all codec packs (incl. K-lite), reboot, and then install <a href="http://code.google.com/p/lavfilters/">LAV Filters - DirectShow Media Splitter and Decoders</a> <br /> -Note that Subtitle Edit is a 32-bit application (unless you have specifically found a 64-bit version) and hence requires 32-bit codecs - even on win7 64-bit<br /> -<br /> -If you have problems with a specific format/file try <a href="http://mediaarea.net/MediaInfo">MediaInfo</a> / <a href="http://www.headbands.com/gspot/">GSpot</a>.<br /><br /> -<br /> -<hr /> - -<h2><a id="commandline">Subtitle Edit command line conversion</a></h2> -<br /> -Subtitle Edit (3.2) can do command line conversion between formats listed in the main window format drop down list.<br /> -<br /> -Syntax: SubtitleEdit /convert "pattern" "name-of-format-without-spaces" [/encoding:?] [/fps:?] [/outputfolder:?]:<br /> -<br /> - Example 1: <div style="font-family:Times New Roman; font-style:italic">SubtitleEdit /convert sub1.srt sami</div> Result: Will convert sub1.srt to sub1.sub to SAMI format<br /> -<br /> - Example 2: <div style="font-family:Times New Roman; font-style:italic">SubtitleEdit /convert *.srt adobeencore</div> Result: Will convert all .srt files to Adobe Encore format<br /> -<br /> - Example 3: <div style="font-family:Times New Roman; font-style:italic">SubtitleEdit /convert *.srt adobeencore /encoding:windows-1252</div> Result: Same as above but using windows-1252 file encoding (see <a href="http://msdn.microsoft.com/en-us/library/system.text.encodinginfo.getencoding.aspx">Info.Name list</a> for more encodings)<br /> -<br /> - Example 4: <div style="font-family:Times New Roman; font-style:italic">SubtitleEdit /convert a.sub subrip /fps:25</div> Result: Converts frame based a.sub to time based a.srt via a frame rate of 25<br /> -<br /> - Example 5: <div style="font-family:Times New Roman; font-style:italic">SubtitleEdit /convert a.sub subrip /outputfolder:C:\Temp</div> Result: Converts a.sub to C:\Temp\a.srt<br /> -<br /> - To list supported formats: <div style="font-family:Times New Roman; font-style:italic">SubtitleEdit /convert /list</div> Result: Show the more than 100 supported formats in command line conversion!<br /> -<br /> -<br /> -<hr /> - -<h2><a id="portable">Portable version and VLC</a></h2> -<br /> -To use the portable version with VLC portable, download VLC portable (at least version 1.1.0, like <a href="http://get.videolan.org/vlc/2.0.6/win32/vlc-2.0.6-win32.zip">vlc 2.0.6</a>) and unpack to a sub folder in the Subtitle Edit folder called "VLC". Another option is to use the &lt;VlcLocation&gt; in Settings.xml.<br /> -Note: You need VLC 32-bit. -<br /> -<br /> -<hr /> - -<h2><a id="plugins">Make your own plugin</a></h2> -<br /> -If you can code C# or VB.net you can make your own plugins for SE (SE 3.3 and later).<br /> -<br /> -You can <a href="/Content/SubtitleEdit/PluginSource.zip">download two demo plugins here</a>.<br /> -"Haxor" is a very very basic example.<br /> -"Fix Hyphens" is a more complete example with a form and some basic helper classes.<br /> -At the moment it is possible to use plugins here: File, Tools, Sync, Translate, and Spellcheck.<br /> -<br /> -<br /> -<hr /> - -<h2><a id="compile">Compiling Subtitle Edit</a></h2> -<br /> -Compiling your own version of Subtitle Edit is easy as pie!<br /> -<br /> -If you don't have MS Visual Studio, then just download and install <a href="http://www.microsoft.com/express/vcsharp/">MS Visual C# Express</a>. -Then download the Subtitle Edit source code and open the "SubtitleEdit.csproj" file. Hit F5 - and that's it :)<br /> -Now you can change/add features you want or fix my bugs - if there were any ;) -<br /> -<br /> -<hr /> - - -<h2><a id="issues">Known issues</a></h2> -<br /> -Subtitle Edit has a few known problems!<br /> -<br /> -<table id="tableKnownIssues"> - <thead> - <tr> - <th>Problem</th> - <th>Solution</th> - </tr> - </thead> - <tbody> - <tr> - <td>Crash while playing/loading/showing video with K-Lite installed<br /> - (or other video/audio problems)</td> - <td>Uninstall K-lite and then install <a href="http://code.google.com/p/lavfilters/">LAV Filters - DirectShow Media Splitter and Decoders</a><br /> - <small>Note that Subtitle Edit is a 32-bit application (unless you have specifically found a 64-bit version) and hence requires 32-bit codecs - even on win7 64-bit</small> - <br /><br />Another option is to change video player to VLC in Subtitle Edit via Options->Settings: Video player!</td> - </tr> - <tr> - <td>Problems with unicode characters (WinXp)</td> - <td> - Use font Lucida Sans Unicode/Times New Roman - or upgrade your xp to Windows 7 or 8 (even Vista works better than XP here - also from April 8 2014 nobody should use XP as MS stops all updates/patches)<br /> - Also, you can use File -> Import subtitle with manual chosen encoding. - </td> - </tr> - <tr> - <td>Spell check (NHunspell) crashes</td> - <td>You can change spell check to use MS Word in Options!</td> - </tr> - <tr> - <td>Subtitle Edit fails to run from a network drive ("The publisher could not be verified")</td> - <td>If you do not have sufficient access to run Subtitle Edit from a network drive, then copy it to your local hard disk or obtain the needed access.</td> - </tr> - <tr> - <td>Subtitle Edit portable is not working properly in "Program files" folder</td> - <td>Use the installer if you want to have Subtitle Edit in "Program files" (remove portable version before)</td> - </tr> - <tr> - <td>Subtitle Edit does not detect VLC in options (it's grayed out)</td> - <td>You will need VLC 2.x - and it must be the 32-bit version (unless you also compiled your own 64-bit version of Subtitle Edit)</td> - </tr> - <tr> - <td>Tesseract will not run properly...</td> - <td>If you have used the tesseract installer, then uninstall it. After uninstalling the tesseract installer, you must still remove the environment variable "TESSDATA_PREFIX" (e.g. <a href="http://www.itechtalk.com/thread3595.html">like this)</a>.<br /> - Also, you might need the visual studio 2008 c++ runtime: http://www.microsoft.com/en-au/download/details.aspx?id=5582</td> - </tr> - </tbody> -</table> -<br /> -<br /> -<hr /> - -<br /> -<br /> -<br /> -<br /> -Did you not find what you were looking for? Feel free to <a href="mailto:nikse.dk@gmail.com">email me</a>.<br /> -<br /> -Also, do check out <a href="Video">the Subtitle Edit Intro videos</a> and the <a href="/Content/SubtitleEdit/TutorialByDny238.html">Syncing Subtitles with Subtitle Edit</a> tutorial by dny238! -<br /> -<br /> -<br /> -<br /> -<br /> -<script type="text/javascript"> - addGrid('tableShortcuts'); - addGrid('tableKnownIssues'); -</script> \ No newline at end of file diff --git a/www/HelpEU.cshtml b/www/HelpEU.cshtml deleted file mode 100644 index 64bc05c51..000000000 --- a/www/HelpEU.cshtml +++ /dev/null @@ -1,955 +0,0 @@ -@{ - ViewBag.Title = "Subtitle Edit 3.3 Laguntza"; - ViewBag.Footer = "LaGuNgaRrI iZaTeA iTxAroTen dUt"; - ViewBag.MetaKeywords = "Subtitle Edit help, subtitle tutorial, FAQ, how to synchronize"; - ViewBag.MetaDescription = "Subtitle Edit help page"; - ViewBag.FavIcon = "/favicon.ico"; -} -<h1>@ViewBag.Title</h1> -<hr /> -<br /> -<div style="text-align:right">Laguntza eskuragarri dago ere: <a href="/SubtitleEdit/Help">English</a> | <a href="/SubtitleEdit/HelpEs">Spanish</a> | <a href="/Content/SubtitleEdit/Help/RU">Russian</a></div> -<h2>SEG Txikia</h2> -G: x heuskarriko bideo bat irekitzen saiatzen naizenean, SE-ek ezin du bideoa irakurri edo ez dago soinurik. Zer egin dezaket?<br /> -E: Direct Show erabiltzen baduzu bideo irakurgailu bezala zihurtatu <a href="#codecs">kodek zuzenak</a> erabiltzeaz. Nik k-lite bezalako kodek pakete guztiak kentzea eta <a href="http://code.google.com/p/lavfilters/downloads/list">LAV iragazkiak</a> 32-bit (+64-bit nahi baduzu) bakarrik ezartzea gomendatzen dut. Beste aukera bat VLC bideo irakurgailu bezala erabiltzea da.<br /> -<br /> -G: Non dago atzerapen tresna?<br /> -E: Erabili <b>Erakutsi lehenago/geroago</b> <b>Aldiberetze</b> menuan. Lastertekla <b>Ktrl+Shift+A</b> da. Tresna leiho bat da, hortaz irekita eduki dezakezu lanean ari zaren bitartean <br /> edo azpidatziaren aurreikuspena bideo irakurgailuan egiaztatzerakoan.<br /> -<br /> -G: Zergaitik ezin du Subtitle Editek frame neurria aldatu?<br /> -E: Ongi, ahal du. Hautatu <b>Aldiberetzea -> Aldatu frame neurria</b>.<br /> -<br /> -G: Zergaitik ezin du Subtitle Editek azpidatziak banandu/erantsi?<br /> -E: Erabili <b>Tresnak -> Banandu/erantsi</b>.<br /> -<br /> -G: Subtitle Editek denborak orekatu ahal ditu - baina ez oso hasieratik?<br /> -E: Bai, azpidatzi lerro hautapen batekin lan egin dezakezu. Hautatu lerroak -zerrenda ikuspenean (aholkua: klikatu lehen lerroan, -orduan shift+klikatu azkena) eta -eskuin-klikatu zerrenda ikuspenean (hitzinguru menua) - orain hautaturiko lerroak -zehaztu ditzakezu "ikus aldiberetu hautaturiko lerroak" edo bestela "erakutsi -hauturiko lerroak lehenago/geroago" erabiliz.<br /> -<br /> -G: Subtitle Editek bideoa ikusleiho-osoan irakurri dezake?<br /> -E: Bai, sakatu ALT+ENTER. Erabili tarte tekla irakurri/pausatzeko eta ALT+GORA/BEHERA GEZIA hurrengo/aurreko azpidatzia ikusteko.<br /> -<br /> -G: Azpidatziak itzultzerakoan/editatzerakoan, Subtitle Editek nabigatu dezake azkar hurrengo lerrora?<br /> -E: Bai, sakatu ALT+GORA/BEHERA GEZIA hurrengo/aurreko azpidatzira joateko - idaz-kutxak ere fokuari heutsi diezaioke.<br /> -<br /> -G: Subtitle Editek gehitu ahal ditu azpidatziak bideo agirira?<br /> -E: Ez, Subtitle Editek ezin du egin - baina 100+ irteera heuskarrietako batek edo gehiagok lan egin behar du. Erabili <i>Agiria</i> -> <i>Gorde honela...</i> idatzi ohinarriko azpidatzientzat edo <i>Agiria</i> -> <i>Esportatu...</i> binario/irudi-ohinarriko heuskarrientzat.<br /> -Bi bide daude azpidatziak bideo agirira gehitzeko - erreta (ezin dira inoiz ezkutatu, hortaz <i>beharketa</i> hau ideia txarra izan daiteke) edo barneratuz (zenbait heuskarrirako bakarrik, mkv, mp4 bezala).<br /> -Irakurri gehiago <a href="AddSubtitlesToVideo">azpidatziak gehitzea bideoari</a>. -<br /> -<br /> -<hr /> -<br /> -<h2>Laguntza Aurkibidea</h2> -<div style="margin-left: 25px; line-height: 25px;"> - <a href="#main">Subtitle Edit leiho nagusia</a><br /> - <a href="#main_resize">Subtitle Edit leiho nagusia - birneurritu/uztargabetu</a><br /> - <a href="#main_edit_original">Subtitle Edit leiho nagusia - editatu jatorrizkoa</a><br /> - <a href="#video_modes">Bideo/uhinera edo argilitzaera moduak</a><br /> - <a href="#waveform">Uhinera eta Argilitzaera</a><br /> - <a href="#export">Esportatu</a><br /> - <a href="#sync">Aldiberetzea</a><br /> - <a href="#visual_sync">Ikus aldiberetzea</a><br /> - <a href="#translation">Itzulpena (berez)</a><br /> - <a href="#fixcommonerrors">Akats arrunten zuzenketa</a><br /> - <a href="#spellcheck">Idaz egiaztapena</a><br /> - <a href="#importvobsub">Inportatu/OCR irudi ohinarriko azpidatziak - DVD Sub/idx edo Blu-ray sup bezalakoak</a><br /> - <a href="#shortcuts">Lasterteklak</a><br /> - <a href="#translate">Subtitle Edit beste hizkuntza batera itzultzea</a><br /> - <a href="#networking">Sarea - online elkarlaguntza</a><br /> - <a href="#codecs">Bideo irakurgailua eta kodekak</a><br /> - <a href="#commandline">Komando lerro bihurketa</a><br /> - <a href="#portable">Bertsio eramangarria eta VLC</a><br /> - <a href="#plugins">Egin zeure plugina</a><br /> - <a href="#compile">Subtitle Edit bilketa</a><br /> - <a href="#issues">Arazo Ezagunak</a><br /> -</div> -<br /> -<hr /> -<br /> -<h2><a id="main">Subtitle Edit leiho nagusia</a></h2> - -<br /> -<h3>Ikusleiho nagusiko menua</h3> -Menuan tresna ugari aurkitu ditzakezu, aldatu hizki larri-xehera, banandu, erantsi, idaz egiaztapena, aldiberetzea, aldatu frame neurria, Google itzulpena, bilatu, ordeztu, kendu gorrentzako idatzia eta askoz gehiago!<br /> -DVD, vobsub, Blu-ray sup azpidatziak inportatu ditzakezu - Matroska barneko vobsub agiriak ere inportatu daitezke.<br /> -<br /> -<img src="/Content/SubtitleEdit/EU/main_menu.png" alt="Menu" /><br /> -<br /> -<small>OHARRA: Tresna ugari daude eskuragarri ere zerrenda ikuspenean eskuin klikatuz.</small> -<br /> -<br /> -<br /> - -<br /> -<h3><a id="formats">Azpidatzi/agiri heuskarriak</a></h3> -<table> - <tr> - <td> - <img src="/Content/SubtitleEdit/EU/FormatAndEncoding.png" alt="Subtitle format" /> - <br /> - <br /> - Goiko menuan heuskarria eta kodeaketa hautatu ditzakezu. Lehen hedagarri zerrendak azpidatzi heuskarriak erakusten ditu. SubRip (luzapena ".srt" da) gaur egun heuskarri erabiliena da, hortaz azpidatziak heuskarri honetan gordetzea gomendatzen da.<br /> - Jatorrian SubRip idazki soileko heuskarria zen, baina azken urteetan html etiketak arrunt bihurtu dira. Bereziki etzana eta hizkia etiketak oso erabiliak dira. SubRip sostengua duten irakurgailuen zerrenda ikusteko <a href="http://ale5000.altervista.org/subtitles.htm">aztertu hau</a>.<br /> - <br /> - Agiri kodeaketa berez atzematen da gehienetan. ANSI da gaur egun aurkitzen den heuskarri zahar arruntena, baina beharrezkoa da zure sistemak kultura ezarpen bereizia edukitzea. UTF-8 gomendatzen da azpidatzi berrientzat, honek Ingelerazkoak ez diren hizkiak ANSI-ak baino hobeto kudeatu ditzake (UTF-8 azpidatziek edozein ordenagailutan jardun dezakete zer kultura ezarpen duen axola gabe), eta musika notak bezalako beste ikur batzuk ere erakutsi ditzake. UTF-8 erabiltzearen alde txar bakarra da, batzuetan programa zaharrek ez dutela UFT-8 sostengatzen eta WinXP-ek erdi-unicode hizki gutxik batzuk besterik ez ditu (Lucida Sans Unicode, Time New Roman, Courier New).<br /> - ANSI agiri bat baduzu oraingo kultura/hizkuntzaren bestelakoa den hizkuntza batean (edo baliogabeko UTF/Unicode agiri bat baduzu) menuko gai hau erabili dezakezu:<br /> <i>Agiria</i> -> <i>Inportatu azpidatzia eskuzko kodeaketa hautapenarekin</i>.<br /> - <br /> - <i>Inportatu azpidatzia eskuzko kodeaketa hautapenarekin </i> aurreikuspenarekin:<br /> - <img src="/Content/SubtitleEdit/EU/ChooseEncoding.gif" alt="ChooseEncoding" /> - </td> - </tr> -</table> -<br /> -<br /> - -<h3>Frame neurria</h3> -<table> - <tr> - <td> - <img src="/Content/SubtitleEdit/EU/help_framerate.png" alt="Frame rate" /><br /> - <br /> - Frame neurria ez da berez erakusten, baina gaitu dezakezu menuan <i>Aukerak</i> -> <i>Ezarpenak: Tresnabarra: Erakutsi frame neurria tresnabarran</i>.<br /> - Frame neurria frametan eta denbora ohinarriko heuskarrietan ohinarrituriko azpidatziak heuskarri artean bihurtzerakoan erabiltzen da. - SubRip denboran ohinarriturik dago. MicroDvd (asko erabilia duela 7-9 urte) frametan ohinarriturik dago.<br /> - Denboran ohinarrituriko azpidatziak hobetsiak dira frame neurri aldagaitza ez duten bideotarako - zeinak malgutasunik - ez duten frametan ohinarrituriko azpidatziekin lan egiten duen.<br /> - Frame neurria aldatzeko erabili <i>Aldiberetzea</i> -> <i>Aldatu frame neurria</i> - edo erabili beste <a href="#sync">aldiberetze tresnak</a>-tako bat. - </td> - </tr> -</table> -<br /> -<br /> - -<h3>Azpidatzi ikuspena - Zerrenda ikuspena edo iturburu ikuspena</h3> -<p>Bi modu daude azpidatzi bat ikusteko - zerrenda ikuspena edo iturburu ikuspena.</p> -<table> - <tr> - <td> - <img src="/Content/SubtitleEdit/EU/help_sourceview.png" alt="Source view" /> - </td> - <td> - Horrela ikusten da azpidatzi agiria orain - ezberdina heuskarri bakoitzean.<br /> - Idatzia eta denbora-kodeak editatu ditzakezu hemen, baina kontuz - erraza da ere gauzak nahastea.<br /> - Subtitle Edit Iturburu ikuspegaian abiarazi dezakezu Ezarpenetan. - </td> - </tr> -</table> -<br /> -<table> - <tr> - <td colspan="2"> - <a id="listview"><img src="/Content/SubtitleEdit/EU/help_listview.png" alt="List view" /></a> - </td> - </tr> - <tr> - <td> - Zerrenda ikuspegian azpidatziaren gainikuspen bikaina ematen du - berdina heuskarri guztientzat.<br /> - Idatzia eta denbora-kodeak editatu ditzakezu hemen, lerroak ezabatzea eta txertatzea erraza da.<br /> - <br /> - </td> - </tr> - <tr> - <td colspan="2"> - <br /> - Ahal da ere lerro ugari hautatzea eta <i>Google itzultzailea</i> edo - <i>Ikus aldiberetzea</i> tresnak erabiltzea hautaturiko lerroetan.<br /> - <br /> - <a id="listview2"><img src="/Content/SubtitleEdit/EU/help_listview2.png" alt="Listview" /></a> - </td> - </tr> - <td colspan="2"> - <br /> - <br /> - <h3>Idaz-Kutxa</h3> - <p>Azpidatzia idatzi dezakezun idaz-kutxaren gainean "Hizk/seg" deituriko etiketa bat dago. - 25 baino gehiago baditu laranja/gorriz margotuko da.<br /> - <br /> - </p> - <img src="/Content/SubtitleEdit/EU/TextBox.png" alt="search" /><br /> - <br /> - Idaz-kutxaren azpian "Lerro bakarraren luzera" deituriko etiketa dago. Lehen lerroak 33 hizkirrikoa da eta bigarren lerroa 75 hizkirrikoa. - Lerro luzeraren margo xehetasunak alderatzen dira hemen: Ezarpenak -> Aukerak : Orokorra : Lerro bakarraren geh. luzera. - (43 da berezkoa). Gorriak luzeegia esanahi du, laranjak gehienetik hurbil dagoela. - <br /> - <br /> - </td> - <tr> - </tr> - <tr> - <td colspan="2"> - <br /> - <br /> - <h3>Erakutsi bideoa eta/edo uhinera/argilitzaera</h3> - <br /> - <a id="main_resize">Leiho nagusiak bideoa eta/edo uhinera-argilitzaera erakutsi ditzake.</a> Bideo aginteak uztargabetu daitezke ere - erabilgarria bi monitore badituzu!<br /> - Etzaneko/zutikako lerro gorriek leiho nagusia non birneurriratu dezakezun erakusten dute (banantzaile bidez).<br /> - <br /> - <img src="/Content/SubtitleEdit/EU/main_video1.png" alt="Main window - with video/waveform" /> - </td> - </tr> - <tr> - <td colspan="2"> - <br /> - <br /> - <a id="main_edit_original">Orain bi azpidatziak editatu daitezke aldiberean, itzulpen berria eta jatorrizko azpidatzia.</a> Berez, jatorrizkoa irakurtzeko-bakarrik da, baina hau aldatu dezakezu hemen:<br /> Aukerak -> Ezarpenak: Orokorra: Ahalbidetu jatorrizko azpidatzia editatzea.<br /> - Lasterteklak: <b>Ktrl+U</b> jatorrizko azpidatzia aldatzen du. <b>Ktrl+Shift+U</b> itzulitako / jatorrizko azpidatzia aldatuko du.<br /> - Biak editatzerakoan, jatorrizkoa eta itzulitako azpidatzia, hasiera denbora/iraupena/ezabapena/txertapenak bi azpidatziei eragingo die!<br /> - <br /> - <img src="/Content/SubtitleEdit/EU/main_edit_original.jpg" alt="Main window - with video/waveform" /> - </td> - </tr> -</table> - -<br /> -<br /> -<h3>Bilatu</h3> -<p>Bilaketa bat egin dezakezu Ktrl+F sakatuz (F3 bilatu hurrengoa). Adierazpen arrunt bilaketa eskuragarri dago.</p> -<img src="/Content/SubtitleEdit/EU/help_search.png" alt="search" /><br /> -<br /> -<hr /> -<br /> - -<br /> -<br /> -<h3><a id="multiple_replace">Ordezte Anitza</a></h3> -<p><i>Editatu -> Ordezte anitza</i> erabiliz zeure arauak sortu ditzakezu azpidatzi bat zuzentzeko - baita arau aurreratuak <a href="http://en.wikipedia.org/wiki/Regular_expression">adierazpen arruntak</a> erabiliz!</p> -<p>Idazterakoan adierazpen arrunt taldekatzea eta atzera-xehetasunak oso erabilgarriak dira. Adierazpen arrunt baten zatiak hitzarte batean taldeak dira eta xehetasun bezala erabili daitezke ordezte lerroan $1 lehen taldearen xehatasuna denean eta $2 bigarrenaren xehetasuna eta horrela.<br /> -<div style="padding-left:15px"> -1 adibidea: <b>^#( .+)</b> + ordeztu katea <b>♪ $1</b> - "#" hasiera bakarrik ordeztuko da, hortaz idaztzia "# Musika Entzuten #" bada "♪ Musika Entzuten #"-ekin ordeztuko da<br /> -2 adibidea: <b>([a-z]+)([0-9]+)</b> + ordeztu katea <b>$2$1</b> - bi taldeak aldatuko dira, hortaz idatzia "zenbakia52" bada "52zenbakia" bihurtuko da.<br /> -</div> -</p> -<img src="/Content/SubtitleEdit/EU/main_edit_multiple_replace.png" alt="Multiple replace" /><br /> -<br /> -<hr /> -<br /> - -<h2><a id="video_modes">Bideo/uhinera edo argilitza moduak</a></h2> -<br /> -Bideoa eta/edo uhinera-argilitzaera erabiltzarekoan hiru modu (hegats) daude eskuragarri: Itzuli, Sortu eta Zehaztu. - -<h3>Itzuli modua</h3> -<img src="/Content/SubtitleEdit/EU/mode_translate.png" alt="Translate mode" /><br /> -<br /> -Itzulpen moduan azpidatzi bat hizkuntza batetik bestera eskuz itzuli dezakezu (edo makinaz itzulitako azpidatzi bat zuzendu) -bideoa ikusten - eta audioa entzuten duzun bitartean.<br /> -"Berez berregin" gaituta badago, azpidatzia x-aldiz berregingo da idatzi zuzena idazten duzun bitartean.<br /> -Erabili <i>Agiria</i> -> <i>Ireki jatorrizko azpidatzia (itzultzaile modua)</i> jatorrizko idatzia ere erakusteko.<br /> -Aholkua: Erabili &lt;alt+gora/behera gezia&gt; aurreko/hurrengo azpidatzira joateko.<br /> -<br /> -<br /> - -<h3>Sortu modua</h3> -<img src="/Content/SubtitleEdit/EU/mode_create.png" alt="Create/adjust lines" /><br /> -<br /> -Hau azpidatzi lerroak hutsetik sortzeko edo dauden lerroak eskuz zehazteko tokia da.<br /> -<br /> -Azpidatzi lerroak hutsetik sortzeko, pausatu bideoa azpidatzi lerroa hasi behar den tokian eta sakatu "Txertatu azpidatzi berria bideo kokapenean". Orduan sartu idatzia - iraupena berez iradokitzen da. Orain sakatu "Irakurri idatziaren aurretik" botoia eta idatzia ez bada zehaz-mehatz hasten hizketa hasten denean, zehaztu "Hasiera denbora" gora/behera geziekin bat egin arte. Iraupena "Ezarri amaiera denbora" botoiarekin ezarri daiteke bideoa irakurtzen ari den bitartean edo "Iraupena" gora/behera geziak bidez.<br /> -Azpidatzi bat uneko lerroaren aurretik txertatzeko, sakatu Txertatu botoia (zerrenda ikuspegia fokuturik dagoela).<br /> -<br /> -Baita ere eskuin klikatu dezakezu uhineran edo zerrenda ikuspegian txertatu/batu/banandu/ezabatu lerroak egiteko.<br /> -<br /> -<br /> - -<h3>Zehaztu modua</h3> -<img src="/Content/SubtitleEdit/EU/mode_adjust.png" alt="Adjust mode" /><br /> -<br /> -Hau dauden lerroak zehazteko tokia da.<br /> -<br /> -Azpidatzi lerroak banan-banan eskuz zehazteko goitik hasiz. Erabili "Ezarri hasiera eta orekatu gainontzekoa" (F9) eta "Ezarri amaiera eta joan hurrengora" (F10) botoiak.<br /> -"Hasiera denbora" eta "Iraupena" azken ikutua gora/behera geziak erabiliz egin behar da.<br /> -<br /> -Baita ere eskuin klikatu dezakezu uhineran edo zerrenda ikuspegian txertatu/batu/banandu/ezabatu lerroak egiteko.<br /> -<br /> -<hr /> -<br /> - -<h2><a id="waveform">Uhinera</a></h2> -Uhinera aginteak errazagoa egiten du hizketaren hasiera/amaiera zehatz ikustea.<br /> -<img src="/Content/SubtitleEdit/EU/Waveform1.png" alt="Wave form" /><br /> -<br /> -<br /> -Menuan eskuin klikatuz, azpidatziak banandu/batu/ezabatu ditzakezu.<br /> -<img src="/Content/SubtitleEdit/EU/Waveform2.png" alt="Wave form - right click menu"/><br /> -<br /> -<br /> -Esaldi berri bat sortzeko, hautatu eremu huts bat eta eskuin klikatu.<br /> -<img src="/Content/SubtitleEdit/EU/Waveform3.png" alt="Wave form - new selection" /><br /> -<br /> - -<h3>Uhinera sagu/tekla erabilera:</h3> -<ul> - <li>Sagu klik bakarra: Joan kokapenera</li> - <li>Sagu klik bikoitza dagoen azpidatzian: Hautatu klikaturiko azpidatzia</li> - <li>Markatu erema + eskuin klikatu markaturiko eremuan: Galdetu gehitu esaldi berria / irakurri oraingo hautapena</li> - <li>Sagua arrastatu azpidatziaren ezker/eskuin hertzean (zehaztu hasiera edo amaiera denbora)</li> - <li>Mugitu/arrastatu azpidatziaren erdian (zehaztu biak hasiera eta amaiera denbora - baina ez iraupena)</li> - <li>Sagu eskuin klikak azpidatzi berri bat gehitu dezake edo ezabatu/banandu/batu badagoen azpidatzi lerro bat</li> - <li>Sagu gurpilak uhinera aurrera/atzera irristatzen du</li> - <li>alt+ezker/eskuin geziak bideo kokapena mugitzen du</li> - <li>alt+gora/behera gezia aurreko/hurrengo azpidatziara joateko</li> - <li>Zenbaki +/- zomma handitu/gutxitu</li> - <li>Sagu klik bakarra+Shift hautaturiko azpidatziaren hasiera ezarriko du (amaiera denbora mugitu gabe)</li> - <li>Sagu klik bakarra+Ktrl hautaturiko azpidatziaren amiera ezarriko du (hasiera denbora mugitu gabe)</li> - <li>Sagu klik bakarra+Alt hautaturiko azpidatziaren hasiera ezarriko du (eta iraupenari heutsi)</li> - <li>Sagu klik bikoitza esaldi-gabean - aldatu irakurketa</li> - <li><b>Sagu klik bakarra+Ktrl+Shift hautaturiko azpidatziaren hasiera ezarriko du + hautaturiko azpidatziaren ondorengo lerro guztiak orekatu (iraupenei heutsiz)</b></li> -</ul> - -<br /> -<h3>Uhin aterapena</h3> -Uhin datu aterapena <a href="http://www.videolan.org/">VLC multimedia irakurgailuak 2.x (edo 1.1.x/)</a> egiten du, eta uhin agiri oso txiki bat (lagineurri OSO apal batekin) sortu eta gordetzen da "Uhinera" agiritegian. VLC-k zerbaitegaitik huts egiten badu bideotik uhin agiria ateratzerakoan, uhin agiria beste tresna batekin atera dezakezu eta askatu uhin agiria uhinera agintean, honek uhin agiri txiki bat sortuko du (lagineurri OSO apal batekin) "Uhinera" agiritegian.<br /> -<br /> -Oharra: Ezin duzu uhinera bideo gabe erabili (wav agiria bakarrik baduzu eta ez bideoa, uhin agiria bideo bezala gertatu daiteke + askatu uhin agiria uhinera agintean). -<br /> -<hr /> -<br /> - - -<br /> -<h2><a id="export">Esportatu</a></h2> -Subtitle Editek "Gorde honela..." bidez idazki heuskarri ezberdin anitz gorde ditzake, baina azpidatzi bat heuskarri binarioan gordetzea nahi baduzu (pac edo 890 bezalakoak) edo irudi ohinarrikko heuskarri batean (png edo bluray sup bezalakoak) Agiria -> Esportatu erabili behar duzu.<br /> -Azpidatzien etzana eta margoa bezalako estilo anitz gordetzen dira irudi ohinarriko heuskarrietan esportatzerakoan.<br /> -<br /> -<hr /> -<br /> - - -<h2><a id="sync">Aldiberetzea</a></h2> -<table> - <tr> - <td> - <img src="/Content/SubtitleEdit/EU/SyncMenu.png" alt="Sync menu" /> - </td> - </tr> - <tr> - <td> - <br /> - Subtitle Editek bide anitz eskaintzen ditu azpidatziak aldiberetzeko.<br /> - <p>Zehaztu denbora guztiak (erakutsi lehenago/geroago): Hau erabilgarria da idatzi guztiak 3 segundu lehenago erakustea behar baduzu.</p> - <p><a href="#visual_sync">Ikus aldiberetzea</a>: Aldiberetu hasier/amaiera agerraldia berdinduz (behean gehiago).</p> - <p>Aldiberetze puntua: Honek aldiberetzea ahalbidetzen du 2 puntu edo gehiago erabiliz - aldiberetze puntu denbora kodeak - eskuz sartu daitezke honek erabilterraza egiten duelarik jadanik aldibereturik dagoen beste azpidatzi baten denbora kodeak erabiltzea.</p> - <p>Aldiberetze puntua beste azpidatzi baten bidez: Aldibereturik dagoen beste azpidatzi bat baduzu (adibidez beste hizkuntza batean - lagungarria da apur bat ulertu badezakezu) lehen lerroetako bat berdindu dezakezu, berdindu azken lerroetako bat, aldiberetu eta orduan lerro guztiak aldibereturik egon behar dute.</p> - <p>Aldatu frame neurria: Honek erraza egiten du idatzi bat berdintzea frame neurri bat duen bideo batetik beste frame neurri bat duen bideo batera (ikus aldiberetzez edo aldiberetze puntuaz ere egin daiteke).</p> - </td> - </tr> -</table> -<br /> -<br /> -<br /> - - -<h2><a id="visual_sync">Ikus aldiberetzea</a></h2> -<table> - <tr> - <td colspan="2"> - <img src="/Content/SubtitleEdit/EU/vissync.png" alt="Visual Sync controls" /> - </td> - </tr> - <tr> - <td> - <img src="/Content/SubtitleEdit/EU/help_vs2.png" alt="Synchronize button" /> - </td> - <td> - <br /> - Ikus aldiberetzea egitan bide erraza da azpidatzi bat bideo agiri batekin aldiberetzeko.<br /> - Berdindu lehen lerroetako bat hasierako agerraldiarekin. Orduan berdindu azpidatziaren azken - lerroetako bat amaiera agerraldiarekin. Sakatu "Aldiberetu!" - eta eginda :)<br /> - Botoi lagungarri gutxi batzuk daude azpidatzia bideoan hasi behar den tokia bilatzen lagunduko dutenak - (lehen hitza irtetzen den tokia). "Irakurri 1 seg eta atzera" botoia azterketa botoi bat da, - hortaz oraingo kokapena egitan zuzena den erraz egiaztatu dezakezu. Egiaztatu ere <a href="#shortcuts">Lasterteklak</a>.<br /> - <br /> - Batzuetan ezinezkoa da azpidatzia aldiberetzea agerraldi bat edo gehiago ezabatu/gehitu direlako. - Kasu hauetan azpidatzi zenbateko bat hautatu dezakezu azpidatziaren <a href="#listview">zerrenda ikuspegian</a>, eskuin - klikatu eta hautatu <i>Ikus aldiberetu hautaturiko lerroak</i>. Honela azpidatzia zati txikiagotan zehaztu dezakezu. - </td> - </tr> -</table><br /> -<br /> -<hr /> -<br /> -<h2><a id="translation">Itzulpena (berez)</a></h2> -Subtitle Editek azpidatzia itzuli dezake <a href="http://www.google.com/translate">Google itzulpena</a> erabiliz -edo <a href="../mt">Multi Translator</a> (Suedieratik Danierara bakarrik).<br /> -Googlek hizkuntza askoren arteko itzulpena egiten du! Nahiko ongi lan egiten du, baina itzulitako azpidatziek -oraindik eskuzko zuzenketa behar dute (aholkua: erabili leiho nagusiko <a href="#video_modes">itzulpen modua</a>). -<br /> -<br /> -<img src="/Content/SubtitleEdit/EU/help_googletranslate.png" alt="Create/add lines" /><br /> -<br /> -<hr /> -<br /> -<h2><a id="fixcommonerrors">Akats arrunt zuzenketa</a></h2> -<br /> -<img src="/Content/SubtitleEdit/EU/help_fixcommonerrors1.png" alt="Fix common errors" /><br /> -<br /> -Azpidatzi batzuek akats pilo bat izaten dute (sarri azpidatzi hauek OCR softwarea erabiliz sortuak dira).<br /> -"Tresnak -> Zuzendu akats arruntak" bide erraz bat eskaintzen du akats hauetako asko zuzentzeko.<br /> -Lehen leihoak zuzentzeko ekintzen zerrenda bat erakusten du, klikatu zuzentzea nahi dituzunak eta klikatu "Hurrengoa".<br /> -<br /> -<br /> -<img src="/Content/SubtitleEdit/EU/help_fixcommonerrors2.png" alt="Fix common errors" /><br /> -<br /> -Orain zer zuzenketa ezarri hautatu dezakezu. Berez lerro guztiak hautatzen dira, baina ezartzea nahi ez dituzun zuzenketak ezhautatu ditzakezu.<br /> -Ohar hegatsak zuzenduko denaren gainikuspen bat ematen du - eta zer ezin den zuzendu.<br /> -"Ezarri zuzenketak" botoiak zuzenketak ezartzen ditu.<br /> -<br /> -<hr /> -<br /> -<b><a id="spellcheck">Idaz-Egiaztapena</a></b> -<br /> -<br /> -Idaz-egiaztapena <a href="http://hunspell.sourceforge.net/">Hunspell</a> (Open/LibreOffice, Firefox, Chrome, eta Operak ere erabiltzen dutena) bidez egiten da.<br /> -Ingelerazko hiztegia bakarrik dago barne, baina erraz bilatu ditzakezu hiztegi gehiago tresnabarra menuan <i>Idaz-egiaztapena</i> -> <i>Lortu hiztegiak...</i>!<br /> -<a href="http://extensions.services.openoffice.org/en/dictionaries">Open Office 3.x hiztegiak</a> jeisten badituzu .oxt luzapenarekin, berrizandatu itzazu .zip, eta orduan despaketatu .dic agiria eta .aff agiria Subtitle Edit <i>Dictionary</i> agiritegira.<br /> -<br /> -Idaz-egiaztapenak leiho hau erakutsiko du hitz ezezagun bat aurkitzen duenean:<br /> -<img src="/Content/SubtitleEdit/EU/spell_check.png" alt="spell check" /><br /> -<b><i>Editatu idatzi osoa</i></b> idatzi osoa editatzea gaitzen du (eta ez uneko hitza bakarrik) - azpidatzi honetarako bakarrik.<br /> -<b><i>Aldatu denak / Erabili betik</i></b> uneko hitza betik aldatuko du - baita hurrengo lanetan (OCR Zuzendu Ordeztu zerrendan gordeta - bota begirada bat Dictionaries/eng_OCRFixReplaceList.xml agiri honetaz gehiago jakiteko).<br /> -<b><i>Aldatu / Erbili</i></b> uneko hitza oraingoan bakarrik aldatuko du.<br /> -<b><i>Gehitu zerrenda/zarata zerrendara (hizki xehe-larriak)</i></b> izena edizio idaz-kutxan gogoratuko du uneko xehe-larriz - baita hurrengo lanetan.<br /> -<b><i>Gehitu erabiltzaile zerrendara</i></b> hitza edizio idaz-kutxan gogoratuko du eta ez du berriro berataz galdetuko - baita hurrengo lanetan. Erabiltzaile hiztegiak ez ditu hizki xehe-larriak bereizten.<br /> -<br /> -"Hitza ez da aurkitu" taldekutxako botoi guztiak hitza erabiliko dute "Hitza ez da aurkitu" idazkutxan.<br /> -<br /> -<hr /> -<br /> -<h2><a id="importvobsub">Inportatu/OCR irudi ohinarriko azpidatziak - DVD Sub/idx edo Blu-ray sup bezalakoak</a></h2> -<br /> -<br /> -Blu-ray sup edo sub/idx (vobsub) bezalako irudi ohinarriko azpidatzi bat irekitzen baduzu leiho hau agertuko da:<br /> -<br /> -<img src="/Content/SubtitleEdit/EU/help_importvobsub.png" alt="Import/ocr image based subtitles" /><br /> -<br /> -<br /> -Zerrenda ikuspegiak orain denbora-kodea besterik ez duten azpidatzi lerro hutsak ditu. Idatzia eskuz sartu dezakezu, baina bi (edo hiru MODI ezarrita baduzu) aukera hobeagoak daude: -<ul> - <li>OCR Tesseract 3 bidez (gomendatua): <a href="http://code.google.com/p/tesseract-ocr/">Tesseract</a> iturburu irekiko OCR gailua da. <br /> - Hizkuntza gehigarri datu agiriak bilatu ditzakezu hemen: <a href="http://code.google.com/p/tesseract-ocr/downloads/list">Tesseract Google code project</a>. Tesseract hiztegi agiri hauek despaketatu egin behar dira [Subtitle Edit agiritegia]\Tesseract\tessdata.<br /> - <br /> - Zerrenda ikuspegian eskuin-klikatzen baduzu, aukera hauek dituen hitzinguru menu bat lortuko duzu:<br /> - <img src="/Content/SubtitleEdit/EU/ocr_context_menu.png" alt="OCR list view context menu" /><br /> - <b><i>Inportatu idatzia denbora-kode berdinekin...</i></b> lehenago sorturiko azpidatzi batekin lanean jarraitzeko erabili daiteke.<br /> - <b><i>Gorde azpidatzi irudia honela...</i></b> oraingo irudia pgn, gif, bmp, edo tiff bezala gordetzea ahalbidetzen du.<br /> - <b><i>Gorde irudi guztiak html aurkibidearekin</i></b> azpidatzi irudi guztiak html orrialde bezala erakusten ditu - irakurketa azterketa errazerako.<br /> - <br /> - - OCR Tesseract bidez hobeto lan egingo du <a href="#spellcheck">idaz-egiaztapen</a> hiztegiak badituzu.<br /> - <img src="/Content/SubtitleEdit/EU/ocr_dictionary.png" alt="OCR dictionary" /><br /> - <b><i>Galdetu hitz ezezagunak</i></b> eta <b><i>Saiatu iradokitzen hitz ezezagunak</i></b> hiztegia eskuragarri badago bakarrik lan egingo du. <b><i>Zuzendu OCR akatsak</i></b> ere onura ateratzen du hiztegia badu.<br /> - <br /> - <b><i>Galdetu hitz ezezagunak</i></b> honela ikusiko da (leihoa ber-neurriragarria da):<br /> - <img src="/Content/SubtitleEdit/EU/ocr_spell_check.png" alt="OCR spell check" /><br /> - <b><i>Editatu idatzi osoa</i></b> idatzi osoa editatzea gaitzen du (eta ez uneko hitza bakarrik) - azpidatzi honetarako bakarrik.<br /> - <b><i>Aldatu denak / Erabili betik</i></b> uneko hitza betik aldatuko du - baita hurrengo lanetan (OCR Zuzendu Ordeztu zerrendan gordeta - bota begirada bat Dictionaries/eng_OCRFixReplaceList.xml agiri honetaz gehiago jakiteko).<br /> - <b><i>Aldatu / Erabili</i></b> uneko hitza oraingoan bakarrik aldatuko du.<br /> - <b><i>Gehitu zerrenda/zarata zerrendara (hizki xehe-larriak)</i></b> izena uneko hizki xehe-larriz gogoratuko du - baita hurrengo lanetan.<br /> - <b><i>Gehitu erabiltzaile zerrendara</i></b> hitza edizio idaz-kutxan gogoratuko du eta ez du berriro berataz galdetuko - baita hurrengo lanetan.<br /> - <br /> - <br /> - </li> - <li>OCR irudi alderaketa bidez: Aukera honek ez behar hirugarren softwarerik ezarrita, baina - erabiltzaileak irudi zatietan ohinarrituriko hizkiak eskuz sartzea behar du.<br /> - "Ez dago pixelik tartean" gutxitu egin behar da itzulitako hitz guztiak ez badaude bananduta ("<i>ongigaude.</i>" bezala), eta handitua - bananketa gehiegi badaude ("<i>on gi ga u d e.</i>" bezala).<br /> - Oharra: Ez du ongi lan egiten Blu-ray sup agiriekin!<br /> - <br /> - </li> - <li>OCR MODI bidez: MODI <a href="http://en.wikipedia.org/wiki/Microsoft_Office_Document_Imaging">Microsoft Office Document Imaging</a> laburpena da. Hau Microsoft Office Tools-en barne dago ("Microsoft Office \ Microsoft Office Tools" agiritegia hasiera menuan).<br /> - Honek Tesseract-en oso antzera egiten du lan, baina MS Office behar du.<br /> - Microsoft Office ezarrita baduzu baina MODI OCR ez badago eskuragarri saiatu MS Office ezarpena berriro ekiten eta zihurtatu MODI hautaturik dagoela programaren ezarpenean. - <br /> - </li> -</ul> -Hautatu OCR metodoetako bat eta klikatu "Hasi OCR" botoia.<br/> -Eginda duzunean klikatu "Ongi" eta gogoratu OCR azpidatzi batek zihurrenik zuzenketa behar duten akats batzuk izango dituela.<br /> -VobSub azpidatzi batek hizkuntza bat baino gehiago badu, hizkuntza hautatzeko galdetuko zaizu.<br /> -<br /> -<hr /> -<br /> -<br /> -<h2><a id="shortcuts">Lasterteklak</a></h2> -<br /> -<table id="tableShortcuts"> - <thead> - <tr> - <th>Leihoa</th> - <th>Agintea</th> - <th>Lasterteklak</th> - <th>Eginkizuna</th> - </tr> - </thead> - <tbody> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>F1</td> - <td>Erakutsi laguntza agiri hau ;)</td> - </tr> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>Ktrl+F</td> - <td>Ireki Bilatu elkarrizketa</td> - </tr> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>F3</td> - <td>Bilatu hurrengoa</td> - </tr> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>Ktrl+z</td> - <td>Erakutsi historia/desegin</td> - </tr> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>Ktrl+G</td> - <td>Joan azpidatzi zenbaki elkarrizketara</td> - </tr> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>Ktrl+L</td> - <td>Azpidatzi zerrenda ikuspegian lehenik hautaturiko azpidatzi lerroa aurkitzen du (irriskapena)</td> - </tr> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>Alt+Gora gezia</td> - <td>Joan lerro bat gora azpidatzi zerrenda ikuspegian</td> - </tr> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>Alt+Behera gezia</td> - <td>Joan lerro bat behera azpidatzi zerrenda ikuspegian</td> - </tr> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>Ktrl+U</td> - <td>Itzultzaile modua bai/ez</td> - </tr> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>Ktrl+Shift+U</td> - <td>Aldatu oraingo azpidatzia jatorrizko azpidatziarekin</td> - </tr> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>Shift+Txertatu</td> - <td>Txertatu lerroa hautaturiko lehen lerroaren aurretik</td> - </tr> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>Alt+Txertatu</td> - <td>Txertatu lerroa hautaturiko lehen lerroaren ondoren</td> - </tr> - <tr> - <td>Nagusia</td> - <td>Azpidatzi idaz kutxa</td> - <td>Ktrl+I</td> - <td>Egin hautapena etzana</td> - </tr> - <tr> - <td>-</td> - <td>-</td> - <td>-</td> - <td>-</td> - </tr> - <tr> - <td>Nagusia</td> - <td>Azpidatzi zerrenda ikuspena</td> - <td>Ktrl+A</td> - <td>Hautatu lerro denak</td> - </tr> - <tr> - <td>Nagusia</td> - <td>Azpidatzi zerrenda ikuspena</td> - <td>ktrl+D</td> - <td>Hautatu bakarrik hauturiko lehen lerroa</td> - </tr> - <tr> - <td>Nagusia</td> - <td>Azpidatzi zerrenda ikuspena</td> - <td>Ktrl+Shift+I</td> - <td>Alderantzizkatu hautapena</td> - </tr> - <tr> - <td>Nagusia</td> - <td>Azpidatzi zerrenda ikuspena</td> - <td>Ezabatu</td> - <td>Ezabatu hautaturiko lerroak</td> - </tr> - <tr> - <td>Nagusia</td> - <td>Azpidatzi zerrenda ikuspena</td> - <td>Txertatu</td> - <td>Txertatu lerroa hautaturiko lehen lerroaren ondoren</td> - </tr> - <tr> - <td>Nagusia</td> - <td>*</td> - <td>Ktrl+Shift+M (edo Ktrl+K)</td> - <td>Batu hautaturiko lerroak</td> - </tr> - <tr> - <td>-</td> - <td>-</td> - <td>-</td> - <td>-</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>Alt+Ezker gezia</td> - <td>Joan 0,5 segundu atzera bideoan</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>Alt+Eskuin gezia</td> - <td>Joan 0,5 segundu aurrera bideoan</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>Ktrl+Ezker gezia</td> - <td>Joan 0,1 segundu atzera bideoan</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>Ktrl+Eskuin gezia</td> - <td>Joan 0,1 segundu aurrera bideoan</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>Ktrl+Alt+P</td> - <td>Pausatu bideoa</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>Ktrl+P</td> - <td>Aldatu irakurri/pausatu bideoa</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>F4</td> - <td>Aldatu oraingo esaldiaren kokapena amaiera/hasiera artean</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>F5</td> - <td>Irakurri oraingo esaldia eta gelditu ondoren</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>F6</td> - <td>Joan oraingo esaldiaren hasiera kokapenera</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>F7</td> - <td>Joan 3 segundu atzera</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>F8</td> - <td>Aldatu irakurri/pausatu</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>F9-F12</td> - <td>Moduaren arabera (itzuli/sortu/zehaztu</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>Alt+1</td> - <td>Joan oraingo esaldiaren hasiera kokapena</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>Alt+2</td> - <td>Joan oraingo esaldiaren amaiera kokapena</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>Alt+3</td> - <td>Joan aurreko esaldira</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera</td> - <td>Alt+4</td> - <td>Joan hurrengo esaldira</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera - Zehaztu modua</td> - <td>Ktrl+Tartea</td> - <td>Ezarri hasiera eta orekatu gainontzekoa</td> - </tr> - <tr> - <td>Nagusia</td> - <td>bideo irakurgailua/uhinera - Zehaztu modua</td> - <td>Shift+Tartea</td> - <td>Ezarri amaiera eta joan hurrengora</td> - </tr> - <tr> - <td>-</td> - <td>-</td> - <td>-</td> - <td>-</td> - </tr> - <tr> - - <td>Uztargabetu bideo irakurgailua</td> - <td>-</td> - <td>Alt+A</td> - <td>Birneurritu bideo ikuspegi maila 1:1 izateko</td> - </tr> - <tr> - - <td>Uztargebetu bideo irakurgailua</td> - <td>-</td> - <td>Alt+Sartu</td> - <td>Aldatu leihoa handien/arrunt artean</td> - </tr> - <tr> - <td>-</td> - <td>-</td> - <td>-</td> - <td>-</td> - </tr> - <tr> - <td>OCR bidezko irudi alderaketa - Irudia idatzira eskuz</td> - <td>-</td> - <td>Alt+Eskuin gezia</td> - <td>Hedatu hautapena</td> - </tr> - <tr> - <td>OCR bidezko irudi alderaketa - Irudia idatzira eskuz</td> - <td>-</td> - <td>Alt+Ezker gezia</td> - <td>Hautapen murriztua</td> - </tr> - <tr> - <td>OCR bidezko irudi alderaketa - Irudia idatzira eskuz</td> - <td>-</td> - <td>Alt+i (itzulpenaren arabera)</td> - <td>Aldatu etzana</td> - </tr> - <tr> - <td>OCR bidezko irudi alderaketa - Irudia idatzira eskuz</td> - <td>-</td> - <td>Alt+f (itzulpenaren arabera)</td> - <td>Aldatu berez-aurkezpena (berezgaitasunez jarraitu sakaturiko lehen hizkiaren ondoren)</td> - </tr> - </tbody> -</table> -<br /> -<br /> -Oharra - lastertekla asko itxuratu daitezke hemen: <i>Aukerak -> Ezarpenak -> Lasterteklak</i> (jakinarazi diezadazu gehiago behar baduzu):<br /> -<br /> -<img src="/Content/SubtitleEdit/EU/shortcuts.png" alt="Configurable shortcuts" /><br /> -<br /> -<br /> -<br /> -<hr /> -<br /> -<br /> - -<h2><a id="translate">Itzuli Subtitle Edit beste hizkuntza batera</a></h2> -<br /> -Subtitle Edit itzultzeko lehenik jeitsi <a href="/Content/SubtitleEdit/Language.xml">Ingelerazko xml hizkuntza agiria</a> eta gorde zure -"Subtitle Edit\Languages" agiritegian. Itzuli etiketa guztien edukia xml editatzaile batean edo notepad-ekin. -<a href="/XmlContentTranslator">Xml Eduki Itzultzailea</a> ere erabili dezakezu!<br /> -Gorde editaturiko zure xml agiria honela 'KulturaIzena'.xml ('KulturaIzena' <a href="http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo%28v=vs.80%29.aspx">badagoen kultura izen bat</a> izan behar da - eta baita etiketa bat xml agirian) SubtitleEdit\Languages agiritegian.<br /> Orain Aukerak > Hautatu hizkuntza, hegatsean -zure itzulpena aztertu dezakezu zure hizkuntza hautatuz hizkuntza bezala.<br /> -Mesedez bidali itzulpena niri, horrela Subtitle Edit-en barneratuko dut - Mila esker :)<br /> -Aholkua: <a href="http://winmerge.org">WinMerge </a> tresna bikaina da agiriak alderatzeko.<br /> -<br /> -Ezartzailea <a href="http://subtitleedit.googlecode.com/svn/trunk/installer/Custom_Messages.iss">agiri hau</a> itzuliz herrialdetu daiteke. -<br /> -<br /> -<hr /> -<br /> - - -<h2><a id="networking">Sarea - online elkarlaguntza</a></h2> -<br /> -Zuk eta zenbait lagunek azpidatzi bera aldiberean itzultzea nahi baduzue internet bidez, saiatu "Sarea" ezaugarriarekin.<br /> -Lehenik gertatu itzultzea nahi duzun azpidatzia (eta aukeran jatorrizko azpidatzia). Orduan hautatu "Hasi saio berri bat" "Sarea" menuan:<br /> -<br /> -<img src="/Content/SubtitleEdit/EU/NetworkingStart.png" alt="Start network session" /> -<br /> -<br /> -"Saio giltza" zure azpidatziaren id-a da (zuk nahi duzun idazkia izan daiteke) - besteek hau behar dute zure saiora batu ahal izateko (menuko Sarea -> Batu saiora) bidez.<br /> -"Erabiltzaile izena" erakutsiko da lerroak eguneratu/txertatu/ezabatutakoan eta txat leihoan.<br /> -"Webzerbitzu url-a"-k zerbitzari programa hostalari txiki batean jartzen du (Hasieran hau zuzeneko p2p bidez garatu nuen, baina webzerbitzua erabiltzea erabaki nuen ordez, horrela askoz hobeto egiten du lan suhesiak bezalako gauzekin). <a href="/Content/SubtitleEdit/SENetworkingService.zip">Webzerbitzu honen iturburu kodea eskuragarri dago</a> eta oso erraza izan beharko litzake zure zerbitzaria erabiltzea sare saioak hostatzeko.<br /> -<br /> -<br /> -Subtitle Edit-ek behean erakusten den moduan egiten du lan sarean. "Erabiltzailea/ekintza" zutabean zerrenda ikuspegian itzulpenaren garapena jarraitu dezakezu - honek sinergia eraginen bat bizitu dezake!<br /> -<br /> -<img src="/Content/SubtitleEdit/EU/networking.jpg" alt="Subtitle Edit running in networking mode" /> -<br /> -<br /> -<hr /> -<br /> - - -<h2><a id="codecs">Bideo irakurgailua eta kodekak</a></h2> -<br /> -Subtitle Editek VLC multimedia irakurgailua erabili dezake Subtitle Edit barnean DirectShow ordez - joan <i>Aukerak -> Ezarpenak -> Bideo irakurgailua</i>. VLC aukera ez badago eskuragarri, zihurrenik VLC 2.x edo 1.1.x bertsioa ezarri beharko duzu!<br /> -Beste bideo aukera erabilgarri bat <a href="http://www.mplayer2.org/">mplayer2</a> da. Gorde "mplayer.exe" zure Subtitle Edit agiritegian eta Subtitle Editen joan <i>Aukerak -> Ezarpenak -> Bideo irakurgailua</i>-ra eta hautatu "MPlayer".<br /> -Oharra: VLC eta MPlayer beren kodekekin datoz, hortaz ez duzu <a href="http://code.google.com/p/lavfilters/">LAV Iragazkiak</a> edo ffdshow/Hali Matroska Banantzailea ezarri beharrik.<br /> -<br /> -<img src="/Content/SubtitleEdit/EU/OptionsVideoPlayer.png" alt="Choose video player" /> -<br /> -<br /> -Sarri DirectShow bideo irakurgailu arazoak Subtitle Editen kodek gaitz/gatazkatsu/galdu/zaharrek eraginak dira(Kodek paketeak DEABRUA dira!).<br/> -Akatsa horrelako zerbait izan daiteke: System.Runtime.InteropServices.InvalidComObjectException eta aipatu dezake QuartzTypeLib/QuartzPlayer.<br /> -<br /> -Nire gomendioa kodek pakete denak kentzea da (K-lite barne), berrabiarazi eta orduan ezarri <a href="http://code.google.com/p/lavfilters/">LAV Iragazkiak - DirectShow Multimedia Banantzailea eta Dekodeatzaileak</a> <br /> -Ohartu Subtitle Edit 32-biteko aplikazioa dela (64-biteko bertsio bereizi bat aurkitu ez baduzu) eta hortaz 32-biteko kodekak behar ditu - baita 64-biteko win7/8-an<br /> -<br /> -Arazoak badituzu heuskarri/agiri bereizi batekin saiatu honekin: <a href="http://mediaarea.net/MediaInfo">MediaInfo</a> / <a href="http://www.headbands.com/gspot/">GSpot</a>.<br /><br /> -<br /> -<hr /> - -<h2><a id="commandline">SE komando lerro bihurketa</a></h2> -<br /> -Subtitle Edit-ek (3.2) agindu lerro bihurketa egin dezake leiho nagusiko hedagarri zerrendako heuskarrien artean.<br /> -<br /> -Joskera: SubtitleEdit /convert "eredua" "heuskarriaren-izena-tarterik-gabe" [/kodeaketa:?] [/fs-ko:?] [/irteera-agiritegia:?]:<br /> -<br /> - 1 Adibidea: <div style="font-family:Times New Roman; font-style:italic">SubtitleEdit /convert sub1.srt sami</div> Emaitza: sub1.srt --> sub1.sub --> SAMI heuskarrira bihurtuko du<br /> -<br /> - 2 Adibidea: <div style="font-family:Times New Roman; font-style:italic">SubtitleEdit /convert *.srt adobeencore</div> Emaitza: .srt agiri guztiak Adobe Encore heuskarrira bihurtuko ditu<br /> -<br /> - 3 Adibidea: <div style="font-family:Times New Roman; font-style:italic">SubtitleEdit /convert *.srt adobeencore /encoding:windows-1252</div> Emaitza: Gainekoa bezala baina windows-1252 agiri kodeaketa erabiliz (ikusi <a href="http://msdn.microsoft.com/en-us/library/system.text.encodinginfo.getencoding.aspx">Info.Name zerrenda</a> kodeaketa gehiagorako)<br /> -<br /> - 4 Adibidea: <div style="font-family:Times New Roman; font-style:italic">SubtitleEdit /convert a.sub subrip /fps:25</div> Emaitza: Frame ohinarriko a.sub denbora ohinarriko a.srt bihurtzen ditu 25-eko frame neurriaren bidez<br /> -<br /> - 5 Adibidea: <div style="font-family:Times New Roman; font-style:italic">SubtitleEdit /convert a.sub subrip /outputfolder:C:\Temp</div> Emaitza: a.sub --> C:\Temp\a.srt bihurtzen ditu<br /> -<br /> - Sostengaturiko heuskarri zerrenda ikusteko: <div style="font-family:Times New Roman; font-style:italic">SubtitleEdit /convert /list</div> Emaitza: Agindu lerro bihurketan sostengaturiko 100 heuskarri baino gehiago erakusten ditu!<br /> -<br /> -<br /> -<hr /> - -<h2><a id="portable">Bertsio eramangarria eta VLC</a></h2> -<br /> -Bertsio eramangarria VLC-rekin erabiltzeko, jeitsi VLC eramangarria (gutxienez 1.1.0 bertsioa, azken bertsioa hemen: <a href="http://sourceforge.net/projects/azpidatziak.u/files/Euskarazko%20VLC-2.0.8%20%28EUS_XA%29%20Egonkor%20Eramangarria%20%28Programa%20Osorik%29.zip/download"> vlc 2.0.x</a> (Zip) eta despaketatu "VLC" deituriko agiritegi batera SubtitlEdit zuzenbidean. - -<br /> -<br /> -<hr /> - -<h2><a id="plugins">Egin zeure plugina</a></h2> -<br /> -C# edo VB.net kodeatu badezakezu zeure pluginak egin ditzakezu SE-rentzat (SE 3.3 eta berriagoak).<br /> -<br /> -<a href="/Content/SubtitleEdit/PluginSource.zip">Bi erakus plugin jeitsi ditzakezu hemen</a>.<br /> -"Haxor" adibide oso oso ohinarrizkoa da.<br /> -"Fix Hyphens" adibide osoago bat da forma batekin eta zenbait ohinarrizko klaseekin.<br /> -Oraingoz pluginak hemen erabili daitezke: Agiria, Tresnak, Aldiberetzea, Itzulpena eta Idaz-egiaztapena.<br /> -<br /> -<br /> -<hr /> - -<h2><a id="compile">Subtitle Edit bilketa</a></h2> -<br /> -Subtitle Edit-en zeure bertsioa biltzea osoa erraza da!<br /> -<br /> -Ez badizu MS Visual Studio, orduan besterik gabe jeitsi eta ezarri <a href="http://www.microsoft.com/express/vcsharp/">MS Visual C# Express</a>. -Orduan jeitsi Subtitle Edit-en iturburu kodea eta ireki "SubtitleEdit.csproj" agiria. Sakatu F5 - eta eginda :)<br /> -Orain nahi dituzun ezaugarriak aldatu/gehitu ditzakezu edo nire akatsak zuzendu - bakarren bat badago ;) -<br /> -<br /> -<hr /> - - -<h2><a id="issues">Arazo ezagunak</a></h2> -<br /> -Subtitle Editek arazo ezagun gutxi batzuk ditu!<br /> -<br /> -<table id="tableKnownIssues"> - <thead> - <tr> - <th>Arazoa</th> - <th>Konponbidea</hd> - </tr> - </thead> - <tbody> - <tr> - <td>Matxura irakurtzerakoan/gertatzerakoan/bideoa erakusterakoan K-Lite ezarrita dagoela</td> - <td>Kendu K-lite eta ezarri <a href="http://code.google.com/p/lavfilters/">LAV Iragazkiak - DirectShow Multimedia Banantzailea eta Dekodeatzaileka</a><br /> - <small>Ohartu Subtitle Edit 32-biteko aplikazioa dela (64-biteko bertsio bereizi bat aurkitu ez baduzu) eta hortaz 32-biteko kodekak behar ditu - baita 64-biteko win7/8-an</small> - <br /><br />Beste aukera bat bideo irakurgailua VLC-ra aldatzea da Subtitle Editen, Aukerak->Ezarpenak: Bideo irakurgailua erabiliz!</td> - </tr> - <tr> - <td>Arazoak unicode hizkiekin (WinXp)</td> - <td> - Erabili Lucida Sans Unicode/Times New Roman hizkiak - edo eguneratu zure xp Windows 7 edo 8-ra (Vistak ere XP-ak baino hobeto egiten du lan hemen - baita 2014-ko Apirilak 8-tik aurrera inork ez du XP erabili behar MS-ek eguneraketa/eranskin guztiak geldiarazten dituenez)<br /> - Erabili dezakezu ere, Agiria -> Inportatu azpidatziak eskuzko kodeaketa hautapenarekin. - </td> - </tr> - <tr> - <td>Idaz egiaztapen (NHunspell) matxura</td> - <td>Idaz egiaztatzeilea aldatu dezakezu Aukeratan MS Word erabiltzeko!</td> - </tr> - <tr> - <td>Subtitle Edit-ek huts egiten du sare gidagailu batetik ekiterakoan ("Argitaratzailea ezin da egiaztatu")</td> - <td>Ez baduzu nahikoa sarbiderik Subtitle Edit sare gidagailu batetik ekiteko, kopiatu zure tokiko diska gogorrera edo lortu beharrezko sarbide baimena.</td> - </tr> - <tr> - <td>Subtitle Edit eramangarriak ez du ongi lan egiten "Programa agiriak" agiritegian</td> - <td>Erabili ezartzailea Subtitle Edit "Programa agiriak"-an edukitzea nahi baduzu (kendu bertsio eramangarria aurretik)</td> - </tr> - <tr> - <td>Subtitle Editek ez du VLC atzematen aukeratan (hautaezina dago)</td> - <td>VLC 2.x behar duzu - eta 32-biteko bertsioa izan behar da (baita zeure Subtitle Edit 64-biteko bertsioa bilduta baduzu ere)</td> - </tr> - </tbody> -</table> -<br /> -<br /> -<hr /> - -<br /> -<br /> -<br /> -<br /> -Ez duzu bilatzen duzuna aurkitzen? Sentitu aske <a href="mailto:nikse.dk@gmail.com">post@mezu bidaltzeko niri</a>.<br /> -<br /> -<br /> -<br /> -<br /> -<br /> \ No newline at end of file diff --git a/www/HelpEs.cshtml b/www/HelpEs.cshtml deleted file mode 100644 index 1531e204f..000000000 --- a/www/HelpEs.cshtml +++ /dev/null @@ -1,985 +0,0 @@ -@{ - ViewBag.Title = "Subtitle Edit 3.3 Ayuda"; - ViewBag.Footer = "esPero Que leS SirvA"; - ViewBag.MetaKeywords = "Ayuda Subtitle Edit, tutorial subtítulos, FAQ, cómo sincronizar"; - ViewBag.MetaDescription = "Página de ayuda de Subtitle Edit"; - ViewBag.FavIcon = "/favicon.ico"; -} -<h1>@ViewBag.Title</h1> -<hr /> -<br /> -<div style="text-align:right">La ayuda también está disponible en <a href="/SubtitleEdit/HelpEU">Basco</a> | <a href="/SubtitleEdit/HelpEs">Español</a> | <a href="/Content/SubtitleEdit/Help/RU">Ruso</a></div> -<h2>Mini FAQ</h2> -P: Cuando intento un abrir un video en x formato, SE no puede abrir el video o no hay sonido. ¿Qué puedo hacer?<br /> -R: Si usas Direct Show como reproductor de video asegúrate de tener <a href="#codecs">los códecs correctos</a>. Recomiendo desinstalar códecs como k-lite e instalar <a href="https://github.com/Nevcairiel/LAVFilters/releases">LAV filters</a> de 32-bit (+64-bit si lo deseas) en su lugar. Otra opción es usar el reproductor de video de VLC en su lugar.<br /> -<br /> -P: ¿Dónde está la herramienta para sincronizar los subtítulos?<br /> -R: Usa <b>Ajustar todos los tiempos (mostrar antes/después)...</b> en el menú <b>Sincronización</b>. El atajo es <b>Ctrl+Shift+A</b>. Es una ventana de herramientas, para que pueda mantenerse abierta mientras se trabaja - o controle una vista previa de los subtítulos en el reproductor de video.<br /> -<br /> -P: ¿Puede Subtitle Edit cambiar la velocidad de fotogramas?<br /> -R: Bueno, puede. Ve a <b>Sincronización -> Cambiar tasa de cuadros...</b><br /> -<br /> -P: ¿Puede Subtitle Edit dividir/unir subtítulos?<br /> -R: Prueba con <b>Herramientas -> Dividir/Anexar/Unir subtítulos...</b><br /> -<br /> -P: ¿Puede Subtitle Edit modificar tiempos de compensación - pero no desde el principio?<br /> -R: Sí, se puede trabajar con una selección de líneas dentro del subtítulo. Selecciona las líneas en la lista que quieras trabajar(sugerencia: haz clic en la primera línea, luego shift+clic en la última) y a continuación, haga clic-derecho en la lista (menú contextual) - ahora puedes ajustar las líneas seleccionadas en "Sincronización visual líneas seleccionadas" o solo "Mostrar líneas seleccionadas antes/después".<br /> -<br /> -P: ¿Puede Subtitle Edit reproducir un video en pantalla completa?<br /> -R: Sí, presiona ALT+ENTER. Utiliza la barra espaciadora para reproducir/pausar y ALT+FLECHA ARRIBA/ABAJO para el subtítulo siguiente/anterior.<br /> -<br /> -P: Al traducir/editar subtítulos, ¿puede Subtitle Edit navegar rápidamente a la siguiente línea?<br /> -R: Sí, presiona ALT+FLECHA ARRIBA/ABAJO para el subtítulo anterior/siguiente - también el campo de texto se mantendrá enfocado.<br /> -<br /> -P: ¿Puede Subtitle Edit pegar los subtítulos en el archivo de video?<br /> -R: No, Subtitle Edit no puede hacer esto - pero uno o más de los más de 100 formatos de salida deberían servir. Utiliza ya sea <i>Archivo</i> -&gt; <i>Guardar como ...</i> para los formatos basados ​​en texto o <i>Archivo</i> -&gt; <i>Exportar ...</i> para formatos basados en binarios/imágenes.<br /> -Hay dos formas de agregar subtítulos en el archivo de video - pegados al video (no se puede deshabilitar, por lo que esta <i>podría</i> ser una mala idea) o dentro de un contenedor de video (sólo para algunos formatos como mp4, mkv)<br /> -Lee más acerca de <a href="AddSubtitlesToVideo">añadir subtítulos al video</a>. -<br /> -<br /> -<hr /> -<br /> -<h2>Índice de Ayuda</h2> -<div style="margin-left: 25px; line-height: 25px;"> - <a href="#main">Subtitle Edit ventana principal</a><br /> - <a href="#main_resize">Subtitle Edit ventana principal - ajustar/desacoplar</a><br /> - <a href="#main_edit_original">Subtitle Edit ventana principal - editar original</a><br /> - <a href="#video_modes">Modos de video/onda de audio</a><br /> - <a href="#waveform">Onda de audio</a><br /> - <a href="#export">Exportar</a><br /> - <a href="#sync">Sincronización</a><br /> - <a href="#visual_sync">Sincronización visual</a><br /> - <a href="#translation">Traducción (automática)</a><br /> - <a href="#fixcommonerrors">Corregir errores comunes</a><br /> - <a href="#spellcheck">Revisar ortografía</a><br /> - <a href="#importvobsub">Importar subtítulos OCR basados ​​en imágenes - como DVD Sub/idx o Blu-ray sup</a><br /> - <a href="#shortcuts">Atajos</a><br /> - <a href="#translate">Traduciendo Subtitle Edit a otro idioma</a><br /> - <a href="#networking">Redes - colaboración en línea</a><br /> - <a href="#codecs">Reproductor de video y códecs</a><br /> - <a href="#commandline">Conversión por línea de comandos</a><br /> - <a href="#portable">Versión portable y VLC</a><br /> - <a href="#plugins">Haz tu propio plugin</a><br /> - <a href="#compile">Compilar Subtitle Edit</a><br /> - <a href="#issues">Problemas conocidos</a><br /> -</div> -<br /> -<hr /> -<br /> -<h2><a id="main">Subtitle Edit ventana principal</a></h2> - -<br /> -<h3>Menú de la ventana principal</h3> -En el menú se pueden encontrar muchas herramientas como cambiar mayúsculas, dividir líneas largas, dividir/anexar subtítulo, corrector ortográfico, sincronización visual/puntual/desde otro subtítulo, cambio de la tasa de cuadros (FPS), traductor Google, buscar, reemplazar, quitar el texto para sordos (Closed Caption "CC"), ¡y mucho más!<br /> -Puedes importar subtítulos desde un DVD, vobsub, Blu-ray sup - incluso se pueden importar vobsub dentro de archivos Matroska.<br /> -<br /> -<img src="/Content/SubtitleEdit/main_menu.png" alt="Menu" /><br /> -<br /> -<small>NOTA: Muchas otras herramientas están también disponibles haciendo clic derecho en la lista de los subtítulos.</small> -<br /> -<br /> -<br /> - -<br /> -<h3><a id="formats">Subtítulo/formatos de archivo</a></h3> -<table> - <tr> - <td> - <img src="/Content/SubtitleEdit/FormatAndEncoding.png" alt="Subtitle format" /> - <br /> - <br /> - En el menú superior puedes elegir el formato y la codificación. La primera lista desplegable muestra formatos de subtítulos. SubRip (su extensión es ".srt") es - el formato más utilizado hoy en día, por lo que se recomienda guardar los subtítulos en este formato.<br /> - Originalmente SubRip era un formato de sólo texto, pero en los últimos años se empezaron a utilizar las etiquetas html. Especialmente las - etiquetas de cursiva y de fuentes son ampliamente utilizadas. Para obtener una lista de los reproductores que soportan SubRip <a href="http://ale5000.altervista.org/subtitles.htm">mira esto</a> .<br /> - <br /> - La codificación del archivo es detectada automáticamente en la mayoría de los casos. ANSI es un formato antiguo, que se utiliza mucho hoy en día, pero requiere que tu - sistema tenga una configuración de referencia cultural específica. Se recomienda UTF-8 para nuevos subtítulos, ya que puede manejar caracteres distintos al Inglés - mejor que ANSI (los subtítulos UTF-8 funcionarán en todos los equipos sin importar que configuración cultural tengan en la computadora) y puede mostrar otros - símbolos como notas de música. El único inconveniente con la utilización de UTF-8 es, que algunos programas antiguos no son compatibles con este formato y WinXP sólo tiene unas pocas fuentes semi-unicode (Lucida Sans Unicode, Time New Roman, Courier New).<br /> - Si tienes un archivo ANSI en otro idioma que no sea tu actual cultura/lengua (o tienes un archivo inválido UTF/Unicode), entonces puedes utilizar el menú - : <i>Archivo</i> -> <i>Importar subtítulos seleccionando codificador manualmente...</i><br /> - <br /> - <i>Importar subtítulos seleccionando codificador manualmente...</i> con vista previa:<br /> - <img src="/Content/SubtitleEdit/ChooseEncoding.gif" alt="ChooseEncoding" /> - </td> - </tr> -</table> -<br /> -<br /> - -<h3>Tasa de cuadros (FPS)</h3> -<table> - <tr> - <td> - <img src="/Content/SubtitleEdit/help_framerate.png" alt="Frame rate" /><br /> - <br /> - La velocidad de cuadros ya no se muestra por defecto, pero se puede activar a través del menú <i>Opciones</i> -> <i>Ajustes: Barra de herramientas: Mostrar tasa de cuadros en la barra de herramientas.</i><br /> - La tasa de cuadros se utiliza al convertir entre formatos de subtítulos basados ​​en cuadros y formatos basados ​​en tiempo. - SubRip se basa en el tiempo. MicroDVD (utilizados ampliamente hace 7-9 años) se basan en cuadros.<br /> - Los subtítulos basados ​​en el tiempo se usan siempre que los videos tengan una frecuencia de cuadros constante - en caso contrario - se utilizan los subtítulos basados ​​en cuadros, nada flexibles en absoluto.<br /> - Para cambiar la tasa de cuadros usa <i>Sincronización</i> -> <i>Cambiar tasa de cuadros</i> - o utiliza una de las otras <a href="#sync">herramientas de sincronización</a>. - </td> - </tr> -</table> -<br /> -<br /> - -<h3>Vistas del Subtítulo - vista de lista o vista original</h3> -<p>Hay dos formas de ver un subtítulo - vista de lista o vista original.</p> -<table> - <tr> - <td> - <img src="/Content/SubtitleEdit/help_sourceview.png" alt="Source view" /> - </td> - <td> - Así es como el archivo de subtítulo se ve en realidad - diferente para todos los formatos.<br /> - Puedes editar textos y códigos de tiempo aquí, pero ten cuidado - también es fácil echarlo a perder. - <br /> - Puedes hacer que Subtitle Edit comience con la vista original dentro de Ajustes. - </td> - </tr> -</table> -<br /> -<table> - <tr> - <td colspan="2"> - <a id="listview"><img src="/Content/SubtitleEdit/help_listview.png" alt="List view" /></a> - </td> - </tr> - <tr> - <td> - La vista de lista ofrece un excelente panorama de los subtítulos - lo mismo para todos los formatos.<br /> - Puedes editar textos y códigos de tiempo aquí, borrar e insertar líneas con facilidad.<br /> - <br /> - </td> - </tr> - <tr> - <td colspan="2"> - <br /> - También es posible seleccionar varias líneas y usar herramientas como <i>Traducir con Google</i> o - <i>Sincronización visual</i> en las líneas seleccionadas.<br /> - <br /> - <a id="listview2"><img src="/Content/SubtitleEdit/help_listview2.png" alt="Listview" /></a> - </td> - </tr> - <td colspan="2"> - <br /> - <br /> - <h3>Campo de texto</h3> - <p> - Por encima del campo de texto donde escribes el subtítulo actual hay una etiqueta llamada "Caracteres/segundo". - Si es mayor a 25 será de color naranja/rojo.<br /> - <br /> - </p> - <img src="/Content/SubtitleEdit/TextBox.png" alt="search" /><br /> - <br /> - Por debajo del campo de texto hay una etiqueta llamada "Longitud línea individual". La primera línea es de 33 caracteres y segunda línea es de 75 caracteres. - Los colores referentes a la comparación de la duración de la línea actual se pueden modificar en Opciones -> Ajustes: General: longitud máxima línea simple - (43 por defecto). Rojo significa demasiado largo, naranja significa que está cerca de máximo. - <br /> - <br /> - </td> - <tr></tr> - <tr> - <td colspan="2"> - <br /> - <br /> - <h3>Mostrar video y/o onda de audio/espectrograma</h3> - <br /> - <a id="main_resize">La ventana principal puede mostrar video y/o la onda de audio.</a> Los controles de video pueden incluso desacoplarse - ¡excelente si tienes dos monitores!<br /> - Las líneas rojas horizontales/verticales muestra donde se puede cambiar el tamaño dentro de la ventana principal (a través de divisores).<br /> - <br /> - <img src="/Content/SubtitleEdit/main_video1.png" alt="Main window - with video/waveform" /> - </td> - </tr> - <tr> - <td colspan="2"> - <br /> - <br /> - <a id="main_edit_original">Ahora es posible editar tanto la traducción como los subtítulos originales al mismo tiempo.</a> Por defecto, el original es de sólo lectura, pero puedes cambiar esto en Opciones -&gt; Ajustes: General: Permitir la edición del subtítulo original.<br /> - Atajos: <b>Ctrl+U</b> alternará con el subtítulo original. <b>Ctrl+Shift+U</b> cambia al subtítulo traducido/original.<br /> - Al editar los subtítulos originales y traducidos, ¡cambiar el inicio de tiempo/duración/eliminación/inserción afectará a ambos subtítulos!<br /> - <br /> - <img src="/Content/SubtitleEdit/main_edit_original.jpg" alt="Main window - with video/waveform" /> - </td> - </tr> -</table> - -<br /> -<br /> -<h3>Buscar</h3> -<p>Puede buscar pulsando Ctrl+F (F3 para buscar el siguiente). La búsqueda de expresión regular está disponible para nerds ;)</p> -<img src="/Content/SubtitleEdit/help_search.png" alt="search" /><br /> -<br /> -<hr /> -<br /> - -<br /> -<br /> -<h3><a id="multiple_replace">Reemplazado Múltiple</a></h3> -<p>En <i>Editar -> Reemplazado Múltiple...</i> puede crear tus propias reglas para la reparación de un subtítulo - ¡incluso reglas avanzadas usando <a href="https://es.wikipedia.org/wiki/Expresión_regular">expresiones regulares</a>!</p> -<p> - Al escribir expresiones regulares y referencias inversas son de mucha utilidad. Las partes dentro de paréntesis son grupos y pueden ser referenciados en la cadena de reemplazo donde $1 hace referencia al primer grupo y $2 al segundo y así continuamente.<br /> - <div style="padding-left:15px"> - Ejemplo 1: <b>^J( .+)</b> + cadena de reemplazo <b>♪ $1</b> - solo el inicio con "J" será reemplazado, entonces si el texto es "J Letra de la música J" se convertirá en "♪ Letra de la música J"<br /> - Ejemplo 2: <b>([a-zá-úñü]+)([0-9]+)</b> + cadena de reemplazo <b>$2$1</b> - dos grupos que serán intercambiados, entonces si el texto es "número26" se convertirá en "26número".<br /> - </div> -</p> -<img src="/Content/SubtitleEdit/main_edit_multiple_replace.png" alt="Multiple replace" /><br /> -<br /> -<hr /> -<br /> - -<h2><a id="video_modes">Modos de video/onda de audio</a></h2> -<br /> -Al utilizar video y/o onda de audio tres modos diferentes (pestañas) están disponibles: Traducir, Crear y Ajustar. - -<h3>Modo traductor</h3> -<img src="/Content/SubtitleEdit/mode_translate.png" alt="Translate mode" /><br /> -<br /> -En el modo traductor puedes traducir los subtítulos de un idioma a otro de forma manual (o corregir el subtítulo -traducido por una máquina) mientras se ve el video - y se escucha el audio.<br /> -Si "Repetir automáticamente" está activado, entonces el subtítulo se repetirá determinado número de veces mientras escribes el texto correcto.<br /> -Usa <i>Archivo</i> -> <i>Abrir subtítulo original (modo traductor)</i> para ver también el texto original.<br /> -Sugerencia: utiliza &lt;alt+flecha arriba/abajo&gt; para ir al subtítulo anterior/siguiente.<br /> -<br /> -<br /> - -<h3>Modo crear</h3> -<img src="/Content/SubtitleEdit/mode_create.png" alt="Create/adjust lines" /><br /> -<br /> -Este es el lugar para crear líneas de subtítulos desde cero o ajustar manualmente las líneas existentes.<br /> -<br /> -Para crear líneas de subtítulos desde cero, pausa el archivo de video donde la línea del subtítulo debe comenzar y pulsa el botón -"Inser. subt. en pocisión del video". A continuación, escribe el texto - la duración se ajusta automáticamente. Ahora presiona el botón "Repro. poco antes del texto" y si el texto no se inicia exactamente cuando el diálogo se inicia, entonces, corrige "Ajustar tiempo inicial" a través de las flechas arriba/abajo hasta que se ajusten. La duración se puede ajustar a través del botón "Ajustar tiempo final" mientras se reproduce el video o a través de las "Flechas de duración arriba/abajo".<br /> -Para insertar un subtítulo justo después de la línea actual, pulsa el botón Insertar (mientras que la lista está enfocada).<br /> -<br /> -También puedes hacer clic en la onda de audio o en la lista para insertar/dividir/combinar/eliminar las líneas.<br /> -<br /> -<br /> - -<h3>Modo ajustar</h3> -<img src="/Content/SubtitleEdit/mode_adjust.png" alt="Adjust mode" /><br /> -<br /> -Este es el lugar para ajustar las líneas existentes.<br /> -<br /> -Para ajustar las líneas de subtítulos manualmente uno por uno, comenzando desde la parte superior. Utiliza el botón "Ajustar inicio y compensar el resto" (F9) y "Ajustar tiempo final / siguiente" (F10). -Para hacerlo de forma más exacta, el "Tiempo inicial" y la "Duración" lo puedes ajustar mediante el uso de la flechas arriba/abajo.<br /> -<br /> -También puedes hacer clic en la onda de audio o en la lista para insertar/dividir/combinar/eliminar las líneas.<br /> -<br /> -<hr /> -<br /> - -<h2><a id="waveform">Forma de onda</a></h2> -El control de la forma de onda hace que sea fácil ver exactamente dónde comienza/termina el habla.<br /> -<img src="/Content/SubtitleEdit/Waveform1.png" alt="Wave form" /><br /> -<br /> -<br /> -Con el menú del botón derecho, puedes dividir/combinar/eliminar subtítulos.<br /> -<img src="/Content/SubtitleEdit/Waveform2.png" alt="Wave form - right click menu" /><br /> -<br /> -<br /> -Para crear un nuevo párrafo, sólo tienes que seleccionar un área vacía y hacer clic derecho "Añadir texto aquí".<br /> -<img src="/Content/SubtitleEdit/Waveform3.png" alt="Wave form - new selection" /><br /> -<br /> - -<h3>Forma de onda, uso del ratón/teclado:</h3> -<ul> - <li>Clic sencillo del ratón: Ir a la posición</li> - <li>Doble clic del ratón sobre el subtítulo existente: Seleccionar subtítulo clicado</li> - <li>Área marcada+clic derecho del ratón sobre el área marcada: Pregunta por Añadir texto aquí/Reproducir selección</li> - <li>Arrastrar con el ratón hacia la izquierda/derecha los bordes del subtítulo (ajusta el tiempo de inicio o fin)</li> - <li>Mover/arrastrar en medio del subtítulo (ajusta tanto el tiempo de inicio y final - pero no la duración)</li> - <li>Con el clic derecho del ratón se puede agregar un nuevo subtítulo o realizar una acción como borrar/dividir/combinar en la línea del subtítulo existente</li> - <li>Con la rueda del ratón puedes desplazarte por la onda de audio hacia adelante/atrás</li> - <li>Alt+flecha izquierda/derecha mueve la posición del video</li> - <li>Alt+flecha arriba/abajo va hacia el anterior/siguiente subtítulo</li> - <li>Los símbolos numéricos +/- hacen zum de acercamiento/alejamiento</li> - <li>Clic sencillo del ratón+Shift fijará el comienzo de la línea seleccionada (sin moverse el tiempo de finalización)</li> - <li>Clic sencillo del ratón+Ctrl fijará el final de la línea seleccionada (no se mueve el tiempo de inicio)</li> - <li>Clic sencillo del ratón+Alt fijará el comienzo de la línea seleccionada (y mantendrá la duración)</li> - <li>Doble clic del ratón en donde no hay un párrafo - intercambia la reproducción</li> - <li><b>Clic sencillo del ratón+Ctrl+Shift fijará el comienzo de la línea seleccionada y compensará todas las líneas siguientes (manteniendo sus duraciones)</b></li> - <li>Manteniendo presionada la tecla ALT al mover el inicio/final se moverá el inicio/final del subtítulo más cercano también si está más cercano a los 500 milisegundos - <a href="/Content/SubtitleEdit/WaveformMoveNextPrev.gif">como aquí.</a></li> -</ul> - -<br /> -<h3>Extracción de la forma de audio</h3> -La extracción de los datos de la forma de onda se realiza por medio de <a href="http://www.videolan.org/">VLC Media Player 2.x (o 1.1.x /)</a> y genera un archivo de onda muy pequeño (con una frecuencia de muestreo MUY baja) -y se guarda en la carpeta "WaveForms" del programa. Si por alguna razón VLC falla al extraer un archivo de sonido en el video, puedes extraer el archivo de onda con otra herramienta y soltar -ese archivo de onda en el control de forma de onda, lo que generará un archivo de onda pequeña (con una frecuencia de muestreo MUY baja) en la carpeta "WaveForms".<br /> -<br /> -Nota: No se puede utilizar una forma de onda sin el video (si sólo tienes un archivo wav y no el video, es posible cargar el archivo de audio como un archivo de video arrastrando el archivo de audio en el control de forma de onda). -<br /> -<hr /> -<br /> - - -<br /> -<h2><a id="export">Exportar</a></h2> -Subtitle Edit puede guardar a través de "Guardar como..." en muchos diferentes formatos de texto, pero si deseas guardar un subtítulo en un formato binario (como pac o 890) o un formato basado en imágenes (como png o bluray sup) debes utilizar Archivo -> Exportar.<br /> -Muchos estilos como cursivas y colores dentro de los subtítulos se mantendrán al exportar a formatos basados en imágenes.<br /> -<br /> -<hr /> -<br /> - - -<h2><a id="sync">Sincronización</a></h2> -<table> - <tr> - <td> - <img src="/Content/SubtitleEdit/SyncMenu.png" alt="Sync menu" /> - </td> - </tr> - <tr> - <td> - <br /> - Subtitle Edit ofrece varias opciones para sincronizar los subtítulos.<br /> - <p>Ajustar todos los tiempos (mostrar antes/después): Esto es útil si por ejemplo necesitas mostrar todos los textos 3 segundos antes.</p> - <p><a href="#visual_sync">Sincronización visual</a>: Sincroniza haciendo coincidir el inicio/final de una escena (más abajo).</p> - <p> - Sincronización puntual: Permite la sincronización mediante el uso de 2 o más puntos - los códigos de los tiempo de sincronización puntual - pueden ser introducidos manualmente, lo que hace que sea fácil de usar códigos de tiempo a partir de otro subtítulo ya en sincronía. - </p> - <p> - Sincronización puntual desde de otro subtítulo: Si tiene otro subtítulo sincronizado (tal vez en otro idioma - ayuda si se puede entender un poco) puedes coincidir con una de - las primeras líneas, coincidir con una de las últimas líneas, sincroniza y luego todas las líneas deben estar en sincronía. - </p> - <p>Cambiar la tasa de cuadros: Esto facilita que coincida el texto de un video con una velocidad de fotogramas distinta de otro (también se puede hacer por la sincronización visual o sincronización puntual).</p> - </td> - </tr> -</table> -<br /> -<br /> -<br /> - - -<h2><a id="visual_sync">Sincronización visual</a></h2> -<table> - <tr> - <td colspan="2"> - <img src="/Content/SubtitleEdit/vissync.gif" alt="Visual Sync controls" /> - </td> - </tr> - <tr> - <td> - <img src="/Content/SubtitleEdit/help_vs2.png" alt="Synchronize button" /> - </td> - <td> - <br /> - La sincronización visual es una manera muy fácil de sincronizar los subtítulos con un archivo de video.<br /> - Haz coincidir una de las primeras líneas del subtítulo con el comienzo de la escena. A continuación, haz coincidir una - de las últimas líneas del subtítulo con la escena final. Presiona el botón "Sincronización" - y eso es todo :)<br /> - Hay unos pocos botones de ayuda que te servirán para encontrar el lugar adecuado en el video donde el - subtítulo debe comenzar (justo donde aparece la primera palabra). El botón "Reproducir 2" es un botón de prueba, - para que fácilmente puedas ver si la posición actual es realmente la correcta. También puedes ver los <a href="shortcuts">Atajos</a> .<br /> - <br /> - En algunos casos, un subtítulo es imposible de sincronizar porque una o más escenas se han eliminado/añadido. - En estos casos se puede seleccionar un número de subtítulos en el subtítulo <a href="#listview"></a>Vista de lista/0}, haz - clic derecho con el ratón y selecciona <i>Sincro visual líneas seleccionadas...</i> De esta manera puedes ajustar el subtítulo en partes más pequeñas. - </td> - </tr> -</table><br /> -<br /> -<hr /> -<br /> -<h2><a id="translation">Traducción (automática)</a></h2> -Subtitle Edit puede traducir un subtítulo mediante el uso del <a href="http://www.google.com/translate">Traductor de Google</a> -o <a href="../mt">Multi Translator</a> (sólo del sueco al danés).<br /> -¡Google puede traducir entre un montón de idiomas! Funciona bastante bien, pero los subtítulos traducidos aún necesitan -corrección manual (sugerencia: utilizar ventana principal en <a href="#video_modes">modo traductor</a>). -<br /> -<br /> -<img src="/Content/SubtitleEdit/help_googletranslate.png" alt="Create/add lines" /><br /> -<br /> -<hr /> -<br /> -<h2><a id="fixcommonerrors">Corregir errores comunes</a></h2> -<br /> -<img src="/Content/SubtitleEdit/help_fixcommonerrors1.png" alt="Fix common errors" /><br /> -<br /> -Algunos subtítulos tienen una gran cantidad de errores (a menudo estos subtítulos se crean utilizando software OCR).<br /> -"Herramientas -> Fijar errores comunes" proporciona una manera fácil de solucionar muchos de estos errores.<br /> -La primera ventana muestra una lista de acciones para corregir, sólo debes marcar las casillas de verificación que desees reparar y pulsa "Siguiente".<br /> -<br /> -<br /> -<img src="/Content/SubtitleEdit/help_fixcommonerrors2.png" alt="Fix common errors" /><br /> -<br /> -Ahora puedes elegir que correcciones quieres aplicar. Por defecto todos las correcciones están seleccionadas, por lo que debes desmarcar las casillas de verificación de las correcciones -que no deseas aplicar.<br /> -La pestaña de registro ofrece una visión general de lo que se ha hecho - y de lo que no se ha podido corregir.<br /> -El botón "Aplicar correcciones" hace las reparaciones.<br /> -<br /> -<hr /> -<br /> -<b><a id="spellcheck">Revisar ortografía</a></b> -<br /> -<br /> -El corrector ortográfico utiliza <a href="http://hunspell.sourceforge.net/">Hunspell</a> (que también es utilizado por Open/LibraOffice, Firefox, Chrome y Opera).<br /> -Sólo el diccionario Inglés está incluido, pero se pueden encontrar más diccionarios a través del menú de la barra de herramientas <i>Ortografía</i> -> <i>Conseguir diccionarios...</i><br /> -Si descargas <a href="http://extensions.services.openoffice.org/en/dictionaries">los diccionarios Open Office 3.x</a> con la extensión .oxt, cambia la extensión a .zip, luego descomprime -el archivo .dic y el archivo .aff a la carpeta <i>Dictionaries</i> del programa Subtitle Edit.<br /> -<br /> -El corrector ortográfico mostrará esta ventana cuando encuentre una palabra desconocida:<br /> -<img src="http://www.nikse.dk/Content/SubtitleEdit/spell_check.png" alt="corrector ortográfico" /><br /> -<b><i>Editar texto completo</i></b> permitirá editar todo el texto (y no sólo la palabra actual) - para éste subtítulo únicamente.<br /> -<b><i>Cambiar todo / Utilizar siempre</i></b> va a cambiar la palabra actual siempre - también en trabajos futuros (guardado en la lista OCR de reemplazo - echarle un vistazo en la carpeta Dictionaries/spa_OCRFixReplaceList.xml para aprender más acerca de este archivo).<br /> -<b><i>Cambiar / Utilizar</i></b> va a cambiar la palabra sólo por esa vez.<br /> -<b><i>Añadir a list.nombres (sensible mayúsculas)</i></b> recordará el nombre en el campo de texto con el caso actual - también para futuros trabajos.<br /> -<b><i>Añadir al diccionario del usuario</i></b> recordará la palabra en el campo de texto y no pedirá cambiarla más - también para futuros trabajos. El diccionario del usuario no distingue entre mayúsculas y minúsculas.<br /> -<br /> -Todos los botones del grupo "Palabra no encontrada" usan la palabra en el campo de texto "Palabra no encontrada".<br /> -<br /> -<hr /> -<br /> -<h2><a id="importvobsub">Importar subtítulos OCR basados ​​en imágenes - como DVD Sub/idx o Blu-ray sup</a></h2> -<br /> -<br /> -Si abres un subtítulo basado en imágenes como Blu-ray sup o sub/idx (vobsub), esta pantalla aparecerá:<br /> -<br /> -<img src="/Content/SubtitleEdit/help_importvobsub.png" alt="Import/ocr image based subtitles" /><br /> -<br /> -<br /> -La lista que se muestra contiene sólamente subtítulos con líneas vacías de texto mostrando sólo los tiempos. Puedes introducir el texto de forma manual, pero existen dos (o tres si tienes instalado MODI) opciones mejores: -<ul> - <li> - OCR vía Tesseract 3 (recomendado): <a href="http://code.google.com/p/tesseract-ocr/">Tesseract</a> es un motor OCR de código abierto. <br /> - Puedes encontrar archivos de datos adicionales para otros idiomas en el proyecto <a href="http://code.google.com/p/tesseract-ocr/downloads/list">Tesseract Google code project</a>. Estos diccionarios para Tesseract - deben descomprimirse en [la carpeta de Subtitle Edit]\Tesseract\tessdata.<br /> - <br /> - Si haces clic derecho en la lista, aparecerá un menú contextual con las siguientes opciones:<br /> - <img src="/Content/SubtitleEdit/ocr_context_menu.png" alt="Menú contextual lista OCR" /><br /> - <b><i>Importar texto con código de tiempo coincidente...</i></b> se puede utilizar para seguir trabajando con un subtítulo antes creado.<br /> - <b><i>Guardar imagen de subtítulo como...</i></b> permite guardar la imagen actual ya sea como pgn, gif, bmp o tiff.<br /> - <b><i>Guardar todas las imágenes con el índice HTML...</i></b> muestra todas las imágenes del subtítulo en una página HTML - para una lectura fácil.<br /> - <br /> - - OCR via Tesseract will work best if you also havOCR vía Tesseract funcionará mejor si también tienes los <a href="#spellcheck">diccionarios ortográficos</a>.<br /> - <img src="/Content/SubtitleEdit/ocr_dictionary.png" alt="Diccionario OCR" /><br /> - <b><i>Solicitará palabras desconocidas</i></b> y <b><i>tratará de adivinar esas palabras</i></b>, sólo funcionará si está disponible un diccionario. <i><b>Corregir los errores de OCR</b></i> también se beneficiarán - de un diccionario.<br /> - <br /> - La <b><i>solicitud de palabras desconocidas</i></b> se verá como esto (la ventana puede redimensionarse):<br /> - <img src="/Content/SubtitleEdit/ocr_spell_check.png" alt="Corrector ortográfico OCR" /><br /> - <b><i>Editar texto completo</i></b> permitirá editar todo el texto (y no sólo la palabra actual) - para éste subtítulo únicamente.<br /> - <b><i>Cambiar todo / Utilizar siempre</i></b> va a cambiar la palabra actual siempre - también en trabajos futuros (guardado en la lista OCR de reemplazo - puedes echarle un vistazo en Dictionaries/spa_OCRFixReplaceList.xml para aprender más acerca de este archivo).<br /> - <b><i>Cambiar / Utilizar</i></b> la palabra actual se va a cambiar sólo por esta vez.<br /> - <b><i>Añadir a list.nombres (sensible mayúsculas)</i></b> recordará este nombre con la palabra actual - también para futuros trabajos.<br /> - <b><i>Añadir al diccionario del usuario</i></b> recordará esta palabra y no preguntará más por ella - también para futuros trabajos.<br /> - <br /> - <br /> - </li> - <li> - OCR a través de comparar imágenes: Esta opción no requiere ningún software de terceros instalado, pero sí requiere que el usuario manualmente - introduzca las letras basadas en partes de las imágenes.<br /> - "Ninguno de los pixeles es espacio" debe disminuirse si no todas las palabras traducidas están separadas (como "<i>"wearefine</i>"), Y aumentarse - si hay demasiadas separaciones (como "<i>w e ar e fi n e</i>").<br /> - Nota: ¡Esto no funciona bien con archivos Blu-ray sup!<br /> - <br /> - </li> - <li> - OCR vía MODI: MODI es la abreviatura de <a href="http://en.wikipedia.org/wiki/Microsoft_Office_Document_Imaging">Microsoft Office Document Imaging</a> . Se incluye con las herramientas de Microsoft Office (en la carpeta del menú de inicio "Microsoft Office\Microsoft Office Tools").<br /> - Esto funciona muy parecido a Tesseract, pero requiere de MS Office.<br /> - Si tienes Microsoft Office instalado, pero el OCR de MODI no está disponible trata de ejecutar la instalación de MS Office de nuevo y asegúrate de que MODI está seleccionado en el programa de instalación. - <br /> - </li> -</ul> -Selecciona uno de los métodos de OCR y haz clic en el botón "Empezar OCR".<br /> -Cuando hayas terminado haz clic en "Aceptar" y recuerda que el subtítulo que acabas de crear por este medio probablemente contenga algunos errores que haya que corregir.<br /> -Si un subtítulo VobSub contiene más de un idioma, se te pedirá escoger el lenguaje.<br /> -<br /> -<hr /> -<br /> -<br /> -<h2><a id="shortcuts">Atajos</a></h2> -<br /> -<table class="table table-striped" id="tableShortcuts"> - <thead> - <tr> - <th>Ventana</th> - <th>Control</th> - <th>Atajos</th> - <th>Función</th> - </tr> - </thead> - <tbody> - <tr> - <td>Principal</td> - <td>*</td> - <td>F1</td> - <td>Mostrar esta ayuda ;)</td> - </tr> - <tr> - <td>Principal</td> - <td>*</td> - <td>Ctrl+F</td> - <td>Abre el cuadro de diálogo Buscar</td> - </tr> - <tr> - <td>Principal</td> - <td>*</td> - <td>F3</td> - <td>Buscar siguiente</td> - </tr> - <tr> - <td>Principal</td> - <td>*</td> - <td>Ctrl+Z</td> - <td>Mostrar historial/deshacer</td> - </tr> - <tr> - <td>Principal</td> - <td>*</td> - <td>Ctrl+G</td> - <td>Ir al diálogo "Ir al subtítulo número (x - xxx)"</td> - </tr> - <tr> - <td>Principal</td> - <td>*</td> - <td>Ctrl+L</td> - <td>Localiza (desliza hacia) la primera línea del subtítulo seleccionado en la lista de subtítulos</td> - </tr> - <tr> - <td>Principal</td> - <td>*</td> - <td>Alt+Flecha arriba</td> - <td>Va un línea hacia arriba en la lista de subtítulos</td> - </tr> - <tr> - <td>Principal</td> - <td>*</td> - <td>Alt+Flecha abajo</td> - <td>Va un línea hacia abajo en la lista de subtítulos</td> - </tr> - <tr> - <td>Principal</td> - <td>*</td> - <td>Ctrl+U</td> - <td>Modo traductor activado/desactivado</td> - </tr> - <tr> - <td>Principal</td> - <td>*</td> - <td>Ctrl+Shift+U</td> - <td>Cambia el subtítulo actual con el subtítulo original</td> - </tr> - <tr> - <td>Principal</td> - <td>*</td> - <td>Shift+Insert</td> - <td>Inserta una línea antes de la primera línea seleccionada</td> - </tr> - <tr> - <td>Principal</td> - <td>*</td> - <td>Alt+Insert</td> - <td>Inserta una línea después de la primera línea seleccionada</td> - </tr> - <tr> - <td>Principal</td> - <td>Campo de texto del subtítulo</td> - <td>Ctrl+I</td> - <td>Hace cursiva la selección</td> - </tr> - <tr> - <td>-</td> - <td>-</td> - <td>-</td> - <td>-</td> - </tr> - <tr> - <td>Principal</td> - <td>Lista del subtítulo</td> - <td>Ctrl+A</td> - <td>Selecciona todas las líneas</td> - </tr> - <tr> - <td>Principal</td> - <td>Lista del subtítulo</td> - <td>Ctrl+D</td> - <td>Selecciona sólo la primera línea seleccionada</td> - </tr> - <tr> - <td>Principal</td> - <td>Lista del subtítulo</td> - <td>Ctrl+Shift+I</td> - <td>Invierte la selección</td> - </tr> - <tr> - <td>Principal</td> - <td>Lista del subtítulo</td> - <td>Suprimir</td> - <td>Elimina las líneas seleccionadas</td> - </tr> - <tr> - <td>Principal</td> - <td>Lista del subtítulo</td> - <td>Insert</td> - <td>Inserta una línea después de la primera línea seleccionada</td> - </tr> - <tr> - <td>Principal</td> - <td>*</td> - <td>Ctrl+Shift+M (o Ctrl+K)</td> - <td>Combina las líneas seleccionadas</td> - </tr> - <tr> - <td>-</td> - <td>-</td> - <td>-</td> - <td>-</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>Alt+Flecha izquierda</td> - <td>Regresa 0,5 segundos en el video</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>Alt+Flecha derecha</td> - <td>Adelanta 0,5 segundos en el video</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>Ctrl+Flecha izquierda</td> - <td>Regresa 0,1 segundos en el video</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>Ctrl+Flecha derecha</td> - <td>Adelanta 0,1 segundos en el video</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>Ctrl+Alt+P</td> - <td>Pausa el video</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>Ctrl+P</td> - <td>Alterna entre reproducir/pausar video</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>F4</td> - <td>Alternar entre la posición final/principio del párrafo actual</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>F5</td> - <td>Reproduce el párrafo actual y se detiene inmediatamente después</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>F6</td> - <td>Va al inicio del párrafo actual</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>F7</td> - <td>Regresa 3 segundos</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>· F8.</td> - <td>Arterna entre reprodur/pausar</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>F9-F12</td> - <td>Depende del modo (traducir/crear/ajustar)</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>Alt +1</td> - <td>Va a la posición inicial del párrafo actual</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>Alt +2</td> - <td>Va a la posición final del párrafo actual</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>Alt+3</td> - <td>Va al párrafo anterior</td> - </tr> - <tr> - <td>Principal</td> - <td>reproductor de video/onda de audio</td> - <td>Alt +4</td> - <td>Va al párrafo siguiente</td> - </tr> - <tr> - <td>Principal</td> - <td>reprodutor de video/onda de audio - modo ajuste</td> - <td>Ctrl+Espacio</td> - <td>Establece el inicio y compensa al resto</td> - </tr> - <tr> - <td>Principal</td> - <td>reprodutor de video/onda de audio - modo ajuste</td> - <td>Shift+Espacio</td> - <td>Ajusta el final y va al siguiente</td> - </tr> - <tr> - <td>-</td> - <td>-</td> - <td>-</td> - <td>-</td> - </tr> - <tr> - <td>Reproductor de video desacoplado</td> - <td>-</td> - <td>Alt+A</td> - <td>Cambia el tamaño de la ventana de modo que el video tenga una relación de aspecto 1:1</td> - </tr> - <tr> - <td>Reproductor de video desacoplado</td> - <td>-</td> - <td>Alt+Enter</td> - <td>Alterna el tamaño de la ventana entre maximizado/normal</td> - </tr> - <tr> - <td>-</td> - <td>-</td> - <td>-</td> - <td>-</td> - </tr> - <tr> - <td>OCR mediante comparación de imágenes - imagen a texto de forma manual</td> - <td>-</td> - <td>Alt+Flecha derecha</td> - <td>Expande la selección</td> - </tr> - <tr> - <td>OCR mediante comparación de imágenes - imagen a texto de forma manual</td> - <td>-</td> - <td>Alt+Flecha izquierda</td> - <td>Compacta la selección</td> - </tr> - <tr> - <td>OCR mediante comparación de imágenes - imagen a texto de forma manual</td> - <td>-</td> - <td>Alt+I (depende de la traducción)</td> - <td>Activa las cursivas</td> - </tr> - <tr> - <td>OCR mediante comparación de imágenes - imagen a texto de forma manual</td> - <td>-</td> - <td>Alt+F (depende de la traducción)</td> - <td>Activa el envío automático (continúa automáticamente después de la primera letra presionada)</td> - </tr> - </tbody> -</table> -<br /> -<br /> -Note - many of the shortcuts are configurable via <i>Options -> Settings -> Shortcuts</i> (let me know if you need more):<br /> -<br /> -<img src="/Content/SubtitleEdit/shortcuts.png" alt="Configuración de atajos" /><br /> -<br /> -<br /> -<br /> -<hr /> -<br /> -<br /> - -<h2><a id="translate">Traduciendo Subtitle Edit a otro idioma</a></h2> -<br /> -Para traducir Subtitle Edit descarga primero <a href="/Content/SubtitleEdit/Language.xml">el archivo xml en inglés</a> y guárdalo en la carpeta -"Subtitle Edit\Languages". Traduce el contenido de todas las etiquetas con un editor xml o sólo con el bloc de notas. ¡También puedes utilizar -<a href="/XmlContentTranslator">Xml Content Translator</a>!<br /> -Guarda el archivo xml editado como 'CultureName'.xml ('CultureName' debe ser un <a href="http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo%28v=vs.80%29.aspx">nombre de referencia cultural existente</a> - y también una etiqueta en el archivo xml) en la carpeta SubtitleEdit\Languages. En Opciones -> Seleccionar idioma, -ahora puedes probar tu traducción al elegir tu idioma como lenguaje.<br /> -Por favor envíame las traducciones, para que yo pueda incluirlos en el Subtitle Edit - gracias :)<br /> -Sugerencia: <a href="http://winmerge.org">WinMerge </a> es una excelente herramienta para comparar archivos.<br /> -<br /> -El instalador puede localizarse mediante la traducción de <a href="http://subtitleedit.googlecode.com/svn/trunk/installer/Custom_Messages.iss">este archivo</a>. -<br /> -<br /> -<hr /> -<br /> - - -<h2><a id="networking">Redes - colaboración en línea</a></h2> -<br /> -Si tú y algunos amigos quieren traducir un subtítulo al mismo tiempo a través de Internet, pueden probar la característica "Red".<br /> -Primero carga los subtítulos que desean traducir (y opcionalmente el subtítulo original). Después, selecciona "Iniciar sesión" en el menú "Red":<br /> -<br /> -<img src="/Content/SubtitleEdit/NetworkingStart.png" alt="Start network session" /> -<br /> -<br /> -La "Clave de sesión" es el ID de tus subtítulos (puede ser cualquier texto que quieras) - otras personas necesitan esto para unirse (a través del menú Red -> Unirse a sesión) a la sesión.<br /> -El "Usuario" se mostrará en la pantalla al actualizar/insertar/eliminar las líneas y en la ventana del chat<br /> -La "URL" apunta a un pequeño programa en un servidor que aloja la sesión (Inicialmente lo desarrollé para usarlo directamente mediante p2p, pero decidí utilizar un servicio web -en su lugar, ya que funciona mucho mejor con cosas como cortafuegos "firewalls"). <a href="/Content/SubtitleEdit/SENetworkingService.zip">El código fuente de este servicio web está disponible</a> y es -fácil de usar para alojar una sesión en tu propio servidor de red.<br /> -<br /> -<br /> -Subtitle Edit funcionando en modo de red, como se muestra en la imagen. En la columna "Usuario/acción" de la lista de los subtítulos puedes seguir el progreso de traducción - ¡esto podría tener algún efecto sinérgico!<br /> -<br /> -<img src="/Content/SubtitleEdit/networking.jpg" alt="Subtitle Edit running in networking mode" /> -<br /> -<br /> -<hr /> -<br /> - - -<h2><a id="codecs">Reproductor de video y códecs</a></h2> -<br /> -Subtitle Edit puede usar el reproductor VLC dentro de Subtitle Edit en lugar de DirectShow - ir a <i>Opciones -> Ajustes -> Reproductor de Video.</i> Si la opción VLC está en gris, entonces probablemente -necesitas instalar VLC versión 2.x o 1.1.x.<br /> -Sin embargo, otra opción de video es usar <a href="http://www.mplayer2.org/">mplayer2</a> . Guarda "mplayer.exe" en la carpeta de Subtitle Edit y ve a <i>Opciones -> Ajustes -> Reproductor de video</i> y elige la opción "MPlayer".<br /> -Nota: VLC y MPlayer vienen con sus propios codecs, por lo que no es necesario instalar <a href="https://github.com/Nevcairiel/LAVFilters/releases">LAV Filters</a> o ffdshow/Hali Matroska Splitter.<br /> -<br /> -<img src="/Content/SubtitleEdit/OptionsVideoPlayer.png" alt="Elegir Reproductor de video" /> -<br /> -<br /> -A menudo, los problemas con el reproductor de video de DirectShow en el Subtitle Edit son causados ​​por codecs malos/conflictivos/desaparecidos/antiguos (¡Los paquetes de codecs son MALOS!).<br /> -El error podría aparecer como System.Runtime.InteropServices.InvalidComObjectException y podría mencionar algo como QuartzTypeLib/QuartzPlayer.<br /> -<br /> -Mi recomendación es desinstalar todos los paquetes de codecs (incl. K-lite), reiniciar y luego instalar <a href="https://github.com/Nevcairiel/LAVFilters/releases">LAV Filters - DirectShow Media Splitter and Decoders</a> <br /> -Tenga en cuenta que Subtitle Edit es una aplicación de 32-bit (a menos que específicamente hayas encontrado una versión de 64-bit) y por lo tanto requiere de codecs de 32-bit - incluso en win7 64-bit<br /> -<br /> -Si tienes problemas con un determinado formato/archivo intenta con <a href="http://mediaarea.net/MediaInfo">MediaInfo</a> / <a href="http://www.headbands.com/gspot/">GSpot</a>.<br /><br /> -<br /> -<hr /> - -<h2><a id="commandline">Subtitle Edit conversión mediante línea de comandos</a></h2> -<br /> -Subtitle Edit (3.3) puede realizar la conversión entre distintos formatos mediante línea de comandos.<br /> -<br /> -Sintaxis: SubtitleEdit /convert "pattern" "name-of-format-without-spaces" [/encoding:?] [/fps:?] [/outputfolder:?]:<br /> -<br /> - Ejemplo 1: <div style="font-family:Times New Roman;font-style:italic">SubtitleEdit /convert sub1.srt sami</div> Resultado: Convertirá sub1.srt a sub1.sub con formato SAMI<br /> -<br /> - Ejemplo 2: <div style="font-family:Times New Roman;font-style:italic">SubtitleEdit /convert *.srt adobeencore</div> Resultado: Convertirá todos los archivos .srt a formato Adobe Encore.<br /> -<br /> - Ejemplo 3 <div style="font-family:Times New Roman;font-style:italic">SubtitleEdit /convert *.srt adobeencore /encoding:windows-1252</div> Resultado: Igual que el anterior pero la codificación de archivos usará windows-1252 (véase la lista <a href="http://msdn.microsoft.com/en-us/library/system.text.encodinginfo.getencoding.aspx">Info.Name</a> para más codificaciones)<br /> -<br /> - Ejemplo 4 <div style="font-family:Times New Roman;font-style:italic">SubtitleEdit /convert a.sub subrip /fps:25</div> Resultado: Convierte a.sub en a.srt basado en tiempo a través de una tasa de 25 cuados<br /> -<br /> - Ejemplo 5 <div style="font-family:Times New Roman;font-style:italic">SubtitleEdit /convert a.sub subrip /outputfolder:C:\Temp</div> Resultado: Convierte a.sub a C:\Temp\a.srt<br /> -<br /> - Para una lista de formatos soportados: <div style="font-family:Times New Roman;font-style:italic">SubtitleEdit /convert /list</div> Resultado: ¡Muestra los más de 100 formatos soportados en la conversión mediante línea de comandos!<br /> -<br /> -<br /> -<hr /> - -<h2><a id="portable">Versión portable y VLC</a></h2> -<br /> -Para utilizar la versión portable de VLC, descarga VLC portable (al menos la versión 1.1.0, como <a href="http://get.videolan.org/vlc/2.1.3/win32/vlc-2.1.3-win32.zip">vlc 2.1.3</a>) y desempácala a una subcarpeta en la carpeta de Subtitle Edit llamándola "VLC". Otra opción es usar la carpeta donde se localiza &lt;Vlc&gt; en Settings.xml.<br /> -Nota: Nececitas la versión de VLC de 32-bit. -<br /> -<br /> -<hr /> - -<h2><a id="plugins">Haz tu propio plugin</a></h2> -<br /> -Si sabes programar en C# o VB.net puedes hacer tus propios plugins para el Subtitle Edit (SE 3.3 y posteriores).<br /> -<br /> -Puedes <a href="/Content/SubtitleEdit/PluginSource.zip">descargar dos plugins de demostración aquí</a>.<br /> -"Haxor" es un ejemplo muy básico.<br /> -"Fix Hyphens (Reparar Guiones)" es un ejemplo más completo de una forma y unas clases de ayuda básicas.<br /> -Por el momento es posible utilizar plugins aquí: Archivo, Herramientas, Sincronizar, Traducir y Ortografía.<br /> -<br /> -<br /> -<hr /> - -<h2><a id="compile">Compilar Subtitle Edit</a></h2> -<br /> -¡Compilar su propia versión de Subtitle Edit es pan comido!<br /> -<br /> -Si no tienes MS Visual Studio, sólo tienes que descargar e instalar <a href="http://www.microsoft.com/express/vcsharp/">MS Visual C# Express</a>. -Después, descarga el código fuente de Subtitle Edit y abre el archivo "SubtitleEdit.csproj". Pulsa F5 - y eso es todo :)<br /> -Ahora puedes cambiar/añadir características que desees o corregir mis errores - si hubiera alguno ;) -<br /> -<br /> -<hr /> - - -<h2><a id="issues">Problemas conocidos</a></h2> -<br /> -¡Subtitle Edit tiene algunos problemas conocidos!<br /> -<br /> -<table class="table table-striped" id="tableKnownIssues"> - <thead> - <tr> - <th>Problema</th> - <th>Solución</th> - </tr> - </thead> - <tbody> - <tr> - <td>Fallas durante la reproducción/carga/muestra del video con K-Lite instalado</td> - <td> - Desinstalar K-lite y luego instalar {0LAV Filters - DirectShow Media Splitter and Decoders<br /> - <small>Tenga en cuenta que Subtitle Edit es una aplicación de 32-bit (a menos que hayas encontrado específicamente una versión de 64-bit) y por lo tanto requiere de codecs de 32-bit - incluso en win7 64-bit</small> - <br /><br />¡Otra opción es cambiar el reproductor de video VLC en Subtitle Edit mediante Opciones-> Ajustes: Reproductor de Video! - </td> - </tr> - <tr> - <td>Problemas con los caracteres Unicode (WinXp)</td> - <td> - Usar la fuente Lucida Sans Unicode/Times New Roman - o actualizar tu XP a Windows 7 u 8 (Vista funciona incluso mejor que XP aquí - también desde el 8 de Abril del 2014 nadie debería utilizar XP ta que MS dejará de dar actualizaciones/parches)<br /> - Además, puedes utilizar Archivo -> Importar subtítulo seleccionando codificador manualmente. - </td> - </tr> - <tr> - <td>Corrector Ortográfico (NHunspell) se bloquea</td> - <td>¡Puedes cambiar el corrector ortográfico para utilizar MS Word en opciones!</td> - </tr> - <tr> - <td>Subtitle Edit no se puede ejecutar desde una unidad de red (("The publisher could not be verified")</td> - <td>Si no tienes permisos suficientes para ejecutar Subtitle Edit desde una unidad de red, cópialo en el disco duro local para obtener los permisos necesarios.</td> - </tr> - <tr> - <td>Subtitle Edit portable no funciona correctamente en la carpeta "Archivos de programa"</td> - <td>Utiliza el instalador si quieres tener Subtitle Edit en "Archivos de programa" (quita primero la versión portable)</td> - </tr> - <tr> - <td>Subtitle Edit no detecta VLC en opciones (está atenuada)</td> - <td>Necesitas VLC 2.x - y debe ser la versión de 32-bit (a menos que hayas compilado una versión propia en 64-bit del Subtitle Edit)</td> - </tr> - <tr> - <td>Tesseract no funciona correctamente...</td> - <td> - Si usaste el instalador de tesseract, entonces desinstálalo. Después de desinstalarlo, debes eliminar todavía la variable de entorno "TESSDATA_PREFIX" (ej. <a href="http://www.itechtalk.com/thread3595.html">como aquí)</a>.<br /> - Además, es posible que necesites visual studio 2008 c++ runtime: http://www.microsoft.com/en-au/download/details.aspx?id=5582 - </td> - </tr> - </tbody> -</table> -<br /> -<br /> -<hr /> - -<br /> -<br /> -<br /> -<br /> -¿No encontraste lo que necesitas? Siéntete libre de <a href="mailto:nikse.dk@gmail.com">enviarme un correo</a>.<br /> -<br /> -Además, ¡echa un vistazo a los <a href="Video">videos introductorios de Subtitle Edit</a> y al tutorial <a href="/Content/SubtitleEdit/TutorialByDny238.html">Sincronizar Subtítulos con Subtitle Edit</a> por dny238! -<br /> -<br /> -<br /> -<br />